summaryrefslogtreecommitdiff
path: root/mjit.h
blob: 8cfc3d05b7ccdabfef0c4c997a527c8c0abaf18b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#ifndef RUBY_MJIT_H
#define RUBY_MJIT_H 1
/**********************************************************************

  mjit.h - Interface to MRI method JIT compiler for Ruby's main thread

  Copyright (C) 2017 Vladimir Makarov <vmakarov@redhat.com>.

**********************************************************************/

#include "ruby/internal/config.h" // defines USE_MJIT
#include "ruby/internal/stdbool.h"
#include "vm_core.h"

# if USE_MJIT

#include "debug_counter.h"
#include "ruby.h"

// Special address values of a function generated from the
// corresponding iseq by MJIT:
enum rb_mjit_iseq_func {
    // ISEQ was not queued yet for the machine code generation
    NOT_ADDED_JIT_ISEQ_FUNC = 0,
    // ISEQ is already queued for the machine code generation but the
    // code is not ready yet for the execution
    NOT_READY_JIT_ISEQ_FUNC = 1,
    // ISEQ included not compilable insn, some internal assertion failed
    // or the unit is unloaded
    NOT_COMPILED_JIT_ISEQ_FUNC = 2,
    // End mark
    LAST_JIT_ISEQ_FUNC = 3
};

// MJIT options which can be defined on the MRI command line.
struct mjit_options {
    // Converted from "jit" feature flag to tell the enablement
    // information to ruby_show_version().
    char on;
    // Save temporary files after MRI finish.  The temporary files
    // include the pre-compiled header, C code file generated for ISEQ,
    // and the corresponding object file.
    char save_temps;
    // Print MJIT warnings to stderr.
    char warnings;
    // Disable compiler optimization and add debug symbols. It can be
    // very slow.
    char debug;
    // Add arbitrary cflags.
    char* debug_flags;
    // If not 0, all ISeqs are synchronously compiled. For testing.
    unsigned int wait;
    // Number of calls to trigger JIT compilation. For testing.
    unsigned int min_calls;
    // Force printing info about MJIT work of level VERBOSE or
    // less. 0=silence, 1=medium, 2=verbose.
    int verbose;
    // Maximal permitted number of iseq JIT codes in a MJIT memory
    // cache.
    int max_cache_size;
};

// State of optimization switches
struct rb_mjit_compile_info {
    // Disable getinstancevariable/setinstancevariable optimizations based on inline cache (T_OBJECT)
    bool disable_ivar_cache;
    // Disable getinstancevariable/setinstancevariable optimizations based on inline cache (FL_EXIVAR)
    bool disable_exivar_cache;
    // Disable send/opt_send_without_block optimizations based on inline cache
    bool disable_send_cache;
    // Disable method inlining
    bool disable_inlining;
    // Disable opt_getinlinecache inlining
    bool disable_const_cache;
};

typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);

RUBY_SYMBOL_EXPORT_BEGIN
RUBY_EXTERN struct mjit_options mjit_opts;
RUBY_EXTERN bool mjit_call_p;

extern void rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq);
extern VALUE rb_mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body);
extern struct rb_mjit_compile_info* rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body);
extern void rb_mjit_recompile_send(const rb_iseq_t *iseq);
extern void rb_mjit_recompile_ivar(const rb_iseq_t *iseq);
extern void rb_mjit_recompile_exivar(const rb_iseq_t *iseq);
extern void rb_mjit_recompile_inlining(const rb_iseq_t *iseq);
extern void rb_mjit_recompile_const(const rb_iseq_t *iseq);
RUBY_SYMBOL_EXPORT_END

extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id);
extern void mjit_init(const struct mjit_options *opts);
extern void mjit_gc_start_hook(void);
extern void mjit_gc_exit_hook(void);
extern void mjit_free_iseq(const rb_iseq_t *iseq);
extern void mjit_update_references(const rb_iseq_t *iseq);
extern void mjit_mark(void);
extern struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec);
extern void mjit_cont_free(struct mjit_cont *cont);
extern void mjit_mark_cc_entries(const struct rb_iseq_constant_body *const body);

#  ifdef MJIT_HEADER
NOINLINE(static COLDFUNC VALUE mjit_exec_slowpath(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body));
#  else
static inline VALUE mjit_exec_slowpath(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body);
#  endif
static VALUE
mjit_exec_slowpath(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body)
{
    uintptr_t func_i = (uintptr_t)(body->jit_func);
    ASSUME(func_i <= LAST_JIT_ISEQ_FUNC);
    switch ((enum rb_mjit_iseq_func)func_i) {
      case NOT_ADDED_JIT_ISEQ_FUNC:
        RB_DEBUG_COUNTER_INC(mjit_exec_not_added);
        if (body->total_calls == mjit_opts.min_calls) {
            rb_mjit_add_iseq_to_process(iseq);
            if (UNLIKELY(mjit_opts.wait)) {
                return rb_mjit_wait_call(ec, body);
            }
        }
        break;
      case NOT_READY_JIT_ISEQ_FUNC:
        RB_DEBUG_COUNTER_INC(mjit_exec_not_ready);
        break;
      case NOT_COMPILED_JIT_ISEQ_FUNC:
        RB_DEBUG_COUNTER_INC(mjit_exec_not_compiled);
        break;
      default: // to avoid warning with LAST_JIT_ISEQ_FUNC
        break;
    }
    return Qundef;
}

// Try to execute the current iseq in ec.  Use JIT code if it is ready.
// If it is not, add ISEQ to the compilation queue and return Qundef.
static inline VALUE
mjit_exec(rb_execution_context_t *ec)
{
    const rb_iseq_t *iseq;
    struct rb_iseq_constant_body *body;

    if (!mjit_call_p)
        return Qundef;
    RB_DEBUG_COUNTER_INC(mjit_exec);

    iseq = ec->cfp->iseq;
    body = iseq->body;
    body->total_calls++;

    mjit_func_t func = body->jit_func;
    if (UNLIKELY((uintptr_t)func <= LAST_JIT_ISEQ_FUNC)) {
#  ifdef MJIT_HEADER
        RB_DEBUG_COUNTER_INC(mjit_frame_JT2VM);
#  else
        RB_DEBUG_COUNTER_INC(mjit_frame_VM2VM);
#  endif
        return mjit_exec_slowpath(ec, iseq, body);
    }

#  ifdef MJIT_HEADER
    RB_DEBUG_COUNTER_INC(mjit_frame_JT2JT);
#  else
    RB_DEBUG_COUNTER_INC(mjit_frame_VM2JT);
#  endif
    RB_DEBUG_COUNTER_INC(mjit_exec_call_func);
    return func(ec, ec->cfp);
}

void mjit_child_after_fork(void);

#  ifdef MJIT_HEADER
#define mjit_enabled true
#  else // MJIT_HEADER
extern bool mjit_enabled;
#  endif // MJIT_HEADER
VALUE mjit_pause(bool wait_p);
VALUE mjit_resume(void);
void mjit_finish(bool close_handle_p);

# else // USE_MJIT

static inline struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec){return NULL;}
static inline void mjit_cont_free(struct mjit_cont *cont){}
static inline void mjit_gc_start_hook(void){}
static inline void mjit_gc_exit_hook(void){}
static inline void mjit_free_iseq(const rb_iseq_t *iseq){}
static inline void mjit_mark(void){}
static inline VALUE mjit_exec(rb_execution_context_t *ec) { return Qundef; /* unreachable */ }
static inline void mjit_child_after_fork(void){}

#define mjit_enabled false
static inline VALUE mjit_pause(bool wait_p){ return Qnil; } // unreachable
static inline VALUE mjit_resume(void){ return Qnil; } // unreachable
static inline void mjit_finish(bool close_handle_p){}

# endif // USE_MJIT
#endif // RUBY_MJIT_H
class='del'>benchmark/README.md72
-rw-r--r--benchmark/app_aobench.rb297
-rw-r--r--benchmark/app_erb.yml23
-rw-r--r--benchmark/app_pentomino.rb130
-rw-r--r--benchmark/array_flatten.yml19
-rw-r--r--benchmark/array_intersection.yml14
-rw-r--r--benchmark/array_values_at_int.rb2
-rw-r--r--benchmark/array_values_at_range.rb2
-rw-r--r--benchmark/bm_app_answer.rb (renamed from benchmark/app_answer.rb)0
-rw-r--r--benchmark/bm_app_aobench.rb291
-rw-r--r--benchmark/bm_app_erb.rb26
-rw-r--r--benchmark/bm_app_factorial.rb (renamed from benchmark/app_factorial.rb)0
-rw-r--r--benchmark/bm_app_fib.rb (renamed from benchmark/app_fib.rb)0
-rw-r--r--benchmark/bm_app_lc_fizzbuzz.rb (renamed from benchmark/app_lc_fizzbuzz.rb)0
-rw-r--r--benchmark/bm_app_mandelbrot.rb (renamed from benchmark/app_mandelbrot.rb)0
-rw-r--r--benchmark/bm_app_pentomino.rb259
-rw-r--r--benchmark/bm_app_raise.rb (renamed from benchmark/app_raise.rb)0
-rw-r--r--benchmark/bm_app_strconcat.rb (renamed from benchmark/app_strconcat.rb)0
-rw-r--r--benchmark/bm_app_tak.rb (renamed from benchmark/app_tak.rb)0
-rw-r--r--benchmark/bm_app_tarai.rb (renamed from benchmark/app_tarai.rb)0
-rw-r--r--benchmark/bm_app_uri.rb (renamed from benchmark/app_uri.rb)0
-rw-r--r--benchmark/bm_array_sample_100k_10.rb (renamed from benchmark/array_sample_100k_10.rb)0
-rw-r--r--benchmark/bm_array_sample_100k_11.rb (renamed from benchmark/array_sample_100k_11.rb)0
-rw-r--r--benchmark/bm_array_sample_100k__100.rb (renamed from benchmark/array_sample_100k__100.rb)0
-rw-r--r--benchmark/bm_array_sample_100k__1k.rb (renamed from benchmark/array_sample_100k__1k.rb)0
-rw-r--r--benchmark/bm_array_sample_100k__6k.rb (renamed from benchmark/array_sample_100k__6k.rb)0
-rw-r--r--benchmark/bm_array_sample_100k___10k.rb (renamed from benchmark/array_sample_100k___10k.rb)0
-rw-r--r--benchmark/bm_array_sample_100k___50k.rb (renamed from benchmark/array_sample_100k___50k.rb)0
-rw-r--r--benchmark/bm_array_shift.rb (renamed from benchmark/array_shift.rb)0
-rw-r--r--benchmark/bm_array_small_and.rb (renamed from benchmark/array_small_and.rb)0
-rw-r--r--benchmark/bm_array_small_diff.rb (renamed from benchmark/array_small_diff.rb)0
-rw-r--r--benchmark/bm_array_small_or.rb (renamed from benchmark/array_small_or.rb)0
-rw-r--r--benchmark/bm_array_sort_block.rb (renamed from benchmark/array_sort_block.rb)0
-rw-r--r--benchmark/bm_array_sort_float.rb (renamed from benchmark/array_sort_float.rb)0
-rw-r--r--benchmark/bm_bighash.rb (renamed from benchmark/bighash.rb)0
-rw-r--r--benchmark/bm_dir_empty_p.rb (renamed from benchmark/dir_empty_p.rb)0
-rw-r--r--benchmark/bm_erb_render.rb26
-rw-r--r--benchmark/bm_file_chmod.rb (renamed from benchmark/file_chmod.rb)0
-rw-r--r--benchmark/bm_file_rename.rb11
-rw-r--r--benchmark/bm_hash_aref_dsym.rb (renamed from benchmark/hash_aref_dsym.rb)0
-rw-r--r--benchmark/bm_hash_aref_dsym_long.rb (renamed from benchmark/hash_aref_dsym_long.rb)0
-rw-r--r--benchmark/bm_hash_aref_fix.rb (renamed from benchmark/hash_aref_fix.rb)0
-rw-r--r--benchmark/bm_hash_aref_flo.rb (renamed from benchmark/hash_aref_flo.rb)0
-rw-r--r--benchmark/bm_hash_aref_miss.rb (renamed from benchmark/hash_aref_miss.rb)0
-rw-r--r--benchmark/bm_hash_aref_str.rb (renamed from benchmark/hash_aref_str.rb)0
-rw-r--r--benchmark/bm_hash_aref_sym.rb (renamed from benchmark/hash_aref_sym.rb)0
-rw-r--r--benchmark/bm_hash_aref_sym_long.rb (renamed from benchmark/hash_aref_sym_long.rb)0
-rw-r--r--benchmark/bm_hash_flatten.rb (renamed from benchmark/hash_flatten.rb)0
-rw-r--r--benchmark/bm_hash_ident_flo.rb (renamed from benchmark/hash_ident_flo.rb)0
-rw-r--r--benchmark/bm_hash_ident_num.rb (renamed from benchmark/hash_ident_num.rb)0
-rw-r--r--benchmark/bm_hash_ident_obj.rb (renamed from benchmark/hash_ident_obj.rb)0
-rw-r--r--benchmark/bm_hash_ident_str.rb (renamed from benchmark/hash_ident_str.rb)0
-rw-r--r--benchmark/bm_hash_ident_sym.rb (renamed from benchmark/hash_ident_sym.rb)0
-rw-r--r--benchmark/bm_hash_keys.rb (renamed from benchmark/hash_keys.rb)0
-rw-r--r--benchmark/bm_hash_long.rb (renamed from benchmark/hash_long.rb)0
-rw-r--r--benchmark/bm_hash_shift.rb (renamed from benchmark/hash_shift.rb)0
-rw-r--r--benchmark/bm_hash_shift_u16.rb (renamed from benchmark/hash_shift_u16.rb)0
-rw-r--r--benchmark/bm_hash_shift_u24.rb (renamed from benchmark/hash_shift_u24.rb)0
-rw-r--r--benchmark/bm_hash_shift_u32.rb (renamed from benchmark/hash_shift_u32.rb)0
-rw-r--r--benchmark/bm_hash_small2.rb (renamed from benchmark/hash_small2.rb)0
-rw-r--r--benchmark/bm_hash_small4.rb (renamed from benchmark/hash_small4.rb)0
-rw-r--r--benchmark/bm_hash_small8.rb (renamed from benchmark/hash_small8.rb)0
-rw-r--r--benchmark/bm_hash_to_proc.rb (renamed from benchmark/hash_to_proc.rb)0
-rw-r--r--benchmark/bm_hash_values.rb (renamed from benchmark/hash_values.rb)0
-rw-r--r--benchmark/bm_int_quo.rb (renamed from benchmark/int_quo.rb)0
-rw-r--r--benchmark/bm_io_copy_stream_write.rb (renamed from benchmark/io_copy_stream_write.rb)0
-rw-r--r--benchmark/bm_io_copy_stream_write_socket.rb (renamed from benchmark/io_copy_stream_write_socket.rb)0
-rw-r--r--benchmark/bm_io_file_create.rb (renamed from benchmark/io_file_create.rb)0
-rw-r--r--benchmark/bm_io_file_read.rb (renamed from benchmark/io_file_read.rb)0
-rw-r--r--benchmark/bm_io_file_write.rb (renamed from benchmark/io_file_write.rb)0
-rw-r--r--benchmark/bm_io_nonblock_noex.rb (renamed from benchmark/io_nonblock_noex.rb)0
-rw-r--r--benchmark/bm_io_nonblock_noex2.rb (renamed from benchmark/io_nonblock_noex2.rb)0
-rw-r--r--benchmark/bm_io_pipe_rw.rb (renamed from benchmark/io_pipe_rw.rb)0
-rw-r--r--benchmark/bm_io_select.rb (renamed from benchmark/io_select.rb)0
-rw-r--r--benchmark/bm_io_select2.rb (renamed from benchmark/io_select2.rb)0
-rw-r--r--benchmark/bm_io_select3.rb (renamed from benchmark/io_select3.rb)0
-rw-r--r--benchmark/bm_loop_for.rb (renamed from benchmark/loop_for.rb)0
-rw-r--r--benchmark/bm_loop_generator.rb (renamed from benchmark/loop_generator.rb)0
-rw-r--r--benchmark/bm_loop_times.rb (renamed from benchmark/loop_times.rb)0
-rw-r--r--benchmark/bm_loop_whileloop.rb (renamed from benchmark/loop_whileloop.rb)0
-rw-r--r--benchmark/bm_loop_whileloop2.rb (renamed from benchmark/loop_whileloop2.rb)0
-rw-r--r--benchmark/bm_marshal_dump_flo.rb (renamed from benchmark/marshal_dump_flo.rb)0
-rw-r--r--benchmark/bm_marshal_dump_load_geniv.rb (renamed from benchmark/marshal_dump_load_geniv.rb)0
-rw-r--r--benchmark/bm_marshal_dump_load_time.rb (renamed from benchmark/marshal_dump_load_time.rb)0
-rw-r--r--benchmark/bm_require.rb7
-rw-r--r--benchmark/bm_require_thread.rb15
-rw-r--r--benchmark/bm_securerandom.rb (renamed from benchmark/securerandom.rb)0
-rw-r--r--benchmark/bm_so_ackermann.rb19
-rw-r--r--benchmark/bm_so_array.rb23
-rw-r--r--benchmark/bm_so_binary_trees.rb (renamed from benchmark/so_binary_trees.rb)0
-rw-r--r--benchmark/bm_so_concatenate.rb18
-rw-r--r--benchmark/bm_so_count_words.rb19
-rw-r--r--benchmark/bm_so_exception.rb61
-rw-r--r--benchmark/bm_so_fannkuch.rb (renamed from benchmark/so_fannkuch.rb)0
-rw-r--r--benchmark/bm_so_fasta.rb (renamed from benchmark/so_fasta.rb)0
-rw-r--r--benchmark/bm_so_k_nucleotide.rb48
-rw-r--r--benchmark/bm_so_lists.rb (renamed from benchmark/so_lists.rb)0
-rw-r--r--benchmark/bm_so_mandelbrot.rb (renamed from benchmark/so_mandelbrot.rb)0
-rw-r--r--benchmark/bm_so_matrix.rb48
-rwxr-xr-x[-rw-r--r--]benchmark/bm_so_meteor_contest.rb (renamed from benchmark/so_meteor_contest.rb)0
-rw-r--r--benchmark/bm_so_nbody.rb (renamed from benchmark/so_nbody.rb)0
-rw-r--r--benchmark/bm_so_nested_loop.rb24
-rw-r--r--benchmark/bm_so_nsieve.rb (renamed from benchmark/so_nsieve.rb)0
-rw-r--r--benchmark/bm_so_nsieve_bits.rb (renamed from benchmark/so_nsieve_bits.rb)0
-rw-r--r--benchmark/bm_so_object.rb56
-rw-r--r--benchmark/bm_so_partial_sums.rb (renamed from benchmark/so_partial_sums.rb)0
-rw-r--r--benchmark/bm_so_pidigits.rb (renamed from benchmark/so_pidigits.rb)0
-rw-r--r--benchmark/bm_so_random.rb (renamed from benchmark/so_random.rb)0
-rw-r--r--benchmark/bm_so_reverse_complement.rb30
-rw-r--r--benchmark/bm_so_sieve.rb (renamed from benchmark/so_sieve.rb)0
-rw-r--r--benchmark/bm_so_spectralnorm.rb (renamed from benchmark/so_spectralnorm.rb)0
-rw-r--r--benchmark/bm_string_index.rb (renamed from benchmark/string_index.rb)0
-rw-r--r--benchmark/bm_string_scan_re.rb (renamed from benchmark/string_scan_re.rb)0
-rw-r--r--benchmark/bm_string_scan_str.rb (renamed from benchmark/string_scan_str.rb)0
-rw-r--r--benchmark/bm_time_subsec.rb (renamed from benchmark/time_subsec.rb)0
-rw-r--r--benchmark/bm_vm1_attr_ivar.rb14
-rw-r--r--benchmark/bm_vm1_attr_ivar_set.rb14
-rw-r--r--benchmark/bm_vm1_block.rb10
-rwxr-xr-xbenchmark/bm_vm1_blockparam.rb9
-rwxr-xr-xbenchmark/bm_vm1_blockparam_call.rb9
-rwxr-xr-xbenchmark/bm_vm1_blockparam_pass.rb13
-rwxr-xr-xbenchmark/bm_vm1_blockparam_yield.rb9
-rw-r--r--benchmark/bm_vm1_const.rb8
-rw-r--r--benchmark/bm_vm1_ensure.rb11
-rw-r--r--benchmark/bm_vm1_float_simple.rb7
-rw-r--r--benchmark/bm_vm1_gc_short_lived.rb10
-rw-r--r--benchmark/bm_vm1_gc_short_with_complex_long.rb27
-rw-r--r--benchmark/bm_vm1_gc_short_with_long.rb13
-rw-r--r--benchmark/bm_vm1_gc_short_with_symbol.rb15
-rw-r--r--benchmark/bm_vm1_gc_wb_ary.rb12
-rw-r--r--benchmark/bm_vm1_gc_wb_ary_promoted.rb14
-rw-r--r--benchmark/bm_vm1_gc_wb_obj.rb15
-rw-r--r--benchmark/bm_vm1_gc_wb_obj_promoted.rb17
-rw-r--r--benchmark/bm_vm1_ivar.rb8
-rw-r--r--benchmark/bm_vm1_ivar_set.rb6
-rw-r--r--benchmark/bm_vm1_length.rb9
-rw-r--r--benchmark/bm_vm1_lvar_init.rb18
-rw-r--r--benchmark/bm_vm1_lvar_set.rb5
-rw-r--r--benchmark/bm_vm1_neq.rb8
-rw-r--r--benchmark/bm_vm1_not.rb7
-rw-r--r--benchmark/bm_vm1_rescue.rb7
-rw-r--r--benchmark/bm_vm1_simplereturn.rb9
-rw-r--r--benchmark/bm_vm1_swap.rb8
-rw-r--r--benchmark/bm_vm1_yield.rb10
-rw-r--r--benchmark/bm_vm2_array.rb5
-rw-r--r--benchmark/bm_vm2_bigarray.rb106
-rw-r--r--benchmark/bm_vm2_bighash.rb5
-rw-r--r--benchmark/bm_vm2_case.rb14
-rw-r--r--benchmark/bm_vm2_case_lit.rb19
-rw-r--r--benchmark/bm_vm2_defined_method.rb9
-rw-r--r--benchmark/bm_vm2_dstr.rb6
-rw-r--r--benchmark/bm_vm2_eval.rb6
-rw-r--r--benchmark/bm_vm2_fiber_switch.rb9
-rw-r--r--benchmark/bm_vm2_method.rb9
-rw-r--r--benchmark/bm_vm2_method_missing.rb12
-rw-r--r--benchmark/bm_vm2_method_with_block.rb9
-rw-r--r--benchmark/bm_vm2_module_ann_const_set.rb5
-rw-r--r--benchmark/bm_vm2_module_const_set.rb8
-rw-r--r--benchmark/bm_vm2_mutex.rb9
-rw-r--r--benchmark/bm_vm2_newlambda.rb5
-rw-r--r--benchmark/bm_vm2_poly_method.rb20
-rw-r--r--benchmark/bm_vm2_poly_method_ov.rb20
-rw-r--r--benchmark/bm_vm2_poly_singleton.rb14
-rw-r--r--benchmark/bm_vm2_proc.rb14
-rw-r--r--benchmark/bm_vm2_raise1.rb18
-rw-r--r--benchmark/bm_vm2_raise2.rb18
-rw-r--r--benchmark/bm_vm2_regexp.rb6
-rw-r--r--benchmark/bm_vm2_send.rb12
-rw-r--r--benchmark/bm_vm2_string_literal.rb5
-rw-r--r--benchmark/bm_vm2_struct_big_aref_hi.rb7
-rw-r--r--benchmark/bm_vm2_struct_big_aref_lo.rb7
-rw-r--r--benchmark/bm_vm2_struct_big_aset.rb7
-rw-r--r--benchmark/bm_vm2_struct_big_href_hi.rb7
-rw-r--r--benchmark/bm_vm2_struct_big_href_lo.rb7
-rw-r--r--benchmark/bm_vm2_struct_big_hset.rb7
-rw-r--r--benchmark/bm_vm2_struct_small_aref.rb7
-rw-r--r--benchmark/bm_vm2_struct_small_aset.rb7
-rw-r--r--benchmark/bm_vm2_struct_small_href.rb7
-rw-r--r--benchmark/bm_vm2_struct_small_hset.rb7
-rw-r--r--benchmark/bm_vm2_super.rb20
-rw-r--r--benchmark/bm_vm2_unif1.rb8
-rw-r--r--benchmark/bm_vm2_zsuper.rb20
-rw-r--r--benchmark/bm_vm3_backtrace.rb (renamed from benchmark/vm3_backtrace.rb)0
-rw-r--r--benchmark/bm_vm3_clearmethodcache.rb (renamed from benchmark/vm3_clearmethodcache.rb)0
-rw-r--r--benchmark/bm_vm3_gc.rb (renamed from benchmark/vm3_gc.rb)0
-rw-r--r--benchmark/bm_vm3_gc_old_full.rb (renamed from benchmark/vm3_gc_old_full.rb)0
-rw-r--r--benchmark/bm_vm3_gc_old_immediate.rb (renamed from benchmark/vm3_gc_old_immediate.rb)0
-rw-r--r--benchmark/bm_vm3_gc_old_lazy.rb (renamed from benchmark/vm3_gc_old_lazy.rb)0
-rw-r--r--benchmark/bm_vm_symbol_block_pass.rb (renamed from benchmark/vm_symbol_block_pass.rb)0
-rw-r--r--benchmark/bm_vm_thread_alive_check1.rb6
-rw-r--r--benchmark/bm_vm_thread_close.rb (renamed from benchmark/vm_thread_close.rb)0
-rw-r--r--benchmark/bm_vm_thread_condvar1.rb (renamed from benchmark/vm_thread_condvar1.rb)0
-rw-r--r--benchmark/bm_vm_thread_condvar2.rb (renamed from benchmark/vm_thread_condvar2.rb)0
-rw-r--r--benchmark/bm_vm_thread_create_join.rb (renamed from benchmark/vm_thread_create_join.rb)0
-rw-r--r--benchmark/bm_vm_thread_mutex1.rb (renamed from benchmark/vm_thread_mutex1.rb)0
-rw-r--r--benchmark/bm_vm_thread_mutex2.rb (renamed from benchmark/vm_thread_mutex2.rb)0
-rw-r--r--benchmark/bm_vm_thread_mutex3.rb (renamed from benchmark/vm_thread_mutex3.rb)0
-rw-r--r--benchmark/bm_vm_thread_pass.rb15
-rw-r--r--benchmark/bm_vm_thread_pass_flood.rb10
-rw-r--r--benchmark/bm_vm_thread_pipe.rb (renamed from benchmark/vm_thread_pipe.rb)0
-rw-r--r--benchmark/bm_vm_thread_queue.rb18
-rw-r--r--benchmark/bm_vm_thread_sized_queue.rb (renamed from benchmark/vm_thread_sized_queue.rb)0
-rw-r--r--benchmark/bm_vm_thread_sized_queue2.rb (renamed from benchmark/vm_thread_sized_queue2.rb)0
-rw-r--r--benchmark/bm_vm_thread_sized_queue3.rb (renamed from benchmark/vm_thread_sized_queue3.rb)0
-rw-r--r--benchmark/bm_vm_thread_sized_queue4.rb (renamed from benchmark/vm_thread_sized_queue4.rb)0
-rw-r--r--benchmark/cgi_escape_html.yml40
-rw-r--r--benchmark/complex_float_add.yml7
-rw-r--r--benchmark/complex_float_div.yml7
-rw-r--r--benchmark/complex_float_mul.yml7
-rw-r--r--benchmark/complex_float_new.yml7
-rw-r--r--benchmark/complex_float_power.yml7
-rw-r--r--benchmark/complex_float_sub.yml7
-rwxr-xr-xbenchmark/driver.rb441
-rw-r--r--benchmark/enum_lazy_grep_v_100.rb4
-rw-r--r--benchmark/enum_lazy_grep_v_20.rb4
-rw-r--r--benchmark/enum_lazy_grep_v_50.rb4
-rw-r--r--benchmark/enum_lazy_uniq_100.rb4
-rw-r--r--benchmark/enum_lazy_uniq_20.rb4
-rw-r--r--benchmark/enum_lazy_uniq_50.rb4
-rw-r--r--benchmark/erb_render.yml24
-rwxr-xr-xbenchmark/fiber_chain.yml36
-rw-r--r--benchmark/file_rename.rb11
-rw-r--r--benchmark/gc/aobench.rb2
-rw-r--r--benchmark/gc/binary_trees.rb2
-rw-r--r--benchmark/gc/gcbench.rb3
-rw-r--r--benchmark/gc/pentomino.rb2
-rw-r--r--benchmark/hash_dup.yml8
-rw-r--r--benchmark/hash_literal_small2.rb3
-rw-r--r--benchmark/hash_literal_small4.rb3
-rw-r--r--benchmark/hash_literal_small8.rb3
-rw-r--r--benchmark/irb_color.yml13
-rw-r--r--benchmark/irb_exec.yml10
-rw-r--r--benchmark/lib/benchmark_driver/output/driver.rb36
-rw-r--r--benchmark/lib/benchmark_driver/runner/cstime.rb22
-rw-r--r--benchmark/lib/benchmark_driver/runner/cutime.rb22
-rw-r--r--benchmark/lib/benchmark_driver/runner/mjit_exec.rb237
-rw-r--r--benchmark/lib/benchmark_driver/runner/peak.rb151
-rw-r--r--benchmark/lib/benchmark_driver/runner/size.rb25
-rw-r--r--benchmark/lib/benchmark_driver/runner/stime.rb22
-rw-r--r--benchmark/lib/benchmark_driver/runner/total.rb137
-rw-r--r--benchmark/lib/benchmark_driver/runner/utime.rb22
-rw-r--r--benchmark/lib/load.rb18
-rw-r--r--benchmark/make_fasta_output.rb19
-rw-r--r--benchmark/match_gt4.rb1
-rw-r--r--benchmark/match_small.rb1
-rw-r--r--benchmark/memory_wrapper.rb16
-rw-r--r--benchmark/mjit_exec_jt2jt.yml8
-rw-r--r--benchmark/mjit_exec_vm2jt.yml8
-rw-r--r--benchmark/mjit_exec_vm2vm.yml8
-rw-r--r--benchmark/nil_p.yml9
-rw-r--r--benchmark/other-lang/fact.py2
-rw-r--r--benchmark/prepare_require.rb25
-rw-r--r--benchmark/prepare_require_thread.rb2
-rw-r--r--benchmark/prepare_so_count_words.rb15
-rw-r--r--benchmark/prepare_so_k_nucleotide.rb2
-rw-r--r--benchmark/prepare_so_reverse_complement.rb2
-rw-r--r--benchmark/range_last.yml4
-rw-r--r--benchmark/realpath.yml30
-rw-r--r--benchmark/report.rb79
-rw-r--r--benchmark/require.yml32
-rw-r--r--benchmark/require_thread.yml40
-rw-r--r--benchmark/run.rb127
-rw-r--r--benchmark/runc.rb27
-rw-r--r--benchmark/so_ackermann.rb19
-rw-r--r--benchmark/so_array.rb23
-rw-r--r--benchmark/so_concatenate.rb18
-rw-r--r--benchmark/so_count_words.yml65
-rw-r--r--benchmark/so_exception.rb61
-rw-r--r--benchmark/so_k_nucleotide.yml155
-rw-r--r--benchmark/so_matrix.rb48
-rw-r--r--benchmark/so_nested_loop.rb24
-rw-r--r--benchmark/so_object.rb56
-rw-r--r--benchmark/so_reverse_complement.yml137
-rw-r--r--benchmark/string_capitalize.yml10
-rw-r--r--benchmark/string_downcase.yml10
-rw-r--r--benchmark/string_split.yml7
-rw-r--r--benchmark/string_swapcase.yml10
-rw-r--r--benchmark/string_upcase.yml10
-rw-r--r--benchmark/time_strptime.yml13
-rw-r--r--benchmark/vm1_attr_ivar.yml14
-rw-r--r--benchmark/vm1_attr_ivar_set.yml14
-rw-r--r--benchmark/vm1_block.yml9
-rw-r--r--benchmark/vm1_blockparam.yml7
-rw-r--r--benchmark/vm1_blockparam_call.yml8
-rw-r--r--benchmark/vm1_blockparam_pass.yml12
-rw-r--r--benchmark/vm1_blockparam_yield.yml8
-rw-r--r--benchmark/vm1_const.yml7
-rw-r--r--benchmark/vm1_ensure.yml14
-rw-r--r--benchmark/vm1_float_simple.yml8
-rw-r--r--benchmark/vm1_gc_short_lived.yml9
-rw-r--r--benchmark/vm1_gc_short_with_complex_long.yml25
-rw-r--r--benchmark/vm1_gc_short_with_long.yml13
-rw-r--r--benchmark/vm1_gc_short_with_symbol.yml13
-rw-r--r--benchmark/vm1_gc_wb_ary.yml12
-rw-r--r--benchmark/vm1_gc_wb_ary_promoted.yml15
-rw-r--r--benchmark/vm1_gc_wb_obj.yml15
-rw-r--r--benchmark/vm1_gc_wb_obj_promoted.yml17
-rw-r--r--benchmark/vm1_ivar.yml6
-rw-r--r--benchmark/vm1_ivar_set.yml5
-rw-r--r--benchmark/vm1_length.yml8
-rw-r--r--benchmark/vm1_lvar_init.yml21
-rw-r--r--benchmark/vm1_lvar_set.yml4
-rw-r--r--benchmark/vm1_neq.yml7
-rw-r--r--benchmark/vm1_not.yml6
-rw-r--r--benchmark/vm1_rescue.yml6
-rw-r--r--benchmark/vm1_simplereturn.yml7
-rw-r--r--benchmark/vm1_swap.yml7
-rw-r--r--benchmark/vm1_yield.yml13
-rw-r--r--benchmark/vm2_array.yml4
-rw-r--r--benchmark/vm2_bigarray.yml105
-rw-r--r--benchmark/vm2_bighash.yml4
-rw-r--r--benchmark/vm2_case.yml13
-rw-r--r--benchmark/vm2_case_lit.yml23
-rw-r--r--benchmark/vm2_defined_method.yml8
-rw-r--r--benchmark/vm2_dstr.yml6
-rw-r--r--benchmark/vm2_eval.yml4
-rw-r--r--benchmark/vm2_fiber_allocate.yml8
-rw-r--r--benchmark/vm2_fiber_count.yml10
-rw-r--r--benchmark/vm2_fiber_reuse.yml14
-rw-r--r--benchmark/vm2_fiber_reuse_gc.yml12
-rw-r--r--benchmark/vm2_fiber_switch.yml9
-rw-r--r--benchmark/vm2_freezestring.yml10
-rw-r--r--benchmark/vm2_method.yml8
-rw-r--r--benchmark/vm2_method_missing.yml11
-rw-r--r--benchmark/vm2_method_with_block.yml8
-rw-r--r--benchmark/vm2_module_ann_const_set.yml4
-rw-r--r--benchmark/vm2_module_const_set.yml8
-rw-r--r--benchmark/vm2_mutex.yml8
-rw-r--r--benchmark/vm2_newlambda.yml4
-rw-r--r--benchmark/vm2_poly_method.yml24
-rw-r--r--benchmark/vm2_poly_method_ov.yml24
-rw-r--r--benchmark/vm2_poly_same_method.yml25
-rw-r--r--benchmark/vm2_poly_singleton.yml18
-rw-r--r--benchmark/vm2_proc.yml12
-rw-r--r--benchmark/vm2_raise1.yml16
-rw-r--r--benchmark/vm2_raise2.yml16
-rw-r--r--benchmark/vm2_regexp.yml8
-rw-r--r--benchmark/vm2_send.yml11
-rw-r--r--benchmark/vm2_string_literal.yml4
-rw-r--r--benchmark/vm2_struct_big_aref_hi.yml7
-rw-r--r--benchmark/vm2_struct_big_aref_lo.yml7
-rw-r--r--benchmark/vm2_struct_big_aset.yml11
-rw-r--r--benchmark/vm2_struct_big_href_hi.yml7
-rw-r--r--benchmark/vm2_struct_big_href_lo.yml7
-rw-r--r--benchmark/vm2_struct_big_hset.yml11
-rw-r--r--benchmark/vm2_struct_small_aref.yml7
-rw-r--r--benchmark/vm2_struct_small_aset.yml11
-rw-r--r--benchmark/vm2_struct_small_href.yml7
-rw-r--r--benchmark/vm2_struct_small_hset.yml7
-rw-r--r--benchmark/vm2_super.yml17
-rw-r--r--benchmark/vm2_unif1.yml7
-rw-r--r--benchmark/vm2_zsuper.yml18
-rw-r--r--benchmark/vm_thread_alive_check.yml8
-rw-r--r--benchmark/vm_thread_pass.rb15
-rw-r--r--benchmark/vm_thread_pass_flood.rb10
-rw-r--r--benchmark/vm_thread_queue.rb18
-rw-r--r--benchmark/vm_thread_sleep.yml4
-rw-r--r--benchmark/wc.input.base25
-rw-r--r--bignum.c250
-rwxr-xr-xbin/bundle27
-rwxr-xr-xbin/bundler27
-rwxr-xr-xbin/erb15
-rwxr-xr-xbin/irb28
-rwxr-xr-xbin/racc27
-rwxr-xr-xbin/racc2y27
-rwxr-xr-xbin/rdoc53
-rwxr-xr-xbin/ri31
-rwxr-xr-xbin/y2racc27
-rw-r--r--bootstraptest/pending.rb5
-rwxr-xr-xbootstraptest/runner.rb47
-rw-r--r--bootstraptest/test_eval.rb3
-rw-r--r--bootstraptest/test_exception.rb2
-rw-r--r--bootstraptest/test_fiber.rb39
-rw-r--r--bootstraptest/test_fork.rb4
-rw-r--r--bootstraptest/test_insns.rb113
-rw-r--r--bootstraptest/test_jump.rb7
-rw-r--r--bootstraptest/test_literal_suffix.rb6
-rw-r--r--bootstraptest/test_objectspace.rb9
-rw-r--r--bootstraptest/test_proc.rb4
-rw-r--r--bootstraptest/test_thread.rb24
-rw-r--r--builtin.c69
-rw-r--r--builtin.h78
-rw-r--r--ccan/list/list.h33
-rw-r--r--class.c499
-rw-r--r--common.mk1203
-rw-r--r--compar.c105
-rw-r--r--compile.c6061
-rw-r--r--complex.c777
-rw-r--r--configure.ac1907
-rw-r--r--constant.h9
-rw-r--r--cont.c2380
-rw-r--r--coroutine/amd64/Context.S46
-rw-r--r--coroutine/amd64/Context.h52
-rw-r--r--coroutine/arm32/Context.S29
-rw-r--r--coroutine/arm32/Context.h51
-rw-r--r--coroutine/arm64/Context.S62
-rw-r--r--coroutine/arm64/Context.h50
-rw-r--r--coroutine/copy/Context.c162
-rw-r--r--coroutine/copy/Context.h86
-rw-r--r--coroutine/ppc64le/Context.S75
-rw-r--r--coroutine/ppc64le/Context.h49
-rw-r--r--coroutine/ucontext/Context.c22
-rw-r--r--coroutine/ucontext/Context.h70
-rw-r--r--coroutine/win32/Context.S47
-rw-r--r--coroutine/win32/Context.asm55
-rw-r--r--coroutine/win32/Context.h57
-rw-r--r--coroutine/win64/Context.S77
-rw-r--r--coroutine/win64/Context.asm79
-rw-r--r--coroutine/win64/Context.h67
-rw-r--r--coroutine/x86/Context.S42
-rw-r--r--coroutine/x86/Context.h53
-rw-r--r--coverage/README2
-rw-r--r--debug.c3
-rw-r--r--debug_counter.c106
-rw-r--r--debug_counter.h305
-rw-r--r--defs/gmake.mk242
-rw-r--r--defs/id.def29
-rw-r--r--defs/keywords2
-rw-r--r--defs/known_errors.def251
-rw-r--r--defs/lex.c.src2
-rw-r--r--defs/separated_version.mk2
-rw-r--r--defs/universal.mk5
-rw-r--r--dir.c420
-rw-r--r--dln.c28
-rw-r--r--dmydln.c2
-rw-r--r--doc/ChangeLog-0.60_to_1.14
-rw-r--r--doc/ChangeLog-1.8.02
-rw-r--r--doc/ChangeLog-2.4.02
-rw-r--r--doc/ChangeLog-20166
-rw-r--r--doc/NEWS-1.9.22
-rw-r--r--doc/NEWS-2.0.03
-rw-r--r--doc/NEWS-2.5.0565
-rw-r--r--doc/NEWS-2.6.0662
-rw-r--r--doc/bug_triaging.rdoc79
-rw-r--r--doc/contributing.rdoc137
-rw-r--r--doc/contributors.rdoc4
-rw-r--r--doc/etc.rd.ja75
-rw-r--r--doc/extension.ja.rdoc29
-rw-r--r--doc/extension.rdoc194
-rw-r--r--doc/globals.rdoc90
-rw-r--r--doc/irb/irb.rd.ja75
-rw-r--r--doc/keywords.rdoc8
-rw-r--r--doc/maintainers.rdoc228
-rw-r--r--doc/regexp.rdoc36
-rw-r--r--doc/security.rdoc13
-rw-r--r--doc/shell.rd.ja335
-rw-r--r--doc/signals.rdoc106
-rw-r--r--doc/standard_library.rdoc64
-rw-r--r--doc/syntax.rdoc2
-rw-r--r--doc/syntax/assignment.rdoc27
-rw-r--r--doc/syntax/calling_methods.rdoc63
-rw-r--r--doc/syntax/comments.rdoc37
-rw-r--r--doc/syntax/control_expressions.rdoc62
-rw-r--r--doc/syntax/exceptions.rdoc9
-rw-r--r--doc/syntax/literals.rdoc34
-rw-r--r--doc/syntax/methods.rdoc194
-rw-r--r--doc/syntax/miscellaneous.rdoc2
-rw-r--r--doc/syntax/modules_and_classes.rdoc38
-rw-r--r--doc/syntax/precedence.rdoc6
-rw-r--r--doc/syntax/refinements.rdoc13
-rw-r--r--enc/cesu_8.c454
-rw-r--r--enc/depend118
-rw-r--r--enc/gb2312.c4
-rwxr-xr-xenc/make_encmake.rb12
-rw-r--r--enc/trans/JIS/JISX0212%UCS.src2
-rw-r--r--enc/trans/JIS/UCS%JISX0212.src2
-rw-r--r--enc/trans/cesu_8.trans85
-rw-r--r--enc/unicode.c27
-rw-r--r--enc/unicode/10.0.0/casefold.h7044
-rw-r--r--enc/unicode/10.0.0/name2ctype.h38381
-rw-r--r--enc/unicode/12.1.0/casefold.h7428
-rw-r--r--enc/unicode/12.1.0/name2ctype.h41810
-rwxr-xr-xenc/unicode/case-folding.rb7
-rw-r--r--enc/x_emoji.h4
-rw-r--r--encoding.c107
-rw-r--r--enum.c384
-rw-r--r--enumerator.c2058
-rw-r--r--error.c680
-rw-r--r--eval.c416
-rw-r--r--eval_error.c181
-rw-r--r--eval_intern.h35
-rw-r--r--eval_jump.c14
-rw-r--r--ext/-test-/arith_seq/extract/depend13
-rw-r--r--ext/-test-/arith_seq/extract/extconf.rb2
-rw-r--r--ext/-test-/arith_seq/extract/extract.c27
-rw-r--r--ext/-test-/array/resize/depend1
-rw-r--r--ext/-test-/bignum/depend51
-rw-r--r--ext/-test-/bug-14834/bug-14384.c39
-rw-r--r--ext/-test-/bug-14834/depend14
-rw-r--r--ext/-test-/bug-14834/extconf.rb2
-rw-r--r--ext/-test-/bug-3571/bug.c2
-rw-r--r--ext/-test-/bug-3571/depend14
-rw-r--r--ext/-test-/bug-5832/depend14
-rw-r--r--ext/-test-/bug_reporter/depend14
-rw-r--r--ext/-test-/class/depend4
-rw-r--r--ext/-test-/cxxanyargs/cxxanyargs.cpp619
-rw-r--r--ext/-test-/cxxanyargs/depend25
-rw-r--r--ext/-test-/cxxanyargs/extconf.rb33
-rw-r--r--ext/-test-/cxxanyargs/failure.cpp13
-rw-r--r--ext/-test-/cxxanyargs/failurem1.cpp13
-rw-r--r--ext/-test-/debug/depend5
-rw-r--r--ext/-test-/enumerator_kw/depend14
-rw-r--r--ext/-test-/enumerator_kw/enumerator_kw.c21
-rw-r--r--ext/-test-/enumerator_kw/extconf.rb1
-rw-r--r--ext/-test-/exception/depend10
-rw-r--r--ext/-test-/exception/enc_raise.c2
-rw-r--r--ext/-test-/fatal/depend14
-rw-r--r--ext/-test-/file/depend5
-rw-r--r--ext/-test-/float/depend31
-rw-r--r--ext/-test-/funcall/depend14
-rw-r--r--ext/-test-/funcall/funcall.c32
-rw-r--r--ext/-test-/gvl/call_without_gvl/call_without_gvl.c42
-rw-r--r--ext/-test-/gvl/call_without_gvl/depend1
-rw-r--r--ext/-test-/hash/depend26
-rw-r--r--ext/-test-/integer/depend13
-rw-r--r--ext/-test-/iseq_load/depend14
-rw-r--r--ext/-test-/iter/break.c4
-rw-r--r--ext/-test-/iter/depend38
-rw-r--r--ext/-test-/iter/yield.c2
-rw-r--r--ext/-test-/load/protect/depend14
-rw-r--r--ext/-test-/marshal/compat/depend14
-rw-r--r--ext/-test-/marshal/internal_ivar/depend14
-rw-r--r--ext/-test-/marshal/internal_ivar/internal_ivar.c15
-rw-r--r--ext/-test-/marshal/usr/depend14
-rw-r--r--ext/-test-/memory_status/depend14
-rw-r--r--ext/-test-/memory_status/memory_status.c4
-rw-r--r--ext/-test-/method/depend26
-rw-r--r--ext/-test-/notimplement/bug.c2
-rw-r--r--ext/-test-/notimplement/depend14
-rw-r--r--ext/-test-/num2int/depend14
-rw-r--r--ext/-test-/path_to_class/depend14
-rw-r--r--ext/-test-/popen_deadlock/depend14
-rw-r--r--ext/-test-/postponed_job/depend16
-rw-r--r--ext/-test-/postponed_job/postponed_job.c18
-rw-r--r--ext/-test-/printf/depend20
-rw-r--r--ext/-test-/proc/depend38
-rw-r--r--ext/-test-/rational/depend7
-rw-r--r--ext/-test-/rb_call_super_kw/depend14
-rw-r--r--ext/-test-/rb_call_super_kw/extconf.rb1
-rw-r--r--ext/-test-/rb_call_super_kw/rb_call_super_kw.c14
-rw-r--r--ext/-test-/recursion/depend14
-rw-r--r--ext/-test-/regexp/depend27
-rw-r--r--ext/-test-/scan_args/depend14
-rwxr-xr-x[-rw-r--r--]ext/-test-/scan_args/extconf.rb0
-rw-r--r--ext/-test-/scan_args/scan_args.c31
-rw-r--r--ext/-test-/st/foreach/depend14
-rw-r--r--ext/-test-/st/foreach/foreach.c2
-rw-r--r--ext/-test-/st/numhash/depend14
-rw-r--r--ext/-test-/st/numhash/numhash.c3
-rw-r--r--ext/-test-/st/update/depend14
-rw-r--r--ext/-test-/string/coderange.c2
-rw-r--r--ext/-test-/string/cstr.c1
-rw-r--r--ext/-test-/string/depend50
-rw-r--r--ext/-test-/struct/depend12
-rw-r--r--ext/-test-/symbol/depend26
-rw-r--r--ext/-test-/symbol/init.c8
-rw-r--r--ext/-test-/thread_fd_close/depend5
-rw-r--r--ext/-test-/time/depend38
-rw-r--r--ext/-test-/time/leap_second.c15
-rw-r--r--ext/-test-/tracepoint/depend2
-rw-r--r--ext/-test-/tracepoint/gc_hook.c10
-rw-r--r--ext/-test-/typeddata/depend14
-rw-r--r--ext/-test-/vm/depend1
-rw-r--r--ext/-test-/wait_for_single_fd/depend1
-rw-r--r--ext/-test-/wait_for_single_fd/extconf.rb2
-rw-r--r--ext/-test-/wait_for_single_fd/wait_for_single_fd.c64
-rw-r--r--ext/-test-/win32/console/attribute.c5
-rw-r--r--ext/.document2
-rw-r--r--ext/bigdecimal/bigdecimal.c568
-rw-r--r--ext/bigdecimal/bigdecimal.gemspec10
-rw-r--r--ext/bigdecimal/bigdecimal.h6
-rw-r--r--ext/bigdecimal/depend4
-rw-r--r--ext/bigdecimal/extconf.rb33
-rw-r--r--ext/bigdecimal/lib/bigdecimal.rb1
-rw-r--r--ext/bigdecimal/lib/bigdecimal/jacobian.rb4
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb28
-rw-r--r--ext/bigdecimal/sample/linear.rb21
-rw-r--r--ext/bigdecimal/sample/nlsolve.rb10
-rw-r--r--ext/bigdecimal/util/depend14
-rw-r--r--ext/cgi/escape/depend3
-rw-r--r--ext/cgi/escape/escape.c90
-rw-r--r--ext/continuation/depend1
-rw-r--r--ext/coverage/coverage.c63
-rw-r--r--ext/coverage/depend21
-rw-r--r--ext/coverage/lib/coverage.rb14
-rw-r--r--ext/date/date.gemspec10
-rw-r--r--ext/date/date_core.c1002
-rw-r--r--ext/date/date_parse.c257
-rw-r--r--ext/date/date_strptime.c83
-rw-r--r--ext/date/depend10
-rw-r--r--ext/date/lib/date.rb5
-rw-r--r--ext/date/prereq.mk6
-rw-r--r--ext/date/update-abbr35
-rw-r--r--ext/date/zonetab.h2061
-rw-r--r--ext/date/zonetab.list146
-rw-r--r--ext/dbm/dbm.c47
-rw-r--r--ext/dbm/dbm.gemspec3
-rw-r--r--ext/dbm/depend3
-rw-r--r--ext/dbm/extconf.rb6
-rw-r--r--ext/digest/bubblebabble/bubblebabble.c1
-rw-r--r--ext/digest/bubblebabble/depend5
-rw-r--r--ext/digest/depend3
-rw-r--r--ext/digest/digest.c41
-rw-r--r--ext/digest/digest.h13
-rw-r--r--ext/digest/md5/depend5
-rw-r--r--ext/digest/md5/md5cc.h7
-rw-r--r--ext/digest/md5/md5init.c4
-rw-r--r--ext/digest/rmd160/depend5
-rw-r--r--ext/digest/rmd160/rmd160init.c4
-rw-r--r--ext/digest/sha1/depend5
-rw-r--r--ext/digest/sha1/sha1init.c4
-rw-r--r--ext/digest/sha2/depend5
-rw-r--r--ext/digest/sha2/sha2init.c8
-rw-r--r--ext/etc/depend3
-rw-r--r--ext/etc/etc.c26
-rw-r--r--ext/etc/etc.gemspec27
-rw-r--r--ext/etc/extconf.rb6
-rw-r--r--ext/etc/mkconstants.rb16
-rwxr-xr-xext/extmk.rb31
-rw-r--r--ext/fcntl/depend3
-rw-r--r--ext/fcntl/fcntl.gemspec1
-rw-r--r--ext/fiber/depend2
-rw-r--r--ext/fiddle/closure.c5
-rw-r--r--ext/fiddle/depend23
-rw-r--r--ext/fiddle/extconf.rb25
-rw-r--r--ext/fiddle/function.c15
-rw-r--r--ext/fiddle/handle.c8
-rw-r--r--ext/fiddle/lib/fiddle/import.rb12
-rw-r--r--ext/fiddle/lib/fiddle/pack.rb21
-rw-r--r--ext/fiddle/lib/fiddle/types.rb35
-rw-r--r--ext/fiddle/lib/fiddle/value.rb27
-rw-r--r--ext/fiddle/pointer.c15
-rw-r--r--ext/gdbm/depend3
-rw-r--r--ext/gdbm/gdbm.c7
-rw-r--r--ext/gdbm/gdbm.gemspec8
-rw-r--r--ext/io/console/console.c741
-rw-r--r--ext/io/console/depend4
-rw-r--r--ext/io/console/extconf.rb14
-rw-r--r--ext/io/console/io-console.gemspec19
-rw-r--r--ext/io/nonblock/depend3
-rw-r--r--ext/io/wait/depend3
-rw-r--r--ext/io/wait/wait.c3
-rw-r--r--ext/json/depend2
-rw-r--r--ext/json/generator/depend5
-rw-r--r--ext/json/generator/generator.c136
-rw-r--r--ext/json/json.gemspecbin4425 -> 5474 bytes-rw-r--r--ext/json/lib/json/add/bigdecimal.rb4
-rw-r--r--ext/json/lib/json/add/complex.rb4
-rw-r--r--ext/json/lib/json/add/ostruct.rb2
-rw-r--r--ext/json/lib/json/add/rational.rb4
-rw-r--r--ext/json/lib/json/add/regexp.rb4
-rw-r--r--ext/json/lib/json/add/set.rb29
-rw-r--r--ext/json/lib/json/common.rb4
-rw-r--r--ext/json/lib/json/version.rb2
-rw-r--r--ext/json/parser/depend5
-rw-r--r--ext/json/parser/parser.c185
-rw-r--r--ext/json/parser/parser.rl37
-rw-r--r--ext/json/parser/prereq.mk3
-rw-r--r--ext/monitor/depend13
-rw-r--r--ext/monitor/extconf.rb2
-rw-r--r--ext/monitor/lib/monitor.rb284
-rw-r--r--ext/monitor/monitor.c221
-rw-r--r--ext/nkf/depend1
-rw-r--r--ext/nkf/nkf-utf8/nkf.c51
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.c158
-rw-r--r--ext/nkf/nkf.c1
-rw-r--r--ext/objspace/depend14
-rw-r--r--ext/objspace/object_tracing.c40
-rw-r--r--ext/objspace/objspace.c24
-rw-r--r--ext/objspace/objspace_dump.c27
-rw-r--r--ext/openssl/History.md36
-rw-r--r--ext/openssl/depend93
-rw-r--r--ext/openssl/deprecation.rb6
-rw-r--r--ext/openssl/extconf.rb46
-rw-r--r--ext/openssl/lib/openssl/buffering.rb17
-rw-r--r--ext/openssl/lib/openssl/config.rb54
-rw-r--r--ext/openssl/lib/openssl/ssl.rb11
-rw-r--r--ext/openssl/openssl.gemspec63
-rw-r--r--ext/openssl/openssl_missing.h2
-rw-r--r--ext/openssl/ossl.c4
-rw-r--r--ext/openssl/ossl.h2
-rw-r--r--ext/openssl/ossl_asn1.c1
-rw-r--r--ext/openssl/ossl_bn.c41
-rw-r--r--ext/openssl/ossl_digest.c8
-rw-r--r--ext/openssl/ossl_pkey.h10
-rw-r--r--ext/openssl/ossl_pkey_dh.c2
-rw-r--r--ext/openssl/ossl_pkey_ec.c16
-rw-r--r--ext/openssl/ossl_rand.c8
-rw-r--r--ext/openssl/ossl_ssl.c144
-rw-r--r--ext/openssl/ossl_version.h2
-rw-r--r--ext/openssl/ossl_x509.c91
-rw-r--r--ext/openssl/ossl_x509name.c2
-rw-r--r--ext/openssl/ossl_x509store.c61
-rw-r--r--ext/pathname/depend3
-rw-r--r--ext/pathname/extconf.rb2
-rw-r--r--ext/pathname/lib/pathname.rb16
-rw-r--r--ext/pathname/pathname.c61
-rw-r--r--ext/psych/.gitignore11
-rw-r--r--ext/psych/depend17
-rw-r--r--ext/psych/extconf.rb8
-rw-r--r--ext/psych/lib/psych.rb195
-rw-r--r--ext/psych/lib/psych/handler.rb2
-rw-r--r--ext/psych/lib/psych/nodes/alias.rb2
-rw-r--r--ext/psych/lib/psych/nodes/document.rb2
-rw-r--r--ext/psych/lib/psych/nodes/mapping.rb2
-rw-r--r--ext/psych/lib/psych/nodes/node.rb7
-rw-r--r--ext/psych/lib/psych/nodes/scalar.rb2
-rw-r--r--ext/psych/lib/psych/nodes/sequence.rb2
-rw-r--r--ext/psych/lib/psych/nodes/stream.rb2
-rw-r--r--ext/psych/lib/psych/scalar_scanner.rb59
-rw-r--r--ext/psych/lib/psych/versions.rb7
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb22
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb70
-rw-r--r--ext/psych/psych.gemspec36
-rw-r--r--ext/psych/psych_emitter.c1
-rw-r--r--ext/psych/psych_parser.c20
-rw-r--r--ext/psych/yaml/api.c65
-rw-r--r--ext/psych/yaml/config.h10
-rw-r--r--ext/psych/yaml/dumper.c4
-rw-r--r--ext/psych/yaml/emitter.c13
-rw-r--r--ext/psych/yaml/loader.c14
-rw-r--r--ext/psych/yaml/parser.c10
-rw-r--r--ext/psych/yaml/reader.c6
-rw-r--r--ext/psych/yaml/scanner.c20
-rw-r--r--ext/psych/yaml/yaml_private.h60
-rw-r--r--ext/pty/depend3
-rw-r--r--ext/pty/extconf.rb2
-rw-r--r--ext/pty/pty.c62
-rw-r--r--ext/racc/cparse/README2
-rw-r--r--ext/racc/cparse/cparse.c12
-rw-r--r--ext/racc/cparse/depend2
-rw-r--r--ext/racc/cparse/extconf.rb6
-rw-r--r--ext/rbconfig/sizeof/depend2
-rw-r--r--ext/readline/.gitignore1
-rw-r--r--ext/readline/depend2
-rw-r--r--ext/readline/extconf.rb8
-rw-r--r--ext/readline/readline-ext.gemspec26
-rw-r--r--ext/readline/readline.c60
-rw-r--r--ext/ripper/depend12
-rw-r--r--ext/ripper/eventids2.c351
-rw-r--r--ext/ripper/extconf.rb8
-rw-r--r--ext/ripper/lib/ripper/core.rb2
-rw-r--r--ext/ripper/lib/ripper/lexer.rb88
-rw-r--r--ext/ripper/lib/ripper/sexp.rb2
-rw-r--r--ext/ripper/tools/dsl.rb85
-rwxr-xr-x[-rw-r--r--]ext/ripper/tools/generate-param-macros.rb0
-rwxr-xr-x[-rw-r--r--]ext/ripper/tools/generate.rb9
-rwxr-xr-x[-rw-r--r--]ext/ripper/tools/preproc.rb41
-rwxr-xr-x[-rw-r--r--]ext/ripper/tools/strip.rb0
-rw-r--r--ext/rubyvm/depend2
-rw-r--r--ext/rubyvm/lib/forwardable/impl.rb5
-rw-r--r--ext/sdbm/depend4
-rw-r--r--ext/sdbm/init.c2
-rw-r--r--ext/sdbm/sdbm.gemspec3
-rw-r--r--ext/socket/ancdata.c12
-rw-r--r--ext/socket/basicsocket.c4
-rw-r--r--ext/socket/constants.c1
-rw-r--r--ext/socket/depend45
-rw-r--r--ext/socket/extconf.rb5
-rw-r--r--ext/socket/getaddrinfo.c2
-rw-r--r--ext/socket/init.c59
-rw-r--r--ext/socket/ipsocket.c11
-rw-r--r--ext/socket/lib/socket.rb13
-rw-r--r--ext/socket/mkconstants.rb31
-rw-r--r--ext/socket/option.c4
-rw-r--r--ext/socket/raddrinfo.c259
-rw-r--r--ext/socket/rubysocket.h10
-rw-r--r--ext/socket/socket.c32
-rw-r--r--ext/socket/sockssocket.c14
-rw-r--r--ext/socket/udpsocket.c9
-rw-r--r--ext/socket/unixsocket.c29
-rw-r--r--ext/stringio/depend3
-rw-r--r--ext/stringio/extconf.rb1
-rw-r--r--ext/stringio/stringio.c349
-rw-r--r--ext/stringio/stringio.gemspec45
-rw-r--r--ext/strscan/depend3
-rw-r--r--ext/strscan/extconf.rb3
-rw-r--r--ext/strscan/strscan.c317
-rw-r--r--ext/strscan/strscan.gemspec10
-rw-r--r--ext/syslog/depend1
-rw-r--r--ext/syslog/extconf.rb2
-rw-r--r--ext/syslog/lib/syslog/logger.rb4
-rw-r--r--ext/syslog/syslog.c6
-rw-r--r--ext/win32/depend2
-rw-r--r--ext/win32/lib/Win32API.rb2
-rw-r--r--ext/win32/lib/win32/registry.rb4
-rw-r--r--ext/win32/lib/win32/resolv.rb25
-rw-r--r--ext/win32/resolv/depend17
-rw-r--r--ext/win32ole/lib/win32ole.rb2
-rw-r--r--ext/win32ole/win32ole.c18
-rw-r--r--ext/win32ole/win32ole.h4
-rw-r--r--ext/win32ole/win32ole_error.c3
-rw-r--r--ext/win32ole/win32ole_error.h4
-rw-r--r--ext/win32ole/win32ole_event.c5
-rw-r--r--ext/win32ole/win32ole_method.c4
-rw-r--r--ext/win32ole/win32ole_method.h2
-rw-r--r--ext/win32ole/win32ole_record.c2
-rw-r--r--ext/win32ole/win32ole_record.h2
-rw-r--r--ext/win32ole/win32ole_type.c2
-rw-r--r--ext/win32ole/win32ole_type.h2
-rw-r--r--ext/win32ole/win32ole_typelib.c2
-rw-r--r--ext/win32ole/win32ole_typelib.h2
-rw-r--r--ext/win32ole/win32ole_variable.c2
-rw-r--r--ext/win32ole/win32ole_variable.h2
-rw-r--r--ext/win32ole/win32ole_variant.c3
-rw-r--r--ext/win32ole/win32ole_variant.h2
-rw-r--r--ext/win32ole/win32ole_variant_m.c2
-rw-r--r--ext/win32ole/win32ole_variant_m.h2
-rw-r--r--ext/zlib/.gitignore1
-rw-r--r--ext/zlib/depend3
-rw-r--r--ext/zlib/zlib.c395
-rw-r--r--ext/zlib/zlib.gemspec14
-rw-r--r--file.c674
-rw-r--r--gc.c4156
-rw-r--r--gc.h19
-rw-r--r--gc.rb169
-rw-r--r--gem_prelude.rb10
-rw-r--r--gems/bundled_gems11
-rw-r--r--golf_prelude.rb7
-rw-r--r--hash.c2886
-rw-r--r--hrtime.h168
-rw-r--r--ia64.s42
-rw-r--r--id_table.c22
-rw-r--r--id_table.h3
-rw-r--r--include/ruby/assert.h54
-rw-r--r--include/ruby/backward.h21
-rw-r--r--include/ruby/backward/cxxanyargs.hpp439
-rw-r--r--include/ruby/debug.h6
-rw-r--r--include/ruby/defines.h183
-rw-r--r--include/ruby/encoding.h6
-rw-r--r--include/ruby/intern.h328
-rw-r--r--include/ruby/io.h10
-rw-r--r--include/ruby/missing.h12
-rw-r--r--include/ruby/onigmo.h8
-rw-r--r--include/ruby/re.h3
-rw-r--r--include/ruby/ruby.h620
-rw-r--r--include/ruby/st.h128
-rw-r--r--include/ruby/thread.h12
-rw-r--r--include/ruby/version.h2
-rw-r--r--include/ruby/vm.h3
-rw-r--r--include/ruby/win32.h3
-rw-r--r--inits.c22
-rw-r--r--insns.def1292
-rw-r--r--internal.h1048
-rw-r--r--io.c1492
-rw-r--r--io.rb123
-rw-r--r--iseq.c1873
-rw-r--r--iseq.h132
-rw-r--r--lex.c.blt2
-rw-r--r--lib/.document1
-rw-r--r--lib/English.rb48
-rw-r--r--lib/base64.rb5
-rw-r--r--lib/benchmark.rb13
-rw-r--r--lib/benchmark/benchmark.gemspec29
-rw-r--r--lib/benchmark/version.rb3
-rw-r--r--lib/bundler.rb682
-rw-r--r--lib/bundler/build_metadata.rb51
-rw-r--r--lib/bundler/bundler.gemspec44
-rw-r--r--lib/bundler/capistrano.rb22
-rw-r--r--lib/bundler/cli.rb828
-rw-r--r--lib/bundler/cli/add.rb47
-rw-r--r--lib/bundler/cli/binstubs.rb49
-rw-r--r--lib/bundler/cli/cache.rb48
-rw-r--r--lib/bundler/cli/check.rb38
-rw-r--r--lib/bundler/cli/clean.rb25
-rw-r--r--lib/bundler/cli/common.rb101
-rw-r--r--lib/bundler/cli/config.rb194
-rw-r--r--lib/bundler/cli/console.rb43
-rw-r--r--lib/bundler/cli/doctor.rb140
-rw-r--r--lib/bundler/cli/exec.rb93
-rw-r--r--lib/bundler/cli/gem.rb252
-rw-r--r--lib/bundler/cli/info.rb62
-rw-r--r--lib/bundler/cli/init.rb47
-rw-r--r--lib/bundler/cli/inject.rb60
-rw-r--r--lib/bundler/cli/install.rb219
-rw-r--r--lib/bundler/cli/issue.rb40
-rw-r--r--lib/bundler/cli/list.rb58
-rw-r--r--lib/bundler/cli/lock.rb63
-rw-r--r--lib/bundler/cli/open.rb30
-rw-r--r--lib/bundler/cli/outdated.rb270
-rw-r--r--lib/bundler/cli/package.rb48
-rw-r--r--lib/bundler/cli/platform.rb46
-rw-r--r--lib/bundler/cli/plugin.rb31
-rw-r--r--lib/bundler/cli/pristine.rb47
-rw-r--r--lib/bundler/cli/remove.rb18
-rw-r--r--lib/bundler/cli/show.rb75
-rw-r--r--lib/bundler/cli/update.rb111
-rw-r--r--lib/bundler/cli/viz.rb31
-rw-r--r--lib/bundler/compact_index_client.rb125
-rw-r--r--lib/bundler/compact_index_client/cache.rb118
-rw-r--r--lib/bundler/compact_index_client/updater.rb112
-rw-r--r--lib/bundler/constants.rb7
-rw-r--r--lib/bundler/current_ruby.rb95
-rw-r--r--lib/bundler/definition.rb1002
-rw-r--r--lib/bundler/dep_proxy.rb48
-rw-r--r--lib/bundler/dependency.rb151
-rw-r--r--lib/bundler/deployment.rb69
-rw-r--r--lib/bundler/deprecate.rb44
-rw-r--r--lib/bundler/dsl.rb591
-rw-r--r--lib/bundler/endpoint_specification.rb141
-rw-r--r--lib/bundler/env.rb150
-rw-r--r--lib/bundler/environment_preserver.rb58
-rw-r--r--lib/bundler/errors.rb158
-rw-r--r--lib/bundler/feature_flag.rb63
-rw-r--r--lib/bundler/fetcher.rb315
-rw-r--r--lib/bundler/fetcher/base.rb52
-rw-r--r--lib/bundler/fetcher/compact_index.rb140
-rw-r--r--lib/bundler/fetcher/dependency.rb82
-rw-r--r--lib/bundler/fetcher/downloader.rb87
-rw-r--r--lib/bundler/fetcher/index.rb54
-rw-r--r--lib/bundler/friendly_errors.rb130
-rw-r--r--lib/bundler/gem_helper.rb216
-rw-r--r--lib/bundler/gem_helpers.rb99
-rw-r--r--lib/bundler/gem_remote_fetcher.rb43
-rw-r--r--lib/bundler/gem_tasks.rb7
-rw-r--r--lib/bundler/gem_version_promoter.rb190
-rw-r--r--lib/bundler/gemdeps.rb29
-rw-r--r--lib/bundler/graph.rb152
-rw-r--r--lib/bundler/index.rb213
-rw-r--r--lib/bundler/injector.rb255
-rw-r--r--lib/bundler/inline.rb84
-rw-r--r--lib/bundler/installer.rb311
-rw-r--r--lib/bundler/installer/gem_installer.rb89
-rw-r--r--lib/bundler/installer/parallel_installer.rb229
-rw-r--r--lib/bundler/installer/standalone.rb52
-rw-r--r--lib/bundler/lazy_specification.rb122
-rw-r--r--lib/bundler/lockfile_generator.rb95
-rw-r--r--lib/bundler/lockfile_parser.rb249
-rw-r--r--lib/bundler/match_platform.rb24
-rw-r--r--lib/bundler/mirror.rb223
-rw-r--r--lib/bundler/plugin.rb305
-rw-r--r--lib/bundler/plugin/api.rb81
-rw-r--r--lib/bundler/plugin/api/source.rb304
-rw-r--r--lib/bundler/plugin/dsl.rb53
-rw-r--r--lib/bundler/plugin/events.rb61
-rw-r--r--lib/bundler/plugin/index.rb173
-rw-r--r--lib/bundler/plugin/installer.rb109
-rw-r--r--lib/bundler/plugin/installer/git.rb38
-rw-r--r--lib/bundler/plugin/installer/rubygems.rb27
-rw-r--r--lib/bundler/plugin/source_list.rb27
-rw-r--r--lib/bundler/process_lock.rb24
-rw-r--r--lib/bundler/psyched_yaml.rb37
-rw-r--r--lib/bundler/remote_specification.rb112
-rw-r--r--lib/bundler/resolver.rb421
-rw-r--r--lib/bundler/resolver/spec_group.rb107
-rw-r--r--lib/bundler/retry.rb66
-rw-r--r--lib/bundler/ruby_dsl.rb18
-rw-r--r--lib/bundler/ruby_version.rb137
-rw-r--r--lib/bundler/rubygems_ext.rb154
-rw-r--r--lib/bundler/rubygems_gem_installer.rb99
-rw-r--r--lib/bundler/rubygems_integration.rb648
-rw-r--r--lib/bundler/runtime.rb315
-rw-r--r--lib/bundler/settings.rb434
-rw-r--r--lib/bundler/settings/validator.rb102
-rw-r--r--lib/bundler/setup.rb27
-rw-r--r--lib/bundler/shared_helpers.rb358
-rw-r--r--lib/bundler/similarity_detector.rb63
-rw-r--r--lib/bundler/source.rb94
-rw-r--r--lib/bundler/source/gemspec.rb18
-rw-r--r--lib/bundler/source/git.rb336
-rw-r--r--lib/bundler/source/git/git_proxy.rb259
-rw-r--r--lib/bundler/source/metadata.rb67
-rw-r--r--lib/bundler/source/path.rb254
-rw-r--r--lib/bundler/source/path/installer.rb74
-rw-r--r--lib/bundler/source/rubygems.rb545
-rw-r--r--lib/bundler/source/rubygems/remote.rb68
-rw-r--r--lib/bundler/source_list.rb183
-rw-r--r--lib/bundler/spec_set.rb203
-rw-r--r--lib/bundler/stub_specification.rb96
-rw-r--r--lib/bundler/templates/.document1
-rw-r--r--lib/bundler/templates/Executable29
-rw-r--r--lib/bundler/templates/Executable.bundler114
-rw-r--r--lib/bundler/templates/Executable.standalone14
-rw-r--r--lib/bundler/templates/Gemfile7
-rw-r--r--lib/bundler/templates/gems.rb8
-rw-r--r--lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt74
-rw-r--r--lib/bundler/templates/newgem/Gemfile.tt12
-rw-r--r--lib/bundler/templates/newgem/LICENSE.txt.tt21
-rw-r--r--lib/bundler/templates/newgem/README.md.tt48
-rw-r--r--lib/bundler/templates/newgem/Rakefile.tt29
-rw-r--r--lib/bundler/templates/newgem/bin/console.tt14
-rw-r--r--lib/bundler/templates/newgem/bin/setup.tt8
-rw-r--r--lib/bundler/templates/newgem/exe/newgem.tt3
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt3
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/newgem.c.tt9
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/newgem.h.tt6
-rw-r--r--lib/bundler/templates/newgem/gitignore.tt20
-rw-r--r--lib/bundler/templates/newgem/lib/newgem.rb.tt13
-rw-r--r--lib/bundler/templates/newgem/lib/newgem/version.rb.tt7
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt34
-rw-r--r--lib/bundler/templates/newgem/rspec.tt3
-rw-r--r--lib/bundler/templates/newgem/spec/newgem_spec.rb.tt9
-rw-r--r--lib/bundler/templates/newgem/spec/spec_helper.rb.tt14
-rw-r--r--lib/bundler/templates/newgem/test/newgem_test.rb.tt11
-rw-r--r--lib/bundler/templates/newgem/test/test_helper.rb.tt4
-rw-r--r--lib/bundler/templates/newgem/travis.yml.tt6
-rw-r--r--lib/bundler/ui.rb9
-rw-r--r--lib/bundler/ui/rg_proxy.rb19
-rw-r--r--lib/bundler/ui/shell.rb142
-rw-r--r--lib/bundler/ui/silent.rb69
-rw-r--r--lib/bundler/uri_credentials_filter.rb41
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool.rb161
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb66
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb176
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb3
-rw-r--r--lib/bundler/vendor/fileutils/lib/fileutils.rb1764
-rw-r--r--lib/bundler/vendor/fileutils/lib/fileutils/version.rb5
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo.rb12
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb26
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb57
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb81
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb223
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb36
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb66
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb62
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb63
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb61
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb126
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb46
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb36
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb158
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/errors.rb143
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb6
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb101
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb67
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb837
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb46
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/state.rb58
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb1180
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb40
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb53
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb79
-rw-r--r--lib/bundler/vendor/thor/lib/thor.rb524
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions.rb336
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/create_file.rb104
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/create_link.rb60
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/directory.rb108
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb143
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb373
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb120
-rw-r--r--lib/bundler/vendor/thor/lib/thor/base.rb690
-rw-r--r--lib/bundler/vendor/thor/lib/thor/command.rb142
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb97
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb12
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb129
-rw-r--r--lib/bundler/vendor/thor/lib/thor/error.rb110
-rw-r--r--lib/bundler/vendor/thor/lib/thor/group.rb281
-rw-r--r--lib/bundler/vendor/thor/lib/thor/invocation.rb178
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor.rb17
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb37
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb88
-rw-r--r--lib/bundler/vendor/thor/lib/thor/nested_context.rb29
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/argument.rb70
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/arguments.rb175
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/option.rb159
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/options.rb236
-rw-r--r--lib/bundler/vendor/thor/lib/thor/rake_compat.rb72
-rw-r--r--lib/bundler/vendor/thor/lib/thor/runner.rb325
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell.rb81
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/basic.rb491
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/color.rb153
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/html.rb126
-rw-r--r--lib/bundler/vendor/thor/lib/thor/util.rb284
-rw-r--r--lib/bundler/vendor/thor/lib/thor/version.rb3
-rw-r--r--lib/bundler/vendor/uri/lib/uri.rb104
-rw-r--r--lib/bundler/vendor/uri/lib/uri/common.rb744
-rw-r--r--lib/bundler/vendor/uri/lib/uri/file.rb94
-rw-r--r--lib/bundler/vendor/uri/lib/uri/ftp.rb267
-rw-r--r--lib/bundler/vendor/uri/lib/uri/generic.rb1568
-rw-r--r--lib/bundler/vendor/uri/lib/uri/http.rb88
-rw-r--r--lib/bundler/vendor/uri/lib/uri/https.rb23
-rw-r--r--lib/bundler/vendor/uri/lib/uri/ldap.rb261
-rw-r--r--lib/bundler/vendor/uri/lib/uri/ldaps.rb21
-rw-r--r--lib/bundler/vendor/uri/lib/uri/mailto.rb294
-rw-r--r--lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb546
-rw-r--r--lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb125
-rw-r--r--lib/bundler/vendor/uri/lib/uri/version.rb6
-rw-r--r--lib/bundler/vendored_fileutils.rb4
-rw-r--r--lib/bundler/vendored_molinillo.rb4
-rw-r--r--lib/bundler/vendored_persistent.rb54
-rw-r--r--lib/bundler/vendored_thor.rb8
-rw-r--r--lib/bundler/vendored_uri.rb4
-rw-r--r--lib/bundler/version.rb9
-rw-r--r--lib/bundler/version_ranges.rb122
-rw-r--r--lib/bundler/vlad.rb17
-rw-r--r--lib/bundler/worker.rb104
-rw-r--r--lib/bundler/yaml_serializer.rb89
-rw-r--r--lib/cgi.rb2
-rw-r--r--lib/cgi/cgi.gemspec27
-rw-r--r--lib/cgi/cookie.rb17
-rw-r--r--lib/cgi/core.rb33
-rw-r--r--lib/cgi/html.rb6
-rw-r--r--lib/cgi/session.rb12
-rw-r--r--lib/cgi/session/pstore.rb3
-rw-r--r--lib/cgi/util.rb38
-rw-r--r--lib/cgi/version.rb3
-rw-r--r--lib/cmath.gemspec24
-rw-r--r--lib/cmath.rb435
-rw-r--r--lib/csv.gemspec21
-rw-r--r--lib/csv.rb2500
-rw-r--r--lib/csv/core_ext/array.rb9
-rw-r--r--lib/csv/core_ext/string.rb9
-rw-r--r--lib/csv/csv.gemspec44
-rw-r--r--lib/csv/delete_suffix.rb18
-rw-r--r--lib/csv/fields_converter.rb84
-rw-r--r--lib/csv/match_p.rb20
-rw-r--r--lib/csv/parser.rb1136
-rw-r--r--lib/csv/row.rb390
-rw-r--r--lib/csv/table.rb402
-rw-r--r--lib/csv/version.rb6
-rw-r--r--lib/csv/writer.rb168
-rw-r--r--lib/debug.rb7
-rw-r--r--lib/delegate.rb93
-rw-r--r--lib/delegate/delegate.gemspec27
-rw-r--r--lib/delegate/version.rb3
-rw-r--r--lib/did_you_mean.rb110
-rw-r--r--lib/did_you_mean/core_ext/name_error.rb25
-rw-r--r--lib/did_you_mean/did_you_mean.gemspec27
-rw-r--r--lib/did_you_mean/experimental.rb2
-rw-r--r--lib/did_you_mean/experimental/initializer_name_correction.rb20
-rw-r--r--lib/did_you_mean/experimental/ivar_name_correction.rb76
-rw-r--r--lib/did_you_mean/formatters/plain_formatter.rb33
-rw-r--r--lib/did_you_mean/formatters/verbose_formatter.rb49
-rw-r--r--lib/did_you_mean/jaro_winkler.rb87
-rw-r--r--lib/did_you_mean/levenshtein.rb57
-rw-r--r--lib/did_you_mean/spell_checker.rb46
-rw-r--r--lib/did_you_mean/spell_checkers/key_error_checker.rb20
-rw-r--r--lib/did_you_mean/spell_checkers/method_name_checker.rb64
-rw-r--r--lib/did_you_mean/spell_checkers/name_error_checkers.rb20
-rw-r--r--lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb49
-rw-r--r--lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb82
-rw-r--r--lib/did_you_mean/spell_checkers/null_checker.rb6
-rw-r--r--lib/did_you_mean/tree_spell_checker.rb137
-rw-r--r--lib/did_you_mean/verbose.rb4
-rw-r--r--lib/did_you_mean/version.rb3
-rw-r--r--lib/drb/drb.rb291
-rw-r--r--lib/drb/extserv.rb2
-rw-r--r--lib/drb/extservm.rb5
-rw-r--r--lib/drb/gw.rb2
-rw-r--r--lib/drb/ssl.rb12
-rw-r--r--lib/drb/timeridconv.rb2
-rw-r--r--lib/drb/unix.rb8
-rw-r--r--lib/drb/weakidconv.rb59
-rw-r--r--lib/e2mmap.rb177
-rw-r--r--lib/erb.rb88
-rw-r--r--lib/fileutils.gemspec28
-rw-r--r--lib/fileutils.rb415
-rw-r--r--lib/find.rb6
-rw-r--r--lib/forwardable.rb44
-rw-r--r--lib/forwardable/forwardable.gemspec23
-rw-r--r--lib/forwardable/impl.rb8
-rw-r--r--lib/forwardable/version.rb5
-rw-r--r--lib/getoptlong/getoptlong.gemspec29
-rw-r--r--lib/getoptlong/version.rb3
-rw-r--r--lib/ipaddr.gemspec4
-rw-r--r--lib/ipaddr.rb10
-rw-r--r--lib/irb.rb355
-rw-r--r--lib/irb/.document1
-rw-r--r--lib/irb/cmd/chws.rb4
-rw-r--r--lib/irb/cmd/fork.rb4
-rw-r--r--lib/irb/cmd/help.rb16
-rw-r--r--lib/irb/cmd/info.rb24
-rw-r--r--lib/irb/cmd/load.rb4
-rw-r--r--lib/irb/cmd/pushws.rb5
-rw-r--r--lib/irb/cmd/subirb.rb4
-rw-r--r--lib/irb/color.rb235
-rw-r--r--lib/irb/completion.rb209
-rw-r--r--lib/irb/context.rb219
-rw-r--r--lib/irb/easter-egg.rb137
-rw-r--r--lib/irb/ext/change-ws.rb1
-rw-r--r--lib/irb/ext/history.rb58
-rw-r--r--lib/irb/ext/loader.rb1
-rw-r--r--lib/irb/ext/multi-irb.rb14
-rw-r--r--lib/irb/ext/save-history.rb37
-rw-r--r--lib/irb/ext/tracer.rb16
-rw-r--r--lib/irb/ext/use-loader.rb11
-rw-r--r--lib/irb/ext/workspaces.rb1
-rw-r--r--lib/irb/extend-command.rb133
-rw-r--r--lib/irb/frame.rb19
-rw-r--r--lib/irb/help.rb3
-rw-r--r--lib/irb/init.rb75
-rw-r--r--lib/irb/input-method.rb170
-rw-r--r--lib/irb/inspector.rb20
-rw-r--r--lib/irb/irb.gemspec84
-rw-r--r--lib/irb/lc/.document4
-rw-r--r--lib/irb/lc/error.rb71
-rw-r--r--lib/irb/lc/help-message15
-rw-r--r--lib/irb/lc/ja/error.rb69
-rw-r--r--lib/irb/lc/ja/help-message15
-rw-r--r--lib/irb/locale.rb17
-rw-r--r--lib/irb/notifier.rb22
-rw-r--r--lib/irb/output-method.rb12
-rw-r--r--lib/irb/ruby-lex.rb1450
-rw-r--r--lib/irb/ruby-token.rb267
-rw-r--r--lib/irb/ruby_logo.aa37
-rw-r--r--lib/irb/slex.rb282
-rw-r--r--lib/irb/version.rb5
-rw-r--r--lib/irb/workspace.rb88
-rw-r--r--lib/irb/xmp.rb4
-rw-r--r--lib/logger.rb356
-rw-r--r--lib/logger/errors.rb9
-rw-r--r--lib/logger/formatter.rb36
-rw-r--r--lib/logger/log_device.rb205
-rw-r--r--lib/logger/logger.gemspec29
-rw-r--r--lib/logger/period.rb47
-rw-r--r--lib/logger/severity.rb19
-rw-r--r--lib/logger/version.rb5
-rw-r--r--lib/matrix.rb451
-rw-r--r--lib/matrix/eigenvalue_decomposition.rb23
-rw-r--r--lib/matrix/lup_decomposition.rb8
-rw-r--r--lib/matrix/matrix.gemspec28
-rw-r--r--lib/matrix/version.rb5
-rw-r--r--lib/mkmf.rb121
-rw-r--r--lib/monitor.rb324
-rw-r--r--lib/mutex_m.gemspec27
-rw-r--r--lib/mutex_m.rb9
-rw-r--r--lib/net/ftp.rb115
-rw-r--r--lib/net/http.rb91
-rw-r--r--lib/net/http/exceptions.rb7
-rw-r--r--lib/net/http/generic_request.rb13
-rw-r--r--lib/net/http/header.rb34
-rw-r--r--lib/net/http/response.rb18
-rw-r--r--lib/net/http/responses.rb34
-rw-r--r--lib/net/http/status.rb4
-rw-r--r--lib/net/https.rb2
-rw-r--r--lib/net/imap.rb27
-rw-r--r--lib/net/pop.rb1
-rw-r--r--lib/net/pop/net-pop.gemspec27
-rw-r--r--lib/net/pop/version.rb6
-rw-r--r--lib/net/protocol.rb102
-rw-r--r--lib/net/smtp.rb8
-rw-r--r--lib/net/smtp/net-smtp.gemspec27
-rw-r--r--lib/net/smtp/version.rb6
-rw-r--r--lib/observer/observer.gemspec29
-rw-r--r--lib/observer/version.rb3
-rw-r--r--lib/open-uri.rb51
-rw-r--r--lib/open3.rb105
-rw-r--r--lib/open3/open3.gemspec29
-rw-r--r--lib/open3/version.rb3
-rw-r--r--lib/optparse.rb158
-rw-r--r--lib/optparse/ac.rb7
-rw-r--r--lib/ostruct.rb39
-rw-r--r--lib/ostruct/ostruct.gemspec28
-rw-r--r--lib/ostruct/version.rb5
-rw-r--r--lib/pp.rb73
-rw-r--r--lib/prime.gemspec27
-rw-r--r--lib/prime.rb16
-rw-r--r--lib/profile.rb11
-rw-r--r--lib/profiler.rb149
-rw-r--r--lib/pstore.rb6
-rw-r--r--lib/pstore/pstore.gemspec29
-rw-r--r--lib/pstore/version.rb3
-rw-r--r--lib/racc.rb6
-rw-r--r--lib/racc/compat.rb32
-rw-r--r--lib/racc/debugflags.rb59
-rw-r--r--lib/racc/exception.rb13
-rw-r--r--lib/racc/grammar.rb1113
-rw-r--r--lib/racc/grammarfileparser.rb560
-rw-r--r--lib/racc/info.rb14
-rw-r--r--lib/racc/iset.rb91
-rw-r--r--lib/racc/logfilegenerator.rb211
-rw-r--r--lib/racc/parser-text.rb643
-rw-r--r--lib/racc/parser.rb81
-rw-r--r--lib/racc/parserfilegenerator.rb510
-rw-r--r--lib/racc/pre-setup13
-rw-r--r--lib/racc/racc.gemspec105
-rw-r--r--lib/racc/sourcetext.rb34
-rw-r--r--lib/racc/state.rb969
-rw-r--r--lib/racc/statetransitiontable.rb316
-rw-r--r--lib/racc/static.rb5
-rw-r--r--lib/rdoc.rb10
-rw-r--r--lib/rdoc/.document1
-rw-r--r--lib/rdoc/class_module.rb2
-rw-r--r--lib/rdoc/comment.rb13
-rw-r--r--lib/rdoc/context.rb51
-rw-r--r--lib/rdoc/cross_reference.rb44
-rw-r--r--lib/rdoc/encoding.rb48
-rw-r--r--lib/rdoc/erbio.rb8
-rw-r--r--lib/rdoc/generator/darkfish.rb18
-rw-r--r--lib/rdoc/generator/json_index.rb5
-rw-r--r--lib/rdoc/generator/markup.rb14
-rw-r--r--lib/rdoc/generator/pot.rb6
-rw-r--r--lib/rdoc/generator/template/darkfish/css/rdoc.css18
-rw-r--r--lib/rdoc/generator/template/json_index/js/navigation.js5
-rw-r--r--lib/rdoc/i18n.rb2
-rw-r--r--lib/rdoc/markdown.rb1
-rw-r--r--lib/rdoc/markdown/literals.rb1
-rw-r--r--lib/rdoc/markup.rb24
-rw-r--r--lib/rdoc/markup/attribute_manager.rb44
-rw-r--r--lib/rdoc/markup/attributes.rb12
-rw-r--r--lib/rdoc/markup/formatter.rb47
-rw-r--r--lib/rdoc/markup/formatter_test_case.rb764
-rw-r--r--lib/rdoc/markup/heading.rb6
-rw-r--r--lib/rdoc/markup/inline.rb2
-rw-r--r--lib/rdoc/markup/parser.rb120
-rw-r--r--lib/rdoc/markup/pre_process.rb1
-rw-r--r--lib/rdoc/markup/regexp_handling.rb41
-rw-r--r--lib/rdoc/markup/special.rb41
-rw-r--r--lib/rdoc/markup/text_formatter_test_case.rb (renamed from test/rdoc/support/text_formatter_test_case.rb)0
-rw-r--r--lib/rdoc/markup/to_bs.rb6
-rw-r--r--lib/rdoc/markup/to_html.rb40
-rw-r--r--lib/rdoc/markup/to_html_crossref.rb51
-rw-r--r--lib/rdoc/markup/to_html_snippet.rb18
-rw-r--r--lib/rdoc/markup/to_label.rb18
-rw-r--r--lib/rdoc/markup/to_markdown.rb16
-rw-r--r--lib/rdoc/markup/to_rdoc.rb12
-rw-r--r--lib/rdoc/markup/to_tt_only.rb4
-rw-r--r--lib/rdoc/options.rb52
-rw-r--r--lib/rdoc/parser.rb2
-rw-r--r--lib/rdoc/parser/c.rb243
-rw-r--r--lib/rdoc/parser/ripper_state_lex.rb159
-rw-r--r--lib/rdoc/parser/ruby.rb283
-rw-r--r--lib/rdoc/parser/ruby_tools.rb22
-rw-r--r--lib/rdoc/rd/block_parser.rb95
-rw-r--r--lib/rdoc/rd/inline_parser.rb275
-rw-r--r--lib/rdoc/rdoc.gemspec207
-rw-r--r--lib/rdoc/rdoc.rb25
-rw-r--r--lib/rdoc/ri/driver.rb35
-rw-r--r--lib/rdoc/ri/paths.rb2
-rw-r--r--lib/rdoc/servlet.rb22
-rw-r--r--lib/rdoc/stats/normal.rb34
-rw-r--r--lib/rdoc/store.rb61
-rw-r--r--lib/rdoc/task.rb2
-rw-r--r--lib/rdoc/test_case.rb203
-rw-r--r--lib/rdoc/text.rb12
-rw-r--r--lib/rdoc/token_stream.rb13
-rw-r--r--lib/rdoc/tom_doc.rb25
-rw-r--r--lib/rdoc/top_level.rb10
-rw-r--r--lib/rdoc/version.rb8
-rw-r--r--lib/readline.gemspec35
-rw-r--r--lib/readline.rb6
-rw-r--r--lib/reline.rb441
-rw-r--r--lib/reline/ansi.rb202
-rw-r--r--lib/reline/config.rb345
-rw-r--r--lib/reline/general_io.rb75
-rw-r--r--lib/reline/history.rb76
-rw-r--r--lib/reline/key_actor.rb7
-rw-r--r--lib/reline/key_actor/base.rb7
-rw-r--r--lib/reline/key_actor/emacs.rb517
-rw-r--r--lib/reline/key_actor/vi_command.rb518
-rw-r--r--lib/reline/key_actor/vi_insert.rb517
-rw-r--r--lib/reline/key_stroke.rb55
-rw-r--r--lib/reline/kill_ring.rb113
-rw-r--r--lib/reline/line_editor.rb2304
-rw-r--r--lib/reline/reline.gemspec26
-rw-r--r--lib/reline/unicode.rb595
-rw-r--r--lib/reline/unicode/east_asian_width.rb1145
-rw-r--r--lib/reline/version.rb3
-rw-r--r--lib/reline/windows.rb282
-rw-r--r--lib/resolv.rb54
-rw-r--r--lib/rexml/attlistdecl.rb4
-rw-r--r--lib/rexml/attribute.rb31
-rw-r--r--lib/rexml/cdata.rb2
-rw-r--r--lib/rexml/child.rb2
-rw-r--r--lib/rexml/comment.rb2
-rw-r--r--lib/rexml/doctype.rb76
-rw-r--r--lib/rexml/document.rb28
-rw-r--r--lib/rexml/dtd/attlistdecl.rb2
-rw-r--r--lib/rexml/dtd/dtd.rb12
-rw-r--r--lib/rexml/dtd/elementdecl.rb2
-rw-r--r--lib/rexml/dtd/entitydecl.rb2
-rw-r--r--lib/rexml/dtd/notationdecl.rb2
-rw-r--r--lib/rexml/element.rb38
-rw-r--r--lib/rexml/entity.rb8
-rw-r--r--lib/rexml/formatters/default.rb12
-rw-r--r--lib/rexml/formatters/pretty.rb2
-rw-r--r--lib/rexml/formatters/transitive.rb2
-rw-r--r--lib/rexml/functions.rb102
-rw-r--r--lib/rexml/instruction.rb32
-rw-r--r--lib/rexml/light/node.rb2
-rw-r--r--lib/rexml/namespace.rb25
-rw-r--r--lib/rexml/node.rb6
-rw-r--r--lib/rexml/output.rb2
-rw-r--r--lib/rexml/parent.rb2
-rw-r--r--lib/rexml/parsers/baseparser.rb355
-rw-r--r--lib/rexml/parsers/lightparser.rb6
-rw-r--r--lib/rexml/parsers/pullparser.rb6
-rw-r--r--lib/rexml/parsers/sax2parser.rb8
-rw-r--r--lib/rexml/parsers/streamparser.rb2
-rw-r--r--lib/rexml/parsers/treeparser.rb4
-rw-r--r--lib/rexml/parsers/ultralightparser.rb4
-rw-r--r--lib/rexml/parsers/xpathparser.rb78
-rw-r--r--lib/rexml/quickpath.rb4
-rw-r--r--lib/rexml/rexml.gemspec84
-rw-r--r--lib/rexml/rexml.rb6
-rw-r--r--lib/rexml/source.rb7
-rw-r--r--lib/rexml/syncenumerator.rb33
-rw-r--r--lib/rexml/text.rb66
-rw-r--r--lib/rexml/undefinednamespaceexception.rb2
-rw-r--r--lib/rexml/validation/relaxng.rb4
-rw-r--r--lib/rexml/validation/validation.rb2
-rw-r--r--lib/rexml/xmldecl.rb40
-rw-r--r--lib/rexml/xpath.rb16
-rw-r--r--lib/rexml/xpath_parser.rb980
-rw-r--r--lib/rinda/ring.rb2
-rw-r--r--lib/rinda/tuplespace.rb2
-rw-r--r--lib/rss.rb2
-rw-r--r--lib/rss/0.9.rb2
-rw-r--r--lib/rss/1.0.rb2
-rw-r--r--lib/rss/atom.rb2
-rw-r--r--lib/rss/content.rb2
-rw-r--r--lib/rss/converter.rb2
-rw-r--r--lib/rss/dublincore.rb4
-rw-r--r--lib/rss/dublincore/atom.rb2
-rw-r--r--lib/rss/image.rb2
-rw-r--r--lib/rss/itunes.rb36
-rw-r--r--lib/rss/maker.rb26
-rw-r--r--lib/rss/maker/0.9.rb6
-rw-r--r--lib/rss/maker/1.0.rb4
-rw-r--r--lib/rss/maker/2.0.rb4
-rw-r--r--lib/rss/maker/atom.rb4
-rw-r--r--lib/rss/maker/base.rb2
-rw-r--r--lib/rss/maker/content.rb6
-rw-r--r--lib/rss/maker/dublincore.rb4
-rw-r--r--lib/rss/maker/entry.rb4
-rw-r--r--lib/rss/maker/feed.rb2
-rw-r--r--lib/rss/maker/image.rb6
-rw-r--r--lib/rss/maker/itunes.rb4
-rw-r--r--lib/rss/maker/slash.rb4
-rw-r--r--lib/rss/maker/syndication.rb4
-rw-r--r--lib/rss/maker/taxonomy.rb6
-rw-r--r--lib/rss/maker/trackback.rb6
-rw-r--r--lib/rss/parser.rb28
-rw-r--r--lib/rss/rss.gemspec80
-rw-r--r--lib/rss/rss.rb10
-rw-r--r--lib/rss/taxonomy.rb2
-rw-r--r--lib/rss/version.rb4
-rw-r--r--lib/rss/xml-stylesheet.rb2
-rw-r--r--lib/rss/xml.rb2
-rw-r--r--lib/rubygems.rb432
-rw-r--r--lib/rubygems/available_set.rb3
-rw-r--r--lib/rubygems/basic_specification.rb65
-rw-r--r--lib/rubygems/bundler_version_finder.rb18
-rw-r--r--lib/rubygems/command.rb96
-rw-r--r--lib/rubygems/command_manager.rb21
-rw-r--r--lib/rubygems/commands/build_command.rb67
-rw-r--r--lib/rubygems/commands/cert_command.rb70
-rw-r--r--lib/rubygems/commands/check_command.rb2
-rw-r--r--lib/rubygems/commands/cleanup_command.rb35
-rw-r--r--lib/rubygems/commands/contents_command.rb35
-rw-r--r--lib/rubygems/commands/dependency_command.rb39
-rw-r--r--lib/rubygems/commands/environment_command.rb24
-rw-r--r--lib/rubygems/commands/fetch_command.rb5
-rw-r--r--lib/rubygems/commands/generate_index_command.rb8
-rw-r--r--lib/rubygems/commands/help_command.rb27
-rw-r--r--lib/rubygems/commands/info_command.rb35
-rw-r--r--lib/rubygems/commands/install_command.rb97
-rw-r--r--lib/rubygems/commands/list_command.rb1
-rw-r--r--lib/rubygems/commands/lock_command.rb11
-rw-r--r--lib/rubygems/commands/mirror_command.rb1
-rw-r--r--lib/rubygems/commands/open_command.rb29
-rw-r--r--lib/rubygems/commands/outdated_command.rb1
-rw-r--r--lib/rubygems/commands/owner_command.rb27
-rw-r--r--lib/rubygems/commands/pristine_command.rb47
-rw-r--r--lib/rubygems/commands/push_command.rb60
-rw-r--r--lib/rubygems/commands/query_command.rb208
-rw-r--r--lib/rubygems/commands/rdoc_command.rb8
-rw-r--r--lib/rubygems/commands/search_command.rb1
-rw-r--r--lib/rubygems/commands/server_command.rb3
-rw-r--r--lib/rubygems/commands/setup_command.rb185
-rw-r--r--lib/rubygems/commands/signin_command.rb4
-rw-r--r--lib/rubygems/commands/signout_command.rb4
-rw-r--r--lib/rubygems/commands/sources_command.rb43
-rw-r--r--lib/rubygems/commands/specification_command.rb15
-rw-r--r--lib/rubygems/commands/stale_command.rb2
-rw-r--r--lib/rubygems/commands/uninstall_command.rb73
-rw-r--r--lib/rubygems/commands/unpack_command.rb52
-rw-r--r--lib/rubygems/commands/update_command.rb71
-rw-r--r--lib/rubygems/commands/which_command.rb14
-rw-r--r--lib/rubygems/commands/yank_command.rb13
-rw-r--r--lib/rubygems/compatibility.rb30
-rw-r--r--lib/rubygems/config_file.rb119
-rw-r--r--lib/rubygems/core_ext/kernel_gem.rb13
-rwxr-xr-x[-rw-r--r--]lib/rubygems/core_ext/kernel_require.rb64
-rw-r--r--lib/rubygems/core_ext/kernel_warn.rb55
-rw-r--r--lib/rubygems/defaults.rb69
-rw-r--r--lib/rubygems/dependency.rb58
-rw-r--r--lib/rubygems/dependency_installer.rb172
-rw-r--r--lib/rubygems/dependency_list.rb40
-rw-r--r--lib/rubygems/deprecate.rb15
-rw-r--r--lib/rubygems/doctor.rb11
-rw-r--r--lib/rubygems/errors.rb19
-rw-r--r--lib/rubygems/exceptions.rb34
-rw-r--r--lib/rubygems/ext.rb1
-rw-r--r--lib/rubygems/ext/build_error.rb1
-rw-r--r--lib/rubygems/ext/builder.rb92
-rw-r--r--lib/rubygems/ext/cmake_builder.rb6
-rw-r--r--lib/rubygems/ext/configure_builder.rb5
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb33
-rw-r--r--lib/rubygems/ext/rake_builder.rb34
-rw-r--r--lib/rubygems/gem_runner.rb4
-rw-r--r--lib/rubygems/gemcutter_utilities.rb67
-rw-r--r--lib/rubygems/indexer.rb45
-rw-r--r--lib/rubygems/install_default_message.rb1
-rw-r--r--lib/rubygems/install_message.rb1
-rw-r--r--lib/rubygems/install_update_options.rb34
-rw-r--r--lib/rubygems/installer.rb197
-rw-r--r--lib/rubygems/installer_test_case.rb142
-rw-r--r--lib/rubygems/local_remote_options.rb9
-rw-r--r--lib/rubygems/mock_gem_ui.rb12
-rw-r--r--lib/rubygems/name_tuple.rb11
-rw-r--r--lib/rubygems/package.rb207
-rw-r--r--lib/rubygems/package/digest_io.rb7
-rw-r--r--lib/rubygems/package/file_source.rb7
-rw-r--r--lib/rubygems/package/io_source.rb3
-rw-r--r--lib/rubygems/package/old.rb24
-rw-r--r--lib/rubygems/package/source.rb1
-rw-r--r--lib/rubygems/package/tar_header.rb21
-rw-r--r--lib/rubygems/package/tar_reader.rb30
-rw-r--r--lib/rubygems/package/tar_reader/entry.rb24
-rw-r--r--lib/rubygems/package/tar_test_case.rb10
-rw-r--r--lib/rubygems/package/tar_writer.rb33
-rw-r--r--lib/rubygems/package_task.rb1
-rw-r--r--lib/rubygems/path_support.rb26
-rw-r--r--lib/rubygems/platform.rb12
-rw-r--r--lib/rubygems/psych_tree.rb4
-rw-r--r--lib/rubygems/rdoc.rb315
-rw-r--r--lib/rubygems/remote_fetcher.rb166
-rw-r--r--lib/rubygems/request.rb43
-rw-r--r--lib/rubygems/request/connection_pools.rb45
-rw-r--r--lib/rubygems/request/http_pool.rb8
-rw-r--r--lib/rubygems/request/https_pool.rb6
-rw-r--r--lib/rubygems/request_set.rb126
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb103
-rw-r--r--lib/rubygems/request_set/lockfile.rb35
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb49
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb20
-rw-r--r--lib/rubygems/requirement.rb80
-rw-r--r--lib/rubygems/resolver.rb39
-rw-r--r--lib/rubygems/resolver/activation_request.rb74
-rw-r--r--lib/rubygems/resolver/api_set.rb13
-rw-r--r--lib/rubygems/resolver/api_specification.rb12
-rw-r--r--lib/rubygems/resolver/best_set.rb15
-rw-r--r--lib/rubygems/resolver/composed_set.rb11
-rw-r--r--lib/rubygems/resolver/conflict.rb15
-rw-r--r--lib/rubygems/resolver/current_set.rb3
-rw-r--r--lib/rubygems/resolver/dependency_request.rb8
-rw-r--r--lib/rubygems/resolver/git_set.rb11
-rw-r--r--lib/rubygems/resolver/git_specification.rb9
-rw-r--r--lib/rubygems/resolver/index_set.rb11
-rw-r--r--lib/rubygems/resolver/index_specification.rb7
-rw-r--r--lib/rubygems/resolver/installed_specification.rb7
-rw-r--r--lib/rubygems/resolver/installer_set.rb30
-rw-r--r--lib/rubygems/resolver/local_specification.rb3
-rw-r--r--lib/rubygems/resolver/lock_set.rb13
-rw-r--r--lib/rubygems/resolver/lock_specification.rb19
-rw-r--r--lib/rubygems/resolver/requirement_list.rb3
-rw-r--r--lib/rubygems/resolver/set.rb4
-rw-r--r--lib/rubygems/resolver/source_set.rb9
-rw-r--r--lib/rubygems/resolver/spec_specification.rb3
-rw-r--r--lib/rubygems/resolver/specification.rb18
-rw-r--r--lib/rubygems/resolver/stats.rb4
-rw-r--r--lib/rubygems/resolver/vendor_set.rb9
-rw-r--r--lib/rubygems/resolver/vendor_specification.rb5
-rw-r--r--lib/rubygems/s3_uri_signer.rb183
-rw-r--r--lib/rubygems/safe_yaml.rb28
-rw-r--r--lib/rubygems/security.rb48
-rw-r--r--lib/rubygems/security/policies.rb3
-rw-r--r--lib/rubygems/security/policy.rb50
-rw-r--r--lib/rubygems/security/signer.rb99
-rw-r--r--lib/rubygems/security/trust_dir.rb20
-rw-r--r--lib/rubygems/security_option.rb1
-rw-r--r--lib/rubygems/server.rb59
-rw-r--r--lib/rubygems/source.rb53
-rw-r--r--lib/rubygems/source/git.rb19
-rw-r--r--lib/rubygems/source/installed.rb7
-rw-r--r--lib/rubygems/source/local.rb14
-rw-r--r--lib/rubygems/source/lock.rb8
-rw-r--r--lib/rubygems/source/specific_file.rb10
-rw-r--r--lib/rubygems/source/vendor.rb5
-rw-r--r--lib/rubygems/source_list.rb7
-rw-r--r--lib/rubygems/source_local.rb1
-rw-r--r--lib/rubygems/spec_fetcher.rb30
-rw-r--r--lib/rubygems/specification.rb986
-rw-r--r--lib/rubygems/specification_policy.rb435
-rw-r--r--lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem21
-rw-r--r--lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem21
-rw-r--r--lib/rubygems/stub_specification.rb38
-rw-r--r--lib/rubygems/syck_hack.rb2
-rw-r--r--lib/rubygems/test_case.rb588
-rw-r--r--lib/rubygems/test_utilities.rb80
-rw-r--r--lib/rubygems/text.rb17
-rw-r--r--lib/rubygems/uninstaller.rb95
-rw-r--r--lib/rubygems/uri_formatter.rb4
-rw-r--r--lib/rubygems/uri_parser.rb36
-rw-r--r--lib/rubygems/uri_parsing.rb23
-rw-r--r--lib/rubygems/user_interaction.rb138
-rw-r--r--lib/rubygems/util.rb96
-rw-r--r--lib/rubygems/util/licenses.rb753
-rw-r--r--lib/rubygems/util/list.rb4
-rw-r--r--lib/rubygems/validator.rb47
-rw-r--r--lib/rubygems/version.rb86
-rw-r--r--lib/rubygems/version_option.rb5
-rw-r--r--lib/scanf.gemspec25
-rw-r--r--lib/scanf.rb776
-rw-r--r--lib/securerandom.rb90
-rw-r--r--lib/set.rb27
-rw-r--r--lib/shell.rb461
-rw-r--r--lib/shell/builtin-command.rb147
-rw-r--r--lib/shell/command-processor.rb671
-rw-r--r--lib/shell/error.rb26
-rw-r--r--lib/shell/filter.rb138
-rw-r--r--lib/shell/process-controller.rb309
-rw-r--r--lib/shell/system-command.rb159
-rw-r--r--lib/shell/version.rb16
-rw-r--r--lib/shellwords.rb2
-rw-r--r--lib/singleton.rb29
-rw-r--r--lib/singleton/singleton.gemspec27
-rw-r--r--lib/singleton/version.rb3
-rw-r--r--lib/sync.rb329
-rw-r--r--lib/tempfile.rb44
-rw-r--r--lib/thwait.rb140
-rw-r--r--lib/time.rb234
-rw-r--r--lib/timeout.rb4
-rw-r--r--lib/timeout/timeout.gemspec27
-rw-r--r--lib/timeout/version.rb3
-rw-r--r--lib/tmpdir.rb48
-rw-r--r--lib/tracer.rb15
-rw-r--r--lib/tracer/tracer.gemspec23
-rw-r--r--lib/tracer/version.rb5
-rw-r--r--lib/un.rb23
-rw-r--r--lib/unicode_normalize/normalize.rb4
-rw-r--r--lib/unicode_normalize/tables.rb10113
-rw-r--r--lib/uri.rb52
-rw-r--r--lib/uri/common.rb136
-rw-r--r--lib/uri/file.rb94
-rw-r--r--lib/uri/ftp.rb64
-rw-r--r--lib/uri/generic.rb361
-rw-r--r--lib/uri/http.rb22
-rw-r--r--lib/uri/https.rb2
-rw-r--r--lib/uri/ldap.rb81
-rw-r--r--lib/uri/ldaps.rb2
-rw-r--r--lib/uri/mailto.rb40
-rw-r--r--lib/uri/rfc2396_parser.rb52
-rw-r--r--lib/uri/rfc3986_parser.rb6
-rw-r--r--lib/uri/uri.gemspec29
-rw-r--r--lib/uri/version.rb6
-rw-r--r--lib/webrick.rb2
-rw-r--r--lib/webrick/accesslog.rb8
-rw-r--r--lib/webrick/cgi.rb6
-rw-r--r--lib/webrick/config.rb10
-rw-r--r--lib/webrick/cookie.rb2
-rw-r--r--lib/webrick/httpauth.rb10
-rw-r--r--lib/webrick/httpauth/basicauth.rb18
-rw-r--r--lib/webrick/httpauth/digestauth.rb6
-rw-r--r--lib/webrick/httpauth/htdigest.rb4
-rw-r--r--lib/webrick/httpauth/htgroup.rb11
-rw-r--r--lib/webrick/httpauth/htpasswd.rb41
-rw-r--r--lib/webrick/httpproxy.rb76
-rw-r--r--lib/webrick/httprequest.rb51
-rw-r--r--lib/webrick/httpresponse.rb83
-rw-r--r--lib/webrick/https.rb4
-rw-r--r--lib/webrick/httpserver.rb32
-rw-r--r--lib/webrick/httpservlet.rb10
-rw-r--r--lib/webrick/httpservlet/abstract.rb6
-rw-r--r--lib/webrick/httpservlet/cgihandler.rb12
-rw-r--r--lib/webrick/httpservlet/erbhandler.rb2
-rw-r--r--lib/webrick/httpservlet/filehandler.rb10
-rw-r--r--lib/webrick/httpservlet/prochandler.rb2
-rw-r--r--lib/webrick/httpstatus.rb2
-rw-r--r--lib/webrick/httputils.rb6
-rw-r--r--lib/webrick/server.rb4
-rw-r--r--lib/webrick/ssl.rb4
-rw-r--r--lib/webrick/version.rb2
-rw-r--r--lib/webrick/webrick.gemspec55
-rw-r--r--lib/yaml.rb11
-rw-r--r--lib/yaml/yaml.gemspec23
-rwxr-xr-xlibexec/bundle47
-rwxr-xr-xlibexec/bundler4
-rwxr-xr-xlibexec/irb11
-rwxr-xr-xlibexec/racc306
-rwxr-xr-xlibexec/racc2y195
-rwxr-xr-xlibexec/rdoc44
-rwxr-xr-xlibexec/ri12
-rwxr-xr-xlibexec/y2racc339
-rw-r--r--load.c415
-rw-r--r--loadpath.c1
-rw-r--r--localeinit.c1
-rw-r--r--main.c8
-rw-r--r--man/bundle-add.166
-rw-r--r--man/bundle-add.1.txt58
-rw-r--r--man/bundle-add.ronn46
-rw-r--r--man/bundle-binstubs.140
-rw-r--r--man/bundle-binstubs.1.txt48
-rw-r--r--man/bundle-binstubs.ronn43
-rw-r--r--man/bundle-cache.155
-rw-r--r--man/bundle-cache.1.txt78
-rw-r--r--man/bundle-cache.ronn72
-rw-r--r--man/bundle-check.131
-rw-r--r--man/bundle-check.1.txt33
-rw-r--r--man/bundle-check.ronn26
-rw-r--r--man/bundle-clean.124
-rw-r--r--man/bundle-clean.1.txt26
-rw-r--r--man/bundle-clean.ronn18
-rw-r--r--man/bundle-config.1497
-rw-r--r--man/bundle-config.1.txt528
-rw-r--r--man/bundle-config.ronn399
-rw-r--r--man/bundle-doctor.144
-rw-r--r--man/bundle-doctor.1.txt44
-rw-r--r--man/bundle-doctor.ronn33
-rw-r--r--man/bundle-exec.1165
-rw-r--r--man/bundle-exec.1.txt178
-rw-r--r--man/bundle-exec.ronn152
-rw-r--r--man/bundle-gem.180
-rw-r--r--man/bundle-gem.1.txt91
-rw-r--r--man/bundle-gem.ronn78
-rw-r--r--man/bundle-info.120
-rw-r--r--man/bundle-info.1.txt21
-rw-r--r--man/bundle-info.ronn17
-rw-r--r--man/bundle-init.125
-rw-r--r--man/bundle-init.1.txt34
-rw-r--r--man/bundle-init.ronn29
-rw-r--r--man/bundle-inject.133
-rw-r--r--man/bundle-inject.1.txt32
-rw-r--r--man/bundle-inject.ronn22
-rw-r--r--man/bundle-install.1311
-rw-r--r--man/bundle-install.1.txt401
-rw-r--r--man/bundle-install.ronn383
-rw-r--r--man/bundle-list.150
-rw-r--r--man/bundle-list.1.txt43
-rw-r--r--man/bundle-list.ronn33
-rw-r--r--man/bundle-lock.184
-rw-r--r--man/bundle-lock.1.txt93
-rw-r--r--man/bundle-lock.ronn94
-rw-r--r--man/bundle-open.132
-rw-r--r--man/bundle-open.1.txt29
-rw-r--r--man/bundle-open.ronn19
-rw-r--r--man/bundle-outdated.1155
-rw-r--r--man/bundle-outdated.1.txt131
-rw-r--r--man/bundle-outdated.ronn111
-rw-r--r--man/bundle-package.155
-rw-r--r--man/bundle-package.1.txt79
-rw-r--r--man/bundle-package.ronn72
-rw-r--r--man/bundle-platform.161
-rw-r--r--man/bundle-platform.1.txt57
-rw-r--r--man/bundle-platform.ronn42
-rw-r--r--man/bundle-pristine.134
-rw-r--r--man/bundle-pristine.1.txt44
-rw-r--r--man/bundle-pristine.ronn34
-rw-r--r--man/bundle-remove.131
-rw-r--r--man/bundle-remove.1.txt34
-rw-r--r--man/bundle-remove.ronn23
-rw-r--r--man/bundle-show.123
-rw-r--r--man/bundle-show.1.txt27
-rw-r--r--man/bundle-show.ronn21
-rw-r--r--man/bundle-update.1394
-rw-r--r--man/bundle-update.1.txt390
-rw-r--r--man/bundle-update.ronn350
-rw-r--r--man/bundle-viz.139
-rw-r--r--man/bundle-viz.1.txt39
-rw-r--r--man/bundle-viz.ronn30
-rw-r--r--man/bundle.1136
-rw-r--r--man/bundle.1.txt116
-rw-r--r--man/bundle.ronn111
-rw-r--r--man/erb.17
-rw-r--r--man/gemfile.5686
-rw-r--r--man/gemfile.5.ronn517
-rw-r--r--man/gemfile.5.txt649
-rw-r--r--man/goruby.12
-rw-r--r--man/index.txt25
-rw-r--r--man/irb.163
-rw-r--r--man/ruby.117
-rw-r--r--marshal.c260
-rw-r--r--math.c47
-rw-r--r--method.h72
-rw-r--r--mini_builtin.c83
-rw-r--r--miniinit.c2
-rw-r--r--misc/README18
-rwxr-xr-xmisc/expand_tabs.rb169
-rw-r--r--misc/inf-ruby.el418
-rwxr-xr-xmisc/lldb_cruby.py196
-rwxr-xr-xmisc/rb_optparse.zsh2
-rw-r--r--misc/rdoc-mode.el166
-rw-r--r--misc/ruby-additional.el181
-rw-r--r--misc/ruby-electric.el583
-rw-r--r--misc/ruby-mode.el1584
-rw-r--r--misc/ruby-style.el17
-rw-r--r--misc/rubydb2x.el104
-rw-r--r--misc/rubydb3x.el115
-rw-r--r--misc/test_lldb_cruby.rb8
-rw-r--r--missing/dtoa.c3417
-rw-r--r--missing/explicit_bzero.c8
-rw-r--r--missing/fileblocks.c1
-rw-r--r--missing/memcmp.c3
-rw-r--r--missing/mt19937.c158
-rw-r--r--missing/nan.c28
-rw-r--r--missing/procstat_vm.c85
-rw-r--r--missing/setproctitle.c5
-rw-r--r--missing/stdbool.h22
-rw-r--r--missing/x86_64-chkstk.s (renamed from missing/x86_64-chkstk.S)0
-rw-r--r--mjit.c1046
-rw-r--r--mjit.h177
-rw-r--r--mjit_compile.c478
-rw-r--r--mjit_worker.c1259
-rw-r--r--node.c473
-rw-r--r--node.h419
-rw-r--r--numeric.c527
-rw-r--r--object.c1308
-rw-r--r--pack.c424
-rw-r--r--pack.rb283
-rw-r--r--parse.y10351
-rw-r--r--prelude.rb138
-rw-r--r--probes_helper.h1
-rw-r--r--proc.c1385
-rw-r--r--process.c1553
-rw-r--r--random.c320
-rw-r--r--range.c787
-rw-r--r--rational.c616
-rw-r--r--re.c313
-rw-r--r--regcomp.c34
-rw-r--r--regenc.h2
-rw-r--r--regerror.c7
-rw-r--r--regexec.c7
-rw-r--r--regint.h2
-rw-r--r--regparse.c1009
-rw-r--r--regparse.h2
-rw-r--r--ruby-runner.c21
-rw-r--r--ruby.c515
-rw-r--r--ruby_assert.h55
-rw-r--r--ruby_atomic.h11
-rw-r--r--safe.c82
-rw-r--r--sample/README2
-rw-r--r--sample/biorhythm.rb9
-rw-r--r--sample/dir.rb2
-rw-r--r--sample/drb/http0serv.rb8
-rw-r--r--sample/drb/old_tuplespace.rb2
-rw-r--r--sample/fact.rb4
-rw-r--r--sample/fib.py2
-rw-r--r--sample/freq.rb12
-rw-r--r--sample/iseq_loader.rb6
-rw-r--r--sample/list3.rb2
-rw-r--r--sample/observ.rb2
-rw-r--r--sample/occur.rb2
-rw-r--r--sample/occur2.rb13
-rw-r--r--sample/ripper/ruby2html.rb6
-rwxr-xr-x[-rw-r--r--]sample/test.rb0
-rw-r--r--sample/timeout.rb18
-rw-r--r--sample/trick2013/kinaba/remarks.markdown4
-rw-r--r--sample/trick2013/mame/music-box.mp4bin0 -> 580724 bytes-rw-r--r--sample/trick2013/yhara/entry.rb2
-rw-r--r--sample/trick2015/ksk_1/remarks.markdown2
-rw-r--r--sample/trick2015/ksk_2/remarks.markdown4
-rw-r--r--sample/trick2018/01-kinaba/authors.markdown3
-rw-r--r--sample/trick2018/01-kinaba/entry.rb8
-rw-r--r--sample/trick2018/01-kinaba/remarks.markdown55
-rw-r--r--sample/trick2018/02-mame/authors.markdown3
-rw-r--r--sample/trick2018/02-mame/entry.rb15
-rw-r--r--sample/trick2018/02-mame/remarks.markdown16
-rw-r--r--sample/trick2018/03-tompng/Gemfile2
-rw-r--r--sample/trick2018/03-tompng/Gemfile.lock13
-rw-r--r--sample/trick2018/03-tompng/authors.markdown3
-rw-r--r--sample/trick2018/03-tompng/entry.rb31
-rw-r--r--sample/trick2018/03-tompng/output.txt44
-rw-r--r--sample/trick2018/03-tompng/remarks.markdown19
-rw-r--r--sample/trick2018/03-tompng/trick.pngbin5661 -> 0 bytes-rw-r--r--sample/trick2018/04-colin/authors.markdown3
-rw-r--r--sample/trick2018/04-colin/entry.rb2
-rw-r--r--sample/trick2018/04-colin/remarks.markdown62
-rw-r--r--sample/trick2018/05-tompng/authors.markdown3
-rw-r--r--sample/trick2018/05-tompng/entry.rb41
-rw-r--r--sample/trick2018/05-tompng/preview_of_output.pngbin66800 -> 0 bytes-rw-r--r--sample/trick2018/05-tompng/remarks.markdown31
-rw-r--r--sample/trick2018/README.md16
-rw-r--r--signal.c514
-rw-r--r--siphash.c2
-rw-r--r--siphash.h2
-rw-r--r--spec/README.md57
-rw-r--r--spec/bundler/bundler/build_metadata_spec.rb49
-rw-r--r--spec/bundler/bundler/bundler_spec.rb460
-rw-r--r--spec/bundler/bundler/cli_spec.rb223
-rw-r--r--spec/bundler/bundler/compact_index_client/updater_spec.rb55
-rw-r--r--spec/bundler/bundler/definition_spec.rb351
-rw-r--r--spec/bundler/bundler/dep_proxy_spec.rb22
-rw-r--r--spec/bundler/bundler/dsl_spec.rb302
-rw-r--r--spec/bundler/bundler/endpoint_specification_spec.rb71
-rw-r--r--spec/bundler/bundler/env_spec.rb200
-rw-r--r--spec/bundler/bundler/environment_preserver_spec.rb79
-rw-r--r--spec/bundler/bundler/fetcher/base_spec.rb76
-rw-r--r--spec/bundler/bundler/fetcher/compact_index_spec.rb106
-rw-r--r--spec/bundler/bundler/fetcher/dependency_spec.rb287
-rw-r--r--spec/bundler/bundler/fetcher/downloader_spec.rb269
-rw-r--r--spec/bundler/bundler/fetcher/index_spec.rb116
-rw-r--r--spec/bundler/bundler/fetcher_spec.rb161
-rw-r--r--spec/bundler/bundler/friendly_errors_spec.rb255
-rw-r--r--spec/bundler/bundler/gem_helper_spec.rb348
-rw-r--r--spec/bundler/bundler/gem_version_promoter_spec.rb179
-rw-r--r--spec/bundler/bundler/index_spec.rb36
-rw-r--r--spec/bundler/bundler/installer/gem_installer_spec.rb40
-rw-r--r--spec/bundler/bundler/installer/parallel_installer_spec.rb47
-rw-r--r--spec/bundler/bundler/installer/spec_installation_spec.rb62
-rw-r--r--spec/bundler/bundler/lockfile_parser_spec.rb153
-rw-r--r--spec/bundler/bundler/mirror_spec.rb329
-rw-r--r--spec/bundler/bundler/plugin/api/source_spec.rb82
-rw-r--r--spec/bundler/bundler/plugin/api_spec.rb83
-rw-r--r--spec/bundler/bundler/plugin/dsl_spec.rb38
-rw-r--r--spec/bundler/bundler/plugin/events_spec.rb22
-rw-r--r--spec/bundler/bundler/plugin/index_spec.rb197
-rw-r--r--spec/bundler/bundler/plugin/installer_spec.rb131
-rw-r--r--spec/bundler/bundler/plugin/source_list_spec.rb25
-rw-r--r--spec/bundler/bundler/plugin_spec.rb334
-rw-r--r--spec/bundler/bundler/psyched_yaml_spec.rb9
-rw-r--r--spec/bundler/bundler/remote_specification_spec.rb187
-rw-r--r--spec/bundler/bundler/retry_spec.rb81
-rw-r--r--spec/bundler/bundler/ruby_dsl_spec.rb95
-rw-r--r--spec/bundler/bundler/ruby_version_spec.rb528
-rw-r--r--spec/bundler/bundler/rubygems_integration_spec.rb102
-rw-r--r--spec/bundler/bundler/settings/validator_spec.rb111
-rw-r--r--spec/bundler/bundler/settings_spec.rb328
-rw-r--r--spec/bundler/bundler/shared_helpers_spec.rb515
-rw-r--r--spec/bundler/bundler/source/git/git_proxy_spec.rb148
-rw-r--r--spec/bundler/bundler/source/git_spec.rb28
-rw-r--r--spec/bundler/bundler/source/path_spec.rb31
-rw-r--r--spec/bundler/bundler/source/rubygems/remote_spec.rb172
-rw-r--r--spec/bundler/bundler/source/rubygems_spec.rb33
-rw-r--r--spec/bundler/bundler/source_list_spec.rb463
-rw-r--r--spec/bundler/bundler/source_spec.rb200
-rw-r--r--spec/bundler/bundler/spec_set_spec.rb77
-rw-r--r--spec/bundler/bundler/stub_specification_spec.rb22
-rw-r--r--spec/bundler/bundler/ui/shell_spec.rb53
-rw-r--r--spec/bundler/bundler/ui_spec.rb41
-rw-r--r--spec/bundler/bundler/uri_credentials_filter_spec.rb127
-rw-r--r--spec/bundler/bundler/vendored_persistent_spec.rb77
-rw-r--r--spec/bundler/bundler/version_ranges_spec.rb40
-rw-r--r--spec/bundler/bundler/worker_spec.rb22
-rw-r--r--spec/bundler/bundler/yaml_serializer_spec.rb194
-rw-r--r--spec/bundler/cache/cache_path_spec.rb32
-rw-r--r--spec/bundler/cache/gems_spec.rb304
-rw-r--r--spec/bundler/cache/git_spec.rb239
-rw-r--r--spec/bundler/cache/path_spec.rb144
-rw-r--r--spec/bundler/cache/platform_spec.rb49
-rw-r--r--spec/bundler/commands/add_spec.rb251
-rw-r--r--spec/bundler/commands/binstubs_spec.rb465
-rw-r--r--spec/bundler/commands/cache_spec.rb351
-rw-r--r--spec/bundler/commands/check_spec.rb359
-rw-r--r--spec/bundler/commands/clean_spec.rb892
-rw-r--r--spec/bundler/commands/config_spec.rb493
-rw-r--r--spec/bundler/commands/console_spec.rb106
-rw-r--r--spec/bundler/commands/doctor_spec.rb116
-rw-r--r--spec/bundler/commands/exec_spec.rb913
-rw-r--r--spec/bundler/commands/help_spec.rb89
-rw-r--r--spec/bundler/commands/info_spec.rb145
-rw-r--r--spec/bundler/commands/init_spec.rb177
-rw-r--r--spec/bundler/commands/inject_spec.rb117
-rw-r--r--spec/bundler/commands/install_spec.rb589
-rw-r--r--spec/bundler/commands/issue_spec.rb16
-rw-r--r--spec/bundler/commands/licenses_spec.rb31
-rw-r--r--spec/bundler/commands/list_spec.rb168
-rw-r--r--spec/bundler/commands/lock_spec.rb362
-rw-r--r--spec/bundler/commands/newgem_spec.rb732
-rw-r--r--spec/bundler/commands/open_spec.rb117
-rw-r--r--spec/bundler/commands/outdated_spec.rb780
-rw-r--r--spec/bundler/commands/post_bundle_message_spec.rb210
-rw-r--r--spec/bundler/commands/pristine_spec.rb191
-rw-r--r--spec/bundler/commands/remove_spec.rb595
-rw-r--r--spec/bundler/commands/show_spec.rb225
-rw-r--r--spec/bundler/commands/update_spec.rb1021
-rw-r--r--spec/bundler/commands/version_spec.rb47
-rw-r--r--spec/bundler/commands/viz_spec.rb149
-rw-r--r--spec/bundler/install/allow_offline_install_spec.rb92
-rw-r--r--spec/bundler/install/binstubs_spec.rb51
-rw-r--r--spec/bundler/install/bundler_spec.rb182
-rw-r--r--spec/bundler/install/deploy_spec.rb429
-rw-r--r--spec/bundler/install/failure_spec.rb144
-rw-r--r--spec/bundler/install/gemfile/eval_gemfile_spec.rb82
-rw-r--r--spec/bundler/install/gemfile/gemspec_spec.rb583
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb1455
-rw-r--r--spec/bundler/install/gemfile/groups_spec.rb384
-rw-r--r--spec/bundler/install/gemfile/install_if.rb44
-rw-r--r--spec/bundler/install/gemfile/lockfile_spec.rb48
-rw-r--r--spec/bundler/install/gemfile/path_spec.rb747
-rw-r--r--spec/bundler/install/gemfile/platform_spec.rb425
-rw-r--r--spec/bundler/install/gemfile/ruby_spec.rb108
-rw-r--r--spec/bundler/install/gemfile/sources_spec.rb647
-rw-r--r--spec/bundler/install/gemfile/specific_platform_spec.rb114
-rw-r--r--spec/bundler/install/gemfile_spec.rb124
-rw-r--r--spec/bundler/install/gems/compact_index_spec.rb940
-rw-r--r--spec/bundler/install/gems/dependency_api_spec.rb760
-rw-r--r--spec/bundler/install/gems/env_spec.rb107
-rw-r--r--spec/bundler/install/gems/flex_spec.rb353
-rw-r--r--spec/bundler/install/gems/mirror_spec.rb39
-rw-r--r--spec/bundler/install/gems/native_extensions_spec.rb131
-rw-r--r--spec/bundler/install/gems/post_install_spec.rb150
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb214
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb337
-rw-r--r--spec/bundler/install/gems/sudo_spec.rb187
-rw-r--r--spec/bundler/install/gems/win32_spec.rb26
-rw-r--r--spec/bundler/install/gemspecs_spec.rb151
-rw-r--r--spec/bundler/install/git_spec.rb85
-rw-r--r--spec/bundler/install/global_cache_spec.rb235
-rw-r--r--spec/bundler/install/path_spec.rb221
-rw-r--r--spec/bundler/install/prereleases_spec.rb41
-rw-r--r--spec/bundler/install/process_lock_spec.rb35
-rw-r--r--spec/bundler/install/redownload_spec.rb90
-rw-r--r--spec/bundler/install/security_policy_spec.rb76
-rw-r--r--spec/bundler/install/yanked_spec.rb73
-rw-r--r--spec/bundler/lock/git_spec.rb34
-rw-r--r--spec/bundler/lock/lockfile_spec.rb1489
-rw-r--r--spec/bundler/other/cli_dispatch_spec.rb20
-rw-r--r--spec/bundler/other/ext_spec.rb61
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb562
-rw-r--r--spec/bundler/other/platform_spec.rb1307
-rw-r--r--spec/bundler/plugins/command_spec.rb80
-rw-r--r--spec/bundler/plugins/hook_spec.rb109
-rw-r--r--spec/bundler/plugins/install_spec.rb309
-rw-r--r--spec/bundler/plugins/list_spec.rb60
-rw-r--r--spec/bundler/plugins/source/example_spec.rb508
-rw-r--r--spec/bundler/plugins/source_spec.rb108
-rw-r--r--spec/bundler/quality_es_spec.rb65
-rw-r--r--spec/bundler/quality_spec.rb289
-rw-r--r--spec/bundler/realworld/dependency_api_spec.rb46
-rw-r--r--spec/bundler/realworld/double_check_spec.rb40
-rw-r--r--spec/bundler/realworld/edgecases_spec.rb347
-rw-r--r--spec/bundler/realworld/gemfile_source_header_spec.rb53
-rw-r--r--spec/bundler/realworld/mirror_probe_spec.rb144
-rw-r--r--spec/bundler/realworld/parallel_spec.rb66
-rw-r--r--spec/bundler/resolver/basic_spec.rb308
-rw-r--r--spec/bundler/resolver/platform_spec.rb100
-rw-r--r--spec/bundler/runtime/executable_spec.rb173
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb80
-rw-r--r--spec/bundler/runtime/inline_spec.rb353
-rw-r--r--spec/bundler/runtime/load_spec.rb111
-rw-r--r--spec/bundler/runtime/platform_spec.rb169
-rw-r--r--spec/bundler/runtime/require_spec.rb450
-rw-r--r--spec/bundler/runtime/setup_spec.rb1375
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb270
-rw-r--r--spec/bundler/spec_helper.rb130
-rw-r--r--spec/bundler/support/artifice/compact_index.rb118
-rw-r--r--spec/bundler/support/artifice/compact_index_api_missing.rb18
-rw-r--r--spec/bundler/support/artifice/compact_index_basic_authentication.rb15
-rw-r--r--spec/bundler/support/artifice/compact_index_checksum_mismatch.rb16
-rw-r--r--spec/bundler/support/artifice/compact_index_concurrent_download.rb32
-rw-r--r--spec/bundler/support/artifice/compact_index_creds_diff_host.rb39
-rw-r--r--spec/bundler/support/artifice/compact_index_extra.rb37
-rw-r--r--spec/bundler/support/artifice/compact_index_extra_api.rb52
-rw-r--r--spec/bundler/support/artifice/compact_index_extra_api_missing.rb17
-rw-r--r--spec/bundler/support/artifice/compact_index_extra_missing.rb17
-rw-r--r--spec/bundler/support/artifice/compact_index_forbidden.rb13
-rw-r--r--spec/bundler/support/artifice/compact_index_host_redirect.rb21
-rw-r--r--spec/bundler/support/artifice/compact_index_no_gem.rb13
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update.rb38
-rw-r--r--spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb34
-rw-r--r--spec/bundler/support/artifice/compact_index_rate_limited.rb48
-rw-r--r--spec/bundler/support/artifice/compact_index_redirects.rb21
-rw-r--r--spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb20
-rw-r--r--spec/bundler/support/artifice/compact_index_wrong_dependencies.rb17
-rw-r--r--spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb20
-rw-r--r--spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb15
-rw-r--r--spec/bundler/support/artifice/endpoint.rb100
-rw-r--r--spec/bundler/support/artifice/endpoint_500.rb19
-rw-r--r--spec/bundler/support/artifice/endpoint_api_forbidden.rb13
-rw-r--r--spec/bundler/support/artifice/endpoint_api_missing.rb18
-rw-r--r--spec/bundler/support/artifice/endpoint_basic_authentication.rb15
-rw-r--r--spec/bundler/support/artifice/endpoint_creds_diff_host.rb39
-rw-r--r--spec/bundler/support/artifice/endpoint_extra.rb33
-rw-r--r--spec/bundler/support/artifice/endpoint_extra_api.rb34
-rw-r--r--spec/bundler/support/artifice/endpoint_extra_missing.rb17
-rw-r--r--spec/bundler/support/artifice/endpoint_fallback.rb19
-rw-r--r--spec/bundler/support/artifice/endpoint_host_redirect.rb17
-rw-r--r--spec/bundler/support/artifice/endpoint_marshal_fail.rb13
-rw-r--r--spec/bundler/support/artifice/endpoint_mirror_source.rb15
-rw-r--r--spec/bundler/support/artifice/endpoint_redirect.rb17
-rw-r--r--spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb20
-rw-r--r--spec/bundler/support/artifice/endpoint_timeout.rb15
-rw-r--r--spec/bundler/support/artifice/fail.rb39
-rw-r--r--spec/bundler/support/artifice/vcr.rb152
-rw-r--r--spec/bundler/support/artifice/windows.rb47
-rw-r--r--spec/bundler/support/builders.rb823
-rw-r--r--spec/bundler/support/command_execution.rb44
-rw-r--r--spec/bundler/support/filters.rb45
-rw-r--r--spec/bundler/support/hax.rb68
-rw-r--r--spec/bundler/support/helpers.rb587
-rw-r--r--spec/bundler/support/indexes.rb421
-rw-r--r--spec/bundler/support/matchers.rb224
-rw-r--r--spec/bundler/support/parallel.rb5
-rw-r--r--spec/bundler/support/path.rb191
-rw-r--r--spec/bundler/support/permissions.rb12
-rw-r--r--spec/bundler/support/platforms.rb106
-rw-r--r--spec/bundler/support/rubygems_ext.rb107
-rw-r--r--spec/bundler/support/rubygems_version_manager.rb103
-rw-r--r--spec/bundler/support/silent_logger.rb10
-rw-r--r--spec/bundler/support/sometimes.rb57
-rw-r--r--spec/bundler/support/streams.rb19
-rw-r--r--spec/bundler/support/sudo.rb18
-rw-r--r--spec/bundler/support/the_bundle.rb35
-rw-r--r--spec/bundler/update/gemfile_spec.rb49
-rw-r--r--spec/bundler/update/gems/post_install_spec.rb76
-rw-r--r--spec/bundler/update/git_spec.rb374
-rw-r--r--spec/bundler/update/path_spec.rb18
-rw-r--r--spec/bundler/update/redownload_spec.rb34
-rw-r--r--spec/mspec/.gitignore26
-rw-r--r--spec/mspec/.travis.yml18
-rw-r--r--spec/mspec/Gemfile.lock7
-rw-r--r--spec/mspec/README.md33
-rw-r--r--spec/mspec/Rakefile1
-rw-r--r--spec/mspec/lib/mspec.rb14
-rwxr-xr-xspec/mspec/lib/mspec/commands/mkspec.rb4
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-ci.rb3
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-run.rb3
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-tag.rb3
-rwxr-xr-xspec/mspec/lib/mspec/commands/mspec.rb68
-rw-r--r--spec/mspec/lib/mspec/expectations/expectations.rb18
-rw-r--r--spec/mspec/lib/mspec/expectations/should.rb12
-rw-r--r--spec/mspec/lib/mspec/guards/conflict.rb6
-rw-r--r--spec/mspec/lib/mspec/guards/feature.rb4
-rw-r--r--spec/mspec/lib/mspec/guards/platform.rb33
-rw-r--r--spec/mspec/lib/mspec/helpers/datetime.rb2
-rw-r--r--spec/mspec/lib/mspec/helpers/flunk.rb2
-rw-r--r--spec/mspec/lib/mspec/helpers/frozen_error_class.rb2
-rw-r--r--spec/mspec/lib/mspec/helpers/fs.rb10
-rw-r--r--spec/mspec/lib/mspec/helpers/io.rb36
-rw-r--r--spec/mspec/lib/mspec/helpers/numeric.rb2
-rw-r--r--spec/mspec/lib/mspec/helpers/ruby_exe.rb59
-rw-r--r--spec/mspec/lib/mspec/helpers/tmp.rb2
-rw-r--r--spec/mspec/lib/mspec/helpers/warning.rb12
-rw-r--r--spec/mspec/lib/mspec/matchers.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/base.rb86
-rw-r--r--spec/mspec/lib/mspec/matchers/be_close.rb4
-rw-r--r--spec/mspec/lib/mspec/matchers/block_caller.rb30
-rw-r--r--spec/mspec/lib/mspec/matchers/complain.rb25
-rw-r--r--spec/mspec/lib/mspec/matchers/eql.rb8
-rw-r--r--spec/mspec/lib/mspec/matchers/equal.rb8
-rw-r--r--spec/mspec/lib/mspec/matchers/equal_element.rb4
-rw-r--r--spec/mspec/lib/mspec/matchers/have_instance_method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/have_method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/have_private_instance_method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/have_private_method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/have_protected_instance_method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/have_public_instance_method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/have_singleton_method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/include_any_of.rb29
-rw-r--r--spec/mspec/lib/mspec/matchers/method.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/output.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/raise_error.rb19
-rw-r--r--spec/mspec/lib/mspec/matchers/skip.rb5
-rw-r--r--spec/mspec/lib/mspec/mocks/mock.rb22
-rw-r--r--spec/mspec/lib/mspec/mocks/object.rb4
-rw-r--r--spec/mspec/lib/mspec/mocks/proxy.rb6
-rw-r--r--spec/mspec/lib/mspec/runner/actions/constants_leak_checker.rb79
-rw-r--r--spec/mspec/lib/mspec/runner/actions/filter.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/actions/leakchecker.rb113
-rw-r--r--spec/mspec/lib/mspec/runner/actions/profile.rb60
-rw-r--r--spec/mspec/lib/mspec/runner/actions/tag.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/actions/taglist.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/actions/tally.rb14
-rw-r--r--spec/mspec/lib/mspec/runner/actions/timeout.rb60
-rw-r--r--spec/mspec/lib/mspec/runner/context.rb6
-rw-r--r--spec/mspec/lib/mspec/runner/evaluate.rb4
-rw-r--r--spec/mspec/lib/mspec/runner/example.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/filters/regexp.rb24
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/base.rb128
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/describe.rb1
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/dotted.rb110
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/file.rb9
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/html.rb10
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/junit.rb9
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/method.rb14
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/multi.rb42
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/profile.rb60
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/specdoc.rb14
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/spinner.rb18
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/summary.rb11
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/unit.rb1
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/yaml.rb10
-rw-r--r--spec/mspec/lib/mspec/runner/mspec.rb12
-rw-r--r--spec/mspec/lib/mspec/runner/object.rb10
-rw-r--r--spec/mspec/lib/mspec/runner/parallel.rb98
-rw-r--r--spec/mspec/lib/mspec/runner/shared.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/tag.rb2
-rw-r--r--spec/mspec/lib/mspec/utils/format.rb20
-rw-r--r--spec/mspec/lib/mspec/utils/name_map.rb51
-rw-r--r--spec/mspec/lib/mspec/utils/options.rb18
-rw-r--r--spec/mspec/lib/mspec/utils/script.rb28
-rw-r--r--spec/mspec/lib/mspec/utils/warnings.rb2
-rw-r--r--spec/mspec/spec/commands/mkspec_spec.rb4
-rw-r--r--spec/mspec/spec/expectations/should.rb2
-rw-r--r--spec/mspec/spec/expectations/should_spec.rb10
-rw-r--r--spec/mspec/spec/fixtures/chatty_spec.rb8
-rw-r--r--spec/mspec/spec/fixtures/die_spec.rb7
-rw-r--r--spec/mspec/spec/guards/conflict_spec.rb2
-rw-r--r--spec/mspec/spec/guards/feature_spec.rb40
-rw-r--r--spec/mspec/spec/guards/platform_spec.rb47
-rw-r--r--spec/mspec/spec/helpers/io_spec.rb46
-rw-r--r--spec/mspec/spec/integration/run_spec.rb35
-rw-r--r--spec/mspec/spec/integration/tag_spec.rb10
-rw-r--r--spec/mspec/spec/matchers/base_spec.rb219
-rw-r--r--spec/mspec/spec/matchers/be_close_spec.rb10
-rw-r--r--spec/mspec/spec/matchers/complain_spec.rb47
-rw-r--r--spec/mspec/spec/matchers/eql_spec.rb4
-rw-r--r--spec/mspec/spec/matchers/equal_element_spec.rb12
-rw-r--r--spec/mspec/spec/matchers/equal_spec.rb4
-rw-r--r--spec/mspec/spec/matchers/include_any_of_spec.rb42
-rw-r--r--spec/mspec/spec/matchers/raise_error_spec.rb14
-rw-r--r--spec/mspec/spec/mocks/mock_spec.rb65
-rw-r--r--spec/mspec/spec/runner/filters/regexp_spec.rb20
-rw-r--r--spec/mspec/spec/runner/formatters/dotted_spec.rb2
-rw-r--r--spec/mspec/spec/runner/formatters/multi_spec.rb8
-rw-r--r--spec/mspec/spec/spec_helper.rb2
-rw-r--r--spec/mspec/spec/utils/name_map_spec.rb4
-rw-r--r--spec/mspec/spec/utils/script_spec.rb12
-rwxr-xr-xspec/mspec/tool/pull-latest-mspec-spec26
-rw-r--r--spec/mspec/tool/remove_old_guards.rb34
-rw-r--r--spec/mspec/tool/sync/sync-rubyspec.rb54
-rwxr-xr-xspec/mspec/tool/tag_from_output.rb42
-rw-r--r--spec/ruby/.mspec.constants225
-rw-r--r--spec/ruby/.rubocop.yml66
-rw-r--r--spec/ruby/.rubocop_todo.yml88
-rw-r--r--spec/ruby/.travis.yml36
-rw-r--r--spec/ruby/CHANGES.before-2008-05-1017796
-rw-r--r--spec/ruby/CONTRIBUTING.md88
-rw-r--r--spec/ruby/README.md65
-rw-r--r--spec/ruby/appveyor.yml30
-rw-r--r--spec/ruby/command_line/dash_a_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_c_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_d_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_e_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_encoding_spec.rb30
-rw-r--r--spec/ruby/command_line/dash_external_encoding_spec.rb15
-rw-r--r--spec/ruby/command_line/dash_internal_encoding_spec.rb15
-rw-r--r--spec/ruby/command_line/dash_n_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_p_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_r_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_s_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_c_spec.rb20
-rw-r--r--spec/ruby/command_line/dash_upper_e_spec.rb29
-rw-r--r--spec/ruby/command_line/dash_upper_f_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_i_spec.rb42
-rw-r--r--spec/ruby/command_line/dash_upper_k_spec.rb76
-rw-r--r--spec/ruby/command_line/dash_upper_s_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_u_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_w_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_upper_x_spec.rb6
-rw-r--r--spec/ruby/command_line/dash_v_spec.rb6
-rw-r--r--spec/ruby/command_line/dash_w_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_x_spec.rb4
-rw-r--r--spec/ruby/command_line/error_message_spec.rb2
-rw-r--r--spec/ruby/command_line/feature_spec.rb56
-rw-r--r--[-rwxr-xr-x]spec/ruby/command_line/fixtures/bin/launcher.rb0
-rw-r--r--spec/ruby/command_line/fixtures/dash_upper_c_script.rb (renamed from spec/ruby/command_line/fixtures/change_directory_script.rb)0
-rw-r--r--spec/ruby/command_line/frozen_strings_spec.rb41
-rw-r--r--spec/ruby/command_line/rubylib_spec.rb69
-rw-r--r--spec/ruby/command_line/rubyopt_spec.rb22
-rw-r--r--spec/ruby/command_line/shared/change_directory.rb21
-rw-r--r--spec/ruby/command_line/shared/verbose.rb2
-rw-r--r--spec/ruby/command_line/syntax_error_spec.rb2
-rw-r--r--spec/ruby/core/argf/argf_spec.rb2
-rw-r--r--spec/ruby/core/argf/argv_spec.rb2
-rw-r--r--spec/ruby/core/argf/binmode_spec.rb10
-rw-r--r--spec/ruby/core/argf/bytes_spec.rb4
-rw-r--r--spec/ruby/core/argf/chars_spec.rb4
-rw-r--r--spec/ruby/core/argf/close_spec.rb21
-rw-r--r--spec/ruby/core/argf/closed_spec.rb2
-rw-r--r--spec/ruby/core/argf/codepoints_spec.rb4
-rw-r--r--spec/ruby/core/argf/each_byte_spec.rb4
-rw-r--r--spec/ruby/core/argf/each_char_spec.rb4
-rw-r--r--spec/ruby/core/argf/each_codepoint_spec.rb4
-rw-r--r--spec/ruby/core/argf/each_line_spec.rb4
-rw-r--r--spec/ruby/core/argf/each_spec.rb4
-rw-r--r--spec/ruby/core/argf/eof_spec.rb4
-rw-r--r--spec/ruby/core/argf/file_spec.rb2
-rw-r--r--spec/ruby/core/argf/filename_spec.rb4
-rw-r--r--spec/ruby/core/argf/fileno_spec.rb4
-rw-r--r--spec/ruby/core/argf/getc_spec.rb4
-rw-r--r--spec/ruby/core/argf/gets_spec.rb34
-rw-r--r--spec/ruby/core/argf/lineno_spec.rb2
-rw-r--r--spec/ruby/core/argf/lines_spec.rb4
-rw-r--r--spec/ruby/core/argf/path_spec.rb4
-rw-r--r--spec/ruby/core/argf/pos_spec.rb4
-rw-r--r--spec/ruby/core/argf/read_nonblock_spec.rb14
-rw-r--r--spec/ruby/core/argf/read_spec.rb34
-rw-r--r--spec/ruby/core/argf/readchar_spec.rb6
-rw-r--r--spec/ruby/core/argf/readline_spec.rb6
-rw-r--r--spec/ruby/core/argf/readlines_spec.rb4
-rw-r--r--spec/ruby/core/argf/readpartial_spec.rb22
-rw-r--r--spec/ruby/core/argf/rewind_spec.rb4
-rw-r--r--spec/ruby/core/argf/seek_spec.rb4
-rw-r--r--spec/ruby/core/argf/set_encoding_spec.rb2
-rw-r--r--spec/ruby/core/argf/shared/eof.rb2
-rw-r--r--spec/ruby/core/argf/shared/fileno.rb2
-rw-r--r--spec/ruby/core/argf/shared/pos.rb2
-rw-r--r--spec/ruby/core/argf/skip_spec.rb4
-rw-r--r--spec/ruby/core/argf/tell_spec.rb4
-rw-r--r--spec/ruby/core/argf/to_a_spec.rb4
-rw-r--r--spec/ruby/core/argf/to_i_spec.rb4
-rw-r--r--spec/ruby/core/argf/to_io_spec.rb2
-rw-r--r--spec/ruby/core/argf/to_s_spec.rb2
-rw-r--r--spec/ruby/core/array/allocate_spec.rb4
-rw-r--r--spec/ruby/core/array/any_spec.rb2
-rw-r--r--spec/ruby/core/array/append_spec.rb12
-rw-r--r--spec/ruby/core/array/array_spec.rb2
-rw-r--r--spec/ruby/core/array/assoc_spec.rb4
-rw-r--r--spec/ruby/core/array/at_spec.rb8
-rw-r--r--spec/ruby/core/array/bsearch_index_spec.rb124
-rw-r--r--spec/ruby/core/array/bsearch_spec.rb8
-rw-r--r--spec/ruby/core/array/clear_spec.rb41
-rw-r--r--spec/ruby/core/array/clone_spec.rb6
-rw-r--r--spec/ruby/core/array/collect_spec.rb10
-rw-r--r--spec/ruby/core/array/combination_spec.rb4
-rw-r--r--spec/ruby/core/array/compact_spec.rb54
-rw-r--r--spec/ruby/core/array/comparison_spec.rb4
-rw-r--r--spec/ruby/core/array/concat_spec.rb138
-rw-r--r--spec/ruby/core/array/constructor_spec.rb4
-rw-r--r--spec/ruby/core/array/count_spec.rb2
-rw-r--r--spec/ruby/core/array/cycle_spec.rb20
-rw-r--r--spec/ruby/core/array/delete_at_spec.rb50
-rw-r--r--spec/ruby/core/array/delete_if_spec.rb42
-rw-r--r--spec/ruby/core/array/delete_spec.rb44
-rw-r--r--spec/ruby/core/array/difference_spec.rb24
-rw-r--r--spec/ruby/core/array/dig_spec.rb100
-rw-r--r--spec/ruby/core/array/drop_spec.rb22
-rw-r--r--spec/ruby/core/array/drop_while_spec.rb2
-rw-r--r--spec/ruby/core/array/dup_spec.rb6
-rw-r--r--spec/ruby/core/array/each_index_spec.rb8
-rw-r--r--spec/ruby/core/array/each_spec.rb24
-rw-r--r--spec/ruby/core/array/element_reference_spec.rb8
-rw-r--r--spec/ruby/core/array/element_set_spec.rb89
-rw-r--r--spec/ruby/core/array/empty_spec.rb4
-rw-r--r--spec/ruby/core/array/eql_spec.rb12
-rw-r--r--spec/ruby/core/array/equal_value_spec.rb12
-rw-r--r--spec/ruby/core/array/fetch_spec.rb14
-rw-r--r--spec/ruby/core/array/fill_spec.rb80
-rw-r--r--spec/ruby/core/array/filter_spec.rb16
-rw-r--r--spec/ruby/core/array/find_index_spec.rb4
-rw-r--r--spec/ruby/core/array/first_spec.rb14
-rw-r--r--spec/ruby/core/array/fixtures/classes.rb19
-rw-r--r--spec/ruby/core/array/fixtures/encoded_strings.rb16
-rw-r--r--spec/ruby/core/array/flatten_spec.rb52
-rw-r--r--spec/ruby/core/array/frozen_spec.rb4
-rw-r--r--spec/ruby/core/array/hash_spec.rb8
-rw-r--r--spec/ruby/core/array/include_spec.rb4
-rw-r--r--spec/ruby/core/array/index_spec.rb6
-rw-r--r--spec/ruby/core/array/initialize_spec.rb34
-rw-r--r--spec/ruby/core/array/insert_spec.rb18
-rw-r--r--spec/ruby/core/array/inspect_spec.rb6
-rw-r--r--spec/ruby/core/array/intersection_spec.rb4
-rw-r--r--spec/ruby/core/array/join_spec.rb18
-rw-r--r--spec/ruby/core/array/keep_if_spec.rb2
-rw-r--r--spec/ruby/core/array/last_spec.rb14
-rw-r--r--spec/ruby/core/array/length_spec.rb8
-rw-r--r--spec/ruby/core/array/map_spec.rb10
-rw-r--r--spec/ruby/core/array/max_spec.rb14
-rw-r--r--spec/ruby/core/array/min_spec.rb14
-rw-r--r--spec/ruby/core/array/minus_spec.rb88
-rw-r--r--spec/ruby/core/array/multiply_spec.rb82
-rw-r--r--spec/ruby/core/array/new_spec.rb24
-rw-r--r--spec/ruby/core/array/pack/a_spec.rb13
-rw-r--r--spec/ruby/core/array/pack/at_spec.rb8
-rw-r--r--spec/ruby/core/array/pack/b_spec.rb21
-rw-r--r--spec/ruby/core/array/pack/buffer_spec.rb76
-rw-r--r--spec/ruby/core/array/pack/c_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/comment_spec.rb6
-rw-r--r--spec/ruby/core/array/pack/d_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/e_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/empty_spec.rb2
-rw-r--r--spec/ruby/core/array/pack/f_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/g_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/h_spec.rb21
-rw-r--r--spec/ruby/core/array/pack/i_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/j_spec.rb319
-rw-r--r--spec/ruby/core/array/pack/l_spec.rb26
-rw-r--r--spec/ruby/core/array/pack/m_spec.rb19
-rw-r--r--spec/ruby/core/array/pack/n_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/p_spec.rb57
-rw-r--r--spec/ruby/core/array/pack/percent_spec.rb4
-rw-r--r--spec/ruby/core/array/pack/q_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/s_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/shared/basic.rb22
-rw-r--r--spec/ruby/core/array/pack/shared/encodings.rb4
-rw-r--r--spec/ruby/core/array/pack/shared/float.rb70
-rw-r--r--spec/ruby/core/array/pack/shared/integer.rb2
-rw-r--r--spec/ruby/core/array/pack/shared/numeric_basic.rb20
-rw-r--r--spec/ruby/core/array/pack/shared/string.rb46
-rw-r--r--spec/ruby/core/array/pack/shared/taint.rb35
-rw-r--r--spec/ruby/core/array/pack/shared/unicode.rb6
-rw-r--r--spec/ruby/core/array/pack/u_spec.rb20
-rw-r--r--spec/ruby/core/array/pack/v_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/w_spec.rb16
-rw-r--r--spec/ruby/core/array/pack/x_spec.rb12
-rw-r--r--spec/ruby/core/array/pack/z_spec.rb12
-rw-r--r--spec/ruby/core/array/partition_spec.rb4
-rw-r--r--spec/ruby/core/array/permutation_spec.rb4
-rw-r--r--spec/ruby/core/array/plus_spec.rb30
-rw-r--r--spec/ruby/core/array/pop_spec.rb106
-rw-r--r--spec/ruby/core/array/prepend_spec.rb8
-rw-r--r--spec/ruby/core/array/product_spec.rb12
-rw-r--r--spec/ruby/core/array/push_spec.rb8
-rw-r--r--spec/ruby/core/array/rassoc_spec.rb6
-rw-r--r--spec/ruby/core/array/reject_spec.rb48
-rw-r--r--spec/ruby/core/array/repeated_combination_spec.rb4
-rw-r--r--spec/ruby/core/array/repeated_permutation_spec.rb2
-rw-r--r--spec/ruby/core/array/replace_spec.rb8
-rw-r--r--spec/ruby/core/array/reverse_each_spec.rb8
-rw-r--r--spec/ruby/core/array/reverse_spec.rb8
-rw-r--r--spec/ruby/core/array/rindex_spec.rb6
-rw-r--r--spec/ruby/core/array/rotate_spec.rb22
-rw-r--r--spec/ruby/core/array/sample_spec.rb16
-rw-r--r--spec/ruby/core/array/select_spec.rb28
-rw-r--r--spec/ruby/core/array/shared/clone.rb40
-rw-r--r--spec/ruby/core/array/shared/collect.rb70
-rw-r--r--spec/ruby/core/array/shared/delete_if.rb24
-rw-r--r--spec/ruby/core/array/shared/difference.rb78
-rw-r--r--spec/ruby/core/array/shared/inspect.rb61
-rw-r--r--spec/ruby/core/array/shared/join.rb122
-rw-r--r--spec/ruby/core/array/shared/keep_if.rb14
-rw-r--r--spec/ruby/core/array/shared/push.rb6
-rw-r--r--spec/ruby/core/array/shared/replace.rb6
-rw-r--r--spec/ruby/core/array/shared/select.rb32
-rw-r--r--spec/ruby/core/array/shared/slice.rb37
-rw-r--r--spec/ruby/core/array/shared/union.rb79
-rw-r--r--spec/ruby/core/array/shared/unshift.rb8
-rw-r--r--spec/ruby/core/array/shift_spec.rb46
-rw-r--r--spec/ruby/core/array/shuffle_spec.rb16
-rw-r--r--spec/ruby/core/array/size_spec.rb8
-rw-r--r--spec/ruby/core/array/slice_spec.rb16
-rw-r--r--spec/ruby/core/array/sort_by_spec.rb14
-rw-r--r--spec/ruby/core/array/sort_spec.rb16
-rw-r--r--spec/ruby/core/array/sum_spec.rb82
-rw-r--r--spec/ruby/core/array/take_spec.rb4
-rw-r--r--spec/ruby/core/array/take_while_spec.rb2
-rw-r--r--spec/ruby/core/array/to_a_spec.rb4
-rw-r--r--spec/ruby/core/array/to_ary_spec.rb4
-rw-r--r--spec/ruby/core/array/to_h_spec.rb54
-rw-r--r--spec/ruby/core/array/to_s_spec.rb8
-rw-r--r--spec/ruby/core/array/transpose_spec.rb8
-rw-r--r--spec/ruby/core/array/try_convert_spec.rb8
-rw-r--r--spec/ruby/core/array/union_spec.rb91
-rw-r--r--spec/ruby/core/array/uniq_spec.rb104
-rw-r--r--spec/ruby/core/array/unshift_spec.rb8
-rw-r--r--spec/ruby/core/array/values_at_spec.rb4
-rw-r--r--spec/ruby/core/array/zip_spec.rb6
-rw-r--r--spec/ruby/core/basicobject/__id__spec.rb4
-rw-r--r--spec/ruby/core/basicobject/__send___spec.rb6
-rw-r--r--spec/ruby/core/basicobject/basicobject_spec.rb14
-rw-r--r--spec/ruby/core/basicobject/equal_spec.rb4
-rw-r--r--spec/ruby/core/basicobject/equal_value_spec.rb4
-rw-r--r--spec/ruby/core/basicobject/initialize_spec.rb4
-rw-r--r--spec/ruby/core/basicobject/instance_eval_spec.rb26
-rw-r--r--spec/ruby/core/basicobject/instance_exec_spec.rb18
-rw-r--r--spec/ruby/core/basicobject/method_missing_spec.rb2
-rw-r--r--spec/ruby/core/basicobject/not_equal_spec.rb2
-rw-r--r--spec/ruby/core/basicobject/not_spec.rb2
-rw-r--r--spec/ruby/core/basicobject/singleton_method_added_spec.rb4
-rw-r--r--spec/ruby/core/basicobject/singleton_method_removed_spec.rb2
-rw-r--r--spec/ruby/core/basicobject/singleton_method_undefined_spec.rb2
-rw-r--r--spec/ruby/core/bignum/abs_spec.rb7
-rw-r--r--spec/ruby/core/bignum/bignum_spec.rb31
-rw-r--r--spec/ruby/core/bignum/bit_and_spec.rb50
-rw-r--r--spec/ruby/core/bignum/bit_length_spec.rb33
-rw-r--r--spec/ruby/core/bignum/bit_or_spec.rb41
-rw-r--r--spec/ruby/core/bignum/bit_xor_spec.rb47
-rw-r--r--spec/ruby/core/bignum/case_compare_spec.rb6
-rw-r--r--spec/ruby/core/bignum/coerce_spec.rb65
-rw-r--r--spec/ruby/core/bignum/comparison_spec.rb162
-rw-r--r--spec/ruby/core/bignum/complement_spec.rb9
-rw-r--r--spec/ruby/core/bignum/div_spec.rb21
-rw-r--r--spec/ruby/core/bignum/divide_spec.rb18
-rw-r--r--spec/ruby/core/bignum/divmod_spec.rb81
-rw-r--r--spec/ruby/core/bignum/element_reference_spec.rb30
-rw-r--r--spec/ruby/core/bignum/eql_spec.rb22
-rw-r--r--spec/ruby/core/bignum/equal_value_spec.rb6
-rw-r--r--spec/ruby/core/bignum/even_spec.rb19
-rw-r--r--spec/ruby/core/bignum/exponent_spec.rb29
-rw-r--r--spec/ruby/core/bignum/fdiv_spec.rb5
-rw-r--r--spec/ruby/core/bignum/gt_spec.rb20
-rw-r--r--spec/ruby/core/bignum/gte_spec.rb19
-rw-r--r--spec/ruby/core/bignum/hash_spec.rb12
-rw-r--r--spec/ruby/core/bignum/left_shift_spec.rb73
-rw-r--r--spec/ruby/core/bignum/lt_spec.rb22
-rw-r--r--spec/ruby/core/bignum/lte_spec.rb24
-rw-r--r--spec/ruby/core/bignum/magnitude_spec.rb6
-rw-r--r--spec/ruby/core/bignum/minus_spec.rb19
-rw-r--r--spec/ruby/core/bignum/modulo_spec.rb10
-rw-r--r--spec/ruby/core/bignum/multiply_spec.rb20
-rw-r--r--spec/ruby/core/bignum/odd_spec.rb19
-rw-r--r--spec/ruby/core/bignum/plus_spec.rb19
-rw-r--r--spec/ruby/core/bignum/remainder_spec.rb21
-rw-r--r--spec/ruby/core/bignum/right_shift_spec.rb99
-rw-r--r--spec/ruby/core/bignum/shared/abs.rb6
-rw-r--r--spec/ruby/core/bignum/shared/divide.rb27
-rw-r--r--spec/ruby/core/bignum/shared/equal.rb31
-rw-r--r--spec/ruby/core/bignum/shared/modulo.rb29
-rw-r--r--spec/ruby/core/bignum/size_spec.rb16
-rw-r--r--spec/ruby/core/bignum/to_f_spec.rb13
-rw-r--r--spec/ruby/core/bignum/to_s_spec.rb48
-rw-r--r--spec/ruby/core/bignum/uminus_spec.rb11
-rw-r--r--spec/ruby/core/binding/clone_spec.rb8
-rw-r--r--spec/ruby/core/binding/dup_spec.rb8
-rw-r--r--spec/ruby/core/binding/eval_spec.rb66
-rw-r--r--spec/ruby/core/binding/fixtures/classes.rb12
-rw-r--r--spec/ruby/core/binding/fixtures/irb.rb3
-rw-r--r--spec/ruby/core/binding/fixtures/irbrc1
-rw-r--r--spec/ruby/core/binding/fixtures/location.rb6
-rw-r--r--spec/ruby/core/binding/irb_spec.rb18
-rw-r--r--spec/ruby/core/binding/local_variable_defined_spec.rb4
-rw-r--r--spec/ruby/core/binding/local_variable_get_spec.rb16
-rw-r--r--spec/ruby/core/binding/local_variable_set_spec.rb12
-rw-r--r--spec/ruby/core/binding/local_variables_spec.rb2
-rw-r--r--spec/ruby/core/binding/location_spec.rb46
-rw-r--r--spec/ruby/core/binding/receiver_spec.rb4
-rw-r--r--spec/ruby/core/binding/source_location_spec.rb11
-rw-r--r--spec/ruby/core/builtin_constants/builtin_constants_spec.rb14
-rw-r--r--spec/ruby/core/class/allocate_spec.rb6
-rw-r--r--spec/ruby/core/class/dup_spec.rb4
-rw-r--r--spec/ruby/core/class/inherited_spec.rb9
-rw-r--r--spec/ruby/core/class/initialize_spec.rb10
-rw-r--r--spec/ruby/core/class/new_spec.rb16
-rw-r--r--spec/ruby/core/class/superclass_spec.rb4
-rw-r--r--spec/ruby/core/class/to_s_spec.rb23
-rw-r--r--spec/ruby/core/comparable/between_spec.rb4
-rw-r--r--spec/ruby/core/comparable/clamp_spec.rb84
-rw-r--r--spec/ruby/core/comparable/equal_value_spec.rb43
-rw-r--r--spec/ruby/core/comparable/gt_spec.rb6
-rw-r--r--spec/ruby/core/comparable/gte_spec.rb6
-rw-r--r--spec/ruby/core/comparable/lt_spec.rb6
-rw-r--r--spec/ruby/core/comparable/lte_spec.rb6
-rw-r--r--spec/ruby/core/complex/abs2_spec.rb8
-rw-r--r--spec/ruby/core/complex/abs_spec.rb5
-rw-r--r--spec/ruby/core/complex/angle_spec.rb7
-rw-r--r--spec/ruby/core/complex/arg_spec.rb7
-rw-r--r--spec/ruby/core/complex/coerce_spec.rb69
-rw-r--r--spec/ruby/core/complex/conj_spec.rb6
-rw-r--r--spec/ruby/core/complex/conjugate_spec.rb6
-rw-r--r--spec/ruby/core/complex/constants_spec.rb6
-rw-r--r--spec/ruby/core/complex/denominator_spec.rb12
-rw-r--r--spec/ruby/core/complex/divide_spec.rb3
-rw-r--r--spec/ruby/core/complex/eql_spec.rb2
-rw-r--r--spec/ruby/core/complex/equal_value_spec.rb92
-rw-r--r--spec/ruby/core/complex/exponent_spec.rb60
-rw-r--r--spec/ruby/core/complex/fdiv_spec.rb20
-rw-r--r--spec/ruby/core/complex/finite_spec.rb52
-rw-r--r--spec/ruby/core/complex/hash_spec.rb16
-rw-r--r--spec/ruby/core/complex/imag_spec.rb5
-rw-r--r--spec/ruby/core/complex/imaginary_spec.rb3
-rw-r--r--spec/ruby/core/complex/infinite_spec.rb50
-rw-r--r--spec/ruby/core/complex/inspect_spec.rb15
-rw-r--r--spec/ruby/core/complex/integer_spec.rb2
-rw-r--r--spec/ruby/core/complex/magnitude_spec.rb5
-rw-r--r--spec/ruby/core/complex/marshal_dump_spec.rb2
-rw-r--r--spec/ruby/core/complex/minus_spec.rb44
-rw-r--r--spec/ruby/core/complex/multiply_spec.rb48
-rw-r--r--spec/ruby/core/complex/negative_spec.rb4
-rw-r--r--spec/ruby/core/complex/numerator_spec.rb18
-rw-r--r--spec/ruby/core/complex/phase_spec.rb4
-rw-r--r--spec/ruby/core/complex/plus_spec.rb44
-rw-r--r--spec/ruby/core/complex/polar_spec.rb23
-rw-r--r--spec/ruby/core/complex/positive_spec.rb4
-rw-r--r--spec/ruby/core/complex/quo_spec.rb3
-rw-r--r--spec/ruby/core/complex/rationalize_spec.rb10
-rw-r--r--spec/ruby/core/complex/real_spec.rb9
-rw-r--r--spec/ruby/core/complex/rect_spec.rb7
-rw-r--r--spec/ruby/core/complex/rectangular_spec.rb7
-rw-r--r--spec/ruby/core/complex/shared/abs.rb10
-rw-r--r--spec/ruby/core/complex/shared/divide.rb82
-rw-r--r--spec/ruby/core/complex/shared/image.rb8
-rw-r--r--spec/ruby/core/complex/shared/rect.rb94
-rw-r--r--spec/ruby/core/complex/spaceship_spec.rb27
-rw-r--r--spec/ruby/core/complex/to_f_spec.rb6
-rw-r--r--spec/ruby/core/complex/to_i_spec.rb6
-rw-r--r--spec/ruby/core/complex/to_r_spec.rb6
-rw-r--r--spec/ruby/core/complex/to_s_spec.rb43
-rw-r--r--spec/ruby/core/complex/uminus_spec.rb2
-rw-r--r--spec/ruby/core/data/constants_spec.rb22
-rw-r--r--spec/ruby/core/dir/chdir_spec.rb14
-rw-r--r--spec/ruby/core/dir/children_spec.rb78
-rw-r--r--spec/ruby/core/dir/chroot_spec.rb14
-rw-r--r--spec/ruby/core/dir/close_spec.rb24
-rw-r--r--spec/ruby/core/dir/delete_spec.rb6
-rw-r--r--spec/ruby/core/dir/dir_spec.rb2
-rw-r--r--spec/ruby/core/dir/each_child_spec.rb58
-rw-r--r--spec/ruby/core/dir/each_spec.rb6
-rw-r--r--spec/ruby/core/dir/element_reference_spec.rb6
-rw-r--r--spec/ruby/core/dir/empty_spec.rb48
-rw-r--r--spec/ruby/core/dir/entries_spec.rb12
-rw-r--r--spec/ruby/core/dir/exist_spec.rb8
-rw-r--r--spec/ruby/core/dir/exists_spec.rb8
-rw-r--r--spec/ruby/core/dir/fileno_spec.rb6
-rw-r--r--spec/ruby/core/dir/foreach_spec.rb6
-rw-r--r--spec/ruby/core/dir/getwd_spec.rb6
-rw-r--r--spec/ruby/core/dir/glob_spec.rb18
-rw-r--r--spec/ruby/core/dir/home_spec.rb47
-rw-r--r--spec/ruby/core/dir/initialize_spec.rb4
-rw-r--r--spec/ruby/core/dir/inspect_spec.rb4
-rw-r--r--spec/ruby/core/dir/mkdir_spec.rb38
-rw-r--r--spec/ruby/core/dir/open_spec.rb6
-rw-r--r--spec/ruby/core/dir/path_spec.rb8
-rw-r--r--spec/ruby/core/dir/pos_spec.rb8
-rw-r--r--spec/ruby/core/dir/pwd_spec.rb6
-rw-r--r--spec/ruby/core/dir/read_spec.rb6
-rw-r--r--spec/ruby/core/dir/rewind_spec.rb6
-rw-r--r--spec/ruby/core/dir/rmdir_spec.rb6
-rw-r--r--spec/ruby/core/dir/seek_spec.rb6
-rw-r--r--spec/ruby/core/dir/shared/chroot.rb10
-rw-r--r--spec/ruby/core/dir/shared/closed.rb2
-rw-r--r--spec/ruby/core/dir/shared/delete.rb24
-rw-r--r--spec/ruby/core/dir/shared/exist.rb2
-rw-r--r--spec/ruby/core/dir/shared/glob.rb107
-rw-r--r--spec/ruby/core/dir/shared/open.rb20
-rw-r--r--spec/ruby/core/dir/shared/path.rb22
-rw-r--r--spec/ruby/core/dir/shared/pwd.rb20
-rw-r--r--spec/ruby/core/dir/tell_spec.rb8
-rw-r--r--spec/ruby/core/dir/to_path_spec.rb8
-rw-r--r--spec/ruby/core/dir/unlink_spec.rb6
-rw-r--r--spec/ruby/core/encoding/_dump_spec.rb2
-rw-r--r--spec/ruby/core/encoding/_load_spec.rb2
-rw-r--r--spec/ruby/core/encoding/aliases_spec.rb62
-rw-r--r--spec/ruby/core/encoding/ascii_compatible_spec.rb16
-rw-r--r--spec/ruby/core/encoding/compatible_spec.rb574
-rw-r--r--spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb60
-rw-r--r--spec/ruby/core/encoding/converter/constants_spec.rb184
-rw-r--r--spec/ruby/core/encoding/converter/convert_spec.rb72
-rw-r--r--spec/ruby/core/encoding/converter/convpath_spec.rb77
-rw-r--r--spec/ruby/core/encoding/converter/destination_encoding_spec.rb16
-rw-r--r--spec/ruby/core/encoding/converter/finish_spec.rb56
-rw-r--r--spec/ruby/core/encoding/converter/insert_output_spec.rb2
-rw-r--r--spec/ruby/core/encoding/converter/inspect_spec.rb2
-rw-r--r--spec/ruby/core/encoding/converter/last_error_spec.rb150
-rw-r--r--spec/ruby/core/encoding/converter/new_spec.rb200
-rw-r--r--spec/ruby/core/encoding/converter/primitive_convert_spec.rb418
-rw-r--r--spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb112
-rw-r--r--spec/ruby/core/encoding/converter/putback_spec.rb76
-rw-r--r--spec/ruby/core/encoding/converter/replacement_spec.rb118
-rw-r--r--spec/ruby/core/encoding/converter/search_convpath_spec.rb89
-rw-r--r--spec/ruby/core/encoding/converter/source_encoding_spec.rb16
-rw-r--r--spec/ruby/core/encoding/default_external_spec.rb105
-rw-r--r--spec/ruby/core/encoding/default_internal_spec.rb141
-rw-r--r--spec/ruby/core/encoding/dummy_spec.rb22
-rw-r--r--spec/ruby/core/encoding/find_spec.rb120
-rw-r--r--spec/ruby/core/encoding/inspect_spec.rb26
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb28
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb28
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb44
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb42
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb44
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb46
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb54
-rw-r--r--spec/ruby/core/encoding/list_spec.rb60
-rw-r--r--spec/ruby/core/encoding/locale_charmap_spec.rb70
-rw-r--r--spec/ruby/core/encoding/name_list_spec.rb32
-rw-r--r--spec/ruby/core/encoding/name_spec.rb8
-rw-r--r--spec/ruby/core/encoding/names_spec.rb50
-rw-r--r--spec/ruby/core/encoding/replicate_spec.rb76
-rw-r--r--spec/ruby/core/encoding/shared/name.rb2
-rw-r--r--spec/ruby/core/encoding/to_s_spec.rb8
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb22
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb22
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb40
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb46
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb48
-rw-r--r--spec/ruby/core/enumerable/all_spec.rb115
-rw-r--r--spec/ruby/core/enumerable/any_spec.rb81
-rw-r--r--spec/ruby/core/enumerable/chain_spec.rb25
-rw-r--r--spec/ruby/core/enumerable/chunk_spec.rb59
-rw-r--r--spec/ruby/core/enumerable/chunk_while_spec.rb64
-rw-r--r--spec/ruby/core/enumerable/collect_concat_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/collect_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/count_spec.rb4
-rw-r--r--spec/ruby/core/enumerable/cycle_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/detect_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/drop_spec.rb14
-rw-r--r--spec/ruby/core/enumerable/drop_while_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/each_cons_spec.rb22
-rw-r--r--spec/ruby/core/enumerable/each_entry_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/each_slice_spec.rb22
-rw-r--r--spec/ruby/core/enumerable/each_with_index_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/each_with_object_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/entries_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/filter_map_spec.rb26
-rw-r--r--spec/ruby/core/enumerable/filter_spec.rb9
-rw-r--r--spec/ruby/core/enumerable/find_all_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/find_index_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/find_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/first_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/fixtures/classes.rb18
-rw-r--r--spec/ruby/core/enumerable/flat_map_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/grep_spec.rb26
-rw-r--r--spec/ruby/core/enumerable/grep_v_spec.rb84
-rw-r--r--spec/ruby/core/enumerable/group_by_spec.rb18
-rw-r--r--spec/ruby/core/enumerable/include_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/inject_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/lazy_spec.rb4
-rw-r--r--spec/ruby/core/enumerable/map_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/max_by_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/max_spec.rb12
-rw-r--r--spec/ruby/core/enumerable/member_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/min_by_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/min_spec.rb12
-rw-r--r--spec/ruby/core/enumerable/minmax_by_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/minmax_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/none_spec.rb191
-rw-r--r--spec/ruby/core/enumerable/one_spec.rb165
-rw-r--r--spec/ruby/core/enumerable/partition_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/reduce_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/reject_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/reverse_each_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/select_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/shared/collect.rb8
-rw-r--r--spec/ruby/core/enumerable/shared/collect_concat.rb4
-rw-r--r--spec/ruby/core/enumerable/shared/entries.rb12
-rw-r--r--spec/ruby/core/enumerable/shared/enumerable_enumeratorized.rb2
-rw-r--r--spec/ruby/core/enumerable/shared/find.rb16
-rw-r--r--spec/ruby/core/enumerable/shared/find_all.rb2
-rw-r--r--spec/ruby/core/enumerable/shared/take.rb8
-rw-r--r--spec/ruby/core/enumerable/slice_after_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/slice_before_spec.rb41
-rw-r--r--spec/ruby/core/enumerable/slice_when_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/sort_by_spec.rb13
-rw-r--r--spec/ruby/core/enumerable/sort_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/sum_spec.rb42
-rw-r--r--spec/ruby/core/enumerable/take_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/take_while_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/tally_spec.rb35
-rw-r--r--spec/ruby/core/enumerable/to_a_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/to_h_spec.rb52
-rw-r--r--spec/ruby/core/enumerable/uniq_spec.rb106
-rw-r--r--spec/ruby/core/enumerable/zip_spec.rb19
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb11
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb19
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb11
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb20
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb19
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb11
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb22
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb22
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb11
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb19
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb19
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb15
-rw-r--r--spec/ruby/core/enumerator/chain/each_spec.rb17
-rw-r--r--spec/ruby/core/enumerator/chain/initialize_spec.rb33
-rw-r--r--spec/ruby/core/enumerator/chain/inspect_spec.rb16
-rw-r--r--spec/ruby/core/enumerator/chain/rewind_spec.rb53
-rw-r--r--spec/ruby/core/enumerator/chain/size_spec.rb24
-rw-r--r--spec/ruby/core/enumerator/each_spec.rb88
-rw-r--r--spec/ruby/core/enumerator/each_with_index_spec.rb16
-rw-r--r--spec/ruby/core/enumerator/each_with_object_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/enum_for_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/enumerator_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/feed_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/first_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/generator/each_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/generator/initialize_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/initialize_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/inject_spec.rb15
-rw-r--r--spec/ruby/core/enumerator/inspect_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/lazy/chunk_spec.rb67
-rw-r--r--spec/ruby/core/enumerator/lazy/chunk_while_spec.rb9
-rw-r--r--spec/ruby/core/enumerator/lazy/collect_concat_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/collect_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/drop_spec.rb10
-rw-r--r--spec/ruby/core/enumerator/lazy/drop_while_spec.rb12
-rw-r--r--spec/ruby/core/enumerator/lazy/enum_for_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/filter_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/lazy/find_all_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/flat_map_spec.rb12
-rw-r--r--spec/ruby/core/enumerator/lazy/force_spec.rb10
-rw-r--r--spec/ruby/core/enumerator/lazy/grep_spec.rb43
-rw-r--r--spec/ruby/core/enumerator/lazy/grep_v_spec.rb161
-rw-r--r--spec/ruby/core/enumerator/lazy/initialize_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/lazy/lazy_spec.rb14
-rw-r--r--spec/ruby/core/enumerator/lazy/map_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/reject_spec.rb24
-rw-r--r--spec/ruby/core/enumerator/lazy/select_spec.rb43
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/collect.rb10
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/collect_concat.rb12
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/select.rb12
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/to_enum.rb9
-rw-r--r--spec/ruby/core/enumerator/lazy/slice_after_spec.rb9
-rw-r--r--spec/ruby/core/enumerator/lazy/slice_before_spec.rb9
-rw-r--r--spec/ruby/core/enumerator/lazy/slice_when_spec.rb9
-rw-r--r--spec/ruby/core/enumerator/lazy/take_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/take_while_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/lazy/to_enum_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/uniq_spec.rb108
-rw-r--r--spec/ruby/core/enumerator/lazy/zip_spec.rb18
-rw-r--r--spec/ruby/core/enumerator/new_spec.rb41
-rw-r--r--spec/ruby/core/enumerator/next_spec.rb27
-rw-r--r--spec/ruby/core/enumerator/next_values_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/peek_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/peek_values_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/plus_spec.rb35
-rw-r--r--spec/ruby/core/enumerator/rewind_spec.rb42
-rw-r--r--spec/ruby/core/enumerator/size_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/to_enum_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/with_index_spec.rb16
-rw-r--r--spec/ruby/core/enumerator/with_object_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/yielder/append_spec.rb13
-rw-r--r--spec/ruby/core/enumerator/yielder/initialize_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/yielder/yield_spec.rb9
-rw-r--r--spec/ruby/core/env/assoc_spec.rb12
-rw-r--r--spec/ruby/core/env/clear_spec.rb4
-rw-r--r--spec/ruby/core/env/delete_if_spec.rb41
-rw-r--r--spec/ruby/core/env/delete_spec.rb22
-rw-r--r--spec/ruby/core/env/each_key_spec.rb10
-rw-r--r--spec/ruby/core/env/each_pair_spec.rb6
-rw-r--r--spec/ruby/core/env/each_spec.rb6
-rw-r--r--spec/ruby/core/env/each_value_spec.rb12
-rw-r--r--spec/ruby/core/env/element_reference_spec.rb67
-rw-r--r--spec/ruby/core/env/element_set_spec.rb6
-rw-r--r--spec/ruby/core/env/empty_spec.rb2
-rw-r--r--spec/ruby/core/env/fetch_spec.rb47
-rw-r--r--spec/ruby/core/env/filter_spec.rb15
-rw-r--r--spec/ruby/core/env/has_key_spec.rb6
-rw-r--r--spec/ruby/core/env/has_value_spec.rb6
-rw-r--r--spec/ruby/core/env/include_spec.rb6
-rw-r--r--spec/ruby/core/env/index_spec.rb16
-rw-r--r--spec/ruby/core/env/indexes_spec.rb2
-rw-r--r--spec/ruby/core/env/indices_spec.rb2
-rw-r--r--spec/ruby/core/env/inspect_spec.rb2
-rw-r--r--spec/ruby/core/env/invert_spec.rb2
-rw-r--r--spec/ruby/core/env/keep_if_spec.rb35
-rw-r--r--spec/ruby/core/env/key_spec.rb10
-rw-r--r--spec/ruby/core/env/keys_spec.rb6
-rw-r--r--spec/ruby/core/env/length_spec.rb6
-rw-r--r--spec/ruby/core/env/member_spec.rb6
-rw-r--r--spec/ruby/core/env/merge_spec.rb8
-rw-r--r--spec/ruby/core/env/rassoc_spec.rb23
-rw-r--r--spec/ruby/core/env/rehash_spec.rb8
-rw-r--r--spec/ruby/core/env/reject_spec.rb38
-rw-r--r--spec/ruby/core/env/replace_spec.rb52
-rw-r--r--spec/ruby/core/env/select_spec.rb36
-rw-r--r--spec/ruby/core/env/shared/each.rb58
-rw-r--r--spec/ruby/core/env/shared/include.rb16
-rw-r--r--spec/ruby/core/env/shared/key.rb18
-rw-r--r--spec/ruby/core/env/shared/select.rb61
-rw-r--r--spec/ruby/core/env/shared/store.rb14
-rw-r--r--spec/ruby/core/env/shared/to_hash.rb19
-rw-r--r--spec/ruby/core/env/shared/update.rb100
-rw-r--r--spec/ruby/core/env/shared/value.rb15
-rw-r--r--spec/ruby/core/env/shift_spec.rb50
-rw-r--r--spec/ruby/core/env/size_spec.rb6
-rw-r--r--spec/ruby/core/env/slice_spec.rb29
-rw-r--r--spec/ruby/core/env/spec_helper.rb26
-rw-r--r--spec/ruby/core/env/store_spec.rb6
-rw-r--r--spec/ruby/core/env/to_a_spec.rb11
-rw-r--r--spec/ruby/core/env/to_h_spec.rb62
-rw-r--r--spec/ruby/core/env/to_hash_spec.rb6
-rw-r--r--spec/ruby/core/env/to_s_spec.rb2
-rw-r--r--spec/ruby/core/env/update_spec.rb25
-rw-r--r--spec/ruby/core/env/value_spec.rb6
-rw-r--r--spec/ruby/core/env/values_at_spec.rb30
-rw-r--r--spec/ruby/core/env/values_spec.rb13
-rw-r--r--spec/ruby/core/exception/args_spec.rb5
-rw-r--r--spec/ruby/core/exception/arguments_spec.rb11
-rw-r--r--spec/ruby/core/exception/backtrace_locations_spec.rb39
-rw-r--r--spec/ruby/core/exception/backtrace_spec.rb31
-rw-r--r--spec/ruby/core/exception/case_compare_spec.rb38
-rw-r--r--spec/ruby/core/exception/cause_spec.rb39
-rw-r--r--spec/ruby/core/exception/destination_encoding_name_spec.rb20
-rw-r--r--spec/ruby/core/exception/destination_encoding_spec.rb20
-rw-r--r--spec/ruby/core/exception/dup_spec.rb74
-rw-r--r--spec/ruby/core/exception/equal_value_spec.rb4
-rw-r--r--spec/ruby/core/exception/errno_spec.rb4
-rw-r--r--spec/ruby/core/exception/error_bytes_spec.rb11
-rw-r--r--spec/ruby/core/exception/error_char_spec.rb11
-rw-r--r--spec/ruby/core/exception/exception_spec.rb78
-rw-r--r--spec/ruby/core/exception/exit_value_spec.rb2
-rw-r--r--spec/ruby/core/exception/fixtures/common.rb33
-rw-r--r--spec/ruby/core/exception/frozen_error_spec.rb34
-rw-r--r--spec/ruby/core/exception/full_message_spec.rb94
-rw-r--r--spec/ruby/core/exception/hierarchy_spec.rb62
-rw-r--r--spec/ruby/core/exception/incomplete_input_spec.rb2
-rw-r--r--spec/ruby/core/exception/initialize_spec.rb2
-rw-r--r--spec/ruby/core/exception/inspect_spec.rb8
-rw-r--r--spec/ruby/core/exception/interrupt_spec.rb10
-rw-r--r--spec/ruby/core/exception/io_error_spec.rb2
-rw-r--r--spec/ruby/core/exception/key_error_spec.rb15
-rw-r--r--spec/ruby/core/exception/load_error_spec.rb2
-rw-r--r--spec/ruby/core/exception/message_spec.rb4
-rw-r--r--spec/ruby/core/exception/name_error_spec.rb13
-rw-r--r--spec/ruby/core/exception/name_spec.rb38
-rw-r--r--spec/ruby/core/exception/new_spec.rb8
-rw-r--r--spec/ruby/core/exception/no_method_error_spec.rb55
-rw-r--r--spec/ruby/core/exception/range_error_spec.rb2
-rw-r--r--spec/ruby/core/exception/readagain_bytes_spec.rb11
-rw-r--r--spec/ruby/core/exception/reason_spec.rb2
-rw-r--r--spec/ruby/core/exception/receiver_spec.rb94
-rw-r--r--spec/ruby/core/exception/result_spec.rb4
-rw-r--r--spec/ruby/core/exception/script_error_spec.rb15
-rw-r--r--spec/ruby/core/exception/set_backtrace_spec.rb12
-rw-r--r--spec/ruby/core/exception/signal_exception_spec.rb63
-rw-r--r--spec/ruby/core/exception/signm_spec.rb2
-rw-r--r--spec/ruby/core/exception/signo_spec.rb2
-rw-r--r--spec/ruby/core/exception/source_encoding_name_spec.rb20
-rw-r--r--spec/ruby/core/exception/source_encoding_spec.rb20
-rw-r--r--spec/ruby/core/exception/standard_error_spec.rb57
-rw-r--r--spec/ruby/core/exception/status_spec.rb2
-rw-r--r--spec/ruby/core/exception/success_spec.rb2
-rw-r--r--spec/ruby/core/exception/system_call_error_spec.rb75
-rw-r--r--spec/ruby/core/exception/system_stack_error_spec.rb2
-rw-r--r--spec/ruby/core/exception/to_s_spec.rb20
-rw-r--r--spec/ruby/core/exception/uncaught_throw_error_spec.rb3
-rw-r--r--spec/ruby/core/false/and_spec.rb2
-rw-r--r--spec/ruby/core/false/dup_spec.rb10
-rw-r--r--spec/ruby/core/false/falseclass_spec.rb6
-rw-r--r--spec/ruby/core/false/inspect_spec.rb2
-rw-r--r--spec/ruby/core/false/or_spec.rb2
-rw-r--r--spec/ruby/core/false/to_s_spec.rb12
-rw-r--r--spec/ruby/core/false/xor_spec.rb2
-rw-r--r--spec/ruby/core/fiber/new_spec.rb62
-rw-r--r--spec/ruby/core/fiber/resume_spec.rb86
-rw-r--r--spec/ruby/core/fiber/yield_spec.rb80
-rw-r--r--spec/ruby/core/file/absolute_path_spec.rb55
-rw-r--r--spec/ruby/core/file/atime_spec.rb6
-rw-r--r--spec/ruby/core/file/basename_spec.rb30
-rw-r--r--spec/ruby/core/file/birthtime_spec.rb16
-rw-r--r--spec/ruby/core/file/blockdev_spec.rb4
-rw-r--r--spec/ruby/core/file/chardev_spec.rb4
-rw-r--r--spec/ruby/core/file/chmod_spec.rb182
-rw-r--r--spec/ruby/core/file/chown_spec.rb12
-rw-r--r--spec/ruby/core/file/constants/constants_spec.rb2
-rw-r--r--spec/ruby/core/file/constants_spec.rb2
-rw-r--r--spec/ruby/core/file/ctime_spec.rb6
-rw-r--r--spec/ruby/core/file/delete_spec.rb6
-rw-r--r--spec/ruby/core/file/directory_spec.rb4
-rw-r--r--spec/ruby/core/file/dirname_spec.rb10
-rw-r--r--spec/ruby/core/file/empty_spec.rb16
-rw-r--r--spec/ruby/core/file/executable_real_spec.rb4
-rw-r--r--spec/ruby/core/file/executable_spec.rb4
-rw-r--r--spec/ruby/core/file/exist_spec.rb6
-rw-r--r--spec/ruby/core/file/exists_spec.rb6
-rw-r--r--spec/ruby/core/file/expand_path_spec.rb183
-rw-r--r--spec/ruby/core/file/extname_spec.rb44
-rw-r--r--spec/ruby/core/file/file_spec.rb4
-rw-r--r--spec/ruby/core/file/fixtures/file_types.rb36
-rw-r--r--spec/ruby/core/file/flock_spec.rb6
-rw-r--r--spec/ruby/core/file/fnmatch_spec.rb8
-rw-r--r--spec/ruby/core/file/ftype_spec.rb13
-rw-r--r--spec/ruby/core/file/grpowned_spec.rb4
-rw-r--r--spec/ruby/core/file/identical_spec.rb4
-rw-r--r--spec/ruby/core/file/initialize_spec.rb6
-rw-r--r--spec/ruby/core/file/inspect_spec.rb2
-rw-r--r--spec/ruby/core/file/join_spec.rb10
-rw-r--r--spec/ruby/core/file/lchmod_spec.rb12
-rw-r--r--spec/ruby/core/file/lchown_spec.rb6
-rw-r--r--spec/ruby/core/file/link_spec.rb16
-rw-r--r--spec/ruby/core/file/lstat_spec.rb4
-rw-r--r--spec/ruby/core/file/lutime_spec.rb40
-rw-r--r--spec/ruby/core/file/mkfifo_spec.rb74
-rw-r--r--spec/ruby/core/file/mtime_spec.rb8
-rw-r--r--spec/ruby/core/file/new_spec.rb46
-rw-r--r--spec/ruby/core/file/null_spec.rb2
-rw-r--r--spec/ruby/core/file/open_spec.rb270
-rw-r--r--spec/ruby/core/file/owned_spec.rb12
-rw-r--r--spec/ruby/core/file/path_spec.rb33
-rw-r--r--spec/ruby/core/file/pipe_spec.rb6
-rw-r--r--spec/ruby/core/file/printf_spec.rb6
-rw-r--r--spec/ruby/core/file/read_spec.rb4
-rw-r--r--spec/ruby/core/file/readable_real_spec.rb4
-rw-r--r--spec/ruby/core/file/readable_spec.rb4
-rw-r--r--spec/ruby/core/file/readlink_spec.rb6
-rw-r--r--spec/ruby/core/file/realdirpath_spec.rb8
-rw-r--r--spec/ruby/core/file/realpath_spec.rb8
-rw-r--r--spec/ruby/core/file/rename_spec.rb18
-rw-r--r--spec/ruby/core/file/reopen_spec.rb4
-rw-r--r--spec/ruby/core/file/setgid_spec.rb4
-rw-r--r--spec/ruby/core/file/setuid_spec.rb4
-rw-r--r--spec/ruby/core/file/shared/fnmatch.rb16
-rw-r--r--spec/ruby/core/file/shared/open.rb2
-rw-r--r--spec/ruby/core/file/shared/path.rb77
-rw-r--r--spec/ruby/core/file/shared/read.rb6
-rw-r--r--spec/ruby/core/file/shared/stat.rb2
-rw-r--r--spec/ruby/core/file/shared/unlink.rb26
-rw-r--r--spec/ruby/core/file/size_spec.rb6
-rw-r--r--spec/ruby/core/file/socket_spec.rb4
-rw-r--r--spec/ruby/core/file/split_spec.rb13
-rw-r--r--spec/ruby/core/file/stat/atime_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/birthtime_spec.rb4
-rw-r--r--spec/ruby/core/file/stat/blksize_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/blockdev_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/blocks_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/chardev_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/comparison_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/ctime_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/dev_major_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/dev_minor_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/dev_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/directory_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/executable_real_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/executable_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/file_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/ftype_spec.rb8
-rw-r--r--spec/ruby/core/file/stat/gid_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/grpowned_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/ino_spec.rb20
-rw-r--r--spec/ruby/core/file/stat/inspect_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/mode_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/mtime_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/new_spec.rb4
-rw-r--r--spec/ruby/core/file/stat/nlink_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/owned_spec.rb16
-rw-r--r--spec/ruby/core/file/stat/pipe_spec.rb8
-rw-r--r--spec/ruby/core/file/stat/rdev_major_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/rdev_minor_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/rdev_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/readable_real_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/readable_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/setgid_spec.rb10
-rw-r--r--spec/ruby/core/file/stat/setuid_spec.rb10
-rw-r--r--spec/ruby/core/file/stat/size_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/socket_spec.rb10
-rw-r--r--spec/ruby/core/file/stat/sticky_spec.rb10
-rw-r--r--spec/ruby/core/file/stat/symlink_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/uid_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/world_readable_spec.rb8
-rw-r--r--spec/ruby/core/file/stat/world_writable_spec.rb8
-rw-r--r--spec/ruby/core/file/stat/writable_real_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/writable_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/zero_spec.rb6
-rw-r--r--spec/ruby/core/file/stat_spec.rb4
-rw-r--r--spec/ruby/core/file/sticky_spec.rb6
-rw-r--r--spec/ruby/core/file/symlink_spec.rb16
-rw-r--r--spec/ruby/core/file/to_path_spec.rb49
-rw-r--r--spec/ruby/core/file/truncate_spec.rb26
-rw-r--r--spec/ruby/core/file/umask_spec.rb23
-rw-r--r--spec/ruby/core/file/unlink_spec.rb6
-rw-r--r--spec/ruby/core/file/utime_spec.rb62
-rw-r--r--spec/ruby/core/file/world_readable_spec.rb8
-rw-r--r--spec/ruby/core/file/world_writable_spec.rb8
-rw-r--r--spec/ruby/core/file/writable_real_spec.rb4
-rw-r--r--spec/ruby/core/file/writable_spec.rb4
-rw-r--r--spec/ruby/core/file/zero_spec.rb4
-rw-r--r--spec/ruby/core/filetest/blockdev_spec.rb4
-rw-r--r--spec/ruby/core/filetest/chardev_spec.rb4
-rw-r--r--spec/ruby/core/filetest/directory_spec.rb4
-rw-r--r--spec/ruby/core/filetest/executable_real_spec.rb4
-rw-r--r--spec/ruby/core/filetest/executable_spec.rb4
-rw-r--r--spec/ruby/core/filetest/exist_spec.rb4
-rw-r--r--spec/ruby/core/filetest/exists_spec.rb4
-rw-r--r--spec/ruby/core/filetest/file_spec.rb4
-rw-r--r--spec/ruby/core/filetest/grpowned_spec.rb4
-rw-r--r--spec/ruby/core/filetest/identical_spec.rb4
-rw-r--r--spec/ruby/core/filetest/owned_spec.rb8
-rw-r--r--spec/ruby/core/filetest/pipe_spec.rb8
-rw-r--r--spec/ruby/core/filetest/readable_real_spec.rb4
-rw-r--r--spec/ruby/core/filetest/readable_spec.rb4
-rw-r--r--spec/ruby/core/filetest/setgid_spec.rb8
-rw-r--r--spec/ruby/core/filetest/setuid_spec.rb8
-rw-r--r--spec/ruby/core/filetest/size_spec.rb4
-rw-r--r--spec/ruby/core/filetest/socket_spec.rb8
-rw-r--r--spec/ruby/core/filetest/sticky_spec.rb4
-rw-r--r--spec/ruby/core/filetest/symlink_spec.rb4
-rw-r--r--spec/ruby/core/filetest/world_readable_spec.rb2
-rw-r--r--spec/ruby/core/filetest/world_writable_spec.rb2
-rw-r--r--spec/ruby/core/filetest/writable_real_spec.rb4
-rw-r--r--spec/ruby/core/filetest/writable_spec.rb4
-rw-r--r--spec/ruby/core/filetest/zero_spec.rb4
-rw-r--r--spec/ruby/core/fixnum/abs_spec.rb7
-rw-r--r--spec/ruby/core/fixnum/bit_and_spec.rb46
-rw-r--r--spec/ruby/core/fixnum/bit_length_spec.rb42
-rw-r--r--spec/ruby/core/fixnum/bit_or_spec.rb26
-rw-r--r--spec/ruby/core/fixnum/bit_xor_spec.rb24
-rw-r--r--spec/ruby/core/fixnum/case_compare_spec.rb6
-rw-r--r--spec/ruby/core/fixnum/coerce_spec.rb39
-rw-r--r--spec/ruby/core/fixnum/comparison_spec.rb26
-rw-r--r--spec/ruby/core/fixnum/complement_spec.rb10
-rw-r--r--spec/ruby/core/fixnum/div_spec.rb44
-rw-r--r--spec/ruby/core/fixnum/divide_spec.rb35
-rw-r--r--spec/ruby/core/fixnum/divmod_spec.rb35
-rw-r--r--spec/ruby/core/fixnum/element_reference_spec.rb80
-rw-r--r--spec/ruby/core/fixnum/equal_value_spec.rb6
-rw-r--r--spec/ruby/core/fixnum/even_spec.rb23
-rw-r--r--spec/ruby/core/fixnum/exponent_spec.rb76
-rw-r--r--spec/ruby/core/fixnum/fdiv_spec.rb49
-rw-r--r--spec/ruby/core/fixnum/fixnum_spec.rb31
-rw-r--r--spec/ruby/core/fixnum/gt_spec.rb19
-rw-r--r--spec/ruby/core/fixnum/gte_spec.rb20
-rw-r--r--spec/ruby/core/fixnum/hash_spec.rb11
-rw-r--r--spec/ruby/core/fixnum/left_shift_spec.rb91
-rw-r--r--spec/ruby/core/fixnum/lt_spec.rb19
-rw-r--r--spec/ruby/core/fixnum/lte_spec.rb20
-rw-r--r--spec/ruby/core/fixnum/magnitude_spec.rb6
-rw-r--r--spec/ruby/core/fixnum/minus_spec.rb29
-rw-r--r--spec/ruby/core/fixnum/modulo_spec.rb10
-rw-r--r--spec/ruby/core/fixnum/multiply_spec.rb27
-rw-r--r--spec/ruby/core/fixnum/odd_spec.rb23
-rw-r--r--spec/ruby/core/fixnum/plus_spec.rb29
-rw-r--r--spec/ruby/core/fixnum/right_shift_spec.rb91
-rw-r--r--spec/ruby/core/fixnum/shared/abs.rb9
-rw-r--r--spec/ruby/core/fixnum/shared/equal.rb24
-rw-r--r--spec/ruby/core/fixnum/shared/modulo.rb42
-rw-r--r--spec/ruby/core/fixnum/size_spec.rb19
-rw-r--r--spec/ruby/core/fixnum/succ_spec.rb15
-rw-r--r--spec/ruby/core/fixnum/to_f_spec.rb9
-rw-r--r--spec/ruby/core/fixnum/to_s_spec.rb50
-rw-r--r--spec/ruby/core/fixnum/uminus_spec.rb16
-rw-r--r--spec/ruby/core/fixnum/zero_spec.rb9
-rw-r--r--spec/ruby/core/float/abs_spec.rb5
-rw-r--r--spec/ruby/core/float/angle_spec.rb3
-rw-r--r--spec/ruby/core/float/arg_spec.rb3
-rw-r--r--spec/ruby/core/float/case_compare_spec.rb4
-rw-r--r--spec/ruby/core/float/ceil_spec.rb16
-rw-r--r--spec/ruby/core/float/coerce_spec.rb2
-rw-r--r--spec/ruby/core/float/comparison_spec.rb36
-rw-r--r--spec/ruby/core/float/constants_spec.rb2
-rw-r--r--spec/ruby/core/float/denominator_spec.rb2
-rw-r--r--spec/ruby/core/float/divide_spec.rb11
-rw-r--r--spec/ruby/core/float/divmod_spec.rb12
-rw-r--r--spec/ruby/core/float/dup_spec.rb12
-rw-r--r--spec/ruby/core/float/eql_spec.rb2
-rw-r--r--spec/ruby/core/float/equal_value_spec.rb4
-rw-r--r--spec/ruby/core/float/exponent_spec.rb2
-rw-r--r--spec/ruby/core/float/fdiv_spec.rb4
-rw-r--r--spec/ruby/core/float/finite_spec.rb2
-rw-r--r--spec/ruby/core/float/fixtures/classes.rb4
-rw-r--r--spec/ruby/core/float/float_spec.rb6
-rw-r--r--spec/ruby/core/float/floor_spec.rb16
-rw-r--r--spec/ruby/core/float/gt_spec.rb9
-rw-r--r--spec/ruby/core/float/gte_spec.rb9
-rw-r--r--spec/ruby/core/float/hash_spec.rb2
-rw-r--r--spec/ruby/core/float/infinite_spec.rb2
-rw-r--r--spec/ruby/core/float/lt_spec.rb9
-rw-r--r--spec/ruby/core/float/lte_spec.rb9
-rw-r--r--spec/ruby/core/float/magnitude_spec.rb4
-rw-r--r--spec/ruby/core/float/minus_spec.rb5
-rw-r--r--spec/ruby/core/float/modulo_spec.rb8
-rw-r--r--spec/ruby/core/float/multiply_spec.rb9
-rw-r--r--spec/ruby/core/float/nan_spec.rb2
-rw-r--r--spec/ruby/core/float/next_float_spec.rb2
-rw-r--r--spec/ruby/core/float/numerator_spec.rb2
-rw-r--r--spec/ruby/core/float/phase_spec.rb3
-rw-r--r--spec/ruby/core/float/plus_spec.rb5
-rw-r--r--spec/ruby/core/float/prev_float_spec.rb2
-rw-r--r--spec/ruby/core/float/quo_spec.rb4
-rw-r--r--spec/ruby/core/float/rationalize_spec.rb10
-rw-r--r--spec/ruby/core/float/round_spec.rb76
-rw-r--r--spec/ruby/core/float/shared/abs.rb2
-rw-r--r--spec/ruby/core/float/shared/arg.rb36
-rw-r--r--spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb33
-rw-r--r--spec/ruby/core/float/shared/comparison_exception_in_coerce.rb35
-rw-r--r--spec/ruby/core/float/shared/modulo.rb4
-rw-r--r--spec/ruby/core/float/shared/quo.rb4
-rw-r--r--spec/ruby/core/float/to_f_spec.rb2
-rw-r--r--spec/ruby/core/float/to_i_spec.rb6
-rw-r--r--spec/ruby/core/float/to_int_spec.rb6
-rw-r--r--spec/ruby/core/float/to_r_spec.rb2
-rw-r--r--spec/ruby/core/float/to_s_spec.rb224
-rw-r--r--spec/ruby/core/float/truncate_spec.rb20
-rw-r--r--spec/ruby/core/float/uminus_spec.rb2
-rw-r--r--spec/ruby/core/float/uplus_spec.rb2
-rw-r--r--spec/ruby/core/float/zero_spec.rb2
-rw-r--r--spec/ruby/core/gc/count_spec.rb12
-rw-r--r--spec/ruby/core/gc/disable_spec.rb2
-rw-r--r--spec/ruby/core/gc/enable_spec.rb2
-rw-r--r--spec/ruby/core/gc/garbage_collect_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/clear_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/disable_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/enable_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/enabled_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/report_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/result_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/total_time_spec.rb2
-rw-r--r--spec/ruby/core/gc/start_spec.rb2
-rw-r--r--spec/ruby/core/gc/stat_spec.rb16
-rw-r--r--spec/ruby/core/gc/stress_spec.rb2
-rw-r--r--spec/ruby/core/hash/allocate_spec.rb2
-rw-r--r--spec/ruby/core/hash/any_spec.rb2
-rw-r--r--spec/ruby/core/hash/assoc_spec.rb2
-rw-r--r--spec/ruby/core/hash/clear_spec.rb10
-rw-r--r--spec/ruby/core/hash/clone_spec.rb5
-rw-r--r--spec/ruby/core/hash/compact_spec.rb88
-rw-r--r--spec/ruby/core/hash/compare_by_identity_spec.rb22
-rw-r--r--spec/ruby/core/hash/constructor_spec.rb37
-rw-r--r--spec/ruby/core/hash/default_proc_spec.rb24
-rw-r--r--spec/ruby/core/hash/default_spec.rb12
-rw-r--r--spec/ruby/core/hash/delete_if_spec.rb18
-rw-r--r--spec/ruby/core/hash/delete_spec.rb10
-rw-r--r--spec/ruby/core/hash/dig_spec.rb108
-rw-r--r--spec/ruby/core/hash/each_key_spec.rb12
-rw-r--r--spec/ruby/core/hash/each_pair_spec.rb16
-rw-r--r--spec/ruby/core/hash/each_spec.rb16
-rw-r--r--spec/ruby/core/hash/each_value_spec.rb12
-rw-r--r--spec/ruby/core/hash/element_reference_spec.rb4
-rw-r--r--spec/ruby/core/hash/element_set_spec.rb8
-rw-r--r--spec/ruby/core/hash/empty_spec.rb4
-rw-r--r--spec/ruby/core/hash/eql_spec.rb6
-rw-r--r--spec/ruby/core/hash/equal_value_spec.rb6
-rw-r--r--spec/ruby/core/hash/fetch_spec.rb30
-rw-r--r--spec/ruby/core/hash/fetch_values_spec.rb48
-rw-r--r--spec/ruby/core/hash/filter_spec.rb12
-rw-r--r--spec/ruby/core/hash/fixtures/classes.rb7
-rw-r--r--spec/ruby/core/hash/flatten_spec.rb4
-rw-r--r--spec/ruby/core/hash/gt_spec.rb66
-rw-r--r--spec/ruby/core/hash/gte_spec.rb66
-rw-r--r--spec/ruby/core/hash/has_key_spec.rb9
-rw-r--r--spec/ruby/core/hash/has_value_spec.rb9
-rw-r--r--spec/ruby/core/hash/hash_spec.rb10
-rw-r--r--spec/ruby/core/hash/include_spec.rb8
-rw-r--r--spec/ruby/core/hash/index_spec.rb6
-rw-r--r--spec/ruby/core/hash/initialize_spec.rb45
-rw-r--r--spec/ruby/core/hash/inspect_spec.rb6
-rw-r--r--spec/ruby/core/hash/invert_spec.rb4
-rw-r--r--spec/ruby/core/hash/keep_if_spec.rb18
-rw-r--r--spec/ruby/core/hash/key_spec.rb12
-rw-r--r--spec/ruby/core/hash/keys_spec.rb4
-rw-r--r--spec/ruby/core/hash/length_spec.rb8
-rw-r--r--spec/ruby/core/hash/lt_spec.rb66
-rw-r--r--spec/ruby/core/hash/lte_spec.rb66
-rw-r--r--spec/ruby/core/hash/member_spec.rb8
-rw-r--r--spec/ruby/core/hash/merge_spec.rb51
-rw-r--r--spec/ruby/core/hash/new_spec.rb10
-rw-r--r--spec/ruby/core/hash/rassoc_spec.rb2
-rw-r--r--spec/ruby/core/hash/rehash_spec.rb48
-rw-r--r--spec/ruby/core/hash/reject_spec.rb32
-rw-r--r--spec/ruby/core/hash/replace_spec.rb8
-rw-r--r--spec/ruby/core/hash/select_spec.rb81
-rw-r--r--spec/ruby/core/hash/shared/comparison.rb6
-rw-r--r--spec/ruby/core/hash/shared/each.rb17
-rw-r--r--spec/ruby/core/hash/shared/eql.rb96
-rw-r--r--spec/ruby/core/hash/shared/index.rb4
-rw-r--r--spec/ruby/core/hash/shared/replace.rb14
-rw-r--r--spec/ruby/core/hash/shared/select.rb91
-rw-r--r--spec/ruby/core/hash/shared/store.rb6
-rw-r--r--spec/ruby/core/hash/shared/to_s.rb41
-rw-r--r--spec/ruby/core/hash/shared/update.rb33
-rw-r--r--spec/ruby/core/hash/shift_spec.rb25
-rw-r--r--spec/ruby/core/hash/size_spec.rb8
-rw-r--r--spec/ruby/core/hash/slice_spec.rb23
-rw-r--r--spec/ruby/core/hash/sort_spec.rb4
-rw-r--r--spec/ruby/core/hash/store_spec.rb8
-rw-r--r--spec/ruby/core/hash/to_a_spec.rb16
-rw-r--r--spec/ruby/core/hash/to_h_spec.rb44
-rw-r--r--spec/ruby/core/hash/to_hash_spec.rb4
-rw-r--r--spec/ruby/core/hash/to_proc_spec.rb122
-rw-r--r--spec/ruby/core/hash/to_s_spec.rb6
-rw-r--r--spec/ruby/core/hash/transform_keys_spec.rb48
-rw-r--r--spec/ruby/core/hash/transform_values_spec.rb148
-rw-r--r--spec/ruby/core/hash/try_convert_spec.rb8
-rw-r--r--spec/ruby/core/hash/update_spec.rb8
-rw-r--r--spec/ruby/core/hash/value_spec.rb9
-rw-r--r--spec/ruby/core/hash/values_at_spec.rb8
-rw-r--r--spec/ruby/core/hash/values_spec.rb4
-rw-r--r--spec/ruby/core/integer/abs_spec.rb6
-rw-r--r--spec/ruby/core/integer/allbits_spec.rb64
-rw-r--r--spec/ruby/core/integer/anybits_spec.rb62
-rw-r--r--spec/ruby/core/integer/bit_and_spec.rb97
-rw-r--r--spec/ruby/core/integer/bit_length_spec.rb76
-rw-r--r--spec/ruby/core/integer/bit_or_spec.rb68
-rw-r--r--spec/ruby/core/integer/bit_xor_spec.rb72
-rw-r--r--spec/ruby/core/integer/case_compare_spec.rb6
-rw-r--r--spec/ruby/core/integer/ceil_spec.rb28
-rw-r--r--spec/ruby/core/integer/chr_spec.rb54
-rw-r--r--spec/ruby/core/integer/coerce_spec.rb104
-rw-r--r--spec/ruby/core/integer/comparison_spec.rb189
-rw-r--r--spec/ruby/core/integer/complement_spec.rb20
-rw-r--r--spec/ruby/core/integer/constants_spec.rb27
-rw-r--r--spec/ruby/core/integer/denominator_spec.rb2
-rw-r--r--spec/ruby/core/integer/digits_spec.rb48
-rw-r--r--spec/ruby/core/integer/div_spec.rb146
-rw-r--r--spec/ruby/core/integer/divide_spec.rb95
-rw-r--r--spec/ruby/core/integer/divmod_spec.rb117
-rw-r--r--spec/ruby/core/integer/downto_spec.rb10
-rw-r--r--spec/ruby/core/integer/dup_spec.rb17
-rw-r--r--spec/ruby/core/integer/element_reference_spec.rb111
-rw-r--r--spec/ruby/core/integer/equal_value_spec.rb6
-rw-r--r--spec/ruby/core/integer/even_spec.rb44
-rw-r--r--spec/ruby/core/integer/exponent_spec.rb7
-rw-r--r--spec/ruby/core/integer/fdiv_spec.rb49
-rw-r--r--spec/ruby/core/integer/fixtures/classes.rb4
-rw-r--r--spec/ruby/core/integer/floor_spec.rb28
-rw-r--r--spec/ruby/core/integer/gcd_spec.rb21
-rw-r--r--spec/ruby/core/integer/gcdlcm_spec.rb10
-rw-r--r--spec/ruby/core/integer/gt_spec.rb49
-rw-r--r--spec/ruby/core/integer/gte_spec.rb49
-rw-r--r--spec/ruby/core/integer/integer_spec.rb10
-rw-r--r--spec/ruby/core/integer/lcm_spec.rb10
-rw-r--r--spec/ruby/core/integer/left_shift_spec.rb165
-rw-r--r--spec/ruby/core/integer/lt_spec.rb51
-rw-r--r--spec/ruby/core/integer/lte_spec.rb54
-rw-r--r--spec/ruby/core/integer/magnitude_spec.rb6
-rw-r--r--spec/ruby/core/integer/minus_spec.rb49
-rw-r--r--spec/ruby/core/integer/modulo_spec.rb10
-rw-r--r--spec/ruby/core/integer/multiply_spec.rb51
-rw-r--r--spec/ruby/core/integer/next_spec.rb6
-rw-r--r--spec/ruby/core/integer/nobits_spec.rb62
-rw-r--r--spec/ruby/core/integer/numerator_spec.rb2
-rw-r--r--spec/ruby/core/integer/odd_spec.rb42
-rw-r--r--spec/ruby/core/integer/ord_spec.rb2
-rw-r--r--spec/ruby/core/integer/plus_spec.rb49
-rw-r--r--spec/ruby/core/integer/pow_spec.rb49
-rw-r--r--spec/ruby/core/integer/pred_spec.rb2
-rw-r--r--spec/ruby/core/integer/rationalize_spec.rb6
-rw-r--r--spec/ruby/core/integer/remainder_spec.rb51
-rw-r--r--spec/ruby/core/integer/right_shift_spec.rb191
-rw-r--r--spec/ruby/core/integer/round_spec.rb52
-rw-r--r--spec/ruby/core/integer/shared/abs.rb18
-rw-r--r--spec/ruby/core/integer/shared/arithmetic_coerce.rb31
-rw-r--r--spec/ruby/core/integer/shared/comparison_coerce.rb33
-rw-r--r--spec/ruby/core/integer/shared/equal.rb58
-rw-r--r--spec/ruby/core/integer/shared/exponent.rb118
-rw-r--r--spec/ruby/core/integer/shared/integer_rounding.rb8
-rw-r--r--spec/ruby/core/integer/shared/modulo.rb74
-rw-r--r--spec/ruby/core/integer/size_spec.rb34
-rw-r--r--spec/ruby/core/integer/sqrt_spec.rb6
-rw-r--r--spec/ruby/core/integer/succ_spec.rb6
-rw-r--r--spec/ruby/core/integer/times_spec.rb2
-rw-r--r--spec/ruby/core/integer/to_f_spec.rb23
-rw-r--r--spec/ruby/core/integer/to_i_spec.rb6
-rw-r--r--spec/ruby/core/integer/to_int_spec.rb6
-rw-r--r--spec/ruby/core/integer/to_r_spec.rb6
-rw-r--r--spec/ruby/core/integer/to_s_spec.rb95
-rw-r--r--spec/ruby/core/integer/truncate_spec.rb28
-rw-r--r--spec/ruby/core/integer/uminus_spec.rb30
-rw-r--r--spec/ruby/core/integer/upto_spec.rb10
-rw-r--r--spec/ruby/core/io/advise_spec.rb21
-rw-r--r--spec/ruby/core/io/binmode_spec.rb6
-rw-r--r--spec/ruby/core/io/binread_spec.rb20
-rw-r--r--spec/ruby/core/io/binwrite_spec.rb6
-rw-r--r--spec/ruby/core/io/bytes_spec.rb8
-rw-r--r--spec/ruby/core/io/chars_spec.rb6
-rw-r--r--spec/ruby/core/io/close_on_exec_spec.rb30
-rw-r--r--spec/ruby/core/io/close_read_spec.rb42
-rw-r--r--spec/ruby/core/io/close_spec.rb45
-rw-r--r--spec/ruby/core/io/close_write_spec.rb42
-rw-r--r--spec/ruby/core/io/closed_spec.rb4
-rw-r--r--spec/ruby/core/io/codepoints_spec.rb8
-rw-r--r--spec/ruby/core/io/constants_spec.rb2
-rw-r--r--spec/ruby/core/io/copy_stream_spec.rb14
-rw-r--r--spec/ruby/core/io/dup_spec.rb30
-rw-r--r--spec/ruby/core/io/each_byte_spec.rb6
-rw-r--r--spec/ruby/core/io/each_char_spec.rb6
-rw-r--r--spec/ruby/core/io/each_codepoint_spec.rb14
-rw-r--r--spec/ruby/core/io/each_line_spec.rb6
-rw-r--r--spec/ruby/core/io/each_spec.rb6
-rw-r--r--spec/ruby/core/io/eof_spec.rb10
-rw-r--r--spec/ruby/core/io/external_encoding_spec.rb304
-rw-r--r--spec/ruby/core/io/fcntl_spec.rb6
-rw-r--r--spec/ruby/core/io/fdatasync_spec.rb2
-rw-r--r--spec/ruby/core/io/fileno_spec.rb6
-rw-r--r--spec/ruby/core/io/fixtures/classes.rb4
-rw-r--r--spec/ruby/core/io/flush_spec.rb35
-rw-r--r--spec/ruby/core/io/for_fd_spec.rb4
-rw-r--r--spec/ruby/core/io/foreach_spec.rb8
-rw-r--r--spec/ruby/core/io/fsync_spec.rb6
-rw-r--r--spec/ruby/core/io/getbyte_spec.rb6
-rw-r--r--spec/ruby/core/io/getc_spec.rb6
-rw-r--r--spec/ruby/core/io/gets_spec.rb70
-rw-r--r--spec/ruby/core/io/initialize_spec.rb20
-rw-r--r--spec/ruby/core/io/inspect_spec.rb2
-rw-r--r--spec/ruby/core/io/internal_encoding_spec.rb232
-rw-r--r--spec/ruby/core/io/io_spec.rb2
-rw-r--r--spec/ruby/core/io/ioctl_spec.rb10
-rw-r--r--spec/ruby/core/io/isatty_spec.rb4
-rw-r--r--spec/ruby/core/io/lineno_spec.rb10
-rw-r--r--spec/ruby/core/io/lines_spec.rb4
-rw-r--r--spec/ruby/core/io/new_spec.rb4
-rw-r--r--spec/ruby/core/io/open_spec.rb10
-rw-r--r--spec/ruby/core/io/output_spec.rb12
-rw-r--r--spec/ruby/core/io/pid_spec.rb6
-rw-r--r--spec/ruby/core/io/pipe_spec.rb8
-rw-r--r--spec/ruby/core/io/popen_spec.rb77
-rw-r--r--spec/ruby/core/io/pos_spec.rb7
-rw-r--r--spec/ruby/core/io/pread_spec.rb52
-rw-r--r--spec/ruby/core/io/print_spec.rb7
-rw-r--r--spec/ruby/core/io/printf_spec.rb6
-rw-r--r--spec/ruby/core/io/putc_spec.rb4
-rw-r--r--spec/ruby/core/io/puts_spec.rb40
-rw-r--r--spec/ruby/core/io/pwrite_spec.rb45
-rw-r--r--spec/ruby/core/io/read_nonblock_spec.rb42
-rw-r--r--spec/ruby/core/io/read_spec.rb268
-rw-r--r--spec/ruby/core/io/readbyte_spec.rb6
-rw-r--r--spec/ruby/core/io/readchar_spec.rb10
-rw-r--r--spec/ruby/core/io/readline_spec.rb16
-rw-r--r--spec/ruby/core/io/readlines_spec.rb28
-rw-r--r--spec/ruby/core/io/readpartial_spec.rb18
-rw-r--r--spec/ruby/core/io/reopen_spec.rb47
-rw-r--r--spec/ruby/core/io/rewind_spec.rb6
-rw-r--r--spec/ruby/core/io/seek_spec.rb8
-rw-r--r--spec/ruby/core/io/select_spec.rb34
-rw-r--r--spec/ruby/core/io/set_encoding_spec.rb288
-rw-r--r--spec/ruby/core/io/shared/binwrite.rb16
-rw-r--r--spec/ruby/core/io/shared/chars.rb4
-rw-r--r--spec/ruby/core/io/shared/codepoints.rb6
-rw-r--r--spec/ruby/core/io/shared/each.rb16
-rw-r--r--spec/ruby/core/io/shared/new.rb146
-rw-r--r--spec/ruby/core/io/shared/pos.rb6
-rw-r--r--spec/ruby/core/io/shared/readlines.rb34
-rw-r--r--spec/ruby/core/io/shared/tty.rb7
-rw-r--r--spec/ruby/core/io/shared/write.rb45
-rw-r--r--spec/ruby/core/io/stat_spec.rb6
-rw-r--r--spec/ruby/core/io/sync_spec.rb8
-rw-r--r--spec/ruby/core/io/sysopen_spec.rb4
-rw-r--r--spec/ruby/core/io/sysread_spec.rb10
-rw-r--r--spec/ruby/core/io/sysseek_spec.rb10
-rw-r--r--spec/ruby/core/io/syswrite_spec.rb27
-rw-r--r--spec/ruby/core/io/tell_spec.rb8
-rw-r--r--spec/ruby/core/io/to_i_spec.rb6
-rw-r--r--spec/ruby/core/io/to_io_spec.rb4
-rw-r--r--spec/ruby/core/io/try_convert_spec.rb8
-rw-r--r--spec/ruby/core/io/tty_spec.rb4
-rw-r--r--spec/ruby/core/io/ungetbyte_spec.rb35
-rw-r--r--spec/ruby/core/io/ungetc_spec.rb24
-rw-r--r--spec/ruby/core/io/write_nonblock_spec.rb23
-rw-r--r--spec/ruby/core/io/write_spec.rb93
-rw-r--r--spec/ruby/core/kernel/Array_spec.rb8
-rw-r--r--spec/ruby/core/kernel/Complex_spec.rb187
-rw-r--r--spec/ruby/core/kernel/Float_spec.rb113
-rw-r--r--spec/ruby/core/kernel/Hash_spec.rb16
-rw-r--r--spec/ruby/core/kernel/Integer_spec.rb337
-rw-r--r--spec/ruby/core/kernel/Rational_spec.rb4
-rw-r--r--spec/ruby/core/kernel/String_spec.rb12
-rw-r--r--spec/ruby/core/kernel/__callee___spec.rb4
-rw-r--r--spec/ruby/core/kernel/__dir___spec.rb9
-rw-r--r--spec/ruby/core/kernel/__method___spec.rb4
-rw-r--r--spec/ruby/core/kernel/abort_spec.rb6
-rw-r--r--spec/ruby/core/kernel/at_exit_spec.rb4
-rw-r--r--spec/ruby/core/kernel/autoload_spec.rb55
-rw-r--r--spec/ruby/core/kernel/backtick_spec.rb8
-rw-r--r--spec/ruby/core/kernel/binding_spec.rb6
-rw-r--r--spec/ruby/core/kernel/block_given_spec.rb4
-rw-r--r--spec/ruby/core/kernel/caller_locations_spec.rb6
-rw-r--r--spec/ruby/core/kernel/caller_spec.rb13
-rw-r--r--spec/ruby/core/kernel/case_compare_spec.rb4
-rw-r--r--spec/ruby/core/kernel/catch_spec.rb10
-rw-r--r--spec/ruby/core/kernel/chomp_spec.rb40
-rw-r--r--spec/ruby/core/kernel/chop_spec.rb40
-rw-r--r--spec/ruby/core/kernel/class_spec.rb4
-rw-r--r--spec/ruby/core/kernel/clone_spec.rb32
-rw-r--r--spec/ruby/core/kernel/comparison_spec.rb2
-rw-r--r--spec/ruby/core/kernel/define_singleton_method_spec.rb36
-rw-r--r--spec/ruby/core/kernel/display_spec.rb4
-rw-r--r--spec/ruby/core/kernel/dup_spec.rb12
-rw-r--r--spec/ruby/core/kernel/enum_for_spec.rb2
-rw-r--r--spec/ruby/core/kernel/eql_spec.rb5
-rw-r--r--spec/ruby/core/kernel/equal_value_spec.rb4
-rw-r--r--spec/ruby/core/kernel/eval_spec.rb172
-rw-r--r--spec/ruby/core/kernel/exec_spec.rb4
-rw-r--r--spec/ruby/core/kernel/exit_spec.rb6
-rw-r--r--spec/ruby/core/kernel/extend_spec.rb18
-rw-r--r--spec/ruby/core/kernel/fail_spec.rb25
-rw-r--r--spec/ruby/core/kernel/fixtures/autoload_c.rb5
-rw-r--r--spec/ruby/core/kernel/fixtures/autoload_from_included_module.rb9
-rw-r--r--spec/ruby/core/kernel/fixtures/autoload_from_included_module2.rb9
-rw-r--r--spec/ruby/core/kernel/fixtures/caller_at_exit.rb7
-rw-r--r--spec/ruby/core/kernel/fixtures/classes.rb93
-rw-r--r--spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb2
-rw-r--r--spec/ruby/core/kernel/fixtures/singleton_methods.rb13
-rw-r--r--spec/ruby/core/kernel/fork_spec.rb6
-rw-r--r--spec/ruby/core/kernel/format_spec.rb4
-rw-r--r--spec/ruby/core/kernel/freeze_spec.rb8
-rw-r--r--spec/ruby/core/kernel/frozen_spec.rb4
-rw-r--r--spec/ruby/core/kernel/gets_spec.rb4
-rw-r--r--spec/ruby/core/kernel/global_variables_spec.rb4
-rw-r--r--spec/ruby/core/kernel/gsub_spec.rb6
-rw-r--r--spec/ruby/core/kernel/inspect_spec.rb16
-rw-r--r--spec/ruby/core/kernel/instance_of_spec.rb10
-rw-r--r--spec/ruby/core/kernel/instance_variable_defined_spec.rb6
-rw-r--r--spec/ruby/core/kernel/instance_variable_get_spec.rb28
-rw-r--r--spec/ruby/core/kernel/instance_variable_set_spec.rb42
-rw-r--r--spec/ruby/core/kernel/instance_variables_spec.rb6
-rw-r--r--spec/ruby/core/kernel/is_a_spec.rb6
-rw-r--r--spec/ruby/core/kernel/iterator_spec.rb4
-rw-r--r--spec/ruby/core/kernel/itself_spec.rb4
-rw-r--r--spec/ruby/core/kernel/kind_of_spec.rb6
-rw-r--r--spec/ruby/core/kernel/lambda_spec.rb48
-rw-r--r--spec/ruby/core/kernel/load_spec.rb8
-rw-r--r--spec/ruby/core/kernel/local_variables_spec.rb15
-rw-r--r--spec/ruby/core/kernel/loop_spec.rb22
-rw-r--r--spec/ruby/core/kernel/match_spec.rb24
-rw-r--r--spec/ruby/core/kernel/method_spec.rb8
-rw-r--r--spec/ruby/core/kernel/methods_spec.rb6
-rw-r--r--spec/ruby/core/kernel/nil_spec.rb4
-rw-r--r--spec/ruby/core/kernel/not_match_spec.rb4
-rw-r--r--spec/ruby/core/kernel/object_id_spec.rb4
-rw-r--r--spec/ruby/core/kernel/open_spec.rb18
-rw-r--r--spec/ruby/core/kernel/p_spec.rb30
-rw-r--r--spec/ruby/core/kernel/pp_spec.rb11
-rw-r--r--spec/ruby/core/kernel/print_spec.rb4
-rw-r--r--spec/ruby/core/kernel/printf_spec.rb11
-rw-r--r--spec/ruby/core/kernel/private_methods_spec.rb6
-rw-r--r--spec/ruby/core/kernel/proc_spec.rb44
-rw-r--r--spec/ruby/core/kernel/protected_methods_spec.rb6
-rw-r--r--spec/ruby/core/kernel/public_method_spec.rb14
-rw-r--r--spec/ruby/core/kernel/public_methods_spec.rb6
-rw-r--r--spec/ruby/core/kernel/public_send_spec.rb20
-rw-r--r--spec/ruby/core/kernel/putc_spec.rb6
-rw-r--r--spec/ruby/core/kernel/puts_spec.rb4
-rw-r--r--spec/ruby/core/kernel/raise_spec.rb6
-rw-r--r--spec/ruby/core/kernel/rand_spec.rb20
-rw-r--r--spec/ruby/core/kernel/readline_spec.rb4
-rw-r--r--spec/ruby/core/kernel/readlines_spec.rb4
-rw-r--r--spec/ruby/core/kernel/remove_instance_variable_spec.rb10
-rw-r--r--spec/ruby/core/kernel/require_relative_spec.rb126
-rw-r--r--spec/ruby/core/kernel/require_spec.rb8
-rw-r--r--spec/ruby/core/kernel/respond_to_missing_spec.rb4
-rw-r--r--spec/ruby/core/kernel/respond_to_spec.rb8
-rw-r--r--spec/ruby/core/kernel/select_spec.rb6
-rw-r--r--spec/ruby/core/kernel/send_spec.rb8
-rw-r--r--spec/ruby/core/kernel/set_trace_func_spec.rb4
-rw-r--r--spec/ruby/core/kernel/shared/dup_clone.rb88
-rw-r--r--spec/ruby/core/kernel/shared/kind_of.rb23
-rw-r--r--spec/ruby/core/kernel/shared/lambda.rb2
-rw-r--r--spec/ruby/core/kernel/shared/load.rb43
-rw-r--r--spec/ruby/core/kernel/shared/method.rb6
-rw-r--r--spec/ruby/core/kernel/shared/require.rb174
-rw-r--r--spec/ruby/core/kernel/shared/sprintf.rb40
-rw-r--r--spec/ruby/core/kernel/shared/sprintf_encoding.rb2
-rw-r--r--spec/ruby/core/kernel/shared/then.rb20
-rw-r--r--spec/ruby/core/kernel/singleton_class_spec.rb4
-rw-r--r--spec/ruby/core/kernel/singleton_method_spec.rb2
-rw-r--r--spec/ruby/core/kernel/singleton_methods_spec.rb32
-rw-r--r--spec/ruby/core/kernel/sleep_spec.rb22
-rw-r--r--spec/ruby/core/kernel/spawn_spec.rb8
-rw-r--r--spec/ruby/core/kernel/sprintf_spec.rb16
-rw-r--r--spec/ruby/core/kernel/srand_spec.rb10
-rw-r--r--spec/ruby/core/kernel/sub_spec.rb4
-rw-r--r--spec/ruby/core/kernel/syscall_spec.rb4
-rw-r--r--spec/ruby/core/kernel/system_spec.rb28
-rw-r--r--spec/ruby/core/kernel/taint_spec.rb68
-rw-r--r--spec/ruby/core/kernel/tainted_spec.rb18
-rw-r--r--spec/ruby/core/kernel/tap_spec.rb6
-rw-r--r--spec/ruby/core/kernel/test_spec.rb4
-rw-r--r--spec/ruby/core/kernel/then_spec.rb8
-rw-r--r--spec/ruby/core/kernel/throw_spec.rb16
-rw-r--r--spec/ruby/core/kernel/to_enum_spec.rb2
-rw-r--r--spec/ruby/core/kernel/to_s_spec.rb16
-rw-r--r--spec/ruby/core/kernel/trace_var_spec.rb6
-rw-r--r--spec/ruby/core/kernel/trap_spec.rb4
-rw-r--r--spec/ruby/core/kernel/trust_spec.rb38
-rw-r--r--spec/ruby/core/kernel/untaint_spec.rb38
-rw-r--r--spec/ruby/core/kernel/untrace_var_spec.rb4
-rw-r--r--spec/ruby/core/kernel/untrust_spec.rb38
-rw-r--r--spec/ruby/core/kernel/untrusted_spec.rb46
-rw-r--r--spec/ruby/core/kernel/warn_spec.rb97
-rw-r--r--spec/ruby/core/kernel/yield_self_spec.rb26
-rw-r--r--spec/ruby/core/main/define_method_spec.rb4
-rw-r--r--spec/ruby/core/main/include_spec.rb4
-rw-r--r--spec/ruby/core/main/private_spec.rb6
-rw-r--r--spec/ruby/core/main/public_spec.rb6
-rw-r--r--spec/ruby/core/main/to_s_spec.rb2
-rw-r--r--spec/ruby/core/main/using_spec.rb217
-rw-r--r--spec/ruby/core/marshal/dump_spec.rb189
-rw-r--r--spec/ruby/core/marshal/float_spec.rb2
-rw-r--r--spec/ruby/core/marshal/load_spec.rb4
-rw-r--r--spec/ruby/core/marshal/major_version_spec.rb2
-rw-r--r--spec/ruby/core/marshal/minor_version_spec.rb2
-rw-r--r--spec/ruby/core/marshal/restore_spec.rb4
-rw-r--r--spec/ruby/core/marshal/shared/load.rb414
-rw-r--r--spec/ruby/core/matchdata/allocate_spec.rb10
-rw-r--r--spec/ruby/core/matchdata/begin_spec.rb110
-rw-r--r--spec/ruby/core/matchdata/captures_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/dup_spec.rb14
-rw-r--r--spec/ruby/core/matchdata/element_reference_spec.rb6
-rw-r--r--spec/ruby/core/matchdata/end_spec.rb110
-rw-r--r--spec/ruby/core/matchdata/eql_spec.rb6
-rw-r--r--spec/ruby/core/matchdata/equal_value_spec.rb6
-rw-r--r--spec/ruby/core/matchdata/hash_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/inspect_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/length_spec.rb6
-rw-r--r--spec/ruby/core/matchdata/named_captures_spec.rb20
-rw-r--r--spec/ruby/core/matchdata/names_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/offset_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/post_match_spec.rb46
-rw-r--r--spec/ruby/core/matchdata/pre_match_spec.rb46
-rw-r--r--spec/ruby/core/matchdata/regexp_spec.rb13
-rw-r--r--spec/ruby/core/matchdata/shared/eql.rb2
-rw-r--r--spec/ruby/core/matchdata/size_spec.rb6
-rw-r--r--spec/ruby/core/matchdata/string_spec.rb13
-rw-r--r--spec/ruby/core/matchdata/to_a_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/to_s_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/values_at_spec.rb14
-rw-r--r--spec/ruby/core/math/acos_spec.rb22
-rw-r--r--spec/ruby/core/math/acosh_spec.rb18
-rw-r--r--spec/ruby/core/math/asin_spec.rb20
-rw-r--r--spec/ruby/core/math/asinh_spec.rb8
-rw-r--r--spec/ruby/core/math/atan2_spec.rb16
-rw-r--r--spec/ruby/core/math/atan_spec.rb8
-rw-r--r--spec/ruby/core/math/atanh_spec.rb6
-rw-r--r--spec/ruby/core/math/cbrt_spec.rb8
-rw-r--r--spec/ruby/core/math/constants_spec.rb4
-rw-r--r--spec/ruby/core/math/cos_spec.rb8
-rw-r--r--spec/ruby/core/math/cosh_spec.rb8
-rw-r--r--spec/ruby/core/math/erf_spec.rb8
-rw-r--r--spec/ruby/core/math/erfc_spec.rb8
-rw-r--r--spec/ruby/core/math/exp_spec.rb8
-rw-r--r--spec/ruby/core/math/frexp_spec.rb8
-rw-r--r--spec/ruby/core/math/gamma_spec.rb6
-rw-r--r--spec/ruby/core/math/hypot_spec.rb8
-rw-r--r--spec/ruby/core/math/ldexp_spec.rb14
-rw-r--r--spec/ruby/core/math/lgamma_spec.rb10
-rw-r--r--spec/ruby/core/math/log10_spec.rb14
-rw-r--r--spec/ruby/core/math/log2_spec.rb12
-rw-r--r--spec/ruby/core/math/log_spec.rb20
-rw-r--r--spec/ruby/core/math/sin_spec.rb8
-rw-r--r--spec/ruby/core/math/sinh_spec.rb8
-rw-r--r--spec/ruby/core/math/sqrt_spec.rb8
-rw-r--r--spec/ruby/core/math/tan_spec.rb10
-rw-r--r--spec/ruby/core/math/tanh_spec.rb8
-rw-r--r--spec/ruby/core/method/arity_spec.rb4
-rw-r--r--spec/ruby/core/method/call_spec.rb8
-rw-r--r--spec/ruby/core/method/case_compare_spec.rb9
-rw-r--r--spec/ruby/core/method/clone_spec.rb4
-rw-r--r--spec/ruby/core/method/compose_spec.rb101
-rw-r--r--spec/ruby/core/method/curry_spec.rb14
-rw-r--r--spec/ruby/core/method/element_reference_spec.rb8
-rw-r--r--spec/ruby/core/method/eql_spec.rb6
-rw-r--r--spec/ruby/core/method/equal_value_spec.rb6
-rw-r--r--spec/ruby/core/method/fixtures/classes.rb26
-rw-r--r--spec/ruby/core/method/hash_spec.rb6
-rw-r--r--spec/ruby/core/method/inspect_spec.rb6
-rw-r--r--spec/ruby/core/method/name_spec.rb4
-rw-r--r--spec/ruby/core/method/original_name_spec.rb22
-rw-r--r--spec/ruby/core/method/owner_spec.rb4
-rw-r--r--spec/ruby/core/method/parameters_spec.rb23
-rw-r--r--spec/ruby/core/method/receiver_spec.rb4
-rw-r--r--spec/ruby/core/method/shared/call.rb4
-rw-r--r--spec/ruby/core/method/shared/eql.rb4
-rw-r--r--spec/ruby/core/method/shared/to_s.rb4
-rw-r--r--spec/ruby/core/method/source_location_spec.rb6
-rw-r--r--spec/ruby/core/method/super_method_spec.rb4
-rw-r--r--spec/ruby/core/method/to_proc_spec.rb19
-rw-r--r--spec/ruby/core/method/to_s_spec.rb6
-rw-r--r--spec/ruby/core/method/unbind_spec.rb4
-rw-r--r--spec/ruby/core/module/alias_method_spec.rb24
-rw-r--r--spec/ruby/core/module/allocate_spec.rb2
-rw-r--r--spec/ruby/core/module/ancestors_spec.rb4
-rw-r--r--spec/ruby/core/module/append_features_spec.rb34
-rw-r--r--spec/ruby/core/module/attr_accessor_spec.rb14
-rw-r--r--spec/ruby/core/module/attr_reader_spec.rb12
-rw-r--r--spec/ruby/core/module/attr_spec.rb23
-rw-r--r--spec/ruby/core/module/attr_writer_spec.rb12
-rw-r--r--spec/ruby/core/module/autoload_spec.rb581
-rw-r--r--spec/ruby/core/module/case_compare_spec.rb4
-rw-r--r--spec/ruby/core/module/class_eval_spec.rb6
-rw-r--r--spec/ruby/core/module/class_exec_spec.rb6
-rw-r--r--spec/ruby/core/module/class_variable_defined_spec.rb12
-rw-r--r--spec/ruby/core/module/class_variable_get_spec.rb20
-rw-r--r--spec/ruby/core/module/class_variable_set_spec.rb22
-rw-r--r--spec/ruby/core/module/class_variables_spec.rb4
-rw-r--r--spec/ruby/core/module/comparison_spec.rb6
-rw-r--r--spec/ruby/core/module/const_defined_spec.rb22
-rw-r--r--spec/ruby/core/module/const_get_spec.rb69
-rw-r--r--spec/ruby/core/module/const_missing_spec.rb15
-rw-r--r--spec/ruby/core/module/const_set_spec.rb73
-rw-r--r--spec/ruby/core/module/constants_spec.rb6
-rw-r--r--spec/ruby/core/module/define_method_spec.rb143
-rw-r--r--spec/ruby/core/module/define_singleton_method_spec.rb6
-rw-r--r--spec/ruby/core/module/deprecate_constant_spec.rb86
-rw-r--r--spec/ruby/core/module/eql_spec.rb8
-rw-r--r--spec/ruby/core/module/equal_spec.rb8
-rw-r--r--spec/ruby/core/module/equal_value_spec.rb8
-rw-r--r--spec/ruby/core/module/extend_object_spec.rb28
-rw-r--r--spec/ruby/core/module/extended_spec.rb4
-rw-r--r--spec/ruby/core/module/fixtures/autoload_callback.rb2
-rw-r--r--spec/ruby/core/module/fixtures/autoload_during_autoload.rb7
-rw-r--r--spec/ruby/core/module/fixtures/autoload_during_require.rb4
-rw-r--r--spec/ruby/core/module/fixtures/autoload_exception.rb3
-rw-r--r--spec/ruby/core/module/fixtures/autoload_nested.rb8
-rw-r--r--spec/ruby/core/module/fixtures/autoload_o.rb1
-rw-r--r--spec/ruby/core/module/fixtures/autoload_overridden.rb3
-rw-r--r--spec/ruby/core/module/fixtures/autoload_raise.rb2
-rw-r--r--spec/ruby/core/module/fixtures/autoload_required_directly.rb7
-rw-r--r--spec/ruby/core/module/fixtures/autoload_required_directly_nested.rb1
-rw-r--r--spec/ruby/core/module/fixtures/autoload_scope.rb8
-rw-r--r--spec/ruby/core/module/fixtures/autoload_self_during_require.rb5
-rw-r--r--spec/ruby/core/module/fixtures/autoload_subclass.rb4
-rw-r--r--spec/ruby/core/module/fixtures/classes.rb9
-rw-r--r--spec/ruby/core/module/fixtures/constants_autoload.rb6
-rw-r--r--spec/ruby/core/module/fixtures/constants_autoload_a.rb2
-rw-r--r--spec/ruby/core/module/fixtures/constants_autoload_b.rb2
-rw-r--r--spec/ruby/core/module/fixtures/constants_autoload_c.rb3
-rw-r--r--spec/ruby/core/module/fixtures/constants_autoload_d.rb4
-rw-r--r--spec/ruby/core/module/fixtures/multi/foo.rb6
-rw-r--r--spec/ruby/core/module/fixtures/multi/foo/bar_baz.rb11
-rw-r--r--spec/ruby/core/module/freeze_spec.rb4
-rw-r--r--spec/ruby/core/module/gt_spec.rb6
-rw-r--r--spec/ruby/core/module/gte_spec.rb6
-rw-r--r--spec/ruby/core/module/include_spec.rb38
-rw-r--r--spec/ruby/core/module/included_modules_spec.rb4
-rw-r--r--spec/ruby/core/module/included_spec.rb4
-rw-r--r--spec/ruby/core/module/initialize_copy_spec.rb10
-rw-r--r--spec/ruby/core/module/initialize_spec.rb4
-rw-r--r--spec/ruby/core/module/instance_method_spec.rb16
-rw-r--r--spec/ruby/core/module/instance_methods_spec.rb4
-rw-r--r--spec/ruby/core/module/lt_spec.rb6
-rw-r--r--spec/ruby/core/module/lte_spec.rb6
-rw-r--r--spec/ruby/core/module/method_added_spec.rb4
-rw-r--r--spec/ruby/core/module/method_defined_spec.rb59
-rw-r--r--spec/ruby/core/module/method_removed_spec.rb4
-rw-r--r--spec/ruby/core/module/method_undefined_spec.rb4
-rw-r--r--spec/ruby/core/module/module_eval_spec.rb6
-rw-r--r--spec/ruby/core/module/module_exec_spec.rb6
-rw-r--r--spec/ruby/core/module/module_function_spec.rb14
-rw-r--r--spec/ruby/core/module/name_spec.rb66
-rw-r--r--spec/ruby/core/module/nesting_spec.rb4
-rw-r--r--spec/ruby/core/module/new_spec.rb4
-rw-r--r--spec/ruby/core/module/prepend_features_spec.rb28
-rw-r--r--spec/ruby/core/module/prepend_spec.rb48
-rw-r--r--spec/ruby/core/module/prepended_spec.rb2
-rw-r--r--spec/ruby/core/module/private_class_method_spec.rb24
-rw-r--r--spec/ruby/core/module/private_constant_spec.rb10
-rw-r--r--spec/ruby/core/module/private_instance_methods_spec.rb6
-rw-r--r--spec/ruby/core/module/private_method_defined_spec.rb64
-rw-r--r--spec/ruby/core/module/private_spec.rb12
-rw-r--r--spec/ruby/core/module/protected_instance_methods_spec.rb6
-rw-r--r--spec/ruby/core/module/protected_method_defined_spec.rb64
-rw-r--r--spec/ruby/core/module/protected_spec.rb11
-rw-r--r--spec/ruby/core/module/public_class_method_spec.rb18
-rw-r--r--spec/ruby/core/module/public_constant_spec.rb4
-rw-r--r--spec/ruby/core/module/public_instance_method_spec.rb14
-rw-r--r--spec/ruby/core/module/public_instance_methods_spec.rb6
-rw-r--r--spec/ruby/core/module/public_method_defined_spec.rb14
-rw-r--r--spec/ruby/core/module/public_spec.rb8
-rw-r--r--spec/ruby/core/module/refine_spec.rb343
-rw-r--r--spec/ruby/core/module/remove_class_variable_spec.rb12
-rw-r--r--spec/ruby/core/module/remove_const_spec.rb30
-rw-r--r--spec/ruby/core/module/remove_method_spec.rb30
-rw-r--r--spec/ruby/core/module/shared/class_eval.rb14
-rw-r--r--spec/ruby/core/module/shared/class_exec.rb4
-rw-r--r--spec/ruby/core/module/shared/set_visibility.rb17
-rw-r--r--spec/ruby/core/module/singleton_class_spec.rb2
-rw-r--r--spec/ruby/core/module/to_s_spec.rb35
-rw-r--r--spec/ruby/core/module/undef_method_spec.rb59
-rw-r--r--spec/ruby/core/module/using_spec.rb12
-rw-r--r--spec/ruby/core/mutex/lock_spec.rb21
-rw-r--r--spec/ruby/core/mutex/locked_spec.rb2
-rw-r--r--spec/ruby/core/mutex/owned_spec.rb2
-rw-r--r--spec/ruby/core/mutex/sleep_spec.rb22
-rw-r--r--spec/ruby/core/mutex/synchronize_spec.rb43
-rw-r--r--spec/ruby/core/mutex/try_lock_spec.rb2
-rw-r--r--spec/ruby/core/mutex/unlock_spec.rb8
-rw-r--r--spec/ruby/core/nil/and_spec.rb2
-rw-r--r--spec/ruby/core/nil/dup_spec.rb10
-rw-r--r--spec/ruby/core/nil/inspect_spec.rb2
-rw-r--r--spec/ruby/core/nil/match_spec.rb19
-rw-r--r--spec/ruby/core/nil/nil_spec.rb2
-rw-r--r--spec/ruby/core/nil/nilclass_spec.rb6
-rw-r--r--spec/ruby/core/nil/or_spec.rb2
-rw-r--r--spec/ruby/core/nil/rationalize_spec.rb6
-rw-r--r--spec/ruby/core/nil/to_a_spec.rb2
-rw-r--r--spec/ruby/core/nil/to_c_spec.rb2
-rw-r--r--spec/ruby/core/nil/to_f_spec.rb2
-rw-r--r--spec/ruby/core/nil/to_h_spec.rb2
-rw-r--r--spec/ruby/core/nil/to_i_spec.rb2
-rw-r--r--spec/ruby/core/nil/to_r_spec.rb2
-rw-r--r--spec/ruby/core/nil/to_s_spec.rb12
-rw-r--r--spec/ruby/core/nil/xor_spec.rb2
-rw-r--r--spec/ruby/core/numeric/abs2_spec.rb2
-rw-r--r--spec/ruby/core/numeric/abs_spec.rb5
-rw-r--r--spec/ruby/core/numeric/angle_spec.rb6
-rw-r--r--spec/ruby/core/numeric/arg_spec.rb6
-rw-r--r--spec/ruby/core/numeric/ceil_spec.rb4
-rw-r--r--spec/ruby/core/numeric/coerce_spec.rb49
-rw-r--r--spec/ruby/core/numeric/comparison_spec.rb4
-rw-r--r--spec/ruby/core/numeric/conj_spec.rb6
-rw-r--r--spec/ruby/core/numeric/conjugate_spec.rb6
-rw-r--r--spec/ruby/core/numeric/denominator_spec.rb2
-rw-r--r--spec/ruby/core/numeric/div_spec.rb10
-rw-r--r--spec/ruby/core/numeric/divmod_spec.rb4
-rw-r--r--spec/ruby/core/numeric/eql_spec.rb4
-rw-r--r--spec/ruby/core/numeric/fdiv_spec.rb4
-rw-r--r--spec/ruby/core/numeric/finite_spec.rb12
-rw-r--r--spec/ruby/core/numeric/floor_spec.rb4
-rw-r--r--spec/ruby/core/numeric/i_spec.rb2
-rw-r--r--spec/ruby/core/numeric/imag_spec.rb6
-rw-r--r--spec/ruby/core/numeric/imaginary_spec.rb6
-rw-r--r--spec/ruby/core/numeric/infinite_spec.rb12
-rw-r--r--spec/ruby/core/numeric/integer_spec.rb4
-rw-r--r--spec/ruby/core/numeric/magnitude_spec.rb4
-rw-r--r--spec/ruby/core/numeric/modulo_spec.rb4
-rw-r--r--spec/ruby/core/numeric/negative_spec.rb60
-rw-r--r--spec/ruby/core/numeric/nonzero_spec.rb4
-rw-r--r--spec/ruby/core/numeric/numerator_spec.rb2
-rw-r--r--spec/ruby/core/numeric/numeric_spec.rb2
-rw-r--r--spec/ruby/core/numeric/phase_spec.rb6
-rw-r--r--spec/ruby/core/numeric/polar_spec.rb50
-rw-r--r--spec/ruby/core/numeric/positive_spec.rb60
-rw-r--r--spec/ruby/core/numeric/quo_spec.rb24
-rw-r--r--spec/ruby/core/numeric/real_spec.rb32
-rw-r--r--spec/ruby/core/numeric/rect_spec.rb6
-rw-r--r--spec/ruby/core/numeric/rectangular_spec.rb6
-rw-r--r--spec/ruby/core/numeric/remainder_spec.rb4
-rw-r--r--spec/ruby/core/numeric/round_spec.rb4
-rw-r--r--spec/ruby/core/numeric/shared/abs.rb4
-rw-r--r--spec/ruby/core/numeric/shared/arg.rb38
-rw-r--r--spec/ruby/core/numeric/shared/conj.rb20
-rw-r--r--spec/ruby/core/numeric/shared/imag.rb26
-rw-r--r--spec/ruby/core/numeric/shared/rect.rb4
-rw-r--r--spec/ruby/core/numeric/shared/step.rb246
-rw-r--r--spec/ruby/core/numeric/singleton_method_added_spec.rb12
-rw-r--r--spec/ruby/core/numeric/step_spec.rb103
-rw-r--r--spec/ruby/core/numeric/to_c_spec.rb2
-rw-r--r--spec/ruby/core/numeric/to_int_spec.rb4
-rw-r--r--spec/ruby/core/numeric/truncate_spec.rb4
-rw-r--r--spec/ruby/core/numeric/uminus_spec.rb2
-rw-r--r--spec/ruby/core/numeric/uplus_spec.rb4
-rw-r--r--spec/ruby/core/numeric/zero_spec.rb4
-rw-r--r--spec/ruby/core/objectspace/_id2ref_spec.rb2
-rw-r--r--spec/ruby/core/objectspace/add_finalizer_spec.rb2
-rw-r--r--spec/ruby/core/objectspace/call_finalizer_spec.rb2
-rw-r--r--spec/ruby/core/objectspace/count_objects_spec.rb2
-rw-r--r--spec/ruby/core/objectspace/define_finalizer_spec.rb99
-rw-r--r--spec/ruby/core/objectspace/each_object_spec.rb26
-rw-r--r--spec/ruby/core/objectspace/finalizers_spec.rb2
-rw-r--r--spec/ruby/core/objectspace/fixtures/classes.rb2
-rw-r--r--spec/ruby/core/objectspace/garbage_collect_spec.rb8
-rw-r--r--spec/ruby/core/objectspace/remove_finalizer_spec.rb2
-rw-r--r--spec/ruby/core/objectspace/undefine_finalizer_spec.rb2
-rw-r--r--spec/ruby/core/proc/allocate_spec.rb4
-rw-r--r--spec/ruby/core/proc/arity_spec.rb2
-rw-r--r--spec/ruby/core/proc/binding_spec.rb6
-rw-r--r--spec/ruby/core/proc/block_pass_spec.rb38
-rw-r--r--spec/ruby/core/proc/call_spec.rb6
-rw-r--r--spec/ruby/core/proc/case_compare_spec.rb6
-rw-r--r--spec/ruby/core/proc/clone_spec.rb6
-rw-r--r--spec/ruby/core/proc/compose_spec.rb156
-rw-r--r--spec/ruby/core/proc/curry_spec.rb62
-rw-r--r--spec/ruby/core/proc/dup_spec.rb6
-rw-r--r--spec/ruby/core/proc/element_reference_spec.rb17
-rw-r--r--spec/ruby/core/proc/eql_spec.rb6
-rw-r--r--spec/ruby/core/proc/equal_value_spec.rb6
-rw-r--r--spec/ruby/core/proc/fixtures/proc_aref.rb9
-rw-r--r--spec/ruby/core/proc/fixtures/proc_aref_frozen.rb10
-rw-r--r--spec/ruby/core/proc/fixtures/source_location.rb6
-rw-r--r--spec/ruby/core/proc/hash_spec.rb4
-rw-r--r--spec/ruby/core/proc/inspect_spec.rb4
-rw-r--r--spec/ruby/core/proc/lambda_spec.rb18
-rw-r--r--spec/ruby/core/proc/new_spec.rb84
-rw-r--r--spec/ruby/core/proc/parameters_spec.rb38
-rw-r--r--spec/ruby/core/proc/shared/call.rb30
-rw-r--r--spec/ruby/core/proc/shared/call_arguments.rb24
-rw-r--r--spec/ruby/core/proc/shared/compose.rb47
-rw-r--r--spec/ruby/core/proc/shared/dup.rb2
-rw-r--r--spec/ruby/core/proc/shared/equal.rb24
-rw-r--r--spec/ruby/core/proc/shared/to_s.rb44
-rw-r--r--spec/ruby/core/proc/source_location_spec.rb28
-rw-r--r--spec/ruby/core/proc/to_proc_spec.rb4
-rw-r--r--spec/ruby/core/proc/to_s_spec.rb4
-rw-r--r--spec/ruby/core/proc/yield_spec.rb6
-rw-r--r--spec/ruby/core/process/abort_spec.rb4
-rw-r--r--spec/ruby/core/process/clock_getres_spec.rb33
-rw-r--r--spec/ruby/core/process/clock_gettime_spec.rb137
-rw-r--r--spec/ruby/core/process/daemon_spec.rb14
-rw-r--r--spec/ruby/core/process/detach_spec.rb4
-rw-r--r--spec/ruby/core/process/egid_spec.rb2
-rw-r--r--spec/ruby/core/process/euid_spec.rb33
-rw-r--r--spec/ruby/core/process/exec_spec.rb55
-rw-r--r--spec/ruby/core/process/exit_spec.rb4
-rw-r--r--spec/ruby/core/process/fixtures/clocks.rb18
-rw-r--r--spec/ruby/core/process/fixtures/common.rb8
-rw-r--r--spec/ruby/core/process/fixtures/in.txt1
-rw-r--r--spec/ruby/core/process/fixtures/map_fd.rb3
-rw-r--r--spec/ruby/core/process/fork_spec.rb4
-rw-r--r--spec/ruby/core/process/getpgid_spec.rb2
-rw-r--r--spec/ruby/core/process/getpgrp_spec.rb2
-rw-r--r--spec/ruby/core/process/getpriority_spec.rb2
-rw-r--r--spec/ruby/core/process/getrlimit_spec.rb22
-rw-r--r--spec/ruby/core/process/gid/change_privilege_spec.rb2
-rw-r--r--spec/ruby/core/process/gid/eid_spec.rb2
-rw-r--r--spec/ruby/core/process/gid/grant_privilege_spec.rb2
-rw-r--r--spec/ruby/core/process/gid/re_exchange_spec.rb2
-rw-r--r--spec/ruby/core/process/gid/re_exchangeable_spec.rb2
-rw-r--r--spec/ruby/core/process/gid/rid_spec.rb2
-rw-r--r--spec/ruby/core/process/gid/sid_available_spec.rb2
-rw-r--r--spec/ruby/core/process/gid/switch_spec.rb2
-rw-r--r--spec/ruby/core/process/gid_spec.rb2
-rw-r--r--spec/ruby/core/process/groups_spec.rb15
-rw-r--r--spec/ruby/core/process/initgroups_spec.rb30
-rw-r--r--spec/ruby/core/process/kill_spec.rb18
-rw-r--r--spec/ruby/core/process/last_status_spec.rb20
-rw-r--r--spec/ruby/core/process/maxgroups_spec.rb2
-rw-r--r--spec/ruby/core/process/pid_spec.rb2
-rw-r--r--spec/ruby/core/process/ppid_spec.rb20
-rw-r--r--spec/ruby/core/process/set_proctitle_spec.rb2
-rw-r--r--spec/ruby/core/process/setpgid_spec.rb5
-rw-r--r--spec/ruby/core/process/setpgrp_spec.rb2
-rw-r--r--spec/ruby/core/process/setpriority_spec.rb33
-rw-r--r--spec/ruby/core/process/setrlimit_spec.rb16
-rw-r--r--spec/ruby/core/process/setsid_spec.rb39
-rw-r--r--spec/ruby/core/process/spawn_spec.rb342
-rw-r--r--spec/ruby/core/process/status/bit_and_spec.rb2
-rw-r--r--spec/ruby/core/process/status/coredump_spec.rb2
-rw-r--r--spec/ruby/core/process/status/equal_value_spec.rb14
-rw-r--r--spec/ruby/core/process/status/exited_spec.rb2
-rw-r--r--spec/ruby/core/process/status/exitstatus_spec.rb16
-rw-r--r--spec/ruby/core/process/status/inspect_spec.rb2
-rw-r--r--spec/ruby/core/process/status/pid_spec.rb2
-rw-r--r--spec/ruby/core/process/status/right_shift_spec.rb2
-rw-r--r--spec/ruby/core/process/status/signaled_spec.rb2
-rw-r--r--spec/ruby/core/process/status/stopped_spec.rb2
-rw-r--r--spec/ruby/core/process/status/stopsig_spec.rb2
-rw-r--r--spec/ruby/core/process/status/success_spec.rb2
-rw-r--r--spec/ruby/core/process/status/termsig_spec.rb22
-rw-r--r--spec/ruby/core/process/status/to_i_spec.rb12
-rw-r--r--spec/ruby/core/process/status/to_int_spec.rb2
-rw-r--r--spec/ruby/core/process/status/to_s_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/getegid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/geteuid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/getgid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/getuid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/issetugid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setegid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/seteuid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setgid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setregid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setresgid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setresuid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setreuid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setrgid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setruid_spec.rb2
-rw-r--r--spec/ruby/core/process/sys/setuid_spec.rb2
-rw-r--r--spec/ruby/core/process/times_spec.rb37
-rw-r--r--spec/ruby/core/process/uid/change_privilege_spec.rb2
-rw-r--r--spec/ruby/core/process/uid/eid_spec.rb2
-rw-r--r--spec/ruby/core/process/uid/grant_privilege_spec.rb2
-rw-r--r--spec/ruby/core/process/uid/re_exchange_spec.rb2
-rw-r--r--spec/ruby/core/process/uid/re_exchangeable_spec.rb2
-rw-r--r--spec/ruby/core/process/uid/rid_spec.rb2
-rw-r--r--spec/ruby/core/process/uid/sid_available_spec.rb2
-rw-r--r--spec/ruby/core/process/uid/switch_spec.rb2
-rw-r--r--spec/ruby/core/process/uid_spec.rb63
-rw-r--r--spec/ruby/core/process/wait2_spec.rb12
-rw-r--r--spec/ruby/core/process/wait_spec.rb20
-rw-r--r--spec/ruby/core/process/waitall_spec.rb6
-rw-r--r--spec/ruby/core/process/waitpid2_spec.rb2
-rw-r--r--spec/ruby/core/process/waitpid_spec.rb4
-rw-r--r--spec/ruby/core/queue/append_spec.rb6
-rw-r--r--spec/ruby/core/queue/clear_spec.rb6
-rw-r--r--spec/ruby/core/queue/close_spec.rb6
-rw-r--r--spec/ruby/core/queue/closed_spec.rb6
-rw-r--r--spec/ruby/core/queue/deq_spec.rb6
-rw-r--r--spec/ruby/core/queue/empty_spec.rb6
-rw-r--r--spec/ruby/core/queue/enq_spec.rb6
-rw-r--r--spec/ruby/core/queue/length_spec.rb6
-rw-r--r--spec/ruby/core/queue/num_waiting_spec.rb6
-rw-r--r--spec/ruby/core/queue/pop_spec.rb6
-rw-r--r--spec/ruby/core/queue/push_spec.rb6
-rw-r--r--spec/ruby/core/queue/shift_spec.rb6
-rw-r--r--spec/ruby/core/queue/size_spec.rb6
-rw-r--r--spec/ruby/core/random/bytes_spec.rb21
-rw-r--r--spec/ruby/core/random/default_spec.rb2
-rw-r--r--spec/ruby/core/random/equal_value_spec.rb2
-rw-r--r--spec/ruby/core/random/fixtures/classes.rb15
-rw-r--r--spec/ruby/core/random/new_seed_spec.rb2
-rw-r--r--spec/ruby/core/random/new_spec.rb2
-rw-r--r--spec/ruby/core/random/rand_spec.rb31
-rw-r--r--spec/ruby/core/random/random_number_spec.rb10
-rw-r--r--spec/ruby/core/random/raw_seed_spec.rb4
-rw-r--r--spec/ruby/core/random/seed_spec.rb2
-rw-r--r--spec/ruby/core/random/shared/bytes.rb17
-rw-r--r--spec/ruby/core/random/shared/rand.rb9
-rw-r--r--spec/ruby/core/random/shared/urandom.rb6
-rw-r--r--spec/ruby/core/random/srand_spec.rb2
-rw-r--r--spec/ruby/core/random/urandom_spec.rb6
-rw-r--r--spec/ruby/core/range/begin_spec.rb6
-rw-r--r--spec/ruby/core/range/bsearch_spec.rb12
-rw-r--r--spec/ruby/core/range/case_compare_spec.rb31
-rw-r--r--spec/ruby/core/range/cover_spec.rb8
-rw-r--r--spec/ruby/core/range/dup_spec.rb2
-rw-r--r--spec/ruby/core/range/each_spec.rb10
-rw-r--r--spec/ruby/core/range/end_spec.rb6
-rw-r--r--spec/ruby/core/range/eql_spec.rb8
-rw-r--r--spec/ruby/core/range/equal_value_spec.rb8
-rw-r--r--spec/ruby/core/range/exclude_end_spec.rb2
-rw-r--r--spec/ruby/core/range/first_spec.rb14
-rw-r--r--spec/ruby/core/range/fixtures/classes.rb25
-rw-r--r--spec/ruby/core/range/hash_spec.rb2
-rw-r--r--spec/ruby/core/range/include_spec.rb10
-rw-r--r--spec/ruby/core/range/initialize_spec.rb20
-rw-r--r--spec/ruby/core/range/inspect_spec.rb22
-rw-r--r--spec/ruby/core/range/last_spec.rb14
-rw-r--r--spec/ruby/core/range/max_spec.rb6
-rw-r--r--spec/ruby/core/range/member_spec.rb10
-rw-r--r--spec/ruby/core/range/min_spec.rb2
-rw-r--r--spec/ruby/core/range/new_spec.rb61
-rw-r--r--spec/ruby/core/range/percent_spec.rb18
-rw-r--r--spec/ruby/core/range/range_spec.rb2
-rw-r--r--spec/ruby/core/range/shared/cover.rb66
-rw-r--r--spec/ruby/core/range/shared/cover_and_include.rb8
-rw-r--r--spec/ruby/core/range/shared/equal_value.rb2
-rw-r--r--spec/ruby/core/range/shared/include.rb6
-rw-r--r--spec/ruby/core/range/size_spec.rb2
-rw-r--r--spec/ruby/core/range/step_spec.rb110
-rw-r--r--spec/ruby/core/range/to_a_spec.rb4
-rw-r--r--spec/ruby/core/range/to_s_spec.rb22
-rw-r--r--spec/ruby/core/rational/abs_spec.rb4
-rw-r--r--spec/ruby/core/rational/ceil_spec.rb4
-rw-r--r--spec/ruby/core/rational/coerce_spec.rb4
-rw-r--r--spec/ruby/core/rational/comparison_spec.rb13
-rw-r--r--spec/ruby/core/rational/denominator_spec.rb4
-rw-r--r--spec/ruby/core/rational/div_spec.rb10
-rw-r--r--spec/ruby/core/rational/divide_spec.rb12
-rw-r--r--spec/ruby/core/rational/divmod_spec.rb8
-rw-r--r--spec/ruby/core/rational/equal_value_spec.rb10
-rw-r--r--spec/ruby/core/rational/exponent_spec.rb4
-rw-r--r--spec/ruby/core/rational/fdiv_spec.rb4
-rw-r--r--spec/ruby/core/rational/floor_spec.rb4
-rw-r--r--spec/ruby/core/rational/hash_spec.rb4
-rw-r--r--spec/ruby/core/rational/inspect_spec.rb4
-rw-r--r--spec/ruby/core/rational/integer_spec.rb7
-rw-r--r--spec/ruby/core/rational/magnitude_spec.rb4
-rw-r--r--spec/ruby/core/rational/marshal_dump_spec.rb2
-rw-r--r--spec/ruby/core/rational/minus_spec.rb6
-rw-r--r--spec/ruby/core/rational/modulo_spec.rb4
-rw-r--r--spec/ruby/core/rational/multiply_spec.rb12
-rw-r--r--spec/ruby/core/rational/numerator_spec.rb4
-rw-r--r--spec/ruby/core/rational/plus_spec.rb12
-rw-r--r--spec/ruby/core/rational/quo_spec.rb4
-rw-r--r--spec/ruby/core/rational/rational_spec.rb2
-rw-r--r--spec/ruby/core/rational/rationalize_spec.rb6
-rw-r--r--spec/ruby/core/rational/remainder_spec.rb4
-rw-r--r--spec/ruby/core/rational/round_spec.rb5
-rw-r--r--spec/ruby/core/rational/to_f_spec.rb4
-rw-r--r--spec/ruby/core/rational/to_i_spec.rb4
-rw-r--r--spec/ruby/core/rational/to_r_spec.rb8
-rw-r--r--spec/ruby/core/rational/to_s_spec.rb4
-rw-r--r--spec/ruby/core/rational/truncate_spec.rb4
-rw-r--r--spec/ruby/core/regexp/case_compare_spec.rb4
-rw-r--r--spec/ruby/core/regexp/casefold_spec.rb2
-rw-r--r--spec/ruby/core/regexp/compile_spec.rb15
-rw-r--r--spec/ruby/core/regexp/encoding_spec.rb10
-rw-r--r--spec/ruby/core/regexp/eql_spec.rb4
-rw-r--r--spec/ruby/core/regexp/equal_value_spec.rb4
-rw-r--r--spec/ruby/core/regexp/escape_spec.rb4
-rw-r--r--spec/ruby/core/regexp/fixed_encoding_spec.rb2
-rw-r--r--spec/ruby/core/regexp/hash_spec.rb2
-rw-r--r--spec/ruby/core/regexp/initialize_spec.rb6
-rw-r--r--spec/ruby/core/regexp/inspect_spec.rb2
-rw-r--r--spec/ruby/core/regexp/last_match_spec.rb2
-rw-r--r--spec/ruby/core/regexp/match_spec.rb86
-rw-r--r--spec/ruby/core/regexp/named_captures_spec.rb2
-rw-r--r--spec/ruby/core/regexp/names_spec.rb2
-rw-r--r--spec/ruby/core/regexp/new_spec.rb19
-rw-r--r--spec/ruby/core/regexp/options_spec.rb4
-rw-r--r--spec/ruby/core/regexp/quote_spec.rb4
-rw-r--r--spec/ruby/core/regexp/shared/new.rb505
-rw-r--r--spec/ruby/core/regexp/shared/new_ascii.rb464
-rw-r--r--spec/ruby/core/regexp/shared/new_ascii_8bit.rb553
-rw-r--r--spec/ruby/core/regexp/shared/quote.rb6
-rw-r--r--spec/ruby/core/regexp/source_spec.rb2
-rw-r--r--spec/ruby/core/regexp/to_s_spec.rb2
-rw-r--r--spec/ruby/core/regexp/try_convert_spec.rb2
-rw-r--r--spec/ruby/core/regexp/union_spec.rb30
-rw-r--r--spec/ruby/core/signal/fixtures/trap_all.rb15
-rw-r--r--spec/ruby/core/signal/list_spec.rb6
-rw-r--r--spec/ruby/core/signal/signame_spec.rb21
-rw-r--r--spec/ruby/core/signal/trap_spec.rb95
-rw-r--r--spec/ruby/core/sizedqueue/append_spec.rb11
-rw-r--r--spec/ruby/core/sizedqueue/clear_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/close_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/closed_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/deq_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/empty_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/enq_spec.rb11
-rw-r--r--spec/ruby/core/sizedqueue/length_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/max_spec.rb10
-rw-r--r--spec/ruby/core/sizedqueue/new_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/num_waiting_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/pop_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/push_spec.rb11
-rw-r--r--spec/ruby/core/sizedqueue/shift_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/size_spec.rb6
-rw-r--r--spec/ruby/core/string/allocate_spec.rb2
-rw-r--r--spec/ruby/core/string/append_spec.rb6
-rw-r--r--spec/ruby/core/string/ascii_only_spec.rb130
-rw-r--r--spec/ruby/core/string/b_spec.rb22
-rw-r--r--spec/ruby/core/string/bytes_spec.rb28
-rw-r--r--spec/ruby/core/string/bytesize_spec.rb52
-rw-r--r--spec/ruby/core/string/byteslice_spec.rb20
-rw-r--r--spec/ruby/core/string/capitalize_spec.rb155
-rw-r--r--spec/ruby/core/string/case_compare_spec.rb10
-rw-r--r--spec/ruby/core/string/casecmp_spec.rb120
-rw-r--r--spec/ruby/core/string/center_spec.rb88
-rw-r--r--spec/ruby/core/string/chars_spec.rb9
-rw-r--r--spec/ruby/core/string/chomp_spec.rb182
-rw-r--r--spec/ruby/core/string/chop_spec.rb72
-rw-r--r--spec/ruby/core/string/chr_spec.rb82
-rw-r--r--spec/ruby/core/string/clear_spec.rb60
-rw-r--r--spec/ruby/core/string/clone_spec.rb5
-rw-r--r--spec/ruby/core/string/codepoints_spec.rb26
-rw-r--r--spec/ruby/core/string/comparison_spec.rb4
-rw-r--r--spec/ruby/core/string/concat_spec.rb36
-rw-r--r--spec/ruby/core/string/count_spec.rb16
-rw-r--r--spec/ruby/core/string/crypt_spec.rb163
-rw-r--r--spec/ruby/core/string/delete_prefix_spec.rb20
-rw-r--r--spec/ruby/core/string/delete_spec.rb34
-rw-r--r--spec/ruby/core/string/delete_suffix_spec.rb20
-rw-r--r--spec/ruby/core/string/downcase_spec.rb165
-rw-r--r--spec/ruby/core/string/dump_spec.rb148
-rw-r--r--spec/ruby/core/string/dup_spec.rb10
-rw-r--r--spec/ruby/core/string/each_byte_spec.rb4
-rw-r--r--spec/ruby/core/string/each_char_spec.rb8
-rw-r--r--spec/ruby/core/string/each_codepoint_spec.rb14
-rw-r--r--spec/ruby/core/string/each_grapheme_cluster_spec.rb11
-rw-r--r--spec/ruby/core/string/each_line_spec.rb12
-rw-r--r--spec/ruby/core/string/element_reference_spec.rb6
-rw-r--r--spec/ruby/core/string/element_set_spec.rb458
-rw-r--r--spec/ruby/core/string/empty_spec.rb4
-rw-r--r--spec/ruby/core/string/encode_spec.rb240
-rw-r--r--spec/ruby/core/string/encoding_spec.rb370
-rw-r--r--spec/ruby/core/string/end_with_spec.rb36
-rw-r--r--spec/ruby/core/string/eql_spec.rb6
-rw-r--r--spec/ruby/core/string/equal_value_spec.rb10
-rw-r--r--spec/ruby/core/string/fixtures/classes.rb2
-rw-r--r--spec/ruby/core/string/force_encoding_spec.rb92
-rw-r--r--spec/ruby/core/string/freeze_spec.rb7
-rw-r--r--spec/ruby/core/string/getbyte_spec.rb8
-rw-r--r--spec/ruby/core/string/grapheme_clusters_spec.rb15
-rw-r--r--spec/ruby/core/string/gsub_spec.rb252
-rw-r--r--spec/ruby/core/string/hash_spec.rb4
-rw-r--r--spec/ruby/core/string/hex_spec.rb4
-rw-r--r--spec/ruby/core/string/include_spec.rb12
-rw-r--r--spec/ruby/core/string/index_spec.rb72
-rw-r--r--spec/ruby/core/string/initialize_spec.rb6
-rw-r--r--spec/ruby/core/string/insert_spec.rb64
-rw-r--r--spec/ruby/core/string/inspect_spec.rb28
-rw-r--r--spec/ruby/core/string/intern_spec.rb8
-rw-r--r--spec/ruby/core/string/length_spec.rb8
-rw-r--r--spec/ruby/core/string/lines_spec.rb22
-rw-r--r--spec/ruby/core/string/ljust_spec.rb86
-rw-r--r--spec/ruby/core/string/lstrip_spec.rb24
-rw-r--r--spec/ruby/core/string/match_spec.rb64
-rw-r--r--spec/ruby/core/string/modulo_spec.rb224
-rw-r--r--spec/ruby/core/string/multiply_spec.rb8
-rw-r--r--spec/ruby/core/string/new_spec.rb26
-rw-r--r--spec/ruby/core/string/next_spec.rb10
-rw-r--r--spec/ruby/core/string/oct_spec.rb4
-rw-r--r--spec/ruby/core/string/ord_spec.rb40
-rw-r--r--spec/ruby/core/string/partition_spec.rb8
-rw-r--r--spec/ruby/core/string/percent_spec.rb11
-rw-r--r--spec/ruby/core/string/plus_spec.rb24
-rw-r--r--spec/ruby/core/string/prepend_spec.rb56
-rw-r--r--spec/ruby/core/string/replace_spec.rb6
-rw-r--r--spec/ruby/core/string/reverse_spec.rb38
-rw-r--r--spec/ruby/core/string/rindex_spec.rb44
-rw-r--r--spec/ruby/core/string/rjust_spec.rb86
-rw-r--r--spec/ruby/core/string/rpartition_spec.rb8
-rw-r--r--spec/ruby/core/string/rstrip_spec.rb24
-rw-r--r--spec/ruby/core/string/scan_spec.rb69
-rw-r--r--spec/ruby/core/string/scrub_spec.rb6
-rw-r--r--spec/ruby/core/string/setbyte_spec.rb14
-rw-r--r--spec/ruby/core/string/shared/chars.rb82
-rw-r--r--spec/ruby/core/string/shared/codepoints.rb18
-rw-r--r--spec/ruby/core/string/shared/concat.rb62
-rw-r--r--spec/ruby/core/string/shared/each_char_without_block.rb4
-rw-r--r--spec/ruby/core/string/shared/each_line.rb66
-rw-r--r--spec/ruby/core/string/shared/encode.rb48
-rw-r--r--spec/ruby/core/string/shared/eql.rb4
-rw-r--r--spec/ruby/core/string/shared/equal_value.rb6
-rw-r--r--spec/ruby/core/string/shared/grapheme_clusters.rb16
-rw-r--r--spec/ruby/core/string/shared/length.rb22
-rw-r--r--spec/ruby/core/string/shared/replace.rb62
-rw-r--r--spec/ruby/core/string/shared/slice.rb196
-rw-r--r--spec/ruby/core/string/shared/succ.rb14
-rw-r--r--spec/ruby/core/string/shared/to_s.rb8
-rw-r--r--spec/ruby/core/string/size_spec.rb8
-rw-r--r--spec/ruby/core/string/slice_spec.rb250
-rw-r--r--spec/ruby/core/string/split_spec.rb166
-rw-r--r--spec/ruby/core/string/squeeze_spec.rb36
-rw-r--r--spec/ruby/core/string/start_with_spec.rb61
-rw-r--r--spec/ruby/core/string/string_spec.rb2
-rw-r--r--spec/ruby/core/string/strip_spec.rb24
-rw-r--r--spec/ruby/core/string/sub_spec.rb184
-rw-r--r--spec/ruby/core/string/succ_spec.rb10
-rw-r--r--spec/ruby/core/string/sum_spec.rb4
-rw-r--r--spec/ruby/core/string/swapcase_spec.rb143
-rw-r--r--spec/ruby/core/string/to_c_spec.rb2
-rw-r--r--spec/ruby/core/string/to_f_spec.rb5
-rw-r--r--spec/ruby/core/string/to_i_spec.rb10
-rw-r--r--spec/ruby/core/string/to_r_spec.rb4
-rw-r--r--spec/ruby/core/string/to_s_spec.rb8
-rw-r--r--spec/ruby/core/string/to_str_spec.rb8
-rw-r--r--spec/ruby/core/string/to_sym_spec.rb8
-rw-r--r--spec/ruby/core/string/tr_s_spec.rb98
-rw-r--r--spec/ruby/core/string/tr_spec.rb74
-rw-r--r--spec/ruby/core/string/try_convert_spec.rb8
-rw-r--r--spec/ruby/core/string/uminus_spec.rb79
-rw-r--r--spec/ruby/core/string/undump_spec.rb453
-rw-r--r--spec/ruby/core/string/unicode_normalize_spec.rb10
-rw-r--r--spec/ruby/core/string/unicode_normalized_spec.rb6
-rw-r--r--spec/ruby/core/string/unpack/a_spec.rb17
-rw-r--r--spec/ruby/core/string/unpack/at_spec.rb10
-rw-r--r--spec/ruby/core/string/unpack/b_spec.rb11
-rw-r--r--spec/ruby/core/string/unpack/c_spec.rb10
-rw-r--r--spec/ruby/core/string/unpack/comment_spec.rb6
-rw-r--r--spec/ruby/core/string/unpack/d_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/e_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/f_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/g_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/h_spec.rb19
-rw-r--r--spec/ruby/core/string/unpack/i_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/j_spec.rb427
-rw-r--r--spec/ruby/core/string/unpack/l_spec.rb24
-rw-r--r--spec/ruby/core/string/unpack/m_spec.rb11
-rw-r--r--spec/ruby/core/string/unpack/n_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/p_spec.rb53
-rw-r--r--spec/ruby/core/string/unpack/percent_spec.rb4
-rw-r--r--spec/ruby/core/string/unpack/q_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/s_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/shared/basic.rb8
-rw-r--r--spec/ruby/core/string/unpack/shared/float.rb2
-rw-r--r--spec/ruby/core/string/unpack/shared/integer.rb2
-rw-r--r--spec/ruby/core/string/unpack/shared/taint.rb83
-rw-r--r--spec/ruby/core/string/unpack/u_spec.rb21
-rw-r--r--spec/ruby/core/string/unpack/v_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/w_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/x_spec.rb14
-rw-r--r--spec/ruby/core/string/unpack/z_spec.rb12
-rw-r--r--spec/ruby/core/string/unpack1_spec.rb16
-rw-r--r--spec/ruby/core/string/upcase_spec.rb150
-rw-r--r--spec/ruby/core/string/uplus_spec.rb32
-rw-r--r--spec/ruby/core/string/upto_spec.rb12
-rw-r--r--spec/ruby/core/string/valid_encoding_spec.rb238
-rw-r--r--spec/ruby/core/struct/clone_spec.rb7
-rw-r--r--spec/ruby/core/struct/dig_spec.rb64
-rw-r--r--spec/ruby/core/struct/dup_spec.rb7
-rw-r--r--spec/ruby/core/struct/each_pair_spec.rb8
-rw-r--r--spec/ruby/core/struct/each_spec.rb8
-rw-r--r--spec/ruby/core/struct/element_reference_spec.rb16
-rw-r--r--spec/ruby/core/struct/element_set_spec.rb12
-rw-r--r--spec/ruby/core/struct/eql_spec.rb10
-rw-r--r--spec/ruby/core/struct/equal_value_spec.rb8
-rw-r--r--spec/ruby/core/struct/filter_spec.rb12
-rw-r--r--spec/ruby/core/struct/hash_spec.rb6
-rw-r--r--spec/ruby/core/struct/initialize_spec.rb4
-rw-r--r--spec/ruby/core/struct/inspect_spec.rb13
-rw-r--r--spec/ruby/core/struct/instance_variable_get_spec.rb16
-rw-r--r--spec/ruby/core/struct/instance_variables_spec.rb4
-rw-r--r--spec/ruby/core/struct/length_spec.rb6
-rw-r--r--spec/ruby/core/struct/members_spec.rb6
-rw-r--r--spec/ruby/core/struct/new_spec.rb113
-rw-r--r--spec/ruby/core/struct/select_spec.rb30
-rw-r--r--spec/ruby/core/struct/shared/dup.rb9
-rw-r--r--spec/ruby/core/struct/shared/equal_value.rb7
-rw-r--r--spec/ruby/core/struct/shared/select.rb26
-rw-r--r--spec/ruby/core/struct/size_spec.rb6
-rw-r--r--spec/ruby/core/struct/struct_spec.rb6
-rw-r--r--spec/ruby/core/struct/tms/cstime_spec.rb9
-rw-r--r--spec/ruby/core/struct/tms/cutime_spec.rb9
-rw-r--r--spec/ruby/core/struct/tms/element_reference_spec.rb5
-rw-r--r--spec/ruby/core/struct/tms/members_spec.rb5
-rw-r--r--spec/ruby/core/struct/tms/new_spec.rb5
-rw-r--r--spec/ruby/core/struct/tms/stime_spec.rb9
-rw-r--r--spec/ruby/core/struct/tms/utime_spec.rb9
-rw-r--r--spec/ruby/core/struct/to_a_spec.rb6
-rw-r--r--spec/ruby/core/struct/to_h_spec.rb47
-rw-r--r--spec/ruby/core/struct/to_s_spec.rb8
-rw-r--r--spec/ruby/core/struct/values_at_spec.rb6
-rw-r--r--spec/ruby/core/struct/values_spec.rb4
-rw-r--r--spec/ruby/core/symbol/all_symbols_spec.rb2
-rw-r--r--spec/ruby/core/symbol/capitalize_spec.rb23
-rw-r--r--spec/ruby/core/symbol/case_compare_spec.rb2
-rw-r--r--spec/ruby/core/symbol/casecmp_spec.rb138
-rw-r--r--spec/ruby/core/symbol/comparison_spec.rb2
-rw-r--r--spec/ruby/core/symbol/downcase_spec.rb16
-rw-r--r--spec/ruby/core/symbol/dup_spec.rb10
-rw-r--r--spec/ruby/core/symbol/element_reference_spec.rb6
-rw-r--r--spec/ruby/core/symbol/empty_spec.rb2
-rw-r--r--spec/ruby/core/symbol/encoding_spec.rb2
-rw-r--r--spec/ruby/core/symbol/equal_value_spec.rb2
-rw-r--r--spec/ruby/core/symbol/id2name_spec.rb6
-rw-r--r--spec/ruby/core/symbol/inspect_spec.rb2
-rw-r--r--spec/ruby/core/symbol/intern_spec.rb2
-rw-r--r--spec/ruby/core/symbol/length_spec.rb4
-rw-r--r--spec/ruby/core/symbol/match_spec.rb66
-rw-r--r--spec/ruby/core/symbol/next_spec.rb4
-rw-r--r--spec/ruby/core/symbol/shared/slice.rb50
-rw-r--r--spec/ruby/core/symbol/shared/succ.rb2
-rw-r--r--spec/ruby/core/symbol/size_spec.rb4
-rw-r--r--spec/ruby/core/symbol/slice_spec.rb6
-rw-r--r--spec/ruby/core/symbol/succ_spec.rb4
-rw-r--r--spec/ruby/core/symbol/swapcase_spec.rb20
-rw-r--r--spec/ruby/core/symbol/symbol_spec.rb6
-rw-r--r--spec/ruby/core/symbol/to_proc_spec.rb20
-rw-r--r--spec/ruby/core/symbol/to_s_spec.rb6
-rw-r--r--spec/ruby/core/symbol/to_sym_spec.rb2
-rw-r--r--spec/ruby/core/symbol/upcase_spec.rb16
-rw-r--r--spec/ruby/core/systemexit/initialize_spec.rb3
-rw-r--r--spec/ruby/core/systemexit/success_spec.rb2
-rw-r--r--spec/ruby/core/thread/abort_on_exception_spec.rb6
-rw-r--r--spec/ruby/core/thread/add_trace_func_spec.rb2
-rw-r--r--spec/ruby/core/thread/alive_spec.rb4
-rw-r--r--spec/ruby/core/thread/allocate_spec.rb4
-rw-r--r--spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb53
-rw-r--r--spec/ruby/core/thread/backtrace/location/base_label_spec.rb14
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/absolute_path.rb4
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/absolute_path_method_added.rb10
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/classes.rb18
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/locations_in_main.rb5
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/locations_in_required.rb3
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/main.rb4
-rw-r--r--spec/ruby/core/thread/backtrace/location/inspect_spec.rb4
-rw-r--r--spec/ruby/core/thread/backtrace/location/label_spec.rb21
-rw-r--r--spec/ruby/core/thread/backtrace/location/lineno_spec.rb4
-rw-r--r--spec/ruby/core/thread/backtrace/location/path_spec.rb10
-rw-r--r--spec/ruby/core/thread/backtrace/location/to_s_spec.rb4
-rw-r--r--spec/ruby/core/thread/backtrace_locations_spec.rb33
-rw-r--r--spec/ruby/core/thread/backtrace_spec.rb10
-rw-r--r--spec/ruby/core/thread/current_spec.rb20
-rw-r--r--spec/ruby/core/thread/element_reference_spec.rb8
-rw-r--r--spec/ruby/core/thread/element_set_spec.rb12
-rw-r--r--spec/ruby/core/thread/exclusive_spec.rb33
-rw-r--r--spec/ruby/core/thread/exit_spec.rb6
-rw-r--r--spec/ruby/core/thread/fetch_spec.rb38
-rw-r--r--spec/ruby/core/thread/fixtures/classes.rb12
-rw-r--r--spec/ruby/core/thread/fork_spec.rb6
-rw-r--r--spec/ruby/core/thread/group_spec.rb4
-rw-r--r--spec/ruby/core/thread/initialize_spec.rb6
-rw-r--r--spec/ruby/core/thread/inspect_spec.rb44
-rw-r--r--spec/ruby/core/thread/join_spec.rb24
-rw-r--r--spec/ruby/core/thread/key_spec.rb8
-rw-r--r--spec/ruby/core/thread/keys_spec.rb4
-rw-r--r--spec/ruby/core/thread/kill_spec.rb36
-rw-r--r--spec/ruby/core/thread/list_spec.rb29
-rw-r--r--spec/ruby/core/thread/main_spec.rb4
-rw-r--r--spec/ruby/core/thread/name_spec.rb106
-rw-r--r--spec/ruby/core/thread/new_spec.rb43
-rw-r--r--spec/ruby/core/thread/pass_spec.rb4
-rw-r--r--spec/ruby/core/thread/priority_spec.rb26
-rw-r--r--spec/ruby/core/thread/raise_spec.rb53
-rw-r--r--spec/ruby/core/thread/report_on_exception_spec.rb186
-rw-r--r--spec/ruby/core/thread/run_spec.rb7
-rw-r--r--spec/ruby/core/thread/set_trace_func_spec.rb2
-rw-r--r--spec/ruby/core/thread/shared/exit.rb30
-rw-r--r--spec/ruby/core/thread/shared/start.rb2
-rw-r--r--spec/ruby/core/thread/shared/to_s.rb53
-rw-r--r--spec/ruby/core/thread/shared/wakeup.rb2
-rw-r--r--spec/ruby/core/thread/start_spec.rb6
-rw-r--r--spec/ruby/core/thread/status_spec.rb4
-rw-r--r--spec/ruby/core/thread/stop_spec.rb4
-rw-r--r--spec/ruby/core/thread/terminate_spec.rb6
-rw-r--r--spec/ruby/core/thread/thread_variable_get_spec.rb2
-rw-r--r--spec/ruby/core/thread/thread_variable_set_spec.rb2
-rw-r--r--spec/ruby/core/thread/thread_variable_spec.rb2
-rw-r--r--spec/ruby/core/thread/thread_variables_spec.rb2
-rw-r--r--spec/ruby/core/thread/to_s_spec.rb8
-rw-r--r--spec/ruby/core/thread/value_spec.rb16
-rw-r--r--spec/ruby/core/thread/wakeup_spec.rb6
-rw-r--r--spec/ruby/core/threadgroup/add_spec.rb47
-rw-r--r--spec/ruby/core/threadgroup/default_spec.rb2
-rw-r--r--spec/ruby/core/threadgroup/enclose_spec.rb13
-rw-r--r--spec/ruby/core/threadgroup/enclosed_spec.rb2
-rw-r--r--spec/ruby/core/threadgroup/fixtures/classes.rb6
-rw-r--r--spec/ruby/core/threadgroup/list_spec.rb13
-rw-r--r--spec/ruby/core/time/_dump_spec.rb3
-rw-r--r--spec/ruby/core/time/_load_spec.rb14
-rw-r--r--spec/ruby/core/time/asctime_spec.rb6
-rw-r--r--spec/ruby/core/time/at_spec.rb87
-rw-r--r--spec/ruby/core/time/ceil_spec.rb45
-rw-r--r--spec/ruby/core/time/comparison_spec.rb12
-rw-r--r--spec/ruby/core/time/ctime_spec.rb6
-rw-r--r--spec/ruby/core/time/day_spec.rb6
-rw-r--r--spec/ruby/core/time/dst_spec.rb6
-rw-r--r--spec/ruby/core/time/dup_spec.rb2
-rw-r--r--spec/ruby/core/time/eql_spec.rb2
-rw-r--r--spec/ruby/core/time/fixtures/classes.rb94
-rw-r--r--spec/ruby/core/time/floor_spec.rb37
-rw-r--r--spec/ruby/core/time/friday_spec.rb2
-rw-r--r--spec/ruby/core/time/getgm_spec.rb6
-rw-r--r--spec/ruby/core/time/getlocal_spec.rb81
-rw-r--r--spec/ruby/core/time/getutc_spec.rb6
-rw-r--r--spec/ruby/core/time/gm_spec.rb14
-rw-r--r--spec/ruby/core/time/gmt_offset_spec.rb6
-rw-r--r--spec/ruby/core/time/gmt_spec.rb2
-rw-r--r--spec/ruby/core/time/gmtime_spec.rb6
-rw-r--r--spec/ruby/core/time/gmtoff_spec.rb6
-rw-r--r--spec/ruby/core/time/hash_spec.rb2
-rw-r--r--spec/ruby/core/time/hour_spec.rb2
-rw-r--r--spec/ruby/core/time/inspect_spec.rb4
-rw-r--r--spec/ruby/core/time/isdst_spec.rb6
-rw-r--r--spec/ruby/core/time/local_spec.rb16
-rw-r--r--spec/ruby/core/time/localtime_spec.rb14
-rw-r--r--spec/ruby/core/time/mday_spec.rb6
-rw-r--r--spec/ruby/core/time/min_spec.rb2
-rw-r--r--spec/ruby/core/time/minus_spec.rb34
-rw-r--r--spec/ruby/core/time/mktime_spec.rb16
-rw-r--r--spec/ruby/core/time/mon_spec.rb6
-rw-r--r--spec/ruby/core/time/monday_spec.rb2
-rw-r--r--spec/ruby/core/time/month_spec.rb6
-rw-r--r--spec/ruby/core/time/new_spec.rb266
-rw-r--r--spec/ruby/core/time/now_spec.rb6
-rw-r--r--spec/ruby/core/time/nsec_spec.rb6
-rw-r--r--spec/ruby/core/time/plus_spec.rb36
-rw-r--r--spec/ruby/core/time/round_spec.rb2
-rw-r--r--spec/ruby/core/time/saturday_spec.rb2
-rw-r--r--spec/ruby/core/time/sec_spec.rb2
-rw-r--r--spec/ruby/core/time/shared/gm.rb41
-rw-r--r--spec/ruby/core/time/shared/gmt_offset.rb6
-rw-r--r--spec/ruby/core/time/shared/gmtime.rb2
-rw-r--r--spec/ruby/core/time/shared/inspect.rb6
-rw-r--r--spec/ruby/core/time/shared/now.rb19
-rw-r--r--spec/ruby/core/time/shared/time_params.rb30
-rw-r--r--spec/ruby/core/time/strftime_spec.rb16
-rw-r--r--spec/ruby/core/time/subsec_spec.rb2
-rw-r--r--spec/ruby/core/time/succ_spec.rb34
-rw-r--r--spec/ruby/core/time/sunday_spec.rb2
-rw-r--r--spec/ruby/core/time/thursday_spec.rb2
-rw-r--r--spec/ruby/core/time/time_spec.rb2
-rw-r--r--spec/ruby/core/time/to_a_spec.rb2
-rw-r--r--spec/ruby/core/time/to_f_spec.rb2
-rw-r--r--spec/ruby/core/time/to_i_spec.rb6
-rw-r--r--spec/ruby/core/time/to_r_spec.rb2
-rw-r--r--spec/ruby/core/time/to_s_spec.rb4
-rw-r--r--spec/ruby/core/time/tuesday_spec.rb2
-rw-r--r--spec/ruby/core/time/tv_nsec_spec.rb2
-rw-r--r--spec/ruby/core/time/tv_sec_spec.rb6
-rw-r--r--spec/ruby/core/time/tv_usec_spec.rb2
-rw-r--r--spec/ruby/core/time/usec_spec.rb6
-rw-r--r--spec/ruby/core/time/utc_offset_spec.rb6
-rw-r--r--spec/ruby/core/time/utc_spec.rb18
-rw-r--r--spec/ruby/core/time/wday_spec.rb2
-rw-r--r--spec/ruby/core/time/wednesday_spec.rb2
-rw-r--r--spec/ruby/core/time/yday_spec.rb2
-rw-r--r--spec/ruby/core/time/year_spec.rb2
-rw-r--r--spec/ruby/core/time/zone_spec.rb4
-rw-r--r--spec/ruby/core/tracepoint/binding_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/callee_id_spec.rb27
-rw-r--r--spec/ruby/core/tracepoint/defined_class_spec.rb4
-rw-r--r--spec/ruby/core/tracepoint/disable_spec.rb62
-rw-r--r--spec/ruby/core/tracepoint/enable_spec.rb460
-rw-r--r--spec/ruby/core/tracepoint/enabled_spec.rb8
-rw-r--r--spec/ruby/core/tracepoint/eval_script_spec.rb24
-rw-r--r--spec/ruby/core/tracepoint/event_spec.rb4
-rw-r--r--spec/ruby/core/tracepoint/inspect_spec.rb24
-rw-r--r--spec/ruby/core/tracepoint/lineno_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/method_id_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/new_spec.rb23
-rw-r--r--spec/ruby/core/tracepoint/parameters_spec.rb23
-rw-r--r--spec/ruby/core/tracepoint/path_spec.rb4
-rw-r--r--spec/ruby/core/tracepoint/raised_exception_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/return_value_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/self_spec.rb12
-rw-r--r--spec/ruby/core/tracepoint/trace_spec.rb6
-rw-r--r--spec/ruby/core/true/and_spec.rb2
-rw-r--r--spec/ruby/core/true/dup_spec.rb10
-rw-r--r--spec/ruby/core/true/inspect_spec.rb2
-rw-r--r--spec/ruby/core/true/or_spec.rb2
-rw-r--r--spec/ruby/core/true/to_s_spec.rb12
-rw-r--r--spec/ruby/core/true/trueclass_spec.rb6
-rw-r--r--spec/ruby/core/true/xor_spec.rb2
-rw-r--r--spec/ruby/core/unboundmethod/arity_spec.rb2
-rw-r--r--spec/ruby/core/unboundmethod/bind_call_spec.rb52
-rw-r--r--spec/ruby/core/unboundmethod/bind_spec.rb20
-rw-r--r--spec/ruby/core/unboundmethod/clone_spec.rb4
-rw-r--r--spec/ruby/core/unboundmethod/eql_spec.rb2
-rw-r--r--spec/ruby/core/unboundmethod/equal_value_spec.rb4
-rw-r--r--spec/ruby/core/unboundmethod/fixtures/classes.rb1
-rw-r--r--spec/ruby/core/unboundmethod/hash_spec.rb6
-rw-r--r--spec/ruby/core/unboundmethod/inspect_spec.rb8
-rw-r--r--spec/ruby/core/unboundmethod/name_spec.rb4
-rw-r--r--spec/ruby/core/unboundmethod/original_name_spec.rb22
-rw-r--r--spec/ruby/core/unboundmethod/owner_spec.rb4
-rw-r--r--spec/ruby/core/unboundmethod/parameters_spec.rb2
-rw-r--r--spec/ruby/core/unboundmethod/shared/to_s.rb4
-rw-r--r--spec/ruby/core/unboundmethod/source_location_spec.rb6
-rw-r--r--spec/ruby/core/unboundmethod/super_method_spec.rb4
-rw-r--r--spec/ruby/core/unboundmethod/to_s_spec.rb8
-rw-r--r--spec/ruby/core/warning/warn_spec.rb82
-rw-r--r--spec/ruby/default.mspec23
-rw-r--r--spec/ruby/fixtures/class.rb4
-rw-r--r--spec/ruby/fixtures/code/load_fixture_and__FILE__.rb1
-rw-r--r--spec/ruby/fixtures/code/recursive_require_fixture.rb2
-rw-r--r--spec/ruby/fixtures/code/wrap_fixture.rb8
-rw-r--r--spec/ruby/fixtures/rational.rb3
-rw-r--r--spec/ruby/language/BEGIN_spec.rb4
-rw-r--r--spec/ruby/language/alias_spec.rb38
-rw-r--r--spec/ruby/language/and_spec.rb2
-rw-r--r--spec/ruby/language/array_spec.rb11
-rw-r--r--spec/ruby/language/block_spec.rb200
-rw-r--r--spec/ruby/language/break_spec.rb20
-rw-r--r--spec/ruby/language/case_spec.rb258
-rw-r--r--spec/ruby/language/class_spec.rb54
-rw-r--r--spec/ruby/language/class_variable_spec.rb8
-rw-r--r--spec/ruby/language/constants_spec.rb167
-rw-r--r--spec/ruby/language/def_spec.rb150
-rw-r--r--spec/ruby/language/defined_spec.rb46
-rw-r--r--spec/ruby/language/encoding_spec.rb16
-rw-r--r--spec/ruby/language/ensure_spec.rb54
-rw-r--r--spec/ruby/language/execution_spec.rb2
-rw-r--r--spec/ruby/language/file_spec.rb8
-rw-r--r--spec/ruby/language/fixtures/array.rb21
-rw-r--r--spec/ruby/language/fixtures/block.rb4
-rw-r--r--spec/ruby/language/fixtures/break.rb10
-rw-r--r--spec/ruby/language/fixtures/break_lambda_toplevel.rb2
-rw-r--r--spec/ruby/language/fixtures/break_lambda_toplevel_block.rb2
-rw-r--r--spec/ruby/language/fixtures/break_lambda_toplevel_method.rb2
-rw-r--r--spec/ruby/language/fixtures/bytes_magic_comment.rb2
-rw-r--r--spec/ruby/language/fixtures/case_magic_comment.rb2
-rw-r--r--spec/ruby/language/fixtures/def.rb6
-rw-r--r--spec/ruby/language/fixtures/defined.rb5
-rw-r--r--spec/ruby/language/fixtures/emacs_magic_comment.rb2
-rw-r--r--spec/ruby/language/fixtures/ensure.rb44
-rw-r--r--spec/ruby/language/fixtures/for_scope.rb15
-rw-r--r--spec/ruby/language/fixtures/hash_strings_ascii8bit.rb7
-rw-r--r--spec/ruby/language/fixtures/hash_strings_binary.rb7
-rw-r--r--spec/ruby/language/fixtures/magic_comment.rb2
-rw-r--r--spec/ruby/language/fixtures/metaclass.rb1
-rw-r--r--spec/ruby/language/fixtures/no_magic_comment.rb1
-rw-r--r--spec/ruby/language/fixtures/print_magic_comment_result_at_exit.rb3
-rw-r--r--spec/ruby/language/fixtures/rescue.rb4
-rw-r--r--spec/ruby/language/fixtures/second_line_magic_comment.rb3
-rw-r--r--spec/ruby/language/fixtures/second_token_magic_comment.rb2
-rw-r--r--spec/ruby/language/fixtures/send.rb3
-rwxr-xr-xspec/ruby/language/fixtures/shebang_magic_comment.rb3
-rw-r--r--spec/ruby/language/fixtures/super.rb40
-rw-r--r--spec/ruby/language/fixtures/utf16-be-nobom.rbbin68 -> 0 bytes-rw-r--r--spec/ruby/language/fixtures/utf16-le-nobom.rbbin69 -> 0 bytes-rw-r--r--spec/ruby/language/fixtures/utf8-bom.rb2
-rw-r--r--spec/ruby/language/fixtures/utf8-nobom.rb2
-rw-r--r--spec/ruby/language/fixtures/vim_magic_comment.rb2
-rw-r--r--spec/ruby/language/fixtures/yield.rb4
-rw-r--r--spec/ruby/language/for_spec.rb17
-rw-r--r--spec/ruby/language/hash_spec.rb33
-rw-r--r--spec/ruby/language/heredoc_spec.rb66
-rw-r--r--spec/ruby/language/if_spec.rb32
-rw-r--r--spec/ruby/language/lambda_spec.rb120
-rw-r--r--spec/ruby/language/line_spec.rb8
-rw-r--r--spec/ruby/language/loop_spec.rb4
-rw-r--r--spec/ruby/language/magic_comment_spec.rb110
-rw-r--r--spec/ruby/language/match_spec.rb11
-rw-r--r--spec/ruby/language/metaclass_spec.rb18
-rw-r--r--spec/ruby/language/method_spec.rb471
-rw-r--r--spec/ruby/language/module_spec.rb16
-rw-r--r--spec/ruby/language/next_spec.rb16
-rw-r--r--spec/ruby/language/not_spec.rb2
-rw-r--r--spec/ruby/language/numbers_spec.rb8
-rw-r--r--spec/ruby/language/optional_assignments_spec.rb137
-rw-r--r--spec/ruby/language/or_spec.rb14
-rw-r--r--spec/ruby/language/order_spec.rb2
-rw-r--r--spec/ruby/language/precedence_spec.rb39
-rw-r--r--spec/ruby/language/predefined/data_spec.rb21
-rw-r--r--spec/ruby/language/predefined/fixtures/data2.rb3
-rw-r--r--spec/ruby/language/predefined/fixtures/data3.rb3
-rw-r--r--spec/ruby/language/predefined/fixtures/data_offset.rb12
-rw-r--r--spec/ruby/language/predefined/fixtures/empty_data.rb3
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic.rb4
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic_required.rb2
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_id.rb4
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_id_required.rb1
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_required_before.rb2
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_values.rb9
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_variables.rb4
-rw-r--r--spec/ruby/language/predefined/fixtures/toplevel_binding_variables_required.rb2
-rw-r--r--spec/ruby/language/predefined/toplevel_binding_spec.rb34
-rw-r--r--spec/ruby/language/predefined_spec.rb370
-rw-r--r--spec/ruby/language/private_spec.rb18
-rw-r--r--spec/ruby/language/proc_spec.rb4
-rw-r--r--spec/ruby/language/range_spec.rb19
-rw-r--r--spec/ruby/language/redo_spec.rb6
-rw-r--r--spec/ruby/language/regexp/anchors_spec.rb4
-rw-r--r--spec/ruby/language/regexp/back-references_spec.rb11
-rw-r--r--spec/ruby/language/regexp/character_classes_spec.rb36
-rw-r--r--spec/ruby/language/regexp/encoding_spec.rb28
-rw-r--r--spec/ruby/language/regexp/escapes_spec.rb12
-rw-r--r--spec/ruby/language/regexp/grouping_spec.rb6
-rw-r--r--spec/ruby/language/regexp/interpolation_spec.rb8
-rw-r--r--spec/ruby/language/regexp/modifiers_spec.rb22
-rw-r--r--spec/ruby/language/regexp/repetition_spec.rb21
-rw-r--r--spec/ruby/language/regexp_spec.rb41
-rw-r--r--spec/ruby/language/rescue_spec.rb117
-rw-r--r--spec/ruby/language/retry_spec.rb4
-rw-r--r--spec/ruby/language/return_spec.rb58
-rw-r--r--spec/ruby/language/safe_navigator_spec.rb144
-rw-r--r--spec/ruby/language/safe_spec.rb138
-rw-r--r--spec/ruby/language/send_spec.rb75
-rw-r--r--spec/ruby/language/singleton_class_spec.rb22
-rw-r--r--spec/ruby/language/source_encoding_spec.rb61
-rw-r--r--spec/ruby/language/string_spec.rb117
-rw-r--r--spec/ruby/language/super_spec.rb189
-rw-r--r--spec/ruby/language/symbol_spec.rb4
-rw-r--r--spec/ruby/language/throw_spec.rb10
-rw-r--r--spec/ruby/language/undef_spec.rb14
-rw-r--r--spec/ruby/language/unless_spec.rb2
-rw-r--r--spec/ruby/language/until_spec.rb4
-rw-r--r--spec/ruby/language/variables_spec.rb56
-rw-r--r--spec/ruby/language/while_spec.rb4
-rw-r--r--spec/ruby/language/yield_spec.rb56
-rw-r--r--spec/ruby/library/English/English_spec.rb18
-rw-r--r--spec/ruby/library/abbrev/abbrev_spec.rb6
-rw-r--r--spec/ruby/library/base64/decode64_spec.rb18
-rw-r--r--spec/ruby/library/base64/encode64_spec.rb11
-rw-r--r--spec/ruby/library/base64/strict_decode64_spec.rb41
-rw-r--r--spec/ruby/library/base64/strict_encode64_spec.rb19
-rw-r--r--spec/ruby/library/base64/urlsafe_decode64_spec.rb14
-rw-r--r--spec/ruby/library/base64/urlsafe_encode64_spec.rb10
-rw-r--r--spec/ruby/library/bigdecimal/BigDecimal_spec.rb257
-rw-r--r--spec/ruby/library/bigdecimal/abs_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/add_spec.rb26
-rw-r--r--spec/ruby/library/bigdecimal/case_compare_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/ceil_spec.rb8
-rw-r--r--spec/ruby/library/bigdecimal/clone_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/coerce_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/comparison_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/constants_spec.rb72
-rw-r--r--spec/ruby/library/bigdecimal/div_spec.rb40
-rw-r--r--spec/ruby/library/bigdecimal/divide_spec.rb14
-rw-r--r--spec/ruby/library/bigdecimal/divmod_spec.rb22
-rw-r--r--spec/ruby/library/bigdecimal/double_fig_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/dup_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/eql_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/equal_value_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/exponent_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/finite_spec.rb3
-rw-r--r--spec/ruby/library/bigdecimal/fix_spec.rb4
-rw-r--r--spec/ruby/library/bigdecimal/floor_spec.rb8
-rw-r--r--spec/ruby/library/bigdecimal/frac_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/gt_spec.rb30
-rw-r--r--spec/ruby/library/bigdecimal/gte_spec.rb30
-rw-r--r--spec/ruby/library/bigdecimal/hash_spec.rb30
-rw-r--r--spec/ruby/library/bigdecimal/infinite_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/inspect_spec.rb45
-rw-r--r--spec/ruby/library/bigdecimal/limit_spec.rb14
-rw-r--r--spec/ruby/library/bigdecimal/lt_spec.rb30
-rw-r--r--spec/ruby/library/bigdecimal/lte_spec.rb30
-rw-r--r--spec/ruby/library/bigdecimal/minus_spec.rb10
-rw-r--r--spec/ruby/library/bigdecimal/mode_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/modulo_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/mult_spec.rb14
-rw-r--r--spec/ruby/library/bigdecimal/multiply_spec.rb19
-rw-r--r--spec/ruby/library/bigdecimal/nan_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/new_spec.rb109
-rw-r--r--spec/ruby/library/bigdecimal/nonzero_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/plus_spec.rb9
-rw-r--r--spec/ruby/library/bigdecimal/power_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/precs_spec.rb3
-rw-r--r--spec/ruby/library/bigdecimal/quo_spec.rb5
-rw-r--r--spec/ruby/library/bigdecimal/remainder_spec.rb16
-rw-r--r--spec/ruby/library/bigdecimal/round_spec.rb256
-rw-r--r--spec/ruby/library/bigdecimal/shared/clone.rb24
-rw-r--r--spec/ruby/library/bigdecimal/shared/eql.rb4
-rw-r--r--spec/ruby/library/bigdecimal/shared/modulo.rb23
-rw-r--r--spec/ruby/library/bigdecimal/shared/quo.rb8
-rw-r--r--spec/ruby/library/bigdecimal/shared/to_int.rb4
-rw-r--r--spec/ruby/library/bigdecimal/sign_spec.rb3
-rw-r--r--spec/ruby/library/bigdecimal/split_spec.rb4
-rw-r--r--spec/ruby/library/bigdecimal/sqrt_spec.rb24
-rw-r--r--spec/ruby/library/bigdecimal/sub_spec.rb19
-rw-r--r--spec/ruby/library/bigdecimal/to_d_spec.rb10
-rw-r--r--spec/ruby/library/bigdecimal/to_f_spec.rb3
-rw-r--r--spec/ruby/library/bigdecimal/to_i_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/to_int_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/to_r_spec.rb4
-rw-r--r--spec/ruby/library/bigdecimal/to_s_spec.rb47
-rw-r--r--spec/ruby/library/bigdecimal/truncate_spec.rb8
-rw-r--r--spec/ruby/library/bigdecimal/uminus_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/uplus_spec.rb5
-rw-r--r--spec/ruby/library/bigdecimal/util_spec.rb42
-rw-r--r--spec/ruby/library/bigdecimal/ver_spec.rb11
-rw-r--r--spec/ruby/library/bigdecimal/zero_spec.rb3
-rw-r--r--spec/ruby/library/bigmath/log_spec.rb2
-rw-r--r--spec/ruby/library/cgi/cookie/domain_spec.rb2
-rw-r--r--spec/ruby/library/cgi/cookie/expires_spec.rb2
-rw-r--r--spec/ruby/library/cgi/cookie/initialize_spec.rb6
-rw-r--r--spec/ruby/library/cgi/cookie/name_spec.rb2
-rw-r--r--spec/ruby/library/cgi/cookie/parse_spec.rb27
-rw-r--r--spec/ruby/library/cgi/cookie/path_spec.rb2
-rw-r--r--spec/ruby/library/cgi/cookie/secure_spec.rb2
-rw-r--r--spec/ruby/library/cgi/cookie/to_s_spec.rb2
-rw-r--r--spec/ruby/library/cgi/cookie/value_spec.rb2
-rw-r--r--spec/ruby/library/cgi/escapeElement_spec.rb2
-rw-r--r--spec/ruby/library/cgi/escapeHTML_spec.rb2
-rw-r--r--spec/ruby/library/cgi/escape_spec.rb2
-rw-r--r--spec/ruby/library/cgi/htmlextension/a_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/base_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/blockquote_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/br_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/caption_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/checkbox_group_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/checkbox_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/doctype_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/file_field_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/form_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/frame_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/frameset_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/hidden_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/html_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/image_button_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/img_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/multipart_form_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/password_field_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/popup_menu_spec.rb6
-rw-r--r--spec/ruby/library/cgi/htmlextension/radio_button_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/radio_group_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/reset_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/scrolling_list_spec.rb6
-rw-r--r--spec/ruby/library/cgi/htmlextension/submit_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/text_field_spec.rb4
-rw-r--r--spec/ruby/library/cgi/htmlextension/textarea_spec.rb4
-rw-r--r--spec/ruby/library/cgi/http_header_spec.rb6
-rw-r--r--spec/ruby/library/cgi/initialize_spec.rb2
-rw-r--r--spec/ruby/library/cgi/out_spec.rb4
-rw-r--r--spec/ruby/library/cgi/parse_spec.rb2
-rw-r--r--spec/ruby/library/cgi/pretty_spec.rb2
-rw-r--r--spec/ruby/library/cgi/print_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_charset_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_encoding_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_language_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/auth_type_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/cache_control_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/content_length_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/content_type_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/cookies_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/element_reference_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/from_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/gateway_interface_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/has_key_spec.rb4
-rw-r--r--spec/ruby/library/cgi/queryextension/host_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/include_spec.rb4
-rw-r--r--spec/ruby/library/cgi/queryextension/key_spec.rb4
-rw-r--r--spec/ruby/library/cgi/queryextension/keys_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/multipart_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/negotiate_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/params_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/path_info_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/path_translated_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/pragma_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/query_string_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/raw_cookie2_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/raw_cookie_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/referer_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_addr_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_host_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_ident_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_user_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/request_method_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/script_name_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/server_name_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/server_port_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/server_protocol_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/server_software_spec.rb2
-rw-r--r--spec/ruby/library/cgi/queryextension/user_agent_spec.rb2
-rw-r--r--spec/ruby/library/cgi/rfc1123_date_spec.rb4
-rw-r--r--spec/ruby/library/cgi/shared/http_header.rb2
-rw-r--r--spec/ruby/library/cgi/unescapeElement_spec.rb2
-rw-r--r--spec/ruby/library/cgi/unescapeHTML_spec.rb2
-rw-r--r--spec/ruby/library/cgi/unescape_spec.rb2
-rw-r--r--spec/ruby/library/cmath/math/acos_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/acosh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/asin_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/asinh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atan2_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atan_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atanh_spec.rb20
-rw-r--r--spec/ruby/library/cmath/math/cos_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/cosh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/exp_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/log10_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/log_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/shared/acos.rb41
-rw-r--r--spec/ruby/library/cmath/math/shared/acosh.rb37
-rw-r--r--spec/ruby/library/cmath/math/shared/asin.rb47
-rw-r--r--spec/ruby/library/cmath/math/shared/asinh.rb32
-rw-r--r--spec/ruby/library/cmath/math/shared/atan.rb32
-rw-r--r--spec/ruby/library/cmath/math/shared/atan2.rb34
-rw-r--r--spec/ruby/library/cmath/math/shared/atanh.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/cos.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/cosh.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/exp.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/log.rb39
-rw-r--r--spec/ruby/library/cmath/math/shared/log10.rb41
-rw-r--r--spec/ruby/library/cmath/math/shared/sin.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/sinh.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/sqrt.rb34
-rw-r--r--spec/ruby/library/cmath/math/shared/tan.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/tanh.rb32
-rw-r--r--spec/ruby/library/cmath/math/sin_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/sinh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/sqrt_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/tan_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/tanh_spec.rb18
-rw-r--r--spec/ruby/library/complex/math/acos_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/acosh_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/asin_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/asinh_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/atan2_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/atan_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/atanh_spec.rb17
-rw-r--r--spec/ruby/library/complex/math/cos_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/cosh_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/exp_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/fixtures/classes.rb (renamed from spec/ruby/library/cmath/math/fixtures/classes.rb)0
-rw-r--r--spec/ruby/library/complex/math/log10_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/log_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/shared/acos.rb41
-rw-r--r--spec/ruby/library/complex/math/shared/acosh.rb37
-rw-r--r--spec/ruby/library/complex/math/shared/asin.rb47
-rw-r--r--spec/ruby/library/complex/math/shared/asinh.rb32
-rw-r--r--spec/ruby/library/complex/math/shared/atan.rb32
-rw-r--r--spec/ruby/library/complex/math/shared/atan2.rb34
-rw-r--r--spec/ruby/library/complex/math/shared/atanh.rb30
-rw-r--r--spec/ruby/library/complex/math/shared/cos.rb30
-rw-r--r--spec/ruby/library/complex/math/shared/cosh.rb28
-rw-r--r--spec/ruby/library/complex/math/shared/exp.rb28
-rw-r--r--spec/ruby/library/complex/math/shared/log.rb39
-rw-r--r--spec/ruby/library/complex/math/shared/log10.rb41
-rw-r--r--spec/ruby/library/complex/math/shared/sin.rb30
-rw-r--r--spec/ruby/library/complex/math/shared/sinh.rb28
-rw-r--r--spec/ruby/library/complex/math/shared/sqrt.rb34
-rw-r--r--spec/ruby/library/complex/math/shared/tan.rb28
-rw-r--r--spec/ruby/library/complex/math/shared/tanh.rb32
-rw-r--r--spec/ruby/library/complex/math/sin_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/sinh_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/sqrt_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/tan_spec.rb15
-rw-r--r--spec/ruby/library/complex/math/tanh_spec.rb15
-rw-r--r--spec/ruby/library/complex/numeric/im_spec.rb3
-rw-r--r--spec/ruby/library/conditionvariable/broadcast_spec.rb2
-rw-r--r--spec/ruby/library/conditionvariable/marshal_dump_spec.rb2
-rw-r--r--spec/ruby/library/conditionvariable/signal_spec.rb37
-rw-r--r--spec/ruby/library/conditionvariable/wait_spec.rb109
-rw-r--r--spec/ruby/library/coverage/fixtures/spec_helper.rb11
-rw-r--r--spec/ruby/library/coverage/peek_result_spec.rb105
-rw-r--r--spec/ruby/library/coverage/result_spec.rb22
-rw-r--r--spec/ruby/library/coverage/start_spec.rb2
-rw-r--r--spec/ruby/library/csv/basicwriter/close_on_terminate_spec.rb2
-rw-r--r--spec/ruby/library/csv/basicwriter/initialize_spec.rb2
-rw-r--r--spec/ruby/library/csv/basicwriter/terminate_spec.rb2
-rw-r--r--spec/ruby/library/csv/cell/data_spec.rb2
-rw-r--r--spec/ruby/library/csv/cell/initialize_spec.rb2
-rw-r--r--spec/ruby/library/csv/foreach_spec.rb2
-rw-r--r--spec/ruby/library/csv/generate_line_spec.rb2
-rw-r--r--spec/ruby/library/csv/generate_row_spec.rb2
-rw-r--r--spec/ruby/library/csv/generate_spec.rb4
-rw-r--r--spec/ruby/library/csv/iobuf/close_spec.rb2
-rw-r--r--spec/ruby/library/csv/iobuf/initialize_spec.rb2
-rw-r--r--spec/ruby/library/csv/iobuf/read_spec.rb2
-rw-r--r--spec/ruby/library/csv/iobuf/terminate_spec.rb2
-rw-r--r--spec/ruby/library/csv/ioreader/close_on_terminate_spec.rb2
-rw-r--r--spec/ruby/library/csv/ioreader/get_row_spec.rb2
-rw-r--r--spec/ruby/library/csv/ioreader/initialize_spec.rb2
-rw-r--r--spec/ruby/library/csv/ioreader/terminate_spec.rb2
-rw-r--r--spec/ruby/library/csv/liberal_parsing_spec.rb28
-rw-r--r--spec/ruby/library/csv/open_spec.rb2
-rw-r--r--spec/ruby/library/csv/parse_spec.rb12
-rw-r--r--spec/ruby/library/csv/read_spec.rb2
-rw-r--r--spec/ruby/library/csv/readlines_spec.rb14
-rw-r--r--spec/ruby/library/csv/streambuf/add_buf_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/buf_size_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/drop_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/element_reference_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/get_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/idx_is_eos_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/initialize_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/is_eos_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/read_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/rel_buf_spec.rb2
-rw-r--r--spec/ruby/library/csv/streambuf/terminate_spec.rb2
-rw-r--r--spec/ruby/library/csv/stringreader/get_row_spec.rb2
-rw-r--r--spec/ruby/library/csv/stringreader/initialize_spec.rb2
-rw-r--r--spec/ruby/library/csv/writer/add_row_spec.rb2
-rw-r--r--spec/ruby/library/csv/writer/append_spec.rb2
-rw-r--r--spec/ruby/library/csv/writer/close_spec.rb2
-rw-r--r--spec/ruby/library/csv/writer/create_spec.rb2
-rw-r--r--spec/ruby/library/csv/writer/generate_spec.rb2
-rw-r--r--spec/ruby/library/csv/writer/initialize_spec.rb2
-rw-r--r--spec/ruby/library/csv/writer/terminate_spec.rb2
-rw-r--r--spec/ruby/library/date/accessor_spec.rb2
-rw-r--r--spec/ruby/library/date/add_month_spec.rb10
-rw-r--r--spec/ruby/library/date/add_spec.rb10
-rw-r--r--spec/ruby/library/date/ajd_spec.rb2
-rw-r--r--spec/ruby/library/date/ajd_to_amjd_spec.rb2
-rw-r--r--spec/ruby/library/date/ajd_to_jd_spec.rb2
-rw-r--r--spec/ruby/library/date/amjd_spec.rb2
-rw-r--r--spec/ruby/library/date/amjd_to_ajd_spec.rb2
-rw-r--r--spec/ruby/library/date/append_spec.rb2
-rw-r--r--spec/ruby/library/date/asctime_spec.rb2
-rw-r--r--spec/ruby/library/date/boat_spec.rb2
-rw-r--r--spec/ruby/library/date/case_compare_spec.rb2
-rw-r--r--spec/ruby/library/date/civil_spec.rb6
-rw-r--r--spec/ruby/library/date/commercial_spec.rb7
-rw-r--r--spec/ruby/library/date/commercial_to_jd_spec.rb2
-rw-r--r--spec/ruby/library/date/comparison_spec.rb2
-rw-r--r--spec/ruby/library/date/constants_spec.rb10
-rw-r--r--spec/ruby/library/date/conversions_spec.rb2
-rw-r--r--spec/ruby/library/date/ctime_spec.rb2
-rw-r--r--spec/ruby/library/date/cwday_spec.rb2
-rw-r--r--spec/ruby/library/date/cweek_spec.rb2
-rw-r--r--spec/ruby/library/date/cwyear_spec.rb2
-rw-r--r--spec/ruby/library/date/day_fraction_spec.rb2
-rw-r--r--spec/ruby/library/date/day_fraction_to_time_spec.rb2
-rw-r--r--spec/ruby/library/date/day_spec.rb2
-rw-r--r--spec/ruby/library/date/downto_spec.rb2
-rw-r--r--spec/ruby/library/date/england_spec.rb2
-rw-r--r--spec/ruby/library/date/eql_spec.rb2
-rw-r--r--spec/ruby/library/date/format/bag/method_missing_spec.rb2
-rw-r--r--spec/ruby/library/date/format/bag/to_hash_spec.rb2
-rw-r--r--spec/ruby/library/date/friday_spec.rb2
-rw-r--r--spec/ruby/library/date/gregorian_leap_spec.rb3
-rw-r--r--spec/ruby/library/date/gregorian_spec.rb2
-rw-r--r--spec/ruby/library/date/hash_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/abs_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/coerce_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/comparison_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/d_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/finite_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/infinite_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/nan_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/uminus_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/uplus_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity/zero_spec.rb2
-rw-r--r--spec/ruby/library/date/infinity_spec.rb2
-rw-r--r--spec/ruby/library/date/inspect_spec.rb2
-rw-r--r--spec/ruby/library/date/iso8601_spec.rb44
-rw-r--r--spec/ruby/library/date/italy_spec.rb2
-rw-r--r--spec/ruby/library/date/jd_spec.rb4
-rw-r--r--spec/ruby/library/date/jd_to_ajd_spec.rb2
-rw-r--r--spec/ruby/library/date/jd_to_civil_spec.rb2
-rw-r--r--spec/ruby/library/date/jd_to_commercial_spec.rb2
-rw-r--r--spec/ruby/library/date/jd_to_ld_spec.rb2
-rw-r--r--spec/ruby/library/date/jd_to_mjd_spec.rb2
-rw-r--r--spec/ruby/library/date/jd_to_ordinal_spec.rb2
-rw-r--r--spec/ruby/library/date/jd_to_wday_spec.rb2
-rw-r--r--spec/ruby/library/date/julian_leap_spec.rb2
-rw-r--r--spec/ruby/library/date/julian_spec.rb2
-rw-r--r--spec/ruby/library/date/ld_spec.rb2
-rw-r--r--spec/ruby/library/date/ld_to_jd_spec.rb2
-rw-r--r--spec/ruby/library/date/leap_spec.rb2
-rw-r--r--spec/ruby/library/date/mday_spec.rb2
-rw-r--r--spec/ruby/library/date/minus_month_spec.rb14
-rw-r--r--spec/ruby/library/date/minus_spec.rb8
-rw-r--r--spec/ruby/library/date/mjd_spec.rb2
-rw-r--r--spec/ruby/library/date/mjd_to_jd_spec.rb2
-rw-r--r--spec/ruby/library/date/mon_spec.rb2
-rw-r--r--spec/ruby/library/date/monday_spec.rb2
-rw-r--r--spec/ruby/library/date/month_spec.rb2
-rw-r--r--spec/ruby/library/date/new_spec.rb8
-rw-r--r--spec/ruby/library/date/new_start_spec.rb2
-rw-r--r--spec/ruby/library/date/next_day_spec.rb2
-rw-r--r--spec/ruby/library/date/next_month_spec.rb2
-rw-r--r--spec/ruby/library/date/next_spec.rb2
-rw-r--r--spec/ruby/library/date/next_year_spec.rb2
-rw-r--r--spec/ruby/library/date/ordinal_spec.rb5
-rw-r--r--spec/ruby/library/date/ordinal_to_jd_spec.rb2
-rw-r--r--spec/ruby/library/date/parse_spec.rb15
-rw-r--r--spec/ruby/library/date/plus_spec.rb4
-rw-r--r--spec/ruby/library/date/prev_day_spec.rb2
-rw-r--r--spec/ruby/library/date/prev_month_spec.rb2
-rw-r--r--spec/ruby/library/date/prev_year_spec.rb2
-rw-r--r--spec/ruby/library/date/relationship_spec.rb2
-rw-r--r--spec/ruby/library/date/rfc3339_spec.rb13
-rw-r--r--spec/ruby/library/date/right_shift_spec.rb2
-rw-r--r--spec/ruby/library/date/saturday_spec.rb2
-rw-r--r--spec/ruby/library/date/shared/civil.rb16
-rw-r--r--spec/ruby/library/date/shared/commercial.rb18
-rw-r--r--spec/ruby/library/date/shared/valid_jd.rb25
-rw-r--r--spec/ruby/library/date/start_spec.rb2
-rw-r--r--spec/ruby/library/date/step_spec.rb2
-rw-r--r--spec/ruby/library/date/strftime_spec.rb4
-rw-r--r--spec/ruby/library/date/strptime_spec.rb2
-rw-r--r--spec/ruby/library/date/succ_spec.rb2
-rw-r--r--spec/ruby/library/date/sunday_spec.rb2
-rw-r--r--spec/ruby/library/date/thursday_spec.rb2
-rw-r--r--spec/ruby/library/date/time_to_day_fraction_spec.rb2
-rw-r--r--spec/ruby/library/date/to_s_spec.rb2
-rw-r--r--spec/ruby/library/date/today_spec.rb2
-rw-r--r--spec/ruby/library/date/tuesday_spec.rb2
-rw-r--r--spec/ruby/library/date/upto_spec.rb2
-rw-r--r--spec/ruby/library/date/valid_civil_spec.rb5
-rw-r--r--spec/ruby/library/date/valid_commercial_spec.rb6
-rw-r--r--spec/ruby/library/date/valid_date_spec.rb4
-rw-r--r--spec/ruby/library/date/valid_jd_spec.rb5
-rw-r--r--spec/ruby/library/date/valid_ordinal_spec.rb5
-rw-r--r--spec/ruby/library/date/valid_time_spec.rb2
-rw-r--r--spec/ruby/library/date/wday_spec.rb2
-rw-r--r--spec/ruby/library/date/wednesday_spec.rb2
-rw-r--r--spec/ruby/library/date/yday_spec.rb2
-rw-r--r--spec/ruby/library/date/year_spec.rb2
-rw-r--r--spec/ruby/library/date/zone_to_diff_spec.rb2
-rw-r--r--spec/ruby/library/datetime/_strptime_spec.rb2
-rw-r--r--spec/ruby/library/datetime/add_spec.rb9
-rw-r--r--spec/ruby/library/datetime/civil_spec.rb2
-rw-r--r--spec/ruby/library/datetime/commercial_spec.rb2
-rw-r--r--spec/ruby/library/datetime/hour_spec.rb14
-rw-r--r--spec/ruby/library/datetime/httpdate_spec.rb2
-rw-r--r--spec/ruby/library/datetime/iso8601_spec.rb2
-rw-r--r--spec/ruby/library/datetime/jd_spec.rb2
-rw-r--r--spec/ruby/library/datetime/jisx0301_spec.rb2
-rw-r--r--spec/ruby/library/datetime/min_spec.rb4
-rw-r--r--spec/ruby/library/datetime/minute_spec.rb4
-rw-r--r--spec/ruby/library/datetime/new_offset_spec.rb2
-rw-r--r--spec/ruby/library/datetime/new_spec.rb4
-rw-r--r--spec/ruby/library/datetime/now_spec.rb6
-rw-r--r--spec/ruby/library/datetime/offset_spec.rb2
-rw-r--r--spec/ruby/library/datetime/ordinal_spec.rb2
-rw-r--r--spec/ruby/library/datetime/parse_spec.rb14
-rw-r--r--spec/ruby/library/datetime/rfc2822_spec.rb2
-rw-r--r--spec/ruby/library/datetime/rfc3339_spec.rb2
-rw-r--r--spec/ruby/library/datetime/rfc822_spec.rb2
-rw-r--r--spec/ruby/library/datetime/sec_fraction_spec.rb2
-rw-r--r--spec/ruby/library/datetime/sec_spec.rb4
-rw-r--r--spec/ruby/library/datetime/second_fraction_spec.rb2
-rw-r--r--spec/ruby/library/datetime/second_spec.rb4
-rw-r--r--spec/ruby/library/datetime/shared/min.rb12
-rw-r--r--spec/ruby/library/datetime/shared/sec.rb8
-rw-r--r--spec/ruby/library/datetime/strftime_spec.rb12
-rw-r--r--spec/ruby/library/datetime/strptime_spec.rb2
-rw-r--r--spec/ruby/library/datetime/subtract_spec.rb19
-rw-r--r--spec/ruby/library/datetime/to_date_spec.rb4
-rw-r--r--spec/ruby/library/datetime/to_datetime_spec.rb2
-rw-r--r--spec/ruby/library/datetime/to_s_spec.rb4
-rw-r--r--spec/ruby/library/datetime/to_time_spec.rb26
-rw-r--r--spec/ruby/library/datetime/xmlschema_spec.rb2
-rw-r--r--spec/ruby/library/datetime/zone_spec.rb2
-rw-r--r--spec/ruby/library/delegate/delegate_class/instance_method_spec.rb8
-rw-r--r--spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/case_compare_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/compare_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/complement_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/eql_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/equal_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/equal_value_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/frozen_spec.rb10
-rw-r--r--spec/ruby/library/delegate/delegator/hash_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/marshal_spec.rb2
-rw-r--r--spec/ruby/library/delegate/delegator/method_spec.rb12
-rw-r--r--spec/ruby/library/delegate/delegator/methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/not_equal_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/not_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/private_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/protected_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/public_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/send_spec.rb12
-rw-r--r--spec/ruby/library/delegate/delegator/taint_spec.rb28
-rw-r--r--spec/ruby/library/delegate/delegator/tap_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/trust_spec.rb26
-rw-r--r--spec/ruby/library/delegate/delegator/untaint_spec.rb32
-rw-r--r--spec/ruby/library/delegate/delegator/untrust_spec.rb28
-rw-r--r--spec/ruby/library/digest/bubblebabble_spec.rb8
-rw-r--r--spec/ruby/library/digest/hexencode_spec.rb6
-rw-r--r--spec/ruby/library/digest/md5/append_spec.rb8
-rw-r--r--spec/ruby/library/digest/md5/block_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/md5/digest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/md5/digest_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/md5/digest_spec.rb4
-rw-r--r--spec/ruby/library/digest/md5/equal_spec.rb5
-rw-r--r--spec/ruby/library/digest/md5/file_spec.rb10
-rw-r--r--spec/ruby/library/digest/md5/hexdigest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/md5/hexdigest_spec.rb4
-rw-r--r--spec/ruby/library/digest/md5/inspect_spec.rb5
-rw-r--r--spec/ruby/library/digest/md5/length_spec.rb7
-rw-r--r--spec/ruby/library/digest/md5/reset_spec.rb5
-rw-r--r--spec/ruby/library/digest/md5/size_spec.rb7
-rw-r--r--spec/ruby/library/digest/md5/to_s_spec.rb4
-rw-r--r--spec/ruby/library/digest/md5/update_spec.rb6
-rw-r--r--spec/ruby/library/digest/sha1/digest_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha1/file_spec.rb10
-rw-r--r--spec/ruby/library/digest/sha256/append_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha256/block_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha256/digest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha256/digest_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha256/digest_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha256/equal_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha256/file_spec.rb10
-rw-r--r--spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha256/hexdigest_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha256/inspect_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha256/length_spec.rb7
-rw-r--r--spec/ruby/library/digest/sha256/reset_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha256/size_spec.rb7
-rw-r--r--spec/ruby/library/digest/sha256/to_s_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha256/update_spec.rb6
-rw-r--r--spec/ruby/library/digest/sha384/append_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha384/block_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha384/digest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha384/digest_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha384/digest_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha384/equal_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha384/file_spec.rb10
-rw-r--r--spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha384/hexdigest_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha384/inspect_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha384/length_spec.rb7
-rw-r--r--spec/ruby/library/digest/sha384/reset_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha384/size_spec.rb7
-rw-r--r--spec/ruby/library/digest/sha384/to_s_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha384/update_spec.rb6
-rw-r--r--spec/ruby/library/digest/sha512/append_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha512/block_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha512/digest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha512/digest_length_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha512/digest_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha512/equal_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha512/file_spec.rb10
-rw-r--r--spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha512/hexdigest_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha512/inspect_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha512/length_spec.rb7
-rw-r--r--spec/ruby/library/digest/sha512/reset_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha512/size_spec.rb7
-rw-r--r--spec/ruby/library/digest/sha512/to_s_spec.rb4
-rw-r--r--spec/ruby/library/digest/sha512/update_spec.rb6
-rw-r--r--spec/ruby/library/drb/start_service_spec.rb4
-rw-r--r--spec/ruby/library/erb/def_class_spec.rb2
-rw-r--r--spec/ruby/library/erb/def_method_spec.rb2
-rw-r--r--spec/ruby/library/erb/def_module_spec.rb2
-rw-r--r--spec/ruby/library/erb/defmethod/def_erb_method_spec.rb5
-rw-r--r--spec/ruby/library/erb/filename_spec.rb6
-rw-r--r--spec/ruby/library/erb/fixtures/classes.rb9
-rw-r--r--spec/ruby/library/erb/new_spec.rb48
-rw-r--r--spec/ruby/library/erb/result_spec.rb6
-rw-r--r--spec/ruby/library/erb/run_spec.rb7
-rw-r--r--spec/ruby/library/erb/src_spec.rb2
-rw-r--r--spec/ruby/library/erb/util/h_spec.rb4
-rw-r--r--spec/ruby/library/erb/util/html_escape_spec.rb5
-rw-r--r--spec/ruby/library/erb/util/u_spec.rb5
-rw-r--r--spec/ruby/library/erb/util/url_encode_spec.rb4
-rw-r--r--spec/ruby/library/etc/confstr_spec.rb14
-rw-r--r--spec/ruby/library/etc/endgrent_spec.rb6
-rw-r--r--spec/ruby/library/etc/endpwent_spec.rb6
-rw-r--r--spec/ruby/library/etc/getgrent_spec.rb6
-rw-r--r--spec/ruby/library/etc/getgrgid_spec.rb92
-rw-r--r--spec/ruby/library/etc/getgrnam_spec.rb4
-rw-r--r--spec/ruby/library/etc/getlogin_spec.rb9
-rw-r--r--spec/ruby/library/etc/getpwent_spec.rb6
-rw-r--r--spec/ruby/library/etc/getpwnam_spec.rb4
-rw-r--r--spec/ruby/library/etc/getpwuid_spec.rb4
-rw-r--r--spec/ruby/library/etc/group_spec.rb15
-rw-r--r--spec/ruby/library/etc/nprocessors_spec.rb2
-rw-r--r--spec/ruby/library/etc/passwd_spec.rb15
-rw-r--r--spec/ruby/library/etc/struct_group_spec.rb8
-rw-r--r--spec/ruby/library/etc/struct_passwd_spec.rb2
-rw-r--r--spec/ruby/library/etc/sysconf_spec.rb22
-rw-r--r--spec/ruby/library/etc/sysconfdir_spec.rb8
-rw-r--r--spec/ruby/library/etc/systmpdir_spec.rb8
-rw-r--r--spec/ruby/library/expect/expect_spec.rb4
-rw-r--r--spec/ruby/library/fiber/alive_spec.rb76
-rw-r--r--spec/ruby/library/fiber/current_spec.rb82
-rw-r--r--spec/ruby/library/fiber/resume_spec.rb18
-rw-r--r--spec/ruby/library/fiber/transfer_spec.rb109
-rw-r--r--spec/ruby/library/find/find_spec.rb4
-rw-r--r--spec/ruby/library/find/prune_spec.rb2
-rw-r--r--spec/ruby/library/getoptlong/each_option_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/each_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/error_message_spec.rb2
-rw-r--r--spec/ruby/library/getoptlong/get_option_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/get_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/initialize_spec.rb2
-rw-r--r--spec/ruby/library/getoptlong/ordering_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/set_options_spec.rb16
-rw-r--r--spec/ruby/library/getoptlong/shared/get.rb2
-rw-r--r--spec/ruby/library/getoptlong/terminate_spec.rb4
-rw-r--r--spec/ruby/library/getoptlong/terminated_spec.rb2
-rw-r--r--spec/ruby/library/ipaddr/hton_spec.rb2
-rw-r--r--spec/ruby/library/ipaddr/ipv4_conversion_spec.rb4
-rw-r--r--spec/ruby/library/ipaddr/new_spec.rb10
-rw-r--r--spec/ruby/library/ipaddr/operator_spec.rb17
-rw-r--r--spec/ruby/library/ipaddr/reverse_spec.rb6
-rw-r--r--spec/ruby/library/ipaddr/to_s_spec.rb2
-rw-r--r--spec/ruby/library/logger/device/close_spec.rb19
-rw-r--r--spec/ruby/library/logger/device/new_spec.rb12
-rw-r--r--spec/ruby/library/logger/device/write_spec.rb19
-rw-r--r--spec/ruby/library/logger/logger/add_spec.rb10
-rw-r--r--spec/ruby/library/logger/logger/close_spec.rb6
-rw-r--r--spec/ruby/library/logger/logger/datetime_format_spec.rb6
-rw-r--r--spec/ruby/library/logger/logger/debug_spec.rb4
-rw-r--r--spec/ruby/library/logger/logger/error_spec.rb4
-rw-r--r--spec/ruby/library/logger/logger/fatal_spec.rb4
-rw-r--r--spec/ruby/library/logger/logger/info_spec.rb4
-rw-r--r--spec/ruby/library/logger/logger/new_spec.rb98
-rw-r--r--spec/ruby/library/logger/logger/unknown_spec.rb6
-rw-r--r--spec/ruby/library/logger/logger/warn_spec.rb4
-rw-r--r--spec/ruby/library/logger/severity_spec.rb2
-rw-r--r--spec/ruby/library/mathn/bignum/exponent_spec.rb2
-rw-r--r--spec/ruby/library/mathn/complex/Complex_spec.rb2
-rw-r--r--spec/ruby/library/mathn/fixnum/exponent_spec.rb2
-rw-r--r--spec/ruby/library/mathn/float/exponent_spec.rb2
-rw-r--r--spec/ruby/library/mathn/integer/from_prime_division_spec.rb2
-rw-r--r--spec/ruby/library/mathn/integer/prime_division_spec.rb4
-rw-r--r--spec/ruby/library/mathn/math/rsqrt_spec.rb4
-rw-r--r--spec/ruby/library/mathn/math/shared/rsqrt.rb8
-rw-r--r--spec/ruby/library/mathn/math/shared/sqrt.rb2
-rw-r--r--spec/ruby/library/mathn/math/sqrt_spec.rb4
-rw-r--r--spec/ruby/library/mathn/mathn_spec.rb13
-rw-r--r--spec/ruby/library/mathn/rational/Rational_spec.rb2
-rw-r--r--spec/ruby/library/mathn/rational/inspect_spec.rb2
-rw-r--r--spec/ruby/library/matrix/I_spec.rb6
-rw-r--r--spec/ruby/library/matrix/antisymmetric_spec.rb37
-rw-r--r--spec/ruby/library/matrix/build_spec.rb14
-rw-r--r--spec/ruby/library/matrix/clone_spec.rb4
-rw-r--r--spec/ruby/library/matrix/coerce_spec.rb4
-rw-r--r--spec/ruby/library/matrix/collect_spec.rb6
-rw-r--r--spec/ruby/library/matrix/column_size_spec.rb2
-rw-r--r--spec/ruby/library/matrix/column_spec.rb6
-rw-r--r--spec/ruby/library/matrix/column_vector_spec.rb4
-rw-r--r--spec/ruby/library/matrix/column_vectors_spec.rb2
-rw-r--r--spec/ruby/library/matrix/columns_spec.rb4
-rw-r--r--spec/ruby/library/matrix/conj_spec.rb6
-rw-r--r--spec/ruby/library/matrix/conjugate_spec.rb6
-rw-r--r--spec/ruby/library/matrix/constructor_spec.rb16
-rw-r--r--spec/ruby/library/matrix/det_spec.rb6
-rw-r--r--spec/ruby/library/matrix/determinant_spec.rb6
-rw-r--r--spec/ruby/library/matrix/diagonal_spec.rb6
-rw-r--r--spec/ruby/library/matrix/divide_spec.rb21
-rw-r--r--spec/ruby/library/matrix/each_spec.rb8
-rw-r--r--spec/ruby/library/matrix/each_with_index_spec.rb8
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb2
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb4
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb4
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb4
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb8
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb2
-rw-r--r--spec/ruby/library/matrix/element_reference_spec.rb2
-rw-r--r--spec/ruby/library/matrix/empty_spec.rb14
-rw-r--r--spec/ruby/library/matrix/eql_spec.rb6
-rw-r--r--spec/ruby/library/matrix/equal_value_spec.rb6
-rw-r--r--spec/ruby/library/matrix/exponent_spec.rb12
-rw-r--r--spec/ruby/library/matrix/find_index_spec.rb10
-rw-r--r--spec/ruby/library/matrix/hash_spec.rb2
-rw-r--r--spec/ruby/library/matrix/hermitian_spec.rb4
-rw-r--r--spec/ruby/library/matrix/identity_spec.rb6
-rw-r--r--spec/ruby/library/matrix/imag_spec.rb6
-rw-r--r--spec/ruby/library/matrix/imaginary_spec.rb6
-rw-r--r--spec/ruby/library/matrix/inspect_spec.rb4
-rw-r--r--spec/ruby/library/matrix/inv_spec.rb8
-rw-r--r--spec/ruby/library/matrix/inverse_from_spec.rb2
-rw-r--r--spec/ruby/library/matrix/inverse_spec.rb8
-rw-r--r--spec/ruby/library/matrix/lower_triangular_spec.rb2
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb4
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb6
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/l_spec.rb2
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/p_spec.rb2
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/solve_spec.rb8
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb2
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/u_spec.rb2
-rw-r--r--spec/ruby/library/matrix/map_spec.rb6
-rw-r--r--spec/ruby/library/matrix/minor_spec.rb4
-rw-r--r--spec/ruby/library/matrix/minus_spec.rb20
-rw-r--r--spec/ruby/library/matrix/multiply_spec.rb14
-rw-r--r--spec/ruby/library/matrix/new_spec.rb2
-rw-r--r--spec/ruby/library/matrix/normal_spec.rb4
-rw-r--r--spec/ruby/library/matrix/orthogonal_spec.rb4
-rw-r--r--spec/ruby/library/matrix/permutation_spec.rb4
-rw-r--r--spec/ruby/library/matrix/plus_spec.rb20
-rw-r--r--spec/ruby/library/matrix/rank_spec.rb2
-rw-r--r--spec/ruby/library/matrix/real_spec.rb7
-rw-r--r--spec/ruby/library/matrix/rect_spec.rb6
-rw-r--r--spec/ruby/library/matrix/rectangular_spec.rb6
-rw-r--r--spec/ruby/library/matrix/regular_spec.rb6
-rw-r--r--spec/ruby/library/matrix/round_spec.rb4
-rw-r--r--spec/ruby/library/matrix/row_size_spec.rb2
-rw-r--r--spec/ruby/library/matrix/row_spec.rb6
-rw-r--r--spec/ruby/library/matrix/row_vector_spec.rb4
-rw-r--r--spec/ruby/library/matrix/row_vectors_spec.rb2
-rw-r--r--spec/ruby/library/matrix/rows_spec.rb4
-rw-r--r--spec/ruby/library/matrix/scalar/Fail_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/Raise_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/divide_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/exponent_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/included_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/initialize_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/minus_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/multiply_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/plus_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar_spec.rb2
-rw-r--r--spec/ruby/library/matrix/shared/collect.rb2
-rw-r--r--spec/ruby/library/matrix/shared/conjugate.rb2
-rw-r--r--spec/ruby/library/matrix/shared/determinant.rb4
-rw-r--r--spec/ruby/library/matrix/shared/equal_value.rb2
-rw-r--r--spec/ruby/library/matrix/shared/identity.rb2
-rw-r--r--spec/ruby/library/matrix/shared/imaginary.rb2
-rw-r--r--spec/ruby/library/matrix/shared/inverse.rb4
-rw-r--r--spec/ruby/library/matrix/shared/rectangular.rb2
-rw-r--r--spec/ruby/library/matrix/shared/trace.rb2
-rw-r--r--spec/ruby/library/matrix/shared/transpose.rb2
-rw-r--r--spec/ruby/library/matrix/singular_spec.rb6
-rw-r--r--spec/ruby/library/matrix/square_spec.rb2
-rw-r--r--spec/ruby/library/matrix/symmetric_spec.rb4
-rw-r--r--spec/ruby/library/matrix/t_spec.rb6
-rw-r--r--spec/ruby/library/matrix/to_a_spec.rb2
-rw-r--r--spec/ruby/library/matrix/to_s_spec.rb2
-rw-r--r--spec/ruby/library/matrix/tr_spec.rb6
-rw-r--r--spec/ruby/library/matrix/trace_spec.rb6
-rw-r--r--spec/ruby/library/matrix/transpose_spec.rb6
-rw-r--r--spec/ruby/library/matrix/unit_spec.rb6
-rw-r--r--spec/ruby/library/matrix/unitary_spec.rb4
-rw-r--r--spec/ruby/library/matrix/upper_triangular_spec.rb2
-rw-r--r--spec/ruby/library/matrix/vector/cross_product_spec.rb4
-rw-r--r--spec/ruby/library/matrix/vector/each2_spec.rb10
-rw-r--r--spec/ruby/library/matrix/vector/eql_spec.rb2
-rw-r--r--spec/ruby/library/matrix/vector/inner_product_spec.rb4
-rw-r--r--spec/ruby/library/matrix/vector/normalize_spec.rb6
-rw-r--r--spec/ruby/library/matrix/zero_spec.rb4
-rw-r--r--spec/ruby/library/mkmf/mkmf_spec.rb7
-rw-r--r--spec/ruby/library/monitor/mon_initialize_spec.rb31
-rw-r--r--spec/ruby/library/net/FTPError_spec.rb2
-rw-r--r--spec/ruby/library/net/FTPPermError_spec.rb2
-rw-r--r--spec/ruby/library/net/FTPProtoError_spec.rb2
-rw-r--r--spec/ruby/library/net/FTPReplyError_spec.rb2
-rw-r--r--spec/ruby/library/net/FTPTempError_spec.rb2
-rw-r--r--spec/ruby/library/net/ftp/abort_spec.rb20
-rw-r--r--spec/ruby/library/net/ftp/acct_spec.rb18
-rw-r--r--spec/ruby/library/net/ftp/binary_spec.rb4
-rw-r--r--spec/ruby/library/net/ftp/chdir_spec.rb30
-rw-r--r--spec/ruby/library/net/ftp/close_spec.rb4
-rw-r--r--spec/ruby/library/net/ftp/closed_spec.rb4
-rw-r--r--spec/ruby/library/net/ftp/connect_spec.rb16
-rw-r--r--spec/ruby/library/net/ftp/debug_mode_spec.rb4
-rw-r--r--spec/ruby/library/net/ftp/default_passive_spec.rb12
-rw-r--r--spec/ruby/library/net/ftp/delete_spec.rb20
-rw-r--r--spec/ruby/library/net/ftp/dir_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/fixtures/server.rb4
-rw-r--r--spec/ruby/library/net/ftp/get_spec.rb10
-rw-r--r--spec/ruby/library/net/ftp/getbinaryfile_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/getdir_spec.rb6
-rw-r--r--spec/ruby/library/net/ftp/gettextfile_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/help_spec.rb18
-rw-r--r--spec/ruby/library/net/ftp/initialize_spec.rb320
-rw-r--r--spec/ruby/library/net/ftp/last_response_code_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/last_response_spec.rb6
-rw-r--r--spec/ruby/library/net/ftp/lastresp_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/list_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/login_spec.rb48
-rw-r--r--spec/ruby/library/net/ftp/ls_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/mdtm_spec.rb10
-rw-r--r--spec/ruby/library/net/ftp/mkdir_spec.rb18
-rw-r--r--spec/ruby/library/net/ftp/mtime_spec.rb10
-rw-r--r--spec/ruby/library/net/ftp/nlst_spec.rb26
-rw-r--r--spec/ruby/library/net/ftp/noop_spec.rb10
-rw-r--r--spec/ruby/library/net/ftp/open_spec.rb4
-rw-r--r--spec/ruby/library/net/ftp/passive_spec.rb16
-rw-r--r--spec/ruby/library/net/ftp/put_spec.rb10
-rw-r--r--spec/ruby/library/net/ftp/putbinaryfile_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/puttextfile_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/pwd_spec.rb16
-rw-r--r--spec/ruby/library/net/ftp/quit_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/rename_spec.rb30
-rw-r--r--spec/ruby/library/net/ftp/resume_spec.rb4
-rw-r--r--spec/ruby/library/net/ftp/retrbinary_spec.rb6
-rw-r--r--spec/ruby/library/net/ftp/retrlines_spec.rb6
-rw-r--r--spec/ruby/library/net/ftp/return_code_spec.rb8
-rw-r--r--spec/ruby/library/net/ftp/rmdir_spec.rb18
-rw-r--r--spec/ruby/library/net/ftp/sendcmd_spec.rb18
-rw-r--r--spec/ruby/library/net/ftp/set_socket_spec.rb6
-rw-r--r--spec/ruby/library/net/ftp/shared/getbinaryfile.rb32
-rw-r--r--spec/ruby/library/net/ftp/shared/gettextfile.rb20
-rw-r--r--spec/ruby/library/net/ftp/shared/list.rb20
-rw-r--r--spec/ruby/library/net/ftp/shared/putbinaryfile.rb36
-rw-r--r--spec/ruby/library/net/ftp/shared/puttextfile.rb24
-rw-r--r--spec/ruby/library/net/ftp/site_spec.rb16
-rw-r--r--spec/ruby/library/net/ftp/size_spec.rb14
-rw-r--r--spec/ruby/library/net/ftp/status_spec.rb26
-rw-r--r--spec/ruby/library/net/ftp/storbinary_spec.rb6
-rw-r--r--spec/ruby/library/net/ftp/storlines_spec.rb6
-rw-r--r--spec/ruby/library/net/ftp/system_spec.rb14
-rw-r--r--spec/ruby/library/net/ftp/voidcmd_spec.rb18
-rw-r--r--spec/ruby/library/net/ftp/welcome_spec.rb6
-rw-r--r--spec/ruby/library/net/http/HTTPBadResponse_spec.rb2
-rw-r--r--spec/ruby/library/net/http/HTTPClientExcepton_spec.rb14
-rw-r--r--spec/ruby/library/net/http/HTTPError_spec.rb2
-rw-r--r--spec/ruby/library/net/http/HTTPFatalError_spec.rb2
-rw-r--r--spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb2
-rw-r--r--spec/ruby/library/net/http/HTTPRetriableError_spec.rb2
-rw-r--r--spec/ruby/library/net/http/HTTPServerException_spec.rb26
-rw-r--r--spec/ruby/library/net/http/http/Proxy_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/active_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/address_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/close_on_empty_response_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/copy_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/default_port_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/delete_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/finish_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/get2_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/get_print_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/get_response_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/get_spec.rb73
-rw-r--r--spec/ruby/library/net/http/http/head2_spec.rb7
-rw-r--r--spec/ruby/library/net/http/http/head_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/http_default_port_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/https_default_port_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/initialize_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/inspect_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/is_version_1_1_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/is_version_1_2_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/lock_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/mkcol_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/move_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/new_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/newobj_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/open_timeout_spec.rb23
-rw-r--r--spec/ruby/library/net/http/http/options_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/port_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/post2_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/post_form_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/post_spec.rb61
-rw-r--r--spec/ruby/library/net/http/http/propfind_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/proppatch_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/proxy_address_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/proxy_class_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/proxy_pass_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/proxy_port_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/proxy_user_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/put2_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/put_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/read_timeout_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/request_get_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/request_head_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/request_post_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/request_put_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/request_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/request_types_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/send_request_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/set_debug_output_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/socket_type_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/start_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/started_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/trace_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/unlock_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/use_ssl_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/version_1_1_spec.rb4
-rw-r--r--spec/ruby/library/net/http/http/version_1_2_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpexceptions/initialize_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpexceptions/response_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb7
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/body_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/method_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/path_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/add_field_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/basic_auth_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/canonical_each_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/chunked_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/content_length_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/content_range_spec.rb10
-rw-r--r--spec/ruby/library/net/http/httpheader/content_type_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/delete_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb7
-rw-r--r--spec/ruby/library/net/http/httpheader/each_header_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/each_key_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/each_name_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/each_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/each_value_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/element_reference_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/element_set_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/fetch_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/form_data_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/get_fields_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpheader/key_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/length_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/main_type_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/range_length_spec.rb10
-rw-r--r--spec/ruby/library/net/http/httpheader/range_spec.rb14
-rw-r--r--spec/ruby/library/net/http/httpheader/set_content_type_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/set_form_data_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/set_range_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/shared/set_range.rb12
-rw-r--r--spec/ruby/library/net/http/httpheader/size_spec.rb6
-rw-r--r--spec/ruby/library/net/http/httpheader/sub_type_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/to_hash_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpheader/type_params_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httprequest/initialize_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/body_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpresponse/code_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/code_type_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/entity_spec.rb4
-rw-r--r--spec/ruby/library/net/http/httpresponse/error_spec.rb19
-rw-r--r--spec/ruby/library/net/http/httpresponse/error_type_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpresponse/exception_type_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpresponse/header_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/http_version_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/initialize_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/inspect_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/message_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/msg_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/read_body_spec.rb11
-rw-r--r--spec/ruby/library/net/http/httpresponse/read_header_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/read_new_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/reading_body_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/response_spec.rb2
-rw-r--r--spec/ruby/library/net/http/httpresponse/value_spec.rb19
-rw-r--r--spec/ruby/library/objectspace/memsize_of_spec.rb30
-rw-r--r--spec/ruby/library/objectspace/reachable_objects_from_spec.rb61
-rw-r--r--spec/ruby/library/observer/add_observer_spec.rb4
-rw-r--r--spec/ruby/library/observer/count_observers_spec.rb4
-rw-r--r--spec/ruby/library/observer/delete_observer_spec.rb4
-rw-r--r--spec/ruby/library/observer/delete_observers_spec.rb4
-rw-r--r--spec/ruby/library/observer/notify_observers_spec.rb6
-rw-r--r--spec/ruby/library/open3/capture2_spec.rb2
-rw-r--r--spec/ruby/library/open3/capture2e_spec.rb2
-rw-r--r--spec/ruby/library/open3/capture3_spec.rb2
-rw-r--r--spec/ruby/library/open3/pipeline_r_spec.rb2
-rw-r--r--spec/ruby/library/open3/pipeline_rw_spec.rb2
-rw-r--r--spec/ruby/library/open3/pipeline_spec.rb2
-rw-r--r--spec/ruby/library/open3/pipeline_start_spec.rb2
-rw-r--r--spec/ruby/library/open3/pipeline_w_spec.rb2
-rw-r--r--spec/ruby/library/open3/popen2_spec.rb2
-rw-r--r--spec/ruby/library/open3/popen2e_spec.rb2
-rw-r--r--spec/ruby/library/open3/popen3_spec.rb4
-rw-r--r--spec/ruby/library/openssl/cipher_spec.rb4
-rw-r--r--spec/ruby/library/openssl/config/freeze_spec.rb8
-rw-r--r--spec/ruby/library/openssl/hmac/digest_spec.rb4
-rw-r--r--spec/ruby/library/openssl/hmac/hexdigest_spec.rb4
-rw-r--r--spec/ruby/library/openssl/random/pseudo_bytes_spec.rb4
-rw-r--r--spec/ruby/library/openssl/random/random_bytes_spec.rb4
-rw-r--r--spec/ruby/library/openssl/random/shared/random_bytes.rb4
-rw-r--r--spec/ruby/library/openssl/x509/name/parse_spec.rb6
-rw-r--r--spec/ruby/library/openstruct/delete_field_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/element_reference_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/element_set_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/equal_value_spec.rb4
-rw-r--r--spec/ruby/library/openstruct/frozen_spec.rb12
-rw-r--r--spec/ruby/library/openstruct/initialize_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/inspect_spec.rb6
-rw-r--r--spec/ruby/library/openstruct/marshal_dump_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/marshal_load_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/method_missing_spec.rb22
-rw-r--r--spec/ruby/library/openstruct/new_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/to_h_spec.rb43
-rw-r--r--spec/ruby/library/openstruct/to_s_spec.rb6
-rw-r--r--spec/ruby/library/optionparser/order_spec.rb38
-rw-r--r--spec/ruby/library/optionparser/parse_spec.rb38
-rw-r--r--spec/ruby/library/pathname/absolute_spec.rb3
-rw-r--r--spec/ruby/library/pathname/empty_spec.rb48
-rw-r--r--spec/ruby/library/pathname/equal_value_spec.rb3
-rw-r--r--spec/ruby/library/pathname/hash_spec.rb3
-rw-r--r--spec/ruby/library/pathname/join_spec.rb2
-rw-r--r--spec/ruby/library/pathname/new_spec.rb20
-rw-r--r--spec/ruby/library/pathname/parent_spec.rb3
-rw-r--r--spec/ruby/library/pathname/realdirpath_spec.rb2
-rw-r--r--spec/ruby/library/pathname/realpath_spec.rb2
-rw-r--r--spec/ruby/library/pathname/relative_path_from_spec.rb6
-rw-r--r--spec/ruby/library/pathname/relative_spec.rb3
-rw-r--r--spec/ruby/library/pathname/root_spec.rb3
-rw-r--r--spec/ruby/library/pathname/sub_spec.rb3
-rw-r--r--spec/ruby/library/pp/pp_spec.rb8
-rw-r--r--spec/ruby/library/prime/each_spec.rb2
-rw-r--r--spec/ruby/library/prime/instance_spec.rb6
-rw-r--r--spec/ruby/library/prime/int_from_prime_division_spec.rb2
-rw-r--r--spec/ruby/library/prime/integer/each_prime_spec.rb2
-rw-r--r--spec/ruby/library/prime/integer/from_prime_division_spec.rb2
-rw-r--r--spec/ruby/library/prime/integer/prime_division_spec.rb4
-rw-r--r--spec/ruby/library/prime/integer/prime_spec.rb2
-rw-r--r--spec/ruby/library/prime/next_spec.rb4
-rw-r--r--spec/ruby/library/prime/prime_division_spec.rb4
-rw-r--r--spec/ruby/library/prime/prime_spec.rb2
-rw-r--r--spec/ruby/library/prime/succ_spec.rb4
-rw-r--r--spec/ruby/library/rbconfig/rbconfig_spec.rb48
-rw-r--r--spec/ruby/library/rbconfig/sizeof/limits_spec.rb42
-rw-r--r--spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb30
-rw-r--r--spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb22
-rw-r--r--spec/ruby/library/rbconfig/unicode_version_spec.rb34
-rw-r--r--spec/ruby/library/readline/basic_quote_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/basic_word_break_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/completer_quote_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/completer_word_break_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/completion_append_character_spec.rb2
-rw-r--r--spec/ruby/library/readline/completion_case_fold_spec.rb2
-rw-r--r--spec/ruby/library/readline/completion_proc_spec.rb4
-rw-r--r--spec/ruby/library/readline/constants_spec.rb2
-rw-r--r--spec/ruby/library/readline/emacs_editing_mode_spec.rb2
-rw-r--r--spec/ruby/library/readline/filename_quote_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/append_spec.rb4
-rw-r--r--spec/ruby/library/readline/history/delete_at_spec.rb18
-rw-r--r--spec/ruby/library/readline/history/each_spec.rb10
-rw-r--r--spec/ruby/library/readline/history/element_reference_spec.rb22
-rw-r--r--spec/ruby/library/readline/history/element_set_spec.rb6
-rw-r--r--spec/ruby/library/readline/history/empty_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/history_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/length_spec.rb4
-rw-r--r--spec/ruby/library/readline/history/pop_spec.rb14
-rw-r--r--spec/ruby/library/readline/history/push_spec.rb4
-rw-r--r--spec/ruby/library/readline/history/shift_spec.rb14
-rw-r--r--spec/ruby/library/readline/history/size_spec.rb4
-rw-r--r--spec/ruby/library/readline/history/to_s_spec.rb2
-rw-r--r--spec/ruby/library/readline/readline_spec.rb10
-rw-r--r--spec/ruby/library/readline/spec_helper.rb6
-rw-r--r--spec/ruby/library/readline/vi_editing_mode_spec.rb2
-rw-r--r--spec/ruby/library/resolv/fixtures/hosts1
-rw-r--r--spec/ruby/library/resolv/get_address_spec.rb16
-rw-r--r--spec/ruby/library/resolv/get_addresses_spec.rb14
-rw-r--r--spec/ruby/library/resolv/get_name_spec.rb15
-rw-r--r--spec/ruby/library/resolv/get_names_spec.rb13
-rw-r--r--spec/ruby/library/rexml/attribute/clone_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/element_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/equal_value_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/hash_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/initialize_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attribute/inspect_spec.rb7
-rw-r--r--spec/ruby/library/rexml/attribute/namespace_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/node_type_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/prefix_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/remove_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attribute/to_s_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/to_string_spec.rb3
-rw-r--r--spec/ruby/library/rexml/attribute/value_spec.rb3
-rw-r--r--spec/ruby/library/rexml/attribute/write_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/xpath_spec.rb5
-rw-r--r--spec/ruby/library/rexml/attributes/add_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attributes/append_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attributes/delete_all_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/delete_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/each_attribute_spec.rb5
-rw-r--r--spec/ruby/library/rexml/attributes/each_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attributes/element_reference_spec.rb3
-rw-r--r--spec/ruby/library/rexml/attributes/element_set_spec.rb3
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/initialize_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/length_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attributes/namespaces_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/prefixes_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/shared/length.rb2
-rw-r--r--spec/ruby/library/rexml/attributes/size_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attributes/to_a_spec.rb3
-rw-r--r--spec/ruby/library/rexml/cdata/clone_spec.rb2
-rw-r--r--spec/ruby/library/rexml/cdata/initialize_spec.rb2
-rw-r--r--spec/ruby/library/rexml/cdata/to_s_spec.rb4
-rw-r--r--spec/ruby/library/rexml/cdata/value_spec.rb4
-rw-r--r--spec/ruby/library/rexml/document/add_element_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/add_spec.rb8
-rw-r--r--spec/ruby/library/rexml/document/clone_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/doctype_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/encoding_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/expanded_name_spec.rb6
-rw-r--r--spec/ruby/library/rexml/document/new_spec.rb4
-rw-r--r--spec/ruby/library/rexml/document/node_type_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/root_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/stand_alone_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/version_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/write_spec.rb2
-rw-r--r--spec/ruby/library/rexml/document/xml_decl_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/add_attribute_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/add_attributes_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/add_element_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/add_namespace_spec.rb3
-rw-r--r--spec/ruby/library/rexml/element/add_text_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/attribute_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/attributes_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/cdatas_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/clone_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/comments_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/delete_attribute_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/delete_element_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/delete_namespace_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/document_spec.rb4
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_text_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/element_reference_spec.rb16
-rw-r--r--spec/ruby/library/rexml/element/get_text_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/has_attributes_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/has_elements_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/has_text_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/inspect_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/instructions_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/namespace_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/namespaces_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/new_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/next_element_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/node_type_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/prefixes_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/previous_element_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/raw_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/root_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/text_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/texts_spec.rb2
-rw-r--r--spec/ruby/library/rexml/element/whitespace_spec.rb2
-rw-r--r--spec/ruby/library/rexml/node/each_recursive_spec.rb2
-rw-r--r--spec/ruby/library/rexml/node/find_first_recursive_spec.rb2
-rw-r--r--spec/ruby/library/rexml/node/index_in_parent_spec.rb2
-rw-r--r--spec/ruby/library/rexml/node/next_sibling_node_spec.rb2
-rw-r--r--spec/ruby/library/rexml/node/parent_spec.rb3
-rw-r--r--spec/ruby/library/rexml/node/previous_sibling_node_spec.rb2
-rw-r--r--spec/ruby/library/rexml/shared/each_element.rb2
-rw-r--r--spec/ruby/library/rexml/shared/elements_to_a.rb2
-rw-r--r--spec/ruby/library/rexml/text/append_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/clone_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/comparison_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/empty_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/indent_text_spec.rb3
-rw-r--r--spec/ruby/library/rexml/text/inspect_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/new_spec.rb7
-rw-r--r--spec/ruby/library/rexml/text/node_type_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/normalize_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/read_with_substitution_spec.rb5
-rw-r--r--spec/ruby/library/rexml/text/to_s_spec.rb3
-rw-r--r--spec/ruby/library/rexml/text/unnormalize_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/value_spec.rb2
-rw-r--r--spec/ruby/library/rexml/text/wrap_spec.rb3
-rw-r--r--spec/ruby/library/rexml/text/write_with_substitution_spec.rb2
-rw-r--r--spec/ruby/library/rubygems/gem/bin_path_spec.rb34
-rw-r--r--spec/ruby/library/scanf/io/block_scanf_spec.rb13
-rw-r--r--spec/ruby/library/scanf/io/scanf_spec.rb57
-rw-r--r--spec/ruby/library/scanf/io/shared/block_scanf.rb2
-rw-r--r--spec/ruby/library/scanf/string/block_scanf_spec.rb13
-rw-r--r--spec/ruby/library/scanf/string/scanf_spec.rb97
-rw-r--r--spec/ruby/library/securerandom/base64_spec.rb4
-rw-r--r--spec/ruby/library/securerandom/bytes_spec.rb8
-rw-r--r--spec/ruby/library/securerandom/hex_spec.rb6
-rw-r--r--spec/ruby/library/securerandom/random_bytes_spec.rb7
-rw-r--r--spec/ruby/library/securerandom/random_number_spec.rb54
-rw-r--r--spec/ruby/library/set/add_spec.rb4
-rw-r--r--spec/ruby/library/set/append_spec.rb4
-rw-r--r--spec/ruby/library/set/case_compare_spec.rb5
-rw-r--r--spec/ruby/library/set/case_equality_spec.rb4
-rw-r--r--spec/ruby/library/set/classify_spec.rb2
-rw-r--r--spec/ruby/library/set/clear_spec.rb2
-rw-r--r--spec/ruby/library/set/collect_spec.rb4
-rw-r--r--spec/ruby/library/set/compare_by_identity_spec.rb268
-rw-r--r--spec/ruby/library/set/constructor_spec.rb2
-rw-r--r--spec/ruby/library/set/delete_if_spec.rb2
-rw-r--r--spec/ruby/library/set/delete_spec.rb2
-rw-r--r--spec/ruby/library/set/difference_spec.rb4
-rw-r--r--spec/ruby/library/set/disjoint_spec.rb23
-rw-r--r--spec/ruby/library/set/divide_spec.rb2
-rw-r--r--spec/ruby/library/set/each_spec.rb2
-rw-r--r--spec/ruby/library/set/empty_spec.rb2
-rw-r--r--spec/ruby/library/set/enumerable/to_set_spec.rb4
-rw-r--r--spec/ruby/library/set/eql_spec.rb2
-rw-r--r--spec/ruby/library/set/equal_value_spec.rb9
-rw-r--r--spec/ruby/library/set/exclusion_spec.rb8
-rw-r--r--spec/ruby/library/set/filter_spec.rb8
-rw-r--r--spec/ruby/library/set/fixtures/set_like.rb31
-rw-r--r--spec/ruby/library/set/flatten_merge_spec.rb4
-rw-r--r--spec/ruby/library/set/flatten_spec.rb19
-rw-r--r--spec/ruby/library/set/hash_spec.rb2
-rw-r--r--spec/ruby/library/set/include_spec.rb4
-rw-r--r--spec/ruby/library/set/initialize_spec.rb26
-rw-r--r--spec/ruby/library/set/inspect_spec.rb4
-rw-r--r--spec/ruby/library/set/intersect_spec.rb23
-rw-r--r--spec/ruby/library/set/intersection_spec.rb4
-rw-r--r--spec/ruby/library/set/keep_if_spec.rb2
-rw-r--r--spec/ruby/library/set/length_spec.rb4
-rw-r--r--spec/ruby/library/set/map_spec.rb4
-rw-r--r--spec/ruby/library/set/member_spec.rb4
-rw-r--r--spec/ruby/library/set/merge_spec.rb6
-rw-r--r--spec/ruby/library/set/minus_spec.rb4
-rw-r--r--spec/ruby/library/set/plus_spec.rb4
-rw-r--r--spec/ruby/library/set/pretty_print_cycle_spec.rb2
-rw-r--r--spec/ruby/library/set/pretty_print_spec.rb2
-rw-r--r--spec/ruby/library/set/proper_subset_spec.rb17
-rw-r--r--spec/ruby/library/set/proper_superset_spec.rb17
-rw-r--r--spec/ruby/library/set/reject_spec.rb2
-rw-r--r--spec/ruby/library/set/replace_spec.rb2
-rw-r--r--spec/ruby/library/set/select_spec.rb42
-rw-r--r--spec/ruby/library/set/shared/difference.rb4
-rw-r--r--spec/ruby/library/set/shared/intersection.rb4
-rw-r--r--spec/ruby/library/set/shared/select.rb42
-rw-r--r--spec/ruby/library/set/shared/union.rb4
-rw-r--r--spec/ruby/library/set/size_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/add_spec.rb8
-rw-r--r--spec/ruby/library/set/sortedset/append_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/case_equality_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/classify_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/clear_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/collect_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/constructor_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/delete_if_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/delete_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/difference_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/divide_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/each_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/empty_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/eql_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/equal_value_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/exclusion_spec.rb8
-rw-r--r--spec/ruby/library/set/sortedset/filter_spec.rb9
-rw-r--r--spec/ruby/library/set/sortedset/flatten_merge_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/flatten_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/hash_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/include_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/initialize_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/inspect_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/intersection_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/keep_if_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/length_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/map_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/member_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/merge_spec.rb6
-rw-r--r--spec/ruby/library/set/sortedset/minus_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/plus_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/proper_subset_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/proper_superset_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/reject_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/replace_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/select_spec.rb34
-rw-r--r--spec/ruby/library/set/sortedset/shared/difference.rb4
-rw-r--r--spec/ruby/library/set/sortedset/shared/intersection.rb4
-rw-r--r--spec/ruby/library/set/sortedset/shared/select.rb35
-rw-r--r--spec/ruby/library/set/sortedset/shared/union.rb4
-rw-r--r--spec/ruby/library/set/sortedset/size_spec.rb4
-rw-r--r--spec/ruby/library/set/sortedset/subset_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/subtract_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/superset_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/to_a_spec.rb2
-rw-r--r--spec/ruby/library/set/sortedset/union_spec.rb4
-rw-r--r--spec/ruby/library/set/subset_spec.rb17
-rw-r--r--spec/ruby/library/set/subtract_spec.rb2
-rw-r--r--spec/ruby/library/set/superset_spec.rb17
-rw-r--r--spec/ruby/library/set/to_a_spec.rb2
-rw-r--r--spec/ruby/library/set/to_s_spec.rb2
-rw-r--r--spec/ruby/library/set/union_spec.rb4
-rw-r--r--spec/ruby/library/shellwords/shellwords_spec.rb14
-rw-r--r--spec/ruby/library/singleton/allocate_spec.rb6
-rw-r--r--spec/ruby/library/singleton/clone_spec.rb6
-rw-r--r--spec/ruby/library/singleton/dump_spec.rb4
-rw-r--r--spec/ruby/library/singleton/dup_spec.rb6
-rw-r--r--spec/ruby/library/singleton/instance_spec.rb4
-rw-r--r--spec/ruby/library/singleton/load_spec.rb4
-rw-r--r--spec/ruby/library/singleton/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/addrinfo/afamily_spec.rb5
-rw-r--r--spec/ruby/library/socket/addrinfo/bind_spec.rb5
-rw-r--r--spec/ruby/library/socket/addrinfo/canonname_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/connect_from_spec.rb75
-rw-r--r--spec/ruby/library/socket/addrinfo/connect_spec.rb35
-rw-r--r--spec/ruby/library/socket/addrinfo/connect_to_spec.rb75
-rw-r--r--spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb115
-rw-r--r--spec/ruby/library/socket/addrinfo/foreach_spec.rb9
-rw-r--r--spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb91
-rw-r--r--spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb40
-rw-r--r--spec/ruby/library/socket/addrinfo/initialize_spec.rb340
-rw-r--r--spec/ruby/library/socket/addrinfo/inspect_sockaddr_spec.rb55
-rw-r--r--spec/ruby/library/socket/addrinfo/inspect_spec.rb65
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_address_spec.rb38
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_port_spec.rb7
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_spec.rb36
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb7
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb17
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb39
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_spec.rb5
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb23
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb9
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb19
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb26
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb23
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_spec.rb5
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb71
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb15
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/listen_spec.rb34
-rw-r--r--spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb84
-rw-r--r--spec/ruby/library/socket/addrinfo/marshal_load_spec.rb35
-rw-r--r--spec/ruby/library/socket/addrinfo/pfamily_spec.rb11
-rw-r--r--spec/ruby/library/socket/addrinfo/protocol_spec.rb28
-rw-r--r--spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb24
-rw-r--r--spec/ruby/library/socket/addrinfo/socktype_spec.rb27
-rw-r--r--spec/ruby/library/socket/addrinfo/tcp_spec.rb42
-rw-r--r--spec/ruby/library/socket/addrinfo/to_s_spec.rb7
-rw-r--r--spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb7
-rw-r--r--spec/ruby/library/socket/addrinfo/udp_spec.rb42
-rw-r--r--spec/ruby/library/socket/addrinfo/unix_path_spec.rb23
-rw-r--r--spec/ruby/library/socket/addrinfo/unix_spec.rb39
-rw-r--r--spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb33
-rw-r--r--spec/ruby/library/socket/ancillarydata/data_spec.rb9
-rw-r--r--spec/ruby/library/socket/ancillarydata/family_spec.rb9
-rw-r--r--spec/ruby/library/socket/ancillarydata/initialize_spec.rb284
-rw-r--r--spec/ruby/library/socket/ancillarydata/int_spec.rb43
-rw-r--r--spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb145
-rw-r--r--spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb11
-rw-r--r--spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_ifindex_spec.rb11
-rw-r--r--spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb89
-rw-r--r--spec/ruby/library/socket/ancillarydata/level_spec.rb9
-rw-r--r--spec/ruby/library/socket/ancillarydata/type_spec.rb9
-rw-r--r--spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb61
-rw-r--r--spec/ruby/library/socket/basicsocket/close_read_spec.rb18
-rw-r--r--spec/ruby/library/socket/basicsocket/close_write_spec.rb18
-rw-r--r--spec/ruby/library/socket/basicsocket/connect_address_spec.rb154
-rw-r--r--spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb68
-rw-r--r--spec/ruby/library/socket/basicsocket/for_fd_spec.rb25
-rw-r--r--spec/ruby/library/socket/basicsocket/getpeereid_spec.rb36
-rw-r--r--spec/ruby/library/socket/basicsocket/getpeername_spec.rb9
-rw-r--r--spec/ruby/library/socket/basicsocket/getsockname_spec.rb8
-rw-r--r--spec/ruby/library/socket/basicsocket/getsockopt_spec.rb148
-rw-r--r--spec/ruby/library/socket/basicsocket/ioctl_spec.rb3
-rw-r--r--spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb46
-rw-r--r--spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb71
-rw-r--r--spec/ruby/library/socket/basicsocket/recv_spec.rb91
-rw-r--r--spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb209
-rw-r--r--spec/ruby/library/socket/basicsocket/recvmsg_spec.rb197
-rw-r--r--spec/ruby/library/socket/basicsocket/send_spec.rb131
-rw-r--r--spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb113
-rw-r--r--spec/ruby/library/socket/basicsocket/sendmsg_spec.rb111
-rw-r--r--spec/ruby/library/socket/basicsocket/setsockopt_spec.rb149
-rw-r--r--spec/ruby/library/socket/basicsocket/shutdown_spec.rb155
-rw-r--r--spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb45
-rw-r--r--spec/ruby/library/socket/constants/constants_spec.rb24
-rw-r--r--spec/ruby/library/socket/fixtures/classes.rb85
-rw-r--r--spec/ruby/library/socket/ipsocket/addr_spec.rb67
-rw-r--r--spec/ruby/library/socket/ipsocket/getaddress_spec.rb16
-rw-r--r--spec/ruby/library/socket/ipsocket/peeraddr_spec.rb72
-rw-r--r--spec/ruby/library/socket/ipsocket/recvfrom_spec.rb59
-rw-r--r--spec/ruby/library/socket/option/bool_spec.rb12
-rw-r--r--spec/ruby/library/socket/option/initialize_spec.rb83
-rw-r--r--spec/ruby/library/socket/option/inspect_spec.rb5
-rw-r--r--spec/ruby/library/socket/option/int_spec.rb25
-rw-r--r--spec/ruby/library/socket/option/linger_spec.rb22
-rw-r--r--spec/ruby/library/socket/option/new_spec.rb10
-rw-r--r--spec/ruby/library/socket/shared/pack_sockaddr.rb57
-rw-r--r--spec/ruby/library/socket/shared/recv_nonblock.rb54
-rw-r--r--spec/ruby/library/socket/shared/socketpair.rb115
-rw-r--r--spec/ruby/library/socket/socket/accept_loop_spec.rb84
-rw-r--r--spec/ruby/library/socket/socket/accept_nonblock_spec.rb117
-rw-r--r--spec/ruby/library/socket/socket/accept_spec.rb123
-rw-r--r--spec/ruby/library/socket/socket/bind_spec.rb103
-rw-r--r--spec/ruby/library/socket/socket/connect_nonblock_spec.rb146
-rw-r--r--spec/ruby/library/socket/socket/connect_spec.rb58
-rw-r--r--spec/ruby/library/socket/socket/for_fd_spec.rb5
-rw-r--r--spec/ruby/library/socket/socket/getaddrinfo_spec.rb279
-rw-r--r--spec/ruby/library/socket/socket/gethostbyaddr_spec.rb126
-rw-r--r--spec/ruby/library/socket/socket/gethostbyname_spec.rb132
-rw-r--r--spec/ruby/library/socket/socket/gethostname_spec.rb4
-rw-r--r--spec/ruby/library/socket/socket/getifaddrs_spec.rb117
-rw-r--r--spec/ruby/library/socket/socket/getnameinfo_spec.rb89
-rw-r--r--spec/ruby/library/socket/socket/getservbyname_spec.rb14
-rw-r--r--spec/ruby/library/socket/socket/getservbyport_spec.rb23
-rw-r--r--spec/ruby/library/socket/socket/initialize_spec.rb87
-rw-r--r--spec/ruby/library/socket/socket/ip_address_list_spec.rb50
-rw-r--r--spec/ruby/library/socket/socket/ipv6only_bang_spec.rb20
-rw-r--r--spec/ruby/library/socket/socket/listen_spec.rb52
-rw-r--r--spec/ruby/library/socket/socket/local_address_spec.rb43
-rw-r--r--spec/ruby/library/socket/socket/new_spec.rb4
-rw-r--r--spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/pack_sockaddr_un_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/pair_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb120
-rw-r--r--spec/ruby/library/socket/socket/recvfrom_spec.rb94
-rw-r--r--spec/ruby/library/socket/socket/remote_address_spec.rb54
-rw-r--r--spec/ruby/library/socket/socket/sockaddr_in_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/sockaddr_un_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/socket_spec.rb4
-rw-r--r--spec/ruby/library/socket/socket/socketpair_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/sysaccept_spec.rb93
-rw-r--r--spec/ruby/library/socket/socket/tcp_server_loop_spec.rb54
-rw-r--r--spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb39
-rw-r--r--spec/ruby/library/socket/socket/tcp_spec.rb70
-rw-r--r--spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb47
-rw-r--r--spec/ruby/library/socket/socket/udp_server_loop_spec.rb57
-rw-r--r--spec/ruby/library/socket/socket/udp_server_recv_spec.rb35
-rw-r--r--spec/ruby/library/socket/socket/udp_server_sockets_spec.rb39
-rw-r--r--spec/ruby/library/socket/socket/unix_server_loop_spec.rb58
-rw-r--r--spec/ruby/library/socket/socket/unix_server_socket_spec.rb48
-rw-r--r--spec/ruby/library/socket/socket/unix_spec.rb45
-rw-r--r--spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb33
-rw-r--r--spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb12
-rw-r--r--spec/ruby/library/socket/spec_helper.rb13
-rw-r--r--spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb53
-rw-r--r--spec/ruby/library/socket/tcpserver/accept_spec.rb41
-rw-r--r--spec/ruby/library/socket/tcpserver/gets_spec.rb6
-rw-r--r--spec/ruby/library/socket/tcpserver/initialize_spec.rb101
-rw-r--r--spec/ruby/library/socket/tcpserver/listen_spec.rb28
-rw-r--r--spec/ruby/library/socket/tcpserver/new_spec.rb61
-rw-r--r--spec/ruby/library/socket/tcpserver/sysaccept_spec.rb46
-rw-r--r--spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb64
-rw-r--r--spec/ruby/library/socket/tcpsocket/initialize_spec.rb61
-rw-r--r--spec/ruby/library/socket/tcpsocket/local_address_spec.rb73
-rw-r--r--spec/ruby/library/socket/tcpsocket/new_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpsocket/open_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb6
-rw-r--r--spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb12
-rw-r--r--spec/ruby/library/socket/tcpsocket/recv_spec.rb28
-rw-r--r--spec/ruby/library/socket/tcpsocket/remote_address_spec.rb72
-rw-r--r--spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb4
-rw-r--r--spec/ruby/library/socket/tcpsocket/shared/new.rb10
-rw-r--r--spec/ruby/library/socket/udpsocket/bind_spec.rb53
-rw-r--r--spec/ruby/library/socket/udpsocket/connect_spec.rb35
-rw-r--r--spec/ruby/library/socket/udpsocket/initialize_spec.rb40
-rw-r--r--spec/ruby/library/socket/udpsocket/inspect_spec.rb25
-rw-r--r--spec/ruby/library/socket/udpsocket/local_address_spec.rb80
-rw-r--r--spec/ruby/library/socket/udpsocket/new_spec.rb8
-rw-r--r--spec/ruby/library/socket/udpsocket/open_spec.rb4
-rw-r--r--spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb95
-rw-r--r--spec/ruby/library/socket/udpsocket/remote_address_spec.rb79
-rw-r--r--spec/ruby/library/socket/udpsocket/send_spec.rb90
-rw-r--r--spec/ruby/library/socket/udpsocket/write_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb64
-rw-r--r--spec/ruby/library/socket/unixserver/accept_spec.rb60
-rw-r--r--spec/ruby/library/socket/unixserver/for_fd_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixserver/initialize_spec.rb28
-rw-r--r--spec/ruby/library/socket/unixserver/listen_spec.rb21
-rw-r--r--spec/ruby/library/socket/unixserver/new_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixserver/open_spec.rb5
-rw-r--r--spec/ruby/library/socket/unixserver/shared/new.rb5
-rw-r--r--spec/ruby/library/socket/unixserver/sysaccept_spec.rb52
-rw-r--r--spec/ruby/library/socket/unixsocket/addr_spec.rb14
-rw-r--r--spec/ruby/library/socket/unixsocket/initialize_spec.rb38
-rw-r--r--spec/ruby/library/socket/unixsocket/inspect_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixsocket/local_address_spec.rb96
-rw-r--r--spec/ruby/library/socket/unixsocket/new_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixsocket/open_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/pair_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/partially_closable_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/path_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixsocket/peeraddr_spec.rb8
-rw-r--r--spec/ruby/library/socket/unixsocket/recv_io_spec.rb49
-rw-r--r--spec/ruby/library/socket/unixsocket/recvfrom_spec.rb57
-rw-r--r--spec/ruby/library/socket/unixsocket/remote_address_spec.rb45
-rw-r--r--spec/ruby/library/socket/unixsocket/send_io_spec.rb27
-rw-r--r--spec/ruby/library/socket/unixsocket/shared/new.rb4
-rw-r--r--spec/ruby/library/socket/unixsocket/socketpair_spec.rb40
-rw-r--r--spec/ruby/library/stringio/append_spec.rb16
-rw-r--r--spec/ruby/library/stringio/binmode_spec.rb4
-rw-r--r--spec/ruby/library/stringio/bytes_spec.rb4
-rw-r--r--spec/ruby/library/stringio/chars_spec.rb4
-rw-r--r--spec/ruby/library/stringio/close_read_spec.rb15
-rw-r--r--spec/ruby/library/stringio/close_spec.rb23
-rw-r--r--spec/ruby/library/stringio/close_write_spec.rb15
-rw-r--r--spec/ruby/library/stringio/closed_read_spec.rb4
-rw-r--r--spec/ruby/library/stringio/closed_spec.rb4
-rw-r--r--spec/ruby/library/stringio/closed_write_spec.rb4
-rw-r--r--spec/ruby/library/stringio/codepoints_spec.rb8
-rw-r--r--spec/ruby/library/stringio/each_byte_spec.rb4
-rw-r--r--spec/ruby/library/stringio/each_char_spec.rb4
-rw-r--r--spec/ruby/library/stringio/each_codepoint_spec.rb9
-rw-r--r--spec/ruby/library/stringio/each_line_spec.rb12
-rw-r--r--spec/ruby/library/stringio/each_spec.rb12
-rw-r--r--spec/ruby/library/stringio/eof_spec.rb6
-rw-r--r--spec/ruby/library/stringio/external_encoding_spec.rb24
-rw-r--r--spec/ruby/library/stringio/fcntl_spec.rb6
-rw-r--r--spec/ruby/library/stringio/fileno_spec.rb6
-rw-r--r--spec/ruby/library/stringio/flush_spec.rb4
-rw-r--r--spec/ruby/library/stringio/fsync_spec.rb4
-rw-r--r--spec/ruby/library/stringio/getbyte_spec.rb10
-rw-r--r--spec/ruby/library/stringio/getc_spec.rb10
-rw-r--r--spec/ruby/library/stringio/getch_spec.rb32
-rw-r--r--spec/ruby/library/stringio/gets_spec.rb16
-rw-r--r--spec/ruby/library/stringio/initialize_spec.rb39
-rw-r--r--spec/ruby/library/stringio/internal_encoding_spec.rb2
-rw-r--r--spec/ruby/library/stringio/isatty_spec.rb6
-rw-r--r--spec/ruby/library/stringio/length_spec.rb6
-rw-r--r--spec/ruby/library/stringio/lineno_spec.rb2
-rw-r--r--spec/ruby/library/stringio/lines_spec.rb10
-rw-r--r--spec/ruby/library/stringio/open_spec.rb13
-rw-r--r--spec/ruby/library/stringio/path_spec.rb6
-rw-r--r--spec/ruby/library/stringio/pid_spec.rb4
-rw-r--r--spec/ruby/library/stringio/pos_spec.rb8
-rw-r--r--spec/ruby/library/stringio/print_spec.rb8
-rw-r--r--spec/ruby/library/stringio/printf_spec.rb13
-rw-r--r--spec/ruby/library/stringio/putc_spec.rb10
-rw-r--r--spec/ruby/library/stringio/puts_spec.rb16
-rw-r--r--spec/ruby/library/stringio/read_nonblock_spec.rb28
-rw-r--r--spec/ruby/library/stringio/read_spec.rb4
-rw-r--r--spec/ruby/library/stringio/readbyte_spec.rb8
-rw-r--r--spec/ruby/library/stringio/readchar_spec.rb8
-rw-r--r--spec/ruby/library/stringio/readline_spec.rb20
-rw-r--r--spec/ruby/library/stringio/readlines_spec.rb18
-rw-r--r--spec/ruby/library/stringio/readpartial_spec.rb14
-rw-r--r--spec/ruby/library/stringio/reopen_spec.rb48
-rw-r--r--spec/ruby/library/stringio/rewind_spec.rb4
-rw-r--r--spec/ruby/library/stringio/seek_spec.rb18
-rw-r--r--spec/ruby/library/stringio/set_encoding_spec.rb16
-rw-r--r--spec/ruby/library/stringio/shared/codepoints.rb6
-rw-r--r--spec/ruby/library/stringio/shared/each.rb4
-rw-r--r--spec/ruby/library/stringio/shared/each_byte.rb4
-rw-r--r--spec/ruby/library/stringio/shared/each_char.rb4
-rw-r--r--spec/ruby/library/stringio/shared/getc.rb4
-rw-r--r--spec/ruby/library/stringio/shared/read.rb16
-rw-r--r--spec/ruby/library/stringio/shared/readchar.rb6
-rw-r--r--spec/ruby/library/stringio/shared/sysread.rb2
-rw-r--r--spec/ruby/library/stringio/shared/write.rb12
-rw-r--r--spec/ruby/library/stringio/size_spec.rb6
-rw-r--r--spec/ruby/library/stringio/string_spec.rb6
-rw-r--r--spec/ruby/library/stringio/stringio_spec.rb3
-rw-r--r--spec/ruby/library/stringio/sync_spec.rb4
-rw-r--r--spec/ruby/library/stringio/sysread_spec.rb6
-rw-r--r--spec/ruby/library/stringio/syswrite_spec.rb6
-rw-r--r--spec/ruby/library/stringio/tell_spec.rb6
-rw-r--r--spec/ruby/library/stringio/truncate_spec.rb12
-rw-r--r--spec/ruby/library/stringio/tty_spec.rb6
-rw-r--r--spec/ruby/library/stringio/ungetbyte_spec.rb2
-rw-r--r--spec/ruby/library/stringio/ungetc_spec.rb10
-rw-r--r--spec/ruby/library/stringio/write_nonblock_spec.rb6
-rw-r--r--spec/ruby/library/stringio/write_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/append_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/beginning_of_line_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/bol_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/check_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/check_until_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/clear_spec.rb16
-rw-r--r--spec/ruby/library/stringscanner/concat_spec.rb8
-rw-r--r--spec/ruby/library/stringscanner/dup_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/element_reference_spec.rb11
-rw-r--r--spec/ruby/library/stringscanner/empty_spec.rb16
-rw-r--r--spec/ruby/library/stringscanner/eos_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/exist_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/get_byte_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/getbyte_spec.rb16
-rw-r--r--spec/ruby/library/stringscanner/getch_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/initialize_spec.rb3
-rw-r--r--spec/ruby/library/stringscanner/inspect_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/match_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/matched_size_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/matched_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/must_C_version_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/peek_spec.rb7
-rw-r--r--spec/ruby/library/stringscanner/peep_spec.rb16
-rw-r--r--spec/ruby/library/stringscanner/pointer_spec.rb8
-rw-r--r--spec/ruby/library/stringscanner/pos_spec.rb8
-rw-r--r--spec/ruby/library/stringscanner/post_match_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/pre_match_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/reset_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/rest_size_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/rest_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/restsize_spec.rb16
-rw-r--r--spec/ruby/library/stringscanner/scan_full_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/scan_spec.rb66
-rw-r--r--spec/ruby/library/stringscanner/scan_until_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/search_full_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/shared/concat.rb12
-rw-r--r--spec/ruby/library/stringscanner/shared/extract_range.rb16
-rw-r--r--spec/ruby/library/stringscanner/shared/extract_range_matched.rb14
-rw-r--r--spec/ruby/library/stringscanner/shared/peek.rb16
-rw-r--r--spec/ruby/library/stringscanner/shared/pos.rb4
-rw-r--r--spec/ruby/library/stringscanner/skip_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/skip_until_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/string_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/terminate_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/unscan_spec.rb6
-rw-r--r--spec/ruby/library/syslog/alert_spec.rb4
-rw-r--r--spec/ruby/library/syslog/close_spec.rb6
-rw-r--r--spec/ruby/library/syslog/constants_spec.rb2
-rw-r--r--spec/ruby/library/syslog/crit_spec.rb4
-rw-r--r--spec/ruby/library/syslog/debug_spec.rb4
-rw-r--r--spec/ruby/library/syslog/emerg_spec.rb4
-rw-r--r--spec/ruby/library/syslog/err_spec.rb4
-rw-r--r--spec/ruby/library/syslog/facility_spec.rb2
-rw-r--r--spec/ruby/library/syslog/ident_spec.rb2
-rw-r--r--spec/ruby/library/syslog/info_spec.rb4
-rw-r--r--spec/ruby/library/syslog/inspect_spec.rb2
-rw-r--r--spec/ruby/library/syslog/instance_spec.rb2
-rw-r--r--spec/ruby/library/syslog/log_spec.rb20
-rw-r--r--spec/ruby/library/syslog/mask_spec.rb8
-rw-r--r--spec/ruby/library/syslog/notice_spec.rb4
-rw-r--r--spec/ruby/library/syslog/open_spec.rb8
-rw-r--r--spec/ruby/library/syslog/opened_spec.rb2
-rw-r--r--spec/ruby/library/syslog/options_spec.rb2
-rw-r--r--spec/ruby/library/syslog/reopen_spec.rb4
-rw-r--r--spec/ruby/library/syslog/shared/log.rb13
-rw-r--r--spec/ruby/library/syslog/shared/reopen.rb4
-rw-r--r--spec/ruby/library/syslog/warning_spec.rb4
-rw-r--r--spec/ruby/library/tempfile/_close_spec.rb2
-rw-r--r--spec/ruby/library/tempfile/callback_spec.rb2
-rw-r--r--spec/ruby/library/tempfile/close_spec.rb8
-rw-r--r--spec/ruby/library/tempfile/delete_spec.rb4
-rw-r--r--spec/ruby/library/tempfile/initialize_spec.rb11
-rw-r--r--spec/ruby/library/tempfile/length_spec.rb4
-rw-r--r--spec/ruby/library/tempfile/open_spec.rb19
-rw-r--r--spec/ruby/library/tempfile/path_spec.rb2
-rw-r--r--spec/ruby/library/tempfile/shared/unlink.rb2
-rw-r--r--spec/ruby/library/tempfile/size_spec.rb4
-rw-r--r--spec/ruby/library/tempfile/unlink_spec.rb4
-rw-r--r--spec/ruby/library/thread/exclusive_spec.rb12
-rw-r--r--spec/ruby/library/thread/queue/append_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/clear_spec.rb9
-rw-r--r--spec/ruby/library/thread/queue/close_spec.rb9
-rw-r--r--spec/ruby/library/thread/queue/closed_spec.rb9
-rw-r--r--spec/ruby/library/thread/queue/deq_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/empty_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/enq_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/length_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/num_waiting_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/pop_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/push_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/shift_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue/size_spec.rb7
-rw-r--r--spec/ruby/library/thread/queue_spec.rb8
-rw-r--r--spec/ruby/library/thread/shared/queue/clear.rb10
-rw-r--r--spec/ruby/library/thread/shared/queue/close.rb26
-rw-r--r--spec/ruby/library/thread/shared/queue/closed.rb (renamed from spec/ruby/shared/queue/closed.rb)0
-rw-r--r--spec/ruby/library/thread/shared/queue/deque.rb37
-rw-r--r--spec/ruby/library/thread/shared/queue/empty.rb (renamed from spec/ruby/shared/queue/empty.rb)0
-rw-r--r--spec/ruby/library/thread/shared/queue/enque.rb10
-rw-r--r--spec/ruby/library/thread/shared/queue/length.rb (renamed from spec/ruby/shared/queue/length.rb)0
-rw-r--r--spec/ruby/library/thread/shared/queue/num_waiting.rb (renamed from spec/ruby/shared/queue/num_waiting.rb)0
-rw-r--r--spec/ruby/library/thread/sizedqueue/append_spec.rb12
-rw-r--r--spec/ruby/library/thread/sizedqueue/clear_spec.rb9
-rw-r--r--spec/ruby/library/thread/sizedqueue/close_spec.rb9
-rw-r--r--spec/ruby/library/thread/sizedqueue/closed_spec.rb9
-rw-r--r--spec/ruby/library/thread/sizedqueue/deq_spec.rb7
-rw-r--r--spec/ruby/library/thread/sizedqueue/empty_spec.rb7
-rw-r--r--spec/ruby/library/thread/sizedqueue/enq_spec.rb12
-rw-r--r--spec/ruby/library/thread/sizedqueue/length_spec.rb7
-rw-r--r--spec/ruby/library/thread/sizedqueue/max_spec.rb52
-rw-r--r--spec/ruby/library/thread/sizedqueue/new_spec.rb25
-rw-r--r--spec/ruby/library/thread/sizedqueue/num_waiting_spec.rb18
-rw-r--r--spec/ruby/library/thread/sizedqueue/pop_spec.rb7
-rw-r--r--spec/ruby/library/thread/sizedqueue/push_spec.rb12
-rw-r--r--spec/ruby/library/thread/sizedqueue/shared/enque.rb34
-rw-r--r--spec/ruby/library/thread/sizedqueue/shift_spec.rb7
-rw-r--r--spec/ruby/library/thread/sizedqueue/size_spec.rb7
-rw-r--r--spec/ruby/library/thread/sizedqueue_spec.rb8
-rw-r--r--spec/ruby/library/time/httpdate_spec.rb2
-rw-r--r--spec/ruby/library/time/iso8601_spec.rb4
-rw-r--r--spec/ruby/library/time/rfc2822_spec.rb4
-rw-r--r--spec/ruby/library/time/rfc822_spec.rb4
-rw-r--r--spec/ruby/library/time/shared/rfc2822.rb2
-rw-r--r--spec/ruby/library/time/to_date_spec.rb2
-rw-r--r--spec/ruby/library/time/to_datetime_spec.rb2
-rw-r--r--spec/ruby/library/time/to_time_spec.rb20
-rw-r--r--spec/ruby/library/time/xmlschema_spec.rb4
-rw-r--r--spec/ruby/library/timeout/error_spec.rb2
-rw-r--r--spec/ruby/library/timeout/timeout_spec.rb21
-rw-r--r--spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb12
-rw-r--r--spec/ruby/library/tmpdir/dir/tmpdir_spec.rb2
-rw-r--r--spec/ruby/library/uri/decode_www_form_component_spec.rb2
-rw-r--r--spec/ruby/library/uri/decode_www_form_spec.rb2
-rw-r--r--spec/ruby/library/uri/encode_www_form_component_spec.rb2
-rw-r--r--spec/ruby/library/uri/encode_www_form_spec.rb2
-rw-r--r--spec/ruby/library/uri/eql_spec.rb6
-rw-r--r--spec/ruby/library/uri/equality_spec.rb6
-rw-r--r--spec/ruby/library/uri/escape/decode_spec.rb2
-rw-r--r--spec/ruby/library/uri/escape/encode_spec.rb2
-rw-r--r--spec/ruby/library/uri/escape/escape_spec.rb2
-rw-r--r--spec/ruby/library/uri/escape/unescape_spec.rb2
-rw-r--r--spec/ruby/library/uri/extract_spec.rb2
-rw-r--r--spec/ruby/library/uri/ftp/build_spec.rb2
-rw-r--r--spec/ruby/library/uri/ftp/merge_spec.rb2
-rw-r--r--spec/ruby/library/uri/ftp/new2_spec.rb2
-rw-r--r--spec/ruby/library/uri/ftp/path_spec.rb2
-rw-r--r--spec/ruby/library/uri/ftp/set_typecode_spec.rb2
-rw-r--r--spec/ruby/library/uri/ftp/to_s_spec.rb2
-rw-r--r--spec/ruby/library/uri/ftp/typecode_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/absolute_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/build2_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/build_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/coerce_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/component_ary_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/component_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/default_port_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/eql_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/equal_value_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/fragment_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/hash_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/hierarchical_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/host_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/inspect_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/merge_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/minus_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/normalize_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/opaque_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/password_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/path_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/plus_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/port_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/query_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/registry_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/relative_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/route_from_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/route_to_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/scheme_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/select_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_fragment_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_host_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_opaque_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_password_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_path_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_port_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_query_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_registry_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_scheme_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_user_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/set_userinfo_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/to_s_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/use_registry_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/user_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/userinfo_spec.rb2
-rw-r--r--spec/ruby/library/uri/http/build_spec.rb2
-rw-r--r--spec/ruby/library/uri/http/request_uri_spec.rb2
-rw-r--r--spec/ruby/library/uri/join_spec.rb4
-rw-r--r--spec/ruby/library/uri/ldap/attributes_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/build_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/dn_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/extensions_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/filter_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/hierarchical_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/scope_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/set_attributes_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/set_dn_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/set_extensions_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/set_filter_spec.rb2
-rw-r--r--spec/ruby/library/uri/ldap/set_scope_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/build_spec.rb10
-rw-r--r--spec/ruby/library/uri/mailto/headers_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/set_headers_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/set_to_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/to_mailtext_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/to_rfc822text_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/to_s_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/to_spec.rb2
-rw-r--r--spec/ruby/library/uri/merge_spec.rb2
-rw-r--r--spec/ruby/library/uri/normalize_spec.rb4
-rw-r--r--spec/ruby/library/uri/parse_spec.rb4
-rw-r--r--spec/ruby/library/uri/parser/escape_spec.rb2
-rw-r--r--spec/ruby/library/uri/parser/extract_spec.rb4
-rw-r--r--spec/ruby/library/uri/parser/inspect_spec.rb2
-rw-r--r--spec/ruby/library/uri/parser/join_spec.rb4
-rw-r--r--spec/ruby/library/uri/parser/make_regexp_spec.rb2
-rw-r--r--spec/ruby/library/uri/parser/parse_spec.rb6
-rw-r--r--spec/ruby/library/uri/parser/split_spec.rb2
-rw-r--r--spec/ruby/library/uri/parser/unescape_spec.rb2
-rw-r--r--spec/ruby/library/uri/plus_spec.rb6
-rw-r--r--spec/ruby/library/uri/regexp_spec.rb2
-rw-r--r--spec/ruby/library/uri/route_from_spec.rb2
-rw-r--r--spec/ruby/library/uri/route_to_spec.rb2
-rw-r--r--spec/ruby/library/uri/select_spec.rb12
-rw-r--r--spec/ruby/library/uri/set_component_spec.rb24
-rw-r--r--spec/ruby/library/uri/shared/join.rb2
-rw-r--r--spec/ruby/library/uri/shared/parse.rb4
-rw-r--r--spec/ruby/library/uri/split_spec.rb2
-rw-r--r--spec/ruby/library/uri/uri_spec.rb4
-rw-r--r--spec/ruby/library/uri/util/make_components_hash_spec.rb2
-rw-r--r--spec/ruby/library/weakref/__getobj___spec.rb6
-rw-r--r--spec/ruby/library/weakref/allocate_spec.rb8
-rw-r--r--spec/ruby/library/weakref/new_spec.rb13
-rw-r--r--spec/ruby/library/weakref/send_spec.rb6
-rw-r--r--spec/ruby/library/weakref/weakref_alive_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/fixtures/classes.rb16
-rw-r--r--spec/ruby/library/win32ole/fixtures/event.xml4
-rw-r--r--spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb15
-rw-r--r--spec/ruby/library/win32ole/win32ole/_invoke_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole/codepage_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/connect_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/const_load_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/constants_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/create_guid_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/invoke_spec.rb15
-rw-r--r--spec/ruby/library/win32ole/win32ole/locale_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/new_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb18
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_method_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb18
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb13
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb18
-rw-r--r--spec/ruby/library/win32ole/win32ole/setproperty_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/shared/ole_method.rb18
-rw-r--r--spec/ruby/library/win32ole/win32ole/shared/setproperty.rb22
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/new_spec.rb46
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb104
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb36
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_spec.rb26
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/name_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/new_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/params_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/shared/name.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/visible_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/default_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/input_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/name_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/optional_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/retval_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/shared/name.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/name_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/new_spec.rb21
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/progids_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/shared/name.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/name_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb2
-rw-r--r--spec/ruby/library/yaml/add_builtin_type_spec.rb4
-rw-r--r--spec/ruby/library/yaml/add_domain_type_spec.rb4
-rw-r--r--spec/ruby/library/yaml/add_private_type_spec.rb4
-rw-r--r--spec/ruby/library/yaml/add_ruby_type_spec.rb4
-rw-r--r--spec/ruby/library/yaml/detect_implicit_spec.rb4
-rw-r--r--spec/ruby/library/yaml/dump_spec.rb4
-rw-r--r--spec/ruby/library/yaml/dump_stream_spec.rb4
-rw-r--r--spec/ruby/library/yaml/each_node_spec.rb4
-rw-r--r--spec/ruby/library/yaml/emitter_spec.rb4
-rw-r--r--spec/ruby/library/yaml/fixtures/example_class.rb8
-rw-r--r--spec/ruby/library/yaml/generic_parser_spec.rb4
-rw-r--r--spec/ruby/library/yaml/load_documents_spec.rb8
-rw-r--r--spec/ruby/library/yaml/load_file_spec.rb4
-rw-r--r--spec/ruby/library/yaml/load_spec.rb10
-rw-r--r--spec/ruby/library/yaml/load_stream_spec.rb8
-rw-r--r--spec/ruby/library/yaml/object_maker_spec.rb4
-rw-r--r--spec/ruby/library/yaml/parse_documents_spec.rb4
-rw-r--r--spec/ruby/library/yaml/parse_file_spec.rb10
-rw-r--r--spec/ruby/library/yaml/parse_spec.rb4
-rw-r--r--spec/ruby/library/yaml/parser_spec.rb4
-rw-r--r--spec/ruby/library/yaml/quick_emit_spec.rb4
-rw-r--r--spec/ruby/library/yaml/read_type_class_spec.rb4
-rw-r--r--spec/ruby/library/yaml/tagurize_spec.rb4
-rw-r--r--spec/ruby/library/yaml/to_yaml_spec.rb21
-rw-r--r--spec/ruby/library/yaml/transfer_spec.rb4
-rw-r--r--spec/ruby/library/yaml/try_implicit_spec.rb4
-rw-r--r--spec/ruby/library/zlib/adler32_spec.rb4
-rw-r--r--spec/ruby/library/zlib/crc32_spec.rb6
-rw-r--r--spec/ruby/library/zlib/crc_table_spec.rb2
-rw-r--r--spec/ruby/library/zlib/deflate/append_spec.rb1
-rw-r--r--spec/ruby/library/zlib/deflate/deflate_spec.rb4
-rw-r--r--spec/ruby/library/zlib/deflate/flush_spec.rb1
-rw-r--r--spec/ruby/library/zlib/deflate/new_spec.rb2
-rw-r--r--spec/ruby/library/zlib/deflate/params_spec.rb2
-rw-r--r--spec/ruby/library/zlib/deflate/set_dictionary_spec.rb3
-rw-r--r--spec/ruby/library/zlib/deflate_spec.rb8
-rw-r--r--spec/ruby/library/zlib/gunzip_spec.rb14
-rw-r--r--spec/ruby/library/zlib/gzip_spec.rb15
-rw-r--r--spec/ruby/library/zlib/gzipfile/close_spec.rb7
-rw-r--r--spec/ruby/library/zlib/gzipfile/closed_spec.rb3
-rw-r--r--spec/ruby/library/zlib/gzipfile/comment_spec.rb5
-rw-r--r--spec/ruby/library/zlib/gzipfile/crc_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/finish_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/level_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/mtime_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/orig_name_spec.rb5
-rw-r--r--spec/ruby/library/zlib/gzipfile/os_code_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/sync_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/to_io_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/wrap_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_byte_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_line_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/eof_spec.rb8
-rw-r--r--spec/ruby/library/zlib/gzipreader/getc_spec.rb6
-rw-r--r--spec/ruby/library/zlib/gzipreader/gets_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/lineno_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/new_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/open_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/pos_spec.rb7
-rw-r--r--spec/ruby/library/zlib/gzipreader/read_spec.rb12
-rw-r--r--spec/ruby/library/zlib/gzipreader/readchar_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/readline_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/readlines_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/readpartial_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/rewind_spec.rb5
-rw-r--r--spec/ruby/library/zlib/gzipreader/shared/each.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/tell_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb12
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetc_spec.rb36
-rw-r--r--spec/ruby/library/zlib/gzipreader/unused_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/append_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipwriter/comment_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/flush_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/mtime_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipwriter/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/open_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/pos_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/print_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/printf_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/putc_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/puts_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/tell_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/write_spec.rb4
-rw-r--r--spec/ruby/library/zlib/inflate/append_spec.rb4
-rw-r--r--spec/ruby/library/zlib/inflate/inflate_spec.rb4
-rw-r--r--spec/ruby/library/zlib/inflate/new_spec.rb2
-rw-r--r--spec/ruby/library/zlib/inflate/set_dictionary_spec.rb3
-rw-r--r--spec/ruby/library/zlib/inflate/sync_point_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate/sync_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate_spec.rb8
-rw-r--r--spec/ruby/library/zlib/zlib_version_spec.rb9
-rw-r--r--spec/ruby/library/zlib/zstream/adler_spec.rb2
-rw-r--r--spec/ruby/library/zlib/zstream/avail_in_spec.rb2
-rw-r--r--spec/ruby/library/zlib/zstream/avail_out_spec.rb2
-rw-r--r--spec/ruby/library/zlib/zstream/close_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/closed_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/data_type_spec.rb2
-rw-r--r--spec/ruby/library/zlib/zstream/end_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/ended_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/finish_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/finished_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/flush_next_in_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/flush_next_out_spec.rb4
-rw-r--r--spec/ruby/library/zlib/zstream/reset_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/stream_end_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/total_in_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/total_out_spec.rb1
-rw-r--r--spec/ruby/optional/capi/README2
-rw-r--r--spec/ruby/optional/capi/array_spec.rb26
-rw-r--r--spec/ruby/optional/capi/bignum_spec.rb28
-rw-r--r--spec/ruby/optional/capi/boolean_spec.rb2
-rw-r--r--spec/ruby/optional/capi/class_spec.rb94
-rw-r--r--spec/ruby/optional/capi/complex_spec.rb2
-rw-r--r--spec/ruby/optional/capi/constants_spec.rb14
-rw-r--r--spec/ruby/optional/capi/data_spec.rb11
-rw-r--r--spec/ruby/optional/capi/encoding_spec.rb103
-rw-r--r--spec/ruby/optional/capi/enumerator_spec.rb29
-rw-r--r--spec/ruby/optional/capi/exception_spec.rb8
-rw-r--r--spec/ruby/optional/capi/ext/array_spec.c203
-rw-r--r--spec/ruby/optional/capi/ext/bignum_spec.c55
-rw-r--r--spec/ruby/optional/capi/ext/boolean_spec.c3
-rw-r--r--spec/ruby/optional/capi/ext/class_spec.c123
-rw-r--r--spec/ruby/optional/capi/ext/complex_spec.c33
-rw-r--r--spec/ruby/optional/capi/ext/constants_spec.c317
-rw-r--r--spec/ruby/optional/capi/ext/data_spec.c22
-rw-r--r--spec/ruby/optional/capi/ext/encoding_spec.c187
-rw-r--r--spec/ruby/optional/capi/ext/enumerator_spec.c19
-rw-r--r--spec/ruby/optional/capi/ext/exception_spec.c28
-rw-r--r--spec/ruby/optional/capi/ext/file_spec.c15
-rw-r--r--spec/ruby/optional/capi/ext/fixnum_spec.c28
-rw-r--r--spec/ruby/optional/capi/ext/float_spec.c18
-rw-r--r--spec/ruby/optional/capi/ext/gc_spec.c29
-rw-r--r--spec/ruby/optional/capi/ext/globals_spec.c83
-rw-r--r--spec/ruby/optional/capi/ext/hash_spec.c89
-rw-r--r--spec/ruby/optional/capi/ext/integer_spec.c8
-rw-r--r--spec/ruby/optional/capi/ext/io_spec.c129
-rw-r--r--spec/ruby/optional/capi/ext/kernel_spec.c186
-rw-r--r--spec/ruby/optional/capi/ext/marshal_spec.c14
-rw-r--r--spec/ruby/optional/capi/ext/module_spec.c109
-rw-r--r--spec/ruby/optional/capi/ext/mutex_spec.c38
-rw-r--r--spec/ruby/optional/capi/ext/numeric_spec.c149
-rw-r--r--spec/ruby/optional/capi/ext/object_spec.c253
-rw-r--r--spec/ruby/optional/capi/ext/proc_spec.c21
-rw-r--r--spec/ruby/optional/capi/ext/range_spec.c18
-rw-r--r--spec/ruby/optional/capi/ext/rational_spec.c43
-rw-r--r--spec/ruby/optional/capi/ext/regexp_spec.c31
-rw-r--r--spec/ruby/optional/capi/ext/rubyspec.h587
-rw-r--r--spec/ruby/optional/capi/ext/st_spec.c12
-rw-r--r--spec/ruby/optional/capi/ext/string_spec.c385
-rw-r--r--spec/ruby/optional/capi/ext/struct_spec.c48
-rw-r--r--spec/ruby/optional/capi/ext/symbol_spec.c50
-rw-r--r--spec/ruby/optional/capi/ext/thread_spec.c56
-rw-r--r--spec/ruby/optional/capi/ext/time_spec.c48
-rw-r--r--spec/ruby/optional/capi/ext/typed_data_spec.c22
-rw-r--r--spec/ruby/optional/capi/ext/util_spec.c65
-rw-r--r--spec/ruby/optional/capi/file_spec.rb4
-rw-r--r--spec/ruby/optional/capi/fixnum_spec.rb113
-rw-r--r--spec/ruby/optional/capi/fixtures/class.rb11
-rw-r--r--spec/ruby/optional/capi/float_spec.rb2
-rw-r--r--spec/ruby/optional/capi/gc_spec.rb17
-rw-r--r--spec/ruby/optional/capi/globals_spec.rb8
-rw-r--r--spec/ruby/optional/capi/hash_spec.rb24
-rw-r--r--spec/ruby/optional/capi/integer_spec.rb2
-rw-r--r--spec/ruby/optional/capi/io_spec.rb59
-rw-r--r--spec/ruby/optional/capi/kernel_spec.rb159
-rw-r--r--spec/ruby/optional/capi/marshal_spec.rb2
-rw-r--r--spec/ruby/optional/capi/module_spec.rb47
-rw-r--r--spec/ruby/optional/capi/mutex_spec.rb17
-rw-r--r--spec/ruby/optional/capi/numeric_spec.rb264
-rw-r--r--spec/ruby/optional/capi/object_spec.rb203
-rw-r--r--spec/ruby/optional/capi/proc_spec.rb48
-rw-r--r--spec/ruby/optional/capi/rake_helper.rb1
-rw-r--r--spec/ruby/optional/capi/range_spec.rb8
-rw-r--r--spec/ruby/optional/capi/rational_spec.rb2
-rw-r--r--spec/ruby/optional/capi/regexp_spec.rb2
-rw-r--r--spec/ruby/optional/capi/spec_helper.rb58
-rw-r--r--spec/ruby/optional/capi/st_spec.rb2
-rw-r--r--spec/ruby/optional/capi/string_spec.rb388
-rw-r--r--spec/ruby/optional/capi/struct_spec.rb42
-rw-r--r--spec/ruby/optional/capi/symbol_spec.rb2
-rw-r--r--spec/ruby/optional/capi/thread_spec.rb40
-rw-r--r--spec/ruby/optional/capi/time_spec.rb80
-rw-r--r--spec/ruby/optional/capi/typed_data_spec.rb18
-rw-r--r--spec/ruby/optional/capi/util_spec.rb88
-rw-r--r--spec/ruby/security/cve_2010_1330_spec.rb21
-rw-r--r--spec/ruby/security/cve_2011_4815_spec.rb14
-rw-r--r--spec/ruby/security/cve_2013_4164_spec.rb2
-rw-r--r--spec/ruby/security/cve_2014_8080_spec.rb8
-rw-r--r--spec/ruby/security/cve_2017_17742_spec.rb34
-rw-r--r--spec/ruby/security/cve_2018_16396_spec.rb25
-rw-r--r--spec/ruby/security/cve_2018_6914_spec.rb55
-rw-r--r--spec/ruby/security/cve_2018_8778_spec.rb12
-rw-r--r--spec/ruby/security/cve_2018_8779_spec.rb30
-rw-r--r--spec/ruby/security/cve_2018_8780_spec.rb45
-rw-r--r--spec/ruby/security/cve_2019_8321_spec.rb22
-rw-r--r--spec/ruby/security/cve_2019_8322_spec.rb23
-rw-r--r--spec/ruby/security/cve_2019_8323_spec.rb38
-rw-r--r--spec/ruby/security/cve_2019_8325_spec.rb38
-rw-r--r--spec/ruby/shared/basicobject/method_missing.rb36
-rw-r--r--spec/ruby/shared/basicobject/send.rb28
-rw-r--r--spec/ruby/shared/complex/Complex.rb133
-rw-r--r--spec/ruby/shared/complex/abs.rb12
-rw-r--r--spec/ruby/shared/complex/abs2.rb12
-rw-r--r--spec/ruby/shared/complex/arg.rb (renamed from spec/ruby/core/complex/shared/arg.rb)0
-rw-r--r--spec/ruby/shared/complex/coerce.rb70
-rw-r--r--spec/ruby/shared/complex/conjugate.rb (renamed from spec/ruby/core/complex/shared/conjugate.rb)0
-rw-r--r--spec/ruby/shared/complex/constants.rb7
-rw-r--r--spec/ruby/shared/complex/denominator.rb13
-rw-r--r--spec/ruby/shared/complex/divide.rb84
-rw-r--r--spec/ruby/shared/complex/equal_value.rb93
-rw-r--r--spec/ruby/shared/complex/exponent.rb61
-rw-r--r--spec/ruby/shared/complex/float/arg.rb38
-rw-r--r--spec/ruby/shared/complex/hash.rb16
-rw-r--r--spec/ruby/shared/complex/image.rb10
-rw-r--r--spec/ruby/shared/complex/inspect.rb14
-rw-r--r--spec/ruby/shared/complex/minus.rb45
-rw-r--r--spec/ruby/shared/complex/multiply.rb49
-rw-r--r--spec/ruby/shared/complex/numerator.rb19
-rw-r--r--spec/ruby/shared/complex/numeric/arg.rb38
-rw-r--r--spec/ruby/shared/complex/numeric/conj.rb20
-rw-r--r--spec/ruby/shared/complex/numeric/imag.rb26
-rw-r--r--spec/ruby/shared/complex/numeric/polar.rb50
-rw-r--r--spec/ruby/shared/complex/numeric/real.rb30
-rw-r--r--spec/ruby/shared/complex/plus.rb45
-rw-r--r--spec/ruby/shared/complex/polar.rb22
-rw-r--r--spec/ruby/shared/complex/real.rb8
-rw-r--r--spec/ruby/shared/complex/rect.rb96
-rw-r--r--spec/ruby/shared/complex/to_s.rb44
-rw-r--r--spec/ruby/shared/enumerator/each.rb89
-rw-r--r--spec/ruby/shared/enumerator/enum_cons.rb12
-rw-r--r--spec/ruby/shared/enumerator/new.rb42
-rw-r--r--spec/ruby/shared/enumerator/next.rb28
-rw-r--r--spec/ruby/shared/enumerator/rewind.rb39
-rw-r--r--spec/ruby/shared/enumerator/with_index.rb15
-rw-r--r--spec/ruby/shared/enumerator/with_object.rb2
-rw-r--r--spec/ruby/shared/fiber/resume.rb19
-rw-r--r--spec/ruby/shared/file/directory.rb6
-rw-r--r--spec/ruby/shared/file/executable.rb8
-rw-r--r--spec/ruby/shared/file/executable_real.rb8
-rw-r--r--spec/ruby/shared/file/exist.rb6
-rw-r--r--spec/ruby/shared/file/file.rb8
-rw-r--r--spec/ruby/shared/file/grpowned.rb3
-rw-r--r--spec/ruby/shared/file/identical.rb6
-rw-r--r--spec/ruby/shared/file/size.rb2
-rw-r--r--spec/ruby/shared/file/world_readable.rb4
-rw-r--r--spec/ruby/shared/file/world_writable.rb4
-rw-r--r--spec/ruby/shared/file/writable.rb4
-rw-r--r--spec/ruby/shared/file/writable_real.rb8
-rw-r--r--spec/ruby/shared/file/zero.rb8
-rw-r--r--spec/ruby/shared/hash/key_error.rb25
-rw-r--r--spec/ruby/shared/io/putc.rb10
-rw-r--r--spec/ruby/shared/kernel/raise.rb43
-rw-r--r--spec/ruby/shared/math/atanh.rb8
-rw-r--r--spec/ruby/shared/process/abort.rb12
-rw-r--r--spec/ruby/shared/process/exit.rb20
-rw-r--r--spec/ruby/shared/process/fork.rb6
-rw-r--r--spec/ruby/shared/queue/clear.rb12
-rw-r--r--spec/ruby/shared/queue/close.rb14
-rw-r--r--spec/ruby/shared/queue/deque.rb85
-rw-r--r--spec/ruby/shared/queue/enque.rb18
-rw-r--r--spec/ruby/shared/rational/Rational.rb56
-rw-r--r--spec/ruby/shared/rational/abs.rb2
-rw-r--r--spec/ruby/shared/rational/arithmetic_exception_in_coerce.rb33
-rw-r--r--spec/ruby/shared/rational/ceil.rb2
-rw-r--r--spec/ruby/shared/rational/coerce.rb10
-rw-r--r--spec/ruby/shared/rational/comparison.rb34
-rw-r--r--spec/ruby/shared/rational/denominator.rb2
-rw-r--r--spec/ruby/shared/rational/div.rb14
-rw-r--r--spec/ruby/shared/rational/divide.rb6
-rw-r--r--spec/ruby/shared/rational/divmod.rb8
-rw-r--r--spec/ruby/shared/rational/equal_value.rb2
-rw-r--r--spec/ruby/shared/rational/exponent.rb22
-rw-r--r--spec/ruby/shared/rational/fdiv.rb2
-rw-r--r--spec/ruby/shared/rational/floor.rb2
-rw-r--r--spec/ruby/shared/rational/hash.rb2
-rw-r--r--spec/ruby/shared/rational/inspect.rb14
-rw-r--r--spec/ruby/shared/rational/marshal_dump.rb2
-rw-r--r--spec/ruby/shared/rational/marshal_load.rb2
-rw-r--r--spec/ruby/shared/rational/minus.rb2
-rw-r--r--spec/ruby/shared/rational/modulo.rb10
-rw-r--r--spec/ruby/shared/rational/multiply.rb2
-rw-r--r--spec/ruby/shared/rational/numerator.rb2
-rw-r--r--spec/ruby/shared/rational/plus.rb2
-rw-r--r--spec/ruby/shared/rational/quo.rb2
-rw-r--r--spec/ruby/shared/rational/remainder.rb2
-rw-r--r--spec/ruby/shared/rational/round.rb58
-rw-r--r--spec/ruby/shared/rational/to_f.rb2
-rw-r--r--spec/ruby/shared/rational/to_i.rb2
-rw-r--r--spec/ruby/shared/rational/to_r.rb14
-rw-r--r--spec/ruby/shared/rational/to_s.rb9
-rw-r--r--spec/ruby/shared/rational/truncate.rb2
-rw-r--r--spec/ruby/shared/sizedqueue/enque.rb50
-rw-r--r--spec/ruby/shared/sizedqueue/max.rb47
-rw-r--r--spec/ruby/shared/sizedqueue/new.rb18
-rw-r--r--spec/ruby/shared/sizedqueue/num_waiting.rb12
-rw-r--r--spec/ruby/shared/string/times.rb32
-rw-r--r--spec/ruby/shared/time/strftime_for_date.rb10
-rw-r--r--sprintf.c285
-rw-r--r--st.c192
-rw-r--r--strftime.c36
-rw-r--r--string.c1540
-rw-r--r--struct.c152
-rw-r--r--symbol.c178
-rw-r--r--symbol.h9
-rw-r--r--template/Doxyfile.tmpl6
-rw-r--r--template/GNUmakefile.in6
-rw-r--r--template/Makefile.in683
-rw-r--r--template/configure-ext.mk.tmpl2
-rw-r--r--template/depend.tmpl2
-rw-r--r--template/encdb.h.tmpl32
-rw-r--r--template/exts.mk.tmpl21
-rw-r--r--template/fake.rb.in20
-rw-r--r--template/insns.inc.tmpl24
-rw-r--r--template/insns_info.inc.tmpl109
-rw-r--r--template/minsns.inc.tmpl14
-rw-r--r--template/opt_sc.inc.tmpl35
-rw-r--r--template/optinsn.inc.tmpl78
-rw-r--r--template/optunifs.inc.tmpl67
-rw-r--r--template/prelude.c.tmpl100
-rw-r--r--template/ruby-runner.h.in2
-rw-r--r--template/ruby.pc.in1
-rw-r--r--template/transdb.h.tmpl21
-rw-r--r--template/unicode_norm_gen.tmpl22
-rw-r--r--template/verconf.h.tmpl2
-rw-r--r--template/vm.inc.tmpl33
-rw-r--r--template/vmtc.inc.tmpl21
-rw-r--r--template/yarvarch.en (renamed from doc/yarvarch.en)0
-rw-r--r--template/yarvarch.ja (renamed from doc/yarvarch.ja)0
-rw-r--r--template/yasmdata.rb.tmpl20
-rw-r--r--test/-ext-/arith_seq/test_arith_seq_extract.rb40
-rw-r--r--test/-ext-/array/test_resize.rb2
-rw-r--r--test/-ext-/bignum/test_big2str.rb2
-rw-r--r--test/-ext-/bignum/test_bigzero.rb2
-rw-r--r--test/-ext-/bignum/test_div.rb2
-rw-r--r--test/-ext-/bignum/test_mul.rb2
-rw-r--r--test/-ext-/bignum/test_pack.rb2
-rw-r--r--test/-ext-/bignum/test_str2big.rb2
-rw-r--r--test/-ext-/bug_reporter/test_bug_reporter.rb4
-rw-r--r--test/-ext-/debug/test_debug.rb2
-rw-r--r--test/-ext-/debug/test_profile_frames.rb40
-rw-r--r--test/-ext-/exception/test_data_error.rb2
-rw-r--r--test/-ext-/exception/test_enc_raise.rb2
-rw-r--r--test/-ext-/exception/test_ensured.rb2
-rw-r--r--test/-ext-/exception/test_exception_at_throwing.rb2
-rw-r--r--test/-ext-/funcall/test_passing_block.rb56
-rw-r--r--test/-ext-/gvl/test_last_thread.rb1
-rw-r--r--test/-ext-/gvl/test_ubf_async_safe.rb20
-rw-r--r--test/-ext-/hash/test_delete.rb2
-rw-r--r--test/-ext-/integer/test_integer.rb2
-rw-r--r--test/-ext-/integer/test_my_integer.rb2
-rw-r--r--test/-ext-/iseq_load/test_iseq_load.rb67
-rw-r--r--test/-ext-/iter/test_yield_block.rb2
-rw-r--r--test/-ext-/marshal/test_internal_ivar.rb8
-rw-r--r--test/-ext-/method/test_arity.rb2
-rw-r--r--test/-ext-/popen_deadlock/test_popen_deadlock.rb2
-rw-r--r--test/-ext-/postponed_job/test_postponed_job.rb4
-rw-r--r--test/-ext-/proc/test_bmethod.rb4
-rw-r--r--test/-ext-/string/test_capacity.rb19
-rw-r--r--test/-ext-/string/test_fstring.rb46
-rw-r--r--test/-ext-/string/test_modify_expand.rb3
-rw-r--r--test/-ext-/struct/test_duplicate.rb4
-rw-r--r--test/-ext-/symbol/noninterned_name.rb2
-rw-r--r--test/-ext-/symbol/test_inadvertent_creation.rb21
-rw-r--r--test/-ext-/test_bug-14834.rb12
-rw-r--r--test/-ext-/test_enumerator_kw.rb11
-rw-r--r--test/-ext-/test_notimplement.rb31
-rw-r--r--test/-ext-/test_printf.rb11
-rw-r--r--test/-ext-/test_scan_args.rb137
-rw-r--r--test/-ext-/tracepoint/test_tracepoint.rb10
-rw-r--r--test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb26
-rw-r--r--test/-ext-/win32/test_console_attr.rb17
-rw-r--r--test/benchmark/test_benchmark.rb8
-rw-r--r--test/bigdecimal/test_bigdecimal.rb230
-rw-r--r--test/bigdecimal/test_bigdecimal_util.rb35
-rw-r--r--test/cgi/test_cgi_cookie.rb5
-rw-r--r--test/cgi/test_cgi_multipart.rb3
-rw-r--r--test/cgi/test_cgi_util.rb61
-rw-r--r--test/colors (renamed from tool/colors)0
-rw-r--r--test/coverage/test_coverage.rb278
-rw-r--r--test/csv/base.rb9
-rw-r--r--test/csv/helper.rb18
-rw-r--r--test/csv/interface/test_delegation.rb47
-rw-r--r--test/csv/interface/test_read.rb277
-rw-r--r--test/csv/interface/test_read_write.rb50
-rw-r--r--test/csv/interface/test_write.rb174
-rw-r--r--test/csv/parse/test_column_separator.rb40
-rw-r--r--test/csv/parse/test_convert.rb110
-rw-r--r--test/csv/parse/test_each.rb23
-rw-r--r--test/csv/parse/test_general.rb255
-rw-r--r--test/csv/parse/test_header.rb335
-rw-r--r--test/csv/parse/test_invalid.rb39
-rw-r--r--test/csv/parse/test_liberal_parsing.rb160
-rw-r--r--test/csv/parse/test_quote_char_nil.rb93
-rw-r--r--test/csv/parse/test_rewind.rb40
-rw-r--r--test/csv/parse/test_row_separator.rb16
-rw-r--r--test/csv/parse/test_skip_lines.rb105
-rw-r--r--test/csv/parse/test_strip.rb78
-rw-r--r--test/csv/parse/test_unconverted_fields.rb117
-rwxr-xr-xtest/csv/test_csv_parsing.rb244
-rwxr-xr-xtest/csv/test_csv_writing.rb98
-rwxr-xr-x[-rw-r--r--]test/csv/test_data_converters.rb243
-rwxr-xr-x[-rw-r--r--]test/csv/test_encodings.rb56
-rwxr-xr-x[-rw-r--r--]test/csv/test_features.rb203
-rwxr-xr-xtest/csv/test_headers.rb305
-rwxr-xr-xtest/csv/test_interface.rb393
-rwxr-xr-x[-rw-r--r--]test/csv/test_row.rb86
-rwxr-xr-x[-rw-r--r--]test/csv/test_table.rb243
-rw-r--r--test/csv/ts_all.rb21
-rw-r--r--test/csv/write/test_converters.rb53
-rw-r--r--test/csv/write/test_general.rb258
-rw-r--r--test/csv/write/test_quote_empty.rb70
-rw-r--r--test/date/test_date.rb13
-rw-r--r--test/date/test_date_arith.rb22
-rw-r--r--test/date/test_date_attr.rb20
-rw-r--r--test/date/test_date_base.rb435
-rw-r--r--test/date/test_date_conv.rb18
-rw-r--r--test/date/test_date_marshal.rb21
-rw-r--r--test/date/test_date_new.rb110
-rw-r--r--test/date/test_date_parse.rb195
-rw-r--r--test/date/test_date_strftime.rb16
-rw-r--r--test/date/test_date_strptime.rb19
-rw-r--r--test/date/test_switch_hitter.rb57
-rw-r--r--test/dbm/test_dbm.rb4
-rw-r--r--test/did_you_mean/core_ext/test_name_error_extension.rb48
-rw-r--r--test/did_you_mean/edit_distance/test_jaro_winkler.rb36
-rw-r--r--test/did_you_mean/fixtures/book.rb4
-rw-r--r--test/did_you_mean/fixtures/mini_dir.yml15
-rw-r--r--test/did_you_mean/fixtures/rspec_dir.yml112
-rw-r--r--test/did_you_mean/helper.rb29
-rw-r--r--test/did_you_mean/spell_checking/test_class_name_check.rb79
-rw-r--r--test/did_you_mean/spell_checking/test_key_name_check.rb54
-rw-r--r--test/did_you_mean/spell_checking/test_method_name_check.rb140
-rw-r--r--test/did_you_mean/spell_checking/test_uncorrectable_name_check.rb15
-rw-r--r--test/did_you_mean/spell_checking/test_variable_name_check.rb140
-rw-r--r--test/did_you_mean/test_spell_checker.rb77
-rw-r--r--test/did_you_mean/test_tree_spell_checker.rb173
-rw-r--r--test/did_you_mean/test_verbose_formatter.rb21
-rw-r--r--test/did_you_mean/tree_spell/change_word.rb61
-rw-r--r--test/did_you_mean/tree_spell/human_typo.rb89
-rw-r--r--test/did_you_mean/tree_spell/test_change_word.rb38
-rw-r--r--test/did_you_mean/tree_spell/test_human_typo.rb24
-rw-r--r--test/digest/test_digest_extend.rb2
-rw-r--r--test/drb/drbtest.rb104
-rw-r--r--test/drb/test_drb.rb133
-rw-r--r--test/drb/test_drbobject.rb69
-rw-r--r--test/drb/test_drbssl.rb54
-rw-r--r--test/drb/test_drbunix.rb26
-rw-r--r--test/drb/ut_drb.rb21
-rw-r--r--test/dtrace/helper.rb100
-rw-r--r--test/dtrace/test_array_create.rb8
-rw-r--r--test/dtrace/test_function_entry.rb9
-rw-r--r--test/dtrace/test_hash_create.rb6
-rw-r--r--test/dtrace/test_method_cache.rb2
-rw-r--r--test/dtrace/test_require.rb6
-rw-r--r--test/dtrace/test_singleton_function.rb9
-rw-r--r--test/dtrace/test_string.rb6
-rw-r--r--test/erb/test_erb.rb126
-rw-r--r--test/erb/test_erb_command.rb12
-rw-r--r--test/erb/test_erb_m17n.rb2
-rw-r--r--test/excludes/_appveyor/TestArray.rb7
-rw-r--r--test/fiddle/helper.rb33
-rw-r--r--test/fiddle/test_cparser.rb10
-rw-r--r--test/fiddle/test_func.rb10
-rw-r--r--test/fiddle/test_function.rb25
-rw-r--r--test/fiddle/test_handle.rb19
-rw-r--r--test/fiddle/test_import.rb6
-rw-r--r--test/fiddle/test_pointer.rb5
-rw-r--r--test/fileutils/test_dryrun.rb2
-rw-r--r--test/fileutils/test_fileutils.rb150
-rw-r--r--test/fileutils/test_nowrite.rb2
-rw-r--r--test/fileutils/test_verbose.rb2
-rw-r--r--test/fileutils/visibility_tests.rb4
-rw-r--r--test/gdbm/test_gdbm.rb7
-rw-r--r--test/io/console/test_io_console.rb139
-rw-r--r--test/io/nonblock/test_flush.rb1
-rw-r--r--test/io/wait/test_io_wait.rb22
-rw-r--r--test/io/wait/test_io_wait_uncommon.rb78
-rw-r--r--test/irb/test_cmd.rb129
-rw-r--r--test/irb/test_color.rb193
-rw-r--r--test/irb/test_completion.rb33
-rw-r--r--test/irb/test_context.rb426
-rw-r--r--test/irb/test_history.rb175
-rw-r--r--test/irb/test_init.rb52
-rw-r--r--test/irb/test_option.rb3
-rw-r--r--test/irb/test_raise_no_backtrace_exception.rb4
-rw-r--r--test/irb/test_ruby-lex.rb108
-rw-r--r--test/irb/test_ruby_lex.rb264
-rw-r--r--test/irb/test_workspace.rb21
-rw-r--r--test/json/json_addition_test.rb10
-rw-r--r--test/json/json_common_interface_test.rb8
-rw-r--r--test/json/json_generator_test.rb44
-rw-r--r--test/json/json_parser_test.rb28
-rw-r--r--test/json/test_helper.rb4
-rw-r--r--test/lib/-test-/integer.rb (renamed from tool/lib/-test-/integer.rb)0
-rw-r--r--test/lib/envutil.rb298
-rw-r--r--test/lib/find_executable.rb (renamed from tool/lib/find_executable.rb)0
-rw-r--r--test/lib/iseq_loader_checker.rb75
-rw-r--r--test/lib/jit_support.rb78
-rw-r--r--test/lib/leakchecker.rb229
-rw-r--r--test/lib/memory_status.rb (renamed from tool/lib/memory_status.rb)0
-rw-r--r--test/lib/minitest/README.txt (renamed from tool/lib/minitest/README.txt)0
-rw-r--r--test/lib/minitest/autorun.rb (renamed from tool/lib/minitest/autorun.rb)0
-rw-r--r--test/lib/minitest/benchmark.rb (renamed from tool/lib/minitest/benchmark.rb)0
-rw-r--r--test/lib/minitest/mock.rb (renamed from tool/lib/minitest/mock.rb)0
-rw-r--r--test/lib/minitest/unit.rb1414
-rw-r--r--test/lib/profile_test_all.rb91
-rw-r--r--test/lib/test/unit.rb1176
-rw-r--r--test/lib/test/unit/assertions.rb943
-rw-r--r--test/lib/test/unit/parallel.rb208
-rw-r--r--test/lib/test/unit/testcase.rb (renamed from tool/lib/test/unit/testcase.rb)0
-rw-r--r--test/lib/tracepointchecker.rb126
-rw-r--r--test/lib/with_different_ofs.rb4
-rw-r--r--test/lib/zombie_hunter.rb9
-rw-r--r--test/logger/helper.rb13
-rw-r--r--test/logger/test_logdevice.rb34
-rw-r--r--test/logger/test_logger.rb45
-rw-r--r--test/logger/test_logperiod.rb80
-rw-r--r--test/logger/test_severity.rb14
-rw-r--r--test/matrix/test_matrix.rb146
-rw-r--r--test/matrix/test_vector.rb104
-rw-r--r--test/minitest/metametameta.rb (renamed from tool/test/minitest/metametameta.rb)0
-rw-r--r--test/minitest/test_minitest_benchmark.rb (renamed from tool/test/minitest/test_minitest_benchmark.rb)0
-rw-r--r--test/minitest/test_minitest_mock.rb404
-rw-r--r--test/minitest/test_minitest_unit.rb1779
-rw-r--r--test/mkmf/base.rb14
-rw-r--r--test/mkmf/test_flags.rb2
-rw-r--r--test/mkmf/test_framework.rb2
-rw-r--r--test/monitor/test_monitor.rb60
-rw-r--r--test/net/ftp/test_ftp.rb264
-rw-r--r--test/net/http/test_http.rb99
-rw-r--r--test/net/http/test_http_request.rb13
-rw-r--r--test/net/http/test_httpheader.rb19
-rw-r--r--test/net/http/test_httpresponse.rb32
-rw-r--r--test/net/http/test_https.rb80
-rw-r--r--test/net/http/utils.rb19
-rw-r--r--test/net/imap/Makefile (renamed from test/net/fixtures/Makefile)0
-rw-r--r--test/net/imap/test_imap.rb89
-rw-r--r--test/net/imap/test_imap_response_parser.rb49
-rw-r--r--test/net/protocol/test_protocol.rb93
-rw-r--r--test/net/smtp/test_smtp.rb2
-rw-r--r--test/objspace/test_objspace.rb94
-rw-r--r--test/open-uri/test_open-uri.rb112
-rw-r--r--test/open-uri/test_ssl.rb353
-rw-r--r--test/openssl/fixtures/pkey/dh-1.pem13
-rw-r--r--test/openssl/fixtures/pkey/rsa-1.pem51
-rw-r--r--test/openssl/fixtures/pkey/rsa-2.pem51
-rw-r--r--test/openssl/fixtures/pkey/rsa-3.pem51
-rw-r--r--test/openssl/test_asn1.rb5
-rw-r--r--test/openssl/test_config.rb70
-rw-r--r--test/openssl/test_pair.rb59
-rw-r--r--test/openssl/test_pkey_dh.rb8
-rw-r--r--test/openssl/test_pkey_ec.rb10
-rw-r--r--test/openssl/test_ssl.rb122
-rw-r--r--test/openssl/test_ssl_session.rb1
-rw-r--r--test/openssl/test_x509name.rb12
-rw-r--r--test/openssl/utils.rb27
-rw-r--r--test/optparse/test_autoconf.rb7
-rw-r--r--test/optparse/test_did_you_mean.rb52
-rw-r--r--test/optparse/test_summary.rb11
-rw-r--r--test/optparse/test_zsh_completion.rb2
-rw-r--r--test/ostruct/test_ostruct.rb14
-rw-r--r--test/pathname/test_pathname.rb171
-rw-r--r--test/psych/test_exception.rb46
-rw-r--r--test/psych/test_hash.rb34
-rw-r--r--test/psych/test_nil.rb4
-rw-r--r--test/psych/test_psych.rb144
-rw-r--r--test/psych/test_safe_load.rb91
-rw-r--r--test/psych/test_scalar_scanner.rb17
-rw-r--r--test/psych/test_stream.rb16
-rw-r--r--test/psych/test_tainted.rb131
-rw-r--r--test/psych/test_yaml.rb24
-rw-r--r--test/psych/test_yaml_special_cases.rb130
-rw-r--r--test/psych/visitors/test_yaml_tree.rb2
-rw-r--r--test/racc/assets/cadenza.y170
-rw-r--r--test/racc/assets/cast.y926
-rw-r--r--test/racc/assets/chk.y126
-rw-r--r--test/racc/assets/conf.y16
-rw-r--r--test/racc/assets/csspool.y729
-rw-r--r--test/racc/assets/digraph.y29
-rw-r--r--test/racc/assets/echk.y118
-rw-r--r--test/racc/assets/edtf.y583
-rw-r--r--test/racc/assets/err.y60
-rw-r--r--test/racc/assets/error_recovery.y35
-rw-r--r--test/racc/assets/expect.y7
-rw-r--r--test/racc/assets/firstline.y4
-rw-r--r--test/racc/assets/huia.y318
-rw-r--r--test/racc/assets/ichk.y102
-rw-r--r--test/racc/assets/intp.y546
-rw-r--r--test/racc/assets/journey.y47
-rw-r--r--test/racc/assets/liquor.y313
-rw-r--r--test/racc/assets/machete.y423
-rw-r--r--test/racc/assets/macruby.y2197
-rw-r--r--test/racc/assets/mailp.y437
-rw-r--r--test/racc/assets/mediacloth.y599
-rw-r--r--test/racc/assets/mof.y649
-rw-r--r--test/racc/assets/namae.y302
-rw-r--r--test/racc/assets/nasl.y626
-rw-r--r--test/racc/assets/newsyn.y25
-rw-r--r--test/racc/assets/noend.y4
-rw-r--r--test/racc/assets/nokogiri-css.y255
-rw-r--r--test/racc/assets/nonass.y41
-rw-r--r--test/racc/assets/normal.y27
-rw-r--r--test/racc/assets/norule.y4
-rw-r--r--test/racc/assets/nullbug1.y25
-rw-r--r--test/racc/assets/nullbug2.y15
-rw-r--r--test/racc/assets/opal.y1807
-rw-r--r--test/racc/assets/opt.y123
-rw-r--r--test/racc/assets/percent.y35
-rw-r--r--test/racc/assets/php_serialization.y98
-rw-r--r--test/racc/assets/recv.y97
-rw-r--r--test/racc/assets/riml.y665
-rw-r--r--test/racc/assets/rrconf.y14
-rw-r--r--test/racc/assets/ruby18.y1943
-rw-r--r--test/racc/assets/ruby19.y2174
-rw-r--r--test/racc/assets/ruby20.y2350
-rw-r--r--test/racc/assets/ruby21.y2359
-rw-r--r--test/racc/assets/ruby22.y2381
-rw-r--r--test/racc/assets/scan.y72
-rw-r--r--test/racc/assets/syntax.y50
-rw-r--r--test/racc/assets/tp_plus.y622
-rw-r--r--test/racc/assets/twowaysql.y278
-rw-r--r--test/racc/assets/unterm.y5
-rw-r--r--test/racc/assets/useless.y12
-rw-r--r--test/racc/assets/yyerr.y46
-rw-r--r--test/racc/bench.y36
-rw-r--r--test/racc/helper.rb115
-rw-r--r--test/racc/infini.y8
-rw-r--r--test/racc/regress/README.txt7
-rw-r--r--test/racc/regress/cadenza796
-rw-r--r--test/racc/regress/cast3425
-rw-r--r--test/racc/regress/csspool2318
-rw-r--r--test/racc/regress/edtf1794
-rw-r--r--test/racc/regress/huia1392
-rw-r--r--test/racc/regress/journey222
-rw-r--r--test/racc/regress/liquor885
-rw-r--r--test/racc/regress/machete833
-rw-r--r--test/racc/regress/mediacloth1463
-rw-r--r--test/racc/regress/mof1368
-rw-r--r--test/racc/regress/namae634
-rw-r--r--test/racc/regress/nasl2058
-rw-r--r--test/racc/regress/nokogiri-css836
-rw-r--r--test/racc/regress/opal6429
-rw-r--r--test/racc/regress/php_serialization336
-rw-r--r--test/racc/regress/riml3297
-rw-r--r--test/racc/regress/ruby186351
-rw-r--r--test/racc/regress/ruby227456
-rw-r--r--test/racc/regress/tp_plus1933
-rw-r--r--test/racc/regress/twowaysql556
-rw-r--r--test/racc/scandata/brace7
-rw-r--r--test/racc/scandata/gvar1
-rw-r--r--test/racc/scandata/normal4
-rw-r--r--test/racc/scandata/percent18
-rw-r--r--test/racc/scandata/slash10
-rw-r--r--test/racc/src.intp34
-rw-r--r--test/racc/start.y20
-rw-r--r--test/racc/test_chk_y.rb52
-rw-r--r--test/racc/test_grammar_file_parser.rb15
-rw-r--r--test/racc/test_racc_command.rb322
-rw-r--r--test/racc/test_scan_y.rb52
-rw-r--r--test/racc/testscanner.rb51
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Markdown Documentation - Basics.text4
-rw-r--r--test/rdoc/helper.rb5
-rw-r--r--test/rdoc/support/formatter_test_case.rb764
-rw-r--r--test/rdoc/support/test_case.rb216
-rw-r--r--test/rdoc/test_rdoc_any_method.rb55
-rw-r--r--test/rdoc/test_rdoc_attr.rb5
-rw-r--r--test/rdoc/test_rdoc_class_module.rb56
-rw-r--r--test/rdoc/test_rdoc_code_object.rb2
-rw-r--r--test/rdoc/test_rdoc_comment.rb7
-rw-r--r--test/rdoc/test_rdoc_constant.rb2
-rw-r--r--test/rdoc/test_rdoc_context.rb36
-rw-r--r--test/rdoc/test_rdoc_context_section.rb6
-rw-r--r--test/rdoc/test_rdoc_cross_reference.rb32
-rw-r--r--test/rdoc/test_rdoc_encoding.rb102
-rw-r--r--test/rdoc/test_rdoc_generator_darkfish.rb6
-rw-r--r--test/rdoc/test_rdoc_generator_json_index.rb33
-rw-r--r--test/rdoc/test_rdoc_generator_markup.rb2
-rw-r--r--test/rdoc/test_rdoc_generator_pot.rb2
-rw-r--r--test/rdoc/test_rdoc_generator_pot_po.rb2
-rw-r--r--test/rdoc/test_rdoc_generator_pot_po_entry.rb2
-rw-r--r--test/rdoc/test_rdoc_generator_ri.rb2
-rw-r--r--test/rdoc/test_rdoc_i18n_locale.rb10
-rw-r--r--test/rdoc/test_rdoc_i18n_text.rb2
-rw-r--r--test/rdoc/test_rdoc_markdown.rb4
-rw-r--r--test/rdoc/test_rdoc_markdown_test.rb6
-rw-r--r--test/rdoc/test_rdoc_markup.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_attribute_manager.rb30
-rw-r--r--test/rdoc/test_rdoc_markup_attributes.rb10
-rw-r--r--test/rdoc/test_rdoc_markup_document.rb4
-rw-r--r--test/rdoc/test_rdoc_markup_formatter.rb57
-rw-r--r--test/rdoc/test_rdoc_markup_hard_break.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_heading.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_include.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_indented_paragraph.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_paragraph.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_parser.rb62
-rw-r--r--test/rdoc/test_rdoc_markup_pre_process.rb4
-rw-r--r--test/rdoc/test_rdoc_markup_raw.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_ansi.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_bs.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_html.rb16
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_crossref.rb98
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_snippet.rb14
-rw-r--r--test/rdoc/test_rdoc_markup_to_joined_paragraph.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_label.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_markdown.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_rdoc.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_table_of_contents.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_tt_only.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_verbatim.rb2
-rw-r--r--test/rdoc/test_rdoc_options.rb108
-rw-r--r--test/rdoc/test_rdoc_parser.rb24
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb63
-rw-r--r--test/rdoc/test_rdoc_parser_changelog.rb2
-rw-r--r--test/rdoc/test_rdoc_parser_markdown.rb2
-rw-r--r--test/rdoc/test_rdoc_parser_rd.rb2
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb601
-rw-r--r--test/rdoc/test_rdoc_parser_simple.rb2
-rw-r--r--test/rdoc/test_rdoc_rd.rb2
-rw-r--r--test/rdoc/test_rdoc_rd_block_parser.rb2
-rw-r--r--test/rdoc/test_rdoc_rd_inline.rb2
-rw-r--r--test/rdoc/test_rdoc_rd_inline_parser.rb2
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb146
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb169
-rw-r--r--test/rdoc/test_rdoc_ri_paths.rb6
-rw-r--r--test/rdoc/test_rdoc_rubygems_hook.rb16
-rw-r--r--test/rdoc/test_rdoc_servlet.rb33
-rw-r--r--test/rdoc/test_rdoc_single_class.rb2
-rw-r--r--test/rdoc/test_rdoc_stats.rb2
-rw-r--r--test/rdoc/test_rdoc_store.rb45
-rw-r--r--test/rdoc/test_rdoc_task.rb12
-rw-r--r--test/rdoc/test_rdoc_text.rb43
-rw-r--r--test/rdoc/test_rdoc_token_stream.rb17
-rw-r--r--test/rdoc/test_rdoc_tom_doc.rb62
-rw-r--r--test/rdoc/test_rdoc_top_level.rb2
-rw-r--r--test/rdoc/xref_data.rb21
-rw-r--r--test/rdoc/xref_test_case.rb24
-rw-r--r--test/readline/helper.rb24
-rw-r--r--test/readline/test_readline.rb544
-rw-r--r--test/readline/test_readline_history.rb192
-rw-r--r--test/reline/helper.rb90
-rw-r--r--test/reline/test_config.rb325
-rw-r--r--test/reline/test_history.rb301
-rw-r--r--test/reline/test_key_actor_emacs.rb2082
-rw-r--r--test/reline/test_key_actor_vi.rb1240
-rw-r--r--test/reline/test_key_stroke.rb49
-rw-r--r--test/reline/test_kill_ring.rb256
-rw-r--r--test/reline/test_macro.rb39
-rw-r--r--test/reline/test_reline.rb315
-rw-r--r--test/reline/test_string_processing.rb23
-rw-r--r--test/reline/test_within_pipe.rb61
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb224
-rw-r--r--test/resolv/test_dns.rb176
-rw-r--r--test/resolv/test_mdns.rb29
-rw-r--r--test/rexml/data/t75.xml2
-rw-r--r--test/rexml/formatter/test_default.rb19
-rw-r--r--test/rexml/functions/test_base.rb261
-rw-r--r--test/rexml/functions/test_boolean.rb75
-rw-r--r--test/rexml/functions/test_local_name.rb44
-rw-r--r--test/rexml/functions/test_number.rb38
-rw-r--r--test/rexml/parse/test_document_type_declaration.rb193
-rw-r--r--test/rexml/parse/test_element.rb77
-rw-r--r--test/rexml/parse/test_notation_declaration.rb181
-rw-r--r--test/rexml/parse/test_processing_instruction.rb44
-rw-r--r--test/rexml/parser/test_tree.rb2
-rw-r--r--test/rexml/parser/test_ultra_light.rb3
-rw-r--r--test/rexml/rexml_test_utils.rb5
-rw-r--r--test/rexml/test_attribute.rb14
-rw-r--r--test/rexml/test_core.rb85
-rw-r--r--test/rexml/test_doctype.rb124
-rw-r--r--test/rexml/test_functions.rb238
-rw-r--r--test/rexml/test_functions_number.rb35
-rw-r--r--test/rexml/test_instruction.rb14
-rw-r--r--test/rexml/test_jaxen.rb189
-rw-r--r--test/rexml/test_martin_fowler.rb2
-rw-r--r--test/rexml/test_stream.rb4
-rw-r--r--test/rexml/test_text.rb55
-rw-r--r--test/rexml/test_xml_declaration.rb18
-rw-r--r--test/rexml/xpath/test_attribute.rb10
-rw-r--r--test/rexml/xpath/test_base.rb133
-rw-r--r--test/rexml/xpath/test_compare.rb256
-rw-r--r--test/rinda/test_rinda.rb46
-rw-r--r--test/ripper/assert_parse_files.rb32
-rw-r--r--test/ripper/test_files.rb50
-rw-r--r--test/ripper/test_files_ext.rb8
-rw-r--r--test/ripper/test_files_lib.rb14
-rw-r--r--test/ripper/test_files_sample.rb8
-rw-r--r--test/ripper/test_files_test.rb8
-rw-r--r--test/ripper/test_files_test_1.rb9
-rw-r--r--test/ripper/test_files_test_2.rb9
-rw-r--r--test/ripper/test_lexer.rb50
-rw-r--r--test/ripper/test_parser_events.rb90
-rw-r--r--test/ripper/test_ripper.rb10
-rw-r--r--test/ripper/test_scanner_events.rb77
-rw-r--r--test/ripper/test_sexp.rb330
-rw-r--r--test/rss/rss-assertions.rb63
-rw-r--r--test/rss/test_itunes.rb6
-rw-r--r--test/rss/test_maker_itunes.rb9
-rw-r--r--test/rss/test_parser.rb58
-rw-r--r--test/rss/test_version.rb10
-rw-r--r--test/ruby/enc/test_case_comprehensive.rb6
-rw-r--r--test/ruby/enc/test_case_mapping.rb33
-rw-r--r--test/ruby/enc/test_cesu8.rb109
-rw-r--r--test/ruby/enc/test_emoji_breaks.rb122
-rw-r--r--test/ruby/enc/test_grapheme_breaks.rb7
-rw-r--r--test/ruby/marshaltestlib.rb4
-rw-r--r--test/ruby/sentence.rb2
-rw-r--r--test/ruby/test_alias.rb35
-rw-r--r--test/ruby/test_argf.rb35
-rw-r--r--test/ruby/test_arithmetic_sequence.rb494
-rw-r--r--test/ruby/test_array.rb391
-rw-r--r--test/ruby/test_assignment.rb40
-rw-r--r--test/ruby/test_ast.rb348
-rw-r--r--test/ruby/test_autoload.rb153
-rw-r--r--test/ruby/test_backtrace.rb46
-rw-r--r--test/ruby/test_basicinstructions.rb1
-rw-r--r--test/ruby/test_bignum.rb7
-rw-r--r--test/ruby/test_class.rb143
-rw-r--r--test/ruby/test_clone.rb35
-rw-r--r--test/ruby/test_comparable.rb32
-rw-r--r--test/ruby/test_complex.rb192
-rw-r--r--test/ruby/test_complexrational.rb8
-rw-r--r--test/ruby/test_const.rb11
-rw-r--r--test/ruby/test_continuation.rb17
-rw-r--r--test/ruby/test_default_gems.rb16
-rw-r--r--test/ruby/test_defined.rb46
-rw-r--r--test/ruby/test_dir.rb73
-rw-r--r--test/ruby/test_dir_m17n.rb36
-rw-r--r--test/ruby/test_econv.rb8
-rw-r--r--test/ruby/test_encoding.rb17
-rw-r--r--test/ruby/test_enum.rb151
-rw-r--r--test/ruby/test_enumerator.rb235
-rw-r--r--test/ruby/test_env.rb75
-rw-r--r--test/ruby/test_eval.rb53
-rw-r--r--test/ruby/test_exception.rb419
-rw-r--r--test/ruby/test_fiber.rb90
-rw-r--r--test/ruby/test_file.rb97
-rw-r--r--test/ruby/test_file_exhaustive.rb132
-rw-r--r--test/ruby/test_flip.rb3
-rw-r--r--test/ruby/test_float.rb51
-rw-r--r--test/ruby/test_fnmatch.rb31
-rw-r--r--test/ruby/test_gc.rb32
-rw-r--r--test/ruby/test_gc_compact.rb65
-rw-r--r--test/ruby/test_hash.rb321
-rw-r--r--test/ruby/test_ifunless.rb2
-rw-r--r--test/ruby/test_integer.rb134
-rw-r--r--test/ruby/test_io.rb499
-rw-r--r--test/ruby/test_io_m17n.rb79
-rw-r--r--test/ruby/test_iseq.rb205
-rw-r--r--test/ruby/test_iterator.rb27
-rw-r--r--test/ruby/test_jit.rb1124
-rw-r--r--test/ruby/test_key_error.rb42
-rw-r--r--test/ruby/test_keyword.rb4430
-rw-r--r--test/ruby/test_lambda.rb62
-rw-r--r--test/ruby/test_lazy_enumerator.rb104
-rw-r--r--test/ruby/test_literal.rb53
-rw-r--r--test/ruby/test_m17n.rb46
-rw-r--r--test/ruby/test_m17n_comb.rb17
-rw-r--r--test/ruby/test_marshal.rb115
-rw-r--r--test/ruby/test_math.rb1
-rw-r--r--test/ruby/test_method.rb337
-rw-r--r--test/ruby/test_module.rb345
-rw-r--r--test/ruby/test_not.rb2
-rw-r--r--test/ruby/test_notimp.rb85
-rw-r--r--test/ruby/test_numeric.rb47
-rw-r--r--test/ruby/test_object.rb101
-rw-r--r--test/ruby/test_objectspace.rb30
-rw-r--r--test/ruby/test_optimization.rb109
-rw-r--r--test/ruby/test_pack.rb27
-rw-r--r--test/ruby/test_parse.rb523
-rw-r--r--test/ruby/test_path.rb8
-rw-r--r--test/ruby/test_pattern_matching.rb1342
-rw-r--r--test/ruby/test_pipe.rb19
-rw-r--r--test/ruby/test_proc.rb333
-rw-r--r--test/ruby/test_process.rb185
-rw-r--r--test/ruby/test_rand.rb13
-rw-r--r--test/ruby/test_range.rb330
-rw-r--r--test/ruby/test_rational.rb75
-rw-r--r--test/ruby/test_refinement.rb290
-rw-r--r--test/ruby/test_regexp.rb82
-rw-r--r--test/ruby/test_require.rb172
-rw-r--r--test/ruby/test_require_lib.rb28
-rw-r--r--test/ruby/test_rubyoptions.rb283
-rw-r--r--test/ruby/test_rubyvm_mjit.rb91
-rw-r--r--test/ruby/test_settracefunc.rb535
-rw-r--r--test/ruby/test_signal.rb107
-rw-r--r--test/ruby/test_sprintf.rb11
-rw-r--r--test/ruby/test_string.rb291
-rw-r--r--test/ruby/test_struct.rb59
-rw-r--r--test/ruby/test_super.rb27
-rw-r--r--test/ruby/test_symbol.rb67
-rw-r--r--test/ruby/test_syntax.rb613
-rw-r--r--test/ruby/test_system.rb41
-rw-r--r--test/ruby/test_thread.rb181
-rw-r--r--test/ruby/test_thread_cv.rb245
-rw-r--r--test/ruby/test_thread_queue.rb630
-rw-r--r--test/ruby/test_time.rb120
-rw-r--r--test/ruby/test_time_tz.rb339
-rw-r--r--test/ruby/test_trace.rb11
-rw-r--r--test/ruby/test_transcode.rb30
-rw-r--r--test/ruby/test_undef.rb2
-rw-r--r--test/ruby/test_variable.rb72
-rw-r--r--test/ruby/test_weakmap.rb65
-rw-r--r--test/rubygems/fix_openssl_warnings.rb13
-rw-r--r--test/rubygems/plugin/load/rubygems_plugin.rb2
-rw-r--r--test/rubygems/rubygems_plugin.rb1
-rw-r--r--test/rubygems/simple_gem.rb2
-rw-r--r--test/rubygems/specifications/rubyforge-0.0.1.gemspec14
-rw-r--r--test/rubygems/test_bundled_ca.rb12
-rw-r--r--test/rubygems/test_config.rb9
-rw-r--r--test/rubygems/test_deprecate.rb3
-rw-r--r--test/rubygems/test_gem.rb728
-rw-r--r--test/rubygems/test_gem_available_set.rb5
-rw-r--r--test/rubygems/test_gem_bundler_version_finder.rb8
-rw-r--r--test/rubygems/test_gem_command.rb129
-rw-r--r--test/rubygems/test_gem_command_manager.rb23
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb394
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb93
-rw-r--r--test/rubygems/test_gem_commands_check_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_cleanup_command.rb56
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb3
-rw-r--r--test/rubygems/test_gem_commands_dependency_command.rb69
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb13
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_generate_index_command.rb37
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb10
-rw-r--r--test/rubygems/test_gem_commands_info_command.rb45
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb319
-rw-r--r--test/rubygems/test_gem_commands_lock_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_mirror.rb1
-rw-r--r--test/rubygems/test_gem_commands_open_command.rb29
-rw-r--r--test/rubygems/test_gem_commands_outdated_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb151
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb186
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb95
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb229
-rw-r--r--test/rubygems/test_gem_commands_search_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_server_command.rb9
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb194
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb13
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb141
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb5
-rw-r--r--test/rubygems/test_gem_commands_stale_command.rb5
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb321
-rw-r--r--test/rubygems/test_gem_commands_unpack_command.rb18
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb128
-rw-r--r--test/rubygems/test_gem_commands_which_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb48
-rw-r--r--test/rubygems/test_gem_config_file.rb17
-rw-r--r--test/rubygems/test_gem_dependency.rb7
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb116
-rw-r--r--test/rubygems/test_gem_dependency_list.rb48
-rw-r--r--test/rubygems/test_gem_dependency_resolution_error.rb1
-rw-r--r--test/rubygems/test_gem_doctor.rb3
-rw-r--r--test/rubygems/test_gem_ext_builder.rb39
-rw-r--r--test/rubygems/test_gem_ext_cmake_builder.rb11
-rw-r--r--test/rubygems/test_gem_ext_configure_builder.rb14
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb29
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb31
-rw-r--r--test/rubygems/test_gem_gem_runner.rb37
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb54
-rw-r--r--test/rubygems/test_gem_impossible_dependencies_error.rb1
-rw-r--r--test/rubygems/test_gem_indexer.rb85
-rw-r--r--test/rubygems/test_gem_install_update_options.rb71
-rw-r--r--test/rubygems/test_gem_installer.rb899
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb6
-rw-r--r--test/rubygems/test_gem_name_tuple.rb1
-rw-r--r--test/rubygems/test_gem_package.rb277
-rw-r--r--test/rubygems/test_gem_package_old.rb112
-rw-r--r--test/rubygems/test_gem_package_tar_header.rb45
-rw-r--r--test/rubygems/test_gem_package_tar_reader.rb1
-rw-r--r--test/rubygems/test_gem_package_tar_reader_entry.rb22
-rw-r--r--test/rubygems/test_gem_package_tar_writer.rb70
-rw-r--r--test/rubygems/test_gem_package_task.rb4
-rw-r--r--test/rubygems/test_gem_path_support.rb63
-rw-r--r--test/rubygems/test_gem_platform.rb15
-rw-r--r--test/rubygems/test_gem_rdoc.rb138
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb429
-rw-r--r--test/rubygems/test_gem_request.rb46
-rw-r--r--test/rubygems/test_gem_request_connection_pools.rb35
-rw-r--r--test/rubygems/test_gem_request_set.rb103
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb148
-rw-r--r--test/rubygems/test_gem_request_set_lockfile.rb4
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_parser.rb16
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_tokenizer.rb4
-rw-r--r--test/rubygems/test_gem_requirement.rb40
-rw-r--r--test/rubygems/test_gem_resolver.rb120
-rw-r--r--test/rubygems/test_gem_resolver_activation_request.rb36
-rw-r--r--test/rubygems/test_gem_resolver_api_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_api_specification.rb25
-rw-r--r--test/rubygems/test_gem_resolver_best_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_composed_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_conflict.rb5
-rw-r--r--test/rubygems/test_gem_resolver_dependency_request.rb1
-rw-r--r--test/rubygems/test_gem_resolver_git_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_git_specification.rb2
-rw-r--r--test/rubygems/test_gem_resolver_index_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_index_specification.rb10
-rw-r--r--test/rubygems/test_gem_resolver_installed_specification.rb2
-rw-r--r--test/rubygems/test_gem_resolver_installer_set.rb11
-rw-r--r--test/rubygems/test_gem_resolver_local_specification.rb1
-rw-r--r--test/rubygems/test_gem_resolver_lock_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_lock_specification.rb1
-rw-r--r--test/rubygems/test_gem_resolver_requirement_list.rb1
-rw-r--r--test/rubygems/test_gem_resolver_specification.rb5
-rw-r--r--test/rubygems/test_gem_resolver_vendor_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_vendor_specification.rb1
-rw-r--r--test/rubygems/test_gem_security.rb12
-rw-r--r--test/rubygems/test_gem_security_policy.rb15
-rw-r--r--test/rubygems/test_gem_security_signer.rb8
-rw-r--r--test/rubygems/test_gem_security_trust_dir.rb3
-rw-r--r--test/rubygems/test_gem_server.rb33
-rw-r--r--test/rubygems/test_gem_silent_ui.rb1
-rw-r--r--test/rubygems/test_gem_source.rb41
-rw-r--r--test/rubygems/test_gem_source_fetch_problem.rb2
-rw-r--r--test/rubygems/test_gem_source_git.rb14
-rw-r--r--test/rubygems/test_gem_source_installed.rb13
-rw-r--r--test/rubygems/test_gem_source_list.rb1
-rw-r--r--test/rubygems/test_gem_source_local.rb9
-rw-r--r--test/rubygems/test_gem_source_lock.rb25
-rw-r--r--test/rubygems/test_gem_source_specific_file.rb13
-rw-r--r--test/rubygems/test_gem_source_vendor.rb9
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb1
-rw-r--r--test/rubygems/test_gem_specification.rb812
-rw-r--r--test/rubygems/test_gem_stream_ui.rb53
-rw-r--r--test/rubygems/test_gem_stub_specification.rb7
-rw-r--r--test/rubygems/test_gem_text.rb5
-rw-r--r--test/rubygems/test_gem_uninstaller.rb86
-rw-r--r--test/rubygems/test_gem_unsatisfiable_dependency_error.rb1
-rw-r--r--test/rubygems/test_gem_uri_formatter.rb1
-rw-r--r--test/rubygems/test_gem_util.rb52
-rw-r--r--test/rubygems/test_gem_validator.rb8
-rw-r--r--test/rubygems/test_gem_version.rb82
-rw-r--r--test/rubygems/test_gem_version_option.rb1
-rw-r--r--test/rubygems/test_kernel.rb20
-rw-r--r--test/rubygems/test_project_sanity.rb15
-rw-r--r--test/rubygems/test_remote_fetch_error.rb4
-rw-r--r--test/rubygems/test_require.rb354
-rw-r--r--test/runner.rb37
-rw-r--r--test/scanf/data.txt6
-rw-r--r--test/scanf/test_scanf.rb305
-rw-r--r--test/scanf/test_scanfblocks.rb82
-rw-r--r--test/scanf/test_scanfio.rb28
-rw-r--r--test/shell/test_command_processor.rb100
-rw-r--r--test/socket/test_addrinfo.rb12
-rw-r--r--test/socket/test_basicsocket.rb1
-rw-r--r--test/socket/test_nonblock.rb4
-rw-r--r--test/socket/test_socket.rb66
-rw-r--r--test/socket/test_tcp.rb25
-rw-r--r--test/socket/test_udp.rb10
-rw-r--r--test/stringio/test_stringio.rb67
-rw-r--r--test/strscan/test_stringscanner.rb301
-rw-r--r--test/syslog/test_syslog_logger.rb15
-rw-r--r--test/test_cmath.rb76
-rw-r--r--test/test_delegate.rb94
-rw-r--r--test/test_find.rb2
-rw-r--r--test/test_forwardable.rb67
-rw-r--r--test/test_ipaddr.rb14
-rw-r--r--test/test_open3.rb23
-rw-r--r--test/test_pp.rb26
-rw-r--r--test/test_prime.rb84
-rw-r--r--test/test_pstore.rb2
-rw-r--r--test/test_pty.rb7
-rw-r--r--test/test_securerandom.rb5
-rw-r--r--test/test_set.rb27
-rw-r--r--test/test_shellwords.rb5
-rw-r--r--test/test_syslog.rb9
-rw-r--r--test/test_tempfile.rb76
-rw-r--r--test/test_time.rb63
-rw-r--r--test/test_tmpdir.rb55
-rw-r--r--test/test_tracer.rb178
-rw-r--r--test/test_unicode_normalize.rb20
-rw-r--r--test/test_win32api.rb3
-rw-r--r--test/testunit/test4test_hideskip.rb10
-rw-r--r--test/testunit/test4test_redefinition.rb14
-rw-r--r--test/testunit/test4test_sorting.rb18
-rw-r--r--test/testunit/test_assertion.rb (renamed from tool/test/testunit/test_assertion.rb)0
-rw-r--r--test/testunit/test_hideskip.rb17
-rw-r--r--test/testunit/test_parallel.rb200
-rw-r--r--test/testunit/test_redefinition.rb (renamed from tool/test/testunit/test_redefinition.rb)0
-rw-r--r--test/testunit/test_sorting.rb (renamed from tool/test/testunit/test_sorting.rb)0
-rw-r--r--test/testunit/tests_for_parallel/ptest_first.rb (renamed from tool/test/testunit/tests_for_parallel/ptest_first.rb)0
-rw-r--r--test/testunit/tests_for_parallel/ptest_forth.rb (renamed from tool/test/testunit/tests_for_parallel/ptest_forth.rb)0
-rw-r--r--test/testunit/tests_for_parallel/ptest_second.rb (renamed from tool/test/testunit/tests_for_parallel/ptest_second.rb)0
-rw-r--r--test/testunit/tests_for_parallel/ptest_third.rb (renamed from tool/test/testunit/tests_for_parallel/ptest_third.rb)0
-rw-r--r--test/testunit/tests_for_parallel/runner.rb14
-rw-r--r--test/thread/test_cv.rb239
-rw-r--r--test/thread/test_queue.rb616
-rw-r--r--test/thread/test_sync.rb68
-rw-r--r--test/uri/test_common.rb3
-rw-r--r--test/uri/test_file.rb67
-rw-r--r--test/uri/test_generic.rb29
-rw-r--r--test/uri/test_ldap.rb4
-rw-r--r--test/uri/test_parser.rb13
-rw-r--r--test/webrick/test_filehandler.rb8
-rw-r--r--test/webrick/test_htgroup.rb19
-rw-r--r--test/webrick/test_httpauth.rb182
-rw-r--r--test/webrick/test_httpproxy.rb140
-rw-r--r--test/webrick/test_httprequest.rb63
-rw-r--r--test/webrick/test_httpresponse.rb35
-rw-r--r--test/webrick/test_httpserver.rb39
-rw-r--r--test/webrick/test_httpstatus.rb35
-rw-r--r--test/webrick/test_server.rb1
-rw-r--r--test/webrick/test_ssl_server.rb2
-rw-r--r--test/webrick/test_utils.rb6
-rw-r--r--test/webrick/utils.rb10
-rw-r--r--test/win32ole/available_ole.rb41
-rw-r--r--test/win32ole/test_thread.rb2
-rw-r--r--test/win32ole/test_win32ole.rb45
-rw-r--r--test/win32ole/test_win32ole_event.rb87
-rw-r--r--test/win32ole/test_win32ole_method.rb13
-rw-r--r--test/win32ole/test_win32ole_method_event.rb36
-rw-r--r--test/win32ole/test_win32ole_param.rb53
-rw-r--r--test/win32ole/test_win32ole_param_event.rb30
-rw-r--r--test/win32ole/test_win32ole_record.rb18
-rw-r--r--test/win32ole/test_win32ole_type.rb52
-rw-r--r--test/win32ole/test_win32ole_type_event.rb44
-rw-r--r--test/zlib/test_zlib.rb108
-rw-r--r--thread.c1609
-rw-r--r--thread_pthread.c1921
-rw-r--r--thread_pthread.h51
-rw-r--r--thread_sync.c196
-rw-r--r--thread_win32.c151
-rw-r--r--thread_win32.h2
-rw-r--r--time.c1679
-rw-r--r--timev.h32
-rwxr-xr-xtool/actions-commit-info.sh17
-rwxr-xr-xtool/bisect.sh31
-rwxr-xr-xtool/change_maker.rb47
-rwxr-xr-xtool/checksum.rb4
-rw-r--r--tool/colorize.rb41
-rwxr-xr-xtool/darwin-cc6
-rw-r--r--tool/downloader.rb85
-rw-r--r--tool/enc-emoji-citrus-gen.rb4
-rwxr-xr-xtool/enc-unicode.rb75
-rw-r--r--tool/eval.rb4
-rwxr-xr-xtool/expand-config.rb2
-rwxr-xr-xtool/extlibs.rb21
-rw-r--r--tool/fake.rb35
-rwxr-xr-xtool/fetch-bundled_gems.rb6
-rwxr-xr-xtool/file2lastrev.rb76
-rwxr-xr-xtool/format-release245
-rwxr-xr-x[-rw-r--r--]tool/gem-unpack.rb0
-rwxr-xr-xtool/gen-mailmap.rb47
-rwxr-xr-xtool/gen_ruby_tapset.rb11
-rw-r--r--tool/generate-backport-changelog.rb99
-rw-r--r--tool/generic_erb.rb15
-rwxr-xr-xtool/git-refresh3
-rwxr-xr-xtool/id2token.rb3
-rwxr-xr-xtool/ifchange3
-rwxr-xr-xtool/insns2vm.rb17
-rwxr-xr-xtool/instruction.rb1249
-rw-r--r--tool/jisx0208.rb (renamed from tool/lib/jisx0208.rb)0
-rwxr-xr-xtool/leaked-globals40
-rw-r--r--tool/lib/colorize.rb51
-rw-r--r--tool/lib/envutil.rb345
-rw-r--r--tool/lib/gc_compact_checker.rb10
-rw-r--r--tool/lib/iseq_loader_checker.rb81
-rw-r--r--tool/lib/leakchecker.rb240
-rw-r--r--tool/lib/minitest/unit.rb1434
-rw-r--r--tool/lib/profile_test_all.rb91
-rw-r--r--tool/lib/test/unit.rb1219
-rw-r--r--tool/lib/test/unit/assertions.rb583
-rw-r--r--tool/lib/test/unit/core_assertions.rb420
-rw-r--r--tool/lib/test/unit/parallel.rb214
-rw-r--r--tool/lib/tracepointchecker.rb126
-rw-r--r--tool/lib/vcs.rb749
-rw-r--r--tool/lib/zombie_hunter.rb10
-rw-r--r--tool/m4/_colorize_result_prepare.m433
-rw-r--r--tool/m4/ac_msg_result.m45
-rw-r--r--tool/m4/colorize_result.m49
-rw-r--r--tool/m4/ruby_append_option.m45
-rw-r--r--tool/m4/ruby_append_options.m47
-rw-r--r--tool/m4/ruby_check_builtin_func.m410
-rw-r--r--tool/m4/ruby_check_builtin_setjmp.m427
-rw-r--r--tool/m4/ruby_check_printf_prefix.m429
-rw-r--r--tool/m4/ruby_check_setjmp.m417
-rw-r--r--tool/m4/ruby_check_signedness.m45
-rw-r--r--tool/m4/ruby_check_sizeof.m4108
-rw-r--r--tool/m4/ruby_check_sysconf.m413
-rw-r--r--tool/m4/ruby_cppoutfile.m418
-rw-r--r--tool/m4/ruby_decl_attribute.m445
-rw-r--r--tool/m4/ruby_default_arch.m411
-rw-r--r--tool/m4/ruby_define_if.m412
-rw-r--r--tool/m4/ruby_defint.m440
-rw-r--r--tool/m4/ruby_dtrace_available.m420
-rw-r--r--tool/m4/ruby_dtrace_postprocess.m430
-rw-r--r--tool/m4/ruby_func_attribute.m47
-rw-r--r--tool/m4/ruby_mingw32.m424
-rw-r--r--tool/m4/ruby_prepend_option.m45
-rw-r--r--tool/m4/ruby_prog_gnu_ld.m410
-rw-r--r--tool/m4/ruby_replace_funcs.m413
-rw-r--r--tool/m4/ruby_replace_type.m458
-rw-r--r--tool/m4/ruby_rm_recursive.m418
-rw-r--r--tool/m4/ruby_setjmp_type.m452
-rw-r--r--tool/m4/ruby_stack_grow_direction.m430
-rw-r--r--tool/m4/ruby_try_cflags.m412
-rw-r--r--tool/m4/ruby_try_ldflags.m415
-rw-r--r--tool/m4/ruby_type_attribute.m48
-rw-r--r--tool/m4/ruby_universal_arch.m490
-rw-r--r--tool/m4/ruby_werror_flag.m418
-rwxr-xr-xtool/make-snapshot401
-rwxr-xr-xtool/merger.rb445
-rw-r--r--tool/mjit_archflag.sh40
-rw-r--r--tool/mk_builtin_binary.rb44
-rw-r--r--tool/mk_builtin_loader.rb201
-rw-r--r--tool/mk_call_iseq_optimized.rb7
-rwxr-xr-xtool/mkconfig.rb67
-rwxr-xr-xtool/mkrunnable.rb2
-rwxr-xr-xtool/node_name.rb8
-rw-r--r--tool/prereq.status3
-rwxr-xr-xtool/pull-latest-mspec-spec18
-rwxr-xr-xtool/pure_parser.rb24
-rwxr-xr-xtool/rbinstall.rb100
-rwxr-xr-xtool/redmine-backporter.rb95
-rwxr-xr-xtool/release.sh47
-rw-r--r--tool/ruby_vm/controllers/application_controller.rb25
-rw-r--r--tool/ruby_vm/helpers/c_escape.rb128
-rw-r--r--tool/ruby_vm/helpers/dumper.rb112
-rw-r--r--tool/ruby_vm/helpers/scanner.rb52
-rw-r--r--tool/ruby_vm/loaders/insns_def.rb96
-rw-r--r--tool/ruby_vm/loaders/opt_insn_unif_def.rb34
-rw-r--r--tool/ruby_vm/loaders/opt_operand_def.rb56
-rw-r--r--tool/ruby_vm/loaders/vm_opts_h.rb37
-rw-r--r--tool/ruby_vm/models/attribute.rb59
-rwxr-xr-xtool/ruby_vm/models/bare_instructions.rb236
-rw-r--r--tool/ruby_vm/models/c_expr.rb41
-rw-r--r--tool/ruby_vm/models/instructions.rb22
-rw-r--r--tool/ruby_vm/models/instructions_unifications.rb43
-rw-r--r--tool/ruby_vm/models/operands_unifications.rb142
-rw-r--r--tool/ruby_vm/models/trace_instructions.rb71
-rw-r--r--tool/ruby_vm/models/typemap.rb63
-rw-r--r--tool/ruby_vm/scripts/converter.rb29
-rw-r--r--tool/ruby_vm/scripts/insns2vm.rb93
-rw-r--r--tool/ruby_vm/tests/.gitkeep0
-rw-r--r--tool/ruby_vm/views/_attributes.erb35
-rw-r--r--tool/ruby_vm/views/_c_expr.erb17
-rw-r--r--tool/ruby_vm/views/_comptime_insn_stack_increase.erb62
-rw-r--r--tool/ruby_vm/views/_copyright.erb31
-rw-r--r--tool/ruby_vm/views/_insn_entry.erb76
-rw-r--r--tool/ruby_vm/views/_insn_len_info.erb21
-rw-r--r--tool/ruby_vm/views/_insn_name_info.erb38
-rw-r--r--tool/ruby_vm/views/_insn_operand_info.erb46
-rw-r--r--tool/ruby_vm/views/_insn_sp_pc_dependency.erb27
-rw-r--r--tool/ruby_vm/views/_insn_type_chars.erb13
-rw-r--r--tool/ruby_vm/views/_leaf_helpers.erb108
-rw-r--r--tool/ruby_vm/views/_mjit_compile_insn.erb92
-rw-r--r--tool/ruby_vm/views/_mjit_compile_insn_body.erb115
-rw-r--r--tool/ruby_vm/views/_mjit_compile_ivar.erb54
-rw-r--r--tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb36
-rw-r--r--tool/ruby_vm/views/_mjit_compile_send.erb107
-rw-r--r--tool/ruby_vm/views/_notice.erb22
-rw-r--r--tool/ruby_vm/views/_sp_inc_helpers.erb37
-rw-r--r--tool/ruby_vm/views/_trace_instruction.erb16
-rw-r--r--tool/ruby_vm/views/insns.inc.erb26
-rw-r--r--tool/ruby_vm/views/insns_info.inc.erb22
-rw-r--r--tool/ruby_vm/views/mjit_compile.inc.erb93
-rw-r--r--tool/ruby_vm/views/opt_sc.inc.erb40
-rw-r--r--tool/ruby_vm/views/optinsn.inc.erb71
-rw-r--r--tool/ruby_vm/views/optunifs.inc.erb21
-rw-r--r--tool/ruby_vm/views/vm.inc.erb30
-rw-r--r--tool/ruby_vm/views/vmtc.inc.erb21
-rwxr-xr-xtool/runruby.rb26
-rw-r--r--tool/sync_default_gems.rb439
-rw-r--r--tool/test-bundled-gems.rb28
-rw-r--r--tool/test-coverage.rb17
-rw-r--r--tool/test/minitest/test_minitest_mock.rb404
-rw-r--r--tool/test/minitest/test_minitest_unit.rb1790
-rw-r--r--tool/test/runner.rb23
-rw-r--r--tool/test/test_jisx0208.rb2
-rw-r--r--tool/test/testunit/test4test_hideskip.rb10
-rw-r--r--tool/test/testunit/test4test_redefinition.rb14
-rw-r--r--tool/test/testunit/test4test_sorting.rb18
-rw-r--r--tool/test/testunit/test_hideskip.rb21
-rw-r--r--tool/test/testunit/test_parallel.rb204
-rw-r--r--tool/test/testunit/tests_for_parallel/runner.rb14
-rw-r--r--tool/transcode-tblgen.rb24
-rw-r--r--tool/transform_mjit_header.rb298
-rwxr-xr-xtool/travis_retry.sh13
-rwxr-xr-xtool/update-deps38
-rw-r--r--tool/vcs.rb495
-rw-r--r--tool/vpath.rb (renamed from tool/lib/vpath.rb)0
-rwxr-xr-xtool/ytab.sed65
-rw-r--r--trace_point.rb348
-rw-r--r--transcode.c62
-rw-r--r--transient_heap.c940
-rw-r--r--transient_heap.h62
-rw-r--r--util.c3461
-rw-r--r--variable.c1360
-rw-r--r--variable.h9
-rw-r--r--version.c55
-rw-r--r--version.h36
-rw-r--r--vm.c1101
-rw-r--r--vm_args.c530
-rw-r--r--vm_backtrace.c64
-rw-r--r--vm_core.h554
-rw-r--r--vm_debug.h3
-rw-r--r--vm_dump.c256
-rw-r--r--vm_eval.c1005
-rw-r--r--vm_exec.c14
-rw-r--r--vm_exec.h55
-rw-r--r--vm_insnhelper.c2421
-rw-r--r--vm_insnhelper.h136
-rw-r--r--vm_method.c574
-rw-r--r--vm_opts.h24
-rw-r--r--vm_trace.c895
-rw-r--r--vsnprintf.c5
-rw-r--r--warning.rb45
-rw-r--r--win32/.document1
-rw-r--r--win32/Makefile.sub296
-rw-r--r--win32/README.win32100
-rwxr-xr-xwin32/configure.bat22
-rw-r--r--win32/file.c20
-rwxr-xr-xwin32/ifchange.bat13
-rwxr-xr-xwin32/mkexports.rb10
-rwxr-xr-xwin32/rm.bat2
-rw-r--r--[-rwxr-xr-x]win32/rtname.cmd0
-rw-r--r--win32/setup.mak33
-rw-r--r--win32/win32.c405
7727 files changed, 181685 insertions, 444862 deletions
diff --git a/.dir-locals.el b/.dir-locals.el
deleted file mode 100644
index 7c32d1f7ee..0000000000
--- a/.dir-locals.el
+++ /dev/null
@@ -1,37 +0,0 @@
-;; Copyright (c) 2018 Urabe, Shyouhei. All rights reserved.
-;;
-;; This file is a part of the programming language Ruby. Permission is hereby
-;; granted, to either redistribute and/or modify this file, provided that the
-;; conditions mentioned in the file COPYING are met. Consult the file for
-;; details.
-
-((nil .
- ((indent-tabs-mode . nil)
- (require-final-newline . t)
- (tab-width . 8)
- (show-trailing-whitespace . t)
- (whitespace-line-column . 80))) ;; See also [Misc #12277]
-
- ;; (bat-mode . ((buffer-file-coding-system . utf-8-dos)))
-
- (ruby-mode . ((ruby-indent-level . 2)))
-
- (rdoc-mode . ((fill-column . 74)))
-
- (yaml-mode . ((yaml-indent-offset . 2)))
-
- (makefile-mode . ((indent-tabs-mode . t)))
-
- (c-mode . ((c-file-style . "ruby")))
-
- (change-log-mode .
- ((buffer-file-coding-system . us-ascii)
- (indent-tabs-mode . t)
- (change-log-indent-text . 2)
- (add-log-time-format . (lambda (&optional x y)
- (let* ((time (or x (current-time)))
- (system-time-locale "C")
- (diff (+ (cadr time) 32400))
- (lo (% diff 65536))
- (hi (+ (car time) (/ diff 65536))))
- (format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t)))))))
diff --git a/.document b/.document
index 8a418e5d4a..eeb565b08b 100644
--- a/.document
+++ b/.document
@@ -9,14 +9,8 @@
# prelude
prelude.rb
-rbconfig.rb
-ast.rb
-gc.rb
-io.rb
-pack.rb
-trace_point.rb
-warning.rb
+rbconfig.rb
# the lib/ directory (which has its own .document file)
lib
@@ -30,13 +24,4 @@ NEWS
README.md
README.ja.md
-COPYING
-COPYING.ja
-CONTRIBUTING.md
-
-LEGAL
-
-# win32/README.win32 linked from README.md
-win32
-
doc
diff --git a/.editorconfig b/.editorconfig
index 4633a7acae..49cc692091 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -3,7 +3,7 @@ root = true
[*]
end_of_line = lf
indent_size = 4
-indent_style = space
+indent_style = tab
insert_final_newline = true
tab_width = 8
trim_trailing_whitespace = true
@@ -13,18 +13,12 @@ end_of_line = crlf
[*.gemspec]
indent_size = 2
+indent_style = space
[*.rb]
indent_size = 2
+indent_style = space
[*.yml]
indent_size = 2
-
-[{*[Mm]akefile*,*.mak,*.mk,depend}]
-indent_style = tab
-
-[enc/*]
-indent_size = 2
-
-[reg*.[ch]]
-indent_size = 2
+indent_style = space
diff --git a/.gdbinit b/.gdbinit
index 0d44622691..a188ffa172 100644
--- a/.gdbinit
+++ b/.gdbinit
@@ -1,5 +1,3 @@
-set startup-with-shell off
-
define hook-run
set $color_type = 0
set $color_highlite = 0
@@ -156,12 +154,8 @@ define rp
else
if ($flags & RUBY_T_MASK) == RUBY_T_HASH
printf "%sT_HASH%s: ", $color_type, $color_end,
- if (((struct RHash *)($arg0))->basic->flags & RHASH_ST_TABLE_FLAG)
- printf "st len=%ld ", ((struct RHash *)($arg0))->as.st->num_entries
- else
- printf "li len=%ld bound=%ld ", \
- ((((struct RHash *)($arg0))->basic->flags & RHASH_AR_TABLE_SIZE_MASK) >> RHASH_AR_TABLE_SIZE_SHIFT), \
- ((((struct RHash *)($arg0))->basic->flags & RHASH_AR_TABLE_BOUND_MASK) >> RHASH_AR_TABLE_BOUND_SHIFT)
+ if ((struct RHash *)($arg0))->ntbl
+ printf "len=%ld ", ((struct RHash *)($arg0))->ntbl->num_entries
end
print (struct RHash *)($arg0)
else
@@ -704,6 +698,12 @@ define nd_cval
rp ($arg0).u3.value
end
+
+define nd_cnt
+ printf "%su3.cnt%s: ", $color_highlite, $color_end
+ p ($arg0).u3.cnt
+end
+
define nd_tbl
printf "%su1.tbl%s: ", $color_highlite, $color_end
p ($arg0).u1.tbl
@@ -742,6 +742,12 @@ define nd_lit
rp ($arg0).u1.value
end
+
+define nd_frml
+ printf "%su1.node%s: ", $color_highlite, $color_end
+ rp ($arg0).u1.node
+end
+
define nd_rest
printf "%su2.argc%s: ", $color_highlite, $color_end
p ($arg0).u2.argc
@@ -768,6 +774,12 @@ define nd_args
rp ($arg0).u3.node
end
+
+define nd_noex
+ printf "%su1.id%s: ", $color_highlite, $color_end
+ p ($arg0).u1.id
+end
+
define nd_defn
printf "%su3.node%s: ", $color_highlite, $color_end
rp ($arg0).u3.node
@@ -785,6 +797,17 @@ define nd_new
end
+define nd_cfnc
+ printf "%su1.cfunc%s: ", $color_highlite, $color_end
+ p ($arg0).u1.cfunc
+end
+
+define nd_argc
+ printf "%su2.argc%s: ", $color_highlite, $color_end
+ p ($arg0).u2.argc
+end
+
+
define nd_cname
printf "%su1.id%s: ", $color_highlite, $color_end
p ($arg0).u1.id
@@ -998,55 +1021,24 @@ define print_lineno
set $pos = $pos - 1
end
- set $index = 0
- set $size = $iseq->body->insns_info.size
- set $table = $iseq->body->insns_info.body
- set $positions = $iseq->body->insns_info.positions
+ set $i = 0
+ set $size = $iseq->body->insns_info_size
+ set $table = $iseq->body->insns_info
#printf "size: %d\n", $size
if $size == 0
else
- if $size == 1
- printf "%d", $table[0].line_no
- else
- if $positions
- # get_insn_info_linear_search
- set $index = 1
- while $index < $size
- #printf "table[%d]: position: %d, line: %d, pos: %d\n", $i, $positions[$i], $table[$i].line_no, $pos
- if $positions[$index] > $pos
- loop_break
- end
- set $index = $index + 1
- if $positions[$index] == $pos
- loop_break
- end
+ set $i = 1
+ while $i < $size
+ #printf "table[%d]: position: %d, line: %d, pos: %d\n", $i, $table[$i].position, $table[$i].line_no, $pos
+ if $table[$i].position > $pos
+ loop_break
end
- else
- # get_insn_info_succinct_bitvector
- set $sd = $iseq->body->insns_info.succ_index_table
- set $immediate_table_size = sizeof($sd->imm_part) / sizeof(uint64_t) * 9
- if $pos < $immediate_table_size
- set $i = $pos / 9
- set $j = $pos % 9
- set $index = ((int)($sd->imm_part[$i] >> ($j * 7))) & 0x7f
- else
- set $block_index = ($pos - $immediate_table_size) / 512
- set $block = &$sd->succ_part[$block_index]
- set $block_bit_index = ($pos - $immediate_table_size) % 512
- set $small_block_index = $block_bit_index / 64
- set $small_block_popcount = $small_block_index == 0 ? 0 : (((int)($block->small_block_ranks >> (($small_block_index - 1) * 9))) & 0x1ff)
- set $x = $block->bits[$small_block_index] << (63 - $block_bit_index % 64)
- set $x = ($x & 0x5555555555555555) + ($x >> 1 & 0x5555555555555555)
- set $x = ($x & 0x3333333333333333) + ($x >> 2 & 0x3333333333333333)
- set $x = ($x & 0x0707070707070707) + ($x >> 4 & 0x0707070707070707)
- set $x = ($x & 0x001f001f001f001f) + ($x >> 8 & 0x001f001f001f001f)
- set $x = ($x & 0x0000003f0000003f) + ($x >>16 & 0x0000003f0000003f)
- set $popcnt = ($x & 0x7f) + ($x >>32 & 0x7f)
- set $index = $block->rank + $small_block_popcount + $popcnt
+ set $i = $i + 1
+ if $table[$i].position == $pos
+ loop_break
end
end
- printf "%d", $table[$index-1].line_no
- end
+ printf "%d", $table[$i-1].line_no
end
end
@@ -1073,9 +1065,9 @@ define print_id
else
set $serial = (rb_id_serial_t)$id
end
- if $serial && $serial <= ruby_global_symbols.last_id
+ if $serial && $serial <= global_symbols.last_id
set $idx = $serial / ID_ENTRY_UNIT
- set $ids = (struct RArray *)ruby_global_symbols.ids
+ set $ids = (struct RArray *)global_symbols.ids
set $flags = $ids->basic.flags
if ($flags & RUBY_FL_USER1)
set $idsptr = $ids->as.ary
@@ -1313,34 +1305,3 @@ define dump_node
((struct RString*)$str)->as.heap.ptr : \
((struct RString*)$str)->as.ary)
end
-
-define print_flags
- printf "RUBY_FL_WB_PROTECTED: %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_WB_PROTECTED ? "1" : "0"
- printf "RUBY_FL_PROMOTED0 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED0 ? "1" : "0"
- printf "RUBY_FL_PROMOTED1 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED1 ? "1" : "0"
- printf "RUBY_FL_FINALIZE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FINALIZE ? "1" : "0"
- printf "RUBY_FL_TAINT : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_TAINT ? "1" : "0"
- printf "RUBY_FL_UNTRUSTED : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_UNTRUSTED ? "1" : "0"
- printf "RUBY_FL_EXIVAR : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_EXIVAR ? "1" : "0"
- printf "RUBY_FL_FREEZE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FREEZE ? "1" : "0"
-
- printf "RUBY_FL_USER0 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER0 ? "1" : "0"
- printf "RUBY_FL_USER1 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER1 ? "1" : "0"
- printf "RUBY_FL_USER2 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER2 ? "1" : "0"
- printf "RUBY_FL_USER3 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER3 ? "1" : "0"
- printf "RUBY_FL_USER4 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER4 ? "1" : "0"
- printf "RUBY_FL_USER5 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER5 ? "1" : "0"
- printf "RUBY_FL_USER6 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER6 ? "1" : "0"
- printf "RUBY_FL_USER7 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER7 ? "1" : "0"
- printf "RUBY_FL_USER8 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER8 ? "1" : "0"
- printf "RUBY_FL_USER9 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER9 ? "1" : "0"
- printf "RUBY_FL_USER10 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER10 ? "1" : "0"
- printf "RUBY_FL_USER11 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER11 ? "1" : "0"
- printf "RUBY_FL_USER12 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER12 ? "1" : "0"
- printf "RUBY_FL_USER13 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER13 ? "1" : "0"
- printf "RUBY_FL_USER14 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER14 ? "1" : "0"
- printf "RUBY_FL_USER15 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER15 ? "1" : "0"
- printf "RUBY_FL_USER16 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER16 ? "1" : "0"
- printf "RUBY_FL_USER17 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER17 ? "1" : "0"
- printf "RUBY_FL_USER18 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER18 ? "1" : "0"
-end
diff --git a/.gitattributes b/.gitattributes
index d0c2d266b4..6ca2f89462 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -4,5 +4,3 @@ bin svn-properties=svn:ignore=ruby
bin/* diff=ruby
tool/update-deps diff=ruby
tool/make-snapshot diff=ruby
-tool/format-release diff=ruby
-tool/leaked-globals diff=ruby
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
deleted file mode 100644
index 56baa29942..0000000000
--- a/.github/SECURITY.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Security Policy
-
-## Supported Versions
-
-See <https://www.ruby-lang.org/en/downloads/branches/>.
-
-## Reporting a Vulnerability
-
-See <https://www.ruby-lang.org/en/security/>.
diff --git a/.github/workflows/check_branch.yml b/.github/workflows/check_branch.yml
deleted file mode 100644
index 40292838f2..0000000000
--- a/.github/workflows/check_branch.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-# We bidirectionally synchronize github.com/ruby/ruby.git's ruby_2_7 branch and
-# git.ruby-lang.org/ruby.git's ruby_2_7 branch.
-# We can use a pull request's merge button only on the ruby_2_7 branch.
-#
-# Therefore, we require to pass this "check_branch" on all protected branches
-# to prevent us from accidentally pushing commits to GitHub directly.
-#
-# Details: https://bugs.ruby-lang.org/issues/16094
-name: Pull Request
-on: [pull_request]
-jobs:
- check_branch:
- runs-on: ubuntu-latest
- steps:
- - name: Check if branch is ruby_2_7
- run: |
- if [ "$BASE_REF" != ruby_2_7 ]; then
- echo "Only ruby_2_7 branch accepts a pull request, but it's '$BASE_REF'."
- exit 1
- fi
- env:
- BASE_REF: ${{ github.base_ref }}
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
deleted file mode 100644
index 6cdbdc272b..0000000000
--- a/.github/workflows/macos.yml
+++ /dev/null
@@ -1,82 +0,0 @@
-name: macOS
-on:
- push:
- branches:
- - '*'
- pull_request:
- branches:
- - '*'
-jobs:
- make:
- runs-on: macos-latest
- strategy:
- matrix:
- test_task: [ "check", "test-bundler", "test-bundled-gems" ]
- fail-fast: false
- if: "!contains(github.event.head_commit.message, '[ci skip]')"
- steps:
- - name: Disable Firewall
- run: |
- sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
- sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
- # Not using official actions/checkout because it's unstable and sometimes doesn't work for a fork.
- - name: Checkout ruby
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${GITHUB_REF#refs/heads/} https://github.com/${{ github.repository }} src
- git -C src reset --hard "$GITHUB_SHA"
- if: github.event_name == 'push'
- - name: Checkout a pull request
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${{ github.event.pull_request.head.ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }} src
- git -C src reset --hard ${{ github.event.pull_request.head.sha }}
- if: github.event_name == 'pull_request'
- - run: ./src/tool/actions-commit-info.sh
- id: commit_info
- - name: Install libraries
- run: |
- export WAITS='5 60'
- cd src
- tool/travis_retry.sh brew upgrade
- tool/travis_retry.sh brew install gdbm gmp libffi openssl@1.1 zlib autoconf automake libtool readline
- - name: Set ENV
- run: |
- echo "JOBS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
- - name: Autoconf
- run: |
- cd src
- autoconf
- - name: Configure
- run: |
- mkdir build
- cd build
- ../src/configure -C --disable-install-doc --with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline)
- - name: Make
- run: make -C build $JOBS
- - name: Remove system gems
- run: rm -rf /usr/local/lib/ruby/gems/2.7.0/
- - name: Extract gems
- run: make -C build update-gems extract-gems
- if: matrix.test_task == 'check'
- - name: Tests
- run: make -C build $JOBS -s ${{ matrix.test_task }}
- env:
- RUBY_TESTOPTS: "-q --tty=no"
- # Remove minitest from TEST_BUNDLED_GEMS_ALLOW_FAILURES if https://github.com/seattlerb/minitest/pull/798 is resolved
- # rss needs to add workaround for the non rexml environment
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: "minitest,xmlrpc,rss,rexml"
- - name: Leaked Globals
- run: make -C build -s leaked-globals
- - uses: k0kubun/action-slack@v2.0.0
- with:
- payload: |
- {
- "attachments": [{
- "text": "${{ github.workflow }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ steps.commit_info.outputs.COMMIT_DATE }} #${{ steps.commit_info.outputs.COMMIT_NUMBER_OF_DAY }}> " +
- "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
- "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }} failed",
- "color": "danger"
- }]
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- if: failure() && github.event_name == 'push'
diff --git a/.github/workflows/mjit.yml b/.github/workflows/mjit.yml
deleted file mode 100644
index 5b662caa14..0000000000
--- a/.github/workflows/mjit.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-name: MJIT
-on:
- push:
- branches:
- - '*'
- pull_request:
- branches:
- - '*'
-jobs:
- make:
- strategy:
- matrix:
- test_task: [ "check" ] # to make job names consistent
- jit_opts: [ "--jit", "--jit-wait" ]
- fail-fast: false
- runs-on: ubuntu-latest
- if: "!contains(github.event.head_commit.message, '[ci skip]')"
- steps:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev bison autoconf ruby
- # Not using official actions/checkout because it's unstable and sometimes doesn't work for a fork.
- - name: Checkout ruby
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${GITHUB_REF#refs/heads/} https://github.com/${{ github.repository }} src
- git -C src reset --hard "$GITHUB_SHA"
- if: github.event_name == 'push'
- - name: Checkout a pull request
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${{ github.event.pull_request.head.ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }} src
- git -C src reset --hard ${{ github.event.pull_request.head.sha }}
- if: github.event_name == 'pull_request'
- - run: ./src/tool/actions-commit-info.sh
- id: commit_info
- - name: Fixed world writable dirs
- run: |
- chmod go-w $HOME
- sudo chmod -R go-w /usr/share
- - name: Set ENV
- run: |
- echo "JOBS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - name: Autoconf
- run: cd src && exec autoconf
- - name: configure
- run: |
- mkdir build
- cd build
- ../src/configure -C --disable-install-doc
- - name: make all
- run: make -C build $JOBS
- - name: make install
- run: sudo make -C build $JOBS install
- - name: make test
- run: "make -C build $JOBS -s test TESTOPTS='-q --tty=no' RUN_OPTS='--disable-gems --jit-warnings ${{ matrix.jit_opts }}'"
- - name: make test-all
- run: "make -C build $JOBS -s test-all TESTOPTS='-q --tty=no' RUN_OPTS='--disable-gems --jit-warnings ${{ matrix.jit_opts }}'"
- - name: make test-spec
- run: "make -C build $JOBS -s test-spec RUN_OPTS='--disable-gems --jit-warnings ${{ matrix.jit_opts }}'"
- - name: Leaked Globals
- run: make -C build -s leaked-globals
- - uses: k0kubun/action-slack@v2.0.0
- with:
- payload: |
- {
- "attachments": [{
- "text": "${{ github.workflow }} / ${{ matrix.test_task }} ${{ matrix.jit_opts }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ steps.commit_info.outputs.COMMIT_DATE }} #${{ steps.commit_info.outputs.COMMIT_NUMBER_OF_DAY }}> " +
- "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
- "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }} failed",
- "color": "danger"
- }]
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- if: failure() && github.event_name == 'push'
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml
deleted file mode 100644
index 68f28d7b40..0000000000
--- a/.github/workflows/ubuntu.yml
+++ /dev/null
@@ -1,114 +0,0 @@
-name: Ubuntu
-on:
- push:
- branches:
- - '*'
- pull_request:
- branches:
- - '*'
-jobs:
- make:
- strategy:
- matrix:
- test_task: [ "check", "test-bundler", "test-bundled-gems" ]
- os: [ubuntu-latest, ubuntu-16.04]
- exclude:
- - test_task: test-bundler
- os: ubuntu-16.04
- - test_task: test-bundled-gems
- os: ubuntu-16.04
- fail-fast: false
- runs-on: ${{ matrix.os }}
- if: "!contains(github.event.head_commit.message, '[ci skip]')"
- steps:
- - run: env | sort
- - name: Dump GitHub context
- env:
- GITHUB_CONTEXT: ${{ toJson(github) }}
- run: echo "$GITHUB_CONTEXT"
- - name: Dump job context
- env:
- JOB_CONTEXT: ${{ toJson(job) }}
- run: echo "$JOB_CONTEXT"
- - name: Dump steps context
- env:
- STEPS_CONTEXT: ${{ toJson(steps) }}
- run: echo "$STEPS_CONTEXT"
- - name: Dump runner context
- env:
- RUNNER_CONTEXT: ${{ toJson(runner) }}
- run: echo "$RUNNER_CONTEXT"
- - name: Dump strategy context
- env:
- STRATEGY_CONTEXT: ${{ toJson(strategy) }}
- run: echo "$STRATEGY_CONTEXT"
- - name: Dump matrix context
- env:
- MATRIX_CONTEXT: ${{ toJson(matrix) }}
- run: echo "$MATRIX_CONTEXT"
-
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev bison autoconf ruby
- # Not using official actions/checkout because it's unstable and sometimes doesn't work for a fork.
- - name: Checkout ruby
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${GITHUB_REF#refs/heads/} https://github.com/${{ github.repository }} src
- git -C src reset --hard "$GITHUB_SHA"
- if: github.event_name == 'push'
- - name: Checkout a pull request
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${{ github.event.pull_request.head.ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }} src
- git -C src reset --hard ${{ github.event.pull_request.head.sha }}
- if: github.event_name == 'pull_request'
- - run: ./src/tool/actions-commit-info.sh
- id: commit_info
- - name: Fixed world writable dirs
- run: |
- chmod go-w $HOME
- sudo chmod -R go-w /usr/share
- - name: Set ENV
- run: |
- echo "JOBS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - name: Autoconf
- run: cd src && exec autoconf
- - name: configure
- run: |
- mkdir build
- cd build
- ../src/configure -C --disable-install-doc
- - name: Make
- run: make -C build $JOBS
- - name: Extract gems
- run: make -C build update-gems extract-gems
- if: matrix.test_task == 'check'
- - name: Create dummy files in build dir
- run: |
- cd build
- ./miniruby -e '(("a".."z").to_a+("A".."Z").to_a+("0".."9").to_a+%w[foo bar test zzz]).each{|basename|File.write("#{basename}.rb", "raise %(do not load #{basename}.rb)")}'
- if: matrix.test_task == 'check'
- - name: Tests
- run: make -C build $JOBS -s ${{ matrix.test_task }}
- env:
- RUBY_TESTOPTS: "-q --tty=no"
- # Remove minitest from TEST_BUNDLED_GEMS_ALLOW_FAILURES if https://github.com/seattlerb/minitest/pull/798 is resolved
- # rss needs to add workaround for the non rexml environment
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: "minitest,xmlrpc,rss"
- - name: Leaked Globals
- run: make -C build -s leaked-globals
- - uses: k0kubun/action-slack@v2.0.0
- with:
- payload: |
- {
- "attachments": [{
- "text": "${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ steps.commit_info.outputs.COMMIT_DATE }} #${{ steps.commit_info.outputs.COMMIT_NUMBER_OF_DAY }}> " +
- "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
- "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }} failed",
- "color": "danger"
- }]
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- if: failure() && github.event_name == 'push'
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
deleted file mode 100644
index 82cca9353b..0000000000
--- a/.github/workflows/windows.yml
+++ /dev/null
@@ -1,91 +0,0 @@
-name: Windows
-on:
- push:
- branches:
- - '*'
- pull_request:
- branches:
- - '*'
-jobs:
- make:
- strategy:
- matrix:
- test_task: [test]
- os: [windows-2019]
- vs: [2019]
- fail-fast: false
- runs-on: ${{ matrix.os }}
- if: "!contains(github.event.head_commit.message, '[ci skip]')"
- steps:
- - uses: actions/cache@v1
- with:
- path: C:\vcpkg\downloads
- key: ${{ runner.os }}-vcpkg-download-${{ matrix.os }}-${{ github.sha }}
- restore-keys: |
- ${{ runner.os }}-vcpkg-download-${{ matrix.os }}-
- ${{ runner.os }}-vcpkg-download-
- - name: Install libraries with vcpkg
- run: |
- vcpkg --triplet x64-windows install readline zlib
- - uses: actions/cache@v1
- with:
- path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
- key: ${{ runner.os }}-chocolatey-${{ matrix.os }}-${{ github.sha }}
- restore-keys: |
- ${{ runner.os }}-chocolatey-${{ matrix.os }}-
- ${{ runner.os }}-chocolatey-
- - name: Install libraries with chocolatey
- run: |
- choco install --no-progress openssl winflexbison3
- # Not using official actions/checkout because it's unstable and sometimes doesn't work for a fork.
- - name: Checkout ruby
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${GITHUB_REF#refs/heads/} https://github.com/${{ github.repository }} src
- git -C src reset --hard ${{ github.sha }}
- if: github.event_name == 'push'
- shell: bash
- - name: Checkout a pull request
- run: |
- git clone --single-branch --shallow-since=yesterday --branch=${{ github.event.pull_request.head.ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }} src
- git -C src reset --hard ${{ github.event.pull_request.head.sha }}
- if: github.event_name == 'pull_request'
- - run: ./src/tool/actions-commit-info.sh
- shell: bash
- id: commit_info
- - name: Configure
- run: |
- md build
- cd build
- call "C:\Program Files (x86)\Microsoft Visual Studio\${{ matrix.vs }}\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
- ../src/win32/configure.bat --disable-install-doc --without-ext=+,dbm,gdbm --enable-bundled-libffi --with-opt-dir=C:/vcpkg/installed/x64-windows --with-openssl-dir="C:/Program Files/OpenSSL-Win64"
- shell: cmd
- - name: nmake
- run: |
- call "C:\Program Files (x86)\Microsoft Visual Studio\${{ matrix.vs }}\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
- set YACC=win_bison
- cd build
- echo on
- nmake up
- nmake extract-gems
- nmake
- shell: cmd
- - name: nmake test
- run: |
- call "C:\Program Files (x86)\Microsoft Visual Studio\${{ matrix.vs }}\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
- cd build
- nmake ${{ matrix.test_task }}
- shell: cmd
- - uses: k0kubun/action-slack@v2.0.0
- with:
- payload: |
- {
- "attachments": [{
- "text": "${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ steps.commit_info.outputs.COMMIT_DATE }} #${{ steps.commit_info.outputs.COMMIT_NUMBER_OF_DAY }}> " +
- "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
- "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }} failed",
- "color": "danger"
- }]
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- if: failure() && github.event_name == 'push'
diff --git a/.gitignore b/.gitignore
index 487af950f3..efc7fd5864 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,6 @@
*.a
*.bak
*.bc
-*.bundle
*.dSYM
*.dmyh
*.dylib
@@ -16,14 +15,10 @@
*.obj
*.old
*.orig
-*.pch
*.pdb
-*.rbinc
*.rej
*.s
*.sav
-*.sl
-*.so
*.swp
*.yarb
*~
@@ -37,7 +32,6 @@
.pc
.ppack
.svn
-.time
Makefile
cygruby*.def
extconf.h
@@ -46,7 +40,6 @@ y.tab.c
*.gcda
*.gcno
*.gcov
-*.vscode
lcov*.info
# /
@@ -57,9 +50,7 @@ lcov*.info
/*.pc
/*.rc
/*_prelude.c
-/build*/
/COPYING.LIB
-/ChangeLog
/Doxyfile
/GNUmakefile
/README.atheos
@@ -69,7 +60,6 @@ lcov*.info
/archive
/autom4te*.cache
/automake
-/benchmark/benchmark-driver
/beos
/bmlog-*
/breakpoints.gdb
@@ -135,11 +125,6 @@ lcov*.info
/web
/yasmdata.rb
-# /bin/
-
-/bin/*.exe
-/bin/*.dll
-
# /benchmark/
/benchmark/bm_require.data
/benchmark/bmx_*.rb
@@ -152,27 +137,22 @@ lcov*.info
/enc/jis/props.h
/enc/unicode/data
-# /coroutine/
-!/coroutine/**/*.s
-
# /enc/trans/
/enc/trans/*.c
/enc/trans/*.def
/enc/trans/*.exp
/enc/trans/*.lib
+/enc/trans/.time
# /exe/
-/exe/goruby
/exe/ruby
+/exe/.time
# /ext/
/ext/extinit.c
/ext/configure-ext.mk
/ext/*/exts.mk
-# /ext/-test-/cxxanyargs
-/ext/-test-/cxxanyargs/failure*.failed
-
# /ext/-test-/win32/dln/
/ext/-test-/win32/dln/dlntest.dll
/ext/-test-/win32/dln/dlntest.exp
@@ -205,10 +185,6 @@ lcov*.info
/gems/src
/gems/*-*
-# /lib/
-/lib/ruby/[1-9]*.*
-/lib/ruby/vendor_ruby
-
# /spec/bundler
/.rspec_status
@@ -218,8 +194,4 @@ lcov*.info
# /win32/
/win32/*.ico
-
-# MJIT
-/rb_mjit_header.h
-/mjit_config.h
-/include/ruby-*/*/rb_mjit_min_header-*.h
+/win32/.time
diff --git a/.indent.pro b/.indent.pro
new file mode 100644
index 0000000000..6a207a0554
--- /dev/null
+++ b/.indent.pro
@@ -0,0 +1,21 @@
+-bap
+-nbbb
+-nbc
+-br
+-nbs
+-ncdb
+-ce
+-cli0.5
+-ndj
+-ei
+-nfc1
+-i4
+-l120
+-lp
+-npcs
+-psl
+-sc
+-sob
+
+-TID
+-TVALUE
diff --git a/.rspec_parallel b/.rspec_parallel
deleted file mode 100644
index aaff198a32..0000000000
--- a/.rspec_parallel
+++ /dev/null
@@ -1,2 +0,0 @@
---format progress
---format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
diff --git a/.travis.yml b/.travis.yml
index 71945e349e..a9117d190f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,3 @@
-# -*- YAML -*-
# Copyright (C) 2011 Urabe, Shyouhei. All rights reserved.
#
# This file is a part of the programming language Ruby. Permission is hereby
@@ -18,522 +17,72 @@
# is also a good place to look at.
language: c
+dist: trusty
-os: linux
+# temporary workaround for https://github.com/travis-ci/travis-ci/issues/8892
+sudo: required
+group: deprecated-2017Q4
-dist: xenial
+compiler:
+ - gcc
-git:
- quiet: true
+os:
+ - linux
-cache:
- ccache: true
- directories:
- - $HOME/config_2nd
- - $HOME/.downloaded-cache
-
-env:
- global:
- # Reset timestamps early
- - _=$(touch NEWS && find . -type f -exec touch -r NEWS {} +)
- - CONFIGURE_TTY=no
- - CCACHE_COMPILERCHECK=none
- - CCACHE_NOCOMPRESS=1
- - CCACHE_MAXSIZE=512Mi
- - NPROC="`nproc`"
- # JOBS and SETARCH are overridden when necessary; see below.
- - JOBS=-j$((1+${NPROC}))
- - SETARCH=
- - RUBY_PREFIX=/tmp/ruby-prefix
- - GEMS_FOR_TEST='timezone tzinfo'
- - UPDATE_UNICODE="UNICODE_FILES=. UNICODE_PROPERTY_FILES=. UNICODE_AUXILIARY_FILES=. UNICODE_EMOJI_FILES=."
- # https://github.com/travis-ci/travis-build/blob/e411371dda21430a60f61b8f3f57943d2fe4d344/lib/travis/build/bash/travis_apt_get_options.bash#L7
- - travis_apt_get_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages'
- - travis_apt_get_options="-yq --no-install-suggests --no-install-recommends $travis_apt_get_options"
-
-.org.ruby-lang.ci.matrix-definitions:
-
- - &cron-only
- if: (type = cron) AND (branch = master) AND (fork = false)
-
- - &make-test-only
- script:
- - $SETARCH make -s test TESTOPTS="${TESTOPTS=$JOBS -q --tty=no}"
-
- - &gcc-8
- compiler: gcc-8
- # # Not using addon to control retries
- # addons:
- # apt:
- # sources:
- # - ubuntu-toolchain-r-test
- before_install:
- - tool/travis_retry.sh sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- - tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- - |-
- ${BEFORE_INSTALL}
- tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install \
- ccache \
- gcc-8 \
- g++-8 \
- libffi-dev \
- libgdbm-dev \
- libgmp-dev \
- libjemalloc-dev \
- libncurses5-dev \
- libncursesw5-dev \
- libreadline6-dev \
- libssl-dev \
- libyaml-dev \
- openssl \
- valgrind \
- zlib1g-dev
-
- - &clang-8
- compiler: clang-8
- addons:
- apt:
- # Not doing this manually unlike other sources, because it has been stable.
- sources:
- - llvm-toolchain-xenial-8
- config:
- retries: true
- before_install:
- - tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- - |-
- tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install \
- clang-8 \
- llvm-8-tools \
- libffi-dev \
- libgdbm-dev \
- libgmp-dev \
- libjemalloc-dev \
- libncurses5-dev \
- libncursesw5-dev \
- libreadline6-dev \
- libssl-dev \
- libyaml-dev \
- openssl \
- valgrind \
- zlib1g-dev
-
- # --------
-
- - &x86_64-linux
- name: x86_64-linux
- <<: *gcc-8
-
- - &arm64-linux
- name: arm64-linux
- arch: arm64
- <<: *gcc-8
-
- - &s390x-linux
- name: s390x-linux
- arch: s390x
- <<: *gcc-8
-
- - &jemalloc
- name: --with-jemalloc
- <<: *gcc-8
- <<: *cron-only
- env:
- - CONFIG_FLAG='--with-gmp --with-jemalloc --with-valgrind'
-
- - &assertions
- name: RUBY_DEBUG=1
- <<: *gcc-8
- #<<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - cppflags='-DRUBY_DEBUG -DVM_CHECK_MODE=1 -DTRANSIENT_HEAP_CHECK_MODE -DRGENGC_CHECK_MODE -DENC_DEBUG'
-
- - &VM_CHECK_MODE
- name: VM_CHECK_MODE=3
- <<: *gcc-8
- <<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - cppflags=-DVM_CHECK_MODE=0x0003
-
- - &SUPPORT_JOKE
- name: SUPPORT_JOKE
- <<: *gcc-8
- <<: *cron-only
- <<: *make-test-only
- env:
- - BEFORE_INSTALL="sed vm_opts.h -e 's/OPT_SUPPORT_JOKE *0/OPT_SUPPORT_JOKE 1/' -i"
-
- - &CPDEBUG
- name: CPDEBUG
- <<: *gcc-8
- <<: *cron-only
- <<: *make-test-only
- env:
- - cppflags=-DCPDEBUG
-
- - &WITH_COROUTINE_UCONTEXT
- name: COROUTINE=ucontext
- <<: *gcc-8
- <<: *cron-only
- env:
- - CONFIG_FLAG='--with-coroutine=ucontext'
-
- - &WITH_COROUTINE_COPY
- name: COROUTINE=copy
- <<: *gcc-8
- <<: *cron-only
- env:
- - CONFIG_FLAG='--with-coroutine=copy'
-
- - &TOKEN_THREADED_CODE
- name: TOKEN_THREADED_CODE
- <<: *gcc-8
- <<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - cppflags=-DOPT_THREADED_CODE=1
-
- - &CALL_THREADED_CODE
- name: CALL_THREADED_CODE
- <<: *gcc-8
- <<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - cppflags=-DOPT_THREADED_CODE=2
-
- - &NO_THREADED_CODE
- name: NO_THREADED_CODE
- <<: *gcc-8
- <<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - cppflags=-DOPT_THREADED_CODE=3
-
- - &ASAN
- name: -fsanitize=address
- <<: *clang-8
- #<<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - ASAN_OPTIONS=detect_leaks=0
- - cflags='-U_FORTIFY_SOURCE -march=native -fsanitize=address -fno-omit-frame-pointer -fPIC'
- - debugflags=-ggdb3
- - optflags=-O1
- - LD=clang-8
- - LDFLAGS='-fsanitize=address -fPIC'
- - CONFIG_FLAG='--with-out-ext=openssl --without-gmp --without-jemalloc --without-valgrind'
-
- - &MSAN
- name: -fsanitize=memory
- <<: *clang-8
- #<<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - cflags='-U_FORTIFY_SOURCE -fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -fPIC'
- - optflags=-O1
- - LD=clang-8
- - LDFLAGS='-fsanitize=memory -fPIC'
- - CONFIG_FLAG='--with-out-ext=openssl --without-gmp --without-jemalloc --without-valgrind'
-
- - &UBSAN
- name: -fsanitize=undefined
- <<: *clang-8
- #<<: *cron-only
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - cflags='-U_FORTIFY_SOURCE -fsanitize=undefined,integer,nullability -fno-sanitize=implicit-integer-sign-change,unsigned-integer-overflow'
- - cppflags=-DUNALIGNED_WORD_ACCESS=0
- - debugflags=-ggdb3
- - optflags='-O1 -march=native'
- - LD=clang-8
- - LDFLAGS='-fsanitize=undefined,integer,nullability -fno-sanitize=implicit-integer-sign-change,unsigned-integer-overflow'
-
- - &i686-linux
- name: i686-linux
- compiler: gcc-8
- env:
- - GCC_FLAGS=-m32
- - CXX='g++-8 -m32'
- - debugflags=-g0
- - SETARCH='setarch i686 --verbose --3gb'
- # # Not using addon to control retries
- # addons:
- # apt:
- # sources:
- # - ubuntu-toolchain-r-test
- before_install:
- - tool/travis_retry.sh sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- - tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- - |-
- tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install \
- gcc-8-multilib \
- g++-8 \
- g++-8-multilib \
- libstdc++-8-dev:i386 \
- libffi-dev:i386 \
- libffi6:i386 \
- libgdbm-dev:i386 \
- libgdbm3:i386 \
- libncurses5-dev:i386 \
- libncurses5:i386 \
- libncursesw5-dev:i386 \
- libreadline6-dev:i386 \
- libreadline6:i386 \
- libssl-dev:i386 \
- libssl1.0.0:i386 \
- linux-libc-dev:i386 \
- zlib1g-dev:i386 \
- zlib1g:i386
-
- - &arm32-linux
- name: arm32-linux
- arch: arm64
- # https://packages.ubuntu.com/xenial/crossbuild-essential-armhf
- compiler: arm-linux-gnueabihf-gcc
- env:
- - debugflags=-g0
- - SETARCH='setarch linux32 --verbose --32bit'
- before_install:
- - sudo dpkg --add-architecture armhf
- - tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- - |-
- tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install \
- ccache \
- crossbuild-essential-armhf \
- libc6:armhf \
- libstdc++-5-dev:armhf \
- libffi-dev:armhf \
- libffi6:armhf \
- libgdbm-dev:armhf \
- libgdbm3:armhf \
- libncurses5-dev:armhf \
- libncurses5:armhf \
- libncursesw5-dev:armhf \
- libreadline6-dev:armhf \
- libreadline6:armhf \
- libssl-dev:armhf \
- libssl1.0.0:armhf \
- linux-libc-dev:armhf \
- zlib1g-dev:armhf \
- zlib1g:armhf
-
- - &pedanticism
- name: -std=c99 -pedantic
- compiler: clang
- <<: *make-test-only
- env:
- - GEMS_FOR_TEST=
- - GCC_FLAGS='-std=c99 -Werror=pedantic -pedantic-errors'
- - CONFIG_FLAG=
- - JOBS=
- - >-
- warnflags='
- -Wall
- -Wextra
- -Werror=deprecated-declarations
- -Werror=division-by-zero
- -Werror=extra-tokens
- -Werror=implicit-function-declaration
- -Werror=implicit-int
- -Werror=pointer-arith
- -Werror=shorten-64-to-32
- -Werror=write-strings
- -Wmissing-noreturn
- -Wno-constant-logical-operand
- -Wno-missing-field-initializers
- -Wno-overlength-strings
- -Wno-parentheses-equality
- -Wno-self-assign
- -Wno-tautological-compare
- -Wno-unused-local-typedef
- -Wno-unused-parameter
- -Wunused-variable'
- - LDFLAGS=-Wno-unused-command-line-argument
-
- - &rubyspec
- name: Check ruby/spec version guards on Ruby 2.4
- language: ruby
- rvm: 2.4.6
- before_install:
- install:
- before_script: chmod -R u+w spec/ruby
- # -j randomly hangs.
- script: ruby -C spec/ruby ../mspec/bin/mspec .
- after_failure:
- - echo "ruby/spec failed on Ruby 2.4. This is likely because of a missing ruby_version_is guard, please add it. See spec/README.md."
-
- - &baseruby
- name: "BASERUBY: Ruby 2.2"
- <<: *gcc-8
- <<: *make-test-only
- language: ruby
- rvm: 2.2
-
- - &dependency
- name: Check dependencies in makefiles
- language: ruby
- before_install:
- install:
- before_script:
- - |-
- ruby -e 'new = []
- Dir.glob("ext/**/extconf.rb") {|ex|
- unless File.exist?(dep = File.dirname(ex)+"/depend")
- puts "Adding "+dep
- File.copy_stream("template/depend.tmpl", dep)
- new << dep
- end
- }
- exec("git", "add", *new) unless new.empty?'
- - git diff --cached
- - "> config.status"
- - "> .rbconfig.time"
- - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile
- - make touch-unicode-files
- - make -s $JOBS $UPDATE_UNICODE up
- - make -s $JOBS srcs
- - rm -f config.status Makefile rbconfig.rb .rbconfig.time
- - $SETARCH ./configure -C --disable-install-doc --prefix=$RUBY_PREFIX --disable-rubygems 'optflags=-O0' 'debugflags=-save-temps=obj -g'
- - ruby tool/update-deps --fix
- script:
- - git diff --no-ext-diff --ignore-submodules --exit-code
- after_failure:
- - echo "Dependencies need to update"
- env:
- - CONFIG_FLAG=
-
-matrix:
- include:
- # Build every commit:
- - <<: *x86_64-linux
- - <<: *arm64-linux
- - <<: *i686-linux
- - <<: *arm32-linux
- - <<: *s390x-linux
- - <<: *pedanticism
- - <<: *assertions
- - <<: *baseruby
- - <<: *rubyspec
- - <<: *dependency
- # Build every commit (Allowed Failures):
- - <<: *ASAN
- - <<: *MSAN
- - <<: *UBSAN
- # Cron only:
- - <<: *jemalloc
- - <<: *VM_CHECK_MODE
- - <<: *SUPPORT_JOKE
- - <<: *CPDEBUG
- - <<: *WITH_COROUTINE_UCONTEXT
- - <<: *WITH_COROUTINE_COPY
- - <<: *TOKEN_THREADED_CODE
- - <<: *CALL_THREADED_CODE
- - <<: *NO_THREADED_CODE
- allow_failures:
- - name: s390x-linux
- - name: -fsanitize=address
- - name: -fsanitize=memory
- - name: -fsanitize=undefined
- fast_finish: true
+before_install:
+ - "CONFIG_FLAG="
+ - "JOBS=-j`nproc`"
before_script:
- - date # Debugging "Permission defined" failure on darwin like https://travis-ci.org/ruby/ruby/jobs/508683759
- - dpkg --print-architecture
- - dpkg --print-foreign-architectures
- - setarch --list
- - echo JOBS=${JOBS} SETARCH=${SETARCH}
- - $SETARCH uname -a
- - $SETARCH uname -r
- - rm -fr .ext autom4te.cache
- - echo $TERM
- - |-
- [ -d ~/.downloaded-cache ] ||
- mkdir ~/.downloaded-cache
- - ln -s ~/.downloaded-cache
+ - "echo JOBS=$JOBS"
+ - "uname -a"
+ - "uname -r"
+ - "rm -fr .ext autom4te.cache"
+ - "echo $TERM"
- "> config.status"
- - "> .rbconfig.time"
- - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile
- - date; make touch-unicode-files
- - date; make -s $JOBS $UPDATE_UNICODE up
- - date; make -s $JOBS srcs
- - rm -f config.status Makefile rbconfig.rb .rbconfig.time
- - |-
- if [ -d ~/config_2nd ]; then
- cp -pr ~/config_2nd build
- else
- mkdir build
- fi
- - mkdir config_1st config_2nd
- - chmod -R a-w .
- - chmod -R u+w build config_1st config_2nd
- - cd build
- - ccache --show-stats
- - |-
- case "$CC" in
- gcc*) CC="ccache $CC${GCC_FLAGS:+ }$GCC_FLAGS -fno-diagnostics-color";;
- clang*) CC="ccache $CC${GCC_FLAGS:+ }$GCC_FLAGS -fno-color-diagnostics";;
- esac
- - |-
- [ ! -f config.cache ] ||
- [ "$CC" = "`sed -n s/^ac_cv_prog_CC=//p config.cache`" ] ||
- (set -x; exec rm config.cache)
- - $SETARCH ../configure -C --disable-install-doc --prefix=$RUBY_PREFIX $CONFIG_FLAG
- - cp -pr config.cache config.status .ext/include ../config_1st
- - $SETARCH make reconfig
- - cp -pr config.cache config.status .ext/include ../config_2nd
- - (cd .. && exec diff -ru config_1st config_2nd)
- - chmod u+w ..
- - rm -rf ~/config_2nd
- - mv ../config_2nd ~
- - chmod u-w ..
- - $SETARCH make -s $JOBS
- - |-
- date; : # Debugging "Permission defined" failure on darwin like https://travis-ci.org/ruby/ruby/jobs/508683759
- if ! make install; then
- if [ "$(uname)" = Darwin ]; then
- # Debugging "Permission defined" failure on darwin like https://travis-ci.org/ruby/ruby/jobs/508683759
- set -x
- date
- ./miniruby -e 'ARGV.map{|path|[path,File.stat(path)]}.sort_by{|path,st|st.mtime}.each{|path,st|p mtime:st.mtime.to_f, ctime:st.ctime.to_f, path:path}' .ext/.timestamp/.RUBYCOMMONDIR*time .ext/common/bigdecimal/*.rb ../ext/bigdecimal/lib/bigdecimal/*.rb . .. .ext .ext/common .ext/common/bigdecimal ext/bigdecimal ../ext ../ext/bigdecimal ../ext/bigdecimal/lib ../ext/bigdecimal/lib/bigdecimal
- make COPY='cp -f' install
- else
- exit 1
- fi
- fi
- - ccache --show-stats
- - |-
- [ -z "${GEMS_FOR_TEST}" ] ||
- $RUBY_PREFIX/bin/gem install --no-document $GEMS_FOR_TEST
- - echo "raise 'do not load ~/.irbrc in test'" > ~/.irbrc
+ - "sed -f tool/prereq.status Makefile.in common.mk > Makefile"
+ - "make update-config_files"
+ - "make touch-unicode-files"
+ - "make -s $JOBS srcs UNICODE_FILES=."
+ - "requests=; for req in ${RUBYSPEC_PULL_REQUEST//,/ }; do
+ requests=\"$requests +refs/pull/$req/merge:\";
+ done"
+ - "${requests:+git -C spec/ruby -c user.email=none -c user.name=none pull --no-edit origin $requests}"
+ - "${requests:+git -C spec/ruby log --oneline origin/master..@}"
+ - "rm config.status Makefile rbconfig.rb .rbconfig.time"
+ - "mkdir build config_1st config_2nd"
+ - "chmod -R a-w ."
+ - "chmod u+w build config_1st config_2nd"
+ - "cd build"
+ - "../configure -C --disable-install-doc --with-gcc=$CC $CONFIG_FLAG"
+ - "cp -pr config.cache config.status .ext/include ../config_1st"
+ - "make reconfig"
+ - "cp -pr config.cache config.status .ext/include ../config_2nd"
+ - "(cd .. && exec diff -ru config_1st config_2nd)"
+ - "make -s $JOBS"
script:
- - $SETARCH make -s test -o showflags TESTOPTS="${TESTOPTS=$JOBS -q --tty=no}"
- - travis_wait 50 $SETARCH make -s test-all -o exts TESTOPTS="${TESTOPTS} ${TEST_ALL_OPTS}" RUBYOPT="-w"
- - $SETARCH make -s test-spec MSPECOPT=-ff # not using `-j` because sometimes `mspec -j` silently dies
- - $SETARCH make -s -o showflags leaked-globals
+ - "make -s test TESTOPTS=--color=never"
+ - "make -s $JOBS test-all -o exts TESTOPTS='-q --color=never --job-status=normal'"
+ - "make -s $JOBS test-spec MSPECOPT=-j"
# Branch matrix. Not all branches are Travis-ready so we limit branches here.
branches:
only:
- - master
+ - trunk
+ - ruby_2_2
+ - ruby_2_3
- ruby_2_4
- ruby_2_5
- - ruby_2_6
+ - /^feature\//
+ - /^bug\//
# We want to be notified when something happens.
notifications:
irc:
channels:
- "chat.freenode.net#ruby-core"
+ - "chat.freenode.net#ruby-ja"
on_success: change # [always|never|change] # default: always
on_failure: always # [always|never|change] # default: always
template:
@@ -541,6 +90,7 @@ notifications:
slack:
rooms:
+ - secure: i1GLETSKye85ea6dGNA3MxI/5myChmMFiZtBd5C69xK+s1sBFqEgOSbaSf9KHc0CYrHVyNhQMaZRruieV7xS+6Pfs0Zvxf1DO6QQTWC2KhkqwFDLvZncAzjoyASdR90hbr+iRPOngQ+HJuE94zemALAwEqNAinzA74PMiJXktqY= # ruby:<token>#commits
- secure: ah7UEHBvncXT7bM5mvYIQAO+tIyV/wl7nXLb7wQD16dO2v8Gragy0mWjB79Q09hrrMGmp6H9bCDpdGS80boIA5EHaHoG4QaP0i9bsSt8U2AMWgZtfyIgQKJ4H2kXkGlrjO+AXTgnIkP7LNjdgAVUUTGQPb26T3QmoN2Splt+fIQ= # ruby:<token>#alerts
on_pull_requests: false
on_success: change
@@ -548,3 +98,12 @@ notifications:
email:
- ko1c-failure@atdot.net
+
+# Local Variables:
+# mode: YAML
+# coding: utf-8-unix
+# indent-tabs-mode: nil
+# tab-width: 4
+# fill-column: 79
+# default-justification: full
+# End:
diff --git a/COPYING b/COPYING
index 48e5a96de7..f06056fb45 100644
--- a/COPYING
+++ b/COPYING
@@ -2,55 +2,55 @@ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
You can redistribute it and/or modify it under either the terms of the
2-clause BSDL (see the file BSDL), or the conditions below:
-1. You may make and give away verbatim copies of the source form of the
- software without restriction, provided that you duplicate all of the
- original copyright notices and associated disclaimers.
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
-2. You may modify your copy of the software in any way, provided that
- you do at least ONE of the following:
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
- a. place your modifications in the Public Domain or otherwise
- make them Freely Available, such as by posting said
- modifications to Usenet or an equivalent medium, or by allowing
- the author to include your modifications in the software.
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
- b. use the modified software only within your corporation or
- organization.
+ b) use the modified software only within your corporation or
+ organization.
- c. give non-standard binaries non-standard names, with
- instructions on where to get the original software distribution.
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
- d. make other distribution arrangements with the author.
+ d) make other distribution arrangements with the author.
-3. You may distribute the software in object code or binary form,
- provided that you do at least ONE of the following:
+ 3. You may distribute the software in object code or binary form,
+ provided that you do at least ONE of the following:
- a. distribute the binaries and library files of the software,
- together with instructions (in the manual page or equivalent)
- on where to get the original distribution.
+ a) distribute the binaries and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
- b. accompany the distribution with the machine-readable source of
- the software.
+ b) accompany the distribution with the machine-readable source of
+ the software.
- c. give non-standard binaries non-standard names, with
- instructions on where to get the original software distribution.
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
- d. make other distribution arrangements with the author.
+ d) make other distribution arrangements with the author.
-4. You may modify and include the part of the software into any other
- software (possibly commercial). But some files in the distribution
- are not written by the author, so that they are not under these terms.
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial). But some files in the distribution
+ are not written by the author, so that they are not under these terms.
- For the list of those files and their copying conditions, see the
- file LEGAL.
+ For the list of those files and their copying conditions, see the
+ file LEGAL.
-5. The scripts and library files supplied as input to or produced as
- output from the software do not automatically fall under the
- copyright of the software, but belong to whomever generated them,
- and may be sold commercially, and may be aggregated with this
- software.
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
-6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE.
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
diff --git a/COPYING.ja b/COPYING.ja
index 230376bc60..e50d01c8d1 100644
--- a/COPYING.ja
+++ b/COPYING.ja
@@ -2,50 +2,50 @@
ã¾ãŸã¯ä»¥ä¸‹ã«ç¤ºã™æ¡ä»¶ã§æœ¬ãƒ—ログラムをå†é…布ã§ãã¾ã™
2-clause BSDLã«ã¤ã„ã¦ã¯BSDLファイルをå‚ç…§ã—ã¦ä¸‹ã•ã„.
-1. 複製ã¯åˆ¶é™ãªã自由ã§ã™ï¼Ž
+ 1. 複製ã¯åˆ¶é™ãªã自由ã§ã™ï¼Ž
-2. ä»¥ä¸‹ã®æ¡ä»¶ã®ã„ãšã‚Œã‹ã‚’満ãŸã™æ™‚ã«æœ¬ãƒ—ログラムã®ã‚½ãƒ¼ã‚¹ã‚’
- 自由ã«å¤‰æ›´ã§ãã¾ã™ï¼Ž
+ 2. ä»¥ä¸‹ã®æ¡ä»¶ã®ã„ãšã‚Œã‹ã‚’満ãŸã™æ™‚ã«æœ¬ãƒ—ログラムã®ã‚½ãƒ¼ã‚¹ã‚’
+ 自由ã«å¤‰æ›´ã§ãã¾ã™ï¼Ž
- a. ãƒãƒƒãƒˆãƒ‹ãƒ¥ãƒ¼ã‚ºã«ãƒã‚¹ãƒˆã—ãŸã‚Šï¼Œä½œè€…ã«å¤‰æ›´ã‚’é€ä»˜ã™ã‚‹
- ãªã©ã®æ–¹æ³•ã§ï¼Œå¤‰æ›´ã‚’公開ã™ã‚‹ï¼Ž
+ (a) ãƒãƒƒãƒˆãƒ‹ãƒ¥ãƒ¼ã‚ºã«ãƒã‚¹ãƒˆã—ãŸã‚Šï¼Œä½œè€…ã«å¤‰æ›´ã‚’é€ä»˜ã™ã‚‹
+ ãªã©ã®æ–¹æ³•ã§ï¼Œå¤‰æ›´ã‚’公開ã™ã‚‹ï¼Ž
- b. 変更ã—ãŸæœ¬ãƒ—ãƒ­ã‚°ãƒ©ãƒ ã‚’è‡ªåˆ†ã®æ‰€å±žã™ã‚‹çµ„織内部ã ã‘ã§
- 使ã†ï¼Ž
+ (b) 変更ã—ãŸæœ¬ãƒ—ãƒ­ã‚°ãƒ©ãƒ ã‚’è‡ªåˆ†ã®æ‰€å±žã™ã‚‹çµ„織内部ã ã‘ã§
+ 使ã†ï¼Ž
- c. 変更点を明示ã—ãŸã†ãˆï¼Œã‚½ãƒ•トウェアã®åå‰ã‚’変更ã™ã‚‹ï¼Ž
- ãã®ã‚½ãƒ•トウェアをé…布ã™ã‚‹æ™‚ã«ã¯å¤‰æ›´å‰ã®æœ¬ãƒ—ログラ
- ãƒ ã‚‚åŒæ™‚ã«é…布ã™ã‚‹ï¼Žã¾ãŸã¯å¤‰æ›´å‰ã®æœ¬ãƒ—ログラムã®ã‚½ãƒ¼
- スã®å…¥æ‰‹æ³•を明示ã™ã‚‹ï¼Ž
+ (c) 変更点を明示ã—ãŸã†ãˆï¼Œã‚½ãƒ•トウェアã®åå‰ã‚’変更ã™ã‚‹ï¼Ž
+ ãã®ã‚½ãƒ•トウェアをé…布ã™ã‚‹æ™‚ã«ã¯å¤‰æ›´å‰ã®æœ¬ãƒ—ログラ
+ ãƒ ã‚‚åŒæ™‚ã«é…布ã™ã‚‹ï¼Žã¾ãŸã¯å¤‰æ›´å‰ã®æœ¬ãƒ—ログラムã®ã‚½ãƒ¼
+ スã®å…¥æ‰‹æ³•を明示ã™ã‚‹ï¼Ž
- d. ãã®ä»–ã®å¤‰æ›´æ¡ä»¶ã‚’作者ã¨åˆæ„ã™ã‚‹ï¼Ž
+ (d) ãã®ä»–ã®å¤‰æ›´æ¡ä»¶ã‚’作者ã¨åˆæ„ã™ã‚‹ï¼Ž
-3. ä»¥ä¸‹ã®æ¡ä»¶ã®ã„ãšã‚Œã‹ã‚’満ãŸã™æ™‚ã«æœ¬ãƒ—ログラムをコンパイ
- ルã—ãŸã‚ªãƒ–ジェクトコードや実行形å¼ã§ã‚‚é…布ã§ãã¾ã™ï¼Ž
+ 3. ä»¥ä¸‹ã®æ¡ä»¶ã®ã„ãšã‚Œã‹ã‚’満ãŸã™æ™‚ã«æœ¬ãƒ—ログラムをコンパイ
+ ルã—ãŸã‚ªãƒ–ジェクトコードや実行形å¼ã§ã‚‚é…布ã§ãã¾ã™ï¼Ž
- a. ãƒã‚¤ãƒŠãƒªã‚’å—ã‘å–ã£ãŸäººãŒã‚½ãƒ¼ã‚¹ã‚’入手ã§ãるよã†ã«ï¼Œ
- ソースã®å…¥æ‰‹æ³•を明示ã™ã‚‹ï¼Ž
+ (a) ãƒã‚¤ãƒŠãƒªã‚’å—ã‘å–ã£ãŸäººãŒã‚½ãƒ¼ã‚¹ã‚’入手ã§ãるよã†ã«ï¼Œ
+ ソースã®å…¥æ‰‹æ³•を明示ã™ã‚‹ï¼Ž
- b. 機械å¯èª­ãªã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã‚’添付ã™ã‚‹ï¼Ž
+ (b) 機械å¯èª­ãªã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã‚’添付ã™ã‚‹ï¼Ž
- c. 変更を行ã£ãŸãƒã‚¤ãƒŠãƒªã¯åå‰ã‚’変更ã—ãŸã†ãˆï¼Œã‚ªãƒªã‚¸ãƒŠ
- ルã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã®å…¥æ‰‹æ³•を明示ã™ã‚‹ï¼Ž
+ (c) 変更を行ã£ãŸãƒã‚¤ãƒŠãƒªã¯åå‰ã‚’変更ã—ãŸã†ãˆï¼Œã‚ªãƒªã‚¸ãƒŠ
+ ルã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã®å…¥æ‰‹æ³•を明示ã™ã‚‹ï¼Ž
- d. ãã®ä»–ã®é…布æ¡ä»¶ã‚’作者ã¨åˆæ„ã™ã‚‹ï¼Ž
+ (d) ãã®ä»–ã®é…布æ¡ä»¶ã‚’作者ã¨åˆæ„ã™ã‚‹ï¼Ž
-4. ä»–ã®ãƒ—ログラムã¸ã®å¼•用ã¯ã„ã‹ãªã‚‹ç›®çš„ã§ã‚れ自由ã§ã™ï¼ŽãŸ
- ã ã—,本プログラムã«å«ã¾ã‚Œã‚‹ä»–ã®ä½œè€…ã«ã‚ˆã‚‹ã‚³ãƒ¼ãƒ‰ã¯ï¼Œã
- れãžã‚Œã®ä½œè€…ã®æ„å‘ã«ã‚ˆã‚‹åˆ¶é™ãŒåŠ ãˆã‚‰ã‚Œã‚‹å ´åˆãŒã‚りã¾ã™ï¼Ž
+ 4. ä»–ã®ãƒ—ログラムã¸ã®å¼•用ã¯ã„ã‹ãªã‚‹ç›®çš„ã§ã‚れ自由ã§ã™ï¼ŽãŸ
+ ã ã—,本プログラムã«å«ã¾ã‚Œã‚‹ä»–ã®ä½œè€…ã«ã‚ˆã‚‹ã‚³ãƒ¼ãƒ‰ã¯ï¼Œã
+ れãžã‚Œã®ä½œè€…ã®æ„å‘ã«ã‚ˆã‚‹åˆ¶é™ãŒåŠ ãˆã‚‰ã‚Œã‚‹å ´åˆãŒã‚りã¾ã™ï¼Ž
- ãれらファイルã®ä¸€è¦§ã¨ãれãžã‚Œã®é…布æ¡ä»¶ãªã©ã«ä»˜ã„ã¦ã¯
- LEGALファイルをå‚ç…§ã—ã¦ãã ã•ã„.
+ ãれらファイルã®ä¸€è¦§ã¨ãれãžã‚Œã®é…布æ¡ä»¶ãªã©ã«ä»˜ã„ã¦ã¯
+ LEGALファイルをå‚ç…§ã—ã¦ãã ã•ã„.
-5. 本プログラムã¸ã®å…¥åŠ›ã¨ãªã‚‹ã‚¹ã‚¯ãƒªãƒ—トãŠã‚ˆã³ï¼Œæœ¬ãƒ—ログラ
- ムã‹ã‚‰ã®å‡ºåŠ›ã®æ¨©åˆ©ã¯æœ¬ãƒ—ログラムã®ä½œè€…ã§ã¯ãªã,ãれãž
- れã®å…¥å‡ºåŠ›ã‚’ç”Ÿæˆã—ãŸäººã«å±žã—ã¾ã™ï¼Žã¾ãŸï¼Œæœ¬ãƒ—ログラムã«
- 組ã¿è¾¼ã¾ã‚Œã‚‹ãŸã‚ã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリã«ã¤ã„ã¦ã‚‚åŒæ§˜ã§ã™ï¼Ž
+ 5. 本プログラムã¸ã®å…¥åŠ›ã¨ãªã‚‹ã‚¹ã‚¯ãƒªãƒ—トãŠã‚ˆã³ï¼Œæœ¬ãƒ—ログラ
+ ムã‹ã‚‰ã®å‡ºåŠ›ã®æ¨©åˆ©ã¯æœ¬ãƒ—ログラムã®ä½œè€…ã§ã¯ãªã,ãれãž
+ れã®å…¥å‡ºåŠ›ã‚’ç”Ÿæˆã—ãŸäººã«å±žã—ã¾ã™ï¼Žã¾ãŸï¼Œæœ¬ãƒ—ログラムã«
+ 組ã¿è¾¼ã¾ã‚Œã‚‹ãŸã‚ã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリã«ã¤ã„ã¦ã‚‚åŒæ§˜ã§ã™ï¼Ž
-6. 本プログラムã¯ç„¡ä¿è¨¼ã§ã™ï¼Žä½œè€…ã¯æœ¬ãƒ—ログラムをサãƒãƒ¼ãƒˆ
- ã™ã‚‹æ„å¿—ã¯ã‚りã¾ã™ãŒï¼Œãƒ—ログラム自身ã®ãƒã‚°ã‚ã‚‹ã„ã¯æœ¬ãƒ—
- ログラムã®å®Ÿè¡Œãªã©ã‹ã‚‰ç™ºç”Ÿã™ã‚‹ã„ã‹ãªã‚‹æå®³ã«å¯¾ã—ã¦ã‚‚責
- 任をæŒã¡ã¾ã›ã‚“.
+ 6. 本プログラムã¯ç„¡ä¿è¨¼ã§ã™ï¼Žä½œè€…ã¯æœ¬ãƒ—ログラムをサãƒãƒ¼ãƒˆ
+ ã™ã‚‹æ„å¿—ã¯ã‚りã¾ã™ãŒï¼Œãƒ—ログラム自身ã®ãƒã‚°ã‚ã‚‹ã„ã¯æœ¬ãƒ—
+ ログラムã®å®Ÿè¡Œãªã©ã‹ã‚‰ç™ºç”Ÿã™ã‚‹ã„ã‹ãªã‚‹æå®³ã«å¯¾ã—ã¦ã‚‚責
+ 任をæŒã¡ã¾ã›ã‚“.
diff --git a/LEGAL b/LEGAL
index 565c4c9cde..0479751691 100644
--- a/LEGAL
+++ b/LEGAL
@@ -1,27 +1,23 @@
-# -*- rdoc -*-
-
-= LEGAL NOTICE INFORMATION
---------------------------
+LEGAL NOTICE INFORMATION
+------------------------
All the files in this distribution are covered under either the Ruby's
license (see the file COPYING) or public-domain except some files
mentioned below.
-ccan/build_assert/build_assert.h::
-ccan/check_type/check_type.h::
-ccan/container_of/container_of.h::
-ccan/str/str.h::
+ccan/build_assert/build_assert.h
+ccan/check_type/check_type.h
+ccan/container_of/container_of.h
+ccan/str/str.h
These files are licensed under the CC0.
- >>>
https://creativecommons.org/choose/zero/
-ccan/list/list.h::
+ccan/list/list.h
This file is licensed under the MIT License.
- >>>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@@ -40,124 +36,124 @@ ccan/list/list.h::
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-include/ruby/onigmo.h::
-include/ruby/oniguruma.h::
-regcomp.c::
-regenc.c::
-regenc.h::
-regerror.c::
-regexec.c::
-regint.h::
-regparse.c::
-regparse.h::
-enc/ascii.c::
-enc/big5.c::
-enc/cp949.c::
-enc/emacs_mule.c::
-enc/encdb.c::
-enc/euc_jp.c::
-enc/euc_kr.c::
-enc/euc_tw.c::
-enc/gb18030.c::
-enc/gb2312.c::
-enc/gbk.c::
-enc/iso_8859_1.c::
-enc/iso_8859_10.c::
-enc/iso_8859_11.c::
-enc/iso_8859_13.c::
-enc/iso_8859_14.c::
-enc/iso_8859_15.c::
-enc/iso_8859_16.c::
-enc/iso_8859_2.c::
-enc/iso_8859_3.c::
-enc/iso_8859_4.c::
-enc/iso_8859_5.c::
-enc/iso_8859_6.c::
-enc/iso_8859_7.c::
-enc/iso_8859_8.c::
-enc/iso_8859_9.c::
-enc/koi8_r.c::
-enc/koi8_u.c::
-enc/shift_jis.c::
-enc/unicode.c::
-enc/us_ascii.c::
-enc/utf_16be.c::
-enc/utf_16le.c::
-enc/utf_32be.c::
-enc/utf_32le.c::
-enc/utf_8.c::
-enc/windows_1251.c::
-
- Onigmo (Oniguruma-mod) LICENSE
-
- >>>
- Copyright (c) 2002-2009 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- Copyright (c) 2011-2014 K.Takata <kentkt AT csc DOT jp>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- Oniguruma LICENSE
-
- >>>
- Copyright (c) 2002-2009 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- * https://github.com/k-takata/Onigmo/
- * https://github.com/kkos/oniguruma
- * https://svnweb.freebsd.org/ports/head/devel/oniguruma/
-
- When this software is partly used or it is distributed with Ruby,
- this of Ruby follows the license of Ruby.
+include/ruby/onigmo.h:
+include/ruby/oniguruma.h:
+regcomp.c:
+regenc.[ch]:
+regerror.c:
+regexec.c:
+regint.h:
+regparse.[ch]:
+enc/ascii.c
+enc/big5.c
+enc/cp949.c
+enc/emacs_mule.c
+enc/encdb.c
+enc/euc_jp.c
+enc/euc_kr.c
+enc/euc_tw.c
+enc/gb18030.c
+enc/gb2312.c
+enc/gbk.c
+enc/iso_8859_1.c
+enc/iso_8859_10.c
+enc/iso_8859_11.c
+enc/iso_8859_13.c
+enc/iso_8859_14.c
+enc/iso_8859_15.c
+enc/iso_8859_16.c
+enc/iso_8859_2.c
+enc/iso_8859_3.c
+enc/iso_8859_4.c
+enc/iso_8859_5.c
+enc/iso_8859_6.c
+enc/iso_8859_7.c
+enc/iso_8859_8.c
+enc/iso_8859_9.c
+enc/koi8_r.c
+enc/koi8_u.c
+enc/shift_jis.c
+enc/unicode.c
+enc/us_ascii.c
+enc/utf_16be.c
+enc/utf_16le.c
+enc/utf_32be.c
+enc/utf_32le.c
+enc/utf_8.c
+enc/windows_1251.c
+
+Onigmo (Oniguruma-mod) LICENSE
+------------------------------
+
+/*-
+ * Copyright (c) 2002-2009 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014 K.Takata <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+Oniguruma LICENSE
+-----------------
+
+/*-
+ * Copyright (c) 2002-2009 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+https://github.com/k-takata/Onigmo/
+https://github.com/kkos/oniguruma
+https://svnweb.freebsd.org/ports/head/devel/oniguruma/
+
+ When this software is partly used or it is distributed with Ruby,
+ this of Ruby follows the license of Ruby.
+
+enc/trans/GB/GB12345%UCS.src:
+enc/trans/GB/UCS%GB12345.src:
+enc/trans/GB/GB2312%UCS.src:
+enc/trans/GB/UCS%GB2312.src:
-enc/trans/GB/GB12345%UCS.src::
-enc/trans/GB/UCS%GB12345.src::
-enc/trans/GB/GB2312%UCS.src::
-enc/trans/GB/UCS%GB2312.src::
-
- These files have this explanatory texts.
-
- >>>
This mapping data was created from files provided by Unicode, Inc.
(The Unicode Consortium). The files were used to create a product supporting
Unicode, as explicitly permitted in the files' copyright notices.
@@ -165,67 +161,56 @@ enc/trans/GB/UCS%GB2312.src::
files for any particular purpose, and has ceased to publish the files many
years ago.
-enc/trans/JIS/JISX0201-KANA%UCS.src::
-enc/trans/JIS/JISX0208\@1990%UCS.src::
-enc/trans/JIS/JISX0212%UCS.src::
-enc/trans/JIS/UCS%JISX0201-KANA.src::
-enc/trans/JIS/UCS%JISX0208@1990.src::
-enc/trans/JIS/UCS%JISX0212.src::
+enc/trans/JIS/JISX0201-KANA%UCS.src:
+enc/trans/JIS/JISX0208@1990%UCS.src:
+enc/trans/JIS/JISX0212%UCS.src:
+enc/trans/JIS/UCS%JISX0201-KANA.src:
+enc/trans/JIS/UCS%JISX0208@1990.src:
+enc/trans/JIS/UCS%JISX0212.src:
- These files are copyrighted as the following.
-
- >>>
© 2015 Unicode®, Inc.
-
For terms of use, see http://www.unicode.org/terms_of_use.html
-enc/trans/JIS/JISX0213-1%UCS@BMP.src::
-enc/trans/JIS/JISX0213-1%UCS@SIP.src::
-enc/trans/JIS/JISX0213-2%UCS@BMP.src::
-enc/trans/JIS/JISX0213-2%UCS@SIP.src::
+enc/trans/JIS/JISX0213-1%UCS@BMP.src:
+enc/trans/JIS/JISX0213-1%UCS@SIP.src:
+enc/trans/JIS/JISX0213-2%UCS@BMP.src:
+enc/trans/JIS/JISX0213-2%UCS@SIP.src:
- These files are copyrighted as the following.
+ Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved.
+ Copyright (C) 2001 I'O, All Rights Reserved.
+ Copyright (C) 2006 Project X0213, All Rights Reserved.
+ You can use, modify, distribute this table freely.
- >>>
- Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved.
- Copyright (C) 2001 I'O, All Rights Reserved.
- Copyright (C) 2006 Project X0213, All Rights Reserved.
- You can use, modify, distribute this table freely.
+enc/trans/JIS/UCS@BMP%JISX0213-1.src:
+enc/trans/JIS/UCS@BMP%JISX0213-2.src:
+enc/trans/JIS/UCS@SIP%JISX0213-1.src:
+enc/trans/JIS/UCS@SIP%JISX0213-2.src:
-enc/trans/JIS/UCS@BMP%JISX0213-1.src::
-enc/trans/JIS/UCS@BMP%JISX0213-2.src::
-enc/trans/JIS/UCS@SIP%JISX0213-1.src::
-enc/trans/JIS/UCS@SIP%JISX0213-2.src::
+ Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved.
+ Copyright (C) 2001 I'O, All Rights Reserved.
+ You can use, modify, distribute this table freely.
- These files are copyrighted as the following.
-
- >>>
- Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved.
- Copyright (C) 2001 I'O, All Rights Reserved.
- You can use, modify, distribute this table freely.
-
-configure::
+configure:
This file is free software.
- >>>
- Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+ Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
-tool/config.guess::
-tool/config.sub::
+tool/config.guess:
+tool/config.sub:
As long as you distribute these files with the file configure, they
are covered under the Ruby's license.
- >>>
- Copyright 1992-2018 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+ Free Software Foundation, Inc.
This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
@@ -234,55 +219,53 @@ tool/config.sub::
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>.
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception to the GNU General Public License, if you
distribute this file as part of a program that contains a
configuration script generated by Autoconf, you may include it under
- the same distribution terms that you use for the rest of that
- program. This Exception is an additional permission under section 7
- of the GNU General Public License, version 3 ("GPLv3").
+ the same distribution terms that you use for the rest of that program.
-parse.c::
+parse.c:
This file is licensed under the GPL, but is incorporated into Ruby and
redistributed under the terms of the Ruby license, as permitted by the
exception to the GPL below.
- >>>
- Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
- As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
+ /* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison.
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
-missing/dtoa.c::
+util.c (partly):
- This file is under these licenses.
-
- >>>
Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
Permission to use, copy, modify, and distribute this software for any
@@ -296,49 +279,48 @@ missing/dtoa.c::
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- >>>
- Copyright (c) 2004-2008 David Schultz <das@FreeBSD.ORG>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
-win32/win32.{c,h}::
+win32/win32.[ch]:
You can apply the Artistic License to these files. (or GPL,
alternatively)
- >>>
Copyright (c) 1993, Intergraph Corporation
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the perl README file.
-missing/mt19937.c::
+util.c (partly):
+
+ Copyright (c) 2004-2008 David Schultz <das@FreeBSD.ORG>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+random.c
This file is under the new-style BSD license.
- >>>
A C-program for MT19937, with initialization improved 2002/2/10.
- Coded by Takuji Nishimura and Makoto Matsumoto.
+ Coded by Takuji Nishimura and Makoto Matsumoto.
This is a faster version by taking Shawn Cokus's optimization,
Matthe Bellew's simplification, Isaku Wada's real version.
@@ -352,16 +334,16 @@ missing/mt19937.c::
modification, are permitted provided that the following conditions
are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
- 3. The names of its contributors may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -382,12 +364,11 @@ missing/mt19937.c::
The Wayback Machine url: http://web.archive.org/web/19990429082237/http://www.math.keio.ac.jp/matumoto/emt.html
-missing/procstat_vm.c::
+vm_dump.c:procstat_vm
This file is under the new-style BSD license.
- >>>
- Copyright (c) 2007 Robert N. M. Watson
+ Copyright (c) 2007 Robert N. M. Watson
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -413,14 +394,13 @@ missing/procstat_vm.c::
$FreeBSD: head/usr.bin/procstat/procstat_vm.c 261780 2014-02-11 21:57:37Z jhb $
-vsnprintf.c::
+vsnprintf.c:
This file is under the old-style BSD license. Note that the
paragraph 3 below is now null and void.
- >>>
- Copyright (c) 1990, 1993
- The Regents of the University of California. All rights reserved.
+ Copyright (c) 1990, 1993
+ The Regents of the University of California. All rights reserved.
This code is derived from software contributed to Berkeley by
Chris Torek.
@@ -454,40 +434,38 @@ vsnprintf.c::
From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
paragraph 3 above is now null and void.
-st.c::
-strftime.c::
-include/ruby/st.h::
-missing/acosh.c::
-missing/alloca.c::
-missing/dup2.c::
-missing/erf.c::
-missing/finite.c::
-missing/hypot.c::
-missing/isinf.c::
-missing/isnan.c::
-missing/lgamma_r.c::
-missing/memcmp.c::
-missing/memmove.c::
-missing/strchr.c::
-missing/strerror.c::
-missing/strstr.c::
-missing/tgamma.c::
-ext/date/date_strftime.c::
-ext/digest/sha1/sha1.c::
-ext/digest/sha1/sha1.h::
-ext/sdbm/_sdbm.c::
-ext/sdbm/sdbm.h::
+st.c:
+strftime.c:
+include/ruby/st.h:
+missing/acosh.c:
+missing/alloca.c:
+missing/dup2.c:
+missing/erf.c:
+missing/finite.c:
+missing/hypot.c:
+missing/isinf.c:
+missing/isnan.c:
+missing/lgamma_r.c:
+missing/memcmp.c:
+missing/memmove.c:
+missing/strchr.c:
+missing/strerror.c:
+missing/strstr.c:
+missing/tgamma.c:
+ext/date/date_strftime.c:
+ext/digest/sha1/sha1.[ch]:
+ext/sdbm/_sdbm.c:
+ext/sdbm/sdbm.h:
These files are all under public domain.
-missing/crypt.c::
+missing/crypt.c:
This file is under the old-style BSD license. Note that the
paragraph 3 below is now null and void.
- >>>
- Copyright (c) 1989, 1993
- The Regents of the University of California. All rights reserved.
+ Copyright (c) 1989, 1993
+ The Regents of the University of California. All rights reserved.
This code is derived from software contributed to Berkeley by
Tom Truscott.
@@ -516,16 +494,15 @@ missing/crypt.c::
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-missing/setproctitle.c::
+missing/setproctitle.c
This file is under the old-style BSD license. Note that the
paragraph 3 below is now null and void.
- >>>
- Copyright 2003 Damien Miller
- Copyright (c) 1983, 1995-1997 Eric P. Allman
- Copyright (c) 1988, 1993
- The Regents of the University of California. All rights reserved.
+ Copyright 2003 Damien Miller
+ Copyright (c) 1983, 1995-1997 Eric P. Allman
+ Copyright (c) 1988, 1993
+ The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -551,12 +528,11 @@ missing/setproctitle.c::
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-missing/strlcat.c::
-missing/strlcpy.c::
+missing/strlcat.c
+missing/strlcpy.c
These files are under an ISC-style license.
- >>>
Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
Permission to use, copy, modify, and distribute this software for any
@@ -571,25 +547,22 @@ missing/strlcpy.c::
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-missing/langinfo.c::
+missing/langinfo.c
This file is from http://www.cl.cam.ac.uk/~mgk25/ucs/langinfo.c.
Ruby uses a modified version. The file contains the following
author/copyright notice:
- >>>
- Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11
- Permission to use, copy, modify, and distribute this software
- for any purpose and without fee is hereby granted. The author
- disclaims all warranties with regard to this software.
+ Markus.Kuhn@cl.cam.ac.uk -- 2002-03-11
+ Permission to use, copy, modify, and distribute this software
+ for any purpose and without fee is hereby granted. The author
+ disclaims all warranties with regard to this software.
-ext/digest/md5/md5.c::
-ext/digest/md5/md5.h::
+ext/digest/md5/md5.[ch]:
These files are under the following license. Ruby uses modified
versions of them.
- >>>
Copyright (C) 1999, 2000 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
@@ -611,26 +584,22 @@ ext/digest/md5/md5.h::
L. Peter Deutsch
ghost@aladdin.com
-ext/digest/rmd160/rmd160.c::
-ext/digest/rmd160/rmd160.h::
+ext/digest/rmd160/rmd160.[ch]:
These files have the following copyright information, and by the
author we are allowed to use it under the new-style BSD license.
- >>>
- AUTHOR:: Antoon Bosselaers, ESAT-COSIC
+ AUTHOR: Antoon Bosselaers, ESAT-COSIC
(Arranged for libc by Todd C. Miller)
- DATE:: 1 March 1996
+ DATE: 1 March 1996
Copyright (c) Katholieke Universiteit Leuven
1996, All Rights Reserved
-ext/digest/sha2/sha2.c::
-ext/digest/sha2/sha2.h::
+ext/digest/sha2/sha2.[ch]:
These files are under the new-style BSD license.
- >>>
Copyright 2000 Aaron D. Gifford. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -657,108 +626,95 @@ ext/digest/sha2/sha2.h::
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-ext/json/generator/generator.c::
-
- The file contains the following copyright notice.
+ext/json/generator/generator.c:
- >>>
Copyright 2001-2004 Unicode, Inc.
- Disclaimer::
+ Disclaimer
- This source code is provided as is by Unicode, Inc. No claims are
- made as to fitness for any particular purpose. No warranties of any
- kind are expressed or implied. The recipient agrees to determine
- applicability of information provided. If this file has been
- purchased on magnetic or optical media from Unicode, Inc., the
- sole remedy for any claim will be exchange of defective media
- within 90 days of receipt.
+ This source code is provided as is by Unicode, Inc. No claims are
+ made as to fitness for any particular purpose. No warranties of any
+ kind are expressed or implied. The recipient agrees to determine
+ applicability of information provided. If this file has been
+ purchased on magnetic or optical media from Unicode, Inc., the
+ sole remedy for any claim will be exchange of defective media
+ within 90 days of receipt.
- Limitations on Rights to Redistribute This Code::
+ Limitations on Rights to Redistribute This Code
- Unicode, Inc. hereby grants the right to freely use the information
- supplied in this file in the creation of products supporting the
- Unicode Standard, and to make copies of this file in any form
- for internal or external distribution as long as this notice
- remains attached.
+ Unicode, Inc. hereby grants the right to freely use the information
+ supplied in this file in the creation of products supporting the
+ Unicode Standard, and to make copies of this file in any form
+ for internal or external distribution as long as this notice
+ remains attached.
-ext/nkf/nkf-utf8/config.h::
-ext/nkf/nkf-utf8/nkf.c::
-ext/nkf/nkf-utf8/utf8tbl.c::
+ext/nkf/nkf-utf8/config.h:
+ext/nkf/nkf-utf8/nkf.c:
+ext/nkf/nkf-utf8/utf8tbl.c:
These files are under the following license. So to speak, it is
copyrighted semi-public-domain software.
- >>>
Copyright (C) 1987, Fujitsu LTD. (Itaru ICHIKAWA)
-
- Everyone is permitted to do anything on this program
- including copying, modifying, improving,
- as long as you don't try to pretend that you wrote it.
- i.e., the above copyright notice has to appear in all copies.
- Binary distribution requires original version messages.
- You don't have to ask before copying, redistribution or publishing.
- THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
-
-ext/psych::
-test/psych::
-
- The files under these directories are under the following license, except for
- ext/psych/yaml.
-
- >>>
- Copyright 2009 Aaron Patterson, et al.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the 'Software'), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do
- so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
-ext/psych/yaml::
-
- The files under this directory are under the following license.
-
- >>>
- Copyright (c) 2006 Kirill Simonov
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the "Software"), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do
- so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
-ext/socket/addrinfo.h::
-ext/socket/getaddrinfo.c::
-ext/socket/getnameinfo.c::
+ Everyone is permitted to do anything on this program
+ including copying, modifying, improving,
+ as long as you don't try to pretend that you wrote it.
+ i.e., the above copyright notice has to appear in all copies.
+ Binary distribution requires original version messages.
+ You don't have to ask before copying, redistribution or publishing.
+ THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+
+ext/psych:
+test/psych:
+
+ Copyright 2009 Aaron Patterson, et al.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the 'Software'), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do
+ so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ext/psych/yaml:
+
+ Copyright (c) 2006 Kirill Simonov
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the "Software"), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do
+ so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ext/socket/addrinfo.h:
+ext/socket/getaddrinfo.c:
+ext/socket/getnameinfo.c:
These files are under the new-style BSD license.
- >>>
Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
All rights reserved.
@@ -786,12 +742,11 @@ ext/socket/getnameinfo.c::
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-ext/win32ole/win32ole.c::
+ext/win32ole/win32ole.c:
You can apply the Artistic License to this file. (or GPL,
alternatively)
- >>>
(c) 1995 Microsoft Corporation. All rights reserved.
Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
@@ -804,19 +759,15 @@ ext/win32ole/win32ole.c::
The Wayback Machine url: http://web.archive.org/web/19970607104352/http://www.activeware.com:80/
-lib/rdoc/generator/template/darkfish/css/fonts.css::
+lib/rdoc/generator/template/darkfish/css/fonts.css:
This file is licensed under the SIL Open Font License.
- >>>
http://scripts.sil.org/OFL
-spec/mspec::
-spec/ruby::
-
- The files under these directories are under the following license.
+spec/mspec:
+spec/ruby:
- >>>
Copyright (c) 2008 Engine Yard, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person
@@ -840,96 +791,60 @@ spec/ruby::
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-lib/rubygems.rb::
-lib/rubygems::
-test/rubygems::
-
- RubyGems is under the following license.
-
- >>>
- RubyGems is copyrighted free software by Chad Fowler, Rich Kilmer, Jim
- Weirich and others. You can redistribute it and/or modify it under
- either the terms of the MIT license (see the file MIT.txt), or the
- conditions below:
-
- 1. You may make and give away verbatim copies of the source form of the
- software without restriction, provided that you duplicate all of the
- original copyright notices and associated disclaimers.
-
- 2. You may modify your copy of the software in any way, provided that
- you do at least ONE of the following:
-
- a. place your modifications in the Public Domain or otherwise
- make them Freely Available, such as by posting said
- modifications to Usenet or an equivalent medium, or by allowing
- the author to include your modifications in the software.
-
- b. use the modified software only within your corporation or
- organization.
-
- c. give non-standard executables non-standard names, with
- instructions on where to get the original software distribution.
-
- d. make other distribution arrangements with the author.
+lib/rubygems.rb:
+lib/rubygems:
+test/rubygems:
- 3. You may distribute the software in object code or executable
- form, provided that you do at least ONE of the following:
+ RubyGems is copyrighted free software by Chad Fowler, Rich Kilmer, Jim
+ Weirich and others. You can redistribute it and/or modify it under
+ either the terms of the MIT license (see the file MIT.txt), or the
+ conditions below:
- a. distribute the executables and library files of the software,
- together with instructions (in the manual page or equivalent)
- on where to get the original distribution.
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
- b. accompany the distribution with the machine-readable source of
- the software.
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
- c. give non-standard executables non-standard names, with
- instructions on where to get the original software distribution.
+ a. place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
- d. make other distribution arrangements with the author.
+ b. use the modified software only within your corporation or
+ organization.
- 4. You may modify and include the part of the software into any other
- software (possibly commercial).
+ c. give non-standard executables non-standard names, with
+ instructions on where to get the original software distribution.
- 5. The scripts and library files supplied as input to or produced as
- output from the software do not automatically fall under the
- copyright of the software, but belong to whomever generated them,
- and may be sold commercially, and may be aggregated with this
- software.
+ d. make other distribution arrangements with the author.
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE.
+ 3. You may distribute the software in object code or executable
+ form, provided that you do at least ONE of the following:
-lib/bundler::
-lib/bundler.rb::
-lib/bundler.gemspec::
-spec/bundler::
-man/bundle-*,gemfile.*::
+ a. distribute the executables and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
- Bundler is under the following license.
+ b. accompany the distribution with the machine-readable source of
+ the software.
- >>>
- Portions copyright (c) 2010 Andre Arko
- Portions copyright (c) 2009 Engine Yard
+ c. give non-standard executables non-standard names, with
+ instructions on where to get the original software distribution.
- MIT License::
+ d . make other distribution arrangements with the author.
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial).
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000000..25075f5900
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,531 @@
+SHELL = /bin/sh
+NULLCMD = @NULLCMD@
+n=$(NULLCMD)
+ECHO1 = $(V:1=$n)
+RUNCMD = $(SHELL)
+CDPATH = .
+CHDIR = @CHDIR@
+exec = exec
+NULL = /dev/null
+PATH_SEPARATOR = @PATH_SEPARATOR@
+
+#### Start of system configuration section. ####
+
+srcdir = @srcdir@
+top_srcdir = $(srcdir)
+hdrdir = $(srcdir)/include
+PLATFORM_DIR = @PLATFORM_DIR@
+
+CC = @CC@
+CPP = @CPP@
+LD = @LD@
+YACC = bison
+PURIFY =
+AUTOCONF = autoconf
+ACLOCAL = aclocal
+CONFIGURE = @CONFIGURE@
+@SET_MAKE@
+MKFILES = @MAKEFILES@
+BASERUBY = @BASERUBY@
+HAVE_BASERUBY = @HAVE_BASERUBY@
+TEST_RUNNABLE = @TEST_RUNNABLE@
+CROSS_COMPILING = @CROSS_COMPILING@
+DOXYGEN = @DOXYGEN@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+sbindir = @sbindir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+datarootdir = @datarootdir@
+datadir = @datadir@
+arch = @arch@
+sitearch = @sitearch@
+sitedir = @sitedir@
+archlibdir = @archlibdir@
+ruby_version = @ruby_version@
+
+TESTUI = console
+TESTS =
+INSTALLDOC = @INSTALLDOC@
+DOCTARGETS = @RDOCTARGET@ @CAPITARGET@
+
+EXTOUT = @EXTOUT@
+arch_hdrdir = $(EXTOUT)/include/$(arch)
+VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir):$(srcdir)/missing
+
+empty =
+CC_VERSION = @CC_VERSION@
+OUTFLAG = @OUTFLAG@$(empty)
+COUTFLAG = @COUTFLAG@$(empty)
+ARCH_FLAG = @ARCH_FLAG@
+CFLAGS_NO_ARCH = @CFLAGS@
+CFLAGS = $(CFLAGS_NO_ARCH) $(ARCH_FLAG)
+cflags = @cflags@
+optflags = @optflags@
+debugflags = @debugflags@
+warnflags = @warnflags@ @strict_warnflags@
+cppflags = @cppflags@
+XCFLAGS = @XCFLAGS@
+CPPFLAGS = @CPPFLAGS@ $(INCFLAGS)
+LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
+EXTLDFLAGS = @EXTLDFLAGS@
+XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
+EXTLIBS =
+LIBS = @LIBS@ $(EXTLIBS)
+MISSING = @LIBOBJS@ @ALLOCA@
+ENABLE_SHARED = @ENABLE_SHARED@
+LDSHARED = @LIBRUBY_LDSHARED@
+DLDFLAGS = @LIBRUBY_DLDFLAGS@ $(XLDFLAGS) $(ARCH_FLAG)
+SOLIBS = @SOLIBS@
+ENABLE_DEBUG_ENV = @ENABLE_DEBUG_ENV@
+MAINLIBS = @MAINLIBS@
+ARCHMINIOBJS = @MINIOBJS@
+DLNOBJ = @DLNOBJ@
+ENCOBJS = @ENCOBJS@
+EXTOBJS = @EXTOBJS@
+BUILTIN_ENCOBJS = @BUILTIN_ENCOBJS@
+BUILTIN_TRANSSRCS = @BUILTIN_TRANSSRCS@
+BUILTIN_TRANSOBJS = @BUILTIN_TRANSOBJS@
+POSTLINK = @POSTLINK@
+
+RUBY_BASE_NAME=@RUBY_BASE_NAME@
+RUBY_PROGRAM_VERSION=@RUBY_PROGRAM_VERSION@
+RUBY_API_VERSION=@RUBY_API_VERSION@
+RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
+RUBY_SO_NAME=@RUBY_SO_NAME@
+EXEEXT = @EXEEXT@
+LIBEXT = @LIBEXT@
+PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
+RUBY = $(RUBY_INSTALL_NAME)
+MINIRUBY = @MINIRUBY@\
+ $(MINIRUBYOPT)
+# RUNRUBY_COMMAND:: runruby.rb or baseruby. do not append options directly
+RUNRUBY_COMMAND = @RUNRUBY_COMMAND@
+# RUNRUBY:: run ruby with RUN_OPTS which is passed to ruby
+RUNRUBY = @RUNRUBY@ $(RUN_OPTS)
+# RUNRUBY_DEBUGGER:: debugging option for runruby.rb
+RUNRUBY_DEBUGGER = --debugger='gdb -x run.gdb --quiet --args'
+XRUBY = @XRUBY@
+BTESTRUBY = @BTESTRUBY@\
+ $(MINIRUBYOPT)
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+XRUBY_LIBDIR = @XRUBY_LIBDIR@
+XRUBY_RUBYLIBDIR = @XRUBY_RUBYLIBDIR@
+XRUBY_RUBYHDRDIR = @XRUBY_RUBYHDRDIR@
+BOOTSTRAPRUBY = @BOOTSTRAPRUBY@
+
+#### End of system configuration section. ####
+
+MAJOR= @MAJOR@
+MINOR= @MINOR@
+TEENY= @TEENY@
+RUBY_PROGRAM_VERSION = @RUBY_PROGRAM_VERSION@
+
+LIBRUBY_A = @LIBRUBY_A@
+LIBRUBY_SO = @LIBRUBY_SO@
+LIBRUBY_SONAME= @LIBRUBY_SONAME@
+LIBRUBY_ALIASES= @LIBRUBY_ALIASES@
+LIBRUBY = @LIBRUBY@
+LIBRUBYARG = @LIBRUBYARG@
+LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@
+LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@
+LIBRUBY_RELATIVE = @LIBRUBY_RELATIVE@
+LIBRUBY_A_OBJS = @LIBRUBY_A_OBJS@
+
+DTRACE_REBUILD_OBJS = $(DTRACE_REBUILD:yes=$(DTRACE_DEPENDENT_OBJS))
+
+DTRACE_DEPENDENT_OBJS = array.$(OBJEXT) \
+ eval.$(OBJEXT) \
+ gc.$(OBJEXT) \
+ hash.$(OBJEXT) \
+ load.$(OBJEXT) \
+ object.$(OBJEXT) \
+ parse.$(OBJEXT) \
+ string.$(OBJEXT) \
+ symbol.$(OBJEXT) \
+ vm.$(OBJEXT)
+
+THREAD_MODEL = @THREAD_MODEL@
+
+PREP = @PREP@
+ARCHFILE = @ARCHFILE@
+SETUP =
+EXTSTATIC = @EXTSTATIC@
+ENCSTATIC = @ENCSTATIC@
+SET_LC_MESSAGES = env LC_MESSAGES=C
+
+MAKEDIRS = @MKDIR_P@
+CP = cp
+MV = mv
+RM = rm -f
+RMDIR = @RMDIR@
+RMDIRS = @RMDIRS@
+RMALL = @RMALL@
+NM = @NM@
+AR = @AR@
+ARFLAGS = @ARFLAGS@$(empty)
+RANLIB = @RANLIB@
+AS = @AS@
+ASFLAGS = @ASFLAGS@ $(INCFLAGS)
+IFCHANGE = $(srcdir)/tool/ifchange
+SET_LC_MESSAGES = env LC_MESSAGES=C
+OBJDUMP = @OBJDUMP@
+OBJCOPY = @OBJCOPY@
+HAVE_GIT = @HAVE_GIT@
+GIT = @GIT@
+VCS = @VCS@
+VCSUP = @VCSUP@
+DTRACE = @DTRACE@ @DTRACE_OPT@
+DTRACE_EXT = @DTRACE_EXT@
+DTRACE_OBJ = @DTRACE_OBJ@
+DTRACE_REBUILD= @DTRACE_REBUILD@
+DTRACE_GLOMMED_OBJ = $(DTRACE_REBUILD:yes=ruby-glommed.$(OBJEXT))
+
+OBJEXT = @OBJEXT@
+ASMEXT = S
+SOEXT = @SOEXT@
+DLEXT = @DLEXT@
+MANTYPE = @MANTYPE@
+SYMBOL_PREFIX = @SYMBOL_PREFIX@
+
+INSTALLED_LIST= .installed.list
+
+NEWLINE_C = enc/trans/newline.c
+MINIPRELUDE_C = miniprelude.c
+PRELUDE_C = prelude.c
+RBCONFIG = .rbconfig.time
+
+MAINSRC = $(MAINOBJ:@OBJEXT@=c)
+
+SRC_FILE = $<
+OS_SRC_FILE = $<
+DEST_FILE = $@
+OS_DEST_FILE = $@
+
+MESSAGE_BEGIN = @for line in
+MESSAGE_END = ; do echo "$$line"; done
+ECHO_BEGIN = @sep=''; for word in
+ECHO_END = ; do echo @ECHO_N@ "$$sep'$$word'@ECHO_C@"; sep=' '; done; echo
+
+DESTDIR = @DESTDIR@
+
+configure_args = @configure_args@
+#### End of variables
+
+.SUFFIXES: .inc .h .c .y .i .$(DTRACE_EXT)
+
+all:
+
+# Prevent GNU make v3 from overflowing arg limit on SysV.
+.NOEXPORT:
+
+miniruby$(EXEEXT):
+ @-if test -f $@; then $(MV) -f $@ $@.old; $(RM) $@.old; fi
+ $(ECHO) linking $@
+ $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@
+ $(Q) $(POSTLINK)
+
+$(PROGRAM):
+ @$(RM) $@
+ $(ECHO) linking $@
+ $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@
+ $(Q) $(POSTLINK)
+
+# We must `rm' the library each time this rule is invoked because "updating" a
+# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
+# supported.
+$(LIBRUBY_A):
+ @$(RM) $@
+ $(ECHO) linking static-library $@
+ $(Q) $(AR) $(ARFLAGS) $@ $(LIBRUBY_A_OBJS) $(INITOBJS)
+ @-$(RANLIB) $@ 2> /dev/null || true
+
+verify-static-library: $(LIBRUBY_A)
+ $(ECHO) verifying static-library $@
+ @$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)conftest$(EXEEXT)
+ @$(RMALL) conftest$(EXEEXT) conftest.c conftest.dSYM
+
+$(LIBRUBY_SO):
+ @-$(PRE_LIBRUBY_UPDATE)
+ $(ECHO) linking shared-library $@
+ $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(EXTSOLIBS) $(OUTFLAG)$@
+ -$(Q) $(OBJCOPY) -w -L '$(SYMBOL_PREFIX)Init_*' -L '$(SYMBOL_PREFIX)ruby_static_id_*' \
+ -L '$(SYMBOL_PREFIX)*_threadptr_*' -L '$(SYMBOL_PREFIX)*_ec_*' $@
+ $(Q) $(POSTLINK)
+ @-$(MINIRUBY) -e 'ARGV.each{|link| File.delete link rescue nil; \
+ File.symlink "$(LIBRUBY_SO)", link}' \
+ $(LIBRUBY_ALIASES) || true
+
+ruby_pc = @ruby_pc@
+$(ruby_pc):
+ @./config.status --file=$@:$(srcdir)/template/ruby.pc.in
+
+ruby-runner.h: template/ruby-runner.h.in
+ @./config.status --file=$@:$(srcdir)/template/$(@F).in
+
+$(RBCONFIG): $(PREP)
+
+rbconfig.rb: $(RBCONFIG)
+
+install-cross: $(arch)-fake.rb $(RBCONFIG) rbconfig.rb $(arch_hdrdir)/ruby/config.h \
+ $(LIBRUBY_A) $(LIBRUBY_SO) $(ARCHFILE)
+ $(ECHO) installing cross-compiling stuff
+ $(Q) $(MAKEDIRS) $(XRUBY_RUBYLIBDIR)/$(arch) $(XRUBY_RUBYHDRDIR)/$(arch)/ruby
+ $(Q) sed '/^\$$:\.unshift/q' $(arch)-fake.rb > fake.rb
+ $(Q) $(BASERUBY) -p \
+ -e '~/^\s*CONFIG\["LDFLAGS"\]/ and' \
+ -e '$$_[/(?=\s*"$$)/] = %q[ #{(CONFIG["LIBPATHFLAG"]%File.dirname(__FILE__)).strip}]' \
+ rbconfig.rb > fake-rbconfig.rb
+ $(INSTALL_SCRIPT) fake.rb $(XRUBY_RUBYLIBDIR)/$(arch)/fake.rb
+ $(INSTALL_SCRIPT) fake-rbconfig.rb $(XRUBY_RUBYLIBDIR)/$(arch)/rbconfig.rb
+ @$(RM) fake.rb fake-rbconfig.rb
+ $(INSTALL_DATA) $(arch_hdrdir)/ruby/config.h $(XRUBY_RUBYHDRDIR)/$(arch)/ruby
+ $(INSTALL_DATA) $(top_srcdir)/include/ruby/win32.h $(XRUBY_RUBYHDRDIR)/ruby
+ $(INSTALL_DATA) $(LIBRUBY) $(LIBRUBY_A) $(XRUBY_RUBYLIBDIR)/$(arch)
+ $(INSTALL_PROGRAM) $(LIBRUBY_SO) $(XRUBY_RUBYLIBDIR)/$(arch)
+
+Makefile: $(srcdir)/Makefile.in $(srcdir)/enc/Makefile.in
+
+$(MKFILES): config.status $(srcdir)/version.h
+ @[ -f $@ ] && mv $@ $@.old
+ MAKE=$(MAKE) $(SHELL) ./config.status $@
+ @cmp $@ $@.old > /dev/null 2>&1 && echo $@ unchanged && exit 0; \
+ { \
+ echo "all:; -@rm -f conftest.mk"; \
+ echo "conftest.mk: .force; @echo AUTO_REMAKE"; \
+ echo ".force:"; \
+ } > conftest.mk || exit 1; \
+ $(MAKE) -f conftest.mk | grep '^AUTO_REMAKE$$' >/dev/null 2>&1 || \
+ { echo "$@ updated, restart."; exit 1; }
+
+uncommon.mk: $(srcdir)/common.mk
+ sed 's/{\$$([^(){}]*)[^{}]*}//g' $< > $@
+
+.PHONY: reconfig
+reconfig-args = $(srcdir)/$(CONFIGURE) $(configure_args)
+config.status-args = ./config.status --recheck
+reconfig-exec-0 = test -t 1 && { CONFIGURE_TTY=yes; export CONFIGURE_TTY; }; exec 3>&1; exit `exec 4>&1; { "$$@" 3>&- 4>&-; echo $$? 1>&4; } | fgrep -v '(cached)' 1>&3 3>&- 4>&-`
+reconfig-exec-1 = set -x; "$$@"
+
+reconfig config.status: $(srcdir)/$(CONFIGURE) $(srcdir)/enc/Makefile.in \
+ $(srcdir)/include/ruby/version.h
+ @PWD= MINIRUBY="$(MINIRUBY)"; export MINIRUBY; \
+ set $(SHELL) $($@-args); $(reconfig-exec-$(V))
+
+$(srcdir)/$(CONFIGURE): $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+ $(CHDIR) $(srcdir) && exec $(AUTOCONF) -o $(@F)
+
+$(srcdir)/aclocal.m4:
+ $(CHDIR) $(srcdir) && \
+ type $(ACLOCAL) >/dev/null 2>&1 && exec $(ACLOCAL); \
+ touch $(@F)
+
+prereq: $(srcdir)/$(CONFIGURE)
+
+incs: id.h
+all-incs: probes.h
+
+# Things which should be considered:
+# * with gperf v.s. without gperf
+# * committers may have various versions of gperf
+# * ./configure v.s. ../ruby/configure
+# * GNU make v.s. HP-UX make # HP-UX make invokes the action if lex.c and keywords has same mtime.
+# * svn checkout generate a file with mtime as current time
+# * ext4 and XFS has a mtime with fractional part
+lex.c: defs/keywords
+ @\
+ if cmp -s $(srcdir)/defs/lex.c.src $?; then \
+ [ $(Q) ] && echo copying $@ || set -x; \
+ $(CP) $(srcdir)/lex.c.blt $@; \
+ else \
+ [ $(Q) ] && echo generating $@ || set -x; \
+ gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? \
+ | sed -f $(srcdir)/tool/gperf.sed \
+ > $@.tmp && \
+ $(MV) $@.tmp $@ && \
+ $(CP) $? $(srcdir)/defs/lex.c.src && \
+ $(CP) $@ $(srcdir)/lex.c.blt; \
+ fi
+
+JIS_PROPS_OPTIONS = -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property
+
+$(srcdir)/enc/jis/props.h: enc/jis/props.kwd
+ $(MAKEDIRS) $(@D)
+ @set +e; \
+ if cmp -s $(?:.kwd=.src) $?; then \
+ set -x; \
+ $(CP) $(?:.kwd=.h.blt) $@; \
+ else \
+ set -x; \
+ gperf $(JIS_PROPS_OPTIONS) $? | \
+ sed -f $(srcdir)/tool/gperf.sed > $@ && \
+ $(CP) $? $(?:.kwd=.src) && \
+ $(CP) $@ $(?:.kwd=.h.blt); \
+ fi
+
+.c.@OBJEXT@:
+ @$(ECHO) compiling $<
+ $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $<
+
+.s.@OBJEXT@:
+ @$(ECHO) assembling $<
+ $(Q) $(AS) $(ASFLAGS) -o $@ $<
+
+.c.S:
+ @$(ECHO) translating $<
+ $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.i:
+ @$(ECHO) preprocessing $<
+ $(Q) $(CPP) $(warnflags) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -E $< > $@
+
+.d.h:
+ @$(ECHO) translating probes $<
+ $(Q) $(DTRACE) -o $@.tmp -h -C $(INCFLAGS) -s $<
+ $(Q) sed -e 's/RUBY_/RUBY_DTRACE_/g' -e 's/PROBES_H_TMP/RUBY_PROBES_H/' -e 's/(char \*/(const char */g' -e 's/, char \*/, const char */g' $@.tmp > $@
+ $(Q) $(RM) $@.tmp
+
+.dmyh.h:
+ @$(ECHO) making dummy $(DEST_FILE)
+ $(Q)echo '#include "$(*F).dmyh"' > $@
+
+probes.stamp: $(DTRACE_REBUILD_OBJS)
+ $(Q) if test -f $@ -o -f probes.$(OBJEXT); then \
+ $(RM) $(DTRACE_REBUILD_OBJS) $@; \
+ $(ECHO0) "rebuilding objects which were modified by \"dtrace -G\""; \
+ $(MAKE) $(DTRACE_REBUILD_OBJS); \
+ fi
+ $(Q) touch $@
+
+probes.@OBJEXT@: $(srcdir)/probes.d $(DTRACE_REBUILD:yes=probes.stamp)
+ @$(ECHO) processing probes in object files
+ $(Q) $(RM) $@
+ $(Q) $(DTRACE) -G -C $(INCFLAGS) -s $(srcdir)/probes.d -o $@ $(DTRACE_REBUILD_OBJS)
+
+# DTrace static library hacks described here:
+# http://mail.opensolaris.org/pipermail/dtrace-discuss/2005-August/000207.html
+ruby-glommed.$(OBJEXT):
+ @$(ECHO) generating a glommed object with DTrace probes for static library
+ $(Q) $(LD) -r -o $@ $(OBJS)
+
+clean-local::
+ $(Q)$(RM) ext/extinit.c ext/extinit.$(OBJEXT) ext/ripper/y.output \
+ enc/encinit.c enc/encinit.$(OBJEXT)
+ -$(Q)$(RM) $(pkgconfig_DATA)
+ -$(Q)$(RMALL) exe/ ruby-runner.h *.dSYM
+
+distclean-local::
+ $(Q)$(RM) ext/config.cache $(RBCONFIG) Doxyfile
+ -$(Q)$(RM) run.gdb
+ -$(Q)$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h verconf.h
+ -$(Q)$(RMDIRS) $(arch_hdrdir)/ruby 2> /dev/null || true
+
+ext/clean.sub gems/clean.sub:: ext/clean.mk
+ext/distclean.sub gems/distclean.sub:: ext/distclean.mk
+ext/realclean.sub gems/realclean.sub:: ext/realclean.mk
+
+ext/clean.mk ext/distclean.mk ext/realclean.mk::
+ -$(Q) if [ -f $(EXTS_MK) ]; then exec $(MAKE) -f $(EXTS_MK) $(@F:.mk=); fi
+
+ext/clean:: ext/clean.sub
+ext/distclean:: ext/distclean.sub
+ext/realclean:: ext/realclean.sub
+gems/clean:: gems/clean.sub
+gems/distclean:: gems/distclean.sub
+gems/realclean:: gems/realclean.sub
+
+ext/clean.sub ext/distclean.sub ext/realclean.sub \
+gems/clean.sub gems/distclean.sub gems/realclean.sub::
+ $(Q) set dummy `echo "${EXTS}" | tr , ' '`; shift; \
+ test "$$#" = 0 && set .; \
+ set dummy `\
+ cd $(@D) 2>/dev/null && \
+ find "$$@" \( -name Makefile -o -name exts.mk \) -print | \
+ sed -n 's:^\./::;s:^:$(@D)/:;s:/[^/][^/]*$$::p' | sort -u; \
+ `; shift; \
+ for dir do \
+ $(RM) "$$dir/exts.mk"; \
+ if [ -f "$$dir/Makefile" ]; then \
+ echo $(@F:.sub=)ing "$$dir"; \
+ (cd "$$dir" && exec $(MAKE) $(mflags) $(@F:.sub=)); \
+ fi; \
+ done || true
+
+ext/distclean ext/realclean gems/distclean gems/realclean::
+ $(Q) set dummy `echo "${EXTS}" | tr , ' '`; shift; \
+ test "$$#" = 0 && set .; \
+ cd $(@D) 2>/dev/null && \
+ find "$$@" -type d -empty -exec $(RMDIRS) {} + 2> /dev/null || true
+ $(Q) $(RMDIRS) $(@D) 2> /dev/null || true
+
+clean-enc distclean-enc realclean-enc:
+ @test -f "$(ENC_MK)" || exit 0; \
+ echo $(@:-enc=ing) encodings; \
+ exec $(MAKE) $(MAKE_ENC) $(@:-enc=)
+
+ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
+ $(ECHO) compiling $@
+ $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c
+
+enc/encinit.$(OBJEXT): enc/encinit.c $(SETUP)
+
+test-bundled-gems-run:
+ $(Q) set -e; while read gem _; do \
+ echo testing $$gem gem && \
+ $(XRUBY) -C $(srcdir)/gems/src/$$gem -Ilib ../../../.bundle/bin/rake; \
+ done < $(srcdir)/gems/bundled_gems
+
+update-src::
+ @$(CHDIR) "$(srcdir)" && LC_TIME=C exec $(VCSUP)
+
+update-download:: update-config_files
+
+after-update:: prereq
+
+gcov:
+ $(Q) $(BASERUBY) $(srcdir)/tool/run-gcov.rb
+
+lcov:
+ $(Q) $(BASERUBY) $(srcdir)/tool/run-lcov.rb
+
+update-doclie:
+ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
+ --branch $(DOCLIE_GIT_REF) \
+ $(DOCLIE_GIT_URL) doclie $(GIT_OPTS)
+
+update-simplecov-html:
+ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
+ --branch $(SIMPLECOV_HTML_GIT_REF) \
+ $(SIMPLECOV_HTML_GIT_URL) simplecov-html $(GIT_OPTS)
+
+update-simplecov:
+ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
+ --branch $(SIMPLECOV_GIT_REF) \
+ $(SIMPLECOV_GIT_URL) simplecov $(GIT_OPTS)
+
+update-coverage: update-simplecov update-simplecov-html update-doclie
+
+INSNS = opt_sc.inc optinsn.inc optunifs.inc insns.inc insns_info.inc \
+ vmtc.inc vm.inc
+
+$(INSNS): $(srcdir)/insns.def vm_opts.h \
+ $(srcdir)/defs/opt_operand.def $(srcdir)/defs/opt_insn_unif.def \
+ $(srcdir)/tool/instruction.rb $(srcdir)/tool/insns2vm.rb
+ $(ECHO) generating $@
+ $(Q) $(BASERUBY) -Ku $(srcdir)/tool/insns2vm.rb $(INSNS2VMOPT) $@
+
+verconf.h: $(RBCONFIG)
+
+loadpath: verconf.h
+ @$(CPP) $(XCFLAGS) $(CPPFLAGS) $(srcdir)/loadpath.c | \
+ sed -e '1,/^const char ruby_initial_load_paths/d;/;/,$$d' \
+ -e '/^ /!d;s/ *"\\0"$$//;s/" *"//g'
+
+un-runnable:
+ $(ECHO) cannot make runnable, configure with --enable-load-relative.
+ $(Q) exit 1
diff --git a/NEWS b/NEWS
index e1adb5115d..e1b91f38b7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,826 +1,577 @@
# -*- rdoc -*-
-= NEWS for Ruby 2.7.0
+= NEWS for Ruby 2.5.0
This document is a list of user visible feature changes made between
releases except for bug fixes.
-Note that each entry is kept so brief that no reason behind or reference
-information is supplied with. For a full list of changes with all
-sufficient information, see the ChangeLog file or Redmine
-(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>).
+Note that each entry is kept so brief that no reason behind or
+reference information is supplied with. For a full list of changes
+with all sufficient information, see the ChangeLog file or Redmine
+(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>)
-== Changes since the 2.6.0 release
+== Changes since the 2.4.0 release
=== Language changes
-==== Pattern matching
+* Top-level constant look-up is removed. [Feature #11547]
-* Pattern matching is introduced as an experimental feature. [Feature #14912]
+* rescue/else/ensure are allowed inside do/end blocks. [Feature #12906]
- case [0, [1, 2, 3]]
- in [a, [b, *c]]
- p a #=> 0
- p b #=> 1
- p c #=> [2, 3]
- end
-
- case {a: 0, b: 1}
- in {a: 0, x: 1}
- :unreachable
- in {a: 0, b: var}
- p var #=> 1
- end
+* refinements take place in string interpolations. [Feature #13812]
- case -1
- in 0 then :unreachable
- in 1 then :unreachable
- end #=> NoMatchingPatternError
-
- json = <<END
- {
- "name": "Alice",
- "age": 30,
- "children": [{ "name": "Bob", "age": 2 }]
- }
- END
-
- JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: name, age: age}]}
-
- p name #=> "Bob"
- p age #=> 2
-
- JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: "Charlie", age: age}]}
- #=> NoMatchingPatternError
-
-* See the following slides for more details:
- * https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7
- * Note that the slides are slightly obsolete.
-
-* The warning against pattern matching can be suppressed with
- {-W:no-experimental option}[#label-Warning+option].
-
-==== The spec of keyword arguments is changed towards 3.0
-
-* Automatic conversion of keyword arguments and positional arguments is
- deprecated, and conversion will be removed in Ruby 3. [Feature #14183]
-
- * When a method call passes a Hash at the last argument, and when it
- passes no keywords, and when the called method accepts keywords,
- a warning is emitted. To continue treating the hash as keywords,
- add a double splat operator to avoid the warning and ensure
- correct behavior in Ruby 3.
-
- def foo(key: 42); end; foo({key: 42}) # warned
- def foo(**kw); end; foo({key: 42}) # warned
- def foo(key: 42); end; foo(**{key: 42}) # OK
- def foo(**kw); end; foo(**{key: 42}) # OK
-
- * When a method call passes keywords to a method that accepts keywords,
- but it does not pass enough required positional arguments, the
- keywords are treated as a final required positional argument, and a
- warning is emitted. Pass the argument as a hash instead of keywords
- to avoid the warning and ensure correct behavior in Ruby 3.
-
- def foo(h, **kw); end; foo(key: 42) # warned
- def foo(h, key: 42); end; foo(key: 42) # warned
- def foo(h, **kw); end; foo({key: 42}) # OK
- def foo(h, key: 42); end; foo({key: 42}) # OK
-
- * When a method accepts specific keywords but not a keyword splat, and
- a hash or keywords splat is passed to the method that includes both
- Symbol and non-Symbol keys, the hash will continue to be split, and
- a warning will be emitted. You will need to update the calling code
- to pass separate hashes to ensure correct behavior in Ruby 3.
-
- def foo(h={}, key: 42); end; foo("key" => 43, key: 42) # warned
- def foo(h={}, key: 42); end; foo({"key" => 43, key: 42}) # warned
- def foo(h={}, key: 42); end; foo({"key" => 43}, key: 42) # OK
-
- * If a method does not accept keywords, and is called with keywords,
- the keywords are still treated as a positional hash, with no warning.
- This behavior will continue to work in Ruby 3.
-
- def foo(opt={}); end; foo( key: 42 ) # OK
-
-* Non-symbols are allowed as keyword argument keys if the method accepts
- arbitrary keywords. [Feature #14183]
-
- * Non-Symbol keys in a keyword arguments hash were prohibited in 2.6.0,
- but are now allowed again. [Bug #15658]
-
- def foo(**kw); p kw; end; foo("str" => 1) #=> {"str"=>1}
-
-* <code>**nil</code> is allowed in method definitions to explicitly mark
- that the method accepts no keywords. Calling such a method with keywords
- will result in an ArgumentError. [Feature #14183]
-
- def foo(h, **nil); end; foo(key: 1) # ArgumentError
- def foo(h, **nil); end; foo(**{key: 1}) # ArgumentError
- def foo(h, **nil); end; foo("str" => 1) # ArgumentError
- def foo(h, **nil); end; foo({key: 1}) # OK
- def foo(h, **nil); end; foo({"str" => 1}) # OK
-
-* Passing an empty keyword splat to a method that does not accept keywords
- no longer passes an empty hash, unless the empty hash is necessary for
- a required parameter, in which case a warning will be emitted. Remove
- the double splat to continue passing a positional hash. [Feature #14183]
-
- h = {}; def foo(*a) a end; foo(**h) # []
- h = {}; def foo(a) a end; foo(**h) # {} and warning
- h = {}; def foo(*a) a end; foo(h) # [{}]
- h = {}; def foo(a) a end; foo(h) # {}
-
-* Above warnings can be suppressed also with {-W:no-deprecated option}[#label-Warning+option].
-
-==== Numbered parameters
-
-* Numbered parameters as default block parameters are introduced.
- [Feature #4475]
-
- [1, 2, 10].map { _1.to_s(16) } #=> ["1", "2", "a"]
- [[1, 2], [3, 4]].map { _1 + _2 } #=> [3, 7]
-
- You can still define a local variable named +_1+ and so on,
- and that is honored when present, but renders a warning.
-
- _1 = 0 #=> warning: `_1' is reserved for numbered parameter; consider another name
- [1].each { p _1 } # prints 0 instead of 1
-
-==== proc/lambda without block is deprecated
-
-* Proc.new and Kernel#proc with no block in a method called with a block is
- warned now.
-
- def foo
- proc
- end
- foo { puts "Hello" } #=> warning: Capturing the given block using Kernel#proc is deprecated; use `&block` instead
-
- This warning can be suppressed with {-W:no-deprecated option}[#label-Warning+option].
-
-* Kernel#lambda with no block in a method called with a block raises an exception.
-
- def bar
- lambda
- end
- bar { puts "Hello" } #=> tried to create Proc object without a block (ArgumentError)
-
-==== Other miscellaneous changes
-
-* A beginless range is experimentally introduced. It might be useful
- in +case+, new call-sequence of the <code>Comparable#clamp</code>,
- constants and DSLs. [Feature #14799]
-
- ary[..3] # identical to ary[0..3]
-
- case RUBY_VERSION
- when ..."2.4" then puts "EOL"
- # ...
- end
-
- age.clamp(..100)
-
- where(sales: ..100)
-
-* Setting <code>$;</code> to a non-nil value is warned now. [Feature #14240]
- Use of it in String#split is warned too.
- This warning can be suppressed with {-W:no-deprecated option}[#label-Warning+option].
-
-* Setting <code>$,</code> to a non-nil value is warned now. [Feature #14240]
- Use of it in Array#join is warned too.
- This warning can be suppressed with {-W:no-deprecated option}[#label-Warning+option].
-
-* Quoted here-document identifiers must end within the same line.
-
- <<"EOS
- " # This had been warned since 2.4; Now it raises a SyntaxError
- EOS
-
-* The flip-flop syntax deprecation is reverted. [Feature #5400]
-
-* Comment lines can be placed between fluent dot now.
-
- foo
- # .bar
- .baz # => foo.baz
-
-* Calling a private method with a literal +self+ as the receiver
- is now allowed. [Feature #11297] [Feature #16123]
-
-* Modifier rescue now operates the same for multiple assignment as single
- assignment. [Bug #8279]
-
- a, b = raise rescue [1, 2]
- # Previously parsed as: (a, b = raise) rescue [1, 2]
- # Now parsed as: a, b = (raise rescue [1, 2])
-
-* +yield+ in singleton class syntax is warned and will be deprecated later. [Feature #15575].
-
- def foo
- class << Object.new
- yield #=> warning: `yield' in class syntax will not be supported from Ruby 3.0. [Feature #15575]
- end
- end
- foo { p :ok }
-
- This warning can be suppressed with {-W:no-deprecated option}[#label-Warning+option].
-
-* Argument forwarding by <code>(...)</code> is introduced. [Feature #16253]
-
- def foo(...)
- bar(...)
- end
-
- All arguments to +foo+ are forwarded to +bar+, including keyword and
- block arguments.
- Note that the parentheses are mandatory. <code>bar ...</code> is parsed
- as an endless range.
-
-* Access and setting of <code>$SAFE</code> is now always warned. <code>$SAFE</code>
- will become a normal global variable in Ruby 3.0. [Feature #16131]
-
-* <code>Object#{taint,untaint,trust,untrust}</code> and related functions in the C-API
- no longer have an effect (all objects are always considered untainted), and are now
- warned in verbose mode. This warning will be disabled even in non-verbose mode in
- Ruby 3.0, and the methods and C functions will be removed in Ruby 3.2. [Feature #16131]
-
-* Refinements take place at Object#method and Module#instance_method. [Feature #15373]
-
-=== Command line options
-
-==== Warning option
+=== Core classes updates (outstanding ones only)
-The +-W+ option has been extended with a following +:+, to manage categorized
-warnings. [Feature #16345] [Feature #16420]
+* Array
-* To suppress deprecation warnings:
+ * New methods:
- $ ruby -e '$; = ""'
- -e:1: warning: `$;' is deprecated
+ * Array#append [Feature #12746]
+ * Array#prepend [Feature #12746]
- $ ruby -W:no-deprecated -e '$; = //'
+* Data
-* It works with the +RUBYOPT+ environment variable:
+ * Is deprecated. It was a base class for C extensions, and it's not
+ necessary to expose in Ruby level. [Feature #3072]
- $ RUBYOPT=-W:no-deprecated ruby -e '$; = //'
+* Exception
-* To suppress experimental feature warnings:
+ * New methods:
- $ ruby -e '0 in a'
- -e:1: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!
+ * Exception#full_message to retrieve a String expression of an exception,
+ formatted in the same way in which Ruby prints out an uncaught exception.
+ [Feature #14141] [experimental]
- $ ruby -W:no-experimental -e '0 in a'
+* Dir
-* To suppress both by using +RUBYOPT+, set space separated values:
+ * Dir.glob provides new optional keyword argument, :base.
+ [Feature #13056]
+ * Dir.chdir (without block arg), Dir.open, Dir.new, Dir.mkdir, Dir.rmdir,
+ Dir.empty? releases GVL
- $ RUBYOPT='-W:no-deprecated -W:no-experimental' ruby -e '($; = "") in a'
+ * New methods:
-See also Warning in {Core classes updates}[#label-Core+classes+updates+-28outstanding+ones+only-29].
+ * Dir.children [Feature #11302]
+ * Dir.each_child [Feature #11302]
-=== Core classes updates (outstanding ones only)
+* Enumerable
-Array::
+ * Enumerable#{any?,all?,none?,one?} accept a pattern argument [Feature #11286]
- New methods::
+* File
- * Added Array#intersection. [Feature #16155]
+ * File.open accepts :newline option to imply text mode. [Bug #13350]
+ * File#path raises an IOError for files opened with
+ File::Constants::TMPFILE option. [Feature #13568]
+ * File.stat, File.exist?, and other rb_stat()-using methods release GVL
+ [Bug #13941]
+ * File.rename releases GVL [Feature #13951]
+ * File::Stat#{atime,mtime,ctime} support fractional second timestamps on
+ Windows 8 and later [Feature #13726]
+ * File::Stat#ino and File.indentical? support ReFS 128bit ino on Windows 8.1
+ and later [Feature #13731]
+ * File.readable?, File.readable_real?, File.writable?, File.writable_real?,
+ File.executable?, File.executable_real?, File.mkfifo, File.readlink,
+ File.truncate, File#truncate, File.chmod, File.lchmod, File.chown,
+ File.lchown, File.unlink, File.utime, File.lstat release GVL
- * Added Array#minmax, with a faster implementation than Enumerable#minmax. [Bug #15929]
+ * New method:
-Comparable::
+ * File.lutime [Feature #4052]
- Modified method::
+* Exception
- * Comparable#clamp now accepts a Range argument. [Feature #14784]
+ * Exception#full_message takes :highlight and :order options [Bug #14324]
- -1.clamp(0..2) #=> 0
- 1.clamp(0..2) #=> 1
- 3.clamp(0..2) #=> 2
- # With beginless and endless ranges:
- -1.clamp(0..) #=> 0
- 3.clamp(..2) #=> 2
+* Hash
+ * New methods:
-Complex::
+ * Hash#transform_keys [Feature #13583]
+ * Hash#transform_keys! [Feature #13583]
+ * Hash#slice [Feature #8499]
- New method::
+* IO
- * Added Complex#<=>.
- So <code>0 <=> 0i</code> will not raise NoMethodError. [Bug #15857]
+ * IO#copy_stream tries copy offload with copy_file_range(2) [Feature #13867]
-Dir::
+ * New methods:
- Modified methods::
+ * IO#pread [Feature #4532]
+ * IO#pwrite [Feature #4532]
+ * IO#write accepts multiple arguments [Feature #9323]
- * Dir.glob and Dir.[] no longer allow NUL-separated glob pattern.
- Use Array instead. [Feature #14643]
+* IOError
-Encoding::
+ * IO#close might raise an error with message "stream closed",
+ but it is refined to "stream closed in another thread". The new message
+ is more clear for user.
+ [Bug #13405]
- New encoding::
+* Integer
- * Added new encoding CESU-8. [Feature #15931]
+ * Integer#step no longer hides errors from coerce method when
+ given a step value which cannot be compared with #> to 0.
+ [Feature #7688]
+ * Integer#{round,floor,ceil,truncate} always return an Integer.
+ [Bug #13420]
+ * Integer#pow accepts modulo argument for calculating modular
+ exponentiation. [Feature #12508] [Feature #11003]
-Enumerable::
+ * New methods:
- New methods::
+ * Integer#allbits?, Integer#anybits?, Integer#nobits? [Feature #12753]
+ * Integer.sqrt [Feature #13219]
- * Added Enumerable#filter_map. [Feature #15323]
+* Kernel
- [1, 2, 3].filter_map {|x| x.odd? ? x.to_s : nil } #=> ["1", "3"]
+ * Kernel#yield_self [Feature #6721]
+ * Kernel#pp [Feature #14123]
+ * Kernel#warn(..., uplevel:n) [Feature #12882]
- * Added Enumerable#tally. [Feature #11076]
+* Method
- ["A", "B", "C", "B", "A"].tally #=> {"A"=>2, "B"=>2, "C"=>1}
+ * New methods:
-Enumerator::
+ * Method#=== that invokes Method#call, as same as Proc#=== [Feature #14142]
- New methods::
+* Module
- * Added Enumerator.produce to generate an Enumerator from any custom
- data transformation. [Feature #14781]
+ * Module#{attr,attr_accessor,attr_reader,attr_writer} become public [Feature #14132]
+ * Module#{define_method,alias_method,undef_method,remove_method} become public [Feature #14133]
- require "date"
- dates = Enumerator.produce(Date.today, &:succ) #=> infinite sequence of dates
- dates.detect(&:tuesday?) #=> next Tuesday
+* Numeric
- * Added Enumerator::Lazy#eager that generates a non-lazy enumerator
- from a lazy enumerator. [Feature #15901]
+ * Numerical comparison operators (<,<=,>=,>) no longer hide exceptions
+ from #coerce method internally. Return nil in #coerce if the coercion is
+ impossible. [Feature #7688]
- a = %w(foo bar baz)
- e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
- p e.class #=> Enumerator
- p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
+* Process
- * Added Enumerator::Yielder#to_proc so that a Yielder object
- can be directly passed to another method as a block
- argument. [Feature #15618]
+ * Precision of Process.times is improved if getrusage(2) exists. [Feature #11952]
-Fiber::
+ * New method:
- New method::
+ * Process.last_status as an alias of $? [Feature #14043]
- * Added Fiber#raise that behaves like Fiber#resume but raises an
- exception on the resumed fiber. [Feature #10344]
+* Range
+ * Range#initialize no longer hides exceptions when comparing begin and
+ end with #<=> and raise a "bad value for range" ArgumentError
+ but instead lets the exception from the #<=> call go through.
+ [Feature #7688]
-File::
+* Regexp
- Modified method::
+ * Update to Onigmo 6.1.3-669ac9997619954c298da971fcfacccf36909d05.
- * File.extname now returns a dot string for names ending with a dot on
- non-Windows platforms. [Bug #15267]
+ * Support absence operator https://github.com/k-takata/Onigmo/issues/82
- File.extname("foo.") #=> "."
+ * Support new 5 emoji-related Unicode character properties
-FrozenError::
+* RubyVM::InstructionSequence
- New method::
+ * New method:
- * Added FrozenError#receiver to return the frozen object on which
- modification was attempted. To set this object when raising
- FrozenError in Ruby code, FrozenError.new accepts a +:receiver+
- option. [Feature #15751]
+ * RubyVM::InstructionSequence#each_child
+ * RubyVM::InstructionSequence#trace_points
-GC::
+* String
- New method::
+ * String#-@ deduplicates unfrozen strings. Already-frozen
+ strings remain unchanged for compatibility. [Feature #13077]
+ * -"literal" (String#-@) optimized to return the same object
+ (same as "literal".freeze in Ruby 2.1+) [Feature #13295]
+ * String#{casecmp,casecmp?} return nil for non-string arguments
+ instead of raising a TypeError. [Bug #13312]
+ * String#start_with? accepts a regexp [Feature #13712]
- * Added GC.compact method for compacting the heap.
- This function compacts live objects in the heap so that fewer pages may
- be used, and the heap may be more CoW (copy-on-write) friendly. [Feature #15626]
+ * New methods:
- Details on the algorithm and caveats can be found here:
- https://bugs.ruby-lang.org/issues/15626
+ * String#delete_prefix, String#delete_prefix! [Feature #12694]
+ * String#delete_suffix, String#delete_suffix! [Feature #13665]
+ * String#each_grapheme_cluster and String#grapheme_clusters to
+ enumerate grapheme clusters [Feature #13780]
+ * String#undump to unescape String#dump'ed string [Feature #12275]
-IO::
+* Struct
- New method::
+ * Struct.new takes `keyword_init: true` option to initialize members
+ with keyword arguments. [Feature #11925]
- * Added IO#set_encoding_by_bom to check the BOM and set the external
- encoding. [Bug #15210]
+* Regexp/String: Update Unicode version from 9.0.0 to 10.0.0 [Feature #13685]
-Integer::
+* Thread
- Modified method::
+ * Description set by Thread#name= is now visible on Windows 10.
- * Integer#[] now supports range operations. [Feature #8842]
+ * New method:
+ * Thread#fetch [Feature #13009]
- 0b01001101[2, 4] #=> 0b0011
- 0b01001100[2..5] #=> 0b0011
- 0b01001100[2...6] #=> 0b0011
- # ^^^^
+ * The default of Thread.report_on_exception is now true,
+ showing unhandled exceptions terminating threads on $stderr.
+ [Feature #14143]
-Method::
+* Time
- Modified method::
+ * Time#at receives 3rd argument which specifies the unit of 2nd argument.
+ [Feature #13919]
- * Method#inspect shows more information. [Feature #14145]
+* KeyError
-Module::
+ * New methods:
- New methods::
+ * KeyError#receiver [Feature #12063]
+ * KeyError#key [Feature #12063]
- * Added Module#const_source_location to retrieve the location where a
- constant is defined. [Feature #10771]
+* FrozenError
- * Added Module#ruby2_keywords for marking a method as passing keyword
- arguments through a regular argument splat, useful when delegating
- all arguments to another method in a way that can be backwards
- compatible with older Ruby versions. [Bug #16154]
+ * New exception class. [Feature #13224]
- Modified methods::
+=== Stdlib updates (outstanding ones only)
- * Module#autoload? now takes an +inherit+ optional argument, like
- Module#const_defined?. [Feature #15777]
+* BigDecimal
- * Module#name now always returns a frozen String. The returned String is
- always the same for a given Module. This change is
- experimental. [Feature #16150]
+ * Update to BigDecimal 1.3.4
-NilClass / TrueClass / FalseClass::
+ * The following features are added:
- Modified methods::
+ * BigDecimal::VERSION
- * NilClass#to_s, TrueClass#to_s, and FalseClass#to_s now always return a
- frozen String. The returned String is always the same for each of these
- values. This change is experimental. [Feature #16150]
+ * The following features have been deprecated,
+ and are planned to be removed in the version 1.4.0:
-ObjectSpace::WeakMap::
+ * BigDecimal.new
- Modified method::
+ * BigDecimal.ver
- * ObjectSpace::WeakMap#[]= now accepts special objects as either key or
- values. [Feature #16035]
+ * BigDecimal#clone and #dup now do not make a new instance,
+ but returns the receiver itself.
-Proc::
+* Coverage
- New method::
+ * Support branch coverage and method coverage measurement. [Feature #13901]
+ Branch coverage tells you which branches are executed, and which not.
+ Method coverage tells you which methods are invoked, and which not.
+ By running a test suite with this new feature, you can know which branches
+ and methods are executed by a test, and evaluate total coverage of a test
+ suite more strictly.
- * Added Proc#ruby2_keywords for marking the proc as passing keyword
- arguments through a regular argument splat, useful when delegating
- all arguments to another method or proc in a way that can be backwards
- compatible with older Ruby versions. [Feature #16404]
+ You can specify the measuring target by an option to `Coverage.start`:
-Range::
+ Coverage.start(lines: true, branches: true, methods: true)
- New method::
+ After some Ruby files are loaded, you can use `Coverage.result` to get
+ the coverage result:
- * Added Range#minmax, with a faster implementation than Enumerable#minmax.
- It returns a maximum that now corresponds to Range#max. [Bug #15807]
+ Coverage.result
+ #=> { "/path/to/file.rb"=>
+ # { :lines => [1, 2, 0, nil, ...],
+ # :branches =>
+ # { [:if, 0, 2, 1, 6, 4] =>
+ # { [:then, 1, 3, 2, 3, 8] => 0,
+ # [:else, 2, 5, 2, 5, 8] => 2
+ # }
+ # },
+ # :methods => {
+ # [Object, :foo, 1, 0, 7, 3] => 2
+ # }
+ # }
+ # }
- Modified method::
+ The result type of line coverage is not changed; it is just an array that
+ contains numbers, which means the count that each line was executed,
+ or `nil`s, which means that the line is not relevant.
- * Range#=== now uses Range#cover? for String arguments, too (in Ruby 2.6, it was
- changed from Range#include? for all types except strings). [Bug #15449]
+ The result type of branch coverage is:
+ { (jump base) => { (jump target) => (counter) } }
-RubyVM::
+ where jump base and targets have the format
- Removed method::
+ [type, unique-id, start lineno, start column, end lineno, end column]
- * +RubyVM.resolve_feature_path+ moved to
- <code>$LOAD_PATH.resolve_feature_path</code>. [Feature #15903] [Feature #15230]
+ For example, `[:if, 0, 2, 1, 6, 4]` reads an `if` statement that ranges from
+ line 2 and column 1, to line 6 and column 4. `[:then, 1, 3, 2, 3, 8]` reads
+ a `then` clause that ranges from line 3 and column 2, to line 3 and column 8.
+ Note that lineno starts from 1, and that columnno starts from 0. So, the
+ above example shows a branch from the `if` to the `then` was never executed,
+ and a branch from the `if` to the `else` was executed twice.
-String::
+ The result type of method coverage is:
- Unicode::
+ { (method key) => (counter) }
- * Update Unicode version and Emoji version from 11.0.0 to
- 12.0.0. [Feature #15321]
+ where method key has the format
- * Update Unicode version to 12.1.0, adding support for
- U+32FF SQUARE ERA NAME REIWA. [Feature #15195]
+ [class, method-name, start lineno, start column, end lineno, end column]
- * Update Unicode Emoji version to 12.1. [Feature #16272]
+ For example, `[Object, :foo, 1, 0, 7, 3]` reads `Object#foo` that ranges from
+ line 1 and column 0, to line 7 and column 3. The above example shows this
+ `Object#foo` was invoked twice.
-Symbol::
+ Note: To keep compatibility, passing no option to `Coverage.start` will measure
+ only line coverage, and `Coverage.result` will return the old format:
- New methods::
+ Coverage.result
+ #=> { "/path/to/file.rb"=> [1, 2, 0, nil, ...] }
- * Added Symbol#start_with? and Symbol#end_with? methods. [Feature #16348]
+* DRb
-Time::
+ * ACL::ACLEntry.new no longer suppresses IPAddr::InvalidPrefixError.
- New methods::
+* ERB
- * Added Time#ceil method. [Feature #15772]
+ * Add ERB#result_with_hash to render a template with local variables passed
+ with a Hash object. [Feature #8631]
- * Added Time#floor method. [Feature #15653]
+ * Default template file encoding is changed from ASCII-8BIT to UTF-8 in erb
+ command. [Bug #14095]
- Modified method::
+ * Carriage returns are changed to be trimmed properly if trim_mode is specified
+ and used. Duplicated newlines will be removed on Windows. [Bug #5339] [Bug #11464]
- * Time#inspect is separated from Time#to_s and it shows
- the time's sub second. [Feature #15958]
+* IPAddr
-UnboundMethod::
+ * IPAddr no longer accepts invalid address mask. [Bug #13399]
+ * IPAddr#{ipv4_compat,ipv4_compat?} are marked for deprecation. [Bug #13769]
- New method::
+ * New methods:
- * Added UnboundMethod#bind_call method. [Feature #15955]
+ * IPAddr#prefix
+ * IPAddr#loopback?
+ * IPAddr#private? [Feature #11666]
+ * IPAddr#link_local? [Feature #10912]
- <code>umethod.bind_call(obj, ...)</code> is semantically equivalent
- to <code>umethod.bind(obj).call(...)</code>. This idiom is used in
- some libraries to call a method that is overridden. The added
- method does the same without allocation of an intermediate Method
- object.
- class Foo
- def add_1(x)
- x + 1
- end
- end
- class Bar < Foo
- def add_1(x) # override
- x + 2
- end
- end
+* IRB
- obj = Bar.new
- p obj.add_1(1) #=> 3
- p Foo.instance_method(:add_1).bind(obj).call(1) #=> 2
- p Foo.instance_method(:add_1).bind_call(obj, 1) #=> 2
+ * Print backtrace and error message in reverse order [Feature #8661] [experimental]
+ * `binding.irb` automatically requires irb and runs [Bug #13099] [experimental]
+ * `binding.irb` on its start shows source around the line where it was called
+ [Feature #14124]
-Warning::
+* Matrix
- New methods::
+ * New methods:
- * Added Warning.[] and Warning.[]= to manage emitting/suppressing
- some categories of warnings. [Feature #16345] [Feature #16420]
+ * Matrix.combine and Matrix#combine [Feature #10903]
+ * Matrix#{hadamard_product,entrywise_product}
-$LOAD_PATH::
+* Net::HTTP
- New method::
+ * Net::HTTP.new supports no_proxy parameter [Feature #11195]
+ * Net::HTTP#{min_version,max_version}, [Feature #9450]
+ * Add more HTTP status classes
+ * Net::HTTP::STATUS_CODES is added as HTTP Status Code Repository [Misc #12935]
+ * Net::HTTP#{proxy_user,proxy_pass} reflect http_proxy environment variable
+ if the system's environment variable is multiuser safe. [Bug #12921]
- * Added <code>$LOAD_PATH.resolve_feature_path</code>. [Feature #15903] [Feature #15230]
+* open-uri
+ * URI.open method defined as an alias to open-uri's Kernel.open.
+ open-uri's Kernel.open will be deprecated in future.
-=== Stdlib updates (outstanding ones only)
+* OpenSSL
-Bundler::
+ * Updated Ruby/OpenSSL from version 2.0 to 2.1. Changes are noted in
+ "Version 2.1.0" section in ext/openssl/History.md.
- * Upgrade to Bundler 2.1.2.
- See https://github.com/bundler/bundler/releases/tag/v2.1.2
+* Pathname
-CGI::
+ * New method:
- * CGI.escapeHTML becomes 2~5x faster when there is at least one escaped character.
- See https://github.com/ruby/ruby/pull/2226
+ * Pathname#glob [Feature #7360]
-CSV::
+* Psych
- * Upgrade to 3.1.2.
- See https://github.com/ruby/csv/blob/master/NEWS.md.
+ * Update to Psych 3.0.2.
-Date::
+ * Convert fallback option to a keyword argument
+ https://github.com/ruby/psych/pull/342
+ * Add :symbolize_names option to Psych.load, Psych.safe_load like JSON.parse
+ https://github.com/ruby/psych/pull/333, https://github.com/ruby/psych/pull/337
+ * Add Psych::Handler#event_location
+ https://github.com/ruby/psych/pull/326
+ * Make frozen string literal = true
+ https://github.com/ruby/psych/pull/320
+ * Preserve time zone offset when deserializing times
+ https://github.com/ruby/psych/pull/316
+ * Remove deprecated method aliases for syck gem
+ https://github.com/ruby/psych/pull/312
- * Date.jisx0301, Date#jisx0301, and Date.parse support the new Japanese
- era. [Feature #15742]
+* RbConfig
-Delegator::
+ * RbConfig::LIMITS is added to provide the limits of C types.
+ This is available when rbconfig/sizeof is loaded.
- * Object#DelegateClass accepts a block and module_evals it in the context
- of the returned class, similar to Class.new and Struct.new.
+* Ripper
-ERB::
+ * Ripper::EXPR_BEG and so on for Ripper#state.
- * Prohibit marshaling ERB instance.
+ * New method:
-IRB::
+ * Ripper#state to tell the state of scanner. [Feature #13686]
- * Introduce syntax highlighting inspired by the Pry gem to Binding#irb
- source lines, REPL input, and inspect output of some core-class objects.
+* RDoc
- * Introduce multiline editing mode provided by Reline.
+ * Update to RDoc 6.0.1.
- * Show documentation when completion.
+ * Replace IRB based lexer with Ripper.
+ * https://github.com/ruby/rdoc/pull/512
+ * This much improves the speed of generating documents.
+ * It also facilitates supporting new syntax in the future.
+ * Support many new syntaxes of Ruby from the past few years.
+ * Use "frozen_string_literal: true".
+ Performance survey: https://gist.github.com/aycabta/abdfaa75ea8a6877eeb734e942e73800
+ * Support did_you_mean.
- * Enable auto indent and save/load history by default.
+* Rubygems
-JSON::
+ * Update to Rubygems 2.7.3.
+ * http://blog.rubygems.org/2017/11/28/2.7.3-released.html
+ * http://blog.rubygems.org/2017/11/08/2.7.2-released.html
+ * http://blog.rubygems.org/2017/11/03/2.7.1-released.html
+ * http://blog.rubygems.org/2017/11/01/2.7.0-released.html
+ * http://blog.rubygems.org/2017/10/09/2.6.14-released.html
+ * http://blog.rubygems.org/2017/08/27/2.6.13-released.html
- * Upgrade to 2.3.0.
+* SecureRandom
-Net::FTP::
+ * New method:
- * Add Net::FTP#features to check available features, and Net::FTP#option to
- enable/disable each of them. [Feature #15964]
+ * SecureRandom.alphanumeric
-Net::HTTP::
+* Set
- * Add +ipaddr+ optional parameter to Net::HTTP#start to replace the address for
- the TCP/IP connection. [Feature #5180]
+ * New methods:
-Net::IMAP::
+ * Set#to_s as alias to #inspect [Feature #13676]
+ * Set#=== as alias to #include? [Feature #13801]
+ * Set#reset [Feature #6589]
- * Add Server Name Indication (SNI) support. [Feature #15594]
+* StringIO
-open-uri::
+ * StringIO#write accepts multiple arguments
- * Warn open-uri's "open" method at Kernel.
- Use URI.open instead. [Misc #15893]
+* StringScanner
- * The default charset of "text/*" media type is UTF-8 instead of
- ISO-8859-1. [Bug #15933]
+ * New methods:
-OptionParser::
+ * StringScanner#size, StringScanner#captures, StringScanner#values_at [Feature #836]
- * Now show "Did you mean?" for unknown options. [Feature #16256]
+* URI
- test.rb:
+ * Relative path operations no longer collapse consecutive slashes to a single slash. [Bug #8352]
- require "optparse"
- OptionParser.new do |opts|
- opts.on("-f", "--foo", "foo") {|v| }
- opts.on("-b", "--bar", "bar") {|v| }
- opts.on("-c", "--baz", "baz") {|v| }
- end.parse!
+* WEBrick
- example:
+ * Add Server Name Indication (SNI) support [Feature #13729]
+ * support Proc objects as body responses [Feature #855]
+ * released as a RubyGem [Feature #13173]
+ * avoid unintended behavior from Kernel#open [Misc #14216]
- $ ruby test.rb --baa
- Traceback (most recent call last):
- test.rb:7:in `<main>': invalid option: --baa (OptionParser::InvalidOption)
- Did you mean? baz
- bar
+* Zlib
-Pathname::
+ * Zlib::GzipWriter#write accepts multiple arguments
- * Pathname.glob now delegates 3 arguments to Dir.glob
- to accept +base+ keyword. [Feature #14405]
+=== Compatibility issues (excluding feature bug fixes)
-Racc::
+* Socket
- * Merge 1.4.15 from upstream repository and added cli of racc.
+ * BasicSocket#read_nonblock and BasicSocket#write_nonblock no
+ longer set the O_NONBLOCK file description flag as side effect
+ (on Linux only) [Feature #13362]
-Reline::
+* Random
- * New stdlib that is compatible with the readline stdlib but is
- implemented in pure Ruby. It also provides a multiline editing mode.
+ * Random.raw_seed renamed to become Random.urandom. It is now
+ applicable to non-seeding purposes due to [Bug #9569].
-REXML::
+* Socket
- * Upgrade to 3.2.3.
- See https://github.com/ruby/rexml/blob/master/NEWS.md.
+ * Socket::Ifaddr#vhid is added [Feature #13803]
-RSS::
+* ConditionVariable, Queue and SizedQueue reimplemented for speed.
+ They no longer subclass Struct. [Feature #13552]
- * Upgrade to RSS 0.2.8.
- See https://github.com/ruby/rss/blob/master/NEWS.md.
+=== Stdlib compatibility issues (excluding feature bug fixes)
-RubyGems::
+* Gemification
- * Upgrade to RubyGems 3.1.2.
- * https://github.com/rubygems/rubygems/releases/tag/v3.1.0
- * https://github.com/rubygems/rubygems/releases/tag/v3.1.1
- * https://github.com/rubygems/rubygems/releases/tag/v3.1.2
+ * Promote following standard libraries to default gems.
+ * cmath
+ * csv
+ * date
+ * dbm
+ * etc
+ * fcntl
+ * fiddle
+ * fileutils
+ * gdbm
+ * ipaddr
+ * scanf
+ * sdbm
+ * stringio
+ * strscan
+ * webrick
+ * zlib
-StringScanner::
+* Logger
- * Upgrade to 1.0.3.
- See https://github.com/ruby/strscan/blob/master/NEWS.md.
+ * Logger.new("| command") had been working to open a command
+ unintentionally. It was prohibited, and now Logger#initialize
+ treats a String argument only as a filename, as its specification.
+ [Bug #14212]
-=== Compatibility issues (excluding feature bug fixes)
+* Net::HTTP
-* The following libraries are no longer bundled gems.
- Install corresponding gems to use these features.
- * CMath (cmath gem)
- * Scanf (scanf gem)
- * Shell (shell gem)
- * Synchronizer (sync gem)
- * ThreadsWait (thwait gem)
- * E2MM (e2mmap gem)
+ * Net::HTTP#start now passes :ENV to p_addr by default. [Bug #13351]
+ To avoid this, pass nil explicitly.
-Proc::
- * The Proc#to_s format was changed. [Feature #16101]
+* mathn.rb
-Range::
- * Range#minmax used to iterate on the range to determine the maximum.
- It now uses the same algorithm as Range#max. In rare cases (e.g.
- ranges of Floats or Strings), this may yield different results. [Bug #15807]
+ * Removed from stdlib. [Feature #10169]
-=== Stdlib compatibility issues (excluding feature bug fixes)
+* Rubygems
-* Promote stdlib to default gems
- * The following default gems were published on rubygems.org
- * benchmark
- * cgi
- * delegate
- * getoptlong
- * net-pop
- * net-smtp
- * open3
- * pstore
- * readline
- * readline-ext
- * singleton
- * The following default gems were only promoted at ruby-core,
- but not yet published on rubygems.org.
- * monitor
- * observer
- * timeout
- * tracer
- * uri
- * yaml
-* The <tt>did_you_mean</tt> gem has been promoted up to a default gem from a bundled gem
-
-pathname::
-
- * Kernel#Pathname when called with a Pathname argument now returns
- the argument instead of creating a new Pathname. This is more
- similar to other Kernel methods, but can break code that modifies
- the return value and expects the argument not to be modified.
-
-profile.rb, Profiler__::
-
- * Removed from standard library. It was unmaintained since Ruby 2.0.0.
+ * Removed "ubygems.rb" file from stdlib. It's needless since Ruby 1.9.
=== C API updates
-* Many <code>*_kw</code> functions have been added for setting whether
- the final argument being passed should be treated as keywords. You
- may need to switch to these functions to avoid keyword argument
- separation warnings, and to ensure correct behavior in Ruby 3.
+=== Supported platform changes
-* The <code>:</code> character in rb_scan_args format string is now
- treated as keyword arguments. Passing a positional hash instead of
- keyword arguments will emit a deprecation warning.
+* Drop support of NaCl platform
-* C API declarations with +ANYARGS+ are changed not to use +ANYARGS+.
- See https://github.com/ruby/ruby/pull/2404
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160
=== Implementation improvements
-Fiber::
-
- * Allow selecting different coroutine implementations by using
- +--with-coroutine=+, e.g.
-
- $ ./configure --with-coroutine=ucontext
- $ ./configure --with-coroutine=copy
-
- * Replace previous stack cache with fiber pool cache. The fiber pool
- allocates many stacks in a single memory region. Stack allocation
- becomes O(log N) and fiber creation is amortized O(1). Around 10x
- performance improvement was measured in micro-benchmarks.
- https://github.com/ruby/ruby/pull/2224
-
-File::
- * File.realpath now uses realpath(3) on many platforms, which can
- significantly improve performance. [Feature #15797]
-
-Hash::
- * Change data structure of small Hash objects. [Feature #15602]
-
-Monitor::
- * Monitor class is written in C-extension. [Feature #16255]
-
-Thread::
+* (This might not be a "user visible feature change" but) Hash class's
+ hash function is now SipHash13. [Feature #13017]
- * VM stack memory allocation is now combined with native thread stack,
- improving thread allocation performance and reducing allocation related
- failures. Around 10x performance improvement was measured in micro-benchmarks.
+* SecureRandom now prefers OS-provided sources than OpenSSL. [Bug #9569]
-JIT::
+* Mutex rewritten to be smaller and faster [Feature #13517]
- * JIT-ed code is recompiled to less-optimized code when an optimization assumption is invalidated.
+* Performance of block passing using block parameters is improved by
+ lazy Proc allocation [Feature #14045]
- * Method inlining is performed when a method is considered as pure.
- This optimization is still experimental and many methods are NOT considered as pure yet.
+* Dynamic instrumentation for TracePoint hooks instead of using "trace"
+ instruction to avoid overhead [Feature #14104]
- * The default value of +--jit-max-cache+ is changed from 1,000 to 100.
-
- * The default value of +--jit-min-calls+ is changed from 5 to 10,000.
-
-RubyVM::
-
- * Per-call-site method cache, which has been there since around 1.9, was
- improved: cache hit rate raised from 89% to 94%.
- See https://github.com/ruby/ruby/pull/2583
-
-RubyVM::InstructionSequence::
-
- * RubyVM::InstructionSequence#to_binary method generates compiled binary.
- The binary size is reduced. [Feature #16163]
+* ERB now generates code from a template which runs 2 times faster than Ruby 2.4
=== Miscellaneous changes
-* Support for IA64 architecture has been removed. Hardware for testing was
- difficult to find, native fiber code is difficult to implement, and it added
- non-trivial complexity to the interpreter. [Feature #15894]
-
-* Require compilers to support C99. [Misc #15347]
-
- * Details of our dialect: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99
-
-* Ruby's upstream repository is changed from Subversion to Git.
-
- * https://git.ruby-lang.org/ruby.git
-
- * RUBY_REVISION class is changed from Integer to String.
+* Print backtrace and error message in reverse order if STDERR is unchanged and a tty.
+ [Feature #8661] [experimental]
- * RUBY_DESCRIPTION includes Git revision instead of Subversion's one.
+* Print error message in bold/underlined text if STDERR is unchanged and a tty.
+ [Feature #14140] [experimental]
-* Support built-in methods in Ruby with the <code>_\_builtin_</code> syntax. [Feature #16254]
+* configure option --with-ext now mandates its arguments. So for
+ instance if you run ./configure --with-ext=openssl,+ then the
+ openssl library is guaranteed compiled, otherwise the build fails
+ abnormally.
- Some methods are defined in *.rb (such as trace_point.rb).
- For example, it is easy to define a method which accepts keyword arguments.
+ Note however to always add the ",+" at the end of the argument.
+ Otherwise nothing but openssl are built. [Feature #13302]
diff --git a/README.ja.md b/README.ja.md
index 4e1e6b9d87..2902216f99 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -1,11 +1,3 @@
-[![Build Status](https://travis-ci.org/ruby/ruby.svg?branch=master)](https://travis-ci.org/ruby/ruby)
-[![Build status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
-![](https://github.com/ruby/ruby/workflows/Cygwin/badge.svg)
-![](https://github.com/ruby/ruby/workflows/macOS/badge.svg)
-![](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)
-![](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)
-![](https://github.com/ruby/ruby/workflows/Windows/badge.svg)
-
# Rubyã¨ã¯
Rubyã¯ã‚·ãƒ³ãƒ—ルã‹ã¤å¼·åŠ›ãªã‚ªãƒ–ジェクト指å‘スクリプト言語ã§ã™ï¼Ž Rubyã¯ç´”粋ãªã‚ªãƒ–ジェクト指å‘言語ã¨ã—ã¦è¨­è¨ˆã•れã¦ã„ã‚‹ã®ã§ï¼Œ
@@ -18,48 +10,40 @@ Rubyã¯ãƒ†ã‚­ã‚¹ãƒˆå‡¦ç†é–¢ä¿‚ã®èƒ½åŠ›ãªã©ã«å„ªã‚Œï¼ŒPerlã¨åŒã˜ãらã„
* ã‚·ãƒ³ãƒ—ãƒ«ãªæ–‡æ³•
* 普通ã®ã‚ªãƒ–ã‚¸ã‚§ã‚¯ãƒˆæŒ‡å‘æ©Ÿèƒ½(クラス,メソッドコールãªã©)
-* 特殊ãªã‚ªãƒ–ã‚¸ã‚§ã‚¯ãƒˆæŒ‡å‘æ©Ÿèƒ½(Mixin,特異メソッドãªã©)
+* 特殊ãªã‚ªãƒ–ã‚¸ã‚§ã‚¯ãƒˆæŒ‡å‘æ©Ÿèƒ½(Mixin, 特異メソッドãªã©)
* 演算å­ã‚ªãƒ¼ãƒãƒ¼ãƒ­ãƒ¼ãƒ‰
* ä¾‹å¤–å‡¦ç†æ©Ÿèƒ½
* イテレータã¨ã‚¯ãƒ­ãƒ¼ã‚¸ãƒ£
* ガーベージコレクタ
* ダイナミックローディング (アーキテクãƒãƒ£ã«ã‚ˆã‚‹)
-* ç§»æ¤æ€§ãŒé«˜ã„.多ãã®Unix-like/POSIX互æ›ãƒ—ラットフォーム上ã§å‹•ãã ã‘ã§ãªã,Windows, macOS,
- Haikuãªã©ã®ä¸Šã§ã‚‚å‹•ã cf.
- https://github.com/ruby/ruby/blob/master/doc/contributing.rdoc#platform-maintainers
+* ç§»æ¤æ€§ãŒé«˜ã„.多ãã®Unix-like/POSIX互æ›ãƒ—ラットフォーム上ã§å‹•ãã ã‘ã§ãªã,Windows, Mac OS
+ X,Haikuãªã©ã®ä¸Šã§ã‚‚å‹•ã cf.
+ https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/SupportedPlatformsJa
## 入手法
-サードパーティーツールを使ã£ãŸæ–¹æ³•ã‚’å«ã‚€Rubyã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«æ–¹æ³•ã®ä¸€è¦§ã¯
-
-https://www.ruby-lang.org/ja/downloads/
-
-ã‚’å‚ç…§ã—ã¦ãã ã•ã„.
-
-### Git
-
-ミラーをGitHubã«å…¬é–‹ã—ã¦ã„ã¾ã™ï¼Ž 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã§ãƒªãƒã‚¸ãƒˆãƒªã‚’å–å¾—ã§ãã¾ã™ï¼Ž
+### FTPã§
- $ git clone https://github.com/ruby/ruby.git
+以下ã®å ´æ‰€ã«ãŠã„ã¦ã‚りã¾ã™ï¼Ž
-ä»–ã®ãƒ–ランãƒã®ä¸€è¦§ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§è¦‹ã‚‰ã‚Œã¾ã™ï¼Ž
+ftp://ftp.ruby-lang.org/pub/ruby/
- $ git ls-remote https://github.com/ruby/ruby.git
+### Subversionã§
-Rubyリãƒã‚¸ãƒˆãƒªã®æœ¬æ¥ã®master㯠https://git.ruby-lang.org/ruby.git ã«ã‚りã¾ã™ï¼Ž
-コミッタã¯ã“ã¡ã‚‰ã‚’使ã„ã¾ã™ï¼Ž
+開発先端ã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§å–å¾—ã§ãã¾ã™ï¼Ž
-### Subversion
-
-å¤ã„Rubyã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§å–å¾—ã§ãã¾ã™ï¼Ž
-
- $ svn co https://svn.ruby-lang.org/repos/ruby/branches/ruby_2_6/ ruby
+ $ svn co https://svn.ruby-lang.org/repos/ruby/trunk/ ruby
ä»–ã«é–‹ç™ºä¸­ã®ãƒ–ランãƒã®ä¸€è¦§ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§è¦‹ã‚‰ã‚Œã¾ã™ï¼Ž
$ svn ls https://svn.ruby-lang.org/repos/ruby/branches/
+### Gitã§
+
+Subversionã®ãƒŸãƒ©ãƒ¼ã‚’GitHubã«å…¬é–‹ã—ã¦ã„ã¾ã™ï¼Ž 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã§ãƒªãƒã‚¸ãƒˆãƒªã‚’å–å¾—ã§ãã¾ã™ï¼Ž
+
+ $ git clone git://github.com/ruby/ruby.git
## ホームページ
@@ -111,8 +95,7 @@ Ruby拡張モジュールã«ã¤ã„ã¦è©±ã—åˆã†ruby-extメーリングリスãƒ
`ext/Setup` ã«è¨˜è¿°ã—ãŸãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã¯é™çš„ã«ãƒªãƒ³ã‚¯ã•れã¾ã™ï¼Ž
ダイナミックローディングをサãƒãƒ¼ãƒˆã—ã¦ã„ãªã„アーキテクãƒãƒ£ã§ã¯ `Setup` ã®1行目ã®ã€Œ`option nodynamic`ã€ã¨ã„ã†è¡Œã®ã‚³
- メントを外ã™å¿…è¦ãŒã‚りã¾ã™ï¼Ž
- ã¾ãŸï¼Œã“ã®ã‚¢ãƒ¼ã‚­ãƒ†ã‚¯ãƒãƒ£ã§æ‹¡å¼µãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã‚’利用ã™ã‚‹ãŸã‚ã«ã¯ï¼Œã‚らã‹ã˜ã‚é™çš„ã«ãƒªãƒ³ã‚¯ã‚’ã—ã¦ãŠãå¿…è¦ãŒã‚りã¾ã™ï¼Ž
+ メントを外ã™å¿…è¦ãŒã‚りã¾ã™ï¼Žã¾ãŸï¼Œã“ã®ã‚¢ãƒ¼ã‚­ãƒ†ã‚¯ãƒãƒ£ã§æ‹¡å¼µãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã‚’利用ã™ã‚‹ãŸã‚ã«ã¯ï¼Œã‚らã‹ã˜ã‚é™çš„ã«ãƒªãƒ³ã‚¯ã‚’ã—ã¦ãŠãå¿…è¦ãŒã‚りã¾ã™ï¼Ž
5. `make` を実行ã—ã¦ã‚³ãƒ³ãƒ‘イルã™ã‚‹
@@ -183,3 +166,6 @@ stackoverflow (https://ja.stackoverflow.com/) ãªã©ã®Webã‚µã‚¤ãƒˆã«æŠ•ç¨¿ã—ã
Rubyã®ã‚ªãƒªã‚¸ãƒŠãƒ«ç‰ˆã¯ï¼Œ1995å¹´ã«ã¾ã¤ã‚‚ã¨ã‚†ãã²ã‚æ°ã«ã‚ˆã£ã¦è¨­è¨ˆãƒ»é–‹ç™ºã•れã¾ã—ãŸï¼Ž
<mailto:matz@ruby-lang.org>
+
+---
+created at: Thu Aug 3 11:57:36 JST 1995
diff --git a/README.md b/README.md
index 1e935095c6..7a24329fe8 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,12 @@
-[![Build Status](https://travis-ci.org/ruby/ruby.svg?branch=master)](https://travis-ci.org/ruby/ruby)
-[![Build status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
-![](https://github.com/ruby/ruby/workflows/Cygwin/badge.svg)
-![](https://github.com/ruby/ruby/workflows/macOS/badge.svg)
-![](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)
-![](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)
-![](https://github.com/ruby/ruby/workflows/Windows/badge.svg)
+[![Build Status](https://travis-ci.org/ruby/ruby.svg)](https://travis-ci.org/ruby/ruby)
+[![Build status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/trunk?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/trunk)
# What's Ruby
-Ruby is an interpreted object-oriented programming language often
-used for web development. It also offers many scripting features
-to process plain text and serialized files, or manage system tasks.
-It is simple, straightforward, and extensible.
+Ruby is the interpreted scripting language for quick and easy object-oriented
+programming. It has many features to process text files and to do system
+management tasks (as in Perl). It is simple, straight-forward, and
+extensible.
## Features of Ruby
@@ -25,7 +20,7 @@ It is simple, straightforward, and extensible.
* Dynamic Loading of Object Files (on some architectures)
* Highly Portable (works on many Unix-like/POSIX compatible platforms as
well as Windows, macOS, Haiku, etc.) cf.
- https://github.com/ruby/ruby/blob/master/doc/contributing.rdoc#platform-maintainers
+ https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/SupportedPlatforms
## How to get Ruby
@@ -35,47 +30,48 @@ like rvm, see:
https://www.ruby-lang.org/en/downloads/
-### Git
+The Ruby distribution files can be found on the following FTP site:
-The mirror of the Ruby source tree can be checked out with the following command:
+ftp://ftp.ruby-lang.org/pub/ruby/
- $ git clone https://github.com/ruby/ruby.git
-
-There are some other branches under development. Try the following command
-to see the list of branches:
+The trunk of the Ruby source tree can be checked out with the following
+command:
- $ git ls-remote https://github.com/ruby/ruby.git
+ $ svn co https://svn.ruby-lang.org/repos/ruby/trunk/ ruby
-You may also want to use https://git.ruby-lang.org/ruby.git (actual master of Ruby source)
-if you are a committer.
+Or if you are using git then use the following command:
-### Subversion
-
-Stable branches for older Ruby versions can be checked out with the following command:
-
- $ svn co https://svn.ruby-lang.org/repos/ruby/branches/ruby_2_6/ ruby
+ $ git clone https://github.com/ruby/ruby.git
-Try the following command to see the list of branches:
+There are some other branches under development. Try the following command
+to see the list of branches:
$ svn ls https://svn.ruby-lang.org/repos/ruby/branches/
+Or if you are using git then use the following command:
+
+ $ git ls-remote git://github.com/ruby/ruby.git
## Ruby home page
+The URL of the Ruby home page is:
+
https://www.ruby-lang.org/
## Mailing list
-There is a mailing list to discuss Ruby. To subscribe to this list, please
+There is a mailing list to talk about Ruby. To subscribe to this list, please
send the following phrase:
subscribe
in the mail body (not subject) to the address
-[ruby-talk-request@ruby-lang.org](mailto:ruby-talk-request@ruby-lang.org?subject=Join%20Ruby%20Mailing%20List&body=subscribe).
+<mailto:ruby-talk-request@ruby-lang.org>.
## How to compile and install
+This is what you need to do to compile and install Ruby:
+
1. If you want to use Microsoft Visual C++ to compile Ruby, read
[win32/README.win32](win32/README.win32) instead of this document.
@@ -144,6 +140,7 @@ in the mail body (not subject) to the address
You may have to be a super user to install Ruby.
+
If you fail to compile Ruby, please send the detailed error report with the
error log and machine/OS type, to help others.
@@ -161,7 +158,7 @@ Questions about the Ruby language can be asked on the Ruby-Talk mailing list
(https://www.ruby-lang.org/en/community/mailing-lists) or on websites like
(https://stackoverflow.com).
-Bugs should be reported at https://bugs.ruby-lang.org. Read [HowToReport] for more information.
+Bug reports should be filed at https://bugs.ruby-lang.org. Read [HowToReport] for more information.
[HowToReport]: https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReport
@@ -169,8 +166,10 @@ Bugs should be reported at https://bugs.ruby-lang.org. Read [HowToReport] for mo
See the file [CONTRIBUTING.md](CONTRIBUTING.md)
+
## The Author
-Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in 1995.
+Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in
+1995.
-<matz@ruby-lang.org>
+<mailto:matz@ruby-lang.org>
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000000..99b24e6d93
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,46 @@
+# -*- autoconf -*-
+
+AC_DEFUN([_COLORIZE_RESULT_PREPARE], [
+ msg_checking= msg_result_yes= msg_result_no= msg_result_other= msg_reset=
+ AS_IF([test "x${CONFIGURE_TTY}" = xyes -o -t 1], [
+ msg_begin="`tput smso 2>/dev/null`"
+ AS_CASE(["$msg_begin"], ['@<:@'*m],
+ [msg_begin="`echo "$msg_begin" | sed ['s/[0-9]*m$//']`"
+ msg_checking="${msg_begin}33m"
+ AS_IF([test ${TEST_COLORS:+set}], [
+ msg_result_yes=[`expr ":$TEST_COLORS:" : ".*:pass=\([^:]*\):"`]
+ msg_result_no=[`expr ":$TEST_COLORS:" : ".*:fail=\([^:]*\):"`]
+ msg_result_other=[`expr ":$TEST_COLORS:" : ".*:skip=\([^:]*\):"`]
+ ])
+ msg_result_yes="${msg_begin}${msg_result_yes:-32;1}m"
+ msg_result_no="${msg_begin}${msg_result_no:-31;1}m"
+ msg_result_other="${msg_begin}${msg_result_other:-33;1}m"
+ msg_reset="${msg_begin}m"
+ ])
+ AS_UNSET(msg_begin)
+ ])
+ AS_REQUIRE_SHELL_FN([colorize_result],
+ [AS_FUNCTION_DESCRIBE([colorize_result], [MSG], [Colorize result])],
+ [AS_CASE(["$[]1"],
+ [yes], [AS_ECHO(["${msg_result_yes}$[]1${msg_reset}]")],
+ [no], [AS_ECHO(["${msg_result_no}$[]1${msg_reset}]")],
+ [AS_ECHO(["${msg_result_other}$[]1${msg_reset}]")])])
+])
+
+AC_DEFUN([COLORIZE_RESULT], [AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl
+ AS_LITERAL_IF([$1],
+ [m4_case([$1],
+ [yes], [AS_ECHO(["${msg_result_yes}$1${msg_reset}"])],
+ [no], [AS_ECHO(["${msg_result_no}$1${msg_reset}"])],
+ [AS_ECHO(["${msg_result_other}$1${msg_reset}"])])],
+ [colorize_result "$1"]) dnl
+])
+
+AC_DEFUN([AC_CHECKING],[dnl
+AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl
+AS_MESSAGE([checking ${msg_checking}$1${msg_reset}...])])
+
+AC_DEFUN([AC_MSG_RESULT], [dnl
+{ _AS_ECHO_LOG([result: $1])
+COLORIZE_RESULT([$1]); dnl
+}])
diff --git a/aclocal.m4 b/aclocal.m4
index ed7d14ef63..18ba297b05 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.16.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -12,36 +12,4 @@
# PARTICULAR PURPOSE.
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
-m4_include([tool/m4/_colorize_result_prepare.m4])
-m4_include([tool/m4/ac_msg_result.m4])
-m4_include([tool/m4/colorize_result.m4])
-m4_include([tool/m4/ruby_append_option.m4])
-m4_include([tool/m4/ruby_append_options.m4])
-m4_include([tool/m4/ruby_check_builtin_func.m4])
-m4_include([tool/m4/ruby_check_builtin_setjmp.m4])
-m4_include([tool/m4/ruby_check_printf_prefix.m4])
-m4_include([tool/m4/ruby_check_setjmp.m4])
-m4_include([tool/m4/ruby_check_signedness.m4])
-m4_include([tool/m4/ruby_check_sizeof.m4])
-m4_include([tool/m4/ruby_check_sysconf.m4])
-m4_include([tool/m4/ruby_cppoutfile.m4])
-m4_include([tool/m4/ruby_decl_attribute.m4])
-m4_include([tool/m4/ruby_default_arch.m4])
-m4_include([tool/m4/ruby_define_if.m4])
-m4_include([tool/m4/ruby_defint.m4])
-m4_include([tool/m4/ruby_dtrace_available.m4])
-m4_include([tool/m4/ruby_dtrace_postprocess.m4])
-m4_include([tool/m4/ruby_func_attribute.m4])
-m4_include([tool/m4/ruby_mingw32.m4])
-m4_include([tool/m4/ruby_prepend_option.m4])
-m4_include([tool/m4/ruby_prog_gnu_ld.m4])
-m4_include([tool/m4/ruby_replace_funcs.m4])
-m4_include([tool/m4/ruby_replace_type.m4])
-m4_include([tool/m4/ruby_rm_recursive.m4])
-m4_include([tool/m4/ruby_setjmp_type.m4])
-m4_include([tool/m4/ruby_stack_grow_direction.m4])
-m4_include([tool/m4/ruby_try_cflags.m4])
-m4_include([tool/m4/ruby_try_ldflags.m4])
-m4_include([tool/m4/ruby_type_attribute.m4])
-m4_include([tool/m4/ruby_universal_arch.m4])
-m4_include([tool/m4/ruby_werror_flag.m4])
+m4_include([acinclude.m4])
diff --git a/addr2line.c b/addr2line.c
index 283382f51d..09fcc3c225 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -8,30 +8,20 @@
**********************************************************************/
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wgnu-empty-initializer"
-#pragma clang diagnostic ignored "-Wgcc-compat"
-#endif
-
#include "ruby/config.h"
-#include "ruby/defines.h"
#include "ruby/missing.h"
#include "addr2line.h"
#include <stdio.h>
#include <errno.h>
-#ifdef HAVE_LIBPROC_H
-#include <libproc.h>
-#endif
-
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else
#include "missing/stdbool.h"
#endif
-#if defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H)
+#ifdef USE_ELF
#include <fcntl.h>
#include <limits.h>
@@ -44,6 +34,12 @@
#include <sys/stat.h>
#include <unistd.h>
+#ifdef __OpenBSD__
+#include <elf_abi.h>
+#else
+#include <elf.h>
+#endif
+
/* Make alloca work the best possible way. */
#ifdef __GNUC__
# ifndef alloca
@@ -67,20 +63,24 @@ void *alloca();
# include <dlfcn.h>
#endif
-#ifdef HAVE_MACH_O_LOADER_H
-# include <crt_externs.h>
-# include <mach-o/fat.h>
-# include <mach-o/loader.h>
-# include <mach-o/nlist.h>
-# include <mach-o/stab.h>
-#endif
+#define DW_LNS_copy 0x01
+#define DW_LNS_advance_pc 0x02
+#define DW_LNS_advance_line 0x03
+#define DW_LNS_set_file 0x04
+#define DW_LNS_set_column 0x05
+#define DW_LNS_negate_stmt 0x06
+#define DW_LNS_set_basic_block 0x07
+#define DW_LNS_const_add_pc 0x08
+#define DW_LNS_fixed_advance_pc 0x09
+#define DW_LNS_set_prologue_end 0x0a /* DWARF3 */
+#define DW_LNS_set_epilogue_begin 0x0b /* DWARF3 */
+#define DW_LNS_set_isa 0x0c /* DWARF3 */
-#ifdef USE_ELF
-# ifdef __OpenBSD__
-# include <elf_abi.h>
-# else
-# include <elf.h>
-# endif
+/* Line number extended opcode name. */
+#define DW_LNE_end_sequence 0x01
+#define DW_LNE_set_address 0x02
+#define DW_LNE_define_file 0x03
+#define DW_LNE_set_discriminator 0x04 /* DWARF4 */
#ifndef ElfW
# if SIZEOF_VOIDP == 8
@@ -96,44 +96,17 @@ void *alloca();
# define ELF_ST_TYPE ELF32_ST_TYPE
# endif
#endif
-#endif
-
-#ifdef SHF_COMPRESSED
-# if defined(ELFCOMPRESS_ZLIB) && defined(HAVE_LIBZ)
- /* FreeBSD 11.0 lacks ELFCOMPRESS_ZLIB */
-# include <zlib.h>
-# define SUPPORT_COMPRESSED_DEBUG_LINE
-# endif
-#else /* compatibility with glibc < 2.22 */
-# define SHF_COMPRESSED 0
-#endif
-
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
-#define DW_LNS_copy 0x01
-#define DW_LNS_advance_pc 0x02
-#define DW_LNS_advance_line 0x03
-#define DW_LNS_set_file 0x04
-#define DW_LNS_set_column 0x05
-#define DW_LNS_negate_stmt 0x06
-#define DW_LNS_set_basic_block 0x07
-#define DW_LNS_const_add_pc 0x08
-#define DW_LNS_fixed_advance_pc 0x09
-#define DW_LNS_set_prologue_end 0x0a /* DWARF3 */
-#define DW_LNS_set_epilogue_begin 0x0b /* DWARF3 */
-#define DW_LNS_set_isa 0x0c /* DWARF3 */
-
-/* Line number extended opcode name. */
-#define DW_LNE_end_sequence 0x01
-#define DW_LNE_set_address 0x02
-#define DW_LNE_define_file 0x03
-#define DW_LNE_set_discriminator 0x04 /* DWARF4 */
+#ifndef SHF_COMPRESSED /* compatibility with glibc < 2.22 */
+#define SHF_COMPRESSED 0
+#endif
-PRINTF_ARGS(static int kprintf(const char *fmt, ...), 1, 2);
+int kprintf(const char *fmt, ...);
-typedef struct line_info {
+typedef struct {
const char *dirname;
const char *filename;
const char *path; /* object path */
@@ -142,56 +115,19 @@ typedef struct line_info {
uintptr_t base_addr;
uintptr_t saddr;
const char *sname; /* function name */
-
- struct line_info *next;
} line_info_t;
-
-struct dwarf_section {
- char *ptr;
- size_t size;
- uint64_t flags;
-};
-
-typedef struct obj_info {
+typedef struct obj_info obj_info_t;
+struct obj_info {
const char *path; /* object path */
- char *mapped;
+ int fd;
+ void *mapped;
size_t mapped_size;
- void *uncompressed;
uintptr_t base_addr;
- uintptr_t vmaddr;
- struct dwarf_section debug_abbrev;
- struct dwarf_section debug_info;
- struct dwarf_section debug_line;
- struct dwarf_section debug_ranges;
- struct dwarf_section debug_str;
- struct obj_info *next;
-} obj_info_t;
-
-#define DWARF_SECTION_COUNT 5
-
-static struct dwarf_section *
-obj_dwarf_section_at(obj_info_t *obj, int n)
-{
- struct dwarf_section *ary[] = {
- &obj->debug_abbrev,
- &obj->debug_info,
- &obj->debug_line,
- &obj->debug_ranges,
- &obj->debug_str
- };
- if (n < 0 || DWARF_SECTION_COUNT <= n) {
- abort();
- }
- return ary[n];
-}
-
-struct debug_section_definition {
- const char *name;
- struct dwarf_section *dwarf;
+ obj_info_t *next;
};
/* Avoid consuming stack as this module may be used from signal handler */
-static char binary_filename[PATH_MAX + 1];
+static char binary_filename[PATH_MAX];
static unsigned long
uleb128(char **p)
@@ -251,7 +187,8 @@ get_nth_dirname(unsigned long dir, char *p)
}
static void
-fill_filename(int file, char *include_directories, char *filenames, line_info_t *line, obj_info_t *obj)
+fill_filename(int file, char *include_directories, char *filenames,
+ line_info_t *line)
{
int i;
char *p = filenames;
@@ -261,8 +198,8 @@ fill_filename(int file, char *include_directories, char *filenames, line_info_t
filename = p;
if (!*p) {
/* Need to output binary file name? */
- kprintf("Unexpected file number %d in %s at %tx\n",
- file, binary_filename, filenames - obj->mapped);
+ kprintf("Unexpected file number %d in %s\n",
+ file, binary_filename);
return;
}
while (*p) p++;
@@ -286,128 +223,104 @@ fill_line(int num_traces, void **traces, uintptr_t addr, int file, int line,
obj_info_t *obj, line_info_t *lines, int offset)
{
int i;
- addr += obj->base_addr - obj->vmaddr;
+ addr += obj->base_addr;
for (i = offset; i < num_traces; i++) {
uintptr_t a = (uintptr_t)traces[i];
/* We assume one line code doesn't result >100 bytes of native code.
We may want more reliable way eventually... */
if (addr < a && a < addr + 100) {
- fill_filename(file, include_directories, filenames, &lines[i], obj);
+ fill_filename(file, include_directories, filenames, &lines[i]);
lines[i].line = line;
}
}
}
-struct LineNumberProgramHeader {
- uint64_t unit_length;
- uint16_t version;
- uint8_t format; /* 4 or 8 */
- uint64_t header_length;
- uint8_t minimum_instruction_length;
- uint8_t maximum_operations_per_instruction;
- uint8_t default_is_stmt;
- int8_t line_base;
- uint8_t line_range;
- uint8_t opcode_base;
- /* uint8_t standard_opcode_lengths[opcode_base-1]; */
- const char *include_directories;
- const char *filenames;
- const char *cu_start;
- const char *cu_end;
-};
-
static int
-parse_debug_line_header(const char **pp, struct LineNumberProgramHeader *header)
+parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
+ obj_info_t *obj, line_info_t *lines, int offset)
{
- const char *p = *pp;
- header->unit_length = *(uint32_t *)p;
- p += sizeof(uint32_t);
-
- header->format = 4;
- if (header->unit_length == 0xffffffff) {
- header->unit_length = *(uint64_t *)p;
- p += sizeof(uint64_t);
- header->format = 8;
+ char *p, *cu_end, *cu_start, *include_directories, *filenames;
+ unsigned long unit_length;
+ int default_is_stmt, line_base;
+ unsigned int header_length, minimum_instruction_length, line_range,
+ opcode_base;
+ /* unsigned char *standard_opcode_lengths; */
+
+ /* The registers. */
+ unsigned long addr = 0;
+ unsigned int file = 1;
+ unsigned int line = 1;
+ /* unsigned int column = 0; */
+ int is_stmt;
+ /* int basic_block = 0; */
+ /* int end_sequence = 0; */
+ /* int prologue_end = 0; */
+ /* int epilogue_begin = 0; */
+ /* unsigned int isa = 0; */
+
+ p = *debug_line;
+
+ unit_length = *(unsigned int *)p;
+ p += sizeof(unsigned int);
+ if (unit_length == 0xffffffff) {
+ unit_length = *(unsigned long *)p;
+ p += sizeof(unsigned long);
}
- header->cu_end = p + header->unit_length;
+ cu_end = p + unit_length;
- header->version = *(uint16_t *)p;
- p += sizeof(uint16_t);
- if (header->version > 4) return -1;
+ /*dwarf_version = *(unsigned short *)p;*/
+ p += 2;
- header->header_length = header->format == 4 ? *(uint32_t *)p : *(uint64_t *)p;
- p += header->format;
- header->cu_start = p + header->header_length;
+ header_length = *(unsigned int *)p;
+ p += sizeof(unsigned int);
- header->minimum_instruction_length = *(uint8_t *)p++;
+ cu_start = p + header_length;
- if (header->version >= 4) {
- /* maximum_operations_per_instruction = *(uint8_t *)p; */
- if (*p != 1) return -1; /* For non-VLIW architectures, this field is 1 */
- p++;
- }
+ minimum_instruction_length = *(unsigned char *)p;
+ p++;
- header->default_is_stmt = *(uint8_t *)p++;
- header->line_base = *(int8_t *)p++;
- header->line_range = *(uint8_t *)p++;
- header->opcode_base = *(uint8_t *)p++;
- /* header->standard_opcode_lengths = (uint8_t *)p - 1; */
- p += header->opcode_base - 1;
+ is_stmt = default_is_stmt = *(unsigned char *)p;
+ p++;
+
+ line_base = *(signed char *)p;
+ p++;
+
+ line_range = *(unsigned char *)p;
+ p++;
+
+ opcode_base = *(unsigned char *)p;
+ p++;
- header->include_directories = p;
+ /* standard_opcode_lengths = (unsigned char *)p - 1; */
+ p += opcode_base - 1;
+
+ include_directories = p;
/* temporary measure for compress-debug-sections */
- if (p >= header->cu_end) return -1;
+ if (p >= cu_end) return -1;
/* skip include directories */
while (*p) {
- p = memchr(p, '\0', header->cu_end - p);
+ p = memchr(p, '\0', cu_end - p);
if (!p) return -1;
p++;
}
p++;
- header->filenames = p;
-
- *pp = header->cu_start;
-
- return 0;
-}
+ filenames = p;
-static int
-parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
- obj_info_t *obj, line_info_t *lines, int offset)
-{
- const char *p = (const char *)*debug_line;
- struct LineNumberProgramHeader header;
-
- /* The registers. */
- unsigned long addr = 0;
- unsigned int file = 1;
- unsigned int line = 1;
- /* unsigned int column = 0; */
- int is_stmt;
- /* int basic_block = 0; */
- /* int end_sequence = 0; */
- /* int prologue_end = 0; */
- /* int epilogue_begin = 0; */
- /* unsigned int isa = 0; */
-
- if (parse_debug_line_header(&p, &header))
- return -1;
- is_stmt = header.default_is_stmt;
+ p = cu_start;
#define FILL_LINE() \
do { \
fill_line(num_traces, traces, addr, file, line, \
- (char *)header.include_directories, \
- (char *)header.filenames, \
+ include_directories, filenames, \
obj, lines, offset); \
/*basic_block = prologue_end = epilogue_begin = 0;*/ \
} while (0)
- while (p < header.cu_end) {
+ while (p < cu_end) {
unsigned long a;
unsigned char op = *p++;
switch (op) {
@@ -415,19 +328,19 @@ parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
FILL_LINE();
break;
case DW_LNS_advance_pc:
- a = uleb128((char **)&p);
+ a = uleb128(&p);
addr += a;
break;
case DW_LNS_advance_line: {
- long a = sleb128((char **)&p);
+ long a = sleb128(&p);
line += a;
break;
}
case DW_LNS_set_file:
- file = (unsigned int)uleb128((char **)&p);
+ file = (unsigned int)uleb128(&p);
break;
case DW_LNS_set_column:
- /*column = (unsigned int)*/(void)uleb128((char **)&p);
+ /*column = (unsigned int)*/(void)uleb128(&p);
break;
case DW_LNS_negate_stmt:
is_stmt = !is_stmt;
@@ -436,8 +349,8 @@ parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
/*basic_block = 1; */
break;
case DW_LNS_const_add_pc:
- a = ((255UL - header.opcode_base) / header.line_range) *
- header.minimum_instruction_length;
+ a = ((255 - opcode_base) / line_range) *
+ minimum_instruction_length;
addr += a;
break;
case DW_LNS_fixed_advance_pc:
@@ -451,7 +364,7 @@ parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
/* epilogue_begin = 1; */
break;
case DW_LNS_set_isa:
- /* isa = (unsigned int)*/(void)uleb128((char **)&p);
+ /* isa = (unsigned int)*/(void)uleb128(&p);
break;
case 0:
a = *(unsigned char *)p++;
@@ -464,7 +377,7 @@ parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
file = 1;
line = 1;
/* column = 0; */
- is_stmt = header.default_is_stmt;
+ is_stmt = default_is_stmt;
/* end_sequence = 0; */
/* isa = 0; */
break;
@@ -478,7 +391,7 @@ parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
break;
case DW_LNE_set_discriminator:
/* TODO:currently ignore */
- uleb128((char **)&p);
+ uleb128(&p);
break;
default:
kprintf("Unknown extended opcode: %d in %s\n",
@@ -486,16 +399,18 @@ parse_debug_line_cu(int num_traces, void **traces, char **debug_line,
}
break;
default: {
- uint8_t adjusted_opcode = op - header.opcode_base;
- uint8_t operation_advance = adjusted_opcode / header.line_range;
- /* NOTE: this code doesn't support VLIW */
- addr += operation_advance * header.minimum_instruction_length;
- line += header.line_base + (adjusted_opcode % header.line_range);
+ unsigned long addr_incr;
+ unsigned long line_incr;
+ a = op - opcode_base;
+ addr_incr = (a / line_range) * minimum_instruction_length;
+ line_incr = line_base + (a % line_range);
+ addr += (unsigned int)addr_incr;
+ line += (unsigned int)line_incr;
FILL_LINE();
}
}
}
- *debug_line = (char *)p;
+ *debug_line = p;
return 0;
}
@@ -529,7 +444,6 @@ append_obj(obj_info_t **objp)
*objp = newobj;
}
-#ifdef USE_ELF
static void
follow_debuglink(const char *debuglink, int num_traces, void **traces,
obj_info_t **objp, line_info_t *lines, int offset)
@@ -563,1053 +477,6 @@ follow_debuglink(const char *debuglink, int num_traces, void **traces,
o2->path = o1->path;
fill_lines(num_traces, traces, 0, objp, lines, offset);
}
-#endif
-
-enum
-{
- DW_TAG_compile_unit = 0x11,
- DW_TAG_inlined_subroutine = 0x1d,
- DW_TAG_subprogram = 0x2e,
-};
-
-/* Attributes encodings */
-enum
-{
- DW_AT_sibling = 0x01,
- DW_AT_location = 0x02,
- DW_AT_name = 0x03,
- /* Reserved 0x04 */
- /* Reserved 0x05 */
- /* Reserved 0x06 */
- /* Reserved 0x07 */
- /* Reserved 0x08 */
- DW_AT_ordering = 0x09,
- /* Reserved 0x0a */
- DW_AT_byte_size = 0x0b,
- /* Reserved 0x0c */
- DW_AT_bit_size = 0x0d,
- /* Reserved 0x0e */
- /* Reserved 0x0f */
- DW_AT_stmt_list = 0x10,
- DW_AT_low_pc = 0x11,
- DW_AT_high_pc = 0x12,
- DW_AT_language = 0x13,
- /* Reserved 0x14 */
- DW_AT_discr = 0x15,
- DW_AT_discr_value = 0x16,
- DW_AT_visibility = 0x17,
- DW_AT_import = 0x18,
- DW_AT_string_length = 0x19,
- DW_AT_common_reference = 0x1a,
- DW_AT_comp_dir = 0x1b,
- DW_AT_const_value = 0x1c,
- DW_AT_containing_type = 0x1d,
- DW_AT_default_value = 0x1e,
- /* Reserved 0x1f */
- DW_AT_inline = 0x20,
- DW_AT_is_optional = 0x21,
- DW_AT_lower_bound = 0x22,
- /* Reserved 0x23 */
- /* Reserved 0x24 */
- DW_AT_producer = 0x25,
- /* Reserved 0x26 */
- DW_AT_prototyped = 0x27,
- /* Reserved 0x28 */
- /* Reserved 0x29 */
- DW_AT_return_addr = 0x2a,
- /* Reserved 0x2b */
- DW_AT_start_scope = 0x2c,
- /* Reserved 0x2d */
- DW_AT_bit_stride = 0x2e,
- DW_AT_upper_bound = 0x2f,
- /* Reserved 0x30 */
- DW_AT_abstract_origin = 0x31,
- DW_AT_accessibility = 0x32,
- DW_AT_address_class = 0x33,
- DW_AT_artificial = 0x34,
- DW_AT_base_types = 0x35,
- DW_AT_calling_convention = 0x36,
- DW_AT_count = 0x37,
- DW_AT_data_member_location = 0x38,
- DW_AT_decl_column = 0x39,
- DW_AT_decl_file = 0x3a,
- DW_AT_decl_line = 0x3b,
- DW_AT_declaration = 0x3c,
- DW_AT_discr_list = 0x3d,
- DW_AT_encoding = 0x3e,
- DW_AT_external = 0x3f,
- DW_AT_frame_base = 0x40,
- DW_AT_friend = 0x41,
- DW_AT_identifier_case = 0x42,
- /* Reserved 0x43 */
- DW_AT_namelist_item = 0x44,
- DW_AT_priority = 0x45,
- DW_AT_segment = 0x46,
- DW_AT_specification = 0x47,
- DW_AT_static_link = 0x48,
- DW_AT_type = 0x49,
- DW_AT_use_location = 0x4a,
- DW_AT_variable_parameter = 0x4b,
- DW_AT_virtuality = 0x4c,
- DW_AT_vtable_elem_location = 0x4d,
- DW_AT_allocated = 0x4e,
- DW_AT_associated = 0x4f,
- DW_AT_data_location = 0x50,
- DW_AT_byte_stride = 0x51,
- DW_AT_entry_pc = 0x52,
- DW_AT_use_UTF8 = 0x53,
- DW_AT_extension = 0x54,
- DW_AT_ranges = 0x55,
- DW_AT_trampoline = 0x56,
- DW_AT_call_column = 0x57,
- DW_AT_call_file = 0x58,
- DW_AT_call_line = 0x59,
- DW_AT_description = 0x5a,
- DW_AT_binary_scale = 0x5b,
- DW_AT_decimal_scale = 0x5c,
- DW_AT_small = 0x5d,
- DW_AT_decimal_sign = 0x5e,
- DW_AT_digit_count = 0x5f,
- DW_AT_picture_string = 0x60,
- DW_AT_mutable = 0x61,
- DW_AT_threads_scaled = 0x62,
- DW_AT_explicit = 0x63,
- DW_AT_object_pointer = 0x64,
- DW_AT_endianity = 0x65,
- DW_AT_elemental = 0x66,
- DW_AT_pure = 0x67,
- DW_AT_recursive = 0x68,
- DW_AT_signature = 0x69,
- DW_AT_main_subprogram = 0x6a,
- DW_AT_data_bit_offset = 0x6b,
- DW_AT_const_expr = 0x6c,
- DW_AT_enum_class = 0x6d,
- DW_AT_linkage_name = 0x6e,
- DW_AT_string_length_bit_size = 0x6f,
- DW_AT_string_length_byte_size = 0x70,
- DW_AT_rank = 0x71,
- DW_AT_str_offsets_base = 0x72,
- DW_AT_addr_base = 0x73,
- DW_AT_rnglists_base = 0x74,
- /* Reserved 0x75 */
- DW_AT_dwo_name = 0x76,
- DW_AT_reference = 0x77,
- DW_AT_rvalue_reference = 0x78,
- DW_AT_macros = 0x79,
- DW_AT_call_all_calls = 0x7a,
- DW_AT_call_all_source_calls = 0x7b,
- DW_AT_call_all_tail_calls = 0x7c,
- DW_AT_call_return_pc = 0x7d,
- DW_AT_call_value = 0x7e,
- DW_AT_call_origin = 0x7f,
- DW_AT_call_parameter = 0x80,
- DW_AT_call_pc = 0x81,
- DW_AT_call_tail_call = 0x82,
- DW_AT_call_target = 0x83,
- DW_AT_call_target_clobbered = 0x84,
- DW_AT_call_data_location = 0x85,
- DW_AT_call_data_value = 0x86,
- DW_AT_noreturn = 0x87,
- DW_AT_alignment = 0x88,
- DW_AT_export_symbols = 0x89,
- DW_AT_deleted = 0x8a,
- DW_AT_defaulted = 0x8b,
- DW_AT_loclists_base = 0x8c,
- DW_AT_lo_user = 0x2000,
- DW_AT_hi_user = 0x3fff
-};
-
-/* Attribute form encodings */
-enum
-{
- DW_FORM_addr = 0x01,
- /* Reserved 0x02 */
- DW_FORM_block2 = 0x03,
- DW_FORM_block4 = 0x04,
- DW_FORM_data2 = 0x05,
- DW_FORM_data4 = 0x06,
- DW_FORM_data8 = 0x07,
- DW_FORM_string = 0x08,
- DW_FORM_block = 0x09,
- DW_FORM_block1 = 0x0a,
- DW_FORM_data1 = 0x0b,
- DW_FORM_flag = 0x0c,
- DW_FORM_sdata = 0x0d,
- DW_FORM_strp = 0x0e,
- DW_FORM_udata = 0x0f,
- DW_FORM_ref_addr = 0x10,
- DW_FORM_ref1 = 0x11,
- DW_FORM_ref2 = 0x12,
- DW_FORM_ref4 = 0x13,
- DW_FORM_ref8 = 0x14,
- DW_FORM_ref_udata = 0x15,
- DW_FORM_indirect = 0x16,
- DW_FORM_sec_offset = 0x17,
- DW_FORM_exprloc = 0x18,
- DW_FORM_flag_present = 0x19,
- DW_FORM_strx = 0x1a,
- DW_FORM_addrx = 0x1b,
- DW_FORM_ref_sup4 = 0x1c,
- DW_FORM_strp_sup = 0x1d,
- DW_FORM_data16 = 0x1e,
- DW_FORM_line_strp = 0x1f,
- DW_FORM_ref_sig8 = 0x20,
- DW_FORM_implicit_const = 0x21,
- DW_FORM_loclistx = 0x22,
- DW_FORM_rnglistx = 0x23,
- DW_FORM_ref_sup8 = 0x24,
- DW_FORM_strx1 = 0x25,
- DW_FORM_strx2 = 0x26,
- DW_FORM_strx3 = 0x27,
- DW_FORM_strx4 = 0x28,
- DW_FORM_addrx1 = 0x29,
- DW_FORM_addrx2 = 0x2a,
- DW_FORM_addrx3 = 0x2b,
- DW_FORM_addrx4 = 0x2c
-};
-
-enum {
- VAL_none = 0,
- VAL_cstr = 1,
- VAL_data = 2,
- VAL_uint = 3,
- VAL_int = 4
-};
-
-# define ABBREV_TABLE_SIZE 256
-typedef struct {
- obj_info_t *obj;
- char *file;
- char *current_cu;
- uint64_t current_low_pc;
- char *debug_line_cu_end;
- char *debug_line_files;
- char *debug_line_directories;
- char *p;
- char *cu_end;
- char *pend;
- char *q0;
- char *q;
- int format; // 4 or 8
- uint8_t address_size;
- int level;
- char *abbrev_table[ABBREV_TABLE_SIZE];
-} DebugInfoReader;
-
-typedef struct {
- ptrdiff_t pos;
- int tag;
- int has_children;
-} DIE;
-
-typedef struct {
- union {
- char *ptr;
- uint64_t uint64;
- int64_t int64;
- } as;
- uint64_t off;
- uint64_t at;
- uint64_t form;
- size_t size;
- int type;
-} DebugInfoValue;
-
-/* TODO: Big Endian */
-#define MERGE_2INTS(a,b,sz) (((uint64_t)(b)<<sz)|(a))
-
-static uint16_t
-get_uint16(const uint8_t *p)
-{
- return (uint16_t)MERGE_2INTS(p[0],p[1],8);
-}
-
-static uint32_t
-get_uint32(const uint8_t *p)
-{
- return (uint32_t)MERGE_2INTS(get_uint16(p),get_uint16(p+2),16);
-}
-
-static uint64_t
-get_uint64(const uint8_t *p)
-{
- return MERGE_2INTS(get_uint32(p),get_uint32(p+4),32);
-}
-
-static uint8_t
-read_uint8(char **ptr)
-{
- const unsigned char *p = (const unsigned char *)*ptr;
- *ptr = (char *)(p + 1);
- return *p;
-}
-
-static uint16_t
-read_uint16(char **ptr)
-{
- const unsigned char *p = (const unsigned char *)*ptr;
- *ptr = (char *)(p + 2);
- return get_uint16(p);
-}
-
-static uint32_t
-read_uint24(char **ptr)
-{
- const unsigned char *p = (const unsigned char *)*ptr;
- *ptr = (char *)(p + 3);
- return (*p << 16) | get_uint16(p+1);
-}
-
-static uint32_t
-read_uint32(char **ptr)
-{
- const unsigned char *p = (const unsigned char *)*ptr;
- *ptr = (char *)(p + 4);
- return get_uint32(p);
-}
-
-static uint64_t
-read_uint64(char **ptr)
-{
- const unsigned char *p = (const unsigned char *)*ptr;
- *ptr = (char *)(p + 8);
- return get_uint64(p);
-}
-
-static uintptr_t
-read_uintptr(char **ptr)
-{
- const unsigned char *p = (const unsigned char *)*ptr;
- *ptr = (char *)(p + SIZEOF_VOIDP);
-#if SIZEOF_VOIDP == 8
- return get_uint64(p);
-#else
- return get_uint32(p);
-#endif
-}
-
-static uint64_t
-read_uint(DebugInfoReader *reader)
-{
- if (reader->format == 4) {
- return read_uint32(&reader->p);
- } else { /* 64 bit */
- return read_uint64(&reader->p);
- }
-}
-
-static uint64_t
-read_uleb128(DebugInfoReader *reader)
-{
- return uleb128(&reader->p);
-}
-
-static int64_t
-read_sleb128(DebugInfoReader *reader)
-{
- return sleb128(&reader->p);
-}
-
-static void
-debug_info_reader_init(DebugInfoReader *reader, obj_info_t *obj)
-{
- reader->file = obj->mapped;
- reader->obj = obj;
- reader->p = obj->debug_info.ptr;
- reader->pend = obj->debug_info.ptr + obj->debug_info.size;
- reader->debug_line_cu_end = obj->debug_line.ptr;
-}
-
-static void
-di_read_debug_abbrev_cu(DebugInfoReader *reader)
-{
- uint64_t prev = 0;
- char *p = reader->q0;
- for (;;) {
- uint64_t abbrev_number = uleb128(&p);
- if (abbrev_number <= prev) break;
- if (abbrev_number < ABBREV_TABLE_SIZE) {
- reader->abbrev_table[abbrev_number] = p;
- }
- prev = abbrev_number;
- uleb128(&p); /* tag */
- p++; /* has_children */
- /* skip content */
- for (;;) {
- uint64_t at = uleb128(&p);
- uint64_t form = uleb128(&p);
- if (!at && !form) break;
- }
- }
-}
-
-static int
-di_read_debug_line_cu(DebugInfoReader *reader)
-{
- const char *p;
- struct LineNumberProgramHeader header;
-
- p = (const char *)reader->debug_line_cu_end;
- if (parse_debug_line_header(&p, &header))
- return -1;
-
- reader->debug_line_cu_end = (char *)header.cu_end;
- reader->debug_line_directories = (char *)header.include_directories;
- reader->debug_line_files = (char *)header.filenames;
-
- return 0;
-}
-
-static void
-set_uint_value(DebugInfoValue *v, uint64_t n)
-{
- v->as.uint64 = n;
- v->type = VAL_uint;
-}
-
-static void
-set_int_value(DebugInfoValue *v, int64_t n)
-{
- v->as.int64 = n;
- v->type = VAL_int;
-}
-
-static void
-set_cstr_value(DebugInfoValue *v, char *s)
-{
- v->as.ptr = s;
- v->off = 0;
- v->type = VAL_cstr;
-}
-
-static void
-set_cstrp_value(DebugInfoValue *v, char *s, uint64_t off)
-{
- v->as.ptr = s;
- v->off = off;
- v->type = VAL_cstr;
-}
-
-static void
-set_data_value(DebugInfoValue *v, char *s)
-{
- v->as.ptr = s;
- v->type = VAL_data;
-}
-
-static const char *
-get_cstr_value(DebugInfoValue *v)
-{
- if (v->as.ptr) {
- return v->as.ptr + v->off;
- } else {
- return NULL;
- }
-}
-
-static void
-debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoValue *v)
-{
- switch (form) {
- case DW_FORM_addr:
- if (reader->address_size == 4) {
- set_uint_value(v, read_uint32(&reader->p));
- } else if (reader->address_size == 8) {
- set_uint_value(v, read_uint64(&reader->p));
- } else {
- fprintf(stderr,"unknown address_size:%d", reader->address_size);
- abort();
- }
- break;
- case DW_FORM_block2:
- v->size = read_uint16(&reader->p);
- set_data_value(v, reader->p);
- reader->p += v->size;
- break;
- case DW_FORM_block4:
- v->size = read_uint32(&reader->p);
- set_data_value(v, reader->p);
- reader->p += v->size;
- break;
- case DW_FORM_data2:
- set_uint_value(v, read_uint16(&reader->p));
- break;
- case DW_FORM_data4:
- set_uint_value(v, read_uint32(&reader->p));
- break;
- case DW_FORM_data8:
- set_uint_value(v, read_uint64(&reader->p));
- break;
- case DW_FORM_string:
- v->size = strlen(reader->p);
- set_cstr_value(v, reader->p);
- reader->p += v->size + 1;
- break;
- case DW_FORM_block:
- v->size = uleb128(&reader->p);
- set_data_value(v, reader->p);
- reader->p += v->size;
- break;
- case DW_FORM_block1:
- v->size = read_uint8(&reader->p);
- set_data_value(v, reader->p);
- reader->p += v->size;
- break;
- case DW_FORM_data1:
- set_uint_value(v, read_uint8(&reader->p));
- break;
- case DW_FORM_flag:
- set_uint_value(v, read_uint8(&reader->p));
- break;
- case DW_FORM_sdata:
- set_int_value(v, read_sleb128(reader));
- break;
- case DW_FORM_strp:
- set_cstrp_value(v, reader->obj->debug_str.ptr, read_uint(reader));
- break;
- case DW_FORM_udata:
- set_uint_value(v, read_uleb128(reader));
- break;
- case DW_FORM_ref_addr:
- if (reader->address_size == 4) {
- set_uint_value(v, read_uint32(&reader->p));
- } else if (reader->address_size == 8) {
- set_uint_value(v, read_uint64(&reader->p));
- } else {
- fprintf(stderr,"unknown address_size:%d", reader->address_size);
- abort();
- }
- break;
- case DW_FORM_ref1:
- set_uint_value(v, read_uint8(&reader->p));
- break;
- case DW_FORM_ref2:
- set_uint_value(v, read_uint16(&reader->p));
- break;
- case DW_FORM_ref4:
- set_uint_value(v, read_uint32(&reader->p));
- break;
- case DW_FORM_ref8:
- set_uint_value(v, read_uint64(&reader->p));
- break;
- case DW_FORM_ref_udata:
- set_uint_value(v, uleb128(&reader->p));
- break;
- case DW_FORM_indirect:
- /* TODO: read the referred value */
- set_uint_value(v, uleb128(&reader->p));
- break;
- case DW_FORM_sec_offset:
- set_uint_value(v, read_uint(reader)); /* offset */
- /* addrptr: debug_addr */
- /* lineptr: debug_line */
- /* loclist: debug_loclists */
- /* loclistptr: debug_loclists */
- /* macptr: debug_macro */
- /* rnglist: debug_rnglists */
- /* rnglistptr: debug_rnglists */
- /* stroffsetsptr: debug_str_offsets */
- break;
- case DW_FORM_exprloc:
- v->size = (size_t)read_uleb128(reader);
- set_data_value(v, reader->p);
- reader->p += v->size;
- break;
- case DW_FORM_flag_present:
- set_uint_value(v, 1);
- break;
- case DW_FORM_strx:
- set_uint_value(v, uleb128(&reader->p));
- break;
- case DW_FORM_addrx:
- /* TODO: read .debug_addr */
- set_uint_value(v, uleb128(&reader->p));
- break;
- case DW_FORM_ref_sup4:
- set_uint_value(v, read_uint32(&reader->p));
- break;
- case DW_FORM_strp_sup:
- set_uint_value(v, read_uint(reader));
- /* *p = reader->sup_file + reader->sup_str->sh_offset + ret; */
- break;
- case DW_FORM_data16:
- v->size = 16;
- set_data_value(v, reader->p);
- reader->p += v->size;
- break;
- case DW_FORM_line_strp:
- set_uint_value(v, read_uint(reader));
- /* *p = reader->file + reader->line->sh_offset + ret; */
- break;
- case DW_FORM_ref_sig8:
- set_uint_value(v, read_uint64(&reader->p));
- break;
- case DW_FORM_implicit_const:
- set_int_value(v, sleb128(&reader->q));
- break;
- case DW_FORM_loclistx:
- set_uint_value(v, read_uleb128(reader));
- break;
- case DW_FORM_rnglistx:
- set_uint_value(v, read_uleb128(reader));
- break;
- case DW_FORM_ref_sup8:
- set_uint_value(v, read_uint64(&reader->p));
- break;
- case DW_FORM_strx1:
- set_uint_value(v, read_uint8(&reader->p));
- break;
- case DW_FORM_strx2:
- set_uint_value(v, read_uint16(&reader->p));
- break;
- case DW_FORM_strx3:
- set_uint_value(v, read_uint24(&reader->p));
- break;
- case DW_FORM_strx4:
- set_uint_value(v, read_uint32(&reader->p));
- break;
- case DW_FORM_addrx1:
- set_uint_value(v, read_uint8(&reader->p));
- break;
- case DW_FORM_addrx2:
- set_uint_value(v, read_uint16(&reader->p));
- break;
- case DW_FORM_addrx3:
- set_uint_value(v, read_uint24(&reader->p));
- break;
- case DW_FORM_addrx4:
- set_uint_value(v, read_uint32(&reader->p));
- break;
- case 0:
- goto fail;
- break;
- }
- return;
-
- fail:
- fprintf(stderr, "%d: unsupported form: %#"PRIx64"\n", __LINE__, form);
- exit(1);
-}
-
-/* find abbrev in current compilation unit */
-static char *
-di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
-{
- char *p;
- if (abbrev_number < ABBREV_TABLE_SIZE) {
- return reader->abbrev_table[abbrev_number];
- }
- p = reader->abbrev_table[ABBREV_TABLE_SIZE-1];
- /* skip 255th record */
- uleb128(&p); /* tag */
- p++; /* has_children */
- /* skip content */
- for (;;) {
- uint64_t at = uleb128(&p);
- uint64_t form = uleb128(&p);
- if (!at && !form) break;
- }
- for (uint64_t n = uleb128(&p); abbrev_number != n; n = uleb128(&p)) {
- if (n == 0) {
- fprintf(stderr,"%d: Abbrev Number %"PRId64" not found\n",__LINE__, abbrev_number);
- exit(1);
- }
- uleb128(&p); /* tag */
- p++; /* has_children */
- /* skip content */
- for (;;) {
- uint64_t at = uleb128(&p);
- uint64_t form = uleb128(&p);
- if (!at && !form) break;
- }
- }
- return p;
-}
-
-#if 0
-static void
-hexdump0(const unsigned char *p, size_t n)
-{
- size_t i;
- fprintf(stderr, " 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
- for (i=0; i < n; i++){
- switch (i & 15) {
- case 0:
- fprintf(stderr, "%02zd: %02X ", i/16, p[i]);
- break;
- case 15:
- fprintf(stderr, "%02X\n", p[i]);
- break;
- default:
- fprintf(stderr, "%02X ", p[i]);
- break;
- }
- }
- if ((i & 15) != 15) {
- fprintf(stderr, "\n");
- }
-}
-#define hexdump(p,n) hexdump0((const unsigned char *)p, n)
-
-static void
-div_inspect(DebugInfoValue *v)
-{
- switch (v->type) {
- case VAL_uint:
- fprintf(stderr,"%d: type:%d size:%zx v:%lx\n",__LINE__,v->type,v->size,v->as.uint64);
- break;
- case VAL_int:
- fprintf(stderr,"%d: type:%d size:%zx v:%ld\n",__LINE__,v->type,v->size,(int64_t)v->as.uint64);
- break;
- case VAL_cstr:
- fprintf(stderr,"%d: type:%d size:%zx v:'%s'\n",__LINE__,v->type,v->size,v->as.ptr);
- break;
- case VAL_data:
- fprintf(stderr,"%d: type:%d size:%zx v:\n",__LINE__,v->type,v->size);
- hexdump(v->as.ptr, 16);
- break;
- }
-}
-#endif
-
-static DIE *
-di_read_die(DebugInfoReader *reader, DIE *die)
-{
- uint64_t abbrev_number = uleb128(&reader->p);
- if (abbrev_number == 0) {
- reader->level--;
- return NULL;
- }
-
- reader->q = di_find_abbrev(reader, abbrev_number);
-
- die->pos = reader->p - reader->obj->debug_info.ptr - 1;
- die->tag = (int)uleb128(&reader->q); /* tag */
- die->has_children = *reader->q++; /* has_children */
- if (die->has_children) {
- reader->level++;
- }
- return die;
-}
-
-static DebugInfoValue *
-di_read_record(DebugInfoReader *reader, DebugInfoValue *vp)
-{
- uint64_t at = uleb128(&reader->q);
- uint64_t form = uleb128(&reader->q);
- if (!at || !form) return NULL;
- vp->at = at;
- vp->form = form;
- debug_info_reader_read_value(reader, form, vp);
- return vp;
-}
-
-static void
-di_skip_records(DebugInfoReader *reader)
-{
- for (;;) {
- DebugInfoValue v = {{}};
- uint64_t at = uleb128(&reader->q);
- uint64_t form = uleb128(&reader->q);
- if (!at || !form) return;
- debug_info_reader_read_value(reader, form, &v);
- }
-}
-
-typedef struct {
- uint64_t low_pc;
- uint64_t high_pc;
- uint64_t ranges;
- bool low_pc_set;
- bool high_pc_set;
- bool ranges_set;
-} ranges_t;
-
-static void
-ranges_set(ranges_t *ptr, DebugInfoValue *v)
-{
- switch (v->at) {
- case DW_AT_low_pc:
- ptr->low_pc = v->as.uint64;
- ptr->low_pc_set = true;
- break;
- case DW_AT_high_pc:
- if (v->form == DW_FORM_addr) {
- ptr->high_pc = v->as.uint64;
- }
- else {
- ptr->high_pc = ptr->low_pc + v->as.uint64;
- }
- ptr->high_pc_set = true;
- break;
- case DW_AT_ranges:
- ptr->ranges = v->as.uint64;
- ptr->ranges_set = true;
- break;
- }
-}
-
-static uintptr_t
-ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr)
-{
- if (ptr->high_pc_set) {
- if (ptr->ranges_set || !ptr->low_pc_set) {
- exit(1);
- }
- if (ptr->low_pc <= addr && addr <= ptr->high_pc) {
- return (uintptr_t)ptr->low_pc;
- }
- }
- else if (ptr->ranges_set) {
- /* TODO: support base address selection entry */
- char *p = reader->obj->debug_ranges.ptr + ptr->ranges;
- uint64_t base = ptr->low_pc_set ? ptr->low_pc : reader->current_low_pc;
- for (;;) {
- uintptr_t from = read_uintptr(&p);
- uintptr_t to = read_uintptr(&p);
- if (!from && !to) break;
- if (from == UINTPTR_MAX) {
- /* base address selection entry */
- base = to;
- }
- else if (base + from <= addr && addr < base + to) {
- return from;
- }
- }
- }
- else if (ptr->low_pc_set) {
- if (ptr->low_pc == addr) {
- return (uintptr_t)ptr->low_pc;
- }
- }
- return false;
-}
-
-#if 0
-static void
-ranges_inspect(DebugInfoReader *reader, ranges_t *ptr)
-{
- if (ptr->high_pc_set) {
- if (ptr->ranges_set || !ptr->low_pc_set) {
- fprintf(stderr,"low_pc_set:%d high_pc_set:%d ranges_set:%d\n",ptr->low_pc_set,ptr->high_pc_set,ptr->ranges_set);
- exit(1);
- }
- fprintf(stderr,"low_pc:%"PRIx64" high_pc:%"PRIx64"\n",ptr->low_pc,ptr->high_pc);
- }
- else if (ptr->ranges_set) {
- char *p = reader->obj->debug_ranges.ptr + ptr->ranges;
- fprintf(stderr,"low_pc:%"PRIx64" ranges:%"PRIx64" %lx ",ptr->low_pc,ptr->ranges, p-reader->obj->mapped);
- for (;;) {
- uintptr_t from = read_uintptr(&p);
- uintptr_t to = read_uintptr(&p);
- if (!from && !to) break;
- fprintf(stderr,"%"PRIx64"-%"PRIx64" ",ptr->low_pc+from,ptr->low_pc+to);
- }
- fprintf(stderr,"\n");
- }
- else if (ptr->low_pc_set) {
- fprintf(stderr,"low_pc:%"PRIx64"\n",ptr->low_pc);
- }
- else {
- fprintf(stderr,"empty\n");
- }
-}
-#endif
-
-static int
-di_read_cu(DebugInfoReader *reader)
-{
- uint64_t unit_length;
- uint16_t version;
- uint64_t debug_abbrev_offset;
- reader->format = 4;
- reader->current_cu = reader->p;
- unit_length = read_uint32(&reader->p);
- if (unit_length == 0xffffffff) {
- unit_length = read_uint64(&reader->p);
- reader->format = 8;
- }
- reader->cu_end = reader->p + unit_length;
- version = read_uint16(&reader->p);
- if (version > 5) {
- return -1;
- }
- else if (version == 5) {
- /* unit_type = */ read_uint8(&reader->p);
- reader->address_size = read_uint8(&reader->p);
- debug_abbrev_offset = read_uint(reader);
- }
- else {
- debug_abbrev_offset = read_uint(reader);
- reader->address_size = read_uint8(&reader->p);
- }
- reader->q0 = reader->obj->debug_abbrev.ptr + debug_abbrev_offset;
-
- reader->level = 0;
- di_read_debug_abbrev_cu(reader);
- if (di_read_debug_line_cu(reader)) return -1;
-
-#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER_BUILD_DATE)
- /* Though DWARF specifies "the applicable base address defaults to the base
- address of the compilation unit", but GCC seems to use zero as default */
-#else
- do {
- DIE die;
-
- if (!di_read_die(reader, &die)) continue;
-
- if (die.tag != DW_TAG_compile_unit) {
- di_skip_records(reader);
- break;
- }
-
- /* enumerate abbrev */
- for (;;) {
- DebugInfoValue v = {{}};
- if (!di_read_record(reader, &v)) break;
- switch (v.at) {
- case DW_AT_low_pc:
- reader->current_low_pc = v.as.uint64;
- break;
- }
- }
- } while (0);
-#endif
- return 0;
-}
-
-static void
-read_abstract_origin(DebugInfoReader *reader, uint64_t abstract_origin, line_info_t *line)
-{
- char *p = reader->p;
- char *q = reader->q;
- int level = reader->level;
- DIE die;
-
- reader->p = reader->current_cu + abstract_origin;
- if (!di_read_die(reader, &die)) goto finish;
-
- /* enumerate abbrev */
- for (;;) {
- DebugInfoValue v = {{}};
- if (!di_read_record(reader, &v)) break;
- switch (v.at) {
- case DW_AT_name:
- line->sname = get_cstr_value(&v);
- break;
- }
- }
-
- finish:
- reader->p = p;
- reader->q = q;
- reader->level = level;
-}
-
-static void
-debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
- line_info_t *lines, int offset) {
- while (reader->p < reader->cu_end) {
- DIE die;
- ranges_t ranges = {};
- line_info_t line = {};
-
- if (!di_read_die(reader, &die)) continue;
- /* fprintf(stderr,"%d:%tx: <%d>\n",__LINE__,die.pos,reader->level,die.tag); */
-
- if (die.tag != DW_TAG_subprogram && die.tag != DW_TAG_inlined_subroutine) {
- skip_die:
- di_skip_records(reader);
- continue;
- }
-
- /* enumerate abbrev */
- for (;;) {
- DebugInfoValue v = {{}};
- /* ptrdiff_t pos = reader->p - reader->p0; */
- if (!di_read_record(reader, &v)) break;
- /* fprintf(stderr,"\n%d:%tx: AT:%lx FORM:%lx\n",__LINE__,pos,v.at,v.form); */
- /* div_inspect(&v); */
- switch (v.at) {
- case DW_AT_name:
- line.sname = get_cstr_value(&v);
- break;
- case DW_AT_call_file:
- fill_filename((int)v.as.uint64, reader->debug_line_directories, reader->debug_line_files, &line, reader->obj);
- break;
- case DW_AT_call_line:
- line.line = (int)v.as.uint64;
- break;
- case DW_AT_low_pc:
- case DW_AT_high_pc:
- case DW_AT_ranges:
- ranges_set(&ranges, &v);
- break;
- case DW_AT_declaration:
- goto skip_die;
- case DW_AT_inline:
- /* 1 or 3 */
- break; /* goto skip_die; */
- case DW_AT_abstract_origin:
- read_abstract_origin(reader, v.as.uint64, &line);
- break; /* goto skip_die; */
- }
- }
- /* ranges_inspect(reader, &ranges); */
- /* fprintf(stderr,"%d:%tx: %x ",__LINE__,diepos,die.tag); */
- for (int i=offset; i < num_traces; i++) {
- uintptr_t addr = (uintptr_t)traces[i];
- uintptr_t offset = addr - reader->obj->base_addr + reader->obj->vmaddr;
- uintptr_t saddr = ranges_include(reader, &ranges, offset);
- if (saddr) {
- /* fprintf(stderr, "%d:%tx: %d %lx->%lx %x %s: %s/%s %d %s %s %s\n",__LINE__,die.pos, i,addr,offset, die.tag,line.sname,line.dirname,line.filename,line.line,reader->obj->path,line.sname,lines[i].sname); */
- if (lines[i].sname) {
- line_info_t *lp = malloc(sizeof(line_info_t));
- memcpy(lp, &lines[i], sizeof(line_info_t));
- lines[i].next = lp;
- lp->dirname = line.dirname;
- lp->filename = line.filename;
- lp->line = line.line;
- lp->saddr = 0;
- }
- lines[i].path = reader->obj->path;
- lines[i].base_addr = line.base_addr;
- lines[i].sname = line.sname;
- lines[i].saddr = saddr + reader->obj->base_addr - reader->obj->vmaddr;
- }
- }
- }
-}
-
-#ifdef USE_ELF
-static unsigned long
-uncompress_debug_section(ElfW(Shdr) *shdr, char *file, char **ptr)
-{
- *ptr = NULL;
-#ifdef SUPPORT_COMPRESSED_DEBUG_LINE
- ElfW(Chdr) *chdr = (ElfW(Chdr) *)(file + shdr->sh_offset);
- unsigned long destsize = chdr->ch_size;
- int ret = 0;
-
- if (chdr->ch_type != ELFCOMPRESS_ZLIB) {
- /* unsupported compression type */
- return 0;
- }
-
- *ptr = malloc(destsize);
- if (!*ptr) return 0;
- ret = uncompress((Bytef *)*ptr, &destsize,
- (const Bytef*)chdr + sizeof(ElfW(Chdr)),
- shdr->sh_size - sizeof(ElfW(Chdr)));
- if (ret != Z_OK) goto fail;
- return destsize;
-
-fail:
- free(*ptr);
- *ptr = NULL;
-#endif
- return 0;
-}
/* read file and fill lines */
static uintptr_t
@@ -1618,9 +485,10 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
{
int i, j;
char *shstr;
+ char *section_name;
ElfW(Ehdr) *ehdr;
ElfW(Shdr) *shdr, *shstr_shdr;
- ElfW(Shdr) *gnu_debuglink_shdr = NULL;
+ ElfW(Shdr) *debug_line_shdr = NULL, *gnu_debuglink_shdr = NULL;
int fd;
off_t filesize;
char *file;
@@ -1628,6 +496,7 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
ElfW(Shdr) *dynsym_shdr = NULL, *dynstr_shdr = NULL;
obj_info_t *obj = *objp;
uintptr_t dladdr_fbase = 0;
+ bool compressed_p = false;
fd = open(binary_filename, O_RDONLY);
if (fd < 0) {
@@ -1656,7 +525,6 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
kprintf("mmap: %s\n", strerror(e));
goto fail;
}
- close(fd);
ehdr = (ElfW(Ehdr) *)file;
if (memcmp(ehdr->e_ident, "\177ELF", 4) != 0) {
@@ -1664,8 +532,11 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
* Huh? Maybe filename was overridden by setproctitle() and
* it match non-elf file.
*/
+ close(fd);
goto fail;
}
+
+ obj->fd = fd;
obj->mapped = file;
obj->mapped_size = (size_t)filesize;
@@ -1675,7 +546,7 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
shstr = file + shstr_shdr->sh_offset;
for (i = 0; i < ehdr->e_shnum; i++) {
- char *section_name = shstr + shdr[i].sh_name;
+ section_name = shstr + shdr[i].sh_name;
switch (shdr[i].sh_type) {
case SHT_STRTAB:
if (!strcmp(section_name, ".strtab")) {
@@ -1694,34 +565,15 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
dynsym_shdr = shdr + i;
break;
case SHT_PROGBITS:
- if (!strcmp(section_name, ".gnu_debuglink")) {
+ if (!strcmp(section_name, ".debug_line")) {
+ if (shdr[i].sh_flags & SHF_COMPRESSED) {
+ compressed_p = true;
+ }
+ debug_line_shdr = shdr + i;
+ }
+ else if (!strcmp(section_name, ".gnu_debuglink")) {
gnu_debuglink_shdr = shdr + i;
}
- else {
- const char *debug_section_names[] = {
- ".debug_abbrev",
- ".debug_info",
- ".debug_line",
- ".debug_ranges",
- ".debug_str"
- };
-
- for (j=0; j < DWARF_SECTION_COUNT; j++) {
- struct dwarf_section *s = obj_dwarf_section_at(obj, j);
-
- if (strcmp(section_name, debug_section_names[j]) != 0)
- continue;
-
- s->ptr = file + shdr[i].sh_offset;
- s->size = shdr[i].sh_size;
- s->flags = shdr[i].sh_flags;
- if (s->flags & SHF_COMPRESSED) {
- s->size = uncompress_debug_section(&shdr[i], file, &s->ptr);
- if (!s->size) goto fail;
- }
- break;
- }
- }
break;
}
}
@@ -1733,22 +585,20 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
char *strtab = file + dynstr_shdr->sh_offset;
ElfW(Sym) *symtab = (ElfW(Sym) *)(file + dynsym_shdr->sh_offset);
int symtab_count = (int)(dynsym_shdr->sh_size / sizeof(ElfW(Sym)));
- void *handle = dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
- if (handle) {
- for (j = 0; j < symtab_count; j++) {
- ElfW(Sym) *sym = &symtab[j];
- Dl_info info;
- void *s;
- if (ELF_ST_TYPE(sym->st_info) != STT_FUNC || sym->st_size == 0) continue;
- s = dlsym(handle, strtab + sym->st_name);
- if (s && dladdr(s, &info)) {
- obj->base_addr = dladdr_fbase;
- dladdr_fbase = (uintptr_t)info.dli_fbase;
- break;
- }
- }
- dlclose(handle);
- }
+ for (j = 0; j < symtab_count; j++) {
+ ElfW(Sym) *sym = &symtab[j];
+ Dl_info info;
+ void *h, *s;
+ if (ELF_ST_TYPE(sym->st_info) != STT_FUNC || sym->st_size <= 0) continue;
+ h = dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
+ if (!h) continue;
+ s = dlsym(h, strtab + sym->st_name);
+ if (!s) continue;
+ if (dladdr(s, &info)) {
+ dladdr_fbase = (uintptr_t)info.dli_fbase;
+ break;
+ }
+ }
if (ehdr->e_type == ET_EXEC) {
obj->base_addr = 0;
}
@@ -1759,48 +609,33 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
}
}
- if (obj->debug_info.ptr && obj->debug_abbrev.ptr) {
- DebugInfoReader reader;
- debug_info_reader_init(&reader, obj);
- i = 0;
- while (reader.p < reader.pend) {
- /* fprintf(stderr, "%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info.ptr, i++); */
- if (di_read_cu(&reader)) goto use_symtab;
- debug_info_read(&reader, num_traces, traces, lines, offset);
- }
- }
- else {
- /* This file doesn't have dwarf, use symtab or dynsym */
-use_symtab:
- if (!symtab_shdr) {
- /* This file doesn't have symtab, use dynsym instead */
- symtab_shdr = dynsym_shdr;
- strtab_shdr = dynstr_shdr;
- }
-
- if (symtab_shdr && strtab_shdr) {
- char *strtab = file + strtab_shdr->sh_offset;
- ElfW(Sym) *symtab = (ElfW(Sym) *)(file + symtab_shdr->sh_offset);
- int symtab_count = (int)(symtab_shdr->sh_size / sizeof(ElfW(Sym)));
- for (j = 0; j < symtab_count; j++) {
- ElfW(Sym) *sym = &symtab[j];
- uintptr_t saddr = (uintptr_t)sym->st_value + obj->base_addr;
- if (ELF_ST_TYPE(sym->st_info) != STT_FUNC) continue;
- for (i = offset; i < num_traces; i++) {
- uintptr_t d = (uintptr_t)traces[i] - saddr;
- if (lines[i].line > 0 || d > (uintptr_t)sym->st_size)
- continue;
- /* fill symbol name and addr from .symtab */
- if (!lines[i].sname) lines[i].sname = strtab + sym->st_name;
- lines[i].saddr = saddr;
- lines[i].path = obj->path;
- lines[i].base_addr = obj->base_addr;
- }
- }
- }
+ if (!symtab_shdr) {
+ symtab_shdr = dynsym_shdr;
+ strtab_shdr = dynstr_shdr;
+ }
+
+ if (symtab_shdr && strtab_shdr) {
+ char *strtab = file + strtab_shdr->sh_offset;
+ ElfW(Sym) *symtab = (ElfW(Sym) *)(file + symtab_shdr->sh_offset);
+ int symtab_count = (int)(symtab_shdr->sh_size / sizeof(ElfW(Sym)));
+ for (j = 0; j < symtab_count; j++) {
+ ElfW(Sym) *sym = &symtab[j];
+ uintptr_t saddr = (uintptr_t)sym->st_value + obj->base_addr;
+ if (ELF_ST_TYPE(sym->st_info) != STT_FUNC || sym->st_size <= 0) continue;
+ for (i = offset; i < num_traces; i++) {
+ uintptr_t d = (uintptr_t)traces[i] - saddr;
+ if (lines[i].line > 0 || d <= 0 || d > (uintptr_t)sym->st_size)
+ continue;
+ /* fill symbol name and addr from .symtab */
+ lines[i].sname = strtab + sym->st_name;
+ lines[i].saddr = saddr;
+ lines[i].path = obj->path;
+ lines[i].base_addr = obj->base_addr;
+ }
+ }
}
- if (!obj->debug_line.ptr) {
+ if (!debug_line_shdr) {
/* This file doesn't have .debug_line section,
let's check .gnu_debuglink section instead. */
if (gnu_debuglink_shdr && check_debuglink) {
@@ -1811,234 +646,17 @@ use_symtab:
goto finish;
}
- if (parse_debug_line(num_traces, traces,
- obj->debug_line.ptr,
- obj->debug_line.size,
- obj, lines, offset) == -1)
- goto fail;
-
+ if (!compressed_p &&
+ parse_debug_line(num_traces, traces,
+ file + debug_line_shdr->sh_offset,
+ debug_line_shdr->sh_size,
+ obj, lines, offset))
+ goto fail;
finish:
return dladdr_fbase;
fail:
return (uintptr_t)-1;
}
-#else /* Mach-O */
-/* read file and fill lines */
-static uintptr_t
-fill_lines(int num_traces, void **traces, int check_debuglink,
- obj_info_t **objp, line_info_t *lines, int offset)
-{
-# ifdef __LP64__
-# define LP(x) x##_64
-# else
-# define LP(x) x
-# endif
- int fd;
- off_t filesize;
- char *file, *p = NULL;
- obj_info_t *obj = *objp;
- struct LP(mach_header) *header;
- uintptr_t dladdr_fbase = 0;
-
- {
- char *s = binary_filename;
- char *base = strrchr(binary_filename, '/')+1;
- size_t max = PATH_MAX;
- size_t size = strlen(binary_filename);
- size_t basesize = size - (base - binary_filename);
- s += size;
- max -= size;
- p = s;
- size = strlcpy(s, ".dSYM/Contents/Resources/DWARF/", max);
- if (size == 0) goto fail;
- s += size;
- max -= size;
- if (max <= basesize) goto fail;
- memcpy(s, base, basesize);
- s[basesize] = 0;
-
- fd = open(binary_filename, O_RDONLY);
- if (fd < 0) {
- *p = 0; /* binary_filename becomes original file name */
- fd = open(binary_filename, O_RDONLY);
- if (fd < 0) {
- goto fail;
- }
- }
- }
-
- filesize = lseek(fd, 0, SEEK_END);
- if (filesize < 0) {
- int e = errno;
- close(fd);
- kprintf("lseek: %s\n", strerror(e));
- goto fail;
- }
-#if SIZEOF_OFF_T > SIZEOF_SIZE_T
- if (filesize > (off_t)SIZE_MAX) {
- close(fd);
- kprintf("Too large file %s\n", binary_filename);
- goto fail;
- }
-#endif
- lseek(fd, 0, SEEK_SET);
- /* async-signal unsafe */
- file = (char *)mmap(NULL, (size_t)filesize, PROT_READ, MAP_SHARED, fd, 0);
- if (file == MAP_FAILED) {
- int e = errno;
- close(fd);
- kprintf("mmap: %s\n", strerror(e));
- goto fail;
- }
- close(fd);
-
- obj->mapped = file;
- obj->mapped_size = (size_t)filesize;
-
- header = (struct LP(mach_header) *)file;
- if (header->magic == LP(MH_MAGIC)) {
- /* non universal binary */
- p = file;
- }
- else if (header->magic == FAT_CIGAM) {
- struct LP(mach_header) *mhp = _NSGetMachExecuteHeader();
- struct fat_header *fat = (struct fat_header *)file;
- char *q = file + sizeof(*fat);
- uint32_t nfat_arch = __builtin_bswap32(fat->nfat_arch);
- /* fprintf(stderr,"%d: fat:%s %d\n",__LINE__, binary_filename,nfat_arch); */
- for (uint32_t i = 0; i < nfat_arch; i++) {
- struct fat_arch *arch = (struct fat_arch *)q;
- cpu_type_t cputype = __builtin_bswap32(arch->cputype);
- cpu_subtype_t cpusubtype = __builtin_bswap32(arch->cpusubtype);
- uint32_t offset = __builtin_bswap32(arch->offset);
- /* fprintf(stderr,"%d: fat %d %x/%x %x/%x\n",__LINE__, i, mhp->cputype,mhp->cpusubtype, cputype,cpusubtype); */
- if (mhp->cputype == cputype &&
- (cpu_subtype_t)(mhp->cpusubtype & ~CPU_SUBTYPE_MASK) == cpusubtype) {
- p = file + offset;
- file = p;
- header = (struct LP(mach_header) *)p;
- if (header->magic == LP(MH_MAGIC)) {
- goto found_mach_header;
- }
- break;
- }
- q += sizeof(*arch);
- }
- kprintf("'%s' is not a Mach-O universal binary file!\n",binary_filename);
- close(fd);
- goto fail;
- }
- else {
- kprintf("'%s' is not a "
-# ifdef __LP64__
- "64"
-# else
- "32"
-# endif
- "-bit Mach-O file!\n",binary_filename);
- close(fd);
- goto fail;
- }
-found_mach_header:
- p += sizeof(*header);
-
- for (uint32_t i = 0; i < (uint32_t)header->ncmds; i++) {
- struct load_command *lcmd = (struct load_command *)p;
- switch (lcmd->cmd) {
- case LP(LC_SEGMENT):
- {
- static const char *debug_section_names[] = {
- "__debug_abbrev",
- "__debug_info",
- "__debug_line",
- "__debug_ranges",
- "__debug_str"
- };
- struct LP(segment_command) *scmd = (struct LP(segment_command) *)lcmd;
- if (strcmp(scmd->segname, "__TEXT") == 0) {
- obj->vmaddr = scmd->vmaddr;
- }
- else if (strcmp(scmd->segname, "__DWARF") == 0) {
- p += sizeof(struct LP(segment_command));
- for (uint64_t i = 0; i < scmd->nsects; i++) {
- struct LP(section) *sect = (struct LP(section) *)p;
- p += sizeof(struct LP(section));
- for (int j=0; j < DWARF_SECTION_COUNT; j++) {
- struct dwarf_section *s = obj_dwarf_section_at(obj, j);
-
- if (strcmp(sect->sectname, debug_section_names[j]) != 0)
- continue;
-
- s->ptr = file + sect->offset;
- s->size = sect->size;
- s->flags = sect->flags;
- if (s->flags & SHF_COMPRESSED) {
- goto fail;
- }
- break;
- }
- }
- }
- }
- break;
-
- case LC_SYMTAB:
- {
- struct symtab_command *cmd = (struct symtab_command *)lcmd;
- struct LP(nlist) *nl = (struct LP(nlist) *)(file + cmd->symoff);
- char *strtab = file + cmd->stroff, *sname = 0;
- uint32_t j;
- uintptr_t saddr = 0;
- /* kprintf("[%2d]: %x/symtab %p\n", i, cmd->cmd, p); */
- for (j = 0; j < cmd->nsyms; j++) {
- uintptr_t symsize, d;
- struct LP(nlist) *e = &nl[j];
- /* kprintf("[%2d][%4d]: %02x/%x/%x: %s %llx\n", i, j, e->n_type,e->n_sect,e->n_desc,strtab+e->n_un.n_strx,e->n_value); */
- if (e->n_type != N_FUN) continue;
- if (e->n_sect) {
- saddr = (uintptr_t)e->n_value + obj->base_addr - obj->vmaddr;
- sname = strtab + e->n_un.n_strx;
- /* kprintf("[%2d][%4d]: %02x/%x/%x: %s %llx\n", i, j, e->n_type,e->n_sect,e->n_desc,strtab+e->n_un.n_strx,e->n_value); */
- continue;
- }
- for (int k = offset; k < num_traces; k++) {
- d = (uintptr_t)traces[k] - saddr;
- symsize = e->n_value;
- /* kprintf("%lx %lx %lx\n",saddr,symsize,traces[k]); */
- if (lines[k].line > 0 || d > (uintptr_t)symsize)
- continue;
- /* fill symbol name and addr from .symtab */
- if (!lines[k].sname) lines[k].sname = sname;
- lines[k].saddr = saddr;
- lines[k].path = obj->path;
- lines[k].base_addr = obj->base_addr;
- }
- }
- }
- }
- p += lcmd->cmdsize;
- }
-
- if (obj->debug_info.ptr && obj->debug_abbrev.ptr) {
- DebugInfoReader reader;
- debug_info_reader_init(&reader, obj);
- while (reader.p < reader.pend) {
- if (di_read_cu(&reader)) goto fail;
- debug_info_read(&reader, num_traces, traces, lines, offset);
- }
- }
-
- if (parse_debug_line(num_traces, traces,
- obj->debug_line.ptr,
- obj->debug_line.size,
- obj, lines, offset) == -1)
- goto fail;
-
- return dladdr_fbase;
-fail:
- return (uintptr_t)-1;
-}
-#endif
#define HAVE_MAIN_EXE_PATH
#if defined(__FreeBSD__)
@@ -2056,7 +674,6 @@ main_exe_path(void)
{
# define PROC_SELF_EXE "/proc/self/exe"
ssize_t len = readlink(PROC_SELF_EXE, binary_filename, PATH_MAX);
- if (len < 0) return 0;
binary_filename[len] = 0;
return len;
}
@@ -2074,66 +691,10 @@ main_exe_path(void)
len--; /* sysctl sets strlen+1 */
return len;
}
-#elif defined(HAVE_LIBPROC_H)
-static ssize_t
-main_exe_path(void)
-{
- int len = proc_pidpath(getpid(), binary_filename, PATH_MAX);
- if (len == 0) return 0;
- binary_filename[len] = 0;
- return len;
-}
#else
#undef HAVE_MAIN_EXE_PATH
#endif
-static void
-print_line0(line_info_t *line, void *address)
-{
- uintptr_t addr = (uintptr_t)address;
- uintptr_t d = addr - line->saddr;
- if (!address) {
- /* inlined */
- if (line->dirname && line->dirname[0]) {
- kprintf("%s(%s) %s/%s:%d\n", line->path, line->sname, line->dirname, line->filename, line->line);
- }
- else {
- kprintf("%s(%s) %s:%d\n", line->path, line->sname, line->filename, line->line);
- }
- }
- else if (!line->path) {
- kprintf("[0x%"PRIxPTR"]\n", addr);
- }
- else if (!line->saddr || !line->sname) {
- kprintf("%s(0x%"PRIxPTR") [0x%"PRIxPTR"]\n", line->path, addr-line->base_addr, addr);
- }
- else if (line->line <= 0) {
- kprintf("%s(%s+0x%"PRIxPTR") [0x%"PRIxPTR"]\n", line->path, line->sname,
- d, addr);
- }
- else if (!line->filename) {
- kprintf("%s(%s+0x%"PRIxPTR") [0x%"PRIxPTR"] ???:%d\n", line->path, line->sname,
- d, addr, line->line);
- }
- else if (line->dirname && line->dirname[0]) {
- kprintf("%s(%s+0x%"PRIxPTR") [0x%"PRIxPTR"] %s/%s:%d\n", line->path, line->sname,
- d, addr, line->dirname, line->filename, line->line);
- }
- else {
- kprintf("%s(%s+0x%"PRIxPTR") [0x%"PRIxPTR"] %s:%d\n", line->path, line->sname,
- d, addr, line->filename, line->line);
- }
-}
-
-static void
-print_line(line_info_t *line, void *address)
-{
- print_line0(line, address);
- if (line->next) {
- print_line(line->next, NULL);
- }
-}
-
void
rb_dump_backtrace_with_lines(int num_traces, void **traces)
{
@@ -2185,8 +746,6 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
path = info.dli_fname;
obj->path = path;
lines[i].path = path;
- lines[i].sname = info.dli_sname;
- lines[i].saddr = (uintptr_t)info.dli_saddr;
strlcpy(binary_filename, path, PATH_MAX);
if (fill_lines(num_traces, traces, 1, &obj, lines, i) == (uintptr_t)-1)
break;
@@ -2197,36 +756,46 @@ next_line:
/* output */
for (i = 0; i < num_traces; i++) {
- print_line(&lines[i], traces[i]);
-
+ line_info_t *line = &lines[i];
+ uintptr_t addr = (uintptr_t)traces[i];
+ uintptr_t d = addr - line->saddr;
+ if (!line->path) {
+ kprintf("[0x%lx]\n", addr);
+ }
+ else if (!line->saddr || !line->sname) {
+ kprintf("%s(0x%lx) [0x%lx]\n", line->path, addr-line->base_addr, addr);
+ }
+ else if (line->line <= 0) {
+ kprintf("%s(%s+0x%lx) [0x%lx]\n", line->path, line->sname,
+ d, addr);
+ }
+ else if (!line->filename) {
+ kprintf("%s(%s+0x%lx) [0x%lx] ???:%d\n", line->path, line->sname,
+ d, addr, line->line);
+ }
+ else if (line->dirname && line->dirname[0]) {
+ kprintf("%s(%s+0x%lx) [0x%lx] %s/%s:%d\n", line->path, line->sname,
+ d, addr, line->dirname, line->filename, line->line);
+ }
+ else {
+ kprintf("%s(%s+0x%lx) [0x%lx] %s:%d\n", line->path, line->sname,
+ d, addr, line->filename, line->line);
+ }
/* FreeBSD's backtrace may show _start and so on */
- if (lines[i].sname && strcmp("main", lines[i].sname) == 0)
+ if (line->sname && strcmp("main", line->sname) == 0)
break;
}
/* free */
while (obj) {
obj_info_t *o = obj;
- for (i=0; i < DWARF_SECTION_COUNT; i++) {
- struct dwarf_section *s = obj_dwarf_section_at(obj, i);
- if (s->flags & SHF_COMPRESSED) {
- free(s->ptr);
- }
- }
- if (obj->mapped_size) {
- munmap(obj->mapped, obj->mapped_size);
- }
obj = o->next;
+ if (o->fd) {
+ munmap(o->mapped, o->mapped_size);
+ close(o->fd);
+ }
free(o);
}
- for (i = 0; i < num_traces; i++) {
- line_info_t *line = lines[i].next;
- while (line) {
- line_info_t *l = line;
- line = line->next;
- free(l);
- }
- }
free(lines);
free(dladdr_fbases);
}
@@ -2272,7 +841,7 @@ next_line:
#define MAXNBUF (sizeof(intmax_t) * CHAR_BIT + 1)
static inline int toupper(int c) { return ('A' <= c && c <= 'Z') ? (c&0x5f) : c; }
#define hex2ascii(hex) (hex2ascii_data[hex])
-static const char hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
static inline int imax(int a, int b) { return (a > b ? a : b); }
static int kvprintf(char const *fmt, void (*func)(int), void *arg, int radix, va_list ap);
@@ -2286,7 +855,7 @@ static void putce(int c)
(void)ret;
}
-static int
+int
kprintf(const char *fmt, ...)
{
va_list ap;
diff --git a/addr2line.h b/addr2line.h
index 4f6cf179ef..d99f010934 100644
--- a/addr2line.h
+++ b/addr2line.h
@@ -11,7 +11,7 @@
#ifndef RUBY_ADDR2LINE_H
#define RUBY_ADDR2LINE_H
-#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H))
+#ifdef USE_ELF
void
rb_dump_backtrace_with_lines(int num_traces, void **traces);
diff --git a/appveyor.yml b/appveyor.yml
index 7909de9e6b..22c7bdce6a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,5 +1,4 @@
---
-version: '{build}'
shallow_clone: true
platform:
- x64
@@ -7,88 +6,50 @@ environment:
ruby_version: "24-%Platform%"
zlib_version: "1.2.11"
matrix:
- - build: vs
- vs: 120
- ssl: OpenSSL
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- GEMS_FOR_TEST: ""
- - build: vs
- vs: 140
- ssl: OpenSSL-v111
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- GEMS_FOR_TEST: ""
- RELINE_TEST_ENCODING: "Windows-31J"
- UPDATE_UNICODE: "UNICODE_FILES=. UNICODE_PROPERTY_FILES=. UNICODE_AUXILIARY_FILES=. UNICODE_EMOJI_FILES=."
-for:
--
- matrix:
- only:
- - build: vs
- install:
- - ver
- - chcp
- - SET BITS=%Platform:x86=32%
- - SET BITS=%BITS:x=%
- - SET OPENSSL_DIR=C:\%ssl%-Win%BITS%
- - CALL SET vcvars=%%^VS%VS%COMNTOOLS^%%..\..\VC\vcvarsall.bat
- - SET vcvars
- - '"%vcvars%" %Platform:x64=amd64%'
- - SET ruby_path=C:\Ruby%ruby_version:-x86=%
- - SET PATH=\usr\local\bin;%ruby_path%\bin;%PATH%;C:\msys64\mingw64\bin;C:\msys64\usr\bin
- - ruby --version
- - 'cl'
- - echo> Makefile srcdir=.
- - echo>> Makefile MSC_VER=0
- - echo>> Makefile RT=none
- - echo>> Makefile RT_VER=0
- - echo>> Makefile BUILTIN_ENCOBJS=nul
- - type win32\Makefile.sub >> Makefile
- - nmake %mflags% touch-unicode-files
- - nmake %mflags% %UPDATE_UNICODE% up incs
- - del Makefile
- - mkdir \usr\local\bin
- - mkdir \usr\local\include
- - mkdir \usr\local\lib
- - curl -fsSL -o zlib%zlib_version:.=%.zip --retry 10 https://zlib.net/zlib%zlib_version:.=%.zip
- - 7z x -o%APPVEYOR_BUILD_FOLDER%\ext\zlib zlib%zlib_version:.=%.zip
- - for %%I in (%OPENSSL_DIR%\*.dll) do mklink /h \usr\local\bin\%%~nxI %%I
- - attrib +r /s /d
- - mkdir %Platform%-mswin_%vs%
- build_script:
- - cd %APPVEYOR_BUILD_FOLDER%
- - cd %Platform%-mswin_%vs%
- - ..\win32\configure.bat --without-ext=+,dbm,gdbm,readline --with-opt-dir=/usr/local --with-openssl-dir=%OPENSSL_DIR:\=/%
- - nmake -l
- - nmake install-nodoc
- - \usr\bin\ruby -v -e "p :locale => Encoding.find('locale'), :filesystem => Encoding.find('filesystem')"
- - if not "%GEMS_FOR_TEST%" == "" \usr\bin\gem install --no-document %GEMS_FOR_TEST%
- - \usr\bin\ruby -ropenssl -e "puts 'Build ' + OpenSSL::OPENSSL_VERSION, 'Runtime ' + OpenSSL::OPENSSL_LIBRARY_VERSION"
- test_script:
- - set /a JOBS=%NUMBER_OF_PROCESSORS%
- - nmake -l "TESTOPTS=-v -q" btest
- - nmake -l "TESTOPTS=-v -q" test-basic
- - nmake -l "TESTOPTS=-v --timeout-scale=3.0 --excludes=../test/excludes/_appveyor -j%JOBS% --exclude readline --exclude win32ole --exclude test_bignum --exclude test_syntax --exclude test_open-uri --exclude test_bundled_ca" test-all
- # separately execute tests without -j which may crash worker with -j.
- - nmake -l "TESTOPTS=-v --timeout-scale=3.0 --excludes=../test/excludes/_appveyor" test-all TESTS="../test/win32ole ../test/ruby/test_bignum.rb ../test/ruby/test_syntax.rb ../test/open-uri/test_open-uri.rb ../test/rubygems/test_bundled_ca.rb"
- - nmake -l test-spec MSPECOPT=-fs # not using `-j` because sometimes `mspec -j` silently dies on Windows
-notifications:
- # Using "Webhook" with templated body to skip notification on Pull Request
- - provider: Webhook
- method: POST
- url:
- secure: iMINHMS0nZabaDsxN9omRDsekxzVvAAzEq5ev7lN6vb+gUETT+rbDKLGxBxBpEpxlnPlLdzroIJ+DTKlwfJA8VkGawTn9EXNsucH0OkSf2M= # AppVeyor CI
- body: >-
- {{^isPullRequest}}
- {
- "attachments": [
- {
- "text": "Build <{{buildUrl}}|#{{buildVersion}}> (<{{commitUrl}}|{{commitId}}>) of {{repositoryName}}@{{branch}} by {{commitAuthor}} {{status}}",
- "color": "{{#passed}}good{{/passed}}{{#failed}}danger{{/failed}}"
- }
- ],
- "channel": "#alerts"
- }
- {{/isPullRequest}}
- on_build_success: false
- on_build_failure: true
- on_build_status_changed: true
+ - vs: "120"
+install:
+ - chcp
+ - SET BITS=%Platform:x86=32%
+ - SET BITS=%BITS:x=%
+ - SET OPENSSL_DIR=c:\OpenSSL-Win%BITS%
+ - CALL SET vcvars=%%^VS%VS%COMNTOOLS^%%..\..\VC\vcvarsall.bat
+ - SET vcvars
+ - '"%vcvars%" %Platform:x64=amd64%'
+ - SET ruby_path=C:\Ruby%ruby_version:-x86=%
+ - SET PATH=\usr\local\bin;%ruby_path%\bin;%PATH%;C:\msys64\mingw64\bin;C:\msys64\usr\bin
+ - ruby --version
+ - 'cl'
+ - SET
+ - echo> Makefile srcdir=.
+ - echo>> Makefile MSC_VER=0
+ - echo>> Makefile RT=none
+ - echo>> Makefile RT_VER=0
+ - echo>> Makefile BUILTIN_ENCOBJS=nul
+ - type win32\Makefile.sub >> Makefile
+ - nmake %mflags% touch-unicode-files
+ - nmake %mflags% up incs UNICODE_FILES=.
+ - del Makefile
+ - mkdir \usr\local\bin
+ - mkdir \usr\local\include
+ - mkdir \usr\local\lib
+ - appveyor DownloadFile https://zlib.net/zlib%zlib_version:.=%.zip
+ - 7z x -o%APPVEYOR_BUILD_FOLDER%\ext\zlib zlib%zlib_version:.=%.zip
+ - for %%I in (%OPENSSL_DIR%\*.dll) do mklink /h \usr\local\bin\%%~nxI %%I
+ - mkdir %Platform%-mswin_%vs%
+ - ps: Get-ChildItem "win32" -Recurse | foreach {$_.Attributes = 'Readonly'}
+ - ps: Get-Item $env:Platform"-mswin_"$env:vs | foreach {$_.Attributes = 'Normal'}
+build_script:
+ - cd %APPVEYOR_BUILD_FOLDER%
+ - cd %Platform%-mswin_%vs%
+ - ..\win32\configure.bat --without-ext=+,dbm,gdbm,readline --with-opt-dir=/usr/local --with-openssl-dir=%OPENSSL_DIR:\=/%
+ - nmake -l
+ - nmake install-nodoc
+ - \usr\bin\ruby -v -e "p :locale => Encoding.find('locale'), :filesystem => Encoding.find('filesystem')"
+test_script:
+ - set /a JOBS=%NUMBER_OF_PROCESSORS%
+ - nmake -l "TESTOPTS=-v -q" btest
+ - nmake -l "TESTOPTS=-v -q" test-basic
+ - nmake -l "TESTOPTS=-q -j%JOBS%" test-all
+ - nmake -l test-spec
+matrix:
+ fast_finish: true
diff --git a/array.c b/array.c
index 90fa2e06d6..1600e484fe 100644
--- a/array.c
+++ b/array.c
@@ -10,16 +10,15 @@
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/encoding.h"
+
+#include "internal.h"
#include "ruby/util.h"
#include "ruby/st.h"
#include "probes.h"
#include "id.h"
#include "debug_counter.h"
-#include "transient_heap.h"
-#include "internal.h"
-#if !ARRAY_DEBUG
+#ifndef ARRAY_DEBUG
# define NDEBUG
#endif
#include "ruby_assert.h"
@@ -33,50 +32,27 @@ VALUE rb_cArray;
#define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE))
#define SMALL_ARRAY_LEN 16
-static int
-should_be_T_ARRAY(VALUE ary)
-{
- return RB_TYPE_P(ary, T_ARRAY);
-}
-
-static int
-should_not_be_shared_and_embedded(VALUE ary)
-{
- return !FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG);
-}
-
-#define ARY_SHARED_P(ary) \
- (assert(should_be_T_ARRAY((VALUE)(ary))), \
- assert(should_not_be_shared_and_embedded((VALUE)ary)), \
- FL_TEST_RAW((ary),ELTS_SHARED)!=0)
-
-#define ARY_EMBED_P(ary) \
- (assert(should_be_T_ARRAY((VALUE)(ary))), \
- assert(should_not_be_shared_and_embedded((VALUE)ary)), \
- FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0)
+# define ARY_SHARED_P(ary) \
+ (assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \
+ FL_TEST((ary),ELTS_SHARED)!=0)
+# define ARY_EMBED_P(ary) \
+ (assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \
+ FL_TEST((ary), RARRAY_EMBED_FLAG)!=0)
#define ARY_HEAP_PTR(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr)
#define ARY_HEAP_LEN(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len)
-#define ARY_HEAP_CAPA(a) (assert(!ARY_EMBED_P(a)), assert(!ARY_SHARED_ROOT_P(a)), \
- RARRAY(a)->as.heap.aux.capa)
-
#define ARY_EMBED_PTR(a) (assert(ARY_EMBED_P(a)), RARRAY(a)->as.ary)
#define ARY_EMBED_LEN(a) \
(assert(ARY_EMBED_P(a)), \
(long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
(RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT)))
-#define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE))
-
-#define ARY_OWNS_HEAP_P(a) (assert(should_be_T_ARRAY((VALUE)(a))), \
- !FL_TEST_RAW((a), ELTS_SHARED|RARRAY_EMBED_FLAG))
+#define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), RARRAY(a)->as.heap.aux.capa * sizeof(VALUE))
+#define ARY_OWNS_HEAP_P(a) (!FL_TEST((a), ELTS_SHARED|RARRAY_EMBED_FLAG))
#define FL_SET_EMBED(a) do { \
assert(!ARY_SHARED_P(a)); \
FL_SET((a), RARRAY_EMBED_FLAG); \
- RARY_TRANSIENT_UNSET(a); \
- ary_verify(a); \
} while (0)
-
#define FL_UNSET_EMBED(ary) FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK)
#define FL_SET_SHARED(ary) do { \
assert(!ARY_EMBED_P(ary)); \
@@ -125,7 +101,7 @@ should_not_be_shared_and_embedded(VALUE ary)
} while (0)
#define ARY_CAPA(ary) (ARY_EMBED_P(ary) ? RARRAY_EMBED_LEN_MAX : \
- ARY_SHARED_ROOT_P(ary) ? RARRAY_LEN(ary) : ARY_HEAP_CAPA(ary))
+ ARY_SHARED_ROOT_P(ary) ? RARRAY_LEN(ary) : RARRAY(ary)->as.heap.aux.capa)
#define ARY_SET_CAPA(ary, n) do { \
assert(!ARY_EMBED_P(ary)); \
assert(!ARY_SHARED_P(ary)); \
@@ -133,114 +109,33 @@ should_not_be_shared_and_embedded(VALUE ary)
RARRAY(ary)->as.heap.aux.capa = (n); \
} while (0)
-#define ARY_SHARED_ROOT(ary) (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared_root)
+#define ARY_SHARED(ary) (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared)
#define ARY_SET_SHARED(ary, value) do { \
const VALUE _ary_ = (ary); \
const VALUE _value_ = (value); \
assert(!ARY_EMBED_P(_ary_)); \
assert(ARY_SHARED_P(_ary_)); \
assert(ARY_SHARED_ROOT_P(_value_)); \
- RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared_root, _value_); \
+ RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared, _value_); \
} while (0)
#define RARRAY_SHARED_ROOT_FLAG FL_USER5
-#define ARY_SHARED_ROOT_P(ary) (assert(should_be_T_ARRAY((VALUE)(ary))), \
- FL_TEST_RAW((ary), RARRAY_SHARED_ROOT_FLAG))
-#define ARY_SHARED_ROOT_REFCNT(ary) \
+#define ARY_SHARED_ROOT_P(ary) (FL_TEST((ary), RARRAY_SHARED_ROOT_FLAG))
+#define ARY_SHARED_NUM(ary) \
(assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa)
-#define ARY_SHARED_ROOT_OCCUPIED(ary) (ARY_SHARED_ROOT_REFCNT(ary) == 1)
-#define ARY_SET_SHARED_ROOT_REFCNT(ary, value) do { \
+#define ARY_SHARED_OCCUPIED(ary) (ARY_SHARED_NUM(ary) == 1)
+#define ARY_SET_SHARED_NUM(ary, value) do { \
assert(ARY_SHARED_ROOT_P(ary)); \
RARRAY(ary)->as.heap.aux.capa = (value); \
} while (0)
#define FL_SET_SHARED_ROOT(ary) do { \
assert(!ARY_EMBED_P(ary)); \
- assert(!RARRAY_TRANSIENT_P(ary)); \
FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \
} while (0)
-static inline void
-ARY_SET(VALUE a, long i, VALUE v)
-{
- assert(!ARY_SHARED_P(a));
- assert(!OBJ_FROZEN(a));
-
- RARRAY_ASET(a, i, v);
-}
-#undef RARRAY_ASET
-
-
-#if ARRAY_DEBUG
-#define ary_verify(ary) ary_verify_(ary, __FILE__, __LINE__)
-
-static VALUE
-ary_verify_(VALUE ary, const char *file, int line)
-{
- assert(RB_TYPE_P(ary, T_ARRAY));
-
- if (FL_TEST(ary, ELTS_SHARED)) {
- VALUE root = RARRAY(ary)->as.heap.aux.shared_root;
- const VALUE *ptr = ARY_HEAP_PTR(ary);
- const VALUE *root_ptr = RARRAY_CONST_PTR_TRANSIENT(root);
- long len = ARY_HEAP_LEN(ary), root_len = RARRAY_LEN(root);
- assert(FL_TEST(root, RARRAY_SHARED_ROOT_FLAG));
- assert(root_ptr <= ptr && ptr + len <= root_ptr + root_len);
- ary_verify(root);
- }
- else if (ARY_EMBED_P(ary)) {
- assert(!RARRAY_TRANSIENT_P(ary));
- assert(!ARY_SHARED_P(ary));
- assert(RARRAY_LEN(ary) <= RARRAY_EMBED_LEN_MAX);
- }
- else {
-#if 1
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
- long i, len = RARRAY_LEN(ary);
- volatile VALUE v;
- if (len > 1) len = 1; /* check only HEAD */
- for (i=0; i<len; i++) {
- v = ptr[i]; /* access check */
- }
- v = v;
-#endif
- }
-
- if (RARRAY_TRANSIENT_P(ary)) {
- assert(rb_transient_heap_managed_ptr_p(RARRAY_CONST_PTR_TRANSIENT(ary)));
- }
-
- rb_transient_heap_verify();
-
- return ary;
-}
+#define ARY_SET(a, i, v) RARRAY_ASET((assert(!ARY_SHARED_P(a)), (a)), (i), (v))
void
-rb_ary_verify(VALUE ary)
-{
- ary_verify(ary);
-}
-#else
-#define ary_verify(ary) ((void)0)
-#endif
-
-VALUE *
-rb_ary_ptr_use_start(VALUE ary)
-{
-#if ARRAY_DEBUG
- FL_SET_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
-#endif
- return (VALUE *)RARRAY_CONST_PTR_TRANSIENT(ary);
-}
-
-void
-rb_ary_ptr_use_end(VALUE ary)
-{
-#if ARRAY_DEBUG
- FL_UNSET_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
-#endif
-}
-
-void
-rb_mem_clear(VALUE *mem, long size)
+rb_mem_clear(register VALUE *mem, register long size)
{
while (size--) {
*mem++ = Qnil;
@@ -250,7 +145,7 @@ rb_mem_clear(VALUE *mem, long size)
static void
ary_mem_clear(VALUE ary, long beg, long size)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
rb_mem_clear(ptr + beg, size);
});
}
@@ -266,7 +161,7 @@ memfill(register VALUE *mem, register long size, register VALUE val)
static void
ary_memfill(VALUE ary, long beg, long size, VALUE val)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
memfill(ptr + beg, size, val);
RB_OBJ_WRITTEN(ary, Qundef, val);
});
@@ -275,22 +170,28 @@ ary_memfill(VALUE ary, long beg, long size, VALUE val)
static void
ary_memcpy0(VALUE ary, long beg, long argc, const VALUE *argv, VALUE buff_owner_ary)
{
+#if 1
assert(!ARY_SHARED_P(buff_owner_ary));
if (argc > (int)(128/sizeof(VALUE)) /* is magic number (cache line size) */) {
- rb_gc_writebarrier_remember(buff_owner_ary);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
- MEMCPY(ptr+beg, argv, VALUE, argc);
- });
+ rb_gc_writebarrier_remember(buff_owner_ary);
+ RARRAY_PTR_USE(ary, ptr, {
+ MEMCPY(ptr+beg, argv, VALUE, argc);
+ });
}
else {
- int i;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
- for (i=0; i<argc; i++) {
- RB_OBJ_WRITE(buff_owner_ary, &ptr[i+beg], argv[i]);
- }
- });
+ int i;
+ RARRAY_PTR_USE(ary, ptr, {
+ for (i=0; i<argc; i++) {
+ RB_OBJ_WRITE(buff_owner_ary, &ptr[i+beg], argv[i]);
+ }
+ });
}
+#else
+ /* giveup write barrier (traditional way) */
+ RARRAY_PTR(buff_owner_ary);
+ MEMCPY(RARRAY_PTR(ary)+beg, argv, VALUE, argc);
+#endif
}
static void
@@ -299,175 +200,49 @@ ary_memcpy(VALUE ary, long beg, long argc, const VALUE *argv)
ary_memcpy0(ary, beg, argc, argv, ary);
}
-static VALUE *
-ary_heap_alloc(VALUE ary, size_t capa)
-{
- VALUE *ptr = rb_transient_heap_alloc(ary, sizeof(VALUE) * capa);
-
- if (ptr != NULL) {
- RARY_TRANSIENT_SET(ary);
- }
- else {
- RARY_TRANSIENT_UNSET(ary);
- ptr = ALLOC_N(VALUE, capa);
- }
-
- return ptr;
-}
-
-static void
-ary_heap_free_ptr(VALUE ary, const VALUE *ptr, long size)
-{
- if (RARRAY_TRANSIENT_P(ary)) {
- /* ignore it */
- }
- else {
- ruby_sized_xfree((void *)ptr, size);
- }
-}
-
-static void
-ary_heap_free(VALUE ary)
-{
- if (RARRAY_TRANSIENT_P(ary)) {
- RARY_TRANSIENT_UNSET(ary);
- }
- else {
- ary_heap_free_ptr(ary, ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
- }
-}
-
-static void
-ary_heap_realloc(VALUE ary, size_t new_capa)
-{
- size_t old_capa = ARY_HEAP_CAPA(ary);
-
- if (RARRAY_TRANSIENT_P(ary)) {
- if (new_capa <= old_capa) {
- /* do nothing */
- }
- else {
- VALUE *new_ptr = rb_transient_heap_alloc(ary, sizeof(VALUE) * new_capa);
-
- if (new_ptr == NULL) {
- new_ptr = ALLOC_N(VALUE, new_capa);
- RARY_TRANSIENT_UNSET(ary);
- }
-
- MEMCPY(new_ptr, ARY_HEAP_PTR(ary), VALUE, old_capa);
- ARY_SET_PTR(ary, new_ptr);
- }
- }
- else {
- SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, new_capa, old_capa);
- }
- ary_verify(ary);
-}
-
-#if USE_TRANSIENT_HEAP
-static inline void
-rb_ary_transient_heap_evacuate_(VALUE ary, int transient, int promote)
-{
- if (transient) {
- VALUE *new_ptr;
- const VALUE *old_ptr = ARY_HEAP_PTR(ary);
- long capa = ARY_HEAP_CAPA(ary);
- long len = ARY_HEAP_LEN(ary);
-
- if (ARY_SHARED_ROOT_P(ary)) {
- capa = len;
- }
-
- assert(ARY_OWNS_HEAP_P(ary));
- assert(RARRAY_TRANSIENT_P(ary));
- assert(!ARY_PTR_USING_P(ary));
-
- if (promote) {
- new_ptr = ALLOC_N(VALUE, capa);
- RARY_TRANSIENT_UNSET(ary);
- }
- else {
- new_ptr = ary_heap_alloc(ary, capa);
- }
-
- MEMCPY(new_ptr, old_ptr, VALUE, capa);
- /* do not use ARY_SET_PTR() because they assert !frozen */
- RARRAY(ary)->as.heap.ptr = new_ptr;
- }
-
- ary_verify(ary);
-}
-
-void
-rb_ary_transient_heap_evacuate(VALUE ary, int promote)
-{
- rb_ary_transient_heap_evacuate_(ary, RARRAY_TRANSIENT_P(ary), promote);
-}
-
-void
-rb_ary_detransient(VALUE ary)
-{
- assert(RARRAY_TRANSIENT_P(ary));
- rb_ary_transient_heap_evacuate_(ary, TRUE, TRUE);
-}
-#else
-void
-rb_ary_detransient(VALUE ary)
-{
- /* do nothing */
-}
-#endif
-
static void
ary_resize_capa(VALUE ary, long capacity)
{
assert(RARRAY_LEN(ary) <= capacity);
assert(!OBJ_FROZEN(ary));
assert(!ARY_SHARED_P(ary));
-
if (capacity > RARRAY_EMBED_LEN_MAX) {
if (ARY_EMBED_P(ary)) {
long len = ARY_EMBED_LEN(ary);
- VALUE *ptr = ary_heap_alloc(ary, capacity);
-
+ VALUE *ptr = ALLOC_N(VALUE, (capacity));
MEMCPY(ptr, ARY_EMBED_PTR(ary), VALUE, len);
FL_UNSET_EMBED(ary);
ARY_SET_PTR(ary, ptr);
ARY_SET_HEAP_LEN(ary, len);
}
else {
- ary_heap_realloc(ary, capacity);
+ SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, capacity, RARRAY(ary)->as.heap.aux.capa);
}
- ARY_SET_CAPA(ary, capacity);
+ ARY_SET_CAPA(ary, (capacity));
}
else {
if (!ARY_EMBED_P(ary)) {
- long len = ARY_HEAP_LEN(ary);
- long old_capa = ARY_HEAP_CAPA(ary);
- const VALUE *ptr = ARY_HEAP_PTR(ary);
+ long len = RARRAY_LEN(ary);
+ const VALUE *ptr = RARRAY_CONST_PTR(ary);
- if (len > capacity) len = capacity;
+ if (len > capacity) len = capacity;
MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
- ary_heap_free_ptr(ary, ptr, old_capa);
-
FL_SET_EMBED(ary);
ARY_SET_LEN(ary, len);
+ ruby_xfree((VALUE *)ptr);
}
}
-
- ary_verify(ary);
}
static inline void
ary_shrink_capa(VALUE ary)
{
long capacity = ARY_HEAP_LEN(ary);
- long old_capa = ARY_HEAP_CAPA(ary);
+ long old_capa = RARRAY(ary)->as.heap.aux.capa;
assert(!ARY_SHARED_P(ary));
assert(old_capa >= capacity);
- if (old_capa > capacity) ary_heap_realloc(ary, capacity);
-
- ary_verify(ary);
+ if (old_capa > capacity)
+ REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, capacity);
}
static void
@@ -483,21 +258,19 @@ ary_double_capa(VALUE ary, long min)
}
new_capa += min;
ary_resize_capa(ary, new_capa);
-
- ary_verify(ary);
}
static void
-rb_ary_decrement_share(VALUE shared_root)
+rb_ary_decrement_share(VALUE shared)
{
- if (shared_root) {
- long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1;
+ if (shared) {
+ long num = ARY_SHARED_NUM(shared) - 1;
if (num == 0) {
- rb_ary_free(shared_root);
- rb_gc_force_recycle(shared_root);
+ rb_ary_free(shared);
+ rb_gc_force_recycle(shared);
}
else if (num > 0) {
- ARY_SET_SHARED_ROOT_REFCNT(shared_root, num);
+ ARY_SET_SHARED_NUM(shared, num);
}
}
}
@@ -505,8 +278,8 @@ rb_ary_decrement_share(VALUE shared_root)
static void
rb_ary_unshare(VALUE ary)
{
- VALUE shared_root = RARRAY(ary)->as.heap.aux.shared_root;
- rb_ary_decrement_share(shared_root);
+ VALUE shared = RARRAY(ary)->as.heap.aux.shared;
+ rb_ary_decrement_share(shared);
FL_UNSET_SHARED(ary);
}
@@ -519,29 +292,27 @@ rb_ary_unshare_safe(VALUE ary)
}
static VALUE
-rb_ary_increment_share(VALUE shared_root)
+rb_ary_increment_share(VALUE shared)
{
- long num = ARY_SHARED_ROOT_REFCNT(shared_root);
+ long num = ARY_SHARED_NUM(shared);
if (num >= 0) {
- ARY_SET_SHARED_ROOT_REFCNT(shared_root, num + 1);
+ ARY_SET_SHARED_NUM(shared, num + 1);
}
- return shared_root;
+ return shared;
}
static void
-rb_ary_set_shared(VALUE ary, VALUE shared_root)
+rb_ary_set_shared(VALUE ary, VALUE shared)
{
- rb_ary_increment_share(shared_root);
+ rb_ary_increment_share(shared);
FL_SET_SHARED(ary);
- RB_DEBUG_COUNTER_INC(obj_ary_shared_create);
- ARY_SET_SHARED(ary, shared_root);
+ ARY_SET_SHARED(ary, shared);
}
static inline void
rb_ary_modify_check(VALUE ary)
{
rb_check_frozen(ary);
- ary_verify(ary);
}
void
@@ -550,32 +321,29 @@ rb_ary_modify(VALUE ary)
rb_ary_modify_check(ary);
if (ARY_SHARED_P(ary)) {
long shared_len, len = RARRAY_LEN(ary);
- VALUE shared_root = ARY_SHARED_ROOT(ary);
-
- ary_verify(shared_root);
-
+ VALUE shared = ARY_SHARED(ary);
if (len <= RARRAY_EMBED_LEN_MAX) {
const VALUE *ptr = ARY_HEAP_PTR(ary);
FL_UNSET_SHARED(ary);
FL_SET_EMBED(ary);
MEMCPY((VALUE *)ARY_EMBED_PTR(ary), ptr, VALUE, len);
- rb_ary_decrement_share(shared_root);
+ rb_ary_decrement_share(shared);
ARY_SET_EMBED_LEN(ary, len);
}
- else if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && len > ((shared_len = RARRAY_LEN(shared_root))>>1)) {
- long shift = RARRAY_CONST_PTR_TRANSIENT(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root);
+ else if (ARY_SHARED_OCCUPIED(shared) && len > ((shared_len = RARRAY_LEN(shared))>>1)) {
+ long shift = RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared);
FL_UNSET_SHARED(ary);
- ARY_SET_PTR(ary, RARRAY_CONST_PTR_TRANSIENT(shared_root));
+ ARY_SET_PTR(ary, RARRAY_CONST_PTR(shared));
ARY_SET_CAPA(ary, shared_len);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr, ptr+shift, VALUE, len);
});
- FL_SET_EMBED(shared_root);
- rb_ary_decrement_share(shared_root);
+ FL_SET_EMBED(shared);
+ rb_ary_decrement_share(shared);
}
else {
- VALUE *ptr = ary_heap_alloc(ary, len);
- MEMCPY(ptr, ARY_HEAP_PTR(ary), VALUE, len);
+ VALUE *ptr = ALLOC_N(VALUE, len);
+ MEMCPY(ptr, RARRAY_CONST_PTR(ary), VALUE, len);
rb_ary_unshare(ary);
ARY_SET_CAPA(ary, len);
ARY_SET_PTR(ary, ptr);
@@ -583,7 +351,6 @@ rb_ary_modify(VALUE ary)
rb_gc_writebarrier_remember(ary);
}
- ary_verify(ary);
}
static VALUE
@@ -598,14 +365,11 @@ ary_ensure_room_for_push(VALUE ary, long add_len)
}
if (ARY_SHARED_P(ary)) {
if (new_len > RARRAY_EMBED_LEN_MAX) {
- VALUE shared_root = ARY_SHARED_ROOT(ary);
- if (ARY_SHARED_ROOT_OCCUPIED(shared_root)) {
- if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root) + new_len <= RARRAY_LEN(shared_root)) {
+ VALUE shared = ARY_SHARED(ary);
+ if (ARY_SHARED_OCCUPIED(shared)) {
+ if (RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared) + new_len <= RARRAY_LEN(shared)) {
rb_ary_modify_check(ary);
-
- ary_verify(ary);
- ary_verify(shared_root);
- return shared_root;
+ return shared;
}
else {
/* if array is shared, then it is likely it participate in push/shift pattern */
@@ -614,13 +378,11 @@ ary_ensure_room_for_push(VALUE ary, long add_len)
if (new_len > capa - (capa >> 6)) {
ary_double_capa(ary, new_len);
}
- ary_verify(ary);
return ary;
}
}
}
- ary_verify(ary);
- rb_ary_modify(ary);
+ rb_ary_modify(ary);
}
else {
rb_ary_modify_check(ary);
@@ -630,7 +392,6 @@ ary_ensure_room_for_push(VALUE ary, long add_len)
ary_double_capa(ary, new_len);
}
- ary_verify(ary);
return ary;
}
@@ -650,6 +411,21 @@ rb_ary_freeze(VALUE ary)
return rb_obj_freeze(ary);
}
+/*
+ * call-seq:
+ * ary.frozen? -> true or false
+ *
+ * Return +true+ if this array is frozen (or temporarily frozen
+ * while being sorted). See also Object#frozen?
+ */
+
+static VALUE
+rb_ary_frozen_p(VALUE ary)
+{
+ if (OBJ_FROZEN(ary)) return Qtrue;
+ return Qfalse;
+}
+
/* This can be used to take a snapshot of an array (with
e.g. rb_ary_replace) and check later whether the array has been
modified from the snapshot. The snapshot is cheap, though if
@@ -662,7 +438,7 @@ rb_ary_shared_with_p(VALUE ary1, VALUE ary2)
{
if (!ARY_EMBED_P(ary1) && ARY_SHARED_P(ary1) &&
!ARY_EMBED_P(ary2) && ARY_SHARED_P(ary2) &&
- RARRAY(ary1)->as.heap.aux.shared_root == RARRAY(ary2)->as.heap.aux.shared_root &&
+ RARRAY(ary1)->as.heap.aux.shared == RARRAY(ary2)->as.heap.aux.shared &&
RARRAY(ary1)->as.heap.len == RARRAY(ary2)->as.heap.len) {
return Qtrue;
}
@@ -703,7 +479,7 @@ ary_new(VALUE klass, long capa)
ary = ary_alloc(klass);
if (capa > RARRAY_EMBED_LEN_MAX) {
- ptr = ary_heap_alloc(ary, capa);
+ ptr = ALLOC_N(VALUE, capa);
FL_UNSET_EMBED(ary);
ARY_SET_PTR(ary, ptr);
ARY_SET_CAPA(ary, capa);
@@ -744,7 +520,7 @@ VALUE
return ary;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_ary_tmp_new_from_values(VALUE klass, long n, const VALUE *elts)
{
VALUE ary;
@@ -767,9 +543,7 @@ rb_ary_new_from_values(long n, const VALUE *elts)
VALUE
rb_ary_tmp_new(long capa)
{
- VALUE ary = ary_new(0, capa);
- rb_ary_transient_heap_evacuate(ary, TRUE);
- return ary;
+ return ary_new(0, capa);
}
VALUE
@@ -778,7 +552,6 @@ rb_ary_tmp_new_fill(long capa)
VALUE ary = ary_new(0, capa);
ary_memfill(ary, 0, capa, Qnil);
ARY_SET_LEN(ary, capa);
- rb_ary_transient_heap_evacuate(ary, TRUE);
return ary;
}
@@ -786,29 +559,11 @@ void
rb_ary_free(VALUE ary)
{
if (ARY_OWNS_HEAP_P(ary)) {
- if (USE_DEBUG_COUNTER &&
- !ARY_SHARED_ROOT_P(ary) &&
- ARY_HEAP_CAPA(ary) > RARRAY_LEN(ary)) {
- RB_DEBUG_COUNTER_INC(obj_ary_extracapa);
- }
-
- if (RARRAY_TRANSIENT_P(ary)) {
- RB_DEBUG_COUNTER_INC(obj_ary_transient);
- }
- else {
- RB_DEBUG_COUNTER_INC(obj_ary_ptr);
- ary_heap_free(ary);
- }
+ RB_DEBUG_COUNTER_INC(obj_ary_ptr);
+ ruby_sized_xfree((void *)ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
}
else {
- RB_DEBUG_COUNTER_INC(obj_ary_embed);
- }
-
- if (ARY_SHARED_P(ary)) {
- RB_DEBUG_COUNTER_INC(obj_ary_shared);
- }
- if (ARY_SHARED_ROOT_P(ary) && ARY_SHARED_ROOT_OCCUPIED(ary)) {
- RB_DEBUG_COUNTER_INC(obj_ary_shared_root_occupied);
+ RB_DEBUG_COUNTER_INC(obj_ary_embed);
}
}
@@ -828,51 +583,39 @@ ary_discard(VALUE ary)
{
rb_ary_free(ary);
RBASIC(ary)->flags |= RARRAY_EMBED_FLAG;
- RBASIC(ary)->flags &= ~(RARRAY_EMBED_LEN_MASK | RARRAY_TRANSIENT_FLAG);
+ RBASIC(ary)->flags &= ~RARRAY_EMBED_LEN_MASK;
}
static VALUE
ary_make_shared(VALUE ary)
{
assert(!ARY_EMBED_P(ary));
- ary_verify(ary);
-
if (ARY_SHARED_P(ary)) {
- return ARY_SHARED_ROOT(ary);
+ return ARY_SHARED(ary);
}
else if (ARY_SHARED_ROOT_P(ary)) {
return ary;
}
else if (OBJ_FROZEN(ary)) {
- rb_ary_transient_heap_evacuate(ary, TRUE);
ary_shrink_capa(ary);
FL_SET_SHARED_ROOT(ary);
- ARY_SET_SHARED_ROOT_REFCNT(ary, 1);
+ ARY_SET_SHARED_NUM(ary, 1);
return ary;
}
else {
long capa = ARY_CAPA(ary), len = RARRAY_LEN(ary);
- const VALUE *ptr;
NEWOBJ_OF(shared, struct RArray, 0, T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0));
-
- rb_ary_transient_heap_evacuate(ary, TRUE);
- ptr = ARY_HEAP_PTR(ary);
-
FL_UNSET_EMBED(shared);
+
ARY_SET_LEN((VALUE)shared, capa);
- ARY_SET_PTR((VALUE)shared, ptr);
- ary_mem_clear((VALUE)shared, len, capa - len);
+ ARY_SET_PTR((VALUE)shared, RARRAY_CONST_PTR(ary));
+ ary_mem_clear((VALUE)shared, len, capa - len);
FL_SET_SHARED_ROOT(shared);
- ARY_SET_SHARED_ROOT_REFCNT((VALUE)shared, 1);
+ ARY_SET_SHARED_NUM((VALUE)shared, 1);
FL_SET_SHARED(ary);
- RB_DEBUG_COUNTER_INC(obj_ary_shared_create);
ARY_SET_SHARED(ary, (VALUE)shared);
OBJ_FREEZE(shared);
-
- ary_verify((VALUE)shared);
- ary_verify(ary);
-
- return (VALUE)shared;
+ return (VALUE)shared;
}
}
@@ -883,7 +626,7 @@ ary_make_substitution(VALUE ary)
if (len <= RARRAY_EMBED_LEN_MAX) {
VALUE subst = rb_ary_new2(len);
- ary_memcpy(subst, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(subst, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_EMBED_LEN(subst, len);
return subst;
}
@@ -911,18 +654,12 @@ rb_check_array_type(VALUE ary)
return rb_check_convert_type_with_id(ary, T_ARRAY, "Array", idTo_ary);
}
-MJIT_FUNC_EXPORTED VALUE
-rb_check_to_array(VALUE ary)
-{
- return rb_check_convert_type_with_id(ary, T_ARRAY, "Array", idTo_a);
-}
-
/*
* call-seq:
* Array.try_convert(obj) -> array or nil
*
- * Tries to convert +obj+ into an array, using the +to_ary+ method. Returns
- * the converted array or +nil+ if +obj+ cannot be converted.
+ * Tries to convert +obj+ into an array, using +to_ary+ method. Returns the
+ * converted array or +nil+ if +obj+ cannot be converted for any reason.
* This method can be used to check if an argument is an array.
*
* Array.try_convert([1]) #=> [1]
@@ -968,7 +705,7 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary)
* this array is created by passing the element's index to the given block
* and storing the return value.
*
- * Array.new(3) {|index| index ** 2}
+ * Array.new(3){ |index| index ** 2 }
* # => [0, 1, 4]
*
* == Common gotchas
@@ -992,7 +729,7 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary)
* version which uses the result of that block each time an element
* of the array needs to be initialized:
*
- * a = Array.new(2) {Hash.new}
+ * a = Array.new(2) { Hash.new }
* a[0]['cat'] = 'feline'
* a # => [{"cat"=>"feline"}, {}]
*
@@ -1006,8 +743,8 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
rb_ary_modify(ary);
if (argc == 0) {
- if (ARY_OWNS_HEAP_P(ary) && ARY_HEAP_PTR(ary) != NULL) {
- ary_heap_free(ary);
+ if (ARY_OWNS_HEAP_P(ary) && RARRAY_CONST_PTR(ary) != 0) {
+ ruby_sized_xfree((void *)RARRAY_CONST_PTR(ary), ARY_HEAP_SIZE(ary));
}
rb_ary_unshare_safe(ary);
FL_SET_EMBED(ary);
@@ -1058,7 +795,7 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
/*
* Returns a new array populated with the given objects.
*
- * Array.[]( 1, 'a', /^A/) # => [1, "a", /^A/]
+ * Array.[]( 1, 'a', /^A/ ) # => [1, "a", /^A/]
* Array[ 1, 'a', /^A/ ] # => [1, "a", /^A/]
* [ 1, 'a', /^A/ ] # => [1, "a", /^A/]
*/
@@ -1114,7 +851,7 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
if (len <= RARRAY_EMBED_LEN_MAX) {
VALUE result = ary_alloc(klass);
- ary_memcpy(result, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary) + offset);
+ ary_memcpy(result, 0, len, RARRAY_CONST_PTR(ary) + offset);
ARY_SET_EMBED_LEN(result, len);
return result;
}
@@ -1123,15 +860,12 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
FL_UNSET_EMBED(result);
shared = ary_make_shared(ary);
- ARY_SET_PTR(result, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ARY_SET_PTR(result, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(result, RARRAY_LEN(ary));
rb_ary_set_shared(result, shared);
ARY_INCREASE_PTR(result, offset);
ARY_SET_LEN(result, len);
-
- ary_verify(shared);
- ary_verify(result);
return result;
}
}
@@ -1151,17 +885,13 @@ enum ary_take_pos_flags
static VALUE
ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos_flags last)
{
+ VALUE nv;
long n;
long len;
long offset = 0;
- argc = rb_check_arity(argc, 0, 1);
- /* the case optional argument is omitted should be handled in
- * callers of this function. if another arity case is added,
- * this arity check needs to rewrite. */
- RUBY_ASSERT_ALWAYS(argc == 1);
-
- n = NUM2LONG(argv[0]);
+ rb_scan_args(argc, argv, "1", &nv);
+ n = NUM2LONG(nv);
len = RARRAY_LEN(ary);
if (n > len) {
n = len;
@@ -1194,13 +924,12 @@ ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos
VALUE
rb_ary_push(VALUE ary, VALUE item)
{
- long idx = RARRAY_LEN((ary_verify(ary), ary));
+ long idx = RARRAY_LEN(ary);
VALUE target_ary = ary_ensure_room_for_push(ary, 1);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
RB_OBJ_WRITE(target_ary, &ptr[idx], item);
});
ARY_SET_LEN(ary, idx + 1);
- ary_verify(ary);
return ary;
}
@@ -1216,8 +945,7 @@ rb_ary_cat(VALUE ary, const VALUE *argv, long len)
/*
* call-seq:
- * ary.push(obj, ...) -> ary
- * ary.append(obj, ...) -> ary
+ * ary.push(obj, ... ) -> ary
*
* Append --- Pushes the given object(s) on to the end of this array. This
* expression returns the array itself, so several appends
@@ -1252,7 +980,6 @@ rb_ary_pop(VALUE ary)
}
--n;
ARY_SET_LEN(ary, n);
- ary_verify(ary);
return RARRAY_AREF(ary, n);
}
@@ -1286,7 +1013,6 @@ rb_ary_pop_m(int argc, VALUE *argv, VALUE ary)
rb_ary_modify_check(ary);
result = ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST);
ARY_INCREASE_LEN(ary, -RARRAY_LEN(result));
- ary_verify(ary);
return result;
}
@@ -1301,11 +1027,10 @@ rb_ary_shift(VALUE ary)
top = RARRAY_AREF(ary, 0);
if (!ARY_SHARED_P(ary)) {
if (len < ARY_DEFAULT_SIZE) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr, ptr+1, VALUE, len-1);
}); /* WB: no new reference */
ARY_INCREASE_LEN(ary, -1);
- ary_verify(ary);
return top;
}
assert(!ARY_EMBED_P(ary)); /* ARY_EMBED_LEN_MAX < ARY_DEFAULT_SIZE */
@@ -1313,14 +1038,12 @@ rb_ary_shift(VALUE ary)
ARY_SET(ary, 0, Qnil);
ary_make_shared(ary);
}
- else if (ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, ptr[0] = Qnil);
+ else if (ARY_SHARED_OCCUPIED(ARY_SHARED(ary))) {
+ RARRAY_PTR_USE(ary, ptr, ptr[0] = Qnil);
}
ARY_INCREASE_PTR(ary, 1); /* shift ptr */
ARY_INCREASE_LEN(ary, -1);
- ary_verify(ary);
-
return top;
}
@@ -1360,19 +1083,8 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
rb_ary_modify_check(ary);
result = ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST);
n = RARRAY_LEN(result);
- rb_ary_behead(ary,n);
-
- return result;
-}
-
-MJIT_FUNC_EXPORTED VALUE
-rb_ary_behead(VALUE ary, long n)
-{
- if (n<=0) return ary;
-
- rb_ary_modify_check(ary);
if (ARY_SHARED_P(ary)) {
- if (ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))) {
+ if (ARY_SHARED_OCCUPIED(ARY_SHARED(ary))) {
setup_occupied_shared:
ary_mem_clear(ary, 0, n);
}
@@ -1380,8 +1092,8 @@ rb_ary_behead(VALUE ary, long n)
}
else {
if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
- MEMMOVE(ptr, ptr+n, VALUE, RARRAY_LEN(ary)-n);
+ RARRAY_PTR_USE(ary, ptr, {
+ MEMMOVE(ptr, ptr+n, VALUE, RARRAY_LEN(ary)-n);
}); /* WB: no new reference */
}
else {
@@ -1391,8 +1103,7 @@ rb_ary_behead(VALUE ary, long n)
}
ARY_INCREASE_LEN(ary, -n);
- ary_verify(ary);
- return ary;
+ return result;
}
static VALUE
@@ -1407,18 +1118,18 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
rb_raise(rb_eIndexError, "index %ld too big", new_len);
}
+ rb_ary_modify(ary);
+
if (ARY_SHARED_P(ary)) {
- VALUE shared_root = ARY_SHARED_ROOT(ary);
- capa = RARRAY_LEN(shared_root);
- if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && capa > new_len) {
- rb_ary_modify_check(ary);
- head = RARRAY_CONST_PTR_TRANSIENT(ary);
- sharedp = RARRAY_CONST_PTR_TRANSIENT(shared_root);
+ VALUE shared = ARY_SHARED(ary);
+ capa = RARRAY_LEN(shared);
+ if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) {
+ head = RARRAY_CONST_PTR(ary);
+ sharedp = RARRAY_CONST_PTR(shared);
goto makeroom_if_need;
}
}
- rb_ary_modify(ary);
capa = ARY_CAPA(ary);
if (capa - (capa >> 6) <= new_len) {
ary_double_capa(ary, new_len);
@@ -1426,13 +1137,11 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
/* use shared array for big "queues" */
if (new_len > ARY_DEFAULT_SIZE * 4) {
- ary_verify(ary);
-
- /* make a room for unshifted items */
+ /* make a room for unshifted items */
capa = ARY_CAPA(ary);
ary_make_shared(ary);
- head = sharedp = RARRAY_CONST_PTR_TRANSIENT(ary);
+ head = sharedp = RARRAY_CONST_PTR(ary);
goto makeroom;
makeroom_if_need:
if (head - sharedp < argc) {
@@ -1444,18 +1153,15 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
head = sharedp + argc + room;
}
ARY_SET_PTR(ary, head - argc);
- assert(ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary)));
-
- ary_verify(ary);
- return ARY_SHARED_ROOT(ary);
+ assert(ARY_SHARED_OCCUPIED(ARY_SHARED(ary)));
+ return ARY_SHARED(ary);
}
else {
/* sliding items */
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr + argc, ptr, VALUE, len);
});
- ary_verify(ary);
return ary;
}
}
@@ -1463,7 +1169,6 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
/*
* call-seq:
* ary.unshift(obj, ...) -> ary
- * ary.prepend(obj, ...) -> ary
*
* Prepends objects to the front of +self+, moving other elements upwards.
* See also Array#shift for the opposite effect.
@@ -1511,7 +1216,17 @@ rb_ary_elt(VALUE ary, long offset)
VALUE
rb_ary_entry(VALUE ary, long offset)
{
- return rb_ary_entry_internal(ary, offset);
+ long len = RARRAY_LEN(ary);
+ const VALUE *ptr = RARRAY_CONST_PTR(ary);
+ if (len == 0) return Qnil;
+ if (offset < 0) {
+ offset += len;
+ if (offset < 0) return Qnil;
+ }
+ else if (len <= offset) {
+ return Qnil;
+ }
+ return ptr[offset];
}
VALUE
@@ -1532,8 +1247,6 @@ rb_ary_subseq(VALUE ary, long beg, long len)
return ary_make_partial(ary, klass, beg, len);
}
-static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
-
/*
* call-seq:
* ary[index] -> obj or nil
@@ -1591,7 +1304,7 @@ rb_ary_aref2(VALUE ary, VALUE b, VALUE e)
return rb_ary_subseq(ary, beg, len);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_ary_aref1(VALUE ary, VALUE arg)
{
long beg, len;
@@ -1690,7 +1403,7 @@ rb_ary_last(int argc, const VALUE *argv, VALUE ary)
* call-seq:
* ary.fetch(index) -> obj
* ary.fetch(index, default) -> obj
- * ary.fetch(index) {|index| block} -> obj
+ * ary.fetch(index) { |index| block } -> obj
*
* Tries to return the element at position +index+, but throws an IndexError
* exception if the referenced +index+ lies outside of the array bounds. This
@@ -1706,7 +1419,7 @@ rb_ary_last(int argc, const VALUE *argv, VALUE ary)
* a.fetch(1) #=> 22
* a.fetch(-1) #=> 44
* a.fetch(4, 'cat') #=> "cat"
- * a.fetch(100) {|i| puts "#{i} is out of bounds"}
+ * a.fetch(100) { |i| puts "#{i} is out of bounds" }
* #=> "100 is out of bounds"
*/
@@ -1741,10 +1454,10 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
* ary.find_index(obj) -> int or nil
- * ary.find_index {|item| block} -> int or nil
+ * ary.find_index { |item| block } -> int or nil
* ary.find_index -> Enumerator
* ary.index(obj) -> int or nil
- * ary.index {|item| block} -> int or nil
+ * ary.index { |item| block } -> int or nil
* ary.index -> Enumerator
*
* Returns the _index_ of the first object in +ary+ such that the object is
@@ -1761,7 +1474,7 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
* a = [ "a", "b", "c" ]
* a.index("b") #=> 1
* a.index("z") #=> nil
- * a.index {|x| x == "b"} #=> 1
+ * a.index { |x| x == "b" } #=> 1
*/
static VALUE
@@ -1795,7 +1508,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
* ary.rindex(obj) -> int or nil
- * ary.rindex {|item| block} -> int or nil
+ * ary.rindex { |item| block } -> int or nil
* ary.rindex -> Enumerator
*
* Returns the _index_ of the last object in +self+ <code>==</code> to +obj+.
@@ -1813,7 +1526,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
* a = [ "a", "b", "b", "b", "c" ]
* a.rindex("b") #=> 3
* a.rindex("z") #=> nil
- * a.rindex {|x| x == "b"} #=> 3
+ * a.rindex { |x| x == "b" } #=> 3
*/
static VALUE
@@ -1842,9 +1555,6 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary)
if (rb_equal(e, val)) {
return LONG2NUM(i);
}
- if (i > RARRAY_LEN(ary)) {
- break;
- }
}
return Qnil;
}
@@ -1878,7 +1588,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
}
{
- const VALUE *optr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *optr = RARRAY_CONST_PTR(ary);
rofs = (rptr >= optr && rptr < optr + olen) ? rptr - optr : -1;
}
@@ -1891,7 +1601,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
len = beg + rlen;
ary_mem_clear(ary, olen, beg - olen);
if (rlen > 0) {
- if (rofs != -1) rptr = RARRAY_CONST_PTR_TRANSIENT(ary) + rofs;
+ if (rofs != -1) rptr = RARRAY_CONST_PTR(ary) + rofs;
ary_memcpy0(ary, beg, rlen, rptr, target_ary);
}
ARY_SET_LEN(ary, len);
@@ -1909,21 +1619,14 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
}
if (len != rlen) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
- MEMMOVE(ptr + beg + rlen, ptr + beg + len,
- VALUE, olen - (beg + len)));
+ RARRAY_PTR_USE(ary, ptr,
+ MEMMOVE(ptr + beg + rlen, ptr + beg + len,
+ VALUE, olen - (beg + len)));
ARY_SET_LEN(ary, alen);
}
if (rlen > 0) {
- if (rofs != -1) rptr = RARRAY_CONST_PTR_TRANSIENT(ary) + rofs;
- /* give up wb-protected ary */
- RB_OBJ_WB_UNPROTECT_FOR(ARRAY, ary);
-
- /* do not use RARRAY_PTR() because it can causes GC.
- * ary can contain T_NONE object because it is not cleared.
- */
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
- MEMMOVE(ptr + beg, rptr, VALUE, rlen));
+ if (rofs != -1) rptr = RARRAY_CONST_PTR(ary) + rofs;
+ MEMMOVE(RARRAY_PTR(ary) + beg, rptr, VALUE, rlen);
}
}
}
@@ -1981,12 +1684,11 @@ rb_ary_resize(VALUE ary, long len)
}
else {
if (olen > len + ARY_DEFAULT_SIZE) {
- ary_heap_realloc(ary, len);
+ SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, len, RARRAY(ary)->as.heap.aux.capa);
ARY_SET_CAPA(ary, len);
}
ARY_SET_HEAP_LEN(ary, len);
}
- ary_verify(ary);
return ary;
}
@@ -2047,7 +1749,7 @@ rb_ary_aset(int argc, VALUE *argv, VALUE ary)
/* check if idx is Range */
range:
rpl = rb_ary_to_ary(argv[argc-1]);
- rb_ary_splice(ary, beg, len, RARRAY_CONST_PTR_TRANSIENT(rpl), RARRAY_LEN(rpl));
+ rb_ary_splice(ary, beg, len, RARRAY_CONST_PTR(rpl), RARRAY_LEN(rpl));
RB_GC_GUARD(rpl);
return argv[argc-1];
}
@@ -2109,7 +1811,7 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * ary.each {|item| block} -> ary
+ * ary.each { |item| block } -> ary
* ary.each -> Enumerator
*
* Calls the given block once for each element in +self+, passing that element
@@ -2129,7 +1831,7 @@ VALUE
rb_ary_each(VALUE ary)
{
long i;
- ary_verify(ary);
+
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
for (i=0; i<RARRAY_LEN(ary); i++) {
rb_yield(RARRAY_AREF(ary, i));
@@ -2139,7 +1841,7 @@ rb_ary_each(VALUE ary)
/*
* call-seq:
- * ary.each_index {|index| block} -> ary
+ * ary.each_index { |index| block } -> ary
* ary.each_index -> Enumerator
*
* Same as Array#each, but passes the +index+ of the element instead of the
@@ -2169,7 +1871,7 @@ rb_ary_each_index(VALUE ary)
/*
* call-seq:
- * ary.reverse_each {|item| block} -> ary
+ * ary.reverse_each { |item| block } -> ary
* ary.reverse_each -> Enumerator
*
* Same as Array#each, but traverses +self+ in reverse order.
@@ -2239,18 +1941,15 @@ rb_ary_dup(VALUE ary)
{
long len = RARRAY_LEN(ary);
VALUE dup = rb_ary_new2(len);
- ary_memcpy(dup, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(dup, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(dup, len);
-
- ary_verify(ary);
- ary_verify(dup);
return dup;
}
VALUE
rb_ary_resurrect(VALUE ary)
{
- return ary_make_partial(ary, rb_cArray, 0, RARRAY_LEN(ary));
+ return rb_ary_new4(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
}
extern VALUE rb_output_fs;
@@ -2287,6 +1986,7 @@ ary_join_0(VALUE ary, VALUE sep, long max, VALUE result)
if (i > 0 && !NIL_P(sep))
rb_str_buf_append(result, sep);
rb_str_buf_append(result, val);
+ if (OBJ_TAINTED(val)) OBJ_TAINT(result);
}
}
@@ -2347,9 +2047,11 @@ VALUE
rb_ary_join(VALUE ary, VALUE sep)
{
long len = 1, i;
+ int taint = FALSE;
VALUE val, tmp, result;
if (RARRAY_LEN(ary) == 0) return rb_usascii_str_new(0, 0);
+ if (OBJ_TAINTED(ary)) taint = TRUE;
if (!NIL_P(sep)) {
StringValue(sep);
@@ -2363,6 +2065,7 @@ rb_ary_join(VALUE ary, VALUE sep)
int first;
result = rb_str_buf_new(len + (RARRAY_LEN(ary)-i)*10);
rb_enc_associate(result, rb_usascii_encoding());
+ if (taint) OBJ_TAINT(result);
ary_join_0(ary, sep, i, result);
first = i == 0;
ary_join_1(ary, ary, sep, i, result, &first);
@@ -2372,9 +2075,8 @@ rb_ary_join(VALUE ary, VALUE sep)
len += RSTRING_LEN(tmp);
}
- result = rb_str_new(0, len);
- rb_str_set_len(result, 0);
-
+ result = rb_str_buf_new(len);
+ if (taint) OBJ_TAINT(result);
ary_join_0(ary, sep, RARRAY_LEN(ary), result);
return result;
@@ -2403,12 +2105,8 @@ rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
{
VALUE sep;
- if (rb_check_arity(argc, 0, 1) == 0 || NIL_P(sep = argv[0])) {
- sep = rb_output_fs;
- if (!NIL_P(sep)) {
- rb_warn("$, is set to non-nil value");
- }
- }
+ rb_scan_args(argc, argv, "01", &sep);
+ if (NIL_P(sep)) sep = rb_output_fs;
return rb_ary_join(ary, sep);
}
@@ -2416,6 +2114,7 @@ rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
static VALUE
inspect_ary(VALUE ary, VALUE dummy, int recur)
{
+ int tainted = OBJ_TAINTED(ary);
long i;
VALUE s, str;
@@ -2423,11 +2122,13 @@ inspect_ary(VALUE ary, VALUE dummy, int recur)
str = rb_str_buf_new2("[");
for (i=0; i<RARRAY_LEN(ary); i++) {
s = rb_inspect(RARRAY_AREF(ary, i));
+ if (OBJ_TAINTED(s)) tainted = TRUE;
if (i > 0) rb_str_buf_cat2(str, ", ");
else rb_enc_copy(str, s);
rb_str_buf_append(str, s);
}
rb_str_buf_cat2(str, "]");
+ if (tainted) OBJ_TAINT(str);
return str;
}
@@ -2436,8 +2137,7 @@ inspect_ary(VALUE ary, VALUE dummy, int recur)
* ary.inspect -> string
* ary.to_s -> string
*
- * Creates a string representation of +self+, by calling #inspect
- * on each element.
+ * Creates a string representation of +self+.
*
* [ "a", "b", "c" ].to_s #=> "[\"a\", \"b\", \"c\"]"
*/
@@ -2477,20 +2177,13 @@ rb_ary_to_a(VALUE ary)
/*
* call-seq:
- * ary.to_h -> hash
- * ary.to_h {|item| block } -> hash
+ * ary.to_h -> hash
*
* Returns the result of interpreting <i>ary</i> as an array of
* <tt>[key, value]</tt> pairs.
*
* [[:foo, :bar], [1, 2]].to_h
* # => {:foo => :bar, 1 => 2}
- *
- * If a block is given, the results of the block on each element of
- * the array will be used as pairs.
- *
- * ["foo", "bar"].to_h {|s| [s.ord, s]}
- * # => {102=>"foo", 98=>"bar"}
*/
static VALUE
@@ -2498,11 +2191,8 @@ rb_ary_to_h(VALUE ary)
{
long i;
VALUE hash = rb_hash_new_with_size(RARRAY_LEN(ary));
- int block_given = rb_block_given_p();
-
for (i=0; i<RARRAY_LEN(ary); i++) {
- const VALUE e = rb_ary_elt(ary, i);
- const VALUE elt = block_given ? rb_yield_force_blockarg(e) : e;
+ const VALUE elt = rb_ary_elt(ary, i);
const VALUE key_value_pair = rb_check_array_type(elt);
if (NIL_P(key_value_pair)) {
rb_raise(rb_eTypeError, "wrong element type %"PRIsVALUE" at %ld (expected array)",
@@ -2548,9 +2238,9 @@ rb_ary_reverse(VALUE ary)
rb_ary_modify(ary);
if (len > 1) {
- RARRAY_PTR_USE_TRANSIENT(ary, p1, {
- p2 = p1 + len - 1; /* points last item */
- ary_reverse(p1, p2);
+ RARRAY_PTR_USE(ary, p1, {
+ p2 = p1 + len - 1; /* points last item */
+ ary_reverse(p1, p2);
}); /* WB: no new reference */
}
return ary;
@@ -2590,8 +2280,8 @@ rb_ary_reverse_m(VALUE ary)
VALUE dup = rb_ary_new2(len);
if (len > 0) {
- const VALUE *p1 = RARRAY_CONST_PTR_TRANSIENT(ary);
- VALUE *p2 = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(dup) + len - 1;
+ const VALUE *p1 = RARRAY_CONST_PTR(ary);
+ VALUE *p2 = (VALUE *)RARRAY_CONST_PTR(dup) + len - 1;
do *p2-- = *p1++; while (--len > 0);
}
ARY_SET_LEN(dup, RARRAY_LEN(ary));
@@ -2604,27 +2294,24 @@ rotate_count(long cnt, long len)
return (cnt < 0) ? (len - (~cnt % len) - 1) : (cnt % len);
}
-static void
-ary_rotate_ptr(VALUE *ptr, long len, long cnt)
-{
- --len;
- if (cnt < len) ary_reverse(ptr + cnt, ptr + len);
- if (--cnt > 0) ary_reverse(ptr, ptr + cnt);
- if (len > 0) ary_reverse(ptr, ptr + len);
-}
-
VALUE
rb_ary_rotate(VALUE ary, long cnt)
{
rb_ary_modify(ary);
if (cnt != 0) {
- long len = RARRAY_LEN(ary);
- if (len > 0 && (cnt = rotate_count(cnt, len)) > 0) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, ary_rotate_ptr(ptr, len, cnt));
- return ary;
- }
+ VALUE *ptr = RARRAY_PTR(ary);
+ long len = RARRAY_LEN(ary);
+
+ if (len > 0 && (cnt = rotate_count(cnt, len)) > 0) {
+ --len;
+ if (cnt < len) ary_reverse(ptr + cnt, ptr + len);
+ if (--cnt > 0) ary_reverse(ptr, ptr + cnt);
+ if (len > 0) ary_reverse(ptr, ptr + len);
+ return ary;
+ }
}
+
return Qnil;
}
@@ -2648,7 +2335,13 @@ rb_ary_rotate(VALUE ary, long cnt)
static VALUE
rb_ary_rotate_bang(int argc, VALUE *argv, VALUE ary)
{
- long n = (rb_check_arity(argc, 0, 1) ? NUM2LONG(argv[0]) : 1);
+ long n = 1;
+
+ switch (argc) {
+ case 1: n = NUM2LONG(argv[0]);
+ case 0: break;
+ default: rb_scan_args(argc, argv, "01", NULL);
+ }
rb_ary_rotate(ary, n);
return ary;
}
@@ -2675,14 +2368,19 @@ rb_ary_rotate_m(int argc, VALUE *argv, VALUE ary)
{
VALUE rotated;
const VALUE *ptr;
- long len;
- long cnt = (rb_check_arity(argc, 0, 1) ? NUM2LONG(argv[0]) : 1);
+ long len, cnt = 1;
+
+ switch (argc) {
+ case 1: cnt = NUM2LONG(argv[0]);
+ case 0: break;
+ default: rb_scan_args(argc, argv, "01", NULL);
+ }
len = RARRAY_LEN(ary);
rotated = rb_ary_new2(len);
if (len > 0) {
cnt = rotate_count(cnt, len);
- ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ ptr = RARRAY_CONST_PTR(ary);
len -= cnt;
ary_memcpy(rotated, 0, len, ptr + cnt);
ary_memcpy(rotated, len, cnt, ptr);
@@ -2752,7 +2450,7 @@ sort_2(const void *ap, const void *bp, void *dummy)
/*
* call-seq:
* ary.sort! -> ary
- * ary.sort! {|a, b| block} -> ary
+ * ary.sort! { |a, b| block } -> ary
*
* Sorts +self+ in place.
*
@@ -2768,7 +2466,7 @@ sort_2(const void *ap, const void *bp, void *dummy)
*
* ary = [ "d", "a", "e", "c", "b" ]
* ary.sort! #=> ["a", "b", "c", "d", "e"]
- * ary.sort! {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"]
+ * ary.sort! { |a, b| b <=> a } #=> ["e", "d", "c", "b", "a"]
*
* See also Enumerable#sort_by.
*/
@@ -2782,13 +2480,14 @@ rb_ary_sort_bang(VALUE ary)
VALUE tmp = ary_make_substitution(ary); /* only ary refers tmp */
struct ary_sort_data data;
long len = RARRAY_LEN(ary);
+
RBASIC_CLEAR_CLASS(tmp);
data.ary = tmp;
data.cmp_opt.opt_methods = 0;
data.cmp_opt.opt_inited = 0;
RARRAY_PTR_USE(tmp, ptr, {
- ruby_qsort(ptr, len, sizeof(VALUE),
- rb_block_given_p()?sort_1:sort_2, &data);
+ ruby_qsort(ptr, len, sizeof(VALUE),
+ rb_block_given_p()?sort_1:sort_2, &data);
}); /* WB: no new reference */
rb_ary_modify(ary);
if (ARY_EMBED_P(tmp)) {
@@ -2814,29 +2513,28 @@ rb_ary_sort_bang(VALUE ary)
rb_ary_unshare(ary);
}
else {
- ary_heap_free(ary);
+ ruby_sized_xfree((void *)ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
}
- ARY_SET_PTR(ary, ARY_HEAP_PTR(tmp));
+ ARY_SET_PTR(ary, RARRAY_CONST_PTR(tmp));
ARY_SET_HEAP_LEN(ary, len);
- ARY_SET_CAPA(ary, ARY_HEAP_LEN(tmp));
+ ARY_SET_CAPA(ary, RARRAY_LEN(tmp));
}
/* tmp was lost ownership for the ptr */
FL_UNSET(tmp, FL_FREEZE);
FL_SET_EMBED(tmp);
ARY_SET_EMBED_LEN(tmp, 0);
FL_SET(tmp, FL_FREEZE);
- }
+ }
/* tmp will be GC'ed. */
RBASIC_SET_CLASS_RAW(tmp, rb_cArray); /* rb_cArray must be marked */
}
- ary_verify(ary);
return ary;
}
/*
* call-seq:
* ary.sort -> new_ary
- * ary.sort {|a, b| block} -> new_ary
+ * ary.sort { |a, b| block } -> new_ary
*
* Returns a new array created by sorting +self+.
*
@@ -2852,12 +2550,7 @@ rb_ary_sort_bang(VALUE ary)
*
* ary = [ "d", "a", "e", "c", "b" ]
* ary.sort #=> ["a", "b", "c", "d", "e"]
- * ary.sort {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"]
- *
- * To produce the reverse order, the following can also be used
- * (and may be faster):
- *
- * ary.sort.reverse! #=> ["e", "d", "c", "b", "a"]
+ * ary.sort { |a, b| b <=> a } #=> ["e", "d", "c", "b", "a"]
*
* See also Enumerable#sort_by.
*/
@@ -3005,7 +2698,7 @@ sort_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, dummy))
/*
* call-seq:
- * ary.sort_by! {|obj| block} -> ary
+ * ary.sort_by! { |obj| block } -> ary
* ary.sort_by! -> Enumerator
*
* Sorts +self+ in place using a set of keys generated by mapping the
@@ -3034,8 +2727,8 @@ rb_ary_sort_by_bang(VALUE ary)
/*
* call-seq:
- * ary.collect {|item| block} -> new_ary
- * ary.map {|item| block} -> new_ary
+ * ary.collect { |item| block } -> new_ary
+ * ary.map { |item| block } -> new_ary
* ary.collect -> Enumerator
* ary.map -> Enumerator
*
@@ -3048,8 +2741,8 @@ rb_ary_sort_by_bang(VALUE ary)
* If no block is given, an Enumerator is returned instead.
*
* a = [ "a", "b", "c", "d" ]
- * a.collect {|x| x + "!"} #=> ["a!", "b!", "c!", "d!"]
- * a.map.with_index {|x, i| x * i} #=> ["", "b", "cc", "ddd"]
+ * a.collect { |x| x + "!" } #=> ["a!", "b!", "c!", "d!"]
+ * a.map.with_index { |x, i| x * i } #=> ["", "b", "cc", "ddd"]
* a #=> ["a", "b", "c", "d"]
*/
@@ -3062,7 +2755,7 @@ rb_ary_collect(VALUE ary)
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
collect = rb_ary_new2(RARRAY_LEN(ary));
for (i = 0; i < RARRAY_LEN(ary); i++) {
- rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i)));
+ rb_ary_push(collect, rb_yield_force_blockarg(RARRAY_AREF(ary, i)));
}
return collect;
}
@@ -3128,34 +2821,6 @@ rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE (*func
return result;
}
-static VALUE
-append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx)
-{
- long beg, len;
- if (FIXNUM_P(idx)) {
- beg = FIX2LONG(idx);
- }
- /* check if idx is Range */
- else if (rb_range_beg_len(idx, &beg, &len, olen, 1)) {
- if (len > 0) {
- const VALUE *const src = RARRAY_CONST_PTR_TRANSIENT(ary);
- const long end = beg + len;
- const long prevlen = RARRAY_LEN(result);
- if (beg < olen) {
- rb_ary_cat(result, src + beg, end > olen ? olen-beg : len);
- }
- if (end > olen) {
- rb_ary_store(result, prevlen + len - 1, Qnil);
- }
- }
- return result;
- }
- else {
- beg = NUM2LONG(idx);
- }
- return rb_ary_push(result, rb_ary_entry(ary, beg));
-}
-
/*
* call-seq:
* ary.values_at(selector, ...) -> new_ary
@@ -3177,36 +2842,26 @@ append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx)
static VALUE
rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
{
- long i, olen = RARRAY_LEN(ary);
- VALUE result = rb_ary_new_capa(argc);
- for (i = 0; i < argc; ++i) {
- append_values_at_single(result, ary, olen, argv[i]);
- }
- RB_GC_GUARD(ary);
- return result;
+ return rb_get_values_at(ary, RARRAY_LEN(ary), argc, argv, rb_ary_entry);
}
/*
* call-seq:
- * ary.select {|item| block} -> new_ary
+ * ary.select { |item| block } -> new_ary
* ary.select -> Enumerator
- * ary.filter {|item| block} -> new_ary
- * ary.filter -> Enumerator
*
* Returns a new array containing all elements of +ary+
* for which the given +block+ returns a true value.
*
* If no block is given, an Enumerator is returned instead.
*
- * [1,2,3,4,5].select {|num| num.even? } #=> [2, 4]
+ * [1,2,3,4,5].select { |num| num.even? } #=> [2, 4]
*
- * a = %w[ a b c d e f ]
- * a.select {|v| v =~ /[aeiou]/ } #=> ["a", "e"]
+ * a = %w{ a b c d e f }
+ * a.select { |v| v =~ /[aeiou]/ } #=> ["a", "e"]
*
* See also Enumerable#select.
- *
- * Array#filter is an alias for Array#select.
*/
static VALUE
@@ -3260,7 +2915,7 @@ select_bang_ensure(VALUE a)
long tail = 0;
if (i1 < len) {
tail = len - i1;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr + i2, ptr + i1, VALUE, tail);
});
}
@@ -3271,10 +2926,8 @@ select_bang_ensure(VALUE a)
/*
* call-seq:
- * ary.select! {|item| block } -> ary or nil
- * ary.select! -> Enumerator
- * ary.filter! {|item| block } -> ary or nil
- * ary.filter! -> Enumerator
+ * ary.select! {|item| block } -> ary or nil
+ * ary.select! -> Enumerator
*
* Invokes the given block passing in successive elements from +self+,
* deleting elements for which the block returns a +false+ value.
@@ -3283,11 +2936,10 @@ select_bang_ensure(VALUE a)
*
* If changes were made, it will return +self+, otherwise it returns +nil+.
*
- * If no block is given, an Enumerator is returned instead.
+ * See also Array#keep_if
*
- * See also Array#keep_if.
+ * If no block is given, an Enumerator is returned instead.
*
- * Array#filter! is an alias for Array#select!.
*/
static VALUE
@@ -3305,19 +2957,18 @@ rb_ary_select_bang(VALUE ary)
/*
* call-seq:
- * ary.keep_if {|item| block} -> ary
+ * ary.keep_if { |item| block } -> ary
* ary.keep_if -> Enumerator
*
* Deletes every element of +self+ for which the given block evaluates to
- * +false+, and returns +self+.
+ * +false+.
*
- * If no block is given, an Enumerator is returned instead.
+ * See also Array#select!
*
- * a = %w[ a b c d e f ]
- * a.keep_if {|v| v =~ /[aeiou]/ } #=> ["a", "e"]
- * a #=> ["a", "e"]
+ * If no block is given, an Enumerator is returned instead.
*
- * See also Array#select!.
+ * a = %w{ a b c d e f }
+ * a.keep_if { |v| v =~ /[aeiou]/ } #=> ["a", "e"]
*/
static VALUE
@@ -3344,7 +2995,7 @@ ary_resize_smaller(VALUE ary, long len)
/*
* call-seq:
* ary.delete(obj) -> item or nil
- * ary.delete(obj) {block} -> item or result of block
+ * ary.delete(obj) { block } -> item or result of block
*
* Deletes all items from +self+ that are equal to +obj+.
*
@@ -3358,7 +3009,7 @@ ary_resize_smaller(VALUE ary, long len)
* a.delete("b") #=> "b"
* a #=> ["a", "c"]
* a.delete("z") #=> nil
- * a.delete("z") {"not found"} #=> "not found"
+ * a.delete("z") { "not found" } #=> "not found"
*/
VALUE
@@ -3388,7 +3039,6 @@ rb_ary_delete(VALUE ary, VALUE item)
ary_resize_smaller(ary, i2);
- ary_verify(ary);
return v;
}
@@ -3429,11 +3079,11 @@ rb_ary_delete_at(VALUE ary, long pos)
rb_ary_modify(ary);
del = RARRAY_AREF(ary, pos);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
- MEMMOVE(ptr+pos, ptr+pos+1, VALUE, len-pos-1);
+ RARRAY_PTR_USE(ary, ptr, {
+ MEMMOVE(ptr+pos, ptr+pos+1, VALUE, len-pos-1);
});
ARY_INCREASE_LEN(ary, -1);
- ary_verify(ary);
+
return del;
}
@@ -3501,13 +3151,16 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
len = orig_len - pos;
}
if (len == 0) return rb_ary_new2(0);
- arg2 = rb_ary_new4(len, RARRAY_CONST_PTR_TRANSIENT(ary)+pos);
+ arg2 = rb_ary_new4(len, RARRAY_CONST_PTR(ary)+pos);
RBASIC_SET_CLASS(arg2, rb_obj_class(ary));
rb_ary_splice(ary, pos, len, 0, 0);
return arg2;
}
- rb_check_arity(argc, 1, 2);
+ if (argc != 1) {
+ /* error report */
+ rb_scan_args(argc, argv, "11", NULL, NULL);
+ }
arg1 = argv[0];
if (!FIXNUM_P(arg1)) {
@@ -3534,8 +3187,7 @@ ary_reject(VALUE orig, VALUE result)
for (i = 0; i < RARRAY_LEN(orig); i++) {
VALUE v = RARRAY_AREF(orig, i);
-
- if (!RTEST(rb_yield(v))) {
+ if (!RTEST(rb_yield(v))) {
rb_ary_push(result, v);
}
}
@@ -3564,6 +3216,7 @@ static VALUE
ary_reject_bang(VALUE ary)
{
struct select_bang_arg args;
+
rb_ary_modify_check(ary);
args.ary = ary;
args.len[0] = args.len[1] = 0;
@@ -3572,7 +3225,7 @@ ary_reject_bang(VALUE ary)
/*
* call-seq:
- * ary.reject! {|item| block} -> ary or nil
+ * ary.reject! { |item| block } -> ary or nil
* ary.reject! -> Enumerator
*
* Deletes every element of +self+ for which the block evaluates to +true+,
@@ -3619,7 +3272,7 @@ rb_ary_reject(VALUE ary)
/*
* call-seq:
- * ary.delete_if {|item| block} -> ary
+ * ary.delete_if { |item| block } -> ary
* ary.delete_if -> Enumerator
*
* Deletes every element of +self+ for which block evaluates to +true+.
@@ -3638,7 +3291,6 @@ rb_ary_reject(VALUE ary)
static VALUE
rb_ary_delete_if(VALUE ary)
{
- ary_verify(ary);
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
ary_reject_bang(ary);
return ary;
@@ -3648,8 +3300,7 @@ static VALUE
take_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, cbarg))
{
VALUE *args = (VALUE *)cbarg;
- if (args[1] == 0) rb_iter_break();
- else args[1]--;
+ if (args[1]-- == 0) rb_iter_break();
if (argc > 1) val = rb_ary_new4(argc, argv);
rb_ary_push(args[0], val);
return Qnil;
@@ -3674,7 +3325,7 @@ take_items(VALUE obj, long n)
/*
* call-seq:
* ary.zip(arg, ...) -> new_ary
- * ary.zip(arg, ...) {|arr| block} -> nil
+ * ary.zip(arg, ...) { |arr| block } -> nil
*
* Converts any arguments to arrays, then merges elements of +self+ with
* corresponding elements from each argument.
@@ -3815,36 +3466,35 @@ rb_ary_replace(VALUE copy, VALUE orig)
if (copy == orig) return copy;
if (RARRAY_LEN(orig) <= RARRAY_EMBED_LEN_MAX) {
- VALUE shared_root = 0;
+ VALUE shared = 0;
if (ARY_OWNS_HEAP_P(copy)) {
- ary_heap_free(copy);
+ RARRAY_PTR_USE(copy, ptr, ruby_sized_xfree(ptr, ARY_HEAP_SIZE(copy)));
}
else if (ARY_SHARED_P(copy)) {
- shared_root = ARY_SHARED_ROOT(copy);
+ shared = ARY_SHARED(copy);
FL_UNSET_SHARED(copy);
}
FL_SET_EMBED(copy);
- ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig));
- if (shared_root) {
- rb_ary_decrement_share(shared_root);
+ ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR(orig));
+ if (shared) {
+ rb_ary_decrement_share(shared);
}
ARY_SET_LEN(copy, RARRAY_LEN(orig));
}
else {
- VALUE shared_root = ary_make_shared(orig);
+ VALUE shared = ary_make_shared(orig);
if (ARY_OWNS_HEAP_P(copy)) {
- ary_heap_free(copy);
+ RARRAY_PTR_USE(copy, ptr, ruby_sized_xfree(ptr, ARY_HEAP_SIZE(copy)));
}
else {
rb_ary_unshare_safe(copy);
}
FL_UNSET_EMBED(copy);
- ARY_SET_PTR(copy, ARY_HEAP_PTR(orig));
- ARY_SET_LEN(copy, ARY_HEAP_LEN(orig));
- rb_ary_set_shared(copy, shared_root);
+ ARY_SET_PTR(copy, RARRAY_CONST_PTR(orig));
+ ARY_SET_LEN(copy, RARRAY_LEN(orig));
+ rb_ary_set_shared(copy, shared);
}
- ary_verify(copy);
return copy;
}
@@ -3862,20 +3512,16 @@ VALUE
rb_ary_clear(VALUE ary)
{
rb_ary_modify_check(ary);
+ ARY_SET_LEN(ary, 0);
if (ARY_SHARED_P(ary)) {
if (!ARY_EMBED_P(ary)) {
rb_ary_unshare(ary);
FL_SET_EMBED(ary);
- ARY_SET_EMBED_LEN(ary, 0);
}
}
- else {
- ARY_SET_LEN(ary, 0);
- if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
- ary_resize_capa(ary, ARY_DEFAULT_SIZE * 2);
- }
+ else if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
+ ary_resize_capa(ary, ARY_DEFAULT_SIZE * 2);
}
- ary_verify(ary);
return ary;
}
@@ -3883,10 +3529,10 @@ rb_ary_clear(VALUE ary)
* call-seq:
* ary.fill(obj) -> ary
* ary.fill(obj, start [, length]) -> ary
- * ary.fill(obj, range) -> ary
- * ary.fill {|index| block} -> ary
- * ary.fill(start [, length]) {|index| block} -> ary
- * ary.fill(range) {|index| block} -> ary
+ * ary.fill(obj, range ) -> ary
+ * ary.fill { |index| block } -> ary
+ * ary.fill(start [, length] ) { |index| block } -> ary
+ * ary.fill(range) { |index| block } -> ary
*
* The first three forms set the selected elements of +self+ (which
* may be the entire array) to +obj+.
@@ -3905,8 +3551,8 @@ rb_ary_clear(VALUE ary)
* a.fill("x") #=> ["x", "x", "x", "x"]
* a.fill("z", 2, 2) #=> ["x", "x", "z", "z"]
* a.fill("y", 0..1) #=> ["y", "y", "z", "z"]
- * a.fill {|i| i*i} #=> [0, 1, 4, 9]
- * a.fill(-2) {|i| i*i*i} #=> [0, 1, 8, 27]
+ * a.fill { |i| i*i } #=> [0, 1, 4, 9]
+ * a.fill(-2) { |i| i*i*i } #=> [0, 1, 8, 27]
*/
static VALUE
@@ -4008,8 +3654,8 @@ rb_ary_plus(VALUE x, VALUE y)
len = xlen + ylen;
z = rb_ary_new2(len);
- ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR_TRANSIENT(x));
- ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR_TRANSIENT(y));
+ ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR(x));
+ ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR(y));
ARY_SET_LEN(z, len);
return z;
}
@@ -4019,23 +3665,23 @@ ary_append(VALUE x, VALUE y)
{
long n = RARRAY_LEN(y);
if (n > 0) {
- rb_ary_splice(x, RARRAY_LEN(x), 0, RARRAY_CONST_PTR_TRANSIENT(y), n);
+ rb_ary_splice(x, RARRAY_LEN(x), 0, RARRAY_CONST_PTR(y), n);
}
return x;
}
/*
* call-seq:
- * ary.concat(other_ary1, other_ary2, ...) -> ary
+ * ary.concat(other_ary1, other_ary2,...) -> ary
*
- * Appends the elements of <code>other_ary</code>s to +self+.
+ * Appends the elements of +other_ary+s to +self+.
*
- * [ "a", "b" ].concat( ["c", "d"]) #=> [ "a", "b", "c", "d" ]
- * [ "a" ].concat( ["b"], ["c", "d"]) #=> [ "a", "b", "c", "d" ]
+ * [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
+ * [ "a" ].concat( ["b"], ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
* [ "a" ].concat #=> [ "a" ]
*
* a = [ 1, 2, 3 ]
- * a.concat( [ 4, 5 ])
+ * a.concat( [ 4, 5 ] )
* a #=> [ 1, 2, 3, 4, 5 ]
*
* a = [ 1, 2 ]
@@ -4061,7 +3707,6 @@ rb_ary_concat_multi(int argc, VALUE *argv, VALUE ary)
ary_append(ary, args);
}
- ary_verify(ary);
return ary;
}
@@ -4116,19 +3761,21 @@ rb_ary_times(VALUE ary, VALUE times)
ary2 = ary_new(rb_obj_class(ary), len);
ARY_SET_LEN(ary2, len);
- ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ ptr = RARRAY_CONST_PTR(ary);
t = RARRAY_LEN(ary);
if (0 < t) {
ary_memcpy(ary2, 0, t, ptr);
while (t <= len/2) {
- ary_memcpy(ary2, t, t, RARRAY_CONST_PTR_TRANSIENT(ary2));
+ ary_memcpy(ary2, t, t, RARRAY_CONST_PTR(ary2));
t *= 2;
}
if (t < len) {
- ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR_TRANSIENT(ary2));
+ ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR(ary2));
}
}
out:
+ OBJ_INFECT(ary2, ary);
+
return ary2;
}
@@ -4209,7 +3856,6 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur)
if (recur) return Qtrue; /* Subtle! */
- /* rb_equal() can evacuate ptrs */
p1 = RARRAY_CONST_PTR(ary1);
p2 = RARRAY_CONST_PTR(ary2);
len1 = RARRAY_LEN(ary1);
@@ -4222,8 +3868,8 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur)
return Qfalse;
if (len1 < i)
return Qtrue;
- p1 = RARRAY_CONST_PTR(ary1) + i;
- p2 = RARRAY_CONST_PTR(ary2) + i;
+ p1 = RARRAY_CONST_PTR(ary1) + i;
+ p2 = RARRAY_CONST_PTR(ary2) + i;
}
else {
return Qfalse;
@@ -4260,7 +3906,7 @@ rb_ary_equal(VALUE ary1, VALUE ary2)
return rb_equal(ary2, ary1);
}
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
- if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue;
+ if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_equal, ary1, ary2, ary2);
}
@@ -4291,7 +3937,7 @@ rb_ary_eql(VALUE ary1, VALUE ary2)
if (ary1 == ary2) return Qtrue;
if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
- if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue;
+ if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
@@ -4485,11 +4131,11 @@ static inline void
ary_recycle_hash(VALUE hash)
{
assert(RBASIC_CLASS(hash) == 0);
- if (RHASH_ST_TABLE_P(hash)) {
- st_table *tbl = RHASH_ST_TABLE(hash);
+ if (RHASH(hash)->ntbl) {
+ st_table *tbl = RHASH(hash)->ntbl;
st_free_table(tbl);
- RHASH_ST_CLEAR(hash);
}
+ rb_gc_force_recycle(hash);
}
/*
@@ -4498,21 +4144,15 @@ ary_recycle_hash(VALUE hash)
*
* Array Difference
*
- * Returns a new array that is a copy of the original array, removing all
- * occurrences of any item that also appear in +other_ary+. The order is
- * preserved from the original array.
+ * Returns a new array that is a copy of the original array, removing any
+ * items that also appear in +other_ary+. The order is preserved from the
+ * original array.
*
* It compares elements using their #hash and #eql? methods for efficiency.
*
* [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ]
*
- * Note that while 1 and 2 were only present once in the array argument, and
- * were present twice in the receiver array, all occurrences of each Integer are
- * removed in the returned array.
- *
* If you need set-like behavior, see the library class Set.
- *
- * See also Array#difference.
*/
static VALUE
@@ -4536,7 +4176,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
hash = ary_make_hash(ary2);
for (i=0; i<RARRAY_LEN(ary1); i++) {
- if (rb_hash_stlike_lookup(hash, RARRAY_AREF(ary1, i), NULL)) continue;
+ if (st_lookup(rb_hash_tbl_raw(hash), RARRAY_AREF(ary1, i), 0)) continue;
rb_ary_push(ary3, rb_ary_elt(ary1, i));
}
ary_recycle_hash(hash);
@@ -4545,72 +4185,6 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
/*
* call-seq:
- * ary.difference(other_ary1, other_ary2, ...) -> new_ary
- *
- * Array Difference
- *
- * Returns a new array that is a copy of the original array, removing all
- * occurrences of any item that also appear in +other_ary+. The order is
- * preserved from the original array.
- *
- * It compares elements using their #hash and #eql? methods for efficiency.
- *
- * [ 1, 1, 2, 2, 3, 3, 4, 5 ].difference([ 1, 2, 4 ]) #=> [ 3, 3, 5 ]
- *
- * Note that while 1 and 2 were only present once in the array argument, and
- * were present twice in the receiver array, all occurrences of each Integer are
- * removed in the returned array.
- *
- * Multiple array arguments can be supplied and all occurrences of any element
- * in those supplied arrays that match the receiver will be removed from the
- * returned array.
- *
- * [ 1, 'c', :s, 'yep' ].difference([ 1 ], [ 'a', 'c' ]) #=> [ :s, "yep" ]
- *
- * If you need set-like behavior, see the library class Set.
- *
- * See also Array#-.
- */
-
-static VALUE
-rb_ary_difference_multi(int argc, VALUE *argv, VALUE ary)
-{
- VALUE ary_diff;
- long i, length;
- volatile VALUE t0;
- bool *is_hash = ALLOCV_N(bool, t0, argc);
- ary_diff = rb_ary_new();
- length = RARRAY_LEN(ary);
-
- for (i = 0; i < argc; i++) {
- argv[i] = to_ary(argv[i]);
- is_hash[i] = (length > SMALL_ARRAY_LEN && RARRAY_LEN(argv[i]) > SMALL_ARRAY_LEN);
- if (is_hash[i]) argv[i] = ary_make_hash(argv[i]);
- }
-
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- int j;
- VALUE elt = rb_ary_elt(ary, i);
- for (j = 0; j < argc; j++) {
- if (is_hash[j]) {
- if (rb_hash_stlike_lookup(argv[j], RARRAY_AREF(ary, i), NULL))
- break;
- }
- else {
- if (rb_ary_includes_by_eql(argv[j], elt)) break;
- }
- }
- if (j == argc) rb_ary_push(ary_diff, elt);
- }
-
- ALLOCV_END(t0);
-
- return ary_diff;
-}
-
-
-/*
- * call-seq:
* ary & other_ary -> new_ary
*
* Set Intersection --- Returns a new array containing unique elements common to the
@@ -4629,12 +4203,13 @@ static VALUE
rb_ary_and(VALUE ary1, VALUE ary2)
{
VALUE hash, ary3, v;
+ st_table *table;
st_data_t vv;
long i;
ary2 = to_ary(ary2);
ary3 = rb_ary_new();
- if (RARRAY_LEN(ary1) == 0 || RARRAY_LEN(ary2) == 0) return ary3;
+ if (RARRAY_LEN(ary2) == 0) return ary3;
if (RARRAY_LEN(ary1) <= SMALL_ARRAY_LEN && RARRAY_LEN(ary2) <= SMALL_ARRAY_LEN) {
for (i=0; i<RARRAY_LEN(ary1); i++) {
@@ -4647,11 +4222,12 @@ rb_ary_and(VALUE ary1, VALUE ary2)
}
hash = ary_make_hash(ary2);
+ table = rb_hash_tbl_raw(hash);
for (i=0; i<RARRAY_LEN(ary1); i++) {
v = RARRAY_AREF(ary1, i);
vv = (st_data_t)v;
- if (rb_hash_stlike_delete(hash, &vv, 0)) {
+ if (st_delete(table, &vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -4660,36 +4236,6 @@ rb_ary_and(VALUE ary1, VALUE ary2)
return ary3;
}
-/*
- * call-seq:
- * ary.intersection(other_ary1, other_ary2, ...) -> new_ary
- *
- * Set Intersection --- Returns a new array containing unique elements common
- * to +self+ and <code>other_ary</code>s. Order is preserved from the original
- * array.
- *
- * It compares elements using their #hash and #eql? methods for efficiency.
- *
- * [ 1, 1, 3, 5 ].intersection([ 3, 2, 1 ]) # => [ 1, 3 ]
- * [ "a", "b", "z" ].intersection([ "a", "b", "c" ], [ "b" ]) # => [ "b" ]
- * [ "a" ].intersection #=> [ "a" ]
- *
- * See also Array#&.
- */
-
-static VALUE
-rb_ary_intersection_multi(int argc, VALUE *argv, VALUE ary)
-{
- VALUE result = rb_ary_dup(ary);
- int i;
-
- for (i = 0; i < argc; i++) {
- result = rb_ary_and(result, argv[i]);
- }
-
- return result;
-}
-
static int
ary_hash_orset(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
{
@@ -4698,29 +4244,6 @@ ary_hash_orset(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
return ST_CONTINUE;
}
-static void
-rb_ary_union(VALUE ary_union, VALUE ary)
-{
- long i;
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- VALUE elt = rb_ary_elt(ary, i);
- if (rb_ary_includes_by_eql(ary_union, elt)) continue;
- rb_ary_push(ary_union, elt);
- }
-}
-
-static void
-rb_ary_union_hash(VALUE hash, VALUE ary2)
-{
- long i;
- for (i = 0; i < RARRAY_LEN(ary2); i++) {
- VALUE elt = RARRAY_AREF(ary2, i);
- if (!rb_hash_stlike_update(hash, (st_data_t)elt, ary_hash_orset, (st_data_t)elt)) {
- RB_OBJ_WRITTEN(hash, Qundef, elt);
- }
- }
-}
-
/*
* call-seq:
* ary | other_ary -> new_ary
@@ -4733,25 +4256,38 @@ rb_ary_union_hash(VALUE hash, VALUE ary2)
* [ "a", "b", "c" ] | [ "c", "d", "a" ] #=> [ "a", "b", "c", "d" ]
* [ "c", "d", "a" ] | [ "a", "b", "c" ] #=> [ "c", "d", "a", "b" ]
*
- * See also Array#union.
+ * See also Array#uniq.
*/
static VALUE
rb_ary_or(VALUE ary1, VALUE ary2)
{
VALUE hash, ary3;
+ long i;
ary2 = to_ary(ary2);
if (RARRAY_LEN(ary1) + RARRAY_LEN(ary2) <= SMALL_ARRAY_LEN) {
ary3 = rb_ary_new();
- rb_ary_union(ary3, ary1);
- rb_ary_union(ary3, ary2);
+ for (i=0; i<RARRAY_LEN(ary1); i++) {
+ VALUE elt = rb_ary_elt(ary1, i);
+ if (rb_ary_includes_by_eql(ary3, elt)) continue;
+ rb_ary_push(ary3, elt);
+ }
+ for (i=0; i<RARRAY_LEN(ary2); i++) {
+ VALUE elt = rb_ary_elt(ary2, i);
+ if (rb_ary_includes_by_eql(ary3, elt)) continue;
+ rb_ary_push(ary3, elt);
+ }
return ary3;
}
hash = ary_make_hash(ary1);
- rb_ary_union_hash(hash, ary2);
-
+ for (i=0; i<RARRAY_LEN(ary2); i++) {
+ VALUE elt = RARRAY_AREF(ary2, i);
+ if (!st_update(RHASH_TBL_RAW(hash), (st_data_t)elt, ary_hash_orset, (st_data_t)elt)) {
+ RB_OBJ_WRITTEN(hash, Qundef, elt);
+ }
+ }
ary3 = rb_hash_values(hash);
ary_recycle_hash(hash);
return ary3;
@@ -4759,64 +4295,18 @@ rb_ary_or(VALUE ary1, VALUE ary2)
/*
* call-seq:
- * ary.union(other_ary1, other_ary2, ...) -> new_ary
- *
- * Set Union --- Returns a new array by joining <code>other_ary</code>s with +self+,
- * excluding any duplicates and preserving the order from the given arrays.
- *
- * It compares elements using their #hash and #eql? methods for efficiency.
- *
- * [ "a", "b", "c" ].union( [ "c", "d", "a" ] ) #=> [ "a", "b", "c", "d" ]
- * [ "a" ].union( ["e", "b"], ["a", "c", "b"] ) #=> [ "a", "e", "b", "c" ]
- * [ "a" ].union #=> [ "a" ]
- *
- * See also Array#|.
- */
-
-static VALUE
-rb_ary_union_multi(int argc, VALUE *argv, VALUE ary)
-{
- int i;
- long sum;
- VALUE hash, ary_union;
-
- sum = RARRAY_LEN(ary);
- for (i = 0; i < argc; i++) {
- argv[i] = to_ary(argv[i]);
- sum += RARRAY_LEN(argv[i]);
- }
-
- if (sum <= SMALL_ARRAY_LEN) {
- ary_union = rb_ary_new();
-
- rb_ary_union(ary_union, ary);
- for (i = 0; i < argc; i++) rb_ary_union(ary_union, argv[i]);
-
- return ary_union;
- }
-
- hash = ary_make_hash(ary);
- for (i = 0; i < argc; i++) rb_ary_union_hash(hash, argv[i]);
-
- ary_union = rb_hash_values(hash);
- ary_recycle_hash(hash);
- return ary_union;
-}
-
-/*
- * call-seq:
* ary.max -> obj
- * ary.max {|a, b| block} -> obj
+ * ary.max { |a, b| block } -> obj
* ary.max(n) -> array
- * ary.max(n) {|a, b| block} -> array
+ * ary.max(n) { |a, b| block } -> array
*
* Returns the object in _ary_ with the maximum value. The
- * first form assumes all objects implement Comparable;
+ * first form assumes all objects implement <code>Comparable</code>;
* the second uses the block to return <em>a <=> b</em>.
*
* ary = %w(albatross dog horse)
* ary.max #=> "horse"
- * ary.max {|a, b| a.length <=> b.length} #=> "albatross"
+ * ary.max { |a, b| a.length <=> b.length } #=> "albatross"
*
* If the +n+ argument is given, maximum +n+ elements are returned
* as an array.
@@ -4833,7 +4323,9 @@ rb_ary_max(int argc, VALUE *argv, VALUE ary)
VALUE num;
long i;
- if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0]))
+ rb_scan_args(argc, argv, "01", &num);
+
+ if (!NIL_P(num))
return rb_nmin_run(ary, num, 0, 1, 1);
if (rb_block_given_p()) {
@@ -4864,12 +4356,12 @@ rb_ary_max(int argc, VALUE *argv, VALUE ary)
* ary.min(n) {| a,b | block } -> array
*
* Returns the object in _ary_ with the minimum value. The
- * first form assumes all objects implement Comparable;
+ * first form assumes all objects implement <code>Comparable</code>;
* the second uses the block to return <em>a <=> b</em>.
*
* ary = %w(albatross dog horse)
* ary.min #=> "albatross"
- * ary.min {|a, b| a.length <=> b.length} #=> "dog"
+ * ary.min { |a, b| a.length <=> b.length } #=> "dog"
*
* If the +n+ argument is given, minimum +n+ elements are returned
* as an array.
@@ -4886,7 +4378,9 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
VALUE num;
long i;
- if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0]))
+ rb_scan_args(argc, argv, "01", &num);
+
+ if (!NIL_P(num))
return rb_nmin_run(ary, num, 0, 0, 1);
if (rb_block_given_p()) {
@@ -4909,26 +4403,6 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
return result;
}
-/*
- * call-seq:
- * ary.minmax -> [obj, obj]
- * ary.minmax {| a,b | block } -> [obj, obj]
- *
- * Returns a two element array which contains the minimum and the
- * maximum value in the array.
- *
- * Can be given an optional block to override the default comparison
- * method <code>a <=> b</code>.
- */
-static VALUE
-rb_ary_minmax(VALUE ary)
-{
- if (rb_block_given_p()) {
- return rb_call_super(0, NULL);
- }
- return rb_assoc_new(rb_ary_min(0, 0, ary), rb_ary_max(0, 0, ary));
-}
-
static int
push_value(st_data_t key, st_data_t val, st_data_t ary)
{
@@ -4939,7 +4413,7 @@ push_value(st_data_t key, st_data_t val, st_data_t ary)
/*
* call-seq:
* ary.uniq! -> ary or nil
- * ary.uniq! {|item| ...} -> ary or nil
+ * ary.uniq! { |item| ... } -> ary or nil
*
* Removes duplicate elements from +self+.
*
@@ -4959,7 +4433,7 @@ push_value(st_data_t key, st_data_t val, st_data_t ary)
* b.uniq! # => nil
*
* c = [["student","sam"], ["student","george"], ["teacher","matz"]]
- * c.uniq! {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]]
+ * c.uniq! { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
*
*/
@@ -4988,7 +4462,7 @@ rb_ary_uniq_bang(VALUE ary)
FL_SET_EMBED(ary);
}
ary_resize_capa(ary, hash_size);
- rb_hash_foreach(hash, push_value, ary);
+ st_foreach(rb_hash_tbl_raw(hash), push_value, ary);
ary_recycle_hash(hash);
return ary;
@@ -4997,7 +4471,7 @@ rb_ary_uniq_bang(VALUE ary)
/*
* call-seq:
* ary.uniq -> new_ary
- * ary.uniq {|item| ...} -> new_ary
+ * ary.uniq { |item| ... } -> new_ary
*
* Returns a new array by removing duplicate values in +self+.
*
@@ -5011,7 +4485,7 @@ rb_ary_uniq_bang(VALUE ary)
* a.uniq # => ["a", "b", "c"]
*
* b = [["student","sam"], ["student","george"], ["teacher","matz"]]
- * b.uniq {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]]
+ * b.uniq { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
*
*/
@@ -5020,11 +4494,9 @@ rb_ary_uniq(VALUE ary)
{
VALUE hash, uniq;
- if (RARRAY_LEN(ary) <= 1) {
- hash = 0;
- uniq = rb_ary_dup(ary);
- }
- else if (rb_block_given_p()) {
+ if (RARRAY_LEN(ary) <= 1)
+ return rb_ary_dup(ary);
+ if (rb_block_given_p()) {
hash = ary_make_hash_by(ary);
uniq = rb_hash_values(hash);
}
@@ -5033,9 +4505,7 @@ rb_ary_uniq(VALUE ary)
uniq = rb_hash_values(hash);
}
RBASIC_SET_CLASS(uniq, rb_obj_class(ary));
- if (hash) {
- ary_recycle_hash(hash);
- }
+ ary_recycle_hash(hash);
return uniq;
}
@@ -5059,14 +4529,14 @@ rb_ary_compact_bang(VALUE ary)
long n;
rb_ary_modify(ary);
- p = t = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(ary); /* WB: no new reference */
+ p = t = (VALUE *)RARRAY_CONST_PTR(ary); /* WB: no new reference */
end = p + RARRAY_LEN(ary);
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
}
- n = p - RARRAY_CONST_PTR_TRANSIENT(ary);
+ n = p - RARRAY_CONST_PTR(ary);
if (RARRAY_LEN(ary) == n) {
return Qnil;
}
@@ -5097,7 +4567,7 @@ rb_ary_compact(VALUE ary)
* call-seq:
* ary.count -> int
* ary.count(obj) -> int
- * ary.count {|item| block} -> int
+ * ary.count { |item| block } -> int
*
* Returns the number of elements.
*
@@ -5110,7 +4580,7 @@ rb_ary_compact(VALUE ary)
* ary = [1, 2, 4, 2]
* ary.count #=> 4
* ary.count(2) #=> 2
- * ary.count {|x| x%2 == 0} #=> 3
+ * ary.count { |x| x%2 == 0 } #=> 3
*
*/
@@ -5119,7 +4589,7 @@ rb_ary_count(int argc, VALUE *argv, VALUE ary)
{
long i, n = 0;
- if (rb_check_arity(argc, 0, 1) == 0) {
+ if (argc == 0) {
VALUE v;
if (!rb_block_given_p())
@@ -5131,8 +4601,9 @@ rb_ary_count(int argc, VALUE *argv, VALUE ary)
}
}
else {
- VALUE obj = argv[0];
+ VALUE obj;
+ rb_scan_args(argc, argv, "1", &obj);
if (rb_block_given_p()) {
rb_warn("given block not used");
}
@@ -5145,43 +4616,18 @@ rb_ary_count(int argc, VALUE *argv, VALUE ary)
}
static VALUE
-flatten(VALUE ary, int level)
+flatten(VALUE ary, int level, int *modified)
{
- long i;
- VALUE stack, result, tmp, elt, vmemo;
- st_table *memo = 0;
+ long i = 0;
+ VALUE stack, result, tmp, elt;
+ st_table *memo;
st_data_t id;
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- elt = RARRAY_AREF(ary, i);
- tmp = rb_check_array_type(elt);
- if (!NIL_P(tmp)) {
- break;
- }
- }
- if (i == RARRAY_LEN(ary)) {
- return ary;
- }
-
- result = ary_new(0, RARRAY_LEN(ary));
- ary_memcpy(result, 0, i, RARRAY_CONST_PTR_TRANSIENT(ary));
- ARY_SET_LEN(result, i);
-
stack = ary_new(0, ARY_DEFAULT_SIZE);
- rb_ary_push(stack, ary);
- rb_ary_push(stack, LONG2NUM(i + 1));
-
- if (level < 0) {
- vmemo = rb_hash_new();
- RBASIC_CLEAR_CLASS(vmemo);
- memo = st_init_numtable();
- rb_hash_st_table_set(vmemo, memo);
- st_insert(memo, (st_data_t)ary, (st_data_t)Qtrue);
- st_insert(memo, (st_data_t)tmp, (st_data_t)Qtrue);
- }
-
- ary = tmp;
- i = 0;
+ result = ary_new(0, RARRAY_LEN(ary));
+ memo = st_init_numtable();
+ st_insert(memo, (st_data_t)ary, (st_data_t)Qtrue);
+ *modified = 0;
while (1) {
while (i < RARRAY_LEN(ary)) {
@@ -5192,24 +4638,19 @@ flatten(VALUE ary, int level)
}
tmp = rb_check_array_type(elt);
if (RBASIC(result)->klass) {
- if (memo) {
- RB_GC_GUARD(vmemo);
- st_clear(memo);
- }
rb_raise(rb_eRuntimeError, "flatten reentered");
}
if (NIL_P(tmp)) {
rb_ary_push(result, elt);
}
else {
- if (memo) {
- id = (st_data_t)tmp;
- if (st_is_member(memo, id)) {
- st_clear(memo);
- rb_raise(rb_eArgError, "tried to flatten recursive array");
- }
- st_insert(memo, id, (st_data_t)Qtrue);
+ *modified = 1;
+ id = (st_data_t)tmp;
+ if (st_lookup(memo, id, 0)) {
+ st_free_table(memo);
+ rb_raise(rb_eArgError, "tried to flatten recursive array");
}
+ st_insert(memo, id, (st_data_t)Qtrue);
rb_ary_push(stack, ary);
rb_ary_push(stack, LONG2NUM(i));
ary = tmp;
@@ -5219,18 +4660,14 @@ flatten(VALUE ary, int level)
if (RARRAY_LEN(stack) == 0) {
break;
}
- if (memo) {
- id = (st_data_t)ary;
- st_delete(memo, &id, 0);
- }
+ id = (st_data_t)ary;
+ st_delete(memo, &id, 0);
tmp = rb_ary_pop(stack);
i = NUM2LONG(tmp);
ary = rb_ary_pop(stack);
}
- if (memo) {
- st_clear(memo);
- }
+ st_free_table(memo);
RBASIC_SET_CLASS(result, rb_obj_class(ary));
return result;
@@ -5262,13 +4699,14 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
int mod = 0, level = -1;
VALUE result, lv;
- lv = (rb_check_arity(argc, 0, 1) ? argv[0] : Qnil);
+ rb_scan_args(argc, argv, "01", &lv);
rb_ary_modify_check(ary);
if (!NIL_P(lv)) level = NUM2INT(lv);
if (level == 0) return Qnil;
- result = flatten(ary, level);
- if (result == ary) {
+ result = flatten(ary, level, &mod);
+ if (mod == 0) {
+ ary_discard(result);
return Qnil;
}
if (!(mod = ARY_EMBED_P(result))) rb_obj_freeze(result);
@@ -5303,18 +4741,15 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
static VALUE
rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
{
- int level = -1;
- VALUE result;
+ int mod = 0, level = -1;
+ VALUE result, lv;
- if (rb_check_arity(argc, 0, 1) && !NIL_P(argv[0])) {
- level = NUM2INT(argv[0]);
- if (level == 0) return ary_make_shared_copy(ary);
- }
+ rb_scan_args(argc, argv, "01", &lv);
+ if (!NIL_P(lv)) level = NUM2INT(lv);
+ if (level == 0) return ary_make_shared_copy(ary);
- result = flatten(ary, level);
- if (result == ary) {
- result = ary_make_shared_copy(ary);
- }
+ result = flatten(ary, level, &mod);
+ OBJ_INFECT(result, ary);
return result;
}
@@ -5364,8 +4799,8 @@ rb_ary_shuffle_bang(int argc, VALUE *argv, VALUE ary)
while (i) {
long j = RAND_UPTO(i);
VALUE tmp;
- if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR_TRANSIENT(ary)) {
- rb_raise(rb_eRuntimeError, "modified during shuffle");
+ if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR(ary)) {
+ rb_raise(rb_eRuntimeError, "modified during shuffle");
}
tmp = ptr[--i];
ptr[i] = ptr[j];
@@ -5417,14 +4852,11 @@ rb_ary_shuffle(int argc, VALUE *argv, VALUE ary)
* If the array is empty the first form returns +nil+ and the second form
* returns an empty array.
*
+ * The optional +rng+ argument will be used as the random number generator.
+ *
* a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
* a.sample #=> 7
* a.sample(4) #=> [6, 4, 2, 5]
- *
- * The optional +rng+ argument will be used as the random number generator.
- *
- * a.sample(random: Random.new(1)) #=> 6
- * a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
*/
@@ -5448,7 +4880,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary)
}
}
len = RARRAY_LEN(ary);
- if (rb_check_arity(argc, 0, 1) == 0) {
+ if (argc == 0) {
if (len < 2)
i = 0;
else
@@ -5456,7 +4888,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary)
return rb_ary_elt(ary, i);
}
- nv = argv[0];
+ rb_scan_args(argc, argv, "1", &nv);
n = NUM2LONG(nv);
if (n < 0) rb_raise(rb_eArgError, "negative sample number");
if (n > len) n = len;
@@ -5513,7 +4945,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary)
sorted[j] = idx[i] = k;
}
result = rb_ary_new_capa(n);
- RARRAY_PTR_USE_TRANSIENT(result, ptr_result, {
+ RARRAY_PTR_USE(result, ptr_result, {
for (i=0; i<n; i++) {
ptr_result[i] = RARRAY_AREF(ary, idx[i]);
}
@@ -5536,7 +4968,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary)
len = RARRAY_LEN(ary);
if (len <= max_idx) n = 0;
else if (n > len) n = len;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr_ary, {
+ RARRAY_PTR_USE(ary, ptr_ary, {
for (i=0; i<n; i++) {
long j2 = j = ptr_result[i];
long i2 = i;
@@ -5579,7 +5011,7 @@ rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
n = RARRAY_AREF(args, 0);
}
if (RARRAY_LEN(self) == 0) return INT2FIX(0);
- if (n == Qnil) return DBL2NUM(HUGE_VAL);
+ if (n == Qnil) return DBL2NUM(INFINITY);
mul = NUM2LONG(n);
if (mul <= 0) return INT2FIX(0);
n = LONG2FIX(mul);
@@ -5588,7 +5020,7 @@ rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
/*
* call-seq:
- * ary.cycle(n=nil) {|obj| block} -> nil
+ * ary.cycle(n=nil) { |obj| block } -> nil
* ary.cycle(n=nil) -> Enumerator
*
* Calls the given block for each element +n+ times or forever if +nil+ is
@@ -5601,8 +5033,8 @@ rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
* If no block is given, an Enumerator is returned instead.
*
* a = ["a", "b", "c"]
- * a.cycle {|x| puts x} # print, a, b, c, a, b, c,.. forever.
- * a.cycle(2) {|x| puts x} # print, a, b, c, a, b, c.
+ * a.cycle { |x| puts x } # print, a, b, c, a, b, c,.. forever.
+ * a.cycle(2) { |x| puts x } # print, a, b, c, a, b, c.
*
*/
@@ -5610,15 +5042,16 @@ static VALUE
rb_ary_cycle(int argc, VALUE *argv, VALUE ary)
{
long n, i;
+ VALUE nv = Qnil;
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", &nv);
RETURN_SIZED_ENUMERATOR(ary, argc, argv, rb_ary_cycle_size);
- if (argc == 0 || NIL_P(argv[0])) {
+ if (NIL_P(nv)) {
n = -1;
}
else {
- n = NUM2LONG(argv[0]);
+ n = NUM2LONG(nv);
if (n <= 0) return Qnil;
}
@@ -5630,6 +5063,8 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary)
return Qnil;
}
+#define tmpbuf(n, size) rb_str_tmp_new((n)*(size))
+#define tmpbuf_discard(s) (rb_str_resize((s), 0L), RBASIC_SET_CLASS_RAW(s, rb_cString))
#define tmpary(n) rb_ary_tmp_new(n)
#define tmpary_discard(a) (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray))
@@ -5642,9 +5077,11 @@ static int
yield_indexed_values(const VALUE values, const long r, const long *const p)
{
const VALUE result = rb_ary_new2(r);
+ VALUE *const result_array = RARRAY_PTR(result);
+ const VALUE *const values_array = RARRAY_CONST_PTR(values);
long i;
- for (i = 0; i < r; i++) ARY_SET(result, i, RARRAY_AREF(values, p[i]));
+ for (i = 0; i < r; i++) result_array[i] = values_array[p[i]];
ARY_SET_LEN(result, r);
rb_yield(result);
return !RBASIC(values)->klass;
@@ -5751,9 +5188,9 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * ary.permutation {|p| block} -> ary
+ * ary.permutation { |p| block } -> ary
* ary.permutation -> Enumerator
- * ary.permutation(n) {|p| block} -> ary
+ * ary.permutation(n) { |p| block } -> ary
* ary.permutation(n) -> Enumerator
*
* When invoked with a block, yield all permutations of length +n+ of the
@@ -5780,13 +5217,13 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj)
static VALUE
rb_ary_permutation(int argc, VALUE *argv, VALUE ary)
{
+ VALUE num;
long r, n, i;
n = RARRAY_LEN(ary); /* Array length */
RETURN_SIZED_ENUMERATOR(ary, argc, argv, rb_ary_permutation_size); /* Return enumerator if no block */
- r = n;
- if (rb_check_arity(argc, 0, 1) && !NIL_P(argv[0]))
- r = NUM2LONG(argv[0]); /* Permutation size from argument */
+ rb_scan_args(argc, argv, "01", &num);
+ r = NIL_P(num) ? n : NUM2LONG(num); /* Permutation size from argument */
if (r < 0 || n < r) {
/* no permutations: yield nothing */
@@ -5847,7 +5284,7 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * ary.combination(n) {|c| block} -> ary
+ * ary.combination(n) { |c| block } -> ary
* ary.combination(n) -> Enumerator
*
* When invoked with a block, yields all combinations of length +n+ of elements
@@ -5954,7 +5391,7 @@ rb_ary_repeated_permutation_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * ary.repeated_permutation(n) {|p| block} -> ary
+ * ary.repeated_permutation(n) { |p| block } -> ary
* ary.repeated_permutation(n) -> Enumerator
*
* When invoked with a block, yield all repeated permutations of length +n+ of
@@ -6044,7 +5481,7 @@ rb_ary_repeated_combination_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * ary.repeated_combination(n) {|c| block} -> ary
+ * ary.repeated_combination(n) { |c| block } -> ary
* ary.repeated_combination(n) -> Enumerator
*
* When invoked with a block, yields all repeated combinations of length +n+ of
@@ -6107,7 +5544,7 @@ rb_ary_repeated_combination(VALUE ary, VALUE num)
/*
* call-seq:
* ary.product(other_ary, ...) -> new_ary
- * ary.product(other_ary, ...) {|p| block} -> ary
+ * ary.product(other_ary, ...) { |p| block } -> ary
*
* Returns an array of all combinations of elements from all arrays.
*
@@ -6130,14 +5567,15 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
{
int n = argc+1; /* How many arrays we're operating on */
volatile VALUE t0 = tmpary(n);
- volatile VALUE t1 = Qundef;
+ volatile VALUE t1 = tmpbuf(n, sizeof(int));
VALUE *arrays = RARRAY_PTR(t0); /* The arrays we're computing the product of */
- int *counters = ALLOCV_N(int, t1, n); /* The current position in each one */
+ int *counters = (int*)RSTRING_PTR(t1); /* The current position in each one */
VALUE result = Qnil; /* The array we'll be returning, when no block given */
long i,j;
long resultlen = 1;
RBASIC_CLEAR_CLASS(t0);
+ RBASIC_CLEAR_CLASS(t1);
/* initialize the arrays of arrays */
ARY_SET_LEN(t0, n);
@@ -6208,7 +5646,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
}
done:
tmpary_discard(t0);
- ALLOCV_END(t1);
+ tmpbuf_discard(t1);
return NIL_P(result) ? ary : result;
}
@@ -6240,7 +5678,7 @@ rb_ary_take(VALUE obj, VALUE n)
/*
* call-seq:
- * ary.take_while {|obj| block} -> new_ary
+ * ary.take_while { |obj| block } -> new_ary
* ary.take_while -> Enumerator
*
* Passes elements to the block until the block returns +nil+ or +false+, then
@@ -6251,7 +5689,7 @@ rb_ary_take(VALUE obj, VALUE n)
* See also Array#drop_while
*
* a = [1, 2, 3, 4, 5, 0]
- * a.take_while {|i| i < 3} #=> [1, 2]
+ * a.take_while { |i| i < 3 } #=> [1, 2]
*
*/
@@ -6299,7 +5737,7 @@ rb_ary_drop(VALUE ary, VALUE n)
/*
* call-seq:
- * ary.drop_while {|obj| block} -> new_ary
+ * ary.drop_while { |obj| block } -> new_ary
* ary.drop_while -> Enumerator
*
* Drops elements up to, but not including, the first element for which the
@@ -6329,8 +5767,7 @@ rb_ary_drop_while(VALUE ary)
/*
* call-seq:
- * ary.any? [{|obj| block} ] -> true or false
- * ary.any?(pattern) -> true or false
+ * ary.any? [{ |obj| block }] -> true or false
*
* See also Enumerable#any?
*/
@@ -6339,21 +5776,17 @@ static VALUE
rb_ary_any_p(int argc, VALUE *argv, VALUE ary)
{
long i, len = RARRAY_LEN(ary);
+ const VALUE *ptr = RARRAY_CONST_PTR(ary);
rb_check_arity(argc, 0, 1);
if (!len) return Qfalse;
if (argc) {
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
for (i = 0; i < RARRAY_LEN(ary); ++i) {
if (RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) return Qtrue;
}
}
else if (!rb_block_given_p()) {
- for (i = 0; i < len; ++i) {
- if (RTEST(RARRAY_AREF(ary, i))) return Qtrue;
- }
+ for (i = 0; i < len; ++i) if (RTEST(ptr[i])) return Qtrue;
}
else {
for (i = 0; i < RARRAY_LEN(ary); ++i) {
@@ -6364,124 +5797,6 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary)
}
/*
- * call-seq:
- * ary.all? [{|obj| block} ] -> true or false
- * ary.all?(pattern) -> true or false
- *
- * See also Enumerable#all?
- */
-
-static VALUE
-rb_ary_all_p(int argc, VALUE *argv, VALUE ary)
-{
- long i, len = RARRAY_LEN(ary);
-
- rb_check_arity(argc, 0, 1);
- if (!len) return Qtrue;
- if (argc) {
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- if (!RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) return Qfalse;
- }
- }
- else if (!rb_block_given_p()) {
- for (i = 0; i < len; ++i) {
- if (!RTEST(RARRAY_AREF(ary, i))) return Qfalse;
- }
- }
- else {
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) return Qfalse;
- }
- }
- return Qtrue;
-}
-
-/*
- * call-seq:
- * ary.none? [{|obj| block} ] -> true or false
- * ary.none?(pattern) -> true or false
- *
- * See also Enumerable#none?
- */
-
-static VALUE
-rb_ary_none_p(int argc, VALUE *argv, VALUE ary)
-{
- long i, len = RARRAY_LEN(ary);
-
- rb_check_arity(argc, 0, 1);
- if (!len) return Qtrue;
- if (argc) {
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- if (RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) return Qfalse;
- }
- }
- else if (!rb_block_given_p()) {
- for (i = 0; i < len; ++i) {
- if (RTEST(RARRAY_AREF(ary, i))) return Qfalse;
- }
- }
- else {
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) return Qfalse;
- }
- }
- return Qtrue;
-}
-
-/*
- * call-seq:
- * ary.one? [{|obj| block} ] -> true or false
- * ary.one?(pattern) -> true or false
- *
- * See also Enumerable#one?
- */
-
-static VALUE
-rb_ary_one_p(int argc, VALUE *argv, VALUE ary)
-{
- long i, len = RARRAY_LEN(ary);
- VALUE result = Qfalse;
-
- rb_check_arity(argc, 0, 1);
- if (!len) return Qfalse;
- if (argc) {
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- if (RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) {
- if (result) return Qfalse;
- result = Qtrue;
- }
- }
- }
- else if (!rb_block_given_p()) {
- for (i = 0; i < len; ++i) {
- if (RTEST(RARRAY_AREF(ary, i))) {
- if (result) return Qfalse;
- result = Qtrue;
- }
- }
- }
- else {
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) {
- if (result) return Qfalse;
- result = Qtrue;
- }
- }
- }
- return result;
-}
-
-/*
* call-seq:
* ary.dig(idx, ...) -> object
*
@@ -6497,7 +5812,7 @@ rb_ary_one_p(int argc, VALUE *argv, VALUE ary)
* [42, {foo: :bar}].dig(1, :foo) #=> :bar
*/
-static VALUE
+VALUE
rb_ary_dig(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
@@ -6576,7 +5891,8 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
long i, n;
int block_given;
- v = (rb_check_arity(argc, 0, 1) ? argv[0] : LONG2FIX(0));
+ if (rb_scan_args(argc, argv, "01", &v) == 0)
+ v = LONG2FIX(0);
block_given = rb_block_given_p();
@@ -6619,12 +5935,12 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
* See http://link.springer.com/article/10.1007/s00607-005-0139-x
*/
double f, c;
- double x, t;
f = NUM2DBL(v);
c = 0.0;
goto has_float_value;
for (; i < RARRAY_LEN(ary); i++) {
+ double x, t;
e = RARRAY_AREF(ary, i);
if (block_given)
e = rb_yield(e);
@@ -6679,12 +5995,6 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
return v;
}
-static VALUE
-rb_ary_deconstruct(VALUE ary)
-{
- return ary;
-}
-
/*
* Arrays are ordered, integer-indexed collections of any object.
*
@@ -6718,12 +6028,12 @@ rb_ary_deconstruct(VALUE ary)
* This method is safe to use with mutable objects such as hashes, strings or
* other arrays:
*
- * Array.new(4) {Hash.new} #=> [{}, {}, {}, {}]
+ * Array.new(4) { Hash.new } #=> [{}, {}, {}, {}]
* Array.new(4) {|i| i.to_s } #=> ["0", "1", "2", "3"]
*
* This is also a quick way to build up multi-dimensional arrays:
*
- * empty_table = Array.new(3) {Array.new(3)}
+ * empty_table = Array.new(3) { Array.new(3) }
* #=> [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]]
*
* An array can also be created by using the Array() method, provided by
@@ -6870,7 +6180,7 @@ rb_ary_deconstruct(VALUE ary)
* Note that this operation leaves the array unchanged.
*
* arr = [1, 2, 3, 4, 5]
- * arr.each {|a| print a -= 10, " "}
+ * arr.each { |a| print a -= 10, " " }
* # prints: -9 -8 -7 -6 -5
* #=> [1, 2, 3, 4, 5]
*
@@ -6879,15 +6189,15 @@ rb_ary_deconstruct(VALUE ary)
*
* words = %w[first second third fourth fifth sixth]
* str = ""
- * words.reverse_each {|word| str += "#{word} "}
+ * words.reverse_each { |word| str += "#{word} " }
* p str #=> "sixth fifth fourth third second first "
*
* The #map method can be used to create a new array based on the original
* array, but with the values modified by the supplied block:
*
- * arr.map {|a| 2*a} #=> [2, 4, 6, 8, 10]
+ * arr.map { |a| 2*a } #=> [2, 4, 6, 8, 10]
* arr #=> [1, 2, 3, 4, 5]
- * arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25]
+ * arr.map! { |a| a**2 } #=> [1, 4, 9, 16, 25]
* arr #=> [1, 4, 9, 16, 25]
*
* == Selecting Items from an Array
@@ -6901,9 +6211,9 @@ rb_ary_deconstruct(VALUE ary)
* === Non-destructive Selection
*
* arr = [1, 2, 3, 4, 5, 6]
- * arr.select {|a| a > 3} #=> [4, 5, 6]
- * arr.reject {|a| a < 3} #=> [3, 4, 5, 6]
- * arr.drop_while {|a| a < 4} #=> [4, 5, 6]
+ * arr.select { |a| a > 3 } #=> [4, 5, 6]
+ * arr.reject { |a| a < 3 } #=> [3, 4, 5, 6]
+ * arr.drop_while { |a| a < 4 } #=> [4, 5, 6]
* arr #=> [1, 2, 3, 4, 5, 6]
*
* === Destructive Selection
@@ -6914,11 +6224,11 @@ rb_ary_deconstruct(VALUE ary)
* Similar to #select vs. #reject, #delete_if and #keep_if have the exact
* opposite result when supplied with the same block:
*
- * arr.delete_if {|a| a < 4} #=> [4, 5, 6]
+ * arr.delete_if { |a| a < 4 } #=> [4, 5, 6]
* arr #=> [4, 5, 6]
*
* arr = [1, 2, 3, 4, 5, 6]
- * arr.keep_if {|a| a < 4} #=> [1, 2, 3]
+ * arr.keep_if { |a| a < 4 } #=> [1, 2, 3]
* arr #=> [1, 2, 3]
*
*/
@@ -6943,6 +6253,7 @@ Init_Array(void)
rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0);
rb_define_method(rb_cArray, "to_h", rb_ary_to_h, 0);
rb_define_method(rb_cArray, "to_ary", rb_ary_to_ary_m, 0);
+ rb_define_method(rb_cArray, "frozen?", rb_ary_frozen_p, 0);
rb_define_method(rb_cArray, "==", rb_ary_equal, 1);
rb_define_method(rb_cArray, "eql?", rb_ary_eql, 1);
@@ -6955,9 +6266,6 @@ Init_Array(void)
rb_define_method(rb_cArray, "first", rb_ary_first, -1);
rb_define_method(rb_cArray, "last", rb_ary_last, -1);
rb_define_method(rb_cArray, "concat", rb_ary_concat_multi, -1);
- rb_define_method(rb_cArray, "union", rb_ary_union_multi, -1);
- rb_define_method(rb_cArray, "difference", rb_ary_difference_multi, -1);
- rb_define_method(rb_cArray, "intersection", rb_ary_intersection_multi, -1);
rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
rb_define_method(rb_cArray, "push", rb_ary_push_m, -1);
rb_define_alias(rb_cArray, "append", "push");
@@ -6989,8 +6297,6 @@ Init_Array(void)
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
rb_define_method(rb_cArray, "select", rb_ary_select, 0);
rb_define_method(rb_cArray, "select!", rb_ary_select_bang, 0);
- rb_define_method(rb_cArray, "filter", rb_ary_select, 0);
- rb_define_method(rb_cArray, "filter!", rb_ary_select_bang, 0);
rb_define_method(rb_cArray, "keep_if", rb_ary_keep_if, 0);
rb_define_method(rb_cArray, "values_at", rb_ary_values_at, -1);
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
@@ -7021,7 +6327,6 @@ Init_Array(void)
rb_define_method(rb_cArray, "max", rb_ary_max, -1);
rb_define_method(rb_cArray, "min", rb_ary_min, -1);
- rb_define_method(rb_cArray, "minmax", rb_ary_minmax, 0);
rb_define_method(rb_cArray, "uniq", rb_ary_uniq, 0);
rb_define_method(rb_cArray, "uniq!", rb_ary_uniq_bang, 0);
@@ -7047,13 +6352,8 @@ Init_Array(void)
rb_define_method(rb_cArray, "bsearch", rb_ary_bsearch, 0);
rb_define_method(rb_cArray, "bsearch_index", rb_ary_bsearch_index, 0);
rb_define_method(rb_cArray, "any?", rb_ary_any_p, -1);
- rb_define_method(rb_cArray, "all?", rb_ary_all_p, -1);
- rb_define_method(rb_cArray, "none?", rb_ary_none_p, -1);
- rb_define_method(rb_cArray, "one?", rb_ary_one_p, -1);
rb_define_method(rb_cArray, "dig", rb_ary_dig, -1);
rb_define_method(rb_cArray, "sum", rb_ary_sum, -1);
- rb_define_method(rb_cArray, "deconstruct", rb_ary_deconstruct, 0);
-
id_random = rb_intern("random");
}
diff --git a/ast.c b/ast.c
deleted file mode 100644
index a0c026229c..0000000000
--- a/ast.c
+++ /dev/null
@@ -1,694 +0,0 @@
-/* indent-tabs-mode: nil */
-#include "ruby.h"
-#include "ruby/encoding.h"
-#include "ruby/util.h"
-#include "internal.h"
-#include "node.h"
-#include "vm_core.h"
-#include "iseq.h"
-#include "builtin.h"
-
-static VALUE rb_mAST;
-static VALUE rb_cNode;
-
-struct ASTNodeData {
- rb_ast_t *ast;
- NODE *node;
-};
-
-static void
-node_gc_mark(void *ptr)
-{
- struct ASTNodeData *data = (struct ASTNodeData *)ptr;
- rb_gc_mark((VALUE)data->ast);
-}
-
-static size_t
-node_memsize(const void *ptr)
-{
- struct ASTNodeData *data = (struct ASTNodeData *)ptr;
- return rb_ast_memsize(data->ast);
-}
-
-static const rb_data_type_t rb_node_type = {
- "AST/node",
- {node_gc_mark, RUBY_TYPED_DEFAULT_FREE, node_memsize,},
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
-};
-
-static VALUE rb_ast_node_alloc(VALUE klass);
-
-static void
-setup_node(VALUE obj, rb_ast_t *ast, NODE *node)
-{
- struct ASTNodeData *data;
-
- TypedData_Get_Struct(obj, struct ASTNodeData, &rb_node_type, data);
- data->ast = ast;
- data->node = node;
-}
-
-static VALUE
-ast_new_internal(rb_ast_t *ast, NODE *node)
-{
- VALUE obj;
-
- obj = rb_ast_node_alloc(rb_cNode);
- setup_node(obj, ast, node);
-
- return obj;
-}
-
-static VALUE rb_ast_parse_str(VALUE str);
-static VALUE rb_ast_parse_file(VALUE path);
-static VALUE rb_ast_parse_array(VALUE array);
-
-static VALUE
-ast_parse_new(void)
-{
- return rb_parser_set_context(rb_parser_new(), NULL, 0);
-}
-
-static VALUE
-ast_parse_done(rb_ast_t *ast)
-{
- if (!ast->body.root) {
- rb_ast_dispose(ast);
- rb_exc_raise(GET_EC()->errinfo);
- }
-
- return ast_new_internal(ast, (NODE *)ast->body.root);
-}
-
-static VALUE
-ast_s_parse(rb_execution_context_t *ec, VALUE module, VALUE str)
-{
- return rb_ast_parse_str(str);
-}
-
-static VALUE
-rb_ast_parse_str(VALUE str)
-{
- rb_ast_t *ast = 0;
-
- StringValue(str);
- ast = rb_parser_compile_string_path(ast_parse_new(), Qnil, str, 1);
- return ast_parse_done(ast);
-}
-
-static VALUE
-ast_s_parse_file(rb_execution_context_t *ec, VALUE module, VALUE path)
-{
- return rb_ast_parse_file(path);
-}
-
-static VALUE
-rb_ast_parse_file(VALUE path)
-{
- VALUE f;
- rb_ast_t *ast = 0;
- rb_encoding *enc = rb_utf8_encoding();
-
- FilePathValue(path);
- f = rb_file_open_str(path, "r");
- rb_funcall(f, rb_intern("set_encoding"), 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
- ast = rb_parser_compile_file_path(ast_parse_new(), Qnil, f, 1);
- rb_io_close(f);
- return ast_parse_done(ast);
-}
-
-static VALUE
-lex_array(VALUE array, int index)
-{
- VALUE str = rb_ary_entry(array, index);
- if (!NIL_P(str)) {
- StringValue(str);
- if (!rb_enc_asciicompat(rb_enc_get(str))) {
- rb_raise(rb_eArgError, "invalid source encoding");
- }
- }
- return str;
-}
-
-static VALUE
-rb_ast_parse_array(VALUE array)
-{
- rb_ast_t *ast = 0;
-
- array = rb_check_array_type(array);
- ast = rb_parser_compile_generic(ast_parse_new(), lex_array, Qnil, array, 1);
- return ast_parse_done(ast);
-}
-
-static VALUE node_children(rb_ast_t*, NODE*);
-
-static VALUE
-node_find(VALUE self, const int node_id)
-{
- VALUE ary;
- long i;
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- if (nd_node_id(data->node) == node_id) return self;
-
- ary = node_children(data->ast, data->node);
-
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- VALUE child = RARRAY_AREF(ary, i);
-
- if (CLASS_OF(child) == rb_cNode) {
- VALUE result = node_find(child, node_id);
- if (RTEST(result)) return result;
- }
- }
-
- return Qnil;
-}
-
-extern VALUE rb_e_script;
-
-static VALUE
-script_lines(VALUE path)
-{
- VALUE hash, lines;
- ID script_lines;
- CONST_ID(script_lines, "SCRIPT_LINES__");
- if (!rb_const_defined_at(rb_cObject, script_lines)) return Qnil;
- hash = rb_const_get_at(rb_cObject, script_lines);
- if (!RB_TYPE_P(hash, T_HASH)) return Qnil;
- lines = rb_hash_lookup(hash, path);
- if (!RB_TYPE_P(lines, T_ARRAY)) return Qnil;
- return lines;
-}
-
-static VALUE
-ast_s_of(rb_execution_context_t *ec, VALUE module, VALUE body)
-{
- VALUE path, node, lines;
- int node_id;
- const rb_iseq_t *iseq = NULL;
-
- if (rb_obj_is_proc(body)) {
- iseq = vm_proc_iseq(body);
-
- if (!rb_obj_is_iseq((VALUE)iseq)) {
- iseq = NULL;
- }
- }
- else {
- iseq = rb_method_iseq(body);
- }
-
- if (!iseq) return Qnil;
-
- path = rb_iseq_path(iseq);
- node_id = iseq->body->location.node_id;
- if (!NIL_P(lines = script_lines(path))) {
- node = rb_ast_parse_array(lines);
- }
- else if (RSTRING_LEN(path) == 2 && memcmp(RSTRING_PTR(path), "-e", 2) == 0) {
- node = rb_ast_parse_str(rb_e_script);
- }
- else {
- node = rb_ast_parse_file(path);
- }
-
- return node_find(node, node_id);
-}
-
-static VALUE
-rb_ast_node_alloc(VALUE klass)
-{
- struct ASTNodeData *data;
- VALUE obj = TypedData_Make_Struct(klass, struct ASTNodeData, &rb_node_type, data);
-
- return obj;
-}
-
-static const char*
-node_type_to_str(const NODE *node)
-{
- return (ruby_node_name(nd_type(node)) + rb_strlen_lit("NODE_"));
-}
-
-static VALUE
-ast_node_type(rb_execution_context_t *ec, VALUE self)
-{
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- return rb_sym_intern_ascii_cstr(node_type_to_str(data->node));
-}
-
-#define NEW_CHILD(ast, node) node ? ast_new_internal(ast, node) : Qnil
-
-static VALUE
-rb_ary_new_from_node_args(rb_ast_t *ast, long n, ...)
-{
- va_list ar;
- VALUE ary;
- long i;
-
- ary = rb_ary_new2(n);
-
- va_start(ar, n);
- for (i=0; i<n; i++) {
- NODE *node;
- node = va_arg(ar, NODE *);
- rb_ary_push(ary, NEW_CHILD(ast, node));
- }
- va_end(ar);
- return ary;
-}
-
-static VALUE
-dump_block(rb_ast_t *ast, NODE *node)
-{
- VALUE ary = rb_ary_new();
- do {
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
- } while (node->nd_next &&
- nd_type(node->nd_next) == NODE_BLOCK &&
- (node = node->nd_next, 1));
- if (node->nd_next) {
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_next));
- }
-
- return ary;
-}
-
-static VALUE
-dump_array(rb_ast_t *ast, NODE *node)
-{
- VALUE ary = rb_ary_new();
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
-
- while (node->nd_next && nd_type(node->nd_next) == NODE_LIST) {
- node = node->nd_next;
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
- }
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_next));
-
- return ary;
-}
-
-static VALUE
-var_name(ID id)
-{
- if (!id) return Qnil;
- if (!rb_id2str(id)) return Qnil;
- return ID2SYM(id);
-}
-
-static VALUE
-node_children(rb_ast_t *ast, NODE *node)
-{
- char name[DECIMAL_SIZE_OF_BITS(sizeof(long) * CHAR_BIT) + 2]; /* including '$' */
-
- enum node_type type = nd_type(node);
- switch (type) {
- case NODE_BLOCK:
- return dump_block(ast, node);
- case NODE_IF:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cond, node->nd_body, node->nd_else);
- case NODE_UNLESS:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cond, node->nd_body, node->nd_else);
- case NODE_CASE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
- case NODE_CASE2:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
- case NODE_CASE3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
- case NODE_WHEN:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
- case NODE_IN:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
- case NODE_WHILE:
- goto loop;
- case NODE_UNTIL:
- loop:
- return rb_ary_push(rb_ary_new_from_node_args(ast, 2, node->nd_cond, node->nd_body),
- (node->nd_state ? Qtrue : Qfalse));
- case NODE_ITER:
- case NODE_FOR:
- return rb_ary_new_from_node_args(ast, 2, node->nd_iter, node->nd_body);
- case NODE_FOR_MASGN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_var);
- case NODE_BREAK:
- goto jump;
- case NODE_NEXT:
- goto jump;
- case NODE_RETURN:
- jump:
- return rb_ary_new_from_node_args(ast, 1, node->nd_stts);
- case NODE_REDO:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_RETRY:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_BEGIN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
- case NODE_RESCUE:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_resq, node->nd_else);
- case NODE_RESBODY:
- return rb_ary_new_from_node_args(ast, 3, node->nd_args, node->nd_body, node->nd_head);
- case NODE_ENSURE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_ensr);
- case NODE_AND:
- goto andor;
- case NODE_OR:
- andor:
- {
- VALUE ary = rb_ary_new();
-
- while (1) {
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_1st));
- if (!node->nd_2nd || nd_type(node->nd_2nd) != (int)type)
- break;
- node = node->nd_2nd;
- }
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_2nd));
- return ary;
- }
- case NODE_MASGN:
- if (NODE_NAMED_REST_P(node->nd_args)) {
- return rb_ary_new_from_node_args(ast, 3, node->nd_value, node->nd_head, node->nd_args);
- }
- else {
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_value),
- NEW_CHILD(ast, node->nd_head),
- ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST")));
- }
- case NODE_LASGN:
- goto asgn;
- case NODE_DASGN:
- goto asgn;
- case NODE_DASGN_CURR:
- goto asgn;
- case NODE_IASGN:
- goto asgn;
- case NODE_CVASGN:
- asgn:
- if (NODE_REQUIRED_KEYWORD_P(node)) {
- return rb_ary_new_from_args(2, var_name(node->nd_vid), ID2SYM(rb_intern("NODE_SPECIAL_REQUIRED_KEYWORD")));
- }
- return rb_ary_new_from_args(2, var_name(node->nd_vid), NEW_CHILD(ast, node->nd_value));
- case NODE_GASGN:
- goto asgn;
- case NODE_CDECL:
- if (node->nd_vid) {
- return rb_ary_new_from_args(2, ID2SYM(node->nd_vid), NEW_CHILD(ast, node->nd_value));
- }
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_else), ID2SYM(node->nd_else->nd_mid), NEW_CHILD(ast, node->nd_value));
- case NODE_OP_ASGN1:
- return rb_ary_new_from_args(4, NEW_CHILD(ast, node->nd_recv),
- ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args->nd_head),
- NEW_CHILD(ast, node->nd_args->nd_body));
- case NODE_OP_ASGN2:
- return rb_ary_new_from_args(5, NEW_CHILD(ast, node->nd_recv),
- node->nd_next->nd_aid ? Qtrue : Qfalse,
- ID2SYM(node->nd_next->nd_vid),
- ID2SYM(node->nd_next->nd_mid),
- NEW_CHILD(ast, node->nd_value));
- case NODE_OP_ASGN_AND:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head), ID2SYM(idANDOP),
- NEW_CHILD(ast, node->nd_value));
- case NODE_OP_ASGN_OR:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head), ID2SYM(idOROP),
- NEW_CHILD(ast, node->nd_value));
- case NODE_OP_CDECL:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head),
- ID2SYM(node->nd_aid),
- NEW_CHILD(ast, node->nd_value));
- case NODE_CALL:
- case NODE_OPCALL:
- case NODE_QCALL:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv),
- ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args));
- case NODE_FCALL:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args));
- case NODE_VCALL:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_mid));
- case NODE_SUPER:
- return rb_ary_new_from_node_args(ast, 1, node->nd_args);
- case NODE_ZSUPER:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_LIST:
- goto ary;
- case NODE_VALUES:
- ary:
- return dump_array(ast, node);
- case NODE_ZLIST:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_HASH:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
- case NODE_YIELD:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
- case NODE_LVAR:
- case NODE_DVAR:
- return rb_ary_new_from_args(1, var_name(node->nd_vid));
- case NODE_IVAR:
- case NODE_CONST:
- case NODE_CVAR:
- case NODE_GVAR:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_vid));
- case NODE_NTH_REF:
- snprintf(name, sizeof(name), "$%ld", node->nd_nth);
- return rb_ary_new_from_args(1, ID2SYM(rb_intern(name)));
- case NODE_BACK_REF:
- name[0] = '$';
- name[1] = (char)node->nd_nth;
- name[2] = '\0';
- return rb_ary_new_from_args(1, ID2SYM(rb_intern(name)));
- case NODE_MATCH:
- goto lit;
- case NODE_MATCH2:
- if (node->nd_args) {
- return rb_ary_new_from_node_args(ast, 3, node->nd_recv, node->nd_value, node->nd_args);
- }
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_value);
- case NODE_MATCH3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_value);
- case NODE_LIT:
- goto lit;
- case NODE_STR:
- goto lit;
- case NODE_XSTR:
- lit:
- return rb_ary_new_from_args(1, node->nd_lit);
- case NODE_ONCE:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
- case NODE_DSTR:
- goto dlit;
- case NODE_DXSTR:
- goto dlit;
- case NODE_DREGX:
- goto dlit;
- case NODE_DSYM:
- dlit:
- return rb_ary_new_from_args(3, node->nd_lit,
- NEW_CHILD(ast, node->nd_next->nd_head),
- NEW_CHILD(ast, node->nd_next->nd_next));
- case NODE_EVSTR:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
- case NODE_ARGSCAT:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
- case NODE_ARGSPUSH:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
- case NODE_SPLAT:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
- case NODE_BLOCK_PASS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
- case NODE_DEFN:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_defn));
- case NODE_DEFS:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv), ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_defn));
- case NODE_ALIAS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
- case NODE_VALIAS:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_alias), ID2SYM(node->nd_orig));
- case NODE_UNDEF:
- return rb_ary_new_from_node_args(ast, 1, node->nd_undef);
- case NODE_CLASS:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cpath, node->nd_super, node->nd_body);
- case NODE_MODULE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_cpath, node->nd_body);
- case NODE_SCLASS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_body);
- case NODE_COLON2:
- return rb_ary_new_from_args(2, NEW_CHILD(ast, node->nd_head), ID2SYM(node->nd_mid));
- case NODE_COLON3:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_mid));
- case NODE_DOT2:
- goto dot;
- case NODE_DOT3:
- goto dot;
- case NODE_FLIP2:
- goto dot;
- case NODE_FLIP3:
- dot:
- return rb_ary_new_from_node_args(ast, 2, node->nd_beg, node->nd_end);
- case NODE_SELF:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_NIL:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_TRUE:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_FALSE:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_ERRINFO:
- return rb_ary_new_from_node_args(ast, 0);
- case NODE_DEFINED:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
- case NODE_POSTEXE:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
- case NODE_ATTRASGN:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv), ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_args));
- case NODE_LAMBDA:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
- case NODE_OPT_ARG:
- return rb_ary_new_from_node_args(ast, 2, node->nd_body, node->nd_next);
- case NODE_KW_ARG:
- return rb_ary_new_from_node_args(ast, 2, node->nd_body, node->nd_next);
- case NODE_POSTARG:
- if (NODE_NAMED_REST_P(node->nd_1st)) {
- return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
- }
- return rb_ary_new_from_args(2, ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST")),
- NEW_CHILD(ast, node->nd_2nd));
- case NODE_ARGS:
- {
- struct rb_args_info *ainfo = node->nd_ainfo;
- return rb_ary_new_from_args(10,
- INT2NUM(ainfo->pre_args_num),
- NEW_CHILD(ast, ainfo->pre_init),
- NEW_CHILD(ast, ainfo->opt_args),
- var_name(ainfo->first_post_arg),
- INT2NUM(ainfo->post_args_num),
- NEW_CHILD(ast, ainfo->post_init),
- (ainfo->rest_arg == NODE_SPECIAL_EXCESSIVE_COMMA
- ? ID2SYM(rb_intern("NODE_SPECIAL_EXCESSIVE_COMMA"))
- : var_name(ainfo->rest_arg)),
- (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_args)),
- (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_rest_arg)),
- var_name(ainfo->block_arg));
- }
- case NODE_SCOPE:
- {
- ID *tbl = node->nd_tbl;
- int i, size = tbl ? (int)*tbl++ : 0;
- VALUE locals = rb_ary_new_capa(size);
- for (i = 0; i < size; i++) {
- rb_ary_push(locals, var_name(tbl[i]));
- }
- return rb_ary_new_from_args(3, locals, NEW_CHILD(ast, node->nd_args), NEW_CHILD(ast, node->nd_body));
- }
- case NODE_ARYPTN:
- {
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- VALUE rest = NODE_NAMED_REST_P(apinfo->rest_arg) ? NEW_CHILD(ast, apinfo->rest_arg) :
- ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST"));
- return rb_ary_new_from_args(4,
- NEW_CHILD(ast, node->nd_pconst),
- NEW_CHILD(ast, apinfo->pre_args),
- rest,
- NEW_CHILD(ast, apinfo->post_args));
- }
- case NODE_HSHPTN:
- {
- VALUE kwrest = node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD ? ID2SYM(rb_intern("NODE_SPECIAL_NO_REST_KEYWORD")) :
- NEW_CHILD(ast, node->nd_pkwrestarg);
-
- return rb_ary_new_from_args(3,
- NEW_CHILD(ast, node->nd_pconst),
- NEW_CHILD(ast, node->nd_pkwargs),
- kwrest);
- }
- case NODE_ARGS_AUX:
- case NODE_LAST:
- break;
- }
-
- rb_bug("node_children: unknown node: %s", ruby_node_name(type));
-}
-
-static VALUE
-ast_node_children(rb_execution_context_t *ec, VALUE self)
-{
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- return node_children(data->ast, data->node);
-}
-
-static VALUE
-ast_node_first_lineno(rb_execution_context_t *ec, VALUE self)
-{
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- return INT2NUM(nd_first_lineno(data->node));
-}
-
-static VALUE
-ast_node_first_column(rb_execution_context_t *ec, VALUE self)
-{
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- return INT2NUM(nd_first_column(data->node));
-}
-
-static VALUE
-ast_node_last_lineno(rb_execution_context_t *ec, VALUE self)
-{
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- return INT2NUM(nd_last_lineno(data->node));
-}
-
-static VALUE
-ast_node_last_column(rb_execution_context_t *ec, VALUE self)
-{
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- return INT2NUM(nd_last_column(data->node));
-}
-
-static VALUE
-ast_node_inspect(rb_execution_context_t *ec, VALUE self)
-{
- VALUE str;
- VALUE cname;
- struct ASTNodeData *data;
- TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
-
- cname = rb_class_path(rb_obj_class(self));
- str = rb_str_new2("#<");
-
- rb_str_append(str, cname);
- rb_str_catf(str, ":%s@%d:%d-%d:%d>",
- node_type_to_str(data->node),
- nd_first_lineno(data->node), nd_first_column(data->node),
- nd_last_lineno(data->node), nd_last_column(data->node));
-
- return str;
-}
-
-#include "ast.rbinc"
-
-void
-Init_ast(void)
-{
- rb_mAST = rb_define_module_under(rb_cRubyVM, "AbstractSyntaxTree");
- rb_cNode = rb_define_class_under(rb_mAST, "Node", rb_cObject);
- rb_undef_alloc_func(rb_cNode);
-
- load_ast();
-}
diff --git a/ast.rb b/ast.rb
deleted file mode 100644
index 1fedf76649..0000000000
--- a/ast.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-# for ast.c
-
-class RubyVM
-
- # AbstractSyntaxTree provides methods to parse Ruby code into
- # abstract syntax trees. The nodes in the tree
- # are instances of RubyVM::AbstractSyntaxTree::Node.
- #
- # This class is MRI specific as it exposes implementation details
- # of the MRI abstract syntax tree.
- #
- # This class is experimental and its API is not stable, therefore it might
- # change without notice. As examples, the order of children nodes is not
- # guaranteed, the number of children nodes might change, there is no way to
- # access children nodes by name, etc.
- #
- # If you are looking for a stable API or an API working under multiple Ruby
- # implementations, consider using the _parser_ gem or Ripper. If you would
- # like to make RubyVM::AbstractSyntaxTree stable, please join the discussion
- # at https://bugs.ruby-lang.org/issues/14844.
- #
- module AbstractSyntaxTree
-
- # call-seq:
- # RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node
- #
- # Parses the given _string_ into an abstract syntax tree,
- # returning the root node of that tree.
- #
- # SyntaxError is raised if the given _string_ is invalid syntax.
- #
- # RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
- # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9>
- def self.parse string
- __builtin_ast_s_parse string
- end
-
- # call-seq:
- # RubyVM::AbstractSyntaxTree.parse_file(pathname) -> RubyVM::AbstractSyntaxTree::Node
- #
- # Reads the file from _pathname_, then parses it like ::parse,
- # returning the root node of the abstract syntax tree.
- #
- # SyntaxError is raised if _pathname_'s contents are not
- # valid Ruby syntax.
- #
- # RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb")
- # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>
- def self.parse_file pathname
- __builtin_ast_s_parse_file pathname
- end
-
- # call-seq:
- # RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node
- # RubyVM::AbstractSyntaxTree.of(method) -> RubyVM::AbstractSyntaxTree::Node
- #
- # Returns AST nodes of the given _proc_ or _method_.
- #
- # RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
- # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:35-1:42>
- #
- # def hello
- # puts "hello, world"
- # end
- #
- # RubyVM::AbstractSyntaxTree.of(method(:hello))
- # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3>
- def self.of body
- __builtin_ast_s_of body
- end
-
- # RubyVM::AbstractSyntaxTree::Node instances are created by parse methods in
- # RubyVM::AbstractSyntaxTree.
- #
- # This class is MRI specific.
- #
- class Node
-
- # call-seq:
- # node.type -> symbol
- #
- # Returns the type of this node as a symbol.
- #
- # root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
- # root.type # => :SCOPE
- # call = root.children[2]
- # call.type # => :OPCALL
- def type
- __builtin_ast_node_type
- end
-
- # call-seq:
- # node.first_lineno -> integer
- #
- # The line number in the source code where this AST's text began.
- def first_lineno
- __builtin_ast_node_first_lineno
- end
-
- # call-seq:
- # node.first_column -> integer
- #
- # The column number in the source code where this AST's text began.
- def first_column
- __builtin_ast_node_first_column
- end
-
- # call-seq:
- # node.last_lineno -> integer
- #
- # The line number in the source code where this AST's text ended.
- def last_lineno
- __builtin_ast_node_last_lineno
- end
-
- # call-seq:
- # node.last_column -> integer
- #
- # The column number in the source code where this AST's text ended.
- def last_column
- __builtin_ast_node_last_column
- end
-
- # call-seq:
- # node.children -> array
- #
- # Returns AST nodes under this one. Each kind of node
- # has different children, depending on what kind of node it is.
- #
- # The returned array may contain other nodes or <code>nil</code>.
- def children
- __builtin_ast_node_children
- end
-
- # call-seq:
- # node.inspect -> string
- #
- # Returns debugging information about this node as a string.
- def inspect
- __builtin_ast_node_inspect
- end
- end
- end
-end
diff --git a/basictest/test.rb b/basictest/test.rb
index 25a4298234..25d52ca1ef 100755
--- a/basictest/test.rb
+++ b/basictest/test.rb
@@ -35,7 +35,7 @@ class Progress
# dircolors-like style
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
begin
- File.read(File.join(__dir__, "../tool/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
+ File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
colors[n] ||= c
end
rescue
@@ -984,6 +984,13 @@ test_ok($z == 0)
test_check "iterator"
+test_ok(!iterator?)
+
+def ttt
+ test_ok(iterator?)
+end
+ttt{}
+
# yield at top level
test_ok(!defined?(yield))
@@ -1732,7 +1739,7 @@ a = nil
test_ok(defined?(a))
test_ok(a == nil)
-# multiple assignment
+# multiple asignment
a, b = 1, 2
test_ok(a == 1 && b == 2)
diff --git a/benchmark/README.md b/benchmark/README.md
deleted file mode 100644
index 24a2669143..0000000000
--- a/benchmark/README.md
+++ /dev/null
@@ -1,72 +0,0 @@
-# ruby/benchmark
-
-This directory has benchmark definitions to be run with
-[benchmark\_driver.gem](https://github.com/benchmark-driver/benchmark-driver).
-
-## Normal usage
-
-Execute `gem install benchmark_driver` and run a command like:
-
-```bash
-# Run a benchmark script with the ruby in the $PATH
-benchmark-driver benchmark/app_fib.rb
-
-# Run benchmark scripts with multiple Ruby executables or options
-benchmark-driver benchmark/*.rb -e /path/to/ruby -e '/path/to/ruby --jit'
-
-# Or compare Ruby versions managed by rbenv
-benchmark-driver benchmark/*.rb --rbenv '2.5.1;2.6.0-preview2 --jit'
-
-# You can collect many metrics in many ways
-benchmark-driver benchmark/*.rb --runner memory --output markdown
-
-# Some are defined with YAML for complex setup or accurate measurement
-benchmark-driver benchmark/*.yml
-```
-
-See also:
-
-```console
-Usage: benchmark-driver [options] RUBY|YAML...
- -r, --runner TYPE Specify runner type: ips, time, memory, once (default: ips)
- -o, --output TYPE Specify output type: compare, simple, markdown, record (default: compare)
- -e, --executables EXECS Ruby executables (e1::path1 arg1; e2::path2 arg2;...)
- --rbenv VERSIONS Ruby executables in rbenv (x.x.x arg1;y.y.y arg2;...)
- --repeat-count NUM Try benchmark NUM times and use the fastest result or the worst memory usage
- --repeat-result TYPE Yield "best", "average" or "worst" result with --repeat-count (default: best)
- --bundler Install and use gems specified in Gemfile
- --filter REGEXP Filter out benchmarks with given regexp
- --run-duration SECONDS Warmup estimates loop_count to run for this duration (default: 3)
- -v, --verbose Verbose mode. Multiple -v options increase visilibity (max: 2)
-```
-
-## make benchmark
-
-Using `make benchmark`, `make update-benchmark-driver` automatically downloads
-the supported version of benchmark\_driver, and it runs benchmarks with the downloaded
-benchmark\_driver.
-
-```bash
-# Run all benchmarks with the ruby in the $PATH and the built ruby
-make benchmark
-
-# Or compare with specific ruby binary
-make benchmark COMPARE_RUBY="/path/to/ruby --jit"
-
-# Run vm1 benchmarks
-make benchmark ITEM=vm1
-
-# Run some limited benchmarks in ITEM-matched files
-make benchmark ITEM=vm1 OPTS=--filter=block
-
-# You can specify the benchmark by an exact filename instead of using the default argument:
-# ARGS = $$(find $(srcdir)/benchmark -maxdepth 1 -name '*$(ITEM)*.yml' -o -name '*$(ITEM)*.rb')
-make benchmark ARGS=../benchmark/erb_render.yml
-
-# You can specify any option via $OPTS
-make benchmark OPTS="--help"
-
-# With `make benchmark`, some special runner plugins are available:
-# -r peak, -r size, -r total, -r utime, -r stime, -r cutime, -r cstime
-make benchmark ITEM=vm2_bigarray OPTS="-r peak"
-```
diff --git a/benchmark/app_aobench.rb b/benchmark/app_aobench.rb
deleted file mode 100644
index 16296af12b..0000000000
--- a/benchmark/app_aobench.rb
+++ /dev/null
@@ -1,297 +0,0 @@
-# coding: US-ASCII
-
-# AO render benchmark
-# Original program (C) Syoyo Fujita in Javascript (and other languages)
-# https://code.google.com/p/aobench/
-# Ruby(yarv2llvm) version by Hideki Miura
-#
-
-IMAGE_WIDTH = 256
-IMAGE_HEIGHT = 256
-NSUBSAMPLES = 2
-NAO_SAMPLES = 8
-
-srand(0)
-
-class Vec
- def initialize(x, y, z)
- @x = x
- @y = y
- @z = z
- end
-
- attr_accessor :x, :y, :z
-
- def vadd(b)
- Vec.new(@x + b.x, @y + b.y, @z + b.z)
- end
-
- def vsub(b)
- Vec.new(@x - b.x, @y - b.y, @z - b.z)
- end
-
- def vcross(b)
- Vec.new(@y * b.z - @z * b.y,
- @z * b.x - @x * b.z,
- @x * b.y - @y * b.x)
- end
-
- def vdot(b)
- @x * b.x + @y * b.y + @z * b.z
- end
-
- def vlength
- Math.sqrt(@x * @x + @y * @y + @z * @z)
- end
-
- def vnormalize
- len = vlength
- v = Vec.new(@x, @y, @z)
- if len > 1.0e-17 then
- v.x = v.x / len
- v.y = v.y / len
- v.z = v.z / len
- end
- v
- end
-end
-
-
-class Sphere
- def initialize(center, radius)
- @center = center
- @radius = radius
- end
-
- attr_reader :center, :radius
-
- def intersect(ray, isect)
- rs = ray.org.vsub(@center)
- b = rs.vdot(ray.dir)
- c = rs.vdot(rs) - (@radius * @radius)
- d = b * b - c
- if d > 0.0 then
- t = - b - Math.sqrt(d)
-
- if t > 0.0 and t < isect.t then
- isect.t = t
- isect.hit = true
- isect.pl = Vec.new(ray.org.x + ray.dir.x * t,
- ray.org.y + ray.dir.y * t,
- ray.org.z + ray.dir.z * t)
- n = isect.pl.vsub(@center)
- isect.n = n.vnormalize
- else
- 0.0
- end
- end
- nil
- end
-end
-
-class Plane
- def initialize(p, n)
- @p = p
- @n = n
- end
-
- def intersect(ray, isect)
- d = -@p.vdot(@n)
- v = ray.dir.vdot(@n)
- v0 = v
- if v < 0.0 then
- v0 = -v
- end
- if v0 < 1.0e-17 then
- return
- end
-
- t = -(ray.org.vdot(@n) + d) / v
-
- if t > 0.0 and t < isect.t then
- isect.hit = true
- isect.t = t
- isect.n = @n
- isect.pl = Vec.new(ray.org.x + t * ray.dir.x,
- ray.org.y + t * ray.dir.y,
- ray.org.z + t * ray.dir.z)
- end
- nil
- end
-end
-
-class Ray
- def initialize(org, dir)
- @org = org
- @dir = dir
- end
-
- attr_accessor :org, :dir
-end
-
-class Isect
- def initialize
- @t = 10000000.0
- @hit = false
- @pl = Vec.new(0.0, 0.0, 0.0)
- @n = Vec.new(0.0, 0.0, 0.0)
- end
-
- attr_accessor :t, :hit, :pl, :n
-end
-
-def clamp(f)
- i = f * 255.5
- if i > 255.0 then
- i = 255.0
- end
- if i < 0.0 then
- i = 0.0
- end
- i.to_i
-end
-
-def otherBasis(basis, n)
- basis[2] = Vec.new(n.x, n.y, n.z)
- basis[1] = Vec.new(0.0, 0.0, 0.0)
-
- if n.x < 0.6 and n.x > -0.6 then
- basis[1].x = 1.0
- elsif n.y < 0.6 and n.y > -0.6 then
- basis[1].y = 1.0
- elsif n.z < 0.6 and n.z > -0.6 then
- basis[1].z = 1.0
- else
- basis[1].x = 1.0
- end
-
- basis[0] = basis[1].vcross(basis[2])
- basis[0] = basis[0].vnormalize
-
- basis[1] = basis[2].vcross(basis[0])
- basis[1] = basis[1].vnormalize
-end
-
-class Scene
- def initialize
- @spheres = Array.new
- @spheres[0] = Sphere.new(Vec.new(-2.0, 0.0, -3.5), 0.5)
- @spheres[1] = Sphere.new(Vec.new(-0.5, 0.0, -3.0), 0.5)
- @spheres[2] = Sphere.new(Vec.new(1.0, 0.0, -2.2), 0.5)
- @plane = Plane.new(Vec.new(0.0, -0.5, 0.0), Vec.new(0.0, 1.0, 0.0))
- end
-
- def ambient_occlusion(isect)
- basis = Array.new
- otherBasis(basis, isect.n)
-
- ntheta = NAO_SAMPLES
- nphi = NAO_SAMPLES
- eps = 0.0001
- occlusion = 0.0
-
- p0 = Vec.new(isect.pl.x + eps * isect.n.x,
- isect.pl.y + eps * isect.n.y,
- isect.pl.z + eps * isect.n.z)
- nphi.times do |j|
- ntheta.times do |i|
- r = rand
- phi = 2.0 * 3.14159265 * rand
- x = Math.cos(phi) * Math.sqrt(1.0 - r)
- y = Math.sin(phi) * Math.sqrt(1.0 - r)
- z = Math.sqrt(r)
-
- rx = x * basis[0].x + y * basis[1].x + z * basis[2].x
- ry = x * basis[0].y + y * basis[1].y + z * basis[2].y
- rz = x * basis[0].z + y * basis[1].z + z * basis[2].z
-
- raydir = Vec.new(rx, ry, rz)
- ray = Ray.new(p0, raydir)
-
- occisect = Isect.new
- @spheres[0].intersect(ray, occisect)
- @spheres[1].intersect(ray, occisect)
- @spheres[2].intersect(ray, occisect)
- @plane.intersect(ray, occisect)
- if occisect.hit then
- occlusion = occlusion + 1.0
- else
- 0.0
- end
- end
- end
-
- occlusion = (ntheta.to_f * nphi.to_f - occlusion) / (ntheta.to_f * nphi.to_f)
-
- Vec.new(occlusion, occlusion, occlusion)
- end
-
- def render(w, h, nsubsamples)
- cnt = 0
- nsf = nsubsamples.to_f
- h.times do |y|
- w.times do |x|
- rad = Vec.new(0.0, 0.0, 0.0)
-
- # Subsampling
- nsubsamples.times do |v|
- nsubsamples.times do |u|
-
- cnt = cnt + 1
- wf = w.to_f
- hf = h.to_f
- xf = x.to_f
- yf = y.to_f
- uf = u.to_f
- vf = v.to_f
-
- px = (xf + (uf / nsf) - (wf / 2.0)) / (wf / 2.0)
- py = -(yf + (vf / nsf) - (hf / 2.0)) / (hf / 2.0)
-
- eye = Vec.new(px, py, -1.0).vnormalize
-
- ray = Ray.new(Vec.new(0.0, 0.0, 0.0), eye)
-
- isect = Isect.new
- @spheres[0].intersect(ray, isect)
- @spheres[1].intersect(ray, isect)
- @spheres[2].intersect(ray, isect)
- @plane.intersect(ray, isect)
- if isect.hit then
- col = ambient_occlusion(isect)
- rad.x = rad.x + col.x
- rad.y = rad.y + col.y
- rad.z = rad.z + col.z
- end
- end
- end
-
- r = rad.x / (nsf * nsf)
- g = rad.y / (nsf * nsf)
- b = rad.z / (nsf * nsf)
- printf("%c", clamp(r))
- printf("%c", clamp(g))
- printf("%c", clamp(b))
- end
- nil
- end
-
- nil
- end
-end
-
-alias printf_orig printf
-def printf *args
- # $fp.printf(*args)
-end
-
-# File.open("ao.ppm", "w") do |fp|
- # $fp = fp
- printf("P6\n")
- printf("%d %d\n", IMAGE_WIDTH, IMAGE_HEIGHT)
- printf("255\n")
- Scene.new.render(IMAGE_WIDTH, IMAGE_HEIGHT, NSUBSAMPLES)
-# end
-
-undef printf
-alias printf printf_orig
diff --git a/benchmark/app_erb.yml b/benchmark/app_erb.yml
deleted file mode 100644
index 31e29b7644..0000000000
--- a/benchmark/app_erb.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Create many HTML strings with ERB.
-#
-prelude: |
- require 'erb'
-
- data = <<erb
- <html>
- <head> <%= title %> </head>
- <body>
- <h1> <%= title %> </h1>
- <p>
- <%= content %>
- </p>
- </body>
- </html>
- erb
-
- title = "hello world!"
- content = "hello world!\n" * 10
-benchmark:
- app_erb: ERB.new(data).result(binding)
-loop_count: 15000
diff --git a/benchmark/app_pentomino.rb b/benchmark/app_pentomino.rb
deleted file mode 100644
index 47be7b203f..0000000000
--- a/benchmark/app_pentomino.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/local/bin/ruby
-# This program is contributed by Shin Nishiyama
-
-
-# modified by K.Sasada
-
-NP = 5
-ROW = 8 + NP
-COL = 8
-
-$p = []
-$b = []
-$no = 0
-
-def piece(n, a, nb)
- nb.each{|x|
- a[n] = x
- if n == NP-1
- $p << [a.sort]
- else
- nbc=nb.dup
- [-ROW, -1, 1, ROW].each{|d|
- if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d)
- nbc << x+d
- end
- }
- nbc.delete x
- piece(n+1,a[0..n],nbc)
- end
- }
-end
-
-def kikaku(a)
- a.collect {|x| x - a[0]}
-end
-def ud(a)
- kikaku(a.collect {|x| ((x+NP)%ROW)-ROW*((x+NP)/ROW) }.sort)
-end
-def rl(a)
- kikaku(a.collect {|x| ROW*((x+NP)/ROW)+ROW-((x+NP)%ROW)}.sort)
-end
-def xy(a)
- kikaku(a.collect {|x| ROW*((x+NP)%ROW) + (x+NP)/ROW }.sort)
-end
-
-def mkpieces
- piece(0,[],[0])
- $p.each do |a|
- a0 = a[0]
- a[1] = ud(a0)
- a[2] = rl(a0)
- a[3] = ud(rl(a0))
- a[4] = xy(a0)
- a[5] = ud(xy(a0))
- a[6] = rl(xy(a0))
- a[7] = ud(rl(xy(a0)))
- a.sort!
- a.uniq!
- end
- $p.uniq!.sort! {|x,y| x[0] <=> y[0] }
-end
-
-def mkboard
- (0...ROW*COL).each{|i|
- if i % ROW >= ROW-NP
- $b[i] = -2
- else
- $b[i] = -1
- end
- $b[3*ROW+3]=$b[3*ROW+4]=$b[4*ROW+3]=$b[4*ROW+4]=-2
- }
-end
-
-def pboard
- return # skip print
- print "No. #$no\n"
- (0...COL).each{|i|
- print "|"
- (0...ROW-NP).each{|j|
- x = $b[i*ROW+j]
- if x < 0
- print "..|"
- else
- printf "%2d|",x+1
- end
- }
- print "\n"
- }
- print "\n"
-end
-
-$pnum=[]
-def setpiece(a,pos)
- if a.length == $p.length then
- $no += 1
- pboard
- return
- end
- while $b[pos] != -1
- pos += 1
- end
- ($pnum - a).each do |i|
- $p[i].each do |x|
- f = 0
- x.each{|s|
- if $b[pos+s] != -1
- f=1
- break
- end
- }
- if f == 0 then
- x.each{|s|
- $b[pos+s] = i
- }
- a << i
- setpiece(a.dup, pos)
- a.pop
- x.each{|s|
- $b[pos+s] = -1
- }
- end
- end
- end
-end
-
-mkpieces
-mkboard
-$p[4] = [$p[4][0]]
-$pnum = (0...$p.length).to_a
-setpiece([],0)
diff --git a/benchmark/array_flatten.yml b/benchmark/array_flatten.yml
deleted file mode 100644
index 88ef544ba0..0000000000
--- a/benchmark/array_flatten.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-prelude: |
- small_flat_ary = 5.times.to_a
- large_flat_ary = 100.times.to_a
- small_pairs_ary = [[1, 2]] * 5
- large_pairs_ary = [[1, 2]] * 100
- mostly_flat_ary = 100.times.to_a.push([101, 102])
-
-benchmark:
- small_flat_ary.flatten: small_flat_ary.flatten
- small_flat_ary.flatten!: small_flat_ary.flatten!
- large_flat_ary.flatten: large_flat_ary.flatten
- large_flat_ary.flatten!: large_flat_ary.flatten!
- small_pairs_ary.flatten: small_pairs_ary.flatten
- small_pairs_ary.flatten!: small_pairs_ary.dup.flatten!
- large_pairs_ary.flatten: large_pairs_ary.flatten
- large_pairs_ary.flatten!: large_pairs_ary.dup.flatten!
- mostly_flat_ary.flatten: mostly_flat_ary.flatten
- mostly_flat_ary.flatten!: mostly_flat_ary.dup.flatten!
-loop_count: 10000
diff --git a/benchmark/array_intersection.yml b/benchmark/array_intersection.yml
deleted file mode 100644
index 26705323fd..0000000000
--- a/benchmark/array_intersection.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-prelude: |
- small1 = [1, 2, 3]
- small2 = [1, 2, 3, 4, 5]
- small3 = [2, 3, 4, 5]
- small4 = [2]
- big1 = [1, 2, 3, 4] * 64
- big2 = [1, 2, 3] * 64
- big3 = [1, 2] * 64
-
-benchmark:
- small-&: small1 & small2 & small3 & small4
- small-intersection: small1.intersection(small2, small3, small4)
- big-&: big1 & big2 & big3
- big-intersection: big1.intersection(big2, big3)
diff --git a/benchmark/array_values_at_int.rb b/benchmark/array_values_at_int.rb
deleted file mode 100644
index 6cb394cb9f..0000000000
--- a/benchmark/array_values_at_int.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-ary = Array.new(10000) {|i| i}
-100000.times { ary.values_at(500) }
diff --git a/benchmark/array_values_at_range.rb b/benchmark/array_values_at_range.rb
deleted file mode 100644
index 5b53806d1c..0000000000
--- a/benchmark/array_values_at_range.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-ary = Array.new(10000) {|i| i}
-100000.times { ary.values_at(1..2000) }
diff --git a/benchmark/app_answer.rb b/benchmark/bm_app_answer.rb
index 3cd8a8fd37..3cd8a8fd37 100644
--- a/benchmark/app_answer.rb
+++ b/benchmark/bm_app_answer.rb
diff --git a/benchmark/bm_app_aobench.rb b/benchmark/bm_app_aobench.rb
new file mode 100644
index 0000000000..2bd6acfaf8
--- /dev/null
+++ b/benchmark/bm_app_aobench.rb
@@ -0,0 +1,291 @@
+# AO render benchmark
+# Original program (C) Syoyo Fujita in Javascript (and other languages)
+# https://code.google.com/p/aobench/
+# Ruby(yarv2llvm) version by Hideki Miura
+#
+
+IMAGE_WIDTH = 256
+IMAGE_HEIGHT = 256
+NSUBSAMPLES = 2
+NAO_SAMPLES = 8
+
+class Vec
+ def initialize(x, y, z)
+ @x = x
+ @y = y
+ @z = z
+ end
+
+ attr_accessor :x, :y, :z
+
+ def vadd(b)
+ Vec.new(@x + b.x, @y + b.y, @z + b.z)
+ end
+
+ def vsub(b)
+ Vec.new(@x - b.x, @y - b.y, @z - b.z)
+ end
+
+ def vcross(b)
+ Vec.new(@y * b.z - @z * b.y,
+ @z * b.x - @x * b.z,
+ @x * b.y - @y * b.x)
+ end
+
+ def vdot(b)
+ @x * b.x + @y * b.y + @z * b.z
+ end
+
+ def vlength
+ Math.sqrt(@x * @x + @y * @y + @z * @z)
+ end
+
+ def vnormalize
+ len = vlength
+ v = Vec.new(@x, @y, @z)
+ if len > 1.0e-17 then
+ v.x = v.x / len
+ v.y = v.y / len
+ v.z = v.z / len
+ end
+ v
+ end
+end
+
+
+class Sphere
+ def initialize(center, radius)
+ @center = center
+ @radius = radius
+ end
+
+ attr_reader :center, :radius
+
+ def intersect(ray, isect)
+ rs = ray.org.vsub(@center)
+ b = rs.vdot(ray.dir)
+ c = rs.vdot(rs) - (@radius * @radius)
+ d = b * b - c
+ if d > 0.0 then
+ t = - b - Math.sqrt(d)
+
+ if t > 0.0 and t < isect.t then
+ isect.t = t
+ isect.hit = true
+ isect.pl = Vec.new(ray.org.x + ray.dir.x * t,
+ ray.org.y + ray.dir.y * t,
+ ray.org.z + ray.dir.z * t)
+ n = isect.pl.vsub(@center)
+ isect.n = n.vnormalize
+ else
+ 0.0
+ end
+ end
+ nil
+ end
+end
+
+class Plane
+ def initialize(p, n)
+ @p = p
+ @n = n
+ end
+
+ def intersect(ray, isect)
+ d = -@p.vdot(@n)
+ v = ray.dir.vdot(@n)
+ v0 = v
+ if v < 0.0 then
+ v0 = -v
+ end
+ if v0 < 1.0e-17 then
+ return
+ end
+
+ t = -(ray.org.vdot(@n) + d) / v
+
+ if t > 0.0 and t < isect.t then
+ isect.hit = true
+ isect.t = t
+ isect.n = @n
+ isect.pl = Vec.new(ray.org.x + t * ray.dir.x,
+ ray.org.y + t * ray.dir.y,
+ ray.org.z + t * ray.dir.z)
+ end
+ nil
+ end
+end
+
+class Ray
+ def initialize(org, dir)
+ @org = org
+ @dir = dir
+ end
+
+ attr_accessor :org, :dir
+end
+
+class Isect
+ def initialize
+ @t = 10000000.0
+ @hit = false
+ @pl = Vec.new(0.0, 0.0, 0.0)
+ @n = Vec.new(0.0, 0.0, 0.0)
+ end
+
+ attr_accessor :t, :hit, :pl, :n
+end
+
+def clamp(f)
+ i = f * 255.5
+ if i > 255.0 then
+ i = 255.0
+ end
+ if i < 0.0 then
+ i = 0.0
+ end
+ i.to_i
+end
+
+def otherBasis(basis, n)
+ basis[2] = Vec.new(n.x, n.y, n.z)
+ basis[1] = Vec.new(0.0, 0.0, 0.0)
+
+ if n.x < 0.6 and n.x > -0.6 then
+ basis[1].x = 1.0
+ elsif n.y < 0.6 and n.y > -0.6 then
+ basis[1].y = 1.0
+ elsif n.z < 0.6 and n.z > -0.6 then
+ basis[1].z = 1.0
+ else
+ basis[1].x = 1.0
+ end
+
+ basis[0] = basis[1].vcross(basis[2])
+ basis[0] = basis[0].vnormalize
+
+ basis[1] = basis[2].vcross(basis[0])
+ basis[1] = basis[1].vnormalize
+end
+
+class Scene
+ def initialize
+ @spheres = Array.new
+ @spheres[0] = Sphere.new(Vec.new(-2.0, 0.0, -3.5), 0.5)
+ @spheres[1] = Sphere.new(Vec.new(-0.5, 0.0, -3.0), 0.5)
+ @spheres[2] = Sphere.new(Vec.new(1.0, 0.0, -2.2), 0.5)
+ @plane = Plane.new(Vec.new(0.0, -0.5, 0.0), Vec.new(0.0, 1.0, 0.0))
+ end
+
+ def ambient_occlusion(isect)
+ basis = Array.new
+ otherBasis(basis, isect.n)
+
+ ntheta = NAO_SAMPLES
+ nphi = NAO_SAMPLES
+ eps = 0.0001
+ occlusion = 0.0
+
+ p0 = Vec.new(isect.pl.x + eps * isect.n.x,
+ isect.pl.y + eps * isect.n.y,
+ isect.pl.z + eps * isect.n.z)
+ nphi.times do |j|
+ ntheta.times do |i|
+ r = rand
+ phi = 2.0 * 3.14159265 * rand
+ x = Math.cos(phi) * Math.sqrt(1.0 - r)
+ y = Math.sin(phi) * Math.sqrt(1.0 - r)
+ z = Math.sqrt(r)
+
+ rx = x * basis[0].x + y * basis[1].x + z * basis[2].x
+ ry = x * basis[0].y + y * basis[1].y + z * basis[2].y
+ rz = x * basis[0].z + y * basis[1].z + z * basis[2].z
+
+ raydir = Vec.new(rx, ry, rz)
+ ray = Ray.new(p0, raydir)
+
+ occisect = Isect.new
+ @spheres[0].intersect(ray, occisect)
+ @spheres[1].intersect(ray, occisect)
+ @spheres[2].intersect(ray, occisect)
+ @plane.intersect(ray, occisect)
+ if occisect.hit then
+ occlusion = occlusion + 1.0
+ else
+ 0.0
+ end
+ end
+ end
+
+ occlusion = (ntheta.to_f * nphi.to_f - occlusion) / (ntheta.to_f * nphi.to_f)
+
+ Vec.new(occlusion, occlusion, occlusion)
+ end
+
+ def render(w, h, nsubsamples)
+ cnt = 0
+ nsf = nsubsamples.to_f
+ h.times do |y|
+ w.times do |x|
+ rad = Vec.new(0.0, 0.0, 0.0)
+
+ # Subsampling
+ nsubsamples.times do |v|
+ nsubsamples.times do |u|
+
+ cnt = cnt + 1
+ wf = w.to_f
+ hf = h.to_f
+ xf = x.to_f
+ yf = y.to_f
+ uf = u.to_f
+ vf = v.to_f
+
+ px = (xf + (uf / nsf) - (wf / 2.0)) / (wf / 2.0)
+ py = -(yf + (vf / nsf) - (hf / 2.0)) / (hf / 2.0)
+
+ eye = Vec.new(px, py, -1.0).vnormalize
+
+ ray = Ray.new(Vec.new(0.0, 0.0, 0.0), eye)
+
+ isect = Isect.new
+ @spheres[0].intersect(ray, isect)
+ @spheres[1].intersect(ray, isect)
+ @spheres[2].intersect(ray, isect)
+ @plane.intersect(ray, isect)
+ if isect.hit then
+ col = ambient_occlusion(isect)
+ rad.x = rad.x + col.x
+ rad.y = rad.y + col.y
+ rad.z = rad.z + col.z
+ end
+ end
+ end
+
+ r = rad.x / (nsf * nsf)
+ g = rad.y / (nsf * nsf)
+ b = rad.z / (nsf * nsf)
+ printf("%c", clamp(r))
+ printf("%c", clamp(g))
+ printf("%c", clamp(b))
+ end
+ nil
+ end
+
+ nil
+ end
+end
+
+alias printf_orig printf
+def printf *args
+end
+
+# File.open("ao.ppm", "w") do |fp|
+ printf("P6\n")
+ printf("%d %d\n", IMAGE_WIDTH, IMAGE_HEIGHT)
+ printf("255\n", IMAGE_WIDTH, IMAGE_HEIGHT)
+ Scene.new.render(IMAGE_WIDTH, IMAGE_HEIGHT, NSUBSAMPLES)
+# end
+
+undef printf
+alias printf printf_orig
diff --git a/benchmark/bm_app_erb.rb b/benchmark/bm_app_erb.rb
new file mode 100644
index 0000000000..77c66a7949
--- /dev/null
+++ b/benchmark/bm_app_erb.rb
@@ -0,0 +1,26 @@
+#
+# Create many HTML strings with ERB.
+#
+
+require 'erb'
+
+data = DATA.read
+max = 15_000
+title = "hello world!"
+content = "hello world!\n" * 10
+
+max.times{
+ ERB.new(data).result(binding)
+}
+
+__END__
+
+<html>
+ <head> <%= title %> </head>
+ <body>
+ <h1> <%= title %> </h1>
+ <p>
+ <%= content %>
+ </p>
+ </body>
+</html>
diff --git a/benchmark/app_factorial.rb b/benchmark/bm_app_factorial.rb
index 45f471dfdb..45f471dfdb 100644
--- a/benchmark/app_factorial.rb
+++ b/benchmark/bm_app_factorial.rb
diff --git a/benchmark/app_fib.rb b/benchmark/bm_app_fib.rb
index 34a7b2e725..34a7b2e725 100644
--- a/benchmark/app_fib.rb
+++ b/benchmark/bm_app_fib.rb
diff --git a/benchmark/app_lc_fizzbuzz.rb b/benchmark/bm_app_lc_fizzbuzz.rb
index f09574bbeb..f09574bbeb 100644
--- a/benchmark/app_lc_fizzbuzz.rb
+++ b/benchmark/bm_app_lc_fizzbuzz.rb
diff --git a/benchmark/app_mandelbrot.rb b/benchmark/bm_app_mandelbrot.rb
index 801b75e8e2..801b75e8e2 100644
--- a/benchmark/app_mandelbrot.rb
+++ b/benchmark/bm_app_mandelbrot.rb
diff --git a/benchmark/bm_app_pentomino.rb b/benchmark/bm_app_pentomino.rb
new file mode 100644
index 0000000000..59c63f358e
--- /dev/null
+++ b/benchmark/bm_app_pentomino.rb
@@ -0,0 +1,259 @@
+#!/usr/local/bin/ruby
+# This program is contributed by Shin Nishiyama
+
+
+# modified by K.Sasada
+
+NP = 5
+ROW = 8 + NP
+COL = 8
+
+$p = []
+$b = []
+$no = 0
+
+def piece(n, a, nb)
+ nb.each{|x|
+ a[n] = x
+ if n == NP-1
+ $p << [a.sort]
+ else
+ nbc=nb.dup
+ [-ROW, -1, 1, ROW].each{|d|
+ if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d)
+ nbc << x+d
+ end
+ }
+ nbc.delete x
+ piece(n+1,a[0..n],nbc)
+ end
+ }
+end
+
+def kikaku(a)
+ a.collect {|x| x - a[0]}
+end
+def ud(a)
+ kikaku(a.collect {|x| ((x+NP)%ROW)-ROW*((x+NP)/ROW) }.sort)
+end
+def rl(a)
+ kikaku(a.collect {|x| ROW*((x+NP)/ROW)+ROW-((x+NP)%ROW)}.sort)
+end
+def xy(a)
+ kikaku(a.collect {|x| ROW*((x+NP)%ROW) + (x+NP)/ROW }.sort)
+end
+
+def mkpieces
+ piece(0,[],[0])
+ $p.each do |a|
+ a0 = a[0]
+ a[1] = ud(a0)
+ a[2] = rl(a0)
+ a[3] = ud(rl(a0))
+ a[4] = xy(a0)
+ a[5] = ud(xy(a0))
+ a[6] = rl(xy(a0))
+ a[7] = ud(rl(xy(a0)))
+ a.sort!
+ a.uniq!
+ end
+ $p.uniq!.sort! {|x,y| x[0] <=> y[0] }
+end
+
+def mkboard
+ (0...ROW*COL).each{|i|
+ if i % ROW >= ROW-NP
+ $b[i] = -2
+ else
+ $b[i] = -1
+ end
+ $b[3*ROW+3]=$b[3*ROW+4]=$b[4*ROW+3]=$b[4*ROW+4]=-2
+ }
+end
+
+def pboard
+ return # skip print
+ print "No. #$no\n"
+ (0...COL).each{|i|
+ print "|"
+ (0...ROW-NP).each{|j|
+ x = $b[i*ROW+j]
+ if x < 0
+ print "..|"
+ else
+ printf "%2d|",x+1
+ end
+ }
+ print "\n"
+ }
+ print "\n"
+end
+
+$pnum=[]
+def setpiece(a,pos)
+ if a.length == $p.length then
+ $no += 1
+ pboard
+ return
+ end
+ while $b[pos] != -1
+ pos += 1
+ end
+ ($pnum - a).each do |i|
+ $p[i].each do |x|
+ f = 0
+ x.each{|s|
+ if $b[pos+s] != -1
+ f=1
+ break
+ end
+ }
+ if f == 0 then
+ x.each{|s|
+ $b[pos+s] = i
+ }
+ a << i
+ setpiece(a.dup, pos)
+ a.pop
+ x.each{|s|
+ $b[pos+s] = -1
+ }
+ end
+ end
+ end
+end
+
+mkpieces
+mkboard
+$p[4] = [$p[4][0]]
+$pnum = (0...$p.length).to_a
+setpiece([],0)
+
+
+__END__
+
+# original
+
+NP = 5
+ROW = 8 + NP
+COL = 8
+
+$p = []
+$b = []
+$no = 0
+
+def piece(n,a,nb)
+ for x in nb
+ a[n] = x
+ if n == NP-1
+ $p << [a.sort]
+ else
+ nbc=nb.dup
+ for d in [-ROW, -1, 1, ROW]
+ if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d)
+ nbc << x+d
+ end
+ end
+ nbc.delete x
+ piece(n+1,a[0..n],nbc)
+ end
+ end
+end
+
+def kikaku(a)
+ a.collect {|x| x - a[0]}
+end
+def ud(a)
+ kikaku(a.collect {|x| ((x+NP)%ROW)-ROW*((x+NP)/ROW) }.sort)
+end
+def rl(a)
+ kikaku(a.collect {|x| ROW*((x+NP)/ROW)+ROW-((x+NP)%ROW)}.sort)
+end
+def xy(a)
+ kikaku(a.collect {|x| ROW*((x+NP)%ROW) + (x+NP)/ROW }.sort)
+end
+
+def mkpieces
+ piece(0,[],[0])
+ $p.each do |a|
+ a0 = a[0]
+ a[1] = ud(a0)
+ a[2] = rl(a0)
+ a[3] = ud(rl(a0))
+ a[4] = xy(a0)
+ a[5] = ud(xy(a0))
+ a[6] = rl(xy(a0))
+ a[7] = ud(rl(xy(a0)))
+ a.sort!
+ a.uniq!
+ end
+ $p.uniq!.sort! {|x,y| x[0] <=> y[0] }
+end
+
+def mkboard
+ for i in 0...ROW*COL
+ if i % ROW >= ROW-NP
+ $b[i] = -2
+ else
+ $b[i] = -1
+ end
+ $b[3*ROW+3]=$b[3*ROW+4]=$b[4*ROW+3]=$b[4*ROW+4]=-2
+ end
+end
+
+def pboard
+ print "No. #$no\n"
+ for i in 0...COL
+ print "|"
+ for j in 0...ROW-NP
+ x = $b[i*ROW+j]
+ if x < 0
+ print "..|"
+ else
+ printf "%2d|",x+1
+ end
+ end
+ print "\n"
+ end
+ print "\n"
+end
+
+$pnum=[]
+def setpiece(a,pos)
+ if a.length == $p.length then
+ $no += 1
+ pboard
+ return
+ end
+ while $b[pos] != -1
+ pos += 1
+ end
+ ($pnum - a).each do |i|
+ $p[i].each do |x|
+ f = 0
+ for s in x do
+ if $b[pos+s] != -1
+ f=1
+ break
+ end
+ end
+ if f == 0 then
+ for s in x do
+ $b[pos+s] = i
+ end
+ a << i
+ setpiece(a.dup, pos)
+ a.pop
+ for s in x do
+ $b[pos+s] = -1
+ end
+ end
+ end
+ end
+end
+
+mkpieces
+mkboard
+$p[4] = [$p[4][0]]
+$pnum = (0...$p.length).to_a
+setpiece([],0)
diff --git a/benchmark/app_raise.rb b/benchmark/bm_app_raise.rb
index 5db8f95d50..5db8f95d50 100644
--- a/benchmark/app_raise.rb
+++ b/benchmark/bm_app_raise.rb
diff --git a/benchmark/app_strconcat.rb b/benchmark/bm_app_strconcat.rb
index 7eed7c1aed..7eed7c1aed 100644
--- a/benchmark/app_strconcat.rb
+++ b/benchmark/bm_app_strconcat.rb
diff --git a/benchmark/app_tak.rb b/benchmark/bm_app_tak.rb
index efe5380f4e..efe5380f4e 100644
--- a/benchmark/app_tak.rb
+++ b/benchmark/bm_app_tak.rb
diff --git a/benchmark/app_tarai.rb b/benchmark/bm_app_tarai.rb
index 4c146f5ccf..4c146f5ccf 100644
--- a/benchmark/app_tarai.rb
+++ b/benchmark/bm_app_tarai.rb
diff --git a/benchmark/app_uri.rb b/benchmark/bm_app_uri.rb
index 586edfd5dc..586edfd5dc 100644
--- a/benchmark/app_uri.rb
+++ b/benchmark/bm_app_uri.rb
diff --git a/benchmark/array_sample_100k_10.rb b/benchmark/bm_array_sample_100k_10.rb
index 5f41ecc32b..5f41ecc32b 100644
--- a/benchmark/array_sample_100k_10.rb
+++ b/benchmark/bm_array_sample_100k_10.rb
diff --git a/benchmark/array_sample_100k_11.rb b/benchmark/bm_array_sample_100k_11.rb
index 18b1715319..18b1715319 100644
--- a/benchmark/array_sample_100k_11.rb
+++ b/benchmark/bm_array_sample_100k_11.rb
diff --git a/benchmark/array_sample_100k__100.rb b/benchmark/bm_array_sample_100k__100.rb
index 22863afe89..22863afe89 100644
--- a/benchmark/array_sample_100k__100.rb
+++ b/benchmark/bm_array_sample_100k__100.rb
diff --git a/benchmark/array_sample_100k__1k.rb b/benchmark/bm_array_sample_100k__1k.rb
index 4cd79e6c67..4cd79e6c67 100644
--- a/benchmark/array_sample_100k__1k.rb
+++ b/benchmark/bm_array_sample_100k__1k.rb
diff --git a/benchmark/array_sample_100k__6k.rb b/benchmark/bm_array_sample_100k__6k.rb
index b3d264249e..b3d264249e 100644
--- a/benchmark/array_sample_100k__6k.rb
+++ b/benchmark/bm_array_sample_100k__6k.rb
diff --git a/benchmark/array_sample_100k___10k.rb b/benchmark/bm_array_sample_100k___10k.rb
index 5dd55ec058..5dd55ec058 100644
--- a/benchmark/array_sample_100k___10k.rb
+++ b/benchmark/bm_array_sample_100k___10k.rb
diff --git a/benchmark/array_sample_100k___50k.rb b/benchmark/bm_array_sample_100k___50k.rb
index 1506732c3c..1506732c3c 100644
--- a/benchmark/array_sample_100k___50k.rb
+++ b/benchmark/bm_array_sample_100k___50k.rb
diff --git a/benchmark/array_shift.rb b/benchmark/bm_array_shift.rb
index 798bb9e3f4..798bb9e3f4 100644
--- a/benchmark/array_shift.rb
+++ b/benchmark/bm_array_shift.rb
diff --git a/benchmark/array_small_and.rb b/benchmark/bm_array_small_and.rb
index e53a6edae6..e53a6edae6 100644
--- a/benchmark/array_small_and.rb
+++ b/benchmark/bm_array_small_and.rb
diff --git a/benchmark/array_small_diff.rb b/benchmark/bm_array_small_diff.rb
index 9661ee48db..9661ee48db 100644
--- a/benchmark/array_small_diff.rb
+++ b/benchmark/bm_array_small_diff.rb
diff --git a/benchmark/array_small_or.rb b/benchmark/bm_array_small_or.rb
index c58b5fd1ff..c58b5fd1ff 100644
--- a/benchmark/array_small_or.rb
+++ b/benchmark/bm_array_small_or.rb
diff --git a/benchmark/array_sort_block.rb b/benchmark/bm_array_sort_block.rb
index 3579786056..3579786056 100644
--- a/benchmark/array_sort_block.rb
+++ b/benchmark/bm_array_sort_block.rb
diff --git a/benchmark/array_sort_float.rb b/benchmark/bm_array_sort_float.rb
index 9a6e2f8bd2..9a6e2f8bd2 100644
--- a/benchmark/array_sort_float.rb
+++ b/benchmark/bm_array_sort_float.rb
diff --git a/benchmark/bighash.rb b/benchmark/bm_bighash.rb
index e2ad5a5c94..e2ad5a5c94 100644
--- a/benchmark/bighash.rb
+++ b/benchmark/bm_bighash.rb
diff --git a/benchmark/dir_empty_p.rb b/benchmark/bm_dir_empty_p.rb
index 8329c757cf..8329c757cf 100644
--- a/benchmark/dir_empty_p.rb
+++ b/benchmark/bm_dir_empty_p.rb
diff --git a/benchmark/bm_erb_render.rb b/benchmark/bm_erb_render.rb
new file mode 100644
index 0000000000..d2929b0553
--- /dev/null
+++ b/benchmark/bm_erb_render.rb
@@ -0,0 +1,26 @@
+require 'erb'
+
+data = DATA.read
+max = 1_500_000
+title = "hello world!"
+content = "hello world!\n" * 10
+
+src = "def self.render(title, content); #{ERB.new(data).src}; end"
+mod = Module.new
+mod.instance_eval(src, "(ERB)")
+
+max.times do
+ mod.render(title, content)
+end
+
+__END__
+
+<html>
+ <head> <%= title %> </head>
+ <body>
+ <h1> <%= title %> </h1>
+ <p>
+ <%= content %>
+ </p>
+ </body>
+</html>
diff --git a/benchmark/file_chmod.rb b/benchmark/bm_file_chmod.rb
index 1cd4760c9d..1cd4760c9d 100644
--- a/benchmark/file_chmod.rb
+++ b/benchmark/bm_file_chmod.rb
diff --git a/benchmark/bm_file_rename.rb b/benchmark/bm_file_rename.rb
new file mode 100644
index 0000000000..3bf6a5ef35
--- /dev/null
+++ b/benchmark/bm_file_rename.rb
@@ -0,0 +1,11 @@
+# rename file
+require 'tempfile'
+
+max = 100_000
+tmp = [ Tempfile.new('rename-a'), Tempfile.new('rename-b') ]
+a, b = tmp.map { |x| x.path }
+max.times do
+ File.rename(a, b)
+ File.rename(b, a)
+end
+tmp.each { |t| t.close! }
diff --git a/benchmark/hash_aref_dsym.rb b/benchmark/bm_hash_aref_dsym.rb
index af4f8c36d4..af4f8c36d4 100644
--- a/benchmark/hash_aref_dsym.rb
+++ b/benchmark/bm_hash_aref_dsym.rb
diff --git a/benchmark/hash_aref_dsym_long.rb b/benchmark/bm_hash_aref_dsym_long.rb
index 9d7759379e..9d7759379e 100644
--- a/benchmark/hash_aref_dsym_long.rb
+++ b/benchmark/bm_hash_aref_dsym_long.rb
diff --git a/benchmark/hash_aref_fix.rb b/benchmark/bm_hash_aref_fix.rb
index 1346890582..1346890582 100644
--- a/benchmark/hash_aref_fix.rb
+++ b/benchmark/bm_hash_aref_fix.rb
diff --git a/benchmark/hash_aref_flo.rb b/benchmark/bm_hash_aref_flo.rb
index 2217274c82..2217274c82 100644
--- a/benchmark/hash_aref_flo.rb
+++ b/benchmark/bm_hash_aref_flo.rb
diff --git a/benchmark/hash_aref_miss.rb b/benchmark/bm_hash_aref_miss.rb
index b0913dd4bb..b0913dd4bb 100644
--- a/benchmark/hash_aref_miss.rb
+++ b/benchmark/bm_hash_aref_miss.rb
diff --git a/benchmark/hash_aref_str.rb b/benchmark/bm_hash_aref_str.rb
index 19439b061b..19439b061b 100644
--- a/benchmark/hash_aref_str.rb
+++ b/benchmark/bm_hash_aref_str.rb
diff --git a/benchmark/hash_aref_sym.rb b/benchmark/bm_hash_aref_sym.rb
index f75d163fe6..f75d163fe6 100644
--- a/benchmark/hash_aref_sym.rb
+++ b/benchmark/bm_hash_aref_sym.rb
diff --git a/benchmark/hash_aref_sym_long.rb b/benchmark/bm_hash_aref_sym_long.rb
index 9dab8df7be..9dab8df7be 100644
--- a/benchmark/hash_aref_sym_long.rb
+++ b/benchmark/bm_hash_aref_sym_long.rb
diff --git a/benchmark/hash_flatten.rb b/benchmark/bm_hash_flatten.rb
index e944aae9f2..e944aae9f2 100644
--- a/benchmark/hash_flatten.rb
+++ b/benchmark/bm_hash_flatten.rb
diff --git a/benchmark/hash_ident_flo.rb b/benchmark/bm_hash_ident_flo.rb
index 0c7edfed3e..0c7edfed3e 100644
--- a/benchmark/hash_ident_flo.rb
+++ b/benchmark/bm_hash_ident_flo.rb
diff --git a/benchmark/hash_ident_num.rb b/benchmark/bm_hash_ident_num.rb
index b226736c6f..b226736c6f 100644
--- a/benchmark/hash_ident_num.rb
+++ b/benchmark/bm_hash_ident_num.rb
diff --git a/benchmark/hash_ident_obj.rb b/benchmark/bm_hash_ident_obj.rb
index 4b3b58edec..4b3b58edec 100644
--- a/benchmark/hash_ident_obj.rb
+++ b/benchmark/bm_hash_ident_obj.rb
diff --git a/benchmark/hash_ident_str.rb b/benchmark/bm_hash_ident_str.rb
index 8582b38e31..8582b38e31 100644
--- a/benchmark/hash_ident_str.rb
+++ b/benchmark/bm_hash_ident_str.rb
diff --git a/benchmark/hash_ident_sym.rb b/benchmark/bm_hash_ident_sym.rb
index 4c81e3d28e..4c81e3d28e 100644
--- a/benchmark/hash_ident_sym.rb
+++ b/benchmark/bm_hash_ident_sym.rb
diff --git a/benchmark/hash_keys.rb b/benchmark/bm_hash_keys.rb
index 6863cd01f9..6863cd01f9 100644
--- a/benchmark/hash_keys.rb
+++ b/benchmark/bm_hash_keys.rb
diff --git a/benchmark/hash_long.rb b/benchmark/bm_hash_long.rb
index 03d9109602..03d9109602 100644
--- a/benchmark/hash_long.rb
+++ b/benchmark/bm_hash_long.rb
diff --git a/benchmark/hash_shift.rb b/benchmark/bm_hash_shift.rb
index a645671a5b..a645671a5b 100644
--- a/benchmark/hash_shift.rb
+++ b/benchmark/bm_hash_shift.rb
diff --git a/benchmark/hash_shift_u16.rb b/benchmark/bm_hash_shift_u16.rb
index ec800d0342..ec800d0342 100644
--- a/benchmark/hash_shift_u16.rb
+++ b/benchmark/bm_hash_shift_u16.rb
diff --git a/benchmark/hash_shift_u24.rb b/benchmark/bm_hash_shift_u24.rb
index de4e0fa696..de4e0fa696 100644
--- a/benchmark/hash_shift_u24.rb
+++ b/benchmark/bm_hash_shift_u24.rb
diff --git a/benchmark/hash_shift_u32.rb b/benchmark/bm_hash_shift_u32.rb
index 656aa55583..656aa55583 100644
--- a/benchmark/hash_shift_u32.rb
+++ b/benchmark/bm_hash_shift_u32.rb
diff --git a/benchmark/hash_small2.rb b/benchmark/bm_hash_small2.rb
index 45485d9c71..45485d9c71 100644
--- a/benchmark/hash_small2.rb
+++ b/benchmark/bm_hash_small2.rb
diff --git a/benchmark/hash_small4.rb b/benchmark/bm_hash_small4.rb
index acd4084334..acd4084334 100644
--- a/benchmark/hash_small4.rb
+++ b/benchmark/bm_hash_small4.rb
diff --git a/benchmark/hash_small8.rb b/benchmark/bm_hash_small8.rb
index 9cffcc91b6..9cffcc91b6 100644
--- a/benchmark/hash_small8.rb
+++ b/benchmark/bm_hash_small8.rb
diff --git a/benchmark/hash_to_proc.rb b/benchmark/bm_hash_to_proc.rb
index 2b675bf509..2b675bf509 100644
--- a/benchmark/hash_to_proc.rb
+++ b/benchmark/bm_hash_to_proc.rb
diff --git a/benchmark/hash_values.rb b/benchmark/bm_hash_values.rb
index 069441302f..069441302f 100644
--- a/benchmark/hash_values.rb
+++ b/benchmark/bm_hash_values.rb
diff --git a/benchmark/int_quo.rb b/benchmark/bm_int_quo.rb
index e22a3f8c30..e22a3f8c30 100644
--- a/benchmark/int_quo.rb
+++ b/benchmark/bm_int_quo.rb
diff --git a/benchmark/io_copy_stream_write.rb b/benchmark/bm_io_copy_stream_write.rb
index 3fd87250a4..3fd87250a4 100644
--- a/benchmark/io_copy_stream_write.rb
+++ b/benchmark/bm_io_copy_stream_write.rb
diff --git a/benchmark/io_copy_stream_write_socket.rb b/benchmark/bm_io_copy_stream_write_socket.rb
index 11f369bd0d..11f369bd0d 100644
--- a/benchmark/io_copy_stream_write_socket.rb
+++ b/benchmark/bm_io_copy_stream_write_socket.rb
diff --git a/benchmark/io_file_create.rb b/benchmark/bm_io_file_create.rb
index 2f205c1333..2f205c1333 100644
--- a/benchmark/io_file_create.rb
+++ b/benchmark/bm_io_file_create.rb
diff --git a/benchmark/io_file_read.rb b/benchmark/bm_io_file_read.rb
index b9e796ed30..b9e796ed30 100644
--- a/benchmark/io_file_read.rb
+++ b/benchmark/bm_io_file_read.rb
diff --git a/benchmark/io_file_write.rb b/benchmark/bm_io_file_write.rb
index aa1be0e5fe..aa1be0e5fe 100644
--- a/benchmark/io_file_write.rb
+++ b/benchmark/bm_io_file_write.rb
diff --git a/benchmark/io_nonblock_noex.rb b/benchmark/bm_io_nonblock_noex.rb
index da9357fdc6..da9357fdc6 100644
--- a/benchmark/io_nonblock_noex.rb
+++ b/benchmark/bm_io_nonblock_noex.rb
diff --git a/benchmark/io_nonblock_noex2.rb b/benchmark/bm_io_nonblock_noex2.rb
index 56819d049b..56819d049b 100644
--- a/benchmark/io_nonblock_noex2.rb
+++ b/benchmark/bm_io_nonblock_noex2.rb
diff --git a/benchmark/io_pipe_rw.rb b/benchmark/bm_io_pipe_rw.rb
index 6862a8ae61..6862a8ae61 100644
--- a/benchmark/io_pipe_rw.rb
+++ b/benchmark/bm_io_pipe_rw.rb
diff --git a/benchmark/io_select.rb b/benchmark/bm_io_select.rb
index 19248daeb1..19248daeb1 100644
--- a/benchmark/io_select.rb
+++ b/benchmark/bm_io_select.rb
diff --git a/benchmark/io_select2.rb b/benchmark/bm_io_select2.rb
index 10e37d71b2..10e37d71b2 100644
--- a/benchmark/io_select2.rb
+++ b/benchmark/bm_io_select2.rb
diff --git a/benchmark/io_select3.rb b/benchmark/bm_io_select3.rb
index 7d0ba1f092..7d0ba1f092 100644
--- a/benchmark/io_select3.rb
+++ b/benchmark/bm_io_select3.rb
diff --git a/benchmark/loop_for.rb b/benchmark/bm_loop_for.rb
index 0fc4cc1511..0fc4cc1511 100644
--- a/benchmark/loop_for.rb
+++ b/benchmark/bm_loop_for.rb
diff --git a/benchmark/loop_generator.rb b/benchmark/bm_loop_generator.rb
index d3375c744c..d3375c744c 100644
--- a/benchmark/loop_generator.rb
+++ b/benchmark/bm_loop_generator.rb
diff --git a/benchmark/loop_times.rb b/benchmark/bm_loop_times.rb
index 521f72ad1a..521f72ad1a 100644
--- a/benchmark/loop_times.rb
+++ b/benchmark/bm_loop_times.rb
diff --git a/benchmark/loop_whileloop.rb b/benchmark/bm_loop_whileloop.rb
index 0072822c06..0072822c06 100644
--- a/benchmark/loop_whileloop.rb
+++ b/benchmark/bm_loop_whileloop.rb
diff --git a/benchmark/loop_whileloop2.rb b/benchmark/bm_loop_whileloop2.rb
index 47d02dffc4..47d02dffc4 100644
--- a/benchmark/loop_whileloop2.rb
+++ b/benchmark/bm_loop_whileloop2.rb
diff --git a/benchmark/marshal_dump_flo.rb b/benchmark/bm_marshal_dump_flo.rb
index 9b8d0c6afb..9b8d0c6afb 100644
--- a/benchmark/marshal_dump_flo.rb
+++ b/benchmark/bm_marshal_dump_flo.rb
diff --git a/benchmark/marshal_dump_load_geniv.rb b/benchmark/bm_marshal_dump_load_geniv.rb
index 8252ad90fa..8252ad90fa 100644
--- a/benchmark/marshal_dump_load_geniv.rb
+++ b/benchmark/bm_marshal_dump_load_geniv.rb
diff --git a/benchmark/marshal_dump_load_time.rb b/benchmark/bm_marshal_dump_load_time.rb
index e29743b791..e29743b791 100644
--- a/benchmark/marshal_dump_load_time.rb
+++ b/benchmark/bm_marshal_dump_load_time.rb
diff --git a/benchmark/bm_require.rb b/benchmark/bm_require.rb
new file mode 100644
index 0000000000..b8abc88f41
--- /dev/null
+++ b/benchmark/bm_require.rb
@@ -0,0 +1,7 @@
+$:.push File.join(File.dirname(__FILE__), "bm_require.data")
+
+1.upto(10000) do |i|
+ require "c#{i}"
+end
+
+$:.pop
diff --git a/benchmark/bm_require_thread.rb b/benchmark/bm_require_thread.rb
new file mode 100644
index 0000000000..e54db6c6e5
--- /dev/null
+++ b/benchmark/bm_require_thread.rb
@@ -0,0 +1,15 @@
+$:.push File.join(File.dirname(__FILE__), "bm_require.data")
+
+i=0
+t = Thread.new do
+ while true
+ i = i+1 # dummy loop
+ end
+end
+
+1.upto(100) do |i|
+ require "c#{i}"
+end
+
+$:.pop
+t.kill
diff --git a/benchmark/securerandom.rb b/benchmark/bm_securerandom.rb
index a082ea6d5b..a082ea6d5b 100644
--- a/benchmark/securerandom.rb
+++ b/benchmark/bm_securerandom.rb
diff --git a/benchmark/bm_so_ackermann.rb b/benchmark/bm_so_ackermann.rb
new file mode 100644
index 0000000000..7db5be9050
--- /dev/null
+++ b/benchmark/bm_so_ackermann.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: ackermann-ruby.code,v 1.4 2004/11/13 07:40:41 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+
+def ack(m, n)
+ if m == 0 then
+ n + 1
+ elsif n == 0 then
+ ack(m - 1, 1)
+ else
+ ack(m - 1, ack(m, n - 1))
+ end
+end
+
+NUM = 9
+ack(3, NUM)
+
+
diff --git a/benchmark/bm_so_array.rb b/benchmark/bm_so_array.rb
new file mode 100644
index 0000000000..2b8fce8f99
--- /dev/null
+++ b/benchmark/bm_so_array.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: ary-ruby.code,v 1.4 2004/11/13 07:41:27 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+# with help from Paul Brannan and Mark Hubbart
+
+n = 9000 # Integer(ARGV.shift || 1)
+
+x = Array.new(n)
+y = Array.new(n, 0)
+
+n.times{|bi|
+ x[bi] = bi + 1
+}
+
+(0 .. 999).each do |e|
+ (n-1).step(0,-1) do |bi|
+ y[bi] += x.at(bi)
+ end
+end
+# puts "#{y.first} #{y.last}"
+
+
diff --git a/benchmark/so_binary_trees.rb b/benchmark/bm_so_binary_trees.rb
index b1693e4109..b1693e4109 100644
--- a/benchmark/so_binary_trees.rb
+++ b/benchmark/bm_so_binary_trees.rb
diff --git a/benchmark/bm_so_concatenate.rb b/benchmark/bm_so_concatenate.rb
new file mode 100644
index 0000000000..873214de7c
--- /dev/null
+++ b/benchmark/bm_so_concatenate.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: strcat-ruby.code,v 1.4 2004/11/13 07:43:28 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+# based on code from Aristarkh A Zagorodnikov and Dat Nguyen
+
+STUFF = "hello\n"
+i = 0
+while i<10
+ i += 1
+ hello = ''
+ 4_000_000.times do |e|
+ hello << STUFF
+ end
+end
+# puts hello.length
+
+
diff --git a/benchmark/bm_so_count_words.rb b/benchmark/bm_so_count_words.rb
new file mode 100644
index 0000000000..65f6337a4a
--- /dev/null
+++ b/benchmark/bm_so_count_words.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: wc-ruby.code,v 1.4 2004/11/13 07:43:32 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+# with help from Paul Brannan
+
+input = open(File.join(File.dirname($0), 'wc.input'), 'rb')
+
+nl = nw = nc = 0
+while true
+ tmp = input.read(4096) or break
+ data = tmp << (input.gets || "")
+ nc += data.length
+ nl += data.count("\n")
+ ((data.strip! || data).tr!("\n", " ") || data).squeeze!
+ nw += data.count(" ") + 1
+end
+# STDERR.puts "#{nl} #{nw} #{nc}"
+
diff --git a/benchmark/bm_so_exception.rb b/benchmark/bm_so_exception.rb
new file mode 100644
index 0000000000..deb003a594
--- /dev/null
+++ b/benchmark/bm_so_exception.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: except-ruby.code,v 1.4 2004/11/13 07:41:33 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+
+$HI = 0
+$LO = 0
+NUM = 250000 # Integer(ARGV[0] || 1)
+
+
+class Lo_Exception < Exception
+ def initialize(num)
+ @value = num
+ end
+end
+
+class Hi_Exception < Exception
+ def initialize(num)
+ @value = num
+ end
+end
+
+def some_function(num)
+ begin
+ hi_function(num)
+ rescue
+ print "We shouldn't get here, exception is: #{$!.type}\n"
+ end
+end
+
+def hi_function(num)
+ begin
+ lo_function(num)
+ rescue Hi_Exception
+ $HI = $HI + 1
+ end
+end
+
+def lo_function(num)
+ begin
+ blowup(num)
+ rescue Lo_Exception
+ $LO = $LO + 1
+ end
+end
+
+def blowup(num)
+ if num % 2 == 0
+ raise Lo_Exception.new(num)
+ else
+ raise Hi_Exception.new(num)
+ end
+end
+
+
+i = 1
+max = NUM+1
+while i < max
+ i += 1
+ some_function(i+1)
+end
diff --git a/benchmark/so_fannkuch.rb b/benchmark/bm_so_fannkuch.rb
index bac5ecd44c..bac5ecd44c 100644
--- a/benchmark/so_fannkuch.rb
+++ b/benchmark/bm_so_fannkuch.rb
diff --git a/benchmark/so_fasta.rb b/benchmark/bm_so_fasta.rb
index dcc6b39507..dcc6b39507 100644
--- a/benchmark/so_fasta.rb
+++ b/benchmark/bm_so_fasta.rb
diff --git a/benchmark/bm_so_k_nucleotide.rb b/benchmark/bm_so_k_nucleotide.rb
new file mode 100644
index 0000000000..dadab3e79c
--- /dev/null
+++ b/benchmark/bm_so_k_nucleotide.rb
@@ -0,0 +1,48 @@
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org
+#
+# contributed by jose fco. gonzalez
+# modified by Sokolov Yura
+
+seq = String.new
+
+def frecuency( seq,length )
+ n, table = seq.length - length + 1, Hash.new(0)
+ f, i = nil, nil
+ (0 ... length).each do |f|
+ (f ... n).step(length) do |i|
+ table[seq[i,length]] += 1
+ end
+ end
+ [n,table]
+
+end
+
+def sort_by_freq( seq,length )
+ n,table = frecuency( seq,length )
+ a, b, v = nil, nil, nil
+ table.sort{|a,b| b[1] <=> a[1]}.each do |v|
+ puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)]
+ end
+ puts
+end
+
+def find_seq( seq,s )
+ n,table = frecuency( seq,s.length )
+ puts "#{table[s].to_s}\t#{s.upcase}"
+end
+
+input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb')
+
+line = input.gets while line !~ /^>THREE/
+line = input.gets
+
+while (line !~ /^>/) & line do
+ seq << line.chomp
+ line = input.gets
+end
+
+[1,2].each {|i| sort_by_freq( seq,i ) }
+
+%w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) }
+
diff --git a/benchmark/so_lists.rb b/benchmark/bm_so_lists.rb
index e8f4a2a5f7..e8f4a2a5f7 100644
--- a/benchmark/so_lists.rb
+++ b/benchmark/bm_so_lists.rb
diff --git a/benchmark/so_mandelbrot.rb b/benchmark/bm_so_mandelbrot.rb
index 76331c64b8..76331c64b8 100644
--- a/benchmark/so_mandelbrot.rb
+++ b/benchmark/bm_so_mandelbrot.rb
diff --git a/benchmark/bm_so_matrix.rb b/benchmark/bm_so_matrix.rb
new file mode 100644
index 0000000000..e2c5c8e559
--- /dev/null
+++ b/benchmark/bm_so_matrix.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: matrix-ruby.code,v 1.4 2004/11/13 07:42:14 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+
+n = 60 #Integer(ARGV.shift || 1)
+
+size = 40
+
+def mkmatrix(rows, cols)
+ count = 1
+ mx = Array.new(rows)
+ (0 .. (rows - 1)).each do |bi|
+ row = Array.new(cols, 0)
+ (0 .. (cols - 1)).each do |j|
+ row[j] = count
+ count += 1
+ end
+ mx[bi] = row
+ end
+ mx
+end
+
+def mmult(rows, cols, m1, m2)
+ m3 = Array.new(rows)
+ (0 .. (rows - 1)).each do |bi|
+ row = Array.new(cols, 0)
+ (0 .. (cols - 1)).each do |j|
+ val = 0
+ (0 .. (cols - 1)).each do |k|
+ val += m1.at(bi).at(k) * m2.at(k).at(j)
+ end
+ row[j] = val
+ end
+ m3[bi] = row
+ end
+ m3
+end
+
+m1 = mkmatrix(size, size)
+m2 = mkmatrix(size, size)
+mm = Array.new
+n.times do
+ mm = mmult(size, size, m1, m2)
+end
+# puts "#{mm[0][0]} #{mm[2][3]} #{mm[3][2]} #{mm[4][4]}"
+
+
diff --git a/benchmark/so_meteor_contest.rb b/benchmark/bm_so_meteor_contest.rb
index 8c136baa6c..8c136baa6c 100644..100755
--- a/benchmark/so_meteor_contest.rb
+++ b/benchmark/bm_so_meteor_contest.rb
diff --git a/benchmark/so_nbody.rb b/benchmark/bm_so_nbody.rb
index d6c5bb9e61..d6c5bb9e61 100644
--- a/benchmark/so_nbody.rb
+++ b/benchmark/bm_so_nbody.rb
diff --git a/benchmark/bm_so_nested_loop.rb b/benchmark/bm_so_nested_loop.rb
new file mode 100644
index 0000000000..a0513f8c47
--- /dev/null
+++ b/benchmark/bm_so_nested_loop.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: nestedloop-ruby.code,v 1.4 2004/11/13 07:42:22 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+# from Avi Bryant
+
+n = 16 # Integer(ARGV.shift || 1)
+x = 0
+n.times do
+ n.times do
+ n.times do
+ n.times do
+ n.times do
+ n.times do
+ x += 1
+ end
+ end
+ end
+ end
+ end
+end
+# puts x
+
+
diff --git a/benchmark/so_nsieve.rb b/benchmark/bm_so_nsieve.rb
index a65cc78233..a65cc78233 100644
--- a/benchmark/so_nsieve.rb
+++ b/benchmark/bm_so_nsieve.rb
diff --git a/benchmark/so_nsieve_bits.rb b/benchmark/bm_so_nsieve_bits.rb
index 6f958ee44e..6f958ee44e 100644
--- a/benchmark/so_nsieve_bits.rb
+++ b/benchmark/bm_so_nsieve_bits.rb
diff --git a/benchmark/bm_so_object.rb b/benchmark/bm_so_object.rb
new file mode 100644
index 0000000000..e8607c7199
--- /dev/null
+++ b/benchmark/bm_so_object.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: objinst-ruby.code,v 1.4 2004/11/13 07:42:25 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+# with help from Aristarkh Zagorodnikov
+
+class Toggle
+ def initialize(start_state)
+ @bool = start_state
+ end
+
+ def value
+ @bool
+ end
+
+ def activate
+ @bool = !@bool
+ self
+ end
+end
+
+class NthToggle < Toggle
+ def initialize(start_state, max_counter)
+ super start_state
+ @count_max = max_counter
+ @counter = 0
+ end
+
+ def activate
+ @counter += 1
+ if @counter >= @count_max
+ @bool = !@bool
+ @counter = 0
+ end
+ self
+ end
+end
+
+n = 1500000 # (ARGV.shift || 1).to_i
+
+toggle = Toggle.new 1
+5.times do
+ toggle.activate.value ? 'true' : 'false'
+end
+n.times do
+ toggle = Toggle.new 1
+end
+
+ntoggle = NthToggle.new 1, 3
+8.times do
+ ntoggle.activate.value ? 'true' : 'false'
+end
+n.times do
+ ntoggle = NthToggle.new 1, 3
+end
+
diff --git a/benchmark/so_partial_sums.rb b/benchmark/bm_so_partial_sums.rb
index 630b45cb8d..630b45cb8d 100644
--- a/benchmark/so_partial_sums.rb
+++ b/benchmark/bm_so_partial_sums.rb
diff --git a/benchmark/so_pidigits.rb b/benchmark/bm_so_pidigits.rb
index 9a537b2d1c..9a537b2d1c 100644
--- a/benchmark/so_pidigits.rb
+++ b/benchmark/bm_so_pidigits.rb
diff --git a/benchmark/so_random.rb b/benchmark/bm_so_random.rb
index a66b9e8e63..a66b9e8e63 100644
--- a/benchmark/so_random.rb
+++ b/benchmark/bm_so_random.rb
diff --git a/benchmark/bm_so_reverse_complement.rb b/benchmark/bm_so_reverse_complement.rb
new file mode 100644
index 0000000000..82ea666994
--- /dev/null
+++ b/benchmark/bm_so_reverse_complement.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/ruby
+# The Great Computer Language Shootout
+# http://shootout.alioth.debian.org/
+#
+# Contributed by Peter Bjarke Olsen
+# Modified by Doug King
+
+seq=Array.new
+
+def revcomp(seq)
+ seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')
+ stringlen=seq.length
+ 0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"}
+end
+
+input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb')
+
+while input.gets
+ if $_ =~ />/
+ if seq.length != 0
+ revcomp(seq.join)
+ seq=Array.new
+ end
+ puts $_
+ else
+ $_.sub(/\n/,'')
+ seq.push $_
+ end
+end
+revcomp(seq.join)
diff --git a/benchmark/so_sieve.rb b/benchmark/bm_so_sieve.rb
index 43dc302648..43dc302648 100644
--- a/benchmark/so_sieve.rb
+++ b/benchmark/bm_so_sieve.rb
diff --git a/benchmark/so_spectralnorm.rb b/benchmark/bm_so_spectralnorm.rb
index 6b97206689..6b97206689 100644
--- a/benchmark/so_spectralnorm.rb
+++ b/benchmark/bm_so_spectralnorm.rb
diff --git a/benchmark/string_index.rb b/benchmark/bm_string_index.rb
index 7783111082..7783111082 100644
--- a/benchmark/string_index.rb
+++ b/benchmark/bm_string_index.rb
diff --git a/benchmark/string_scan_re.rb b/benchmark/bm_string_scan_re.rb
index b0d60201a9..b0d60201a9 100644
--- a/benchmark/string_scan_re.rb
+++ b/benchmark/bm_string_scan_re.rb
diff --git a/benchmark/string_scan_str.rb b/benchmark/bm_string_scan_str.rb
index 42440bd948..42440bd948 100644
--- a/benchmark/string_scan_str.rb
+++ b/benchmark/bm_string_scan_str.rb
diff --git a/benchmark/time_subsec.rb b/benchmark/bm_time_subsec.rb
index 505021c701..505021c701 100644
--- a/benchmark/time_subsec.rb
+++ b/benchmark/bm_time_subsec.rb
diff --git a/benchmark/bm_vm1_attr_ivar.rb b/benchmark/bm_vm1_attr_ivar.rb
new file mode 100644
index 0000000000..16906f3605
--- /dev/null
+++ b/benchmark/bm_vm1_attr_ivar.rb
@@ -0,0 +1,14 @@
+class C
+ attr_reader :a, :b
+ def initialize
+ @a = nil
+ @b = nil
+ end
+end
+obj = C.new
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ j = obj.a
+ k = obj.b
+end
diff --git a/benchmark/bm_vm1_attr_ivar_set.rb b/benchmark/bm_vm1_attr_ivar_set.rb
new file mode 100644
index 0000000000..7e7a6b48c0
--- /dev/null
+++ b/benchmark/bm_vm1_attr_ivar_set.rb
@@ -0,0 +1,14 @@
+class C
+ attr_accessor :a, :b
+ def initialize
+ @a = nil
+ @b = nil
+ end
+end
+obj = C.new
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ obj.a = 1
+ obj.b = 2
+end
diff --git a/benchmark/bm_vm1_block.rb b/benchmark/bm_vm1_block.rb
new file mode 100644
index 0000000000..a9f56b15ea
--- /dev/null
+++ b/benchmark/bm_vm1_block.rb
@@ -0,0 +1,10 @@
+def m
+ yield
+end
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ m{
+ }
+end
diff --git a/benchmark/bm_vm1_blockparam.rb b/benchmark/bm_vm1_blockparam.rb
new file mode 100755
index 0000000000..11680a2e61
--- /dev/null
+++ b/benchmark/bm_vm1_blockparam.rb
@@ -0,0 +1,9 @@
+def m &b
+end
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ m{}
+end
+
diff --git a/benchmark/bm_vm1_blockparam_call.rb b/benchmark/bm_vm1_blockparam_call.rb
new file mode 100755
index 0000000000..f6102a2b5a
--- /dev/null
+++ b/benchmark/bm_vm1_blockparam_call.rb
@@ -0,0 +1,9 @@
+def m &b
+ b.call
+end
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ m{}
+end
diff --git a/benchmark/bm_vm1_blockparam_pass.rb b/benchmark/bm_vm1_blockparam_pass.rb
new file mode 100755
index 0000000000..10029a257a
--- /dev/null
+++ b/benchmark/bm_vm1_blockparam_pass.rb
@@ -0,0 +1,13 @@
+def bp_yield
+ yield
+end
+
+def bp_pass &b
+ bp_yield &b
+end
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ bp_pass{}
+end
diff --git a/benchmark/bm_vm1_blockparam_yield.rb b/benchmark/bm_vm1_blockparam_yield.rb
new file mode 100755
index 0000000000..6dc01ced7c
--- /dev/null
+++ b/benchmark/bm_vm1_blockparam_yield.rb
@@ -0,0 +1,9 @@
+def bp_yield &b
+ yield
+end
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ bp_yield{}
+end
diff --git a/benchmark/bm_vm1_const.rb b/benchmark/bm_vm1_const.rb
new file mode 100644
index 0000000000..ac59ebccf1
--- /dev/null
+++ b/benchmark/bm_vm1_const.rb
@@ -0,0 +1,8 @@
+Const = 1
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ j = Const
+ k = Const
+end
diff --git a/benchmark/bm_vm1_ensure.rb b/benchmark/bm_vm1_ensure.rb
new file mode 100644
index 0000000000..a1596145f2
--- /dev/null
+++ b/benchmark/bm_vm1_ensure.rb
@@ -0,0 +1,11 @@
+i = 0
+while i<30_000_000 # benchmark loop 1
+ i += 1
+ begin
+ begin
+ ensure
+ end
+ ensure
+ end
+end
+
diff --git a/benchmark/bm_vm1_float_simple.rb b/benchmark/bm_vm1_float_simple.rb
new file mode 100644
index 0000000000..d4581439ff
--- /dev/null
+++ b/benchmark/bm_vm1_float_simple.rb
@@ -0,0 +1,7 @@
+i = 0.0; f = 0.0
+while i<30_000_000
+ i += 1
+ f += 0.1; f -= 0.1
+ f += 0.1; f -= 0.1
+ f += 0.1; f -= 0.1
+end
diff --git a/benchmark/bm_vm1_gc_short_lived.rb b/benchmark/bm_vm1_gc_short_lived.rb
new file mode 100644
index 0000000000..e78bca5668
--- /dev/null
+++ b/benchmark/bm_vm1_gc_short_lived.rb
@@ -0,0 +1,10 @@
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
diff --git a/benchmark/bm_vm1_gc_short_with_complex_long.rb b/benchmark/bm_vm1_gc_short_with_complex_long.rb
new file mode 100644
index 0000000000..b66052dee0
--- /dev/null
+++ b/benchmark/bm_vm1_gc_short_with_complex_long.rb
@@ -0,0 +1,27 @@
+def nested_hash h, n
+ if n == 0
+ ''
+ else
+ 10.times{
+ h[Object.new] = nested_hash(h, n-1)
+ }
+ end
+end
+
+long_lived = Hash.new
+nested_hash long_lived, 6
+
+GC.start
+GC.start
+
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
+
diff --git a/benchmark/bm_vm1_gc_short_with_long.rb b/benchmark/bm_vm1_gc_short_with_long.rb
new file mode 100644
index 0000000000..298dbc845b
--- /dev/null
+++ b/benchmark/bm_vm1_gc_short_with_long.rb
@@ -0,0 +1,13 @@
+long_lived = Array.new(1_000_000){|i| "#{i}"}
+GC.start
+GC.start
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
diff --git a/benchmark/bm_vm1_gc_short_with_symbol.rb b/benchmark/bm_vm1_gc_short_with_symbol.rb
new file mode 100644
index 0000000000..6b15c1b7bf
--- /dev/null
+++ b/benchmark/bm_vm1_gc_short_with_symbol.rb
@@ -0,0 +1,15 @@
+# make many symbols
+50_000.times{|i| sym = "sym#{i}".to_sym}
+GC.start
+GC.start
+
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
diff --git a/benchmark/bm_vm1_gc_wb_ary.rb b/benchmark/bm_vm1_gc_wb_ary.rb
new file mode 100644
index 0000000000..1b030386cf
--- /dev/null
+++ b/benchmark/bm_vm1_gc_wb_ary.rb
@@ -0,0 +1,12 @@
+short_lived_ary = []
+
+if RUBY_VERSION >= "2.2.0"
+ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ short_lived_ary[0] = short_lived # write barrier
+ i+=1
+end
diff --git a/benchmark/bm_vm1_gc_wb_ary_promoted.rb b/benchmark/bm_vm1_gc_wb_ary_promoted.rb
new file mode 100644
index 0000000000..ebc369a60f
--- /dev/null
+++ b/benchmark/bm_vm1_gc_wb_ary_promoted.rb
@@ -0,0 +1,14 @@
+long_lived = []
+
+if RUBY_VERSION > "2.2.0"
+ 3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
+elsif
+ GC.start
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ long_lived[0] = short_lived # write barrier
+ i+=1
+end
diff --git a/benchmark/bm_vm1_gc_wb_obj.rb b/benchmark/bm_vm1_gc_wb_obj.rb
new file mode 100644
index 0000000000..96f4261915
--- /dev/null
+++ b/benchmark/bm_vm1_gc_wb_obj.rb
@@ -0,0 +1,15 @@
+class C
+ attr_accessor :foo
+end
+short_lived_obj = C.new
+
+if RUBY_VERSION >= "2.2.0"
+ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ short_lived_obj.foo = short_lived # write barrier
+ i+=1
+end
diff --git a/benchmark/bm_vm1_gc_wb_obj_promoted.rb b/benchmark/bm_vm1_gc_wb_obj_promoted.rb
new file mode 100644
index 0000000000..674c413992
--- /dev/null
+++ b/benchmark/bm_vm1_gc_wb_obj_promoted.rb
@@ -0,0 +1,17 @@
+class C
+ attr_accessor :foo
+end
+long_lived = C.new
+
+if RUBY_VERSION >= "2.2.0"
+ 3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
+elsif
+ GC.start
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ long_lived.foo = short_lived # write barrier
+ i+=1
+end
diff --git a/benchmark/bm_vm1_ivar.rb b/benchmark/bm_vm1_ivar.rb
new file mode 100644
index 0000000000..68a73cf92f
--- /dev/null
+++ b/benchmark/bm_vm1_ivar.rb
@@ -0,0 +1,8 @@
+@a = 1
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ j = @a
+ k = @a
+end
diff --git a/benchmark/bm_vm1_ivar_set.rb b/benchmark/bm_vm1_ivar_set.rb
new file mode 100644
index 0000000000..bd81b06c34
--- /dev/null
+++ b/benchmark/bm_vm1_ivar_set.rb
@@ -0,0 +1,6 @@
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ @a = 1
+ @b = 2
+end
diff --git a/benchmark/bm_vm1_length.rb b/benchmark/bm_vm1_length.rb
new file mode 100644
index 0000000000..353de3ab0e
--- /dev/null
+++ b/benchmark/bm_vm1_length.rb
@@ -0,0 +1,9 @@
+a = 'abc'
+b = [1, 2, 3]
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ a.length
+ b.length
+end
+
diff --git a/benchmark/bm_vm1_lvar_init.rb b/benchmark/bm_vm1_lvar_init.rb
new file mode 100644
index 0000000000..36f2068811
--- /dev/null
+++ b/benchmark/bm_vm1_lvar_init.rb
@@ -0,0 +1,18 @@
+def m v
+ unless v
+ # unreachable code
+ v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = v9 = v10 =
+ v11 = v12 = v13 = v14 = v15 = v16 = v17 = v18 = v19 = v20 =
+ v21 = v22 = v23 = v24 = v25 = v26 = v27 = v28 = v29 = v30 =
+ v31 = v32 = v33 = v34 = v35 = v36 = v37 = v38 = v39 = v40 =
+ v41 = v42 = v43 = v44 = v45 = v46 = v47 = v48 = v49 = v50 = 1
+ end
+end
+
+i = 0
+
+while i<30_000_000 # while loop 1
+ i += 1
+ m i
+end
+
diff --git a/benchmark/bm_vm1_lvar_set.rb b/benchmark/bm_vm1_lvar_set.rb
new file mode 100644
index 0000000000..222e864134
--- /dev/null
+++ b/benchmark/bm_vm1_lvar_set.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ a = b = c = d = e = f = g = h = j = k = l = m = n = o = p = q = r = 1
+end
diff --git a/benchmark/bm_vm1_neq.rb b/benchmark/bm_vm1_neq.rb
new file mode 100644
index 0000000000..bbb4ae07a4
--- /dev/null
+++ b/benchmark/bm_vm1_neq.rb
@@ -0,0 +1,8 @@
+i = 0
+obj1 = Object.new
+obj2 = Object.new
+
+while i<30_000_000 # while loop 1
+ i += 1
+ obj1 != obj2
+end
diff --git a/benchmark/bm_vm1_not.rb b/benchmark/bm_vm1_not.rb
new file mode 100644
index 0000000000..b09ecdcc21
--- /dev/null
+++ b/benchmark/bm_vm1_not.rb
@@ -0,0 +1,7 @@
+i = 0
+obj = Object.new
+
+while i<30_000_000 # while loop 1
+ i += 1
+ !obj
+end
diff --git a/benchmark/bm_vm1_rescue.rb b/benchmark/bm_vm1_rescue.rb
new file mode 100644
index 0000000000..b0d3e2bdfa
--- /dev/null
+++ b/benchmark/bm_vm1_rescue.rb
@@ -0,0 +1,7 @@
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ begin
+ rescue
+ end
+end
diff --git a/benchmark/bm_vm1_simplereturn.rb b/benchmark/bm_vm1_simplereturn.rb
new file mode 100644
index 0000000000..63f9f21675
--- /dev/null
+++ b/benchmark/bm_vm1_simplereturn.rb
@@ -0,0 +1,9 @@
+def m
+ return 1
+end
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ m
+end
+
diff --git a/benchmark/bm_vm1_swap.rb b/benchmark/bm_vm1_swap.rb
new file mode 100644
index 0000000000..918f8b2112
--- /dev/null
+++ b/benchmark/bm_vm1_swap.rb
@@ -0,0 +1,8 @@
+a = 1
+b = 2
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ a, b = b, a
+end
+
diff --git a/benchmark/bm_vm1_yield.rb b/benchmark/bm_vm1_yield.rb
new file mode 100644
index 0000000000..775597cea6
--- /dev/null
+++ b/benchmark/bm_vm1_yield.rb
@@ -0,0 +1,10 @@
+def m
+ i = 0
+ while i<30_000_000 # while loop 1
+ i += 1
+ yield
+ end
+end
+
+m{}
+
diff --git a/benchmark/bm_vm2_array.rb b/benchmark/bm_vm2_array.rb
new file mode 100644
index 0000000000..df9037c83c
--- /dev/null
+++ b/benchmark/bm_vm2_array.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ a = [1,2,3,4,5,6,7,8,9,10]
+end
diff --git a/benchmark/bm_vm2_bigarray.rb b/benchmark/bm_vm2_bigarray.rb
new file mode 100644
index 0000000000..b02509d6a2
--- /dev/null
+++ b/benchmark/bm_vm2_bigarray.rb
@@ -0,0 +1,106 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ a = [
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ ]
+end
diff --git a/benchmark/bm_vm2_bighash.rb b/benchmark/bm_vm2_bighash.rb
new file mode 100644
index 0000000000..5e3f437bb8
--- /dev/null
+++ b/benchmark/bm_vm2_bighash.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<60_000 # benchmark loop 2
+ i += 1
+ a = {0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9, 10=>10, 11=>11, 12=>12, 13=>13, 14=>14, 15=>15, 16=>16, 17=>17, 18=>18, 19=>19, 20=>20, 21=>21, 22=>22, 23=>23, 24=>24, 25=>25, 26=>26, 27=>27, 28=>28, 29=>29, 30=>30, 31=>31, 32=>32, 33=>33, 34=>34, 35=>35, 36=>36, 37=>37, 38=>38, 39=>39, 40=>40, 41=>41, 42=>42, 43=>43, 44=>44, 45=>45, 46=>46, 47=>47, 48=>48, 49=>49, 50=>50, 51=>51, 52=>52, 53=>53, 54=>54, 55=>55, 56=>56, 57=>57, 58=>58, 59=>59, 60=>60, 61=>61, 62=>62, 63=>63, 64=>64, 65=>65, 66=>66, 67=>67, 68=>68, 69=>69, 70=>70, 71=>71, 72=>72, 73=>73, 74=>74, 75=>75, 76=>76, 77=>77, 78=>78, 79=>79, 80=>80, 81=>81, 82=>82, 83=>83, 84=>84, 85=>85, 86=>86, 87=>87, 88=>88, 89=>89, 90=>90, 91=>91, 92=>92, 93=>93, 94=>94, 95=>95, 96=>96, 97=>97, 98=>98, 99=>99, 100=>100, 101=>101, 102=>102, 103=>103, 104=>104, 105=>105, 106=>106, 107=>107, 108=>108, 109=>109, 110=>110, 111=>111, 112=>112, 113=>113, 114=>114, 115=>115, 116=>116, 117=>117, 118=>118, 119=>119, 120=>120, 121=>121, 122=>122, 123=>123, 124=>124, 125=>125, 126=>126, 127=>127, 128=>128, 129=>129, 130=>130, 131=>131, 132=>132, 133=>133, 134=>134, 135=>135, 136=>136, 137=>137, 138=>138, 139=>139, 140=>140, 141=>141, 142=>142, 143=>143, 144=>144, 145=>145, 146=>146, 147=>147, 148=>148, 149=>149, 150=>150, 151=>151, 152=>152, 153=>153, 154=>154, 155=>155, 156=>156, 157=>157, 158=>158, 159=>159, 160=>160, 161=>161, 162=>162, 163=>163, 164=>164, 165=>165, 166=>166, 167=>167, 168=>168, 169=>169, 170=>170, 171=>171, 172=>172, 173=>173, 174=>174, 175=>175, 176=>176, 177=>177, 178=>178, 179=>179, 180=>180, 181=>181, 182=>182, 183=>183, 184=>184, 185=>185, 186=>186, 187=>187, 188=>188, 189=>189, 190=>190, 191=>191, 192=>192, 193=>193, 194=>194, 195=>195, 196=>196, 197=>197, 198=>198, 199=>199, 200=>200, 201=>201, 202=>202, 203=>203, 204=>204, 205=>205, 206=>206, 207=>207, 208=>208, 209=>209, 210=>210, 211=>211, 212=>212, 213=>213, 214=>214, 215=>215, 216=>216, 217=>217, 218=>218, 219=>219, 220=>220, 221=>221, 222=>222, 223=>223, 224=>224, 225=>225, 226=>226, 227=>227, 228=>228, 229=>229, 230=>230, 231=>231, 232=>232, 233=>233, 234=>234, 235=>235, 236=>236, 237=>237, 238=>238, 239=>239, 240=>240, 241=>241, 242=>242, 243=>243, 244=>244, 245=>245, 246=>246, 247=>247, 248=>248, 249=>249, 250=>250, 251=>251, 252=>252, 253=>253, 254=>254, 255=>255, 256=>256, 257=>257, 258=>258, 259=>259, 260=>260, 261=>261, 262=>262, 263=>263, 264=>264, 265=>265, 266=>266, 267=>267, 268=>268, 269=>269, 270=>270, 271=>271, 272=>272, 273=>273, 274=>274, 275=>275, 276=>276, 277=>277, 278=>278, 279=>279, 280=>280, 281=>281, 282=>282, 283=>283, 284=>284, 285=>285, 286=>286, 287=>287, 288=>288, 289=>289, 290=>290, 291=>291, 292=>292, 293=>293, 294=>294, 295=>295, 296=>296, 297=>297, 298=>298, 299=>299, 300=>300, 301=>301, 302=>302, 303=>303, 304=>304, 305=>305, 306=>306, 307=>307, 308=>308, 309=>309, 310=>310, 311=>311, 312=>312, 313=>313, 314=>314, 315=>315, 316=>316, 317=>317, 318=>318, 319=>319, 320=>320, 321=>321, 322=>322, 323=>323, 324=>324, 325=>325, 326=>326, 327=>327, 328=>328, 329=>329, 330=>330, 331=>331, 332=>332, 333=>333, 334=>334, 335=>335, 336=>336, 337=>337, 338=>338, 339=>339, 340=>340, 341=>341, 342=>342, 343=>343, 344=>344, 345=>345, 346=>346, 347=>347, 348=>348, 349=>349, 350=>350, 351=>351, 352=>352, 353=>353, 354=>354, 355=>355, 356=>356, 357=>357, 358=>358, 359=>359, 360=>360, 361=>361, 362=>362, 363=>363, 364=>364, 365=>365, 366=>366, 367=>367, 368=>368, 369=>369, 370=>370, 371=>371, 372=>372, 373=>373, 374=>374, 375=>375, 376=>376, 377=>377, 378=>378, 379=>379, 380=>380, 381=>381, 382=>382, 383=>383, 384=>384, 385=>385, 386=>386, 387=>387, 388=>388, 389=>389, 390=>390, 391=>391, 392=>392, 393=>393, 394=>394, 395=>395, 396=>396, 397=>397, 398=>398, 399=>399, 400=>400, 401=>401, 402=>402, 403=>403, 404=>404, 405=>405, 406=>406, 407=>407, 408=>408, 409=>409, 410=>410, 411=>411, 412=>412, 413=>413, 414=>414, 415=>415, 416=>416, 417=>417, 418=>418, 419=>419, 420=>420, 421=>421, 422=>422, 423=>423, 424=>424, 425=>425, 426=>426, 427=>427, 428=>428, 429=>429, 430=>430, 431=>431, 432=>432, 433=>433, 434=>434, 435=>435, 436=>436, 437=>437, 438=>438, 439=>439, 440=>440, 441=>441, 442=>442, 443=>443, 444=>444, 445=>445, 446=>446, 447=>447, 448=>448, 449=>449, 450=>450, 451=>451, 452=>452, 453=>453, 454=>454, 455=>455, 456=>456, 457=>457, 458=>458, 459=>459, 460=>460, 461=>461, 462=>462, 463=>463, 464=>464, 465=>465, 466=>466, 467=>467, 468=>468, 469=>469, 470=>470, 471=>471, 472=>472, 473=>473, 474=>474, 475=>475, 476=>476, 477=>477, 478=>478, 479=>479, 480=>480, 481=>481, 482=>482, 483=>483, 484=>484, 485=>485, 486=>486, 487=>487, 488=>488, 489=>489, 490=>490, 491=>491, 492=>492, 493=>493, 494=>494, 495=>495, 496=>496, 497=>497, 498=>498, 499=>499, 500=>500,}
+end
diff --git a/benchmark/bm_vm2_case.rb b/benchmark/bm_vm2_case.rb
new file mode 100644
index 0000000000..adc6e4df0a
--- /dev/null
+++ b/benchmark/bm_vm2_case.rb
@@ -0,0 +1,14 @@
+i = 0
+while i<6_000_000 # while loop 2
+ case :foo
+ when :bar
+ raise
+ when :baz
+ raise
+ when :boo
+ raise
+ when :foo
+ i += 1
+ end
+end
+
diff --git a/benchmark/bm_vm2_case_lit.rb b/benchmark/bm_vm2_case_lit.rb
new file mode 100644
index 0000000000..c62b294e0e
--- /dev/null
+++ b/benchmark/bm_vm2_case_lit.rb
@@ -0,0 +1,19 @@
+i = 0
+@ret = [ "foo", true, false, :sym, 6, nil, 0.1, 0xffffffffffffffff ]
+def foo(i)
+ @ret[i % @ret.size]
+end
+
+while i<6_000_000 # while loop 2
+ case foo(i)
+ when "foo" then :foo
+ when true then true
+ when false then false
+ when :sym then :sym
+ when 6 then :fix
+ when nil then nil
+ when 0.1 then :float
+ when 0xffffffffffffffff then :big
+ end
+ i += 1
+end
diff --git a/benchmark/bm_vm2_defined_method.rb b/benchmark/bm_vm2_defined_method.rb
new file mode 100644
index 0000000000..053ed6c912
--- /dev/null
+++ b/benchmark/bm_vm2_defined_method.rb
@@ -0,0 +1,9 @@
+class Object
+ define_method(:m){}
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m; m; m; m; m; m; m; m;
+end
diff --git a/benchmark/bm_vm2_dstr.rb b/benchmark/bm_vm2_dstr.rb
new file mode 100644
index 0000000000..58c0f7bbc3
--- /dev/null
+++ b/benchmark/bm_vm2_dstr.rb
@@ -0,0 +1,6 @@
+i = 0
+x = y = 'z'
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ str = "foo#{x}bar#{y}baz"
+end
diff --git a/benchmark/bm_vm2_eval.rb b/benchmark/bm_vm2_eval.rb
new file mode 100644
index 0000000000..307cfc28ef
--- /dev/null
+++ b/benchmark/bm_vm2_eval.rb
@@ -0,0 +1,6 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ eval("1")
+end
+
diff --git a/benchmark/bm_vm2_fiber_switch.rb b/benchmark/bm_vm2_fiber_switch.rb
new file mode 100644
index 0000000000..c6f615d71d
--- /dev/null
+++ b/benchmark/bm_vm2_fiber_switch.rb
@@ -0,0 +1,9 @@
+# based on benchmark for [ruby-core:65518] [Feature #10341] by Knut Franke
+fib = Fiber.new do
+ loop { Fiber.yield }
+end
+i = 0
+while i< 6_000_000 # benchmark loop 2
+ i += 1
+ fib.resume
+end
diff --git a/benchmark/bm_vm2_method.rb b/benchmark/bm_vm2_method.rb
new file mode 100644
index 0000000000..a8ccff7138
--- /dev/null
+++ b/benchmark/bm_vm2_method.rb
@@ -0,0 +1,9 @@
+def m
+ nil
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m; m; m; m; m; m; m; m;
+end
diff --git a/benchmark/bm_vm2_method_missing.rb b/benchmark/bm_vm2_method_missing.rb
new file mode 100644
index 0000000000..2badc73101
--- /dev/null
+++ b/benchmark/bm_vm2_method_missing.rb
@@ -0,0 +1,12 @@
+class C
+ def method_missing mid
+ end
+end
+
+obj = C.new
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ obj.m; obj.m; obj.m; obj.m; obj.m; obj.m; obj.m; obj.m;
+end
diff --git a/benchmark/bm_vm2_method_with_block.rb b/benchmark/bm_vm2_method_with_block.rb
new file mode 100644
index 0000000000..b4efb4f520
--- /dev/null
+++ b/benchmark/bm_vm2_method_with_block.rb
@@ -0,0 +1,9 @@
+def m
+ nil
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m{}; m{}; m{}; m{}; m{}; m{}; m{}; m{};
+end
diff --git a/benchmark/bm_vm2_module_ann_const_set.rb b/benchmark/bm_vm2_module_ann_const_set.rb
new file mode 100644
index 0000000000..12ccfd2ff3
--- /dev/null
+++ b/benchmark/bm_vm2_module_ann_const_set.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ Module.new.const_set(:X, Module.new)
+end
diff --git a/benchmark/bm_vm2_module_const_set.rb b/benchmark/bm_vm2_module_const_set.rb
new file mode 100644
index 0000000000..f4d4c1b2e7
--- /dev/null
+++ b/benchmark/bm_vm2_module_const_set.rb
@@ -0,0 +1,8 @@
+i = 0
+module M
+end
+$VERBOSE = nil
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ M.const_set(:X, Module.new)
+end
diff --git a/benchmark/bm_vm2_mutex.rb b/benchmark/bm_vm2_mutex.rb
new file mode 100644
index 0000000000..5d16480c6b
--- /dev/null
+++ b/benchmark/bm_vm2_mutex.rb
@@ -0,0 +1,9 @@
+require 'thread'
+
+m = Thread::Mutex.new
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m.synchronize{}
+end
diff --git a/benchmark/bm_vm2_newlambda.rb b/benchmark/bm_vm2_newlambda.rb
new file mode 100644
index 0000000000..6422c9b0d0
--- /dev/null
+++ b/benchmark/bm_vm2_newlambda.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ lambda {}
+end
diff --git a/benchmark/bm_vm2_poly_method.rb b/benchmark/bm_vm2_poly_method.rb
new file mode 100644
index 0000000000..c82c0e4bce
--- /dev/null
+++ b/benchmark/bm_vm2_poly_method.rb
@@ -0,0 +1,20 @@
+class C1
+ def m
+ 1
+ end
+end
+class C2
+ def m
+ 2
+ end
+end
+
+o1 = C1.new
+o2 = C2.new
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ o = (i % 2 == 0) ? o1 : o2
+ o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
+ i += 1
+end
diff --git a/benchmark/bm_vm2_poly_method_ov.rb b/benchmark/bm_vm2_poly_method_ov.rb
new file mode 100644
index 0000000000..aa5fd1dd38
--- /dev/null
+++ b/benchmark/bm_vm2_poly_method_ov.rb
@@ -0,0 +1,20 @@
+class C1
+ def m
+ 1
+ end
+end
+class C2
+ def m
+ 2
+ end
+end
+
+o1 = C1.new
+o2 = C2.new
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ o = (i % 2 == 0) ? o1 : o2
+# o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
+ i += 1
+end
diff --git a/benchmark/bm_vm2_poly_singleton.rb b/benchmark/bm_vm2_poly_singleton.rb
new file mode 100644
index 0000000000..0dba4320c4
--- /dev/null
+++ b/benchmark/bm_vm2_poly_singleton.rb
@@ -0,0 +1,14 @@
+class C1
+ def m; 1; end
+end
+
+o1 = C1.new
+o2 = C1.new
+o2.singleton_class
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ o = (i % 2 == 0) ? o1 : o2
+ o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
+ i += 1
+end
diff --git a/benchmark/bm_vm2_proc.rb b/benchmark/bm_vm2_proc.rb
new file mode 100644
index 0000000000..65e5217371
--- /dev/null
+++ b/benchmark/bm_vm2_proc.rb
@@ -0,0 +1,14 @@
+def m &b
+ b
+end
+
+pr = m{
+ a = 1
+}
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ pr.call
+end
+
diff --git a/benchmark/bm_vm2_raise1.rb b/benchmark/bm_vm2_raise1.rb
new file mode 100644
index 0000000000..aa5387987f
--- /dev/null
+++ b/benchmark/bm_vm2_raise1.rb
@@ -0,0 +1,18 @@
+def rec n
+ if n > 0
+ rec n-1
+ else
+ raise
+ end
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+
+ begin
+ rec 1
+ rescue
+ # ignore
+ end
+end
diff --git a/benchmark/bm_vm2_raise2.rb b/benchmark/bm_vm2_raise2.rb
new file mode 100644
index 0000000000..1f61c63157
--- /dev/null
+++ b/benchmark/bm_vm2_raise2.rb
@@ -0,0 +1,18 @@
+def rec n
+ if n > 0
+ rec n-1
+ else
+ raise
+ end
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+
+ begin
+ rec 10
+ rescue
+ # ignore
+ end
+end
diff --git a/benchmark/bm_vm2_regexp.rb b/benchmark/bm_vm2_regexp.rb
new file mode 100644
index 0000000000..55f9e957a3
--- /dev/null
+++ b/benchmark/bm_vm2_regexp.rb
@@ -0,0 +1,6 @@
+i = 0
+str = 'xxxhogexxx'
+while i<6_000_000 # benchmark loop 2
+ /hoge/ =~ str
+ i += 1
+end
diff --git a/benchmark/bm_vm2_send.rb b/benchmark/bm_vm2_send.rb
new file mode 100644
index 0000000000..6a3ab6fdab
--- /dev/null
+++ b/benchmark/bm_vm2_send.rb
@@ -0,0 +1,12 @@
+class C
+ def m
+ end
+end
+
+o = C.new
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ o.__send__ :m
+end
diff --git a/benchmark/bm_vm2_string_literal.rb b/benchmark/bm_vm2_string_literal.rb
new file mode 100644
index 0000000000..1d73036849
--- /dev/null
+++ b/benchmark/bm_vm2_string_literal.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+end
diff --git a/benchmark/bm_vm2_struct_big_aref_hi.rb b/benchmark/bm_vm2_struct_big_aref_hi.rb
new file mode 100644
index 0000000000..22cb26b0a5
--- /dev/null
+++ b/benchmark/bm_vm2_struct_big_aref_hi.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.z # x[25]
+end
diff --git a/benchmark/bm_vm2_struct_big_aref_lo.rb b/benchmark/bm_vm2_struct_big_aref_lo.rb
new file mode 100644
index 0000000000..5e61a7087e
--- /dev/null
+++ b/benchmark/bm_vm2_struct_big_aref_lo.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.k # x[10]
+end
diff --git a/benchmark/bm_vm2_struct_big_aset.rb b/benchmark/bm_vm2_struct_big_aset.rb
new file mode 100644
index 0000000000..5a1c3d16f3
--- /dev/null
+++ b/benchmark/bm_vm2_struct_big_aset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.k = i # x[10] = i
+end
diff --git a/benchmark/bm_vm2_struct_big_href_hi.rb b/benchmark/bm_vm2_struct_big_href_hi.rb
new file mode 100644
index 0000000000..fff940a80a
--- /dev/null
+++ b/benchmark/bm_vm2_struct_big_href_hi.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:z]
+end
diff --git a/benchmark/bm_vm2_struct_big_href_lo.rb b/benchmark/bm_vm2_struct_big_href_lo.rb
new file mode 100644
index 0000000000..5e4085d59d
--- /dev/null
+++ b/benchmark/bm_vm2_struct_big_href_lo.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:k]
+end
diff --git a/benchmark/bm_vm2_struct_big_hset.rb b/benchmark/bm_vm2_struct_big_hset.rb
new file mode 100644
index 0000000000..9c0cee4141
--- /dev/null
+++ b/benchmark/bm_vm2_struct_big_hset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:k] = i
+end
diff --git a/benchmark/bm_vm2_struct_small_aref.rb b/benchmark/bm_vm2_struct_small_aref.rb
new file mode 100644
index 0000000000..8eaa555b41
--- /dev/null
+++ b/benchmark/bm_vm2_struct_small_aref.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.a
+end
diff --git a/benchmark/bm_vm2_struct_small_aset.rb b/benchmark/bm_vm2_struct_small_aset.rb
new file mode 100644
index 0000000000..ecd0f95669
--- /dev/null
+++ b/benchmark/bm_vm2_struct_small_aset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.a = i
+end
diff --git a/benchmark/bm_vm2_struct_small_href.rb b/benchmark/bm_vm2_struct_small_href.rb
new file mode 100644
index 0000000000..2c88fee6bf
--- /dev/null
+++ b/benchmark/bm_vm2_struct_small_href.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:a]
+end
diff --git a/benchmark/bm_vm2_struct_small_hset.rb b/benchmark/bm_vm2_struct_small_hset.rb
new file mode 100644
index 0000000000..33c36d20f1
--- /dev/null
+++ b/benchmark/bm_vm2_struct_small_hset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:a] = 1
+end
diff --git a/benchmark/bm_vm2_super.rb b/benchmark/bm_vm2_super.rb
new file mode 100644
index 0000000000..afd8579e7b
--- /dev/null
+++ b/benchmark/bm_vm2_super.rb
@@ -0,0 +1,20 @@
+
+class C
+ def m
+ 1
+ end
+end
+
+class CC < C
+ def m
+ super()
+ end
+end
+
+obj = CC.new
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ obj.m
+ i += 1
+end
diff --git a/benchmark/bm_vm2_unif1.rb b/benchmark/bm_vm2_unif1.rb
new file mode 100644
index 0000000000..1774625942
--- /dev/null
+++ b/benchmark/bm_vm2_unif1.rb
@@ -0,0 +1,8 @@
+i = 0
+def m a, b
+end
+
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m 100, 200
+end
diff --git a/benchmark/bm_vm2_zsuper.rb b/benchmark/bm_vm2_zsuper.rb
new file mode 100644
index 0000000000..2a43e62217
--- /dev/null
+++ b/benchmark/bm_vm2_zsuper.rb
@@ -0,0 +1,20 @@
+i = 0
+
+class C
+ def m a
+ 1
+ end
+end
+
+class CC < C
+ def m a
+ super
+ end
+end
+
+obj = CC.new
+
+while i<6_000_000 # benchmark loop 2
+ obj.m 10
+ i += 1
+end
diff --git a/benchmark/vm3_backtrace.rb b/benchmark/bm_vm3_backtrace.rb
index 0fbf73e1ca..0fbf73e1ca 100644
--- a/benchmark/vm3_backtrace.rb
+++ b/benchmark/bm_vm3_backtrace.rb
diff --git a/benchmark/vm3_clearmethodcache.rb b/benchmark/bm_vm3_clearmethodcache.rb
index 9661323cd2..9661323cd2 100644
--- a/benchmark/vm3_clearmethodcache.rb
+++ b/benchmark/bm_vm3_clearmethodcache.rb
diff --git a/benchmark/vm3_gc.rb b/benchmark/bm_vm3_gc.rb
index e668026915..e668026915 100644
--- a/benchmark/vm3_gc.rb
+++ b/benchmark/bm_vm3_gc.rb
diff --git a/benchmark/vm3_gc_old_full.rb b/benchmark/bm_vm3_gc_old_full.rb
index cfdfc8c5a5..cfdfc8c5a5 100644
--- a/benchmark/vm3_gc_old_full.rb
+++ b/benchmark/bm_vm3_gc_old_full.rb
diff --git a/benchmark/vm3_gc_old_immediate.rb b/benchmark/bm_vm3_gc_old_immediate.rb
index ad22feb655..ad22feb655 100644
--- a/benchmark/vm3_gc_old_immediate.rb
+++ b/benchmark/bm_vm3_gc_old_immediate.rb
diff --git a/benchmark/vm3_gc_old_lazy.rb b/benchmark/bm_vm3_gc_old_lazy.rb
index b74d44baf1..b74d44baf1 100644
--- a/benchmark/vm3_gc_old_lazy.rb
+++ b/benchmark/bm_vm3_gc_old_lazy.rb
diff --git a/benchmark/vm_symbol_block_pass.rb b/benchmark/bm_vm_symbol_block_pass.rb
index 1d433353e1..1d433353e1 100644
--- a/benchmark/vm_symbol_block_pass.rb
+++ b/benchmark/bm_vm_symbol_block_pass.rb
diff --git a/benchmark/bm_vm_thread_alive_check1.rb b/benchmark/bm_vm_thread_alive_check1.rb
new file mode 100644
index 0000000000..c993accdda
--- /dev/null
+++ b/benchmark/bm_vm_thread_alive_check1.rb
@@ -0,0 +1,6 @@
+5_000.times{
+ t = Thread.new{}
+ while t.alive?
+ Thread.pass
+ end
+}
diff --git a/benchmark/vm_thread_close.rb b/benchmark/bm_vm_thread_close.rb
index 3e9a265ce8..3e9a265ce8 100644
--- a/benchmark/vm_thread_close.rb
+++ b/benchmark/bm_vm_thread_close.rb
diff --git a/benchmark/vm_thread_condvar1.rb b/benchmark/bm_vm_thread_condvar1.rb
index cf5706b23e..cf5706b23e 100644
--- a/benchmark/vm_thread_condvar1.rb
+++ b/benchmark/bm_vm_thread_condvar1.rb
diff --git a/benchmark/vm_thread_condvar2.rb b/benchmark/bm_vm_thread_condvar2.rb
index 7c8dc19481..7c8dc19481 100644
--- a/benchmark/vm_thread_condvar2.rb
+++ b/benchmark/bm_vm_thread_condvar2.rb
diff --git a/benchmark/vm_thread_create_join.rb b/benchmark/bm_vm_thread_create_join.rb
index 393cd45df9..393cd45df9 100644
--- a/benchmark/vm_thread_create_join.rb
+++ b/benchmark/bm_vm_thread_create_join.rb
diff --git a/benchmark/vm_thread_mutex1.rb b/benchmark/bm_vm_thread_mutex1.rb
index 66e42c85e1..66e42c85e1 100644
--- a/benchmark/vm_thread_mutex1.rb
+++ b/benchmark/bm_vm_thread_mutex1.rb
diff --git a/benchmark/vm_thread_mutex2.rb b/benchmark/bm_vm_thread_mutex2.rb
index 6e6c804c31..6e6c804c31 100644
--- a/benchmark/vm_thread_mutex2.rb
+++ b/benchmark/bm_vm_thread_mutex2.rb
diff --git a/benchmark/vm_thread_mutex3.rb b/benchmark/bm_vm_thread_mutex3.rb
index c750dc542a..c750dc542a 100644
--- a/benchmark/vm_thread_mutex3.rb
+++ b/benchmark/bm_vm_thread_mutex3.rb
diff --git a/benchmark/bm_vm_thread_pass.rb b/benchmark/bm_vm_thread_pass.rb
new file mode 100644
index 0000000000..b5b3c0bc85
--- /dev/null
+++ b/benchmark/bm_vm_thread_pass.rb
@@ -0,0 +1,15 @@
+# Plenty Thtread.pass
+# A performance may depend on GVL implementation.
+
+tmax = (ARGV.shift || 2).to_i
+lmax = 200_000 / tmax
+
+(1..tmax).map{
+ Thread.new{
+ lmax.times{
+ Thread.pass
+ }
+ }
+}.each{|t| t.join}
+
+
diff --git a/benchmark/bm_vm_thread_pass_flood.rb b/benchmark/bm_vm_thread_pass_flood.rb
new file mode 100644
index 0000000000..a660aafc18
--- /dev/null
+++ b/benchmark/bm_vm_thread_pass_flood.rb
@@ -0,0 +1,10 @@
+# n.b. this is a good test for GVL when pinned to a single CPU
+
+1000.times{
+ Thread.new{loop{Thread.pass}}
+}
+
+i = 0
+while i<10000
+ i += 1
+end
diff --git a/benchmark/vm_thread_pipe.rb b/benchmark/bm_vm_thread_pipe.rb
index 112a621905..112a621905 100644
--- a/benchmark/vm_thread_pipe.rb
+++ b/benchmark/bm_vm_thread_pipe.rb
diff --git a/benchmark/bm_vm_thread_queue.rb b/benchmark/bm_vm_thread_queue.rb
new file mode 100644
index 0000000000..274ceda366
--- /dev/null
+++ b/benchmark/bm_vm_thread_queue.rb
@@ -0,0 +1,18 @@
+require 'thread'
+
+n = 1_000_000
+q = Thread::Queue.new
+consumer = Thread.new{
+ while q.pop
+ # consuming
+ end
+}
+
+producer = Thread.new{
+ n.times{
+ q.push true
+ }
+ q.push nil
+}
+
+consumer.join
diff --git a/benchmark/vm_thread_sized_queue.rb b/benchmark/bm_vm_thread_sized_queue.rb
index 7b9af5482b..7b9af5482b 100644
--- a/benchmark/vm_thread_sized_queue.rb
+++ b/benchmark/bm_vm_thread_sized_queue.rb
diff --git a/benchmark/vm_thread_sized_queue2.rb b/benchmark/bm_vm_thread_sized_queue2.rb
index de9f55e978..de9f55e978 100644
--- a/benchmark/vm_thread_sized_queue2.rb
+++ b/benchmark/bm_vm_thread_sized_queue2.rb
diff --git a/benchmark/vm_thread_sized_queue3.rb b/benchmark/bm_vm_thread_sized_queue3.rb
index ce5f1796d8..ce5f1796d8 100644
--- a/benchmark/vm_thread_sized_queue3.rb
+++ b/benchmark/bm_vm_thread_sized_queue3.rb
diff --git a/benchmark/vm_thread_sized_queue4.rb b/benchmark/bm_vm_thread_sized_queue4.rb
index a9b7d80ec0..a9b7d80ec0 100644
--- a/benchmark/vm_thread_sized_queue4.rb
+++ b/benchmark/bm_vm_thread_sized_queue4.rb
diff --git a/benchmark/cgi_escape_html.yml b/benchmark/cgi_escape_html.yml
deleted file mode 100644
index af6abd08ac..0000000000
--- a/benchmark/cgi_escape_html.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-prelude: require 'cgi/escape'
-benchmark:
- - name: escape_html_blank
- prelude: str = ""
- script: CGI.escapeHTML(str)
- loop_count: 20000000
- - name: escape_html_short_none
- prelude: str = "abcde"
- script: CGI.escapeHTML(str)
- loop_count: 20000000
- - name: escape_html_short_one
- prelude: str = "abcd<"
- script: CGI.escapeHTML(str)
- loop_count: 20000000
- - name: escape_html_short_all
- prelude: str = "'&\"<>"
- script: CGI.escapeHTML(str)
- loop_count: 5000000
- - name: escape_html_long_none
- prelude: str = "abcde" * 300
- script: CGI.escapeHTML(str)
- loop_count: 1000000
- - name: escape_html_long_all
- prelude: str = "'&\"<>" * 10
- script: CGI.escapeHTML(str)
- loop_count: 1000000
- - name: escape_html_real
- prelude: | # http://example.com/
- str = <<~HTML
- <body>
- <div>
- <h1>Example Domain</h1>
- <p>This domain is established to be used for illustrative examples in documents. You may use this
- domain in examples without prior coordination or asking for permission.</p>
- <p><a href="http://www.iana.org/domains/example">More information...</a></p>
- </div>
- </body>
- HTML
- script: CGI.escapeHTML(str)
- loop_count: 1000000
diff --git a/benchmark/complex_float_add.yml b/benchmark/complex_float_add.yml
deleted file mode 100644
index d0150c5e5b..0000000000
--- a/benchmark/complex_float_add.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- max, min = 1000.0, -1000.0
- a = Complex(rand(max)+min, rand(max)+min)
- b = Complex(rand(max)+min, rand(max)+min)
-benchmark:
- complex_float_add: c = a + b
-loop_count: 1000000
diff --git a/benchmark/complex_float_div.yml b/benchmark/complex_float_div.yml
deleted file mode 100644
index b9f5e1d51c..0000000000
--- a/benchmark/complex_float_div.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- max, min = 1000.0, -1000.0
- a = Complex(rand(max)+min, rand(max)+min)
- b = Complex(rand(max)+min, rand(max)+min)
-benchmark:
- complex_float_div: c = a / b
-loop_count: 1000000
diff --git a/benchmark/complex_float_mul.yml b/benchmark/complex_float_mul.yml
deleted file mode 100644
index 59b096a6dc..0000000000
--- a/benchmark/complex_float_mul.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- max, min = 1000.0, -1000.0
- a = Complex(rand(max)+min, rand(max)+min)
- b = Complex(rand(max)+min, rand(max)+min)
-benchmark:
- complex_float_mul: c = a * b
-loop_count: 1000000
diff --git a/benchmark/complex_float_new.yml b/benchmark/complex_float_new.yml
deleted file mode 100644
index 6fcde3125b..0000000000
--- a/benchmark/complex_float_new.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- max, min = 1000.0, -1000.0
- a = Complex(rand(max)+min, rand(max)+min)
- b = Complex(rand(max)+min, rand(max)+min)
-benchmark:
- complex_float_new: c = Complex(a, b)
-loop_count: 1000000
diff --git a/benchmark/complex_float_power.yml b/benchmark/complex_float_power.yml
deleted file mode 100644
index c40a31ab55..0000000000
--- a/benchmark/complex_float_power.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- max, min = 1000.0, -1000.0
- a = Complex(rand(max)+min, rand(max)+min)
- b = Complex(rand(max)+min, rand(max)+min)
-benchmark:
- complex_float_power: c = a ** b
-loop_count: 1000000
diff --git a/benchmark/complex_float_sub.yml b/benchmark/complex_float_sub.yml
deleted file mode 100644
index 3fafe7cdbe..0000000000
--- a/benchmark/complex_float_sub.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- max, min = 1000.0, -1000.0
- a = Complex(rand(max)+min, rand(max)+min)
- b = Complex(rand(max)+min, rand(max)+min)
-benchmark:
- complex_float_sub: c = a - b
-loop_count: 1000000
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
new file mode 100755
index 0000000000..469fc99f40
--- /dev/null
+++ b/benchmark/driver.rb
@@ -0,0 +1,441 @@
+#!/usr/bin/env ruby
+#
+# Ruby Benchmark driver
+#
+
+first = true
+
+begin
+ require 'optparse'
+rescue LoadError
+ if first
+ first = false
+ $:.unshift File.join(File.dirname(__FILE__), '../lib')
+ retry
+ else
+ raise
+ end
+end
+
+require 'benchmark'
+require 'pp'
+require 'tempfile'
+
+class BenchmarkDriver
+ def self.benchmark(opt)
+ driver = self.new(opt[:execs], opt[:dir], opt)
+ begin
+ driver.run
+ ensure
+ driver.show_results
+ end
+ end
+
+ def self.load(input, type, opt)
+ case type
+ when 'yaml'
+ require 'yaml'
+ h = YAML.load(input)
+ when 'json'
+ require 'json'
+ h = JSON.load(input)
+ else
+ h = eval(input.read)
+ end
+ results = h[:results] || h["results"]
+ obj = allocate
+ obj.instance_variable_set("@execs", h[:executables] || h["executables"])
+ obj.instance_variable_set("@results", results)
+ obj.instance_variable_set("@opt", opt)
+ [1, 2].each do |i|
+ loop = results.assoc((n = "loop_whileloop#{i}").intern) || results.assoc(n)
+ obj.instance_variable_set("@loop_wl#{i}", loop ? loop[1].map {|t,*|t} : nil)
+ end
+ obj.instance_variable_set("@measure_target", opt[:measure_target] || opt["measure_target"])
+ obj
+ end
+
+ def output *args
+ puts(*args)
+ @output and @output.puts(*args)
+ end
+
+ def message *args
+ output(*args) if @verbose
+ end
+
+ def message_print *args
+ if @verbose
+ print(*args)
+ STDOUT.flush
+ @output and @output.print(*args)
+ end
+ end
+
+ def progress_message *args
+ unless STDOUT.tty?
+ STDERR.print(*args)
+ STDERR.flush
+ end
+ end
+
+ def initialize execs, dir, opt = {}
+ @execs = execs.map{|e|
+ e.strip!
+ next if e.empty?
+
+ if /(.+)::(.+)/ =~ e
+ # ex) ruby-a::/path/to/ruby-a
+ label = $1.strip
+ path = $2
+ version = `#{path} -v`.chomp
+ else
+ path = e
+ version = label = `#{path} -v`.chomp
+ end
+ [path, label, version]
+ }.compact
+
+ @dir = dir
+ @repeat = opt[:repeat] || 1
+ @repeat = 1 if @repeat < 1
+ @pattern = opt[:pattern] || nil
+ @exclude = opt[:exclude] || nil
+ @verbose = opt[:quiet] ? false : (opt[:verbose] || false)
+ @output = opt[:output] ? open(opt[:output], 'w') : nil
+ @loop_wl1 = @loop_wl2 = nil
+ @ruby_arg = opt[:ruby_arg] || nil
+ @measure_target = opt[:measure_target]
+ @opt = opt
+
+ # [[name, [[r-1-1, r-1-2, ...], [r-2-1, r-2-2, ...]]], ...]
+ @results = []
+
+ if @verbose
+ @start_time = Time.now
+ message @start_time
+ @execs.each_with_index{|(path, label, version), i|
+ message "target #{i}: " + (label == version ? "#{label}" : "#{label} (#{version})") + " at \"#{path}\""
+ }
+ message "measure target: #{@measure_target}"
+ end
+ end
+
+ def adjusted_results name, results
+ s = nil
+ results.each_with_index{|e, i|
+ r = e.min
+ case name
+ when /^vm1_/
+ if @loop_wl1
+ r -= @loop_wl1[i]
+ r = 0 if r < 0
+ s = '*'
+ end
+ when /^vm2_/
+ if @loop_wl2
+ r -= @loop_wl2[i]
+ r = 0 if r < 0
+ s = '*'
+ end
+ end
+ yield r
+ }
+ s
+ end
+
+ def show_results
+ case @opt[:format]
+ when :tsv
+ strformat = "\t%1$s"
+ numformat = "\t%1$*2$.3f"
+ minwidth = 0
+ name_width = 0
+ when :markdown
+ markdown = true
+ strformat = "|%1$-*2$s"
+ numformat = "|%1$*2$.3f"
+ when :plain
+ strformat = " %1$-*2$s"
+ numformat = " %1$*2$.3f"
+ end
+
+ name_width ||= @results.map {|v, result|
+ v.size + (case v; when /^vm1_/; @loop_wl1; when /^vm2_/; @loop_wl2; end ? 1 : 0)
+ }.max
+ minwidth ||= 7
+ width = @execs.map{|(_, v)| [v.size, minwidth].max}
+
+ output
+
+ if @verbose
+ message '-----------------------------------------------------------'
+ message 'raw data:'
+ message
+ message PP.pp(@results, "", 79)
+ message
+ message "Elapsed time: #{Time.now - @start_time} (sec)"
+ end
+
+ if rawdata_output = @opt[:rawdata_output]
+ h = {}
+ h[:cpuinfo] = File.read('/proc/cpuinfo') if File.exist?('/proc/cpuinfo')
+ h[:executables] = @execs
+ h[:results] = @results
+ if (type = File.extname(rawdata_output)).empty?
+ type = rawdata_output
+ rawdata_output = @output.path.sub(/\.[^.\/]+\z/, '') << '.' << rawdata_output
+ end
+ case type
+ when 'yaml'
+ require 'yaml'
+ h = YAML.dump(h)
+ when 'json'
+ require 'json'
+ h = JSON.pretty_generate(h)
+ else
+ require 'pp'
+ h = h.pretty_inspect
+ end
+ open(rawdata_output, 'w') {|f| f.puts h}
+ end
+
+ output '-----------------------------------------------------------'
+ output 'benchmark results:'
+
+ if @verbose and @repeat > 1
+ output "minimum results in each #{@repeat} measurements."
+ end
+
+ output({
+ real: "Execution time (sec)",
+ peak: "Memory usage (peak) (B)",
+ size: "Memory usage (last size) (B)",
+ }[@measure_target])
+ output if markdown
+ output ["name".ljust(name_width), @execs.map.with_index{|(_, v), i| sprintf(strformat, v, width[i])}].join("").rstrip
+ output ["-"*name_width, width.map{|n|":".rjust(n, "-")}].join("|") if markdown
+ @results.each{|v, result|
+ rets = []
+ s = adjusted_results(v, result){|r|
+ rets << sprintf(numformat, r, width[rets.size])
+ }
+ v += s if s
+ output [v.ljust(name_width), rets].join("")
+ }
+
+ if @execs.size > 1
+ output
+ output({
+ real: "Speedup ratio: compare with the result of `#{@execs[0][1]}' (greater is better)",
+ peak: "Memory consuming ratio (peak) with the result of `#{@execs[0][1]}' (greater is better)",
+ size: "Memory consuming ratio (size) with the result of `#{@execs[0][1]}' (greater is better)",
+ }[@measure_target])
+ output if markdown
+ output ["name".ljust(name_width), @execs[1..-1].map.with_index{|(_, v), i| sprintf(strformat, v, width[i])}].join("").rstrip
+ output ["-"*name_width, width[1..-1].map{|n|":".rjust(n, "-")}].join("|") if markdown
+ @results.each{|v, result|
+ rets = []
+ first_value = nil
+ s = adjusted_results(v, result){|r|
+ if first_value
+ if r == 0
+ rets << "Error"
+ else
+ rets << sprintf(numformat, first_value/Float(r), width[rets.size+1])
+ end
+ else
+ first_value = r
+ end
+ }
+ v += s if s
+ output [v.ljust(name_width), rets].join("")
+ }
+ end
+
+ if @opt[:output]
+ output
+ output "Log file: #{@opt[:output]}"
+ end
+ end
+
+ def files
+ flag = {}
+ @files = Dir.glob(File.join(@dir, 'bm*.rb')).map{|file|
+ next if @pattern && /#{@pattern}/ !~ File.basename(file)
+ next if @exclude && /#{@exclude}/ =~ File.basename(file)
+ case file
+ when /bm_(vm[12])_/, /bm_loop_(whileloop2?).rb/
+ flag[$1] = true
+ end
+ file
+ }.compact
+
+ if flag['vm1'] && !flag['whileloop']
+ @files << File.join(@dir, 'bm_loop_whileloop.rb')
+ elsif flag['vm2'] && !flag['whileloop2']
+ @files << File.join(@dir, 'bm_loop_whileloop2.rb')
+ end
+
+ @files.sort!
+ progress_message "total: #{@files.size * @repeat} trial(s) (#{@repeat} trial(s) for #{@files.size} benchmark(s))\n"
+ @files
+ end
+
+ def run
+ files.each_with_index{|file, i|
+ @i = i
+ r = measure_file(file)
+
+ if /bm_loop_whileloop.rb/ =~ file
+ @loop_wl1 = r[1].map{|e| e.min}
+ elsif /bm_loop_whileloop2.rb/ =~ file
+ @loop_wl2 = r[1].map{|e| e.min}
+ end
+ }
+ end
+
+ def measure_file file
+ name = File.basename(file, '.rb').sub(/^bm_/, '')
+ prepare_file = File.join(File.dirname(file), "prepare_#{name}.rb")
+ load prepare_file if FileTest.exist?(prepare_file)
+
+ if @verbose
+ output
+ output '-----------------------------------------------------------'
+ output name
+ output
+ output File.read(file)
+ output
+ end
+
+ result = [name]
+ result << @execs.map{|(e, v)|
+ (0...@repeat).map{
+ message_print "#{v}\t"
+ progress_message '.'
+
+ m = measure(e, file)
+ message "#{m}"
+ m
+ }
+ }
+ @results << result
+ result
+ end
+
+ unless defined?(File::NULL)
+ if File.exist?('/dev/null')
+ File::NULL = '/dev/null'
+ end
+ end
+
+ def measure executable, file
+ case @measure_target
+ when :real
+ cmd = "#{executable} #{@ruby_arg} #{file}"
+ m = Benchmark.measure{
+ system(cmd, out: File::NULL)
+ }
+ result = m.real
+ when :peak, :size
+ tmp = Tempfile.new("benchmark-memory-wrapper-data")
+ wrapper = "#{File.join(__dir__, 'memory_wrapper.rb')} #{tmp.path} #{@measure_target}"
+ cmd = "#{executable} #{@ruby_arg} #{wrapper} #{file}"
+ system(cmd, out: File::NULL)
+ result = tmp.read.to_i
+ tmp.close
+ else
+ raise "unknown measure target"
+ end
+
+ if $? != 0
+ raise $?.inspect if $? && $?.signaled?
+ output "\`#{cmd}\' exited with abnormal status (#{$?})"
+ 0
+ else
+ result
+ end
+ end
+end
+
+if __FILE__ == $0
+ opt = {
+ :execs => [],
+ :dir => File.dirname(__FILE__),
+ :repeat => 1,
+ :measure_target => :real,
+ :output => nil,
+ :raw_output => nil,
+ :format => :tsv,
+ }
+ formats = {
+ :tsv => ".tsv",
+ :markdown => ".md",
+ :plain => ".txt",
+ }
+
+ parser = OptionParser.new{|o|
+ o.on('-e', '--executables [EXECS]',
+ "Specify benchmark one or more targets (e1::path1; e2::path2; e3::path3;...)"){|e|
+ e.split(/;/).each{|path|
+ opt[:execs] << path
+ }
+ }
+ o.on('--rbenv [VERSIONS]', 'Specify benchmark targets with rbenv version (vX.X.X;vX.X.X;...)'){|v|
+ v.split(/;/).each{|version|
+ opt[:execs] << "#{version}::#{`RBENV_VERSION='#{version}' rbenv which ruby`.rstrip}"
+ }
+ }
+ o.on('-d', '--directory [DIRECTORY]', "Benchmark suites directory"){|d|
+ opt[:dir] = d
+ }
+ o.on('-p', '--pattern [PATTERN]', "Benchmark name pattern"){|p|
+ opt[:pattern] = p
+ }
+ o.on('-x', '--exclude [PATTERN]', "Benchmark exclude pattern"){|e|
+ opt[:exclude] = e
+ }
+ o.on('-r', '--repeat-count [NUM]', "Repeat count"){|n|
+ opt[:repeat] = n.to_i
+ }
+ o.on('-o', '--output-file [FILE]', "Output file"){|f|
+ opt[:output] = f
+ }
+ o.on('--ruby-arg [ARG]', "Optional argument for ruby"){|a|
+ opt[:ruby_arg] = a
+ }
+ o.on('--measure-target [TARGET]', 'real (execution time), peak, size (memory)'){|mt|
+ opt[:measure_target] = mt.to_sym
+ }
+ o.on('--rawdata-output [FILE]', 'output rawdata'){|r|
+ opt[:rawdata_output] = r
+ }
+ o.on('--load-rawdata=FILE', 'input rawdata'){|r|
+ opt[:rawdata_input] = r
+ }
+ o.on('-f', "--format=FORMAT", "output format (#{formats.keys.join(",")})", formats.keys){|r|
+ opt[:format] = r
+ }
+ o.on('-v', '--verbose'){|v|
+ opt[:verbose] = v
+ }
+ o.on('-q', '--quiet', "Run without notify information except result table."){|q|
+ opt[:quiet] = q
+ opt[:verbose] = false
+ }
+ }
+
+ parser.parse!(ARGV)
+
+ if input = opt[:rawdata_input]
+ b = open(input) {|f|
+ BenchmarkDriver.load(f, File.extname(input)[1..-1], opt)
+ }
+ b.show_results
+ else
+ opt[:output] ||= "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}#{formats[opt[:format]]}"
+ BenchmarkDriver.benchmark(opt)
+ end
+end
+
diff --git a/benchmark/enum_lazy_grep_v_100.rb b/benchmark/enum_lazy_grep_v_100.rb
deleted file mode 100644
index 8832392e65..0000000000
--- a/benchmark/enum_lazy_grep_v_100.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-grep_data = (1..10).to_a * 1000
-N = 100
-enum = grep_data.lazy.grep_v(->(i){i == 0}).grep_v(->(i){i == 0})
-N.times {enum.each {}}
diff --git a/benchmark/enum_lazy_grep_v_20.rb b/benchmark/enum_lazy_grep_v_20.rb
deleted file mode 100644
index 329509fa8f..0000000000
--- a/benchmark/enum_lazy_grep_v_20.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-grep_data = (1..10).to_a * 1000
-N = 100
-enum = grep_data.lazy.grep_v(->(i){i > 2}).grep_v(->(i){i > 2})
-N.times {enum.each {}}
diff --git a/benchmark/enum_lazy_grep_v_50.rb b/benchmark/enum_lazy_grep_v_50.rb
deleted file mode 100644
index 02ea4d4e71..0000000000
--- a/benchmark/enum_lazy_grep_v_50.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-grep_data = (1..10).to_a * 1000
-N = 100
-enum = grep_data.lazy.grep_v(->(i){i > 5}).grep_v(->(i){i > 5})
-N.times {enum.each {}}
diff --git a/benchmark/enum_lazy_uniq_100.rb b/benchmark/enum_lazy_uniq_100.rb
deleted file mode 100644
index 2e6434d9c4..0000000000
--- a/benchmark/enum_lazy_uniq_100.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-uniq_data = (1..10_000).to_a
-N = 100
-enum = uniq_data.lazy.uniq {|i| i % 10000}.uniq {|i| i % 10000}
-N.times {enum.each {}}
diff --git a/benchmark/enum_lazy_uniq_20.rb b/benchmark/enum_lazy_uniq_20.rb
deleted file mode 100644
index 75e6398fee..0000000000
--- a/benchmark/enum_lazy_uniq_20.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-uniq_data = (1..10_000).to_a
-N = 100
-enum = uniq_data.lazy.uniq {|i| i % 2000}.uniq {|i| i % 2000}
-N.times {enum.each {}}
diff --git a/benchmark/enum_lazy_uniq_50.rb b/benchmark/enum_lazy_uniq_50.rb
deleted file mode 100644
index 59a39b78ff..0000000000
--- a/benchmark/enum_lazy_uniq_50.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-uniq_data = (1..10_000).to_a
-N = 100
-enum = uniq_data.lazy.uniq {|i| i % 5000}.uniq {|i| i % 5000}
-N.times {enum.each {}}
diff --git a/benchmark/erb_render.yml b/benchmark/erb_render.yml
deleted file mode 100644
index 15f6c3880b..0000000000
--- a/benchmark/erb_render.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-prelude: |
- require 'erb'
-
- data = <<erb
- <html>
- <head> <%= title %> </head>
- <body>
- <h1> <%= title %> </h1>
- <p>
- <%= content %>
- </p>
- </body>
- </html>
- erb
-
- title = "hello world!"
- content = "hello world!\n" * 10
-
- src = "def self.render(title, content); #{ERB.new(data).src}; end"
- mod = Module.new
- mod.instance_eval(src, "(ERB)")
-benchmark:
- erb_render: mod.render(title, content)
-loop_count: 1500000
diff --git a/benchmark/fiber_chain.yml b/benchmark/fiber_chain.yml
deleted file mode 100755
index a36c759f8e..0000000000
--- a/benchmark/fiber_chain.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-prelude: |
- def make_link(previous)
- Fiber.new do
- while message = previous.resume
- Fiber.yield(message)
- end
- end
- end
-
- def make_chain(length = 1000, &block)
- chain = Fiber.new(&block)
-
- (length - 1).times do
- chain = make_link(chain)
- end
-
- return chain
- end
-
- message = "Hello World!"
-
- chain = make_chain do
- while true
- Fiber.yield(message)
- end
- end
-benchmark:
- make_chain: |
- make_chain(100) do
- while true
- Fiber.yield(message)
- end
- end
- resume_chain: |
- chain.resume
-loop_count: 5000
diff --git a/benchmark/file_rename.rb b/benchmark/file_rename.rb
deleted file mode 100644
index bbb44aebac..0000000000
--- a/benchmark/file_rename.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# rename file
-require 'tempfile'
-
-max = 100_000
-tmp = [ Tempfile.new('rename-a'), Tempfile.new('rename-b') ]
-a, b = tmp.map { |x| x.path }
-tmp.each { |t| t.close } # Windows can't rename files without closing them
-max.times do
- File.rename(a, b)
- File.rename(b, a)
-end
diff --git a/benchmark/gc/aobench.rb b/benchmark/gc/aobench.rb
index 275f58b924..2eed7abc83 100644
--- a/benchmark/gc/aobench.rb
+++ b/benchmark/gc/aobench.rb
@@ -1 +1 @@
-require_relative '../app_aobench'
+require_relative '../bm_app_aobench.rb'
diff --git a/benchmark/gc/binary_trees.rb b/benchmark/gc/binary_trees.rb
index 83347cdd20..af8ea722aa 100644
--- a/benchmark/gc/binary_trees.rb
+++ b/benchmark/gc/binary_trees.rb
@@ -1 +1 @@
-require_relative '../so_binary_trees'
+require_relative '../bm_so_binary_trees.rb'
diff --git a/benchmark/gc/gcbench.rb b/benchmark/gc/gcbench.rb
index 23d0b91c6c..09a404466a 100644
--- a/benchmark/gc/gcbench.rb
+++ b/benchmark/gc/gcbench.rb
@@ -3,12 +3,11 @@ require 'pp'
require 'optparse'
$list = true
-$gcprof = false
+$gcprof = true
opt = OptionParser.new
opt.on('-q'){$list = false}
opt.on('-d'){$gcprof = false}
-opt.on('-p'){$gcprof = true}
opt.parse!(ARGV)
script = File.join(File.dirname(__FILE__), ARGV.shift)
diff --git a/benchmark/gc/pentomino.rb b/benchmark/gc/pentomino.rb
index 8ebdff7d1d..94ba74be89 100644
--- a/benchmark/gc/pentomino.rb
+++ b/benchmark/gc/pentomino.rb
@@ -1 +1 @@
-require_relative '../app_pentomino'
+require_relative '../bm_app_pentomino.rb'
diff --git a/benchmark/hash_dup.yml b/benchmark/hash_dup.yml
deleted file mode 100644
index 65f521ec94..0000000000
--- a/benchmark/hash_dup.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- small_hash = { a: 1 }
- larger_hash = 20.times.map { |i| [('a'.ord + i).chr.to_sym, i] }.to_h
-
-benchmark:
- dup_small: small_hash.dup
- dup_larger: larger_hash.dup
-loop_count: 10000
diff --git a/benchmark/hash_literal_small2.rb b/benchmark/hash_literal_small2.rb
deleted file mode 100644
index c188529260..0000000000
--- a/benchmark/hash_literal_small2.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: true
-
-1_000_000.times.map { { "foo" => "bar", "bar" => "baz" } }
diff --git a/benchmark/hash_literal_small4.rb b/benchmark/hash_literal_small4.rb
deleted file mode 100644
index 739f71b5b0..0000000000
--- a/benchmark/hash_literal_small4.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: true
-
-1_000_000.times.map { { "foo" => "bar", "bar" => "baz", "baz" => "lol", "lol" => "lgtm" } }
diff --git a/benchmark/hash_literal_small8.rb b/benchmark/hash_literal_small8.rb
deleted file mode 100644
index 53d80af535..0000000000
--- a/benchmark/hash_literal_small8.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: true
-
-1_000_000.times.map { { "foo" => "bar", "bar" => "baz", "baz" => "lol", "lol" => "lgtm", "lgtm" => "nope", "nope" => "ok", "ok" => "again", "again" => "wait" } }
diff --git a/benchmark/irb_color.yml b/benchmark/irb_color.yml
deleted file mode 100644
index ebdc8d7e8b..0000000000
--- a/benchmark/irb_color.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-prelude: |
- require 'irb/color'
- code = <<~'CODE'
- def self.foo # bar
- :"erb #{ERB.new("<%= self %>", trim_mode: ?-).result}"
- end
- CODE
-benchmark:
- irb_color_complete: |
- IRB::Color.colorize_code(code, complete: true)
- irb_color_incomplete: |
- IRB::Color.colorize_code(code, complete: false)
-loop_count: 2000000
diff --git a/benchmark/irb_exec.yml b/benchmark/irb_exec.yml
deleted file mode 100644
index 28933f8b38..0000000000
--- a/benchmark/irb_exec.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-prelude: |
- # frozen_string_literal: true
- require 'rbconfig'
- irb_f = [File.join(File.dirname(RbConfig.ruby), 'irb'), '-f']
-benchmark:
- irb_exec: |
- IO.popen(irb_f, 'w') do |io|
- io.write('exit')
- end
-loop_count: 30
diff --git a/benchmark/lib/benchmark_driver/output/driver.rb b/benchmark/lib/benchmark_driver/output/driver.rb
deleted file mode 100644
index d22236e9fb..0000000000
--- a/benchmark/lib/benchmark_driver/output/driver.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'benchmark_driver/output/simple'
-
-# This replicates the legacy benchmark/driver.rb behavior.
-class BenchmarkDriver::Output::Driver < BenchmarkDriver::Output::Simple
- def initialize(*)
- super
- @stdout = $stdout
- @strio = StringIO.new
- $stdout = IOMultiplexer.new(@stdout, @strio)
- end
-
- def with_benchmark(*)
- super
- ensure
- logfile = "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}.log"
- puts "\nLog file: #{logfile}"
-
- $stdout = @stdout
- File.write(logfile, @strio.tap(&:rewind).read)
- end
-
- class IOMultiplexer
- def initialize(io1, io2)
- @io1 = io1
- @io2 = io2
- end
-
- [:write, :sync, :sync=, :puts, :print, :flush].each do |method|
- define_method(method) do |*args|
- @io1.send(method, *args)
- @io2.send(method, *args)
- end
- end
- end
- private_constant :IOMultiplexer
-end
diff --git a/benchmark/lib/benchmark_driver/runner/cstime.rb b/benchmark/lib/benchmark_driver/runner/cstime.rb
deleted file mode 100644
index 3c3453e527..0000000000
--- a/benchmark/lib/benchmark_driver/runner/cstime.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'benchmark_driver/runner/total'
-
-class BenchmarkDriver::Runner::Cstime < BenchmarkDriver::Runner::Total
- METRIC = BenchmarkDriver::Metric.new(name: 'cstime', unit: 's', larger_better: false)
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC])
-
- private
-
- # Overriding BenchmarkDriver::Runner::Total#metric
- def metric
- METRIC
- end
-
- # Overriding BenchmarkDriver::Runner::Total#target
- def target
- :cstime
- end
-end
diff --git a/benchmark/lib/benchmark_driver/runner/cutime.rb b/benchmark/lib/benchmark_driver/runner/cutime.rb
deleted file mode 100644
index e139962ef2..0000000000
--- a/benchmark/lib/benchmark_driver/runner/cutime.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'benchmark_driver/runner/total'
-
-class BenchmarkDriver::Runner::Cutime < BenchmarkDriver::Runner::Total
- METRIC = BenchmarkDriver::Metric.new(name: 'cutime', unit: 's', larger_better: false)
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC])
-
- private
-
- # Overriding BenchmarkDriver::Runner::Total#metric
- def metric
- METRIC
- end
-
- # Overriding BenchmarkDriver::Runner::Total#target
- def target
- :cutime
- end
-end
diff --git a/benchmark/lib/benchmark_driver/runner/mjit_exec.rb b/benchmark/lib/benchmark_driver/runner/mjit_exec.rb
deleted file mode 100644
index 9f7c8c8af3..0000000000
--- a/benchmark/lib/benchmark_driver/runner/mjit_exec.rb
+++ /dev/null
@@ -1,237 +0,0 @@
-require 'benchmark_driver/struct'
-require 'benchmark_driver/metric'
-require 'erb'
-
-# A special runner dedicated for measuring mjit_exec overhead.
-class BenchmarkDriver::Runner::MjitExec
- METRIC = BenchmarkDriver::Metric.new(name: 'Iteration per second', unit: 'i/s')
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = ::BenchmarkDriver::Struct.new(
- :name, # @param [String] name - This is mandatory for all runner
- :metrics, # @param [Array<BenchmarkDriver::Metric>]
- :num_methods, # @param [Integer] num_methods - The number of methods to be defined
- :loop_count, # @param [Integer] loop_count
- :from_jit, # @param [TrueClass,FalseClass] from_jit - Whether the mjit_exec() is from JIT or not
- :to_jit, # @param [TrueClass,FalseClass] to_jit - Whether the mjit_exec() is to JIT or not
- )
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- class << JobParser = Module.new
- # @param [Array,String] num_methods
- # @param [Integer] loop_count
- # @param [TrueClass,FalseClass] from_jit
- # @param [TrueClass,FalseClass] to_jit
- def parse(num_methods:, loop_count:, from_jit:, to_jit:)
- if num_methods.is_a?(String)
- num_methods = eval(num_methods)
- end
-
- num_methods.map do |num|
- if num_methods.size > 1
- suffix = "[#{'%4d' % num}]"
- else
- suffix = "_#{num}"
- end
- Job.new(
- name: "mjit_exec_#{from_jit ? 'JT' : 'VM'}2#{to_jit ? 'JT' : 'VM'}#{suffix}",
- metrics: [METRIC],
- num_methods: num,
- loop_count: loop_count,
- from_jit: from_jit,
- to_jit: to_jit,
- )
- end
- end
- end
-
- # @param [BenchmarkDriver::Config::RunnerConfig] config
- # @param [BenchmarkDriver::Output] output
- # @param [BenchmarkDriver::Context] contexts
- def initialize(config:, output:, contexts:)
- @config = config
- @output = output
- @contexts = contexts
- end
-
- # This method is dynamically called by `BenchmarkDriver::JobRunner.run`
- # @param [Array<BenchmarkDriver::Runner::Peak::Job>] jobs
- def run(jobs)
- @output.with_benchmark do
- jobs.each do |job|
- @output.with_job(name: job.name) do
- @contexts.each do |context|
- result = BenchmarkDriver::Repeater.with_repeat(config: @config, larger_better: true, rest_on_average: :average) do
- run_benchmark(job, context: context)
- end
- value, duration = result.value
- @output.with_context(name: context.name, executable: context.executable, gems: context.gems, prelude: context.prelude) do
- @output.report(values: { METRIC => value }, duration: duration, loop_count: job.loop_count)
- end
- end
- end
- end
- end
- end
-
- private
-
- # @param [BenchmarkDriver::Runner::Ips::Job] job - loop_count is not nil
- # @param [BenchmarkDriver::Context] context
- # @return [BenchmarkDriver::Metrics]
- def run_benchmark(job, context:)
- if job.from_jit
- if job.to_jit
- benchmark = BenchmarkJT2JT.new(num_methods: job.num_methods, loop_count: job.loop_count)
- else
- raise NotImplementedError, "JT2VM is not implemented yet"
- end
- else
- if job.to_jit
- benchmark = BenchmarkVM2JT.new(num_methods: job.num_methods, loop_count: job.loop_count)
- else
- benchmark = BenchmarkVM2VM.new(num_methods: job.num_methods, loop_count: job.loop_count)
- end
- end
-
- duration = Tempfile.open(['benchmark_driver-result', '.txt']) do |f|
- with_script(benchmark.render(result: f.path)) do |path|
- opt = []
- if context.executable.command.any? { |c| c.start_with?('--jit') }
- opt << '--jit-min-calls=2'
- end
- IO.popen([*context.executable.command, '--disable-gems', *opt, path], &:read)
- if $?.success?
- Float(f.read)
- else
- BenchmarkDriver::Result::ERROR
- end
- end
- end
-
- [job.loop_count.to_f / duration, duration]
- end
-
- def with_script(script)
- if @config.verbose >= 2
- sep = '-' * 30
- $stdout.puts "\n\n#{sep}[Script begin]#{sep}\n#{script}#{sep}[Script end]#{sep}\n\n"
- end
-
- Tempfile.open(['benchmark_driver-', '.rb']) do |f|
- f.puts script
- f.close
- return yield(f.path)
- end
- end
-
- # @param [Integer] num_methods
- # @param [Integer] loop_count
- BenchmarkVM2VM = ::BenchmarkDriver::Struct.new(:num_methods, :loop_count) do
- # @param [String] result - A file to write result
- def render(result:)
- ERB.new(<<~EOS, trim_mode: '%').result(binding)
- % num_methods.times do |i|
- def a<%= i %>
- nil
- end
- % end
- RubyVM::MJIT.pause if RubyVM::MJIT.enabled?
-
- def vm
- t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- i = 0
- while i < <%= loop_count / 1000 %>
- % 1000.times do |i|
- a<%= i % num_methods %>
- % end
- i += 1
- end
- % (loop_count % 1000).times do |i|
- a<%= i % num_methods %>
- % end
- Process.clock_gettime(Process::CLOCK_MONOTONIC) - t
- end
-
- vm # warmup call cache
- File.write(<%= result.dump %>, vm)
- EOS
- end
- end
- private_constant :BenchmarkVM2VM
-
- # @param [Integer] num_methods
- # @param [Integer] loop_count
- BenchmarkVM2JT = ::BenchmarkDriver::Struct.new(:num_methods, :loop_count) do
- # @param [String] result - A file to write result
- def render(result:)
- ERB.new(<<~EOS, trim_mode: '%').result(binding)
- % num_methods.times do |i|
- def a<%= i %>
- nil
- end
- a<%= i %>
- a<%= i %> # --jit-min-calls=2
- % end
- RubyVM::MJIT.pause if RubyVM::MJIT.enabled?
-
- def vm
- t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- i = 0
- while i < <%= loop_count / 1000 %>
- % 1000.times do |i|
- a<%= i % num_methods %>
- % end
- i += 1
- end
- % (loop_count % 1000).times do |i|
- a<%= i % num_methods %>
- % end
- Process.clock_gettime(Process::CLOCK_MONOTONIC) - t
- end
-
- vm # warmup call cache
- File.write(<%= result.dump %>, vm)
- EOS
- end
- end
- private_constant :BenchmarkVM2JT
-
- # @param [Integer] num_methods
- # @param [Integer] loop_count
- BenchmarkJT2JT = ::BenchmarkDriver::Struct.new(:num_methods, :loop_count) do
- # @param [String] result - A file to write result
- def render(result:)
- ERB.new(<<~EOS, trim_mode: '%').result(binding)
- % num_methods.times do |i|
- def a<%= i %>
- nil
- end
- % end
-
- # You may need to:
- # * Increase `JIT_ISEQ_SIZE_THRESHOLD` to 10000000 in mjit.h
- # * Always return false in `inlinable_iseq_p()` of mjit_compile.c
- def jit
- t = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- i = 0
- while i < <%= loop_count / 1000 %>
- % 1000.times do |i|
- a<%= i % num_methods %>
- % end
- i += 1
- end
- % (loop_count % 1000).times do |i|
- a<%= i % num_methods %>
- % end
- Process.clock_gettime(Process::CLOCK_MONOTONIC) - t
- end
-
- jit
- jit
- RubyVM::MJIT.pause if RubyVM::MJIT.enabled?
- File.write(<%= result.dump %>, jit)
- EOS
- end
- end
- private_constant :BenchmarkJT2JT
-end
diff --git a/benchmark/lib/benchmark_driver/runner/peak.rb b/benchmark/lib/benchmark_driver/runner/peak.rb
deleted file mode 100644
index d04f2e51ff..0000000000
--- a/benchmark/lib/benchmark_driver/runner/peak.rb
+++ /dev/null
@@ -1,151 +0,0 @@
-require 'benchmark_driver/struct'
-require 'benchmark_driver/metric'
-require 'benchmark_driver/default_job'
-require 'benchmark_driver/default_job_parser'
-require 'tempfile'
-
-class BenchmarkDriver::Runner::Peak
- METRIC = BenchmarkDriver::Metric.new(
- name: 'Peak memory usage', unit: 'bytes', larger_better: false, worse_word: 'larger',
- )
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC])
-
- # @param [BenchmarkDriver::Config::RunnerConfig] config
- # @param [BenchmarkDriver::Output] output
- # @param [BenchmarkDriver::Context] contexts
- def initialize(config:, output:, contexts:)
- @config = config
- @output = output
- @contexts = contexts
- end
-
- # This method is dynamically called by `BenchmarkDriver::JobRunner.run`
- # @param [Array<BenchmarkDriver::Runner::Peak::Job>] jobs
- def run(jobs)
- if jobs.any? { |job| job.loop_count.nil? }
- jobs = jobs.map do |job|
- job.loop_count ? job : Job.new(job.to_h.merge(loop_count: 1))
- end
- end
-
- @output.with_benchmark do
- jobs.each do |job|
- @output.with_job(name: job.name) do
- job.runnable_contexts(@contexts).each do |context|
- value = BenchmarkDriver::Repeater.with_repeat(config: @config, larger_better: false) do
- run_benchmark(job, context: context)
- end
- @output.with_context(name: context.name, executable: context.executable, gems: context.gems, prelude: context.prelude) do
- @output.report(values: { metric => value }, loop_count: job.loop_count)
- end
- end
- end
- end
- end
- end
-
- private
-
- # @param [BenchmarkDriver::Runner::Ips::Job] job - loop_count is not nil
- # @param [BenchmarkDriver::Context] context
- # @return [BenchmarkDriver::Metrics]
- def run_benchmark(job, context:)
- benchmark = BenchmarkScript.new(
- preludes: [context.prelude, job.prelude],
- script: job.script,
- teardown: job.teardown,
- loop_count: job.loop_count,
- )
-
- memory_status = File.expand_path('../../../../tool/lib/memory_status', __dir__)
- Tempfile.open(['benchmark_driver-', '.rb']) do |f|
- with_script(benchmark.render) do |path|
- output = IO.popen([*context.executable.command, path, f.path, target, memory_status], &:read)
- if $?.success?
- Integer(f.read)
- else
- $stdout.print(output)
- BenchmarkDriver::Result::ERROR
- end
- end
- end
- end
-
- # Overridden by BenchmarkDriver::Runner::Size
- def target
- 'peak'
- end
-
- # Overridden by BenchmarkDriver::Runner::Size
- def metric
- METRIC
- end
-
- def with_script(script)
- if @config.verbose >= 2
- sep = '-' * 30
- $stdout.puts "\n\n#{sep}[Script begin]#{sep}\n#{script}#{sep}[Script end]#{sep}\n\n"
- end
-
- Tempfile.open(['benchmark_driver-', '.rb']) do |f|
- f.puts script
- f.close
- return yield(f.path)
- end
- end
-
- # @param [String] prelude
- # @param [String] script
- # @param [String] teardown
- # @param [Integer] loop_count
- BenchmarkScript = ::BenchmarkDriver::Struct.new(:preludes, :script, :teardown, :loop_count) do
- def render
- prelude = preludes.reject(&:nil?).reject(&:empty?).join("\n")
- <<-RUBY
-#{prelude}
-#{while_loop(script, loop_count)}
-#{teardown}
-
-result_file, target, memory_status = ARGV
-require_relative memory_status
-
-ms = Memory::Status.new
-case target.to_sym
-when :peak
- key = ms.respond_to?(:hwm) ? :hwm : :peak
-when :size
- key = ms.respond_to?(:rss) ? :rss : :size
-else
- raise('unexpected target: ' + target)
-end
-
-File.write(result_file, ms[key])
- RUBY
- end
-
- private
-
- def while_loop(content, times)
- if !times.is_a?(Integer) || times <= 0
- raise ArgumentError.new("Unexpected times: #{times.inspect}")
- end
-
- if times > 1
- <<-RUBY
-__bmdv_i = 0
-while __bmdv_i < #{times}
- #{content}
- __bmdv_i += 1
-end
- RUBY
- else
- content
- end
- end
- end
- private_constant :BenchmarkScript
-end
diff --git a/benchmark/lib/benchmark_driver/runner/size.rb b/benchmark/lib/benchmark_driver/runner/size.rb
deleted file mode 100644
index 1b31f901c7..0000000000
--- a/benchmark/lib/benchmark_driver/runner/size.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'benchmark_driver/runner/peak'
-
-# Actually the same as BenchmarkDriver::Runner::Memory
-class BenchmarkDriver::Runner::Size < BenchmarkDriver::Runner::Peak
- METRIC = BenchmarkDriver::Metric.new(
- name: 'Max resident set size', unit: 'bytes', larger_better: false, worse_word: 'larger',
- )
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC])
-
- private
-
- # Overriding BenchmarkDriver::Runner::Peak#metric
- def metric
- METRIC
- end
-
- # Overriding BenchmarkDriver::Runner::Peak#target
- def target
- 'size'
- end
-end
diff --git a/benchmark/lib/benchmark_driver/runner/stime.rb b/benchmark/lib/benchmark_driver/runner/stime.rb
deleted file mode 100644
index 4577fb0bf8..0000000000
--- a/benchmark/lib/benchmark_driver/runner/stime.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'benchmark_driver/runner/total'
-
-class BenchmarkDriver::Runner::Stime < BenchmarkDriver::Runner::Total
- METRIC = BenchmarkDriver::Metric.new(name: 'stime', unit: 's', larger_better: false)
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC])
-
- private
-
- # Overriding BenchmarkDriver::Runner::Total#metric
- def metric
- METRIC
- end
-
- # Overriding BenchmarkDriver::Runner::Total#target
- def target
- :stime
- end
-end
diff --git a/benchmark/lib/benchmark_driver/runner/total.rb b/benchmark/lib/benchmark_driver/runner/total.rb
deleted file mode 100644
index 64dc14f84e..0000000000
--- a/benchmark/lib/benchmark_driver/runner/total.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-require 'benchmark_driver/struct'
-require 'benchmark_driver/metric'
-require 'benchmark_driver/default_job'
-require 'benchmark_driver/default_job_parser'
-require 'tempfile'
-
-class BenchmarkDriver::Runner::Total
- METRIC = BenchmarkDriver::Metric.new(name: 'Total time', unit: 's', larger_better: false)
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC])
-
- # @param [BenchmarkDriver::Config::RunnerConfig] config
- # @param [BenchmarkDriver::Output] output
- # @param [BenchmarkDriver::Context] contexts
- def initialize(config:, output:, contexts:)
- @config = config
- @output = output
- @contexts = contexts
- end
-
- # This method is dynamically called by `BenchmarkDriver::JobRunner.run`
- # @param [Array<BenchmarkDriver::Runner::Total::Job>] jobs
- def run(jobs)
- if jobs.any? { |job| job.loop_count.nil? }
- raise 'missing loop_count is not supported in Ruby repository'
- end
-
- @output.with_benchmark do
- jobs.each do |job|
- @output.with_job(name: job.name) do
- job.runnable_contexts(@contexts).each do |context|
- duration = BenchmarkDriver::Repeater.with_repeat(config: @config, larger_better: false) do
- run_benchmark(job, context: context)
- end
- @output.with_context(name: context.name, executable: context.executable, gems: context.gems, prelude: context.prelude) do
- @output.report(values: { metric => duration }, duration: duration, loop_count: job.loop_count)
- end
- end
- end
- end
- end
- end
-
- private
-
- # @param [BenchmarkDriver::Runner::Ips::Job] job - loop_count is not nil
- # @param [BenchmarkDriver::Context] context
- # @return [BenchmarkDriver::Metrics]
- def run_benchmark(job, context:)
- benchmark = BenchmarkScript.new(
- preludes: [context.prelude, job.prelude],
- script: job.script,
- teardown: job.teardown,
- loop_count: job.loop_count,
- )
-
- Tempfile.open(['benchmark_driver-', '.rb']) do |f|
- with_script(benchmark.render(result: f.path, target: target)) do |path|
- IO.popen([*context.executable.command, path], &:read) # TODO: print stdout if verbose=2
- if $?.success?
- Float(f.read)
- else
- BenchmarkDriver::Result::ERROR
- end
- end
- end
- end
-
- # This method is overridden by some subclasses
- def metric
- METRIC
- end
-
- # This method is overridden by some subclasses
- def target
- :total
- end
-
- def with_script(script)
- if @config.verbose >= 2
- sep = '-' * 30
- $stdout.puts "\n\n#{sep}[Script begin]#{sep}\n#{script}#{sep}[Script end]#{sep}\n\n"
- end
-
- Tempfile.open(['benchmark_driver-', '.rb']) do |f|
- f.puts script
- f.close
- return yield(f.path)
- end
- end
-
- # @param [String] prelude
- # @param [String] script
- # @param [String] teardown
- # @param [Integer] loop_count
- BenchmarkScript = ::BenchmarkDriver::Struct.new(:preludes, :script, :teardown, :loop_count) do
- # @param [String] result - A file to write result
- def render(result:, target:)
- prelude = preludes.reject(&:nil?).reject(&:empty?).join("\n")
- <<-RUBY
-#{prelude}
-
-require 'benchmark'
-__bmdv_result = Benchmark.measure {
- #{while_loop(script, loop_count)}
-}
-
-#{teardown}
-
-File.write(#{result.dump}, __bmdv_result.#{target})
- RUBY
- end
-
- private
-
- def while_loop(content, times)
- if !times.is_a?(Integer) || times <= 0
- raise ArgumentError.new("Unexpected times: #{times.inspect}")
- elsif times == 1
- return content
- end
-
- # TODO: execute in batch
- <<-RUBY
-__bmdv_i = 0
-while __bmdv_i < #{times}
- #{content}
- __bmdv_i += 1
-end
- RUBY
- end
- end
- private_constant :BenchmarkScript
-end
diff --git a/benchmark/lib/benchmark_driver/runner/utime.rb b/benchmark/lib/benchmark_driver/runner/utime.rb
deleted file mode 100644
index b61d83a188..0000000000
--- a/benchmark/lib/benchmark_driver/runner/utime.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'benchmark_driver/runner/total'
-
-class BenchmarkDriver::Runner::Utime < BenchmarkDriver::Runner::Total
- METRIC = BenchmarkDriver::Metric.new(name: 'utime', unit: 's', larger_better: false)
-
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC])
-
- private
-
- # Overriding BenchmarkDriver::Runner::Total#metric
- def metric
- METRIC
- end
-
- # Overriding BenchmarkDriver::Runner::Total#target
- def target
- :utime
- end
-end
diff --git a/benchmark/lib/load.rb b/benchmark/lib/load.rb
deleted file mode 100644
index 31b770c484..0000000000
--- a/benchmark/lib/load.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# How to use this file:
-# 1. write a `$(srcdir)/test.rb` like:
-=begin
-require_relative 'benchmark/lib/load'
-
-Benchmark.driver(repeat_count: 5){|x|
- x.executable name: 'clean-miniruby', command: %w'../clean-trunk/miniruby'
- x.executable name: 'modif-miniruby', command: %w'./miniruby'
-
- x.report %q{
- h = {a: 1, b: 2, c: 3, d: 4}
- }
-}
-=end
-#
-# 2. `make run`
-$:.unshift(File.join(__dir__, '../benchmark-driver/lib'))
-require 'benchmark_driver'
diff --git a/benchmark/make_fasta_output.rb b/benchmark/make_fasta_output.rb
new file mode 100644
index 0000000000..b6d787ae27
--- /dev/null
+++ b/benchmark/make_fasta_output.rb
@@ -0,0 +1,19 @@
+# prepare 'fasta.output'
+
+def prepare_fasta_output n
+ filebase = File.join(File.dirname($0), 'fasta.output')
+ script = File.join(File.dirname($0), 'bm_so_fasta.rb')
+ file = "#{filebase}.#{n}"
+
+ unless FileTest.exist?(file)
+ STDERR.puts "preparing #{file}"
+
+ open(file, 'w'){|f|
+ ARGV[0] = n
+ $stdout = f
+ load script
+ $stdout = STDOUT
+ }
+ end
+end
+
diff --git a/benchmark/match_gt4.rb b/benchmark/match_gt4.rb
deleted file mode 100644
index ffda109912..0000000000
--- a/benchmark/match_gt4.rb
+++ /dev/null
@@ -1 +0,0 @@
-1000000.times { /(.)(.)(\d+)(\d)/.match("THX1138.") }
diff --git a/benchmark/match_small.rb b/benchmark/match_small.rb
deleted file mode 100644
index 3b743d484a..0000000000
--- a/benchmark/match_small.rb
+++ /dev/null
@@ -1 +0,0 @@
-1000000.times { 'haystack'.match(/hay/) }
diff --git a/benchmark/memory_wrapper.rb b/benchmark/memory_wrapper.rb
new file mode 100644
index 0000000000..3f4451a037
--- /dev/null
+++ b/benchmark/memory_wrapper.rb
@@ -0,0 +1,16 @@
+
+write_file, target, script_file = ARGV
+
+load(script_file)
+require_relative '../test/lib/memory_status'
+open(write_file, 'wb'){|f|
+ ms = Memory::Status.new
+ case target.to_sym
+ when :peak
+ key = ms.respond_to?(:hwm) ? :hwm : :peak
+ when :size
+ key = ms.respond_to?(:rss) ? :rss : :size
+ end
+
+ f.puts ms[key]
+}
diff --git a/benchmark/mjit_exec_jt2jt.yml b/benchmark/mjit_exec_jt2jt.yml
deleted file mode 100644
index 5be408e30c..0000000000
--- a/benchmark/mjit_exec_jt2jt.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Usage:
-# RUBYOPT=-Ibenchmark/lib benchmark-driver -e 'ruby --jit' benchmark/mjit_exec_vm2jt.yml
-type: mjit_exec # benchmark/lib/benchmark_driver/runner/mjit_exec.rb
-num_methods: [1]
-#num_methods: (1..100).to_a + [200, 300, 400, 500, 600, 700, 800, 900, 1000]
-loop_count: 50000000
-from_jit: true
-to_jit: true
diff --git a/benchmark/mjit_exec_vm2jt.yml b/benchmark/mjit_exec_vm2jt.yml
deleted file mode 100644
index 9947dbb7dd..0000000000
--- a/benchmark/mjit_exec_vm2jt.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Usage:
-# RUBYOPT=-Ibenchmark/lib benchmark-driver -e 'ruby --jit' benchmark/mjit_exec_vm2jt.yml
-type: mjit_exec # benchmark/lib/benchmark_driver/runner/mjit_exec.rb
-num_methods: [1]
-#num_methods: (1..100).to_a + [200, 300, 400, 500, 600, 700, 800, 900, 1000]
-loop_count: 50000000
-from_jit: false
-to_jit: true
diff --git a/benchmark/mjit_exec_vm2vm.yml b/benchmark/mjit_exec_vm2vm.yml
deleted file mode 100644
index 4b84427b10..0000000000
--- a/benchmark/mjit_exec_vm2vm.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Usage:
-# RUBYOPT=-Ibenchmark/lib benchmark-driver -e 'ruby --jit' benchmark/mjit_exec_vm2vm.yml
-type: mjit_exec # benchmark/lib/benchmark_driver/runner/mjit_exec.rb
-num_methods: [1]
-#num_methods: (1..100).to_a + [200, 300, 400, 500, 600, 700, 800, 900, 1000]
-loop_count: 50000000
-from_jit: false
-to_jit: false
diff --git a/benchmark/nil_p.yml b/benchmark/nil_p.yml
deleted file mode 100644
index 79ba4f2177..0000000000
--- a/benchmark/nil_p.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-prelude: |
- class Niller; def nil?; true; end; end
- xnil, notnil = nil, Object.new
- niller = Niller.new
-benchmark:
- - xnil.nil?
- - notnil.nil?
- - niller.nil?
-loop_count: 10000000
diff --git a/benchmark/other-lang/fact.py b/benchmark/other-lang/fact.py
index 1ce9f76275..01593965d9 100644
--- a/benchmark/other-lang/fact.py
+++ b/benchmark/other-lang/fact.py
@@ -3,7 +3,7 @@
def factL(n):
r = 1
- for x in range(2, n+1):
+ for x in range(2, n):
r *= x
return r
diff --git a/benchmark/prepare_require.rb b/benchmark/prepare_require.rb
new file mode 100644
index 0000000000..c4786f04ad
--- /dev/null
+++ b/benchmark/prepare_require.rb
@@ -0,0 +1,25 @@
+require "fileutils"
+
+def prepare
+ num_files = 10000
+
+ basename = File.dirname($0)
+ data_dir = File.join(basename, "bm_require.data")
+
+ # skip if all of files exists
+ if File.exist?(File.join(data_dir, "c#{num_files}.rb"))
+ return
+ end
+
+ FileUtils.mkdir_p(data_dir)
+
+ 1.upto(num_files) do |i|
+ f = File.open("#{data_dir}/c#{i}.rb", "w")
+ f.puts <<-END
+ class C#{i}
+ end
+ END
+ end
+end
+
+prepare
diff --git a/benchmark/prepare_require_thread.rb b/benchmark/prepare_require_thread.rb
new file mode 100644
index 0000000000..339ecb8b39
--- /dev/null
+++ b/benchmark/prepare_require_thread.rb
@@ -0,0 +1,2 @@
+load File.join(File.dirname(__FILE__), "prepare_require.rb")
+
diff --git a/benchmark/prepare_so_count_words.rb b/benchmark/prepare_so_count_words.rb
new file mode 100644
index 0000000000..ee2138cdb2
--- /dev/null
+++ b/benchmark/prepare_so_count_words.rb
@@ -0,0 +1,15 @@
+# prepare 'wc.input'
+
+def prepare_wc_input
+ wcinput = File.join(File.dirname($0), 'wc.input')
+ wcbase = File.join(File.dirname($0), 'wc.input.base')
+ unless FileTest.exist?(wcinput)
+ data = File.read(wcbase)
+ 13.times{
+ data << data
+ }
+ open(wcinput, 'w'){|f| f.write data}
+ end
+end
+
+prepare_wc_input
diff --git a/benchmark/prepare_so_k_nucleotide.rb b/benchmark/prepare_so_k_nucleotide.rb
new file mode 100644
index 0000000000..d83aeb7a7e
--- /dev/null
+++ b/benchmark/prepare_so_k_nucleotide.rb
@@ -0,0 +1,2 @@
+require_relative 'make_fasta_output'
+prepare_fasta_output(100_000)
diff --git a/benchmark/prepare_so_reverse_complement.rb b/benchmark/prepare_so_reverse_complement.rb
new file mode 100644
index 0000000000..da3ec2df14
--- /dev/null
+++ b/benchmark/prepare_so_reverse_complement.rb
@@ -0,0 +1,2 @@
+require_relative 'make_fasta_output'
+prepare_fasta_output(2_500_000)
diff --git a/benchmark/range_last.yml b/benchmark/range_last.yml
deleted file mode 100644
index a6674f82ee..0000000000
--- a/benchmark/range_last.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- - (1..1_000_000).last(100)
- - (1..1_000_000).last(1000)
- - (1..1_000_000).last(10000)
diff --git a/benchmark/realpath.yml b/benchmark/realpath.yml
deleted file mode 100644
index 90a029d5b9..0000000000
--- a/benchmark/realpath.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-prelude: |
- f = File
- pwd = Dir.pwd
- Dir.mkdir('b') unless f.directory?('b')
- f.write('b/a', '') unless f.file?('b/a')
-
- relative = 'b/a'
- absolute = File.join(pwd, relative)
- dir = 'b'
- file = 'a'
-
- relative_dir = 'b/c'
- absolute_dir = File.join(pwd, relative_dir)
- file_dir = 'c'
-benchmark:
- relative_nil: "f.realpath(relative, nil)"
- absolute_nil: "f.realpath(absolute, nil)"
- relative_relative: "f.realpath(file, dir)"
- absolute_relative: "f.realpath(absolute, dir)"
- relative_absolute: "f.realpath(relative, pwd)"
- relative_nil_dir: "f.realdirpath(relative_dir, nil)"
- absolute_nil_dir: "f.realdirpath(absolute_dir, nil)"
- relative_relative_dir: "f.realdirpath(file_dir, dir)"
- absolute_relative_dir: "f.realdirpath(absolute_dir, dir)"
- relative_absolute_dir: "f.realdirpath(relative_dir, pwd)"
- relative_nil_notexist: "f.realpath(relative_dir, nil) rescue nil"
- absolute_nil_notexist: "f.realpath(absolute_dir, nil) rescue nil"
- relative_relative_notexist: "f.realpath(file_dir, dir) rescue nil"
- absolute_relative_notexist: "f.realpath(absolute_dir, dir) rescue nil"
- relative_absolute_notexist: "f.realpath(relative_dir, pwd) rescue nil"
diff --git a/benchmark/report.rb b/benchmark/report.rb
new file mode 100644
index 0000000000..d2dc56b1e1
--- /dev/null
+++ b/benchmark/report.rb
@@ -0,0 +1,79 @@
+#
+# YARV benchmark driver
+#
+
+require 'yarvutil'
+require 'benchmark'
+require 'rbconfig'
+
+def exec_command type, file, w
+ <<-EOP
+ $DRIVER_PATH = '#{File.dirname($0)}'
+ $LOAD_PATH.replace $LOAD_PATH | #{$LOAD_PATH.inspect}
+ require 'benchmark'
+ require 'yarvutil'
+# print '#{type}'
+ begin
+ puts Benchmark.measure{
+ #{w}('#{file}')
+ }.utime
+ rescue Exception => exec_command_error_variable
+ puts "\t" + exec_command_error_variable.message
+ end
+ EOP
+end
+
+def benchmark cmd
+ rubybin = ENV['RUBY'] || RbConfig.ruby
+
+ IO.popen(rubybin, 'r+'){|io|
+ io.write cmd
+ io.close_write
+ return io.gets
+ }
+end
+
+def ruby_exec file
+ prog = exec_command 'ruby', file, 'load'
+ benchmark prog
+end
+
+def yarv_exec file
+ prog = exec_command 'yarv', file, 'YARVUtil.load_bm'
+ benchmark prog
+end
+
+$wr = $wy = nil
+
+def measure bench
+ file = File.dirname($0) + "/bm_#{bench}.rb"
+ r = ruby_exec(file).to_f
+ y = yarv_exec(file).to_f
+ puts "#{bench}\t#{r}\t#{y}"
+end
+
+def measure2
+ r = ruby_exec.to_f
+ y = yarv_exec.to_f
+ puts r/y
+end
+
+if $0 == __FILE__
+ %w{
+ whileloop
+ whileloop2
+ times
+ const
+ method
+ poly_method
+ block
+ rescue
+ rescue2
+ }.each{|bench|
+ measure bench
+ }
+end
+
+
+
+
diff --git a/benchmark/require.yml b/benchmark/require.yml
deleted file mode 100644
index 09f218cf08..0000000000
--- a/benchmark/require.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-prelude: |
- require "fileutils"
-
- def prepare
- num_files = 10000
-
- basename = File.dirname($0)
- data_dir = File.join(basename, "bm_require.data")
-
- # skip if all of files exists
- if File.exist?(File.join(data_dir, "c#{num_files}.rb"))
- return
- end
-
- FileUtils.mkdir_p(data_dir)
-
- 1.upto(num_files) do |i|
- File.write("#{data_dir}/c#{i}.rb", "class C#{i}\n""end\n")
- end
- end
-
- prepare
-benchmark:
- require: |
- $:.push File.join(File.dirname(__FILE__), "bm_require.data")
-
- 1.upto(10000) do |i|
- require "c#{i}"
- end
-
- $:.pop
-loop_count: 1
diff --git a/benchmark/require_thread.yml b/benchmark/require_thread.yml
deleted file mode 100644
index 0c63257106..0000000000
--- a/benchmark/require_thread.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-prelude: |
- require "fileutils"
-
- def prepare
- num_files = 10000
-
- basename = File.dirname($0)
- data_dir = File.join(basename, "bm_require.data")
-
- # skip if all of files exists
- if File.exist?(File.join(data_dir, "c#{num_files}.rb"))
- return
- end
-
- FileUtils.mkdir_p(data_dir)
-
- 1.upto(num_files) do |i|
- File.write("#{data_dir}/c#{i}.rb", "class C#{i}\n""end\n")
- end
- end
-
- prepare
-benchmark:
- require_thread: |
- $:.push File.join(File.dirname(__FILE__), "bm_require.data")
-
- i=0
- t = Thread.new do
- while true
- i = i+1 # dummy loop
- end
- end
-
- 1.upto(100) do |i|
- require "c#{i}"
- end
-
- $:.pop
- t.kill
-loop_count: 1
diff --git a/benchmark/run.rb b/benchmark/run.rb
new file mode 100644
index 0000000000..0cd2363849
--- /dev/null
+++ b/benchmark/run.rb
@@ -0,0 +1,127 @@
+#
+# Ruby benchmark driver
+#
+
+require 'benchmark'
+require 'rbconfig'
+
+$matzrubyonly = false
+$rubyonly = false
+
+$results = []
+
+# prepare 'wc.input'
+def prepare_wc_input
+ wcinput = File.join(File.dirname($0), 'wc.input')
+ wcbase = File.join(File.dirname($0), 'wc.input.base')
+ unless FileTest.exist?(wcinput)
+ data = File.read(wcbase)
+ 13.times{
+ data << data
+ }
+ open(wcinput, 'w'){|f| f.write data}
+ end
+end
+
+prepare_wc_input
+
+def bm file
+ prog = File.readlines(file).map{|e| e.rstrip}.join("\n")
+ return if prog.empty?
+
+ /[a-z]+_(.+)\.rb/ =~ file
+ bm_name = $1
+ puts '-----------------------------------------------------------' unless $rubyonly || $matzrubyonly
+ puts "#{bm_name}: "
+
+
+puts <<EOS unless $matzrubyonly || $rubyonly
+#{prog}
+--
+EOS
+ begin
+ result = [bm_name]
+ result << matzruby_exec(file) unless $rubyonly
+ result << ruby_exec(file) unless $matzrubyonly
+ $results << result
+
+ rescue Exception => e
+ puts
+ puts "** benchmark failure: #{e}"
+ puts e.backtrace
+ end
+end
+
+def benchmark file, bin
+ m = Benchmark.measure{
+ `#{bin} #{$opts} #{file}`
+ }
+ sec = '%.3f' % m.real
+ puts " #{sec}"
+ sec
+end
+
+def ruby_exec file
+ print 'ruby'
+ benchmark file, $ruby_program
+end
+
+def matzruby_exec file
+ print 'matz'
+ rubylib = ENV['RUBYLIB']
+ ENV['RUBYLIB'] = ''
+ r = benchmark file, $matzruby_program
+ ENV['RUBYLIB'] = rubylib
+ r
+end
+
+if $0 == __FILE__
+ ARGV.each{|arg|
+ case arg
+ when /\A--ruby=(.+)/
+ $ruby_program = $1
+ when /\A--matzruby=(.+)/
+ $matzruby_program = $1
+ when /\A--opts=(.+)/
+ $opts = $1
+ when /\A(-r|--only-ruby)\z/
+ $rubyonly = true
+ when /\A(-m|--only-matzruby)\z/
+ $matzrubyonly = true
+ end
+ }
+ ARGV.delete_if{|arg|
+ /\A-/ =~ arg
+ }
+
+ puts "MatzRuby:"
+ system("#{$matzruby_program} -v")
+ puts "Ruby:"
+ system("#{$ruby_program} -v")
+ puts
+
+ if ARGV.empty?
+ Dir.glob(File.dirname(__FILE__) + '/bm_*.rb').sort.each{|file|
+ bm file
+ }
+ else
+ ARGV.each{|file|
+ Dir.glob(File.join(File.dirname(__FILE__), file + '*')){|ef|
+ # file = "#{File.dirname(__FILE__)}/#{file}.rb"
+ bm ef
+ }
+ }
+ end
+
+ puts
+ puts "-- benchmark summary ---------------------------"
+ $results.each{|res|
+ print res.shift, "\t"
+ (res||[]).each{|result|
+ /([\d\.]+)/ =~ result
+ print $1 + "\t" if $1
+ }
+ puts
+ }
+end
+
diff --git a/benchmark/runc.rb b/benchmark/runc.rb
new file mode 100644
index 0000000000..97c5cef045
--- /dev/null
+++ b/benchmark/runc.rb
@@ -0,0 +1,27 @@
+#
+#
+#
+
+require 'benchmark'
+require 'rbconfig'
+
+$rubybin = ENV['RUBY'] || RbConfig.ruby
+
+def runfile file
+ puts file
+ file = File.join(File.dirname($0), 'contrib', file)
+ Benchmark.bm{|x|
+ x.report('ruby'){
+ system("#{$rubybin} #{file}")
+ }
+ x.report('yarv'){
+ system("#{$rubybin} -rite -I.. #{file}")
+ }
+ }
+end
+
+ARGV.each{|file|
+ runfile file
+}
+
+
diff --git a/benchmark/so_ackermann.rb b/benchmark/so_ackermann.rb
deleted file mode 100644
index 4effa1ecaf..0000000000
--- a/benchmark/so_ackermann.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/ruby
-# -*- Ruby -*-
-# $Id: ackermann-ruby.code,v 1.4 2004/11/13 07:40:41 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-
-def ack(m, n)
- if m == 0 then
- n + 1
- elsif n == 0 then
- ack(m - 1, 1)
- else
- ack(m - 1, ack(m, n - 1))
- end
-end
-
-NUM = 9
-ack(3, NUM)
-
-
diff --git a/benchmark/so_array.rb b/benchmark/so_array.rb
deleted file mode 100644
index 767e03db5f..0000000000
--- a/benchmark/so_array.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/ruby
-# -*- Ruby -*-
-# $Id: ary-ruby.code,v 1.4 2004/11/13 07:41:27 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# with help from Paul Brannan and Mark Hubbart
-
-n = 9000 # Integer(ARGV.shift || 1)
-
-x = Array.new(n)
-y = Array.new(n, 0)
-
-n.times{|bi|
- x[bi] = bi + 1
-}
-
-(0 .. 999).each do |e|
- (n-1).step(0,-1) do |bi|
- y[bi] += x.at(bi)
- end
-end
-# puts "#{y.first} #{y.last}"
-
-
diff --git a/benchmark/so_concatenate.rb b/benchmark/so_concatenate.rb
deleted file mode 100644
index 4468e20ac8..0000000000
--- a/benchmark/so_concatenate.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/ruby
-# -*- Ruby -*-
-# $Id: strcat-ruby.code,v 1.4 2004/11/13 07:43:28 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# based on code from Aristarkh A Zagorodnikov and Dat Nguyen
-
-STUFF = "hello\n"
-i = 0
-while i<10
- i += 1
- hello = ''
- 4_000_000.times do |e|
- hello << STUFF
- end
-end
-# puts hello.length
-
-
diff --git a/benchmark/so_count_words.yml b/benchmark/so_count_words.yml
deleted file mode 100644
index 99683505f9..0000000000
--- a/benchmark/so_count_words.yml
+++ /dev/null
@@ -1,65 +0,0 @@
-prelude: |
- #!/usr/bin/ruby
-
- wc_input_base = <<EOS
- Subject: Re: Who was Izchak Miller?
- From: "Jane D. Anonymous" <nobody@yale.edu>
- Date: 1996/04/28
- Message-Id: <4lv7bc$oh@news.ycc.yale.edu>
- References: <317C405E.5DFA@panix.com> <4lk6vl$gde@ns.oar.net>
- To: 75176.2330@compuserve.com
- Content-Type: text/plain; charset=us-ascii
- Organization: Yale University
- X-Url: news:4lk6vl$gde@ns.oar.net
- Mime-Version: 1.0
- Newsgroups: rec.games.roguelike.nethack
- X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
-
- Hello there, Izchak Miller was my father. When I was younger I spent
- many a night, hunched over the keyboard with a cup of tea, playing
- nethack with him and my brother. my dad was a philosopher with a strong
- weakness for fantasy/sci fi. I remember when he started to get involved
- with the Nethack team- my brother's Dungeons and Dragons monster book
- found a regular place beside my dad's desk. it's nice to see him living
- on in the game he loved so much :-).
- Tamar Miller
-
- The following is a really long word of 5000 characters:
-
- wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
- EOS
-
- # prepare 'wc.input'
-
- def prepare_wc_input(wcbase)
- wcinput = File.join(File.dirname($0), 'wc.input')
- unless FileTest.exist?(wcinput)
- data = wcbase.dup
- 13.times{
- data << data
- }
- open(wcinput, 'w'){|f| f.write data}
- end
- end
-
- prepare_wc_input(wc_input_base)
-
-benchmark:
- so_count_words: |
- # $Id: wc-ruby.code,v 1.4 2004/11/13 07:43:32 bfulgham Exp $
- # http://www.bagley.org/~doug/shootout/
- # with help from Paul Brannan
- input = open(File.join(File.dirname($0), 'wc.input'), 'rb')
-
- nl = nw = nc = 0
- while true
- tmp = input.read(4096) or break
- data = tmp << (input.gets || "")
- nc += data.length
- nl += data.count("\n")
- ((data.strip! || data).tr!("\n", " ") || data).squeeze!
- nw += data.count(" ") + 1
- end
- # STDERR.puts "#{nl} #{nw} #{nc}"
-
-loop_count: 1
diff --git a/benchmark/so_exception.rb b/benchmark/so_exception.rb
deleted file mode 100644
index eb205b4df1..0000000000
--- a/benchmark/so_exception.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/ruby
-# -*- Ruby -*-
-# $Id: except-ruby.code,v 1.4 2004/11/13 07:41:33 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-
-$HI = 0
-$LO = 0
-NUM = 250000 # Integer(ARGV[0] || 1)
-
-
-class Lo_Exception < Exception
- def initialize(num)
- @value = num
- end
-end
-
-class Hi_Exception < Exception
- def initialize(num)
- @value = num
- end
-end
-
-def some_function(num)
- begin
- hi_function(num)
- rescue
- print "We shouldn't get here, exception is: #{$!.type}\n"
- end
-end
-
-def hi_function(num)
- begin
- lo_function(num)
- rescue Hi_Exception
- $HI = $HI + 1
- end
-end
-
-def lo_function(num)
- begin
- blowup(num)
- rescue Lo_Exception
- $LO = $LO + 1
- end
-end
-
-def blowup(num)
- if num % 2 == 0
- raise Lo_Exception.new(num)
- else
- raise Hi_Exception.new(num)
- end
-end
-
-
-i = 1
-max = NUM+1
-while i < max
- i += 1
- some_function(i+1)
-end
diff --git a/benchmark/so_k_nucleotide.yml b/benchmark/so_k_nucleotide.yml
deleted file mode 100644
index d7df086c39..0000000000
--- a/benchmark/so_k_nucleotide.yml
+++ /dev/null
@@ -1,155 +0,0 @@
-prelude: |
- bm_so_fasta = <<'EOS'
- # The Computer Language Shootout
- # http://shootout.alioth.debian.org/
- # Contributed by Sokolov Yura
-
- $last = 42.0
- def gen_random(max, im=139968, ia=3877, ic=29573)
- (max * ($last = ($last * ia + ic) % im)) / im
- end
-
- alu =
- "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+
- "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+
- "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+
- "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+
- "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+
- "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+
- "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
-
- iub = [
- ["a", 0.27],
- ["c", 0.12],
- ["g", 0.12],
- ["t", 0.27],
-
- ["B", 0.02],
- ["D", 0.02],
- ["H", 0.02],
- ["K", 0.02],
- ["M", 0.02],
- ["N", 0.02],
- ["R", 0.02],
- ["S", 0.02],
- ["V", 0.02],
- ["W", 0.02],
- ["Y", 0.02],
- ]
- homosapiens = [
- ["a", 0.3029549426680],
- ["c", 0.1979883004921],
- ["g", 0.1975473066391],
- ["t", 0.3015094502008],
- ]
-
- def make_repeat_fasta(id, desc, src, n)
- puts ">#{id} #{desc}"
- v = nil
- width = 60
- l = src.length
- s = src * ((n / l) + 1)
- s.slice!(n, l)
- puts(s.scan(/.{1,#{width}}/).join("\n"))
- end
-
- def make_random_fasta(id, desc, table, n)
- puts ">#{id} #{desc}"
- rand, v = nil,nil
- width = 60
- chunk = 1 * width
- prob = 0.0
- table.each{|v| v[1]= (prob += v[1])}
- for i in 1..(n/width)
- puts((1..width).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
- if n%width != 0
- puts((1..(n%width)).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
- end
-
-
- n = (ARGV[0] or 250_000).to_i
-
- make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2)
- make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3)
- make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5)
- EOS
-benchmark:
- - name: so_k_nucleotide
- prelude: |
- script = File.join(File.dirname($0), 'bm_so_fasta.rb')
- File.write(script, bm_so_fasta)
-
- def prepare_fasta_output n
- filebase = File.join(File.dirname($0), 'fasta.output')
- script = File.join(File.dirname($0), 'bm_so_fasta.rb')
- file = "#{filebase}.#{n}"
-
- unless FileTest.exist?(file)
- STDERR.puts "preparing #{file}"
-
- open(file, 'w'){|f|
- ARGV[0] = n
- $stdout = f
- load script
- $stdout = STDOUT
- }
- end
- end
- prepare_fasta_output(100_000)
- script: |
- # The Computer Language Shootout
- # http://shootout.alioth.debian.org
- #
- # contributed by jose fco. gonzalez
- # modified by Sokolov Yura
-
- seq = String.new
-
- def frecuency( seq,length )
- n, table = seq.length - length + 1, Hash.new(0)
- f, i = nil, nil
- (0 ... length).each do |f|
- (f ... n).step(length) do |i|
- table[seq[i,length]] += 1
- end
- end
- [n,table]
-
- end
-
- def sort_by_freq( seq,length )
- n,table = frecuency( seq,length )
- a, b, v = nil, nil, nil
- table.sort{|a,b| b[1] <=> a[1]}.each do |v|
- puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)]
- end
- puts
- end
-
- def find_seq( seq,s )
- n,table = frecuency( seq,s.length )
- puts "#{table[s].to_s}\t#{s.upcase}"
- end
-
- input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb')
-
- line = input.gets while line !~ /^>THREE/
- line = input.gets
-
- while (line !~ /^>/) & line do
- seq << line.chomp
- line = input.gets
- end
-
- [1,2].each {|i| sort_by_freq( seq,i ) }
-
- %w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) }
- loop_count: 1
diff --git a/benchmark/so_matrix.rb b/benchmark/so_matrix.rb
deleted file mode 100644
index 2d1e72bda9..0000000000
--- a/benchmark/so_matrix.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/ruby
-# -*- Ruby -*-
-# $Id: matrix-ruby.code,v 1.4 2004/11/13 07:42:14 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-
-n = 60 #Integer(ARGV.shift || 1)
-
-size = 40
-
-def mkmatrix(rows, cols)
- count = 1
- mx = Array.new(rows)
- (0 .. (rows - 1)).each do |bi|
- row = Array.new(cols, 0)
- (0 .. (cols - 1)).each do |j|
- row[j] = count
- count += 1
- end
- mx[bi] = row
- end
- mx
-end
-
-def mmult(rows, cols, m1, m2)
- m3 = Array.new(rows)
- (0 .. (rows - 1)).each do |bi|
- row = Array.new(cols, 0)
- (0 .. (cols - 1)).each do |j|
- val = 0
- (0 .. (cols - 1)).each do |k|
- val += m1.at(bi).at(k) * m2.at(k).at(j)
- end
- row[j] = val
- end
- m3[bi] = row
- end
- m3
-end
-
-m1 = mkmatrix(size, size)
-m2 = mkmatrix(size, size)
-mm = Array.new
-n.times do
- mm = mmult(size, size, m1, m2)
-end
-# puts "#{mm[0][0]} #{mm[2][3]} #{mm[3][2]} #{mm[4][4]}"
-
-
diff --git a/benchmark/so_nested_loop.rb b/benchmark/so_nested_loop.rb
deleted file mode 100644
index 766fcf7b84..0000000000
--- a/benchmark/so_nested_loop.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/ruby
-# -*- Ruby -*-
-# $Id: nestedloop-ruby.code,v 1.4 2004/11/13 07:42:22 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# from Avi Bryant
-
-n = 16 # Integer(ARGV.shift || 1)
-x = 0
-n.times do
- n.times do
- n.times do
- n.times do
- n.times do
- n.times do
- x += 1
- end
- end
- end
- end
- end
-end
-# puts x
-
-
diff --git a/benchmark/so_object.rb b/benchmark/so_object.rb
deleted file mode 100644
index 131f44624c..0000000000
--- a/benchmark/so_object.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/ruby
-# -*- Ruby -*-
-# $Id: objinst-ruby.code,v 1.4 2004/11/13 07:42:25 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# with help from Aristarkh Zagorodnikov
-
-class Toggle
- def initialize(start_state)
- @bool = start_state
- end
-
- def value
- @bool
- end
-
- def activate
- @bool = !@bool
- self
- end
-end
-
-class NthToggle < Toggle
- def initialize(start_state, max_counter)
- super start_state
- @count_max = max_counter
- @counter = 0
- end
-
- def activate
- @counter += 1
- if @counter >= @count_max
- @bool = !@bool
- @counter = 0
- end
- self
- end
-end
-
-n = 1500000 # (ARGV.shift || 1).to_i
-
-toggle = Toggle.new 1
-5.times do
- toggle.activate.value ? 'true' : 'false'
-end
-n.times do
- toggle = Toggle.new 1
-end
-
-ntoggle = NthToggle.new 1, 3
-8.times do
- ntoggle.activate.value ? 'true' : 'false'
-end
-n.times do
- ntoggle = NthToggle.new 1, 3
-end
-
diff --git a/benchmark/so_reverse_complement.yml b/benchmark/so_reverse_complement.yml
deleted file mode 100644
index de05eedfc4..0000000000
--- a/benchmark/so_reverse_complement.yml
+++ /dev/null
@@ -1,137 +0,0 @@
-prelude: |
- bm_so_fasta = <<'EOS'
- # The Computer Language Shootout
- # http://shootout.alioth.debian.org/
- # Contributed by Sokolov Yura
-
- $last = 42.0
- def gen_random(max, im=139968, ia=3877, ic=29573)
- (max * ($last = ($last * ia + ic) % im)) / im
- end
-
- alu =
- "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+
- "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+
- "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+
- "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+
- "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+
- "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+
- "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
-
- iub = [
- ["a", 0.27],
- ["c", 0.12],
- ["g", 0.12],
- ["t", 0.27],
-
- ["B", 0.02],
- ["D", 0.02],
- ["H", 0.02],
- ["K", 0.02],
- ["M", 0.02],
- ["N", 0.02],
- ["R", 0.02],
- ["S", 0.02],
- ["V", 0.02],
- ["W", 0.02],
- ["Y", 0.02],
- ]
- homosapiens = [
- ["a", 0.3029549426680],
- ["c", 0.1979883004921],
- ["g", 0.1975473066391],
- ["t", 0.3015094502008],
- ]
-
- def make_repeat_fasta(id, desc, src, n)
- puts ">#{id} #{desc}"
- v = nil
- width = 60
- l = src.length
- s = src * ((n / l) + 1)
- s.slice!(n, l)
- puts(s.scan(/.{1,#{width}}/).join("\n"))
- end
-
- def make_random_fasta(id, desc, table, n)
- puts ">#{id} #{desc}"
- rand, v = nil,nil
- width = 60
- chunk = 1 * width
- prob = 0.0
- table.each{|v| v[1]= (prob += v[1])}
- for i in 1..(n/width)
- puts((1..width).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
- if n%width != 0
- puts((1..(n%width)).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
- end
-
-
- n = (ARGV[0] or 250_000).to_i
-
- make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2)
- make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3)
- make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5)
- EOS
-benchmark:
- - name: so_reverse_complement
- prelude: |
- script = File.join(File.dirname($0), 'bm_so_fasta.rb')
- File.write(script, bm_so_fasta)
-
- def prepare_fasta_output n
- filebase = File.join(File.dirname($0), 'fasta.output')
- script = File.join(File.dirname($0), 'bm_so_fasta.rb')
- file = "#{filebase}.#{n}"
-
- unless FileTest.exist?(file)
- STDERR.puts "preparing #{file}"
-
- open(file, 'w'){|f|
- ARGV[0] = n
- $stdout = f
- load script
- $stdout = STDOUT
- }
- end
- end
- prepare_fasta_output(2_500_000)
- script: |
- # The Great Computer Language Shootout
- # http://shootout.alioth.debian.org/
- #
- # Contributed by Peter Bjarke Olsen
- # Modified by Doug King
-
- seq=Array.new
-
- def revcomp(seq)
- seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')
- stringlen=seq.length
- 0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"}
- end
-
- input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb')
-
- while input.gets
- if $_ =~ />/
- if seq.length != 0
- revcomp(seq.join)
- seq=Array.new
- end
- puts $_
- else
- $_.sub(/\n/,'')
- seq.push $_
- end
- end
- revcomp(seq.join)
- loop_count: 1
diff --git a/benchmark/string_capitalize.yml b/benchmark/string_capitalize.yml
deleted file mode 100644
index 7d23fd3d35..0000000000
--- a/benchmark/string_capitalize.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-prelude: |
- str1 = [*"a".."m",*"N".."Z",*"0".."9"].join("")
- str10 = str1 * 10
- str100 = str10 * 10
- str1000 = str100 * 10
-benchmark:
- capitalize-1: str1.capitalize
- capitalize-10: str10.capitalize
- capitalize-100: str100.capitalize
- capitalize-1000: str1000.capitalize
diff --git a/benchmark/string_downcase.yml b/benchmark/string_downcase.yml
deleted file mode 100644
index a31c3ac712..0000000000
--- a/benchmark/string_downcase.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-prelude: |
- str1 = [*"A".."Z",*"0".."9"].join("")
- str10 = str1 * 10
- str100 = str10 * 10
- str1000 = str100 * 10
-benchmark:
- downcase-1: str1.upcase
- downcase-10: str10.upcase
- downcase-100: str100.upcase
- downcase-1000: str1000.upcase
diff --git a/benchmark/string_split.yml b/benchmark/string_split.yml
deleted file mode 100644
index 84ffe8f6a7..0000000000
--- a/benchmark/string_split.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- str0 = [*0..9].join("")
-benchmark:
- to_chars-1: str0.split('')
- to_chars-10: (str0 * 10).split('')
- to_chars-100: (str0 * 100).split('')
- to_chars-1000: (str0 * 1000).split('')
diff --git a/benchmark/string_swapcase.yml b/benchmark/string_swapcase.yml
deleted file mode 100644
index afaae3f696..0000000000
--- a/benchmark/string_swapcase.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-prelude: |
- str1 = [*"A".."M",*"n".."z",*"0".."9"].join("")
- str10 = str1 * 10
- str100 = str10 * 10
- str1000 = str100 * 10
-benchmark:
- swapcase-1: str1.swapcase
- swapcase-10: str10.swapcase
- swapcase-100: str100.swapcase
- swapcase-1000: str1000.swapcase
diff --git a/benchmark/string_upcase.yml b/benchmark/string_upcase.yml
deleted file mode 100644
index 456d213c74..0000000000
--- a/benchmark/string_upcase.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-prelude: |
- str1 = [*"a".."z",*"0".."9"].join("")
- str10 = str1 * 10
- str100 = str10 * 10
- str1000 = str100 * 10
-benchmark:
- upcase-1: str1.upcase
- upcase-10: str10.upcase
- upcase-100: str100.upcase
- upcase-1000: str1000.upcase
diff --git a/benchmark/time_strptime.yml b/benchmark/time_strptime.yml
deleted file mode 100644
index 8d89ebb7a7..0000000000
--- a/benchmark/time_strptime.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-prelude: |
- require 'time'
-benchmark:
- - Time.strptime("28/Aug/2005:06:54:20 +0000", "%d/%b/%Y:%T %z")
- - Time.strptime("1", "%s")
- - Time.strptime("0 +0100", "%s %z")
- - Time.strptime("0 UTC", "%s %z")
- - Time.strptime("1.5", "%s.%N")
- - Time.strptime("1.000000000001", "%s.%N")
- - Time.strptime("20010203 -0200", "%Y%m%d %z")
- - Time.strptime("20010203 UTC", "%Y%m%d %z")
- - Time.strptime("2018-365", "%Y-%j")
- - Time.strptime("2018-091", "%Y-%j")
diff --git a/benchmark/vm1_attr_ivar.yml b/benchmark/vm1_attr_ivar.yml
deleted file mode 100644
index f714dd9bd9..0000000000
--- a/benchmark/vm1_attr_ivar.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-prelude: |
- class C
- attr_reader :a, :b
- def initialize
- @a = nil
- @b = nil
- end
- end
- obj = C.new
-benchmark:
- vm1_attr_ivar: |
- j = obj.a
- k = obj.b
-loop_count: 30000000
diff --git a/benchmark/vm1_attr_ivar_set.yml b/benchmark/vm1_attr_ivar_set.yml
deleted file mode 100644
index f383e59ef4..0000000000
--- a/benchmark/vm1_attr_ivar_set.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-prelude: |
- class C
- attr_accessor :a, :b
- def initialize
- @a = nil
- @b = nil
- end
- end
- obj = C.new
-benchmark:
- vm1_attr_ivar_set: |
- obj.a = 1
- obj.b = 2
-loop_count: 30000000
diff --git a/benchmark/vm1_block.yml b/benchmark/vm1_block.yml
deleted file mode 100644
index ac7c940f93..0000000000
--- a/benchmark/vm1_block.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-prelude: |
- def m
- yield
- end
-benchmark:
- vm1_block: |
- m{
- }
-loop_count: 30000000
diff --git a/benchmark/vm1_blockparam.yml b/benchmark/vm1_blockparam.yml
deleted file mode 100644
index 947b8c53d5..0000000000
--- a/benchmark/vm1_blockparam.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- def m &b
- end
-benchmark:
- vm1_blockparam: |
- m{}
-loop_count: 30000000
diff --git a/benchmark/vm1_blockparam_call.yml b/benchmark/vm1_blockparam_call.yml
deleted file mode 100644
index e2817a3ce2..0000000000
--- a/benchmark/vm1_blockparam_call.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- def m &b
- b.call
- end
-benchmark:
- vm1_blockparam_call: |
- m{}
-loop_count: 30000000
diff --git a/benchmark/vm1_blockparam_pass.yml b/benchmark/vm1_blockparam_pass.yml
deleted file mode 100644
index ca1bef3369..0000000000
--- a/benchmark/vm1_blockparam_pass.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-prelude: |
- def bp_yield
- yield
- end
-
- def bp_pass &b
- bp_yield &b
- end
-benchmark:
- vm1_blockparam_pass: |
- bp_pass{}
-loop_count: 30000000
diff --git a/benchmark/vm1_blockparam_yield.yml b/benchmark/vm1_blockparam_yield.yml
deleted file mode 100644
index 56ae617798..0000000000
--- a/benchmark/vm1_blockparam_yield.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- def bp_yield &b
- yield
- end
-benchmark:
- vm1_blockparam_yield: |
- bp_yield{}
-loop_count: 30000000
diff --git a/benchmark/vm1_const.yml b/benchmark/vm1_const.yml
deleted file mode 100644
index b98db1545c..0000000000
--- a/benchmark/vm1_const.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- Const = 1
-benchmark:
- vm1_const: |
- j = Const
- k = Const
-loop_count: 30000000
diff --git a/benchmark/vm1_ensure.yml b/benchmark/vm1_ensure.yml
deleted file mode 100644
index afbbe38bec..0000000000
--- a/benchmark/vm1_ensure.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Not utilizing loop_count since using it for this is too unstable for now
-benchmark:
- vm1_ensure: |
- i = 0
- while i<30_000_000
- i += 1
- begin
- begin
- ensure
- end
- ensure
- end
- end
-loop_count: 1
diff --git a/benchmark/vm1_float_simple.yml b/benchmark/vm1_float_simple.yml
deleted file mode 100644
index 4e9ad1852b..0000000000
--- a/benchmark/vm1_float_simple.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- f = 0.0
-benchmark:
- vm1_float_simple: |
- f += 0.1; f -= 0.1
- f += 0.1; f -= 0.1
- f += 0.1; f -= 0.1
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_short_lived.yml b/benchmark/vm1_gc_short_lived.yml
deleted file mode 100644
index 8fdcb7371d..0000000000
--- a/benchmark/vm1_gc_short_lived.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-benchmark:
- vm1_gc_short_lived: |
- a = '' # short-lived String
- b = ''
- c = ''
- d = ''
- e = ''
- f = ''
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_short_with_complex_long.yml b/benchmark/vm1_gc_short_with_complex_long.yml
deleted file mode 100644
index c22ea74a60..0000000000
--- a/benchmark/vm1_gc_short_with_complex_long.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-prelude: |
- def nested_hash h, n
- if n == 0
- ''
- else
- 10.times{
- h[Object.new] = nested_hash(h, n-1)
- }
- end
- end
-
- long_lived = Hash.new
- nested_hash long_lived, 6
-
- GC.start
- GC.start
-benchmark:
- vm1_gc_short_with_complex_long: |
- a = '' # short-lived String
- b = ''
- c = ''
- d = ''
- e = ''
- f = ''
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_short_with_long.yml b/benchmark/vm1_gc_short_with_long.yml
deleted file mode 100644
index c731aae548..0000000000
--- a/benchmark/vm1_gc_short_with_long.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-prelude: |
- long_lived = Array.new(1_000_000){|i| "#{i}"}
- GC.start
- GC.start
-benchmark:
- vm1_gc_short_with_long: |
- a = '' # short-lived String
- b = ''
- c = ''
- d = ''
- e = ''
- f = ''
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_short_with_symbol.yml b/benchmark/vm1_gc_short_with_symbol.yml
deleted file mode 100644
index 7fc1abedd8..0000000000
--- a/benchmark/vm1_gc_short_with_symbol.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-prelude: |
- 50_000.times{|i| sym = "sym#{i}".to_sym}
- GC.start
- GC.start
-benchmark:
- vm1_gc_short_with_symbol: |
- a = '' # short-lived String
- b = ''
- c = ''
- d = ''
- e = ''
- f = ''
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_wb_ary.yml b/benchmark/vm1_gc_wb_ary.yml
deleted file mode 100644
index 50fb4b6f84..0000000000
--- a/benchmark/vm1_gc_wb_ary.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-prelude: |
- short_lived_ary = []
-
- if RUBY_VERSION >= "2.2.0"
- GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
- end
-
- short_lived = ''
-benchmark:
- vm1_gc_wb_ary: |
- short_lived_ary[0] = short_lived # write barrier
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_wb_ary_promoted.yml b/benchmark/vm1_gc_wb_ary_promoted.yml
deleted file mode 100644
index cf9b5de005..0000000000
--- a/benchmark/vm1_gc_wb_ary_promoted.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-prelude: |
- long_lived = []
-
- if RUBY_VERSION > "2.2.0"
- 3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
- elsif
- GC.start
- end
-
- short_lived = ''
-
-benchmark:
- vm1_gc_wb_ary_promoted: |
- long_lived[0] = short_lived # write barrier
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_wb_obj.yml b/benchmark/vm1_gc_wb_obj.yml
deleted file mode 100644
index 9dc08e7e1a..0000000000
--- a/benchmark/vm1_gc_wb_obj.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-prelude: |
- class C
- attr_accessor :foo
- end
- short_lived_obj = C.new
-
- if RUBY_VERSION >= "2.2.0"
- GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
- end
-
- short_lived = ''
-benchmark:
- vm1_gc_wb_obj: |
- short_lived_obj.foo = short_lived # write barrier
-loop_count: 30000000
diff --git a/benchmark/vm1_gc_wb_obj_promoted.yml b/benchmark/vm1_gc_wb_obj_promoted.yml
deleted file mode 100644
index 26859d2a52..0000000000
--- a/benchmark/vm1_gc_wb_obj_promoted.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-prelude: |
- class C
- attr_accessor :foo
- end
- long_lived = C.new
-
- if RUBY_VERSION >= "2.2.0"
- 3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
- elsif
- GC.start
- end
-
- short_lived = ''
-benchmark:
- vm1_gc_wb_obj_promoted: |
- long_lived.foo = short_lived # write barrier
-loop_count: 30000000
diff --git a/benchmark/vm1_ivar.yml b/benchmark/vm1_ivar.yml
deleted file mode 100644
index 7aa6fac729..0000000000
--- a/benchmark/vm1_ivar.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-prelude: "@a = 1\n"
-benchmark:
- vm1_ivar: |
- j = @a
- k = @a
-loop_count: 30000000
diff --git a/benchmark/vm1_ivar_set.yml b/benchmark/vm1_ivar_set.yml
deleted file mode 100644
index 6f19412d16..0000000000
--- a/benchmark/vm1_ivar_set.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-benchmark:
- vm1_ivar_set: |
- @a = 1
- @b = 2
-loop_count: 30000000
diff --git a/benchmark/vm1_length.yml b/benchmark/vm1_length.yml
deleted file mode 100644
index a18e2ca2e6..0000000000
--- a/benchmark/vm1_length.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- a = 'abc'
- b = [1, 2, 3]
-benchmark:
- vm1_length: |
- a.length
- b.length
-loop_count: 30000000
diff --git a/benchmark/vm1_lvar_init.yml b/benchmark/vm1_lvar_init.yml
deleted file mode 100644
index 10e2becef9..0000000000
--- a/benchmark/vm1_lvar_init.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-# while loop cost is not removed because `i` is used in the script
-benchmark:
- vm1_lvar_init: |
- def m v
- unless v
- # unreachable code
- v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = v9 = v10 =
- v11 = v12 = v13 = v14 = v15 = v16 = v17 = v18 = v19 = v20 =
- v21 = v22 = v23 = v24 = v25 = v26 = v27 = v28 = v29 = v30 =
- v31 = v32 = v33 = v34 = v35 = v36 = v37 = v38 = v39 = v40 =
- v41 = v42 = v43 = v44 = v45 = v46 = v47 = v48 = v49 = v50 = 1
- end
- end
-
- i = 0
-
- while i<30_000_000
- i += 1
- m i
- end
-loop_count: 1
diff --git a/benchmark/vm1_lvar_set.yml b/benchmark/vm1_lvar_set.yml
deleted file mode 100644
index df8f6b6ea4..0000000000
--- a/benchmark/vm1_lvar_set.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm1_lvar_set: |
- a = b = c = d = e = f = g = h = j = k = l = m = n = o = p = q = r = 1
-loop_count: 30000000
diff --git a/benchmark/vm1_neq.yml b/benchmark/vm1_neq.yml
deleted file mode 100644
index 65a8128dda..0000000000
--- a/benchmark/vm1_neq.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- obj1 = Object.new
- obj2 = Object.new
-benchmark:
- vm1_neq: |
- obj1 != obj2
-loop_count: 30000000
diff --git a/benchmark/vm1_not.yml b/benchmark/vm1_not.yml
deleted file mode 100644
index 0fb7b282a9..0000000000
--- a/benchmark/vm1_not.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-prelude: |
- obj = Object.new
-benchmark:
- vm1_not: |
- !obj
-loop_count: 30000000
diff --git a/benchmark/vm1_rescue.yml b/benchmark/vm1_rescue.yml
deleted file mode 100644
index a175b823af..0000000000
--- a/benchmark/vm1_rescue.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-benchmark:
- vm1_rescue: |
- begin
- rescue
- end
-loop_count: 30000000
diff --git a/benchmark/vm1_simplereturn.yml b/benchmark/vm1_simplereturn.yml
deleted file mode 100644
index 3564aac7e2..0000000000
--- a/benchmark/vm1_simplereturn.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- def m
- return 1
- end
-benchmark:
- vm1_simplereturn: m
-loop_count: 30000000
diff --git a/benchmark/vm1_swap.yml b/benchmark/vm1_swap.yml
deleted file mode 100644
index fed87ccd62..0000000000
--- a/benchmark/vm1_swap.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- a = 1
- b = 2
-benchmark:
- vm1_swap: |
- a, b = b, a
-loop_count: 30000000
diff --git a/benchmark/vm1_yield.yml b/benchmark/vm1_yield.yml
deleted file mode 100644
index ae1f9316f9..0000000000
--- a/benchmark/vm1_yield.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-# while loop cost is not removed due to benchmark_driver.gem's limitation
-benchmark:
- vm1_yield: |
- def m
- i = 0
- while i<30_000_000
- i += 1
- yield
- end
- end
-
- m{}
-loop_count: 1
diff --git a/benchmark/vm2_array.yml b/benchmark/vm2_array.yml
deleted file mode 100644
index 7373098d5e..0000000000
--- a/benchmark/vm2_array.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm2_array: |
- a = [1,2,3,4,5,6,7,8,9,10]
-loop_count: 6000000
diff --git a/benchmark/vm2_bigarray.yml b/benchmark/vm2_bigarray.yml
deleted file mode 100644
index 2ad6da3905..0000000000
--- a/benchmark/vm2_bigarray.yml
+++ /dev/null
@@ -1,105 +0,0 @@
-benchmark:
- vm2_bigarray: |
- a = [
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- 1,2,3,4,5,6,7,8,9,10,
- ]
-loop_count: 6000000
diff --git a/benchmark/vm2_bighash.yml b/benchmark/vm2_bighash.yml
deleted file mode 100644
index e9154e4ba9..0000000000
--- a/benchmark/vm2_bighash.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm2_bighash: |
- a = {0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9, 10=>10, 11=>11, 12=>12, 13=>13, 14=>14, 15=>15, 16=>16, 17=>17, 18=>18, 19=>19, 20=>20, 21=>21, 22=>22, 23=>23, 24=>24, 25=>25, 26=>26, 27=>27, 28=>28, 29=>29, 30=>30, 31=>31, 32=>32, 33=>33, 34=>34, 35=>35, 36=>36, 37=>37, 38=>38, 39=>39, 40=>40, 41=>41, 42=>42, 43=>43, 44=>44, 45=>45, 46=>46, 47=>47, 48=>48, 49=>49, 50=>50, 51=>51, 52=>52, 53=>53, 54=>54, 55=>55, 56=>56, 57=>57, 58=>58, 59=>59, 60=>60, 61=>61, 62=>62, 63=>63, 64=>64, 65=>65, 66=>66, 67=>67, 68=>68, 69=>69, 70=>70, 71=>71, 72=>72, 73=>73, 74=>74, 75=>75, 76=>76, 77=>77, 78=>78, 79=>79, 80=>80, 81=>81, 82=>82, 83=>83, 84=>84, 85=>85, 86=>86, 87=>87, 88=>88, 89=>89, 90=>90, 91=>91, 92=>92, 93=>93, 94=>94, 95=>95, 96=>96, 97=>97, 98=>98, 99=>99, 100=>100, 101=>101, 102=>102, 103=>103, 104=>104, 105=>105, 106=>106, 107=>107, 108=>108, 109=>109, 110=>110, 111=>111, 112=>112, 113=>113, 114=>114, 115=>115, 116=>116, 117=>117, 118=>118, 119=>119, 120=>120, 121=>121, 122=>122, 123=>123, 124=>124, 125=>125, 126=>126, 127=>127, 128=>128, 129=>129, 130=>130, 131=>131, 132=>132, 133=>133, 134=>134, 135=>135, 136=>136, 137=>137, 138=>138, 139=>139, 140=>140, 141=>141, 142=>142, 143=>143, 144=>144, 145=>145, 146=>146, 147=>147, 148=>148, 149=>149, 150=>150, 151=>151, 152=>152, 153=>153, 154=>154, 155=>155, 156=>156, 157=>157, 158=>158, 159=>159, 160=>160, 161=>161, 162=>162, 163=>163, 164=>164, 165=>165, 166=>166, 167=>167, 168=>168, 169=>169, 170=>170, 171=>171, 172=>172, 173=>173, 174=>174, 175=>175, 176=>176, 177=>177, 178=>178, 179=>179, 180=>180, 181=>181, 182=>182, 183=>183, 184=>184, 185=>185, 186=>186, 187=>187, 188=>188, 189=>189, 190=>190, 191=>191, 192=>192, 193=>193, 194=>194, 195=>195, 196=>196, 197=>197, 198=>198, 199=>199, 200=>200, 201=>201, 202=>202, 203=>203, 204=>204, 205=>205, 206=>206, 207=>207, 208=>208, 209=>209, 210=>210, 211=>211, 212=>212, 213=>213, 214=>214, 215=>215, 216=>216, 217=>217, 218=>218, 219=>219, 220=>220, 221=>221, 222=>222, 223=>223, 224=>224, 225=>225, 226=>226, 227=>227, 228=>228, 229=>229, 230=>230, 231=>231, 232=>232, 233=>233, 234=>234, 235=>235, 236=>236, 237=>237, 238=>238, 239=>239, 240=>240, 241=>241, 242=>242, 243=>243, 244=>244, 245=>245, 246=>246, 247=>247, 248=>248, 249=>249, 250=>250, 251=>251, 252=>252, 253=>253, 254=>254, 255=>255, 256=>256, 257=>257, 258=>258, 259=>259, 260=>260, 261=>261, 262=>262, 263=>263, 264=>264, 265=>265, 266=>266, 267=>267, 268=>268, 269=>269, 270=>270, 271=>271, 272=>272, 273=>273, 274=>274, 275=>275, 276=>276, 277=>277, 278=>278, 279=>279, 280=>280, 281=>281, 282=>282, 283=>283, 284=>284, 285=>285, 286=>286, 287=>287, 288=>288, 289=>289, 290=>290, 291=>291, 292=>292, 293=>293, 294=>294, 295=>295, 296=>296, 297=>297, 298=>298, 299=>299, 300=>300, 301=>301, 302=>302, 303=>303, 304=>304, 305=>305, 306=>306, 307=>307, 308=>308, 309=>309, 310=>310, 311=>311, 312=>312, 313=>313, 314=>314, 315=>315, 316=>316, 317=>317, 318=>318, 319=>319, 320=>320, 321=>321, 322=>322, 323=>323, 324=>324, 325=>325, 326=>326, 327=>327, 328=>328, 329=>329, 330=>330, 331=>331, 332=>332, 333=>333, 334=>334, 335=>335, 336=>336, 337=>337, 338=>338, 339=>339, 340=>340, 341=>341, 342=>342, 343=>343, 344=>344, 345=>345, 346=>346, 347=>347, 348=>348, 349=>349, 350=>350, 351=>351, 352=>352, 353=>353, 354=>354, 355=>355, 356=>356, 357=>357, 358=>358, 359=>359, 360=>360, 361=>361, 362=>362, 363=>363, 364=>364, 365=>365, 366=>366, 367=>367, 368=>368, 369=>369, 370=>370, 371=>371, 372=>372, 373=>373, 374=>374, 375=>375, 376=>376, 377=>377, 378=>378, 379=>379, 380=>380, 381=>381, 382=>382, 383=>383, 384=>384, 385=>385, 386=>386, 387=>387, 388=>388, 389=>389, 390=>390, 391=>391, 392=>392, 393=>393, 394=>394, 395=>395, 396=>396, 397=>397, 398=>398, 399=>399, 400=>400, 401=>401, 402=>402, 403=>403, 404=>404, 405=>405, 406=>406, 407=>407, 408=>408, 409=>409, 410=>410, 411=>411, 412=>412, 413=>413, 414=>414, 415=>415, 416=>416, 417=>417, 418=>418, 419=>419, 420=>420, 421=>421, 422=>422, 423=>423, 424=>424, 425=>425, 426=>426, 427=>427, 428=>428, 429=>429, 430=>430, 431=>431, 432=>432, 433=>433, 434=>434, 435=>435, 436=>436, 437=>437, 438=>438, 439=>439, 440=>440, 441=>441, 442=>442, 443=>443, 444=>444, 445=>445, 446=>446, 447=>447, 448=>448, 449=>449, 450=>450, 451=>451, 452=>452, 453=>453, 454=>454, 455=>455, 456=>456, 457=>457, 458=>458, 459=>459, 460=>460, 461=>461, 462=>462, 463=>463, 464=>464, 465=>465, 466=>466, 467=>467, 468=>468, 469=>469, 470=>470, 471=>471, 472=>472, 473=>473, 474=>474, 475=>475, 476=>476, 477=>477, 478=>478, 479=>479, 480=>480, 481=>481, 482=>482, 483=>483, 484=>484, 485=>485, 486=>486, 487=>487, 488=>488, 489=>489, 490=>490, 491=>491, 492=>492, 493=>493, 494=>494, 495=>495, 496=>496, 497=>497, 498=>498, 499=>499, 500=>500,}
-loop_count: 60000
diff --git a/benchmark/vm2_case.yml b/benchmark/vm2_case.yml
deleted file mode 100644
index 7716783c09..0000000000
--- a/benchmark/vm2_case.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-benchmark:
- vm2_case: |
- case :foo
- when :bar
- raise
- when :baz
- raise
- when :boo
- raise
- when :foo
- # noop
- end
-loop_count: 6000000
diff --git a/benchmark/vm2_case_lit.yml b/benchmark/vm2_case_lit.yml
deleted file mode 100644
index c49b8dfe5e..0000000000
--- a/benchmark/vm2_case_lit.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-# loop_count is not utilized since `i` is involved in the script
-benchmark:
- vm2_case_lit: |
- i = 0
- @ret = [ "foo", true, false, :sym, 6, nil, 0.1, 0xffffffffffffffff ]
- def foo(i)
- @ret[i % @ret.size]
- end
-
- while i<6_000_000
- case foo(i)
- when "foo" then :foo
- when true then true
- when false then false
- when :sym then :sym
- when 6 then :fix
- when nil then nil
- when 0.1 then :float
- when 0xffffffffffffffff then :big
- end
- i += 1
- end
-loop_count: 1
diff --git a/benchmark/vm2_defined_method.yml b/benchmark/vm2_defined_method.yml
deleted file mode 100644
index e1b0d55674..0000000000
--- a/benchmark/vm2_defined_method.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- class Object
- define_method(:m){}
- end
-benchmark:
- vm2_defined_method: |
- m; m; m; m; m; m; m; m;
-loop_count: 6000000
diff --git a/benchmark/vm2_dstr.yml b/benchmark/vm2_dstr.yml
deleted file mode 100644
index f8bd6e0133..0000000000
--- a/benchmark/vm2_dstr.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-prelude: |
- x = y = 'z'
-benchmark:
- vm2_dstr: |
- str = "foo#{x}bar#{y}baz"
-loop_count: 6000000
diff --git a/benchmark/vm2_eval.yml b/benchmark/vm2_eval.yml
deleted file mode 100644
index d506a9c079..0000000000
--- a/benchmark/vm2_eval.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm2_eval: |
- eval("1")
-loop_count: 6000000
diff --git a/benchmark/vm2_fiber_allocate.yml b/benchmark/vm2_fiber_allocate.yml
deleted file mode 100644
index f29705f694..0000000000
--- a/benchmark/vm2_fiber_allocate.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- # Disable GC to see raw throughput:
- GC.disable
-benchmark:
- vm2_fiber_allocate: |
- fiber = Fiber.new{Fiber.yield}
- fiber.resume
-loop_count: 100000
diff --git a/benchmark/vm2_fiber_count.yml b/benchmark/vm2_fiber_count.yml
deleted file mode 100644
index 3ecf6bdcb2..0000000000
--- a/benchmark/vm2_fiber_count.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# On Linux, you will need to increase the maximum number of memory maps:
-# sudo sysctl -w vm.max_map_count=200000
-prelude: |
- fibers = []
-benchmark:
- vm2_fiber_count: |
- fiber = Fiber.new{Fiber.yield}
- fibers << fiber
- fiber.resume
-loop_count: 100000
diff --git a/benchmark/vm2_fiber_reuse.yml b/benchmark/vm2_fiber_reuse.yml
deleted file mode 100644
index 0170650638..0000000000
--- a/benchmark/vm2_fiber_reuse.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-prelude: |
- GC.disable
- fibers = []
-benchmark:
- vm2_fiber_reuse: |
- 1024.times do
- fiber = Fiber.new{Fiber.yield}
- fibers << fiber
- fiber.resume
- end
-
- fibers.clear
- GC.start
-loop_count: 200
diff --git a/benchmark/vm2_fiber_reuse_gc.yml b/benchmark/vm2_fiber_reuse_gc.yml
deleted file mode 100644
index 8fb91a84eb..0000000000
--- a/benchmark/vm2_fiber_reuse_gc.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-# https://bugs.ruby-lang.org/issues/16009
-prelude: |
- fibers = []
-benchmark:
- vm2_fiber_reuse_gc: |
- 2000.times do
- fiber = Fiber.new{Fiber.yield}
- fibers << fiber
- fiber.resume
- end
- fibers.clear
-loop_count: 100
diff --git a/benchmark/vm2_fiber_switch.yml b/benchmark/vm2_fiber_switch.yml
deleted file mode 100644
index fbf7283c29..0000000000
--- a/benchmark/vm2_fiber_switch.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-prelude: |
- # based on benchmark for [ruby-core:65518] [Feature #10341] by Knut Franke
- fib = Fiber.new do
- loop { Fiber.yield }
- end
-benchmark:
- vm2_fiber_switch: |
- fib.resume
-loop_count: 20000000
diff --git a/benchmark/vm2_freezestring.yml b/benchmark/vm2_freezestring.yml
deleted file mode 100644
index b78af91a20..0000000000
--- a/benchmark/vm2_freezestring.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-prelude: |
- class String
- def freeze
- -self
- end
- end
-benchmark:
- vm2_freezestring: |
- "tXnL1BP5T1WPXMjuFNLQtallEtRcay1t2lHtJSrlVsDgvunlbtfpr/DGdH0NGYE9".freeze
-loop_count: 6000000
diff --git a/benchmark/vm2_method.yml b/benchmark/vm2_method.yml
deleted file mode 100644
index cc7b9b28ff..0000000000
--- a/benchmark/vm2_method.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- def m
- nil
- end
-benchmark:
- vm2_method: |
- m; m; m; m; m; m; m; m;
-loop_count: 6000000
diff --git a/benchmark/vm2_method_missing.yml b/benchmark/vm2_method_missing.yml
deleted file mode 100644
index cbfb794b25..0000000000
--- a/benchmark/vm2_method_missing.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-prelude: |
- class C
- def method_missing mid
- end
- end
-
- obj = C.new
-benchmark:
- vm2_method_missing: |
- obj.m; obj.m; obj.m; obj.m; obj.m; obj.m; obj.m; obj.m;
-loop_count: 6000000
diff --git a/benchmark/vm2_method_with_block.yml b/benchmark/vm2_method_with_block.yml
deleted file mode 100644
index 6e522adccc..0000000000
--- a/benchmark/vm2_method_with_block.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- def m
- nil
- end
-benchmark:
- vm2_method_with_block: |
- m{}; m{}; m{}; m{}; m{}; m{}; m{}; m{};
-loop_count: 6000000
diff --git a/benchmark/vm2_module_ann_const_set.yml b/benchmark/vm2_module_ann_const_set.yml
deleted file mode 100644
index b0becd9d3d..0000000000
--- a/benchmark/vm2_module_ann_const_set.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm2_module_ann_const_set: |
- Module.new.const_set(:X, Module.new)
-loop_count: 6000000
diff --git a/benchmark/vm2_module_const_set.yml b/benchmark/vm2_module_const_set.yml
deleted file mode 100644
index 05a640069c..0000000000
--- a/benchmark/vm2_module_const_set.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- module M
- end
- $VERBOSE = nil
-benchmark:
- vm2_module_const_set: |
- M.const_set(:X, Module.new)
-loop_count: 6000000
diff --git a/benchmark/vm2_mutex.yml b/benchmark/vm2_mutex.yml
deleted file mode 100644
index c40a90444a..0000000000
--- a/benchmark/vm2_mutex.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- require 'thread'
-
- m = Thread::Mutex.new
-benchmark:
- vm2_mutex: |
- m.synchronize{}
-loop_count: 6000000
diff --git a/benchmark/vm2_newlambda.yml b/benchmark/vm2_newlambda.yml
deleted file mode 100644
index 93133f9f30..0000000000
--- a/benchmark/vm2_newlambda.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm2_newlambda: |
- lambda {}
-loop_count: 6000000
diff --git a/benchmark/vm2_poly_method.yml b/benchmark/vm2_poly_method.yml
deleted file mode 100644
index 0104bdfb66..0000000000
--- a/benchmark/vm2_poly_method.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-# loop_count is not utilized since `i` is involved in the script
-benchmark:
- vm2_poly_method: |
- class C1
- def m
- 1
- end
- end
- class C2
- def m
- 2
- end
- end
-
- o1 = C1.new
- o2 = C2.new
-
- i = 0
- while i<6_000_000
- o = (i % 2 == 0) ? o1 : o2
- o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
- i += 1
- end
-loop_count: 1
diff --git a/benchmark/vm2_poly_method_ov.yml b/benchmark/vm2_poly_method_ov.yml
deleted file mode 100644
index 3748073ba2..0000000000
--- a/benchmark/vm2_poly_method_ov.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-# loop_count is not utilized since `i` is involved in the script
-benchmark:
- vm2_poly_method_ov: |
- class C1
- def m
- 1
- end
- end
- class C2
- def m
- 2
- end
- end
-
- o1 = C1.new
- o2 = C2.new
-
- i = 0
- while i<6_000_000
- o = (i % 2 == 0) ? o1 : o2
- # o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
- i += 1
- end
-loop_count: 1
diff --git a/benchmark/vm2_poly_same_method.yml b/benchmark/vm2_poly_same_method.yml
deleted file mode 100644
index 867c433cf8..0000000000
--- a/benchmark/vm2_poly_same_method.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-prelude: |
- module AR; end
- class AR::Base
- def create_or_update
- nil
- end
- def save
- create_or_update
- end
- end
- class Foo < AR::Base; end
- class Bar < AR::Base; end
- o1 = Foo.new
- o2 = Bar.new
-benchmark:
- vm2_poly_same_method: |
- o1.save; o2.save;
- o1.save; o2.save;
- o1.save; o2.save;
- o1.save; o2.save;
- o1.save; o2.save;
- o1.save; o2.save;
- o1.save; o2.save;
- o1.save; o2.save;
-loop_count: 6000000
diff --git a/benchmark/vm2_poly_singleton.yml b/benchmark/vm2_poly_singleton.yml
deleted file mode 100644
index e58d7bfb37..0000000000
--- a/benchmark/vm2_poly_singleton.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-# loop_count is not utilized since `i` is involved in the script
-benchmark:
- vm2_poly_singleton: |
- class C1
- def m; 1; end
- end
-
- o1 = C1.new
- o2 = C1.new
- o2.singleton_class
-
- i = 0
- while i<6_000_000 # benchmark loop 2
- o = (i % 2 == 0) ? o1 : o2
- o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
- i += 1
- end
-loop_count: 1
diff --git a/benchmark/vm2_proc.yml b/benchmark/vm2_proc.yml
deleted file mode 100644
index 5c36e936d9..0000000000
--- a/benchmark/vm2_proc.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-prelude: |
- def m &b
- b
- end
-
- pr = m{
- a = 1
- }
-benchmark:
- vm2_proc: |
- pr.call
-loop_count: 6000000
diff --git a/benchmark/vm2_raise1.yml b/benchmark/vm2_raise1.yml
deleted file mode 100644
index f6eb308968..0000000000
--- a/benchmark/vm2_raise1.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-prelude: |
- def rec n
- if n > 0
- rec n-1
- else
- raise
- end
- end
-benchmark:
- vm2_raise1: |
- begin
- rec 1
- rescue
- # ignore
- end
-loop_count: 6000000
diff --git a/benchmark/vm2_raise2.yml b/benchmark/vm2_raise2.yml
deleted file mode 100644
index 7d51b1b314..0000000000
--- a/benchmark/vm2_raise2.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-prelude: |
- def rec n
- if n > 0
- rec n-1
- else
- raise
- end
- end
-benchmark:
- vm2_raise2: |
- begin
- rec 10
- rescue
- # ignore
- end
-loop_count: 6000000
diff --git a/benchmark/vm2_regexp.yml b/benchmark/vm2_regexp.yml
deleted file mode 100644
index e53341f43b..0000000000
--- a/benchmark/vm2_regexp.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-prelude: |
- str = 'xxxhogexxx'
-benchmark:
- vm2_regexp: |
- /hoge/ =~ str
- vm2_regexp_invert: |
- str =~ /hoge/
-loop_count: 6000000
diff --git a/benchmark/vm2_send.yml b/benchmark/vm2_send.yml
deleted file mode 100644
index 44a12a27d9..0000000000
--- a/benchmark/vm2_send.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-prelude: |
- class C
- def m
- end
- end
-
- o = C.new
-benchmark:
- vm2_send: |
- o.__send__ :m
-loop_count: 6000000
diff --git a/benchmark/vm2_string_literal.yml b/benchmark/vm2_string_literal.yml
deleted file mode 100644
index 54b0aec1fe..0000000000
--- a/benchmark/vm2_string_literal.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm2_string_literal: |
- x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-loop_count: 6000000
diff --git a/benchmark/vm2_struct_big_aref_hi.yml b/benchmark/vm2_struct_big_aref_hi.yml
deleted file mode 100644
index eed1846d28..0000000000
--- a/benchmark/vm2_struct_big_aref_hi.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- s = Struct.new(*('a'..'z').map { |x| x.to_sym })
- x = s.new
-benchmark:
- vm2_struct_big_aref_hi: |
- x.z # x[25]
-loop_count: 6000000
diff --git a/benchmark/vm2_struct_big_aref_lo.yml b/benchmark/vm2_struct_big_aref_lo.yml
deleted file mode 100644
index 0915435b76..0000000000
--- a/benchmark/vm2_struct_big_aref_lo.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- s = Struct.new(*('a'..'z').map { |x| x.to_sym })
- x = s.new
-benchmark:
- vm2_struct_big_aref_lo: |
- x.k # x[10]
-loop_count: 6000000
diff --git a/benchmark/vm2_struct_big_aset.yml b/benchmark/vm2_struct_big_aset.yml
deleted file mode 100644
index 6af50103d3..0000000000
--- a/benchmark/vm2_struct_big_aset.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-# loop_count is not utilized since `i` is involved in the script
-benchmark:
- vm2_struct_big_aset: |
- s = Struct.new(*('a'..'z').map { |x| x.to_sym })
- x = s.new
- i = 0
- while i<6_000_000
- i += 1
- x.k = i # x[10] = i
- end
-loop_count: 1
diff --git a/benchmark/vm2_struct_big_href_hi.yml b/benchmark/vm2_struct_big_href_hi.yml
deleted file mode 100644
index 60aa7fddf3..0000000000
--- a/benchmark/vm2_struct_big_href_hi.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- s = Struct.new(*('a'..'z').map { |x| x.to_sym })
- x = s.new
-benchmark:
- vm2_struct_big_href_hi: |
- x[:z]
-loop_count: 6000000
diff --git a/benchmark/vm2_struct_big_href_lo.yml b/benchmark/vm2_struct_big_href_lo.yml
deleted file mode 100644
index c55c0bd16c..0000000000
--- a/benchmark/vm2_struct_big_href_lo.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- s = Struct.new(*('a'..'z').map { |x| x.to_sym })
- x = s.new
-benchmark:
- vm2_struct_big_href_lo: |
- x[:k]
-loop_count: 6000000
diff --git a/benchmark/vm2_struct_big_hset.yml b/benchmark/vm2_struct_big_hset.yml
deleted file mode 100644
index d199c5bd47..0000000000
--- a/benchmark/vm2_struct_big_hset.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-# loop_count is not utilized since `i` is involved in the script
-benchmark:
- vm2_struct_big_hset: |
- s = Struct.new(*('a'..'z').map { |x| x.to_sym })
- x = s.new
- i = 0
- while i<6_000_000
- i += 1
- x[:k] = i
- end
-loop_count: 1
diff --git a/benchmark/vm2_struct_small_aref.yml b/benchmark/vm2_struct_small_aref.yml
deleted file mode 100644
index 83381bed3a..0000000000
--- a/benchmark/vm2_struct_small_aref.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- s = Struct.new(:a, :b, :c)
- x = s.new
-benchmark:
- vm2_struct_small_aref: |
- x.a
-loop_count: 6000000
diff --git a/benchmark/vm2_struct_small_aset.yml b/benchmark/vm2_struct_small_aset.yml
deleted file mode 100644
index 3e84a61dd0..0000000000
--- a/benchmark/vm2_struct_small_aset.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-# loop_count is not utilized since `i` is involved in the script
-benchmark:
- vm2_struct_small_aset: |
- s = Struct.new(:a, :b, :c)
- x = s.new
- i = 0
- while i<6_000_000
- i += 1
- x.a = i
- end
-loop_count: 1
diff --git a/benchmark/vm2_struct_small_href.yml b/benchmark/vm2_struct_small_href.yml
deleted file mode 100644
index b744f070d1..0000000000
--- a/benchmark/vm2_struct_small_href.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- s = Struct.new(:a, :b, :c)
- x = s.new
-benchmark:
- vm2_struct_small_href: |
- x[:a]
-loop_count: 6000000
diff --git a/benchmark/vm2_struct_small_hset.yml b/benchmark/vm2_struct_small_hset.yml
deleted file mode 100644
index d43845d6e0..0000000000
--- a/benchmark/vm2_struct_small_hset.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- s = Struct.new(:a, :b, :c)
- x = s.new
-benchmark:
- vm2_struct_small_hset: |
- x[:a] = 1
-loop_count: 6000000
diff --git a/benchmark/vm2_super.yml b/benchmark/vm2_super.yml
deleted file mode 100644
index 674743762a..0000000000
--- a/benchmark/vm2_super.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-prelude: |
- class C
- def m
- 1
- end
- end
-
- class CC < C
- def m
- super()
- end
- end
-
- obj = CC.new
-benchmark:
- vm2_super: obj.m
-loop_count: 6000000
diff --git a/benchmark/vm2_unif1.yml b/benchmark/vm2_unif1.yml
deleted file mode 100644
index caef13279f..0000000000
--- a/benchmark/vm2_unif1.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-prelude: |
- def m a, b
- end
-benchmark:
- vm2_unif1: |
- m 100, 200
-loop_count: 6000000
diff --git a/benchmark/vm2_zsuper.yml b/benchmark/vm2_zsuper.yml
deleted file mode 100644
index f760cfd48e..0000000000
--- a/benchmark/vm2_zsuper.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-prelude: |
- class C
- def m a
- 1
- end
- end
-
- class CC < C
- def m a
- super
- end
- end
-
- obj = CC.new
-benchmark:
- vm2_zsuper: |
- obj.m 10
-loop_count: 6000000
diff --git a/benchmark/vm_thread_alive_check.yml b/benchmark/vm_thread_alive_check.yml
deleted file mode 100644
index d21737d3e8..0000000000
--- a/benchmark/vm_thread_alive_check.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-benchmark:
- vm_thread_alive_check: |
- t = Thread.new{}
- while t.alive?
- Thread.pass
- end
-loop_count: 50_000
-
diff --git a/benchmark/vm_thread_pass.rb b/benchmark/vm_thread_pass.rb
deleted file mode 100644
index 438bd08d45..0000000000
--- a/benchmark/vm_thread_pass.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# Plenty Thread.pass
-# A performance may depend on GVL implementation.
-
-tmax = (ARGV.shift || 8).to_i
-lmax = 400_000 / tmax
-
-(1..tmax).map{
- Thread.new{
- lmax.times{
- Thread.pass
- }
- }
-}.each{|t| t.join}
-
-
diff --git a/benchmark/vm_thread_pass_flood.rb b/benchmark/vm_thread_pass_flood.rb
deleted file mode 100644
index 65df8e6154..0000000000
--- a/benchmark/vm_thread_pass_flood.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# n.b. this is a good test for GVL when pinned to a single CPU
-
-5_000.times{
- Thread.new{loop{Thread.pass}}
-}
-
-i = 0
-while i<10_000
- i += 1
-end
diff --git a/benchmark/vm_thread_queue.rb b/benchmark/vm_thread_queue.rb
deleted file mode 100644
index 1dd3696a3c..0000000000
--- a/benchmark/vm_thread_queue.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'thread'
-
-n = 10_000_000
-q = Thread::Queue.new
-consumer = Thread.new{
- while q.pop
- # consuming
- end
-}
-
-producer = Thread.new{
- n.times{
- q.push true
- }
- q.push nil
-}
-
-consumer.join
diff --git a/benchmark/vm_thread_sleep.yml b/benchmark/vm_thread_sleep.yml
deleted file mode 100644
index 96901d8466..0000000000
--- a/benchmark/vm_thread_sleep.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark:
- vm_thread_sleep: |
- Thread.new { sleep }
-loop_count: 10_000
diff --git a/benchmark/wc.input.base b/benchmark/wc.input.base
new file mode 100644
index 0000000000..41143fbac0
--- /dev/null
+++ b/benchmark/wc.input.base
@@ -0,0 +1,25 @@
+Subject: Re: Who was Izchak Miller?
+From: "Jane D. Anonymous" <nobody@yale.edu>
+Date: 1996/04/28
+Message-Id: <4lv7bc$oh@news.ycc.yale.edu>
+References: <317C405E.5DFA@panix.com> <4lk6vl$gde@ns.oar.net>
+To: 75176.2330@compuserve.com
+Content-Type: text/plain; charset=us-ascii
+Organization: Yale University
+X-Url: news:4lk6vl$gde@ns.oar.net
+Mime-Version: 1.0
+Newsgroups: rec.games.roguelike.nethack
+X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
+
+Hello there, Izchak Miller was my father. When I was younger I spent
+many a night, hunched over the keyboard with a cup of tea, playing
+nethack with him and my brother. my dad was a philosopher with a strong
+weakness for fantasy/sci fi. I remember when he started to get involved
+with the Nethack team- my brother's Dungeons and Dragons monster book
+found a regular place beside my dad's desk. it's nice to see him living
+on in the game he loved so much :-).
+ Tamar Miller
+
+The following is a really long word of 5000 characters:
+
+wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
diff --git a/bignum.c b/bignum.c
index 4569183e45..7ffb798e5e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -65,6 +65,7 @@ STATIC_ASSERT(sizeof_long_and_sizeof_bdigit, SIZEOF_BDIGIT % SIZEOF_LONG == 0);
#else
# define HOST_BIGENDIAN_P 0
#endif
+#define ALIGNOF(type) ((int)offsetof(struct { char f1; type f2; }, f2))
/* (!LSHIFTABLE(d, n) ? 0 : (n)) is same as n but suppress a warning, C4293, by Visual Studio. */
#define LSHIFTABLE(d, n) ((n) < sizeof(d) * CHAR_BIT)
#define LSHIFTX(d, n) (!LSHIFTABLE(d, n) ? 0 : ((d) << (!LSHIFTABLE(d, n) ? 0 : (n))))
@@ -385,7 +386,6 @@ bdigitdbl2bary(BDIGIT *ds, size_t n, BDIGIT_DBL num)
static int
bary_cmp(const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
{
- size_t i;
BARY_TRUNC(xds, xn);
BARY_TRUNC(yds, yn);
@@ -394,12 +394,11 @@ bary_cmp(const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
if (xn > yn)
return 1;
- for (i = 0; i < xn; i++)
- if (xds[xn - i - 1] != yds[yn - i - 1])
- break;
- if (i == xn)
+ while (xn-- && xds[xn] == yds[xn])
+ ;
+ if (xn == (size_t)-1)
return 0;
- return xds[xn - i - 1] < yds[yn - i - 1] ? -1 : 1;
+ return xds[xn] < yds[xn] ? -1 : 1;
}
static BDIGIT
@@ -420,16 +419,15 @@ bary_small_lshift(BDIGIT *zds, const BDIGIT *xds, size_t n, int shift)
static void
bary_small_rshift(BDIGIT *zds, const BDIGIT *xds, size_t n, int shift, BDIGIT higher_bdigit)
{
- size_t i;
BDIGIT_DBL num = 0;
assert(0 <= shift && shift < BITSPERDIG);
num = BIGUP(higher_bdigit);
- for (i = 0; i < n; i++) {
- BDIGIT x = xds[n - i - 1];
+ while (n--) {
+ BDIGIT x = xds[n];
num = (num | x) >> shift;
- zds[n - i - 1] = BIGLO(num);
+ zds[n] = BIGLO(num);
num = BIGUP(x);
}
}
@@ -448,9 +446,8 @@ bary_zero_p(const BDIGIT *xds, size_t xn)
static void
bary_neg(BDIGIT *ds, size_t n)
{
- size_t i;
- for (i = 0; i < n; i++)
- ds[n - i - 1] = BIGLO(~ds[n - i - 1]);
+ while (n--)
+ ds[n] = BIGLO(~ds[n]);
}
static int
@@ -620,12 +617,8 @@ static int
bytes_2comp(unsigned char *buf, size_t len)
{
size_t i;
- for (i = 0; i < len; i++) {
- signed char c = buf[i];
- signed int d = ~c;
- unsigned int e = d & 0xFF;
- buf[i] = e;
- }
+ for (i = 0; i < len; i++)
+ buf[i] = ~buf[i];
for (i = 0; i < len; i++) {
buf[i]++;
if (buf[i] != 0)
@@ -675,7 +668,7 @@ bary_pack(int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords
return ((1 < de - dp || CLEAR_LOWBITS(d, 8) != 0) ? 2 : 1) * sign;
}
#if defined(HAVE_UINT16_T) && 2 <= SIZEOF_BDIGIT
- if (wordsize == 2 && (uintptr_t)words % RUBY_ALIGNOF(uint16_t) == 0) {
+ if (wordsize == 2 && (uintptr_t)words % ALIGNOF(uint16_t) == 0) {
uint16_t u = (uint16_t)(d = dp[0]);
if (need_swap) u = swap16(u);
*((uint16_t *)words) = u;
@@ -683,7 +676,7 @@ bary_pack(int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords
}
#endif
#if defined(HAVE_UINT32_T) && 4 <= SIZEOF_BDIGIT
- if (wordsize == 4 && (uintptr_t)words % RUBY_ALIGNOF(uint32_t) == 0) {
+ if (wordsize == 4 && (uintptr_t)words % ALIGNOF(uint32_t) == 0) {
uint32_t u = (uint32_t)(d = dp[0]);
if (need_swap) u = swap32(u);
*((uint32_t *)words) = u;
@@ -691,7 +684,7 @@ bary_pack(int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords
}
#endif
#if defined(HAVE_UINT64_T) && 8 <= SIZEOF_BDIGIT
- if (wordsize == 8 && (uintptr_t)words % RUBY_ALIGNOF(uint64_t) == 0) {
+ if (wordsize == 8 && (uintptr_t)words % ALIGNOF(uint64_t) == 0) {
uint64_t u = (uint64_t)(d = dp[0]);
if (need_swap) u = swap64(u);
*((uint64_t *)words) = u;
@@ -706,7 +699,7 @@ bary_pack(int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords
return (1 < de - dp || FILL_LOWBITS(d, 8) != -1) ? -2 : -1;
}
#if defined(HAVE_UINT16_T) && 2 <= SIZEOF_BDIGIT
- if (wordsize == 2 && (uintptr_t)words % RUBY_ALIGNOF(uint16_t) == 0) {
+ if (wordsize == 2 && (uintptr_t)words % ALIGNOF(uint16_t) == 0) {
uint16_t u = (uint16_t)(d = -(BDIGIT_DBL_SIGNED)dp[0]);
if (need_swap) u = swap16(u);
*((uint16_t *)words) = u;
@@ -715,7 +708,7 @@ bary_pack(int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords
}
#endif
#if defined(HAVE_UINT32_T) && 4 <= SIZEOF_BDIGIT
- if (wordsize == 4 && (uintptr_t)words % RUBY_ALIGNOF(uint32_t) == 0) {
+ if (wordsize == 4 && (uintptr_t)words % ALIGNOF(uint32_t) == 0) {
uint32_t u = (uint32_t)(d = -(BDIGIT_DBL_SIGNED)dp[0]);
if (need_swap) u = swap32(u);
*((uint32_t *)words) = u;
@@ -724,7 +717,7 @@ bary_pack(int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords
}
#endif
#if defined(HAVE_UINT64_T) && 8 <= SIZEOF_BDIGIT
- if (wordsize == 8 && (uintptr_t)words % RUBY_ALIGNOF(uint64_t) == 0) {
+ if (wordsize == 8 && (uintptr_t)words % ALIGNOF(uint64_t) == 0) {
uint64_t u = (uint64_t)(d = -(BDIGIT_DBL_SIGNED)dp[0]);
if (need_swap) u = swap64(u);
*((uint64_t *)words) = u;
@@ -767,7 +760,7 @@ bary_pack(int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords
}
#endif
if (nails == 0 && SIZEOF_BDIGIT == sizeof(BDIGIT) &&
- wordsize % SIZEOF_BDIGIT == 0 && (uintptr_t)words % RUBY_ALIGNOF(BDIGIT) == 0) {
+ wordsize % SIZEOF_BDIGIT == 0 && (uintptr_t)words % ALIGNOF(BDIGIT) == 0) {
size_t bdigits_per_word = wordsize / SIZEOF_BDIGIT;
size_t src_num_bdigits = de - dp;
size_t dst_num_bdigits = numwords * bdigits_per_word;
@@ -1087,13 +1080,6 @@ integer_unpack_single_bdigit(BDIGIT u, size_t size, int flags, BDIGIT *dp)
return sign;
}
-#ifdef HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED
-#define reinterpret_cast(type, value) (type) \
- __builtin_assume_aligned((value), sizeof(*(type)NULL));
-#else
-#define reinterpret_cast(type, value) (type)value
-#endif
-
static int
bary_unpack_internal(BDIGIT *bdigits, size_t num_bdigits, const void *words, size_t numwords, size_t wordsize, size_t nails, int flags, int nlp_bits)
{
@@ -1114,24 +1100,23 @@ bary_unpack_internal(BDIGIT *bdigits, size_t num_bdigits, const void *words, siz
return integer_unpack_single_bdigit(*(uint8_t *)buf, sizeof(uint8_t), flags, dp);
}
#if defined(HAVE_UINT16_T) && 2 <= SIZEOF_BDIGIT
- if (wordsize == 2 && (uintptr_t)words % RUBY_ALIGNOF(uint16_t) == 0) {
- uint16_t u = *reinterpret_cast(const uint16_t *, buf);
+ if (wordsize == 2 && (uintptr_t)words % ALIGNOF(uint16_t) == 0) {
+ uint16_t u = *(uint16_t *)buf;
return integer_unpack_single_bdigit(need_swap ? swap16(u) : u, sizeof(uint16_t), flags, dp);
}
#endif
#if defined(HAVE_UINT32_T) && 4 <= SIZEOF_BDIGIT
- if (wordsize == 4 && (uintptr_t)words % RUBY_ALIGNOF(uint32_t) == 0) {
- uint32_t u = *reinterpret_cast(const uint32_t *, buf);
+ if (wordsize == 4 && (uintptr_t)words % ALIGNOF(uint32_t) == 0) {
+ uint32_t u = *(uint32_t *)buf;
return integer_unpack_single_bdigit(need_swap ? swap32(u) : u, sizeof(uint32_t), flags, dp);
}
#endif
#if defined(HAVE_UINT64_T) && 8 <= SIZEOF_BDIGIT
- if (wordsize == 8 && (uintptr_t)words % RUBY_ALIGNOF(uint64_t) == 0) {
- uint64_t u = *reinterpret_cast(const uint64_t *, buf);
+ if (wordsize == 8 && (uintptr_t)words % ALIGNOF(uint64_t) == 0) {
+ uint64_t u = *(uint64_t *)buf;
return integer_unpack_single_bdigit(need_swap ? swap64(u) : u, sizeof(uint64_t), flags, dp);
}
#endif
-#undef reinterpret_cast
}
#if !defined(WORDS_BIGENDIAN)
if (nails == 0 && SIZEOF_BDIGIT == sizeof(BDIGIT) &&
@@ -1447,9 +1432,7 @@ bary_add_one(BDIGIT *ds, size_t n)
{
size_t i;
for (i = 0; i < n; i++) {
- BDIGIT_DBL n = ds[i];
- n += 1;
- ds[i] = BIGLO(n);
+ ds[i] = BIGLO(ds[i]+1);
if (ds[i] != 0)
return 0;
}
@@ -1517,16 +1500,15 @@ bigdivrem_mulsub(BDIGIT *zds, size_t zn, BDIGIT x, const BDIGIT *yds, size_t yn)
i = 0;
do {
- BDIGIT_DBL_SIGNED ee;
+ BDIGIT_DBL ee;
t2 += (BDIGIT_DBL)yds[i] * x;
ee = num - BIGLO(t2);
- num = (BDIGIT_DBL_SIGNED)zds[i] + ee;
+ num = (BDIGIT_DBL)zds[i] + ee;
if (ee) zds[i] = BIGLO(num);
num = BIGDN(num);
t2 = BIGDN(t2);
} while (++i < yn);
- num -= (BDIGIT_DBL_SIGNED)t2;
- num += (BDIGIT_DBL_SIGNED)zds[yn]; /* borrow from high digit; don't update */
+ num += zds[i] - t2; /* borrow from high digit; don't update */
return num;
}
@@ -2572,7 +2554,6 @@ bigdivrem1(void *ptr)
return 0;
}
-/* async-signal-safe */
static void
rb_big_stop(void *ptr)
{
@@ -2595,9 +2576,10 @@ bigdivrem_single1(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT x_higher_bdi
size_t i;
BDIGIT_DBL t2;
t2 = x_higher_bdigit;
- for (i = 0; i < xn; i++) {
- t2 = BIGUP(t2) + xds[xn - i - 1];
- qds[xn - i - 1] = (BDIGIT)(t2 / y);
+ i = xn;
+ while (i--) {
+ t2 = BIGUP(t2) + xds[i];
+ qds[i] = (BDIGIT)(t2 / y);
t2 %= y;
}
return (BDIGIT)t2;
@@ -2637,7 +2619,7 @@ bigdivrem_restoring(BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
if (bds.zn > 10000 || bds.yn > 10000) {
retry:
bds.stop = Qfalse;
- rb_nogvl(bigdivrem1, &bds, rb_big_stop, &bds, RB_NOGVL_UBF_ASYNC_SAFE);
+ rb_thread_call_without_gvl(bigdivrem1, &bds, rb_big_stop, &bds);
if (bds.stop == Qtrue) {
/* execute trap handler, but exception was not raised. */
@@ -3155,7 +3137,7 @@ rb_big_norm(VALUE x)
}
VALUE
-rb_uint2big(uintptr_t n)
+rb_uint2big(VALUE n)
{
long i;
VALUE big = bignew(bdigit_roomof(SIZEOF_VALUE), 1);
@@ -3177,7 +3159,7 @@ rb_uint2big(uintptr_t n)
}
VALUE
-rb_int2big(intptr_t n)
+rb_int2big(SIGNED_VALUE n)
{
long neg = 0;
VALUE u;
@@ -3198,14 +3180,14 @@ rb_int2big(intptr_t n)
}
VALUE
-rb_uint2inum(uintptr_t n)
+rb_uint2inum(VALUE n)
{
if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_uint2big(n);
}
VALUE
-rb_int2inum(intptr_t n)
+rb_int2inum(SIGNED_VALUE n)
{
if (FIXABLE(n)) return LONG2FIX(n);
return rb_int2big(n);
@@ -3990,8 +3972,6 @@ str2big_gmp(
}
#endif
-static VALUE rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base);
-
/*
* Parse +str+ as Ruby Integer, i.e., underscores, 0d and 0b prefixes.
*
@@ -4235,7 +4215,7 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits,
return bignorm(z);
}
-static VALUE
+VALUE
rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base)
{
return rb_int_parse_cstr(str, len, endp, NULL, base,
@@ -4243,7 +4223,7 @@ rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base)
}
VALUE
-rb_str_convert_to_inum(VALUE str, int base, int badcheck, int raise_exception)
+rb_str_to_inum(VALUE str, int base, int badcheck)
{
VALUE ret;
const char *s;
@@ -4255,22 +4235,13 @@ rb_str_convert_to_inum(VALUE str, int base, int badcheck, int raise_exception)
RSTRING_GETMEM(str, s, len);
ret = rb_cstr_parse_inum(s, len, (badcheck ? NULL : &end), base);
if (NIL_P(ret)) {
- if (badcheck) {
- if (!raise_exception) return Qnil;
- invalid_integer(str);
- }
- ret = INT2FIX(0);
+ if (badcheck) invalid_integer(str);
+ ret = INT2FIX(0);
}
return ret;
}
VALUE
-rb_str_to_inum(VALUE str, int base, int badcheck)
-{
- return rb_str_convert_to_inum(str, base, badcheck, TRUE);
-}
-
-VALUE
rb_str2big_poweroftwo(VALUE arg, int base, int badcheck)
{
int positive_p = 1;
@@ -4512,7 +4483,7 @@ rb_uint128t2big(uint128_t n)
return big;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_int128t2big(int128_t n)
{
int neg = 0;
@@ -5096,9 +5067,6 @@ rb_big2str(VALUE x, int base)
static unsigned long
big2ulong(VALUE x, const char *type)
{
-#if SIZEOF_LONG > SIZEOF_BDIGIT
- size_t i;
-#endif
size_t len = BIGNUM_LEN(x);
unsigned long num;
BDIGIT *ds;
@@ -5113,9 +5081,9 @@ big2ulong(VALUE x, const char *type)
num = (unsigned long)ds[0];
#else
num = 0;
- for (i = 0; i < len; i++) {
+ while (len--) {
num <<= BITSPERDIG;
- num += (unsigned long)ds[len - i - 1]; /* overflow is already checked */
+ num += (unsigned long)ds[len]; /* overflow is already checked */
}
#endif
return num;
@@ -5157,9 +5125,6 @@ rb_big2long(VALUE x)
static unsigned LONG_LONG
big2ull(VALUE x, const char *type)
{
-#if SIZEOF_LONG_LONG > SIZEOF_BDIGIT
- size_t i;
-#endif
size_t len = BIGNUM_LEN(x);
unsigned LONG_LONG num;
BDIGIT *ds = BDIGITS(x);
@@ -5172,9 +5137,9 @@ big2ull(VALUE x, const char *type)
num = (unsigned LONG_LONG)ds[0];
#else
num = 0;
- for (i = 0; i < len; i++) {
+ while (len--) {
num = BIGUP(num);
- num += ds[len - i - 1];
+ num += ds[len];
}
#endif
return num;
@@ -5281,13 +5246,8 @@ big2dbl(VALUE x)
}
}
if (carry) {
- BDIGIT mask = BDIGMAX;
- BDIGIT bit = 1;
- mask <<= bits;
- bit <<= bits;
- dl &= mask;
- dl += bit;
- dl = BIGLO(dl);
+ dl &= BDIGMAX << bits;
+ dl = BIGLO(dl + ((BDIGIT)1 << bits));
if (!dl) d += 1;
}
}
@@ -5371,17 +5331,6 @@ rb_integer_float_cmp(VALUE x, VALUE y)
return INT2FIX(-1);
}
-#if SIZEOF_LONG * CHAR_BIT >= DBL_MANT_DIG /* assume FLT_RADIX == 2 */
-COMPILER_WARNING_PUSH
-#ifdef __has_warning
-#if __has_warning("-Wimplicit-int-float-conversion")
-COMPILER_WARNING_IGNORED(-Wimplicit-int-float-conversion)
-#endif
-#endif
-static const double LONG_MAX_as_double = LONG_MAX;
-COMPILER_WARNING_POP
-#endif
-
VALUE
rb_integer_float_eq(VALUE x, VALUE y)
{
@@ -5401,7 +5350,7 @@ rb_integer_float_eq(VALUE x, VALUE y)
return Qtrue;
#else
long xn, yn;
- if (yi < LONG_MIN || LONG_MAX_as_double <= yi)
+ if (yi < LONG_MIN || LONG_MAX < yi)
return Qfalse;
xn = FIX2LONG(x);
yn = (long)yi;
@@ -5414,7 +5363,6 @@ rb_integer_float_eq(VALUE x, VALUE y)
return rb_big_eq(x, y);
}
-
VALUE
rb_big_cmp(VALUE x, VALUE y)
{
@@ -5514,8 +5462,8 @@ rb_big_le(VALUE x, VALUE y)
* big == obj -> true or false
*
* Returns <code>true</code> only if <i>obj</i> has the same value
- * as <i>big</i>. Contrast this with Integer#eql?, which requires
- * <i>obj</i> to be a Integer.
+ * as <i>big</i>. Contrast this with <code>Integer#eql?</code>, which
+ * requires <i>obj</i> to be a <code>Integer</code>.
*
* 68719476736 == 68719476736.0 #=> true
*/
@@ -5978,7 +5926,7 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
zds = BDIGITS(z);
dd = bigdivrem_single(zds, xds, xn, dd);
if (modp) {
- *modp = rb_uint2big((uintptr_t)dd);
+ *modp = rb_uint2big((VALUE)dd);
BIGNUM_SET_SIGN(*modp, BIGNUM_SIGN(x));
}
if (divp) *divp = z;
@@ -6068,15 +6016,12 @@ rb_big_divide(VALUE x, VALUE y, ID op)
}
else if (RB_FLOAT_TYPE_P(y)) {
if (op == '/') {
- double dx = rb_big2dbl(x);
- return rb_flo_div_flo(DBL2NUM(dx), y);
+ return DBL2NUM(rb_big2dbl(x) / RFLOAT_VALUE(y));
}
else {
- VALUE v;
double dy = RFLOAT_VALUE(y);
if (dy == 0.0) rb_num_zerodiv();
- v = rb_big_divide(x, y, '/');
- return rb_dbl2big(RFLOAT_VALUE(v));
+ return rb_dbl2big(rb_big2dbl(x) / dy);
}
}
else {
@@ -6096,7 +6041,7 @@ rb_big_div(VALUE x, VALUE y)
VALUE
rb_big_idiv(VALUE x, VALUE y)
{
- return rb_big_divide(x, y, idDiv);
+ return rb_big_divide(x, y, rb_intern("div"));
}
VALUE
@@ -6140,7 +6085,7 @@ rb_big_divmod(VALUE x, VALUE y)
y = rb_int2big(FIX2LONG(y));
}
else if (!RB_BIGNUM_TYPE_P(y)) {
- return rb_num_coerce_bin(x, y, idDivmod);
+ return rb_num_coerce_bin(x, y, rb_intern("divmod"));
}
bigdivmod(x, y, &div, &mod);
@@ -6178,7 +6123,7 @@ big_fdiv(VALUE x, VALUE y, long ey)
#if SIZEOF_LONG > SIZEOF_INT
{
/* Visual C++ can't be here */
- if (l > INT_MAX) return HUGE_VAL;
+ if (l > INT_MAX) return INFINITY;
if (l < INT_MIN) return 0.0;
}
#endif
@@ -6209,7 +6154,6 @@ double
rb_big_fdiv_double(VALUE x, VALUE y)
{
double dx, dy;
- VALUE v;
dx = big2dbl(x);
if (FIXNUM_P(y)) {
@@ -6218,7 +6162,9 @@ rb_big_fdiv_double(VALUE x, VALUE y)
return big_fdiv_int(x, rb_int2big(FIX2LONG(y)));
}
else if (RB_BIGNUM_TYPE_P(y)) {
- return big_fdiv_int(x, y);
+ dy = rb_big2dbl(y);
+ if (isinf(dx) || isinf(dy))
+ return big_fdiv_int(x, y);
}
else if (RB_FLOAT_TYPE_P(y)) {
dy = RFLOAT_VALUE(y);
@@ -6228,10 +6174,9 @@ rb_big_fdiv_double(VALUE x, VALUE y)
return big_fdiv_float(x, y);
}
else {
- return NUM2DBL(rb_num_coerce_bin(x, y, idFdiv));
+ return NUM2DBL(rb_num_coerce_bin(x, y, rb_intern("fdiv")));
}
- v = rb_flo_div_flo(DBL2NUM(dx), DBL2NUM(dy));
- return NUM2DBL(v);
+ return dx / dy;
}
VALUE
@@ -6248,12 +6193,10 @@ rb_big_pow(VALUE x, VALUE y)
again:
if (y == INT2FIX(0)) return INT2FIX(1);
- if (y == INT2FIX(1)) return x;
if (RB_FLOAT_TYPE_P(y)) {
d = RFLOAT_VALUE(y);
- if ((BIGNUM_NEGATIVE_P(x) && !BIGZEROP(x))) {
- return rb_dbl_complex_new_polar_pi(pow(-rb_big2dbl(x), d), d);
- }
+ if ((BIGNUM_NEGATIVE_P(x) && !BIGZEROP(x)) && d != round(d))
+ return rb_funcall(rb_complex_raw1(x), idPow, 1, y);
}
else if (RB_BIGNUM_TYPE_P(y)) {
y = bignorm(y);
@@ -6265,13 +6208,8 @@ rb_big_pow(VALUE x, VALUE y)
else if (FIXNUM_P(y)) {
yy = FIX2LONG(y);
- if (yy < 0) {
- x = rb_big_pow(x, INT2NUM(-yy));
- if (RB_INTEGER_TYPE_P(x))
- return rb_rational_raw(INT2FIX(1), x);
- else
- return DBL2NUM(1.0 / NUM2DBL(x));
- }
+ if (yy < 0)
+ return rb_funcall(rb_rational_raw1(x), idPow, 1, y);
else {
VALUE z = 0;
SIGNED_VALUE mask;
@@ -6890,15 +6828,7 @@ estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len)
rshift /= 2;
rshift += (2-(len&1))*BITSPERDIG/2;
if (rshift >= 0) {
- if (nlz((BDIGIT)d) + rshift >= BITSPERDIG) {
- /* (d << rshift) does cause overflow.
- * example: Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)
- */
- d = ~(BDIGIT_DBL)0;
- }
- else {
- d <<= rshift;
- }
+ d <<= rshift;
}
BDIGITS_ZERO(xds, xn-2);
bdigitdbl2bary(&xds[xn-2], 2, d);
@@ -6992,7 +6922,7 @@ int_pow_tmp3(VALUE x, VALUE y, VALUE m, int nega_flg)
z = bignew(zn, 1);
bary_powm_gmp(BDIGITS(z), zn, BDIGITS(x), xn, BDIGITS(y), yn, BDIGITS(m), mn);
if (nega_flg & BIGNUM_POSITIVE_P(z)) {
- z = rb_big_minus(z, m);
+ z = rb_funcall(z, '-', 1, m);
}
RB_GC_GUARD(x);
RB_GC_GUARD(y);
@@ -7002,25 +6932,25 @@ int_pow_tmp3(VALUE x, VALUE y, VALUE m, int nega_flg)
VALUE tmp = LONG2FIX(1L);
long yy;
- for (/*NOP*/; ! FIXNUM_P(y); y = rb_big_rshift(y, LONG2FIX(1L))) {
- if (RTEST(rb_int_odd_p(y))) {
- tmp = rb_int_mul(tmp, x);
+ for (/*NOP*/; ! FIXNUM_P(y); y = rb_funcall(y, rb_intern(">>"), 1, LONG2FIX(1L))) {
+ if (RTEST(rb_funcall(y, rb_intern("odd?"), 0))) {
+ tmp = rb_funcall(tmp, '*', 1, x);
tmp = rb_int_modulo(tmp, m);
}
- x = rb_int_mul(x, x);
+ x = rb_funcall(x, '*', 1, x);
x = rb_int_modulo(x, m);
}
for (yy = FIX2LONG(y); yy; yy >>= 1L) {
if (yy & 1L) {
- tmp = rb_int_mul(tmp, x);
+ tmp = rb_funcall(tmp, '*', 1, x);
tmp = rb_int_modulo(tmp, m);
}
- x = rb_int_mul(x, x);
+ x = rb_funcall(x, '*', 1, x);
x = rb_int_modulo(x, m);
}
- if (nega_flg && rb_int_positive_p(tmp)) {
- tmp = rb_int_minus(tmp, m);
+ if (nega_flg && RTEST(rb_funcall(tmp, rb_intern("positive?"), 0))) {
+ tmp = rb_funcall(tmp, '-', 1, m);
}
return tmp;
#endif
@@ -7037,7 +6967,7 @@ int_pow_tmp1(VALUE x, VALUE y, long mm, int nega_flg)
long tmp = 1L;
long yy;
- for (/*NOP*/; ! FIXNUM_P(y); y = rb_big_rshift(y, LONG2FIX(1L))) {
+ for (/*NOP*/; ! FIXNUM_P(y); y = rb_funcall(y, idGTGT, 1, LONG2FIX(1L))) {
if (RTEST(rb_int_odd_p(y))) {
tmp = (tmp * xx) % mm;
}
@@ -7073,7 +7003,7 @@ int_pow_tmp2(VALUE x, VALUE y, long mm, int nega_flg)
# define MUL_MODULO(a, b, c) rb_int_modulo(rb_fix_mul_fix((a), (b)), (c))
#endif
- for (/*NOP*/; ! FIXNUM_P(y); y = rb_big_rshift(y, LONG2FIX(1L))) {
+ for (/*NOP*/; ! FIXNUM_P(y); y = rb_funcall(y, idGTGT, 1, LONG2FIX(1L))) {
if (RTEST(rb_int_odd_p(y))) {
tmp2 = MUL_MODULO(tmp2, xx, m);
}
@@ -7114,7 +7044,7 @@ rb_int_powm(int const argc, VALUE * const argv, VALUE const num)
rb_check_arity(argc, 1, 2);
if (argc == 1) {
- return rb_int_pow(num, argv[0]);
+ return rb_funcall(num, rb_intern("**"), 1, argv[0]);
}
else {
VALUE const a = num;
@@ -7124,35 +7054,34 @@ rb_int_powm(int const argc, VALUE * const argv, VALUE const num)
if ( ! RB_INTEGER_TYPE_P(b)) {
rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless a 1st argument is integer");
}
- if (rb_int_negative_p(b)) {
+ if (rb_num_negative_int_p(b)) {
rb_raise(rb_eRangeError, "Integer#pow() 1st argument cannot be negative when 2nd argument specified");
}
if (!RB_INTEGER_TYPE_P(m)) {
rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless all arguments are integers");
}
- if (rb_int_negative_p(m)) {
- m = rb_int_uminus(m);
+ if (rb_num_negative_int_p(m)) {
+ m = rb_funcall(m, idUMinus, 0);
nega_flg = 1;
}
+ if (!rb_num_positive_int_p(m)) {
+ rb_num_zerodiv();
+ }
if (FIXNUM_P(m)) {
long const half_val = (long)HALF_LONG_MSB;
long const mm = FIX2LONG(m);
- if (!mm) rb_num_zerodiv();
if (mm <= half_val) {
return int_pow_tmp1(rb_int_modulo(a, m), b, mm, nega_flg);
- }
- else {
+ } else {
return int_pow_tmp2(rb_int_modulo(a, m), b, mm, nega_flg);
}
- }
- else {
- if (rb_bigzero_p(m)) rb_num_zerodiv();
+ } else if (RB_TYPE_P(m, T_BIGNUM)) {
return int_pow_tmp3(rb_int_modulo(a, m), b, m, nega_flg);
}
}
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
/*
@@ -7179,7 +7108,6 @@ Init_Bignum(void)
#ifndef RUBY_INTEGER_UNIFICATION
rb_cBignum = rb_cInteger;
#endif
- /* An obsolete class, use Integer */
rb_define_const(rb_cObject, "Bignum", rb_cInteger);
rb_deprecate_constant(rb_cObject, "Bignum");
diff --git a/bin/bundle b/bin/bundle
deleted file mode 100755
index 1a0b06b005..0000000000
--- a/bin/bundle
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env ruby
-#
-# This file was generated by RubyGems.
-#
-# The application 'bundler' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0.a"
-
-str = ARGV.first
-if str
- str = str.b[/\A_(.*)_\z/, 1]
- if str and Gem::Version.correct?(str)
- version = str
- ARGV.shift
- end
-end
-
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('bundler', 'bundle', version)
-else
-gem "bundler", version
-load Gem.bin_path("bundler", "bundle", version)
-end
diff --git a/bin/bundler b/bin/bundler
deleted file mode 100755
index e15eb39ed7..0000000000
--- a/bin/bundler
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env ruby
-#
-# This file was generated by RubyGems.
-#
-# The application 'bundler' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0.a"
-
-str = ARGV.first
-if str
- str = str.b[/\A_(.*)_\z/, 1]
- if str and Gem::Version.correct?(str)
- version = str
- ARGV.shift
- end
-end
-
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('bundler', 'bundler', version)
-else
-gem "bundler", version
-load Gem.bin_path("bundler", "bundler", version)
-end
diff --git a/bin/erb b/bin/erb
index 2435224fe1..86f7042fae 100755
--- a/bin/erb
+++ b/bin/erb
@@ -75,7 +75,6 @@ class ERB
when '-r' # require
require ARGV.req_arg
when '-S' # security level
- warn 'warning: -S option of erb command is deprecated. Please do not use this.'
arg = ARGV.req_arg
raise "invalid safe_level #{arg.dump}" unless arg =~ /\A[0-1]\z/
safe_level = arg.to_i
@@ -113,10 +112,11 @@ class ERB
-v enable verbose mode
-d set $DEBUG to true
-r library load a library
+ -S safe_level set $SAFE (0..1)
-E ex[:in] set default external/internal encodings
- -U set default encoding to UTF-8
+ -U set default encoding to UTF-8.
-T trim_mode specify trim_mode (0..2, -)
- -P disable ruby code evaluation for lines beginning with %
+ -P ignore lines which start with "%"
var=value set variable
EOU
exit 1
@@ -127,12 +127,7 @@ EOU
filename = $FILENAME
exit 2 unless src
trim = trim_mode_opt(trim_mode, disable_percent)
- if safe_level.nil?
- erb = factory.new(src, trim_mode: trim)
- else
- # [deprecated] This will be removed at Ruby 2.7.
- erb = factory.new(src, safe_level, trim_mode: trim)
- end
+ erb = factory.new(src.untaint, safe_level, trim)
erb.filename = filename
if output
if number
@@ -143,7 +138,7 @@ EOU
puts erb.src
end
else
- bind = TOPLEVEL_BINDING
+ bind = TOPLEVEL_BINDING.taint
if variables
enc = erb.encoding
for var, val in variables do
diff --git a/bin/irb b/bin/irb
index ae6d358c9d..c64ee85fbd 100755
--- a/bin/irb
+++ b/bin/irb
@@ -1,27 +1,11 @@
#!/usr/bin/env ruby
#
-# This file was generated by RubyGems.
+# irb.rb - interactive ruby
+# $Release Version: 0.9.6 $
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
-# The application 'irb' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0.a"
-str = ARGV.first
-if str
- str = str.b[/\A_(.*)_\z/, 1]
- if str and Gem::Version.correct?(str)
- version = str
- ARGV.shift
- end
-end
+require "irb"
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('irb', 'irb', version)
-else
-gem "irb", version
-load Gem.bin_path("irb", "irb", version)
-end
+IRB.start(__FILE__)
diff --git a/bin/racc b/bin/racc
deleted file mode 100755
index 3ddac532b4..0000000000
--- a/bin/racc
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env ruby
-#
-# This file was generated by RubyGems.
-#
-# The application 'racc' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0.a"
-
-if ARGV.first
- str = ARGV.first
- str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
- if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
- version = $1
- ARGV.shift
- end
-end
-
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('racc', 'racc', version)
-else
-gem "racc", version
-load Gem.bin_path("racc", "racc", version)
-end
diff --git a/bin/racc2y b/bin/racc2y
deleted file mode 100755
index a1e4352632..0000000000
--- a/bin/racc2y
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env ruby
-#
-# This file was generated by RubyGems.
-#
-# The application 'racc' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0.a"
-
-if ARGV.first
- str = ARGV.first
- str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
- if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
- version = $1
- ARGV.shift
- end
-end
-
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('racc', 'racc2y', version)
-else
-gem "racc", version
-load Gem.bin_path("racc", "racc2y", version)
-end
diff --git a/bin/rdoc b/bin/rdoc
index 8fa948cddb..aaa23292df 100755
--- a/bin/rdoc
+++ b/bin/rdoc
@@ -1,27 +1,44 @@
#!/usr/bin/env ruby
#
-# This file was generated by RubyGems.
-#
-# The application 'rdoc' is installed as part of a gem, and
-# this file is here to facilitate running it.
+# RDoc: Documentation tool for source code
+# (see lib/rdoc/rdoc.rb for more information)
#
+# Copyright (c) 2003 Dave Thomas
+# Released under the same terms as Ruby
-require 'rubygems'
+begin
+ gem 'rdoc'
+rescue NameError => e # --disable-gems
+ raise unless e.name == :gem
+rescue Gem::LoadError
+end
-version = ">= 0.a"
+require 'rdoc/rdoc'
-str = ARGV.first
-if str
- str = str.b[/\A_(.*)_\z/, 1]
- if str and Gem::Version.correct?(str)
- version = str
- ARGV.shift
+begin
+ r = RDoc::RDoc.new
+ r.document ARGV
+rescue Errno::ENOSPC
+ $stderr.puts 'Ran out of space creating documentation'
+ $stderr.puts
+ $stderr.puts 'Please free up some space and try again'
+rescue SystemExit
+ raise
+rescue Exception => e
+ if $DEBUG_RDOC then
+ $stderr.puts e.message
+ $stderr.puts "#{e.backtrace.join "\n\t"}"
+ $stderr.puts
+ elsif Interrupt === e then
+ $stderr.puts
+ $stderr.puts 'Interrupted'
+ else
+ $stderr.puts "uh-oh! RDoc had a problem:"
+ $stderr.puts e.message
+ $stderr.puts
+ $stderr.puts "run with --debug for full backtrace"
end
-end
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('rdoc', 'rdoc', version)
-else
-gem "rdoc", version
-load Gem.bin_path("rdoc", "rdoc", version)
+ exit 1
end
+
diff --git a/bin/ri b/bin/ri
index 0cc2f73bb6..7fbed0c099 100755
--- a/bin/ri
+++ b/bin/ri
@@ -1,27 +1,12 @@
#!/usr/bin/env ruby
-#
-# This file was generated by RubyGems.
-#
-# The application 'rdoc' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-require 'rubygems'
-
-version = ">= 0.a"
-
-str = ARGV.first
-if str
- str = str.b[/\A_(.*)_\z/, 1]
- if str and Gem::Version.correct?(str)
- version = str
- ARGV.shift
- end
+begin
+ gem 'rdoc'
+rescue NameError => e # --disable-gems
+ raise unless e.name == :gem
+rescue Gem::LoadError
end
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('rdoc', 'ri', version)
-else
-gem "rdoc", version
-load Gem.bin_path("rdoc", "ri", version)
-end
+require 'rdoc/ri/driver'
+
+RDoc::RI::Driver.run ARGV
diff --git a/bin/y2racc b/bin/y2racc
deleted file mode 100755
index 023615f369..0000000000
--- a/bin/y2racc
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env ruby
-#
-# This file was generated by RubyGems.
-#
-# The application 'racc' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0.a"
-
-if ARGV.first
- str = ARGV.first
- str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
- if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
- version = $1
- ARGV.shift
- end
-end
-
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('racc', 'y2racc', version)
-else
-gem "racc", version
-load Gem.bin_path("racc", "y2racc", version)
-end
diff --git a/bootstraptest/pending.rb b/bootstraptest/pending.rb
index 0959bfa2b0..744c0adac1 100644
--- a/bootstraptest/pending.rb
+++ b/bootstraptest/pending.rb
@@ -37,8 +37,3 @@ assert_normal_exit %q{
r.instance_eval { initialize r, r }
r.inspect
}
-
-# This randomly fails on mswin.
-assert_equal %q{[]}, %q{
- Thread.new{sleep}.backtrace
-}
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index 56b4b12230..e807ce5b62 100755
--- a/bootstraptest/runner.rb
+++ b/bootstraptest/runner.rb
@@ -1,4 +1,4 @@
-"exec" "${RUBY-ruby}" "-x" "$0" "$@" || true # -*- Ruby -*-
+"exec" "${RUBY-ruby}" "-x" "$0" "$@" || true # -*- mode: ruby; coding: utf-8 -*-
#!./ruby
# $Id$
@@ -6,7 +6,6 @@
# Never use optparse in this file.
# Never use test/unit in this file.
# Never use Ruby extensions in this file.
-# Maintain Ruby 1.8 compatibility for now
begin
require 'fileutils'
@@ -140,7 +139,7 @@ End
# dircolors-like style
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
begin
- File.read(File.join(__dir__, "../tool/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
+ File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
colors[n] ||= c
end
rescue
@@ -171,8 +170,8 @@ End
end
def erase(e = true)
- if e and @columns > 0 and @tty and !@verbose
- "\e[1K\r"
+ if e and @columns > 0 and !@verbose
+ "\r#{" "*@columns}\r"
else
""
end
@@ -208,9 +207,6 @@ def exec_test(pathes)
$stderr.puts unless @quiet and @tty and @error == error
end
$stderr.print(erase) if @quiet
- @errbuf.each do |msg|
- $stderr.puts msg
- end
if @error == 0
if @count == 0
$stderr.puts "No tests, no problem"
@@ -219,6 +215,9 @@ def exec_test(pathes)
end
exit true
else
+ @errbuf.each do |msg|
+ $stderr.puts msg
+ end
$stderr.puts "#{@failed}FAIL#{@reset} #{@error}/#{@count} tests failed"
exit false
end
@@ -244,7 +243,7 @@ def show_progress(message = '')
else
$stderr.print "#{@failed}F"
$stderr.printf(" %.3f", t) if @verbose
- $stderr.print @reset
+ $stderr.print "#{@reset}"
$stderr.puts if @verbose
error faildesc, message
unless errout.empty?
@@ -256,22 +255,13 @@ def show_progress(message = '')
end
rescue Interrupt
$stderr.puts "\##{@count} #{@location}"
- raise
+ raise Interrupt
rescue Exception => err
$stderr.print 'E'
$stderr.puts if @verbose
error err.message, message
end
-def show_limit(testsrc, opt = '', **argh)
- result = get_result_string(testsrc, opt, **argh)
- if @tty and @verbose
- $stderr.puts ".{#@reset}\n#{erase}#{result}"
- else
- @errbuf.push result
- end
-end
-
def assert_check(testsrc, message = '', opt = '', **argh)
show_progress(message) {
result = get_result_string(testsrc, opt, **argh)
@@ -376,9 +366,6 @@ def assert_normal_exit(testsrc, *rest, timeout: nil, **opt)
end
def assert_finish(timeout_seconds, testsrc, message = '')
- if RubyVM.const_defined? :MJIT
- timeout_seconds *= 3 if RubyVM::MJIT.enabled? # for --jit-wait
- end
newtest
show_progress(message) {
faildesc = nil
@@ -387,24 +374,12 @@ def assert_finish(timeout_seconds, testsrc, message = '')
pid = io.pid
waited = false
tlimit = Time.now + timeout_seconds
- diff = timeout_seconds
- while diff > 0
+ while Time.now < tlimit
if Process.waitpid pid, Process::WNOHANG
waited = true
break
end
- if io.respond_to?(:read_nonblock)
- if IO.select([io], nil, nil, diff)
- begin
- io.read_nonblock(1024)
- rescue Errno::EAGAIN, IO::WaitReadable, EOFError
- break
- end while true
- end
- else
- sleep 0.1
- end
- diff = tlimit - Time.now
+ sleep 0.1
end
if !waited
Process.kill(:KILL, pid)
diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb
index fa04323b7f..8e90ac2728 100644
--- a/bootstraptest/test_eval.rb
+++ b/bootstraptest/test_eval.rb
@@ -190,8 +190,7 @@ assert_equal %q{[10, main]}, %q{
}
%w[break next redo].each do |keyword|
- assert_match %r"Can't escape from eval with #{keyword}\b", %{
- STDERR.reopen(STDOUT)
+ assert_match %r"Can't escape from eval with #{keyword}\z", %{
begin
eval "0 rescue #{keyword}"
rescue SyntaxError => e
diff --git a/bootstraptest/test_exception.rb b/bootstraptest/test_exception.rb
index 0fb6f552b8..35c8d25e37 100644
--- a/bootstraptest/test_exception.rb
+++ b/bootstraptest/test_exception.rb
@@ -402,7 +402,7 @@ assert_equal 'nil', %q{
exc.inspect
}, '[ruby-dev:32608]'
-assert_equal 'divided by 0', %q{
+assert_equal 'exception class/object expected', %q{
class ZeroDivisionError
def self.new(message)
42
diff --git a/bootstraptest/test_fiber.rb b/bootstraptest/test_fiber.rb
deleted file mode 100644
index 35e1bf6851..0000000000
--- a/bootstraptest/test_fiber.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-show_limit %q{
- fibers = []
- begin
- fiber = Fiber.new{Fiber.yield}
- fiber.resume
- fibers << fiber
-
- raise Exception, "skipping" if fibers.count >= 10_000
- rescue Exception => error
- puts "Fiber count: #{fibers.count} (#{error})"
- break
- end while true
-}
-
-assert_equal %q{ok}, %q{
- Fiber.new{
- }.resume
- :ok
-}
-
-assert_equal %q{ok}, %q{
- 10_000.times.collect{Fiber.new{}}
- :ok
-}
-
-assert_equal %q{ok}, %q{
- fibers = 100.times.collect{Fiber.new{Fiber.yield}}
- fibers.each(&:resume)
- fibers.each(&:resume)
- :ok
-}
-
-assert_normal_exit %q{
- at_exit { Fiber.new{}.resume }
-}
-
-assert_normal_exit %q{
- Fiber.new(&Object.method(:class_eval)).resume("foo")
-}, '[ruby-dev:34128]'
diff --git a/bootstraptest/test_fork.rb b/bootstraptest/test_fork.rb
index 83923dad97..1cd9f7ac6c 100644
--- a/bootstraptest/test_fork.rb
+++ b/bootstraptest/test_fork.rb
@@ -21,9 +21,7 @@ assert_finish 10, %q{
end
}, '[ruby-core:22158]'
-# temporarily stop this test to enable explicit failure when
-# timer thread couldn't be created (r61706 and r61717).
-assert_normal_exit(<<'End', '[ruby-dev:37934]') if false
+assert_normal_exit(<<'End', '[ruby-dev:37934]')
main = Thread.current
Thread.new { sleep 0.01 until main.stop?; Thread.kill main }
Process.setrlimit(:NPROC, 1) if defined?(Process::RLIMIT_NPROC)
diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb
index 1269d7d013..4dd888897a 100644
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -10,16 +10,15 @@ begin
rescue LoadError
# OK, just skip
else
- if defined? RbConfig::LIMITS
- $FIXNUM_MAX = RbConfig::LIMITS["FIXNUM_MAX"]
- $FIXNUM_MIN = RbConfig::LIMITS["FIXNUM_MIN"]
- end
+ $FIXNUM_MAX = RbConfig::LIMITS["FIXNUM_MAX"]
+ $FIXNUM_MIN = RbConfig::LIMITS["FIXNUM_MIN"]
end
fsl = { frozen_string_literal: true } # used later
tests = [
# insn , expression to generate such insn
[ 'nop', %q{ raise rescue true }, ],
+ [ 'trace', %q{ true }, ],
[ 'setlocal *, 0', %q{ x = true }, ],
[ 'setlocal *, 1', %q{ x = nil; -> { x = true }.call }, ],
@@ -28,27 +27,6 @@ tests = [
[ 'getlocal *, 1', %q{ x = true; -> { x }.call }, ],
[ 'getlocal', %q{ x = true; -> { -> { x }.() }.() }, ],
- [ 'setblockparam', <<-'},', ], # {
- def m&b
- b = # here
- proc { true }
- end
- m { false }.call
- },
- [ 'getblockparam', <<-'},', ], # {
- def m&b
- b # here
- end
- m { true }.call
- },
- [ 'getblockparamproxy', <<-'},', ], # {
- def m&b
- b # here
- .call
- end
- m { true }
- },
-
[ 'setspecial', %q{ true if true..true }, ],
[ 'getspecial', %q{ $&.nil? }, ],
[ 'getspecial', %q{ $`.nil? }, ],
@@ -89,24 +67,22 @@ tests = [
[ 'putiseq', %q{ -> { true }.() }, ],
[ 'putstring', %q{ "true" }, ],
[ 'tostring / concatstrings', %q{ "#{true}" }, ],
- [ 'freezestring', %q{ "#{true}" }, fsl, ],
- [ 'freezestring', %q{ "#{true}" }, '-d', fsl, ],
+ [ 'freezestring', %q{ "#{true}"}, fsl, ],
+ [ 'freezestring', %q{ "#{true}"}, '-d', fsl, ],
[ 'toregexp', %q{ /#{true}/ =~ "true" && $~ }, ],
- [ 'intern', %q{ :"#{true}" }, ],
[ 'newarray', %q{ ["true"][0] }, ],
- [ 'newarraykwsplat', %q{ [**{x:'true'}][0][:x] }, ],
[ 'duparray', %q{ [ true ][0] }, ],
[ 'expandarray', %q{ y = [ true, false, nil ]; x, = y; x }, ],
[ 'expandarray', %q{ y = [ true, false, nil ]; x, *z = y; x }, ],
[ 'expandarray', %q{ y = [ true, false, nil ]; x, *z, w = y; x }, ],
[ 'splatarray', %q{ x, = *(y = true), false; x }, ],
[ 'concatarray', %q{ ["t", "r", *x = "u", "e"].join }, ],
- [ 'concatarray', <<-'},', ], # {
+ [ 'concatarray', <<~'},', ], # {
class X; def to_a; ['u']; end; end
['t', 'r', *X.new, 'e'].join
},
- [ 'concatarray', <<-'},', ], # {
+ [ 'concatarray', <<~'},', ], # {
r = false
t = [true, nil]
q, w, e = r, *t # here
@@ -115,15 +91,15 @@ tests = [
[ 'newhash', %q{ x = {}; x[x] = true }, ],
[ 'newhash', %q{ x = true; { x => x }[x] }, ],
- [ 'newhashfromarray', %q{ { a: true }[:a] }, ],
[ 'newrange', %q{ x = 1; [*(0..x)][0] == 0 }, ],
[ 'newrange', %q{ x = 1; [*(0...x)][0] == 0 }, ],
[ 'pop', %q{ def x; true; end; x }, ],
[ 'dup', %q{ x = y = true; x }, ],
[ 'dupn', %q{ Object::X ||= true }, ],
+ [ 'dupn', %q{ Object::X ||= true }, ],
[ 'reverse', %q{ q, (w, e), r = 1, [2, 3], 4; e == 3 }, ],
- [ 'swap', <<-'},', ], # {
+ [ 'swap', <<~'},', ], # {
x = [[false, true]]
for i, j in x # here
;
@@ -137,8 +113,7 @@ tests = [
[ 'defined', %q{ !defined?(x) }, ],
[ 'checkkeyword', %q{ def x x:rand;x end; x x: true }, ],
- [ 'checktype', %q{ x = true; "#{x}" }, ],
- [ 'checkmatch', <<-'},', ], # {
+ [ 'checkmatch', <<~'},', ], # {
x = y = true
case x
when false
@@ -148,7 +123,7 @@ tests = [
end
y == nil
},
- [ 'checkmatch', <<-'},', ], # {
+ [ 'checkmatch', <<~'},', ], # {
x, y = true, [false]
case x
when *y # here
@@ -158,7 +133,7 @@ tests = [
end
z
},
- [ 'checkmatch', <<-'},', ], # {
+ [ 'checkmatch', <<~'},', ], # {
x = false
begin
raise
@@ -174,7 +149,7 @@ tests = [
[ 'defineclass', %q{ X = Class.new; class X; true end }, ],
[ 'defineclass', %q{ X = Class.new; class Y < X; true end }, ],
[ 'defineclass', %q{ X = Class.new; class << X; true end }, ],
- [ 'defineclass', <<-'},', ], # {
+ [ 'defineclass', <<~'},', ], # {
X = Class.new
Y = Class.new(X)
class Y < X
@@ -185,7 +160,7 @@ tests = [
[ 'opt_send_without_block', %q{ true.to_s }, ],
[ 'send', %q{ true.tap {|i| i.to_s } }, ],
[ 'leave', %q{ def x; true; end; x }, ],
- [ 'invokesuper', <<-'},', ], # {
+ [ 'invokesuper', <<~'},', ], # {
class X < String
def empty?
super # here
@@ -193,7 +168,7 @@ tests = [
end
X.new.empty?
},
- [ 'invokeblock', <<-'},', ], # {
+ [ 'invokeblock', <<~'},', ], # {
def x
return yield self # here
end
@@ -203,11 +178,8 @@ tests = [
},
[ 'opt_str_freeze', %q{ 'true'.freeze }, ],
- [ 'opt_nil_p', %q{ nil.nil? }, ],
- [ 'opt_nil_p', %q{ !Object.nil? }, ],
- [ 'opt_nil_p', %q{ Class.new{def nil?; true end}.new.nil? }, ],
[ 'opt_str_uminus', %q{ -'true' }, ],
- [ 'opt_str_freeze', <<-'},', ], # {
+ [ 'opt_str_freeze', <<~'},', ], # {
class String
def freeze
true
@@ -218,7 +190,7 @@ tests = [
[ 'opt_newarray_max', %q{ [ ].max.nil? }, ],
[ 'opt_newarray_max', %q{ [1, x = 2, 3].max == 3 }, ],
- [ 'opt_newarray_max', <<-'},', ], # {
+ [ 'opt_newarray_max', <<~'},', ], # {
class Array
def max
true
@@ -228,7 +200,7 @@ tests = [
},
[ 'opt_newarray_min', %q{ [ ].min.nil? }, ],
[ 'opt_newarray_min', %q{ [3, x = 2, 1].min == 1 }, ],
- [ 'opt_newarray_min', <<-'},', ], # {
+ [ 'opt_newarray_min', <<~'},', ], # {
class Array
def min
true
@@ -244,12 +216,12 @@ tests = [
[ 'branchunless', %q{ x = nil; x &&= true; x.nil? }, ],
[ 'branchnil', %q{ x = true; x&.to_s }, ],
[ 'branchnil', %q{ x = nil; (x&.to_s).nil? }, ],
- [ 'jump', <<-'},', ], # {
+ [ 'jump', <<~'},', ], # {
y = 1
x = if y == 0 then nil elsif y == 1 then true else nil end
x
},
- [ 'jump', <<-'},', ], # {
+ [ 'jump', <<~'},', ], # {
# ultra complicated situation: this ||= assignment only generates
# 15 instructions, not including the class definition.
class X; attr_accessor :x; end
@@ -258,14 +230,14 @@ tests = [
},
[ 'once', %q{ /#{true}/o =~ "true" && $~ }, ],
- [ 'once', <<-'},', ], # {
+ [ 'once', <<~'},', ], # {
def once expr
return /#{expr}/o # here
end
x = once(true); x = once(false); x = once(nil);
x =~ "true" && $~
},
- [ 'once', <<-'},', ], # {
+ [ 'once', <<~'},', ], # {
# recursive once
def once n
return %r/#{
@@ -279,7 +251,7 @@ tests = [
x = once(128); x = once(7); x = once(16);
x =~ "true" && $~
},
- [ 'once', <<-'},', ], # {
+ [ 'once', <<~'},', ], # {
# inter-thread lockup situation
def once n
return Thread.start n do |m|
@@ -327,12 +299,12 @@ tests = [
[ 'opt_mod', %q{ '%s' % [ true ] }, ],
[ 'opt_eq', %q{ 1 == 1 }, ],
- [ 'opt_eq', <<-'},', ], # {
+ [ 'opt_eq', <<~'},', ], # {
class X; def == other; true; end; end
X.new == true
},
[ 'opt_neq', %q{ 1 != 0 }, ],
- [ 'opt_neq', <<-'},', ], # {
+ [ 'opt_neq', <<~'},', ], # {
class X; def != other; true; end; end
X.new != true
},
@@ -364,7 +336,7 @@ tests = [
[ 'opt_aset', %q{ [][0] = true }, ],
[ 'opt_aset', %q{ {}[0] = true }, ],
[ 'opt_aset', %q{ x = 'frue'; x[0] = 't'; x }, ],
- [ 'opt_aset', <<-'},', ], # {
+ [ 'opt_aset', <<~'},', ], # {
# opt_aref / opt_aset mixup situation
class X; def x; {}; end; end
x = X.new
@@ -397,44 +369,21 @@ tests = [
[ 'opt_succ', %q{ x = Time.at(0); x.succ == Time.at(1) }, ],
[ 'opt_not', %q{ ! false }, ],
- [ 'opt_neq', <<-'},', ], # {
+ [ 'opt_neq', <<~'},', ], # {
class X; def !; true; end; end
! X.new
},
- [ 'opt_regexpmatch2', %q{ /true/ =~ 'true' && $~ }, ],
- [ 'opt_regexpmatch2', <<-'},', ], # {
+ [ 'opt_regexpmatch1', %q{ /true/ =~ 'true' && $~ }, ],
+ [ 'opt_regexpmatch1', <<~'},', ], # {
class Regexp; def =~ other; true; end; end
/true/ =~ 'true'
},
[ 'opt_regexpmatch2', %q{ 'true' =~ /true/ && $~ }, ],
- [ 'opt_regexpmatch2', <<-'},', ], # {
+ [ 'opt_regexpmatch2', <<~'},', ], # {
class String; def =~ other; true; end; end
'true' =~ /true/
},
-
- [ 'opt_call_c_function', 'Struct.new(:x).new.x = true', ],
]
-# normal path
-tests.compact.each do |(insn, expr, *a)|
- if a.last.is_a?(Hash)
- a = a.dup
- kw = a.pop
- assert_equal 'true', expr, insn, *a, **kw
- else
- assert_equal 'true', expr, insn, *a
- end
-end
-
-# with trace
-tests.compact.each {|(insn, expr, *a)|
- progn = "set_trace_func(proc{})\n" + expr
- if a.last.is_a?(Hash)
- a = a.dup
- kw = a.pop
- assert_equal 'true', progn, 'trace_' + insn, *a, **kw
- else
- assert_equal 'true', progn, 'trace_' + insn, *a
- end
-}
+tests.compact.each {|(insn, expr, *a)| assert_equal 'true', expr, insn, *a }
diff --git a/bootstraptest/test_jump.rb b/bootstraptest/test_jump.rb
index 7944915862..595aaa7c4b 100644
--- a/bootstraptest/test_jump.rb
+++ b/bootstraptest/test_jump.rb
@@ -146,16 +146,15 @@ assert_equal %q{131}, %q{
end
}
}
-assert_match %r{Invalid retry}, %q{
-STDERR.reopen(STDOUT)
+assert_equal %q{ok}, %q{
begin
eval %q{
1.times{
retry
}
}
-rescue SyntaxError => e
- e.message
+rescue SyntaxError
+ :ok
end
}
assert_equal %q{3}, %q{
diff --git a/bootstraptest/test_literal_suffix.rb b/bootstraptest/test_literal_suffix.rb
index c36fa7078f..4316c9e040 100644
--- a/bootstraptest/test_literal_suffix.rb
+++ b/bootstraptest/test_literal_suffix.rb
@@ -46,9 +46,9 @@ assert_equal '1', '1rescue nil'
assert_equal '10000000000000000001/10000000000000000000',
'1.0000000000000000001r'
-assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input',
+assert_equal 'syntax error, unexpected tIDENTIFIER, expecting end-of-input',
%q{begin eval('1ir', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end}
-assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input',
+assert_equal 'syntax error, unexpected tIDENTIFIER, expecting end-of-input',
%q{begin eval('1.2ir', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end}
-assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input',
+assert_equal 'syntax error, unexpected tIDENTIFIER, expecting end-of-input',
%q{begin eval('1e1r', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end}
diff --git a/bootstraptest/test_objectspace.rb b/bootstraptest/test_objectspace.rb
index 63a8d99322..24a1a0ce2c 100644
--- a/bootstraptest/test_objectspace.rb
+++ b/bootstraptest/test_objectspace.rb
@@ -44,12 +44,3 @@ assert_normal_exit %q{
Thread.new {}
end
}, '[ruby-core:37858]'
-
-assert_equal 'ok', %q{
- objects_and_ids = 1000.times.map { o = Object.new; [o, o.object_id] }
- objects_and_ids.each { |expected, id|
- actual = ObjectSpace._id2ref(id)
- raise "expected #{expected.inspect}, got #{actual.inspect}" unless actual.equal?(expected)
- }
- 'ok'
-}
diff --git a/bootstraptest/test_proc.rb b/bootstraptest/test_proc.rb
index 1e384411dc..c23394e8d2 100644
--- a/bootstraptest/test_proc.rb
+++ b/bootstraptest/test_proc.rb
@@ -224,14 +224,14 @@ assert_equal %q{[[nil, []], [1, []], [1, [2]], [1, [2, 3]]]}, %q{
Proc.new{|a, *b| [a, b]}.call(1, 2, 3),
]
}
-assert_equal %q{1}, %q{
+assert_equal %q{0}, %q{
pr = proc{
$SAFE
}
$SAFE = 1
pr.call
}
-assert_equal %q{[1, 1]}, %q{
+assert_equal %q{[1, 0]}, %q{
pr = proc{
$SAFE += 1
}
diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb
index e7ddadf4a7..d16295de8b 100644
--- a/bootstraptest/test_thread.rb
+++ b/bootstraptest/test_thread.rb
@@ -1,14 +1,4 @@
-show_limit %q{
- threads = []
- begin
- threads << Thread.new{sleep}
-
- raise Exception, "skipping" if threads.count >= 10_000
- rescue Exception => error
- puts "Thread count: #{threads.count} (#{error})"
- break
- end while true
-} if false # disable to pass CI
+# Thread and Fiber
assert_equal %q{ok}, %q{
Thread.new{
@@ -46,7 +36,7 @@ begin
}
}
rescue ThreadError => e
- /can't create Thread/ =~ e.message ? :ok : e.message
+ :ok if /can't create Thread/ =~ e.message
end
}
assert_equal %q{ok}, %q{
@@ -60,7 +50,7 @@ begin
}
}
rescue ThreadError => e
- /can't create Thread/ =~ e.message ? :ok : e.message
+ :ok if /can't create Thread/ =~ e.message
end
}
assert_equal %q{ok}, %q{
@@ -309,6 +299,10 @@ assert_equal 'ok', %q{
}, '[ruby-dev:34492]'
assert_normal_exit %q{
+ at_exit { Fiber.new{}.resume }
+}
+
+assert_normal_exit %q{
g = enum_for(:local_variables)
loop { g.next }
}, '[ruby-dev:34128]'
@@ -334,6 +328,10 @@ assert_normal_exit %q{
}, '[ruby-dev:34128]'
assert_normal_exit %q{
+ Fiber.new(&Object.method(:class_eval)).resume("foo")
+}, '[ruby-dev:34128]'
+
+assert_normal_exit %q{
Thread.new("foo", &Object.method(:class_eval)).join
}, '[ruby-dev:34128]'
diff --git a/builtin.c b/builtin.c
deleted file mode 100644
index 6de77228d0..0000000000
--- a/builtin.c
+++ /dev/null
@@ -1,69 +0,0 @@
-#include "internal.h"
-#include "vm_core.h"
-#include "iseq.h"
-#include "builtin.h"
-
-#if CROSS_COMPILING
-
-#define INCLUDED_BY_BUILTIN_C 1
-#include "mini_builtin.c"
-
-#else
-
-#include "builtin_binary.inc"
-
-static const unsigned char*
-builtin_lookup(const char *feature, size_t *psize)
-{
- static int index = 0;
- int i = index++;
-
- // usually, `builtin_binary` order is loading order at miniruby.
- if (LIKELY(strcmp(builtin_binary[i].feature, feature) == 0)) {
- found:
- *psize = builtin_binary[i].bin_size;
- return builtin_binary[i].bin;
- }
- else {
- if (0) fprintf(stderr, "builtin_lookup: cached index miss (index:%d)\n", i);
- for (i=0; i<BUILTIN_BINARY_SIZE; i++) {
- if (strcmp(builtin_binary[i].feature, feature) == 0) {
- goto found;
- }
- }
- }
- rb_bug("builtin_lookup: can not find %s\n", feature);
-}
-
-void
-rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
-{
- // search binary
- size_t size;
- const unsigned char *bin = builtin_lookup(feature_name, &size);
-
- // load binary
- rb_vm_t *vm = GET_VM();
- if (vm->builtin_function_table != NULL) rb_bug("vm->builtin_function_table should be NULL.");
- vm->builtin_function_table = table;
- vm->builtin_inline_index = 0;
- const rb_iseq_t *iseq = rb_iseq_ibf_load_bytes((const char *)bin, size);
- vm->builtin_function_table = NULL;
-
- // exec
- rb_iseq_eval(rb_iseq_check(iseq));
-}
-
-#endif
-
-void
-Init_builtin(void)
-{
- // nothing
-}
-
-void
-Init_builtin_features(void)
-{
- rb_load_with_builtin_functions("gem_prelude", NULL);
-}
diff --git a/builtin.h b/builtin.h
deleted file mode 100644
index f4d485e08d..0000000000
--- a/builtin.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef BUILTIN_H_INCLUDED
-#define BUILTIN_H_INCLUDED
-
-// invoke
-
-struct rb_builtin_function {
- // for invocation
- const void * const func_ptr;
- const int argc;
-
- // for load
- const int index;
- const char * const name;
-};
-
-#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) { \
- .name = #_name, \
- .func_ptr = (void *)_fname, \
- .argc = _arity, \
- .index = _i \
-}
-
-void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
-
-#ifndef VM_CORE_H_EC_DEFINED
-typedef struct rb_execution_context_struct rb_execution_context_t;
-#endif
-
-/* The following code is generated by the following Ruby script:
-
-16.times{|i|
- args = (i > 0 ? ', ' : '') + (0...i).map{"VALUE"}.join(', ')
- puts "static inline void rb_builtin_function_check_arity#{i}(VALUE (*f)(rb_execution_context_t *ec, VALUE self#{args})){}"
-}
-*/
-
-static inline void rb_builtin_function_check_arity0(VALUE (*f)(rb_execution_context_t *ec, VALUE self)){}
-static inline void rb_builtin_function_check_arity1(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE)){}
-static inline void rb_builtin_function_check_arity2(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity3(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity4(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity5(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity6(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity7(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity8(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity9(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity10(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity11(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity12(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity13(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity14(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-static inline void rb_builtin_function_check_arity15(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
-
-VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
-
-// __builtin_inline!
-
-PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
-
-static inline VALUE
-rb_vm_lvar(rb_execution_context_t *ec, int index)
-{
-#if VM_CORE_H_EC_DEFINED
- return ec->cfp->ep[index];
-#else
- return rb_vm_lvar_exposed(ec, index);
-#endif
-}
-
-// dump/load
-
-struct builtin_binary {
- const char *feature; // feature name
- const unsigned char *bin; // binary by ISeq#to_binary
- size_t bin_size;
-};
-
-#endif // BUILTIN_H_INCLUDED
diff --git a/ccan/list/list.h b/ccan/list/list.h
index 7d219307bc..ca9f9f1f7f 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -57,7 +57,7 @@ struct list_head
* Example:
* static struct list_head my_list = LIST_HEAD_INIT(my_list);
*/
-#define LIST_HEAD_INIT(name) { { &(name).n, &(name).n } }
+#define LIST_HEAD_INIT(name) { { &name.n, &name.n } }
/**
* LIST_HEAD - define and initialize an empty list_head
@@ -238,21 +238,6 @@ static inline int list_empty_nodebug(const struct list_head *h)
#endif
/**
- * list_empty_nocheck - is a list empty?
- * @h: the list_head
- *
- * If the list is empty, returns true. This doesn't perform any
- * debug check for list consistency, so it can be called without
- * locks, racing with the list being modified. This is ok for
- * checks where an incorrect result is not an issue (optimized
- * bail out path for example).
- */
-static inline bool list_empty_nocheck(const struct list_head *h)
-{
- return h->n.next == &h->n;
-}
-
-/**
* list_del - delete an entry from an (unknown) linked list.
* @n: the list_node to delete from the list.
*
@@ -654,7 +639,7 @@ static inline void list_prepend_list_(struct list_head *to,
/**
* list_for_each_off - iterate through a list of memory regions.
* @h: the list_head
- * @i: the pointer to a memory region which contains list node data.
+ * @i: the pointer to a memory region wich contains list node data.
* @off: offset(relative to @i) at which list node data resides.
*
* This is a low-level wrapper to iterate @i over the entire list, used to
@@ -662,12 +647,12 @@ static inline void list_prepend_list_(struct list_head *to,
* so you can break and continue as normal.
*
* WARNING! Being the low-level macro that it is, this wrapper doesn't know
- * nor care about the type of @i. The only assumption made is that @i points
+ * nor care about the type of @i. The only assumtion made is that @i points
* to a chunk of memory that at some @offset, relative to @i, contains a
- * properly filled `struct list_node' which in turn contains pointers to
- * memory chunks and it's turtles all the way down. With all that in mind
+ * properly filled `struct node_list' which in turn contains pointers to
+ * memory chunks and it's turtles all the way down. Whith all that in mind
* remember that given the wrong pointer/offset couple this macro will
- * happily churn all you memory until SEGFAULT stops it, in other words
+ * happilly churn all you memory untill SEGFAULT stops it, in other words
* caveat emptor.
*
* It is worth mentioning that one of legitimate use-cases for that wrapper
@@ -686,7 +671,7 @@ static inline void list_prepend_list_(struct list_head *to,
/**
* list_for_each_rev_off - iterate through a list of memory regions backwards
* @h: the list_head
- * @i: the pointer to a memory region which contains list node data.
+ * @i: the pointer to a memory region wich contains list node data.
* @off: offset(relative to @i) at which list node data resides.
*
* See list_for_each_off for details
@@ -698,7 +683,7 @@ static inline void list_prepend_list_(struct list_head *to,
* list_for_each_safe_off - iterate through a list of memory regions, maybe
* during deletion
* @h: the list_head
- * @i: the pointer to a memory region which contains list node data.
+ * @i: the pointer to a memory region wich contains list node data.
* @nxt: the structure containing the list_node
* @off: offset(relative to @i) at which list node data resides.
*
@@ -717,7 +702,7 @@ static inline void list_prepend_list_(struct list_head *to,
* list_for_each_rev_safe_off - iterate backwards through a list of
* memory regions, maybe during deletion
* @h: the list_head
- * @i: the pointer to a memory region which contains list node data.
+ * @i: the pointer to a memory region wich contains list node data.
* @nxt: the structure containing the list_node
* @off: offset(relative to @i) at which list node data resides.
*
diff --git a/class.c b/class.c
index f17e7f053a..364f258333 100644
--- a/class.c
+++ b/class.c
@@ -32,9 +32,6 @@
#define id_attached id__attached__
-#define METACLASS_OF(k) RBASIC(k)->klass
-#define SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls)
-
void
rb_class_subclass_add(VALUE super, VALUE klass)
{
@@ -179,7 +176,7 @@ class_alloc(VALUE flags, VALUE klass)
*/
RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj);
RCLASS_SERIAL(obj) = rb_next_class_serial();
- RB_OBJ_WRITE(obj, &RCLASS_REFINED_CLASS(obj), Qnil);
+ RCLASS_REFINED_CLASS(obj) = Qnil;
RCLASS_EXT(obj)->allocator = 0;
return (VALUE)obj;
@@ -208,6 +205,7 @@ rb_class_boot(VALUE super)
RCLASS_SET_SUPER(klass, super);
RCLASS_M_TBL_INIT(klass);
+ OBJ_INFECT(klass, super);
return (VALUE)klass;
}
@@ -315,12 +313,6 @@ class_init_copy_check(VALUE clone, VALUE orig)
VALUE
rb_mod_init_copy(VALUE clone, VALUE orig)
{
- /* cloned flag is refer at constant inline cache
- * see vm_get_const_key_cref() in vm_insnhelper.c
- */
- FL_SET(clone, RCLASS_CLONED);
- FL_SET(orig , RCLASS_CLONED);
-
if (RB_TYPE_P(clone, T_CLASS)) {
class_init_copy_check(clone, orig);
}
@@ -343,7 +335,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
if (RCLASS_IV_TBL(orig)) {
st_data_t id;
- rb_iv_tbl_copy(clone, orig);
+ RCLASS_IV_TBL(clone) = rb_st_copy(clone, RCLASS_IV_TBL(orig));
CONST_ID(id, "__tmp_classpath__");
st_delete(RCLASS_IV_TBL(clone), &id, 0);
CONST_ID(id, "__classpath__");
@@ -375,41 +367,28 @@ rb_singleton_class_clone(VALUE obj)
return rb_singleton_class_clone_and_attach(obj, Qundef);
}
-// Clone and return the singleton class of `obj` if it has been created and is attached to `obj`.
VALUE
rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
{
const VALUE klass = RBASIC(obj)->klass;
- // Note that `rb_singleton_class()` can create situations where `klass` is
- // attached to an object other than `obj`. In which case `obj` does not have
- // a material singleton class attached yet and there is no singleton class
- // to clone.
- if (!(FL_TEST(klass, FL_SINGLETON) && rb_attr_get(klass, id_attached) == obj)) {
- // nothing to clone
- return klass;
- }
+ if (!FL_TEST(klass, FL_SINGLETON))
+ return klass;
else {
/* copy singleton(unnamed) class */
- bool klass_of_clone_is_new;
VALUE clone = class_alloc(RBASIC(klass)->flags, 0);
if (BUILTIN_TYPE(obj) == T_CLASS) {
- klass_of_clone_is_new = true;
RBASIC_SET_CLASS(clone, clone);
}
else {
- VALUE klass_metaclass_clone = rb_singleton_class_clone(klass);
- // When `METACLASS_OF(klass) == klass_metaclass_clone`, it means the
- // recursive call did not clone `METACLASS_OF(klass)`.
- klass_of_clone_is_new = (METACLASS_OF(klass) != klass_metaclass_clone);
- RBASIC_SET_CLASS(clone, klass_metaclass_clone);
+ RBASIC_SET_CLASS(clone, rb_singleton_class_clone(klass));
}
RCLASS_SET_SUPER(clone, RCLASS_SUPER(klass));
RCLASS_EXT(clone)->allocator = RCLASS_EXT(klass)->allocator;
if (RCLASS_IV_TBL(klass)) {
- rb_iv_tbl_copy(clone, klass);
+ RCLASS_IV_TBL(clone) = rb_st_copy(clone, RCLASS_IV_TBL(klass));
}
if (RCLASS_CONST_TBL(klass)) {
struct clone_const_arg arg;
@@ -427,9 +406,7 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
arg.new_klass = clone;
rb_id_table_foreach(RCLASS_M_TBL(klass), clone_method_i, &arg);
}
- if (klass_of_clone_is_new) {
- rb_singleton_class_attached(RBASIC(clone)->klass, clone);
- }
+ rb_singleton_class_attached(RBASIC(clone)->klass, clone);
FL_SET(clone, FL_SINGLETON);
return clone;
@@ -451,6 +428,11 @@ rb_singleton_class_attached(VALUE klass, VALUE obj)
}
}
+
+
+#define METACLASS_OF(k) RBASIC(k)->klass
+#define SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls)
+
/*!
* whether k is a meta^(n)-class of Class class
* @retval 1 if \a k is a meta^(n)-class of Class class (n >= 0)
@@ -523,6 +505,8 @@ make_metaclass(VALUE klass)
while (RB_TYPE_P(super, T_ICLASS)) super = RCLASS_SUPER(super);
RCLASS_SET_SUPER(metaclass, super ? ENSURE_EIGENCLASS(super) : rb_cClass);
+ OBJ_INFECT(metaclass, RCLASS_SUPER(metaclass));
+
return metaclass;
}
@@ -553,8 +537,8 @@ boot_defclass(const char *name, VALUE super)
VALUE obj = rb_class_boot(super);
ID id = rb_intern(name);
+ rb_name_class(obj, id);
rb_const_set((rb_cObject ? rb_cObject : obj), id, obj);
- rb_vm_add_root_module(id, obj);
return obj;
}
@@ -566,7 +550,7 @@ Init_class_hierarchy(void)
rb_gc_register_mark_object(rb_cObject);
/* resolve class name ASAP for order-independence */
- rb_set_class_path_string(rb_cObject, rb_cObject, rb_fstring_lit("Object"));
+ rb_class_name(rb_cObject);
rb_cModule = boot_defclass("Module", rb_cObject);
rb_cClass = boot_defclass("Class", rb_cModule);
@@ -632,7 +616,7 @@ rb_define_class_id(ID id, VALUE super)
* \return the value \c Class#inherited's returns
* \pre Each of \a super and \a klass must be a \c Class object.
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_class_inherited(VALUE super, VALUE klass)
{
ID inherited;
@@ -674,9 +658,6 @@ rb_define_class(const char *name, VALUE super)
if (rb_class_real(RCLASS_SUPER(klass)) != super) {
rb_raise(rb_eTypeError, "superclass mismatch for class %s", name);
}
-
- /* Class may have been defined in Ruby and not pin-rooted */
- rb_vm_add_root_module(id, klass);
return klass;
}
if (!super) {
@@ -684,6 +665,7 @@ rb_define_class(const char *name, VALUE super)
}
klass = rb_define_class_id(id, super);
rb_vm_add_root_module(id, klass);
+ rb_name_class(klass, id);
rb_const_set(rb_cObject, id, klass);
rb_class_inherited(super, klass);
@@ -748,9 +730,6 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
" (%"PRIsVALUE" is given but was %"PRIsVALUE")",
outer, rb_id2str(id), RCLASS_SUPER(klass), super);
}
- /* Class may have been defined in Ruby and not pin-rooted */
- rb_vm_add_root_module(id, klass);
-
return klass;
}
if (!super) {
@@ -761,7 +740,6 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
rb_set_class_path_string(klass, outer, rb_id2str(id));
rb_const_set(outer, id, klass);
rb_class_inherited(super, klass);
- rb_vm_add_root_module(id, klass);
rb_gc_register_mark_object(klass);
return klass;
@@ -778,7 +756,12 @@ rb_module_new(void)
VALUE
rb_define_module_id(ID id)
{
- return rb_module_new();
+ VALUE mdl;
+
+ mdl = rb_module_new();
+ rb_name_class(mdl, id);
+
+ return mdl;
}
VALUE
@@ -794,13 +777,10 @@ rb_define_module(const char *name)
rb_raise(rb_eTypeError, "%s is not a module (%"PRIsVALUE")",
name, rb_obj_class(module));
}
- /* Module may have been defined in Ruby and not pin-rooted */
- rb_vm_add_root_module(id, module);
return module;
}
module = rb_define_module_id(id);
rb_vm_add_root_module(id, module);
- rb_gc_register_mark_object(module);
rb_const_set(rb_cObject, id, module);
return module;
@@ -839,10 +819,6 @@ rb_include_class_new(VALUE module, VALUE super)
{
VALUE klass = class_alloc(T_ICLASS, rb_cClass);
- RCLASS_M_TBL(OBJ_WB_UNPROTECT(klass)) =
- RCLASS_M_TBL(OBJ_WB_UNPROTECT(module)); /* TODO: unprotected? */
-
- RCLASS_SET_ORIGIN(klass, module == RCLASS_ORIGIN(module) ? klass : RCLASS_ORIGIN(module));
if (BUILTIN_TYPE(module) == T_ICLASS) {
module = RBASIC(module)->klass;
}
@@ -855,6 +831,9 @@ rb_include_class_new(VALUE module, VALUE super)
RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
+ RCLASS_M_TBL(OBJ_WB_UNPROTECT(klass)) =
+ RCLASS_M_TBL(OBJ_WB_UNPROTECT(RCLASS_ORIGIN(module))); /* TODO: unprotected? */
+
RCLASS_SET_SUPER(klass, super);
if (RB_TYPE_P(module, T_ICLASS)) {
RBASIC_SET_CLASS(klass, RBASIC(module)->klass);
@@ -862,6 +841,8 @@ rb_include_class_new(VALUE module, VALUE super)
else {
RBASIC_SET_CLASS(klass, module);
}
+ OBJ_INFECT(klass, module);
+ OBJ_INFECT(klass, super);
return (VALUE)klass;
}
@@ -871,11 +852,12 @@ static int include_modules_at(const VALUE klass, VALUE c, VALUE module, int sear
static void
ensure_includable(VALUE klass, VALUE module)
{
- rb_class_modify_check(klass);
+ rb_frozen_class_p(klass);
Check_Type(module, T_MODULE);
if (!NIL_P(rb_refinement_module_get_refined_class(module))) {
rb_raise(rb_eArgError, "refinement module is not allowed");
}
+ OBJ_INFECT(klass, module);
}
void
@@ -897,8 +879,6 @@ add_refined_method_entry_i(ID key, VALUE value, void *data)
return ID_TABLE_CONTINUE;
}
-static void ensure_origin(VALUE klass);
-
static int
include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super)
{
@@ -906,27 +886,20 @@ include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super)
int method_changed = 0, constant_changed = 0;
struct rb_id_table *const klass_m_tbl = RCLASS_M_TBL(RCLASS_ORIGIN(klass));
- if (FL_TEST(module, RCLASS_REFINED_BY_ANY)) {
- ensure_origin(module);
- }
-
while (module) {
- int origin_seen = FALSE;
int superclass_seen = FALSE;
struct rb_id_table *tbl;
- if (klass == c)
- origin_seen = TRUE;
+ if (RCLASS_ORIGIN(module) != module)
+ goto skip;
if (klass_m_tbl && klass_m_tbl == RCLASS_M_TBL(module))
return -1;
/* ignore if the module included already in superclasses */
for (p = RCLASS_SUPER(klass); p; p = RCLASS_SUPER(p)) {
int type = BUILTIN_TYPE(p);
- if (c == p)
- origin_seen = TRUE;
if (type == T_ICLASS) {
if (RCLASS_M_TBL(p) == RCLASS_M_TBL(module)) {
- if (!superclass_seen && origin_seen) {
+ if (!superclass_seen) {
c = p; /* move insertion point */
}
goto skip;
@@ -939,7 +912,6 @@ include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super)
}
iclass = rb_include_class_new(module, RCLASS_SUPER(c));
c = RCLASS_SET_SUPER(c, iclass);
- RCLASS_SET_INCLUDER(iclass, klass);
{
VALUE m = module;
@@ -997,10 +969,15 @@ move_refined_method(ID key, VALUE value, void *data)
}
}
-static void
-ensure_origin(VALUE klass)
+void
+rb_prepend_module(VALUE klass, VALUE module)
{
- VALUE origin = RCLASS_ORIGIN(klass);
+ VALUE origin;
+ int changed = 0;
+
+ ensure_includable(klass, module);
+
+ origin = RCLASS_ORIGIN(klass);
if (origin == klass) {
origin = class_alloc(T_ICLASS, klass);
OBJ_WB_UNPROTECT(origin); /* TODO: conservative shading. Need more survey. */
@@ -1011,15 +988,6 @@ ensure_origin(VALUE klass)
RCLASS_M_TBL_INIT(klass);
rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)klass);
}
-}
-
-void
-rb_prepend_module(VALUE klass, VALUE module)
-{
- int changed = 0;
-
- ensure_includable(klass, module);
- ensure_origin(klass);
changed = include_modules_at(klass, klass, module, FALSE);
if (changed < 0)
rb_raise(rb_eArgError, "cyclic prepend detected");
@@ -1119,11 +1087,10 @@ rb_mod_ancestors(VALUE mod)
VALUE p, ary = rb_ary_new();
for (p = mod; p; p = RCLASS_SUPER(p)) {
- if (p != RCLASS_ORIGIN(p)) continue;
if (BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);
}
- else {
+ else if (p == RCLASS_ORIGIN(p)) {
rb_ary_push(ary, p);
}
}
@@ -1195,7 +1162,7 @@ method_entry_i(ID key, VALUE value, void *data)
if (!me) return ID_TABLE_CONTINUE;
if (!arg->recur && me->owner != owner) return ID_TABLE_CONTINUE;
}
- if (!st_is_member(arg->list, key)) {
+ if (!st_lookup(arg->list, key, 0)) {
if (UNDEFINED_METHOD_ENTRY_P(me)) {
type = METHOD_VISI_UNDEF; /* none */
}
@@ -1207,39 +1174,20 @@ method_entry_i(ID key, VALUE value, void *data)
return ID_TABLE_CONTINUE;
}
-static void
-add_instance_method_list(VALUE mod, struct method_entry_arg *me_arg)
-{
- struct rb_id_table *m_tbl = RCLASS_M_TBL(mod);
- if (!m_tbl) return;
- rb_id_table_foreach(m_tbl, method_entry_i, me_arg);
-}
-
-static bool
-particular_class_p(VALUE mod)
-{
- if (!mod) return false;
- if (FL_TEST(mod, FL_SINGLETON)) return true;
- if (BUILTIN_TYPE(mod) == T_ICLASS) return true;
- return false;
-}
-
static VALUE
class_instance_method_list(int argc, const VALUE *argv, VALUE mod, int obj, int (*func) (st_data_t, st_data_t, st_data_t))
{
VALUE ary;
- int recur = TRUE, prepended = 0;
+ int recur, prepended = 0;
struct method_entry_arg me_arg;
- if (rb_check_arity(argc, 0, 1)) recur = RTEST(argv[0]);
-
- me_arg.list = st_init_numtable();
- me_arg.recur = recur;
-
- if (obj) {
- for (; particular_class_p(mod); mod = RCLASS_SUPER(mod)) {
- add_instance_method_list(mod, &me_arg);
- }
+ if (argc == 0) {
+ recur = TRUE;
+ }
+ else {
+ VALUE r;
+ rb_scan_args(argc, argv, "01", &r);
+ recur = RTEST(r);
}
if (!recur && RCLASS_ORIGIN(mod) != mod) {
@@ -1247,12 +1195,15 @@ class_instance_method_list(int argc, const VALUE *argv, VALUE mod, int obj, int
prepended = 1;
}
+ me_arg.list = st_init_numtable();
+ me_arg.recur = recur;
for (; mod; mod = RCLASS_SUPER(mod)) {
- add_instance_method_list(mod, &me_arg);
+ if (RCLASS_M_TBL(mod)) rb_id_table_foreach(RCLASS_M_TBL(mod), method_entry_i, &me_arg);
if (BUILTIN_TYPE(mod) == T_ICLASS && !prepended) continue;
+ if (obj && FL_TEST(mod, FL_SINGLETON)) continue;
if (!recur) break;
}
- ary = rb_ary_new2(me_arg.list->num_entries);
+ ary = rb_ary_new();
st_foreach(me_arg.list, func, ary);
st_free_table(me_arg.list);
@@ -1353,7 +1304,7 @@ rb_class_public_instance_methods(int argc, const VALUE *argv, VALUE mod)
* <i>obj</i>. This will include all the methods accessible in
* <i>obj</i>'s ancestors.
* If the optional parameter is <code>false</code>, it
- * returns an array of <i>obj</i>'s public and protected singleton methods,
+ * returns an array of <i>obj<i>'s public and protected singleton methods,
* the array will not include methods in modules included in <i>obj</i>.
*
* class Klass
@@ -1466,30 +1417,31 @@ rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj)
VALUE
rb_obj_singleton_methods(int argc, const VALUE *argv, VALUE obj)
{
- VALUE ary, klass, origin;
+ VALUE recur, ary, klass, origin;
struct method_entry_arg me_arg;
struct rb_id_table *mtbl;
- int recur = TRUE;
- if (rb_check_arity(argc, 0, 1)) recur = RTEST(argv[0]);
- if (RB_TYPE_P(obj, T_CLASS) && FL_TEST(obj, FL_SINGLETON)) {
- rb_singleton_class(obj);
+ if (argc == 0) {
+ recur = Qtrue;
+ }
+ else {
+ rb_scan_args(argc, argv, "01", &recur);
}
klass = CLASS_OF(obj);
origin = RCLASS_ORIGIN(klass);
me_arg.list = st_init_numtable();
- me_arg.recur = recur;
+ me_arg.recur = RTEST(recur);
if (klass && FL_TEST(klass, FL_SINGLETON)) {
if ((mtbl = RCLASS_M_TBL(origin)) != 0) rb_id_table_foreach(mtbl, method_entry_i, &me_arg);
klass = RCLASS_SUPER(klass);
}
- if (recur) {
+ if (RTEST(recur)) {
while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) {
if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0) rb_id_table_foreach(mtbl, method_entry_i, &me_arg);
klass = RCLASS_SUPER(klass);
}
}
- ary = rb_ary_new2(me_arg.list->num_entries);
+ ary = rb_ary_new();
st_foreach(me_arg.list, ins_methods_i, ary);
st_free_table(me_arg.list);
@@ -1553,36 +1505,24 @@ rb_obj_singleton_methods(int argc, const VALUE *argv, VALUE obj)
* \{
*/
-#ifdef rb_define_method_id
-#undef rb_define_method_id
-#endif
void
rb_define_method_id(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc)
{
rb_add_method_cfunc(klass, mid, func, argc, METHOD_VISI_PUBLIC);
}
-#ifdef rb_define_method
-#undef rb_define_method
-#endif
void
rb_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc)
{
rb_add_method_cfunc(klass, rb_intern(name), func, argc, METHOD_VISI_PUBLIC);
}
-#ifdef rb_define_protected_method
-#undef rb_define_protected_method
-#endif
void
rb_define_protected_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc)
{
rb_add_method_cfunc(klass, rb_intern(name), func, argc, METHOD_VISI_PROTECTED);
}
-#ifdef rb_define_private_method
-#undef rb_define_private_method
-#endif
void
rb_define_private_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc)
{
@@ -1683,6 +1623,12 @@ singleton_class_of(VALUE obj)
RCLASS_SERIAL(klass) = serial;
}
+ if (OBJ_TAINTED(obj)) {
+ OBJ_TAINT(klass);
+ }
+ else {
+ FL_UNSET(klass, FL_TAINT);
+ }
RB_FL_SET_RAW(klass, RB_OBJ_FROZEN_RAW(obj));
return klass;
@@ -1759,9 +1705,6 @@ rb_singleton_class(VALUE obj)
* \{
*/
-#ifdef rb_define_singleton_method
-#undef rb_define_singleton_method
-#endif
/*!
* Defines a singleton method for \a obj.
* \param obj an arbitrary object
@@ -1775,9 +1718,8 @@ rb_define_singleton_method(VALUE obj, const char *name, VALUE (*func)(ANYARGS),
rb_define_method(singleton_class_of(obj), name, func, argc);
}
-#ifdef rb_define_module_function
-#undef rb_define_module_function
-#endif
+
+
/*!
* Defines a module function for \a module.
* \param module an module or a class.
@@ -1792,9 +1734,7 @@ rb_define_module_function(VALUE module, const char *name, VALUE (*func)(ANYARGS)
rb_define_singleton_method(module, name, func, argc);
}
-#ifdef rb_define_global_function
-#undef rb_define_global_function
-#endif
+
/*!
* Defines a global function
* \param name name of the function
@@ -1833,17 +1773,19 @@ rb_define_attr(VALUE klass, const char *name, int read, int write)
rb_attr(klass, rb_intern(name), read, write, FALSE);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_keyword_error_new(const char *error, VALUE keys)
{
+ const VALUE *ptr = RARRAY_CONST_PTR(keys);
long i = 0, len = RARRAY_LEN(keys);
VALUE error_message = rb_sprintf("%s keyword%.*s", error, len > 1, "s");
if (len > 0) {
rb_str_cat_cstr(error_message, ": ");
while (1) {
- const VALUE k = RARRAY_AREF(keys, i);
- rb_str_append(error_message, rb_inspect(k));
+ const VALUE k = ptr[i];
+ Check_Type(k, T_SYMBOL); /* wrong hash is given to rb_get_kwargs */
+ rb_str_append(error_message, rb_sym2str(k));
if (++i >= len) break;
rb_str_cat_cstr(error_message, ", ");
}
@@ -1863,19 +1805,20 @@ NORETURN(static void unknown_keyword_error(VALUE hash, const ID *table, int keyw
static void
unknown_keyword_error(VALUE hash, const ID *table, int keywords)
{
+ st_table *tbl = rb_hash_tbl_raw(hash);
int i;
for (i = 0; i < keywords; i++) {
st_data_t key = ID2SYM(table[i]);
- rb_hash_stlike_delete(hash, &key, NULL);
+ st_delete(tbl, &key, NULL);
}
rb_keyword_error("unknown", rb_hash_keys(hash));
}
-
static int
separate_symbol(st_data_t key, st_data_t value, st_data_t arg)
{
VALUE *kwdhash = (VALUE *)arg;
+
if (!SYMBOL_P(key)) kwdhash++;
if (!*kwdhash) *kwdhash = rb_hash_new();
rb_hash_aset(*kwdhash, (VALUE)key, (VALUE)value);
@@ -1892,10 +1835,10 @@ rb_extract_keywords(VALUE *orighash)
*orighash = 0;
return hash;
}
- rb_hash_foreach(hash, separate_symbol, (st_data_t)&parthash);
+ st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&parthash);
*orighash = parthash[1];
if (parthash[1] && RBASIC_CLASS(hash) != rb_cHash) {
- RBASIC_SET_CLASS(parthash[1], RBASIC_CLASS(hash));
+ RBASIC_SET_CLASS(parthash[1], RBASIC_CLASS(hash));
}
return parthash[0];
}
@@ -1910,8 +1853,8 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
#define extract_kwarg(keyword, val) \
(key = (st_data_t)(keyword), values ? \
- (rb_hash_stlike_delete(keyword_hash, &key, &(val)) || ((val) = Qundef, 0)) : \
- rb_hash_stlike_lookup(keyword_hash, key, NULL))
+ st_delete(rb_hash_tbl_raw(keyword_hash), &key, (val)) : \
+ st_lookup(rb_hash_tbl_raw(keyword_hash), key, (val)))
if (NIL_P(keyword_hash)) keyword_hash = 0;
@@ -1919,11 +1862,18 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
rest = 1;
optional = -1-optional;
}
+ if (values) {
+ for (j = 0; j < required + optional; j++) {
+ values[j] = Qundef;
+ }
+ }
if (required) {
for (; i < required; i++) {
VALUE keyword = ID2SYM(table[i]);
if (keyword_hash) {
- if (extract_kwarg(keyword, values[i])) {
+ st_data_t val;
+ if (extract_kwarg(keyword, &val)) {
+ if (values) values[i] = (VALUE)val;
continue;
}
}
@@ -1937,7 +1887,9 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
j = i;
if (optional && keyword_hash) {
for (i = 0; i < optional; i++) {
- if (extract_kwarg(ID2SYM(table[required+i]), values[required+i])) {
+ st_data_t val;
+ if (extract_kwarg(ID2SYM(table[required+i]), &val)) {
+ if (values) values[required+i] = (VALUE)val;
j++;
}
}
@@ -1947,181 +1899,89 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
unknown_keyword_error(keyword_hash, table, required+optional);
}
}
- if (values && !keyword_hash) {
- for (i = 0; i < required + optional; i++) {
- values[i] = Qundef;
- }
- }
return j;
#undef extract_kwarg
}
-struct rb_scan_args_t {
- int argc;
- const VALUE *argv;
- va_list vargs;
- int f_var;
- int f_hash;
- int f_block;
- int n_lead;
- int n_opt;
- int n_trail;
- int n_mand;
- int argi;
- int last_idx;
- VALUE hash;
- VALUE last_hash;
- VALUE *tmp_buffer;
-};
-
-static void
-rb_scan_args_parse(int kw_flag, int argc, const VALUE *argv, const char *fmt, struct rb_scan_args_t *arg)
+#undef rb_scan_args
+int
+rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
{
+ int i;
const char *p = fmt;
- VALUE *tmp_buffer = arg->tmp_buffer;
- int keyword_given = 0;
- int empty_keyword_given = 0;
- int last_hash_keyword = 0;
-
- memset(arg, 0, sizeof(*arg));
- arg->last_idx = -1;
- arg->hash = Qnil;
-
- switch (kw_flag) {
- case RB_SCAN_ARGS_PASS_CALLED_KEYWORDS:
- if (!(keyword_given = rb_keyword_given_p())) {
- empty_keyword_given = rb_empty_keyword_given_p();
- }
- break;
- case RB_SCAN_ARGS_KEYWORDS:
- keyword_given = 1;
- break;
- case RB_SCAN_ARGS_EMPTY_KEYWORDS:
- empty_keyword_given = 1;
- break;
- case RB_SCAN_ARGS_LAST_HASH_KEYWORDS:
- last_hash_keyword = 1;
- break;
- }
+ VALUE *var;
+ va_list vargs;
+ int f_var = 0, f_hash = 0, f_block = 0;
+ int n_lead = 0, n_opt = 0, n_trail = 0, n_mand;
+ int argi = 0, last_idx = -1;
+ VALUE hash = Qnil, last_hash = 0;
if (ISDIGIT(*p)) {
- arg->n_lead = *p - '0';
+ n_lead = *p - '0';
p++;
if (ISDIGIT(*p)) {
- arg->n_opt = *p - '0';
+ n_opt = *p - '0';
p++;
}
}
if (*p == '*') {
- arg->f_var = 1;
+ f_var = 1;
p++;
}
if (ISDIGIT(*p)) {
- arg->n_trail = *p - '0';
+ n_trail = *p - '0';
p++;
}
if (*p == ':') {
- arg->f_hash = 1;
+ f_hash = 1;
p++;
}
if (*p == '&') {
- arg->f_block = 1;
+ f_block = 1;
p++;
}
if (*p != '\0') {
rb_fatal("bad scan arg format: %s", fmt);
}
- arg->n_mand = arg->n_lead + arg->n_trail;
+ n_mand = n_lead + n_trail;
- /* capture an option hash - phase 1: pop */
- /* Ignore final positional hash if empty keywords given */
- if (argc > 0 && !(arg->f_hash && empty_keyword_given)) {
- VALUE last = argv[argc - 1];
-
- if (arg->f_hash && arg->n_mand < argc) {
- if (keyword_given) {
- if (!RB_TYPE_P(last, T_HASH)) {
- rb_warn("Keyword flag set when calling rb_scan_args, but last entry is not a hash");
- }
- else {
- arg->hash = last;
- }
- }
- else if (NIL_P(last)) {
- /* For backwards compatibility, nil is taken as an empty
- option hash only if it is not ambiguous; i.e. '*' is
- not specified and arguments are given more than sufficient.
- This will be removed in Ruby 3. */
- if (!arg->f_var && arg->n_mand + arg->n_opt < argc) {
- rb_warn("The last argument is nil, treating as empty keywords");
- argc--;
- }
- }
- else {
- arg->hash = rb_check_hash_type(last);
- }
-
- /* Ruby 3: Remove if branch, as it will not attempt to split hashes */
- if (!NIL_P(arg->hash)) {
- VALUE opts = rb_extract_keywords(&arg->hash);
-
- if (!(arg->last_hash = arg->hash)) {
- if (!keyword_given && !last_hash_keyword) {
- /* Warn if treating positional as keyword, as in Ruby 3,
- this will be an error */
- rb_warn("Using the last argument as keyword parameters is deprecated");
- }
- argc--;
- }
- else {
- /* Warn if splitting either positional hash to keywords or keywords
- to positional hash, as in Ruby 3, no splitting will be done */
- rb_warn("The last argument is split into positional and keyword parameters");
- arg->last_idx = argc - 1;
- }
- arg->hash = opts ? opts : Qnil;
- }
- }
- else if (arg->f_hash && keyword_given && arg->n_mand == argc) {
- /* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
- rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
- }
- }
- if (arg->f_hash && arg->n_mand == argc+1 && empty_keyword_given) {
- VALUE *ptr = rb_alloc_tmp_buffer2(tmp_buffer, argc+1, sizeof(VALUE));
- memcpy(ptr, argv, sizeof(VALUE)*argc);
- ptr[argc] = rb_hash_new();
- argc++;
- *(&argv) = ptr;
- rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
- }
-
- arg->argc = argc;
- arg->argv = argv;
-}
+ if (argc < n_mand)
+ goto argc_error;
-static int
-rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs)
-{
- int argi = 0;
- int i;
- VALUE *var;
+ va_start(vargs, fmt);
- if (arg->argc < arg->n_mand) {
- return 1;
+ /* capture an option hash - phase 1: pop */
+ if (f_hash && n_mand < argc) {
+ VALUE last = argv[argc - 1];
+
+ if (NIL_P(last)) {
+ /* nil is taken as an empty option hash only if it is not
+ ambiguous; i.e. '*' is not specified and arguments are
+ given more than sufficient */
+ if (!f_var && n_mand + n_opt < argc)
+ argc--;
+ }
+ else {
+ hash = rb_check_hash_type(last);
+ if (!NIL_P(hash)) {
+ VALUE opts = rb_extract_keywords(&hash);
+ if (!(last_hash = hash)) argc--;
+ else last_idx = argc - 1;
+ hash = opts ? opts : Qnil;
+ }
+ }
}
-
/* capture leading mandatory arguments */
- for (i = arg->n_lead; i-- > 0; ) {
+ for (i = n_lead; i-- > 0; ) {
var = va_arg(vargs, VALUE *);
- if (var) *var = (argi == arg->last_idx) ? arg->last_hash : arg->argv[argi];
+ if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
argi++;
}
/* capture optional arguments */
- for (i = arg->n_opt; i-- > 0; ) {
+ for (i = n_opt; i-- > 0; ) {
var = va_arg(vargs, VALUE *);
- if (argi < arg->argc - arg->n_trail) {
- if (var) *var = (argi == arg->last_idx) ? arg->last_hash : arg->argv[argi];
+ if (argi < argc - n_trail) {
+ if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
argi++;
}
else {
@@ -2129,15 +1989,15 @@ rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs)
}
}
/* capture variable length arguments */
- if (arg->f_var) {
- int n_var = arg->argc - argi - arg->n_trail;
+ if (f_var) {
+ int n_var = argc - argi - n_trail;
var = va_arg(vargs, VALUE *);
if (0 < n_var) {
if (var) {
- int f_last = (arg->last_idx + 1 == arg->argc - arg->n_trail);
- *var = rb_ary_new4(n_var - f_last, &arg->argv[argi]);
- if (f_last) rb_ary_push(*var, arg->last_hash);
+ int f_last = (last_idx + 1 == argc - n_trail);
+ *var = rb_ary_new4(n_var-f_last, &argv[argi]);
+ if (f_last) rb_ary_push(*var, last_hash);
}
argi += n_var;
}
@@ -2146,18 +2006,18 @@ rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs)
}
}
/* capture trailing mandatory arguments */
- for (i = arg->n_trail; i-- > 0; ) {
+ for (i = n_trail; i-- > 0; ) {
var = va_arg(vargs, VALUE *);
- if (var) *var = (argi == arg->last_idx) ? arg->last_hash : arg->argv[argi];
+ if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
argi++;
}
/* capture an option hash - phase 2: assignment */
- if (arg->f_hash) {
+ if (f_hash) {
var = va_arg(vargs, VALUE *);
- if (var) *var = arg->hash;
+ if (var) *var = hash;
}
/* capture iterator block */
- if (arg->f_block) {
+ if (f_block) {
var = va_arg(vargs, VALUE *);
if (rb_block_given_p()) {
*var = rb_block_proc();
@@ -2166,53 +2026,14 @@ rb_scan_args_assign(struct rb_scan_args_t *arg, va_list vargs)
*var = Qnil;
}
}
-
- if (argi < arg->argc) return 1;
-
- return 0;
-}
-
-#undef rb_scan_args
-int
-rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
-{
- int error;
- va_list vargs;
- VALUE tmp_buffer = 0;
- struct rb_scan_args_t arg;
- arg.tmp_buffer = &tmp_buffer;
- rb_scan_args_parse(RB_SCAN_ARGS_PASS_CALLED_KEYWORDS, argc, argv, fmt, &arg);
- va_start(vargs,fmt);
- error = rb_scan_args_assign(&arg, vargs);
va_end(vargs);
- if (tmp_buffer) {
- rb_free_tmp_buffer(&tmp_buffer);
- }
- if (error) {
- rb_error_arity(arg.argc, arg.n_mand, arg.f_var ? UNLIMITED_ARGUMENTS : arg.n_mand + arg.n_opt);
- }
- return arg.argc;
-}
-int
-rb_scan_args_kw(int kw_flag, int argc, const VALUE *argv, const char *fmt, ...)
-{
- int error;
- va_list vargs;
- VALUE tmp_buffer = 0;
- struct rb_scan_args_t arg;
- arg.tmp_buffer = &tmp_buffer;
- rb_scan_args_parse(kw_flag, argc, argv, fmt, &arg);
- va_start(vargs,fmt);
- error = rb_scan_args_assign(&arg, vargs);
- va_end(vargs);
- if (tmp_buffer) {
- rb_free_tmp_buffer(&tmp_buffer);
- }
- if (error) {
- rb_error_arity(arg.argc, arg.n_mand, arg.f_var ? UNLIMITED_ARGUMENTS : arg.n_mand + arg.n_opt);
+ if (argi < argc) {
+ argc_error:
+ rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
}
- return arg.argc;
+
+ return argc;
}
int
diff --git a/common.mk b/common.mk
index fd14ab6688..2175f67eba 100644
--- a/common.mk
+++ b/common.mk
@@ -1,10 +1,8 @@
-# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
-
bin: $(PROGRAM) $(WPROGRAM)
lib: $(LIBRUBY)
dll: $(LIBRUBY_SO)
-.SUFFIXES: .rbinc .rb .inc .h .c .y .i .$(ASMEXT) .$(DTRACE_EXT)
+.SUFFIXES: .inc .h .c .y .i .$(DTRACE_EXT)
# V=0 quiet, V=1 verbose. other values don't work.
V = 0
@@ -17,9 +15,8 @@ mflags = $(MFLAGS)
gnumake_recursive =
enable_shared = $(ENABLE_SHARED:no=)
-UNICODE_VERSION = 12.1.0
-UNICODE_EMOJI_VERSION = 12.1
-UNICODE_BETA = NO
+UNICODE_VERSION = 10.0.0
+UNICODE_EMOJI_VERSION = 5.0
### set the following environment variable or uncomment the line if
### the Unicode data files should be updated completely on every update ('make up',...).
@@ -38,51 +35,42 @@ RUBYLIB = $(PATH_SEPARATOR)
RUBYOPT = -
RUN_OPTS = --disable-gems
-GITPULLOPTIONS = --rebase
-
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(UNICODE_HDR_DIR)
GEM_HOME =
GEM_PATH =
GEM_VENDOR =
-BENCHMARK_DRIVER_GIT_URL = https://github.com/benchmark-driver/benchmark-driver
-BENCHMARK_DRIVER_GIT_REF = v0.15.6
-SIMPLECOV_GIT_URL = https://github.com/colszowka/simplecov.git
-SIMPLECOV_GIT_REF = v0.17.0
-SIMPLECOV_HTML_GIT_URL = https://github.com/colszowka/simplecov-html.git
+SIMPLECOV_GIT_URL = git://github.com/colszowka/simplecov.git
+SIMPLECOV_GIT_REF = v0.15.0
+SIMPLECOV_HTML_GIT_URL = git://github.com/colszowka/simplecov-html.git
SIMPLECOV_HTML_GIT_REF = v0.10.2
-DOCLIE_GIT_URL = https://github.com/ms-ati/docile.git
-DOCLIE_GIT_REF = v1.3.2
+DOCLIE_GIT_URL = git://github.com/ms-ati/docile.git
+DOCLIE_GIT_REF = v1.1.5
STATIC_RUBY = static-ruby
TIMESTAMPDIR = $(EXTOUT)/.timestamp
-RUBYCOMMONDIR = $(EXTOUT)/common
EXTCONF = extconf.rb
LIBRUBY_EXTS = ./.libruby-with-ext.time
REVISION_H = ./.revision.time
PLATFORM_D = $(TIMESTAMPDIR)/.$(PLATFORM_DIR).time
ENC_TRANS_D = $(TIMESTAMPDIR)/.enc-trans.time
-RDOC = $(XRUBY) "$(srcdir)/libexec/rdoc" --root "$(srcdir)" --encoding=UTF-8 --all
RDOCOUT = $(EXTOUT)/rdoc
HTMLOUT = $(EXTOUT)/html
CAPIOUT = doc/capi
-INSTALL_DOC_OPTS = --rdoc-output="$(RDOCOUT)" --html-output="$(HTMLOUT)"
-RDOC_GEN_OPTS = --page-dir "$(srcdir)/doc" --no-force-update
INITOBJS = dmyext.$(OBJEXT) dmyenc.$(OBJEXT)
NORMALMAINOBJ = main.$(OBJEXT)
MAINOBJ = $(NORMALMAINOBJ)
DLDOBJS = $(INITOBJS)
EXTSOLIBS =
-MINIOBJS = $(ARCHMINIOBJS) miniinit.$(OBJEXT) dmyext.$(OBJEXT)
+MINIOBJS = $(ARCHMINIOBJS) miniinit.$(OBJEXT) dmyext.$(OBJEXT) miniprelude.$(OBJEXT)
ENC_MK = enc.mk
MAKE_ENC = -f $(ENC_MK) V="$(V)" UNICODE_HDR_DIR="$(UNICODE_HDR_DIR)" \
RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(mflags)
COMMONOBJS = array.$(OBJEXT) \
- ast.$(OBJEXT) \
bignum.$(OBJEXT) \
class.$(OBJEXT) \
compar.$(OBJEXT) \
@@ -107,8 +95,6 @@ COMMONOBJS = array.$(OBJEXT) \
load.$(OBJEXT) \
marshal.$(OBJEXT) \
math.$(OBJEXT) \
- mjit.$(OBJEXT) \
- mjit_compile.$(OBJEXT) \
node.$(OBJEXT) \
numeric.$(OBJEXT) \
object.$(OBJEXT) \
@@ -138,7 +124,6 @@ COMMONOBJS = array.$(OBJEXT) \
thread.$(OBJEXT) \
time.$(OBJEXT) \
transcode.$(OBJEXT) \
- transient_heap.$(OBJEXT) \
util.$(OBJEXT) \
variable.$(OBJEXT) \
version.$(OBJEXT) \
@@ -146,7 +131,6 @@ COMMONOBJS = array.$(OBJEXT) \
vm_backtrace.$(OBJEXT) \
vm_dump.$(OBJEXT) \
vm_trace.$(OBJEXT) \
- $(COROUTINE_OBJ) \
$(DTRACE_OBJ) \
$(BUILTIN_ENCOBJS) \
$(BUILTIN_TRANSOBJS) \
@@ -157,15 +141,15 @@ EXPORTOBJS = $(DLNOBJ) \
loadpath.$(OBJEXT) \
$(COMMONOBJS)
-OBJS = $(EXPORTOBJS) builtin.$(OBJEXT)
+OBJS = $(EXPORTOBJS) prelude.$(OBJEXT)
ALLOBJS = $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(INITOBJS)
GOLFOBJS = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)
DEFAULT_PRELUDES = $(GEM_PRELUDE)
-PRELUDE_SCRIPTS = $(DEFAULT_PRELUDES)
-GEM_PRELUDE =
-PRELUDES = {$(srcdir)}miniprelude.c
+PRELUDE_SCRIPTS = $(srcdir)/prelude.rb $(DEFAULT_PRELUDES)
+GEM_PRELUDE = $(srcdir)/gem_prelude.rb
+PRELUDES = {$(srcdir)}prelude.c {$(srcdir)}miniprelude.c
GOLFPRELUDES = {$(srcdir)}golf_prelude.c
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
@@ -185,9 +169,12 @@ INSTRUBY_ARGS = $(SCRIPT_ARGS) \
INSTALL_PROG_MODE = 0755
INSTALL_DATA_MODE = 0644
+PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARGV[1] or File.unlink(ARGV[0]) rescue nil' -- \
+ $(LIBRUBY_EXTS) $(LIBRUBY_SO_UPDATE)
+
TESTSDIR = $(srcdir)/test
-TOOL_TESTSDIR = $(srcdir)/tool/test
TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/excludes --name=!/memory_leak/
+EXCLUDE_TESTFRAMEWORK = --exclude=/testunit/ --exclude=/minitest/
TESTWORKDIR = testwork
TESTOPTS = $(RUBY_TESTOPTS)
@@ -197,55 +184,15 @@ COMPILE_PRELUDE = $(srcdir)/tool/generic_erb.rb $(srcdir)/template/prelude.c.tmp
SHOWFLAGS = showflags
-MAKE_LINK = $(MINIRUBY) -rfileutils -e "include FileUtils::Verbose" \
- -e "src, dest = ARGV" \
- -e "exit if File.identical?(src, dest) or cmp(src, dest) rescue nil" \
- -e "def noraise; yield; rescue; rescue NotImplementedError; end" \
- -e "noraise {ln_sf('../'*dest.count('/')+src, dest)} or" \
- -e "noraise {ln(src, dest)} or" \
- -e "cp(src, dest)"
-
-
all: $(SHOWFLAGS) main docs
main: $(SHOWFLAGS) exts $(ENCSTATIC:static=lib)encs
@$(NULLCMD)
-mjit-headers: $(MJIT_SUPPORT)-mjit-headers
-no-mjit-headers: PHONY
-yes-mjit-headers: mjit_config.h PHONY
-
-mjit.$(OBJEXT): mjit_config.h
-mjit_config.h: Makefile
-
-
-# These rules using MJIT_HEADER_SUFFIX must be in common.mk, not
-# Makefile.in, in order to override the macro in defs/universal.mk.
-
-# Other `-Dxxx`s preceding `-DMJIT_HEADER` will be removed in transform_mjit_header.rb.
-# So `-DMJIT_HEADER` should be passed first when rb_mjit_header.h is generated.
-$(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time: probes.h vm.$(OBJEXT) \
- $(TIMESTAMPDIR)/$(arch)/.time
- $(ECHO) building $(@F:.time=.h)
- $(Q) $(CPP) -DMJIT_HEADER $(MJIT_HEADER_FLAGS) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(srcdir)/vm.c $(CPPOUTFLAG)$(@F:.time=.h).new
- $(Q) $(IFCHANGE) "--timestamp=$@" $(@F:.time=.h) $(@F:.time=.h).new
-
-$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: $(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time
-
-$(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: \
- $(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time \
- $(srcdir)/tool/transform_mjit_header.rb $(PREP) \
- $(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h
- $(ECHO) building $@
- $(MINIRUBY) $(srcdir)/tool/transform_mjit_header.rb "$(CC) $(ARCH_FLAG) $(CFLAGS)" $(MJIT_HEADER:.h=)$(MJIT_HEADER_ARCH).h $@
- $(Q) $(MAKEDIRS) $(MJIT_HEADER_INSTALL_DIR)
- $(Q) $(MAKE_LINK) $@ $(MJIT_HEADER_INSTALL_DIR)/$(@F)
-
.PHONY: showflags
exts enc trans: $(SHOWFLAGS)
showflags:
$(MESSAGE_BEGIN) \
- " BASERUBY = $(BASERUBY)" \
" CC = $(CC)" \
" LD = $(LD)" \
" LDSHARED = $(LDSHARED)" \
@@ -257,7 +204,6 @@ showflags:
" LANG = $(LANG)" \
" LC_ALL = $(LC_ALL)" \
" LC_CTYPE = $(LC_CTYPE)" \
- " MFLAGS = $(MFLAGS)" \
$(MESSAGE_END)
-@$(CC_VERSION)
@@ -272,8 +218,7 @@ EXTS_NOTE = -f $(EXTS_MK) $(mflags) RUBY="$(MINIRUBY)" top_srcdir="$(srcdir)" no
exts: build-ext
EXTS_MK = exts.mk
-$(EXTS_MK): ext/configure-ext.mk $(srcdir)/template/exts.mk.tmpl \
- $(TIMESTAMPDIR)/$(arch)/.time $(TIMESTAMPDIR)/.RUBYCOMMONDIR.time
+$(EXTS_MK): ext/configure-ext.mk $(TIMESTAMPDIR)/$(arch)/.time $(srcdir)/template/exts.mk.tmpl
$(Q)$(MAKE) -f ext/configure-ext.mk $(mflags) V=$(V) EXTSTATIC=$(EXTSTATIC) \
gnumake=$(gnumake) MINIRUBY="$(MINIRUBY)" \
EXTLDFLAGS="$(EXTLDFLAGS)" srcdir="$(srcdir)"
@@ -313,15 +258,11 @@ miniruby$(EXEEXT): config.status $(ALLOBJS) $(ARCHFILE)
objs: $(ALLOBJS)
GORUBY = go$(RUBY_INSTALL_NAME)
-GOLF = $(GORUBY)
-golf: $(GOLF)
-$(GOLF): $(LIBRUBY) $(GOLFOBJS) PHONY
+golf: $(LIBRUBY) $(GOLFOBJS) PHONY
$(Q) $(MAKE) $(mflags) \
- GOLF=_dummy_golf_target_to_avoid_conflict_just_in_case_ \
MAINOBJ=goruby.$(OBJEXT) \
EXTOBJS="golf_prelude.$(OBJEXT) $(EXTOBJS)" \
PROGRAM=$(GORUBY)$(EXEEXT) \
- V=$(V) \
program
capi: $(CAPIOUT)/.timestamp PHONY
@@ -344,22 +285,18 @@ $(PROGRAM) $(WPROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP
$(LIBRUBY_A): $(LIBRUBY_A_OBJS) $(MAINOBJ) $(INITOBJS) $(ARCHFILE)
-$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP) $(BUILTIN_ENCOBJS)
+$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP) $(LIBRUBY_SO_UPDATE) $(BUILTIN_ENCOBJS)
$(LIBRUBY_EXTS):
- @$(NULLCMD) > $@
+ @exit > $@
$(STATIC_RUBY)$(EXEEXT): $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A)
$(Q)$(RM) $@
- $(PURIFY) $(CC) $(MAINOBJ) $(DLDOBJS) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)$@ $(LDFLAGS) $(XLDFLAGS)
+ $(PURIFY) $(CC) $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)$@ $(LDFLAGS) $(XLDFLAGS)
ruby.imp: $(COMMONOBJS)
- $(Q){ \
- $(NM) -Pgp $(COMMONOBJS) | \
- awk 'BEGIN{print "#!"}; $$2~/^[BDT]$$/&&$$1!~/^$(SYMBOL_PREFIX)(Init_|InitVM_|ruby_static_id_|.*_threadptr_|rb_ec_)|^\./{print $$1}'; \
- ($(CHDIR) $(srcdir) && \
- exec sed -n '/^MJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
- } | \
+ $(Q)$(NM) -Pgp $(COMMONOBJS) | \
+ awk 'BEGIN{print "#!"}; $$2~/^[BDT]$$/&&$$1!~/^(Init_|ruby_static_id_|.*_threadptr_|rb_ec_\.)/{print $$1}' | \
sort -u -o $@
install: install-$(INSTALLDOC)
@@ -370,14 +307,14 @@ $(ruby_pc): $(srcdir)/template/ruby.pc.in config.status
install-all: docs pre-install-all do-install-all post-install-all
pre-install-all:: all pre-install-local pre-install-ext pre-install-doc
do-install-all: pre-install-all
- $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) $(INSTALL_DOC_OPTS)
+ $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all --rdoc-output="$(RDOCOUT)"
post-install-all:: post-install-local post-install-ext post-install-doc
@$(NULLCMD)
install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc
pre-install-nodoc:: pre-install-local pre-install-ext
do-install-nodoc: main pre-install-nodoc
- $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --exclude=doc
+ $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS)
post-install-nodoc:: post-install-local post-install-ext
install-local: pre-install-local do-install-local post-install-local
@@ -452,7 +389,7 @@ what-where-all: no-install-all
no-install-all: pre-no-install-all dont-install-all post-no-install-all
pre-no-install-all:: pre-no-install-local pre-no-install-ext pre-no-install-doc
dont-install-all: $(PROGRAM)
- $(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all $(INSTALL_DOC_OPTS)
+ $(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all --rdoc-output="$(RDOCOUT)"
post-no-install-all:: post-no-install-local post-no-install-ext post-no-install-doc
@$(NULLCMD)
@@ -539,7 +476,7 @@ post-no-install-man::
install-doc: rdoc pre-install-doc do-install-doc post-install-doc
pre-install-doc:: install-prereq
do-install-doc: $(PROGRAM) pre-install-doc
- $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc $(INSTALL_DOC_OPTS)
+ $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
post-install-doc::
@$(NULLCMD)
@@ -552,15 +489,15 @@ post-install-gem::
rdoc: PHONY main
@echo Generating RDoc documentation
- $(Q) $(RDOC) --ri --op "$(RDOCOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) "$(srcdir)"
+ $(Q) $(XRUBY) "$(srcdir)/bin/rdoc" --root "$(srcdir)" --page-dir "$(srcdir)/doc" --encoding=UTF-8 --no-force-update --all --ri --op "$(RDOCOUT)" $(RDOCFLAGS) "$(srcdir)"
html: PHONY main
@echo Generating RDoc HTML files
- $(Q) $(RDOC) --op "$(HTMLOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) "$(srcdir)"
+ $(Q) $(XRUBY) "$(srcdir)/bin/rdoc" --root "$(srcdir)" --page-dir "$(srcdir)/doc" --encoding=UTF-8 --no-force-update --all --op "$(HTMLOUT)" $(RDOCFLAGS) "$(srcdir)"
rdoc-coverage: PHONY main
@echo Generating RDoc coverage report
- $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) "$(srcdir)"
+ $(Q) $(XRUBY) "$(srcdir)/bin/rdoc" --root "$(srcdir)" --encoding=UTF-8 --all --quiet -C $(RDOCFLAGS) "$(srcdir)"
RDOCBENCHOUT=/tmp/rdocbench
@@ -578,7 +515,7 @@ what-where-doc: no-install-doc
no-install-doc: pre-no-install-doc dont-install-doc post-no-install-doc
pre-no-install-doc:: install-prereq
dont-install-doc:: $(PREP)
- $(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc $(INSTALL_DOC_OPTS)
+ $(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
post-no-install-doc::
@$(NULLCMD)
@@ -593,17 +530,13 @@ clean: clean-ext clean-enc clean-golf clean-docs clean-extout clean-local clean-
clean-local:: clean-runnable
$(Q)$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
$(Q)$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) dmyenc.$(OBJEXT) $(ARCHFILE) .*.time
- $(Q)$(RM) y.tab.c y.output encdb.h transdb.h config.log rbconfig.rb $(ruby_pc) $(COROUTINE_H:/Context.h=/.time)
- $(Q)$(RM) probes.h probes.$(OBJEXT) probes.stamp ruby-glommed.$(OBJEXT) ruby.imp
+ $(Q)$(RM) y.tab.c y.output encdb.h transdb.h config.log rbconfig.rb $(ruby_pc) probes.h probes.$(OBJEXT) probes.stamp ruby-glommed.$(OBJEXT)
$(Q)$(RM) GNUmakefile.old Makefile.old $(arch)-fake.rb bisect.sh $(ENC_TRANS_D)
- -$(Q) $(RMDIR) enc/jis enc/trans enc $(COROUTINE_H:/Context.h=) coroutine 2> $(NULL) || $(NULLCMD)
-
-bin/clean-runnable:: PHONY
- $(Q)$(CHDIR) bin 2>$(NULL) && $(RM) $(PROGRAM) $(WPROGRAM) $(GORUBY)$(EXEEXT) bin/*.$(DLEXT) 2>$(NULL) || $(NULLCMD)
-lib/clean-runnable:: PHONY
- $(Q)$(CHDIR) lib 2>$(NULL) && $(RM) $(LIBRUBY_A) $(LIBRUBY) $(LIBRUBY_ALIASES) $(RUBY_BASE_NAME)/$(RUBY_PROGRAM_VERSION) $(RUBY_BASE_NAME)/vendor_ruby 2>$(NULL) || $(NULLCMD)
-clean-runnable:: bin/clean-runnable lib/clean-runnable PHONY
- $(Q)$(RMDIR) lib/$(RUBY_BASE_NAME) lib bin 2>$(NULL) || $(NULLCMD)
+ -$(Q) $(RMDIR) enc/jis enc/trans enc 2> $(NULL) || exit 0
+clean-runnable:: PHONY
+ $(Q)$(CHDIR) bin 2>$(NULL) && $(RM) $(PROGRAM) $(WPROGRAM) $(GORUBY)$(EXEEXT) bin/*.$(DLEXT) 2>$(NULL) || exit 0
+ $(Q)$(CHDIR) lib 2>$(NULL) && $(RM) $(LIBRUBY_A) $(LIBRUBY) $(LIBRUBY_ALIASES) $(RUBY_BASE_NAME)/$(RUBY_PROGRAM_VERSION) $(RUBY_BASE_NAME)/vendor_ruby 2>$(NULL) || exit 0
+ $(Q)$(RMDIR) lib/$(RUBY_BASE_NAME) lib bin 2>$(NULL) || exit 0
clean-ext:: PHONY
clean-golf: PHONY
$(Q)$(RM) $(GORUBY)$(EXEEXT) $(GOLFOBJS)
@@ -612,14 +545,14 @@ clean-html: PHONY
clean-capi: PHONY
clean-platform: PHONY
clean-extout: PHONY
- -$(Q)$(RMDIR) $(EXTOUT)/$(arch) $(EXTOUT) 2> $(NULL) || $(NULLCMD)
+ -$(Q)$(RMDIR) $(EXTOUT)/$(arch) $(EXTOUT) 2> $(NULL) || exit 0
clean-docs: clean-rdoc clean-html clean-capi
clean-spec: PHONY
clean-rubyspec: clean-spec
distclean: distclean-ext distclean-enc distclean-golf distclean-docs distclean-extout distclean-local distclean-platform distclean-spec
distclean-local:: clean-local
- $(Q)$(RM) $(MKFILES) yasmdata.rb *.inc $(PRELUDES) *.rbinc
+ $(Q)$(RM) $(MKFILES) yasmdata.rb *.inc $(PRELUDES)
$(Q)$(RM) config.cache config.status config.status.lineno
$(Q)$(RM) *~ *.bak *.stackdump core *.core gmon.out $(PREP)
-$(Q)$(RMALL) $(srcdir)/autom4te.cache
@@ -635,27 +568,12 @@ distclean-spec: clean-spec
distclean-rubyspec: distclean-spec
realclean:: realclean-ext realclean-local realclean-enc realclean-golf realclean-extout
-realclean-local:: distclean-local realclean-srcs-local
-
-clean-srcs:: clean-srcs-local clean-srcs-ext
-realclean-srcs:: realclean-srcs-local realclean-srcs-ext
-
-clean-srcs-local::
+realclean-local:: distclean-local
$(Q)$(RM) parse.c parse.h lex.c enc/trans/newline.c revision.h
- $(Q)$(RM) id.c id.h probes.dmyh probes.h
- $(Q)$(RM) encdb.h transdb.h verconf.h ruby-runner.h
- $(Q)$(RM) mjit_config.h rb_mjit_header.h
- $(Q)$(RM) $(MJIT_MIN_HEADER) $(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX:%=*).h
-
-realclean-srcs-local:: clean-srcs-local
- $(Q)$(CHDIR) $(srcdir) && $(RM) \
- parse.c parse.h lex.c enc/trans/newline.c $(PRELUDES) revision.h \
- id.c id.h probes.dmyh configure aclocal.m4 tool/config.guess tool/config.sub gems/*.gem \
- || $(NULLCMD)
-
-clean-srcs-ext::
-realclean-srcs-ext:: clean-srcs-ext
-
+ $(Q)$(RM) id.c id.h probes.dmyh
+ $(Q)$(CHDIR) $(srcdir) && $(exec) $(RM) parse.c parse.h lex.c enc/trans/newline.c $(PRELUDES) revision.h
+ $(Q)$(CHDIR) $(srcdir) && $(exec) $(RM) id.c id.h probes.dmyh
+ $(Q)$(CHDIR) $(srcdir) && $(exec) $(RM) configure aclocal.m4 tool/config.guess tool/config.sub gems/*.gem
realclean-ext:: PHONY
realclean-golf: distclean-golf
$(Q)$(RM) $(GOLFPRELUDES)
@@ -673,9 +591,9 @@ distclean-ext:: ext/distclean gems/distclean timestamp/distclean
realclean-ext:: ext/realclean gems/realclean timestamp/realclean
ext/clean.mk ext/distclean.mk ext/realclean.mk::
-ext/clean:: ext/clean.mk
-ext/distclean:: ext/distclean.mk
-ext/realclean:: ext/realclean.mk
+ext/clean gems/clean:: ext/clean.mk
+ext/distclean gems/distclean:: ext/distclean.mk
+ext/realclean gems/realclean:: ext/realclean.mk
timestamp/clean:: ext/clean gems/clean
timestamp/distclean:: ext/distclean gems/distclean
@@ -683,14 +601,14 @@ timestamp/realclean:: ext/realclean gems/realclean
timestamp/clean timestamp/distclean timestamp/realclean::
$(Q)$(RM) $(TIMESTAMPDIR)/.*.time $(TIMESTAMPDIR)/$(arch)/.time
- $(Q)$(RMDIRS) $(TIMESTAMPDIR)/$(arch) $(TIMESTAMPDIR) 2> $(NULL) || $(NULLCMD)
+ $(Q)$(RMDIRS) $(TIMESTAMPDIR)/$(arch) 2> $(NULL) || exit 0
clean-ext::
-$(Q)$(RM) ext/extinit.$(OBJEXT)
distclean-ext realclean-ext::
-$(Q)$(RM) $(EXTS_MK) ext/extinit.* ext/configure-ext.mk
- -$(Q)$(RMDIR) ext 2> $(NULL) || $(NULLCMD)
+ -$(Q)$(RMDIR) ext 2> $(NULL) || exit 0
clean-enc distclean-enc realclean-enc: PHONY
@@ -698,7 +616,7 @@ clean-enc: clean-enc.d
clean-enc.d: PHONY
$(Q)$(RM) $(ENC_TRANS_D)
- -$(Q) $(RMDIR) enc/jis enc/trans enc 2> $(NULL) || $(NULLCMD)
+ -$(Q) $(RMDIR) enc/jis enc/trans enc 2> $(NULL) || exit 0
clean-rdoc distclean-rdoc realclean-rdoc:
@echo $(@:-rdoc=ing) rdoc
@@ -714,18 +632,15 @@ clean-capi distclean-capi realclean-capi:
clean-platform:
$(Q) $(RM) $(PLATFORM_D)
- -$(Q) $(RMDIR) $(PLATFORM_DIR) 2> $(NULL) || $(NULLCMD)
+ -$(Q) $(RMDIR) $(PLATFORM_DIR) 2> $(NULL) || exit 0
RUBYSPEC_CAPIEXT = spec/ruby/optional/capi/ext
clean-spec: PHONY
-$(Q) $(RM) $(RUBYSPEC_CAPIEXT)/*.$(OBJEXT) $(RUBYSPEC_CAPIEXT)/*.$(DLEXT)
- -$(Q) $(RMDIRS) $(RUBYSPEC_CAPIEXT) 2> $(NULL) || $(NULLCMD)
+ -$(Q) $(RMDIRS) $(RUBYSPEC_CAPIEXT) 2> $(NULL) || exit 0
-check: main test test-tool test-all test-spec
+check: main test test-testframework test-almost
$(ECHO) check succeeded
- -$(Q) if [ x"$(GIT)" != x ] && $(CHDIR) "$(srcdir)" && $(GIT) rev-parse > /dev/null 2>&1; then \
- set -x; $(GIT) --no-pager log --format=oneline -G "^ *# *include" origin/master..HEAD; \
- fi
check-ruby: test test-ruby
fake: $(CROSS_COMPILING)-fake
@@ -736,19 +651,19 @@ no-fake -fake: PHONY
# version.o depends on.
$(arch)-fake.rb: $(srcdir)/template/fake.rb.in $(srcdir)/tool/generic_erb.rb version.$(OBJEXT) miniruby$(EXEEXT)
$(ECHO) generating $@
- $(Q) $(CPP) -DRUBY_EXPORT $(INCFLAGS) $(CPPFLAGS) "$(srcdir)/version.c" | \
+ $(Q) $(CPP) $(warnflags) $(XCFLAGS) $(CPPFLAGS) "$(srcdir)/version.c" | \
$(BOOTSTRAPRUBY) "$(srcdir)/tool/generic_erb.rb" -o $@ "$(srcdir)/template/fake.rb.in" \
i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)"
btest: $(TEST_RUNNABLE)-btest
no-btest: PHONY
yes-btest: fake miniruby$(EXEEXT) PHONY
- $(Q)$(exec) $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(BTESTRUBY) $(RUN_OPTS)" $(OPTS) $(TESTOPTS) $(BTESTS)
+ $(Q)$(exec) $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(BTESTRUBY) $(RUN_OPTS)" $(OPTS) $(TESTOPTS)
btest-ruby: $(TEST_RUNNABLE)-btest-ruby
no-btest-ruby: PHONY
yes-btest-ruby: prog PHONY
- $(Q)$(exec) $(RUNRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM) -I$(srcdir)/lib $(RUN_OPTS)" -q $(OPTS) $(TESTOPTS) $(BTESTS)
+ $(Q)$(exec) $(RUNRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM) -I$(srcdir)/lib $(RUN_OPTS)" -q $(OPTS) $(TESTOPTS)
test-basic: $(TEST_RUNNABLE)-test-basic
no-test-basic: PHONY
@@ -763,35 +678,30 @@ yes-test-knownbug: prog PHONY
test-testframework: $(TEST_RUNNABLE)-test-testframework
yes-test-testframework: prog PHONY
- $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest
+ $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest
no-test-testframework: PHONY
-test-tool: $(TEST_RUNNABLE)-test-tool
-yes-test-tool: prog PHONY
- $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS)
-no-test-tool: PHONY
-
test-sample: test-basic # backward compatibility for mswin-build
-test-short: btest-ruby test-knownbug test-basic
-test: test-short
+test: btest-ruby test-knownbug test-basic
# $ make test-all TESTOPTS="--help" displays more detail
# for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
test-all: $(TEST_RUNNABLE)-test-all
yes-test-all: programs PHONY
- $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
+ $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
TESTS_BUILD = mkmf
no-test-all: PHONY
- $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TESTSDIR)/runner.rb" $(TESTOPTS) $(TESTS_BUILD)
+ $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(srcdir)/test/runner.rb" $(TESTOPTS) $(TESTS_BUILD)
-test-almost: test-all
-yes-test-almost: yes-test-all
-no-test-almost: no-test-all
+test-almost: $(TEST_RUNNABLE)-test-almost
+yes-test-almost: prog PHONY
+ $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) $(TESTS)
+no-test-almost: PHONY
test-ruby: $(TEST_RUNNABLE)-test-ruby
no-test-ruby: PHONY
yes-test-ruby: prog encs PHONY
- $(gnumake_recursive)$(RUNRUBY) "$(TESTSDIR)/runner.rb" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext-
+ $(gnumake_recursive)$(RUNRUBY) "$(srcdir)/test/runner.rb" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext-
extconf: $(PREP)
$(Q) $(MAKEDIRS) "$(EXTCONFDIR)"
@@ -808,7 +718,6 @@ $(RBCONFIG): $(srcdir)/tool/mkconfig.rb config.status $(srcdir)/version.h
-install_name=$(RUBY_INSTALL_NAME) \
-so_name=$(RUBY_SO_NAME) \
-unicode_version=$(UNICODE_VERSION) \
- -unicode_emoji_version=$(UNICODE_EMOJI_VERSION) \
> rbconfig.tmp
$(IFCHANGE) "--timestamp=$@" rbconfig.rb rbconfig.tmp
@@ -852,8 +761,8 @@ $(ENC_MK): $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc
.PHONY: clean clean-ext clean-local clean-enc clean-golf clean-rdoc clean-html clean-extout
.PHONY: distclean distclean-ext distclean-local distclean-enc distclean-golf distclean-extout
.PHONY: realclean realclean-ext realclean-local realclean-enc realclean-golf realclean-extout
-.PHONY: exam check test test-short test-all btest btest-ruby test-basic test-knownbug
-.PHONY: run runruby parse benchmark gdb gdb-ruby
+.PHONY: check test test-all btest btest-ruby test-basic test-knownbug
+.PHONY: run runruby parse benchmark benchmark-each tbench gdb gdb-ruby
.PHONY: update-mspec update-rubyspec test-rubyspec test-spec
.PHONY: touch-unicode-files
@@ -865,7 +774,6 @@ PHONY:
{$(srcdir)}.y.c:
$(ECHO) generating $@
$(Q)$(BASERUBY) $(srcdir)/tool/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ --vpath=$(VPATH) id.h $(SRC_FILE) > parse.tmp.y
- $(Q)$(BASERUBY) $(srcdir)/tool/pure_parser.rb parse.tmp.y $(YACC)
$(Q)$(YACC) -d $(YFLAGS) -o y.tab.c parse.tmp.y
$(Q)$(RM) parse.tmp.y
$(Q)sed -f $(srcdir)/tool/ytab.sed -e "/^#/s|parse\.tmp\.[iy]|$(SRC_FILE)|" -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@.new
@@ -875,45 +783,38 @@ PHONY:
$(PLATFORM_D):
$(Q) $(MAKEDIRS) $(PLATFORM_DIR) $(@D)
- @$(NULLCMD) > $@
+ @exit > $@
-exe/$(PROGRAM): ruby-runner.c ruby-runner.h exe/.time miniruby$(EXEEXT) {$(VPATH)}config.h
- $(Q) $(CC) $(CFLAGS) $(INCFLAGS) $(CPPFLAGS) -DRUBY_INSTALL_NAME=$(@F) $(COUTFLAG)ruby-runner.$(OBJEXT) -c $(CSRCFLAG)$(srcdir)/ruby-runner.c
- $(Q) $(PURIFY) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTFLAG)$@ ruby-runner.$(OBJEXT) $(LIBS)
- $(Q) $(POSTLINK)
+exe/$(PROGRAM): ruby-runner.c ruby-runner.h exe/.time miniruby$(EXEEXT)
+ $(Q) $(PURIFY) $(CC) $(CFLAGS) $(CPPFLAGS) -DRUBY_INSTALL_NAME=$(@F) $(LDFLAGS) $(LIBS) $(OUTFLAG)$@ $<
$(Q) ./miniruby$(EXEEXT) \
- -e 'prog, dest, inst = ARGV; dest += "/ruby"' \
- -e 'exit unless prog==inst' \
+ -e 'prog, dest = ARGV; dest += "/ruby"' \
-e 'unless prog=="ruby"' \
-e ' begin File.unlink(dest); rescue Errno::ENOENT; end' \
-e ' File.symlink(prog, dest)' \
-e 'end' \
- $(@F) $(@D) $(RUBY_INSTALL_NAME)$(EXEEXT)
+ $(@F) $(@D)
exe/.time:
- $(Q) $(MAKEDIRS) $(@D)
- @$(NULLCMD) > $@
+ $(Q) $(MAKEDIRS) exe $(@D)
+ @exit > $@
$(BUILTIN_ENCOBJS) $(BUILTIN_TRANSOBJS): $(ENC_TRANS_D)
$(ENC_TRANS_D):
$(Q) $(MAKEDIRS) enc/trans $(@D)
- @$(NULLCMD) > $@
+ @exit > $@
$(TIMESTAMPDIR)/$(arch)/.time:
$(Q)$(MAKEDIRS) $(@D) $(EXTOUT)/$(arch)
- @$(NULLCMD) > $@
-
-$(TIMESTAMPDIR)/.RUBYCOMMONDIR.time:
- $(Q)$(MAKEDIRS) $(@D) $(RUBYCOMMONDIR)
- @$(NULLCMD) > $@
+ @exit > $@
###
CCAN_DIR = {$(VPATH)}ccan
RUBY_H_INCLUDES = {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h \
{$(VPATH)}intern.h {$(VPATH)}missing.h {$(VPATH)}st.h \
- {$(VPATH)}assert.h {$(VPATH)}subst.h
+ {$(VPATH)}subst.h
###
@@ -936,19 +837,15 @@ strlcat.$(OBJEXT): {$(VPATH)}strlcat.c
strlcpy.$(OBJEXT): {$(VPATH)}strlcpy.c
strstr.$(OBJEXT): {$(VPATH)}strstr.c
nt.$(OBJEXT): {$(VPATH)}nt.c
-
-.coroutine_obj $(COROUTINE_OBJ): \
- {$(VPATH)}$(COROUTINE_SRC) \
- $(COROUTINE_H:/Context.h=/.time)
-$(COROUTINE_H:/Context.h=/.time):
- $(Q) $(MAKEDIRS) $(@D)
- @$(NULLCMD) > $@
+ia64.$(OBJEXT): {$(VPATH)}ia64.s
+ $(CC) $(CFLAGS) -c $<
###
# dependencies for generated C sources.
parse.$(OBJEXT): {$(VPATH)}parse.c
miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c
+prelude.$(OBJEXT): {$(VPATH)}prelude.c
# dependencies for optional sources.
compile.$(OBJEXT): {$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc
@@ -975,40 +872,23 @@ $(OBJS): {$(VPATH)}config.h {$(VPATH)}missing.h
INSNS2VMOPT = --srcdir="$(srcdir)"
-srcs_vpath = {$(VPATH)}
-
-inc_common_headers = $(srcdir)/tool/ruby_vm/views/_copyright.erb $(srcdir)/tool/ruby_vm/views/_notice.erb
-$(srcs_vpath)opt_sc.inc: $(srcdir)/tool/ruby_vm/views/opt_sc.inc.erb $(inc_common_headers)
-$(srcs_vpath)optinsn.inc: $(srcdir)/tool/ruby_vm/views/optinsn.inc.erb $(inc_common_headers)
-$(srcs_vpath)optunifs.inc: $(srcdir)/tool/ruby_vm/views/optunifs.inc.erb $(inc_common_headers)
-$(srcs_vpath)insns.inc: $(srcdir)/tool/ruby_vm/views/insns.inc.erb $(inc_common_headers)
-$(srcs_vpath)insns_info.inc: $(srcdir)/tool/ruby_vm/views/insns_info.inc.erb $(inc_common_headers) \
- $(srcdir)/tool/ruby_vm/views/_insn_type_chars.erb $(srcdir)/tool/ruby_vm/views/_insn_name_info.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_len_info.erb $(srcdir)/tool/ruby_vm/views/_insn_operand_info.erb \
- $(srcdir)/tool/ruby_vm/views/_attributes.erb $(srcdir)/tool/ruby_vm/views/_comptime_insn_stack_increase.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_sp_pc_dependency.erb
-$(srcs_vpath)vmtc.inc: $(srcdir)/tool/ruby_vm/views/vmtc.inc.erb $(inc_common_headers)
-$(srcs_vpath)vm.inc: $(srcdir)/tool/ruby_vm/views/vm.inc.erb $(inc_common_headers) \
- $(srcdir)/tool/ruby_vm/views/_insn_entry.erb $(srcdir)/tool/ruby_vm/views/_trace_instruction.erb
-$(srcs_vpath)mjit_compile.inc: $(srcdir)/tool/ruby_vm/views/mjit_compile.inc.erb $(inc_common_headers) \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_insn.erb $(srcdir)/tool/ruby_vm/views/_mjit_compile_send.erb \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_ivar.erb \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_insn_body.erb $(srcdir)/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
-
-BUILTIN_RB_SRCS = \
- $(srcdir)/ast.rb \
- $(srcdir)/gc.rb \
- $(srcdir)/io.rb \
- $(srcdir)/pack.rb \
- $(srcdir)/trace_point.rb \
- $(srcdir)/warning.rb \
- $(srcdir)/prelude.rb \
- $(srcdir)/gem_prelude.rb \
- $(empty)
-BUILTIN_RB_INCS = $(BUILTIN_RB_SRCS:.rb=.rbinc)
+{$(VPATH)}minsns.inc: $(srcdir)/template/minsns.inc.tmpl
+
+{$(VPATH)}opt_sc.inc: $(srcdir)/template/opt_sc.inc.tmpl
-common-srcs: $(srcs_vpath)parse.c $(srcs_vpath)lex.c $(srcs_vpath)enc/trans/newline.c $(srcs_vpath)id.c \
- $(BUILTIN_RB_INCS) \
+{$(VPATH)}optinsn.inc: $(srcdir)/template/optinsn.inc.tmpl
+
+{$(VPATH)}optunifs.inc: $(srcdir)/template/optunifs.inc.tmpl
+
+{$(VPATH)}insns.inc: $(srcdir)/template/insns.inc.tmpl
+
+{$(VPATH)}insns_info.inc: $(srcdir)/template/insns_info.inc.tmpl
+
+{$(VPATH)}vmtc.inc: $(srcdir)/template/vmtc.inc.tmpl
+
+{$(VPATH)}vm.inc: $(srcdir)/template/vm.inc.tmpl
+
+common-srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c {$(VPATH)}enc/trans/newline.c {$(VPATH)}id.c \
srcs-lib srcs-ext incs
missing-srcs: $(srcdir)/missing/des_tables.c
@@ -1019,20 +899,13 @@ EXT_SRCS = $(srcdir)/ext/ripper/ripper.c \
$(srcdir)/ext/rbconfig/sizeof/sizes.c \
$(srcdir)/ext/rbconfig/sizeof/limits.c \
$(srcdir)/ext/socket/constdefs.c \
- $(srcdir)/ext/etc/constdefs.h \
# EXT_SRCS
srcs-ext: $(EXT_SRCS)
-realclean-srcs-ext::
- $(Q)$(RM) $(EXT_SRCS)
-EXTRA_SRCS = $(srcdir)/ext/json/parser/parser.c \
- $(srcdir)/ext/date/zonetab.h \
- $(empty)
-
-srcs-extra: $(EXTRA_SRCS)
-realclean-srcs-extra::
- $(Q)$(RM) $(EXTRA_SRCS)
+srcs-extra: $(srcdir)/ext/json/parser/parser.c \
+ $(srcdir)/ext/date/zonetab.h \
+ $(empty)
LIB_SRCS = $(srcdir)/lib/unicode_normalize/tables.rb
@@ -1061,9 +934,9 @@ id.c: $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.c.tmpl $(srcdir)/defs/
$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb --output=$@ \
$(srcdir)/template/id.c.tmpl
-node_name.inc: $(srcdir)/tool/node_name.rb $(srcdir)/node.h
+node_name.inc: {$(VPATH)}node.h
$(ECHO) generating $@
- $(Q) $(BASERUBY) -n $(srcdir)/tool/node_name.rb < $(srcdir)/node.h > $@
+ $(Q) $(BASERUBY) -n $(srcdir)/tool/node_name.rb < $? > $@
encdb.h: $(PREP) $(srcdir)/tool/generic_erb.rb $(srcdir)/template/encdb.h.tmpl
$(ECHO) generating $@
@@ -1083,12 +956,18 @@ vm_call_iseq_optimized.inc: $(srcdir)/tool/mk_call_iseq_optimized.rb
$(ECHO) generating $@
$(Q) $(BASERUBY) $(srcdir)/tool/mk_call_iseq_optimized.rb > $@
-$(MINIPRELUDE_C): $(COMPILE_PRELUDE) $(BUILTIN_RB_SRCS)
+$(MINIPRELUDE_C): $(COMPILE_PRELUDE)
$(ECHO) generating $@
$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb -I$(srcdir) -o $@ \
- $(srcdir)/template/prelude.c.tmpl $(BUILTIN_RB_SRCS)
+ $(srcdir)/template/prelude.c.tmpl
+
+$(PRELUDE_C): $(COMPILE_PRELUDE) \
+ $(PRELUDE_SCRIPTS)
+ $(ECHO) generating $@
+ $(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb -I$(srcdir) -c -o $@ \
+ $(srcdir)/template/prelude.c.tmpl $(PRELUDE_SCRIPTS)
-$(GOLF_PRELUDE_C): $(COMPILE_PRELUDE) {$(srcdir)}golf_prelude.rb
+{$(VPATH)}golf_prelude.c: $(COMPILE_PRELUDE) {$(srcdir)}golf_prelude.rb
$(ECHO) generating $@
$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb -I$(srcdir) -c -o $@ \
$(srcdir)/template/prelude.c.tmpl golf_prelude.rb
@@ -1108,44 +987,31 @@ probes.h: {$(VPATH)}probes.$(DTRACE_EXT)
prereq: incs srcs preludes PHONY
+preludes: {$(VPATH)}prelude.c
preludes: {$(VPATH)}miniprelude.c
preludes: {$(srcdir)}golf_prelude.c
-{$(srcdir)}.rb.rbinc:
- $(ECHO) making $@
- $(Q) $(BASERUBY) $(srcdir)/tool/mk_builtin_loader.rb $<
-
-builtin_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/tool/mk_builtin_binary.rb
- $(Q) $(MINIRUBY) $(srcdir)/tool/mk_builtin_binary.rb --cross=$(CROSS_COMPILING)
-
-$(BUILTIN_RB_INCS): $(top_srcdir)/tool/mk_builtin_loader.rb
-
$(srcdir)/revision.h:
- $(Q)$(gnumake:yes=#) $(RM) $(@F)
- $(Q)$(gnumake:yes=#) $(NULLCMD) > $@ || $(NULLCMD) > $(@F)
+ @exit > $@
-revision.tmp::
- $(Q) $(NULLCMD) > $@
-revision.$(HAVE_BASERUBY:yes=tmp):: $(srcdir)/version.h $(srcdir)/tool/file2lastrev.rb $(REVISION_FORCE)
- $(Q) $(BASERUBY) $(srcdir)/tool/file2lastrev.rb -q --revision.h --srcdir="$(srcdir)" > $@
-
-$(REVISION_H): revision.tmp
+$(REVISION_H): $(srcdir)/version.h $(srcdir)/tool/file2lastrev.rb $(REVISION_FORCE)
+ -$(Q) $(BASERUBY) $(srcdir)/tool/file2lastrev.rb -q --revision.h "$(srcdir)" > revision.tmp
$(Q)$(IFCHANGE) "--timestamp=$@" "$(srcdir)/revision.h" revision.tmp
-$(srcdir)/ext/ripper/ripper.c: $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/parse.y id.h $(srcdir)/ext/ripper/depend
+$(srcdir)/ext/ripper/ripper.c: $(srcdir)/parse.y id.h
$(ECHO) generating $@
$(Q) VPATH=$${PWD-`pwd`} && $(CHDIR) $(@D) && \
- sed -e 's/{\$$([^(){}]*)[^{}]*}//g' -e /AUTOGENERATED/q depend | \
+ sed /AUTOGENERATED/q depend | \
$(exec) $(MAKE) -f - $(mflags) \
- Q=$(Q) ECHO=$(ECHO) RM="$(RM)" BISON=$(YACC) top_srcdir=../.. srcdir=. VPATH="$${VPATH}" \
+ Q=$(Q) ECHO=$(ECHO) RM="$(RM)" top_srcdir=../.. srcdir=. VPATH="$${VPATH}" \
RUBY="$(BASERUBY)" PATH_SEPARATOR="$(PATH_SEPARATOR)"
-$(srcdir)/ext/json/parser/parser.c: $(srcdir)/ext/json/parser/parser.rl $(srcdir)/ext/json/parser/prereq.mk
+$(srcdir)/ext/json/parser/parser.c: $(srcdir)/ext/json/parser/parser.rl
$(ECHO) generating $@
$(Q) $(CHDIR) $(@D) && $(exec) $(MAKE) -f prereq.mk $(mflags) \
Q=$(Q) ECHO=$(ECHO) top_srcdir=../../.. srcdir=. VPATH=../../.. BASERUBY="$(BASERUBY)"
-$(srcdir)/ext/date/zonetab.h: $(srcdir)/ext/date/zonetab.list $(srcdir)/ext/date/prereq.mk
+$(srcdir)/ext/date/zonetab.h: $(srcdir)/ext/date/zonetab.list
$(ECHO) generating $@
$(Q) $(CHDIR) $(@D) && $(exec) $(MAKE) -f prereq.mk $(mflags) \
Q=$(Q) ECHO=$(ECHO) top_srcdir=../.. srcdir=. VPATH=../.. BASERUBY="$(BASERUBY)"
@@ -1172,12 +1038,6 @@ $(srcdir)/ext/socket/constdefs.c: $(srcdir)/ext/socket/depend
$(exec) $(MAKE) -f - $(mflags) \
Q=$(Q) ECHO=$(ECHO) top_srcdir=../.. srcdir=. VPATH=../.. RUBY="$(BASERUBY)"
-$(srcdir)/ext/etc/constdefs.h: $(srcdir)/ext/etc/depend
- $(Q) $(CHDIR) $(@D) && \
- sed '/AUTOGENERATED/q' depend | \
- $(exec) $(MAKE) -f - $(mflags) \
- Q=$(Q) ECHO=$(ECHO) top_srcdir=../.. srcdir=. VPATH=../.. RUBY="$(BASERUBY)"
-
##
run: fake miniruby$(EXEEXT) PHONY
@@ -1196,17 +1056,28 @@ bisect-ruby: PHONY
$(srcdir)/tool/bisect.sh ruby $(srcdir)
COMPARE_RUBY = $(BASERUBY)
-BENCH_RUBY = $(RUNRUBY)
ITEM =
-ARGS = $$(find $(srcdir)/benchmark -maxdepth 1 -name '$(ITEM)' -o -name '*$(ITEM)*.yml' -o -name '*$(ITEM)*.rb' | sort)
OPTS =
-# See benchmark/README.md for details.
-benchmark: miniruby$(EXEEXT) update-benchmark-driver PHONY
- $(BASERUBY) -rrubygems -I$(srcdir)/benchmark/lib $(srcdir)/benchmark/benchmark-driver/exe/benchmark-driver \
- --executables="compare-ruby::$(COMPARE_RUBY) -I$(EXTOUT)/common --disable-gem" \
- --executables="built-ruby::$(BENCH_RUBY) --disable-gem" \
- $(ARGS) $(OPTS)
+# You can pass several options through OPTS environment variable.
+# $ make benchmark OPTS="--help" displays more detail.
+# for example,
+# $ make benchmark COMPARE_RUBY="ruby-trunk" OPTS="-e ruby-2.2.2"
+# This command compares trunk and built-ruby and 2.2.2
+benchmark: miniruby$(EXEEXT) PHONY
+ $(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
+ --executables="$(COMPARE_RUBY) -I$(srcdir)/lib -I. -I$(EXTOUT)/common --disable-gem; built-ruby::$(MINIRUBY) --disable-gem" \
+ --pattern='bm_' --directory=$(srcdir)/benchmark $(OPTS)
+
+benchmark-each: miniruby$(EXEEXT) PHONY
+ $(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
+ --executables="$(COMPARE_RUBY) -I$(srcdir)/lib -I. -I$(EXTOUT)/common --disable-gem; built-ruby::$(MINIRUBY) --disable-gem" \
+ --pattern=$(ITEM) --directory=$(srcdir)/benchmark $(OPTS)
+
+tbench: miniruby$(EXEEXT) PHONY
+ $(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
+ --executables="$(COMPARE_RUBY) -I$(srcdir)/lib -I. -I$(EXTOUT)/common --disable-gem; built-ruby::$(MINIRUBY) --disable-gem" \
+ --pattern='bmx_' --directory=$(srcdir)/benchmark $(OPTS)
run.gdb:
echo set breakpoint pending on > run.gdb
@@ -1252,26 +1123,18 @@ up::
up::
-$(Q)$(MAKE) $(mflags) Q=$(Q) after-update
-yes::
-no::
-
after-update:: extract-extlibs
-after-update:: extract-gems
update-remote:: update-src update-download
-update-download:: $(ALWAYS_UPDATE_UNICODE:yes=update-unicode)
-update-download:: update-gems
-update-download:: download-extlibs
+update-download:: update-unicode update-gems download-extlibs
update-mspec:
update-rubyspec:
update-config_files: PHONY
- $(Q) $(BASERUBY) -C "$(srcdir)" tool/downloader.rb -d tool --cache-dir=$(CACHE_DIR) -e gnu \
+ $(Q) $(BASERUBY) -C "$(srcdir)" tool/downloader.rb -d tool -e gnu \
config.guess config.sub
-refresh-gems: update-bundled_gems update-gems extract-gems
-
update-gems: PHONY
$(ECHO) Downloading bundled gem files...
$(Q) $(BASERUBY) -C "$(srcdir)" \
@@ -1296,13 +1159,11 @@ extract-gems: PHONY
update-bundled_gems: PHONY
$(Q) $(RUNRUBY) -rrubygems \
-pla \
- -e '(gem,src), = Gem::SpecFetcher.fetcher.detect(:latest) {'"|s|" \
- -e 's.platform=="ruby"&&s.name==$$F[0]' \
+ -e '$$_=Gem::SpecFetcher.fetcher.detect(:latest) {'"|s|" \
+ -e 'if s.platform=="ruby"&&s.name==$$F[0]' \
+ -e 'break [s.name, s.version, *$$F[2..-1]].join(" ")' \
+ -e 'end' \
-e '}' \
- -e 'gem = src.fetch_spec(gem)' \
- -e 'uri = gem.metadata["source_code_uri"]||gem.homepage' \
- -e 'uri = uri.sub(%r[\Ahttps://github\.com/[^/]+/[^/]+\K/tree/.*], "")' \
- -e '$$_ = [gem.name, gem.version, uri].join(" ")' \
"$(srcdir)/gems/bundled_gems" | \
"$(IFCHANGE)" "$(srcdir)/gems/bundled_gems" -
@@ -1312,45 +1173,14 @@ test-bundled-gems-fetch: $(PREP)
$(Q) $(BASERUBY) -C $(srcdir)/gems ../tool/fetch-bundled_gems.rb src bundled_gems
test-bundled-gems-prepare: test-bundled-gems-precheck test-bundled-gems-fetch
- $(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
+ $(XRUBY) -C "$(srcdir)" bin/gem install --no-ri --no-rdoc \
--install-dir .bundle --conservative "bundler" "minitest:~> 5" 'test-unit' 'rake' 'hoe' 'yard' 'pry' 'packnga'
PREPARE_BUNDLED_GEMS = test-bundled-gems-prepare
test-bundled-gems: $(TEST_RUNNABLE)-test-bundled-gems
yes-test-bundled-gems: test-bundled-gems-run
no-test-bundled-gems:
-
-# Override this to allow failure of specific gems on CI
-# TEST_BUNDLED_GEMS_ALLOW_FAILURES =
-
test-bundled-gems-run: $(PREPARE_BUNDLED_GEMS)
- $(Q) $(XRUBY) $(srcdir)/tool/test-bundled-gems.rb
-
-test-bundler-precheck: $(arch)-fake.rb programs
-
-yes-test-bundler-prepare: test-bundler-precheck
- $(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
- --install-dir .bundle --conservative "rspec:~> 3.5" "rake:~> 12.0" "parallel_tests:~> 2.29"
-
-RSPECOPTS =
-BUNDLER_SPECS =
-test-bundler: $(TEST_RUNNABLE)-test-bundler
-yes-test-bundler: yes-test-bundler-prepare
- $(XRUBY) -C $(srcdir) -Ispec/bundler .bundle/bin/rspec \
- --require spec_helper $(RSPECOPTS) spec/bundler/$(BUNDLER_SPECS)
-no-test-bundler:
-
-PARALLELRSPECOPTS = --runtime-log $(srcdir)/tmp/parallel_runtime_rspec.log
-test-bundler-parallel: $(TEST_RUNNABLE)-test-bundler-parallel
-yes-test-bundler-parallel: yes-test-bundler-prepare
- $(XRUBY) -C $(srcdir) -Ispec/bundler .bundle/bin/parallel_rspec \
- -o "--require $(srcdir)/spec/bundler/spec_helper --require $(srcdir)/spec/bundler/support/parallel" \
- $(PARALLELRSPECOPTS) spec/bundler/$(BUNDLER_SPECS)
-no-test-bundler-parallel:
-
-GEM = up
-sync-default-gems:
- $(Q) $(XRUBY) -C "$(srcdir)" tool/sync_default_gems.rb $(GEM)
UNICODE_FILES = $(UNICODE_SRC_DATA_DIR)/UnicodeData.txt \
$(UNICODE_SRC_DATA_DIR)/CompositionExclusions.txt \
@@ -1367,96 +1197,71 @@ UNICODE_PROPERTY_FILES = \
$(UNICODE_SRC_DATA_DIR)/PropertyAliases.txt \
$(UNICODE_SRC_DATA_DIR)/PropertyValueAliases.txt \
$(UNICODE_SRC_DATA_DIR)/Scripts.txt \
- $(empty)
-
-UNICODE_AUXILIARY_FILES = \
$(UNICODE_SRC_DATA_DIR)/auxiliary/GraphemeBreakProperty.txt \
- $(UNICODE_SRC_DATA_DIR)/auxiliary/GraphemeBreakTest.txt \
$(empty)
UNICODE_EMOJI_FILES = \
$(UNICODE_SRC_EMOJI_DATA_DIR)/emoji-data.txt \
- $(UNICODE_SRC_EMOJI_DATA_DIR)/emoji-sequences.txt \
- $(UNICODE_SRC_EMOJI_DATA_DIR)/emoji-test.txt \
- $(UNICODE_SRC_EMOJI_DATA_DIR)/emoji-variation-sequences.txt \
- $(UNICODE_SRC_EMOJI_DATA_DIR)/emoji-zwj-sequences.txt \
$(empty)
-update-unicode: $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES) \
- $(UNICODE_AUXILIARY_FILES) $(UNICODE_EMOJI_FILES)
+update-unicode: $(UNICODE_FILES)
CACHE_DIR = $(srcdir)/.downloaded-cache
UNICODE_DOWNLOAD = \
$(BASERUBY) $(srcdir)/tool/downloader.rb \
--cache-dir=$(CACHE_DIR) \
- --unicode-beta $(UNICODE_BETA) \
-d $(UNICODE_SRC_DATA_DIR) \
-p $(UNICODE_VERSION)/ucd \
-e $(ALWAYS_UPDATE_UNICODE:yes=-a) unicode
-UNICODE_AUXILIARY_DOWNLOAD = \
- $(BASERUBY) $(srcdir)/tool/downloader.rb \
- --cache-dir=$(CACHE_DIR) \
- --unicode-beta $(UNICODE_BETA) \
- -d $(UNICODE_SRC_DATA_DIR)/auxiliary \
- -p $(UNICODE_VERSION)/ucd/auxiliary \
- -e $(ALWAYS_UPDATE_UNICODE:yes=-a) unicode
UNICODE_EMOJI_DOWNLOAD = \
$(BASERUBY) $(srcdir)/tool/downloader.rb \
--cache-dir=$(CACHE_DIR) \
- --unicode-beta $(UNICODE_BETA) \
-d $(UNICODE_SRC_EMOJI_DATA_DIR) \
-p emoji/$(UNICODE_EMOJI_VERSION) \
-e $(ALWAYS_UPDATE_UNICODE:yes=-a) unicode
-$(UNICODE_FILES) $(UNICODE_PROPERTY_FILES): update-unicode-files
-update-unicode-files:
- $(ECHO) Downloading Unicode $(UNICODE_VERSION) data and property files...
- $(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)"
- $(Q) $(UNICODE_DOWNLOAD) $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
-
-$(UNICODE_AUXILIARY_FILES): update-unicode-auxiliary-files
-update-unicode-auxiliary-files:
- $(ECHO) Downloading Unicode $(UNICODE_VERSION) auxiliary files...
+$(UNICODE_PROPERTY_FILES): update-unicode-property-files
+update-unicode-property-files:
+ $(ECHO) Downloading Unicode $(UNICODE_VERSION) property files...
$(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)/auxiliary"
- $(Q) $(UNICODE_AUXILIARY_DOWNLOAD) $(UNICODE_AUXILIARY_FILES)
-
-$(UNICODE_EMOJI_FILES): update-unicode-emoji-files
-update-unicode-emoji-files:
+ $(Q) $(UNICODE_DOWNLOAD) $(UNICODE_PROPERTY_FILES)
$(ECHO) Downloading Unicode emoji $(UNICODE_EMOJI_VERSION) files...
$(Q) $(MAKEDIRS) "$(UNICODE_SRC_EMOJI_DATA_DIR)"
$(Q) $(UNICODE_EMOJI_DOWNLOAD) $(UNICODE_EMOJI_FILES)
-$(srcdir)/lib/unicode_normalize/$(HAVE_BASERUBY:yes=tables.rb): \
+$(UNICODE_FILES): update-unicode-files
+update-unicode-files:
+ $(ECHO) Downloading Unicode $(UNICODE_VERSION) data files...
+ $(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)"
+ $(Q) $(UNICODE_DOWNLOAD) $(UNICODE_FILES)
+
+$(srcdir)/$(HAVE_BASERUBY:yes=lib/unicode_normalize/tables.rb): \
$(UNICODE_SRC_DATA_DIR)/.unicode-tables.time
$(UNICODE_SRC_DATA_DIR)/$(ALWAYS_UPDATE_UNICODE:yes=.unicode-tables.time): \
- $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES) \
- $(UNICODE_AUXILIARY_FILES) $(UNICODE_EMOJI_FILES)
+ $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
touch-unicode-files:
$(MAKEDIRS) $(UNICODE_SRC_DATA_DIR)
touch $(UNICODE_SRC_DATA_DIR)/.unicode-tables.time $(UNICODE_DATA_HEADERS)
-UNICODE_TABLES_TIMESTAMP = yes
$(UNICODE_SRC_DATA_DIR)/.unicode-tables.time: $(srcdir)/tool/generic_erb.rb \
$(srcdir)/template/unicode_norm_gen.tmpl \
$(ALWAYS_UPDATE_UNICODE:yes=update-unicode)
$(Q) $(MAKE) $(@D)
$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb \
- -c $(UNICODE_TABLES_TIMESTAMP:yes=-t$@) \
- -o $(srcdir)/lib/unicode_normalize/tables.rb \
+ -c -t$@ -o $(srcdir)/lib/unicode_normalize/tables.rb \
-I $(srcdir) \
$(srcdir)/template/unicode_norm_gen.tmpl \
$(UNICODE_DATA_DIR) lib/unicode_normalize
$(UNICODE_SRC_DATA_DIR):
- $(gnumake_recursive)$(Q) $(MAKEDIRS) $@
+ $(Q) $(exec) $(MAKEDIRS) $@ || exit && echo $(MAKE)
$(UNICODE_HDR_DIR)/$(ALWAYS_UPDATE_UNICODE:yes=name2ctype.h): \
$(srcdir)/tool/enc-unicode.rb \
$(UNICODE_SRC_DATA_DIR)/UnicodeData.txt \
- $(UNICODE_PROPERTY_FILES) \
- $(UNICODE_EMOJI_FILES)
+ $(UNICODE_PROPERTY_FILES)
$(UNICODE_HDR_DIR)/name2ctype.h:
$(MAKEDIRS) $(@D)
@@ -1505,7 +1310,10 @@ info-libruby_so: PHONY
info-arch: PHONY
@echo arch=$(arch)
-exam: check
+change: PHONY
+ $(BASERUBY) -C "$(srcdir)" ./tool/change_maker.rb $(CHANGES) > change.log
+
+exam: check test-spec
love: sudo-precheck up all test exam install
@echo love is all you need
@@ -1518,13 +1326,11 @@ sudo-precheck: PHONY
@$(SUDO) echo > $(NULL)
update-man-date: PHONY
- -$(Q) $(BASERUBY) -I"$(srcdir)/tool/lib" -rvcs -i -p \
+ -$(Q) $(BASERUBY) -I"$(srcdir)/tool" -rvcs -i -p \
-e 'BEGIN{@vcs=VCS.detect(ARGV.shift)}' \
-e '$$_.sub!(/^(\.Dd ).*/){$$1+@vcs.modified(ARGF.path).strftime("%B %d, %Y")}' \
"$(srcdir)" "$(srcdir)"/man/*.1
-HELP_EXTRA_TASKS = ""
-
help: PHONY
$(MESSAGE_BEGIN) \
" Makefile of Ruby" \
@@ -1541,26 +1347,25 @@ help: PHONY
" runruby: runs test.rb by ruby you just built" \
" gdb: runs test.rb by miniruby under gdb" \
" gdb-ruby: runs test.rb by ruby under gdb" \
- " check: equals make test test-tool test-all test-spec" \
- " test: ruby core tests [BTESTS=<bootstraptest files>]" \
+ " check: equals make test test-all" \
+ " exam: equals make check test-spec" \
+ " test: ruby core tests" \
" test-all: all ruby tests [TESTOPTS=-j4 TESTS=<test files>]" \
- " test-spec: run the Ruby spec suite [SPECOPTS=<specs, opts>]" \
- " test-bundler: run the Bundler spec" \
+ " test-spec: run the Ruby spec suite" \
+ " test-rubyspec: same as test-spec" \
" test-bundled-gems: run the test suite of bundled gems" \
- " test-tool: tests under the tool/test" \
- " update-gems: download files of the bundled gems" \
- " update-bundled_gems: update the latest version of bundled gems" \
- " sync-default-gems: sync default gems from upstream [GEM=<gem_name>]" \
" up: update local copy and autogenerated files" \
" benchmark: benchmark this ruby and COMPARE_RUBY." \
" gcbench: gc benchmark [GCBENCH_ITEM=<item_name>]" \
+ " gcbench-rdoc: gc benchmark with GCBENCH_ITEM=rdoc" \
" install: install all ruby distributions" \
" install-nodoc: install without rdoc" \
" install-cross: install cross compiling stuff" \
" clean: clean for tarball" \
" distclean: clean for repository" \
- " golf: build goruby for golfers" \
- $(HELP_EXTRA_TASKS) \
+ " change: make change log template" \
+ " golf: for golfers" \
+ "" \
"see DeveloperHowto for more detail: " \
" https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto" \
$(MESSAGE_END)
@@ -1569,12 +1374,10 @@ help: PHONY
addr2line.$(OBJEXT): {$(VPATH)}addr2line.c
addr2line.$(OBJEXT): {$(VPATH)}addr2line.h
addr2line.$(OBJEXT): {$(VPATH)}config.h
-addr2line.$(OBJEXT): {$(VPATH)}defines.h
addr2line.$(OBJEXT): {$(VPATH)}missing.h
-array.$(OBJEXT): $(hdrdir)/ruby.h
array.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+array.$(OBJEXT): $(top_srcdir)/include/ruby.h
array.$(OBJEXT): {$(VPATH)}array.c
-array.$(OBJEXT): {$(VPATH)}assert.h
array.$(OBJEXT): {$(VPATH)}config.h
array.$(OBJEXT): {$(VPATH)}debug_counter.h
array.$(OBJEXT): {$(VPATH)}defines.h
@@ -1582,6 +1385,7 @@ array.$(OBJEXT): {$(VPATH)}encoding.h
array.$(OBJEXT): {$(VPATH)}id.h
array.$(OBJEXT): {$(VPATH)}intern.h
array.$(OBJEXT): {$(VPATH)}internal.h
+array.$(OBJEXT): {$(VPATH)}io.h
array.$(OBJEXT): {$(VPATH)}missing.h
array.$(OBJEXT): {$(VPATH)}onigmo.h
array.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -1590,99 +1394,46 @@ array.$(OBJEXT): {$(VPATH)}probes.h
array.$(OBJEXT): {$(VPATH)}ruby_assert.h
array.$(OBJEXT): {$(VPATH)}st.h
array.$(OBJEXT): {$(VPATH)}subst.h
-array.$(OBJEXT): {$(VPATH)}transient_heap.h
array.$(OBJEXT): {$(VPATH)}util.h
-ast.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-ast.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-ast.$(OBJEXT): $(CCAN_DIR)/list/list.h
-ast.$(OBJEXT): $(CCAN_DIR)/str/str.h
-ast.$(OBJEXT): $(hdrdir)/ruby.h
-ast.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-ast.$(OBJEXT): {$(VPATH)}assert.h
-ast.$(OBJEXT): {$(VPATH)}ast.c
-ast.$(OBJEXT): {$(VPATH)}ast.rbinc
-ast.$(OBJEXT): {$(VPATH)}builtin.h
-ast.$(OBJEXT): {$(VPATH)}config.h
-ast.$(OBJEXT): {$(VPATH)}defines.h
-ast.$(OBJEXT): {$(VPATH)}encoding.h
-ast.$(OBJEXT): {$(VPATH)}id.h
-ast.$(OBJEXT): {$(VPATH)}intern.h
-ast.$(OBJEXT): {$(VPATH)}internal.h
-ast.$(OBJEXT): {$(VPATH)}iseq.h
-ast.$(OBJEXT): {$(VPATH)}method.h
-ast.$(OBJEXT): {$(VPATH)}missing.h
-ast.$(OBJEXT): {$(VPATH)}node.h
-ast.$(OBJEXT): {$(VPATH)}onigmo.h
-ast.$(OBJEXT): {$(VPATH)}oniguruma.h
-ast.$(OBJEXT): {$(VPATH)}ruby_assert.h
-ast.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-ast.$(OBJEXT): {$(VPATH)}st.h
-ast.$(OBJEXT): {$(VPATH)}subst.h
-ast.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-ast.$(OBJEXT): {$(VPATH)}thread_native.h
-ast.$(OBJEXT): {$(VPATH)}util.h
-ast.$(OBJEXT): {$(VPATH)}vm_core.h
-ast.$(OBJEXT): {$(VPATH)}vm_opts.h
-bignum.$(OBJEXT): $(hdrdir)/ruby.h
bignum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-bignum.$(OBJEXT): {$(VPATH)}assert.h
+bignum.$(OBJEXT): $(top_srcdir)/include/ruby.h
bignum.$(OBJEXT): {$(VPATH)}bignum.c
bignum.$(OBJEXT): {$(VPATH)}config.h
bignum.$(OBJEXT): {$(VPATH)}defines.h
+bignum.$(OBJEXT): {$(VPATH)}encoding.h
bignum.$(OBJEXT): {$(VPATH)}id.h
bignum.$(OBJEXT): {$(VPATH)}intern.h
bignum.$(OBJEXT): {$(VPATH)}internal.h
+bignum.$(OBJEXT): {$(VPATH)}io.h
bignum.$(OBJEXT): {$(VPATH)}missing.h
+bignum.$(OBJEXT): {$(VPATH)}onigmo.h
+bignum.$(OBJEXT): {$(VPATH)}oniguruma.h
bignum.$(OBJEXT): {$(VPATH)}ruby_assert.h
bignum.$(OBJEXT): {$(VPATH)}st.h
bignum.$(OBJEXT): {$(VPATH)}subst.h
bignum.$(OBJEXT): {$(VPATH)}thread.h
bignum.$(OBJEXT): {$(VPATH)}util.h
-builtin.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-builtin.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-builtin.$(OBJEXT): $(CCAN_DIR)/list/list.h
-builtin.$(OBJEXT): $(CCAN_DIR)/str/str.h
-builtin.$(OBJEXT): $(hdrdir)/ruby.h
-builtin.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-builtin.$(OBJEXT): {$(VPATH)}assert.h
-builtin.$(OBJEXT): {$(VPATH)}builtin.c
-builtin.$(OBJEXT): {$(VPATH)}builtin.h
-builtin.$(OBJEXT): {$(VPATH)}builtin_binary.inc
-builtin.$(OBJEXT): {$(VPATH)}config.h
-builtin.$(OBJEXT): {$(VPATH)}defines.h
-builtin.$(OBJEXT): {$(VPATH)}id.h
-builtin.$(OBJEXT): {$(VPATH)}intern.h
-builtin.$(OBJEXT): {$(VPATH)}internal.h
-builtin.$(OBJEXT): {$(VPATH)}iseq.h
-builtin.$(OBJEXT): {$(VPATH)}method.h
-builtin.$(OBJEXT): {$(VPATH)}missing.h
-builtin.$(OBJEXT): {$(VPATH)}node.h
-builtin.$(OBJEXT): {$(VPATH)}ruby_assert.h
-builtin.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-builtin.$(OBJEXT): {$(VPATH)}st.h
-builtin.$(OBJEXT): {$(VPATH)}subst.h
-builtin.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-builtin.$(OBJEXT): {$(VPATH)}thread_native.h
-builtin.$(OBJEXT): {$(VPATH)}vm_core.h
-builtin.$(OBJEXT): {$(VPATH)}vm_opts.h
class.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
class.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
class.$(OBJEXT): $(CCAN_DIR)/list/list.h
class.$(OBJEXT): $(CCAN_DIR)/str/str.h
-class.$(OBJEXT): $(hdrdir)/ruby.h
class.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-class.$(OBJEXT): {$(VPATH)}assert.h
+class.$(OBJEXT): $(top_srcdir)/include/ruby.h
class.$(OBJEXT): {$(VPATH)}class.c
class.$(OBJEXT): {$(VPATH)}config.h
class.$(OBJEXT): {$(VPATH)}constant.h
class.$(OBJEXT): {$(VPATH)}defines.h
+class.$(OBJEXT): {$(VPATH)}encoding.h
class.$(OBJEXT): {$(VPATH)}id.h
class.$(OBJEXT): {$(VPATH)}id_table.h
class.$(OBJEXT): {$(VPATH)}intern.h
class.$(OBJEXT): {$(VPATH)}internal.h
+class.$(OBJEXT): {$(VPATH)}io.h
class.$(OBJEXT): {$(VPATH)}method.h
class.$(OBJEXT): {$(VPATH)}missing.h
class.$(OBJEXT): {$(VPATH)}node.h
+class.$(OBJEXT): {$(VPATH)}onigmo.h
+class.$(OBJEXT): {$(VPATH)}oniguruma.h
class.$(OBJEXT): {$(VPATH)}ruby_assert.h
class.$(OBJEXT): {$(VPATH)}ruby_atomic.h
class.$(OBJEXT): {$(VPATH)}st.h
@@ -1690,16 +1441,14 @@ class.$(OBJEXT): {$(VPATH)}subst.h
class.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
class.$(OBJEXT): {$(VPATH)}thread_native.h
class.$(OBJEXT): {$(VPATH)}vm_core.h
+class.$(OBJEXT): {$(VPATH)}vm_debug.h
class.$(OBJEXT): {$(VPATH)}vm_opts.h
-compar.$(OBJEXT): $(hdrdir)/ruby.h
compar.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-compar.$(OBJEXT): {$(VPATH)}assert.h
compar.$(OBJEXT): {$(VPATH)}compar.c
compar.$(OBJEXT): {$(VPATH)}config.h
compar.$(OBJEXT): {$(VPATH)}defines.h
compar.$(OBJEXT): {$(VPATH)}id.h
compar.$(OBJEXT): {$(VPATH)}intern.h
-compar.$(OBJEXT): {$(VPATH)}internal.h
compar.$(OBJEXT): {$(VPATH)}missing.h
compar.$(OBJEXT): {$(VPATH)}st.h
compar.$(OBJEXT): {$(VPATH)}subst.h
@@ -1707,10 +1456,9 @@ compile.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
compile.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
compile.$(OBJEXT): $(CCAN_DIR)/list/list.h
compile.$(OBJEXT): $(CCAN_DIR)/str/str.h
-compile.$(OBJEXT): $(hdrdir)/ruby.h
compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-compile.$(OBJEXT): {$(VPATH)}assert.h
-compile.$(OBJEXT): {$(VPATH)}builtin.h
+compile.$(OBJEXT): $(hdrdir)/ruby/version.h
+compile.$(OBJEXT): $(top_srcdir)/include/ruby.h
compile.$(OBJEXT): {$(VPATH)}compile.c
compile.$(OBJEXT): {$(VPATH)}config.h
compile.$(OBJEXT): {$(VPATH)}defines.h
@@ -1719,11 +1467,11 @@ compile.$(OBJEXT): {$(VPATH)}encoding.h
compile.$(OBJEXT): {$(VPATH)}gc.h
compile.$(OBJEXT): {$(VPATH)}id.h
compile.$(OBJEXT): {$(VPATH)}id_table.h
-compile.$(OBJEXT): {$(VPATH)}insns.def
compile.$(OBJEXT): {$(VPATH)}insns.inc
compile.$(OBJEXT): {$(VPATH)}insns_info.inc
compile.$(OBJEXT): {$(VPATH)}intern.h
compile.$(OBJEXT): {$(VPATH)}internal.h
+compile.$(OBJEXT): {$(VPATH)}io.h
compile.$(OBJEXT): {$(VPATH)}iseq.h
compile.$(OBJEXT): {$(VPATH)}method.h
compile.$(OBJEXT): {$(VPATH)}missing.h
@@ -1741,20 +1489,21 @@ compile.$(OBJEXT): {$(VPATH)}st.h
compile.$(OBJEXT): {$(VPATH)}subst.h
compile.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
compile.$(OBJEXT): {$(VPATH)}thread_native.h
-compile.$(OBJEXT): {$(VPATH)}util.h
compile.$(OBJEXT): {$(VPATH)}vm_core.h
compile.$(OBJEXT): {$(VPATH)}vm_debug.h
compile.$(OBJEXT): {$(VPATH)}vm_opts.h
-complex.$(OBJEXT): $(hdrdir)/ruby.h
complex.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-complex.$(OBJEXT): {$(VPATH)}assert.h
+complex.$(OBJEXT): $(top_srcdir)/include/ruby.h
complex.$(OBJEXT): {$(VPATH)}complex.c
complex.$(OBJEXT): {$(VPATH)}config.h
complex.$(OBJEXT): {$(VPATH)}defines.h
-complex.$(OBJEXT): {$(VPATH)}id.h
+complex.$(OBJEXT): {$(VPATH)}encoding.h
complex.$(OBJEXT): {$(VPATH)}intern.h
complex.$(OBJEXT): {$(VPATH)}internal.h
+complex.$(OBJEXT): {$(VPATH)}io.h
complex.$(OBJEXT): {$(VPATH)}missing.h
+complex.$(OBJEXT): {$(VPATH)}onigmo.h
+complex.$(OBJEXT): {$(VPATH)}oniguruma.h
complex.$(OBJEXT): {$(VPATH)}ruby_assert.h
complex.$(OBJEXT): {$(VPATH)}st.h
complex.$(OBJEXT): {$(VPATH)}subst.h
@@ -1762,23 +1511,23 @@ cont.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
cont.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
cont.$(OBJEXT): $(CCAN_DIR)/list/list.h
cont.$(OBJEXT): $(CCAN_DIR)/str/str.h
-cont.$(OBJEXT): $(hdrdir)/ruby.h
cont.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-cont.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
-cont.$(OBJEXT): {$(VPATH)}assert.h
+cont.$(OBJEXT): $(top_srcdir)/include/ruby.h
cont.$(OBJEXT): {$(VPATH)}config.h
cont.$(OBJEXT): {$(VPATH)}cont.c
-cont.$(OBJEXT): {$(VPATH)}debug_counter.h
cont.$(OBJEXT): {$(VPATH)}defines.h
+cont.$(OBJEXT): {$(VPATH)}encoding.h
cont.$(OBJEXT): {$(VPATH)}eval_intern.h
cont.$(OBJEXT): {$(VPATH)}gc.h
cont.$(OBJEXT): {$(VPATH)}id.h
cont.$(OBJEXT): {$(VPATH)}intern.h
cont.$(OBJEXT): {$(VPATH)}internal.h
+cont.$(OBJEXT): {$(VPATH)}io.h
cont.$(OBJEXT): {$(VPATH)}method.h
cont.$(OBJEXT): {$(VPATH)}missing.h
-cont.$(OBJEXT): {$(VPATH)}mjit.h
cont.$(OBJEXT): {$(VPATH)}node.h
+cont.$(OBJEXT): {$(VPATH)}onigmo.h
+cont.$(OBJEXT): {$(VPATH)}oniguruma.h
cont.$(OBJEXT): {$(VPATH)}ruby_assert.h
cont.$(OBJEXT): {$(VPATH)}ruby_atomic.h
cont.$(OBJEXT): {$(VPATH)}st.h
@@ -1786,14 +1535,14 @@ cont.$(OBJEXT): {$(VPATH)}subst.h
cont.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
cont.$(OBJEXT): {$(VPATH)}thread_native.h
cont.$(OBJEXT): {$(VPATH)}vm_core.h
+cont.$(OBJEXT): {$(VPATH)}vm_debug.h
cont.$(OBJEXT): {$(VPATH)}vm_opts.h
debug.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
debug.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
debug.$(OBJEXT): $(CCAN_DIR)/list/list.h
debug.$(OBJEXT): $(CCAN_DIR)/str/str.h
-debug.$(OBJEXT): $(hdrdir)/ruby.h
debug.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-debug.$(OBJEXT): {$(VPATH)}assert.h
+debug.$(OBJEXT): $(top_srcdir)/include/ruby.h
debug.$(OBJEXT): {$(VPATH)}config.h
debug.$(OBJEXT): {$(VPATH)}debug.c
debug.$(OBJEXT): {$(VPATH)}defines.h
@@ -1820,50 +1569,47 @@ debug.$(OBJEXT): {$(VPATH)}util.h
debug.$(OBJEXT): {$(VPATH)}vm_core.h
debug.$(OBJEXT): {$(VPATH)}vm_debug.h
debug.$(OBJEXT): {$(VPATH)}vm_opts.h
-debug_counter.$(OBJEXT): $(hdrdir)/ruby.h
debug_counter.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-debug_counter.$(OBJEXT): {$(VPATH)}assert.h
+debug_counter.$(OBJEXT): $(top_srcdir)/include/ruby.h
debug_counter.$(OBJEXT): {$(VPATH)}config.h
debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.c
debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.h
debug_counter.$(OBJEXT): {$(VPATH)}defines.h
+debug_counter.$(OBJEXT): {$(VPATH)}encoding.h
debug_counter.$(OBJEXT): {$(VPATH)}intern.h
debug_counter.$(OBJEXT): {$(VPATH)}internal.h
+debug_counter.$(OBJEXT): {$(VPATH)}io.h
debug_counter.$(OBJEXT): {$(VPATH)}missing.h
+debug_counter.$(OBJEXT): {$(VPATH)}onigmo.h
+debug_counter.$(OBJEXT): {$(VPATH)}oniguruma.h
debug_counter.$(OBJEXT): {$(VPATH)}st.h
debug_counter.$(OBJEXT): {$(VPATH)}subst.h
-dir.$(OBJEXT): $(hdrdir)/ruby.h
dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dir.$(OBJEXT): {$(VPATH)}assert.h
+dir.$(OBJEXT): $(top_srcdir)/include/ruby.h
dir.$(OBJEXT): {$(VPATH)}config.h
dir.$(OBJEXT): {$(VPATH)}defines.h
dir.$(OBJEXT): {$(VPATH)}dir.c
dir.$(OBJEXT): {$(VPATH)}encindex.h
dir.$(OBJEXT): {$(VPATH)}encoding.h
-dir.$(OBJEXT): {$(VPATH)}id.h
dir.$(OBJEXT): {$(VPATH)}intern.h
dir.$(OBJEXT): {$(VPATH)}internal.h
+dir.$(OBJEXT): {$(VPATH)}io.h
dir.$(OBJEXT): {$(VPATH)}missing.h
dir.$(OBJEXT): {$(VPATH)}onigmo.h
dir.$(OBJEXT): {$(VPATH)}oniguruma.h
dir.$(OBJEXT): {$(VPATH)}st.h
dir.$(OBJEXT): {$(VPATH)}subst.h
-dir.$(OBJEXT): {$(VPATH)}thread.h
dir.$(OBJEXT): {$(VPATH)}util.h
-dln.$(OBJEXT): $(hdrdir)/ruby.h
dln.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dln.$(OBJEXT): {$(VPATH)}assert.h
dln.$(OBJEXT): {$(VPATH)}config.h
dln.$(OBJEXT): {$(VPATH)}defines.h
dln.$(OBJEXT): {$(VPATH)}dln.c
dln.$(OBJEXT): {$(VPATH)}dln.h
dln.$(OBJEXT): {$(VPATH)}intern.h
-dln.$(OBJEXT): {$(VPATH)}internal.h
dln.$(OBJEXT): {$(VPATH)}missing.h
dln.$(OBJEXT): {$(VPATH)}st.h
dln.$(OBJEXT): {$(VPATH)}subst.h
dln_find.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dln_find.$(OBJEXT): {$(VPATH)}assert.h
dln_find.$(OBJEXT): {$(VPATH)}config.h
dln_find.$(OBJEXT): {$(VPATH)}defines.h
dln_find.$(OBJEXT): {$(VPATH)}dln.h
@@ -1873,7 +1619,6 @@ dln_find.$(OBJEXT): {$(VPATH)}missing.h
dln_find.$(OBJEXT): {$(VPATH)}st.h
dln_find.$(OBJEXT): {$(VPATH)}subst.h
dmydln.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dmydln.$(OBJEXT): {$(VPATH)}assert.h
dmydln.$(OBJEXT): {$(VPATH)}config.h
dmydln.$(OBJEXT): {$(VPATH)}defines.h
dmydln.$(OBJEXT): {$(VPATH)}dmydln.c
@@ -1888,6 +1633,7 @@ enc/ascii.$(OBJEXT): {$(VPATH)}defines.h
enc/ascii.$(OBJEXT): {$(VPATH)}enc/ascii.c
enc/ascii.$(OBJEXT): {$(VPATH)}encindex.h
enc/ascii.$(OBJEXT): {$(VPATH)}missing.h
+enc/ascii.$(OBJEXT): {$(VPATH)}oniguruma.h
enc/ascii.$(OBJEXT): {$(VPATH)}regenc.h
enc/trans/newline.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}config.h
@@ -1906,7 +1652,7 @@ enc/unicode.$(OBJEXT): {$(VPATH)}defines.h
enc/unicode.$(OBJEXT): {$(VPATH)}enc/unicode.c
enc/unicode.$(OBJEXT): {$(VPATH)}intern.h
enc/unicode.$(OBJEXT): {$(VPATH)}missing.h
-enc/unicode.$(OBJEXT): {$(VPATH)}onigmo.h
+enc/unicode.$(OBJEXT): {$(VPATH)}oniguruma.h
enc/unicode.$(OBJEXT): {$(VPATH)}regenc.h
enc/unicode.$(OBJEXT): {$(VPATH)}regint.h
enc/unicode.$(OBJEXT): {$(VPATH)}st.h
@@ -1916,16 +1662,17 @@ enc/us_ascii.$(OBJEXT): {$(VPATH)}defines.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}enc/us_ascii.c
enc/us_ascii.$(OBJEXT): {$(VPATH)}encindex.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}missing.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}oniguruma.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}regenc.h
enc/utf_8.$(OBJEXT): {$(VPATH)}config.h
enc/utf_8.$(OBJEXT): {$(VPATH)}defines.h
enc/utf_8.$(OBJEXT): {$(VPATH)}enc/utf_8.c
enc/utf_8.$(OBJEXT): {$(VPATH)}encindex.h
enc/utf_8.$(OBJEXT): {$(VPATH)}missing.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}oniguruma.h
enc/utf_8.$(OBJEXT): {$(VPATH)}regenc.h
-encoding.$(OBJEXT): $(hdrdir)/ruby.h
encoding.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-encoding.$(OBJEXT): {$(VPATH)}assert.h
+encoding.$(OBJEXT): $(top_srcdir)/include/ruby.h
encoding.$(OBJEXT): {$(VPATH)}config.h
encoding.$(OBJEXT): {$(VPATH)}defines.h
encoding.$(OBJEXT): {$(VPATH)}encindex.h
@@ -1933,6 +1680,7 @@ encoding.$(OBJEXT): {$(VPATH)}encoding.c
encoding.$(OBJEXT): {$(VPATH)}encoding.h
encoding.$(OBJEXT): {$(VPATH)}intern.h
encoding.$(OBJEXT): {$(VPATH)}internal.h
+encoding.$(OBJEXT): {$(VPATH)}io.h
encoding.$(OBJEXT): {$(VPATH)}missing.h
encoding.$(OBJEXT): {$(VPATH)}onigmo.h
encoding.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -1941,9 +1689,8 @@ encoding.$(OBJEXT): {$(VPATH)}ruby_assert.h
encoding.$(OBJEXT): {$(VPATH)}st.h
encoding.$(OBJEXT): {$(VPATH)}subst.h
encoding.$(OBJEXT): {$(VPATH)}util.h
-enum.$(OBJEXT): $(hdrdir)/ruby.h
enum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enum.$(OBJEXT): {$(VPATH)}assert.h
+enum.$(OBJEXT): $(top_srcdir)/include/ruby.h
enum.$(OBJEXT): {$(VPATH)}config.h
enum.$(OBJEXT): {$(VPATH)}defines.h
enum.$(OBJEXT): {$(VPATH)}encoding.h
@@ -1951,6 +1698,7 @@ enum.$(OBJEXT): {$(VPATH)}enum.c
enum.$(OBJEXT): {$(VPATH)}id.h
enum.$(OBJEXT): {$(VPATH)}intern.h
enum.$(OBJEXT): {$(VPATH)}internal.h
+enum.$(OBJEXT): {$(VPATH)}io.h
enum.$(OBJEXT): {$(VPATH)}missing.h
enum.$(OBJEXT): {$(VPATH)}onigmo.h
enum.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -1958,34 +1706,34 @@ enum.$(OBJEXT): {$(VPATH)}st.h
enum.$(OBJEXT): {$(VPATH)}subst.h
enum.$(OBJEXT): {$(VPATH)}symbol.h
enum.$(OBJEXT): {$(VPATH)}util.h
-enumerator.$(OBJEXT): $(hdrdir)/ruby.h
enumerator.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enumerator.$(OBJEXT): {$(VPATH)}assert.h
+enumerator.$(OBJEXT): $(top_srcdir)/include/ruby.h
enumerator.$(OBJEXT): {$(VPATH)}config.h
enumerator.$(OBJEXT): {$(VPATH)}defines.h
+enumerator.$(OBJEXT): {$(VPATH)}encoding.h
enumerator.$(OBJEXT): {$(VPATH)}enumerator.c
-enumerator.$(OBJEXT): {$(VPATH)}id.h
enumerator.$(OBJEXT): {$(VPATH)}intern.h
enumerator.$(OBJEXT): {$(VPATH)}internal.h
+enumerator.$(OBJEXT): {$(VPATH)}io.h
enumerator.$(OBJEXT): {$(VPATH)}missing.h
+enumerator.$(OBJEXT): {$(VPATH)}onigmo.h
+enumerator.$(OBJEXT): {$(VPATH)}oniguruma.h
enumerator.$(OBJEXT): {$(VPATH)}st.h
enumerator.$(OBJEXT): {$(VPATH)}subst.h
error.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
error.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
error.$(OBJEXT): $(CCAN_DIR)/list/list.h
error.$(OBJEXT): $(CCAN_DIR)/str/str.h
-error.$(OBJEXT): $(hdrdir)/ruby.h
error.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-error.$(OBJEXT): {$(VPATH)}assert.h
-error.$(OBJEXT): {$(VPATH)}builtin.h
+error.$(OBJEXT): $(top_srcdir)/include/ruby.h
error.$(OBJEXT): {$(VPATH)}config.h
error.$(OBJEXT): {$(VPATH)}defines.h
error.$(OBJEXT): {$(VPATH)}encoding.h
error.$(OBJEXT): {$(VPATH)}error.c
-error.$(OBJEXT): {$(VPATH)}eval_intern.h
error.$(OBJEXT): {$(VPATH)}id.h
error.$(OBJEXT): {$(VPATH)}intern.h
error.$(OBJEXT): {$(VPATH)}internal.h
+error.$(OBJEXT): {$(VPATH)}io.h
error.$(OBJEXT): {$(VPATH)}known_errors.inc
error.$(OBJEXT): {$(VPATH)}method.h
error.$(OBJEXT): {$(VPATH)}missing.h
@@ -1999,18 +1747,18 @@ error.$(OBJEXT): {$(VPATH)}subst.h
error.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
error.$(OBJEXT): {$(VPATH)}thread_native.h
error.$(OBJEXT): {$(VPATH)}vm_core.h
+error.$(OBJEXT): {$(VPATH)}vm_debug.h
error.$(OBJEXT): {$(VPATH)}vm_opts.h
-error.$(OBJEXT): {$(VPATH)}warning.rbinc
eval.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
eval.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
eval.$(OBJEXT): $(CCAN_DIR)/list/list.h
eval.$(OBJEXT): $(CCAN_DIR)/str/str.h
-eval.$(OBJEXT): $(hdrdir)/ruby.h
eval.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-eval.$(OBJEXT): {$(VPATH)}assert.h
+eval.$(OBJEXT): $(hdrdir)/ruby/version.h
+eval.$(OBJEXT): $(top_srcdir)/include/ruby.h
eval.$(OBJEXT): {$(VPATH)}config.h
-eval.$(OBJEXT): {$(VPATH)}debug_counter.h
eval.$(OBJEXT): {$(VPATH)}defines.h
+eval.$(OBJEXT): {$(VPATH)}encoding.h
eval.$(OBJEXT): {$(VPATH)}eval.c
eval.$(OBJEXT): {$(VPATH)}eval_error.c
eval.$(OBJEXT): {$(VPATH)}eval_intern.h
@@ -2019,11 +1767,13 @@ eval.$(OBJEXT): {$(VPATH)}gc.h
eval.$(OBJEXT): {$(VPATH)}id.h
eval.$(OBJEXT): {$(VPATH)}intern.h
eval.$(OBJEXT): {$(VPATH)}internal.h
+eval.$(OBJEXT): {$(VPATH)}io.h
eval.$(OBJEXT): {$(VPATH)}iseq.h
eval.$(OBJEXT): {$(VPATH)}method.h
eval.$(OBJEXT): {$(VPATH)}missing.h
-eval.$(OBJEXT): {$(VPATH)}mjit.h
eval.$(OBJEXT): {$(VPATH)}node.h
+eval.$(OBJEXT): {$(VPATH)}onigmo.h
+eval.$(OBJEXT): {$(VPATH)}oniguruma.h
eval.$(OBJEXT): {$(VPATH)}probes.dmyh
eval.$(OBJEXT): {$(VPATH)}probes.h
eval.$(OBJEXT): {$(VPATH)}probes_helper.h
@@ -2035,13 +1785,13 @@ eval.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
eval.$(OBJEXT): {$(VPATH)}thread_native.h
eval.$(OBJEXT): {$(VPATH)}vm.h
eval.$(OBJEXT): {$(VPATH)}vm_core.h
+eval.$(OBJEXT): {$(VPATH)}vm_debug.h
eval.$(OBJEXT): {$(VPATH)}vm_opts.h
explicit_bzero.$(OBJEXT): {$(VPATH)}config.h
explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
explicit_bzero.$(OBJEXT): {$(VPATH)}missing.h
-file.$(OBJEXT): $(hdrdir)/ruby.h
file.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-file.$(OBJEXT): {$(VPATH)}assert.h
+file.$(OBJEXT): $(top_srcdir)/include/ruby.h
file.$(OBJEXT): {$(VPATH)}config.h
file.$(OBJEXT): {$(VPATH)}defines.h
file.$(OBJEXT): {$(VPATH)}dln.h
@@ -2063,10 +1813,8 @@ gc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
gc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
gc.$(OBJEXT): $(CCAN_DIR)/list/list.h
gc.$(OBJEXT): $(CCAN_DIR)/str/str.h
-gc.$(OBJEXT): $(hdrdir)/ruby.h
gc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-gc.$(OBJEXT): {$(VPATH)}assert.h
-gc.$(OBJEXT): {$(VPATH)}builtin.h
+gc.$(OBJEXT): $(top_srcdir)/include/ruby.h
gc.$(OBJEXT): {$(VPATH)}config.h
gc.$(OBJEXT): {$(VPATH)}constant.h
gc.$(OBJEXT): {$(VPATH)}debug.h
@@ -2076,7 +1824,6 @@ gc.$(OBJEXT): {$(VPATH)}encoding.h
gc.$(OBJEXT): {$(VPATH)}eval_intern.h
gc.$(OBJEXT): {$(VPATH)}gc.c
gc.$(OBJEXT): {$(VPATH)}gc.h
-gc.$(OBJEXT): {$(VPATH)}gc.rbinc
gc.$(OBJEXT): {$(VPATH)}id.h
gc.$(OBJEXT): {$(VPATH)}id_table.h
gc.$(OBJEXT): {$(VPATH)}intern.h
@@ -2084,7 +1831,6 @@ gc.$(OBJEXT): {$(VPATH)}internal.h
gc.$(OBJEXT): {$(VPATH)}io.h
gc.$(OBJEXT): {$(VPATH)}method.h
gc.$(OBJEXT): {$(VPATH)}missing.h
-gc.$(OBJEXT): {$(VPATH)}mjit.h
gc.$(OBJEXT): {$(VPATH)}node.h
gc.$(OBJEXT): {$(VPATH)}onigmo.h
gc.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -2098,32 +1844,34 @@ gc.$(OBJEXT): {$(VPATH)}ruby_assert.h
gc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
gc.$(OBJEXT): {$(VPATH)}st.h
gc.$(OBJEXT): {$(VPATH)}subst.h
-gc.$(OBJEXT): {$(VPATH)}symbol.h
gc.$(OBJEXT): {$(VPATH)}thread.h
gc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
gc.$(OBJEXT): {$(VPATH)}thread_native.h
-gc.$(OBJEXT): {$(VPATH)}transient_heap.h
gc.$(OBJEXT): {$(VPATH)}util.h
gc.$(OBJEXT): {$(VPATH)}vm_core.h
+gc.$(OBJEXT): {$(VPATH)}vm_debug.h
gc.$(OBJEXT): {$(VPATH)}vm_opts.h
golf_prelude.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
golf_prelude.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
golf_prelude.$(OBJEXT): $(CCAN_DIR)/list/list.h
golf_prelude.$(OBJEXT): $(CCAN_DIR)/str/str.h
-golf_prelude.$(OBJEXT): $(hdrdir)/ruby.h
golf_prelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-golf_prelude.$(OBJEXT): {$(VPATH)}assert.h
+golf_prelude.$(OBJEXT): $(hdrdir)/ruby/version.h
+golf_prelude.$(OBJEXT): $(top_srcdir)/include/ruby.h
golf_prelude.$(OBJEXT): {$(VPATH)}config.h
golf_prelude.$(OBJEXT): {$(VPATH)}defines.h
+golf_prelude.$(OBJEXT): {$(VPATH)}encoding.h
golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c
-golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.rb
golf_prelude.$(OBJEXT): {$(VPATH)}id.h
golf_prelude.$(OBJEXT): {$(VPATH)}intern.h
golf_prelude.$(OBJEXT): {$(VPATH)}internal.h
+golf_prelude.$(OBJEXT): {$(VPATH)}io.h
golf_prelude.$(OBJEXT): {$(VPATH)}iseq.h
golf_prelude.$(OBJEXT): {$(VPATH)}method.h
golf_prelude.$(OBJEXT): {$(VPATH)}missing.h
golf_prelude.$(OBJEXT): {$(VPATH)}node.h
+golf_prelude.$(OBJEXT): {$(VPATH)}onigmo.h
+golf_prelude.$(OBJEXT): {$(VPATH)}oniguruma.h
golf_prelude.$(OBJEXT): {$(VPATH)}ruby_assert.h
golf_prelude.$(OBJEXT): {$(VPATH)}ruby_atomic.h
golf_prelude.$(OBJEXT): {$(VPATH)}st.h
@@ -2131,10 +1879,10 @@ golf_prelude.$(OBJEXT): {$(VPATH)}subst.h
golf_prelude.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
golf_prelude.$(OBJEXT): {$(VPATH)}thread_native.h
golf_prelude.$(OBJEXT): {$(VPATH)}vm_core.h
+golf_prelude.$(OBJEXT): {$(VPATH)}vm_debug.h
golf_prelude.$(OBJEXT): {$(VPATH)}vm_opts.h
-goruby.$(OBJEXT): $(hdrdir)/ruby.h
goruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-goruby.$(OBJEXT): {$(VPATH)}assert.h
+goruby.$(OBJEXT): $(top_srcdir)/include/ruby.h
goruby.$(OBJEXT): {$(VPATH)}backward.h
goruby.$(OBJEXT): {$(VPATH)}config.h
goruby.$(OBJEXT): {$(VPATH)}defines.h
@@ -2146,49 +1894,41 @@ goruby.$(OBJEXT): {$(VPATH)}node.h
goruby.$(OBJEXT): {$(VPATH)}st.h
goruby.$(OBJEXT): {$(VPATH)}subst.h
goruby.$(OBJEXT): {$(VPATH)}vm_debug.h
-hash.$(OBJEXT): $(hdrdir)/ruby.h
hash.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-hash.$(OBJEXT): {$(VPATH)}assert.h
+hash.$(OBJEXT): $(top_srcdir)/include/ruby.h
hash.$(OBJEXT): {$(VPATH)}config.h
-hash.$(OBJEXT): {$(VPATH)}debug_counter.h
hash.$(OBJEXT): {$(VPATH)}defines.h
hash.$(OBJEXT): {$(VPATH)}encoding.h
hash.$(OBJEXT): {$(VPATH)}hash.c
hash.$(OBJEXT): {$(VPATH)}id.h
hash.$(OBJEXT): {$(VPATH)}intern.h
hash.$(OBJEXT): {$(VPATH)}internal.h
+hash.$(OBJEXT): {$(VPATH)}io.h
hash.$(OBJEXT): {$(VPATH)}missing.h
hash.$(OBJEXT): {$(VPATH)}onigmo.h
hash.$(OBJEXT): {$(VPATH)}oniguruma.h
hash.$(OBJEXT): {$(VPATH)}probes.dmyh
hash.$(OBJEXT): {$(VPATH)}probes.h
-hash.$(OBJEXT): {$(VPATH)}ruby_assert.h
hash.$(OBJEXT): {$(VPATH)}st.h
hash.$(OBJEXT): {$(VPATH)}subst.h
hash.$(OBJEXT): {$(VPATH)}symbol.h
-hash.$(OBJEXT): {$(VPATH)}transient_heap.h
hash.$(OBJEXT): {$(VPATH)}util.h
-inits.$(OBJEXT): $(hdrdir)/ruby.h
inits.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-inits.$(OBJEXT): {$(VPATH)}assert.h
-inits.$(OBJEXT): {$(VPATH)}builtin.h
+inits.$(OBJEXT): $(top_srcdir)/include/ruby.h
inits.$(OBJEXT): {$(VPATH)}config.h
inits.$(OBJEXT): {$(VPATH)}defines.h
+inits.$(OBJEXT): {$(VPATH)}encoding.h
inits.$(OBJEXT): {$(VPATH)}inits.c
inits.$(OBJEXT): {$(VPATH)}intern.h
inits.$(OBJEXT): {$(VPATH)}internal.h
+inits.$(OBJEXT): {$(VPATH)}io.h
inits.$(OBJEXT): {$(VPATH)}missing.h
-inits.$(OBJEXT): {$(VPATH)}prelude.rbinc
+inits.$(OBJEXT): {$(VPATH)}onigmo.h
+inits.$(OBJEXT): {$(VPATH)}oniguruma.h
inits.$(OBJEXT): {$(VPATH)}st.h
inits.$(OBJEXT): {$(VPATH)}subst.h
-io.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-io.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-io.$(OBJEXT): $(CCAN_DIR)/list/list.h
-io.$(OBJEXT): $(CCAN_DIR)/str/str.h
-io.$(OBJEXT): $(hdrdir)/ruby.h
io.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-io.$(OBJEXT): {$(VPATH)}assert.h
-io.$(OBJEXT): {$(VPATH)}builtin.h
+io.$(OBJEXT): $(top_srcdir)/include/ruby.h
io.$(OBJEXT): {$(VPATH)}config.h
io.$(OBJEXT): {$(VPATH)}defines.h
io.$(OBJEXT): {$(VPATH)}dln.h
@@ -2199,49 +1939,41 @@ io.$(OBJEXT): {$(VPATH)}intern.h
io.$(OBJEXT): {$(VPATH)}internal.h
io.$(OBJEXT): {$(VPATH)}io.c
io.$(OBJEXT): {$(VPATH)}io.h
-io.$(OBJEXT): {$(VPATH)}io.rbinc
-io.$(OBJEXT): {$(VPATH)}method.h
io.$(OBJEXT): {$(VPATH)}missing.h
-io.$(OBJEXT): {$(VPATH)}node.h
io.$(OBJEXT): {$(VPATH)}onigmo.h
io.$(OBJEXT): {$(VPATH)}oniguruma.h
-io.$(OBJEXT): {$(VPATH)}ruby_assert.h
io.$(OBJEXT): {$(VPATH)}ruby_atomic.h
io.$(OBJEXT): {$(VPATH)}st.h
io.$(OBJEXT): {$(VPATH)}subst.h
io.$(OBJEXT): {$(VPATH)}thread.h
-io.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-io.$(OBJEXT): {$(VPATH)}thread_native.h
io.$(OBJEXT): {$(VPATH)}util.h
-io.$(OBJEXT): {$(VPATH)}vm_core.h
-io.$(OBJEXT): {$(VPATH)}vm_opts.h
iseq.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
iseq.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
iseq.$(OBJEXT): $(CCAN_DIR)/list/list.h
iseq.$(OBJEXT): $(CCAN_DIR)/str/str.h
-iseq.$(OBJEXT): $(hdrdir)/ruby.h
iseq.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-iseq.$(OBJEXT): {$(VPATH)}assert.h
-iseq.$(OBJEXT): {$(VPATH)}builtin.h
+iseq.$(OBJEXT): $(hdrdir)/ruby/version.h
+iseq.$(OBJEXT): $(top_srcdir)/include/ruby.h
iseq.$(OBJEXT): {$(VPATH)}config.h
-iseq.$(OBJEXT): {$(VPATH)}debug_counter.h
iseq.$(OBJEXT): {$(VPATH)}defines.h
+iseq.$(OBJEXT): {$(VPATH)}encoding.h
iseq.$(OBJEXT): {$(VPATH)}eval_intern.h
iseq.$(OBJEXT): {$(VPATH)}gc.h
iseq.$(OBJEXT): {$(VPATH)}id.h
iseq.$(OBJEXT): {$(VPATH)}id_table.h
-iseq.$(OBJEXT): {$(VPATH)}insns.def
iseq.$(OBJEXT): {$(VPATH)}insns.inc
iseq.$(OBJEXT): {$(VPATH)}insns_info.inc
iseq.$(OBJEXT): {$(VPATH)}intern.h
iseq.$(OBJEXT): {$(VPATH)}internal.h
+iseq.$(OBJEXT): {$(VPATH)}io.h
iseq.$(OBJEXT): {$(VPATH)}iseq.c
iseq.$(OBJEXT): {$(VPATH)}iseq.h
iseq.$(OBJEXT): {$(VPATH)}method.h
iseq.$(OBJEXT): {$(VPATH)}missing.h
-iseq.$(OBJEXT): {$(VPATH)}mjit.h
iseq.$(OBJEXT): {$(VPATH)}node.h
iseq.$(OBJEXT): {$(VPATH)}node_name.inc
+iseq.$(OBJEXT): {$(VPATH)}onigmo.h
+iseq.$(OBJEXT): {$(VPATH)}oniguruma.h
iseq.$(OBJEXT): {$(VPATH)}ruby_assert.h
iseq.$(OBJEXT): {$(VPATH)}ruby_atomic.h
iseq.$(OBJEXT): {$(VPATH)}st.h
@@ -2250,14 +1982,14 @@ iseq.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
iseq.$(OBJEXT): {$(VPATH)}thread_native.h
iseq.$(OBJEXT): {$(VPATH)}util.h
iseq.$(OBJEXT): {$(VPATH)}vm_core.h
+iseq.$(OBJEXT): {$(VPATH)}vm_debug.h
iseq.$(OBJEXT): {$(VPATH)}vm_opts.h
load.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
load.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
load.$(OBJEXT): $(CCAN_DIR)/list/list.h
load.$(OBJEXT): $(CCAN_DIR)/str/str.h
-load.$(OBJEXT): $(hdrdir)/ruby.h
load.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-load.$(OBJEXT): {$(VPATH)}assert.h
+load.$(OBJEXT): $(top_srcdir)/include/ruby.h
load.$(OBJEXT): {$(VPATH)}config.h
load.$(OBJEXT): {$(VPATH)}defines.h
load.$(OBJEXT): {$(VPATH)}dln.h
@@ -2266,7 +1998,7 @@ load.$(OBJEXT): {$(VPATH)}eval_intern.h
load.$(OBJEXT): {$(VPATH)}id.h
load.$(OBJEXT): {$(VPATH)}intern.h
load.$(OBJEXT): {$(VPATH)}internal.h
-load.$(OBJEXT): {$(VPATH)}iseq.h
+load.$(OBJEXT): {$(VPATH)}io.h
load.$(OBJEXT): {$(VPATH)}load.c
load.$(OBJEXT): {$(VPATH)}method.h
load.$(OBJEXT): {$(VPATH)}missing.h
@@ -2283,11 +2015,11 @@ load.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
load.$(OBJEXT): {$(VPATH)}thread_native.h
load.$(OBJEXT): {$(VPATH)}util.h
load.$(OBJEXT): {$(VPATH)}vm_core.h
+load.$(OBJEXT): {$(VPATH)}vm_debug.h
load.$(OBJEXT): {$(VPATH)}vm_opts.h
loadpath.$(OBJEXT): $(hdrdir)/ruby/ruby.h
loadpath.$(OBJEXT): $(hdrdir)/ruby/version.h
loadpath.$(OBJEXT): $(top_srcdir)/version.h
-loadpath.$(OBJEXT): {$(VPATH)}assert.h
loadpath.$(OBJEXT): {$(VPATH)}config.h
loadpath.$(OBJEXT): {$(VPATH)}defines.h
loadpath.$(OBJEXT): {$(VPATH)}intern.h
@@ -2296,24 +2028,23 @@ loadpath.$(OBJEXT): {$(VPATH)}missing.h
loadpath.$(OBJEXT): {$(VPATH)}st.h
loadpath.$(OBJEXT): {$(VPATH)}subst.h
loadpath.$(OBJEXT): {$(VPATH)}verconf.h
-localeinit.$(OBJEXT): $(hdrdir)/ruby.h
localeinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-localeinit.$(OBJEXT): {$(VPATH)}assert.h
+localeinit.$(OBJEXT): $(top_srcdir)/include/ruby.h
localeinit.$(OBJEXT): {$(VPATH)}config.h
localeinit.$(OBJEXT): {$(VPATH)}defines.h
localeinit.$(OBJEXT): {$(VPATH)}encindex.h
localeinit.$(OBJEXT): {$(VPATH)}encoding.h
localeinit.$(OBJEXT): {$(VPATH)}intern.h
localeinit.$(OBJEXT): {$(VPATH)}internal.h
+localeinit.$(OBJEXT): {$(VPATH)}io.h
localeinit.$(OBJEXT): {$(VPATH)}localeinit.c
localeinit.$(OBJEXT): {$(VPATH)}missing.h
localeinit.$(OBJEXT): {$(VPATH)}onigmo.h
localeinit.$(OBJEXT): {$(VPATH)}oniguruma.h
localeinit.$(OBJEXT): {$(VPATH)}st.h
localeinit.$(OBJEXT): {$(VPATH)}subst.h
-main.$(OBJEXT): $(hdrdir)/ruby.h
main.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-main.$(OBJEXT): {$(VPATH)}assert.h
+main.$(OBJEXT): $(top_srcdir)/include/ruby.h
main.$(OBJEXT): {$(VPATH)}backward.h
main.$(OBJEXT): {$(VPATH)}config.h
main.$(OBJEXT): {$(VPATH)}defines.h
@@ -2324,9 +2055,8 @@ main.$(OBJEXT): {$(VPATH)}node.h
main.$(OBJEXT): {$(VPATH)}st.h
main.$(OBJEXT): {$(VPATH)}subst.h
main.$(OBJEXT): {$(VPATH)}vm_debug.h
-marshal.$(OBJEXT): $(hdrdir)/ruby.h
marshal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-marshal.$(OBJEXT): {$(VPATH)}assert.h
+marshal.$(OBJEXT): $(top_srcdir)/include/ruby.h
marshal.$(OBJEXT): {$(VPATH)}config.h
marshal.$(OBJEXT): {$(VPATH)}defines.h
marshal.$(OBJEXT): {$(VPATH)}encindex.h
@@ -2342,141 +2072,53 @@ marshal.$(OBJEXT): {$(VPATH)}oniguruma.h
marshal.$(OBJEXT): {$(VPATH)}st.h
marshal.$(OBJEXT): {$(VPATH)}subst.h
marshal.$(OBJEXT): {$(VPATH)}util.h
-math.$(OBJEXT): $(hdrdir)/ruby.h
math.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-math.$(OBJEXT): {$(VPATH)}assert.h
+math.$(OBJEXT): $(top_srcdir)/include/ruby.h
math.$(OBJEXT): {$(VPATH)}config.h
math.$(OBJEXT): {$(VPATH)}defines.h
+math.$(OBJEXT): {$(VPATH)}encoding.h
math.$(OBJEXT): {$(VPATH)}intern.h
math.$(OBJEXT): {$(VPATH)}internal.h
+math.$(OBJEXT): {$(VPATH)}io.h
math.$(OBJEXT): {$(VPATH)}math.c
math.$(OBJEXT): {$(VPATH)}missing.h
+math.$(OBJEXT): {$(VPATH)}onigmo.h
+math.$(OBJEXT): {$(VPATH)}oniguruma.h
math.$(OBJEXT): {$(VPATH)}st.h
math.$(OBJEXT): {$(VPATH)}subst.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/list/list.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/str/str.h
-miniinit.$(OBJEXT): $(hdrdir)/ruby.h
miniinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-miniinit.$(OBJEXT): {$(VPATH)}assert.h
-miniinit.$(OBJEXT): {$(VPATH)}ast.rb
-miniinit.$(OBJEXT): {$(VPATH)}builtin.h
miniinit.$(OBJEXT): {$(VPATH)}config.h
miniinit.$(OBJEXT): {$(VPATH)}defines.h
miniinit.$(OBJEXT): {$(VPATH)}encoding.h
-miniinit.$(OBJEXT): {$(VPATH)}gc.rb
-miniinit.$(OBJEXT): {$(VPATH)}gem_prelude.rb
-miniinit.$(OBJEXT): {$(VPATH)}id.h
miniinit.$(OBJEXT): {$(VPATH)}intern.h
-miniinit.$(OBJEXT): {$(VPATH)}internal.h
-miniinit.$(OBJEXT): {$(VPATH)}io.rb
-miniinit.$(OBJEXT): {$(VPATH)}iseq.h
-miniinit.$(OBJEXT): {$(VPATH)}method.h
-miniinit.$(OBJEXT): {$(VPATH)}mini_builtin.c
miniinit.$(OBJEXT): {$(VPATH)}miniinit.c
-miniinit.$(OBJEXT): {$(VPATH)}miniprelude.c
miniinit.$(OBJEXT): {$(VPATH)}missing.h
-miniinit.$(OBJEXT): {$(VPATH)}node.h
miniinit.$(OBJEXT): {$(VPATH)}onigmo.h
miniinit.$(OBJEXT): {$(VPATH)}oniguruma.h
-miniinit.$(OBJEXT): {$(VPATH)}pack.rb
-miniinit.$(OBJEXT): {$(VPATH)}prelude.rb
-miniinit.$(OBJEXT): {$(VPATH)}ruby_assert.h
-miniinit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
miniinit.$(OBJEXT): {$(VPATH)}st.h
miniinit.$(OBJEXT): {$(VPATH)}subst.h
-miniinit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-miniinit.$(OBJEXT): {$(VPATH)}thread_native.h
-miniinit.$(OBJEXT): {$(VPATH)}trace_point.rb
-miniinit.$(OBJEXT): {$(VPATH)}vm_core.h
-miniinit.$(OBJEXT): {$(VPATH)}vm_opts.h
-miniinit.$(OBJEXT): {$(VPATH)}warning.rb
-mjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-mjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-mjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
-mjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
-mjit.$(OBJEXT): $(hdrdir)/ruby.h
-mjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-mjit.$(OBJEXT): {$(VPATH)}assert.h
-mjit.$(OBJEXT): {$(VPATH)}config.h
-mjit.$(OBJEXT): {$(VPATH)}constant.h
-mjit.$(OBJEXT): {$(VPATH)}debug.h
-mjit.$(OBJEXT): {$(VPATH)}debug_counter.h
-mjit.$(OBJEXT): {$(VPATH)}defines.h
-mjit.$(OBJEXT): {$(VPATH)}dln.h
-mjit.$(OBJEXT): {$(VPATH)}gc.h
-mjit.$(OBJEXT): {$(VPATH)}id.h
-mjit.$(OBJEXT): {$(VPATH)}id_table.h
-mjit.$(OBJEXT): {$(VPATH)}intern.h
-mjit.$(OBJEXT): {$(VPATH)}internal.h
-mjit.$(OBJEXT): {$(VPATH)}method.h
-mjit.$(OBJEXT): {$(VPATH)}missing.h
-mjit.$(OBJEXT): {$(VPATH)}mjit.c
-mjit.$(OBJEXT): {$(VPATH)}mjit.h
-mjit.$(OBJEXT): {$(VPATH)}mjit_config.h
-mjit.$(OBJEXT): {$(VPATH)}mjit_worker.c
-mjit.$(OBJEXT): {$(VPATH)}node.h
-mjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
-mjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-mjit.$(OBJEXT): {$(VPATH)}st.h
-mjit.$(OBJEXT): {$(VPATH)}subst.h
-mjit.$(OBJEXT): {$(VPATH)}thread.h
-mjit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-mjit.$(OBJEXT): {$(VPATH)}thread_native.h
-mjit.$(OBJEXT): {$(VPATH)}util.h
-mjit.$(OBJEXT): {$(VPATH)}vm_core.h
-mjit.$(OBJEXT): {$(VPATH)}vm_opts.h
-mjit_compile.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-mjit_compile.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-mjit_compile.$(OBJEXT): $(CCAN_DIR)/list/list.h
-mjit_compile.$(OBJEXT): $(CCAN_DIR)/str/str.h
-mjit_compile.$(OBJEXT): $(hdrdir)/ruby.h
-mjit_compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-mjit_compile.$(OBJEXT): {$(VPATH)}assert.h
-mjit_compile.$(OBJEXT): {$(VPATH)}builtin.h
-mjit_compile.$(OBJEXT): {$(VPATH)}config.h
-mjit_compile.$(OBJEXT): {$(VPATH)}debug_counter.h
-mjit_compile.$(OBJEXT): {$(VPATH)}defines.h
-mjit_compile.$(OBJEXT): {$(VPATH)}id.h
-mjit_compile.$(OBJEXT): {$(VPATH)}insns.def
-mjit_compile.$(OBJEXT): {$(VPATH)}insns.inc
-mjit_compile.$(OBJEXT): {$(VPATH)}insns_info.inc
-mjit_compile.$(OBJEXT): {$(VPATH)}intern.h
-mjit_compile.$(OBJEXT): {$(VPATH)}internal.h
-mjit_compile.$(OBJEXT): {$(VPATH)}iseq.h
-mjit_compile.$(OBJEXT): {$(VPATH)}method.h
-mjit_compile.$(OBJEXT): {$(VPATH)}missing.h
-mjit_compile.$(OBJEXT): {$(VPATH)}mjit.h
-mjit_compile.$(OBJEXT): {$(VPATH)}mjit_compile.c
-mjit_compile.$(OBJEXT): {$(VPATH)}mjit_compile.inc
-mjit_compile.$(OBJEXT): {$(VPATH)}node.h
-mjit_compile.$(OBJEXT): {$(VPATH)}ruby_assert.h
-mjit_compile.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-mjit_compile.$(OBJEXT): {$(VPATH)}st.h
-mjit_compile.$(OBJEXT): {$(VPATH)}subst.h
-mjit_compile.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-mjit_compile.$(OBJEXT): {$(VPATH)}thread_native.h
-mjit_compile.$(OBJEXT): {$(VPATH)}vm_core.h
-mjit_compile.$(OBJEXT): {$(VPATH)}vm_exec.h
-mjit_compile.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
-mjit_compile.$(OBJEXT): {$(VPATH)}vm_opts.h
+miniprelude.$(OBJEXT): $(hdrdir)/ruby/version.h
+miniprelude.$(OBJEXT): {$(VPATH)}iseq.h
+miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c
node.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
node.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
node.$(OBJEXT): $(CCAN_DIR)/list/list.h
node.$(OBJEXT): $(CCAN_DIR)/str/str.h
-node.$(OBJEXT): $(hdrdir)/ruby.h
node.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-node.$(OBJEXT): {$(VPATH)}assert.h
+node.$(OBJEXT): $(top_srcdir)/include/ruby.h
node.$(OBJEXT): {$(VPATH)}config.h
node.$(OBJEXT): {$(VPATH)}defines.h
+node.$(OBJEXT): {$(VPATH)}encoding.h
node.$(OBJEXT): {$(VPATH)}id.h
node.$(OBJEXT): {$(VPATH)}intern.h
node.$(OBJEXT): {$(VPATH)}internal.h
+node.$(OBJEXT): {$(VPATH)}io.h
node.$(OBJEXT): {$(VPATH)}method.h
node.$(OBJEXT): {$(VPATH)}missing.h
node.$(OBJEXT): {$(VPATH)}node.c
node.$(OBJEXT): {$(VPATH)}node.h
+node.$(OBJEXT): {$(VPATH)}onigmo.h
+node.$(OBJEXT): {$(VPATH)}oniguruma.h
node.$(OBJEXT): {$(VPATH)}ruby_assert.h
node.$(OBJEXT): {$(VPATH)}ruby_atomic.h
node.$(OBJEXT): {$(VPATH)}st.h
@@ -2484,16 +2126,17 @@ node.$(OBJEXT): {$(VPATH)}subst.h
node.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
node.$(OBJEXT): {$(VPATH)}thread_native.h
node.$(OBJEXT): {$(VPATH)}vm_core.h
+node.$(OBJEXT): {$(VPATH)}vm_debug.h
node.$(OBJEXT): {$(VPATH)}vm_opts.h
-numeric.$(OBJEXT): $(hdrdir)/ruby.h
numeric.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-numeric.$(OBJEXT): {$(VPATH)}assert.h
+numeric.$(OBJEXT): $(top_srcdir)/include/ruby.h
numeric.$(OBJEXT): {$(VPATH)}config.h
numeric.$(OBJEXT): {$(VPATH)}defines.h
numeric.$(OBJEXT): {$(VPATH)}encoding.h
numeric.$(OBJEXT): {$(VPATH)}id.h
numeric.$(OBJEXT): {$(VPATH)}intern.h
numeric.$(OBJEXT): {$(VPATH)}internal.h
+numeric.$(OBJEXT): {$(VPATH)}io.h
numeric.$(OBJEXT): {$(VPATH)}missing.h
numeric.$(OBJEXT): {$(VPATH)}numeric.c
numeric.$(OBJEXT): {$(VPATH)}onigmo.h
@@ -2501,9 +2144,8 @@ numeric.$(OBJEXT): {$(VPATH)}oniguruma.h
numeric.$(OBJEXT): {$(VPATH)}st.h
numeric.$(OBJEXT): {$(VPATH)}subst.h
numeric.$(OBJEXT): {$(VPATH)}util.h
-object.$(OBJEXT): $(hdrdir)/ruby.h
object.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-object.$(OBJEXT): {$(VPATH)}assert.h
+object.$(OBJEXT): $(top_srcdir)/include/ruby.h
object.$(OBJEXT): {$(VPATH)}config.h
object.$(OBJEXT): {$(VPATH)}constant.h
object.$(OBJEXT): {$(VPATH)}defines.h
@@ -2511,6 +2153,7 @@ object.$(OBJEXT): {$(VPATH)}encoding.h
object.$(OBJEXT): {$(VPATH)}id.h
object.$(OBJEXT): {$(VPATH)}intern.h
object.$(OBJEXT): {$(VPATH)}internal.h
+object.$(OBJEXT): {$(VPATH)}io.h
object.$(OBJEXT): {$(VPATH)}missing.h
object.$(OBJEXT): {$(VPATH)}object.c
object.$(OBJEXT): {$(VPATH)}onigmo.h
@@ -2520,25 +2163,22 @@ object.$(OBJEXT): {$(VPATH)}probes.h
object.$(OBJEXT): {$(VPATH)}st.h
object.$(OBJEXT): {$(VPATH)}subst.h
object.$(OBJEXT): {$(VPATH)}util.h
-pack.$(OBJEXT): $(hdrdir)/ruby.h
pack.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-pack.$(OBJEXT): {$(VPATH)}assert.h
-pack.$(OBJEXT): {$(VPATH)}builtin.h
+pack.$(OBJEXT): $(top_srcdir)/include/ruby.h
pack.$(OBJEXT): {$(VPATH)}config.h
pack.$(OBJEXT): {$(VPATH)}defines.h
pack.$(OBJEXT): {$(VPATH)}encoding.h
pack.$(OBJEXT): {$(VPATH)}intern.h
pack.$(OBJEXT): {$(VPATH)}internal.h
+pack.$(OBJEXT): {$(VPATH)}io.h
pack.$(OBJEXT): {$(VPATH)}missing.h
pack.$(OBJEXT): {$(VPATH)}onigmo.h
pack.$(OBJEXT): {$(VPATH)}oniguruma.h
pack.$(OBJEXT): {$(VPATH)}pack.c
-pack.$(OBJEXT): {$(VPATH)}pack.rbinc
pack.$(OBJEXT): {$(VPATH)}st.h
pack.$(OBJEXT): {$(VPATH)}subst.h
-parse.$(OBJEXT): $(hdrdir)/ruby.h
parse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-parse.$(OBJEXT): {$(VPATH)}assert.h
+parse.$(OBJEXT): $(top_srcdir)/include/ruby.h
parse.$(OBJEXT): {$(VPATH)}config.h
parse.$(OBJEXT): {$(VPATH)}defines.h
parse.$(OBJEXT): {$(VPATH)}defs/keywords
@@ -2546,6 +2186,7 @@ parse.$(OBJEXT): {$(VPATH)}encoding.h
parse.$(OBJEXT): {$(VPATH)}id.h
parse.$(OBJEXT): {$(VPATH)}intern.h
parse.$(OBJEXT): {$(VPATH)}internal.h
+parse.$(OBJEXT): {$(VPATH)}io.h
parse.$(OBJEXT): {$(VPATH)}lex.c
parse.$(OBJEXT): {$(VPATH)}missing.h
parse.$(OBJEXT): {$(VPATH)}node.h
@@ -2562,24 +2203,58 @@ parse.$(OBJEXT): {$(VPATH)}st.h
parse.$(OBJEXT): {$(VPATH)}subst.h
parse.$(OBJEXT): {$(VPATH)}symbol.h
parse.$(OBJEXT): {$(VPATH)}util.h
+prelude.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+prelude.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+prelude.$(OBJEXT): $(CCAN_DIR)/list/list.h
+prelude.$(OBJEXT): $(CCAN_DIR)/str/str.h
+prelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prelude.$(OBJEXT): $(hdrdir)/ruby/version.h
+prelude.$(OBJEXT): $(top_srcdir)/include/ruby.h
+prelude.$(OBJEXT): {$(VPATH)}config.h
+prelude.$(OBJEXT): {$(VPATH)}defines.h
+prelude.$(OBJEXT): {$(VPATH)}encoding.h
+prelude.$(OBJEXT): {$(VPATH)}id.h
+prelude.$(OBJEXT): {$(VPATH)}intern.h
+prelude.$(OBJEXT): {$(VPATH)}internal.h
+prelude.$(OBJEXT): {$(VPATH)}io.h
+prelude.$(OBJEXT): {$(VPATH)}iseq.h
+prelude.$(OBJEXT): {$(VPATH)}method.h
+prelude.$(OBJEXT): {$(VPATH)}missing.h
+prelude.$(OBJEXT): {$(VPATH)}node.h
+prelude.$(OBJEXT): {$(VPATH)}onigmo.h
+prelude.$(OBJEXT): {$(VPATH)}oniguruma.h
+prelude.$(OBJEXT): {$(VPATH)}prelude.c
+prelude.$(OBJEXT): {$(VPATH)}ruby_assert.h
+prelude.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+prelude.$(OBJEXT): {$(VPATH)}st.h
+prelude.$(OBJEXT): {$(VPATH)}subst.h
+prelude.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+prelude.$(OBJEXT): {$(VPATH)}thread_native.h
+prelude.$(OBJEXT): {$(VPATH)}vm_core.h
+prelude.$(OBJEXT): {$(VPATH)}vm_debug.h
+prelude.$(OBJEXT): {$(VPATH)}vm_opts.h
proc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
proc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
proc.$(OBJEXT): $(CCAN_DIR)/list/list.h
proc.$(OBJEXT): $(CCAN_DIR)/str/str.h
-proc.$(OBJEXT): $(hdrdir)/ruby.h
proc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-proc.$(OBJEXT): {$(VPATH)}assert.h
+proc.$(OBJEXT): $(hdrdir)/ruby/version.h
+proc.$(OBJEXT): $(top_srcdir)/include/ruby.h
proc.$(OBJEXT): {$(VPATH)}config.h
proc.$(OBJEXT): {$(VPATH)}defines.h
+proc.$(OBJEXT): {$(VPATH)}encoding.h
proc.$(OBJEXT): {$(VPATH)}eval_intern.h
proc.$(OBJEXT): {$(VPATH)}gc.h
proc.$(OBJEXT): {$(VPATH)}id.h
proc.$(OBJEXT): {$(VPATH)}intern.h
proc.$(OBJEXT): {$(VPATH)}internal.h
+proc.$(OBJEXT): {$(VPATH)}io.h
proc.$(OBJEXT): {$(VPATH)}iseq.h
proc.$(OBJEXT): {$(VPATH)}method.h
proc.$(OBJEXT): {$(VPATH)}missing.h
proc.$(OBJEXT): {$(VPATH)}node.h
+proc.$(OBJEXT): {$(VPATH)}onigmo.h
+proc.$(OBJEXT): {$(VPATH)}oniguruma.h
proc.$(OBJEXT): {$(VPATH)}proc.c
proc.$(OBJEXT): {$(VPATH)}ruby_assert.h
proc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
@@ -2588,19 +2263,18 @@ proc.$(OBJEXT): {$(VPATH)}subst.h
proc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
proc.$(OBJEXT): {$(VPATH)}thread_native.h
proc.$(OBJEXT): {$(VPATH)}vm_core.h
+proc.$(OBJEXT): {$(VPATH)}vm_debug.h
proc.$(OBJEXT): {$(VPATH)}vm_opts.h
process.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
process.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
process.$(OBJEXT): $(CCAN_DIR)/list/list.h
process.$(OBJEXT): $(CCAN_DIR)/str/str.h
-process.$(OBJEXT): $(hdrdir)/ruby.h
process.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-process.$(OBJEXT): {$(VPATH)}assert.h
+process.$(OBJEXT): $(top_srcdir)/include/ruby.h
process.$(OBJEXT): {$(VPATH)}config.h
process.$(OBJEXT): {$(VPATH)}defines.h
process.$(OBJEXT): {$(VPATH)}dln.h
process.$(OBJEXT): {$(VPATH)}encoding.h
-process.$(OBJEXT): {$(VPATH)}hrtime.h
process.$(OBJEXT): {$(VPATH)}id.h
process.$(OBJEXT): {$(VPATH)}intern.h
process.$(OBJEXT): {$(VPATH)}internal.h
@@ -2620,56 +2294,65 @@ process.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
process.$(OBJEXT): {$(VPATH)}thread_native.h
process.$(OBJEXT): {$(VPATH)}util.h
process.$(OBJEXT): {$(VPATH)}vm_core.h
+process.$(OBJEXT): {$(VPATH)}vm_debug.h
process.$(OBJEXT): {$(VPATH)}vm_opts.h
-random.$(OBJEXT): $(hdrdir)/ruby.h
random.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-random.$(OBJEXT): {$(VPATH)}assert.h
+random.$(OBJEXT): $(top_srcdir)/include/ruby.h
random.$(OBJEXT): {$(VPATH)}config.h
random.$(OBJEXT): {$(VPATH)}defines.h
+random.$(OBJEXT): {$(VPATH)}encoding.h
random.$(OBJEXT): {$(VPATH)}intern.h
random.$(OBJEXT): {$(VPATH)}internal.h
+random.$(OBJEXT): {$(VPATH)}io.h
random.$(OBJEXT): {$(VPATH)}missing.h
-random.$(OBJEXT): {$(VPATH)}mt19937.c
+random.$(OBJEXT): {$(VPATH)}onigmo.h
+random.$(OBJEXT): {$(VPATH)}oniguruma.h
random.$(OBJEXT): {$(VPATH)}random.c
random.$(OBJEXT): {$(VPATH)}ruby_atomic.h
random.$(OBJEXT): {$(VPATH)}siphash.c
random.$(OBJEXT): {$(VPATH)}siphash.h
random.$(OBJEXT): {$(VPATH)}st.h
random.$(OBJEXT): {$(VPATH)}subst.h
-range.$(OBJEXT): $(hdrdir)/ruby.h
range.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-range.$(OBJEXT): {$(VPATH)}assert.h
+range.$(OBJEXT): $(top_srcdir)/include/ruby.h
range.$(OBJEXT): {$(VPATH)}config.h
range.$(OBJEXT): {$(VPATH)}defines.h
+range.$(OBJEXT): {$(VPATH)}encoding.h
range.$(OBJEXT): {$(VPATH)}id.h
range.$(OBJEXT): {$(VPATH)}intern.h
range.$(OBJEXT): {$(VPATH)}internal.h
+range.$(OBJEXT): {$(VPATH)}io.h
range.$(OBJEXT): {$(VPATH)}missing.h
+range.$(OBJEXT): {$(VPATH)}onigmo.h
+range.$(OBJEXT): {$(VPATH)}oniguruma.h
range.$(OBJEXT): {$(VPATH)}range.c
range.$(OBJEXT): {$(VPATH)}st.h
range.$(OBJEXT): {$(VPATH)}subst.h
-rational.$(OBJEXT): $(hdrdir)/ruby.h
rational.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-rational.$(OBJEXT): {$(VPATH)}assert.h
+rational.$(OBJEXT): $(top_srcdir)/include/ruby.h
rational.$(OBJEXT): {$(VPATH)}config.h
rational.$(OBJEXT): {$(VPATH)}defines.h
+rational.$(OBJEXT): {$(VPATH)}encoding.h
rational.$(OBJEXT): {$(VPATH)}id.h
rational.$(OBJEXT): {$(VPATH)}intern.h
rational.$(OBJEXT): {$(VPATH)}internal.h
+rational.$(OBJEXT): {$(VPATH)}io.h
rational.$(OBJEXT): {$(VPATH)}missing.h
+rational.$(OBJEXT): {$(VPATH)}onigmo.h
+rational.$(OBJEXT): {$(VPATH)}oniguruma.h
rational.$(OBJEXT): {$(VPATH)}rational.c
rational.$(OBJEXT): {$(VPATH)}ruby_assert.h
rational.$(OBJEXT): {$(VPATH)}st.h
rational.$(OBJEXT): {$(VPATH)}subst.h
-re.$(OBJEXT): $(hdrdir)/ruby.h
re.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-re.$(OBJEXT): {$(VPATH)}assert.h
+re.$(OBJEXT): $(top_srcdir)/include/ruby.h
re.$(OBJEXT): {$(VPATH)}config.h
re.$(OBJEXT): {$(VPATH)}defines.h
re.$(OBJEXT): {$(VPATH)}encindex.h
re.$(OBJEXT): {$(VPATH)}encoding.h
re.$(OBJEXT): {$(VPATH)}intern.h
re.$(OBJEXT): {$(VPATH)}internal.h
+re.$(OBJEXT): {$(VPATH)}io.h
re.$(OBJEXT): {$(VPATH)}missing.h
re.$(OBJEXT): {$(VPATH)}onigmo.h
re.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -2682,12 +2365,12 @@ re.$(OBJEXT): {$(VPATH)}st.h
re.$(OBJEXT): {$(VPATH)}subst.h
re.$(OBJEXT): {$(VPATH)}util.h
regcomp.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regcomp.$(OBJEXT): {$(VPATH)}assert.h
regcomp.$(OBJEXT): {$(VPATH)}config.h
regcomp.$(OBJEXT): {$(VPATH)}defines.h
regcomp.$(OBJEXT): {$(VPATH)}intern.h
regcomp.$(OBJEXT): {$(VPATH)}missing.h
regcomp.$(OBJEXT): {$(VPATH)}onigmo.h
+regcomp.$(OBJEXT): {$(VPATH)}oniguruma.h
regcomp.$(OBJEXT): {$(VPATH)}regcomp.c
regcomp.$(OBJEXT): {$(VPATH)}regenc.h
regcomp.$(OBJEXT): {$(VPATH)}regint.h
@@ -2695,48 +2378,48 @@ regcomp.$(OBJEXT): {$(VPATH)}regparse.h
regcomp.$(OBJEXT): {$(VPATH)}st.h
regcomp.$(OBJEXT): {$(VPATH)}subst.h
regenc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regenc.$(OBJEXT): {$(VPATH)}assert.h
regenc.$(OBJEXT): {$(VPATH)}config.h
regenc.$(OBJEXT): {$(VPATH)}defines.h
regenc.$(OBJEXT): {$(VPATH)}intern.h
regenc.$(OBJEXT): {$(VPATH)}missing.h
regenc.$(OBJEXT): {$(VPATH)}onigmo.h
+regenc.$(OBJEXT): {$(VPATH)}oniguruma.h
regenc.$(OBJEXT): {$(VPATH)}regenc.c
regenc.$(OBJEXT): {$(VPATH)}regenc.h
regenc.$(OBJEXT): {$(VPATH)}regint.h
regenc.$(OBJEXT): {$(VPATH)}st.h
regenc.$(OBJEXT): {$(VPATH)}subst.h
regerror.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regerror.$(OBJEXT): {$(VPATH)}assert.h
regerror.$(OBJEXT): {$(VPATH)}config.h
regerror.$(OBJEXT): {$(VPATH)}defines.h
regerror.$(OBJEXT): {$(VPATH)}intern.h
regerror.$(OBJEXT): {$(VPATH)}missing.h
regerror.$(OBJEXT): {$(VPATH)}onigmo.h
+regerror.$(OBJEXT): {$(VPATH)}oniguruma.h
regerror.$(OBJEXT): {$(VPATH)}regenc.h
regerror.$(OBJEXT): {$(VPATH)}regerror.c
regerror.$(OBJEXT): {$(VPATH)}regint.h
regerror.$(OBJEXT): {$(VPATH)}st.h
regerror.$(OBJEXT): {$(VPATH)}subst.h
regexec.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regexec.$(OBJEXT): {$(VPATH)}assert.h
regexec.$(OBJEXT): {$(VPATH)}config.h
regexec.$(OBJEXT): {$(VPATH)}defines.h
regexec.$(OBJEXT): {$(VPATH)}intern.h
regexec.$(OBJEXT): {$(VPATH)}missing.h
regexec.$(OBJEXT): {$(VPATH)}onigmo.h
+regexec.$(OBJEXT): {$(VPATH)}oniguruma.h
regexec.$(OBJEXT): {$(VPATH)}regenc.h
regexec.$(OBJEXT): {$(VPATH)}regexec.c
regexec.$(OBJEXT): {$(VPATH)}regint.h
regexec.$(OBJEXT): {$(VPATH)}st.h
regexec.$(OBJEXT): {$(VPATH)}subst.h
regparse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regparse.$(OBJEXT): {$(VPATH)}assert.h
regparse.$(OBJEXT): {$(VPATH)}config.h
regparse.$(OBJEXT): {$(VPATH)}defines.h
regparse.$(OBJEXT): {$(VPATH)}intern.h
regparse.$(OBJEXT): {$(VPATH)}missing.h
regparse.$(OBJEXT): {$(VPATH)}onigmo.h
+regparse.$(OBJEXT): {$(VPATH)}oniguruma.h
regparse.$(OBJEXT): {$(VPATH)}regenc.h
regparse.$(OBJEXT): {$(VPATH)}regint.h
regparse.$(OBJEXT): {$(VPATH)}regparse.c
@@ -2744,30 +2427,26 @@ regparse.$(OBJEXT): {$(VPATH)}regparse.h
regparse.$(OBJEXT): {$(VPATH)}st.h
regparse.$(OBJEXT): {$(VPATH)}subst.h
regsyntax.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regsyntax.$(OBJEXT): {$(VPATH)}assert.h
regsyntax.$(OBJEXT): {$(VPATH)}config.h
regsyntax.$(OBJEXT): {$(VPATH)}defines.h
regsyntax.$(OBJEXT): {$(VPATH)}intern.h
regsyntax.$(OBJEXT): {$(VPATH)}missing.h
regsyntax.$(OBJEXT): {$(VPATH)}onigmo.h
+regsyntax.$(OBJEXT): {$(VPATH)}oniguruma.h
regsyntax.$(OBJEXT): {$(VPATH)}regenc.h
regsyntax.$(OBJEXT): {$(VPATH)}regint.h
regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c
regsyntax.$(OBJEXT): {$(VPATH)}st.h
regsyntax.$(OBJEXT): {$(VPATH)}subst.h
-ruby-runner.$(OBJEXT): {$(VPATH)}config.h
ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.c
ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.h
ruby.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
ruby.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
ruby.$(OBJEXT): $(CCAN_DIR)/list/list.h
ruby.$(OBJEXT): $(CCAN_DIR)/str/str.h
-ruby.$(OBJEXT): $(hdrdir)/ruby.h
ruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-ruby.$(OBJEXT): $(hdrdir)/ruby/version.h
-ruby.$(OBJEXT): {$(VPATH)}assert.h
+ruby.$(OBJEXT): $(top_srcdir)/include/ruby.h
ruby.$(OBJEXT): {$(VPATH)}config.h
-ruby.$(OBJEXT): {$(VPATH)}debug_counter.h
ruby.$(OBJEXT): {$(VPATH)}defines.h
ruby.$(OBJEXT): {$(VPATH)}dln.h
ruby.$(OBJEXT): {$(VPATH)}encoding.h
@@ -2775,9 +2454,9 @@ ruby.$(OBJEXT): {$(VPATH)}eval_intern.h
ruby.$(OBJEXT): {$(VPATH)}id.h
ruby.$(OBJEXT): {$(VPATH)}intern.h
ruby.$(OBJEXT): {$(VPATH)}internal.h
+ruby.$(OBJEXT): {$(VPATH)}io.h
ruby.$(OBJEXT): {$(VPATH)}method.h
ruby.$(OBJEXT): {$(VPATH)}missing.h
-ruby.$(OBJEXT): {$(VPATH)}mjit.h
ruby.$(OBJEXT): {$(VPATH)}node.h
ruby.$(OBJEXT): {$(VPATH)}onigmo.h
ruby.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -2791,22 +2470,26 @@ ruby.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
ruby.$(OBJEXT): {$(VPATH)}thread_native.h
ruby.$(OBJEXT): {$(VPATH)}util.h
ruby.$(OBJEXT): {$(VPATH)}vm_core.h
+ruby.$(OBJEXT): {$(VPATH)}vm_debug.h
ruby.$(OBJEXT): {$(VPATH)}vm_opts.h
safe.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
safe.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
safe.$(OBJEXT): $(CCAN_DIR)/list/list.h
safe.$(OBJEXT): $(CCAN_DIR)/str/str.h
-safe.$(OBJEXT): $(hdrdir)/ruby.h
safe.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-safe.$(OBJEXT): {$(VPATH)}assert.h
+safe.$(OBJEXT): $(top_srcdir)/include/ruby.h
safe.$(OBJEXT): {$(VPATH)}config.h
safe.$(OBJEXT): {$(VPATH)}defines.h
+safe.$(OBJEXT): {$(VPATH)}encoding.h
safe.$(OBJEXT): {$(VPATH)}id.h
safe.$(OBJEXT): {$(VPATH)}intern.h
safe.$(OBJEXT): {$(VPATH)}internal.h
+safe.$(OBJEXT): {$(VPATH)}io.h
safe.$(OBJEXT): {$(VPATH)}method.h
safe.$(OBJEXT): {$(VPATH)}missing.h
safe.$(OBJEXT): {$(VPATH)}node.h
+safe.$(OBJEXT): {$(VPATH)}onigmo.h
+safe.$(OBJEXT): {$(VPATH)}oniguruma.h
safe.$(OBJEXT): {$(VPATH)}ruby_assert.h
safe.$(OBJEXT): {$(VPATH)}ruby_atomic.h
safe.$(OBJEXT): {$(VPATH)}safe.c
@@ -2815,10 +2498,10 @@ safe.$(OBJEXT): {$(VPATH)}subst.h
safe.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
safe.$(OBJEXT): {$(VPATH)}thread_native.h
safe.$(OBJEXT): {$(VPATH)}vm_core.h
+safe.$(OBJEXT): {$(VPATH)}vm_debug.h
safe.$(OBJEXT): {$(VPATH)}vm_opts.h
-setproctitle.$(OBJEXT): $(hdrdir)/ruby.h
setproctitle.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-setproctitle.$(OBJEXT): {$(VPATH)}assert.h
+setproctitle.$(OBJEXT): $(top_srcdir)/include/ruby.h
setproctitle.$(OBJEXT): {$(VPATH)}config.h
setproctitle.$(OBJEXT): {$(VPATH)}defines.h
setproctitle.$(OBJEXT): {$(VPATH)}intern.h
@@ -2831,19 +2514,21 @@ signal.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
signal.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
signal.$(OBJEXT): $(CCAN_DIR)/list/list.h
signal.$(OBJEXT): $(CCAN_DIR)/str/str.h
-signal.$(OBJEXT): $(hdrdir)/ruby.h
signal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-signal.$(OBJEXT): {$(VPATH)}assert.h
+signal.$(OBJEXT): $(top_srcdir)/include/ruby.h
signal.$(OBJEXT): {$(VPATH)}config.h
-signal.$(OBJEXT): {$(VPATH)}debug_counter.h
signal.$(OBJEXT): {$(VPATH)}defines.h
+signal.$(OBJEXT): {$(VPATH)}encoding.h
signal.$(OBJEXT): {$(VPATH)}eval_intern.h
signal.$(OBJEXT): {$(VPATH)}id.h
signal.$(OBJEXT): {$(VPATH)}intern.h
signal.$(OBJEXT): {$(VPATH)}internal.h
+signal.$(OBJEXT): {$(VPATH)}io.h
signal.$(OBJEXT): {$(VPATH)}method.h
signal.$(OBJEXT): {$(VPATH)}missing.h
signal.$(OBJEXT): {$(VPATH)}node.h
+signal.$(OBJEXT): {$(VPATH)}onigmo.h
+signal.$(OBJEXT): {$(VPATH)}oniguruma.h
signal.$(OBJEXT): {$(VPATH)}ruby_assert.h
signal.$(OBJEXT): {$(VPATH)}ruby_atomic.h
signal.$(OBJEXT): {$(VPATH)}signal.c
@@ -2852,16 +2537,17 @@ signal.$(OBJEXT): {$(VPATH)}subst.h
signal.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
signal.$(OBJEXT): {$(VPATH)}thread_native.h
signal.$(OBJEXT): {$(VPATH)}vm_core.h
+signal.$(OBJEXT): {$(VPATH)}vm_debug.h
signal.$(OBJEXT): {$(VPATH)}vm_opts.h
-sprintf.$(OBJEXT): $(hdrdir)/ruby.h
sprintf.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-sprintf.$(OBJEXT): {$(VPATH)}assert.h
+sprintf.$(OBJEXT): $(top_srcdir)/include/ruby.h
sprintf.$(OBJEXT): {$(VPATH)}config.h
sprintf.$(OBJEXT): {$(VPATH)}defines.h
sprintf.$(OBJEXT): {$(VPATH)}encoding.h
sprintf.$(OBJEXT): {$(VPATH)}id.h
sprintf.$(OBJEXT): {$(VPATH)}intern.h
sprintf.$(OBJEXT): {$(VPATH)}internal.h
+sprintf.$(OBJEXT): {$(VPATH)}io.h
sprintf.$(OBJEXT): {$(VPATH)}missing.h
sprintf.$(OBJEXT): {$(VPATH)}onigmo.h
sprintf.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -2871,25 +2557,32 @@ sprintf.$(OBJEXT): {$(VPATH)}sprintf.c
sprintf.$(OBJEXT): {$(VPATH)}st.h
sprintf.$(OBJEXT): {$(VPATH)}subst.h
sprintf.$(OBJEXT): {$(VPATH)}vsnprintf.c
-st.$(OBJEXT): $(hdrdir)/ruby.h
+st.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+st.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+st.$(OBJEXT): $(CCAN_DIR)/list/list.h
+st.$(OBJEXT): $(CCAN_DIR)/str/str.h
st.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-st.$(OBJEXT): {$(VPATH)}assert.h
+st.$(OBJEXT): $(top_srcdir)/include/ruby.h
st.$(OBJEXT): {$(VPATH)}config.h
st.$(OBJEXT): {$(VPATH)}defines.h
+st.$(OBJEXT): {$(VPATH)}encoding.h
st.$(OBJEXT): {$(VPATH)}intern.h
st.$(OBJEXT): {$(VPATH)}internal.h
+st.$(OBJEXT): {$(VPATH)}io.h
st.$(OBJEXT): {$(VPATH)}missing.h
+st.$(OBJEXT): {$(VPATH)}onigmo.h
+st.$(OBJEXT): {$(VPATH)}oniguruma.h
st.$(OBJEXT): {$(VPATH)}st.c
st.$(OBJEXT): {$(VPATH)}st.h
st.$(OBJEXT): {$(VPATH)}subst.h
-strftime.$(OBJEXT): $(hdrdir)/ruby.h
strftime.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-strftime.$(OBJEXT): {$(VPATH)}assert.h
+strftime.$(OBJEXT): $(top_srcdir)/include/ruby.h
strftime.$(OBJEXT): {$(VPATH)}config.h
strftime.$(OBJEXT): {$(VPATH)}defines.h
strftime.$(OBJEXT): {$(VPATH)}encoding.h
strftime.$(OBJEXT): {$(VPATH)}intern.h
strftime.$(OBJEXT): {$(VPATH)}internal.h
+strftime.$(OBJEXT): {$(VPATH)}io.h
strftime.$(OBJEXT): {$(VPATH)}missing.h
strftime.$(OBJEXT): {$(VPATH)}onigmo.h
strftime.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -2897,9 +2590,8 @@ strftime.$(OBJEXT): {$(VPATH)}st.h
strftime.$(OBJEXT): {$(VPATH)}strftime.c
strftime.$(OBJEXT): {$(VPATH)}subst.h
strftime.$(OBJEXT): {$(VPATH)}timev.h
-string.$(OBJEXT): $(hdrdir)/ruby.h
string.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-string.$(OBJEXT): {$(VPATH)}assert.h
+string.$(OBJEXT): $(top_srcdir)/include/ruby.h
string.$(OBJEXT): {$(VPATH)}config.h
string.$(OBJEXT): {$(VPATH)}crypt.h
string.$(OBJEXT): {$(VPATH)}debug_counter.h
@@ -2910,6 +2602,7 @@ string.$(OBJEXT): {$(VPATH)}gc.h
string.$(OBJEXT): {$(VPATH)}id.h
string.$(OBJEXT): {$(VPATH)}intern.h
string.$(OBJEXT): {$(VPATH)}internal.h
+string.$(OBJEXT): {$(VPATH)}io.h
string.$(OBJEXT): {$(VPATH)}missing.h
string.$(OBJEXT): {$(VPATH)}onigmo.h
string.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -2921,7 +2614,6 @@ string.$(OBJEXT): {$(VPATH)}ruby_assert.h
string.$(OBJEXT): {$(VPATH)}st.h
string.$(OBJEXT): {$(VPATH)}string.c
string.$(OBJEXT): {$(VPATH)}subst.h
-string.$(OBJEXT): {$(VPATH)}util.h
strlcat.$(OBJEXT): {$(VPATH)}config.h
strlcat.$(OBJEXT): {$(VPATH)}missing.h
strlcat.$(OBJEXT): {$(VPATH)}strlcat.c
@@ -2932,17 +2624,20 @@ struct.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
struct.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
struct.$(OBJEXT): $(CCAN_DIR)/list/list.h
struct.$(OBJEXT): $(CCAN_DIR)/str/str.h
-struct.$(OBJEXT): $(hdrdir)/ruby.h
struct.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-struct.$(OBJEXT): {$(VPATH)}assert.h
+struct.$(OBJEXT): $(top_srcdir)/include/ruby.h
struct.$(OBJEXT): {$(VPATH)}config.h
struct.$(OBJEXT): {$(VPATH)}defines.h
+struct.$(OBJEXT): {$(VPATH)}encoding.h
struct.$(OBJEXT): {$(VPATH)}id.h
struct.$(OBJEXT): {$(VPATH)}intern.h
struct.$(OBJEXT): {$(VPATH)}internal.h
+struct.$(OBJEXT): {$(VPATH)}io.h
struct.$(OBJEXT): {$(VPATH)}method.h
struct.$(OBJEXT): {$(VPATH)}missing.h
struct.$(OBJEXT): {$(VPATH)}node.h
+struct.$(OBJEXT): {$(VPATH)}onigmo.h
+struct.$(OBJEXT): {$(VPATH)}oniguruma.h
struct.$(OBJEXT): {$(VPATH)}ruby_assert.h
struct.$(OBJEXT): {$(VPATH)}ruby_atomic.h
struct.$(OBJEXT): {$(VPATH)}st.h
@@ -2950,12 +2645,11 @@ struct.$(OBJEXT): {$(VPATH)}struct.c
struct.$(OBJEXT): {$(VPATH)}subst.h
struct.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
struct.$(OBJEXT): {$(VPATH)}thread_native.h
-struct.$(OBJEXT): {$(VPATH)}transient_heap.h
struct.$(OBJEXT): {$(VPATH)}vm_core.h
+struct.$(OBJEXT): {$(VPATH)}vm_debug.h
struct.$(OBJEXT): {$(VPATH)}vm_opts.h
-symbol.$(OBJEXT): $(hdrdir)/ruby.h
symbol.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-symbol.$(OBJEXT): {$(VPATH)}assert.h
+symbol.$(OBJEXT): $(top_srcdir)/include/ruby.h
symbol.$(OBJEXT): {$(VPATH)}config.h
symbol.$(OBJEXT): {$(VPATH)}defines.h
symbol.$(OBJEXT): {$(VPATH)}encoding.h
@@ -2966,6 +2660,7 @@ symbol.$(OBJEXT): {$(VPATH)}id_table.c
symbol.$(OBJEXT): {$(VPATH)}id_table.h
symbol.$(OBJEXT): {$(VPATH)}intern.h
symbol.$(OBJEXT): {$(VPATH)}internal.h
+symbol.$(OBJEXT): {$(VPATH)}io.h
symbol.$(OBJEXT): {$(VPATH)}missing.h
symbol.$(OBJEXT): {$(VPATH)}onigmo.h
symbol.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -2980,25 +2675,19 @@ thread.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
thread.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
thread.$(OBJEXT): $(CCAN_DIR)/list/list.h
thread.$(OBJEXT): $(CCAN_DIR)/str/str.h
-thread.$(OBJEXT): $(hdrdir)/ruby.h
thread.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-thread.$(OBJEXT): {$(VPATH)}assert.h
+thread.$(OBJEXT): $(top_srcdir)/include/ruby.h
thread.$(OBJEXT): {$(VPATH)}config.h
-thread.$(OBJEXT): {$(VPATH)}debug.h
-thread.$(OBJEXT): {$(VPATH)}debug_counter.h
thread.$(OBJEXT): {$(VPATH)}defines.h
thread.$(OBJEXT): {$(VPATH)}encoding.h
thread.$(OBJEXT): {$(VPATH)}eval_intern.h
thread.$(OBJEXT): {$(VPATH)}gc.h
-thread.$(OBJEXT): {$(VPATH)}hrtime.h
thread.$(OBJEXT): {$(VPATH)}id.h
thread.$(OBJEXT): {$(VPATH)}intern.h
thread.$(OBJEXT): {$(VPATH)}internal.h
thread.$(OBJEXT): {$(VPATH)}io.h
-thread.$(OBJEXT): {$(VPATH)}iseq.h
thread.$(OBJEXT): {$(VPATH)}method.h
thread.$(OBJEXT): {$(VPATH)}missing.h
-thread.$(OBJEXT): {$(VPATH)}mjit.h
thread.$(OBJEXT): {$(VPATH)}node.h
thread.$(OBJEXT): {$(VPATH)}onigmo.h
thread.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -3014,16 +2703,17 @@ thread.$(OBJEXT): {$(VPATH)}thread_native.h
thread.$(OBJEXT): {$(VPATH)}thread_sync.c
thread.$(OBJEXT): {$(VPATH)}timev.h
thread.$(OBJEXT): {$(VPATH)}vm_core.h
+thread.$(OBJEXT): {$(VPATH)}vm_debug.h
thread.$(OBJEXT): {$(VPATH)}vm_opts.h
-time.$(OBJEXT): $(hdrdir)/ruby.h
time.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-time.$(OBJEXT): {$(VPATH)}assert.h
+time.$(OBJEXT): $(top_srcdir)/include/ruby.h
time.$(OBJEXT): {$(VPATH)}config.h
time.$(OBJEXT): {$(VPATH)}defines.h
time.$(OBJEXT): {$(VPATH)}encoding.h
time.$(OBJEXT): {$(VPATH)}id.h
time.$(OBJEXT): {$(VPATH)}intern.h
time.$(OBJEXT): {$(VPATH)}internal.h
+time.$(OBJEXT): {$(VPATH)}io.h
time.$(OBJEXT): {$(VPATH)}missing.h
time.$(OBJEXT): {$(VPATH)}onigmo.h
time.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -3031,15 +2721,14 @@ time.$(OBJEXT): {$(VPATH)}st.h
time.$(OBJEXT): {$(VPATH)}subst.h
time.$(OBJEXT): {$(VPATH)}time.c
time.$(OBJEXT): {$(VPATH)}timev.h
-transcode.$(OBJEXT): $(hdrdir)/ruby.h
transcode.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-transcode.$(OBJEXT): {$(VPATH)}assert.h
+transcode.$(OBJEXT): $(top_srcdir)/include/ruby.h
transcode.$(OBJEXT): {$(VPATH)}config.h
transcode.$(OBJEXT): {$(VPATH)}defines.h
transcode.$(OBJEXT): {$(VPATH)}encoding.h
-transcode.$(OBJEXT): {$(VPATH)}id.h
transcode.$(OBJEXT): {$(VPATH)}intern.h
transcode.$(OBJEXT): {$(VPATH)}internal.h
+transcode.$(OBJEXT): {$(VPATH)}io.h
transcode.$(OBJEXT): {$(VPATH)}missing.h
transcode.$(OBJEXT): {$(VPATH)}onigmo.h
transcode.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -3047,33 +2736,17 @@ transcode.$(OBJEXT): {$(VPATH)}st.h
transcode.$(OBJEXT): {$(VPATH)}subst.h
transcode.$(OBJEXT): {$(VPATH)}transcode.c
transcode.$(OBJEXT): {$(VPATH)}transcode_data.h
-transient_heap.$(OBJEXT): $(hdrdir)/ruby.h
-transient_heap.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-transient_heap.$(OBJEXT): {$(VPATH)}assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}config.h
-transient_heap.$(OBJEXT): {$(VPATH)}debug.h
-transient_heap.$(OBJEXT): {$(VPATH)}debug_counter.h
-transient_heap.$(OBJEXT): {$(VPATH)}defines.h
-transient_heap.$(OBJEXT): {$(VPATH)}gc.h
-transient_heap.$(OBJEXT): {$(VPATH)}intern.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal.h
-transient_heap.$(OBJEXT): {$(VPATH)}missing.h
-transient_heap.$(OBJEXT): {$(VPATH)}node.h
-transient_heap.$(OBJEXT): {$(VPATH)}ruby_assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}st.h
-transient_heap.$(OBJEXT): {$(VPATH)}subst.h
-transient_heap.$(OBJEXT): {$(VPATH)}transient_heap.c
-transient_heap.$(OBJEXT): {$(VPATH)}transient_heap.h
-transient_heap.$(OBJEXT): {$(VPATH)}vm_debug.h
-util.$(OBJEXT): $(hdrdir)/ruby.h
util.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-util.$(OBJEXT): {$(VPATH)}assert.h
+util.$(OBJEXT): $(top_srcdir)/include/ruby.h
util.$(OBJEXT): {$(VPATH)}config.h
util.$(OBJEXT): {$(VPATH)}defines.h
-util.$(OBJEXT): {$(VPATH)}dtoa.c
+util.$(OBJEXT): {$(VPATH)}encoding.h
util.$(OBJEXT): {$(VPATH)}intern.h
util.$(OBJEXT): {$(VPATH)}internal.h
+util.$(OBJEXT): {$(VPATH)}io.h
util.$(OBJEXT): {$(VPATH)}missing.h
+util.$(OBJEXT): {$(VPATH)}onigmo.h
+util.$(OBJEXT): {$(VPATH)}oniguruma.h
util.$(OBJEXT): {$(VPATH)}st.h
util.$(OBJEXT): {$(VPATH)}subst.h
util.$(OBJEXT): {$(VPATH)}util.c
@@ -3082,9 +2755,8 @@ variable.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
variable.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
variable.$(OBJEXT): $(CCAN_DIR)/list/list.h
variable.$(OBJEXT): $(CCAN_DIR)/str/str.h
-variable.$(OBJEXT): $(hdrdir)/ruby.h
variable.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-variable.$(OBJEXT): {$(VPATH)}assert.h
+variable.$(OBJEXT): $(top_srcdir)/include/ruby.h
variable.$(OBJEXT): {$(VPATH)}config.h
variable.$(OBJEXT): {$(VPATH)}constant.h
variable.$(OBJEXT): {$(VPATH)}debug_counter.h
@@ -3094,79 +2766,52 @@ variable.$(OBJEXT): {$(VPATH)}id.h
variable.$(OBJEXT): {$(VPATH)}id_table.h
variable.$(OBJEXT): {$(VPATH)}intern.h
variable.$(OBJEXT): {$(VPATH)}internal.h
-variable.$(OBJEXT): {$(VPATH)}method.h
+variable.$(OBJEXT): {$(VPATH)}io.h
variable.$(OBJEXT): {$(VPATH)}missing.h
-variable.$(OBJEXT): {$(VPATH)}node.h
variable.$(OBJEXT): {$(VPATH)}onigmo.h
variable.$(OBJEXT): {$(VPATH)}oniguruma.h
-variable.$(OBJEXT): {$(VPATH)}ruby_assert.h
-variable.$(OBJEXT): {$(VPATH)}ruby_atomic.h
variable.$(OBJEXT): {$(VPATH)}st.h
variable.$(OBJEXT): {$(VPATH)}subst.h
-variable.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-variable.$(OBJEXT): {$(VPATH)}thread_native.h
-variable.$(OBJEXT): {$(VPATH)}transient_heap.h
variable.$(OBJEXT): {$(VPATH)}util.h
variable.$(OBJEXT): {$(VPATH)}variable.c
-variable.$(OBJEXT): {$(VPATH)}variable.h
-variable.$(OBJEXT): {$(VPATH)}vm_core.h
-variable.$(OBJEXT): {$(VPATH)}vm_opts.h
-version.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-version.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-version.$(OBJEXT): $(CCAN_DIR)/list/list.h
-version.$(OBJEXT): $(CCAN_DIR)/str/str.h
-version.$(OBJEXT): $(hdrdir)/ruby.h
version.$(OBJEXT): $(hdrdir)/ruby/ruby.h
version.$(OBJEXT): $(hdrdir)/ruby/version.h
version.$(OBJEXT): $(top_srcdir)/revision.h
version.$(OBJEXT): $(top_srcdir)/version.h
-version.$(OBJEXT): {$(VPATH)}assert.h
version.$(OBJEXT): {$(VPATH)}config.h
-version.$(OBJEXT): {$(VPATH)}debug_counter.h
version.$(OBJEXT): {$(VPATH)}defines.h
-version.$(OBJEXT): {$(VPATH)}id.h
version.$(OBJEXT): {$(VPATH)}intern.h
-version.$(OBJEXT): {$(VPATH)}internal.h
-version.$(OBJEXT): {$(VPATH)}method.h
version.$(OBJEXT): {$(VPATH)}missing.h
-version.$(OBJEXT): {$(VPATH)}mjit.h
-version.$(OBJEXT): {$(VPATH)}node.h
-version.$(OBJEXT): {$(VPATH)}ruby_assert.h
-version.$(OBJEXT): {$(VPATH)}ruby_atomic.h
version.$(OBJEXT): {$(VPATH)}st.h
version.$(OBJEXT): {$(VPATH)}subst.h
-version.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-version.$(OBJEXT): {$(VPATH)}thread_native.h
version.$(OBJEXT): {$(VPATH)}version.c
-version.$(OBJEXT): {$(VPATH)}vm_core.h
-version.$(OBJEXT): {$(VPATH)}vm_opts.h
vm.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
vm.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
vm.$(OBJEXT): $(CCAN_DIR)/list/list.h
vm.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm.$(OBJEXT): $(hdrdir)/ruby.h
vm.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm.$(OBJEXT): {$(VPATH)}assert.h
-vm.$(OBJEXT): {$(VPATH)}builtin.h
+vm.$(OBJEXT): $(hdrdir)/ruby/version.h
+vm.$(OBJEXT): $(top_srcdir)/include/ruby.h
vm.$(OBJEXT): {$(VPATH)}config.h
vm.$(OBJEXT): {$(VPATH)}constant.h
vm.$(OBJEXT): {$(VPATH)}debug_counter.h
vm.$(OBJEXT): {$(VPATH)}defines.h
-vm.$(OBJEXT): {$(VPATH)}defs/opt_operand.def
+vm.$(OBJEXT): {$(VPATH)}encoding.h
vm.$(OBJEXT): {$(VPATH)}eval_intern.h
vm.$(OBJEXT): {$(VPATH)}gc.h
vm.$(OBJEXT): {$(VPATH)}id.h
vm.$(OBJEXT): {$(VPATH)}id_table.h
vm.$(OBJEXT): {$(VPATH)}insns.def
vm.$(OBJEXT): {$(VPATH)}insns.inc
-vm.$(OBJEXT): {$(VPATH)}insns_info.inc
vm.$(OBJEXT): {$(VPATH)}intern.h
vm.$(OBJEXT): {$(VPATH)}internal.h
+vm.$(OBJEXT): {$(VPATH)}io.h
vm.$(OBJEXT): {$(VPATH)}iseq.h
vm.$(OBJEXT): {$(VPATH)}method.h
vm.$(OBJEXT): {$(VPATH)}missing.h
-vm.$(OBJEXT): {$(VPATH)}mjit.h
vm.$(OBJEXT): {$(VPATH)}node.h
+vm.$(OBJEXT): {$(VPATH)}onigmo.h
+vm.$(OBJEXT): {$(VPATH)}oniguruma.h
vm.$(OBJEXT): {$(VPATH)}probes.dmyh
vm.$(OBJEXT): {$(VPATH)}probes.h
vm.$(OBJEXT): {$(VPATH)}probes_helper.h
@@ -3176,7 +2821,6 @@ vm.$(OBJEXT): {$(VPATH)}st.h
vm.$(OBJEXT): {$(VPATH)}subst.h
vm.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
vm.$(OBJEXT): {$(VPATH)}thread_native.h
-vm.$(OBJEXT): {$(VPATH)}variable.h
vm.$(OBJEXT): {$(VPATH)}vm.c
vm.$(OBJEXT): {$(VPATH)}vm.h
vm.$(OBJEXT): {$(VPATH)}vm.inc
@@ -3196,9 +2840,9 @@ vm_backtrace.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
vm_backtrace.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
vm_backtrace.$(OBJEXT): $(CCAN_DIR)/list/list.h
vm_backtrace.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm_backtrace.$(OBJEXT): $(hdrdir)/ruby.h
vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}assert.h
+vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/version.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/include/ruby.h
vm_backtrace.$(OBJEXT): {$(VPATH)}config.h
vm_backtrace.$(OBJEXT): {$(VPATH)}debug.h
vm_backtrace.$(OBJEXT): {$(VPATH)}defines.h
@@ -3207,6 +2851,7 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}eval_intern.h
vm_backtrace.$(OBJEXT): {$(VPATH)}id.h
vm_backtrace.$(OBJEXT): {$(VPATH)}intern.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}io.h
vm_backtrace.$(OBJEXT): {$(VPATH)}iseq.h
vm_backtrace.$(OBJEXT): {$(VPATH)}method.h
vm_backtrace.$(OBJEXT): {$(VPATH)}missing.h
@@ -3221,26 +2866,29 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
vm_backtrace.$(OBJEXT): {$(VPATH)}thread_native.h
vm_backtrace.$(OBJEXT): {$(VPATH)}vm_backtrace.c
vm_backtrace.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_debug.h
vm_backtrace.$(OBJEXT): {$(VPATH)}vm_opts.h
vm_dump.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
vm_dump.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
vm_dump.$(OBJEXT): $(CCAN_DIR)/list/list.h
vm_dump.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm_dump.$(OBJEXT): $(hdrdir)/ruby.h
vm_dump.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm_dump.$(OBJEXT): $(hdrdir)/ruby/version.h
+vm_dump.$(OBJEXT): $(top_srcdir)/include/ruby.h
vm_dump.$(OBJEXT): {$(VPATH)}addr2line.h
-vm_dump.$(OBJEXT): {$(VPATH)}assert.h
vm_dump.$(OBJEXT): {$(VPATH)}config.h
vm_dump.$(OBJEXT): {$(VPATH)}defines.h
-vm_dump.$(OBJEXT): {$(VPATH)}gc.h
+vm_dump.$(OBJEXT): {$(VPATH)}encoding.h
vm_dump.$(OBJEXT): {$(VPATH)}id.h
vm_dump.$(OBJEXT): {$(VPATH)}intern.h
vm_dump.$(OBJEXT): {$(VPATH)}internal.h
+vm_dump.$(OBJEXT): {$(VPATH)}io.h
vm_dump.$(OBJEXT): {$(VPATH)}iseq.h
vm_dump.$(OBJEXT): {$(VPATH)}method.h
vm_dump.$(OBJEXT): {$(VPATH)}missing.h
vm_dump.$(OBJEXT): {$(VPATH)}node.h
-vm_dump.$(OBJEXT): {$(VPATH)}procstat_vm.c
+vm_dump.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_dump.$(OBJEXT): {$(VPATH)}oniguruma.h
vm_dump.$(OBJEXT): {$(VPATH)}ruby_assert.h
vm_dump.$(OBJEXT): {$(VPATH)}ruby_atomic.h
vm_dump.$(OBJEXT): {$(VPATH)}st.h
@@ -3248,37 +2896,38 @@ vm_dump.$(OBJEXT): {$(VPATH)}subst.h
vm_dump.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
vm_dump.$(OBJEXT): {$(VPATH)}thread_native.h
vm_dump.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_dump.$(OBJEXT): {$(VPATH)}vm_debug.h
vm_dump.$(OBJEXT): {$(VPATH)}vm_dump.c
vm_dump.$(OBJEXT): {$(VPATH)}vm_opts.h
vm_trace.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
vm_trace.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
vm_trace.$(OBJEXT): $(CCAN_DIR)/list/list.h
vm_trace.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm_trace.$(OBJEXT): $(hdrdir)/ruby.h
vm_trace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm_trace.$(OBJEXT): {$(VPATH)}assert.h
-vm_trace.$(OBJEXT): {$(VPATH)}builtin.h
+vm_trace.$(OBJEXT): $(top_srcdir)/include/ruby.h
vm_trace.$(OBJEXT): {$(VPATH)}config.h
vm_trace.$(OBJEXT): {$(VPATH)}debug.h
-vm_trace.$(OBJEXT): {$(VPATH)}debug_counter.h
vm_trace.$(OBJEXT): {$(VPATH)}defines.h
+vm_trace.$(OBJEXT): {$(VPATH)}encoding.h
vm_trace.$(OBJEXT): {$(VPATH)}eval_intern.h
vm_trace.$(OBJEXT): {$(VPATH)}id.h
vm_trace.$(OBJEXT): {$(VPATH)}intern.h
vm_trace.$(OBJEXT): {$(VPATH)}internal.h
+vm_trace.$(OBJEXT): {$(VPATH)}io.h
vm_trace.$(OBJEXT): {$(VPATH)}iseq.h
vm_trace.$(OBJEXT): {$(VPATH)}method.h
vm_trace.$(OBJEXT): {$(VPATH)}missing.h
-vm_trace.$(OBJEXT): {$(VPATH)}mjit.h
vm_trace.$(OBJEXT): {$(VPATH)}node.h
+vm_trace.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_trace.$(OBJEXT): {$(VPATH)}oniguruma.h
vm_trace.$(OBJEXT): {$(VPATH)}ruby_assert.h
vm_trace.$(OBJEXT): {$(VPATH)}ruby_atomic.h
vm_trace.$(OBJEXT): {$(VPATH)}st.h
vm_trace.$(OBJEXT): {$(VPATH)}subst.h
vm_trace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
vm_trace.$(OBJEXT): {$(VPATH)}thread_native.h
-vm_trace.$(OBJEXT): {$(VPATH)}trace_point.rbinc
vm_trace.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_trace.$(OBJEXT): {$(VPATH)}vm_debug.h
vm_trace.$(OBJEXT): {$(VPATH)}vm_opts.h
vm_trace.$(OBJEXT): {$(VPATH)}vm_trace.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/compar.c b/compar.c
index 94072c9fc1..02529c9960 100644
--- a/compar.c
+++ b/compar.c
@@ -11,7 +11,6 @@
#include "ruby/ruby.h"
#include "id.h"
-#include "internal.h"
VALUE rb_mComparable;
@@ -96,7 +95,7 @@ cmpint(VALUE x, VALUE y)
* obj > other -> true or false
*
* Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value greater than 0.
+ * method, returning true if it returns 1.
*/
static VALUE
@@ -111,7 +110,7 @@ cmp_gt(VALUE x, VALUE y)
* obj >= other -> true or false
*
* Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value greater than or equal to 0.
+ * method, returning true if it returns 0 or 1.
*/
static VALUE
@@ -126,7 +125,7 @@ cmp_ge(VALUE x, VALUE y)
* obj < other -> true or false
*
* Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value less than 0.
+ * method, returning true if it returns -1.
*/
static VALUE
@@ -141,7 +140,7 @@ cmp_lt(VALUE x, VALUE y)
* obj <= other -> true or false
*
* Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value less than or equal to 0.
+ * method, returning true if it returns -1 or 0.
*/
static VALUE
@@ -155,9 +154,9 @@ cmp_le(VALUE x, VALUE y)
* call-seq:
* obj.between?(min, max) -> true or false
*
- * Returns <code>false</code> if _obj_ <code><=></code> _min_ is less
- * than zero or if _obj_ <code><=></code> _max_ is greater than zero,
- * <code>true</code> otherwise.
+ * Returns <code>false</code> if <i>obj</i> <code><=></code>
+ * <i>min</i> is less than zero or if <i>anObject</i> <code><=></code>
+ * <i>max</i> is greater than zero, <code>true</code> otherwise.
*
* 3.between?(1, 5) #=> true
* 6.between?(1, 5) #=> false
@@ -177,12 +176,10 @@ cmp_between(VALUE x, VALUE min, VALUE max)
/*
* call-seq:
* obj.clamp(min, max) -> obj
- * obj.clamp(range) -> obj
*
- * In <code>(min, max)</code> form, returns _min_ if _obj_
- * <code><=></code> _min_ is less than zero, _max_ if _obj_
- * <code><=></code> _max_ is greater than zero, and _obj_
- * otherwise.
+ * Returns <i>min</i> if <i>obj</i> <code><=></code> <i>min</i> is less
+ * than zero, <i>max</i> if <i>obj</i> <code><=></code> <i>max</i> is
+ * greater than zero and <i>obj</i> otherwise.
*
* 12.clamp(0, 100) #=> 12
* 523.clamp(0, 100) #=> 100
@@ -190,78 +187,36 @@ cmp_between(VALUE x, VALUE min, VALUE max)
*
* 'd'.clamp('a', 'f') #=> 'd'
* 'z'.clamp('a', 'f') #=> 'f'
- *
- * In <code>(range)</code> form, returns _range.begin_ if _obj_
- * <code><=></code> _range.begin_ is less than zero, _range.end_
- * if _obj_ <code><=></code> _range.end_ is greater than zero, and
- * _obj_ otherwise.
- *
- * 12.clamp(0..100) #=> 12
- * 523.clamp(0..100) #=> 100
- * -3.123.clamp(0..100) #=> 0
- *
- * 'd'.clamp('a'..'f') #=> 'd'
- * 'z'.clamp('a'..'f') #=> 'f'
- *
- * If _range.begin_ is +nil+, it is considered smaller than _obj_,
- * and if _range.end_ is +nil+, it is considered greater than
- * _obj_.
- *
- * -20.clamp(0..) #=> 0
- * 523.clamp(..100) #=> 100
- *
- * When _range.end_ is excluded and not +nil+, an exception is
- * raised.
- *
- * 100.clamp(0...100) # ArgumentError
*/
static VALUE
-cmp_clamp(int argc, VALUE *argv, VALUE x)
+cmp_clamp(VALUE x, VALUE min, VALUE max)
{
- VALUE min, max;
- int c, excl = 0;
-
- if (rb_scan_args(argc, argv, "11", &min, &max) == 1) {
- VALUE range = min;
- if (!rb_range_values(range, &min, &max, &excl)) {
- rb_raise(rb_eTypeError, "wrong argument type %s (expected Range)",
- rb_builtin_class_name(range));
- }
- if (!NIL_P(max)) {
- if (excl) rb_raise(rb_eArgError, "cannot clamp with an exclusive range");
- if (!NIL_P(min) && cmpint(min, max) > 0) goto arg_error;
- }
- }
- else if (cmpint(min, max) > 0) {
- arg_error:
+ int c;
+
+ if (cmpint(min, max) > 0) {
rb_raise(rb_eArgError, "min argument must be smaller than max argument");
}
- if (!NIL_P(min)) {
- c = cmpint(x, min);
- if (c == 0) return x;
- if (c < 0) return min;
- }
- if (!NIL_P(max)) {
- c = cmpint(x, max);
- if (c > 0) return max;
- }
+ c = cmpint(x, min);
+ if (c == 0) return x;
+ if (c < 0) return min;
+ c = cmpint(x, max);
+ if (c > 0) return max;
return x;
}
/*
- * The Comparable mixin is used by classes whose objects may be
- * ordered. The class must define the <code><=></code> operator,
- * which compares the receiver against another object, returning a
- * value less than 0, returning 0, or returning a value greater than 0,
- * depending on whether the receiver is less than, equal to,
- * or greater than the other object. If the other object is not
- * comparable then the <code><=></code> operator should return +nil+.
- * Comparable uses <code><=></code> to implement the conventional
- * comparison operators (<code><</code>, <code><=</code>,
- * <code>==</code>, <code>>=</code>, and <code>></code>) and the
- * method <code>between?</code>.
+ * The <code>Comparable</code> mixin is used by classes whose objects
+ * may be ordered. The class must define the <code><=></code> operator,
+ * which compares the receiver against another object, returning -1, 0,
+ * or +1 depending on whether the receiver is less than, equal to, or
+ * greater than the other object. If the other object is not comparable
+ * then the <code><=></code> operator should return nil.
+ * <code>Comparable</code> uses
+ * <code><=></code> to implement the conventional comparison operators
+ * (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,
+ * and <code>></code>) and the method <code>between?</code>.
*
* class SizeMatters
* include Comparable
@@ -303,5 +258,5 @@ Init_Comparable(void)
rb_define_method(rb_mComparable, "<", cmp_lt, 1);
rb_define_method(rb_mComparable, "<=", cmp_le, 1);
rb_define_method(rb_mComparable, "between?", cmp_between, 2);
- rb_define_method(rb_mComparable, "clamp", cmp_clamp, -1);
+ rb_define_method(rb_mComparable, "clamp", cmp_clamp, 2);
}
diff --git a/compile.c b/compile.c
index e2c24a119b..2c10d151f5 100644
--- a/compile.c
+++ b/compile.c
@@ -9,16 +9,13 @@
**********************************************************************/
-#include "ruby/encoding.h"
-#include "ruby/re.h"
-#include "ruby/util.h"
#include "internal.h"
+#include "ruby/re.h"
#include "encindex.h"
#include <math.h>
+#define USE_INSN_STACK_INCREASE 1
#include "vm_core.h"
-#include "vm_debug.h"
-#include "builtin.h"
#include "iseq.h"
#include "insns.inc"
#include "insns_info.inc"
@@ -32,16 +29,17 @@
#undef RUBY_UNTYPED_DATA_WARNING
#define RUBY_UNTYPED_DATA_WARNING 0
+#define ISEQ_TYPE_ONCE_GUARD ISEQ_TYPE_DEFINED_GUARD
+
#define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
#define FIXNUM_OR(n, i) ((n)|INT2FIX(i))
typedef struct iseq_link_element {
enum {
- ISEQ_ELEMENT_ANCHOR,
ISEQ_ELEMENT_LABEL,
ISEQ_ELEMENT_INSN,
ISEQ_ELEMENT_ADJUST,
- ISEQ_ELEMENT_TRACE,
+ ISEQ_ELEMENT_TRACE
} type;
struct iseq_link_element *next;
struct iseq_link_element *prev;
@@ -92,7 +90,6 @@ typedef struct iseq_adjust_data {
typedef struct iseq_trace_data {
LINK_ELEMENT link;
rb_event_flag_t event;
- long data;
} TRACE;
struct ensure_range {
@@ -107,8 +104,6 @@ struct iseq_compile_data_ensure_node_stack {
struct ensure_range *erange;
};
-const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
-
/**
* debug function(macro) interface depend on CPDEBUG
* if it is less than 0, runtime option is in effect.
@@ -204,27 +199,18 @@ const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
#define ADD_INSN(seq, line, insn) \
ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
-/* insert an instruction before next */
-#define INSERT_BEFORE_INSN(next, line, insn) \
- ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
-
-/* insert an instruction after prev */
-#define INSERT_AFTER_INSN(prev, line, insn) \
- ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
+/* insert an instruction before prev */
+#define INSERT_BEFORE_INSN(prev, line, insn) \
+ ELEM_INSERT_PREV(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
/* add an instruction with some operands (1, 2, 3, 5) */
#define ADD_INSN1(seq, line, insn, op1) \
ADD_ELEM((seq), (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
-/* insert an instruction with some operands (1, 2, 3, 5) before next */
-#define INSERT_BEFORE_INSN1(next, line, insn, op1) \
- ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) \
- new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
-
-/* insert an instruction with some operands (1, 2, 3, 5) after prev */
-#define INSERT_AFTER_INSN1(prev, line, insn, op1) \
- ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) \
+/* insert an instruction with some operands (1, 2, 3, 5) before prev */
+#define INSERT_BEFORE_INSN1(prev, line, insn, op1) \
+ ELEM_INSERT_PREV(&(prev)->link, (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
#define LABEL_REF(label) ((label)->refcnt++)
@@ -263,9 +249,16 @@ const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (line), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))
#define ADD_TRACE(seq, event) \
- ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event), 0))
-#define ADD_TRACE_WITH_DATA(seq, event, data) \
- ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event), (data)))
+ ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event)))
+#define ADD_TRACE_LINE_COVERAGE(seq, line) \
+ do { \
+ if (ISEQ_COVERAGE(iseq) && \
+ ISEQ_LINE_COVERAGE(iseq) && \
+ (line) > 0) { \
+ RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), (line) - 1, INT2FIX(0)); \
+ ADD_INSN2((seq), (line), tracecoverage, INT2FIX(RUBY_EVENT_COVERAGE_LINE), INT2FIX(line)); \
+ } \
+ } while (0)
#define DECL_BRANCH_BASE(branches, first_line, first_column, last_line, last_column, type) \
@@ -274,7 +267,7 @@ const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
ISEQ_BRANCH_COVERAGE(iseq) && \
(first_line) > 0) { \
VALUE structure = RARRAY_AREF(ISEQ_BRANCH_COVERAGE(iseq), 0); \
- branches = rb_ary_tmp_new(5); \
+ branches = rb_ary_tmp_new(0); \
rb_ary_push(structure, branches); \
rb_ary_push(branches, ID2SYM(rb_intern(type))); \
rb_ary_push(branches, INT2FIX(first_line)); \
@@ -297,8 +290,7 @@ const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
rb_ary_push(branches, INT2FIX(last_line)); \
rb_ary_push(branches, INT2FIX(last_column)); \
rb_ary_push(branches, INT2FIX(counter_idx)); \
- ADD_TRACE_WITH_DATA(seq, RUBY_EVENT_COVERAGE_BRANCH, counter_idx); \
- ADD_INSN(seq, last_line, nop); \
+ ADD_INSN2((seq), (first_line), tracecoverage, INT2FIX(RUBY_EVENT_COVERAGE_BRANCH), INT2FIX(counter_idx)); \
} \
} while (0)
@@ -330,8 +322,6 @@ static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line,
LABEL_UNREMOVABLE(ls); \
LABEL_REF(le); \
LABEL_REF(lc); \
- if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) \
- RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_tmp_new(3)); \
rb_ary_push(ISEQ_COMPILE_DATA(iseq)->catch_table_ary, freeze_hide_obj(_e)); \
} while (0)
@@ -353,7 +343,7 @@ static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line,
#define COMPILE_RECV(anchor, desc, node) \
(private_recv_p(node) ? \
(ADD_INSN(anchor, nd_line(node), putself), VM_CALL_FCALL) : \
- COMPILE(anchor, desc, node->nd_recv) ? 0 : -1)
+ (COMPILE(anchor, desc, node->nd_recv), 0))
#define OPERAND_AT(insn, idx) \
(((INSN*)(insn))->operands[(idx)])
@@ -371,11 +361,11 @@ static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line,
/* error */
#if CPDEBUG > 0
-NORETURN(static void append_compile_error(const rb_iseq_t *iseq, int line, const char *fmt, ...));
+NORETURN(static void append_compile_error(rb_iseq_t *iseq, int line, const char *fmt, ...));
#endif
static void
-append_compile_error(const rb_iseq_t *iseq, int line, const char *fmt, ...)
+append_compile_error(rb_iseq_t *iseq, int line, const char *fmt, ...)
{
VALUE err_info = ISEQ_COMPILE_DATA(iseq)->err_info;
VALUE file = rb_iseq_path(iseq);
@@ -392,10 +382,7 @@ append_compile_error(const rb_iseq_t *iseq, int line, const char *fmt, ...)
else if (!err_info) {
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, Qtrue);
}
- if (compile_debug) {
- if (SPECIAL_CONST_P(err)) err = rb_eSyntaxError;
- rb_exc_fatal(err);
- }
+ if (compile_debug) rb_exc_fatal(err);
}
#if 0
@@ -446,13 +433,12 @@ do { \
#define COMPILE_NG 0
#define CHECK(sub) if (!(sub)) {BEFORE_RETURN;return COMPILE_NG;}
-#define NO_CHECK(sub) (void)(sub)
#define BEFORE_RETURN
/* leave name uninitialized so that compiler warn if INIT_ANCHOR is
* missing */
#define DECL_ANCHOR(name) \
- LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},}}
+ LINK_ANCHOR name[1] = {{{0,},}}
#define INIT_ANCHOR(name) \
(name->last = &name->anchor)
@@ -491,7 +477,7 @@ static int calc_sp_depth(int depth, INSN *iobj);
static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, enum ruby_vminsn_type insn_id, int argc, ...);
static LABEL *new_label_body(rb_iseq_t *iseq, long line);
static ADJUST *new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line);
-static TRACE *new_trace_body(rb_iseq_t *iseq, rb_event_flag_t event, long data);
+static TRACE *new_trace_body(rb_iseq_t *iseq, rb_event_flag_t event);
static int iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *anchor, const NODE *n, int);
@@ -547,31 +533,6 @@ verify_list(ISEQ_ARG_DECLARE const char *info, LINK_ANCHOR *const anchor)
#define verify_list(info, anchor) verify_list(iseq, (info), (anchor))
#endif
-static void
-verify_call_cache(rb_iseq_t *iseq)
-{
-#if CPDEBUG
- VALUE *original = rb_iseq_original_iseq(iseq);
- size_t i = 0;
- while (i < iseq->body->iseq_size) {
- VALUE insn = original[i];
- const char *types = insn_op_types(insn);
-
- for (int j=0; types[j]; j++) {
- if (types[j] == TS_CALLDATA) {
- struct rb_call_cache cc;
- struct rb_call_data *cd = (struct rb_call_data *)original[i+j+1];
- MEMZERO(&cc, cc, 1);
- if (memcmp(&cc, &cd->cc, sizeof(cc))) {
- rb_bug("call cache not zero for fresh iseq");
- }
- }
- }
- i += insn_len(insn);
- }
-#endif
-}
-
/*
* elem1, elem2 => elem1, elem2, elem
*/
@@ -602,7 +563,31 @@ APPEND_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *const anchor, LINK_ELEMENT *before, LI
#define APPEND_ELEM(anchor, before, elem) APPEND_ELEM(iseq, (anchor), (before), (elem))
#endif
-#define ISEQ_LAST_LINE(iseq) (ISEQ_COMPILE_DATA(iseq)->last_line)
+static int
+iseq_add_mark_object(const rb_iseq_t *iseq, VALUE v)
+{
+ if (!SPECIAL_CONST_P(v)) {
+ rb_iseq_add_mark_object(iseq, v);
+ }
+ return COMPILE_OK;
+}
+
+static int
+iseq_add_mark_object_compile_time(const rb_iseq_t *iseq, VALUE v)
+{
+ if (!SPECIAL_CONST_P(v)) {
+ rb_ary_push(ISEQ_COMPILE_DATA(iseq)->mark_ary, v);
+ }
+ return COMPILE_OK;
+}
+
+static inline VALUE
+freeze_literal(rb_iseq_t *iseq, VALUE lit)
+{
+ lit = rb_fstring(lit);
+ rb_ary_push(ISEQ_COMPILE_DATA(iseq)->mark_ary, lit);
+ return lit;
+}
static int
validate_label(st_data_t name, st_data_t label, st_data_t arg)
@@ -627,7 +612,7 @@ validate_labels(rb_iseq_t *iseq, st_table *labels_table)
}
VALUE
-rb_iseq_compile_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_callback_callback_func * ifunc)
+rb_iseq_compile_ifunc(rb_iseq_t *iseq, const struct vm_ifunc *ifunc)
{
DECL_ANCHOR(ret);
INIT_ANCHOR(ret);
@@ -646,14 +631,15 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
DECL_ANCHOR(ret);
INIT_ANCHOR(ret);
- if (imemo_type_p((VALUE)node, imemo_ifunc)) {
- rb_raise(rb_eArgError, "unexpected imemo_ifunc");
- }
-
if (node == 0) {
- NO_CHECK(COMPILE(ret, "nil", node));
+ COMPILE(ret, "nil", node);
iseq_set_local_table(iseq, 0);
}
+ else if (imemo_type_p((VALUE)node, imemo_ifunc)) {
+ const struct vm_ifunc *ifunc = (struct vm_ifunc *)node;
+ /* user callback */
+ (*ifunc->func)(iseq, ret, ifunc->data);
+ }
/* assume node is T_NODE */
else if (nd_type(node) == NODE_SCOPE) {
/* iseq type of top, method, class, block */
@@ -675,7 +661,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
CHECK(COMPILE(ret, "block body", node->nd_body));
ADD_LABEL(ret, end);
ADD_TRACE(ret, RUBY_EVENT_B_RETURN);
- ISEQ_COMPILE_DATA(iseq)->last_line = iseq->body->location.code_location.end_pos.lineno;
+ ISEQ_COMPILE_DATA(iseq)->last_line = iseq->body->location.code_range.last_loc.lineno;
/* wide range catch handler must put at last */
ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, NULL, start);
@@ -724,8 +710,9 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
iseq_set_exception_local_table(iseq);
CHECK(COMPILE_POPPED(ret, "ensure", node));
break;
- case ISEQ_TYPE_PLAIN:
- CHECK(COMPILE(ret, "ensure", node));
+ case ISEQ_TYPE_DEFINED_GUARD:
+ iseq_set_exception_local_table(iseq);
+ CHECK(COMPILE(ret, "defined guard", node));
break;
default:
COMPILE_ERROR(ERROR_ARGS "unknown scope: %d", iseq->body->type);
@@ -744,7 +731,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
ADD_INSN(ret, ISEQ_COMPILE_DATA(iseq)->last_line, leave);
}
-#if OPT_SUPPORT_JOKE
+#if SUPPORT_JOKE
if (ISEQ_COMPILE_DATA(iseq)->labels_table) {
st_table *labels_table = ISEQ_COMPILE_DATA(iseq)->labels_table;
ISEQ_COMPILE_DATA(iseq)->labels_table = 0;
@@ -755,7 +742,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
return iseq_setup(iseq, ret);
}
-static int
+int
rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
{
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
@@ -769,11 +756,26 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
encoded[i] = (VALUE)table[insn];
i += len;
}
- FL_SET(iseq, ISEQ_TRANSLATED);
#endif
return COMPILE_OK;
}
+#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
+static int
+rb_vm_insn_addr2insn(const void *addr) /* cold path */
+{
+ int insn;
+ const void * const *table = rb_vm_get_insns_address_table();
+
+ for (insn = 0; insn < VM_INSTRUCTION_SIZE; insn++) {
+ if (table[insn] == addr) {
+ return insn;
+ }
+ }
+ rb_bug("rb_vm_insn_addr2insn: invalid insn address: %p", addr);
+}
+#endif
+
VALUE *
rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */
{
@@ -853,10 +855,11 @@ calc_padding(void *ptr, size_t size)
#endif /* STRICT_ALIGNMENT */
static void *
-compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t size)
+compile_data_alloc(rb_iseq_t *iseq, size_t size)
{
void *ptr = 0;
- struct iseq_compile_data_storage *storage = *arena;
+ struct iseq_compile_data_storage *storage =
+ ISEQ_COMPILE_DATA(iseq)->storage_current;
#ifdef STRICT_ALIGNMENT
size_t padding = calc_padding((void *)&storage->buff[storage->pos], size);
#else
@@ -872,8 +875,8 @@ compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t s
alloc_size *= 2;
}
storage->next = (void *)ALLOC_N(char, alloc_size +
- offsetof(struct iseq_compile_data_storage, buff));
- storage = *arena = storage->next;
+ SIZEOF_ISEQ_COMPILE_DATA_STORAGE);
+ storage = ISEQ_COMPILE_DATA(iseq)->storage_current = storage->next;
storage->next = 0;
storage->pos = 0;
storage->size = alloc_size;
@@ -891,25 +894,10 @@ compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t s
return ptr;
}
-static void *
-compile_data_alloc(rb_iseq_t *iseq, size_t size)
-{
- struct iseq_compile_data_storage ** arena = &ISEQ_COMPILE_DATA(iseq)->node.storage_current;
- return compile_data_alloc_with_arena(arena, size);
-}
-
-static inline void *
-compile_data_alloc2(rb_iseq_t *iseq, size_t x, size_t y)
-{
- size_t size = rb_size_mul_or_raise(x, y, rb_eRuntimeError);
- return compile_data_alloc(iseq, size);
-}
-
static INSN *
compile_data_alloc_insn(rb_iseq_t *iseq)
{
- struct iseq_compile_data_storage ** arena = &ISEQ_COMPILE_DATA(iseq)->insn.storage_current;
- return (INSN *)compile_data_alloc_with_arena(arena, sizeof(INSN));
+ return (INSN *)compile_data_alloc(iseq, sizeof(INSN));
}
static LABEL *
@@ -1068,6 +1056,35 @@ APPEND_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *const anc1, LINK_ANCHOR *const anc2)
#define APPEND_LIST(anc1, anc2) APPEND_LIST(iseq, (anc1), (anc2))
#endif
+/*
+ * anc1: e1, e2, e3
+ * anc2: e4, e5
+ *#=>
+ * anc1: e4, e5, e1, e2, e3
+ * anc2: e4, e5 (broken)
+ */
+static void
+INSERT_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *const anc1, LINK_ANCHOR *const anc2)
+{
+ if (anc2->anchor.next) {
+ LINK_ELEMENT *first = anc1->anchor.next;
+ anc1->anchor.next = anc2->anchor.next;
+ anc1->anchor.next->prev = &anc1->anchor;
+ anc2->last->next = first;
+ if (first) {
+ first->prev = anc2->last;
+ }
+ else {
+ anc1->last = anc2->last;
+ }
+ }
+
+ verify_list("append", anc1);
+}
+#if CPDEBUG < 0
+#define INSERT_LIST(anc1, anc2) INSERT_LIST(iseq, (anc1), (anc2))
+#endif
+
#if CPDEBUG && 0
static void
debug_list(ISEQ_ARG_DECLARE LINK_ANCHOR *const anchor)
@@ -1094,14 +1111,13 @@ debug_list(ISEQ_ARG_DECLARE LINK_ANCHOR *const anchor)
#endif
static TRACE *
-new_trace_body(rb_iseq_t *iseq, rb_event_flag_t event, long data)
+new_trace_body(rb_iseq_t *iseq, rb_event_flag_t event)
{
TRACE *trace = compile_data_alloc_trace(iseq);
trace->link.type = ISEQ_ELEMENT_TRACE;
trace->link.next = NULL;
trace->event = event;
- trace->data = data;
return trace;
}
@@ -1163,7 +1179,7 @@ new_insn_body(rb_iseq_t *iseq, int line_no, enum ruby_vminsn_type insn_id, int a
if (argc > 0) {
int i;
va_init_list(argv, argc);
- operands = compile_data_alloc2(iseq, sizeof(VALUE), argc);
+ operands = (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * argc);
for (i = 0; i < argc; i++) {
VALUE v = va_arg(argv, VALUE);
operands[i] = v;
@@ -1204,10 +1220,11 @@ new_callinfo(rb_iseq_t *iseq, ID mid, int argc, unsigned int flag, struct rb_cal
static INSN *
new_insn_send(rb_iseq_t *iseq, int line_no, ID id, VALUE argc, const rb_iseq_t *blockiseq, VALUE flag, struct rb_call_info_kw_arg *keywords)
{
- VALUE *operands = compile_data_alloc2(iseq, sizeof(VALUE), 2);
+ VALUE *operands = (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * 3);
operands[0] = (VALUE)new_callinfo(iseq, id, FIX2INT(argc), FIX2INT(flag), keywords, blockiseq != NULL);
- operands[1] = (VALUE)blockiseq;
- return new_insn_core(iseq, line_no, BIN(send), 2, operands);
+ operands[1] = Qfalse; /* cache */
+ operands[2] = (VALUE)blockiseq;
+ return new_insn_core(iseq, line_no, BIN(send), 3, operands);
}
static rb_iseq_t *
@@ -1215,98 +1232,24 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
VALUE name, const rb_iseq_t *parent, enum iseq_type type, int line_no)
{
rb_iseq_t *ret_iseq;
- rb_ast_body_t ast;
-
- ast.root = node;
- ast.compile_option = 0;
- ast.line_count = -1;
debugs("[new_child_iseq]> ---------------------------------------\n");
- ret_iseq = rb_iseq_new_with_opt(&ast, name,
+ ret_iseq = rb_iseq_new_with_opt(node, name,
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
INT2FIX(line_no), parent, type, ISEQ_COMPILE_DATA(iseq)->option);
debugs("[new_child_iseq]< ---------------------------------------\n");
- return ret_iseq;
-}
-
-static rb_iseq_t *
-new_child_iseq_with_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_callback_callback_func *ifunc,
- VALUE name, const rb_iseq_t *parent, enum iseq_type type, int line_no)
-{
- rb_iseq_t *ret_iseq;
-
- debugs("[new_child_iseq_with_callback]> ---------------------------------------\n");
- ret_iseq = rb_iseq_new_with_callback(ifunc, name,
- rb_iseq_path(iseq), rb_iseq_realpath(iseq),
- INT2FIX(line_no), parent, type, ISEQ_COMPILE_DATA(iseq)->option);
- debugs("[new_child_iseq_with_callback]< ---------------------------------------\n");
+ iseq_add_mark_object(iseq, (VALUE)ret_iseq);
return ret_iseq;
}
static void
-set_catch_except_p(struct rb_iseq_constant_body *body)
-{
- body->catch_except_p = TRUE;
- if (body->parent_iseq != NULL) {
- set_catch_except_p(body->parent_iseq->body);
- }
-}
-
-/* Set body->catch_except_p to TRUE if the ISeq may catch an exception. If it is FALSE,
- JIT-ed code may be optimized. If we are extremely conservative, we should set TRUE
- if catch table exists. But we want to optimize while loop, which always has catch
- table entries for break/next/redo.
-
- So this function sets TRUE for limited ISeqs with break/next/redo catch table entries
- whose child ISeq would really raise an exception. */
-static void
-update_catch_except_flags(struct rb_iseq_constant_body *body)
-{
- unsigned int pos;
- size_t i;
- int insn;
- const struct iseq_catch_table *ct = body->catch_table;
-
- /* This assumes that a block has parent_iseq which may catch an exception from the block, and that
- BREAK/NEXT/REDO catch table entries are used only when `throw` insn is used in the block. */
- pos = 0;
- while (pos < body->iseq_size) {
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
- insn = rb_vm_insn_addr2insn((void *)body->iseq_encoded[pos]);
-#else
- insn = (int)body->iseq_encoded[pos];
-#endif
- if (insn == BIN(throw)) {
- set_catch_except_p(body);
- break;
- }
- pos += insn_len(insn);
- }
-
- if (ct == NULL)
- return;
-
- for (i = 0; i < ct->size; i++) {
- const struct iseq_catch_table_entry *entry =
- UNALIGNED_MEMBER_PTR(ct, entries[i]);
- if (entry->type != CATCH_TYPE_BREAK
- && entry->type != CATCH_TYPE_NEXT
- && entry->type != CATCH_TYPE_REDO) {
- body->catch_except_p = TRUE;
- break;
- }
- }
-}
-
-static void
iseq_insert_nop_between_end_and_cont(rb_iseq_t *iseq)
{
VALUE catch_table_ary = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
- if (NIL_P(catch_table_ary)) return;
unsigned int i, tlen = (unsigned int)RARRAY_LEN(catch_table_ary);
- const VALUE *tptr = RARRAY_CONST_PTR_TRANSIENT(catch_table_ary);
+ const VALUE *tptr = RARRAY_CONST_PTR(catch_table_ary);
for (i = 0; i < tlen; i++) {
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(tptr[i]);
+ const VALUE *ptr = RARRAY_CONST_PTR(tptr[i]);
LINK_ELEMENT *end = (LINK_ELEMENT *)(ptr[2] & ~1);
LINK_ELEMENT *cont = (LINK_ELEMENT *)(ptr[4] & ~1);
LINK_ELEMENT *e;
@@ -1361,7 +1304,7 @@ static int
iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
{
if (RTEST(ISEQ_COMPILE_DATA(iseq)->err_info))
- return COMPILE_NG;
+ return COMPILE_NG;
debugs("[compile step 4.1 (iseq_set_sequence)]\n");
if (!iseq_set_sequence(iseq, anchor)) return COMPILE_NG;
@@ -1377,13 +1320,10 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
debugs("[compile step 5 (iseq_translate_threaded_code)] \n");
if (!rb_iseq_translate_threaded_code(iseq)) return COMPILE_NG;
- update_catch_except_flags(iseq->body);
-
if (compile_debug > 1) {
VALUE str = rb_iseq_disasm(iseq);
printf("%s\n", StringValueCStr(str));
}
- verify_call_cache(iseq);
debugs("[compile step: finish]\n");
return COMPILE_OK;
@@ -1392,8 +1332,16 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
static int
iseq_set_exception_local_table(rb_iseq_t *iseq)
{
- iseq->body->local_table_size = numberof(rb_iseq_shared_exc_local_tbl);
- iseq->body->local_table = rb_iseq_shared_exc_local_tbl;
+ /* TODO: every id table is same -> share it.
+ * Current problem is iseq_free().
+ */
+ ID id_dollar_bang;
+ ID *ids = (ID *)ALLOC_N(ID, 1);
+
+ CONST_ID(id_dollar_bang, "#$!");
+ iseq->body->local_table_size = 1;
+ ids[0] = id_dollar_bang;
+ iseq->body->local_table = ids;
return COMPILE_OK;
}
@@ -1427,8 +1375,7 @@ get_local_var_idx(const rb_iseq_t *iseq, ID id)
int idx = get_dyna_var_idx_at_raw(iseq->body->local_iseq, id);
if (idx < 0) {
- COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq),
- "get_local_var_idx: %d", idx);
+ rb_bug("get_local_var_idx: %d", idx);
}
return idx;
@@ -1438,7 +1385,6 @@ static int
get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
{
int lv = 0, idx = -1;
- const rb_iseq_t *const topmost_iseq = iseq;
while (iseq) {
idx = get_dyna_var_idx_at_raw(iseq, id);
@@ -1450,8 +1396,7 @@ get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
}
if (idx < 0) {
- COMPILE_ERROR(topmost_iseq, ISEQ_LAST_LINE(topmost_iseq),
- "get_dyna_var_idx: -1");
+ rb_bug("get_dyna_var_idx: -1");
}
*level = lv;
@@ -1462,30 +1407,13 @@ get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
static int
iseq_local_block_param_p(const rb_iseq_t *iseq, unsigned int idx, unsigned int level)
{
- const struct rb_iseq_constant_body *body;
while (level > 0) {
iseq = iseq->body->parent_iseq;
level--;
}
- body = iseq->body;
- if (body->local_iseq == iseq && /* local variables */
- body->param.flags.has_block &&
- body->local_table_size - body->param.block_start == idx) {
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-static int
-iseq_block_param_id_p(const rb_iseq_t *iseq, ID id, int *pidx, int *plevel)
-{
- int level, ls;
- int idx = get_dyna_var_idx(iseq, id, &level, &ls);
- if (iseq_local_block_param_p(iseq, ls - idx, level)) {
- *pidx = ls - idx;
- *plevel = level;
+ if (iseq->body->local_iseq == iseq && /* local variables */
+ iseq->body->param.flags.has_block &&
+ iseq->body->local_table_size - iseq->body->param.block_start == idx) {
return TRUE;
}
else {
@@ -1520,74 +1448,66 @@ iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line, int idx, in
static void
iseq_calc_param_size(rb_iseq_t *iseq)
{
- struct rb_iseq_constant_body *const body = iseq->body;
- if (body->param.flags.has_opt ||
- body->param.flags.has_post ||
- body->param.flags.has_rest ||
- body->param.flags.has_block ||
- body->param.flags.has_kw ||
- body->param.flags.has_kwrest) {
+ if (iseq->body->param.flags.has_opt ||
+ iseq->body->param.flags.has_post ||
+ iseq->body->param.flags.has_rest ||
+ iseq->body->param.flags.has_block ||
+ iseq->body->param.flags.has_kw ||
+ iseq->body->param.flags.has_kwrest) {
- if (body->param.flags.has_block) {
- body->param.size = body->param.block_start + 1;
+ if (iseq->body->param.flags.has_block) {
+ iseq->body->param.size = iseq->body->param.block_start + 1;
}
- else if (body->param.flags.has_kwrest) {
- body->param.size = body->param.keyword->rest_start + 1;
+ else if (iseq->body->param.flags.has_kwrest) {
+ iseq->body->param.size = iseq->body->param.keyword->rest_start + 1;
}
- else if (body->param.flags.has_kw) {
- body->param.size = body->param.keyword->bits_start + 1;
+ else if (iseq->body->param.flags.has_kw) {
+ iseq->body->param.size = iseq->body->param.keyword->bits_start + 1;
}
- else if (body->param.flags.has_post) {
- body->param.size = body->param.post_start + body->param.post_num;
+ else if (iseq->body->param.flags.has_post) {
+ iseq->body->param.size = iseq->body->param.post_start + iseq->body->param.post_num;
}
- else if (body->param.flags.has_rest) {
- body->param.size = body->param.rest_start + 1;
+ else if (iseq->body->param.flags.has_rest) {
+ iseq->body->param.size = iseq->body->param.rest_start + 1;
}
- else if (body->param.flags.has_opt) {
- body->param.size = body->param.lead_num + body->param.opt_num;
+ else if (iseq->body->param.flags.has_opt) {
+ iseq->body->param.size = iseq->body->param.lead_num + iseq->body->param.opt_num;
}
else {
- UNREACHABLE;
+ rb_bug("unreachable");
}
}
else {
- body->param.size = body->param.lead_num;
+ iseq->body->param.size = iseq->body->param.lead_num;
}
}
-static int
+static void
iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
- const struct rb_args_info *args, int arg_size)
+ const struct rb_args_info *args)
{
const NODE *node = args->kw_args;
- struct rb_iseq_constant_body *const body = iseq->body;
struct rb_iseq_param_keyword *keyword;
const VALUE default_values = rb_ary_tmp_new(1);
const VALUE complex_mark = rb_str_tmp_new(0);
int kw = 0, rkw = 0, di = 0, i;
- body->param.flags.has_kw = TRUE;
- body->param.keyword = keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
-
- while (node) {
- kw++;
- node = node->nd_next;
- }
- arg_size += kw;
- keyword->bits_start = arg_size++;
+ iseq->body->param.flags.has_kw = TRUE;
+ iseq->body->param.keyword = keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
+ keyword->bits_start = get_dyna_var_idx_at_raw(iseq, args->kw_rest_arg->nd_cflag);
- node = args->kw_args;
while (node) {
const NODE *val_node = node->nd_body->nd_value;
VALUE dv;
- if (val_node == NODE_SPECIAL_REQUIRED_KEYWORD) {
+ if (val_node == (const NODE *)-1) {
++rkw;
}
else {
switch (nd_type(val_node)) {
case NODE_LIT:
dv = val_node->nd_lit;
+ iseq_add_mark_object(iseq, dv);
break;
case NODE_NIL:
dv = Qnil;
@@ -1599,7 +1519,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
dv = Qfalse;
break;
default:
- NO_CHECK(COMPILE_POPPED(optargs, "kwarg", node)); /* nd_type(node) == NODE_KW_ARG */
+ COMPILE_POPPED(optargs, "kwarg", node); /* nd_type(node) == NODE_KW_ARG */
dv = complex_mark;
}
@@ -1607,17 +1527,18 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
rb_ary_push(default_values, dv);
}
+ kw++;
node = node->nd_next;
}
keyword->num = kw;
if (args->kw_rest_arg->nd_vid != 0) {
- keyword->rest_start = arg_size++;
- body->param.flags.has_kwrest = TRUE;
+ keyword->rest_start = get_dyna_var_idx_at_raw(iseq, args->kw_rest_arg->nd_vid);
+ iseq->body->param.flags.has_kwrest = TRUE;
}
keyword->required_num = rkw;
- keyword->table = &body->local_table[keyword->bits_start - keyword->num];
+ keyword->table = &iseq->body->local_table[keyword->bits_start - keyword->num];
{
VALUE *dvs = ALLOC_N(VALUE, RARRAY_LEN(default_values));
@@ -1625,15 +1546,11 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
for (i = 0; i < RARRAY_LEN(default_values); i++) {
VALUE dv = RARRAY_AREF(default_values, i);
if (dv == complex_mark) dv = Qundef;
- if (!SPECIAL_CONST_P(dv)) {
- RB_OBJ_WRITTEN(iseq, Qundef, dv);
- }
dvs[i] = dv;
}
keyword->default_values = dvs;
}
- return arg_size;
}
static int
@@ -1642,27 +1559,30 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
debugs("iseq_set_arguments: %s\n", node_args ? "" : "0");
if (node_args) {
- struct rb_iseq_constant_body *const body = iseq->body;
struct rb_args_info *args = node_args->nd_ainfo;
ID rest_id = 0;
int last_comma = 0;
ID block_id = 0;
- int arg_size;
EXPECT_NODE("iseq_set_arguments", node_args, NODE_ARGS, COMPILE_NG);
- body->param.flags.ruby2_keywords = args->ruby2_keywords;
- body->param.lead_num = arg_size = (int)args->pre_args_num;
- if (body->param.lead_num > 0) body->param.flags.has_lead = TRUE;
- debugs(" - argc: %d\n", body->param.lead_num);
+ iseq->body->param.lead_num = (int)args->pre_args_num;
+ if (iseq->body->param.lead_num > 0) iseq->body->param.flags.has_lead = TRUE;
+ debugs(" - argc: %d\n", iseq->body->param.lead_num);
rest_id = args->rest_arg;
- if (rest_id == NODE_SPECIAL_EXCESSIVE_COMMA) {
+ if (rest_id == 1) {
last_comma = 1;
rest_id = 0;
}
block_id = args->block_arg;
+ if (args->first_post_arg) {
+ iseq->body->param.post_start = get_dyna_var_idx_at_raw(iseq, args->first_post_arg);
+ iseq->body->param.post_num = args->post_args_num;
+ iseq->body->param.flags.has_post = TRUE;
+ }
+
if (args->opt_args) {
const NODE *node = args->opt_args;
LABEL *label;
@@ -1674,7 +1594,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
label = NEW_LABEL(nd_line(node));
rb_ary_push(labels, (VALUE)label | 1);
ADD_LABEL(optargs, label);
- NO_CHECK(COMPILE_POPPED(optargs, "optarg", node->nd_body));
+ COMPILE_POPPED(optargs, "optarg", node->nd_body);
node = node->nd_next;
i += 1;
}
@@ -1686,73 +1606,61 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
opt_table = ALLOC_N(VALUE, i+1);
- MEMCPY(opt_table, RARRAY_CONST_PTR_TRANSIENT(labels), VALUE, i+1);
+ MEMCPY(opt_table, RARRAY_CONST_PTR(labels), VALUE, i+1);
for (j = 0; j < i+1; j++) {
opt_table[j] &= ~1;
}
rb_ary_clear(labels);
- body->param.flags.has_opt = TRUE;
- body->param.opt_num = i;
- body->param.opt_table = opt_table;
- arg_size += i;
- }
-
- if (rest_id) {
- body->param.rest_start = arg_size++;
- body->param.flags.has_rest = TRUE;
- assert(body->param.rest_start != -1);
- }
-
- if (args->first_post_arg) {
- body->param.post_start = arg_size;
- body->param.post_num = args->post_args_num;
- body->param.flags.has_post = TRUE;
- arg_size += args->post_args_num;
-
- if (body->param.flags.has_rest) { /* TODO: why that? */
- body->param.post_start = body->param.rest_start + 1;
- }
+ iseq->body->param.flags.has_opt = TRUE;
+ iseq->body->param.opt_num = i;
+ iseq->body->param.opt_table = opt_table;
}
if (args->kw_args) {
- arg_size = iseq_set_arguments_keywords(iseq, optargs, args, arg_size);
+ iseq_set_arguments_keywords(iseq, optargs, args);
}
else if (args->kw_rest_arg) {
struct rb_iseq_param_keyword *keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
- keyword->rest_start = arg_size++;
- body->param.keyword = keyword;
- body->param.flags.has_kwrest = TRUE;
- }
- else if (args->no_kwarg) {
- body->param.flags.accepts_no_kwarg = TRUE;
+ keyword->rest_start = get_dyna_var_idx_at_raw(iseq, args->kw_rest_arg->nd_vid);
+ iseq->body->param.keyword = keyword;
+ iseq->body->param.flags.has_kwrest = TRUE;
}
- if (block_id) {
- body->param.block_start = arg_size++;
- body->param.flags.has_block = TRUE;
+ if (args->pre_init) { /* m_init */
+ COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init);
+ }
+ if (args->post_init) { /* p_init */
+ COMPILE_POPPED(optargs, "init arguments (p)", args->post_init);
}
- iseq_calc_param_size(iseq);
- body->param.size = arg_size;
+ if (rest_id) {
+ iseq->body->param.rest_start = get_dyna_var_idx_at_raw(iseq, rest_id);
+ iseq->body->param.flags.has_rest = TRUE;
+ assert(iseq->body->param.rest_start != -1);
- if (args->pre_init) { /* m_init */
- NO_CHECK(COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init));
+ if (iseq->body->param.post_start == 0) { /* TODO: why that? */
+ iseq->body->param.post_start = iseq->body->param.rest_start + 1;
+ }
}
- if (args->post_init) { /* p_init */
- NO_CHECK(COMPILE_POPPED(optargs, "init arguments (p)", args->post_init));
+
+ if (block_id) {
+ iseq->body->param.block_start = get_dyna_var_idx_at_raw(iseq, block_id);
+ iseq->body->param.flags.has_block = TRUE;
}
- if (body->type == ISEQ_TYPE_BLOCK) {
- if (body->param.flags.has_opt == FALSE &&
- body->param.flags.has_post == FALSE &&
- body->param.flags.has_rest == FALSE &&
- body->param.flags.has_kw == FALSE &&
- body->param.flags.has_kwrest == FALSE) {
+ iseq_calc_param_size(iseq);
- if (body->param.lead_num == 1 && last_comma == 0) {
+ if (iseq->body->type == ISEQ_TYPE_BLOCK) {
+ if (iseq->body->param.flags.has_opt == FALSE &&
+ iseq->body->param.flags.has_post == FALSE &&
+ iseq->body->param.flags.has_rest == FALSE &&
+ iseq->body->param.flags.has_kw == FALSE &&
+ iseq->body->param.flags.has_kwrest == FALSE) {
+
+ if (iseq->body->param.lead_num == 1 && last_comma == 0) {
/* {|a|} */
- body->param.flags.ambiguous_param0 = TRUE;
+ iseq->body->param.flags.ambiguous_param0 = TRUE;
}
}
}
@@ -1788,57 +1696,27 @@ iseq_set_local_table(rb_iseq_t *iseq, const ID *tbl)
static int
cdhash_cmp(VALUE val, VALUE lit)
{
- int tval, tlit;
-
- if (val == lit) {
- return 0;
+ if (val == lit) return 0;
+ if (SPECIAL_CONST_P(lit)) {
+ return val != lit;
}
- else if ((tlit = OBJ_BUILTIN_TYPE(lit)) == -1) {
- return val != lit;
+ if (SPECIAL_CONST_P(val) || BUILTIN_TYPE(val) != BUILTIN_TYPE(lit)) {
+ return -1;
}
- else if ((tval = OBJ_BUILTIN_TYPE(val)) == -1) {
- return -1;
- }
- else if (tlit != tval) {
- return -1;
- }
- else if (tlit == T_SYMBOL) {
- return val != lit;
- }
- else if (tlit == T_STRING) {
- return rb_str_hash_cmp(lit, val);
- }
- else if (tlit == T_BIGNUM) {
- long x = FIX2LONG(rb_big_cmp(lit, val));
-
- /* Given lit and val are both Bignum, x must be -1, 0, 1.
- * There is no need to call rb_fix2int here. */
- RUBY_ASSERT((x == 1) || (x == 0) || (x == -1));
- return (int)x;
- }
- else if (tlit == T_FLOAT) {
- return rb_float_cmp(lit, val);
- }
- else {
- UNREACHABLE_RETURN(-1);
+ if (BUILTIN_TYPE(lit) == T_STRING) {
+ return rb_str_hash_cmp(lit, val);
}
+ return !rb_eql(lit, val);
}
static st_index_t
cdhash_hash(VALUE a)
{
- switch (OBJ_BUILTIN_TYPE(a)) {
- case -1:
- case T_SYMBOL:
- return (st_index_t)a;
- case T_STRING:
- return rb_str_hash(a);
- case T_BIGNUM:
- return FIX2LONG(rb_big_hash(a));
- case T_FLOAT:
- return rb_dbl_long_hash(RFLOAT_VALUE(a));
- default:
- UNREACHABLE_RETURN(0);
+ if (SPECIAL_CONST_P(a)) return (st_index_t)a;
+ if (RB_TYPE_P(a, T_STRING)) return rb_str_hash(a);
+ {
+ VALUE hval = rb_hash(a);
+ return (st_index_t)FIX2LONG(hval);
}
}
@@ -1854,7 +1732,7 @@ struct cdhash_set_label_struct {
};
static int
-cdhash_set_label_i(VALUE key, VALUE val, VALUE ptr)
+cdhash_set_label_i(VALUE key, VALUE val, void *ptr)
{
struct cdhash_set_label_struct *data = (struct cdhash_set_label_struct *)ptr;
LABEL *lobj = (LABEL *)(val & ~1);
@@ -1883,7 +1761,7 @@ get_ivar_ic_value(rb_iseq_t *iseq,ID id)
}
#define BADINSN_DUMP(anchor, list, dest) \
- dump_disasm_list_with_cursor(FIRST_ELEMENT(anchor), list, dest)
+ dump_disasm_list_with_cursor(&anchor->anchor, list, dest)
#define BADINSN_ERROR \
(xfree(generated_iseq), \
@@ -2000,32 +1878,38 @@ fix_sp_depth(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
}
static int
-add_insn_info(struct iseq_insn_info_entry *insns_info, unsigned int *positions,
- int insns_info_index, int code_index, const INSN *iobj)
+add_insn_info(struct iseq_insn_info_entry *insns_info, int insns_info_index, int code_index, LINK_ELEMENT *list)
{
- if (insns_info_index == 0 ||
- insns_info[insns_info_index-1].line_no != iobj->insn_info.line_no ||
- insns_info[insns_info_index-1].events != iobj->insn_info.events) {
- insns_info[insns_info_index].line_no = iobj->insn_info.line_no;
- insns_info[insns_info_index].events = iobj->insn_info.events;
- positions[insns_info_index] = code_index;
- return TRUE;
+ if (list->type == ISEQ_ELEMENT_INSN) {
+ INSN *iobj = (INSN *)list;
+ if (insns_info_index == 0 ||
+ insns_info[insns_info_index-1].line_no != iobj->insn_info.line_no ||
+ insns_info[insns_info_index-1].events != iobj->insn_info.events) {
+ insns_info[insns_info_index].position = code_index;
+ insns_info[insns_info_index].line_no = iobj->insn_info.line_no;
+ insns_info[insns_info_index].events = iobj->insn_info.events;
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
}
- return FALSE;
-}
-
-static int
-add_adjust_info(struct iseq_insn_info_entry *insns_info, unsigned int *positions,
- int insns_info_index, int code_index, const ADJUST *adjust)
-{
- if (insns_info_index > 0 ||
- insns_info[insns_info_index-1].line_no != adjust->line_no) {
- insns_info[insns_info_index].line_no = adjust->line_no;
- insns_info[insns_info_index].events = 0;
- positions[insns_info_index] = code_index;
- return TRUE;
+ else if (list->type == ISEQ_ELEMENT_ADJUST) {
+ ADJUST *adjust = (ADJUST *)list;
+ if (insns_info_index > 0 ||
+ insns_info[insns_info_index-1].line_no != adjust->line_no) {
+ insns_info[insns_info_index].position = code_index;
+ insns_info[insns_info_index].line_no = adjust->line_no;
+ insns_info[insns_info_index].events = 0;
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ VM_UNREACHABLE(add_insn_info);
}
- return FALSE;
}
/**
@@ -2035,12 +1919,9 @@ static int
iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
{
struct iseq_insn_info_entry *insns_info;
- struct rb_iseq_constant_body *const body = iseq->body;
- unsigned int *positions;
LINK_ELEMENT *list;
VALUE *generated_iseq;
rb_event_flag_t events = 0;
- long data = 0;
int insn_num, code_index, insns_info_index, sp = 0;
int stack_max = fix_sp_depth(iseq, anchor);
@@ -2048,34 +1929,19 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
if (stack_max < 0) return COMPILE_NG;
/* fix label position */
+ list = FIRST_ELEMENT(anchor);
insn_num = code_index = 0;
- for (list = FIRST_ELEMENT(anchor); list; list = list->next) {
+ while (list) {
switch (list->type) {
case ISEQ_ELEMENT_INSN:
{
INSN *iobj = (INSN *)list;
/* update sp */
sp = calc_sp_depth(sp, iobj);
+ code_index += insn_data_length(iobj);
insn_num++;
- events = iobj->insn_info.events |= events;
- if (ISEQ_COVERAGE(iseq)) {
- if (ISEQ_LINE_COVERAGE(iseq) && (events & RUBY_EVENT_COVERAGE_LINE) &&
- !(rb_get_coverage_mode() & COVERAGE_TARGET_ONESHOT_LINES)) {
- int line = iobj->insn_info.line_no;
- if (line >= 1) {
- RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), line - 1, INT2FIX(0));
- }
- }
- if (ISEQ_BRANCH_COVERAGE(iseq) && (events & RUBY_EVENT_COVERAGE_BRANCH)) {
- while (RARRAY_LEN(ISEQ_PC2BRANCHINDEX(iseq)) <= code_index) {
- rb_ary_push(ISEQ_PC2BRANCHINDEX(iseq), Qnil);
- }
- RARRAY_ASET(ISEQ_PC2BRANCHINDEX(iseq), code_index, INT2FIX(data));
- }
- }
- code_index += insn_data_length(iobj);
+ iobj->insn_info.events |= events;
events = 0;
- data = 0;
break;
}
case ISEQ_ELEMENT_LABEL:
@@ -2089,7 +1955,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
{
TRACE *trace = (TRACE *)list;
events |= trace->event;
- if (trace->event & RUBY_EVENT_COVERAGE_BRANCH) data = trace->data;
break;
}
case ISEQ_ELEMENT_ADJUST:
@@ -2106,19 +1971,19 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
}
break;
}
- default: break;
}
+ list = list->next;
}
/* make instruction sequence */
generated_iseq = ALLOC_N(VALUE, code_index);
insns_info = ALLOC_N(struct iseq_insn_info_entry, insn_num);
- positions = ALLOC_N(unsigned int, insn_num);
- body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, body->is_size);
- body->call_data =
- rb_xcalloc_mul_add_mul(
- sizeof(struct rb_call_data), body->ci_size,
- sizeof(struct rb_kwarg_call_data), body->ci_kw_size);
+ iseq->body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, iseq->body->is_size);
+ iseq->body->ci_entries = (struct rb_call_info *)ruby_xmalloc(sizeof(struct rb_call_info) * iseq->body->ci_size +
+ sizeof(struct rb_call_info_with_kwarg) * iseq->body->ci_kw_size);
+ MEMZERO(iseq->body->ci_entries + iseq->body->ci_size, struct rb_call_info_with_kwarg, iseq->body->ci_kw_size); /* need to clear ci_kw entries */
+ iseq->body->cc_entries = ZALLOC_N(struct rb_call_cache, iseq->body->ci_size + iseq->body->ci_kw_size);
+
ISEQ_COMPILE_DATA(iseq)->ci_index = ISEQ_COMPILE_DATA(iseq)->ci_kw_index = 0;
list = FIRST_ELEMENT(anchor);
@@ -2165,65 +2030,63 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
rb_hash_rehash(map);
freeze_hide_obj(map);
generated_iseq[code_index + 1 + j] = map;
- RB_OBJ_WRITTEN(iseq, Qundef, map);
- FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
break;
}
case TS_LINDEX:
case TS_NUM: /* ulong */
generated_iseq[code_index + 1 + j] = FIX2INT(operands[j]);
break;
- case TS_VALUE: /* VALUE */
case TS_ISEQ: /* iseq */
{
VALUE v = operands[j];
generated_iseq[code_index + 1 + j] = v;
+ break;
+ }
+ case TS_VALUE: /* VALUE */
+ {
+ VALUE v = operands[j];
+ generated_iseq[code_index + 1 + j] = v;
/* to mark ruby object */
- if (!SPECIAL_CONST_P(v)) {
- RB_OBJ_WRITTEN(iseq, Qundef, v);
- FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
- }
+ iseq_add_mark_object(iseq, v);
break;
}
- case TS_ISE: /* inline storage entry */
- /* Treated as an IC, but may contain a markable VALUE */
- FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
- /* fall through */
case TS_IC: /* inline cache */
- case TS_IVC: /* inline ivar cache */
{
unsigned int ic_index = FIX2UINT(operands[j]);
- IC ic = (IC)&body->is_entries[ic_index];
- if (UNLIKELY(ic_index >= body->is_size)) {
- BADINSN_DUMP(anchor, &iobj->link, 0);
- COMPILE_ERROR(iseq, iobj->insn_info.line_no,
- "iseq_set_sequence: ic_index overflow: index: %d, size: %d",
- ic_index, body->is_size);
+ IC ic = (IC)&iseq->body->is_entries[ic_index];
+ if (UNLIKELY(ic_index >= iseq->body->is_size)) {
+ rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size);
}
generated_iseq[code_index + 1 + j] = (VALUE)ic;
break;
}
- case TS_CALLDATA:
- {
- struct rb_call_info *source_ci = (struct rb_call_info *)operands[j];
- struct rb_call_data *cd;
-
- if (source_ci->flag & VM_CALL_KWARG) {
- struct rb_kwarg_call_data *kw_calls = (struct rb_kwarg_call_data *)&body->call_data[body->ci_size];
- struct rb_kwarg_call_data *cd_kw = &kw_calls[ISEQ_COMPILE_DATA(iseq)->ci_kw_index++];
- cd_kw->ci_kw = *((struct rb_call_info_with_kwarg *)source_ci);
- cd = (struct rb_call_data *)cd_kw;
- assert(ISEQ_COMPILE_DATA(iseq)->ci_kw_index <= body->ci_kw_size);
- }
- else {
- cd = &body->call_data[ISEQ_COMPILE_DATA(iseq)->ci_index++];
- cd->ci = *source_ci;
- assert(ISEQ_COMPILE_DATA(iseq)->ci_index <= body->ci_size);
- }
-
- generated_iseq[code_index + 1 + j] = (VALUE)cd;
- break;
- }
+ case TS_CALLINFO: /* call info */
+ {
+ struct rb_call_info *base_ci = (struct rb_call_info *)operands[j];
+ struct rb_call_info *ci;
+
+ if (base_ci->flag & VM_CALL_KWARG) {
+ struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&iseq->body->ci_entries[iseq->body->ci_size];
+ struct rb_call_info_with_kwarg *ci_kw = &ci_kw_entries[ISEQ_COMPILE_DATA(iseq)->ci_kw_index++];
+ *ci_kw = *((struct rb_call_info_with_kwarg *)base_ci);
+ ci = (struct rb_call_info *)ci_kw;
+ assert(ISEQ_COMPILE_DATA(iseq)->ci_kw_index <= iseq->body->ci_kw_size);
+ }
+ else {
+ ci = &iseq->body->ci_entries[ISEQ_COMPILE_DATA(iseq)->ci_index++];
+ *ci = *base_ci;
+ assert(ISEQ_COMPILE_DATA(iseq)->ci_index <= iseq->body->ci_size);
+ }
+
+ generated_iseq[code_index + 1 + j] = (VALUE)ci;
+ break;
+ }
+ case TS_CALLCACHE:
+ {
+ struct rb_call_cache *cc = &iseq->body->cc_entries[ISEQ_COMPILE_DATA(iseq)->ci_index + ISEQ_COMPILE_DATA(iseq)->ci_kw_index - 1];
+ generated_iseq[code_index + 1 + j] = (VALUE)cc;
+ break;
+ }
case TS_ID: /* ID */
generated_iseq[code_index + 1 + j] = SYM2ID(operands[j]);
break;
@@ -2237,16 +2100,13 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
case TS_FUNCPTR:
generated_iseq[code_index + 1 + j] = operands[j];
break;
- case TS_BUILTIN:
- generated_iseq[code_index + 1 + j] = operands[j];
- break;
default:
BADINSN_ERROR(iseq, iobj->insn_info.line_no,
"unknown operand type: %c", type);
return COMPILE_NG;
}
}
- if (add_insn_info(insns_info, positions, insns_info_index, code_index, iobj)) insns_info_index++;
+ if (add_insn_info(insns_info, insns_info_index, code_index, (LINK_ELEMENT *)iobj)) insns_info_index++;
code_index += len;
break;
}
@@ -2271,7 +2131,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
if (adjust->line_no != -1) {
const int diff = orig_sp - sp;
if (diff > 0) {
- if (add_adjust_info(insns_info, positions, insns_info_index, code_index, adjust)) insns_info_index++;
+ if (add_insn_info(insns_info, insns_info_index, code_index, (LINK_ELEMENT *)adjust)) insns_info_index++;
}
if (diff > 1) {
generated_iseq[code_index++] = BIN(adjuststack);
@@ -2284,7 +2144,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
int label_no = adjust->label ? adjust->label->label_no : -1;
xfree(generated_iseq);
xfree(insns_info);
- xfree(positions);
debug_list(anchor);
COMPILE_ERROR(iseq, adjust->line_no,
"iseq_set_sequence: adjust bug to %d %d < %d",
@@ -2301,19 +2160,16 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
list = list->next;
}
- body->iseq_encoded = (void *)generated_iseq;
- body->iseq_size = code_index;
- body->stack_max = stack_max;
+ iseq->body->iseq_encoded = (void *)generated_iseq;
+ iseq->body->iseq_size = code_index;
+ iseq->body->stack_max = stack_max;
/* get rid of memory leak when REALLOC failed */
- body->insns_info.body = insns_info;
- body->insns_info.positions = positions;
+ iseq->body->insns_info = insns_info;
REALLOC_N(insns_info, struct iseq_insn_info_entry, insns_info_index);
- body->insns_info.body = insns_info;
- REALLOC_N(positions, unsigned int, insns_info_index);
- body->insns_info.positions = positions;
- body->insns_info.size = insns_info_index;
+ iseq->body->insns_info = insns_info;
+ iseq->body->insns_info_size = insns_info_index;
return COMPILE_OK;
}
@@ -2337,22 +2193,25 @@ iseq_set_exception_table(rb_iseq_t *iseq)
unsigned int tlen, i;
struct iseq_catch_table_entry *entry;
- if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) goto no_catch_table;
tlen = (int)RARRAY_LEN(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
- tptr = RARRAY_CONST_PTR_TRANSIENT(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
+ tptr = RARRAY_CONST_PTR(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
if (tlen > 0) {
struct iseq_catch_table *table = xmalloc(iseq_catch_table_bytes(tlen));
table->size = tlen;
for (i = 0; i < table->size; i++) {
- ptr = RARRAY_CONST_PTR_TRANSIENT(tptr[i]);
- entry = UNALIGNED_MEMBER_PTR(table, entries[i]);
+ ptr = RARRAY_CONST_PTR(tptr[i]);
+ entry = &table->entries[i];
entry->type = (enum catch_type)(ptr[0] & 0xffff);
entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
entry->iseq = (rb_iseq_t *)ptr[3];
- RB_OBJ_WRITTEN(iseq, Qundef, entry->iseq);
+
+ /* register iseq as mark object */
+ if (entry->iseq != 0) {
+ iseq_add_mark_object(iseq, (VALUE)entry->iseq);
+ }
/* stack depth */
if (ptr[4]) {
@@ -2375,8 +2234,7 @@ iseq_set_exception_table(rb_iseq_t *iseq)
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, 0); /* free */
}
else {
- no_catch_table:
- iseq->body->catch_table = NULL;
+ iseq->body->catch_table = NULL;
}
return COMPILE_OK;
@@ -2427,7 +2285,6 @@ get_destination_insn(INSN *iobj)
events |= trace->event;
}
break;
- default: break;
}
list = list->next;
}
@@ -2550,7 +2407,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
case TS_OFFSET:
unref_destination((INSN *)i, pos);
break;
- case TS_CALLDATA:
+ case TS_CALLINFO:
if (((struct rb_call_info *)OPERAND_AT(i, pos))->flag & VM_CALL_KWARG)
--(body->ci_kw_size);
else
@@ -2596,115 +2453,12 @@ same_debug_pos_p(LINK_ELEMENT *iobj1, LINK_ELEMENT *iobj2)
}
static int
-is_frozen_putstring(INSN *insn, VALUE *op)
-{
- if (IS_INSN_ID(insn, putstring)) {
- *op = OPERAND_AT(insn, 0);
- return 1;
- }
- else if (IS_INSN_ID(insn, putobject)) { /* frozen_string_literal */
- *op = OPERAND_AT(insn, 0);
- return RB_TYPE_P(*op, T_STRING);
- }
- return 0;
-}
-
-static int
-optimize_checktype(rb_iseq_t *iseq, INSN *iobj)
-{
- /*
- * putobject obj
- * dup
- * checktype T_XXX
- * branchif l1
- * l2:
- * ...
- * l1:
- *
- * => obj is a T_XXX
- *
- * putobject obj (T_XXX)
- * jump L1
- * L1:
- *
- * => obj is not a T_XXX
- *
- * putobject obj (T_XXX)
- * jump L2
- * L2:
- */
- int line;
- INSN *niobj, *ciobj, *dup = 0;
- LABEL *dest = 0;
- VALUE type;
-
- switch (INSN_OF(iobj)) {
- case BIN(putstring):
- type = INT2FIX(T_STRING);
- break;
- case BIN(putnil):
- type = INT2FIX(T_NIL);
- break;
- case BIN(putobject):
- type = INT2FIX(TYPE(OPERAND_AT(iobj, 0)));
- break;
- default: return FALSE;
- }
-
- ciobj = (INSN *)get_next_insn(iobj);
- if (IS_INSN_ID(ciobj, jump)) {
- ciobj = (INSN *)get_next_insn((INSN*)OPERAND_AT(ciobj, 0));
- }
- if (IS_INSN_ID(ciobj, dup)) {
- ciobj = (INSN *)get_next_insn(dup = ciobj);
- }
- if (!ciobj || !IS_INSN_ID(ciobj, checktype)) return FALSE;
- niobj = (INSN *)get_next_insn(ciobj);
- if (!niobj) {
- no_branch:
- /* TODO: putobject true/false */
- return FALSE;
- }
- switch (INSN_OF(niobj)) {
- case BIN(branchif):
- if (OPERAND_AT(ciobj, 0) == type) {
- dest = (LABEL *)OPERAND_AT(niobj, 0);
- }
- break;
- case BIN(branchunless):
- if (OPERAND_AT(ciobj, 0) != type) {
- dest = (LABEL *)OPERAND_AT(niobj, 0);
- }
- break;
- default:
- goto no_branch;
- }
- line = ciobj->insn_info.line_no;
- if (!dest) {
- if (niobj->link.next && IS_LABEL(niobj->link.next)) {
- dest = (LABEL *)niobj->link.next; /* reuse label */
- }
- else {
- dest = NEW_LABEL(line);
- ELEM_INSERT_NEXT(&niobj->link, &dest->link);
- }
- }
- INSERT_AFTER_INSN1(iobj, line, jump, dest);
- LABEL_REF(dest);
- if (!dup) INSERT_AFTER_INSN(iobj, line, pop);
- return TRUE;
-}
-
-static int
iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcallopt)
{
INSN *const iobj = (INSN *)list;
-
again:
- optimize_checktype(iseq, iobj);
-
if (IS_INSN_ID(iobj, jump)) {
- INSN *niobj, *diobj, *piobj;
+ INSN *niobj, *diobj, *piobj;
diobj = (INSN *)get_destination_insn(iobj);
niobj = (INSN *)get_next_insn(iobj);
@@ -2719,8 +2473,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
ELEM_REMOVE(&iobj->link);
return COMPILE_OK;
}
- else if (iobj != diobj && IS_INSN(&diobj->link) &&
- IS_INSN_ID(diobj, jump) &&
+ else if (iobj != diobj && IS_INSN_ID(diobj, jump) &&
OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) {
/*
* useless jump elimination:
@@ -2736,7 +2489,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
remove_unreachable_chunk(iseq, iobj->link.next);
goto again;
}
- else if (IS_INSN_ID(diobj, leave)) {
+ else if (IS_INSN_ID(diobj, leave)) {
+ INSN *pop;
/*
* jump LABEL
* ...
@@ -2744,18 +2498,22 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* leave
* =>
* leave
+ * pop
* ...
* LABEL:
* leave
*/
/* replace */
unref_destination(iobj, 0);
- iobj->insn_id = BIN(leave);
+ iobj->insn_id = BIN(leave);
iobj->operand_size = 0;
iobj->insn_info = diobj->insn_info;
+ /* adjust stack depth */
+ pop = new_insn_body(iseq, diobj->insn_info.line_no, BIN(pop), 0);
+ ELEM_INSERT_NEXT(&iobj->link, &pop->link);
goto again;
}
- else if (IS_INSN(iobj->link.prev) &&
+ else if (IS_INSN(iobj->link.prev) &&
(piobj = (INSN *)iobj->link.prev) &&
(IS_INSN_ID(piobj, branchif) ||
IS_INSN_ID(piobj, branchunless))) {
@@ -2822,23 +2580,24 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* putobject "beg".."end"
*/
if (IS_INSN_ID(iobj, checkmatch)) {
- INSN *range = (INSN *)get_prev_insn(iobj);
- INSN *beg, *end;
- VALUE str_beg, str_end;
+ INSN *range = (INSN *)get_prev_insn(iobj);
+ INSN *beg, *end;
if (range && IS_INSN_ID(range, newrange) &&
- (end = (INSN *)get_prev_insn(range)) != 0 &&
- is_frozen_putstring(end, &str_end) &&
- (beg = (INSN *)get_prev_insn(end)) != 0 &&
- is_frozen_putstring(beg, &str_beg)) {
+ (end = (INSN *)get_prev_insn(range)) != 0 &&
+ IS_INSN_ID(end, putstring) &&
+ (beg = (INSN *)get_prev_insn(end)) != 0 &&
+ IS_INSN_ID(beg, putstring)) {
+ VALUE str_beg = OPERAND_AT(beg, 0);
+ VALUE str_end = OPERAND_AT(end, 0);
int excl = FIX2INT(OPERAND_AT(range, 0));
VALUE lit_range = rb_range_new(str_beg, str_end, excl);
+ iseq_add_mark_object_compile_time(iseq, lit_range);
ELEM_REMOVE(&beg->link);
ELEM_REMOVE(&end->link);
range->insn_id = BIN(putobject);
OPERAND_AT(range, 0) = lit_range;
- RB_OBJ_WRITTEN(iseq, Qundef, lit_range);
}
}
@@ -2858,135 +2617,109 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* if L2
*/
INSN *nobj = (INSN *)get_destination_insn(iobj);
-
- /* This is super nasty hack!!!
- *
- * This jump-jump optimization may ignore event flags of the jump
- * instruction being skipped. Actually, Line 2 TracePoint event
- * is never fired in the following code:
- *
- * 1: raise if 1 == 2
- * 2: while true
- * 3: break
- * 4: end
- *
- * This is critical for coverage measurement. [Bug #15980]
- *
- * This is a stopgap measure: stop the jump-jump optimization if
- * coverage measurement is enabled and if the skipped instruction
- * has any event flag.
- *
- * Note that, still, TracePoint Line event does not occur on Line 2.
- * This should be fixed in future.
- */
- int stop_optimization =
- ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq) &&
- nobj->insn_info.events;
- if (!stop_optimization) {
- INSN *pobj = (INSN *)iobj->link.prev;
- int prev_dup = 0;
- if (pobj) {
- if (!IS_INSN(&pobj->link))
- pobj = 0;
- else if (IS_INSN_ID(pobj, dup))
- prev_dup = 1;
- }
-
- for (;;) {
- if (IS_INSN(&nobj->link) && IS_INSN_ID(nobj, jump)) {
- replace_destination(iobj, nobj);
- }
- else if (prev_dup && IS_INSN_ID(nobj, dup) &&
- !!(nobj = (INSN *)nobj->link.next) &&
- /* basic blocks, with no labels in the middle */
- nobj->insn_id == iobj->insn_id) {
- /*
- * dup
- * if L1
- * ...
- * L1:
- * dup
- * if L2
- * =>
- * dup
- * if L2
- * ...
- * L1:
- * dup
- * if L2
- */
- replace_destination(iobj, nobj);
- }
- else if (pobj) {
- /*
- * putnil
- * if L1
- * =>
- * # nothing
- *
- * putobject true
- * if L1
- * =>
- * jump L1
- *
- * putstring ".."
- * if L1
- * =>
- * jump L1
- *
- * putstring ".."
- * dup
- * if L1
- * =>
- * putstring ".."
- * jump L1
- *
- */
- int cond;
- if (prev_dup && IS_INSN(pobj->link.prev)) {
- pobj = (INSN *)pobj->link.prev;
- }
- if (IS_INSN_ID(pobj, putobject)) {
- cond = (IS_INSN_ID(iobj, branchif) ?
- OPERAND_AT(pobj, 0) != Qfalse :
- IS_INSN_ID(iobj, branchunless) ?
- OPERAND_AT(pobj, 0) == Qfalse :
- FALSE);
- }
- else if (IS_INSN_ID(pobj, putstring) ||
- IS_INSN_ID(pobj, duparray) ||
- IS_INSN_ID(pobj, newarray)) {
- cond = IS_INSN_ID(iobj, branchif);
- }
- else if (IS_INSN_ID(pobj, putnil)) {
- cond = !IS_INSN_ID(iobj, branchif);
- }
- else break;
- if (prev_dup || !IS_INSN_ID(pobj, newarray)) {
- ELEM_REMOVE(iobj->link.prev);
- }
- else if (!iseq_pop_newarray(iseq, pobj)) {
- pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(pop), 0, NULL);
- ELEM_INSERT_PREV(&iobj->link, &pobj->link);
- }
- if (cond) {
- if (prev_dup) {
- pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(putnil), 0, NULL);
- ELEM_INSERT_NEXT(&iobj->link, &pobj->link);
- }
- iobj->insn_id = BIN(jump);
- goto again;
- }
- else {
- unref_destination(iobj, 0);
- ELEM_REMOVE(&iobj->link);
- }
- break;
- }
- else break;
- nobj = (INSN *)get_destination_insn(nobj);
- }
- }
+ INSN *pobj = (INSN *)iobj->link.prev;
+ int prev_dup = 0;
+ if (pobj) {
+ if (!IS_INSN(&pobj->link))
+ pobj = 0;
+ else if (IS_INSN_ID(pobj, dup))
+ prev_dup = 1;
+ }
+
+ for (;;) {
+ if (IS_INSN_ID(nobj, jump)) {
+ replace_destination(iobj, nobj);
+ }
+ else if (prev_dup && IS_INSN_ID(nobj, dup) &&
+ !!(nobj = (INSN *)nobj->link.next) &&
+ /* basic blocks, with no labels in the middle */
+ nobj->insn_id == iobj->insn_id) {
+ /*
+ * dup
+ * if L1
+ * ...
+ * L1:
+ * dup
+ * if L2
+ * =>
+ * dup
+ * if L2
+ * ...
+ * L1:
+ * dup
+ * if L2
+ */
+ replace_destination(iobj, nobj);
+ }
+ else if (pobj) {
+ /*
+ * putnil
+ * if L1
+ * =>
+ * # nothing
+ *
+ * putobject true
+ * if L1
+ * =>
+ * jump L1
+ *
+ * putstring ".."
+ * if L1
+ * =>
+ * jump L1
+ *
+ * putstring ".."
+ * dup
+ * if L1
+ * =>
+ * putstring ".."
+ * jump L1
+ *
+ */
+ int cond;
+ if (prev_dup && IS_INSN(pobj->link.prev)) {
+ pobj = (INSN *)pobj->link.prev;
+ }
+ if (IS_INSN_ID(pobj, putobject)) {
+ cond = (IS_INSN_ID(iobj, branchif) ?
+ OPERAND_AT(pobj, 0) != Qfalse :
+ IS_INSN_ID(iobj, branchunless) ?
+ OPERAND_AT(pobj, 0) == Qfalse :
+ FALSE);
+ }
+ else if (IS_INSN_ID(pobj, putstring) ||
+ IS_INSN_ID(pobj, duparray) ||
+ IS_INSN_ID(pobj, newarray)) {
+ cond = IS_INSN_ID(iobj, branchif);
+ }
+ else if (IS_INSN_ID(pobj, putnil)) {
+ cond = !IS_INSN_ID(iobj, branchif);
+ }
+ else break;
+ if (prev_dup || !IS_INSN_ID(pobj, newarray)) {
+ ELEM_REMOVE(iobj->link.prev);
+ }
+ else if (!iseq_pop_newarray(iseq, pobj)) {
+ pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(pop), 0, NULL);
+ ELEM_INSERT_PREV(&iobj->link, &pobj->link);
+ }
+ if (cond) {
+ if (prev_dup) {
+ pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(putnil), 0, NULL);
+ ELEM_INSERT_NEXT(&iobj->link, &pobj->link);
+ }
+ iobj->insn_id = BIN(jump);
+ goto again;
+ }
+ else {
+ unref_destination(iobj, 0);
+ ELEM_REMOVE(&iobj->link);
+ }
+ break;
+ }
+ else break;
+ nobj = (INSN *)get_destination_insn(nobj);
+ }
}
if (IS_INSN_ID(iobj, pop)) {
@@ -3001,11 +2734,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
enum ruby_vminsn_type previ = ((INSN *)prev)->insn_id;
if (previ == BIN(putobject) || previ == BIN(putnil) ||
previ == BIN(putself) || previ == BIN(putstring) ||
- previ == BIN(dup) ||
- previ == BIN(getlocal) ||
- previ == BIN(getblockparam) ||
- previ == BIN(getblockparamproxy) ||
- /* getinstancevariable may issue a warning */
previ == BIN(duparray)) {
/* just push operand or static value and pop soon, no
* side effects */
@@ -3015,20 +2743,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
else if (previ == BIN(newarray) && iseq_pop_newarray(iseq, (INSN*)prev)) {
ELEM_REMOVE(&iobj->link);
}
- else if (previ == BIN(concatarray)) {
- INSN *piobj = (INSN *)prev;
- INSERT_BEFORE_INSN1(piobj, piobj->insn_info.line_no, splatarray, Qfalse);
- INSN_OF(piobj) = BIN(pop);
- }
- else if (previ == BIN(concatstrings)) {
- if (OPERAND_AT(prev, 0) == INT2FIX(1)) {
- ELEM_REMOVE(prev);
- }
- else {
- ELEM_REMOVE(&iobj->link);
- INSN_OF(prev) = BIN(adjuststack);
- }
- }
}
}
@@ -3128,25 +2842,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
- if (IS_INSN_ID(iobj, freezestring) &&
- NIL_P(OPERAND_AT(iobj, 0)) &&
- IS_NEXT_INSN_ID(&iobj->link, send)) {
- INSN *niobj = (INSN *)iobj->link.next;
- struct rb_call_info *ci = (struct rb_call_info *)OPERAND_AT(niobj, 0);
- /*
- * freezestring nil # no debug_info
- * send <:+@, 0, ARG_SIMPLE> # :-@, too
- * =>
- * send <:+@, 0, ARG_SIMPLE> # :-@, too
- */
- if ((ci->mid == idUPlus || ci->mid == idUMinus) &&
- (ci->flag & VM_CALL_ARGS_SIMPLE) &&
- ci->orig_argc == 0) {
- ELEM_REMOVE(list);
- return COMPILE_OK;
- }
- }
-
if (do_tailcallopt &&
(IS_INSN_ID(iobj, send) ||
IS_INSN_ID(iobj, opt_aref_with) ||
@@ -3180,7 +2875,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
break;
case BIN(leave):
piobj = iobj;
- /* fall through */
default:
next = NULL;
break;
@@ -3189,9 +2883,9 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
if (piobj) {
- struct rb_call_info *ci = (struct rb_call_info *)OPERAND_AT(piobj, 0);
+ struct rb_call_info *ci = (struct rb_call_info *)piobj->operands[0];
if (IS_INSN_ID(piobj, send) || IS_INSN_ID(piobj, invokesuper)) {
- if (OPERAND_AT(piobj, 1) == 0) { /* no blockiseq */
+ if (piobj->operands[2] == 0) { /* no blockiseq */
ci->flag |= VM_CALL_TAILCALL;
}
}
@@ -3239,14 +2933,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
- if (IS_INSN_ID(iobj, opt_invokebuiltin_delegate)) {
- if (IS_TRACE(iobj->link.next)) {
- if (IS_NEXT_INSN_ID(iobj->link.next, leave)) {
- iobj->insn_id = BIN(opt_invokebuiltin_delegate_leave);
- }
- }
- }
-
return COMPILE_OK;
}
@@ -3258,10 +2944,12 @@ insn_set_specialized_instruction(rb_iseq_t *iseq, INSN *iobj, int insn_id)
if (insn_id == BIN(opt_neq)) {
VALUE *old_operands = iobj->operands;
- iobj->operand_size = 2;
- iobj->operands = compile_data_alloc2(iseq, iobj->operand_size, sizeof(VALUE));
- iobj->operands[0] = (VALUE)new_callinfo(iseq, idEq, 1, 0, NULL, FALSE);
- iobj->operands[1] = old_operands[0];
+ iobj->operand_size = 4;
+ iobj->operands = (VALUE *)compile_data_alloc(iseq, iobj->operand_size * sizeof(VALUE));
+ iobj->operands[0] = old_operands[0];
+ iobj->operands[1] = Qfalse; /* CALL_CACHE */
+ iobj->operands[2] = (VALUE)new_callinfo(iseq, idEq, 1, 0, NULL, FALSE);
+ iobj->operands[3] = Qfalse; /* CALL_CACHE */
}
return COMPILE_OK;
@@ -3295,7 +2983,7 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
if (IS_INSN_ID(iobj, send)) {
struct rb_call_info *ci = (struct rb_call_info *)OPERAND_AT(iobj, 0);
- const rb_iseq_t *blockiseq = (rb_iseq_t *)OPERAND_AT(iobj, 1);
+ const rb_iseq_t *blockiseq = (rb_iseq_t *)OPERAND_AT(iobj, 2);
#define SP_INSN(opt) insn_set_specialized_instruction(iseq, iobj, BIN(opt_##opt))
if (ci->flag & VM_CALL_ARGS_SIMPLE) {
@@ -3305,7 +2993,6 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
case idLength: SP_INSN(length); return COMPILE_OK;
case idSize: SP_INSN(size); return COMPILE_OK;
case idEmptyP: SP_INSN(empty_p);return COMPILE_OK;
- case idNilP: SP_INSN(nil_p); return COMPILE_OK;
case idSucc: SP_INSN(succ); return COMPILE_OK;
case idNot: SP_INSN(not); return COMPILE_OK;
}
@@ -3319,15 +3006,12 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
case idMOD: SP_INSN(mod); return COMPILE_OK;
case idEq: SP_INSN(eq); return COMPILE_OK;
case idNeq: SP_INSN(neq); return COMPILE_OK;
- case idEqTilde:SP_INSN(regexpmatch2);return COMPILE_OK;
case idLT: SP_INSN(lt); return COMPILE_OK;
case idLE: SP_INSN(le); return COMPILE_OK;
case idGT: SP_INSN(gt); return COMPILE_OK;
case idGE: SP_INSN(ge); return COMPILE_OK;
case idLTLT: SP_INSN(ltlt); return COMPILE_OK;
case idAREF: SP_INSN(aref); return COMPILE_OK;
- case idAnd: SP_INSN(and); return COMPILE_OK;
- case idOr: SP_INSN(or); return COMPILE_OK;
}
break;
case 2:
@@ -3427,7 +3111,7 @@ new_unified_insn(rb_iseq_t *iseq,
if (argc > 0) {
ptr = operands =
- compile_data_alloc2(iseq, sizeof(VALUE), argc);
+ (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * argc);
}
/* copy operands */
@@ -3698,18 +3382,16 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons
rb_builtin_type_name(TYPE(lit)));
return COMPILE_NG;
}
- lit = rb_fstring(lit);
+ lit = freeze_literal(iseq, lit);
ADD_INSN1(ret, nd_line(node), putobject, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
if (RSTRING_LEN(lit) == 0) first_lit = LAST_ELEMENT(ret);
}
while (list) {
const NODE *const head = list->nd_head;
if (nd_type(head) == NODE_STR) {
- lit = rb_fstring(head->nd_lit);
+ lit = freeze_literal(iseq, head->nd_lit);
ADD_INSN1(ret, nd_line(head), putobject, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
lit = Qnil;
}
else {
@@ -3807,7 +3489,7 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
case NODE_LIT: /* NODE_LIT is always true */
case NODE_TRUE:
case NODE_STR:
- case NODE_ZLIST:
+ case NODE_ZARRAY:
case NODE_LAMBDA:
/* printf("useless condition eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
ADD_INSNL(ret, nd_line(cond), jump, then_label);
@@ -3817,13 +3499,6 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
/* printf("useless condition eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
ADD_INSNL(ret, nd_line(cond), jump, else_label);
break;
- case NODE_LIST:
- case NODE_ARGSCAT:
- case NODE_DREGX:
- case NODE_DSTR:
- CHECK(COMPILE_POPPED(ret, "branch condition", cond));
- ADD_INSNL(ret, nd_line(cond), jump, then_label);
- break;
case NODE_FLIP2:
CHECK(compile_flip_flop(iseq, ret, cond, TRUE, then_label, else_label));
break;
@@ -3844,35 +3519,28 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
}
static int
-keyword_node_p(const NODE *const node)
-{
- return nd_type(node) == NODE_HASH && node->nd_brace == FALSE;
-}
-
-static int
-compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
+compile_array_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *const root_node,
struct rb_call_info_kw_arg **const kw_arg_ptr,
unsigned int *flag)
{
if (kw_arg_ptr == NULL) return FALSE;
- if (keyword_node_p(root_node) && root_node->nd_head && nd_type(root_node->nd_head) == NODE_LIST) {
+ if (nd_type(root_node) == NODE_HASH && root_node->nd_head && nd_type(root_node->nd_head) == NODE_ARRAY) {
const NODE *node = root_node->nd_head;
while (node) {
const NODE *key_node = node->nd_head;
- assert(nd_type(node) == NODE_LIST);
+ assert(nd_type(node) == NODE_ARRAY);
if (!key_node) {
- if (flag) *flag |= VM_CALL_KW_SPLAT;
+ if (flag && !root_node->nd_alen) *flag |= VM_CALL_KW_SPLAT;
return FALSE;
}
else if (nd_type(key_node) == NODE_LIT && RB_TYPE_P(key_node->nd_lit, T_SYMBOL)) {
/* can be keywords */
}
else {
- if (flag) *flag |= VM_CALL_KW_SPLAT;
return FALSE;
}
node = node->nd_next; /* skip value node */
@@ -3883,8 +3551,7 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
node = root_node->nd_head;
{
int len = (int)node->nd_alen / 2;
- struct rb_call_info_kw_arg *kw_arg =
- rb_xmalloc_mul_add(len - 1, sizeof(VALUE), sizeof(struct rb_call_info_kw_arg));
+ struct rb_call_info_kw_arg *kw_arg = (struct rb_call_info_kw_arg *)ruby_xmalloc(sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (len - 1));
VALUE *keywords = kw_arg->keywords;
int i = 0;
kw_arg->keyword_len = len;
@@ -3895,7 +3562,7 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *key_node = node->nd_head;
const NODE *val_node = node->nd_next->nd_head;
keywords[i] = key_node->nd_lit;
- NO_CHECK(COMPILE(ret, "keyword values", val_node));
+ COMPILE(ret, "keyword values", val_node);
}
assert(i == len);
return TRUE;
@@ -3904,31 +3571,14 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
return FALSE;
}
-static int
-compile_args(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node,
- struct rb_call_info_kw_arg **keywords_ptr, unsigned int *flag)
-{
- int len = 0;
-
- for (; node; len++, node = node->nd_next) {
- if (CPDEBUG > 0) {
- EXPECT_NODE("compile_args", node, NODE_LIST, -1);
- }
-
- if (node->nd_next == NULL /* last node */ &&
- compile_keyword_arg(iseq, ret, node->nd_head, keywords_ptr, flag)) {
- len--;
- }
- else {
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, FALSE));
- }
- }
-
- return len;
-}
+enum compile_array_type_t {
+ COMPILE_ARRAY_TYPE_ARRAY,
+ COMPILE_ARRAY_TYPE_HASH,
+ COMPILE_ARRAY_TYPE_ARGS
+};
static inline int
-static_literal_node_p(const NODE *node, const rb_iseq_t *iseq)
+static_literal_node_p(const NODE *node)
{
node = node->nd_head;
switch (nd_type(node)) {
@@ -3937,15 +3587,13 @@ static_literal_node_p(const NODE *node, const rb_iseq_t *iseq)
case NODE_TRUE:
case NODE_FALSE:
return TRUE;
- case NODE_STR:
- return ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal;
default:
return FALSE;
}
}
static inline VALUE
-static_literal_value(const NODE *node, rb_iseq_t *iseq)
+static_literal_value(const NODE *node)
{
node = node->nd_head;
switch (nd_type(node)) {
@@ -3955,333 +3603,193 @@ static_literal_value(const NODE *node, rb_iseq_t *iseq)
return Qtrue;
case NODE_FALSE:
return Qfalse;
- case NODE_STR:
- if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
- VALUE lit;
- VALUE debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX((int)nd_line(node)));
- lit = rb_str_dup(node->nd_lit);
- rb_ivar_set(lit, id_debug_created_info, rb_obj_freeze(debug_info));
- return rb_str_freeze(lit);
- }
- else {
- return rb_fstring(node->nd_lit);
- }
default:
return node->nd_lit;
}
}
static int
-compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped)
+compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_root,
+ enum compile_array_type_t type, struct rb_call_info_kw_arg **keywords_ptr,
+ unsigned int *flag, int popped)
{
+ const NODE *node = node_root;
int line = (int)nd_line(node);
+ int len = 0;
- if (nd_type(node) == NODE_ZLIST) {
+ if (nd_type(node) == NODE_ZARRAY) {
if (!popped) {
- ADD_INSN1(ret, line, newarray, INT2FIX(0));
+ switch (type) {
+ case COMPILE_ARRAY_TYPE_ARRAY: ADD_INSN1(ret, line, newarray, INT2FIX(0)); break;
+ case COMPILE_ARRAY_TYPE_HASH: ADD_INSN1(ret, line, newhash, INT2FIX(0)); break;
+ case COMPILE_ARRAY_TYPE_ARGS: /* do nothing */ break;
+ }
}
- return 0;
}
+ else {
+ int opt_p = 1;
+ int first = 1, i;
- EXPECT_NODE("compile_array", node, NODE_LIST, -1);
-
- if (popped) {
- for (; node; node = node->nd_next) {
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, popped));
- }
- return 1;
- }
-
- /* Compilation of an array literal.
- * The following code is essentially the same as:
- *
- * for (int count = 0; node; count++; node->nd_next) {
- * compile(node->nd_head);
- * }
- * ADD_INSN(newarray, count);
- *
- * However, there are three points.
- *
- * - The code above causes stack overflow for a big string literal.
- * The following limits the stack length up to max_stack_len.
- *
- * [x1,x2,...,x10000] =>
- * push x1 ; push x2 ; ...; push x256; newarray 256;
- * push x257; push x258; ...; push x512; newarray 256; concatarray;
- * push x513; push x514; ...; push x768; newarray 256; concatarray;
- * ...
- *
- * - Long subarray can be optimized by pre-allocating a hidden array.
- *
- * [1,2,3,...,100] =>
- * duparray [1,2,3,...,100]
- *
- * [x, 1,2,3,...,100, z] =>
- * push x; newarray 1;
- * putobject [1,2,3,...,100] (<- hidden array); concatarray;
- * push z; newarray 1; concatarray
- *
- * - If the last element is a keyword, newarraykwsplat should be emitted
- * to check and remove empty keyword arguments hash from array.
- * (Note: a keyword is NODE_HASH which is not static_literal_node_p.)
- *
- * [1,2,3,**kw] =>
- * putobject 1; putobject 2; putobject 3; push kw; newarraykwsplat
- */
-
- const int max_stack_len = 0x100;
- const int min_tmp_ary_len = 0x40;
- int stack_len = 0;
- int first_chunk = 1;
-
- /* Convert pushed elements to an array, and concatarray if needed */
-#define FLUSH_CHUNK(newarrayinsn) \
- if (stack_len) { \
- ADD_INSN1(ret, line, newarrayinsn, INT2FIX(stack_len)); \
- if (!first_chunk) ADD_INSN(ret, line, concatarray); \
- first_chunk = stack_len = 0; \
- }
+ while (node) {
+ const NODE *start_node = node, *end_node;
+ const NODE *kw = 0;
+ const int max = 0x100;
+ DECL_ANCHOR(anchor);
+ INIT_ANCHOR(anchor);
+
+ for (i=0; i<max && node; i++, len++, node = node->nd_next) {
+ if (CPDEBUG > 0) {
+ EXPECT_NODE("compile_array", node, NODE_ARRAY, -1);
+ }
- while (node) {
- int count = 1;
-
- /* pre-allocation check (this branch can be omittable) */
- if (static_literal_node_p(node, iseq)) {
- /* count the elements that are optimizable */
- const NODE *node_tmp = node->nd_next;
- for (; node_tmp && static_literal_node_p(node_tmp, iseq); node_tmp = node_tmp->nd_next)
- count++;
-
- if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_ary_len) {
- /* The literal contains only optimizable elements, or the subarray is long enough */
- VALUE ary = rb_ary_tmp_new(count);
-
- /* Create a hidden array */
- for (; count; count--, node = node->nd_next)
- rb_ary_push(ary, static_literal_value(node, iseq));
- OBJ_FREEZE(ary);
-
- /* Emit optimized code */
- FLUSH_CHUNK(newarray);
- if (first_chunk) {
- ADD_INSN1(ret, line, duparray, ary);
- first_chunk = 0;
- }
- else {
- ADD_INSN1(ret, line, putobject, ary);
- ADD_INSN(ret, line, concatarray);
- }
- RB_OBJ_WRITTEN(iseq, Qundef, ary);
- }
- }
+ if (type != COMPILE_ARRAY_TYPE_ARRAY && !node->nd_head) {
+ kw = node->nd_next;
+ node = 0;
+ if (kw) {
+ opt_p = 0;
+ node = kw->nd_next;
+ kw = kw->nd_head;
+ }
+ break;
+ }
+ if (opt_p && !static_literal_node_p(node)) {
+ opt_p = 0;
+ }
- /* Base case: Compile "count" elements */
- for (; count; count--, node = node->nd_next) {
- if (CPDEBUG > 0) {
- EXPECT_NODE("compile_array", node, NODE_LIST, -1);
- }
+ if (type == COMPILE_ARRAY_TYPE_ARGS &&
+ node->nd_next == NULL /* last node */ &&
+ compile_array_keyword_arg(iseq, anchor, node->nd_head, keywords_ptr, flag)) {
+ len--;
+ }
+ else {
+ COMPILE_(anchor, "array element", node->nd_head, popped);
+ }
+ }
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, 0));
- stack_len++;
+ if (opt_p && type != COMPILE_ARRAY_TYPE_ARGS) {
+ if (!popped) {
+ VALUE ary = rb_ary_tmp_new(i);
- if (!node->nd_next && keyword_node_p(node->nd_head)) {
- /* Reached the end, and the last element is a keyword */
- FLUSH_CHUNK(newarraykwsplat);
- return 1;
- }
+ end_node = node;
+ node = start_node;
- /* If there are many pushed elements, flush them to avoid stack overflow */
- if (stack_len >= max_stack_len) FLUSH_CHUNK(newarray);
- }
- }
+ while (node != end_node) {
+ rb_ary_push(ary, static_literal_value(node));
+ node = node->nd_next;
+ }
+ while (node && node->nd_next &&
+ static_literal_node_p(node) &&
+ static_literal_node_p(node->nd_next)) {
+ VALUE elem[2];
+ elem[0] = static_literal_value(node);
+ elem[1] = static_literal_value(node->nd_next);
+ rb_ary_cat(ary, elem, 2);
+ node = node->nd_next->nd_next;
+ len++;
+ }
- FLUSH_CHUNK(newarray);
-#undef FLUSH_CHUNK
- return 1;
-}
+ OBJ_FREEZE(ary);
-static inline int
-static_literal_node_pair_p(const NODE *node, const rb_iseq_t *iseq)
-{
- return node->nd_head && static_literal_node_p(node, iseq) && static_literal_node_p(node->nd_next, iseq);
-}
+ iseq_add_mark_object_compile_time(iseq, ary);
-static int
-compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped)
-{
- int line = (int)nd_line(node);
+ if (first) {
+ first = 0;
+ if (type == COMPILE_ARRAY_TYPE_ARRAY) {
+ ADD_INSN1(ret, line, duparray, ary);
+ }
+ else { /* COMPILE_ARRAY_TYPE_HASH */
+ ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ ADD_INSN1(ret, line, putobject, ary);
+ ADD_SEND(ret, line, id_core_hash_from_ary, INT2FIX(1));
+ }
+ }
+ else {
+ if (type == COMPILE_ARRAY_TYPE_ARRAY) {
+ ADD_INSN1(ret, line, putobject, ary);
+ ADD_INSN(ret, line, concatarray);
+ }
+ else {
+#if 0
+ ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ ADD_INSN1(ret, line, putobject, ary);
+ ADD_SEND(ret, line, id_core_hash_merge_ary, INT2FIX(1));
+ /* wrong number of arguments -----------------------^ */
+#else
+ COMPILE_ERROR(ERROR_ARGS "core#hash_merge_ary");
+ return -1;
+#endif
+ }
+ }
+ }
+ }
+ else {
+ if (!popped || kw) {
+ switch (type) {
+ case COMPILE_ARRAY_TYPE_ARRAY:
+ ADD_INSN1(anchor, line, newarray, INT2FIX(i));
- node = node->nd_head;
+ if (first) {
+ first = 0;
+ }
+ else {
+ ADD_INSN(anchor, line, concatarray);
+ }
- if (!node || nd_type(node) == NODE_ZLIST) {
- if (!popped) {
- ADD_INSN1(ret, line, newhash, INT2FIX(0));
+ APPEND_LIST(ret, anchor);
+ break;
+ case COMPILE_ARRAY_TYPE_HASH:
+ if (i > 0) {
+ if (first) {
+ if (!popped) {
+ ADD_INSN1(anchor, line, newhash, INT2FIX(i));
+ }
+ APPEND_LIST(ret, anchor);
+ }
+ else {
+ if (!popped) {
+ ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ ADD_INSN(ret, line, swap);
+ }
+ APPEND_LIST(ret, anchor);
+ if (!popped) {
+ ADD_SEND(ret, line, id_core_hash_merge_ptr, INT2FIX(i + 1));
+ }
+ }
+ }
+ if (kw) {
+ VALUE nhash = (i > 0 || !first) ? INT2FIX(2) : INT2FIX(1);
+ if (!popped) {
+ ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ if (i > 0 || !first) ADD_INSN(ret, line, swap);
+ }
+ COMPILE(ret, "keyword splat", kw);
+ if (popped) {
+ ADD_INSN(ret, line, pop);
+ }
+ else {
+ ADD_SEND(ret, line, id_core_hash_merge_kwd, nhash);
+ if (nhash == INT2FIX(1)) ADD_SEND(ret, line, rb_intern("dup"), INT2FIX(0));
+ }
+ }
+ first = 0;
+ break;
+ case COMPILE_ARRAY_TYPE_ARGS:
+ APPEND_LIST(ret, anchor);
+ break;
+ }
+ }
+ else {
+ /* popped */
+ APPEND_LIST(ret, anchor);
+ }
+ }
}
- return 0;
- }
-
- EXPECT_NODE("compile_hash", node, NODE_LIST, -1);
-
- if (popped) {
- for (; node; node = node->nd_next) {
- NO_CHECK(COMPILE_(ret, "hash element", node->nd_head, popped));
- }
- return 1;
- }
-
- /* Compilation of a hash literal (or keyword arguments).
- * This is very similar to compile_array, but there are some differences:
- *
- * - It contains key-value pairs. So we need to take every two elements.
- * We can assume that the length is always even.
- *
- * - Merging is done by a method call (id_core_hash_merge_ptr).
- * Sometimes we need to insert the receiver, so "anchor" is needed.
- * In addition, a method call is much slower than concatarray.
- * So it pays only when the subsequence is really long.
- * (min_tmp_hash_len must be much larger than min_tmp_ary_len.)
- *
- * - We need to handle keyword splat: **kw.
- * For **kw, the key part (node->nd_head) is NULL, and the value part
- * (node->nd_next->nd_head) is "kw".
- * The code is a bit difficult to avoid hash allocation for **{}.
- */
-
- const int max_stack_len = 0x100;
- const int min_tmp_hash_len = 0x800;
- int stack_len = 0;
- int first_chunk = 1;
- DECL_ANCHOR(anchor);
- INIT_ANCHOR(anchor);
-
- /* Convert pushed elements to a hash, and merge if needed */
-#define FLUSH_CHUNK() \
- if (stack_len) { \
- if (first_chunk) { \
- APPEND_LIST(ret, anchor); \
- ADD_INSN1(ret, line, newhash, INT2FIX(stack_len)); \
- } \
- else { \
- ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); \
- ADD_INSN(ret, line, swap); \
- APPEND_LIST(ret, anchor); \
- ADD_SEND(ret, line, id_core_hash_merge_ptr, INT2FIX(stack_len + 1)); \
- } \
- INIT_ANCHOR(anchor); \
- first_chunk = stack_len = 0; \
}
-
- while (node) {
- int count = 1;
-
- /* pre-allocation check (this branch can be omittable) */
- if (static_literal_node_pair_p(node, iseq)) {
- /* count the elements that are optimizable */
- const NODE *node_tmp = node->nd_next->nd_next;
- for (; node_tmp && static_literal_node_pair_p(node_tmp, iseq); node_tmp = node_tmp->nd_next->nd_next)
- count++;
-
- if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_hash_len) {
- /* The literal contains only optimizable elements, or the subsequence is long enough */
- VALUE ary = rb_ary_tmp_new(count);
-
- /* Create a hidden hash */
- for (; count; count--, node = node->nd_next->nd_next) {
- VALUE elem[2];
- elem[0] = static_literal_value(node, iseq);
- elem[1] = static_literal_value(node->nd_next, iseq);
- rb_ary_cat(ary, elem, 2);
- }
- VALUE hash = rb_hash_new_with_size(RARRAY_LEN(ary) / 2);
- rb_hash_bulk_insert(RARRAY_LEN(ary), RARRAY_CONST_PTR_TRANSIENT(ary), hash);
- hash = rb_obj_hide(hash);
- OBJ_FREEZE(hash);
-
- /* Emit optimized code */
- FLUSH_CHUNK();
- if (first_chunk) {
- ADD_INSN1(ret, line, duphash, hash);
- first_chunk = 0;
- }
- else {
- ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- ADD_INSN(ret, line, swap);
-
- ADD_INSN1(ret, line, putobject, hash);
-
- ADD_SEND(ret, line, id_core_hash_merge_kwd, INT2FIX(2));
- }
- RB_OBJ_WRITTEN(iseq, Qundef, hash);
- }
- }
-
- /* Base case: Compile "count" elements */
- for (; count; count--, node = node->nd_next->nd_next) {
-
- if (CPDEBUG > 0) {
- EXPECT_NODE("compile_hash", node, NODE_LIST, -1);
- }
-
- if (node->nd_head) {
- /* Normal key-value pair */
- NO_CHECK(COMPILE_(anchor, "hash key element", node->nd_head, 0));
- NO_CHECK(COMPILE_(anchor, "hash value element", node->nd_next->nd_head, 0));
- stack_len += 2;
-
- /* If there are many pushed elements, flush them to avoid stack overflow */
- if (stack_len >= max_stack_len) FLUSH_CHUNK();
- }
- else {
- /* kwsplat case: foo(..., **kw, ...) */
- FLUSH_CHUNK();
-
- const NODE *kw = node->nd_next->nd_head;
- int empty_kw = nd_type(kw) == NODE_LIT && RB_TYPE_P(kw->nd_lit, T_HASH); /* foo( ..., **{}, ...) */
- int first_kw = first_chunk && stack_len == 0; /* foo(1,2,3, **kw, ...) */
- int last_kw = !node->nd_next->nd_next; /* foo( ..., **kw) */
- int only_kw = last_kw && first_kw; /* foo(1,2,3, **kw) */
-
- if (empty_kw) {
- if (only_kw) {
- /* **{} appears at the last, so it won't be modified.
- * kw is a special NODE_LIT that contains a special empty hash,
- * so this emits: putobject {}
- */
- NO_CHECK(COMPILE(ret, "keyword splat", kw));
- }
- else if (first_kw) {
- /* **{} appears at the first, so it may be modified.
- * We need to create a fresh hash object.
- */
- ADD_INSN1(ret, line, newhash, INT2FIX(0));
- }
- }
- else {
- /* This is not empty hash: **{k:1}.
- * We need to clone the hash (if first), or merge the hash to
- * the accumulated hash (if not first).
- */
- ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- if (first_kw) ADD_INSN1(ret, line, newhash, INT2FIX(0));
- else ADD_INSN(ret, line, swap);
-
- NO_CHECK(COMPILE(ret, "keyword splat", kw));
-
- ADD_SEND(ret, line, id_core_hash_merge_kwd, INT2FIX(2));
- }
-
- first_chunk = 0;
- }
- }
- }
-
- FLUSH_CHUNK();
-#undef FLUSH_CHUNK
- return 1;
+ return len;
}
-VALUE
-rb_node_case_when_optimizable_literal(const NODE *const node)
+static VALUE
+case_when_optimizable_literal(const NODE *const node)
{
switch (nd_type(node)) {
case NODE_LIT: {
@@ -4314,25 +3822,31 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
{
while (vals) {
const NODE *val = vals->nd_head;
- VALUE lit = rb_node_case_when_optimizable_literal(val);
+ VALUE lit = case_when_optimizable_literal(val);
if (lit == Qundef) {
only_special_literals = 0;
}
- else if (NIL_P(rb_hash_lookup(literals, lit))) {
- rb_hash_aset(literals, lit, (VALUE)(l1) | 1);
+ else {
+ if (rb_hash_lookup(literals, lit) != Qnil) {
+ VALUE file = rb_iseq_path(iseq);
+ rb_compile_warning(RSTRING_PTR(file), nd_line(val),
+ "duplicated when clause is ignored");
+ }
+ else {
+ rb_hash_aset(literals, lit, (VALUE)(l1) | 1);
+ }
}
ADD_INSN(cond_seq, nd_line(val), dup); /* dup target */
if (nd_type(val) == NODE_STR) {
debugp_param("nd_lit", val->nd_lit);
- lit = rb_fstring(val->nd_lit);
+ lit = freeze_literal(iseq, val->nd_lit);
ADD_INSN1(cond_seq, nd_line(val), putobject, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
else {
- if (!COMPILE(cond_seq, "when cond", val)) return -1;
+ COMPILE(cond_seq, "when cond", val);
}
ADD_INSN1(cond_seq, nd_line(vals), checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
@@ -4343,47 +3857,6 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
}
static int
-when_splat_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
- LABEL *l1, int only_special_literals, VALUE literals)
-{
- const int line = nd_line(vals);
-
- switch (nd_type(vals)) {
- case NODE_LIST:
- if (when_vals(iseq, cond_seq, vals, l1, only_special_literals, literals) < 0)
- return COMPILE_NG;
- break;
- case NODE_SPLAT:
- ADD_INSN (cond_seq, line, dup);
- CHECK(COMPILE(cond_seq, "when splat", vals->nd_head));
- ADD_INSN1(cond_seq, line, splatarray, Qfalse);
- ADD_INSN1(cond_seq, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE | VM_CHECKMATCH_ARRAY));
- ADD_INSNL(cond_seq, line, branchif, l1);
- break;
- case NODE_ARGSCAT:
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_head, l1, only_special_literals, literals));
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_body, l1, only_special_literals, literals));
- break;
- case NODE_ARGSPUSH:
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_head, l1, only_special_literals, literals));
- ADD_INSN (cond_seq, line, dup);
- CHECK(COMPILE(cond_seq, "when argspush body", vals->nd_body));
- ADD_INSN1(cond_seq, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
- ADD_INSNL(cond_seq, line, branchif, l1);
- break;
- default:
- ADD_INSN (cond_seq, line, dup);
- CHECK(COMPILE(cond_seq, "when val", vals));
- ADD_INSN1(cond_seq, line, splatarray, Qfalse);
- ADD_INSN1(cond_seq, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE | VM_CHECKMATCH_ARRAY));
- ADD_INSNL(cond_seq, line, branchif, l1);
- break;
- }
- return COMPILE_OK;
-}
-
-
-static int
compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
{
switch (nd_type(node)) {
@@ -4396,7 +3869,7 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const n
CHECK(COMPILE_POPPED(ret, "masgn lhs (NODE_ATTRASGN)", node));
iobj = (INSN *)get_prev_insn((INSN *)LAST_ELEMENT(ret)); /* send insn */
- ci = (struct rb_call_info *)OPERAND_AT(iobj, 0);
+ ci = (struct rb_call_info *)iobj->operands[0];
ci->orig_argc += 1;
dupidx = INT2FIX(ci->orig_argc);
@@ -4459,7 +3932,7 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
mem[memindex++] = (v); \
}
- if (rhsn == 0 || nd_type(rhsn) != NODE_LIST) {
+ if (rhsn == 0 || nd_type(rhsn) != NODE_ARRAY) {
return 0;
}
@@ -4484,10 +3957,10 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
while (rhsn) {
if (llen <= rlen) {
- NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head));
+ COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head);
}
else {
- NO_CHECK(COMPILE(ret, "masgn val", rhsn->nd_head));
+ COMPILE(ret, "masgn val", rhsn->nd_head);
}
rhsn = rhsn->nd_next;
rlen++;
@@ -4520,7 +3993,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
const NODE *rhsn = node->nd_value;
const NODE *splatn = node->nd_args;
const NODE *lhsn = node->nd_head;
- int lhs_splat = (splatn && NODE_NAMED_REST_P(splatn)) ? 1 : 0;
+ int lhs_splat = (splatn && splatn != NODE_SPECIAL_NO_NAME_REST) ? 1 : 0;
if (!popped || splatn || !compile_massign_opt(iseq, ret, rhsn, lhsn)) {
int llen = 0;
@@ -4535,7 +4008,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
lhsn = lhsn->nd_next;
}
- NO_CHECK(COMPILE(ret, "normal masgn rhs", rhsn));
+ COMPILE(ret, "normal masgn rhs", rhsn);
if (!popped) {
ADD_INSN(ret, nd_line(node), dup);
@@ -4577,12 +4050,12 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
const NODE *postn = splatn->nd_2nd;
const NODE *restn = splatn->nd_1st;
int num = (int)postn->nd_alen;
- int flag = 0x02 | (NODE_NAMED_REST_P(restn) ? 0x01 : 0x00);
+ int flag = 0x02 | ((restn == NODE_SPECIAL_NO_NAME_REST) ? 0x00 : 0x01);
ADD_INSN2(ret, nd_line(splatn), expandarray,
INT2FIX(num), INT2FIX(flag));
- if (NODE_NAMED_REST_P(restn)) {
+ if (restn != NODE_SPECIAL_NO_NAME_REST) {
CHECK(compile_massign_lhs(iseq, ret, restn));
}
while (postn) {
@@ -4606,21 +4079,18 @@ compile_const_prefix(rb_iseq_t *iseq, const NODE *const node,
switch (nd_type(node)) {
case NODE_CONST:
debugi("compile_const_prefix - colon", node->nd_vid);
- ADD_INSN1(body, nd_line(node), putobject, Qtrue);
- ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_vid));
break;
case NODE_COLON3:
debugi("compile_const_prefix - colon3", node->nd_mid);
ADD_INSN(body, nd_line(node), pop);
ADD_INSN1(body, nd_line(node), putobject, rb_cObject);
- ADD_INSN1(body, nd_line(node), putobject, Qtrue);
- ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
break;
case NODE_COLON2:
CHECK(compile_const_prefix(iseq, node->nd_head, pref, body));
debugi("compile_const_prefix - colon2", node->nd_mid);
- ADD_INSN1(body, nd_line(node), putobject, Qfalse);
- ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
break;
default:
CHECK(COMPILE(pref, "const colon2 prefix", node));
@@ -4639,7 +4109,7 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath)
}
else if (cpath->nd_head) {
/* Bar::Foo */
- NO_CHECK(COMPILE(ret, "nd_else->nd_head", cpath->nd_head));
+ COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
return VM_DEFINECLASS_FLAG_SCOPED;
}
else {
@@ -4650,27 +4120,17 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath)
}
}
-static inline int
-private_recv_p(const NODE *node)
-{
- if (nd_type(node->nd_recv) == NODE_SELF) {
- NODE *self = node->nd_recv;
- return self->nd_state != 0;
- }
- return 0;
-}
-
-static void
+#define private_recv_p(node) (nd_type((node)->nd_recv) == NODE_SELF)
+static int
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *const node, LABEL **lfinish, VALUE needstr);
-static void
+static int
defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *const node, LABEL **lfinish, VALUE needstr)
{
- enum defined_type expr_type = DEFINED_NOT_DEFINED;
+ enum defined_type expr_type = 0;
enum node_type type;
- const int line = nd_line(node);
switch (type = nd_type(node)) {
@@ -4688,22 +4148,21 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
expr_type = DEFINED_FALSE;
break;
- case NODE_LIST:{
+ case NODE_ARRAY:{
const NODE *vals = node;
do {
defined_expr0(iseq, ret, vals->nd_head, lfinish, Qfalse);
if (!lfinish[1]) {
- lfinish[1] = NEW_LABEL(line);
+ lfinish[1] = NEW_LABEL(nd_line(node));
}
- ADD_INSNL(ret, line, branchunless, lfinish[1]);
+ ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
} while ((vals = vals->nd_next) != NULL);
}
- /* fall through */
case NODE_STR:
case NODE_LIT:
- case NODE_ZLIST:
+ case NODE_ZARRAY:
case NODE_AND:
case NODE_OR:
default:
@@ -4717,46 +4176,46 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
break;
case NODE_IVAR:
- ADD_INSN(ret, line, putnil);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_IVAR),
+ ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_IVAR),
ID2SYM(node->nd_vid), needstr);
- return;
+ return 1;
case NODE_GVAR:
- ADD_INSN(ret, line, putnil);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_GVAR),
+ ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_GVAR),
ID2SYM(node->nd_entry->id), needstr);
- return;
+ return 1;
case NODE_CVAR:
- ADD_INSN(ret, line, putnil);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CVAR),
+ ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CVAR),
ID2SYM(node->nd_vid), needstr);
- return;
+ return 1;
case NODE_CONST:
- ADD_INSN(ret, line, putnil);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST),
+ ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CONST),
ID2SYM(node->nd_vid), needstr);
- return;
+ return 1;
case NODE_COLON2:
if (!lfinish[1]) {
- lfinish[1] = NEW_LABEL(line);
+ lfinish[1] = NEW_LABEL(nd_line(node));
}
defined_expr0(iseq, ret, node->nd_head, lfinish, Qfalse);
- ADD_INSNL(ret, line, branchunless, lfinish[1]);
- NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", node->nd_head));
+ ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
+ COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
- ADD_INSN3(ret, line, defined,
+ ADD_INSN3(ret, nd_line(node), defined,
(rb_is_const_id(node->nd_mid) ?
- INT2FIX(DEFINED_CONST_FROM) : INT2FIX(DEFINED_METHOD)),
+ INT2FIX(DEFINED_CONST) : INT2FIX(DEFINED_METHOD)),
ID2SYM(node->nd_mid), needstr);
- return;
+ return 1;
case NODE_COLON3:
- ADD_INSN1(ret, line, putobject, rb_cObject);
- ADD_INSN3(ret, line, defined,
- INT2FIX(DEFINED_CONST_FROM), ID2SYM(node->nd_mid), needstr);
- return;
+ ADD_INSN1(ret, nd_line(node), putobject, rb_cObject);
+ ADD_INSN3(ret, nd_line(node), defined,
+ INT2FIX(DEFINED_CONST), ID2SYM(node->nd_mid), needstr);
+ return 1;
/* method dispatch */
case NODE_CALL:
@@ -4769,47 +4228,47 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
(type == NODE_ATTRASGN && !private_recv_p(node)));
if (!lfinish[1] && (node->nd_args || explicit_receiver)) {
- lfinish[1] = NEW_LABEL(line);
+ lfinish[1] = NEW_LABEL(nd_line(node));
}
if (node->nd_args) {
defined_expr0(iseq, ret, node->nd_args, lfinish, Qfalse);
- ADD_INSNL(ret, line, branchunless, lfinish[1]);
+ ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
}
if (explicit_receiver) {
defined_expr0(iseq, ret, node->nd_recv, lfinish, Qfalse);
- ADD_INSNL(ret, line, branchunless, lfinish[1]);
- NO_CHECK(COMPILE(ret, "defined/recv", node->nd_recv));
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_METHOD),
+ ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
+ COMPILE(ret, "defined/recv", node->nd_recv);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_METHOD),
ID2SYM(node->nd_mid), needstr);
}
else {
- ADD_INSN(ret, line, putself);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_FUNC),
+ ADD_INSN(ret, nd_line(node), putself);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_FUNC),
ID2SYM(node->nd_mid), needstr);
}
- return;
+ return 1;
}
case NODE_YIELD:
- ADD_INSN(ret, line, putnil);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_YIELD), 0,
+ ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_YIELD), 0,
needstr);
- return;
+ return 1;
case NODE_BACK_REF:
case NODE_NTH_REF:
- ADD_INSN(ret, line, putnil);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_REF),
+ ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_REF),
INT2FIX((node->nd_nth << 1) | (type == NODE_BACK_REF)),
needstr);
- return;
+ return 1;
case NODE_SUPER:
case NODE_ZSUPER:
- ADD_INSN(ret, line, putnil);
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_ZSUPER), 0,
+ ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_ZSUPER), 0,
needstr);
- return;
+ return 1;
case NODE_OP_ASGN1:
case NODE_OP_ASGN2:
@@ -4827,47 +4286,44 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
break;
}
- assert(expr_type != DEFINED_NOT_DEFINED);
-
- if (needstr != Qfalse) {
- VALUE str = rb_iseq_defined_string(expr_type);
- ADD_INSN1(ret, line, putobject, str);
- }
- else {
- ADD_INSN1(ret, line, putobject, Qtrue);
+ if (expr_type) {
+ if (needstr != Qfalse) {
+ VALUE str = rb_iseq_defined_string(expr_type);
+ ADD_INSN1(ret, nd_line(node), putobject, str);
+ }
+ else {
+ ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
+ }
+ return 1;
}
+ return 0;
}
-static void
-build_defined_rescue_iseq(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const void *unused)
-{
- ADD_INSN(ret, 0, putnil);
- iseq_set_exception_local_table(iseq);
-}
-
-static void
+static int
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *const node, LABEL **lfinish, VALUE needstr)
{
LINK_ELEMENT *lcur = ret->last;
- defined_expr0(iseq, ret, node, lfinish, needstr);
+ int done = defined_expr0(iseq, ret, node, lfinish, needstr);
if (lfinish[1]) {
int line = nd_line(node);
LABEL *lstart = NEW_LABEL(line);
LABEL *lend = NEW_LABEL(line);
const rb_iseq_t *rescue;
- struct rb_iseq_new_with_callback_callback_func *ifunc =
- rb_iseq_new_with_callback_new_callback(build_defined_rescue_iseq, NULL);
- rescue = new_child_iseq_with_callback(iseq, ifunc,
- rb_str_concat(rb_str_new2("defined guard in "),
- iseq->body->location.label),
- iseq, ISEQ_TYPE_RESCUE, 0);
+ NODE tmp_node, *node = &tmp_node;
+ rb_node_init(node, NODE_NIL, 0, 0, 0);
+ rescue = NEW_CHILD_ISEQ(node,
+ rb_str_concat(rb_str_new2
+ ("defined guard in "),
+ iseq->body->location.label),
+ ISEQ_TYPE_DEFINED_GUARD, 0);
lstart->rescued = LABEL_RESCUE_BEG;
lend->rescued = LABEL_RESCUE_END;
APPEND_LABEL(ret, lcur, lstart);
ADD_LABEL(ret, lend);
ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lfinish[1]);
}
+ return done;
}
static int
@@ -4967,7 +4423,7 @@ add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return)
ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = enlp->prev;
ADD_LABEL(ensure_part, lstart);
- NO_CHECK(COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node));
+ COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node);
ADD_LABEL(ensure_part, lend);
ADD_SEQ(ensure, ensure_part);
}
@@ -4982,123 +4438,115 @@ add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return)
ADD_SEQ(ret, ensure);
}
-static int
-check_keyword(const NODE *node)
+static VALUE
+setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
+ unsigned int *flag, struct rb_call_info_kw_arg **keywords)
{
- /* This check is essentially a code clone of compile_keyword_arg. */
+ VALUE argc = INT2FIX(0);
+ int nsplat = 0;
+ DECL_ANCHOR(arg_block);
+ DECL_ANCHOR(args_splat);
- if (nd_type(node) == NODE_LIST) {
- while (node->nd_next) {
- node = node->nd_next;
- }
- node = node->nd_head;
+ INIT_ANCHOR(arg_block);
+ INIT_ANCHOR(args_splat);
+ if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
+ COMPILE(arg_block, "block", argn->nd_body);
+ *flag |= VM_CALL_ARGS_BLOCKARG;
+ argn = argn->nd_head;
}
- return keyword_node_p(node);
-}
-
-static VALUE
-setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
- int dup_rest, unsigned int *flag, struct rb_call_info_kw_arg **keywords)
-{
+ setup_argn:
if (argn) {
- switch (nd_type(argn)) {
- case NODE_SPLAT: {
- NO_CHECK(COMPILE(args, "args (splat)", argn->nd_head));
- ADD_INSN1(args, nd_line(argn), splatarray, dup_rest ? Qtrue : Qfalse);
- if (flag) *flag |= VM_CALL_ARGS_SPLAT;
- return INT2FIX(1);
- }
- case NODE_ARGSCAT:
- case NODE_ARGSPUSH: {
- int next_is_list = (nd_type(argn->nd_head) == NODE_LIST);
- VALUE argc = setup_args_core(iseq, args, argn->nd_head, 1, NULL, NULL);
- if (nd_type(argn->nd_body) == NODE_LIST) {
- /* This branch is needed to avoid "newarraykwsplat" [Bug #16442] */
- int rest_len = compile_args(iseq, args, argn->nd_body, NULL, NULL);
- ADD_INSN1(args, nd_line(argn), newarray, INT2FIX(rest_len));
- }
- else {
- NO_CHECK(COMPILE(args, "args (cat: splat)", argn->nd_body));
- }
- if (flag) {
- *flag |= VM_CALL_ARGS_SPLAT;
- /* This is a dirty hack. It traverses the AST twice.
- * In a long term, it should be fixed by a redesign of keyword arguments */
- if (check_keyword(argn->nd_body))
- *flag |= VM_CALL_KW_SPLAT;
- }
- if (nd_type(argn) == NODE_ARGSCAT) {
- if (next_is_list) {
- ADD_INSN1(args, nd_line(argn), splatarray, Qtrue);
- return INT2FIX(FIX2INT(argc) + 1);
- }
- else {
- ADD_INSN1(args, nd_line(argn), splatarray, Qfalse);
- ADD_INSN(args, nd_line(argn), concatarray);
- return argc;
- }
- }
- else {
- ADD_INSN1(args, nd_line(argn), newarray, INT2FIX(1));
- ADD_INSN(args, nd_line(argn), concatarray);
- return argc;
- }
- }
- case NODE_LIST: {
- int len = compile_args(iseq, args, argn, keywords, flag);
- return INT2FIX(len);
- }
- default: {
- UNKNOWN_NODE("setup_arg", argn, Qnil);
- }
- }
+ switch (nd_type(argn)) {
+ case NODE_SPLAT: {
+ COMPILE(args, "args (splat)", argn->nd_head);
+ ADD_INSN1(args, nd_line(argn), splatarray, nsplat ? Qtrue : Qfalse);
+ argc = INT2FIX(1);
+ nsplat++;
+ *flag |= VM_CALL_ARGS_SPLAT;
+ break;
+ }
+ case NODE_ARGSCAT:
+ case NODE_ARGSPUSH: {
+ int next_is_array = (nd_type(argn->nd_head) == NODE_ARRAY);
+ DECL_ANCHOR(tmp);
+
+ INIT_ANCHOR(tmp);
+ COMPILE(tmp, "args (cat: splat)", argn->nd_body);
+ if (nd_type(argn) == NODE_ARGSCAT) {
+ ADD_INSN1(tmp, nd_line(argn), splatarray, nsplat ? Qtrue : Qfalse);
+ }
+ else {
+ ADD_INSN1(tmp, nd_line(argn), newarray, INT2FIX(1));
+ }
+ INSERT_LIST(args_splat, tmp);
+ nsplat++;
+ *flag |= VM_CALL_ARGS_SPLAT;
+ if (nd_type(argn->nd_body) == NODE_HASH)
+ *flag |= VM_CALL_KW_SPLAT;
+
+ if (next_is_array) {
+ int len = compile_array(iseq, args, argn->nd_head, COMPILE_ARRAY_TYPE_ARGS, NULL, flag, FALSE);
+ if (len < 0) return Qnil;
+ argc = INT2FIX(len + 1);
+ }
+ else {
+ argn = argn->nd_head;
+ goto setup_argn;
+ }
+ break;
+ }
+ case NODE_ARRAY:
+ {
+ int len = compile_array(iseq, args, argn, COMPILE_ARRAY_TYPE_ARGS, keywords, flag, FALSE);
+ if (len < 0) return Qnil;
+ argc = INT2FIX(len);
+ break;
+ }
+ default: {
+ UNKNOWN_NODE("setup_arg", argn, Qnil);
+ }
+ }
}
- return INT2FIX(0);
-}
-static VALUE
-setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
- unsigned int *flag, struct rb_call_info_kw_arg **keywords)
-{
- VALUE ret;
- if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
- DECL_ANCHOR(arg_block);
- INIT_ANCHOR(arg_block);
- NO_CHECK(COMPILE(arg_block, "block", argn->nd_body));
-
- *flag |= VM_CALL_ARGS_BLOCKARG;
- ret = setup_args_core(iseq, args, argn->nd_head, 0, flag, keywords);
-
- if (LIST_INSN_SIZE_ONE(arg_block)) {
- LINK_ELEMENT *elem = FIRST_ELEMENT(arg_block);
- if (elem->type == ISEQ_ELEMENT_INSN) {
- INSN *iobj = (INSN *)elem;
- if (iobj->insn_id == BIN(getblockparam)) {
- iobj->insn_id = BIN(getblockparamproxy);
- }
- }
- }
- ADD_SEQ(args, arg_block);
+ if (nsplat > 1) {
+ int i;
+ for (i=1; i<nsplat; i++) {
+ ADD_INSN(args_splat, nd_line(argn), concatarray);
+ }
}
- else {
- ret = setup_args_core(iseq, args, argn, 0, flag, keywords);
+
+ if (!LIST_INSN_SIZE_ZERO(args_splat)) {
+ ADD_SEQ(args, args_splat);
+ }
+
+ if (*flag & VM_CALL_ARGS_BLOCKARG) {
+ if (LIST_INSN_SIZE_ONE(arg_block)) {
+ LINK_ELEMENT *elem = FIRST_ELEMENT(arg_block);
+ if (elem->type == ISEQ_ELEMENT_INSN) {
+ INSN *iobj = (INSN *)elem;
+ if (iobj->insn_id == BIN(getblockparam)) {
+ iobj->insn_id = BIN(getlocal);
+ *flag |= VM_CALL_ARGS_BLOCKARG_BLOCKPARAM;
+ }
+ }
+ }
+ ADD_SEQ(args, arg_block);
}
- return ret;
+ return argc;
}
-static void
-build_postexe_iseq(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *ptr)
+static VALUE
+build_postexe_iseq(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *body)
{
- const NODE *body = ptr;
int line = nd_line(body);
VALUE argc = INT2FIX(0);
const rb_iseq_t *block = NEW_CHILD_ISEQ(body, make_name_for_block(iseq->body->parent_iseq), ISEQ_TYPE_BLOCK, line);
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_CALL_WITH_BLOCK(ret, line, id_core_set_postexe, argc, block);
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)block);
iseq_set_local_table(iseq, 0);
+ return Qnil;
}
static void
@@ -5123,7 +4571,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
ADD_INSN(ret, line, dup);
}
last = ret->last;
- NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head));
+ COMPILE_POPPED(ret, "capture", vars->nd_head);
last = last->next; /* putobject :var */
cap = new_insn_send(iseq, line, idAREF, INT2FIX(1),
NULL, INT2FIX(0), NULL);
@@ -5152,7 +4600,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
ADD_INSN(ret, line, pop);
for (vars = node; vars; vars = vars->nd_next) {
last = ret->last;
- NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head));
+ COMPILE_POPPED(ret, "capture", vars->nd_head);
last = last->next; /* putobject :var */
((INSN*)last)->insn_id = BIN(putnil);
((INSN*)last)->operand_size = 0;
@@ -5169,7 +4617,6 @@ number_literal_p(const NODE *n)
static int
compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const enum node_type type)
{
- struct rb_iseq_constant_body *const body = iseq->body;
const NODE *const node_body = type == NODE_IF ? node->nd_body : node->nd_else;
const NODE *const node_else = type == NODE_IF ? node->nd_else : node->nd_body;
@@ -5182,10 +4629,8 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
DECL_ANCHOR(then_seq);
DECL_ANCHOR(else_seq);
LABEL *then_label, *else_label, *end_label;
- VALUE branches = Qfalse;
+ VALUE branches = 0;
int ci_size, ci_kw_size;
- VALUE catch_table = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
- long catch_table_size = NIL_P(catch_table) ? 0 : RARRAY_LEN(catch_table);
INIT_ANCHOR(cond_seq);
INIT_ANCHOR(then_seq);
@@ -5197,30 +4642,20 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
compile_branch_condition(iseq, cond_seq, node->nd_cond,
then_label, else_label);
- ci_size = body->ci_size;
- ci_kw_size = body->ci_kw_size;
+ ci_size = iseq->body->ci_size;
+ ci_kw_size = iseq->body->ci_kw_size;
CHECK(COMPILE_(then_seq, "then", node_body, popped));
- catch_table = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
if (!then_label->refcnt) {
- body->ci_size = ci_size;
- body->ci_kw_size = ci_kw_size;
- if (!NIL_P(catch_table)) rb_ary_set_len(catch_table, catch_table_size);
- }
- else {
- if (!NIL_P(catch_table)) catch_table_size = RARRAY_LEN(catch_table);
+ iseq->body->ci_size = ci_size;
+ iseq->body->ci_kw_size = ci_kw_size;
}
- ci_size = body->ci_size;
- ci_kw_size = body->ci_kw_size;
+ ci_size = iseq->body->ci_size;
+ ci_kw_size = iseq->body->ci_kw_size;
CHECK(COMPILE_(else_seq, "else", node_else, popped));
- catch_table = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
if (!else_label->refcnt) {
- body->ci_size = ci_size;
- body->ci_kw_size = ci_kw_size;
- if (!NIL_P(catch_table)) rb_ary_set_len(catch_table, catch_table_size);
- }
- else {
- if (!NIL_P(catch_table)) catch_table_size = RARRAY_LEN(catch_table);
+ iseq->body->ci_size = ci_size;
+ iseq->body->ci_kw_size = ci_kw_size;
}
ADD_SEQ(ret, cond_seq);
@@ -5240,13 +4675,10 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
node_body ? nd_last_column(node_body) : last_column,
type == NODE_IF ? "then" : "else",
branches);
- end_label = NEW_LABEL(line);
- ADD_INSNL(then_seq, line, jump, end_label);
- if (!popped) {
- ADD_INSN(then_seq, line, pop);
- }
}
ADD_SEQ(ret, then_seq);
+ end_label = NEW_LABEL(line);
+ ADD_INSNL(ret, line, jump, end_label);
}
if (else_label->refcnt) {
@@ -5284,20 +4716,19 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
VALUE literals = rb_hash_new();
int line, lineno, column, last_lineno, last_column;
enum node_type type;
- VALUE branches = Qfalse;
+ VALUE branches = 0;
INIT_ANCHOR(head);
INIT_ANCHOR(body_seq);
INIT_ANCHOR(cond_seq);
- RHASH_TBL_RAW(literals)->type = &cdhash_type;
+ rb_hash_tbl_raw(literals)->type = &cdhash_type;
CHECK(COMPILE(head, "case base", node->nd_head));
DECL_BRANCH_BASE(branches, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "case");
node = node->nd_body;
- EXPECT_NODE("NODE_CASE", node, NODE_WHEN, COMPILE_NG);
type = nd_type(node);
line = nd_line(node);
lineno = nd_first_lineno(node);
@@ -5305,6 +4736,11 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
last_lineno = nd_last_lineno(node);
last_column = nd_last_column(node);
+ if (type != NODE_WHEN) {
+ COMPILE_ERROR(ERROR_ARGS "NODE_CASE: unexpected node. must be NODE_WHEN, but %s", ruby_node_name(type));
+ return COMPILE_NG;
+ }
+
endlabel = NEW_LABEL(line);
elselabel = NEW_LABEL(line);
@@ -5330,22 +4766,24 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
vals = node->nd_head;
if (vals) {
switch (nd_type(vals)) {
- case NODE_LIST:
+ case NODE_ARRAY:
only_special_literals = when_vals(iseq, cond_seq, vals, l1, only_special_literals, literals);
- if (only_special_literals < 0) return COMPILE_NG;
break;
case NODE_SPLAT:
case NODE_ARGSCAT:
case NODE_ARGSPUSH:
only_special_literals = 0;
- CHECK(when_splat_vals(iseq, cond_seq, vals, l1, only_special_literals, literals));
+ ADD_INSN (cond_seq, nd_line(vals), dup);
+ CHECK(COMPILE(cond_seq, "when/cond splat", vals));
+ ADD_INSN1(cond_seq, nd_line(vals), checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE | VM_CHECKMATCH_ARRAY));
+ ADD_INSNL(cond_seq, nd_line(vals), branchif, l1);
break;
default:
UNKNOWN_NODE("NODE_CASE", vals, COMPILE_NG);
}
}
else {
- EXPECT_NODE_NONULL("NODE_CASE", node, NODE_LIST, COMPILE_NG);
+ EXPECT_NODE_NONULL("NODE_CASE", node, NODE_ARRAY, COMPILE_NG);
}
node = node->nd_next;
@@ -5378,10 +4816,11 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
ADD_INSNL(cond_seq, nd_line(orig_node), jump, endlabel);
}
- if (only_special_literals && ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
+ if (only_special_literals) {
+ iseq_add_mark_object(iseq, literals);
+
ADD_INSN(ret, nd_line(orig_node), dup);
ADD_INSN2(ret, nd_line(orig_node), opt_case_dispatch, literals, elselabel);
- RB_OBJ_WRITTEN(iseq, Qundef, literals);
LABEL_REF(elselabel);
}
@@ -5399,7 +4838,7 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
const NODE *node = orig_node->nd_body;
LABEL *endlabel;
DECL_ANCHOR(body_seq);
- VALUE branches = Qfalse;
+ VALUE branches = 0;
DECL_BRANCH_BASE(branches, nd_first_lineno(orig_node), nd_first_column(orig_node), nd_last_lineno(orig_node), nd_last_column(orig_node), "case");
@@ -5427,17 +4866,15 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
vals = node->nd_head;
if (!vals) {
- EXPECT_NODE_NONULL("NODE_WHEN", node, NODE_LIST, COMPILE_NG);
+ COMPILE_ERROR(ERROR_ARGS "NODE_WHEN: must be NODE_ARRAY, but 0");
+ return COMPILE_NG;
}
switch (nd_type(vals)) {
- case NODE_LIST:
+ case NODE_ARRAY:
while (vals) {
- LABEL *lnext;
val = vals->nd_head;
- lnext = NEW_LABEL(nd_line(val));
- debug_compile("== when2\n", (void)0);
- CHECK(compile_branch_condition(iseq, ret, val, l1, lnext));
- ADD_LABEL(ret, lnext);
+ CHECK(COMPILE(ret, "when2", val));
+ ADD_INSNL(ret, nd_line(val), branchif, l1);
vals = vals->nd_next;
}
break;
@@ -5472,602 +4909,6 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
}
static int
-iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int in_alt_pattern)
-{
- const int line = nd_line(node);
-
- switch (nd_type(node)) {
- case NODE_ARYPTN: {
- /*
- * if pattern.use_rest_num?
- * rest_num = 0
- * end
- * if pattern.has_constant_node?
- * unless pattern.constant === obj
- * goto match_failed
- * end
- * end
- * unless obj.respond_to?(:deconstruct)
- * goto match_failed
- * end
- * d = obj.deconstruct
- * unless Array === d
- * goto type_error
- * end
- * min_argc = pattern.pre_args_num + pattern.post_args_num
- * if pattern.has_rest_arg?
- * unless d.length >= min_argc
- * goto match_failed
- * end
- * else
- * unless d.length == min_argc
- * goto match_failed
- * end
- * end
- * pattern.pre_args_num.each do |i|
- * unless pattern.pre_args[i].match?(d[i])
- * goto match_failed
- * end
- * end
- * if pattern.use_rest_num?
- * rest_num = d.length - min_argc
- * if pattern.has_rest_arg? && pattern.has_rest_arg_id # not `*`, but `*rest`
- * unless pattern.rest_arg.match?(d[pattern.pre_args_num, rest_num])
- * goto match_failed
- * end
- * end
- * end
- * pattern.post_args_num.each do |i|
- * j = pattern.pre_args_num + i
- * j += rest_num
- * unless pattern.post_args[i].match?(d[j])
- * goto match_failed
- * end
- * end
- * true
- * goto fin
- * type_error:
- * FrozenCore.raise TypeError
- * match_failed:
- * false
- * fin:
- */
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- const NODE *args = apinfo->pre_args;
- const int pre_args_num = apinfo->pre_args ? rb_long2int(apinfo->pre_args->nd_alen) : 0;
- const int post_args_num = apinfo->post_args ? rb_long2int(apinfo->post_args->nd_alen) : 0;
-
- const int min_argc = pre_args_num + post_args_num;
- const int use_rest_num = apinfo->rest_arg && (NODE_NAMED_REST_P(apinfo->rest_arg) ||
- (!NODE_NAMED_REST_P(apinfo->rest_arg) && post_args_num > 0));
-
- LABEL *match_failed, *type_error, *fin;
- int i;
- match_failed = NEW_LABEL(line);
- type_error = NEW_LABEL(line);
- fin = NEW_LABEL(line);
-
- if (use_rest_num) {
- ADD_INSN1(ret, line, putobject, INT2FIX(0)); /* allocate stack for rest_num */
- ADD_INSN(ret, line, swap);
- }
-
- if (node->nd_pconst) {
- ADD_INSN(ret, line, dup);
- CHECK(COMPILE(ret, "constant", node->nd_pconst));
- ADD_INSN1(ret, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
-
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, putobject, ID2SYM(rb_intern("deconstruct")));
- ADD_SEND(ret, line, idRespond_to, INT2FIX(1));
- ADD_INSNL(ret, line, branchunless, match_failed);
-
- ADD_SEND(ret, line, rb_intern("deconstruct"), INT2FIX(0));
-
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, checktype, INT2FIX(T_ARRAY));
- ADD_INSNL(ret, line, branchunless, type_error);
-
- ADD_INSN(ret, line, dup);
- ADD_SEND(ret, line, idLength, INT2FIX(0));
- ADD_INSN1(ret, line, putobject, INT2FIX(min_argc));
- ADD_SEND(ret, line, apinfo->rest_arg ? idGE : idEq, INT2FIX(1));
- ADD_INSNL(ret, line, branchunless, match_failed);
-
- for (i = 0; i < pre_args_num; i++) {
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, putobject, INT2FIX(i));
- ADD_SEND(ret, line, idAREF, INT2FIX(1));
- iseq_compile_pattern_each(iseq, ret, args->nd_head, in_alt_pattern);
- args = args->nd_next;
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
-
- if (apinfo->rest_arg) {
- if (NODE_NAMED_REST_P(apinfo->rest_arg)) {
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, putobject, INT2FIX(pre_args_num));
- ADD_INSN1(ret, line, topn, INT2FIX(1));
- ADD_SEND(ret, line, idLength, INT2FIX(0));
- ADD_INSN1(ret, line, putobject, INT2FIX(min_argc));
- ADD_SEND(ret, line, idMINUS, INT2FIX(1));
- ADD_INSN1(ret, line, setn, INT2FIX(4));
- ADD_SEND(ret, line, idAREF, INT2FIX(2));
-
- iseq_compile_pattern_each(iseq, ret, apinfo->rest_arg, in_alt_pattern);
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
- else {
- if (post_args_num > 0) {
- ADD_INSN(ret, line, dup);
- ADD_SEND(ret, line, idLength, INT2FIX(0));
- ADD_INSN1(ret, line, putobject, INT2FIX(min_argc));
- ADD_SEND(ret, line, idMINUS, INT2FIX(1));
- ADD_INSN1(ret, line, setn, INT2FIX(2));
- ADD_INSN(ret, line, pop);
- }
- }
- }
-
- args = apinfo->post_args;
- for (i = 0; i < post_args_num; i++) {
- ADD_INSN(ret, line, dup);
-
- ADD_INSN1(ret, line, putobject, INT2FIX(pre_args_num + i));
- ADD_INSN1(ret, line, topn, INT2FIX(3));
- ADD_SEND(ret, line, idPLUS, INT2FIX(1));
-
- ADD_SEND(ret, line, idAREF, INT2FIX(1));
- iseq_compile_pattern_each(iseq, ret, args->nd_head, in_alt_pattern);
- args = args->nd_next;
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
-
- ADD_INSN(ret, line, pop);
- if (use_rest_num) {
- ADD_INSN(ret, line, pop);
- }
- ADD_INSN1(ret, line, putobject, Qtrue);
- ADD_INSNL(ret, line, jump, fin);
-
- ADD_LABEL(ret, type_error);
- ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- ADD_INSN1(ret, line, putobject, rb_eTypeError);
- ADD_INSN1(ret, line, putobject, rb_fstring_lit("deconstruct must return Array"));
- ADD_SEND(ret, line, id_core_raise, INT2FIX(2));
-
- ADD_LABEL(ret, match_failed);
- ADD_INSN(ret, line, pop);
- if (use_rest_num) {
- ADD_INSN(ret, line, pop);
- }
- ADD_INSN1(ret, line, putobject, Qfalse);
- ADD_LABEL(ret, fin);
-
- break;
- }
- case NODE_HSHPTN: {
- /*
- * keys = nil
- * if pattern.has_kw_args_node? && !pattern.has_kw_rest_arg_node?
- * keys = pattern.kw_args_node.keys
- * end
- * if pattern.has_constant_node?
- * unless pattern.constant === obj
- * goto match_failed
- * end
- * end
- * unless obj.respond_to?(:deconstruct_keys)
- * goto match_failed
- * end
- * d = obj.deconstruct_keys(keys)
- * unless Hash === d
- * goto type_error
- * end
- * if pattern.has_kw_rest_arg_node?
- * d = d.dup
- * end
- * if pattern.has_kw_args_node?
- * pattern.kw_args_node.each |k,|
- * unless d.key?(k)
- * goto match_failed
- * end
- * end
- * pattern.kw_args_node.each |k, pat|
- * if pattern.has_kw_rest_arg_node?
- * unless pat.match?(d.delete(k))
- * goto match_failed
- * end
- * else
- * unless pat.match?(d[k])
- * goto match_failed
- * end
- * end
- * end
- * else
- * unless d.empty?
- * goto match_failed
- * end
- * end
- * if pattern.has_kw_rest_arg_node?
- * if pattern.no_rest_keyword?
- * unless d.empty?
- * goto match_failed
- * end
- * else
- * unless pattern.kw_rest_arg_node.match?(d)
- * goto match_failed
- * end
- * end
- * end
- * true
- * goto fin
- * type_error:
- * FrozenCore.raise TypeError
- * match_failed:
- * false
- * fin:
- */
- LABEL *match_failed, *type_error, *fin;
- VALUE keys = Qnil;
-
- match_failed = NEW_LABEL(line);
- type_error = NEW_LABEL(line);
- fin = NEW_LABEL(line);
-
- if (node->nd_pkwargs && !node->nd_pkwrestarg) {
- const NODE *kw_args = node->nd_pkwargs->nd_head;
- keys = rb_ary_new_capa(kw_args ? kw_args->nd_alen/2 : 0);
- while (kw_args) {
- rb_ary_push(keys, kw_args->nd_head->nd_lit);
- kw_args = kw_args->nd_next->nd_next;
- }
- }
-
- if (node->nd_pconst) {
- ADD_INSN(ret, line, dup);
- CHECK(COMPILE(ret, "constant", node->nd_pconst));
- ADD_INSN1(ret, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
-
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, putobject, ID2SYM(rb_intern("deconstruct_keys")));
- ADD_SEND(ret, line, idRespond_to, INT2FIX(1));
- ADD_INSNL(ret, line, branchunless, match_failed);
-
- if (NIL_P(keys)) {
- ADD_INSN(ret, line, putnil);
- }
- else {
- ADD_INSN1(ret, line, duparray, keys);
- RB_OBJ_WRITTEN(iseq, Qundef, rb_obj_hide(keys));
- }
- ADD_SEND(ret, line, rb_intern("deconstruct_keys"), INT2FIX(1));
-
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, checktype, INT2FIX(T_HASH));
- ADD_INSNL(ret, line, branchunless, type_error);
-
- if (node->nd_pkwrestarg) {
- ADD_SEND(ret, line, rb_intern("dup"), INT2FIX(0));
- }
-
- if (node->nd_pkwargs) {
- int i;
- int keys_num;
- const NODE *args;
- args = node->nd_pkwargs->nd_head;
- if (args) {
- DECL_ANCHOR(match_values);
- INIT_ANCHOR(match_values);
- keys_num = rb_long2int(args->nd_alen) / 2;
- for (i = 0; i < keys_num; i++) {
- NODE *key_node = args->nd_head;
- NODE *value_node = args->nd_next->nd_head;
- VALUE key;
-
- if (nd_type(key_node) != NODE_LIT) {
- UNKNOWN_NODE("NODE_IN", key_node, COMPILE_NG);
- }
- key = key_node->nd_lit;
-
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, putobject, key);
- ADD_SEND(ret, line, rb_intern("key?"), INT2FIX(1));
- ADD_INSNL(ret, line, branchunless, match_failed);
-
- ADD_INSN(match_values, line, dup);
- ADD_INSN1(match_values, line, putobject, key);
- ADD_SEND(match_values, line, node->nd_pkwrestarg ? rb_intern("delete") : idAREF, INT2FIX(1));
- iseq_compile_pattern_each(iseq, match_values, value_node, in_alt_pattern);
- ADD_INSNL(match_values, line, branchunless, match_failed);
- args = args->nd_next->nd_next;
- }
- ADD_SEQ(ret, match_values);
- }
- }
- else {
- ADD_INSN(ret, line, dup);
- ADD_SEND(ret, line, idEmptyP, INT2FIX(0));
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
-
- if (node->nd_pkwrestarg) {
- if (node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
- ADD_INSN(ret, line, dup);
- ADD_SEND(ret, line, idEmptyP, INT2FIX(0));
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
- else {
- ADD_INSN(ret, line, dup);
- iseq_compile_pattern_each(iseq, ret, node->nd_pkwrestarg, in_alt_pattern);
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
- }
-
- ADD_INSN(ret, line, pop);
- ADD_INSN1(ret, line, putobject, Qtrue);
- ADD_INSNL(ret, line, jump, fin);
-
- ADD_LABEL(ret, type_error);
- ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- ADD_INSN1(ret, line, putobject, rb_eTypeError);
- ADD_INSN1(ret, line, putobject, rb_fstring_lit("deconstruct_keys must return Hash"));
- ADD_SEND(ret, line, id_core_raise, INT2FIX(2));
-
- ADD_LABEL(ret, match_failed);
- ADD_INSN(ret, line, pop);
- ADD_INSN1(ret, line, putobject, Qfalse);
-
- ADD_LABEL(ret, fin);
- break;
- }
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DSTR:
- case NODE_DSYM:
- case NODE_DREGX:
- case NODE_LIST:
- case NODE_ZLIST:
- case NODE_LAMBDA:
- case NODE_DOT2:
- case NODE_DOT3:
- case NODE_CONST:
- case NODE_LVAR:
- case NODE_DVAR:
- case NODE_TRUE:
- case NODE_FALSE:
- case NODE_SELF:
- case NODE_NIL:
- case NODE_COLON2:
- case NODE_COLON3:
- CHECK(COMPILE(ret, "case in literal", node));
- ADD_INSN1(ret, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
- break;
- case NODE_LASGN: {
- struct rb_iseq_constant_body *const body = iseq->body;
- ID id = node->nd_vid;
- int idx = body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
-
- if (in_alt_pattern) {
- const char *name = rb_id2name(id);
- if (name && strlen(name) > 0 && name[0] != '_') {
- COMPILE_ERROR(ERROR_ARGS "illegal variable in alternative pattern (%"PRIsVALUE")",
- rb_id2str(id));
- return COMPILE_NG;
- }
- }
-
- ADD_SETLOCAL(ret, line, idx, get_lvar_level(iseq));
- ADD_INSN1(ret, line, putobject, Qtrue);
- break;
- }
- case NODE_DASGN:
- case NODE_DASGN_CURR: {
- int idx, lv, ls;
- ID id = node->nd_vid;
-
- idx = get_dyna_var_idx(iseq, id, &lv, &ls);
-
- if (in_alt_pattern) {
- const char *name = rb_id2name(id);
- if (name && strlen(name) > 0 && name[0] != '_') {
- COMPILE_ERROR(ERROR_ARGS "illegal variable in alternative pattern (%"PRIsVALUE")",
- rb_id2str(id));
- return COMPILE_NG;
- }
- }
-
- if (idx < 0) {
- COMPILE_ERROR(ERROR_ARGS "NODE_DASGN(_CURR): unknown id (%"PRIsVALUE")",
- rb_id2str(id));
- return COMPILE_NG;
- }
- ADD_SETLOCAL(ret, line, ls - idx, lv);
- ADD_INSN1(ret, line, putobject, Qtrue);
- break;
- }
- case NODE_IF:
- case NODE_UNLESS: {
- LABEL *match_failed, *fin;
- match_failed = NEW_LABEL(line);
- fin = NEW_LABEL(line);
- iseq_compile_pattern_each(iseq, ret, node->nd_body, in_alt_pattern);
- ADD_INSNL(ret, line, branchunless, match_failed);
- CHECK(COMPILE(ret, "case in if", node->nd_cond));
- if (nd_type(node) == NODE_IF) {
- ADD_INSNL(ret, line, branchunless, match_failed);
- }
- else {
- ADD_INSNL(ret, line, branchif, match_failed);
- }
- ADD_INSN1(ret, line, putobject, Qtrue);
- ADD_INSNL(ret, line, jump, fin);
-
- ADD_LABEL(ret, match_failed);
- ADD_INSN1(ret, line, putobject, Qfalse);
-
- ADD_LABEL(ret, fin);
- break;
- }
- case NODE_HASH: {
- NODE *n;
- LABEL *match_failed, *fin;
- match_failed = NEW_LABEL(line);
- fin = NEW_LABEL(line);
-
- n = node->nd_head;
- if (! (nd_type(n) == NODE_LIST && n->nd_alen == 2)) {
- COMPILE_ERROR(ERROR_ARGS "unexpected node");
- return COMPILE_NG;
- }
-
- ADD_INSN(ret, line, dup);
- iseq_compile_pattern_each(iseq, ret, n->nd_head, in_alt_pattern);
- ADD_INSNL(ret, line, branchunless, match_failed);
- iseq_compile_pattern_each(iseq, ret, n->nd_next->nd_head, in_alt_pattern);
- ADD_INSNL(ret, line, jump, fin);
-
- ADD_LABEL(ret, match_failed);
- ADD_INSN(ret, line, pop);
- ADD_INSN1(ret, line, putobject, Qfalse);
-
- ADD_LABEL(ret, fin);
- break;
- }
- case NODE_OR: {
- LABEL *match_succeeded, *fin;
- match_succeeded = NEW_LABEL(line);
- fin = NEW_LABEL(line);
-
- ADD_INSN(ret, line, dup);
- iseq_compile_pattern_each(iseq, ret, node->nd_1st, TRUE);
- ADD_INSNL(ret, line, branchif, match_succeeded);
- iseq_compile_pattern_each(iseq, ret, node->nd_2nd, TRUE);
- ADD_INSNL(ret, line, jump, fin);
-
- ADD_LABEL(ret, match_succeeded);
- ADD_INSN(ret, line, pop);
- ADD_INSN1(ret, line, putobject, Qtrue);
-
- ADD_LABEL(ret, fin);
- break;
- }
- default:
- UNKNOWN_NODE("NODE_IN", node, COMPILE_NG);
- }
- return COMPILE_OK;
-}
-
-static int
-compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_node, int popped)
-{
- const NODE *pattern;
- const NODE *node = orig_node;
- LABEL *endlabel, *elselabel;
- DECL_ANCHOR(head);
- DECL_ANCHOR(body_seq);
- DECL_ANCHOR(cond_seq);
- int line, lineno, column, last_lineno, last_column;
- enum node_type type;
- VALUE branches = 0;
-
- INIT_ANCHOR(head);
- INIT_ANCHOR(body_seq);
- INIT_ANCHOR(cond_seq);
-
- CHECK(COMPILE(head, "case base", node->nd_head));
-
- DECL_BRANCH_BASE(branches, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "case");
-
- node = node->nd_body;
- EXPECT_NODE("NODE_CASE3", node, NODE_IN, COMPILE_NG);
- type = nd_type(node);
- line = nd_line(node);
- lineno = nd_first_lineno(node);
- column = nd_first_column(node);
- last_lineno = nd_last_lineno(node);
- last_column = nd_last_column(node);
-
- endlabel = NEW_LABEL(line);
- elselabel = NEW_LABEL(line);
-
- ADD_SEQ(ret, head); /* case VAL */
-
- while (type == NODE_IN) {
- LABEL *l1;
-
- l1 = NEW_LABEL(line);
- ADD_LABEL(body_seq, l1);
- ADD_INSN(body_seq, line, pop);
- ADD_TRACE_BRANCH_COVERAGE(
- body_seq,
- node->nd_body ? nd_first_lineno(node->nd_body) : lineno,
- node->nd_body ? nd_first_column(node->nd_body) : column,
- node->nd_body ? nd_last_lineno(node->nd_body) : last_lineno,
- node->nd_body ? nd_last_column(node->nd_body) : last_column,
- "in",
- branches);
- CHECK(COMPILE_(body_seq, "in body", node->nd_body, popped));
- ADD_INSNL(body_seq, line, jump, endlabel);
-
- pattern = node->nd_head;
- if (pattern) {
- ADD_INSN (cond_seq, nd_line(pattern), dup);
- iseq_compile_pattern_each(iseq, cond_seq, pattern, FALSE);
- ADD_INSNL(cond_seq, nd_line(pattern), branchif, l1);
- }
- else {
- COMPILE_ERROR(ERROR_ARGS "unexpected node");
- return COMPILE_NG;
- }
-
- node = node->nd_next;
- if (!node) {
- break;
- }
- type = nd_type(node);
- line = nd_line(node);
- lineno = nd_first_lineno(node);
- column = nd_first_column(node);
- last_lineno = nd_last_lineno(node);
- last_column = nd_last_column(node);
- }
- /* else */
- if (node) {
- ADD_LABEL(cond_seq, elselabel);
- ADD_INSN(cond_seq, line, pop);
- ADD_TRACE_BRANCH_COVERAGE(cond_seq, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "else", branches);
- CHECK(COMPILE_(cond_seq, "else", node, popped));
- ADD_INSNL(cond_seq, line, jump, endlabel);
- }
- else {
- debugs("== else (implicit)\n");
- ADD_LABEL(cond_seq, elselabel);
- ADD_TRACE_BRANCH_COVERAGE(cond_seq, nd_first_lineno(orig_node), nd_first_column(orig_node), nd_last_lineno(orig_node), nd_last_column(orig_node), "else", branches);
- ADD_INSN1(cond_seq, nd_line(orig_node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- ADD_INSN1(cond_seq, nd_line(orig_node), putobject, rb_eNoMatchingPatternError);
- ADD_INSN1(cond_seq, nd_line(orig_node), topn, INT2FIX(2));
- ADD_SEND(cond_seq, nd_line(orig_node), id_core_raise, INT2FIX(2));
- ADD_INSN(cond_seq, nd_line(orig_node), pop);
- ADD_INSN(cond_seq, nd_line(orig_node), pop);
- if (!popped) {
- ADD_INSN(cond_seq, nd_line(orig_node), putnil);
- }
- ADD_INSNL(cond_seq, nd_line(orig_node), jump, endlabel);
- }
-
- ADD_SEQ(ret, cond_seq);
- ADD_SEQ(ret, body_seq);
- ADD_LABEL(ret, endlabel);
- return COMPILE_OK;
-}
-
-static int
compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const enum node_type type)
{
const int line = (int)nd_line(node);
@@ -6079,7 +4920,7 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
LABEL *prev_end_label = ISEQ_COMPILE_DATA(iseq)->end_label;
LABEL *prev_redo_label = ISEQ_COMPILE_DATA(iseq)->redo_label;
int prev_loopval_popped = ISEQ_COMPILE_DATA(iseq)->loopval_popped;
- VALUE branches = Qfalse;
+ VALUE branches = 0;
struct iseq_compile_data_ensure_node_stack enl;
@@ -6202,41 +5043,45 @@ compile_iter(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
}
static int
-compile_for_masgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
+compile_for(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- /* massign to var in "for"
- * (args.length == 1 && Array.try_convert(args[0])) || args
- */
const int line = nd_line(node);
- const NODE *var = node->nd_var;
- LABEL *not_single = NEW_LABEL(nd_line(var));
- LABEL *not_ary = NEW_LABEL(nd_line(var));
- CHECK(COMPILE(ret, "for var", var));
- ADD_INSN(ret, line, dup);
- ADD_CALL(ret, line, idLength, INT2FIX(0));
- ADD_INSN1(ret, line, putobject, INT2FIX(1));
- ADD_CALL(ret, line, idEq, INT2FIX(1));
- ADD_INSNL(ret, line, branchunless, not_single);
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, putobject, INT2FIX(0));
- ADD_CALL(ret, line, idAREF, INT2FIX(1));
- ADD_INSN1(ret, line, putobject, rb_cArray);
- ADD_INSN(ret, line, swap);
- ADD_CALL(ret, line, rb_intern("try_convert"), INT2FIX(1));
- ADD_INSN(ret, line, dup);
- ADD_INSNL(ret, line, branchunless, not_ary);
- ADD_INSN(ret, line, swap);
- ADD_LABEL(ret, not_ary);
- ADD_INSN(ret, line, pop);
- ADD_LABEL(ret, not_single);
- return COMPILE_OK;
+ if (node->nd_var) {
+ /* massign to var in "for"
+ * args.length == 1 && Array === (tmp = args[0]) ? tmp : args
+ */
+ const NODE *var = node->nd_var;
+ LABEL *not_single = NEW_LABEL(nd_line(var));
+ LABEL *not_ary = NEW_LABEL(nd_line(var));
+ CHECK(COMPILE(ret, "for var", var));
+ ADD_INSN(ret, line, dup);
+ ADD_CALL(ret, line, idLength, INT2FIX(0));
+ ADD_INSN1(ret, line, putobject, INT2FIX(1));
+ ADD_CALL(ret, line, idEq, INT2FIX(1));
+ ADD_INSNL(ret, line, branchunless, not_single);
+ ADD_INSN(ret, line, dup);
+ ADD_INSN1(ret, line, putobject, INT2FIX(0));
+ ADD_CALL(ret, line, idAREF, INT2FIX(1));
+ ADD_INSN1(ret, line, putobject, rb_cArray);
+ ADD_INSN1(ret, line, topn, INT2FIX(1));
+ ADD_CALL(ret, line, idEqq, INT2FIX(1));
+ ADD_INSNL(ret, line, branchunless, not_ary);
+ ADD_INSN(ret, line, swap);
+ ADD_LABEL(ret, not_ary);
+ ADD_INSN(ret, line, pop);
+ ADD_LABEL(ret, not_single);
+ return COMPILE_OK;
+ }
+ else {
+ return compile_iter(iseq, ret, node, popped);
+ }
}
static int
compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
const int line = nd_line(node);
- unsigned long throw_flag = 0;
+ unsigned long level = 0;
if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0) {
/* while/until */
@@ -6257,7 +5102,7 @@ compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
break_by_insn:
/* escape from block */
CHECK(COMPILE(ret, "break val (block)", node->nd_stts));
- ADD_INSN1(ret, line, throw, INT2FIX(throw_flag | TAG_BREAK));
+ ADD_INSN1(ret, line, throw, INT2FIX(level | TAG_BREAK));
if (popped) {
ADD_INSN(ret, line, pop);
}
@@ -6276,11 +5121,13 @@ compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
break;
}
+ level++;
if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
- throw_flag = VM_THROW_NO_ESCAPE_FLAG;
+ level = VM_THROW_NO_ESCAPE_FLAG;
goto break_by_insn;
}
else if (ip->body->type == ISEQ_TYPE_BLOCK) {
+ level <<= VM_THROW_LEVEL_SHIFT;
goto break_by_insn;
}
else if (ip->body->type == ISEQ_TYPE_EVAL) {
@@ -6299,7 +5146,7 @@ static int
compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
const int line = nd_line(node);
- unsigned long throw_flag = 0;
+ unsigned long level = 0;
if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0) {
LABEL *splabel = NEW_LABEL(0);
@@ -6343,7 +5190,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
break;
}
- throw_flag = VM_THROW_NO_ESCAPE_FLAG;
+ level = VM_THROW_NO_ESCAPE_FLAG;
if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
/* while loop */
break;
@@ -6359,7 +5206,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
}
if (ip != 0) {
CHECK(COMPILE(ret, "next val", node->nd_stts));
- ADD_INSN1(ret, line, throw, INT2FIX(throw_flag | TAG_NEXT));
+ ADD_INSN1(ret, line, throw, INT2FIX(level | TAG_NEXT));
if (popped) {
ADD_INSN(ret, line, pop);
@@ -6411,6 +5258,7 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
}
else {
const rb_iseq_t *ip = iseq;
+ const unsigned long level = VM_THROW_NO_ESCAPE_FLAG;
while (ip) {
if (!ISEQ_COMPILE_DATA(ip)) {
@@ -6432,7 +5280,7 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
}
if (ip != 0) {
ADD_INSN(ret, line, putnil);
- ADD_INSN1(ret, line, throw, INT2FIX(VM_THROW_NO_ESCAPE_FLAG | TAG_REDO));
+ ADD_INSN1(ret, line, throw, INT2FIX(level | TAG_REDO));
if (popped) {
ADD_INSN(ret, line, pop);
@@ -6514,7 +5362,7 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
narg = resq->nd_args;
if (narg) {
switch (nd_type(narg)) {
- case NODE_LIST:
+ case NODE_ARRAY:
while (narg) {
ADD_GETLOCAL(ret, line, LVAR_ERRINFO, 0);
CHECK(COMPILE(ret, "rescue arg", narg->nd_head));
@@ -6621,9 +5469,6 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
switch (t) {
case ISEQ_TYPE_TOP:
case ISEQ_TYPE_MAIN:
- if (retval) {
- rb_warn("argument of top-level return is ignored");
- }
if (is == iseq) {
/* plain top-level, leave directly */
type = ISEQ_TYPE_METHOD;
@@ -6661,419 +5506,6 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
return COMPILE_OK;
}
-static int
-compile_evstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
-{
- CHECK(COMPILE_(ret, "nd_body", node, popped));
-
- if (!popped && !all_string_result_p(node)) {
- const int line = nd_line(node);
- const unsigned int flag = VM_CALL_FCALL;
- LABEL *isstr = NEW_LABEL(line);
- ADD_INSN(ret, line, dup);
- ADD_INSN1(ret, line, checktype, INT2FIX(T_STRING));
- ADD_INSNL(ret, line, branchif, isstr);
- ADD_INSN(ret, line, dup);
- ADD_SEND_R(ret, line, idTo_s, INT2FIX(0), NULL, INT2FIX(flag), NULL);
- ADD_INSN(ret, line, tostring);
- ADD_LABEL(ret, isstr);
- }
- return COMPILE_OK;
-}
-
-static LABEL *
-qcall_branch_start(rb_iseq_t *iseq, LINK_ANCHOR *const recv, VALUE *branches, const NODE *node, int line)
-{
- LABEL *else_label = NEW_LABEL(line);
- const int first_lineno = nd_first_lineno(node), first_column = nd_first_column(node);
- const int last_lineno = nd_last_lineno(node), last_column = nd_last_column(node);
- VALUE br = 0;
-
- DECL_BRANCH_BASE(br, first_lineno, first_column, last_lineno, last_column, "&.");
- *branches = br;
- ADD_INSN(recv, line, dup);
- ADD_INSNL(recv, line, branchnil, else_label);
- ADD_TRACE_BRANCH_COVERAGE(recv, first_lineno, first_column, last_lineno, last_column, "then", br);
- return else_label;
-}
-
-static void
-qcall_branch_end(rb_iseq_t *iseq, LINK_ANCHOR *const ret, LABEL *else_label, VALUE branches, const NODE *node, int line)
-{
- LABEL *end_label;
- if (!else_label) return;
- end_label = NEW_LABEL(line);
- ADD_INSNL(ret, line, jump, end_label);
- ADD_LABEL(ret, else_label);
- ADD_TRACE_BRANCH_COVERAGE(ret, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node),
- "else", branches);
- ADD_LABEL(ret, end_label);
-}
-
-static int
-compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int line, int popped)
-{
- /* optimization shortcut
- * "literal".freeze -> opt_str_freeze("literal")
- */
- if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
- (node->nd_mid == idFreeze || node->nd_mid == idUMinus) &&
- node->nd_args == NULL &&
- ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
- ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
- VALUE str = rb_fstring(node->nd_recv->nd_lit);
- if (node->nd_mid == idUMinus) {
- ADD_INSN2(ret, line, opt_str_uminus, str,
- new_callinfo(iseq, idUMinus, 0, 0, NULL, FALSE));
- }
- else {
- ADD_INSN2(ret, line, opt_str_freeze, str,
- new_callinfo(iseq, idFreeze, 0, 0, NULL, FALSE));
- }
- RB_OBJ_WRITTEN(iseq, Qundef, str);
- if (popped) {
- ADD_INSN(ret, line, pop);
- }
- return TRUE;
- }
- /* optimization shortcut
- * obj["literal"] -> opt_aref_with(obj, "literal")
- */
- if (node->nd_mid == idAREF && !private_recv_p(node) && node->nd_args &&
- nd_type(node->nd_args) == NODE_LIST && node->nd_args->nd_alen == 1 &&
- nd_type(node->nd_args->nd_head) == NODE_STR &&
- ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
- !ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
- ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
- VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
- CHECK(COMPILE(ret, "recv", node->nd_recv));
- ADD_INSN2(ret, line, opt_aref_with, str,
- new_callinfo(iseq, idAREF, 1, 0, NULL, FALSE));
- RB_OBJ_WRITTEN(iseq, Qundef, str);
- if (popped) {
- ADD_INSN(ret, line, pop);
- }
- return TRUE;
- }
- return FALSE;
-}
-
-static int
-iseq_has_builtin_function_table(const rb_iseq_t *iseq)
-{
- return ISEQ_COMPILE_DATA(iseq)->builtin_function_table != NULL;
-}
-
-static const struct rb_builtin_function *
-iseq_builtin_function_lookup(const rb_iseq_t *iseq, const char *name)
-{
- int i;
- const struct rb_builtin_function *table = ISEQ_COMPILE_DATA(iseq)->builtin_function_table;
- for (i=0; table[i].index != -1; i++) {
- if (strcmp(table[i].name, name) == 0) {
- return &table[i];
- }
- }
- return NULL;
-}
-
-static const char *
-iseq_builtin_function_name(ID mid)
-{
- const char *name = rb_id2name(mid);
- static const char prefix[] = "__builtin_";
- const size_t prefix_len = sizeof(prefix) - 1;
-
- if (UNLIKELY(strncmp(prefix, name, prefix_len) == 0)) {
- return &name[prefix_len];
- }
- else {
- return NULL;
- }
-}
-
-static int
-delegate_call_p(const rb_iseq_t *iseq, unsigned int argc, const LINK_ANCHOR *args, unsigned int *pstart_index)
-{
-
- if (argc == 0) {
- *pstart_index = 0;
- return TRUE;
- }
- else if (argc <= iseq->body->local_table_size) {
- unsigned int start=0;
-
- // local_table: [p1, p2, p3, l1, l2, l3]
- // arguments: [p3, l1, l2] -> 2
- for (start = 0;
- argc + start <= iseq->body->local_table_size;
- start++) {
- const LINK_ELEMENT *elem = FIRST_ELEMENT(args);
-
- for (unsigned int i=start; i-start<argc; i++) {
- if (elem->type == ISEQ_ELEMENT_INSN &&
- INSN_OF(elem) == BIN(getlocal)) {
- int local_index = FIX2INT(OPERAND_AT(elem, 0));
- int local_level = FIX2INT(OPERAND_AT(elem, 1));
-
- if (local_level == 0) {
- unsigned int index = iseq->body->local_table_size - (local_index - VM_ENV_DATA_SIZE + 1);
- if (0) { // for debug
- fprintf(stderr, "lvar:%s (%d), id:%s (%d) local_index:%d, local_size:%d\n",
- rb_id2name(iseq->body->local_table[i]), i,
- rb_id2name(iseq->body->local_table[index]), index,
- local_index, (int)iseq->body->local_table_size);
- }
- if (i == index) {
- elem = elem->next;
- continue; /* for */
- }
- else {
- goto next;
- }
- }
- else {
- goto fail; // level != 0 is unsupported
- }
- }
- else {
- goto fail; // insn is not a getlocal
- }
- }
- goto success;
- next:;
- }
- fail:
- return FALSE;
- success:
- *pstart_index = start;
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-static int
-compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int type, int line, int popped)
-{
- /* call: obj.method(...)
- * fcall: func(...)
- * vcall: func
- */
- DECL_ANCHOR(recv);
- DECL_ANCHOR(args);
- ID mid = node->nd_mid;
- VALUE argc;
- unsigned int flag = 0;
- struct rb_call_info_kw_arg *keywords = NULL;
- const rb_iseq_t *parent_block = ISEQ_COMPILE_DATA(iseq)->current_block;
- LABEL *else_label = NULL;
- VALUE branches = Qfalse;
-
- ISEQ_COMPILE_DATA(iseq)->current_block = NULL;
-
- INIT_ANCHOR(recv);
- INIT_ANCHOR(args);
-#if OPT_SUPPORT_JOKE
- if (nd_type(node) == NODE_VCALL) {
- ID id_bitblt;
- ID id_answer;
-
- CONST_ID(id_bitblt, "bitblt");
- CONST_ID(id_answer, "the_answer_to_life_the_universe_and_everything");
-
- if (mid == id_bitblt) {
- ADD_INSN(ret, line, bitblt);
- return COMPILE_OK;
- }
- else if (mid == id_answer) {
- ADD_INSN(ret, line, answer);
- return COMPILE_OK;
- }
- }
- /* only joke */
- {
- ID goto_id;
- ID label_id;
-
- CONST_ID(goto_id, "__goto__");
- CONST_ID(label_id, "__label__");
-
- if (nd_type(node) == NODE_FCALL &&
- (mid == goto_id || mid == label_id)) {
- LABEL *label;
- st_data_t data;
- st_table *labels_table = ISEQ_COMPILE_DATA(iseq)->labels_table;
- VALUE label_name;
-
- if (!labels_table) {
- labels_table = st_init_numtable();
- ISEQ_COMPILE_DATA(iseq)->labels_table = labels_table;
- }
- if (nd_type(node->nd_args->nd_head) == NODE_LIT &&
- SYMBOL_P(node->nd_args->nd_head->nd_lit)) {
-
- label_name = node->nd_args->nd_head->nd_lit;
- if (!st_lookup(labels_table, (st_data_t)label_name, &data)) {
- label = NEW_LABEL(line);
- label->position = line;
- st_insert(labels_table, (st_data_t)label_name, (st_data_t)label);
- }
- else {
- label = (LABEL *)data;
- }
- }
- else {
- COMPILE_ERROR(ERROR_ARGS "invalid goto/label format");
- return COMPILE_NG;
- }
-
- if (mid == goto_id) {
- ADD_INSNL(ret, line, jump, label);
- }
- else {
- ADD_LABEL(ret, label);
- }
- return COMPILE_OK;
- }
- }
-#endif
- const char *builtin_func;
- NODE *args_node = node->nd_args;
-
- if (UNLIKELY(iseq_has_builtin_function_table(iseq)) &&
- (builtin_func = iseq_builtin_function_name(mid)) != NULL) {
-
- if (parent_block != NULL) {
- COMPILE_ERROR(iseq, line, "should not call builtins here.");
- return COMPILE_NG;
- }
- else {
- char inline_func[0x20];
- bool cconst = false;
- retry:;
- const struct rb_builtin_function *bf = iseq_builtin_function_lookup(iseq, builtin_func);
-
- if (bf == NULL) {
- if (strcmp("cstmt!", builtin_func) == 0 ||
- strcmp("cexpr!", builtin_func) == 0) {
- inlinec:;
- int inline_index = GET_VM()->builtin_inline_index++;
- snprintf(inline_func, 0x20, "_bi%d", inline_index);
- builtin_func = inline_func;
- args_node = NULL;
- goto retry;
- }
- else if (strcmp("cconst!", builtin_func) == 0) {
- cconst = true;
- goto inlinec;
- }
- else if (strcmp("cinit!", builtin_func) == 0) {
- // ignore
- GET_VM()->builtin_inline_index++;
- return COMPILE_OK;
- }
-
- if (1) {
- rb_bug("can't find builtin function:%s", builtin_func);
- }
- else {
- COMPILE_ERROR(ERROR_ARGS "can't find builtin function:%s", builtin_func);
- }
- return COMPILE_NG;
- }
-
- if (cconst) {
- typedef VALUE(*builtin_func0)(void *, VALUE);
- VALUE const_val = (*(builtin_func0)bf->func_ptr)(NULL, Qnil);
- ADD_INSN1(ret, line, putobject, const_val);
- return COMPILE_OK;
- }
-
- // fprintf(stderr, "func_name:%s -> %p\n", builtin_func, bf->func_ptr);
-
- argc = setup_args(iseq, args, args_node, &flag, &keywords);
-
- if (FIX2INT(argc) != bf->argc) {
- COMPILE_ERROR(ERROR_ARGS "argc is not match for builtin function:%s (expect %d but %d)",
- builtin_func, bf->argc, FIX2INT(argc));
- return COMPILE_NG;
- }
-
- unsigned int start_index;
- if (delegate_call_p(iseq, FIX2INT(argc), args, &start_index)) {
- ADD_INSN2(ret, line, opt_invokebuiltin_delegate, bf, INT2FIX(start_index));
- }
- else {
- ADD_SEQ(ret, args);
- ADD_INSN1(ret,line, invokebuiltin, bf);
- }
-
- if (popped) ADD_INSN(ret, line, pop);
- return COMPILE_OK;
- }
- }
-
-
- /* receiver */
- if (type == NODE_CALL || type == NODE_OPCALL || type == NODE_QCALL) {
- int idx, level;
-
- if (mid == idCall &&
- nd_type(node->nd_recv) == NODE_LVAR &&
- iseq_block_param_id_p(iseq, node->nd_recv->nd_vid, &idx, &level)) {
- ADD_INSN2(recv, nd_line(node->nd_recv), getblockparamproxy, INT2FIX(idx + VM_ENV_DATA_SIZE - 1), INT2FIX(level));
- }
- else if (private_recv_p(node)) {
- ADD_INSN(recv, nd_line(node), putself);
- flag |= VM_CALL_FCALL;
- }
- else {
- CHECK(COMPILE(recv, "recv", node->nd_recv));
- }
-
- if (type == NODE_QCALL) {
- else_label = qcall_branch_start(iseq, recv, &branches, node, line);
- }
- }
- else if (type == NODE_FCALL || type == NODE_VCALL) {
- ADD_CALL_RECEIVER(recv, line);
- }
-
- /* args */
- if (type != NODE_VCALL) {
- argc = setup_args(iseq, args, node->nd_args, &flag, &keywords);
- CHECK(!NIL_P(argc));
- }
- else {
- argc = INT2FIX(0);
- }
-
- ADD_SEQ(ret, recv);
- ADD_SEQ(ret, args);
-
- debugp_param("call args argc", argc);
- debugp_param("call method", ID2SYM(mid));
-
- switch ((int)type) {
- case NODE_VCALL:
- flag |= VM_CALL_VCALL;
- /* VCALL is funcall, so fall through */
- case NODE_FCALL:
- flag |= VM_CALL_FCALL;
- }
-
- ADD_SEND_R(ret, line, mid, argc, parent_block, INT2FIX(flag), keywords);
-
- qcall_branch_end(iseq, ret, else_label, branches, node, line);
- if (popped) {
- ADD_INSN(ret, line, pop);
- }
- return COMPILE_OK;
-}
-
-
static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped);
/**
compile each node
@@ -7086,55 +5518,31 @@ static int
iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *node, int popped)
{
if (node == 0) {
- if (!popped) {
- int lineno = ISEQ_COMPILE_DATA(iseq)->last_line;
- if (lineno == 0) lineno = FIX2INT(rb_iseq_first_lineno(iseq));
- debugs("node: NODE_NIL(implicit)\n");
- ADD_INSN(ret, lineno, putnil);
- }
- return COMPILE_OK;
+ if (!popped) {
+ int lineno = ISEQ_COMPILE_DATA(iseq)->last_line;
+ if (lineno == 0) lineno = FIX2INT(rb_iseq_first_lineno(iseq));
+ debugs("node: NODE_NIL(implicit)\n");
+ ADD_INSN(ret, lineno, putnil);
+ }
+ return COMPILE_OK;
}
return iseq_compile_each0(iseq, ret, node, popped);
}
static int
-check_yield_place(const rb_iseq_t *iseq, int line)
-{
- VALUE file;
- switch (iseq->body->local_iseq->body->type) {
- case ISEQ_TYPE_TOP:
- case ISEQ_TYPE_MAIN:
- return FALSE;
- case ISEQ_TYPE_CLASS:
- file = rb_iseq_path(iseq);
- if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) {
- rb_compile_warn(RSTRING_PTR(file), line,
- "`yield' in class syntax will not be supported from Ruby 3.0. [Feature #15575]");
- }
- return TRUE;
- default:
- return TRUE;
- }
-}
-
-static int
iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped)
{
const int line = (int)nd_line(node);
const enum node_type type = nd_type(node);
- struct rb_iseq_constant_body *const body = iseq->body;
if (ISEQ_COMPILE_DATA(iseq)->last_line == line) {
/* ignore */
}
else {
if (node->flags & NODE_FL_NEWLINE) {
- int event = RUBY_EVENT_LINE;
ISEQ_COMPILE_DATA(iseq)->last_line = line;
- if (ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) {
- event |= RUBY_EVENT_COVERAGE_LINE;
- }
- ADD_TRACE(ret, event);
+ ADD_TRACE_LINE_COVERAGE(ret, line);
+ ADD_TRACE(ret, RUBY_EVENT_LINE);
}
}
@@ -7164,20 +5572,16 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
case NODE_CASE2:
CHECK(compile_case2(iseq, ret, node, popped));
break;
- case NODE_CASE3:
- CHECK(compile_case3(iseq, ret, node, popped));
- break;
case NODE_WHILE:
case NODE_UNTIL:
CHECK(compile_loop(iseq, ret, node, popped, type));
break;
case NODE_FOR:
+ CHECK(compile_for(iseq, ret, node, popped));
+ break;
case NODE_ITER:
CHECK(compile_iter(iseq, ret, node, popped));
break;
- case NODE_FOR_MASGN:
- CHECK(compile_for_masgn(iseq, ret, node, popped));
- break;
case NODE_BREAK:
CHECK(compile_break(iseq, ret, node, popped));
break;
@@ -7232,7 +5636,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
case NODE_LASGN:{
ID id = node->nd_vid;
- int idx = body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
+ int idx = iseq->body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
debugs("lvar: %s idx: %d\n", rb_id2name(id), idx);
CHECK(COMPILE(ret, "rvalue", node->nd_value));
@@ -7285,20 +5689,20 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
break;
}
case NODE_CDECL:{
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ CHECK(COMPILE(ret, "lvalue", node->nd_value));
- if (!popped) {
- ADD_INSN(ret, line, dup);
- }
+ if (!popped) {
+ ADD_INSN(ret, line, dup);
+ }
if (node->nd_vid) {
ADD_INSN1(ret, line, putspecialobject,
INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
- ADD_INSN1(ret, line, setconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(ret, line, setconstant, ID2SYM(node->nd_vid));
}
else {
compile_cpath(ret, iseq, node->nd_else);
- ADD_INSN1(ret, line, setconstant, ID2SYM(node->nd_else->nd_mid));
+ ADD_INSN1(ret, line, setconstant, ID2SYM(node->nd_else->nd_mid));
}
break;
}
@@ -7312,9 +5716,10 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
break;
}
case NODE_OP_ASGN1: {
+ DECL_ANCHOR(args);
VALUE argc;
unsigned int flag = 0;
- int asgnflag = 0;
+ unsigned int asgnflag = 0;
ID id = node->nd_mid;
int boff = 0;
@@ -7345,24 +5750,25 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN(ret, line, putnil);
}
asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN1 recv", node);
- CHECK(asgnflag != -1);
switch (nd_type(node->nd_args->nd_head)) {
- case NODE_ZLIST:
+ case NODE_ZARRAY:
argc = INT2FIX(0);
break;
case NODE_BLOCK_PASS:
boff = 1;
- /* fall through */
default:
- argc = setup_args(iseq, ret, node->nd_args->nd_head, &flag, NULL);
+ INIT_ANCHOR(args);
+ argc = setup_args(iseq, args, node->nd_args->nd_head, &flag, NULL);
CHECK(!NIL_P(argc));
+ ADD_SEQ(ret, args);
}
ADD_INSN1(ret, line, dupn, FIXNUM_INC(argc, 1 + boff));
- flag |= asgnflag;
ADD_SEND_WITH_FLAG(ret, line, idAREF, argc, INT2FIX(flag));
+ flag |= asgnflag;
- if (id == idOROP || id == idANDOP) {
- /* a[x] ||= y or a[x] &&= y
+ if (id == 0 || id == 1) {
+ /* 0: or, 1: and
+ a[x] ||= y
unless/if a[x]
a[x]= y
@@ -7374,10 +5780,12 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
LABEL *lfin = NEW_LABEL(line);
ADD_INSN(ret, line, dup);
- if (id == idOROP) {
+ if (id == 0) {
+ /* or */
ADD_INSNL(ret, line, branchif, label);
}
- else { /* idANDOP */
+ else {
+ /* and */
ADD_INSNL(ret, line, branchunless, label);
}
ADD_INSN(ret, line, pop);
@@ -7449,7 +5857,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
case NODE_OP_ASGN2:{
ID atype = node->nd_next->nd_mid;
ID vid = node->nd_next->nd_vid, aid = rb_id_attrset(vid);
- int asgnflag;
+ VALUE asgnflag;
LABEL *lfin = NEW_LABEL(line);
LABEL *lcfin = NEW_LABEL(line);
LABEL *lskip = 0;
@@ -7496,21 +5904,20 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
*/
asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node);
- CHECK(asgnflag != -1);
if (node->nd_next->nd_aid) {
lskip = NEW_LABEL(line);
ADD_INSN(ret, line, dup);
ADD_INSNL(ret, line, branchnil, lskip);
}
ADD_INSN(ret, line, dup);
- ADD_SEND_WITH_FLAG(ret, line, vid, INT2FIX(0), INT2FIX(asgnflag));
+ ADD_SEND(ret, line, vid, INT2FIX(0));
- if (atype == idOROP || atype == idANDOP) {
+ if (atype == 0 || atype == 1) { /* 0: OR or 1: AND */
ADD_INSN(ret, line, dup);
- if (atype == idOROP) {
+ if (atype == 0) {
ADD_INSNL(ret, line, branchif, lcfin);
}
- else { /* idANDOP */
+ else {
ADD_INSNL(ret, line, branchunless, lcfin);
}
ADD_INSN(ret, line, pop);
@@ -7570,23 +5977,22 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
mid = node->nd_head->nd_mid;
/* cref */
- if (node->nd_aid == idOROP) {
+ if (node->nd_aid == 0) {
lassign = NEW_LABEL(line);
ADD_INSN(ret, line, dup); /* cref cref */
- ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST_FROM),
+ ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST),
ID2SYM(mid), Qfalse); /* cref bool */
ADD_INSNL(ret, line, branchunless, lassign); /* cref */
}
ADD_INSN(ret, line, dup); /* cref cref */
- ADD_INSN1(ret, line, putobject, Qtrue);
- ADD_INSN1(ret, line, getconstant, ID2SYM(mid)); /* cref obj */
+ ADD_INSN1(ret, line, getconstant, ID2SYM(mid)); /* cref obj */
- if (node->nd_aid == idOROP || node->nd_aid == idANDOP) {
+ if (node->nd_aid == 0 || node->nd_aid == 1) {
lfin = NEW_LABEL(line);
if (!popped) ADD_INSN(ret, line, dup); /* cref [obj] obj */
- if (node->nd_aid == idOROP)
+ if (node->nd_aid == 0)
ADD_INSNL(ret, line, branchif, lfin);
- else /* idANDOP */
+ else
ADD_INSNL(ret, line, branchunless, lfin);
/* cref [obj] */
if (!popped) ADD_INSN(ret, line, pop); /* cref */
@@ -7659,18 +6065,187 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
break;
}
- case NODE_CALL: /* obj.foo */
- case NODE_OPCALL: /* foo[] */
- if (compile_call_precheck_freeze(iseq, ret, node, line, popped) == TRUE) {
- break;
- }
- case NODE_QCALL: /* obj&.foo */
- case NODE_FCALL: /* foo() */
- case NODE_VCALL: /* foo (variable or call) */
- if (compile_call(iseq, ret, node, type, line, popped) == COMPILE_NG) {
- goto ng;
- }
- break;
+ case NODE_CALL:
+ case NODE_OPCALL:
+ /* optimization shortcut
+ * "literal".freeze -> opt_str_freeze("literal")
+ */
+ if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
+ (node->nd_mid == idFreeze || node->nd_mid == idUMinus) &&
+ node->nd_args == NULL &&
+ ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
+ ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
+ VALUE str = freeze_literal(iseq, node->nd_recv->nd_lit);
+ if (node->nd_mid == idUMinus) {
+ ADD_INSN1(ret, line, opt_str_uminus, str);
+ }
+ else {
+ ADD_INSN1(ret, line, opt_str_freeze, str);
+ }
+ if (popped) {
+ ADD_INSN(ret, line, pop);
+ }
+ break;
+ }
+ /* optimization shortcut
+ * obj["literal"] -> opt_aref_with(obj, "literal")
+ */
+ if (node->nd_mid == idAREF && !private_recv_p(node) && node->nd_args &&
+ nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 1 &&
+ nd_type(node->nd_args->nd_head) == NODE_STR &&
+ ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
+ !ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
+ ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
+ VALUE str = freeze_literal(iseq, node->nd_args->nd_head->nd_lit);
+ CHECK(COMPILE(ret, "recv", node->nd_recv));
+ ADD_INSN3(ret, line, opt_aref_with,
+ new_callinfo(iseq, idAREF, 1, 0, NULL, FALSE),
+ NULL/* CALL_CACHE */, str);
+ if (popped) {
+ ADD_INSN(ret, line, pop);
+ }
+ break;
+ }
+ case NODE_QCALL:
+ case NODE_FCALL:
+ case NODE_VCALL:{ /* VCALL: variable or call */
+ /*
+ call: obj.method(...)
+ fcall: func(...)
+ vcall: func
+ */
+ DECL_ANCHOR(recv);
+ DECL_ANCHOR(args);
+ LABEL *else_label = 0;
+ LABEL *end_label = 0;
+ VALUE branches = 0;
+ ID mid = node->nd_mid;
+ VALUE argc;
+ unsigned int flag = 0;
+ struct rb_call_info_kw_arg *keywords = NULL;
+ const rb_iseq_t *parent_block = ISEQ_COMPILE_DATA(iseq)->current_block;
+ ISEQ_COMPILE_DATA(iseq)->current_block = NULL;
+
+ INIT_ANCHOR(recv);
+ INIT_ANCHOR(args);
+#if SUPPORT_JOKE
+ if (nd_type(node) == NODE_VCALL) {
+ ID id_bitblt;
+ ID id_answer;
+
+ CONST_ID(id_bitblt, "bitblt");
+ CONST_ID(id_answer, "the_answer_to_life_the_universe_and_everything");
+
+ if (mid == id_bitblt) {
+ ADD_INSN(ret, line, bitblt);
+ break;
+ }
+ else if (mid == id_answer) {
+ ADD_INSN(ret, line, answer);
+ break;
+ }
+ }
+ /* only joke */
+ {
+ ID goto_id;
+ ID label_id;
+
+ CONST_ID(goto_id, "__goto__");
+ CONST_ID(label_id, "__label__");
+
+ if (nd_type(node) == NODE_FCALL &&
+ (mid == goto_id || mid == label_id)) {
+ LABEL *label;
+ st_data_t data;
+ st_table *labels_table = ISEQ_COMPILE_DATA(iseq)->labels_table;
+ VALUE label_name;
+
+ if (!labels_table) {
+ labels_table = st_init_numtable();
+ ISEQ_COMPILE_DATA(iseq)->labels_table = labels_table;
+ }
+ if (nd_type(node->nd_args->nd_head) == NODE_LIT &&
+ SYMBOL_P(node->nd_args->nd_head->nd_lit)) {
+
+ label_name = node->nd_args->nd_head->nd_lit;
+ if (!st_lookup(labels_table, (st_data_t)label_name, &data)) {
+ label = NEW_LABEL(line);
+ label->position = line;
+ st_insert(labels_table, (st_data_t)label_name, (st_data_t)label);
+ }
+ else {
+ label = (LABEL *)data;
+ }
+ }
+ else {
+ COMPILE_ERROR(ERROR_ARGS "invalid goto/label format");
+ goto ng;
+ }
+
+
+ if (mid == goto_id) {
+ ADD_INSNL(ret, line, jump, label);
+ }
+ else {
+ ADD_LABEL(ret, label);
+ }
+ break;
+ }
+ }
+#endif
+ /* receiver */
+ if (type == NODE_CALL || type == NODE_OPCALL || type == NODE_QCALL) {
+ CHECK(COMPILE(recv, "recv", node->nd_recv));
+ if (type == NODE_QCALL) {
+ else_label = NEW_LABEL(line);
+ end_label = NEW_LABEL(line);
+
+ DECL_BRANCH_BASE(branches, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "&.");
+ ADD_INSN(recv, line, dup);
+ ADD_INSNL(recv, line, branchnil, else_label);
+ ADD_TRACE_BRANCH_COVERAGE(recv, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "then", branches);
+ }
+ }
+ else if (type == NODE_FCALL || type == NODE_VCALL) {
+ ADD_CALL_RECEIVER(recv, line);
+ }
+
+ /* args */
+ if (type != NODE_VCALL) {
+ argc = setup_args(iseq, args, node->nd_args, &flag, &keywords);
+ CHECK(!NIL_P(argc));
+ }
+ else {
+ argc = INT2FIX(0);
+ }
+
+ ADD_SEQ(ret, recv);
+ ADD_SEQ(ret, args);
+
+ debugp_param("call args argc", argc);
+ debugp_param("call method", ID2SYM(mid));
+
+ switch ((int)type) {
+ case NODE_VCALL:
+ flag |= VM_CALL_VCALL;
+ /* VCALL is funcall, so fall through */
+ case NODE_FCALL:
+ flag |= VM_CALL_FCALL;
+ }
+
+ ADD_SEND_R(ret, line, mid, argc, parent_block, INT2FIX(flag), keywords);
+
+ if (else_label && end_label) {
+ ADD_INSNL(ret, line, jump, end_label);
+ ADD_LABEL(ret, else_label);
+ ADD_TRACE_BRANCH_COVERAGE(ret, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "else", branches);
+ ADD_LABEL(ret, end_label);
+ }
+ if (popped) {
+ ADD_INSN(ret, line, pop);
+ }
+ break;
+ }
case NODE_SUPER:
case NODE_ZSUPER:{
DECL_ANCHOR(args);
@@ -7689,48 +6264,46 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
else {
/* NODE_ZSUPER */
int i;
- const rb_iseq_t *liseq = body->local_iseq;
- const struct rb_iseq_constant_body *const local_body = liseq->body;
- const struct rb_iseq_param_keyword *const local_kwd = local_body->param.keyword;
+ const rb_iseq_t *liseq = iseq->body->local_iseq;
int lvar_level = get_lvar_level(iseq);
- argc = local_body->param.lead_num;
+ argc = liseq->body->param.lead_num;
/* normal arguments */
- for (i = 0; i < local_body->param.lead_num; i++) {
- int idx = local_body->local_table_size - i;
+ for (i = 0; i < liseq->body->param.lead_num; i++) {
+ int idx = liseq->body->local_table_size - i;
ADD_GETLOCAL(args, line, idx, lvar_level);
}
- if (local_body->param.flags.has_opt) {
+ if (liseq->body->param.flags.has_opt) {
/* optional arguments */
int j;
- for (j = 0; j < local_body->param.opt_num; j++) {
- int idx = local_body->local_table_size - (i + j);
+ for (j = 0; j < liseq->body->param.opt_num; j++) {
+ int idx = liseq->body->local_table_size - (i + j);
ADD_GETLOCAL(args, line, idx, lvar_level);
}
i += j;
argc = i;
}
- if (local_body->param.flags.has_rest) {
+ if (liseq->body->param.flags.has_rest) {
/* rest argument */
- int idx = local_body->local_table_size - local_body->param.rest_start;
+ int idx = liseq->body->local_table_size - liseq->body->param.rest_start;
ADD_GETLOCAL(args, line, idx, lvar_level);
ADD_INSN1(args, line, splatarray, Qfalse);
- argc = local_body->param.rest_start + 1;
+ argc = liseq->body->param.rest_start + 1;
flag |= VM_CALL_ARGS_SPLAT;
}
- if (local_body->param.flags.has_post) {
+ if (liseq->body->param.flags.has_post) {
/* post arguments */
- int post_len = local_body->param.post_num;
- int post_start = local_body->param.post_start;
+ int post_len = liseq->body->param.post_num;
+ int post_start = liseq->body->param.post_start;
- if (local_body->param.flags.has_rest) {
+ if (liseq->body->param.flags.has_rest) {
int j;
for (j=0; j<post_len; j++) {
- int idx = local_body->local_table_size - (post_start + j);
+ int idx = liseq->body->local_table_size - (post_start + j);
ADD_GETLOCAL(args, line, idx, lvar_level);
}
ADD_INSN1(args, line, newarray, INT2FIX(j));
@@ -7740,61 +6313,61 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
else {
int j;
for (j=0; j<post_len; j++) {
- int idx = local_body->local_table_size - (post_start + j);
+ int idx = liseq->body->local_table_size - (post_start + j);
ADD_GETLOCAL(args, line, idx, lvar_level);
}
argc = post_len + post_start;
}
}
- if (local_body->param.flags.has_kw) { /* TODO: support keywords */
- int local_size = local_body->local_table_size;
+ if (liseq->body->param.flags.has_kw) { /* TODO: support keywords */
+ int local_size = liseq->body->local_table_size;
argc++;
ADD_INSN1(args, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- if (local_body->param.flags.has_kwrest) {
- int idx = local_body->local_table_size - local_kwd->rest_start;
+ if (liseq->body->param.flags.has_kwrest) {
+ int idx = liseq->body->local_table_size - liseq->body->param.keyword->rest_start;
ADD_GETLOCAL(args, line, idx, lvar_level);
ADD_SEND (args, line, rb_intern("dup"), INT2FIX(0));
}
else {
ADD_INSN1(args, line, newhash, INT2FIX(0));
}
- for (i = 0; i < local_kwd->num; ++i) {
- ID id = local_kwd->table[i];
+ for (i = 0; i < liseq->body->param.keyword->num; ++i) {
+ ID id = liseq->body->param.keyword->table[i];
int idx = local_size - get_local_var_idx(liseq, id);
ADD_INSN1(args, line, putobject, ID2SYM(id));
ADD_GETLOCAL(args, line, idx, lvar_level);
}
ADD_SEND(args, line, id_core_hash_merge_ptr, INT2FIX(i * 2 + 1));
- if (local_body->param.flags.has_rest) {
+ if (liseq->body->param.flags.has_rest) {
ADD_INSN1(args, line, newarray, INT2FIX(1));
ADD_INSN (args, line, concatarray);
--argc;
}
- flag |= VM_CALL_KW_SPLAT;
}
- else if (local_body->param.flags.has_kwrest) {
- int idx = local_body->local_table_size - local_kwd->rest_start;
+ else if (liseq->body->param.flags.has_kwrest) {
+ int idx = liseq->body->local_table_size - liseq->body->param.keyword->rest_start;
ADD_GETLOCAL(args, line, idx, lvar_level);
ADD_SEND (args, line, rb_intern("dup"), INT2FIX(0));
- if (local_body->param.flags.has_rest) {
+ if (liseq->body->param.flags.has_rest) {
ADD_INSN1(args, line, newarray, INT2FIX(1));
ADD_INSN (args, line, concatarray);
}
else {
argc++;
}
- flag |= VM_CALL_KW_SPLAT;
}
}
- ADD_INSN(ret, line, putself);
+ /* dummy receiver */
+ ADD_INSN1(ret, line, putobject, type == NODE_ZSUPER ? Qfalse : Qtrue);
ADD_SEQ(ret, args);
- ADD_INSN2(ret, line, invokesuper,
- new_callinfo(iseq, 0, argc, flag | VM_CALL_SUPER | (type == NODE_ZSUPER ? VM_CALL_ZSUPER : 0) | VM_CALL_FCALL, keywords, parent_block != NULL),
+ ADD_INSN3(ret, line, invokesuper,
+ new_callinfo(iseq, 0, argc, flag | VM_CALL_SUPER | VM_CALL_FCALL, keywords, parent_block != NULL),
+ Qnil, /* CALL_CACHE */
parent_block);
if (popped) {
@@ -7802,11 +6375,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
break;
}
- case NODE_LIST:{
- CHECK(compile_array(iseq, ret, node, popped) >= 0);
+ case NODE_ARRAY:{
+ CHECK(compile_array(iseq, ret, node, COMPILE_ARRAY_TYPE_ARRAY, NULL, NULL, popped) >= 0);
break;
}
- case NODE_ZLIST:{
+ case NODE_ZARRAY:{
if (!popped) {
ADD_INSN1(ret, line, newarray, INT2FIX(0));
}
@@ -7824,9 +6397,29 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN1(ret, line, newarray, INT2FIX(node->nd_alen));
break;
}
- case NODE_HASH:
- CHECK(compile_hash(iseq, ret, node, popped) >= 0);
- break;
+ case NODE_HASH:{
+ DECL_ANCHOR(list);
+ enum node_type type = node->nd_head ? nd_type(node->nd_head) : NODE_ZARRAY;
+
+ INIT_ANCHOR(list);
+ switch (type) {
+ case NODE_ARRAY:
+ CHECK(compile_array(iseq, list, node->nd_head, COMPILE_ARRAY_TYPE_HASH, NULL, NULL, popped) >= 0);
+ ADD_SEQ(ret, list);
+ break;
+
+ case NODE_ZARRAY:
+ if (popped) break;
+ ADD_INSN1(ret, line, newhash, INT2FIX(0));
+ break;
+
+ default:
+ COMPILE_ERROR(ERROR_ARGS_AT(node->nd_head) "can't make hash with this node: %s",
+ ruby_node_name(type));
+ goto ng;
+ }
+ break;
+ }
case NODE_RETURN:
CHECK(compile_return(iseq, ret, node, popped));
break;
@@ -7837,11 +6430,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
struct rb_call_info_kw_arg *keywords = NULL;
INIT_ANCHOR(args);
-
- if (check_yield_place(iseq, line) == FALSE) {
+ if (iseq->body->type == ISEQ_TYPE_TOP ||
+ iseq->body->type == ISEQ_TYPE_MAIN) {
COMPILE_ERROR(ERROR_ARGS "Invalid yield");
- goto ng;
- }
+ goto ng;
+ }
if (node->nd_head) {
argc = setup_args(iseq, args, node->nd_head, &flag, &keywords);
@@ -7862,7 +6455,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
case NODE_LVAR:{
if (!popped) {
ID id = node->nd_vid;
- int idx = body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
+ int idx = iseq->body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
debugs("id: %s idx: %d\n", rb_id2name(id), idx);
ADD_GETLOCAL(ret, line, idx, get_lvar_level(iseq));
@@ -7905,18 +6498,16 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
LABEL *lend = NEW_LABEL(line);
- int ic_index = body->is_size++;
+ int ic_index = iseq->body->is_size++;
- ADD_INSN2(ret, line, opt_getinlinecache, lend, INT2FIX(ic_index));
- ADD_INSN1(ret, line, putobject, Qtrue);
- ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_vid));
- ADD_INSN1(ret, line, opt_setinlinecache, INT2FIX(ic_index));
+ ADD_INSN2(ret, line, getinlinecache, lend, INT2FIX(ic_index));
+ ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(ret, line, setinlinecache, INT2FIX(ic_index));
ADD_LABEL(ret, lend);
}
else {
ADD_INSN(ret, line, putnil);
- ADD_INSN1(ret, line, putobject, Qtrue);
- ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_vid));
}
if (popped) {
@@ -7973,9 +6564,26 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
break;
}
- ADD_SEQ(ret, recv);
- ADD_SEQ(ret, val);
- ADD_SEND(ret, line, idEqTilde, INT2FIX(1));
+ if (ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
+ /* TODO: detect by node */
+ if (recv->last == recv->anchor.next &&
+ INSN_OF(recv->last) == BIN(putobject) &&
+ nd_type(node) == NODE_MATCH2) {
+ ADD_SEQ(ret, val);
+ ADD_INSN1(ret, line, opt_regexpmatch1,
+ OPERAND_AT(recv->last, 0));
+ }
+ else {
+ ADD_SEQ(ret, recv);
+ ADD_SEQ(ret, val);
+ ADD_INSN2(ret, line, opt_regexpmatch2, new_callinfo(iseq, idEqTilde, 1, 0, NULL, FALSE), Qnil);
+ }
+ }
+ else {
+ ADD_SEQ(ret, recv);
+ ADD_SEQ(ret, val);
+ ADD_SEND(ret, line, idEqTilde, INT2FIX(1));
+ }
if (node->nd_args) {
compile_named_capture_assign(iseq, ret, node->nd_args);
@@ -7998,9 +6606,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
if (!popped) {
VALUE lit = node->nd_lit;
if (!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) {
- lit = rb_fstring(lit);
+ lit = freeze_literal(iseq, lit);
ADD_INSN1(ret, line, putstring, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
else {
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
@@ -8013,7 +6620,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
lit = rb_fstring(lit);
}
ADD_INSN1(ret, line, putobject, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ iseq_add_mark_object_compile_time(iseq, lit);
}
}
break;
@@ -8029,20 +6636,16 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
VALUE debug_info = Qnil;
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX(line));
+ iseq_add_mark_object_compile_time(iseq, rb_obj_freeze(debug_info));
}
ADD_INSN1(ret, line, freezestring, debug_info);
- if (!NIL_P(debug_info)) {
- RB_OBJ_WRITTEN(iseq, Qundef, rb_obj_freeze(debug_info));
- }
}
}
break;
}
case NODE_XSTR:{
ADD_CALL_RECEIVER(ret, line);
- VALUE str = rb_fstring(node->nd_lit);
- ADD_INSN1(ret, line, putobject, str);
- RB_OBJ_WRITTEN(iseq, Qundef, str);
+ ADD_INSN1(ret, line, putobject, freeze_literal(iseq, node->nd_lit));
ADD_CALL(ret, line, idBackquote, INT2FIX(1));
if (popped) {
@@ -8060,9 +6663,25 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
break;
}
- case NODE_EVSTR:
- CHECK(compile_evstr(iseq, ret, node->nd_body, popped));
+ case NODE_EVSTR:{
+ CHECK(COMPILE(ret, "nd_body", node->nd_body));
+
+ if (popped) {
+ ADD_INSN(ret, line, pop);
+ }
+ else if (!all_string_result_p(node->nd_body)) {
+ const unsigned int flag = VM_CALL_FCALL;
+ LABEL *isstr = NEW_LABEL(line);
+ ADD_INSN(ret, line, dup);
+ ADD_INSN2(ret, line, branchiftype, INT2FIX(T_STRING), isstr);
+ LABEL_REF(isstr);
+ ADD_INSN(ret, line, dup);
+ ADD_SEND_R(ret, line, idTo_s, INT2FIX(0), NULL, INT2FIX(flag), NULL);
+ ADD_INSN(ret, line, tostring);
+ ADD_LABEL(ret, isstr);
+ }
break;
+ }
case NODE_DREGX:{
compile_dregx(iseq, ret, node);
@@ -8071,13 +6690,12 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
break;
}
- case NODE_ONCE:{
- int ic_index = body->is_size++;
- const rb_iseq_t *block_iseq;
- block_iseq = NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_PLAIN, line);
+ case NODE_SCOPE:{
+ int ic_index = iseq->body->is_size++;
+ const rb_iseq_t *block_iseq = NEW_CHILD_ISEQ(node, make_name_for_block(iseq),
+ ISEQ_TYPE_ONCE_GUARD, line);
ADD_INSN2(ret, line, once, block_iseq, INT2FIX(ic_index));
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)block_iseq);
if (popped) {
ADD_INSN(ret, line, pop);
@@ -8125,35 +6743,39 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
break;
}
case NODE_DEFN:{
- ID mid = node->nd_mid;
const rb_iseq_t *method_iseq = NEW_ISEQ(node->nd_defn,
- rb_id2str(mid),
+ rb_id2str(node->nd_mid),
ISEQ_TYPE_METHOD, line);
debugp_param("defn/iseq", rb_iseqw_new(method_iseq));
- ADD_INSN2(ret, line, definemethod, ID2SYM(mid), method_iseq);
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)method_iseq);
- if (!popped) {
- ADD_INSN1(ret, line, putobject, ID2SYM(mid));
+ ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid));
+ ADD_INSN1(ret, line, putiseq, method_iseq);
+ ADD_SEND (ret, line, id_core_define_method, INT2FIX(2));
+
+ if (popped) {
+ ADD_INSN(ret, line, pop);
}
break;
}
case NODE_DEFS:{
- ID mid = node->nd_mid;
- const rb_iseq_t * singleton_method_iseq = NEW_ISEQ(node->nd_defn,
- rb_id2str(mid),
- ISEQ_TYPE_METHOD, line);
+ const rb_iseq_t * singleton_method = NEW_ISEQ(node->nd_defn,
+ rb_id2str(node->nd_mid),
+ ISEQ_TYPE_METHOD, line);
- debugp_param("defs/iseq", rb_iseqw_new(singleton_method_iseq));
- CHECK(COMPILE(ret, "defs: recv", node->nd_recv));
- ADD_INSN2(ret, line, definesmethod, ID2SYM(mid), singleton_method_iseq);
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)singleton_method_iseq);
+ debugp_param("defs/iseq", rb_iseqw_new(singleton_method));
- if (!popped) {
- ADD_INSN1(ret, line, putobject, ID2SYM(mid));
- }
+ ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ CHECK(COMPILE(ret, "defs: recv", node->nd_recv));
+ ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid));
+ ADD_INSN1(ret, line, putiseq, singleton_method);
+ ADD_SEND (ret, line, id_core_define_singleton_method, INT2FIX(3));
+
+ if (popped) {
+ ADD_INSN(ret, line, pop);
+ }
break;
}
case NODE_ALIAS:{
@@ -8200,7 +6822,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
CHECK(COMPILE(ret, "super", node->nd_super));
ADD_INSN3(ret, line, defineclass, ID2SYM(node->nd_cpath->nd_mid), class_iseq, INT2FIX(flags));
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)class_iseq);
if (popped) {
ADD_INSN(ret, line, pop);
@@ -8216,7 +6837,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN (ret, line, putnil); /* dummy */
ADD_INSN3(ret, line, defineclass, ID2SYM(node->nd_cpath->nd_mid), module_iseq, INT2FIX(flags));
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)module_iseq);
if (popped) {
ADD_INSN(ret, line, pop);
@@ -8225,7 +6845,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
case NODE_SCLASS:{
ID singletonclass;
- const rb_iseq_t *singleton_class = NEW_ISEQ(node->nd_body, rb_fstring_lit("singleton class"),
+ const rb_iseq_t *singleton_class = NEW_ISEQ(node->nd_body, rb_fstring_cstr("singleton class"),
ISEQ_TYPE_CLASS, line);
CHECK(COMPILE(ret, "sclass#recv", node->nd_recv));
@@ -8234,7 +6854,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN3(ret, line, defineclass,
ID2SYM(singletonclass), singleton_class,
INT2FIX(VM_DEFINECLASS_TYPE_SINGLETON_CLASS));
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)singleton_class);
if (popped) {
ADD_INSN(ret, line, pop);
@@ -8245,7 +6864,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
if (rb_is_const_id(node->nd_mid)) {
/* constant */
LABEL *lend = NEW_LABEL(line);
- int ic_index = body->is_size++;
+ int ic_index = iseq->body->is_size++;
DECL_ANCHOR(pref);
DECL_ANCHOR(body);
@@ -8255,7 +6874,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
CHECK(compile_const_prefix(iseq, node, pref, body));
if (LIST_INSN_SIZE_ZERO(pref)) {
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
- ADD_INSN2(ret, line, opt_getinlinecache, lend, INT2FIX(ic_index));
+ ADD_INSN2(ret, line, getinlinecache, lend, INT2FIX(ic_index));
}
else {
ADD_INSN(ret, line, putnil);
@@ -8264,7 +6883,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_SEQ(ret, body);
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
- ADD_INSN1(ret, line, opt_setinlinecache, INT2FIX(ic_index));
+ ADD_INSN1(ret, line, setinlinecache, INT2FIX(ic_index));
ADD_LABEL(ret, lend);
}
}
@@ -8286,22 +6905,21 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
case NODE_COLON3:{
LABEL *lend = NEW_LABEL(line);
- int ic_index = body->is_size++;
+ int ic_index = iseq->body->is_size++;
debugi("colon3#nd_mid", node->nd_mid);
/* add cache insn */
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
- ADD_INSN2(ret, line, opt_getinlinecache, lend, INT2FIX(ic_index));
+ ADD_INSN2(ret, line, getinlinecache, lend, INT2FIX(ic_index));
ADD_INSN(ret, line, pop);
}
ADD_INSN1(ret, line, putobject, rb_cObject);
- ADD_INSN1(ret, line, putobject, Qtrue);
- ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_mid));
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
- ADD_INSN1(ret, line, opt_setinlinecache, INT2FIX(ic_index));
+ ADD_INSN1(ret, line, setinlinecache, INT2FIX(ic_index));
ADD_LABEL(ret, lend);
}
@@ -8319,8 +6937,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
if (number_literal_p(b) && number_literal_p(e)) {
if (!popped) {
VALUE val = rb_range_new(b->nd_lit, e->nd_lit, excl);
+ iseq_add_mark_object_compile_time(iseq, val);
ADD_INSN1(ret, line, putobject, val);
- RB_OBJ_WRITTEN(iseq, Qundef, val);
}
}
else {
@@ -8373,7 +6991,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
case NODE_ERRINFO:{
if (!popped) {
- if (body->type == ISEQ_TYPE_RESCUE) {
+ if (iseq->body->type == ISEQ_TYPE_RESCUE) {
ADD_GETLOCAL(ret, line, LVAR_ERRINFO, 0);
}
else {
@@ -8405,15 +7023,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
/* compiled to:
* ONCE{ rb_mRubyVMFrozenCore::core#set_postexe{ ... } }
*/
- int is_index = body->is_size++;
- struct rb_iseq_new_with_callback_callback_func *ifunc =
- rb_iseq_new_with_callback_new_callback(build_postexe_iseq, node->nd_body);
- const rb_iseq_t *once_iseq =
- new_child_iseq_with_callback(iseq, ifunc,
- rb_fstring(make_name_for_block(iseq)), iseq, ISEQ_TYPE_BLOCK, line);
+ int is_index = iseq->body->is_size++;
+ const rb_iseq_t *once_iseq = NEW_CHILD_ISEQ((const NODE *)IFUNC_NEW(build_postexe_iseq, node->nd_body, 0),
+ make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
ADD_INSN2(ret, line, once, once_iseq, INT2FIX(is_index));
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)once_iseq);
if (popped) {
ADD_INSN(ret, line, pop);
@@ -8425,7 +7039,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
LABEL *end_label = NEW_LABEL(nd_line(node));
const NODE *default_value = node->nd_body->nd_value;
- if (default_value == NODE_SPECIAL_REQUIRED_KEYWORD) {
+ if (default_value == (const NODE *)-1) {
/* required argument. do nothing */
COMPILE_ERROR(ERROR_ARGS "unreachable");
goto ng;
@@ -8442,8 +7056,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
* kw = default_value
* end
*/
- int kw_bits_idx = body->local_table_size - body->param.keyword->bits_start;
- int keyword_idx = body->param.keyword->num;
+ int kw_bits_idx = iseq->body->local_table_size - iseq->body->param.keyword->bits_start;
+ int keyword_idx = iseq->body->param.keyword->num;
ADD_INSN2(ret, line, checkkeyword, INT2FIX(kw_bits_idx + VM_ENV_DATA_SIZE - 1), INT2FIX(keyword_idx));
ADD_INSNL(ret, line, branchif, end_label);
@@ -8468,30 +7082,29 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
DECL_ANCHOR(args);
unsigned int flag = 0;
ID mid = node->nd_mid;
+ LABEL *lskip = 0;
VALUE argc;
- LABEL *else_label = NULL;
- VALUE branches = Qfalse;
/* optimization shortcut
* obj["literal"] = value -> opt_aset_with(obj, "literal", value)
*/
if (mid == idASET && !private_recv_p(node) && node->nd_args &&
- nd_type(node->nd_args) == NODE_LIST && node->nd_args->nd_alen == 2 &&
+ nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 2 &&
nd_type(node->nd_args->nd_head) == NODE_STR &&
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction)
{
- VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
+ VALUE str = freeze_literal(iseq, node->nd_args->nd_head->nd_lit);
CHECK(COMPILE(ret, "recv", node->nd_recv));
CHECK(COMPILE(ret, "value", node->nd_args->nd_next->nd_head));
if (!popped) {
ADD_INSN(ret, line, swap);
ADD_INSN1(ret, line, topn, INT2FIX(1));
}
- ADD_INSN2(ret, line, opt_aset_with, str,
- new_callinfo(iseq, idASET, 2, 0, NULL, FALSE));
- RB_OBJ_WRITTEN(iseq, Qundef, str);
+ ADD_INSN3(ret, line, opt_aset_with,
+ new_callinfo(iseq, idASET, 2, 0, NULL, FALSE),
+ NULL/* CALL_CACHE */, str);
ADD_INSN(ret, line, pop);
break;
}
@@ -8501,9 +7114,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
argc = setup_args(iseq, args, node->nd_args, &flag, NULL);
CHECK(!NIL_P(argc));
- int asgnflag = COMPILE_RECV(recv, "recv", node);
- CHECK(asgnflag != -1);
- flag |= (unsigned int)asgnflag;
+ flag |= COMPILE_RECV(recv, "recv", node);
debugp_param("argc", argc);
debugp_param("nd_mid", ID2SYM(mid));
@@ -8511,7 +7122,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
if (!rb_is_attrset_id(mid)) {
/* safe nav attr */
mid = rb_id_attrset(mid);
- else_label = qcall_branch_start(iseq, recv, &branches, node, line);
+ ADD_INSN(recv, line, dup);
+ lskip = NEW_LABEL(line);
+ ADD_INSNL(recv, line, branchnil, lskip);
}
if (!popped) {
ADD_INSN(ret, line, putnil);
@@ -8522,7 +7135,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN1(ret, line, topn, INT2FIX(1));
if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
- ADD_SEND_WITH_FLAG(ret, line, idAREF, INT2FIX(1), INT2FIX(asgnflag));
+ ADD_SEND(ret, line, idAREF, INT2FIX(1));
}
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 3));
ADD_INSN (ret, line, pop);
@@ -8530,7 +7143,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
else if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN(ret, line, dup);
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
- ADD_SEND_WITH_FLAG(ret, line, idAREF, INT2FIX(1), INT2FIX(asgnflag));
+ ADD_SEND(ret, line, idAREF, INT2FIX(1));
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2));
ADD_INSN (ret, line, pop);
}
@@ -8543,11 +7156,31 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_SEQ(ret, args);
}
ADD_SEND_WITH_FLAG(ret, line, mid, argc, INT2FIX(flag));
- qcall_branch_end(iseq, ret, else_label, branches, node, line);
+ if (lskip) ADD_LABEL(ret, lskip);
ADD_INSN(ret, line, pop);
break;
}
+ case NODE_PRELUDE:{
+ const rb_compile_option_t *orig_opt = ISEQ_COMPILE_DATA(iseq)->option;
+ rb_compile_option_t new_opt = *orig_opt;
+ if (node->nd_compile_option) {
+ rb_iseq_make_compile_option(&new_opt, node->nd_compile_option);
+ ISEQ_COMPILE_DATA(iseq)->option = &new_opt;
+ }
+ if (!new_opt.coverage_enabled) ISEQ_COVERAGE_SET(iseq, Qfalse);
+ CHECK(COMPILE_POPPED(ret, "prelude", node->nd_head));
+ CHECK(COMPILE_(ret, "body", node->nd_body, popped));
+ ISEQ_COMPILE_DATA(iseq)->option = orig_opt;
+ /* Do NOT restore ISEQ_COVERAGE!
+ * If ISEQ_COVERAGE is not false, finish_iseq_build function in iseq.c
+ * will initialize the counter array of line coverage.
+ * We keep ISEQ_COVERAGE as nil to disable this initialization.
+ * This is not harmful assuming that NODE_PRELUDE pragma does not occur
+ * in NODE tree except the root.
+ */
+ break;
+ }
case NODE_LAMBDA:{
/* compile same as lambda{...} */
const rb_iseq_t *block = NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
@@ -8555,7 +7188,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_CALL_WITH_BLOCK(ret, line, idLambda, argc, block);
- RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)block);
if (popped) {
ADD_INSN(ret, line, pop);
@@ -8569,6 +7201,18 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
return COMPILE_NG;
}
+ /* remove tracecoverage instruction if there is no relevant instruction */
+ if (IS_TRACE(ret->last) && ((TRACE*) ret->last)->event == RUBY_EVENT_LINE) {
+ LINK_ELEMENT *insn = ret->last->prev;
+ if (IS_INSN(insn) &&
+ IS_INSN_ID(insn, tracecoverage) &&
+ FIX2LONG(OPERAND_AT(insn, 0)) == RUBY_EVENT_COVERAGE_LINE
+ ) {
+ ELEM_REMOVE(insn); /* remove tracecovearge */
+ RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), line - 1, Qnil);
+ }
+ }
+
debug_node_end();
return COMPILE_OK;
}
@@ -8586,7 +7230,7 @@ insn_data_length(INSN *iobj)
static int
calc_sp_depth(int depth, INSN *insn)
{
- return comptime_insn_stack_increase(depth, insn->insn_id, insn->operands);
+ return insn_stack_increase(depth, insn->insn_id, insn->operands);
}
static VALUE
@@ -8657,16 +7301,19 @@ insn_data_to_s_detail(INSN *iobj)
break;
}
case TS_IC: /* inline cache */
- case TS_IVC: /* inline ivar cache */
- case TS_ISE: /* inline storage entry */
rb_str_catf(str, "<ic:%d>", FIX2INT(OPERAND_AT(iobj, j)));
break;
- case TS_CALLDATA: /* we store these as call infos at compile time */
+ case TS_CALLINFO: /* call info */
{
- const struct rb_call_info *ci = (struct rb_call_info *)OPERAND_AT(iobj, j);
- rb_str_cat2(str, "<calldata:");
- if (ci->mid) rb_str_catf(str, "%"PRIsVALUE, rb_id2str(ci->mid));
- rb_str_catf(str, ", %d>", ci->orig_argc);
+ struct rb_call_info *ci = (struct rb_call_info *)OPERAND_AT(iobj, j);
+ rb_str_cat2(str, "<callinfo:");
+ if (ci->mid) rb_str_catf(str, "%"PRIsVALUE, rb_id2str(ci->mid));
+ rb_str_catf(str, ", %d>", ci->orig_argc);
+ break;
+ }
+ case TS_CALLCACHE: /* call cache */
+ {
+ rb_str_catf(str, "<call cache>");
break;
}
case TS_CDHASH: /* case/when condition cache */
@@ -8674,7 +7321,7 @@ insn_data_to_s_detail(INSN *iobj)
break;
case TS_FUNCPTR:
{
- void *func = (void *)OPERAND_AT(iobj, j);
+ rb_insn_func_t func = (rb_insn_func_t)OPERAND_AT(iobj, j);
#ifdef HAVE_DLADDR
Dl_info info;
if (dladdr(func, &info) && info.dli_sname) {
@@ -8685,9 +7332,6 @@ insn_data_to_s_detail(INSN *iobj)
rb_str_catf(str, "<%p>", func);
}
break;
- case TS_BUILTIN:
- rb_bug("unsupported: TS_BUILTIN");
- break;
default:{
rb_raise(rb_eSyntaxError, "unknown operand type: %c", type);
}
@@ -8730,8 +7374,7 @@ dump_disasm_list_with_cursor(const LINK_ELEMENT *link, const LINK_ELEMENT *curr,
case ISEQ_ELEMENT_LABEL:
{
lobj = (LABEL *)link;
- printf(LABEL_FORMAT" [sp: %d]%s\n", lobj->label_no, lobj->sp,
- dest == lobj ? " <---" : "");
+ printf(LABEL_FORMAT"%s\n", lobj->label_no, dest == lobj ? " <---" : "");
break;
}
case ISEQ_ELEMENT_TRACE:
@@ -8759,16 +7402,16 @@ dump_disasm_list_with_cursor(const LINK_ELEMENT *link, const LINK_ELEMENT *curr,
const char *
rb_insns_name(int i)
{
- return insn_name(i);
+ return insn_name_info[i];
}
VALUE
rb_insns_name_array(void)
{
- VALUE ary = rb_ary_new_capa(VM_INSTRUCTION_SIZE);
+ VALUE ary = rb_ary_new();
int i;
for (i = 0; i < VM_INSTRUCTION_SIZE; i++) {
- rb_ary_push(ary, rb_fstring_cstr(insn_name(i)));
+ rb_ary_push(ary, rb_fstring_cstr(insn_name_info[i]));
}
return rb_obj_freeze(ary);
}
@@ -8827,6 +7470,7 @@ iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table,
for (i=0; i<RARRAY_LEN(exception); i++) {
const rb_iseq_t *eiseq;
VALUE v, type;
+ const VALUE *ptr;
LABEL *lstart, *lend, *lcont;
unsigned int sp;
@@ -8834,18 +7478,19 @@ iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table,
if (RARRAY_LEN(v) != 6) {
rb_raise(rb_eSyntaxError, "wrong exception entry");
}
- type = get_exception_sym2type(RARRAY_AREF(v, 0));
- if (RARRAY_AREF(v, 1) == Qnil) {
+ ptr = RARRAY_CONST_PTR(v);
+ type = get_exception_sym2type(ptr[0]);
+ if (ptr[1] == Qnil) {
eiseq = NULL;
}
else {
- eiseq = rb_iseqw_to_iseq(rb_iseq_load(RARRAY_AREF(v, 1), (VALUE)iseq, Qnil));
- }
+ eiseq = rb_iseqw_to_iseq(rb_iseq_load(ptr[1], (VALUE)iseq, Qnil));
+ }
- lstart = register_label(iseq, labels_table, RARRAY_AREF(v, 2));
- lend = register_label(iseq, labels_table, RARRAY_AREF(v, 3));
- lcont = register_label(iseq, labels_table, RARRAY_AREF(v, 4));
- sp = NUM2UINT(RARRAY_AREF(v, 5));
+ lstart = register_label(iseq, labels_table, ptr[2]);
+ lend = register_label(iseq, labels_table, ptr[3]);
+ lcont = register_label(iseq, labels_table, ptr[4]);
+ sp = NUM2UINT(ptr[5]);
/* TODO: Dirty Hack! Fix me */
if (type == CATCH_TYPE_RESCUE ||
@@ -8868,7 +7513,7 @@ insn_make_insn_table(void)
{
struct st_table *table;
int i;
- table = st_init_numtable_with_size(VM_INSTRUCTION_SIZE);
+ table = st_init_numtable();
for (i=0; i<VM_INSTRUCTION_SIZE; i++) {
st_insert(table, ID2SYM(rb_intern(insn_name(i))), i);
@@ -8894,6 +7539,7 @@ iseq_build_load_iseq(const rb_iseq_t *iseq, VALUE op)
}
loaded_iseq = rb_iseqw_to_iseq(iseqw);
+ iseq_add_mark_object(iseq, (VALUE)loaded_iseq);
return loaded_iseq;
}
@@ -8953,6 +7599,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
VALUE body, VALUE labels_wrapper)
{
/* TODO: body should be frozen */
+ const VALUE *ptr = RARRAY_CONST_PTR(body);
long i, len = RARRAY_LEN(body);
struct st_table *labels_table = DATA_PTR(labels_wrapper);
int j;
@@ -8969,7 +7616,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
for (i=0; i<len; i++) {
- VALUE obj = RARRAY_AREF(body, i);
+ VALUE obj = ptr[i];
if (SYMBOL_P(obj)) {
rb_event_flag_t event;
@@ -9007,7 +7654,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
if (argc > 0) {
- argv = compile_data_alloc2(iseq, sizeof(VALUE), argc);
+ argv = compile_data_alloc(iseq, sizeof(VALUE) * argc);
for (j=0; j<argc; j++) {
VALUE op = rb_ary_entry(obj, j+1);
switch (insn_op_type((VALUE)insn_id, j)) {
@@ -9023,14 +7670,12 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
break;
case TS_VALUE:
argv[j] = op;
- RB_OBJ_WRITTEN(iseq, Qundef, op);
+ iseq_add_mark_object(iseq, op);
break;
case TS_ISEQ:
{
if (op != Qnil) {
- VALUE v = (VALUE)iseq_build_load_iseq(iseq, op);
- argv[j] = v;
- RB_OBJ_WRITTEN(iseq, Qundef, v);
+ argv[j] = (VALUE)iseq_build_load_iseq(iseq, op);
}
else {
argv[j] = 0;
@@ -9041,19 +7686,18 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
op = rb_to_symbol_type(op);
argv[j] = (VALUE)rb_global_entry(SYM2ID(op));
break;
- case TS_ISE:
- FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
- /* fall through */
case TS_IC:
- case TS_IVC: /* inline ivar cache */
argv[j] = op;
if (NUM2UINT(op) >= iseq->body->is_size) {
iseq->body->is_size = NUM2INT(op) + 1;
}
break;
- case TS_CALLDATA:
+ case TS_CALLINFO:
argv[j] = iseq_build_callinfo_from_hash(iseq, op);
break;
+ case TS_CALLCACHE:
+ argv[j] = Qfalse;
+ break;
case TS_ID:
argv[j] = rb_to_symbol_type(op);
break;
@@ -9062,7 +7706,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
int i;
VALUE map = rb_hash_new_with_size(RARRAY_LEN(op)/2);
- RHASH_TBL_RAW(map)->type = &cdhash_type;
+ rb_hash_tbl_raw(map)->type = &cdhash_type;
op = rb_to_array_type(op);
for (i=0; i<RARRAY_LEN(op); i+=2) {
VALUE key = RARRAY_AREF(op, i);
@@ -9073,7 +7717,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
RB_GC_GUARD(op);
argv[j] = map;
- RB_OBJ_WRITTEN(iseq, Qundef, map);
+ rb_iseq_add_mark_object(iseq, map);
}
break;
case TS_FUNCPTR:
@@ -9160,9 +7804,6 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
keyword->table = ids;
return keyword;
}
- else if (default_len < 0) {
- UNREACHABLE;
- }
dvs = ALLOC_N(VALUE, (unsigned int)default_len);
@@ -9193,58 +7834,6 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
}
void
-rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *storage)
-{
- INSN *iobj = 0;
- size_t size = sizeof(INSN);
- unsigned int pos = 0;
-
- while (storage) {
-#ifdef STRICT_ALIGNMENT
- size_t padding = calc_padding((void *)&storage->buff[pos], size);
-#else
- const size_t padding = 0; /* expected to be optimized by compiler */
-#endif /* STRICT_ALIGNMENT */
- size_t offset = pos + size + padding;
- if (offset > storage->size || offset > storage->pos) {
- pos = 0;
- storage = storage->next;
- }
- else {
-#ifdef STRICT_ALIGNMENT
- pos += (int)padding;
-#endif /* STRICT_ALIGNMENT */
-
- iobj = (INSN *)&storage->buff[pos];
-
- if (iobj->operands) {
- int j;
- const char *types = insn_op_types(iobj->insn_id);
-
- for (j = 0; types[j]; j++) {
- char type = types[j];
- switch (type) {
- case TS_CDHASH:
- case TS_ISEQ:
- case TS_VALUE:
- {
- VALUE op = OPERAND_AT(iobj, j);
- if (!SPECIAL_CONST_P(op)) {
- rb_gc_mark(op);
- }
- break;
- }
- default:
- break;
- }
- }
- }
- pos += (int)size;
- }
- }
-}
-
-void
rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
VALUE exception, VALUE body)
{
@@ -9253,7 +7842,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
unsigned int arg_size, local_size, stack_max;
ID *tbl;
struct st_table *labels_table = st_init_numtable();
- VALUE labels_wrapper = Data_Wrap_Struct(0, rb_mark_set, st_free_table, labels_table);
+ VALUE labels_wrapper = Data_Wrap_Struct(0, 0, st_free_table, labels_table);
VALUE arg_opt_labels = rb_hash_aref(params, SYM(opt));
VALUE keywords = rb_hash_aref(params, SYM(keyword));
VALUE sym_arg_rest = ID2SYM(rb_intern("#arg_rest"));
@@ -9352,39 +7941,41 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
/* for parser */
int
-rb_dvar_defined(ID id, const rb_iseq_t *iseq)
+rb_dvar_defined(ID id, const struct rb_block *base_block)
{
- if (iseq) {
- const struct rb_iseq_constant_body *body = iseq->body;
- while (body->type == ISEQ_TYPE_BLOCK ||
- body->type == ISEQ_TYPE_RESCUE ||
- body->type == ISEQ_TYPE_ENSURE ||
- body->type == ISEQ_TYPE_EVAL ||
- body->type == ISEQ_TYPE_MAIN
+ const rb_iseq_t *iseq;
+
+ if (base_block && (iseq = vm_block_iseq(base_block)) != NULL) {
+ while (iseq->body->type == ISEQ_TYPE_BLOCK ||
+ iseq->body->type == ISEQ_TYPE_RESCUE ||
+ iseq->body->type == ISEQ_TYPE_ENSURE ||
+ iseq->body->type == ISEQ_TYPE_EVAL ||
+ iseq->body->type == ISEQ_TYPE_MAIN
) {
unsigned int i;
- for (i = 0; i < body->local_table_size; i++) {
- if (body->local_table[i] == id) {
+ for (i = 0; i < iseq->body->local_table_size; i++) {
+ if (iseq->body->local_table[i] == id) {
return 1;
}
}
- iseq = body->parent_iseq;
- body = iseq->body;
+ iseq = iseq->body->parent_iseq;
}
}
return 0;
}
int
-rb_local_defined(ID id, const rb_iseq_t *iseq)
+rb_local_defined(ID id, const struct rb_block *base_block)
{
- if (iseq) {
+ const rb_iseq_t *iseq;
+
+ if (base_block && (iseq = vm_block_iseq(base_block)) != NULL) {
unsigned int i;
- const struct rb_iseq_constant_body *const body = iseq->body->local_iseq->body;
+ iseq = iseq->body->local_iseq;
- for (i=0; i<body->local_table_size; i++) {
- if (body->local_table[i] == id) {
+ for (i=0; i<iseq->body->local_table_size; i++) {
+ if (iseq->body->local_table[i] == id) {
return 1;
}
}
@@ -9406,7 +7997,7 @@ caller_location(VALUE *path, VALUE *realpath)
return line;
}
else {
- *path = rb_fstring_lit("<compiled>");
+ *path = rb_fstring_cstr("<compiled>");
*realpath = *path;
return 1;
}
@@ -9420,7 +8011,7 @@ typedef struct {
static const rb_iseq_t *
method_for_self(VALUE name, VALUE arg, rb_insn_func_t func,
- void (*build)(rb_iseq_t *, LINK_ANCHOR *, const void *))
+ VALUE (*build)(rb_iseq_t *, LINK_ANCHOR *const, VALUE))
{
VALUE path, realpath;
accessor_args acc;
@@ -9428,44 +8019,42 @@ method_for_self(VALUE name, VALUE arg, rb_insn_func_t func,
acc.arg = arg;
acc.func = func;
acc.line = caller_location(&path, &realpath);
- struct rb_iseq_new_with_callback_callback_func *ifunc =
- rb_iseq_new_with_callback_new_callback(build, &acc);
- return rb_iseq_new_with_callback(ifunc,
- rb_sym2str(name), path, realpath,
- INT2FIX(acc.line), 0, ISEQ_TYPE_METHOD, 0);
+ return rb_iseq_new_with_opt((const NODE *)IFUNC_NEW(build, (VALUE)&acc, 0),
+ rb_sym2str(name), path, realpath,
+ INT2FIX(acc.line), 0, ISEQ_TYPE_METHOD, 0);
}
-static void
-for_self_aref(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a)
+static VALUE
+for_self_aref(rb_iseq_t *iseq, LINK_ANCHOR *const ret, VALUE a)
{
const accessor_args *const args = (void *)a;
const int line = args->line;
- struct rb_iseq_constant_body *const body = iseq->body;
iseq_set_local_table(iseq, 0);
- body->param.lead_num = 0;
- body->param.size = 0;
+ iseq->body->param.lead_num = 0;
+ iseq->body->param.size = 0;
ADD_INSN1(ret, line, putobject, args->arg);
ADD_INSN1(ret, line, opt_call_c_function, (VALUE)args->func);
+ return Qnil;
}
-static void
-for_self_aset(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a)
+static VALUE
+for_self_aset(rb_iseq_t *iseq, LINK_ANCHOR *const ret, VALUE a)
{
const accessor_args *const args = (void *)a;
const int line = args->line;
- struct rb_iseq_constant_body *const body = iseq->body;
static const ID vars[] = {1, idUScore};
iseq_set_local_table(iseq, vars);
- body->param.lead_num = 1;
- body->param.size = 1;
+ iseq->body->param.lead_num = 1;
+ iseq->body->param.size = 1;
ADD_GETLOCAL(ret, line, numberof(vars)-1, 0);
ADD_INSN1(ret, line, putobject, args->arg);
ADD_INSN1(ret, line, opt_call_c_function, (VALUE)args->func);
ADD_INSN(ret, line, pop);
+ return Qnil;
}
/*
@@ -9488,25 +8077,9 @@ rb_method_for_self_aset(VALUE name, VALUE arg, rb_insn_func_t func)
/* ISeq binary format */
-#ifndef IBF_ISEQ_DEBUG
-#define IBF_ISEQ_DEBUG 0
-#endif
-
-#ifndef IBF_ISEQ_ENABLE_LOCAL_BUFFER
-#define IBF_ISEQ_ENABLE_LOCAL_BUFFER 0
-#endif
-
typedef unsigned int ibf_offset_t;
#define IBF_OFFSET(ptr) ((ibf_offset_t)(VALUE)(ptr))
-#define IBF_MAJOR_VERSION ISEQ_MAJOR_VERSION
-#if RUBY_DEVEL
-#define IBF_DEVEL_VERSION 2
-#define IBF_MINOR_VERSION (ISEQ_MINOR_VERSION * 10000 + IBF_DEVEL_VERSION)
-#else
-#define IBF_MINOR_VERSION ISEQ_MINOR_VERSION
-#endif
-
struct ibf_header {
char magic[4]; /* YARB */
unsigned int major_version;
@@ -9515,124 +8088,81 @@ struct ibf_header {
unsigned int extra_size;
unsigned int iseq_list_size;
- unsigned int global_object_list_size;
+ unsigned int id_list_size;
+ unsigned int object_list_size;
+
ibf_offset_t iseq_list_offset;
- ibf_offset_t global_object_list_offset;
+ ibf_offset_t id_list_offset;
+ ibf_offset_t object_list_offset;
};
-struct ibf_dump_buffer {
- VALUE str;
- VALUE obj_list; /* [objs] */
+struct ibf_id_entry {
+ enum {
+ ibf_id_enc_ascii,
+ ibf_id_enc_utf8,
+ ibf_id_enc_other
+ } enc : 2;
+ char body[1];
};
struct ibf_dump {
- VALUE iseq_list; /* [iseqs] */
+ VALUE str;
+ VALUE iseq_list; /* [iseq0 offset, ...] */
+ VALUE obj_list; /* [objs] */
st_table *iseq_table; /* iseq -> iseq number */
- struct ibf_dump_buffer global_buffer;
- struct ibf_dump_buffer *current_buffer;
+ st_table *id_table; /* id -> id number */
};
rb_iseq_t * iseq_alloc(void);
-struct ibf_load_buffer {
- const char *buff;
- ibf_offset_t size;
-
- VALUE obj_list; /* [obj0, ...] */
- unsigned int obj_list_size;
- ibf_offset_t obj_list_offset;
-};
-
struct ibf_load {
+ const char *buff;
const struct ibf_header *header;
- VALUE iseq_list; /* [iseq0, ...] */
- struct ibf_load_buffer global_buffer;
+ ID *id_list; /* [id0, ...] */
+ VALUE iseq_list; /* [iseq0, ...] */
+ VALUE obj_list; /* [obj0, ...] */
VALUE loader_obj;
- rb_iseq_t *iseq;
VALUE str;
- struct ibf_load_buffer *current_buffer;
+ rb_iseq_t *iseq;
};
static ibf_offset_t
ibf_dump_pos(struct ibf_dump *dump)
{
- long pos = RSTRING_LEN(dump->current_buffer->str);
-#if SIZEOF_LONG > SIZEOF_INT
- if (pos >= UINT_MAX) {
- rb_raise(rb_eRuntimeError, "dump size exceeds");
- }
-#endif
- return (unsigned int)pos;
-}
-
-static void
-ibf_dump_align(struct ibf_dump *dump, size_t align)
-{
- ibf_offset_t pos = ibf_dump_pos(dump);
- if (pos % align) {
- static const char padding[sizeof(VALUE)];
- size_t size = align - ((size_t)pos % align);
-#if SIZEOF_LONG > SIZEOF_INT
- if (pos + size >= UINT_MAX) {
- rb_raise(rb_eRuntimeError, "dump size exceeds");
- }
-#endif
- for (; size > sizeof(padding); size -= sizeof(padding)) {
- rb_str_cat(dump->current_buffer->str, padding, sizeof(padding));
- }
- rb_str_cat(dump->current_buffer->str, padding, size);
- }
+ return (unsigned int)rb_str_strlen(dump->str);
}
static ibf_offset_t
ibf_dump_write(struct ibf_dump *dump, const void *buff, unsigned long size)
{
ibf_offset_t pos = ibf_dump_pos(dump);
- rb_str_cat(dump->current_buffer->str, (const char *)buff, size);
+ rb_str_cat(dump->str, (const char *)buff, size);
/* TODO: overflow check */
return pos;
}
-static ibf_offset_t
-ibf_dump_write_byte(struct ibf_dump *dump, unsigned char byte)
-{
- return ibf_dump_write(dump, &byte, sizeof(unsigned char));
-}
-
static void
ibf_dump_overwrite(struct ibf_dump *dump, void *buff, unsigned int size, long offset)
{
- VALUE str = dump->current_buffer->str;
+ VALUE str = dump->str;
char *ptr = RSTRING_PTR(str);
if ((unsigned long)(size + offset) > (unsigned long)RSTRING_LEN(str))
- rb_bug("ibf_dump_overwrite: overflow");
+ rb_bug("ibf_dump_overwrite: overflow");
memcpy(ptr + offset, buff, size);
}
-static const void *
-ibf_load_ptr(const struct ibf_load *load, ibf_offset_t *offset, int size)
-{
- ibf_offset_t beg = *offset;
- *offset += size;
- return load->current_buffer->buff + beg;
-}
-
static void *
-ibf_load_alloc(const struct ibf_load *load, ibf_offset_t offset, size_t x, size_t y)
+ibf_load_alloc(const struct ibf_load *load, ibf_offset_t offset, int size)
{
- void *buff = ruby_xmalloc2(x, y);
- size_t size = x * y;
- memcpy(buff, load->current_buffer->buff + offset, size);
+ void *buff = ruby_xmalloc(size);
+ memcpy(buff, load->buff + offset, size);
return buff;
}
-#define IBF_W_ALIGN(type) (RUBY_ALIGNOF(type) > 1 ? ibf_dump_align(dump, RUBY_ALIGNOF(type)) : (void)0)
-
-#define IBF_W(b, type, n) (IBF_W_ALIGN(type), (type *)(VALUE)IBF_WP(b, type, n))
+#define IBF_W(b, type, n) (type *)(VALUE)ibf_dump_write(dump, (b), sizeof(type) * (n))
#define IBF_WV(variable) ibf_dump_write(dump, &(variable), sizeof(variable))
#define IBF_WP(b, type, n) ibf_dump_write(dump, (b), sizeof(type) * (n))
-#define IBF_R(val, type, n) (type *)ibf_load_alloc(load, IBF_OFFSET(val), sizeof(type), (n))
-#define IBF_ZERO(variable) memset(&(variable), 0, sizeof(variable))
+#define IBF_R(val, type, n) (type *)ibf_load_alloc(load, IBF_OFFSET(val), sizeof(type) * (n))
static int
ibf_table_lookup(struct st_table *table, st_data_t key)
@@ -9640,10 +8170,10 @@ ibf_table_lookup(struct st_table *table, st_data_t key)
st_data_t val;
if (st_lookup(table, key, &val)) {
- return (int)val;
+ return (int)val;
}
else {
- return -1;
+ return -1;
}
}
@@ -9653,8 +8183,8 @@ ibf_table_index(struct st_table *table, st_data_t key)
int index = ibf_table_lookup(table, key);
if (index < 0) { /* not found */
- index = (int)table->num_entries;
- st_insert(table, key, (st_data_t)index);
+ index = (int)table->num_entries;
+ st_insert(table, key, (st_data_t)index);
}
return index;
@@ -9662,75 +8192,72 @@ ibf_table_index(struct st_table *table, st_data_t key)
/* dump/load generic */
-static void ibf_dump_object_list(struct ibf_dump *dump, ibf_offset_t *obj_list_offset, unsigned int *obj_list_size);
-
static VALUE ibf_load_object(const struct ibf_load *load, VALUE object_index);
static rb_iseq_t *ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq);
static VALUE
-ibf_dump_object_list_new(void)
-{
- VALUE obj_list = rb_ary_tmp_new(1);
- rb_ary_push(obj_list, Qnil); /* 0th is nil */
-
- return obj_list;
-}
-
-static VALUE
ibf_dump_object(struct ibf_dump *dump, VALUE obj)
{
- VALUE obj_list = dump->current_buffer->obj_list;
- long index = RARRAY_LEN(obj_list);
+ long index = RARRAY_LEN(dump->obj_list);
long i;
for (i=0; i<index; i++) {
- if (RARRAY_AREF(obj_list, i) == obj) return (VALUE)i; /* dedup */
+ if (RARRAY_AREF(dump->obj_list, i) == obj) return (VALUE)i; /* dedup */
}
- rb_ary_push(obj_list, obj);
+ rb_ary_push(dump->obj_list, obj);
return (VALUE)index;
}
static VALUE
ibf_dump_id(struct ibf_dump *dump, ID id)
{
- if (id == 0 || rb_id2name(id) == NULL) {
- return 0;
- }
- return ibf_dump_object(dump, rb_id2sym(id));
+ return (VALUE)ibf_table_index(dump->id_table, (st_data_t)id);
}
static ID
ibf_load_id(const struct ibf_load *load, const ID id_index)
{
+ ID id;
+
if (id_index == 0) {
- return 0;
+ id = 0;
+ }
+ else {
+ id = load->id_list[(long)id_index];
+
+ if (id == 0) {
+ long *indices = (long *)(load->buff + load->header->id_list_offset);
+ VALUE str = ibf_load_object(load, indices[id_index]);
+ id = NIL_P(str) ? 0 : rb_intern_str(str); /* str == nil -> internal junk id */
+ load->id_list[(long)id_index] = id;
+ }
}
- VALUE sym = ibf_load_object(load, id_index);
- return rb_sym2id(sym);
+
+ return id;
}
/* dump/load: code */
static VALUE
-ibf_dump_calldata(struct ibf_dump *dump, const struct rb_call_data *cd)
+ibf_dump_callinfo(struct ibf_dump *dump, const struct rb_call_info *ci)
{
- return (cd->ci.flag & VM_CALL_KWARG) ? Qtrue : Qfalse;
+ return (ci->flag & VM_CALL_KWARG) ? Qtrue : Qfalse;
}
static ibf_offset_t ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq);
-static int
+static rb_iseq_t *
ibf_dump_iseq(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
if (iseq == NULL) {
- return -1;
+ return (rb_iseq_t *)-1;
}
else {
- int iseq_index = ibf_table_lookup(dump->iseq_table, (st_data_t)iseq);
- if (iseq_index < 0) {
- iseq_index = ibf_table_index(dump->iseq_table, (st_data_t)iseq);
- rb_ary_push(dump->iseq_list, (VALUE)iseq);
- }
- return iseq_index;
+ int iseq_index = ibf_table_lookup(dump->iseq_table, (st_data_t)iseq);
+ if (iseq_index < 0) {
+ iseq_index = ibf_table_index(dump->iseq_table, (st_data_t)iseq);
+ rb_ary_store(dump->iseq_list, iseq_index, LONG2NUM(ibf_dump_iseq_each(dump, rb_iseq_check(iseq))));
+ }
+ return (rb_iseq_t *)(VALUE)iseq_index;
}
}
@@ -9747,741 +8274,383 @@ ibf_load_gentry(const struct ibf_load *load, const struct rb_global_entry *entry
return (VALUE)rb_global_entry(gid);
}
-static unsigned char
-ibf_load_byte(const struct ibf_load *load, ibf_offset_t *offset)
-{
- if (*offset >= load->current_buffer->size) { rb_raise(rb_eRuntimeError, "invalid bytecode"); }
- return (unsigned char)load->current_buffer->buff[(*offset)++];
-}
-
-/*
- * Small uint serialization
- * 0x00000000_00000000 - 0x00000000_0000007f: 1byte | XXXX XXX1 |
- * 0x00000000_00000080 - 0x00000000_00003fff: 2byte | XXXX XX10 | XXXX XXXX |
- * 0x00000000_00004000 - 0x00000000_001fffff: 3byte | XXXX X100 | XXXX XXXX | XXXX XXXX |
- * 0x00000000_00020000 - 0x00000000_0fffffff: 4byte | XXXX 1000 | XXXX XXXX | XXXX XXXX | XXXX XXXX |
- * ...
- * 0x00010000_00000000 - 0x00ffffff_ffffffff: 8byte | 1000 0000 | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX |
- * 0x01000000_00000000 - 0xffffffff_ffffffff: 9byte | 0000 0000 | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX | XXXX XXXX |
- */
-static void
-ibf_dump_write_small_value(struct ibf_dump *dump, VALUE x)
-{
- if (sizeof(VALUE) > 8 || CHAR_BIT != 8) {
- ibf_dump_write(dump, &x, sizeof(VALUE));
- }
-
- enum { max_byte_length = sizeof(VALUE) + 1 };
-
- unsigned char bytes[max_byte_length];
- ibf_offset_t n;
-
- for (n = 0; n < sizeof(VALUE) && (x >> (7 - n)); n++, x >>= 8) {
- bytes[max_byte_length - 1 - n] = (unsigned char)x;
- }
-
- x <<= 1;
- x |= 1;
- x <<= n;
- bytes[max_byte_length - 1 - n] = (unsigned char)x;
- n++;
-
- ibf_dump_write(dump, bytes + max_byte_length - n, n);
-}
-
-static VALUE
-ibf_load_small_value(const struct ibf_load *load, ibf_offset_t *offset)
-{
- if (sizeof(VALUE) > 8 || CHAR_BIT != 8) {
- union { char s[sizeof(VALUE)]; VALUE v; } x;
-
- memcpy(x.s, load->current_buffer->buff + *offset, sizeof(VALUE));
- *offset += sizeof(VALUE);
-
- return x.v;
- }
-
- enum { max_byte_length = sizeof(VALUE) + 1 };
-
- const unsigned char *buffer = (const unsigned char *)load->current_buffer->buff;
- const unsigned char c = buffer[*offset];
-
- ibf_offset_t n =
- c & 1 ? 1 :
- c == 0 ? 9 : ntz_int32(c) + 1;
- VALUE x = (VALUE)c >> n;
-
- if (*offset + n > load->current_buffer->size) {
- rb_raise(rb_eRuntimeError, "invalid byte sequence");
- }
-
- ibf_offset_t i;
- for (i = 1; i < n; i++) {
- x <<= 8;
- x |= (VALUE)buffer[*offset + i];
- }
-
- *offset += n;
- return x;
-}
-
-static void
-ibf_dump_builtin(struct ibf_dump *dump, const struct rb_builtin_function *bf)
-{
- // short: index
- // short: name.length
- // bytes: name
- // // omit argc (only verify with name)
- ibf_dump_write_small_value(dump, (VALUE)bf->index);
-
- size_t len = strlen(bf->name);
- ibf_dump_write_small_value(dump, (VALUE)len);
- ibf_dump_write(dump, bf->name, len);
-}
-
-static const struct rb_builtin_function *
-ibf_load_builtin(const struct ibf_load *load, ibf_offset_t *offset)
-{
- int i = (int)ibf_load_small_value(load, offset);
- int len = (int)ibf_load_small_value(load, offset);
- const char *name = (char *)ibf_load_ptr(load, offset, len);
-
- if (0) {
- fprintf(stderr, "%.*s!!\n", len, name);
- }
-
- const struct rb_builtin_function *table = GET_VM()->builtin_function_table;
- if (table == NULL) rb_raise(rb_eArgError, "builtin function table is not provided");
- if (strncmp(table[i].name, name, len) != 0) {
- rb_raise(rb_eArgError, "builtin function index (%d) mismatch (expect %s but %s)", i, name, table[i].name);
- }
- // fprintf(stderr, "load-builtin: name:%s(%d)\n", table[i].name, table[i].argc);
-
- return &table[i];
-}
-
-static ibf_offset_t
+static VALUE *
ibf_dump_code(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
- const int iseq_size = body->iseq_size;
+ const int iseq_size = iseq->body->iseq_size;
int code_index;
+ VALUE *code;
const VALUE *orig_code = rb_iseq_original_iseq(iseq);
- ibf_offset_t offset = ibf_dump_pos(dump);
+ code = ALLOCA_N(VALUE, iseq_size);
for (code_index=0; code_index<iseq_size;) {
- const VALUE insn = orig_code[code_index++];
- const char *types = insn_op_types(insn);
- int op_index;
-
- /* opcode */
- if (insn >= 0x100) { rb_raise(rb_eRuntimeError, "invalid instruction"); }
- ibf_dump_write_small_value(dump, insn);
-
- /* operands */
- for (op_index=0; types[op_index]; op_index++, code_index++) {
- VALUE op = orig_code[code_index];
- VALUE wv;
-
- switch (types[op_index]) {
- case TS_CDHASH:
- case TS_VALUE:
- wv = ibf_dump_object(dump, op);
- break;
- case TS_ISEQ:
- wv = (VALUE)ibf_dump_iseq(dump, (const rb_iseq_t *)op);
- break;
- case TS_IC:
- case TS_IVC:
- case TS_ISE:
- {
- unsigned int i;
- for (i=0; i<body->is_size; i++) {
- if (op == (VALUE)&body->is_entries[i]) {
- break;
- }
- }
- wv = (VALUE)i;
- }
- break;
- case TS_CALLDATA:
- {
- /* ibf_dump_calldata() always returns either Qtrue or Qfalse */
- char c = ibf_dump_calldata(dump, (const struct rb_call_data *)op) == Qtrue; // 1 or 0
- ibf_dump_write_byte(dump, c);
- goto skip_wv;
- }
- case TS_ID:
- wv = ibf_dump_id(dump, (ID)op);
- break;
- case TS_GENTRY:
- wv = ibf_dump_gentry(dump, (const struct rb_global_entry *)op);
- break;
- case TS_FUNCPTR:
- rb_raise(rb_eRuntimeError, "TS_FUNCPTR is not supported");
- goto skip_wv;
- case TS_BUILTIN:
- ibf_dump_builtin(dump, (const struct rb_builtin_function *)op);
- goto skip_wv;
- default:
- wv = op;
- break;
- }
- ibf_dump_write_small_value(dump, wv);
- skip_wv:;
- }
- assert(insn_len(insn) == op_index+1);
+ const VALUE insn = orig_code[code_index];
+ const char *types = insn_op_types(insn);
+ int op_index;
+
+ code[code_index++] = (VALUE)insn;
+
+ for (op_index=0; types[op_index]; op_index++, code_index++) {
+ VALUE op = orig_code[code_index];
+ switch (types[op_index]) {
+ case TS_CDHASH:
+ case TS_VALUE:
+ code[code_index] = ibf_dump_object(dump, op);
+ break;
+ case TS_ISEQ:
+ code[code_index] = (VALUE)ibf_dump_iseq(dump, (const rb_iseq_t *)op);
+ break;
+ case TS_IC:
+ {
+ unsigned int i;
+ for (i=0; i<iseq->body->is_size; i++) {
+ if (op == (VALUE)&iseq->body->is_entries[i]) {
+ break;
+ }
+ }
+ code[code_index] = i;
+ }
+ break;
+ case TS_CALLINFO:
+ code[code_index] = ibf_dump_callinfo(dump, (const struct rb_call_info *)op);
+ break;
+ case TS_CALLCACHE:
+ code[code_index] = 0;
+ break;
+ case TS_ID:
+ code[code_index] = ibf_dump_id(dump, (ID)op);
+ break;
+ case TS_GENTRY:
+ code[code_index] = ibf_dump_gentry(dump, (const struct rb_global_entry *)op);
+ break;
+ case TS_FUNCPTR:
+ rb_raise(rb_eRuntimeError, "TS_FUNCPTR is not supported");
+ break;
+ default:
+ code[code_index] = op;
+ break;
+ }
+ }
+ assert(insn_len(insn) == op_index+1);
}
- return offset;
+ return IBF_W(code, VALUE, iseq_size);
}
static VALUE *
-ibf_load_code(const struct ibf_load *load, const rb_iseq_t *iseq, ibf_offset_t bytecode_offset, ibf_offset_t bytecode_size, unsigned int iseq_size)
+ibf_load_code(const struct ibf_load *load, const rb_iseq_t *iseq, const struct rb_iseq_constant_body *body)
{
- unsigned int code_index;
- ibf_offset_t reading_pos = bytecode_offset;
- VALUE *code = ALLOC_N(VALUE, iseq_size);
+ const int iseq_size = body->iseq_size;
+ int code_index;
+ VALUE *code = IBF_R(body->iseq_encoded, VALUE, iseq_size);
- struct rb_iseq_constant_body *load_body = iseq->body;
- struct rb_call_data *cd_entries = load_body->call_data;
- struct rb_kwarg_call_data *cd_kw_entries = (struct rb_kwarg_call_data *)&load_body->call_data[load_body->ci_size];
- union iseq_inline_storage_entry *is_entries = load_body->is_entries;
+ struct rb_call_info *ci_entries = iseq->body->ci_entries;
+ struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&iseq->body->ci_entries[iseq->body->ci_size];
+ struct rb_call_cache *cc_entries = iseq->body->cc_entries;
+ union iseq_inline_storage_entry *is_entries = iseq->body->is_entries;
for (code_index=0; code_index<iseq_size;) {
- /* opcode */
- const VALUE insn = code[code_index++] = ibf_load_small_value(load, &reading_pos);
- const char *types = insn_op_types(insn);
- int op_index;
-
- /* operands */
- for (op_index=0; types[op_index]; op_index++, code_index++) {
- switch (types[op_index]) {
- case TS_CDHASH:
- case TS_VALUE:
- {
- VALUE op = ibf_load_small_value(load, &reading_pos);
- VALUE v = ibf_load_object(load, op);
- code[code_index] = v;
- if (!SPECIAL_CONST_P(v)) {
- RB_OBJ_WRITTEN(iseq, Qundef, v);
- FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
- }
- break;
- }
- case TS_ISEQ:
- {
- VALUE op = (VALUE)ibf_load_small_value(load, &reading_pos);
- VALUE v = (VALUE)ibf_load_iseq(load, (const rb_iseq_t *)op);
- code[code_index] = v;
- if (!SPECIAL_CONST_P(v)) {
- RB_OBJ_WRITTEN(iseq, Qundef, v);
- FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
- }
- break;
- }
- case TS_ISE:
- FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
- /* fall through */
- case TS_IC:
- case TS_IVC:
- {
- VALUE op = ibf_load_small_value(load, &reading_pos);
- code[code_index] = (VALUE)&is_entries[op];
- }
- break;
- case TS_CALLDATA:
- {
- unsigned char op = ibf_load_byte(load, &reading_pos);
- code[code_index] = op ? (VALUE)cd_kw_entries++ : (VALUE)cd_entries++; /* op is 1 (kw) or 0 (!kw) */
- }
- break;
- case TS_ID:
- {
- VALUE op = ibf_load_small_value(load, &reading_pos);
- code[code_index] = ibf_load_id(load, (ID)(VALUE)op);
- }
- break;
- case TS_GENTRY:
- {
- VALUE op = ibf_load_small_value(load, &reading_pos);
- code[code_index] = ibf_load_gentry(load, (const struct rb_global_entry *)(VALUE)op);
- }
- break;
- case TS_FUNCPTR:
- rb_raise(rb_eRuntimeError, "TS_FUNCPTR is not supported");
- break;
- case TS_BUILTIN:
- code[code_index] = (VALUE)ibf_load_builtin(load, &reading_pos);
- break;
- default:
- code[code_index] = ibf_load_small_value(load, &reading_pos);
- continue;
- }
- }
- if (insn_len(insn) != op_index+1) {
- rb_raise(rb_eRuntimeError, "operand size mismatch");
- }
+ const VALUE insn = code[code_index++];
+ const char *types = insn_op_types(insn);
+ int op_index;
+
+ for (op_index=0; types[op_index]; op_index++, code_index++) {
+ VALUE op = code[code_index];
+
+ switch (types[op_index]) {
+ case TS_CDHASH:
+ case TS_VALUE:
+ code[code_index] = ibf_load_object(load, op);
+ break;
+ case TS_ISEQ:
+ code[code_index] = (VALUE)ibf_load_iseq(load, (const rb_iseq_t *)op);
+ break;
+ case TS_IC:
+ code[code_index] = (VALUE)&is_entries[(int)op];
+ break;
+ case TS_CALLINFO:
+ code[code_index] = op ? (VALUE)ci_kw_entries++ : (VALUE)ci_entries++; /* op is Qtrue (kw) or Qfalse (!kw) */
+ break;
+ case TS_CALLCACHE:
+ code[code_index] = (VALUE)cc_entries++;
+ break;
+ case TS_ID:
+ code[code_index] = ibf_load_id(load, (ID)op);
+ break;
+ case TS_GENTRY:
+ code[code_index] = ibf_load_gentry(load, (const struct rb_global_entry *)op);
+ break;
+ case TS_FUNCPTR:
+ rb_raise(rb_eRuntimeError, "TS_FUNCPTR is not supported");
+ break;
+ default:
+ /* code[code_index] = op; */
+ break;
+ }
+ }
+ if (insn_len(insn) != op_index+1) {
+ rb_raise(rb_eRuntimeError, "operand size mismatch");
+ }
}
- load_body->iseq_encoded = code;
- load_body->iseq_size = code_index;
- assert(code_index == iseq_size);
- assert(reading_pos == bytecode_offset + bytecode_size);
+
return code;
}
-static ibf_offset_t
+static VALUE *
ibf_dump_param_opt_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
int opt_num = iseq->body->param.opt_num;
if (opt_num > 0) {
- IBF_W_ALIGN(VALUE);
- return ibf_dump_write(dump, iseq->body->param.opt_table, sizeof(VALUE) * (opt_num + 1));
+ return IBF_W(iseq->body->param.opt_table, VALUE, opt_num + 1);
}
else {
- return ibf_dump_pos(dump);
+ return NULL;
}
}
static VALUE *
-ibf_load_param_opt_table(const struct ibf_load *load, ibf_offset_t opt_table_offset, int opt_num)
+ibf_load_param_opt_table(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
{
+ int opt_num = body->param.opt_num;
+
if (opt_num > 0) {
- VALUE *table = ALLOC_N(VALUE, opt_num+1);
- MEMCPY(table, load->current_buffer->buff + opt_table_offset, VALUE, opt_num+1);
- return table;
+ ibf_offset_t offset = IBF_OFFSET(body->param.opt_table);
+ VALUE *table = ALLOC_N(VALUE, opt_num+1);
+ MEMCPY(table, load->buff + offset, VALUE, opt_num+1);
+ return table;
}
else {
- return NULL;
+ return NULL;
}
}
-static ibf_offset_t
+static struct rb_iseq_param_keyword *
ibf_dump_param_keyword(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
const struct rb_iseq_param_keyword *kw = iseq->body->param.keyword;
if (kw) {
- struct rb_iseq_param_keyword dump_kw = *kw;
- int dv_num = kw->num - kw->required_num;
- ID *ids = kw->num > 0 ? ALLOCA_N(ID, kw->num) : NULL;
- VALUE *dvs = dv_num > 0 ? ALLOCA_N(VALUE, dv_num) : NULL;
- int i;
+ struct rb_iseq_param_keyword dump_kw = *kw;
+ int dv_num = kw->num - kw->required_num;
+ ID *ids = kw->num > 0 ? ALLOCA_N(ID, kw->num) : NULL;
+ VALUE *dvs = dv_num > 0 ? ALLOCA_N(VALUE, dv_num) : NULL;
+ int i;
- for (i=0; i<kw->num; i++) ids[i] = (ID)ibf_dump_id(dump, kw->table[i]);
- for (i=0; i<dv_num; i++) dvs[i] = (VALUE)ibf_dump_object(dump, kw->default_values[i]);
+ for (i=0; i<kw->num; i++) ids[i] = (ID)ibf_dump_id(dump, kw->table[i]);
+ for (i=0; i<dv_num; i++) dvs[i] = (VALUE)ibf_dump_object(dump, kw->default_values[i]);
- dump_kw.table = IBF_W(ids, ID, kw->num);
- dump_kw.default_values = IBF_W(dvs, VALUE, dv_num);
- IBF_W_ALIGN(struct rb_iseq_param_keyword);
- return ibf_dump_write(dump, &dump_kw, sizeof(struct rb_iseq_param_keyword) * 1);
+ dump_kw.table = IBF_W(ids, ID, kw->num);
+ dump_kw.default_values = IBF_W(dvs, VALUE, dv_num);
+ return IBF_W(&dump_kw, struct rb_iseq_param_keyword, 1);
}
else {
- return 0;
+ return NULL;
}
}
static const struct rb_iseq_param_keyword *
-ibf_load_param_keyword(const struct ibf_load *load, ibf_offset_t param_keyword_offset)
+ibf_load_param_keyword(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
{
- if (param_keyword_offset) {
- struct rb_iseq_param_keyword *kw = IBF_R(param_keyword_offset, struct rb_iseq_param_keyword, 1);
- ID *ids = IBF_R(kw->table, ID, kw->num);
- int dv_num = kw->num - kw->required_num;
- VALUE *dvs = IBF_R(kw->default_values, VALUE, dv_num);
- int i;
+ if (body->param.keyword) {
+ struct rb_iseq_param_keyword *kw = IBF_R(body->param.keyword, struct rb_iseq_param_keyword, 1);
+ ID *ids = IBF_R(kw->table, ID, kw->num);
+ int dv_num = kw->num - kw->required_num;
+ VALUE *dvs = IBF_R(kw->default_values, VALUE, dv_num);
+ int i;
- for (i=0; i<kw->num; i++) {
- ids[i] = ibf_load_id(load, ids[i]);
- }
- for (i=0; i<dv_num; i++) {
- dvs[i] = ibf_load_object(load, dvs[i]);
- }
+ for (i=0; i<kw->num; i++) {
+ ids[i] = ibf_load_id(load, ids[i]);
+ }
+ for (i=0; i<dv_num; i++) {
+ dvs[i] = ibf_load_object(load, dvs[i]);
+ }
- kw->table = ids;
- kw->default_values = dvs;
- return kw;
+ kw->table = ids;
+ kw->default_values = dvs;
+ return kw;
}
else {
- return NULL;
- }
-}
-
-static ibf_offset_t
-ibf_dump_insns_info_body(struct ibf_dump *dump, const rb_iseq_t *iseq)
-{
- ibf_offset_t offset = ibf_dump_pos(dump);
- const struct iseq_insn_info_entry *entries = iseq->body->insns_info.body;
-
- unsigned int i;
- for (i = 0; i < iseq->body->insns_info.size; i++) {
- ibf_dump_write_small_value(dump, entries[i].line_no);
- ibf_dump_write_small_value(dump, entries[i].events);
+ return NULL;
}
-
- return offset;
}
static struct iseq_insn_info_entry *
-ibf_load_insns_info_body(const struct ibf_load *load, ibf_offset_t body_offset, unsigned int size)
+ibf_dump_insns_info(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- ibf_offset_t reading_pos = body_offset;
- struct iseq_insn_info_entry *entries = ALLOC_N(struct iseq_insn_info_entry, size);
-
- unsigned int i;
- for (i = 0; i < size; i++) {
- entries[i].line_no = (int)ibf_load_small_value(load, &reading_pos);
- entries[i].events = (rb_event_flag_t)ibf_load_small_value(load, &reading_pos);
- }
-
- return entries;
+ return IBF_W(iseq->body->insns_info, struct iseq_insn_info_entry, iseq->body->insns_info_size);
}
-static ibf_offset_t
-ibf_dump_insns_info_positions(struct ibf_dump *dump, const unsigned int *positions, unsigned int size)
+static struct iseq_insn_info_entry *
+ibf_load_insns_info(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
{
- ibf_offset_t offset = ibf_dump_pos(dump);
-
- unsigned int last = 0;
- unsigned int i;
- for (i = 0; i < size; i++) {
- ibf_dump_write_small_value(dump, positions[i] - last);
- last = positions[i];
- }
-
- return offset;
+ return IBF_R(body->insns_info, struct iseq_insn_info_entry, body->insns_info_size);
}
-static unsigned int *
-ibf_load_insns_info_positions(const struct ibf_load *load, ibf_offset_t positions_offset, unsigned int size)
-{
- ibf_offset_t reading_pos = positions_offset;
- unsigned int *positions = ALLOC_N(unsigned int, size);
-
- unsigned int last = 0;
- unsigned int i;
- for (i = 0; i < size; i++) {
- positions[i] = last + (unsigned int)ibf_load_small_value(load, &reading_pos);
- last = positions[i];
- }
-
- return positions;
-}
-
-static ibf_offset_t
+static ID *
ibf_dump_local_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
- const int size = body->local_table_size;
+ const int size = iseq->body->local_table_size;
ID *table = ALLOCA_N(ID, size);
int i;
for (i=0; i<size; i++) {
- table[i] = ibf_dump_id(dump, body->local_table[i]);
+ table[i] = ibf_dump_id(dump, iseq->body->local_table[i]);
}
- IBF_W_ALIGN(ID);
- return ibf_dump_write(dump, table, sizeof(ID) * size);
+ return IBF_W(table, ID, size);
}
static ID *
-ibf_load_local_table(const struct ibf_load *load, ibf_offset_t local_table_offset, int size)
+ibf_load_local_table(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
{
+ const int size = body->local_table_size;
+
if (size > 0) {
- ID *table = IBF_R(local_table_offset, ID, size);
- int i;
+ ID *table = IBF_R(body->local_table, ID, size);
+ int i;
- for (i=0; i<size; i++) {
- table[i] = ibf_load_id(load, table[i]);
- }
- return table;
+ for (i=0; i<size; i++) {
+ table[i] = ibf_load_id(load, table[i]);
+ }
+ return table;
}
else {
- return NULL;
+ return NULL;
}
}
-static ibf_offset_t
+static struct iseq_catch_table *
ibf_dump_catch_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
const struct iseq_catch_table *table = iseq->body->catch_table;
if (table) {
- int *iseq_indices = ALLOCA_N(int, table->size);
- unsigned int i;
-
- for (i=0; i<table->size; i++) {
- iseq_indices[i] = ibf_dump_iseq(dump, table->entries[i].iseq);
- }
-
- const ibf_offset_t offset = ibf_dump_pos(dump);
-
- for (i=0; i<table->size; i++) {
- ibf_dump_write_small_value(dump, iseq_indices[i]);
- ibf_dump_write_small_value(dump, table->entries[i].type);
- ibf_dump_write_small_value(dump, table->entries[i].start);
- ibf_dump_write_small_value(dump, table->entries[i].end);
- ibf_dump_write_small_value(dump, table->entries[i].cont);
- ibf_dump_write_small_value(dump, table->entries[i].sp);
- }
- return offset;
+ int byte_size = iseq_catch_table_bytes(iseq->body->catch_table->size);
+ struct iseq_catch_table *dump_table = (struct iseq_catch_table *)ALLOCA_N(char, byte_size);
+ unsigned int i;
+ dump_table->size = table->size;
+ for (i=0; i<table->size; i++) {
+ dump_table->entries[i] = table->entries[i];
+ dump_table->entries[i].iseq = ibf_dump_iseq(dump, table->entries[i].iseq);
+ }
+ return (struct iseq_catch_table *)(VALUE)ibf_dump_write(dump, dump_table, byte_size);
}
else {
- return ibf_dump_pos(dump);
+ return NULL;
}
}
static struct iseq_catch_table *
-ibf_load_catch_table(const struct ibf_load *load, ibf_offset_t catch_table_offset, unsigned int size)
+ibf_load_catch_table(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
{
- if (size) {
- struct iseq_catch_table *table = ruby_xmalloc(iseq_catch_table_bytes(size));
- table->size = size;
-
- ibf_offset_t reading_pos = catch_table_offset;
-
- unsigned int i;
- for (i=0; i<table->size; i++) {
- int iseq_index = (int)ibf_load_small_value(load, &reading_pos);
- table->entries[i].type = (enum catch_type)ibf_load_small_value(load, &reading_pos);
- table->entries[i].start = (unsigned int)ibf_load_small_value(load, &reading_pos);
- table->entries[i].end = (unsigned int)ibf_load_small_value(load, &reading_pos);
- table->entries[i].cont = (unsigned int)ibf_load_small_value(load, &reading_pos);
- table->entries[i].sp = (unsigned int)ibf_load_small_value(load, &reading_pos);
-
- table->entries[i].iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)iseq_index);
- }
- return table;
+ if (body->catch_table) {
+ struct iseq_catch_table *table;
+ unsigned int i;
+ unsigned int size;
+ size = *(unsigned int *)(load->buff + IBF_OFFSET(body->catch_table));
+ table = ibf_load_alloc(load, IBF_OFFSET(body->catch_table), iseq_catch_table_bytes(size));
+ for (i=0; i<size; i++) {
+ table->entries[i].iseq = ibf_load_iseq(load, table->entries[i].iseq);
+ }
+ return table;
}
else {
- return NULL;
+ return NULL;
}
}
-static ibf_offset_t
+static struct rb_call_info *
ibf_dump_ci_entries(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
- const unsigned int ci_size = body->ci_size;
- const unsigned int ci_kw_size = body->ci_kw_size;
- const struct rb_call_data *calls = body->call_data;
- const struct rb_kwarg_call_data *kw_calls = (const struct rb_kwarg_call_data *)&body->call_data[ci_size];
-
- ibf_offset_t offset = ibf_dump_pos(dump);
-
+ const unsigned int ci_size = iseq->body->ci_size;
+ const unsigned int ci_kw_size = iseq->body->ci_kw_size;
+ const struct rb_call_info *ci_entries = iseq->body->ci_entries;
+ struct rb_call_info *dump_ci_entries;
+ struct rb_call_info_with_kwarg *dump_ci_kw_entries;
+ int byte_size = ci_size * sizeof(struct rb_call_info) +
+ ci_kw_size * sizeof(struct rb_call_info_with_kwarg);
unsigned int i;
- for (i = 0; i < ci_size; i++) {
- VALUE mid = ibf_dump_id(dump, calls[i].ci.mid);
+ dump_ci_entries = (struct rb_call_info *)ALLOCA_N(char, byte_size);
+ dump_ci_kw_entries = (struct rb_call_info_with_kwarg *)&dump_ci_entries[ci_size];
+ memcpy(dump_ci_entries, ci_entries, byte_size);
- ibf_dump_write_small_value(dump, mid);
- ibf_dump_write_small_value(dump, calls[i].ci.flag);
- ibf_dump_write_small_value(dump, calls[i].ci.orig_argc);
+ for (i=0; i<ci_size; i++) { /* conver ID for each ci */
+ dump_ci_entries[i].mid = ibf_dump_id(dump, dump_ci_entries[i].mid);
}
+ for (i=0; i<ci_kw_size; i++) {
+ const struct rb_call_info_kw_arg *kw_arg = dump_ci_kw_entries[i].kw_arg;
+ int j;
+ VALUE *keywords = ALLOCA_N(VALUE, kw_arg->keyword_len);
+ for (j=0; j<kw_arg->keyword_len; j++) {
+ keywords[j] = (VALUE)ibf_dump_object(dump, kw_arg->keywords[j]); /* kw_arg->keywords[n] is Symbol */
+ }
+ dump_ci_kw_entries[i].kw_arg = (struct rb_call_info_kw_arg *)(VALUE)ibf_dump_write(dump, &kw_arg->keyword_len, sizeof(int));
+ ibf_dump_write(dump, keywords, sizeof(VALUE) * kw_arg->keyword_len);
- for (i = 0; i < ci_kw_size; i++) {
- const struct rb_call_info_kw_arg *kw_arg = kw_calls[i].ci_kw.kw_arg;
-
- VALUE mid = ibf_dump_id(dump, kw_calls[i].ci_kw.ci.mid);
-
- ibf_dump_write_small_value(dump, mid);
- ibf_dump_write_small_value(dump, kw_calls[i].ci_kw.ci.flag);
- ibf_dump_write_small_value(dump, kw_calls[i].ci_kw.ci.orig_argc);
-
- ibf_dump_write_small_value(dump, kw_arg->keyword_len);
-
- int j;
- for (j = 0; j < kw_calls[i].ci_kw.kw_arg->keyword_len; j++) {
- VALUE keyword = ibf_dump_object(dump, kw_arg->keywords[j]); /* kw_arg->keywords[n] is Symbol */
-
- ibf_dump_write_small_value(dump, keyword);
- }
+ dump_ci_kw_entries[i].ci.mid = ibf_dump_id(dump, dump_ci_kw_entries[i].ci.mid);
}
-
- return offset;
+ return (struct rb_call_info *)(VALUE)ibf_dump_write(dump, dump_ci_entries, byte_size);
}
-/* note that we dump out rb_call_info but load back rb_call_data */
-static struct rb_call_data *
-ibf_load_ci_entries(const struct ibf_load *load,
- ibf_offset_t ci_entries_offset,
- unsigned int ci_size,
- unsigned int ci_kw_size)
+static struct rb_call_info *
+ibf_load_ci_entries(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
{
- ibf_offset_t reading_pos = ci_entries_offset;
-
unsigned int i;
+ const unsigned int ci_size = body->ci_size;
+ const unsigned int ci_kw_size = body->ci_kw_size;
+ struct rb_call_info *ci_entries = ibf_load_alloc(load, IBF_OFFSET(body->ci_entries),
+ sizeof(struct rb_call_info) * body->ci_size +
+ sizeof(struct rb_call_info_with_kwarg) * body->ci_kw_size);
+ struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&ci_entries[ci_size];
- struct rb_call_data *calls =
- rb_xcalloc_mul_add_mul(
- sizeof(struct rb_call_data), ci_size,
- sizeof(struct rb_kwarg_call_data), ci_kw_size);
- struct rb_kwarg_call_data *kw_calls = (struct rb_kwarg_call_data *)&calls[ci_size];
-
- for (i = 0; i < ci_size; i++) {
- VALUE mid_index = ibf_load_small_value(load, &reading_pos);
-
- calls[i].ci.mid = ibf_load_id(load, mid_index);
- calls[i].ci.flag = (unsigned int)ibf_load_small_value(load, &reading_pos);
- calls[i].ci.orig_argc = (int)ibf_load_small_value(load, &reading_pos);
+ for (i=0; i<ci_size; i++) {
+ ci_entries[i].mid = ibf_load_id(load, ci_entries[i].mid);
}
-
- for (i = 0; i < ci_kw_size; i++) {
- VALUE mid_index = ibf_load_small_value(load, &reading_pos);
-
- kw_calls[i].ci_kw.ci.mid = ibf_load_id(load, mid_index);
- kw_calls[i].ci_kw.ci.flag = (unsigned int)ibf_load_small_value(load, &reading_pos);
- kw_calls[i].ci_kw.ci.orig_argc = (int)ibf_load_small_value(load, &reading_pos);
-
- int keyword_len = (int)ibf_load_small_value(load, &reading_pos);
-
- kw_calls[i].ci_kw.kw_arg =
- rb_xmalloc_mul_add(keyword_len - 1, sizeof(VALUE), sizeof(struct rb_call_info_kw_arg));
-
- kw_calls[i].ci_kw.kw_arg->keyword_len = keyword_len;
-
- int j;
- for (j = 0; j < kw_calls[i].ci_kw.kw_arg->keyword_len; j++) {
- VALUE keyword = ibf_load_small_value(load, &reading_pos);
-
- kw_calls[i].ci_kw.kw_arg->keywords[j] = ibf_load_object(load, keyword);
- }
+ for (i=0; i<ci_kw_size; i++) {
+ int j;
+ ibf_offset_t kw_arg_offset = IBF_OFFSET(ci_kw_entries[i].kw_arg);
+ const int keyword_len = *(int *)(load->buff + kw_arg_offset);
+ const VALUE *keywords = (VALUE *)(load->buff + kw_arg_offset + sizeof(int));
+ struct rb_call_info_kw_arg *kw_arg = ruby_xmalloc(sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1));
+ kw_arg->keyword_len = keyword_len;
+ for (j=0; j<kw_arg->keyword_len; j++) {
+ kw_arg->keywords[j] = (VALUE)ibf_load_object(load, keywords[j]);
+ }
+ ci_kw_entries[i].kw_arg = kw_arg;
+ ci_kw_entries[i].ci.mid = ibf_load_id(load, ci_kw_entries[i].ci.mid);
}
- return calls;
+ return ci_entries;
}
static ibf_offset_t
ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- assert(dump->current_buffer == &dump->global_buffer);
-
- unsigned int *positions;
-
- const struct rb_iseq_constant_body *body = iseq->body;
-
- const VALUE location_pathobj_index = ibf_dump_object(dump, body->location.pathobj); /* TODO: freeze */
- const VALUE location_base_label_index = ibf_dump_object(dump, body->location.base_label);
- const VALUE location_label_index = ibf_dump_object(dump, body->location.label);
-
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
- ibf_offset_t iseq_start = ibf_dump_pos(dump);
-
- struct ibf_dump_buffer *saved_buffer = dump->current_buffer;
- struct ibf_dump_buffer buffer;
- buffer.str = rb_str_new(0, 0);
- buffer.obj_list = ibf_dump_object_list_new();
- dump->current_buffer = &buffer;
-#endif
-
- const ibf_offset_t bytecode_offset = ibf_dump_code(dump, iseq);
- const ibf_offset_t bytecode_size = ibf_dump_pos(dump) - bytecode_offset;
- const ibf_offset_t param_opt_table_offset = ibf_dump_param_opt_table(dump, iseq);
- const ibf_offset_t param_keyword_offset = ibf_dump_param_keyword(dump, iseq);
- const ibf_offset_t insns_info_body_offset = ibf_dump_insns_info_body(dump, iseq);
+ struct rb_iseq_constant_body dump_body;
+ dump_body = *iseq->body;
- positions = rb_iseq_insns_info_decode_positions(iseq->body);
- const ibf_offset_t insns_info_positions_offset = ibf_dump_insns_info_positions(dump, positions, body->insns_info.size);
- ruby_xfree(positions);
+ dump_body.location.pathobj = ibf_dump_object(dump, dump_body.location.pathobj); /* TODO: freeze */
+ dump_body.location.base_label = ibf_dump_object(dump, dump_body.location.base_label);
+ dump_body.location.label = ibf_dump_object(dump, dump_body.location.label);
- const ibf_offset_t local_table_offset = ibf_dump_local_table(dump, iseq);
- const unsigned int catch_table_size = body->catch_table ? body->catch_table->size : 0;
- const ibf_offset_t catch_table_offset = ibf_dump_catch_table(dump, iseq);
- const int parent_iseq_index = ibf_dump_iseq(dump, iseq->body->parent_iseq);
- const int local_iseq_index = ibf_dump_iseq(dump, iseq->body->local_iseq);
- const ibf_offset_t ci_entries_offset = ibf_dump_ci_entries(dump, iseq);
+ dump_body.iseq_encoded = ibf_dump_code(dump, iseq);
+ dump_body.param.opt_table = ibf_dump_param_opt_table(dump, iseq);
+ dump_body.param.keyword = ibf_dump_param_keyword(dump, iseq);
+ dump_body.insns_info = ibf_dump_insns_info(dump, iseq);
+ dump_body.local_table = ibf_dump_local_table(dump, iseq);
+ dump_body.catch_table = ibf_dump_catch_table(dump, iseq);
+ dump_body.parent_iseq = ibf_dump_iseq(dump, iseq->body->parent_iseq);
+ dump_body.local_iseq = ibf_dump_iseq(dump, iseq->body->local_iseq);
+ dump_body.is_entries = NULL;
+ dump_body.ci_entries = ibf_dump_ci_entries(dump, iseq);
+ dump_body.cc_entries = NULL;
+ dump_body.mark_ary = ISEQ_FLIP_CNT(iseq);
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
- ibf_offset_t local_obj_list_offset;
- unsigned int local_obj_list_size;
-
- ibf_dump_object_list(dump, &local_obj_list_offset, &local_obj_list_size);
-#endif
-
- ibf_offset_t body_offset = ibf_dump_pos(dump);
-
- /* dump the constant body */
- unsigned int param_flags =
- (body->param.flags.has_lead << 0) |
- (body->param.flags.has_opt << 1) |
- (body->param.flags.has_rest << 2) |
- (body->param.flags.has_post << 3) |
- (body->param.flags.has_kw << 4) |
- (body->param.flags.has_kwrest << 5) |
- (body->param.flags.has_block << 6) |
- (body->param.flags.ambiguous_param0 << 7) |
- (body->param.flags.accepts_no_kwarg << 8) |
- (body->param.flags.ruby2_keywords << 9);
-
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
-# define IBF_BODY_OFFSET(x) (x)
-#else
-# define IBF_BODY_OFFSET(x) (body_offset - (x))
-#endif
-
- ibf_dump_write_small_value(dump, body->type);
- ibf_dump_write_small_value(dump, body->iseq_size);
- ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(bytecode_offset));
- ibf_dump_write_small_value(dump, bytecode_size);
- ibf_dump_write_small_value(dump, param_flags);
- ibf_dump_write_small_value(dump, body->param.size);
- ibf_dump_write_small_value(dump, body->param.lead_num);
- ibf_dump_write_small_value(dump, body->param.opt_num);
- ibf_dump_write_small_value(dump, body->param.rest_start);
- ibf_dump_write_small_value(dump, body->param.post_start);
- ibf_dump_write_small_value(dump, body->param.post_num);
- ibf_dump_write_small_value(dump, body->param.block_start);
- ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(param_opt_table_offset));
- ibf_dump_write_small_value(dump, param_keyword_offset);
- ibf_dump_write_small_value(dump, location_pathobj_index);
- ibf_dump_write_small_value(dump, location_base_label_index);
- ibf_dump_write_small_value(dump, location_label_index);
- ibf_dump_write_small_value(dump, body->location.first_lineno);
- ibf_dump_write_small_value(dump, body->location.node_id);
- ibf_dump_write_small_value(dump, body->location.code_location.beg_pos.lineno);
- ibf_dump_write_small_value(dump, body->location.code_location.beg_pos.column);
- ibf_dump_write_small_value(dump, body->location.code_location.end_pos.lineno);
- ibf_dump_write_small_value(dump, body->location.code_location.end_pos.column);
- ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(insns_info_body_offset));
- ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(insns_info_positions_offset));
- ibf_dump_write_small_value(dump, body->insns_info.size);
- ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(local_table_offset));
- ibf_dump_write_small_value(dump, catch_table_size);
- ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(catch_table_offset));
- ibf_dump_write_small_value(dump, parent_iseq_index);
- ibf_dump_write_small_value(dump, local_iseq_index);
- ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(ci_entries_offset));
- ibf_dump_write_small_value(dump, body->variable.flip_count);
- ibf_dump_write_small_value(dump, body->local_table_size);
- ibf_dump_write_small_value(dump, body->is_size);
- ibf_dump_write_small_value(dump, body->ci_size);
- ibf_dump_write_small_value(dump, body->ci_kw_size);
- ibf_dump_write_small_value(dump, body->stack_max);
- ibf_dump_write_small_value(dump, body->catch_except_p);
-
-#undef IBF_BODY_OFFSET
-
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
- ibf_offset_t iseq_length_bytes = ibf_dump_pos(dump);
-
- dump->current_buffer = saved_buffer;
- ibf_dump_write(dump, RSTRING_PTR(buffer.str), iseq_length_bytes);
-
- ibf_offset_t offset = ibf_dump_pos(dump);
- ibf_dump_write_small_value(dump, iseq_start);
- ibf_dump_write_small_value(dump, iseq_length_bytes);
- ibf_dump_write_small_value(dump, body_offset);
-
- ibf_dump_write_small_value(dump, local_obj_list_offset);
- ibf_dump_write_small_value(dump, local_obj_list_size);
-
- return offset;
-#else
- return body_offset;
-#endif
+ return ibf_dump_write(dump, &dump_body, sizeof(dump_body));
}
static VALUE
@@ -10489,203 +8658,132 @@ ibf_load_location_str(const struct ibf_load *load, VALUE str_index)
{
VALUE str = ibf_load_object(load, str_index);
if (str != Qnil) {
- str = rb_fstring(str);
+ str = rb_fstring(str);
}
return str;
}
static void
-ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
+ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
{
- struct rb_iseq_constant_body *load_body = iseq->body = rb_iseq_constant_body_alloc();
-
- ibf_offset_t reading_pos = offset;
+ struct rb_iseq_constant_body *load_body = iseq->body = ZALLOC(struct rb_iseq_constant_body);
+ const struct rb_iseq_constant_body *body = (struct rb_iseq_constant_body *)(load->buff + offset);
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
- struct ibf_load_buffer *saved_buffer = load->current_buffer;
- load->current_buffer = &load->global_buffer;
+ /* memcpy(load_body, load->buff + offset, sizeof(*load_body)); */
+ load_body->type = body->type;
+ load_body->stack_max = body->stack_max;
+ load_body->iseq_size = body->iseq_size;
+ load_body->param = body->param;
+ load_body->local_table_size = body->local_table_size;
+ load_body->is_size = body->is_size;
+ load_body->ci_size = body->ci_size;
+ load_body->ci_kw_size = body->ci_kw_size;
+ load_body->insns_info_size = body->insns_info_size;
- const ibf_offset_t iseq_start = ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t iseq_length_bytes = ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t body_offset = ibf_load_small_value(load, &reading_pos);
+ RB_OBJ_WRITE(iseq, &load_body->mark_ary, iseq_mark_ary_create((int)body->mark_ary));
- struct ibf_load_buffer buffer;
- buffer.buff = load->global_buffer.buff + iseq_start;
- buffer.size = iseq_length_bytes;
- buffer.obj_list_offset = ibf_load_small_value(load, &reading_pos);
- buffer.obj_list_size = ibf_load_small_value(load, &reading_pos);
- buffer.obj_list = rb_ary_tmp_new(buffer.obj_list_size);
- rb_ary_resize(buffer.obj_list, buffer.obj_list_size);
+ {
+ VALUE realpath = Qnil, path = ibf_load_object(load, body->location.pathobj);
+ if (RB_TYPE_P(path, T_STRING)) {
+ realpath = path = rb_fstring(path);
+ }
+ else if (RB_TYPE_P(path, T_ARRAY)) {
+ VALUE pathobj = path;
+ if (RARRAY_LEN(pathobj) != 2) {
+ rb_raise(rb_eRuntimeError, "path object size mismatch");
+ }
+ path = rb_fstring(RARRAY_AREF(pathobj, 0));
+ realpath = RARRAY_AREF(pathobj, 1);
+ if (!NIL_P(realpath)) {
+ if (!RB_TYPE_P(realpath, T_STRING)) {
+ rb_raise(rb_eArgError, "unexpected realpath %"PRIxVALUE
+ "(%x), path=%+"PRIsVALUE,
+ realpath, TYPE(realpath), path);
+ }
+ realpath = rb_fstring(realpath);
+ }
+ }
+ else {
+ rb_raise(rb_eRuntimeError, "unexpected path object");
+ }
+ rb_iseq_pathobj_set(iseq, path, realpath);
+ }
- load->current_buffer = &buffer;
- reading_pos = body_offset;
-#endif
+ RB_OBJ_WRITE(iseq, &load_body->location.base_label, ibf_load_location_str(load, body->location.base_label));
+ RB_OBJ_WRITE(iseq, &load_body->location.label, ibf_load_location_str(load, body->location.label));
+ load_body->location.first_lineno = body->location.first_lineno;
+ load_body->location.code_range = body->location.code_range;
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
-# define IBF_BODY_OFFSET(x) (x)
-#else
-# define IBF_BODY_OFFSET(x) (offset - (x))
-#endif
+ load_body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, body->is_size);
+ load_body->ci_entries = ibf_load_ci_entries(load, body);
+ load_body->cc_entries = ZALLOC_N(struct rb_call_cache, body->ci_size + body->ci_kw_size);
+ load_body->param.opt_table = ibf_load_param_opt_table(load, body);
+ load_body->param.keyword = ibf_load_param_keyword(load, body);
+ load_body->insns_info = ibf_load_insns_info(load, body);
+ load_body->local_table = ibf_load_local_table(load, body);
+ load_body->catch_table = ibf_load_catch_table(load, body);
+ load_body->parent_iseq = ibf_load_iseq(load, body->parent_iseq);
+ load_body->local_iseq = ibf_load_iseq(load, body->local_iseq);
- const unsigned int type = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const unsigned int iseq_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t bytecode_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
- const ibf_offset_t bytecode_size = (ibf_offset_t)ibf_load_small_value(load, &reading_pos);
- const unsigned int param_flags = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const unsigned int param_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const int param_lead_num = (int)ibf_load_small_value(load, &reading_pos);
- const int param_opt_num = (int)ibf_load_small_value(load, &reading_pos);
- const int param_rest_start = (int)ibf_load_small_value(load, &reading_pos);
- const int param_post_start = (int)ibf_load_small_value(load, &reading_pos);
- const int param_post_num = (int)ibf_load_small_value(load, &reading_pos);
- const int param_block_start = (int)ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t param_opt_table_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
- const ibf_offset_t param_keyword_offset = (ibf_offset_t)ibf_load_small_value(load, &reading_pos);
- const VALUE location_pathobj_index = ibf_load_small_value(load, &reading_pos);
- const VALUE location_base_label_index = ibf_load_small_value(load, &reading_pos);
- const VALUE location_label_index = ibf_load_small_value(load, &reading_pos);
- const VALUE location_first_lineno = ibf_load_small_value(load, &reading_pos);
- const int location_node_id = (int)ibf_load_small_value(load, &reading_pos);
- const int location_code_location_beg_pos_lineno = (int)ibf_load_small_value(load, &reading_pos);
- const int location_code_location_beg_pos_column = (int)ibf_load_small_value(load, &reading_pos);
- const int location_code_location_end_pos_lineno = (int)ibf_load_small_value(load, &reading_pos);
- const int location_code_location_end_pos_column = (int)ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t insns_info_body_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
- const ibf_offset_t insns_info_positions_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
- const unsigned int insns_info_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t local_table_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
- const unsigned int catch_table_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t catch_table_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
- const int parent_iseq_index = (int)ibf_load_small_value(load, &reading_pos);
- const int local_iseq_index = (int)ibf_load_small_value(load, &reading_pos);
- const ibf_offset_t ci_entries_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
- const rb_snum_t variable_flip_count = (rb_snum_t)ibf_load_small_value(load, &reading_pos);
- const unsigned int local_table_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const unsigned int is_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const unsigned int ci_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const unsigned int ci_kw_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const unsigned int stack_max = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const char catch_except_p = (char)ibf_load_small_value(load, &reading_pos);
-
-#undef IBF_BODY_OFFSET
-
- load_body->type = type;
- load_body->stack_max = stack_max;
- load_body->param.flags.has_lead = (param_flags >> 0) & 1;
- load_body->param.flags.has_opt = (param_flags >> 1) & 1;
- load_body->param.flags.has_rest = (param_flags >> 2) & 1;
- load_body->param.flags.has_post = (param_flags >> 3) & 1;
- load_body->param.flags.has_kw = FALSE;
- load_body->param.flags.has_kwrest = (param_flags >> 5) & 1;
- load_body->param.flags.has_block = (param_flags >> 6) & 1;
- load_body->param.flags.ambiguous_param0 = (param_flags >> 7) & 1;
- load_body->param.flags.accepts_no_kwarg = (param_flags >> 8) & 1;
- load_body->param.flags.ruby2_keywords = (param_flags >> 9) & 1;
- load_body->param.size = param_size;
- load_body->param.lead_num = param_lead_num;
- load_body->param.opt_num = param_opt_num;
- load_body->param.rest_start = param_rest_start;
- load_body->param.post_start = param_post_start;
- load_body->param.post_num = param_post_num;
- load_body->param.block_start = param_block_start;
- load_body->local_table_size = local_table_size;
- load_body->is_size = is_size;
- load_body->ci_size = ci_size;
- load_body->ci_kw_size = ci_kw_size;
- load_body->insns_info.size = insns_info_size;
-
- ISEQ_COVERAGE_SET(iseq, Qnil);
- ISEQ_ORIGINAL_ISEQ_CLEAR(iseq);
- iseq->body->variable.flip_count = variable_flip_count;
-
- load_body->location.first_lineno = location_first_lineno;
- load_body->location.node_id = location_node_id;
- load_body->location.code_location.beg_pos.lineno = location_code_location_beg_pos_lineno;
- load_body->location.code_location.beg_pos.column = location_code_location_beg_pos_column;
- load_body->location.code_location.end_pos.lineno = location_code_location_end_pos_lineno;
- load_body->location.code_location.end_pos.column = location_code_location_end_pos_column;
- load_body->catch_except_p = catch_except_p;
-
- load_body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, is_size);
- load_body->call_data = ibf_load_ci_entries(load, ci_entries_offset, ci_size, ci_kw_size);
- load_body->param.opt_table = ibf_load_param_opt_table(load, param_opt_table_offset, param_opt_num);
- load_body->param.keyword = ibf_load_param_keyword(load, param_keyword_offset);
- load_body->param.flags.has_kw = (param_flags >> 4) & 1;
- load_body->insns_info.body = ibf_load_insns_info_body(load, insns_info_body_offset, insns_info_size);
- load_body->insns_info.positions = ibf_load_insns_info_positions(load, insns_info_positions_offset, insns_info_size);
- load_body->local_table = ibf_load_local_table(load, local_table_offset, local_table_size);
- load_body->catch_table = ibf_load_catch_table(load, catch_table_offset, catch_table_size);
- load_body->parent_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)parent_iseq_index);
- load_body->local_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)local_iseq_index);
-
- ibf_load_code(load, iseq, bytecode_offset, bytecode_size, iseq_size);
-#if VM_INSN_INFO_TABLE_IMPL == 2
- rb_iseq_insns_info_encode_positions(iseq);
-#endif
+ load_body->iseq_encoded = ibf_load_code(load, iseq, body);
rb_iseq_translate_threaded_code(iseq);
-
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
- load->current_buffer = &load->global_buffer;
-#endif
-
- {
- VALUE realpath = Qnil, path = ibf_load_object(load, location_pathobj_index);
- if (RB_TYPE_P(path, T_STRING)) {
- realpath = path = rb_fstring(path);
- }
- else if (RB_TYPE_P(path, T_ARRAY)) {
- VALUE pathobj = path;
- if (RARRAY_LEN(pathobj) != 2) {
- rb_raise(rb_eRuntimeError, "path object size mismatch");
- }
- path = rb_fstring(RARRAY_AREF(pathobj, 0));
- realpath = RARRAY_AREF(pathobj, 1);
- if (!NIL_P(realpath)) {
- if (!RB_TYPE_P(realpath, T_STRING)) {
- rb_raise(rb_eArgError, "unexpected realpath %"PRIxVALUE
- "(%x), path=%+"PRIsVALUE,
- realpath, TYPE(realpath), path);
- }
- realpath = rb_fstring(realpath);
- }
- }
- else {
- rb_raise(rb_eRuntimeError, "unexpected path object");
- }
- rb_iseq_pathobj_set(iseq, path, realpath);
- }
-
- RB_OBJ_WRITE(iseq, &load_body->location.base_label, ibf_load_location_str(load, location_base_label_index));
- RB_OBJ_WRITE(iseq, &load_body->location.label, ibf_load_location_str(load, location_label_index));
-
-#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
- load->current_buffer = saved_buffer;
-#endif
- verify_call_cache(iseq);
}
+
static void
ibf_dump_iseq_list(struct ibf_dump *dump, struct ibf_header *header)
{
- VALUE list = rb_ary_tmp_new(RARRAY_LEN(dump->iseq_list));
+ const long size = RARRAY_LEN(dump->iseq_list);
+ ibf_offset_t *list = ALLOCA_N(ibf_offset_t, size);
long i;
- for (i = 0; i < RARRAY_LEN(dump->iseq_list); i++) {
- ibf_offset_t offset = ibf_dump_iseq_each(dump, (rb_iseq_t *)RARRAY_AREF(dump->iseq_list, i));
- rb_ary_push(list, UINT2NUM(offset));
+ for (i=0; i<size; i++) {
+ list[i] = (ibf_offset_t)NUM2LONG(rb_ary_entry(dump->iseq_list, i));
}
- long size = RARRAY_LEN(dump->iseq_list);
- ibf_offset_t *offsets = ALLOCA_N(ibf_offset_t, size);
+ header->iseq_list_offset = ibf_dump_write(dump, list, sizeof(ibf_offset_t) * size);
+ header->iseq_list_size = (unsigned int)size;
+}
- for (i = 0; i < size; i++) {
- offsets[i] = NUM2UINT(RARRAY_AREF(list, i));
+struct ibf_dump_id_list_i_arg {
+ struct ibf_dump *dump;
+ long *list;
+ int current_i;
+};
+
+static int
+ibf_dump_id_list_i(st_data_t key, st_data_t val, st_data_t ptr)
+{
+ struct ibf_dump_id_list_i_arg *arg = (struct ibf_dump_id_list_i_arg *)ptr;
+ int i = (int)val;
+ ID id = (ID)key;
+ assert(arg->current_i == i);
+ arg->current_i++;
+
+ if (rb_id2name(id)) {
+ arg->list[i] = (long)ibf_dump_object(arg->dump, rb_id2str(id));
+ }
+ else {
+ arg->list[i] = 0;
}
- ibf_dump_align(dump, sizeof(ibf_offset_t));
- header->iseq_list_offset = ibf_dump_write(dump, offsets, sizeof(ibf_offset_t) * size);
- header->iseq_list_size = (unsigned int)size;
+ return ST_CONTINUE;
+}
+
+static void
+ibf_dump_id_list(struct ibf_dump *dump, struct ibf_header *header)
+{
+ const long size = dump->id_table->num_entries;
+ struct ibf_dump_id_list_i_arg arg;
+ arg.list = ALLOCA_N(long, size);
+ arg.dump = dump;
+ arg.current_i = 0;
+
+ st_foreach(dump->id_table, ibf_dump_id_list_i, (st_data_t)&arg);
+
+ header->id_list_offset = ibf_dump_write(dump, arg.list, sizeof(long) * size);
+ header->id_list_size = (unsigned int)size;
}
#define IBF_OBJECT_INTERNAL FL_PROMOTED0
@@ -10706,9 +8804,13 @@ struct ibf_object_header {
enum ibf_object_class_index {
IBF_OBJECT_CLASS_OBJECT,
IBF_OBJECT_CLASS_ARRAY,
- IBF_OBJECT_CLASS_STANDARD_ERROR,
- IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR,
- IBF_OBJECT_CLASS_TYPE_ERROR,
+ IBF_OBJECT_CLASS_STANDARD_ERROR
+};
+
+struct ibf_object_string {
+ long encindex;
+ long len;
+ char ptr[1];
};
struct ibf_object_regexp {
@@ -10716,9 +8818,14 @@ struct ibf_object_regexp {
char option;
};
+struct ibf_object_array {
+ long len;
+ long ary[1];
+};
+
struct ibf_object_hash {
long len;
- long keyval[FLEX_ARY_LEN];
+ long keyval[1];
};
struct ibf_object_struct_range {
@@ -10731,11 +8838,11 @@ struct ibf_object_struct_range {
struct ibf_object_bignum {
ssize_t slen;
- BDIGIT digits[FLEX_ARY_LEN];
+ BDIGIT digits[1];
};
enum ibf_object_data_type {
- IBF_OBJECT_DATA_ENCODING,
+ IBF_OBJECT_DATA_ENCODING
};
struct ibf_object_complex_rational {
@@ -10746,34 +8853,20 @@ struct ibf_object_symbol {
long str;
};
-#define IBF_ALIGNED_OFFSET(align, offset) /* offset > 0 */ \
- ((((offset) - 1) / (align) + 1) * (align))
-#define IBF_OBJBODY(type, offset) (const type *)\
- ibf_load_check_offset(load, IBF_ALIGNED_OFFSET(RUBY_ALIGNOF(type), offset))
-
-static const void *
-ibf_load_check_offset(const struct ibf_load *load, size_t offset)
-{
- if (offset >= load->current_buffer->size) {
- rb_raise(rb_eIndexError, "object offset out of range: %"PRIdSIZE, offset);
- }
- return load->current_buffer->buff + offset;
-}
-
-NORETURN(static void ibf_dump_object_unsupported(struct ibf_dump *dump, VALUE obj));
+#define IBF_OBJHEADER(offset) (struct ibf_object_header *)(load->buff + (offset))
+#define IBF_OBJBODY(type, offset) (type *)(load->buff + sizeof(struct ibf_object_header) + (offset))
static void
ibf_dump_object_unsupported(struct ibf_dump *dump, VALUE obj)
{
- char buff[0x100];
- rb_raw_obj_info(buff, sizeof(buff), obj);
- rb_raise(rb_eNotImpError, "ibf_dump_object_unsupported: %s", buff);
+ rb_obj_info_dump(obj);
+ rb_bug("ibf_dump_object_unsupported: unsupported");
}
static VALUE
ibf_load_object_unsupported(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- rb_raise(rb_eArgError, "unsupported");
+ rb_bug("unsupported");
return Qnil;
}
@@ -10782,32 +8875,27 @@ ibf_dump_object_class(struct ibf_dump *dump, VALUE obj)
{
enum ibf_object_class_index cindex;
if (obj == rb_cObject) {
- cindex = IBF_OBJECT_CLASS_OBJECT;
+ cindex = IBF_OBJECT_CLASS_OBJECT;
}
else if (obj == rb_cArray) {
- cindex = IBF_OBJECT_CLASS_ARRAY;
+ cindex = IBF_OBJECT_CLASS_ARRAY;
}
else if (obj == rb_eStandardError) {
- cindex = IBF_OBJECT_CLASS_STANDARD_ERROR;
- }
- else if (obj == rb_eNoMatchingPatternError) {
- cindex = IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR;
- }
- else if (obj == rb_eTypeError) {
- cindex = IBF_OBJECT_CLASS_TYPE_ERROR;
+ cindex = IBF_OBJECT_CLASS_STANDARD_ERROR;
}
else {
- rb_obj_info_dump(obj);
- rb_p(obj);
- rb_bug("unsupported class");
+ rb_obj_info_dump(obj);
+ rb_p(obj);
+ rb_bug("unsupported class");
}
- ibf_dump_write_small_value(dump, (VALUE)cindex);
+ ibf_dump_write(dump, &cindex, sizeof(cindex));
}
static VALUE
ibf_load_object_class(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- enum ibf_object_class_index cindex = (enum ibf_object_class_index)ibf_load_small_value(load, &offset);
+ enum ibf_object_class_index *cindexp = IBF_OBJBODY(enum ibf_object_class_index, offset);
+ enum ibf_object_class_index cindex = *cindexp;
switch (cindex) {
case IBF_OBJECT_CLASS_OBJECT:
@@ -10816,13 +8904,9 @@ ibf_load_object_class(const struct ibf_load *load, const struct ibf_object_heade
return rb_cArray;
case IBF_OBJECT_CLASS_STANDARD_ERROR:
return rb_eStandardError;
- case IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR:
- return rb_eNoMatchingPatternError;
- case IBF_OBJECT_CLASS_TYPE_ERROR:
- return rb_eTypeError;
}
- rb_raise(rb_eArgError, "ibf_load_object_class: unknown class (%d)", (int)cindex);
+ rb_bug("ibf_load_object_class: unknown class (%d)", (int)cindex);
}
@@ -10830,13 +8914,13 @@ static void
ibf_dump_object_float(struct ibf_dump *dump, VALUE obj)
{
double dbl = RFLOAT_VALUE(obj);
- (void)IBF_W(&dbl, double, 1);
+ ibf_dump_write(dump, &dbl, sizeof(dbl));
}
static VALUE
ibf_load_object_float(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- const double *dblp = IBF_OBJBODY(double, offset);
+ double *dblp = IBF_OBJBODY(double, offset);
return DBL2NUM(*dblp);
}
@@ -10848,30 +8932,26 @@ ibf_dump_object_string(struct ibf_dump *dump, VALUE obj)
const char *ptr = RSTRING_PTR(obj);
if (encindex > RUBY_ENCINDEX_BUILTIN_MAX) {
- rb_encoding *enc = rb_enc_from_index((int)encindex);
- const char *enc_name = rb_enc_name(enc);
- encindex = RUBY_ENCINDEX_BUILTIN_MAX + ibf_dump_object(dump, rb_str_new2(enc_name));
+ rb_encoding *enc = rb_enc_from_index((int)encindex);
+ const char *enc_name = rb_enc_name(enc);
+ encindex = RUBY_ENCINDEX_BUILTIN_MAX + ibf_dump_object(dump, rb_str_new2(enc_name));
}
- ibf_dump_write_small_value(dump, encindex);
- ibf_dump_write_small_value(dump, len);
+ IBF_WV(encindex);
+ IBF_WV(len);
IBF_WP(ptr, char, len);
}
static VALUE
ibf_load_object_string(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- ibf_offset_t reading_pos = offset;
-
- int encindex = (int)ibf_load_small_value(load, &reading_pos);
- const long len = (long)ibf_load_small_value(load, &reading_pos);
- const char *ptr = load->current_buffer->buff + reading_pos;
-
- VALUE str = rb_str_new(ptr, len);
+ const struct ibf_object_string *string = IBF_OBJBODY(struct ibf_object_string, offset);
+ VALUE str = rb_str_new(string->ptr, string->len);
+ int encindex = (int)string->encindex;
if (encindex > RUBY_ENCINDEX_BUILTIN_MAX) {
- VALUE enc_name_str = ibf_load_object(load, encindex - RUBY_ENCINDEX_BUILTIN_MAX);
- encindex = rb_enc_find_index(RSTRING_PTR(enc_name_str));
+ VALUE enc_name_str = ibf_load_object(load, encindex - RUBY_ENCINDEX_BUILTIN_MAX);
+ encindex = rb_enc_find_index(RSTRING_PTR(enc_name_str));
}
rb_enc_associate_index(str, encindex);
@@ -10884,24 +8964,19 @@ ibf_load_object_string(const struct ibf_load *load, const struct ibf_object_head
static void
ibf_dump_object_regexp(struct ibf_dump *dump, VALUE obj)
{
- VALUE srcstr = RREGEXP_SRC(obj);
struct ibf_object_regexp regexp;
+ VALUE srcstr = RREGEXP_SRC(obj);
regexp.option = (char)rb_reg_options(obj);
regexp.srcstr = (long)ibf_dump_object(dump, srcstr);
-
- ibf_dump_write_byte(dump, (unsigned char)regexp.option);
- ibf_dump_write_small_value(dump, regexp.srcstr);
+ IBF_WV(regexp);
}
static VALUE
ibf_load_object_regexp(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- struct ibf_object_regexp regexp;
- regexp.option = ibf_load_byte(load, &offset);
- regexp.srcstr = ibf_load_small_value(load, &offset);
-
- VALUE srcstr = ibf_load_object(load, regexp.srcstr);
- VALUE reg = rb_reg_compile(srcstr, (int)regexp.option, NULL, 0);
+ const struct ibf_object_regexp *regexp = IBF_OBJBODY(struct ibf_object_regexp, offset);
+ VALUE srcstr = ibf_load_object(load, regexp->srcstr);
+ VALUE reg = rb_reg_compile(srcstr, (int)regexp->option, NULL, 0);
if (header->internal) rb_obj_hide(reg);
if (header->frozen) rb_obj_freeze(reg);
@@ -10912,27 +8987,23 @@ ibf_load_object_regexp(const struct ibf_load *load, const struct ibf_object_head
static void
ibf_dump_object_array(struct ibf_dump *dump, VALUE obj)
{
- long i, len = RARRAY_LEN(obj);
- ibf_dump_write_small_value(dump, len);
+ long i, len = (int)RARRAY_LEN(obj);
+ IBF_WV(len);
for (i=0; i<len; i++) {
- long index = (long)ibf_dump_object(dump, RARRAY_AREF(obj, i));
- ibf_dump_write_small_value(dump, index);
+ long index = (long)ibf_dump_object(dump, RARRAY_AREF(obj, i));
+ IBF_WV(index);
}
}
static VALUE
ibf_load_object_array(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- ibf_offset_t reading_pos = offset;
-
- const long len = (long)ibf_load_small_value(load, &reading_pos);
-
- VALUE ary = rb_ary_new_capa(len);
+ const struct ibf_object_array *array = IBF_OBJBODY(struct ibf_object_array, offset);
+ VALUE ary = rb_ary_new_capa(array->len);
int i;
- for (i=0; i<len; i++) {
- const VALUE index = ibf_load_small_value(load, &reading_pos);
- rb_ary_push(ary, ibf_load_object(load, index));
+ for (i=0; i<array->len; i++) {
+ rb_ary_push(ary, ibf_load_object(load, array->ary[i]));
}
if (header->internal) rb_obj_hide(ary);
@@ -10945,12 +9016,10 @@ static int
ibf_dump_object_hash_i(st_data_t key, st_data_t val, st_data_t ptr)
{
struct ibf_dump *dump = (struct ibf_dump *)ptr;
-
- VALUE key_index = ibf_dump_object(dump, (VALUE)key);
- VALUE val_index = ibf_dump_object(dump, (VALUE)val);
-
- ibf_dump_write_small_value(dump, key_index);
- ibf_dump_write_small_value(dump, val_index);
+ long key_index = (long)ibf_dump_object(dump, (VALUE)key);
+ long val_index = (long)ibf_dump_object(dump, (VALUE)val);
+ IBF_WV(key_index);
+ IBF_WV(val_index);
return ST_CONTINUE;
}
@@ -10958,25 +9027,21 @@ static void
ibf_dump_object_hash(struct ibf_dump *dump, VALUE obj)
{
long len = RHASH_SIZE(obj);
- ibf_dump_write_small_value(dump, (VALUE)len);
-
- if (len > 0) rb_hash_foreach(obj, ibf_dump_object_hash_i, (VALUE)dump);
+ IBF_WV(len);
+ if (len > 0) st_foreach(RHASH(obj)->ntbl, ibf_dump_object_hash_i, (st_data_t)dump);
}
static VALUE
ibf_load_object_hash(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- long len = (long)ibf_load_small_value(load, &offset);
- VALUE obj = rb_hash_new_with_size(len);
+ const struct ibf_object_hash *hash = IBF_OBJBODY(struct ibf_object_hash, offset);
+ VALUE obj = rb_hash_new_with_size(hash->len);
int i;
- for (i = 0; i < len; i++) {
- VALUE key_index = ibf_load_small_value(load, &offset);
- VALUE val_index = ibf_load_small_value(load, &offset);
-
- VALUE key = ibf_load_object(load, key_index);
- VALUE val = ibf_load_object(load, val_index);
- rb_hash_aset(obj, key, val);
+ for (i=0; i<hash->len; i++) {
+ VALUE key = ibf_load_object(load, hash->keyval[i*2 ]);
+ VALUE val = ibf_load_object(load, hash->keyval[i*2+1]);
+ rb_hash_aset(obj, key, val);
}
rb_hash_rehash(obj);
@@ -10990,22 +9055,19 @@ static void
ibf_dump_object_struct(struct ibf_dump *dump, VALUE obj)
{
if (rb_obj_is_kind_of(obj, rb_cRange)) {
- struct ibf_object_struct_range range;
- VALUE beg, end;
- IBF_ZERO(range);
- range.len = 3;
- range.class_index = 0;
+ struct ibf_object_struct_range range;
+ VALUE beg, end;
+ range.len = 3;
+ range.class_index = 0;
- rb_range_values(obj, &beg, &end, &range.excl);
- range.beg = (long)ibf_dump_object(dump, beg);
- range.end = (long)ibf_dump_object(dump, end);
+ rb_range_values(obj, &beg, &end, &range.excl);
+ range.beg = (long)ibf_dump_object(dump, beg);
+ range.end = (long)ibf_dump_object(dump, end);
- IBF_W_ALIGN(struct ibf_object_struct_range);
- IBF_WV(range);
+ IBF_WV(range);
}
else {
- rb_raise(rb_eNotImpError, "ibf_dump_object_struct: unsupported class %"PRIsVALUE,
- rb_class_name(CLASS_OF(obj)));
+ rb_bug("ibf_dump_object_struct: unsupported class");
}
}
@@ -11028,7 +9090,7 @@ ibf_dump_object_bignum(struct ibf_dump *dump, VALUE obj)
ssize_t slen = BIGNUM_SIGN(obj) > 0 ? len : len * -1;
BDIGIT *d = BIGNUM_DIGITS(obj);
- (void)IBF_W(&slen, ssize_t, 1);
+ IBF_WV(slen);
IBF_WP(d, BDIGIT, len);
}
@@ -11049,34 +9111,32 @@ static void
ibf_dump_object_data(struct ibf_dump *dump, VALUE obj)
{
if (rb_data_is_encoding(obj)) {
- rb_encoding *enc = rb_to_encoding(obj);
- const char *name = rb_enc_name(enc);
- long len = strlen(name) + 1;
- long data[2];
- data[0] = IBF_OBJECT_DATA_ENCODING;
- data[1] = len;
- (void)IBF_W(data, long, 2);
- IBF_WP(name, char, len);
+ rb_encoding *enc = rb_to_encoding(obj);
+ const char *name = rb_enc_name(enc);
+ enum ibf_object_data_type type = IBF_OBJECT_DATA_ENCODING;
+ long len = strlen(name) + 1;
+ IBF_WV(type);
+ IBF_WV(len);
+ IBF_WP(name, char, strlen(name) + 1);
}
else {
- ibf_dump_object_unsupported(dump, obj);
+ ibf_dump_object_unsupported(dump, obj);
}
}
static VALUE
ibf_load_object_data(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- const long *body = IBF_OBJBODY(long, offset);
- const enum ibf_object_data_type type = (enum ibf_object_data_type)body[0];
- /* const long len = body[1]; */
- const char *data = (const char *)&body[2];
+ const enum ibf_object_data_type *typep = IBF_OBJBODY(enum ibf_object_data_type, offset);
+ /* const long *lenp = IBF_OBJBODY(long, offset + sizeof(enum ibf_object_data_type)); */
+ const char *data = IBF_OBJBODY(char, offset + sizeof(enum ibf_object_data_type) + sizeof(long));
- switch (type) {
+ switch (*typep) {
case IBF_OBJECT_DATA_ENCODING:
- {
- VALUE encobj = rb_enc_from_encoding(rb_enc_find(data));
- return encobj;
- }
+ {
+ VALUE encobj = rb_enc_from_encoding(rb_enc_find(data));
+ return encobj;
+ }
}
return ibf_load_object_unsupported(load, header, offset);
@@ -11085,11 +9145,11 @@ ibf_load_object_data(const struct ibf_load *load, const struct ibf_object_header
static void
ibf_dump_object_complex_rational(struct ibf_dump *dump, VALUE obj)
{
- long data[2];
- data[0] = (long)ibf_dump_object(dump, RCOMPLEX(obj)->real);
- data[1] = (long)ibf_dump_object(dump, RCOMPLEX(obj)->imag);
+ long real = (long)ibf_dump_object(dump, RCOMPLEX(obj)->real);
+ long imag = (long)ibf_dump_object(dump, RCOMPLEX(obj)->imag);
- (void)IBF_W(data, long, 2);
+ IBF_WV(real);
+ IBF_WV(imag);
}
static VALUE
@@ -11110,16 +9170,16 @@ static void
ibf_dump_object_symbol(struct ibf_dump *dump, VALUE obj)
{
VALUE str = rb_sym2str(obj);
- VALUE str_index = ibf_dump_object(dump, str);
-
- ibf_dump_write_small_value(dump, str_index);
+ long str_index = (long)ibf_dump_object(dump, str);
+ IBF_WV(str_index);
}
static VALUE
ibf_load_object_symbol(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- VALUE str_index = ibf_load_small_value(load, &offset);
- VALUE str = ibf_load_object(load, str_index);
+ /* const struct ibf_object_header *header = IBF_OBJHEADER(offset); */
+ const struct ibf_object_symbol *symbol = IBF_OBJBODY(struct ibf_object_symbol, offset);
+ VALUE str = ibf_load_object(load, symbol->str);
ID id = rb_intern_str(str);
return ID2SYM(id);
}
@@ -11157,71 +9217,41 @@ static ibf_dump_object_function dump_object_functions[RUBY_T_MASK+1] = {
ibf_dump_object_unsupported, /* T_ICLASS 0x1c */
ibf_dump_object_unsupported, /* T_ZOMBIE 0x1d */
ibf_dump_object_unsupported, /* 0x1e */
- ibf_dump_object_unsupported, /* 0x1f */
+ ibf_dump_object_unsupported /* 0x1f */
};
-static void
-ibf_dump_object_object_header(struct ibf_dump *dump, const struct ibf_object_header header)
-{
- unsigned char byte =
- (header.type << 0) |
- (header.special_const << 5) |
- (header.frozen << 6) |
- (header.internal << 7);
-
- IBF_WV(byte);
-}
-
-static struct ibf_object_header
-ibf_load_object_object_header(const struct ibf_load *load, ibf_offset_t *offset)
-{
- unsigned char byte = ibf_load_byte(load, offset);
-
- struct ibf_object_header header;
- header.type = (byte >> 0) & 0x1f;
- header.special_const = (byte >> 5) & 0x01;
- header.frozen = (byte >> 6) & 0x01;
- header.internal = (byte >> 7) & 0x01;
-
- return header;
-}
-
static ibf_offset_t
-ibf_dump_object_object(struct ibf_dump *dump, VALUE obj_list, VALUE obj)
+lbf_dump_object_object(struct ibf_dump *dump, VALUE obj)
{
struct ibf_object_header obj_header;
- ibf_offset_t current_offset;
- IBF_ZERO(obj_header);
+ ibf_offset_t current_offset = ibf_dump_pos(dump);
obj_header.type = TYPE(obj);
- IBF_W_ALIGN(ibf_offset_t);
- current_offset = ibf_dump_pos(dump);
-
if (SPECIAL_CONST_P(obj)) {
- if (RB_TYPE_P(obj, T_SYMBOL) ||
- RB_TYPE_P(obj, T_FLOAT)) {
- obj_header.internal = FALSE;
- goto dump_object;
- }
- obj_header.special_const = TRUE;
- obj_header.frozen = TRUE;
- obj_header.internal = TRUE;
- ibf_dump_object_object_header(dump, obj_header);
- ibf_dump_write_small_value(dump, obj);
+ if (RB_TYPE_P(obj, T_SYMBOL) ||
+ RB_TYPE_P(obj, T_FLOAT)) {
+ obj_header.internal = FALSE;
+ goto dump_object;
+ }
+ obj_header.special_const = TRUE;
+ obj_header.frozen = TRUE;
+ obj_header.internal = TRUE;
+ IBF_WV(obj_header);
+ IBF_WV(obj);
}
else {
- obj_header.internal = (RBASIC_CLASS(obj) == 0) ? TRUE : FALSE;
+ obj_header.internal = (RBASIC_CLASS(obj) == 0) ? TRUE : FALSE;
dump_object:
- obj_header.special_const = FALSE;
- obj_header.frozen = FL_TEST(obj, FL_FREEZE) ? TRUE : FALSE;
- ibf_dump_object_object_header(dump, obj_header);
- (*dump_object_functions[obj_header.type])(dump, obj);
+ obj_header.special_const = FALSE;
+ obj_header.frozen = FL_TEST(obj, FL_FREEZE) ? TRUE : FALSE;
+ IBF_WV(obj_header);
+ (*dump_object_functions[obj_header.type])(dump, obj);
}
return current_offset;
}
-typedef VALUE (*ibf_load_object_function)(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset);
+typedef VALUE (*ibf_load_object_function)(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t);
static ibf_load_object_function load_object_functions[RUBY_T_MASK+1] = {
ibf_load_object_unsupported, /* T_NONE */
ibf_load_object_unsupported, /* T_OBJECT */
@@ -11254,85 +9284,69 @@ static ibf_load_object_function load_object_functions[RUBY_T_MASK+1] = {
ibf_load_object_unsupported, /* T_ICLASS 0x1c */
ibf_load_object_unsupported, /* T_ZOMBIE 0x1d */
ibf_load_object_unsupported, /* 0x1e */
- ibf_load_object_unsupported, /* 0x1f */
+ ibf_load_object_unsupported /* 0x1f */
};
static VALUE
ibf_load_object(const struct ibf_load *load, VALUE object_index)
{
if (object_index == 0) {
- return Qnil;
+ return Qnil;
}
- else if (object_index >= (VALUE)RARRAY_LEN(load->current_buffer->obj_list)) {
- rb_raise(rb_eIndexError, "object index out of range: %"PRIdVALUE, object_index);
+ else if (object_index >= load->header->object_list_size) {
+ rb_raise(rb_eIndexError, "object index out of range: %"PRIdVALUE, object_index);
}
else {
- VALUE obj = rb_ary_entry(load->current_buffer->obj_list, (long)object_index);
- if (obj == Qnil) { /* TODO: avoid multiple Qnil load */
- ibf_offset_t *offsets = (ibf_offset_t *)(load->current_buffer->obj_list_offset + load->current_buffer->buff);
- ibf_offset_t offset = offsets[object_index];
- const struct ibf_object_header header = ibf_load_object_object_header(load, &offset);
-
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_object: list=%#x offsets=%p offset=%#x\n",
- load->current_buffer->obj_list_offset, (void *)offsets, offset);
- fprintf(stderr, "ibf_load_object: type=%#x special=%d frozen=%d internal=%d\n",
- header.type, header.special_const, header.frozen, header.internal);
-#endif
- if (offset >= load->current_buffer->size) {
- rb_raise(rb_eIndexError, "object offset out of range: %u", offset);
- }
+ VALUE obj = rb_ary_entry(load->obj_list, (long)object_index);
+ if (obj == Qnil) { /* TODO: avoid multiple Qnil load */
+ ibf_offset_t *offsets = (ibf_offset_t *)(load->header->object_list_offset + load->buff);
+ ibf_offset_t offset = offsets[object_index];
+ const struct ibf_object_header *header = IBF_OBJHEADER(offset);
- if (header.special_const) {
- ibf_offset_t reading_pos = offset;
-
- obj = ibf_load_small_value(load, &reading_pos);
- }
- else {
- obj = (*load_object_functions[header.type])(load, &header, offset);
- }
+ if (header->special_const) {
+ VALUE *vp = IBF_OBJBODY(VALUE, offset);
+ obj = *vp;
+ }
+ else {
+ obj = (*load_object_functions[header->type])(load, header, offset);
+ }
- rb_ary_store(load->current_buffer->obj_list, (long)object_index, obj);
- }
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_object: index=%#"PRIxVALUE" obj=%#"PRIxVALUE"\n",
- object_index, obj);
-#endif
- return obj;
+ rb_ary_store(load->obj_list, (long)object_index, obj);
+ }
+ iseq_add_mark_object(load->iseq, obj);
+ return obj;
}
}
static void
-ibf_dump_object_list(struct ibf_dump *dump, ibf_offset_t *obj_list_offset, unsigned int *obj_list_size)
+ibf_dump_object_list(struct ibf_dump *dump, struct ibf_header *header)
{
- VALUE obj_list = dump->current_buffer->obj_list;
- VALUE list = rb_ary_tmp_new(RARRAY_LEN(obj_list));
+ VALUE list = rb_ary_tmp_new(RARRAY_LEN(dump->obj_list));
int i, size;
- for (i=0; i<RARRAY_LEN(obj_list); i++) {
- VALUE obj = RARRAY_AREF(obj_list, i);
- ibf_offset_t offset = ibf_dump_object_object(dump, obj_list, obj);
- rb_ary_push(list, UINT2NUM(offset));
+ for (i=0; i<RARRAY_LEN(dump->obj_list); i++) {
+ VALUE obj = RARRAY_AREF(dump->obj_list, i);
+ ibf_offset_t offset = lbf_dump_object_object(dump, obj);
+ rb_ary_push(list, UINT2NUM(offset));
}
size = i;
- IBF_W_ALIGN(ibf_offset_t);
- *obj_list_offset = ibf_dump_pos(dump);
+ header->object_list_offset = ibf_dump_pos(dump);
for (i=0; i<size; i++) {
- ibf_offset_t offset = NUM2UINT(RARRAY_AREF(list, i));
- IBF_WV(offset);
+ ibf_offset_t offset = NUM2UINT(RARRAY_AREF(list, i));
+ IBF_WV(offset);
}
- *obj_list_size = size;
+ header->object_list_size = size;
}
static void
ibf_dump_mark(void *ptr)
{
struct ibf_dump *dump = (struct ibf_dump *)ptr;
- rb_gc_mark(dump->global_buffer.str);
- rb_gc_mark(dump->global_buffer.obj_list);
+ rb_gc_mark(dump->str);
rb_gc_mark(dump->iseq_list);
+ rb_gc_mark(dump->obj_list);
}
static void
@@ -11340,8 +9354,12 @@ ibf_dump_free(void *ptr)
{
struct ibf_dump *dump = (struct ibf_dump *)ptr;
if (dump->iseq_table) {
- st_free_table(dump->iseq_table);
- dump->iseq_table = 0;
+ st_free_table(dump->iseq_table);
+ dump->iseq_table = 0;
+ }
+ if (dump->id_table) {
+ st_free_table(dump->id_table);
+ dump->id_table = 0;
}
ruby_xfree(dump);
}
@@ -11352,6 +9370,7 @@ ibf_dump_memsize(const void *ptr)
struct ibf_dump *dump = (struct ibf_dump *)ptr;
size_t size = sizeof(*dump);
if (dump->iseq_table) size += st_memsize(dump->iseq_table);
+ if (dump->id_table) size += st_memsize(dump->id_table);
return size;
}
@@ -11364,12 +9383,14 @@ static const rb_data_type_t ibf_dump_type = {
static void
ibf_dump_setup(struct ibf_dump *dump, VALUE dumper_obj)
{
+ RB_OBJ_WRITE(dumper_obj, &dump->str, rb_str_new(0, 0));
RB_OBJ_WRITE(dumper_obj, &dump->iseq_list, rb_ary_tmp_new(0));
- RB_OBJ_WRITE(dumper_obj, &dump->global_buffer.obj_list, ibf_dump_object_list_new());
- RB_OBJ_WRITE(dumper_obj, &dump->global_buffer.str, rb_str_new(0, 0));
+ RB_OBJ_WRITE(dumper_obj, &dump->obj_list, rb_ary_tmp_new(1));
+ rb_ary_push(dump->obj_list, Qnil); /* 0th is nil */
dump->iseq_table = st_init_numtable(); /* need free */
+ dump->id_table = st_init_numtable(); /* need free */
- dump->current_buffer = &dump->global_buffer;
+ ibf_table_index(dump->id_table, 0); /* id_index:0 is 0 */
}
VALUE
@@ -11381,11 +9402,11 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
VALUE str;
if (iseq->body->parent_iseq != NULL ||
- iseq->body->local_iseq != iseq) {
- rb_raise(rb_eRuntimeError, "should be top of iseq");
+ iseq->body->local_iseq != iseq) {
+ rb_raise(rb_eRuntimeError, "should be top of iseq");
}
if (RTEST(ISEQ_COVERAGE(iseq))) {
- rb_raise(rb_eRuntimeError, "should not compile with coverage");
+ rb_raise(rb_eRuntimeError, "should not compile with coverage");
}
dump_obj = TypedData_Make_Struct(0, struct ibf_dump, &ibf_dump_type, dump);
@@ -11399,25 +9420,26 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
header.magic[1] = 'A';
header.magic[2] = 'R';
header.magic[3] = 'B';
- header.major_version = IBF_MAJOR_VERSION;
- header.minor_version = IBF_MINOR_VERSION;
+ header.major_version = ISEQ_MAJOR_VERSION;
+ header.minor_version = ISEQ_MINOR_VERSION;
ibf_dump_iseq_list(dump, &header);
- ibf_dump_object_list(dump, &header.global_object_list_offset, &header.global_object_list_size);
+ ibf_dump_id_list(dump, &header);
+ ibf_dump_object_list(dump, &header);
header.size = ibf_dump_pos(dump);
if (RTEST(opt)) {
- VALUE opt_str = opt;
- const char *ptr = StringValuePtr(opt_str);
- header.extra_size = RSTRING_LENINT(opt_str);
- ibf_dump_write(dump, ptr, header.extra_size);
+ VALUE opt_str = opt;
+ const char *ptr = StringValuePtr(opt_str);
+ header.extra_size = RSTRING_LENINT(opt_str);
+ ibf_dump_write(dump, ptr, header.extra_size);
}
else {
- header.extra_size = 0;
+ header.extra_size = 0;
}
ibf_dump_overwrite(dump, &header, sizeof(header), 0);
- str = dump->global_buffer.str;
+ str = dump->str;
ibf_dump_free(dump);
DATA_PTR(dump_obj) = NULL;
RB_GC_GUARD(dump_obj);
@@ -11427,7 +9449,7 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
static const ibf_offset_t *
ibf_iseq_list(const struct ibf_load *load)
{
- return (const ibf_offset_t *)(load->global_buffer.buff + load->header->iseq_list_offset);
+ return (ibf_offset_t *)(load->buff + load->header->iseq_list_offset);
}
void
@@ -11435,22 +9457,15 @@ rb_ibf_load_iseq_complete(rb_iseq_t *iseq)
{
struct ibf_load *load = RTYPEDDATA_DATA(iseq->aux.loader.obj);
rb_iseq_t *prev_src_iseq = load->iseq;
- ibf_offset_t offset = ibf_iseq_list(load)[iseq->aux.loader.index];
load->iseq = iseq;
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "rb_ibf_load_iseq_complete: index=%#x offset=%#x size=%#x\n",
- iseq->aux.loader.index, offset,
- load->header->size);
-#endif
- ibf_load_iseq_each(load, iseq, offset);
+ ibf_load_iseq_each(load, iseq, ibf_iseq_list(load)[iseq->aux.loader.index]);
ISEQ_COMPILE_DATA_CLEAR(iseq);
FL_UNSET(iseq, ISEQ_NOT_LOADED_YET);
- rb_iseq_init_trace(iseq);
load->iseq = prev_src_iseq;
}
#if USE_LAZY_LOAD
-MJIT_FUNC_EXPORTED const rb_iseq_t *
+const rb_iseq_t *
rb_iseq_complete(const rb_iseq_t *iseq)
{
rb_ibf_load_iseq_complete((rb_iseq_t *)iseq);
@@ -11463,109 +9478,65 @@ ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq)
{
int iseq_index = (int)(VALUE)index_iseq;
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: index_iseq=%p iseq_list=%p\n",
- (void *)index_iseq, (void *)load->iseq_list);
-#endif
if (iseq_index == -1) {
return NULL;
}
else {
VALUE iseqv = rb_ary_entry(load->iseq_list, iseq_index);
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: iseqv=%p\n", (void *)iseqv);
-#endif
if (iseqv != Qnil) {
return (rb_iseq_t *)iseqv;
}
else {
rb_iseq_t *iseq = iseq_imemo_alloc();
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: new iseq=%p\n", (void *)iseq);
-#endif
FL_SET(iseq, ISEQ_NOT_LOADED_YET);
iseq->aux.loader.obj = load->loader_obj;
iseq->aux.loader.index = iseq_index;
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: iseq=%p loader_obj=%p index=%d\n",
- (void *)iseq, (void *)load->loader_obj, iseq_index);
-#endif
rb_ary_store(load->iseq_list, iseq_index, (VALUE)iseq);
#if !USE_LAZY_LOAD
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: loading iseq=%p\n", (void *)iseq);
-#endif
- rb_ibf_load_iseq_complete(iseq);
-#else
- if (GET_VM()->builtin_function_table) {
- rb_ibf_load_iseq_complete(iseq);
- }
+ rb_ibf_load_iseq_complete(iseq);
#endif /* !USE_LAZY_LOAD */
-#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: iseq=%p loaded %p\n",
- (void *)iseq, (void *)load->iseq);
-#endif
+ if (load->iseq) {
+ iseq_add_mark_object(load->iseq, (VALUE)iseq);
+ }
return iseq;
}
}
}
static void
-ibf_load_setup_bytes(struct ibf_load *load, VALUE loader_obj, const char *bytes, size_t size)
+ibf_load_setup(struct ibf_load *load, VALUE loader_obj, VALUE str)
{
+ rb_check_safe_obj(str);
+
+ if (RSTRING_LENINT(str) < (int)sizeof(struct ibf_header)) {
+ rb_raise(rb_eRuntimeError, "broken binary format");
+ }
+ RB_OBJ_WRITE(loader_obj, &load->str, str);
load->loader_obj = loader_obj;
- load->global_buffer.buff = bytes;
- load->header = (struct ibf_header *)load->global_buffer.buff;
- load->global_buffer.size = load->header->size;
- load->global_buffer.obj_list_offset = load->header->global_object_list_offset;
- load->global_buffer.obj_list_size = load->header->global_object_list_size;
+ load->buff = StringValuePtr(str);
+ load->header = (struct ibf_header *)load->buff;
RB_OBJ_WRITE(loader_obj, &load->iseq_list, rb_ary_tmp_new(0));
- RB_OBJ_WRITE(loader_obj, &load->global_buffer.obj_list, rb_ary_tmp_new(load->global_buffer.obj_list_size));
- rb_ary_resize(load->global_buffer.obj_list, load->global_buffer.obj_list_size);
+ RB_OBJ_WRITE(loader_obj, &load->obj_list, rb_ary_tmp_new(0));
+ load->id_list = ZALLOC_N(ID, load->header->id_list_size);
load->iseq = NULL;
- load->current_buffer = &load->global_buffer;
-
- if (size < load->header->size) {
+ if (RSTRING_LENINT(str) < (int)load->header->size) {
rb_raise(rb_eRuntimeError, "broken binary format");
}
if (strncmp(load->header->magic, "YARB", 4) != 0) {
rb_raise(rb_eRuntimeError, "unknown binary format");
}
- if (load->header->major_version != IBF_MAJOR_VERSION ||
- load->header->minor_version != IBF_MINOR_VERSION) {
+ if (load->header->major_version != ISEQ_MAJOR_VERSION ||
+ load->header->minor_version != ISEQ_MINOR_VERSION) {
rb_raise(rb_eRuntimeError, "unmatched version file (%u.%u for %u.%u)",
- load->header->major_version, load->header->minor_version, IBF_MAJOR_VERSION, IBF_MINOR_VERSION);
+ load->header->major_version, load->header->minor_version, ISEQ_MAJOR_VERSION, ISEQ_MINOR_VERSION);
}
- if (strcmp(load->global_buffer.buff + sizeof(struct ibf_header), RUBY_PLATFORM) != 0) {
+ if (strcmp(load->buff + sizeof(struct ibf_header), RUBY_PLATFORM) != 0) {
rb_raise(rb_eRuntimeError, "unmatched platform");
}
- if (load->header->iseq_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
- rb_raise(rb_eArgError, "unaligned iseq list offset: %u",
- load->header->iseq_list_offset);
- }
- if (load->global_buffer.obj_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
- rb_raise(rb_eArgError, "unaligned object list offset: %u",
- load->global_buffer.obj_list_offset);
- }
-}
-
-static void
-ibf_load_setup(struct ibf_load *load, VALUE loader_obj, VALUE str)
-{
- if (RSTRING_LENINT(str) < (int)sizeof(struct ibf_header)) {
- rb_raise(rb_eRuntimeError, "broken binary format");
- }
-
-#if USE_LAZY_LOAD
- str = rb_str_new(RSTRING_PTR(str), RSTRING_LEN(str));
-#endif
-
- ibf_load_setup_bytes(load, loader_obj, StringValuePtr(str), RSTRING_LEN(str));
- RB_OBJ_WRITE(loader_obj, &load->str, str);
}
static void
@@ -11574,20 +9545,22 @@ ibf_loader_mark(void *ptr)
struct ibf_load *load = (struct ibf_load *)ptr;
rb_gc_mark(load->str);
rb_gc_mark(load->iseq_list);
- rb_gc_mark(load->global_buffer.obj_list);
+ rb_gc_mark(load->obj_list);
}
static void
ibf_loader_free(void *ptr)
{
struct ibf_load *load = (struct ibf_load *)ptr;
+ ruby_xfree(load->id_list);
ruby_xfree(load);
}
static size_t
ibf_loader_memsize(const void *ptr)
{
- return sizeof(struct ibf_load);
+ struct ibf_load *load = (struct ibf_load *)ptr;
+ return sizeof(struct ibf_load) + load->header->id_list_size * sizeof(ID);
}
static const rb_data_type_t ibf_load_type = {
@@ -11606,19 +9579,7 @@ rb_iseq_ibf_load(VALUE str)
ibf_load_setup(load, loader_obj, str);
iseq = ibf_load_iseq(load, 0);
- RB_GC_GUARD(loader_obj);
- return iseq;
-}
-
-const rb_iseq_t *
-rb_iseq_ibf_load_bytes(const char *bytes, size_t size)
-{
- struct ibf_load *load;
- rb_iseq_t *iseq;
- VALUE loader_obj = TypedData_Make_Struct(0, struct ibf_load, &ibf_load_type, load);
-
- ibf_load_setup_bytes(load, loader_obj, bytes, size);
- iseq = ibf_load_iseq(load, 0);
+ rb_iseq_init_trace(iseq);
RB_GC_GUARD(loader_obj);
return iseq;
@@ -11632,7 +9593,7 @@ rb_iseq_ibf_load_extra_data(VALUE str)
VALUE extra_str;
ibf_load_setup(load, loader_obj, str);
- extra_str = rb_str_new(load->global_buffer.buff + load->header->size, load->header->extra_size);
+ extra_str = rb_str_new(load->buff + load->header->size, load->header->extra_size);
RB_GC_GUARD(loader_obj);
return extra_str;
}
diff --git a/complex.c b/complex.c
index cdd5edc50a..e06faa813b 100644
--- a/complex.c
+++ b/complex.c
@@ -12,7 +12,6 @@
#endif
#include <math.h>
#include "internal.h"
-#include "id.h"
#define NDEBUG
#include "ruby_assert.h"
@@ -20,11 +19,7 @@
#define ZERO INT2FIX(0)
#define ONE INT2FIX(1)
#define TWO INT2FIX(2)
-#if USE_FLONUM
#define RFLOAT_0 DBL2NUM(0)
-#else
-static VALUE RFLOAT_0;
-#endif
#if defined(HAVE_SIGNBIT) && defined(__GNUC__) && defined(__sun) && \
!defined(signbit)
extern int signbit(double);
@@ -32,21 +27,26 @@ extern int signbit(double);
VALUE rb_cComplex;
+static VALUE nucomp_abs(VALUE self);
+static VALUE nucomp_arg(VALUE self);
+
static ID id_abs, id_arg,
- id_denominator, id_numerator,
- id_real_p, id_i_real, id_i_imag,
+ id_denominator, id_expt, id_fdiv,
+ id_negate, id_numerator, id_quo,
+ id_real_p, id_to_f, id_to_i, id_to_r,
+ id_i_real, id_i_imag,
id_finite_p, id_infinite_p, id_rationalize,
id_PI;
-#define id_to_i idTo_i
-#define id_to_r idTo_r
-#define id_negate idUMinus
-#define id_expt idPow
-#define id_to_f idTo_f
-#define id_quo idQuo
-#define id_fdiv idFdiv
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
+#define binop(n,op) \
+inline static VALUE \
+f_##n(VALUE x, VALUE y)\
+{\
+ return rb_funcall(x, (op), 1, y);\
+}
+
#define fun1(n) \
inline static VALUE \
f_##n(VALUE x)\
@@ -61,32 +61,31 @@ f_##n(VALUE x, VALUE y)\
return rb_funcall(x, id_##n, 1, y);\
}
+#define math1(n) \
+inline static VALUE \
+m_##n(VALUE x)\
+{\
+ return rb_funcall(rb_mMath, id_##n, 1, x);\
+}
+
+#define math2(n) \
+inline static VALUE \
+m_##n(VALUE x, VALUE y)\
+{\
+ return rb_funcall(rb_mMath, id_##n, 2, x, y);\
+}
+
#define PRESERVE_SIGNEDZERO
inline static VALUE
f_add(VALUE x, VALUE y)
{
- if (RB_INTEGER_TYPE_P(x) &&
- LIKELY(rb_method_basic_definition_p(rb_cInteger, idPLUS))) {
- if (FIXNUM_ZERO_P(x))
- return y;
- if (FIXNUM_ZERO_P(y))
- return x;
- return rb_int_plus(x, y);
- }
- else if (RB_FLOAT_TYPE_P(x) &&
- LIKELY(rb_method_basic_definition_p(rb_cFloat, idPLUS))) {
- if (FIXNUM_ZERO_P(y))
- return x;
- return rb_float_plus(x, y);
- }
- else if (RB_TYPE_P(x, T_RATIONAL) &&
- LIKELY(rb_method_basic_definition_p(rb_cRational, idPLUS))) {
- if (FIXNUM_ZERO_P(y))
- return x;
- return rb_rational_plus(x, y);
- }
-
+#ifndef PRESERVE_SIGNEDZERO
+ if (FIXNUM_P(y) && FIXNUM_ZERO_P(y))
+ return x;
+ else if (FIXNUM_P(x) && FIXNUM_ZERO_P(x))
+ return y;
+#endif
return rb_funcall(x, '+', 1, y);
}
@@ -118,104 +117,44 @@ f_gt_p(VALUE x, VALUE y)
inline static VALUE
f_mul(VALUE x, VALUE y)
{
- if (RB_INTEGER_TYPE_P(x) &&
- LIKELY(rb_method_basic_definition_p(rb_cInteger, idMULT))) {
- if (FIXNUM_ZERO_P(y))
- return ZERO;
- if (FIXNUM_ZERO_P(x) && RB_INTEGER_TYPE_P(y))
- return ZERO;
- if (x == ONE) return y;
- if (y == ONE) return x;
- return rb_int_mul(x, y);
- }
- else if (RB_FLOAT_TYPE_P(x) &&
- LIKELY(rb_method_basic_definition_p(rb_cFloat, idMULT))) {
- if (y == ONE) return x;
- return rb_float_mul(x, y);
- }
- else if (RB_TYPE_P(x, T_RATIONAL) &&
- LIKELY(rb_method_basic_definition_p(rb_cRational, idMULT))) {
- if (y == ONE) return x;
- return rb_rational_mul(x, y);
- }
- else if (LIKELY(rb_method_basic_definition_p(CLASS_OF(x), idMULT))) {
- if (y == ONE) return x;
+#ifndef PRESERVE_SIGNEDZERO
+ if (FIXNUM_P(y)) {
+ long iy = FIX2LONG(y);
+ if (iy == 0) {
+ if (RB_INTEGER_TYPE_P(x))
+ return ZERO;
+ }
+ else if (iy == 1)
+ return x;
+ }
+ else if (FIXNUM_P(x)) {
+ long ix = FIX2LONG(x);
+ if (ix == 0) {
+ if (RB_INTEGER_TYPE_P(y))
+ return ZERO;
+ }
+ else if (ix == 1)
+ return y;
}
+#endif
return rb_funcall(x, '*', 1, y);
}
inline static VALUE
f_sub(VALUE x, VALUE y)
{
- if (FIXNUM_ZERO_P(y) &&
- LIKELY(rb_method_basic_definition_p(CLASS_OF(x), idMINUS))) {
+#ifndef PRESERVE_SIGNEDZERO
+ if (FIXNUM_P(y) && FIXNUM_ZERO_P(y))
return x;
- }
+#endif
return rb_funcall(x, '-', 1, y);
}
-inline static VALUE
-f_abs(VALUE x)
-{
- if (RB_INTEGER_TYPE_P(x)) {
- return rb_int_abs(x);
- }
- else if (RB_FLOAT_TYPE_P(x)) {
- return rb_float_abs(x);
- }
- else if (RB_TYPE_P(x, T_RATIONAL)) {
- return rb_rational_abs(x);
- }
- else if (RB_TYPE_P(x, T_COMPLEX)) {
- return rb_complex_abs(x);
- }
- return rb_funcall(x, id_abs, 0);
-}
+fun1(abs)
+fun1(arg)
+fun1(denominator)
-static VALUE numeric_arg(VALUE self);
-static VALUE float_arg(VALUE self);
-
-inline static VALUE
-f_arg(VALUE x)
-{
- if (RB_INTEGER_TYPE_P(x)) {
- return numeric_arg(x);
- }
- else if (RB_FLOAT_TYPE_P(x)) {
- return float_arg(x);
- }
- else if (RB_TYPE_P(x, T_RATIONAL)) {
- return numeric_arg(x);
- }
- else if (RB_TYPE_P(x, T_COMPLEX)) {
- return rb_complex_arg(x);
- }
- return rb_funcall(x, id_arg, 0);
-}
-
-inline static VALUE
-f_numerator(VALUE x)
-{
- if (RB_TYPE_P(x, T_RATIONAL)) {
- return RRATIONAL(x)->num;
- }
- if (RB_FLOAT_TYPE_P(x)) {
- return rb_float_numerator(x);
- }
- return x;
-}
-
-inline static VALUE
-f_denominator(VALUE x)
-{
- if (RB_TYPE_P(x, T_RATIONAL)) {
- return RRATIONAL(x)->den;
- }
- if (RB_FLOAT_TYPE_P(x)) {
- return rb_float_denominator(x);
- }
- return INT2FIX(1);
-}
+static VALUE nucomp_negate(VALUE self);
inline static VALUE
f_negate(VALUE x)
@@ -230,30 +169,13 @@ f_negate(VALUE x)
return rb_rational_uminus(x);
}
else if (RB_TYPE_P(x, T_COMPLEX)) {
- return rb_complex_uminus(x);
+ return nucomp_negate(x);
}
return rb_funcall(x, id_negate, 0);
}
-static bool nucomp_real_p(VALUE self);
-
-static inline bool
-f_real_p(VALUE x)
-{
- if (RB_INTEGER_TYPE_P(x)) {
- return true;
- }
- else if (RB_FLOAT_TYPE_P(x)) {
- return true;
- }
- else if (RB_TYPE_P(x, T_RATIONAL)) {
- return true;
- }
- else if (RB_TYPE_P(x, T_COMPLEX)) {
- return nucomp_real_p(x);
- }
- return rb_funcall(x, id_real_p, 0);
-}
+fun1(numerator)
+fun1(real_p)
inline static VALUE
f_to_i(VALUE x)
@@ -262,7 +184,6 @@ f_to_i(VALUE x)
return rb_str_to_inum(x, 10, 0);
return rb_funcall(x, id_to_i, 0);
}
-
inline static VALUE
f_to_f(VALUE x)
{
@@ -285,19 +206,7 @@ f_eqeq_p(VALUE x, VALUE y)
fun2(expt)
fun2(fdiv)
-
-static VALUE
-f_quo(VALUE x, VALUE y)
-{
- if (RB_INTEGER_TYPE_P(x))
- return rb_numeric_quo(x, y);
- if (RB_FLOAT_TYPE_P(x))
- return rb_float_div(x, y);
- if (RB_TYPE_P(x, T_RATIONAL))
- return rb_numeric_quo(x, y);
-
- return rb_funcallv(x, id_quo, 1, &y);
-}
+fun2(quo)
inline static int
f_negative_p(VALUE x)
@@ -316,10 +225,7 @@ f_negative_p(VALUE x)
inline static int
f_zero_p(VALUE x)
{
- if (RB_FLOAT_TYPE_P(x)) {
- return FLOAT_ZERO_P(x);
- }
- else if (RB_INTEGER_TYPE_P(x)) {
+ if (RB_INTEGER_TYPE_P(x)) {
return FIXNUM_ZERO_P(x);
}
else if (RB_TYPE_P(x, T_RATIONAL)) {
@@ -403,6 +309,30 @@ nucomp_s_alloc(VALUE klass)
return nucomp_s_new_internal(klass, ZERO, ZERO);
}
+#if 0
+static VALUE
+nucomp_s_new_bang(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE real, imag;
+
+ switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
+ case 1:
+ if (!k_numeric_p(real))
+ real = f_to_i(real);
+ imag = ZERO;
+ break;
+ default:
+ if (!k_numeric_p(real))
+ real = f_to_i(real);
+ if (!k_numeric_p(imag))
+ imag = f_to_i(imag);
+ break;
+ }
+
+ return nucomp_s_new_internal(klass, real, imag);
+}
+#endif
+
inline static VALUE
f_complex_new_bang1(VALUE klass, VALUE x)
{
@@ -419,6 +349,10 @@ f_complex_new_bang2(VALUE klass, VALUE x, VALUE y)
}
#ifdef CANONICALIZATION_FOR_MATHN
+#define CANON
+#endif
+
+#ifdef CANON
static int canonicalization = 0;
RUBY_FUNC_EXPORTED void
@@ -444,24 +378,26 @@ nucomp_real_check(VALUE num)
inline static VALUE
nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
{
- int complex_r, complex_i;
-#ifdef CANONICALIZATION_FOR_MATHN
+#ifdef CANON
+#define CL_CANON
+#ifdef CL_CANON
if (k_exact_zero_p(imag) && canonicalization)
return real;
+#else
+ if (f_zero_p(imag) && canonicalization)
+ return real;
+#endif
#endif
- complex_r = RB_TYPE_P(real, T_COMPLEX);
- complex_i = RB_TYPE_P(imag, T_COMPLEX);
- if (!complex_r && !complex_i) {
+ if (f_real_p(real) && f_real_p(imag))
return nucomp_s_new_internal(klass, real, imag);
- }
- else if (!complex_r) {
+ else if (f_real_p(real)) {
get_dat1(imag);
return nucomp_s_new_internal(klass,
f_sub(real, dat->imag),
f_add(ZERO, dat->real));
}
- else if (!complex_i) {
+ else if (f_real_p(imag)) {
get_dat1(real);
return nucomp_s_new_internal(klass,
@@ -512,12 +448,11 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y)
return nucomp_s_canonicalize_internal(klass, x, y);
}
-static VALUE nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise);
static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
/*
* call-seq:
- * Complex(x[, y], exception: true) -> numeric or nil
+ * Complex(x[, y]) -> numeric
*
* Returns x+i*y;
*
@@ -526,9 +461,6 @@ static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
* Complex(nil) #=> TypeError
* Complex(1, nil) #=> TypeError
*
- * Complex(1, nil, exception: false) #=> nil
- * Complex('1+2', exception: false) #=> nil
- *
* Syntax of string form:
*
* string form = extra spaces , complex , extra spaces ;
@@ -554,19 +486,7 @@ static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
{
- VALUE a1, a2, opts = Qnil;
- int raise = TRUE;
-
- if (rb_scan_args(argc, argv, "11:", &a1, &a2, &opts) == 1) {
- a2 = Qundef;
- }
- if (!NIL_P(opts)) {
- raise = rb_opts_exception_p(opts, raise);
- }
- if (argc > 0 && CLASS_OF(a1) == rb_cComplex && a2 == Qundef) {
- return a1;
- }
- return nucomp_convert(rb_cComplex, a1, a2, raise);
+ return nucomp_s_convert(argc, argv, rb_cComplex);
}
#define imp1(n) \
@@ -592,7 +512,7 @@ imp1(sinh)
static VALUE
m_cos(VALUE x)
{
- if (!RB_TYPE_P(x, T_COMPLEX))
+ if (f_real_p(x))
return m_cos_bang(x);
{
get_dat1(x);
@@ -607,7 +527,7 @@ m_cos(VALUE x)
static VALUE
m_sin(VALUE x)
{
- if (!RB_TYPE_P(x, T_COMPLEX))
+ if (f_real_p(x))
return m_sin_bang(x);
{
get_dat1(x);
@@ -619,6 +539,36 @@ m_sin(VALUE x)
}
}
+#if 0
+imp1(sqrt)
+
+VALUE
+rb_complex_sqrt(VALUE x)
+{
+ int pos;
+ VALUE a, re, im;
+ get_dat1(x);
+
+ pos = f_positive_p(dat->imag);
+ a = f_abs(x);
+ re = m_sqrt_bang(f_div(f_add(a, dat->real), TWO));
+ im = m_sqrt_bang(f_div(f_sub(a, dat->real), TWO));
+ if (!pos) im = f_negate(im);
+ return f_complex_new2(rb_cComplex, re, im);
+}
+
+static VALUE
+m_sqrt(VALUE x)
+{
+ if (f_real_p(x)) {
+ if (f_positive_p(x))
+ return m_sqrt_bang(x);
+ return f_complex_new2(rb_cComplex, ZERO, m_sqrt_bang(f_negate(x)));
+ }
+ return rb_complex_sqrt(x);
+}
+#endif
+
static VALUE
f_complex_polar(VALUE klass, VALUE x, VALUE y)
{
@@ -662,28 +612,6 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y)
f_mul(x, m_sin(y)));
}
-/* returns a Complex or Float of ang*PI-rotated abs */
-VALUE
-rb_dbl_complex_new_polar_pi(double abs, double ang)
-{
- double fi;
- const double fr = modf(ang, &fi);
- int pos = fr == +0.5;
-
- if (pos || fr == -0.5) {
- if ((modf(fi / 2.0, &fi) != fr) ^ pos) abs = -abs;
- return rb_complex_new(RFLOAT_0, DBL2NUM(abs));
- }
- else if (fr == 0.0) {
- if (modf(fi / 2.0, &fi) != 0.0) abs = -abs;
- return DBL2NUM(abs);
- }
- else {
- ang *= M_PI;
- return rb_complex_new(DBL2NUM(abs * cos(ang)), DBL2NUM(abs * sin(ang)));
- }
-}
-
/*
* call-seq:
* Complex.polar(abs[, arg]) -> complex
@@ -722,8 +650,8 @@ nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
* Complex(7).real #=> 7
* Complex(9, -4).real #=> 9
*/
-VALUE
-rb_complex_real(VALUE self)
+static VALUE
+nucomp_real(VALUE self)
{
get_dat1(self);
return dat->real;
@@ -739,8 +667,8 @@ rb_complex_real(VALUE self)
* Complex(7).imaginary #=> 0
* Complex(9, -4).imaginary #=> -4
*/
-VALUE
-rb_complex_imag(VALUE self)
+static VALUE
+nucomp_imag(VALUE self)
{
get_dat1(self);
return dat->imag;
@@ -754,12 +682,12 @@ rb_complex_imag(VALUE self)
*
* -Complex(1, 2) #=> (-1-2i)
*/
-VALUE
-rb_complex_uminus(VALUE self)
+static VALUE
+nucomp_negate(VALUE self)
{
- get_dat1(self);
- return f_complex_new2(CLASS_OF(self),
- f_negate(dat->real), f_negate(dat->imag));
+ get_dat1(self);
+ return f_complex_new2(CLASS_OF(self),
+ f_negate(dat->real), f_negate(dat->imag));
}
/*
@@ -808,8 +736,8 @@ rb_complex_plus(VALUE self, VALUE other)
* Complex(9, 8) - 4 #=> (5+8i)
* Complex(20, 9) - 9.8 #=> (10.2+9i)
*/
-VALUE
-rb_complex_minus(VALUE self, VALUE other)
+static VALUE
+nucomp_sub(VALUE self, VALUE other)
{
if (RB_TYPE_P(other, T_COMPLEX)) {
VALUE real, imag;
@@ -843,19 +771,6 @@ safe_mul(VALUE a, VALUE b, int az, int bz)
return f_mul(a, b);
}
-static void
-comp_mul(VALUE areal, VALUE aimag, VALUE breal, VALUE bimag, VALUE *real, VALUE *imag)
-{
- int arzero = f_zero_p(areal);
- int aizero = f_zero_p(aimag);
- int brzero = f_zero_p(breal);
- int bizero = f_zero_p(bimag);
- *real = f_sub(safe_mul(areal, breal, arzero, brzero),
- safe_mul(aimag, bimag, aizero, bizero));
- *imag = f_add(safe_mul(areal, bimag, arzero, bizero),
- safe_mul(aimag, breal, aizero, brzero));
-}
-
/*
* call-seq:
* cmp * numeric -> complex
@@ -873,9 +788,19 @@ rb_complex_mul(VALUE self, VALUE other)
{
if (RB_TYPE_P(other, T_COMPLEX)) {
VALUE real, imag;
+ VALUE areal, aimag, breal, bimag;
+ int arzero, aizero, brzero, bizero;
+
get_dat2(self, other);
- comp_mul(adat->real, adat->imag, bdat->real, bdat->imag, &real, &imag);
+ arzero = f_zero_p(areal = adat->real);
+ aizero = f_zero_p(aimag = adat->imag);
+ brzero = f_zero_p(breal = bdat->real);
+ bizero = f_zero_p(bimag = bdat->imag);
+ real = f_sub(safe_mul(areal, breal, arzero, brzero),
+ safe_mul(aimag, bimag, aizero, bizero));
+ imag = f_add(safe_mul(areal, bimag, arzero, bizero),
+ safe_mul(aimag, breal, aizero, brzero));
return f_complex_new2(CLASS_OF(self), real, imag);
}
@@ -888,13 +813,13 @@ rb_complex_mul(VALUE self, VALUE other)
}
return rb_num_coerce_bin(self, other, '*');
}
+#define nucomp_mul rb_complex_mul
inline static VALUE
f_divide(VALUE self, VALUE other,
VALUE (*func)(VALUE, VALUE), ID id)
{
if (RB_TYPE_P(other, T_COMPLEX)) {
- VALUE r, n, x, y;
int flo;
get_dat2(self, other);
@@ -902,29 +827,42 @@ f_divide(VALUE self, VALUE other,
RB_FLOAT_TYPE_P(bdat->real) || RB_FLOAT_TYPE_P(bdat->imag));
if (f_gt_p(f_abs(bdat->real), f_abs(bdat->imag))) {
+ VALUE r, n;
+
r = (*func)(bdat->imag, bdat->real);
n = f_mul(bdat->real, f_add(ONE, f_mul(r, r)));
- x = (*func)(f_add(adat->real, f_mul(adat->imag, r)), n);
- y = (*func)(f_sub(adat->imag, f_mul(adat->real, r)), n);
+ if (flo)
+ return f_complex_new2(CLASS_OF(self),
+ (*func)(self, n),
+ (*func)(f_negate(f_mul(self, r)), n));
+ return f_complex_new2(CLASS_OF(self),
+ (*func)(f_add(adat->real,
+ f_mul(adat->imag, r)), n),
+ (*func)(f_sub(adat->imag,
+ f_mul(adat->real, r)), n));
}
else {
+ VALUE r, n;
+
r = (*func)(bdat->real, bdat->imag);
n = f_mul(bdat->imag, f_add(ONE, f_mul(r, r)));
- x = (*func)(f_add(f_mul(adat->real, r), adat->imag), n);
- y = (*func)(f_sub(f_mul(adat->imag, r), adat->real), n);
+ if (flo)
+ return f_complex_new2(CLASS_OF(self),
+ (*func)(f_mul(self, r), n),
+ (*func)(f_negate(self), n));
+ return f_complex_new2(CLASS_OF(self),
+ (*func)(f_add(f_mul(adat->real, r),
+ adat->imag), n),
+ (*func)(f_sub(f_mul(adat->imag, r),
+ adat->real), n));
}
- if (!flo) {
- x = rb_rational_canonicalize(x);
- y = rb_rational_canonicalize(y);
- }
- return f_complex_new2(CLASS_OF(self), x, y);
}
if (k_numeric_p(other) && f_real_p(other)) {
- VALUE x, y;
get_dat1(self);
- x = rb_rational_canonicalize((*func)(dat->real, other));
- y = rb_rational_canonicalize((*func)(dat->imag, other));
- return f_complex_new2(CLASS_OF(self), x, y);
+
+ return f_complex_new2(CLASS_OF(self),
+ (*func)(dat->real, other),
+ (*func)(dat->imag, other));
}
return rb_num_coerce_bin(self, other, id);
}
@@ -944,13 +882,13 @@ f_divide(VALUE self, VALUE other,
* Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i)
* Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i)
*/
-VALUE
-rb_complex_div(VALUE self, VALUE other)
+static VALUE
+nucomp_div(VALUE self, VALUE other)
{
return f_divide(self, other, f_quo, id_quo);
}
-#define nucomp_quo rb_complex_div
+#define nucomp_quo nucomp_div
/*
* call-seq:
@@ -981,8 +919,8 @@ f_reciprocal(VALUE x)
* Complex('i') ** 2 #=> (-1+0i)
* Complex(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i)
*/
-VALUE
-rb_complex_pow(VALUE self, VALUE other)
+static VALUE
+nucomp_expt(VALUE self, VALUE other)
{
if (k_numeric_p(other) && k_exact_zero_p(other))
return f_complex_new_bang1(CLASS_OF(self), ONE);
@@ -1012,45 +950,38 @@ rb_complex_pow(VALUE self, VALUE other)
return f_complex_polar(CLASS_OF(self), nr, ntheta);
}
if (FIXNUM_P(other)) {
- long n = FIX2LONG(other);
- if (n == 0) {
- return nucomp_s_new_internal(CLASS_OF(self), ONE, ZERO);
- }
- if (n < 0) {
- self = f_reciprocal(self);
- other = rb_int_uminus(other);
- n = -n;
- }
- {
- get_dat1(self);
- VALUE xr = dat->real, xi = dat->imag, zr = xr, zi = xi;
-
- if (f_zero_p(xi)) {
- zr = rb_num_pow(zr, other);
- }
- else if (f_zero_p(xr)) {
- zi = rb_num_pow(zi, other);
- if (n & 2) zi = f_negate(zi);
- if (!(n & 1)) {
- VALUE tmp = zr;
- zr = zi;
- zi = tmp;
- }
- }
- else {
- while (--n) {
- long q, r;
-
- for (; q = n / 2, r = n % 2, r == 0; n = q) {
- VALUE tmp = f_sub(f_mul(xr, xr), f_mul(xi, xi));
- xi = f_mul(f_mul(TWO, xr), xi);
- xr = tmp;
- }
- comp_mul(zr, zi, xr, xi, &zr, &zi);
- }
- }
- return nucomp_s_new_internal(CLASS_OF(self), zr, zi);
+ if (f_gt_p(other, ZERO)) {
+ VALUE x, z;
+ long n;
+
+ x = self;
+ z = x;
+ n = FIX2LONG(other) - 1;
+
+ while (n) {
+ long q, r;
+
+ while (1) {
+ get_dat1(x);
+
+ q = n / 2;
+ r = n % 2;
+
+ if (r)
+ break;
+
+ x = nucomp_s_new_internal(CLASS_OF(self),
+ f_sub(f_mul(dat->real, dat->real),
+ f_mul(dat->imag, dat->imag)),
+ f_mul(f_mul(TWO, dat->real), dat->imag));
+ n = q;
+ }
+ z = f_mul(z, x);
+ n--;
+ }
+ return z;
}
+ return f_expt(f_reciprocal(self), rb_int_uminus(other));
}
if (k_numeric_p(other) && f_real_p(other)) {
VALUE r, theta;
@@ -1096,51 +1027,14 @@ nucomp_eqeq_p(VALUE self, VALUE other)
return f_boolcast(f_eqeq_p(other, self));
}
-static bool
-nucomp_real_p(VALUE self)
-{
- get_dat1(self);
- return(f_zero_p(dat->imag) ? true : false);
-}
-
-/*
- * call-seq:
- * cmp <=> object -> 0, 1, -1, or nil
- *
- * If +cmp+'s imaginary part is zero, and +object+ is also a
- * real number (or a Complex number where the imaginary part is zero),
- * compare the real part of +cmp+ to object. Otherwise, return nil.
- *
- * Complex(2, 3) <=> Complex(2, 3) #=> nil
- * Complex(2, 3) <=> 1 #=> nil
- * Complex(2) <=> 1 #=> 1
- * Complex(2) <=> 2 #=> 0
- * Complex(2) <=> 3 #=> -1
- */
-static VALUE
-nucomp_cmp(VALUE self, VALUE other)
-{
- if (nucomp_real_p(self) && k_numeric_p(other)) {
- if (RB_TYPE_P(other, T_COMPLEX) && nucomp_real_p(other)) {
- get_dat2(self, other);
- return rb_funcall(adat->real, idCmp, 1, bdat->real);
- }
- else if (f_real_p(other)) {
- get_dat1(self);
- return rb_funcall(dat->real, idCmp, 1, other);
- }
- }
- return Qnil;
-}
-
/* :nodoc: */
static VALUE
nucomp_coerce(VALUE self, VALUE other)
{
+ if (k_numeric_p(other) && f_real_p(other))
+ return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self);
if (RB_TYPE_P(other, T_COMPLEX))
return rb_assoc_new(other, self);
- if (k_numeric_p(other) && f_real_p(other))
- return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self);
rb_raise(rb_eTypeError, "%"PRIsVALUE" can't be coerced into %"PRIsVALUE,
rb_obj_class(other), rb_obj_class(self));
@@ -1157,8 +1051,8 @@ nucomp_coerce(VALUE self, VALUE other)
* Complex(-1).abs #=> 1
* Complex(3.0, -4.0).abs #=> 5.0
*/
-VALUE
-rb_complex_abs(VALUE self)
+static VALUE
+nucomp_abs(VALUE self)
{
get_dat1(self);
@@ -1204,8 +1098,8 @@ nucomp_abs2(VALUE self)
*
* Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966
*/
-VALUE
-rb_complex_arg(VALUE self)
+static VALUE
+nucomp_arg(VALUE self)
{
get_dat1(self);
return rb_math_atan2(dat->imag, dat->real);
@@ -1250,19 +1144,27 @@ nucomp_polar(VALUE self)
*
* Complex(1, 2).conjugate #=> (1-2i)
*/
-VALUE
-rb_complex_conjugate(VALUE self)
+static VALUE
+nucomp_conj(VALUE self)
{
get_dat1(self);
return f_complex_new2(CLASS_OF(self), dat->real, f_negate(dat->imag));
}
+#if 0
+/* :nodoc: */
+static VALUE
+nucomp_true(VALUE self)
+{
+ return Qtrue;
+}
+#endif
+
/*
* call-seq:
- * Complex(1).real? -> false
- * Complex(1, 2).real? -> false
+ * cmp.real? -> false
*
- * Returns false, even if the complex number has no imaginary part.
+ * Returns false.
*/
static VALUE
nucomp_false(VALUE self)
@@ -1270,6 +1172,23 @@ nucomp_false(VALUE self)
return Qfalse;
}
+#if 0
+/* :nodoc: */
+static VALUE
+nucomp_exact_p(VALUE self)
+{
+ get_dat1(self);
+ return f_boolcast(k_exact_p(dat->real) && k_exact_p(dat->imag));
+}
+
+/* :nodoc: */
+static VALUE
+nucomp_inexact_p(VALUE self)
+{
+ return f_boolcast(!nucomp_exact_p(self));
+}
+#endif
+
/*
* call-seq:
* cmp.denominator -> integer
@@ -1310,7 +1229,7 @@ nucomp_numerator(VALUE self)
get_dat1(self);
- cd = nucomp_denominator(self);
+ cd = f_denominator(self);
return f_complex_new2(CLASS_OF(self),
f_mul(f_numerator(dat->real),
f_div(cd, f_denominator(dat->real))),
@@ -1434,7 +1353,7 @@ nucomp_inspect(VALUE self)
* call-seq:
* cmp.finite? -> true or false
*
- * Returns +true+ if +cmp+'s real and imaginary parts are both finite numbers,
+ * Returns +true+ if +cmp+'s magnitude is a finite number,
* otherwise returns +false+.
*/
static VALUE
@@ -1452,8 +1371,10 @@ rb_complex_finite_p(VALUE self)
* call-seq:
* cmp.infinite? -> nil or 1
*
- * Returns +1+ if +cmp+'s real or imaginary part is an infinite number,
- * otherwise returns +nil+.
+ * Returns values corresponding to the value of +cmp+'s magnitude:
+ *
+ * +finite+:: +nil+
+ * ++Infinity+:: ++1+
*
* For example:
*
@@ -1530,15 +1451,9 @@ rb_complex_new(VALUE x, VALUE y)
}
VALUE
-rb_complex_new_polar(VALUE x, VALUE y)
-{
- return f_complex_polar(rb_cComplex, x, y);
-}
-
-VALUE
rb_complex_polar(VALUE x, VALUE y)
{
- return rb_complex_new_polar(x, y);
+ return f_complex_polar(rb_cComplex, x, y);
}
VALUE
@@ -1550,17 +1465,10 @@ rb_Complex(VALUE x, VALUE y)
return nucomp_s_convert(2, a, rb_cComplex);
}
-/*!
- * Creates a Complex object.
- *
- * \param real real part value
- * \param imag imaginary part value
- * \return a new Complex object
- */
VALUE
-rb_dbl_complex_new(double real, double imag)
+rb_complex_abs(VALUE cmp)
{
- return rb_complex_raw(DBL2NUM(real), DBL2NUM(imag));
+ return nucomp_abs(cmp);
}
/*
@@ -1652,7 +1560,7 @@ nucomp_rationalize(int argc, VALUE *argv, VALUE self)
{
get_dat1(self);
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", NULL);
if (!k_exact_zero_p(dat->imag)) {
rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Rational",
@@ -1898,7 +1806,7 @@ read_comp(const char **s, int strict,
return 0; /* e.g. "1@-" */
}
num2 = str2num(bb);
- *ret = rb_complex_new_polar(num, num2);
+ *ret = rb_complex_polar(num, num2);
if (!st)
return 0; /* e.g. "1@2." */
else
@@ -1941,7 +1849,8 @@ skip_ws(const char **s)
}
static int
-parse_comp(const char *s, int strict, VALUE *num)
+parse_comp(const char *s, int strict,
+ VALUE *num)
{
char *buf, *b;
VALUE tmp;
@@ -1952,14 +1861,14 @@ parse_comp(const char *s, int strict, VALUE *num)
skip_ws(&s);
if (!read_comp(&s, strict, num, &b)) {
- ret = 0;
+ ret = 0;
}
else {
- skip_ws(&s);
+ skip_ws(&s);
- if (strict)
- if (*s != '\0')
- ret = 0;
+ if (strict)
+ if (*s != '\0')
+ ret = 0;
}
ALLOCV_END(tmp);
@@ -1967,7 +1876,7 @@ parse_comp(const char *s, int strict, VALUE *num)
}
static VALUE
-string_to_c_strict(VALUE self, int raise)
+string_to_c_strict(VALUE self)
{
char *s;
VALUE num;
@@ -1976,10 +1885,8 @@ string_to_c_strict(VALUE self, int raise)
s = RSTRING_PTR(self);
- if (!s || memchr(s, '\0', RSTRING_LEN(self))) {
- if (!raise) return Qnil;
+ if (!s || memchr(s, '\0', RSTRING_LEN(self)))
rb_raise(rb_eArgError, "string contains null byte");
- }
if (s && s[RSTRING_LEN(self)]) {
rb_str_modify(self);
@@ -1991,7 +1898,6 @@ string_to_c_strict(VALUE self, int raise)
s = (char *)"";
if (!parse_comp(s, 1, &num)) {
- if (!raise) return Qnil;
rb_raise(rb_eArgError, "invalid value for convert(): %+"PRIsVALUE,
self);
}
@@ -2047,29 +1953,28 @@ string_to_c(VALUE self)
}
static VALUE
-to_complex(VALUE val)
+nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
{
- return rb_convert_type(val, T_COMPLEX, "Complex", "to_c");
-}
+ VALUE a1, a2, backref;
-static VALUE
-nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
-{
- if (NIL_P(a1) || NIL_P(a2)) {
- if (!raise) return Qnil;
+ rb_scan_args(argc, argv, "11", &a1, &a2);
+
+ if (NIL_P(a1) || (argc == 2 && NIL_P(a2)))
rb_raise(rb_eTypeError, "can't convert nil into Complex");
- }
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
if (RB_TYPE_P(a1, T_STRING)) {
- a1 = string_to_c_strict(a1, raise);
- if (NIL_P(a1)) return Qnil;
+ a1 = string_to_c_strict(a1);
}
if (RB_TYPE_P(a2, T_STRING)) {
- a2 = string_to_c_strict(a2, raise);
- if (NIL_P(a2)) return Qnil;
+ a2 = string_to_c_strict(a2);
}
+ rb_backref_set(backref);
+
if (RB_TYPE_P(a1, T_COMPLEX)) {
{
get_dat1(a1);
@@ -2089,19 +1994,16 @@ nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
}
if (RB_TYPE_P(a1, T_COMPLEX)) {
- if (a2 == Qundef || (k_exact_zero_p(a2)))
+ if (argc == 1 || (k_exact_zero_p(a2)))
return a1;
}
- if (a2 == Qundef) {
+ if (argc == 1) {
if (k_numeric_p(a1) && !f_real_p(a1))
return a1;
/* should raise exception for consistency */
- if (!k_numeric_p(a1)) {
- if (!raise)
- return rb_protect(to_complex, a1, NULL);
- return to_complex(a1);
- }
+ if (!k_numeric_p(a1))
+ return rb_convert_type(a1, T_COMPLEX, "Complex", "to_c");
}
else {
if ((k_numeric_p(a1) && k_numeric_p(a2)) &&
@@ -2112,35 +2014,13 @@ nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
}
{
- int argc;
VALUE argv2[2];
argv2[0] = a1;
- if (a2 == Qundef) {
- argv2[1] = Qnil;
- argc = 1;
- }
- else {
- if (!raise && !RB_INTEGER_TYPE_P(a2) && !RB_FLOAT_TYPE_P(a2) && !RB_TYPE_P(a2, T_RATIONAL))
- return Qnil;
- argv2[1] = a2;
- argc = 2;
- }
+ argv2[1] = a2;
return nucomp_s_new(argc, argv2, klass);
}
}
-static VALUE
-nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
-{
- VALUE a1, a2;
-
- if (rb_scan_args(argc, argv, "11", &a1, &a2) == 1) {
- a2 = Qundef;
- }
-
- return nucomp_convert(klass, a1, a2, TRUE);
-}
-
/* --- */
/*
@@ -2312,11 +2192,20 @@ Init_Complex(void)
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
+ assert(fprintf(stderr, "assert() is now active\n"));
+
id_abs = rb_intern("abs");
id_arg = rb_intern("arg");
id_denominator = rb_intern("denominator");
+ id_expt = rb_intern("**");
+ id_fdiv = rb_intern("fdiv");
+ id_negate = rb_intern("-@");
id_numerator = rb_intern("numerator");
+ id_quo = rb_intern("quo");
id_real_p = rb_intern("real?");
+ id_to_f = rb_intern("to_f");
+ id_to_i = rb_intern("to_i");
+ id_to_r = rb_intern("to_r");
id_i_real = rb_intern("@real");
id_i_imag = rb_intern("@image"); /* @image, not @imag */
id_finite_p = rb_intern("finite?");
@@ -2329,7 +2218,12 @@ Init_Complex(void)
rb_define_alloc_func(rb_cComplex, nucomp_s_alloc);
rb_undef_method(CLASS_OF(rb_cComplex), "allocate");
+#if 0
+ rb_define_private_method(CLASS_OF(rb_cComplex), "new!", nucomp_s_new_bang, -1);
+ rb_define_private_method(CLASS_OF(rb_cComplex), "new", nucomp_s_new, -1);
+#else
rb_undef_method(CLASS_OF(rb_cComplex), "new");
+#endif
rb_define_singleton_method(rb_cComplex, "rectangular", nucomp_s_new, -1);
rb_define_singleton_method(rb_cComplex, "rect", nucomp_s_new, -1);
@@ -2339,6 +2233,7 @@ Init_Complex(void)
rb_undef_methods_from(rb_cComplex, rb_mComparable);
rb_undef_method(rb_cComplex, "%");
+ rb_undef_method(rb_cComplex, "<=>");
rb_undef_method(rb_cComplex, "div");
rb_undef_method(rb_cComplex, "divmod");
rb_undef_method(rb_cComplex, "floor");
@@ -2350,36 +2245,43 @@ Init_Complex(void)
rb_undef_method(rb_cComplex, "truncate");
rb_undef_method(rb_cComplex, "i");
- rb_define_method(rb_cComplex, "real", rb_complex_real, 0);
- rb_define_method(rb_cComplex, "imaginary", rb_complex_imag, 0);
- rb_define_method(rb_cComplex, "imag", rb_complex_imag, 0);
+ rb_define_method(rb_cComplex, "real", nucomp_real, 0);
+ rb_define_method(rb_cComplex, "imaginary", nucomp_imag, 0);
+ rb_define_method(rb_cComplex, "imag", nucomp_imag, 0);
- rb_define_method(rb_cComplex, "-@", rb_complex_uminus, 0);
+ rb_define_method(rb_cComplex, "-@", nucomp_negate, 0);
rb_define_method(rb_cComplex, "+", rb_complex_plus, 1);
- rb_define_method(rb_cComplex, "-", rb_complex_minus, 1);
- rb_define_method(rb_cComplex, "*", rb_complex_mul, 1);
- rb_define_method(rb_cComplex, "/", rb_complex_div, 1);
+ rb_define_method(rb_cComplex, "-", nucomp_sub, 1);
+ rb_define_method(rb_cComplex, "*", nucomp_mul, 1);
+ rb_define_method(rb_cComplex, "/", nucomp_div, 1);
rb_define_method(rb_cComplex, "quo", nucomp_quo, 1);
rb_define_method(rb_cComplex, "fdiv", nucomp_fdiv, 1);
- rb_define_method(rb_cComplex, "**", rb_complex_pow, 1);
+ rb_define_method(rb_cComplex, "**", nucomp_expt, 1);
rb_define_method(rb_cComplex, "==", nucomp_eqeq_p, 1);
- rb_define_method(rb_cComplex, "<=>", nucomp_cmp, 1);
rb_define_method(rb_cComplex, "coerce", nucomp_coerce, 1);
- rb_define_method(rb_cComplex, "abs", rb_complex_abs, 0);
- rb_define_method(rb_cComplex, "magnitude", rb_complex_abs, 0);
+ rb_define_method(rb_cComplex, "abs", nucomp_abs, 0);
+ rb_define_method(rb_cComplex, "magnitude", nucomp_abs, 0);
rb_define_method(rb_cComplex, "abs2", nucomp_abs2, 0);
- rb_define_method(rb_cComplex, "arg", rb_complex_arg, 0);
- rb_define_method(rb_cComplex, "angle", rb_complex_arg, 0);
- rb_define_method(rb_cComplex, "phase", rb_complex_arg, 0);
+ rb_define_method(rb_cComplex, "arg", nucomp_arg, 0);
+ rb_define_method(rb_cComplex, "angle", nucomp_arg, 0);
+ rb_define_method(rb_cComplex, "phase", nucomp_arg, 0);
rb_define_method(rb_cComplex, "rectangular", nucomp_rect, 0);
rb_define_method(rb_cComplex, "rect", nucomp_rect, 0);
rb_define_method(rb_cComplex, "polar", nucomp_polar, 0);
- rb_define_method(rb_cComplex, "conjugate", rb_complex_conjugate, 0);
- rb_define_method(rb_cComplex, "conj", rb_complex_conjugate, 0);
+ rb_define_method(rb_cComplex, "conjugate", nucomp_conj, 0);
+ rb_define_method(rb_cComplex, "conj", nucomp_conj, 0);
+#if 0
+ rb_define_method(rb_cComplex, "~", nucomp_conj, 0); /* gcc */
+#endif
rb_define_method(rb_cComplex, "real?", nucomp_false, 0);
+#if 0
+ rb_define_method(rb_cComplex, "complex?", nucomp_true, 0);
+ rb_define_method(rb_cComplex, "exact?", nucomp_exact_p, 0);
+ rb_define_method(rb_cComplex, "inexact?", nucomp_inexact_p, 0);
+#endif
rb_define_method(rb_cComplex, "numerator", nucomp_numerator, 0);
rb_define_method(rb_cComplex, "denominator", nucomp_denominator, 0);
@@ -2397,8 +2299,7 @@ Init_Complex(void)
rb_define_method(rb_cComplex, "infinite?", rb_complex_infinite_p, 0);
rb_define_private_method(rb_cComplex, "marshal_dump", nucomp_marshal_dump, 0);
- /* :nodoc: */
- compat = rb_define_class_under(rb_cComplex, "compatible", rb_cObject);
+ compat = rb_define_class_under(rb_cComplex, "compatible", rb_cObject); /* :nodoc: */
rb_define_private_method(compat, "marshal_load", nucomp_marshal_load, 1);
rb_marshal_define_compat(rb_cComplex, compat, nucomp_dumper, nucomp_loader);
@@ -2441,9 +2342,11 @@ Init_Complex(void)
rb_define_const(rb_cComplex, "I",
f_complex_new_bang2(rb_cComplex, ZERO, ONE));
-#if !USE_FLONUM
- rb_gc_register_mark_object(RFLOAT_0 = DBL2NUM(0.0));
-#endif
-
rb_provide("complex.so"); /* for backward compatibility */
}
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
diff --git a/configure.ac b/configure.ac
index 826a688871..8a7cee55b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,27 +1,37 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT
+AC_INIT()
{
AC_CONFIG_AUX_DIR(tool)
-AC_CONFIG_MACRO_DIRS(tool/m4)
AC_PREREQ(2.67)
-dnl override AC_CHECKING
-dnl placed here due to aclocal(1)'s
-dnl ignoring this definition in separate files
-AC_DEFUN([AC_CHECKING],[dnl
-AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl
-AS_MESSAGE([checking ${msg_checking}$1${msg_reset}...])])dnl
-
AC_DISABLE_OPTION_CHECKING
-AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])
-AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])
-AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])
+AC_ARG_VAR([cflags], [additional CFLAGS])
+AC_ARG_VAR([cppflags], [additional CPPFLAGS])
+AC_ARG_VAR([cxxflags], [additional CXXFLAGS])
+
+AC_DEFUN([RUBY_RM_RECURSIVE], [
+m4_version_prereq([2.70], [-1], [
+# suppress error messages, rm: cannot remove 'conftest.dSYM', from
+# AC_EGREP_CPP with CFLAGS=-g on Darwin.
+AS_CASE([$build_os], [darwin*], [
+rm() {
+ rm_recursive=''
+ for arg do
+ AS_CASE("$arg",
+ [--*], [],
+ [-*r*], [break],
+ [conftest.*], [AS_IF([test -d "$arg"], [rm_recursive=-r; break])],
+ [])
+ done
+ command rm $rm_recursive "[$]@"
+}
+])])])
+
+{ # environment section
-: "environment section" && {
HAVE_BASERUBY=yes
-BASERUBY_VERSION=
AC_ARG_WITH(baseruby,
AS_HELP_STRING([--with-baseruby=RUBY], [use RUBY as baseruby; RUBY is the pathname of ruby]),
[AS_CASE(["$withval"],
@@ -35,9 +45,8 @@ AC_ARG_WITH(baseruby,
AS_IF([test "$HAVE_BASERUBY" = yes -a "`RUBYOPT=- $BASERUBY -e 'print 42' 2>/dev/null`" = 42], [
AS_IF([test "`RUBYOPT=- $BASERUBY --disable=gems -e 'print 42' 2>/dev/null`" = 42], [
BASERUBY="$BASERUBY --disable=gems"
- BASERUBY_VERSION=`$BASERUBY -v`
])
- $BASERUBY -C "$srcdir" tool/downloader.rb -d tool -e gnu config.guess config.sub >&AS_MESSAGE_FD
+ $BASERUBY -C "$srcdir" tool/downloader.rb -d tool -e gnu config.guess config.sub
], [
BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
HAVE_BASERUBY=no
@@ -57,20 +66,77 @@ AS_IF([test x"$HAVE_GIT" = xyes], [command -v "$GIT" > /dev/null || HAVE_GIT=no]
AC_SUBST(GIT)
AC_SUBST(HAVE_GIT)
-eval `sed -n -e ['s/^@%:@define RUBY_[A-Z_]*VERSION_\([A-Z][A-Z][A-Z_0-9]*\) \([0-9][0-9]*\)$/\1=\2/p'] \
- -e ['s/^@%:@define \(RUBY_PATCHLEVEL\) \(.*\)/\1=\2/p'] \
- $srcdir/include/ruby/version.h $srcdir/version.h`
+AC_DEFUN([RUBY_MINGW32],
+[AS_CASE(["$host_os"],
+[cygwin*], [
+AC_CACHE_CHECK(for mingw32 environment, rb_cv_mingw32,
+[AC_TRY_CPP([
+#ifndef __MINGW32__
+# error
+#endif
+], rb_cv_mingw32=yes,rb_cv_mingw32=no)
+rm -f conftest*])
+AS_IF([test "$rb_cv_mingw32" = yes], [
+ target_os="mingw32"
+ : ${ac_tool_prefix:="`expr "$CC" : ['\(.*-\)g\?cc[^/]*$']`"}
+])
+])
+AS_CASE(["$target_os"], [mingw*msvc], [
+target_os="`echo ${target_os} | sed 's/msvc$//'`"
+])
+AS_CASE(["$target_cpu-$target_os"], [x86_64-mingw*], [
+target_cpu=x64
+])
+])
+
+AC_DEFUN([RUBY_CPPOUTFILE],
+[AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
+[save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS='-o conftest-1.i'
+rb_cv_cppoutfile=no
+AC_TRY_CPP([test-for-cppout],
+ [grep test-for-cppout conftest-1.i > /dev/null && rb_cv_cppoutfile=yes])
+CPPFLAGS="$save_CPPFLAGS"
+rm -f conftest*])
+AS_IF([test "$rb_cv_cppoutfile" = yes], [
+ CPPOUTFILE='-o conftest.i'
+], [test "$rb_cv_cppoutfile" = no], [
+ CPPOUTFILE='> conftest.i'
+], [test -n "$rb_cv_cppoutfile"], [
+ CPPOUTFILE="$rb_cv_cppoutfile"
+])
+AC_SUBST(CPPOUTFILE)])
+
+AC_DEFUN([RUBY_PROG_GNU_LD],
+[AC_CACHE_CHECK(whether the linker is GNU ld, rb_cv_prog_gnu_ld,
+[AS_IF([`$CC $CFLAGS $CPPFLAGS $LDFLAGS --print-prog-name=ld 2>&1` -v 2>&1 | grep "GNU ld" > /dev/null], [
+ rb_cv_prog_gnu_ld=yes
+], [
+ rb_cv_prog_gnu_ld=no
+])])
+GNU_LD=$rb_cv_prog_gnu_ld
+AC_SUBST(GNU_LD)])
+
+eval `sed -n ['s/^@%:@define RUBY_API_VERSION_\([A-Z][A-Z_0-9]*\) \([0-9][0-9]*\)/API_\1=\2/p'] $srcdir/include/ruby/version.h`
+RUBY_PROGRAM_VERSION=`sed -n 's/^@%:@define RUBY_VERSION "\(.*\)"/\1/p' $srcdir/version.h`
+MAJOR=`echo $RUBY_PROGRAM_VERSION | cut -d. -f1`
+MINOR=`echo $RUBY_PROGRAM_VERSION | cut -d. -f2`
+TEENY=`echo $RUBY_PROGRAM_VERSION | cut -d. -f3`
for v in MAJOR MINOR TEENY; do
AS_IF([eval "test \"\$$v\" = ''"], [
AC_MSG_ERROR(could not determine $v number from version.h)
])
done
+AS_IF([test "$MAJOR.$MINOR" != "$API_MAJOR.$API_MINOR"], [
+ AC_MSG_ERROR([API version $API_MAJOR.$API_MINOR differs from program version $MAJOR.$MINOR])
+])
AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(TEENY)
+AC_SUBST(RUBY_PROGRAM_VERSION)
AC_SUBST(RUBY_API_VERSION, '$(MAJOR).$(MINOR)')
-AC_SUBST(RUBY_PROGRAM_VERSION, '$(MAJOR).$(MINOR).$(TEENY)')
-
+RUBY_PATCHLEVEL=`sed -n 's/^#define RUBY_PATCHLEVEL //p' $srcdir/version.h`
+AC_DEFINE(CANONICALIZATION_FOR_MATHN)
dnl checks for alternative programs
AC_CANONICAL_BUILD
RUBY_RM_RECURSIVE
@@ -127,7 +193,7 @@ AS_CASE("${os_version_style}",
[minor], [os_version_style_transform=['s/\([0-9]\.[0-9][0-9]*\)\.[0-9][.0-9]*$/\1/']],
[major+0], [os_version_style_transform=['s/\([0-9]\)\.[0-9][.0-9]*$/\1.0/']],
[major], [os_version_style_transform=['s/\([0-9]\)\.[0-9][.0-9]*$/\1/']],
- [none], [os_version_style_transform=['s/[0-9]*\.[0-9][.0-9]*$//']],
+ [none], [os_version_style_transform=['s/[0-9]\.[0-9][.0-9]*$//']],
[AC_MSG_ERROR(unknown --with-os-version-style: $withval)])
AS_IF([test -z "$target_alias" -a -n "$os_version_style_transform"],
[
@@ -135,6 +201,28 @@ AS_IF([test -z "$target_alias" -a -n "$os_version_style_transform"],
target_os=`echo ${target_os} | sed "$os_version_style_transform"`
])
+AC_DEFUN([RUBY_APPEND_OPTION],
+ [# RUBY_APPEND_OPTION($1)
+ AS_CASE([" [$]{$1-} "],
+ [*" $2 "*], [], [' '], [ $1="$2"], [ $1="[$]$1 $2"])])
+AC_DEFUN([RUBY_APPEND_OPTIONS],
+ [# RUBY_APPEND_OPTIONS($1)
+ for rb_opt in $2; do
+ AS_CASE([" [$]{$1-} "],
+ [*" [$]{rb_opt} "*], [], [' '], [ $1="[$]{rb_opt}"], [ $1="[$]$1 [$]{rb_opt}"])
+ done])
+AC_DEFUN([RUBY_PREPEND_OPTION],
+ [# RUBY_PREPEND_OPTION($1)
+ AS_CASE([" [$]{$1-} "],
+ [*" $2 "*], [], [' '], [ $1="$2"], [ $1="$2 [$]$1"])])
+AC_DEFUN([RUBY_PREPEND_OPTIONS],
+ [# RUBY_PREPEND_OPTIONS($1)
+ unset rb_opts; for rb_opt in $2; do
+ AS_CASE([" [$]{rb_opts} [$]{$1-} "],
+ [*" [$]{rb_opt} "*], [], [' '], [ $1="[$]{rb_opt}"], [ rb_opts="[$]{rb_opts}[$]{rb_opt} "])
+ done
+ $1="[$]{rb_opts}[$]$1"])
+
AC_ARG_WITH(arch,
AS_HELP_STRING([--with-arch=ARCHS],
[build an Apple/NeXT Multi Architecture Binary (MAB);
@@ -144,15 +232,112 @@ AC_ARG_WITH(arch,
target platform]),
[target_archs="$withval"], [unset target_archs])
+AC_DEFUN([RUBY_DEFAULT_ARCH], [
+AC_MSG_CHECKING([arch option])
+AS_CASE([$1],
+ [*64], [ARCH_FLAG=-m64],
+ [[i[3-6]86]], [ARCH_FLAG=-m32],
+ [AC_MSG_ERROR(unknown target architecture: $target_archs)]
+ )
+AC_MSG_RESULT([$ARCH_FLAG])
+])
+
+AC_DEFUN([RUBY_UNIVERSAL_ARCH], [
+# RUBY_UNIVERSAL_ARCH begin
+ARCH_FLAG=`expr " $CXXFLAGS " : ['.* \(-m[0-9][0-9]*\) ']`
+test ${CXXFLAGS+set} && CXXFLAGS=`echo "$CXXFLAGS" | sed [-e 's/ *-arch *[^ ]*//g' -e 's/ *-m32//g' -e 's/ *-m64//g']`
+ARCH_FLAG=`expr " $CFLAGS " : ['.* \(-m[0-9][0-9]*\) ']`
+test ${CFLAGS+set} && CFLAGS=`echo "$CFLAGS" | sed [-e 's/ *-arch *[^ ]*//g' -e 's/ *-m32//g' -e 's/ *-m64//g']`
+test ${LDFLAGS+set} && LDFLAGS=`echo "$LDFLAGS" | sed [-e 's/ *-arch *[^ ]*//g' -e 's/ *-m32//g' -e 's/ *-m64//g']`
+unset universal_binary universal_archnames
+AS_IF([test ${target_archs+set}], [
+ AC_MSG_CHECKING([target architectures])
+ target_archs=`echo $target_archs | tr , ' '`
+ # /usr/lib/arch_tool -archify_list $TARGET_ARCHS
+ for archs in $target_archs
+ do
+ AS_CASE([",$universal_binary,"],[*",$archs,"*], [],[
+ cpu=`$SHELL "$ac_aux_dir/config.sub" "${archs}-${target_os}" 2>&1` || {
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([$cpu])
+ }
+ cpu=`echo $cpu | sed 's/-.*-.*//'`
+ universal_binary="${universal_binary+$universal_binary,}$cpu"
+ universal_archnames="${universal_archnames} ${archs}=${cpu}"
+ ARCH_FLAG="${ARCH_FLAG+$ARCH_FLAG }-arch $archs"
+ ])
+ done
+ target_archs="$universal_binary"
+ unset universal_binary
+ AS_CASE(["$target_archs"],
+ [*,*], [universal_binary=yes],
+ [unset universal_archnames])
+ AC_MSG_RESULT([$target_archs])
+
+ target=`echo $target | sed "s/^$target_cpu-/-/"`
+ target_alias=`echo $target_alias | sed "s/^$target_cpu-/-/"`
+ AS_IF([test "${universal_binary-no}" = yes], [
+ AC_SUBST(try_header,try_compile)
+ target_cpu=universal
+ real_cross_compiling=$cross_compiling
+ ], [
+ AS_IF([test x"$target_cpu" != x"${target_archs}"], [
+ echo 'int main(){return 0;}' > conftest.c
+ AS_IF([$CC $CFLAGS $ARCH_FLAG -o conftest conftest.c > /dev/null 2>&1], [
+ rm -fr conftest.*
+ ], [
+ RUBY_DEFAULT_ARCH("$target_archs")
+ ])
+ ])
+ target_cpu=${target_archs}
+ ])
+ AS_CASE(["$target"], [-*], [ target="$target_cpu${target}"])
+ AS_CASE(["$target_alias"], [-*], [ target_alias="$target_cpu${target_alias}"])
+], [
+ AS_IF([test x"$target_alias" = x], [
+ AS_CASE(["$target_os"],
+ [darwin*], [
+ AC_MSG_CHECKING([for real target cpu])
+ target=`echo $target | sed "s/^$target_cpu-/-/"`
+ target_cpu=`$CC -E - 2>/dev/null <<EOF |
+#ifdef __x86_64__
+"processor-name=x86_64"
+#endif
+#ifdef __i386__
+"processor-name=i386"
+#endif
+#ifdef __ppc__
+"processor-name=powerpc"
+#endif
+#ifdef __ppc64__
+"processor-name=powerpc64"
+#endif
+EOF
+ sed -n 's/^"processor-name=\(.*\)"/\1/p'`
+ target="$target_cpu${target}"
+ AC_MSG_RESULT([$target_cpu])
+ ])
+ ])
+ target_archs="$target_cpu"
+])
+AS_IF([test "${target_archs}" != "${rb_cv_target_archs-${target_archs}}"], [
+ AC_MSG_ERROR([target arch(s) has changed from ${rb_cv_target_archs-nothing} to ${target_archs}])
+], [
+ rb_cv_target_archs=${target_archs}
+])
+AS_IF([test "x${ARCH_FLAG}" != x], [
+ CFLAGS="${CFLAGS:+$CFLAGS }${ARCH_FLAG}"
+ LDFLAGS="${LDFLAGS:+$LDFLAGS }${ARCH_FLAG}"
+])
+# RUBY_UNIVERSAL_ARCH end
+])
+
AC_ARG_ENABLE(load-relative,
AS_HELP_STRING([--enable-load-relative], [resolve load paths at run time]),
[load_relative=$enableval])
AC_ARG_PROGRAM
-# checks for UNIX variants that set C preprocessor variables
-AC_USE_SYSTEM_EXTENSIONS
-
dnl Checks for programs.
cflagspat=
@@ -160,18 +345,18 @@ test -z "$optflags" ||
cflagspat="$cflagspat;s|"`eval echo '"'"${optflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/ *$/ /'`'| |g'
test -z "$debugflags" ||
cflagspat="$cflagspat;s|"`eval echo '"'"${debugflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/ *$/ /'`'| |g'
-test -z "$warnflags" ||
+test -z "warnflags" ||
cflagspat="$cflagspat;s|"`eval echo '"'"${warnflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/ *$/ /'`'| |g'
AS_IF([test -z "${CFLAGS+set}"], [
cflags=`echo " $cflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
orig_cflags="$cflags"
cflags="$cflags "'${optflags} ${debugflags} ${warnflags}'
])
-dnl AS_IF([test -z "${CXXFLAGS+set}"], [
-dnl cxxflags=`echo " $cxxflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
-dnl orig_cxxflags="$cxxflags"
-dnl cxxflags="$cxxflags "'${optflags} ${debugflags} ${warnflags}'
-dnl ])
+AS_IF([test -z "${CXXFLAGS+set}"], [
+ cxxflags=`echo " $cxxflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
+ orig_cxxflags="$cxxflags"
+ cxxflags="$cxxflags "'${optflags} ${debugflags} ${warnflags}'
+])
AS_CASE(["$host_os:$build_os"],
[darwin*:darwin*], [
@@ -180,68 +365,32 @@ AS_CASE(["$host_os:$build_os"],
# clang version 1.0 (http://llvm.org/svn/llvm-project/cfe/tags/Apple/clang-23 exported)
# Apple clang version 2.0 (tags/Apple/clang-137) (based on LLVM 2.9svn)
# Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
- AC_PREPROC_IFELSE(
- [AC_LANG_PROGRAM([
- @%:@if defined __APPLE_CC__ && defined __clang_major__ && __clang_major__ < 3
- @%:@error premature clang
- @%:@endif
- ])],
- [],
- [AC_MSG_ERROR([clang version 3.0 or later is required])
- ])],
-[openbsd*:openbsd*], [
- AC_CHECK_TOOLS(CC, [cc])
+ AS_IF([! $CC -E -xc - <<SRC >/dev/null], [
+ @%:@if defined __APPLE_CC__ && defined __clang_major__ && __clang_major__ < 3
+ @%:@error premature clang
+ @%:@endif
+SRC
+ AC_MSG_ERROR([clang version 3.0 or later is required])
+ ])
])
AS_IF([test x"${build}" != x"${host}"], [
AC_CHECK_TOOL(CC, gcc)
])
-dnl Seems necessarily in order to add -std=gnu99 option for gcc 4.9.
-m4_version_prereq([2.70], [], [AC_PROG_CC_C99])
-
-AS_CASE([$CC],
-[gcc-*], [
- gcc_prefix=gcc- gcc_suffix=`echo "$CC" | sed 's/^gcc//'`
- AC_PROG_CXX(g++${gcc_suffix})],
-[clang-*|clang], [
- gcc_prefix=clang- gcc_suffix=`echo "$CC" | sed 's/^clang//'`
- AC_PROG_CXX(clang++${gcc_suffix})],
-[gcc_prefix= gcc_suffix=])
+AC_PROG_CC
dnl Select the appropriate C++ compiler in OS X
-AS_CASE(["$build_os:${CXX}"],
- [darwin1*.*:], [
- AC_MSG_CHECKING([CXX for $CC])
- AS_CASE(["/$CC "],
- [*@<:@\ /@:>@"gcc-4.2 "*], [pat='gcc-4\.2' CXX=g++-4.2],
- [*@<:@\ /@:>@"gcc "*], [pat=gcc CXX=g++],
- [*@<:@\ /@:>@"cc "*], [pat=cc CXX=c++],
- [*@<:@\ /@:>@"icc "*], [pat=icc CXX=icpc],
- [*@<:@\ /@:>@"clang "*], [pat=clang CXX=clang++])
- AS_IF([test "${CXX}"], [
- CXX=`echo "/$CC " | sed ["s:\([ /]\)${pat}:\1$CXX:; s:^/::; s: *$::"]`
- ])
- AC_MSG_RESULT([$CXX])],
- [openbsd*:*], [
- AC_CHECK_TOOLS(CXX, [c++])
- ])
+AS_CASE(["$build_os"],
+ [darwin1*.*], [
+ AS_CASE(["x$CC"],
+ [xgcc-4.2|x/usr/bin/gcc-4.2], [: ${CXX=g++-4.2}],
+ [xgcc|x/usr/bin/gcc], [: ${CXX=g++}],
+ [xcc|x/usr/bin/cc], [: ${CXX=c++}],
+ [xicc], [: ${CXX=icpc}],
+ [xclang|x/usr/bin/clang], [: ${CXX=clang++}])
+ ])
test -z "$CXX" || ac_cv_prog_CXX="$CXX"
-AS_CASE(["$target_os"],
-[darwin*], [
- AC_MSG_CHECKING(if minimum required OS X version is supported)
- AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <AvailabilityMacros.h>
- @%:@if MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5
- @%:@error pre OS X 10.5
- [!<===== pre OS X 10.5 =====>]
- @%:@endif
- ]])],
- [macosx_min_required=yes],
- [AC_MSG_RESULT(no)
- AC_MSG_ERROR([Unsupported OS X version is required])])
- AC_MSG_RESULT(${macosx_min_required})
-])
-
AC_PROG_CXX
RUBY_MINGW32
AC_PROG_GCC_TRADITIONAL
@@ -257,17 +406,15 @@ AS_IF([test "$GCC" = yes], [
gcc_minor=`echo =__GNUC_MINOR__ | $CC -E -xc - | sed '/^=/!d;s///'`
test -n "$gcc_major" || gcc_major=0
test -n "$gcc_minor" || gcc_minor=0
- icc_version=`echo =__ICC | $CC -E -xc - | sed '/^=/!d;s///;/^__ICC/d'`
+ AS_CASE(["x$CC"], [xicc], [
+ icc_version=`echo =__ICC | $CC -E -xc - | sed '/^=/!d;s///'`
+ ])
test -n "$icc_version" || icc_version=0
# RUBY_APPEND_OPTIONS(XCFLAGS, ["-include ruby/config.h" "-include ruby/missing.h"])
], [
linker_flag=
])
-AS_IF([test "$GCC" = yes -a "$gcc_major" -lt 3 ], [
- AC_MSG_ERROR([too old GCC])
-])
-
RUBY_PROG_GNU_LD
RUBY_CPPOUTFILE
@@ -278,29 +425,6 @@ AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG)
AC_SUBST(CSRCFLAG)
-: ${MJIT_CC=$CC}
-AS_IF([test "x$cross_compiling" = xno], [
- AC_PATH_PROG([MJIT_CC], ${MJIT_CC})
- AS_CASE([$target_os],
- [*mingw*], [command -v cygpath > /dev/null && MJIT_CC=`cygpath -ma $MJIT_CC`])
- shift 2
- MJIT_CC="$MJIT_CC${1+ }$*"
-])
-
-AS_CASE(["$build_os"],
- [darwin1*.*], [
- # Xcode linker warns for deprecated architecture and wrongly
- # installed TBD files.
- CC_WRAPPER=""
- echo 'int main(void) {return 0;}' > conftest.c
- AS_IF([$CC -framework Foundation -o conftest conftest.c 2>&1 |
- grep '^ld: warning: text-based stub file' >/dev/null], [
- CC_WRAPPER=`cd -P "$srcdir/tool" && pwd`/darwin-cc
- CC="$CC_WRAPPER $CC"
- ])
- rm -fr conftest*
- ])
-
cc_version=
for option in --version -v -V -qversion; do
cc_version_message=`$CC $option 2>&1`
@@ -313,17 +437,33 @@ done
AC_SUBST(CC_VERSION, $cc_version)
AC_SUBST(CC_VERSION_MESSAGE, $cc_version_message)
-: ${DLDFLAGS="$LDFLAGS"}
-
RUBY_UNIVERSAL_ARCH
-AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "$cross_compiling" = no -a "${universal_binary:-no}" = no], [
+AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "$cross_compiling" = no -a "$universal_binary" = no], [
RUBY_DEFAULT_ARCH("$target_cpu")
])
-host_os=$target_os
-host_vendor=$target_vendor
-host_cpu=$target_cpu
-host=$target
-host_alias=$target_alias
+
+AS_CASE(["$target_cpu-$target_os"], [[i[3-6]86*]], [
+ AC_CACHE_CHECK([for __sync_val_compare_and_swap], [rb_cv_gcc_compiler_cas], [
+ AC_TRY_LINK([unsigned long atomic_var;],
+ [
+ __sync_val_compare_and_swap(&atomic_var, 0, 1);
+ ],
+ [rb_cv_gcc_compiler_cas=yes],
+ [rb_cv_gcc_compiler_cas=no])])
+ AS_IF([test "$rb_cv_gcc_compiler_cas" = no], [
+ unset rb_cv_gcc_compiler_cas
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -march=i486"
+ AC_CACHE_CHECK([for __sync_val_compare_and_swap with -march=i486], [rb_cv_gcc_compiler_cas], [
+ AC_TRY_LINK([unsigned long atomic_var;],
+ [
+ __sync_val_compare_and_swap(&atomic_var, 0, 1);
+ ],
+ [rb_cv_gcc_compiler_cas=yes
+ ARCH_FLAG="-march=i486"],
+ [rb_cv_gcc_compiler_cas=no])])
+ CFLAGS="$save_CFLAGS"
+ ])])
AS_CASE(["$target_os"], [darwin*], [
if libtool 2>&1 | grep no_warning_for_no_symbols > /dev/null; then
@@ -332,8 +472,8 @@ if libtool 2>&1 | grep no_warning_for_no_symbols > /dev/null; then
rb_cv_arflags='-no_warning_for_no_symbols -o'
fi
])
-AC_CHECK_TOOLS(RANLIB, [${gcc_prefix}ranlib${gcc_suffix} ranlib], :)
-AC_CHECK_TOOLS(AR, [${gcc_prefix}ar${gcc_suffix} ar])
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(AR, ar)
AS_IF([test -z "$AR"], [
AC_CHECK_PROGS(AR, aal, ar)
])
@@ -366,8 +506,8 @@ AS_CASE(["$target_os"],
[mingw*], [
test "$rb_cv_msvcrt" = "" && unset rb_cv_msvcrt
AC_CACHE_CHECK(for mingw32 runtime DLL, rb_cv_msvcrt, [
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]],
- [[FILE* volatile f = stdin; return 0;]])],
+ AC_TRY_LINK([@%:@include <stdio.h>],
+ [FILE* volatile f = stdin; return 0;],
[rb_cv_msvcrt=`$OBJDUMP -p conftest$ac_exeext |
tr A-Z a-z |
sed -n '/^[[ ]]*dll name: \(msvc.*\)\.dll$/{s//\1/p;q;}'`],
@@ -382,7 +522,7 @@ AS_CASE(["$target_os"],
],
[aix*], [AC_CHECK_TOOL(NM, nm, /usr/ccs/bin/nm, /usr/ccs/bin:$PATH)],
[hiuxmpp*], [AC_DEFINE(__HIUX_MPP__)]) # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
-AC_CHECK_TOOLS(NM, [${gcc_prefix}nm${gcc_suffix} nm])
+AC_CHECK_TOOL(NM, nm)
AC_PROG_LN_S
AC_PROG_MAKE_SET
@@ -399,6 +539,56 @@ AS_IF([test "x$MKDIR_P" = "x -d"], [
MAKEDIRS="$MKDIR_P"
AC_SUBST(MAKEDIRS)
+AC_DEFUN([RUBY_DTRACE_AVAILABLE],
+[AC_CACHE_CHECK(whether dtrace USDT is available, rb_cv_dtrace_available,
+[
+ echo "provider conftest{ probe fire(); };" > conftest_provider.d
+ rb_cv_dtrace_available=no
+ AS_FOR(opt, rb_dtrace_opt, ["-xnolibs" ""], [dnl
+ AS_IF([$DTRACE opt -h -o conftest_provider.h -s conftest_provider.d >/dev/null 2>/dev/null],
+ [], [continue])
+ AC_TRY_COMPILE([@%:@include "conftest_provider.h"], [CONFTEST_FIRE();],
+ [], [continue])
+ # DTrace is available on the system
+ rb_cv_dtrace_available=yes${rb_dtrace_opt:+"(opt)"}
+ break
+ ])
+ rm -f conftest.[co] conftest_provider.[dho]
+])
+AS_CASE(["$rb_cv_dtrace_available"], ["yes("*")"],
+ [DTRACE_OPT=`expr "$rb_cv_dtrace_available" : "yes(\(.*\))"`])
+])
+
+AC_DEFUN([RUBY_DTRACE_POSTPROCESS],
+[AC_CACHE_CHECK(whether $DTRACE needs post processing, rb_cv_prog_dtrace_g,
+[
+ rb_cv_prog_dtrace_g=no
+ AS_IF([{
+ cat >conftest_provider.d <<_PROBES &&
+ provider conftest {
+ probe fire();
+ };
+_PROBES
+ $DTRACE ${DTRACE_OPT} -h -o conftest_provider.h -s conftest_provider.d >/dev/null 2>/dev/null &&
+ :
+ }], [
+ AC_TRY_COMPILE([@%:@include "conftest_provider.h"], [CONFTEST_FIRE();], [
+ AS_IF([{
+ cp -p conftest.${ac_objext} conftest.${ac_objext}.save &&
+ $DTRACE ${DTRACE_OPT} -G -s conftest_provider.d conftest.${ac_objext} 2>/dev/null &&
+ :
+ }], [
+ AS_IF([cmp -s conftest.o conftest.${ac_objext}.save], [
+ rb_cv_prog_dtrace_g=yes
+ ], [
+ rb_cv_prog_dtrace_g=rebuild
+ ])
+ ])])
+ ])
+ rm -f conftest.[co] conftest_provider.[dho]
+])
+])
+
AC_CHECK_PROG([DTRACE], [${ac_tool_prefix}dtrace], [${ac_tool_prefix}dtrace])
AS_IF([test "$cross_compiling:$ac_cv_prog_DTRACE" = no: -a -n "$ac_tool_prefix"], [
AC_CHECK_PROG([DTRACE], [dtrace], [dtrace])
@@ -410,6 +600,9 @@ AC_CHECK_PROGS(DOXYGEN, doxygen)
AC_CHECK_PROG(PKG_CONFIG, pkg-config, [pkg-config], [], [],
[`"$as_dir/$ac_word$ac_exec_ext" --print-errors --version > /dev/null 2>&1 || echo "$as_dir/$ac_word$ac_exec_ext"`])
+# checks for UNIX variants that set C preprocessor variables
+AC_USE_SYSTEM_EXTENSIONS
+
AC_SUBST(RM, ['rm -f'])
AC_SUBST(CP, ['cp'])
RMDIRS='$(top_srcdir)/tool/rmdirs'
@@ -440,19 +633,37 @@ AS_IF([test -f conf$$.dir/src/cdcmd], [
rm -fr conf$$.dir
AC_MSG_RESULT([$CHDIR])
AC_SUBST(CHDIR)
+
}
+{ # compiler section
+
+AC_DEFUN([RUBY_WERROR_FLAG], [dnl
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $rb_cv_warnflags"
+AS_IF([test "${ac_c_werror_flag+set}"], [
+ rb_c_werror_flag="$ac_c_werror_flag"
+], [
+ unset rb_c_werror_flag
+])
+ac_c_werror_flag=yes
+$1
+CFLAGS="$save_CFLAGS"
+save_CFLAGS=
+AS_IF([test "${rb_c_werror_flag+set}"], [
+ ac_c_werror_flag="$rb_c_werror_flag"
+], [
+ unset ac_c_werror_flag
+])])
-: "compiler section" && {
RUBY_WERROR_FLAG([
AC_MSG_CHECKING([whether CFLAGS is valid])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ AC_TRY_COMPILE([], [],
[AC_MSG_RESULT(yes)],
[
AC_MSG_RESULT(no)
AC_MSG_ERROR([something wrong with CFLAGS="$CFLAGS"])
]
)
-
AC_MSG_CHECKING([whether LDFLAGS is valid])
{
mkdir tmp.$$.try_link &&
@@ -461,7 +672,7 @@ RUBY_WERROR_FLAG([
echo '<?xml?><plist><dict><key>CFBundleIdentifier</key><string></string></dict></plist>' > Info.plist &&
:
} || AC_MSG_ERROR([failed to make temporary directory])
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ AC_TRY_LINK([], [],
[AC_MSG_RESULT(yes)],
[
cd .. && rm -fr tmp.$$.try_link
@@ -472,6 +683,34 @@ RUBY_WERROR_FLAG([
cd .. && rm -fr tmp.$$.try_link
])
+AC_DEFUN([RUBY_TRY_CFLAGS], [
+ AC_MSG_CHECKING([whether ]$1[ is accepted as CFLAGS])
+ RUBY_WERROR_FLAG([
+ CFLAGS="[$]CFLAGS $1"
+ AC_TRY_COMPILE([$4], [$5],
+ [$2
+ AC_MSG_RESULT(yes)],
+ [$3
+ AC_MSG_RESULT(no)])
+ ])
+])
+
+AC_DEFUN([RUBY_TRY_LDFLAGS], [
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="[$]LDFLAGS $1"
+ AC_MSG_CHECKING([whether $1 is accepted as LDFLAGS])
+ RUBY_WERROR_FLAG([
+ AC_TRY_LINK([$4], [$5],
+ [$2
+ AC_MSG_RESULT(yes)],
+ [$3
+ AC_MSG_RESULT(no)])
+ ])
+ LDFLAGS="$save_LDFLAGS"
+ save_LDFLAGS=
+])
+
+: ${DLDFLAGS="$LDFLAGS"}
: ${RPATHFLAG=''}
rpathflag=''
AS_IF([test x"${RPATHFLAG}" = x], [
@@ -501,46 +740,43 @@ AC_ARG_ENABLE(werror,
[particular_werror_flags=$enableval])
rb_cv_warnflags="$warnflags"
-AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
-[yes::*|yes:*:set:], [# GCC && (!warnflags || extra_warnflags)
+AS_IF([test "$GCC:${warnflags+set}:no" = yes::no], [
AS_IF([test $gcc_major -ge 4], [
- extra_warnflags="$extra_warnflags -Werror=extra-tokens"
+ extra_warning=-Werror=extra-tokens
+ ], [
+ extra_warning=
])
AS_IF([test $gcc_major -ge 5 -a $gcc_major -le 6], [
- extra_warnflags="$extra_warnflags -Wno-maybe-uninitialized"
+ extra_warning="$extra_warning -Wno-maybe-uninitialized"
])
# ICC doesn't support -Werror=
AS_IF([test $icc_version -gt 0], [
particular_werror_flags=no
])
- for wflag in \
- -Werror=deprecated-declarations \
- -Werror=division-by-zero \
- -Werror=duplicated-cond \
- -Werror=implicit-function-declaration \
+ for wflag in -Wno-unused-parameter -Wno-parentheses -Wno-long-long \
+ -diag-disable=175,188,2259 \
+ -Wno-missing-field-initializers \
+ -Wno-tautological-compare \
+ -Wno-parentheses-equality \
+ -Wno-constant-logical-operand \
+ -Wno-self-assign \
+ -Wunused-variable \
-Werror=implicit-int \
- -Werror=misleading-indentation \
-Werror=pointer-arith \
- -Werror=shorten-64-to-32 \
-Werror=write-strings \
- -Wimplicit-fallthrough=0 \
- -Wmissing-noreturn \
- -Wno-cast-function-type \
- -Wno-constant-logical-operand \
- -Wno-long-long \
- -Wno-missing-field-initializers \
- -Wno-overlength-strings \
+ -Werror=declaration-after-statement \
+ -Werror=shorten-64-to-32 \
+ -Werror=implicit-function-declaration \
+ -Werror=division-by-zero \
+ -Werror=deprecated-declarations \
+ -Werror=misleading-indentation \
-Wno-packed-bitfield-compat \
- -Wno-parentheses-equality \
- -Wno-self-assign \
- -Wno-tautological-compare \
- -Wno-unused-parameter \
- -Wno-unused-value \
- -Wsuggest-attribute=format \
-Wsuggest-attribute=noreturn \
- -Wunused-variable \
- -diag-disable=175,188,1684,2259,2312 \
- $extra_warnflags \
+ -Wsuggest-attribute=format \
+ -Wimplicit-fallthrough=0 \
+ -Werror=duplicated-cond \
+ -Werror=restrict \
+ $extra_warning \
; do
AS_IF([test "$particular_werror_flags" != yes], [
wflag=`echo x$wflag | sed 's/^x-Werror=/-W/;s/^x//'`
@@ -567,6 +803,20 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
])
RUBY_TRY_CFLAGS(-Qunused-arguments, [RUBY_APPEND_OPTIONS(rb_cv_wsuppress_flags, -Qunused-arguments)])
+for n in infinity nan; do
+ m=AS_TR_CPP($n)
+ AC_CACHE_CHECK([whether $m is available without C99 option], rb_cv_$n,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_BOOL_COMPILE_TRY(AC_INCLUDES_DEFAULT([@%:@include <math.h>
+@%:@ifndef $m
+@%:@error no $m
+@%:@endif
+]), [1])], [eval rb_cv_$n=yes], [eval rb_cv_$n=no])])
+ AS_IF([eval test '"$rb_cv_'$n'"' = yes], [
+ AC_DEFINE_UNQUOTED([HAVE_]$m)
+ ])
+done
+
AC_ARG_WITH(compress-debug-sections,
AS_HELP_STRING([--with-compress-debug-sections=type],
[enable debug section compression]),
@@ -578,21 +828,7 @@ AS_IF([test "$GCC" = yes], [
# argument check. The performance drop is very little and Ubuntu enables
# _FORTIFY_SOURCE=2 by default. So, let's support it for protecting us from
# a mistake of silly C extensions.
-
- # TODO: check if link succeeds with _FORTIFY_SOURCE=2.
- AS_CASE(["$target_os"],
- [mingw*], [
- fortify_source=no
- ])
- AC_ARG_ENABLE(fortify_source,
- AS_HELP_STRING([--disable-fortify-source],
- [disable -D_FORTIFY_SOURCE=2 option, which causes link error on mingw]),
- [fortify_source=$enableval])
- AS_IF([test "x$fortify_source" != xno], [
RUBY_TRY_CFLAGS(-D_FORTIFY_SOURCE=2, [RUBY_APPEND_OPTION(XCFLAGS, -D_FORTIFY_SOURCE=2)])
- ])
-
- : ${MJIT_HEADER_FLAGS='-P -dD'}
# -fstack-protector
AS_CASE(["$target_os"],
@@ -600,18 +836,15 @@ AS_IF([test "$GCC" = yes], [
stack_protector=no
])
AS_IF([test -z "${stack_protector+set}"], [
- AS_FOR(option, opt, [-fstack-protector-strong -fstack-protector], [
- RUBY_TRY_CFLAGS(option, [stack_protector=yes])
- AS_IF([test "x$stack_protector" = xyes], [
- RUBY_TRY_LDFLAGS(option, [], [stack_protector=])
- ])
- AS_IF([test "x$stack_protector" = xyes], [stack_protector=option; break])
+ RUBY_TRY_CFLAGS(-fstack-protector, [stack_protector=yes], [stack_protector=no])
+ AS_IF([test "x$stack_protector" = xyes], [
+ RUBY_TRY_LDFLAGS(-fstack-protector, [], [stack_protector=broken])
])
])
- AS_CASE(["$stack_protector"], [-*], [
- RUBY_APPEND_OPTION(XCFLAGS, $stack_protector)
- RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector)
- RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
+ AS_IF([test "x$stack_protector" = xyes], [
+ RUBY_APPEND_OPTION(XCFLAGS, -fstack-protector)
+ RUBY_APPEND_OPTION(XLDFLAGS, -fstack-protector)
+ RUBY_APPEND_OPTION(LDFLAGS, -fstack-protector)
])
AS_CASE("${compress_debug_sections:-zlib}",
@@ -631,7 +864,7 @@ AS_IF([test "$GCC" = yes], [
# comments. We bypass ANSI C mode for them. Otherwise
# extension libs cannot include those headers.
- # Since math.h in some mingw64 wrongly declares frexp and modf
+ # Since math.h in some mingw64 wrongly delcares frexp and modf
# to be pure, the variables pointed by the second arguments are
# considered uninitialized unexpectedly.
AC_CACHE_CHECK([whether frexp and modf are broken],
@@ -643,13 +876,13 @@ AS_IF([test "$GCC" = yes], [
], [
CFLAGS="$CFLAGS -Werror -Wuninitialized"
])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>
+ AC_TRY_COMPILE([@%:@include <math.h>
int foo(double x)
{
int exp;
frexp(x, &exp);
return exp;
- }]], [[if (foo(0.0)) return 1;]])],
+ }], [if (foo(0.0)) return 1;],
[rb_cv_mingw64_broken_frexp_modf=no],
[rb_cv_mingw64_broken_frexp_modf=yes])
CFLAGS="$save_CFLAGS"
@@ -660,25 +893,9 @@ AS_IF([test "$GCC" = yes], [
],
[cygwin*|darwin*|netbsd*], [
# need lgamma_r(), finite()
- ])
-
- # ANSI (no XCFLAGS because this is C only)
- AS_CASE(["$target_os"],
- [solaris*], [
- # Because "-std=gnu99" affects existence of functions on Solaris,
- # "-std=gnu99" will be appended to CPPFLAGS.
- for ansi_options in -std=gnu99; do
- RUBY_TRY_CFLAGS(${ansi_options}, [
- RUBY_APPEND_OPTIONS(CPPFLAGS, ${ansi_options})
- ], [ansi_options=])
- test "x${ansi_options}" = x || break
- done
],
[
# ANSI (no XCFLAGS because this is C only)
- rb_tmp_std_check=`echo $CC $CFLAGS $optflags $warnflags $debugflags | fgrep std= | tr -d '\015'`
- AS_IF([test "x$rb_tmp_std_check" = "x"],
- [
for ansi_options in -std=gnu99; do
RUBY_TRY_CFLAGS(${ansi_options}, [
RUBY_APPEND_OPTIONS(warnflags, ${ansi_options})
@@ -686,7 +903,6 @@ AS_IF([test "$GCC" = yes], [
], [ansi_options=])
test "x${ansi_options}" = x || break
done
- ])
])
# suppress annoying -Wstrict-overflow warnings
@@ -737,23 +953,6 @@ AS_IF([test "$GCC" = yes], [
done
])
-AS_CASE(["$target_cpu"], [[i[3-6]86*]], [
- AC_CACHE_CHECK([for __sync_val_compare_and_swap], [rb_cv_gcc_compiler_cas], [
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned long atomic_var;]],
- [[__sync_val_compare_and_swap(&atomic_var, 0, 1);]])],
- [rb_cv_gcc_compiler_cas=yes],
- [
- save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -march=i486"
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned long atomic_var;]],
- [[__sync_val_compare_and_swap(&atomic_var, 0, 1);]])],
- [rb_cv_gcc_compiler_cas=i486],
- [rb_cv_gcc_compiler_cas=no])
- CFLAGS="$save_CFLAGS"
- ])
- ])
- AS_IF([test "$rb_cv_gcc_compiler_cas" = i486], [ARCH_FLAG="-march=i486"])
-])
-
AC_ARG_WITH(opt-dir,
AS_HELP_STRING([--with-opt-dir=DIR-LIST],
[add optional headers and libraries directories separated by $PATH_SEPARATOR]),
@@ -768,21 +967,13 @@ AC_ARG_WITH(opt-dir,
test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\""
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
-}
-AC_CACHE_CHECK([whether compiler has statement and declarations in expressions],
- rb_cv_have_stmt_and_decl_in_expr,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[ __extension__ ({ int a = 0; a; }); ]])],
- [rb_cv_have_stmt_and_decl_in_expr=yes],
- [rb_cv_have_stmt_and_decl_in_expr=no])])
-AS_IF([test "$rb_cv_have_stmt_and_decl_in_expr" = yes], [
- AC_DEFINE(HAVE_STMT_AND_DECL_IN_EXPR)
-])
+}
+{ # header and library section
-: "header and library section" && {
AC_ARG_WITH(winnt-ver,
- AS_HELP_STRING([--with-winnt-ver=0xXXXX], [target Windows NT version (default to 0x0600)]),
- [with_winnt_ver="$withval"], [with_winnt_ver="0x0600"])
+ AS_HELP_STRING([--with-winnt-ver=0xXXXX], [target Windows NT version (default to 0x0501)]),
+ [with_winnt_ver="$withval"], [with_winnt_ver="0x0501"])
AS_CASE(["$target_os"],
[mingw*], [
RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver)
@@ -793,12 +984,12 @@ AS_CASE(["$target_os"],
[freebsd*], [
AC_CACHE_CHECK([whether pthread should be enabled by default],
rb_cv_enable_pthread_default,
- [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_CPP([
#include <osreldate.h>
#if __FreeBSD_version < 502102
#error pthread should be disabled on this platform
#endif
- ]])],
+ ],
rb_cv_enable_pthread_default=yes,
rb_cv_enable_pthread_default=no)])
enable_pthread=$rb_cv_enable_pthread_default
@@ -813,31 +1004,36 @@ AS_CASE(["$target_os"],
dnl Checks for libraries.
AS_CASE(["$target_os"],[*bsd*|dragonfly*],[],[ac_cv_func_daemon=no])
-AS_UNSET(ORIG_LIBS)
POSTLINK=:
AC_SUBST(POSTLINK)
AS_CASE(["$target_os"],
[nextstep*], [ ],
[openstep*], [ ],
[rhapsody*], [ ],
-[darwin*], [
- ORIG_LIBS="$LIBS"
- RUBY_PREPEND_OPTION(LIBS, -lobjc)
+[darwin*], [ RUBY_PREPEND_OPTION(LIBS, -lobjc)
RUBY_APPEND_OPTIONS(CPPFLAGS, -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT)
- AC_CACHE_CHECK([whether syscall(2) is deprecated], rb_cv_syscall_deprecated,
- [RUBY_WERROR_FLAG([
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <unistd.h>]],
- [[if (syscall(0)) return 1;]])],
- [rb_cv_syscall_deprecated=no],
- [rb_cv_syscall_deprecated=yes])])])
- AS_IF([test $rb_cv_syscall_deprecated = yes], [
+ AC_MSG_CHECKING(whether Mac OS X 10.5 or later)
+ AC_TRY_CPP([#include <AvailabilityMacros.h>
+ #if MAC_OS_X_VERSION_MAX_ALLOWED <= 1040
+ #error pre OS X 10.4
+ [!<===== pre OS X 10.4 =====>]
+ #endif
+ ],
+ [macosx_10_5=yes], [macosx_10_5=no])
+ AC_MSG_RESULT($macosx_10_5)
+ AS_IF([test "${target_os@%:@darwin}" -ge 16], [
ac_cv_func___syscall=no
ac_cv_func_syscall=no
ac_cv_header_sys_syscall_h=no
ac_cv_header_syscall_h=no
])
- ac_cv_func_getcontext=no
- ac_cv_func_setcontext=no
+ AS_IF([test $macosx_10_5 = yes], [
+ ac_cv_func_getcontext=no
+ ac_cv_func_setcontext=no
+ ], [
+ AC_DEFINE(BROKEN_SETREUID, 1)
+ AC_DEFINE(BROKEN_SETREGID, 1)
+ ])
incs=`$CC -v -E -xc - < /dev/null 2>&1 | sed ['1,/^@%:@include </d;s/^ *//;s|[^./][^/]*/\.\./||g;/\/include$/!d;s||/lib|;/\/usr\/lib/d']`
for d in `$CC -print-search-dirs | sed -e '/^libraries: */!d;s///' | tr : '\012' | fgrep -v /../ | sed -n 's|^\(/.*/lib\)/$|\1|p'`; do
incs=`echo "$incs" | fgrep -v "$d"`
@@ -852,9 +1048,8 @@ AS_CASE(["$target_os"],
AS_IF([test $gcc_major -lt 4 -o \( $gcc_major -eq 4 -a $gcc_minor -lt 3 \)], [
ac_cv_func___builtin_setjmp=no
])
- with_setjmp_type=sigsetjmp # to hijack SIGCHLD handler
AC_CACHE_CHECK(for broken crypt with 8bit chars, rb_cv_broken_crypt,
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_RUN([
#include <stdio.h>
#include <unistd.h>
#include <string.h>
@@ -891,7 +1086,7 @@ main()
}
return 0;
}
-]])],
+],
rb_cv_broken_crypt=no,
rb_cv_broken_crypt=yes,
rb_cv_broken_crypt=yes)])
@@ -920,29 +1115,45 @@ main()
[solaris*], [ LIBS="-lm $LIBS"
ac_cv_func_vfork=no
AC_MSG_CHECKING(whether _XOPEN_SOURCE is already given)
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
- #ifndef _XOPEN_SOURCE
- #error _XOPEN_SOURCE is not defined
- #endif
- ]], [[]])],
- [given_xopen_source=yes], [given_xopen_source=no])
+ AC_TRY_COMPILE([#include <unistd.h>
+ #ifndef _XOPEN_SOURCE
+ #error _XOPEN_SOURCE is not defined
+ #endif
+ ], [],
+ [given_xopen_source=yes], [given_xopen_source=no])
AC_MSG_RESULT($given_xopen_source)
AS_IF([test $given_xopen_source = no], [
+ # On Solaris, with gcc, -std=iso9899:1999 in $ansi_options
+ # is often also needed in CPPFLAGS, because some feature
+ # definitions vary depending on such standards options.
+ AS_CASE(["${ansi_options}"],
+ [*-std=iso9899:1999*], [
+ RUBY_APPEND_OPTIONS(CPPFLAGS, ${ansi_options})
+ ])
AC_MSG_CHECKING(appropriate _XOPEN_SOURCE value to define)
define_xopen_source=""
for tmp_xpg in 7 6 5; do
AS_IF([test x"$define_xopen_source" != x], [
- break
+ break
])
- RUBY_WERROR_FLAG([AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ # Both AC_TRY_CPP and AC_TRY_COMPILE should pass
+ # because some options may not be set to CPPFLAGS.
+ AC_TRY_CPP([
+ #define _XOPEN_SOURCE ${tmp_xpg}00
+ #include <unistd.h>
+ #ifndef _XPG${tmp_xpg}
+ #error _XPG${tmp_xpg} should be defined by _XOPEN_SOURCE=${tmp_xpg}00
+ #endif
+ ], [
+ AC_TRY_COMPILE([
#define _XOPEN_SOURCE ${tmp_xpg}00
#include <unistd.h>
#ifndef _XPG${tmp_xpg}
#error _XPG${tmp_xpg} should be defined by _XOPEN_SOURCE=${tmp_xpg}00
#endif
- ]], [[]])],
+ ], [],
[define_xopen_source=${tmp_xpg}00], [])
- ])
+ ], [])
done
AS_IF([test x"$define_xopen_source" = x], [
define_xopen_source=no
@@ -978,6 +1189,9 @@ main()
ac_cv_func_fsync=yes
ac_cv_func_seekdir=yes
ac_cv_func_telldir=yes
+ ac_cv_func_isinf=yes
+ ac_cv_func_isnan=yes
+ ac_cv_func_finite=yes
ac_cv_func_lchown=yes
ac_cv_func_link=yes
ac_cv_func_readlink=yes
@@ -996,12 +1210,9 @@ main()
ac_cv_func_clock_gettime=yes
ac_cv_func_clock_getres=yes
ac_cv_func_malloc_usable_size=no
- ac_cv_type_off_t=yes
- ac_cv_sizeof_off_t=8
AS_IF([test "$target_cpu" = x64], [
- ac_cv_func___builtin_setjmp=yes
+ ac_cv_func___builtin_setjmp=no
ac_cv_func_round=no
- rb_cv_coroutine=yes
])
ac_cv_func_tgamma=no
rb_cv_negative_time_t=yes
@@ -1028,26 +1239,14 @@ main()
[netbsd*], [ LIBS="-lm $LIBS"
],
[dragonfly*], [ LIBS="-lm $LIBS"
+ # isinf() and isnan() are macros on DragonFly.
+ ac_cv_func_isinf=yes
+ ac_cv_func_isnan=yes
],
[aix*],[ LIBS="-lm $LIBS"
ac_cv_func_round=no
- ac_cv_func___builtin_setjmp=no
- ],
-[linux*],[ LIBS="-lm $LIBS"
- # __builtin_longjmp in ppc64* Linux does not restore
- # the TOC register (r2), which is problematic
- # when a global exit happens from JITted .so code.
- AS_CASE(["$target_cpu"], [powerpc64*], [
- ac_cv_func___builtin_setjmp=no
- ])
- # With gcc-8's -fcf-protection, MJIT's __builtin_longjmp fails.
- AS_CASE(["$CC $CFLAGS "], [*" -fcf-protection "*], [cf_protection=yes], [cf_protection=no])
- AS_IF([test "$cf_protection" = yes], [
- ac_cv_func___builtin_setjmp=no
- ])
],
[ LIBS="-lm $LIBS"])
-: ${ORIG_LIBS=$LIBS}
AC_CHECK_LIB(crypt, crypt) # glibc (GNU/Linux, GNU/Hurd, GNU/kFreeBSD)
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
@@ -1062,7 +1261,6 @@ AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(a.out.h)
AC_CHECK_HEADERS(atomic.h)
-AC_CHECK_HEADERS(copyfile.h)
AC_CHECK_HEADERS(direct.h)
AC_CHECK_HEADERS(grp.h)
AC_CHECK_HEADERS(fcntl.h)
@@ -1078,12 +1276,8 @@ AC_CHECK_HEADERS(malloc_np.h)
AC_CHECK_HEADERS(net/socket.h)
AC_CHECK_HEADERS(process.h)
AC_CHECK_HEADERS(pwd.h)
-AC_CHECK_HEADERS(sanitizer/asan_interface.h)
-AC_CHECK_HEADERS(sanitizer/msan_interface.h)
AC_CHECK_HEADERS(setjmpex.h)
-AC_CHECK_HEADERS(stdalign.h)
AC_CHECK_HEADERS(sys/attr.h)
-AC_CHECK_HEADERS(sys/eventfd.h)
AC_CHECK_HEADERS(sys/fcntl.h)
AC_CHECK_HEADERS(sys/file.h)
AC_CHECK_HEADERS(sys/id.h)
@@ -1120,18 +1314,14 @@ AS_IF([test "x$with_gmp" != xno],
AC_ARG_WITH([jemalloc],
[AS_HELP_STRING([--with-jemalloc],[use jemalloc allocator])],
[with_jemalloc=$withval], [with_jemalloc=no])
-AS_IF([test "x$with_jemalloc" != xno],[
+AS_IF([test "x$with_jemalloc" = xyes],[
AC_SEARCH_LIBS([malloc_conf], [jemalloc],
- [
- AC_DEFINE(HAVE_LIBJEMALLOC, 1)
- with_jemalloc=yes
- ],
- [test x$with_jemalloc = xyes && with_jemalloc=no])
+ [AC_DEFINE(HAVE_LIBJEMALLOC, 1)], [with_jemalloc=no])
AC_CHECK_HEADER(jemalloc/jemalloc.h, [
AC_DEFINE(RUBY_ALTERNATIVE_MALLOC_HEADER, [<jemalloc/jemalloc.h>])
],
[test x$with_jemalloc = xyes && with_jemalloc=no])
- AS_IF([test "x$with_jemalloc" != xyes], [
+ AS_IF([test "x$with_jemalloc" = xno], [
AC_CACHE_CHECK([for jemalloc with JEMALLOC_MANGLE], rb_cv_jemalloc_demangle,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@define JEMALLOC_MANGLE 1
@%:@ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
@@ -1147,13 +1337,11 @@ AS_IF([test "x$with_jemalloc" != xno],[
AC_DEFINE(JEMALLOC_MANGLE)
with_jemalloc=yes
])
- AS_CASE(["$with_jemalloc"],
- [yes],
+ AS_IF([test "x$with_jemalloc" = xyes],
[
AC_DEFINE(HAVE_MALLOC_CONF)
ac_cv_func_malloc_usable_size=yes
],
- [no],
[AC_MSG_ERROR([jemalloc requested but not found])
])
])
@@ -1185,6 +1373,7 @@ mv confdefs1.h confdefs.h
cat largefile.h >> confdefs.h
AS_CASE(["$target_os"],
+ [mingw*], [ac_cv_type_off_t=yes;ac_cv_sizeof_off_t=8],
[aix*], [
AS_CASE(["$target_cpu:$ac_cv_sys_large_files"],
[ppc64:*|powerpc64:*], [],
@@ -1202,7 +1391,6 @@ AC_C_CHAR_UNSIGNED
AC_C_INLINE
AC_C_VOLATILE
AC_C_TYPEOF
-AC_C_RESTRICT
AS_CASE(":$ac_cv_c_const:$ac_cv_c_volatile:",
[*:no:*], [AC_MSG_ERROR(ANSI C-conforming const and volatile are mandatory)])
@@ -1215,6 +1403,114 @@ AC_CACHE_CHECK([char bit], [rb_cv_char_bit],
[AC_INCLUDES_DEFAULT([@%:@include <limits.h>])], [rb_cv_char_bit=8])
test "$universal_binary" = yes && cross_compiling=$real_cross_compiling])
+dnl RUBY_CHECK_SIZEOF [typename], [maybe same size types], [macros], [include]
+AC_DEFUN([RUBY_CHECK_SIZEOF],
+[dnl
+AS_VAR_PUSHDEF([rbcv_var], [rbcv_sizeof_var])dnl
+AS_VAR_PUSHDEF([cond], [rbcv_sizeof_cond])dnl
+AS_VAR_PUSHDEF([t], [rbcv_sizeof_type])dnl
+AS_VAR_PUSHDEF([s], [rbcv_sizeof_size])dnl
+]
+[m4_bmatch([$1], [\.], [], [if test "$universal_binary" = yes; then])
+AC_CACHE_CHECK([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])], [
+ unset AS_TR_SH(ac_cv_sizeof_$1)
+ rbcv_var="
+typedef m4_bpatsubst([$1], [\..*]) ac__type_sizeof_;
+static ac__type_sizeof_ *rbcv_ptr;
+@%:@define AS_TR_CPP(SIZEOF_$1) sizeof((*rbcv_ptr)[]m4_bmatch([$1], [\.], .m4_bpatsubst([$1], [^[^.]*\.])))
+"
+ m4_ifval([$2], [test -z "${AS_TR_SH(ac_cv_sizeof_$1)+set}" && {
+ for t in $2; do
+ AC_COMPILE_IFELSE(
+ [AC_LANG_BOOL_COMPILE_TRY(AC_INCLUDES_DEFAULT([$4]
+ [$rbcv_var]),
+ [AS_TR_CPP(SIZEOF_$1) == sizeof($t)])], [
+ AS_TR_SH(ac_cv_sizeof_$1)=AS_TR_CPP([SIZEOF_]$t)
+ break])
+ done
+ }], [
+ AC_COMPUTE_INT([AS_TR_SH(ac_cv_sizeof_$1)], [AS_TR_CPP(SIZEOF_$1)],
+ [AC_INCLUDES_DEFAULT([$4])
+$rbcv_var],
+ [AS_TR_SH(ac_cv_sizeof_$1)=])
+ ])
+ unset cond
+ m4_ifval([$3], [test -z "${AS_TR_SH(ac_cv_sizeof_$1)+set}" && {
+ for s in 32 64 128; do
+ for t in $3; do
+ cond="${cond}
+@%:@${cond+el}if defined(__${t}${s}__) || defined(__${t}${s}) || defined(_${t}${s}) || defined(${t}${s})"
+ hdr="AC_INCLUDES_DEFAULT([$4
+@%:@if defined(__${t}${s}__) || defined(__${t}${s}) || defined(_${t}${s}) || defined(${t}${s})
+@%:@ define AS_TR_CPP(HAVE_$1) 1
+@%:@else
+@%:@ define AS_TR_CPP(HAVE_$1) 0
+@%:@endif])"
+ AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$hdr], [!AS_TR_CPP(HAVE_$1)])], [continue])
+ AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$hdr]
+ [$rbcv_var],
+ [AS_TR_CPP(HAVE_$1) == (AS_TR_CPP(SIZEOF_$1) == ($s / $rb_cv_char_bit))])],
+ [AS_TR_SH(ac_cv_sizeof_$1)="${AS_TR_SH(ac_cv_sizeof_$1)+${AS_TR_SH(ac_cv_sizeof_$1)-} }${t}${s}"; continue])
+ AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$hdr]
+[
+@%:@if AS_TR_CPP(HAVE_$1)
+$rbcv_var
+@%:@else
+@%:@define AS_TR_CPP(SIZEOF_$1) 0
+@%:@endif
+],
+ [AS_TR_CPP(HAVE_$1) == (AS_TR_CPP(SIZEOF_$1) == (m4_bmatch([$2], [^[0-9][0-9]*$], [$2], [($s / $rb_cv_char_bit)])))])],
+ [AS_TR_SH(ac_cv_sizeof_$1)="${AS_TR_SH(ac_cv_sizeof_$1)+${AS_TR_SH(ac_cv_sizeof_$1)-} }${t}${s}m4_bmatch([$2], [^[0-9][0-9]*$], [:$2])"])
+ done
+ done
+ }])
+ test "${AS_TR_SH(ac_cv_sizeof_$1)@%:@@<:@1-9@:>@}" = "${AS_TR_SH(ac_cv_sizeof_$1)}" &&
+ m4_ifval([$2][$3],
+ [test "${AS_TR_SH(ac_cv_sizeof_$1)@%:@SIZEOF_}" = "${AS_TR_SH(ac_cv_sizeof_$1)}" && ]){
+ test "$universal_binary" = yes && cross_compiling=yes
+ AC_COMPUTE_INT([t], AS_TR_CPP(SIZEOF_$1), [AC_INCLUDES_DEFAULT([$4])]
+[${cond+$cond
+@%:@else}
+$rbcv_var
+${cond+@%:@endif}
+@%:@ifndef AS_TR_CPP(SIZEOF_$1)
+@%:@define AS_TR_CPP(SIZEOF_$1) 0
+@%:@endif], [t=0])
+ test "$universal_binary" = yes && cross_compiling=$real_cross_compiling
+ AS_IF([test ${t-0} != 0], [
+ AS_TR_SH(ac_cv_sizeof_$1)="${AS_TR_SH(ac_cv_sizeof_$1)+${AS_TR_SH(ac_cv_sizeof_$1)-} }${t}"
+ ])
+ }
+ : ${AS_TR_SH(ac_cv_sizeof_$1)=0}
+])
+{
+ unset cond
+ for t in ${AS_TR_SH(ac_cv_sizeof_$1)-}; do
+ AS_CASE(["$t"],
+ [[[0-9]*|SIZEOF_*]], [
+ ${cond+echo "@%:@else"}
+ echo "[@%:@define ]AS_TR_CPP(SIZEOF_$1) $t"
+ break
+ ],
+ [
+ s=`expr $t : ['.*[^0-9]\([0-9][0-9]*\)$']`
+ AS_CASE([$t], [*:*], [t="${t%:*}"], [s=`expr $s / $rb_cv_char_bit`])
+ echo "@%:@${cond+el}if defined(__${t}__) || defined(__${t}) || defined(_${t}) || defined($t)"
+ echo "@%:@define AS_TR_CPP(SIZEOF_$1) $s"
+ cond=1
+ ])
+ done
+ ${cond+echo "@%:@endif"}
+} >> confdefs.h
+m4_bmatch([$1], [\.], [], [else
+AC_CHECK_SIZEOF([$1], 0, [$4])
+fi])
+AS_VAR_POPDEF([rbcv_var])dnl
+AS_VAR_POPDEF([cond])dnl
+AS_VAR_POPDEF([t])dnl
+AS_VAR_POPDEF([s])dnl
+])
+
RUBY_CHECK_SIZEOF(int, [], [ILP])
RUBY_CHECK_SIZEOF(short)
RUBY_CHECK_SIZEOF(long, [int], [ILP LP])
@@ -1234,8 +1530,8 @@ AC_CACHE_CHECK(packed struct attribute, rb_cv_packed_struct,
"__pragma(pack(push, 1)) x __pragma(pack(pop))" \
"x __attribute__((packed))" \
; do
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@define PACKED_STRUCT(x) $mac
- PACKED_STRUCT(struct { int a; });]], [[]])],
+ AC_TRY_COMPILE([@%:@define PACKED_STRUCT(x) $mac
+ PACKED_STRUCT(struct { int a; });], [],
[rb_cv_packed_struct=$mac; break])
done])
AS_IF([test "$rb_cv_packed_struct" != no], [
@@ -1245,18 +1541,102 @@ AS_IF([test "$rb_cv_packed_struct" != no], [
AC_DEFINE_UNQUOTED([PACKED_STRUCT(x)], x)
])
+AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [
+AC_CACHE_CHECK([for printf prefix for $1], [rb_cv_pri_prefix_]AS_TR_SH($1),[
+ [rb_cv_pri_prefix_]AS_TR_SH($1)=[NONE]
+ RUBY_WERROR_FLAG(RUBY_APPEND_OPTIONS(CFLAGS, $rb_cv_wsuppress_flags)
+ for pri in $2; do
+ AC_TRY_COMPILE(
+ [@%:@include <stdio.h>
+ @%:@include <stddef.h>
+ @%:@ifdef __GNUC__
+ @%:@define PRINTF_ARGS(decl, string_index, first_to_check) \
+ decl __attribute__((format(printf, string_index, first_to_check)))
+ @%:@else
+ @%:@define PRINTF_ARGS(decl, string_index, first_to_check) decl
+ @%:@endif
+ PRINTF_ARGS(void test_sprintf(const char*, ...), 1, 2);],
+ [printf("%]${pri}[d", (]$1[)42);
+ test_sprintf("%]${pri}[d", (]$1[)42);],
+ [rb_cv_pri_prefix_]AS_TR_SH($1)[=[$pri]; break])
+ done)])
+AS_IF([test "[$rb_cv_pri_prefix_]AS_TR_SH($1)" != NONE], [
+ AC_DEFINE_UNQUOTED([PRI_]m4_ifval($3,$3,AS_TR_CPP(m4_bpatsubst([$1],[_t$])))[_PREFIX],
+ "[$rb_cv_pri_prefix_]AS_TR_SH($1)")
+])
+])
+
AS_IF([test "x$ac_cv_type_long_long" = xyes], [
RUBY_CHECK_PRINTF_PREFIX(long long, ll I64, LL)
], [test "x$ac_cv_type___int64" = xyes], [
RUBY_CHECK_PRINTF_PREFIX(__int64, ll I64, LL)
])
+dnl RUBY_CHECK_SIGNEDNESS [typename] [if-signed] [if-unsigned] [included]
+AC_DEFUN([RUBY_CHECK_SIGNEDNESS], [dnl
+ AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([$4])], [($1)-1 > 0])],
+ [$3], [$2])])
+
+dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
+AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
+ AC_CHECK_TYPE([$1],
+ [n="patsubst([$1],["],[\\"])"],
+ [n="patsubst([$2],["],[\\"])"],
+ [$4])
+ AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
+ u= t=
+ AS_CASE(["$n "],
+ [*" signed "*], [ ],
+ [*" unsigned "*], [
+ u=U],
+ [RUBY_CHECK_SIGNEDNESS($n, [], [u=U], [$4])])
+ AS_IF([test x"$t" = x], [
+ for t in "long long" long int short; do
+ test -n "$u" && t="unsigned $t"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([$4])]
+ [typedef $n rbcv_conftest_target_type;
+ typedef $t rbcv_conftest_replace_type;
+ extern rbcv_conftest_target_type rbcv_conftest_var;
+ extern rbcv_conftest_replace_type rbcv_conftest_var;
+ extern rbcv_conftest_target_type rbcv_conftest_func(void);
+ extern rbcv_conftest_replace_type rbcv_conftest_func(void);
+ ], [sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type)])],
+ [n="$t"; break])
+ done
+ ])
+ AS_CASE([" $n "],
+ [*" long long "*], [
+ t=LL],
+ [*" long "*], [
+ t=LONG],
+ [
+ t=INT])
+ rb_cv_[$1]_convertible=${u}${t}])
+ AS_IF([test "${AS_TR_SH(ac_cv_type_[$1])}" = "yes"], [
+ n="$1"
+ ], [
+ AS_CASE(["${rb_cv_[$1]_convertible}"],
+ [*LL], [n="long long"],
+ [*LONG], [n="long"],
+ [n="int"])
+ AS_CASE(["${rb_cv_[$1]_convertible}"],
+ [U*], [n="unsigned $n"])
+ ])
+ AS_CASE("${rb_cv_[$1]_convertible}", [U*], [u=+1], [u=-1])
+ AC_DEFINE_UNQUOTED(rb_[$1], $n)
+ AC_DEFINE_UNQUOTED([SIGNEDNESS_OF_]AS_TR_CPP($1), $u)
+ AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)])
+ AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)])
+ AC_DEFINE_UNQUOTED(PRI_[$3]_PREFIX,
+ [PRI_`echo ${rb_cv_[$1]_convertible} | sed ['s/^U//']`_PREFIX])
+])
RUBY_REPLACE_TYPE(pid_t, int, PIDT)
RUBY_REPLACE_TYPE(uid_t, int, UIDT)
RUBY_REPLACE_TYPE(gid_t, int, GIDT)
RUBY_REPLACE_TYPE(time_t, [], TIMET, [@%:@include <time.h>])
RUBY_REPLACE_TYPE(dev_t, [int long "long long"], DEVT)
-RUBY_REPLACE_TYPE(mode_t, ["unsigned short" "unsigned int" long], MODET, [@%:@include <sys/stat.h>])
+RUBY_REPLACE_TYPE(mode_t, ["unsigned int" long], MODET, [@%:@include <sys/stat.h>])
RUBY_REPLACE_TYPE(rlim_t, [int long "long long"], RLIM, [
@%:@ifdef HAVE_SYS_TYPES_H
@%:@include <sys/types.h>
@@ -1267,15 +1647,10 @@ RUBY_REPLACE_TYPE(rlim_t, [int long "long long"], RLIM, [
@%:@include <sys/resource.h>
])
RUBY_REPLACE_TYPE(off_t, [], OFFT)
-RUBY_REPLACE_TYPE(clockid_t, [], CLOCKID, [@%:@ifdef HAVE_TIME_H
-@%:@ include <time.h>
-@%:@endif
-@%:@ifdef HAVE_SYS_TIME_H
-@%:@ include <sys/time.h>
-@%:@endif])
+RUBY_REPLACE_TYPE(clockid_t, [], CLOCKID)
AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
+ [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
rb_cv_have_prototypes=yes,
rb_cv_have_prototypes=no)])
AS_IF([test "$rb_cv_have_prototypes" = yes], [
@@ -1283,8 +1658,8 @@ AS_IF([test "$rb_cv_have_prototypes" = yes], [
])
AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@define paste(a,b) a@%:@@%:@b]],
- [[int xy = 1; return paste(x,y);]])],
+ [AC_TRY_COMPILE([@%:@define paste(a,b) a@%:@@%:@b],
+ [int xy = 1; return paste(x,y);],
rb_cv_tokenpaste=ansi,
rb_cv_tokenpaste=knr)])
AS_IF([test "$rb_cv_tokenpaste" = ansi], [
@@ -1325,11 +1700,11 @@ const char concatenated_literal[[]] = "literals" "to"
[rb_cv_string_literal_concatenation=no])]
)
AS_IF([test "$rb_cv_string_literal_concatenation" = no], [
- AC_MSG_ERROR([No string literal concatenation])
+ AC_DEFINE(NO_STRING_LITERAL_CONCATENATION,1)
])
AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
#include <stdarg.h>
int foo(int x, ...) {
va_list va;
@@ -1339,7 +1714,7 @@ int foo(int x, ...) {
va_arg(va, double);
return 0;
}
-]], [[return foo(10, "", 3.14);]])],
+], [return foo(10, "", 3.14);],
rb_cv_stdarg=yes,
rb_cv_stdarg=no)])
AS_IF([test "$rb_cv_stdarg" = yes], [
@@ -1347,59 +1722,85 @@ AS_IF([test "$rb_cv_stdarg" = yes], [
])
AC_CACHE_CHECK(for variable length macro, rb_cv_va_args_macro,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
int foo(int x, ...);
@%:@define FOO(a, ...) foo(a, @%:@@%:@__VA_ARGS__)
-]], [[FOO(1);FOO(1,2);FOO(1,2,3);]])],
+], [FOO(1);FOO(1,2);FOO(1,2,3);],
rb_cv_va_args_macro=yes,
rb_cv_va_args_macro=no)])
AS_IF([test "$rb_cv_va_args_macro" = yes], [
AC_DEFINE(HAVE_VA_ARGS_MACRO)
])
-AC_CACHE_CHECK([for alignas() syntax], rb_cv_have_alignas, [
-rb_cv_have_alignas=no
+AC_DEFUN([RUBY_DEFINE_IF], [dnl
+ m4_ifval([$1], [AS_LITERAL_IF([$1], [], [test "X$1" = X || ])cat <<EOH >> confdefs.h
+@%:@if $1
+EOH
+])dnl
+AC_DEFINE_UNQUOTED($2, $3)dnl
+ m4_ifval([$1], [AS_LITERAL_IF([$1], [], [test "X$1" = X || ])cat <<EOH >> confdefs.h
+@%:@endif /* $1 */
+EOH
+])dnl
+])dnl
+
+dnl RUBY_DECL_ATTRIBUTE(attrib, macroname, cachevar, condition, type, code)
+AC_DEFUN([RUBY_DECL_ATTRIBUTE], [dnl
+m4_ifval([$2], dnl
+ [AS_VAR_PUSHDEF([attrib], m4_bpatsubst([$2], [(.*)], []))], dnl
+ [AS_VAR_PUSHDEF([attrib], m4_toupper(m4_format(%.4s, [$5]))[_]AS_TR_CPP($1))] dnl
+)dnl
+m4_ifval([$3], dnl
+ [AS_VAR_PUSHDEF([rbcv],[$3])], dnl
+ [AS_VAR_PUSHDEF([rbcv],[rb_cv_]m4_format(%.4s, [$5])[_][$1])]dnl
+)dnl
+m4_pushdef([attrib_code],[m4_bpatsubst([$1],["],[\\"])])dnl
+m4_pushdef([attrib_params],[m4_bpatsubst([$2(x)],[^[^()]*(\([^()]*\)).*],[\1])])dnl
+m4_ifval([$4], [rbcv_cond=["$4"]; test "$rbcv_cond" || unset rbcv_cond])
+AC_CACHE_CHECK(for m4_ifval([$2],[m4_bpatsubst([$2], [(.*)], [])],[$1]) [$5] attribute, rbcv, dnl
+[rbcv=x
RUBY_WERROR_FLAG([
-for attr in \
- "_Alignas(x)" \
- "alignas(x)" \
- "@<:@@<:@alignas(x)@:>@@:>@" \
- "__declspec(aligned(x))" \
- "__attribute__((__aligned__(x)))" \
-;
-do
- # C11 _Alignas and GCC __attribute__((__aligned__)) behave
- # slightly differently. What we want is GCC's. Check that
- # here by something C11 does not allow (`struct ALIGNAS ...`)
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
- [@%:@define ALIGNAS(x) $attr
- struct ALIGNAS(128) conftest_tag { int foo; } foo; ]], [[]])],
- [rb_cv_have_alignas="$attr"; break], [])
+for mac in \
+ "__attribute__ ((attrib_code)) x" \
+ "x __attribute__ ((attrib_code))" \
+ "__declspec(attrib_code) x" \
+ x; do
+ m4_ifval([$4],mac="$mac"${rbcv_cond+" /* only if $rbcv_cond */"})
+ AC_TRY_COMPILE(
+ m4_ifval([$4],${rbcv_cond+[@%:@if ]$rbcv_cond})
+[@%:@define ]attrib[](attrib_params)[ $mac]
+m4_ifval([$4],${rbcv_cond+[@%:@else]}
+${rbcv_cond+[@%:@define ]attrib[](attrib_params)[ x]}
+${rbcv_cond+[@%:@endif]})
+$6
+@%:@define mesg ("")
+ attrib[](attrib_params)[;], [],
+ [rbcv="$mac"; break])
done
])])
-AS_IF([test "$rb_cv_have_alignas" != no], [
- AC_DEFINE_UNQUOTED([RUBY_ALIGNAS(x)], $rb_cv_have_alignas)
+AS_IF([test "$rbcv" != x], [
+ RUBY_DEFINE_IF(m4_ifval([$4],[${rbcv_cond}]), attrib[](attrib_params)[], $rbcv)
+])
+m4_ifval([$4], [unset rbcv_cond]) dnl
+m4_popdef([attrib_params])dnl
+m4_popdef([attrib_code])dnl
+AS_VAR_POPDEF([attrib])dnl
+AS_VAR_POPDEF([rbcv])dnl
])
-AC_CACHE_CHECK([for alignof() syntax], rb_cv_have_alignof,[
-rb_cv_have_alignof=no
-RUBY_WERROR_FLAG([
-for expr in \
- "alignof" \
- "_Alignof" \
- "__alignof" \
- "__alignof__" \
-;
-do
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
- @%:@ifdef HAVE_STDALIGN_H
- @%:@include <stdalign.h>
- @%:@endif]],[[return (int)$expr(int);]])],
- [rb_cv_have_alignof="$expr"; break], [])
-done
-])])
-AS_IF([test "$rb_cv_have_alignof" != no], [
- AC_DEFINE_UNQUOTED(RUBY_ALIGNOF, $rb_cv_have_alignof)
+dnl RUBY_FUNC_ATTRIBUTE(attrib, macroname, cachevar, condition)
+AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
+ RUBY_DECL_ATTRIBUTE([$1], [$2], [$3], [$4],
+ [function], [@%:@define x int conftest_attribute_check(void)]
+ )
+])
+
+dnl RUBY_TYPE_ATTRIBUTE(attrib, macroname, cachevar, condition)
+AC_DEFUN([RUBY_TYPE_ATTRIBUTE], [dnl
+ RUBY_DECL_ATTRIBUTE([$1], [$2], [$3], [$4],
+ [type], [
+@%:@define x struct conftest_attribute_check {int i;}
+])
])
RUBY_FUNC_ATTRIBUTE(__const__, CONSTFUNC)
@@ -1410,9 +1811,6 @@ RUBY_FUNC_ATTRIBUTE(__deprecated__("by "@%:@n), DEPRECATED_BY(n,x), rb_cv_func_d
RUBY_TYPE_ATTRIBUTE(__deprecated__ mesg, DEPRECATED_TYPE(mesg,x), rb_cv_type_deprecated)
RUBY_FUNC_ATTRIBUTE(__noinline__, NOINLINE)
RUBY_FUNC_ATTRIBUTE(__always_inline__, ALWAYS_INLINE)
-RUBY_FUNC_ATTRIBUTE(__no_sanitize__(san), NO_SANITIZE(san, x), rb_cv_func_no_sanitize)
-RUBY_FUNC_ATTRIBUTE(__no_sanitize_address__, NO_SANITIZE_ADDRESS)
-RUBY_FUNC_ATTRIBUTE(__no_address_safety_analysis__, NO_ADDRESS_SAFETY_ANALYSIS)
RUBY_FUNC_ATTRIBUTE(__warn_unused_result__, WARN_UNUSED_RESULT)
RUBY_FUNC_ATTRIBUTE(__unused__, MAYBE_UNUSED)
RUBY_FUNC_ATTRIBUTE(__error__ mesg, ERRORFUNC(mesg,x), rb_cv_func___error__)
@@ -1422,21 +1820,6 @@ AS_IF([test "$rb_cv_func_weak" != x], [
AC_DEFINE(HAVE_FUNC_WEAK)
])
-AC_CACHE_CHECK([for __attribute__((__depreacted__(msg))) in C++],
- rb_cv_CentOS6_CXX_workaround,
- RUBY_WERROR_FLAG([
- AC_LANG_PUSH([C++])
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [],
- [__attribute__((__deprecated__("message"))) int conftest(...);])],
- [rb_cv_CentOS6_CXX_workaround=yes],
- [rb_cv_CentOS6_CXX_workaround=no])
- AC_LANG_POP()]))
-AS_IF([test "$rb_cv_CentOS6_CXX_workaround" != no],[
- AC_DEFINE([RUBY_CXX_DEPRECATED(msg)],
- [__attribute__((__deprecated__(msg)))])])
-
if_i386=${universal_binary+[defined __i386__]}
RUBY_FUNC_ATTRIBUTE(__stdcall__, FUNC_STDCALL, rb_cv_func_stdcall, ${if_i386})
RUBY_FUNC_ATTRIBUTE(__cdecl__, FUNC_CDECL, rb_cv_func_cdecl, ${if_i386})
@@ -1448,8 +1831,8 @@ AS_IF([test "$GCC" = yes], [
AC_CACHE_CHECK([for function alias], [rb_cv_gcc_function_alias],
[rb_cv_gcc_function_alias=no
for a in alias weak,alias; do
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[void foo(void) {}
- void bar(void) __attribute__(($a("foo")));]], [[bar()]])],
+ AC_TRY_LINK([void foo(void) {}
+ void bar(void) __attribute__(($a("foo")));], [bar()],
[rb_cv_gcc_function_alias=$a; break])
done])
AS_IF([test "$rb_cv_gcc_function_alias" != no], [
@@ -1461,14 +1844,14 @@ AS_IF([test "$GCC" = yes], [
])
AC_CACHE_CHECK([for __atomic builtins], [rb_cv_gcc_atomic_builtins], [
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned int atomic_var;]],
- [[
+ AC_TRY_LINK([unsigned char atomic_var;],
+ [
__atomic_exchange_n(&atomic_var, 0, __ATOMIC_SEQ_CST);
__atomic_exchange_n(&atomic_var, 1, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&atomic_var, 1, __ATOMIC_SEQ_CST);
__atomic_fetch_sub(&atomic_var, 1, __ATOMIC_SEQ_CST);
__atomic_or_fetch(&atomic_var, 1, __ATOMIC_SEQ_CST);
- ]])],
+ ],
[rb_cv_gcc_atomic_builtins=yes],
[rb_cv_gcc_atomic_builtins=no])])
AS_IF([test "$rb_cv_gcc_atomic_builtins" = yes], [
@@ -1476,15 +1859,15 @@ AS_IF([test "$GCC" = yes], [
])
AC_CACHE_CHECK([for __sync builtins], [rb_cv_gcc_sync_builtins], [
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[unsigned int atomic_var;]],
- [[
+ AC_TRY_LINK([unsigned char atomic_var;],
+ [
__sync_lock_test_and_set(&atomic_var, 0);
__sync_lock_test_and_set(&atomic_var, 1);
__sync_fetch_and_add(&atomic_var, 1);
__sync_fetch_and_sub(&atomic_var, 1);
__sync_or_and_fetch(&atomic_var, 1);
__sync_val_compare_and_swap(&atomic_var, 0, 1);
- ]])],
+ ],
[rb_cv_gcc_sync_builtins=yes],
[rb_cv_gcc_sync_builtins=no])])
AS_IF([test "$rb_cv_gcc_sync_builtins" = yes], [
@@ -1493,8 +1876,8 @@ AS_IF([test "$GCC" = yes], [
AC_CACHE_CHECK(for __builtin_unreachable, rb_cv_func___builtin_unreachable,
[RUBY_WERROR_FLAG(
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([[volatile int zero;]],
- [[if (zero) __builtin_unreachable();]])],
+ [AC_TRY_LINK([volatile int zero;],
+ [if (zero) __builtin_unreachable();],
[rb_cv_func___builtin_unreachable=yes],
[rb_cv_func___builtin_unreachable=no])
])
@@ -1508,42 +1891,28 @@ AC_CACHE_CHECK(for exported function attribute, rb_cv_func_exported, [
rb_cv_func_exported=no
RUBY_WERROR_FLAG([
for mac in '__attribute__ ((__visibility__("default")))' '__declspec(dllexport)'; do
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@define RUBY_FUNC_EXPORTED $mac extern
- RUBY_FUNC_EXPORTED void conftest_attribute_check(void);]], [[]])],
+ AC_TRY_COMPILE([@%:@define RUBY_FUNC_EXPORTED $mac extern
+ RUBY_FUNC_EXPORTED void conftest_attribute_check(void);], [],
[rb_cv_func_exported="$mac"; break])
done
])])
AS_IF([test "$rb_cv_func_exported" != no], [
AC_DEFINE_UNQUOTED(RUBY_FUNC_EXPORTED, [$rb_cv_func_exported extern])
])
-RUBY_DECL_ATTRIBUTE([__nonnull__(n)], [RUBY_FUNC_NONNULL(n,x)], [rb_cv_func_nonnull],
- [], [function], [
-@%:@define x int conftest_attribute_check(void *p)
-@%:@define n 1
-])
RUBY_APPEND_OPTION(XCFLAGS, -DRUBY_EXPORT)
-AC_ARG_ENABLE(mathn,
- AS_HELP_STRING([--disable-mathn], [disable canonicalization for mathn]),
- [mathn=$enableval], [mathn=yes])
-test "x$mathn" = xyes || mathn=
-AC_SUBST(MATHN, $mathn)
-
AC_CACHE_CHECK(for function name string predefined identifier,
rb_cv_function_name_string,
- [AS_CASE(["$target_os"],[openbsd*],[
- rb_cv_function_name_string=__func__
- ],[
- rb_cv_function_name_string=no
- RUBY_WERROR_FLAG([
- for func in __func__ __FUNCTION__; do
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]],
- [[puts($func);]])],
- [rb_cv_function_name_string=$func
- break])
- done
- ])])]
+ [rb_cv_function_name_string=no
+ RUBY_WERROR_FLAG([
+ for func in __func__ __FUNCTION__; do
+ AC_TRY_LINK([@%:@include <stdio.h>],
+ [puts($func);],
+ [rb_cv_function_name_string=$func
+ break])
+ done
+ ])]
)
AS_IF([test "$rb_cv_function_name_string" != no], [
AC_DEFINE_UNQUOTED(RUBY_FUNCTION_NAME_STRING, [$rb_cv_function_name_string])
@@ -1605,9 +1974,9 @@ RUBY_CHECK_SIZEOF(size_t, [int long void*], [], [@%:@include <sys/types.h>])
RUBY_CHECK_SIZEOF(ptrdiff_t, size_t, [], [@%:@include <stddef.h>])
RUBY_CHECK_PRINTF_PREFIX(size_t, z)
RUBY_CHECK_PRINTF_PREFIX(ptrdiff_t, t)
-AC_CHECK_MEMBERS([struct stat.st_blksize])
-AC_CHECK_MEMBERS([struct stat.st_blocks])
-AC_CHECK_MEMBERS([struct stat.st_rdev])
+AC_STRUCT_ST_BLKSIZE
+AC_STRUCT_ST_BLOCKS
+AC_STRUCT_ST_RDEV
RUBY_CHECK_SIZEOF([struct stat.st_size], [off_t int long "long long"], [], [@%:@include <sys/stat.h>])
AS_IF([test "$ac_cv_member_struct_stat_st_blocks" = yes], [
RUBY_CHECK_SIZEOF([struct stat.st_blocks], [off_t int long "long long"], [], [@%:@include <sys/stat.h>])
@@ -1623,8 +1992,6 @@ AC_CHECK_MEMBERS([struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_ctimespec])
AC_CHECK_MEMBERS([struct stat.st_ctimensec])
AC_CHECK_MEMBERS([struct stat.st_birthtimespec])
-AS_IF([test "x$ac_cv_member_struct_stat_st_birthtimespec" != xyes],
- [AC_CHECK_MEMBERS([struct statx.stx_btime])])
AC_CHECK_TYPES([struct timeval], [], [], [@%:@ifdef HAVE_TIME_H
@%:@include <time.h>
@@ -1665,6 +2032,13 @@ AC_CHECK_TYPES([struct timezone], [], [], [@%:@ifdef HAVE_TIME_H
@%:@ include <sys/time.h>
@%:@endif])
+AC_CHECK_TYPES([clockid_t], [], [], [@%:@ifdef HAVE_TIME_H
+@%:@ include <time.h>
+@%:@endif
+@%:@ifdef HAVE_SYS_TIME_H
+@%:@ include <sys/time.h>
+@%:@endif])
+
AC_CACHE_VAL([rb_cv_large_fd_select],
[AC_CHECK_TYPE(fd_mask, [rb_cv_large_fd_select=yes], [rb_cv_large_fd_select=no], [AC_INCLUDES_DEFAULT([])
@%:@ifdef HAVE_SYS_SELECT_H
@@ -1674,6 +2048,46 @@ AS_IF([test "$rb_cv_large_fd_select" = yes], [
AC_DEFINE(HAVE_RB_FD_INIT, 1)
])
+dnl RUBY_DEFINT TYPENAME, SIZE, [UNSIGNED], [INCLUDES = DEFAULT-INCLUDES]
+AC_DEFUN([RUBY_DEFINT], [dnl
+AS_VAR_PUSHDEF([cond], [rb_defint_cond])dnl
+AS_VAR_PUSHDEF([type], [rb_defint_type])dnl
+AC_CACHE_CHECK([for $1], [rb_cv_type_$1],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])
+typedef $1 t; int s = sizeof(t) == 42;])],
+ [rb_cv_type_$1=yes],
+ [AS_CASE([m4_bmatch([$2], [^[1-9][0-9]*$], $2, [$ac_cv_sizeof_]AS_TR_SH($2))],
+ ["1"], [ rb_cv_type_$1="m4_if([$3], [], [signed ], [$3 ])char"],
+ ["$ac_cv_sizeof_short"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])short"],
+ ["$ac_cv_sizeof_int"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])int"],
+ ["$ac_cv_sizeof_long"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long"],
+ ["$ac_cv_sizeof_long_long"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long long"],
+ ["${ac_cv_sizeof___int64@%:@*:}"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int64"],
+ ["${ac_cv_sizeof___int128@%:@*:}"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int128"],
+ [ rb_cv_type_$1=no])])])
+AS_IF([test "${rb_cv_type_$1}" != no], [
+ type="${rb_cv_type_$1@%:@@%:@unsigned }"
+ AS_IF([test "$type" != yes && eval 'test -n "${ac_cv_sizeof_'$type'+set}"'], [
+ eval cond='"${ac_cv_sizeof_'$type'}"'
+ AS_CASE([$cond], [*:*], [
+ cond=AS_TR_CPP($type)
+ echo "@%:@if defined SIZEOF_"$cond" && SIZEOF_"$cond" > 0" >> confdefs.h
+ ], [cond=])
+ ], [cond=])
+ AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)
+ AS_IF([test "${rb_cv_type_$1}" = yes], [
+ m4_bmatch([$2], [^[1-9][0-9]*$], [AC_CHECK_SIZEOF([$1], 0, [AC_INCLUDES_DEFAULT([$4])])],
+ [RUBY_CHECK_SIZEOF([$1], [$2], [], [AC_INCLUDES_DEFAULT([$4])])])
+ ], [
+ AC_DEFINE_UNQUOTED($1, [$rb_cv_type_$1])
+ AC_DEFINE_UNQUOTED([SIZEOF_]AS_TR_CPP($1), [SIZEOF_]AS_TR_CPP([$type]))
+ ])
+ test -n "$cond" && echo "@%:@endif /* $cond */" >> confdefs.h
+])
+AS_VAR_POPDEF([cond])dnl
+AS_VAR_POPDEF([type])dnl
+])
+
RUBY_DEFINT(int8_t, 1)
RUBY_DEFINT(uint8_t, 1, unsigned)
RUBY_DEFINT(int16_t, 2)
@@ -1686,28 +2100,50 @@ RUBY_DEFINT(int128_t, 16)
RUBY_DEFINT(uint128_t, 16, unsigned)
RUBY_DEFINT(intptr_t, void*)
RUBY_DEFINT(uintptr_t, void*, unsigned)
-AS_IF([test "x$rb_cv_type_intptr_t" != xno], [
- RUBY_CHECK_PRINTF_PREFIX(intptr_t, '' ll I64 l, PTR)
-])
RUBY_DEFINT(ssize_t, size_t, [], [@%:@include <sys/types.h>]) dnl may differ from int, so not use AC_TYPE_SSIZE_T.
-AS_IF([test "x$rb_cv_type_int64_t" != xno], [
- RUBY_CHECK_PRINTF_PREFIX(int64_t, ll I64 l, 64)
-])
AC_CACHE_CHECK(for stack end address, rb_cv_stack_end_address,
[rb_cv_stack_end_address=no
- AC_LINK_IFELSE([AC_LANG_PROGRAM(
- [[extern void *__libc_stack_end;]],
- [[if (!__libc_stack_end) return 1;]])],
+ AC_TRY_LINK(
+ [extern void *__libc_stack_end;],
+ [if (!__libc_stack_end) return 1;],
[rb_cv_stack_end_address="__libc_stack_end"])
])
AS_IF([test $rb_cv_stack_end_address != no], [
AC_DEFINE_UNQUOTED(STACK_END_ADDRESS, $rb_cv_stack_end_address)
])
+# posix_memalign(memptr, alignment, size) implemented for OpenBSD 4.8 doesn't work if alignment > MALLOC_PAGESIZE.
+# [ruby-core:42158] https://bugs.ruby-lang.org/issues/5901
+# OpenBSD 5.2 fixed the problem. (src/lib/libc/stdlib/malloc.c:1.142)
+# MirOS #10semel has the problem but fixed in the repository. (src/lib/libc/stdlib/malloc.c:1.9)
+AS_CASE(["$target_os"],
+[openbsd*|mirbsd*], [
+ AC_CACHE_CHECK(for heap align log on openbsd, rb_cv_page_size_log,
+ [rb_cv_page_size_log=no
+ for page_log in 12 13; do
+ AC_TRY_RUN([
+#include <math.h>
+#include <unistd.h>
+
+int
+main() {
+ if ((int)log2((double)sysconf(_SC_PAGESIZE)) != $page_log) return 1;
+ return 0;
+}
+ ],
+ rb_cv_page_size_log="$page_log"; break)
+ done])
+ AS_IF([test $rb_cv_page_size_log != no], [
+ AC_DEFINE_UNQUOTED(HEAP_ALIGN_LOG, $rb_cv_page_size_log)
+ ], [
+ AC_DEFINE_UNQUOTED(HEAP_ALIGN_LOG, 12)
+ ])
+])
+
dnl Checks for library functions.
AC_TYPE_GETGROUPS
-AC_DEFINE(RETSIGTYPE, void)
+AC_TYPE_SIGNAL
AS_CASE(["${target_cpu}-${target_os}:${target_archs}"],
[powerpc-darwin*], [
AC_LIBSOURCES(alloca.c)
@@ -1727,14 +2163,14 @@ AS_CASE(["${target_cpu}-${target_os}:${target_archs}"],
AS_IF([test "x$ALLOCA" = "x"], [
AC_CACHE_CHECK([for dynamic size alloca], rb_cv_dynamic_alloca, [
for chk in ok __chkstk; do
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ AC_TRY_LINK([
@%:@ifdef HAVE_ALLOCA_H
@%:@include <alloca.h>
@%:@endif
void $chk() {}
int dynamic_alloca_test;
- int dynamic_alloca_result;]],
- [[dynamic_alloca_result = alloca(dynamic_alloca_test) != 0;]])],
+ int dynamic_alloca_result;],
+ [dynamic_alloca_result = alloca(dynamic_alloca_test) != 0;],
[rb_cv_dynamic_alloca=$chk; break])
done])
AS_IF([test "x$rb_cv_dynamic_alloca" = "x__chkstk"], [
@@ -1747,6 +2183,24 @@ AS_IF([test "x$ALLOCA" = "x"], [
])
AC_FUNC_MEMCMP
+# http://sources.redhat.com/ml/libc-hacker/2005-08/msg00008.html
+# Debian GNU/Linux Etch's libc6.1 2.3.6.ds1-13etch5 has this problem.
+# Debian GNU/Linux Lenny's libc6.1 2.7-10 has no problem.
+AC_CACHE_CHECK(for broken erfc of glibc-2.3.6 on IA64, rb_cv_broken_glibc_ia64_erfc,
+ [AC_TRY_RUN([
+#include <math.h>
+int
+main()
+{
+ erfc(10000.0);
+ return 0;
+}
+],
+ rb_cv_broken_glibc_ia64_erfc=no,
+ rb_cv_broken_glibc_ia64_erfc=yes,
+ rb_cv_broken_glibc_ia64_erfc=no)])
+AS_CASE([$rb_cv_broken_glibc_ia64_erfc],[yes],[ac_cv_func_erf=no])
+
AS_CASE(["$target_os"],[freebsd*],[
AC_DEFINE(BROKEN_CLOSE)
AC_REPLACE_FUNCS(close)
@@ -1759,11 +2213,13 @@ AC_REPLACE_FUNCS(dup2)
AC_REPLACE_FUNCS(erf)
AC_REPLACE_FUNCS(explicit_bzero)
AC_REPLACE_FUNCS(ffs)
+AC_REPLACE_FUNCS(finite)
AC_REPLACE_FUNCS(flock)
AC_REPLACE_FUNCS(hypot)
+AC_REPLACE_FUNCS(isinf)
+AC_REPLACE_FUNCS(isnan)
AC_REPLACE_FUNCS(lgamma_r)
AC_REPLACE_FUNCS(memmove)
-AC_REPLACE_FUNCS(nan)
AC_REPLACE_FUNCS(nextafter)
AC_REPLACE_FUNCS(setproctitle)
AC_REPLACE_FUNCS(strchr)
@@ -1773,10 +2229,6 @@ AC_REPLACE_FUNCS(strlcpy)
AC_REPLACE_FUNCS(strstr)
AC_REPLACE_FUNCS(tgamma)
-RUBY_REPLACE_FUNC([finite], [@%:@include <math.h>])
-RUBY_REPLACE_FUNC([isinf], [@%:@include <math.h>])
-RUBY_REPLACE_FUNC([isnan], [@%:@include <math.h>])
-
# for missing/setproctitle.c
AS_CASE(["$target_os"],
[aix* | k*bsd*-gnu | kopensolaris*-gnu | linux* | darwin*], [AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)],
@@ -1786,9 +2238,9 @@ AC_CHECK_HEADERS(sys/pstat.h)
AC_CACHE_CHECK(for signbit, rb_cv_have_signbit,
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_LINK([
#include <math.h>
-]], [[int v = signbit(-0.0);]])],
+], [int v = signbit(-0.0);],
rb_cv_have_signbit=yes,
rb_cv_have_signbit=no)])
AS_IF([test "$rb_cv_have_signbit" = yes], [
@@ -1797,6 +2249,33 @@ AS_IF([test "$rb_cv_have_signbit" = yes], [
AC_LIBOBJ([signbit])
])
+AC_CACHE_CHECK(for broken memmem, rb_cv_broken_memmem, [
+ AC_TRY_RUN([
+@%:@include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ const char *str = "hogefugafoobar";
+ const char *rs = "foo";
+ const char *empty = "";
+ char *p;
+
+ p = memmem(str, strlen(str), rs, strlen(rs));
+ if (p == str+8) {
+ p = memmem(str, strlen(str), empty, strlen(empty));
+ if (p == str)
+ return 0;
+ }
+ return 1;
+}
+ ],
+ rb_cv_broken_memmem=no,
+ rb_cv_broken_memmem=yes,
+ rb_cv_broken_memmem=yes)
+])
+test x"$rb_cv_broken_memmem" = xyes && ac_cv_func_memmem=no
+
AC_FUNC_FORK
AC_CHECK_FUNCS(__syscall)
@@ -1808,7 +2287,6 @@ AC_CHECK_FUNCS(atan2l atan2f)
AC_CHECK_FUNCS(chroot)
AC_CHECK_FUNCS(chsize)
AC_CHECK_FUNCS(clock_gettime)
-AC_CHECK_FUNCS(copy_file_range)
AC_CHECK_FUNCS(cosh)
AC_CHECK_FUNCS(crypt_r)
AC_CHECK_FUNCS(daemon)
@@ -1820,9 +2298,6 @@ AC_CHECK_FUNCS(dup)
AC_CHECK_FUNCS(dup3)
AC_CHECK_FUNCS(eaccess)
AC_CHECK_FUNCS(endgrent)
-AC_CHECK_FUNCS(eventfd)
-AC_CHECK_FUNCS(explicit_memset)
-AC_CHECK_FUNCS(fcopyfile)
AC_CHECK_FUNCS(fchmod)
AC_CHECK_FUNCS(fchown)
AC_CHECK_FUNCS(fcntl)
@@ -1840,16 +2315,10 @@ AC_CHECK_FUNCS(getgidx)
AC_CHECK_FUNCS(getgrnam)
AC_CHECK_FUNCS(getgrnam_r)
AC_CHECK_FUNCS(getgroups)
-AC_CHECK_FUNCS(getlogin)
-AC_CHECK_FUNCS(getlogin_r)
AC_CHECK_FUNCS(getpgid)
AC_CHECK_FUNCS(getpgrp)
AC_CHECK_FUNCS(getpriority)
-AC_CHECK_FUNCS(getpwnam)
AC_CHECK_FUNCS(getpwnam_r)
-AC_CHECK_FUNCS(getpwuid)
-AC_CHECK_FUNCS(getpwuid_r)
-AC_CHECK_FUNCS(getrandom)
AC_CHECK_FUNCS(getresgid)
AC_CHECK_FUNCS(getresuid)
AC_CHECK_FUNCS(getrlimit)
@@ -1857,7 +2326,6 @@ AC_CHECK_FUNCS(getsid)
AC_CHECK_FUNCS(gettimeofday) # for making ac_cv_func_gettimeofday
AC_CHECK_FUNCS(getuidx)
AC_CHECK_FUNCS(gmtime_r)
-AC_CHECK_FUNCS(grantpt)
AC_CHECK_FUNCS(initgroups)
AC_CHECK_FUNCS(ioctl)
AC_CHECK_FUNCS(isfinite)
@@ -1893,7 +2361,6 @@ AC_CHECK_FUNCS(pwrite)
AC_CHECK_FUNCS(qsort_r)
AC_CHECK_FUNCS(qsort_s)
AC_CHECK_FUNCS(readlink)
-AC_CHECK_FUNCS(realpath)
AC_CHECK_FUNCS(round)
AC_CHECK_FUNCS(sched_getaffinity)
AC_CHECK_FUNCS(seekdir)
@@ -1936,15 +2403,12 @@ AC_CHECK_FUNCS(utimes)
AC_CHECK_FUNCS(wait4)
AC_CHECK_FUNCS(waitpid)
-AS_IF([test "x$ac_cv_member_struct_statx_stx_btime" = xyes],
- [AC_CHECK_FUNCS(statx)])
-
-AS_CASE(["$ac_cv_func_memset_s:$ac_cv_func_qsort_s"], [*yes*],
+AS_IF([test "$ac_cv_func_memset_s" = yes],
[RUBY_DEFINE_IF([!defined __STDC_WANT_LIB_EXT1__], [__STDC_WANT_LIB_EXT1__], 1)])
AS_IF([test "$ac_cv_func_getcwd" = yes], [
AC_CACHE_CHECK(if getcwd allocates buffer if NULL is given, [rb_cv_getcwd_malloc],
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_RUN([
@%:@include <stddef.h>
@%:@include <stdio.h>
@%:@ifdef HAVE_UNISTD_H
@@ -1963,7 +2427,7 @@ main(int argc, char **argv)
if (!getcwd(NULL, 0)) return EXIT_FAILURE;
return EXIT_SUCCESS;
}
-]])],
+],
rb_cv_getcwd_malloc=yes,
rb_cv_getcwd_malloc=no,
AS_CASE($target_os,
@@ -1979,8 +2443,15 @@ AS_IF([test "$ac_cv_func_crypt_r:$ac_cv_header_crypt_h" = yes:yes],
[AC_CHECK_MEMBERS([struct crypt_data.initialized], [], [],
[AC_INCLUDES_DEFAULT([@%:@include <crypt.h>])])])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_alloca_with_align, [__builtin_alloca_with_align(1, 4096)])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_assume_aligned, [__builtin_assume_aligned((void*)32, 32)])
+AC_DEFUN([RUBY_CHECK_BUILTIN_FUNC], [dnl
+AC_CACHE_CHECK([for $1], AS_TR_SH(rb_cv_builtin_$1),
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([int foo;], [$2;])],
+ [AS_TR_SH(rb_cv_builtin_$1)=yes],
+ [AS_TR_SH(rb_cv_builtin_$1)=no])])
+AS_IF([test "${AS_TR_SH(rb_cv_builtin_$1)}" != no], [
+ AC_DEFINE(AS_TR_CPP(HAVE_BUILTIN_$1))
+])])
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap16, [__builtin_bswap16(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap32, [__builtin_bswap32(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap64, [__builtin_bswap64(0)])
@@ -2007,25 +2478,24 @@ AS_IF([test x$rb_cv_builtin___builtin_choose_expr = xyes], [
])
])
RUBY_CHECK_BUILTIN_FUNC(__builtin_types_compatible_p, [__builtin_types_compatible_p(int, int)])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_trap, [__builtin_trap()])
AS_IF([test "$ac_cv_func_qsort_r" != no], [
AC_CACHE_CHECK(whether qsort_r is GNU version, rb_cv_gnu_qsort_r,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
@%:@include <stdlib.h>
-void (qsort_r)(void *base, size_t nmemb, size_t size,
+void qsort_r(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *, void *),
void *arg);
-]], [[ ]])],
+],[ ],
[rb_cv_gnu_qsort_r=yes],
[rb_cv_gnu_qsort_r=no])
])
AC_CACHE_CHECK(whether qsort_r is BSD version, rb_cv_bsd_qsort_r,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
@%:@include <stdlib.h>
-void (qsort_r)(void *base, size_t nmemb, size_t size,
+void qsort_r(void *base, size_t nmemb, size_t size,
void *arg, int (*compar)(void *, const void *, const void *));
-]], [[ ]])],
+],[ ],
[rb_cv_bsd_qsort_r=yes],
[rb_cv_bsd_qsort_r=no])
])
@@ -2040,7 +2510,7 @@ void (qsort_r)(void *base, size_t nmemb, size_t size,
AC_CACHE_CHECK(whether atan2 handles Inf as C99, rb_cv_atan2_inf_c99, [
AS_IF([test $ac_cv_func_atan2f:$ac_cv_func_atan2l = yes:yes], [
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ AC_TRY_RUN([
@%:@include <math.h>
@%:@ifdef HAVE_UNISTD_H
@%:@include <unistd.h>
@@ -2058,7 +2528,7 @@ main(int argc, char **argv)
if (fabs(atan2(INFINITY, INFINITY) - M_PI_4) <= 0.01) return EXIT_SUCCESS;
return EXIT_FAILURE;
}
-]])],
+],
[rb_cv_atan2_inf_c99=yes],
[rb_cv_atan2_inf_c99=no],
[AS_CASE($target_os, [mingw*|mswin*], [rb_cv_atan2_inf_c99=no], [rb_cv_atan2_inf_c99=yes])]
@@ -2077,25 +2547,112 @@ AS_IF([test x"$ac_cv_func_clock_gettime" != xyes], [
])
])
AC_CHECK_FUNCS(clock_getres) # clock_getres should be tested after clock_gettime test including librt test.
-AC_CHECK_LIB([rt], [timer_create])
-AC_CHECK_LIB([rt], [timer_settime])
-AS_IF([test x"$ac_cv_lib_rt_timer_create" = xyes], [
- AC_DEFINE(HAVE_TIMER_CREATE, 1)
-])
-AS_IF([test x"$ac_cv_lib_rt_timer_settime" = xyes], [
- AC_DEFINE(HAVE_TIMER_SETTIME, 1)
-])
AC_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
#include <stdlib.h>
-]], [[int v = unsetenv("foo");]])],
+], [int v = unsetenv("foo");],
rb_cv_unsetenv_return_value=yes,
rb_cv_unsetenv_return_value=no)])
AS_IF([test "$rb_cv_unsetenv_return_value" = no], [
AC_DEFINE(VOID_UNSETENV)
])
+# used for AC_ARG_WITH(setjmp-type)
+AC_DEFUN([RUBY_CHECK_SETJMP], [
+AC_CACHE_CHECK([for ]$1[ as a macro or function], ac_cv_func_$1,
+ [AC_TRY_COMPILE([
+@%:@include <setjmp.h>
+]AC_INCLUDES_DEFAULT([$3])[
+@%:@define JMPARGS_1 env
+@%:@define JMPARGS_2 env,1
+@%:@define JMPARGS JMPARGS_]m4_ifval($2,2,1)[
+],
+ m4_ifval($2,$2,jmp_buf)[ env; $1(JMPARGS);],
+ ac_cv_func_$1=yes,
+ ac_cv_func_$1=no)]
+)
+AS_IF([test "$ac_cv_func_]$1[" = yes], [AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)])
+])
+
+AC_DEFUN([RUBY_CHECK_BUILTIN_SETJMP], [
+AS_IF([test x"${ac_cv_func___builtin_setjmp}" = xyes], [
+ unset ac_cv_func___builtin_setjmp
+])
+AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp,
+ [
+ ac_cv_func___builtin_setjmp=no
+ for cast in "" "(void **)"; do
+ RUBY_WERROR_FLAG(
+ [AC_TRY_LINK([@%:@include <setjmp.h>
+ @%:@include <stdio.h>
+ jmp_buf jb;
+ @%:@ifdef NORETURN
+ NORETURN(void t(void));
+ @%:@endif
+ void t(void) {__builtin_longjmp($cast jb, 1);}
+ int jump(void) {(void)(__builtin_setjmp($cast jb) ? 1 : 0); return 0;}],
+ [
+ void (*volatile f)(void) = t;
+ if (!jump()) printf("%d\n", f != 0);
+ ],
+ [ac_cv_func___builtin_setjmp="yes with cast ($cast)"])
+ ])
+ test "$ac_cv_func___builtin_setjmp" = no || break
+ done])
+])
+
+AC_DEFUN([RUBY_SETJMP_TYPE], [
+RUBY_CHECK_BUILTIN_SETJMP
+RUBY_CHECK_SETJMP(_setjmpex, [], [@%:@include <setjmpex.h>])
+RUBY_CHECK_SETJMP(_setjmp)
+RUBY_CHECK_SETJMP(sigsetjmp, [sigjmp_buf])
+AC_MSG_CHECKING(for setjmp type)
+setjmp_suffix=
+unset setjmp_sigmask
+AC_ARG_WITH(setjmp-type,
+ AS_HELP_STRING([--with-setjmp-type], [select setjmp type]),
+ [
+ AS_CASE([$withval],
+ [__builtin_setjmp], [setjmp=__builtin_setjmp],
+ [_setjmp], [ setjmp_prefix=_],
+ [sigsetjmp,*], [ setjmp_prefix=sig setjmp_sigmask=`expr "$withval" : 'sigsetjmp\(,.*\)'`],
+ [sigsetjmp], [ setjmp_prefix=sig],
+ [setjmp], [ setjmp_prefix=],
+ [setjmpex], [ setjmp_prefix= setjmp_suffix=ex],
+ [''], [ unset setjmp_prefix],
+ [ AC_MSG_ERROR(invalid setjmp type: $withval)])], [unset setjmp_prefix])
+setjmp_cast=
+AS_IF([test ${setjmp_prefix+set}], [
+ AS_IF([test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp${setjmp_suffix} = no], [
+ AC_MSG_ERROR(${setjmp_prefix}setjmp${setjmp_suffix} is not available)
+ ])
+], [{ AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]) }], [
+ setjmp_cast=`expr "$ac_cv_func___builtin_setjmp" : "yes with cast (\(.*\))"`
+ setjmp_prefix=__builtin_
+ setjmp_suffix=
+], [test "$ac_cv_header_setjmpex_h:$ac_cv_func__setjmpex" = yes:yes], [
+ setjmp_prefix=
+ setjmp_suffix=ex
+], [test "$ac_cv_func__setjmp" = yes], [
+ setjmp_prefix=_
+ setjmp_suffix=
+], [test "$ac_cv_func_sigsetjmp" = yes], [
+ AS_CASE([$target_os],[solaris*|cygwin*],[setjmp_prefix=],[setjmp_prefix=sig])
+ setjmp_suffix=
+], [
+ setjmp_prefix=
+ setjmp_suffix=
+])
+AS_IF([test x$setjmp_prefix:$setjmp_sigmask = xsig:], [
+ setjmp_sigmask=,0
+])
+AC_MSG_RESULT(${setjmp_prefix}setjmp${setjmp_suffix}${setjmp_cast:+\($setjmp_cast\)}${setjmp_sigmask})
+AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp${setjmp_suffix}($setjmp_cast(env)${setjmp_sigmask})])
+AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp($setjmp_cast(env),val)])
+AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
+AS_IF([test x$setjmp_suffix = xex], [AC_DEFINE_UNQUOTED(RUBY_USE_SETJMPEX, 1)])
+])
# End of setjmp check.
AC_ARG_ENABLE(setreuid,
@@ -2107,21 +2664,21 @@ AS_IF([test "$use_setreuid" = yes], [
])
AC_STRUCT_TIMEZONE
AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
@%:@define _BSD_SOURCE
@%:@define _DEFAULT_SOURCE
@%:@include <time.h>
- ]],
- [[struct tm t; t.tm_gmtoff = 3600;]])],
+ ],
+ [struct tm t; t.tm_gmtoff = 3600;],
[rb_cv_member_struct_tm_tm_gmtoff=yes],
[rb_cv_member_struct_tm_tm_gmtoff=no])])
AS_IF([test "$rb_cv_member_struct_tm_tm_gmtoff" = yes], [
AC_DEFINE(HAVE_STRUCT_TM_TM_GMTOFF)
])
AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
- int i;]],
- [[i = daylight;]])],
+ [AC_TRY_LINK([#include <time.h>
+ int i;],
+ [i = daylight;],
rb_cv_have_daylight=yes,
rb_cv_have_daylight=no)])
AS_IF([test "$rb_cv_have_daylight" = yes], [
@@ -2129,7 +2686,7 @@ AS_IF([test "$rb_cv_have_daylight" = yes], [
])
AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_RUN([
#include <stdlib.h>
#include <time.h>
@@ -2159,7 +2716,7 @@ main()
check(gmtime(&t), 1, 12, 13, 20, 52);
return 0;
}
-]])],
+],
rb_cv_negative_time_t=yes,
rb_cv_negative_time_t=no,
rb_cv_negative_time_t=yes)])
@@ -2170,7 +2727,7 @@ AS_IF([test "$rb_cv_negative_time_t" = yes], [
# [ruby-dev:40910] overflow of time on FreeBSD
# http://www.freebsd.org/cgi/query-pr.cgi?pr=145341
AC_CACHE_CHECK(for localtime(3) overflow correctly, rb_cv_localtime_overflow,
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_RUN([
#include <stdlib.h>
#include <time.h>
@@ -2202,7 +2759,7 @@ main()
check(t);
return 0;
}
-]])],
+],
rb_cv_localtime_overflow=yes,
rb_cv_localtime_overflow=no,
rb_cv_localtime_overflow=no)])
@@ -2215,7 +2772,7 @@ AS_IF([test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = ye
], [
AC_CHECK_FUNCS(sigsetmask)
AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_RUN([
#include <stdio.h>
#include <signal.h>
@@ -2233,7 +2790,7 @@ main()
kill(getpid(), SIGINT);
return 0;
}
-]])],
+],
rb_cv_bsd_signal=yes,
rb_cv_bsd_signal=no,
rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
@@ -2266,6 +2823,21 @@ AS_IF([test x"$ac_cv_func_dirfd" = xno], [
])])
])
+AS_IF([test x"$target_cpu" = xia64], [
+ AC_LIBOBJ([ia64])
+ AC_CACHE_CHECK(for __libc_ia64_register_backing_store_base,
+ rb_cv___libc_ia64_register_backing_store_base,
+ [rb_cv___libc_ia64_register_backing_store_base=no
+ AC_TRY_LINK(
+ [extern unsigned long __libc_ia64_register_backing_store_base;],
+ [unsigned long p = __libc_ia64_register_backing_store_base;
+ printf("%ld\n", p);],
+ [rb_cv___libc_ia64_register_backing_store_base=yes])])
+ AS_IF([test $rb_cv___libc_ia64_register_backing_store_base = yes], [
+ AC_DEFINE(HAVE___LIBC_IA64_REGISTER_BACKING_STORE_BASE)
+ ])
+])
+
AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
[AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([], [(-1==(-1>>1))])],
rb_cv_rshift_sign=yes,
@@ -2276,16 +2848,55 @@ AS_IF([test "$rb_cv_rshift_sign" = yes], [
AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>(int)(y)) : (x)>>(int)(y)))
])
-AS_CASE(["$ac_cv_func_gettimeofday:$ac_cv_func_clock_gettime"],
-[*yes*], [],
-[
- AC_MSG_ERROR(clock_gettime() or gettimeofday() must exist)
+AS_IF([test x"$ac_cv_func_gettimeofday" != xyes], [
+ AC_MSG_ERROR(gettimeofday() must exist)
])
AS_IF([test "$ac_cv_func_sysconf" = yes], [
+ AC_DEFUN([RUBY_CHECK_SYSCONF], [dnl
+ AC_CACHE_CHECK([whether _SC_$1 is supported], rb_cv_have_sc_[]m4_tolower($1),
+ [AC_TRY_COMPILE([#include <unistd.h>
+ ],
+ [_SC_$1 >= 0],
+ rb_cv_have_sc_[]m4_tolower($1)=yes,
+ rb_cv_have_sc_[]m4_tolower($1)=no)
+ ])
+ AS_IF([test "$rb_cv_have_sc_[]m4_tolower($1)" = yes], [
+ AC_DEFINE(HAVE__SC_$1)
+ ])
+ ])
RUBY_CHECK_SYSCONF(CLK_TCK)
])
+AC_DEFUN([RUBY_STACK_GROW_DIRECTION], [
+ AS_VAR_PUSHDEF([stack_grow_dir], [rb_cv_stack_grow_dir_$1])
+ AC_CACHE_CHECK(stack growing direction on $1, stack_grow_dir, [
+AS_CASE(["$1"],
+[m68*|x86*|x64|i?86|ia64|ppc*|sparc*|alpha*], [ $2=-1],
+[hppa*], [ $2=+1],
+[
+ AC_TRY_RUN([
+/* recurse to get rid of inlining */
+static int
+stack_growup_p(addr, n)
+ volatile int *addr, n;
+{
+ volatile int end;
+ if (n > 0)
+ return *addr = stack_growup_p(addr, n - 1);
+ else
+ return (&end > addr);
+}
+int main()
+{
+ int x;
+ return stack_growup_p(&x, 10);
+}
+], $2=-1, $2=+1, $2=0)
+ ])
+eval stack_grow_dir=\$$2])
+eval $2=\$stack_grow_dir
+AS_VAR_POPDEF([stack_grow_dir])])
AS_IF([test "${universal_binary-no}" = yes ], [
archflagpat=`eval echo '"'"${ARCH_FLAG}"'"' | sed 's/[[][|.*]]/\\&/g'`
save_CFLAGS="$CFLAGS" new_cflags=`echo "$CFLAGS" | sed "s|$archflagpat"'||'`
@@ -2317,98 +2928,35 @@ AS_IF([test "${universal_binary-no}" = yes ], [
AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $dir)
])
-AC_ARG_WITH(coroutine,
- AS_HELP_STRING([--with-coroutine=IMPLEMENTATION], [specify the coroutine implementation to use]),
- [rb_cv_coroutine=$withval])
-AS_CASE([$rb_cv_coroutine], [yes|''], [
- AC_MSG_CHECKING(native coroutine implementation for ${target_cpu}-${target_os})
- AS_CASE(["$target_cpu-$target_os"],
- [x*64-darwin*], [
- rb_cv_coroutine=amd64
- ],
- [arm64-darwin*], [
- rb_cv_coroutine=arm64
- ],
- [x*64-linux*], [
- AS_CASE(["$ac_cv_sizeof_voidp"],
- [8], [ rb_cv_coroutine=amd64 ],
- [4], [ rb_cv_coroutine=x86 ],
- [*], [ rb_cv_coroutine= ]
- )
- ],
- [*86-linux*], [
- rb_cv_coroutine=x86
- ],
- [x64-mingw32], [
- rb_cv_coroutine=win64
- ],
- [*86-mingw32], [
- rb_cv_coroutine=win32
- ],
- [armv7*-linux*], [
- rb_cv_coroutine=ucontext
- ],
- [aarch64-linux*], [
- rb_cv_coroutine=arm64
- ],
- [powerpc64le-linux*], [
- rb_cv_coroutine=ppc64le
- ],
- [x86_64-openbsd*], [
- rb_cv_coroutine=amd64
- ],
- [i386-openbsd*], [
- rb_cv_coroutine=x86
- ],
- [*-openbsd*], [
- rb_cv_coroutine=copy
- ],
- [*], [
- rb_cv_coroutine=ucontext
- ]
- )
- AC_MSG_RESULT(${rb_cv_coroutine})
-])
-COROUTINE_H=coroutine/$rb_cv_coroutine/Context.h
-AS_CASE([$rb_cv_coroutine],
- [copy|ucontext], [
- COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.c
- ],
- [*], [
- COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.'$(ASMEXT)'
- ],
-)
-AC_DEFINE_UNQUOTED(COROUTINE_H, ["$COROUTINE_H"])
-AC_SUBST(X_COROUTINE_H, [$COROUTINE_H])
-AC_SUBST(X_COROUTINE_SRC, [$COROUTINE_SRC])
-
AS_IF([test x"$enable_pthread" = xyes], [
for pthread_lib in thr pthread pthreads c c_r root; do
- AC_CHECK_LIB($pthread_lib, pthread_create,
+ AC_CHECK_LIB($pthread_lib, pthread_kill,
rb_with_pthread=yes, rb_with_pthread=no)
- AS_IF([test "$rb_with_pthread" = "yes"], [break])
+ AS_IF([test "$rb_with_pthread" = "yes"], [ break; fi
done
AS_IF([test x"$rb_with_pthread" = xyes], [
AC_DEFINE(_REENTRANT)
AC_DEFINE(_THREAD_SAFE)
AC_DEFINE(HAVE_LIBPTHREAD)
AC_CHECK_HEADERS(pthread_np.h, [], [], [@%:@include <pthread.h>])
- AS_CASE(["$pthread_lib:$target_os"],
- [c:*], [],
- [root:*], [],
- [c_r:*|*:openbsd*|*:mirbsd*], [LIBS="-pthread $LIBS"],
- [LIBS="-l$pthread_lib $LIBS"])
+ AS_CASE([$pthread_lib],
+ [c], [],
+ [root], [],
+ [c_r], [MAINLIBS="-pthread $MAINLIBS"],
+ [AS_CASE(["$target_os"],
+ [openbsd*|mirbsd*], [LIBS="-pthread $LIBS"],
+ [LIBS="-l$pthread_lib $LIBS"])])
], [
AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
])
AC_CACHE_CHECK([whether pthread_t is scalar type], [rb_cv_scalar_pthread_t], [
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ AC_TRY_COMPILE([
@%:@include <pthread.h>
- ]], [[
+ ], [
pthread_t thread_id;
thread_id = 0;
if (!thread_id) return 0;
- ]])],[rb_cv_scalar_pthread_t=yes],[rb_cv_scalar_pthread_t=no])
+ ], [rb_cv_scalar_pthread_t=yes], [rb_cv_scalar_pthread_t=no])
])
AS_IF([test x"$rb_cv_scalar_pthread_t" = xyes], [
: # RUBY_CHECK_SIZEOF(pthread_t, [void* int long], [], [@%:@include <pthread.h>])
@@ -2416,10 +2964,10 @@ AS_IF([test x"$enable_pthread" = xyes], [
AC_DEFINE(NON_SCALAR_THREAD_ID)
])
AC_CHECK_FUNCS(sched_yield pthread_attr_setinheritsched \
- pthread_attr_get_np pthread_attr_getstack pthread_attr_getguardsize \
+ pthread_attr_get_np pthread_attr_getstack pthread_attr_init \
pthread_get_stackaddr_np pthread_get_stacksize_np \
thr_stksegment pthread_stackseg_np pthread_getthrds_np \
- pthread_condattr_setclock \
+ pthread_cond_init pthread_condattr_setclock pthread_condattr_init \
pthread_sigmask pthread_setname_np pthread_set_name_np)
AS_CASE(["$target_os"],[aix*],[ac_cv_func_pthread_getattr_np=no],[AC_CHECK_FUNCS(pthread_getattr_np)])
set_current_thread_name=
@@ -2427,21 +2975,21 @@ AS_IF([test x"$enable_pthread" = xyes], [
AC_CACHE_CHECK([arguments of pthread_setname_np], [rb_cv_func_pthread_setname_np_arguments],
[rb_cv_func_pthread_setname_np_arguments=
# Linux,AIX, (pthread_self(), name)
- # NetBSD (pthread_self(), \"%s\", name)
+ # NetBSD (pthread_self(), name, \"%s\")
# Darwin (name)
for mac in \
"(pthread_self(), name)" \
- "(pthread_self(), \"%s\", name)" \
+ "(pthread_self(), name, \"%s\")" \
"(name)" \
; do
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ AC_TRY_COMPILE([
@%:@include <pthread.h>
@%:@ifdef HAVE_PTHREAD_NP_H
@%:@include <pthread_np.h>
@%:@endif
@%:@define SET_THREAD_NAME(name) pthread_setname_np${mac}
- ]],
- [[if (SET_THREAD_NAME("conftest")) return 1;]])],
+ ],
+ [if (SET_THREAD_NAME("conftest")) return 1;],
[rb_cv_func_pthread_setname_np_arguments="${mac}"
break])
done
@@ -2465,8 +3013,8 @@ AS_IF([test x"$enable_pthread" = xyes], [
AS_IF([test x"$ac_cv_header_ucontext_h" = xno], [
AC_CACHE_CHECK([if signal.h defines ucontext_t], [rb_cv_ucontext_in_signal_h],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <signal.h>]],
- [[size_t size = sizeof(ucontext_t);]])],
+ [AC_TRY_COMPILE([@%:@include <signal.h>],
+ [size_t size = sizeof(ucontext_t);],
[rb_cv_ucontext_in_signal_h=yes], [rb_cv_ucontext_in_signal_h=no])])
AS_IF([test x"$rb_cv_ucontext_in_signal_h" = xyes], [
AC_DEFINE_UNQUOTED(UCONTEXT_IN_SIGNAL_H, 1)
@@ -2474,14 +3022,14 @@ AS_IF([test x"$ac_cv_header_ucontext_h" = xno], [
])
AS_IF([test x"$ac_cv_header_ucontext_h" = xyes -o x"$rb_cv_ucontext_in_signal_h" = xyes], [
AC_CACHE_CHECK([if mcontext_t is a pointer], [rb_cv_mcontext_t_ptr],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
@%:@include <signal.h>
@%:@ifdef HAVE_UCONTEXT_H
@%:@include <ucontext.h>
@%:@endif
mcontext_t test(mcontext_t mc) {return mc+1;}
- ]],
- [[test(0);]])],
+ ],
+ [test(0);],
[rb_cv_mcontext_t_ptr=yes], [rb_cv_mcontext_t_ptr=no])])
AS_IF([test x"$rb_cv_mcontext_t_ptr" = xyes], [
AC_DEFINE_UNQUOTED(DEFINE_MCONTEXT_PTR(mc, uc), mcontext_t mc = (uc)->uc_mcontext)
@@ -2495,7 +3043,7 @@ AS_IF([test x"$ac_cv_header_ucontext_h" = xyes -o x"$rb_cv_ucontext_in_signal_h"
AS_IF([test "$ac_cv_func_fork_works" = "yes" -a "$rb_with_pthread" = "yes"], [
AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_RUN([
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
@@ -2551,15 +3099,17 @@ main(int argc, char *argv[])
}
return EXIT_SUCCESS;
-}]])],
+}],
rb_cv_fork_with_pthread=yes,
rb_cv_fork_with_pthread=no,
rb_cv_fork_with_pthread=yes)])
test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
])
+
+
}
+{ # runtime section
-: "runtime section" && {
dnl wheather use dln_a_out or not
AC_ARG_WITH(dln-a-out,
AS_HELP_STRING([--with-dln-a-out], [use dln_a_out if possible]),
@@ -2574,7 +3124,7 @@ AC_ARG_WITH(dln-a-out,
with_dln_a_out=no])], [with_dln_a_out=no])
AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[
+[AC_TRY_LINK([],[], [
AS_CASE(["`head -1 conftest$EXEEXT | tr -dc '\177ELF' | tr '\177' .`"],
[.ELF*], [rb_cv_binary_elf=yes], [rb_cv_binary_elf=no])],
rb_cv_binary_elf=no)])
@@ -2587,17 +3137,9 @@ AS_IF([test "$rb_cv_binary_elf" = yes], [
AC_CHECK_HEADERS([elf.h elf_abi.h])
AS_IF([test $ac_cv_header_elf_h = yes -o $ac_cv_header_elf_abi_h = yes], [
AC_LIBOBJ([addr2line])
- AS_IF([test "x$compress_debug_sections" = xzlib], [
- AC_CHECK_LIB([z], [uncompress])
- ])
])
])
-AC_CHECK_HEADERS([mach-o/loader.h])
-AS_IF([test "$ac_cv_header_mach_o_loader_h" = yes], [
- AC_LIBOBJ([addr2line])
-])
-
AS_CASE(["$target_os"],
[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu], [
AS_IF([test "$rb_cv_binary_elf" = no], [
@@ -2609,16 +3151,6 @@ LIBEXT=a
AC_SUBST(DLDFLAGS)dnl
AC_SUBST(ARCH_FLAG)dnl
-AC_SUBST(MJIT_HEADER_FLAGS)dnl
-AC_SUBST(MJIT_HEADER_INSTALL_DIR)dnl
-AC_SUBST(MJIT_CC)dnl
-AS_IF([test "$GCC" = "yes"], [
- AS_CASE(["$target_os"],[aix*],[mjit_std_cflag="-std=gnu99"])
-])
-AC_SUBST(MJIT_CFLAGS, [${MJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl
-AC_SUBST(MJIT_OPTFLAGS, [${MJIT_OPTFLAGS-'$(optflags)'}])dnl
-AC_SUBST(MJIT_DEBUGFLAGS, [${MJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
-AC_SUBST(MJIT_LDSHARED)dnl
AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl
@@ -2725,25 +3257,19 @@ AS_IF([test "$with_dln_a_out" != yes], [
])
rb_cv_dlopen=yes],
[darwin*], [ : ${LDSHARED='$(CC) -dynamic -bundle'}
- : ${DLDSHARED='$(CC) -dynamiclib'}
: ${LDFLAGS=""}
- : ${LIBPATHENV=DYLD_FALLBACK_LIBRARY_PATH}
+ : ${LIBPATHENV=DYLD_LIBRARY_PATH}
: ${PRELOADENV=DYLD_INSERT_LIBRARIES}
rb_cv_dlopen=yes],
[aix*], [ : ${LDSHARED='$(CC)'}
- AS_IF([test "$GCC" = yes], [
- LDSHARED="$LDSHARED ${linker_flag}-G -shared"
- ], [
- LDSHARED="$LDSHARED ${linker_flag}-G"
- ])
+ LDSHARED="$LDSHARED ${linker_flag}-G"
EXTDLDFLAGS='-e$(TARGET_ENTRY)'
XLDFLAGS="${linker_flag}"'-bE:$(ARCHFILE)'" ${linker_flag}-brtl"
XLDFLAGS="$XLDFLAGS ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}"
: ${ARCHFILE="ruby.imp"}
- TRY_LINK='$(CC) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
- TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(LOCAL_LIBS) $(LIBS)'
+ TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
+ TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
: ${LIBPATHENV=LIBPATH}
- : ${PRELOADENV=LDR_PRELOAD}
rb_cv_dlopen=yes],
[nto-qnx*], [ DLDFLAGS="$DLDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
: ${LDSHARED='$(LD) -Bshareable -x'}
@@ -2833,7 +3359,6 @@ AS_CASE(["$target_os"],
])
AS_CASE(["$target_cpu-$target_os"],
[*-darwin*], [
- AC_CHECK_HEADERS([libproc.h])
AC_CHECK_HEADERS([execinfo.h])
AS_IF([test "x$ac_cv_header_execinfo_h" = xyes], [
AC_CHECK_LIB([execinfo], [backtrace])
@@ -2849,7 +3374,7 @@ AC_CHECK_FUNCS(backtrace)
AS_IF([test "x$ac_cv_func_backtrace" = xyes], [
AC_CACHE_CHECK(for broken backtrace, rb_cv_broken_backtrace,
- [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ [AC_TRY_RUN([
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -2875,19 +3400,18 @@ main(void)
{
volatile int *a = NULL;
stack_t ss;
- struct sigaction sa;
-
- ss.ss_sp = malloc(16*1024);
+ ss.ss_sp = malloc(SIGSTKSZ);
if (ss.ss_sp == NULL) {
fprintf(stderr, "cannot allocate memory for sigaltstack\n");
return EXIT_FAILURE;
}
- ss.ss_size = 16*1024;
+ ss.ss_size = SIGSTKSZ;
ss.ss_flags = 0;
if (sigaltstack(&ss, NULL) == -1) {
fprintf(stderr, "sigaltstack failed\n");
return EXIT_FAILURE;
}
+ struct sigaction sa;
memset(&sa, 0, sizeof(struct sigaction));
sigemptyset(&sa.sa_mask);
sa.sa_sigaction = sigsegv;
@@ -2897,7 +3421,7 @@ main(void)
a[0] = 1;
return EXIT_SUCCESS;
}
-]])],
+],
rb_cv_broken_backtrace=no,
rb_cv_broken_backtrace=yes,
rb_cv_broken_backtrace=no)])
@@ -2917,10 +3441,11 @@ AS_IF([test "$ac_cv_header_a_out_h" = yes], [
AS_IF([test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown], [
cat confdefs.h > config.h
AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ [AC_TRY_COMPILE([
#define USE_DLN_A_OUT
#include "dln.c"
-]], [[]])],
+],
+ [],
rb_cv_dln_a_out=yes,
rb_cv_dln_a_out=no)])
AS_IF([test "$rb_cv_dln_a_out" = yes], [
@@ -2986,10 +3511,10 @@ AS_CASE(["$target_os"],
STRIP="$STRIP -A -n"])
AC_ARG_WITH(ext,
- AS_HELP_STRING([--with-ext=EXTS],
+ AC_HELP_STRING([--with-ext=EXTS],
[pass to --with-ext option of extmk.rb]))
AC_ARG_WITH(out-ext,
- AS_HELP_STRING([--with-out-ext=EXTS],
+ AC_HELP_STRING([--with-out-ext=EXTS],
[pass to --without-ext option of extmk.rb]))
EXTSTATIC=
AC_SUBST(EXTSTATIC)dnl
@@ -3057,7 +3582,6 @@ for var in bindir libdir rubylibprefix; do
done
BTESTRUBY='$(MINIRUBY)'
-BOOTSTRAPRUBY='$(BASERUBY)'
AS_IF([test x"$cross_compiling" = xyes], [
test x"$MINIRUBY" = x && MINIRUBY="${RUBY-$BASERUBY} -I`$CHDIR .; pwd` "-r'$(arch)-fake'
XRUBY_LIBDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["libdir"]']`
@@ -3070,9 +3594,9 @@ AS_IF([test x"$cross_compiling" = xyes], [
RUNRUBY_COMMAND='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
RUNRUBY='$(RUNRUBY_COMMAND)'
XRUBY='$(MINIRUBY)'
+ BOOTSTRAPRUBY='$(BASERUBY)'
TEST_RUNNABLE=no
CROSS_COMPILING=yes
- AC_DEFINE(CROSS_COMPILING, 1)
], [
MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib -I.'
MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common'
@@ -3080,7 +3604,7 @@ AS_IF([test x"$cross_compiling" = xyes], [
RUNRUBY_COMMAND='$(MINIRUBY) $(srcdir)/tool/runruby.rb --extout=$(EXTOUT) $(RUNRUBYOPT)'
RUNRUBY='$(RUNRUBY_COMMAND) --'
XRUBY='$(RUNRUBY)'
- AS_CASE(["$HAVE_BASERUBY:$build_os"], [no:*|*:mingw*], [BOOTSTRAPRUBY='$(MINIRUBY)'])
+ BOOTSTRAPRUBY='$(MINIRUBY)'
TEST_RUNNABLE=yes
CROSS_COMPILING=no
])
@@ -3095,12 +3619,12 @@ AC_SUBST(XRUBY)
AC_SUBST(BOOTSTRAPRUBY)
AC_SUBST(EXTOUT, [${EXTOUT=.ext}])
-FIRSTMAKEFILE=""
+])RSTMAKEFILE=""
LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
LIBRUBY='$(LIBRUBY_A)'
LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static'
LIBRUBYARG='$(LIBRUBYARG_STATIC)'
-SOLIBS='$(MAINLIBS)'
+SOLIBS=
AS_CASE(["$target_os"],
[cygwin*|mingw*|haiku*|darwin*], [
@@ -3115,9 +3639,6 @@ AC_ARG_ENABLE(multiarch,
[multiarch=], [unset multiarch])
AS_IF([test ${multiarch+set}], [
AC_DEFINE(ENABLE_MULTIARCH)
- MJIT_HEADER_INSTALL_DIR=include/'${arch}/${RUBY_VERSION_NAME}'
-], [
- MJIT_HEADER_INSTALL_DIR=include/'${RUBY_VERSION_NAME}/${arch}'
])
archlibdir='${libdir}/${arch}'
@@ -3131,7 +3652,7 @@ AC_ARG_WITH(soname,
[
AS_CASE(["$target_os"],
[darwin*], [
- RUBY_SO_NAME='$(RUBY_BASE_NAME).$(RUBY_API_VERSION)'
+ RUBY_SO_NAME='$(RUBY_BASE_NAME).$(RUBY_PROGRAM_VERSION)'
],
[cygwin*], [
RUBY_SO_NAME='$(RUBY_BASE_NAME)$(MAJOR)$(MINOR)0'
@@ -3145,7 +3666,7 @@ AC_ARG_WITH(soname,
[RUBY_SO_NAME='$(RUBY_BASE_NAME)'])
])
-LIBRUBY_LDSHARED=${DLDSHARED=${LDSHARED}}
+LIBRUBY_LDSHARED=$LDSHARED
LIBRUBY_DLDFLAGS=$DLDFLAGS
LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(RUBY_PROGRAM_VERSION)'
LIBRUBY_SONAME='lib$(RUBY_SO_NAME).$(SOEXT).$(RUBY_API_VERSION)'
@@ -3164,6 +3685,9 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_RELATIVE=no
test -z "$CCDLFLAGS" || CFLAGS="$CFLAGS $CCDLFLAGS"
ENABLE_SHARED=yes
+ AS_IF([test "$rb_cv_binary_elf" = yes], [
+ SOLIBS='$(LIBS)'
+ ])
# libdir can be overridden in config.site file (on OpenSUSE at least).
libdir_basename=lib
@@ -3198,6 +3722,7 @@ AS_CASE("$enable_shared", [yes], [
])
],
[freebsd*|dragonfly*], [
+ SOLIBS='$(LIBS)'
LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)$(MINOR)'
LIBRUBY_SONAME='$(LIBRUBY_SO)'
AS_IF([test "$rb_cv_binary_elf" != "yes" ], [
@@ -3206,6 +3731,7 @@ AS_CASE("$enable_shared", [yes], [
])
],
[netbsd*], [
+ SOLIBS='$(LIBS)'
LIBRUBY_SONAME='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)$(MINOR)'
LIBRUBY_SO="${LIBRUBY_SONAME}"'.$(TEENY)'
RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ['-Wl,-soname,$(LIBRUBY_SONAME)' "$LDFLAGS_OPTDIR"])
@@ -3216,13 +3742,19 @@ AS_CASE("$enable_shared", [yes], [
])
],
[openbsd*|mirbsd*], [
+ SOLIBS='$(LIBS)'
LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
],
[solaris*], [
+ SOLIBS='$(LIBS)'
LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR)'
LIBRUBY_SONAME='lib$(RUBY_SO_NAME).$(SOEXT).$(RUBY_PROGRAM_VERSION)'
LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)'
- RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ["${linker_flag}-h${linker_flag:+,}"'$(@F)'])
+ AS_IF([test "$GCC" = yes], [
+ LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)'
+ ], [
+ LIBRUBY_DLDFLAGS="$DLDFLAGS "'-h $(@F)'
+ ])
XLDFLAGS="$XLDFLAGS "'-R${libdir}'
],
[hpux*], [
@@ -3232,12 +3764,10 @@ AS_CASE("$enable_shared", [yes], [
[aix*], [
RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ["${linker_flag}-bnoentry" "$XLDFLAGS" "$LDFLAGS_OPTDIR"])
LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
- LIBS="$LIBS -lm -lc"
+ SOLIBS='-lm -lc'
],
[darwin*], [
- LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT)'
- LIBRUBY_SONAME='$(LIBRUBY_SO)'
- LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(SOEXT)'
+ LIBRUBY_LDSHARED='$(CC) -dynamiclib'
AS_IF([test "$load_relative" = yes], [
libprefix="@executable_path/../${libdir_basename}"
LIBRUBY_RELATIVE=yes
@@ -3251,6 +3781,10 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-Wl,-unexported_symbol,*_threadptr_*'
])
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "' $(XLDFLAGS)'
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT)'
+ LIBRUBY_SONAME='lib$(RUBY_BASE_NAME).$(RUBY_API_VERSION).$(SOEXT)'
+ LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_INSTALL_NAME).$(SOEXT)'
+ SOLIBS='$(LIBS)'
],
[interix*], [
LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
@@ -3376,38 +3910,26 @@ AS_IF([test x"$gcov" = xyes], [
RUBY_SETJMP_TYPE
}
+{ # build section
-: "build section" && {
dnl build rdoc index if requested
RDOCTARGET=""
CAPITARGET=""
AC_ARG_ENABLE(install-doc,
AS_HELP_STRING([--disable-install-doc], [do not install either rdoc indexes or C API documents during install]),
[install_doc=$enableval], [install_doc=yes])
-AC_ARG_WITH(rdoc,
- AS_HELP_STRING([--with-rdoc=ri,html], [comma/space separated list of RDoc formats to install]),
- [install_rdoc=`echo ,$withval, | sed 'y/,/ /;s/ ri / rdoc /;s/^ *//;s/ *$//'`], [
AC_ARG_ENABLE(install-rdoc,
AS_HELP_STRING([--disable-install-rdoc], [do not install rdoc indexes during install]),
[install_rdoc=$enableval], [install_rdoc=yes])
-])
AC_ARG_ENABLE(install-capi,
AS_HELP_STRING([--disable-install-capi], [do not install C API documents during install]),
[install_capi=$enableval], [install_capi=no])
AS_IF([test "$install_doc" != no], [
- AS_CASE(["$install_rdoc"],
- [yes], [
+ AS_IF([test "$install_rdoc" != no], [
RDOCTARGET="rdoc"
- ],
- [all], [
- RDOCTARGET="rdoc html"
- ],
- [no|''], [
+ ], [
RDOCTARGET="nodoc"
- ],
- [
- RDOCTARGET="$install_rdoc"
])
AS_IF([test "$install_capi" != no -a -n "$DOXYGEN"], [
CAPITARGET="capi"
@@ -3425,17 +3947,6 @@ AC_SUBST(CAPITARGET)
AS_CASE(["$RDOCTARGET:$CAPITARGET"],[nodoc:nodoc],[INSTALLDOC=nodoc],[INSTALLDOC=all])
AC_SUBST(INSTALLDOC)
-AC_ARG_ENABLE(jit-support,
- AS_HELP_STRING([--disable-jit-support], [disable JIT features]),
- [MJIT_SUPPORT=$enableval
- AS_IF([test x"$enable_jit_support" = "xyes"],
- [AC_DEFINE(USE_MJIT, 1)],
- [AC_DEFINE(USE_MJIT, 0)])],
- [MJIT_SUPPORT=yes
- AC_DEFINE(USE_MJIT, 1)])
-
-AC_SUBST(MJIT_SUPPORT)
-
AC_ARG_ENABLE(install-static-library,
AS_HELP_STRING([--disable-install-static-library], [do not install static ruby library]),
[INSTALL_STATIC_LIBRARY=$enableval],
@@ -3448,7 +3959,7 @@ AS_IF([test "$rb_with_pthread" = "yes"], [
THREAD_MODEL=pthread
])
AC_CACHE_CHECK([for prefix of external symbols], rb_cv_symbol_prefix, [
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern void conftest_external(void) {}]], [[]])],[
+ AC_TRY_COMPILE([extern void conftest_external(void) {}], [], [
rb_cv_symbol_prefix=`$NM conftest.$ac_objext |
sed -n ['/.*T[ ]\([^ ]*\)conftest_external.*/!d;s//\1/p;q']`
],
@@ -3459,7 +3970,7 @@ SYMBOL_PREFIX="$rb_cv_symbol_prefix"
test "x$SYMBOL_PREFIX" = xNONE && SYMBOL_PREFIX=''
DLNOBJ=dln.o
AC_ARG_ENABLE(dln,
- AS_HELP_STRING([--disable-dln], [disable dynamic link feature]),
+ AC_HELP_STRING([--disable-dln], [disable dynamic link feature]),
[test "$enableval" = yes || DLNOBJ=dmydln.o])
AC_SUBST(DLNOBJ)
MINIDLNOBJ=dmydln.o
@@ -3472,14 +3983,6 @@ AS_CASE(["$target_os"],
],
[darwin*], [
RUBY_APPEND_OPTION(CFLAGS, -pipe)
- AC_COMPILE_IFELSE([
- AC_LANG_BOOL_COMPILE_TRY([@%:@include <AvailabilityMacros.h>],
- [MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7])],
- [dnl
- RUBY_APPEND_OPTION(XLDFLAGS, [-framework Security])
- RUBY_APPEND_OPTION(LIBRUBYARG_STATIC, [-framework Security])
- ]dnl
- )
RUBY_APPEND_OPTION(XLDFLAGS, [-framework Foundation])
RUBY_APPEND_OPTION(LIBRUBYARG_STATIC, [-framework Foundation])
],
@@ -3499,7 +4002,7 @@ AS_CASE(["$target_os"],
])
],
[cygwin*|mingw*], [
- LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
+ LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
AS_CASE(["$target_os"],
[cygwin*], [
AS_IF([test x"$enable_shared" = xyes], [
@@ -3524,6 +4027,7 @@ AS_CASE(["$target_os"],
])
LIBRUBY_ALIASES=''
FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
+ SOLIBS='$(LIBS)'
AS_IF([test x"$enable_shared" = xyes], [
LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
], [
@@ -3591,12 +4095,13 @@ AS_IF([test "${universal_binary-no}" = yes ], [
AC_CACHE_CHECK([for architecture macros], rb_cv_architecture_macros, [
mv confdefs.h confdefs1.h
: > confdefs.h
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@if defined __`echo ${universal_archnames} |
+ AC_TRY_COMPILE([@%:@if defined __`echo ${universal_archnames} |
sed 's/=[^ ]*//g;s/ /__ || defined __/g'`__
@%:@else
@%:@error
>>>>>><<<<<<
-@%:@endif]], [[]])],[
+@%:@endif], [],
+[
rb_cv_architecture_macros=yes
mv -f confdefs1.h confdefs.h
], [
@@ -3609,29 +4114,19 @@ AS_IF([test "${universal_binary-no}" = yes ], [
CFLAGS="$new_cflags -arch $archs"
archs="__${archs}__"
AC_MSG_CHECKING([for macro ${archs} on ${cpu}])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@ifndef ${archs}
+ AC_TRY_COMPILE([@%:@ifndef ${archs}
@%:@error
-@%:@endif]], [[]])],
- [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
+@%:@endif], [], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
done
mv -f confdefs1.h confdefs.h
AC_MSG_ERROR([failed])
])])
AC_CACHE_CHECK(whether __ARCHITECTURE__ is available, rb_cv_architecture_available,
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>
- const char arch[[]] = __ARCHITECTURE__;]], [[puts(arch);]])],
+ AC_TRY_COMPILE([@%:@include <stdio.h>
+ const char arch[[]] = __ARCHITECTURE__;], [puts(arch);],
[rb_cv_architecture_available=yes], [rb_cv_architecture_available=no]))
])
-: ${MJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(MJIT_CC)|g']`}
-
-MAINLIBS="$LIBS"
-LIBS=$ORIG_LIBS
-AS_IF([test -n "${LIBS}"], [
- libspat=`echo "${LIBS}" | sed 's/[[][|.*$^]]/\\&/g;s/^ */ /;s/^ *$/ /'`
- MAINFLAGS=`echo " $MAINLIBS " | sed "s|$libspat"'||;s/^ *//;s/ *$//'`
-])
-LIBRUBYARG_STATIC="${LIBRUBYARG_STATIC} \$(MAINLIBS)"
CPPFLAGS="$CPPFLAGS "'$(DEFS)'
test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
AS_IF([test -n "${cflags+set}"], [
@@ -3648,11 +4143,10 @@ AS_IF([test "${ARCH_FLAG}"], [
CXXFLAGS=`echo "$CXXFLAGS" | sed "s| *$archflagpat"'||'`
LDFLAGS=`echo "$LDFLAGS" | sed "s| *$archflagpat"'||'`
])
-rb_cv_warnflags=`echo "$rb_cv_warnflags" | sed 's/^ *//;s/ *$//'`
warnflags="$rb_cv_warnflags"
AC_SUBST(cppflags)dnl
AC_SUBST(cflags, ["${orig_cflags:+$orig_cflags }"'${optflags} ${debugflags} ${warnflags}'])dnl
-AC_SUBST(cxxflags)dnl
+AC_SUBST(cxxflags, ["${orig_cxxflags:+$orig_cxxflags }"'${optflags} ${debugflags} ${warnflags}'])dnl
AC_SUBST(optflags)dnl
AC_SUBST(debugflags)dnl
AC_SUBST(warnflags)dnl
@@ -3677,7 +4171,6 @@ AC_SUBST(LIBRUBYARG_STATIC)
AC_SUBST(LIBRUBYARG_SHARED)
AC_SUBST(SOLIBS)
AC_SUBST(DLDLIBS)
-AC_SUBST(DLDSHARED)
AC_SUBST(ENABLE_SHARED)
AC_SUBST(MAINLIBS)
AC_SUBST(COMMON_LIBS)
@@ -3821,7 +4314,7 @@ AS_IF([test "${universal_binary-no}" = yes ], [
for archs in ${universal_archnames}; do
cpu=`echo $archs | sed 's/.*=//'`
archs=`echo $archs | sed 's/=.*//'`
- RUBY_DEFINE_IF([defined __${archs}__ &&! defined RUBY_PLATFORM_CPU], RUBY_PLATFORM_CPU, ["${cpu}"])
+ RUBY_DEFINE_IF([defined __${archs}__], RUBY_PLATFORM_CPU, ["${cpu}"])
done
])
ints='long int short'
@@ -3829,8 +4322,8 @@ AS_IF([test "${universal_binary-no}" = yes ], [
AC_SUBST(UNIVERSAL_ARCHNAMES, "${universal_archnames}")
AC_SUBST(UNIVERSAL_INTS, "${ints}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM_OS, "${target_os}")
- AC_DEFINE_UNQUOTED(RUBY_ARCH, "universal-" RUBY_PLATFORM_OS)
- AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "universal." RUBY_PLATFORM_CPU "-" RUBY_PLATFORM_OS)
+ AC_DEFINE_UNQUOTED(RUBY_ARCH, "universal-"RUBY_PLATFORM_OS)
+ AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS)
], [
arch="${target_cpu}-${target_os}"
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "$arch")
@@ -3918,9 +4411,10 @@ AC_ARG_ENABLE(rubygems,
AS_HELP_STRING([--disable-rubygems], [disable rubygems by default]),
[enable_rubygems="$enableval"], [enable_rubygems=yes])
AS_IF([test x"$enable_rubygems" = xno], [
- USE_RUBYGEMS=no
+ AC_DEFINE(DISABLE_RUBYGEMS, 1)
+ USE_RUBYGEMS=NO
], [
- USE_RUBYGEMS=yes
+ USE_RUBYGEMS=YES
])
AC_SUBST(USE_RUBYGEMS)
@@ -3937,7 +4431,7 @@ guard=INCLUDE_RUBY_CONFIG_H
(
AS_IF([test "x$CONFIGURE_TTY" = xyes], [color=--color], [color=])
exec ${srcdir}/tool/ifchange $color "${config_h}" -
-) >&AS_MESSAGE_FD || AC_MSG_ERROR([failed to create ${config_h}])
+) || AC_MSG_ERROR([failed to create ${config_h}])
tr -d '\015' < largefile.h > confdefs.h
rm largefile.h
@@ -3964,31 +4458,30 @@ PACKAGE=$RUBY_BASE_NAME
AC_SUBST(PACKAGE)
AS_MESSAGE([$PACKAGE library version = $ruby_version])
-AS_IF([test x"$CC_WRAPPER" != x], [
- CC='$(CC_WRAPPER) '"${CC@%:@$CC_WRAPPER }"
- CPP='$(CC_WRAPPER) '"${CPP@%:@$CC_WRAPPER }"
- CC_WRAPPER='$(rubyarchdir)/darwin-cc'
- XCC_WRAPPER='$(top_srcdir)/tool/darwin-cc'
-])
-AC_SUBST(CC_WRAPPER, '')
-AC_SUBST(XCC_WRAPPER)
-
AS_CASE([" $CPP "], [*" $CC "*], [CPP=`echo " $CPP " | sed "s| $CC |"' $(CC) |;s/^ *//;s/ *$//'`])
AS_IF([test x"$firstmf" != x], [
AC_CONFIG_FILES($firstmf:$firsttmpl, [], [firstmf="$firstmf" firsttmpl="$firsttmpl"])
])
-AC_CONFIG_FILES(Makefile:template/Makefile.in, [
+AC_CONFIG_FILES(Makefile, [
tmpmk=confmk$$.tmp
{
AS_IF([test ${VCS+set}], [
:
+ ], [svn info "$srcdir" > /dev/null 2>&1], [
+ VCS='svn'
], [git_dir=`$GIT --work-tree="$srcdir" --git-dir="$srcdir/.git" rev-parse --git-dir 2>/dev/null`], [
- VCS='$(GIT)'
+ AS_IF([test -d "$git_dir/svn"], [
+ VCS='$(GIT) svn'
+ ], [
+ VCS='$(GIT)'
+ ])
], [
VCS='echo cannot'
])
AS_CASE("$VCS",
+ [svn], [VCSUP='$(VCS) up $(SVNUPOPTIONS)'],
+ ['$(GIT) svn'], [VCSUP='$(VCS) rebase $(GITSVNREBASEOPTIONS)'],
['$(GIT)'|git], [VCSUP='$(VCS) pull $(GITPULLOPTIONS)'],
[VCSUP='$(VCS)'])
sed -n \
@@ -4022,7 +4515,7 @@ AC_CONFIG_FILES(Makefile:template/Makefile.in, [
[EXEEXT='$EXEEXT' gnumake='$gnumake' GIT='$GIT'])
AC_ARG_WITH([ruby-pc],
- AS_HELP_STRING([--with-ruby-pc=FILENAME], [pc file basename]),
+ AC_HELP_STRING([--with-ruby-pc=FILENAME], [pc file basename]),
[ruby_pc="$withval"],
[ruby_pc="${RUBY_BASE_NAME}-${MAJOR}.${MINOR}.pc"])
AC_SUBST(ruby_pc)
@@ -4052,27 +4545,22 @@ AC_OUTPUT
}
}
-AS_IF([test "$silent" = yes], [], [
AS_IF([${FOLD+:} false], [], [
AS_IF([test "`echo abcdefg hijklmno | fold -s -w10 | sed 1d`" = hijklmno], [FOLD="fold"], [FOLD=])
])
-fold_width=`expr $COLUMNS - 30 2>/dev/null` || fold_width=50
AS_REQUIRE_SHELL_FN([config_summary],
[AS_FUNCTION_DESCRIBE([config_summary], [NAME, VAL], [configuration summary])],
[AS_IF([test -z "$2"], [], [
AS_ECHO_N([" * $1: "]) | dd bs=1 count=26 2>/dev/null
AS_IF([test "$FOLD"], [
- echo "$2" | fold -s -w$fold_width |
+ echo "$2" | fold -s -w50 |
sed '1!s/^/ /;$!s/$/\\/'
], [echo "$2"])
])]
)
-AS_IF([test $install_doc = yes],
- [DOCTARGETS=`echo " $RDOCTARGET $CAPITARGET " | sed 's/ nodoc //g;s/^ *//;s/ *$//'`],
- [DOCTARGETS=no])
echo "---"
-echo "Configuration summary for $RUBY_BASE_NAME version $MAJOR.$MINOR.$TEENY"
+echo "Configuration summary for $RUBY_BASE_NAME version $RUBY_PROGRAM_VERSION"
echo ""
config_summary "Installation prefix" "$prefix"
config_summary "exec prefix" "$exec_prefix"
@@ -4086,23 +4574,18 @@ config_summary "vendor path" "$vendordir"
config_summary "target OS" "$target_os"
config_summary "compiler" "$CC"
config_summary "with pthread" "$enable_pthread"
-config_summary "with coroutine" "$rb_cv_coroutine"
config_summary "enable shared libs" "$ENABLE_SHARED"
config_summary "dynamic library ext" "$DLEXT"
config_summary "CFLAGS" "$cflags"
config_summary "CPPFLAGS" "$cppflags"
config_summary "LDFLAGS" "$LDFLAGS"
-config_summary "DLDFLAGS" "$DLDFLAGS"
config_summary "optflags" "$optflags"
config_summary "debugflags" "$debugflags"
config_summary "warnflags" "$warnflags"
config_summary "strip command" "$STRIP"
-config_summary "install doc" "$DOCTARGETS"
-config_summary "JIT support" "$MJIT_SUPPORT"
+config_summary "install doc" "$install_doc"
config_summary "man page type" "$MANTYPE"
config_summary "search path" "$search_path"
config_summary "static-linked-ext" ${EXTSTATIC:+"yes"}
-config_summary "BASERUBY -v" "$BASERUBY_VERSION"
echo ""
echo "---"
-])
diff --git a/constant.h b/constant.h
index 3f1418df17..fcccf07384 100644
--- a/constant.h
+++ b/constant.h
@@ -31,20 +31,21 @@ typedef enum {
typedef struct rb_const_entry_struct {
rb_const_flag_t flag;
int line;
- VALUE value; /* should be mark */
- VALUE file; /* should be mark */
+ const VALUE value; /* should be mark */
+ const VALUE file; /* should be mark */
} rb_const_entry_t;
VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
void rb_free_const_table(struct rb_id_table *tbl);
+VALUE rb_public_const_get(VALUE klass, ID id);
VALUE rb_public_const_get_at(VALUE klass, ID id);
VALUE rb_public_const_get_from(VALUE klass, ID id);
+int rb_public_const_defined(VALUE klass, ID id);
+int rb_public_const_defined_at(VALUE klass, ID id);
int rb_public_const_defined_from(VALUE klass, ID id);
rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
-VALUE rb_const_source_location(VALUE, ID);
-VALUE rb_const_source_location_at(VALUE, ID);
#endif /* CONSTANT_H */
diff --git a/cont.c b/cont.c
index f1edd82bf0..539d1f48cc 100644
--- a/cont.c
+++ b/cont.c
@@ -13,44 +13,71 @@
#include "vm_core.h"
#include "gc.h"
#include "eval_intern.h"
-#include "mjit.h"
-#include COROUTINE_H
+/* FIBER_USE_NATIVE enables Fiber performance improvement using system
+ * dependent method such as make/setcontext on POSIX system or
+ * CreateFiber() API on Windows.
+ * This hack make Fiber context switch faster (x2 or more).
+ * However, it decrease maximum number of Fiber. For example, on the
+ * 32bit POSIX OS, ten or twenty thousands Fiber can be created.
+ *
+ * Details is reported in the paper "A Fast Fiber Implementation for Ruby 1.9"
+ * in Proc. of 51th Programming Symposium, pp.21--28 (2010) (in Japanese).
+ */
+
+#if !defined(FIBER_USE_NATIVE)
+# if defined(HAVE_GETCONTEXT) && defined(HAVE_SETCONTEXT)
+# if 0
+# elif defined(__NetBSD__)
+/* On our experience, NetBSD doesn't support using setcontext() and pthread
+ * simultaneously. This is because pthread_self(), TLS and other information
+ * are represented by stack pointer (higher bits of stack pointer).
+ * TODO: check such constraint on configure.
+ */
+# define FIBER_USE_NATIVE 0
+# elif defined(__sun)
+/* On Solaris because resuming any Fiber caused SEGV, for some reason.
+ */
+# define FIBER_USE_NATIVE 0
+# elif defined(__ia64)
+/* At least, Linux/ia64's getcontext(3) doesn't save register window.
+ */
+# define FIBER_USE_NATIVE 0
+# elif defined(__GNU__)
+/* GNU/Hurd doesn't fully support getcontext, setcontext, makecontext
+ * and swapcontext functions. Disabling their usage till support is
+ * implemented. More info at
+ * http://darnassus.sceen.net/~hurd-web/open_issues/glibc/#getcontext
+ */
+# define FIBER_USE_NATIVE 0
+# else
+# define FIBER_USE_NATIVE 1
+# endif
+# elif defined(_WIN32)
+# define FIBER_USE_NATIVE 1
+# endif
+#endif
+#if !defined(FIBER_USE_NATIVE)
+#define FIBER_USE_NATIVE 0
+#endif
+#if FIBER_USE_NATIVE
#ifndef _WIN32
#include <unistd.h>
#include <sys/mman.h>
+#include <ucontext.h>
#endif
-
-static const int DEBUG = 0;
-
#define RB_PAGE_SIZE (pagesize)
#define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1))
static long pagesize;
-
-static const rb_data_type_t cont_data_type, fiber_data_type;
-static VALUE rb_cContinuation;
-static VALUE rb_cFiber;
-static VALUE rb_eFiberError;
-#ifdef RB_EXPERIMENTAL_FIBER_POOL
-static VALUE rb_cFiberPool;
-#endif
+#endif /*FIBER_USE_NATIVE*/
#define CAPTURE_JUST_VALID_VM_STACK 1
-// Defined in `coroutine/$arch/Context.h`:
-#ifdef COROUTINE_LIMITED_ADDRESS_SPACE
-#define FIBER_POOL_ALLOCATION_FREE
-#define FIBER_POOL_INITIAL_SIZE 8
-#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 32
-#else
-#define FIBER_POOL_INITIAL_SIZE 32
-#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 1024
-#endif
-
enum context_type {
CONTINUATION_CONTEXT = 0,
- FIBER_CONTEXT = 1
+ FIBER_CONTEXT = 1,
+ ROOT_FIBER_CONTEXT = 2
};
struct cont_saved_vm_stack {
@@ -61,140 +88,28 @@ struct cont_saved_vm_stack {
#endif
};
-struct fiber_pool;
-
-// Represents a single stack.
-struct fiber_pool_stack {
- // A pointer to the memory allocation (lowest address) for the stack.
- void * base;
-
- // The current stack pointer, taking into account the direction of the stack.
- void * current;
-
- // The size of the stack excluding any guard pages.
- size_t size;
-
- // The available stack capacity w.r.t. the current stack offset.
- size_t available;
-
- // The pool this stack should be allocated from.
- struct fiber_pool * pool;
-
- // If the stack is allocated, the allocation it came from.
- struct fiber_pool_allocation * allocation;
-};
-
-// A linked list of vacant (unused) stacks.
-// This structure is stored in the first page of a stack if it is not in use.
-// @sa fiber_pool_vacancy_pointer
-struct fiber_pool_vacancy {
- // Details about the vacant stack:
- struct fiber_pool_stack stack;
-
- // The vacancy linked list.
-#ifdef FIBER_POOL_ALLOCATION_FREE
- struct fiber_pool_vacancy * previous;
-#endif
- struct fiber_pool_vacancy * next;
-};
-
-// Manages singly linked list of mapped regions of memory which contains 1 more more stack:
-//
-// base = +-------------------------------+-----------------------+ +
-// |VM Stack |VM Stack | | |
-// | | | | |
-// | | | | |
-// +-------------------------------+ | |
-// |Machine Stack |Machine Stack | | |
-// | | | | |
-// | | | | |
-// | | | . . . . | | size
-// | | | | |
-// | | | | |
-// | | | | |
-// | | | | |
-// | | | | |
-// +-------------------------------+ | |
-// |Guard Page |Guard Page | | |
-// +-------------------------------+-----------------------+ v
-//
-// +------------------------------------------------------->
-//
-// count
-//
-struct fiber_pool_allocation {
- // A pointer to the memory mapped region.
- void * base;
-
- // The size of the individual stacks.
- size_t size;
-
- // The stride of individual stacks (including any guard pages or other accounting details).
- size_t stride;
-
- // The number of stacks that were allocated.
- size_t count;
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
- // The number of stacks used in this allocation.
- size_t used;
-#endif
-
- struct fiber_pool * pool;
-
- // The allocation linked list.
-#ifdef FIBER_POOL_ALLOCATION_FREE
- struct fiber_pool_allocation * previous;
-#endif
- struct fiber_pool_allocation * next;
-};
-
-// A fiber pool manages vacant stacks to reduce the overhead of creating fibers.
-struct fiber_pool {
- // A singly-linked list of allocations which contain 1 or more stacks each.
- struct fiber_pool_allocation * allocations;
-
- // Provides O(1) stack "allocation":
- struct fiber_pool_vacancy * vacancies;
-
- // The size of the stack allocations (excluding any guard page).
- size_t size;
-
- // The total number of stacks that have been allocated in this pool.
- size_t count;
-
- // The initial number of stacks to allocate.
- size_t initial_count;
-
- // Whether to madvise(free) the stack or not:
- int free_stacks;
-
- // The number of stacks that have been used in this pool.
- size_t used;
-
- // The amount to allocate for the vm_stack:
- size_t vm_stack_size;
-};
-
typedef struct rb_context_struct {
enum context_type type;
int argc;
- int kw_splat;
VALUE self;
VALUE value;
struct cont_saved_vm_stack saved_vm_stack;
struct {
- VALUE *stack;
- VALUE *stack_src;
- size_t stack_size;
+ VALUE *stack;
+ VALUE *stack_src;
+ size_t stack_size;
+#ifdef __ia64
+ VALUE *register_stack;
+ VALUE *register_stack_src;
+ int register_stack_size;
+#endif
} machine;
rb_execution_context_t saved_ec;
rb_jmpbuf_t jmpbuf;
rb_ensure_entry_t *ensure_array;
- /* Pointer to MJIT info about the continuation. */
- struct mjit_cont *mjit_cont;
+ rb_ensure_list_t *ensure_list;
} rb_context_t;
@@ -217,534 +132,48 @@ enum fiber_status {
FIBER_TERMINATED
};
-#define FIBER_CREATED_P(fiber) ((fiber)->status == FIBER_CREATED)
-#define FIBER_RESUMED_P(fiber) ((fiber)->status == FIBER_RESUMED)
-#define FIBER_SUSPENDED_P(fiber) ((fiber)->status == FIBER_SUSPENDED)
-#define FIBER_TERMINATED_P(fiber) ((fiber)->status == FIBER_TERMINATED)
-#define FIBER_RUNNABLE_P(fiber) (FIBER_CREATED_P(fiber) || FIBER_SUSPENDED_P(fiber))
+#define FIBER_CREATED_P(fib) ((fib)->status == FIBER_CREATED)
+#define FIBER_RESUMED_P(fib) ((fib)->status == FIBER_RESUMED)
+#define FIBER_SUSPENDED_P(fib) ((fib)->status == FIBER_SUSPENDED)
+#define FIBER_TERMINATED_P(fib) ((fib)->status == FIBER_TERMINATED)
+#define FIBER_RUNNABLE_P(fib) (FIBER_CREATED_P(fib) || FIBER_SUSPENDED_P(fib))
+
+#if FIBER_USE_NATIVE && !defined(_WIN32)
+#define MAX_MACHINE_STACK_CACHE 10
+static int machine_stack_cache_index = 0;
+typedef struct machine_stack_cache_struct {
+ void *ptr;
+ size_t size;
+} machine_stack_cache_t;
+static machine_stack_cache_t machine_stack_cache[MAX_MACHINE_STACK_CACHE];
+static machine_stack_cache_t terminated_machine_stack;
+#endif
struct rb_fiber_struct {
rb_context_t cont;
VALUE first_proc;
struct rb_fiber_struct *prev;
- BITFIELD(enum fiber_status, status, 2);
- /* If a fiber invokes by "transfer",
- * then this fiber can't be invoked by "resume" any more after that.
+ const enum fiber_status status;
+ /* If a fiber invokes "transfer",
+ * then this fiber can't "resume" any more after that.
* You shouldn't mix "transfer" and "resume".
*/
- unsigned int transferred : 1;
-
- struct coroutine_context context;
- struct fiber_pool_stack stack;
-};
-
-static struct fiber_pool shared_fiber_pool = {NULL, NULL, 0, 0, 0, 0};
-
-/*
- * FreeBSD require a first (i.e. addr) argument of mmap(2) is not NULL
- * if MAP_STACK is passed.
- * http://www.FreeBSD.org/cgi/query-pr.cgi?pr=158755
- */
-#if defined(MAP_STACK) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
-#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON | MAP_STACK)
-#else
-#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON)
-#endif
-
-#define ERRNOMSG strerror(errno)
-
-// Locates the stack vacancy details for the given stack.
-// Requires that fiber_pool_vacancy fits within one page.
-inline static struct fiber_pool_vacancy *
-fiber_pool_vacancy_pointer(void * base, size_t size)
-{
- STACK_GROW_DIR_DETECTION;
-
- return (struct fiber_pool_vacancy *)(
- (char*)base + STACK_DIR_UPPER(0, size - RB_PAGE_SIZE)
- );
-}
-
-// Reset the current stack pointer and available size of the given stack.
-inline static void
-fiber_pool_stack_reset(struct fiber_pool_stack * stack)
-{
- STACK_GROW_DIR_DETECTION;
-
- stack->current = (char*)stack->base + STACK_DIR_UPPER(0, stack->size);
- stack->available = stack->size;
-}
-
-// A pointer to the base of the current unused portion of the stack.
-inline static void *
-fiber_pool_stack_base(struct fiber_pool_stack * stack)
-{
- STACK_GROW_DIR_DETECTION;
-
- VM_ASSERT(stack->current);
-
- return STACK_DIR_UPPER(stack->current, (char*)stack->current - stack->available);
-}
-
-// Allocate some memory from the stack. Used to allocate vm_stack inline with machine stack.
-// @sa fiber_initialize_coroutine
-inline static void *
-fiber_pool_stack_alloca(struct fiber_pool_stack * stack, size_t offset)
-{
- STACK_GROW_DIR_DETECTION;
-
- if (DEBUG) fprintf(stderr, "fiber_pool_stack_alloca(%p): %"PRIuSIZE"/%"PRIuSIZE"\n", (void*)stack, offset, stack->available);
- VM_ASSERT(stack->available >= offset);
-
- // The pointer to the memory being allocated:
- void * pointer = STACK_DIR_UPPER(stack->current, (char*)stack->current - offset);
-
- // Move the stack pointer:
- stack->current = STACK_DIR_UPPER((char*)stack->current + offset, (char*)stack->current - offset);
- stack->available -= offset;
-
- return pointer;
-}
-
-// Reset the current stack pointer and available size of the given stack.
-inline static void
-fiber_pool_vacancy_reset(struct fiber_pool_vacancy * vacancy)
-{
- fiber_pool_stack_reset(&vacancy->stack);
-
- // Consume one page of the stack because it's used for the vacancy list:
- fiber_pool_stack_alloca(&vacancy->stack, RB_PAGE_SIZE);
-}
-
-inline static struct fiber_pool_vacancy *
-fiber_pool_vacancy_push(struct fiber_pool_vacancy * vacancy, struct fiber_pool_vacancy * head)
-{
- vacancy->next = head;
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
- if (head) {
- head->previous = vacancy;
- vacancy->previous = NULL;
- }
-#endif
-
- return vacancy;
-}
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
-static void
-fiber_pool_vacancy_remove(struct fiber_pool_vacancy * vacancy)
-{
- if (vacancy->next) {
- vacancy->next->previous = vacancy->previous;
- }
-
- if (vacancy->previous) {
- vacancy->previous->next = vacancy->next;
- }
- else {
- // It's the head of the list:
- vacancy->stack.pool->vacancies = vacancy->next;
- }
-}
-
-inline static struct fiber_pool_vacancy *
-fiber_pool_vacancy_pop(struct fiber_pool * pool)
-{
- struct fiber_pool_vacancy * vacancy = pool->vacancies;
-
- if (vacancy) {
- fiber_pool_vacancy_remove(vacancy);
- }
-
- return vacancy;
-}
-#else
-inline static struct fiber_pool_vacancy *
-fiber_pool_vacancy_pop(struct fiber_pool * pool)
-{
- struct fiber_pool_vacancy * vacancy = pool->vacancies;
-
- if (vacancy) {
- pool->vacancies = vacancy->next;
- }
-
- return vacancy;
-}
-#endif
-
-// Initialize the vacant stack. The [base, size] allocation should not include the guard page.
-// @param base The pointer to the lowest address of the allocated memory.
-// @param size The size of the allocated memory.
-inline static struct fiber_pool_vacancy *
-fiber_pool_vacancy_initialize(struct fiber_pool * fiber_pool, struct fiber_pool_vacancy * vacancies, void * base, size_t size)
-{
- struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, size);
-
- vacancy->stack.base = base;
- vacancy->stack.size = size;
-
- fiber_pool_vacancy_reset(vacancy);
-
- vacancy->stack.pool = fiber_pool;
-
- return fiber_pool_vacancy_push(vacancy, vacancies);
-}
-
-// Allocate a maximum of count stacks, size given by stride.
-// @param count the number of stacks to allocate / were allocated.
-// @param stride the size of the individual stacks.
-// @return [void *] the allocated memory or NULL if allocation failed.
-inline static void *
-fiber_pool_allocate_memory(size_t * count, size_t stride)
-{
- // We use a divide-by-2 strategy to try and allocate memory. We are trying
- // to allocate `count` stacks. In normal situation, this won't fail. But
- // if we ran out of address space, or we are allocating more memory than
- // the system would allow (e.g. overcommit * physical memory + swap), we
- // divide count by two and try again. This condition should only be
- // encountered in edge cases, but we handle it here gracefully.
- while (*count > 1) {
-#if defined(_WIN32)
- void * base = VirtualAlloc(0, (*count)*stride, MEM_COMMIT, PAGE_READWRITE);
-
- if (!base) {
- *count = (*count) >> 1;
- }
- else {
- return base;
- }
-#else
- errno = 0;
- void * base = mmap(NULL, (*count)*stride, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0);
-
- if (base == MAP_FAILED) {
- // If the allocation fails, count = count / 2, and try again.
- *count = (*count) >> 1;
- }
- else {
- return base;
- }
-#endif
- }
-
- return NULL;
-}
-
-// Given an existing fiber pool, expand it by the specified number of stacks.
-// @param count the maximum number of stacks to allocate.
-// @return the allocated fiber pool.
-// @sa fiber_pool_allocation_free
-static struct fiber_pool_allocation *
-fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count)
-{
- STACK_GROW_DIR_DETECTION;
-
- size_t size = fiber_pool->size;
- size_t stride = size + RB_PAGE_SIZE;
-
- // Allocate the memory required for the stacks:
- void * base = fiber_pool_allocate_memory(&count, stride);
-
- if (base == NULL) {
- rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%"PRIuSIZE" x %"PRIuSIZE" bytes): %s", count, size, ERRNOMSG);
- }
-
- struct fiber_pool_vacancy * vacancies = fiber_pool->vacancies;
- struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation);
-
- // Initialize fiber pool allocation:
- allocation->base = base;
- allocation->size = size;
- allocation->stride = stride;
- allocation->count = count;
-#ifdef FIBER_POOL_ALLOCATION_FREE
- allocation->used = 0;
-#endif
- allocation->pool = fiber_pool;
-
- if (DEBUG) {
- fprintf(stderr, "fiber_pool_expand(%"PRIuSIZE"): %p, %"PRIuSIZE"/%"PRIuSIZE" x [%"PRIuSIZE":%"PRIuSIZE"]\n",
- count, (void*)fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size);
- }
-
- // Iterate over all stacks, initializing the vacancy list:
- for (size_t i = 0; i < count; i += 1) {
- void * base = (char*)allocation->base + (stride * i);
- void * page = (char*)base + STACK_DIR_UPPER(size, 0);
-
-#if defined(_WIN32)
- DWORD old_protect;
-
- if (!VirtualProtect(page, RB_PAGE_SIZE, PAGE_READWRITE | PAGE_GUARD, &old_protect)) {
- VirtualFree(allocation->base, 0, MEM_RELEASE);
- rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG);
- }
-#else
- if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) {
- munmap(allocation->base, count*stride);
- rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG);
- }
-#endif
-
- vacancies = fiber_pool_vacancy_initialize(
- fiber_pool, vacancies,
- (char*)base + STACK_DIR_UPPER(0, RB_PAGE_SIZE),
- size
- );
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
- vacancies->stack.allocation = allocation;
-#endif
- }
-
- // Insert the allocation into the head of the pool:
- allocation->next = fiber_pool->allocations;
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
- if (allocation->next) {
- allocation->next->previous = allocation;
- }
-
- allocation->previous = NULL;
-#endif
-
- fiber_pool->allocations = allocation;
- fiber_pool->vacancies = vacancies;
- fiber_pool->count += count;
-
- return allocation;
-}
-
-// Initialize the specified fiber pool with the given number of stacks.
-// @param vm_stack_size The size of the vm stack to allocate.
-static void
-fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, size_t vm_stack_size)
-{
- VM_ASSERT(vm_stack_size < size);
-
- fiber_pool->allocations = NULL;
- fiber_pool->vacancies = NULL;
- fiber_pool->size = ((size / RB_PAGE_SIZE) + 1) * RB_PAGE_SIZE;
- fiber_pool->count = 0;
- fiber_pool->initial_count = count;
- fiber_pool->free_stacks = 1;
- fiber_pool->used = 0;
-
- fiber_pool->vm_stack_size = vm_stack_size;
-
- fiber_pool_expand(fiber_pool, count);
-}
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
-// Free the list of fiber pool allocations.
-static void
-fiber_pool_allocation_free(struct fiber_pool_allocation * allocation)
-{
- STACK_GROW_DIR_DETECTION;
-
- VM_ASSERT(allocation->used == 0);
-
- if (DEBUG) fprintf(stderr, "fiber_pool_allocation_free: %p base=%p count=%"PRIuSIZE"\n", allocation, allocation->base, allocation->count);
-
- size_t i;
- for (i = 0; i < allocation->count; i += 1) {
- void * base = (char*)allocation->base + (allocation->stride * i) + STACK_DIR_UPPER(0, RB_PAGE_SIZE);
-
- struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(base, allocation->size);
-
- // Pop the vacant stack off the free list:
- fiber_pool_vacancy_remove(vacancy);
- }
+ int transferred;
+#if FIBER_USE_NATIVE
#ifdef _WIN32
- VirtualFree(allocation->base, 0, MEM_RELEASE);
+ void *fib_handle;
#else
- munmap(allocation->base, allocation->stride * allocation->count);
-#endif
-
- if (allocation->previous) {
- allocation->previous->next = allocation->next;
- }
- else {
- // We are the head of the list, so update the pool:
- allocation->pool->allocations = allocation->next;
- }
-
- if (allocation->next) {
- allocation->next->previous = allocation->previous;
- }
-
- allocation->pool->count -= allocation->count;
-
- ruby_xfree(allocation);
-}
-#endif
-
-// Acquire a stack from the given fiber pool. If none are available, allocate more.
-static struct fiber_pool_stack
-fiber_pool_stack_acquire(struct fiber_pool * fiber_pool) {
- struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pop(fiber_pool);
-
- if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%"PRIuSIZE"\n", (void*)fiber_pool->vacancies, fiber_pool->used);
-
- if (!vacancy) {
- const size_t maximum = FIBER_POOL_ALLOCATION_MAXIMUM_SIZE;
- const size_t minimum = fiber_pool->initial_count;
-
- size_t count = fiber_pool->count;
- if (count > maximum) count = maximum;
- if (count < minimum) count = minimum;
-
- fiber_pool_expand(fiber_pool, count);
-
- // The free list should now contain some stacks:
- VM_ASSERT(fiber_pool->vacancies);
-
- vacancy = fiber_pool_vacancy_pop(fiber_pool);
- }
-
- VM_ASSERT(vacancy);
- VM_ASSERT(vacancy->stack.base);
-
- // Take the top item from the free list:
- fiber_pool->used += 1;
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
- vacancy->stack.allocation->used += 1;
-#endif
-
- fiber_pool_stack_reset(&vacancy->stack);
-
- return vacancy->stack;
-}
-
-// We advise the operating system that the stack memory pages are no longer being used.
-// This introduce some performance overhead but allows system to relaim memory when there is pressure.
-static inline void
-fiber_pool_stack_free(struct fiber_pool_stack * stack)
-{
- void * base = fiber_pool_stack_base(stack);
- size_t size = stack->available;
-
- // If this is not true, the vacancy information will almost certainly be destroyed:
- VM_ASSERT(size <= (stack->size - RB_PAGE_SIZE));
-
- if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%"PRIuSIZE" [base=%p, size=%"PRIuSIZE"]\n", base, size, stack->base, stack->size);
-
-#if VM_CHECK_MODE > 0 && defined(MADV_DONTNEED)
- // This immediately discards the pages and the memory is reset to zero.
- madvise(base, size, MADV_DONTNEED);
-#elif defined(MADV_FREE_REUSABLE)
- madvise(base, size, MADV_FREE_REUSABLE);
-#elif defined(MADV_FREE)
- madvise(base, size, MADV_FREE);
-#elif defined(MADV_DONTNEED)
- madvise(base, size, MADV_DONTNEED);
-#elif defined(_WIN32)
- VirtualAlloc(base, size, MEM_RESET, PAGE_READWRITE);
- // Not available in all versions of Windows.
- //DiscardVirtualMemory(base, size);
+ ucontext_t context;
+ /* Because context.uc_stack.ss_sp and context.uc_stack.ss_size
+ * are not necessarily valid after makecontext() or swapcontext(),
+ * they are saved in these variables for later use.
+ */
+ void *ss_sp;
+ size_t ss_size;
#endif
-}
-
-// Release and return a stack to the vacancy list.
-static void
-fiber_pool_stack_release(struct fiber_pool_stack * stack)
-{
- struct fiber_pool * pool = stack->pool;
- struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pointer(stack->base, stack->size);
-
- if (DEBUG) fprintf(stderr, "fiber_pool_stack_release: %p used=%"PRIuSIZE"\n", stack->base, stack->pool->used);
-
- // Copy the stack details into the vacancy area:
- vacancy->stack = *stack;
- // After this point, be careful about updating/using state in stack, since it's copied to the vacancy area.
-
- // Reset the stack pointers and reserve space for the vacancy data:
- fiber_pool_vacancy_reset(vacancy);
-
- // Push the vacancy into the vancancies list:
- pool->vacancies = fiber_pool_vacancy_push(vacancy, stack->pool->vacancies);
- pool->used -= 1;
-
-#ifdef FIBER_POOL_ALLOCATION_FREE
- struct fiber_pool_allocation * allocation = stack->allocation;
-
- allocation->used -= 1;
-
- // Release address space and/or dirty memory:
- if (allocation->used == 0) {
- fiber_pool_allocation_free(allocation);
- }
- else if (stack->pool->free_stacks) {
- fiber_pool_stack_free(&vacancy->stack);
- }
-#else
- // This is entirely optional, but clears the dirty flag from the stack memory, so it won't get swapped to disk when there is memory pressure:
- if (stack->pool->free_stacks) {
- fiber_pool_stack_free(&vacancy->stack);
- }
#endif
-}
-
-static COROUTINE
-fiber_entry(struct coroutine_context * from, struct coroutine_context * to)
-{
- rb_fiber_start();
-}
-
-// Initialize a fiber's coroutine's machine stack and vm stack.
-static VALUE *
-fiber_initialize_coroutine(rb_fiber_t *fiber, size_t * vm_stack_size)
-{
- struct fiber_pool * fiber_pool = fiber->stack.pool;
- rb_execution_context_t *sec = &fiber->cont.saved_ec;
- void * vm_stack = NULL;
-
- VM_ASSERT(fiber_pool != NULL);
-
- fiber->stack = fiber_pool_stack_acquire(fiber_pool);
- vm_stack = fiber_pool_stack_alloca(&fiber->stack, fiber_pool->vm_stack_size);
- *vm_stack_size = fiber_pool->vm_stack_size;
-
-#ifdef COROUTINE_PRIVATE_STACK
- coroutine_initialize(&fiber->context, fiber_entry, fiber_pool_stack_base(&fiber->stack), fiber->stack.available, sec->machine.stack_start);
- // The stack for this execution context is still the main machine stack, so don't adjust it.
- // If this is not managed correctly, you will fail in `rb_ec_stack_check`.
-
- // We limit the machine stack usage to the fiber stack size.
- if (sec->machine.stack_maxsize > fiber->stack.available) {
- sec->machine.stack_maxsize = fiber->stack.available;
- }
-#else
- coroutine_initialize(&fiber->context, fiber_entry, fiber_pool_stack_base(&fiber->stack), fiber->stack.available);
-
- // The stack for this execution context is the one we allocated:
- sec->machine.stack_start = fiber->stack.current;
- sec->machine.stack_maxsize = fiber->stack.available;
-#endif
-
- return vm_stack;
-}
-
-// Release the stack from the fiber, it's execution context, and return it to the fiber pool.
-static void
-fiber_stack_release(rb_fiber_t * fiber)
-{
- rb_execution_context_t *ec = &fiber->cont.saved_ec;
-
- if (DEBUG) fprintf(stderr, "fiber_stack_release: %p, stack.base=%p\n", (void*)fiber, fiber->stack.base);
-
- // Return the stack back to the fiber pool if it wasn't already:
- if (fiber->stack.base) {
- fiber_pool_stack_release(&fiber->stack);
- fiber->stack.base = NULL;
- }
-
- // The stack is no longer associated with this execution context:
- rb_ec_clear_vm_stack(ec);
-}
+};
static const char *
fiber_status_name(enum fiber_status s)
@@ -760,42 +189,57 @@ fiber_status_name(enum fiber_status s)
}
static void
-fiber_verify(const rb_fiber_t *fiber)
+fiber_verify(const rb_fiber_t *fib)
{
#if VM_CHECK_MODE > 0
- VM_ASSERT(fiber->cont.saved_ec.fiber_ptr == fiber);
+ VM_ASSERT(fib->cont.saved_ec.fiber_ptr == fib);
- switch (fiber->status) {
+ switch (fib->status) {
case FIBER_RESUMED:
- VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL);
- break;
+ VM_ASSERT(fib->cont.saved_ec.vm_stack != NULL);
+ break;
case FIBER_SUSPENDED:
- VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL);
- break;
+ VM_ASSERT(fib->cont.saved_ec.vm_stack != NULL);
+ break;
case FIBER_CREATED:
case FIBER_TERMINATED:
- /* TODO */
- break;
+ /* TODO */
+ break;
default:
- VM_UNREACHABLE(fiber_verify);
+ VM_UNREACHABLE(fiber_verify);
}
#endif
}
-inline static void
-fiber_status_set(rb_fiber_t *fiber, enum fiber_status s)
+#if VM_CHECK_MODE > 0
+void
+rb_ec_verify(const rb_execution_context_t *ec)
{
- // if (DEBUG) fprintf(stderr, "fiber: %p, status: %s -> %s\n", (void *)fiber, fiber_status_name(fiber->status), fiber_status_name(s));
- VM_ASSERT(!FIBER_TERMINATED_P(fiber));
- VM_ASSERT(fiber->status != s);
- fiber_verify(fiber);
- fiber->status = s;
+ /* TODO */
+}
+#endif
+
+static void
+fiber_status_set(const rb_fiber_t *fib, enum fiber_status s)
+{
+ if (0) fprintf(stderr, "fib: %p, status: %s -> %s\n", fib, fiber_status_name(fib->status), fiber_status_name(s));
+ VM_ASSERT(!FIBER_TERMINATED_P(fib));
+ VM_ASSERT(fib->status != s);
+ fiber_verify(fib);
+ *((enum fiber_status *)&fib->status) = s;
+}
+
+void
+ec_set_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size)
+{
+ *(VALUE **)(&ec->vm_stack) = stack;
+ *(size_t *)(&ec->vm_stack_size) = size;
}
static inline void
-ec_switch(rb_thread_t *th, rb_fiber_t *fiber)
+ec_switch(rb_thread_t *th, rb_fiber_t *fib)
{
- rb_execution_context_t *ec = &fiber->cont.saved_ec;
+ rb_execution_context_t *ec = &fib->cont.saved_ec;
ruby_current_execution_context_ptr = th->ec = ec;
@@ -810,31 +254,23 @@ ec_switch(rb_thread_t *th, rb_fiber_t *fiber)
VM_ASSERT(ec->fiber_ptr->cont.self == 0 || ec->vm_stack != NULL);
}
-static rb_context_t *
-cont_ptr(VALUE obj)
-{
- rb_context_t *cont;
-
- TypedData_Get_Struct(obj, rb_context_t, &cont_data_type, cont);
-
- return cont;
-}
-
-static rb_fiber_t *
-fiber_ptr(VALUE obj)
-{
- rb_fiber_t *fiber;
+static const rb_data_type_t cont_data_type, fiber_data_type;
+static VALUE rb_cContinuation;
+static VALUE rb_cFiber;
+static VALUE rb_eFiberError;
- TypedData_Get_Struct(obj, rb_fiber_t, &fiber_data_type, fiber);
- if (!fiber) rb_raise(rb_eFiberError, "uninitialized fiber");
+#define GetContPtr(obj, ptr) \
+ TypedData_Get_Struct((obj), rb_context_t, &cont_data_type, (ptr))
- return fiber;
-}
+#define GetFiberPtr(obj, ptr) do {\
+ TypedData_Get_Struct((obj), rb_fiber_t, &fiber_data_type, (ptr)); \
+ if (!(ptr)) rb_raise(rb_eFiberError, "uninitialized fiber"); \
+} while (0)
NOINLINE(static VALUE cont_capture(volatile int *volatile stat));
#define THREAD_MUST_BE_RUNNING(th) do { \
- if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \
+ if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \
} while (0)
static VALUE
@@ -844,90 +280,99 @@ cont_thread_value(const rb_context_t *cont)
}
static void
-cont_compact(void *ptr)
-{
- rb_context_t *cont = ptr;
-
- if (cont->self) {
- cont->self = rb_gc_location(cont->self);
- }
- cont->value = rb_gc_location(cont->value);
- rb_execution_context_update(&cont->saved_ec);
-}
-
-static void
cont_mark(void *ptr)
{
rb_context_t *cont = ptr;
RUBY_MARK_ENTER("cont");
- if (cont->self) {
- rb_gc_mark_movable(cont->self);
- }
- rb_gc_mark_movable(cont->value);
+ rb_gc_mark(cont->value);
rb_execution_context_mark(&cont->saved_ec);
rb_gc_mark(cont_thread_value(cont));
if (cont->saved_vm_stack.ptr) {
#ifdef CAPTURE_JUST_VALID_VM_STACK
- rb_gc_mark_locations(cont->saved_vm_stack.ptr,
- cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen + cont->saved_vm_stack.clen);
+ rb_gc_mark_locations(cont->saved_vm_stack.ptr,
+ cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen + cont->saved_vm_stack.clen);
#else
- rb_gc_mark_locations(cont->saved_vm_stack.ptr,
- cont->saved_vm_stack.ptr, cont->saved_ec.stack_size);
+ rb_gc_mark_locations(cont->saved_vm_stack.ptr,
+ cont->saved_vm_stack.ptr, cont->saved_ec.stack_size);
#endif
}
if (cont->machine.stack) {
- if (cont->type == CONTINUATION_CONTEXT) {
- /* cont */
- rb_gc_mark_locations(cont->machine.stack,
- cont->machine.stack + cont->machine.stack_size);
- }
- else {
- /* fiber */
- const rb_fiber_t *fiber = (rb_fiber_t*)cont;
-
- if (!FIBER_TERMINATED_P(fiber)) {
- rb_gc_mark_locations(cont->machine.stack,
- cont->machine.stack + cont->machine.stack_size);
- }
- }
+ if (cont->type == CONTINUATION_CONTEXT) {
+ /* cont */
+ rb_gc_mark_locations(cont->machine.stack,
+ cont->machine.stack + cont->machine.stack_size);
+ }
+ else {
+ /* fiber */
+ const rb_fiber_t *fib = (rb_fiber_t*)cont;
+
+ if (!FIBER_TERMINATED_P(fib)) {
+ rb_gc_mark_locations(cont->machine.stack,
+ cont->machine.stack + cont->machine.stack_size);
+ }
+ }
+ }
+#ifdef __ia64
+ if (cont->machine.register_stack) {
+ rb_gc_mark_locations(cont->machine.register_stack,
+ cont->machine.register_stack + cont->machine.register_stack_size);
}
+#endif
RUBY_MARK_LEAVE("cont");
}
-static int
-fiber_is_root_p(const rb_fiber_t *fiber)
-{
- return fiber == fiber->cont.saved_ec.thread_ptr->root_fiber;
-}
-
static void
cont_free(void *ptr)
{
rb_context_t *cont = ptr;
RUBY_FREE_ENTER("cont");
+ ruby_xfree(cont->saved_ec.vm_stack);
+#if FIBER_USE_NATIVE
if (cont->type == CONTINUATION_CONTEXT) {
- ruby_xfree(cont->saved_ec.vm_stack);
- ruby_xfree(cont->ensure_array);
- RUBY_FREE_UNLESS_NULL(cont->machine.stack);
+ /* cont */
+ ruby_xfree(cont->ensure_array);
+ RUBY_FREE_UNLESS_NULL(cont->machine.stack);
}
else {
- rb_fiber_t *fiber = (rb_fiber_t*)cont;
- coroutine_destroy(&fiber->context);
- fiber_stack_release(fiber);
+ /* fiber */
+ const rb_fiber_t *fib = (rb_fiber_t*)cont;
+#ifdef _WIN32
+ if (cont->type != ROOT_FIBER_CONTEXT) {
+ /* don't delete root fiber handle */
+ if (fib->fib_handle) {
+ DeleteFiber(fib->fib_handle);
+ }
+ }
+#else /* not WIN32 */
+ if (fib->ss_sp != NULL) {
+ if (cont->type == ROOT_FIBER_CONTEXT) {
+ rb_bug("Illegal root fiber parameter");
+ }
+ munmap((void*)fib->ss_sp, fib->ss_size);
+ }
+ else {
+ /* It may reached here when finalize */
+ /* TODO examine whether it is a bug */
+ /* rb_bug("cont_free: release self"); */
+ }
+#endif
}
-
+#else /* not FIBER_USE_NATIVE */
+ ruby_xfree(cont->ensure_array);
+ RUBY_FREE_UNLESS_NULL(cont->machine.stack);
+#endif
+#ifdef __ia64
+ RUBY_FREE_UNLESS_NULL(cont->machine.register_stack);
+#endif
RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr);
- if (mjit_enabled && cont->mjit_cont != NULL) {
- mjit_cont_free(cont->mjit_cont);
- }
/* free rb_cont_t or rb_fiber_t */
ruby_xfree(ptr);
RUBY_FREE_LEAVE("cont");
@@ -942,97 +387,83 @@ cont_memsize(const void *ptr)
size = sizeof(*cont);
if (cont->saved_vm_stack.ptr) {
#ifdef CAPTURE_JUST_VALID_VM_STACK
- size_t n = (cont->saved_vm_stack.slen + cont->saved_vm_stack.clen);
+ size_t n = (cont->saved_vm_stack.slen + cont->saved_vm_stack.clen);
#else
- size_t n = cont->saved_ec.vm_stack_size;
+ size_t n = cont->saved_ec.vm_stack_size;
#endif
- size += n * sizeof(*cont->saved_vm_stack.ptr);
+ size += n * sizeof(*cont->saved_vm_stack.ptr);
}
if (cont->machine.stack) {
- size += cont->machine.stack_size * sizeof(*cont->machine.stack);
- }
-
- return size;
-}
-
-void
-rb_fiber_update_self(rb_fiber_t *fiber)
-{
- if (fiber->cont.self) {
- fiber->cont.self = rb_gc_location(fiber->cont.self);
+ size += cont->machine.stack_size * sizeof(*cont->machine.stack);
}
- else {
- rb_execution_context_update(&fiber->cont.saved_ec);
+#ifdef __ia64
+ if (cont->machine.register_stack) {
+ size += cont->machine.register_stack_size * sizeof(*cont->machine.register_stack);
}
+#endif
+ return size;
}
void
-rb_fiber_mark_self(const rb_fiber_t *fiber)
+rb_fiber_mark_self(const rb_fiber_t *fib)
{
- if (fiber->cont.self) {
- rb_gc_mark_movable(fiber->cont.self);
+ if (fib->cont.self) {
+ rb_gc_mark(fib->cont.self);
}
else {
- rb_execution_context_mark(&fiber->cont.saved_ec);
+ rb_execution_context_mark(&fib->cont.saved_ec);
}
}
static void
-fiber_compact(void *ptr)
-{
- rb_fiber_t *fiber = ptr;
- fiber->first_proc = rb_gc_location(fiber->first_proc);
-
- if (fiber->prev) rb_fiber_update_self(fiber->prev);
-
- cont_compact(&fiber->cont);
- fiber_verify(fiber);
-}
-
-static void
fiber_mark(void *ptr)
{
- rb_fiber_t *fiber = ptr;
+ rb_fiber_t *fib = ptr;
RUBY_MARK_ENTER("cont");
- fiber_verify(fiber);
- rb_gc_mark_movable(fiber->first_proc);
- if (fiber->prev) rb_fiber_mark_self(fiber->prev);
- cont_mark(&fiber->cont);
+ fiber_verify(fib);
+ rb_gc_mark(fib->first_proc);
+ if (fib->prev) rb_fiber_mark_self(fib->prev);
+
+#if !FIBER_USE_NATIVE
+ if (fib->status == FIBER_TERMINATED) {
+ /* FIBER_TERMINATED fiber should not mark machine stack */
+ if (fib->cont.saved_ec.machine.stack_end != NULL) {
+ fib->cont.saved_ec.machine.stack_end = NULL;
+ }
+ }
+#endif
+
+ cont_mark(&fib->cont);
RUBY_MARK_LEAVE("cont");
}
static void
fiber_free(void *ptr)
{
- rb_fiber_t *fiber = ptr;
+ rb_fiber_t *fib = ptr;
RUBY_FREE_ENTER("fiber");
- //if (DEBUG) fprintf(stderr, "fiber_free: %p[%p]\n", fiber, fiber->stack.base);
-
- if (fiber->cont.saved_ec.local_storage) {
- st_free_table(fiber->cont.saved_ec.local_storage);
+ if (fib->cont.saved_ec.local_storage) {
+ st_free_table(fib->cont.saved_ec.local_storage);
}
- cont_free(&fiber->cont);
+ cont_free(&fib->cont);
RUBY_FREE_LEAVE("fiber");
}
static size_t
fiber_memsize(const void *ptr)
{
- const rb_fiber_t *fiber = ptr;
- size_t size = sizeof(*fiber);
- const rb_execution_context_t *saved_ec = &fiber->cont.saved_ec;
- const rb_thread_t *th = rb_ec_thread_ptr(saved_ec);
+ const rb_fiber_t *fib = ptr;
+ size_t size = 0;
- /*
- * vm.c::thread_memsize already counts th->ec->local_storage
- */
- if (saved_ec->local_storage && fiber != th->root_fiber) {
- size += st_memsize(saved_ec->local_storage);
+ size = sizeof(*fib);
+ if (fib->cont.type != ROOT_FIBER_CONTEXT &&
+ fib->cont.saved_ec.local_storage != NULL) {
+ size += st_memsize(fib->cont.saved_ec.local_storage);
}
- size += cont_memsize(&fiber->cont);
+ size += cont_memsize(&fib->cont);
return size;
}
@@ -1040,10 +471,10 @@ VALUE
rb_obj_is_fiber(VALUE obj)
{
if (rb_typeddata_is_kind_of(obj, &fiber_data_type)) {
- return Qtrue;
+ return Qtrue;
}
else {
- return Qfalse;
+ return Qfalse;
}
}
@@ -1053,30 +484,47 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
size_t size;
SET_MACHINE_STACK_END(&th->ec->machine.stack_end);
+#ifdef __ia64
+ th->machine.register_stack_end = rb_ia64_bsp();
+#endif
if (th->ec->machine.stack_start > th->ec->machine.stack_end) {
- size = cont->machine.stack_size = th->ec->machine.stack_start - th->ec->machine.stack_end;
- cont->machine.stack_src = th->ec->machine.stack_end;
+ size = cont->machine.stack_size = th->ec->machine.stack_start - th->ec->machine.stack_end;
+ cont->machine.stack_src = th->ec->machine.stack_end;
}
else {
- size = cont->machine.stack_size = th->ec->machine.stack_end - th->ec->machine.stack_start;
- cont->machine.stack_src = th->ec->machine.stack_start;
+ size = cont->machine.stack_size = th->ec->machine.stack_end - th->ec->machine.stack_start;
+ cont->machine.stack_src = th->ec->machine.stack_start;
}
if (cont->machine.stack) {
- REALLOC_N(cont->machine.stack, VALUE, size);
+ REALLOC_N(cont->machine.stack, VALUE, size);
}
else {
- cont->machine.stack = ALLOC_N(VALUE, size);
+ cont->machine.stack = ALLOC_N(VALUE, size);
}
FLUSH_REGISTER_WINDOWS;
MEMCPY(cont->machine.stack, cont->machine.stack_src, VALUE, size);
+
+#ifdef __ia64
+ rb_ia64_flushrs();
+ size = cont->machine.register_stack_size = th->machine.register_stack_end - th->machine.register_stack_start;
+ cont->machine.register_stack_src = th->machine.register_stack_start;
+ if (cont->machine.register_stack) {
+ REALLOC_N(cont->machine.register_stack, VALUE, size);
+ }
+ else {
+ cont->machine.register_stack = ALLOC_N(VALUE, size);
+ }
+
+ MEMCPY(cont->machine.register_stack, cont->machine.register_stack_src, VALUE, size);
+#endif
}
static const rb_data_type_t cont_data_type = {
"continuation",
- {cont_mark, cont_free, cont_memsize, cont_compact},
+ {cont_mark, cont_free, cont_memsize,},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -1090,18 +538,14 @@ cont_save_thread(rb_context_t *cont, rb_thread_t *th)
/* save thread context */
*sec = *th->ec;
- /* saved_ec->machine.stack_end should be NULL */
+ /* saved_thread->machine.stack_end should be NULL */
/* because it may happen GC afterward */
sec->machine.stack_end = NULL;
-}
-static void
-cont_init_mjit_cont(rb_context_t *cont)
-{
- VM_ASSERT(cont->mjit_cont == NULL);
- if (mjit_enabled) {
- cont->mjit_cont = mjit_cont_new(&(cont->saved_ec));
- }
+#ifdef __ia64
+ sec->machine.register_stack_start = NULL;
+ sec->machine.register_stack_end = NULL;
+#endif
}
static void
@@ -1113,7 +557,6 @@ cont_init(rb_context_t *cont, rb_thread_t *th)
cont->saved_ec.local_storage = NULL;
cont->saved_ec.local_storage_recursive_hash = Qnil;
cont->saved_ec.local_storage_recursive_hash_for_trace = Qnil;
- cont_init_mjit_cont(cont);
}
static rb_context_t *
@@ -1130,45 +573,33 @@ cont_new(VALUE klass)
return cont;
}
-void
-rb_fiber_init_mjit_cont(struct rb_fiber_struct *fiber)
-{
- // Currently this function is meant for root_fiber. Others go through cont_new.
- // XXX: Is this mjit_cont `mjit_cont_free`d?
- cont_init_mjit_cont(&fiber->cont);
-}
-
#if 0
void
show_vm_stack(const rb_execution_context_t *ec)
{
VALUE *p = ec->vm_stack;
while (p < ec->cfp->sp) {
- fprintf(stderr, "%3d ", (int)(p - ec->vm_stack));
- rb_obj_info_dump(*p);
- p++;
+ fprintf(stderr, "%3d ", (int)(p - ec->vm_stack));
+ rb_obj_info_dump(*p);
+ p++;
}
}
void
show_vm_pcs(const rb_control_frame_t *cfp,
- const rb_control_frame_t *end_of_cfp)
+ const rb_control_frame_t *end_of_cfp)
{
int i=0;
while (cfp != end_of_cfp) {
- int pc = 0;
- if (cfp->iseq) {
- pc = cfp->pc - cfp->iseq->body->iseq_encoded;
- }
- fprintf(stderr, "%2d pc: %d\n", i++, pc);
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+ int pc = 0;
+ if (cfp->iseq) {
+ pc = cfp->pc - cfp->iseq->body->iseq_encoded;
+ }
+ fprintf(stderr, "%2d pc: %d\n", i++, pc);
+ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
}
#endif
-COMPILER_WARNING_PUSH
-#ifdef __clang__
-COMPILER_WARNING_IGNORED(-Wduplicate-decl-specifier)
-#endif
static VALUE
cont_capture(volatile int *volatile stat)
{
@@ -1187,59 +618,56 @@ cont_capture(volatile int *volatile stat)
cont->saved_vm_stack.clen = ec->vm_stack + ec->vm_stack_size - (VALUE*)ec->cfp;
cont->saved_vm_stack.ptr = ALLOC_N(VALUE, cont->saved_vm_stack.slen + cont->saved_vm_stack.clen);
MEMCPY(cont->saved_vm_stack.ptr,
- ec->vm_stack,
- VALUE, cont->saved_vm_stack.slen);
+ ec->vm_stack,
+ VALUE, cont->saved_vm_stack.slen);
MEMCPY(cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen,
- (VALUE*)ec->cfp,
- VALUE,
- cont->saved_vm_stack.clen);
+ (VALUE*)ec->cfp,
+ VALUE,
+ cont->saved_vm_stack.clen);
#else
cont->saved_vm_stack.ptr = ALLOC_N(VALUE, ec->vm_stack_size);
MEMCPY(cont->saved_vm_stack.ptr, ec->vm_stack, VALUE, ec->vm_stack_size);
#endif
- // At this point, `cfp` is valid but `vm_stack` should be cleared:
- rb_ec_set_vm_stack(&cont->saved_ec, NULL, 0);
- VM_ASSERT(cont->saved_ec.cfp != NULL);
+ ec_set_vm_stack(&cont->saved_ec, NULL, 0);
cont_save_machine_stack(th, cont);
/* backup ensure_list to array for search in another context */
{
- rb_ensure_list_t *p;
- int size = 0;
- rb_ensure_entry_t *entry;
- for (p=th->ec->ensure_list; p; p=p->next)
- size++;
- entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1);
- for (p=th->ec->ensure_list; p; p=p->next) {
- if (!p->entry.marker)
- p->entry.marker = rb_ary_tmp_new(0); /* dummy object */
- *entry++ = p->entry;
- }
- entry->marker = 0;
+ rb_ensure_list_t *p;
+ int size = 0;
+ rb_ensure_entry_t *entry;
+ for (p=th->ec->ensure_list; p; p=p->next)
+ size++;
+ entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1);
+ for (p=th->ec->ensure_list; p; p=p->next) {
+ if (!p->entry.marker)
+ p->entry.marker = rb_ary_tmp_new(0); /* dummy object */
+ *entry++ = p->entry;
+ }
+ entry->marker = 0;
}
if (ruby_setjmp(cont->jmpbuf)) {
- VALUE value;
+ VALUE value;
- VAR_INITIALIZED(cont);
- value = cont->value;
- if (cont->argc == -1) rb_exc_raise(value);
- cont->value = Qnil;
- *stat = 1;
- return value;
+ VAR_INITIALIZED(cont);
+ value = cont->value;
+ if (cont->argc == -1) rb_exc_raise(value);
+ cont->value = Qnil;
+ *stat = 1;
+ return value;
}
else {
- *stat = 0;
- return contval;
+ *stat = 0;
+ return contval;
}
}
-COMPILER_WARNING_POP
static inline void
-fiber_restore_thread(rb_thread_t *th, rb_fiber_t *fiber)
+fiber_restore_thread(rb_thread_t *th, rb_fiber_t *fib)
{
- ec_switch(th, fiber);
- VM_ASSERT(th->ec->fiber_ptr == fiber);
+ ec_switch(th, fib);
+ VM_ASSERT(th->ec->fiber_ptr == fib);
}
static inline void
@@ -1249,93 +677,215 @@ cont_restore_thread(rb_context_t *cont)
/* restore thread context */
if (cont->type == CONTINUATION_CONTEXT) {
- /* continuation */
- rb_execution_context_t *sec = &cont->saved_ec;
- rb_fiber_t *fiber = NULL;
+ /* continuation */
+ rb_execution_context_t *sec = &cont->saved_ec;
+ rb_fiber_t *fib = NULL;
+
+ if (sec->fiber_ptr != NULL) {
+ fib = sec->fiber_ptr;
+ }
+ else if (th->root_fiber) {
+ fib = th->root_fiber;
+ }
+
+ if (fib && th->ec != &fib->cont.saved_ec) {
+ ec_switch(th, fib);
+ }
+
+ /* copy vm stack */
+#ifdef CAPTURE_JUST_VALID_VM_STACK
+ MEMCPY(th->ec->vm_stack,
+ cont->saved_vm_stack.ptr,
+ VALUE, cont->saved_vm_stack.slen);
+ MEMCPY(th->ec->vm_stack + th->ec->vm_stack_size - cont->saved_vm_stack.clen,
+ cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen,
+ VALUE, cont->saved_vm_stack.clen);
+#else
+ MEMCPY(th->ec->vm_stack, cont->saved_vm_stack.ptr, VALUE, sec->vm_stack_size);
+#endif
+ /* other members of ec */
+
+ th->ec->cfp = sec->cfp;
+ th->ec->safe_level = sec->safe_level;
+ th->ec->raised_flag = sec->raised_flag;
+ th->ec->tag = sec->tag;
+ th->ec->protect_tag = sec->protect_tag;
+ th->ec->root_lep = sec->root_lep;
+ th->ec->root_svar = sec->root_svar;
+ th->ec->ensure_list = sec->ensure_list;
+ th->ec->errinfo = sec->errinfo;
+
+ /* trace on -> trace off */
+ if (th->ec->trace_arg != NULL && sec->trace_arg == NULL) {
+ GET_VM()->trace_running--;
+ }
+ /* trace off -> trace on */
+ else if (th->ec->trace_arg == NULL && sec->trace_arg != NULL) {
+ GET_VM()->trace_running++;
+ }
+ th->ec->trace_arg = sec->trace_arg;
+
+ VM_ASSERT(th->ec->vm_stack != NULL);
+ }
+ else {
+ /* fiber */
+ fiber_restore_thread(th, (rb_fiber_t*)cont);
+ }
+}
- if (sec->fiber_ptr != NULL) {
- fiber = sec->fiber_ptr;
- }
- else if (th->root_fiber) {
- fiber = th->root_fiber;
- }
+#if FIBER_USE_NATIVE
+#ifdef _WIN32
+static void
+fiber_set_stack_location(void)
+{
+ rb_thread_t *th = GET_THREAD();
+ VALUE *ptr;
- if (fiber && th->ec != &fiber->cont.saved_ec) {
- ec_switch(th, fiber);
- }
+ SET_MACHINE_STACK_END(&ptr);
+ th->ec->machine.stack_start = (void*)(((VALUE)ptr & RB_PAGE_MASK) + STACK_UPPER((void *)&ptr, 0, RB_PAGE_SIZE));
+}
- if (th->ec->trace_arg != sec->trace_arg) {
- rb_raise(rb_eRuntimeError, "can't call across trace_func");
- }
+static VOID CALLBACK
+fiber_entry(void *arg)
+{
+ fiber_set_stack_location();
+ rb_fiber_start();
+}
+#else /* _WIN32 */
- /* copy vm stack */
-#ifdef CAPTURE_JUST_VALID_VM_STACK
- MEMCPY(th->ec->vm_stack,
- cont->saved_vm_stack.ptr,
- VALUE, cont->saved_vm_stack.slen);
- MEMCPY(th->ec->vm_stack + th->ec->vm_stack_size - cont->saved_vm_stack.clen,
- cont->saved_vm_stack.ptr + cont->saved_vm_stack.slen,
- VALUE, cont->saved_vm_stack.clen);
+/*
+ * FreeBSD require a first (i.e. addr) argument of mmap(2) is not NULL
+ * if MAP_STACK is passed.
+ * http://www.FreeBSD.org/cgi/query-pr.cgi?pr=158755
+ */
+#if defined(MAP_STACK) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
+#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON | MAP_STACK)
#else
- MEMCPY(th->ec->vm_stack, cont->saved_vm_stack.ptr, VALUE, sec->vm_stack_size);
+#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON)
#endif
- /* other members of ec */
- th->ec->cfp = sec->cfp;
- th->ec->raised_flag = sec->raised_flag;
- th->ec->tag = sec->tag;
- th->ec->protect_tag = sec->protect_tag;
- th->ec->root_lep = sec->root_lep;
- th->ec->root_svar = sec->root_svar;
- th->ec->ensure_list = sec->ensure_list;
- th->ec->errinfo = sec->errinfo;
+static char*
+fiber_machine_stack_alloc(size_t size)
+{
+ char *ptr;
- VM_ASSERT(th->ec->vm_stack != NULL);
+ if (machine_stack_cache_index > 0) {
+ if (machine_stack_cache[machine_stack_cache_index - 1].size == (size / sizeof(VALUE))) {
+ ptr = machine_stack_cache[machine_stack_cache_index - 1].ptr;
+ machine_stack_cache_index--;
+ machine_stack_cache[machine_stack_cache_index].ptr = NULL;
+ machine_stack_cache[machine_stack_cache_index].size = 0;
+ }
+ else{
+ /* TODO handle multiple machine stack size */
+ rb_bug("machine_stack_cache size is not canonicalized");
+ }
}
else {
- /* fiber */
- fiber_restore_thread(th, (rb_fiber_t*)cont);
+ void *page;
+ STACK_GROW_DIR_DETECTION;
+
+ errno = 0;
+ ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0);
+ if (ptr == MAP_FAILED) {
+ rb_raise(rb_eFiberError, "can't alloc machine stack to fiber: %s", strerror(errno));
+ }
+
+ /* guard page setup */
+ page = ptr + STACK_DIR_UPPER(size - RB_PAGE_SIZE, 0);
+ if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) {
+ rb_raise(rb_eFiberError, "mprotect failed");
+ }
}
+
+ return ptr;
+}
+#endif
+
+static void
+fiber_initialize_machine_stack_context(rb_fiber_t *fib, size_t size)
+{
+ rb_execution_context_t *sec = &fib->cont.saved_ec;
+
+#ifdef _WIN32
+# if defined(_MSC_VER) && _MSC_VER <= 1200
+# define CreateFiberEx(cs, stacksize, flags, entry, param) \
+ CreateFiber((stacksize), (entry), (param))
+# endif
+ fib->fib_handle = CreateFiberEx(size - 1, size, 0, fiber_entry, NULL);
+ if (!fib->fib_handle) {
+ /* try to release unnecessary fibers & retry to create */
+ rb_gc();
+ fib->fib_handle = CreateFiberEx(size - 1, size, 0, fiber_entry, NULL);
+ if (!fib->fib_handle) {
+ rb_raise(rb_eFiberError, "can't create fiber");
+ }
+ }
+ sec->machine.stack_maxsize = size;
+#else /* not WIN32 */
+ ucontext_t *context = &fib->context;
+ char *ptr;
+ STACK_GROW_DIR_DETECTION;
+
+ getcontext(context);
+ ptr = fiber_machine_stack_alloc(size);
+ context->uc_link = NULL;
+ context->uc_stack.ss_sp = ptr;
+ context->uc_stack.ss_size = size;
+ fib->ss_sp = ptr;
+ fib->ss_size = size;
+ makecontext(context, rb_fiber_start, 0);
+ sec->machine.stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size));
+ sec->machine.stack_maxsize = size - RB_PAGE_SIZE;
+#endif
+#ifdef __ia64
+ sth->machine.register_stack_maxsize = sth->machine.stack_maxsize;
+#endif
}
-NOINLINE(static void fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber));
+NOINLINE(static void fiber_setcontext(rb_fiber_t *newfib, rb_fiber_t *oldfib));
static void
-fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber)
+fiber_setcontext(rb_fiber_t *newfib, rb_fiber_t *oldfib)
{
rb_thread_t *th = GET_THREAD();
- /* save old_fiber's machine stack - to ensure efficient garbage collection */
- if (!FIBER_TERMINATED_P(old_fiber)) {
- STACK_GROW_DIR_DETECTION;
- SET_MACHINE_STACK_END(&th->ec->machine.stack_end);
- if (STACK_DIR_UPPER(0, 1)) {
- old_fiber->cont.machine.stack_size = th->ec->machine.stack_start - th->ec->machine.stack_end;
- old_fiber->cont.machine.stack = th->ec->machine.stack_end;
- }
- else {
- old_fiber->cont.machine.stack_size = th->ec->machine.stack_end - th->ec->machine.stack_start;
- old_fiber->cont.machine.stack = th->ec->machine.stack_start;
- }
+ /* save oldfib's machine stack / TODO: is it needed? */
+ if (!FIBER_TERMINATED_P(oldfib)) {
+ STACK_GROW_DIR_DETECTION;
+ SET_MACHINE_STACK_END(&th->ec->machine.stack_end);
+ if (STACK_DIR_UPPER(0, 1)) {
+ oldfib->cont.machine.stack_size = th->ec->machine.stack_start - th->ec->machine.stack_end;
+ oldfib->cont.machine.stack = th->ec->machine.stack_end;
+ }
+ else {
+ oldfib->cont.machine.stack_size = th->ec->machine.stack_end - th->ec->machine.stack_start;
+ oldfib->cont.machine.stack = th->ec->machine.stack_start;
+ }
}
- /* exchange machine_stack_start between old_fiber and new_fiber */
- old_fiber->cont.saved_ec.machine.stack_start = th->ec->machine.stack_start;
+ /* exchange machine_stack_start between oldfib and newfib */
+ oldfib->cont.saved_ec.machine.stack_start = th->ec->machine.stack_start;
- /* old_fiber->machine.stack_end should be NULL */
- old_fiber->cont.saved_ec.machine.stack_end = NULL;
+ /* oldfib->machine.stack_end should be NULL */
+ oldfib->cont.saved_ec.machine.stack_end = NULL;
/* restore thread context */
- fiber_restore_thread(th, new_fiber);
-
- // if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] -> %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base);
+ fiber_restore_thread(th, newfib);
+#ifndef _WIN32
+ if (!newfib->context.uc_stack.ss_sp && th->root_fiber != newfib) {
+ rb_bug("non_root_fiber->context.uc_stac.ss_sp should not be NULL");
+ }
+#endif
/* swap machine context */
- coroutine_transfer(&old_fiber->context, &new_fiber->context);
-
- // It's possible to get here, and new_fiber is already freed.
- // if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] <- %p[%p]\n", old_fiber, old_fiber->stack.base, new_fiber, new_fiber->stack.base);
+#ifdef _WIN32
+ SwitchToFiber(newfib->fib_handle);
+#else
+ swapcontext(&oldfib->context, &newfib->context);
+#endif
}
+#endif
NOINLINE(NORETURN(static void cont_restore_1(rb_context_t *)));
@@ -1347,24 +897,66 @@ cont_restore_1(rb_context_t *cont)
/* restore machine stack */
#ifdef _M_AMD64
{
- /* workaround for x64 SEH */
- jmp_buf buf;
- setjmp(buf);
- _JUMP_BUFFER *bp = (void*)&cont->jmpbuf;
- bp->Frame = ((_JUMP_BUFFER*)((void*)&buf))->Frame;
+ /* workaround for x64 SEH */
+ jmp_buf buf;
+ setjmp(buf);
+ ((_JUMP_BUFFER*)(&cont->jmpbuf))->Frame =
+ ((_JUMP_BUFFER*)(&buf))->Frame;
}
#endif
if (cont->machine.stack_src) {
- FLUSH_REGISTER_WINDOWS;
- MEMCPY(cont->machine.stack_src, cont->machine.stack,
- VALUE, cont->machine.stack_size);
+ FLUSH_REGISTER_WINDOWS;
+ MEMCPY(cont->machine.stack_src, cont->machine.stack,
+ VALUE, cont->machine.stack_size);
}
+#ifdef __ia64
+ if (cont->machine.register_stack_src) {
+ MEMCPY(cont->machine.register_stack_src, cont->machine.register_stack,
+ VALUE, cont->machine.register_stack_size);
+ }
+#endif
+
ruby_longjmp(cont->jmpbuf, 1);
}
NORETURN(NOINLINE(static void cont_restore_0(rb_context_t *, VALUE *)));
+#ifdef __ia64
+#define C(a) rse_##a##0, rse_##a##1, rse_##a##2, rse_##a##3, rse_##a##4
+#define E(a) rse_##a##0= rse_##a##1= rse_##a##2= rse_##a##3= rse_##a##4
+static volatile int C(a), C(b), C(c), C(d), C(e);
+static volatile int C(f), C(g), C(h), C(i), C(j);
+static volatile int C(k), C(l), C(m), C(n), C(o);
+static volatile int C(p), C(q), C(r), C(s), C(t);
+#if 0
+{/* the above lines make cc-mode.el confused so much */}
+#endif
+int rb_dummy_false = 0;
+NORETURN(NOINLINE(static void register_stack_extend(rb_context_t *, VALUE *, VALUE *)));
+static void
+register_stack_extend(rb_context_t *cont, VALUE *vp, VALUE *curr_bsp)
+{
+ if (rb_dummy_false) {
+ /* use registers as much as possible */
+ E(a) = E(b) = E(c) = E(d) = E(e) =
+ E(f) = E(g) = E(h) = E(i) = E(j) =
+ E(k) = E(l) = E(m) = E(n) = E(o) =
+ E(p) = E(q) = E(r) = E(s) = E(t) = 0;
+ E(a) = E(b) = E(c) = E(d) = E(e) =
+ E(f) = E(g) = E(h) = E(i) = E(j) =
+ E(k) = E(l) = E(m) = E(n) = E(o) =
+ E(p) = E(q) = E(r) = E(s) = E(t) = 0;
+ }
+ if (curr_bsp < cont->machine.register_stack_src+cont->machine.register_stack_size) {
+ register_stack_extend(cont, vp, (VALUE*)rb_ia64_bsp());
+ }
+ cont_restore_0(cont, vp);
+}
+#undef C
+#undef E
+#endif
+
static void
cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
{
@@ -1374,45 +966,48 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
#else
#define STACK_PAD_SIZE 1024
#endif
- VALUE space[STACK_PAD_SIZE];
+ VALUE space[STACK_PAD_SIZE];
#if !STACK_GROW_DIRECTION
- if (addr_in_prev_frame > &space[0]) {
- /* Stack grows downward */
+ if (addr_in_prev_frame > &space[0]) {
+ /* Stack grows downward */
#endif
#if STACK_GROW_DIRECTION <= 0
- volatile VALUE *const end = cont->machine.stack_src;
- if (&space[0] > end) {
+ volatile VALUE *const end = cont->machine.stack_src;
+ if (&space[0] > end) {
# ifdef HAVE_ALLOCA
- volatile VALUE *sp = ALLOCA_N(VALUE, &space[0] - end);
- space[0] = *sp;
+ volatile VALUE *sp = ALLOCA_N(VALUE, &space[0] - end);
+ space[0] = *sp;
# else
- cont_restore_0(cont, &space[0]);
+ cont_restore_0(cont, &space[0]);
# endif
- }
+ }
#endif
#if !STACK_GROW_DIRECTION
- }
- else {
- /* Stack grows upward */
+ }
+ else {
+ /* Stack grows upward */
#endif
#if STACK_GROW_DIRECTION >= 0
- volatile VALUE *const end = cont->machine.stack_src + cont->machine.stack_size;
- if (&space[STACK_PAD_SIZE] < end) {
+ volatile VALUE *const end = cont->machine.stack_src + cont->machine.stack_size;
+ if (&space[STACK_PAD_SIZE] < end) {
# ifdef HAVE_ALLOCA
- volatile VALUE *sp = ALLOCA_N(VALUE, end - &space[STACK_PAD_SIZE]);
- space[0] = *sp;
+ volatile VALUE *sp = ALLOCA_N(VALUE, end - &space[STACK_PAD_SIZE]);
+ space[0] = *sp;
# else
- cont_restore_0(cont, &space[STACK_PAD_SIZE-1]);
+ cont_restore_0(cont, &space[STACK_PAD_SIZE-1]);
# endif
- }
+ }
#endif
#if !STACK_GROW_DIRECTION
- }
+ }
#endif
}
cont_restore_1(cont);
}
+#ifdef __ia64
+#define cont_restore_0(cont, vp) register_stack_extend((cont), (vp), (VALUE*)rb_ia64_bsp())
+#endif
/*
* Document-class: Continuation
@@ -1420,7 +1015,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
* Continuation objects are generated by Kernel#callcc,
* after having +require+d <i>continuation</i>. They hold
* a return address and execution context, allowing a nonlocal return
- * to the end of the #callcc block from anywhere within a
+ * to the end of the <code>callcc</code> block from anywhere within a
* program. Continuations are somewhat analogous to a structured
* version of C's <code>setjmp/longjmp</code> (although they contain
* more state, so you might consider them closer to threads).
@@ -1464,7 +1059,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
* require "continuation"
* callcc {|cont|
* for i in 0..4
- * print "#{i}: "
+ * print "\n#{i}: "
* for j in i*5...(i+1)*5
* cont.call() if j == 17
* printf "%3d", j
@@ -1504,10 +1099,10 @@ rb_callcc(VALUE self)
volatile VALUE val = cont_capture(&called);
if (called) {
- return val;
+ return val;
}
else {
- return rb_yield(val);
+ return rb_yield(val);
}
}
@@ -1515,39 +1110,35 @@ static VALUE
make_passing_arg(int argc, const VALUE *argv)
{
switch (argc) {
- case -1:
- return argv[0];
case 0:
- return Qnil;
+ return Qnil;
case 1:
- return argv[0];
+ return argv[0];
default:
- return rb_ary_new4(argc, argv);
+ return rb_ary_new4(argc, argv);
}
}
-typedef VALUE e_proc(VALUE);
-
/* CAUTION!! : Currently, error in rollback_func is not supported */
/* same as rb_protect if set rollback_func to NULL */
void
-ruby_register_rollback_func_for_ensure(e_proc *ensure_func, e_proc *rollback_func)
+ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*rollback_func)(ANYARGS))
{
st_table **table_p = &GET_VM()->ensure_rollback_table;
if (UNLIKELY(*table_p == NULL)) {
- *table_p = st_init_numtable();
+ *table_p = st_init_numtable();
}
st_insert(*table_p, (st_data_t)ensure_func, (st_data_t)rollback_func);
}
-static inline e_proc *
-lookup_rollback_func(e_proc *ensure_func)
+static inline VALUE
+lookup_rollback_func(VALUE (*ensure_func)(ANYARGS))
{
st_table *table = GET_VM()->ensure_rollback_table;
st_data_t val;
if (table && st_lookup(table, (st_data_t)ensure_func, &val))
- return (e_proc *) val;
- return (e_proc *) Qundef;
+ return (VALUE) val;
+ return Qundef;
}
@@ -1556,49 +1147,49 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
{
rb_ensure_list_t *p;
rb_ensure_entry_t *entry;
- size_t i, j;
+ size_t i;
size_t cur_size;
size_t target_size;
size_t base_point;
- e_proc *func;
+ VALUE (*func)(ANYARGS);
cur_size = 0;
for (p=current; p; p=p->next)
- cur_size++;
+ cur_size++;
target_size = 0;
for (entry=target; entry->marker; entry++)
- target_size++;
+ target_size++;
/* search common stack point */
p = current;
base_point = cur_size;
while (base_point) {
- if (target_size >= base_point &&
- p->entry.marker == target[target_size - base_point].marker)
- break;
- base_point --;
- p = p->next;
+ if (target_size >= base_point &&
+ p->entry.marker == target[target_size - base_point].marker)
+ break;
+ base_point --;
+ p = p->next;
}
/* rollback function check */
for (i=0; i < target_size - base_point; i++) {
- if (!lookup_rollback_func(target[i].e_proc)) {
- rb_raise(rb_eRuntimeError, "continuation called from out of critical rb_ensure scope");
- }
+ if (!lookup_rollback_func(target[i].e_proc)) {
+ rb_raise(rb_eRuntimeError, "continuation called from out of critical rb_ensure scope");
+ }
}
/* pop ensure stack */
while (cur_size > base_point) {
- /* escape from ensure block */
- (*current->entry.e_proc)(current->entry.data2);
- current = current->next;
- cur_size--;
+ /* escape from ensure block */
+ (*current->entry.e_proc)(current->entry.data2);
+ current = current->next;
+ cur_size--;
}
/* push ensure stack */
- for (j = 0; j < i; j++) {
- func = lookup_rollback_func(target[i - j - 1].e_proc);
- if ((VALUE)func != Qundef) {
- (*func)(target[i - j - 1].data2);
- }
+ while (i--) {
+ func = (VALUE (*)(ANYARGS)) lookup_rollback_func(target[i].e_proc);
+ if ((VALUE)func != Qundef) {
+ (*func)(target[i].data2);
+ }
}
}
@@ -1607,10 +1198,11 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
* cont.call(args, ...)
* cont[args, ...]
*
- * Invokes the continuation. The program continues from the end of
- * the #callcc block. If no arguments are given, the original #callcc
- * returns +nil+. If one argument is given, #callcc returns
- * it. Otherwise, an array containing <i>args</i> is returned.
+ * Invokes the continuation. The program continues from the end of the
+ * <code>callcc</code> block. If no arguments are given, the original
+ * <code>callcc</code> returns <code>nil</code>. If one argument is
+ * given, <code>callcc</code> returns it. Otherwise, an array
+ * containing <i>args</i> is returned.
*
* callcc {|cont| cont.call } #=> nil
* callcc {|cont| cont.call 1 } #=> 1
@@ -1620,19 +1212,20 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
static VALUE
rb_cont_call(int argc, VALUE *argv, VALUE contval)
{
- rb_context_t *cont = cont_ptr(contval);
+ rb_context_t *cont;
rb_thread_t *th = GET_THREAD();
+ GetContPtr(contval, cont);
if (cont_thread_value(cont) != th->self) {
- rb_raise(rb_eRuntimeError, "continuation called across threads");
+ rb_raise(rb_eRuntimeError, "continuation called across threads");
}
if (cont->saved_ec.protect_tag != th->ec->protect_tag) {
- rb_raise(rb_eRuntimeError, "continuation called across stack rewinding barrier");
+ rb_raise(rb_eRuntimeError, "continuation called across stack rewinding barrier");
}
if (cont->saved_ec.fiber_ptr) {
- if (th->ec->fiber_ptr != cont->saved_ec.fiber_ptr) {
- rb_raise(rb_eRuntimeError, "continuation called across fiber");
- }
+ if (th->ec->fiber_ptr != cont->saved_ec.fiber_ptr) {
+ rb_raise(rb_eRuntimeError, "continuation called across fiber");
+ }
}
rollback_ensure_stack(contval, th->ec->ensure_list, cont->ensure_array);
@@ -1662,10 +1255,10 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
* manpage to configure the size of the fiber stack(s).
*
* When a fiber is created it will not run automatically. Rather it must
- * be explicitly asked to run using the Fiber#resume method.
+ * be explicitly asked to run using the <code>Fiber#resume</code> method.
* The code running inside the fiber can give up control by calling
- * Fiber.yield in which case it yields control back to caller (the
- * caller of the Fiber#resume).
+ * <code>Fiber.yield</code> in which case it yields control back to caller
+ * (the caller of the <code>Fiber#resume</code>).
*
* Upon yielding or termination the Fiber returns the value of the last
* executed expression
@@ -1687,10 +1280,10 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
* 2
* FiberError: dead fiber called
*
- * The Fiber#resume method accepts an arbitrary number of parameters,
- * if it is the first call to #resume then they will be passed as
- * block arguments. Otherwise they will be the return value of the
- * call to Fiber.yield
+ * The <code>Fiber#resume</code> method accepts an arbitrary number of
+ * parameters, if it is the first call to <code>resume</code> then they
+ * will be passed as block arguments. Otherwise they will be the return
+ * value of the call to <code>Fiber.yield</code>
*
* Example:
*
@@ -1699,20 +1292,20 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
* end
*
* puts fiber.resume 10
- * puts fiber.resume 1_000_000
- * puts fiber.resume "The fiber will be dead before I can cause trouble"
+ * puts fiber.resume 14
+ * puts fiber.resume 18
*
* <em>produces</em>
*
* 12
- * 1000000
+ * 14
* FiberError: dead fiber called
*
*/
static const rb_data_type_t fiber_data_type = {
"fiber",
- {fiber_mark, fiber_free, fiber_memsize, fiber_compact,},
+ {fiber_mark, fiber_free, fiber_memsize,},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -1723,208 +1316,215 @@ fiber_alloc(VALUE klass)
}
static rb_fiber_t*
-fiber_t_alloc(VALUE fiber_value)
+fiber_t_alloc(VALUE fibval)
{
- rb_fiber_t *fiber;
+ rb_fiber_t *fib;
rb_thread_t *th = GET_THREAD();
- if (DATA_PTR(fiber_value) != 0) {
- rb_raise(rb_eRuntimeError, "cannot initialize twice");
+ if (DATA_PTR(fibval) != 0) {
+ rb_raise(rb_eRuntimeError, "cannot initialize twice");
}
THREAD_MUST_BE_RUNNING(th);
- fiber = ZALLOC(rb_fiber_t);
- fiber->cont.self = fiber_value;
- fiber->cont.type = FIBER_CONTEXT;
- cont_init(&fiber->cont, th);
-
- fiber->cont.saved_ec.fiber_ptr = fiber;
- rb_ec_clear_vm_stack(&fiber->cont.saved_ec);
-
- fiber->prev = NULL;
-
- /* fiber->status == 0 == CREATED
- * So that we don't need to set status: fiber_status_set(fiber, FIBER_CREATED); */
- VM_ASSERT(FIBER_CREATED_P(fiber));
-
- DATA_PTR(fiber_value) = fiber;
-
- return fiber;
-}
+ fib = ZALLOC(rb_fiber_t);
+ fib->cont.self = fibval;
+ fib->cont.type = FIBER_CONTEXT;
+ cont_init(&fib->cont, th);
+ fib->cont.saved_ec.fiber_ptr = fib;
+ fib->prev = NULL;
+
+ /* fib->status == 0 == CREATED
+ * So that we don't need to set status: fiber_status_set(fib, FIBER_CREATED); */
+ VM_ASSERT(FIBER_CREATED_P(fib));
+
+ DATA_PTR(fibval) = fib;
+
+ return fib;
+}
+
+rb_control_frame_t *
+rb_vm_push_frame(rb_execution_context_t *sec,
+ const rb_iseq_t *iseq,
+ VALUE type,
+ VALUE self,
+ VALUE specval,
+ VALUE cref_or_me,
+ const VALUE *pc,
+ VALUE *sp,
+ int local_size,
+ int stack_max);
static VALUE
-fiber_initialize(VALUE self, VALUE proc, struct fiber_pool * fiber_pool)
+fiber_init(VALUE fibval, VALUE proc)
{
- rb_fiber_t *fiber = fiber_t_alloc(self);
-
- fiber->first_proc = proc;
- fiber->stack.base = NULL;
- fiber->stack.pool = fiber_pool;
-
- return self;
-}
-
-static void
-fiber_prepare_stack(rb_fiber_t *fiber)
-{
- rb_context_t *cont = &fiber->cont;
+ rb_fiber_t *fib = fiber_t_alloc(fibval);
+ rb_context_t *cont = &fib->cont;
rb_execution_context_t *sec = &cont->saved_ec;
-
- size_t vm_stack_size = 0;
- VALUE *vm_stack = fiber_initialize_coroutine(fiber, &vm_stack_size);
+ rb_thread_t *cth = GET_THREAD();
+ size_t fib_stack_size = cth->vm->default_params.fiber_vm_stack_size / sizeof(VALUE);
/* initialize cont */
cont->saved_vm_stack.ptr = NULL;
- rb_ec_initialize_vm_stack(sec, vm_stack, vm_stack_size / sizeof(VALUE));
+ ec_set_vm_stack(sec, NULL, 0);
+
+ ec_set_vm_stack(sec, ALLOC_N(VALUE, fib_stack_size), fib_stack_size);
+ sec->cfp = (void *)(sec->vm_stack + sec->vm_stack_size);
+
+ rb_vm_push_frame(sec,
+ NULL,
+ VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME,
+ Qnil, /* self */
+ VM_BLOCK_HANDLER_NONE,
+ 0, /* specval */
+ NULL, /* pc */
+ sec->vm_stack, /* sp */
+ 0, /* local_size */
+ 0);
sec->tag = NULL;
sec->local_storage = NULL;
sec->local_storage_recursive_hash = Qnil;
sec->local_storage_recursive_hash_for_trace = Qnil;
+
+ fib->first_proc = proc;
+
+#if !FIBER_USE_NATIVE
+ MEMCPY(&cont->jmpbuf, &cth->root_jmpbuf, rb_jmpbuf_t, 1);
+#endif
+
+ return fibval;
}
/* :nodoc: */
static VALUE
-rb_fiber_initialize(int argc, VALUE* argv, VALUE self)
+rb_fiber_init(VALUE fibval)
{
- return fiber_initialize(self, rb_block_proc(), &shared_fiber_pool);
+ return fiber_init(fibval, rb_block_proc());
}
VALUE
-rb_fiber_new(rb_block_call_func_t func, VALUE obj)
+rb_fiber_new(VALUE (*func)(ANYARGS), VALUE obj)
{
- return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), &shared_fiber_pool);
+ return fiber_init(fiber_alloc(rb_cFiber), rb_proc_new(func, obj));
}
-NORETURN(static void rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt));
-
-#define PASS_KW_SPLAT (rb_empty_keyword_given_p() ? RB_PASS_EMPTY_KEYWORDS : rb_keyword_given_p())
+static void rb_fiber_terminate(rb_fiber_t *fib, int need_interrupt);
void
rb_fiber_start(void)
{
rb_thread_t * volatile th = GET_THREAD();
- rb_fiber_t *fiber = th->ec->fiber_ptr;
+ rb_fiber_t *fib = th->ec->fiber_ptr;
rb_proc_t *proc;
enum ruby_tag_type state;
int need_interrupt = TRUE;
VM_ASSERT(th->ec == ruby_current_execution_context_ptr);
- VM_ASSERT(FIBER_RESUMED_P(fiber));
+ VM_ASSERT(FIBER_RESUMED_P(fib));
EC_PUSH_TAG(th->ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- rb_context_t *cont = &VAR_FROM_MEMORY(fiber)->cont;
- int argc;
- const VALUE *argv, args = cont->value;
- int kw_splat = cont->kw_splat;
- GetProcPtr(fiber->first_proc, proc);
- argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
- cont->value = Qnil;
- th->ec->errinfo = Qnil;
- th->ec->root_lep = rb_vm_proc_local_ep(fiber->first_proc);
- th->ec->root_svar = Qfalse;
-
- EXEC_EVENT_HOOK(th->ec, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil);
- rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
- cont->value = rb_vm_invoke_proc(th->ec, proc, argc, argv, kw_splat, VM_BLOCK_HANDLER_NONE);
+ rb_context_t *cont = &VAR_FROM_MEMORY(fib)->cont;
+ int argc;
+ const VALUE *argv, args = cont->value;
+ GetProcPtr(fib->first_proc, proc);
+ argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
+ cont->value = Qnil;
+ th->ec->errinfo = Qnil;
+ th->ec->root_lep = rb_vm_proc_local_ep(fib->first_proc);
+ th->ec->root_svar = Qfalse;
+
+ EXEC_EVENT_HOOK(th->ec, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil);
+ cont->value = rb_vm_invoke_proc(th->ec, proc, argc, argv, VM_BLOCK_HANDLER_NONE);
}
EC_POP_TAG();
if (state) {
- VALUE err = th->ec->errinfo;
- VM_ASSERT(FIBER_RESUMED_P(fiber));
-
- if (state == TAG_RAISE || state == TAG_FATAL) {
- rb_threadptr_pending_interrupt_enque(th, err);
- }
- else {
- err = rb_vm_make_jump_tag_but_local_jump(state, err);
- if (!NIL_P(err)) {
- rb_threadptr_pending_interrupt_enque(th, err);
- }
- }
- need_interrupt = TRUE;
- }
-
- rb_fiber_terminate(fiber, need_interrupt);
+ VALUE err = th->ec->errinfo;
+ VM_ASSERT(FIBER_RESUMED_P(fib));
+
+ if (state == TAG_RAISE || state == TAG_FATAL) {
+ rb_threadptr_pending_interrupt_enque(th, err);
+ }
+ else {
+ err = rb_vm_make_jump_tag_but_local_jump(state, err);
+ if (!NIL_P(err)) {
+ rb_threadptr_pending_interrupt_enque(th, err);
+ }
+ }
+ need_interrupt = TRUE;
+ }
+
+ rb_fiber_terminate(fib, need_interrupt);
VM_UNREACHABLE(rb_fiber_start);
}
static rb_fiber_t *
root_fiber_alloc(rb_thread_t *th)
{
- VALUE fiber_value = fiber_alloc(rb_cFiber);
- rb_fiber_t *fiber = th->ec->fiber_ptr;
-
- VM_ASSERT(DATA_PTR(fiber_value) == NULL);
- VM_ASSERT(fiber->cont.type == FIBER_CONTEXT);
- VM_ASSERT(fiber->status == FIBER_RESUMED);
+ VALUE fibval = fiber_alloc(rb_cFiber);
+ rb_fiber_t *fib = th->ec->fiber_ptr;
- th->root_fiber = fiber;
- DATA_PTR(fiber_value) = fiber;
- fiber->cont.self = fiber_value;
+ VM_ASSERT(DATA_PTR(fibval) == NULL);
+ VM_ASSERT(fib->cont.type == ROOT_FIBER_CONTEXT);
+ VM_ASSERT(fib->status == FIBER_RESUMED);
-#ifdef COROUTINE_PRIVATE_STACK
- fiber->stack = fiber_pool_stack_acquire(&shared_fiber_pool);
- coroutine_initialize_main(&fiber->context, fiber_pool_stack_base(&fiber->stack), fiber->stack.available, th->ec->machine.stack_start);
-#else
- coroutine_initialize_main(&fiber->context);
+ th->root_fiber = fib;
+ DATA_PTR(fibval) = fib;
+ fib->cont.self = fibval;
+#if FIBER_USE_NATIVE
+#ifdef _WIN32
+ if (fib->fib_handle == 0) {
+ fib->fib_handle = ConvertThreadToFiber(0);
+ }
#endif
-
- return fiber;
+#endif
+ return fib;
}
void
rb_threadptr_root_fiber_setup(rb_thread_t *th)
{
- rb_fiber_t *fiber = ruby_mimmalloc(sizeof(rb_fiber_t));
- if (!fiber) {
- rb_bug("%s", strerror(errno)); /* ... is it possible to call rb_bug here? */
+ rb_fiber_t *fib = ruby_mimmalloc(sizeof(rb_fiber_t));
+ MEMZERO(fib, rb_fiber_t, 1);
+ fib->cont.type = ROOT_FIBER_CONTEXT;
+ fib->cont.saved_ec.fiber_ptr = fib;
+ fib->cont.saved_ec.thread_ptr = th;
+ fiber_status_set(fib, FIBER_RESUMED); /* skip CREATED */
+ th->ec = &fib->cont.saved_ec;
+#if FIBER_USE_NATIVE
+#ifdef _WIN32
+ if (fib->fib_handle == 0) {
+ fib->fib_handle = ConvertThreadToFiber(0);
}
- MEMZERO(fiber, rb_fiber_t, 1);
- fiber->cont.type = FIBER_CONTEXT;
- fiber->cont.saved_ec.fiber_ptr = fiber;
- fiber->cont.saved_ec.thread_ptr = th;
- fiber_status_set(fiber, FIBER_RESUMED); /* skip CREATED */
- th->ec = &fiber->cont.saved_ec;
+#endif
+#endif
}
void
rb_threadptr_root_fiber_release(rb_thread_t *th)
{
if (th->root_fiber) {
- /* ignore. A root fiber object will free th->ec */
+ /* ignore. A root fiber object will free th->ec */
}
else {
- VM_ASSERT(th->ec->fiber_ptr->cont.type == FIBER_CONTEXT);
- VM_ASSERT(th->ec->fiber_ptr->cont.self == 0);
- fiber_free(th->ec->fiber_ptr);
+ VM_ASSERT(th->ec->fiber_ptr->cont.type == ROOT_FIBER_CONTEXT);
+ VM_ASSERT(th->ec->fiber_ptr->cont.self == 0);
+ fiber_free(th->ec->fiber_ptr);
- if (th->ec == ruby_current_execution_context_ptr) {
- ruby_current_execution_context_ptr = NULL;
- }
- th->ec = NULL;
+ if (th->ec == ruby_current_execution_context_ptr) {
+ ruby_current_execution_context_ptr = NULL;
+ }
+ th->ec = NULL;
}
}
-void
-rb_threadptr_root_fiber_terminate(rb_thread_t *th)
-{
- rb_fiber_t *fiber = th->ec->fiber_ptr;
-
- fiber->status = FIBER_TERMINATED;
-
- // The vm_stack is `alloca`ed on the thread stack, so it's gone too:
- rb_ec_clear_vm_stack(th->ec);
-}
-
static inline rb_fiber_t*
fiber_current(void)
{
rb_execution_context_t *ec = GET_EC();
if (ec->fiber_ptr->cont.self == 0) {
- root_fiber_alloc(rb_ec_thread_ptr(ec));
+ root_fiber_alloc(rb_ec_thread_ptr(ec));
}
return ec->fiber_ptr;
}
@@ -1932,23 +1532,23 @@ fiber_current(void)
static inline rb_fiber_t*
return_fiber(void)
{
- rb_fiber_t *fiber = fiber_current();
- rb_fiber_t *prev = fiber->prev;
+ rb_fiber_t *fib = fiber_current();
+ rb_fiber_t *prev = fib->prev;
if (!prev) {
- rb_thread_t *th = GET_THREAD();
- rb_fiber_t *root_fiber = th->root_fiber;
+ rb_thread_t *th = GET_THREAD();
+ rb_fiber_t *root_fiber = th->root_fiber;
- VM_ASSERT(root_fiber != NULL);
+ VM_ASSERT(root_fiber != NULL);
- if (root_fiber == fiber) {
- rb_raise(rb_eFiberError, "can't yield from root fiber");
- }
- return root_fiber;
+ if (root_fiber == fib) {
+ rb_raise(rb_eFiberError, "can't yield from root fiber");
+ }
+ return root_fiber;
}
else {
- fiber->prev = NULL;
- return prev;
+ fib->prev = NULL;
+ return prev;
}
}
@@ -1958,102 +1558,140 @@ rb_fiber_current(void)
return fiber_current()->cont.self;
}
-// Prepare to execute next_fiber on the given thread.
static inline VALUE
-fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th)
+fiber_store(rb_fiber_t *next_fib, rb_thread_t *th)
{
- rb_fiber_t *fiber;
+ rb_fiber_t *fib;
if (th->ec->fiber_ptr != NULL) {
- fiber = th->ec->fiber_ptr;
+ fib = th->ec->fiber_ptr;
}
else {
- /* create root fiber */
- fiber = root_fiber_alloc(th);
- }
-
- if (FIBER_CREATED_P(next_fiber)) {
- fiber_prepare_stack(next_fiber);
+ /* create root fiber */
+ fib = root_fiber_alloc(th);
}
- VM_ASSERT(FIBER_RESUMED_P(fiber) || FIBER_TERMINATED_P(fiber));
- VM_ASSERT(FIBER_RUNNABLE_P(next_fiber));
+ VM_ASSERT(FIBER_RESUMED_P(fib) || FIBER_TERMINATED_P(fib));
+ VM_ASSERT(FIBER_RUNNABLE_P(next_fib));
- if (FIBER_RESUMED_P(fiber)) fiber_status_set(fiber, FIBER_SUSPENDED);
+#if FIBER_USE_NATIVE
+ if (FIBER_CREATED_P(next_fib)) {
+ fiber_initialize_machine_stack_context(next_fib, th->vm->default_params.fiber_machine_stack_size);
+ }
+#endif
- fiber_status_set(next_fiber, FIBER_RESUMED);
- fiber_setcontext(next_fiber, fiber);
+ if (FIBER_RESUMED_P(fib)) fiber_status_set(fib, FIBER_SUSPENDED);
- fiber = th->ec->fiber_ptr;
+#if FIBER_USE_NATIVE == 0
+ /* should (re-)allocate stack are before fib->status change to pass fiber_verify() */
+ cont_save_machine_stack(th, &fib->cont);
+#endif
- /* Raise an exception if that was the result of executing the fiber */
- if (fiber->cont.argc == -1) rb_exc_raise(fiber->cont.value);
+ fiber_status_set(next_fib, FIBER_RESUMED);
- return fiber->cont.value;
+#if FIBER_USE_NATIVE
+ fiber_setcontext(next_fib, fib);
+ /* restored */
+#ifndef _WIN32
+ if (terminated_machine_stack.ptr) {
+ if (machine_stack_cache_index < MAX_MACHINE_STACK_CACHE) {
+ machine_stack_cache[machine_stack_cache_index].ptr = terminated_machine_stack.ptr;
+ machine_stack_cache[machine_stack_cache_index].size = terminated_machine_stack.size;
+ machine_stack_cache_index++;
+ }
+ else {
+ if (terminated_machine_stack.ptr != fib->cont.machine.stack) {
+ munmap((void*)terminated_machine_stack.ptr, terminated_machine_stack.size * sizeof(VALUE));
+ }
+ else {
+ rb_bug("terminated fiber resumed");
+ }
+ }
+ terminated_machine_stack.ptr = NULL;
+ terminated_machine_stack.size = 0;
+ }
+#endif /* not _WIN32 */
+ fib = th->ec->fiber_ptr;
+ if (fib->cont.argc == -1) rb_exc_raise(fib->cont.value);
+ return fib->cont.value;
+
+#else /* FIBER_USE_NATIVE */
+ fib->cont.saved_ec.machine.stack_end = NULL;
+ if (ruby_setjmp(fib->cont.jmpbuf)) {
+ /* restored */
+ fib = th->ec->fiber_ptr;
+ if (fib->cont.argc == -1) rb_exc_raise(fib->cont.value);
+ if (next_fib->cont.value == Qundef) {
+ cont_restore_0(&next_fib->cont, &next_fib->cont.value);
+ VM_UNREACHABLE(fiber_store);
+ }
+ return fib->cont.value;
+ }
+ else {
+ VALUE undef = Qundef;
+ cont_restore_0(&next_fib->cont, &undef);
+ VM_UNREACHABLE(fiber_store);
+ }
+#endif /* FIBER_USE_NATIVE */
}
static inline VALUE
-fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int is_resume, int kw_splat)
+fiber_switch(rb_fiber_t *fib, int argc, const VALUE *argv, int is_resume)
{
VALUE value;
- rb_context_t *cont = &fiber->cont;
+ rb_context_t *cont = &fib->cont;
rb_thread_t *th = GET_THREAD();
/* make sure the root_fiber object is available */
if (th->root_fiber == NULL) root_fiber_alloc(th);
- if (th->ec->fiber_ptr == fiber) {
- /* ignore fiber context switch
+ if (th->ec->fiber_ptr == fib) {
+ /* ignore fiber context switch
* because destination fiber is same as current fiber
- */
- return make_passing_arg(argc, argv);
+ */
+ return make_passing_arg(argc, argv);
}
if (cont_thread_value(cont) != th->self) {
- rb_raise(rb_eFiberError, "fiber called across threads");
+ rb_raise(rb_eFiberError, "fiber called across threads");
}
else if (cont->saved_ec.protect_tag != th->ec->protect_tag) {
- rb_raise(rb_eFiberError, "fiber called across stack rewinding barrier");
- }
- else if (FIBER_TERMINATED_P(fiber)) {
- value = rb_exc_new2(rb_eFiberError, "dead fiber called");
-
- if (!FIBER_TERMINATED_P(th->ec->fiber_ptr)) {
- rb_exc_raise(value);
- VM_UNREACHABLE(fiber_switch);
- }
- else {
- /* th->ec->fiber_ptr is also dead => switch to root fiber */
- /* (this means we're being called from rb_fiber_terminate, */
- /* and the terminated fiber's return_fiber() is already dead) */
- VM_ASSERT(FIBER_SUSPENDED_P(th->root_fiber));
-
- cont = &th->root_fiber->cont;
- cont->argc = -1;
- cont->value = value;
-
- fiber_setcontext(th->root_fiber, th->ec->fiber_ptr);
-
- VM_UNREACHABLE(fiber_switch);
- }
+ rb_raise(rb_eFiberError, "fiber called across stack rewinding barrier");
+ }
+ else if (FIBER_TERMINATED_P(fib)) {
+ value = rb_exc_new2(rb_eFiberError, "dead fiber called");
+
+ if (!FIBER_TERMINATED_P(th->ec->fiber_ptr)) {
+ rb_exc_raise(value);
+ VM_UNREACHABLE(fiber_switch);
+ }
+ else {
+ /* th->ec->fiber_ptr is also dead => switch to root fiber */
+ /* (this means we're being called from rb_fiber_terminate, */
+ /* and the terminated fiber's return_fiber() is already dead) */
+ VM_ASSERT(FIBER_SUSPENDED_P(th->root_fiber));
+
+ cont = &th->root_fiber->cont;
+ cont->argc = -1;
+ cont->value = value;
+#if FIBER_USE_NATIVE
+ fiber_setcontext(th->root_fiber, th->ec->fiber_ptr);
+#else
+ cont_restore_0(cont, &value);
+#endif
+ VM_UNREACHABLE(fiber_switch);
+ }
}
if (is_resume) {
- fiber->prev = fiber_current();
+ fib->prev = fiber_current();
}
- VM_ASSERT(FIBER_RUNNABLE_P(fiber));
+ VM_ASSERT(FIBER_RUNNABLE_P(fib));
cont->argc = argc;
- cont->kw_splat = kw_splat;
cont->value = make_passing_arg(argc, argv);
-
- value = fiber_store(fiber, th);
-
- if (is_resume && FIBER_TERMINATED_P(fiber)) {
- fiber_stack_release(fiber);
- }
-
+ value = fiber_store(fib, th);
RUBY_VM_CHECK_INTS(th->ec);
EXEC_EVENT_HOOK(th->ec, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil);
@@ -2062,80 +1700,85 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int is_resume, int
}
VALUE
-rb_fiber_transfer(VALUE fiber_value, int argc, const VALUE *argv)
+rb_fiber_transfer(VALUE fibval, int argc, const VALUE *argv)
{
- return fiber_switch(fiber_ptr(fiber_value), argc, argv, 0, RB_NO_KEYWORDS);
+ rb_fiber_t *fib;
+ GetFiberPtr(fibval, fib);
+ return fiber_switch(fib, argc, argv, 0);
}
void
-rb_fiber_close(rb_fiber_t *fiber)
+rb_fiber_close(rb_fiber_t *fib)
{
- fiber_status_set(fiber, FIBER_TERMINATED);
+ VALUE *vm_stack = fib->cont.saved_ec.vm_stack;
+ fiber_status_set(fib, FIBER_TERMINATED);
+ if (fib->cont.type == ROOT_FIBER_CONTEXT) {
+ rb_thread_recycle_stack_release(vm_stack);
+ }
+ else {
+ ruby_xfree(vm_stack);
+ }
+ ec_set_vm_stack(&fib->cont.saved_ec, NULL, 0);
+
+#if !FIBER_USE_NATIVE
+ /* should not mark machine stack any more */
+ fib->cont.saved_ec.machine.stack_end = NULL;
+#endif
}
static void
-rb_fiber_terminate(rb_fiber_t *fiber, int need_interrupt)
-{
- VALUE value = fiber->cont.value;
- rb_fiber_t *next_fiber;
-
- VM_ASSERT(FIBER_RESUMED_P(fiber));
- rb_fiber_close(fiber);
-
- coroutine_destroy(&fiber->context);
-
- fiber->cont.machine.stack = NULL;
- fiber->cont.machine.stack_size = 0;
+rb_fiber_terminate(rb_fiber_t *fib, int need_interrupt)
+{
+ VALUE value = fib->cont.value;
+ rb_fiber_t *ret_fib;
+
+ VM_ASSERT(FIBER_RESUMED_P(fib));
+ rb_fiber_close(fib);
+
+#if FIBER_USE_NATIVE && !defined(_WIN32)
+ /* Ruby must not switch to other thread until storing terminated_machine_stack */
+ terminated_machine_stack.ptr = fib->ss_sp;
+ terminated_machine_stack.size = fib->ss_size / sizeof(VALUE);
+ fib->ss_sp = NULL;
+ fib->context.uc_stack.ss_sp = NULL;
+ fib->cont.machine.stack = NULL;
+ fib->cont.machine.stack_size = 0;
+#endif
- next_fiber = return_fiber();
- if (need_interrupt) RUBY_VM_SET_INTERRUPT(&next_fiber->cont.saved_ec);
- fiber_switch(next_fiber, 1, &value, 0, RB_NO_KEYWORDS);
- ruby_stop(0);
+ ret_fib = return_fiber();
+ if (need_interrupt) RUBY_VM_SET_INTERRUPT(&ret_fib->cont.saved_ec);
+ fiber_switch(ret_fib, 1, &value, 0);
}
VALUE
-rb_fiber_resume_kw(VALUE fiber_value, int argc, const VALUE *argv, int kw_splat)
+rb_fiber_resume(VALUE fibval, int argc, const VALUE *argv)
{
- rb_fiber_t *fiber = fiber_ptr(fiber_value);
+ rb_fiber_t *fib;
+ GetFiberPtr(fibval, fib);
- if (argc == -1 && FIBER_CREATED_P(fiber)) {
- rb_raise(rb_eFiberError, "cannot raise exception on unborn fiber");
+ if (fib->prev != 0 || fib->cont.type == ROOT_FIBER_CONTEXT) {
+ rb_raise(rb_eFiberError, "double resume");
}
-
- if (fiber->prev != 0 || fiber_is_root_p(fiber)) {
- rb_raise(rb_eFiberError, "double resume");
+ if (fib->transferred != 0) {
+ rb_raise(rb_eFiberError, "cannot resume transferred Fiber");
}
- if (fiber->transferred != 0) {
- rb_raise(rb_eFiberError, "cannot resume transferred Fiber");
- }
-
- return fiber_switch(fiber, argc, argv, 1, kw_splat);
-}
-
-VALUE
-rb_fiber_resume(VALUE fiber_value, int argc, const VALUE *argv)
-{
- return rb_fiber_resume_kw(fiber_value, argc, argv, RB_NO_KEYWORDS);
-}
-
-VALUE
-rb_fiber_yield_kw(int argc, const VALUE *argv, int kw_splat)
-{
- return fiber_switch(return_fiber(), argc, argv, 0, kw_splat);
+ return fiber_switch(fib, argc, argv, 1);
}
VALUE
rb_fiber_yield(int argc, const VALUE *argv)
{
- return fiber_switch(return_fiber(), argc, argv, 0, RB_NO_KEYWORDS);
+ return fiber_switch(return_fiber(), argc, argv, 0);
}
void
-rb_fiber_reset_root_local_storage(rb_thread_t *th)
+rb_fiber_reset_root_local_storage(VALUE thval)
{
+ rb_thread_t *th = rb_thread_ptr(thval);
+
if (th->root_fiber && th->root_fiber != th->ec->fiber_ptr) {
- th->ec->local_storage = th->root_fiber->cont.saved_ec.local_storage;
+ th->ec->local_storage = th->root_fiber->cont.saved_ec.local_storage;
}
}
@@ -2149,56 +1792,32 @@ rb_fiber_reset_root_local_storage(rb_thread_t *th)
* before using this method.
*/
VALUE
-rb_fiber_alive_p(VALUE fiber_value)
+rb_fiber_alive_p(VALUE fibval)
{
- return FIBER_TERMINATED_P(fiber_ptr(fiber_value)) ? Qfalse : Qtrue;
+ const rb_fiber_t *fib;
+ GetFiberPtr(fibval, fib);
+ return FIBER_TERMINATED_P(fib) ? Qfalse : Qtrue;
}
/*
* call-seq:
* fiber.resume(args, ...) -> obj
*
- * Resumes the fiber from the point at which the last Fiber.yield was
- * called, or starts running it if it is the first call to
- * #resume. Arguments passed to resume will be the value of the
- * Fiber.yield expression or will be passed as block parameters to
- * the fiber's block if this is the first #resume.
+ * Resumes the fiber from the point at which the last <code>Fiber.yield</code>
+ * was called, or starts running it if it is the first call to
+ * <code>resume</code>. Arguments passed to resume will be the value of
+ * the <code>Fiber.yield</code> expression or will be passed as block
+ * parameters to the fiber's block if this is the first <code>resume</code>.
*
* Alternatively, when resume is called it evaluates to the arguments passed
- * to the next Fiber.yield statement inside the fiber's block
+ * to the next <code>Fiber.yield</code> statement inside the fiber's block
* or to the block value if it runs to completion without any
- * Fiber.yield
- */
-static VALUE
-rb_fiber_m_resume(int argc, VALUE *argv, VALUE fiber)
-{
- return rb_fiber_resume_kw(fiber, argc, argv, PASS_KW_SPLAT);
-}
-
-/*
- * call-seq:
- * fiber.raise -> obj
- * fiber.raise(string) -> obj
- * fiber.raise(exception [, string [, array]]) -> obj
- *
- * Raises an exception in the fiber at the point at which the last
- * Fiber.yield was called, or at the start if neither +resume+
- * nor +raise+ were called before.
- *
- * With no arguments, raises a +RuntimeError+. With a single +String+
- * argument, raises a +RuntimeError+ with the string as a message. Otherwise,
- * the first parameter should be the name of an +Exception+ class (or an
- * object that returns an +Exception+ object when sent an +exception+
- * message). The optional second parameter sets the message associated with
- * the exception, and the third parameter is an array of callback information.
- * Exceptions are caught by the +rescue+ clause of <code>begin...end</code>
- * blocks.
+ * <code>Fiber.yield</code>
*/
static VALUE
-rb_fiber_raise(int argc, VALUE *argv, VALUE fiber)
+rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
{
- VALUE exc = rb_make_exception(argc, argv);
- return rb_fiber_resume_kw(fiber, -1, &exc, RB_NO_KEYWORDS);
+ return rb_fiber_resume(fib, argc, argv);
}
/*
@@ -2208,25 +1827,22 @@ rb_fiber_raise(int argc, VALUE *argv, VALUE fiber)
* Transfer control to another fiber, resuming it from where it last
* stopped or starting it if it was not resumed before. The calling
* fiber will be suspended much like in a call to
- * Fiber.yield. You need to <code>require 'fiber'</code>
+ * <code>Fiber.yield</code>. You need to <code>require 'fiber'</code>
* before using this method.
*
* The fiber which receives the transfer call is treats it much like
* a resume call. Arguments passed to transfer are treated like those
* passed to resume.
*
- * You cannot call +resume+ on a fiber that has been transferred to.
- * If you call +transfer+ on a fiber, and later call +resume+ on the
- * the fiber, a +FiberError+ will be raised. Once you call +transfer+ on
- * a fiber, the only way to resume processing the fiber is to
- * call +transfer+ on it again.
+ * You cannot resume a fiber that transferred control to another one.
+ * This will cause a double resume error. You need to transfer control
+ * back to this fiber before it can yield and resume.
*
* Example:
*
* fiber1 = Fiber.new do
* puts "In Fiber 1"
* Fiber.yield
- * puts "In Fiber 1 again"
* end
*
* fiber2 = Fiber.new do
@@ -2241,24 +1857,21 @@ rb_fiber_raise(int argc, VALUE *argv, VALUE fiber)
*
* fiber2.resume
* fiber3.resume
- * fiber1.resume rescue (p $!)
- * fiber1.transfer
*
* <em>produces</em>
*
- * In Fiber 2
- * In Fiber 1
- * In Fiber 3
- * #<FiberError: cannot resume transferred Fiber>
- * In Fiber 1 again
+ * In fiber 2
+ * In fiber 1
+ * In fiber 3
*
*/
static VALUE
-rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fiber_value)
+rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fibval)
{
- rb_fiber_t *fiber = fiber_ptr(fiber_value);
- fiber->transferred = 1;
- return fiber_switch(fiber, argc, argv, 0, PASS_KW_SPLAT);
+ rb_fiber_t *fib;
+ GetFiberPtr(fibval, fib);
+ fib->transferred = 1;
+ return fiber_switch(fib, argc, argv, 0);
}
/*
@@ -2267,14 +1880,14 @@ rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fiber_value)
*
* Yields control back to the context that resumed the fiber, passing
* along any arguments that were passed to it. The fiber will resume
- * processing at this point when #resume is called next.
- * Any arguments passed to the next #resume will be the value that
- * this Fiber.yield expression evaluates to.
+ * processing at this point when <code>resume</code> is called next.
+ * Any arguments passed to the next <code>resume</code> will be the
+ * value that this <code>Fiber.yield</code> expression evaluates to.
*/
static VALUE
rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)
{
- return rb_fiber_yield_kw(argc, argv, PASS_KW_SPLAT);
+ return rb_fiber_yield(argc, argv);
}
/*
@@ -2300,28 +1913,23 @@ rb_fiber_s_current(VALUE klass)
*/
static VALUE
-fiber_to_s(VALUE fiber_value)
+fiber_to_s(VALUE fibval)
{
- const rb_fiber_t *fiber = fiber_ptr(fiber_value);
+ const rb_fiber_t *fib;
const rb_proc_t *proc;
- char status_info[0x20];
-
- if (fiber->transferred) {
- snprintf(status_info, 0x20, " (%s, transferred)", fiber_status_name(fiber->status));
- }
- else {
- snprintf(status_info, 0x20, " (%s)", fiber_status_name(fiber->status));
- }
+ char status_info[0x10];
- if (!rb_obj_is_proc(fiber->first_proc)) {
- VALUE str = rb_any_to_s(fiber_value);
- strlcat(status_info, ">", sizeof(status_info));
- rb_str_set_len(str, RSTRING_LEN(str)-1);
- rb_str_cat_cstr(str, status_info);
- return str;
+ GetFiberPtr(fibval, fib);
+ snprintf(status_info, 0x10, " (%s)", fiber_status_name(fib->status));
+ if (!rb_obj_is_proc(fib->first_proc)) {
+ VALUE str = rb_any_to_s(fibval);
+ strlcat(status_info, ">", sizeof(status_info));
+ rb_str_set_len(str, RSTRING_LEN(str)-1);
+ rb_str_cat_cstr(str, status_info);
+ return str;
}
- GetProcPtr(fiber->first_proc, proc);
- return rb_block_to_s(fiber_value, &proc->block, status_info);
+ GetProcPtr(fib->first_proc, proc);
+ return rb_block_to_s(fibval, &proc->block, status_info);
}
#ifdef HAVE_WORKING_FORK
@@ -2331,80 +1939,13 @@ rb_fiber_atfork(rb_thread_t *th)
if (th->root_fiber) {
if (&th->root_fiber->cont.saved_ec != th->ec) {
th->root_fiber = th->ec->fiber_ptr;
+ th->root_fiber->cont.type = ROOT_FIBER_CONTEXT;
}
th->root_fiber->prev = 0;
}
}
#endif
-#ifdef RB_EXPERIMENTAL_FIBER_POOL
-static void
-fiber_pool_free(void *ptr)
-{
- struct fiber_pool * fiber_pool = ptr;
- RUBY_FREE_ENTER("fiber_pool");
-
- fiber_pool_free_allocations(fiber_pool->allocations);
- ruby_xfree(fiber_pool);
-
- RUBY_FREE_LEAVE("fiber_pool");
-}
-
-static size_t
-fiber_pool_memsize(const void *ptr)
-{
- const struct fiber_pool * fiber_pool = ptr;
- size_t size = sizeof(*fiber_pool);
-
- size += fiber_pool->count * fiber_pool->size;
-
- return size;
-}
-
-static const rb_data_type_t FiberPoolDataType = {
- "fiber_pool",
- {NULL, fiber_pool_free, fiber_pool_memsize,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static VALUE
-fiber_pool_alloc(VALUE klass)
-{
- struct fiber_pool * fiber_pool = RB_ALLOC(struct fiber_pool);
-
- return TypedData_Wrap_Struct(klass, &FiberPoolDataType, fiber_pool);
-}
-
-static VALUE
-rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self)
-{
- rb_thread_t *th = GET_THREAD();
- VALUE size = Qnil, count = Qnil, vm_stack_size = Qnil;
- struct fiber_pool * fiber_pool = NULL;
-
- // Maybe these should be keyword arguments.
- rb_scan_args(argc, argv, "03", &size, &count, &vm_stack_size);
-
- if (NIL_P(size)) {
- size = INT2NUM(th->vm->default_params.fiber_machine_stack_size);
- }
-
- if (NIL_P(count)) {
- count = INT2NUM(128);
- }
-
- if (NIL_P(vm_stack_size)) {
- vm_stack_size = INT2NUM(th->vm->default_params.fiber_vm_stack_size);
- }
-
- TypedData_Get_Struct(self, struct fiber_pool, &FiberPoolDataType, fiber_pool);
-
- fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), NUM2SIZET(vm_stack_size));
-
- return self;
-}
-#endif
-
/*
* Document-class: FiberError
*
@@ -2421,10 +1962,8 @@ rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self)
void
Init_Cont(void)
{
+#if FIBER_USE_NATIVE
rb_thread_t *th = GET_THREAD();
- size_t vm_stack_size = th->vm->default_params.fiber_vm_stack_size;
- size_t machine_stack_size = th->vm->default_params.fiber_machine_stack_size;
- size_t stack_size = machine_stack_size + vm_stack_size;
#ifdef _WIN32
SYSTEM_INFO info;
@@ -2434,29 +1973,16 @@ Init_Cont(void)
pagesize = sysconf(_SC_PAGESIZE);
#endif
SET_MACHINE_STACK_END(&th->ec->machine.stack_end);
-
- fiber_pool_initialize(&shared_fiber_pool, stack_size, FIBER_POOL_INITIAL_SIZE, vm_stack_size);
-
- char * fiber_shared_fiber_pool_free_stacks = getenv("RUBY_SHARED_FIBER_POOL_FREE_STACKS");
- if (fiber_shared_fiber_pool_free_stacks) {
- shared_fiber_pool.free_stacks = atoi(fiber_shared_fiber_pool_free_stacks);
- }
+#endif
rb_cFiber = rb_define_class("Fiber", rb_cObject);
rb_define_alloc_func(rb_cFiber, fiber_alloc);
rb_eFiberError = rb_define_class("FiberError", rb_eStandardError);
rb_define_singleton_method(rb_cFiber, "yield", rb_fiber_s_yield, -1);
- rb_define_method(rb_cFiber, "initialize", rb_fiber_initialize, -1);
+ rb_define_method(rb_cFiber, "initialize", rb_fiber_init, 0);
rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1);
- rb_define_method(rb_cFiber, "raise", rb_fiber_raise, -1);
rb_define_method(rb_cFiber, "to_s", fiber_to_s, 0);
rb_define_alias(rb_cFiber, "inspect", "to_s");
-
-#ifdef RB_EXPERIMENTAL_FIBER_POOL
- rb_cFiberPool = rb_define_class("Pool", rb_cFiber);
- rb_define_alloc_func(rb_cFiberPool, fiber_pool_alloc);
- rb_define_method(rb_cFiberPool, "initialize", rb_fiber_pool_initialize, -1);
-#endif
}
RUBY_SYMBOL_EXPORT_BEGIN
diff --git a/coroutine/amd64/Context.S b/coroutine/amd64/Context.S
deleted file mode 100644
index 051db1c5e8..0000000000
--- a/coroutine/amd64/Context.S
+++ /dev/null
@@ -1,46 +0,0 @@
-##
-## This file is part of the "Coroutine" project and released under the MIT License.
-##
-## Created by Samuel Williams on 10/5/2018.
-## Copyright, 2018, by Samuel Williams.
-##
-
-#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
-
-.text
-
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
-
- # Save caller state
- pushq %rbp
- pushq %rbx
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
-
- # Save caller stack pointer
- movq %rsp, (%rdi)
-
- # Restore callee stack pointer
- movq (%rsi), %rsp
-
- # Restore callee state
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %rbx
- popq %rbp
-
- # Put the first argument into the return value
- movq %rdi, %rax
-
- # We pop the return address and jump to it
- ret
-
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack,"",%progbits
-#endif
diff --git a/coroutine/amd64/Context.h b/coroutine/amd64/Context.h
deleted file mode 100644
index 352ed5555a..0000000000
--- a/coroutine/amd64/Context.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 10/5/2018.
- * Copyright, 2018, by Samuel Williams.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <string.h>
-
-#define COROUTINE __attribute__((noreturn)) void
-
-enum {COROUTINE_REGISTERS = 6};
-
-struct coroutine_context
-{
- void **stack_pointer;
-};
-
-typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->stack_pointer = NULL;
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- // Stack grows down. Force 16-byte alignment.
- char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
-
- *--context->stack_pointer = NULL;
- *--context->stack_pointer = (void*)start;
-
- context->stack_pointer -= COROUTINE_REGISTERS;
- memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
-}
-
-struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
- context->stack_pointer = NULL;
-}
diff --git a/coroutine/arm32/Context.S b/coroutine/arm32/Context.S
deleted file mode 100644
index c5338f0b67..0000000000
--- a/coroutine/arm32/Context.S
+++ /dev/null
@@ -1,29 +0,0 @@
-##
-## This file is part of the "Coroutine" project and released under the MIT License.
-##
-## Created by Samuel Williams on 10/5/2018.
-## Copyright, 2018, by Samuel Williams.
-##
-
-#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
-
-.file "Context.S"
-.text
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-.align 2
-.type PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer),%function
-.syntax unified
-
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
- # Save caller state (8 registers + return address)
- push {r4-r11,lr}
-
- # Save caller stack pointer
- str sp, [r0]
-
- # Restore callee stack pointer
- ldr sp, [r1]
-
- # Restore callee state (8 registers program counter)
- pop {r4-r11,pc}
diff --git a/coroutine/arm32/Context.h b/coroutine/arm32/Context.h
deleted file mode 100644
index 6b6807904f..0000000000
--- a/coroutine/arm32/Context.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 10/5/2018.
- * Copyright, 2018, by Samuel Williams.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <string.h>
-
-#define COROUTINE __attribute__((noreturn)) void
-#define COROUTINE_LIMITED_ADDRESS_SPACE
-
-enum {COROUTINE_REGISTERS = 8};
-
-struct coroutine_context
-{
- void **stack_pointer;
-};
-
-typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->stack_pointer = NULL;
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- // Stack grows down. Force 16-byte alignment.
- char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
-
- *--context->stack_pointer = (void*)start;
-
- context->stack_pointer -= COROUTINE_REGISTERS;
- memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
-}
-
-struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
-}
diff --git a/coroutine/arm64/Context.S b/coroutine/arm64/Context.S
deleted file mode 100644
index 04e3f6d1ef..0000000000
--- a/coroutine/arm64/Context.S
+++ /dev/null
@@ -1,62 +0,0 @@
-##
-## This file is part of the "Coroutine" project and released under the MIT License.
-##
-## Created by Samuel Williams on 10/5/2018.
-## Copyright, 2018, by Samuel Williams.
-##
-
-#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
-
-.text
-.align 2
-
-.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
-
- # Make space on the stack for caller registers
- sub sp, sp, 0xb0
-
- # Save caller registers
- stp d8, d9, [sp, 0x00]
- stp d10, d11, [sp, 0x10]
- stp d12, d13, [sp, 0x20]
- stp d14, d15, [sp, 0x30]
- stp x19, x20, [sp, 0x40]
- stp x21, x22, [sp, 0x50]
- stp x23, x24, [sp, 0x60]
- stp x25, x26, [sp, 0x70]
- stp x27, x28, [sp, 0x80]
- stp x29, x30, [sp, 0x90]
-
- # Save return address
- str x30, [sp, 0xa0]
-
- # Save stack pointer to x0 (first argument)
- mov x2, sp
- str x2, [x0, 0]
-
- # Load stack pointer from x1 (second argument)
- ldr x3, [x1, 0]
- mov sp, x3
-
- # Restore caller registers
- ldp d8, d9, [sp, 0x00]
- ldp d10, d11, [sp, 0x10]
- ldp d12, d13, [sp, 0x20]
- ldp d14, d15, [sp, 0x30]
- ldp x19, x20, [sp, 0x40]
- ldp x21, x22, [sp, 0x50]
- ldp x23, x24, [sp, 0x60]
- ldp x25, x26, [sp, 0x70]
- ldp x27, x28, [sp, 0x80]
- ldp x29, x30, [sp, 0x90]
-
- # Load return address into x4
- ldr x4, [sp, 0xa0]
-
- # Pop stack frame
- add sp, sp, 0xb0
-
- # Jump to return address (in x4)
- ret x4
diff --git a/coroutine/arm64/Context.h b/coroutine/arm64/Context.h
deleted file mode 100644
index 3bc19b1e4b..0000000000
--- a/coroutine/arm64/Context.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 10/5/2018.
- * Copyright, 2018, by Samuel Williams.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <string.h>
-
-#define COROUTINE __attribute__((noreturn)) void
-
-enum {COROUTINE_REGISTERS = 0xb0 / 8};
-
-struct coroutine_context
-{
- void **stack_pointer;
-};
-
-typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->stack_pointer = NULL;
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- // Stack grows down. Force 16-byte alignment.
- char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
-
- context->stack_pointer -= COROUTINE_REGISTERS;
- memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
-
- context->stack_pointer[0xa0 / 8] = (void*)start;
-}
-
-struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
-}
diff --git a/coroutine/copy/Context.c b/coroutine/copy/Context.c
deleted file mode 100644
index f6cf462282..0000000000
--- a/coroutine/copy/Context.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 24/6/2019.
- * Copyright, 2019, by Samuel Williams.
-*/
-
-#include "Context.h"
-
-#include <stdint.h>
-
-// http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
-#ifndef __GNUC__
-#define __asm__ asm
-#endif
-
-#if defined(__sparc)
-__attribute__((noinline))
-// https://marc.info/?l=linux-sparc&m=131914569320660&w=2
-static void coroutine_flush_register_windows() {
- __asm__
-#ifdef __GNUC__
- __volatile__
-#endif
-#if defined(__sparcv9) || defined(__sparc_v9__) || defined(__arch64__)
-#ifdef __GNUC__
- ("flushw" : : : "%o7")
-#else
- ("flushw")
-#endif
-#else
- ("ta 0x03")
-#endif
- ;
-}
-#else
-static void coroutine_flush_register_windows() {}
-#endif
-
-__attribute__((noinline))
-void *coroutine_stack_pointer() {
- return (void*)(
- (char*)__builtin_frame_address(0)
- );
-}
-
-// Save the current stack to a private area. It is likely that when restoring the stack, this stack frame will be incomplete. But that is acceptable since the previous stack frame which called `setjmp` should be correctly restored.
-__attribute__((noinline))
-int coroutine_save_stack_1(struct coroutine_context * context) {
- assert(context->stack);
- assert(context->base);
-
- void *stack_pointer = coroutine_stack_pointer();
-
- // At this point, you may need to ensure on architectures that use register windows, that all registers are flushed to the stack, otherwise the copy of the stack will not contain the valid registers:
- coroutine_flush_register_windows();
-
- // Save stack to private area:
- if (stack_pointer < context->base) {
- size_t size = (char*)context->base - (char*)stack_pointer;
- assert(size <= context->size);
-
- memcpy(context->stack, stack_pointer, size);
- context->used = size;
- } else {
- size_t size = (char*)stack_pointer - (char*)context->base;
- assert(size <= context->size);
-
- memcpy(context->stack, context->base, size);
- context->used = size;
- }
-
- // Initialized:
- return 0;
-}
-
-// Copy the current stack to a private memory buffer.
-int coroutine_save_stack(struct coroutine_context * context) {
- if (_setjmp(context->state)) {
- // Restored.
- return 1;
- }
-
- // We need to invoke the memory copy from one stack frame deeper than the one that calls setjmp. That is because if you don't do this, the setjmp might be restored into an invalid stack frame (truncated, etc):
- return coroutine_save_stack_1(context);
-}
-
-__attribute__((noreturn, noinline))
-void coroutine_restore_stack_padded(struct coroutine_context *context, void * buffer) {
- void *stack_pointer = coroutine_stack_pointer();
-
- assert(context->base);
-
- // At this point, you may need to ensure on architectures that use register windows, that all registers are flushed to the stack, otherwise when we copy in the new stack, the registers would not be updated:
- coroutine_flush_register_windows();
-
- // Restore stack from private area:
- if (stack_pointer < context->base) {
- void * bottom = (char*)context->base - context->used;
- assert(bottom > stack_pointer);
-
- memcpy(bottom, context->stack, context->used);
- } else {
- void * top = (char*)context->base + context->used;
- assert(top < stack_pointer);
-
- memcpy(context->base, context->stack, context->used);
- }
-
- // Restore registers. The `buffer` is to force the compiler NOT to elide he buffer and `alloca`:
- _longjmp(context->state, (int)(1 | (intptr_t)buffer));
-}
-
-// In order to swap between coroutines, we need to swap the stack and registers.
-// `setjmp` and `longjmp` are able to swap registers, but what about swapping stacks? You can use `memcpy` to copy the current stack to a private area and `memcpy` to copy the private stack of the next coroutine to the main stack.
-// But if the stack yop are copying in to the main stack is bigger than the currently executing stack, the `memcpy` will clobber the current stack frame (including the context argument). So we use `alloca` to push the current stack frame *beyond* the stack we are about to copy in. This ensures the current stack frame in `coroutine_restore_stack_padded` remains valid for calling `longjmp`.
-__attribute__((noreturn))
-void coroutine_restore_stack(struct coroutine_context *context) {
- void *stack_pointer = coroutine_stack_pointer();
- void *buffer = NULL;
-
- // We must ensure that the next stack frame is BEYOND the stack we are restoring:
- if (stack_pointer < context->base) {
- intptr_t offset = (intptr_t)stack_pointer - ((intptr_t)context->base - context->used);
- if (offset > 0) buffer = alloca(offset);
- } else {
- intptr_t offset = ((intptr_t)context->base + context->used) - (intptr_t)stack_pointer;
- if (offset > 0) buffer = alloca(offset);
- }
-
- assert(context->used > 0);
-
- coroutine_restore_stack_padded(context, buffer);
-}
-
-struct coroutine_context *coroutine_transfer(struct coroutine_context *current, struct coroutine_context *target)
-{
- struct coroutine_context *previous = target->from;
-
- // In theory, either this condition holds true, or we should assign the base address to target:
- assert(current->base == target->base);
- // If you are trying to copy the coroutine to a different thread
- // target->base = current->base
-
- target->from = current;
-
- assert(current != target);
-
- // It's possible to come here, even thought the current fiber has been terminated. We are never going to return so we don't bother saving the stack.
-
- if (current->stack) {
- if (coroutine_save_stack(current) == 0) {
- coroutine_restore_stack(target);
- }
- } else {
- coroutine_restore_stack(target);
- }
-
- target->from = previous;
-
- return target;
-}
diff --git a/coroutine/copy/Context.h b/coroutine/copy/Context.h
deleted file mode 100644
index 8514a61dff..0000000000
--- a/coroutine/copy/Context.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 27/6/2019.
- * Copyright, 2019, by Samuel Williams.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <string.h>
-#include <stdlib.h>
-#include <alloca.h>
-
-#define COROUTINE __attribute__((noreturn)) void
-
-#if INTPTR_MAX <= INT32_MAX
-#define COROUTINE_LIMITED_ADDRESS_SPACE
-#endif
-
-// This stack copying implementation which uses a private stack for each coroutine, including the main one.
-#define COROUTINE_PRIVATE_STACK
-
-struct coroutine_context
-{
- // Private stack:
- void *stack;
- size_t size, used;
-
- // The top (or bottom) of the currently executing stack:
- void *base;
-
- jmp_buf state;
-
- struct coroutine_context *from;
-};
-
-typedef COROUTINE(*coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-int coroutine_save_stack(struct coroutine_context * context);
-COROUTINE coroutine_restore_stack(struct coroutine_context *context);
-
-// @param stack The private stack area memory allocation (pointer to lowest address).
-// @param size The size of the private stack area.
-// @param base A stack pointer to the base of the main stack. On x86 hardware, this is the upper extent of the region that will be copied to the private stack.
-static inline void coroutine_initialize_main(struct coroutine_context *context, void *stack, size_t size, void *base) {
- assert(stack);
- assert(size >= 1024);
-
- context->stack = stack;
- context->size = size;
- context->used = 0;
-
- assert(base);
- context->base = base;
-
- context->from = NULL;
-}
-
-// @param start The start function to invoke.
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size,
- void *base
-) {
- assert(start);
-
- coroutine_initialize_main(context, stack, size, base);
-
- if (coroutine_save_stack(context)) {
- start(context->from, context);
- }
-}
-
-struct coroutine_context *coroutine_transfer(struct coroutine_context *current, register struct coroutine_context *target);
-
-static inline void coroutine_destroy(struct coroutine_context *context)
-{
- context->stack = NULL;
- context->size = 0;
- context->from = NULL;
-}
diff --git a/coroutine/ppc64le/Context.S b/coroutine/ppc64le/Context.S
deleted file mode 100644
index 61be9efcf0..0000000000
--- a/coroutine/ppc64le/Context.S
+++ /dev/null
@@ -1,75 +0,0 @@
-#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
-
-.text
-.align 2
-
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-.type PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer), @function
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
- # Make space on the stack for caller registers
- addi 1,1,-152
-
- # Save caller registers
- std 14,0(1)
- std 15,8(1)
- std 16,16(1)
- std 17,24(1)
- std 18,32(1)
- std 19,40(1)
- std 20,48(1)
- std 21,56(1)
- std 22,64(1)
- std 23,72(1)
- std 24,80(1)
- std 25,88(1)
- std 26,96(1)
- std 27,104(1)
- std 28,112(1)
- std 29,120(1)
- std 30,128(1)
- std 31,136(1)
-
- # Save return address
- mflr 0
- std 0,144(1)
-
- # Save stack pointer to first argument
- std 1,0(3)
-
- # Load stack pointer from second argument
- ld 1,0(4)
-
- # Restore caller registers
- ld 14,0(1)
- ld 15,8(1)
- ld 16,16(1)
- ld 17,24(1)
- ld 18,32(1)
- ld 19,40(1)
- ld 20,48(1)
- ld 21,56(1)
- ld 22,64(1)
- ld 23,72(1)
- ld 24,80(1)
- ld 25,88(1)
- ld 26,96(1)
- ld 27,104(1)
- ld 28,112(1)
- ld 29,120(1)
- ld 30,128(1)
- ld 31,136(1)
-
- # Load return address
- ld 0,144(1)
- mtlr 0
-
- # Pop stack frame
- addi 1,1,152
-
- # Jump to return address
- blr
-
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack,"",%progbits
-#endif
diff --git a/coroutine/ppc64le/Context.h b/coroutine/ppc64le/Context.h
deleted file mode 100644
index adf21b4fd9..0000000000
--- a/coroutine/ppc64le/Context.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-
-#include <assert.h>
-#include <string.h>
-
-#define COROUTINE __attribute__((noreturn)) void
-
-enum {
- COROUTINE_REGISTERS =
- 19 /* 18 general purpose registers (r14-r31) and 1 return address */
- + 4 /* space for fiber_entry() to store the link register */
-};
-
-struct coroutine_context
-{
- void **stack_pointer;
-};
-
-typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->stack_pointer = NULL;
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- // Stack grows down. Force 16-byte alignment.
- char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
-
- context->stack_pointer -= COROUTINE_REGISTERS;
- memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
-
- /* Skip a global prologue that sets the TOC register */
- context->stack_pointer[18] = ((char*)start) + 8;
-}
-
-struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
- context->stack_pointer = NULL;
-}
diff --git a/coroutine/ucontext/Context.c b/coroutine/ucontext/Context.c
deleted file mode 100644
index 2dc3f478e8..0000000000
--- a/coroutine/ucontext/Context.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 24/6/2019.
- * Copyright, 2019, by Samuel Williams.
-*/
-
-/* According to Solaris' ucontext.h, makecontext, etc. are removed in SUSv4.
- * To enable the prototype declarations, we need to define __EXTENSIONS__.
- */
-#if defined(__sun) && !defined(__EXTENSIONS__)
-#define __EXTENSIONS__
-#endif
-#include "Context.h"
-
-void coroutine_trampoline(void * _start, void * _context)
-{
- coroutine_start start = _start;
- struct coroutine_context * context = _context;
-
- start(context->from, context);
-}
diff --git a/coroutine/ucontext/Context.h b/coroutine/ucontext/Context.h
deleted file mode 100644
index 6cf16c8604..0000000000
--- a/coroutine/ucontext/Context.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 24/6/2019.
- * Copyright, 2019, by Samuel Williams. All rights reserved.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <stddef.h>
-#include <ucontext.h>
-
-#define COROUTINE __attribute__((noreturn)) void
-
-#if INTPTR_MAX <= INT32_MAX
-#define COROUTINE_LIMITED_ADDRESS_SPACE
-#endif
-
-struct coroutine_context
-{
- ucontext_t state;
- struct coroutine_context * from;
-};
-
-typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-COROUTINE coroutine_trampoline(void * _start, void * _context);
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->from = NULL;
- getcontext(&context->state);
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- coroutine_initialize_main(context);
-
- context->state.uc_stack.ss_size = size;
- // Despite what it's called, this is not actually a stack pointer. It points to the address of the stack allocation (the lowest address).
- context->state.uc_stack.ss_sp = (char*)stack;
- context->state.uc_stack.ss_flags = 0;
- context->state.uc_link = NULL;
-
- makecontext(&context->state, (void(*)(void))coroutine_trampoline, 2, (void*)start, (void*)context);
-}
-
-static inline struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target)
-{
- struct coroutine_context * previous = target->from;
-
- target->from = current;
- swapcontext(&current->state, &target->state);
- target->from = previous;
-
- return target;
-}
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
- context->state.uc_stack.ss_sp = NULL;
- context->state.uc_stack.ss_size = 0;
- context->from = NULL;
-}
diff --git a/coroutine/win32/Context.S b/coroutine/win32/Context.S
deleted file mode 100644
index d14bf435e8..0000000000
--- a/coroutine/win32/Context.S
+++ /dev/null
@@ -1,47 +0,0 @@
-##
-## This file is part of the "Coroutine" project and released under the MIT License.
-##
-## Created by Lars Kanis on 06/06/2019.
-##
-
-.text
-
-# Using fastcall is a big win (and it's the same as how x64 works).
-# In coroutine transfer, the arguments are passed in ecx and edx. We don't need
-# to touch these in order to pass them to the destination coroutine.
-
-.globl @coroutine_transfer@8
-@coroutine_transfer@8:
- # Save the thread information block:
- pushl %fs:0
- pushl %fs:4
- pushl %fs:8
-
- # Save caller registers:
- pushl %ebp
- pushl %ebx
- pushl %edi
- pushl %esi
-
- # Save caller stack pointer:
- movl %esp, (%ecx)
-
- # Restore callee stack pointer:
- movl (%edx), %esp
-
- # Restore callee stack:
- popl %esi
- popl %edi
- popl %ebx
- popl %ebp
-
- # Restore the thread information block:
- popl %fs:8
- popl %fs:4
- popl %fs:0
-
- # Save the first argument as the return value:
- movl %ecx, %eax
-
- # Jump to the address on the stack:
- ret
diff --git a/coroutine/win32/Context.asm b/coroutine/win32/Context.asm
deleted file mode 100644
index f8f431239b..0000000000
--- a/coroutine/win32/Context.asm
+++ /dev/null
@@ -1,55 +0,0 @@
-;;
-;; This file is part of the "Coroutine" project and released under the MIT License.
-;;
-;; Created by Samuel Williams on 10/5/2018.
-;; Copyright, 2018, by Samuel Williams.
-;;
-
-.386
-.model flat
-
-.code
-
-assume fs:nothing
-
-; Using fastcall is a big win (and it's the same has how x64 works).
-; In coroutine transfer, the arguments are passed in ecx and edx. We don't need
-; to touch these in order to pass them to the destination coroutine.
-
-@coroutine_transfer@8 proc
- ; Save the thread information block:
- push fs:[0]
- push fs:[4]
- push fs:[8]
-
- ; Save caller registers:
- push ebp
- push ebx
- push edi
- push esi
-
- ; Save caller stack pointer:
- mov dword ptr [ecx], esp
-
- ; Restore callee stack pointer:
- mov esp, dword ptr [edx]
-
- ; Restore callee stack:
- pop esi
- pop edi
- pop ebx
- pop ebp
-
- ; Restore the thread information block:
- pop fs:[8]
- pop fs:[4]
- pop fs:[0]
-
- ; Save the first argument as the return value:
- mov eax, dword ptr ecx
-
- ; Jump to the address on the stack:
- ret
-@coroutine_transfer@8 endp
-
-end
diff --git a/coroutine/win32/Context.h b/coroutine/win32/Context.h
deleted file mode 100644
index 299515ed92..0000000000
--- a/coroutine/win32/Context.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 10/5/2018.
- * Copyright, 2018, by Samuel Williams. All rights reserved.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <string.h>
-
-#define COROUTINE __declspec(noreturn) void __fastcall
-#define COROUTINE_LIMITED_ADDRESS_SPACE
-
-/* This doesn't include thread information block */
-enum {COROUTINE_REGISTERS = 4};
-
-struct coroutine_context
-{
- void **stack_pointer;
-};
-
-typedef void(__fastcall * coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->stack_pointer = NULL;
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- // Stack grows down. Force 16-byte alignment.
- char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
-
- *--context->stack_pointer = (void*)start;
-
- /* Windows Thread Information Block */
- *--context->stack_pointer = (void*)0xFFFFFFFF; /* fs:[0] */
- *--context->stack_pointer = (void*)top; /* fs:[4] */
- *--context->stack_pointer = (void*)stack; /* fs:[8] */
-
- context->stack_pointer -= COROUTINE_REGISTERS;
- memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
-}
-
-struct coroutine_context * __fastcall coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
-}
diff --git a/coroutine/win64/Context.S b/coroutine/win64/Context.S
deleted file mode 100644
index e0ee38e006..0000000000
--- a/coroutine/win64/Context.S
+++ /dev/null
@@ -1,77 +0,0 @@
-##
-## This file is part of the "Coroutine" project and released under the MIT License.
-##
-## Created by Samuel Williams on 4/11/2018.
-## Copyright, 2018, by Samuel Williams.
-##
-
-.text
-
-.globl coroutine_transfer
-coroutine_transfer:
- # Save the thread information block:
- pushq %gs:8
- pushq %gs:16
-
- # Save caller registers:
- pushq %rbp
- pushq %rbx
- pushq %rdi
- pushq %rsi
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
-
- movaps %xmm15, -168(%rsp)
- movaps %xmm14, -152(%rsp)
- movaps %xmm13, -136(%rsp)
- movaps %xmm12, -120(%rsp)
- movaps %xmm11, -104(%rsp)
- movaps %xmm10, -88(%rsp)
- movaps %xmm9, -72(%rsp)
- movaps %xmm8, -56(%rsp)
- movaps %xmm7, -40(%rsp)
- movaps %xmm6, -24(%rsp)
-
- # Save caller stack pointer:
- mov %rsp, (%rcx)
-
- # Restore callee stack pointer:
- mov (%rdx), %rsp
-
- movaps -24(%rsp), %xmm6
- movaps -40(%rsp), %xmm7
- movaps -56(%rsp), %xmm8
- movaps -72(%rsp), %xmm9
- movaps -88(%rsp), %xmm10
- movaps -104(%rsp), %xmm11
- movaps -120(%rsp), %xmm12
- movaps -136(%rsp), %xmm13
- movaps -152(%rsp), %xmm14
- movaps -168(%rsp), %xmm15
-
- # Restore callee stack:
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %rsi
- popq %rdi
- popq %rbx
- popq %rbp
-
- # Restore the thread information block:
- popq %gs:16
- popq %gs:8
-
- # Put the first argument into the return value:
- mov %rcx, %rax
-
- # We pop the return address and jump to it:
- ret
-
-.globl coroutine_trampoline
-coroutine_trampoline:
- # Do not remove this. This forces 16-byte alignment when entering the coroutine.
- ret
diff --git a/coroutine/win64/Context.asm b/coroutine/win64/Context.asm
deleted file mode 100644
index 8c4dea1c93..0000000000
--- a/coroutine/win64/Context.asm
+++ /dev/null
@@ -1,79 +0,0 @@
-;;
-;; This file is part of the "Coroutine" project and released under the MIT License.
-;;
-;; Created by Samuel Williams on 10/5/2018.
-;; Copyright, 2018, by Samuel Williams.
-;;
-
-.code
-
-coroutine_transfer proc
- ; Save the thread information block:
- push qword ptr gs:[8]
- push qword ptr gs:[16]
-
- ; Save caller registers:
- push rbp
- push rbx
- push rdi
- push rsi
- push r12
- push r13
- push r14
- push r15
-
- movaps [rsp - 24], xmm6
- movaps [rsp - 40], xmm7
- movaps [rsp - 56], xmm8
- movaps [rsp - 72], xmm9
- movaps [rsp - 88], xmm10
- movaps [rsp - 104], xmm11
- movaps [rsp - 120], xmm12
- movaps [rsp - 136], xmm13
- movaps [rsp - 152], xmm14
- movaps [rsp - 168], xmm15
-
- ; Save caller stack pointer:
- mov [rcx], rsp
-
- ; Restore callee stack pointer:
- mov rsp, [rdx]
-
- movaps xmm15, [rsp - 168]
- movaps xmm14, [rsp - 152]
- movaps xmm13, [rsp - 136]
- movaps xmm12, [rsp - 120]
- movaps xmm11, [rsp - 104]
- movaps xmm10, [rsp - 88]
- movaps xmm9, [rsp - 72]
- movaps xmm8, [rsp - 56]
- movaps xmm7, [rsp - 40]
- movaps xmm6, [rsp - 24]
-
- ; Restore callee stack:
- pop r15
- pop r14
- pop r13
- pop r12
- pop rsi
- pop rdi
- pop rbx
- pop rbp
-
- ; Restore the thread information block:
- pop qword ptr gs:[16]
- pop qword ptr gs:[8]
-
- ; Put the first argument into the return value:
- mov rax, rcx
-
- ; We pop the return address and jump to it:
- ret
-coroutine_transfer endp
-
-coroutine_trampoline proc
- ; Do not remove this. This forces 16-byte alignment when entering the coroutine.
- ret
-coroutine_trampoline endp
-
-end
diff --git a/coroutine/win64/Context.h b/coroutine/win64/Context.h
deleted file mode 100644
index 6bf2dc5b35..0000000000
--- a/coroutine/win64/Context.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 10/5/2018.
- * Copyright, 2018, by Samuel Williams. All rights reserved.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <string.h>
-
-#define COROUTINE __declspec(noreturn) void
-
-enum {
- COROUTINE_REGISTERS = 8,
- COROUTINE_XMM_REGISTERS = 1+10*2,
-};
-
-struct coroutine_context
-{
- void **stack_pointer;
-};
-
-typedef void(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-
-void coroutine_trampoline();
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->stack_pointer = NULL;
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- // Stack grows down. Force 16-byte alignment.
- char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
-
- /* Win64 ABI requires space for arguments */
- context->stack_pointer -= 4;
-
- /* Return address */
- *--context->stack_pointer = 0;
- *--context->stack_pointer = (void*)start;
- *--context->stack_pointer = (void*)coroutine_trampoline;
-
- /* Windows Thread Information Block */
- /* *--context->stack_pointer = 0; */ /* gs:[0x00] is not used */
- *--context->stack_pointer = (void*)top; /* gs:[0x08] */
- *--context->stack_pointer = (void*)stack; /* gs:[0x10] */
-
- context->stack_pointer -= COROUTINE_REGISTERS;
- memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
- memset(context->stack_pointer - COROUTINE_XMM_REGISTERS, 0, sizeof(void*) * COROUTINE_XMM_REGISTERS);
-}
-
-struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
-}
diff --git a/coroutine/x86/Context.S b/coroutine/x86/Context.S
deleted file mode 100644
index 6983f21c3b..0000000000
--- a/coroutine/x86/Context.S
+++ /dev/null
@@ -1,42 +0,0 @@
-##
-## This file is part of the "Coroutine" project and released under the MIT License.
-##
-## Created by Samuel Williams on 3/11/2018.
-## Copyright, 2018, by Samuel Williams.
-##
-
-#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
-
-.text
-
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
-
- # Save caller registers
- pushl %ebp
- pushl %ebx
- pushl %edi
- pushl %esi
-
- # Save caller stack pointer
- movl %esp, (%ecx)
-
- # Restore callee stack pointer
- movl (%edx), %esp
-
- # Restore callee stack
- popl %esi
- popl %edi
- popl %ebx
- popl %ebp
-
- # Save the first argument as the return value
- movl %ecx, %eax
-
- # Jump to the address on the stack
- ret
-
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack,"",%progbits
-#endif
diff --git a/coroutine/x86/Context.h b/coroutine/x86/Context.h
deleted file mode 100644
index 6d3a56eaa6..0000000000
--- a/coroutine/x86/Context.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * This file is part of the "Coroutine" project and released under the MIT License.
- *
- * Created by Samuel Williams on 3/11/2018.
- * Copyright, 2018, by Samuel Williams. All rights reserved.
-*/
-
-#pragma once
-
-#include <assert.h>
-#include <string.h>
-
-#define COROUTINE __attribute__((noreturn, fastcall)) void
-#define COROUTINE_LIMITED_ADDRESS_SPACE
-
-enum {COROUTINE_REGISTERS = 4};
-
-struct coroutine_context
-{
- void **stack_pointer;
-};
-
-typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self) __attribute__((fastcall));
-
-static inline void coroutine_initialize_main(struct coroutine_context * context) {
- context->stack_pointer = NULL;
-}
-
-static inline void coroutine_initialize(
- struct coroutine_context *context,
- coroutine_start start,
- void *stack,
- size_t size
-) {
- assert(start && stack && size >= 1024);
-
- // Stack grows down. Force 16-byte alignment.
- char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
-
- *--context->stack_pointer = NULL;
- *--context->stack_pointer = (void*)start;
-
- context->stack_pointer -= COROUTINE_REGISTERS;
- memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
-}
-
-struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target) __attribute__((fastcall));
-
-static inline void coroutine_destroy(struct coroutine_context * context)
-{
- context->stack_pointer = NULL;
-}
diff --git a/coverage/README b/coverage/README
index 78a01826aa..7e4ff59e2a 100644
--- a/coverage/README
+++ b/coverage/README
@@ -4,7 +4,7 @@ The make task `update-coverage' retrieves simplecov for coverage report.
COVERAGE=1 make test-all TESTS=test/cgi
-it generates test coverage to coverage directory.
+it generate test coverage to coverage directory.
Limitation
diff --git a/debug.c b/debug.c
index a54be27152..f811ec6779 100644
--- a/debug.c
+++ b/debug.c
@@ -11,7 +11,6 @@
#include "ruby/ruby.h"
#include "ruby/encoding.h"
-#include "ruby/io.h"
#include "ruby/util.h"
#include "vm_debug.h"
#include "eval_intern.h"
@@ -147,7 +146,6 @@ extern int ruby_w32_rtc_error;
UINT ruby_w32_codepage[2];
#endif
extern int ruby_rgengc_debug;
-extern int ruby_on_ci;
int
ruby_env_debug_option(const char *str, int len, void *arg)
@@ -193,7 +191,6 @@ ruby_env_debug_option(const char *str, int len, void *arg)
SET_WHEN("gc_stress", *ruby_initial_gc_stress_ptr, Qtrue);
SET_WHEN("core", ruby_enable_coredump, 1);
- SET_WHEN("ci", ruby_on_ci, 1);
if (NAME_MATCH_VALUE("rgengc")) {
if (!len) ruby_rgengc_debug = 1;
else SET_UINT_LIST("rgengc", &ruby_rgengc_debug, 1);
diff --git a/debug_counter.c b/debug_counter.c
index 11ec57a961..6000f98c54 100644
--- a/debug_counter.c
+++ b/debug_counter.c
@@ -8,12 +8,12 @@
**********************************************************************/
-#include "internal.h"
#include "debug_counter.h"
#include <stdio.h>
-#include <locale.h>
#if USE_DEBUG_COUNTER
+#include "internal.h"
+
static const char *const debug_counter_names[] = {
""
#define RB_DEBUG_COUNTER(name) #name,
@@ -21,115 +21,21 @@ static const char *const debug_counter_names[] = {
#undef RB_DEBUG_COUNTER
};
-MJIT_SYMBOL_EXPORT_BEGIN
size_t rb_debug_counter[numberof(debug_counter_names)];
-MJIT_SYMBOL_EXPORT_END
-
-int debug_counter_disable_show_at_exit = 0;
-
-// note that this operation is not atomic.
-void
-ruby_debug_counter_reset(void)
-{
- for (int i = 0; i < RB_DEBUG_COUNTER_MAX; i++) {
- switch (i) {
- case RB_DEBUG_COUNTER_mjit_length_unit_queue:
- case RB_DEBUG_COUNTER_mjit_length_active_units:
- case RB_DEBUG_COUNTER_mjit_length_compact_units:
- case RB_DEBUG_COUNTER_mjit_length_stale_units:
- // These counters may be decreased and should not be reset.
- break;
- default:
- rb_debug_counter[i] = 0;
- break;
- }
- }
-}
-
-// note that this operation is not atomic.
-size_t
-ruby_debug_counter_get(const char **names_ptr, size_t *counters_ptr)
-{
- int i;
- if (names_ptr != NULL) {
- for (i=0; i<RB_DEBUG_COUNTER_MAX; i++) {
- names_ptr[i] = debug_counter_names[i];
- }
- }
- if (counters_ptr != NULL) {
- for (i=0; i<RB_DEBUG_COUNTER_MAX; i++) {
- counters_ptr[i] = rb_debug_counter[i];
- }
- }
-
- return RB_DEBUG_COUNTER_MAX;
-}
-
-void
-ruby_debug_counter_show_at_exit(int enable)
-{
- debug_counter_disable_show_at_exit = !enable;
-}
-void
-rb_debug_counter_show_results(const char *msg)
+__attribute__((destructor))
+static void
+rb_debug_counter_show_results(void)
{
const char *env = getenv("RUBY_DEBUG_COUNTER_DISABLE");
-
- setlocale(LC_NUMERIC, "");
-
if (env == NULL || strcmp("1", env) != 0) {
int i;
- fprintf(stderr, "[RUBY_DEBUG_COUNTER]\t%d %s\n", getpid(), msg);
for (i=0; i<RB_DEBUG_COUNTER_MAX; i++) {
- fprintf(stderr, "[RUBY_DEBUG_COUNTER]\t%-30s\t%'14"PRIuSIZE"\n",
+ fprintf(stderr, "[RUBY_DEBUG_COUNTER]\t%s\t%"PRIuSIZE"\n",
debug_counter_names[i],
rb_debug_counter[i]);
}
}
}
-VALUE
-rb_debug_counter_show(RB_UNUSED_VAR(VALUE klass))
-{
- rb_debug_counter_show_results("method call");
- return Qnil;
-}
-
-VALUE
-rb_debug_counter_reset(RB_UNUSED_VAR(VALUE klass))
-{
- ruby_debug_counter_reset();
- return Qnil;
-}
-
-__attribute__((destructor))
-static void
-debug_counter_show_results_at_exit(void)
-{
- if (debug_counter_disable_show_at_exit == 0) {
- rb_debug_counter_show_results("normal exit.");
- }
-}
-#else
-void
-rb_debug_counter_show_results(const char *msg)
-{
-}
-
-size_t
-ruby_debug_counter_get(const char **names_ptr, size_t *counters_ptr)
-{
- return 0;
-}
-void
-ruby_debug_counter_reset(void)
-{
-}
-
-void
-ruby_debug_counter_show_at_exit(int enable)
-{
-}
-
#endif /* USE_DEBUG_COUNTER */
diff --git a/debug_counter.h b/debug_counter.h
index 066533d1d1..f0f4e5ed0b 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -14,25 +14,7 @@
#ifdef RB_DEBUG_COUNTER
-/*
- * method cache (mc) counts.
- *
- * * mc_inline_hit/miss: inline mc hit/miss counts (VM send insn)
- * * mc_global_hit/miss: global method cache hit/miss counts
- * two types: (1) inline cache miss (VM send insn)
- * (2) called from C (rb_funcall).
- * * mc_global_state_miss: inline mc miss by global_state miss.
- * * mc_class_serial_miss: ... by mc_class_serial_miss
- * * mc_cme_complement: callable_method_entry complement counts.
- * * mc_cme_complement_hit: callable_method_entry cache hit counts.
- * * mc_search_super: search_method() call counts.
- * * mc_miss_by_nome: inline mc miss by no ment.
- * * mc_miss_by_distinct: ... by distinct ment.
- * * mc_miss_by_refine: ... by ment being refined.
- * * mc_miss_by_visi: ... by visibility change.
- * * mc_miss_spurious: spurious inline mc misshit.
- * * mc_miss_reuse_call: count of reuse of cc->call.
- */
+/* method search */
RB_DEBUG_COUNTER(mc_inline_hit)
RB_DEBUG_COUNTER(mc_inline_miss)
RB_DEBUG_COUNTER(mc_global_hit)
@@ -42,72 +24,8 @@ RB_DEBUG_COUNTER(mc_class_serial_miss)
RB_DEBUG_COUNTER(mc_cme_complement)
RB_DEBUG_COUNTER(mc_cme_complement_hit)
RB_DEBUG_COUNTER(mc_search_super)
-RB_DEBUG_COUNTER(mc_miss_by_nome)
-RB_DEBUG_COUNTER(mc_miss_by_distinct)
-RB_DEBUG_COUNTER(mc_miss_by_refine)
-RB_DEBUG_COUNTER(mc_miss_by_visi)
-RB_DEBUG_COUNTER(mc_miss_spurious)
-RB_DEBUG_COUNTER(mc_miss_reuse_call)
-/*
- * call cache fastpath usage
- */
-RB_DEBUG_COUNTER(ccf_general)
-RB_DEBUG_COUNTER(ccf_iseq_setup)
-RB_DEBUG_COUNTER(ccf_iseq_setup_0start)
-RB_DEBUG_COUNTER(ccf_iseq_setup_tailcall_0start)
-RB_DEBUG_COUNTER(ccf_iseq_fix) /* several functions created with tool/mk_call_iseq_optimized.rb */
-RB_DEBUG_COUNTER(ccf_iseq_opt) /* has_opt == TRUE (has optional parameters), but other flags are FALSE */
-RB_DEBUG_COUNTER(ccf_iseq_kw1) /* vm_call_iseq_setup_kwparm_kwarg() */
-RB_DEBUG_COUNTER(ccf_iseq_kw2) /* vm_call_iseq_setup_kwparm_nokwarg() */
-RB_DEBUG_COUNTER(ccf_cfunc)
-RB_DEBUG_COUNTER(ccf_ivar) /* attr_reader */
-RB_DEBUG_COUNTER(ccf_attrset) /* attr_writer */
-RB_DEBUG_COUNTER(ccf_method_missing)
-RB_DEBUG_COUNTER(ccf_zsuper)
-RB_DEBUG_COUNTER(ccf_bmethod)
-RB_DEBUG_COUNTER(ccf_opt_send)
-RB_DEBUG_COUNTER(ccf_opt_call)
-RB_DEBUG_COUNTER(ccf_opt_block_call)
-RB_DEBUG_COUNTER(ccf_super_method)
-
-/*
- * control frame push counts.
- *
- * * frame_push: frame push counts.
- * * frame_push_*: frame push counts per each type.
- * * frame_R2R: Ruby frame to Ruby frame
- * * frame_R2C: Ruby frame to C frame
- * * frame_C2C: C frame to C frame
- * * frame_C2R: C frame to Ruby frame
- */
-RB_DEBUG_COUNTER(frame_push)
-RB_DEBUG_COUNTER(frame_push_method)
-RB_DEBUG_COUNTER(frame_push_block)
-RB_DEBUG_COUNTER(frame_push_class)
-RB_DEBUG_COUNTER(frame_push_top)
-RB_DEBUG_COUNTER(frame_push_cfunc)
-RB_DEBUG_COUNTER(frame_push_ifunc)
-RB_DEBUG_COUNTER(frame_push_eval)
-RB_DEBUG_COUNTER(frame_push_rescue)
-RB_DEBUG_COUNTER(frame_push_dummy)
-
-RB_DEBUG_COUNTER(frame_R2R)
-RB_DEBUG_COUNTER(frame_R2C)
-RB_DEBUG_COUNTER(frame_C2C)
-RB_DEBUG_COUNTER(frame_C2R)
-
-/* instance variable counts
- *
- * * ivar_get_ic_hit/miss: ivar_get inline cache (ic) hit/miss counts (VM insn)
- * * ivar_get_ic_miss_serial: ivar_get ic miss reason by serial (VM insn)
- * * ivar_get_ic_miss_unset: ... by unset (VM insn)
- * * ivar_get_ic_miss_noobject: ... by "not T_OBJECT" (VM insn)
- * * ivar_set_...: same counts with ivar_set (VM insn)
- * * ivar_get/set_base: call counts of "rb_ivar_get/set()".
- * because of (1) ic miss.
- * (2) direct call by C extensions.
- */
+/* ivar access */
RB_DEBUG_COUNTER(ivar_get_ic_hit)
RB_DEBUG_COUNTER(ivar_get_ic_miss)
RB_DEBUG_COUNTER(ivar_get_ic_miss_serial)
@@ -122,92 +40,15 @@ RB_DEBUG_COUNTER(ivar_set_ic_miss_noobject)
RB_DEBUG_COUNTER(ivar_get_base)
RB_DEBUG_COUNTER(ivar_set_base)
-/* local variable counts
- *
- * * lvar_get: total lvar get counts (VM insn)
- * * lvar_get_dynamic: lvar get counts if accessing upper env (VM insn)
- * * lvar_set*: same as "get"
- * * lvar_set_slowpath: counts using vm_env_write_slowpath()
- */
+/* lvar access */
RB_DEBUG_COUNTER(lvar_get)
RB_DEBUG_COUNTER(lvar_get_dynamic)
RB_DEBUG_COUNTER(lvar_set)
RB_DEBUG_COUNTER(lvar_set_dynamic)
RB_DEBUG_COUNTER(lvar_set_slowpath)
-/* GC counts:
- *
- * * count: simple count
- * * _minor: minor gc
- * * _major: major gc
- * * other suffix is corresponding to last_gc_info or
- * gc_profile_record_flag in gc.c.
- */
-RB_DEBUG_COUNTER(gc_count)
-RB_DEBUG_COUNTER(gc_minor_newobj)
-RB_DEBUG_COUNTER(gc_minor_malloc)
-RB_DEBUG_COUNTER(gc_minor_method)
-RB_DEBUG_COUNTER(gc_minor_capi)
-RB_DEBUG_COUNTER(gc_minor_stress)
-RB_DEBUG_COUNTER(gc_major_nofree)
-RB_DEBUG_COUNTER(gc_major_oldgen)
-RB_DEBUG_COUNTER(gc_major_shady)
-RB_DEBUG_COUNTER(gc_major_force)
-RB_DEBUG_COUNTER(gc_major_oldmalloc)
-
-RB_DEBUG_COUNTER(gc_isptr_trial)
-RB_DEBUG_COUNTER(gc_isptr_range)
-RB_DEBUG_COUNTER(gc_isptr_align)
-RB_DEBUG_COUNTER(gc_isptr_maybe)
-
-/* object allocation counts:
- *
- * * obj_newobj: newobj counts
- * * obj_newobj_slowpath: newobj with slowpath counts
- * * obj_newobj_wb_unprotected: newobj for wb_unprotecte.
- * * obj_free: obj_free() counts
- * * obj_promote: promoted counts (oldgen)
- * * obj_wb_unprotect: wb unprotect counts
- *
- * * obj_[type]_[attr]: *free'ed counts* for each type.
- * Note that it is not a allocated counts.
- * * [type]
- * * _obj: T_OBJECT
- * * _str: T_STRING
- * * _ary: T_ARRAY
- * * _xxx: T_XXX (hash, struct, ...)
- *
- * * [attr]
- * * _ptr: R?? is not embed.
- * * _embed: R?? is embed.
- * * _transient: R?? uses transient heap.
- * * type specific attr.
- * * str_shared: str is shared.
- * * str_nofree: nofree
- * * str_fstr: fstr
- * * hash_empty: hash is empty
- * * hash_1_4: has 1 to 4 entries
- * * hash_5_8: has 5 to 8 entries
- * * hash_g8: has n entries (n>8)
- * * match_under4: has under 4 oniguruma regions allocated
- * * match_ge4: has n regions allocated (4<=n<8)
- * * match_ge8: has n regions allocated (8<=n)
- * * data_empty: T_DATA but no memory free.
- * * data_xfree: free'ed by xfree().
- * * data_imm_free: free'ed immediately.
- * * data_zombie: free'ed with zombie.
- * * imemo_*: T_IMEMO with each type.
- */
-RB_DEBUG_COUNTER(obj_newobj)
-RB_DEBUG_COUNTER(obj_newobj_slowpath)
-RB_DEBUG_COUNTER(obj_newobj_wb_unprotected)
+/* object counts */
RB_DEBUG_COUNTER(obj_free)
-RB_DEBUG_COUNTER(obj_promote)
-RB_DEBUG_COUNTER(obj_wb_unprotect)
-
-RB_DEBUG_COUNTER(obj_obj_embed)
-RB_DEBUG_COUNTER(obj_obj_transient)
-RB_DEBUG_COUNTER(obj_obj_ptr)
RB_DEBUG_COUNTER(obj_str_ptr)
RB_DEBUG_COUNTER(obj_str_embed)
@@ -215,127 +56,16 @@ RB_DEBUG_COUNTER(obj_str_shared)
RB_DEBUG_COUNTER(obj_str_nofree)
RB_DEBUG_COUNTER(obj_str_fstr)
-RB_DEBUG_COUNTER(obj_ary_embed)
-RB_DEBUG_COUNTER(obj_ary_transient)
RB_DEBUG_COUNTER(obj_ary_ptr)
-RB_DEBUG_COUNTER(obj_ary_extracapa)
-/*
- ary_shared_create: shared ary by Array#dup and so on.
- ary_shared: finished in shard.
- ary_shared_root_occupied: shared_root but has only 1 refcnt.
- The number (ary_shared - ary_shared_root_occupied) is meaningful.
- */
-RB_DEBUG_COUNTER(obj_ary_shared_create)
-RB_DEBUG_COUNTER(obj_ary_shared)
-RB_DEBUG_COUNTER(obj_ary_shared_root_occupied)
-
-RB_DEBUG_COUNTER(obj_hash_empty)
-RB_DEBUG_COUNTER(obj_hash_1)
-RB_DEBUG_COUNTER(obj_hash_2)
-RB_DEBUG_COUNTER(obj_hash_3)
-RB_DEBUG_COUNTER(obj_hash_4)
-RB_DEBUG_COUNTER(obj_hash_5_8)
-RB_DEBUG_COUNTER(obj_hash_g8)
-
-RB_DEBUG_COUNTER(obj_hash_null)
-RB_DEBUG_COUNTER(obj_hash_ar)
-RB_DEBUG_COUNTER(obj_hash_st)
-RB_DEBUG_COUNTER(obj_hash_transient)
-RB_DEBUG_COUNTER(obj_hash_force_convert)
-
-RB_DEBUG_COUNTER(obj_struct_embed)
-RB_DEBUG_COUNTER(obj_struct_transient)
-RB_DEBUG_COUNTER(obj_struct_ptr)
-
-RB_DEBUG_COUNTER(obj_data_empty)
-RB_DEBUG_COUNTER(obj_data_xfree)
-RB_DEBUG_COUNTER(obj_data_imm_free)
-RB_DEBUG_COUNTER(obj_data_zombie)
-
-RB_DEBUG_COUNTER(obj_match_under4)
-RB_DEBUG_COUNTER(obj_match_ge4)
-RB_DEBUG_COUNTER(obj_match_ge8)
-RB_DEBUG_COUNTER(obj_match_ptr)
-
-RB_DEBUG_COUNTER(obj_iclass_ptr)
-RB_DEBUG_COUNTER(obj_class_ptr)
-RB_DEBUG_COUNTER(obj_module_ptr)
-
-RB_DEBUG_COUNTER(obj_bignum_ptr)
-RB_DEBUG_COUNTER(obj_bignum_embed)
-RB_DEBUG_COUNTER(obj_float)
-RB_DEBUG_COUNTER(obj_complex)
-RB_DEBUG_COUNTER(obj_rational)
-
-RB_DEBUG_COUNTER(obj_regexp_ptr)
-RB_DEBUG_COUNTER(obj_file_ptr)
-RB_DEBUG_COUNTER(obj_symbol)
-
-RB_DEBUG_COUNTER(obj_imemo_ment)
-RB_DEBUG_COUNTER(obj_imemo_iseq)
-RB_DEBUG_COUNTER(obj_imemo_env)
-RB_DEBUG_COUNTER(obj_imemo_tmpbuf)
-RB_DEBUG_COUNTER(obj_imemo_ast)
-RB_DEBUG_COUNTER(obj_imemo_cref)
-RB_DEBUG_COUNTER(obj_imemo_svar)
-RB_DEBUG_COUNTER(obj_imemo_throw_data)
-RB_DEBUG_COUNTER(obj_imemo_ifunc)
-RB_DEBUG_COUNTER(obj_imemo_memo)
-RB_DEBUG_COUNTER(obj_imemo_parser_strterm)
-
-/* ar_table */
-RB_DEBUG_COUNTER(artable_hint_hit)
-RB_DEBUG_COUNTER(artable_hint_miss)
-RB_DEBUG_COUNTER(artable_hint_notfound)
-
-/* heap function counts
- *
- * * heap_xmalloc/realloc/xfree: call counts
- */
-RB_DEBUG_COUNTER(heap_xmalloc)
-RB_DEBUG_COUNTER(heap_xrealloc)
-RB_DEBUG_COUNTER(heap_xfree)
-
-/* transient_heap */
-RB_DEBUG_COUNTER(theap_alloc)
-RB_DEBUG_COUNTER(theap_alloc_fail)
-RB_DEBUG_COUNTER(theap_evacuate)
-
-/* mjit_exec() counts */
-RB_DEBUG_COUNTER(mjit_exec)
-RB_DEBUG_COUNTER(mjit_exec_not_added)
-RB_DEBUG_COUNTER(mjit_exec_not_added_add_iseq)
-RB_DEBUG_COUNTER(mjit_exec_not_ready)
-RB_DEBUG_COUNTER(mjit_exec_not_compiled)
-RB_DEBUG_COUNTER(mjit_exec_call_func)
-
-/* MJIT <-> VM frame push counts */
-RB_DEBUG_COUNTER(mjit_frame_VM2VM)
-RB_DEBUG_COUNTER(mjit_frame_VM2JT)
-RB_DEBUG_COUNTER(mjit_frame_JT2JT)
-RB_DEBUG_COUNTER(mjit_frame_JT2VM)
-
-/* MJIT cancel counters */
-RB_DEBUG_COUNTER(mjit_cancel)
-RB_DEBUG_COUNTER(mjit_cancel_ivar_inline)
-RB_DEBUG_COUNTER(mjit_cancel_send_inline)
-RB_DEBUG_COUNTER(mjit_cancel_opt_insn) /* CALL_SIMPLE_METHOD */
-RB_DEBUG_COUNTER(mjit_cancel_invalidate_all)
-
-/* rb_mjit_unit_list length */
-RB_DEBUG_COUNTER(mjit_length_unit_queue)
-RB_DEBUG_COUNTER(mjit_length_active_units)
-RB_DEBUG_COUNTER(mjit_length_compact_units)
-RB_DEBUG_COUNTER(mjit_length_stale_units)
+RB_DEBUG_COUNTER(obj_ary_embed)
-/* Other MJIT counters */
-RB_DEBUG_COUNTER(mjit_compile_failures)
+RB_DEBUG_COUNTER(obj_obj_ptr)
+RB_DEBUG_COUNTER(obj_obj_embed)
-/* load (not implemented yet) */
-/*
+/* load */
RB_DEBUG_COUNTER(load_files)
RB_DEBUG_COUNTER(load_path_is_not_realpath)
-*/
+
#endif
#ifndef RUBY_DEBUG_COUNTER_H
@@ -347,12 +77,14 @@ RB_DEBUG_COUNTER(load_path_is_not_realpath)
enum rb_debug_counter_type {
#define RB_DEBUG_COUNTER(name) RB_DEBUG_COUNTER_##name,
-#include __FILE__
+#include "debug_counter.h"
RB_DEBUG_COUNTER_MAX
#undef RB_DEBUG_COUNTER
};
#if USE_DEBUG_COUNTER
+#include "ruby/ruby.h"
+
extern size_t rb_debug_counter[];
inline static int
@@ -364,9 +96,6 @@ rb_debug_counter_add(enum rb_debug_counter_type type, int add, int cond)
return cond;
}
-VALUE rb_debug_counter_reset(VALUE klass);
-VALUE rb_debug_counter_show(VALUE klass);
-
#define RB_DEBUG_COUNTER_INC(type) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, 1)
#define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !(cond)))
#define RB_DEBUG_COUNTER_INC_IF(type, cond) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, (cond))
@@ -377,14 +106,4 @@ VALUE rb_debug_counter_show(VALUE klass);
#define RB_DEBUG_COUNTER_INC_IF(type, cond) (cond)
#endif
-void rb_debug_counter_show_results(const char *msg);
-
-RUBY_SYMBOL_EXPORT_BEGIN
-
-size_t ruby_debug_counter_get(const char **names_ptr, size_t *counters_ptr);
-void ruby_debug_counter_reset(void);
-void ruby_debug_counter_show_at_exit(int enable);
-
-RUBY_SYMBOL_EXPORT_END
-
#endif /* RUBY_DEBUG_COUNTER_H */
diff --git a/defs/gmake.mk b/defs/gmake.mk
index 226e1066a5..d961e27f77 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -1,5 +1,4 @@
-# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
-
+# -*- makefile-gmake -*-
gnumake = yes
override gnumake_recursive := $(if $(findstring n,$(firstword $(MFLAGS))),,+)
override mflags := $(filter-out -j%,$(MFLAGS))
@@ -11,22 +10,17 @@ TEST_TARGETS := $(filter $(CHECK_TARGETS),$(MAKECMDGOALS))
TEST_DEPENDS := $(filter-out commit $(TEST_TARGETS),$(MAKECMDGOALS))
TEST_TARGETS := $(patsubst great,exam,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out great $(TEST_TARGETS),$(TEST_DEPENDS))
-TEST_TARGETS := $(patsubst exam,check,$(TEST_TARGETS))
-TEST_TARGETS := $(patsubst check,test-spec test-all test-tool test-short,$(TEST_TARGETS))
+TEST_TARGETS := $(patsubst exam,check test-rubyspec,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-rubyspec,test-spec,$(TEST_TARGETS))
-TEST_DEPENDS := $(filter-out exam check test-spec $(TEST_TARGETS),$(TEST_DEPENDS))
+TEST_DEPENDS := $(filter-out exam $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_TARGETS := $(patsubst love,check,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out love $(TEST_TARGETS),$(TEST_DEPENDS))
-TEST_TARGETS := $(patsubst test-almost,test-all,$(patsubst check-%,test test-%,$(TEST_TARGETS)))
-TEST_DEPENDS := $(filter-out test-all $(TEST_TARGETS),$(TEST_DEPENDS))
-TEST_TARGETS := $(patsubst test,test-short,$(TEST_TARGETS))
+TEST_TARGETS := $(patsubst check,test test-testframework test-almost,$(patsubst check-%,test test-%,$(TEST_TARGETS)))
+TEST_DEPENDS := $(filter-out check $(TEST_TARGETS),$(TEST_DEPENDS))
+TEST_TARGETS := $(patsubst test,btest-ruby test-knownbug test-basic,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out test $(TEST_TARGETS),$(TEST_DEPENDS))
-TEST_TARGETS := $(patsubst test-short,btest-ruby test-knownbug test-basic,$(TEST_TARGETS))
-TEST_DEPENDS := $(filter-out test-short $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_DEPENDS += $(if $(filter great exam love check,$(MAKECMDGOALS)),all exts)
-in-srcdir := $(if $(filter-out .,$(srcdir)),$(CHDIR) $(srcdir) &&)
-
ifneq ($(filter -O0 -Od,$(optflags)),)
override XCFLAGS := $(filter-out -D_FORTIFY_SOURCE=%,$(XCFLAGS))
endif
@@ -54,7 +48,7 @@ define archcmd
%.i: %.$(1).i
endef
-$(foreach arch,$(arch_flags),\
+$(foreach arch,$(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG))),\
$(eval $(call archcmd,$(patsubst -arch=%,%,$(value arch)),$(patsubst -arch=%,-arch %,$(value arch)))))
endif
@@ -66,8 +60,8 @@ endif
ORDERED_TEST_TARGETS := $(filter $(TEST_TARGETS), \
btest-ruby test-knownbug test-basic \
- test-testframework test-tool test-ruby test-all \
- test-spec test-bundler-prepare test-bundler \
+ test-testframework test-ruby test-almost test-all \
+ test-spec \
)
prev_test := $(if $(filter test-spec,$(ORDERED_TEST_TARGETS)),test-spec-precheck)
$(foreach test,$(ORDERED_TEST_TARGETS), \
@@ -89,16 +83,18 @@ showflags: up
sudo-precheck: test yes-test-testframework no-test-testframework
install-prereq: sudo-precheck
yes-test-all no-test-all: install
+yes-test-almost no-test-almost: install
+endif
+ifneq ($(filter great,$(MAKECMDGOALS)),)
+love: test-rubyspec
endif
-# Cross reference needs to parse all files at once
-love install reinstall: RDOCFLAGS = --force-update
$(srcdir)/missing/des_tables.c: $(srcdir)/missing/crypt.c
ifeq ($(if $(filter yes,$(CROSS_COMPILING)),,$(CC)),)
touch $@
else
@$(ECHO) building make_des_table
- $(CC) $(INCFLAGS) $(CPPFLAGS) -DDUMP $(LDFLAGS) $(XLDFLAGS) $(LIBS) -omake_des_table $(srcdir)/missing/crypt.c
+ $(CC) $(CPPFLAGS) -DDUMP $(LDFLAGS) $(XLDFLAGS) $(LIBS) -omake_des_table $(srcdir)/missing/crypt.c
@[ -x ./make_des_table ]
@$(ECHO) generating $@
$(Q) $(MAKEDIRS) $(@D)
@@ -110,7 +106,7 @@ endif
STUBPROGRAM = rubystub$(EXEEXT)
IGNOREDPATTERNS = %~ .% %.orig %.rej \#%\#
SCRIPTBINDIR := $(if $(EXEEXT),,exec/)
-SCRIPTPROGRAMS = $(addprefix $(SCRIPTBINDIR),$(addsuffix $(EXEEXT),$(filter-out $(IGNOREDPATTERNS),$(notdir $(wildcard $(srcdir)/libexec/*)))))
+SCRIPTPROGRAMS = $(addprefix $(SCRIPTBINDIR),$(addsuffix $(EXEEXT),$(filter-out $(IGNOREDPATTERNS),$(notdir $(wildcard $(srcdir)/bin/*)))))
stub: $(STUBPROGRAM)
scriptbin: $(SCRIPTPROGRAMS)
@@ -141,210 +137,10 @@ $(TIMESTAMPDIR)/.exec.time:
$(Q) exit > $@
.PHONY: commit
-commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS))) up
- @$(BASERUBY) -C "$(srcdir)" -I./tool/lib -rvcs -e 'VCS.detect(".").commit'
- +$(Q) \
- { \
- $(in-srcdir) \
- exec sed -f tool/prereq.status defs/gmake.mk template/Makefile.in common.mk; \
- } | \
- $(MAKE) $(mflags) Q=$(Q) ECHO=$(ECHO) srcdir="$(srcdir)" srcs_vpath="" CHDIR="$(CHDIR)" \
- BOOTSTRAPRUBY="$(BOOTSTRAPRUBY)" MINIRUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" \
- VCSUP="" ENC_MK=.top-enc.mk REVISION_FORCE=PHONY CONFIGURE="$(CONFIGURE)" -f - \
- update-src srcs all-incs
-
-GITHUB_RUBY_URL = https://github.com/ruby/ruby
-PR =
-
-COMMIT_GPG_SIGN = $(shell git -C "$(srcdir)" config commit.gpgsign)
-REMOTE_GITHUB_URL = $(shell git -C "$(srcdir)" config remote.github.url)
-COMMITS_NOTES = commits
-
-.PHONY: fetch-github
-fetch-github:
- $(call fetch-github,$(PR))
-
-define fetch-github
- $(if $(1),,\
- echo "usage:"; echo " make $@ PR=1234"; \
- exit 1; \
- )
- $(eval REMOTE_GITHUB_URL := $(REMOTE_GITHUB_URL))
- $(if $(REMOTE_GITHUB_URL),, \
- echo adding $(GITHUB_RUBY_URL) as remote github; \
- git -C "$(srcdir)" remote add github $(GITHUB_RUBY_URL); \
- git -C "$(srcdir)" config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
- $(eval REMOTE_GITHUB_URL := $(GITHUB_RUBY_URL)) \
- )
- $(if $(git -C "$(srcdir)" rev-parse "github/pull/$(1)/head" -- 2> /dev/null), \
- git -C "$(srcdir)" branch -f "gh-$(1)" "github/pull/$(1)/head", \
- git -C "$(srcdir)" fetch -f github "pull/$(1)/head:gh-$(1)" \
- )
-endef
-
-.PHONY: checkout-github
-checkout-github: fetch-github
- git -C "$(srcdir)" checkout "gh-$(PR)"
-
-.PHONY: update-github
-update-github: fetch-github
- $(eval PULL_REQUEST_API := https://api.github.com/repos/ruby/ruby/pulls/$(PR))
- $(eval PULL_REQUEST_FORK_BRANCH := $(shell \
- curl -s $(if $(GITHUB_TOKEN),-H "Authorization: bearer $(GITHUB_TOKEN)") $(PULL_REQUEST_API) | \
- $(BASERUBY) -rjson -e 'JSON.parse(STDIN.read)["head"].tap { |h| print "#{h["repo"]["full_name"]} #{h["ref"]}" }' \
- ))
- $(eval FORK_REPO := $(word 1,$(PULL_REQUEST_FORK_BRANCH)))
- $(eval PR_BRANCH := $(word 2,$(PULL_REQUEST_FORK_BRANCH)))
-
- $(eval GITHUB_UPDATE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(PR)-XXXXXX"))
- git -C "$(srcdir)" worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
- git -C "$(GITHUB_UPDATE_WORKTREE)" merge master --no-edit
- @$(BASERUBY) -e 'print "Are you sure to push this to PR=$(PR)? [Y/n]: "; exit(gets.chomp != "n")'
- git -C "$(srcdir)" remote add fork-$(PR) git@github.com:$(FORK_REPO).git
- git -C "$(GITHUB_UPDATE_WORKTREE)" push fork-$(PR) gh-$(PR):$(PR_BRANCH)
- git -C "$(srcdir)" remote rm fork-$(PR)
- git -C "$(srcdir)" worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
- git -C "$(srcdir)" branch -D gh-$(PR)
-
-.PHONY: pull-github
-pull-github: fetch-github
- $(call pull-github,$(PR))
-
-define pull-github
- $(eval GITHUB_MERGE_BASE := $(shell git -C "$(srcdir)" log -1 --format=format:%H))
- $(eval GITHUB_MERGE_BRANCH := $(shell git -C "$(srcdir)" symbolic-ref --short HEAD))
- $(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(1)-XXXXXX"))
- git -C "$(srcdir)" worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
- git -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH)
- $(eval COMMIT_GPG_SIGN := $(COMMIT_GPG_SIGN))
- $(if $(filter true,$(COMMIT_GPG_SIGN)), \
- git -C "$(GITHUB_MERGE_WORKTREE)" rebase --exec "git commit --amend --no-edit -S" "$(GITHUB_MERGE_BASE)"; \
- )
- git -C "$(GITHUB_MERGE_WORKTREE)" rebase --exec "git notes add --message 'Merged: $(GITHUB_RUBY_URL)/pull/$(1)'" "$(GITHUB_MERGE_BASE)"
-endef
-
-.PHONY: fetch-github-%
-fetch-github-%:
- $(call fetch-github,$*)
-
-.PHONY: checkout-github-%
-checkout-github-%: fetch-github-%
- git -C "$(srcdir)" checkout "gh-$*"
-
-.PHONY: pr-% pull-github-%
-pr-% pull-github-%: fetch-github-%
- $(call pull-github,$*)
-
-HELP_EXTRA_TASKS = \
- " checkout-github: checkout GitHub Pull Request [PR=1234]" \
- " pull-github: rebase GitHub Pull Request to new worktree [PR=1234]" \
- " update-github: merge master branch and push it to Pull Request [PR=1234]" \
- ""
+commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS)))
+ @$(BASERUBY) -C "$(srcdir)" -I./tool -rvcs -e 'VCS.detect(".").commit'
+ $(Q)$(MAKE) $(mflags) Q=$(Q) REVISION_FORCE=PHONY update-src srcs all-incs
-ifneq ($(filter refresh-gems,$(MAKECMDGOALS)),)
+ifeq ($(words $(filter update-gems extract-gems,$(MAKECMDGOALS))),2)
extract-gems: update-gems
-update-gems: update-bundled_gems
endif
-ifneq ($(filter extract-gems,$(MAKECMDGOALS)),)
-extract-gems: $(filter update-gems update-bundled_gems,$(MAKECMDGOALS))
-endif
-ifneq ($(filter update-gems,$(MAKECMDGOALS)),)
-update-gems: $(filter update-bundled_gems,$(MAKECMDGOALS))
-endif
-
-ifeq ($(filter 0 1,$(words $(arch_flags))),)
-$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
- $(eval $$(MJIT_HEADER:.h=)-$(value x).h \
- $$(MJIT_MIN_HEADER:.h=)-$(value x).h \
- $$(TIMESTAMPDIR)/$$(MJIT_HEADER:.h=)-$(value x).time \
- : ARCH_FLAG := -arch $(value x)))
-
-$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
- $(eval $$(MJIT_HEADER:.h=)-$(value x).h: \
- $$(TIMESTAMPDIR)/$$(MJIT_HEADER:.h=)-$(value x).time))
-
-mjit_min_headers := $(patsubst -arch=%,$(MJIT_MIN_HEADER:.h=-%.h),$(arch_flags))
-$(MJIT_MIN_HEADER): $(mjit_min_headers) $(PREP)
- @ set -e; set $(patsubst -arch=%,%,$(arch_flags)); \
- cd $(@D); h=$(@F:.h=); \
- exec > $(@F).new; \
- echo '#if 0'; \
- for arch; do\
- echo "#elif defined __$${arch}__"; \
- echo "# include \"$$h-$$arch.h\""; \
- done; \
- echo "#else"; echo "# error unsupported platform"; echo "#endif"
- $(IFCHANGE) $@ $@.new
- $(Q) $(MAKEDIRS) $(MJIT_HEADER_INSTALL_DIR)
- $(Q) $(MAKE_LINK) $@ $(MJIT_HEADER_INSTALL_DIR)/$(@F)
-
-endif
-
-ifeq ($(if $(wildcard $(filter-out .,$(UNICODE_FILES) $(UNICODE_PROPERTY_FILES))),,\
- $(wildcard $(srcdir)/lib/unicode_normalize/tables.rb)),)
-# Needs the dependency when any Unicode data file exists, or
-# normalization tables script doesn't. Otherwise, when the target
-# only exists, use it as-is.
-.PHONY: $(UNICODE_SRC_DATA_DIR)/.unicode-tables.time
-UNICODE_TABLES_TIMESTAMP =
-$(UNICODE_SRC_DATA_DIR)/.unicode-tables.time: \
- $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
-endif
-
-REVISION_IN_HEADER := $(shell sed -n 's/^\#define RUBY_FULL_REVISION "\(.*\)"/\1/p' $(srcdir)/revision.h 2>/dev/null)
-REVISION_LATEST := $(shell $(CHDIR) $(srcdir) && git log -1 --format=%H 2>/dev/null)
-ifneq ($(REVISION_IN_HEADER),$(REVISION_LATEST))
-# GNU make treat the target as unmodified when its dependents get
-# updated but it is not updated, while others may not.
-$(srcdir)/revision.h: $(REVISION_H)
-endif
-
-# Query on the generated rdoc
-#
-# $ make rdoc:Integer#+
-rdoc\:%: PHONY
- $(Q)$(RUNRUBY) $(srcdir)/libexec/ri --no-standard-docs --doc-dir=$(RDOCOUT) $(patsubst rdoc:%,%,$@)
-
-test_%.rb test/%: programs PHONY
- +$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) -- $(patsubst test/%,%,$@)
-
-spec/bundler/%: PHONY
- +$(Q)$(exec) $(XRUBY) -C $(srcdir) -Ispec/bundler .bundle/bin/rspec --require spec_helper $(RSPECOPTS) $@
-
-spec/%: programs exts PHONY
- +$(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec-run -B $(srcdir)/spec/default.mspec $(SPECOPTS) $(patsubst %,$(srcdir)/%,$@)
-
-benchmark/%: miniruby$(EXEEXT) update-benchmark-driver PHONY
- $(Q)$(BASERUBY) -rrubygems -I$(srcdir)/benchmark/lib $(srcdir)/benchmark/benchmark-driver/exe/benchmark-driver \
- --executables="compare-ruby::$(COMPARE_RUBY) -I$(EXTOUT)/common --disable-gem" \
- --executables="built-ruby::$(BENCH_RUBY) --disable-gem" \
- $(srcdir)/$@ $(OPTS)
-
-clean-srcs-ext::
- $(Q)$(RM) $(patsubst $(srcdir)/%,%,$(EXT_SRCS))
-
-clean-srcs-extra::
- $(Q)$(RM) $(patsubst $(srcdir)/%,%,$(EXTRA_SRCS))
-
-ifneq ($(filter $(VCS),git),)
-update-src::
- @$(BASERUBY) $(srcdir)/tool/lib/colorize.rb pass "Latest commit hash = $(shell $(filter-out svn,$(VCS)) -C $(srcdir) rev-parse --short=10 HEAD)"
-endif
-
-# Update dependencies and commit the updates to the current branch.
-update-deps:
- $(eval update_deps := $(shell date +update-deps-%Y%m%d))
- $(eval deps_dir := $(shell mktemp -d)/$(update_deps))
- $(eval GIT_DIR := $(shell git -C $(srcdir) rev-parse --absolute-git-dir))
- git --git-dir=$(GIT_DIR) worktree add $(deps_dir)
- cp $(srcdir)/tool/config.guess $(srcdir)/tool/config.sub $(deps_dir)/tool
- [ -f config.status ] && cp config.status $(deps_dir)
- cd $(deps_dir) && autoconf && \
- exec ./configure -q -C --enable-load-relative --disable-install-doc --disable-rubygems 'optflags=-O0' 'debugflags=-save-temps=obj -g'
- $(RUNRUBY) -C $(deps_dir) tool/update-deps --fix
- git -C $(deps_dir) diff --no-ext-diff --ignore-submodules --exit-code || \
- git -C $(deps_dir) commit --all --message='Update dependencies'
- git --git-dir=$(GIT_DIR) worktree remove $(deps_dir)
- $(RMDIR) $(dir $(deps_dir))
- git --git-dir=$(GIT_DIR) merge --no-edit --ff-only $(update_deps)
- git --git-dir=$(GIT_DIR) branch --delete $(update_deps)
diff --git a/defs/id.def b/defs/id.def
index fc7a04ffbc..f30b993bd9 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -3,7 +3,6 @@ firstline, predefined = __LINE__+1, %[\
max
min
freeze
- nil?
inspect
intern
object_id
@@ -39,37 +38,17 @@ firstline, predefined = __LINE__+1, %[\
to_a
to_s
to_i
- to_f
to_r
bt
bt_locations
call
mesg
exception
- locals
not NOT
and AND
or OR
- div
- divmod
- fdiv
- quo
- name
- nil
_ UScore
-
- # MUST be successive
- _1 NUMPARAM_1
- _2 NUMPARAM_2
- _3 NUMPARAM_3
- _4 NUMPARAM_4
- _5 NUMPARAM_5
- _6 NUMPARAM_6
- _7 NUMPARAM_7
- _8 NUMPARAM_8
- _9 NUMPARAM_9
-
"/*NULL*/" NULL
empty?
eql?
@@ -83,23 +62,21 @@ firstline, predefined = __LINE__+1, %[\
core#define_method
core#define_singleton_method
core#set_postexe
+ core#hash_from_ary
+ core#hash_merge_ary
core#hash_merge_ptr
core#hash_merge_kwd
- core#raise
- debug#created_info
$_ LASTLINE
$~ BACKREF
- $! ERROR_INFO
]
# VM ID OP Parser Token
token_ops = %[\
Dot2 .. DOT2
Dot3 ... DOT3
- BDot2 .. BDOT2
- BDot3 ... BDOT3
UPlus +@ UPLUS
UMinus -@ UMINUS
Pow ** POW
@@ -119,8 +96,6 @@ token_ops = %[\
Eqq === EQQ
Neq != NEQ
Not !
- And &
- Or |
Backquote `
EqTilde =~ MATCH
NeqTilde !~ NMATCH
diff --git a/defs/keywords b/defs/keywords
index fc30ec2d15..7f5422faef 100644
--- a/defs/keywords
+++ b/defs/keywords
@@ -1,5 +1,5 @@
%{
-struct kwtable {short name, id[2], state;};
+struct kwtable {int name, id[2], state;};
const struct kwtable *rb_reserved_word(const char *, unsigned int);
#ifndef RIPPER
static const struct kwtable *reserved_word(/*!ANSI{*/const char *, unsigned int/*}!ANSI*/);
diff --git a/defs/known_errors.def b/defs/known_errors.def
index e9694cfbda..b9c490d3a2 100644
--- a/defs/known_errors.def
+++ b/defs/known_errors.def
@@ -1,157 +1,148 @@
+EPERM
+ENOENT
+ESRCH
+EINTR
+EIO
+ENXIO
E2BIG
-EACCES
-EADDRINUSE
-EADDRNOTAVAIL
-EADV
-EAFNOSUPPORT
+ENOEXEC
+EBADF
+ECHILD
EAGAIN
-EALREADY
-EAUTH
-EBADARCH
+ENOMEM
+EACCES
+EFAULT
+ENOTBLK
+EBUSY
+EEXIST
+EXDEV
+ENODEV
+ENOTDIR
+EISDIR
+EINVAL
+ENFILE
+EMFILE
+ENOTTY
+ETXTBSY
+EFBIG
+ENOSPC
+ESPIPE
+EROFS
+EMLINK
+EPIPE
+EDOM
+ERANGE
+EDEADLK
+ENAMETOOLONG
+ENOLCK
+ENOSYS
+ENOTEMPTY
+ELOOP
+EWOULDBLOCK
+ENOMSG
+EIDRM
+ECHRNG
+EL2NSYNC
+EL3HLT
+EL3RST
+ELNRNG
+EUNATCH
+ENOCSI
+EL2HLT
EBADE
-EBADEXEC
-EBADF
-EBADFD
-EBADMACHO
-EBADMSG
EBADR
-EBADRPC
+EXFULL
+ENOANO
EBADRQC
EBADSLT
+EDEADLOCK
EBFONT
-EBUSY
-ECANCELED
-ECAPMODE
-ECHILD
-ECHRNG
+ENOSTR
+ENODATA
+ETIME
+ENOSR
+ENONET
+ENOPKG
+EREMOTE
+ENOLINK
+EADV
+ESRMNT
ECOMM
+EPROTO
+EMULTIHOP
+EDOTDOT
+EBADMSG
+EOVERFLOW
+ENOTUNIQ
+EBADFD
+EREMCHG
+ELIBACC
+ELIBBAD
+ELIBSCN
+ELIBMAX
+ELIBEXEC
+EILSEQ
+ERESTART
+ESTRPIPE
+EUSERS
+ENOTSOCK
+EDESTADDRREQ
+EMSGSIZE
+EPROTOTYPE
+ENOPROTOOPT
+EPROTONOSUPPORT
+ESOCKTNOSUPPORT
+EOPNOTSUPP
+EPFNOSUPPORT
+EAFNOSUPPORT
+EADDRINUSE
+EADDRNOTAVAIL
+ENETDOWN
+ENETUNREACH
+ENETRESET
ECONNABORTED
-ECONNREFUSED
ECONNRESET
-EDEADLK
-EDEADLOCK
-EDESTADDRREQ
-EDEVERR
-EDOM
-EDOOFUS
-EDOTDOT
-EDQUOT
-EEXIST
-EFAULT
-EFBIG
-EFTYPE
+ENOBUFS
+EISCONN
+ENOTCONN
+ESHUTDOWN
+ETOOMANYREFS
+ETIMEDOUT
+ECONNREFUSED
EHOSTDOWN
EHOSTUNREACH
-EHWPOISON
-EIDRM
-EILSEQ
+EALREADY
EINPROGRESS
-EINTR
-EINVAL
-EIO
-EIPSEC
-EISCONN
-EISDIR
+ESTALE
+EUCLEAN
+ENOTNAM
+ENAVAIL
EISNAM
+EREMOTEIO
+EDQUOT
+ECANCELED
EKEYEXPIRED
EKEYREJECTED
EKEYREVOKED
-EL2HLT
-EL2NSYNC
-EL3HLT
-EL3RST
-ELAST
-ELIBACC
-ELIBBAD
-ELIBEXEC
-ELIBMAX
-ELIBSCN
-ELNRNG
-ELOOP
EMEDIUMTYPE
-EMFILE
-EMLINK
-EMSGSIZE
-EMULTIHOP
-ENAMETOOLONG
-ENAVAIL
-ENEEDAUTH
-ENETDOWN
-ENETRESET
-ENETUNREACH
-ENFILE
-ENOANO
-ENOATTR
-ENOBUFS
-ENOCSI
-ENODATA
-ENODEV
-ENOENT
-ENOEXEC
ENOKEY
-ENOLCK
-ENOLINK
ENOMEDIUM
-ENOMEM
-ENOMSG
-ENONET
-ENOPKG
-ENOPOLICY
-ENOPROTOOPT
-ENOSPC
-ENOSR
-ENOSTR
-ENOSYS
-ENOTBLK
-ENOTCAPABLE
-ENOTCONN
-ENOTDIR
-ENOTEMPTY
-ENOTNAM
ENOTRECOVERABLE
-ENOTSOCK
-ENOTSUP
-ENOTTY
-ENOTUNIQ
-ENXIO
-EOPNOTSUPP
-EOVERFLOW
EOWNERDEAD
-EPERM
-EPFNOSUPPORT
-EPIPE
+ERFKILL
+EAUTH
+EBADRPC
+EDOOFUS
+EFTYPE
+ENEEDAUTH
+ENOATTR
+ENOTSUP
EPROCLIM
EPROCUNAVAIL
EPROGMISMATCH
EPROGUNAVAIL
-EPROTO
-EPROTONOSUPPORT
-EPROTOTYPE
-EPWROFF
-EQFULL
-ERANGE
-EREMCHG
-EREMOTE
-EREMOTEIO
-ERESTART
-ERFKILL
-EROFS
ERPCMISMATCH
-ESHLIBVERS
-ESHUTDOWN
-ESOCKTNOSUPPORT
-ESPIPE
-ESRCH
-ESRMNT
-ESTALE
-ESTRPIPE
-ETIME
-ETIMEDOUT
-ETOOMANYREFS
-ETXTBSY
-EUCLEAN
-EUNATCH
-EUSERS
-EWOULDBLOCK
-EXDEV
-EXFULL
+EIPSEC
+EHWPOISON
+ECAPMODE
+ENOTCAPABLE
diff --git a/defs/lex.c.src b/defs/lex.c.src
index fc30ec2d15..7f5422faef 100644
--- a/defs/lex.c.src
+++ b/defs/lex.c.src
@@ -1,5 +1,5 @@
%{
-struct kwtable {short name, id[2], state;};
+struct kwtable {int name, id[2], state;};
const struct kwtable *rb_reserved_word(const char *, unsigned int);
#ifndef RIPPER
static const struct kwtable *reserved_word(/*!ANSI{*/const char *, unsigned int/*}!ANSI*/);
diff --git a/defs/separated_version.mk b/defs/separated_version.mk
index 72ee093da7..f086f4b24a 100644
--- a/defs/separated_version.mk
+++ b/defs/separated_version.mk
@@ -1,6 +1,6 @@
# ******** FOR DEVELEPERS ONLY ********
# Separate version.o into a shared library which varies every
-# revisions, in order to make the rest shareable.
+# revisions, in order to make the rest sharable.
include $(firstword $(wildcard GNUmakefile Makefile))
diff --git a/defs/universal.mk b/defs/universal.mk
deleted file mode 100644
index c34a31b356..0000000000
--- a/defs/universal.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-arch_flags := $(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG)))
-ifeq ($(filter 0 1,$(words $(arch_flags))),)
-override MJIT_HEADER_SUFFIX = -%
-override MJIT_HEADER_ARCH = -$(word 2,$(ARCH_FLAG))
-endif
diff --git a/dir.c b/dir.c
index 6a926f438c..40bd4eb193 100644
--- a/dir.c
+++ b/dir.c
@@ -11,11 +11,9 @@
**********************************************************************/
-#include "ruby/encoding.h"
-#include "ruby/thread.h"
#include "internal.h"
-#include "id.h"
#include "encindex.h"
+#include "ruby/thread.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -177,7 +175,7 @@ has_nonascii(const char *ptr, size_t len)
#endif
#ifndef IFTODT
-# define IFTODT(m) (((m) & S_IFMT) / ((~S_IFMT & (S_IFMT-1)) + 1))
+# define IFTODT(m) (((m) & S_IFMT) / ((~S_IFMT & S_IFMT-1) + 1))
#endif
typedef enum {
@@ -592,10 +590,11 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
* The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
* If not specified, the filesystem encoding is used.
*
- * With no block, <code>open</code> is a synonym for Dir::new. If a
- * block is present, it is passed <i>aDir</i> as a parameter. The
- * directory is closed at the end of the block, and Dir::open returns
- * the value of the block.
+ * With no block, <code>open</code> is a synonym for
+ * <code>Dir::new</code>. If a block is present, it is passed
+ * <i>aDir</i> as a parameter. The directory is closed at the end of
+ * the block, and <code>Dir::open</code> returns the value of the
+ * block.
*/
static VALUE
dir_s_open(int argc, VALUE *argv, VALUE klass)
@@ -611,8 +610,6 @@ dir_s_open(int argc, VALUE *argv, VALUE klass)
return dir;
}
-NORETURN(static void dir_closed(void));
-
static void
dir_closed(void)
{
@@ -657,7 +654,7 @@ dir_inspect(VALUE dir)
rb_str_cat2(str, ">");
return str;
}
- return rb_funcallv(dir, idTo_s, 0, 0);
+ return rb_funcallv(dir, rb_intern("to_s"), 0, 0);
}
/* Workaround for Solaris 10 that does not have dirfd.
@@ -858,6 +855,7 @@ dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE), VALUE arg, int children_o
#endif
path = rb_external_str_new_with_enc(name, namlen, dirp->enc);
(*each)(arg, path);
+ if (dirp->dir == NULL) dir_closed();
}
return dir;
}
@@ -868,7 +866,8 @@ dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE), VALUE arg, int children_o
* dir.pos -> integer
* dir.tell -> integer
*
- * Returns the current position in <em>dir</em>. See also Dir#seek.
+ * Returns the current position in <em>dir</em>. See also
+ * <code>Dir#seek</code>.
*
* d = Dir.new("testdir")
* d.tell #=> 0
@@ -895,7 +894,7 @@ dir_tell(VALUE dir)
* dir.seek( integer ) -> dir
*
* Seeks to a particular location in <em>dir</em>. <i>integer</i>
- * must be a value returned by Dir#tell.
+ * must be a value returned by <code>Dir#tell</code>.
*
* d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
* d.read #=> "."
@@ -923,7 +922,8 @@ dir_seek(VALUE dir, VALUE pos)
* call-seq:
* dir.pos = integer -> integer
*
- * Synonym for Dir#seek, but returns the position parameter.
+ * Synonym for <code>Dir#seek</code>, but returns the position
+ * parameter.
*
* d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
* d.read #=> "."
@@ -1010,9 +1010,8 @@ struct chdir_data {
};
static VALUE
-chdir_yield(VALUE v)
+chdir_yield(struct chdir_data *args)
{
- struct chdir_data *args = (void *)v;
dir_chdir(args->new_path);
args->done = TRUE;
chdir_blocking++;
@@ -1022,9 +1021,8 @@ chdir_yield(VALUE v)
}
static VALUE
-chdir_restore(VALUE v)
+chdir_restore(struct chdir_data *args)
{
- struct chdir_data *args = (void *)v;
if (args->done) {
chdir_blocking--;
if (chdir_blocking == 0)
@@ -1042,8 +1040,8 @@ chdir_restore(VALUE v)
* Changes the current working directory of the process to the given
* string. When called without an argument, changes the directory to
* the value of the environment variable <code>HOME</code>, or
- * <code>LOGDIR</code>. SystemCallError (probably Errno::ENOENT) if
- * the target directory does not exist.
+ * <code>LOGDIR</code>. <code>SystemCallError</code> (probably
+ * <code>Errno::ENOENT</code>) if the target directory does not exist.
*
* If a block is given, it is passed the name of the new current
* directory, and the block is executed with that as the current
@@ -1078,8 +1076,9 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
{
VALUE path = Qnil;
- if (rb_check_arity(argc, 0, 1) == 1) {
- path = rb_str_encode_ospath(rb_get_path(argv[0]));
+ if (rb_scan_args(argc, argv, "01", &path) == 1) {
+ FilePathValue(path);
+ path = rb_str_encode_ospath(path);
}
else {
const char *dist = getenv("HOME");
@@ -1129,8 +1128,9 @@ rb_dir_getwd_ospath(void)
DATA_PTR(path_guard) = path;
#ifdef __APPLE__
cwd = rb_str_normalize_ospath(path, strlen(path));
+ OBJ_TAINT(cwd);
#else
- cwd = rb_str_new2(path);
+ cwd = rb_tainted_str_new2(path);
#endif
DATA_PTR(path_guard) = 0;
@@ -1239,10 +1239,11 @@ nogvl_mkdir(void *ptr)
*
* Makes a new directory named by <i>string</i>, with permissions
* specified by the optional parameter <i>anInteger</i>. The
- * permissions may be modified by the value of File::umask, and are
- * ignored on NT. Raises a SystemCallError if the directory cannot be
- * created. See also the discussion of permissions in the class
- * documentation for File.
+ * permissions may be modified by the value of
+ * <code>File::umask</code>, and are ignored on NT. Raises a
+ * <code>SystemCallError</code> if the directory cannot be created. See
+ * also the discussion of permissions in the class documentation for
+ * <code>File</code>.
*
* Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
*
@@ -1284,8 +1285,8 @@ nogvl_rmdir(void *ptr)
* Dir.rmdir( string ) -> 0
* Dir.unlink( string ) -> 0
*
- * Deletes the named directory. Raises a subclass of SystemCallError
- * if the directory isn't empty.
+ * Deletes the named directory. Raises a subclass of
+ * <code>SystemCallError</code> if the directory isn't empty.
*/
static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
@@ -1342,20 +1343,8 @@ sys_enc_warning_in(const char *func, const char *mesg, rb_encoding *enc)
#define sys_warning(val, enc) \
((flags & GLOB_VERBOSE) ? sys_enc_warning_in(RUBY_FUNCTION_NAME_STRING, (val), (enc)) :(void)0)
-static inline void *
-glob_alloc_n(size_t x, size_t y)
-{
- size_t z;
- if (rb_mul_size_overflow(x, y, SSIZE_MAX, &z)) {
- rb_memerror(); /* or...? */
- }
- else {
- return malloc(z);
- }
-}
-
#define GLOB_ALLOC(type) ((type *)malloc(sizeof(type)))
-#define GLOB_ALLOC_N(type, n) ((type *)glob_alloc_n(sizeof(type), n))
+#define GLOB_ALLOC_N(type, n) ((type *)malloc(sizeof(type) * (n)))
#define GLOB_REALLOC(ptr, size) realloc((ptr), (size))
#define GLOB_FREE(ptr) free(ptr)
#define GLOB_JUMP_TAG(status) (((status) == -1) ? rb_memerror() : rb_jump_tag(status))
@@ -1385,24 +1374,12 @@ typedef struct {
ruby_glob_errfunc *error;
} ruby_glob_funcs_t;
-static const char *
-at_subpath(int fd, size_t baselen, const char *path)
-{
-#if USE_OPENDIR_AT
- if (fd != (int)AT_FDCWD && baselen > 0) {
- path += baselen;
- if (*path == '/') ++path;
- }
-#endif
- return *path ? path : ".";
-}
-
/* System call with warning */
static int
-do_stat(int fd, size_t baselen, const char *path, struct stat *pst, int flags, rb_encoding *enc)
+do_stat(int fd, const char *path, struct stat *pst, int flags, rb_encoding *enc)
{
#if USE_OPENDIR_AT
- int ret = fstatat(fd, at_subpath(fd, baselen, path), pst, 0);
+ int ret = fstatat(fd, path, pst, 0);
#else
int ret = STAT(path, pst);
#endif
@@ -1414,10 +1391,10 @@ do_stat(int fd, size_t baselen, const char *path, struct stat *pst, int flags, r
#if defined HAVE_LSTAT || defined lstat || USE_OPENDIR_AT
static int
-do_lstat(int fd, size_t baselen, const char *path, struct stat *pst, int flags, rb_encoding *enc)
+do_lstat(int fd, const char *path, struct stat *pst, int flags, rb_encoding *enc)
{
#if USE_OPENDIR_AT
- int ret = fstatat(fd, at_subpath(fd, baselen, path), pst, AT_SYMLINK_NOFOLLOW);
+ int ret = fstatat(fd, path, pst, AT_SYMLINK_NOFOLLOW);
#else
int ret = lstat(path, pst);
#endif
@@ -1507,7 +1484,7 @@ opendir_at(int basefd, const char *path)
}
static DIR *
-do_opendir(const int basefd, size_t baselen, const char *path, int flags, rb_encoding *enc,
+do_opendir(const int basefd, const char *path, int flags, rb_encoding *enc,
ruby_glob_errfunc *errfunc, VALUE arg, int *status)
{
DIR *dirp;
@@ -1519,7 +1496,7 @@ do_opendir(const int basefd, size_t baselen, const char *path, int flags, rb_enc
path = RSTRING_PTR(tmp);
}
#endif
- dirp = opendir_at(basefd, at_subpath(basefd, baselen, path));
+ dirp = opendir_at(basefd, path);
if (!dirp) {
int e = errno;
@@ -1541,7 +1518,7 @@ do_opendir(const int basefd, size_t baselen, const char *path, int flags, rb_enc
}
/* Globing pattern */
-enum glob_pattern_type { PLAIN, ALPHA, BRACE, MAGICAL, RECURSIVE, MATCH_ALL, MATCH_DIR };
+enum glob_pattern_type { PLAIN, ALPHA, MAGICAL, RECURSIVE, MATCH_ALL, MATCH_DIR };
/* Return nonzero if S has any special globbing chars in it. */
static enum glob_pattern_type
@@ -1549,20 +1526,15 @@ has_magic(const char *p, const char *pend, int flags, rb_encoding *enc)
{
const int escape = !(flags & FNM_NOESCAPE);
int hasalpha = 0;
- int hasmagical = 0;
register char c;
while (p < pend && (c = *p++) != 0) {
switch (c) {
- case '{':
- return BRACE;
-
case '*':
case '?':
case '[':
- hasmagical = 1;
- break;
+ return MAGICAL;
case '\\':
if (escape && p++ >= pend)
@@ -1587,7 +1559,7 @@ has_magic(const char *p, const char *pend, int flags, rb_encoding *enc)
p = Next(p-1, pend, enc);
}
- return hasmagical ? MAGICAL : hasalpha ? ALPHA : PLAIN;
+ return hasalpha ? ALPHA : PLAIN;
}
/* Find separator in globbing pattern. */
@@ -1608,13 +1580,6 @@ find_dirsep(const char *p, const char *pend, int flags, rb_encoding *enc)
open = 0;
continue;
- case '{':
- open = 1;
- continue;
- case '}':
- open = 0;
- continue;
-
case '/':
if (!open)
return (char *)p-1;
@@ -2020,83 +1985,6 @@ dirent_match(const char *pat, rb_encoding *enc, const char *name, const struct d
return 0;
}
-struct push_glob_args {
- int fd;
- const char *path;
- size_t baselen;
- size_t namelen;
- int dirsep; /* '/' should be placed before appending child entry's name to 'path'. */
- rb_pathtype_t pathtype; /* type of 'path' */
- int flags;
- const ruby_glob_funcs_t *funcs;
- VALUE arg;
-};
-
-struct dirent_brace_args {
- const char *name;
- const struct dirent *dp;
- int flags;
-};
-
-static int
-dirent_match_brace(const char *pattern, VALUE val, void *enc)
-{
- struct dirent_brace_args *arg = (struct dirent_brace_args *)val;
-
- return dirent_match(pattern, enc, arg->name, arg->dp, arg->flags);
-}
-
-/* join paths from pattern list of glob_make_pattern() */
-static char*
-join_path_from_pattern(struct glob_pattern **beg)
-{
- struct glob_pattern *p;
- char *path = NULL;
- size_t path_len = 0;
-
- for (p = *beg; p; p = p->next) {
- const char *str;
- switch (p->type) {
- case RECURSIVE:
- str = "**";
- break;
- case MATCH_DIR:
- /* append last slash */
- str = "";
- break;
- default:
- str = p->str;
- if (!str) continue;
- }
- if (!path) {
- path_len = strlen(str);
- path = GLOB_ALLOC_N(char, path_len + 1);
- if (path) {
- memcpy(path, str, path_len);
- path[path_len] = '\0';
- }
- }
- else {
- size_t len = strlen(str);
- char *tmp;
- tmp = GLOB_REALLOC(path, path_len + len + 2);
- if (tmp) {
- path = tmp;
- path[path_len++] = '/';
- memcpy(path + path_len, str, len);
- path_len += len;
- path[path_len] = '\0';
- }
- }
- }
- return path;
-}
-
-static int push_caller(const char *path, VALUE val, void *enc);
-
-static int ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg,
- rb_encoding *enc, VALUE var);
-
static int
glob_helper(
int fd,
@@ -2115,9 +2003,12 @@ glob_helper(
struct stat st;
int status = 0;
struct glob_pattern **cur, **new_beg, **new_end;
- int plain = 0, brace = 0, magical = 0, recursive = 0, match_all = 0, match_dir = 0;
+ int plain = 0, magical = 0, recursive = 0, match_all = 0, match_dir = 0;
int escape = !(flags & FNM_NOESCAPE);
size_t pathlen = baselen + namelen;
+ const char *base = path;
+
+ if (fd != AT_FDCWD && *(base += baselen) == '/') base++;
for (cur = beg; cur < end; ++cur) {
struct glob_pattern *p = *cur;
@@ -2136,11 +2027,6 @@ glob_helper(
magical = 1;
#endif
break;
- case BRACE:
- if (!recursive) {
- brace = 1;
- }
- break;
case MAGICAL:
magical = 2;
break;
@@ -2155,27 +2041,9 @@ glob_helper(
}
}
- if (brace) {
- struct push_glob_args args;
- char* brace_path = join_path_from_pattern(beg);
- if (!brace_path) return -1;
- args.fd = fd;
- args.path = path;
- args.baselen = baselen;
- args.namelen = namelen;
- args.dirsep = dirsep;
- args.pathtype = pathtype;
- args.flags = flags;
- args.funcs = funcs;
- args.arg = arg;
- status = ruby_brace_expand(brace_path, flags, push_caller, (VALUE)&args, enc, Qfalse);
- GLOB_FREE(brace_path);
- return status;
- }
-
- if (*path) {
+ if (*base) {
if (match_all && pathtype == path_unknown) {
- if (do_lstat(fd, baselen, path, &st, flags, enc) == 0) {
+ if (do_lstat(fd, base, &st, flags, enc) == 0) {
pathtype = IFTODT(st.st_mode);
}
else {
@@ -2183,7 +2051,7 @@ glob_helper(
}
}
if (match_dir && (pathtype == path_unknown || pathtype == path_symlink)) {
- if (do_stat(fd, baselen, path, &st, flags, enc) == 0) {
+ if (do_stat(fd, base, &st, flags, enc) == 0) {
pathtype = IFTODT(st.st_mode);
}
else {
@@ -2196,11 +2064,10 @@ glob_helper(
if (status) return status;
}
if (match_dir && pathtype == path_directory) {
- int seplen = (baselen && path[baselen] == '/');
- const char *subpath = path + baselen + seplen;
- char *tmp = join_path(subpath, namelen - seplen, dirsep, "", 0);
+ const char *subpath = path + baselen + (baselen && path[baselen] == '/');
+ char *tmp = join_path(subpath, namelen, dirsep, "", 0);
if (!tmp) return -1;
- status = glob_call_func(funcs->match, tmp, arg, enc);
+ status = glob_call_func(funcs->match, tmp + (baselen ? dirsep : 0), arg, enc);
GLOB_FREE(tmp);
if (status) return status;
}
@@ -2219,14 +2086,14 @@ glob_helper(
if (cur + 1 == end && (*cur)->type <= ALPHA) {
plainname = join_path(path, pathlen, dirsep, (*cur)->str, strlen((*cur)->str));
if (!plainname) return -1;
- dirp = do_opendir(fd, basename, plainname, flags, enc, funcs->error, arg, &status);
+ dirp = do_opendir(fd, plainname, flags, enc, funcs->error, arg, &status);
GLOB_FREE(plainname);
}
else
# else
;
# endif
- dirp = do_opendir(fd, baselen, path, flags, enc, funcs->error, arg, &status);
+ dirp = do_opendir(fd, *base ? base : ".", flags, enc, funcs->error, arg, &status);
if (dirp == NULL) {
# if FNM_SYSCASE || NORMALIZE_UTF8PATH
if ((magical < 2) && !recursive && (errno == EACCES)) {
@@ -2236,7 +2103,7 @@ glob_helper(
# endif
return status;
}
- IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp, *path ? path : "."));
+ IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp, *base ? base : "."));
# if NORMALIZE_UTF8PATH
if (!(norm_p || magical || recursive)) {
@@ -2295,7 +2162,7 @@ glob_helper(
if (recursive && dotfile < ((flags & FNM_DOTMATCH) ? 2 : 1) &&
new_pathtype == path_unknown) {
/* RECURSIVE never match dot files unless FNM_DOTMATCH is set */
- if (do_lstat(fd, baselen, buf, &st, flags, enc) == 0)
+ if (do_lstat(fd, buf, &st, flags, enc) == 0)
new_pathtype = IFTODT(st.st_mode);
else
new_pathtype = path_noent;
@@ -2310,7 +2177,6 @@ glob_helper(
for (cur = beg; cur < end; ++cur) {
struct glob_pattern *p = *cur;
- struct dirent_brace_args args;
if (p->type == RECURSIVE) {
if (new_pathtype == path_directory || /* not symlink but real directory */
new_pathtype == path_exist) {
@@ -2320,14 +2186,6 @@ glob_helper(
p = p->next; /* 0 times recursion */
}
switch (p->type) {
- case BRACE:
- args.name = name;
- args.dp = dp;
- args.flags = flags;
- if (ruby_brace_expand(p->str, flags, dirent_match_brace,
- (VALUE)&args, enc, Qfalse) > 0)
- *new_end++ = p->next;
- break;
case ALPHA:
# if USE_NAME_ON_FS == USE_NAME_ON_FS_BY_FNMATCH
if (plainname) {
@@ -2426,42 +2284,6 @@ glob_helper(
}
static int
-push_caller(const char *path, VALUE val, void *enc)
-{
- struct push_glob_args *arg = (struct push_glob_args *)val;
- struct glob_pattern *list;
- int status;
-
- list = glob_make_pattern(path, path + strlen(path), arg->flags, enc);
- if (!list) {
- return -1;
- }
- status = glob_helper(arg->fd, arg->path, arg->baselen, arg->namelen, arg->dirsep,
- arg->pathtype, &list, &list + 1, arg->flags, arg->funcs,
- arg->arg, enc);
- glob_free_pattern(list);
- return status;
-}
-
-static int ruby_glob0(const char *path, int fd, const char *base, int flags,
- const ruby_glob_funcs_t *funcs, VALUE arg, rb_encoding *enc);
-
-struct push_glob0_args {
- int fd;
- const char *base;
- int flags;
- const ruby_glob_funcs_t *funcs;
- VALUE arg;
-};
-
-static int
-push_glob0_caller(const char *path, VALUE val, void *enc)
-{
- struct push_glob0_args *arg = (struct push_glob0_args *)val;
- return ruby_glob0(path, arg->fd, arg->base, arg->flags, arg->funcs, arg->arg, enc);
-}
-
-static int
ruby_glob0(const char *path, int fd, const char *base, int flags,
const ruby_glob_funcs_t *funcs, VALUE arg,
rb_encoding *enc)
@@ -2473,17 +2295,6 @@ ruby_glob0(const char *path, int fd, const char *base, int flags,
int status, dirsep = FALSE;
start = root = path;
-
- if (*root == '{') {
- struct push_glob0_args args;
- args.fd = fd;
- args.base = base;
- args.flags = flags;
- args.funcs = funcs;
- args.arg = arg;
- return ruby_brace_expand(path, flags, push_glob0_caller, (VALUE)&args, enc, Qfalse);
- }
-
flags |= FNM_SYSCASE;
#if defined DOSISH
root = rb_enc_path_skip_prefix(root, root + strlen(root), enc);
@@ -2563,6 +2374,7 @@ push_pattern(const char *path, VALUE ary, void *enc)
#if defined _WIN32 || defined __APPLE__
VALUE name = rb_utf8_str_new_cstr(path);
rb_encoding *eenc = rb_default_internal_encoding();
+ OBJ_TAINT(name);
name = rb_str_conv_enc(name, NULL, eenc ? eenc : enc);
#else
VALUE name = rb_external_str_new_with_enc(path, strlen(path), enc);
@@ -2663,11 +2475,25 @@ ruby_brace_glob(const char *str, int flags, ruby_glob_func *func, VALUE arg)
return ruby_brace_glob_with_enc(str, flags, func, arg, rb_ascii8bit_encoding());
}
+struct push_glob_args {
+ struct glob_args glob;
+ int flags;
+ int fd;
+};
+
+static int
+push_caller(const char *path, VALUE val, void *enc)
+{
+ struct push_glob_args *arg = (struct push_glob_args *)val;
+
+ return ruby_glob0(path, arg->fd, arg->glob.base, arg->flags, &rb_glob_funcs,
+ (VALUE)&arg->glob, enc);
+}
+
static int
push_glob(VALUE ary, VALUE str, VALUE base, int flags)
{
- struct glob_args args;
- int fd;
+ struct push_glob_args args;
rb_encoding *enc = rb_enc_get(str);
#if defined _WIN32 || defined __APPLE__
@@ -2678,51 +2504,62 @@ push_glob(VALUE ary, VALUE str, VALUE base, int flags)
if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII)
enc = rb_ascii8bit_encoding();
flags |= GLOB_VERBOSE;
- args.func = push_pattern;
- args.value = ary;
- args.enc = enc;
- args.base = 0;
- fd = AT_FDCWD;
+ args.glob.func = push_pattern;
+ args.glob.value = ary;
+ args.glob.enc = enc;
+ args.glob.base = 0;
+ args.flags = flags;
+ args.fd = AT_FDCWD;
if (!NIL_P(base)) {
if (!RB_TYPE_P(base, T_STRING) || !rb_enc_check(str, base)) {
struct dir_data *dirp = DATA_PTR(base);
if (!dirp->dir) dir_closed();
#ifdef HAVE_DIRFD
- if ((fd = dirfd(dirp->dir)) == -1)
+ if ((args.fd = dirfd(dirp->dir)) == -1)
rb_sys_fail_path(dir_inspect(base));
#endif
base = dirp->path;
}
- args.base = RSTRING_PTR(base);
+ args.glob.base = RSTRING_PTR(base);
}
#if defined _WIN32 || defined __APPLE__
enc = rb_utf8_encoding();
#endif
- return ruby_glob0(RSTRING_PTR(str), fd, args.base, flags, &rb_glob_funcs,
- (VALUE)&args, enc);
+ return ruby_brace_expand(RSTRING_PTR(str), flags,
+ push_caller, (VALUE)&args, enc, str);
}
static VALUE
rb_push_glob(VALUE str, VALUE base, int flags) /* '\0' is delimiter */
{
+ long offset = 0;
VALUE ary;
- int status;
/* can contain null bytes as separators */
- if (!RB_TYPE_P(str, T_STRING)) {
+ if (!RB_TYPE_P((str), T_STRING)) {
FilePathValue(str);
}
- else if (!rb_str_to_cstr(str)) {
- rb_raise(rb_eArgError, "nul-separated glob pattern is deprecated");
- }
else {
+ rb_check_safe_obj(str);
rb_enc_check(str, rb_enc_from_encoding(rb_usascii_encoding()));
}
ary = rb_ary_new();
- status = push_glob(ary, str, base, flags);
- if (status) GLOB_JUMP_TAG(status);
+ while (offset < RSTRING_LEN(str)) {
+ char *p, *pend;
+ int status;
+ p = RSTRING_PTR(str) + offset;
+ status = push_glob(ary, rb_enc_str_new(p, strlen(p), rb_enc_get(str)),
+ base, flags);
+ if (status) GLOB_JUMP_TAG(status);
+ if (offset >= RSTRING_LEN(str)) break;
+ p += strlen(p) + 1;
+ pend = RSTRING_PTR(str) + RSTRING_LEN(str);
+ while (p < pend && !*p)
+ p++;
+ offset = p - RSTRING_PTR(str);
+ }
return ary;
}
@@ -2813,7 +2650,7 @@ dir_s_aref(int argc, VALUE *argv, VALUE obj)
*
* <code>*</code>::
* Matches any file. Can be restricted by other values in the glob.
- * Equivalent to <code>/ .* /mx</code> in regexp.
+ * Equivalent to <code>/ .* /x</code> in regexp.
*
* <code>*</code>:: Matches all files
* <code>c*</code>:: Matches all files beginning with <code>c</code>
@@ -2858,7 +2695,6 @@ dir_s_aref(int argc, VALUE *argv, VALUE obj)
* Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
* Dir.glob("*") #=> ["config.h", "main.rb"]
* Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
- * Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
*
* rbfiles = File.join("**", "*.rb")
* Dir.glob(rbfiles) #=> ["main.rb",
@@ -2911,7 +2747,7 @@ dir_s_glob(int argc, VALUE *argv, VALUE obj)
static VALUE
dir_open_dir(int argc, VALUE *argv)
{
- VALUE dir = rb_funcallv_kw(rb_cDir, rb_intern("open"), argc, argv, RB_PASS_CALLED_KEYWORDS);
+ VALUE dir = rb_funcallv(rb_cDir, rb_intern("open"), argc, argv);
rb_check_typeddata(dir, &dir_data_type);
return dir;
@@ -2965,8 +2801,8 @@ dir_collect(VALUE dir)
* Dir.entries( dirname, encoding: enc ) -> array
*
* Returns an array containing all of the filenames in the given
- * directory. Will raise a SystemCallError if the named directory
- * doesn't exist.
+ * directory. Will raise a <code>SystemCallError</code> if the named
+ * directory doesn't exist.
*
* The optional <i>encoding</i> keyword argument specifies the encoding of the
* directory. If not specified, the filesystem encoding is used.
@@ -3021,44 +2857,6 @@ dir_s_each_child(int argc, VALUE *argv, VALUE io)
return Qnil;
}
-/*
- * call-seq:
- * dir.each_child {| filename | block } -> nil
- * dir.each_child -> an_enumerator
- *
- * Calls the block once for each entry except for "." and ".." in
- * this directory, passing the filename of each entry as a parameter
- * to the block.
- *
- * If no block is given, an enumerator is returned instead.
- *
- * d = Dir.new("testdir")
- * d.each_child {|x| puts "Got #{x}" }
- *
- * <em>produces:</em>
- *
- * Got config.h
- * Got main.rb
- *
- */
-static VALUE
-dir_each_child_m(VALUE dir)
-{
- RETURN_ENUMERATOR(dir, 0, 0);
- return dir_each_entry(dir, dir_yield, Qnil, TRUE);
-}
-
-/*
- * call-seq:
- * dir.children -> array
- *
- * Returns an array containing all of the filenames except for "."
- * and ".." in this directory.
- *
- * d = Dir.new("testdir")
- * d.children #=> ["config.h", "main.rb"]
- *
- */
static VALUE
dir_collect_children(VALUE dir)
{
@@ -3073,8 +2871,8 @@ dir_collect_children(VALUE dir)
* Dir.children( dirname, encoding: enc ) -> array
*
* Returns an array containing all of the filenames except for "."
- * and ".." in the given directory. Will raise a SystemCallError if
- * the named directory doesn't exist.
+ * and ".." in the given directory. Will raise a
+ * <code>SystemCallError</code> if the named directory doesn't exist.
*
* The optional <i>encoding</i> keyword argument specifies the encoding of the
* directory. If not specified, the filesystem encoding is used.
@@ -3176,7 +2974,6 @@ fnmatch_brace(const char *pattern, VALUE val, void *enc)
*
* File.fnmatch('cat', 'CAT') #=> false # case sensitive
* File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive
- * File.fnmatch('cat', 'CAT', File::FNM_SYSCASE) #=> true or false # depends on the system default
*
* File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME
* File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto
@@ -3382,9 +3179,10 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
}
/*
- * Objects of class Dir are directory streams representing
- * directories in the underlying file system. They provide a variety
- * of ways to list directories and their contents. See also File.
+ * Objects of class <code>Dir</code> are directory streams representing
+ * directories in the underlying file system. They provide a variety of
+ * ways to list directories and their contents. See also
+ * <code>File</code>.
*
* The directory used in these examples contains the two regular files
* (<code>config.h</code> and <code>main.rb</code>), the parent
@@ -3412,8 +3210,6 @@ Init_Dir(void)
rb_define_method(rb_cDir,"inspect", dir_inspect, 0);
rb_define_method(rb_cDir,"read", dir_read, 0);
rb_define_method(rb_cDir,"each", dir_each, 0);
- rb_define_method(rb_cDir,"each_child", dir_each_child_m, 0);
- rb_define_method(rb_cDir,"children", dir_collect_children, 0);
rb_define_method(rb_cDir,"rewind", dir_rewind, 0);
rb_define_method(rb_cDir,"tell", dir_tell, 0);
rb_define_method(rb_cDir,"seek", dir_seek, 1);
diff --git a/dln.c b/dln.c
index c40cbfc6ac..55f29fda51 100644
--- a/dln.c
+++ b/dln.c
@@ -22,7 +22,6 @@
static void dln_loaderror(const char *format, ...);
#endif
#include "dln.h"
-#include "internal.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
@@ -232,13 +231,13 @@ load_header(int fd, struct exec *hdrp, long disp)
# define R_RIGHTSHIFT(r) (reloc_r_rightshift[(r)->r_type])
# define R_BITSIZE(r) (reloc_r_bitsize[(r)->r_type])
# define R_LENGTH(r) (reloc_r_length[(r)->r_type])
-static const int reloc_r_rightshift[] = {
+static int reloc_r_rightshift[] = {
0, 0, 0, 0, 0, 0, 2, 2, 10, 0, 0, 0, 0, 0, 0,
};
-static const int reloc_r_bitsize[] = {
+static int reloc_r_bitsize[] = {
8, 16, 32, 8, 16, 32, 30, 22, 22, 22, 13, 10, 32, 32, 16,
};
-static const int reloc_r_length[] = {
+static int reloc_r_length[] = {
0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
};
# define R_PCREL(r) \
@@ -1171,7 +1170,7 @@ dln_strerror(void)
}
#endif
-#if defined(_AIX)
+#if defined(_AIX) && ! defined(_IA64)
static void
aix_loaderror(const char *pathname)
{
@@ -1243,20 +1242,6 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine)
#define translit_separator(str) (void)(str)
#endif
-#ifdef USE_DLN_DLOPEN
-COMPILER_WARNING_PUSH
-#if defined(__clang__) || GCC_VERSION_SINCE(4, 2, 0)
-COMPILER_WARNING_IGNORED(-Wpedantic)
-#endif
-static bool
-dln_incompatible_library_p(void *handle)
-{
- void *ex = dlsym(handle, EXTERNAL_PREFIX"ruby_xmalloc");
- return ex && ex != ruby_xmalloc;
-}
-COMPILER_WARNING_POP
-#endif
-
void*
dln_load(const char *file)
{
@@ -1344,7 +1329,8 @@ dln_load(const char *file)
}
# if defined RUBY_EXPORT
{
- if (dln_incompatible_library_p(handle)) {
+ void *ex = dlsym(handle, EXTERNAL_PREFIX"ruby_xmalloc");
+ if (ex && ex != ruby_xmalloc) {
# if defined __APPLE__ && \
defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
@@ -1400,7 +1386,7 @@ dln_load(const char *file)
}
#endif /* hpux */
-#if defined(_AIX)
+#if defined(_AIX) && ! defined(_IA64)
#define DLN_DEFINED
{
void (*init_fct)();
diff --git a/dmydln.c b/dmydln.c
index d05cda0b8e..0fc0a5325e 100644
--- a/dmydln.c
+++ b/dmydln.c
@@ -6,5 +6,5 @@ dln_load(const char *file)
{
rb_loaderror("this executable file can't load extension libraries");
- UNREACHABLE_RETURN(NULL);
+ UNREACHABLE;
}
diff --git a/doc/ChangeLog-0.60_to_1.1 b/doc/ChangeLog-0.60_to_1.1
index bd5f140dc3..33b0326892 100644
--- a/doc/ChangeLog-0.60_to_1.1
+++ b/doc/ChangeLog-0.60_to_1.1
@@ -3166,7 +3166,7 @@ Fri Aug 11 14:37:03 1995 Yukihiro Matsumoto <matz@caelum.co.jp>
* io.c: マクロREAD_DATA_PENDINGã®å®šç¾©ã‚’変更(Linux対応)
- * io.c (io_fptr_finalize): fptrã®è§£æ”¾æ™‚ã®å‡¦ç†ã‚’指定ã§ãるよã†ã«ï¼Ž
+ * io.c (io_fptr_finalize): fptrã®é–‹æ”¾æ™‚ã®å‡¦ç†ã‚’指定ã§ãるよã†ã«ï¼Ž
Wed Aug 9 16:52:41 1995 Yukihiro Matsumoto <matz@caelum.co.jp>
@@ -3448,7 +3448,7 @@ Thu May 18 12:27:23 1995 Yukihiro Matsumoto <matz@ix-02>
ç„¡ããªã£ãŸ(ã¨æ€ã†).
* gc.c (gc): the_scopeをマークã—ã¦ã„ãªã‹ã£ãŸã®ã§ï¼Œãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã®æŒ‡
- ã—ã¦ã„るオブジェクトãŒé–“é•ã£ã¦è§£æ”¾ã•れる場åˆãŒã‚ã£ãŸï¼Ž
+ ã—ã¦ã„るオブジェクトãŒé–“é•ã£ã¦é–‹æ”¾ã•れる場åˆãŒã‚ã£ãŸï¼Ž
* gc.c (mark_locations_array): 若干ã®é«˜é€ŸåŒ–.
diff --git a/doc/ChangeLog-1.8.0 b/doc/ChangeLog-1.8.0
index 6d9453d011..3f7d6bfb3c 100644
--- a/doc/ChangeLog-1.8.0
+++ b/doc/ChangeLog-1.8.0
@@ -13020,7 +13020,7 @@ Tue Jun 12 00:41:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
Mon Jun 11 14:29:41 2001 WATANABE Hirofumi <eban@ruby-lang.org>
- * configure.in: add RUBY_CANONICAL_BUILD.
+ * confgure.in: add RUBY_CANONICAL_BUILD.
Sun Jun 10 17:31:47 2001 Guy Decoux <decoux@moulon.inra.fr>
diff --git a/doc/ChangeLog-2.4.0 b/doc/ChangeLog-2.4.0
index 96b5ecb077..1714b7caec 100644
--- a/doc/ChangeLog-2.4.0
+++ b/doc/ChangeLog-2.4.0
@@ -4690,7 +4690,7 @@ Thu May 19 13:22:44 2016 Kazuki Yamaguchi <k@rhe.jp>
* ext/openssl/ossl.c (Init_openssl): register an ex_data index for
X509_STORE and X509_STORE_CTX respectively. Since they don't share
the ex_data index registry, we can't use the same index.
- (ossl_verify_cb): use the correct index.
+ (ossl_verify_cb): use the the correct index.
* ext/openssl/ossl_ssl.c (ossl_ssl_verify_callback): ditto.
diff --git a/doc/ChangeLog-2016 b/doc/ChangeLog-2016
new file mode 100644
index 0000000000..14fcba55ab
--- /dev/null
+++ b/doc/ChangeLog-2016
@@ -0,0 +1,6 @@
+------------------------------------------------------------------------
+r57181 | matz | 2016-12-26 01:35:51 +0900 (Mon, 26 Dec 2016) | 2 lines
+
+version.h (RUBY_VERSION): 2.5.0 development has started.
+
+------------------------------------------------------------------------
diff --git a/doc/NEWS-1.9.2 b/doc/NEWS-1.9.2
index 430c6cc4f5..fedb1f6633 100644
--- a/doc/NEWS-1.9.2
+++ b/doc/NEWS-1.9.2
@@ -240,7 +240,7 @@ with all sufficient information, see the ChangeLog file.
* new alias of item.guid.isPermaLink=
* DL
- * Now uses libffi as a backend if available.
+ * Now uses libffi as a backend if avaiable.
It means DL works fine on more platforms.
* Fiddle
diff --git a/doc/NEWS-2.0.0 b/doc/NEWS-2.0.0
index 414789dcd1..5c9f5bdc53 100644
--- a/doc/NEWS-2.0.0
+++ b/doc/NEWS-2.0.0
@@ -94,7 +94,7 @@ with all sufficient information, see the ChangeLog file.
required caller size.
* Kernel#to_enum and enum_for accept a block for lazy size evaluation.
* incompatible changes:
- * system() and exec() close non-standard file descriptors
+ * system() and exec() closes non-standard file descriptors
(The default of :close_others option is changed to true by default.)
* respond_to? against a protected method now returns false unless
the second argument is true.
@@ -528,3 +528,4 @@ with all sufficient information, see the ChangeLog file.
* NUM2SHORT() and NUM2USHORT() added. They are similar to NUM2INT, but short.
* rb_newobj_of() and NEWOBJ_OF() added. They create a new object of a given class.
+
diff --git a/doc/NEWS-2.5.0 b/doc/NEWS-2.5.0
deleted file mode 100644
index c891317b61..0000000000
--- a/doc/NEWS-2.5.0
+++ /dev/null
@@ -1,565 +0,0 @@
-# -*- rdoc -*-
-
-= NEWS for Ruby 2.5.0
-
-This document is a list of user visible feature changes made between
-releases except for bug fixes.
-
-Note that each entry is kept so brief that no reason behind or
-reference information is supplied with. For a full list of changes
-with all sufficient information, see the ChangeLog file or Redmine
-(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>)
-
-== Changes since the 2.4.0 release
-
-=== Language changes
-
-* Top-level constant look-up is removed. [Feature #11547]
-
-* rescue/else/ensure are allowed inside do/end blocks. [Feature #12906]
-
-* refinements take place in string interpolations. [Feature #13812]
-
-=== Core classes updates (outstanding ones only)
-
-* Array
-
- * New methods:
-
- * Array#append [Feature #12746]
- * Array#prepend [Feature #12746]
-
-* Data
-
- * Is deprecated. It was a base class for C extensions, and it's not
- necessary to expose in Ruby level. [Feature #3072]
-
-* Exception
-
- * New methods:
-
- * Exception#full_message to retrieve a String expression of an exception,
- formatted in the same way in which Ruby prints out an uncaught
- exception. [Feature #14141] [experimental]
-
-* Dir
-
- * Dir.glob provides new optional keyword argument, +:base+ . [Feature #13056]
- * Dir.chdir (without block arg), Dir.open, Dir.new, Dir.mkdir, Dir.rmdir,
- Dir.empty? releases GVL
-
- * New methods:
-
- * Dir.children [Feature #11302]
- * Dir.each_child [Feature #11302]
-
-* Enumerable
-
- * Enumerable#any?, Enumerable#all?, Enumerable#none? and Enumerable#one?
- accept a pattern argument. [Feature #11286]
-
-* File
-
- * File.open accepts +:newline+ option to imply text mode. [Bug #13350]
- * File#path raises an IOError for files opened with
- File::Constants::TMPFILE option. [Feature #13568]
- * File.stat, File.exist? and other <code>rb_stat()</code>-using methods
- release GVL. [Bug #13941]
- * File.rename releases GVL. [Feature #13951]
- * File::Stat#atime, File::Stat#mtime and File::Stat#ctime support fractional
- second timestamps on Windows 8 and later. [Feature #13726]
- * File::Stat#ino and File.identical? support ReFS 128bit ino on Windows 8.1
- and later. [Feature #13731]
- * File.readable?, File.readable_real?, File.writable?, File.writable_real?,
- File.executable?, File.executable_real?, File.mkfifo, File.readlink,
- File.truncate, File#truncate, File.chmod, File.lchmod, File.chown,
- File.lchown, File.unlink, File.utime, File.lstat release GVL
-
- * New method:
-
- * File.lutime [Feature #4052]
-
-* Hash
-
- * New methods:
-
- * Hash#transform_keys [Feature #13583]
- * Hash#transform_keys! [Feature #13583]
- * Hash#slice [Feature #8499]
-
-* IO
-
- * IO.copy_stream tries copy offload with copy_file_range(2) [Feature #13867]
-
- * New methods:
-
- * IO#pread [Feature #4532]
- * IO#pwrite [Feature #4532]
- * IO#write accepts multiple arguments [Feature #9323]
-
-* IOError
-
- * IO#close might raise an error with message "stream closed",
- but it is refined to "stream closed in another thread". The new message
- is more clear for user. [Bug #13405]
-
-* Integer
-
- * Integer#round, Integer#floor, Integer#ceil and Integer#truncate always
- return an Integer. [Bug #13420]
- * Integer#pow accepts modulo argument for calculating modular
- exponentiation. [Feature #12508] [Feature #11003]
-
- * New methods:
-
- * Integer#allbits?, Integer#anybits?, Integer#nobits? [Feature #12753]
- * Integer.sqrt [Feature #13219]
-
-* Kernel
-
- * Kernel#yield_self [Feature #6721]
- * Kernel#pp [Feature #14123]
- * Kernel#warn(..., uplevel:n) [Feature #12882]
-
-* Method
-
- * New methods:
-
- * Method#=== that invokes Method#call, as same as Proc#=== [Feature #14142]
-
-* Module
-
- * Module#attr, Module#attr_accessor, Module#attr_reader and Module#attr_writer
- become public. [Feature #14132]
- * Module#define_method, Module#alias_method, Module#undef_method and
- Module#remove_method become public. [Feature #14133]
-
-* Numeric
-
- * Numeric#step no longer hides errors from coerce method when
- given a step value which cannot be compared with #> to 0. [Feature #7688]
- * Numerical comparison operators (<,<=,>=,>) no longer hide exceptions
- from #coerce method internally. Return nil in #coerce if the coercion is
- impossible. [Feature #7688]
-
-* Process
-
- * Precision of Process.times is improved if getrusage(2) exists. [Feature #11952]
-
- * New method:
-
- * Process.last_status as an alias of $? [Feature #14043]
-
-* Range
- * Range#initialize no longer hides exceptions when comparing begin and
- end with #<=> and raise a "bad value for range" ArgumentError
- but instead lets the exception from the #<=> call go through. [Feature #7688]
-
-* Regexp
-
- * Update to Onigmo 6.1.3-669ac9997619954c298da971fcfacccf36909d05.
-
- * Support absence operator https://github.com/k-takata/Onigmo/issues/82
-
- * Support new 5 emoji-related Unicode character properties
-
-* RubyVM::InstructionSequence
-
- * New method:
-
- * RubyVM::InstructionSequence#each_child
- * RubyVM::InstructionSequence#trace_points
-
-* String
-
- * <code>String#-@</code> deduplicates unfrozen strings. Already-frozen
- strings remain unchanged for compatibility. [Feature #13077]
- * <code>-"literal"</code> (<code>String#-@</code>) optimized to return the same object
- (same as <code>"literal".freeze</code> in Ruby 2.1+) [Feature #13295]
- * String#casecmp and String#casecmp? return nil for non-string arguments
- instead of raising a TypeError. [Bug #13312]
- * String#start_with? accepts a regexp [Feature #13712]
-
- * New methods:
-
- * String#delete_prefix, String#delete_prefix! [Feature #12694]
- * String#delete_suffix, String#delete_suffix! [Feature #13665]
- * String#each_grapheme_cluster and String#grapheme_clusters to
- enumerate grapheme clusters [Feature #13780]
- * String#undump to unescape String#dump'ed string [Feature #12275]
-
-* Struct
-
- * Struct.new takes `keyword_init: true` option to initialize members
- with keyword arguments. [Feature #11925]
-
-* Regexp/String: Update Unicode version from 9.0.0 to 10.0.0 [Feature #13685]
-
-* Thread
-
- * Description set by Thread#name= is now visible on Windows 10.
-
- * New method:
- * Thread#fetch [Feature #13009]
-
- * The default of Thread.report_on_exception is now true,
- showing unhandled exceptions terminating threads on $stderr. [Feature #14143]
-
-* Time
-
- * Time.at receives 3rd argument which specifies the unit of 2nd argument. [Feature #13919]
-
-* KeyError
-
- * New methods:
-
- * KeyError#receiver [Feature #12063]
- * KeyError#key [Feature #12063]
-
-* FrozenError
-
- * New exception class. [Feature #13224]
-
-=== Stdlib updates (outstanding ones only)
-
-* BigDecimal
-
- * Update to BigDecimal 1.3.4
-
- * The following features are added:
-
- * BigDecimal::VERSION
-
- * The following features have been deprecated,
- and are planned to be removed in the version 1.4.0:
-
- * BigDecimal.new
-
- * BigDecimal.ver
-
- * BigDecimal#clone and #dup now do not make a new instance,
- but returns the receiver itself.
-
-* Coverage
-
- * Support branch coverage and method coverage measurement. [Feature #13901]
- Branch coverage tells you which branches are executed, and which not.
- Method coverage tells you which methods are invoked, and which not.
- By running a test suite with this new feature, you can know which branches
- and methods are executed by a test, and evaluate total coverage of a test
- suite more strictly.
-
- You can specify the measuring target by an option to `Coverage.start`:
-
- Coverage.start(lines: true, branches: true, methods: true)
-
- After some Ruby files are loaded, you can use `Coverage.result` to get
- the coverage result:
-
- Coverage.result
- #=> { "/path/to/file.rb"=>
- # { :lines => [1, 2, 0, nil, ...],
- # :branches =>
- # { [:if, 0, 2, 1, 6, 4] =>
- # { [:then, 1, 3, 2, 3, 8] => 0,
- # [:else, 2, 5, 2, 5, 8] => 2
- # }
- # },
- # :methods => {
- # [Object, :foo, 1, 0, 7, 3] => 2
- # }
- # }
- # }
-
- The result type of line coverage is not changed; it is just an array that
- contains numbers, which means the count that each line was executed,
- or `nil`s, which means that the line is not relevant.
-
- The result type of branch coverage is:
-
- { (jump base) => { (jump target) => (counter) } }
-
- where jump base and targets have the format
-
- [type, unique-id, start lineno, start column, end lineno, end column]
-
- For example, `[:if, 0, 2, 1, 6, 4]` reads an `if` statement that ranges from
- line 2 and column 1, to line 6 and column 4. `[:then, 1, 3, 2, 3, 8]` reads
- a `then` clause that ranges from line 3 and column 2, to line 3 and column 8.
- Note that lineno starts from 1, and that columnno starts from 0. So, the
- above example shows a branch from the `if` to the `then` was never executed,
- and a branch from the `if` to the `else` was executed twice.
-
- The result type of method coverage is:
-
- { (method key) => (counter) }
-
- where method key has the format
-
- [class, method-name, start lineno, start column, end lineno, end column]
-
- For example, `[Object, :foo, 1, 0, 7, 3]` reads `Object#foo` that ranges from
- line 1 and column 0, to line 7 and column 3. The above example shows this
- `Object#foo` was invoked twice.
-
- Note: To keep compatibility, passing no option to `Coverage.start` will measure
- only line coverage, and `Coverage.result` will return the old format:
-
- Coverage.result
- #=> { "/path/to/file.rb"=> [1, 2, 0, nil, ...] }
-
-* DRb
-
- * ACL::ACLEntry.new no longer suppresses IPAddr::InvalidPrefixError.
-
-* ERB
-
- * Add ERB#result_with_hash to render a template with local variables passed
- with a Hash object. [Feature #8631]
-
- * Default template file encoding is changed from ASCII-8BIT to UTF-8 in erb
- command. [Bug #14095]
-
- * Carriage returns are changed to be trimmed properly if trim_mode is specified
- and used. Duplicated newlines will be removed on Windows. [Bug #5339] [Bug #11464]
-
-* IPAddr
-
- * IPAddr no longer accepts invalid address mask. [Bug #13399]
- * IPAddr#ipv4_compat and IPAddr#ipv4_compat? are marked for deprecation. [Bug #13769]
-
- * New methods:
-
- * IPAddr#prefix
- * IPAddr#loopback?
- * IPAddr#private? [Feature #11666]
- * IPAddr#link_local? [Feature #10912]
-
-* IRB
-
- * Print backtrace and error message in reverse order [Feature #8661] [experimental]
- * `binding.irb` automatically requires irb and runs [Bug #13099] [experimental]
- * `binding.irb` on its start shows source around the line where it was called [Feature #14124]
-
-* Matrix
-
- * New methods:
-
- * Matrix.combine and Matrix#combine [Feature #10903]
- * Matrix#hadamard_product and Matrix#entrywise_product
-
-* Net::HTTP
-
- * Net::HTTP.new supports no_proxy parameter [Feature #11195]
- * Net::HTTP#min_version and Net::HTTP#max_version [Feature #9450]
- * Add more HTTP status classes
- * Net::HTTP::STATUS_CODES is added as HTTP Status Code Repository [Misc #12935]
- * Net::HTTP#proxy_user and Net::HTTP#proxy_pass reflect http_proxy environment
- variable if the system's environment variable is multiuser safe. [Bug #12921]
-
-* open-uri
- * URI.open method defined as an alias to open-uri's Kernel.open.
- open-uri's Kernel.open will be deprecated in future.
-
-* OpenSSL
-
- * Updated Ruby/OpenSSL from version 2.0 to 2.1. Changes are noted in
- "Version 2.1.0" section in ext/openssl/History.md.
-
-* Pathname
-
- * New method:
-
- * Pathname#glob [Feature #7360]
-
-* Psych
-
- * Update to Psych 3.0.2.
-
- * Convert fallback option to a keyword argument
- https://github.com/ruby/psych/pull/342
- * Add :symbolize_names option to Psych.load, Psych.safe_load like JSON.parse
- https://github.com/ruby/psych/pull/333, https://github.com/ruby/psych/pull/337
- * Add Psych::Handler#event_location
- https://github.com/ruby/psych/pull/326
- * Make frozen string literal = true
- https://github.com/ruby/psych/pull/320
- * Preserve time zone offset when deserializing times
- https://github.com/ruby/psych/pull/316
- * Remove deprecated method aliases for syck gem
- https://github.com/ruby/psych/pull/312
-
-* RbConfig
-
- * RbConfig::LIMITS is added to provide the limits of C types.
- This is available when rbconfig/sizeof is loaded.
-
-* Ripper
-
- * Ripper::EXPR_BEG and so on for Ripper#state.
-
- * New method:
-
- * Ripper#state to tell the state of scanner. [Feature #13686]
-
-* RDoc
-
- * Update to RDoc 6.0.1.
-
- * Replace IRB based lexer with Ripper.
- * https://github.com/ruby/rdoc/pull/512
- * This much improves the speed of generating documents.
- * It also facilitates supporting new syntax in the future.
- * Support many new syntaxes of Ruby from the past few years.
- * Use "frozen_string_literal: true".
- Performance survey: https://gist.github.com/aycabta/abdfaa75ea8a6877eeb734e942e73800
- * Support did_you_mean.
-
-* Rubygems
-
- * Update to Rubygems 2.7.3.
- * http://blog.rubygems.org/2017/11/28/2.7.3-released.html
- * http://blog.rubygems.org/2017/11/08/2.7.2-released.html
- * http://blog.rubygems.org/2017/11/03/2.7.1-released.html
- * http://blog.rubygems.org/2017/11/01/2.7.0-released.html
- * http://blog.rubygems.org/2017/10/09/2.6.14-released.html
- * http://blog.rubygems.org/2017/08/27/2.6.13-released.html
-
-* SecureRandom
-
- * New method:
-
- * SecureRandom.alphanumeric
-
-* Set
-
- * New methods:
-
- * Set#to_s as alias to #inspect [Feature #13676]
- * Set#=== as alias to #include? [Feature #13801]
- * Set#reset [Feature #6589]
-
-* StringIO
-
- * StringIO#write accepts multiple arguments
-
-* StringScanner
-
- * New methods:
-
- * StringScanner#size, StringScanner#captures, StringScanner#values_at [Feature #836]
-
-* URI
-
- * Relative path operations no longer collapse consecutive slashes to a single slash. [Bug #8352]
-
-* WEBrick
-
- * Add Server Name Indication (SNI) support [Feature #13729]
- * support Proc objects as body responses [Feature #855]
- * released as a RubyGem [Feature #13173]
- * avoid unintended behavior from Kernel#open [Misc #14216]
-
-* Zlib
-
- * Zlib::GzipWriter#write accepts multiple arguments
-
-=== Compatibility issues (excluding feature bug fixes)
-
-* Socket
-
- * BasicSocket#read_nonblock and BasicSocket#write_nonblock no
- longer set the O_NONBLOCK file description flag as side effect
- (on Linux only) [Feature #13362]
-
-* Random
-
- * Random.raw_seed renamed to become Random.urandom. It is now
- applicable to non-seeding purposes due to [Bug #9569].
-
-* Socket
-
- * Socket::Ifaddr#vhid is added [Feature #13803]
-
-* ConditionVariable, Queue and SizedQueue reimplemented for speed.
- They no longer subclass Struct. [Feature #13552]
-
-=== Stdlib compatibility issues (excluding feature bug fixes)
-
-* Gemification
-
- * Promote following standard libraries to default gems.
- * cmath
- * csv
- * date
- * dbm
- * etc
- * fcntl
- * fiddle
- * fileutils
- * gdbm
- * ipaddr
- * scanf
- * sdbm
- * stringio
- * strscan
- * webrick
- * zlib
-
-* Logger
-
- * Logger.new("| command") had been working to open a command
- unintentionally. It was prohibited, and now Logger#initialize
- treats a String argument only as a filename, as its specification. [Bug #14212]
-
-* Net::HTTP
-
- * Net::HTTP#start now passes :ENV to p_addr by default. [Bug #13351]
- To avoid this, pass nil explicitly.
-
-* mathn.rb
-
- * Removed from stdlib. [Feature #10169]
-
-* Rubygems
-
- * Removed "ubygems.rb" file from stdlib. It's needless since Ruby 1.9.
-
-=== Supported platform changes
-
-* Drop support of NaCl platform
-
- * https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160
-
-=== Implementation improvements
-
-* (This might not be a "user visible feature change" but) Hash class's
- hash function is now SipHash13. [Feature #13017]
-
-* SecureRandom now prefers OS-provided sources than OpenSSL. [Bug #9569]
-
-* Mutex rewritten to be smaller and faster [Feature #13517]
-
-* Performance of block passing using block parameters is improved by
- lazy Proc allocation [Feature #14045]
-
-* Dynamic instrumentation for TracePoint hooks instead of using "trace"
- instruction to avoid overhead [Feature #14104]
-
-* ERB now generates code from a template twice as fast as Ruby 2.4
-
-=== Miscellaneous changes
-
-* Print backtrace and error message in reverse order if $stderr is unchanged
- and a tty. [Feature #8661] [experimental]
-
-* Print error message in bold/underlined text if $stderr is unchanged and a
- tty. [Feature #14140] [experimental]
-
-* configure option --with-ext now mandates its arguments. So for
- instance if you run ./configure --with-ext=openssl,+ then the
- openssl library is guaranteed compiled, otherwise the build fails
- abnormally.
-
- Note however to always add the ",+" at the end of the argument.
- Otherwise nothing but openssl are built. [Feature #13302]
diff --git a/doc/NEWS-2.6.0 b/doc/NEWS-2.6.0
deleted file mode 100644
index 2303a5bd41..0000000000
--- a/doc/NEWS-2.6.0
+++ /dev/null
@@ -1,662 +0,0 @@
-# -*- rdoc -*-
-
-= NEWS for Ruby 2.6.0
-
-This document is a list of user visible feature changes made between
-releases except for bug fixes.
-
-Note that each entry is kept so brief that no reason behind or reference
-information is supplied with. For a full list of changes with all
-sufficient information, see the ChangeLog file or Redmine
-(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>)
-
-== Changes since the 2.5.0 release
-
-=== Language changes
-
-* <code>$SAFE</code> now is a process global state and can be set to 0 again. [Feature #14250]
-
-* Refinements take place at block passing. [Feature #14223]
-
-* Refinements take place at Kernel#public_send. [Feature #15326]
-
-* Refinements take place at Kernel#respond_to?. [Feature #15327]
-
-* +else+ without +rescue+ now causes a syntax error. [EXPERIMENTAL] [Feature #14606]
-
-* Constant names may start with a non-ASCII capital letter. [Feature #13770]
-
-* Endless ranges are introduced. You can use a Range that has no end,
- like <code>(0..)</code> (or similarly <code>(0...)</code>). [Feature #12912]
-
- The following shows typical use cases:
-
- ary[1..] # identical to ary[1..-1]
- (1...).each {|index| block } # infinite loop from index 1
- ary.zip(1..) {|elem, index| block } # ary.each.with_index(1) { }
-
-* Non-Symbol keys in a keyword arguments hash cause an exception.
-
-* The "shadowing outer local variable" warning is removed. [Feature #12490]
-
- You can now write the following without warning:
-
- user = users.find {|user| cond(user) }
-
-* Print +cause+ of the exception if the exception is not caught and printed
- its backtraces and error message. [Feature #8257]
-
-* The flip-flop syntax is deprecated. [Feature #5400]
-
-=== Core classes updates (outstanding ones only)
-
-Array::
-
- New methods::
-
- * Added Array#union and Array#difference instance methods. [Feature #14097]
-
- Modified method::
-
- * Array#to_h now accepts a block that maps elements to new key/value pairs. [Feature #15143]
-
- Aliased methods::
-
- * Array#filter is a new alias for Array#select. [Feature #13784]
- * Array#filter! is a new alias for Array#select!. [Feature #13784]
-
-Binding::
-
- New method::
-
- * Added Binding#source_location. [Feature #14230]
-
- This method returns the source location of the binding, a 2-element
- array of <code>__FILE__</code> and <code>__LINE__</code>.
- Traditionally, the same information could be retrieved by
- <code>eval("[__FILE__, __LINE__]", binding)</code>, but we are
- planning to change this behavior so that Kernel#eval ignores
- binding's source location [Bug #4352]. So, users should use this
- newly-introduced method instead of Kernel#eval.
-
-Dir::
-
- New methods::
-
- * Added Dir#each_child and Dir#children instance methods. [Feature #13969]
-
-Enumerable::
-
- New method::
-
- * Enumerable#chain returns an enumerator object that iterates over the
- elements of the receiver and then those of each argument
- in sequence. [Feature #15144]
-
- Modified method::
-
- * Enumerable#to_h now accepts a block that maps elements to new key/value pairs. [Feature #15143]
-
- Aliased method::
-
- * Enumerable#filter is a new alias for Enumerable#select. [Feature #13784]
-
-Enumerator::ArithmeticSequence::
-
- * This is a new class to represent a generator of an arithmetic sequence,
- that is a number sequence defined by a common difference. It can be used
- for representing what is similar to Python's slice. You can get an
- instance of this class from Numeric#step and Range#step.
-
-Enumerator::Chain::
-
- * This is a new class to represent a chain of enumerables that works as a
- single enumerator, generated by such methods as Enumerable#chain and
- Enumerator#+.
-
-Enumerator::Lazy::
-
- Aliased method::
-
- * Enumerator::Lazy#filter is a new alias for
- Enumerator::Lazy#select. [Feature #13784]
-
-Enumerator::
-
- New methods::
-
- * Enumerator#+ returns an enumerator object that iterates over the
- elements of the receiver and then those of the other operand. [Feature #15144]
-
-ENV::
-
- Modified method::
-
- * ENV.to_h now accepts a block that maps names and values to new keys and values. [Feature #15143]
-
-Exception::
-
- New options::
-
- * Exception#full_message takes +:highlight+ and +:order+
- options. [Bug #14324]
-
-Hash::
-
- Modified methods::
-
- * Hash#merge, Hash#merge!, and Hash#update now accept multiple
- arguments. [Feature #15111]
-
- * Hash#to_h now accepts a block that maps keys and values to new keys and values. [Feature #15143]
-
- Aliased methods::
-
- * Hash#filter is a new alias for Hash#select. [Feature #13784]
-
- * Hash#filter! is a new alias for Hash#select!. [Feature #13784]
-
-IO::
-
- New option::
-
- * Added new mode character <code>'x'</code> to open files for exclusive
- access. [Feature #11258]
-
-Kernel::
-
- Aliased method::
-
- * Kernel#then is a new alias for Kernel#yield_self. [Feature #14594]
-
- New options::
-
- * Kernel#Complex, Kernel#Float, Kernel#Integer, and
- Kernel#Rational take an +:exception+ option to specify the way of
- error handling. [Feature #12732]
-
- * Kernel#system takes an +:exception+ option to raise an exception
- on failure. [Feature #14386]
-
- Incompatible changes::
-
- * Kernel#system and Kernel#exec do not close non-standard file descriptors
- (the default of the +:close_others+ option is changed to +false+,
- but we still set the +FD_CLOEXEC+ flag on descriptors we
- create). [Misc #14907]
-
-KeyError::
-
- New options::
-
- * KeyError.new accepts +:receiver+ and +:key+ options to set receiver and
- key in Ruby code. [Feature #14313]
-
-Method::
-
- New methods::
-
- * Added Method#<< and Method#>> for Proc composition. [Feature #6284]
-
-Module::
-
- Modified methods::
-
- * Module#method_defined?, Module#private_method_defined?, and
- Module#protected_method_defined? now accept the second
- parameter as optional. If it is +true+ (the default value), it checks
- ancestor modules/classes, or checks only the class itself. [Feature #14944]
-
-NameError::
-
- New option::
-
- * NameError.new accepts a +:receiver+ option to set receiver in Ruby
- code. [Feature #14313]
-
-NilClass::
-
- New method::
-
- * NilClass#=~ is added for compatibility. [Feature #15231]
-
-NoMethodError::
-
- New option::
-
- * NoMethodError.new accepts a +:receiver+ option to set receiver in Ruby
- code. [Feature #14313]
-
-Numeric::
-
- Incompatible changes::
-
- * Numeric#step now returns an instance of the Enumerator::ArithmeticSequence
- class rather than one of the Enumerator class.
-
-OpenStruct::
-
- Modified method::
-
- * OpenStruct#to_h now accepts a block that maps keys and values to new keys and values. [Feature #15143]
-
-Proc::
-
- New methods::
-
- * Added Proc#<< and Proc#>> for Proc composition. [Feature #6284]
-
- Incompatible changes::
-
- * Proc#call doesn't change <code>$SAFE</code> any more. [Feature #14250]
-
-Random::
-
- New method::
-
- * Added Random.bytes. [Feature #4938]
-
-Range::
-
- New method::
-
- * Added Range#% instance method. [Feature #14697]
-
- Incompatible changes::
-
- * Range#=== now uses the +#cover?+ instead of the +#include?+ method. [Feature #14575]
- * Range#cover? now accepts a Range object. [Feature #14473]
- * Range#step now returns an instance of the Enumerator::ArithmeticSequence
- class rather than one of the Enumerator class.
-
-Regexp/String::
-
- * Update Unicode version from 10.0.0 to 11.0.0. [Feature #14802]
-
- This includes a rewrite of the grapheme cluster (/\X/) algorithm
- and special-casing for Georgian MTAVRULI on String#downcase.
-
- * Update Emoji version from 5.0 to 11.0.0 [Feature #14802]
-
-RubyVM::AbstractSyntaxTree::
-
- New methods::
-
- * RubyVM::AbstractSyntaxTree.parse parses a given string and returns AST
- nodes. [experimental]
-
- * RubyVM::AbstractSyntaxTree.parse_file parses a given file and returns AST
- nodes. [experimental]
-
- * RubyVM::AbstractSyntaxTree.of returns AST nodes of the given proc or
- method. [experimental]
-
-RubyVM::
-
- New method::
-
- * RubyVM.resolve_feature_path identifies the file that will be loaded by
- "require(feature)". [experimental] [Feature #15230]
-
-String::
-
- * String#crypt is now deprecated. [Feature #14915]
-
- New features::
-
- * String#split yields each substring to the block if given. [Feature #4780]
-
-Struct::
-
- Modified method::
-
- * Struct#to_h now accepts a block that maps keys and values to new keys and values. [Feature #15143]
-
- Aliased method::
-
- * Struct#filter is a new alias for Struct#select. [Feature #13784]
-
-Time::
-
- New features::
-
- * Time.new and Time#getlocal accept a timezone object as well as
- a UTC offset string. Time#+, Time#-, and Time#succ also preserve
- the timezone. [Feature #14850]
-
-TracePoint::
-
- New features::
-
- * "script_compiled" event is supported. [Feature #15287]
-
- New methods::
-
- * TracePoint#parameters [Feature #14694]
-
- * TracePoint#instruction_sequence [Feature #15287]
-
- * TracePoint#eval_script [Feature #15287]
-
- Modified method::
-
- * TracePoint#enable accepts new keywords "target:" and
- "target_line:". [Feature #15289]
-
-=== Stdlib updates (outstanding ones only)
-
-BigDecimal::
-
- Update to version 1.4.0. This version includes several compatibility
- issues, see Compatibility issues section below for details.
-
- Modified method::
-
- * BigDecimal() accepts the new keyword "exception:" similar to Float().
-
- Note for the differences among recent versions::
-
- You should want to know the differences among recent versions of bigdecimal.
- Please select the suitable version of bigdecimal according to the following
- information.
-
- * 1.3.5 has BigDecimal.new without "exception:" keyword. You can see the
- deprecation warning of BigDecimal.new when you specify "-w" option.
- BigDecimal(), BigDecimal.new, and Object#to_d methods are the same.
-
- * 1.4.0 has BigDecimal.new with "exception:" keyword. You always see the
- deprecation warning of BigDecimal.new. Object#to_d method is different
- from BigDecimal() and BigDecimal.new.
-
- * 2.0.0 will be released soon after releasing Ruby 2.6.0. This version
- will not have the BigDecimal.new method.
-
-Bundler::
-
- * Add Bundler to Standard Library. [Feature #12733]
-
- * Use 1.17.2, the latest stable version.
-
-Coverage::
-
- A oneshot_lines mode is added. [Feature #15022]
-
- This mode checks "whether each line was executed at least once or not",
- instead of "how many times each line was executed".
- A hook for each line is fired at most once, and after it is fired
- the hook flag is removed, i.e., it runs with zero overhead.
-
- New options::
-
- * Add +:oneshot_lines+ keyword argument to Coverage.start.
-
- * Add +:stop+ and +:clear+ keyword arguments to Coverage.result.
- If +clear+ is true, it clears the counters to zero.
- If +stop+ is true, it disables coverage measurement.
-
- New methods::
-
- * Coverage.line_stub, which is a simple helper function that
- creates the "stub" of line coverage from a given source code.
-
-CSV::
-
- * Upgrade to 3.0.2. This includes performance improvements especially
- for writing. Writing is about 2 times faster.
- See https://github.com/ruby/csv/blob/master/NEWS.md.
-
-ERB::
-
- New options::
-
- * Add +:trim_mode+ and +:eoutvar+ keyword arguments to ERB.new.
- Now non-keyword arguments other than the first one are softly deprecated
- and will be removed when Ruby 2.5 becomes EOL. [Feature #14256]
-
- * erb command's <tt>-S</tt> option is deprecated, and will be removed
- in the next version.
-
-FileUtils::
-
- New methods::
-
- * FileUtils#cp_lr. [Feature #4189]
-
-Matrix::
-
- New methods::
-
- * Matrix#antisymmetric?, Matrix#skew_symmetric?
-
- * Matrix#map!, Matrix#collect! [Feature #14151]
-
- * Matrix#[]=
-
- * Vector#map!, Vector#collect!
-
- * Vector#[]=
-
-Net::
-
- New options::
-
- * Add +:write_timeout+ keyword argument to Net::HTTP.new. [Feature #13396]
-
- New methods::
-
- * Add Net::HTTP#write_timeout and Net::HTTP#write_timeout=. [Feature #13396]
-
- New constant::
-
- * Add Net::HTTPClientException to deprecate Net::HTTPServerException,
- whose name is misleading. [Bug #14688]
-
-NKF::
-
- * Upgrade to nkf v2.1.5
-
-Psych::
-
- * Upgrade to Psych 3.1.0
-
-RDoc::
-
- * Become about 2 times faster.
-
- * Use SOURCE_DATE_EPOCH to generate files.
-
- * Fix method line number that slipped off.
-
- * Enable <code>--width</code>, <code>--exclude</code>,
- and <code>--line-numbers</code> that were ignored.
-
- * Add support for blockquote by ">>>" in default markup notation.
-
- * Add support for "Raises" lines in TomDoc notation.
-
- * Fix syntax error output.
-
- * Fix many parsing bugs.
-
-REXML::
-
- * Upgrade to REXML 3.1.9.
- See https://github.com/ruby/rexml/blob/master/NEWS.md.
-
- Improved some XPath implementations::
-
- * <code>concat()</code> function: Stringify all arguments before concatenating.
-
- * <code>string()</code> function: Support context node.
-
- * <code>string()</code> function: Support processing instruction node.
-
- * Support <code>"*:#{ELEMENT_NAME}"</code> syntax in XPath 2.0.
-
- Fixed some XPath implementations::
-
- * <code>"//#{ELEMENT_NAME}[#{POSITION}]"</code> case
-
- * <code>string()</code> function: Fix <code>function(document)</code>
- returns nodes that are out of root elements.
-
- * <code>"/ #{ELEMENT_NAME} "</code> case
-
- * <code>"/ #{ELEMENT_NAME} [ #{PREDICATE} ]"</code> case
-
- * <code>"/ #{AXIS}::#{ELEMENT_NAME}"</code> case
-
- * <code>"#{N}-#{M}"</code> case: One or more white spaces were required
- before <code>"-"</code>
-
- * <code>"/child::node()"</code> case
-
- * <code>"#{FUNCTION}()/#{PATH}"</code> case
-
- * <code>"@#{ATTRIBUTE}/parent::"</code> case
-
- * <code>"name(#{NODE_SET})"</code> case
-
-RSS::
-
- New options::
-
- * RSS::Parser.parse now accepts options as Hash. +:validate+ ,
- +:ignore_unknown_element+ , +:parser_class+ options are available.
-
-RubyGems::
-
- * Upgrade to RubyGems 3.0.1
-
- * https://blog.rubygems.org/2018/12/19/3.0.0-released.html
-
- * https://blog.rubygems.org/2018/12/23/3.0.1-released.html
-
-Set::
-
- Aliased method::
-
- * Set#filter! is a new alias for Set#select!. [Feature #13784]
-
-URI::
-
- New constant::
-
- * Add URI::File to handle the file URI scheme. [Feature #14035]
-
-=== Compatibility issues (excluding feature bug fixes)
-
-Dir::
-
- * Dir.glob with <code>'\0'</code>-separated pattern list will be deprecated,
- and is now warned. [Feature #14643]
-
-File::
-
- * File.read, File.binread, File.write, File.binwrite, File.foreach, and
- File.readlines do not invoke external commands even if the path starts
- with the pipe character <code>'|'</code>. [Feature #14245]
-
-Object::
-
- * Object#=~ is deprecated. [Feature #15231]
-
-=== Stdlib compatibility issues (excluding feature bug fixes)
-
-* These standard libraries have been promoted to default gems.
-
- * e2mmap
- * forwardable
- * irb
- * logger
- * matrix
- * mutex_m
- * ostruct
- * prime
- * rexml
- * rss
- * shell
- * sync
- * thwait
- * tracer
-
-BigDecimal::
-
- * The following methods are removed.
-
- * BigDecimal.allocate
- * BigDecimal.ver
-
- * Every BigDecimal object is frozen. [Feature #13984]
-
- * BigDecimal() parses the given string similar to Float().
-
- * String#to_d parses the receiver string similar to String#to_f.
-
- * BigDecimal.new will be removed in version 2.0.
-
-Pathname::
-
- * Pathname#read, Pathname#binread, Pathname#write, Pathname#binwrite,
- Pathname#each_line and Pathname#readlines do not invoke external
- commands even if the path starts with the pipe character <code>'|'</code>.
- This follows [Feature #14245].
-
-=== Implementation improvements
-
-* Speedup Proc#call because we don't need to care about <code>$SAFE</code>
- any more. [Feature #14318]
-
- With +lc_fizzbuzz+ benchmark which uses Proc#call many times we can
- measure x1.4 improvements. [Bug #10212]
-
-* Speedup block.call where +block+ is passed block parameter. [Feature #14330]
-
- Ruby 2.5 improves block passing performance. [Feature #14045]
-
- Additionally, Ruby 2.6 improves the performance of passed block calling.
-
-* Introduce an initial implementation of a JIT (Just-in-time) compiler. [Feature #14235] [experimental]
-
- * <tt>--jit</tt> command line option is added to enable JIT. <tt>--jit-verbose=1</tt>
- is good for inspection. See <tt>ruby --help</tt> for others.
- * To generate machine code, this JIT compiler uses the C compiler used for building
- the interpreter. Currently GCC, Clang, and Microsoft Visual C++ are supported for it.
- * <tt>--disable-mjit-support</tt> option is added to configure. This is added for JIT debugging,
- but if you get an error on building a header file for JIT, you can use this option to skip
- building it as a workaround.
- * rb_waitpid reimplemented on Unix-like platforms to maintain
- compatibility with processes created for JIT [Bug #14867]
-
-* VM generator script renewal; makes the generated VM more optimized. [GH-1779]
-
-* Thread cache enabled for pthreads platforms (for Thread.new and
- Thread.start). [Feature #14757]
-
-* timer thread is eliminated for platforms with POSIX timers. [Misc #14937]
-
-* Transient Heap (theap) is supported. [Bug #14858] [Feature #14989]
-
- theap is a managed heap for short-living memory objects. For example,
- making a small and short-living Hash object is x2 faster. With rdoc benchmark,
- we measured 6-7% performance improvement.
-
-* Native implementations (arm32, arm64, ppc64le, win32, win64, x86, amd64) of
- coroutines to improve performance of Fiber significantly. [Feature #14739]
-
-=== Miscellaneous changes
-
-* On macOS, shared libraries no longer include a full version number of Ruby
- in their names. This eliminates the burden of each teeny upgrade on the
- platform that users need to rebuild every extension library.
-
- Before::
- * libruby.2.6.0.dylib
- * libruby.2.6.dylib -> libruby.2.6.0.dylib
- * libruby.dylib -> libruby.2.6.0.dylib
-
- After::
- * libruby.2.6.dylib
- * libruby.dylib -> libruby.2.6.dylib
-
-* Extracted misc/*.el files to https://github.com/ruby/elisp
diff --git a/doc/bug_triaging.rdoc b/doc/bug_triaging.rdoc
deleted file mode 100644
index 83fe88cabe..0000000000
--- a/doc/bug_triaging.rdoc
+++ /dev/null
@@ -1,79 +0,0 @@
-= Bug Triaging Guide
-
-This guide discusses recommendations for triaging bugs in Ruby's bug tracker.
-
-== Bugs with Reproducible Examples
-
-These are the best bug reports. First, consider whether the bug reported is
-actually an issue or if it is expected Ruby behavior. If it is expected Ruby
-behavior, update the issue with why the behavior is expected, and set the
-status to Rejected.
-
-If the bug reported appears to be an actual bug, try reproducing the bug with
-the master branch. If you are not able to reproduce the issue on the master
-branch, try reproducing it on the latest version for the branch the bug was
-reported on. If you cannot reproduce the issue in either case, update
-the issue stating you cannot reproduce the issue, ask the reporter if they
-can reproduce the issue with either the master branch or a later release,
-and set the status to Feedback.
-
-If you can reproduce the example with the master branch, try to figure out
-what is causing the issue. If you feel comfortable, try working on a
-patch for the issue, update the issue, and attach the patch. Try to figure
-out which committer should be assigned to the issue, and set them as the
-assignee, and set the status to Assigned.
-
-If you cannot reproduce the example with the master branch, but can reproduce
-the issue on the latest version for the branch, then it is likely the bug has
-already been fixed, but it has not been backported yet. Try to determine
-which commit fixed it, and update the issue noting that the issue has been
-fixed but not yet backported. If the Ruby version is in the security
-maintenance phase or no longer supported, change the status to Closed. This
-change can be made without adding a note to avoid spamming the mailing list.
-
-For issues that may require backwards incompatible changes or may benefit from
-general committer attention or discussion, consider adding them as agenda
-items for the next committer meeting (https://bugs.ruby-lang.org/issues/14770).
-
-== Crash Bugs Without Reproducers
-
-Many bugs reported have little more than a crash report, often with no way to
-reproduce the issue. These bugs are difficult to triage as they often do not
-contain enough information.
-
-For these bugs, if the Ruby version is the master branch or is the latest
-release for the branch and the branch is in normal maintenance phase, look at
-the backtrace and see if you can determine what could be causing the issue.
-If you can guess what could be causing the issue, see if you can put together
-a reproducible example (this is in general quite difficult). If you cannot
-guess what could be causing the issue, or cannot put together a reproducible
-example yourself, please ask the reporter to provide a reproducible example,
-and change the status to Feedback.
-
-If the Ruby version is no longer current (e.g. 2.5.0 when the latest version
-on the Ruby 2.5 branch is 2.5.5), add a note to the issue asking the reporter
-to try the latest Ruby version for the branch and report back, and change the
-status to Feedback. If the Ruby version is in the security maintenance phase
-or no longer supported, change the status to Closed. This change can be made
-without adding a note.
-
-== Crash Bugs With 3rd Party C Extensions
-
-If the crash happens inside a 3rd party C extension, try to figure out inside
-which C extension it happens, and add a note to the issue to report the
-issue to that C extension, and set the status to Third Party's Issue.
-
-== Non-Bug reports
-
-Any issues in the bug tracker that are not reports of problems should have
-the tracker changed from Bug to either Feature (new features or performance
-improvements) or Misc. This change can be made without adding a note.
-
-== Stale Issues
-
-There are many issues that are stale, with no updates in months or even years.
-For stale issues in Feedback state, where the feedback has not been received,
-you can change the status to Closed without adding a note. For stale issues
-in Assigned state, you can reach out to the assignee and see if they can update
-the issue. If the assignee is no longer an active committer, remove them
-as the assignee and change the status to Open.
diff --git a/doc/contributing.rdoc b/doc/contributing.rdoc
index 68dda66e46..ebd5904f69 100644
--- a/doc/contributing.rdoc
+++ b/doc/contributing.rdoc
@@ -53,10 +53,10 @@ on your ticket.
You can report downstream issues for the following distributions via their bug tracker:
-* {debian}[https://bugs.debian.org/cgi-bin/pkgreport.cgi?src=ruby-defaults]
+* {debian}[http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=ruby-defaults]
* {freebsd}[http://www.freebsd.org/cgi/query-pr-summary.cgi?text=ruby]
* {redhat}[https://bugzilla.redhat.com/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED]
-* {macports}[https://trac.macports.org/query?status=assigned&status=new&status=reopened&port=~ruby]
+* {macports}[http://trac.macports.org/query?status=assigned&status=new&status=reopened&port=~ruby]
* etc (add your distribution bug tracker here)
=== Platform Maintainers
@@ -70,6 +70,8 @@ The current active platform maintainers are as follows:
NAKAMURA Usaku (usa)
[mingw32 (Minimalist GNU for Windows)]
Nobuyoshi Nakada (nobu)
+[IA-64 (Debian GNU/Linux)]
+ TAKANO Mitsuhiro (takano32)
[AIX]
Yutaka Kanemoto (kanemoto)
[FreeBSD]
@@ -77,11 +79,9 @@ The current active platform maintainers are as follows:
[Solaris]
Naohisa Goto (ngoto)
[RHEL, CentOS]
- KOSAKI Motohiro (kosaki)
+ KOSAKI Motohiro kosaki
[macOS]
Kenta Murata (mrkn)
-[OpenBSD]
- Jeremy Evans (jeremyevans0)
[cygwin, bcc32, djgpp, wince, ...]
none. (Maintainer WANTED)
@@ -131,7 +131,7 @@ redmine, if gone without notice. In this case the +patch+ command is your
friend, see <code>man patch</code> for more information. Basically this would
go something like this:
- cd path/to/ruby
+ cd path/to/ruby/trunk
patch -p0 < path/to/patch
You will then be prompted to apply the patch with the associated files. After
@@ -157,7 +157,7 @@ write a convincing proposal and patch to implement the feature.
For new features in CRuby, use the {'Feature'
tracker}[https://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&tracker_id=2]
-on ruby-master. For non-CRuby dependent features, features that would apply to
+on ruby-trunk. For non-CRuby dependent features, features that would apply to
alternate Ruby implementations such as JRuby and Rubinius, use the {CommonRuby
tracker}[https://bugs.ruby-lang.org/projects/common-ruby].
@@ -217,7 +217,7 @@ Please note:
== Backport Requests
When a new version of Ruby is released, it starts at patch level 0 (p0), and
-bugs will be fixed first on the master branch. If it's determined that a bug
+bugs will be fixed first on the trunk branch. If it's determined that a bug
exists in a previous version of Ruby that is still in the bug fix stage of
maintenance, then a patch will be backported. After the maintenance stage of a
particular Ruby version ends, it goes into "security fix only" mode which
@@ -247,28 +247,34 @@ Status and maintainers of branches are listed on the
In order to help resolve existing issues and contributing patches to Ruby you
need to be able to run the test suite.
-CRuby uses git for source control, the {git homepage}[https://git-scm.com/]
-has installation instructions with links to documentation for learning more
-about git. There is a mirror of the repository on {github}[https://github.com/ruby/ruby].
-For other resources see the {ruby-core documentation on
+CRuby uses subversion for source control, you can find installation
+instructions and lots of great info to learn subversion on the
+{svnbook.red-bean.com}[http://svnbook.red-bean.com/]. For other resources see
+the {ruby-core documentation on
ruby-lang.org}[https://www.ruby-lang.org/en/community/ruby-core/].
+This guide will use git for contributing. The {git
+homepage}[http://git-scm.com/] has installation instructions with links to
+documentation for learning more about git. There is a mirror of the subversion
+repository on {github}[https://github.com/ruby/ruby].
+
Install the prerequisite dependencies for building the CRuby interpreter to
run tests.
* C compiler
-* autoconf - 2.67 or later, preferably 2.69.
-* bison - 2.0 or later, preferably 3.4.
-* gperf - 3.0.3 or later, preferably 3.1.
+* autoconf
+* bison
+* gperf
* ruby - Ruby itself is prerequisite in order to build Ruby from source. It
can be 1.8.
You should also have access to development headers for the following
libraries, but these are not required:
+* Tcl/Tk
* NDBM/QDBM
* GDBM
-* OpenSSL/LibreSSL
+* OpenSSL
* readline/editline(libedit)
* zlib
* libffi
@@ -279,15 +285,15 @@ Now let's build CRuby:
* Checkout the CRuby source code:
- git clone https://github.com/ruby/ruby.git ruby-master
+ git clone git://github.com/ruby/ruby.git ruby-trunk
* Generate the configuration files and build:
- cd ruby-master
+ cd ruby-trunk
autoconf
mkdir build && cd build # its good practice to build outside of source dir
- mkdir ~/.rubies # we will install to .rubies/ruby-master in our home dir
- ../configure --prefix="${HOME}/.rubies/ruby-master"
+ mkdir ~/.rubies # we will install to .rubies/ruby-trunk in our home dir
+ ../configure --prefix="${HOME}/.rubies/ruby-trunk"
make up && make install
After adding Ruby to your PATH, you should be ready to run the test suite:
@@ -311,7 +317,7 @@ For older versions of Ruby you will need to run the build setup again after
checking out the associated branch in git, for example if you wanted to
checkout 1.9.3:
- git clone https://github.com/ruby/ruby.git --branch ruby_1_9_3
+ git clone git://github.com/ruby/ruby.git --branch ruby_1_9_3
Once you checked out the source code, you can update the local copy by:
@@ -324,11 +330,11 @@ Or, update, build, install and check, by just:
== Contributing Documentation
If you're interested in contributing documentation directly to CRuby there is
-some information available at
-{Contributing}[https://github.com/ruby/ruby#contributing].
+a wealth of information available at
+{documenting-ruby.org}[http://documenting-ruby.org/].
There is also the {Ruby Reference
-Manual}[https://github.com/rurema/doctree/wiki] in Japanese.
+Manual}[https://bugs.ruby-lang.org/projects/rurema] in Japanese.
== Contributing A Patch
@@ -344,7 +350,7 @@ Before you submit a patch, there are a few things you should know:
To improve the chance your patch will be accepted please follow these simple rules:
-* Bug fixes should be committed on master first
+* Bug fixes should be committed on trunk first
* Format of the patch file must be a unified diff (ie: diff -pu, svn diff, or git diff)
* Don't introduce cosmetic changes
* Follow the original coding style of the code
@@ -352,24 +358,23 @@ To improve the chance your patch will be accepted please follow these simple rul
First thing you should do is check out the code if you haven't already:
- git clone https://github.com/ruby/ruby.git ruby-master
+ git clone git://github.com/ruby/ruby.git ruby-trunk
Now create a dedicated branch:
- cd ruby-master
+ cd ruby-trunk
git checkout -b my_new_branch
The name of your branch doesn't really matter because it will only exist on
your local computer and won't be part of the official Ruby repository. It will
be used to create patches based on the differences between your branch and
-master, or edge Ruby.
+trunk, or edge Ruby.
=== Coding style
Here are some general rules to follow when writing Ruby and C code for CRuby:
-* Indent 4 spaces for C without tabs (old codes might use tabs for eight-space indentation,
- but newer codes recommend to use spaces only)
+* Indent 4 spaces for C with tabs for eight-space indentation (emacs default)
* Indent 2 space tabs for Ruby
* Do not use TABs in ruby codes
* ANSI C style for 1.9+ for function declarations
@@ -380,25 +385,48 @@ Here are some general rules to follow when writing Ruby and C code for CRuby:
* ABBRs should be all upper case.
* Do as others do
-=== Commit messages
+=== ChangeLog
+
+Although not required, if you wish to add a ChangeLog entry for your change
+please note:
+
+You can use the following template for the ChangeLog entry on your commit:
+
+ Thu Jan 1 00:00:00 2004 Your Name <yourmail@example.com>
+
+ * filename (function): short description of this commit.
+ This should include your intention of this change.
+ [bug:#number] [mailinglist:number]
-When you're ready to commit:
+ * filename2 (function2): additional description for this file/function.
- git commit path/to/files
+This follows {GNU Coding Standards for Change
+Logs}[http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs],
+some other requirements and tips:
-This will open your editor in which you write your commit message.
-Use the following style for commit messages:
+* Timestamps must be in JST (+09:00) in the style as above.
+* Two spaces between the timestamp and your name. Two spaces between
+ your name and your mail address.
+* One blank line between the timestamp and the description.
+* Indent the description with TAB. 2nd line should begin with TAB+2SP.
+* Write a entry (*) for each change.
+* Refer to redmine issue or discussion on the mailing list.
+* For GitHub issues, use [GH-#] (such as [Fixes GH-234]
+* One blank line between entries.
+* Do as other committers do.
-* Use a succinct subject line.
-* Include reasoning behind the change in the commit message, focusing on why
- the change is being made.
-* Refer to redmine issue (such as Fixes [Bug #1234] or Implements
- [Feature #3456]), or discussion on the mailing list
- (such as [ruby-core:12345]).
-* For GitHub issues, use [GH-#] (such as [Fixes GH-234]).
-* Follow the style used by other committers.
+You can generate the ChangeLog entry by running <code>make change</code>
-=== Contributing your code
+When you're ready to commit, copy your ChangeLog entry into the commit message,
+keeping the same formatting and select your files:
+
+ git commit ChangeLog path/to/files
+
+In the likely event that your branch becomes outdated, you will have to update
+your working branch:
+
+ git fetch origin
+ git rebase remotes/origin/master
Now that you've got some code you want to contribute, let's get set up to
generate a patch. Start by forking the github mirror, check the {github docs on
@@ -415,7 +443,7 @@ Next copy the writable url for your fork and add it as a git remote, replace
In order to generate a patch that you can upload to the bug tracker, we can use
the github interface to review our changes just visit
-https://github.com/my_username/ruby/compare/master...my_new_branch
+https://github.com/my_username/ruby/compare/trunk...my_new_branch
Next, you can simply add '.patch' to the end of this URL and it will generate
the patch for you, save the file to your computer and upload it to the bug
@@ -426,22 +454,7 @@ Since git is a distributed system, you are welcome to host your git repository
on any {publicly accessible hosting
site}[https://git.wiki.kernel.org/index.php/GitHosting], including {hosting your
own}[https://www.kernel.org/pub/software/scm/git/docs/user-manual.html#public-repositories]
-You may use the {'git format-patch'}[https://git-scm.com/docs/git-format-patch]
+You may use the {'git format-patch'}[http://git-scm.com/docs/git-format-patch]
command to generate patch files to upload to redmine. You may also use
-the {'git request-pull'}[https://git-scm.com/docs/git-request-pull] command for
+the {'git request-pull'}[http://git-scm.com/docs/git-request-pull] command for
formatting pull request messages to redmine.
-
-=== Updating the official repository
-
-If you are a committer, you can push changes directly into the official
-repository:
-
- git push origin your-branch-name:master
-
-However, it is likely will have become outdated, and you will have to
-update it. In that case, run:
-
- git fetch origin
- git rebase remotes/origin/master
-
-and then try pushing your changes again.
diff --git a/doc/contributors.rdoc b/doc/contributors.rdoc
index 7c3722032b..6a97addaf4 100644
--- a/doc/contributors.rdoc
+++ b/doc/contributors.rdoc
@@ -88,7 +88,7 @@ Christoph
* patches for set.rb
Sean Chittenden
-* patches for net/http, cgi
+* pathces for net/http, cgi
William D. Clinger
* ruby_strtod is based on his paper.
@@ -109,7 +109,7 @@ Martin Duerst (duerst)
* M17N
Paul Duncan
-* patches for rdoc
+* pathces for rdoc
Alexander Dymo
* a patch for lib/benchmark.rb
diff --git a/doc/etc.rd.ja b/doc/etc.rd.ja
new file mode 100644
index 0000000000..b4ff6ed04e
--- /dev/null
+++ b/doc/etc.rd.ja
@@ -0,0 +1,75 @@
+# etc.rd.ja - -*- mode: rd; coding: utf-8; -*- created at: Fri Jul 14 00:47:15 JST 1995
+=begin
+
+= Etc(モジュール)
+
+実行ã—ã¦ã„ã‚‹OSã‹ã‚‰ã®æƒ…報を得るãŸã‚ã®ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ï¼Žã‚¯ãƒ©ã‚¹ã«ã‚¤ãƒ³ã‚¯ãƒ«ãƒ¼ãƒ‰
+ã—ã¦ä½¿ã†ã“ã¨ã‚‚ã§ãる.
+
+== Module Function
+
+--- getlogin
+
+ 自分ã®loginåã‚’è¿”ã™ï¼Žã“れãŒå¤±æ•—ã—ãŸå ´åˆã¯getpwuid()を用ã„ã‚‹ã¨
+ 良ã„.
+
+--- getpwnam(name)
+
+ /etc/passwdファイル(ã‚ã‚‹ã„ã¯DBMファイルやNISデータベース)を検
+ ç´¢ã—,nameã®åå‰ã‚’æŒã¤passwdエントリを返ã™ï¼Žæˆ»ã‚Šå€¤ã¯passwd構造
+ 体ã§ä»¥ä¸‹ã®ãƒ¡ãƒ³ãƒã‚’æŒã¤ï¼Ž
+
+ struct passwd
+ name # ユーザå(文字列)
+ passwd # パスワード(文字列)
+ uid # ユーザID(整数)
+ gid # グループID(整数)
+ gecos # gecosフィールド(文字列)
+ dir # ホームディレクトリ(文字列)
+ shell # ログインシェル(文字列)
+ # 以é™ã®ãƒ¡ãƒ³ãƒã¯ã‚·ã‚¹ãƒ†ãƒ ã«ã‚ˆã£ã¦ã¯æä¾›ã•れãªã„.
+ change # パスワード変更時間(整数)
+ quota # クォータ(整数)
+ age # エージ(整数)
+ class # ユーザアクセスクラス(文字列)
+ comment # コメント(文字列)
+ expire # アカウント有効期é™(æ•´æ•°)
+ end
+
+ 詳細ã¯getpwnam(3)ã‚’å‚ç…§ã®ã“ã¨ï¼Ž
+
+--- getpwuid([uid])
+
+ uidをユーザIDã¨ã™ã‚‹passwdエントリを返ã™ï¼Žæˆ»ã‚Šå€¤ã¯getpwnam()ã¨
+ åŒæ§˜ã§ã‚る.引数をçœç•¥ã—ãŸå ´åˆã«ã¯getuid()ã®å€¤ã‚’用ã„る.詳細ã¯
+ getpwuid(3)ã‚’å‚ç…§ã®ã“ã¨ï¼Ž
+
+--- getgrgid(gid)
+
+ /etc/groupファイル(ã‚ã‚‹ã„ã¯â€¦getpwnamå‚ç…§)を検索ã—,gidをグルー
+ プIDã¨ã™ã‚‹ã‚°ãƒ«ãƒ¼ãƒ—エントリを返ã™ï¼Žæˆ»ã‚Šå€¤ã¯group構造体ã§ä»¥ä¸‹ã®
+ メンãƒã‚’æŒã¤ï¼Ž
+
+ struct group
+ name # グループå(文字列)
+ passwd # グループã®ãƒ‘スワード(文字列)
+ gid # グループID(整数)
+ mem # グループメンãƒåã®é…列
+ end
+
+ 詳細ã¯getgrgid(3)ã‚’å‚ç…§ã®ã“ã¨ï¼Ž
+
+--- getgrnam(name)
+
+ nameã¨ã„ã†åå‰ã®ã‚°ãƒ«ãƒ¼ãƒ—エントリを返ã™ï¼Žæˆ»ã‚Šå€¤ã¯getgrgid()ã¨åŒ
+ 様ã§ã‚る.詳細ã¯getgrnam(3)ã‚’å‚照.
+
+--- group
+
+ å…¨ã¦ã®ã‚°ãƒ«ãƒ¼ãƒ—エントリを順ã«ã‚¢ã‚¯ã‚»ã‚¹ã™ã‚‹ãŸã‚ã®ã‚¤ãƒ†ãƒ¬ãƒ¼ã‚¿ï¼Ž
+
+--- passwd
+
+ å…¨ã¦ã®passwdエントリを順ã«ã‚¢ã‚¯ã‚»ã‚¹ã™ã‚‹ãŸã‚ã®ã‚¤ãƒ†ãƒ¬ãƒ¼ã‚¿ï¼Ž
+
+=end
diff --git a/doc/extension.ja.rdoc b/doc/extension.ja.rdoc
index 47303ec408..88f300a562 100644
--- a/doc/extension.ja.rdoc
+++ b/doc/extension.ja.rdoc
@@ -215,6 +215,17 @@ rb_str_new_literal(const char *ptr) ::
Cã®ãƒªãƒ†ãƒ©ãƒ«æ–‡å­—列ã‹ã‚‰Rubyã®æ–‡å­—列を生æˆã™ã‚‹ï¼Ž
+rb_tainted_str_new(const char *ptr, long len) ::
+
+ 汚染マークãŒä»˜åŠ ã•ã‚ŒãŸæ–°ã—ã„Rubyã®æ–‡å­—列を生æˆã™ã‚‹ï¼Žå¤–部
+ ã‹ã‚‰ã®ãƒ‡ãƒ¼ã‚¿ã«åŸºã¥ã文字列ã«ã¯æ±šæŸ“マークãŒä»˜åŠ ã•れるã¹ã
+ ã§ã‚る.
+
+rb_tainted_str_new2(const char *ptr) ::
+rb_tainted_str_new_cstr(const char *ptr) ::
+
+ Cã®æ–‡å­—列ã‹ã‚‰æ±šæŸ“マークãŒä»˜åŠ ã•れãŸRubyã®æ–‡å­—列を生æˆã™ã‚‹ï¼Ž
+
rb_str_append(VALUE str1, VALUE str2) ::
Rubyã®æ–‡å­—列str1ã«Rubyã®æ–‡å­—列str2を追加ã™ã‚‹ï¼Ž
@@ -290,14 +301,6 @@ rb_str_set_len(VALUE str, long len) ::
lenãƒã‚¤ãƒˆã¾ã§ã®å†…容ã¯ä¿å­˜ã•れる.lenã¯strã®å®¹é‡ã‚’è¶Šãˆã¦ã„
ã¦ã¯ãªã‚‰ãªã„.
-rb_str_modify(VALUE str) ::
-
- Rubyã®æ–‡å­—列ã®å¤‰æ›´ã™ã‚‹æº–備をã™ã‚‹ï¼ŽstrãŒå¤‰æ›´å¯èƒ½ã§ãªã‘れã°ä¾‹
- 外ãŒç™ºç”Ÿã™ã‚‹ï¼Žstrã®ãƒãƒƒãƒ•ã‚¡ãŒå…±æœ‰ã•れã¦ã„ã‚‹å ´åˆã¯ï¼Œæ–°ã—ã„ãƒãƒƒ
- ファを割り当ã¦ã¦å…±æœ‰ã•れã¦ã„ãªã„状態ã«ã™ã‚‹ï¼ŽRSTRING_PTRを使ã£
- ã¦ä¸­èº«ã‚’変更ã—ãŸã‚Šï¼Œrb_str_set_lenを呼んã ã‚Šã™ã‚‹å‰ã«ã¯ï¼Œ
- å¿…ãšã“ã®é–¢æ•°ã‚’呼ã°ãªã‘れãªã‚‰ãªã„.
-
==== é…列ã«å¯¾ã™ã‚‹é–¢æ•°
rb_ary_new() ::
@@ -1240,6 +1243,7 @@ Data_Get_Struct(data, type, sval) ::
RB_INTEGER_TYPE_P(value)
RB_FLOAT_TYPE_P(value)
void Check_Type(VALUE value, int type)
+ SafeStringValue(value)
=== 型変æ›
@@ -1321,13 +1325,8 @@ void rb_define_hooked_variable(const char *name, VALUE *var, VALUE (*getter)(),
void rb_global_variable(VALUE *var) ::
- マークã™ã‚‹å¿…è¦ã®ã‚ã‚‹Rubyオブジェクトをå«ã‚€å¤§åŸŸå¤‰æ•°ã‚’,GC
- ã«ã‚ˆã£ã¦è§£æ”¾ã•れãªã„よã†ã«ä¿è­·ã™ã‚‹ï¼Ž
-
-void rb_gc_register_mark_object(VALUE object) ::
-
- マークã™ã‚‹å¿…è¦ã®ã‚ã‚‹Rubyオブジェクトを,GCã«ã‚ˆã£ã¦è§£æ”¾ã•
- れãªã„よã†ã«ç™»éŒ²ã™ã‚‹ï¼Ž
+ GCã®ãŸã‚,Rubyプログラムã‹ã‚‰ã¯ã‚¢ã‚¯ã‚»ã‚¹ã•れãªã„ãŒ, Rubyオブ
+ ジェクトをå«ã‚€å¤§åŸŸå¤‰æ•°ã‚’マークã™ã‚‹ï¼Ž
=== 定数
diff --git a/doc/extension.rdoc b/doc/extension.rdoc
index 79eb96d518..271ed67f9c 100644
--- a/doc/extension.rdoc
+++ b/doc/extension.rdoc
@@ -190,6 +190,16 @@ rb_str_new_literal(const char *ptr) ::
Creates a new Ruby string from a C string literal.
+rb_tainted_str_new(const char *ptr, long len) ::
+
+ Creates a new tainted Ruby string. Strings from external data
+ sources should be tainted.
+
+rb_tainted_str_new2(const char *ptr) ::
+rb_tainted_str_new_cstr(const char *ptr) ::
+
+ Creates a new tainted Ruby string from a C string.
+
rb_sprintf(const char *format, ...) ::
rb_vsprintf(const char *format, va_list ap) ::
@@ -269,14 +279,6 @@ rb_str_set_len(VALUE str, long len) ::
up to len bytes, regardless RSTRING_LEN(str). len must not exceed
the capacity of str.
-rb_str_modify(VALUE str) ::
-
- Prepares a Ruby string to modify. If str is not modifiable, this
- function raises an exception, or if the buffer of str is shared,
- this function allocates new buffer to make it unshared. Always
- you MUST call this function before modifying the contents using
- RSTRING_PTR and/or rb_str_set_len.
-
==== Array Functions
rb_ary_new() ::
@@ -448,20 +450,6 @@ you may rely on:
VALUE rb_call_super(int argc, const VALUE *argv)
-To specify whether keyword arguments are passed when calling super:
-
- VALUE rb_call_super(int argc, const VALUE *argv, int kw_splat)
-
-+kw_splat+ can have these possible values (used by all methods that accept
-+kw_splat+ argument):
-
-RB_NO_KEYWORDS :: Do not pass keywords
-RB_PASS_KEYWORDS :: Pass keywords, final argument should be a hash of keywords
-RB_PASS_EMPTY_KEYWORDS :: Pass empty keywords (not included in arguments)
- (this will be removed in Ruby 3.0)
-RB_PASS_CALLED_KEYWORDS :: Pass keywords if current method was called with
- keywords, useful for argument delegation
-
To achieve the receiver of the current scope (if no other way is
available), you can use:
@@ -726,7 +714,7 @@ RUBY_TYPED_FREE_IMMEDIATELY ::
You can specify this flag if the dfree never unlocks Ruby's
internal lock (GVL).
- If this flag is not set, Ruby defers invocation of dfree()
+ If this flag is not set, Ruby defers invokation of dfree()
and invokes dfree() at the same time as finalizers.
RUBY_TYPED_WB_PROTECTED ::
@@ -758,7 +746,7 @@ be assigned to sval, which should be a pointer of the type specified.
==== Ruby object to C struct
To retrieve the C pointer from the Data object, use the macro
-TypedData_Get_Struct().
+Data_Get_Struct().
TypedData_Get_Struct(obj, type, &data_type, sval)
@@ -907,10 +895,6 @@ but are not exported to the Ruby world. You need to protect them by
void rb_global_variable(VALUE *var)
-or the objects themselves by
-
- void rb_gc_register_mark_object(VALUE object)
-
=== Prepare extconf.rb
If the file named extconf.rb exists, it will be executed to generate
@@ -1200,6 +1184,10 @@ void Check_Type(VALUE value, int type) ::
Ensures +value+ is of the given internal +type+ or raises a TypeError
+SafeStringValue(value) ::
+
+ Checks that +value+ is a String and is not tainted
+
=== Data Type Conversion
FIX2INT(value), INT2FIX(i) ::
@@ -1349,11 +1337,8 @@ void rb_define_hooked_variable(const char *name, VALUE *var, VALUE (*getter)(),
void rb_global_variable(VALUE *var) ::
- Tells GC to protect C global variable, which holds Ruby value to be marked.
-
-void rb_gc_register_mark_object(VALUE object) ::
-
- Tells GC to protect the +object+, which may not be referenced anywhere.
+ GC requires C global variables which hold Ruby values to be marked.
+ rb_global_variable tells GC to protect these variables.
=== Constant Definition
@@ -1398,7 +1383,7 @@ rb_scan_args(int argc, VALUE *argv, const char *fmt, ...) ::
according to the format string. The format can be described in ABNF
as follows:
- scan-arg-spec := param-arg-spec [keyword-arg-spec] [block-arg-spec]
+ scan-arg-spec := param-arg-spec [option-hash-arg-spec] [block-arg-spec]
param-arg-spec := pre-arg-spec [post-arg-spec] / post-arg-spec /
pre-opt-post-arg-spec
@@ -1407,7 +1392,7 @@ rb_scan_args(int argc, VALUE *argv, const char *fmt, ...) ::
[num-of-trailing-mandatory-args]
pre-opt-post-arg-spec := num-of-leading-mandatory-args num-of-optional-args
num-of-trailing-mandatory-args
- keyword-arg-spec := sym-for-keyword-arg
+ option-hash-arg-spec := sym-for-option-hash-arg
block-arg-spec := sym-for-block-arg
num-of-leading-mandatory-args := DIGIT ; The number of leading
@@ -1419,14 +1404,9 @@ rb_scan_args(int argc, VALUE *argv, const char *fmt, ...) ::
; captured as a ruby array
num-of-trailing-mandatory-args := DIGIT ; The number of trailing
; mandatory arguments
- sym-for-keyword-arg := ":" ; Indicates that keyword
- ; argument captured as a hash.
- ; If keyword arguments are not
- ; provided, returns nil.
- ;
- ; Currently, will also consider
- ; final argument as keywords if
- ; it is a hash or can be
+ sym-for-option-hash-arg := ":" ; Indicates that an option
+ ; hash is captured if the last
+ ; argument is a hash or can be
; converted to a hash with
; #to_hash. When the last
; argument is nil, it is
@@ -1436,15 +1416,6 @@ rb_scan_args(int argc, VALUE *argv, const char *fmt, ...) ::
; is not specified and
; arguments are given more
; than sufficient.
- ;
- ; However, handling final
- ; argument as keywords if
- ; method was not called with
- ; keywords (whether final
- ; argument is hash or nil) is
- ; deprecated. In that case, a
- ; warning will be emitted, and
- ; in Ruby 3.0 it will be an error.
sym-for-block-arg := "&" ; Indicates that an iterator
; block should be captured if
; given
@@ -1459,21 +1430,6 @@ rb_scan_args(int argc, VALUE *argv, const char *fmt, ...) ::
The number of given arguments, excluding an option hash or iterator
block, is returned.
-rb_scan_args_kw(int kw_splat, int argc, VALUE *argv, const char *fmt, ...) ::
-
- The same as +rb_scan_args+, except the +kw_splat+ argument specifies whether
- keyword arguments are provided (instead of being determined by the call
- from Ruby to the C function). +kw_splat+ should be one of the following
- values:
-
- RB_SCAN_ARGS_PASS_CALLED_KEYWORDS :: Same behavior as +rb_scan_args+.
- RB_SCAN_ARGS_KEYWORDS :: The final argument should be a hash treated as
- keywords.
- RB_SCAN_ARGS_EMPTY_KEYWORDS :: Don't treat a final hash as keywords.
- (this will be removed in Ruby 3.0)
- RB_SCAN_ARGS_LAST_HASH_KEYWORDS :: Treat a final argument as keywords if it
- is a hash, and not as keywords otherwise.
-
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values) ::
Retrieves argument VALUEs bound to keywords, which directed by +table+
@@ -1512,41 +1468,11 @@ VALUE rb_funcallv(VALUE recv, ID mid, int argc, VALUE *argv) ::
Invokes a method, passing arguments as an array of values.
Able to call even private/protected methods.
-VALUE rb_funcallv_kw(VALUE recv, ID mid, int argc, VALUE *argv, int kw_splat) ::
-
- Same as rb_funcallv, using +kw_splat+ to determine whether keyword
- arguments are passed.
-
VALUE rb_funcallv_public(VALUE recv, ID mid, int argc, VALUE *argv) ::
Invokes a method, passing arguments as an array of values.
Able to call only public methods.
-VALUE rb_funcallv_public_kw(VALUE recv, ID mid, int argc, VALUE *argv, int kw_splat) ::
-
- Same as rb_funcallv_public, using +kw_splat+ to determine whether keyword
- arguments are passed.
-
-VALUE rb_funcall_passing_block(VALUE recv, ID mid, int argc, const VALUE* argv) ::
-
- Same as rb_funcallv_public, except is passes the currently active block as
- the block when calling the method.
-
-VALUE rb_funcall_passing_block_kw(VALUE recv, ID mid, int argc, const VALUE* argv, int kw_splat) ::
-
- Same as rb_funcall_passing_block, using +kw_splat+ to determine whether
- keyword arguments are passed.
-
-VALUE rb_funcall_with_block(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval) ::
-
- Same as rb_funcallv_public, except +passed_procval+ specifies the block to
- pass to the method.
-
-VALUE rb_funcall_with_block_kw(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval, int kw_splat) ::
-
- Same as rb_funcall_with_block, using +kw_splat+ to determine whether
- keyword arguments are passed.
-
VALUE rb_eval_string(const char *str) ::
Compiles and executes the string as a Ruby program.
@@ -1591,11 +1517,6 @@ VALUE rb_block_call(VALUE recv, ID mid, int argc, VALUE * argv, VALUE (*func) (A
whereas yielded values can be gotten via argc/argv of the third/fourth
arguments.
-VALUE rb_block_call_kw(VALUE recv, ID mid, int argc, VALUE * argv, VALUE (*func) (ANYARGS), VALUE data2, int kw_splat) ::
-
- Same as rb_funcall_with_block, using +kw_splat+ to determine whether
- keyword arguments are passed.
-
\[OBSOLETE] VALUE rb_iterate(VALUE (*func1)(), VALUE arg1, VALUE (*func2)(), VALUE arg2) ::
Calls the function func1, supplying func2 as the block. func1 will be
@@ -1607,32 +1528,7 @@ VALUE rb_block_call_kw(VALUE recv, ID mid, int argc, VALUE * argv, VALUE (*func)
VALUE rb_yield(VALUE val) ::
- Yields val as a single argument to the block.
-
-VALUE rb_yield_values(int n, ...) ::
-
- Yields +n+ number of arguments to the block, using one C argument per Ruby
- argument.
-
-VALUE rb_yield_values2(int n, VALUE *argv) ::
-
- Yields +n+ number of arguments to the block, with all Ruby arguments in the
- C argv array.
-
-VALUE rb_yield_values_kw(int n, VALUE *argv, int kw_splat) ::
-
- Same as rb_yield_values2, using +kw_splat+ to determine whether
- keyword arguments are passed.
-
-VALUE rb_yield_splat(VALUE args) ::
-
- Same as rb_yield_values2, except arguments are specified by the Ruby
- array +args+.
-
-VALUE rb_yield_splat_kw(VALUE args, int kw_splat) ::
-
- Same as rb_yield_splat, using +kw_splat+ to determine whether
- keyword arguments are passed.
+ Evaluates the block with value val.
VALUE rb_rescue(VALUE (*func1)(ANYARGS), VALUE arg1, VALUE (*func2)(ANYARGS), VALUE arg2) ::
@@ -1906,48 +1802,6 @@ RB_EVENT_HOOKS_HAVE_CALLBACK_DATA ::
Means that rb_add_event_hook() takes the third argument `data', to be
passed to the given event hook function.
-=== Defining backward compatible macros for keyword argument functions
-
-Most ruby C extensions are designed to support multiple Ruby versions.
-In order to correctly support Ruby 2.7+ in regards to keyword
-argument separation, C extensions need to use <code>*_kw</code>
-functions. However, these functions do not exist in Ruby 2.6 and
-below, so in those cases macros should be defined to allow you to use
-the same code on multiple Ruby versions. Here are example macros
-you can use in extensions that support Ruby 2.6 (or below) when using
-the <code>*_kw</code> functions introduced in Ruby 2.7.
-
- #ifndef RB_PASS_KEYWORDS
- /* Only define macros on Ruby <2.7 */
- #define rb_funcallv_kw(o, m, c, v, kw) rb_funcallv(o, m, c, v)
- #define rb_funcallv_public_kw(o, m, c, v, kw) rb_funcallv_public(o, m, c, v)
- #define rb_funcall_passing_block_kw(o, m, c, v, kw) rb_funcall_passing_block(o, m, c, v)
- #define rb_funcall_with_block_kw(o, m, c, v, b, kw) rb_funcall_with_block(o, m, c, v, b)
- #define rb_scan_args_kw(kw, c, v, s, ...) rb_scan_args(c, v, s, __VA_ARGS__)
- #define rb_call_super_kw(c, v, kw) rb_call_super(c, v)
- #define rb_yield_values_kw(c, v, kw) rb_yield_values2(c, v)
- #define rb_yield_splat_kw(a, kw) rb_yield_splat(a)
- #define rb_block_call_kw(o, m, c, v, f, p, kw) rb_block_call(o, m, c, v, f, p)
- #define rb_fiber_resume_kw(o, c, v, kw) rb_fiber_resume(o, c, v)
- #define rb_fiber_yield_kw(c, v, kw) rb_fiber_yield(c, v)
- #define rb_enumeratorize_with_size_kw(o, m, c, v, f, kw) rb_enumeratorize_with_size(o, m, c, v, f)
- #define SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) \
- rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()), \
- (argc), (argv), (size_fn))
- #define RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) do { \
- if (!rb_block_given_p()) \
- return SIZED_ENUMERATOR(obj, argc, argv, size_fn); \
- } while (0)
- #define RETURN_ENUMERATOR_KW(obj, argc, argv, kw_splat) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0)
- #define rb_check_funcall_kw(o, m, c, v, kw) rb_check_funcall(o, m, c, v)
- #define rb_obj_call_init_kw(o, c, v, kw) rb_obj_call_init(o, c, v)
- #define rb_class_new_instance_kw(c, v, k, kw) rb_class_new_instance(c, v, k)
- #define rb_proc_call_kw(p, a, kw) rb_proc_call(p, a)
- #define rb_proc_call_with_block_kw(p, c, v, b, kw) rb_proc_call_with_block(p, c, v, b)
- #define rb_method_call_kw(c, v, m, kw) rb_method_call(c, v, m)
- #define rb_method_call_with_block_kw(c, v, m, b, kw) rb_method_call_with_block(c, v, m, b)
- #endif
-
== Appendix C. Functions available for use in extconf.rb
See documentation for {mkmf}[rdoc-ref:MakeMakefile].
diff --git a/doc/globals.rdoc b/doc/globals.rdoc
index 89b94e9a8f..1e70555988 100644
--- a/doc/globals.rdoc
+++ b/doc/globals.rdoc
@@ -1,72 +1,70 @@
# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
-== Pre-defined global variables
+== Pre-defined variables
-$!:: The Exception object set by Kernel#raise.
-$@:: The same as <code>$!.backtrace</code>.
-$~:: The information about the last match in the current scope (thread-local and frame-local).
+$!:: The exception information message set by 'raise'.
+$@:: Array of backtrace of the last exception thrown.
$&:: The string matched by the last successful match.
$`:: The string to the left of the last successful match.
$':: The string to the right of the last successful match.
$+:: The highest group matched by the last successful match.
$1:: The Nth group of the last successful match. May be > 1.
+$~:: The information about the last match in the current scope.
$=:: This variable is no longer effective. Deprecated.
-$/:: The input record separator, newline by default. Aliased to $-0.
-$\:: The output record separator for Kernel#print and IO#write. Default is +nil+.
-$,:: The output field separator for Kernel#print and Array#join. Non-nil $, will be deprecated.
-$;:: The default separator for String#split. Non-nil $; will be deprecated. Aliased to $-F.
+$/:: The input record separator, newline by default.
+$\:: The output record separator for the print and IO#write. Default is nil.
+$,:: The output field separator for the print and Array#join.
+$;:: The default separator for String#split.
$.:: The current input line number of the last file that was read.
-$<:: The same as ARGF.
-$>:: The default output stream for Kernel#print and Kernel#printf. $stdout by default.
+$<:: The virtual concatenation file of the files given on command line (or from $stdin if no files were given).
+$>:: The default output for print, printf. $stdout by default.
$_:: The last input line of string by gets or readline.
$0:: Contains the name of the script being executed. May be assignable.
-$*:: The same as ARGV.
-$$:: The process number of the Ruby running this script. Same as Process.pid.
-$?:: The status of the last executed child process (thread-local).
-$LOAD_PATH:: Load path for searching Ruby scripts and extension libraries used
- by Kernel#load and Kernel#require. Aliased to $: and $-I.
- Has a singleton method <code>$LOAD_PATH.resolve_feature_path(feature)</code>
- that returns [+:rb+ or +:so+, path], which resolves the feature to
- the path the original Kernel#require method would load.
-$LOADED_FEATURES:: The array contains the module names loaded by require.
- Aliased to $".
-$DEBUG:: The debug flag, which is set by the <tt>-d</tt> switch. Enabling debug
+$*:: Command line arguments given for the script sans args.
+$$:: The process number of the Ruby running this script.
+$?:: The status of the last executed child process. This value is
+ thread-local.
+$::: Load path for scripts and binary modules by load or require.
+$":: The array contains the module names loaded by require.
+$DEBUG:: The debug flag, which is set by the -d switch. Enabling debug
output prints each exception raised to $stderr (but not its
backtrace). Setting this to a true value enables debug output as
- if <tt>-d</tt> were given on the command line. Setting this to a false
- value disables debug output. Aliased to $-d.
-$FILENAME:: Current input filename from ARGF. Same as ARGF.filename.
+ if -d were given on the command line. Setting this to a false
+ value disables debug output.
+$LOADED_FEATURES:: The alias to the $".
+$FILENAME:: Current input file from $<. Same as $<.filename.
+$LOAD_PATH:: The alias to the $:.
$stderr:: The current standard error output.
$stdin:: The current standard input.
$stdout:: The current standard output.
-$VERBOSE:: The verbose flag, which is set by the <tt>-w</tt> or <tt>-v</tt> switch.
- Setting this to a true value enables warnings as if <tt>-w</tt> or <tt>-v</tt> were given
- on the command line. Setting this to +nil+ disables warnings,
- including from Kernel#warn. Aliased to $-v and $-w.
-$-a:: True if option <tt>-a</tt> is set. Read-only variable.
-$-i:: In in-place-edit mode, this variable holds the extension, otherwise +nil+.
-$-l:: True if option <tt>-l</tt> is set. Read-only variable.
-$-p:: True if option <tt>-p</tt> is set. Read-only variable.
+$VERBOSE:: The verbose flag, which is set by the -w or -v switch. Setting
+ this to a true value enables warnings as if -w or -v were given
+ on the command line. Setting this to nil disables warnings,
+ including from Kernel#warn.
+$-0:: The alias to $/.
+$-a:: True if option -a is set. Read-only variable.
+$-d:: The alias of $DEBUG. See $DEBUG above for further discussion.
+$-F:: The alias to $;.
+$-i:: In in-place-edit mode, this variable holds the extension, otherwise nil.
+$-I:: The alias to $:.
+$-l:: True if option -l is set. Read-only variable.
+$-p:: True if option -p is set. Read-only variable.
+$-v:: An alias of $VERBOSE. See $VERBOSE above for further discussion.
+$-w:: An alias of $VERBOSE. See $VERBOSE above for further discussion.
== Pre-defined global constants
-TRUE:: The typical true value. Deprecated.
-FALSE:: The +false+ itself. Deprecated.
-NIL:: The +nil+ itself. Deprecated.
+TRUE:: The typical true value.
+FALSE:: The false itself.
+NIL:: The nil itself.
STDIN:: The standard input. The default value for $stdin.
STDOUT:: The standard output. The default value for $stdout.
STDERR:: The standard error output. The default value for $stderr.
ENV:: The hash contains current environment variables.
-ARGF:: The virtual concatenation of the files given on command line (or from $stdin if no files were given).
-ARGV:: An Array of command line arguments given for the script.
-DATA:: The file object of the script, pointing just after <code>__END__</code>.
-TOPLEVEL_BINDING:: The Binding of the top level scope.
-RUBY_VERSION:: The Ruby language version.
+ARGF:: The alias to the $<.
+ARGV:: The alias to the $*.
+DATA:: The file object of the script, pointing just after __END__.
+RUBY_VERSION:: The ruby version string (VERSION was deprecated).
RUBY_RELEASE_DATE:: The release date string.
RUBY_PLATFORM:: The platform identifier.
-RUBY_PATCHLEVEL:: The patchlevel for this Ruby. If this is a development build of Ruby the patchlevel will be -1.
-RUBY_REVISION:: The GIT commit hash for this Ruby.
-RUBY_COPYRIGHT:: The copyright string for Ruby.
-RUBY_ENGINE:: The name of the Ruby implementation.
-RUBY_ENGINE_VERSION:: The version of the Ruby implementation.
-RUBY_DESCRIPTION:: The same as <tt>ruby --version</tt>, a String describing various aspects of the Ruby implementation.
+
diff --git a/doc/irb/irb.rd.ja b/doc/irb/irb.rd.ja
index 81247ce4b0..85b6536ee4 100644
--- a/doc/irb/irb.rd.ja
+++ b/doc/irb/irb.rd.ja
@@ -40,46 +40,39 @@ irbã®ä½¿ã„æ–¹ã¯, Rubyã•ãˆçŸ¥ã£ã¦ã„れã°ã„ãŸã£ã¦ç°¡å˜ã§ã™. 基本
irb.rb [options] file_name opts
options:
-f ~/.irbrc を読ã¿è¾¼ã¾ãªã„.
+ -m bcモード(分数, 行列ã®è¨ˆç®—ãŒã§ãã‚‹)
-d $DEBUG ã‚’trueã«ã™ã‚‹(ruby -d ã¨åŒã˜)
+ -Kc ruby -Kcã¨åŒã˜
-r load-module ruby -r ã¨åŒã˜.
- -I path $LOAD_PATH ã« path を追加ã™ã‚‹.
- -U ruby -U ã¨åŒã˜.
- -E enc ruby -E ã¨åŒã˜.
- -w ruby -w ã¨åŒã˜.
- -W[level=2] ruby -W ã¨åŒã˜.
- --context-mode n æ–°ã—ã„ワークスペースを作æˆã—ãŸæ™‚ã«é–¢é€£ã™ã‚‹ Binding
- オブジェクトã®ä½œæˆæ–¹æ³•ã‚’ 0 ã‹ã‚‰ 3 ã®ã„ãšã‚Œã‹ã«è¨­å®šã™ã‚‹.
- --echo å®Ÿè¡Œçµæžœã‚’表示ã™ã‚‹(デフォルト).
- --noecho å®Ÿè¡Œçµæžœã‚’表示ã—ãªã„.
- --inspect çµæžœå‡ºåŠ›ã«inspectを用ã„ã‚‹.
+ --verbose ã“れã‹ã‚‰å®Ÿè¡Œã™ã‚‹è¡Œã‚’表示ã™ã‚‹(デフォルト)
+ --noverbose ã“れã‹ã‚‰å®Ÿè¡Œã™ã‚‹è¡Œã‚’表示ã—ãªã„
+ --echo å®Ÿè¡Œçµæžœã‚’表示ã™ã‚‹(デフォルト)
+ --noecho å®Ÿè¡Œçµæžœã‚’表示ã—ãªã„
+ --inspect çµæžœå‡ºåŠ›ã«inspectを用ã„ã‚‹(bcモード以外ã¯ãƒ‡ãƒ•ォルト).
--noinspect çµæžœå‡ºåŠ›ã«inspectを用ã„ãªã„.
- --singleline シングルラインエディタを利用ã™ã‚‹.
- --nosingleline シングルラインエディタを利用ã—ãªã„. デフォルトã®å‹•
- 作ã¯, inf-ruby-mode以外ã§ã‚·ãƒ³ã‚°ãƒ«ãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利
- 用ã—よã†ã¨ã™ã‚‹.
- --colorize 色付ã‘を利用ã™ã‚‹.
- --nocolorize 色付ã‘を利用ã—ãªã„.
- --prompt prompt-mode/--prompt-mode prompt-mode
+ --readline readlineライブラリを利用ã™ã‚‹.
+ --noreadline readlineライブラリを利用ã—ãªã„. デフォルトã®å‹•作ã¯,
+ inf-ruby-mode以外ã§readlineライブラリを利用ã—よã†
+ ã¨ã™ã‚‹.
+ --prompt prompt-mode
+ --prompt-mode prompt-mode
プロンプトモードを切替ãˆã¾ã™. ç¾åœ¨å®šç¾©ã•れã¦ã„るプ
ロンプトモードã¯, default, simple, xmp, inf-rubyãŒ
- 用æ„ã•れã¦ã„ã¾ã™.
+ 用æ„ã•れã¦ã„ã¾ã™. デフォルトã¯defaultプロンプトモー
+ ドã«ãªã£ã¦ã„ã¾ã™.
+
--inf-ruby-mode emacsã®inf-ruby-mode用ã®ãƒ—ロンプト表示を行ãªã†. 特
- ã«æŒ‡å®šãŒãªã„é™ã‚Š, ラインエディタã¯ä½¿ã‚ãªããªã‚‹.
+ ã«æŒ‡å®šãŒãªã„é™ã‚Š, readlineライブラリã¯ä½¿ã‚ãªããªã‚‹.
--simple-prompt
éžå¸¸ã«ã‚·ãƒ³ãƒ—ルãªãƒ—ロンプトを用ã„るモードã§ã™.
--noprompt プロンプト表示を行ãªã‚ãªã„.
- --single-irb irb 中㧠self を実行ã—ã¦å¾—られるオブジェクトをサ
- ブ irb ã¨å…±æœ‰ã™ã‚‹.
--tracer コマンド実行時ã«ãƒˆãƒ¬ãƒ¼ã‚¹ã‚’行ãªã†.
--back-trace-limit n
ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹è¡¨ç¤ºã‚’ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã®é ­ã‹ã‚‰ n, 後ã‚
ã‹ã‚‰nã ã‘行ãªã†. デフォルトã¯16
-
- --verbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã™ã‚‹.
- --noverbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ãªã„(デフォルト).
- -v, --version irbã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’表示ã™ã‚‹.
- -h, --help irb ã®ãƒ˜ãƒ«ãƒ—を表示ã™ã‚‹.
- -- 以é™ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数をオプションã¨ã—ã¦æ‰±ã‚ãªã„.
+ --irb_debug n irbã®ãƒ‡ãƒãƒƒã‚°ãƒ‡ãƒãƒƒã‚°ãƒ¬ãƒ™ãƒ«ã‚’nã«è¨­å®šã™ã‚‹(利用ã—ãª
+ ã„æ–¹ãŒç„¡é›£ã§ã—ょã†).
+ -v, --version irbã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’表示ã™ã‚‹
= コンフィギュレーション
@@ -98,12 +91,13 @@ irb起動時ã«``~/.irbrc''を読ã¿è¾¼ã¿ã¾ã™. ã‚‚ã—存在ã—ãªã„å ´åˆã¯
IRB.conf[:IRB_RC] = nil
IRB.conf[:BACK_TRACE_LIMIT]=16
IRB.conf[:USE_LOADER] = false
- IRB.conf[:USE_SINGLELINE] = nil
+ IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = false
IRB.conf[:IGNORE_SIGINT] = true
IRB.conf[:IGNORE_EOF] = false
IRB.conf[:PROMPT_MODE] = :DEFAULT
IRB.conf[:PROMPT] = {...}
+ IRB.conf[:DEBUG_LEVEL]=0
IRB.conf[:VERBOSE]=true
== プロンプトã®è¨­å®š
@@ -189,6 +183,9 @@ irb拡張コマンドã¯, ç°¡å˜ãªåå‰ã¨é ­ã«`irb_'ã‚’ã¤ã‘ãŸåå‰ã¨ä¸¡
ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹è¡¨ç¤ºã‚’ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã®é ­ã‹ã‚‰n, 後ã‚ã‹ã‚‰nã ã‘行ãªã†.
デフォルトã¯16
+--- conf.debug_level = N
+ irb用ã®ãƒ‡ãƒãƒƒã‚°ãƒ¬ãƒ™ãƒ«ã®è¨­å®š
+
--- conf.ignore_eof = true/false
^DãŒå…¥åŠ›ã•ã‚ŒãŸæ™‚ã®å‹•作を設定ã™ã‚‹. trueã®æ™‚ã¯^Dを無視ã™ã‚‹, falseã®
時ã¯irbを終了ã™ã‚‹.
@@ -200,8 +197,7 @@ irb拡張コマンドã¯, ç°¡å˜ãªåå‰ã¨é ­ã«`irb_'ã‚’ã¤ã‘ãŸåå‰ã¨ä¸¡
実行中: 実行を中止ã™ã‚‹.
--- conf.inf_ruby_mode = true/false
- inf-ruby-mode用ã®ãƒ—ロンプト表示を行ãªã†. デフォルトã¯false. ç‰¹ã«æŒ‡å®š
- ãŒãªã„é™ã‚Š, ラインエディタã¯ä½¿ã‚ãªããªã‚‹.
+ inf-ruby-mode用ã®ãƒ—ロンプト表示を行ãªã†. デフォルトã¯false.
--- conf.inspect_mode = true/false/nil
インスペクトモードを設定ã™ã‚‹.
@@ -229,19 +225,12 @@ irb拡張コマンドã¯, ç°¡å˜ãªåå‰ã¨é ­ã«`irb_'ã‚’ã¤ã‘ãŸåå‰ã¨ä¸¡
--- conf.use_prompt = true/false
プロンプト表示ã™ã‚‹ã‹ã©ã†ã‹? デフォルトã§ã¯ãƒ—ロンプトを表示ã™ã‚‹.
---- conf.use_multiline = true/false/nil
- マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’使ã†ã‹ã©ã†ã‹?
- true: マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’使ã†.
- false: マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’使ã‚ãªã„.
- nil: (デフォルト)inf-ruby-mode以外ã§ãƒžãƒ«ãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利用ã—よã†
- ã¨ã™ã‚‹.
-
---- conf.use_singleline = true/false/nil
- シングルラインエディタを使ã†ã‹ã©ã†ã‹?
- true: シングルラインエディタを使ã†.
- false: シングルラインエディタを使ã‚ãªã„.
- nil: (デフォルト)inf-ruby-modeã¨ãƒžãƒ«ãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ä»¥å¤–ã§ã‚·ãƒ³ã‚°ãƒ«ãƒ©
- インエディタを利用ã—よã†ã¨ã™ã‚‹.
+--- conf.use_readline = true/false/nil
+ readlineを使ã†ã‹ã©ã†ã‹?
+ true: readlineを使ã†.
+ false: readlineを使ã‚ãªã„.
+ nil: (デフォルト)inf-ruby-mode以外ã§readlineライブラリを利用ã—よ
+ ã†ã¨ã™ã‚‹.
#
#--- conf.verbose=T/F
# irbã‹ã‚‰ã„ã‚ã„ã‚ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã™ã‚‹ã‹?
diff --git a/doc/keywords.rdoc b/doc/keywords.rdoc
index a74126823d..98bbd5e864 100644
--- a/doc/keywords.rdoc
+++ b/doc/keywords.rdoc
@@ -76,7 +76,7 @@ for::
expressions}[rdoc-ref:syntax/control_expressions.rdoc]
if::
- Used for +if+ and modifier +if+ statements. See {control
+ Used for +if+ and modifier +if+ expressions. See {control
expressions}[rdoc-ref:syntax/control_expressions.rdoc]
in::
@@ -115,9 +115,7 @@ retry::
handling}[rdoc-ref:syntax/exceptions.rdoc]
return::
- Exits a method. See {methods}[rdoc-ref:syntax/methods.rdoc].
- If met in top-level scope, immediately stops interpretation of
- the current file.
+ Exits a method. See {methods}[rdoc-ref:syntax/methods.rdoc]
self::
The object the current method is attached to. See
@@ -139,7 +137,7 @@ undef::
See {modules and classes}[rdoc-ref:syntax/modules_and_classes.rdoc]
unless::
- Used for +unless+ and modifier +unless+ statements. See {control
+ Used for +unless+ and modifier +unless+ expressions. See {control
expressions}[rdoc-ref:syntax/control_expressions.rdoc]
until::
diff --git a/doc/maintainers.rdoc b/doc/maintainers.rdoc
index 98de9f2549..382a4e2cbf 100644
--- a/doc/maintainers.rdoc
+++ b/doc/maintainers.rdoc
@@ -44,66 +44,130 @@ Zachary Scott (zzak)
Akinori MUSHA (knu)
[lib/base64.rb]
Yusuke Endoh (mame)
+[lib/benchmark.rb]
+ _unmaintained_
+[lib/cgi.rb, lib/cgi/*]
+ Takeyuki Fujioka (xibbar)
[lib/drb.rb, lib/drb/*]
Masatoshi SEKI (seki)
[lib/debug.rb]
_unmaintained_
+[lib/delegate.rb]
+ _unmaintained_
+[lib/e2mmap.rb]
+ Keiju ISHITSUKA (keiju)
[lib/erb.rb]
Masatoshi SEKI (seki), Takashi Kokubun (k0kubun)
[lib/find.rb]
Kazuki Tsujimoto (ktsj)
+[lib/forwardable.rb]
+ Keiju ISHITSUKA (keiju)
+[lib/getoptlong.rb]
+ _unmaintained_
+[lib/ipaddr.rb]
+ Akinori MUSHA (knu)
+[lib/irb.rb, lib/irb/*]
+ Keiju ISHITSUKA (keiju)
+[lib/logger.rb]
+ Naotoshi Seo (sonots)
+[lib/matrix.rb]
+ Marc-Andre Lafortune (marcandre)
[lib/mkmf.rb]
_unmaintained_
[lib/monitor.rb]
Shugo Maeda (shugo)
+[lib/mutex_m.rb]
+ Keiju ISHITSUKA (keiju)
[lib/net/ftp.rb]
Shugo Maeda (shugo)
[lib/net/imap.rb]
Shugo Maeda (shugo)
[lib/net/http.rb, lib/net/https.rb]
NARUSE, Yui (naruse)
+[lib/net/pop.rb]
+ _unmaintained_
[lib/net/protocol.rb]
_unmaintained_
+[lib/net/smtp.rb]
+ _unmaintained_
+[lib/observer.rb]
+ _unmaintained_
[lib/open-uri.rb]
Tanaka Akira (akr)
+[lib/open3.rb]
+ _unmaintained_
[lib/optparse.rb, lib/optparse/*]
Nobuyuki Nakada (nobu)
+[lib/ostruct.rb]
+ Marc-Andre Lafortune (marcandre)
[lib/pp.rb]
Tanaka Akira (akr)
[lib/prettyprint.rb]
Tanaka Akira (akr)
+[lib/prime.rb]
+ Yuki Sonoda (yugui)
+[lib/profile.rb]
+ _unmaintained_
+[lib/profiler.rb]
+ _unmaintained_
+[lib/pstore.rb]
+ _unmaintained_
+[lib/racc/*]
+ Aaron Patterson (tenderlove)
[lib/resolv-replace.rb]
Tanaka Akira (akr)
[lib/resolv.rb]
Tanaka Akira (akr)
+[lib/rexml/*]
+ Kouhei Sutou (kou)
[lib/rinda/*]
Masatoshi SEKI (seki)
-[lib/rubygems.rb, lib/rubygems/*]
+[lib/rss.rb, lib/rss/*]
+ Kouhei Sutou (kou)
+[lib/rubygems.rb, lib/ubygems.rb, lib/rubygems/*]
Eric Hodel (drbrain), Hiroshi SHIBATA (hsbt)
https://github.com/rubygems/rubygems
[lib/set.rb]
Akinori MUSHA (knu)
[lib/securerandom.rb]
Tanaka Akira (akr)
+[lib/shell.rb, lib/shell/*]
+ Keiju ISHITSUKA (keiju)
[lib/shellwords.rb]
Akinori MUSHA (knu)
+[lib/singleton.rb]
+ Yukihiro Matsumoto (matz)
+[lib/sync.rb]
+ Keiju ISHITSUKA (keiju)
[lib/tempfile.rb]
_unmaintained_
[lib/tmpdir.rb]
_unmaintained_
+[lib/thwait.rb]
+ Keiju ISHITSUKA (keiju)
[lib/time.rb]
Tanaka Akira (akr)
+[lib/timeout.rb]
+ Yukihiro Matsumoto (matz)
+[lib/tracer.rb]
+ Keiju ISHITSUKA (keiju)
[lib/tsort.rb]
Tanaka Akira (akr)
[lib/un.rb]
WATANABE Hirofumi (eban)
[lib/unicode_normalize.rb, lib/unicode_normalize/*]
Martin J. Dürst
+[lib/uri.rb, lib/uri/*]
+ YAMADA, Akira (akira)
[lib/weakref.rb]
_unmaintained_
+[lib/yaml.rb, lib/yaml/*]
+ Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
=== Extensions
+[ext/cgi]
+ Nobuyoshi Nakada (nobu)
[ext/continuation]
Koichi Sasada (ko1)
[ext/coverage]
@@ -117,13 +181,15 @@ Zachary Scott (zzak)
[ext/io/wait]
Nobuyuki Nakada (nobu)
[ext/nkf]
- NARUSE, Yui (naruse)
+ NARUSE, Yui (narse)
[ext/objspace]
_unmaintained_
[ext/pathname]
Tanaka Akira (akr)
[ext/pty]
_unmaintained_
+[ext/racc]
+ Aaron Patterson (tenderlove)
[ext/readline]
TAKAO Kouji (kouji)
[ext/ripper]
@@ -142,209 +208,77 @@ Zachary Scott (zzak)
=== Libraries
-[lib/benchmark.rb]
+[lib/cmath.rb]
_unmaintained_
- https://github.com/bundler/benchmark
- https://rubygems.org/gems/benchmark
-[lib/bundler.rb, lib/bundler/*]
- Hiroshi SHIBATA (hsbt)
- https://github.com/bundler/bundler
- https://rubygems.org/gems/bundler
-[lib/cgi.rb, lib/cgi/*]
- Takeyuki Fujioka (xibbar)
- https://github.com/ruby/cgi
- https://rubygems.org/gems/cgi
+ https://github.com/ruby/cmath
[lib/csv.rb]
- Kenta Murata (mrkn), Kouhei Sutou (kou)
+ James Edward Gray II (jeg2)
https://github.com/ruby/csv
- https://rubygems.org/gems/csv
-[lib/delegate.rb]
- _unmaintained_
- https://github.com/ruby/delegate
- https://rubygems.org/gems/delegate
-[lib/did_you_mean.rb]
- Yuki Nishijima (yuki24)
- https://github.com/ruby/did_you_mean
[lib/fileutils.rb]
_unmaintained_
https://github.com/ruby/fileutils
- https://rubygems.org/gems/fileutils
-[lib/forwardable.rb]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/forwardable
- https://rubygems.org/gems/forwardable
-[lib/getoptlong.rb]
- _unmaintained_
- https://github.com/ruby/getoptlong
- https://rubygems.org/gems/getoptlong
-[lib/ipaddr.rb]
- Akinori MUSHA (knu)
- https://github.com/ruby/ipaddr
- https://rubygems.org/gems/ipaddr
-[lib/irb.rb, lib/irb/*]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/irb
- https://rubygems.org/gems/irb
-[lib/logger.rb]
- Naotoshi Seo (sonots)
- https://github.com/ruby/logger
- https://rubygems.org/gems/logger
-[lib/matrix.rb]
- Marc-Andre Lafortune (marcandre)
- https://github.com/ruby/matrix
- https://rubygems.org/gems/matrix
-[lib/mutex_m.rb]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/mutex_m
- https://rubygems.org/gems/mutex_m
-[lib/net/pop.rb]
- _unmaintained_
- https://github.com/ruby/net-pop
- https://rubygems.org/gems/net-pop
-[lib/net/smtp.rb]
- _unmaintained_
- https://github.com/ruby/net-smtp
- https://rubygems.org/gems/net-smtp
-[lib/observer.rb]
- _unmaintained_
- https://github.com/ruby/observer
-[lib/open3.rb]
- _unmaintained_
- https://github.com/ruby/open3
- https://rubygems.org/gems/open3
-[lib/ostruct.rb]
- Marc-Andre Lafortune (marcandre)
- https://github.com/ruby/ostruct
- https://rubygems.org/gems/ostruct
-[lib/prime.rb]
- Yuki Sonoda (yugui)
- https://github.com/ruby/prime
-[lib/pstore.rb]
- _unmaintained_
- https://github.com/ruby/pstore
- https://rubygems.org/gems/pstore
-[lib/racc.rb, lib/racc/*]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/racc
- https://rubygems.org/gems/racc
-[lib/readline.rb]
- aycabta
- https://github.com/ruby/readline
- https://rubygems.org/gems/readline
[lib/rdoc.rb, lib/rdoc/*]
Eric Hodel (drbrain), Hiroshi SHIBATA (hsbt)
https://github.com/ruby/rdoc
- https://rubygems.org/gems/rdoc
-[lib/reline.rb, lib/reline/*]
- aycabta
- https://github.com/ruby/reline
- https://rubygems.org/gems/reline
-[lib/rexml/*]
- Kouhei Sutou (kou)
- https://github.com/ruby/rexml
- https://rubygems.org/gems/rexml
-[lib/rss.rb, lib/rss/*]
- Kouhei Sutou (kou)
- https://github.com/ruby/rss
- https://rubygems.org/gems/rss
-[lib/singleton.rb]
- Yukihiro Matsumoto (matz)
- https://github.com/ruby/singleton
- https://rubygems.org/gems/singleton
-[lib/timeout.rb]
- Yukihiro Matsumoto (matz)
- https://github.com/ruby/timeout
-[lib/thwait.rb]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/thwait
- https://rubygems.org/gems/thwait
-[lib/tracer.rb]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/tracer
-[lib/uri.rb, lib/uri/*]
- YAMADA, Akira (akira)
- https://github.com/ruby/uri
+[lib/scanf.rb]
+ David A. Black (dblack)
+ https://github.com/ruby/scanf
[lib/webrick.rb, lib/webrick/*]
Eric Wong (normalperson)
https://bugs.ruby-lang.org/
- https://rubygems.org/gems/webrick
-[lib/yaml.rb, lib/yaml/*]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/yaml
=== Extensions
[ext/bigdecimal]
Kenta Murata (mrkn)
https://github.com/ruby/bigdecimal
- https://rubygems.org/gems/bigdecimal
-[ext/cgi]
- Nobuyoshi Nakada (nobu)
- https://github.com/ruby/cgi
- https://rubygems.org/gems/cgi
[ext/date]
_unmaintained_
https://github.com/ruby/date
- https://rubygems.org/gems/date
[ext/dbm]
_unmaintained_
https://github.com/ruby/dbm
- https://rubygems.org/gems/dbm
[ext/etc]
- Ruby core team
+ _unmaintained_
https://github.com/ruby/etc
- https://rubygems.org/gems/etc
[ext/fcntl]
- Ruby core team
+ _unmaintained_
https://github.com/ruby/fcntl
- https://rubygems.org/gems/fcntl
[ext/fiddle]
Aaron Patterson (tenderlove)
https://github.com/ruby/fiddle
- https://rubygems.org/gems/fiddle
[ext/gdbm]
Yukihiro Matsumoto (matz)
https://github.com/ruby/gdbm
- https://rubygems.org/gems/gdbm
[ext/io/console]
Nobuyuki Nakada (nobu)
https://github.com/ruby/io-console
- https://rubygems.org/gems/io-console
[ext/json]
NARUSE, Yui (naruse), Hiroshi SHIBATA (hsbt)
https://github.com/flori/json
- https://rubygems.org/gems/json
[ext/openssl]
Kazuki Yamaguchi (rhe)
https://github.com/ruby/openssl
- https://rubygems.org/gems/openssl
[ext/psych]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
+ Aaron Patterson (tenderlove), Hiroshi SHIBATA(hsbt)
https://github.com/ruby/psych
- https://rubygems.org/gems/psych
-[ext/racc]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/racc
- https://rubygems.org/gems/racc
[ext/sdbm]
Yukihiro Matsumoto (matz)
https://github.com/ruby/sdbm
- https://rubygems.org/gems/sdbm
[ext/stringio]
Nobuyuki Nakada (nobu)
https://github.com/ruby/stringio
- https://rubygems.org/gems/stringio
[ext/strscan]
- Kouhei Sutou (kou)
+ _unmaintained_
https://github.com/ruby/strscan
- https://rubygems.org/gems/strscan
[ext/zlib]
- NARUSE, Yui (naruse)
+ _unmaintained_
https://github.com/ruby/zlib
- https://rubygems.org/gems/zlib
== Bundled gems upstream repositories
+[did_you_mean]
+ https://github.com/yuki24/did_you_mean
[minitest]
https://github.com/seattlerb/minitest
[net-telnet]
diff --git a/doc/regexp.rdoc b/doc/regexp.rdoc
index d84cae1771..06c730058d 100644
--- a/doc/regexp.rdoc
+++ b/doc/regexp.rdoc
@@ -68,9 +68,8 @@ a backslash literally, backslash-escape it: <tt>\\\\</tt>.
/1 \+ 2 = 3\?/.match('Does 1 + 2 = 3?') #=> #<MatchData "1 + 2 = 3?">
/a\\\\b/.match('a\\\\b') #=> #<MatchData "a\\b">
-Patterns behave like double-quoted strings and can contain the same
-backslash escapes (the meaning of <tt>\s</tt> is different, however,
-see below[#label-Character+Classes]).
+Patterns behave like double-quoted strings so can contain the same
+backslash escapes.
/\s\u{6771 4eac 90fd}/.match("Go to æ±äº¬éƒ½")
#=> #<MatchData " æ±äº¬éƒ½">
@@ -132,9 +131,6 @@ The following metacharacters also behave like character classes:
* <tt>/\H/</tt> - A non-hexdigit character (<tt>[^0-9a-fA-F]</tt>)
* <tt>/\s/</tt> - A whitespace character: <tt>/[ \t\r\n\f\v]/</tt>
* <tt>/\S/</tt> - A non-whitespace character: <tt>/[^ \t\r\n\f\v]/</tt>
-* <tt>/\R/</tt> - A linebreak: <tt>\n</tt>, <tt>\v</tt>, <tt>\f</tt>, <tt>\r</tt>
- <tt>\u0085</tt> (NEXT LINE), <tt>\u2028</tt> (LINE SEPARATOR), <tt>\u2029</tt> (PARAGRAPH SEPARATOR)
- or <tt>\r\n</tt>.
POSIX <i>bracket expressions</i> are also similar to character classes.
They provide a portable alternative to the above, with the added benefit
@@ -193,11 +189,8 @@ At least one uppercase character ('H'), at least one lowercase character
Repetition is <i>greedy</i> by default: as many occurrences as possible
are matched while still allowing the overall match to succeed. By
contrast, <i>lazy</i> matching makes the minimal amount of matches
-necessary for overall success. Most greedy metacharacters can be made lazy
-by following them with <tt>?</tt>. For the <tt>{n}</tt> pattern, because
-it specifies an exact number of characters to match and not a variable
-number of characters, the <tt>?</tt> metacharacter instead makes the
-repeated pattern optional.
+necessary for overall success. A greedy metacharacter can be made lazy by
+following it with <tt>?</tt>.
Both patterns below match the string. The first uses a greedy quantifier so
'.+' matches '<a><b>'; the second uses a lazy quantifier so '.+?' matches
@@ -245,15 +238,7 @@ where _name_ is the group name.
#=> #<MatchData "ototo" vowel:"o">
*Note*: A regexp can't use named backreferences and numbered
-backreferences simultaneously. Also, if a named capture is used in a
-regexp, then parentheses used for grouping which would otherwise result
-in a unnamed capture are treated as non-capturing.
-
- /(\w)(\w)/.match("ab").captures # => ["a", "b"]
- /(\w)(\w)/.match("ab").named_captures # => {}
-
- /(?<c>\w)(\w)/.match("ab").captures # => ["a"]
- /(?<c>\w)(\w)/.match("ab").named_captures # => {"c"=>"a"}
+backreferences simultaneously.
When named capture groups are used with a literal regexp on the left-hand
side of an expression and the <tt>=~</tt> operator, the captured text is
@@ -556,15 +541,10 @@ options which control how the pattern can match.
subexpression level with the
<tt>(?</tt><i>on</i><tt>-</tt><i>off</i><tt>)</tt> construct, which
enables options <i>on</i>, and disables options <i>off</i> for the
-expression enclosed by the parentheses:
-
- /a(?i:b)c/.match('aBc') #=> #<MatchData "aBc">
- /a(?-i:b)c/i.match('ABC') #=> nil
-
-Additionally, these options can also be toggled for the remainder of the
-pattern:
+expression enclosed by the parentheses.
- /a(?i)bc/.match('abC') #=> #<MatchData "abC">
+ /a(?i:b)c/.match('aBc') #=> #<MatchData "aBc">
+ /a(?i:b)c/.match('abc') #=> #<MatchData "abc">
Options may also be used with <tt>Regexp.new</tt>:
diff --git a/doc/security.rdoc b/doc/security.rdoc
index ae20ed30fa..d7d6464ce1 100644
--- a/doc/security.rdoc
+++ b/doc/security.rdoc
@@ -15,6 +15,19 @@ mailto:security@ruby-lang.org ({the PGP public
key}[https://www.ruby-lang.org/security.asc]), which is a private mailing list.
Reported problems will be published after fixes.
+== <code>$SAFE</code>
+
+Ruby provides a mechanism to restrict what operations can be performed by Ruby
+code in the form of the <code>$SAFE</code> variable.
+
+However, <code>$SAFE</code> does not provide a secure environment for executing
+untrusted code.
+
+If you need to execute untrusted code, you should use an operating system level
+sandboxing mechanism. On Linux, ptrace or LXC can be used to sandbox
+potentially malicious code. Other similar mechanisms exist on every major
+operating system.
+
== +Marshal.load+
Ruby's +Marshal+ module provides methods for serializing and deserializing Ruby
diff --git a/doc/shell.rd.ja b/doc/shell.rd.ja
new file mode 100644
index 0000000000..a9507fe92a
--- /dev/null
+++ b/doc/shell.rd.ja
@@ -0,0 +1,335 @@
+ -- shell.rb
+ $Release Version: 0.6.0 $
+ $Revision$
+ by Keiju ISHITSUKA(keiju@ishitsuka.com)
+
+=begin
+
+= 目的
+
+ruby上ã§sh/cshã®ã‚ˆã†ã«ã‚³ãƒžãƒ³ãƒ‰ã®å®Ÿè¡ŒåŠã³ãƒ•ィルタリングを手軽ã«è¡Œã†.
+sh/cshã®åˆ¶å¾¡æ–‡ã¯rubyã®æ©Ÿèƒ½ã‚’用ã„ã¦å®Ÿç¾ã™ã‚‹.
+
+= 主ãªã‚¯ãƒ©ã‚¹ä¸€è¦§
+
+== Shell
+
+Shellオブジェクトã¯ã‚«ãƒ¬ãƒ³ãƒˆãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’æŒã¡, コマンド実行ã¯ãã“ã‹ã‚‰ã®
+相対パスã«ãªã‚Šã¾ã™.
+
+--- Shell#cwd
+--- Shell#dir
+--- Shell#getwd
+--- Shell#pwd
+
+ カレントディレクトリを返ã™ã€‚
+
+--- Shell#system_path
+
+ コマンドサーãƒãƒ‘スã®é…列を返ã™ã€‚
+
+--- Shell#umask
+
+ umaskã‚’è¿”ã™ã€‚
+
+== Filter
+
+コマンドã®å®Ÿè¡Œçµæžœã¯ã™ã¹ã¦Filterã¨ã—ã¦ã‹ãˆã‚Šã¾ã™. Enumerableã‚’includeã—
+ã¦ã„ã¾ã™.
+
+= 主ãªãƒ¡ã‚½ãƒƒãƒ‰ä¸€è¦§
+
+== コマンド定義
+
+OS上ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã«ã¯ã¾ãš, Shellã®ãƒ¡ã‚½ãƒƒãƒ‰ã¨ã—ã¦å®šç¾©ã—ã¾ã™.
+
+注) コマンドを定義ã—ãªãã¨ã‚‚直接実行ã§ãã‚‹Shell#systemコマンドもã‚りã¾ã™.
+
+--- Shell.def_system_command(command, path = command)
+
+ Shellã®ãƒ¡ã‚½ãƒƒãƒ‰ã¨ã—ã¦commandを登録ã—ã¾ã™.
+
+ 例)
+ Shell.def_system_command "ls"
+ ls を定義
+
+ Shell.def_system_command "sys_sort", "sort"
+ sortコマンドをsys_sortã¨ã—ã¦å®šç¾©
+
+--- Shell.undef_system_command(command)
+
+ commandを削除ã—ã¾ã™.
+
+--- Shell.alias_command(ali, command, *opts) {...}
+
+ commandã®aliasã‚’ã—ã¾ã™.
+
+ 例)
+ Shell.alias_command "lsC", "ls", "-CBF", "--show-control-chars"
+ Shell.alias_command("lsC", "ls"){|*opts| ["-CBF", "--show-control-chars", *opts]}
+
+--- Shell.unalias_command(ali)
+
+ commandã®aliasを削除ã—ã¾ã™.
+
+--- Shell.install_system_commands(pre = "sys_")
+
+ system_path上ã«ã‚ã‚‹å…¨ã¦ã®å®Ÿè¡Œå¯èƒ½ãƒ•ァイルをShellã«å®šç¾©ã™ã‚‹. メソッ
+ ドåã¯å…ƒã®ãƒ•ァイルåã®é ­ã«preã‚’ã¤ã‘ãŸã‚‚ã®ã¨ãªã‚‹.
+
+== 生æˆ
+
+--- Shell.new
+
+ プロセスã®ã‚«ãƒ¬ãƒ³ãƒˆãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’カレントディレクトリã¨ã™ã‚‹Shellオ
+ ブジェクトを生æˆã—ã¾ã™.
+
+--- Shell.cd(path)
+
+ pathをカレントディレクトリã¨ã™ã‚‹Shellオブジェクトを生æˆã—ã¾ã™.
+
+== プロセス管ç†
+
+--- Shell#jobs
+
+ スケジューリングã•れã¦ã„ã‚‹jobã®ä¸€è¦§ã‚’è¿”ã™.
+
+--- Shell#kill sig, job
+
+ jobã«ã‚·ã‚°ãƒŠãƒ«sigã‚’é€ã‚‹
+
+== カレントディレクトリæ“作
+
+--- Shell#cd(path, &block)
+--- Shell#chdir
+
+ カレントディレクトリをpathã«ã™ã‚‹. イテレータã¨ã—ã¦å‘¼ã°ã‚ŒãŸã¨ãã«ã¯
+ ブロック実行中ã®ã¿ã‚«ãƒ¬ãƒ³ãƒˆãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’変更ã™ã‚‹.
+
+--- Shell#pushd(path = nil, &block)
+--- Shell#pushdir
+
+ カレントディレクトリをディレクトリスタックã«ã¤ã¿, カレントディレク
+ トリをpathã«ã™ã‚‹. pathãŒçœç•¥ã•れãŸã¨ãã«ã¯, カレントディレクトリã¨
+ ディレクトリスタックã®ãƒˆãƒƒãƒ—を交æ›ã™ã‚‹. イテレータã¨ã—ã¦å‘¼ã°ã‚ŒãŸã¨
+ ãã«ã¯, ブロック実行中ã®ã¿pushdã™ã‚‹.
+
+--- Shell#popd
+--- Shell#popdir
+
+ ディレクトリスタックã‹ã‚‰ãƒãƒƒãƒ—ã—, ãれをカレントディレクトリã«ã™ã‚‹.
+
+== ファイル/ディレクトリæ“作
+
+--- Shell#foreach(path = nil, &block)
+
+ pathãŒãƒ•ァイルãªã‚‰, File#foreach
+ pathãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãªã‚‰, Dir#foreach
+
+--- Shell#open(path, mode)
+
+ pathãŒãƒ•ァイルãªã‚‰, File#open
+ pathãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãªã‚‰, Dir#open
+
+--- Shell#unlink(path)
+
+ pathãŒãƒ•ァイルãªã‚‰, File#unlink
+ pathãŒãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªãªã‚‰, Dir#unlink
+
+--- Shell#test(command, file1, file2)
+--- Shell#[command, file1, file2]
+
+ ファイルテスト関数testã¨åŒã˜.
+ 例)
+ sh[?e, "foo"]
+ sh[:e, "foo"]
+ sh["e", "foo"]
+ sh[:exists?, "foo"]
+ sh["exists?", "foo"]
+
+--- Shell#mkdir(*path)
+
+ Dir.mkdirã¨åŒã˜(複数å¯)
+
+--- Shell#rmdir(*path)
+
+ Dir.rmdirã¨åŒã˜(複数å¯)
+
+== コマンド実行
+
+--- System#system(command, *opts)
+
+ commandを実行ã™ã‚‹.
+ 例)
+ print sh.system("ls", "-l")
+ sh.system("ls", "-l") | sh.head > STDOUT
+
+--- System#rehash
+
+ リãƒãƒƒã‚·ãƒ¥ã™ã‚‹
+
+--- Shell#transact &block
+
+ ブロック中ã§ã¯shellã‚’selfã¨ã—ã¦å®Ÿè¡Œã™ã‚‹.
+ 例)
+ sh.transact{system("ls", "-l") | head > STDOUT}
+
+--- Shell#out(dev = STDOUT, &block)
+
+ transactを呼ã³å‡ºã—ãã®çµæžœã‚’devã«å‡ºåŠ›ã™ã‚‹.
+
+== 内部コマンド
+
+--- Shell#echo(*strings)
+--- Shell#cat(*files)
+--- Shell#glob(patten)
+--- Shell#tee(file)
+
+ ã“れらã¯å®Ÿè¡Œã™ã‚‹ã¨, ãれらを内容ã¨ã™ã‚‹Filterオブジェクトを返ã—ã¾ã™.
+
+--- Filter#each &block
+
+ フィルタã®ä¸€è¡Œãšã¤ã‚’blockã«æ¸¡ã™.
+
+--- Filter#<(src)
+
+ srcをフィルタã®å…¥åŠ›ã¨ã™ã‚‹. srcãŒ, 文字列ãªã‚‰ã°ãƒ•ァイルを, IOã§ã‚れ
+ ã°ãれをãã®ã¾ã¾å…¥åŠ›ã¨ã™ã‚‹.
+
+--- Filter#>(to)
+
+ srcをフィルタã®å‡ºåŠ›ã¨ã™ã‚‹. toãŒ, 文字列ãªã‚‰ã°ãƒ•ァイルã«, IOã§ã‚れ
+ ã°ãれをãã®ã¾ã¾å‡ºåŠ›ã¨ã™ã‚‹.
+
+--- Filter#>>(to)
+
+ srcをフィルタã«è¿½åŠ ã™ã‚‹. toãŒ, 文字列ãªã‚‰ã°ãƒ•ァイルã«, IOã§ã‚れã°
+ ãれをãã®ã¾ã¾å‡ºåŠ›ã¨ã™ã‚‹.
+
+--- Filter#|(filter)
+
+ パイプçµåˆ
+
+--- Filter#+(filter)
+
+ filter1 + filter2 㯠filter1ã®å‡ºåŠ›ã®å¾Œ, filter2ã®å‡ºåŠ›ã‚’è¡Œã†.
+
+--- Filter#to_a
+--- Filter#to_s
+
+== 組込ã¿ã‚³ãƒžãƒ³ãƒ‰
+
+--- Shell#atime(file)
+--- Shell#basename(file, *opt)
+--- Shell#chmod(mode, *files)
+--- Shell#chown(owner, group, *file)
+--- Shell#ctime(file)
+--- Shell#delete(*file)
+--- Shell#dirname(file)
+--- Shell#ftype(file)
+--- Shell#join(*file)
+--- Shell#link(file_from, file_to)
+--- Shell#lstat(file)
+--- Shell#mtime(file)
+--- Shell#readlink(file)
+--- Shell#rename(file_from, file_to)
+--- Shell#split(file)
+--- Shell#stat(file)
+--- Shell#symlink(file_from, file_to)
+--- Shell#truncate(file, length)
+--- Shell#utime(atime, mtime, *file)
+
+ ã“れらã¯Fileクラスã«ã‚ã‚‹åŒåã®ã‚¯ãƒ©ã‚¹ãƒ¡ã‚½ãƒƒãƒ‰ã¨åŒã˜ã§ã™.
+
+--- Shell#blockdev?(file)
+--- Shell#chardev?(file)
+--- Shell#directory?(file)
+--- Shell#executable?(file)
+--- Shell#executable_real?(file)
+--- Shell#exist?(file)/Shell#exists?(file)
+--- Shell#file?(file)
+--- Shell#grpowned?(file)
+--- Shell#owned?(file)
+--- Shell#pipe?(file)
+--- Shell#readable?(file)
+--- Shell#readable_real?(file)
+--- Shell#setgid?(file)
+--- Shell#setuid?(file)
+--- Shell#size(file)/Shell#size?(file)
+--- Shell#socket?(file)
+--- Shell#sticky?(file)
+--- Shell#symlink?(file)
+--- Shell#writable?(file)
+--- Shell#writable_real?(file)
+--- Shell#zero?(file)
+
+ ã“れらã¯FileTestクラスã«ã‚ã‚‹åŒåã®ã‚¯ãƒ©ã‚¹ãƒ¡ã‚½ãƒƒãƒ‰ã¨åŒã˜ã§ã™.
+
+--- Shell#syscopy(filename_from, filename_to)
+--- Shell#copy(filename_from, filename_to)
+--- Shell#move(filename_from, filename_to)
+--- Shell#compare(filename_from, filename_to)
+--- Shell#safe_unlink(*filenames)
+--- Shell#makedirs(*filenames)
+--- Shell#install(filename_from, filename_to, mode)
+
+ ã“れらã¯FileToolsクラスã«ã‚ã‚‹åŒåã®ã‚¯ãƒ©ã‚¹ãƒ¡ã‚½ãƒƒãƒ‰ã¨åŒã˜ã§ã™.
+
+ ãã®ä»–, 以下ã®ã‚‚ã®ãŒã‚¨ã‚¤ãƒªã‚¢ã‚¹ã•れã¦ã„ã¾ã™.
+
+--- Shell#cmp <- Shell#compare
+--- Shell#mv <- Shell#move
+--- Shell#cp <- Shell#copy
+--- Shell#rm_f <- Shell#safe_unlink
+--- Shell#mkpath <- Shell#makedirs
+
+= サンプル
+
+== ex1
+
+ sh = Shell.cd("/tmp")
+ sh.mkdir "shell-test-1" unless sh.exists?("shell-test-1")
+ sh.cd("shell-test-1")
+ for dir in ["dir1", "dir3", "dir5"]
+ if !sh.exists?(dir)
+ sh.mkdir dir
+ sh.cd(dir) do
+ f = sh.open("tmpFile", "w")
+ f.print "TEST\n"
+ f.close
+ end
+ print sh.pwd
+ end
+ end
+
+== ex2
+
+ sh = Shell.cd("/tmp")
+ sh.transact do
+ mkdir "shell-test-1" unless exists?("shell-test-1")
+ cd("shell-test-1")
+ for dir in ["dir1", "dir3", "dir5"]
+ if !exists?(dir)
+ mkdir dir
+ cd(dir) do
+ f = open("tmpFile", "w")
+ f.print "TEST\n"
+ f.close
+ end
+ print pwd
+ end
+ end
+ end
+
+== ex3
+
+ sh.cat("/etc/printcap") | sh.tee("tee1") > "tee2"
+ (sh.cat < "/etc/printcap") | sh.tee("tee11") > "tee12"
+ sh.cat("/etc/printcap") | sh.tee("tee1") >> "tee2"
+ (sh.cat < "/etc/printcap") | sh.tee("tee11") >> "tee12"
+
+== ex4
+
+ print sh.cat("/etc/passwd").head.collect{|l| l =~ /keiju/}
+
+=end
diff --git a/doc/signals.rdoc b/doc/signals.rdoc
deleted file mode 100644
index 403eb66549..0000000000
--- a/doc/signals.rdoc
+++ /dev/null
@@ -1,106 +0,0 @@
-= Caveats for implementing Signal.trap callbacks
-
-As with implementing signal handlers in C or most other languages,
-all code passed to Signal.trap must be reentrant. If you are not
-familiar with reentrancy, you need to read up on it at
-{Wikipedia}[https://en.wikipedia.org/wiki/Reentrancy_(computing)] or
-elsewhere before reading the rest of this document.
-
-Most importantly, "thread-safety" does not guarantee reentrancy;
-and methods such as Mutex#lock and Mutex#synchronize which are
-commonly used for thread-safety even prevent reentrancy.
-
-== An implementation detail of the Ruby VM
-
-The Ruby VM defers Signal.trap callbacks from running until it is safe
-for its internal data structures, but it does not know when it is safe
-for data structures in YOUR code. Ruby implements deferred signal
-handling by registering short C functions with only
-{async-signal-safe functions}[http://man7.org/linux/man-pages/man7/signal-safety.7.html] as
-signal handlers. These short C functions only do enough tell the VM to
-run callbacks registered via Signal.trap later in the main Ruby Thread.
-
-== Unsafe methods to call in Signal.trap blocks
-
-When in doubt, consider anything not listed as safe below as being
-unsafe.
-
-* Mutex#lock, Mutex#synchronize and any code using them are explicitly
- unsafe. This includes Monitor in the standard library which uses
- Mutex to provide reentrancy.
-
-* Dir.chdir with block
-
-* any IO write operations when IO#sync is false;
- including IO#write, IO#write_nonblock, IO#puts.
- Pipes and sockets default to `IO#sync = true', so it is safe to
- write to them unless IO#sync was disabled.
-
-* File#flock, as the underlying flock(2) call is not specified by POSIX
-
-== Commonly safe operations inside Signal.trap blocks
-
-* Assignment and retrieval of local, instance, and class variables
-
-* Most object allocations and initializations of common types
- including Array, Hash, String, Struct, Time.
-
-* Common Array, Hash, String, Struct operations which do not execute a block
- are generally safe; but beware if iteration is occurring elsewhere.
-
-* Hash#[], Hash#[]= (unless Hash.new was given an unsafe block)
-
-* Thread::Queue#push and Thread::SizedQueue#push (since Ruby 2.1)
-
-* Creating a new Thread via Thread.new/Thread.start can used to get
- around the unusability of Mutexes inside a signal handler
-
-* Signal.trap is safe to use inside blocks passed to Signal.trap
-
-* arithmetic on Integer and Float (`+', `-', '%', '*', '/')
-
- Additionally, signal handlers do not run between two successive
- local variable accesses, so shortcuts such as `+=' and `-=' will
- not trigger a data race when used on Integer and Float classes in
- signal handlers.
-
-== System call wrapper methods which are safe inside Signal.trap
-
-Since Ruby has wrappers around many
-{async-signal-safe C functions}[http://man7.org/linux/man-pages/man7/signal-safety.7.html]
-the corresponding wrappers for many IO, File, Dir, and Socket methods
-are safe.
-
-(Incomplete list)
-
-* Dir.chdir (without block arg)
-* Dir.mkdir
-* Dir.open
-* File#truncate
-* File.link
-* File.open
-* File.readlink
-* File.rename
-* File.stat
-* File.symlink
-* File.truncate
-* File.unlink
-* File.utime
-* IO#close
-* IO#dup
-* IO#fsync
-* IO#read
-* IO#read_nonblock
-* IO#stat
-* IO#sysread
-* IO#syswrite
-* IO.select
-* IO.pipe
-* Process.clock_gettime
-* Process.exit!
-* Process.fork
-* Process.kill
-* Process.pid
-* Process.ppid
-* Process.waitpid
-...
diff --git a/doc/standard_library.rdoc b/doc/standard_library.rdoc
index f71cedebf7..ff6f6238d8 100644
--- a/doc/standard_library.rdoc
+++ b/doc/standard_library.rdoc
@@ -10,34 +10,67 @@ description.
Abbrev:: Calculates a set of unique abbreviations for a given set of strings
Base64:: Support for encoding and decoding binary data using a Base64 representation
+Benchmark:: Provides methods to measure and report the time used to execute code
+CGI:: Support for the Common Gateway Interface protocol
+ConditionVariable:: Augments the Mutex class
DEBUGGER__:: Debugging functionality for Ruby
+Delegator:: Provides three abilities to delegate method calls to an object
DRb:: Distributed object system for Ruby
+E2MM:: Module for defining custom exceptions with specific messages
English.rb:: Require 'English.rb' to reference global variables with less cryptic names
ERB:: An easy to use but powerful templating system for Ruby
Find:: This module supports top-down traversal of a set of file paths
+Forwardable:: Provides delegation of specified methods to a designated object
+GetoptLong:: Parse command line options similar to the GNU C getopt_long()
+IPAddr:: Provides methods to manipulate IPv4 and IPv6 IP addresses
+IRB:: Interactive Ruby command-line tool for REPL (Read Eval Print Loop)
+Logger:: Provides a simple logging utility for outputting messages
MakeMakefile:: Module used to generate a Makefile for C extensions
+Matrix:: Represents a mathematical matrix.
Monitor:: Provides an object or module to use safely by more than one thread
+Mutex_m:: Mixin to extend objects to be handled like a Mutex
Net::FTP:: Support for the File Transfer Protocol
Net::HTTP:: HTTP client api for Ruby
Net::IMAP:: Ruby client api for Internet Message Access Protocol
+Net::POP3:: Ruby client library for POP3
+Net::SMTP:: Simple Mail Transfer Protocol client library for Ruby
+Observable:: Provides a mechanism for publish/subscribe pattern in Ruby
OpenURI:: An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP
+Open3:: Provides access to stdin, stdout and stderr when running other programs
OptionParser:: Ruby-oriented class for command-line option analysis
+OpenStruct:: Class to build custom data structures, similar to a Hash
PP:: Provides a PrettyPrinter for Ruby objects
PrettyPrinter:: Implements a pretty printing algorithm for readable structure
+Prime:: Prime numbers and factorization library
+profile.rb:: Runs the Ruby Profiler__
+Profiler__:: Provides a way to profile your Ruby application
+PStore:: Implements a file based persistence mechanism based on a Hash
+Queue:: Synchronized communication between threads
+Racc:: A LALR(1) parser generator written in Ruby.
RbConfig:: Information of your configure and build of Ruby
resolv-replace.rb:: Replace Socket DNS with Resolv
Resolv:: Thread-aware DNS resolver library in Ruby
+REXML:: An XML toolkit for Ruby
Rinda:: The Linda distributed computing paradigm in Ruby
+RSS:: Family of libraries that support various formats of XML "feeds"
Gem:: Package management framework for Ruby
SecureRandom:: Interface for secure random number generator
Set:: Provides a class to deal with collections of unordered, unique values
+Shell:: An idiomatic Ruby interface for common UNIX shell commands
Shellwords:: Manipulates strings with word parsing rules of UNIX Bourne shell
+Singleton:: Implementation of the Singleton pattern for Ruby
+Synchronizer:: A module that provides a two-phase lock with a counter
Tempfile:: A utility class for managing temporary files
+ThreadsWait:: Watches for termination of multiple threads
Time:: Extends the Time class with methods for parsing and conversion
+Timeout:: Auto-terminate potentially long-running operations in Ruby
tmpdir.rb:: Extends the Dir class to manage the OS temporary file path
+Tracer:: Outputs a source level execution trace of a Ruby program
TSort:: Topological sorting using Tarjan's algorithm
un.rb:: Utilities to replace common UNIX commands
+URI:: A Ruby module providing support for Uniform Resource Identifiers
WeakRef:: Allows a referenced object to be garbage-collected
+YAML:: Ruby client library for the Psych YAML implementation
== Extensions
@@ -48,6 +81,7 @@ NKF:: Ruby extension for Network Kanji Filter
objspace:: Extends ObjectSpace module to add methods for internal statistics
Pathname:: Representation of the name of a file or directory on the filesystem
PTY:: Creates and manages pseudo terminals
+Readline:: Provides an interface for GNU Readline and Edit Line (libedit)
Ripper:: Provides an interface for parsing Ruby programs into S-expressions
Socket:: Access underlying OS socket implementations
Syslog:: Ruby interface for the POSIX system logging facility
@@ -57,37 +91,13 @@ WIN32OLE:: Provides an interface for OLE Automation in Ruby
== Libraries
-Benchmark:: Provides methods to measure and report the time used to execute code
Bundler:: Manage your Ruby application's gem dependencies
-CGI:: Support for the Common Gateway Interface protocol
+CMath:: Provides Trigonometric and Transcendental functions for complex numbers
CSV:: Provides an interface to read and write CSV files and data
-Delegator:: Provides three abilities to delegate method calls to an object
-DidYouMean:: "Did you mean?" experience in Ruby
FileUtils:: Several file utility methods for copying, moving, removing, etc
-Forwardable:: Provides delegation of specified methods to a designated object
-GetoptLong:: Parse command line options similar to the GNU C getopt_long()
-IPAddr:: Provides methods to manipulate IPv4 and IPv6 IP addresses
-IRB:: Interactive Ruby command-line tool for REPL (Read Eval Print Loop)
-Logger:: Provides a simple logging utility for outputting messages
-Matrix:: Represents a mathematical matrix.
-Mutex_m:: Mixin to extend objects to be handled like a Mutex
-Net::POP3:: Ruby client library for POP3
-Net::SMTP:: Simple Mail Transfer Protocol client library for Ruby
-Observable:: Provides a mechanism for publish/subscribe pattern in Ruby
-Open3:: Provides access to stdin, stdout and stderr when running other programs
-OpenStruct:: Class to build custom data structures, similar to a Hash
-Prime:: Prime numbers and factorization library
-PStore:: Implements a file based persistence mechanism based on a Hash
-Racc:: A LALR(1) parser generator written in Ruby.
RDoc:: Produces HTML and command-line documentation for Ruby
-REXML:: An XML toolkit for Ruby
-RSS:: Family of libraries that support various formats of XML "feeds"
-Singleton:: Implementation of the Singleton pattern for Ruby
-Timeout:: Auto-terminate potentially long-running operations in Ruby
-Tracer:: Outputs a source level execution trace of a Ruby program
-URI:: A Ruby module providing support for Uniform Resource Identifiers
+Scanf:: A Ruby implementation of the C function scanf(3)
WEBrick:: An HTTP server toolkit for Ruby
-YAML:: Ruby client library for the Psych YAML implementation
== Extensions
@@ -103,7 +113,6 @@ IO::console:: Console interface
JSON:: Implements Javascript Object Notation for Ruby
OpenSSL:: Provides SSL, TLS and general purpose cryptography for Ruby
Psych:: A YAML parser and emitter for Ruby
-Readline:: Provides an interface for GNU Readline and Edit Line (libedit)
SDBM:: Provides a simple file-based key-value store with String keys and values
StringIO:: Pseudo I/O on String objects
StringScanner:: Provides lexical scanning operations on a String
@@ -113,6 +122,7 @@ Zlib:: Ruby interface for the zlib compression/decompression library
== Libraries
+DidYouMean:: "Did you mean?" experience in Ruby
MiniTest:: A test suite with TDD, BDD, mocking and benchmarking
Net::Telnet:: Telnet client library for Ruby
PowerAssert:: Power Assert for Ruby.
diff --git a/doc/syntax.rdoc b/doc/syntax.rdoc
index 2463c12a63..fe0f98ce4c 100644
--- a/doc/syntax.rdoc
+++ b/doc/syntax.rdoc
@@ -32,5 +32,3 @@ Refinements[rdoc-ref:syntax/refinements.rdoc] ::
Miscellaneous[rdoc-ref:syntax/miscellaneous.rdoc] ::
+alias+, +undef+, +BEGIN+, +END+
-Comments[rdoc-ref:syntax/comments.rdoc] ::
- Line and block code comments
diff --git a/doc/syntax/assignment.rdoc b/doc/syntax/assignment.rdoc
index a1806e4c48..83300cbece 100644
--- a/doc/syntax/assignment.rdoc
+++ b/doc/syntax/assignment.rdoc
@@ -92,9 +92,8 @@ Now any reference to +big_calculation+ is considered a local variable and will
be cached. To call the method, use <code>self.big_calculation</code>.
You can force a method call by using empty argument parentheses as shown above
-or by using an explicit receiver like <code>self</code>. Using an explicit
-receiver may raise a NameError if the method's visibility is not public or the
-receiver is the literal <code>self</code>.
+or by using an explicit receiver like <code>self.</code>. Using an explicit
+receiver may raise a NameError if the method's visibility is not public.
Another commonly confusing case is when using a modifier +if+:
@@ -110,28 +109,6 @@ The confusion comes from the out-of-order execution of the expression. First
the local variable is assigned-to then you attempt to call a nonexistent
method.
-== Local Variables and eval
-
-Using +eval+ to evaluate Ruby code will allow access to local variables defined
-in the same scope, even if the local variables are not defined until after the
-call to +eval+. However, local variables defined inside the call to +eval+
-will not be reflected in the surrounding scope. Inside the call to +eval+,
-local variables defined in the surrounding scope and local variables defined
-inside the call to +eval+ will be accessible. However, you will not be able
-to access local variables defined in previous or subsequent calls to +eval+ in
-the same scope. Consider each +eval+ call a separate nested scope. Example:
-
- def m
- eval "bar = 1"
- lvs = eval "baz = 2; ary = [local_variables, foo, baz]; x = 2; ary"
- eval "quux = 3"
- foo = 1
- lvs << local_variables
- end
-
- m
- # => [[:baz, :ary, :x, :lvs, :foo], nil, 2, [:lvs, :foo]]
-
== Instance Variables
Instance variables are shared across all methods for the same object.
diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc
index 5abecc69da..ec86ef05ee 100644
--- a/doc/syntax/calling_methods.rdoc
+++ b/doc/syntax/calling_methods.rdoc
@@ -27,32 +27,13 @@ This sends the +my_method+ message to +my_object+. Any object can be a
receiver but depending on the method's visibility sending a message may raise a
NoMethodError.
+You may use <code>&.</code> to designate a receiver, then +my_method+ is not
+invoked and the result is +nil+ when the receiver is +nil+. In that case, the
+arguments of +my_method+ are not evaluated.
+
You may also use <code>::</code> to designate a receiver, but this is rarely
used due to the potential for confusion with <code>::</code> for namespaces.
-=== Safe navigation operator
-
-<code>&.</code>, called "safe navigation operator", allows to skip method call
-when receiver is +nil+. It returns +nil+ and doesn't evaluate method's arguments
-if the call is skipped.
-
- REGEX = /(ruby) is (\w+)/i
- "Ruby is awesome!".match(REGEX).values_at(1, 2)
- # => ["Ruby", "awesome"]
- "Python is fascinating!".match(REGEX).values_at(1, 2)
- # NoMethodError: undefined method `values_at' for nil:NilClass
- "Python is fascinating!".match(REGEX)&.values_at(1, 2)
- # => nil
-
-This allows to easily chain methods which could return empty value. Note that
-<code>&.</code> skips only one next call, so for a longer chain it is necessary
-to add operator on each level:
-
- "Python is fascinating!".match(REGEX)&.values_at(1, 2).join(' - ')
- # NoMethodError: undefined method `join' for nil:NilClass
- "Python is fascinating!".match(REGEX)&.values_at(1, 2)&.join(' - ')
- # => nil
-
== Arguments
There are three types of arguments when sending a message, the positional
@@ -98,7 +79,7 @@ to:
If the method definition has a <code>*argument</code> extra positional
arguments will be assigned to +argument+ in the method as an Array.
-If the method definition doesn't include keyword arguments, the keyword or
+If the method definition doesn't include keyword arguments the keyword or
hash-type arguments are assigned as a single hash to the last argument:
def my_method(options)
@@ -172,8 +153,7 @@ like positional arguments:
my_method(positional1, keyword1: value1, keyword2: value2)
Any keyword arguments not given will use the default value from the method
-definition. If a keyword argument is given that the method did not list,
-and the method definition does not accept arbitrary keyword arguments, an
+definition. If a keyword argument is given that the method did not list an
ArgumentError will be raised.
=== Block Argument
@@ -279,9 +259,6 @@ hash at the end of the array into keyword arguments:
arguments = [1, 2, { c: 4 }]
my_method(*arguments)
-Note that this behavior is currently deprecated and will emit a warning.
-This behavior will be removed in Ruby 3.0.
-
You may also use the <code>**</code> (described next) to convert a Hash into
keyword arguments.
@@ -289,10 +266,7 @@ If the number of objects in the Array do not match the number of arguments for
the method, an ArgumentError will be raised.
If the splat operator comes first in the call, parentheses must be used to
-avoid a warning:
-
- my_method *arguments # warning
- my_method(*arguments) # no warning
+avoid a warning.
=== Hash to Keyword Arguments Conversion
@@ -301,8 +275,7 @@ Given the following method:
def my_method(first: 1, second: 2, third: 3)
end
-You can turn a Hash into keyword arguments with the <code>**</code>
-(keyword splat) operator:
+You can turn a Hash into keyword arguments with the <code>**</code> operator:
arguments = { first: 3, second: 4, third: 5 }
my_method(**arguments)
@@ -316,9 +289,8 @@ Both are equivalent to:
my_method(first: 3, second: 4, third: 5)
-If the method definition uses the keyword splat operator to
-gather arbitrary keyword arguments, they will not be gathered
-by <code>*</code>:
+If the method definition uses <code>**</code> to gather arbitrary keyword
+arguments, they will not be gathered by <code>*</code>:
def my_method(*a, **kw)
p arguments: a, keywords: kw
@@ -328,7 +300,10 @@ by <code>*</code>:
Prints:
- {:arguments=>[1, 2], :keywords=>{'3'=>4, :five=>6}}
+ {:arguments=>[1, 2, {"3"=>4}], :keywords=>{:five=>6}}
+
+Unlike the splat operator described above, the <code>**</code> operator has no
+commonly recognized name.
=== Proc to Block Conversion
@@ -339,17 +314,17 @@ Given a method that use a block:
end
You can convert a proc or lambda to a block argument with the <code>&</code>
-(block conversion) operator:
+operator:
argument = proc { |a| puts "#{a.inspect} was yielded" }
my_method(&argument)
-If the block conversion operator comes first in the call, parenthesis must be
-used to avoid a warning:
+If the splat operator comes first in the call, parenthesis must be used to
+avoid a warning.
- my_method &argument # warning
- my_method(&argument) # no warning
+Unlike the splat operator described above, the <code>&</code> operator has no
+commonly recognized name.
== Method Lookup
diff --git a/doc/syntax/comments.rdoc b/doc/syntax/comments.rdoc
deleted file mode 100644
index a07dd41494..0000000000
--- a/doc/syntax/comments.rdoc
+++ /dev/null
@@ -1,37 +0,0 @@
-= Code Comments
-
-Ruby has two types of comments: inline and block.
-
-Inline comments start with the <code>#</code> character and continue until the
-end of the line:
-
- # On a separate line
- class Foo # or at the end of the line
- # can be indented
- def bar
- end
- end
-
-Block comments start with <code>=begin</code> and end with <code>=end</code>.
-Each should start on a separate line.
-
- =begin
- This is
- commented out
- =end
-
- class Foo
- end
-
- =begin some_tag
- this works, too
- =end
-
-<code>=begin</code> and <code>=end</code> can not be indented, so this is a
-syntax error:
-
- class Foo
- =begin
- Will not work
- =end
- end
diff --git a/doc/syntax/control_expressions.rdoc b/doc/syntax/control_expressions.rdoc
index f7e6d54924..65f7b431e3 100644
--- a/doc/syntax/control_expressions.rdoc
+++ b/doc/syntax/control_expressions.rdoc
@@ -144,7 +144,7 @@ expression.
== Modifier +if+ and +unless+
+if+ and +unless+ can also be used to modify an expression. When used as a
-modifier the left-hand side is the "then" statement and the right-hand side
+modifier the left-hand side is the "then" expression and the right-hand side
is the "test" expression:
a = 0
@@ -164,7 +164,7 @@ This will print 1.
This will print 0.
While the modifier and standard versions have both a "test" expression and a
-"then" statement, they are not exact transformations of each other due to
+"then" expression, they are not exact transformations of each other due to
parse order. Here is an example that shows the difference:
p a if a = 0.zero?
@@ -439,64 +439,6 @@ longer true, now you will receive a SyntaxError when you use +retry+ outside
of a +rescue+ block. See {Exceptions}[rdoc-ref:syntax/exceptions.rdoc]
for proper usage of +retry+.
-== Modifier Statements
-
-Ruby's grammar differentiates between statements and expressions. All
-expressions are statements (an expression is a type of statement), but
-not all statements are expressions. Some parts of the grammar accept
-expressions and not other types of statements, which causes code that
-looks similar to be parsed differently.
-
-For example, when not used as a modifier, +if+, +else+, +while+, +until+,
-and +begin+ are expressions (and also statements). However, when
-used as a modifier, +if+, +else+, +while+, +until+ and +rescue+
-are statements but not expressions.
-
- if true; 1 end # expression (and therefore statement)
- 1 if true # statement (not expression)
-
-Statements that are not expressions cannot be used in contexts where an
-expression is expected, such as method arguments.
-
- puts( 1 if true ) #=> SyntaxError
-
-You can wrap a statement in parentheses to create an expression.
-
- puts((1 if true)) #=> 1
-
-If you put a space between the method name and opening parenthesis, you
-do not need two sets of parentheses.
-
- puts (1 if true) #=> 1, because of optional parentheses for method
-
-This is because this is parsed similar to a method call without
-parentheses. It is equivalent to the following code, without the creation
-of a local variable:
-
- x = (1 if true)
- p x
-
-In a modifier statement, the left-hand side must be a statement and the
-right-hand side must be an expression.
-
-So in <code>a if b rescue c</code>, because <code>b rescue c</code> is a
-statement that is not an expression, and therefore is not allowed as the
-right-hand side of the +if+ modifier statement, the code is necessarily
-parsed as <code>(a if b) rescue c</code>.
-
-This interacts with operator precedence in such a way that:
-
- stmt if v = expr rescue x
- stmt if v = expr unless x
-
-are parsed as:
-
- stmt if v = (expr rescue x)
- (stmt if v = expr) unless x
-
-This is because modifier +rescue+ has higher precedence than <code>=</code>,
-and modifier +if+ has lower precedence than <code>=</code>.
-
== Flip-Flop
The flip-flop is a rarely seen conditional expression. It's primary use is
diff --git a/doc/syntax/exceptions.rdoc b/doc/syntax/exceptions.rdoc
index 31e2f0175c..a2e75616fb 100644
--- a/doc/syntax/exceptions.rdoc
+++ b/doc/syntax/exceptions.rdoc
@@ -17,14 +17,7 @@ wish to limit the scope of rescued exceptions:
# ...
end
-The same is true for a +class+, +module+, and +block+:
-
- [0, 1, 2].map do |i|
- 10 / i
- rescue ZeroDivisionError
- nil
- end
- #=> [nil, 10, 5]
+The same is true for a +class+ or +module+.
You can assign the exception to a local variable by using <tt>=>
variable_name</tt> at the end of the +rescue+ line:
diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc
index 38bfa38676..b8ed7f7c54 100644
--- a/doc/syntax/literals.rdoc
+++ b/doc/syntax/literals.rdoc
@@ -71,33 +71,6 @@ Examples:
All these numbers have the same decimal value, 170. Like integers and floats
you may use an underscore for readability.
-=== Rational numbers
-
-Numbers suffixed by +r+ are Rational numbers.
-
- 12r #=> (12/1)
- 12.3r #=> (123/10)
-
-Rational numbers are exact, whereas Float numbers are inexact.
-
- 0.1r + 0.2r #=> (3/10)
- 0.1 + 0.2 #=> 0.30000000000000004
-
-=== Complex numbers
-
-Numbers suffixed by +i+ are Complex (or imaginary) numbers.
-
- 1i #=> (0+1i)
- 1i * 1i #=> (-1+0i)
-
-Also Rational numbers may be imaginary numbers.
-
- 12.3ri #=> (0+(123/10)*i)
-
-+i+ must be placed after +r+, the opposite is not allowed.
-
- 12.3ir #=> syntax error
-
== Strings
The most common way of writing strings is using <tt>"</tt>:
@@ -193,7 +166,7 @@ a single codepoint in the script encoding:
?\C-\M-a #=> "\x81", same as above
?ã‚ #=> "ã‚"
-=== Here Documents (heredocs)
+=== Here Documents
If you are writing a large block of text you may use a "here document" or
"heredoc":
@@ -255,9 +228,6 @@ behaves like Kernel#`:
cat #{__FILE__}
HEREDOC
-When surrounding with quotes, any character but that quote and newline
-(CR and/or LF) can be used as the identifier.
-
To call a method on a heredoc place it after the opening identifier:
expected_result = <<-EXPECTED.chomp
@@ -336,8 +306,6 @@ its ending value.
(1..2) # includes its ending value
(1...2) # excludes its ending value
- (1..) # endless range, representing infinite sequence from 1 to Infinity
- (..1) # beginless range, representing infinite sequence from -Infinity to 1
You may create a range of any object. See the Range documentation for details
on the methods you need to implement.
diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc
index c11bd449bc..a47c1a3cbf 100644
--- a/doc/syntax/methods.rdoc
+++ b/doc/syntax/methods.rdoc
@@ -17,8 +17,8 @@ on calling methods}[rdoc-ref:syntax/calling_methods.rdoc].
== Method Names
Method names may be one of the operators or must start a letter or a character
-with the eighth bit set. It may contain letters, numbers, an <code>_</code>
-(underscore or low line) or a character with the eighth bit set. The convention
+with the eight bit set. It may contain letters, numbers, an <code>_</code>
+(underscore or low line) or a character with the eight bit set. The convention
is to use underscores to separate words in a multiword method name:
def method_name
@@ -26,7 +26,7 @@ is to use underscores to separate words in a multiword method name:
end
Ruby programs must be written in a US-ASCII-compatible character set such as
-UTF-8, ISO-8859-1 etc. In such character sets if the eighth bit is set it
+UTF-8, ISO-8859-1 etc. In such character sets if the eight bit is set it
indicates an extended character. Ruby allows method names and other identifiers
to contain such characters. Ruby programs cannot contain some characters like
ASCII NUL (<code>\x00</code>).
@@ -62,7 +62,9 @@ Methods that end with a question mark by convention return boolean, but they
may not always return just +true+ or +false+. Often, they will return an
object to indicate a true value (or "truthy" value).
-Methods that end with an equals sign indicate an assignment method.
+Methods that end with an equals sign indicate an assignment method. For
+assignment methods, the return value is ignored and the arguments are returned
+instead.
These are method names for the various Ruby operators. Each of these
operators accepts only one argument. Following the operator is the typical
@@ -92,8 +94,8 @@ operators.
<code>></code> :: greater-than
<code>>=</code> :: greater-than or equal
-To define unary methods minus and plus, follow the operator with an
-<code>@</code> as in <code>+@</code>:
+To define unary methods minus, plus, tilde and not (<code>!</code>) follow the
+operator with an <code>@</code> as in <code>+@</code> or <code>!@</code>:
class C
def -@
@@ -105,13 +107,6 @@ To define unary methods minus and plus, follow the operator with an
-obj # prints "you inverted this object"
-The <code>@</code> is needed to differentiate unary minus and plus
-operators from binary minus and plus operators.
-
-You can also follow tilde and not (<code>!</code>) unary methods with
-<code>@</code>, but it is not required as there are no binary tilde
-and not operators.
-
Unary methods accept zero arguments.
Additionally, methods for element reference and assignment may be defined:
@@ -288,25 +283,6 @@ This will raise a SyntaxError:
a + b + c
end
-Default argument values can refer to arguments that have already been
-evaluated as local variables, and argument values are always evaluated
-left to right. So this is allowed:
-
- def add_values(a = 1, b = a)
- a + b
- end
- add_values
- # => 2
-
-But this will raise a +NameError+ (unless there is a method named
-+b+ defined):
-
- def add_values(a = b, b = 1)
- a + b
- end
- add_values
- # NameError (undefined local variable or method `b' for main:Object)
-
=== Array Decomposition
You can decompose (unpack or extract values from) an Array using extra
@@ -379,23 +355,12 @@ converted to an Array:
gather_arguments 1, 2, 3 # prints [1, 2, 3]
-The array argument must appear before any keyword arguments.
-
-It is possible to gather arguments at the beginning or in the middle:
-
- def gather_arguments(first_arg, *middle_arguments, last_arg)
- p middle_arguments
- end
-
- gather_arguments 1, 2, 3, 4 # prints [2, 3]
+The array argument must be the last positional argument, it must appear before
+any keyword arguments.
The array argument will capture a Hash as the last entry if a hash was sent by
the caller after all positional arguments.
- def gather_arguments(*arguments)
- p arguments
- end
-
gather_arguments 1, a: 2 # prints [1, {:a=>2}]
However, this only occurs if the method does not declare any keyword arguments.
@@ -430,116 +395,12 @@ Arbitrary keyword arguments will be accepted with <code>**</code>:
# prints 1 then {:second=>2, :third=>3}
When calling a method with keyword arguments the arguments may appear in any
-order. If an unknown keyword argument is sent by the caller, and the method
-does not accept arbitrary keyword arguments, an ArgumentError is raised.
-
-To require a specific keyword argument, do not include a default value
-for the keyword argument:
-
- def add_values(first:, second:)
- first + second
- end
- add_values
- # ArgumentError (missing keywords: first, second)
- add_values(first: 1, second: 2)
- # => 3
+order. If an unknown keyword argument is sent by the caller an ArgumentError
+is raised.
When mixing keyword arguments and positional arguments, all positional
arguments must appear before any keyword arguments.
-Also, note that <code>**</code> can be used to ignore keyword arguments:
-
- def ignore_keywords(**)
- end
-
-To mark a method as accepting keywords, but not actually accepting
-keywords, you can use the <code>**nil</code>:
-
- def no_keywords(**nil)
- end
-
-Calling such a method with keywords or a non-empty keyword splat will
-result in an ArgumentError. This syntax is supported so that keywords
-can be added to the method later without affected backwards compatibility.
-
-=== Keyword and Positional Argument Separation
-
-Between Ruby 2.0 and 2.6, keyword and positional arguments were not
-separated, and a keyword argument could be used as a positional argument
-and vice-versa. In Ruby 3.0, keyword and positional arguments will
-be separated if the method definition includes keyword arguments.
-In Ruby 3.0, if the method definition does not include keyword arguments,
-keyword arguments provided when calling the method will continue to be
-treated as a final positional hash argument.
-
-Currently, the keyword and positional arguments are not separated,
-but cases where behavior will change in Ruby 3.0 will result in a
-warning being emitted.
-
-There are a few different types of keyword argument separation issues.
-
-==== Conversion of Hash to Keywords
-
-If a method is called with the hash, the hash could be treated as
-keywords:
-
- def my_method(**keywords)
- keywords
- end
- my_method({a: 1}) # {:a => 1}
-
-This occurs even if the hash could be an optional positional argument
-or an element of a rest argument:
-
- def my_method(hash=nil, **keywords)
- [hash, keywords]
- end
- my_method({a: 1}) # [nil, {:a => 1}]
-
- def my_method(*args, **keywords)
- [args, keywords]
- end
- my_method({a: 1}) # [[], {:a => 1}]
-
-However, if the hash is needed for a mandatory positional argument,
-it would not be treated as keywords:
-
- def my_method(hash, **keywords)
- [hash, keywords]
- end
- my_method({a: 1}) # [{:a => 1}, {}]
-
-==== Conversion of Keywords to Positional Arguments
-
-If a method is called with keywords, but it is missing one
-mandatory positional argument, the keywords are converted to
-a hash and the hash used as the mandatory positional argument:
-
- def my_method(hash, **keywords)
- [hash, keywords]
- end
- my_method(a: 1) # [{:a => 1}, {}]
-
-This is also true for empty keyword splats:
-
- kw = {}
- my_method(**kw) # [{}, {}]
-
-==== Splitting of Positional Hashes or Keywords
-
-If a method definition accepts specific keywords and not arbitrary keywords,
-keywords or a positional hash may be split if the hash includes both Symbol
-keys and non-Symbol keys and the keywords or positional hash are not needed
-as a mandatory positional argument. In this case, the non-Symbol keys are
-separated into a positional argument hash, and the Symbol keys are used
-as the keyword arguments:
-
- def my_method(hash=3, a: 4)
- [hash, a]
- end
- my_method(a: 1, 'a' => 2) # [{"a"=>2}, 1]
- my_method({a: 1, 'a' => 2}) # [{"a"=>2}, 1]
-
== Block Argument
The block argument is indicated by <code>&</code> and must come last:
@@ -563,6 +424,15 @@ in this section:
yield self
end
+There is also a performance benefit to using yield over a calling a block
+parameter. When a block argument is assigned to a variable a Proc object is
+created which holds the block. When using yield this Proc object is not
+created.
+
+If you only need to use the block sometimes you can use Proc.new to create a
+proc from the block that was passed to your method. See Proc.new for further
+details.
+
== Exception Handling
Methods have an implied exception handling block so you do not need to use
@@ -584,28 +454,6 @@ May be written as:
# handle exception
end
-Similarly, if you wish to always run code even if an exception is raised,
-you can use +ensure+ without +begin+ and +end+:
-
- def my_method
- # code that may raise an exception
- ensure
- # code that runs even if previous code raised an exception
- end
-
-You can also combine +rescue+ with +ensure+ and/or +else+, without
-+begin+ and +end+:
-
- def my_method
- # code that may raise an exception
- rescue
- # handle exception
- else
- # only run if no exception raised above
- ensure
- # code that runs even if previous code raised an exception
- end
-
If you wish to rescue an exception for only part of your method, use +begin+ and
+end+. For more details see the page on {exception
handling}[rdoc-ref:syntax/exceptions.rdoc].
diff --git a/doc/syntax/miscellaneous.rdoc b/doc/syntax/miscellaneous.rdoc
index 87ec059ae7..d5691f8d60 100644
--- a/doc/syntax/miscellaneous.rdoc
+++ b/doc/syntax/miscellaneous.rdoc
@@ -13,7 +13,7 @@ most frequently used with <code>ruby -e</code>.
Ruby does not require any indentation. Typically, ruby programs are indented
two spaces.
-If you run ruby with warnings enabled and have an indentation mismatch, you
+If you run ruby with warnings enabled and have an indentation mis-match, you
will receive a warning.
== +alias+
diff --git a/doc/syntax/modules_and_classes.rdoc b/doc/syntax/modules_and_classes.rdoc
index 6122f6e08e..dd70d4ac21 100644
--- a/doc/syntax/modules_and_classes.rdoc
+++ b/doc/syntax/modules_and_classes.rdoc
@@ -190,41 +190,9 @@ Here is an example:
b.n b #=> 1 -- m called on defining class
a.n b # raises NoMethodError A is not a subclass of B
-The third visibility is +private+. A private method may only be called from
-inside the owner class without a receiver, or with a literal +self+
-as a receiver. If a private method is called with a
-receiver other than a literal +self+, a NoMethodError will be raised.
-
- class A
- def without
- m
- end
-
- def with_self
- self.m
- end
-
- def with_other
- A.new.m
- end
-
- def with_renamed
- copy = self
- copy.m
- end
-
- def m
- 1
- end
-
- private :m
- end
-
- a = A.new
- a.without #=> 1
- a.with_self #=> 1
- a.with_other # NoMethodError (private method `m' called for #<A:0x0000559c287f27d0>)
- a.with_renamed # NoMethodError (private method `m' called for #<A:0x0000559c285f8330>)
+The third visibility is +private+. A private method may not be called with a
+receiver, not even +self+. If a private method is called with a receiver a
+NoMethodError will be raised.
=== +alias+ and +undef+
diff --git a/doc/syntax/precedence.rdoc b/doc/syntax/precedence.rdoc
index f64691ab1f..515626c74f 100644
--- a/doc/syntax/precedence.rdoc
+++ b/doc/syntax/precedence.rdoc
@@ -49,14 +49,10 @@ Unary <code>+</code> and unary <code>-</code> are for <code>+1</code>,
<code>-1</code> or <code>-(a + b)</code>.
Modifier-if, modifier-unless, etc. are for the modifier versions of those
-keywords. For example, this is a modifier-unless statement:
+keywords. For example, this is a modifier-unless expression:
a += 1 unless a.zero?
-Note that <code>(a if b rescue c)</code> is parsed as <code>((a if b) rescue
-c)</code> due to reasons not related to precedence. See {modifier
-statements}[control_expressions_rdoc.html#label-Modifier+Statements].
-
<code>{ ... }</code> blocks have priority below all listed operations, but
<code>do ... end</code> blocks have lower priority.
diff --git a/doc/syntax/refinements.rdoc b/doc/syntax/refinements.rdoc
index fc554bb476..a9c1d9edf9 100644
--- a/doc/syntax/refinements.rdoc
+++ b/doc/syntax/refinements.rdoc
@@ -7,7 +7,7 @@ changes. This can cause unintended side-effects or breakage of programs.
Refinements are designed to reduce the impact of monkey patching on other
users of the monkey-patched class. Refinements provide a way to extend a
-class locally. Refinements can modify both classes and modules.
+class locally.
Here is a basic refinement:
@@ -26,7 +26,8 @@ Here is a basic refinement:
end
First, a class +C+ is defined. Next a refinement for +C+ is created using
-Module#refine.
+Module#refine. Refinements only modify classes, not modules so the argument
+must be a class.
Module#refine creates an anonymous module that contains the changes or
refinements to the class (+C+ in the example). +self+ in the refine block is
@@ -247,9 +248,11 @@ Note that +super+ in a method of a refinement invokes the method in the
refined class even if there is another refinement which has been activated in
the same context.
-== Methods Introspection
+== Indirect Method Calls
-When using introspection methods such as Kernel#method or Kernel#methods refinements are not honored.
+When using indirect method access such as Kernel#send, Kernel#method or
+Kernel#respond_to? refinements are not honored for the caller context during
+method lookup.
This behavior may be changed in the future.
@@ -257,7 +260,7 @@ This behavior may be changed in the future.
When a module X is included into a module Y, Y inherits refinements from X.
-For example, C inherits refinements from A and B in the following code:
+For exmaple, C inherits refinements from A and B in the following code:
module A
refine X do ... end
diff --git a/enc/cesu_8.c b/enc/cesu_8.c
deleted file mode 100644
index decbb928f4..0000000000
--- a/enc/cesu_8.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/**********************************************************************
- cesu_8.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-#ifdef RUBY
-# include "encindex.h"
-#endif
-
-#define USE_INVALID_CODE_SCHEME
-
-#ifdef USE_INVALID_CODE_SCHEME
-/* virtual codepoint values for invalid encoding byte 0xfe and 0xff */
-# define INVALID_CODE_FE 0xfffffffe
-# define INVALID_CODE_FF 0xffffffff
-#endif
-#define VALID_CODE_LIMIT 0x0010ffff
-
-#define utf8_islead(c) ((UChar )((c) & 0xc0) != 0x80)
-
-static const int EncLen_CESU8[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-};
-
-typedef enum {
- FAILURE = -2,
- ACCEPT,
- S0, S1, S2, S3,
- S4, S5, S6, S7
-} state_t;
-#define A ACCEPT
-#define F FAILURE
-static const signed char trans[][0x100] = {
- { /* S0 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 1 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 2 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 3 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 4 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 5 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 6 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 7 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* b */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* c */ F, F, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* d */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* e */ 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S1 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 9 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* a */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* b */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S2 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* b */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S3 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* 9 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* a */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* b */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S4 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* 9 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* a */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- /* b */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S5 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- /* 9 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- /* a */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- /* b */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S6 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* b */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, 7, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S7 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* b */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
-};
-#undef A
-#undef F
-
-static int
-mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)
-{
- int firstbyte = *p++;
- state_t s;
- s = trans[0][firstbyte];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_CESU8[firstbyte]-1);
- s = trans[s][*p++];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) {
- int len = EncLen_CESU8[firstbyte];
- if (s == 4) { /* S4 is CESU-8's surrogate pair; len is 6 */
- len = 6;
- }
- return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(len-2);
- }
- s = trans[s][*p++];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(3) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(3);
- s = trans[s][*p++];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(4) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(2);
- s = trans[s][*p++];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(5) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1);
- s = trans[s][*p++];
- return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(6) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-}
-
-static int
-is_mbc_newline(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- if (p < end) {
- if (*p == 0x0a) return 1;
-
-#ifdef USE_UNICODE_ALL_LINE_TERMINATORS
- if (*p == 0x0b || *p == 0x0c || *p == 0x0d) return 1;
- if (p + 1 < end) {
- if (*(p+1) == 0x85 && *p == 0xc2) /* U+0085 */
- return 1;
- if (p + 2 < end) {
- if ((*(p+2) == 0xa8 || *(p+2) == 0xa9)
- && *(p+1) == 0x80 && *p == 0xe2) /* U+2028, U+2029 */
- return 1;
- }
- }
-#endif
- }
-
- return 0;
-}
-
-static OnigCodePoint
-mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- int len;
-
- len = mbc_enc_len(p, end, enc);
- switch (len) {
- case 1:
- return *p;
- case 2:
- return ((p[0] & 0x1F) << 6) | (p[1] & 0x3f);
- case 3:
- return ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
- case 6:
- {
- int high = ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
- int low = ((p[3] & 0xF) << 12) | ((p[4] & 0x3f) << 6) | (p[5] & 0x3f);
- return ((high & 0x03ff) << 10) + (low & 0x03ff) + 0x10000;
- }
- }
-#ifdef USE_INVALID_CODE_SCHEME
- if (*p > 0xfd) {
- return ((*p == 0xfe) ? INVALID_CODE_FE : INVALID_CODE_FF);
- }
-#endif
- return (OnigCodePoint )*p;
-}
-
-static int
-code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED)
-{
- if ((code & 0xffffff80) == 0) return 1;
- else if ((code & 0xfffff800) == 0) return 2;
- else if ((code & 0xffff0000) == 0) return 3;
- else if (code <= VALID_CODE_LIMIT) return 6;
-#ifdef USE_INVALID_CODE_SCHEME
- else if (code == INVALID_CODE_FE) return 1;
- else if (code == INVALID_CODE_FF) return 1;
-#endif
- else
- return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
-}
-
-static int
-code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc ARG_UNUSED)
-{
-#define UTF8_TRAILS(code, shift) (UChar )((((code) >> (shift)) & 0x3f) | 0x80)
-#define UTF8_TRAIL0(code) (UChar )(((code) & 0x3f) | 0x80)
-
- if ((code & 0xffffff80) == 0) {
- *buf = (UChar )code;
- return 1;
- }
- else {
- UChar *p = buf;
-
- if ((code & 0xfffff800) == 0) {
- *p++ = (UChar )(((code>>6)& 0x1f) | 0xc0);
- }
- else if ((code & 0xffff0000) == 0) {
- *p++ = (UChar )(((code>>12) & 0x0f) | 0xe0);
- *p++ = UTF8_TRAILS(code, 6);
- }
- else if (code <= VALID_CODE_LIMIT) {
- unsigned int high = (code >> 10) + 0xD7C0;
- code = (code & 0x3FF) + 0xDC00;
- *p++ = (UChar )(((high>>12) & 0x0f) | 0xe0);
- *p++ = UTF8_TRAILS(high, 6);
- *p++ = UTF8_TRAIL0(high);
- *p++ = (UChar )(((code>>12) & 0x0f) | 0xe0);
- *p++ = UTF8_TRAILS(code, 6);
- }
-#ifdef USE_INVALID_CODE_SCHEME
- else if (code == INVALID_CODE_FE) {
- *p = 0xfe;
- return 1;
- }
- else if (code == INVALID_CODE_FF) {
- *p = 0xff;
- return 1;
- }
-#endif
- else {
- return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
- }
-
- *p++ = UTF8_TRAIL0(code);
- return (int )(p - buf);
- }
-}
-
-static int
-mbc_case_fold(OnigCaseFoldType flag, const UChar** pp,
- const UChar* end, UChar* fold, OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (ONIGENC_IS_MBC_ASCII(p)) {
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
- if (*p == 0x49) {
- *fold++ = 0xc4;
- *fold = 0xb1;
- (*pp)++;
- return 2;
- }
- }
-#endif
-
- *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1; /* return byte length of converted char to lower */
- }
- else {
- return onigenc_unicode_mbc_case_fold(enc, flag, pp, end, fold);
- }
-}
-
-
-static int
-get_ctype_code_range(OnigCtype ctype, OnigCodePoint *sb_out,
- const OnigCodePoint* ranges[], OnigEncoding enc ARG_UNUSED)
-{
- *sb_out = 0x80;
- return onigenc_unicode_ctype_code_range(ctype, ranges);
-}
-
-
-static UChar*
-left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc ARG_UNUSED)
-{
- const UChar *p;
-
- if (s <= start) return (UChar* )s;
- p = s;
-
- while (!utf8_islead(*p) && p > start) p--;
- return (UChar* )p;
-}
-
-static int
-get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items);
-}
-
-OnigEncodingDefine(cesu_8, CESU_8) = {
- mbc_enc_len,
- "CESU-8", /* name */
- 6, /* max byte length */
- 1, /* min byte length */
- is_mbc_newline,
- mbc_to_code,
- code_to_mbclen,
- code_to_mbc,
- mbc_case_fold,
- onigenc_unicode_apply_all_case_fold,
- get_case_fold_codes_by_str,
- onigenc_unicode_property_name_to_ctype,
- onigenc_unicode_is_code_ctype,
- get_ctype_code_range,
- left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match,
- onigenc_unicode_case_map,
- ENCINDEX_UTF_8,
- ONIGENC_FLAG_UNICODE,
-};
diff --git a/enc/depend b/enc/depend
index 0fffcc273f..71345a91fc 100644
--- a/enc/depend
+++ b/enc/depend
@@ -185,82 +185,106 @@ enc/ascii.$(OBJEXT): defines.h
enc/ascii.$(OBJEXT): enc/ascii.c
enc/ascii.$(OBJEXT): missing.h
enc/ascii.$(OBJEXT): onigmo.h
+enc/ascii.$(OBJEXT): oniguruma.h
enc/big5.$(OBJEXT): $(top_srcdir)/regenc.h
enc/big5.$(OBJEXT): config.h
enc/big5.$(OBJEXT): defines.h
enc/big5.$(OBJEXT): enc/big5.c
enc/big5.$(OBJEXT): missing.h
enc/big5.$(OBJEXT): onigmo.h
-enc/cesu_8.$(OBJEXT): $(top_srcdir)/encindex.h
-enc/cesu_8.$(OBJEXT): $(top_srcdir)/regenc.h
-enc/cesu_8.$(OBJEXT): config.h
-enc/cesu_8.$(OBJEXT): defines.h
-enc/cesu_8.$(OBJEXT): enc/cesu_8.c
-enc/cesu_8.$(OBJEXT): missing.h
-enc/cesu_8.$(OBJEXT): onigmo.h
+enc/big5.$(OBJEXT): oniguruma.h
enc/cp949.$(OBJEXT): $(top_srcdir)/regenc.h
enc/cp949.$(OBJEXT): config.h
enc/cp949.$(OBJEXT): defines.h
enc/cp949.$(OBJEXT): enc/cp949.c
enc/cp949.$(OBJEXT): missing.h
enc/cp949.$(OBJEXT): onigmo.h
+enc/cp949.$(OBJEXT): oniguruma.h
+enc/emacs_mule.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/emacs_mule.$(OBJEXT): $(top_srcdir)/regenc.h
+enc/emacs_mule.$(OBJEXT): $(top_srcdir)/regint.h
+enc/emacs_mule.$(OBJEXT): backward.h
enc/emacs_mule.$(OBJEXT): config.h
enc/emacs_mule.$(OBJEXT): defines.h
enc/emacs_mule.$(OBJEXT): enc/emacs_mule.c
+enc/emacs_mule.$(OBJEXT): intern.h
enc/emacs_mule.$(OBJEXT): missing.h
enc/emacs_mule.$(OBJEXT): onigmo.h
-enc/encdb.$(OBJEXT): $(hdrdir)/ruby.h
+enc/emacs_mule.$(OBJEXT): oniguruma.h
+enc/emacs_mule.$(OBJEXT): st.h
+enc/emacs_mule.$(OBJEXT): subst.h
enc/encdb.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enc/encdb.$(OBJEXT): $(top_srcdir)/include/ruby.h
enc/encdb.$(OBJEXT): $(top_srcdir)/internal.h
-enc/encdb.$(OBJEXT): assert.h
enc/encdb.$(OBJEXT): backward.h
enc/encdb.$(OBJEXT): config.h
enc/encdb.$(OBJEXT): defines.h
enc/encdb.$(OBJEXT): enc/encdb.c
enc/encdb.$(OBJEXT): encdb.h
+enc/encdb.$(OBJEXT): encoding.h
enc/encdb.$(OBJEXT): intern.h
+enc/encdb.$(OBJEXT): io.h
enc/encdb.$(OBJEXT): missing.h
+enc/encdb.$(OBJEXT): onigmo.h
+enc/encdb.$(OBJEXT): oniguruma.h
enc/encdb.$(OBJEXT): st.h
enc/encdb.$(OBJEXT): subst.h
+enc/euc_jp.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/euc_jp.$(OBJEXT): $(top_srcdir)/regenc.h
+enc/euc_jp.$(OBJEXT): $(top_srcdir)/regint.h
+enc/euc_jp.$(OBJEXT): backward.h
enc/euc_jp.$(OBJEXT): config.h
enc/euc_jp.$(OBJEXT): defines.h
enc/euc_jp.$(OBJEXT): enc/euc_jp.c
enc/euc_jp.$(OBJEXT): enc/jis/props.h
enc/euc_jp.$(OBJEXT): enc/jis/props.kwd
+enc/euc_jp.$(OBJEXT): intern.h
enc/euc_jp.$(OBJEXT): missing.h
enc/euc_jp.$(OBJEXT): onigmo.h
+enc/euc_jp.$(OBJEXT): oniguruma.h
+enc/euc_jp.$(OBJEXT): st.h
+enc/euc_jp.$(OBJEXT): subst.h
enc/euc_kr.$(OBJEXT): $(top_srcdir)/regenc.h
enc/euc_kr.$(OBJEXT): config.h
enc/euc_kr.$(OBJEXT): defines.h
enc/euc_kr.$(OBJEXT): enc/euc_kr.c
enc/euc_kr.$(OBJEXT): missing.h
enc/euc_kr.$(OBJEXT): onigmo.h
+enc/euc_kr.$(OBJEXT): oniguruma.h
enc/euc_tw.$(OBJEXT): $(top_srcdir)/regenc.h
enc/euc_tw.$(OBJEXT): config.h
enc/euc_tw.$(OBJEXT): defines.h
enc/euc_tw.$(OBJEXT): enc/euc_tw.c
enc/euc_tw.$(OBJEXT): missing.h
enc/euc_tw.$(OBJEXT): onigmo.h
+enc/euc_tw.$(OBJEXT): oniguruma.h
enc/gb18030.$(OBJEXT): $(top_srcdir)/regenc.h
enc/gb18030.$(OBJEXT): config.h
enc/gb18030.$(OBJEXT): defines.h
enc/gb18030.$(OBJEXT): enc/gb18030.c
enc/gb18030.$(OBJEXT): missing.h
enc/gb18030.$(OBJEXT): onigmo.h
+enc/gb18030.$(OBJEXT): oniguruma.h
+enc/gb2312.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/gb2312.$(OBJEXT): $(top_srcdir)/regenc.h
+enc/gb2312.$(OBJEXT): backward.h
enc/gb2312.$(OBJEXT): config.h
enc/gb2312.$(OBJEXT): defines.h
enc/gb2312.$(OBJEXT): enc/gb2312.c
+enc/gb2312.$(OBJEXT): encoding.h
+enc/gb2312.$(OBJEXT): intern.h
enc/gb2312.$(OBJEXT): missing.h
enc/gb2312.$(OBJEXT): onigmo.h
+enc/gb2312.$(OBJEXT): oniguruma.h
+enc/gb2312.$(OBJEXT): st.h
+enc/gb2312.$(OBJEXT): subst.h
enc/gbk.$(OBJEXT): $(top_srcdir)/regenc.h
enc/gbk.$(OBJEXT): config.h
enc/gbk.$(OBJEXT): defines.h
enc/gbk.$(OBJEXT): enc/gbk.c
enc/gbk.$(OBJEXT): missing.h
enc/gbk.$(OBJEXT): onigmo.h
+enc/gbk.$(OBJEXT): oniguruma.h
enc/iso_8859_1.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_1.$(OBJEXT): config.h
enc/iso_8859_1.$(OBJEXT): defines.h
@@ -268,6 +292,7 @@ enc/iso_8859_1.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_1.$(OBJEXT): enc/iso_8859_1.c
enc/iso_8859_1.$(OBJEXT): missing.h
enc/iso_8859_1.$(OBJEXT): onigmo.h
+enc/iso_8859_1.$(OBJEXT): oniguruma.h
enc/iso_8859_10.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_10.$(OBJEXT): config.h
enc/iso_8859_10.$(OBJEXT): defines.h
@@ -275,12 +300,14 @@ enc/iso_8859_10.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_10.$(OBJEXT): enc/iso_8859_10.c
enc/iso_8859_10.$(OBJEXT): missing.h
enc/iso_8859_10.$(OBJEXT): onigmo.h
+enc/iso_8859_10.$(OBJEXT): oniguruma.h
enc/iso_8859_11.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_11.$(OBJEXT): config.h
enc/iso_8859_11.$(OBJEXT): defines.h
enc/iso_8859_11.$(OBJEXT): enc/iso_8859_11.c
enc/iso_8859_11.$(OBJEXT): missing.h
enc/iso_8859_11.$(OBJEXT): onigmo.h
+enc/iso_8859_11.$(OBJEXT): oniguruma.h
enc/iso_8859_13.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_13.$(OBJEXT): config.h
enc/iso_8859_13.$(OBJEXT): defines.h
@@ -288,6 +315,7 @@ enc/iso_8859_13.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_13.$(OBJEXT): enc/iso_8859_13.c
enc/iso_8859_13.$(OBJEXT): missing.h
enc/iso_8859_13.$(OBJEXT): onigmo.h
+enc/iso_8859_13.$(OBJEXT): oniguruma.h
enc/iso_8859_14.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_14.$(OBJEXT): config.h
enc/iso_8859_14.$(OBJEXT): defines.h
@@ -295,6 +323,7 @@ enc/iso_8859_14.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_14.$(OBJEXT): enc/iso_8859_14.c
enc/iso_8859_14.$(OBJEXT): missing.h
enc/iso_8859_14.$(OBJEXT): onigmo.h
+enc/iso_8859_14.$(OBJEXT): oniguruma.h
enc/iso_8859_15.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_15.$(OBJEXT): config.h
enc/iso_8859_15.$(OBJEXT): defines.h
@@ -302,6 +331,7 @@ enc/iso_8859_15.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_15.$(OBJEXT): enc/iso_8859_15.c
enc/iso_8859_15.$(OBJEXT): missing.h
enc/iso_8859_15.$(OBJEXT): onigmo.h
+enc/iso_8859_15.$(OBJEXT): oniguruma.h
enc/iso_8859_16.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_16.$(OBJEXT): config.h
enc/iso_8859_16.$(OBJEXT): defines.h
@@ -309,6 +339,7 @@ enc/iso_8859_16.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_16.$(OBJEXT): enc/iso_8859_16.c
enc/iso_8859_16.$(OBJEXT): missing.h
enc/iso_8859_16.$(OBJEXT): onigmo.h
+enc/iso_8859_16.$(OBJEXT): oniguruma.h
enc/iso_8859_2.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_2.$(OBJEXT): config.h
enc/iso_8859_2.$(OBJEXT): defines.h
@@ -316,6 +347,7 @@ enc/iso_8859_2.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_2.$(OBJEXT): enc/iso_8859_2.c
enc/iso_8859_2.$(OBJEXT): missing.h
enc/iso_8859_2.$(OBJEXT): onigmo.h
+enc/iso_8859_2.$(OBJEXT): oniguruma.h
enc/iso_8859_3.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_3.$(OBJEXT): config.h
enc/iso_8859_3.$(OBJEXT): defines.h
@@ -323,6 +355,7 @@ enc/iso_8859_3.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_3.$(OBJEXT): enc/iso_8859_3.c
enc/iso_8859_3.$(OBJEXT): missing.h
enc/iso_8859_3.$(OBJEXT): onigmo.h
+enc/iso_8859_3.$(OBJEXT): oniguruma.h
enc/iso_8859_4.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_4.$(OBJEXT): config.h
enc/iso_8859_4.$(OBJEXT): defines.h
@@ -330,30 +363,35 @@ enc/iso_8859_4.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_4.$(OBJEXT): enc/iso_8859_4.c
enc/iso_8859_4.$(OBJEXT): missing.h
enc/iso_8859_4.$(OBJEXT): onigmo.h
+enc/iso_8859_4.$(OBJEXT): oniguruma.h
enc/iso_8859_5.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_5.$(OBJEXT): config.h
enc/iso_8859_5.$(OBJEXT): defines.h
enc/iso_8859_5.$(OBJEXT): enc/iso_8859_5.c
enc/iso_8859_5.$(OBJEXT): missing.h
enc/iso_8859_5.$(OBJEXT): onigmo.h
+enc/iso_8859_5.$(OBJEXT): oniguruma.h
enc/iso_8859_6.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_6.$(OBJEXT): config.h
enc/iso_8859_6.$(OBJEXT): defines.h
enc/iso_8859_6.$(OBJEXT): enc/iso_8859_6.c
enc/iso_8859_6.$(OBJEXT): missing.h
enc/iso_8859_6.$(OBJEXT): onigmo.h
+enc/iso_8859_6.$(OBJEXT): oniguruma.h
enc/iso_8859_7.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_7.$(OBJEXT): config.h
enc/iso_8859_7.$(OBJEXT): defines.h
enc/iso_8859_7.$(OBJEXT): enc/iso_8859_7.c
enc/iso_8859_7.$(OBJEXT): missing.h
enc/iso_8859_7.$(OBJEXT): onigmo.h
+enc/iso_8859_7.$(OBJEXT): oniguruma.h
enc/iso_8859_8.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_8.$(OBJEXT): config.h
enc/iso_8859_8.$(OBJEXT): defines.h
enc/iso_8859_8.$(OBJEXT): enc/iso_8859_8.c
enc/iso_8859_8.$(OBJEXT): missing.h
enc/iso_8859_8.$(OBJEXT): onigmo.h
+enc/iso_8859_8.$(OBJEXT): oniguruma.h
enc/iso_8859_9.$(OBJEXT): $(top_srcdir)/regenc.h
enc/iso_8859_9.$(OBJEXT): config.h
enc/iso_8859_9.$(OBJEXT): defines.h
@@ -361,30 +399,38 @@ enc/iso_8859_9.$(OBJEXT): enc/iso_8859.h
enc/iso_8859_9.$(OBJEXT): enc/iso_8859_9.c
enc/iso_8859_9.$(OBJEXT): missing.h
enc/iso_8859_9.$(OBJEXT): onigmo.h
+enc/iso_8859_9.$(OBJEXT): oniguruma.h
enc/koi8_r.$(OBJEXT): $(top_srcdir)/regenc.h
enc/koi8_r.$(OBJEXT): config.h
enc/koi8_r.$(OBJEXT): defines.h
enc/koi8_r.$(OBJEXT): enc/koi8_r.c
enc/koi8_r.$(OBJEXT): missing.h
enc/koi8_r.$(OBJEXT): onigmo.h
+enc/koi8_r.$(OBJEXT): oniguruma.h
enc/koi8_u.$(OBJEXT): $(top_srcdir)/regenc.h
enc/koi8_u.$(OBJEXT): config.h
enc/koi8_u.$(OBJEXT): defines.h
enc/koi8_u.$(OBJEXT): enc/koi8_u.c
enc/koi8_u.$(OBJEXT): missing.h
enc/koi8_u.$(OBJEXT): onigmo.h
+enc/koi8_u.$(OBJEXT): oniguruma.h
+enc/shift_jis.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/shift_jis.$(OBJEXT): $(top_srcdir)/regenc.h
+enc/shift_jis.$(OBJEXT): $(top_srcdir)/regint.h
+enc/shift_jis.$(OBJEXT): backward.h
enc/shift_jis.$(OBJEXT): config.h
enc/shift_jis.$(OBJEXT): defines.h
enc/shift_jis.$(OBJEXT): enc/jis/props.h
enc/shift_jis.$(OBJEXT): enc/jis/props.kwd
enc/shift_jis.$(OBJEXT): enc/shift_jis.c
-enc/shift_jis.$(OBJEXT): enc/shift_jis.h
+enc/shift_jis.$(OBJEXT): intern.h
enc/shift_jis.$(OBJEXT): missing.h
enc/shift_jis.$(OBJEXT): onigmo.h
+enc/shift_jis.$(OBJEXT): oniguruma.h
+enc/shift_jis.$(OBJEXT): st.h
+enc/shift_jis.$(OBJEXT): subst.h
enc/trans/big5.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/big5.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/big5.$(OBJEXT): assert.h
enc/trans/big5.$(OBJEXT): backward.h
enc/trans/big5.$(OBJEXT): config.h
enc/trans/big5.$(OBJEXT): defines.h
@@ -393,20 +439,8 @@ enc/trans/big5.$(OBJEXT): intern.h
enc/trans/big5.$(OBJEXT): missing.h
enc/trans/big5.$(OBJEXT): st.h
enc/trans/big5.$(OBJEXT): subst.h
-enc/trans/cesu_8.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enc/trans/cesu_8.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/cesu_8.$(OBJEXT): assert.h
-enc/trans/cesu_8.$(OBJEXT): backward.h
-enc/trans/cesu_8.$(OBJEXT): config.h
-enc/trans/cesu_8.$(OBJEXT): defines.h
-enc/trans/cesu_8.$(OBJEXT): enc/trans/cesu_8.c
-enc/trans/cesu_8.$(OBJEXT): intern.h
-enc/trans/cesu_8.$(OBJEXT): missing.h
-enc/trans/cesu_8.$(OBJEXT): st.h
-enc/trans/cesu_8.$(OBJEXT): subst.h
enc/trans/chinese.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/chinese.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/chinese.$(OBJEXT): assert.h
enc/trans/chinese.$(OBJEXT): backward.h
enc/trans/chinese.$(OBJEXT): config.h
enc/trans/chinese.$(OBJEXT): defines.h
@@ -417,7 +451,6 @@ enc/trans/chinese.$(OBJEXT): st.h
enc/trans/chinese.$(OBJEXT): subst.h
enc/trans/ebcdic.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/ebcdic.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/ebcdic.$(OBJEXT): assert.h
enc/trans/ebcdic.$(OBJEXT): backward.h
enc/trans/ebcdic.$(OBJEXT): config.h
enc/trans/ebcdic.$(OBJEXT): defines.h
@@ -428,7 +461,6 @@ enc/trans/ebcdic.$(OBJEXT): st.h
enc/trans/ebcdic.$(OBJEXT): subst.h
enc/trans/emoji.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/emoji.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/emoji.$(OBJEXT): assert.h
enc/trans/emoji.$(OBJEXT): backward.h
enc/trans/emoji.$(OBJEXT): config.h
enc/trans/emoji.$(OBJEXT): defines.h
@@ -439,7 +471,6 @@ enc/trans/emoji.$(OBJEXT): st.h
enc/trans/emoji.$(OBJEXT): subst.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/emoji_iso2022_kddi.$(OBJEXT): assert.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): backward.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): config.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): defines.h
@@ -450,7 +481,6 @@ enc/trans/emoji_iso2022_kddi.$(OBJEXT): st.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): subst.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/emoji_sjis_docomo.$(OBJEXT): assert.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): backward.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): config.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): defines.h
@@ -461,7 +491,6 @@ enc/trans/emoji_sjis_docomo.$(OBJEXT): st.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): subst.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/emoji_sjis_kddi.$(OBJEXT): assert.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): backward.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): config.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): defines.h
@@ -472,7 +501,6 @@ enc/trans/emoji_sjis_kddi.$(OBJEXT): st.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): subst.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/emoji_sjis_softbank.$(OBJEXT): assert.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): backward.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): config.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): defines.h
@@ -483,7 +511,6 @@ enc/trans/emoji_sjis_softbank.$(OBJEXT): st.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): subst.h
enc/trans/escape.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/escape.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/escape.$(OBJEXT): assert.h
enc/trans/escape.$(OBJEXT): backward.h
enc/trans/escape.$(OBJEXT): config.h
enc/trans/escape.$(OBJEXT): defines.h
@@ -494,7 +521,6 @@ enc/trans/escape.$(OBJEXT): st.h
enc/trans/escape.$(OBJEXT): subst.h
enc/trans/gb18030.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/gb18030.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/gb18030.$(OBJEXT): assert.h
enc/trans/gb18030.$(OBJEXT): backward.h
enc/trans/gb18030.$(OBJEXT): config.h
enc/trans/gb18030.$(OBJEXT): defines.h
@@ -505,7 +531,6 @@ enc/trans/gb18030.$(OBJEXT): st.h
enc/trans/gb18030.$(OBJEXT): subst.h
enc/trans/gbk.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/gbk.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/gbk.$(OBJEXT): assert.h
enc/trans/gbk.$(OBJEXT): backward.h
enc/trans/gbk.$(OBJEXT): config.h
enc/trans/gbk.$(OBJEXT): defines.h
@@ -516,7 +541,6 @@ enc/trans/gbk.$(OBJEXT): st.h
enc/trans/gbk.$(OBJEXT): subst.h
enc/trans/iso2022.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/iso2022.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/iso2022.$(OBJEXT): assert.h
enc/trans/iso2022.$(OBJEXT): backward.h
enc/trans/iso2022.$(OBJEXT): config.h
enc/trans/iso2022.$(OBJEXT): defines.h
@@ -527,7 +551,6 @@ enc/trans/iso2022.$(OBJEXT): st.h
enc/trans/iso2022.$(OBJEXT): subst.h
enc/trans/japanese.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/japanese.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/japanese.$(OBJEXT): assert.h
enc/trans/japanese.$(OBJEXT): backward.h
enc/trans/japanese.$(OBJEXT): config.h
enc/trans/japanese.$(OBJEXT): defines.h
@@ -538,7 +561,6 @@ enc/trans/japanese.$(OBJEXT): st.h
enc/trans/japanese.$(OBJEXT): subst.h
enc/trans/japanese_euc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/japanese_euc.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/japanese_euc.$(OBJEXT): assert.h
enc/trans/japanese_euc.$(OBJEXT): backward.h
enc/trans/japanese_euc.$(OBJEXT): config.h
enc/trans/japanese_euc.$(OBJEXT): defines.h
@@ -549,7 +571,6 @@ enc/trans/japanese_euc.$(OBJEXT): st.h
enc/trans/japanese_euc.$(OBJEXT): subst.h
enc/trans/japanese_sjis.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/japanese_sjis.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/japanese_sjis.$(OBJEXT): assert.h
enc/trans/japanese_sjis.$(OBJEXT): backward.h
enc/trans/japanese_sjis.$(OBJEXT): config.h
enc/trans/japanese_sjis.$(OBJEXT): defines.h
@@ -560,7 +581,6 @@ enc/trans/japanese_sjis.$(OBJEXT): st.h
enc/trans/japanese_sjis.$(OBJEXT): subst.h
enc/trans/korean.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/korean.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/korean.$(OBJEXT): assert.h
enc/trans/korean.$(OBJEXT): backward.h
enc/trans/korean.$(OBJEXT): config.h
enc/trans/korean.$(OBJEXT): defines.h
@@ -571,7 +591,6 @@ enc/trans/korean.$(OBJEXT): st.h
enc/trans/korean.$(OBJEXT): subst.h
enc/trans/newline.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/newline.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/newline.$(OBJEXT): assert.h
enc/trans/newline.$(OBJEXT): config.h
enc/trans/newline.$(OBJEXT): defines.h
enc/trans/newline.$(OBJEXT): enc/trans/newline.c
@@ -581,7 +600,6 @@ enc/trans/newline.$(OBJEXT): st.h
enc/trans/newline.$(OBJEXT): subst.h
enc/trans/single_byte.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/single_byte.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/single_byte.$(OBJEXT): assert.h
enc/trans/single_byte.$(OBJEXT): backward.h
enc/trans/single_byte.$(OBJEXT): config.h
enc/trans/single_byte.$(OBJEXT): defines.h
@@ -594,7 +612,6 @@ enc/trans/transdb.$(OBJEXT): enc/trans/transdb.c
enc/trans/transdb.$(OBJEXT): transdb.h
enc/trans/utf8_mac.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/utf8_mac.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/utf8_mac.$(OBJEXT): assert.h
enc/trans/utf8_mac.$(OBJEXT): backward.h
enc/trans/utf8_mac.$(OBJEXT): config.h
enc/trans/utf8_mac.$(OBJEXT): defines.h
@@ -605,7 +622,6 @@ enc/trans/utf8_mac.$(OBJEXT): st.h
enc/trans/utf8_mac.$(OBJEXT): subst.h
enc/trans/utf_16_32.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/trans/utf_16_32.$(OBJEXT): $(top_srcdir)/transcode_data.h
-enc/trans/utf_16_32.$(OBJEXT): assert.h
enc/trans/utf_16_32.$(OBJEXT): backward.h
enc/trans/utf_16_32.$(OBJEXT): config.h
enc/trans/utf_16_32.$(OBJEXT): defines.h
@@ -619,13 +635,13 @@ enc/unicode.$(OBJEXT): $(UNICODE_HDR_DIR)/name2ctype.h
enc/unicode.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/unicode.$(OBJEXT): $(top_srcdir)/regenc.h
enc/unicode.$(OBJEXT): $(top_srcdir)/regint.h
-enc/unicode.$(OBJEXT): assert.h
enc/unicode.$(OBJEXT): config.h
enc/unicode.$(OBJEXT): defines.h
enc/unicode.$(OBJEXT): enc/unicode.c
enc/unicode.$(OBJEXT): intern.h
enc/unicode.$(OBJEXT): missing.h
enc/unicode.$(OBJEXT): onigmo.h
+enc/unicode.$(OBJEXT): oniguruma.h
enc/unicode.$(OBJEXT): st.h
enc/unicode.$(OBJEXT): subst.h
enc/us_ascii.$(OBJEXT): $(top_srcdir)/encindex.h
@@ -635,6 +651,7 @@ enc/us_ascii.$(OBJEXT): defines.h
enc/us_ascii.$(OBJEXT): enc/us_ascii.c
enc/us_ascii.$(OBJEXT): missing.h
enc/us_ascii.$(OBJEXT): onigmo.h
+enc/us_ascii.$(OBJEXT): oniguruma.h
enc/utf_16be.$(OBJEXT): $(top_srcdir)/regenc.h
enc/utf_16be.$(OBJEXT): config.h
enc/utf_16be.$(OBJEXT): defines.h
@@ -642,6 +659,7 @@ enc/utf_16be.$(OBJEXT): enc/iso_8859.h
enc/utf_16be.$(OBJEXT): enc/utf_16be.c
enc/utf_16be.$(OBJEXT): missing.h
enc/utf_16be.$(OBJEXT): onigmo.h
+enc/utf_16be.$(OBJEXT): oniguruma.h
enc/utf_16le.$(OBJEXT): $(top_srcdir)/regenc.h
enc/utf_16le.$(OBJEXT): config.h
enc/utf_16le.$(OBJEXT): defines.h
@@ -649,6 +667,7 @@ enc/utf_16le.$(OBJEXT): enc/iso_8859.h
enc/utf_16le.$(OBJEXT): enc/utf_16le.c
enc/utf_16le.$(OBJEXT): missing.h
enc/utf_16le.$(OBJEXT): onigmo.h
+enc/utf_16le.$(OBJEXT): oniguruma.h
enc/utf_32be.$(OBJEXT): $(top_srcdir)/regenc.h
enc/utf_32be.$(OBJEXT): config.h
enc/utf_32be.$(OBJEXT): defines.h
@@ -656,6 +675,7 @@ enc/utf_32be.$(OBJEXT): enc/iso_8859.h
enc/utf_32be.$(OBJEXT): enc/utf_32be.c
enc/utf_32be.$(OBJEXT): missing.h
enc/utf_32be.$(OBJEXT): onigmo.h
+enc/utf_32be.$(OBJEXT): oniguruma.h
enc/utf_32le.$(OBJEXT): $(top_srcdir)/regenc.h
enc/utf_32le.$(OBJEXT): config.h
enc/utf_32le.$(OBJEXT): defines.h
@@ -663,6 +683,7 @@ enc/utf_32le.$(OBJEXT): enc/iso_8859.h
enc/utf_32le.$(OBJEXT): enc/utf_32le.c
enc/utf_32le.$(OBJEXT): missing.h
enc/utf_32le.$(OBJEXT): onigmo.h
+enc/utf_32le.$(OBJEXT): oniguruma.h
enc/utf_8.$(OBJEXT): $(top_srcdir)/encindex.h
enc/utf_8.$(OBJEXT): $(top_srcdir)/regenc.h
enc/utf_8.$(OBJEXT): config.h
@@ -670,6 +691,7 @@ enc/utf_8.$(OBJEXT): defines.h
enc/utf_8.$(OBJEXT): enc/utf_8.c
enc/utf_8.$(OBJEXT): missing.h
enc/utf_8.$(OBJEXT): onigmo.h
+enc/utf_8.$(OBJEXT): oniguruma.h
enc/windows_1250.$(OBJEXT): $(top_srcdir)/regenc.h
enc/windows_1250.$(OBJEXT): config.h
enc/windows_1250.$(OBJEXT): defines.h
@@ -677,12 +699,14 @@ enc/windows_1250.$(OBJEXT): enc/iso_8859.h
enc/windows_1250.$(OBJEXT): enc/windows_1250.c
enc/windows_1250.$(OBJEXT): missing.h
enc/windows_1250.$(OBJEXT): onigmo.h
+enc/windows_1250.$(OBJEXT): oniguruma.h
enc/windows_1251.$(OBJEXT): $(top_srcdir)/regenc.h
enc/windows_1251.$(OBJEXT): config.h
enc/windows_1251.$(OBJEXT): defines.h
enc/windows_1251.$(OBJEXT): enc/windows_1251.c
enc/windows_1251.$(OBJEXT): missing.h
enc/windows_1251.$(OBJEXT): onigmo.h
+enc/windows_1251.$(OBJEXT): oniguruma.h
enc/windows_1252.$(OBJEXT): $(top_srcdir)/regenc.h
enc/windows_1252.$(OBJEXT): config.h
enc/windows_1252.$(OBJEXT): defines.h
@@ -690,6 +714,7 @@ enc/windows_1252.$(OBJEXT): enc/iso_8859.h
enc/windows_1252.$(OBJEXT): enc/windows_1252.c
enc/windows_1252.$(OBJEXT): missing.h
enc/windows_1252.$(OBJEXT): onigmo.h
+enc/windows_1252.$(OBJEXT): oniguruma.h
enc/windows_1253.$(OBJEXT): $(top_srcdir)/regenc.h
enc/windows_1253.$(OBJEXT): config.h
enc/windows_1253.$(OBJEXT): defines.h
@@ -710,13 +735,20 @@ enc/windows_1257.$(OBJEXT): enc/iso_8859.h
enc/windows_1257.$(OBJEXT): enc/windows_1257.c
enc/windows_1257.$(OBJEXT): missing.h
enc/windows_1257.$(OBJEXT): onigmo.h
+enc/windows_31j.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enc/windows_31j.$(OBJEXT): $(top_srcdir)/regenc.h
+enc/windows_31j.$(OBJEXT): $(top_srcdir)/regint.h
+enc/windows_31j.$(OBJEXT): backward.h
enc/windows_31j.$(OBJEXT): config.h
enc/windows_31j.$(OBJEXT): defines.h
enc/windows_31j.$(OBJEXT): enc/jis/props.h
enc/windows_31j.$(OBJEXT): enc/jis/props.kwd
-enc/windows_31j.$(OBJEXT): enc/shift_jis.h
+enc/windows_31j.$(OBJEXT): enc/shift_jis.c
enc/windows_31j.$(OBJEXT): enc/windows_31j.c
+enc/windows_31j.$(OBJEXT): intern.h
enc/windows_31j.$(OBJEXT): missing.h
enc/windows_31j.$(OBJEXT): onigmo.h
+enc/windows_31j.$(OBJEXT): oniguruma.h
+enc/windows_31j.$(OBJEXT): st.h
+enc/windows_31j.$(OBJEXT): subst.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/enc/gb2312.c b/enc/gb2312.c
index 20c8f5b7cc..6fc15735fc 100644
--- a/enc/gb2312.c
+++ b/enc/gb2312.c
@@ -1,11 +1,13 @@
+#include <ruby/ruby.h>
+#include <ruby/encoding.h>
#include "regenc.h"
void
Init_gb2312(void)
{
+ rb_enc_register("GB2312", rb_enc_find("EUC-KR"));
}
-ENC_REPLICATE("GB2312", "EUC-KR")
ENC_ALIAS("EUC-CN", "GB2312")
ENC_ALIAS("eucCN", "GB2312")
ENC_REPLICATE("GB12345", "GB2312")
diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb
index bc0597e3f4..4ab85f36e3 100755
--- a/enc/make_encmake.rb
+++ b/enc/make_encmake.rb
@@ -121,11 +121,7 @@ ENCS, ENC_DEPS = target_encodings
ATRANS, TRANS = target_transcoders
if File.exist?(depend = File.join($srcdir, "depend"))
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- erb = ERB.new(File.read(depend), trim_mode: '%')
- else
- erb = ERB.new(File.read(depend), nil, '%')
- end
+ erb = ERB.new(File.read(depend), nil, '%')
erb.filename = depend
tmp = erb.result(binding)
dep = "\n#### depend ####\n\n" << depend_rules(tmp).join
@@ -139,11 +135,7 @@ open(ARGV[0], 'wb') {|f|
}
if MODULE_TYPE == :static
filename = "encinit.c.erb"
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- erb = ERB.new(File.read(File.join($srcdir, filename)), trim_mode: '%-')
- else
- erb = ERB.new(File.read(File.join($srcdir, filename)), nil, '%-')
- end
+ erb = ERB.new(File.read(File.join($srcdir, filename)), nil, '%-')
erb.filename = "enc/#{filename}"
tmp = erb.result(binding)
begin
diff --git a/enc/trans/JIS/JISX0212%UCS.src b/enc/trans/JIS/JISX0212%UCS.src
index 0e1ab4c9b9..aa51257b99 100644
--- a/enc/trans/JIS/JISX0212%UCS.src
+++ b/enc/trans/JIS/JISX0212%UCS.src
@@ -67,7 +67,7 @@ BEGIN_MAP
#
# However, JIS X 0212 maintains the distinction between
# the lowercase forms of these two elements at 0x2942 and 0x2943.
-# Given the structure of these JIS encodings, it is clear that
+# Given the structre of these JIS encodings, it is clear that
# 0x2922 and 0x2942 are intended to be a capital/small pair.
# Consequently, in the Unicode mapping, 0x2922 is treated as
# LATIN CAPITAL LETTER D WITH STROKE.
diff --git a/enc/trans/JIS/UCS%JISX0212.src b/enc/trans/JIS/UCS%JISX0212.src
index c7711c8ac0..65383a1c9f 100644
--- a/enc/trans/JIS/UCS%JISX0212.src
+++ b/enc/trans/JIS/UCS%JISX0212.src
@@ -67,7 +67,7 @@ BEGIN_MAP
#
# However, JIS X 0212 maintains the distinction between
# the lowercase forms of these two elements at 0x2942 and 0x2943.
-# Given the structure of these JIS encodings, it is clear that
+# Given the structre of these JIS encodings, it is clear that
# 0x2922 and 0x2942 are intended to be a capital/small pair.
# Consequently, in the Unicode mapping, 0x2922 is treated as
# LATIN CAPITAL LETTER D WITH STROKE.
diff --git a/enc/trans/cesu_8.trans b/enc/trans/cesu_8.trans
deleted file mode 100644
index 4e17b1ddbb..0000000000
--- a/enc/trans/cesu_8.trans
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "transcode_data.h"
-
-<%
- map = {}
- map["{00-7f}"] = :nomap
- map["{c2-df}{80-bf}"] = :nomap
- map["e0{a0-bf}{80-bf}"] = :nomap
- map["{e1-ec}{80-bf}{80-bf}"] = :nomap
- map["ed{80-9f}{80-bf}"] = :nomap
- map["{ee-ef}{80-bf}{80-bf}"] = :nomap
- map["ed{a0-af}{80-bf}ed{b0-bf}{80-bf}"] = :func_so # surrogate pairs
- transcode_generate_node(ActionMap.parse(map), "from_CESU_8")
-
- map = {}
- map["{00-7f}"] = :nomap
- map["{c2-df}{80-bf}"] = :nomap
- map["e0{a0-bf}{80-bf}"] = :nomap
- map["{e1-ec}{80-bf}{80-bf}"] = :nomap
- map["ed{80-9f}{80-bf}"] = :nomap
- map["{ee-ef}{80-bf}{80-bf}"] = :nomap
- map["f0{90-bf}{80-bf}{80-bf}"] = :func_so # planes 1-3
- map["{f1-f3}{80-bf}{80-bf}{80-bf}"] = :func_so # planes 4-15
- map["f4{80-8f}{80-bf}{80-bf}"] = :func_so # plane 16
- transcode_generate_node(ActionMap.parse(map), "to_CESU_8")
-%>
-
-<%= transcode_generated_code %>
-
-static ssize_t
-fun_so_from_cesu_8(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
-{
- unsigned int scalar = ( ((s[1]&0x0F)<<16) | ((s[2]&0x3F)<<10)
- | ((s[4]&0x0F)<< 6) | (s[5]&0x3F)
- ) + 0x10000;
- o[0] = 0xF0 | (scalar>>18);
- o[1] = 0x80 | ((scalar>>12)&0x3F);
- o[2] = 0x80 | ((scalar>> 6)&0x3F);
- o[3] = 0x80 | ( scalar &0x3F);
- return 4;
-}
-
-static ssize_t
-fun_so_to_cesu_8(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
-{
- unsigned int scalar = ((s[0]&0x07)<<18) | ((s[1]&0x3F)<<12)
- | ((s[2]&0x3F)<< 6) | (s[3]&0x3F);
- scalar -= 0x10000;
- o[0] = 0xED;
- o[1] = 0xA0 | (scalar>>16);
- o[2] = 0x80 | ((scalar>>10)&0x3F);
- o[3] = 0xED;
- o[4] = 0xB0 | ((scalar>> 6)&0x0F);
- o[5] = 0x80 | (scalar &0x3F);
- return 6;
-}
-
-static const rb_transcoder
-rb_from_CESU_8 = {
- "CESU-8", "UTF-8", from_CESU_8,
- TRANSCODE_TABLE_INFO,
- 1, /* input_unit_length */
- 6, /* max_input */
- 4, /* max_output */
- asciicompat_decoder, /* asciicompat_type */
- 0, NULL, NULL, /* state_size, state_init, state_fini */
- NULL, NULL, NULL, fun_so_from_cesu_8
-};
-
-static const rb_transcoder
-rb_to_CESU_8 = {
- "UTF-8", "CESU-8", to_CESU_8,
- TRANSCODE_TABLE_INFO,
- 1, /* input_unit_length */
- 4, /* max_input */
- 6, /* max_output */
- asciicompat_encoder, /* asciicompat_type */
- 0, NULL, NULL, /* state_size, state_init, state_fini */
- NULL, NULL, NULL, fun_so_to_cesu_8
-};
-
-TRANS_INIT(cesu_8)
-{
- rb_register_transcoder(&rb_from_CESU_8);
- rb_register_transcoder(&rb_to_CESU_8);
-}
diff --git a/enc/unicode.c b/enc/unicode.c
index 6e8c3d8816..c909022989 100644
--- a/enc/unicode.c
+++ b/enc/unicode.c
@@ -683,10 +683,8 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
MODIFIED;
if (flags & ONIGENC_CASE_FOLD_TURKISH_AZERI && code == 'i')
code = I_WITH_DOT_ABOVE;
- else {
- code -= 'a';
- code += 'A';
- }
+ else
+ code += 'A' - 'a';
}
}
else if (code >= 'A' && code <= 'Z') {
@@ -719,11 +717,7 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
}
}
else if ((folded = onigenc_unicode_fold_lookup(code)) != 0) { /* data about character found in CaseFold_11_Table */
- if ((flags & ONIGENC_CASE_TITLECASE) && code>=0x1C90 && code<=0x1CBF) { /* Georgian MTAVRULI */
- MODIFIED;
- code += 0x10D0 - 0x1C90;
- }
- else if ((flags & ONIGENC_CASE_TITLECASE) /* Titlecase needed, */
+ if ((flags & ONIGENC_CASE_TITLECASE) /* Titlecase needed, */
&& (OnigCaseFoldFlags(folded->n) & ONIGENC_CASE_IS_TITLECASE)) { /* but already Titlecase */
/* already Titlecase, no changes needed */
}
@@ -776,15 +770,10 @@ SpecialsCopy:
}
}
}
- else if ((folded = onigenc_unicode_unfold1_lookup(code)) != 0) { /* data about character found in CaseUnfold_11_Table */
- if ((flags & ONIGENC_CASE_TITLECASE) /* Titlecase needed, */
- && (OnigCaseFoldFlags(folded->n) & ONIGENC_CASE_IS_TITLECASE)) { /* but already Titlecase */
- /* already Titlecase, no changes needed */
- }
- else if (flags & OnigCaseFoldFlags(folded->n)) { /* needs and data availability match */
- MODIFIED;
- code = folded->code[(flags & OnigCaseFoldFlags(folded->n) & ONIGENC_CASE_TITLECASE) ? 1 : 0];
- }
+ else if ((folded = onigenc_unicode_unfold1_lookup(code)) != 0 /* data about character found in CaseUnfold_11_Table */
+ && flags & OnigCaseFoldFlags(folded->n)) { /* needs and data availability match */
+ MODIFIED;
+ code = folded->code[(flags & OnigCaseFoldFlags(folded->n) & ONIGENC_CASE_TITLECASE) ? 1 : 0];
}
}
to += ONIGENC_CODE_TO_MBC(enc, code, to);
@@ -797,7 +786,6 @@ SpecialsCopy:
return (int )(to - to_start);
}
-#if 0
const char onigenc_unicode_version_string[] =
#ifdef ONIG_UNICODE_VERSION_STRING
ONIG_UNICODE_VERSION_STRING
@@ -813,4 +801,3 @@ const int onigenc_unicode_version_number[3] = {
0
#endif
};
-#endif
diff --git a/enc/unicode/10.0.0/casefold.h b/enc/unicode/10.0.0/casefold.h
new file mode 100644
index 0000000000..a8f5a24e24
--- /dev/null
+++ b/enc/unicode/10.0.0/casefold.h
@@ -0,0 +1,7044 @@
+/* DO NOT EDIT THIS FILE. */
+/* Generated by enc/unicode/case-folding.rb */
+
+#if defined ONIG_UNICODE_VERSION_STRING && !( \
+ ONIG_UNICODE_VERSION_MAJOR == 10 && \
+ ONIG_UNICODE_VERSION_MINOR == 0 && \
+ ONIG_UNICODE_VERSION_TEENY == 0 && \
+ 1)
+# error ONIG_UNICODE_VERSION_STRING mismatch
+#endif
+#define ONIG_UNICODE_VERSION_STRING "10.0.0"
+#define ONIG_UNICODE_VERSION_MAJOR 10
+#define ONIG_UNICODE_VERSION_MINOR 0
+#define ONIG_UNICODE_VERSION_TEENY 0
+
+static const CaseFold_11_Type CaseFold_11_Table[] = {
+#define CaseFold (*(CaseFold_11_Type (*)[1399])(CaseFold_11_Table+0))
+ {0x0041, {1|F|D, {0x0061}}},
+ {0x0042, {1|F|D, {0x0062}}},
+ {0x0043, {1|F|D, {0x0063}}},
+ {0x0044, {1|F|D, {0x0064}}},
+ {0x0045, {1|F|D, {0x0065}}},
+ {0x0046, {1|F|D, {0x0066}}},
+ {0x0047, {1|F|D, {0x0067}}},
+ {0x0048, {1|F|D, {0x0068}}},
+ {0x004a, {1|F|D, {0x006a}}},
+ {0x004b, {1|F|D, {0x006b}}},
+ {0x004c, {1|F|D, {0x006c}}},
+ {0x004d, {1|F|D, {0x006d}}},
+ {0x004e, {1|F|D, {0x006e}}},
+ {0x004f, {1|F|D, {0x006f}}},
+ {0x0050, {1|F|D, {0x0070}}},
+ {0x0051, {1|F|D, {0x0071}}},
+ {0x0052, {1|F|D, {0x0072}}},
+ {0x0053, {1|F|D, {0x0073}}},
+ {0x0054, {1|F|D, {0x0074}}},
+ {0x0055, {1|F|D, {0x0075}}},
+ {0x0056, {1|F|D, {0x0076}}},
+ {0x0057, {1|F|D, {0x0077}}},
+ {0x0058, {1|F|D, {0x0078}}},
+ {0x0059, {1|F|D, {0x0079}}},
+ {0x005a, {1|F|D, {0x007a}}},
+ {0x00b5, {1|F|SU|I(0), {0x03bc}}},
+ {0x00c0, {1|F|D, {0x00e0}}},
+ {0x00c1, {1|F|D, {0x00e1}}},
+ {0x00c2, {1|F|D, {0x00e2}}},
+ {0x00c3, {1|F|D, {0x00e3}}},
+ {0x00c4, {1|F|D, {0x00e4}}},
+ {0x00c5, {1|F|D, {0x00e5}}},
+ {0x00c6, {1|F|D, {0x00e6}}},
+ {0x00c7, {1|F|D, {0x00e7}}},
+ {0x00c8, {1|F|D, {0x00e8}}},
+ {0x00c9, {1|F|D, {0x00e9}}},
+ {0x00ca, {1|F|D, {0x00ea}}},
+ {0x00cb, {1|F|D, {0x00eb}}},
+ {0x00cc, {1|F|D, {0x00ec}}},
+ {0x00cd, {1|F|D, {0x00ed}}},
+ {0x00ce, {1|F|D, {0x00ee}}},
+ {0x00cf, {1|F|D, {0x00ef}}},
+ {0x00d0, {1|F|D, {0x00f0}}},
+ {0x00d1, {1|F|D, {0x00f1}}},
+ {0x00d2, {1|F|D, {0x00f2}}},
+ {0x00d3, {1|F|D, {0x00f3}}},
+ {0x00d4, {1|F|D, {0x00f4}}},
+ {0x00d5, {1|F|D, {0x00f5}}},
+ {0x00d6, {1|F|D, {0x00f6}}},
+ {0x00d8, {1|F|D, {0x00f8}}},
+ {0x00d9, {1|F|D, {0x00f9}}},
+ {0x00da, {1|F|D, {0x00fa}}},
+ {0x00db, {1|F|D, {0x00fb}}},
+ {0x00dc, {1|F|D, {0x00fc}}},
+ {0x00dd, {1|F|D, {0x00fd}}},
+ {0x00de, {1|F|D, {0x00fe}}},
+ {0x00df, {2|F|ST|SU|I(1), {0x0073, 0x0073}}},
+ {0x0100, {1|F|D, {0x0101}}},
+ {0x0102, {1|F|D, {0x0103}}},
+ {0x0104, {1|F|D, {0x0105}}},
+ {0x0106, {1|F|D, {0x0107}}},
+ {0x0108, {1|F|D, {0x0109}}},
+ {0x010a, {1|F|D, {0x010b}}},
+ {0x010c, {1|F|D, {0x010d}}},
+ {0x010e, {1|F|D, {0x010f}}},
+ {0x0110, {1|F|D, {0x0111}}},
+ {0x0112, {1|F|D, {0x0113}}},
+ {0x0114, {1|F|D, {0x0115}}},
+ {0x0116, {1|F|D, {0x0117}}},
+ {0x0118, {1|F|D, {0x0119}}},
+ {0x011a, {1|F|D, {0x011b}}},
+ {0x011c, {1|F|D, {0x011d}}},
+ {0x011e, {1|F|D, {0x011f}}},
+ {0x0120, {1|F|D, {0x0121}}},
+ {0x0122, {1|F|D, {0x0123}}},
+ {0x0124, {1|F|D, {0x0125}}},
+ {0x0126, {1|F|D, {0x0127}}},
+ {0x0128, {1|F|D, {0x0129}}},
+ {0x012a, {1|F|D, {0x012b}}},
+ {0x012c, {1|F|D, {0x012d}}},
+ {0x012e, {1|F|D, {0x012f}}},
+ {0x0132, {1|F|D, {0x0133}}},
+ {0x0134, {1|F|D, {0x0135}}},
+ {0x0136, {1|F|D, {0x0137}}},
+ {0x0139, {1|F|D, {0x013a}}},
+ {0x013b, {1|F|D, {0x013c}}},
+ {0x013d, {1|F|D, {0x013e}}},
+ {0x013f, {1|F|D, {0x0140}}},
+ {0x0141, {1|F|D, {0x0142}}},
+ {0x0143, {1|F|D, {0x0144}}},
+ {0x0145, {1|F|D, {0x0146}}},
+ {0x0147, {1|F|D, {0x0148}}},
+ {0x0149, {2|F|SU|I(5), {0x02bc, 0x006e}}},
+ {0x014a, {1|F|D, {0x014b}}},
+ {0x014c, {1|F|D, {0x014d}}},
+ {0x014e, {1|F|D, {0x014f}}},
+ {0x0150, {1|F|D, {0x0151}}},
+ {0x0152, {1|F|D, {0x0153}}},
+ {0x0154, {1|F|D, {0x0155}}},
+ {0x0156, {1|F|D, {0x0157}}},
+ {0x0158, {1|F|D, {0x0159}}},
+ {0x015a, {1|F|D, {0x015b}}},
+ {0x015c, {1|F|D, {0x015d}}},
+ {0x015e, {1|F|D, {0x015f}}},
+ {0x0160, {1|F|D, {0x0161}}},
+ {0x0162, {1|F|D, {0x0163}}},
+ {0x0164, {1|F|D, {0x0165}}},
+ {0x0166, {1|F|D, {0x0167}}},
+ {0x0168, {1|F|D, {0x0169}}},
+ {0x016a, {1|F|D, {0x016b}}},
+ {0x016c, {1|F|D, {0x016d}}},
+ {0x016e, {1|F|D, {0x016f}}},
+ {0x0170, {1|F|D, {0x0171}}},
+ {0x0172, {1|F|D, {0x0173}}},
+ {0x0174, {1|F|D, {0x0175}}},
+ {0x0176, {1|F|D, {0x0177}}},
+ {0x0178, {1|F|D, {0x00ff}}},
+ {0x0179, {1|F|D, {0x017a}}},
+ {0x017b, {1|F|D, {0x017c}}},
+ {0x017d, {1|F|D, {0x017e}}},
+ {0x017f, {1|F|SU|I(7), {0x0073}}},
+ {0x0181, {1|F|D, {0x0253}}},
+ {0x0182, {1|F|D, {0x0183}}},
+ {0x0184, {1|F|D, {0x0185}}},
+ {0x0186, {1|F|D, {0x0254}}},
+ {0x0187, {1|F|D, {0x0188}}},
+ {0x0189, {1|F|D, {0x0256}}},
+ {0x018a, {1|F|D, {0x0257}}},
+ {0x018b, {1|F|D, {0x018c}}},
+ {0x018e, {1|F|D, {0x01dd}}},
+ {0x018f, {1|F|D, {0x0259}}},
+ {0x0190, {1|F|D, {0x025b}}},
+ {0x0191, {1|F|D, {0x0192}}},
+ {0x0193, {1|F|D, {0x0260}}},
+ {0x0194, {1|F|D, {0x0263}}},
+ {0x0196, {1|F|D, {0x0269}}},
+ {0x0197, {1|F|D, {0x0268}}},
+ {0x0198, {1|F|D, {0x0199}}},
+ {0x019c, {1|F|D, {0x026f}}},
+ {0x019d, {1|F|D, {0x0272}}},
+ {0x019f, {1|F|D, {0x0275}}},
+ {0x01a0, {1|F|D, {0x01a1}}},
+ {0x01a2, {1|F|D, {0x01a3}}},
+ {0x01a4, {1|F|D, {0x01a5}}},
+ {0x01a6, {1|F|D, {0x0280}}},
+ {0x01a7, {1|F|D, {0x01a8}}},
+ {0x01a9, {1|F|D, {0x0283}}},
+ {0x01ac, {1|F|D, {0x01ad}}},
+ {0x01ae, {1|F|D, {0x0288}}},
+ {0x01af, {1|F|D, {0x01b0}}},
+ {0x01b1, {1|F|D, {0x028a}}},
+ {0x01b2, {1|F|D, {0x028b}}},
+ {0x01b3, {1|F|D, {0x01b4}}},
+ {0x01b5, {1|F|D, {0x01b6}}},
+ {0x01b7, {1|F|D, {0x0292}}},
+ {0x01b8, {1|F|D, {0x01b9}}},
+ {0x01bc, {1|F|D, {0x01bd}}},
+ {0x01c4, {1|F|D|ST|I(8), {0x01c6}}},
+ {0x01c5, {1|F|D|IT|SU|I(9), {0x01c6}}},
+ {0x01c7, {1|F|D|ST|I(12), {0x01c9}}},
+ {0x01c8, {1|F|D|IT|SU|I(13), {0x01c9}}},
+ {0x01ca, {1|F|D|ST|I(16), {0x01cc}}},
+ {0x01cb, {1|F|D|IT|SU|I(17), {0x01cc}}},
+ {0x01cd, {1|F|D, {0x01ce}}},
+ {0x01cf, {1|F|D, {0x01d0}}},
+ {0x01d1, {1|F|D, {0x01d2}}},
+ {0x01d3, {1|F|D, {0x01d4}}},
+ {0x01d5, {1|F|D, {0x01d6}}},
+ {0x01d7, {1|F|D, {0x01d8}}},
+ {0x01d9, {1|F|D, {0x01da}}},
+ {0x01db, {1|F|D, {0x01dc}}},
+ {0x01de, {1|F|D, {0x01df}}},
+ {0x01e0, {1|F|D, {0x01e1}}},
+ {0x01e2, {1|F|D, {0x01e3}}},
+ {0x01e4, {1|F|D, {0x01e5}}},
+ {0x01e6, {1|F|D, {0x01e7}}},
+ {0x01e8, {1|F|D, {0x01e9}}},
+ {0x01ea, {1|F|D, {0x01eb}}},
+ {0x01ec, {1|F|D, {0x01ed}}},
+ {0x01ee, {1|F|D, {0x01ef}}},
+ {0x01f0, {2|F|SU|I(20), {0x006a, 0x030c}}},
+ {0x01f1, {1|F|D|ST|I(22), {0x01f3}}},
+ {0x01f2, {1|F|D|IT|SU|I(23), {0x01f3}}},
+ {0x01f4, {1|F|D, {0x01f5}}},
+ {0x01f6, {1|F|D, {0x0195}}},
+ {0x01f7, {1|F|D, {0x01bf}}},
+ {0x01f8, {1|F|D, {0x01f9}}},
+ {0x01fa, {1|F|D, {0x01fb}}},
+ {0x01fc, {1|F|D, {0x01fd}}},
+ {0x01fe, {1|F|D, {0x01ff}}},
+ {0x0200, {1|F|D, {0x0201}}},
+ {0x0202, {1|F|D, {0x0203}}},
+ {0x0204, {1|F|D, {0x0205}}},
+ {0x0206, {1|F|D, {0x0207}}},
+ {0x0208, {1|F|D, {0x0209}}},
+ {0x020a, {1|F|D, {0x020b}}},
+ {0x020c, {1|F|D, {0x020d}}},
+ {0x020e, {1|F|D, {0x020f}}},
+ {0x0210, {1|F|D, {0x0211}}},
+ {0x0212, {1|F|D, {0x0213}}},
+ {0x0214, {1|F|D, {0x0215}}},
+ {0x0216, {1|F|D, {0x0217}}},
+ {0x0218, {1|F|D, {0x0219}}},
+ {0x021a, {1|F|D, {0x021b}}},
+ {0x021c, {1|F|D, {0x021d}}},
+ {0x021e, {1|F|D, {0x021f}}},
+ {0x0220, {1|F|D, {0x019e}}},
+ {0x0222, {1|F|D, {0x0223}}},
+ {0x0224, {1|F|D, {0x0225}}},
+ {0x0226, {1|F|D, {0x0227}}},
+ {0x0228, {1|F|D, {0x0229}}},
+ {0x022a, {1|F|D, {0x022b}}},
+ {0x022c, {1|F|D, {0x022d}}},
+ {0x022e, {1|F|D, {0x022f}}},
+ {0x0230, {1|F|D, {0x0231}}},
+ {0x0232, {1|F|D, {0x0233}}},
+ {0x023a, {1|F|D, {0x2c65}}},
+ {0x023b, {1|F|D, {0x023c}}},
+ {0x023d, {1|F|D, {0x019a}}},
+ {0x023e, {1|F|D, {0x2c66}}},
+ {0x0241, {1|F|D, {0x0242}}},
+ {0x0243, {1|F|D, {0x0180}}},
+ {0x0244, {1|F|D, {0x0289}}},
+ {0x0245, {1|F|D, {0x028c}}},
+ {0x0246, {1|F|D, {0x0247}}},
+ {0x0248, {1|F|D, {0x0249}}},
+ {0x024a, {1|F|D, {0x024b}}},
+ {0x024c, {1|F|D, {0x024d}}},
+ {0x024e, {1|F|D, {0x024f}}},
+ {0x0345, {1|F|SU|I(26), {0x03b9}}},
+ {0x0370, {1|F|D, {0x0371}}},
+ {0x0372, {1|F|D, {0x0373}}},
+ {0x0376, {1|F|D, {0x0377}}},
+ {0x037f, {1|F|D, {0x03f3}}},
+ {0x0386, {1|F|D, {0x03ac}}},
+ {0x0388, {1|F|D, {0x03ad}}},
+ {0x0389, {1|F|D, {0x03ae}}},
+ {0x038a, {1|F|D, {0x03af}}},
+ {0x038c, {1|F|D, {0x03cc}}},
+ {0x038e, {1|F|D, {0x03cd}}},
+ {0x038f, {1|F|D, {0x03ce}}},
+ {0x0390, {3|F|SU|I(27), {0x03b9, 0x0308, 0x0301}}},
+ {0x0391, {1|F|D, {0x03b1}}},
+ {0x0392, {1|F|D, {0x03b2}}},
+ {0x0393, {1|F|D, {0x03b3}}},
+ {0x0394, {1|F|D, {0x03b4}}},
+ {0x0395, {1|F|D, {0x03b5}}},
+ {0x0396, {1|F|D, {0x03b6}}},
+ {0x0397, {1|F|D, {0x03b7}}},
+ {0x0398, {1|F|D, {0x03b8}}},
+ {0x0399, {1|F|D, {0x03b9}}},
+ {0x039a, {1|F|D, {0x03ba}}},
+ {0x039b, {1|F|D, {0x03bb}}},
+ {0x039c, {1|F|D, {0x03bc}}},
+ {0x039d, {1|F|D, {0x03bd}}},
+ {0x039e, {1|F|D, {0x03be}}},
+ {0x039f, {1|F|D, {0x03bf}}},
+ {0x03a0, {1|F|D, {0x03c0}}},
+ {0x03a1, {1|F|D, {0x03c1}}},
+ {0x03a3, {1|F|D, {0x03c3}}},
+ {0x03a4, {1|F|D, {0x03c4}}},
+ {0x03a5, {1|F|D, {0x03c5}}},
+ {0x03a6, {1|F|D, {0x03c6}}},
+ {0x03a7, {1|F|D, {0x03c7}}},
+ {0x03a8, {1|F|D, {0x03c8}}},
+ {0x03a9, {1|F|D, {0x03c9}}},
+ {0x03aa, {1|F|D, {0x03ca}}},
+ {0x03ab, {1|F|D, {0x03cb}}},
+ {0x03b0, {3|F|SU|I(30), {0x03c5, 0x0308, 0x0301}}},
+ {0x03c2, {1|F|SU|I(33), {0x03c3}}},
+ {0x03cf, {1|F|D, {0x03d7}}},
+ {0x03d0, {1|F|SU|I(34), {0x03b2}}},
+ {0x03d1, {1|F|SU|I(35), {0x03b8}}},
+ {0x03d5, {1|F|SU|I(36), {0x03c6}}},
+ {0x03d6, {1|F|SU|I(37), {0x03c0}}},
+ {0x03d8, {1|F|D, {0x03d9}}},
+ {0x03da, {1|F|D, {0x03db}}},
+ {0x03dc, {1|F|D, {0x03dd}}},
+ {0x03de, {1|F|D, {0x03df}}},
+ {0x03e0, {1|F|D, {0x03e1}}},
+ {0x03e2, {1|F|D, {0x03e3}}},
+ {0x03e4, {1|F|D, {0x03e5}}},
+ {0x03e6, {1|F|D, {0x03e7}}},
+ {0x03e8, {1|F|D, {0x03e9}}},
+ {0x03ea, {1|F|D, {0x03eb}}},
+ {0x03ec, {1|F|D, {0x03ed}}},
+ {0x03ee, {1|F|D, {0x03ef}}},
+ {0x03f0, {1|F|SU|I(38), {0x03ba}}},
+ {0x03f1, {1|F|SU|I(39), {0x03c1}}},
+ {0x03f4, {1|F|D, {0x03b8}}},
+ {0x03f5, {1|F|SU|I(40), {0x03b5}}},
+ {0x03f7, {1|F|D, {0x03f8}}},
+ {0x03f9, {1|F|D, {0x03f2}}},
+ {0x03fa, {1|F|D, {0x03fb}}},
+ {0x03fd, {1|F|D, {0x037b}}},
+ {0x03fe, {1|F|D, {0x037c}}},
+ {0x03ff, {1|F|D, {0x037d}}},
+ {0x0400, {1|F|D, {0x0450}}},
+ {0x0401, {1|F|D, {0x0451}}},
+ {0x0402, {1|F|D, {0x0452}}},
+ {0x0403, {1|F|D, {0x0453}}},
+ {0x0404, {1|F|D, {0x0454}}},
+ {0x0405, {1|F|D, {0x0455}}},
+ {0x0406, {1|F|D, {0x0456}}},
+ {0x0407, {1|F|D, {0x0457}}},
+ {0x0408, {1|F|D, {0x0458}}},
+ {0x0409, {1|F|D, {0x0459}}},
+ {0x040a, {1|F|D, {0x045a}}},
+ {0x040b, {1|F|D, {0x045b}}},
+ {0x040c, {1|F|D, {0x045c}}},
+ {0x040d, {1|F|D, {0x045d}}},
+ {0x040e, {1|F|D, {0x045e}}},
+ {0x040f, {1|F|D, {0x045f}}},
+ {0x0410, {1|F|D, {0x0430}}},
+ {0x0411, {1|F|D, {0x0431}}},
+ {0x0412, {1|F|D, {0x0432}}},
+ {0x0413, {1|F|D, {0x0433}}},
+ {0x0414, {1|F|D, {0x0434}}},
+ {0x0415, {1|F|D, {0x0435}}},
+ {0x0416, {1|F|D, {0x0436}}},
+ {0x0417, {1|F|D, {0x0437}}},
+ {0x0418, {1|F|D, {0x0438}}},
+ {0x0419, {1|F|D, {0x0439}}},
+ {0x041a, {1|F|D, {0x043a}}},
+ {0x041b, {1|F|D, {0x043b}}},
+ {0x041c, {1|F|D, {0x043c}}},
+ {0x041d, {1|F|D, {0x043d}}},
+ {0x041e, {1|F|D, {0x043e}}},
+ {0x041f, {1|F|D, {0x043f}}},
+ {0x0420, {1|F|D, {0x0440}}},
+ {0x0421, {1|F|D, {0x0441}}},
+ {0x0422, {1|F|D, {0x0442}}},
+ {0x0423, {1|F|D, {0x0443}}},
+ {0x0424, {1|F|D, {0x0444}}},
+ {0x0425, {1|F|D, {0x0445}}},
+ {0x0426, {1|F|D, {0x0446}}},
+ {0x0427, {1|F|D, {0x0447}}},
+ {0x0428, {1|F|D, {0x0448}}},
+ {0x0429, {1|F|D, {0x0449}}},
+ {0x042a, {1|F|D, {0x044a}}},
+ {0x042b, {1|F|D, {0x044b}}},
+ {0x042c, {1|F|D, {0x044c}}},
+ {0x042d, {1|F|D, {0x044d}}},
+ {0x042e, {1|F|D, {0x044e}}},
+ {0x042f, {1|F|D, {0x044f}}},
+ {0x0460, {1|F|D, {0x0461}}},
+ {0x0462, {1|F|D, {0x0463}}},
+ {0x0464, {1|F|D, {0x0465}}},
+ {0x0466, {1|F|D, {0x0467}}},
+ {0x0468, {1|F|D, {0x0469}}},
+ {0x046a, {1|F|D, {0x046b}}},
+ {0x046c, {1|F|D, {0x046d}}},
+ {0x046e, {1|F|D, {0x046f}}},
+ {0x0470, {1|F|D, {0x0471}}},
+ {0x0472, {1|F|D, {0x0473}}},
+ {0x0474, {1|F|D, {0x0475}}},
+ {0x0476, {1|F|D, {0x0477}}},
+ {0x0478, {1|F|D, {0x0479}}},
+ {0x047a, {1|F|D, {0x047b}}},
+ {0x047c, {1|F|D, {0x047d}}},
+ {0x047e, {1|F|D, {0x047f}}},
+ {0x0480, {1|F|D, {0x0481}}},
+ {0x048a, {1|F|D, {0x048b}}},
+ {0x048c, {1|F|D, {0x048d}}},
+ {0x048e, {1|F|D, {0x048f}}},
+ {0x0490, {1|F|D, {0x0491}}},
+ {0x0492, {1|F|D, {0x0493}}},
+ {0x0494, {1|F|D, {0x0495}}},
+ {0x0496, {1|F|D, {0x0497}}},
+ {0x0498, {1|F|D, {0x0499}}},
+ {0x049a, {1|F|D, {0x049b}}},
+ {0x049c, {1|F|D, {0x049d}}},
+ {0x049e, {1|F|D, {0x049f}}},
+ {0x04a0, {1|F|D, {0x04a1}}},
+ {0x04a2, {1|F|D, {0x04a3}}},
+ {0x04a4, {1|F|D, {0x04a5}}},
+ {0x04a6, {1|F|D, {0x04a7}}},
+ {0x04a8, {1|F|D, {0x04a9}}},
+ {0x04aa, {1|F|D, {0x04ab}}},
+ {0x04ac, {1|F|D, {0x04ad}}},
+ {0x04ae, {1|F|D, {0x04af}}},
+ {0x04b0, {1|F|D, {0x04b1}}},
+ {0x04b2, {1|F|D, {0x04b3}}},
+ {0x04b4, {1|F|D, {0x04b5}}},
+ {0x04b6, {1|F|D, {0x04b7}}},
+ {0x04b8, {1|F|D, {0x04b9}}},
+ {0x04ba, {1|F|D, {0x04bb}}},
+ {0x04bc, {1|F|D, {0x04bd}}},
+ {0x04be, {1|F|D, {0x04bf}}},
+ {0x04c0, {1|F|D, {0x04cf}}},
+ {0x04c1, {1|F|D, {0x04c2}}},
+ {0x04c3, {1|F|D, {0x04c4}}},
+ {0x04c5, {1|F|D, {0x04c6}}},
+ {0x04c7, {1|F|D, {0x04c8}}},
+ {0x04c9, {1|F|D, {0x04ca}}},
+ {0x04cb, {1|F|D, {0x04cc}}},
+ {0x04cd, {1|F|D, {0x04ce}}},
+ {0x04d0, {1|F|D, {0x04d1}}},
+ {0x04d2, {1|F|D, {0x04d3}}},
+ {0x04d4, {1|F|D, {0x04d5}}},
+ {0x04d6, {1|F|D, {0x04d7}}},
+ {0x04d8, {1|F|D, {0x04d9}}},
+ {0x04da, {1|F|D, {0x04db}}},
+ {0x04dc, {1|F|D, {0x04dd}}},
+ {0x04de, {1|F|D, {0x04df}}},
+ {0x04e0, {1|F|D, {0x04e1}}},
+ {0x04e2, {1|F|D, {0x04e3}}},
+ {0x04e4, {1|F|D, {0x04e5}}},
+ {0x04e6, {1|F|D, {0x04e7}}},
+ {0x04e8, {1|F|D, {0x04e9}}},
+ {0x04ea, {1|F|D, {0x04eb}}},
+ {0x04ec, {1|F|D, {0x04ed}}},
+ {0x04ee, {1|F|D, {0x04ef}}},
+ {0x04f0, {1|F|D, {0x04f1}}},
+ {0x04f2, {1|F|D, {0x04f3}}},
+ {0x04f4, {1|F|D, {0x04f5}}},
+ {0x04f6, {1|F|D, {0x04f7}}},
+ {0x04f8, {1|F|D, {0x04f9}}},
+ {0x04fa, {1|F|D, {0x04fb}}},
+ {0x04fc, {1|F|D, {0x04fd}}},
+ {0x04fe, {1|F|D, {0x04ff}}},
+ {0x0500, {1|F|D, {0x0501}}},
+ {0x0502, {1|F|D, {0x0503}}},
+ {0x0504, {1|F|D, {0x0505}}},
+ {0x0506, {1|F|D, {0x0507}}},
+ {0x0508, {1|F|D, {0x0509}}},
+ {0x050a, {1|F|D, {0x050b}}},
+ {0x050c, {1|F|D, {0x050d}}},
+ {0x050e, {1|F|D, {0x050f}}},
+ {0x0510, {1|F|D, {0x0511}}},
+ {0x0512, {1|F|D, {0x0513}}},
+ {0x0514, {1|F|D, {0x0515}}},
+ {0x0516, {1|F|D, {0x0517}}},
+ {0x0518, {1|F|D, {0x0519}}},
+ {0x051a, {1|F|D, {0x051b}}},
+ {0x051c, {1|F|D, {0x051d}}},
+ {0x051e, {1|F|D, {0x051f}}},
+ {0x0520, {1|F|D, {0x0521}}},
+ {0x0522, {1|F|D, {0x0523}}},
+ {0x0524, {1|F|D, {0x0525}}},
+ {0x0526, {1|F|D, {0x0527}}},
+ {0x0528, {1|F|D, {0x0529}}},
+ {0x052a, {1|F|D, {0x052b}}},
+ {0x052c, {1|F|D, {0x052d}}},
+ {0x052e, {1|F|D, {0x052f}}},
+ {0x0531, {1|F|D, {0x0561}}},
+ {0x0532, {1|F|D, {0x0562}}},
+ {0x0533, {1|F|D, {0x0563}}},
+ {0x0534, {1|F|D, {0x0564}}},
+ {0x0535, {1|F|D, {0x0565}}},
+ {0x0536, {1|F|D, {0x0566}}},
+ {0x0537, {1|F|D, {0x0567}}},
+ {0x0538, {1|F|D, {0x0568}}},
+ {0x0539, {1|F|D, {0x0569}}},
+ {0x053a, {1|F|D, {0x056a}}},
+ {0x053b, {1|F|D, {0x056b}}},
+ {0x053c, {1|F|D, {0x056c}}},
+ {0x053d, {1|F|D, {0x056d}}},
+ {0x053e, {1|F|D, {0x056e}}},
+ {0x053f, {1|F|D, {0x056f}}},
+ {0x0540, {1|F|D, {0x0570}}},
+ {0x0541, {1|F|D, {0x0571}}},
+ {0x0542, {1|F|D, {0x0572}}},
+ {0x0543, {1|F|D, {0x0573}}},
+ {0x0544, {1|F|D, {0x0574}}},
+ {0x0545, {1|F|D, {0x0575}}},
+ {0x0546, {1|F|D, {0x0576}}},
+ {0x0547, {1|F|D, {0x0577}}},
+ {0x0548, {1|F|D, {0x0578}}},
+ {0x0549, {1|F|D, {0x0579}}},
+ {0x054a, {1|F|D, {0x057a}}},
+ {0x054b, {1|F|D, {0x057b}}},
+ {0x054c, {1|F|D, {0x057c}}},
+ {0x054d, {1|F|D, {0x057d}}},
+ {0x054e, {1|F|D, {0x057e}}},
+ {0x054f, {1|F|D, {0x057f}}},
+ {0x0550, {1|F|D, {0x0580}}},
+ {0x0551, {1|F|D, {0x0581}}},
+ {0x0552, {1|F|D, {0x0582}}},
+ {0x0553, {1|F|D, {0x0583}}},
+ {0x0554, {1|F|D, {0x0584}}},
+ {0x0555, {1|F|D, {0x0585}}},
+ {0x0556, {1|F|D, {0x0586}}},
+ {0x0587, {2|F|ST|SU|I(41), {0x0565, 0x0582}}},
+ {0x10a0, {1|F|D, {0x2d00}}},
+ {0x10a1, {1|F|D, {0x2d01}}},
+ {0x10a2, {1|F|D, {0x2d02}}},
+ {0x10a3, {1|F|D, {0x2d03}}},
+ {0x10a4, {1|F|D, {0x2d04}}},
+ {0x10a5, {1|F|D, {0x2d05}}},
+ {0x10a6, {1|F|D, {0x2d06}}},
+ {0x10a7, {1|F|D, {0x2d07}}},
+ {0x10a8, {1|F|D, {0x2d08}}},
+ {0x10a9, {1|F|D, {0x2d09}}},
+ {0x10aa, {1|F|D, {0x2d0a}}},
+ {0x10ab, {1|F|D, {0x2d0b}}},
+ {0x10ac, {1|F|D, {0x2d0c}}},
+ {0x10ad, {1|F|D, {0x2d0d}}},
+ {0x10ae, {1|F|D, {0x2d0e}}},
+ {0x10af, {1|F|D, {0x2d0f}}},
+ {0x10b0, {1|F|D, {0x2d10}}},
+ {0x10b1, {1|F|D, {0x2d11}}},
+ {0x10b2, {1|F|D, {0x2d12}}},
+ {0x10b3, {1|F|D, {0x2d13}}},
+ {0x10b4, {1|F|D, {0x2d14}}},
+ {0x10b5, {1|F|D, {0x2d15}}},
+ {0x10b6, {1|F|D, {0x2d16}}},
+ {0x10b7, {1|F|D, {0x2d17}}},
+ {0x10b8, {1|F|D, {0x2d18}}},
+ {0x10b9, {1|F|D, {0x2d19}}},
+ {0x10ba, {1|F|D, {0x2d1a}}},
+ {0x10bb, {1|F|D, {0x2d1b}}},
+ {0x10bc, {1|F|D, {0x2d1c}}},
+ {0x10bd, {1|F|D, {0x2d1d}}},
+ {0x10be, {1|F|D, {0x2d1e}}},
+ {0x10bf, {1|F|D, {0x2d1f}}},
+ {0x10c0, {1|F|D, {0x2d20}}},
+ {0x10c1, {1|F|D, {0x2d21}}},
+ {0x10c2, {1|F|D, {0x2d22}}},
+ {0x10c3, {1|F|D, {0x2d23}}},
+ {0x10c4, {1|F|D, {0x2d24}}},
+ {0x10c5, {1|F|D, {0x2d25}}},
+ {0x10c7, {1|F|D, {0x2d27}}},
+ {0x10cd, {1|F|D, {0x2d2d}}},
+ {0x13f8, {1|F|U, {0x13f0}}},
+ {0x13f9, {1|F|U, {0x13f1}}},
+ {0x13fa, {1|F|U, {0x13f2}}},
+ {0x13fb, {1|F|U, {0x13f3}}},
+ {0x13fc, {1|F|U, {0x13f4}}},
+ {0x13fd, {1|F|U, {0x13f5}}},
+ {0x1c80, {1|F|SU|I(45), {0x0432}}},
+ {0x1c81, {1|F|SU|I(46), {0x0434}}},
+ {0x1c82, {1|F|SU|I(47), {0x043e}}},
+ {0x1c83, {1|F|SU|I(48), {0x0441}}},
+ {0x1c84, {1|F|SU|I(49), {0x0442}}},
+ {0x1c85, {1|F|SU|I(50), {0x0442}}},
+ {0x1c86, {1|F|SU|I(51), {0x044a}}},
+ {0x1c87, {1|F|SU|I(52), {0x0463}}},
+ {0x1c88, {1|F|SU|I(53), {0xa64b}}},
+ {0x1e00, {1|F|D, {0x1e01}}},
+ {0x1e02, {1|F|D, {0x1e03}}},
+ {0x1e04, {1|F|D, {0x1e05}}},
+ {0x1e06, {1|F|D, {0x1e07}}},
+ {0x1e08, {1|F|D, {0x1e09}}},
+ {0x1e0a, {1|F|D, {0x1e0b}}},
+ {0x1e0c, {1|F|D, {0x1e0d}}},
+ {0x1e0e, {1|F|D, {0x1e0f}}},
+ {0x1e10, {1|F|D, {0x1e11}}},
+ {0x1e12, {1|F|D, {0x1e13}}},
+ {0x1e14, {1|F|D, {0x1e15}}},
+ {0x1e16, {1|F|D, {0x1e17}}},
+ {0x1e18, {1|F|D, {0x1e19}}},
+ {0x1e1a, {1|F|D, {0x1e1b}}},
+ {0x1e1c, {1|F|D, {0x1e1d}}},
+ {0x1e1e, {1|F|D, {0x1e1f}}},
+ {0x1e20, {1|F|D, {0x1e21}}},
+ {0x1e22, {1|F|D, {0x1e23}}},
+ {0x1e24, {1|F|D, {0x1e25}}},
+ {0x1e26, {1|F|D, {0x1e27}}},
+ {0x1e28, {1|F|D, {0x1e29}}},
+ {0x1e2a, {1|F|D, {0x1e2b}}},
+ {0x1e2c, {1|F|D, {0x1e2d}}},
+ {0x1e2e, {1|F|D, {0x1e2f}}},
+ {0x1e30, {1|F|D, {0x1e31}}},
+ {0x1e32, {1|F|D, {0x1e33}}},
+ {0x1e34, {1|F|D, {0x1e35}}},
+ {0x1e36, {1|F|D, {0x1e37}}},
+ {0x1e38, {1|F|D, {0x1e39}}},
+ {0x1e3a, {1|F|D, {0x1e3b}}},
+ {0x1e3c, {1|F|D, {0x1e3d}}},
+ {0x1e3e, {1|F|D, {0x1e3f}}},
+ {0x1e40, {1|F|D, {0x1e41}}},
+ {0x1e42, {1|F|D, {0x1e43}}},
+ {0x1e44, {1|F|D, {0x1e45}}},
+ {0x1e46, {1|F|D, {0x1e47}}},
+ {0x1e48, {1|F|D, {0x1e49}}},
+ {0x1e4a, {1|F|D, {0x1e4b}}},
+ {0x1e4c, {1|F|D, {0x1e4d}}},
+ {0x1e4e, {1|F|D, {0x1e4f}}},
+ {0x1e50, {1|F|D, {0x1e51}}},
+ {0x1e52, {1|F|D, {0x1e53}}},
+ {0x1e54, {1|F|D, {0x1e55}}},
+ {0x1e56, {1|F|D, {0x1e57}}},
+ {0x1e58, {1|F|D, {0x1e59}}},
+ {0x1e5a, {1|F|D, {0x1e5b}}},
+ {0x1e5c, {1|F|D, {0x1e5d}}},
+ {0x1e5e, {1|F|D, {0x1e5f}}},
+ {0x1e60, {1|F|D, {0x1e61}}},
+ {0x1e62, {1|F|D, {0x1e63}}},
+ {0x1e64, {1|F|D, {0x1e65}}},
+ {0x1e66, {1|F|D, {0x1e67}}},
+ {0x1e68, {1|F|D, {0x1e69}}},
+ {0x1e6a, {1|F|D, {0x1e6b}}},
+ {0x1e6c, {1|F|D, {0x1e6d}}},
+ {0x1e6e, {1|F|D, {0x1e6f}}},
+ {0x1e70, {1|F|D, {0x1e71}}},
+ {0x1e72, {1|F|D, {0x1e73}}},
+ {0x1e74, {1|F|D, {0x1e75}}},
+ {0x1e76, {1|F|D, {0x1e77}}},
+ {0x1e78, {1|F|D, {0x1e79}}},
+ {0x1e7a, {1|F|D, {0x1e7b}}},
+ {0x1e7c, {1|F|D, {0x1e7d}}},
+ {0x1e7e, {1|F|D, {0x1e7f}}},
+ {0x1e80, {1|F|D, {0x1e81}}},
+ {0x1e82, {1|F|D, {0x1e83}}},
+ {0x1e84, {1|F|D, {0x1e85}}},
+ {0x1e86, {1|F|D, {0x1e87}}},
+ {0x1e88, {1|F|D, {0x1e89}}},
+ {0x1e8a, {1|F|D, {0x1e8b}}},
+ {0x1e8c, {1|F|D, {0x1e8d}}},
+ {0x1e8e, {1|F|D, {0x1e8f}}},
+ {0x1e90, {1|F|D, {0x1e91}}},
+ {0x1e92, {1|F|D, {0x1e93}}},
+ {0x1e94, {1|F|D, {0x1e95}}},
+ {0x1e96, {2|F|SU|I(54), {0x0068, 0x0331}}},
+ {0x1e97, {2|F|SU|I(56), {0x0074, 0x0308}}},
+ {0x1e98, {2|F|SU|I(58), {0x0077, 0x030a}}},
+ {0x1e99, {2|F|SU|I(60), {0x0079, 0x030a}}},
+ {0x1e9a, {2|F|SU|I(62), {0x0061, 0x02be}}},
+ {0x1e9b, {1|F|SU|I(64), {0x1e61}}},
+ {0x1e9e, {2|F|SL|I(65), {0x0073, 0x0073}}},
+ {0x1ea0, {1|F|D, {0x1ea1}}},
+ {0x1ea2, {1|F|D, {0x1ea3}}},
+ {0x1ea4, {1|F|D, {0x1ea5}}},
+ {0x1ea6, {1|F|D, {0x1ea7}}},
+ {0x1ea8, {1|F|D, {0x1ea9}}},
+ {0x1eaa, {1|F|D, {0x1eab}}},
+ {0x1eac, {1|F|D, {0x1ead}}},
+ {0x1eae, {1|F|D, {0x1eaf}}},
+ {0x1eb0, {1|F|D, {0x1eb1}}},
+ {0x1eb2, {1|F|D, {0x1eb3}}},
+ {0x1eb4, {1|F|D, {0x1eb5}}},
+ {0x1eb6, {1|F|D, {0x1eb7}}},
+ {0x1eb8, {1|F|D, {0x1eb9}}},
+ {0x1eba, {1|F|D, {0x1ebb}}},
+ {0x1ebc, {1|F|D, {0x1ebd}}},
+ {0x1ebe, {1|F|D, {0x1ebf}}},
+ {0x1ec0, {1|F|D, {0x1ec1}}},
+ {0x1ec2, {1|F|D, {0x1ec3}}},
+ {0x1ec4, {1|F|D, {0x1ec5}}},
+ {0x1ec6, {1|F|D, {0x1ec7}}},
+ {0x1ec8, {1|F|D, {0x1ec9}}},
+ {0x1eca, {1|F|D, {0x1ecb}}},
+ {0x1ecc, {1|F|D, {0x1ecd}}},
+ {0x1ece, {1|F|D, {0x1ecf}}},
+ {0x1ed0, {1|F|D, {0x1ed1}}},
+ {0x1ed2, {1|F|D, {0x1ed3}}},
+ {0x1ed4, {1|F|D, {0x1ed5}}},
+ {0x1ed6, {1|F|D, {0x1ed7}}},
+ {0x1ed8, {1|F|D, {0x1ed9}}},
+ {0x1eda, {1|F|D, {0x1edb}}},
+ {0x1edc, {1|F|D, {0x1edd}}},
+ {0x1ede, {1|F|D, {0x1edf}}},
+ {0x1ee0, {1|F|D, {0x1ee1}}},
+ {0x1ee2, {1|F|D, {0x1ee3}}},
+ {0x1ee4, {1|F|D, {0x1ee5}}},
+ {0x1ee6, {1|F|D, {0x1ee7}}},
+ {0x1ee8, {1|F|D, {0x1ee9}}},
+ {0x1eea, {1|F|D, {0x1eeb}}},
+ {0x1eec, {1|F|D, {0x1eed}}},
+ {0x1eee, {1|F|D, {0x1eef}}},
+ {0x1ef0, {1|F|D, {0x1ef1}}},
+ {0x1ef2, {1|F|D, {0x1ef3}}},
+ {0x1ef4, {1|F|D, {0x1ef5}}},
+ {0x1ef6, {1|F|D, {0x1ef7}}},
+ {0x1ef8, {1|F|D, {0x1ef9}}},
+ {0x1efa, {1|F|D, {0x1efb}}},
+ {0x1efc, {1|F|D, {0x1efd}}},
+ {0x1efe, {1|F|D, {0x1eff}}},
+ {0x1f08, {1|F|D, {0x1f00}}},
+ {0x1f09, {1|F|D, {0x1f01}}},
+ {0x1f0a, {1|F|D, {0x1f02}}},
+ {0x1f0b, {1|F|D, {0x1f03}}},
+ {0x1f0c, {1|F|D, {0x1f04}}},
+ {0x1f0d, {1|F|D, {0x1f05}}},
+ {0x1f0e, {1|F|D, {0x1f06}}},
+ {0x1f0f, {1|F|D, {0x1f07}}},
+ {0x1f18, {1|F|D, {0x1f10}}},
+ {0x1f19, {1|F|D, {0x1f11}}},
+ {0x1f1a, {1|F|D, {0x1f12}}},
+ {0x1f1b, {1|F|D, {0x1f13}}},
+ {0x1f1c, {1|F|D, {0x1f14}}},
+ {0x1f1d, {1|F|D, {0x1f15}}},
+ {0x1f28, {1|F|D, {0x1f20}}},
+ {0x1f29, {1|F|D, {0x1f21}}},
+ {0x1f2a, {1|F|D, {0x1f22}}},
+ {0x1f2b, {1|F|D, {0x1f23}}},
+ {0x1f2c, {1|F|D, {0x1f24}}},
+ {0x1f2d, {1|F|D, {0x1f25}}},
+ {0x1f2e, {1|F|D, {0x1f26}}},
+ {0x1f2f, {1|F|D, {0x1f27}}},
+ {0x1f38, {1|F|D, {0x1f30}}},
+ {0x1f39, {1|F|D, {0x1f31}}},
+ {0x1f3a, {1|F|D, {0x1f32}}},
+ {0x1f3b, {1|F|D, {0x1f33}}},
+ {0x1f3c, {1|F|D, {0x1f34}}},
+ {0x1f3d, {1|F|D, {0x1f35}}},
+ {0x1f3e, {1|F|D, {0x1f36}}},
+ {0x1f3f, {1|F|D, {0x1f37}}},
+ {0x1f48, {1|F|D, {0x1f40}}},
+ {0x1f49, {1|F|D, {0x1f41}}},
+ {0x1f4a, {1|F|D, {0x1f42}}},
+ {0x1f4b, {1|F|D, {0x1f43}}},
+ {0x1f4c, {1|F|D, {0x1f44}}},
+ {0x1f4d, {1|F|D, {0x1f45}}},
+ {0x1f50, {2|F|SU|I(66), {0x03c5, 0x0313}}},
+ {0x1f52, {3|F|SU|I(68), {0x03c5, 0x0313, 0x0300}}},
+ {0x1f54, {3|F|SU|I(71), {0x03c5, 0x0313, 0x0301}}},
+ {0x1f56, {3|F|SU|I(74), {0x03c5, 0x0313, 0x0342}}},
+ {0x1f59, {1|F|D, {0x1f51}}},
+ {0x1f5b, {1|F|D, {0x1f53}}},
+ {0x1f5d, {1|F|D, {0x1f55}}},
+ {0x1f5f, {1|F|D, {0x1f57}}},
+ {0x1f68, {1|F|D, {0x1f60}}},
+ {0x1f69, {1|F|D, {0x1f61}}},
+ {0x1f6a, {1|F|D, {0x1f62}}},
+ {0x1f6b, {1|F|D, {0x1f63}}},
+ {0x1f6c, {1|F|D, {0x1f64}}},
+ {0x1f6d, {1|F|D, {0x1f65}}},
+ {0x1f6e, {1|F|D, {0x1f66}}},
+ {0x1f6f, {1|F|D, {0x1f67}}},
+ {0x1f80, {2|F|ST|SU|I(77), {0x1f00, 0x03b9}}},
+ {0x1f81, {2|F|ST|SU|I(80), {0x1f01, 0x03b9}}},
+ {0x1f82, {2|F|ST|SU|I(83), {0x1f02, 0x03b9}}},
+ {0x1f83, {2|F|ST|SU|I(86), {0x1f03, 0x03b9}}},
+ {0x1f84, {2|F|ST|SU|I(89), {0x1f04, 0x03b9}}},
+ {0x1f85, {2|F|ST|SU|I(92), {0x1f05, 0x03b9}}},
+ {0x1f86, {2|F|ST|SU|I(95), {0x1f06, 0x03b9}}},
+ {0x1f87, {2|F|ST|SU|I(98), {0x1f07, 0x03b9}}},
+ {0x1f88, {2|F|IT|SL|SU|I(101), {0x1f00, 0x03b9}}},
+ {0x1f89, {2|F|IT|SL|SU|I(106), {0x1f01, 0x03b9}}},
+ {0x1f8a, {2|F|IT|SL|SU|I(111), {0x1f02, 0x03b9}}},
+ {0x1f8b, {2|F|IT|SL|SU|I(116), {0x1f03, 0x03b9}}},
+ {0x1f8c, {2|F|IT|SL|SU|I(121), {0x1f04, 0x03b9}}},
+ {0x1f8d, {2|F|IT|SL|SU|I(126), {0x1f05, 0x03b9}}},
+ {0x1f8e, {2|F|IT|SL|SU|I(131), {0x1f06, 0x03b9}}},
+ {0x1f8f, {2|F|IT|SL|SU|I(136), {0x1f07, 0x03b9}}},
+ {0x1f90, {2|F|ST|SU|I(141), {0x1f20, 0x03b9}}},
+ {0x1f91, {2|F|ST|SU|I(144), {0x1f21, 0x03b9}}},
+ {0x1f92, {2|F|ST|SU|I(147), {0x1f22, 0x03b9}}},
+ {0x1f93, {2|F|ST|SU|I(150), {0x1f23, 0x03b9}}},
+ {0x1f94, {2|F|ST|SU|I(153), {0x1f24, 0x03b9}}},
+ {0x1f95, {2|F|ST|SU|I(156), {0x1f25, 0x03b9}}},
+ {0x1f96, {2|F|ST|SU|I(159), {0x1f26, 0x03b9}}},
+ {0x1f97, {2|F|ST|SU|I(162), {0x1f27, 0x03b9}}},
+ {0x1f98, {2|F|IT|SL|SU|I(165), {0x1f20, 0x03b9}}},
+ {0x1f99, {2|F|IT|SL|SU|I(170), {0x1f21, 0x03b9}}},
+ {0x1f9a, {2|F|IT|SL|SU|I(175), {0x1f22, 0x03b9}}},
+ {0x1f9b, {2|F|IT|SL|SU|I(180), {0x1f23, 0x03b9}}},
+ {0x1f9c, {2|F|IT|SL|SU|I(185), {0x1f24, 0x03b9}}},
+ {0x1f9d, {2|F|IT|SL|SU|I(190), {0x1f25, 0x03b9}}},
+ {0x1f9e, {2|F|IT|SL|SU|I(195), {0x1f26, 0x03b9}}},
+ {0x1f9f, {2|F|IT|SL|SU|I(200), {0x1f27, 0x03b9}}},
+ {0x1fa0, {2|F|ST|SU|I(205), {0x1f60, 0x03b9}}},
+ {0x1fa1, {2|F|ST|SU|I(208), {0x1f61, 0x03b9}}},
+ {0x1fa2, {2|F|ST|SU|I(211), {0x1f62, 0x03b9}}},
+ {0x1fa3, {2|F|ST|SU|I(214), {0x1f63, 0x03b9}}},
+ {0x1fa4, {2|F|ST|SU|I(217), {0x1f64, 0x03b9}}},
+ {0x1fa5, {2|F|ST|SU|I(220), {0x1f65, 0x03b9}}},
+ {0x1fa6, {2|F|ST|SU|I(223), {0x1f66, 0x03b9}}},
+ {0x1fa7, {2|F|ST|SU|I(226), {0x1f67, 0x03b9}}},
+ {0x1fa8, {2|F|IT|SL|SU|I(229), {0x1f60, 0x03b9}}},
+ {0x1fa9, {2|F|IT|SL|SU|I(234), {0x1f61, 0x03b9}}},
+ {0x1faa, {2|F|IT|SL|SU|I(239), {0x1f62, 0x03b9}}},
+ {0x1fab, {2|F|IT|SL|SU|I(244), {0x1f63, 0x03b9}}},
+ {0x1fac, {2|F|IT|SL|SU|I(249), {0x1f64, 0x03b9}}},
+ {0x1fad, {2|F|IT|SL|SU|I(254), {0x1f65, 0x03b9}}},
+ {0x1fae, {2|F|IT|SL|SU|I(259), {0x1f66, 0x03b9}}},
+ {0x1faf, {2|F|IT|SL|SU|I(264), {0x1f67, 0x03b9}}},
+ {0x1fb2, {2|F|ST|SU|I(269), {0x1f70, 0x03b9}}},
+ {0x1fb3, {2|F|ST|SU|I(273), {0x03b1, 0x03b9}}},
+ {0x1fb4, {2|F|ST|SU|I(276), {0x03ac, 0x03b9}}},
+ {0x1fb6, {2|F|SU|I(280), {0x03b1, 0x0342}}},
+ {0x1fb7, {3|F|ST|SU|I(282), {0x03b1, 0x0342, 0x03b9}}},
+ {0x1fb8, {1|F|D, {0x1fb0}}},
+ {0x1fb9, {1|F|D, {0x1fb1}}},
+ {0x1fba, {1|F|D, {0x1f70}}},
+ {0x1fbb, {1|F|D, {0x1f71}}},
+ {0x1fbc, {2|F|IT|SL|SU|I(288), {0x03b1, 0x03b9}}},
+ {0x1fbe, {1|F|SU|I(293), {0x03b9}}},
+ {0x1fc2, {2|F|ST|SU|I(294), {0x1f74, 0x03b9}}},
+ {0x1fc3, {2|F|ST|SU|I(298), {0x03b7, 0x03b9}}},
+ {0x1fc4, {2|F|ST|SU|I(301), {0x03ae, 0x03b9}}},
+ {0x1fc6, {2|F|SU|I(305), {0x03b7, 0x0342}}},
+ {0x1fc7, {3|F|ST|SU|I(307), {0x03b7, 0x0342, 0x03b9}}},
+ {0x1fc8, {1|F|D, {0x1f72}}},
+ {0x1fc9, {1|F|D, {0x1f73}}},
+ {0x1fca, {1|F|D, {0x1f74}}},
+ {0x1fcb, {1|F|D, {0x1f75}}},
+ {0x1fcc, {2|F|IT|SL|SU|I(313), {0x03b7, 0x03b9}}},
+ {0x1fd2, {3|F|SU|I(318), {0x03b9, 0x0308, 0x0300}}},
+ {0x1fd3, {3|F|SU|I(321), {0x03b9, 0x0308, 0x0301}}},
+ {0x1fd6, {2|F|SU|I(324), {0x03b9, 0x0342}}},
+ {0x1fd7, {3|F|SU|I(326), {0x03b9, 0x0308, 0x0342}}},
+ {0x1fd8, {1|F|D, {0x1fd0}}},
+ {0x1fd9, {1|F|D, {0x1fd1}}},
+ {0x1fda, {1|F|D, {0x1f76}}},
+ {0x1fdb, {1|F|D, {0x1f77}}},
+ {0x1fe2, {3|F|SU|I(329), {0x03c5, 0x0308, 0x0300}}},
+ {0x1fe3, {3|F|SU|I(332), {0x03c5, 0x0308, 0x0301}}},
+ {0x1fe4, {2|F|SU|I(335), {0x03c1, 0x0313}}},
+ {0x1fe6, {2|F|SU|I(337), {0x03c5, 0x0342}}},
+ {0x1fe7, {3|F|SU|I(339), {0x03c5, 0x0308, 0x0342}}},
+ {0x1fe8, {1|F|D, {0x1fe0}}},
+ {0x1fe9, {1|F|D, {0x1fe1}}},
+ {0x1fea, {1|F|D, {0x1f7a}}},
+ {0x1feb, {1|F|D, {0x1f7b}}},
+ {0x1fec, {1|F|D, {0x1fe5}}},
+ {0x1ff2, {2|F|ST|SU|I(342), {0x1f7c, 0x03b9}}},
+ {0x1ff3, {2|F|ST|SU|I(346), {0x03c9, 0x03b9}}},
+ {0x1ff4, {2|F|ST|SU|I(349), {0x03ce, 0x03b9}}},
+ {0x1ff6, {2|F|SU|I(353), {0x03c9, 0x0342}}},
+ {0x1ff7, {3|F|ST|SU|I(355), {0x03c9, 0x0342, 0x03b9}}},
+ {0x1ff8, {1|F|D, {0x1f78}}},
+ {0x1ff9, {1|F|D, {0x1f79}}},
+ {0x1ffa, {1|F|D, {0x1f7c}}},
+ {0x1ffb, {1|F|D, {0x1f7d}}},
+ {0x1ffc, {2|F|IT|SL|SU|I(361), {0x03c9, 0x03b9}}},
+ {0x2126, {1|F|D, {0x03c9}}},
+ {0x212a, {1|F|D, {0x006b}}},
+ {0x212b, {1|F|D, {0x00e5}}},
+ {0x2132, {1|F|D, {0x214e}}},
+ {0x2160, {1|F|D, {0x2170}}},
+ {0x2161, {1|F|D, {0x2171}}},
+ {0x2162, {1|F|D, {0x2172}}},
+ {0x2163, {1|F|D, {0x2173}}},
+ {0x2164, {1|F|D, {0x2174}}},
+ {0x2165, {1|F|D, {0x2175}}},
+ {0x2166, {1|F|D, {0x2176}}},
+ {0x2167, {1|F|D, {0x2177}}},
+ {0x2168, {1|F|D, {0x2178}}},
+ {0x2169, {1|F|D, {0x2179}}},
+ {0x216a, {1|F|D, {0x217a}}},
+ {0x216b, {1|F|D, {0x217b}}},
+ {0x216c, {1|F|D, {0x217c}}},
+ {0x216d, {1|F|D, {0x217d}}},
+ {0x216e, {1|F|D, {0x217e}}},
+ {0x216f, {1|F|D, {0x217f}}},
+ {0x2183, {1|F|D, {0x2184}}},
+ {0x24b6, {1|F|D, {0x24d0}}},
+ {0x24b7, {1|F|D, {0x24d1}}},
+ {0x24b8, {1|F|D, {0x24d2}}},
+ {0x24b9, {1|F|D, {0x24d3}}},
+ {0x24ba, {1|F|D, {0x24d4}}},
+ {0x24bb, {1|F|D, {0x24d5}}},
+ {0x24bc, {1|F|D, {0x24d6}}},
+ {0x24bd, {1|F|D, {0x24d7}}},
+ {0x24be, {1|F|D, {0x24d8}}},
+ {0x24bf, {1|F|D, {0x24d9}}},
+ {0x24c0, {1|F|D, {0x24da}}},
+ {0x24c1, {1|F|D, {0x24db}}},
+ {0x24c2, {1|F|D, {0x24dc}}},
+ {0x24c3, {1|F|D, {0x24dd}}},
+ {0x24c4, {1|F|D, {0x24de}}},
+ {0x24c5, {1|F|D, {0x24df}}},
+ {0x24c6, {1|F|D, {0x24e0}}},
+ {0x24c7, {1|F|D, {0x24e1}}},
+ {0x24c8, {1|F|D, {0x24e2}}},
+ {0x24c9, {1|F|D, {0x24e3}}},
+ {0x24ca, {1|F|D, {0x24e4}}},
+ {0x24cb, {1|F|D, {0x24e5}}},
+ {0x24cc, {1|F|D, {0x24e6}}},
+ {0x24cd, {1|F|D, {0x24e7}}},
+ {0x24ce, {1|F|D, {0x24e8}}},
+ {0x24cf, {1|F|D, {0x24e9}}},
+ {0x2c00, {1|F|D, {0x2c30}}},
+ {0x2c01, {1|F|D, {0x2c31}}},
+ {0x2c02, {1|F|D, {0x2c32}}},
+ {0x2c03, {1|F|D, {0x2c33}}},
+ {0x2c04, {1|F|D, {0x2c34}}},
+ {0x2c05, {1|F|D, {0x2c35}}},
+ {0x2c06, {1|F|D, {0x2c36}}},
+ {0x2c07, {1|F|D, {0x2c37}}},
+ {0x2c08, {1|F|D, {0x2c38}}},
+ {0x2c09, {1|F|D, {0x2c39}}},
+ {0x2c0a, {1|F|D, {0x2c3a}}},
+ {0x2c0b, {1|F|D, {0x2c3b}}},
+ {0x2c0c, {1|F|D, {0x2c3c}}},
+ {0x2c0d, {1|F|D, {0x2c3d}}},
+ {0x2c0e, {1|F|D, {0x2c3e}}},
+ {0x2c0f, {1|F|D, {0x2c3f}}},
+ {0x2c10, {1|F|D, {0x2c40}}},
+ {0x2c11, {1|F|D, {0x2c41}}},
+ {0x2c12, {1|F|D, {0x2c42}}},
+ {0x2c13, {1|F|D, {0x2c43}}},
+ {0x2c14, {1|F|D, {0x2c44}}},
+ {0x2c15, {1|F|D, {0x2c45}}},
+ {0x2c16, {1|F|D, {0x2c46}}},
+ {0x2c17, {1|F|D, {0x2c47}}},
+ {0x2c18, {1|F|D, {0x2c48}}},
+ {0x2c19, {1|F|D, {0x2c49}}},
+ {0x2c1a, {1|F|D, {0x2c4a}}},
+ {0x2c1b, {1|F|D, {0x2c4b}}},
+ {0x2c1c, {1|F|D, {0x2c4c}}},
+ {0x2c1d, {1|F|D, {0x2c4d}}},
+ {0x2c1e, {1|F|D, {0x2c4e}}},
+ {0x2c1f, {1|F|D, {0x2c4f}}},
+ {0x2c20, {1|F|D, {0x2c50}}},
+ {0x2c21, {1|F|D, {0x2c51}}},
+ {0x2c22, {1|F|D, {0x2c52}}},
+ {0x2c23, {1|F|D, {0x2c53}}},
+ {0x2c24, {1|F|D, {0x2c54}}},
+ {0x2c25, {1|F|D, {0x2c55}}},
+ {0x2c26, {1|F|D, {0x2c56}}},
+ {0x2c27, {1|F|D, {0x2c57}}},
+ {0x2c28, {1|F|D, {0x2c58}}},
+ {0x2c29, {1|F|D, {0x2c59}}},
+ {0x2c2a, {1|F|D, {0x2c5a}}},
+ {0x2c2b, {1|F|D, {0x2c5b}}},
+ {0x2c2c, {1|F|D, {0x2c5c}}},
+ {0x2c2d, {1|F|D, {0x2c5d}}},
+ {0x2c2e, {1|F|D, {0x2c5e}}},
+ {0x2c60, {1|F|D, {0x2c61}}},
+ {0x2c62, {1|F|D, {0x026b}}},
+ {0x2c63, {1|F|D, {0x1d7d}}},
+ {0x2c64, {1|F|D, {0x027d}}},
+ {0x2c67, {1|F|D, {0x2c68}}},
+ {0x2c69, {1|F|D, {0x2c6a}}},
+ {0x2c6b, {1|F|D, {0x2c6c}}},
+ {0x2c6d, {1|F|D, {0x0251}}},
+ {0x2c6e, {1|F|D, {0x0271}}},
+ {0x2c6f, {1|F|D, {0x0250}}},
+ {0x2c70, {1|F|D, {0x0252}}},
+ {0x2c72, {1|F|D, {0x2c73}}},
+ {0x2c75, {1|F|D, {0x2c76}}},
+ {0x2c7e, {1|F|D, {0x023f}}},
+ {0x2c7f, {1|F|D, {0x0240}}},
+ {0x2c80, {1|F|D, {0x2c81}}},
+ {0x2c82, {1|F|D, {0x2c83}}},
+ {0x2c84, {1|F|D, {0x2c85}}},
+ {0x2c86, {1|F|D, {0x2c87}}},
+ {0x2c88, {1|F|D, {0x2c89}}},
+ {0x2c8a, {1|F|D, {0x2c8b}}},
+ {0x2c8c, {1|F|D, {0x2c8d}}},
+ {0x2c8e, {1|F|D, {0x2c8f}}},
+ {0x2c90, {1|F|D, {0x2c91}}},
+ {0x2c92, {1|F|D, {0x2c93}}},
+ {0x2c94, {1|F|D, {0x2c95}}},
+ {0x2c96, {1|F|D, {0x2c97}}},
+ {0x2c98, {1|F|D, {0x2c99}}},
+ {0x2c9a, {1|F|D, {0x2c9b}}},
+ {0x2c9c, {1|F|D, {0x2c9d}}},
+ {0x2c9e, {1|F|D, {0x2c9f}}},
+ {0x2ca0, {1|F|D, {0x2ca1}}},
+ {0x2ca2, {1|F|D, {0x2ca3}}},
+ {0x2ca4, {1|F|D, {0x2ca5}}},
+ {0x2ca6, {1|F|D, {0x2ca7}}},
+ {0x2ca8, {1|F|D, {0x2ca9}}},
+ {0x2caa, {1|F|D, {0x2cab}}},
+ {0x2cac, {1|F|D, {0x2cad}}},
+ {0x2cae, {1|F|D, {0x2caf}}},
+ {0x2cb0, {1|F|D, {0x2cb1}}},
+ {0x2cb2, {1|F|D, {0x2cb3}}},
+ {0x2cb4, {1|F|D, {0x2cb5}}},
+ {0x2cb6, {1|F|D, {0x2cb7}}},
+ {0x2cb8, {1|F|D, {0x2cb9}}},
+ {0x2cba, {1|F|D, {0x2cbb}}},
+ {0x2cbc, {1|F|D, {0x2cbd}}},
+ {0x2cbe, {1|F|D, {0x2cbf}}},
+ {0x2cc0, {1|F|D, {0x2cc1}}},
+ {0x2cc2, {1|F|D, {0x2cc3}}},
+ {0x2cc4, {1|F|D, {0x2cc5}}},
+ {0x2cc6, {1|F|D, {0x2cc7}}},
+ {0x2cc8, {1|F|D, {0x2cc9}}},
+ {0x2cca, {1|F|D, {0x2ccb}}},
+ {0x2ccc, {1|F|D, {0x2ccd}}},
+ {0x2cce, {1|F|D, {0x2ccf}}},
+ {0x2cd0, {1|F|D, {0x2cd1}}},
+ {0x2cd2, {1|F|D, {0x2cd3}}},
+ {0x2cd4, {1|F|D, {0x2cd5}}},
+ {0x2cd6, {1|F|D, {0x2cd7}}},
+ {0x2cd8, {1|F|D, {0x2cd9}}},
+ {0x2cda, {1|F|D, {0x2cdb}}},
+ {0x2cdc, {1|F|D, {0x2cdd}}},
+ {0x2cde, {1|F|D, {0x2cdf}}},
+ {0x2ce0, {1|F|D, {0x2ce1}}},
+ {0x2ce2, {1|F|D, {0x2ce3}}},
+ {0x2ceb, {1|F|D, {0x2cec}}},
+ {0x2ced, {1|F|D, {0x2cee}}},
+ {0x2cf2, {1|F|D, {0x2cf3}}},
+ {0xa640, {1|F|D, {0xa641}}},
+ {0xa642, {1|F|D, {0xa643}}},
+ {0xa644, {1|F|D, {0xa645}}},
+ {0xa646, {1|F|D, {0xa647}}},
+ {0xa648, {1|F|D, {0xa649}}},
+ {0xa64a, {1|F|D, {0xa64b}}},
+ {0xa64c, {1|F|D, {0xa64d}}},
+ {0xa64e, {1|F|D, {0xa64f}}},
+ {0xa650, {1|F|D, {0xa651}}},
+ {0xa652, {1|F|D, {0xa653}}},
+ {0xa654, {1|F|D, {0xa655}}},
+ {0xa656, {1|F|D, {0xa657}}},
+ {0xa658, {1|F|D, {0xa659}}},
+ {0xa65a, {1|F|D, {0xa65b}}},
+ {0xa65c, {1|F|D, {0xa65d}}},
+ {0xa65e, {1|F|D, {0xa65f}}},
+ {0xa660, {1|F|D, {0xa661}}},
+ {0xa662, {1|F|D, {0xa663}}},
+ {0xa664, {1|F|D, {0xa665}}},
+ {0xa666, {1|F|D, {0xa667}}},
+ {0xa668, {1|F|D, {0xa669}}},
+ {0xa66a, {1|F|D, {0xa66b}}},
+ {0xa66c, {1|F|D, {0xa66d}}},
+ {0xa680, {1|F|D, {0xa681}}},
+ {0xa682, {1|F|D, {0xa683}}},
+ {0xa684, {1|F|D, {0xa685}}},
+ {0xa686, {1|F|D, {0xa687}}},
+ {0xa688, {1|F|D, {0xa689}}},
+ {0xa68a, {1|F|D, {0xa68b}}},
+ {0xa68c, {1|F|D, {0xa68d}}},
+ {0xa68e, {1|F|D, {0xa68f}}},
+ {0xa690, {1|F|D, {0xa691}}},
+ {0xa692, {1|F|D, {0xa693}}},
+ {0xa694, {1|F|D, {0xa695}}},
+ {0xa696, {1|F|D, {0xa697}}},
+ {0xa698, {1|F|D, {0xa699}}},
+ {0xa69a, {1|F|D, {0xa69b}}},
+ {0xa722, {1|F|D, {0xa723}}},
+ {0xa724, {1|F|D, {0xa725}}},
+ {0xa726, {1|F|D, {0xa727}}},
+ {0xa728, {1|F|D, {0xa729}}},
+ {0xa72a, {1|F|D, {0xa72b}}},
+ {0xa72c, {1|F|D, {0xa72d}}},
+ {0xa72e, {1|F|D, {0xa72f}}},
+ {0xa732, {1|F|D, {0xa733}}},
+ {0xa734, {1|F|D, {0xa735}}},
+ {0xa736, {1|F|D, {0xa737}}},
+ {0xa738, {1|F|D, {0xa739}}},
+ {0xa73a, {1|F|D, {0xa73b}}},
+ {0xa73c, {1|F|D, {0xa73d}}},
+ {0xa73e, {1|F|D, {0xa73f}}},
+ {0xa740, {1|F|D, {0xa741}}},
+ {0xa742, {1|F|D, {0xa743}}},
+ {0xa744, {1|F|D, {0xa745}}},
+ {0xa746, {1|F|D, {0xa747}}},
+ {0xa748, {1|F|D, {0xa749}}},
+ {0xa74a, {1|F|D, {0xa74b}}},
+ {0xa74c, {1|F|D, {0xa74d}}},
+ {0xa74e, {1|F|D, {0xa74f}}},
+ {0xa750, {1|F|D, {0xa751}}},
+ {0xa752, {1|F|D, {0xa753}}},
+ {0xa754, {1|F|D, {0xa755}}},
+ {0xa756, {1|F|D, {0xa757}}},
+ {0xa758, {1|F|D, {0xa759}}},
+ {0xa75a, {1|F|D, {0xa75b}}},
+ {0xa75c, {1|F|D, {0xa75d}}},
+ {0xa75e, {1|F|D, {0xa75f}}},
+ {0xa760, {1|F|D, {0xa761}}},
+ {0xa762, {1|F|D, {0xa763}}},
+ {0xa764, {1|F|D, {0xa765}}},
+ {0xa766, {1|F|D, {0xa767}}},
+ {0xa768, {1|F|D, {0xa769}}},
+ {0xa76a, {1|F|D, {0xa76b}}},
+ {0xa76c, {1|F|D, {0xa76d}}},
+ {0xa76e, {1|F|D, {0xa76f}}},
+ {0xa779, {1|F|D, {0xa77a}}},
+ {0xa77b, {1|F|D, {0xa77c}}},
+ {0xa77d, {1|F|D, {0x1d79}}},
+ {0xa77e, {1|F|D, {0xa77f}}},
+ {0xa780, {1|F|D, {0xa781}}},
+ {0xa782, {1|F|D, {0xa783}}},
+ {0xa784, {1|F|D, {0xa785}}},
+ {0xa786, {1|F|D, {0xa787}}},
+ {0xa78b, {1|F|D, {0xa78c}}},
+ {0xa78d, {1|F|D, {0x0265}}},
+ {0xa790, {1|F|D, {0xa791}}},
+ {0xa792, {1|F|D, {0xa793}}},
+ {0xa796, {1|F|D, {0xa797}}},
+ {0xa798, {1|F|D, {0xa799}}},
+ {0xa79a, {1|F|D, {0xa79b}}},
+ {0xa79c, {1|F|D, {0xa79d}}},
+ {0xa79e, {1|F|D, {0xa79f}}},
+ {0xa7a0, {1|F|D, {0xa7a1}}},
+ {0xa7a2, {1|F|D, {0xa7a3}}},
+ {0xa7a4, {1|F|D, {0xa7a5}}},
+ {0xa7a6, {1|F|D, {0xa7a7}}},
+ {0xa7a8, {1|F|D, {0xa7a9}}},
+ {0xa7aa, {1|F|D, {0x0266}}},
+ {0xa7ab, {1|F|D, {0x025c}}},
+ {0xa7ac, {1|F|D, {0x0261}}},
+ {0xa7ad, {1|F|D, {0x026c}}},
+ {0xa7ae, {1|F|D, {0x026a}}},
+ {0xa7b0, {1|F|D, {0x029e}}},
+ {0xa7b1, {1|F|D, {0x0287}}},
+ {0xa7b2, {1|F|D, {0x029d}}},
+ {0xa7b3, {1|F|D, {0xab53}}},
+ {0xa7b4, {1|F|D, {0xa7b5}}},
+ {0xa7b6, {1|F|D, {0xa7b7}}},
+ {0xab70, {1|F|U, {0x13a0}}},
+ {0xab71, {1|F|U, {0x13a1}}},
+ {0xab72, {1|F|U, {0x13a2}}},
+ {0xab73, {1|F|U, {0x13a3}}},
+ {0xab74, {1|F|U, {0x13a4}}},
+ {0xab75, {1|F|U, {0x13a5}}},
+ {0xab76, {1|F|U, {0x13a6}}},
+ {0xab77, {1|F|U, {0x13a7}}},
+ {0xab78, {1|F|U, {0x13a8}}},
+ {0xab79, {1|F|U, {0x13a9}}},
+ {0xab7a, {1|F|U, {0x13aa}}},
+ {0xab7b, {1|F|U, {0x13ab}}},
+ {0xab7c, {1|F|U, {0x13ac}}},
+ {0xab7d, {1|F|U, {0x13ad}}},
+ {0xab7e, {1|F|U, {0x13ae}}},
+ {0xab7f, {1|F|U, {0x13af}}},
+ {0xab80, {1|F|U, {0x13b0}}},
+ {0xab81, {1|F|U, {0x13b1}}},
+ {0xab82, {1|F|U, {0x13b2}}},
+ {0xab83, {1|F|U, {0x13b3}}},
+ {0xab84, {1|F|U, {0x13b4}}},
+ {0xab85, {1|F|U, {0x13b5}}},
+ {0xab86, {1|F|U, {0x13b6}}},
+ {0xab87, {1|F|U, {0x13b7}}},
+ {0xab88, {1|F|U, {0x13b8}}},
+ {0xab89, {1|F|U, {0x13b9}}},
+ {0xab8a, {1|F|U, {0x13ba}}},
+ {0xab8b, {1|F|U, {0x13bb}}},
+ {0xab8c, {1|F|U, {0x13bc}}},
+ {0xab8d, {1|F|U, {0x13bd}}},
+ {0xab8e, {1|F|U, {0x13be}}},
+ {0xab8f, {1|F|U, {0x13bf}}},
+ {0xab90, {1|F|U, {0x13c0}}},
+ {0xab91, {1|F|U, {0x13c1}}},
+ {0xab92, {1|F|U, {0x13c2}}},
+ {0xab93, {1|F|U, {0x13c3}}},
+ {0xab94, {1|F|U, {0x13c4}}},
+ {0xab95, {1|F|U, {0x13c5}}},
+ {0xab96, {1|F|U, {0x13c6}}},
+ {0xab97, {1|F|U, {0x13c7}}},
+ {0xab98, {1|F|U, {0x13c8}}},
+ {0xab99, {1|F|U, {0x13c9}}},
+ {0xab9a, {1|F|U, {0x13ca}}},
+ {0xab9b, {1|F|U, {0x13cb}}},
+ {0xab9c, {1|F|U, {0x13cc}}},
+ {0xab9d, {1|F|U, {0x13cd}}},
+ {0xab9e, {1|F|U, {0x13ce}}},
+ {0xab9f, {1|F|U, {0x13cf}}},
+ {0xaba0, {1|F|U, {0x13d0}}},
+ {0xaba1, {1|F|U, {0x13d1}}},
+ {0xaba2, {1|F|U, {0x13d2}}},
+ {0xaba3, {1|F|U, {0x13d3}}},
+ {0xaba4, {1|F|U, {0x13d4}}},
+ {0xaba5, {1|F|U, {0x13d5}}},
+ {0xaba6, {1|F|U, {0x13d6}}},
+ {0xaba7, {1|F|U, {0x13d7}}},
+ {0xaba8, {1|F|U, {0x13d8}}},
+ {0xaba9, {1|F|U, {0x13d9}}},
+ {0xabaa, {1|F|U, {0x13da}}},
+ {0xabab, {1|F|U, {0x13db}}},
+ {0xabac, {1|F|U, {0x13dc}}},
+ {0xabad, {1|F|U, {0x13dd}}},
+ {0xabae, {1|F|U, {0x13de}}},
+ {0xabaf, {1|F|U, {0x13df}}},
+ {0xabb0, {1|F|U, {0x13e0}}},
+ {0xabb1, {1|F|U, {0x13e1}}},
+ {0xabb2, {1|F|U, {0x13e2}}},
+ {0xabb3, {1|F|U, {0x13e3}}},
+ {0xabb4, {1|F|U, {0x13e4}}},
+ {0xabb5, {1|F|U, {0x13e5}}},
+ {0xabb6, {1|F|U, {0x13e6}}},
+ {0xabb7, {1|F|U, {0x13e7}}},
+ {0xabb8, {1|F|U, {0x13e8}}},
+ {0xabb9, {1|F|U, {0x13e9}}},
+ {0xabba, {1|F|U, {0x13ea}}},
+ {0xabbb, {1|F|U, {0x13eb}}},
+ {0xabbc, {1|F|U, {0x13ec}}},
+ {0xabbd, {1|F|U, {0x13ed}}},
+ {0xabbe, {1|F|U, {0x13ee}}},
+ {0xabbf, {1|F|U, {0x13ef}}},
+ {0xfb00, {2|F|ST|SU|I(366), {0x0066, 0x0066}}},
+ {0xfb01, {2|F|ST|SU|I(370), {0x0066, 0x0069}}},
+ {0xfb02, {2|F|ST|SU|I(374), {0x0066, 0x006c}}},
+ {0xfb03, {3|F|ST|SU|I(378), {0x0066, 0x0066, 0x0069}}},
+ {0xfb04, {3|F|ST|SU|I(384), {0x0066, 0x0066, 0x006c}}},
+ {0xfb05, {2|F|ST|SU|I(390), {0x0073, 0x0074}}},
+ {0xfb06, {2|F|ST|SU|I(394), {0x0073, 0x0074}}},
+ {0xfb13, {2|F|ST|SU|I(398), {0x0574, 0x0576}}},
+ {0xfb14, {2|F|ST|SU|I(402), {0x0574, 0x0565}}},
+ {0xfb15, {2|F|ST|SU|I(406), {0x0574, 0x056b}}},
+ {0xfb16, {2|F|ST|SU|I(410), {0x057e, 0x0576}}},
+ {0xfb17, {2|F|ST|SU|I(414), {0x0574, 0x056d}}},
+ {0xff21, {1|F|D, {0xff41}}},
+ {0xff22, {1|F|D, {0xff42}}},
+ {0xff23, {1|F|D, {0xff43}}},
+ {0xff24, {1|F|D, {0xff44}}},
+ {0xff25, {1|F|D, {0xff45}}},
+ {0xff26, {1|F|D, {0xff46}}},
+ {0xff27, {1|F|D, {0xff47}}},
+ {0xff28, {1|F|D, {0xff48}}},
+ {0xff29, {1|F|D, {0xff49}}},
+ {0xff2a, {1|F|D, {0xff4a}}},
+ {0xff2b, {1|F|D, {0xff4b}}},
+ {0xff2c, {1|F|D, {0xff4c}}},
+ {0xff2d, {1|F|D, {0xff4d}}},
+ {0xff2e, {1|F|D, {0xff4e}}},
+ {0xff2f, {1|F|D, {0xff4f}}},
+ {0xff30, {1|F|D, {0xff50}}},
+ {0xff31, {1|F|D, {0xff51}}},
+ {0xff32, {1|F|D, {0xff52}}},
+ {0xff33, {1|F|D, {0xff53}}},
+ {0xff34, {1|F|D, {0xff54}}},
+ {0xff35, {1|F|D, {0xff55}}},
+ {0xff36, {1|F|D, {0xff56}}},
+ {0xff37, {1|F|D, {0xff57}}},
+ {0xff38, {1|F|D, {0xff58}}},
+ {0xff39, {1|F|D, {0xff59}}},
+ {0xff3a, {1|F|D, {0xff5a}}},
+ {0x10400, {1|F|D, {0x10428}}},
+ {0x10401, {1|F|D, {0x10429}}},
+ {0x10402, {1|F|D, {0x1042a}}},
+ {0x10403, {1|F|D, {0x1042b}}},
+ {0x10404, {1|F|D, {0x1042c}}},
+ {0x10405, {1|F|D, {0x1042d}}},
+ {0x10406, {1|F|D, {0x1042e}}},
+ {0x10407, {1|F|D, {0x1042f}}},
+ {0x10408, {1|F|D, {0x10430}}},
+ {0x10409, {1|F|D, {0x10431}}},
+ {0x1040a, {1|F|D, {0x10432}}},
+ {0x1040b, {1|F|D, {0x10433}}},
+ {0x1040c, {1|F|D, {0x10434}}},
+ {0x1040d, {1|F|D, {0x10435}}},
+ {0x1040e, {1|F|D, {0x10436}}},
+ {0x1040f, {1|F|D, {0x10437}}},
+ {0x10410, {1|F|D, {0x10438}}},
+ {0x10411, {1|F|D, {0x10439}}},
+ {0x10412, {1|F|D, {0x1043a}}},
+ {0x10413, {1|F|D, {0x1043b}}},
+ {0x10414, {1|F|D, {0x1043c}}},
+ {0x10415, {1|F|D, {0x1043d}}},
+ {0x10416, {1|F|D, {0x1043e}}},
+ {0x10417, {1|F|D, {0x1043f}}},
+ {0x10418, {1|F|D, {0x10440}}},
+ {0x10419, {1|F|D, {0x10441}}},
+ {0x1041a, {1|F|D, {0x10442}}},
+ {0x1041b, {1|F|D, {0x10443}}},
+ {0x1041c, {1|F|D, {0x10444}}},
+ {0x1041d, {1|F|D, {0x10445}}},
+ {0x1041e, {1|F|D, {0x10446}}},
+ {0x1041f, {1|F|D, {0x10447}}},
+ {0x10420, {1|F|D, {0x10448}}},
+ {0x10421, {1|F|D, {0x10449}}},
+ {0x10422, {1|F|D, {0x1044a}}},
+ {0x10423, {1|F|D, {0x1044b}}},
+ {0x10424, {1|F|D, {0x1044c}}},
+ {0x10425, {1|F|D, {0x1044d}}},
+ {0x10426, {1|F|D, {0x1044e}}},
+ {0x10427, {1|F|D, {0x1044f}}},
+ {0x104b0, {1|F|D, {0x104d8}}},
+ {0x104b1, {1|F|D, {0x104d9}}},
+ {0x104b2, {1|F|D, {0x104da}}},
+ {0x104b3, {1|F|D, {0x104db}}},
+ {0x104b4, {1|F|D, {0x104dc}}},
+ {0x104b5, {1|F|D, {0x104dd}}},
+ {0x104b6, {1|F|D, {0x104de}}},
+ {0x104b7, {1|F|D, {0x104df}}},
+ {0x104b8, {1|F|D, {0x104e0}}},
+ {0x104b9, {1|F|D, {0x104e1}}},
+ {0x104ba, {1|F|D, {0x104e2}}},
+ {0x104bb, {1|F|D, {0x104e3}}},
+ {0x104bc, {1|F|D, {0x104e4}}},
+ {0x104bd, {1|F|D, {0x104e5}}},
+ {0x104be, {1|F|D, {0x104e6}}},
+ {0x104bf, {1|F|D, {0x104e7}}},
+ {0x104c0, {1|F|D, {0x104e8}}},
+ {0x104c1, {1|F|D, {0x104e9}}},
+ {0x104c2, {1|F|D, {0x104ea}}},
+ {0x104c3, {1|F|D, {0x104eb}}},
+ {0x104c4, {1|F|D, {0x104ec}}},
+ {0x104c5, {1|F|D, {0x104ed}}},
+ {0x104c6, {1|F|D, {0x104ee}}},
+ {0x104c7, {1|F|D, {0x104ef}}},
+ {0x104c8, {1|F|D, {0x104f0}}},
+ {0x104c9, {1|F|D, {0x104f1}}},
+ {0x104ca, {1|F|D, {0x104f2}}},
+ {0x104cb, {1|F|D, {0x104f3}}},
+ {0x104cc, {1|F|D, {0x104f4}}},
+ {0x104cd, {1|F|D, {0x104f5}}},
+ {0x104ce, {1|F|D, {0x104f6}}},
+ {0x104cf, {1|F|D, {0x104f7}}},
+ {0x104d0, {1|F|D, {0x104f8}}},
+ {0x104d1, {1|F|D, {0x104f9}}},
+ {0x104d2, {1|F|D, {0x104fa}}},
+ {0x104d3, {1|F|D, {0x104fb}}},
+ {0x10c80, {1|F|D, {0x10cc0}}},
+ {0x10c81, {1|F|D, {0x10cc1}}},
+ {0x10c82, {1|F|D, {0x10cc2}}},
+ {0x10c83, {1|F|D, {0x10cc3}}},
+ {0x10c84, {1|F|D, {0x10cc4}}},
+ {0x10c85, {1|F|D, {0x10cc5}}},
+ {0x10c86, {1|F|D, {0x10cc6}}},
+ {0x10c87, {1|F|D, {0x10cc7}}},
+ {0x10c88, {1|F|D, {0x10cc8}}},
+ {0x10c89, {1|F|D, {0x10cc9}}},
+ {0x10c8a, {1|F|D, {0x10cca}}},
+ {0x10c8b, {1|F|D, {0x10ccb}}},
+ {0x10c8c, {1|F|D, {0x10ccc}}},
+ {0x10c8d, {1|F|D, {0x10ccd}}},
+ {0x10c8e, {1|F|D, {0x10cce}}},
+ {0x10c8f, {1|F|D, {0x10ccf}}},
+ {0x10c90, {1|F|D, {0x10cd0}}},
+ {0x10c91, {1|F|D, {0x10cd1}}},
+ {0x10c92, {1|F|D, {0x10cd2}}},
+ {0x10c93, {1|F|D, {0x10cd3}}},
+ {0x10c94, {1|F|D, {0x10cd4}}},
+ {0x10c95, {1|F|D, {0x10cd5}}},
+ {0x10c96, {1|F|D, {0x10cd6}}},
+ {0x10c97, {1|F|D, {0x10cd7}}},
+ {0x10c98, {1|F|D, {0x10cd8}}},
+ {0x10c99, {1|F|D, {0x10cd9}}},
+ {0x10c9a, {1|F|D, {0x10cda}}},
+ {0x10c9b, {1|F|D, {0x10cdb}}},
+ {0x10c9c, {1|F|D, {0x10cdc}}},
+ {0x10c9d, {1|F|D, {0x10cdd}}},
+ {0x10c9e, {1|F|D, {0x10cde}}},
+ {0x10c9f, {1|F|D, {0x10cdf}}},
+ {0x10ca0, {1|F|D, {0x10ce0}}},
+ {0x10ca1, {1|F|D, {0x10ce1}}},
+ {0x10ca2, {1|F|D, {0x10ce2}}},
+ {0x10ca3, {1|F|D, {0x10ce3}}},
+ {0x10ca4, {1|F|D, {0x10ce4}}},
+ {0x10ca5, {1|F|D, {0x10ce5}}},
+ {0x10ca6, {1|F|D, {0x10ce6}}},
+ {0x10ca7, {1|F|D, {0x10ce7}}},
+ {0x10ca8, {1|F|D, {0x10ce8}}},
+ {0x10ca9, {1|F|D, {0x10ce9}}},
+ {0x10caa, {1|F|D, {0x10cea}}},
+ {0x10cab, {1|F|D, {0x10ceb}}},
+ {0x10cac, {1|F|D, {0x10cec}}},
+ {0x10cad, {1|F|D, {0x10ced}}},
+ {0x10cae, {1|F|D, {0x10cee}}},
+ {0x10caf, {1|F|D, {0x10cef}}},
+ {0x10cb0, {1|F|D, {0x10cf0}}},
+ {0x10cb1, {1|F|D, {0x10cf1}}},
+ {0x10cb2, {1|F|D, {0x10cf2}}},
+ {0x118a0, {1|F|D, {0x118c0}}},
+ {0x118a1, {1|F|D, {0x118c1}}},
+ {0x118a2, {1|F|D, {0x118c2}}},
+ {0x118a3, {1|F|D, {0x118c3}}},
+ {0x118a4, {1|F|D, {0x118c4}}},
+ {0x118a5, {1|F|D, {0x118c5}}},
+ {0x118a6, {1|F|D, {0x118c6}}},
+ {0x118a7, {1|F|D, {0x118c7}}},
+ {0x118a8, {1|F|D, {0x118c8}}},
+ {0x118a9, {1|F|D, {0x118c9}}},
+ {0x118aa, {1|F|D, {0x118ca}}},
+ {0x118ab, {1|F|D, {0x118cb}}},
+ {0x118ac, {1|F|D, {0x118cc}}},
+ {0x118ad, {1|F|D, {0x118cd}}},
+ {0x118ae, {1|F|D, {0x118ce}}},
+ {0x118af, {1|F|D, {0x118cf}}},
+ {0x118b0, {1|F|D, {0x118d0}}},
+ {0x118b1, {1|F|D, {0x118d1}}},
+ {0x118b2, {1|F|D, {0x118d2}}},
+ {0x118b3, {1|F|D, {0x118d3}}},
+ {0x118b4, {1|F|D, {0x118d4}}},
+ {0x118b5, {1|F|D, {0x118d5}}},
+ {0x118b6, {1|F|D, {0x118d6}}},
+ {0x118b7, {1|F|D, {0x118d7}}},
+ {0x118b8, {1|F|D, {0x118d8}}},
+ {0x118b9, {1|F|D, {0x118d9}}},
+ {0x118ba, {1|F|D, {0x118da}}},
+ {0x118bb, {1|F|D, {0x118db}}},
+ {0x118bc, {1|F|D, {0x118dc}}},
+ {0x118bd, {1|F|D, {0x118dd}}},
+ {0x118be, {1|F|D, {0x118de}}},
+ {0x118bf, {1|F|D, {0x118df}}},
+ {0x1e900, {1|F|D, {0x1e922}}},
+ {0x1e901, {1|F|D, {0x1e923}}},
+ {0x1e902, {1|F|D, {0x1e924}}},
+ {0x1e903, {1|F|D, {0x1e925}}},
+ {0x1e904, {1|F|D, {0x1e926}}},
+ {0x1e905, {1|F|D, {0x1e927}}},
+ {0x1e906, {1|F|D, {0x1e928}}},
+ {0x1e907, {1|F|D, {0x1e929}}},
+ {0x1e908, {1|F|D, {0x1e92a}}},
+ {0x1e909, {1|F|D, {0x1e92b}}},
+ {0x1e90a, {1|F|D, {0x1e92c}}},
+ {0x1e90b, {1|F|D, {0x1e92d}}},
+ {0x1e90c, {1|F|D, {0x1e92e}}},
+ {0x1e90d, {1|F|D, {0x1e92f}}},
+ {0x1e90e, {1|F|D, {0x1e930}}},
+ {0x1e90f, {1|F|D, {0x1e931}}},
+ {0x1e910, {1|F|D, {0x1e932}}},
+ {0x1e911, {1|F|D, {0x1e933}}},
+ {0x1e912, {1|F|D, {0x1e934}}},
+ {0x1e913, {1|F|D, {0x1e935}}},
+ {0x1e914, {1|F|D, {0x1e936}}},
+ {0x1e915, {1|F|D, {0x1e937}}},
+ {0x1e916, {1|F|D, {0x1e938}}},
+ {0x1e917, {1|F|D, {0x1e939}}},
+ {0x1e918, {1|F|D, {0x1e93a}}},
+ {0x1e919, {1|F|D, {0x1e93b}}},
+ {0x1e91a, {1|F|D, {0x1e93c}}},
+ {0x1e91b, {1|F|D, {0x1e93d}}},
+ {0x1e91c, {1|F|D, {0x1e93e}}},
+ {0x1e91d, {1|F|D, {0x1e93f}}},
+ {0x1e91e, {1|F|D, {0x1e940}}},
+ {0x1e91f, {1|F|D, {0x1e941}}},
+ {0x1e920, {1|F|D, {0x1e942}}},
+ {0x1e921, {1|F|D, {0x1e943}}},
+#define CaseFold_Locale (*(CaseFold_11_Type (*)[2])(CaseFold_11_Table+1399))
+ {0x0049, {1|F|D, {0x0069}}},
+ {0x0130, {2|F|D, {0x0069, 0x0307}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseFold_11_hash -N onigenc_unicode_CaseFold_11_lookup -n */
+
+/* maximum key range = 3623, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseFold_11_hash(const OnigCodePoint code)
+{
+ static const unsigned short asso_values[] =
+ {
+ 1, 3627, 2, 28, 3, 303, 218, 5, 21, 167,
+ 2, 199, 194, 7, 3627, 3627, 3627, 3627, 3627, 3627,
+ 3627, 3627, 3627, 3627, 3627, 3627, 3627, 28, 3627, 3627,
+ 3627, 3627, 3627, 3627, 3627, 282, 3627, 3627, 3627, 3627,
+ 3627, 113, 3627, 3627, 3627, 3627, 3627, 3627, 3627, 3627,
+ 3627, 318, 3627, 3627, 3627, 3627, 3627, 3627, 3627, 1197,
+ 3627, 3627, 149, 73, 513, 1, 3627, 3627, 267, 17,
+ 3627, 3627, 3627, 3627, 3627, 286, 3627, 3627, 289, 617,
+ 291, 28, 1163, 444, 36, 430, 954, 110, 1767, 5,
+ 11, 22, 1761, 486, 1921, 250, 1746, 122, 1905, 163,
+ 1716, 262, 1880, 80, 1503, 68, 1704, 157, 1681, 376,
+ 1673, 209, 1822, 203, 1406, 498, 1622, 362, 1588, 316,
+ 475, 599, 1228, 538, 1160, 585, 1510, 544, 331, 685,
+ 1672, 603, 1536, 840, 1684, 786, 1594, 743, 1380, 700,
+ 142, 839, 1302, 865, 1173, 1329, 1730, 1043, 1449, 969,
+ 1437, 1108, 1360, 925, 1497, 723, 154, 810, 391, 1083,
+ 1777, 1047, 436, 1051, 47, 1342, 8, 974, 98, 1318,
+ 781, 1314, 148, 1403, 39, 1357, 18, 1265, 11, 928,
+ 92, 1205, 2, 1295, 3, 1181, 187, 1151, 385, 1132,
+ 107, 1280, 8, 1678, 41, 511, 42, 1655, 78, 294,
+ 134, 1857, 17, 784, 2, 1113, 57, 496, 52
+ };
+ return asso_values[bits_of(code, 2)+81] + asso_values[bits_of(code, 1)+2] + asso_values[bits_of(code, 0)];
+}
+
+static const CodePointList3 *
+onigenc_unicode_CaseFold_11_lookup(const OnigCodePoint code)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x41,
+ MAX_CODE_VALUE = 0x1e921,
+ TOTAL_KEYWORDS = 1401,
+ MIN_WORD_LENGTH = 3,
+ MAX_WORD_LENGTH = 3,
+ MIN_HASH_VALUE = 4,
+ MAX_HASH_VALUE = 3626
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1, -1,
+ /*0x1ffb*/ 816,
+ /*0x1fe7*/ 802,
+ /*0x017b*/ 118,
+ /*0x1f88*/ 729,
+ /*0x0408*/ 305,
+ /*0x0108*/ 61,
+ /*0x10408*/ 1214,
+ /*0x0055*/ 19,
+ /*0xab88*/ 1112,
+ /*0x1f89*/ 730,
+ /*0x0409*/ 306,
+ /*0x2c67*/ 916,
+ /*0x10409*/ 1215,
+ /*0x2c08*/ 873,
+ /*0xab89*/ 1113,
+ /*0x1ff9*/ 814,
+ /*0x2c6f*/ 921,
+ /*0x0179*/ 117,
+ -1,
+ /*0x2c09*/ 874,
+ /*0x1f8a*/ 731,
+ /*0x040a*/ 307,
+ /*0x010a*/ 62,
+ /*0x1040a*/ 1216,
+ /*0x2c88*/ 931,
+ /*0xab8a*/ 1114,
+ /*0x1f80*/ 721,
+ /*0x0400*/ 297,
+ /*0x0100*/ 57,
+ /*0x10400*/ 1206,
+ /*0x2c0a*/ 875,
+ /*0xab80*/ 1104,
+ /*0x10c88*/ 1290,
+ /*0x00d5*/ 47,
+ /*0x1f83*/ 724,
+ /*0x0403*/ 300,
+ /*0x2c00*/ 865,
+ /*0x10403*/ 1209,
+ /*0x10c89*/ 1291,
+ /*0xab83*/ 1107,
+ /*0x1ff3*/ 809,
+ /*0x2c8a*/ 932,
+ /*0x1e908*/ 1373,
+ /*0x00df*/ 56,
+ /*0x2c03*/ 868,
+ /*0x1fd3*/ 791,
+ /*0x0053*/ 17,
+ /*0x2c80*/ 927,
+ /*0x1e909*/ 1374,
+ /*0x10c8a*/ 1292,
+ /*0x2183*/ 838,
+ -1,
+ /*0x017f*/ 120,
+ -1,
+ /*0xa780*/ 1059,
+ /*0x10c80*/ 1282,
+ -1,
+ /*0x017d*/ 119,
+ -1,
+ /*0x1e90a*/ 1375,
+ /*0x2c7f*/ 926,
+ -1, -1,
+ /*0x10c83*/ 1285,
+ /*0x00dd*/ 54,
+ /*0x1e900*/ 1365,
+ /*0x1f98*/ 745,
+ /*0x0418*/ 321,
+ /*0x0118*/ 69,
+ /*0x10418*/ 1230,
+ /*0x037f*/ 233,
+ /*0xab98*/ 1128,
+ /*0x00d3*/ 45,
+ /*0x1e903*/ 1368,
+ -1,
+ /*0x1e88*/ 607,
+ /*0x2c18*/ 889,
+ -1,
+ /*0x1f96*/ 743,
+ /*0x0416*/ 319,
+ /*0x0116*/ 68,
+ /*0x10416*/ 1228,
+ -1,
+ /*0xab96*/ 1126,
+ -1, -1,
+ /*0x2c75*/ 924,
+ /*0x2c98*/ 939,
+ /*0x2c16*/ 887,
+ -1,
+ /*0x1fe3*/ 799,
+ -1,
+ /*0x1e8a*/ 608,
+ -1,
+ /*0xa798*/ 1068,
+ /*0x10c98*/ 1306,
+ /*0x1fd7*/ 793,
+ /*0x0057*/ 21,
+ /*0x1e80*/ 603,
+ /*0x2c96*/ 938,
+ /*0x2c63*/ 914,
+ -1, -1, -1, -1,
+ /*0x1e918*/ 1389,
+ /*0xa796*/ 1067,
+ /*0x10c96*/ 1304,
+ /*0x1f86*/ 727,
+ /*0x0406*/ 303,
+ /*0x0106*/ 60,
+ /*0x10406*/ 1212,
+ /*0x13fb*/ 527,
+ /*0xab86*/ 1110,
+ -1,
+ /*0x2c6d*/ 919,
+ -1,
+ /*0x1e916*/ 1387,
+ /*0x2c06*/ 871,
+ -1,
+ /*0x1f90*/ 737,
+ /*0x0410*/ 313,
+ /*0x0110*/ 65,
+ /*0x10410*/ 1222,
+ -1,
+ /*0xab90*/ 1120,
+ /*0x2ced*/ 978,
+ /*0x13f9*/ 525,
+ -1,
+ /*0x2c86*/ 930,
+ /*0x2c10*/ 881,
+ -1,
+ /*0x1ff7*/ 812,
+ -1, -1, -1,
+ /*0xa786*/ 1062,
+ /*0x10c86*/ 1288,
+ /*0x1e98*/ 616,
+ -1,
+ /*0x1fbb*/ 777,
+ /*0x2c90*/ 935,
+ /*0x013b*/ 85,
+ -1, -1,
+ /*0xabbb*/ 1163,
+ /*0x1fdb*/ 797,
+ /*0x1e906*/ 1371,
+ /*0xa790*/ 1065,
+ /*0x10c90*/ 1298,
+ /*0x1e96*/ 614,
+ /*0x1e08*/ 543,
+ /*0x1fcb*/ 788,
+ /*0x004b*/ 9,
+ -1,
+ /*0x1f9a*/ 747,
+ /*0x041a*/ 323,
+ /*0x011a*/ 70,
+ /*0x1041a*/ 1232,
+ /*0x1e910*/ 1381,
+ /*0xab9a*/ 1130,
+ /*0x1f92*/ 739,
+ /*0x0412*/ 315,
+ /*0x0112*/ 66,
+ /*0x10412*/ 1224,
+ /*0x2c1a*/ 891,
+ /*0xab92*/ 1122,
+ /*0x13fd*/ 529,
+ /*0x1e0a*/ 544,
+ /*0x0388*/ 235,
+ -1,
+ /*0x2c12*/ 883,
+ /*0x03d5*/ 273,
+ /*0x00db*/ 52,
+ /*0x1e00*/ 539,
+ /*0x0389*/ 236,
+ /*0x2c9a*/ 940,
+ -1, -1,
+ /*0x00cb*/ 37,
+ /*0x1e86*/ 606,
+ /*0x03f9*/ 292,
+ /*0x2c92*/ 936,
+ /*0xa79a*/ 1069,
+ /*0x10c9a*/ 1308,
+ /*0x1fe9*/ 804,
+ /*0x038a*/ 237,
+ -1, -1,
+ /*0xa792*/ 1066,
+ /*0x10c92*/ 1300,
+ -1,
+ /*0x1e90*/ 611,
+ -1,
+ /*0x1e91a*/ 1391,
+ /*0x2c69*/ 917,
+ /*0x0508*/ 425,
+ -1, -1,
+ /*0x0555*/ 481,
+ /*0x1e912*/ 1383,
+ /*0x1fa0*/ 753,
+ /*0x0420*/ 329,
+ /*0x0120*/ 73,
+ /*0x10420*/ 1238,
+ /*0x03f1*/ 288,
+ /*0xaba0*/ 1136,
+ /*0x1f9e*/ 751,
+ /*0x041e*/ 327,
+ /*0x011e*/ 72,
+ /*0x1041e*/ 1236,
+ /*0x2c20*/ 897,
+ /*0xab9e*/ 1134,
+ /*0x050a*/ 426,
+ /*0x1e18*/ 551,
+ -1,
+ /*0x03ff*/ 296,
+ /*0x2c1e*/ 895,
+ /*0x048a*/ 362,
+ /*0x0500*/ 421,
+ /*0x0208*/ 194,
+ /*0x03fd*/ 294,
+ /*0x2ca0*/ 943,
+ -1,
+ /*0x0480*/ 361,
+ -1,
+ /*0x1e16*/ 550,
+ /*0x1e9a*/ 618,
+ /*0x2c9e*/ 942,
+ /*0xa7a0*/ 1072,
+ /*0x10ca0*/ 1314,
+ -1,
+ /*0x0398*/ 249,
+ /*0x1e92*/ 612,
+ -1,
+ /*0xa79e*/ 1071,
+ /*0x10c9e*/ 1312,
+ /*0x020a*/ 195,
+ /*0x0553*/ 479,
+ -1,
+ /*0x1e920*/ 1397,
+ -1,
+ /*0x03f5*/ 290,
+ /*0x0200*/ 190,
+ /*0x0396*/ 247,
+ /*0x104d3*/ 1281,
+ /*0x1e91e*/ 1395,
+ -1,
+ /*0x1f8e*/ 735,
+ /*0x040e*/ 311,
+ /*0x010e*/ 64,
+ /*0x1040e*/ 1220,
+ -1,
+ /*0xab8e*/ 1118,
+ -1, -1,
+ /*0x1e06*/ 542,
+ -1,
+ /*0x2c0e*/ 879,
+ /*0x0518*/ 433,
+ /*0x1f94*/ 741,
+ /*0x0414*/ 317,
+ /*0x0114*/ 67,
+ /*0x10414*/ 1226,
+ /*0x0498*/ 369,
+ /*0xab94*/ 1124,
+ /*0x2165*/ 827,
+ /*0x2167*/ 829,
+ /*0x1e10*/ 547,
+ /*0x2c8e*/ 934,
+ /*0x2c14*/ 885,
+ /*0x0516*/ 432,
+ /*0x216f*/ 837,
+ /*0x1ea0*/ 621,
+ /*0x0386*/ 234,
+ /*0x2161*/ 823,
+ /*0x0496*/ 368,
+ /*0x10c8e*/ 1296,
+ -1,
+ /*0x1e9e*/ 620,
+ -1,
+ /*0x2c94*/ 937,
+ -1,
+ /*0x0218*/ 202,
+ -1, -1,
+ /*0x0390*/ 241,
+ /*0x1e90e*/ 1379,
+ -1,
+ /*0x10c94*/ 1302,
+ -1,
+ /*0xa77b*/ 1056,
+ /*0x1ff6*/ 811,
+ /*0x0476*/ 356,
+ /*0x0176*/ 115,
+ /*0x0216*/ 201,
+ -1, -1,
+ /*0x03f7*/ 291,
+ /*0x1e914*/ 1385,
+ -1,
+ /*0x0506*/ 424,
+ -1,
+ /*0x1e1a*/ 552,
+ -1, -1,
+ /*0xa779*/ 1055,
+ -1,
+ /*0x01d5*/ 167,
+ /*0x1e12*/ 548,
+ -1,
+ /*0x0189*/ 126,
+ /*0x0376*/ 232,
+ /*0x0510*/ 429,
+ /*0x1fa6*/ 759,
+ /*0x0426*/ 335,
+ /*0x0126*/ 76,
+ /*0x10426*/ 1244,
+ /*0x0490*/ 365,
+ /*0xaba6*/ 1142,
+ /*0x1e8e*/ 610,
+ /*0x039a*/ 251,
+ /*0x018a*/ 127,
+ -1,
+ /*0x2c26*/ 903,
+ /*0x0206*/ 193,
+ -1,
+ /*0x0392*/ 243,
+ -1,
+ /*0x1faf*/ 768,
+ /*0x042f*/ 344,
+ -1,
+ /*0x1e94*/ 613,
+ /*0x053b*/ 455,
+ /*0xabaf*/ 1151,
+ /*0x2ca6*/ 946,
+ -1,
+ /*0x0210*/ 198,
+ -1, -1,
+ /*0x104bb*/ 1257,
+ /*0x01f1*/ 181,
+ /*0xa7a6*/ 1075,
+ /*0x10ca6*/ 1320,
+ -1,
+ /*0x054b*/ 471,
+ /*0xa77d*/ 1057,
+ /*0x01d3*/ 166,
+ /*0x051a*/ 434,
+ /*0x1e20*/ 555,
+ /*0x04cb*/ 395,
+ -1,
+ /*0x104cb*/ 1273,
+ /*0x049a*/ 370,
+ /*0x0512*/ 430,
+ /*0x1e1e*/ 554,
+ /*0x2163*/ 825,
+ /*0x023b*/ 217,
+ /*0x10caf*/ 1329,
+ /*0x0492*/ 366,
+ /*0x1fa4*/ 757,
+ /*0x0424*/ 333,
+ /*0x0124*/ 75,
+ /*0x10424*/ 1242,
+ /*0x1ef6*/ 664,
+ /*0xaba4*/ 1140,
+ -1,
+ /*0x03a0*/ 257,
+ /*0x0198*/ 137,
+ -1,
+ /*0x2c24*/ 901,
+ /*0x216d*/ 835,
+ /*0x021a*/ 203,
+ /*0x039e*/ 255,
+ /*0x1f9c*/ 749,
+ /*0x041c*/ 325,
+ /*0x011c*/ 71,
+ /*0x1041c*/ 1234,
+ /*0x0212*/ 199,
+ /*0xab9c*/ 1132,
+ /*0x0196*/ 135,
+ /*0x2ca4*/ 945,
+ -1,
+ /*0x1feb*/ 806,
+ /*0x2c1c*/ 893,
+ -1,
+ /*0x1ea6*/ 624,
+ -1,
+ /*0xa7a4*/ 1074,
+ /*0x10ca4*/ 1318,
+ /*0x004d*/ 11,
+ -1, -1,
+ /*0x2c6b*/ 918,
+ /*0x0520*/ 437,
+ /*0x2c9c*/ 941,
+ /*0x1e0e*/ 546,
+ -1,
+ /*0x01d7*/ 168,
+ /*0x04a0*/ 373,
+ /*0x051e*/ 436,
+ -1,
+ /*0xa79c*/ 1070,
+ /*0x10c9c*/ 1310,
+ /*0x2ceb*/ 977,
+ /*0x049e*/ 372,
+ -1, -1,
+ /*0x1e14*/ 549,
+ -1,
+ /*0x0186*/ 124,
+ -1, -1,
+ /*0x1e91c*/ 1393,
+ /*0x038e*/ 239,
+ -1,
+ /*0x00cd*/ 39,
+ -1,
+ /*0x0220*/ 206,
+ -1, -1,
+ /*0x10bb*/ 511,
+ /*0x0190*/ 131,
+ -1,
+ /*0x021e*/ 205,
+ /*0x24bb*/ 844,
+ /*0x0394*/ 245,
+ -1,
+ /*0x1f84*/ 725,
+ /*0x0404*/ 301,
+ /*0x0104*/ 59,
+ /*0x10404*/ 1210,
+ /*0x1ea4*/ 623,
+ /*0xab84*/ 1108,
+ /*0x01f7*/ 185,
+ /*0x0051*/ 15,
+ -1,
+ /*0x24cb*/ 860,
+ /*0x2c04*/ 869,
+ -1,
+ /*0x1e76*/ 598,
+ /*0x050e*/ 428,
+ /*0x1f82*/ 723,
+ /*0x0402*/ 299,
+ /*0x0102*/ 58,
+ /*0x10402*/ 1208,
+ /*0x048e*/ 364,
+ /*0xab82*/ 1106,
+ /*0x01db*/ 170,
+ /*0x2c84*/ 929,
+ -1,
+ /*0x2169*/ 831,
+ /*0x2c02*/ 867,
+ /*0x0514*/ 431,
+ /*0x01cb*/ 162,
+ -1,
+ /*0xa784*/ 1061,
+ /*0x10c84*/ 1286,
+ /*0x0494*/ 367,
+ /*0x118bb*/ 1360,
+ -1,
+ /*0x00d1*/ 43,
+ /*0x1e26*/ 558,
+ /*0x2c82*/ 928,
+ -1,
+ /*0x020e*/ 197,
+ -1,
+ /*0x1e904*/ 1369,
+ -1, -1,
+ /*0xa782*/ 1060,
+ /*0x10c82*/ 1284,
+ -1,
+ /*0x1fa7*/ 760,
+ /*0x0427*/ 336,
+ -1,
+ /*0x10427*/ 1245,
+ /*0x0214*/ 200,
+ /*0xaba7*/ 1143,
+ -1,
+ /*0x03a6*/ 262,
+ /*0x1e902*/ 1367,
+ /*0x10a0*/ 484,
+ /*0x2c27*/ 904,
+ /*0x1f8c*/ 733,
+ /*0x040c*/ 309,
+ /*0x010c*/ 63,
+ /*0x1040c*/ 1218,
+ -1,
+ /*0xab8c*/ 1116,
+ /*0x04f6*/ 416,
+ -1, -1, -1,
+ /*0x2c0c*/ 877,
+ /*0x047e*/ 360,
+ /*0x1fa2*/ 755,
+ /*0x0422*/ 331,
+ /*0x0122*/ 74,
+ /*0x10422*/ 1240,
+ /*0x1e84*/ 605,
+ /*0xaba2*/ 1138,
+ /*0x10ca7*/ 1321,
+ /*0x01a0*/ 141,
+ /*0x2c7e*/ 925,
+ /*0x2c8c*/ 933,
+ /*0x2c22*/ 899,
+ /*0x0526*/ 440,
+ /*0x1e24*/ 557,
+ /*0x1ff2*/ 808,
+ /*0x0472*/ 354,
+ /*0x0172*/ 113,
+ /*0x04a6*/ 376,
+ /*0x10c8c*/ 1294,
+ /*0x1e82*/ 604,
+ /*0x1f08*/ 669,
+ -1,
+ /*0x2ca2*/ 944,
+ /*0x1f6f*/ 720,
+ /*0x2c72*/ 923,
+ /*0x118a0*/ 1333,
+ /*0x1f09*/ 670,
+ /*0x1e1c*/ 553,
+ /*0x1e90c*/ 1377,
+ /*0xa7a2*/ 1073,
+ /*0x10ca2*/ 1316,
+ /*0x03a4*/ 260,
+ /*0xfb00*/ 1168,
+ /*0x1f5f*/ 712,
+ /*0x0372*/ 231,
+ /*0x2cf2*/ 979,
+ /*0x0226*/ 209,
+ /*0x1f0a*/ 671,
+ -1, -1,
+ /*0xfb03*/ 1171,
+ /*0x1faa*/ 763,
+ /*0x042a*/ 339,
+ /*0x012a*/ 78,
+ -1,
+ /*0x039c*/ 253,
+ /*0xabaa*/ 1146,
+ /*0x1fae*/ 767,
+ /*0x042e*/ 343,
+ /*0x012e*/ 80,
+ -1,
+ /*0x2c2a*/ 907,
+ /*0xabae*/ 1150,
+ -1,
+ /*0x1f5d*/ 711,
+ /*0x018e*/ 129,
+ -1,
+ /*0x2c2e*/ 911,
+ /*0x0524*/ 439,
+ -1, -1,
+ /*0x1e8c*/ 609,
+ /*0x2caa*/ 948,
+ /*0x04a4*/ 375,
+ -1, -1, -1,
+ /*0x0194*/ 134,
+ /*0x2cae*/ 950,
+ /*0xa7aa*/ 1077,
+ /*0x10caa*/ 1324,
+ /*0x1efe*/ 668,
+ /*0x051c*/ 435,
+ /*0x1ea2*/ 622,
+ -1,
+ /*0xa7ae*/ 1081,
+ /*0x10cae*/ 1328,
+ /*0x049c*/ 371,
+ -1, -1, -1,
+ /*0x1e04*/ 541,
+ /*0x0224*/ 208,
+ /*0x1f18*/ 677,
+ /*0xfb16*/ 1178,
+ /*0x2126*/ 818,
+ /*0x1ef2*/ 662,
+ /*0x054d*/ 473,
+ /*0x1fac*/ 765,
+ /*0x042c*/ 341,
+ /*0x012c*/ 79,
+ -1,
+ /*0x04cd*/ 396,
+ /*0xabac*/ 1148,
+ /*0x104cd*/ 1275,
+ /*0x1e02*/ 540,
+ /*0x021c*/ 204,
+ -1,
+ /*0x2c2c*/ 909,
+ /*0x01f6*/ 184,
+ /*0x10a6*/ 490,
+ -1,
+ /*0x1fa8*/ 761,
+ /*0x0428*/ 337,
+ /*0x0128*/ 77,
+ /*0x03d1*/ 272,
+ /*0x1fb2*/ 769,
+ /*0xaba8*/ 1144,
+ /*0x0132*/ 81,
+ /*0x2cac*/ 949,
+ /*0xa726*/ 1019,
+ /*0xabb2*/ 1154,
+ /*0x2c28*/ 905,
+ /*0x1eaa*/ 626,
+ /*0xfb06*/ 1174,
+ /*0x10af*/ 499,
+ /*0xa7ac*/ 1079,
+ /*0x10cac*/ 1326,
+ -1,
+ /*0x1eae*/ 628,
+ -1,
+ /*0x01a6*/ 144,
+ /*0x1f6d*/ 718,
+ /*0x2ca8*/ 947,
+ -1,
+ /*0xa688*/ 1007,
+ /*0x0504*/ 423,
+ /*0x2cb2*/ 952,
+ -1, -1,
+ /*0xa7a8*/ 1076,
+ /*0x10ca8*/ 1322,
+ /*0x0551*/ 477,
+ -1,
+ /*0xa7b2*/ 1084,
+ /*0x10cb2*/ 1332,
+ /*0x01af*/ 149,
+ /*0x1e0c*/ 545,
+ /*0x118a6*/ 1339,
+ /*0x104d1*/ 1279,
+ /*0x0502*/ 422,
+ -1,
+ /*0xa68a*/ 1008,
+ -1,
+ /*0x03a7*/ 263,
+ -1,
+ /*0x10a4*/ 488,
+ /*0x1e7e*/ 602,
+ /*0xa680*/ 1003,
+ /*0x1e22*/ 556,
+ /*0x0204*/ 192,
+ -1, -1,
+ /*0x118af*/ 1348,
+ /*0x216b*/ 833,
+ /*0x038c*/ 238,
+ /*0xa724*/ 1018,
+ /*0x1f3b*/ 694,
+ -1, -1,
+ /*0x1eac*/ 627,
+ -1,
+ /*0x1e72*/ 596,
+ /*0x1f5b*/ 710,
+ /*0x0202*/ 191,
+ /*0x03fe*/ 295,
+ -1,
+ /*0x01a4*/ 143,
+ -1,
+ /*0x1f4b*/ 702,
+ -1, -1,
+ /*0x1f1a*/ 679,
+ -1,
+ /*0x1ea8*/ 625,
+ /*0x10cd*/ 523,
+ /*0xff26*/ 1185,
+ -1,
+ /*0x1eb2*/ 630,
+ /*0x24cd*/ 862,
+ -1,
+ /*0x019c*/ 138,
+ /*0x050c*/ 427,
+ -1,
+ /*0x118a4*/ 1337,
+ -1, -1,
+ /*0x048c*/ 363,
+ /*0xa698*/ 1015,
+ /*0x1e2a*/ 560,
+ /*0x0130*/ 1400,
+ /*0xff2f*/ 1194,
+ -1,
+ /*0xabb0*/ 1152,
+ /*0x0522*/ 438,
+ /*0x1e2e*/ 562,
+ /*0x01cd*/ 163,
+ /*0x04fe*/ 420,
+ -1,
+ /*0x04a2*/ 374,
+ /*0xa696*/ 1014,
+ -1,
+ /*0x1f69*/ 714,
+ /*0x1fba*/ 776,
+ -1, -1,
+ /*0x020c*/ 196,
+ /*0x03aa*/ 266,
+ /*0xabba*/ 1162,
+ /*0x2cb0*/ 951,
+ -1, -1,
+ /*0x04f2*/ 414,
+ -1, -1, -1,
+ /*0xa7b0*/ 1082,
+ /*0x10cb0*/ 1330,
+ /*0x0222*/ 207,
+ -1, -1, -1,
+ /*0xff24*/ 1183,
+ -1,
+ /*0x2cba*/ 956,
+ -1,
+ /*0x1fca*/ 787,
+ /*0x004a*/ 8,
+ /*0x014a*/ 93,
+ -1,
+ /*0xa686*/ 1006,
+ -1, -1, -1,
+ /*0x052a*/ 442,
+ /*0x0184*/ 123,
+ /*0x1e2c*/ 561,
+ -1, -1,
+ /*0x04aa*/ 378,
+ /*0x052e*/ 444,
+ /*0x01d1*/ 165,
+ /*0xa690*/ 1011,
+ -1, -1,
+ /*0x04ae*/ 380,
+ /*0x1fb8*/ 774,
+ /*0x2cca*/ 964,
+ -1,
+ /*0x0182*/ 122,
+ /*0x1e28*/ 559,
+ /*0xabb8*/ 1160,
+ -1,
+ /*0x00ca*/ 36,
+ /*0x1e32*/ 564,
+ -1, -1, -1,
+ /*0x022a*/ 211,
+ /*0x10a7*/ 491,
+ /*0x1eb0*/ 629,
+ -1, -1, -1,
+ /*0x022e*/ 213,
+ /*0x1f0e*/ 675,
+ /*0xfb14*/ 1176,
+ /*0x2cb8*/ 955,
+ /*0x03a8*/ 264,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1eba*/ 634,
+ -1,
+ /*0xa69a*/ 1016,
+ -1, -1,
+ /*0x01a7*/ 145,
+ /*0x052c*/ 443,
+ /*0x10a2*/ 486,
+ /*0xa692*/ 1012,
+ /*0x1fd9*/ 795,
+ /*0x0059*/ 23,
+ /*0x04ac*/ 379,
+ /*0x1ffa*/ 815,
+ /*0x047a*/ 358,
+ /*0x1fb6*/ 772,
+ /*0xa77e*/ 1058,
+ /*0x0136*/ 83,
+ /*0xa722*/ 1017,
+ -1,
+ /*0xabb6*/ 1158,
+ /*0x0528*/ 441,
+ -1,
+ /*0x118a7*/ 1340,
+ /*0x1eca*/ 642,
+ /*0x0532*/ 446,
+ /*0x04a8*/ 377,
+ /*0x01fe*/ 189,
+ -1,
+ /*0x01a2*/ 142,
+ /*0x04b2*/ 382,
+ /*0x022c*/ 212,
+ /*0x104b2*/ 1248,
+ /*0x212a*/ 819,
+ -1, -1,
+ /*0x2cb6*/ 954,
+ /*0x00d9*/ 50,
+ -1,
+ /*0x1fcc*/ 789,
+ /*0x004c*/ 10,
+ /*0x014c*/ 94,
+ /*0x01f2*/ 182,
+ /*0xa7b6*/ 1087,
+ /*0x1eb8*/ 633,
+ /*0x0228*/ 210,
+ /*0x118a2*/ 1335,
+ -1,
+ /*0x10aa*/ 494,
+ /*0x0232*/ 215,
+ -1, -1, -1, -1,
+ /*0x10ae*/ 498,
+ -1, -1, -1,
+ /*0xa72a*/ 1021,
+ -1,
+ /*0x2ccc*/ 965,
+ /*0xff27*/ 1186,
+ /*0x1e30*/ 563,
+ -1,
+ /*0xa72e*/ 1023,
+ -1,
+ /*0x00cc*/ 38,
+ -1,
+ /*0x1fbc*/ 778,
+ /*0x1fb4*/ 771,
+ -1,
+ /*0x0134*/ 82,
+ /*0x1f2f*/ 690,
+ /*0xabbc*/ 1164,
+ /*0xabb4*/ 1156,
+ /*0x01ae*/ 148,
+ -1,
+ /*0x1e3a*/ 568,
+ -1, -1,
+ /*0x03b0*/ 268,
+ -1, -1, -1,
+ /*0xff22*/ 1181,
+ /*0x1efa*/ 666,
+ /*0x118aa*/ 1343,
+ /*0x1eb6*/ 632,
+ -1,
+ /*0x2cbc*/ 957,
+ /*0x2cb4*/ 953,
+ -1,
+ /*0x118ae*/ 1347,
+ -1,
+ /*0x1fbe*/ 779,
+ /*0x10ac*/ 496,
+ /*0xa68e*/ 1010,
+ /*0xa7b4*/ 1086,
+ /*0x2132*/ 821,
+ /*0xabbe*/ 1166,
+ /*0x1e4a*/ 576,
+ -1, -1, -1, -1,
+ /*0xa72c*/ 1022,
+ -1, -1,
+ /*0xa694*/ 1013,
+ /*0x10a8*/ 492,
+ -1,
+ /*0x1ecc*/ 643,
+ /*0x04b0*/ 381,
+ /*0x10b2*/ 502,
+ /*0x104b0*/ 1246,
+ /*0x2cbe*/ 958,
+ /*0x01ac*/ 147,
+ /*0x1f1c*/ 681,
+ -1,
+ /*0xa728*/ 1020,
+ /*0x1e38*/ 567,
+ -1,
+ /*0x053a*/ 454,
+ /*0xa732*/ 1024,
+ /*0xff2a*/ 1189,
+ /*0x13fa*/ 526,
+ /*0x1f6b*/ 716,
+ /*0x04ba*/ 386,
+ -1,
+ /*0x104ba*/ 1256,
+ /*0xff2e*/ 1193,
+ /*0x0230*/ 214,
+ /*0x1f4d*/ 704,
+ /*0x118ac*/ 1345,
+ /*0x01b2*/ 151,
+ -1, -1, -1, -1, -1,
+ /*0x1ebc*/ 635,
+ /*0x1eb4*/ 631,
+ -1, -1, -1,
+ /*0x054a*/ 470,
+ /*0x023a*/ 216,
+ /*0x118a8*/ 1341,
+ -1, -1, -1,
+ /*0x118b2*/ 1351,
+ /*0x104ca*/ 1272,
+ -1,
+ /*0x1fc8*/ 785,
+ /*0x0048*/ 7,
+ -1,
+ /*0x1fe2*/ 798,
+ /*0x0462*/ 346,
+ /*0x0162*/ 105,
+ /*0xfb04*/ 1172,
+ /*0x1e7a*/ 600,
+ -1,
+ /*0x1e36*/ 566,
+ -1,
+ /*0x0538*/ 452,
+ /*0x1ebe*/ 636,
+ /*0x2c62*/ 913,
+ -1,
+ /*0x024a*/ 226,
+ /*0x04b8*/ 385,
+ /*0xff2c*/ 1191,
+ /*0x104b8*/ 1254,
+ -1,
+ /*0xfb02*/ 1170,
+ /*0x2cc8*/ 963,
+ -1, -1,
+ /*0x2ce2*/ 976,
+ /*0x03fa*/ 293,
+ -1,
+ /*0x00c8*/ 34,
+ -1,
+ /*0x1f85*/ 726,
+ /*0x0405*/ 302,
+ /*0xff28*/ 1187,
+ /*0x10405*/ 1211,
+ /*0x1e4c*/ 577,
+ /*0xab85*/ 1109,
+ /*0xff32*/ 1197,
+ -1, -1, -1,
+ /*0x2c05*/ 870,
+ -1,
+ /*0x10b0*/ 500,
+ -1, -1,
+ /*0x1fc4*/ 782,
+ /*0x0044*/ 3,
+ -1, -1, -1,
+ /*0x1fd6*/ 792,
+ /*0x0056*/ 20,
+ /*0x0156*/ 99,
+ -1, -1,
+ /*0x0536*/ 450,
+ -1,
+ /*0x10ba*/ 510,
+ /*0x04fa*/ 418,
+ /*0x10c85*/ 1287,
+ /*0x04b6*/ 384,
+ /*0x24ba*/ 843,
+ /*0x104b6*/ 1252,
+ /*0x1e3c*/ 569,
+ /*0x1e34*/ 565,
+ -1,
+ /*0x2cc4*/ 961,
+ /*0xa73a*/ 1028,
+ -1,
+ /*0x1e905*/ 1370,
+ -1,
+ /*0x2cd6*/ 970,
+ /*0x00c4*/ 30,
+ /*0x1ec8*/ 641,
+ /*0x1f0c*/ 673,
+ -1,
+ /*0x1ee2*/ 654,
+ /*0x00d6*/ 48,
+ -1,
+ /*0x054c*/ 472,
+ /*0x118b0*/ 1349,
+ -1, -1, -1,
+ /*0x24ca*/ 859,
+ -1,
+ /*0x104cc*/ 1274,
+ -1,
+ /*0xa64a*/ 985,
+ /*0x1e3e*/ 570,
+ /*0xa74a*/ 1036,
+ -1, -1, -1, -1,
+ /*0x118ba*/ 1359,
+ -1, -1, -1, -1,
+ /*0x10b8*/ 508,
+ /*0x01ca*/ 161,
+ -1,
+ /*0x024c*/ 227,
+ /*0x24b8*/ 841,
+ -1, -1, -1,
+ /*0x053c*/ 456,
+ /*0x0534*/ 448,
+ /*0xa738*/ 1027,
+ -1, -1,
+ /*0x04bc*/ 387,
+ /*0x04b4*/ 383,
+ /*0x104bc*/ 1258,
+ /*0x104b4*/ 1250,
+ /*0x1ec4*/ 639,
+ /*0xff30*/ 1195,
+ /*0x1fc2*/ 780,
+ /*0x0042*/ 1,
+ /*0x01b8*/ 155,
+ /*0x1ed6*/ 648,
+ /*0xa684*/ 1005,
+ /*0x0050*/ 14,
+ /*0x0150*/ 96,
+ /*0x1f2a*/ 685,
+ /*0x1fd2*/ 790,
+ /*0x0052*/ 16,
+ /*0x0152*/ 97,
+ -1, -1,
+ /*0x1f2e*/ 689,
+ /*0xff3a*/ 1205,
+ /*0x053e*/ 458,
+ -1, -1,
+ /*0xa682*/ 1004,
+ /*0x118b8*/ 1357,
+ /*0x04be*/ 388,
+ /*0x2cc2*/ 960,
+ /*0x104be*/ 1260,
+ -1,
+ /*0x10b6*/ 506,
+ /*0x2cd0*/ 967,
+ -1,
+ /*0x00c2*/ 28,
+ /*0x24b6*/ 839,
+ /*0x2cd2*/ 968,
+ /*0x1e48*/ 575,
+ /*0x00d0*/ 42,
+ -1,
+ /*0x1e62*/ 588,
+ /*0xa736*/ 1026,
+ /*0x00d2*/ 44,
+ -1, -1, -1,
+ /*0x023e*/ 219,
+ /*0x01d9*/ 169,
+ /*0x004e*/ 12,
+ /*0x014e*/ 95,
+ /*0x01fa*/ 187,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x03e2*/ 280,
+ /*0x24cc*/ 861,
+ -1,
+ /*0x1f2c*/ 687,
+ -1,
+ /*0xa64c*/ 986,
+ /*0xff38*/ 1203,
+ /*0xa74c*/ 1037,
+ -1,
+ /*0xa68c*/ 1009,
+ /*0x2cce*/ 966,
+ /*0x118b6*/ 1355,
+ -1, -1,
+ /*0x1fc6*/ 783,
+ /*0x0046*/ 5,
+ /*0x00ce*/ 40,
+ /*0x1f28*/ 683,
+ -1,
+ /*0x1ffc*/ 817,
+ /*0x047c*/ 359,
+ /*0x1ec2*/ 638,
+ -1,
+ /*0x1e44*/ 573,
+ /*0x0548*/ 468,
+ /*0x1ed0*/ 645,
+ /*0x10bc*/ 512,
+ /*0x10b4*/ 504,
+ /*0x1e56*/ 582,
+ /*0x1ed2*/ 646,
+ /*0x24bc*/ 845,
+ /*0x104c8*/ 1270,
+ /*0x04e2*/ 406,
+ -1, -1,
+ /*0x2cc6*/ 962,
+ /*0xa73c*/ 1029,
+ /*0xa734*/ 1025,
+ /*0x1fec*/ 807,
+ /*0x046c*/ 351,
+ /*0x016c*/ 110,
+ /*0x00c6*/ 32,
+ -1, -1, -1, -1,
+ /*0x03d6*/ 274,
+ /*0x01bc*/ 156,
+ /*0x0248*/ 225,
+ /*0xff36*/ 1201,
+ -1, -1,
+ /*0x10be*/ 514,
+ -1, -1, -1,
+ /*0x24be*/ 847,
+ /*0x1fea*/ 805,
+ /*0x046a*/ 350,
+ /*0x016a*/ 109,
+ -1,
+ /*0x1ece*/ 644,
+ /*0xa73e*/ 1030,
+ -1,
+ /*0x118bc*/ 1361,
+ /*0x118b4*/ 1353,
+ /*0x1fab*/ 764,
+ /*0x042b*/ 340,
+ /*0x0544*/ 464,
+ /*0x1f81*/ 722,
+ /*0x0401*/ 298,
+ /*0xabab*/ 1147,
+ /*0x10401*/ 1207,
+ /*0x0556*/ 482,
+ /*0xab81*/ 1105,
+ /*0x104c4*/ 1266,
+ /*0x2c2b*/ 908,
+ -1,
+ /*0x04d6*/ 400,
+ /*0x2c01*/ 866,
+ -1,
+ /*0x013f*/ 87,
+ -1, -1,
+ /*0xabbf*/ 1167,
+ -1,
+ /*0x1ec6*/ 640,
+ /*0x1fe8*/ 803,
+ /*0x0468*/ 349,
+ /*0x0168*/ 108,
+ /*0x118be*/ 1363,
+ /*0x1efc*/ 667,
+ /*0x0244*/ 222,
+ -1,
+ /*0xa7ab*/ 1078,
+ /*0x10cab*/ 1325,
+ -1,
+ /*0x1e42*/ 572,
+ /*0x10c81*/ 1283,
+ -1,
+ /*0x2162*/ 824,
+ /*0x1e50*/ 579,
+ -1,
+ /*0xff34*/ 1199,
+ -1,
+ /*0x1e52*/ 580,
+ -1,
+ /*0x1c88*/ 538,
+ /*0x1e901*/ 1366,
+ -1,
+ /*0x1eec*/ 659,
+ /*0x1fe4*/ 800,
+ /*0x0464*/ 347,
+ /*0x0164*/ 106,
+ -1,
+ /*0x03c2*/ 269,
+ /*0x24c8*/ 857,
+ -1,
+ /*0x1f3a*/ 693,
+ /*0x03d0*/ 271,
+ /*0xa648*/ 984,
+ /*0x2c64*/ 915,
+ /*0xa748*/ 1035,
+ /*0xa662*/ 997,
+ -1,
+ /*0xa762*/ 1048,
+ -1, -1, -1,
+ /*0x1eea*/ 658,
+ /*0x1c80*/ 530,
+ /*0x13fc*/ 528,
+ -1,
+ /*0x01c8*/ 160,
+ /*0x1fa9*/ 762,
+ /*0x0429*/ 338,
+ /*0x01e2*/ 173,
+ /*0x1e4e*/ 578,
+ /*0x1c83*/ 533,
+ /*0xaba9*/ 1145,
+ -1,
+ /*0x1f4a*/ 701,
+ /*0x0542*/ 462,
+ -1,
+ /*0x2c29*/ 906,
+ -1,
+ /*0x0550*/ 476,
+ -1, -1,
+ /*0x104c2*/ 1264,
+ /*0x0552*/ 478,
+ /*0x04d0*/ 397,
+ -1,
+ /*0x104d0*/ 1278,
+ -1,
+ /*0x04d2*/ 398,
+ /*0x10c4*/ 520,
+ /*0x104d2*/ 1280,
+ -1,
+ /*0x1ee8*/ 657,
+ /*0x24c4*/ 853,
+ /*0x1f38*/ 691,
+ /*0x1e46*/ 574,
+ /*0x10ca9*/ 1323,
+ /*0xa644*/ 982,
+ -1,
+ /*0xa744*/ 1033,
+ /*0x1e7c*/ 601,
+ -1,
+ /*0xa656*/ 991,
+ -1,
+ /*0xa756*/ 1042,
+ /*0x0460*/ 345,
+ /*0x0160*/ 104,
+ -1, -1, -1,
+ /*0x01c4*/ 157,
+ -1, -1, -1,
+ /*0x2c60*/ 912,
+ /*0x054e*/ 474,
+ /*0x1ee4*/ 655,
+ -1, -1,
+ /*0x1e6c*/ 593,
+ /*0x046e*/ 352,
+ /*0x016e*/ 111,
+ /*0x104ce*/ 1276,
+ -1, -1,
+ /*0x2ce0*/ 975,
+ -1, -1, -1,
+ /*0x2c6e*/ 920,
+ -1, -1,
+ /*0x1f59*/ 709,
+ -1,
+ /*0x1fe6*/ 801,
+ /*0x0466*/ 348,
+ /*0x0166*/ 107,
+ /*0x03ec*/ 285,
+ /*0x1e6a*/ 592,
+ /*0x024e*/ 228,
+ /*0x0546*/ 466,
+ -1, -1,
+ /*0x013d*/ 86,
+ -1,
+ /*0x1c86*/ 536,
+ /*0xabbd*/ 1165,
+ /*0x104c6*/ 1268,
+ -1, -1,
+ /*0x04fc*/ 419,
+ -1, -1,
+ /*0x1fda*/ 796,
+ /*0x005a*/ 24,
+ /*0x015a*/ 101,
+ /*0x03ea*/ 284,
+ /*0x1fd8*/ 794,
+ /*0x0058*/ 22,
+ /*0x0158*/ 100,
+ -1,
+ /*0x1f4c*/ 703,
+ -1,
+ /*0x10c2*/ 518,
+ /*0x0246*/ 224,
+ /*0x03ab*/ 267,
+ -1,
+ /*0x24c2*/ 851,
+ /*0x1e68*/ 591,
+ /*0x04ec*/ 411,
+ -1,
+ /*0xa642*/ 981,
+ -1,
+ /*0xa742*/ 1032,
+ /*0x2cda*/ 972,
+ /*0xa650*/ 988,
+ /*0x1ee0*/ 653,
+ /*0xa750*/ 1039,
+ /*0x2cd8*/ 971,
+ /*0xa652*/ 989,
+ /*0x00da*/ 51,
+ /*0xa752*/ 1040,
+ /*0x0054*/ 18,
+ /*0x0154*/ 98,
+ /*0x00d8*/ 49,
+ -1,
+ /*0x03e8*/ 283,
+ -1,
+ /*0x04ea*/ 410,
+ /*0x2cc0*/ 959,
+ /*0x1f3c*/ 695,
+ /*0x1eee*/ 660,
+ /*0x1e64*/ 589,
+ -1, -1,
+ /*0x00c0*/ 26,
+ -1, -1,
+ /*0x015e*/ 103,
+ /*0x1fc7*/ 784,
+ /*0x0047*/ 6,
+ /*0x0147*/ 91,
+ /*0x2cd4*/ 969,
+ -1, -1,
+ /*0x053f*/ 459,
+ /*0x1ee6*/ 656,
+ /*0x24ce*/ 863,
+ /*0x00d4*/ 46,
+ -1,
+ /*0x03e4*/ 281,
+ /*0xa64e*/ 987,
+ /*0x104bf*/ 1261,
+ /*0xa74e*/ 1038,
+ -1, -1,
+ /*0x1f3e*/ 697,
+ /*0x2cde*/ 974,
+ /*0x04e8*/ 409,
+ /*0x1fb9*/ 775,
+ -1,
+ /*0x0139*/ 84,
+ -1,
+ /*0x00de*/ 55,
+ /*0xabb9*/ 1161,
+ /*0x1eda*/ 650,
+ /*0x00c7*/ 33,
+ -1, -1,
+ /*0x1ed8*/ 649,
+ -1, -1,
+ /*0x24c6*/ 855,
+ /*0x03a9*/ 265,
+ -1, -1,
+ /*0xa646*/ 983,
+ /*0x216c*/ 834,
+ /*0xa746*/ 1034,
+ -1,
+ /*0x1ec0*/ 637,
+ -1,
+ /*0x04e4*/ 407,
+ -1,
+ /*0x015c*/ 102,
+ /*0x1fa1*/ 754,
+ /*0x0421*/ 330,
+ -1,
+ /*0x10421*/ 1239,
+ -1,
+ /*0xaba1*/ 1137,
+ -1,
+ /*0x1e60*/ 587,
+ /*0x1ed4*/ 647,
+ /*0x01fc*/ 188,
+ /*0x2c21*/ 898,
+ /*0x216a*/ 832,
+ -1, -1, -1,
+ /*0xa66c*/ 1002,
+ -1,
+ /*0xa76c*/ 1053,
+ /*0x2cdc*/ 973,
+ -1,
+ /*0x212b*/ 820,
+ -1,
+ /*0x1e6e*/ 594,
+ /*0x1ede*/ 652,
+ /*0x00dc*/ 53,
+ /*0x03e0*/ 279,
+ -1, -1,
+ /*0x01ec*/ 178,
+ /*0x10ca1*/ 1315,
+ -1,
+ /*0x1f48*/ 699,
+ /*0x0045*/ 4,
+ /*0x0145*/ 90,
+ /*0xa66a*/ 1001,
+ /*0x10ab*/ 495,
+ /*0xa76a*/ 1052,
+ /*0x1e66*/ 590,
+ -1,
+ /*0x1e921*/ 1398,
+ /*0x03ee*/ 286,
+ /*0x2168*/ 830,
+ -1,
+ /*0x1fc3*/ 781,
+ /*0x0043*/ 2,
+ /*0x0143*/ 89,
+ -1,
+ /*0x01ea*/ 177,
+ /*0x10bf*/ 515,
+ /*0xfb05*/ 1173,
+ -1,
+ /*0x0345*/ 229,
+ /*0x24bf*/ 848,
+ -1, -1,
+ /*0x03e6*/ 282,
+ /*0x1e5a*/ 584,
+ /*0x04e0*/ 405,
+ /*0x00c5*/ 31,
+ /*0x0181*/ 121,
+ /*0x1e58*/ 583,
+ -1, -1, -1,
+ /*0xa668*/ 1000,
+ /*0x2164*/ 826,
+ /*0xa768*/ 1051,
+ -1, -1,
+ /*0x1edc*/ 651,
+ /*0x00c3*/ 29,
+ /*0x1e40*/ 571,
+ /*0x04ee*/ 412,
+ /*0x118ab*/ 1344,
+ /*0x03da*/ 276,
+ -1, -1,
+ /*0x01e8*/ 176,
+ /*0x03d8*/ 275,
+ -1,
+ /*0x1f56*/ 708,
+ -1, -1, -1,
+ /*0x1e54*/ 581,
+ -1,
+ /*0x118bf*/ 1364,
+ /*0x04e6*/ 408,
+ /*0xa664*/ 998,
+ /*0x053d*/ 457,
+ /*0xa764*/ 1049,
+ /*0x1fc9*/ 786,
+ /*0x0049*/ 1399,
+ /*0x0149*/ 92,
+ -1, -1,
+ /*0x104bd*/ 1259,
+ /*0x1f97*/ 744,
+ /*0x0417*/ 320,
+ /*0x1e5e*/ 586,
+ /*0x10417*/ 1229,
+ /*0x01e4*/ 174,
+ /*0xab97*/ 1127,
+ /*0x10a9*/ 493,
+ /*0x1fad*/ 766,
+ /*0x042d*/ 342,
+ /*0x04da*/ 402,
+ /*0x2c17*/ 888,
+ -1,
+ /*0xabad*/ 1149,
+ /*0x04d8*/ 401,
+ /*0xff2b*/ 1190,
+ -1,
+ /*0x023d*/ 218,
+ /*0x2c2d*/ 910,
+ -1,
+ /*0x0540*/ 460,
+ /*0x03de*/ 278,
+ /*0x00c9*/ 35,
+ -1, -1,
+ /*0x04c0*/ 389,
+ -1,
+ /*0x104c0*/ 1262,
+ /*0x01a9*/ 146,
+ /*0x2160*/ 822,
+ /*0x10c97*/ 1305,
+ -1, -1,
+ /*0x0554*/ 480,
+ /*0x1fb3*/ 770,
+ -1,
+ /*0xa7ad*/ 1080,
+ /*0x10cad*/ 1327,
+ /*0x04d4*/ 399,
+ /*0xabb3*/ 1155,
+ /*0x1e917*/ 1388,
+ -1, -1, -1,
+ /*0x216e*/ 836,
+ /*0x118a9*/ 1342,
+ -1, -1, -1,
+ /*0x1e5c*/ 585,
+ -1,
+ /*0x0547*/ 467,
+ /*0xa660*/ 996,
+ /*0x04de*/ 404,
+ /*0xa760*/ 1047,
+ -1,
+ /*0x04c7*/ 393,
+ /*0x1f50*/ 705,
+ /*0x104c7*/ 1269,
+ /*0x2166*/ 828,
+ -1,
+ /*0x1f52*/ 706,
+ /*0xa7b3*/ 1085,
+ -1, -1,
+ /*0x01e0*/ 172,
+ -1,
+ /*0x03dc*/ 277,
+ -1,
+ /*0xa76e*/ 1054,
+ /*0x03a1*/ 258,
+ /*0x0539*/ 453,
+ -1,
+ /*0x1e97*/ 615,
+ -1, -1, -1, -1,
+ /*0x104b9*/ 1255,
+ -1,
+ /*0x01ee*/ 179,
+ /*0x10bd*/ 513,
+ /*0xa666*/ 999,
+ /*0xff29*/ 1188,
+ /*0xa766*/ 1050,
+ /*0x24bd*/ 846,
+ /*0x1fa5*/ 758,
+ /*0x0425*/ 334,
+ -1,
+ /*0x10425*/ 1243,
+ -1,
+ /*0xaba5*/ 1141,
+ /*0x1fb7*/ 773,
+ -1, -1,
+ /*0x01e6*/ 175,
+ /*0x2c25*/ 902,
+ /*0xabb7*/ 1159,
+ -1,
+ /*0x04dc*/ 403,
+ -1,
+ /*0xa65a*/ 993,
+ -1,
+ /*0xa75a*/ 1044,
+ -1,
+ /*0xa658*/ 992,
+ -1,
+ /*0xa758*/ 1043,
+ /*0x10c0*/ 516,
+ -1, -1, -1,
+ /*0x24c0*/ 849,
+ -1, -1,
+ /*0x10ca5*/ 1319,
+ /*0xa640*/ 980,
+ -1,
+ /*0xa740*/ 1031,
+ /*0x118bd*/ 1362,
+ /*0x1fa3*/ 756,
+ /*0x0423*/ 332,
+ -1,
+ /*0x10423*/ 1241,
+ /*0x1c84*/ 534,
+ /*0xaba3*/ 1139,
+ -1, -1,
+ /*0x0545*/ 465,
+ /*0xa654*/ 990,
+ /*0x2c23*/ 900,
+ /*0xa754*/ 1041,
+ -1,
+ /*0x04c5*/ 392,
+ -1,
+ /*0x104c5*/ 1267,
+ -1, -1,
+ /*0x1c82*/ 532,
+ /*0x10c7*/ 522,
+ /*0x0543*/ 463,
+ -1,
+ /*0x1f6c*/ 717,
+ /*0x24c7*/ 856,
+ /*0xa65e*/ 995,
+ /*0x04c3*/ 391,
+ /*0xa75e*/ 1046,
+ /*0x104c3*/ 1265,
+ -1,
+ /*0x10ca3*/ 1317,
+ -1, -1,
+ /*0x0245*/ 223,
+ /*0x1ff4*/ 810,
+ /*0x0474*/ 355,
+ /*0x0174*/ 114,
+ -1,
+ /*0x01de*/ 171,
+ -1,
+ /*0x10b9*/ 509,
+ /*0x01c7*/ 159,
+ /*0x1f6a*/ 715,
+ /*0xfb01*/ 1169,
+ /*0x24b9*/ 842,
+ /*0x0243*/ 221,
+ -1, -1,
+ /*0x0397*/ 248,
+ -1, -1,
+ /*0x1f2b*/ 686,
+ /*0x1f9d*/ 750,
+ /*0x041d*/ 326,
+ -1,
+ /*0x1041d*/ 1235,
+ /*0xabb1*/ 1153,
+ /*0xab9d*/ 1133,
+ /*0x0470*/ 353,
+ /*0x0170*/ 112,
+ /*0x1f9b*/ 748,
+ /*0x041b*/ 324,
+ /*0x2c1d*/ 894,
+ /*0x1041b*/ 1233,
+ /*0x1f3f*/ 698,
+ /*0xab9b*/ 1131,
+ /*0x10a1*/ 485,
+ /*0x2c70*/ 922,
+ /*0xabb5*/ 1157,
+ /*0x0549*/ 469,
+ /*0x2c1b*/ 892,
+ /*0xa65c*/ 994,
+ /*0x1f68*/ 713,
+ /*0xa75c*/ 1045,
+ /*0x04c9*/ 394,
+ -1,
+ /*0x104c9*/ 1271,
+ /*0x0370*/ 230,
+ /*0x118b9*/ 1358,
+ /*0xa7b1*/ 1083,
+ /*0x10cb1*/ 1331,
+ /*0x10c9d*/ 1311,
+ -1,
+ /*0x1f99*/ 746,
+ /*0x0419*/ 322,
+ -1,
+ /*0x10419*/ 1231,
+ -1,
+ /*0xab99*/ 1129,
+ /*0x10c9b*/ 1309,
+ /*0x00b5*/ 25,
+ /*0x1e91d*/ 1394,
+ -1,
+ /*0x2c19*/ 890,
+ -1,
+ /*0x1f93*/ 740,
+ /*0x0413*/ 316,
+ /*0x10c5*/ 521,
+ /*0x10413*/ 1225,
+ /*0x1e91b*/ 1392,
+ /*0xab93*/ 1123,
+ /*0x24c5*/ 854,
+ -1, -1,
+ /*0x118a1*/ 1334,
+ /*0x2c13*/ 884,
+ /*0x1ef4*/ 663,
+ -1,
+ /*0x0533*/ 447,
+ /*0x10c3*/ 519,
+ /*0x0041*/ 0,
+ /*0x0141*/ 88,
+ /*0x10c99*/ 1307,
+ /*0x24c3*/ 852,
+ -1,
+ /*0x104b3*/ 1249,
+ /*0xff39*/ 1204,
+ -1,
+ /*0x01c5*/ 158,
+ /*0x1f29*/ 684,
+ -1, -1,
+ /*0x1e919*/ 1390,
+ -1,
+ /*0x10c93*/ 1301,
+ /*0x1f8f*/ 736,
+ /*0x040f*/ 312,
+ -1,
+ /*0x1040f*/ 1221,
+ /*0x1ef0*/ 661,
+ /*0xab8f*/ 1119,
+ -1,
+ /*0x1e9b*/ 619,
+ /*0x03a5*/ 261,
+ /*0x1e913*/ 1384,
+ /*0x2c0f*/ 880,
+ /*0x00c1*/ 27,
+ -1, -1, -1,
+ /*0x1f8b*/ 732,
+ /*0x040b*/ 308,
+ /*0xff21*/ 1180,
+ /*0x1040b*/ 1217,
+ -1,
+ /*0xab8b*/ 1115,
+ /*0x1f87*/ 728,
+ /*0x0407*/ 304,
+ /*0xab7b*/ 1099,
+ /*0x10407*/ 1213,
+ /*0x2c0b*/ 876,
+ /*0xab87*/ 1111,
+ /*0x0587*/ 483,
+ -1,
+ /*0x10c8f*/ 1297,
+ /*0x1e99*/ 617,
+ /*0x2c07*/ 872,
+ /*0x004f*/ 13,
+ -1, -1, -1,
+ /*0x24c9*/ 858,
+ -1,
+ /*0xab79*/ 1097,
+ /*0x1e90f*/ 1380,
+ -1,
+ /*0x0537*/ 451,
+ /*0x03a3*/ 259,
+ /*0xa78b*/ 1063,
+ /*0x10c8b*/ 1293,
+ /*0x10ad*/ 497,
+ /*0x1f6e*/ 719,
+ -1,
+ /*0x104b7*/ 1253,
+ -1,
+ /*0x10c87*/ 1289,
+ -1, -1, -1,
+ /*0x1e90b*/ 1376,
+ -1, -1,
+ /*0x1e74*/ 597,
+ /*0x00cf*/ 41,
+ /*0x0197*/ 136,
+ /*0x1e907*/ 1372,
+ -1,
+ /*0xab71*/ 1089,
+ /*0xab73*/ 1091,
+ -1, -1, -1, -1,
+ /*0x1f3d*/ 696,
+ -1, -1,
+ /*0x10b3*/ 503,
+ -1,
+ /*0xab7f*/ 1103,
+ -1,
+ /*0x03f4*/ 289,
+ /*0x1f9f*/ 752,
+ /*0x041f*/ 328,
+ /*0xab7d*/ 1101,
+ /*0x1041f*/ 1237,
+ /*0x1e70*/ 595,
+ /*0xab9f*/ 1135,
+ -1,
+ /*0x118ad*/ 1346,
+ -1, -1,
+ /*0x2c1f*/ 896,
+ -1, -1, -1, -1, -1,
+ /*0x01b3*/ 152,
+ /*0x039d*/ 254,
+ -1, -1, -1, -1,
+ /*0x03f0*/ 287,
+ /*0xab75*/ 1093,
+ -1,
+ /*0x039b*/ 252,
+ -1, -1, -1,
+ /*0x10c9f*/ 1313,
+ -1,
+ /*0x04f4*/ 415,
+ /*0x1f54*/ 707,
+ /*0x118b3*/ 1352,
+ -1,
+ /*0x1ff8*/ 813,
+ /*0x0478*/ 357,
+ /*0x0178*/ 116,
+ -1,
+ /*0x1e91f*/ 1396,
+ -1, -1, -1,
+ /*0x0531*/ 445,
+ -1,
+ /*0xff2d*/ 1192,
+ -1,
+ /*0x10a5*/ 489,
+ /*0x0399*/ 250,
+ -1,
+ /*0x104b1*/ 1247,
+ -1, -1,
+ /*0x10b7*/ 507,
+ /*0x04f0*/ 413,
+ /*0x0535*/ 449,
+ -1,
+ /*0x24b7*/ 840,
+ /*0x1f95*/ 742,
+ /*0x0415*/ 318,
+ /*0x0393*/ 244,
+ /*0x10415*/ 1227,
+ /*0x104b5*/ 1251,
+ /*0xab95*/ 1125,
+ -1, -1, -1, -1,
+ /*0x2c15*/ 886,
+ -1,
+ /*0x1f39*/ 692,
+ /*0xff33*/ 1198,
+ -1, -1,
+ /*0x01b7*/ 154,
+ -1, -1, -1, -1,
+ /*0xab77*/ 1095,
+ -1,
+ /*0x10a3*/ 487,
+ -1,
+ /*0x1f91*/ 738,
+ /*0x0411*/ 314,
+ /*0x118a5*/ 1338,
+ /*0x10411*/ 1223,
+ /*0x10c95*/ 1303,
+ /*0xab91*/ 1121,
+ -1,
+ /*0x038f*/ 240,
+ /*0x118b7*/ 1356,
+ -1,
+ /*0x2c11*/ 882,
+ -1, -1, -1,
+ /*0x1e915*/ 1386,
+ -1,
+ /*0x1f8d*/ 734,
+ /*0x040d*/ 310,
+ /*0x0541*/ 461,
+ /*0x1040d*/ 1219,
+ -1,
+ /*0xab8d*/ 1117,
+ -1,
+ /*0x04c1*/ 390,
+ /*0x1ef8*/ 665,
+ /*0x104c1*/ 1263,
+ /*0x2c0d*/ 878,
+ -1, -1,
+ /*0x10c91*/ 1299,
+ -1, -1, -1, -1, -1, -1,
+ /*0x118a3*/ 1336,
+ -1,
+ /*0x03cf*/ 270,
+ /*0x1e911*/ 1382,
+ /*0xff25*/ 1184,
+ -1,
+ /*0x0241*/ 220,
+ -1,
+ /*0xa78d*/ 1064,
+ /*0x10c8d*/ 1295,
+ /*0xff37*/ 1202,
+ -1,
+ /*0x10b1*/ 501,
+ -1, -1, -1,
+ /*0x01f4*/ 183,
+ -1, -1,
+ /*0x1e90d*/ 1378,
+ -1, -1, -1, -1,
+ /*0x10b5*/ 505,
+ -1, -1, -1,
+ /*0x13f8*/ 524,
+ /*0x054f*/ 475,
+ -1, -1, -1,
+ /*0x01b1*/ 150,
+ /*0x019d*/ 139,
+ -1,
+ /*0x104cf*/ 1277,
+ -1,
+ /*0xff23*/ 1182,
+ /*0x01f0*/ 180,
+ -1, -1, -1, -1, -1,
+ /*0x01b5*/ 153,
+ -1,
+ /*0x039f*/ 256,
+ -1, -1,
+ /*0x118b1*/ 1350,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x118b5*/ 1354,
+ /*0xfb17*/ 1179,
+ /*0x1e78*/ 599,
+ -1, -1, -1,
+ /*0x1f49*/ 700,
+ -1,
+ /*0x10c1*/ 517,
+ -1, -1, -1,
+ /*0x24c1*/ 850,
+ -1, -1,
+ /*0x0193*/ 133,
+ -1, -1, -1,
+ /*0x1f2d*/ 688,
+ -1, -1, -1, -1, -1, -1,
+ /*0xff31*/ 1196,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0xff35*/ 1200,
+ -1, -1, -1, -1,
+ /*0x0395*/ 246,
+ -1,
+ /*0x018f*/ 130,
+ -1, -1, -1, -1, -1, -1,
+ /*0x04f8*/ 417,
+ -1, -1, -1, -1, -1,
+ /*0xab76*/ 1094,
+ /*0x24cf*/ 864,
+ /*0x018b*/ 128,
+ -1, -1, -1, -1, -1,
+ /*0x0187*/ 125,
+ -1,
+ /*0x0391*/ 242,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x01cf*/ 164,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x019f*/ 140,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x1c85*/ 535,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x01f8*/ 186,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x1f1d*/ 682,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x1f1b*/ 680,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x0191*/ 132,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x1f19*/ 678,
+ /*0xfb13*/ 1175,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x1f0f*/ 676,
+ -1, -1, -1, -1,
+ /*0xab7e*/ 1102,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x1f0b*/ 672,
+ -1, -1, -1, -1,
+ /*0xab72*/ 1090,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x1c81*/ 531,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0xfb15*/ 1177,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x1f0d*/ 674,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0xab7a*/ 1098,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xab7c*/ 1100,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x1c87*/ 537,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0xab74*/ 1092,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xab70*/ 1088,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xab78*/ 1096
+ };
+
+ if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseFold_11_hash(code);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code1_equal(code, CaseFold_11_Table[s].from))
+ return &CaseFold_11_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const CaseUnfold_11_Type CaseUnfold_11_Table[] = {
+#define CaseUnfold_11 (*(CaseUnfold_11_Type (*)[1266])(CaseUnfold_11_Table+0))
+ {0x0061, {1|U, {0x0041}}},
+ {0x0062, {1|U, {0x0042}}},
+ {0x0063, {1|U, {0x0043}}},
+ {0x0064, {1|U, {0x0044}}},
+ {0x0065, {1|U, {0x0045}}},
+ {0x0066, {1|U, {0x0046}}},
+ {0x0067, {1|U, {0x0047}}},
+ {0x0068, {1|U, {0x0048}}},
+ {0x006a, {1|U, {0x004a}}},
+ {0x006b, {2|U, {0x004b, 0x212a}}},
+ {0x006c, {1|U, {0x004c}}},
+ {0x006d, {1|U, {0x004d}}},
+ {0x006e, {1|U, {0x004e}}},
+ {0x006f, {1|U, {0x004f}}},
+ {0x0070, {1|U, {0x0050}}},
+ {0x0071, {1|U, {0x0051}}},
+ {0x0072, {1|U, {0x0052}}},
+ {0x0073, {2|U, {0x0053, 0x017f}}},
+ {0x0074, {1|U, {0x0054}}},
+ {0x0075, {1|U, {0x0055}}},
+ {0x0076, {1|U, {0x0056}}},
+ {0x0077, {1|U, {0x0057}}},
+ {0x0078, {1|U, {0x0058}}},
+ {0x0079, {1|U, {0x0059}}},
+ {0x007a, {1|U, {0x005a}}},
+ {0x00e0, {1|U, {0x00c0}}},
+ {0x00e1, {1|U, {0x00c1}}},
+ {0x00e2, {1|U, {0x00c2}}},
+ {0x00e3, {1|U, {0x00c3}}},
+ {0x00e4, {1|U, {0x00c4}}},
+ {0x00e5, {2|U, {0x00c5, 0x212b}}},
+ {0x00e6, {1|U, {0x00c6}}},
+ {0x00e7, {1|U, {0x00c7}}},
+ {0x00e8, {1|U, {0x00c8}}},
+ {0x00e9, {1|U, {0x00c9}}},
+ {0x00ea, {1|U, {0x00ca}}},
+ {0x00eb, {1|U, {0x00cb}}},
+ {0x00ec, {1|U, {0x00cc}}},
+ {0x00ed, {1|U, {0x00cd}}},
+ {0x00ee, {1|U, {0x00ce}}},
+ {0x00ef, {1|U, {0x00cf}}},
+ {0x00f0, {1|U, {0x00d0}}},
+ {0x00f1, {1|U, {0x00d1}}},
+ {0x00f2, {1|U, {0x00d2}}},
+ {0x00f3, {1|U, {0x00d3}}},
+ {0x00f4, {1|U, {0x00d4}}},
+ {0x00f5, {1|U, {0x00d5}}},
+ {0x00f6, {1|U, {0x00d6}}},
+ {0x00f8, {1|U, {0x00d8}}},
+ {0x00f9, {1|U, {0x00d9}}},
+ {0x00fa, {1|U, {0x00da}}},
+ {0x00fb, {1|U, {0x00db}}},
+ {0x00fc, {1|U, {0x00dc}}},
+ {0x00fd, {1|U, {0x00dd}}},
+ {0x00fe, {1|U, {0x00de}}},
+ {0x00ff, {1|U, {0x0178}}},
+ {0x0101, {1|U, {0x0100}}},
+ {0x0103, {1|U, {0x0102}}},
+ {0x0105, {1|U, {0x0104}}},
+ {0x0107, {1|U, {0x0106}}},
+ {0x0109, {1|U, {0x0108}}},
+ {0x010b, {1|U, {0x010a}}},
+ {0x010d, {1|U, {0x010c}}},
+ {0x010f, {1|U, {0x010e}}},
+ {0x0111, {1|U, {0x0110}}},
+ {0x0113, {1|U, {0x0112}}},
+ {0x0115, {1|U, {0x0114}}},
+ {0x0117, {1|U, {0x0116}}},
+ {0x0119, {1|U, {0x0118}}},
+ {0x011b, {1|U, {0x011a}}},
+ {0x011d, {1|U, {0x011c}}},
+ {0x011f, {1|U, {0x011e}}},
+ {0x0121, {1|U, {0x0120}}},
+ {0x0123, {1|U, {0x0122}}},
+ {0x0125, {1|U, {0x0124}}},
+ {0x0127, {1|U, {0x0126}}},
+ {0x0129, {1|U, {0x0128}}},
+ {0x012b, {1|U, {0x012a}}},
+ {0x012d, {1|U, {0x012c}}},
+ {0x012f, {1|U, {0x012e}}},
+ {0x0133, {1|U, {0x0132}}},
+ {0x0135, {1|U, {0x0134}}},
+ {0x0137, {1|U, {0x0136}}},
+ {0x013a, {1|U, {0x0139}}},
+ {0x013c, {1|U, {0x013b}}},
+ {0x013e, {1|U, {0x013d}}},
+ {0x0140, {1|U, {0x013f}}},
+ {0x0142, {1|U, {0x0141}}},
+ {0x0144, {1|U, {0x0143}}},
+ {0x0146, {1|U, {0x0145}}},
+ {0x0148, {1|U, {0x0147}}},
+ {0x014b, {1|U, {0x014a}}},
+ {0x014d, {1|U, {0x014c}}},
+ {0x014f, {1|U, {0x014e}}},
+ {0x0151, {1|U, {0x0150}}},
+ {0x0153, {1|U, {0x0152}}},
+ {0x0155, {1|U, {0x0154}}},
+ {0x0157, {1|U, {0x0156}}},
+ {0x0159, {1|U, {0x0158}}},
+ {0x015b, {1|U, {0x015a}}},
+ {0x015d, {1|U, {0x015c}}},
+ {0x015f, {1|U, {0x015e}}},
+ {0x0161, {1|U, {0x0160}}},
+ {0x0163, {1|U, {0x0162}}},
+ {0x0165, {1|U, {0x0164}}},
+ {0x0167, {1|U, {0x0166}}},
+ {0x0169, {1|U, {0x0168}}},
+ {0x016b, {1|U, {0x016a}}},
+ {0x016d, {1|U, {0x016c}}},
+ {0x016f, {1|U, {0x016e}}},
+ {0x0171, {1|U, {0x0170}}},
+ {0x0173, {1|U, {0x0172}}},
+ {0x0175, {1|U, {0x0174}}},
+ {0x0177, {1|U, {0x0176}}},
+ {0x017a, {1|U, {0x0179}}},
+ {0x017c, {1|U, {0x017b}}},
+ {0x017e, {1|U, {0x017d}}},
+ {0x0180, {1|U, {0x0243}}},
+ {0x0183, {1|U, {0x0182}}},
+ {0x0185, {1|U, {0x0184}}},
+ {0x0188, {1|U, {0x0187}}},
+ {0x018c, {1|U, {0x018b}}},
+ {0x0192, {1|U, {0x0191}}},
+ {0x0195, {1|U, {0x01f6}}},
+ {0x0199, {1|U, {0x0198}}},
+ {0x019a, {1|U, {0x023d}}},
+ {0x019e, {1|U, {0x0220}}},
+ {0x01a1, {1|U, {0x01a0}}},
+ {0x01a3, {1|U, {0x01a2}}},
+ {0x01a5, {1|U, {0x01a4}}},
+ {0x01a8, {1|U, {0x01a7}}},
+ {0x01ad, {1|U, {0x01ac}}},
+ {0x01b0, {1|U, {0x01af}}},
+ {0x01b4, {1|U, {0x01b3}}},
+ {0x01b6, {1|U, {0x01b5}}},
+ {0x01b9, {1|U, {0x01b8}}},
+ {0x01bd, {1|U, {0x01bc}}},
+ {0x01bf, {1|U, {0x01f7}}},
+ {0x01c6, {2|U|ST, {0x01c4, 0x01c5}}},
+ {0x01c9, {2|U|ST, {0x01c7, 0x01c8}}},
+ {0x01cc, {2|U|ST, {0x01ca, 0x01cb}}},
+ {0x01ce, {1|U, {0x01cd}}},
+ {0x01d0, {1|U, {0x01cf}}},
+ {0x01d2, {1|U, {0x01d1}}},
+ {0x01d4, {1|U, {0x01d3}}},
+ {0x01d6, {1|U, {0x01d5}}},
+ {0x01d8, {1|U, {0x01d7}}},
+ {0x01da, {1|U, {0x01d9}}},
+ {0x01dc, {1|U, {0x01db}}},
+ {0x01dd, {1|U, {0x018e}}},
+ {0x01df, {1|U, {0x01de}}},
+ {0x01e1, {1|U, {0x01e0}}},
+ {0x01e3, {1|U, {0x01e2}}},
+ {0x01e5, {1|U, {0x01e4}}},
+ {0x01e7, {1|U, {0x01e6}}},
+ {0x01e9, {1|U, {0x01e8}}},
+ {0x01eb, {1|U, {0x01ea}}},
+ {0x01ed, {1|U, {0x01ec}}},
+ {0x01ef, {1|U, {0x01ee}}},
+ {0x01f3, {2|U|ST, {0x01f1, 0x01f2}}},
+ {0x01f5, {1|U, {0x01f4}}},
+ {0x01f9, {1|U, {0x01f8}}},
+ {0x01fb, {1|U, {0x01fa}}},
+ {0x01fd, {1|U, {0x01fc}}},
+ {0x01ff, {1|U, {0x01fe}}},
+ {0x0201, {1|U, {0x0200}}},
+ {0x0203, {1|U, {0x0202}}},
+ {0x0205, {1|U, {0x0204}}},
+ {0x0207, {1|U, {0x0206}}},
+ {0x0209, {1|U, {0x0208}}},
+ {0x020b, {1|U, {0x020a}}},
+ {0x020d, {1|U, {0x020c}}},
+ {0x020f, {1|U, {0x020e}}},
+ {0x0211, {1|U, {0x0210}}},
+ {0x0213, {1|U, {0x0212}}},
+ {0x0215, {1|U, {0x0214}}},
+ {0x0217, {1|U, {0x0216}}},
+ {0x0219, {1|U, {0x0218}}},
+ {0x021b, {1|U, {0x021a}}},
+ {0x021d, {1|U, {0x021c}}},
+ {0x021f, {1|U, {0x021e}}},
+ {0x0223, {1|U, {0x0222}}},
+ {0x0225, {1|U, {0x0224}}},
+ {0x0227, {1|U, {0x0226}}},
+ {0x0229, {1|U, {0x0228}}},
+ {0x022b, {1|U, {0x022a}}},
+ {0x022d, {1|U, {0x022c}}},
+ {0x022f, {1|U, {0x022e}}},
+ {0x0231, {1|U, {0x0230}}},
+ {0x0233, {1|U, {0x0232}}},
+ {0x023c, {1|U, {0x023b}}},
+ {0x023f, {1|U, {0x2c7e}}},
+ {0x0240, {1|U, {0x2c7f}}},
+ {0x0242, {1|U, {0x0241}}},
+ {0x0247, {1|U, {0x0246}}},
+ {0x0249, {1|U, {0x0248}}},
+ {0x024b, {1|U, {0x024a}}},
+ {0x024d, {1|U, {0x024c}}},
+ {0x024f, {1|U, {0x024e}}},
+ {0x0250, {1|U, {0x2c6f}}},
+ {0x0251, {1|U, {0x2c6d}}},
+ {0x0252, {1|U, {0x2c70}}},
+ {0x0253, {1|U, {0x0181}}},
+ {0x0254, {1|U, {0x0186}}},
+ {0x0256, {1|U, {0x0189}}},
+ {0x0257, {1|U, {0x018a}}},
+ {0x0259, {1|U, {0x018f}}},
+ {0x025b, {1|U, {0x0190}}},
+ {0x025c, {1|U, {0xa7ab}}},
+ {0x0260, {1|U, {0x0193}}},
+ {0x0261, {1|U, {0xa7ac}}},
+ {0x0263, {1|U, {0x0194}}},
+ {0x0265, {1|U, {0xa78d}}},
+ {0x0266, {1|U, {0xa7aa}}},
+ {0x0268, {1|U, {0x0197}}},
+ {0x0269, {1|U, {0x0196}}},
+ {0x026a, {1|U, {0xa7ae}}},
+ {0x026b, {1|U, {0x2c62}}},
+ {0x026c, {1|U, {0xa7ad}}},
+ {0x026f, {1|U, {0x019c}}},
+ {0x0271, {1|U, {0x2c6e}}},
+ {0x0272, {1|U, {0x019d}}},
+ {0x0275, {1|U, {0x019f}}},
+ {0x027d, {1|U, {0x2c64}}},
+ {0x0280, {1|U, {0x01a6}}},
+ {0x0283, {1|U, {0x01a9}}},
+ {0x0287, {1|U, {0xa7b1}}},
+ {0x0288, {1|U, {0x01ae}}},
+ {0x0289, {1|U, {0x0244}}},
+ {0x028a, {1|U, {0x01b1}}},
+ {0x028b, {1|U, {0x01b2}}},
+ {0x028c, {1|U, {0x0245}}},
+ {0x0292, {1|U, {0x01b7}}},
+ {0x029d, {1|U, {0xa7b2}}},
+ {0x029e, {1|U, {0xa7b0}}},
+ {0x0371, {1|U, {0x0370}}},
+ {0x0373, {1|U, {0x0372}}},
+ {0x0377, {1|U, {0x0376}}},
+ {0x037b, {1|U, {0x03fd}}},
+ {0x037c, {1|U, {0x03fe}}},
+ {0x037d, {1|U, {0x03ff}}},
+ {0x03ac, {1|U, {0x0386}}},
+ {0x03ad, {1|U, {0x0388}}},
+ {0x03ae, {1|U, {0x0389}}},
+ {0x03af, {1|U, {0x038a}}},
+ {0x03b1, {1|U, {0x0391}}},
+ {0x03b2, {2|U, {0x0392, 0x03d0}}},
+ {0x03b3, {1|U, {0x0393}}},
+ {0x03b4, {1|U, {0x0394}}},
+ {0x03b5, {2|U, {0x0395, 0x03f5}}},
+ {0x03b6, {1|U, {0x0396}}},
+ {0x03b7, {1|U, {0x0397}}},
+ {0x03b8, {3|U, {0x0398, 0x03d1, 0x03f4}}},
+ {0x03b9, {3|U, {0x0399, 0x0345, 0x1fbe}}},
+ {0x03ba, {2|U, {0x039a, 0x03f0}}},
+ {0x03bb, {1|U, {0x039b}}},
+ {0x03bc, {2|U, {0x039c, 0x00b5}}},
+ {0x03bd, {1|U, {0x039d}}},
+ {0x03be, {1|U, {0x039e}}},
+ {0x03bf, {1|U, {0x039f}}},
+ {0x03c0, {2|U, {0x03a0, 0x03d6}}},
+ {0x03c1, {2|U, {0x03a1, 0x03f1}}},
+ {0x03c3, {2|U, {0x03a3, 0x03c2}}},
+ {0x03c4, {1|U, {0x03a4}}},
+ {0x03c5, {1|U, {0x03a5}}},
+ {0x03c6, {2|U, {0x03a6, 0x03d5}}},
+ {0x03c7, {1|U, {0x03a7}}},
+ {0x03c8, {1|U, {0x03a8}}},
+ {0x03c9, {2|U, {0x03a9, 0x2126}}},
+ {0x03ca, {1|U, {0x03aa}}},
+ {0x03cb, {1|U, {0x03ab}}},
+ {0x03cc, {1|U, {0x038c}}},
+ {0x03cd, {1|U, {0x038e}}},
+ {0x03ce, {1|U, {0x038f}}},
+ {0x03d7, {1|U, {0x03cf}}},
+ {0x03d9, {1|U, {0x03d8}}},
+ {0x03db, {1|U, {0x03da}}},
+ {0x03dd, {1|U, {0x03dc}}},
+ {0x03df, {1|U, {0x03de}}},
+ {0x03e1, {1|U, {0x03e0}}},
+ {0x03e3, {1|U, {0x03e2}}},
+ {0x03e5, {1|U, {0x03e4}}},
+ {0x03e7, {1|U, {0x03e6}}},
+ {0x03e9, {1|U, {0x03e8}}},
+ {0x03eb, {1|U, {0x03ea}}},
+ {0x03ed, {1|U, {0x03ec}}},
+ {0x03ef, {1|U, {0x03ee}}},
+ {0x03f2, {1|U, {0x03f9}}},
+ {0x03f3, {1|U, {0x037f}}},
+ {0x03f8, {1|U, {0x03f7}}},
+ {0x03fb, {1|U, {0x03fa}}},
+ {0x0430, {1|U, {0x0410}}},
+ {0x0431, {1|U, {0x0411}}},
+ {0x0432, {2|U, {0x0412, 0x1c80}}},
+ {0x0433, {1|U, {0x0413}}},
+ {0x0434, {2|U, {0x0414, 0x1c81}}},
+ {0x0435, {1|U, {0x0415}}},
+ {0x0436, {1|U, {0x0416}}},
+ {0x0437, {1|U, {0x0417}}},
+ {0x0438, {1|U, {0x0418}}},
+ {0x0439, {1|U, {0x0419}}},
+ {0x043a, {1|U, {0x041a}}},
+ {0x043b, {1|U, {0x041b}}},
+ {0x043c, {1|U, {0x041c}}},
+ {0x043d, {1|U, {0x041d}}},
+ {0x043e, {2|U, {0x041e, 0x1c82}}},
+ {0x043f, {1|U, {0x041f}}},
+ {0x0440, {1|U, {0x0420}}},
+ {0x0441, {2|U, {0x0421, 0x1c83}}},
+ {0x0442, {3|U, {0x0422, 0x1c84, 0x1c85}}},
+ {0x0443, {1|U, {0x0423}}},
+ {0x0444, {1|U, {0x0424}}},
+ {0x0445, {1|U, {0x0425}}},
+ {0x0446, {1|U, {0x0426}}},
+ {0x0447, {1|U, {0x0427}}},
+ {0x0448, {1|U, {0x0428}}},
+ {0x0449, {1|U, {0x0429}}},
+ {0x044a, {2|U, {0x042a, 0x1c86}}},
+ {0x044b, {1|U, {0x042b}}},
+ {0x044c, {1|U, {0x042c}}},
+ {0x044d, {1|U, {0x042d}}},
+ {0x044e, {1|U, {0x042e}}},
+ {0x044f, {1|U, {0x042f}}},
+ {0x0450, {1|U, {0x0400}}},
+ {0x0451, {1|U, {0x0401}}},
+ {0x0452, {1|U, {0x0402}}},
+ {0x0453, {1|U, {0x0403}}},
+ {0x0454, {1|U, {0x0404}}},
+ {0x0455, {1|U, {0x0405}}},
+ {0x0456, {1|U, {0x0406}}},
+ {0x0457, {1|U, {0x0407}}},
+ {0x0458, {1|U, {0x0408}}},
+ {0x0459, {1|U, {0x0409}}},
+ {0x045a, {1|U, {0x040a}}},
+ {0x045b, {1|U, {0x040b}}},
+ {0x045c, {1|U, {0x040c}}},
+ {0x045d, {1|U, {0x040d}}},
+ {0x045e, {1|U, {0x040e}}},
+ {0x045f, {1|U, {0x040f}}},
+ {0x0461, {1|U, {0x0460}}},
+ {0x0463, {2|U, {0x0462, 0x1c87}}},
+ {0x0465, {1|U, {0x0464}}},
+ {0x0467, {1|U, {0x0466}}},
+ {0x0469, {1|U, {0x0468}}},
+ {0x046b, {1|U, {0x046a}}},
+ {0x046d, {1|U, {0x046c}}},
+ {0x046f, {1|U, {0x046e}}},
+ {0x0471, {1|U, {0x0470}}},
+ {0x0473, {1|U, {0x0472}}},
+ {0x0475, {1|U, {0x0474}}},
+ {0x0477, {1|U, {0x0476}}},
+ {0x0479, {1|U, {0x0478}}},
+ {0x047b, {1|U, {0x047a}}},
+ {0x047d, {1|U, {0x047c}}},
+ {0x047f, {1|U, {0x047e}}},
+ {0x0481, {1|U, {0x0480}}},
+ {0x048b, {1|U, {0x048a}}},
+ {0x048d, {1|U, {0x048c}}},
+ {0x048f, {1|U, {0x048e}}},
+ {0x0491, {1|U, {0x0490}}},
+ {0x0493, {1|U, {0x0492}}},
+ {0x0495, {1|U, {0x0494}}},
+ {0x0497, {1|U, {0x0496}}},
+ {0x0499, {1|U, {0x0498}}},
+ {0x049b, {1|U, {0x049a}}},
+ {0x049d, {1|U, {0x049c}}},
+ {0x049f, {1|U, {0x049e}}},
+ {0x04a1, {1|U, {0x04a0}}},
+ {0x04a3, {1|U, {0x04a2}}},
+ {0x04a5, {1|U, {0x04a4}}},
+ {0x04a7, {1|U, {0x04a6}}},
+ {0x04a9, {1|U, {0x04a8}}},
+ {0x04ab, {1|U, {0x04aa}}},
+ {0x04ad, {1|U, {0x04ac}}},
+ {0x04af, {1|U, {0x04ae}}},
+ {0x04b1, {1|U, {0x04b0}}},
+ {0x04b3, {1|U, {0x04b2}}},
+ {0x04b5, {1|U, {0x04b4}}},
+ {0x04b7, {1|U, {0x04b6}}},
+ {0x04b9, {1|U, {0x04b8}}},
+ {0x04bb, {1|U, {0x04ba}}},
+ {0x04bd, {1|U, {0x04bc}}},
+ {0x04bf, {1|U, {0x04be}}},
+ {0x04c2, {1|U, {0x04c1}}},
+ {0x04c4, {1|U, {0x04c3}}},
+ {0x04c6, {1|U, {0x04c5}}},
+ {0x04c8, {1|U, {0x04c7}}},
+ {0x04ca, {1|U, {0x04c9}}},
+ {0x04cc, {1|U, {0x04cb}}},
+ {0x04ce, {1|U, {0x04cd}}},
+ {0x04cf, {1|U, {0x04c0}}},
+ {0x04d1, {1|U, {0x04d0}}},
+ {0x04d3, {1|U, {0x04d2}}},
+ {0x04d5, {1|U, {0x04d4}}},
+ {0x04d7, {1|U, {0x04d6}}},
+ {0x04d9, {1|U, {0x04d8}}},
+ {0x04db, {1|U, {0x04da}}},
+ {0x04dd, {1|U, {0x04dc}}},
+ {0x04df, {1|U, {0x04de}}},
+ {0x04e1, {1|U, {0x04e0}}},
+ {0x04e3, {1|U, {0x04e2}}},
+ {0x04e5, {1|U, {0x04e4}}},
+ {0x04e7, {1|U, {0x04e6}}},
+ {0x04e9, {1|U, {0x04e8}}},
+ {0x04eb, {1|U, {0x04ea}}},
+ {0x04ed, {1|U, {0x04ec}}},
+ {0x04ef, {1|U, {0x04ee}}},
+ {0x04f1, {1|U, {0x04f0}}},
+ {0x04f3, {1|U, {0x04f2}}},
+ {0x04f5, {1|U, {0x04f4}}},
+ {0x04f7, {1|U, {0x04f6}}},
+ {0x04f9, {1|U, {0x04f8}}},
+ {0x04fb, {1|U, {0x04fa}}},
+ {0x04fd, {1|U, {0x04fc}}},
+ {0x04ff, {1|U, {0x04fe}}},
+ {0x0501, {1|U, {0x0500}}},
+ {0x0503, {1|U, {0x0502}}},
+ {0x0505, {1|U, {0x0504}}},
+ {0x0507, {1|U, {0x0506}}},
+ {0x0509, {1|U, {0x0508}}},
+ {0x050b, {1|U, {0x050a}}},
+ {0x050d, {1|U, {0x050c}}},
+ {0x050f, {1|U, {0x050e}}},
+ {0x0511, {1|U, {0x0510}}},
+ {0x0513, {1|U, {0x0512}}},
+ {0x0515, {1|U, {0x0514}}},
+ {0x0517, {1|U, {0x0516}}},
+ {0x0519, {1|U, {0x0518}}},
+ {0x051b, {1|U, {0x051a}}},
+ {0x051d, {1|U, {0x051c}}},
+ {0x051f, {1|U, {0x051e}}},
+ {0x0521, {1|U, {0x0520}}},
+ {0x0523, {1|U, {0x0522}}},
+ {0x0525, {1|U, {0x0524}}},
+ {0x0527, {1|U, {0x0526}}},
+ {0x0529, {1|U, {0x0528}}},
+ {0x052b, {1|U, {0x052a}}},
+ {0x052d, {1|U, {0x052c}}},
+ {0x052f, {1|U, {0x052e}}},
+ {0x0561, {1|U, {0x0531}}},
+ {0x0562, {1|U, {0x0532}}},
+ {0x0563, {1|U, {0x0533}}},
+ {0x0564, {1|U, {0x0534}}},
+ {0x0565, {1|U, {0x0535}}},
+ {0x0566, {1|U, {0x0536}}},
+ {0x0567, {1|U, {0x0537}}},
+ {0x0568, {1|U, {0x0538}}},
+ {0x0569, {1|U, {0x0539}}},
+ {0x056a, {1|U, {0x053a}}},
+ {0x056b, {1|U, {0x053b}}},
+ {0x056c, {1|U, {0x053c}}},
+ {0x056d, {1|U, {0x053d}}},
+ {0x056e, {1|U, {0x053e}}},
+ {0x056f, {1|U, {0x053f}}},
+ {0x0570, {1|U, {0x0540}}},
+ {0x0571, {1|U, {0x0541}}},
+ {0x0572, {1|U, {0x0542}}},
+ {0x0573, {1|U, {0x0543}}},
+ {0x0574, {1|U, {0x0544}}},
+ {0x0575, {1|U, {0x0545}}},
+ {0x0576, {1|U, {0x0546}}},
+ {0x0577, {1|U, {0x0547}}},
+ {0x0578, {1|U, {0x0548}}},
+ {0x0579, {1|U, {0x0549}}},
+ {0x057a, {1|U, {0x054a}}},
+ {0x057b, {1|U, {0x054b}}},
+ {0x057c, {1|U, {0x054c}}},
+ {0x057d, {1|U, {0x054d}}},
+ {0x057e, {1|U, {0x054e}}},
+ {0x057f, {1|U, {0x054f}}},
+ {0x0580, {1|U, {0x0550}}},
+ {0x0581, {1|U, {0x0551}}},
+ {0x0582, {1|U, {0x0552}}},
+ {0x0583, {1|U, {0x0553}}},
+ {0x0584, {1|U, {0x0554}}},
+ {0x0585, {1|U, {0x0555}}},
+ {0x0586, {1|U, {0x0556}}},
+ {0x13a0, {1|D, {0xab70}}},
+ {0x13a1, {1|D, {0xab71}}},
+ {0x13a2, {1|D, {0xab72}}},
+ {0x13a3, {1|D, {0xab73}}},
+ {0x13a4, {1|D, {0xab74}}},
+ {0x13a5, {1|D, {0xab75}}},
+ {0x13a6, {1|D, {0xab76}}},
+ {0x13a7, {1|D, {0xab77}}},
+ {0x13a8, {1|D, {0xab78}}},
+ {0x13a9, {1|D, {0xab79}}},
+ {0x13aa, {1|D, {0xab7a}}},
+ {0x13ab, {1|D, {0xab7b}}},
+ {0x13ac, {1|D, {0xab7c}}},
+ {0x13ad, {1|D, {0xab7d}}},
+ {0x13ae, {1|D, {0xab7e}}},
+ {0x13af, {1|D, {0xab7f}}},
+ {0x13b0, {1|D, {0xab80}}},
+ {0x13b1, {1|D, {0xab81}}},
+ {0x13b2, {1|D, {0xab82}}},
+ {0x13b3, {1|D, {0xab83}}},
+ {0x13b4, {1|D, {0xab84}}},
+ {0x13b5, {1|D, {0xab85}}},
+ {0x13b6, {1|D, {0xab86}}},
+ {0x13b7, {1|D, {0xab87}}},
+ {0x13b8, {1|D, {0xab88}}},
+ {0x13b9, {1|D, {0xab89}}},
+ {0x13ba, {1|D, {0xab8a}}},
+ {0x13bb, {1|D, {0xab8b}}},
+ {0x13bc, {1|D, {0xab8c}}},
+ {0x13bd, {1|D, {0xab8d}}},
+ {0x13be, {1|D, {0xab8e}}},
+ {0x13bf, {1|D, {0xab8f}}},
+ {0x13c0, {1|D, {0xab90}}},
+ {0x13c1, {1|D, {0xab91}}},
+ {0x13c2, {1|D, {0xab92}}},
+ {0x13c3, {1|D, {0xab93}}},
+ {0x13c4, {1|D, {0xab94}}},
+ {0x13c5, {1|D, {0xab95}}},
+ {0x13c6, {1|D, {0xab96}}},
+ {0x13c7, {1|D, {0xab97}}},
+ {0x13c8, {1|D, {0xab98}}},
+ {0x13c9, {1|D, {0xab99}}},
+ {0x13ca, {1|D, {0xab9a}}},
+ {0x13cb, {1|D, {0xab9b}}},
+ {0x13cc, {1|D, {0xab9c}}},
+ {0x13cd, {1|D, {0xab9d}}},
+ {0x13ce, {1|D, {0xab9e}}},
+ {0x13cf, {1|D, {0xab9f}}},
+ {0x13d0, {1|D, {0xaba0}}},
+ {0x13d1, {1|D, {0xaba1}}},
+ {0x13d2, {1|D, {0xaba2}}},
+ {0x13d3, {1|D, {0xaba3}}},
+ {0x13d4, {1|D, {0xaba4}}},
+ {0x13d5, {1|D, {0xaba5}}},
+ {0x13d6, {1|D, {0xaba6}}},
+ {0x13d7, {1|D, {0xaba7}}},
+ {0x13d8, {1|D, {0xaba8}}},
+ {0x13d9, {1|D, {0xaba9}}},
+ {0x13da, {1|D, {0xabaa}}},
+ {0x13db, {1|D, {0xabab}}},
+ {0x13dc, {1|D, {0xabac}}},
+ {0x13dd, {1|D, {0xabad}}},
+ {0x13de, {1|D, {0xabae}}},
+ {0x13df, {1|D, {0xabaf}}},
+ {0x13e0, {1|D, {0xabb0}}},
+ {0x13e1, {1|D, {0xabb1}}},
+ {0x13e2, {1|D, {0xabb2}}},
+ {0x13e3, {1|D, {0xabb3}}},
+ {0x13e4, {1|D, {0xabb4}}},
+ {0x13e5, {1|D, {0xabb5}}},
+ {0x13e6, {1|D, {0xabb6}}},
+ {0x13e7, {1|D, {0xabb7}}},
+ {0x13e8, {1|D, {0xabb8}}},
+ {0x13e9, {1|D, {0xabb9}}},
+ {0x13ea, {1|D, {0xabba}}},
+ {0x13eb, {1|D, {0xabbb}}},
+ {0x13ec, {1|D, {0xabbc}}},
+ {0x13ed, {1|D, {0xabbd}}},
+ {0x13ee, {1|D, {0xabbe}}},
+ {0x13ef, {1|D, {0xabbf}}},
+ {0x13f0, {1|D, {0x13f8}}},
+ {0x13f1, {1|D, {0x13f9}}},
+ {0x13f2, {1|D, {0x13fa}}},
+ {0x13f3, {1|D, {0x13fb}}},
+ {0x13f4, {1|D, {0x13fc}}},
+ {0x13f5, {1|D, {0x13fd}}},
+ {0x1d79, {1|U, {0xa77d}}},
+ {0x1d7d, {1|U, {0x2c63}}},
+ {0x1e01, {1|U, {0x1e00}}},
+ {0x1e03, {1|U, {0x1e02}}},
+ {0x1e05, {1|U, {0x1e04}}},
+ {0x1e07, {1|U, {0x1e06}}},
+ {0x1e09, {1|U, {0x1e08}}},
+ {0x1e0b, {1|U, {0x1e0a}}},
+ {0x1e0d, {1|U, {0x1e0c}}},
+ {0x1e0f, {1|U, {0x1e0e}}},
+ {0x1e11, {1|U, {0x1e10}}},
+ {0x1e13, {1|U, {0x1e12}}},
+ {0x1e15, {1|U, {0x1e14}}},
+ {0x1e17, {1|U, {0x1e16}}},
+ {0x1e19, {1|U, {0x1e18}}},
+ {0x1e1b, {1|U, {0x1e1a}}},
+ {0x1e1d, {1|U, {0x1e1c}}},
+ {0x1e1f, {1|U, {0x1e1e}}},
+ {0x1e21, {1|U, {0x1e20}}},
+ {0x1e23, {1|U, {0x1e22}}},
+ {0x1e25, {1|U, {0x1e24}}},
+ {0x1e27, {1|U, {0x1e26}}},
+ {0x1e29, {1|U, {0x1e28}}},
+ {0x1e2b, {1|U, {0x1e2a}}},
+ {0x1e2d, {1|U, {0x1e2c}}},
+ {0x1e2f, {1|U, {0x1e2e}}},
+ {0x1e31, {1|U, {0x1e30}}},
+ {0x1e33, {1|U, {0x1e32}}},
+ {0x1e35, {1|U, {0x1e34}}},
+ {0x1e37, {1|U, {0x1e36}}},
+ {0x1e39, {1|U, {0x1e38}}},
+ {0x1e3b, {1|U, {0x1e3a}}},
+ {0x1e3d, {1|U, {0x1e3c}}},
+ {0x1e3f, {1|U, {0x1e3e}}},
+ {0x1e41, {1|U, {0x1e40}}},
+ {0x1e43, {1|U, {0x1e42}}},
+ {0x1e45, {1|U, {0x1e44}}},
+ {0x1e47, {1|U, {0x1e46}}},
+ {0x1e49, {1|U, {0x1e48}}},
+ {0x1e4b, {1|U, {0x1e4a}}},
+ {0x1e4d, {1|U, {0x1e4c}}},
+ {0x1e4f, {1|U, {0x1e4e}}},
+ {0x1e51, {1|U, {0x1e50}}},
+ {0x1e53, {1|U, {0x1e52}}},
+ {0x1e55, {1|U, {0x1e54}}},
+ {0x1e57, {1|U, {0x1e56}}},
+ {0x1e59, {1|U, {0x1e58}}},
+ {0x1e5b, {1|U, {0x1e5a}}},
+ {0x1e5d, {1|U, {0x1e5c}}},
+ {0x1e5f, {1|U, {0x1e5e}}},
+ {0x1e61, {2|U, {0x1e60, 0x1e9b}}},
+ {0x1e63, {1|U, {0x1e62}}},
+ {0x1e65, {1|U, {0x1e64}}},
+ {0x1e67, {1|U, {0x1e66}}},
+ {0x1e69, {1|U, {0x1e68}}},
+ {0x1e6b, {1|U, {0x1e6a}}},
+ {0x1e6d, {1|U, {0x1e6c}}},
+ {0x1e6f, {1|U, {0x1e6e}}},
+ {0x1e71, {1|U, {0x1e70}}},
+ {0x1e73, {1|U, {0x1e72}}},
+ {0x1e75, {1|U, {0x1e74}}},
+ {0x1e77, {1|U, {0x1e76}}},
+ {0x1e79, {1|U, {0x1e78}}},
+ {0x1e7b, {1|U, {0x1e7a}}},
+ {0x1e7d, {1|U, {0x1e7c}}},
+ {0x1e7f, {1|U, {0x1e7e}}},
+ {0x1e81, {1|U, {0x1e80}}},
+ {0x1e83, {1|U, {0x1e82}}},
+ {0x1e85, {1|U, {0x1e84}}},
+ {0x1e87, {1|U, {0x1e86}}},
+ {0x1e89, {1|U, {0x1e88}}},
+ {0x1e8b, {1|U, {0x1e8a}}},
+ {0x1e8d, {1|U, {0x1e8c}}},
+ {0x1e8f, {1|U, {0x1e8e}}},
+ {0x1e91, {1|U, {0x1e90}}},
+ {0x1e93, {1|U, {0x1e92}}},
+ {0x1e95, {1|U, {0x1e94}}},
+ {0x1ea1, {1|U, {0x1ea0}}},
+ {0x1ea3, {1|U, {0x1ea2}}},
+ {0x1ea5, {1|U, {0x1ea4}}},
+ {0x1ea7, {1|U, {0x1ea6}}},
+ {0x1ea9, {1|U, {0x1ea8}}},
+ {0x1eab, {1|U, {0x1eaa}}},
+ {0x1ead, {1|U, {0x1eac}}},
+ {0x1eaf, {1|U, {0x1eae}}},
+ {0x1eb1, {1|U, {0x1eb0}}},
+ {0x1eb3, {1|U, {0x1eb2}}},
+ {0x1eb5, {1|U, {0x1eb4}}},
+ {0x1eb7, {1|U, {0x1eb6}}},
+ {0x1eb9, {1|U, {0x1eb8}}},
+ {0x1ebb, {1|U, {0x1eba}}},
+ {0x1ebd, {1|U, {0x1ebc}}},
+ {0x1ebf, {1|U, {0x1ebe}}},
+ {0x1ec1, {1|U, {0x1ec0}}},
+ {0x1ec3, {1|U, {0x1ec2}}},
+ {0x1ec5, {1|U, {0x1ec4}}},
+ {0x1ec7, {1|U, {0x1ec6}}},
+ {0x1ec9, {1|U, {0x1ec8}}},
+ {0x1ecb, {1|U, {0x1eca}}},
+ {0x1ecd, {1|U, {0x1ecc}}},
+ {0x1ecf, {1|U, {0x1ece}}},
+ {0x1ed1, {1|U, {0x1ed0}}},
+ {0x1ed3, {1|U, {0x1ed2}}},
+ {0x1ed5, {1|U, {0x1ed4}}},
+ {0x1ed7, {1|U, {0x1ed6}}},
+ {0x1ed9, {1|U, {0x1ed8}}},
+ {0x1edb, {1|U, {0x1eda}}},
+ {0x1edd, {1|U, {0x1edc}}},
+ {0x1edf, {1|U, {0x1ede}}},
+ {0x1ee1, {1|U, {0x1ee0}}},
+ {0x1ee3, {1|U, {0x1ee2}}},
+ {0x1ee5, {1|U, {0x1ee4}}},
+ {0x1ee7, {1|U, {0x1ee6}}},
+ {0x1ee9, {1|U, {0x1ee8}}},
+ {0x1eeb, {1|U, {0x1eea}}},
+ {0x1eed, {1|U, {0x1eec}}},
+ {0x1eef, {1|U, {0x1eee}}},
+ {0x1ef1, {1|U, {0x1ef0}}},
+ {0x1ef3, {1|U, {0x1ef2}}},
+ {0x1ef5, {1|U, {0x1ef4}}},
+ {0x1ef7, {1|U, {0x1ef6}}},
+ {0x1ef9, {1|U, {0x1ef8}}},
+ {0x1efb, {1|U, {0x1efa}}},
+ {0x1efd, {1|U, {0x1efc}}},
+ {0x1eff, {1|U, {0x1efe}}},
+ {0x1f00, {1|U, {0x1f08}}},
+ {0x1f01, {1|U, {0x1f09}}},
+ {0x1f02, {1|U, {0x1f0a}}},
+ {0x1f03, {1|U, {0x1f0b}}},
+ {0x1f04, {1|U, {0x1f0c}}},
+ {0x1f05, {1|U, {0x1f0d}}},
+ {0x1f06, {1|U, {0x1f0e}}},
+ {0x1f07, {1|U, {0x1f0f}}},
+ {0x1f10, {1|U, {0x1f18}}},
+ {0x1f11, {1|U, {0x1f19}}},
+ {0x1f12, {1|U, {0x1f1a}}},
+ {0x1f13, {1|U, {0x1f1b}}},
+ {0x1f14, {1|U, {0x1f1c}}},
+ {0x1f15, {1|U, {0x1f1d}}},
+ {0x1f20, {1|U, {0x1f28}}},
+ {0x1f21, {1|U, {0x1f29}}},
+ {0x1f22, {1|U, {0x1f2a}}},
+ {0x1f23, {1|U, {0x1f2b}}},
+ {0x1f24, {1|U, {0x1f2c}}},
+ {0x1f25, {1|U, {0x1f2d}}},
+ {0x1f26, {1|U, {0x1f2e}}},
+ {0x1f27, {1|U, {0x1f2f}}},
+ {0x1f30, {1|U, {0x1f38}}},
+ {0x1f31, {1|U, {0x1f39}}},
+ {0x1f32, {1|U, {0x1f3a}}},
+ {0x1f33, {1|U, {0x1f3b}}},
+ {0x1f34, {1|U, {0x1f3c}}},
+ {0x1f35, {1|U, {0x1f3d}}},
+ {0x1f36, {1|U, {0x1f3e}}},
+ {0x1f37, {1|U, {0x1f3f}}},
+ {0x1f40, {1|U, {0x1f48}}},
+ {0x1f41, {1|U, {0x1f49}}},
+ {0x1f42, {1|U, {0x1f4a}}},
+ {0x1f43, {1|U, {0x1f4b}}},
+ {0x1f44, {1|U, {0x1f4c}}},
+ {0x1f45, {1|U, {0x1f4d}}},
+ {0x1f51, {1|U, {0x1f59}}},
+ {0x1f53, {1|U, {0x1f5b}}},
+ {0x1f55, {1|U, {0x1f5d}}},
+ {0x1f57, {1|U, {0x1f5f}}},
+ {0x1f60, {1|U, {0x1f68}}},
+ {0x1f61, {1|U, {0x1f69}}},
+ {0x1f62, {1|U, {0x1f6a}}},
+ {0x1f63, {1|U, {0x1f6b}}},
+ {0x1f64, {1|U, {0x1f6c}}},
+ {0x1f65, {1|U, {0x1f6d}}},
+ {0x1f66, {1|U, {0x1f6e}}},
+ {0x1f67, {1|U, {0x1f6f}}},
+ {0x1f70, {1|U, {0x1fba}}},
+ {0x1f71, {1|U, {0x1fbb}}},
+ {0x1f72, {1|U, {0x1fc8}}},
+ {0x1f73, {1|U, {0x1fc9}}},
+ {0x1f74, {1|U, {0x1fca}}},
+ {0x1f75, {1|U, {0x1fcb}}},
+ {0x1f76, {1|U, {0x1fda}}},
+ {0x1f77, {1|U, {0x1fdb}}},
+ {0x1f78, {1|U, {0x1ff8}}},
+ {0x1f79, {1|U, {0x1ff9}}},
+ {0x1f7a, {1|U, {0x1fea}}},
+ {0x1f7b, {1|U, {0x1feb}}},
+ {0x1f7c, {1|U, {0x1ffa}}},
+ {0x1f7d, {1|U, {0x1ffb}}},
+ {0x1fb0, {1|U, {0x1fb8}}},
+ {0x1fb1, {1|U, {0x1fb9}}},
+ {0x1fd0, {1|U, {0x1fd8}}},
+ {0x1fd1, {1|U, {0x1fd9}}},
+ {0x1fe0, {1|U, {0x1fe8}}},
+ {0x1fe1, {1|U, {0x1fe9}}},
+ {0x1fe5, {1|U, {0x1fec}}},
+ {0x214e, {1|U, {0x2132}}},
+ {0x2170, {1|U, {0x2160}}},
+ {0x2171, {1|U, {0x2161}}},
+ {0x2172, {1|U, {0x2162}}},
+ {0x2173, {1|U, {0x2163}}},
+ {0x2174, {1|U, {0x2164}}},
+ {0x2175, {1|U, {0x2165}}},
+ {0x2176, {1|U, {0x2166}}},
+ {0x2177, {1|U, {0x2167}}},
+ {0x2178, {1|U, {0x2168}}},
+ {0x2179, {1|U, {0x2169}}},
+ {0x217a, {1|U, {0x216a}}},
+ {0x217b, {1|U, {0x216b}}},
+ {0x217c, {1|U, {0x216c}}},
+ {0x217d, {1|U, {0x216d}}},
+ {0x217e, {1|U, {0x216e}}},
+ {0x217f, {1|U, {0x216f}}},
+ {0x2184, {1|U, {0x2183}}},
+ {0x24d0, {1|U, {0x24b6}}},
+ {0x24d1, {1|U, {0x24b7}}},
+ {0x24d2, {1|U, {0x24b8}}},
+ {0x24d3, {1|U, {0x24b9}}},
+ {0x24d4, {1|U, {0x24ba}}},
+ {0x24d5, {1|U, {0x24bb}}},
+ {0x24d6, {1|U, {0x24bc}}},
+ {0x24d7, {1|U, {0x24bd}}},
+ {0x24d8, {1|U, {0x24be}}},
+ {0x24d9, {1|U, {0x24bf}}},
+ {0x24da, {1|U, {0x24c0}}},
+ {0x24db, {1|U, {0x24c1}}},
+ {0x24dc, {1|U, {0x24c2}}},
+ {0x24dd, {1|U, {0x24c3}}},
+ {0x24de, {1|U, {0x24c4}}},
+ {0x24df, {1|U, {0x24c5}}},
+ {0x24e0, {1|U, {0x24c6}}},
+ {0x24e1, {1|U, {0x24c7}}},
+ {0x24e2, {1|U, {0x24c8}}},
+ {0x24e3, {1|U, {0x24c9}}},
+ {0x24e4, {1|U, {0x24ca}}},
+ {0x24e5, {1|U, {0x24cb}}},
+ {0x24e6, {1|U, {0x24cc}}},
+ {0x24e7, {1|U, {0x24cd}}},
+ {0x24e8, {1|U, {0x24ce}}},
+ {0x24e9, {1|U, {0x24cf}}},
+ {0x2c30, {1|U, {0x2c00}}},
+ {0x2c31, {1|U, {0x2c01}}},
+ {0x2c32, {1|U, {0x2c02}}},
+ {0x2c33, {1|U, {0x2c03}}},
+ {0x2c34, {1|U, {0x2c04}}},
+ {0x2c35, {1|U, {0x2c05}}},
+ {0x2c36, {1|U, {0x2c06}}},
+ {0x2c37, {1|U, {0x2c07}}},
+ {0x2c38, {1|U, {0x2c08}}},
+ {0x2c39, {1|U, {0x2c09}}},
+ {0x2c3a, {1|U, {0x2c0a}}},
+ {0x2c3b, {1|U, {0x2c0b}}},
+ {0x2c3c, {1|U, {0x2c0c}}},
+ {0x2c3d, {1|U, {0x2c0d}}},
+ {0x2c3e, {1|U, {0x2c0e}}},
+ {0x2c3f, {1|U, {0x2c0f}}},
+ {0x2c40, {1|U, {0x2c10}}},
+ {0x2c41, {1|U, {0x2c11}}},
+ {0x2c42, {1|U, {0x2c12}}},
+ {0x2c43, {1|U, {0x2c13}}},
+ {0x2c44, {1|U, {0x2c14}}},
+ {0x2c45, {1|U, {0x2c15}}},
+ {0x2c46, {1|U, {0x2c16}}},
+ {0x2c47, {1|U, {0x2c17}}},
+ {0x2c48, {1|U, {0x2c18}}},
+ {0x2c49, {1|U, {0x2c19}}},
+ {0x2c4a, {1|U, {0x2c1a}}},
+ {0x2c4b, {1|U, {0x2c1b}}},
+ {0x2c4c, {1|U, {0x2c1c}}},
+ {0x2c4d, {1|U, {0x2c1d}}},
+ {0x2c4e, {1|U, {0x2c1e}}},
+ {0x2c4f, {1|U, {0x2c1f}}},
+ {0x2c50, {1|U, {0x2c20}}},
+ {0x2c51, {1|U, {0x2c21}}},
+ {0x2c52, {1|U, {0x2c22}}},
+ {0x2c53, {1|U, {0x2c23}}},
+ {0x2c54, {1|U, {0x2c24}}},
+ {0x2c55, {1|U, {0x2c25}}},
+ {0x2c56, {1|U, {0x2c26}}},
+ {0x2c57, {1|U, {0x2c27}}},
+ {0x2c58, {1|U, {0x2c28}}},
+ {0x2c59, {1|U, {0x2c29}}},
+ {0x2c5a, {1|U, {0x2c2a}}},
+ {0x2c5b, {1|U, {0x2c2b}}},
+ {0x2c5c, {1|U, {0x2c2c}}},
+ {0x2c5d, {1|U, {0x2c2d}}},
+ {0x2c5e, {1|U, {0x2c2e}}},
+ {0x2c61, {1|U, {0x2c60}}},
+ {0x2c65, {1|U, {0x023a}}},
+ {0x2c66, {1|U, {0x023e}}},
+ {0x2c68, {1|U, {0x2c67}}},
+ {0x2c6a, {1|U, {0x2c69}}},
+ {0x2c6c, {1|U, {0x2c6b}}},
+ {0x2c73, {1|U, {0x2c72}}},
+ {0x2c76, {1|U, {0x2c75}}},
+ {0x2c81, {1|U, {0x2c80}}},
+ {0x2c83, {1|U, {0x2c82}}},
+ {0x2c85, {1|U, {0x2c84}}},
+ {0x2c87, {1|U, {0x2c86}}},
+ {0x2c89, {1|U, {0x2c88}}},
+ {0x2c8b, {1|U, {0x2c8a}}},
+ {0x2c8d, {1|U, {0x2c8c}}},
+ {0x2c8f, {1|U, {0x2c8e}}},
+ {0x2c91, {1|U, {0x2c90}}},
+ {0x2c93, {1|U, {0x2c92}}},
+ {0x2c95, {1|U, {0x2c94}}},
+ {0x2c97, {1|U, {0x2c96}}},
+ {0x2c99, {1|U, {0x2c98}}},
+ {0x2c9b, {1|U, {0x2c9a}}},
+ {0x2c9d, {1|U, {0x2c9c}}},
+ {0x2c9f, {1|U, {0x2c9e}}},
+ {0x2ca1, {1|U, {0x2ca0}}},
+ {0x2ca3, {1|U, {0x2ca2}}},
+ {0x2ca5, {1|U, {0x2ca4}}},
+ {0x2ca7, {1|U, {0x2ca6}}},
+ {0x2ca9, {1|U, {0x2ca8}}},
+ {0x2cab, {1|U, {0x2caa}}},
+ {0x2cad, {1|U, {0x2cac}}},
+ {0x2caf, {1|U, {0x2cae}}},
+ {0x2cb1, {1|U, {0x2cb0}}},
+ {0x2cb3, {1|U, {0x2cb2}}},
+ {0x2cb5, {1|U, {0x2cb4}}},
+ {0x2cb7, {1|U, {0x2cb6}}},
+ {0x2cb9, {1|U, {0x2cb8}}},
+ {0x2cbb, {1|U, {0x2cba}}},
+ {0x2cbd, {1|U, {0x2cbc}}},
+ {0x2cbf, {1|U, {0x2cbe}}},
+ {0x2cc1, {1|U, {0x2cc0}}},
+ {0x2cc3, {1|U, {0x2cc2}}},
+ {0x2cc5, {1|U, {0x2cc4}}},
+ {0x2cc7, {1|U, {0x2cc6}}},
+ {0x2cc9, {1|U, {0x2cc8}}},
+ {0x2ccb, {1|U, {0x2cca}}},
+ {0x2ccd, {1|U, {0x2ccc}}},
+ {0x2ccf, {1|U, {0x2cce}}},
+ {0x2cd1, {1|U, {0x2cd0}}},
+ {0x2cd3, {1|U, {0x2cd2}}},
+ {0x2cd5, {1|U, {0x2cd4}}},
+ {0x2cd7, {1|U, {0x2cd6}}},
+ {0x2cd9, {1|U, {0x2cd8}}},
+ {0x2cdb, {1|U, {0x2cda}}},
+ {0x2cdd, {1|U, {0x2cdc}}},
+ {0x2cdf, {1|U, {0x2cde}}},
+ {0x2ce1, {1|U, {0x2ce0}}},
+ {0x2ce3, {1|U, {0x2ce2}}},
+ {0x2cec, {1|U, {0x2ceb}}},
+ {0x2cee, {1|U, {0x2ced}}},
+ {0x2cf3, {1|U, {0x2cf2}}},
+ {0x2d00, {1|U, {0x10a0}}},
+ {0x2d01, {1|U, {0x10a1}}},
+ {0x2d02, {1|U, {0x10a2}}},
+ {0x2d03, {1|U, {0x10a3}}},
+ {0x2d04, {1|U, {0x10a4}}},
+ {0x2d05, {1|U, {0x10a5}}},
+ {0x2d06, {1|U, {0x10a6}}},
+ {0x2d07, {1|U, {0x10a7}}},
+ {0x2d08, {1|U, {0x10a8}}},
+ {0x2d09, {1|U, {0x10a9}}},
+ {0x2d0a, {1|U, {0x10aa}}},
+ {0x2d0b, {1|U, {0x10ab}}},
+ {0x2d0c, {1|U, {0x10ac}}},
+ {0x2d0d, {1|U, {0x10ad}}},
+ {0x2d0e, {1|U, {0x10ae}}},
+ {0x2d0f, {1|U, {0x10af}}},
+ {0x2d10, {1|U, {0x10b0}}},
+ {0x2d11, {1|U, {0x10b1}}},
+ {0x2d12, {1|U, {0x10b2}}},
+ {0x2d13, {1|U, {0x10b3}}},
+ {0x2d14, {1|U, {0x10b4}}},
+ {0x2d15, {1|U, {0x10b5}}},
+ {0x2d16, {1|U, {0x10b6}}},
+ {0x2d17, {1|U, {0x10b7}}},
+ {0x2d18, {1|U, {0x10b8}}},
+ {0x2d19, {1|U, {0x10b9}}},
+ {0x2d1a, {1|U, {0x10ba}}},
+ {0x2d1b, {1|U, {0x10bb}}},
+ {0x2d1c, {1|U, {0x10bc}}},
+ {0x2d1d, {1|U, {0x10bd}}},
+ {0x2d1e, {1|U, {0x10be}}},
+ {0x2d1f, {1|U, {0x10bf}}},
+ {0x2d20, {1|U, {0x10c0}}},
+ {0x2d21, {1|U, {0x10c1}}},
+ {0x2d22, {1|U, {0x10c2}}},
+ {0x2d23, {1|U, {0x10c3}}},
+ {0x2d24, {1|U, {0x10c4}}},
+ {0x2d25, {1|U, {0x10c5}}},
+ {0x2d27, {1|U, {0x10c7}}},
+ {0x2d2d, {1|U, {0x10cd}}},
+ {0xa641, {1|U, {0xa640}}},
+ {0xa643, {1|U, {0xa642}}},
+ {0xa645, {1|U, {0xa644}}},
+ {0xa647, {1|U, {0xa646}}},
+ {0xa649, {1|U, {0xa648}}},
+ {0xa64b, {2|U, {0xa64a, 0x1c88}}},
+ {0xa64d, {1|U, {0xa64c}}},
+ {0xa64f, {1|U, {0xa64e}}},
+ {0xa651, {1|U, {0xa650}}},
+ {0xa653, {1|U, {0xa652}}},
+ {0xa655, {1|U, {0xa654}}},
+ {0xa657, {1|U, {0xa656}}},
+ {0xa659, {1|U, {0xa658}}},
+ {0xa65b, {1|U, {0xa65a}}},
+ {0xa65d, {1|U, {0xa65c}}},
+ {0xa65f, {1|U, {0xa65e}}},
+ {0xa661, {1|U, {0xa660}}},
+ {0xa663, {1|U, {0xa662}}},
+ {0xa665, {1|U, {0xa664}}},
+ {0xa667, {1|U, {0xa666}}},
+ {0xa669, {1|U, {0xa668}}},
+ {0xa66b, {1|U, {0xa66a}}},
+ {0xa66d, {1|U, {0xa66c}}},
+ {0xa681, {1|U, {0xa680}}},
+ {0xa683, {1|U, {0xa682}}},
+ {0xa685, {1|U, {0xa684}}},
+ {0xa687, {1|U, {0xa686}}},
+ {0xa689, {1|U, {0xa688}}},
+ {0xa68b, {1|U, {0xa68a}}},
+ {0xa68d, {1|U, {0xa68c}}},
+ {0xa68f, {1|U, {0xa68e}}},
+ {0xa691, {1|U, {0xa690}}},
+ {0xa693, {1|U, {0xa692}}},
+ {0xa695, {1|U, {0xa694}}},
+ {0xa697, {1|U, {0xa696}}},
+ {0xa699, {1|U, {0xa698}}},
+ {0xa69b, {1|U, {0xa69a}}},
+ {0xa723, {1|U, {0xa722}}},
+ {0xa725, {1|U, {0xa724}}},
+ {0xa727, {1|U, {0xa726}}},
+ {0xa729, {1|U, {0xa728}}},
+ {0xa72b, {1|U, {0xa72a}}},
+ {0xa72d, {1|U, {0xa72c}}},
+ {0xa72f, {1|U, {0xa72e}}},
+ {0xa733, {1|U, {0xa732}}},
+ {0xa735, {1|U, {0xa734}}},
+ {0xa737, {1|U, {0xa736}}},
+ {0xa739, {1|U, {0xa738}}},
+ {0xa73b, {1|U, {0xa73a}}},
+ {0xa73d, {1|U, {0xa73c}}},
+ {0xa73f, {1|U, {0xa73e}}},
+ {0xa741, {1|U, {0xa740}}},
+ {0xa743, {1|U, {0xa742}}},
+ {0xa745, {1|U, {0xa744}}},
+ {0xa747, {1|U, {0xa746}}},
+ {0xa749, {1|U, {0xa748}}},
+ {0xa74b, {1|U, {0xa74a}}},
+ {0xa74d, {1|U, {0xa74c}}},
+ {0xa74f, {1|U, {0xa74e}}},
+ {0xa751, {1|U, {0xa750}}},
+ {0xa753, {1|U, {0xa752}}},
+ {0xa755, {1|U, {0xa754}}},
+ {0xa757, {1|U, {0xa756}}},
+ {0xa759, {1|U, {0xa758}}},
+ {0xa75b, {1|U, {0xa75a}}},
+ {0xa75d, {1|U, {0xa75c}}},
+ {0xa75f, {1|U, {0xa75e}}},
+ {0xa761, {1|U, {0xa760}}},
+ {0xa763, {1|U, {0xa762}}},
+ {0xa765, {1|U, {0xa764}}},
+ {0xa767, {1|U, {0xa766}}},
+ {0xa769, {1|U, {0xa768}}},
+ {0xa76b, {1|U, {0xa76a}}},
+ {0xa76d, {1|U, {0xa76c}}},
+ {0xa76f, {1|U, {0xa76e}}},
+ {0xa77a, {1|U, {0xa779}}},
+ {0xa77c, {1|U, {0xa77b}}},
+ {0xa77f, {1|U, {0xa77e}}},
+ {0xa781, {1|U, {0xa780}}},
+ {0xa783, {1|U, {0xa782}}},
+ {0xa785, {1|U, {0xa784}}},
+ {0xa787, {1|U, {0xa786}}},
+ {0xa78c, {1|U, {0xa78b}}},
+ {0xa791, {1|U, {0xa790}}},
+ {0xa793, {1|U, {0xa792}}},
+ {0xa797, {1|U, {0xa796}}},
+ {0xa799, {1|U, {0xa798}}},
+ {0xa79b, {1|U, {0xa79a}}},
+ {0xa79d, {1|U, {0xa79c}}},
+ {0xa79f, {1|U, {0xa79e}}},
+ {0xa7a1, {1|U, {0xa7a0}}},
+ {0xa7a3, {1|U, {0xa7a2}}},
+ {0xa7a5, {1|U, {0xa7a4}}},
+ {0xa7a7, {1|U, {0xa7a6}}},
+ {0xa7a9, {1|U, {0xa7a8}}},
+ {0xa7b5, {1|U, {0xa7b4}}},
+ {0xa7b7, {1|U, {0xa7b6}}},
+ {0xab53, {1|U, {0xa7b3}}},
+ {0xff41, {1|U, {0xff21}}},
+ {0xff42, {1|U, {0xff22}}},
+ {0xff43, {1|U, {0xff23}}},
+ {0xff44, {1|U, {0xff24}}},
+ {0xff45, {1|U, {0xff25}}},
+ {0xff46, {1|U, {0xff26}}},
+ {0xff47, {1|U, {0xff27}}},
+ {0xff48, {1|U, {0xff28}}},
+ {0xff49, {1|U, {0xff29}}},
+ {0xff4a, {1|U, {0xff2a}}},
+ {0xff4b, {1|U, {0xff2b}}},
+ {0xff4c, {1|U, {0xff2c}}},
+ {0xff4d, {1|U, {0xff2d}}},
+ {0xff4e, {1|U, {0xff2e}}},
+ {0xff4f, {1|U, {0xff2f}}},
+ {0xff50, {1|U, {0xff30}}},
+ {0xff51, {1|U, {0xff31}}},
+ {0xff52, {1|U, {0xff32}}},
+ {0xff53, {1|U, {0xff33}}},
+ {0xff54, {1|U, {0xff34}}},
+ {0xff55, {1|U, {0xff35}}},
+ {0xff56, {1|U, {0xff36}}},
+ {0xff57, {1|U, {0xff37}}},
+ {0xff58, {1|U, {0xff38}}},
+ {0xff59, {1|U, {0xff39}}},
+ {0xff5a, {1|U, {0xff3a}}},
+ {0x10428, {1|U, {0x10400}}},
+ {0x10429, {1|U, {0x10401}}},
+ {0x1042a, {1|U, {0x10402}}},
+ {0x1042b, {1|U, {0x10403}}},
+ {0x1042c, {1|U, {0x10404}}},
+ {0x1042d, {1|U, {0x10405}}},
+ {0x1042e, {1|U, {0x10406}}},
+ {0x1042f, {1|U, {0x10407}}},
+ {0x10430, {1|U, {0x10408}}},
+ {0x10431, {1|U, {0x10409}}},
+ {0x10432, {1|U, {0x1040a}}},
+ {0x10433, {1|U, {0x1040b}}},
+ {0x10434, {1|U, {0x1040c}}},
+ {0x10435, {1|U, {0x1040d}}},
+ {0x10436, {1|U, {0x1040e}}},
+ {0x10437, {1|U, {0x1040f}}},
+ {0x10438, {1|U, {0x10410}}},
+ {0x10439, {1|U, {0x10411}}},
+ {0x1043a, {1|U, {0x10412}}},
+ {0x1043b, {1|U, {0x10413}}},
+ {0x1043c, {1|U, {0x10414}}},
+ {0x1043d, {1|U, {0x10415}}},
+ {0x1043e, {1|U, {0x10416}}},
+ {0x1043f, {1|U, {0x10417}}},
+ {0x10440, {1|U, {0x10418}}},
+ {0x10441, {1|U, {0x10419}}},
+ {0x10442, {1|U, {0x1041a}}},
+ {0x10443, {1|U, {0x1041b}}},
+ {0x10444, {1|U, {0x1041c}}},
+ {0x10445, {1|U, {0x1041d}}},
+ {0x10446, {1|U, {0x1041e}}},
+ {0x10447, {1|U, {0x1041f}}},
+ {0x10448, {1|U, {0x10420}}},
+ {0x10449, {1|U, {0x10421}}},
+ {0x1044a, {1|U, {0x10422}}},
+ {0x1044b, {1|U, {0x10423}}},
+ {0x1044c, {1|U, {0x10424}}},
+ {0x1044d, {1|U, {0x10425}}},
+ {0x1044e, {1|U, {0x10426}}},
+ {0x1044f, {1|U, {0x10427}}},
+ {0x104d8, {1|U, {0x104b0}}},
+ {0x104d9, {1|U, {0x104b1}}},
+ {0x104da, {1|U, {0x104b2}}},
+ {0x104db, {1|U, {0x104b3}}},
+ {0x104dc, {1|U, {0x104b4}}},
+ {0x104dd, {1|U, {0x104b5}}},
+ {0x104de, {1|U, {0x104b6}}},
+ {0x104df, {1|U, {0x104b7}}},
+ {0x104e0, {1|U, {0x104b8}}},
+ {0x104e1, {1|U, {0x104b9}}},
+ {0x104e2, {1|U, {0x104ba}}},
+ {0x104e3, {1|U, {0x104bb}}},
+ {0x104e4, {1|U, {0x104bc}}},
+ {0x104e5, {1|U, {0x104bd}}},
+ {0x104e6, {1|U, {0x104be}}},
+ {0x104e7, {1|U, {0x104bf}}},
+ {0x104e8, {1|U, {0x104c0}}},
+ {0x104e9, {1|U, {0x104c1}}},
+ {0x104ea, {1|U, {0x104c2}}},
+ {0x104eb, {1|U, {0x104c3}}},
+ {0x104ec, {1|U, {0x104c4}}},
+ {0x104ed, {1|U, {0x104c5}}},
+ {0x104ee, {1|U, {0x104c6}}},
+ {0x104ef, {1|U, {0x104c7}}},
+ {0x104f0, {1|U, {0x104c8}}},
+ {0x104f1, {1|U, {0x104c9}}},
+ {0x104f2, {1|U, {0x104ca}}},
+ {0x104f3, {1|U, {0x104cb}}},
+ {0x104f4, {1|U, {0x104cc}}},
+ {0x104f5, {1|U, {0x104cd}}},
+ {0x104f6, {1|U, {0x104ce}}},
+ {0x104f7, {1|U, {0x104cf}}},
+ {0x104f8, {1|U, {0x104d0}}},
+ {0x104f9, {1|U, {0x104d1}}},
+ {0x104fa, {1|U, {0x104d2}}},
+ {0x104fb, {1|U, {0x104d3}}},
+ {0x10cc0, {1|U, {0x10c80}}},
+ {0x10cc1, {1|U, {0x10c81}}},
+ {0x10cc2, {1|U, {0x10c82}}},
+ {0x10cc3, {1|U, {0x10c83}}},
+ {0x10cc4, {1|U, {0x10c84}}},
+ {0x10cc5, {1|U, {0x10c85}}},
+ {0x10cc6, {1|U, {0x10c86}}},
+ {0x10cc7, {1|U, {0x10c87}}},
+ {0x10cc8, {1|U, {0x10c88}}},
+ {0x10cc9, {1|U, {0x10c89}}},
+ {0x10cca, {1|U, {0x10c8a}}},
+ {0x10ccb, {1|U, {0x10c8b}}},
+ {0x10ccc, {1|U, {0x10c8c}}},
+ {0x10ccd, {1|U, {0x10c8d}}},
+ {0x10cce, {1|U, {0x10c8e}}},
+ {0x10ccf, {1|U, {0x10c8f}}},
+ {0x10cd0, {1|U, {0x10c90}}},
+ {0x10cd1, {1|U, {0x10c91}}},
+ {0x10cd2, {1|U, {0x10c92}}},
+ {0x10cd3, {1|U, {0x10c93}}},
+ {0x10cd4, {1|U, {0x10c94}}},
+ {0x10cd5, {1|U, {0x10c95}}},
+ {0x10cd6, {1|U, {0x10c96}}},
+ {0x10cd7, {1|U, {0x10c97}}},
+ {0x10cd8, {1|U, {0x10c98}}},
+ {0x10cd9, {1|U, {0x10c99}}},
+ {0x10cda, {1|U, {0x10c9a}}},
+ {0x10cdb, {1|U, {0x10c9b}}},
+ {0x10cdc, {1|U, {0x10c9c}}},
+ {0x10cdd, {1|U, {0x10c9d}}},
+ {0x10cde, {1|U, {0x10c9e}}},
+ {0x10cdf, {1|U, {0x10c9f}}},
+ {0x10ce0, {1|U, {0x10ca0}}},
+ {0x10ce1, {1|U, {0x10ca1}}},
+ {0x10ce2, {1|U, {0x10ca2}}},
+ {0x10ce3, {1|U, {0x10ca3}}},
+ {0x10ce4, {1|U, {0x10ca4}}},
+ {0x10ce5, {1|U, {0x10ca5}}},
+ {0x10ce6, {1|U, {0x10ca6}}},
+ {0x10ce7, {1|U, {0x10ca7}}},
+ {0x10ce8, {1|U, {0x10ca8}}},
+ {0x10ce9, {1|U, {0x10ca9}}},
+ {0x10cea, {1|U, {0x10caa}}},
+ {0x10ceb, {1|U, {0x10cab}}},
+ {0x10cec, {1|U, {0x10cac}}},
+ {0x10ced, {1|U, {0x10cad}}},
+ {0x10cee, {1|U, {0x10cae}}},
+ {0x10cef, {1|U, {0x10caf}}},
+ {0x10cf0, {1|U, {0x10cb0}}},
+ {0x10cf1, {1|U, {0x10cb1}}},
+ {0x10cf2, {1|U, {0x10cb2}}},
+ {0x118c0, {1|U, {0x118a0}}},
+ {0x118c1, {1|U, {0x118a1}}},
+ {0x118c2, {1|U, {0x118a2}}},
+ {0x118c3, {1|U, {0x118a3}}},
+ {0x118c4, {1|U, {0x118a4}}},
+ {0x118c5, {1|U, {0x118a5}}},
+ {0x118c6, {1|U, {0x118a6}}},
+ {0x118c7, {1|U, {0x118a7}}},
+ {0x118c8, {1|U, {0x118a8}}},
+ {0x118c9, {1|U, {0x118a9}}},
+ {0x118ca, {1|U, {0x118aa}}},
+ {0x118cb, {1|U, {0x118ab}}},
+ {0x118cc, {1|U, {0x118ac}}},
+ {0x118cd, {1|U, {0x118ad}}},
+ {0x118ce, {1|U, {0x118ae}}},
+ {0x118cf, {1|U, {0x118af}}},
+ {0x118d0, {1|U, {0x118b0}}},
+ {0x118d1, {1|U, {0x118b1}}},
+ {0x118d2, {1|U, {0x118b2}}},
+ {0x118d3, {1|U, {0x118b3}}},
+ {0x118d4, {1|U, {0x118b4}}},
+ {0x118d5, {1|U, {0x118b5}}},
+ {0x118d6, {1|U, {0x118b6}}},
+ {0x118d7, {1|U, {0x118b7}}},
+ {0x118d8, {1|U, {0x118b8}}},
+ {0x118d9, {1|U, {0x118b9}}},
+ {0x118da, {1|U, {0x118ba}}},
+ {0x118db, {1|U, {0x118bb}}},
+ {0x118dc, {1|U, {0x118bc}}},
+ {0x118dd, {1|U, {0x118bd}}},
+ {0x118de, {1|U, {0x118be}}},
+ {0x118df, {1|U, {0x118bf}}},
+ {0x1e922, {1|U, {0x1e900}}},
+ {0x1e923, {1|U, {0x1e901}}},
+ {0x1e924, {1|U, {0x1e902}}},
+ {0x1e925, {1|U, {0x1e903}}},
+ {0x1e926, {1|U, {0x1e904}}},
+ {0x1e927, {1|U, {0x1e905}}},
+ {0x1e928, {1|U, {0x1e906}}},
+ {0x1e929, {1|U, {0x1e907}}},
+ {0x1e92a, {1|U, {0x1e908}}},
+ {0x1e92b, {1|U, {0x1e909}}},
+ {0x1e92c, {1|U, {0x1e90a}}},
+ {0x1e92d, {1|U, {0x1e90b}}},
+ {0x1e92e, {1|U, {0x1e90c}}},
+ {0x1e92f, {1|U, {0x1e90d}}},
+ {0x1e930, {1|U, {0x1e90e}}},
+ {0x1e931, {1|U, {0x1e90f}}},
+ {0x1e932, {1|U, {0x1e910}}},
+ {0x1e933, {1|U, {0x1e911}}},
+ {0x1e934, {1|U, {0x1e912}}},
+ {0x1e935, {1|U, {0x1e913}}},
+ {0x1e936, {1|U, {0x1e914}}},
+ {0x1e937, {1|U, {0x1e915}}},
+ {0x1e938, {1|U, {0x1e916}}},
+ {0x1e939, {1|U, {0x1e917}}},
+ {0x1e93a, {1|U, {0x1e918}}},
+ {0x1e93b, {1|U, {0x1e919}}},
+ {0x1e93c, {1|U, {0x1e91a}}},
+ {0x1e93d, {1|U, {0x1e91b}}},
+ {0x1e93e, {1|U, {0x1e91c}}},
+ {0x1e93f, {1|U, {0x1e91d}}},
+ {0x1e940, {1|U, {0x1e91e}}},
+ {0x1e941, {1|U, {0x1e91f}}},
+ {0x1e942, {1|U, {0x1e920}}},
+ {0x1e943, {1|U, {0x1e921}}},
+#define CaseUnfold_11_Locale (*(CaseUnfold_11_Type (*)[1])(CaseUnfold_11_Table+1266))
+ {0x0069, {1|U, {0x0049}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_11_hash -N onigenc_unicode_CaseUnfold_11_lookup -n */
+
+/* maximum key range = 2216, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_11_hash(const OnigCodePoint code)
+{
+ static const unsigned short asso_values[] =
+ {
+ 1, 2219, 2, 14, 4, 807, 9, 379, 10, 179,
+ 70, 161, 2, 3, 411, 4, 2219, 2219, 2219, 2219,
+ 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 80,
+ 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219,
+ 2219, 2219, 2219, 1, 2219, 2219, 2219, 2219, 2219, 2219,
+ 2219, 2219, 2219, 210, 2219, 2219, 2219, 2219, 2219, 2219,
+ 2219, 2219, 53, 2219, 7, 8, 306, 607, 169, 844,
+ 431, 722, 125, 1047, 489, 1394, 15, 16, 324, 1361,
+ 140, 521, 47, 461, 221, 985, 70, 965, 9, 1085,
+ 51, 1029, 223, 11, 430, 1168, 122, 1457, 344, 930,
+ 91, 711, 31, 651, 157, 772, 224, 876, 262, 900,
+ 254, 686, 221, 830, 1335, 755, 432, 623, 1382, 675,
+ 1275, 587, 99, 821, 1530, 958, 195, 810, 1518, 739,
+ 330, 361, 767, 313, 941, 400, 925, 384, 1142, 295,
+ 1295, 242, 1103, 229, 1082, 206, 1066, 104, 1317, 137,
+ 1249, 263, 1229, 115, 1154, 71, 135, 60, 1211, 158,
+ 1472, 175, 1232, 1, 1345, 27, 1269, 38, 1111, 87,
+ 1189, 49, 1256, 503, 1157, 574, 1410, 556, 1200, 787,
+ 948, 486, 1316, 797, 1218, 1044, 1282, 1007, 1126, 996,
+ 818, 1019, 218, 1072
+ };
+ return asso_values[bits_of(code, 2)+66] + asso_values[bits_of(code, 1)+4] + asso_values[bits_of(code, 0)];
+}
+
+static const CodePointList3 *
+onigenc_unicode_CaseUnfold_11_lookup(const OnigCodePoint code)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x61,
+ MAX_CODE_VALUE = 0x1e943,
+ TOTAL_KEYWORDS = 1267,
+ MIN_WORD_LENGTH = 3,
+ MAX_WORD_LENGTH = 3,
+ MIN_HASH_VALUE = 3,
+ MAX_HASH_VALUE = 2218
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1,
+ /*0x13e1*/ 542,
+ /*0x0461*/ 339,
+ /*0x04e1*/ 399,
+ /*0x0061*/ 0,
+ -1,
+ /*0x104e1*/ 1122,
+ /*0x1e61*/ 613,
+ /*0x1ee1*/ 672,
+ /*0x0161*/ 102,
+ /*0x0261*/ 210,
+ /*0x2ce1*/ 904,
+ -1,
+ /*0x049b*/ 364,
+ -1, -1,
+ /*0x24e1*/ 792,
+ /*0x1e1b*/ 578,
+ /*0x048b*/ 356,
+ /*0x011b*/ 69,
+ /*0x021b*/ 178,
+ /*0x2c9b*/ 869,
+ /*0x1e0b*/ 570,
+ /*0x1e8b*/ 634,
+ /*0x010b*/ 61,
+ /*0x020b*/ 170,
+ /*0x2c8b*/ 861,
+ /*0x13e3*/ 544,
+ /*0x0463*/ 340,
+ /*0x04e3*/ 400,
+ /*0x0063*/ 2,
+ /*0x13a4*/ 481,
+ /*0x104e3*/ 1124,
+ /*0x1e63*/ 614,
+ /*0x1ee3*/ 673,
+ /*0x0163*/ 103,
+ /*0x0263*/ 211,
+ /*0x2ce3*/ 905,
+ /*0x13e5*/ 546,
+ /*0x0465*/ 341,
+ /*0x04e5*/ 401,
+ /*0x0065*/ 4,
+ /*0x24e3*/ 794,
+ /*0x104e5*/ 1126,
+ /*0x1e65*/ 615,
+ /*0x1ee5*/ 674,
+ /*0x0165*/ 104,
+ /*0x0265*/ 212,
+ /*0xa761*/ 1016,
+ /*0x13e9*/ 550,
+ /*0x0469*/ 343,
+ /*0x04e9*/ 403,
+ /*0x0069*/ 1266,
+ /*0x24e5*/ 796,
+ /*0x104e9*/ 1130,
+ /*0x1e69*/ 617,
+ /*0x1ee9*/ 676,
+ /*0x0169*/ 106,
+ /*0x0269*/ 215,
+ -1,
+ /*0x13db*/ 536,
+ /*0x045b*/ 334,
+ /*0x04db*/ 396,
+ -1,
+ /*0x24e9*/ 800,
+ /*0x104db*/ 1116,
+ /*0x1e5b*/ 610,
+ /*0x1edb*/ 669,
+ /*0x015b*/ 99,
+ /*0x025b*/ 207,
+ /*0x2cdb*/ 901,
+ /*0x13d9*/ 534,
+ /*0x0459*/ 332,
+ /*0x04d9*/ 395,
+ /*0xa763*/ 1017,
+ /*0x24db*/ 786,
+ /*0x104d9*/ 1114,
+ /*0x1e59*/ 609,
+ /*0x1ed9*/ 668,
+ /*0x0159*/ 98,
+ /*0x0259*/ 206,
+ /*0x2cd9*/ 900,
+ -1,
+ /*0x10ce1*/ 1182,
+ -1,
+ /*0xa765*/ 1018,
+ /*0x24d9*/ 784,
+ /*0x13e7*/ 548,
+ /*0x0467*/ 342,
+ /*0x04e7*/ 402,
+ /*0x0067*/ 6,
+ /*0x13a2*/ 479,
+ /*0x104e7*/ 1128,
+ /*0x1e67*/ 616,
+ /*0x1ee7*/ 675,
+ /*0x0167*/ 105,
+ /*0xa769*/ 1020,
+ -1, -1,
+ /*0x13b8*/ 501,
+ /*0x0438*/ 299,
+ -1,
+ /*0x24e7*/ 798,
+ /*0x10438*/ 1089,
+ /*0x13d1*/ 526,
+ /*0x0451*/ 324,
+ /*0x04d1*/ 391,
+ /*0xa75b*/ 1013,
+ -1,
+ /*0x10ce3*/ 1184,
+ /*0x1e51*/ 605,
+ /*0x1ed1*/ 664,
+ /*0x0151*/ 94,
+ /*0x0251*/ 200,
+ /*0x2cd1*/ 896,
+ /*0x13d7*/ 532,
+ /*0x0457*/ 330,
+ /*0x04d7*/ 394,
+ /*0xa759*/ 1012,
+ /*0x24d1*/ 776,
+ /*0x10ce5*/ 1186,
+ /*0x1e57*/ 608,
+ /*0x1ed7*/ 667,
+ /*0x0157*/ 97,
+ /*0x0257*/ 205,
+ /*0x2cd7*/ 899,
+ -1, -1,
+ /*0x0586*/ 476,
+ -1,
+ /*0x24d7*/ 782,
+ /*0x10ce9*/ 1190,
+ -1, -1,
+ /*0xa767*/ 1019,
+ /*0x13da*/ 535,
+ /*0x045a*/ 333,
+ /*0x13d3*/ 528,
+ /*0x0453*/ 326,
+ /*0x04d3*/ 392,
+ /*0x104da*/ 1115,
+ /*0xa661*/ 965,
+ /*0x10cdb*/ 1176,
+ /*0x1e53*/ 606,
+ /*0x1ed3*/ 665,
+ /*0x0153*/ 95,
+ /*0x0253*/ 202,
+ /*0x2cd3*/ 897,
+ -1, -1,
+ /*0x24da*/ 785,
+ /*0xa751*/ 1008,
+ /*0x24d3*/ 778,
+ /*0x10cd9*/ 1174,
+ -1, -1, -1,
+ /*0x13a6*/ 483,
+ /*0x13dd*/ 538,
+ /*0x045d*/ 336,
+ /*0x04dd*/ 397,
+ /*0x03e1*/ 279,
+ /*0xa757*/ 1011,
+ /*0x104dd*/ 1118,
+ /*0x1e5d*/ 611,
+ /*0x1edd*/ 670,
+ /*0x015d*/ 100,
+ /*0xa663*/ 966,
+ /*0x2cdd*/ 902,
+ /*0x10ce7*/ 1188,
+ -1, -1,
+ /*0x0582*/ 472,
+ /*0x24dd*/ 788,
+ -1,
+ /*0x13df*/ 540,
+ /*0x045f*/ 338,
+ /*0x04df*/ 398,
+ /*0xa665*/ 967,
+ -1,
+ /*0x104df*/ 1120,
+ /*0x1e5f*/ 612,
+ /*0x1edf*/ 671,
+ /*0x015f*/ 101,
+ /*0xa753*/ 1009,
+ /*0x2cdf*/ 903,
+ /*0x10cd1*/ 1166,
+ /*0x03e3*/ 280,
+ /*0xab53*/ 1046,
+ /*0xa669*/ 969,
+ /*0x24df*/ 790,
+ -1, -1,
+ /*0x028a*/ 229,
+ /*0x028b*/ 230,
+ /*0x13bc*/ 505,
+ /*0x043c*/ 303,
+ /*0x10cd7*/ 1172,
+ /*0x03e5*/ 281,
+ /*0x1043c*/ 1093,
+ /*0xa65b*/ 962,
+ -1, -1,
+ /*0x013c*/ 84,
+ /*0x023c*/ 190,
+ /*0xa75d*/ 1014,
+ /*0x13cf*/ 524,
+ /*0x044f*/ 322,
+ /*0x04cf*/ 390,
+ /*0x03e9*/ 283,
+ /*0x1044f*/ 1112,
+ /*0xa659*/ 961,
+ /*0x1e4f*/ 604,
+ /*0x1ecf*/ 663,
+ /*0x014f*/ 93,
+ /*0x024f*/ 198,
+ /*0x2ccf*/ 895,
+ /*0x10cda*/ 1175,
+ -1,
+ /*0x10cd3*/ 1168,
+ /*0x03db*/ 276,
+ /*0x13ae*/ 491,
+ /*0xa75f*/ 1015,
+ /*0x2c61*/ 848,
+ /*0x13a8*/ 485,
+ /*0x1042e*/ 1079,
+ /*0x017e*/ 116,
+ /*0xa667*/ 968,
+ /*0x10428*/ 1073,
+ /*0x13cd*/ 522,
+ /*0x044d*/ 320,
+ /*0x03d9*/ 275,
+ -1,
+ /*0x1044d*/ 1110,
+ -1,
+ /*0x1e4d*/ 603,
+ /*0x1ecd*/ 662,
+ /*0x014d*/ 92,
+ /*0x024d*/ 197,
+ /*0x2ccd*/ 894,
+ /*0x10cdd*/ 1178,
+ -1,
+ /*0x13cb*/ 520,
+ /*0x044b*/ 318,
+ /*0xa651*/ 957,
+ -1,
+ /*0x1044b*/ 1108,
+ /*0x03e7*/ 282,
+ /*0x1e4b*/ 602,
+ /*0x1ecb*/ 661,
+ /*0x014b*/ 91,
+ /*0x024b*/ 196,
+ /*0x2ccb*/ 893,
+ /*0xa74f*/ 1007,
+ /*0x13ac*/ 489,
+ /*0xa657*/ 960,
+ -1,
+ /*0x10cdf*/ 1180,
+ /*0x1042c*/ 1077,
+ /*0x03b8*/ 252,
+ /*0x2c65*/ 849,
+ -1,
+ /*0x13aa*/ 487,
+ /*0x13d5*/ 530,
+ /*0x0455*/ 328,
+ /*0x04d5*/ 393,
+ /*0x1042a*/ 1075,
+ -1, -1,
+ /*0x1e55*/ 607,
+ /*0x1ed5*/ 666,
+ /*0x0155*/ 96,
+ /*0x118db*/ 1227,
+ /*0x2cd5*/ 898,
+ -1,
+ /*0x03d7*/ 274,
+ /*0xa74d*/ 1006,
+ /*0xa653*/ 958,
+ /*0x24d5*/ 780,
+ -1, -1, -1,
+ /*0x2c5b*/ 844,
+ /*0x118d9*/ 1225,
+ -1, -1, -1, -1,
+ /*0x10ccf*/ 1164,
+ /*0xa74b*/ 1005,
+ -1, -1, -1,
+ /*0x2c59*/ 842,
+ -1,
+ /*0x13c9*/ 518,
+ /*0x0449*/ 316,
+ -1,
+ /*0xa65d*/ 963,
+ /*0x10449*/ 1106,
+ /*0x029e*/ 234,
+ /*0x1e49*/ 601,
+ /*0x1ec9*/ 660,
+ -1,
+ /*0x0249*/ 195,
+ /*0x2cc9*/ 892,
+ /*0x1f61*/ 729,
+ -1, -1,
+ /*0x0580*/ 470,
+ /*0xa755*/ 1010,
+ /*0x10ccd*/ 1162,
+ -1,
+ /*0x13c3*/ 512,
+ /*0x0443*/ 310,
+ /*0xa65f*/ 964,
+ /*0x118d1*/ 1217,
+ /*0x10443*/ 1100,
+ /*0x03dd*/ 277,
+ /*0x1e43*/ 598,
+ /*0x1ec3*/ 657,
+ /*0x2c38*/ 809,
+ -1,
+ /*0x2cc3*/ 889,
+ /*0x10ccb*/ 1160,
+ -1,
+ /*0x2c51*/ 834,
+ /*0x118d7*/ 1223,
+ -1, -1,
+ /*0x13c0*/ 509,
+ /*0x0440*/ 307,
+ /*0x1f63*/ 731,
+ -1,
+ /*0x10440*/ 1097,
+ /*0x03df*/ 278,
+ /*0x1f24*/ 706,
+ /*0x2c57*/ 840,
+ /*0x0140*/ 86,
+ /*0x0240*/ 192,
+ -1, -1,
+ /*0xa749*/ 1004,
+ /*0x1f65*/ 733,
+ /*0x13a0*/ 477,
+ /*0x10cd5*/ 1170,
+ /*0xa64f*/ 956,
+ /*0x118da*/ 1226,
+ -1,
+ /*0x118d3*/ 1219,
+ -1, -1,
+ /*0x1f10*/ 696,
+ -1, -1,
+ /*0x03bc*/ 256,
+ -1,
+ /*0x2c5a*/ 843,
+ -1,
+ /*0x2c53*/ 836,
+ /*0xa743*/ 1001,
+ /*0x13c1*/ 510,
+ /*0x0441*/ 308,
+ -1, -1,
+ /*0x10441*/ 1098,
+ -1,
+ /*0x1e41*/ 597,
+ /*0x1ec1*/ 656,
+ /*0xa64d*/ 955,
+ /*0x118dd*/ 1229,
+ /*0x2cc1*/ 888,
+ -1, -1, -1,
+ /*0x1f14*/ 700,
+ -1,
+ /*0x10cc9*/ 1158,
+ -1,
+ /*0x01e1*/ 151,
+ /*0x2c5d*/ 846,
+ /*0x03ae*/ 243,
+ /*0xa64b*/ 954,
+ -1,
+ /*0x13c7*/ 516,
+ /*0x0447*/ 314,
+ -1,
+ /*0x118df*/ 1231,
+ /*0x10447*/ 1104,
+ /*0x03cd*/ 272,
+ /*0x1e47*/ 600,
+ /*0x1ec7*/ 659,
+ /*0x1f67*/ 735,
+ /*0x0247*/ 194,
+ /*0x2cc7*/ 891,
+ /*0x10cc3*/ 1152,
+ /*0x1f22*/ 704,
+ -1, -1,
+ /*0x0292*/ 232,
+ /*0x13c5*/ 514,
+ /*0x0445*/ 312,
+ /*0x03cb*/ 270,
+ /*0xa655*/ 959,
+ /*0x10445*/ 1102,
+ /*0x01e3*/ 152,
+ /*0x1e45*/ 599,
+ /*0x1ec5*/ 658,
+ /*0xa741*/ 1000,
+ /*0x1f51*/ 724,
+ /*0x2cc5*/ 890,
+ /*0x0561*/ 439,
+ /*0x10cc0*/ 1149,
+ /*0xff59*/ 1071,
+ /*0x03ac*/ 241,
+ -1,
+ /*0x01e5*/ 153,
+ /*0x2c3c*/ 813,
+ /*0x118cf*/ 1215,
+ -1,
+ /*0x1f57*/ 727,
+ /*0x051b*/ 428,
+ -1, -1, -1, -1,
+ /*0x050b*/ 420,
+ /*0x01e9*/ 155,
+ /*0x2c4f*/ 832,
+ -1,
+ /*0x1f06*/ 694,
+ /*0xa747*/ 1003,
+ /*0x13b2*/ 495,
+ /*0x0432*/ 293,
+ /*0x0584*/ 474,
+ /*0xa649*/ 953,
+ /*0x10432*/ 1083,
+ /*0x0563*/ 441,
+ /*0x2d16*/ 931,
+ -1,
+ /*0x2d1b*/ 936,
+ /*0x118cd*/ 1213,
+ /*0x1f53*/ 725,
+ /*0x10cc1*/ 1150,
+ /*0x2d0a*/ 919,
+ /*0x2d0b*/ 920,
+ /*0xff51*/ 1063,
+ /*0xa745*/ 1002,
+ /*0x0565*/ 443,
+ -1, -1,
+ /*0x2c4d*/ 830,
+ -1,
+ /*0xa643*/ 950,
+ /*0x118cb*/ 1211,
+ /*0x03c9*/ 268,
+ -1,
+ /*0xff57*/ 1069,
+ -1,
+ /*0x0569*/ 447,
+ /*0x2d24*/ 945,
+ -1,
+ /*0x1f26*/ 708,
+ /*0x0491*/ 359,
+ /*0x2c4b*/ 828,
+ /*0x01e7*/ 154,
+ /*0x10cc7*/ 1156,
+ /*0x1e11*/ 573,
+ /*0x1e91*/ 637,
+ /*0x0111*/ 64,
+ /*0x0211*/ 173,
+ /*0x2c91*/ 864,
+ /*0xa79b*/ 1036,
+ /*0x03c3*/ 262,
+ /*0x1f02*/ 690,
+ /*0x118d5*/ 1221,
+ /*0x2d10*/ 925,
+ /*0xff5a*/ 1072,
+ /*0x1e924*/ 1234,
+ /*0xff53*/ 1065,
+ /*0x2d18*/ 933,
+ -1,
+ /*0x10cc5*/ 1154,
+ -1,
+ /*0x0280*/ 224,
+ /*0x2c55*/ 838,
+ /*0x13f3*/ 560,
+ /*0x0473*/ 348,
+ /*0x04f3*/ 408,
+ /*0x0073*/ 17,
+ /*0x03c0*/ 260,
+ /*0x104f3*/ 1140,
+ /*0x1e73*/ 622,
+ /*0x1ef3*/ 681,
+ /*0x0173*/ 111,
+ -1,
+ /*0x2cf3*/ 908,
+ /*0x0567*/ 445,
+ -1,
+ /*0x2d14*/ 929,
+ /*0x019e*/ 126,
+ /*0xa641*/ 949,
+ /*0x028c*/ 231,
+ /*0x13eb*/ 552,
+ /*0x046b*/ 344,
+ /*0x04eb*/ 404,
+ /*0x006b*/ 9,
+ /*0x118c9*/ 1209,
+ /*0x104eb*/ 1132,
+ /*0x1e6b*/ 618,
+ /*0x1eeb*/ 677,
+ /*0x016b*/ 107,
+ /*0x026b*/ 217,
+ /*0x01da*/ 147,
+ -1, -1, -1,
+ /*0x2c49*/ 826,
+ -1, -1,
+ /*0x2d22*/ 943,
+ /*0x03c1*/ 261,
+ -1,
+ /*0x048f*/ 358,
+ /*0xa647*/ 952,
+ /*0x118c3*/ 1203,
+ /*0x1f12*/ 698,
+ /*0x1e0f*/ 572,
+ /*0x1e8f*/ 636,
+ /*0x010f*/ 63,
+ /*0x020f*/ 172,
+ /*0x2c8f*/ 863,
+ /*0xa69b*/ 985,
+ -1, -1,
+ /*0x2c43*/ 820,
+ /*0x01dd*/ 149,
+ /*0xa68b*/ 977,
+ /*0x1e922*/ 1232,
+ -1,
+ /*0xa645*/ 951,
+ -1,
+ /*0x118c0*/ 1200,
+ -1,
+ /*0x03c7*/ 266,
+ -1,
+ /*0x1e938*/ 1254,
+ -1,
+ /*0xff4f*/ 1061,
+ -1,
+ /*0xa76b*/ 1021,
+ /*0x2d1e*/ 939,
+ /*0x2c40*/ 817,
+ /*0x01df*/ 150,
+ /*0x2d06*/ 915,
+ /*0x0373*/ 236,
+ /*0x13ef*/ 556,
+ /*0x046f*/ 346,
+ /*0x04ef*/ 406,
+ /*0x006f*/ 13,
+ /*0x03c5*/ 264,
+ /*0x104ef*/ 1136,
+ /*0x1e6f*/ 620,
+ /*0x1eef*/ 679,
+ /*0x016f*/ 109,
+ /*0x026f*/ 219,
+ -1, -1,
+ /*0x1f55*/ 726,
+ /*0x2d0e*/ 923,
+ -1,
+ /*0xff4d*/ 1059,
+ -1,
+ /*0x118c1*/ 1201,
+ /*0x13ed*/ 554,
+ /*0x046d*/ 345,
+ /*0x04ed*/ 405,
+ /*0x006d*/ 11,
+ -1,
+ /*0x104ed*/ 1134,
+ /*0x1e6d*/ 619,
+ /*0x1eed*/ 678,
+ /*0x016d*/ 108,
+ /*0x2c41*/ 818,
+ /*0xff4b*/ 1057,
+ /*0x10ceb*/ 1192,
+ -1,
+ /*0x13b7*/ 500,
+ /*0x0437*/ 298,
+ /*0x04b7*/ 378,
+ -1,
+ /*0x10437*/ 1088,
+ /*0x03b2*/ 246,
+ /*0x1e37*/ 592,
+ /*0x1eb7*/ 651,
+ /*0x0137*/ 82,
+ /*0x118c7*/ 1207,
+ /*0x2cb7*/ 883,
+ /*0x2d02*/ 911,
+ /*0x0192*/ 122,
+ -1,
+ /*0x019a*/ 125,
+ /*0x01a8*/ 130,
+ /*0xa76f*/ 1023,
+ /*0x1e926*/ 1236,
+ /*0xff55*/ 1067,
+ /*0x2c47*/ 824,
+ /*0x1fe1*/ 755,
+ -1,
+ /*0x0481*/ 355,
+ /*0x0581*/ 471,
+ /*0x1f00*/ 688,
+ /*0x118c5*/ 1205,
+ /*0x1e01*/ 565,
+ /*0x1e81*/ 629,
+ /*0x0101*/ 56,
+ /*0x0201*/ 165,
+ /*0x2c81*/ 856,
+ /*0x1f43*/ 721,
+ -1, -1,
+ /*0xa76d*/ 1022,
+ /*0x2c45*/ 822,
+ /*0x13b3*/ 496,
+ /*0x0433*/ 294,
+ /*0x04b3*/ 376,
+ -1,
+ /*0x10433*/ 1084,
+ /*0x057e*/ 468,
+ /*0x1e33*/ 590,
+ /*0x1eb3*/ 649,
+ /*0x0133*/ 80,
+ /*0x0233*/ 189,
+ /*0x2cb3*/ 881,
+ /*0xa737*/ 995,
+ /*0x1f40*/ 718,
+ -1,
+ /*0xff49*/ 1055,
+ /*0x10cef*/ 1196,
+ -1, -1, -1,
+ /*0x1e93c*/ 1258,
+ /*0xa66b*/ 970,
+ /*0x1fe5*/ 756,
+ -1,
+ /*0x03f3*/ 288,
+ -1,
+ /*0x217e*/ 772,
+ /*0x1f20*/ 702,
+ /*0x2d12*/ 927,
+ /*0x13a5*/ 482,
+ /*0x2d1a*/ 935,
+ /*0x04a5*/ 369,
+ /*0x2c32*/ 803,
+ /*0xff43*/ 1049,
+ /*0x10ced*/ 1194,
+ /*0x1e25*/ 583,
+ /*0x1ea5*/ 642,
+ /*0x0125*/ 74,
+ /*0x0225*/ 182,
+ /*0x2ca5*/ 874,
+ -1,
+ /*0x03eb*/ 284,
+ -1, -1,
+ /*0x1f41*/ 719,
+ /*0x0288*/ 227,
+ /*0x1e92e*/ 1244,
+ -1,
+ /*0xa733*/ 993,
+ /*0x1e928*/ 1238,
+ -1,
+ /*0x01c9*/ 139,
+ -1,
+ /*0x13b5*/ 498,
+ /*0x0435*/ 296,
+ /*0x04b5*/ 377,
+ -1,
+ /*0x10435*/ 1086,
+ -1,
+ /*0x1e35*/ 591,
+ /*0x1eb5*/ 650,
+ /*0x0135*/ 81,
+ /*0x0180*/ 117,
+ /*0x2cb5*/ 882,
+ /*0x13ad*/ 490,
+ -1,
+ /*0x04ad*/ 373,
+ -1,
+ /*0x1042d*/ 1078,
+ -1,
+ /*0x1e2d*/ 587,
+ /*0x1ead*/ 646,
+ /*0x012d*/ 78,
+ /*0x022d*/ 186,
+ /*0x2cad*/ 878,
+ -1,
+ /*0xa725*/ 987,
+ -1, -1,
+ /*0x1e92c*/ 1242,
+ /*0x018c*/ 121,
+ /*0xff41*/ 1047,
+ -1,
+ /*0x1f45*/ 723,
+ -1, -1,
+ /*0x2c73*/ 854,
+ /*0x1e92a*/ 1240,
+ /*0x1fd1*/ 753,
+ /*0x13a3*/ 480,
+ -1,
+ /*0x04a3*/ 368,
+ /*0xa66d*/ 971,
+ -1,
+ /*0x03ef*/ 286,
+ /*0x1e23*/ 582,
+ /*0x1ea3*/ 641,
+ /*0x0123*/ 73,
+ /*0x0223*/ 181,
+ /*0x2ca3*/ 873,
+ /*0xa735*/ 994,
+ -1, -1,
+ /*0x0585*/ 475,
+ /*0xff47*/ 1053,
+ -1,
+ /*0x1e05*/ 567,
+ /*0x1e85*/ 631,
+ /*0x0105*/ 58,
+ /*0x0205*/ 167,
+ /*0x2c85*/ 858,
+ /*0xa72d*/ 991,
+ /*0x03ed*/ 285,
+ /*0x2d00*/ 909,
+ /*0x1f04*/ 692,
+ /*0x1f32*/ 712,
+ -1,
+ /*0x13bf*/ 508,
+ /*0x043f*/ 306,
+ /*0x04bf*/ 382,
+ /*0xff45*/ 1051,
+ /*0x1043f*/ 1096,
+ -1,
+ /*0x1e3f*/ 596,
+ /*0x1ebf*/ 655,
+ /*0x03b7*/ 251,
+ /*0x023f*/ 191,
+ /*0x2cbf*/ 887,
+ -1, -1, -1,
+ /*0x2d0c*/ 921,
+ -1,
+ /*0x13b1*/ 494,
+ /*0x0431*/ 292,
+ /*0x04b1*/ 375,
+ /*0xa723*/ 986,
+ /*0x10431*/ 1082,
+ /*0x1e943*/ 1265,
+ /*0x1e31*/ 589,
+ /*0x1eb1*/ 648,
+ -1,
+ /*0x0231*/ 188,
+ /*0x2cb1*/ 880,
+ /*0x1f11*/ 697,
+ /*0x13c2*/ 511,
+ /*0x0442*/ 309,
+ /*0x04c2*/ 383,
+ -1,
+ /*0x10442*/ 1099,
+ /*0x13a7*/ 484,
+ /*0x2d20*/ 941,
+ /*0x04a7*/ 370,
+ /*0x0142*/ 87,
+ /*0x0242*/ 193,
+ /*0x1e940*/ 1262,
+ /*0x1e27*/ 584,
+ /*0x1ea7*/ 643,
+ /*0x0127*/ 75,
+ /*0x0227*/ 183,
+ /*0x2ca7*/ 875,
+ /*0x03b3*/ 247,
+ -1,
+ /*0xa78c*/ 1031,
+ /*0xa73f*/ 999,
+ /*0x13f1*/ 558,
+ /*0x0471*/ 347,
+ /*0x04f1*/ 407,
+ /*0x0071*/ 15,
+ /*0x1f73*/ 739,
+ /*0x104f1*/ 1138,
+ /*0x1e71*/ 621,
+ /*0x1ef1*/ 680,
+ /*0x0171*/ 110,
+ /*0x0271*/ 220,
+ /*0x13f5*/ 562,
+ /*0x0475*/ 349,
+ /*0x04f5*/ 409,
+ /*0x0075*/ 19,
+ -1,
+ /*0x104f5*/ 1142,
+ /*0x1e75*/ 623,
+ /*0x1ef5*/ 682,
+ /*0x0175*/ 112,
+ /*0x0275*/ 222,
+ /*0x00e1*/ 26,
+ /*0x1e941*/ 1263,
+ /*0x2c37*/ 808,
+ /*0x13bd*/ 506,
+ /*0x043d*/ 304,
+ /*0x04bd*/ 381,
+ -1,
+ /*0x1043d*/ 1094,
+ -1,
+ /*0x1e3d*/ 595,
+ /*0x1ebd*/ 654,
+ -1,
+ /*0xa727*/ 988,
+ /*0x2cbd*/ 886,
+ /*0x13b9*/ 502,
+ /*0x0439*/ 300,
+ /*0x04b9*/ 379,
+ -1,
+ /*0x10439*/ 1090,
+ /*0x017c*/ 115,
+ /*0x1e39*/ 593,
+ /*0x1eb9*/ 652,
+ -1,
+ /*0x13af*/ 492,
+ /*0x2cb9*/ 884,
+ /*0x04af*/ 374,
+ /*0x00e3*/ 28,
+ /*0x1042f*/ 1080,
+ /*0x03b5*/ 249,
+ /*0x1e2f*/ 588,
+ /*0x1eaf*/ 647,
+ /*0x012f*/ 79,
+ /*0x022f*/ 187,
+ /*0x2caf*/ 879,
+ -1, -1, -1,
+ /*0x00e5*/ 30,
+ /*0x2c33*/ 804,
+ /*0x03ad*/ 242,
+ /*0x0583*/ 473,
+ -1,
+ /*0x10cc2*/ 1151,
+ /*0x1e03*/ 566,
+ /*0x1e83*/ 630,
+ /*0x0103*/ 57,
+ /*0x0203*/ 166,
+ /*0x2c83*/ 857,
+ /*0x00e9*/ 34,
+ /*0x0371*/ 235,
+ /*0xa73d*/ 998,
+ -1,
+ /*0x2d1c*/ 937,
+ /*0x2d04*/ 913,
+ -1, -1, -1,
+ /*0x01f3*/ 159,
+ /*0xa77c*/ 1025,
+ -1,
+ /*0x0188*/ 120,
+ /*0xa739*/ 996,
+ /*0x10cf1*/ 1198,
+ -1,
+ /*0x0511*/ 423,
+ -1, -1, -1, -1,
+ /*0x13a9*/ 486,
+ /*0xa72f*/ 992,
+ /*0x04a9*/ 371,
+ /*0x1e932*/ 1248,
+ /*0x10429*/ 1074,
+ /*0x01eb*/ 156,
+ /*0x1e29*/ 585,
+ /*0x1ea9*/ 644,
+ /*0x0129*/ 76,
+ /*0x0229*/ 184,
+ /*0x2ca9*/ 876,
+ /*0x037c*/ 239,
+ -1, -1,
+ /*0x2d11*/ 926,
+ -1,
+ /*0x1f37*/ 717,
+ /*0x00e7*/ 32,
+ -1, -1,
+ /*0x0573*/ 457,
+ /*0x2c35*/ 806,
+ -1,
+ /*0x03bf*/ 259,
+ /*0x13ab*/ 488,
+ -1,
+ /*0x04ab*/ 372,
+ -1,
+ /*0x1042b*/ 1076,
+ -1,
+ /*0x1e2b*/ 586,
+ /*0x1eab*/ 645,
+ /*0x012b*/ 77,
+ /*0x022b*/ 185,
+ /*0x2cab*/ 877,
+ -1,
+ /*0x1f01*/ 689,
+ /*0x056b*/ 449,
+ -1,
+ /*0x03b1*/ 245,
+ /*0x2173*/ 761,
+ -1,
+ /*0x2d08*/ 917,
+ -1, -1, -1,
+ /*0xa791*/ 1032,
+ /*0xa729*/ 989,
+ -1,
+ /*0x13c6*/ 515,
+ /*0x0446*/ 313,
+ /*0x04c6*/ 385,
+ /*0x1f33*/ 713,
+ /*0x10446*/ 1103,
+ /*0x13a1*/ 478,
+ /*0x050f*/ 422,
+ /*0x04a1*/ 367,
+ /*0x0146*/ 89,
+ /*0x01ef*/ 158,
+ -1,
+ /*0x1e21*/ 581,
+ /*0x1ea1*/ 640,
+ /*0x0121*/ 72,
+ -1,
+ /*0x2ca1*/ 872,
+ /*0x13c4*/ 513,
+ /*0x0444*/ 311,
+ /*0x04c4*/ 384,
+ -1,
+ /*0x10444*/ 1101,
+ -1,
+ /*0xa72b*/ 990,
+ /*0x13f2*/ 559,
+ /*0x0144*/ 88,
+ /*0x2d0f*/ 924,
+ /*0x0072*/ 16,
+ /*0x01ed*/ 157,
+ /*0x104f2*/ 1139,
+ -1, -1,
+ /*0x1f25*/ 707,
+ /*0x0272*/ 221,
+ /*0x13bb*/ 504,
+ /*0x043b*/ 302,
+ /*0x04bb*/ 380,
+ /*0x2c3f*/ 816,
+ /*0x1043b*/ 1092,
+ -1,
+ /*0x1e3b*/ 594,
+ /*0x1ebb*/ 653,
+ /*0x056f*/ 453,
+ /*0x0495*/ 361,
+ /*0x2cbb*/ 885,
+ -1,
+ /*0x03bd*/ 257,
+ /*0x1e15*/ 575,
+ /*0x1e95*/ 639,
+ /*0x0115*/ 66,
+ /*0x0215*/ 175,
+ /*0x2c95*/ 866,
+ -1,
+ /*0x2c31*/ 802,
+ -1,
+ /*0x118c2*/ 1202,
+ /*0x1f35*/ 715,
+ /*0x03b9*/ 253,
+ /*0xa691*/ 980,
+ -1,
+ /*0x056d*/ 451,
+ -1, -1,
+ /*0x0493*/ 360,
+ -1,
+ /*0x2c42*/ 819,
+ /*0x03af*/ 244,
+ /*0x1e13*/ 574,
+ /*0x1e93*/ 638,
+ /*0x0113*/ 65,
+ /*0x0213*/ 174,
+ /*0x2c93*/ 865,
+ -1,
+ /*0x047b*/ 352,
+ /*0x04fb*/ 412,
+ -1, -1,
+ /*0x104fb*/ 1148,
+ /*0x1e7b*/ 626,
+ /*0x1efb*/ 685,
+ -1,
+ /*0xa73b*/ 997,
+ -1,
+ /*0x10cc6*/ 1155,
+ /*0x0479*/ 351,
+ /*0x04f9*/ 411,
+ /*0x0079*/ 23,
+ -1,
+ /*0x104f9*/ 1146,
+ /*0x1e79*/ 625,
+ /*0x1ef9*/ 684,
+ -1,
+ /*0x1f23*/ 705,
+ /*0x0501*/ 415,
+ -1, -1,
+ /*0x047d*/ 353,
+ /*0x04fd*/ 413,
+ /*0x0283*/ 225,
+ /*0x10cc4*/ 1153,
+ /*0x00fe*/ 54,
+ /*0x1e7d*/ 627,
+ /*0x1efd*/ 686,
+ /*0x1f05*/ 693,
+ /*0x027d*/ 223,
+ /*0x01a5*/ 129,
+ /*0x10cf2*/ 1199,
+ /*0x0499*/ 363,
+ /*0x2c3d*/ 814,
+ -1,
+ /*0x1e937*/ 1253,
+ /*0x1e19*/ 577,
+ /*0x2d01*/ 910,
+ /*0x0119*/ 68,
+ /*0x0219*/ 177,
+ /*0x2c99*/ 868,
+ -1, -1,
+ /*0xa68f*/ 979,
+ /*0x2c39*/ 810,
+ -1,
+ /*0x0477*/ 350,
+ /*0x04f7*/ 410,
+ /*0x0077*/ 21,
+ /*0xa7b7*/ 1045,
+ /*0x104f7*/ 1144,
+ /*0x1e77*/ 624,
+ /*0x1ef7*/ 683,
+ /*0x0177*/ 113,
+ /*0x1e07*/ 568,
+ /*0x1e87*/ 632,
+ /*0x0107*/ 59,
+ /*0x0207*/ 168,
+ /*0x2c87*/ 859,
+ -1,
+ /*0x1d79*/ 563,
+ /*0x1f31*/ 711,
+ /*0x0525*/ 433,
+ -1, -1,
+ /*0x01ad*/ 131,
+ /*0x037b*/ 238,
+ /*0x13d0*/ 525,
+ /*0x0450*/ 323,
+ /*0xa781*/ 1027,
+ -1,
+ /*0x1e933*/ 1249,
+ /*0x1d7d*/ 564,
+ /*0x1f42*/ 720,
+ /*0x047f*/ 354,
+ /*0x04ff*/ 414,
+ /*0x0250*/ 199,
+ -1,
+ /*0x1f27*/ 709,
+ /*0x1e7f*/ 628,
+ /*0x1eff*/ 687,
+ /*0x2d25*/ 946,
+ /*0x24d0*/ 775,
+ /*0x13ce*/ 523,
+ /*0x044e*/ 321,
+ /*0x04ce*/ 389,
+ /*0x03c6*/ 265,
+ /*0x1044e*/ 1111,
+ /*0x0497*/ 362,
+ /*0x037d*/ 240,
+ /*0x01a3*/ 128,
+ -1,
+ /*0x1e17*/ 576,
+ /*0x1f71*/ 737,
+ /*0x0117*/ 67,
+ /*0x0217*/ 176,
+ /*0x2c97*/ 867,
+ /*0x052d*/ 437,
+ -1,
+ /*0x1e925*/ 1235,
+ -1,
+ /*0x0185*/ 119,
+ /*0x03c4*/ 263,
+ /*0x1f75*/ 741,
+ /*0x13cc*/ 521,
+ /*0x044c*/ 319,
+ /*0x04cc*/ 388,
+ -1,
+ /*0x1044c*/ 1109,
+ /*0x03f2*/ 287,
+ /*0xff42*/ 1048,
+ -1,
+ /*0x13e6*/ 547,
+ /*0xa7a5*/ 1041,
+ /*0x0377*/ 237,
+ /*0x0066*/ 5,
+ /*0x2d2d*/ 948,
+ /*0x104e6*/ 1127,
+ /*0x01bf*/ 137,
+ /*0x03bb*/ 255,
+ /*0xa77f*/ 1026,
+ /*0x0266*/ 213,
+ /*0x0523*/ 432,
+ /*0x1e935*/ 1251,
+ /*0x1f7c*/ 748,
+ -1, -1,
+ /*0x24e6*/ 797,
+ -1,
+ /*0xa681*/ 972,
+ /*0x007a*/ 24,
+ -1,
+ /*0x104fa*/ 1147,
+ /*0x0505*/ 417,
+ /*0x1e92d*/ 1243,
+ /*0x017a*/ 114,
+ -1,
+ /*0xa7b5*/ 1044,
+ /*0x118c6*/ 1206,
+ -1, -1,
+ /*0x2d23*/ 944,
+ -1,
+ /*0x13c8*/ 517,
+ /*0x0448*/ 315,
+ /*0x04c8*/ 386,
+ -1,
+ /*0x10448*/ 1105,
+ /*0x2c46*/ 823,
+ /*0x10cd0*/ 1165,
+ /*0x1f03*/ 691,
+ /*0x0148*/ 90,
+ /*0x2d05*/ 914,
+ /*0x2184*/ 774,
+ /*0x118c4*/ 1204,
+ /*0x13d8*/ 533,
+ /*0x0458*/ 331,
+ /*0x03fb*/ 290,
+ /*0x13ec*/ 553,
+ /*0x1e923*/ 1233,
+ /*0x104d8*/ 1113,
+ /*0x006c*/ 10,
+ -1,
+ /*0x104ec*/ 1133,
+ /*0x2c44*/ 821,
+ /*0x10cce*/ 1163,
+ -1,
+ /*0x026c*/ 218,
+ /*0x2cec*/ 906,
+ -1,
+ /*0x24d8*/ 783,
+ /*0x049d*/ 365,
+ -1,
+ /*0xa7a3*/ 1040,
+ /*0xa77a*/ 1024,
+ /*0x1e1d*/ 579,
+ /*0x01f5*/ 160,
+ /*0x011d*/ 70,
+ /*0x021d*/ 179,
+ /*0x2c9d*/ 870,
+ -1,
+ /*0x2c3b*/ 812,
+ -1,
+ /*0x0527*/ 434,
+ /*0xa785*/ 1029,
+ -1,
+ /*0x10ccc*/ 1161,
+ /*0x1e93f*/ 1261,
+ -1,
+ /*0x01bd*/ 136,
+ /*0x13e8*/ 549,
+ -1, -1,
+ /*0x0068*/ 7,
+ /*0x10ce6*/ 1187,
+ /*0x104e8*/ 1129,
+ -1, -1,
+ /*0x0571*/ 455,
+ /*0x0268*/ 214,
+ /*0x01b9*/ 135,
+ /*0x13f0*/ 557,
+ /*0x2d27*/ 947,
+ /*0x1e931*/ 1247,
+ /*0x0070*/ 14,
+ /*0x24e8*/ 799,
+ /*0x104f0*/ 1137,
+ -1,
+ /*0x0575*/ 459,
+ -1, -1, -1,
+ /*0x13dc*/ 537,
+ /*0x045c*/ 335,
+ -1,
+ /*0x1e942*/ 1264,
+ -1,
+ /*0x104dc*/ 1117,
+ /*0x2171*/ 759,
+ -1,
+ /*0x1e927*/ 1237,
+ /*0x025c*/ 208,
+ /*0x0076*/ 20,
+ /*0x0183*/ 118,
+ /*0x104f6*/ 1143,
+ /*0x10cc8*/ 1157,
+ /*0x0287*/ 226,
+ /*0x24dc*/ 787,
+ /*0x2175*/ 763,
+ /*0x057c*/ 466,
+ /*0x13d6*/ 531,
+ /*0x0456*/ 329,
+ -1,
+ /*0x13e0*/ 541,
+ /*0xa7a7*/ 1042,
+ -1,
+ /*0x1f21*/ 703,
+ /*0x10cd8*/ 1173,
+ /*0x104e0*/ 1121,
+ /*0x0256*/ 204,
+ /*0x10cec*/ 1193,
+ /*0x052f*/ 438,
+ /*0x0260*/ 209,
+ /*0x03ce*/ 273,
+ /*0xa685*/ 974,
+ /*0x24d6*/ 781,
+ -1,
+ /*0x1f44*/ 722,
+ /*0x24e0*/ 791,
+ /*0x217c*/ 770,
+ /*0x13d4*/ 529,
+ /*0x0454*/ 327,
+ -1, -1,
+ /*0x1f72*/ 738,
+ /*0x0503*/ 416,
+ -1,
+ /*0x13ea*/ 551,
+ /*0x1e93d*/ 1259,
+ /*0x0254*/ 203,
+ /*0x006a*/ 8,
+ -1,
+ /*0x104ea*/ 1131,
+ -1,
+ /*0x03cc*/ 271,
+ /*0x24d4*/ 779,
+ /*0x026a*/ 216,
+ -1,
+ /*0xff46*/ 1052,
+ /*0x1e939*/ 1255,
+ /*0x13e4*/ 545,
+ /*0x1f15*/ 701,
+ /*0x10ce8*/ 1189,
+ /*0x0064*/ 3,
+ /*0x2d03*/ 912,
+ /*0x104e4*/ 1125,
+ /*0x13b6*/ 499,
+ /*0x0436*/ 297,
+ /*0x1e92f*/ 1245,
+ /*0x118d0*/ 1216,
+ /*0x10436*/ 1087,
+ -1, -1,
+ /*0x10cf0*/ 1197,
+ /*0xff44*/ 1050,
+ /*0x24e4*/ 795,
+ /*0x0078*/ 22,
+ /*0x0529*/ 435,
+ /*0x104f8*/ 1145,
+ /*0x2c50*/ 833,
+ -1,
+ /*0x1f13*/ 699,
+ -1,
+ /*0x00f3*/ 44,
+ /*0x10cdc*/ 1177,
+ /*0x118ce*/ 1214,
+ /*0x13ca*/ 519,
+ /*0x044a*/ 317,
+ /*0x04ca*/ 387,
+ -1,
+ /*0x1044a*/ 1107,
+ -1,
+ /*0x1f7b*/ 747,
+ /*0x03c8*/ 267,
+ /*0x01c6*/ 138,
+ /*0x2c4e*/ 831,
+ /*0xa783*/ 1028,
+ -1, -1,
+ /*0x01a1*/ 127,
+ /*0x00eb*/ 36,
+ /*0x052b*/ 436,
+ /*0x10cd6*/ 1171,
+ /*0x1f79*/ 745,
+ -1,
+ /*0x10ce0*/ 1181,
+ /*0x118cc*/ 1212,
+ /*0x13f4*/ 561,
+ /*0x13d2*/ 527,
+ /*0x0452*/ 325,
+ /*0x0074*/ 18,
+ -1,
+ /*0x104f4*/ 1141,
+ -1,
+ /*0x1e929*/ 1239,
+ /*0x1f7d*/ 749,
+ /*0x2c4c*/ 829,
+ /*0x0252*/ 201,
+ -1, -1, -1, -1,
+ /*0x10cd4*/ 1169,
+ /*0x24d2*/ 777,
+ /*0x2c66*/ 850,
+ -1,
+ /*0x13b0*/ 493,
+ /*0x0430*/ 291,
+ /*0xa7a9*/ 1043,
+ /*0x10cea*/ 1191,
+ /*0x10430*/ 1081,
+ /*0x0521*/ 431,
+ -1, -1,
+ /*0x0195*/ 123,
+ -1,
+ /*0x13e2*/ 543,
+ /*0x029d*/ 233,
+ /*0x1e92b*/ 1241,
+ /*0x0062*/ 1,
+ /*0x1f77*/ 743,
+ /*0x104e2*/ 1123,
+ /*0x10ce4*/ 1185,
+ /*0x1f07*/ 695,
+ -1,
+ /*0x118c8*/ 1208,
+ -1, -1, -1,
+ /*0x0572*/ 456,
+ /*0x2d21*/ 942,
+ /*0x24e2*/ 793,
+ /*0x1fb1*/ 751,
+ /*0x00ef*/ 40,
+ /*0x048d*/ 357,
+ /*0x2c48*/ 825,
+ /*0xa683*/ 973,
+ /*0x118d8*/ 1224,
+ /*0x1e0d*/ 571,
+ /*0x1e8d*/ 635,
+ /*0x010d*/ 62,
+ /*0x020d*/ 171,
+ /*0x2c8d*/ 862,
+ -1, -1,
+ /*0x01fb*/ 162,
+ /*0x0515*/ 425,
+ /*0x2c58*/ 841,
+ /*0x10cca*/ 1159,
+ /*0x2172*/ 760,
+ /*0x2c6c*/ 853,
+ /*0x00ed*/ 38,
+ -1,
+ /*0x13b4*/ 497,
+ /*0x0434*/ 295,
+ -1,
+ /*0x01f9*/ 161,
+ /*0x10434*/ 1085,
+ -1, -1, -1, -1,
+ /*0xa7a1*/ 1039,
+ -1, -1,
+ /*0x2d15*/ 930,
+ /*0x0513*/ 424,
+ -1,
+ /*0x01fd*/ 163,
+ -1,
+ /*0x10cd2*/ 1167,
+ /*0x1e09*/ 569,
+ /*0x1e89*/ 633,
+ /*0x0109*/ 60,
+ /*0x0209*/ 169,
+ /*0x2c89*/ 860,
+ /*0x1e93b*/ 1257,
+ /*0x057b*/ 465,
+ /*0x0199*/ 124,
+ /*0xff50*/ 1062,
+ -1,
+ /*0x13ee*/ 555,
+ /*0x2c68*/ 851,
+ -1,
+ /*0x006e*/ 12,
+ /*0x2d13*/ 928,
+ /*0x104ee*/ 1135,
+ /*0x1f66*/ 734,
+ /*0x0579*/ 463,
+ -1, -1,
+ /*0x2cee*/ 907,
+ -1, -1,
+ /*0x118dc*/ 1228,
+ /*0xff4e*/ 1060,
+ -1,
+ /*0x217b*/ 769,
+ /*0x10ce2*/ 1183,
+ -1,
+ /*0x057d*/ 467,
+ -1,
+ /*0x1f7a*/ 746,
+ -1,
+ /*0x2c5c*/ 845,
+ -1,
+ /*0x03b6*/ 250,
+ -1,
+ /*0x2179*/ 767,
+ -1,
+ /*0x0519*/ 427,
+ /*0x2c76*/ 855,
+ /*0x118d6*/ 1222,
+ /*0x03f8*/ 289,
+ -1,
+ /*0x01d0*/ 142,
+ /*0xff4c*/ 1058,
+ /*0xa793*/ 1033,
+ -1, -1,
+ /*0x217d*/ 771,
+ /*0x01ff*/ 164,
+ /*0x2c56*/ 839,
+ -1, -1,
+ /*0x0577*/ 461,
+ /*0x03ca*/ 269,
+ -1,
+ /*0x0507*/ 418,
+ /*0x2d19*/ 934,
+ /*0x049f*/ 366,
+ /*0x01ce*/ 141,
+ /*0x118d4*/ 1220,
+ -1,
+ /*0x1e1f*/ 580,
+ -1,
+ /*0x011f*/ 71,
+ /*0x021f*/ 180,
+ /*0x2c9f*/ 871,
+ -1, -1, -1,
+ /*0x2c54*/ 837,
+ /*0x13de*/ 539,
+ /*0x045e*/ 337,
+ /*0x2177*/ 765,
+ -1,
+ /*0x2d07*/ 916,
+ /*0x104de*/ 1119,
+ /*0x2c6a*/ 852,
+ -1, -1,
+ /*0x01cc*/ 140,
+ /*0x057f*/ 469,
+ -1,
+ /*0xff48*/ 1054,
+ -1,
+ /*0xa695*/ 982,
+ /*0x24de*/ 789,
+ -1, -1,
+ /*0xa799*/ 1035,
+ -1,
+ /*0x10cee*/ 1195,
+ -1, -1,
+ /*0x0517*/ 426,
+ /*0xff58*/ 1070,
+ /*0x2c36*/ 807,
+ -1, -1, -1, -1,
+ /*0x217f*/ 773,
+ -1, -1,
+ /*0x1f70*/ 736,
+ /*0xa693*/ 981,
+ /*0x118ca*/ 1210,
+ /*0xa787*/ 1030,
+ -1, -1, -1,
+ /*0x214e*/ 757,
+ -1,
+ /*0x2d17*/ 932,
+ -1, -1,
+ /*0x2c4a*/ 827,
+ /*0x13be*/ 507,
+ /*0x043e*/ 305,
+ -1,
+ /*0x0566*/ 444,
+ /*0x1043e*/ 1095,
+ /*0x1f76*/ 742,
+ -1, -1,
+ /*0x013e*/ 85,
+ -1, -1,
+ /*0x118d2*/ 1218,
+ /*0x13ba*/ 503,
+ /*0x043a*/ 301,
+ /*0x01d8*/ 146,
+ -1,
+ /*0x1043a*/ 1091,
+ -1,
+ /*0x057a*/ 464,
+ /*0x1f60*/ 728,
+ /*0x013a*/ 83,
+ /*0x2c52*/ 835,
+ -1, -1,
+ /*0x03b4*/ 248,
+ -1, -1, -1,
+ /*0xa797*/ 1034,
+ -1, -1, -1,
+ /*0xa699*/ 984,
+ -1, -1, -1,
+ /*0x10cde*/ 1179,
+ -1,
+ /*0x217a*/ 768,
+ /*0x2c30*/ 801,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x056c*/ 450,
+ /*0xa687*/ 975,
+ -1, -1,
+ /*0xff56*/ 1068,
+ /*0x0289*/ 228,
+ -1,
+ /*0x1f64*/ 732,
+ -1, -1, -1,
+ /*0x051d*/ 429,
+ -1,
+ /*0x1f36*/ 716,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1f78*/ 744,
+ -1,
+ /*0x01dc*/ 148,
+ -1,
+ /*0xff54*/ 1066,
+ -1,
+ /*0x00f1*/ 42,
+ -1, -1, -1,
+ /*0x2d1d*/ 938,
+ -1,
+ /*0x0568*/ 446,
+ -1, -1, -1,
+ /*0x00f5*/ 46,
+ /*0x2c34*/ 805,
+ -1,
+ /*0xa697*/ 983,
+ /*0x01d6*/ 145,
+ -1, -1,
+ /*0x0570*/ 454,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x1f74*/ 740,
+ -1, -1,
+ /*0x00fc*/ 52,
+ -1, -1,
+ /*0x01d4*/ 144,
+ /*0x0576*/ 460,
+ /*0xa79d*/ 1037,
+ /*0x2170*/ 758,
+ -1, -1, -1, -1, -1, -1,
+ /*0xff4a*/ 1056,
+ -1, -1,
+ /*0x1f30*/ 710,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x2176*/ 764,
+ -1,
+ /*0x1f62*/ 730,
+ -1, -1,
+ /*0x01b6*/ 134,
+ -1, -1, -1, -1, -1,
+ /*0xff52*/ 1064,
+ -1, -1, -1, -1, -1, -1,
+ /*0x056a*/ 448,
+ -1, -1, -1, -1, -1,
+ /*0x1fd0*/ 752,
+ -1, -1, -1, -1, -1,
+ /*0x03be*/ 258,
+ /*0x0564*/ 442,
+ -1, -1, -1, -1,
+ /*0x118de*/ 1230,
+ -1, -1,
+ /*0x1f34*/ 714,
+ -1, -1,
+ /*0x03ba*/ 254,
+ -1,
+ /*0x0578*/ 462,
+ -1,
+ /*0x2c5e*/ 847,
+ /*0x01d2*/ 143,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x2178*/ 766,
+ /*0x01b0*/ 132,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x1e936*/ 1252,
+ -1, -1, -1,
+ /*0x0574*/ 458,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x2c3e*/ 815,
+ -1, -1, -1, -1, -1,
+ /*0x2174*/ 762,
+ -1, -1, -1, -1, -1,
+ /*0x2c3a*/ 811,
+ -1,
+ /*0x00f2*/ 43,
+ /*0x0562*/ 440,
+ -1, -1, -1, -1,
+ /*0x01b4*/ 133,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x050d*/ 421,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x1e930*/ 1246,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x2d0d*/ 922,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x00fb*/ 51,
+ -1,
+ /*0x0509*/ 419,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x00f9*/ 49,
+ -1, -1, -1, -1, -1, -1,
+ /*0x056e*/ 452,
+ -1, -1,
+ /*0x2d09*/ 918,
+ -1,
+ /*0x00fd*/ 53,
+ -1, -1, -1,
+ /*0x1e934*/ 1250,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x1fe0*/ 754,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x051f*/ 430,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x00ff*/ 55,
+ -1, -1, -1,
+ /*0xa68d*/ 978,
+ -1, -1, -1,
+ /*0x2d1f*/ 940,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xa689*/ 976,
+ -1,
+ /*0x00e6*/ 31,
+ /*0xa79f*/ 1038,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x00fa*/ 50,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x1fb0*/ 750,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x00ec*/ 37,
+ -1,
+ /*0x1e93e*/ 1260,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x1e93a*/ 1256,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x00e8*/ 33,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x00f0*/ 41,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x00f6*/ 47,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x00e0*/ 25,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x00ea*/ 35,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0x00e4*/ 29,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0x00f8*/ 48,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x00f4*/ 45,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x00e2*/ 27,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x00ee*/ 39
+ };
+
+ if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseUnfold_11_hash(code);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code1_equal(code, CaseUnfold_11_Table[s].from))
+ return &CaseUnfold_11_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const CaseUnfold_12_Type CaseUnfold_12_Table[] = {
+#define CaseUnfold_12 (*(CaseUnfold_12_Type (*)[58])(CaseUnfold_12_Table+0))
+ {{0x0061, 0x02be}, {1, {0x1e9a}}},
+ {{0x0066, 0x0066}, {1, {0xfb00}}},
+ {{0x0066, 0x0069}, {1, {0xfb01}}},
+ {{0x0066, 0x006c}, {1, {0xfb02}}},
+ {{0x0068, 0x0331}, {1, {0x1e96}}},
+ {{0x006a, 0x030c}, {1, {0x01f0}}},
+ {{0x0073, 0x0073}, {2, {0x00df, 0x1e9e}}},
+ {{0x0073, 0x0074}, {2, {0xfb05, 0xfb06}}},
+ {{0x0074, 0x0308}, {1, {0x1e97}}},
+ {{0x0077, 0x030a}, {1, {0x1e98}}},
+ {{0x0079, 0x030a}, {1, {0x1e99}}},
+ {{0x02bc, 0x006e}, {1, {0x0149}}},
+ {{0x03ac, 0x03b9}, {1, {0x1fb4}}},
+ {{0x03ae, 0x03b9}, {1, {0x1fc4}}},
+ {{0x03b1, 0x0342}, {1, {0x1fb6}}},
+ {{0x03b1, 0x03b9}, {2, {0x1fb3, 0x1fbc}}},
+ {{0x03b7, 0x0342}, {1, {0x1fc6}}},
+ {{0x03b7, 0x03b9}, {2, {0x1fc3, 0x1fcc}}},
+ {{0x03b9, 0x0342}, {1, {0x1fd6}}},
+ {{0x03c1, 0x0313}, {1, {0x1fe4}}},
+ {{0x03c5, 0x0313}, {1, {0x1f50}}},
+ {{0x03c5, 0x0342}, {1, {0x1fe6}}},
+ {{0x03c9, 0x0342}, {1, {0x1ff6}}},
+ {{0x03c9, 0x03b9}, {2, {0x1ff3, 0x1ffc}}},
+ {{0x03ce, 0x03b9}, {1, {0x1ff4}}},
+ {{0x0565, 0x0582}, {1, {0x0587}}},
+ {{0x0574, 0x0565}, {1, {0xfb14}}},
+ {{0x0574, 0x056b}, {1, {0xfb15}}},
+ {{0x0574, 0x056d}, {1, {0xfb17}}},
+ {{0x0574, 0x0576}, {1, {0xfb13}}},
+ {{0x057e, 0x0576}, {1, {0xfb16}}},
+ {{0x1f00, 0x03b9}, {2, {0x1f80, 0x1f88}}},
+ {{0x1f01, 0x03b9}, {2, {0x1f81, 0x1f89}}},
+ {{0x1f02, 0x03b9}, {2, {0x1f82, 0x1f8a}}},
+ {{0x1f03, 0x03b9}, {2, {0x1f83, 0x1f8b}}},
+ {{0x1f04, 0x03b9}, {2, {0x1f84, 0x1f8c}}},
+ {{0x1f05, 0x03b9}, {2, {0x1f85, 0x1f8d}}},
+ {{0x1f06, 0x03b9}, {2, {0x1f86, 0x1f8e}}},
+ {{0x1f07, 0x03b9}, {2, {0x1f87, 0x1f8f}}},
+ {{0x1f20, 0x03b9}, {2, {0x1f90, 0x1f98}}},
+ {{0x1f21, 0x03b9}, {2, {0x1f91, 0x1f99}}},
+ {{0x1f22, 0x03b9}, {2, {0x1f92, 0x1f9a}}},
+ {{0x1f23, 0x03b9}, {2, {0x1f93, 0x1f9b}}},
+ {{0x1f24, 0x03b9}, {2, {0x1f94, 0x1f9c}}},
+ {{0x1f25, 0x03b9}, {2, {0x1f95, 0x1f9d}}},
+ {{0x1f26, 0x03b9}, {2, {0x1f96, 0x1f9e}}},
+ {{0x1f27, 0x03b9}, {2, {0x1f97, 0x1f9f}}},
+ {{0x1f60, 0x03b9}, {2, {0x1fa0, 0x1fa8}}},
+ {{0x1f61, 0x03b9}, {2, {0x1fa1, 0x1fa9}}},
+ {{0x1f62, 0x03b9}, {2, {0x1fa2, 0x1faa}}},
+ {{0x1f63, 0x03b9}, {2, {0x1fa3, 0x1fab}}},
+ {{0x1f64, 0x03b9}, {2, {0x1fa4, 0x1fac}}},
+ {{0x1f65, 0x03b9}, {2, {0x1fa5, 0x1fad}}},
+ {{0x1f66, 0x03b9}, {2, {0x1fa6, 0x1fae}}},
+ {{0x1f67, 0x03b9}, {2, {0x1fa7, 0x1faf}}},
+ {{0x1f70, 0x03b9}, {1, {0x1fb2}}},
+ {{0x1f74, 0x03b9}, {1, {0x1fc2}}},
+ {{0x1f7c, 0x03b9}, {1, {0x1ff2}}},
+#define CaseUnfold_12_Locale (*(CaseUnfold_12_Type (*)[1])(CaseUnfold_12_Table+58))
+ {{0x0069, 0x0307}, {1, {0x0130}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3,4,5,6 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_12_hash -N onigenc_unicode_CaseUnfold_12_lookup -n */
+
+/* maximum key range = 71, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_12_hash(const OnigCodePoint *codes)
+{
+ static const unsigned char asso_values[] =
+ {
+ 3, 58, 54, 57, 56, 16, 8, 2, 43, 82,
+ 3, 1, 23, 82, 82, 82, 82, 82, 82, 4,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 52, 51, 50, 49, 48, 47, 46, 45,
+ 82, 82, 82, 82, 43, 82, 42, 82, 82, 13,
+ 82, 82, 82, 82, 82, 11, 82, 1, 82, 82,
+ 14, 82, 1, 82, 82, 31, 3, 82, 82, 30,
+ 82, 82, 82, 10, 82, 82, 82, 82, 37, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 37, 15, 36, 35,
+ 34, 17, 1, 33, 12, 4, 23, 23, 26, 21,
+ 13, 82, 27, 82, 82, 2, 5, 82, 11, 16,
+ 82, 15, 82, 82, 23, 82, 8, 82
+ };
+ return asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
+}
+
+static const CodePointList2 *
+onigenc_unicode_CaseUnfold_12_lookup(const OnigCodePoint *codes)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x61,
+ MAX_CODE_VALUE = 0x1f7c,
+ TOTAL_KEYWORDS = 59,
+ MIN_WORD_LENGTH = 6,
+ MAX_WORD_LENGTH = 6,
+ MIN_HASH_VALUE = 11,
+ MAX_HASH_VALUE = 81
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x1f66,0x03b9*/ 53,
+ /*0x1f07,0x03b9*/ 38,
+ /*0x1f00,0x03b9*/ 31,
+ /*0x0066,0x0066*/ 1,
+ /*0x1f74,0x03b9*/ 56,
+ /*0x0073,0x0073*/ 6,
+ /*0x0066,0x0069*/ 2,
+ /*0x1f06,0x03b9*/ 37,
+ /*0x0073,0x0074*/ 7,
+ /*0x03b9,0x0342*/ 18,
+ /*0x03c9,0x03b9*/ 23,
+ /*0x03b7,0x03b9*/ 17,
+ /*0x0069,0x0307*/ 58,
+ /*0x03b1,0x03b9*/ 15,
+ /*0x1f61,0x03b9*/ 48,
+ /*0x1f05,0x03b9*/ 36,
+ /*0x1f65,0x03b9*/ 52,
+ /*0x0574,0x0576*/ 29,
+ /*0x03c9,0x0342*/ 22,
+ /*0x03b7,0x0342*/ 16,
+ /*0x057e,0x0576*/ 30,
+ /*0x03b1,0x0342*/ 14,
+ /*0x1f7c,0x03b9*/ 57,
+ /*0x0574,0x0565*/ 26,
+ /*0x0079,0x030a*/ 10,
+ /*0x0077,0x030a*/ 9,
+ /*0x1f70,0x03b9*/ 55,
+ /*0x0574,0x056d*/ 28,
+ /*0x0066,0x006c*/ 3,
+ /*0x0574,0x056b*/ 27,
+ /*0x0061,0x02be*/ 0,
+ /*0x0068,0x0331*/ 4,
+ /*0x1f67,0x03b9*/ 54,
+ /*0x1f64,0x03b9*/ 51,
+ /*0x1f63,0x03b9*/ 50,
+ /*0x1f62,0x03b9*/ 49,
+ /*0x1f60,0x03b9*/ 47,
+ /*0x03ce,0x03b9*/ 24,
+ /*0x03c5,0x0342*/ 21,
+ /*0x03c5,0x0313*/ 20,
+ /*0x03c1,0x0313*/ 19,
+ /*0x02bc,0x006e*/ 11,
+ /*0x03ae,0x03b9*/ 13,
+ /*0x03ac,0x03b9*/ 12,
+ /*0x1f27,0x03b9*/ 46,
+ /*0x1f26,0x03b9*/ 45,
+ /*0x1f25,0x03b9*/ 44,
+ /*0x1f24,0x03b9*/ 43,
+ /*0x1f23,0x03b9*/ 42,
+ /*0x1f22,0x03b9*/ 41,
+ /*0x1f21,0x03b9*/ 40,
+ /*0x1f20,0x03b9*/ 39,
+ /*0x006a,0x030c*/ 5,
+ /*0x1f02,0x03b9*/ 33,
+ /*0x0074,0x0308*/ 8,
+ /*0x1f04,0x03b9*/ 35,
+ /*0x1f03,0x03b9*/ 34,
+ /*0x1f01,0x03b9*/ 32,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0x0565,0x0582*/ 25
+ };
+
+ if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
+ codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseUnfold_12_hash(codes);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code2_equal(codes, CaseUnfold_12_Table[s].from))
+ return &CaseUnfold_12_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const CaseUnfold_13_Type CaseUnfold_13_Table[] = {
+#define CaseUnfold_13 (*(CaseUnfold_13_Type (*)[14])(CaseUnfold_13_Table+0))
+ {{0x0066, 0x0066, 0x0069}, {1, {0xfb03}}},
+ {{0x0066, 0x0066, 0x006c}, {1, {0xfb04}}},
+ {{0x03b1, 0x0342, 0x03b9}, {1, {0x1fb7}}},
+ {{0x03b7, 0x0342, 0x03b9}, {1, {0x1fc7}}},
+ {{0x03b9, 0x0308, 0x0300}, {1, {0x1fd2}}},
+ {{0x03b9, 0x0308, 0x0301}, {2, {0x0390, 0x1fd3}}},
+ {{0x03b9, 0x0308, 0x0342}, {1, {0x1fd7}}},
+ {{0x03c5, 0x0308, 0x0300}, {1, {0x1fe2}}},
+ {{0x03c5, 0x0308, 0x0301}, {2, {0x03b0, 0x1fe3}}},
+ {{0x03c5, 0x0308, 0x0342}, {1, {0x1fe7}}},
+ {{0x03c5, 0x0313, 0x0300}, {1, {0x1f52}}},
+ {{0x03c5, 0x0313, 0x0301}, {1, {0x1f54}}},
+ {{0x03c5, 0x0313, 0x0342}, {1, {0x1f56}}},
+ {{0x03c9, 0x0342, 0x03b9}, {1, {0x1ff7}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3,4,5,6,7,8,9 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_13_hash -N onigenc_unicode_CaseUnfold_13_lookup -n */
+
+/* maximum key range = 20, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_13_hash(const OnigCodePoint *codes)
+{
+ static const unsigned char asso_values[] =
+ {
+ 7, 4, 47, 47, 47, 47, 1, 1, 2, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 1,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 11,
+ 47, 47, 47, 47, 47, 10, 47, 2, 47, 47,
+ 47, 47, 47, 47, 47, 47, 1, 47, 47, 1,
+ 47, 47, 47, 9, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 1, 47, 47, 2, 47, 47, 1, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47
+ };
+ return asso_values[bits_at(codes, 8)] + asso_values[bits_at(codes, 7)] + asso_values[bits_at(codes, 6)] + asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
+}
+
+static const CodePointList2 *
+onigenc_unicode_CaseUnfold_13_lookup(const OnigCodePoint *codes)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x66,
+ MAX_CODE_VALUE = 0x3c9,
+ TOTAL_KEYWORDS = 14,
+ MIN_WORD_LENGTH = 9,
+ MAX_WORD_LENGTH = 9,
+ MIN_HASH_VALUE = 27,
+ MAX_HASH_VALUE = 46
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x03c5,0x0313,0x0342*/ 12,
+ /*0x03c5,0x0308,0x0342*/ 9,
+ /*0x03b9,0x0308,0x0342*/ 6,
+ /*0x03c5,0x0313,0x0301*/ 11,
+ /*0x03c5,0x0308,0x0301*/ 8,
+ /*0x03b9,0x0308,0x0301*/ 5,
+ /*0x03c5,0x0313,0x0300*/ 10,
+ /*0x03c5,0x0308,0x0300*/ 7,
+ /*0x03b9,0x0308,0x0300*/ 4,
+ /*0x03c9,0x0342,0x03b9*/ 13,
+ /*0x03b7,0x0342,0x03b9*/ 3,
+ /*0x03b1,0x0342,0x03b9*/ 2,
+ -1, -1, -1, -1, -1, -1,
+ /*0x0066,0x0066,0x006c*/ 1,
+ /*0x0066,0x0066,0x0069*/ 0
+ };
+
+ if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
+ codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE &&
+ codes[2] <= MAX_CODE_VALUE && codes[2] >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseUnfold_13_hash(codes);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code3_equal(codes, CaseUnfold_13_Table[s].from))
+ return &CaseUnfold_13_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const OnigCodePoint CaseMappingSpecials[] = {
+ L(1)|0x039C,
+ L(2)|0x0053, 0x0073, L(2)|0x0053, 0x0053,
+ L(2)|0x02BC, 0x004E,
+ L(1)|0x0053,
+ L(1)|0x01C5,
+ L(2)|0x0064, 0x017D, L(1)|0x01C4,
+ L(1)|0x01C8,
+ L(2)|0x006C, 0x004A, L(1)|0x01C7,
+ L(1)|0x01CB,
+ L(2)|0x006E, 0x004A, L(1)|0x01CA,
+ L(2)|0x004A, 0x030C,
+ L(1)|0x01F2,
+ L(2)|0x0064, 0x005A, L(1)|0x01F1,
+ L(1)|0x0399,
+ L(3)|0x0399, 0x0308, 0x0301,
+ L(3)|0x03A5, 0x0308, 0x0301,
+ L(1)|0x03A3,
+ L(1)|0x0392,
+ L(1)|0x0398,
+ L(1)|0x03A6,
+ L(1)|0x03A0,
+ L(1)|0x039A,
+ L(1)|0x03A1,
+ L(1)|0x0395,
+ L(2)|0x0535, 0x0582, L(2)|0x0535, 0x0552,
+ L(1)|0x0412,
+ L(1)|0x0414,
+ L(1)|0x041E,
+ L(1)|0x0421,
+ L(1)|0x0422,
+ L(1)|0x0422,
+ L(1)|0x042A,
+ L(1)|0x0462,
+ L(1)|0xA64A,
+ L(2)|0x0048, 0x0331,
+ L(2)|0x0054, 0x0308,
+ L(2)|0x0057, 0x030A,
+ L(2)|0x0059, 0x030A,
+ L(2)|0x0041, 0x02BE,
+ L(1)|0x1E60,
+ L(1)|0x00DF,
+ L(2)|0x03A5, 0x0313,
+ L(3)|0x03A5, 0x0313, 0x0300,
+ L(3)|0x03A5, 0x0313, 0x0301,
+ L(3)|0x03A5, 0x0313, 0x0342,
+ L(1)|0x1F88, L(2)|0x1F08, 0x0399,
+ L(1)|0x1F89, L(2)|0x1F09, 0x0399,
+ L(1)|0x1F8A, L(2)|0x1F0A, 0x0399,
+ L(1)|0x1F8B, L(2)|0x1F0B, 0x0399,
+ L(1)|0x1F8C, L(2)|0x1F0C, 0x0399,
+ L(1)|0x1F8D, L(2)|0x1F0D, 0x0399,
+ L(1)|0x1F8E, L(2)|0x1F0E, 0x0399,
+ L(1)|0x1F8F, L(2)|0x1F0F, 0x0399,
+ L(2)|0x1F00, 0x0399, L(1)|0x1F80, L(2)|0x1F08, 0x0399,
+ L(2)|0x1F01, 0x0399, L(1)|0x1F81, L(2)|0x1F09, 0x0399,
+ L(2)|0x1F02, 0x0399, L(1)|0x1F82, L(2)|0x1F0A, 0x0399,
+ L(2)|0x1F03, 0x0399, L(1)|0x1F83, L(2)|0x1F0B, 0x0399,
+ L(2)|0x1F04, 0x0399, L(1)|0x1F84, L(2)|0x1F0C, 0x0399,
+ L(2)|0x1F05, 0x0399, L(1)|0x1F85, L(2)|0x1F0D, 0x0399,
+ L(2)|0x1F06, 0x0399, L(1)|0x1F86, L(2)|0x1F0E, 0x0399,
+ L(2)|0x1F07, 0x0399, L(1)|0x1F87, L(2)|0x1F0F, 0x0399,
+ L(1)|0x1F98, L(2)|0x1F28, 0x0399,
+ L(1)|0x1F99, L(2)|0x1F29, 0x0399,
+ L(1)|0x1F9A, L(2)|0x1F2A, 0x0399,
+ L(1)|0x1F9B, L(2)|0x1F2B, 0x0399,
+ L(1)|0x1F9C, L(2)|0x1F2C, 0x0399,
+ L(1)|0x1F9D, L(2)|0x1F2D, 0x0399,
+ L(1)|0x1F9E, L(2)|0x1F2E, 0x0399,
+ L(1)|0x1F9F, L(2)|0x1F2F, 0x0399,
+ L(2)|0x1F20, 0x0399, L(1)|0x1F90, L(2)|0x1F28, 0x0399,
+ L(2)|0x1F21, 0x0399, L(1)|0x1F91, L(2)|0x1F29, 0x0399,
+ L(2)|0x1F22, 0x0399, L(1)|0x1F92, L(2)|0x1F2A, 0x0399,
+ L(2)|0x1F23, 0x0399, L(1)|0x1F93, L(2)|0x1F2B, 0x0399,
+ L(2)|0x1F24, 0x0399, L(1)|0x1F94, L(2)|0x1F2C, 0x0399,
+ L(2)|0x1F25, 0x0399, L(1)|0x1F95, L(2)|0x1F2D, 0x0399,
+ L(2)|0x1F26, 0x0399, L(1)|0x1F96, L(2)|0x1F2E, 0x0399,
+ L(2)|0x1F27, 0x0399, L(1)|0x1F97, L(2)|0x1F2F, 0x0399,
+ L(1)|0x1FA8, L(2)|0x1F68, 0x0399,
+ L(1)|0x1FA9, L(2)|0x1F69, 0x0399,
+ L(1)|0x1FAA, L(2)|0x1F6A, 0x0399,
+ L(1)|0x1FAB, L(2)|0x1F6B, 0x0399,
+ L(1)|0x1FAC, L(2)|0x1F6C, 0x0399,
+ L(1)|0x1FAD, L(2)|0x1F6D, 0x0399,
+ L(1)|0x1FAE, L(2)|0x1F6E, 0x0399,
+ L(1)|0x1FAF, L(2)|0x1F6F, 0x0399,
+ L(2)|0x1F60, 0x0399, L(1)|0x1FA0, L(2)|0x1F68, 0x0399,
+ L(2)|0x1F61, 0x0399, L(1)|0x1FA1, L(2)|0x1F69, 0x0399,
+ L(2)|0x1F62, 0x0399, L(1)|0x1FA2, L(2)|0x1F6A, 0x0399,
+ L(2)|0x1F63, 0x0399, L(1)|0x1FA3, L(2)|0x1F6B, 0x0399,
+ L(2)|0x1F64, 0x0399, L(1)|0x1FA4, L(2)|0x1F6C, 0x0399,
+ L(2)|0x1F65, 0x0399, L(1)|0x1FA5, L(2)|0x1F6D, 0x0399,
+ L(2)|0x1F66, 0x0399, L(1)|0x1FA6, L(2)|0x1F6E, 0x0399,
+ L(2)|0x1F67, 0x0399, L(1)|0x1FA7, L(2)|0x1F6F, 0x0399,
+ L(2)|0x1FBA, 0x0345, L(2)|0x1FBA, 0x0399,
+ L(1)|0x1FBC, L(2)|0x0391, 0x0399,
+ L(2)|0x0386, 0x0345, L(2)|0x0386, 0x0399,
+ L(2)|0x0391, 0x0342,
+ L(3)|0x0391, 0x0342, 0x0345, L(3)|0x0391, 0x0342, 0x0399,
+ L(2)|0x03B1, 0x0399, L(1)|0x1FB3, L(2)|0x0391, 0x0399,
+ L(1)|0x0399,
+ L(2)|0x1FCA, 0x0345, L(2)|0x1FCA, 0x0399,
+ L(1)|0x1FCC, L(2)|0x0397, 0x0399,
+ L(2)|0x0389, 0x0345, L(2)|0x0389, 0x0399,
+ L(2)|0x0397, 0x0342,
+ L(3)|0x0397, 0x0342, 0x0345, L(3)|0x0397, 0x0342, 0x0399,
+ L(2)|0x03B7, 0x0399, L(1)|0x1FC3, L(2)|0x0397, 0x0399,
+ L(3)|0x0399, 0x0308, 0x0300,
+ L(3)|0x0399, 0x0308, 0x0301,
+ L(2)|0x0399, 0x0342,
+ L(3)|0x0399, 0x0308, 0x0342,
+ L(3)|0x03A5, 0x0308, 0x0300,
+ L(3)|0x03A5, 0x0308, 0x0301,
+ L(2)|0x03A1, 0x0313,
+ L(2)|0x03A5, 0x0342,
+ L(3)|0x03A5, 0x0308, 0x0342,
+ L(2)|0x1FFA, 0x0345, L(2)|0x1FFA, 0x0399,
+ L(1)|0x1FFC, L(2)|0x03A9, 0x0399,
+ L(2)|0x038F, 0x0345, L(2)|0x038F, 0x0399,
+ L(2)|0x03A9, 0x0342,
+ L(3)|0x03A9, 0x0342, 0x0345, L(3)|0x03A9, 0x0342, 0x0399,
+ L(2)|0x03C9, 0x0399, L(1)|0x1FF3, L(2)|0x03A9, 0x0399,
+ L(2)|0x0046, 0x0066, L(2)|0x0046, 0x0046,
+ L(2)|0x0046, 0x0069, L(2)|0x0046, 0x0049,
+ L(2)|0x0046, 0x006C, L(2)|0x0046, 0x004C,
+ L(3)|0x0046, 0x0066, 0x0069, L(3)|0x0046, 0x0046, 0x0049,
+ L(3)|0x0046, 0x0066, 0x006C, L(3)|0x0046, 0x0046, 0x004C,
+ L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
+ L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
+ L(2)|0x0544, 0x0576, L(2)|0x0544, 0x0546,
+ L(2)|0x0544, 0x0565, L(2)|0x0544, 0x0535,
+ L(2)|0x0544, 0x056B, L(2)|0x0544, 0x053B,
+ L(2)|0x054E, 0x0576, L(2)|0x054E, 0x0546,
+ L(2)|0x0544, 0x056D, L(2)|0x0544, 0x053D,
+};
diff --git a/enc/unicode/10.0.0/name2ctype.h b/enc/unicode/10.0.0/name2ctype.h
new file mode 100644
index 0000000000..4a1422d17a
--- /dev/null
+++ b/enc/unicode/10.0.0/name2ctype.h
@@ -0,0 +1,38381 @@
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -c -j1 -i1 -t -C -P -T -H uniname2ctype_hash -Q uniname2ctype_pool -N uniname2ctype_p */
+#ifndef USE_UNICODE_PROPERTIES
+/* Computed positions: -k'1,3' */
+#else /* USE_UNICODE_PROPERTIES */
+/* Computed positions: -k'1-3,5-6,12,16,$' */
+#endif /* USE_UNICODE_PROPERTIES */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646. */
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
+#endif
+
+
+
+/* 'NEWLINE': [[:NEWLINE:]] */
+static const OnigCodePoint CR_NEWLINE[] = {
+ 1,
+ 0x000a, 0x000a,
+}; /* CR_NEWLINE */
+
+/* 'Alpha': [[:Alpha:]] */
+static const OnigCodePoint CR_Alpha[] = {
+ 660,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0345, 0x0345,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x05b0, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0657,
+ 0x0659, 0x065f,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06e1, 0x06e8,
+ 0x06ed, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x073f,
+ 0x074d, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0817,
+ 0x081a, 0x082c,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x08df,
+ 0x08e3, 0x08e9,
+ 0x08f0, 0x093b,
+ 0x093d, 0x094c,
+ 0x094e, 0x0950,
+ 0x0955, 0x0963,
+ 0x0971, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09ce, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4c,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a70, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0af9, 0x0afc,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b71, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4c,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccc,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d7a, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e46,
+ 0x0e4d, 0x0e4d,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ecd, 0x0ecd,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f81,
+ 0x0f88, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x1000, 0x1036,
+ 0x1038, 0x1038,
+ 0x103b, 0x103f,
+ 0x1050, 0x1062,
+ 0x1065, 0x1068,
+ 0x106e, 0x1086,
+ 0x108e, 0x108e,
+ 0x109c, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135f, 0x135f,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1713,
+ 0x1720, 0x1733,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17b3,
+ 0x17b6, 0x17c8,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x1938,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a61, 0x1a74,
+ 0x1aa7, 0x1aa7,
+ 0x1b00, 0x1b33,
+ 0x1b35, 0x1b43,
+ 0x1b45, 0x1b4b,
+ 0x1b80, 0x1ba9,
+ 0x1bac, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1be7, 0x1bf1,
+ 0x1c00, 0x1c35,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1d00, 0x1dbf,
+ 0x1de7, 0x1df4,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa674, 0xa67b,
+ 0xa67f, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa827,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c3,
+ 0xa8c5, 0xa8c5,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa90a, 0xa92a,
+ 0xa930, 0xa952,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9b2,
+ 0xa9b4, 0xa9bf,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaabe,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf5,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabea,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0xff66, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11000, 0x11045,
+ 0x11082, 0x110b8,
+ 0x110d0, 0x110e8,
+ 0x11100, 0x11132,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11180, 0x111bf,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112e8,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11400, 0x11441,
+ 0x11443, 0x11445,
+ 0x11447, 0x1144a,
+ 0x11480, 0x114c1,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115be,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x1163e,
+ 0x11640, 0x11640,
+ 0x11644, 0x11644,
+ 0x11680, 0x116b5,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172a,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a32,
+ 0x11a35, 0x11a3e,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a97,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c3e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d41,
+ 0x11d43, 0x11d43,
+ 0x11d46, 0x11d47,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9e, 0x1bc9e,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1e947, 0x1e947,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_Alpha */
+
+/* 'Blank': [[:Blank:]] */
+static const OnigCodePoint CR_Blank[] = {
+ 8,
+ 0x0009, 0x0009,
+ 0x0020, 0x0020,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 0x2000, 0x200a,
+ 0x202f, 0x202f,
+ 0x205f, 0x205f,
+ 0x3000, 0x3000,
+}; /* CR_Blank */
+
+/* 'Cntrl': [[:Cntrl:]] */
+static const OnigCodePoint CR_Cntrl[] = {
+ 2,
+ 0x0000, 0x001f,
+ 0x007f, 0x009f,
+}; /* CR_Cntrl */
+
+/* 'Digit': [[:Digit:]] */
+static const OnigCodePoint CR_Digit[] = {
+ 55,
+ 0x0030, 0x0039,
+ 0x0660, 0x0669,
+ 0x06f0, 0x06f9,
+ 0x07c0, 0x07c9,
+ 0x0966, 0x096f,
+ 0x09e6, 0x09ef,
+ 0x0a66, 0x0a6f,
+ 0x0ae6, 0x0aef,
+ 0x0b66, 0x0b6f,
+ 0x0be6, 0x0bef,
+ 0x0c66, 0x0c6f,
+ 0x0ce6, 0x0cef,
+ 0x0d66, 0x0d6f,
+ 0x0de6, 0x0def,
+ 0x0e50, 0x0e59,
+ 0x0ed0, 0x0ed9,
+ 0x0f20, 0x0f29,
+ 0x1040, 0x1049,
+ 0x1090, 0x1099,
+ 0x17e0, 0x17e9,
+ 0x1810, 0x1819,
+ 0x1946, 0x194f,
+ 0x19d0, 0x19d9,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1b50, 0x1b59,
+ 0x1bb0, 0x1bb9,
+ 0x1c40, 0x1c49,
+ 0x1c50, 0x1c59,
+ 0xa620, 0xa629,
+ 0xa8d0, 0xa8d9,
+ 0xa900, 0xa909,
+ 0xa9d0, 0xa9d9,
+ 0xa9f0, 0xa9f9,
+ 0xaa50, 0xaa59,
+ 0xabf0, 0xabf9,
+ 0xff10, 0xff19,
+ 0x104a0, 0x104a9,
+ 0x11066, 0x1106f,
+ 0x110f0, 0x110f9,
+ 0x11136, 0x1113f,
+ 0x111d0, 0x111d9,
+ 0x112f0, 0x112f9,
+ 0x11450, 0x11459,
+ 0x114d0, 0x114d9,
+ 0x11650, 0x11659,
+ 0x116c0, 0x116c9,
+ 0x11730, 0x11739,
+ 0x118e0, 0x118e9,
+ 0x11c50, 0x11c59,
+ 0x11d50, 0x11d59,
+ 0x16a60, 0x16a69,
+ 0x16b50, 0x16b59,
+ 0x1d7ce, 0x1d7ff,
+ 0x1e950, 0x1e959,
+}; /* CR_Digit */
+
+/* 'Graph': [[:Graph:]] */
+static const OnigCodePoint CR_Graph[] = {
+ 654,
+ 0x0021, 0x007e,
+ 0x00a1, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fd,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x167f,
+ 0x1681, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x200b, 0x2027,
+ 0x202a, 0x202e,
+ 0x2030, 0x205e,
+ 0x2060, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e49,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3001, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xe000, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xfffd,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xf0000, 0xffffd,
+ 0x100000, 0x10fffd,
+}; /* CR_Graph */
+
+/* 'Lower': [[:Lower:]] */
+static const OnigCodePoint CR_Lower[] = {
+ 640,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00df, 0x00f6,
+ 0x00f8, 0x00ff,
+ 0x0101, 0x0101,
+ 0x0103, 0x0103,
+ 0x0105, 0x0105,
+ 0x0107, 0x0107,
+ 0x0109, 0x0109,
+ 0x010b, 0x010b,
+ 0x010d, 0x010d,
+ 0x010f, 0x010f,
+ 0x0111, 0x0111,
+ 0x0113, 0x0113,
+ 0x0115, 0x0115,
+ 0x0117, 0x0117,
+ 0x0119, 0x0119,
+ 0x011b, 0x011b,
+ 0x011d, 0x011d,
+ 0x011f, 0x011f,
+ 0x0121, 0x0121,
+ 0x0123, 0x0123,
+ 0x0125, 0x0125,
+ 0x0127, 0x0127,
+ 0x0129, 0x0129,
+ 0x012b, 0x012b,
+ 0x012d, 0x012d,
+ 0x012f, 0x012f,
+ 0x0131, 0x0131,
+ 0x0133, 0x0133,
+ 0x0135, 0x0135,
+ 0x0137, 0x0138,
+ 0x013a, 0x013a,
+ 0x013c, 0x013c,
+ 0x013e, 0x013e,
+ 0x0140, 0x0140,
+ 0x0142, 0x0142,
+ 0x0144, 0x0144,
+ 0x0146, 0x0146,
+ 0x0148, 0x0149,
+ 0x014b, 0x014b,
+ 0x014d, 0x014d,
+ 0x014f, 0x014f,
+ 0x0151, 0x0151,
+ 0x0153, 0x0153,
+ 0x0155, 0x0155,
+ 0x0157, 0x0157,
+ 0x0159, 0x0159,
+ 0x015b, 0x015b,
+ 0x015d, 0x015d,
+ 0x015f, 0x015f,
+ 0x0161, 0x0161,
+ 0x0163, 0x0163,
+ 0x0165, 0x0165,
+ 0x0167, 0x0167,
+ 0x0169, 0x0169,
+ 0x016b, 0x016b,
+ 0x016d, 0x016d,
+ 0x016f, 0x016f,
+ 0x0171, 0x0171,
+ 0x0173, 0x0173,
+ 0x0175, 0x0175,
+ 0x0177, 0x0177,
+ 0x017a, 0x017a,
+ 0x017c, 0x017c,
+ 0x017e, 0x0180,
+ 0x0183, 0x0183,
+ 0x0185, 0x0185,
+ 0x0188, 0x0188,
+ 0x018c, 0x018d,
+ 0x0192, 0x0192,
+ 0x0195, 0x0195,
+ 0x0199, 0x019b,
+ 0x019e, 0x019e,
+ 0x01a1, 0x01a1,
+ 0x01a3, 0x01a3,
+ 0x01a5, 0x01a5,
+ 0x01a8, 0x01a8,
+ 0x01aa, 0x01ab,
+ 0x01ad, 0x01ad,
+ 0x01b0, 0x01b0,
+ 0x01b4, 0x01b4,
+ 0x01b6, 0x01b6,
+ 0x01b9, 0x01ba,
+ 0x01bd, 0x01bf,
+ 0x01c6, 0x01c6,
+ 0x01c9, 0x01c9,
+ 0x01cc, 0x01cc,
+ 0x01ce, 0x01ce,
+ 0x01d0, 0x01d0,
+ 0x01d2, 0x01d2,
+ 0x01d4, 0x01d4,
+ 0x01d6, 0x01d6,
+ 0x01d8, 0x01d8,
+ 0x01da, 0x01da,
+ 0x01dc, 0x01dd,
+ 0x01df, 0x01df,
+ 0x01e1, 0x01e1,
+ 0x01e3, 0x01e3,
+ 0x01e5, 0x01e5,
+ 0x01e7, 0x01e7,
+ 0x01e9, 0x01e9,
+ 0x01eb, 0x01eb,
+ 0x01ed, 0x01ed,
+ 0x01ef, 0x01f0,
+ 0x01f3, 0x01f3,
+ 0x01f5, 0x01f5,
+ 0x01f9, 0x01f9,
+ 0x01fb, 0x01fb,
+ 0x01fd, 0x01fd,
+ 0x01ff, 0x01ff,
+ 0x0201, 0x0201,
+ 0x0203, 0x0203,
+ 0x0205, 0x0205,
+ 0x0207, 0x0207,
+ 0x0209, 0x0209,
+ 0x020b, 0x020b,
+ 0x020d, 0x020d,
+ 0x020f, 0x020f,
+ 0x0211, 0x0211,
+ 0x0213, 0x0213,
+ 0x0215, 0x0215,
+ 0x0217, 0x0217,
+ 0x0219, 0x0219,
+ 0x021b, 0x021b,
+ 0x021d, 0x021d,
+ 0x021f, 0x021f,
+ 0x0221, 0x0221,
+ 0x0223, 0x0223,
+ 0x0225, 0x0225,
+ 0x0227, 0x0227,
+ 0x0229, 0x0229,
+ 0x022b, 0x022b,
+ 0x022d, 0x022d,
+ 0x022f, 0x022f,
+ 0x0231, 0x0231,
+ 0x0233, 0x0239,
+ 0x023c, 0x023c,
+ 0x023f, 0x0240,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0293,
+ 0x0295, 0x02b8,
+ 0x02c0, 0x02c1,
+ 0x02e0, 0x02e4,
+ 0x0345, 0x0345,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037a, 0x037d,
+ 0x0390, 0x0390,
+ 0x03ac, 0x03ce,
+ 0x03d0, 0x03d1,
+ 0x03d5, 0x03d7,
+ 0x03d9, 0x03d9,
+ 0x03db, 0x03db,
+ 0x03dd, 0x03dd,
+ 0x03df, 0x03df,
+ 0x03e1, 0x03e1,
+ 0x03e3, 0x03e3,
+ 0x03e5, 0x03e5,
+ 0x03e7, 0x03e7,
+ 0x03e9, 0x03e9,
+ 0x03eb, 0x03eb,
+ 0x03ed, 0x03ed,
+ 0x03ef, 0x03f3,
+ 0x03f5, 0x03f5,
+ 0x03f8, 0x03f8,
+ 0x03fb, 0x03fc,
+ 0x0430, 0x045f,
+ 0x0461, 0x0461,
+ 0x0463, 0x0463,
+ 0x0465, 0x0465,
+ 0x0467, 0x0467,
+ 0x0469, 0x0469,
+ 0x046b, 0x046b,
+ 0x046d, 0x046d,
+ 0x046f, 0x046f,
+ 0x0471, 0x0471,
+ 0x0473, 0x0473,
+ 0x0475, 0x0475,
+ 0x0477, 0x0477,
+ 0x0479, 0x0479,
+ 0x047b, 0x047b,
+ 0x047d, 0x047d,
+ 0x047f, 0x047f,
+ 0x0481, 0x0481,
+ 0x048b, 0x048b,
+ 0x048d, 0x048d,
+ 0x048f, 0x048f,
+ 0x0491, 0x0491,
+ 0x0493, 0x0493,
+ 0x0495, 0x0495,
+ 0x0497, 0x0497,
+ 0x0499, 0x0499,
+ 0x049b, 0x049b,
+ 0x049d, 0x049d,
+ 0x049f, 0x049f,
+ 0x04a1, 0x04a1,
+ 0x04a3, 0x04a3,
+ 0x04a5, 0x04a5,
+ 0x04a7, 0x04a7,
+ 0x04a9, 0x04a9,
+ 0x04ab, 0x04ab,
+ 0x04ad, 0x04ad,
+ 0x04af, 0x04af,
+ 0x04b1, 0x04b1,
+ 0x04b3, 0x04b3,
+ 0x04b5, 0x04b5,
+ 0x04b7, 0x04b7,
+ 0x04b9, 0x04b9,
+ 0x04bb, 0x04bb,
+ 0x04bd, 0x04bd,
+ 0x04bf, 0x04bf,
+ 0x04c2, 0x04c2,
+ 0x04c4, 0x04c4,
+ 0x04c6, 0x04c6,
+ 0x04c8, 0x04c8,
+ 0x04ca, 0x04ca,
+ 0x04cc, 0x04cc,
+ 0x04ce, 0x04cf,
+ 0x04d1, 0x04d1,
+ 0x04d3, 0x04d3,
+ 0x04d5, 0x04d5,
+ 0x04d7, 0x04d7,
+ 0x04d9, 0x04d9,
+ 0x04db, 0x04db,
+ 0x04dd, 0x04dd,
+ 0x04df, 0x04df,
+ 0x04e1, 0x04e1,
+ 0x04e3, 0x04e3,
+ 0x04e5, 0x04e5,
+ 0x04e7, 0x04e7,
+ 0x04e9, 0x04e9,
+ 0x04eb, 0x04eb,
+ 0x04ed, 0x04ed,
+ 0x04ef, 0x04ef,
+ 0x04f1, 0x04f1,
+ 0x04f3, 0x04f3,
+ 0x04f5, 0x04f5,
+ 0x04f7, 0x04f7,
+ 0x04f9, 0x04f9,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0561, 0x0587,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1d00, 0x1dbf,
+ 0x1e01, 0x1e01,
+ 0x1e03, 0x1e03,
+ 0x1e05, 0x1e05,
+ 0x1e07, 0x1e07,
+ 0x1e09, 0x1e09,
+ 0x1e0b, 0x1e0b,
+ 0x1e0d, 0x1e0d,
+ 0x1e0f, 0x1e0f,
+ 0x1e11, 0x1e11,
+ 0x1e13, 0x1e13,
+ 0x1e15, 0x1e15,
+ 0x1e17, 0x1e17,
+ 0x1e19, 0x1e19,
+ 0x1e1b, 0x1e1b,
+ 0x1e1d, 0x1e1d,
+ 0x1e1f, 0x1e1f,
+ 0x1e21, 0x1e21,
+ 0x1e23, 0x1e23,
+ 0x1e25, 0x1e25,
+ 0x1e27, 0x1e27,
+ 0x1e29, 0x1e29,
+ 0x1e2b, 0x1e2b,
+ 0x1e2d, 0x1e2d,
+ 0x1e2f, 0x1e2f,
+ 0x1e31, 0x1e31,
+ 0x1e33, 0x1e33,
+ 0x1e35, 0x1e35,
+ 0x1e37, 0x1e37,
+ 0x1e39, 0x1e39,
+ 0x1e3b, 0x1e3b,
+ 0x1e3d, 0x1e3d,
+ 0x1e3f, 0x1e3f,
+ 0x1e41, 0x1e41,
+ 0x1e43, 0x1e43,
+ 0x1e45, 0x1e45,
+ 0x1e47, 0x1e47,
+ 0x1e49, 0x1e49,
+ 0x1e4b, 0x1e4b,
+ 0x1e4d, 0x1e4d,
+ 0x1e4f, 0x1e4f,
+ 0x1e51, 0x1e51,
+ 0x1e53, 0x1e53,
+ 0x1e55, 0x1e55,
+ 0x1e57, 0x1e57,
+ 0x1e59, 0x1e59,
+ 0x1e5b, 0x1e5b,
+ 0x1e5d, 0x1e5d,
+ 0x1e5f, 0x1e5f,
+ 0x1e61, 0x1e61,
+ 0x1e63, 0x1e63,
+ 0x1e65, 0x1e65,
+ 0x1e67, 0x1e67,
+ 0x1e69, 0x1e69,
+ 0x1e6b, 0x1e6b,
+ 0x1e6d, 0x1e6d,
+ 0x1e6f, 0x1e6f,
+ 0x1e71, 0x1e71,
+ 0x1e73, 0x1e73,
+ 0x1e75, 0x1e75,
+ 0x1e77, 0x1e77,
+ 0x1e79, 0x1e79,
+ 0x1e7b, 0x1e7b,
+ 0x1e7d, 0x1e7d,
+ 0x1e7f, 0x1e7f,
+ 0x1e81, 0x1e81,
+ 0x1e83, 0x1e83,
+ 0x1e85, 0x1e85,
+ 0x1e87, 0x1e87,
+ 0x1e89, 0x1e89,
+ 0x1e8b, 0x1e8b,
+ 0x1e8d, 0x1e8d,
+ 0x1e8f, 0x1e8f,
+ 0x1e91, 0x1e91,
+ 0x1e93, 0x1e93,
+ 0x1e95, 0x1e9d,
+ 0x1e9f, 0x1e9f,
+ 0x1ea1, 0x1ea1,
+ 0x1ea3, 0x1ea3,
+ 0x1ea5, 0x1ea5,
+ 0x1ea7, 0x1ea7,
+ 0x1ea9, 0x1ea9,
+ 0x1eab, 0x1eab,
+ 0x1ead, 0x1ead,
+ 0x1eaf, 0x1eaf,
+ 0x1eb1, 0x1eb1,
+ 0x1eb3, 0x1eb3,
+ 0x1eb5, 0x1eb5,
+ 0x1eb7, 0x1eb7,
+ 0x1eb9, 0x1eb9,
+ 0x1ebb, 0x1ebb,
+ 0x1ebd, 0x1ebd,
+ 0x1ebf, 0x1ebf,
+ 0x1ec1, 0x1ec1,
+ 0x1ec3, 0x1ec3,
+ 0x1ec5, 0x1ec5,
+ 0x1ec7, 0x1ec7,
+ 0x1ec9, 0x1ec9,
+ 0x1ecb, 0x1ecb,
+ 0x1ecd, 0x1ecd,
+ 0x1ecf, 0x1ecf,
+ 0x1ed1, 0x1ed1,
+ 0x1ed3, 0x1ed3,
+ 0x1ed5, 0x1ed5,
+ 0x1ed7, 0x1ed7,
+ 0x1ed9, 0x1ed9,
+ 0x1edb, 0x1edb,
+ 0x1edd, 0x1edd,
+ 0x1edf, 0x1edf,
+ 0x1ee1, 0x1ee1,
+ 0x1ee3, 0x1ee3,
+ 0x1ee5, 0x1ee5,
+ 0x1ee7, 0x1ee7,
+ 0x1ee9, 0x1ee9,
+ 0x1eeb, 0x1eeb,
+ 0x1eed, 0x1eed,
+ 0x1eef, 0x1eef,
+ 0x1ef1, 0x1ef1,
+ 0x1ef3, 0x1ef3,
+ 0x1ef5, 0x1ef5,
+ 0x1ef7, 0x1ef7,
+ 0x1ef9, 0x1ef9,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 0x1f07,
+ 0x1f10, 0x1f15,
+ 0x1f20, 0x1f27,
+ 0x1f30, 0x1f37,
+ 0x1f40, 0x1f45,
+ 0x1f50, 0x1f57,
+ 0x1f60, 0x1f67,
+ 0x1f70, 0x1f7d,
+ 0x1f80, 0x1f87,
+ 0x1f90, 0x1f97,
+ 0x1fa0, 0x1fa7,
+ 0x1fb0, 0x1fb4,
+ 0x1fb6, 0x1fb7,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fc7,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fd7,
+ 0x1fe0, 0x1fe7,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ff7,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x210a, 0x210a,
+ 0x210e, 0x210f,
+ 0x2113, 0x2113,
+ 0x212f, 0x212f,
+ 0x2134, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213d,
+ 0x2146, 0x2149,
+ 0x214e, 0x214e,
+ 0x2170, 0x217f,
+ 0x2184, 0x2184,
+ 0x24d0, 0x24e9,
+ 0x2c30, 0x2c5e,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c71, 0x2c71,
+ 0x2c73, 0x2c74,
+ 0x2c76, 0x2c7d,
+ 0x2c81, 0x2c81,
+ 0x2c83, 0x2c83,
+ 0x2c85, 0x2c85,
+ 0x2c87, 0x2c87,
+ 0x2c89, 0x2c89,
+ 0x2c8b, 0x2c8b,
+ 0x2c8d, 0x2c8d,
+ 0x2c8f, 0x2c8f,
+ 0x2c91, 0x2c91,
+ 0x2c93, 0x2c93,
+ 0x2c95, 0x2c95,
+ 0x2c97, 0x2c97,
+ 0x2c99, 0x2c99,
+ 0x2c9b, 0x2c9b,
+ 0x2c9d, 0x2c9d,
+ 0x2c9f, 0x2c9f,
+ 0x2ca1, 0x2ca1,
+ 0x2ca3, 0x2ca3,
+ 0x2ca5, 0x2ca5,
+ 0x2ca7, 0x2ca7,
+ 0x2ca9, 0x2ca9,
+ 0x2cab, 0x2cab,
+ 0x2cad, 0x2cad,
+ 0x2caf, 0x2caf,
+ 0x2cb1, 0x2cb1,
+ 0x2cb3, 0x2cb3,
+ 0x2cb5, 0x2cb5,
+ 0x2cb7, 0x2cb7,
+ 0x2cb9, 0x2cb9,
+ 0x2cbb, 0x2cbb,
+ 0x2cbd, 0x2cbd,
+ 0x2cbf, 0x2cbf,
+ 0x2cc1, 0x2cc1,
+ 0x2cc3, 0x2cc3,
+ 0x2cc5, 0x2cc5,
+ 0x2cc7, 0x2cc7,
+ 0x2cc9, 0x2cc9,
+ 0x2ccb, 0x2ccb,
+ 0x2ccd, 0x2ccd,
+ 0x2ccf, 0x2ccf,
+ 0x2cd1, 0x2cd1,
+ 0x2cd3, 0x2cd3,
+ 0x2cd5, 0x2cd5,
+ 0x2cd7, 0x2cd7,
+ 0x2cd9, 0x2cd9,
+ 0x2cdb, 0x2cdb,
+ 0x2cdd, 0x2cdd,
+ 0x2cdf, 0x2cdf,
+ 0x2ce1, 0x2ce1,
+ 0x2ce3, 0x2ce4,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69d,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa731,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa778,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa78e, 0xa78e,
+ 0xa791, 0xa791,
+ 0xa793, 0xa795,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xa7f8, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10cc0, 0x10cf2,
+ 0x118c0, 0x118df,
+ 0x1d41a, 0x1d433,
+ 0x1d44e, 0x1d454,
+ 0x1d456, 0x1d467,
+ 0x1d482, 0x1d49b,
+ 0x1d4b6, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d4cf,
+ 0x1d4ea, 0x1d503,
+ 0x1d51e, 0x1d537,
+ 0x1d552, 0x1d56b,
+ 0x1d586, 0x1d59f,
+ 0x1d5ba, 0x1d5d3,
+ 0x1d5ee, 0x1d607,
+ 0x1d622, 0x1d63b,
+ 0x1d656, 0x1d66f,
+ 0x1d68a, 0x1d6a5,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6e1,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d71b,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d755,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d78f,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7c9,
+ 0x1d7cb, 0x1d7cb,
+ 0x1e922, 0x1e943,
+}; /* CR_Lower */
+
+/* 'Print': [[:Print:]] */
+static const OnigCodePoint CR_Print[] = {
+ 651,
+ 0x0020, 0x007e,
+ 0x00a0, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fd,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2027,
+ 0x202a, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e49,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xe000, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xfffd,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xf0000, 0xffffd,
+ 0x100000, 0x10fffd,
+}; /* CR_Print */
+
+/* 'XPosixPunct': [[:Punct:]] */
+static const OnigCodePoint CR_XPosixPunct[] = {
+ 167,
+ 0x0021, 0x002f,
+ 0x003a, 0x0040,
+ 0x005b, 0x0060,
+ 0x007b, 0x007e,
+ 0x00a1, 0x00a1,
+ 0x00a7, 0x00a7,
+ 0x00ab, 0x00ab,
+ 0x00b6, 0x00b7,
+ 0x00bb, 0x00bb,
+ 0x00bf, 0x00bf,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x055a, 0x055f,
+ 0x0589, 0x058a,
+ 0x05be, 0x05be,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05f3, 0x05f4,
+ 0x0609, 0x060a,
+ 0x060c, 0x060d,
+ 0x061b, 0x061b,
+ 0x061e, 0x061f,
+ 0x066a, 0x066d,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070d,
+ 0x07f7, 0x07f9,
+ 0x0830, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0970, 0x0970,
+ 0x09fd, 0x09fd,
+ 0x0af0, 0x0af0,
+ 0x0df4, 0x0df4,
+ 0x0e4f, 0x0e4f,
+ 0x0e5a, 0x0e5b,
+ 0x0f04, 0x0f12,
+ 0x0f14, 0x0f14,
+ 0x0f3a, 0x0f3d,
+ 0x0f85, 0x0f85,
+ 0x0fd0, 0x0fd4,
+ 0x0fd9, 0x0fda,
+ 0x104a, 0x104f,
+ 0x10fb, 0x10fb,
+ 0x1360, 0x1368,
+ 0x1400, 0x1400,
+ 0x166d, 0x166e,
+ 0x169b, 0x169c,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17d8, 0x17da,
+ 0x1800, 0x180a,
+ 0x1944, 0x1945,
+ 0x1a1e, 0x1a1f,
+ 0x1aa0, 0x1aa6,
+ 0x1aa8, 0x1aad,
+ 0x1b5a, 0x1b60,
+ 0x1bfc, 0x1bff,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x2010, 0x2027,
+ 0x2030, 0x2043,
+ 0x2045, 0x2051,
+ 0x2053, 0x205e,
+ 0x207d, 0x207e,
+ 0x208d, 0x208e,
+ 0x2308, 0x230b,
+ 0x2329, 0x232a,
+ 0x2768, 0x2775,
+ 0x27c5, 0x27c6,
+ 0x27e6, 0x27ef,
+ 0x2983, 0x2998,
+ 0x29d8, 0x29db,
+ 0x29fc, 0x29fd,
+ 0x2cf9, 0x2cfc,
+ 0x2cfe, 0x2cff,
+ 0x2d70, 0x2d70,
+ 0x2e00, 0x2e2e,
+ 0x2e30, 0x2e49,
+ 0x3001, 0x3003,
+ 0x3008, 0x3011,
+ 0x3014, 0x301f,
+ 0x3030, 0x3030,
+ 0x303d, 0x303d,
+ 0x30a0, 0x30a0,
+ 0x30fb, 0x30fb,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa67e,
+ 0xa6f2, 0xa6f7,
+ 0xa874, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa8f8, 0xa8fa,
+ 0xa8fc, 0xa8fc,
+ 0xa92e, 0xa92f,
+ 0xa95f, 0xa95f,
+ 0xa9c1, 0xa9cd,
+ 0xa9de, 0xa9df,
+ 0xaa5c, 0xaa5f,
+ 0xaade, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 0xfd3e, 0xfd3f,
+ 0xfe10, 0xfe19,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe61,
+ 0xfe63, 0xfe63,
+ 0xfe68, 0xfe68,
+ 0xfe6a, 0xfe6b,
+ 0xff01, 0xff03,
+ 0xff05, 0xff0a,
+ 0xff0c, 0xff0f,
+ 0xff1a, 0xff1b,
+ 0xff1f, 0xff20,
+ 0xff3b, 0xff3d,
+ 0xff3f, 0xff3f,
+ 0xff5b, 0xff5b,
+ 0xff5d, 0xff5d,
+ 0xff5f, 0xff65,
+ 0x10100, 0x10102,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x1056f, 0x1056f,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x1093f, 0x1093f,
+ 0x10a50, 0x10a58,
+ 0x10a7f, 0x10a7f,
+ 0x10af0, 0x10af6,
+ 0x10b39, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x11047, 0x1104d,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x11140, 0x11143,
+ 0x11174, 0x11175,
+ 0x111c5, 0x111c9,
+ 0x111cd, 0x111cd,
+ 0x111db, 0x111db,
+ 0x111dd, 0x111df,
+ 0x11238, 0x1123d,
+ 0x112a9, 0x112a9,
+ 0x1144b, 0x1144f,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x114c6, 0x114c6,
+ 0x115c1, 0x115d7,
+ 0x11641, 0x11643,
+ 0x11660, 0x1166c,
+ 0x1173c, 0x1173e,
+ 0x11a3f, 0x11a46,
+ 0x11a9a, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11c41, 0x11c45,
+ 0x11c70, 0x11c71,
+ 0x12470, 0x12474,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b3b,
+ 0x16b44, 0x16b44,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8b,
+ 0x1e95e, 0x1e95f,
+}; /* CR_XPosixPunct */
+
+/* 'Space': [[:Space:]] */
+static const OnigCodePoint CR_Space[] = {
+ 10,
+ 0x0009, 0x000d,
+ 0x0020, 0x0020,
+ 0x0085, 0x0085,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 0x2000, 0x200a,
+ 0x2028, 0x2029,
+ 0x202f, 0x202f,
+ 0x205f, 0x205f,
+ 0x3000, 0x3000,
+}; /* CR_Space */
+
+/* 'Upper': [[:Upper:]] */
+static const OnigCodePoint CR_Upper[] = {
+ 632,
+ 0x0041, 0x005a,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00de,
+ 0x0100, 0x0100,
+ 0x0102, 0x0102,
+ 0x0104, 0x0104,
+ 0x0106, 0x0106,
+ 0x0108, 0x0108,
+ 0x010a, 0x010a,
+ 0x010c, 0x010c,
+ 0x010e, 0x010e,
+ 0x0110, 0x0110,
+ 0x0112, 0x0112,
+ 0x0114, 0x0114,
+ 0x0116, 0x0116,
+ 0x0118, 0x0118,
+ 0x011a, 0x011a,
+ 0x011c, 0x011c,
+ 0x011e, 0x011e,
+ 0x0120, 0x0120,
+ 0x0122, 0x0122,
+ 0x0124, 0x0124,
+ 0x0126, 0x0126,
+ 0x0128, 0x0128,
+ 0x012a, 0x012a,
+ 0x012c, 0x012c,
+ 0x012e, 0x012e,
+ 0x0130, 0x0130,
+ 0x0132, 0x0132,
+ 0x0134, 0x0134,
+ 0x0136, 0x0136,
+ 0x0139, 0x0139,
+ 0x013b, 0x013b,
+ 0x013d, 0x013d,
+ 0x013f, 0x013f,
+ 0x0141, 0x0141,
+ 0x0143, 0x0143,
+ 0x0145, 0x0145,
+ 0x0147, 0x0147,
+ 0x014a, 0x014a,
+ 0x014c, 0x014c,
+ 0x014e, 0x014e,
+ 0x0150, 0x0150,
+ 0x0152, 0x0152,
+ 0x0154, 0x0154,
+ 0x0156, 0x0156,
+ 0x0158, 0x0158,
+ 0x015a, 0x015a,
+ 0x015c, 0x015c,
+ 0x015e, 0x015e,
+ 0x0160, 0x0160,
+ 0x0162, 0x0162,
+ 0x0164, 0x0164,
+ 0x0166, 0x0166,
+ 0x0168, 0x0168,
+ 0x016a, 0x016a,
+ 0x016c, 0x016c,
+ 0x016e, 0x016e,
+ 0x0170, 0x0170,
+ 0x0172, 0x0172,
+ 0x0174, 0x0174,
+ 0x0176, 0x0176,
+ 0x0178, 0x0179,
+ 0x017b, 0x017b,
+ 0x017d, 0x017d,
+ 0x0181, 0x0182,
+ 0x0184, 0x0184,
+ 0x0186, 0x0187,
+ 0x0189, 0x018b,
+ 0x018e, 0x0191,
+ 0x0193, 0x0194,
+ 0x0196, 0x0198,
+ 0x019c, 0x019d,
+ 0x019f, 0x01a0,
+ 0x01a2, 0x01a2,
+ 0x01a4, 0x01a4,
+ 0x01a6, 0x01a7,
+ 0x01a9, 0x01a9,
+ 0x01ac, 0x01ac,
+ 0x01ae, 0x01af,
+ 0x01b1, 0x01b3,
+ 0x01b5, 0x01b5,
+ 0x01b7, 0x01b8,
+ 0x01bc, 0x01bc,
+ 0x01c4, 0x01c4,
+ 0x01c7, 0x01c7,
+ 0x01ca, 0x01ca,
+ 0x01cd, 0x01cd,
+ 0x01cf, 0x01cf,
+ 0x01d1, 0x01d1,
+ 0x01d3, 0x01d3,
+ 0x01d5, 0x01d5,
+ 0x01d7, 0x01d7,
+ 0x01d9, 0x01d9,
+ 0x01db, 0x01db,
+ 0x01de, 0x01de,
+ 0x01e0, 0x01e0,
+ 0x01e2, 0x01e2,
+ 0x01e4, 0x01e4,
+ 0x01e6, 0x01e6,
+ 0x01e8, 0x01e8,
+ 0x01ea, 0x01ea,
+ 0x01ec, 0x01ec,
+ 0x01ee, 0x01ee,
+ 0x01f1, 0x01f1,
+ 0x01f4, 0x01f4,
+ 0x01f6, 0x01f8,
+ 0x01fa, 0x01fa,
+ 0x01fc, 0x01fc,
+ 0x01fe, 0x01fe,
+ 0x0200, 0x0200,
+ 0x0202, 0x0202,
+ 0x0204, 0x0204,
+ 0x0206, 0x0206,
+ 0x0208, 0x0208,
+ 0x020a, 0x020a,
+ 0x020c, 0x020c,
+ 0x020e, 0x020e,
+ 0x0210, 0x0210,
+ 0x0212, 0x0212,
+ 0x0214, 0x0214,
+ 0x0216, 0x0216,
+ 0x0218, 0x0218,
+ 0x021a, 0x021a,
+ 0x021c, 0x021c,
+ 0x021e, 0x021e,
+ 0x0220, 0x0220,
+ 0x0222, 0x0222,
+ 0x0224, 0x0224,
+ 0x0226, 0x0226,
+ 0x0228, 0x0228,
+ 0x022a, 0x022a,
+ 0x022c, 0x022c,
+ 0x022e, 0x022e,
+ 0x0230, 0x0230,
+ 0x0232, 0x0232,
+ 0x023a, 0x023b,
+ 0x023d, 0x023e,
+ 0x0241, 0x0241,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03cf, 0x03cf,
+ 0x03d2, 0x03d4,
+ 0x03d8, 0x03d8,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03e2,
+ 0x03e4, 0x03e4,
+ 0x03e6, 0x03e6,
+ 0x03e8, 0x03e8,
+ 0x03ea, 0x03ea,
+ 0x03ec, 0x03ec,
+ 0x03ee, 0x03ee,
+ 0x03f4, 0x03f4,
+ 0x03f7, 0x03f7,
+ 0x03f9, 0x03fa,
+ 0x03fd, 0x042f,
+ 0x0460, 0x0460,
+ 0x0462, 0x0462,
+ 0x0464, 0x0464,
+ 0x0466, 0x0466,
+ 0x0468, 0x0468,
+ 0x046a, 0x046a,
+ 0x046c, 0x046c,
+ 0x046e, 0x046e,
+ 0x0470, 0x0470,
+ 0x0472, 0x0472,
+ 0x0474, 0x0474,
+ 0x0476, 0x0476,
+ 0x0478, 0x0478,
+ 0x047a, 0x047a,
+ 0x047c, 0x047c,
+ 0x047e, 0x047e,
+ 0x0480, 0x0480,
+ 0x048a, 0x048a,
+ 0x048c, 0x048c,
+ 0x048e, 0x048e,
+ 0x0490, 0x0490,
+ 0x0492, 0x0492,
+ 0x0494, 0x0494,
+ 0x0496, 0x0496,
+ 0x0498, 0x0498,
+ 0x049a, 0x049a,
+ 0x049c, 0x049c,
+ 0x049e, 0x049e,
+ 0x04a0, 0x04a0,
+ 0x04a2, 0x04a2,
+ 0x04a4, 0x04a4,
+ 0x04a6, 0x04a6,
+ 0x04a8, 0x04a8,
+ 0x04aa, 0x04aa,
+ 0x04ac, 0x04ac,
+ 0x04ae, 0x04ae,
+ 0x04b0, 0x04b0,
+ 0x04b2, 0x04b2,
+ 0x04b4, 0x04b4,
+ 0x04b6, 0x04b6,
+ 0x04b8, 0x04b8,
+ 0x04ba, 0x04ba,
+ 0x04bc, 0x04bc,
+ 0x04be, 0x04be,
+ 0x04c0, 0x04c1,
+ 0x04c3, 0x04c3,
+ 0x04c5, 0x04c5,
+ 0x04c7, 0x04c7,
+ 0x04c9, 0x04c9,
+ 0x04cb, 0x04cb,
+ 0x04cd, 0x04cd,
+ 0x04d0, 0x04d0,
+ 0x04d2, 0x04d2,
+ 0x04d4, 0x04d4,
+ 0x04d6, 0x04d6,
+ 0x04d8, 0x04d8,
+ 0x04da, 0x04da,
+ 0x04dc, 0x04dc,
+ 0x04de, 0x04de,
+ 0x04e0, 0x04e0,
+ 0x04e2, 0x04e2,
+ 0x04e4, 0x04e4,
+ 0x04e6, 0x04e6,
+ 0x04e8, 0x04e8,
+ 0x04ea, 0x04ea,
+ 0x04ec, 0x04ec,
+ 0x04ee, 0x04ee,
+ 0x04f0, 0x04f0,
+ 0x04f2, 0x04f2,
+ 0x04f4, 0x04f4,
+ 0x04f6, 0x04f6,
+ 0x04f8, 0x04f8,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x1e00, 0x1e00,
+ 0x1e02, 0x1e02,
+ 0x1e04, 0x1e04,
+ 0x1e06, 0x1e06,
+ 0x1e08, 0x1e08,
+ 0x1e0a, 0x1e0a,
+ 0x1e0c, 0x1e0c,
+ 0x1e0e, 0x1e0e,
+ 0x1e10, 0x1e10,
+ 0x1e12, 0x1e12,
+ 0x1e14, 0x1e14,
+ 0x1e16, 0x1e16,
+ 0x1e18, 0x1e18,
+ 0x1e1a, 0x1e1a,
+ 0x1e1c, 0x1e1c,
+ 0x1e1e, 0x1e1e,
+ 0x1e20, 0x1e20,
+ 0x1e22, 0x1e22,
+ 0x1e24, 0x1e24,
+ 0x1e26, 0x1e26,
+ 0x1e28, 0x1e28,
+ 0x1e2a, 0x1e2a,
+ 0x1e2c, 0x1e2c,
+ 0x1e2e, 0x1e2e,
+ 0x1e30, 0x1e30,
+ 0x1e32, 0x1e32,
+ 0x1e34, 0x1e34,
+ 0x1e36, 0x1e36,
+ 0x1e38, 0x1e38,
+ 0x1e3a, 0x1e3a,
+ 0x1e3c, 0x1e3c,
+ 0x1e3e, 0x1e3e,
+ 0x1e40, 0x1e40,
+ 0x1e42, 0x1e42,
+ 0x1e44, 0x1e44,
+ 0x1e46, 0x1e46,
+ 0x1e48, 0x1e48,
+ 0x1e4a, 0x1e4a,
+ 0x1e4c, 0x1e4c,
+ 0x1e4e, 0x1e4e,
+ 0x1e50, 0x1e50,
+ 0x1e52, 0x1e52,
+ 0x1e54, 0x1e54,
+ 0x1e56, 0x1e56,
+ 0x1e58, 0x1e58,
+ 0x1e5a, 0x1e5a,
+ 0x1e5c, 0x1e5c,
+ 0x1e5e, 0x1e5e,
+ 0x1e60, 0x1e60,
+ 0x1e62, 0x1e62,
+ 0x1e64, 0x1e64,
+ 0x1e66, 0x1e66,
+ 0x1e68, 0x1e68,
+ 0x1e6a, 0x1e6a,
+ 0x1e6c, 0x1e6c,
+ 0x1e6e, 0x1e6e,
+ 0x1e70, 0x1e70,
+ 0x1e72, 0x1e72,
+ 0x1e74, 0x1e74,
+ 0x1e76, 0x1e76,
+ 0x1e78, 0x1e78,
+ 0x1e7a, 0x1e7a,
+ 0x1e7c, 0x1e7c,
+ 0x1e7e, 0x1e7e,
+ 0x1e80, 0x1e80,
+ 0x1e82, 0x1e82,
+ 0x1e84, 0x1e84,
+ 0x1e86, 0x1e86,
+ 0x1e88, 0x1e88,
+ 0x1e8a, 0x1e8a,
+ 0x1e8c, 0x1e8c,
+ 0x1e8e, 0x1e8e,
+ 0x1e90, 0x1e90,
+ 0x1e92, 0x1e92,
+ 0x1e94, 0x1e94,
+ 0x1e9e, 0x1e9e,
+ 0x1ea0, 0x1ea0,
+ 0x1ea2, 0x1ea2,
+ 0x1ea4, 0x1ea4,
+ 0x1ea6, 0x1ea6,
+ 0x1ea8, 0x1ea8,
+ 0x1eaa, 0x1eaa,
+ 0x1eac, 0x1eac,
+ 0x1eae, 0x1eae,
+ 0x1eb0, 0x1eb0,
+ 0x1eb2, 0x1eb2,
+ 0x1eb4, 0x1eb4,
+ 0x1eb6, 0x1eb6,
+ 0x1eb8, 0x1eb8,
+ 0x1eba, 0x1eba,
+ 0x1ebc, 0x1ebc,
+ 0x1ebe, 0x1ebe,
+ 0x1ec0, 0x1ec0,
+ 0x1ec2, 0x1ec2,
+ 0x1ec4, 0x1ec4,
+ 0x1ec6, 0x1ec6,
+ 0x1ec8, 0x1ec8,
+ 0x1eca, 0x1eca,
+ 0x1ecc, 0x1ecc,
+ 0x1ece, 0x1ece,
+ 0x1ed0, 0x1ed0,
+ 0x1ed2, 0x1ed2,
+ 0x1ed4, 0x1ed4,
+ 0x1ed6, 0x1ed6,
+ 0x1ed8, 0x1ed8,
+ 0x1eda, 0x1eda,
+ 0x1edc, 0x1edc,
+ 0x1ede, 0x1ede,
+ 0x1ee0, 0x1ee0,
+ 0x1ee2, 0x1ee2,
+ 0x1ee4, 0x1ee4,
+ 0x1ee6, 0x1ee6,
+ 0x1ee8, 0x1ee8,
+ 0x1eea, 0x1eea,
+ 0x1eec, 0x1eec,
+ 0x1eee, 0x1eee,
+ 0x1ef0, 0x1ef0,
+ 0x1ef2, 0x1ef2,
+ 0x1ef4, 0x1ef4,
+ 0x1ef6, 0x1ef6,
+ 0x1ef8, 0x1ef8,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 0x1f08, 0x1f0f,
+ 0x1f18, 0x1f1d,
+ 0x1f28, 0x1f2f,
+ 0x1f38, 0x1f3f,
+ 0x1f48, 0x1f4d,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f5f,
+ 0x1f68, 0x1f6f,
+ 0x1fb8, 0x1fbb,
+ 0x1fc8, 0x1fcb,
+ 0x1fd8, 0x1fdb,
+ 0x1fe8, 0x1fec,
+ 0x1ff8, 0x1ffb,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210b, 0x210d,
+ 0x2110, 0x2112,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x2130, 0x2133,
+ 0x213e, 0x213f,
+ 0x2145, 0x2145,
+ 0x2160, 0x216f,
+ 0x2183, 0x2183,
+ 0x24b6, 0x24cf,
+ 0x2c00, 0x2c2e,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 0x2c80,
+ 0x2c82, 0x2c82,
+ 0x2c84, 0x2c84,
+ 0x2c86, 0x2c86,
+ 0x2c88, 0x2c88,
+ 0x2c8a, 0x2c8a,
+ 0x2c8c, 0x2c8c,
+ 0x2c8e, 0x2c8e,
+ 0x2c90, 0x2c90,
+ 0x2c92, 0x2c92,
+ 0x2c94, 0x2c94,
+ 0x2c96, 0x2c96,
+ 0x2c98, 0x2c98,
+ 0x2c9a, 0x2c9a,
+ 0x2c9c, 0x2c9c,
+ 0x2c9e, 0x2c9e,
+ 0x2ca0, 0x2ca0,
+ 0x2ca2, 0x2ca2,
+ 0x2ca4, 0x2ca4,
+ 0x2ca6, 0x2ca6,
+ 0x2ca8, 0x2ca8,
+ 0x2caa, 0x2caa,
+ 0x2cac, 0x2cac,
+ 0x2cae, 0x2cae,
+ 0x2cb0, 0x2cb0,
+ 0x2cb2, 0x2cb2,
+ 0x2cb4, 0x2cb4,
+ 0x2cb6, 0x2cb6,
+ 0x2cb8, 0x2cb8,
+ 0x2cba, 0x2cba,
+ 0x2cbc, 0x2cbc,
+ 0x2cbe, 0x2cbe,
+ 0x2cc0, 0x2cc0,
+ 0x2cc2, 0x2cc2,
+ 0x2cc4, 0x2cc4,
+ 0x2cc6, 0x2cc6,
+ 0x2cc8, 0x2cc8,
+ 0x2cca, 0x2cca,
+ 0x2ccc, 0x2ccc,
+ 0x2cce, 0x2cce,
+ 0x2cd0, 0x2cd0,
+ 0x2cd2, 0x2cd2,
+ 0x2cd4, 0x2cd4,
+ 0x2cd6, 0x2cd6,
+ 0x2cd8, 0x2cd8,
+ 0x2cda, 0x2cda,
+ 0x2cdc, 0x2cdc,
+ 0x2cde, 0x2cde,
+ 0x2ce0, 0x2ce0,
+ 0x2ce2, 0x2ce2,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10c80, 0x10cb2,
+ 0x118a0, 0x118bf,
+ 0x1d400, 0x1d419,
+ 0x1d434, 0x1d44d,
+ 0x1d468, 0x1d481,
+ 0x1d49c, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b5,
+ 0x1d4d0, 0x1d4e9,
+ 0x1d504, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d538, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d56c, 0x1d585,
+ 0x1d5a0, 0x1d5b9,
+ 0x1d5d4, 0x1d5ed,
+ 0x1d608, 0x1d621,
+ 0x1d63c, 0x1d655,
+ 0x1d670, 0x1d689,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6e2, 0x1d6fa,
+ 0x1d71c, 0x1d734,
+ 0x1d756, 0x1d76e,
+ 0x1d790, 0x1d7a8,
+ 0x1d7ca, 0x1d7ca,
+ 0x1e900, 0x1e921,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* CR_Upper */
+
+/* 'XDigit': [[:XDigit:]] */
+static const OnigCodePoint CR_XDigit[] = {
+ 3,
+ 0x0030, 0x0039,
+ 0x0041, 0x0046,
+ 0x0061, 0x0066,
+}; /* CR_XDigit */
+
+/* 'Word': [[:Word:]] */
+static const OnigCodePoint CR_Word[] = {
+ 692,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x005f, 0x005f,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0300, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x0483, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0840, 0x085b,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x08e1,
+ 0x08e3, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b6f,
+ 0x0b71, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e4e,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f18, 0x0f19,
+ 0x0f20, 0x0f29,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x1000, 0x1049,
+ 0x1050, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x135f,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1734,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x180b, 0x180d,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b59,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1bf3,
+ 0x1c00, 0x1c37,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x203f, 0x2040,
+ 0x2054, 0x2054,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20f0,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3007,
+ 0x3021, 0x302f,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x3099, 0x309a,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa6f1,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa827,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8e0, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa900, 0xa92d,
+ 0xa930, 0xa953,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9c0,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabea,
+ 0xabec, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xfe33, 0xfe34,
+ 0xfe4d, 0xfe4f,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff10, 0xff19,
+ 0xff21, 0xff3a,
+ 0xff3f, 0xff3f,
+ 0xff41, 0xff5a,
+ 0xff66, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x101fd, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102e0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae6,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11000, 0x11046,
+ 0x11066, 0x1106f,
+ 0x1107f, 0x110ba,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x1113f,
+ 0x11150, 0x11173,
+ 0x11176, 0x11176,
+ 0x11180, 0x111c4,
+ 0x111ca, 0x111cc,
+ 0x111d0, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x1144a,
+ 0x11450, 0x11459,
+ 0x11480, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11739,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a99,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af4,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9d, 0x1bc9e,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0xe0100, 0xe01ef,
+}; /* CR_Word */
+
+/* 'Alnum': [[:Alnum:]] */
+static const OnigCodePoint CR_Alnum[] = {
+ 695,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0345, 0x0345,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x05b0, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0657,
+ 0x0659, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06e1, 0x06e8,
+ 0x06ed, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x073f,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0817,
+ 0x081a, 0x082c,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x08df,
+ 0x08e3, 0x08e9,
+ 0x08f0, 0x093b,
+ 0x093d, 0x094c,
+ 0x094e, 0x0950,
+ 0x0955, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09ce, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4c,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af9, 0x0afc,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b6f,
+ 0x0b71, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4c,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccc,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e46,
+ 0x0e4d, 0x0e4d,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ecd, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f20, 0x0f29,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f81,
+ 0x0f88, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x1000, 0x1036,
+ 0x1038, 0x1038,
+ 0x103b, 0x1049,
+ 0x1050, 0x1062,
+ 0x1065, 0x1068,
+ 0x106e, 0x1086,
+ 0x108e, 0x108e,
+ 0x1090, 0x1099,
+ 0x109c, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135f, 0x135f,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1713,
+ 0x1720, 0x1733,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17b3,
+ 0x17b6, 0x17c8,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x1938,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a61, 0x1a74,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1b00, 0x1b33,
+ 0x1b35, 0x1b43,
+ 0x1b45, 0x1b4b,
+ 0x1b50, 0x1b59,
+ 0x1b80, 0x1ba9,
+ 0x1bac, 0x1be5,
+ 0x1be7, 0x1bf1,
+ 0x1c00, 0x1c35,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1d00, 0x1dbf,
+ 0x1de7, 0x1df4,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa674, 0xa67b,
+ 0xa67f, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa827,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c3,
+ 0xa8c5, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa900, 0xa92a,
+ 0xa930, 0xa952,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9b2,
+ 0xa9b4, 0xa9bf,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaabe,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf5,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabea,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff10, 0xff19,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0xff66, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11000, 0x11045,
+ 0x11066, 0x1106f,
+ 0x11082, 0x110b8,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11132,
+ 0x11136, 0x1113f,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11180, 0x111bf,
+ 0x111c1, 0x111c4,
+ 0x111d0, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112e8,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11400, 0x11441,
+ 0x11443, 0x11445,
+ 0x11447, 0x1144a,
+ 0x11450, 0x11459,
+ 0x11480, 0x114c1,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115be,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x1163e,
+ 0x11640, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b5,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172a,
+ 0x11730, 0x11739,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a32,
+ 0x11a35, 0x11a3e,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a97,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c3e,
+ 0x11c40, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d41,
+ 0x11d43, 0x11d43,
+ 0x11d46, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9e, 0x1bc9e,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1e947, 0x1e947,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_Alnum */
+
+/* 'ASCII': [[:ASCII:]] */
+static const OnigCodePoint CR_ASCII[] = {
+ 1,
+ 0x0000, 0x007f,
+}; /* CR_ASCII */
+
+/* 'Punct' */
+static const OnigCodePoint CR_Punct[] = {
+ 172,
+ 0x0021, 0x0023,
+ 0x0025, 0x002a,
+ 0x002c, 0x002f,
+ 0x003a, 0x003b,
+ 0x003f, 0x0040,
+ 0x005b, 0x005d,
+ 0x005f, 0x005f,
+ 0x007b, 0x007b,
+ 0x007d, 0x007d,
+ 0x00a1, 0x00a1,
+ 0x00a7, 0x00a7,
+ 0x00ab, 0x00ab,
+ 0x00b6, 0x00b7,
+ 0x00bb, 0x00bb,
+ 0x00bf, 0x00bf,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x055a, 0x055f,
+ 0x0589, 0x058a,
+ 0x05be, 0x05be,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05f3, 0x05f4,
+ 0x0609, 0x060a,
+ 0x060c, 0x060d,
+ 0x061b, 0x061b,
+ 0x061e, 0x061f,
+ 0x066a, 0x066d,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070d,
+ 0x07f7, 0x07f9,
+ 0x0830, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0970, 0x0970,
+ 0x09fd, 0x09fd,
+ 0x0af0, 0x0af0,
+ 0x0df4, 0x0df4,
+ 0x0e4f, 0x0e4f,
+ 0x0e5a, 0x0e5b,
+ 0x0f04, 0x0f12,
+ 0x0f14, 0x0f14,
+ 0x0f3a, 0x0f3d,
+ 0x0f85, 0x0f85,
+ 0x0fd0, 0x0fd4,
+ 0x0fd9, 0x0fda,
+ 0x104a, 0x104f,
+ 0x10fb, 0x10fb,
+ 0x1360, 0x1368,
+ 0x1400, 0x1400,
+ 0x166d, 0x166e,
+ 0x169b, 0x169c,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17d8, 0x17da,
+ 0x1800, 0x180a,
+ 0x1944, 0x1945,
+ 0x1a1e, 0x1a1f,
+ 0x1aa0, 0x1aa6,
+ 0x1aa8, 0x1aad,
+ 0x1b5a, 0x1b60,
+ 0x1bfc, 0x1bff,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x2010, 0x2027,
+ 0x2030, 0x2043,
+ 0x2045, 0x2051,
+ 0x2053, 0x205e,
+ 0x207d, 0x207e,
+ 0x208d, 0x208e,
+ 0x2308, 0x230b,
+ 0x2329, 0x232a,
+ 0x2768, 0x2775,
+ 0x27c5, 0x27c6,
+ 0x27e6, 0x27ef,
+ 0x2983, 0x2998,
+ 0x29d8, 0x29db,
+ 0x29fc, 0x29fd,
+ 0x2cf9, 0x2cfc,
+ 0x2cfe, 0x2cff,
+ 0x2d70, 0x2d70,
+ 0x2e00, 0x2e2e,
+ 0x2e30, 0x2e49,
+ 0x3001, 0x3003,
+ 0x3008, 0x3011,
+ 0x3014, 0x301f,
+ 0x3030, 0x3030,
+ 0x303d, 0x303d,
+ 0x30a0, 0x30a0,
+ 0x30fb, 0x30fb,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa67e,
+ 0xa6f2, 0xa6f7,
+ 0xa874, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa8f8, 0xa8fa,
+ 0xa8fc, 0xa8fc,
+ 0xa92e, 0xa92f,
+ 0xa95f, 0xa95f,
+ 0xa9c1, 0xa9cd,
+ 0xa9de, 0xa9df,
+ 0xaa5c, 0xaa5f,
+ 0xaade, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 0xfd3e, 0xfd3f,
+ 0xfe10, 0xfe19,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe61,
+ 0xfe63, 0xfe63,
+ 0xfe68, 0xfe68,
+ 0xfe6a, 0xfe6b,
+ 0xff01, 0xff03,
+ 0xff05, 0xff0a,
+ 0xff0c, 0xff0f,
+ 0xff1a, 0xff1b,
+ 0xff1f, 0xff20,
+ 0xff3b, 0xff3d,
+ 0xff3f, 0xff3f,
+ 0xff5b, 0xff5b,
+ 0xff5d, 0xff5d,
+ 0xff5f, 0xff65,
+ 0x10100, 0x10102,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x1056f, 0x1056f,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x1093f, 0x1093f,
+ 0x10a50, 0x10a58,
+ 0x10a7f, 0x10a7f,
+ 0x10af0, 0x10af6,
+ 0x10b39, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x11047, 0x1104d,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x11140, 0x11143,
+ 0x11174, 0x11175,
+ 0x111c5, 0x111c9,
+ 0x111cd, 0x111cd,
+ 0x111db, 0x111db,
+ 0x111dd, 0x111df,
+ 0x11238, 0x1123d,
+ 0x112a9, 0x112a9,
+ 0x1144b, 0x1144f,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x114c6, 0x114c6,
+ 0x115c1, 0x115d7,
+ 0x11641, 0x11643,
+ 0x11660, 0x1166c,
+ 0x1173c, 0x1173e,
+ 0x11a3f, 0x11a46,
+ 0x11a9a, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11c41, 0x11c45,
+ 0x11c70, 0x11c71,
+ 0x12470, 0x12474,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b3b,
+ 0x16b44, 0x16b44,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8b,
+ 0x1e95e, 0x1e95f,
+}; /* CR_Punct */
+
+#ifdef USE_UNICODE_PROPERTIES
+/* 'Any': - */
+static const OnigCodePoint CR_Any[] = {
+ 1,
+ 0x0000, 0x10ffff,
+}; /* CR_Any */
+
+/* 'Assigned': - */
+static const OnigCodePoint CR_Assigned[] = {
+ 649,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fd,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e49,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xfffd,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xf0000, 0xffffd,
+ 0x100000, 0x10fffd,
+}; /* CR_Assigned */
+
+/* 'C': Major Category */
+static const OnigCodePoint CR_C[] = {
+ 653,
+ 0x0000, 0x001f,
+ 0x007f, 0x009f,
+ 0x00ad, 0x00ad,
+ 0x0378, 0x0379,
+ 0x0380, 0x0383,
+ 0x038b, 0x038b,
+ 0x038d, 0x038d,
+ 0x03a2, 0x03a2,
+ 0x0530, 0x0530,
+ 0x0557, 0x0558,
+ 0x0560, 0x0560,
+ 0x0588, 0x0588,
+ 0x058b, 0x058c,
+ 0x0590, 0x0590,
+ 0x05c8, 0x05cf,
+ 0x05eb, 0x05ef,
+ 0x05f5, 0x0605,
+ 0x061c, 0x061d,
+ 0x06dd, 0x06dd,
+ 0x070e, 0x070f,
+ 0x074b, 0x074c,
+ 0x07b2, 0x07bf,
+ 0x07fb, 0x07ff,
+ 0x082e, 0x082f,
+ 0x083f, 0x083f,
+ 0x085c, 0x085d,
+ 0x085f, 0x085f,
+ 0x086b, 0x089f,
+ 0x08b5, 0x08b5,
+ 0x08be, 0x08d3,
+ 0x08e2, 0x08e2,
+ 0x0984, 0x0984,
+ 0x098d, 0x098e,
+ 0x0991, 0x0992,
+ 0x09a9, 0x09a9,
+ 0x09b1, 0x09b1,
+ 0x09b3, 0x09b5,
+ 0x09ba, 0x09bb,
+ 0x09c5, 0x09c6,
+ 0x09c9, 0x09ca,
+ 0x09cf, 0x09d6,
+ 0x09d8, 0x09db,
+ 0x09de, 0x09de,
+ 0x09e4, 0x09e5,
+ 0x09fe, 0x0a00,
+ 0x0a04, 0x0a04,
+ 0x0a0b, 0x0a0e,
+ 0x0a11, 0x0a12,
+ 0x0a29, 0x0a29,
+ 0x0a31, 0x0a31,
+ 0x0a34, 0x0a34,
+ 0x0a37, 0x0a37,
+ 0x0a3a, 0x0a3b,
+ 0x0a3d, 0x0a3d,
+ 0x0a43, 0x0a46,
+ 0x0a49, 0x0a4a,
+ 0x0a4e, 0x0a50,
+ 0x0a52, 0x0a58,
+ 0x0a5d, 0x0a5d,
+ 0x0a5f, 0x0a65,
+ 0x0a76, 0x0a80,
+ 0x0a84, 0x0a84,
+ 0x0a8e, 0x0a8e,
+ 0x0a92, 0x0a92,
+ 0x0aa9, 0x0aa9,
+ 0x0ab1, 0x0ab1,
+ 0x0ab4, 0x0ab4,
+ 0x0aba, 0x0abb,
+ 0x0ac6, 0x0ac6,
+ 0x0aca, 0x0aca,
+ 0x0ace, 0x0acf,
+ 0x0ad1, 0x0adf,
+ 0x0ae4, 0x0ae5,
+ 0x0af2, 0x0af8,
+ 0x0b00, 0x0b00,
+ 0x0b04, 0x0b04,
+ 0x0b0d, 0x0b0e,
+ 0x0b11, 0x0b12,
+ 0x0b29, 0x0b29,
+ 0x0b31, 0x0b31,
+ 0x0b34, 0x0b34,
+ 0x0b3a, 0x0b3b,
+ 0x0b45, 0x0b46,
+ 0x0b49, 0x0b4a,
+ 0x0b4e, 0x0b55,
+ 0x0b58, 0x0b5b,
+ 0x0b5e, 0x0b5e,
+ 0x0b64, 0x0b65,
+ 0x0b78, 0x0b81,
+ 0x0b84, 0x0b84,
+ 0x0b8b, 0x0b8d,
+ 0x0b91, 0x0b91,
+ 0x0b96, 0x0b98,
+ 0x0b9b, 0x0b9b,
+ 0x0b9d, 0x0b9d,
+ 0x0ba0, 0x0ba2,
+ 0x0ba5, 0x0ba7,
+ 0x0bab, 0x0bad,
+ 0x0bba, 0x0bbd,
+ 0x0bc3, 0x0bc5,
+ 0x0bc9, 0x0bc9,
+ 0x0bce, 0x0bcf,
+ 0x0bd1, 0x0bd6,
+ 0x0bd8, 0x0be5,
+ 0x0bfb, 0x0bff,
+ 0x0c04, 0x0c04,
+ 0x0c0d, 0x0c0d,
+ 0x0c11, 0x0c11,
+ 0x0c29, 0x0c29,
+ 0x0c3a, 0x0c3c,
+ 0x0c45, 0x0c45,
+ 0x0c49, 0x0c49,
+ 0x0c4e, 0x0c54,
+ 0x0c57, 0x0c57,
+ 0x0c5b, 0x0c5f,
+ 0x0c64, 0x0c65,
+ 0x0c70, 0x0c77,
+ 0x0c84, 0x0c84,
+ 0x0c8d, 0x0c8d,
+ 0x0c91, 0x0c91,
+ 0x0ca9, 0x0ca9,
+ 0x0cb4, 0x0cb4,
+ 0x0cba, 0x0cbb,
+ 0x0cc5, 0x0cc5,
+ 0x0cc9, 0x0cc9,
+ 0x0cce, 0x0cd4,
+ 0x0cd7, 0x0cdd,
+ 0x0cdf, 0x0cdf,
+ 0x0ce4, 0x0ce5,
+ 0x0cf0, 0x0cf0,
+ 0x0cf3, 0x0cff,
+ 0x0d04, 0x0d04,
+ 0x0d0d, 0x0d0d,
+ 0x0d11, 0x0d11,
+ 0x0d45, 0x0d45,
+ 0x0d49, 0x0d49,
+ 0x0d50, 0x0d53,
+ 0x0d64, 0x0d65,
+ 0x0d80, 0x0d81,
+ 0x0d84, 0x0d84,
+ 0x0d97, 0x0d99,
+ 0x0db2, 0x0db2,
+ 0x0dbc, 0x0dbc,
+ 0x0dbe, 0x0dbf,
+ 0x0dc7, 0x0dc9,
+ 0x0dcb, 0x0dce,
+ 0x0dd5, 0x0dd5,
+ 0x0dd7, 0x0dd7,
+ 0x0de0, 0x0de5,
+ 0x0df0, 0x0df1,
+ 0x0df5, 0x0e00,
+ 0x0e3b, 0x0e3e,
+ 0x0e5c, 0x0e80,
+ 0x0e83, 0x0e83,
+ 0x0e85, 0x0e86,
+ 0x0e89, 0x0e89,
+ 0x0e8b, 0x0e8c,
+ 0x0e8e, 0x0e93,
+ 0x0e98, 0x0e98,
+ 0x0ea0, 0x0ea0,
+ 0x0ea4, 0x0ea4,
+ 0x0ea6, 0x0ea6,
+ 0x0ea8, 0x0ea9,
+ 0x0eac, 0x0eac,
+ 0x0eba, 0x0eba,
+ 0x0ebe, 0x0ebf,
+ 0x0ec5, 0x0ec5,
+ 0x0ec7, 0x0ec7,
+ 0x0ece, 0x0ecf,
+ 0x0eda, 0x0edb,
+ 0x0ee0, 0x0eff,
+ 0x0f48, 0x0f48,
+ 0x0f6d, 0x0f70,
+ 0x0f98, 0x0f98,
+ 0x0fbd, 0x0fbd,
+ 0x0fcd, 0x0fcd,
+ 0x0fdb, 0x0fff,
+ 0x10c6, 0x10c6,
+ 0x10c8, 0x10cc,
+ 0x10ce, 0x10cf,
+ 0x1249, 0x1249,
+ 0x124e, 0x124f,
+ 0x1257, 0x1257,
+ 0x1259, 0x1259,
+ 0x125e, 0x125f,
+ 0x1289, 0x1289,
+ 0x128e, 0x128f,
+ 0x12b1, 0x12b1,
+ 0x12b6, 0x12b7,
+ 0x12bf, 0x12bf,
+ 0x12c1, 0x12c1,
+ 0x12c6, 0x12c7,
+ 0x12d7, 0x12d7,
+ 0x1311, 0x1311,
+ 0x1316, 0x1317,
+ 0x135b, 0x135c,
+ 0x137d, 0x137f,
+ 0x139a, 0x139f,
+ 0x13f6, 0x13f7,
+ 0x13fe, 0x13ff,
+ 0x169d, 0x169f,
+ 0x16f9, 0x16ff,
+ 0x170d, 0x170d,
+ 0x1715, 0x171f,
+ 0x1737, 0x173f,
+ 0x1754, 0x175f,
+ 0x176d, 0x176d,
+ 0x1771, 0x1771,
+ 0x1774, 0x177f,
+ 0x17de, 0x17df,
+ 0x17ea, 0x17ef,
+ 0x17fa, 0x17ff,
+ 0x180e, 0x180f,
+ 0x181a, 0x181f,
+ 0x1878, 0x187f,
+ 0x18ab, 0x18af,
+ 0x18f6, 0x18ff,
+ 0x191f, 0x191f,
+ 0x192c, 0x192f,
+ 0x193c, 0x193f,
+ 0x1941, 0x1943,
+ 0x196e, 0x196f,
+ 0x1975, 0x197f,
+ 0x19ac, 0x19af,
+ 0x19ca, 0x19cf,
+ 0x19db, 0x19dd,
+ 0x1a1c, 0x1a1d,
+ 0x1a5f, 0x1a5f,
+ 0x1a7d, 0x1a7e,
+ 0x1a8a, 0x1a8f,
+ 0x1a9a, 0x1a9f,
+ 0x1aae, 0x1aaf,
+ 0x1abf, 0x1aff,
+ 0x1b4c, 0x1b4f,
+ 0x1b7d, 0x1b7f,
+ 0x1bf4, 0x1bfb,
+ 0x1c38, 0x1c3a,
+ 0x1c4a, 0x1c4c,
+ 0x1c89, 0x1cbf,
+ 0x1cc8, 0x1ccf,
+ 0x1cfa, 0x1cff,
+ 0x1dfa, 0x1dfa,
+ 0x1f16, 0x1f17,
+ 0x1f1e, 0x1f1f,
+ 0x1f46, 0x1f47,
+ 0x1f4e, 0x1f4f,
+ 0x1f58, 0x1f58,
+ 0x1f5a, 0x1f5a,
+ 0x1f5c, 0x1f5c,
+ 0x1f5e, 0x1f5e,
+ 0x1f7e, 0x1f7f,
+ 0x1fb5, 0x1fb5,
+ 0x1fc5, 0x1fc5,
+ 0x1fd4, 0x1fd5,
+ 0x1fdc, 0x1fdc,
+ 0x1ff0, 0x1ff1,
+ 0x1ff5, 0x1ff5,
+ 0x1fff, 0x1fff,
+ 0x200b, 0x200f,
+ 0x202a, 0x202e,
+ 0x2060, 0x206f,
+ 0x2072, 0x2073,
+ 0x208f, 0x208f,
+ 0x209d, 0x209f,
+ 0x20c0, 0x20cf,
+ 0x20f1, 0x20ff,
+ 0x218c, 0x218f,
+ 0x2427, 0x243f,
+ 0x244b, 0x245f,
+ 0x2b74, 0x2b75,
+ 0x2b96, 0x2b97,
+ 0x2bba, 0x2bbc,
+ 0x2bc9, 0x2bc9,
+ 0x2bd3, 0x2beb,
+ 0x2bf0, 0x2bff,
+ 0x2c2f, 0x2c2f,
+ 0x2c5f, 0x2c5f,
+ 0x2cf4, 0x2cf8,
+ 0x2d26, 0x2d26,
+ 0x2d28, 0x2d2c,
+ 0x2d2e, 0x2d2f,
+ 0x2d68, 0x2d6e,
+ 0x2d71, 0x2d7e,
+ 0x2d97, 0x2d9f,
+ 0x2da7, 0x2da7,
+ 0x2daf, 0x2daf,
+ 0x2db7, 0x2db7,
+ 0x2dbf, 0x2dbf,
+ 0x2dc7, 0x2dc7,
+ 0x2dcf, 0x2dcf,
+ 0x2dd7, 0x2dd7,
+ 0x2ddf, 0x2ddf,
+ 0x2e4a, 0x2e7f,
+ 0x2e9a, 0x2e9a,
+ 0x2ef4, 0x2eff,
+ 0x2fd6, 0x2fef,
+ 0x2ffc, 0x2fff,
+ 0x3040, 0x3040,
+ 0x3097, 0x3098,
+ 0x3100, 0x3104,
+ 0x312f, 0x3130,
+ 0x318f, 0x318f,
+ 0x31bb, 0x31bf,
+ 0x31e4, 0x31ef,
+ 0x321f, 0x321f,
+ 0x32ff, 0x32ff,
+ 0x4db6, 0x4dbf,
+ 0x9feb, 0x9fff,
+ 0xa48d, 0xa48f,
+ 0xa4c7, 0xa4cf,
+ 0xa62c, 0xa63f,
+ 0xa6f8, 0xa6ff,
+ 0xa7af, 0xa7af,
+ 0xa7b8, 0xa7f6,
+ 0xa82c, 0xa82f,
+ 0xa83a, 0xa83f,
+ 0xa878, 0xa87f,
+ 0xa8c6, 0xa8cd,
+ 0xa8da, 0xa8df,
+ 0xa8fe, 0xa8ff,
+ 0xa954, 0xa95e,
+ 0xa97d, 0xa97f,
+ 0xa9ce, 0xa9ce,
+ 0xa9da, 0xa9dd,
+ 0xa9ff, 0xa9ff,
+ 0xaa37, 0xaa3f,
+ 0xaa4e, 0xaa4f,
+ 0xaa5a, 0xaa5b,
+ 0xaac3, 0xaada,
+ 0xaaf7, 0xab00,
+ 0xab07, 0xab08,
+ 0xab0f, 0xab10,
+ 0xab17, 0xab1f,
+ 0xab27, 0xab27,
+ 0xab2f, 0xab2f,
+ 0xab66, 0xab6f,
+ 0xabee, 0xabef,
+ 0xabfa, 0xabff,
+ 0xd7a4, 0xd7af,
+ 0xd7c7, 0xd7ca,
+ 0xd7fc, 0xf8ff,
+ 0xfa6e, 0xfa6f,
+ 0xfada, 0xfaff,
+ 0xfb07, 0xfb12,
+ 0xfb18, 0xfb1c,
+ 0xfb37, 0xfb37,
+ 0xfb3d, 0xfb3d,
+ 0xfb3f, 0xfb3f,
+ 0xfb42, 0xfb42,
+ 0xfb45, 0xfb45,
+ 0xfbc2, 0xfbd2,
+ 0xfd40, 0xfd4f,
+ 0xfd90, 0xfd91,
+ 0xfdc8, 0xfdef,
+ 0xfdfe, 0xfdff,
+ 0xfe1a, 0xfe1f,
+ 0xfe53, 0xfe53,
+ 0xfe67, 0xfe67,
+ 0xfe6c, 0xfe6f,
+ 0xfe75, 0xfe75,
+ 0xfefd, 0xff00,
+ 0xffbf, 0xffc1,
+ 0xffc8, 0xffc9,
+ 0xffd0, 0xffd1,
+ 0xffd8, 0xffd9,
+ 0xffdd, 0xffdf,
+ 0xffe7, 0xffe7,
+ 0xffef, 0xfffb,
+ 0xfffe, 0xffff,
+ 0x1000c, 0x1000c,
+ 0x10027, 0x10027,
+ 0x1003b, 0x1003b,
+ 0x1003e, 0x1003e,
+ 0x1004e, 0x1004f,
+ 0x1005e, 0x1007f,
+ 0x100fb, 0x100ff,
+ 0x10103, 0x10106,
+ 0x10134, 0x10136,
+ 0x1018f, 0x1018f,
+ 0x1019c, 0x1019f,
+ 0x101a1, 0x101cf,
+ 0x101fe, 0x1027f,
+ 0x1029d, 0x1029f,
+ 0x102d1, 0x102df,
+ 0x102fc, 0x102ff,
+ 0x10324, 0x1032c,
+ 0x1034b, 0x1034f,
+ 0x1037b, 0x1037f,
+ 0x1039e, 0x1039e,
+ 0x103c4, 0x103c7,
+ 0x103d6, 0x103ff,
+ 0x1049e, 0x1049f,
+ 0x104aa, 0x104af,
+ 0x104d4, 0x104d7,
+ 0x104fc, 0x104ff,
+ 0x10528, 0x1052f,
+ 0x10564, 0x1056e,
+ 0x10570, 0x105ff,
+ 0x10737, 0x1073f,
+ 0x10756, 0x1075f,
+ 0x10768, 0x107ff,
+ 0x10806, 0x10807,
+ 0x10809, 0x10809,
+ 0x10836, 0x10836,
+ 0x10839, 0x1083b,
+ 0x1083d, 0x1083e,
+ 0x10856, 0x10856,
+ 0x1089f, 0x108a6,
+ 0x108b0, 0x108df,
+ 0x108f3, 0x108f3,
+ 0x108f6, 0x108fa,
+ 0x1091c, 0x1091e,
+ 0x1093a, 0x1093e,
+ 0x10940, 0x1097f,
+ 0x109b8, 0x109bb,
+ 0x109d0, 0x109d1,
+ 0x10a04, 0x10a04,
+ 0x10a07, 0x10a0b,
+ 0x10a14, 0x10a14,
+ 0x10a18, 0x10a18,
+ 0x10a34, 0x10a37,
+ 0x10a3b, 0x10a3e,
+ 0x10a48, 0x10a4f,
+ 0x10a59, 0x10a5f,
+ 0x10aa0, 0x10abf,
+ 0x10ae7, 0x10aea,
+ 0x10af7, 0x10aff,
+ 0x10b36, 0x10b38,
+ 0x10b56, 0x10b57,
+ 0x10b73, 0x10b77,
+ 0x10b92, 0x10b98,
+ 0x10b9d, 0x10ba8,
+ 0x10bb0, 0x10bff,
+ 0x10c49, 0x10c7f,
+ 0x10cb3, 0x10cbf,
+ 0x10cf3, 0x10cf9,
+ 0x10d00, 0x10e5f,
+ 0x10e7f, 0x10fff,
+ 0x1104e, 0x11051,
+ 0x11070, 0x1107e,
+ 0x110bd, 0x110bd,
+ 0x110c2, 0x110cf,
+ 0x110e9, 0x110ef,
+ 0x110fa, 0x110ff,
+ 0x11135, 0x11135,
+ 0x11144, 0x1114f,
+ 0x11177, 0x1117f,
+ 0x111ce, 0x111cf,
+ 0x111e0, 0x111e0,
+ 0x111f5, 0x111ff,
+ 0x11212, 0x11212,
+ 0x1123f, 0x1127f,
+ 0x11287, 0x11287,
+ 0x11289, 0x11289,
+ 0x1128e, 0x1128e,
+ 0x1129e, 0x1129e,
+ 0x112aa, 0x112af,
+ 0x112eb, 0x112ef,
+ 0x112fa, 0x112ff,
+ 0x11304, 0x11304,
+ 0x1130d, 0x1130e,
+ 0x11311, 0x11312,
+ 0x11329, 0x11329,
+ 0x11331, 0x11331,
+ 0x11334, 0x11334,
+ 0x1133a, 0x1133b,
+ 0x11345, 0x11346,
+ 0x11349, 0x1134a,
+ 0x1134e, 0x1134f,
+ 0x11351, 0x11356,
+ 0x11358, 0x1135c,
+ 0x11364, 0x11365,
+ 0x1136d, 0x1136f,
+ 0x11375, 0x113ff,
+ 0x1145a, 0x1145a,
+ 0x1145c, 0x1145c,
+ 0x1145e, 0x1147f,
+ 0x114c8, 0x114cf,
+ 0x114da, 0x1157f,
+ 0x115b6, 0x115b7,
+ 0x115de, 0x115ff,
+ 0x11645, 0x1164f,
+ 0x1165a, 0x1165f,
+ 0x1166d, 0x1167f,
+ 0x116b8, 0x116bf,
+ 0x116ca, 0x116ff,
+ 0x1171a, 0x1171c,
+ 0x1172c, 0x1172f,
+ 0x11740, 0x1189f,
+ 0x118f3, 0x118fe,
+ 0x11900, 0x119ff,
+ 0x11a48, 0x11a4f,
+ 0x11a84, 0x11a85,
+ 0x11a9d, 0x11a9d,
+ 0x11aa3, 0x11abf,
+ 0x11af9, 0x11bff,
+ 0x11c09, 0x11c09,
+ 0x11c37, 0x11c37,
+ 0x11c46, 0x11c4f,
+ 0x11c6d, 0x11c6f,
+ 0x11c90, 0x11c91,
+ 0x11ca8, 0x11ca8,
+ 0x11cb7, 0x11cff,
+ 0x11d07, 0x11d07,
+ 0x11d0a, 0x11d0a,
+ 0x11d37, 0x11d39,
+ 0x11d3b, 0x11d3b,
+ 0x11d3e, 0x11d3e,
+ 0x11d48, 0x11d4f,
+ 0x11d5a, 0x11fff,
+ 0x1239a, 0x123ff,
+ 0x1246f, 0x1246f,
+ 0x12475, 0x1247f,
+ 0x12544, 0x12fff,
+ 0x1342f, 0x143ff,
+ 0x14647, 0x167ff,
+ 0x16a39, 0x16a3f,
+ 0x16a5f, 0x16a5f,
+ 0x16a6a, 0x16a6d,
+ 0x16a70, 0x16acf,
+ 0x16aee, 0x16aef,
+ 0x16af6, 0x16aff,
+ 0x16b46, 0x16b4f,
+ 0x16b5a, 0x16b5a,
+ 0x16b62, 0x16b62,
+ 0x16b78, 0x16b7c,
+ 0x16b90, 0x16eff,
+ 0x16f45, 0x16f4f,
+ 0x16f7f, 0x16f8e,
+ 0x16fa0, 0x16fdf,
+ 0x16fe2, 0x16fff,
+ 0x187ed, 0x187ff,
+ 0x18af3, 0x1afff,
+ 0x1b11f, 0x1b16f,
+ 0x1b2fc, 0x1bbff,
+ 0x1bc6b, 0x1bc6f,
+ 0x1bc7d, 0x1bc7f,
+ 0x1bc89, 0x1bc8f,
+ 0x1bc9a, 0x1bc9b,
+ 0x1bca0, 0x1cfff,
+ 0x1d0f6, 0x1d0ff,
+ 0x1d127, 0x1d128,
+ 0x1d173, 0x1d17a,
+ 0x1d1e9, 0x1d1ff,
+ 0x1d246, 0x1d2ff,
+ 0x1d357, 0x1d35f,
+ 0x1d372, 0x1d3ff,
+ 0x1d455, 0x1d455,
+ 0x1d49d, 0x1d49d,
+ 0x1d4a0, 0x1d4a1,
+ 0x1d4a3, 0x1d4a4,
+ 0x1d4a7, 0x1d4a8,
+ 0x1d4ad, 0x1d4ad,
+ 0x1d4ba, 0x1d4ba,
+ 0x1d4bc, 0x1d4bc,
+ 0x1d4c4, 0x1d4c4,
+ 0x1d506, 0x1d506,
+ 0x1d50b, 0x1d50c,
+ 0x1d515, 0x1d515,
+ 0x1d51d, 0x1d51d,
+ 0x1d53a, 0x1d53a,
+ 0x1d53f, 0x1d53f,
+ 0x1d545, 0x1d545,
+ 0x1d547, 0x1d549,
+ 0x1d551, 0x1d551,
+ 0x1d6a6, 0x1d6a7,
+ 0x1d7cc, 0x1d7cd,
+ 0x1da8c, 0x1da9a,
+ 0x1daa0, 0x1daa0,
+ 0x1dab0, 0x1dfff,
+ 0x1e007, 0x1e007,
+ 0x1e019, 0x1e01a,
+ 0x1e022, 0x1e022,
+ 0x1e025, 0x1e025,
+ 0x1e02b, 0x1e7ff,
+ 0x1e8c5, 0x1e8c6,
+ 0x1e8d7, 0x1e8ff,
+ 0x1e94b, 0x1e94f,
+ 0x1e95a, 0x1e95d,
+ 0x1e960, 0x1edff,
+ 0x1ee04, 0x1ee04,
+ 0x1ee20, 0x1ee20,
+ 0x1ee23, 0x1ee23,
+ 0x1ee25, 0x1ee26,
+ 0x1ee28, 0x1ee28,
+ 0x1ee33, 0x1ee33,
+ 0x1ee38, 0x1ee38,
+ 0x1ee3a, 0x1ee3a,
+ 0x1ee3c, 0x1ee41,
+ 0x1ee43, 0x1ee46,
+ 0x1ee48, 0x1ee48,
+ 0x1ee4a, 0x1ee4a,
+ 0x1ee4c, 0x1ee4c,
+ 0x1ee50, 0x1ee50,
+ 0x1ee53, 0x1ee53,
+ 0x1ee55, 0x1ee56,
+ 0x1ee58, 0x1ee58,
+ 0x1ee5a, 0x1ee5a,
+ 0x1ee5c, 0x1ee5c,
+ 0x1ee5e, 0x1ee5e,
+ 0x1ee60, 0x1ee60,
+ 0x1ee63, 0x1ee63,
+ 0x1ee65, 0x1ee66,
+ 0x1ee6b, 0x1ee6b,
+ 0x1ee73, 0x1ee73,
+ 0x1ee78, 0x1ee78,
+ 0x1ee7d, 0x1ee7d,
+ 0x1ee7f, 0x1ee7f,
+ 0x1ee8a, 0x1ee8a,
+ 0x1ee9c, 0x1eea0,
+ 0x1eea4, 0x1eea4,
+ 0x1eeaa, 0x1eeaa,
+ 0x1eebc, 0x1eeef,
+ 0x1eef2, 0x1efff,
+ 0x1f02c, 0x1f02f,
+ 0x1f094, 0x1f09f,
+ 0x1f0af, 0x1f0b0,
+ 0x1f0c0, 0x1f0c0,
+ 0x1f0d0, 0x1f0d0,
+ 0x1f0f6, 0x1f0ff,
+ 0x1f10d, 0x1f10f,
+ 0x1f12f, 0x1f12f,
+ 0x1f16c, 0x1f16f,
+ 0x1f1ad, 0x1f1e5,
+ 0x1f203, 0x1f20f,
+ 0x1f23c, 0x1f23f,
+ 0x1f249, 0x1f24f,
+ 0x1f252, 0x1f25f,
+ 0x1f266, 0x1f2ff,
+ 0x1f6d5, 0x1f6df,
+ 0x1f6ed, 0x1f6ef,
+ 0x1f6f9, 0x1f6ff,
+ 0x1f774, 0x1f77f,
+ 0x1f7d5, 0x1f7ff,
+ 0x1f80c, 0x1f80f,
+ 0x1f848, 0x1f84f,
+ 0x1f85a, 0x1f85f,
+ 0x1f888, 0x1f88f,
+ 0x1f8ae, 0x1f8ff,
+ 0x1f90c, 0x1f90f,
+ 0x1f93f, 0x1f93f,
+ 0x1f94d, 0x1f94f,
+ 0x1f96c, 0x1f97f,
+ 0x1f998, 0x1f9bf,
+ 0x1f9c1, 0x1f9cf,
+ 0x1f9e7, 0x1ffff,
+ 0x2a6d7, 0x2a6ff,
+ 0x2b735, 0x2b73f,
+ 0x2b81e, 0x2b81f,
+ 0x2cea2, 0x2ceaf,
+ 0x2ebe1, 0x2f7ff,
+ 0x2fa1e, 0xe00ff,
+ 0xe01f0, 0x10ffff,
+}; /* CR_C */
+
+/* 'Cc': General Category */
+#define CR_Cc CR_Cntrl
+
+/* 'Cf': General Category */
+static const OnigCodePoint CR_Cf[] = {
+ 18,
+ 0x00ad, 0x00ad,
+ 0x0600, 0x0605,
+ 0x061c, 0x061c,
+ 0x06dd, 0x06dd,
+ 0x070f, 0x070f,
+ 0x08e2, 0x08e2,
+ 0x180e, 0x180e,
+ 0x200b, 0x200f,
+ 0x202a, 0x202e,
+ 0x2060, 0x2064,
+ 0x2066, 0x206f,
+ 0xfeff, 0xfeff,
+ 0xfff9, 0xfffb,
+ 0x110bd, 0x110bd,
+ 0x1bca0, 0x1bca3,
+ 0x1d173, 0x1d17a,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+}; /* CR_Cf */
+
+/* 'Cn': General Category */
+static const OnigCodePoint CR_Cn[] = {
+ 649,
+ 0x0378, 0x0379,
+ 0x0380, 0x0383,
+ 0x038b, 0x038b,
+ 0x038d, 0x038d,
+ 0x03a2, 0x03a2,
+ 0x0530, 0x0530,
+ 0x0557, 0x0558,
+ 0x0560, 0x0560,
+ 0x0588, 0x0588,
+ 0x058b, 0x058c,
+ 0x0590, 0x0590,
+ 0x05c8, 0x05cf,
+ 0x05eb, 0x05ef,
+ 0x05f5, 0x05ff,
+ 0x061d, 0x061d,
+ 0x070e, 0x070e,
+ 0x074b, 0x074c,
+ 0x07b2, 0x07bf,
+ 0x07fb, 0x07ff,
+ 0x082e, 0x082f,
+ 0x083f, 0x083f,
+ 0x085c, 0x085d,
+ 0x085f, 0x085f,
+ 0x086b, 0x089f,
+ 0x08b5, 0x08b5,
+ 0x08be, 0x08d3,
+ 0x0984, 0x0984,
+ 0x098d, 0x098e,
+ 0x0991, 0x0992,
+ 0x09a9, 0x09a9,
+ 0x09b1, 0x09b1,
+ 0x09b3, 0x09b5,
+ 0x09ba, 0x09bb,
+ 0x09c5, 0x09c6,
+ 0x09c9, 0x09ca,
+ 0x09cf, 0x09d6,
+ 0x09d8, 0x09db,
+ 0x09de, 0x09de,
+ 0x09e4, 0x09e5,
+ 0x09fe, 0x0a00,
+ 0x0a04, 0x0a04,
+ 0x0a0b, 0x0a0e,
+ 0x0a11, 0x0a12,
+ 0x0a29, 0x0a29,
+ 0x0a31, 0x0a31,
+ 0x0a34, 0x0a34,
+ 0x0a37, 0x0a37,
+ 0x0a3a, 0x0a3b,
+ 0x0a3d, 0x0a3d,
+ 0x0a43, 0x0a46,
+ 0x0a49, 0x0a4a,
+ 0x0a4e, 0x0a50,
+ 0x0a52, 0x0a58,
+ 0x0a5d, 0x0a5d,
+ 0x0a5f, 0x0a65,
+ 0x0a76, 0x0a80,
+ 0x0a84, 0x0a84,
+ 0x0a8e, 0x0a8e,
+ 0x0a92, 0x0a92,
+ 0x0aa9, 0x0aa9,
+ 0x0ab1, 0x0ab1,
+ 0x0ab4, 0x0ab4,
+ 0x0aba, 0x0abb,
+ 0x0ac6, 0x0ac6,
+ 0x0aca, 0x0aca,
+ 0x0ace, 0x0acf,
+ 0x0ad1, 0x0adf,
+ 0x0ae4, 0x0ae5,
+ 0x0af2, 0x0af8,
+ 0x0b00, 0x0b00,
+ 0x0b04, 0x0b04,
+ 0x0b0d, 0x0b0e,
+ 0x0b11, 0x0b12,
+ 0x0b29, 0x0b29,
+ 0x0b31, 0x0b31,
+ 0x0b34, 0x0b34,
+ 0x0b3a, 0x0b3b,
+ 0x0b45, 0x0b46,
+ 0x0b49, 0x0b4a,
+ 0x0b4e, 0x0b55,
+ 0x0b58, 0x0b5b,
+ 0x0b5e, 0x0b5e,
+ 0x0b64, 0x0b65,
+ 0x0b78, 0x0b81,
+ 0x0b84, 0x0b84,
+ 0x0b8b, 0x0b8d,
+ 0x0b91, 0x0b91,
+ 0x0b96, 0x0b98,
+ 0x0b9b, 0x0b9b,
+ 0x0b9d, 0x0b9d,
+ 0x0ba0, 0x0ba2,
+ 0x0ba5, 0x0ba7,
+ 0x0bab, 0x0bad,
+ 0x0bba, 0x0bbd,
+ 0x0bc3, 0x0bc5,
+ 0x0bc9, 0x0bc9,
+ 0x0bce, 0x0bcf,
+ 0x0bd1, 0x0bd6,
+ 0x0bd8, 0x0be5,
+ 0x0bfb, 0x0bff,
+ 0x0c04, 0x0c04,
+ 0x0c0d, 0x0c0d,
+ 0x0c11, 0x0c11,
+ 0x0c29, 0x0c29,
+ 0x0c3a, 0x0c3c,
+ 0x0c45, 0x0c45,
+ 0x0c49, 0x0c49,
+ 0x0c4e, 0x0c54,
+ 0x0c57, 0x0c57,
+ 0x0c5b, 0x0c5f,
+ 0x0c64, 0x0c65,
+ 0x0c70, 0x0c77,
+ 0x0c84, 0x0c84,
+ 0x0c8d, 0x0c8d,
+ 0x0c91, 0x0c91,
+ 0x0ca9, 0x0ca9,
+ 0x0cb4, 0x0cb4,
+ 0x0cba, 0x0cbb,
+ 0x0cc5, 0x0cc5,
+ 0x0cc9, 0x0cc9,
+ 0x0cce, 0x0cd4,
+ 0x0cd7, 0x0cdd,
+ 0x0cdf, 0x0cdf,
+ 0x0ce4, 0x0ce5,
+ 0x0cf0, 0x0cf0,
+ 0x0cf3, 0x0cff,
+ 0x0d04, 0x0d04,
+ 0x0d0d, 0x0d0d,
+ 0x0d11, 0x0d11,
+ 0x0d45, 0x0d45,
+ 0x0d49, 0x0d49,
+ 0x0d50, 0x0d53,
+ 0x0d64, 0x0d65,
+ 0x0d80, 0x0d81,
+ 0x0d84, 0x0d84,
+ 0x0d97, 0x0d99,
+ 0x0db2, 0x0db2,
+ 0x0dbc, 0x0dbc,
+ 0x0dbe, 0x0dbf,
+ 0x0dc7, 0x0dc9,
+ 0x0dcb, 0x0dce,
+ 0x0dd5, 0x0dd5,
+ 0x0dd7, 0x0dd7,
+ 0x0de0, 0x0de5,
+ 0x0df0, 0x0df1,
+ 0x0df5, 0x0e00,
+ 0x0e3b, 0x0e3e,
+ 0x0e5c, 0x0e80,
+ 0x0e83, 0x0e83,
+ 0x0e85, 0x0e86,
+ 0x0e89, 0x0e89,
+ 0x0e8b, 0x0e8c,
+ 0x0e8e, 0x0e93,
+ 0x0e98, 0x0e98,
+ 0x0ea0, 0x0ea0,
+ 0x0ea4, 0x0ea4,
+ 0x0ea6, 0x0ea6,
+ 0x0ea8, 0x0ea9,
+ 0x0eac, 0x0eac,
+ 0x0eba, 0x0eba,
+ 0x0ebe, 0x0ebf,
+ 0x0ec5, 0x0ec5,
+ 0x0ec7, 0x0ec7,
+ 0x0ece, 0x0ecf,
+ 0x0eda, 0x0edb,
+ 0x0ee0, 0x0eff,
+ 0x0f48, 0x0f48,
+ 0x0f6d, 0x0f70,
+ 0x0f98, 0x0f98,
+ 0x0fbd, 0x0fbd,
+ 0x0fcd, 0x0fcd,
+ 0x0fdb, 0x0fff,
+ 0x10c6, 0x10c6,
+ 0x10c8, 0x10cc,
+ 0x10ce, 0x10cf,
+ 0x1249, 0x1249,
+ 0x124e, 0x124f,
+ 0x1257, 0x1257,
+ 0x1259, 0x1259,
+ 0x125e, 0x125f,
+ 0x1289, 0x1289,
+ 0x128e, 0x128f,
+ 0x12b1, 0x12b1,
+ 0x12b6, 0x12b7,
+ 0x12bf, 0x12bf,
+ 0x12c1, 0x12c1,
+ 0x12c6, 0x12c7,
+ 0x12d7, 0x12d7,
+ 0x1311, 0x1311,
+ 0x1316, 0x1317,
+ 0x135b, 0x135c,
+ 0x137d, 0x137f,
+ 0x139a, 0x139f,
+ 0x13f6, 0x13f7,
+ 0x13fe, 0x13ff,
+ 0x169d, 0x169f,
+ 0x16f9, 0x16ff,
+ 0x170d, 0x170d,
+ 0x1715, 0x171f,
+ 0x1737, 0x173f,
+ 0x1754, 0x175f,
+ 0x176d, 0x176d,
+ 0x1771, 0x1771,
+ 0x1774, 0x177f,
+ 0x17de, 0x17df,
+ 0x17ea, 0x17ef,
+ 0x17fa, 0x17ff,
+ 0x180f, 0x180f,
+ 0x181a, 0x181f,
+ 0x1878, 0x187f,
+ 0x18ab, 0x18af,
+ 0x18f6, 0x18ff,
+ 0x191f, 0x191f,
+ 0x192c, 0x192f,
+ 0x193c, 0x193f,
+ 0x1941, 0x1943,
+ 0x196e, 0x196f,
+ 0x1975, 0x197f,
+ 0x19ac, 0x19af,
+ 0x19ca, 0x19cf,
+ 0x19db, 0x19dd,
+ 0x1a1c, 0x1a1d,
+ 0x1a5f, 0x1a5f,
+ 0x1a7d, 0x1a7e,
+ 0x1a8a, 0x1a8f,
+ 0x1a9a, 0x1a9f,
+ 0x1aae, 0x1aaf,
+ 0x1abf, 0x1aff,
+ 0x1b4c, 0x1b4f,
+ 0x1b7d, 0x1b7f,
+ 0x1bf4, 0x1bfb,
+ 0x1c38, 0x1c3a,
+ 0x1c4a, 0x1c4c,
+ 0x1c89, 0x1cbf,
+ 0x1cc8, 0x1ccf,
+ 0x1cfa, 0x1cff,
+ 0x1dfa, 0x1dfa,
+ 0x1f16, 0x1f17,
+ 0x1f1e, 0x1f1f,
+ 0x1f46, 0x1f47,
+ 0x1f4e, 0x1f4f,
+ 0x1f58, 0x1f58,
+ 0x1f5a, 0x1f5a,
+ 0x1f5c, 0x1f5c,
+ 0x1f5e, 0x1f5e,
+ 0x1f7e, 0x1f7f,
+ 0x1fb5, 0x1fb5,
+ 0x1fc5, 0x1fc5,
+ 0x1fd4, 0x1fd5,
+ 0x1fdc, 0x1fdc,
+ 0x1ff0, 0x1ff1,
+ 0x1ff5, 0x1ff5,
+ 0x1fff, 0x1fff,
+ 0x2065, 0x2065,
+ 0x2072, 0x2073,
+ 0x208f, 0x208f,
+ 0x209d, 0x209f,
+ 0x20c0, 0x20cf,
+ 0x20f1, 0x20ff,
+ 0x218c, 0x218f,
+ 0x2427, 0x243f,
+ 0x244b, 0x245f,
+ 0x2b74, 0x2b75,
+ 0x2b96, 0x2b97,
+ 0x2bba, 0x2bbc,
+ 0x2bc9, 0x2bc9,
+ 0x2bd3, 0x2beb,
+ 0x2bf0, 0x2bff,
+ 0x2c2f, 0x2c2f,
+ 0x2c5f, 0x2c5f,
+ 0x2cf4, 0x2cf8,
+ 0x2d26, 0x2d26,
+ 0x2d28, 0x2d2c,
+ 0x2d2e, 0x2d2f,
+ 0x2d68, 0x2d6e,
+ 0x2d71, 0x2d7e,
+ 0x2d97, 0x2d9f,
+ 0x2da7, 0x2da7,
+ 0x2daf, 0x2daf,
+ 0x2db7, 0x2db7,
+ 0x2dbf, 0x2dbf,
+ 0x2dc7, 0x2dc7,
+ 0x2dcf, 0x2dcf,
+ 0x2dd7, 0x2dd7,
+ 0x2ddf, 0x2ddf,
+ 0x2e4a, 0x2e7f,
+ 0x2e9a, 0x2e9a,
+ 0x2ef4, 0x2eff,
+ 0x2fd6, 0x2fef,
+ 0x2ffc, 0x2fff,
+ 0x3040, 0x3040,
+ 0x3097, 0x3098,
+ 0x3100, 0x3104,
+ 0x312f, 0x3130,
+ 0x318f, 0x318f,
+ 0x31bb, 0x31bf,
+ 0x31e4, 0x31ef,
+ 0x321f, 0x321f,
+ 0x32ff, 0x32ff,
+ 0x4db6, 0x4dbf,
+ 0x9feb, 0x9fff,
+ 0xa48d, 0xa48f,
+ 0xa4c7, 0xa4cf,
+ 0xa62c, 0xa63f,
+ 0xa6f8, 0xa6ff,
+ 0xa7af, 0xa7af,
+ 0xa7b8, 0xa7f6,
+ 0xa82c, 0xa82f,
+ 0xa83a, 0xa83f,
+ 0xa878, 0xa87f,
+ 0xa8c6, 0xa8cd,
+ 0xa8da, 0xa8df,
+ 0xa8fe, 0xa8ff,
+ 0xa954, 0xa95e,
+ 0xa97d, 0xa97f,
+ 0xa9ce, 0xa9ce,
+ 0xa9da, 0xa9dd,
+ 0xa9ff, 0xa9ff,
+ 0xaa37, 0xaa3f,
+ 0xaa4e, 0xaa4f,
+ 0xaa5a, 0xaa5b,
+ 0xaac3, 0xaada,
+ 0xaaf7, 0xab00,
+ 0xab07, 0xab08,
+ 0xab0f, 0xab10,
+ 0xab17, 0xab1f,
+ 0xab27, 0xab27,
+ 0xab2f, 0xab2f,
+ 0xab66, 0xab6f,
+ 0xabee, 0xabef,
+ 0xabfa, 0xabff,
+ 0xd7a4, 0xd7af,
+ 0xd7c7, 0xd7ca,
+ 0xd7fc, 0xd7ff,
+ 0xfa6e, 0xfa6f,
+ 0xfada, 0xfaff,
+ 0xfb07, 0xfb12,
+ 0xfb18, 0xfb1c,
+ 0xfb37, 0xfb37,
+ 0xfb3d, 0xfb3d,
+ 0xfb3f, 0xfb3f,
+ 0xfb42, 0xfb42,
+ 0xfb45, 0xfb45,
+ 0xfbc2, 0xfbd2,
+ 0xfd40, 0xfd4f,
+ 0xfd90, 0xfd91,
+ 0xfdc8, 0xfdef,
+ 0xfdfe, 0xfdff,
+ 0xfe1a, 0xfe1f,
+ 0xfe53, 0xfe53,
+ 0xfe67, 0xfe67,
+ 0xfe6c, 0xfe6f,
+ 0xfe75, 0xfe75,
+ 0xfefd, 0xfefe,
+ 0xff00, 0xff00,
+ 0xffbf, 0xffc1,
+ 0xffc8, 0xffc9,
+ 0xffd0, 0xffd1,
+ 0xffd8, 0xffd9,
+ 0xffdd, 0xffdf,
+ 0xffe7, 0xffe7,
+ 0xffef, 0xfff8,
+ 0xfffe, 0xffff,
+ 0x1000c, 0x1000c,
+ 0x10027, 0x10027,
+ 0x1003b, 0x1003b,
+ 0x1003e, 0x1003e,
+ 0x1004e, 0x1004f,
+ 0x1005e, 0x1007f,
+ 0x100fb, 0x100ff,
+ 0x10103, 0x10106,
+ 0x10134, 0x10136,
+ 0x1018f, 0x1018f,
+ 0x1019c, 0x1019f,
+ 0x101a1, 0x101cf,
+ 0x101fe, 0x1027f,
+ 0x1029d, 0x1029f,
+ 0x102d1, 0x102df,
+ 0x102fc, 0x102ff,
+ 0x10324, 0x1032c,
+ 0x1034b, 0x1034f,
+ 0x1037b, 0x1037f,
+ 0x1039e, 0x1039e,
+ 0x103c4, 0x103c7,
+ 0x103d6, 0x103ff,
+ 0x1049e, 0x1049f,
+ 0x104aa, 0x104af,
+ 0x104d4, 0x104d7,
+ 0x104fc, 0x104ff,
+ 0x10528, 0x1052f,
+ 0x10564, 0x1056e,
+ 0x10570, 0x105ff,
+ 0x10737, 0x1073f,
+ 0x10756, 0x1075f,
+ 0x10768, 0x107ff,
+ 0x10806, 0x10807,
+ 0x10809, 0x10809,
+ 0x10836, 0x10836,
+ 0x10839, 0x1083b,
+ 0x1083d, 0x1083e,
+ 0x10856, 0x10856,
+ 0x1089f, 0x108a6,
+ 0x108b0, 0x108df,
+ 0x108f3, 0x108f3,
+ 0x108f6, 0x108fa,
+ 0x1091c, 0x1091e,
+ 0x1093a, 0x1093e,
+ 0x10940, 0x1097f,
+ 0x109b8, 0x109bb,
+ 0x109d0, 0x109d1,
+ 0x10a04, 0x10a04,
+ 0x10a07, 0x10a0b,
+ 0x10a14, 0x10a14,
+ 0x10a18, 0x10a18,
+ 0x10a34, 0x10a37,
+ 0x10a3b, 0x10a3e,
+ 0x10a48, 0x10a4f,
+ 0x10a59, 0x10a5f,
+ 0x10aa0, 0x10abf,
+ 0x10ae7, 0x10aea,
+ 0x10af7, 0x10aff,
+ 0x10b36, 0x10b38,
+ 0x10b56, 0x10b57,
+ 0x10b73, 0x10b77,
+ 0x10b92, 0x10b98,
+ 0x10b9d, 0x10ba8,
+ 0x10bb0, 0x10bff,
+ 0x10c49, 0x10c7f,
+ 0x10cb3, 0x10cbf,
+ 0x10cf3, 0x10cf9,
+ 0x10d00, 0x10e5f,
+ 0x10e7f, 0x10fff,
+ 0x1104e, 0x11051,
+ 0x11070, 0x1107e,
+ 0x110c2, 0x110cf,
+ 0x110e9, 0x110ef,
+ 0x110fa, 0x110ff,
+ 0x11135, 0x11135,
+ 0x11144, 0x1114f,
+ 0x11177, 0x1117f,
+ 0x111ce, 0x111cf,
+ 0x111e0, 0x111e0,
+ 0x111f5, 0x111ff,
+ 0x11212, 0x11212,
+ 0x1123f, 0x1127f,
+ 0x11287, 0x11287,
+ 0x11289, 0x11289,
+ 0x1128e, 0x1128e,
+ 0x1129e, 0x1129e,
+ 0x112aa, 0x112af,
+ 0x112eb, 0x112ef,
+ 0x112fa, 0x112ff,
+ 0x11304, 0x11304,
+ 0x1130d, 0x1130e,
+ 0x11311, 0x11312,
+ 0x11329, 0x11329,
+ 0x11331, 0x11331,
+ 0x11334, 0x11334,
+ 0x1133a, 0x1133b,
+ 0x11345, 0x11346,
+ 0x11349, 0x1134a,
+ 0x1134e, 0x1134f,
+ 0x11351, 0x11356,
+ 0x11358, 0x1135c,
+ 0x11364, 0x11365,
+ 0x1136d, 0x1136f,
+ 0x11375, 0x113ff,
+ 0x1145a, 0x1145a,
+ 0x1145c, 0x1145c,
+ 0x1145e, 0x1147f,
+ 0x114c8, 0x114cf,
+ 0x114da, 0x1157f,
+ 0x115b6, 0x115b7,
+ 0x115de, 0x115ff,
+ 0x11645, 0x1164f,
+ 0x1165a, 0x1165f,
+ 0x1166d, 0x1167f,
+ 0x116b8, 0x116bf,
+ 0x116ca, 0x116ff,
+ 0x1171a, 0x1171c,
+ 0x1172c, 0x1172f,
+ 0x11740, 0x1189f,
+ 0x118f3, 0x118fe,
+ 0x11900, 0x119ff,
+ 0x11a48, 0x11a4f,
+ 0x11a84, 0x11a85,
+ 0x11a9d, 0x11a9d,
+ 0x11aa3, 0x11abf,
+ 0x11af9, 0x11bff,
+ 0x11c09, 0x11c09,
+ 0x11c37, 0x11c37,
+ 0x11c46, 0x11c4f,
+ 0x11c6d, 0x11c6f,
+ 0x11c90, 0x11c91,
+ 0x11ca8, 0x11ca8,
+ 0x11cb7, 0x11cff,
+ 0x11d07, 0x11d07,
+ 0x11d0a, 0x11d0a,
+ 0x11d37, 0x11d39,
+ 0x11d3b, 0x11d3b,
+ 0x11d3e, 0x11d3e,
+ 0x11d48, 0x11d4f,
+ 0x11d5a, 0x11fff,
+ 0x1239a, 0x123ff,
+ 0x1246f, 0x1246f,
+ 0x12475, 0x1247f,
+ 0x12544, 0x12fff,
+ 0x1342f, 0x143ff,
+ 0x14647, 0x167ff,
+ 0x16a39, 0x16a3f,
+ 0x16a5f, 0x16a5f,
+ 0x16a6a, 0x16a6d,
+ 0x16a70, 0x16acf,
+ 0x16aee, 0x16aef,
+ 0x16af6, 0x16aff,
+ 0x16b46, 0x16b4f,
+ 0x16b5a, 0x16b5a,
+ 0x16b62, 0x16b62,
+ 0x16b78, 0x16b7c,
+ 0x16b90, 0x16eff,
+ 0x16f45, 0x16f4f,
+ 0x16f7f, 0x16f8e,
+ 0x16fa0, 0x16fdf,
+ 0x16fe2, 0x16fff,
+ 0x187ed, 0x187ff,
+ 0x18af3, 0x1afff,
+ 0x1b11f, 0x1b16f,
+ 0x1b2fc, 0x1bbff,
+ 0x1bc6b, 0x1bc6f,
+ 0x1bc7d, 0x1bc7f,
+ 0x1bc89, 0x1bc8f,
+ 0x1bc9a, 0x1bc9b,
+ 0x1bca4, 0x1cfff,
+ 0x1d0f6, 0x1d0ff,
+ 0x1d127, 0x1d128,
+ 0x1d1e9, 0x1d1ff,
+ 0x1d246, 0x1d2ff,
+ 0x1d357, 0x1d35f,
+ 0x1d372, 0x1d3ff,
+ 0x1d455, 0x1d455,
+ 0x1d49d, 0x1d49d,
+ 0x1d4a0, 0x1d4a1,
+ 0x1d4a3, 0x1d4a4,
+ 0x1d4a7, 0x1d4a8,
+ 0x1d4ad, 0x1d4ad,
+ 0x1d4ba, 0x1d4ba,
+ 0x1d4bc, 0x1d4bc,
+ 0x1d4c4, 0x1d4c4,
+ 0x1d506, 0x1d506,
+ 0x1d50b, 0x1d50c,
+ 0x1d515, 0x1d515,
+ 0x1d51d, 0x1d51d,
+ 0x1d53a, 0x1d53a,
+ 0x1d53f, 0x1d53f,
+ 0x1d545, 0x1d545,
+ 0x1d547, 0x1d549,
+ 0x1d551, 0x1d551,
+ 0x1d6a6, 0x1d6a7,
+ 0x1d7cc, 0x1d7cd,
+ 0x1da8c, 0x1da9a,
+ 0x1daa0, 0x1daa0,
+ 0x1dab0, 0x1dfff,
+ 0x1e007, 0x1e007,
+ 0x1e019, 0x1e01a,
+ 0x1e022, 0x1e022,
+ 0x1e025, 0x1e025,
+ 0x1e02b, 0x1e7ff,
+ 0x1e8c5, 0x1e8c6,
+ 0x1e8d7, 0x1e8ff,
+ 0x1e94b, 0x1e94f,
+ 0x1e95a, 0x1e95d,
+ 0x1e960, 0x1edff,
+ 0x1ee04, 0x1ee04,
+ 0x1ee20, 0x1ee20,
+ 0x1ee23, 0x1ee23,
+ 0x1ee25, 0x1ee26,
+ 0x1ee28, 0x1ee28,
+ 0x1ee33, 0x1ee33,
+ 0x1ee38, 0x1ee38,
+ 0x1ee3a, 0x1ee3a,
+ 0x1ee3c, 0x1ee41,
+ 0x1ee43, 0x1ee46,
+ 0x1ee48, 0x1ee48,
+ 0x1ee4a, 0x1ee4a,
+ 0x1ee4c, 0x1ee4c,
+ 0x1ee50, 0x1ee50,
+ 0x1ee53, 0x1ee53,
+ 0x1ee55, 0x1ee56,
+ 0x1ee58, 0x1ee58,
+ 0x1ee5a, 0x1ee5a,
+ 0x1ee5c, 0x1ee5c,
+ 0x1ee5e, 0x1ee5e,
+ 0x1ee60, 0x1ee60,
+ 0x1ee63, 0x1ee63,
+ 0x1ee65, 0x1ee66,
+ 0x1ee6b, 0x1ee6b,
+ 0x1ee73, 0x1ee73,
+ 0x1ee78, 0x1ee78,
+ 0x1ee7d, 0x1ee7d,
+ 0x1ee7f, 0x1ee7f,
+ 0x1ee8a, 0x1ee8a,
+ 0x1ee9c, 0x1eea0,
+ 0x1eea4, 0x1eea4,
+ 0x1eeaa, 0x1eeaa,
+ 0x1eebc, 0x1eeef,
+ 0x1eef2, 0x1efff,
+ 0x1f02c, 0x1f02f,
+ 0x1f094, 0x1f09f,
+ 0x1f0af, 0x1f0b0,
+ 0x1f0c0, 0x1f0c0,
+ 0x1f0d0, 0x1f0d0,
+ 0x1f0f6, 0x1f0ff,
+ 0x1f10d, 0x1f10f,
+ 0x1f12f, 0x1f12f,
+ 0x1f16c, 0x1f16f,
+ 0x1f1ad, 0x1f1e5,
+ 0x1f203, 0x1f20f,
+ 0x1f23c, 0x1f23f,
+ 0x1f249, 0x1f24f,
+ 0x1f252, 0x1f25f,
+ 0x1f266, 0x1f2ff,
+ 0x1f6d5, 0x1f6df,
+ 0x1f6ed, 0x1f6ef,
+ 0x1f6f9, 0x1f6ff,
+ 0x1f774, 0x1f77f,
+ 0x1f7d5, 0x1f7ff,
+ 0x1f80c, 0x1f80f,
+ 0x1f848, 0x1f84f,
+ 0x1f85a, 0x1f85f,
+ 0x1f888, 0x1f88f,
+ 0x1f8ae, 0x1f8ff,
+ 0x1f90c, 0x1f90f,
+ 0x1f93f, 0x1f93f,
+ 0x1f94d, 0x1f94f,
+ 0x1f96c, 0x1f97f,
+ 0x1f998, 0x1f9bf,
+ 0x1f9c1, 0x1f9cf,
+ 0x1f9e7, 0x1ffff,
+ 0x2a6d7, 0x2a6ff,
+ 0x2b735, 0x2b73f,
+ 0x2b81e, 0x2b81f,
+ 0x2cea2, 0x2ceaf,
+ 0x2ebe1, 0x2f7ff,
+ 0x2fa1e, 0xe0000,
+ 0xe0002, 0xe001f,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0xeffff,
+ 0xffffe, 0xfffff,
+ 0x10fffe, 0x10ffff,
+}; /* CR_Cn */
+
+/* 'Co': General Category */
+static const OnigCodePoint CR_Co[] = {
+ 3,
+ 0xe000, 0xf8ff,
+ 0xf0000, 0xffffd,
+ 0x100000, 0x10fffd,
+}; /* CR_Co */
+
+/* 'Cs': General Category */
+static const OnigCodePoint CR_Cs[] = {
+ 1,
+ 0xd800, 0xdfff,
+}; /* CR_Cs */
+
+/* 'L': Major Category */
+static const OnigCodePoint CR_L[] = {
+ 585,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0620, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06e5, 0x06e6,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0971, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a72, 0x0a74,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0abd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae1,
+ 0x0af9, 0x0af9,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b3d,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b71, 0x0b71,
+ 0x0b83, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e40, 0x0e46,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16f1, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1711,
+ 0x1720, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1877,
+ 0x1880, 0x1884,
+ 0x1887, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1aa7, 0x1aa7,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4b,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf1,
+ 0x1cf5, 0x1cf6,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2183, 0x2184,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3006,
+ 0x3031, 0x3035,
+ 0x303b, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa67f, 0xa69d,
+ 0xa6a0, 0xa6e5,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf4,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb1d,
+ 0xfb1f, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0xff66, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x10340,
+ 0x10342, 0x10349,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11003, 0x11037,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x11700, 0x11719,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a83,
+ 0x11a86, 0x11a89,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x12000, 0x12399,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f50,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_L */
+
+/* 'LC': General Category */
+static const OnigCodePoint CR_LC[] = {
+ 126,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x01ba,
+ 0x01bc, 0x01bf,
+ 0x01c4, 0x0293,
+ 0x0295, 0x02af,
+ 0x0370, 0x0373,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0561, 0x0587,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1d00, 0x1d2b,
+ 0x1d6b, 0x1d77,
+ 0x1d79, 0x1d9a,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2183, 0x2184,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2c7b,
+ 0x2c7e, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa640, 0xa66d,
+ 0xa680, 0xa69b,
+ 0xa722, 0xa76f,
+ 0xa771, 0xa787,
+ 0xa78b, 0xa78e,
+ 0xa790, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7fa, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab60, 0xab65,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0x10400, 0x1044f,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x118a0, 0x118df,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1e900, 0x1e943,
+}; /* CR_LC */
+
+/* 'Ll': General Category */
+static const OnigCodePoint CR_Ll[] = {
+ 633,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 0x00df, 0x00f6,
+ 0x00f8, 0x00ff,
+ 0x0101, 0x0101,
+ 0x0103, 0x0103,
+ 0x0105, 0x0105,
+ 0x0107, 0x0107,
+ 0x0109, 0x0109,
+ 0x010b, 0x010b,
+ 0x010d, 0x010d,
+ 0x010f, 0x010f,
+ 0x0111, 0x0111,
+ 0x0113, 0x0113,
+ 0x0115, 0x0115,
+ 0x0117, 0x0117,
+ 0x0119, 0x0119,
+ 0x011b, 0x011b,
+ 0x011d, 0x011d,
+ 0x011f, 0x011f,
+ 0x0121, 0x0121,
+ 0x0123, 0x0123,
+ 0x0125, 0x0125,
+ 0x0127, 0x0127,
+ 0x0129, 0x0129,
+ 0x012b, 0x012b,
+ 0x012d, 0x012d,
+ 0x012f, 0x012f,
+ 0x0131, 0x0131,
+ 0x0133, 0x0133,
+ 0x0135, 0x0135,
+ 0x0137, 0x0138,
+ 0x013a, 0x013a,
+ 0x013c, 0x013c,
+ 0x013e, 0x013e,
+ 0x0140, 0x0140,
+ 0x0142, 0x0142,
+ 0x0144, 0x0144,
+ 0x0146, 0x0146,
+ 0x0148, 0x0149,
+ 0x014b, 0x014b,
+ 0x014d, 0x014d,
+ 0x014f, 0x014f,
+ 0x0151, 0x0151,
+ 0x0153, 0x0153,
+ 0x0155, 0x0155,
+ 0x0157, 0x0157,
+ 0x0159, 0x0159,
+ 0x015b, 0x015b,
+ 0x015d, 0x015d,
+ 0x015f, 0x015f,
+ 0x0161, 0x0161,
+ 0x0163, 0x0163,
+ 0x0165, 0x0165,
+ 0x0167, 0x0167,
+ 0x0169, 0x0169,
+ 0x016b, 0x016b,
+ 0x016d, 0x016d,
+ 0x016f, 0x016f,
+ 0x0171, 0x0171,
+ 0x0173, 0x0173,
+ 0x0175, 0x0175,
+ 0x0177, 0x0177,
+ 0x017a, 0x017a,
+ 0x017c, 0x017c,
+ 0x017e, 0x0180,
+ 0x0183, 0x0183,
+ 0x0185, 0x0185,
+ 0x0188, 0x0188,
+ 0x018c, 0x018d,
+ 0x0192, 0x0192,
+ 0x0195, 0x0195,
+ 0x0199, 0x019b,
+ 0x019e, 0x019e,
+ 0x01a1, 0x01a1,
+ 0x01a3, 0x01a3,
+ 0x01a5, 0x01a5,
+ 0x01a8, 0x01a8,
+ 0x01aa, 0x01ab,
+ 0x01ad, 0x01ad,
+ 0x01b0, 0x01b0,
+ 0x01b4, 0x01b4,
+ 0x01b6, 0x01b6,
+ 0x01b9, 0x01ba,
+ 0x01bd, 0x01bf,
+ 0x01c6, 0x01c6,
+ 0x01c9, 0x01c9,
+ 0x01cc, 0x01cc,
+ 0x01ce, 0x01ce,
+ 0x01d0, 0x01d0,
+ 0x01d2, 0x01d2,
+ 0x01d4, 0x01d4,
+ 0x01d6, 0x01d6,
+ 0x01d8, 0x01d8,
+ 0x01da, 0x01da,
+ 0x01dc, 0x01dd,
+ 0x01df, 0x01df,
+ 0x01e1, 0x01e1,
+ 0x01e3, 0x01e3,
+ 0x01e5, 0x01e5,
+ 0x01e7, 0x01e7,
+ 0x01e9, 0x01e9,
+ 0x01eb, 0x01eb,
+ 0x01ed, 0x01ed,
+ 0x01ef, 0x01f0,
+ 0x01f3, 0x01f3,
+ 0x01f5, 0x01f5,
+ 0x01f9, 0x01f9,
+ 0x01fb, 0x01fb,
+ 0x01fd, 0x01fd,
+ 0x01ff, 0x01ff,
+ 0x0201, 0x0201,
+ 0x0203, 0x0203,
+ 0x0205, 0x0205,
+ 0x0207, 0x0207,
+ 0x0209, 0x0209,
+ 0x020b, 0x020b,
+ 0x020d, 0x020d,
+ 0x020f, 0x020f,
+ 0x0211, 0x0211,
+ 0x0213, 0x0213,
+ 0x0215, 0x0215,
+ 0x0217, 0x0217,
+ 0x0219, 0x0219,
+ 0x021b, 0x021b,
+ 0x021d, 0x021d,
+ 0x021f, 0x021f,
+ 0x0221, 0x0221,
+ 0x0223, 0x0223,
+ 0x0225, 0x0225,
+ 0x0227, 0x0227,
+ 0x0229, 0x0229,
+ 0x022b, 0x022b,
+ 0x022d, 0x022d,
+ 0x022f, 0x022f,
+ 0x0231, 0x0231,
+ 0x0233, 0x0239,
+ 0x023c, 0x023c,
+ 0x023f, 0x0240,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0293,
+ 0x0295, 0x02af,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037b, 0x037d,
+ 0x0390, 0x0390,
+ 0x03ac, 0x03ce,
+ 0x03d0, 0x03d1,
+ 0x03d5, 0x03d7,
+ 0x03d9, 0x03d9,
+ 0x03db, 0x03db,
+ 0x03dd, 0x03dd,
+ 0x03df, 0x03df,
+ 0x03e1, 0x03e1,
+ 0x03e3, 0x03e3,
+ 0x03e5, 0x03e5,
+ 0x03e7, 0x03e7,
+ 0x03e9, 0x03e9,
+ 0x03eb, 0x03eb,
+ 0x03ed, 0x03ed,
+ 0x03ef, 0x03f3,
+ 0x03f5, 0x03f5,
+ 0x03f8, 0x03f8,
+ 0x03fb, 0x03fc,
+ 0x0430, 0x045f,
+ 0x0461, 0x0461,
+ 0x0463, 0x0463,
+ 0x0465, 0x0465,
+ 0x0467, 0x0467,
+ 0x0469, 0x0469,
+ 0x046b, 0x046b,
+ 0x046d, 0x046d,
+ 0x046f, 0x046f,
+ 0x0471, 0x0471,
+ 0x0473, 0x0473,
+ 0x0475, 0x0475,
+ 0x0477, 0x0477,
+ 0x0479, 0x0479,
+ 0x047b, 0x047b,
+ 0x047d, 0x047d,
+ 0x047f, 0x047f,
+ 0x0481, 0x0481,
+ 0x048b, 0x048b,
+ 0x048d, 0x048d,
+ 0x048f, 0x048f,
+ 0x0491, 0x0491,
+ 0x0493, 0x0493,
+ 0x0495, 0x0495,
+ 0x0497, 0x0497,
+ 0x0499, 0x0499,
+ 0x049b, 0x049b,
+ 0x049d, 0x049d,
+ 0x049f, 0x049f,
+ 0x04a1, 0x04a1,
+ 0x04a3, 0x04a3,
+ 0x04a5, 0x04a5,
+ 0x04a7, 0x04a7,
+ 0x04a9, 0x04a9,
+ 0x04ab, 0x04ab,
+ 0x04ad, 0x04ad,
+ 0x04af, 0x04af,
+ 0x04b1, 0x04b1,
+ 0x04b3, 0x04b3,
+ 0x04b5, 0x04b5,
+ 0x04b7, 0x04b7,
+ 0x04b9, 0x04b9,
+ 0x04bb, 0x04bb,
+ 0x04bd, 0x04bd,
+ 0x04bf, 0x04bf,
+ 0x04c2, 0x04c2,
+ 0x04c4, 0x04c4,
+ 0x04c6, 0x04c6,
+ 0x04c8, 0x04c8,
+ 0x04ca, 0x04ca,
+ 0x04cc, 0x04cc,
+ 0x04ce, 0x04cf,
+ 0x04d1, 0x04d1,
+ 0x04d3, 0x04d3,
+ 0x04d5, 0x04d5,
+ 0x04d7, 0x04d7,
+ 0x04d9, 0x04d9,
+ 0x04db, 0x04db,
+ 0x04dd, 0x04dd,
+ 0x04df, 0x04df,
+ 0x04e1, 0x04e1,
+ 0x04e3, 0x04e3,
+ 0x04e5, 0x04e5,
+ 0x04e7, 0x04e7,
+ 0x04e9, 0x04e9,
+ 0x04eb, 0x04eb,
+ 0x04ed, 0x04ed,
+ 0x04ef, 0x04ef,
+ 0x04f1, 0x04f1,
+ 0x04f3, 0x04f3,
+ 0x04f5, 0x04f5,
+ 0x04f7, 0x04f7,
+ 0x04f9, 0x04f9,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0561, 0x0587,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1d00, 0x1d2b,
+ 0x1d6b, 0x1d77,
+ 0x1d79, 0x1d9a,
+ 0x1e01, 0x1e01,
+ 0x1e03, 0x1e03,
+ 0x1e05, 0x1e05,
+ 0x1e07, 0x1e07,
+ 0x1e09, 0x1e09,
+ 0x1e0b, 0x1e0b,
+ 0x1e0d, 0x1e0d,
+ 0x1e0f, 0x1e0f,
+ 0x1e11, 0x1e11,
+ 0x1e13, 0x1e13,
+ 0x1e15, 0x1e15,
+ 0x1e17, 0x1e17,
+ 0x1e19, 0x1e19,
+ 0x1e1b, 0x1e1b,
+ 0x1e1d, 0x1e1d,
+ 0x1e1f, 0x1e1f,
+ 0x1e21, 0x1e21,
+ 0x1e23, 0x1e23,
+ 0x1e25, 0x1e25,
+ 0x1e27, 0x1e27,
+ 0x1e29, 0x1e29,
+ 0x1e2b, 0x1e2b,
+ 0x1e2d, 0x1e2d,
+ 0x1e2f, 0x1e2f,
+ 0x1e31, 0x1e31,
+ 0x1e33, 0x1e33,
+ 0x1e35, 0x1e35,
+ 0x1e37, 0x1e37,
+ 0x1e39, 0x1e39,
+ 0x1e3b, 0x1e3b,
+ 0x1e3d, 0x1e3d,
+ 0x1e3f, 0x1e3f,
+ 0x1e41, 0x1e41,
+ 0x1e43, 0x1e43,
+ 0x1e45, 0x1e45,
+ 0x1e47, 0x1e47,
+ 0x1e49, 0x1e49,
+ 0x1e4b, 0x1e4b,
+ 0x1e4d, 0x1e4d,
+ 0x1e4f, 0x1e4f,
+ 0x1e51, 0x1e51,
+ 0x1e53, 0x1e53,
+ 0x1e55, 0x1e55,
+ 0x1e57, 0x1e57,
+ 0x1e59, 0x1e59,
+ 0x1e5b, 0x1e5b,
+ 0x1e5d, 0x1e5d,
+ 0x1e5f, 0x1e5f,
+ 0x1e61, 0x1e61,
+ 0x1e63, 0x1e63,
+ 0x1e65, 0x1e65,
+ 0x1e67, 0x1e67,
+ 0x1e69, 0x1e69,
+ 0x1e6b, 0x1e6b,
+ 0x1e6d, 0x1e6d,
+ 0x1e6f, 0x1e6f,
+ 0x1e71, 0x1e71,
+ 0x1e73, 0x1e73,
+ 0x1e75, 0x1e75,
+ 0x1e77, 0x1e77,
+ 0x1e79, 0x1e79,
+ 0x1e7b, 0x1e7b,
+ 0x1e7d, 0x1e7d,
+ 0x1e7f, 0x1e7f,
+ 0x1e81, 0x1e81,
+ 0x1e83, 0x1e83,
+ 0x1e85, 0x1e85,
+ 0x1e87, 0x1e87,
+ 0x1e89, 0x1e89,
+ 0x1e8b, 0x1e8b,
+ 0x1e8d, 0x1e8d,
+ 0x1e8f, 0x1e8f,
+ 0x1e91, 0x1e91,
+ 0x1e93, 0x1e93,
+ 0x1e95, 0x1e9d,
+ 0x1e9f, 0x1e9f,
+ 0x1ea1, 0x1ea1,
+ 0x1ea3, 0x1ea3,
+ 0x1ea5, 0x1ea5,
+ 0x1ea7, 0x1ea7,
+ 0x1ea9, 0x1ea9,
+ 0x1eab, 0x1eab,
+ 0x1ead, 0x1ead,
+ 0x1eaf, 0x1eaf,
+ 0x1eb1, 0x1eb1,
+ 0x1eb3, 0x1eb3,
+ 0x1eb5, 0x1eb5,
+ 0x1eb7, 0x1eb7,
+ 0x1eb9, 0x1eb9,
+ 0x1ebb, 0x1ebb,
+ 0x1ebd, 0x1ebd,
+ 0x1ebf, 0x1ebf,
+ 0x1ec1, 0x1ec1,
+ 0x1ec3, 0x1ec3,
+ 0x1ec5, 0x1ec5,
+ 0x1ec7, 0x1ec7,
+ 0x1ec9, 0x1ec9,
+ 0x1ecb, 0x1ecb,
+ 0x1ecd, 0x1ecd,
+ 0x1ecf, 0x1ecf,
+ 0x1ed1, 0x1ed1,
+ 0x1ed3, 0x1ed3,
+ 0x1ed5, 0x1ed5,
+ 0x1ed7, 0x1ed7,
+ 0x1ed9, 0x1ed9,
+ 0x1edb, 0x1edb,
+ 0x1edd, 0x1edd,
+ 0x1edf, 0x1edf,
+ 0x1ee1, 0x1ee1,
+ 0x1ee3, 0x1ee3,
+ 0x1ee5, 0x1ee5,
+ 0x1ee7, 0x1ee7,
+ 0x1ee9, 0x1ee9,
+ 0x1eeb, 0x1eeb,
+ 0x1eed, 0x1eed,
+ 0x1eef, 0x1eef,
+ 0x1ef1, 0x1ef1,
+ 0x1ef3, 0x1ef3,
+ 0x1ef5, 0x1ef5,
+ 0x1ef7, 0x1ef7,
+ 0x1ef9, 0x1ef9,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 0x1f07,
+ 0x1f10, 0x1f15,
+ 0x1f20, 0x1f27,
+ 0x1f30, 0x1f37,
+ 0x1f40, 0x1f45,
+ 0x1f50, 0x1f57,
+ 0x1f60, 0x1f67,
+ 0x1f70, 0x1f7d,
+ 0x1f80, 0x1f87,
+ 0x1f90, 0x1f97,
+ 0x1fa0, 0x1fa7,
+ 0x1fb0, 0x1fb4,
+ 0x1fb6, 0x1fb7,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fc7,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fd7,
+ 0x1fe0, 0x1fe7,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ff7,
+ 0x210a, 0x210a,
+ 0x210e, 0x210f,
+ 0x2113, 0x2113,
+ 0x212f, 0x212f,
+ 0x2134, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213d,
+ 0x2146, 0x2149,
+ 0x214e, 0x214e,
+ 0x2184, 0x2184,
+ 0x2c30, 0x2c5e,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c71, 0x2c71,
+ 0x2c73, 0x2c74,
+ 0x2c76, 0x2c7b,
+ 0x2c81, 0x2c81,
+ 0x2c83, 0x2c83,
+ 0x2c85, 0x2c85,
+ 0x2c87, 0x2c87,
+ 0x2c89, 0x2c89,
+ 0x2c8b, 0x2c8b,
+ 0x2c8d, 0x2c8d,
+ 0x2c8f, 0x2c8f,
+ 0x2c91, 0x2c91,
+ 0x2c93, 0x2c93,
+ 0x2c95, 0x2c95,
+ 0x2c97, 0x2c97,
+ 0x2c99, 0x2c99,
+ 0x2c9b, 0x2c9b,
+ 0x2c9d, 0x2c9d,
+ 0x2c9f, 0x2c9f,
+ 0x2ca1, 0x2ca1,
+ 0x2ca3, 0x2ca3,
+ 0x2ca5, 0x2ca5,
+ 0x2ca7, 0x2ca7,
+ 0x2ca9, 0x2ca9,
+ 0x2cab, 0x2cab,
+ 0x2cad, 0x2cad,
+ 0x2caf, 0x2caf,
+ 0x2cb1, 0x2cb1,
+ 0x2cb3, 0x2cb3,
+ 0x2cb5, 0x2cb5,
+ 0x2cb7, 0x2cb7,
+ 0x2cb9, 0x2cb9,
+ 0x2cbb, 0x2cbb,
+ 0x2cbd, 0x2cbd,
+ 0x2cbf, 0x2cbf,
+ 0x2cc1, 0x2cc1,
+ 0x2cc3, 0x2cc3,
+ 0x2cc5, 0x2cc5,
+ 0x2cc7, 0x2cc7,
+ 0x2cc9, 0x2cc9,
+ 0x2ccb, 0x2ccb,
+ 0x2ccd, 0x2ccd,
+ 0x2ccf, 0x2ccf,
+ 0x2cd1, 0x2cd1,
+ 0x2cd3, 0x2cd3,
+ 0x2cd5, 0x2cd5,
+ 0x2cd7, 0x2cd7,
+ 0x2cd9, 0x2cd9,
+ 0x2cdb, 0x2cdb,
+ 0x2cdd, 0x2cdd,
+ 0x2cdf, 0x2cdf,
+ 0x2ce1, 0x2ce1,
+ 0x2ce3, 0x2ce4,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69b,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa731,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa76f,
+ 0xa771, 0xa778,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa78e, 0xa78e,
+ 0xa791, 0xa791,
+ 0xa793, 0xa795,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xa7fa, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab60, 0xab65,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10cc0, 0x10cf2,
+ 0x118c0, 0x118df,
+ 0x1d41a, 0x1d433,
+ 0x1d44e, 0x1d454,
+ 0x1d456, 0x1d467,
+ 0x1d482, 0x1d49b,
+ 0x1d4b6, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d4cf,
+ 0x1d4ea, 0x1d503,
+ 0x1d51e, 0x1d537,
+ 0x1d552, 0x1d56b,
+ 0x1d586, 0x1d59f,
+ 0x1d5ba, 0x1d5d3,
+ 0x1d5ee, 0x1d607,
+ 0x1d622, 0x1d63b,
+ 0x1d656, 0x1d66f,
+ 0x1d68a, 0x1d6a5,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6e1,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d71b,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d755,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d78f,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7c9,
+ 0x1d7cb, 0x1d7cb,
+ 0x1e922, 0x1e943,
+}; /* CR_Ll */
+
+/* 'Lm': General Category */
+static const OnigCodePoint CR_Lm[] = {
+ 57,
+ 0x02b0, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0374, 0x0374,
+ 0x037a, 0x037a,
+ 0x0559, 0x0559,
+ 0x0640, 0x0640,
+ 0x06e5, 0x06e6,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0971, 0x0971,
+ 0x0e46, 0x0e46,
+ 0x0ec6, 0x0ec6,
+ 0x10fc, 0x10fc,
+ 0x17d7, 0x17d7,
+ 0x1843, 0x1843,
+ 0x1aa7, 0x1aa7,
+ 0x1c78, 0x1c7d,
+ 0x1d2c, 0x1d6a,
+ 0x1d78, 0x1d78,
+ 0x1d9b, 0x1dbf,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2c7c, 0x2c7d,
+ 0x2d6f, 0x2d6f,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3005,
+ 0x3031, 0x3035,
+ 0x303b, 0x303b,
+ 0x309d, 0x309e,
+ 0x30fc, 0x30fe,
+ 0xa015, 0xa015,
+ 0xa4f8, 0xa4fd,
+ 0xa60c, 0xa60c,
+ 0xa67f, 0xa67f,
+ 0xa69c, 0xa69d,
+ 0xa717, 0xa71f,
+ 0xa770, 0xa770,
+ 0xa788, 0xa788,
+ 0xa7f8, 0xa7f9,
+ 0xa9cf, 0xa9cf,
+ 0xa9e6, 0xa9e6,
+ 0xaa70, 0xaa70,
+ 0xaadd, 0xaadd,
+ 0xaaf3, 0xaaf4,
+ 0xab5c, 0xab5f,
+ 0xff70, 0xff70,
+ 0xff9e, 0xff9f,
+ 0x16b40, 0x16b43,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+}; /* CR_Lm */
+
+/* 'Lo': General Category */
+static const OnigCodePoint CR_Lo[] = {
+ 459,
+ 0x00aa, 0x00aa,
+ 0x00ba, 0x00ba,
+ 0x01bb, 0x01bb,
+ 0x01c0, 0x01c3,
+ 0x0294, 0x0294,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0620, 0x063f,
+ 0x0641, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x0800, 0x0815,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0972, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a72, 0x0a74,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0abd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae1,
+ 0x0af9, 0x0af9,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b3d,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b71, 0x0b71,
+ 0x0b83, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e40, 0x0e45,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x10d0, 0x10fa,
+ 0x10fd, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x1380, 0x138f,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16f1, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1711,
+ 0x1720, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1842,
+ 0x1844, 0x1877,
+ 0x1880, 0x1884,
+ 0x1887, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4b,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c77,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf1,
+ 0x1cf5, 0x1cf6,
+ 0x2135, 0x2138,
+ 0x2d30, 0x2d67,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x3006, 0x3006,
+ 0x303c, 0x303c,
+ 0x3041, 0x3096,
+ 0x309f, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30ff, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa014,
+ 0xa016, 0xa48c,
+ 0xa4d0, 0xa4f7,
+ 0xa500, 0xa60b,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa66e, 0xa66e,
+ 0xa6a0, 0xa6e5,
+ 0xa78f, 0xa78f,
+ 0xa7f7, 0xa7f7,
+ 0xa7fb, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9e0, 0xa9e4,
+ 0xa9e7, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa6f,
+ 0xaa71, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadc,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf2,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb1d, 0xfb1d,
+ 0xfb1f, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff66, 0xff6f,
+ 0xff71, 0xff9d,
+ 0xffa0, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x10340,
+ 0x10342, 0x10349,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x10450, 0x1049d,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x11003, 0x11037,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x11700, 0x11719,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a83,
+ 0x11a86, 0x11a89,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x12000, 0x12399,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f50,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1e800, 0x1e8c4,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_Lo */
+
+/* 'Lt': General Category */
+static const OnigCodePoint CR_Lt[] = {
+ 10,
+ 0x01c5, 0x01c5,
+ 0x01c8, 0x01c8,
+ 0x01cb, 0x01cb,
+ 0x01f2, 0x01f2,
+ 0x1f88, 0x1f8f,
+ 0x1f98, 0x1f9f,
+ 0x1fa8, 0x1faf,
+ 0x1fbc, 0x1fbc,
+ 0x1fcc, 0x1fcc,
+ 0x1ffc, 0x1ffc,
+}; /* CR_Lt */
+
+/* 'Lu': General Category */
+static const OnigCodePoint CR_Lu[] = {
+ 627,
+ 0x0041, 0x005a,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00de,
+ 0x0100, 0x0100,
+ 0x0102, 0x0102,
+ 0x0104, 0x0104,
+ 0x0106, 0x0106,
+ 0x0108, 0x0108,
+ 0x010a, 0x010a,
+ 0x010c, 0x010c,
+ 0x010e, 0x010e,
+ 0x0110, 0x0110,
+ 0x0112, 0x0112,
+ 0x0114, 0x0114,
+ 0x0116, 0x0116,
+ 0x0118, 0x0118,
+ 0x011a, 0x011a,
+ 0x011c, 0x011c,
+ 0x011e, 0x011e,
+ 0x0120, 0x0120,
+ 0x0122, 0x0122,
+ 0x0124, 0x0124,
+ 0x0126, 0x0126,
+ 0x0128, 0x0128,
+ 0x012a, 0x012a,
+ 0x012c, 0x012c,
+ 0x012e, 0x012e,
+ 0x0130, 0x0130,
+ 0x0132, 0x0132,
+ 0x0134, 0x0134,
+ 0x0136, 0x0136,
+ 0x0139, 0x0139,
+ 0x013b, 0x013b,
+ 0x013d, 0x013d,
+ 0x013f, 0x013f,
+ 0x0141, 0x0141,
+ 0x0143, 0x0143,
+ 0x0145, 0x0145,
+ 0x0147, 0x0147,
+ 0x014a, 0x014a,
+ 0x014c, 0x014c,
+ 0x014e, 0x014e,
+ 0x0150, 0x0150,
+ 0x0152, 0x0152,
+ 0x0154, 0x0154,
+ 0x0156, 0x0156,
+ 0x0158, 0x0158,
+ 0x015a, 0x015a,
+ 0x015c, 0x015c,
+ 0x015e, 0x015e,
+ 0x0160, 0x0160,
+ 0x0162, 0x0162,
+ 0x0164, 0x0164,
+ 0x0166, 0x0166,
+ 0x0168, 0x0168,
+ 0x016a, 0x016a,
+ 0x016c, 0x016c,
+ 0x016e, 0x016e,
+ 0x0170, 0x0170,
+ 0x0172, 0x0172,
+ 0x0174, 0x0174,
+ 0x0176, 0x0176,
+ 0x0178, 0x0179,
+ 0x017b, 0x017b,
+ 0x017d, 0x017d,
+ 0x0181, 0x0182,
+ 0x0184, 0x0184,
+ 0x0186, 0x0187,
+ 0x0189, 0x018b,
+ 0x018e, 0x0191,
+ 0x0193, 0x0194,
+ 0x0196, 0x0198,
+ 0x019c, 0x019d,
+ 0x019f, 0x01a0,
+ 0x01a2, 0x01a2,
+ 0x01a4, 0x01a4,
+ 0x01a6, 0x01a7,
+ 0x01a9, 0x01a9,
+ 0x01ac, 0x01ac,
+ 0x01ae, 0x01af,
+ 0x01b1, 0x01b3,
+ 0x01b5, 0x01b5,
+ 0x01b7, 0x01b8,
+ 0x01bc, 0x01bc,
+ 0x01c4, 0x01c4,
+ 0x01c7, 0x01c7,
+ 0x01ca, 0x01ca,
+ 0x01cd, 0x01cd,
+ 0x01cf, 0x01cf,
+ 0x01d1, 0x01d1,
+ 0x01d3, 0x01d3,
+ 0x01d5, 0x01d5,
+ 0x01d7, 0x01d7,
+ 0x01d9, 0x01d9,
+ 0x01db, 0x01db,
+ 0x01de, 0x01de,
+ 0x01e0, 0x01e0,
+ 0x01e2, 0x01e2,
+ 0x01e4, 0x01e4,
+ 0x01e6, 0x01e6,
+ 0x01e8, 0x01e8,
+ 0x01ea, 0x01ea,
+ 0x01ec, 0x01ec,
+ 0x01ee, 0x01ee,
+ 0x01f1, 0x01f1,
+ 0x01f4, 0x01f4,
+ 0x01f6, 0x01f8,
+ 0x01fa, 0x01fa,
+ 0x01fc, 0x01fc,
+ 0x01fe, 0x01fe,
+ 0x0200, 0x0200,
+ 0x0202, 0x0202,
+ 0x0204, 0x0204,
+ 0x0206, 0x0206,
+ 0x0208, 0x0208,
+ 0x020a, 0x020a,
+ 0x020c, 0x020c,
+ 0x020e, 0x020e,
+ 0x0210, 0x0210,
+ 0x0212, 0x0212,
+ 0x0214, 0x0214,
+ 0x0216, 0x0216,
+ 0x0218, 0x0218,
+ 0x021a, 0x021a,
+ 0x021c, 0x021c,
+ 0x021e, 0x021e,
+ 0x0220, 0x0220,
+ 0x0222, 0x0222,
+ 0x0224, 0x0224,
+ 0x0226, 0x0226,
+ 0x0228, 0x0228,
+ 0x022a, 0x022a,
+ 0x022c, 0x022c,
+ 0x022e, 0x022e,
+ 0x0230, 0x0230,
+ 0x0232, 0x0232,
+ 0x023a, 0x023b,
+ 0x023d, 0x023e,
+ 0x0241, 0x0241,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03cf, 0x03cf,
+ 0x03d2, 0x03d4,
+ 0x03d8, 0x03d8,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03e2,
+ 0x03e4, 0x03e4,
+ 0x03e6, 0x03e6,
+ 0x03e8, 0x03e8,
+ 0x03ea, 0x03ea,
+ 0x03ec, 0x03ec,
+ 0x03ee, 0x03ee,
+ 0x03f4, 0x03f4,
+ 0x03f7, 0x03f7,
+ 0x03f9, 0x03fa,
+ 0x03fd, 0x042f,
+ 0x0460, 0x0460,
+ 0x0462, 0x0462,
+ 0x0464, 0x0464,
+ 0x0466, 0x0466,
+ 0x0468, 0x0468,
+ 0x046a, 0x046a,
+ 0x046c, 0x046c,
+ 0x046e, 0x046e,
+ 0x0470, 0x0470,
+ 0x0472, 0x0472,
+ 0x0474, 0x0474,
+ 0x0476, 0x0476,
+ 0x0478, 0x0478,
+ 0x047a, 0x047a,
+ 0x047c, 0x047c,
+ 0x047e, 0x047e,
+ 0x0480, 0x0480,
+ 0x048a, 0x048a,
+ 0x048c, 0x048c,
+ 0x048e, 0x048e,
+ 0x0490, 0x0490,
+ 0x0492, 0x0492,
+ 0x0494, 0x0494,
+ 0x0496, 0x0496,
+ 0x0498, 0x0498,
+ 0x049a, 0x049a,
+ 0x049c, 0x049c,
+ 0x049e, 0x049e,
+ 0x04a0, 0x04a0,
+ 0x04a2, 0x04a2,
+ 0x04a4, 0x04a4,
+ 0x04a6, 0x04a6,
+ 0x04a8, 0x04a8,
+ 0x04aa, 0x04aa,
+ 0x04ac, 0x04ac,
+ 0x04ae, 0x04ae,
+ 0x04b0, 0x04b0,
+ 0x04b2, 0x04b2,
+ 0x04b4, 0x04b4,
+ 0x04b6, 0x04b6,
+ 0x04b8, 0x04b8,
+ 0x04ba, 0x04ba,
+ 0x04bc, 0x04bc,
+ 0x04be, 0x04be,
+ 0x04c0, 0x04c1,
+ 0x04c3, 0x04c3,
+ 0x04c5, 0x04c5,
+ 0x04c7, 0x04c7,
+ 0x04c9, 0x04c9,
+ 0x04cb, 0x04cb,
+ 0x04cd, 0x04cd,
+ 0x04d0, 0x04d0,
+ 0x04d2, 0x04d2,
+ 0x04d4, 0x04d4,
+ 0x04d6, 0x04d6,
+ 0x04d8, 0x04d8,
+ 0x04da, 0x04da,
+ 0x04dc, 0x04dc,
+ 0x04de, 0x04de,
+ 0x04e0, 0x04e0,
+ 0x04e2, 0x04e2,
+ 0x04e4, 0x04e4,
+ 0x04e6, 0x04e6,
+ 0x04e8, 0x04e8,
+ 0x04ea, 0x04ea,
+ 0x04ec, 0x04ec,
+ 0x04ee, 0x04ee,
+ 0x04f0, 0x04f0,
+ 0x04f2, 0x04f2,
+ 0x04f4, 0x04f4,
+ 0x04f6, 0x04f6,
+ 0x04f8, 0x04f8,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x1e00, 0x1e00,
+ 0x1e02, 0x1e02,
+ 0x1e04, 0x1e04,
+ 0x1e06, 0x1e06,
+ 0x1e08, 0x1e08,
+ 0x1e0a, 0x1e0a,
+ 0x1e0c, 0x1e0c,
+ 0x1e0e, 0x1e0e,
+ 0x1e10, 0x1e10,
+ 0x1e12, 0x1e12,
+ 0x1e14, 0x1e14,
+ 0x1e16, 0x1e16,
+ 0x1e18, 0x1e18,
+ 0x1e1a, 0x1e1a,
+ 0x1e1c, 0x1e1c,
+ 0x1e1e, 0x1e1e,
+ 0x1e20, 0x1e20,
+ 0x1e22, 0x1e22,
+ 0x1e24, 0x1e24,
+ 0x1e26, 0x1e26,
+ 0x1e28, 0x1e28,
+ 0x1e2a, 0x1e2a,
+ 0x1e2c, 0x1e2c,
+ 0x1e2e, 0x1e2e,
+ 0x1e30, 0x1e30,
+ 0x1e32, 0x1e32,
+ 0x1e34, 0x1e34,
+ 0x1e36, 0x1e36,
+ 0x1e38, 0x1e38,
+ 0x1e3a, 0x1e3a,
+ 0x1e3c, 0x1e3c,
+ 0x1e3e, 0x1e3e,
+ 0x1e40, 0x1e40,
+ 0x1e42, 0x1e42,
+ 0x1e44, 0x1e44,
+ 0x1e46, 0x1e46,
+ 0x1e48, 0x1e48,
+ 0x1e4a, 0x1e4a,
+ 0x1e4c, 0x1e4c,
+ 0x1e4e, 0x1e4e,
+ 0x1e50, 0x1e50,
+ 0x1e52, 0x1e52,
+ 0x1e54, 0x1e54,
+ 0x1e56, 0x1e56,
+ 0x1e58, 0x1e58,
+ 0x1e5a, 0x1e5a,
+ 0x1e5c, 0x1e5c,
+ 0x1e5e, 0x1e5e,
+ 0x1e60, 0x1e60,
+ 0x1e62, 0x1e62,
+ 0x1e64, 0x1e64,
+ 0x1e66, 0x1e66,
+ 0x1e68, 0x1e68,
+ 0x1e6a, 0x1e6a,
+ 0x1e6c, 0x1e6c,
+ 0x1e6e, 0x1e6e,
+ 0x1e70, 0x1e70,
+ 0x1e72, 0x1e72,
+ 0x1e74, 0x1e74,
+ 0x1e76, 0x1e76,
+ 0x1e78, 0x1e78,
+ 0x1e7a, 0x1e7a,
+ 0x1e7c, 0x1e7c,
+ 0x1e7e, 0x1e7e,
+ 0x1e80, 0x1e80,
+ 0x1e82, 0x1e82,
+ 0x1e84, 0x1e84,
+ 0x1e86, 0x1e86,
+ 0x1e88, 0x1e88,
+ 0x1e8a, 0x1e8a,
+ 0x1e8c, 0x1e8c,
+ 0x1e8e, 0x1e8e,
+ 0x1e90, 0x1e90,
+ 0x1e92, 0x1e92,
+ 0x1e94, 0x1e94,
+ 0x1e9e, 0x1e9e,
+ 0x1ea0, 0x1ea0,
+ 0x1ea2, 0x1ea2,
+ 0x1ea4, 0x1ea4,
+ 0x1ea6, 0x1ea6,
+ 0x1ea8, 0x1ea8,
+ 0x1eaa, 0x1eaa,
+ 0x1eac, 0x1eac,
+ 0x1eae, 0x1eae,
+ 0x1eb0, 0x1eb0,
+ 0x1eb2, 0x1eb2,
+ 0x1eb4, 0x1eb4,
+ 0x1eb6, 0x1eb6,
+ 0x1eb8, 0x1eb8,
+ 0x1eba, 0x1eba,
+ 0x1ebc, 0x1ebc,
+ 0x1ebe, 0x1ebe,
+ 0x1ec0, 0x1ec0,
+ 0x1ec2, 0x1ec2,
+ 0x1ec4, 0x1ec4,
+ 0x1ec6, 0x1ec6,
+ 0x1ec8, 0x1ec8,
+ 0x1eca, 0x1eca,
+ 0x1ecc, 0x1ecc,
+ 0x1ece, 0x1ece,
+ 0x1ed0, 0x1ed0,
+ 0x1ed2, 0x1ed2,
+ 0x1ed4, 0x1ed4,
+ 0x1ed6, 0x1ed6,
+ 0x1ed8, 0x1ed8,
+ 0x1eda, 0x1eda,
+ 0x1edc, 0x1edc,
+ 0x1ede, 0x1ede,
+ 0x1ee0, 0x1ee0,
+ 0x1ee2, 0x1ee2,
+ 0x1ee4, 0x1ee4,
+ 0x1ee6, 0x1ee6,
+ 0x1ee8, 0x1ee8,
+ 0x1eea, 0x1eea,
+ 0x1eec, 0x1eec,
+ 0x1eee, 0x1eee,
+ 0x1ef0, 0x1ef0,
+ 0x1ef2, 0x1ef2,
+ 0x1ef4, 0x1ef4,
+ 0x1ef6, 0x1ef6,
+ 0x1ef8, 0x1ef8,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 0x1f08, 0x1f0f,
+ 0x1f18, 0x1f1d,
+ 0x1f28, 0x1f2f,
+ 0x1f38, 0x1f3f,
+ 0x1f48, 0x1f4d,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f5f,
+ 0x1f68, 0x1f6f,
+ 0x1fb8, 0x1fbb,
+ 0x1fc8, 0x1fcb,
+ 0x1fd8, 0x1fdb,
+ 0x1fe8, 0x1fec,
+ 0x1ff8, 0x1ffb,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210b, 0x210d,
+ 0x2110, 0x2112,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x2130, 0x2133,
+ 0x213e, 0x213f,
+ 0x2145, 0x2145,
+ 0x2183, 0x2183,
+ 0x2c00, 0x2c2e,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 0x2c80,
+ 0x2c82, 0x2c82,
+ 0x2c84, 0x2c84,
+ 0x2c86, 0x2c86,
+ 0x2c88, 0x2c88,
+ 0x2c8a, 0x2c8a,
+ 0x2c8c, 0x2c8c,
+ 0x2c8e, 0x2c8e,
+ 0x2c90, 0x2c90,
+ 0x2c92, 0x2c92,
+ 0x2c94, 0x2c94,
+ 0x2c96, 0x2c96,
+ 0x2c98, 0x2c98,
+ 0x2c9a, 0x2c9a,
+ 0x2c9c, 0x2c9c,
+ 0x2c9e, 0x2c9e,
+ 0x2ca0, 0x2ca0,
+ 0x2ca2, 0x2ca2,
+ 0x2ca4, 0x2ca4,
+ 0x2ca6, 0x2ca6,
+ 0x2ca8, 0x2ca8,
+ 0x2caa, 0x2caa,
+ 0x2cac, 0x2cac,
+ 0x2cae, 0x2cae,
+ 0x2cb0, 0x2cb0,
+ 0x2cb2, 0x2cb2,
+ 0x2cb4, 0x2cb4,
+ 0x2cb6, 0x2cb6,
+ 0x2cb8, 0x2cb8,
+ 0x2cba, 0x2cba,
+ 0x2cbc, 0x2cbc,
+ 0x2cbe, 0x2cbe,
+ 0x2cc0, 0x2cc0,
+ 0x2cc2, 0x2cc2,
+ 0x2cc4, 0x2cc4,
+ 0x2cc6, 0x2cc6,
+ 0x2cc8, 0x2cc8,
+ 0x2cca, 0x2cca,
+ 0x2ccc, 0x2ccc,
+ 0x2cce, 0x2cce,
+ 0x2cd0, 0x2cd0,
+ 0x2cd2, 0x2cd2,
+ 0x2cd4, 0x2cd4,
+ 0x2cd6, 0x2cd6,
+ 0x2cd8, 0x2cd8,
+ 0x2cda, 0x2cda,
+ 0x2cdc, 0x2cdc,
+ 0x2cde, 0x2cde,
+ 0x2ce0, 0x2ce0,
+ 0x2ce2, 0x2ce2,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10c80, 0x10cb2,
+ 0x118a0, 0x118bf,
+ 0x1d400, 0x1d419,
+ 0x1d434, 0x1d44d,
+ 0x1d468, 0x1d481,
+ 0x1d49c, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b5,
+ 0x1d4d0, 0x1d4e9,
+ 0x1d504, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d538, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d56c, 0x1d585,
+ 0x1d5a0, 0x1d5b9,
+ 0x1d5d4, 0x1d5ed,
+ 0x1d608, 0x1d621,
+ 0x1d63c, 0x1d655,
+ 0x1d670, 0x1d689,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6e2, 0x1d6fa,
+ 0x1d71c, 0x1d734,
+ 0x1d756, 0x1d76e,
+ 0x1d790, 0x1d7a8,
+ 0x1d7ca, 0x1d7ca,
+ 0x1e900, 0x1e921,
+}; /* CR_Lu */
+
+/* 'M': Major Category */
+static const OnigCodePoint CR_M[] = {
+ 263,
+ 0x0300, 0x036f,
+ 0x0483, 0x0489,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x08d4, 0x08e1,
+ 0x08e3, 0x0903,
+ 0x093a, 0x093c,
+ 0x093e, 0x094f,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0983,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x0a01, 0x0a03,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0abc, 0x0abc,
+ 0x0abe, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b3c, 0x0b3c,
+ 0x0b3e, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c03,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c83,
+ 0x0cbc, 0x0cbc,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d03,
+ 0x0d3b, 0x0d3c,
+ 0x0d3e, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0d82, 0x0d83,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0eb9,
+ 0x0ebb, 0x0ebc,
+ 0x0ec8, 0x0ecd,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f3f,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102b, 0x103e,
+ 0x1056, 0x1059,
+ 0x105e, 0x1060,
+ 0x1062, 0x1064,
+ 0x1067, 0x106d,
+ 0x1071, 0x1074,
+ 0x1082, 0x108d,
+ 0x108f, 0x108f,
+ 0x109a, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1714,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1a17, 0x1a1b,
+ 0x1a55, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b04,
+ 0x1b34, 0x1b44,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b82,
+ 0x1ba1, 0x1bad,
+ 0x1be6, 0x1bf3,
+ 0x1c24, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf2, 0x1cf4,
+ 0x1cf7, 0x1cf9,
+ 0x1dc0, 0x1df9,
+ 0x1dfb, 0x1dff,
+ 0x20d0, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302f,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa823, 0xa827,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa953,
+ 0xa980, 0xa983,
+ 0xa9b3, 0xa9c0,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4d,
+ 0xaa7b, 0xaa7d,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaeb, 0xaaef,
+ 0xaaf5, 0xaaf6,
+ 0xabe3, 0xabea,
+ 0xabec, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x11000, 0x11002,
+ 0x11038, 0x11046,
+ 0x1107f, 0x11082,
+ 0x110b0, 0x110ba,
+ 0x11100, 0x11102,
+ 0x11127, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11182,
+ 0x111b3, 0x111c0,
+ 0x111ca, 0x111cc,
+ 0x1122c, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x112df, 0x112ea,
+ 0x11300, 0x11303,
+ 0x1133c, 0x1133c,
+ 0x1133e, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11357, 0x11357,
+ 0x11362, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11435, 0x11446,
+ 0x114b0, 0x114c3,
+ 0x115af, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11630, 0x11640,
+ 0x116ab, 0x116b7,
+ 0x1171d, 0x1172b,
+ 0x11a01, 0x11a0a,
+ 0x11a33, 0x11a39,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a5b,
+ 0x11a8a, 0x11a99,
+ 0x11c2f, 0x11c36,
+ 0x11c38, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f51, 0x16f7e,
+ 0x16f8f, 0x16f92,
+ 0x1bc9d, 0x1bc9e,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0xe0100, 0xe01ef,
+}; /* CR_M */
+
+/* 'Mc': General Category */
+static const OnigCodePoint CR_Mc[] = {
+ 160,
+ 0x0903, 0x0903,
+ 0x093b, 0x093b,
+ 0x093e, 0x0940,
+ 0x0949, 0x094c,
+ 0x094e, 0x094f,
+ 0x0982, 0x0983,
+ 0x09be, 0x09c0,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09d7, 0x09d7,
+ 0x0a03, 0x0a03,
+ 0x0a3e, 0x0a40,
+ 0x0a83, 0x0a83,
+ 0x0abe, 0x0ac0,
+ 0x0ac9, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0b02, 0x0b03,
+ 0x0b3e, 0x0b3e,
+ 0x0b40, 0x0b40,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b57, 0x0b57,
+ 0x0bbe, 0x0bbf,
+ 0x0bc1, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0bd7, 0x0bd7,
+ 0x0c01, 0x0c03,
+ 0x0c41, 0x0c44,
+ 0x0c82, 0x0c83,
+ 0x0cbe, 0x0cbe,
+ 0x0cc0, 0x0cc4,
+ 0x0cc7, 0x0cc8,
+ 0x0cca, 0x0ccb,
+ 0x0cd5, 0x0cd6,
+ 0x0d02, 0x0d03,
+ 0x0d3e, 0x0d40,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d57, 0x0d57,
+ 0x0d82, 0x0d83,
+ 0x0dcf, 0x0dd1,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0f3e, 0x0f3f,
+ 0x0f7f, 0x0f7f,
+ 0x102b, 0x102c,
+ 0x1031, 0x1031,
+ 0x1038, 0x1038,
+ 0x103b, 0x103c,
+ 0x1056, 0x1057,
+ 0x1062, 0x1064,
+ 0x1067, 0x106d,
+ 0x1083, 0x1084,
+ 0x1087, 0x108c,
+ 0x108f, 0x108f,
+ 0x109a, 0x109c,
+ 0x17b6, 0x17b6,
+ 0x17be, 0x17c5,
+ 0x17c7, 0x17c8,
+ 0x1923, 0x1926,
+ 0x1929, 0x192b,
+ 0x1930, 0x1931,
+ 0x1933, 0x1938,
+ 0x1a19, 0x1a1a,
+ 0x1a55, 0x1a55,
+ 0x1a57, 0x1a57,
+ 0x1a61, 0x1a61,
+ 0x1a63, 0x1a64,
+ 0x1a6d, 0x1a72,
+ 0x1b04, 0x1b04,
+ 0x1b35, 0x1b35,
+ 0x1b3b, 0x1b3b,
+ 0x1b3d, 0x1b41,
+ 0x1b43, 0x1b44,
+ 0x1b82, 0x1b82,
+ 0x1ba1, 0x1ba1,
+ 0x1ba6, 0x1ba7,
+ 0x1baa, 0x1baa,
+ 0x1be7, 0x1be7,
+ 0x1bea, 0x1bec,
+ 0x1bee, 0x1bee,
+ 0x1bf2, 0x1bf3,
+ 0x1c24, 0x1c2b,
+ 0x1c34, 0x1c35,
+ 0x1ce1, 0x1ce1,
+ 0x1cf2, 0x1cf3,
+ 0x1cf7, 0x1cf7,
+ 0x302e, 0x302f,
+ 0xa823, 0xa824,
+ 0xa827, 0xa827,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c3,
+ 0xa952, 0xa953,
+ 0xa983, 0xa983,
+ 0xa9b4, 0xa9b5,
+ 0xa9ba, 0xa9bb,
+ 0xa9bd, 0xa9c0,
+ 0xaa2f, 0xaa30,
+ 0xaa33, 0xaa34,
+ 0xaa4d, 0xaa4d,
+ 0xaa7b, 0xaa7b,
+ 0xaa7d, 0xaa7d,
+ 0xaaeb, 0xaaeb,
+ 0xaaee, 0xaaef,
+ 0xaaf5, 0xaaf5,
+ 0xabe3, 0xabe4,
+ 0xabe6, 0xabe7,
+ 0xabe9, 0xabea,
+ 0xabec, 0xabec,
+ 0x11000, 0x11000,
+ 0x11002, 0x11002,
+ 0x11082, 0x11082,
+ 0x110b0, 0x110b2,
+ 0x110b7, 0x110b8,
+ 0x1112c, 0x1112c,
+ 0x11182, 0x11182,
+ 0x111b3, 0x111b5,
+ 0x111bf, 0x111c0,
+ 0x1122c, 0x1122e,
+ 0x11232, 0x11233,
+ 0x11235, 0x11235,
+ 0x112e0, 0x112e2,
+ 0x11302, 0x11303,
+ 0x1133e, 0x1133f,
+ 0x11341, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11357, 0x11357,
+ 0x11362, 0x11363,
+ 0x11435, 0x11437,
+ 0x11440, 0x11441,
+ 0x11445, 0x11445,
+ 0x114b0, 0x114b2,
+ 0x114b9, 0x114b9,
+ 0x114bb, 0x114be,
+ 0x114c1, 0x114c1,
+ 0x115af, 0x115b1,
+ 0x115b8, 0x115bb,
+ 0x115be, 0x115be,
+ 0x11630, 0x11632,
+ 0x1163b, 0x1163c,
+ 0x1163e, 0x1163e,
+ 0x116ac, 0x116ac,
+ 0x116ae, 0x116af,
+ 0x116b6, 0x116b6,
+ 0x11720, 0x11721,
+ 0x11726, 0x11726,
+ 0x11a07, 0x11a08,
+ 0x11a39, 0x11a39,
+ 0x11a57, 0x11a58,
+ 0x11a97, 0x11a97,
+ 0x11c2f, 0x11c2f,
+ 0x11c3e, 0x11c3e,
+ 0x11ca9, 0x11ca9,
+ 0x11cb1, 0x11cb1,
+ 0x11cb4, 0x11cb4,
+ 0x16f51, 0x16f7e,
+ 0x1d165, 0x1d166,
+ 0x1d16d, 0x1d172,
+}; /* CR_Mc */
+
+/* 'Me': General Category */
+static const OnigCodePoint CR_Me[] = {
+ 5,
+ 0x0488, 0x0489,
+ 0x1abe, 0x1abe,
+ 0x20dd, 0x20e0,
+ 0x20e2, 0x20e4,
+ 0xa670, 0xa672,
+}; /* CR_Me */
+
+/* 'Mn': General Category */
+static const OnigCodePoint CR_Mn[] = {
+ 301,
+ 0x0300, 0x036f,
+ 0x0483, 0x0487,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x08d4, 0x08e1,
+ 0x08e3, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x094d, 0x094d,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09c1, 0x09c4,
+ 0x09cd, 0x09cd,
+ 0x09e2, 0x09e3,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0acd, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3f, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b4d, 0x0b4d,
+ 0x0b56, 0x0b56,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0c00, 0x0c00,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cbf,
+ 0x0cc6, 0x0cc6,
+ 0x0ccc, 0x0ccd,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d41, 0x0d44,
+ 0x0d4d, 0x0d4d,
+ 0x0d62, 0x0d63,
+ 0x0dca, 0x0dca,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0eb9,
+ 0x0ebb, 0x0ebc,
+ 0x0ec8, 0x0ecd,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x1039, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1714,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a60, 0x1a60,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1abd,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b34,
+ 0x1b36, 0x1b3a,
+ 0x1b3c, 0x1b3c,
+ 0x1b42, 0x1b42,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1ba9,
+ 0x1bab, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf1,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1df9,
+ 0x1dfb, 0x1dff,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302d,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa66f,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bc,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaec, 0xaaed,
+ 0xaaf6, 0xaaf6,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111ca, 0x111cc,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11234,
+ 0x11236, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133c, 0x1133c,
+ 0x11340, 0x11340,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b5,
+ 0x116b7, 0x116b7,
+ 0x1171d, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x11a01, 0x11a06,
+ 0x11a09, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a99,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f8f, 0x16f92,
+ 0x1bc9d, 0x1bc9e,
+ 0x1d167, 0x1d169,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0xe0100, 0xe01ef,
+}; /* CR_Mn */
+
+/* 'N': Major Category */
+static const OnigCodePoint CR_N[] = {
+ 116,
+ 0x0030, 0x0039,
+ 0x00b2, 0x00b3,
+ 0x00b9, 0x00b9,
+ 0x00bc, 0x00be,
+ 0x0660, 0x0669,
+ 0x06f0, 0x06f9,
+ 0x07c0, 0x07c9,
+ 0x0966, 0x096f,
+ 0x09e6, 0x09ef,
+ 0x09f4, 0x09f9,
+ 0x0a66, 0x0a6f,
+ 0x0ae6, 0x0aef,
+ 0x0b66, 0x0b6f,
+ 0x0b72, 0x0b77,
+ 0x0be6, 0x0bf2,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7e,
+ 0x0ce6, 0x0cef,
+ 0x0d58, 0x0d5e,
+ 0x0d66, 0x0d78,
+ 0x0de6, 0x0def,
+ 0x0e50, 0x0e59,
+ 0x0ed0, 0x0ed9,
+ 0x0f20, 0x0f33,
+ 0x1040, 0x1049,
+ 0x1090, 0x1099,
+ 0x1369, 0x137c,
+ 0x16ee, 0x16f0,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1810, 0x1819,
+ 0x1946, 0x194f,
+ 0x19d0, 0x19da,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1b50, 0x1b59,
+ 0x1bb0, 0x1bb9,
+ 0x1c40, 0x1c49,
+ 0x1c50, 0x1c59,
+ 0x2070, 0x2070,
+ 0x2074, 0x2079,
+ 0x2080, 0x2089,
+ 0x2150, 0x2182,
+ 0x2185, 0x2189,
+ 0x2460, 0x249b,
+ 0x24ea, 0x24ff,
+ 0x2776, 0x2793,
+ 0x2cfd, 0x2cfd,
+ 0x3007, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303a,
+ 0x3192, 0x3195,
+ 0x3220, 0x3229,
+ 0x3248, 0x324f,
+ 0x3251, 0x325f,
+ 0x3280, 0x3289,
+ 0x32b1, 0x32bf,
+ 0xa620, 0xa629,
+ 0xa6e6, 0xa6ef,
+ 0xa830, 0xa835,
+ 0xa8d0, 0xa8d9,
+ 0xa900, 0xa909,
+ 0xa9d0, 0xa9d9,
+ 0xa9f0, 0xa9f9,
+ 0xaa50, 0xaa59,
+ 0xabf0, 0xabf9,
+ 0xff10, 0xff19,
+ 0x10107, 0x10133,
+ 0x10140, 0x10178,
+ 0x1018a, 0x1018b,
+ 0x102e1, 0x102fb,
+ 0x10320, 0x10323,
+ 0x10341, 0x10341,
+ 0x1034a, 0x1034a,
+ 0x103d1, 0x103d5,
+ 0x104a0, 0x104a9,
+ 0x10858, 0x1085f,
+ 0x10879, 0x1087f,
+ 0x108a7, 0x108af,
+ 0x108fb, 0x108ff,
+ 0x10916, 0x1091b,
+ 0x109bc, 0x109bd,
+ 0x109c0, 0x109cf,
+ 0x109d2, 0x109ff,
+ 0x10a40, 0x10a47,
+ 0x10a7d, 0x10a7e,
+ 0x10a9d, 0x10a9f,
+ 0x10aeb, 0x10aef,
+ 0x10b58, 0x10b5f,
+ 0x10b78, 0x10b7f,
+ 0x10ba9, 0x10baf,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11052, 0x1106f,
+ 0x110f0, 0x110f9,
+ 0x11136, 0x1113f,
+ 0x111d0, 0x111d9,
+ 0x111e1, 0x111f4,
+ 0x112f0, 0x112f9,
+ 0x11450, 0x11459,
+ 0x114d0, 0x114d9,
+ 0x11650, 0x11659,
+ 0x116c0, 0x116c9,
+ 0x11730, 0x1173b,
+ 0x118e0, 0x118f2,
+ 0x11c50, 0x11c6c,
+ 0x11d50, 0x11d59,
+ 0x12400, 0x1246e,
+ 0x16a60, 0x16a69,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x1d360, 0x1d371,
+ 0x1d7ce, 0x1d7ff,
+ 0x1e8c7, 0x1e8cf,
+ 0x1e950, 0x1e959,
+ 0x1f100, 0x1f10c,
+}; /* CR_N */
+
+/* 'Nd': General Category */
+#define CR_Nd CR_Digit
+
+/* 'Nl': General Category */
+static const OnigCodePoint CR_Nl[] = {
+ 12,
+ 0x16ee, 0x16f0,
+ 0x2160, 0x2182,
+ 0x2185, 0x2188,
+ 0x3007, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303a,
+ 0xa6e6, 0xa6ef,
+ 0x10140, 0x10174,
+ 0x10341, 0x10341,
+ 0x1034a, 0x1034a,
+ 0x103d1, 0x103d5,
+ 0x12400, 0x1246e,
+}; /* CR_Nl */
+
+/* 'No': General Category */
+static const OnigCodePoint CR_No[] = {
+ 60,
+ 0x00b2, 0x00b3,
+ 0x00b9, 0x00b9,
+ 0x00bc, 0x00be,
+ 0x09f4, 0x09f9,
+ 0x0b72, 0x0b77,
+ 0x0bf0, 0x0bf2,
+ 0x0c78, 0x0c7e,
+ 0x0d58, 0x0d5e,
+ 0x0d70, 0x0d78,
+ 0x0f2a, 0x0f33,
+ 0x1369, 0x137c,
+ 0x17f0, 0x17f9,
+ 0x19da, 0x19da,
+ 0x2070, 0x2070,
+ 0x2074, 0x2079,
+ 0x2080, 0x2089,
+ 0x2150, 0x215f,
+ 0x2189, 0x2189,
+ 0x2460, 0x249b,
+ 0x24ea, 0x24ff,
+ 0x2776, 0x2793,
+ 0x2cfd, 0x2cfd,
+ 0x3192, 0x3195,
+ 0x3220, 0x3229,
+ 0x3248, 0x324f,
+ 0x3251, 0x325f,
+ 0x3280, 0x3289,
+ 0x32b1, 0x32bf,
+ 0xa830, 0xa835,
+ 0x10107, 0x10133,
+ 0x10175, 0x10178,
+ 0x1018a, 0x1018b,
+ 0x102e1, 0x102fb,
+ 0x10320, 0x10323,
+ 0x10858, 0x1085f,
+ 0x10879, 0x1087f,
+ 0x108a7, 0x108af,
+ 0x108fb, 0x108ff,
+ 0x10916, 0x1091b,
+ 0x109bc, 0x109bd,
+ 0x109c0, 0x109cf,
+ 0x109d2, 0x109ff,
+ 0x10a40, 0x10a47,
+ 0x10a7d, 0x10a7e,
+ 0x10a9d, 0x10a9f,
+ 0x10aeb, 0x10aef,
+ 0x10b58, 0x10b5f,
+ 0x10b78, 0x10b7f,
+ 0x10ba9, 0x10baf,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11052, 0x11065,
+ 0x111e1, 0x111f4,
+ 0x1173a, 0x1173b,
+ 0x118ea, 0x118f2,
+ 0x11c5a, 0x11c6c,
+ 0x16b5b, 0x16b61,
+ 0x1d360, 0x1d371,
+ 0x1e8c7, 0x1e8cf,
+ 0x1f100, 0x1f10c,
+}; /* CR_No */
+
+/* 'P': Major Category */
+#define CR_P CR_Punct
+
+/* 'Pc': General Category */
+static const OnigCodePoint CR_Pc[] = {
+ 6,
+ 0x005f, 0x005f,
+ 0x203f, 0x2040,
+ 0x2054, 0x2054,
+ 0xfe33, 0xfe34,
+ 0xfe4d, 0xfe4f,
+ 0xff3f, 0xff3f,
+}; /* CR_Pc */
+
+/* 'Pd': General Category */
+static const OnigCodePoint CR_Pd[] = {
+ 17,
+ 0x002d, 0x002d,
+ 0x058a, 0x058a,
+ 0x05be, 0x05be,
+ 0x1400, 0x1400,
+ 0x1806, 0x1806,
+ 0x2010, 0x2015,
+ 0x2e17, 0x2e17,
+ 0x2e1a, 0x2e1a,
+ 0x2e3a, 0x2e3b,
+ 0x2e40, 0x2e40,
+ 0x301c, 0x301c,
+ 0x3030, 0x3030,
+ 0x30a0, 0x30a0,
+ 0xfe31, 0xfe32,
+ 0xfe58, 0xfe58,
+ 0xfe63, 0xfe63,
+ 0xff0d, 0xff0d,
+}; /* CR_Pd */
+
+/* 'Pe': General Category */
+static const OnigCodePoint CR_Pe[] = {
+ 72,
+ 0x0029, 0x0029,
+ 0x005d, 0x005d,
+ 0x007d, 0x007d,
+ 0x0f3b, 0x0f3b,
+ 0x0f3d, 0x0f3d,
+ 0x169c, 0x169c,
+ 0x2046, 0x2046,
+ 0x207e, 0x207e,
+ 0x208e, 0x208e,
+ 0x2309, 0x2309,
+ 0x230b, 0x230b,
+ 0x232a, 0x232a,
+ 0x2769, 0x2769,
+ 0x276b, 0x276b,
+ 0x276d, 0x276d,
+ 0x276f, 0x276f,
+ 0x2771, 0x2771,
+ 0x2773, 0x2773,
+ 0x2775, 0x2775,
+ 0x27c6, 0x27c6,
+ 0x27e7, 0x27e7,
+ 0x27e9, 0x27e9,
+ 0x27eb, 0x27eb,
+ 0x27ed, 0x27ed,
+ 0x27ef, 0x27ef,
+ 0x2984, 0x2984,
+ 0x2986, 0x2986,
+ 0x2988, 0x2988,
+ 0x298a, 0x298a,
+ 0x298c, 0x298c,
+ 0x298e, 0x298e,
+ 0x2990, 0x2990,
+ 0x2992, 0x2992,
+ 0x2994, 0x2994,
+ 0x2996, 0x2996,
+ 0x2998, 0x2998,
+ 0x29d9, 0x29d9,
+ 0x29db, 0x29db,
+ 0x29fd, 0x29fd,
+ 0x2e23, 0x2e23,
+ 0x2e25, 0x2e25,
+ 0x2e27, 0x2e27,
+ 0x2e29, 0x2e29,
+ 0x3009, 0x3009,
+ 0x300b, 0x300b,
+ 0x300d, 0x300d,
+ 0x300f, 0x300f,
+ 0x3011, 0x3011,
+ 0x3015, 0x3015,
+ 0x3017, 0x3017,
+ 0x3019, 0x3019,
+ 0x301b, 0x301b,
+ 0x301e, 0x301f,
+ 0xfd3e, 0xfd3e,
+ 0xfe18, 0xfe18,
+ 0xfe36, 0xfe36,
+ 0xfe38, 0xfe38,
+ 0xfe3a, 0xfe3a,
+ 0xfe3c, 0xfe3c,
+ 0xfe3e, 0xfe3e,
+ 0xfe40, 0xfe40,
+ 0xfe42, 0xfe42,
+ 0xfe44, 0xfe44,
+ 0xfe48, 0xfe48,
+ 0xfe5a, 0xfe5a,
+ 0xfe5c, 0xfe5c,
+ 0xfe5e, 0xfe5e,
+ 0xff09, 0xff09,
+ 0xff3d, 0xff3d,
+ 0xff5d, 0xff5d,
+ 0xff60, 0xff60,
+ 0xff63, 0xff63,
+}; /* CR_Pe */
+
+/* 'Pf': General Category */
+static const OnigCodePoint CR_Pf[] = {
+ 10,
+ 0x00bb, 0x00bb,
+ 0x2019, 0x2019,
+ 0x201d, 0x201d,
+ 0x203a, 0x203a,
+ 0x2e03, 0x2e03,
+ 0x2e05, 0x2e05,
+ 0x2e0a, 0x2e0a,
+ 0x2e0d, 0x2e0d,
+ 0x2e1d, 0x2e1d,
+ 0x2e21, 0x2e21,
+}; /* CR_Pf */
+
+/* 'Pi': General Category */
+static const OnigCodePoint CR_Pi[] = {
+ 11,
+ 0x00ab, 0x00ab,
+ 0x2018, 0x2018,
+ 0x201b, 0x201c,
+ 0x201f, 0x201f,
+ 0x2039, 0x2039,
+ 0x2e02, 0x2e02,
+ 0x2e04, 0x2e04,
+ 0x2e09, 0x2e09,
+ 0x2e0c, 0x2e0c,
+ 0x2e1c, 0x2e1c,
+ 0x2e20, 0x2e20,
+}; /* CR_Pi */
+
+/* 'Po': General Category */
+static const OnigCodePoint CR_Po[] = {
+ 169,
+ 0x0021, 0x0023,
+ 0x0025, 0x0027,
+ 0x002a, 0x002a,
+ 0x002c, 0x002c,
+ 0x002e, 0x002f,
+ 0x003a, 0x003b,
+ 0x003f, 0x0040,
+ 0x005c, 0x005c,
+ 0x00a1, 0x00a1,
+ 0x00a7, 0x00a7,
+ 0x00b6, 0x00b7,
+ 0x00bf, 0x00bf,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x055a, 0x055f,
+ 0x0589, 0x0589,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05f3, 0x05f4,
+ 0x0609, 0x060a,
+ 0x060c, 0x060d,
+ 0x061b, 0x061b,
+ 0x061e, 0x061f,
+ 0x066a, 0x066d,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070d,
+ 0x07f7, 0x07f9,
+ 0x0830, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0970, 0x0970,
+ 0x09fd, 0x09fd,
+ 0x0af0, 0x0af0,
+ 0x0df4, 0x0df4,
+ 0x0e4f, 0x0e4f,
+ 0x0e5a, 0x0e5b,
+ 0x0f04, 0x0f12,
+ 0x0f14, 0x0f14,
+ 0x0f85, 0x0f85,
+ 0x0fd0, 0x0fd4,
+ 0x0fd9, 0x0fda,
+ 0x104a, 0x104f,
+ 0x10fb, 0x10fb,
+ 0x1360, 0x1368,
+ 0x166d, 0x166e,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17d8, 0x17da,
+ 0x1800, 0x1805,
+ 0x1807, 0x180a,
+ 0x1944, 0x1945,
+ 0x1a1e, 0x1a1f,
+ 0x1aa0, 0x1aa6,
+ 0x1aa8, 0x1aad,
+ 0x1b5a, 0x1b60,
+ 0x1bfc, 0x1bff,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x2016, 0x2017,
+ 0x2020, 0x2027,
+ 0x2030, 0x2038,
+ 0x203b, 0x203e,
+ 0x2041, 0x2043,
+ 0x2047, 0x2051,
+ 0x2053, 0x2053,
+ 0x2055, 0x205e,
+ 0x2cf9, 0x2cfc,
+ 0x2cfe, 0x2cff,
+ 0x2d70, 0x2d70,
+ 0x2e00, 0x2e01,
+ 0x2e06, 0x2e08,
+ 0x2e0b, 0x2e0b,
+ 0x2e0e, 0x2e16,
+ 0x2e18, 0x2e19,
+ 0x2e1b, 0x2e1b,
+ 0x2e1e, 0x2e1f,
+ 0x2e2a, 0x2e2e,
+ 0x2e30, 0x2e39,
+ 0x2e3c, 0x2e3f,
+ 0x2e41, 0x2e41,
+ 0x2e43, 0x2e49,
+ 0x3001, 0x3003,
+ 0x303d, 0x303d,
+ 0x30fb, 0x30fb,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa67e,
+ 0xa6f2, 0xa6f7,
+ 0xa874, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa8f8, 0xa8fa,
+ 0xa8fc, 0xa8fc,
+ 0xa92e, 0xa92f,
+ 0xa95f, 0xa95f,
+ 0xa9c1, 0xa9cd,
+ 0xa9de, 0xa9df,
+ 0xaa5c, 0xaa5f,
+ 0xaade, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 0xfe10, 0xfe16,
+ 0xfe19, 0xfe19,
+ 0xfe30, 0xfe30,
+ 0xfe45, 0xfe46,
+ 0xfe49, 0xfe4c,
+ 0xfe50, 0xfe52,
+ 0xfe54, 0xfe57,
+ 0xfe5f, 0xfe61,
+ 0xfe68, 0xfe68,
+ 0xfe6a, 0xfe6b,
+ 0xff01, 0xff03,
+ 0xff05, 0xff07,
+ 0xff0a, 0xff0a,
+ 0xff0c, 0xff0c,
+ 0xff0e, 0xff0f,
+ 0xff1a, 0xff1b,
+ 0xff1f, 0xff20,
+ 0xff3c, 0xff3c,
+ 0xff61, 0xff61,
+ 0xff64, 0xff65,
+ 0x10100, 0x10102,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x1056f, 0x1056f,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x1093f, 0x1093f,
+ 0x10a50, 0x10a58,
+ 0x10a7f, 0x10a7f,
+ 0x10af0, 0x10af6,
+ 0x10b39, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x11047, 0x1104d,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x11140, 0x11143,
+ 0x11174, 0x11175,
+ 0x111c5, 0x111c9,
+ 0x111cd, 0x111cd,
+ 0x111db, 0x111db,
+ 0x111dd, 0x111df,
+ 0x11238, 0x1123d,
+ 0x112a9, 0x112a9,
+ 0x1144b, 0x1144f,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x114c6, 0x114c6,
+ 0x115c1, 0x115d7,
+ 0x11641, 0x11643,
+ 0x11660, 0x1166c,
+ 0x1173c, 0x1173e,
+ 0x11a3f, 0x11a46,
+ 0x11a9a, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11c41, 0x11c45,
+ 0x11c70, 0x11c71,
+ 0x12470, 0x12474,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b3b,
+ 0x16b44, 0x16b44,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8b,
+ 0x1e95e, 0x1e95f,
+}; /* CR_Po */
+
+/* 'Ps': General Category */
+static const OnigCodePoint CR_Ps[] = {
+ 75,
+ 0x0028, 0x0028,
+ 0x005b, 0x005b,
+ 0x007b, 0x007b,
+ 0x0f3a, 0x0f3a,
+ 0x0f3c, 0x0f3c,
+ 0x169b, 0x169b,
+ 0x201a, 0x201a,
+ 0x201e, 0x201e,
+ 0x2045, 0x2045,
+ 0x207d, 0x207d,
+ 0x208d, 0x208d,
+ 0x2308, 0x2308,
+ 0x230a, 0x230a,
+ 0x2329, 0x2329,
+ 0x2768, 0x2768,
+ 0x276a, 0x276a,
+ 0x276c, 0x276c,
+ 0x276e, 0x276e,
+ 0x2770, 0x2770,
+ 0x2772, 0x2772,
+ 0x2774, 0x2774,
+ 0x27c5, 0x27c5,
+ 0x27e6, 0x27e6,
+ 0x27e8, 0x27e8,
+ 0x27ea, 0x27ea,
+ 0x27ec, 0x27ec,
+ 0x27ee, 0x27ee,
+ 0x2983, 0x2983,
+ 0x2985, 0x2985,
+ 0x2987, 0x2987,
+ 0x2989, 0x2989,
+ 0x298b, 0x298b,
+ 0x298d, 0x298d,
+ 0x298f, 0x298f,
+ 0x2991, 0x2991,
+ 0x2993, 0x2993,
+ 0x2995, 0x2995,
+ 0x2997, 0x2997,
+ 0x29d8, 0x29d8,
+ 0x29da, 0x29da,
+ 0x29fc, 0x29fc,
+ 0x2e22, 0x2e22,
+ 0x2e24, 0x2e24,
+ 0x2e26, 0x2e26,
+ 0x2e28, 0x2e28,
+ 0x2e42, 0x2e42,
+ 0x3008, 0x3008,
+ 0x300a, 0x300a,
+ 0x300c, 0x300c,
+ 0x300e, 0x300e,
+ 0x3010, 0x3010,
+ 0x3014, 0x3014,
+ 0x3016, 0x3016,
+ 0x3018, 0x3018,
+ 0x301a, 0x301a,
+ 0x301d, 0x301d,
+ 0xfd3f, 0xfd3f,
+ 0xfe17, 0xfe17,
+ 0xfe35, 0xfe35,
+ 0xfe37, 0xfe37,
+ 0xfe39, 0xfe39,
+ 0xfe3b, 0xfe3b,
+ 0xfe3d, 0xfe3d,
+ 0xfe3f, 0xfe3f,
+ 0xfe41, 0xfe41,
+ 0xfe43, 0xfe43,
+ 0xfe47, 0xfe47,
+ 0xfe59, 0xfe59,
+ 0xfe5b, 0xfe5b,
+ 0xfe5d, 0xfe5d,
+ 0xff08, 0xff08,
+ 0xff3b, 0xff3b,
+ 0xff5b, 0xff5b,
+ 0xff5f, 0xff5f,
+ 0xff62, 0xff62,
+}; /* CR_Ps */
+
+/* 'S': Major Category */
+static const OnigCodePoint CR_S[] = {
+ 217,
+ 0x0024, 0x0024,
+ 0x002b, 0x002b,
+ 0x003c, 0x003e,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x007c, 0x007c,
+ 0x007e, 0x007e,
+ 0x00a2, 0x00a6,
+ 0x00a8, 0x00a9,
+ 0x00ac, 0x00ac,
+ 0x00ae, 0x00b1,
+ 0x00b4, 0x00b4,
+ 0x00b8, 0x00b8,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x02c2, 0x02c5,
+ 0x02d2, 0x02df,
+ 0x02e5, 0x02eb,
+ 0x02ed, 0x02ed,
+ 0x02ef, 0x02ff,
+ 0x0375, 0x0375,
+ 0x0384, 0x0385,
+ 0x03f6, 0x03f6,
+ 0x0482, 0x0482,
+ 0x058d, 0x058f,
+ 0x0606, 0x0608,
+ 0x060b, 0x060b,
+ 0x060e, 0x060f,
+ 0x06de, 0x06de,
+ 0x06e9, 0x06e9,
+ 0x06fd, 0x06fe,
+ 0x07f6, 0x07f6,
+ 0x09f2, 0x09f3,
+ 0x09fa, 0x09fb,
+ 0x0af1, 0x0af1,
+ 0x0b70, 0x0b70,
+ 0x0bf3, 0x0bfa,
+ 0x0c7f, 0x0c7f,
+ 0x0d4f, 0x0d4f,
+ 0x0d79, 0x0d79,
+ 0x0e3f, 0x0e3f,
+ 0x0f01, 0x0f03,
+ 0x0f13, 0x0f13,
+ 0x0f15, 0x0f17,
+ 0x0f1a, 0x0f1f,
+ 0x0f34, 0x0f34,
+ 0x0f36, 0x0f36,
+ 0x0f38, 0x0f38,
+ 0x0fbe, 0x0fc5,
+ 0x0fc7, 0x0fcc,
+ 0x0fce, 0x0fcf,
+ 0x0fd5, 0x0fd8,
+ 0x109e, 0x109f,
+ 0x1390, 0x1399,
+ 0x17db, 0x17db,
+ 0x1940, 0x1940,
+ 0x19de, 0x19ff,
+ 0x1b61, 0x1b6a,
+ 0x1b74, 0x1b7c,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x2044, 0x2044,
+ 0x2052, 0x2052,
+ 0x207a, 0x207c,
+ 0x208a, 0x208c,
+ 0x20a0, 0x20bf,
+ 0x2100, 0x2101,
+ 0x2103, 0x2106,
+ 0x2108, 0x2109,
+ 0x2114, 0x2114,
+ 0x2116, 0x2118,
+ 0x211e, 0x2123,
+ 0x2125, 0x2125,
+ 0x2127, 0x2127,
+ 0x2129, 0x2129,
+ 0x212e, 0x212e,
+ 0x213a, 0x213b,
+ 0x2140, 0x2144,
+ 0x214a, 0x214d,
+ 0x214f, 0x214f,
+ 0x218a, 0x218b,
+ 0x2190, 0x2307,
+ 0x230c, 0x2328,
+ 0x232b, 0x2426,
+ 0x2440, 0x244a,
+ 0x249c, 0x24e9,
+ 0x2500, 0x2767,
+ 0x2794, 0x27c4,
+ 0x27c7, 0x27e5,
+ 0x27f0, 0x2982,
+ 0x2999, 0x29d7,
+ 0x29dc, 0x29fb,
+ 0x29fe, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2ce5, 0x2cea,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3004, 0x3004,
+ 0x3012, 0x3013,
+ 0x3020, 0x3020,
+ 0x3036, 0x3037,
+ 0x303e, 0x303f,
+ 0x309b, 0x309c,
+ 0x3190, 0x3191,
+ 0x3196, 0x319f,
+ 0x31c0, 0x31e3,
+ 0x3200, 0x321e,
+ 0x322a, 0x3247,
+ 0x3250, 0x3250,
+ 0x3260, 0x327f,
+ 0x328a, 0x32b0,
+ 0x32c0, 0x32fe,
+ 0x3300, 0x33ff,
+ 0x4dc0, 0x4dff,
+ 0xa490, 0xa4c6,
+ 0xa700, 0xa716,
+ 0xa720, 0xa721,
+ 0xa789, 0xa78a,
+ 0xa828, 0xa82b,
+ 0xa836, 0xa839,
+ 0xaa77, 0xaa79,
+ 0xab5b, 0xab5b,
+ 0xfb29, 0xfb29,
+ 0xfbb2, 0xfbc1,
+ 0xfdfc, 0xfdfd,
+ 0xfe62, 0xfe62,
+ 0xfe64, 0xfe66,
+ 0xfe69, 0xfe69,
+ 0xff04, 0xff04,
+ 0xff0b, 0xff0b,
+ 0xff1c, 0xff1e,
+ 0xff3e, 0xff3e,
+ 0xff40, 0xff40,
+ 0xff5c, 0xff5c,
+ 0xff5e, 0xff5e,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffc, 0xfffd,
+ 0x10137, 0x1013f,
+ 0x10179, 0x10189,
+ 0x1018c, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fc,
+ 0x10877, 0x10878,
+ 0x10ac8, 0x10ac8,
+ 0x1173f, 0x1173f,
+ 0x16b3c, 0x16b3f,
+ 0x16b45, 0x16b45,
+ 0x1bc9c, 0x1bc9c,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d164,
+ 0x1d16a, 0x1d16c,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1e8,
+ 0x1d200, 0x1d241,
+ 0x1d245, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d6c1, 0x1d6c1,
+ 0x1d6db, 0x1d6db,
+ 0x1d6fb, 0x1d6fb,
+ 0x1d715, 0x1d715,
+ 0x1d735, 0x1d735,
+ 0x1d74f, 0x1d74f,
+ 0x1d76f, 0x1d76f,
+ 0x1d789, 0x1d789,
+ 0x1d7a9, 0x1d7a9,
+ 0x1d7c3, 0x1d7c3,
+ 0x1d800, 0x1d9ff,
+ 0x1da37, 0x1da3a,
+ 0x1da6d, 0x1da74,
+ 0x1da76, 0x1da83,
+ 0x1da85, 0x1da86,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+}; /* CR_S */
+
+/* 'Sc': General Category */
+static const OnigCodePoint CR_Sc[] = {
+ 17,
+ 0x0024, 0x0024,
+ 0x00a2, 0x00a5,
+ 0x058f, 0x058f,
+ 0x060b, 0x060b,
+ 0x09f2, 0x09f3,
+ 0x09fb, 0x09fb,
+ 0x0af1, 0x0af1,
+ 0x0bf9, 0x0bf9,
+ 0x0e3f, 0x0e3f,
+ 0x17db, 0x17db,
+ 0x20a0, 0x20bf,
+ 0xa838, 0xa838,
+ 0xfdfc, 0xfdfc,
+ 0xfe69, 0xfe69,
+ 0xff04, 0xff04,
+ 0xffe0, 0xffe1,
+ 0xffe5, 0xffe6,
+}; /* CR_Sc */
+
+/* 'Sk': General Category */
+static const OnigCodePoint CR_Sk[] = {
+ 29,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x00a8, 0x00a8,
+ 0x00af, 0x00af,
+ 0x00b4, 0x00b4,
+ 0x00b8, 0x00b8,
+ 0x02c2, 0x02c5,
+ 0x02d2, 0x02df,
+ 0x02e5, 0x02eb,
+ 0x02ed, 0x02ed,
+ 0x02ef, 0x02ff,
+ 0x0375, 0x0375,
+ 0x0384, 0x0385,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x309b, 0x309c,
+ 0xa700, 0xa716,
+ 0xa720, 0xa721,
+ 0xa789, 0xa78a,
+ 0xab5b, 0xab5b,
+ 0xfbb2, 0xfbc1,
+ 0xff3e, 0xff3e,
+ 0xff40, 0xff40,
+ 0xffe3, 0xffe3,
+ 0x1f3fb, 0x1f3ff,
+}; /* CR_Sk */
+
+/* 'Sm': General Category */
+static const OnigCodePoint CR_Sm[] = {
+ 64,
+ 0x002b, 0x002b,
+ 0x003c, 0x003e,
+ 0x007c, 0x007c,
+ 0x007e, 0x007e,
+ 0x00ac, 0x00ac,
+ 0x00b1, 0x00b1,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x03f6, 0x03f6,
+ 0x0606, 0x0608,
+ 0x2044, 0x2044,
+ 0x2052, 0x2052,
+ 0x207a, 0x207c,
+ 0x208a, 0x208c,
+ 0x2118, 0x2118,
+ 0x2140, 0x2144,
+ 0x214b, 0x214b,
+ 0x2190, 0x2194,
+ 0x219a, 0x219b,
+ 0x21a0, 0x21a0,
+ 0x21a3, 0x21a3,
+ 0x21a6, 0x21a6,
+ 0x21ae, 0x21ae,
+ 0x21ce, 0x21cf,
+ 0x21d2, 0x21d2,
+ 0x21d4, 0x21d4,
+ 0x21f4, 0x22ff,
+ 0x2320, 0x2321,
+ 0x237c, 0x237c,
+ 0x239b, 0x23b3,
+ 0x23dc, 0x23e1,
+ 0x25b7, 0x25b7,
+ 0x25c1, 0x25c1,
+ 0x25f8, 0x25ff,
+ 0x266f, 0x266f,
+ 0x27c0, 0x27c4,
+ 0x27c7, 0x27e5,
+ 0x27f0, 0x27ff,
+ 0x2900, 0x2982,
+ 0x2999, 0x29d7,
+ 0x29dc, 0x29fb,
+ 0x29fe, 0x2aff,
+ 0x2b30, 0x2b44,
+ 0x2b47, 0x2b4c,
+ 0xfb29, 0xfb29,
+ 0xfe62, 0xfe62,
+ 0xfe64, 0xfe66,
+ 0xff0b, 0xff0b,
+ 0xff1c, 0xff1e,
+ 0xff5c, 0xff5c,
+ 0xff5e, 0xff5e,
+ 0xffe2, 0xffe2,
+ 0xffe9, 0xffec,
+ 0x1d6c1, 0x1d6c1,
+ 0x1d6db, 0x1d6db,
+ 0x1d6fb, 0x1d6fb,
+ 0x1d715, 0x1d715,
+ 0x1d735, 0x1d735,
+ 0x1d74f, 0x1d74f,
+ 0x1d76f, 0x1d76f,
+ 0x1d789, 0x1d789,
+ 0x1d7a9, 0x1d7a9,
+ 0x1d7c3, 0x1d7c3,
+ 0x1eef0, 0x1eef1,
+}; /* CR_Sm */
+
+/* 'So': General Category */
+static const OnigCodePoint CR_So[] = {
+ 173,
+ 0x00a6, 0x00a6,
+ 0x00a9, 0x00a9,
+ 0x00ae, 0x00ae,
+ 0x00b0, 0x00b0,
+ 0x0482, 0x0482,
+ 0x058d, 0x058e,
+ 0x060e, 0x060f,
+ 0x06de, 0x06de,
+ 0x06e9, 0x06e9,
+ 0x06fd, 0x06fe,
+ 0x07f6, 0x07f6,
+ 0x09fa, 0x09fa,
+ 0x0b70, 0x0b70,
+ 0x0bf3, 0x0bf8,
+ 0x0bfa, 0x0bfa,
+ 0x0c7f, 0x0c7f,
+ 0x0d4f, 0x0d4f,
+ 0x0d79, 0x0d79,
+ 0x0f01, 0x0f03,
+ 0x0f13, 0x0f13,
+ 0x0f15, 0x0f17,
+ 0x0f1a, 0x0f1f,
+ 0x0f34, 0x0f34,
+ 0x0f36, 0x0f36,
+ 0x0f38, 0x0f38,
+ 0x0fbe, 0x0fc5,
+ 0x0fc7, 0x0fcc,
+ 0x0fce, 0x0fcf,
+ 0x0fd5, 0x0fd8,
+ 0x109e, 0x109f,
+ 0x1390, 0x1399,
+ 0x1940, 0x1940,
+ 0x19de, 0x19ff,
+ 0x1b61, 0x1b6a,
+ 0x1b74, 0x1b7c,
+ 0x2100, 0x2101,
+ 0x2103, 0x2106,
+ 0x2108, 0x2109,
+ 0x2114, 0x2114,
+ 0x2116, 0x2117,
+ 0x211e, 0x2123,
+ 0x2125, 0x2125,
+ 0x2127, 0x2127,
+ 0x2129, 0x2129,
+ 0x212e, 0x212e,
+ 0x213a, 0x213b,
+ 0x214a, 0x214a,
+ 0x214c, 0x214d,
+ 0x214f, 0x214f,
+ 0x218a, 0x218b,
+ 0x2195, 0x2199,
+ 0x219c, 0x219f,
+ 0x21a1, 0x21a2,
+ 0x21a4, 0x21a5,
+ 0x21a7, 0x21ad,
+ 0x21af, 0x21cd,
+ 0x21d0, 0x21d1,
+ 0x21d3, 0x21d3,
+ 0x21d5, 0x21f3,
+ 0x2300, 0x2307,
+ 0x230c, 0x231f,
+ 0x2322, 0x2328,
+ 0x232b, 0x237b,
+ 0x237d, 0x239a,
+ 0x23b4, 0x23db,
+ 0x23e2, 0x2426,
+ 0x2440, 0x244a,
+ 0x249c, 0x24e9,
+ 0x2500, 0x25b6,
+ 0x25b8, 0x25c0,
+ 0x25c2, 0x25f7,
+ 0x2600, 0x266e,
+ 0x2670, 0x2767,
+ 0x2794, 0x27bf,
+ 0x2800, 0x28ff,
+ 0x2b00, 0x2b2f,
+ 0x2b45, 0x2b46,
+ 0x2b4d, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2ce5, 0x2cea,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3004, 0x3004,
+ 0x3012, 0x3013,
+ 0x3020, 0x3020,
+ 0x3036, 0x3037,
+ 0x303e, 0x303f,
+ 0x3190, 0x3191,
+ 0x3196, 0x319f,
+ 0x31c0, 0x31e3,
+ 0x3200, 0x321e,
+ 0x322a, 0x3247,
+ 0x3250, 0x3250,
+ 0x3260, 0x327f,
+ 0x328a, 0x32b0,
+ 0x32c0, 0x32fe,
+ 0x3300, 0x33ff,
+ 0x4dc0, 0x4dff,
+ 0xa490, 0xa4c6,
+ 0xa828, 0xa82b,
+ 0xa836, 0xa837,
+ 0xa839, 0xa839,
+ 0xaa77, 0xaa79,
+ 0xfdfd, 0xfdfd,
+ 0xffe4, 0xffe4,
+ 0xffe8, 0xffe8,
+ 0xffed, 0xffee,
+ 0xfffc, 0xfffd,
+ 0x10137, 0x1013f,
+ 0x10179, 0x10189,
+ 0x1018c, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fc,
+ 0x10877, 0x10878,
+ 0x10ac8, 0x10ac8,
+ 0x1173f, 0x1173f,
+ 0x16b3c, 0x16b3f,
+ 0x16b45, 0x16b45,
+ 0x1bc9c, 0x1bc9c,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d164,
+ 0x1d16a, 0x1d16c,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1e8,
+ 0x1d200, 0x1d241,
+ 0x1d245, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d800, 0x1d9ff,
+ 0x1da37, 0x1da3a,
+ 0x1da6d, 0x1da74,
+ 0x1da76, 0x1da83,
+ 0x1da85, 0x1da86,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f3fa,
+ 0x1f400, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+}; /* CR_So */
+
+/* 'Z': Major Category */
+static const OnigCodePoint CR_Z[] = {
+ 8,
+ 0x0020, 0x0020,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 0x2000, 0x200a,
+ 0x2028, 0x2029,
+ 0x202f, 0x202f,
+ 0x205f, 0x205f,
+ 0x3000, 0x3000,
+}; /* CR_Z */
+
+/* 'Zl': General Category */
+static const OnigCodePoint CR_Zl[] = {
+ 1,
+ 0x2028, 0x2028,
+}; /* CR_Zl */
+
+/* 'Zp': General Category */
+static const OnigCodePoint CR_Zp[] = {
+ 1,
+ 0x2029, 0x2029,
+}; /* CR_Zp */
+
+/* 'Zs': General Category */
+static const OnigCodePoint CR_Zs[] = {
+ 7,
+ 0x0020, 0x0020,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 0x2000, 0x200a,
+ 0x202f, 0x202f,
+ 0x205f, 0x205f,
+ 0x3000, 0x3000,
+}; /* CR_Zs */
+
+/* 'Math': Derived Property */
+static const OnigCodePoint CR_Math[] = {
+ 138,
+ 0x002b, 0x002b,
+ 0x003c, 0x003e,
+ 0x005e, 0x005e,
+ 0x007c, 0x007c,
+ 0x007e, 0x007e,
+ 0x00ac, 0x00ac,
+ 0x00b1, 0x00b1,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x03d0, 0x03d2,
+ 0x03d5, 0x03d5,
+ 0x03f0, 0x03f1,
+ 0x03f4, 0x03f6,
+ 0x0606, 0x0608,
+ 0x2016, 0x2016,
+ 0x2032, 0x2034,
+ 0x2040, 0x2040,
+ 0x2044, 0x2044,
+ 0x2052, 0x2052,
+ 0x2061, 0x2064,
+ 0x207a, 0x207e,
+ 0x208a, 0x208e,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20e6,
+ 0x20eb, 0x20ef,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2128, 0x2129,
+ 0x212c, 0x212d,
+ 0x212f, 0x2131,
+ 0x2133, 0x2138,
+ 0x213c, 0x2149,
+ 0x214b, 0x214b,
+ 0x2190, 0x21a7,
+ 0x21a9, 0x21ae,
+ 0x21b0, 0x21b1,
+ 0x21b6, 0x21b7,
+ 0x21bc, 0x21db,
+ 0x21dd, 0x21dd,
+ 0x21e4, 0x21e5,
+ 0x21f4, 0x22ff,
+ 0x2308, 0x230b,
+ 0x2320, 0x2321,
+ 0x237c, 0x237c,
+ 0x239b, 0x23b5,
+ 0x23b7, 0x23b7,
+ 0x23d0, 0x23d0,
+ 0x23dc, 0x23e2,
+ 0x25a0, 0x25a1,
+ 0x25ae, 0x25b7,
+ 0x25bc, 0x25c1,
+ 0x25c6, 0x25c7,
+ 0x25ca, 0x25cb,
+ 0x25cf, 0x25d3,
+ 0x25e2, 0x25e2,
+ 0x25e4, 0x25e4,
+ 0x25e7, 0x25ec,
+ 0x25f8, 0x25ff,
+ 0x2605, 0x2606,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2660, 0x2663,
+ 0x266d, 0x266f,
+ 0x27c0, 0x27ff,
+ 0x2900, 0x2aff,
+ 0x2b30, 0x2b44,
+ 0x2b47, 0x2b4c,
+ 0xfb29, 0xfb29,
+ 0xfe61, 0xfe66,
+ 0xfe68, 0xfe68,
+ 0xff0b, 0xff0b,
+ 0xff1c, 0xff1e,
+ 0xff3c, 0xff3c,
+ 0xff3e, 0xff3e,
+ 0xff5c, 0xff5c,
+ 0xff5e, 0xff5e,
+ 0xffe2, 0xffe2,
+ 0xffe9, 0xffec,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+}; /* CR_Math */
+
+/* 'Alphabetic': Derived Property */
+#define CR_Alphabetic CR_Alpha
+
+/* 'Lowercase': Derived Property */
+#define CR_Lowercase CR_Lower
+
+/* 'Uppercase': Derived Property */
+#define CR_Uppercase CR_Upper
+
+/* 'Cased': Derived Property */
+static const OnigCodePoint CR_Cased[] = {
+ 135,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x01ba,
+ 0x01bc, 0x01bf,
+ 0x01c4, 0x0293,
+ 0x0295, 0x02b8,
+ 0x02c0, 0x02c1,
+ 0x02e0, 0x02e4,
+ 0x0345, 0x0345,
+ 0x0370, 0x0373,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0561, 0x0587,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x217f,
+ 0x2183, 0x2184,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa640, 0xa66d,
+ 0xa680, 0xa69d,
+ 0xa722, 0xa787,
+ 0xa78b, 0xa78e,
+ 0xa790, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f8, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0x10400, 0x1044f,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x118a0, 0x118df,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1e900, 0x1e943,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* CR_Cased */
+
+/* 'Case_Ignorable': Derived Property */
+static const OnigCodePoint CR_Case_Ignorable[] = {
+ 381,
+ 0x0027, 0x0027,
+ 0x002e, 0x002e,
+ 0x003a, 0x003a,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x00a8, 0x00a8,
+ 0x00ad, 0x00ad,
+ 0x00af, 0x00af,
+ 0x00b4, 0x00b4,
+ 0x00b7, 0x00b8,
+ 0x02b0, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x0384, 0x0385,
+ 0x0387, 0x0387,
+ 0x0483, 0x0489,
+ 0x0559, 0x0559,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05f4, 0x05f4,
+ 0x0600, 0x0605,
+ 0x0610, 0x061a,
+ 0x061c, 0x061c,
+ 0x0640, 0x0640,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dd,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x070f, 0x070f,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0816, 0x082d,
+ 0x0859, 0x085b,
+ 0x08d4, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x094d, 0x094d,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0971, 0x0971,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09c1, 0x09c4,
+ 0x09cd, 0x09cd,
+ 0x09e2, 0x09e3,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0acd, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3f, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b4d, 0x0b4d,
+ 0x0b56, 0x0b56,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0c00, 0x0c00,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cbf,
+ 0x0cc6, 0x0cc6,
+ 0x0ccc, 0x0ccd,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d41, 0x0d44,
+ 0x0d4d, 0x0d4d,
+ 0x0d62, 0x0d63,
+ 0x0dca, 0x0dca,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e46, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0eb9,
+ 0x0ebb, 0x0ebc,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x1039, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x10fc, 0x10fc,
+ 0x135d, 0x135f,
+ 0x1712, 0x1714,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180e,
+ 0x1843, 0x1843,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a60, 0x1a60,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b34,
+ 0x1b36, 0x1b3a,
+ 0x1b3c, 0x1b3c,
+ 0x1b42, 0x1b42,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1ba9,
+ 0x1bab, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf1,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1c78, 0x1c7d,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1d2c, 0x1d6a,
+ 0x1d78, 0x1d78,
+ 0x1d9b, 0x1df9,
+ 0x1dfb, 0x1dff,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x200b, 0x200f,
+ 0x2018, 0x2019,
+ 0x2024, 0x2024,
+ 0x2027, 0x2027,
+ 0x202a, 0x202e,
+ 0x2060, 0x2064,
+ 0x2066, 0x206f,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20f0,
+ 0x2c7c, 0x2c7d,
+ 0x2cef, 0x2cf1,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3005,
+ 0x302a, 0x302d,
+ 0x3031, 0x3035,
+ 0x303b, 0x303b,
+ 0x3099, 0x309e,
+ 0x30fc, 0x30fe,
+ 0xa015, 0xa015,
+ 0xa4f8, 0xa4fd,
+ 0xa60c, 0xa60c,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa67f,
+ 0xa69c, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa700, 0xa721,
+ 0xa770, 0xa770,
+ 0xa788, 0xa78a,
+ 0xa7f8, 0xa7f9,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bc,
+ 0xa9cf, 0xa9cf,
+ 0xa9e5, 0xa9e6,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa70, 0xaa70,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaadd, 0xaadd,
+ 0xaaec, 0xaaed,
+ 0xaaf3, 0xaaf4,
+ 0xaaf6, 0xaaf6,
+ 0xab5b, 0xab5f,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfbb2, 0xfbc1,
+ 0xfe00, 0xfe0f,
+ 0xfe13, 0xfe13,
+ 0xfe20, 0xfe2f,
+ 0xfe52, 0xfe52,
+ 0xfe55, 0xfe55,
+ 0xfeff, 0xfeff,
+ 0xff07, 0xff07,
+ 0xff0e, 0xff0e,
+ 0xff1a, 0xff1a,
+ 0xff3e, 0xff3e,
+ 0xff40, 0xff40,
+ 0xff70, 0xff70,
+ 0xff9e, 0xff9f,
+ 0xffe3, 0xffe3,
+ 0xfff9, 0xfffb,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x110bd, 0x110bd,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111ca, 0x111cc,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11234,
+ 0x11236, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133c, 0x1133c,
+ 0x11340, 0x11340,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b5,
+ 0x116b7, 0x116b7,
+ 0x1171d, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x11a01, 0x11a06,
+ 0x11a09, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a99,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x1bc9d, 0x1bc9e,
+ 0x1bca0, 0x1bca3,
+ 0x1d167, 0x1d169,
+ 0x1d173, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0x1f3fb, 0x1f3ff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+}; /* CR_Case_Ignorable */
+
+/* 'Changes_When_Lowercased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Lowercased[] = {
+ 590,
+ 0x0041, 0x005a,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00de,
+ 0x0100, 0x0100,
+ 0x0102, 0x0102,
+ 0x0104, 0x0104,
+ 0x0106, 0x0106,
+ 0x0108, 0x0108,
+ 0x010a, 0x010a,
+ 0x010c, 0x010c,
+ 0x010e, 0x010e,
+ 0x0110, 0x0110,
+ 0x0112, 0x0112,
+ 0x0114, 0x0114,
+ 0x0116, 0x0116,
+ 0x0118, 0x0118,
+ 0x011a, 0x011a,
+ 0x011c, 0x011c,
+ 0x011e, 0x011e,
+ 0x0120, 0x0120,
+ 0x0122, 0x0122,
+ 0x0124, 0x0124,
+ 0x0126, 0x0126,
+ 0x0128, 0x0128,
+ 0x012a, 0x012a,
+ 0x012c, 0x012c,
+ 0x012e, 0x012e,
+ 0x0130, 0x0130,
+ 0x0132, 0x0132,
+ 0x0134, 0x0134,
+ 0x0136, 0x0136,
+ 0x0139, 0x0139,
+ 0x013b, 0x013b,
+ 0x013d, 0x013d,
+ 0x013f, 0x013f,
+ 0x0141, 0x0141,
+ 0x0143, 0x0143,
+ 0x0145, 0x0145,
+ 0x0147, 0x0147,
+ 0x014a, 0x014a,
+ 0x014c, 0x014c,
+ 0x014e, 0x014e,
+ 0x0150, 0x0150,
+ 0x0152, 0x0152,
+ 0x0154, 0x0154,
+ 0x0156, 0x0156,
+ 0x0158, 0x0158,
+ 0x015a, 0x015a,
+ 0x015c, 0x015c,
+ 0x015e, 0x015e,
+ 0x0160, 0x0160,
+ 0x0162, 0x0162,
+ 0x0164, 0x0164,
+ 0x0166, 0x0166,
+ 0x0168, 0x0168,
+ 0x016a, 0x016a,
+ 0x016c, 0x016c,
+ 0x016e, 0x016e,
+ 0x0170, 0x0170,
+ 0x0172, 0x0172,
+ 0x0174, 0x0174,
+ 0x0176, 0x0176,
+ 0x0178, 0x0179,
+ 0x017b, 0x017b,
+ 0x017d, 0x017d,
+ 0x0181, 0x0182,
+ 0x0184, 0x0184,
+ 0x0186, 0x0187,
+ 0x0189, 0x018b,
+ 0x018e, 0x0191,
+ 0x0193, 0x0194,
+ 0x0196, 0x0198,
+ 0x019c, 0x019d,
+ 0x019f, 0x01a0,
+ 0x01a2, 0x01a2,
+ 0x01a4, 0x01a4,
+ 0x01a6, 0x01a7,
+ 0x01a9, 0x01a9,
+ 0x01ac, 0x01ac,
+ 0x01ae, 0x01af,
+ 0x01b1, 0x01b3,
+ 0x01b5, 0x01b5,
+ 0x01b7, 0x01b8,
+ 0x01bc, 0x01bc,
+ 0x01c4, 0x01c5,
+ 0x01c7, 0x01c8,
+ 0x01ca, 0x01cb,
+ 0x01cd, 0x01cd,
+ 0x01cf, 0x01cf,
+ 0x01d1, 0x01d1,
+ 0x01d3, 0x01d3,
+ 0x01d5, 0x01d5,
+ 0x01d7, 0x01d7,
+ 0x01d9, 0x01d9,
+ 0x01db, 0x01db,
+ 0x01de, 0x01de,
+ 0x01e0, 0x01e0,
+ 0x01e2, 0x01e2,
+ 0x01e4, 0x01e4,
+ 0x01e6, 0x01e6,
+ 0x01e8, 0x01e8,
+ 0x01ea, 0x01ea,
+ 0x01ec, 0x01ec,
+ 0x01ee, 0x01ee,
+ 0x01f1, 0x01f2,
+ 0x01f4, 0x01f4,
+ 0x01f6, 0x01f8,
+ 0x01fa, 0x01fa,
+ 0x01fc, 0x01fc,
+ 0x01fe, 0x01fe,
+ 0x0200, 0x0200,
+ 0x0202, 0x0202,
+ 0x0204, 0x0204,
+ 0x0206, 0x0206,
+ 0x0208, 0x0208,
+ 0x020a, 0x020a,
+ 0x020c, 0x020c,
+ 0x020e, 0x020e,
+ 0x0210, 0x0210,
+ 0x0212, 0x0212,
+ 0x0214, 0x0214,
+ 0x0216, 0x0216,
+ 0x0218, 0x0218,
+ 0x021a, 0x021a,
+ 0x021c, 0x021c,
+ 0x021e, 0x021e,
+ 0x0220, 0x0220,
+ 0x0222, 0x0222,
+ 0x0224, 0x0224,
+ 0x0226, 0x0226,
+ 0x0228, 0x0228,
+ 0x022a, 0x022a,
+ 0x022c, 0x022c,
+ 0x022e, 0x022e,
+ 0x0230, 0x0230,
+ 0x0232, 0x0232,
+ 0x023a, 0x023b,
+ 0x023d, 0x023e,
+ 0x0241, 0x0241,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03cf, 0x03cf,
+ 0x03d8, 0x03d8,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03e2,
+ 0x03e4, 0x03e4,
+ 0x03e6, 0x03e6,
+ 0x03e8, 0x03e8,
+ 0x03ea, 0x03ea,
+ 0x03ec, 0x03ec,
+ 0x03ee, 0x03ee,
+ 0x03f4, 0x03f4,
+ 0x03f7, 0x03f7,
+ 0x03f9, 0x03fa,
+ 0x03fd, 0x042f,
+ 0x0460, 0x0460,
+ 0x0462, 0x0462,
+ 0x0464, 0x0464,
+ 0x0466, 0x0466,
+ 0x0468, 0x0468,
+ 0x046a, 0x046a,
+ 0x046c, 0x046c,
+ 0x046e, 0x046e,
+ 0x0470, 0x0470,
+ 0x0472, 0x0472,
+ 0x0474, 0x0474,
+ 0x0476, 0x0476,
+ 0x0478, 0x0478,
+ 0x047a, 0x047a,
+ 0x047c, 0x047c,
+ 0x047e, 0x047e,
+ 0x0480, 0x0480,
+ 0x048a, 0x048a,
+ 0x048c, 0x048c,
+ 0x048e, 0x048e,
+ 0x0490, 0x0490,
+ 0x0492, 0x0492,
+ 0x0494, 0x0494,
+ 0x0496, 0x0496,
+ 0x0498, 0x0498,
+ 0x049a, 0x049a,
+ 0x049c, 0x049c,
+ 0x049e, 0x049e,
+ 0x04a0, 0x04a0,
+ 0x04a2, 0x04a2,
+ 0x04a4, 0x04a4,
+ 0x04a6, 0x04a6,
+ 0x04a8, 0x04a8,
+ 0x04aa, 0x04aa,
+ 0x04ac, 0x04ac,
+ 0x04ae, 0x04ae,
+ 0x04b0, 0x04b0,
+ 0x04b2, 0x04b2,
+ 0x04b4, 0x04b4,
+ 0x04b6, 0x04b6,
+ 0x04b8, 0x04b8,
+ 0x04ba, 0x04ba,
+ 0x04bc, 0x04bc,
+ 0x04be, 0x04be,
+ 0x04c0, 0x04c1,
+ 0x04c3, 0x04c3,
+ 0x04c5, 0x04c5,
+ 0x04c7, 0x04c7,
+ 0x04c9, 0x04c9,
+ 0x04cb, 0x04cb,
+ 0x04cd, 0x04cd,
+ 0x04d0, 0x04d0,
+ 0x04d2, 0x04d2,
+ 0x04d4, 0x04d4,
+ 0x04d6, 0x04d6,
+ 0x04d8, 0x04d8,
+ 0x04da, 0x04da,
+ 0x04dc, 0x04dc,
+ 0x04de, 0x04de,
+ 0x04e0, 0x04e0,
+ 0x04e2, 0x04e2,
+ 0x04e4, 0x04e4,
+ 0x04e6, 0x04e6,
+ 0x04e8, 0x04e8,
+ 0x04ea, 0x04ea,
+ 0x04ec, 0x04ec,
+ 0x04ee, 0x04ee,
+ 0x04f0, 0x04f0,
+ 0x04f2, 0x04f2,
+ 0x04f4, 0x04f4,
+ 0x04f6, 0x04f6,
+ 0x04f8, 0x04f8,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x1e00, 0x1e00,
+ 0x1e02, 0x1e02,
+ 0x1e04, 0x1e04,
+ 0x1e06, 0x1e06,
+ 0x1e08, 0x1e08,
+ 0x1e0a, 0x1e0a,
+ 0x1e0c, 0x1e0c,
+ 0x1e0e, 0x1e0e,
+ 0x1e10, 0x1e10,
+ 0x1e12, 0x1e12,
+ 0x1e14, 0x1e14,
+ 0x1e16, 0x1e16,
+ 0x1e18, 0x1e18,
+ 0x1e1a, 0x1e1a,
+ 0x1e1c, 0x1e1c,
+ 0x1e1e, 0x1e1e,
+ 0x1e20, 0x1e20,
+ 0x1e22, 0x1e22,
+ 0x1e24, 0x1e24,
+ 0x1e26, 0x1e26,
+ 0x1e28, 0x1e28,
+ 0x1e2a, 0x1e2a,
+ 0x1e2c, 0x1e2c,
+ 0x1e2e, 0x1e2e,
+ 0x1e30, 0x1e30,
+ 0x1e32, 0x1e32,
+ 0x1e34, 0x1e34,
+ 0x1e36, 0x1e36,
+ 0x1e38, 0x1e38,
+ 0x1e3a, 0x1e3a,
+ 0x1e3c, 0x1e3c,
+ 0x1e3e, 0x1e3e,
+ 0x1e40, 0x1e40,
+ 0x1e42, 0x1e42,
+ 0x1e44, 0x1e44,
+ 0x1e46, 0x1e46,
+ 0x1e48, 0x1e48,
+ 0x1e4a, 0x1e4a,
+ 0x1e4c, 0x1e4c,
+ 0x1e4e, 0x1e4e,
+ 0x1e50, 0x1e50,
+ 0x1e52, 0x1e52,
+ 0x1e54, 0x1e54,
+ 0x1e56, 0x1e56,
+ 0x1e58, 0x1e58,
+ 0x1e5a, 0x1e5a,
+ 0x1e5c, 0x1e5c,
+ 0x1e5e, 0x1e5e,
+ 0x1e60, 0x1e60,
+ 0x1e62, 0x1e62,
+ 0x1e64, 0x1e64,
+ 0x1e66, 0x1e66,
+ 0x1e68, 0x1e68,
+ 0x1e6a, 0x1e6a,
+ 0x1e6c, 0x1e6c,
+ 0x1e6e, 0x1e6e,
+ 0x1e70, 0x1e70,
+ 0x1e72, 0x1e72,
+ 0x1e74, 0x1e74,
+ 0x1e76, 0x1e76,
+ 0x1e78, 0x1e78,
+ 0x1e7a, 0x1e7a,
+ 0x1e7c, 0x1e7c,
+ 0x1e7e, 0x1e7e,
+ 0x1e80, 0x1e80,
+ 0x1e82, 0x1e82,
+ 0x1e84, 0x1e84,
+ 0x1e86, 0x1e86,
+ 0x1e88, 0x1e88,
+ 0x1e8a, 0x1e8a,
+ 0x1e8c, 0x1e8c,
+ 0x1e8e, 0x1e8e,
+ 0x1e90, 0x1e90,
+ 0x1e92, 0x1e92,
+ 0x1e94, 0x1e94,
+ 0x1e9e, 0x1e9e,
+ 0x1ea0, 0x1ea0,
+ 0x1ea2, 0x1ea2,
+ 0x1ea4, 0x1ea4,
+ 0x1ea6, 0x1ea6,
+ 0x1ea8, 0x1ea8,
+ 0x1eaa, 0x1eaa,
+ 0x1eac, 0x1eac,
+ 0x1eae, 0x1eae,
+ 0x1eb0, 0x1eb0,
+ 0x1eb2, 0x1eb2,
+ 0x1eb4, 0x1eb4,
+ 0x1eb6, 0x1eb6,
+ 0x1eb8, 0x1eb8,
+ 0x1eba, 0x1eba,
+ 0x1ebc, 0x1ebc,
+ 0x1ebe, 0x1ebe,
+ 0x1ec0, 0x1ec0,
+ 0x1ec2, 0x1ec2,
+ 0x1ec4, 0x1ec4,
+ 0x1ec6, 0x1ec6,
+ 0x1ec8, 0x1ec8,
+ 0x1eca, 0x1eca,
+ 0x1ecc, 0x1ecc,
+ 0x1ece, 0x1ece,
+ 0x1ed0, 0x1ed0,
+ 0x1ed2, 0x1ed2,
+ 0x1ed4, 0x1ed4,
+ 0x1ed6, 0x1ed6,
+ 0x1ed8, 0x1ed8,
+ 0x1eda, 0x1eda,
+ 0x1edc, 0x1edc,
+ 0x1ede, 0x1ede,
+ 0x1ee0, 0x1ee0,
+ 0x1ee2, 0x1ee2,
+ 0x1ee4, 0x1ee4,
+ 0x1ee6, 0x1ee6,
+ 0x1ee8, 0x1ee8,
+ 0x1eea, 0x1eea,
+ 0x1eec, 0x1eec,
+ 0x1eee, 0x1eee,
+ 0x1ef0, 0x1ef0,
+ 0x1ef2, 0x1ef2,
+ 0x1ef4, 0x1ef4,
+ 0x1ef6, 0x1ef6,
+ 0x1ef8, 0x1ef8,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 0x1f08, 0x1f0f,
+ 0x1f18, 0x1f1d,
+ 0x1f28, 0x1f2f,
+ 0x1f38, 0x1f3f,
+ 0x1f48, 0x1f4d,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f5f,
+ 0x1f68, 0x1f6f,
+ 0x1f88, 0x1f8f,
+ 0x1f98, 0x1f9f,
+ 0x1fa8, 0x1faf,
+ 0x1fb8, 0x1fbc,
+ 0x1fc8, 0x1fcc,
+ 0x1fd8, 0x1fdb,
+ 0x1fe8, 0x1fec,
+ 0x1ff8, 0x1ffc,
+ 0x2126, 0x2126,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x2160, 0x216f,
+ 0x2183, 0x2183,
+ 0x24b6, 0x24cf,
+ 0x2c00, 0x2c2e,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 0x2c80,
+ 0x2c82, 0x2c82,
+ 0x2c84, 0x2c84,
+ 0x2c86, 0x2c86,
+ 0x2c88, 0x2c88,
+ 0x2c8a, 0x2c8a,
+ 0x2c8c, 0x2c8c,
+ 0x2c8e, 0x2c8e,
+ 0x2c90, 0x2c90,
+ 0x2c92, 0x2c92,
+ 0x2c94, 0x2c94,
+ 0x2c96, 0x2c96,
+ 0x2c98, 0x2c98,
+ 0x2c9a, 0x2c9a,
+ 0x2c9c, 0x2c9c,
+ 0x2c9e, 0x2c9e,
+ 0x2ca0, 0x2ca0,
+ 0x2ca2, 0x2ca2,
+ 0x2ca4, 0x2ca4,
+ 0x2ca6, 0x2ca6,
+ 0x2ca8, 0x2ca8,
+ 0x2caa, 0x2caa,
+ 0x2cac, 0x2cac,
+ 0x2cae, 0x2cae,
+ 0x2cb0, 0x2cb0,
+ 0x2cb2, 0x2cb2,
+ 0x2cb4, 0x2cb4,
+ 0x2cb6, 0x2cb6,
+ 0x2cb8, 0x2cb8,
+ 0x2cba, 0x2cba,
+ 0x2cbc, 0x2cbc,
+ 0x2cbe, 0x2cbe,
+ 0x2cc0, 0x2cc0,
+ 0x2cc2, 0x2cc2,
+ 0x2cc4, 0x2cc4,
+ 0x2cc6, 0x2cc6,
+ 0x2cc8, 0x2cc8,
+ 0x2cca, 0x2cca,
+ 0x2ccc, 0x2ccc,
+ 0x2cce, 0x2cce,
+ 0x2cd0, 0x2cd0,
+ 0x2cd2, 0x2cd2,
+ 0x2cd4, 0x2cd4,
+ 0x2cd6, 0x2cd6,
+ 0x2cd8, 0x2cd8,
+ 0x2cda, 0x2cda,
+ 0x2cdc, 0x2cdc,
+ 0x2cde, 0x2cde,
+ 0x2ce0, 0x2ce0,
+ 0x2ce2, 0x2ce2,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10c80, 0x10cb2,
+ 0x118a0, 0x118bf,
+ 0x1e900, 0x1e921,
+}; /* CR_Changes_When_Lowercased */
+
+/* 'Changes_When_Uppercased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Uppercased[] = {
+ 607,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 0x00df, 0x00f6,
+ 0x00f8, 0x00ff,
+ 0x0101, 0x0101,
+ 0x0103, 0x0103,
+ 0x0105, 0x0105,
+ 0x0107, 0x0107,
+ 0x0109, 0x0109,
+ 0x010b, 0x010b,
+ 0x010d, 0x010d,
+ 0x010f, 0x010f,
+ 0x0111, 0x0111,
+ 0x0113, 0x0113,
+ 0x0115, 0x0115,
+ 0x0117, 0x0117,
+ 0x0119, 0x0119,
+ 0x011b, 0x011b,
+ 0x011d, 0x011d,
+ 0x011f, 0x011f,
+ 0x0121, 0x0121,
+ 0x0123, 0x0123,
+ 0x0125, 0x0125,
+ 0x0127, 0x0127,
+ 0x0129, 0x0129,
+ 0x012b, 0x012b,
+ 0x012d, 0x012d,
+ 0x012f, 0x012f,
+ 0x0131, 0x0131,
+ 0x0133, 0x0133,
+ 0x0135, 0x0135,
+ 0x0137, 0x0137,
+ 0x013a, 0x013a,
+ 0x013c, 0x013c,
+ 0x013e, 0x013e,
+ 0x0140, 0x0140,
+ 0x0142, 0x0142,
+ 0x0144, 0x0144,
+ 0x0146, 0x0146,
+ 0x0148, 0x0149,
+ 0x014b, 0x014b,
+ 0x014d, 0x014d,
+ 0x014f, 0x014f,
+ 0x0151, 0x0151,
+ 0x0153, 0x0153,
+ 0x0155, 0x0155,
+ 0x0157, 0x0157,
+ 0x0159, 0x0159,
+ 0x015b, 0x015b,
+ 0x015d, 0x015d,
+ 0x015f, 0x015f,
+ 0x0161, 0x0161,
+ 0x0163, 0x0163,
+ 0x0165, 0x0165,
+ 0x0167, 0x0167,
+ 0x0169, 0x0169,
+ 0x016b, 0x016b,
+ 0x016d, 0x016d,
+ 0x016f, 0x016f,
+ 0x0171, 0x0171,
+ 0x0173, 0x0173,
+ 0x0175, 0x0175,
+ 0x0177, 0x0177,
+ 0x017a, 0x017a,
+ 0x017c, 0x017c,
+ 0x017e, 0x0180,
+ 0x0183, 0x0183,
+ 0x0185, 0x0185,
+ 0x0188, 0x0188,
+ 0x018c, 0x018c,
+ 0x0192, 0x0192,
+ 0x0195, 0x0195,
+ 0x0199, 0x019a,
+ 0x019e, 0x019e,
+ 0x01a1, 0x01a1,
+ 0x01a3, 0x01a3,
+ 0x01a5, 0x01a5,
+ 0x01a8, 0x01a8,
+ 0x01ad, 0x01ad,
+ 0x01b0, 0x01b0,
+ 0x01b4, 0x01b4,
+ 0x01b6, 0x01b6,
+ 0x01b9, 0x01b9,
+ 0x01bd, 0x01bd,
+ 0x01bf, 0x01bf,
+ 0x01c5, 0x01c6,
+ 0x01c8, 0x01c9,
+ 0x01cb, 0x01cc,
+ 0x01ce, 0x01ce,
+ 0x01d0, 0x01d0,
+ 0x01d2, 0x01d2,
+ 0x01d4, 0x01d4,
+ 0x01d6, 0x01d6,
+ 0x01d8, 0x01d8,
+ 0x01da, 0x01da,
+ 0x01dc, 0x01dd,
+ 0x01df, 0x01df,
+ 0x01e1, 0x01e1,
+ 0x01e3, 0x01e3,
+ 0x01e5, 0x01e5,
+ 0x01e7, 0x01e7,
+ 0x01e9, 0x01e9,
+ 0x01eb, 0x01eb,
+ 0x01ed, 0x01ed,
+ 0x01ef, 0x01f0,
+ 0x01f2, 0x01f3,
+ 0x01f5, 0x01f5,
+ 0x01f9, 0x01f9,
+ 0x01fb, 0x01fb,
+ 0x01fd, 0x01fd,
+ 0x01ff, 0x01ff,
+ 0x0201, 0x0201,
+ 0x0203, 0x0203,
+ 0x0205, 0x0205,
+ 0x0207, 0x0207,
+ 0x0209, 0x0209,
+ 0x020b, 0x020b,
+ 0x020d, 0x020d,
+ 0x020f, 0x020f,
+ 0x0211, 0x0211,
+ 0x0213, 0x0213,
+ 0x0215, 0x0215,
+ 0x0217, 0x0217,
+ 0x0219, 0x0219,
+ 0x021b, 0x021b,
+ 0x021d, 0x021d,
+ 0x021f, 0x021f,
+ 0x0223, 0x0223,
+ 0x0225, 0x0225,
+ 0x0227, 0x0227,
+ 0x0229, 0x0229,
+ 0x022b, 0x022b,
+ 0x022d, 0x022d,
+ 0x022f, 0x022f,
+ 0x0231, 0x0231,
+ 0x0233, 0x0233,
+ 0x023c, 0x023c,
+ 0x023f, 0x0240,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0254,
+ 0x0256, 0x0257,
+ 0x0259, 0x0259,
+ 0x025b, 0x025c,
+ 0x0260, 0x0261,
+ 0x0263, 0x0263,
+ 0x0265, 0x0266,
+ 0x0268, 0x026c,
+ 0x026f, 0x026f,
+ 0x0271, 0x0272,
+ 0x0275, 0x0275,
+ 0x027d, 0x027d,
+ 0x0280, 0x0280,
+ 0x0283, 0x0283,
+ 0x0287, 0x028c,
+ 0x0292, 0x0292,
+ 0x029d, 0x029e,
+ 0x0345, 0x0345,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037b, 0x037d,
+ 0x0390, 0x0390,
+ 0x03ac, 0x03ce,
+ 0x03d0, 0x03d1,
+ 0x03d5, 0x03d7,
+ 0x03d9, 0x03d9,
+ 0x03db, 0x03db,
+ 0x03dd, 0x03dd,
+ 0x03df, 0x03df,
+ 0x03e1, 0x03e1,
+ 0x03e3, 0x03e3,
+ 0x03e5, 0x03e5,
+ 0x03e7, 0x03e7,
+ 0x03e9, 0x03e9,
+ 0x03eb, 0x03eb,
+ 0x03ed, 0x03ed,
+ 0x03ef, 0x03f3,
+ 0x03f5, 0x03f5,
+ 0x03f8, 0x03f8,
+ 0x03fb, 0x03fb,
+ 0x0430, 0x045f,
+ 0x0461, 0x0461,
+ 0x0463, 0x0463,
+ 0x0465, 0x0465,
+ 0x0467, 0x0467,
+ 0x0469, 0x0469,
+ 0x046b, 0x046b,
+ 0x046d, 0x046d,
+ 0x046f, 0x046f,
+ 0x0471, 0x0471,
+ 0x0473, 0x0473,
+ 0x0475, 0x0475,
+ 0x0477, 0x0477,
+ 0x0479, 0x0479,
+ 0x047b, 0x047b,
+ 0x047d, 0x047d,
+ 0x047f, 0x047f,
+ 0x0481, 0x0481,
+ 0x048b, 0x048b,
+ 0x048d, 0x048d,
+ 0x048f, 0x048f,
+ 0x0491, 0x0491,
+ 0x0493, 0x0493,
+ 0x0495, 0x0495,
+ 0x0497, 0x0497,
+ 0x0499, 0x0499,
+ 0x049b, 0x049b,
+ 0x049d, 0x049d,
+ 0x049f, 0x049f,
+ 0x04a1, 0x04a1,
+ 0x04a3, 0x04a3,
+ 0x04a5, 0x04a5,
+ 0x04a7, 0x04a7,
+ 0x04a9, 0x04a9,
+ 0x04ab, 0x04ab,
+ 0x04ad, 0x04ad,
+ 0x04af, 0x04af,
+ 0x04b1, 0x04b1,
+ 0x04b3, 0x04b3,
+ 0x04b5, 0x04b5,
+ 0x04b7, 0x04b7,
+ 0x04b9, 0x04b9,
+ 0x04bb, 0x04bb,
+ 0x04bd, 0x04bd,
+ 0x04bf, 0x04bf,
+ 0x04c2, 0x04c2,
+ 0x04c4, 0x04c4,
+ 0x04c6, 0x04c6,
+ 0x04c8, 0x04c8,
+ 0x04ca, 0x04ca,
+ 0x04cc, 0x04cc,
+ 0x04ce, 0x04cf,
+ 0x04d1, 0x04d1,
+ 0x04d3, 0x04d3,
+ 0x04d5, 0x04d5,
+ 0x04d7, 0x04d7,
+ 0x04d9, 0x04d9,
+ 0x04db, 0x04db,
+ 0x04dd, 0x04dd,
+ 0x04df, 0x04df,
+ 0x04e1, 0x04e1,
+ 0x04e3, 0x04e3,
+ 0x04e5, 0x04e5,
+ 0x04e7, 0x04e7,
+ 0x04e9, 0x04e9,
+ 0x04eb, 0x04eb,
+ 0x04ed, 0x04ed,
+ 0x04ef, 0x04ef,
+ 0x04f1, 0x04f1,
+ 0x04f3, 0x04f3,
+ 0x04f5, 0x04f5,
+ 0x04f7, 0x04f7,
+ 0x04f9, 0x04f9,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0561, 0x0587,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1d79, 0x1d79,
+ 0x1d7d, 0x1d7d,
+ 0x1e01, 0x1e01,
+ 0x1e03, 0x1e03,
+ 0x1e05, 0x1e05,
+ 0x1e07, 0x1e07,
+ 0x1e09, 0x1e09,
+ 0x1e0b, 0x1e0b,
+ 0x1e0d, 0x1e0d,
+ 0x1e0f, 0x1e0f,
+ 0x1e11, 0x1e11,
+ 0x1e13, 0x1e13,
+ 0x1e15, 0x1e15,
+ 0x1e17, 0x1e17,
+ 0x1e19, 0x1e19,
+ 0x1e1b, 0x1e1b,
+ 0x1e1d, 0x1e1d,
+ 0x1e1f, 0x1e1f,
+ 0x1e21, 0x1e21,
+ 0x1e23, 0x1e23,
+ 0x1e25, 0x1e25,
+ 0x1e27, 0x1e27,
+ 0x1e29, 0x1e29,
+ 0x1e2b, 0x1e2b,
+ 0x1e2d, 0x1e2d,
+ 0x1e2f, 0x1e2f,
+ 0x1e31, 0x1e31,
+ 0x1e33, 0x1e33,
+ 0x1e35, 0x1e35,
+ 0x1e37, 0x1e37,
+ 0x1e39, 0x1e39,
+ 0x1e3b, 0x1e3b,
+ 0x1e3d, 0x1e3d,
+ 0x1e3f, 0x1e3f,
+ 0x1e41, 0x1e41,
+ 0x1e43, 0x1e43,
+ 0x1e45, 0x1e45,
+ 0x1e47, 0x1e47,
+ 0x1e49, 0x1e49,
+ 0x1e4b, 0x1e4b,
+ 0x1e4d, 0x1e4d,
+ 0x1e4f, 0x1e4f,
+ 0x1e51, 0x1e51,
+ 0x1e53, 0x1e53,
+ 0x1e55, 0x1e55,
+ 0x1e57, 0x1e57,
+ 0x1e59, 0x1e59,
+ 0x1e5b, 0x1e5b,
+ 0x1e5d, 0x1e5d,
+ 0x1e5f, 0x1e5f,
+ 0x1e61, 0x1e61,
+ 0x1e63, 0x1e63,
+ 0x1e65, 0x1e65,
+ 0x1e67, 0x1e67,
+ 0x1e69, 0x1e69,
+ 0x1e6b, 0x1e6b,
+ 0x1e6d, 0x1e6d,
+ 0x1e6f, 0x1e6f,
+ 0x1e71, 0x1e71,
+ 0x1e73, 0x1e73,
+ 0x1e75, 0x1e75,
+ 0x1e77, 0x1e77,
+ 0x1e79, 0x1e79,
+ 0x1e7b, 0x1e7b,
+ 0x1e7d, 0x1e7d,
+ 0x1e7f, 0x1e7f,
+ 0x1e81, 0x1e81,
+ 0x1e83, 0x1e83,
+ 0x1e85, 0x1e85,
+ 0x1e87, 0x1e87,
+ 0x1e89, 0x1e89,
+ 0x1e8b, 0x1e8b,
+ 0x1e8d, 0x1e8d,
+ 0x1e8f, 0x1e8f,
+ 0x1e91, 0x1e91,
+ 0x1e93, 0x1e93,
+ 0x1e95, 0x1e9b,
+ 0x1ea1, 0x1ea1,
+ 0x1ea3, 0x1ea3,
+ 0x1ea5, 0x1ea5,
+ 0x1ea7, 0x1ea7,
+ 0x1ea9, 0x1ea9,
+ 0x1eab, 0x1eab,
+ 0x1ead, 0x1ead,
+ 0x1eaf, 0x1eaf,
+ 0x1eb1, 0x1eb1,
+ 0x1eb3, 0x1eb3,
+ 0x1eb5, 0x1eb5,
+ 0x1eb7, 0x1eb7,
+ 0x1eb9, 0x1eb9,
+ 0x1ebb, 0x1ebb,
+ 0x1ebd, 0x1ebd,
+ 0x1ebf, 0x1ebf,
+ 0x1ec1, 0x1ec1,
+ 0x1ec3, 0x1ec3,
+ 0x1ec5, 0x1ec5,
+ 0x1ec7, 0x1ec7,
+ 0x1ec9, 0x1ec9,
+ 0x1ecb, 0x1ecb,
+ 0x1ecd, 0x1ecd,
+ 0x1ecf, 0x1ecf,
+ 0x1ed1, 0x1ed1,
+ 0x1ed3, 0x1ed3,
+ 0x1ed5, 0x1ed5,
+ 0x1ed7, 0x1ed7,
+ 0x1ed9, 0x1ed9,
+ 0x1edb, 0x1edb,
+ 0x1edd, 0x1edd,
+ 0x1edf, 0x1edf,
+ 0x1ee1, 0x1ee1,
+ 0x1ee3, 0x1ee3,
+ 0x1ee5, 0x1ee5,
+ 0x1ee7, 0x1ee7,
+ 0x1ee9, 0x1ee9,
+ 0x1eeb, 0x1eeb,
+ 0x1eed, 0x1eed,
+ 0x1eef, 0x1eef,
+ 0x1ef1, 0x1ef1,
+ 0x1ef3, 0x1ef3,
+ 0x1ef5, 0x1ef5,
+ 0x1ef7, 0x1ef7,
+ 0x1ef9, 0x1ef9,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 0x1f07,
+ 0x1f10, 0x1f15,
+ 0x1f20, 0x1f27,
+ 0x1f30, 0x1f37,
+ 0x1f40, 0x1f45,
+ 0x1f50, 0x1f57,
+ 0x1f60, 0x1f67,
+ 0x1f70, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fb7,
+ 0x1fbc, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fc7,
+ 0x1fcc, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fd7,
+ 0x1fe0, 0x1fe7,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ff7,
+ 0x1ffc, 0x1ffc,
+ 0x214e, 0x214e,
+ 0x2170, 0x217f,
+ 0x2184, 0x2184,
+ 0x24d0, 0x24e9,
+ 0x2c30, 0x2c5e,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c73, 0x2c73,
+ 0x2c76, 0x2c76,
+ 0x2c81, 0x2c81,
+ 0x2c83, 0x2c83,
+ 0x2c85, 0x2c85,
+ 0x2c87, 0x2c87,
+ 0x2c89, 0x2c89,
+ 0x2c8b, 0x2c8b,
+ 0x2c8d, 0x2c8d,
+ 0x2c8f, 0x2c8f,
+ 0x2c91, 0x2c91,
+ 0x2c93, 0x2c93,
+ 0x2c95, 0x2c95,
+ 0x2c97, 0x2c97,
+ 0x2c99, 0x2c99,
+ 0x2c9b, 0x2c9b,
+ 0x2c9d, 0x2c9d,
+ 0x2c9f, 0x2c9f,
+ 0x2ca1, 0x2ca1,
+ 0x2ca3, 0x2ca3,
+ 0x2ca5, 0x2ca5,
+ 0x2ca7, 0x2ca7,
+ 0x2ca9, 0x2ca9,
+ 0x2cab, 0x2cab,
+ 0x2cad, 0x2cad,
+ 0x2caf, 0x2caf,
+ 0x2cb1, 0x2cb1,
+ 0x2cb3, 0x2cb3,
+ 0x2cb5, 0x2cb5,
+ 0x2cb7, 0x2cb7,
+ 0x2cb9, 0x2cb9,
+ 0x2cbb, 0x2cbb,
+ 0x2cbd, 0x2cbd,
+ 0x2cbf, 0x2cbf,
+ 0x2cc1, 0x2cc1,
+ 0x2cc3, 0x2cc3,
+ 0x2cc5, 0x2cc5,
+ 0x2cc7, 0x2cc7,
+ 0x2cc9, 0x2cc9,
+ 0x2ccb, 0x2ccb,
+ 0x2ccd, 0x2ccd,
+ 0x2ccf, 0x2ccf,
+ 0x2cd1, 0x2cd1,
+ 0x2cd3, 0x2cd3,
+ 0x2cd5, 0x2cd5,
+ 0x2cd7, 0x2cd7,
+ 0x2cd9, 0x2cd9,
+ 0x2cdb, 0x2cdb,
+ 0x2cdd, 0x2cdd,
+ 0x2cdf, 0x2cdf,
+ 0x2ce1, 0x2ce1,
+ 0x2ce3, 0x2ce3,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69b,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa72f,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa76f,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa791, 0xa791,
+ 0xa793, 0xa793,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xab53, 0xab53,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10cc0, 0x10cf2,
+ 0x118c0, 0x118df,
+ 0x1e922, 0x1e943,
+}; /* CR_Changes_When_Uppercased */
+
+/* 'Changes_When_Titlecased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Titlecased[] = {
+ 608,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 0x00df, 0x00f6,
+ 0x00f8, 0x00ff,
+ 0x0101, 0x0101,
+ 0x0103, 0x0103,
+ 0x0105, 0x0105,
+ 0x0107, 0x0107,
+ 0x0109, 0x0109,
+ 0x010b, 0x010b,
+ 0x010d, 0x010d,
+ 0x010f, 0x010f,
+ 0x0111, 0x0111,
+ 0x0113, 0x0113,
+ 0x0115, 0x0115,
+ 0x0117, 0x0117,
+ 0x0119, 0x0119,
+ 0x011b, 0x011b,
+ 0x011d, 0x011d,
+ 0x011f, 0x011f,
+ 0x0121, 0x0121,
+ 0x0123, 0x0123,
+ 0x0125, 0x0125,
+ 0x0127, 0x0127,
+ 0x0129, 0x0129,
+ 0x012b, 0x012b,
+ 0x012d, 0x012d,
+ 0x012f, 0x012f,
+ 0x0131, 0x0131,
+ 0x0133, 0x0133,
+ 0x0135, 0x0135,
+ 0x0137, 0x0137,
+ 0x013a, 0x013a,
+ 0x013c, 0x013c,
+ 0x013e, 0x013e,
+ 0x0140, 0x0140,
+ 0x0142, 0x0142,
+ 0x0144, 0x0144,
+ 0x0146, 0x0146,
+ 0x0148, 0x0149,
+ 0x014b, 0x014b,
+ 0x014d, 0x014d,
+ 0x014f, 0x014f,
+ 0x0151, 0x0151,
+ 0x0153, 0x0153,
+ 0x0155, 0x0155,
+ 0x0157, 0x0157,
+ 0x0159, 0x0159,
+ 0x015b, 0x015b,
+ 0x015d, 0x015d,
+ 0x015f, 0x015f,
+ 0x0161, 0x0161,
+ 0x0163, 0x0163,
+ 0x0165, 0x0165,
+ 0x0167, 0x0167,
+ 0x0169, 0x0169,
+ 0x016b, 0x016b,
+ 0x016d, 0x016d,
+ 0x016f, 0x016f,
+ 0x0171, 0x0171,
+ 0x0173, 0x0173,
+ 0x0175, 0x0175,
+ 0x0177, 0x0177,
+ 0x017a, 0x017a,
+ 0x017c, 0x017c,
+ 0x017e, 0x0180,
+ 0x0183, 0x0183,
+ 0x0185, 0x0185,
+ 0x0188, 0x0188,
+ 0x018c, 0x018c,
+ 0x0192, 0x0192,
+ 0x0195, 0x0195,
+ 0x0199, 0x019a,
+ 0x019e, 0x019e,
+ 0x01a1, 0x01a1,
+ 0x01a3, 0x01a3,
+ 0x01a5, 0x01a5,
+ 0x01a8, 0x01a8,
+ 0x01ad, 0x01ad,
+ 0x01b0, 0x01b0,
+ 0x01b4, 0x01b4,
+ 0x01b6, 0x01b6,
+ 0x01b9, 0x01b9,
+ 0x01bd, 0x01bd,
+ 0x01bf, 0x01bf,
+ 0x01c4, 0x01c4,
+ 0x01c6, 0x01c7,
+ 0x01c9, 0x01ca,
+ 0x01cc, 0x01cc,
+ 0x01ce, 0x01ce,
+ 0x01d0, 0x01d0,
+ 0x01d2, 0x01d2,
+ 0x01d4, 0x01d4,
+ 0x01d6, 0x01d6,
+ 0x01d8, 0x01d8,
+ 0x01da, 0x01da,
+ 0x01dc, 0x01dd,
+ 0x01df, 0x01df,
+ 0x01e1, 0x01e1,
+ 0x01e3, 0x01e3,
+ 0x01e5, 0x01e5,
+ 0x01e7, 0x01e7,
+ 0x01e9, 0x01e9,
+ 0x01eb, 0x01eb,
+ 0x01ed, 0x01ed,
+ 0x01ef, 0x01f1,
+ 0x01f3, 0x01f3,
+ 0x01f5, 0x01f5,
+ 0x01f9, 0x01f9,
+ 0x01fb, 0x01fb,
+ 0x01fd, 0x01fd,
+ 0x01ff, 0x01ff,
+ 0x0201, 0x0201,
+ 0x0203, 0x0203,
+ 0x0205, 0x0205,
+ 0x0207, 0x0207,
+ 0x0209, 0x0209,
+ 0x020b, 0x020b,
+ 0x020d, 0x020d,
+ 0x020f, 0x020f,
+ 0x0211, 0x0211,
+ 0x0213, 0x0213,
+ 0x0215, 0x0215,
+ 0x0217, 0x0217,
+ 0x0219, 0x0219,
+ 0x021b, 0x021b,
+ 0x021d, 0x021d,
+ 0x021f, 0x021f,
+ 0x0223, 0x0223,
+ 0x0225, 0x0225,
+ 0x0227, 0x0227,
+ 0x0229, 0x0229,
+ 0x022b, 0x022b,
+ 0x022d, 0x022d,
+ 0x022f, 0x022f,
+ 0x0231, 0x0231,
+ 0x0233, 0x0233,
+ 0x023c, 0x023c,
+ 0x023f, 0x0240,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0254,
+ 0x0256, 0x0257,
+ 0x0259, 0x0259,
+ 0x025b, 0x025c,
+ 0x0260, 0x0261,
+ 0x0263, 0x0263,
+ 0x0265, 0x0266,
+ 0x0268, 0x026c,
+ 0x026f, 0x026f,
+ 0x0271, 0x0272,
+ 0x0275, 0x0275,
+ 0x027d, 0x027d,
+ 0x0280, 0x0280,
+ 0x0283, 0x0283,
+ 0x0287, 0x028c,
+ 0x0292, 0x0292,
+ 0x029d, 0x029e,
+ 0x0345, 0x0345,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037b, 0x037d,
+ 0x0390, 0x0390,
+ 0x03ac, 0x03ce,
+ 0x03d0, 0x03d1,
+ 0x03d5, 0x03d7,
+ 0x03d9, 0x03d9,
+ 0x03db, 0x03db,
+ 0x03dd, 0x03dd,
+ 0x03df, 0x03df,
+ 0x03e1, 0x03e1,
+ 0x03e3, 0x03e3,
+ 0x03e5, 0x03e5,
+ 0x03e7, 0x03e7,
+ 0x03e9, 0x03e9,
+ 0x03eb, 0x03eb,
+ 0x03ed, 0x03ed,
+ 0x03ef, 0x03f3,
+ 0x03f5, 0x03f5,
+ 0x03f8, 0x03f8,
+ 0x03fb, 0x03fb,
+ 0x0430, 0x045f,
+ 0x0461, 0x0461,
+ 0x0463, 0x0463,
+ 0x0465, 0x0465,
+ 0x0467, 0x0467,
+ 0x0469, 0x0469,
+ 0x046b, 0x046b,
+ 0x046d, 0x046d,
+ 0x046f, 0x046f,
+ 0x0471, 0x0471,
+ 0x0473, 0x0473,
+ 0x0475, 0x0475,
+ 0x0477, 0x0477,
+ 0x0479, 0x0479,
+ 0x047b, 0x047b,
+ 0x047d, 0x047d,
+ 0x047f, 0x047f,
+ 0x0481, 0x0481,
+ 0x048b, 0x048b,
+ 0x048d, 0x048d,
+ 0x048f, 0x048f,
+ 0x0491, 0x0491,
+ 0x0493, 0x0493,
+ 0x0495, 0x0495,
+ 0x0497, 0x0497,
+ 0x0499, 0x0499,
+ 0x049b, 0x049b,
+ 0x049d, 0x049d,
+ 0x049f, 0x049f,
+ 0x04a1, 0x04a1,
+ 0x04a3, 0x04a3,
+ 0x04a5, 0x04a5,
+ 0x04a7, 0x04a7,
+ 0x04a9, 0x04a9,
+ 0x04ab, 0x04ab,
+ 0x04ad, 0x04ad,
+ 0x04af, 0x04af,
+ 0x04b1, 0x04b1,
+ 0x04b3, 0x04b3,
+ 0x04b5, 0x04b5,
+ 0x04b7, 0x04b7,
+ 0x04b9, 0x04b9,
+ 0x04bb, 0x04bb,
+ 0x04bd, 0x04bd,
+ 0x04bf, 0x04bf,
+ 0x04c2, 0x04c2,
+ 0x04c4, 0x04c4,
+ 0x04c6, 0x04c6,
+ 0x04c8, 0x04c8,
+ 0x04ca, 0x04ca,
+ 0x04cc, 0x04cc,
+ 0x04ce, 0x04cf,
+ 0x04d1, 0x04d1,
+ 0x04d3, 0x04d3,
+ 0x04d5, 0x04d5,
+ 0x04d7, 0x04d7,
+ 0x04d9, 0x04d9,
+ 0x04db, 0x04db,
+ 0x04dd, 0x04dd,
+ 0x04df, 0x04df,
+ 0x04e1, 0x04e1,
+ 0x04e3, 0x04e3,
+ 0x04e5, 0x04e5,
+ 0x04e7, 0x04e7,
+ 0x04e9, 0x04e9,
+ 0x04eb, 0x04eb,
+ 0x04ed, 0x04ed,
+ 0x04ef, 0x04ef,
+ 0x04f1, 0x04f1,
+ 0x04f3, 0x04f3,
+ 0x04f5, 0x04f5,
+ 0x04f7, 0x04f7,
+ 0x04f9, 0x04f9,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0561, 0x0587,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1d79, 0x1d79,
+ 0x1d7d, 0x1d7d,
+ 0x1e01, 0x1e01,
+ 0x1e03, 0x1e03,
+ 0x1e05, 0x1e05,
+ 0x1e07, 0x1e07,
+ 0x1e09, 0x1e09,
+ 0x1e0b, 0x1e0b,
+ 0x1e0d, 0x1e0d,
+ 0x1e0f, 0x1e0f,
+ 0x1e11, 0x1e11,
+ 0x1e13, 0x1e13,
+ 0x1e15, 0x1e15,
+ 0x1e17, 0x1e17,
+ 0x1e19, 0x1e19,
+ 0x1e1b, 0x1e1b,
+ 0x1e1d, 0x1e1d,
+ 0x1e1f, 0x1e1f,
+ 0x1e21, 0x1e21,
+ 0x1e23, 0x1e23,
+ 0x1e25, 0x1e25,
+ 0x1e27, 0x1e27,
+ 0x1e29, 0x1e29,
+ 0x1e2b, 0x1e2b,
+ 0x1e2d, 0x1e2d,
+ 0x1e2f, 0x1e2f,
+ 0x1e31, 0x1e31,
+ 0x1e33, 0x1e33,
+ 0x1e35, 0x1e35,
+ 0x1e37, 0x1e37,
+ 0x1e39, 0x1e39,
+ 0x1e3b, 0x1e3b,
+ 0x1e3d, 0x1e3d,
+ 0x1e3f, 0x1e3f,
+ 0x1e41, 0x1e41,
+ 0x1e43, 0x1e43,
+ 0x1e45, 0x1e45,
+ 0x1e47, 0x1e47,
+ 0x1e49, 0x1e49,
+ 0x1e4b, 0x1e4b,
+ 0x1e4d, 0x1e4d,
+ 0x1e4f, 0x1e4f,
+ 0x1e51, 0x1e51,
+ 0x1e53, 0x1e53,
+ 0x1e55, 0x1e55,
+ 0x1e57, 0x1e57,
+ 0x1e59, 0x1e59,
+ 0x1e5b, 0x1e5b,
+ 0x1e5d, 0x1e5d,
+ 0x1e5f, 0x1e5f,
+ 0x1e61, 0x1e61,
+ 0x1e63, 0x1e63,
+ 0x1e65, 0x1e65,
+ 0x1e67, 0x1e67,
+ 0x1e69, 0x1e69,
+ 0x1e6b, 0x1e6b,
+ 0x1e6d, 0x1e6d,
+ 0x1e6f, 0x1e6f,
+ 0x1e71, 0x1e71,
+ 0x1e73, 0x1e73,
+ 0x1e75, 0x1e75,
+ 0x1e77, 0x1e77,
+ 0x1e79, 0x1e79,
+ 0x1e7b, 0x1e7b,
+ 0x1e7d, 0x1e7d,
+ 0x1e7f, 0x1e7f,
+ 0x1e81, 0x1e81,
+ 0x1e83, 0x1e83,
+ 0x1e85, 0x1e85,
+ 0x1e87, 0x1e87,
+ 0x1e89, 0x1e89,
+ 0x1e8b, 0x1e8b,
+ 0x1e8d, 0x1e8d,
+ 0x1e8f, 0x1e8f,
+ 0x1e91, 0x1e91,
+ 0x1e93, 0x1e93,
+ 0x1e95, 0x1e9b,
+ 0x1ea1, 0x1ea1,
+ 0x1ea3, 0x1ea3,
+ 0x1ea5, 0x1ea5,
+ 0x1ea7, 0x1ea7,
+ 0x1ea9, 0x1ea9,
+ 0x1eab, 0x1eab,
+ 0x1ead, 0x1ead,
+ 0x1eaf, 0x1eaf,
+ 0x1eb1, 0x1eb1,
+ 0x1eb3, 0x1eb3,
+ 0x1eb5, 0x1eb5,
+ 0x1eb7, 0x1eb7,
+ 0x1eb9, 0x1eb9,
+ 0x1ebb, 0x1ebb,
+ 0x1ebd, 0x1ebd,
+ 0x1ebf, 0x1ebf,
+ 0x1ec1, 0x1ec1,
+ 0x1ec3, 0x1ec3,
+ 0x1ec5, 0x1ec5,
+ 0x1ec7, 0x1ec7,
+ 0x1ec9, 0x1ec9,
+ 0x1ecb, 0x1ecb,
+ 0x1ecd, 0x1ecd,
+ 0x1ecf, 0x1ecf,
+ 0x1ed1, 0x1ed1,
+ 0x1ed3, 0x1ed3,
+ 0x1ed5, 0x1ed5,
+ 0x1ed7, 0x1ed7,
+ 0x1ed9, 0x1ed9,
+ 0x1edb, 0x1edb,
+ 0x1edd, 0x1edd,
+ 0x1edf, 0x1edf,
+ 0x1ee1, 0x1ee1,
+ 0x1ee3, 0x1ee3,
+ 0x1ee5, 0x1ee5,
+ 0x1ee7, 0x1ee7,
+ 0x1ee9, 0x1ee9,
+ 0x1eeb, 0x1eeb,
+ 0x1eed, 0x1eed,
+ 0x1eef, 0x1eef,
+ 0x1ef1, 0x1ef1,
+ 0x1ef3, 0x1ef3,
+ 0x1ef5, 0x1ef5,
+ 0x1ef7, 0x1ef7,
+ 0x1ef9, 0x1ef9,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 0x1f07,
+ 0x1f10, 0x1f15,
+ 0x1f20, 0x1f27,
+ 0x1f30, 0x1f37,
+ 0x1f40, 0x1f45,
+ 0x1f50, 0x1f57,
+ 0x1f60, 0x1f67,
+ 0x1f70, 0x1f7d,
+ 0x1f80, 0x1f87,
+ 0x1f90, 0x1f97,
+ 0x1fa0, 0x1fa7,
+ 0x1fb0, 0x1fb4,
+ 0x1fb6, 0x1fb7,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fc7,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fd7,
+ 0x1fe0, 0x1fe7,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ff7,
+ 0x214e, 0x214e,
+ 0x2170, 0x217f,
+ 0x2184, 0x2184,
+ 0x24d0, 0x24e9,
+ 0x2c30, 0x2c5e,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c73, 0x2c73,
+ 0x2c76, 0x2c76,
+ 0x2c81, 0x2c81,
+ 0x2c83, 0x2c83,
+ 0x2c85, 0x2c85,
+ 0x2c87, 0x2c87,
+ 0x2c89, 0x2c89,
+ 0x2c8b, 0x2c8b,
+ 0x2c8d, 0x2c8d,
+ 0x2c8f, 0x2c8f,
+ 0x2c91, 0x2c91,
+ 0x2c93, 0x2c93,
+ 0x2c95, 0x2c95,
+ 0x2c97, 0x2c97,
+ 0x2c99, 0x2c99,
+ 0x2c9b, 0x2c9b,
+ 0x2c9d, 0x2c9d,
+ 0x2c9f, 0x2c9f,
+ 0x2ca1, 0x2ca1,
+ 0x2ca3, 0x2ca3,
+ 0x2ca5, 0x2ca5,
+ 0x2ca7, 0x2ca7,
+ 0x2ca9, 0x2ca9,
+ 0x2cab, 0x2cab,
+ 0x2cad, 0x2cad,
+ 0x2caf, 0x2caf,
+ 0x2cb1, 0x2cb1,
+ 0x2cb3, 0x2cb3,
+ 0x2cb5, 0x2cb5,
+ 0x2cb7, 0x2cb7,
+ 0x2cb9, 0x2cb9,
+ 0x2cbb, 0x2cbb,
+ 0x2cbd, 0x2cbd,
+ 0x2cbf, 0x2cbf,
+ 0x2cc1, 0x2cc1,
+ 0x2cc3, 0x2cc3,
+ 0x2cc5, 0x2cc5,
+ 0x2cc7, 0x2cc7,
+ 0x2cc9, 0x2cc9,
+ 0x2ccb, 0x2ccb,
+ 0x2ccd, 0x2ccd,
+ 0x2ccf, 0x2ccf,
+ 0x2cd1, 0x2cd1,
+ 0x2cd3, 0x2cd3,
+ 0x2cd5, 0x2cd5,
+ 0x2cd7, 0x2cd7,
+ 0x2cd9, 0x2cd9,
+ 0x2cdb, 0x2cdb,
+ 0x2cdd, 0x2cdd,
+ 0x2cdf, 0x2cdf,
+ 0x2ce1, 0x2ce1,
+ 0x2ce3, 0x2ce3,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69b,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa72f,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa76f,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa791, 0xa791,
+ 0xa793, 0xa793,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xab53, 0xab53,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10cc0, 0x10cf2,
+ 0x118c0, 0x118df,
+ 0x1e922, 0x1e943,
+}; /* CR_Changes_When_Titlecased */
+
+/* 'Changes_When_Casefolded': Derived Property */
+static const OnigCodePoint CR_Changes_When_Casefolded[] = {
+ 603,
+ 0x0041, 0x005a,
+ 0x00b5, 0x00b5,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00df,
+ 0x0100, 0x0100,
+ 0x0102, 0x0102,
+ 0x0104, 0x0104,
+ 0x0106, 0x0106,
+ 0x0108, 0x0108,
+ 0x010a, 0x010a,
+ 0x010c, 0x010c,
+ 0x010e, 0x010e,
+ 0x0110, 0x0110,
+ 0x0112, 0x0112,
+ 0x0114, 0x0114,
+ 0x0116, 0x0116,
+ 0x0118, 0x0118,
+ 0x011a, 0x011a,
+ 0x011c, 0x011c,
+ 0x011e, 0x011e,
+ 0x0120, 0x0120,
+ 0x0122, 0x0122,
+ 0x0124, 0x0124,
+ 0x0126, 0x0126,
+ 0x0128, 0x0128,
+ 0x012a, 0x012a,
+ 0x012c, 0x012c,
+ 0x012e, 0x012e,
+ 0x0130, 0x0130,
+ 0x0132, 0x0132,
+ 0x0134, 0x0134,
+ 0x0136, 0x0136,
+ 0x0139, 0x0139,
+ 0x013b, 0x013b,
+ 0x013d, 0x013d,
+ 0x013f, 0x013f,
+ 0x0141, 0x0141,
+ 0x0143, 0x0143,
+ 0x0145, 0x0145,
+ 0x0147, 0x0147,
+ 0x0149, 0x014a,
+ 0x014c, 0x014c,
+ 0x014e, 0x014e,
+ 0x0150, 0x0150,
+ 0x0152, 0x0152,
+ 0x0154, 0x0154,
+ 0x0156, 0x0156,
+ 0x0158, 0x0158,
+ 0x015a, 0x015a,
+ 0x015c, 0x015c,
+ 0x015e, 0x015e,
+ 0x0160, 0x0160,
+ 0x0162, 0x0162,
+ 0x0164, 0x0164,
+ 0x0166, 0x0166,
+ 0x0168, 0x0168,
+ 0x016a, 0x016a,
+ 0x016c, 0x016c,
+ 0x016e, 0x016e,
+ 0x0170, 0x0170,
+ 0x0172, 0x0172,
+ 0x0174, 0x0174,
+ 0x0176, 0x0176,
+ 0x0178, 0x0179,
+ 0x017b, 0x017b,
+ 0x017d, 0x017d,
+ 0x017f, 0x017f,
+ 0x0181, 0x0182,
+ 0x0184, 0x0184,
+ 0x0186, 0x0187,
+ 0x0189, 0x018b,
+ 0x018e, 0x0191,
+ 0x0193, 0x0194,
+ 0x0196, 0x0198,
+ 0x019c, 0x019d,
+ 0x019f, 0x01a0,
+ 0x01a2, 0x01a2,
+ 0x01a4, 0x01a4,
+ 0x01a6, 0x01a7,
+ 0x01a9, 0x01a9,
+ 0x01ac, 0x01ac,
+ 0x01ae, 0x01af,
+ 0x01b1, 0x01b3,
+ 0x01b5, 0x01b5,
+ 0x01b7, 0x01b8,
+ 0x01bc, 0x01bc,
+ 0x01c4, 0x01c5,
+ 0x01c7, 0x01c8,
+ 0x01ca, 0x01cb,
+ 0x01cd, 0x01cd,
+ 0x01cf, 0x01cf,
+ 0x01d1, 0x01d1,
+ 0x01d3, 0x01d3,
+ 0x01d5, 0x01d5,
+ 0x01d7, 0x01d7,
+ 0x01d9, 0x01d9,
+ 0x01db, 0x01db,
+ 0x01de, 0x01de,
+ 0x01e0, 0x01e0,
+ 0x01e2, 0x01e2,
+ 0x01e4, 0x01e4,
+ 0x01e6, 0x01e6,
+ 0x01e8, 0x01e8,
+ 0x01ea, 0x01ea,
+ 0x01ec, 0x01ec,
+ 0x01ee, 0x01ee,
+ 0x01f1, 0x01f2,
+ 0x01f4, 0x01f4,
+ 0x01f6, 0x01f8,
+ 0x01fa, 0x01fa,
+ 0x01fc, 0x01fc,
+ 0x01fe, 0x01fe,
+ 0x0200, 0x0200,
+ 0x0202, 0x0202,
+ 0x0204, 0x0204,
+ 0x0206, 0x0206,
+ 0x0208, 0x0208,
+ 0x020a, 0x020a,
+ 0x020c, 0x020c,
+ 0x020e, 0x020e,
+ 0x0210, 0x0210,
+ 0x0212, 0x0212,
+ 0x0214, 0x0214,
+ 0x0216, 0x0216,
+ 0x0218, 0x0218,
+ 0x021a, 0x021a,
+ 0x021c, 0x021c,
+ 0x021e, 0x021e,
+ 0x0220, 0x0220,
+ 0x0222, 0x0222,
+ 0x0224, 0x0224,
+ 0x0226, 0x0226,
+ 0x0228, 0x0228,
+ 0x022a, 0x022a,
+ 0x022c, 0x022c,
+ 0x022e, 0x022e,
+ 0x0230, 0x0230,
+ 0x0232, 0x0232,
+ 0x023a, 0x023b,
+ 0x023d, 0x023e,
+ 0x0241, 0x0241,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0345, 0x0345,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03c2, 0x03c2,
+ 0x03cf, 0x03d1,
+ 0x03d5, 0x03d6,
+ 0x03d8, 0x03d8,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03e2,
+ 0x03e4, 0x03e4,
+ 0x03e6, 0x03e6,
+ 0x03e8, 0x03e8,
+ 0x03ea, 0x03ea,
+ 0x03ec, 0x03ec,
+ 0x03ee, 0x03ee,
+ 0x03f0, 0x03f1,
+ 0x03f4, 0x03f5,
+ 0x03f7, 0x03f7,
+ 0x03f9, 0x03fa,
+ 0x03fd, 0x042f,
+ 0x0460, 0x0460,
+ 0x0462, 0x0462,
+ 0x0464, 0x0464,
+ 0x0466, 0x0466,
+ 0x0468, 0x0468,
+ 0x046a, 0x046a,
+ 0x046c, 0x046c,
+ 0x046e, 0x046e,
+ 0x0470, 0x0470,
+ 0x0472, 0x0472,
+ 0x0474, 0x0474,
+ 0x0476, 0x0476,
+ 0x0478, 0x0478,
+ 0x047a, 0x047a,
+ 0x047c, 0x047c,
+ 0x047e, 0x047e,
+ 0x0480, 0x0480,
+ 0x048a, 0x048a,
+ 0x048c, 0x048c,
+ 0x048e, 0x048e,
+ 0x0490, 0x0490,
+ 0x0492, 0x0492,
+ 0x0494, 0x0494,
+ 0x0496, 0x0496,
+ 0x0498, 0x0498,
+ 0x049a, 0x049a,
+ 0x049c, 0x049c,
+ 0x049e, 0x049e,
+ 0x04a0, 0x04a0,
+ 0x04a2, 0x04a2,
+ 0x04a4, 0x04a4,
+ 0x04a6, 0x04a6,
+ 0x04a8, 0x04a8,
+ 0x04aa, 0x04aa,
+ 0x04ac, 0x04ac,
+ 0x04ae, 0x04ae,
+ 0x04b0, 0x04b0,
+ 0x04b2, 0x04b2,
+ 0x04b4, 0x04b4,
+ 0x04b6, 0x04b6,
+ 0x04b8, 0x04b8,
+ 0x04ba, 0x04ba,
+ 0x04bc, 0x04bc,
+ 0x04be, 0x04be,
+ 0x04c0, 0x04c1,
+ 0x04c3, 0x04c3,
+ 0x04c5, 0x04c5,
+ 0x04c7, 0x04c7,
+ 0x04c9, 0x04c9,
+ 0x04cb, 0x04cb,
+ 0x04cd, 0x04cd,
+ 0x04d0, 0x04d0,
+ 0x04d2, 0x04d2,
+ 0x04d4, 0x04d4,
+ 0x04d6, 0x04d6,
+ 0x04d8, 0x04d8,
+ 0x04da, 0x04da,
+ 0x04dc, 0x04dc,
+ 0x04de, 0x04de,
+ 0x04e0, 0x04e0,
+ 0x04e2, 0x04e2,
+ 0x04e4, 0x04e4,
+ 0x04e6, 0x04e6,
+ 0x04e8, 0x04e8,
+ 0x04ea, 0x04ea,
+ 0x04ec, 0x04ec,
+ 0x04ee, 0x04ee,
+ 0x04f0, 0x04f0,
+ 0x04f2, 0x04f2,
+ 0x04f4, 0x04f4,
+ 0x04f6, 0x04f6,
+ 0x04f8, 0x04f8,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x0587, 0x0587,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1e00, 0x1e00,
+ 0x1e02, 0x1e02,
+ 0x1e04, 0x1e04,
+ 0x1e06, 0x1e06,
+ 0x1e08, 0x1e08,
+ 0x1e0a, 0x1e0a,
+ 0x1e0c, 0x1e0c,
+ 0x1e0e, 0x1e0e,
+ 0x1e10, 0x1e10,
+ 0x1e12, 0x1e12,
+ 0x1e14, 0x1e14,
+ 0x1e16, 0x1e16,
+ 0x1e18, 0x1e18,
+ 0x1e1a, 0x1e1a,
+ 0x1e1c, 0x1e1c,
+ 0x1e1e, 0x1e1e,
+ 0x1e20, 0x1e20,
+ 0x1e22, 0x1e22,
+ 0x1e24, 0x1e24,
+ 0x1e26, 0x1e26,
+ 0x1e28, 0x1e28,
+ 0x1e2a, 0x1e2a,
+ 0x1e2c, 0x1e2c,
+ 0x1e2e, 0x1e2e,
+ 0x1e30, 0x1e30,
+ 0x1e32, 0x1e32,
+ 0x1e34, 0x1e34,
+ 0x1e36, 0x1e36,
+ 0x1e38, 0x1e38,
+ 0x1e3a, 0x1e3a,
+ 0x1e3c, 0x1e3c,
+ 0x1e3e, 0x1e3e,
+ 0x1e40, 0x1e40,
+ 0x1e42, 0x1e42,
+ 0x1e44, 0x1e44,
+ 0x1e46, 0x1e46,
+ 0x1e48, 0x1e48,
+ 0x1e4a, 0x1e4a,
+ 0x1e4c, 0x1e4c,
+ 0x1e4e, 0x1e4e,
+ 0x1e50, 0x1e50,
+ 0x1e52, 0x1e52,
+ 0x1e54, 0x1e54,
+ 0x1e56, 0x1e56,
+ 0x1e58, 0x1e58,
+ 0x1e5a, 0x1e5a,
+ 0x1e5c, 0x1e5c,
+ 0x1e5e, 0x1e5e,
+ 0x1e60, 0x1e60,
+ 0x1e62, 0x1e62,
+ 0x1e64, 0x1e64,
+ 0x1e66, 0x1e66,
+ 0x1e68, 0x1e68,
+ 0x1e6a, 0x1e6a,
+ 0x1e6c, 0x1e6c,
+ 0x1e6e, 0x1e6e,
+ 0x1e70, 0x1e70,
+ 0x1e72, 0x1e72,
+ 0x1e74, 0x1e74,
+ 0x1e76, 0x1e76,
+ 0x1e78, 0x1e78,
+ 0x1e7a, 0x1e7a,
+ 0x1e7c, 0x1e7c,
+ 0x1e7e, 0x1e7e,
+ 0x1e80, 0x1e80,
+ 0x1e82, 0x1e82,
+ 0x1e84, 0x1e84,
+ 0x1e86, 0x1e86,
+ 0x1e88, 0x1e88,
+ 0x1e8a, 0x1e8a,
+ 0x1e8c, 0x1e8c,
+ 0x1e8e, 0x1e8e,
+ 0x1e90, 0x1e90,
+ 0x1e92, 0x1e92,
+ 0x1e94, 0x1e94,
+ 0x1e9a, 0x1e9b,
+ 0x1e9e, 0x1e9e,
+ 0x1ea0, 0x1ea0,
+ 0x1ea2, 0x1ea2,
+ 0x1ea4, 0x1ea4,
+ 0x1ea6, 0x1ea6,
+ 0x1ea8, 0x1ea8,
+ 0x1eaa, 0x1eaa,
+ 0x1eac, 0x1eac,
+ 0x1eae, 0x1eae,
+ 0x1eb0, 0x1eb0,
+ 0x1eb2, 0x1eb2,
+ 0x1eb4, 0x1eb4,
+ 0x1eb6, 0x1eb6,
+ 0x1eb8, 0x1eb8,
+ 0x1eba, 0x1eba,
+ 0x1ebc, 0x1ebc,
+ 0x1ebe, 0x1ebe,
+ 0x1ec0, 0x1ec0,
+ 0x1ec2, 0x1ec2,
+ 0x1ec4, 0x1ec4,
+ 0x1ec6, 0x1ec6,
+ 0x1ec8, 0x1ec8,
+ 0x1eca, 0x1eca,
+ 0x1ecc, 0x1ecc,
+ 0x1ece, 0x1ece,
+ 0x1ed0, 0x1ed0,
+ 0x1ed2, 0x1ed2,
+ 0x1ed4, 0x1ed4,
+ 0x1ed6, 0x1ed6,
+ 0x1ed8, 0x1ed8,
+ 0x1eda, 0x1eda,
+ 0x1edc, 0x1edc,
+ 0x1ede, 0x1ede,
+ 0x1ee0, 0x1ee0,
+ 0x1ee2, 0x1ee2,
+ 0x1ee4, 0x1ee4,
+ 0x1ee6, 0x1ee6,
+ 0x1ee8, 0x1ee8,
+ 0x1eea, 0x1eea,
+ 0x1eec, 0x1eec,
+ 0x1eee, 0x1eee,
+ 0x1ef0, 0x1ef0,
+ 0x1ef2, 0x1ef2,
+ 0x1ef4, 0x1ef4,
+ 0x1ef6, 0x1ef6,
+ 0x1ef8, 0x1ef8,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 0x1f08, 0x1f0f,
+ 0x1f18, 0x1f1d,
+ 0x1f28, 0x1f2f,
+ 0x1f38, 0x1f3f,
+ 0x1f48, 0x1f4d,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f5f,
+ 0x1f68, 0x1f6f,
+ 0x1f80, 0x1faf,
+ 0x1fb2, 0x1fb4,
+ 0x1fb7, 0x1fbc,
+ 0x1fc2, 0x1fc4,
+ 0x1fc7, 0x1fcc,
+ 0x1fd8, 0x1fdb,
+ 0x1fe8, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff7, 0x1ffc,
+ 0x2126, 0x2126,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x2160, 0x216f,
+ 0x2183, 0x2183,
+ 0x24b6, 0x24cf,
+ 0x2c00, 0x2c2e,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 0x2c80,
+ 0x2c82, 0x2c82,
+ 0x2c84, 0x2c84,
+ 0x2c86, 0x2c86,
+ 0x2c88, 0x2c88,
+ 0x2c8a, 0x2c8a,
+ 0x2c8c, 0x2c8c,
+ 0x2c8e, 0x2c8e,
+ 0x2c90, 0x2c90,
+ 0x2c92, 0x2c92,
+ 0x2c94, 0x2c94,
+ 0x2c96, 0x2c96,
+ 0x2c98, 0x2c98,
+ 0x2c9a, 0x2c9a,
+ 0x2c9c, 0x2c9c,
+ 0x2c9e, 0x2c9e,
+ 0x2ca0, 0x2ca0,
+ 0x2ca2, 0x2ca2,
+ 0x2ca4, 0x2ca4,
+ 0x2ca6, 0x2ca6,
+ 0x2ca8, 0x2ca8,
+ 0x2caa, 0x2caa,
+ 0x2cac, 0x2cac,
+ 0x2cae, 0x2cae,
+ 0x2cb0, 0x2cb0,
+ 0x2cb2, 0x2cb2,
+ 0x2cb4, 0x2cb4,
+ 0x2cb6, 0x2cb6,
+ 0x2cb8, 0x2cb8,
+ 0x2cba, 0x2cba,
+ 0x2cbc, 0x2cbc,
+ 0x2cbe, 0x2cbe,
+ 0x2cc0, 0x2cc0,
+ 0x2cc2, 0x2cc2,
+ 0x2cc4, 0x2cc4,
+ 0x2cc6, 0x2cc6,
+ 0x2cc8, 0x2cc8,
+ 0x2cca, 0x2cca,
+ 0x2ccc, 0x2ccc,
+ 0x2cce, 0x2cce,
+ 0x2cd0, 0x2cd0,
+ 0x2cd2, 0x2cd2,
+ 0x2cd4, 0x2cd4,
+ 0x2cd6, 0x2cd6,
+ 0x2cd8, 0x2cd8,
+ 0x2cda, 0x2cda,
+ 0x2cdc, 0x2cdc,
+ 0x2cde, 0x2cde,
+ 0x2ce0, 0x2ce0,
+ 0x2ce2, 0x2ce2,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10c80, 0x10cb2,
+ 0x118a0, 0x118bf,
+ 0x1e900, 0x1e921,
+}; /* CR_Changes_When_Casefolded */
+
+/* 'Changes_When_Casemapped': Derived Property */
+static const OnigCodePoint CR_Changes_When_Casemapped[] = {
+ 116,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x0137,
+ 0x0139, 0x018c,
+ 0x018e, 0x019a,
+ 0x019c, 0x01a9,
+ 0x01ac, 0x01b9,
+ 0x01bc, 0x01bd,
+ 0x01bf, 0x01bf,
+ 0x01c4, 0x0220,
+ 0x0222, 0x0233,
+ 0x023a, 0x0254,
+ 0x0256, 0x0257,
+ 0x0259, 0x0259,
+ 0x025b, 0x025c,
+ 0x0260, 0x0261,
+ 0x0263, 0x0263,
+ 0x0265, 0x0266,
+ 0x0268, 0x026c,
+ 0x026f, 0x026f,
+ 0x0271, 0x0272,
+ 0x0275, 0x0275,
+ 0x027d, 0x027d,
+ 0x0280, 0x0280,
+ 0x0283, 0x0283,
+ 0x0287, 0x028c,
+ 0x0292, 0x0292,
+ 0x029d, 0x029e,
+ 0x0345, 0x0345,
+ 0x0370, 0x0373,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03d1,
+ 0x03d5, 0x03f5,
+ 0x03f7, 0x03fb,
+ 0x03fd, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0561, 0x0587,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1d79, 0x1d79,
+ 0x1d7d, 0x1d7d,
+ 0x1e00, 0x1e9b,
+ 0x1e9e, 0x1e9e,
+ 0x1ea0, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2126, 0x2126,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x214e, 0x214e,
+ 0x2160, 0x217f,
+ 0x2183, 0x2184,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2c70,
+ 0x2c72, 0x2c73,
+ 0x2c75, 0x2c76,
+ 0x2c7e, 0x2ce3,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa640, 0xa66d,
+ 0xa680, 0xa69b,
+ 0xa722, 0xa72f,
+ 0xa732, 0xa76f,
+ 0xa779, 0xa787,
+ 0xa78b, 0xa78d,
+ 0xa790, 0xa793,
+ 0xa796, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xab53, 0xab53,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0x10400, 0x1044f,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x118a0, 0x118df,
+ 0x1e900, 0x1e943,
+}; /* CR_Changes_When_Casemapped */
+
+/* 'ID_Start': Derived Property */
+static const OnigCodePoint CR_ID_Start[] = {
+ 585,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0620, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06e5, 0x06e6,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0971, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a72, 0x0a74,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0abd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae1,
+ 0x0af9, 0x0af9,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b3d,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b71, 0x0b71,
+ 0x0b83, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e40, 0x0e46,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1711,
+ 0x1720, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1aa7, 0x1aa7,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4b,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf1,
+ 0x1cf5, 0x1cf6,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309b, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa67f, 0xa69d,
+ 0xa6a0, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf4,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb1d,
+ 0xfb1f, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0xff66, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11003, 0x11037,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x11700, 0x11719,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a83,
+ 0x11a86, 0x11a89,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f50,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_ID_Start */
+
+/* 'ID_Continue': Derived Property */
+static const OnigCodePoint CR_ID_Continue[] = {
+ 689,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x005f, 0x005f,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00b7, 0x00b7,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0300, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x0483, 0x0487,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0840, 0x085b,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x08e1,
+ 0x08e3, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b6f,
+ 0x0b71, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e4e,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f18, 0x0f19,
+ 0x0f20, 0x0f29,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x1000, 0x1049,
+ 0x1050, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x135f,
+ 0x1369, 0x1371,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1734,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x180b, 0x180d,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1abd,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b59,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1bf3,
+ 0x1c00, 0x1c37,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x203f, 0x2040,
+ 0x2054, 0x2054,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20f0,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x3005, 0x3007,
+ 0x3021, 0x302f,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x3099, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa66f,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa6f1,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa827,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8e0, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa900, 0xa92d,
+ 0xa930, 0xa953,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9c0,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabea,
+ 0xabec, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xfe33, 0xfe34,
+ 0xfe4d, 0xfe4f,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff10, 0xff19,
+ 0xff21, 0xff3a,
+ 0xff3f, 0xff3f,
+ 0xff41, 0xff5a,
+ 0xff66, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x101fd, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102e0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae6,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11000, 0x11046,
+ 0x11066, 0x1106f,
+ 0x1107f, 0x110ba,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x1113f,
+ 0x11150, 0x11173,
+ 0x11176, 0x11176,
+ 0x11180, 0x111c4,
+ 0x111ca, 0x111cc,
+ 0x111d0, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x1144a,
+ 0x11450, 0x11459,
+ 0x11480, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11739,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a99,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af4,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9d, 0x1bc9e,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0xe0100, 0xe01ef,
+}; /* CR_ID_Continue */
+
+/* 'XID_Start': Derived Property */
+static const OnigCodePoint CR_XID_Start[] = {
+ 592,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0620, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06e5, 0x06e6,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0971, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a72, 0x0a74,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0abd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae1,
+ 0x0af9, 0x0af9,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b3d,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b71, 0x0b71,
+ 0x0b83, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e32,
+ 0x0e40, 0x0e46,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb0,
+ 0x0eb2, 0x0eb2,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1711,
+ 0x1720, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1aa7, 0x1aa7,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4b,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf1,
+ 0x1cf5, 0x1cf6,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa67f, 0xa69d,
+ 0xa6a0, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf4,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb1d,
+ 0xfb1f, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfc5d,
+ 0xfc64, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdf9,
+ 0xfe71, 0xfe71,
+ 0xfe73, 0xfe73,
+ 0xfe77, 0xfe77,
+ 0xfe79, 0xfe79,
+ 0xfe7b, 0xfe7b,
+ 0xfe7d, 0xfe7d,
+ 0xfe7f, 0xfefc,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0xff66, 0xff9d,
+ 0xffa0, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11003, 0x11037,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x11700, 0x11719,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a83,
+ 0x11a86, 0x11a89,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f50,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_XID_Start */
+
+/* 'XID_Continue': Derived Property */
+static const OnigCodePoint CR_XID_Continue[] = {
+ 696,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x005f, 0x005f,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00b7, 0x00b7,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0300, 0x0374,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x0483, 0x0487,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0561, 0x0587,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0840, 0x085b,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x08e1,
+ 0x08e3, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b6f,
+ 0x0b71, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e4e,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f18, 0x0f19,
+ 0x0f20, 0x0f29,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x1000, 0x1049,
+ 0x1050, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x135f,
+ 0x1369, 0x1371,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1734,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x180b, 0x180d,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1abd,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b59,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1bf3,
+ 0x1c00, 0x1c37,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c88,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fe0, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffc,
+ 0x203f, 0x2040,
+ 0x2054, 0x2054,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20f0,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2ce4,
+ 0x2ceb, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x3005, 0x3007,
+ 0x3021, 0x302f,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x3099, 0x309a,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31ba,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa66f,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa6f1,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa827,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8e0, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fd,
+ 0xa900, 0xa92d,
+ 0xa930, 0xa953,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9c0,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab65,
+ 0xab70, 0xabea,
+ 0xabec, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfc5d,
+ 0xfc64, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdf9,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xfe33, 0xfe34,
+ 0xfe4d, 0xfe4f,
+ 0xfe71, 0xfe71,
+ 0xfe73, 0xfe73,
+ 0xfe77, 0xfe77,
+ 0xfe79, 0xfe79,
+ 0xfe7b, 0xfe7b,
+ 0xfe7d, 0xfe7d,
+ 0xfe7f, 0xfefc,
+ 0xff10, 0xff19,
+ 0xff21, 0xff3a,
+ 0xff3f, 0xff3f,
+ 0xff41, 0xff5a,
+ 0xff66, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x101fd, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102e0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae6,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x11000, 0x11046,
+ 0x11066, 0x1106f,
+ 0x1107f, 0x110ba,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x1113f,
+ 0x11150, 0x11173,
+ 0x11176, 0x11176,
+ 0x11180, 0x111c4,
+ 0x111ca, 0x111cc,
+ 0x111d0, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x1144a,
+ 0x11450, 0x11459,
+ 0x11480, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11739,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a99,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af4,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9d, 0x1bc9e,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0xe0100, 0xe01ef,
+}; /* CR_XID_Continue */
+
+/* 'Default_Ignorable_Code_Point': Derived Property */
+static const OnigCodePoint CR_Default_Ignorable_Code_Point[] = {
+ 17,
+ 0x00ad, 0x00ad,
+ 0x034f, 0x034f,
+ 0x061c, 0x061c,
+ 0x115f, 0x1160,
+ 0x17b4, 0x17b5,
+ 0x180b, 0x180e,
+ 0x200b, 0x200f,
+ 0x202a, 0x202e,
+ 0x2060, 0x206f,
+ 0x3164, 0x3164,
+ 0xfe00, 0xfe0f,
+ 0xfeff, 0xfeff,
+ 0xffa0, 0xffa0,
+ 0xfff0, 0xfff8,
+ 0x1bca0, 0x1bca3,
+ 0x1d173, 0x1d17a,
+ 0xe0000, 0xe0fff,
+}; /* CR_Default_Ignorable_Code_Point */
+
+/* 'Grapheme_Extend': Derived Property */
+static const OnigCodePoint CR_Grapheme_Extend[] = {
+ 319,
+ 0x0300, 0x036f,
+ 0x0483, 0x0489,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x08d4, 0x08e1,
+ 0x08e3, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x094d, 0x094d,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09be,
+ 0x09c1, 0x09c4,
+ 0x09cd, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0acd, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3e, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b4d, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bbe,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c00,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cbf,
+ 0x0cc2, 0x0cc2,
+ 0x0cc6, 0x0cc6,
+ 0x0ccc, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d3e, 0x0d3e,
+ 0x0d41, 0x0d44,
+ 0x0d4d, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dcf,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0ddf, 0x0ddf,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0eb9,
+ 0x0ebb, 0x0ebc,
+ 0x0ec8, 0x0ecd,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x1039, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1714,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a60, 0x1a60,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b34,
+ 0x1b36, 0x1b3a,
+ 0x1b3c, 0x1b3c,
+ 0x1b42, 0x1b42,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1ba9,
+ 0x1bab, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf1,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1df9,
+ 0x1dfb, 0x1dff,
+ 0x200c, 0x200c,
+ 0x20d0, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302f,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bc,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaec, 0xaaed,
+ 0xaaf6, 0xaaf6,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xff9e, 0xff9f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111ca, 0x111cc,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11234,
+ 0x11236, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133c, 0x1133c,
+ 0x1133e, 0x1133e,
+ 0x11340, 0x11340,
+ 0x11357, 0x11357,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x114b0, 0x114b0,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bd, 0x114bd,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115af, 0x115af,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b5,
+ 0x116b7, 0x116b7,
+ 0x1171d, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x11a01, 0x11a06,
+ 0x11a09, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a99,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f8f, 0x16f92,
+ 0x1bc9d, 0x1bc9e,
+ 0x1d165, 0x1d165,
+ 0x1d167, 0x1d169,
+ 0x1d16e, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+}; /* CR_Grapheme_Extend */
+
+/* 'Grapheme_Base': Derived Property */
+static const OnigCodePoint CR_Grapheme_Base[] = {
+ 791,
+ 0x0020, 0x007e,
+ 0x00a0, 0x00ac,
+ 0x00ae, 0x02ff,
+ 0x0370, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0482,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x05be, 0x05be,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0606, 0x060f,
+ 0x061b, 0x061b,
+ 0x061e, 0x064a,
+ 0x0660, 0x066f,
+ 0x0671, 0x06d5,
+ 0x06de, 0x06de,
+ 0x06e5, 0x06e6,
+ 0x06e9, 0x06e9,
+ 0x06ee, 0x070d,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07c0, 0x07ea,
+ 0x07f4, 0x07fa,
+ 0x0800, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0830, 0x083e,
+ 0x0840, 0x0858,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x0903, 0x0939,
+ 0x093b, 0x093b,
+ 0x093d, 0x0940,
+ 0x0949, 0x094c,
+ 0x094e, 0x0950,
+ 0x0958, 0x0961,
+ 0x0964, 0x0980,
+ 0x0982, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09bf, 0x09c0,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09e6, 0x09fd,
+ 0x0a03, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3e, 0x0a40,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a6f,
+ 0x0a72, 0x0a74,
+ 0x0a83, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0ac0,
+ 0x0ac9, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae1,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0af9,
+ 0x0b02, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b3d,
+ 0x0b40, 0x0b40,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b77,
+ 0x0b83, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbf, 0x0bbf,
+ 0x0bc1, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0bd0, 0x0bd0,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c41, 0x0c44,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c80,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbe,
+ 0x0cc0, 0x0cc1,
+ 0x0cc3, 0x0cc4,
+ 0x0cc7, 0x0cc8,
+ 0x0cca, 0x0ccb,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d3f, 0x0d40,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d4e, 0x0d4f,
+ 0x0d54, 0x0d56,
+ 0x0d58, 0x0d61,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dd0, 0x0dd1,
+ 0x0dd8, 0x0dde,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e3f, 0x0e46,
+ 0x0e4f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f17,
+ 0x0f1a, 0x0f34,
+ 0x0f36, 0x0f36,
+ 0x0f38, 0x0f38,
+ 0x0f3a, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f7f, 0x0f7f,
+ 0x0f85, 0x0f85,
+ 0x0f88, 0x0f8c,
+ 0x0fbe, 0x0fc5,
+ 0x0fc7, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x102c,
+ 0x1031, 0x1031,
+ 0x1038, 0x1038,
+ 0x103b, 0x103c,
+ 0x103f, 0x1057,
+ 0x105a, 0x105d,
+ 0x1061, 0x1070,
+ 0x1075, 0x1081,
+ 0x1083, 0x1084,
+ 0x1087, 0x108c,
+ 0x108e, 0x109c,
+ 0x109e, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x1360, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1711,
+ 0x1720, 0x1731,
+ 0x1735, 0x1736,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17b6, 0x17b6,
+ 0x17be, 0x17c5,
+ 0x17c7, 0x17c8,
+ 0x17d4, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180a,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x1884,
+ 0x1887, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1923, 0x1926,
+ 0x1929, 0x192b,
+ 0x1930, 0x1931,
+ 0x1933, 0x1938,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a16,
+ 0x1a19, 0x1a1a,
+ 0x1a1e, 0x1a55,
+ 0x1a57, 0x1a57,
+ 0x1a61, 0x1a61,
+ 0x1a63, 0x1a64,
+ 0x1a6d, 0x1a72,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b04, 0x1b33,
+ 0x1b35, 0x1b35,
+ 0x1b3b, 0x1b3b,
+ 0x1b3d, 0x1b41,
+ 0x1b43, 0x1b4b,
+ 0x1b50, 0x1b6a,
+ 0x1b74, 0x1b7c,
+ 0x1b82, 0x1ba1,
+ 0x1ba6, 0x1ba7,
+ 0x1baa, 0x1baa,
+ 0x1bae, 0x1be5,
+ 0x1be7, 0x1be7,
+ 0x1bea, 0x1bec,
+ 0x1bee, 0x1bee,
+ 0x1bf2, 0x1bf3,
+ 0x1bfc, 0x1c2b,
+ 0x1c34, 0x1c35,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x1ce1, 0x1ce1,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf7,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x200a,
+ 0x2010, 0x2027,
+ 0x202f, 0x205f,
+ 0x2070, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2e00, 0x2e49,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x3029,
+ 0x3030, 0x303f,
+ 0x3041, 0x3096,
+ 0x309b, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa69d,
+ 0xa6a0, 0xa6ef,
+ 0xa6f2, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa824,
+ 0xa827, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c3,
+ 0xa8ce, 0xa8d9,
+ 0xa8f2, 0xa8fd,
+ 0xa900, 0xa925,
+ 0xa92e, 0xa946,
+ 0xa952, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa983, 0xa9b2,
+ 0xa9b4, 0xa9b5,
+ 0xa9ba, 0xa9bb,
+ 0xa9bd, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9e4,
+ 0xa9e6, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa2f, 0xaa30,
+ 0xaa33, 0xaa34,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa4d, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa7d, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaaeb,
+ 0xaaee, 0xaaf5,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabe4,
+ 0xabe6, 0xabe7,
+ 0xabe9, 0xabec,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb1d,
+ 0xfb1f, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfd,
+ 0xfe10, 0xfe19,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff01, 0xff9d,
+ 0xffa0, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffc, 0xfffd,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fc,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e1, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a40, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae4,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x11000,
+ 0x11002, 0x11037,
+ 0x11047, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11082, 0x110b2,
+ 0x110b7, 0x110b8,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11103, 0x11126,
+ 0x1112c, 0x1112c,
+ 0x11136, 0x11143,
+ 0x11150, 0x11172,
+ 0x11174, 0x11176,
+ 0x11182, 0x111b5,
+ 0x111bf, 0x111c9,
+ 0x111cd, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122e,
+ 0x11232, 0x11233,
+ 0x11235, 0x11235,
+ 0x11238, 0x1123d,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112de,
+ 0x112e0, 0x112e2,
+ 0x112f0, 0x112f9,
+ 0x11302, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x1133f, 0x1133f,
+ 0x11341, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11363,
+ 0x11400, 0x11437,
+ 0x11440, 0x11441,
+ 0x11445, 0x11445,
+ 0x11447, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114af,
+ 0x114b1, 0x114b2,
+ 0x114b9, 0x114b9,
+ 0x114bb, 0x114bc,
+ 0x114be, 0x114be,
+ 0x114c1, 0x114c1,
+ 0x114c4, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115ae,
+ 0x115b0, 0x115b1,
+ 0x115b8, 0x115bb,
+ 0x115be, 0x115be,
+ 0x115c1, 0x115db,
+ 0x11600, 0x11632,
+ 0x1163b, 0x1163c,
+ 0x1163e, 0x1163e,
+ 0x11641, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116aa,
+ 0x116ac, 0x116ac,
+ 0x116ae, 0x116af,
+ 0x116b6, 0x116b6,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x11720, 0x11721,
+ 0x11726, 0x11726,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a00,
+ 0x11a07, 0x11a08,
+ 0x11a0b, 0x11a32,
+ 0x11a39, 0x11a3a,
+ 0x11a3f, 0x11a46,
+ 0x11a50, 0x11a50,
+ 0x11a57, 0x11a58,
+ 0x11a5c, 0x11a83,
+ 0x11a86, 0x11a89,
+ 0x11a97, 0x11a97,
+ 0x11a9a, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2f,
+ 0x11c3e, 0x11c3e,
+ 0x11c40, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11ca9, 0x11ca9,
+ 0x11cb1, 0x11cb1,
+ 0x11cb4, 0x11cb4,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af5, 0x16af5,
+ 0x16b00, 0x16b2f,
+ 0x16b37, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bc9c,
+ 0x1bc9f, 0x1bc9f,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d164,
+ 0x1d166, 0x1d166,
+ 0x1d16a, 0x1d16d,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1e8,
+ 0x1d200, 0x1d241,
+ 0x1d245, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d9ff,
+ 0x1da37, 0x1da3a,
+ 0x1da6d, 0x1da74,
+ 0x1da76, 0x1da83,
+ 0x1da85, 0x1da8b,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8cf,
+ 0x1e900, 0x1e943,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_Grapheme_Base */
+
+/* 'Grapheme_Link': Derived Property */
+static const OnigCodePoint CR_Grapheme_Link[] = {
+ 48,
+ 0x094d, 0x094d,
+ 0x09cd, 0x09cd,
+ 0x0a4d, 0x0a4d,
+ 0x0acd, 0x0acd,
+ 0x0b4d, 0x0b4d,
+ 0x0bcd, 0x0bcd,
+ 0x0c4d, 0x0c4d,
+ 0x0ccd, 0x0ccd,
+ 0x0d3b, 0x0d3c,
+ 0x0d4d, 0x0d4d,
+ 0x0dca, 0x0dca,
+ 0x0e3a, 0x0e3a,
+ 0x0f84, 0x0f84,
+ 0x1039, 0x103a,
+ 0x1714, 0x1714,
+ 0x1734, 0x1734,
+ 0x17d2, 0x17d2,
+ 0x1a60, 0x1a60,
+ 0x1b44, 0x1b44,
+ 0x1baa, 0x1bab,
+ 0x1bf2, 0x1bf3,
+ 0x2d7f, 0x2d7f,
+ 0xa806, 0xa806,
+ 0xa8c4, 0xa8c4,
+ 0xa953, 0xa953,
+ 0xa9c0, 0xa9c0,
+ 0xaaf6, 0xaaf6,
+ 0xabed, 0xabed,
+ 0x10a3f, 0x10a3f,
+ 0x11046, 0x11046,
+ 0x1107f, 0x1107f,
+ 0x110b9, 0x110b9,
+ 0x11133, 0x11134,
+ 0x111c0, 0x111c0,
+ 0x11235, 0x11235,
+ 0x112ea, 0x112ea,
+ 0x1134d, 0x1134d,
+ 0x11442, 0x11442,
+ 0x114c2, 0x114c2,
+ 0x115bf, 0x115bf,
+ 0x1163f, 0x1163f,
+ 0x116b6, 0x116b6,
+ 0x1172b, 0x1172b,
+ 0x11a34, 0x11a34,
+ 0x11a47, 0x11a47,
+ 0x11a99, 0x11a99,
+ 0x11c3f, 0x11c3f,
+ 0x11d44, 0x11d45,
+}; /* CR_Grapheme_Link */
+
+/* 'Common': Script */
+static const OnigCodePoint CR_Common[] = {
+ 164,
+ 0x0000, 0x0040,
+ 0x005b, 0x0060,
+ 0x007b, 0x00a9,
+ 0x00ab, 0x00b9,
+ 0x00bb, 0x00bf,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x02b9, 0x02df,
+ 0x02e5, 0x02e9,
+ 0x02ec, 0x02ff,
+ 0x0374, 0x0374,
+ 0x037e, 0x037e,
+ 0x0385, 0x0385,
+ 0x0387, 0x0387,
+ 0x0589, 0x0589,
+ 0x0605, 0x0605,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0640, 0x0640,
+ 0x06dd, 0x06dd,
+ 0x08e2, 0x08e2,
+ 0x0964, 0x0965,
+ 0x0e3f, 0x0e3f,
+ 0x0fd5, 0x0fd8,
+ 0x10fb, 0x10fb,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x1802, 0x1803,
+ 0x1805, 0x1805,
+ 0x1cd3, 0x1cd3,
+ 0x1ce1, 0x1ce1,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf7,
+ 0x2000, 0x200b,
+ 0x200e, 0x2064,
+ 0x2066, 0x2070,
+ 0x2074, 0x207e,
+ 0x2080, 0x208e,
+ 0x20a0, 0x20bf,
+ 0x2100, 0x2125,
+ 0x2127, 0x2129,
+ 0x212c, 0x2131,
+ 0x2133, 0x214d,
+ 0x214f, 0x215f,
+ 0x2189, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x27ff,
+ 0x2900, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2e00, 0x2e49,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x3004,
+ 0x3006, 0x3006,
+ 0x3008, 0x3020,
+ 0x3030, 0x3037,
+ 0x303c, 0x303f,
+ 0x309b, 0x309c,
+ 0x30a0, 0x30a0,
+ 0x30fb, 0x30fc,
+ 0x3190, 0x319f,
+ 0x31c0, 0x31e3,
+ 0x3220, 0x325f,
+ 0x327f, 0x32cf,
+ 0x3358, 0x33ff,
+ 0x4dc0, 0x4dff,
+ 0xa700, 0xa721,
+ 0xa788, 0xa78a,
+ 0xa830, 0xa839,
+ 0xa92e, 0xa92e,
+ 0xa9cf, 0xa9cf,
+ 0xab5b, 0xab5b,
+ 0xfd3e, 0xfd3f,
+ 0xfe10, 0xfe19,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff20,
+ 0xff3b, 0xff40,
+ 0xff5b, 0xff65,
+ 0xff70, 0xff70,
+ 0xff9e, 0xff9f,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xfffd,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1013f,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fc,
+ 0x102e1, 0x102fb,
+ 0x1bca0, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d166,
+ 0x1d16a, 0x1d17a,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1e8,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f201, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+}; /* CR_Common */
+
+/* 'Latin': Script */
+static const OnigCodePoint CR_Latin[] = {
+ 31,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02b8,
+ 0x02e0, 0x02e4,
+ 0x1d00, 0x1d25,
+ 0x1d2c, 0x1d5c,
+ 0x1d62, 0x1d65,
+ 0x1d6b, 0x1d77,
+ 0x1d79, 0x1dbe,
+ 0x1e00, 0x1eff,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c60, 0x2c7f,
+ 0xa722, 0xa787,
+ 0xa78b, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa7ff,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab64,
+ 0xfb00, 0xfb06,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+}; /* CR_Latin */
+
+/* 'Greek': Script */
+static const OnigCodePoint CR_Greek[] = {
+ 36,
+ 0x0370, 0x0373,
+ 0x0375, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0384, 0x0384,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03e1,
+ 0x03f0, 0x03ff,
+ 0x1d26, 0x1d2a,
+ 0x1d5d, 0x1d61,
+ 0x1d66, 0x1d6a,
+ 0x1dbf, 0x1dbf,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2126, 0x2126,
+ 0xab65, 0xab65,
+ 0x10140, 0x1018e,
+ 0x101a0, 0x101a0,
+ 0x1d200, 0x1d245,
+}; /* CR_Greek */
+
+/* 'Cyrillic': Script */
+static const OnigCodePoint CR_Cyrillic[] = {
+ 8,
+ 0x0400, 0x0484,
+ 0x0487, 0x052f,
+ 0x1c80, 0x1c88,
+ 0x1d2b, 0x1d2b,
+ 0x1d78, 0x1d78,
+ 0x2de0, 0x2dff,
+ 0xa640, 0xa69f,
+ 0xfe2e, 0xfe2f,
+}; /* CR_Cyrillic */
+
+/* 'Armenian': Script */
+static const OnigCodePoint CR_Armenian[] = {
+ 6,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x058a, 0x058a,
+ 0x058d, 0x058f,
+ 0xfb13, 0xfb17,
+}; /* CR_Armenian */
+
+/* 'Hebrew': Script */
+static const OnigCodePoint CR_Hebrew[] = {
+ 9,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfb4f,
+}; /* CR_Hebrew */
+
+/* 'Arabic': Script */
+static const OnigCodePoint CR_Arabic[] = {
+ 57,
+ 0x0600, 0x0604,
+ 0x0606, 0x060b,
+ 0x060d, 0x061a,
+ 0x061c, 0x061c,
+ 0x061e, 0x061e,
+ 0x0620, 0x063f,
+ 0x0641, 0x064a,
+ 0x0656, 0x066f,
+ 0x0671, 0x06dc,
+ 0x06de, 0x06ff,
+ 0x0750, 0x077f,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x08e1,
+ 0x08e3, 0x08ff,
+ 0xfb50, 0xfbc1,
+ 0xfbd3, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfd,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0x10e60, 0x10e7e,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+}; /* CR_Arabic */
+
+/* 'Syriac': Script */
+static const OnigCodePoint CR_Syriac[] = {
+ 4,
+ 0x0700, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x074f,
+ 0x0860, 0x086a,
+}; /* CR_Syriac */
+
+/* 'Thaana': Script */
+static const OnigCodePoint CR_Thaana[] = {
+ 1,
+ 0x0780, 0x07b1,
+}; /* CR_Thaana */
+
+/* 'Devanagari': Script */
+static const OnigCodePoint CR_Devanagari[] = {
+ 4,
+ 0x0900, 0x0950,
+ 0x0953, 0x0963,
+ 0x0966, 0x097f,
+ 0xa8e0, 0xa8fd,
+}; /* CR_Devanagari */
+
+/* 'Bengali': Script */
+static const OnigCodePoint CR_Bengali[] = {
+ 14,
+ 0x0980, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fd,
+}; /* CR_Bengali */
+
+/* 'Gurmukhi': Script */
+static const OnigCodePoint CR_Gurmukhi[] = {
+ 16,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+}; /* CR_Gurmukhi */
+
+/* 'Gujarati': Script */
+static const OnigCodePoint CR_Gujarati[] = {
+ 14,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0aff,
+}; /* CR_Gujarati */
+
+/* 'Oriya': Script */
+static const OnigCodePoint CR_Oriya[] = {
+ 14,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+}; /* CR_Oriya */
+
+/* 'Tamil': Script */
+static const OnigCodePoint CR_Tamil[] = {
+ 16,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+}; /* CR_Tamil */
+
+/* 'Telugu': Script */
+static const OnigCodePoint CR_Telugu[] = {
+ 13,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+}; /* CR_Telugu */
+
+/* 'Kannada': Script */
+static const OnigCodePoint CR_Kannada[] = {
+ 14,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+}; /* CR_Kannada */
+
+/* 'Malayalam': Script */
+static const OnigCodePoint CR_Malayalam[] = {
+ 8,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+}; /* CR_Malayalam */
+
+/* 'Sinhala': Script */
+static const OnigCodePoint CR_Sinhala[] = {
+ 13,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x111e1, 0x111f4,
+}; /* CR_Sinhala */
+
+/* 'Thai': Script */
+static const OnigCodePoint CR_Thai[] = {
+ 2,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e5b,
+}; /* CR_Thai */
+
+/* 'Lao': Script */
+static const OnigCodePoint CR_Lao[] = {
+ 18,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+}; /* CR_Lao */
+
+/* 'Tibetan': Script */
+static const OnigCodePoint CR_Tibetan[] = {
+ 7,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fd4,
+ 0x0fd9, 0x0fda,
+}; /* CR_Tibetan */
+
+/* 'Myanmar': Script */
+static const OnigCodePoint CR_Myanmar[] = {
+ 3,
+ 0x1000, 0x109f,
+ 0xa9e0, 0xa9fe,
+ 0xaa60, 0xaa7f,
+}; /* CR_Myanmar */
+
+/* 'Georgian': Script */
+static const OnigCodePoint CR_Georgian[] = {
+ 8,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x10ff,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+}; /* CR_Georgian */
+
+/* 'Hangul': Script */
+static const OnigCodePoint CR_Hangul[] = {
+ 14,
+ 0x1100, 0x11ff,
+ 0x302e, 0x302f,
+ 0x3131, 0x318e,
+ 0x3200, 0x321e,
+ 0x3260, 0x327e,
+ 0xa960, 0xa97c,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xffa0, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+}; /* CR_Hangul */
+
+/* 'Ethiopic': Script */
+static const OnigCodePoint CR_Ethiopic[] = {
+ 32,
+ 0x1200, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+}; /* CR_Ethiopic */
+
+/* 'Cherokee': Script */
+static const OnigCodePoint CR_Cherokee[] = {
+ 3,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0xab70, 0xabbf,
+}; /* CR_Cherokee */
+
+/* 'Canadian_Aboriginal': Script */
+static const OnigCodePoint CR_Canadian_Aboriginal[] = {
+ 2,
+ 0x1400, 0x167f,
+ 0x18b0, 0x18f5,
+}; /* CR_Canadian_Aboriginal */
+
+/* 'Ogham': Script */
+static const OnigCodePoint CR_Ogham[] = {
+ 1,
+ 0x1680, 0x169c,
+}; /* CR_Ogham */
+
+/* 'Runic': Script */
+static const OnigCodePoint CR_Runic[] = {
+ 2,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+}; /* CR_Runic */
+
+/* 'Khmer': Script */
+static const OnigCodePoint CR_Khmer[] = {
+ 4,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x19e0, 0x19ff,
+}; /* CR_Khmer */
+
+/* 'Mongolian': Script */
+static const OnigCodePoint CR_Mongolian[] = {
+ 7,
+ 0x1800, 0x1801,
+ 0x1804, 0x1804,
+ 0x1806, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x11660, 0x1166c,
+}; /* CR_Mongolian */
+
+/* 'Hiragana': Script */
+static const OnigCodePoint CR_Hiragana[] = {
+ 4,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x1b001, 0x1b11e,
+ 0x1f200, 0x1f200,
+}; /* CR_Hiragana */
+
+/* 'Katakana': Script */
+static const OnigCodePoint CR_Katakana[] = {
+ 8,
+ 0x30a1, 0x30fa,
+ 0x30fd, 0x30ff,
+ 0x31f0, 0x31ff,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3357,
+ 0xff66, 0xff6f,
+ 0xff71, 0xff9d,
+ 0x1b000, 0x1b000,
+}; /* CR_Katakana */
+
+/* 'Bopomofo': Script */
+static const OnigCodePoint CR_Bopomofo[] = {
+ 3,
+ 0x02ea, 0x02eb,
+ 0x3105, 0x312e,
+ 0x31a0, 0x31ba,
+}; /* CR_Bopomofo */
+
+/* 'Han': Script */
+static const OnigCodePoint CR_Han[] = {
+ 17,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x3005, 0x3005,
+ 0x3007, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303b,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_Han */
+
+/* 'Yi': Script */
+static const OnigCodePoint CR_Yi[] = {
+ 2,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+}; /* CR_Yi */
+
+/* 'Old_Italic': Script */
+static const OnigCodePoint CR_Old_Italic[] = {
+ 2,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1032f,
+}; /* CR_Old_Italic */
+
+/* 'Gothic': Script */
+static const OnigCodePoint CR_Gothic[] = {
+ 1,
+ 0x10330, 0x1034a,
+}; /* CR_Gothic */
+
+/* 'Deseret': Script */
+static const OnigCodePoint CR_Deseret[] = {
+ 1,
+ 0x10400, 0x1044f,
+}; /* CR_Deseret */
+
+/* 'Inherited': Script */
+static const OnigCodePoint CR_Inherited[] = {
+ 27,
+ 0x0300, 0x036f,
+ 0x0485, 0x0486,
+ 0x064b, 0x0655,
+ 0x0670, 0x0670,
+ 0x0951, 0x0952,
+ 0x1ab0, 0x1abe,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1df9,
+ 0x1dfb, 0x1dff,
+ 0x200c, 0x200d,
+ 0x20d0, 0x20f0,
+ 0x302a, 0x302d,
+ 0x3099, 0x309a,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2d,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x1d167, 0x1d169,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0xe0100, 0xe01ef,
+}; /* CR_Inherited */
+
+/* 'Tagalog': Script */
+static const OnigCodePoint CR_Tagalog[] = {
+ 2,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+}; /* CR_Tagalog */
+
+/* 'Hanunoo': Script */
+static const OnigCodePoint CR_Hanunoo[] = {
+ 1,
+ 0x1720, 0x1734,
+}; /* CR_Hanunoo */
+
+/* 'Buhid': Script */
+static const OnigCodePoint CR_Buhid[] = {
+ 1,
+ 0x1740, 0x1753,
+}; /* CR_Buhid */
+
+/* 'Tagbanwa': Script */
+static const OnigCodePoint CR_Tagbanwa[] = {
+ 3,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+}; /* CR_Tagbanwa */
+
+/* 'Limbu': Script */
+static const OnigCodePoint CR_Limbu[] = {
+ 5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x194f,
+}; /* CR_Limbu */
+
+/* 'Tai_Le': Script */
+static const OnigCodePoint CR_Tai_Le[] = {
+ 2,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+}; /* CR_Tai_Le */
+
+/* 'Linear_B': Script */
+static const OnigCodePoint CR_Linear_B[] = {
+ 7,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+}; /* CR_Linear_B */
+
+/* 'Ugaritic': Script */
+static const OnigCodePoint CR_Ugaritic[] = {
+ 2,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x1039f,
+}; /* CR_Ugaritic */
+
+/* 'Shavian': Script */
+static const OnigCodePoint CR_Shavian[] = {
+ 1,
+ 0x10450, 0x1047f,
+}; /* CR_Shavian */
+
+/* 'Osmanya': Script */
+static const OnigCodePoint CR_Osmanya[] = {
+ 2,
+ 0x10480, 0x1049d,
+ 0x104a0, 0x104a9,
+}; /* CR_Osmanya */
+
+/* 'Cypriot': Script */
+static const OnigCodePoint CR_Cypriot[] = {
+ 6,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x1083f,
+}; /* CR_Cypriot */
+
+/* 'Braille': Script */
+static const OnigCodePoint CR_Braille[] = {
+ 1,
+ 0x2800, 0x28ff,
+}; /* CR_Braille */
+
+/* 'Buginese': Script */
+static const OnigCodePoint CR_Buginese[] = {
+ 2,
+ 0x1a00, 0x1a1b,
+ 0x1a1e, 0x1a1f,
+}; /* CR_Buginese */
+
+/* 'Coptic': Script */
+static const OnigCodePoint CR_Coptic[] = {
+ 3,
+ 0x03e2, 0x03ef,
+ 0x2c80, 0x2cf3,
+ 0x2cf9, 0x2cff,
+}; /* CR_Coptic */
+
+/* 'New_Tai_Lue': Script */
+static const OnigCodePoint CR_New_Tai_Lue[] = {
+ 4,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x19df,
+}; /* CR_New_Tai_Lue */
+
+/* 'Glagolitic': Script */
+static const OnigCodePoint CR_Glagolitic[] = {
+ 7,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+}; /* CR_Glagolitic */
+
+/* 'Tifinagh': Script */
+static const OnigCodePoint CR_Tifinagh[] = {
+ 3,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d7f,
+}; /* CR_Tifinagh */
+
+/* 'Syloti_Nagri': Script */
+static const OnigCodePoint CR_Syloti_Nagri[] = {
+ 1,
+ 0xa800, 0xa82b,
+}; /* CR_Syloti_Nagri */
+
+/* 'Old_Persian': Script */
+static const OnigCodePoint CR_Old_Persian[] = {
+ 2,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103d5,
+}; /* CR_Old_Persian */
+
+/* 'Kharoshthi': Script */
+static const OnigCodePoint CR_Kharoshthi[] = {
+ 8,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+}; /* CR_Kharoshthi */
+
+/* 'Balinese': Script */
+static const OnigCodePoint CR_Balinese[] = {
+ 2,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+}; /* CR_Balinese */
+
+/* 'Cuneiform': Script */
+static const OnigCodePoint CR_Cuneiform[] = {
+ 4,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+}; /* CR_Cuneiform */
+
+/* 'Phoenician': Script */
+static const OnigCodePoint CR_Phoenician[] = {
+ 2,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x1091f,
+}; /* CR_Phoenician */
+
+/* 'Phags_Pa': Script */
+static const OnigCodePoint CR_Phags_Pa[] = {
+ 1,
+ 0xa840, 0xa877,
+}; /* CR_Phags_Pa */
+
+/* 'Nko': Script */
+static const OnigCodePoint CR_Nko[] = {
+ 1,
+ 0x07c0, 0x07fa,
+}; /* CR_Nko */
+
+/* 'Sundanese': Script */
+static const OnigCodePoint CR_Sundanese[] = {
+ 2,
+ 0x1b80, 0x1bbf,
+ 0x1cc0, 0x1cc7,
+}; /* CR_Sundanese */
+
+/* 'Lepcha': Script */
+static const OnigCodePoint CR_Lepcha[] = {
+ 3,
+ 0x1c00, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c4f,
+}; /* CR_Lepcha */
+
+/* 'Ol_Chiki': Script */
+static const OnigCodePoint CR_Ol_Chiki[] = {
+ 1,
+ 0x1c50, 0x1c7f,
+}; /* CR_Ol_Chiki */
+
+/* 'Vai': Script */
+static const OnigCodePoint CR_Vai[] = {
+ 1,
+ 0xa500, 0xa62b,
+}; /* CR_Vai */
+
+/* 'Saurashtra': Script */
+static const OnigCodePoint CR_Saurashtra[] = {
+ 2,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+}; /* CR_Saurashtra */
+
+/* 'Kayah_Li': Script */
+static const OnigCodePoint CR_Kayah_Li[] = {
+ 2,
+ 0xa900, 0xa92d,
+ 0xa92f, 0xa92f,
+}; /* CR_Kayah_Li */
+
+/* 'Rejang': Script */
+static const OnigCodePoint CR_Rejang[] = {
+ 2,
+ 0xa930, 0xa953,
+ 0xa95f, 0xa95f,
+}; /* CR_Rejang */
+
+/* 'Lycian': Script */
+static const OnigCodePoint CR_Lycian[] = {
+ 1,
+ 0x10280, 0x1029c,
+}; /* CR_Lycian */
+
+/* 'Carian': Script */
+static const OnigCodePoint CR_Carian[] = {
+ 1,
+ 0x102a0, 0x102d0,
+}; /* CR_Carian */
+
+/* 'Lydian': Script */
+static const OnigCodePoint CR_Lydian[] = {
+ 2,
+ 0x10920, 0x10939,
+ 0x1093f, 0x1093f,
+}; /* CR_Lydian */
+
+/* 'Cham': Script */
+static const OnigCodePoint CR_Cham[] = {
+ 4,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa5f,
+}; /* CR_Cham */
+
+/* 'Tai_Tham': Script */
+static const OnigCodePoint CR_Tai_Tham[] = {
+ 5,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+}; /* CR_Tai_Tham */
+
+/* 'Tai_Viet': Script */
+static const OnigCodePoint CR_Tai_Viet[] = {
+ 2,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaadf,
+}; /* CR_Tai_Viet */
+
+/* 'Avestan': Script */
+static const OnigCodePoint CR_Avestan[] = {
+ 2,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b3f,
+}; /* CR_Avestan */
+
+/* 'Egyptian_Hieroglyphs': Script */
+static const OnigCodePoint CR_Egyptian_Hieroglyphs[] = {
+ 1,
+ 0x13000, 0x1342e,
+}; /* CR_Egyptian_Hieroglyphs */
+
+/* 'Samaritan': Script */
+static const OnigCodePoint CR_Samaritan[] = {
+ 2,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+}; /* CR_Samaritan */
+
+/* 'Lisu': Script */
+static const OnigCodePoint CR_Lisu[] = {
+ 1,
+ 0xa4d0, 0xa4ff,
+}; /* CR_Lisu */
+
+/* 'Bamum': Script */
+static const OnigCodePoint CR_Bamum[] = {
+ 2,
+ 0xa6a0, 0xa6f7,
+ 0x16800, 0x16a38,
+}; /* CR_Bamum */
+
+/* 'Javanese': Script */
+static const OnigCodePoint CR_Javanese[] = {
+ 3,
+ 0xa980, 0xa9cd,
+ 0xa9d0, 0xa9d9,
+ 0xa9de, 0xa9df,
+}; /* CR_Javanese */
+
+/* 'Meetei_Mayek': Script */
+static const OnigCodePoint CR_Meetei_Mayek[] = {
+ 3,
+ 0xaae0, 0xaaf6,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+}; /* CR_Meetei_Mayek */
+
+/* 'Imperial_Aramaic': Script */
+static const OnigCodePoint CR_Imperial_Aramaic[] = {
+ 2,
+ 0x10840, 0x10855,
+ 0x10857, 0x1085f,
+}; /* CR_Imperial_Aramaic */
+
+/* 'Old_South_Arabian': Script */
+static const OnigCodePoint CR_Old_South_Arabian[] = {
+ 1,
+ 0x10a60, 0x10a7f,
+}; /* CR_Old_South_Arabian */
+
+/* 'Inscriptional_Parthian': Script */
+static const OnigCodePoint CR_Inscriptional_Parthian[] = {
+ 2,
+ 0x10b40, 0x10b55,
+ 0x10b58, 0x10b5f,
+}; /* CR_Inscriptional_Parthian */
+
+/* 'Inscriptional_Pahlavi': Script */
+static const OnigCodePoint CR_Inscriptional_Pahlavi[] = {
+ 2,
+ 0x10b60, 0x10b72,
+ 0x10b78, 0x10b7f,
+}; /* CR_Inscriptional_Pahlavi */
+
+/* 'Old_Turkic': Script */
+static const OnigCodePoint CR_Old_Turkic[] = {
+ 1,
+ 0x10c00, 0x10c48,
+}; /* CR_Old_Turkic */
+
+/* 'Kaithi': Script */
+static const OnigCodePoint CR_Kaithi[] = {
+ 1,
+ 0x11080, 0x110c1,
+}; /* CR_Kaithi */
+
+/* 'Batak': Script */
+static const OnigCodePoint CR_Batak[] = {
+ 2,
+ 0x1bc0, 0x1bf3,
+ 0x1bfc, 0x1bff,
+}; /* CR_Batak */
+
+/* 'Brahmi': Script */
+static const OnigCodePoint CR_Brahmi[] = {
+ 3,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x1107f,
+}; /* CR_Brahmi */
+
+/* 'Mandaic': Script */
+static const OnigCodePoint CR_Mandaic[] = {
+ 2,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+}; /* CR_Mandaic */
+
+/* 'Chakma': Script */
+static const OnigCodePoint CR_Chakma[] = {
+ 2,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+}; /* CR_Chakma */
+
+/* 'Meroitic_Cursive': Script */
+static const OnigCodePoint CR_Meroitic_Cursive[] = {
+ 3,
+ 0x109a0, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x109ff,
+}; /* CR_Meroitic_Cursive */
+
+/* 'Meroitic_Hieroglyphs': Script */
+static const OnigCodePoint CR_Meroitic_Hieroglyphs[] = {
+ 1,
+ 0x10980, 0x1099f,
+}; /* CR_Meroitic_Hieroglyphs */
+
+/* 'Miao': Script */
+static const OnigCodePoint CR_Miao[] = {
+ 3,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+}; /* CR_Miao */
+
+/* 'Sharada': Script */
+static const OnigCodePoint CR_Sharada[] = {
+ 2,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+}; /* CR_Sharada */
+
+/* 'Sora_Sompeng': Script */
+static const OnigCodePoint CR_Sora_Sompeng[] = {
+ 2,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+}; /* CR_Sora_Sompeng */
+
+/* 'Takri': Script */
+static const OnigCodePoint CR_Takri[] = {
+ 2,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+}; /* CR_Takri */
+
+/* 'Caucasian_Albanian': Script */
+static const OnigCodePoint CR_Caucasian_Albanian[] = {
+ 2,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+}; /* CR_Caucasian_Albanian */
+
+/* 'Bassa_Vah': Script */
+static const OnigCodePoint CR_Bassa_Vah[] = {
+ 2,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+}; /* CR_Bassa_Vah */
+
+/* 'Duployan': Script */
+static const OnigCodePoint CR_Duployan[] = {
+ 5,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bc9f,
+}; /* CR_Duployan */
+
+/* 'Elbasan': Script */
+static const OnigCodePoint CR_Elbasan[] = {
+ 1,
+ 0x10500, 0x10527,
+}; /* CR_Elbasan */
+
+/* 'Grantha': Script */
+static const OnigCodePoint CR_Grantha[] = {
+ 15,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+}; /* CR_Grantha */
+
+/* 'Pahawh_Hmong': Script */
+static const OnigCodePoint CR_Pahawh_Hmong[] = {
+ 5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+}; /* CR_Pahawh_Hmong */
+
+/* 'Khojki': Script */
+static const OnigCodePoint CR_Khojki[] = {
+ 2,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+}; /* CR_Khojki */
+
+/* 'Linear_A': Script */
+static const OnigCodePoint CR_Linear_A[] = {
+ 3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+}; /* CR_Linear_A */
+
+/* 'Mahajani': Script */
+static const OnigCodePoint CR_Mahajani[] = {
+ 1,
+ 0x11150, 0x11176,
+}; /* CR_Mahajani */
+
+/* 'Manichaean': Script */
+static const OnigCodePoint CR_Manichaean[] = {
+ 2,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+}; /* CR_Manichaean */
+
+/* 'Mende_Kikakui': Script */
+static const OnigCodePoint CR_Mende_Kikakui[] = {
+ 2,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+}; /* CR_Mende_Kikakui */
+
+/* 'Modi': Script */
+static const OnigCodePoint CR_Modi[] = {
+ 2,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+}; /* CR_Modi */
+
+/* 'Mro': Script */
+static const OnigCodePoint CR_Mro[] = {
+ 3,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+}; /* CR_Mro */
+
+/* 'Old_North_Arabian': Script */
+static const OnigCodePoint CR_Old_North_Arabian[] = {
+ 1,
+ 0x10a80, 0x10a9f,
+}; /* CR_Old_North_Arabian */
+
+/* 'Nabataean': Script */
+static const OnigCodePoint CR_Nabataean[] = {
+ 2,
+ 0x10880, 0x1089e,
+ 0x108a7, 0x108af,
+}; /* CR_Nabataean */
+
+/* 'Palmyrene': Script */
+static const OnigCodePoint CR_Palmyrene[] = {
+ 1,
+ 0x10860, 0x1087f,
+}; /* CR_Palmyrene */
+
+/* 'Pau_Cin_Hau': Script */
+static const OnigCodePoint CR_Pau_Cin_Hau[] = {
+ 1,
+ 0x11ac0, 0x11af8,
+}; /* CR_Pau_Cin_Hau */
+
+/* 'Old_Permic': Script */
+static const OnigCodePoint CR_Old_Permic[] = {
+ 1,
+ 0x10350, 0x1037a,
+}; /* CR_Old_Permic */
+
+/* 'Psalter_Pahlavi': Script */
+static const OnigCodePoint CR_Psalter_Pahlavi[] = {
+ 3,
+ 0x10b80, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+}; /* CR_Psalter_Pahlavi */
+
+/* 'Siddham': Script */
+static const OnigCodePoint CR_Siddham[] = {
+ 2,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+}; /* CR_Siddham */
+
+/* 'Khudawadi': Script */
+static const OnigCodePoint CR_Khudawadi[] = {
+ 2,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+}; /* CR_Khudawadi */
+
+/* 'Tirhuta': Script */
+static const OnigCodePoint CR_Tirhuta[] = {
+ 2,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+}; /* CR_Tirhuta */
+
+/* 'Warang_Citi': Script */
+static const OnigCodePoint CR_Warang_Citi[] = {
+ 2,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+}; /* CR_Warang_Citi */
+
+/* 'Ahom': Script */
+static const OnigCodePoint CR_Ahom[] = {
+ 3,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+}; /* CR_Ahom */
+
+/* 'Anatolian_Hieroglyphs': Script */
+static const OnigCodePoint CR_Anatolian_Hieroglyphs[] = {
+ 1,
+ 0x14400, 0x14646,
+}; /* CR_Anatolian_Hieroglyphs */
+
+/* 'Hatran': Script */
+static const OnigCodePoint CR_Hatran[] = {
+ 3,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x108ff,
+}; /* CR_Hatran */
+
+/* 'Multani': Script */
+static const OnigCodePoint CR_Multani[] = {
+ 5,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+}; /* CR_Multani */
+
+/* 'Old_Hungarian': Script */
+static const OnigCodePoint CR_Old_Hungarian[] = {
+ 3,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+}; /* CR_Old_Hungarian */
+
+/* 'SignWriting': Script */
+static const OnigCodePoint CR_SignWriting[] = {
+ 3,
+ 0x1d800, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+}; /* CR_SignWriting */
+
+/* 'Adlam': Script */
+static const OnigCodePoint CR_Adlam[] = {
+ 3,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+}; /* CR_Adlam */
+
+/* 'Bhaiksuki': Script */
+static const OnigCodePoint CR_Bhaiksuki[] = {
+ 4,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+}; /* CR_Bhaiksuki */
+
+/* 'Marchen': Script */
+static const OnigCodePoint CR_Marchen[] = {
+ 3,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+}; /* CR_Marchen */
+
+/* 'Newa': Script */
+static const OnigCodePoint CR_Newa[] = {
+ 3,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+}; /* CR_Newa */
+
+/* 'Osage': Script */
+static const OnigCodePoint CR_Osage[] = {
+ 2,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+}; /* CR_Osage */
+
+/* 'Tangut': Script */
+static const OnigCodePoint CR_Tangut[] = {
+ 3,
+ 0x16fe0, 0x16fe0,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+}; /* CR_Tangut */
+
+/* 'Masaram_Gondi': Script */
+static const OnigCodePoint CR_Masaram_Gondi[] = {
+ 7,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+}; /* CR_Masaram_Gondi */
+
+/* 'Nushu': Script */
+static const OnigCodePoint CR_Nushu[] = {
+ 2,
+ 0x16fe1, 0x16fe1,
+ 0x1b170, 0x1b2fb,
+}; /* CR_Nushu */
+
+/* 'Soyombo': Script */
+static const OnigCodePoint CR_Soyombo[] = {
+ 3,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+}; /* CR_Soyombo */
+
+/* 'Zanabazar_Square': Script */
+static const OnigCodePoint CR_Zanabazar_Square[] = {
+ 1,
+ 0x11a00, 0x11a47,
+}; /* CR_Zanabazar_Square */
+
+/* 'White_Space': Binary Property */
+#define CR_White_Space CR_Space
+
+/* 'Bidi_Control': Binary Property */
+static const OnigCodePoint CR_Bidi_Control[] = {
+ 4,
+ 0x061c, 0x061c,
+ 0x200e, 0x200f,
+ 0x202a, 0x202e,
+ 0x2066, 0x2069,
+}; /* CR_Bidi_Control */
+
+/* 'Join_Control': Binary Property */
+static const OnigCodePoint CR_Join_Control[] = {
+ 1,
+ 0x200c, 0x200d,
+}; /* CR_Join_Control */
+
+/* 'Dash': Binary Property */
+static const OnigCodePoint CR_Dash[] = {
+ 21,
+ 0x002d, 0x002d,
+ 0x058a, 0x058a,
+ 0x05be, 0x05be,
+ 0x1400, 0x1400,
+ 0x1806, 0x1806,
+ 0x2010, 0x2015,
+ 0x2053, 0x2053,
+ 0x207b, 0x207b,
+ 0x208b, 0x208b,
+ 0x2212, 0x2212,
+ 0x2e17, 0x2e17,
+ 0x2e1a, 0x2e1a,
+ 0x2e3a, 0x2e3b,
+ 0x2e40, 0x2e40,
+ 0x301c, 0x301c,
+ 0x3030, 0x3030,
+ 0x30a0, 0x30a0,
+ 0xfe31, 0xfe32,
+ 0xfe58, 0xfe58,
+ 0xfe63, 0xfe63,
+ 0xff0d, 0xff0d,
+}; /* CR_Dash */
+
+/* 'Hyphen': Binary Property */
+static const OnigCodePoint CR_Hyphen[] = {
+ 10,
+ 0x002d, 0x002d,
+ 0x00ad, 0x00ad,
+ 0x058a, 0x058a,
+ 0x1806, 0x1806,
+ 0x2010, 0x2011,
+ 0x2e17, 0x2e17,
+ 0x30fb, 0x30fb,
+ 0xfe63, 0xfe63,
+ 0xff0d, 0xff0d,
+ 0xff65, 0xff65,
+}; /* CR_Hyphen */
+
+/* 'Quotation_Mark': Binary Property */
+static const OnigCodePoint CR_Quotation_Mark[] = {
+ 13,
+ 0x0022, 0x0022,
+ 0x0027, 0x0027,
+ 0x00ab, 0x00ab,
+ 0x00bb, 0x00bb,
+ 0x2018, 0x201f,
+ 0x2039, 0x203a,
+ 0x2e42, 0x2e42,
+ 0x300c, 0x300f,
+ 0x301d, 0x301f,
+ 0xfe41, 0xfe44,
+ 0xff02, 0xff02,
+ 0xff07, 0xff07,
+ 0xff62, 0xff63,
+}; /* CR_Quotation_Mark */
+
+/* 'Terminal_Punctuation': Binary Property */
+static const OnigCodePoint CR_Terminal_Punctuation[] = {
+ 97,
+ 0x0021, 0x0021,
+ 0x002c, 0x002c,
+ 0x002e, 0x002e,
+ 0x003a, 0x003b,
+ 0x003f, 0x003f,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x0589, 0x0589,
+ 0x05c3, 0x05c3,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070a,
+ 0x070c, 0x070c,
+ 0x07f8, 0x07f9,
+ 0x0830, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0e5a, 0x0e5b,
+ 0x0f08, 0x0f08,
+ 0x0f0d, 0x0f12,
+ 0x104a, 0x104b,
+ 0x1361, 0x1368,
+ 0x166d, 0x166e,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17da, 0x17da,
+ 0x1802, 0x1805,
+ 0x1808, 0x1809,
+ 0x1944, 0x1945,
+ 0x1aa8, 0x1aab,
+ 0x1b5a, 0x1b5b,
+ 0x1b5d, 0x1b5f,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x203c, 0x203d,
+ 0x2047, 0x2049,
+ 0x2e2e, 0x2e2e,
+ 0x2e3c, 0x2e3c,
+ 0x2e41, 0x2e41,
+ 0x3001, 0x3002,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa6f3, 0xa6f7,
+ 0xa876, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa92f, 0xa92f,
+ 0xa9c7, 0xa9c9,
+ 0xaa5d, 0xaa5f,
+ 0xaadf, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 0xfe50, 0xfe52,
+ 0xfe54, 0xfe57,
+ 0xff01, 0xff01,
+ 0xff0c, 0xff0c,
+ 0xff0e, 0xff0e,
+ 0xff1a, 0xff1b,
+ 0xff1f, 0xff1f,
+ 0xff61, 0xff61,
+ 0xff64, 0xff64,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x10a56, 0x10a57,
+ 0x10af0, 0x10af5,
+ 0x10b3a, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x11047, 0x1104d,
+ 0x110be, 0x110c1,
+ 0x11141, 0x11143,
+ 0x111c5, 0x111c6,
+ 0x111cd, 0x111cd,
+ 0x111de, 0x111df,
+ 0x11238, 0x1123c,
+ 0x112a9, 0x112a9,
+ 0x1144b, 0x1144d,
+ 0x1145b, 0x1145b,
+ 0x115c2, 0x115c5,
+ 0x115c9, 0x115d7,
+ 0x11641, 0x11642,
+ 0x1173c, 0x1173e,
+ 0x11a42, 0x11a43,
+ 0x11a9b, 0x11a9c,
+ 0x11aa1, 0x11aa2,
+ 0x11c41, 0x11c43,
+ 0x11c71, 0x11c71,
+ 0x12470, 0x12474,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b39,
+ 0x16b44, 0x16b44,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8a,
+}; /* CR_Terminal_Punctuation */
+
+/* 'Other_Math': Binary Property */
+static const OnigCodePoint CR_Other_Math[] = {
+ 134,
+ 0x005e, 0x005e,
+ 0x03d0, 0x03d2,
+ 0x03d5, 0x03d5,
+ 0x03f0, 0x03f1,
+ 0x03f4, 0x03f5,
+ 0x2016, 0x2016,
+ 0x2032, 0x2034,
+ 0x2040, 0x2040,
+ 0x2061, 0x2064,
+ 0x207d, 0x207e,
+ 0x208d, 0x208e,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20e6,
+ 0x20eb, 0x20ef,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2128, 0x2129,
+ 0x212c, 0x212d,
+ 0x212f, 0x2131,
+ 0x2133, 0x2138,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x2195, 0x2199,
+ 0x219c, 0x219f,
+ 0x21a1, 0x21a2,
+ 0x21a4, 0x21a5,
+ 0x21a7, 0x21a7,
+ 0x21a9, 0x21ad,
+ 0x21b0, 0x21b1,
+ 0x21b6, 0x21b7,
+ 0x21bc, 0x21cd,
+ 0x21d0, 0x21d1,
+ 0x21d3, 0x21d3,
+ 0x21d5, 0x21db,
+ 0x21dd, 0x21dd,
+ 0x21e4, 0x21e5,
+ 0x2308, 0x230b,
+ 0x23b4, 0x23b5,
+ 0x23b7, 0x23b7,
+ 0x23d0, 0x23d0,
+ 0x23e2, 0x23e2,
+ 0x25a0, 0x25a1,
+ 0x25ae, 0x25b6,
+ 0x25bc, 0x25c0,
+ 0x25c6, 0x25c7,
+ 0x25ca, 0x25cb,
+ 0x25cf, 0x25d3,
+ 0x25e2, 0x25e2,
+ 0x25e4, 0x25e4,
+ 0x25e7, 0x25ec,
+ 0x2605, 0x2606,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2660, 0x2663,
+ 0x266d, 0x266e,
+ 0x27c5, 0x27c6,
+ 0x27e6, 0x27ef,
+ 0x2983, 0x2998,
+ 0x29d8, 0x29db,
+ 0x29fc, 0x29fd,
+ 0xfe61, 0xfe61,
+ 0xfe63, 0xfe63,
+ 0xfe68, 0xfe68,
+ 0xff3c, 0xff3c,
+ 0xff3e, 0xff3e,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d6c0,
+ 0x1d6c2, 0x1d6da,
+ 0x1d6dc, 0x1d6fa,
+ 0x1d6fc, 0x1d714,
+ 0x1d716, 0x1d734,
+ 0x1d736, 0x1d74e,
+ 0x1d750, 0x1d76e,
+ 0x1d770, 0x1d788,
+ 0x1d78a, 0x1d7a8,
+ 0x1d7aa, 0x1d7c2,
+ 0x1d7c4, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+}; /* CR_Other_Math */
+
+/* 'Hex_Digit': Binary Property */
+static const OnigCodePoint CR_Hex_Digit[] = {
+ 6,
+ 0x0030, 0x0039,
+ 0x0041, 0x0046,
+ 0x0061, 0x0066,
+ 0xff10, 0xff19,
+ 0xff21, 0xff26,
+ 0xff41, 0xff46,
+}; /* CR_Hex_Digit */
+
+/* 'ASCII_Hex_Digit': Binary Property */
+#define CR_ASCII_Hex_Digit CR_XDigit
+
+/* 'Other_Alphabetic': Binary Property */
+static const OnigCodePoint CR_Other_Alphabetic[] = {
+ 206,
+ 0x0345, 0x0345,
+ 0x05b0, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x0657,
+ 0x0659, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06e1, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ed, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x073f,
+ 0x07a6, 0x07b0,
+ 0x0816, 0x0817,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082c,
+ 0x08d4, 0x08df,
+ 0x08e3, 0x08e9,
+ 0x08f0, 0x0903,
+ 0x093a, 0x093b,
+ 0x093e, 0x094c,
+ 0x094e, 0x094f,
+ 0x0955, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0983,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x0a01, 0x0a03,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4c,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0abe, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0afc,
+ 0x0b01, 0x0b03,
+ 0x0b3e, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b56, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c03,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4c,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c83,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccc,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d03,
+ 0x0d3e, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0d82, 0x0d83,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e4d, 0x0e4d,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0eb9,
+ 0x0ebb, 0x0ebc,
+ 0x0ecd, 0x0ecd,
+ 0x0f71, 0x0f81,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x102b, 0x1036,
+ 0x1038, 0x1038,
+ 0x103b, 0x103e,
+ 0x1056, 0x1059,
+ 0x105e, 0x1060,
+ 0x1062, 0x1062,
+ 0x1067, 0x1068,
+ 0x1071, 0x1074,
+ 0x1082, 0x1086,
+ 0x109c, 0x109d,
+ 0x135f, 0x135f,
+ 0x1712, 0x1713,
+ 0x1732, 0x1733,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b6, 0x17c8,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x192b,
+ 0x1930, 0x1938,
+ 0x1a17, 0x1a1b,
+ 0x1a55, 0x1a5e,
+ 0x1a61, 0x1a74,
+ 0x1b00, 0x1b04,
+ 0x1b35, 0x1b43,
+ 0x1b80, 0x1b82,
+ 0x1ba1, 0x1ba9,
+ 0x1bac, 0x1bad,
+ 0x1be7, 0x1bf1,
+ 0x1c24, 0x1c35,
+ 0x1cf2, 0x1cf3,
+ 0x1de7, 0x1df4,
+ 0x24b6, 0x24e9,
+ 0x2de0, 0x2dff,
+ 0xa674, 0xa67b,
+ 0xa69e, 0xa69f,
+ 0xa823, 0xa827,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c3,
+ 0xa8c5, 0xa8c5,
+ 0xa926, 0xa92a,
+ 0xa947, 0xa952,
+ 0xa980, 0xa983,
+ 0xa9b4, 0xa9bf,
+ 0xaa29, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4d,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabe,
+ 0xaaeb, 0xaaef,
+ 0xaaf5, 0xaaf5,
+ 0xabe3, 0xabea,
+ 0xfb1e, 0xfb1e,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x11000, 0x11002,
+ 0x11038, 0x11045,
+ 0x11082, 0x11082,
+ 0x110b0, 0x110b8,
+ 0x11100, 0x11102,
+ 0x11127, 0x11132,
+ 0x11180, 0x11182,
+ 0x111b3, 0x111bf,
+ 0x1122c, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x112df, 0x112e8,
+ 0x11300, 0x11303,
+ 0x1133e, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11357, 0x11357,
+ 0x11362, 0x11363,
+ 0x11435, 0x11441,
+ 0x11443, 0x11445,
+ 0x114b0, 0x114c1,
+ 0x115af, 0x115b5,
+ 0x115b8, 0x115be,
+ 0x115dc, 0x115dd,
+ 0x11630, 0x1163e,
+ 0x11640, 0x11640,
+ 0x116ab, 0x116b5,
+ 0x1171d, 0x1172a,
+ 0x11a01, 0x11a0a,
+ 0x11a35, 0x11a39,
+ 0x11a3b, 0x11a3e,
+ 0x11a51, 0x11a5b,
+ 0x11a8a, 0x11a97,
+ 0x11c2f, 0x11c36,
+ 0x11c38, 0x11c3e,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d41,
+ 0x11d43, 0x11d43,
+ 0x11d47, 0x11d47,
+ 0x16b30, 0x16b36,
+ 0x16f51, 0x16f7e,
+ 0x1bc9e, 0x1bc9e,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e947, 0x1e947,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* CR_Other_Alphabetic */
+
+/* 'Ideographic': Binary Property */
+static const OnigCodePoint CR_Ideographic[] = {
+ 16,
+ 0x3006, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303a,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b170, 0x1b2fb,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+}; /* CR_Ideographic */
+
+/* 'Diacritic': Binary Property */
+static const OnigCodePoint CR_Diacritic[] = {
+ 159,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x00a8, 0x00a8,
+ 0x00af, 0x00af,
+ 0x00b4, 0x00b4,
+ 0x00b7, 0x00b8,
+ 0x02b0, 0x034e,
+ 0x0350, 0x0357,
+ 0x035d, 0x0362,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x0384, 0x0385,
+ 0x0483, 0x0487,
+ 0x0559, 0x0559,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c4,
+ 0x064b, 0x0652,
+ 0x0657, 0x0658,
+ 0x06df, 0x06e0,
+ 0x06e5, 0x06e6,
+ 0x06ea, 0x06ec,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f5,
+ 0x0818, 0x0819,
+ 0x08e3, 0x08fe,
+ 0x093c, 0x093c,
+ 0x094d, 0x094d,
+ 0x0951, 0x0954,
+ 0x0971, 0x0971,
+ 0x09bc, 0x09bc,
+ 0x09cd, 0x09cd,
+ 0x0a3c, 0x0a3c,
+ 0x0a4d, 0x0a4d,
+ 0x0abc, 0x0abc,
+ 0x0acd, 0x0acd,
+ 0x0afd, 0x0aff,
+ 0x0b3c, 0x0b3c,
+ 0x0b4d, 0x0b4d,
+ 0x0bcd, 0x0bcd,
+ 0x0c4d, 0x0c4d,
+ 0x0cbc, 0x0cbc,
+ 0x0ccd, 0x0ccd,
+ 0x0d3b, 0x0d3c,
+ 0x0d4d, 0x0d4d,
+ 0x0dca, 0x0dca,
+ 0x0e47, 0x0e4c,
+ 0x0e4e, 0x0e4e,
+ 0x0ec8, 0x0ecc,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f3f,
+ 0x0f82, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0fc6, 0x0fc6,
+ 0x1037, 0x1037,
+ 0x1039, 0x103a,
+ 0x1087, 0x108d,
+ 0x108f, 0x108f,
+ 0x109a, 0x109b,
+ 0x17c9, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x1939, 0x193b,
+ 0x1a75, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1abd,
+ 0x1b34, 0x1b34,
+ 0x1b44, 0x1b44,
+ 0x1b6b, 0x1b73,
+ 0x1baa, 0x1bab,
+ 0x1c36, 0x1c37,
+ 0x1c78, 0x1c7d,
+ 0x1cd0, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf7, 0x1cf9,
+ 0x1d2c, 0x1d6a,
+ 0x1dc4, 0x1dcf,
+ 0x1df5, 0x1df9,
+ 0x1dfd, 0x1dff,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x2cef, 0x2cf1,
+ 0x2e2f, 0x2e2f,
+ 0x302a, 0x302f,
+ 0x3099, 0x309c,
+ 0x30fc, 0x30fc,
+ 0xa66f, 0xa66f,
+ 0xa67c, 0xa67d,
+ 0xa67f, 0xa67f,
+ 0xa69c, 0xa69d,
+ 0xa6f0, 0xa6f1,
+ 0xa717, 0xa721,
+ 0xa788, 0xa788,
+ 0xa7f8, 0xa7f9,
+ 0xa8c4, 0xa8c4,
+ 0xa8e0, 0xa8f1,
+ 0xa92b, 0xa92e,
+ 0xa953, 0xa953,
+ 0xa9b3, 0xa9b3,
+ 0xa9c0, 0xa9c0,
+ 0xa9e5, 0xa9e5,
+ 0xaa7b, 0xaa7d,
+ 0xaabf, 0xaac2,
+ 0xaaf6, 0xaaf6,
+ 0xab5b, 0xab5f,
+ 0xabec, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe20, 0xfe2f,
+ 0xff3e, 0xff3e,
+ 0xff40, 0xff40,
+ 0xff70, 0xff70,
+ 0xff9e, 0xff9f,
+ 0xffe3, 0xffe3,
+ 0x102e0, 0x102e0,
+ 0x10ae5, 0x10ae6,
+ 0x110b9, 0x110ba,
+ 0x11133, 0x11134,
+ 0x11173, 0x11173,
+ 0x111c0, 0x111c0,
+ 0x111ca, 0x111cc,
+ 0x11235, 0x11236,
+ 0x112e9, 0x112ea,
+ 0x1133c, 0x1133c,
+ 0x1134d, 0x1134d,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11442, 0x11442,
+ 0x11446, 0x11446,
+ 0x114c2, 0x114c3,
+ 0x115bf, 0x115c0,
+ 0x1163f, 0x1163f,
+ 0x116b6, 0x116b7,
+ 0x1172b, 0x1172b,
+ 0x11a34, 0x11a34,
+ 0x11a47, 0x11a47,
+ 0x11a99, 0x11a99,
+ 0x11c3f, 0x11c3f,
+ 0x11d42, 0x11d42,
+ 0x11d44, 0x11d45,
+ 0x16af0, 0x16af4,
+ 0x16f8f, 0x16f9f,
+ 0x1d167, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e946,
+ 0x1e948, 0x1e94a,
+}; /* CR_Diacritic */
+
+/* 'Extender': Binary Property */
+static const OnigCodePoint CR_Extender[] = {
+ 29,
+ 0x00b7, 0x00b7,
+ 0x02d0, 0x02d1,
+ 0x0640, 0x0640,
+ 0x07fa, 0x07fa,
+ 0x0e46, 0x0e46,
+ 0x0ec6, 0x0ec6,
+ 0x180a, 0x180a,
+ 0x1843, 0x1843,
+ 0x1aa7, 0x1aa7,
+ 0x1c36, 0x1c36,
+ 0x1c7b, 0x1c7b,
+ 0x3005, 0x3005,
+ 0x3031, 0x3035,
+ 0x309d, 0x309e,
+ 0x30fc, 0x30fe,
+ 0xa015, 0xa015,
+ 0xa60c, 0xa60c,
+ 0xa9cf, 0xa9cf,
+ 0xa9e6, 0xa9e6,
+ 0xaa70, 0xaa70,
+ 0xaadd, 0xaadd,
+ 0xaaf3, 0xaaf4,
+ 0xff70, 0xff70,
+ 0x1135d, 0x1135d,
+ 0x115c6, 0x115c8,
+ 0x11a98, 0x11a98,
+ 0x16b42, 0x16b43,
+ 0x16fe0, 0x16fe1,
+ 0x1e944, 0x1e946,
+}; /* CR_Extender */
+
+/* 'Other_Lowercase': Binary Property */
+static const OnigCodePoint CR_Other_Lowercase[] = {
+ 20,
+ 0x00aa, 0x00aa,
+ 0x00ba, 0x00ba,
+ 0x02b0, 0x02b8,
+ 0x02c0, 0x02c1,
+ 0x02e0, 0x02e4,
+ 0x0345, 0x0345,
+ 0x037a, 0x037a,
+ 0x1d2c, 0x1d6a,
+ 0x1d78, 0x1d78,
+ 0x1d9b, 0x1dbf,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2170, 0x217f,
+ 0x24d0, 0x24e9,
+ 0x2c7c, 0x2c7d,
+ 0xa69c, 0xa69d,
+ 0xa770, 0xa770,
+ 0xa7f8, 0xa7f9,
+ 0xab5c, 0xab5f,
+}; /* CR_Other_Lowercase */
+
+/* 'Other_Uppercase': Binary Property */
+static const OnigCodePoint CR_Other_Uppercase[] = {
+ 5,
+ 0x2160, 0x216f,
+ 0x24b6, 0x24cf,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* CR_Other_Uppercase */
+
+/* 'Noncharacter_Code_Point': Binary Property */
+static const OnigCodePoint CR_Noncharacter_Code_Point[] = {
+ 18,
+ 0xfdd0, 0xfdef,
+ 0xfffe, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0xeffff,
+ 0xffffe, 0xfffff,
+ 0x10fffe, 0x10ffff,
+}; /* CR_Noncharacter_Code_Point */
+
+/* 'Other_Grapheme_Extend': Binary Property */
+static const OnigCodePoint CR_Other_Grapheme_Extend[] = {
+ 23,
+ 0x09be, 0x09be,
+ 0x09d7, 0x09d7,
+ 0x0b3e, 0x0b3e,
+ 0x0b57, 0x0b57,
+ 0x0bbe, 0x0bbe,
+ 0x0bd7, 0x0bd7,
+ 0x0cc2, 0x0cc2,
+ 0x0cd5, 0x0cd6,
+ 0x0d3e, 0x0d3e,
+ 0x0d57, 0x0d57,
+ 0x0dcf, 0x0dcf,
+ 0x0ddf, 0x0ddf,
+ 0x200c, 0x200c,
+ 0x302e, 0x302f,
+ 0xff9e, 0xff9f,
+ 0x1133e, 0x1133e,
+ 0x11357, 0x11357,
+ 0x114b0, 0x114b0,
+ 0x114bd, 0x114bd,
+ 0x115af, 0x115af,
+ 0x1d165, 0x1d165,
+ 0x1d16e, 0x1d172,
+ 0xe0020, 0xe007f,
+}; /* CR_Other_Grapheme_Extend */
+
+/* 'IDS_Binary_Operator': Binary Property */
+static const OnigCodePoint CR_IDS_Binary_Operator[] = {
+ 2,
+ 0x2ff0, 0x2ff1,
+ 0x2ff4, 0x2ffb,
+}; /* CR_IDS_Binary_Operator */
+
+/* 'IDS_Trinary_Operator': Binary Property */
+static const OnigCodePoint CR_IDS_Trinary_Operator[] = {
+ 1,
+ 0x2ff2, 0x2ff3,
+}; /* CR_IDS_Trinary_Operator */
+
+/* 'Radical': Binary Property */
+static const OnigCodePoint CR_Radical[] = {
+ 3,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+}; /* CR_Radical */
+
+/* 'Unified_Ideograph': Binary Property */
+static const OnigCodePoint CR_Unified_Ideograph[] = {
+ 14,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fea,
+ 0xfa0e, 0xfa0f,
+ 0xfa11, 0xfa11,
+ 0xfa13, 0xfa14,
+ 0xfa1f, 0xfa1f,
+ 0xfa21, 0xfa21,
+ 0xfa23, 0xfa24,
+ 0xfa27, 0xfa29,
+ 0x20000, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+}; /* CR_Unified_Ideograph */
+
+/* 'Other_Default_Ignorable_Code_Point': Binary Property */
+static const OnigCodePoint CR_Other_Default_Ignorable_Code_Point[] = {
+ 11,
+ 0x034f, 0x034f,
+ 0x115f, 0x1160,
+ 0x17b4, 0x17b5,
+ 0x2065, 0x2065,
+ 0x3164, 0x3164,
+ 0xffa0, 0xffa0,
+ 0xfff0, 0xfff8,
+ 0xe0000, 0xe0000,
+ 0xe0002, 0xe001f,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0xe0fff,
+}; /* CR_Other_Default_Ignorable_Code_Point */
+
+/* 'Deprecated': Binary Property */
+static const OnigCodePoint CR_Deprecated[] = {
+ 8,
+ 0x0149, 0x0149,
+ 0x0673, 0x0673,
+ 0x0f77, 0x0f77,
+ 0x0f79, 0x0f79,
+ 0x17a3, 0x17a4,
+ 0x206a, 0x206f,
+ 0x2329, 0x232a,
+ 0xe0001, 0xe0001,
+}; /* CR_Deprecated */
+
+/* 'Soft_Dotted': Binary Property */
+static const OnigCodePoint CR_Soft_Dotted[] = {
+ 31,
+ 0x0069, 0x006a,
+ 0x012f, 0x012f,
+ 0x0249, 0x0249,
+ 0x0268, 0x0268,
+ 0x029d, 0x029d,
+ 0x02b2, 0x02b2,
+ 0x03f3, 0x03f3,
+ 0x0456, 0x0456,
+ 0x0458, 0x0458,
+ 0x1d62, 0x1d62,
+ 0x1d96, 0x1d96,
+ 0x1da4, 0x1da4,
+ 0x1da8, 0x1da8,
+ 0x1e2d, 0x1e2d,
+ 0x1ecb, 0x1ecb,
+ 0x2071, 0x2071,
+ 0x2148, 0x2149,
+ 0x2c7c, 0x2c7c,
+ 0x1d422, 0x1d423,
+ 0x1d456, 0x1d457,
+ 0x1d48a, 0x1d48b,
+ 0x1d4be, 0x1d4bf,
+ 0x1d4f2, 0x1d4f3,
+ 0x1d526, 0x1d527,
+ 0x1d55a, 0x1d55b,
+ 0x1d58e, 0x1d58f,
+ 0x1d5c2, 0x1d5c3,
+ 0x1d5f6, 0x1d5f7,
+ 0x1d62a, 0x1d62b,
+ 0x1d65e, 0x1d65f,
+ 0x1d692, 0x1d693,
+}; /* CR_Soft_Dotted */
+
+/* 'Logical_Order_Exception': Binary Property */
+static const OnigCodePoint CR_Logical_Order_Exception[] = {
+ 7,
+ 0x0e40, 0x0e44,
+ 0x0ec0, 0x0ec4,
+ 0x19b5, 0x19b7,
+ 0x19ba, 0x19ba,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaab9,
+ 0xaabb, 0xaabc,
+}; /* CR_Logical_Order_Exception */
+
+/* 'Other_ID_Start': Binary Property */
+static const OnigCodePoint CR_Other_ID_Start[] = {
+ 4,
+ 0x1885, 0x1886,
+ 0x2118, 0x2118,
+ 0x212e, 0x212e,
+ 0x309b, 0x309c,
+}; /* CR_Other_ID_Start */
+
+/* 'Other_ID_Continue': Binary Property */
+static const OnigCodePoint CR_Other_ID_Continue[] = {
+ 4,
+ 0x00b7, 0x00b7,
+ 0x0387, 0x0387,
+ 0x1369, 0x1371,
+ 0x19da, 0x19da,
+}; /* CR_Other_ID_Continue */
+
+/* 'Sentence_Terminal': Binary Property */
+static const OnigCodePoint CR_Sentence_Terminal[] = {
+ 68,
+ 0x0021, 0x0021,
+ 0x002e, 0x002e,
+ 0x003f, 0x003f,
+ 0x0589, 0x0589,
+ 0x061f, 0x061f,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x0702,
+ 0x07f9, 0x07f9,
+ 0x0964, 0x0965,
+ 0x104a, 0x104b,
+ 0x1362, 0x1362,
+ 0x1367, 0x1368,
+ 0x166e, 0x166e,
+ 0x1735, 0x1736,
+ 0x1803, 0x1803,
+ 0x1809, 0x1809,
+ 0x1944, 0x1945,
+ 0x1aa8, 0x1aab,
+ 0x1b5a, 0x1b5b,
+ 0x1b5e, 0x1b5f,
+ 0x1c3b, 0x1c3c,
+ 0x1c7e, 0x1c7f,
+ 0x203c, 0x203d,
+ 0x2047, 0x2049,
+ 0x2e2e, 0x2e2e,
+ 0x2e3c, 0x2e3c,
+ 0x3002, 0x3002,
+ 0xa4ff, 0xa4ff,
+ 0xa60e, 0xa60f,
+ 0xa6f3, 0xa6f3,
+ 0xa6f7, 0xa6f7,
+ 0xa876, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa92f, 0xa92f,
+ 0xa9c8, 0xa9c9,
+ 0xaa5d, 0xaa5f,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 0xfe52, 0xfe52,
+ 0xfe56, 0xfe57,
+ 0xff01, 0xff01,
+ 0xff0e, 0xff0e,
+ 0xff1f, 0xff1f,
+ 0xff61, 0xff61,
+ 0x10a56, 0x10a57,
+ 0x11047, 0x11048,
+ 0x110be, 0x110c1,
+ 0x11141, 0x11143,
+ 0x111c5, 0x111c6,
+ 0x111cd, 0x111cd,
+ 0x111de, 0x111df,
+ 0x11238, 0x11239,
+ 0x1123b, 0x1123c,
+ 0x112a9, 0x112a9,
+ 0x1144b, 0x1144c,
+ 0x115c2, 0x115c3,
+ 0x115c9, 0x115d7,
+ 0x11641, 0x11642,
+ 0x1173c, 0x1173e,
+ 0x11a42, 0x11a43,
+ 0x11a9b, 0x11a9c,
+ 0x11c41, 0x11c42,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b38,
+ 0x16b44, 0x16b44,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da88, 0x1da88,
+}; /* CR_Sentence_Terminal */
+
+/* 'Variation_Selector': Binary Property */
+static const OnigCodePoint CR_Variation_Selector[] = {
+ 3,
+ 0x180b, 0x180d,
+ 0xfe00, 0xfe0f,
+ 0xe0100, 0xe01ef,
+}; /* CR_Variation_Selector */
+
+/* 'Pattern_White_Space': Binary Property */
+static const OnigCodePoint CR_Pattern_White_Space[] = {
+ 5,
+ 0x0009, 0x000d,
+ 0x0020, 0x0020,
+ 0x0085, 0x0085,
+ 0x200e, 0x200f,
+ 0x2028, 0x2029,
+}; /* CR_Pattern_White_Space */
+
+/* 'Pattern_Syntax': Binary Property */
+static const OnigCodePoint CR_Pattern_Syntax[] = {
+ 28,
+ 0x0021, 0x002f,
+ 0x003a, 0x0040,
+ 0x005b, 0x005e,
+ 0x0060, 0x0060,
+ 0x007b, 0x007e,
+ 0x00a1, 0x00a7,
+ 0x00a9, 0x00a9,
+ 0x00ab, 0x00ac,
+ 0x00ae, 0x00ae,
+ 0x00b0, 0x00b1,
+ 0x00b6, 0x00b6,
+ 0x00bb, 0x00bb,
+ 0x00bf, 0x00bf,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x2010, 0x2027,
+ 0x2030, 0x203e,
+ 0x2041, 0x2053,
+ 0x2055, 0x205e,
+ 0x2190, 0x245f,
+ 0x2500, 0x2775,
+ 0x2794, 0x2bff,
+ 0x2e00, 0x2e7f,
+ 0x3001, 0x3003,
+ 0x3008, 0x3020,
+ 0x3030, 0x3030,
+ 0xfd3e, 0xfd3f,
+ 0xfe45, 0xfe46,
+}; /* CR_Pattern_Syntax */
+
+/* 'Prepended_Concatenation_Mark': Binary Property */
+static const OnigCodePoint CR_Prepended_Concatenation_Mark[] = {
+ 5,
+ 0x0600, 0x0605,
+ 0x06dd, 0x06dd,
+ 0x070f, 0x070f,
+ 0x08e2, 0x08e2,
+ 0x110bd, 0x110bd,
+}; /* CR_Prepended_Concatenation_Mark */
+
+/* 'Regional_Indicator': Binary Property */
+static const OnigCodePoint CR_Regional_Indicator[] = {
+ 1,
+ 0x1f1e6, 0x1f1ff,
+}; /* CR_Regional_Indicator */
+
+/* 'Emoji': Emoji */
+static const OnigCodePoint CR_Emoji[] = {
+ 145,
+ 0x0023, 0x0023,
+ 0x002a, 0x002a,
+ 0x0030, 0x0039,
+ 0x00a9, 0x00a9,
+ 0x00ae, 0x00ae,
+ 0x203c, 0x203c,
+ 0x2049, 0x2049,
+ 0x2122, 0x2122,
+ 0x2139, 0x2139,
+ 0x2194, 0x2199,
+ 0x21a9, 0x21aa,
+ 0x231a, 0x231b,
+ 0x2328, 0x2328,
+ 0x23cf, 0x23cf,
+ 0x23e9, 0x23f3,
+ 0x23f8, 0x23fa,
+ 0x24c2, 0x24c2,
+ 0x25aa, 0x25ab,
+ 0x25b6, 0x25b6,
+ 0x25c0, 0x25c0,
+ 0x25fb, 0x25fe,
+ 0x2600, 0x2604,
+ 0x260e, 0x260e,
+ 0x2611, 0x2611,
+ 0x2614, 0x2615,
+ 0x2618, 0x2618,
+ 0x261d, 0x261d,
+ 0x2620, 0x2620,
+ 0x2622, 0x2623,
+ 0x2626, 0x2626,
+ 0x262a, 0x262a,
+ 0x262e, 0x262f,
+ 0x2638, 0x263a,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2648, 0x2653,
+ 0x2660, 0x2660,
+ 0x2663, 0x2663,
+ 0x2665, 0x2666,
+ 0x2668, 0x2668,
+ 0x267b, 0x267b,
+ 0x267f, 0x267f,
+ 0x2692, 0x2697,
+ 0x2699, 0x2699,
+ 0x269b, 0x269c,
+ 0x26a0, 0x26a1,
+ 0x26aa, 0x26ab,
+ 0x26b0, 0x26b1,
+ 0x26bd, 0x26be,
+ 0x26c4, 0x26c5,
+ 0x26c8, 0x26c8,
+ 0x26ce, 0x26cf,
+ 0x26d1, 0x26d1,
+ 0x26d3, 0x26d4,
+ 0x26e9, 0x26ea,
+ 0x26f0, 0x26f5,
+ 0x26f7, 0x26fa,
+ 0x26fd, 0x26fd,
+ 0x2702, 0x2702,
+ 0x2705, 0x2705,
+ 0x2708, 0x270d,
+ 0x270f, 0x270f,
+ 0x2712, 0x2712,
+ 0x2714, 0x2714,
+ 0x2716, 0x2716,
+ 0x271d, 0x271d,
+ 0x2721, 0x2721,
+ 0x2728, 0x2728,
+ 0x2733, 0x2734,
+ 0x2744, 0x2744,
+ 0x2747, 0x2747,
+ 0x274c, 0x274c,
+ 0x274e, 0x274e,
+ 0x2753, 0x2755,
+ 0x2757, 0x2757,
+ 0x2763, 0x2764,
+ 0x2795, 0x2797,
+ 0x27a1, 0x27a1,
+ 0x27b0, 0x27b0,
+ 0x27bf, 0x27bf,
+ 0x2934, 0x2935,
+ 0x2b05, 0x2b07,
+ 0x2b1b, 0x2b1c,
+ 0x2b50, 0x2b50,
+ 0x2b55, 0x2b55,
+ 0x3030, 0x3030,
+ 0x303d, 0x303d,
+ 0x3297, 0x3297,
+ 0x3299, 0x3299,
+ 0x1f004, 0x1f004,
+ 0x1f0cf, 0x1f0cf,
+ 0x1f170, 0x1f171,
+ 0x1f17e, 0x1f17f,
+ 0x1f18e, 0x1f18e,
+ 0x1f191, 0x1f19a,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f201, 0x1f202,
+ 0x1f21a, 0x1f21a,
+ 0x1f22f, 0x1f22f,
+ 0x1f232, 0x1f23a,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f321,
+ 0x1f324, 0x1f393,
+ 0x1f396, 0x1f397,
+ 0x1f399, 0x1f39b,
+ 0x1f39e, 0x1f3f0,
+ 0x1f3f3, 0x1f3f5,
+ 0x1f3f7, 0x1f4fd,
+ 0x1f4ff, 0x1f53d,
+ 0x1f549, 0x1f54e,
+ 0x1f550, 0x1f567,
+ 0x1f56f, 0x1f570,
+ 0x1f573, 0x1f57a,
+ 0x1f587, 0x1f587,
+ 0x1f58a, 0x1f58d,
+ 0x1f590, 0x1f590,
+ 0x1f595, 0x1f596,
+ 0x1f5a4, 0x1f5a5,
+ 0x1f5a8, 0x1f5a8,
+ 0x1f5b1, 0x1f5b2,
+ 0x1f5bc, 0x1f5bc,
+ 0x1f5c2, 0x1f5c4,
+ 0x1f5d1, 0x1f5d3,
+ 0x1f5dc, 0x1f5de,
+ 0x1f5e1, 0x1f5e1,
+ 0x1f5e3, 0x1f5e3,
+ 0x1f5e8, 0x1f5e8,
+ 0x1f5ef, 0x1f5ef,
+ 0x1f5f3, 0x1f5f3,
+ 0x1f5fa, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f6cb, 0x1f6d2,
+ 0x1f6e0, 0x1f6e5,
+ 0x1f6e9, 0x1f6e9,
+ 0x1f6eb, 0x1f6ec,
+ 0x1f6f0, 0x1f6f0,
+ 0x1f6f3, 0x1f6f8,
+ 0x1f910, 0x1f93a,
+ 0x1f93c, 0x1f93e,
+ 0x1f940, 0x1f945,
+ 0x1f947, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+}; /* CR_Emoji */
+
+/* 'Emoji_Presentation': Emoji */
+static const OnigCodePoint CR_Emoji_Presentation[] = {
+ 75,
+ 0x231a, 0x231b,
+ 0x23e9, 0x23ec,
+ 0x23f0, 0x23f0,
+ 0x23f3, 0x23f3,
+ 0x25fd, 0x25fe,
+ 0x2614, 0x2615,
+ 0x2648, 0x2653,
+ 0x267f, 0x267f,
+ 0x2693, 0x2693,
+ 0x26a1, 0x26a1,
+ 0x26aa, 0x26ab,
+ 0x26bd, 0x26be,
+ 0x26c4, 0x26c5,
+ 0x26ce, 0x26ce,
+ 0x26d4, 0x26d4,
+ 0x26ea, 0x26ea,
+ 0x26f2, 0x26f3,
+ 0x26f5, 0x26f5,
+ 0x26fa, 0x26fa,
+ 0x26fd, 0x26fd,
+ 0x2705, 0x2705,
+ 0x270a, 0x270b,
+ 0x2728, 0x2728,
+ 0x274c, 0x274c,
+ 0x274e, 0x274e,
+ 0x2753, 0x2755,
+ 0x2757, 0x2757,
+ 0x2795, 0x2797,
+ 0x27b0, 0x27b0,
+ 0x27bf, 0x27bf,
+ 0x2b1b, 0x2b1c,
+ 0x2b50, 0x2b50,
+ 0x2b55, 0x2b55,
+ 0x1f004, 0x1f004,
+ 0x1f0cf, 0x1f0cf,
+ 0x1f18e, 0x1f18e,
+ 0x1f191, 0x1f19a,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f201, 0x1f201,
+ 0x1f21a, 0x1f21a,
+ 0x1f22f, 0x1f22f,
+ 0x1f232, 0x1f236,
+ 0x1f238, 0x1f23a,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f32d, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f37e, 0x1f393,
+ 0x1f3a0, 0x1f3ca,
+ 0x1f3cf, 0x1f3d3,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f3f4, 0x1f3f4,
+ 0x1f3f8, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4fc,
+ 0x1f4ff, 0x1f53d,
+ 0x1f54b, 0x1f54e,
+ 0x1f550, 0x1f567,
+ 0x1f57a, 0x1f57a,
+ 0x1f595, 0x1f596,
+ 0x1f5a4, 0x1f5a4,
+ 0x1f5fb, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f6cc, 0x1f6cc,
+ 0x1f6d0, 0x1f6d2,
+ 0x1f6eb, 0x1f6ec,
+ 0x1f6f4, 0x1f6f8,
+ 0x1f910, 0x1f93a,
+ 0x1f93c, 0x1f93e,
+ 0x1f940, 0x1f945,
+ 0x1f947, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+}; /* CR_Emoji_Presentation */
+
+/* 'Emoji_Modifier': Emoji */
+static const OnigCodePoint CR_Emoji_Modifier[] = {
+ 1,
+ 0x1f3fb, 0x1f3ff,
+}; /* CR_Emoji_Modifier */
+
+/* 'Emoji_Modifier_Base': Emoji */
+static const OnigCodePoint CR_Emoji_Modifier_Base[] = {
+ 32,
+ 0x261d, 0x261d,
+ 0x26f9, 0x26f9,
+ 0x270a, 0x270d,
+ 0x1f385, 0x1f385,
+ 0x1f3c2, 0x1f3c4,
+ 0x1f3c7, 0x1f3c7,
+ 0x1f3ca, 0x1f3cc,
+ 0x1f442, 0x1f443,
+ 0x1f446, 0x1f450,
+ 0x1f466, 0x1f469,
+ 0x1f46e, 0x1f46e,
+ 0x1f470, 0x1f478,
+ 0x1f47c, 0x1f47c,
+ 0x1f481, 0x1f483,
+ 0x1f485, 0x1f487,
+ 0x1f4aa, 0x1f4aa,
+ 0x1f574, 0x1f575,
+ 0x1f57a, 0x1f57a,
+ 0x1f590, 0x1f590,
+ 0x1f595, 0x1f596,
+ 0x1f645, 0x1f647,
+ 0x1f64b, 0x1f64f,
+ 0x1f6a3, 0x1f6a3,
+ 0x1f6b4, 0x1f6b6,
+ 0x1f6c0, 0x1f6c0,
+ 0x1f6cc, 0x1f6cc,
+ 0x1f918, 0x1f91c,
+ 0x1f91e, 0x1f91f,
+ 0x1f926, 0x1f926,
+ 0x1f930, 0x1f939,
+ 0x1f93d, 0x1f93e,
+ 0x1f9d1, 0x1f9dd,
+}; /* CR_Emoji_Modifier_Base */
+
+/* 'Emoji_Component': Emoji */
+static const OnigCodePoint CR_Emoji_Component[] = {
+ 5,
+ 0x0023, 0x0023,
+ 0x002a, 0x002a,
+ 0x0030, 0x0039,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f3fb, 0x1f3ff,
+}; /* CR_Emoji_Component */
+
+/* 'Unknown': Script */
+static const OnigCodePoint CR_Unknown[] = {
+ 647,
+ 0x0378, 0x0379,
+ 0x0380, 0x0383,
+ 0x038b, 0x038b,
+ 0x038d, 0x038d,
+ 0x03a2, 0x03a2,
+ 0x0530, 0x0530,
+ 0x0557, 0x0558,
+ 0x0560, 0x0560,
+ 0x0588, 0x0588,
+ 0x058b, 0x058c,
+ 0x0590, 0x0590,
+ 0x05c8, 0x05cf,
+ 0x05eb, 0x05ef,
+ 0x05f5, 0x05ff,
+ 0x061d, 0x061d,
+ 0x070e, 0x070e,
+ 0x074b, 0x074c,
+ 0x07b2, 0x07bf,
+ 0x07fb, 0x07ff,
+ 0x082e, 0x082f,
+ 0x083f, 0x083f,
+ 0x085c, 0x085d,
+ 0x085f, 0x085f,
+ 0x086b, 0x089f,
+ 0x08b5, 0x08b5,
+ 0x08be, 0x08d3,
+ 0x0984, 0x0984,
+ 0x098d, 0x098e,
+ 0x0991, 0x0992,
+ 0x09a9, 0x09a9,
+ 0x09b1, 0x09b1,
+ 0x09b3, 0x09b5,
+ 0x09ba, 0x09bb,
+ 0x09c5, 0x09c6,
+ 0x09c9, 0x09ca,
+ 0x09cf, 0x09d6,
+ 0x09d8, 0x09db,
+ 0x09de, 0x09de,
+ 0x09e4, 0x09e5,
+ 0x09fe, 0x0a00,
+ 0x0a04, 0x0a04,
+ 0x0a0b, 0x0a0e,
+ 0x0a11, 0x0a12,
+ 0x0a29, 0x0a29,
+ 0x0a31, 0x0a31,
+ 0x0a34, 0x0a34,
+ 0x0a37, 0x0a37,
+ 0x0a3a, 0x0a3b,
+ 0x0a3d, 0x0a3d,
+ 0x0a43, 0x0a46,
+ 0x0a49, 0x0a4a,
+ 0x0a4e, 0x0a50,
+ 0x0a52, 0x0a58,
+ 0x0a5d, 0x0a5d,
+ 0x0a5f, 0x0a65,
+ 0x0a76, 0x0a80,
+ 0x0a84, 0x0a84,
+ 0x0a8e, 0x0a8e,
+ 0x0a92, 0x0a92,
+ 0x0aa9, 0x0aa9,
+ 0x0ab1, 0x0ab1,
+ 0x0ab4, 0x0ab4,
+ 0x0aba, 0x0abb,
+ 0x0ac6, 0x0ac6,
+ 0x0aca, 0x0aca,
+ 0x0ace, 0x0acf,
+ 0x0ad1, 0x0adf,
+ 0x0ae4, 0x0ae5,
+ 0x0af2, 0x0af8,
+ 0x0b00, 0x0b00,
+ 0x0b04, 0x0b04,
+ 0x0b0d, 0x0b0e,
+ 0x0b11, 0x0b12,
+ 0x0b29, 0x0b29,
+ 0x0b31, 0x0b31,
+ 0x0b34, 0x0b34,
+ 0x0b3a, 0x0b3b,
+ 0x0b45, 0x0b46,
+ 0x0b49, 0x0b4a,
+ 0x0b4e, 0x0b55,
+ 0x0b58, 0x0b5b,
+ 0x0b5e, 0x0b5e,
+ 0x0b64, 0x0b65,
+ 0x0b78, 0x0b81,
+ 0x0b84, 0x0b84,
+ 0x0b8b, 0x0b8d,
+ 0x0b91, 0x0b91,
+ 0x0b96, 0x0b98,
+ 0x0b9b, 0x0b9b,
+ 0x0b9d, 0x0b9d,
+ 0x0ba0, 0x0ba2,
+ 0x0ba5, 0x0ba7,
+ 0x0bab, 0x0bad,
+ 0x0bba, 0x0bbd,
+ 0x0bc3, 0x0bc5,
+ 0x0bc9, 0x0bc9,
+ 0x0bce, 0x0bcf,
+ 0x0bd1, 0x0bd6,
+ 0x0bd8, 0x0be5,
+ 0x0bfb, 0x0bff,
+ 0x0c04, 0x0c04,
+ 0x0c0d, 0x0c0d,
+ 0x0c11, 0x0c11,
+ 0x0c29, 0x0c29,
+ 0x0c3a, 0x0c3c,
+ 0x0c45, 0x0c45,
+ 0x0c49, 0x0c49,
+ 0x0c4e, 0x0c54,
+ 0x0c57, 0x0c57,
+ 0x0c5b, 0x0c5f,
+ 0x0c64, 0x0c65,
+ 0x0c70, 0x0c77,
+ 0x0c84, 0x0c84,
+ 0x0c8d, 0x0c8d,
+ 0x0c91, 0x0c91,
+ 0x0ca9, 0x0ca9,
+ 0x0cb4, 0x0cb4,
+ 0x0cba, 0x0cbb,
+ 0x0cc5, 0x0cc5,
+ 0x0cc9, 0x0cc9,
+ 0x0cce, 0x0cd4,
+ 0x0cd7, 0x0cdd,
+ 0x0cdf, 0x0cdf,
+ 0x0ce4, 0x0ce5,
+ 0x0cf0, 0x0cf0,
+ 0x0cf3, 0x0cff,
+ 0x0d04, 0x0d04,
+ 0x0d0d, 0x0d0d,
+ 0x0d11, 0x0d11,
+ 0x0d45, 0x0d45,
+ 0x0d49, 0x0d49,
+ 0x0d50, 0x0d53,
+ 0x0d64, 0x0d65,
+ 0x0d80, 0x0d81,
+ 0x0d84, 0x0d84,
+ 0x0d97, 0x0d99,
+ 0x0db2, 0x0db2,
+ 0x0dbc, 0x0dbc,
+ 0x0dbe, 0x0dbf,
+ 0x0dc7, 0x0dc9,
+ 0x0dcb, 0x0dce,
+ 0x0dd5, 0x0dd5,
+ 0x0dd7, 0x0dd7,
+ 0x0de0, 0x0de5,
+ 0x0df0, 0x0df1,
+ 0x0df5, 0x0e00,
+ 0x0e3b, 0x0e3e,
+ 0x0e5c, 0x0e80,
+ 0x0e83, 0x0e83,
+ 0x0e85, 0x0e86,
+ 0x0e89, 0x0e89,
+ 0x0e8b, 0x0e8c,
+ 0x0e8e, 0x0e93,
+ 0x0e98, 0x0e98,
+ 0x0ea0, 0x0ea0,
+ 0x0ea4, 0x0ea4,
+ 0x0ea6, 0x0ea6,
+ 0x0ea8, 0x0ea9,
+ 0x0eac, 0x0eac,
+ 0x0eba, 0x0eba,
+ 0x0ebe, 0x0ebf,
+ 0x0ec5, 0x0ec5,
+ 0x0ec7, 0x0ec7,
+ 0x0ece, 0x0ecf,
+ 0x0eda, 0x0edb,
+ 0x0ee0, 0x0eff,
+ 0x0f48, 0x0f48,
+ 0x0f6d, 0x0f70,
+ 0x0f98, 0x0f98,
+ 0x0fbd, 0x0fbd,
+ 0x0fcd, 0x0fcd,
+ 0x0fdb, 0x0fff,
+ 0x10c6, 0x10c6,
+ 0x10c8, 0x10cc,
+ 0x10ce, 0x10cf,
+ 0x1249, 0x1249,
+ 0x124e, 0x124f,
+ 0x1257, 0x1257,
+ 0x1259, 0x1259,
+ 0x125e, 0x125f,
+ 0x1289, 0x1289,
+ 0x128e, 0x128f,
+ 0x12b1, 0x12b1,
+ 0x12b6, 0x12b7,
+ 0x12bf, 0x12bf,
+ 0x12c1, 0x12c1,
+ 0x12c6, 0x12c7,
+ 0x12d7, 0x12d7,
+ 0x1311, 0x1311,
+ 0x1316, 0x1317,
+ 0x135b, 0x135c,
+ 0x137d, 0x137f,
+ 0x139a, 0x139f,
+ 0x13f6, 0x13f7,
+ 0x13fe, 0x13ff,
+ 0x169d, 0x169f,
+ 0x16f9, 0x16ff,
+ 0x170d, 0x170d,
+ 0x1715, 0x171f,
+ 0x1737, 0x173f,
+ 0x1754, 0x175f,
+ 0x176d, 0x176d,
+ 0x1771, 0x1771,
+ 0x1774, 0x177f,
+ 0x17de, 0x17df,
+ 0x17ea, 0x17ef,
+ 0x17fa, 0x17ff,
+ 0x180f, 0x180f,
+ 0x181a, 0x181f,
+ 0x1878, 0x187f,
+ 0x18ab, 0x18af,
+ 0x18f6, 0x18ff,
+ 0x191f, 0x191f,
+ 0x192c, 0x192f,
+ 0x193c, 0x193f,
+ 0x1941, 0x1943,
+ 0x196e, 0x196f,
+ 0x1975, 0x197f,
+ 0x19ac, 0x19af,
+ 0x19ca, 0x19cf,
+ 0x19db, 0x19dd,
+ 0x1a1c, 0x1a1d,
+ 0x1a5f, 0x1a5f,
+ 0x1a7d, 0x1a7e,
+ 0x1a8a, 0x1a8f,
+ 0x1a9a, 0x1a9f,
+ 0x1aae, 0x1aaf,
+ 0x1abf, 0x1aff,
+ 0x1b4c, 0x1b4f,
+ 0x1b7d, 0x1b7f,
+ 0x1bf4, 0x1bfb,
+ 0x1c38, 0x1c3a,
+ 0x1c4a, 0x1c4c,
+ 0x1c89, 0x1cbf,
+ 0x1cc8, 0x1ccf,
+ 0x1cfa, 0x1cff,
+ 0x1dfa, 0x1dfa,
+ 0x1f16, 0x1f17,
+ 0x1f1e, 0x1f1f,
+ 0x1f46, 0x1f47,
+ 0x1f4e, 0x1f4f,
+ 0x1f58, 0x1f58,
+ 0x1f5a, 0x1f5a,
+ 0x1f5c, 0x1f5c,
+ 0x1f5e, 0x1f5e,
+ 0x1f7e, 0x1f7f,
+ 0x1fb5, 0x1fb5,
+ 0x1fc5, 0x1fc5,
+ 0x1fd4, 0x1fd5,
+ 0x1fdc, 0x1fdc,
+ 0x1ff0, 0x1ff1,
+ 0x1ff5, 0x1ff5,
+ 0x1fff, 0x1fff,
+ 0x2065, 0x2065,
+ 0x2072, 0x2073,
+ 0x208f, 0x208f,
+ 0x209d, 0x209f,
+ 0x20c0, 0x20cf,
+ 0x20f1, 0x20ff,
+ 0x218c, 0x218f,
+ 0x2427, 0x243f,
+ 0x244b, 0x245f,
+ 0x2b74, 0x2b75,
+ 0x2b96, 0x2b97,
+ 0x2bba, 0x2bbc,
+ 0x2bc9, 0x2bc9,
+ 0x2bd3, 0x2beb,
+ 0x2bf0, 0x2bff,
+ 0x2c2f, 0x2c2f,
+ 0x2c5f, 0x2c5f,
+ 0x2cf4, 0x2cf8,
+ 0x2d26, 0x2d26,
+ 0x2d28, 0x2d2c,
+ 0x2d2e, 0x2d2f,
+ 0x2d68, 0x2d6e,
+ 0x2d71, 0x2d7e,
+ 0x2d97, 0x2d9f,
+ 0x2da7, 0x2da7,
+ 0x2daf, 0x2daf,
+ 0x2db7, 0x2db7,
+ 0x2dbf, 0x2dbf,
+ 0x2dc7, 0x2dc7,
+ 0x2dcf, 0x2dcf,
+ 0x2dd7, 0x2dd7,
+ 0x2ddf, 0x2ddf,
+ 0x2e4a, 0x2e7f,
+ 0x2e9a, 0x2e9a,
+ 0x2ef4, 0x2eff,
+ 0x2fd6, 0x2fef,
+ 0x2ffc, 0x2fff,
+ 0x3040, 0x3040,
+ 0x3097, 0x3098,
+ 0x3100, 0x3104,
+ 0x312f, 0x3130,
+ 0x318f, 0x318f,
+ 0x31bb, 0x31bf,
+ 0x31e4, 0x31ef,
+ 0x321f, 0x321f,
+ 0x32ff, 0x32ff,
+ 0x4db6, 0x4dbf,
+ 0x9feb, 0x9fff,
+ 0xa48d, 0xa48f,
+ 0xa4c7, 0xa4cf,
+ 0xa62c, 0xa63f,
+ 0xa6f8, 0xa6ff,
+ 0xa7af, 0xa7af,
+ 0xa7b8, 0xa7f6,
+ 0xa82c, 0xa82f,
+ 0xa83a, 0xa83f,
+ 0xa878, 0xa87f,
+ 0xa8c6, 0xa8cd,
+ 0xa8da, 0xa8df,
+ 0xa8fe, 0xa8ff,
+ 0xa954, 0xa95e,
+ 0xa97d, 0xa97f,
+ 0xa9ce, 0xa9ce,
+ 0xa9da, 0xa9dd,
+ 0xa9ff, 0xa9ff,
+ 0xaa37, 0xaa3f,
+ 0xaa4e, 0xaa4f,
+ 0xaa5a, 0xaa5b,
+ 0xaac3, 0xaada,
+ 0xaaf7, 0xab00,
+ 0xab07, 0xab08,
+ 0xab0f, 0xab10,
+ 0xab17, 0xab1f,
+ 0xab27, 0xab27,
+ 0xab2f, 0xab2f,
+ 0xab66, 0xab6f,
+ 0xabee, 0xabef,
+ 0xabfa, 0xabff,
+ 0xd7a4, 0xd7af,
+ 0xd7c7, 0xd7ca,
+ 0xd7fc, 0xf8ff,
+ 0xfa6e, 0xfa6f,
+ 0xfada, 0xfaff,
+ 0xfb07, 0xfb12,
+ 0xfb18, 0xfb1c,
+ 0xfb37, 0xfb37,
+ 0xfb3d, 0xfb3d,
+ 0xfb3f, 0xfb3f,
+ 0xfb42, 0xfb42,
+ 0xfb45, 0xfb45,
+ 0xfbc2, 0xfbd2,
+ 0xfd40, 0xfd4f,
+ 0xfd90, 0xfd91,
+ 0xfdc8, 0xfdef,
+ 0xfdfe, 0xfdff,
+ 0xfe1a, 0xfe1f,
+ 0xfe53, 0xfe53,
+ 0xfe67, 0xfe67,
+ 0xfe6c, 0xfe6f,
+ 0xfe75, 0xfe75,
+ 0xfefd, 0xfefe,
+ 0xff00, 0xff00,
+ 0xffbf, 0xffc1,
+ 0xffc8, 0xffc9,
+ 0xffd0, 0xffd1,
+ 0xffd8, 0xffd9,
+ 0xffdd, 0xffdf,
+ 0xffe7, 0xffe7,
+ 0xffef, 0xfff8,
+ 0xfffe, 0xffff,
+ 0x1000c, 0x1000c,
+ 0x10027, 0x10027,
+ 0x1003b, 0x1003b,
+ 0x1003e, 0x1003e,
+ 0x1004e, 0x1004f,
+ 0x1005e, 0x1007f,
+ 0x100fb, 0x100ff,
+ 0x10103, 0x10106,
+ 0x10134, 0x10136,
+ 0x1018f, 0x1018f,
+ 0x1019c, 0x1019f,
+ 0x101a1, 0x101cf,
+ 0x101fe, 0x1027f,
+ 0x1029d, 0x1029f,
+ 0x102d1, 0x102df,
+ 0x102fc, 0x102ff,
+ 0x10324, 0x1032c,
+ 0x1034b, 0x1034f,
+ 0x1037b, 0x1037f,
+ 0x1039e, 0x1039e,
+ 0x103c4, 0x103c7,
+ 0x103d6, 0x103ff,
+ 0x1049e, 0x1049f,
+ 0x104aa, 0x104af,
+ 0x104d4, 0x104d7,
+ 0x104fc, 0x104ff,
+ 0x10528, 0x1052f,
+ 0x10564, 0x1056e,
+ 0x10570, 0x105ff,
+ 0x10737, 0x1073f,
+ 0x10756, 0x1075f,
+ 0x10768, 0x107ff,
+ 0x10806, 0x10807,
+ 0x10809, 0x10809,
+ 0x10836, 0x10836,
+ 0x10839, 0x1083b,
+ 0x1083d, 0x1083e,
+ 0x10856, 0x10856,
+ 0x1089f, 0x108a6,
+ 0x108b0, 0x108df,
+ 0x108f3, 0x108f3,
+ 0x108f6, 0x108fa,
+ 0x1091c, 0x1091e,
+ 0x1093a, 0x1093e,
+ 0x10940, 0x1097f,
+ 0x109b8, 0x109bb,
+ 0x109d0, 0x109d1,
+ 0x10a04, 0x10a04,
+ 0x10a07, 0x10a0b,
+ 0x10a14, 0x10a14,
+ 0x10a18, 0x10a18,
+ 0x10a34, 0x10a37,
+ 0x10a3b, 0x10a3e,
+ 0x10a48, 0x10a4f,
+ 0x10a59, 0x10a5f,
+ 0x10aa0, 0x10abf,
+ 0x10ae7, 0x10aea,
+ 0x10af7, 0x10aff,
+ 0x10b36, 0x10b38,
+ 0x10b56, 0x10b57,
+ 0x10b73, 0x10b77,
+ 0x10b92, 0x10b98,
+ 0x10b9d, 0x10ba8,
+ 0x10bb0, 0x10bff,
+ 0x10c49, 0x10c7f,
+ 0x10cb3, 0x10cbf,
+ 0x10cf3, 0x10cf9,
+ 0x10d00, 0x10e5f,
+ 0x10e7f, 0x10fff,
+ 0x1104e, 0x11051,
+ 0x11070, 0x1107e,
+ 0x110c2, 0x110cf,
+ 0x110e9, 0x110ef,
+ 0x110fa, 0x110ff,
+ 0x11135, 0x11135,
+ 0x11144, 0x1114f,
+ 0x11177, 0x1117f,
+ 0x111ce, 0x111cf,
+ 0x111e0, 0x111e0,
+ 0x111f5, 0x111ff,
+ 0x11212, 0x11212,
+ 0x1123f, 0x1127f,
+ 0x11287, 0x11287,
+ 0x11289, 0x11289,
+ 0x1128e, 0x1128e,
+ 0x1129e, 0x1129e,
+ 0x112aa, 0x112af,
+ 0x112eb, 0x112ef,
+ 0x112fa, 0x112ff,
+ 0x11304, 0x11304,
+ 0x1130d, 0x1130e,
+ 0x11311, 0x11312,
+ 0x11329, 0x11329,
+ 0x11331, 0x11331,
+ 0x11334, 0x11334,
+ 0x1133a, 0x1133b,
+ 0x11345, 0x11346,
+ 0x11349, 0x1134a,
+ 0x1134e, 0x1134f,
+ 0x11351, 0x11356,
+ 0x11358, 0x1135c,
+ 0x11364, 0x11365,
+ 0x1136d, 0x1136f,
+ 0x11375, 0x113ff,
+ 0x1145a, 0x1145a,
+ 0x1145c, 0x1145c,
+ 0x1145e, 0x1147f,
+ 0x114c8, 0x114cf,
+ 0x114da, 0x1157f,
+ 0x115b6, 0x115b7,
+ 0x115de, 0x115ff,
+ 0x11645, 0x1164f,
+ 0x1165a, 0x1165f,
+ 0x1166d, 0x1167f,
+ 0x116b8, 0x116bf,
+ 0x116ca, 0x116ff,
+ 0x1171a, 0x1171c,
+ 0x1172c, 0x1172f,
+ 0x11740, 0x1189f,
+ 0x118f3, 0x118fe,
+ 0x11900, 0x119ff,
+ 0x11a48, 0x11a4f,
+ 0x11a84, 0x11a85,
+ 0x11a9d, 0x11a9d,
+ 0x11aa3, 0x11abf,
+ 0x11af9, 0x11bff,
+ 0x11c09, 0x11c09,
+ 0x11c37, 0x11c37,
+ 0x11c46, 0x11c4f,
+ 0x11c6d, 0x11c6f,
+ 0x11c90, 0x11c91,
+ 0x11ca8, 0x11ca8,
+ 0x11cb7, 0x11cff,
+ 0x11d07, 0x11d07,
+ 0x11d0a, 0x11d0a,
+ 0x11d37, 0x11d39,
+ 0x11d3b, 0x11d3b,
+ 0x11d3e, 0x11d3e,
+ 0x11d48, 0x11d4f,
+ 0x11d5a, 0x11fff,
+ 0x1239a, 0x123ff,
+ 0x1246f, 0x1246f,
+ 0x12475, 0x1247f,
+ 0x12544, 0x12fff,
+ 0x1342f, 0x143ff,
+ 0x14647, 0x167ff,
+ 0x16a39, 0x16a3f,
+ 0x16a5f, 0x16a5f,
+ 0x16a6a, 0x16a6d,
+ 0x16a70, 0x16acf,
+ 0x16aee, 0x16aef,
+ 0x16af6, 0x16aff,
+ 0x16b46, 0x16b4f,
+ 0x16b5a, 0x16b5a,
+ 0x16b62, 0x16b62,
+ 0x16b78, 0x16b7c,
+ 0x16b90, 0x16eff,
+ 0x16f45, 0x16f4f,
+ 0x16f7f, 0x16f8e,
+ 0x16fa0, 0x16fdf,
+ 0x16fe2, 0x16fff,
+ 0x187ed, 0x187ff,
+ 0x18af3, 0x1afff,
+ 0x1b11f, 0x1b16f,
+ 0x1b2fc, 0x1bbff,
+ 0x1bc6b, 0x1bc6f,
+ 0x1bc7d, 0x1bc7f,
+ 0x1bc89, 0x1bc8f,
+ 0x1bc9a, 0x1bc9b,
+ 0x1bca4, 0x1cfff,
+ 0x1d0f6, 0x1d0ff,
+ 0x1d127, 0x1d128,
+ 0x1d1e9, 0x1d1ff,
+ 0x1d246, 0x1d2ff,
+ 0x1d357, 0x1d35f,
+ 0x1d372, 0x1d3ff,
+ 0x1d455, 0x1d455,
+ 0x1d49d, 0x1d49d,
+ 0x1d4a0, 0x1d4a1,
+ 0x1d4a3, 0x1d4a4,
+ 0x1d4a7, 0x1d4a8,
+ 0x1d4ad, 0x1d4ad,
+ 0x1d4ba, 0x1d4ba,
+ 0x1d4bc, 0x1d4bc,
+ 0x1d4c4, 0x1d4c4,
+ 0x1d506, 0x1d506,
+ 0x1d50b, 0x1d50c,
+ 0x1d515, 0x1d515,
+ 0x1d51d, 0x1d51d,
+ 0x1d53a, 0x1d53a,
+ 0x1d53f, 0x1d53f,
+ 0x1d545, 0x1d545,
+ 0x1d547, 0x1d549,
+ 0x1d551, 0x1d551,
+ 0x1d6a6, 0x1d6a7,
+ 0x1d7cc, 0x1d7cd,
+ 0x1da8c, 0x1da9a,
+ 0x1daa0, 0x1daa0,
+ 0x1dab0, 0x1dfff,
+ 0x1e007, 0x1e007,
+ 0x1e019, 0x1e01a,
+ 0x1e022, 0x1e022,
+ 0x1e025, 0x1e025,
+ 0x1e02b, 0x1e7ff,
+ 0x1e8c5, 0x1e8c6,
+ 0x1e8d7, 0x1e8ff,
+ 0x1e94b, 0x1e94f,
+ 0x1e95a, 0x1e95d,
+ 0x1e960, 0x1edff,
+ 0x1ee04, 0x1ee04,
+ 0x1ee20, 0x1ee20,
+ 0x1ee23, 0x1ee23,
+ 0x1ee25, 0x1ee26,
+ 0x1ee28, 0x1ee28,
+ 0x1ee33, 0x1ee33,
+ 0x1ee38, 0x1ee38,
+ 0x1ee3a, 0x1ee3a,
+ 0x1ee3c, 0x1ee41,
+ 0x1ee43, 0x1ee46,
+ 0x1ee48, 0x1ee48,
+ 0x1ee4a, 0x1ee4a,
+ 0x1ee4c, 0x1ee4c,
+ 0x1ee50, 0x1ee50,
+ 0x1ee53, 0x1ee53,
+ 0x1ee55, 0x1ee56,
+ 0x1ee58, 0x1ee58,
+ 0x1ee5a, 0x1ee5a,
+ 0x1ee5c, 0x1ee5c,
+ 0x1ee5e, 0x1ee5e,
+ 0x1ee60, 0x1ee60,
+ 0x1ee63, 0x1ee63,
+ 0x1ee65, 0x1ee66,
+ 0x1ee6b, 0x1ee6b,
+ 0x1ee73, 0x1ee73,
+ 0x1ee78, 0x1ee78,
+ 0x1ee7d, 0x1ee7d,
+ 0x1ee7f, 0x1ee7f,
+ 0x1ee8a, 0x1ee8a,
+ 0x1ee9c, 0x1eea0,
+ 0x1eea4, 0x1eea4,
+ 0x1eeaa, 0x1eeaa,
+ 0x1eebc, 0x1eeef,
+ 0x1eef2, 0x1efff,
+ 0x1f02c, 0x1f02f,
+ 0x1f094, 0x1f09f,
+ 0x1f0af, 0x1f0b0,
+ 0x1f0c0, 0x1f0c0,
+ 0x1f0d0, 0x1f0d0,
+ 0x1f0f6, 0x1f0ff,
+ 0x1f10d, 0x1f10f,
+ 0x1f12f, 0x1f12f,
+ 0x1f16c, 0x1f16f,
+ 0x1f1ad, 0x1f1e5,
+ 0x1f203, 0x1f20f,
+ 0x1f23c, 0x1f23f,
+ 0x1f249, 0x1f24f,
+ 0x1f252, 0x1f25f,
+ 0x1f266, 0x1f2ff,
+ 0x1f6d5, 0x1f6df,
+ 0x1f6ed, 0x1f6ef,
+ 0x1f6f9, 0x1f6ff,
+ 0x1f774, 0x1f77f,
+ 0x1f7d5, 0x1f7ff,
+ 0x1f80c, 0x1f80f,
+ 0x1f848, 0x1f84f,
+ 0x1f85a, 0x1f85f,
+ 0x1f888, 0x1f88f,
+ 0x1f8ae, 0x1f8ff,
+ 0x1f90c, 0x1f90f,
+ 0x1f93f, 0x1f93f,
+ 0x1f94d, 0x1f94f,
+ 0x1f96c, 0x1f97f,
+ 0x1f998, 0x1f9bf,
+ 0x1f9c1, 0x1f9cf,
+ 0x1f9e7, 0x1ffff,
+ 0x2a6d7, 0x2a6ff,
+ 0x2b735, 0x2b73f,
+ 0x2b81e, 0x2b81f,
+ 0x2cea2, 0x2ceaf,
+ 0x2ebe1, 0x2f7ff,
+ 0x2fa1e, 0xe0000,
+ 0xe0002, 0xe001f,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0x10ffff,
+}; /* CR_Unknown */
+
+#ifdef USE_UNICODE_AGE_PROPERTIES
+/* 'Age_1_1': Derived Age 1.1 */
+static const OnigCodePoint CR_Age_1_1[] = {
+ 288,
+ 0x0000, 0x01f5,
+ 0x01fa, 0x0217,
+ 0x0250, 0x02a8,
+ 0x02b0, 0x02de,
+ 0x02e0, 0x02e9,
+ 0x0300, 0x0345,
+ 0x0360, 0x0361,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d6,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03f3,
+ 0x0401, 0x040c,
+ 0x040e, 0x044f,
+ 0x0451, 0x045c,
+ 0x045e, 0x0486,
+ 0x0490, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04eb,
+ 0x04ee, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x0589,
+ 0x05b0, 0x05b9,
+ 0x05bb, 0x05c3,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0652,
+ 0x0660, 0x066d,
+ 0x0670, 0x06b7,
+ 0x06ba, 0x06be,
+ 0x06c0, 0x06ce,
+ 0x06d0, 0x06ed,
+ 0x06f0, 0x06f9,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 0x0bf2,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1e00, 0x1e9a,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x202e,
+ 0x2030, 0x2046,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20aa,
+ 0x20d0, 0x20e1,
+ 0x2100, 0x2138,
+ 0x2153, 0x2182,
+ 0x2190, 0x21ea,
+ 0x2200, 0x22f1,
+ 0x2300, 0x2300,
+ 0x2302, 0x237a,
+ 0x2400, 0x2424,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25ef,
+ 0x2600, 0x2613,
+ 0x261a, 0x266f,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x3000, 0x3037,
+ 0x303f, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x319f,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x4e00, 0x9fa5,
+ 0xe000, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1e, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffd, 0xffff,
+}; /* CR_Age_1_1 */
+
+/* 'Age_2_0': Derived Age 2.0 */
+static const OnigCodePoint CR_Age_2_0[] = {
+ 312,
+ 0x0000, 0x01f5,
+ 0x01fa, 0x0217,
+ 0x0250, 0x02a8,
+ 0x02b0, 0x02de,
+ 0x02e0, 0x02e9,
+ 0x0300, 0x0345,
+ 0x0360, 0x0361,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d6,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03f3,
+ 0x0401, 0x040c,
+ 0x040e, 0x044f,
+ 0x0451, 0x045c,
+ 0x045e, 0x0486,
+ 0x0490, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04eb,
+ 0x04ee, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x0589,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0652,
+ 0x0660, 0x066d,
+ 0x0670, 0x06b7,
+ 0x06ba, 0x06be,
+ 0x06c0, 0x06ce,
+ 0x06d0, 0x06ed,
+ 0x06f0, 0x06f9,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 0x0bf2,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f69,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f95,
+ 0x0f97, 0x0f97,
+ 0x0f99, 0x0fad,
+ 0x0fb1, 0x0fb7,
+ 0x0fb9, 0x0fb9,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1e00, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x202e,
+ 0x2030, 0x2046,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20ab,
+ 0x20d0, 0x20e1,
+ 0x2100, 0x2138,
+ 0x2153, 0x2182,
+ 0x2190, 0x21ea,
+ 0x2200, 0x22f1,
+ 0x2300, 0x2300,
+ 0x2302, 0x237a,
+ 0x2400, 0x2424,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25ef,
+ 0x2600, 0x2613,
+ 0x261a, 0x266f,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x3000, 0x3037,
+ 0x303f, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x319f,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x4e00, 0x9fa5,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1e, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffd, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_2_0 */
+
+/* 'Age_2_1': Derived Age 2.1 */
+static const OnigCodePoint CR_Age_2_1[] = {
+ 312,
+ 0x0000, 0x01f5,
+ 0x01fa, 0x0217,
+ 0x0250, 0x02a8,
+ 0x02b0, 0x02de,
+ 0x02e0, 0x02e9,
+ 0x0300, 0x0345,
+ 0x0360, 0x0361,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d6,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03f3,
+ 0x0401, 0x040c,
+ 0x040e, 0x044f,
+ 0x0451, 0x045c,
+ 0x045e, 0x0486,
+ 0x0490, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04eb,
+ 0x04ee, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x0589,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0652,
+ 0x0660, 0x066d,
+ 0x0670, 0x06b7,
+ 0x06ba, 0x06be,
+ 0x06c0, 0x06ce,
+ 0x06d0, 0x06ed,
+ 0x06f0, 0x06f9,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 0x0bf2,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f69,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f95,
+ 0x0f97, 0x0f97,
+ 0x0f99, 0x0fad,
+ 0x0fb1, 0x0fb7,
+ 0x0fb9, 0x0fb9,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1e00, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x202e,
+ 0x2030, 0x2046,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20ac,
+ 0x20d0, 0x20e1,
+ 0x2100, 0x2138,
+ 0x2153, 0x2182,
+ 0x2190, 0x21ea,
+ 0x2200, 0x22f1,
+ 0x2300, 0x2300,
+ 0x2302, 0x237a,
+ 0x2400, 0x2424,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25ef,
+ 0x2600, 0x2613,
+ 0x261a, 0x266f,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x3000, 0x3037,
+ 0x303f, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x319f,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x4e00, 0x9fa5,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1e, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffc, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_2_1 */
+
+/* 'Age_3_0': Derived Age 3.0 */
+static const OnigCodePoint CR_Age_3_0[] = {
+ 369,
+ 0x0000, 0x021f,
+ 0x0222, 0x0233,
+ 0x0250, 0x02ad,
+ 0x02b0, 0x02ee,
+ 0x0300, 0x034e,
+ 0x0360, 0x0362,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d7,
+ 0x03da, 0x03f3,
+ 0x0400, 0x0486,
+ 0x0488, 0x0489,
+ 0x048c, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0655,
+ 0x0660, 0x066d,
+ 0x0670, 0x06ed,
+ 0x06f0, 0x06fe,
+ 0x0700, 0x070d,
+ 0x070f, 0x072c,
+ 0x0730, 0x074a,
+ 0x0780, 0x07b0,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 0x0bf2,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6a,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fcf, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1780, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 0x1e00, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2046,
+ 0x2048, 0x204d,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20af,
+ 0x20d0, 0x20e3,
+ 0x2100, 0x213a,
+ 0x2153, 0x2183,
+ 0x2190, 0x21f3,
+ 0x2200, 0x22f1,
+ 0x2300, 0x237b,
+ 0x237d, 0x239a,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25f7,
+ 0x2600, 0x2613,
+ 0x2619, 0x2671,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x2800, 0x28ff,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303a,
+ 0x303e, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4a1,
+ 0xa4a4, 0xa4b3,
+ 0xa4b5, 0xa4c0,
+ 0xa4c2, 0xa4c4,
+ 0xa4c6, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_3_0 */
+
+/* 'Age_3_1': Derived Age 3.1 */
+static const OnigCodePoint CR_Age_3_1[] = {
+ 402,
+ 0x0000, 0x021f,
+ 0x0222, 0x0233,
+ 0x0250, 0x02ad,
+ 0x02b0, 0x02ee,
+ 0x0300, 0x034e,
+ 0x0360, 0x0362,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d7,
+ 0x03da, 0x03f5,
+ 0x0400, 0x0486,
+ 0x0488, 0x0489,
+ 0x048c, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0655,
+ 0x0660, 0x066d,
+ 0x0670, 0x06ed,
+ 0x06f0, 0x06fe,
+ 0x0700, 0x070d,
+ 0x070f, 0x072c,
+ 0x0730, 0x074a,
+ 0x0780, 0x07b0,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 0x0bf2,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6a,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fcf, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1780, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 0x1e00, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2046,
+ 0x2048, 0x204d,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20af,
+ 0x20d0, 0x20e3,
+ 0x2100, 0x213a,
+ 0x2153, 0x2183,
+ 0x2190, 0x21f3,
+ 0x2200, 0x22f1,
+ 0x2300, 0x237b,
+ 0x237d, 0x239a,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25f7,
+ 0x2600, 0x2613,
+ 0x2619, 0x2671,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x2800, 0x28ff,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303a,
+ 0x303e, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4a1,
+ 0xa4a4, 0xa4b3,
+ 0xa4b5, 0xa4c0,
+ 0xa4c2, 0xa4c4,
+ 0xa4c6, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xffff,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10400, 0x10425,
+ 0x10428, 0x1044d,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c0,
+ 0x1d4c2, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a3,
+ 0x1d6a8, 0x1d7c9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_3_1 */
+
+/* 'Age_3_2': Derived Age 3.2 */
+static const OnigCodePoint CR_Age_3_2[] = {
+ 397,
+ 0x0000, 0x0220,
+ 0x0222, 0x0233,
+ 0x0250, 0x02ad,
+ 0x02b0, 0x02ee,
+ 0x0300, 0x034f,
+ 0x0360, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03f6,
+ 0x0400, 0x0486,
+ 0x0488, 0x04ce,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0500, 0x050f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0655,
+ 0x0660, 0x06ed,
+ 0x06f0, 0x06fe,
+ 0x0700, 0x070d,
+ 0x070f, 0x072c,
+ 0x0730, 0x074a,
+ 0x0780, 0x07b1,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 0x0bf2,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6a,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fcf, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f8,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 0x1e00, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2052,
+ 0x2057, 0x2057,
+ 0x205f, 0x2063,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20b1,
+ 0x20d0, 0x20ea,
+ 0x2100, 0x213a,
+ 0x213d, 0x214b,
+ 0x2153, 0x2183,
+ 0x2190, 0x23ce,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x24fe,
+ 0x2500, 0x2613,
+ 0x2616, 0x2617,
+ 0x2619, 0x267d,
+ 0x2680, 0x2689,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27d0, 0x27eb,
+ 0x27f0, 0x2aff,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31f0, 0x321c,
+ 0x3220, 0x3243,
+ 0x3251, 0x327b,
+ 0x327f, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6a,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfc,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe46,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xffff,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10400, 0x10425,
+ 0x10428, 0x1044d,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c0,
+ 0x1d4c2, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a3,
+ 0x1d6a8, 0x1d7c9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_3_2 */
+
+/* 'Age_4_0': Derived Age 4.0 */
+static const OnigCodePoint CR_Age_4_0[] = {
+ 412,
+ 0x0000, 0x0236,
+ 0x0250, 0x0357,
+ 0x035d, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03fb,
+ 0x0400, 0x0486,
+ 0x0488, 0x04ce,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0500, 0x050f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x060c, 0x0615,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0658,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x074f,
+ 0x0780, 0x07b1,
+ 0x0901, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af1, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6a,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fcf, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f8,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x19e0, 0x19ff,
+ 0x1d00, 0x1d6b,
+ 0x1e00, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2054,
+ 0x2057, 0x2057,
+ 0x205f, 0x2063,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20b1,
+ 0x20d0, 0x20ea,
+ 0x2100, 0x213b,
+ 0x213d, 0x214b,
+ 0x2153, 0x2183,
+ 0x2190, 0x23d0,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2617,
+ 0x2619, 0x267d,
+ 0x2680, 0x2691,
+ 0x26a0, 0x26a1,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27d0, 0x27eb,
+ 0x27f0, 0x2b0d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31f0, 0x321e,
+ 0x3220, 0x3243,
+ 0x3250, 0x327d,
+ 0x327f, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6a,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1013f,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x1039f,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x1083f,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d300, 0x1d356,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a3,
+ 0x1d6a8, 0x1d7c9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_4_0 */
+
+/* 'Age_4_1': Derived Age 4.1 */
+static const OnigCodePoint CR_Age_4_1[] = {
+ 430,
+ 0x0000, 0x0241,
+ 0x0250, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x0486,
+ 0x0488, 0x04ce,
+ 0x04d0, 0x04f9,
+ 0x0500, 0x050f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05b9,
+ 0x05bb, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x060b, 0x0615,
+ 0x061b, 0x061b,
+ 0x061e, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x065e,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x076d,
+ 0x0780, 0x07b1,
+ 0x0901, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x097d, 0x097d,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af1, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6a,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fcf, 0x0fd1,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10fc,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135f, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19a9,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a1f,
+ 0x1d00, 0x1dc3,
+ 0x1e00, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2063,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x2094,
+ 0x20a0, 0x20b5,
+ 0x20d0, 0x20eb,
+ 0x2100, 0x214c,
+ 0x2153, 0x2183,
+ 0x2190, 0x23db,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x269c,
+ 0x26a0, 0x26b1,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27c0, 0x27c6,
+ 0x27d0, 0x27eb,
+ 0x27f0, 0x2b13,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c80, 0x2cea,
+ 0x2cf9, 0x2d25,
+ 0x2d30, 0x2d65,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2e00, 0x2e17,
+ 0x2e1c, 0x2e1d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31c0, 0x31cf,
+ 0x31f0, 0x321e,
+ 0x3220, 0x3243,
+ 0x3250, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fbb,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa700, 0xa716,
+ 0xa800, 0xa82b,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6a,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x1083f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7c9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_4_1 */
+
+/* 'Age_5_0': Derived Age 5.0 */
+static const OnigCodePoint CR_Age_5_0[] = {
+ 440,
+ 0x0000, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x0486,
+ 0x0488, 0x0513,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x060b, 0x0615,
+ 0x061b, 0x061b,
+ 0x061e, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x065e,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x076d,
+ 0x0780, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0901, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x097b, 0x097f,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a74,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af1, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3e, 0x0d43,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d61,
+ 0x0d66, 0x0d6f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6a,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fcf, 0x0fd1,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10fc,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135f, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19a9,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a1f,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1d00, 0x1dca,
+ 0x1dfe, 0x1e9b,
+ 0x1ea0, 0x1ef9,
+ 0x1f00, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2063,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x2094,
+ 0x20a0, 0x20b5,
+ 0x20d0, 0x20ef,
+ 0x2100, 0x214e,
+ 0x2153, 0x2184,
+ 0x2190, 0x23e7,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x269c,
+ 0x26a0, 0x26b2,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27c0, 0x27ca,
+ 0x27d0, 0x27eb,
+ 0x27f0, 0x2b1a,
+ 0x2b20, 0x2b23,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2c6c,
+ 0x2c74, 0x2c77,
+ 0x2c80, 0x2cea,
+ 0x2cf9, 0x2d25,
+ 0x2d30, 0x2d65,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2e00, 0x2e17,
+ 0x2e1c, 0x2e1d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31c0, 0x31cf,
+ 0x31f0, 0x321e,
+ 0x3220, 0x3243,
+ 0x3250, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fbb,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa700, 0xa71a,
+ 0xa720, 0xa721,
+ 0xa800, 0xa82b,
+ 0xa840, 0xa877,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6a,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x1083f,
+ 0x10900, 0x10919,
+ 0x1091f, 0x1091f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_5_0 */
+
+/* 'Age_5_1': Derived Age 5.1 */
+static const OnigCodePoint CR_Age_5_1[] = {
+ 455,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0523,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x0606, 0x061b,
+ 0x061e, 0x061f,
+ 0x0621, 0x065e,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0901, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0972,
+ 0x097b, 0x097f,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af1, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fd4,
+ 0x1000, 0x1099,
+ 0x109e, 0x10c5,
+ 0x10d0, 0x10fc,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135f, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19a9,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a1f,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1baa,
+ 0x1bae, 0x1bb9,
+ 0x1c00, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1d00, 0x1de6,
+ 0x1dfe, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x2094,
+ 0x20a0, 0x20b5,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x214f,
+ 0x2153, 0x2188,
+ 0x2190, 0x23e7,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x269d,
+ 0x26a0, 0x26bc,
+ 0x26c0, 0x26c3,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27c0, 0x27ca,
+ 0x27cc, 0x27cc,
+ 0x27d0, 0x2b4c,
+ 0x2b50, 0x2b54,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2c6f,
+ 0x2c71, 0x2c7d,
+ 0x2c80, 0x2cea,
+ 0x2cf9, 0x2d25,
+ 0x2d30, 0x2d65,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e30,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x3243,
+ 0x3250, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fc3,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa500, 0xa62b,
+ 0xa640, 0xa65f,
+ 0xa662, 0xa673,
+ 0xa67c, 0xa697,
+ 0xa700, 0xa78c,
+ 0xa7fb, 0xa82b,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa95f,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa5f,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6a,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x1083f,
+ 0x10900, 0x10919,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_5_1 */
+
+/* 'Age_5_2': Derived Age 5.2 */
+static const OnigCodePoint CR_Age_5_2[] = {
+ 495,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0525,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x0606, 0x061b,
+ 0x061e, 0x061f,
+ 0x0621, 0x065e,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0900, 0x0939,
+ 0x093c, 0x094e,
+ 0x0950, 0x0955,
+ 0x0958, 0x0972,
+ 0x0979, 0x097f,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af1, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b71,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fd8,
+ 0x1000, 0x10c5,
+ 0x10d0, 0x10fc,
+ 0x1100, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135f, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1baa,
+ 0x1bae, 0x1bb9,
+ 0x1c00, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cd0, 0x1cf2,
+ 0x1d00, 0x1de6,
+ 0x1dfd, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x2094,
+ 0x20a0, 0x20b8,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23e8,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26cd,
+ 0x26cf, 0x26e1,
+ 0x26e3, 0x26e3,
+ 0x26e8, 0x26ff,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27c0, 0x27ca,
+ 0x27cc, 0x27cc,
+ 0x27d0, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf1,
+ 0x2cf9, 0x2d25,
+ 0x2d30, 0x2d65,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e31,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcb,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa65f,
+ 0xa662, 0xa673,
+ 0xa67c, 0xa697,
+ 0xa6a0, 0xa6f7,
+ 0xa700, 0xa78c,
+ 0xa7fb, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaadf,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11080, 0x110c1,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f131, 0x1f131,
+ 0x1f13d, 0x1f13d,
+ 0x1f13f, 0x1f13f,
+ 0x1f142, 0x1f142,
+ 0x1f146, 0x1f146,
+ 0x1f14a, 0x1f14e,
+ 0x1f157, 0x1f157,
+ 0x1f15f, 0x1f15f,
+ 0x1f179, 0x1f179,
+ 0x1f17b, 0x1f17c,
+ 0x1f17f, 0x1f17f,
+ 0x1f18a, 0x1f18d,
+ 0x1f190, 0x1f190,
+ 0x1f200, 0x1f200,
+ 0x1f210, 0x1f231,
+ 0x1f240, 0x1f248,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_5_2 */
+
+/* 'Age_6_0': Derived Age 6.0 */
+static const OnigCodePoint CR_Age_6_0[] = {
+ 511,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x0606, 0x061b,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af1, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edd,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10d0, 0x10fc,
+ 0x1100, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1baa,
+ 0x1bae, 0x1bb9,
+ 0x1bc0, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cd0, 0x1cf2,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20b9,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x27ca,
+ 0x27cc, 0x27cc,
+ 0x27ce, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf1,
+ 0x2cf9, 0x2d25,
+ 0x2d30, 0x2d65,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e31,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcb,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa673,
+ 0xa67c, 0xa697,
+ 0xa6a0, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa791,
+ 0xa7a0, 0xa7a9,
+ 0xa7fa, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaadf,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f169,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f5ff,
+ 0x1f601, 0x1f610,
+ 0x1f612, 0x1f614,
+ 0x1f616, 0x1f616,
+ 0x1f618, 0x1f618,
+ 0x1f61a, 0x1f61a,
+ 0x1f61c, 0x1f61e,
+ 0x1f620, 0x1f625,
+ 0x1f628, 0x1f62b,
+ 0x1f62d, 0x1f62d,
+ 0x1f630, 0x1f633,
+ 0x1f635, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_0 */
+
+/* 'Age_6_1': Derived Age 6.1 */
+static const OnigCodePoint CR_Age_6_1[] = {
+ 549,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058f, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0604,
+ 0x0606, 0x061b,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08a0,
+ 0x08a2, 0x08ac,
+ 0x08e4, 0x08fe,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20b9,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e3b,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa697,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa793,
+ 0xa7a0, 0xa7aa,
+ 0xa7f8, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11180, 0x111c8,
+ 0x111d0, 0x111d9,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f540, 0x1f543,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_1 */
+
+/* 'Age_6_2': Derived Age 6.2 */
+static const OnigCodePoint CR_Age_6_2[] = {
+ 549,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058f, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0604,
+ 0x0606, 0x061b,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08a0,
+ 0x08a2, 0x08ac,
+ 0x08e4, 0x08fe,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20ba,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e3b,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa697,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa793,
+ 0xa7a0, 0xa7aa,
+ 0xa7f8, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11180, 0x111c8,
+ 0x111d0, 0x111d9,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f540, 0x1f543,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_2 */
+
+/* 'Age_6_3': Derived Age 6.3 */
+static const OnigCodePoint CR_Age_6_3[] = {
+ 549,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058f, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0604,
+ 0x0606, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08a0,
+ 0x08a2, 0x08ac,
+ 0x08e4, 0x08fe,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20ba,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e3b,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa697,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa793,
+ 0xa7a0, 0xa7aa,
+ 0xa7f8, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11180, 0x111c8,
+ 0x111d0, 0x111d9,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f540, 0x1f543,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_3 */
+
+/* 'Age_7_0': Derived Age 7.0 */
+static const OnigCodePoint CR_Age_7_0[] = {
+ 610,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08b2,
+ 0x08e4, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c81, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d01, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1cf8, 0x1cf9,
+ 0x1d00, 0x1df5,
+ 0x1dfc, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bd,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23fa,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd1,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e42,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa69d,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa7ad,
+ 0xa7b0, 0xa7b1,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5f,
+ 0xab64, 0xab65,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe2d,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018c,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111c8,
+ 0x111cd, 0x111cd,
+ 0x111d0, 0x111da,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123d,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11301, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c9,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11ac0, 0x11af8,
+ 0x12000, 0x12398,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f32c,
+ 0x1f330, 0x1f37d,
+ 0x1f380, 0x1f3ce,
+ 0x1f3d4, 0x1f3f7,
+ 0x1f400, 0x1f4fe,
+ 0x1f500, 0x1f54a,
+ 0x1f550, 0x1f579,
+ 0x1f57b, 0x1f5a3,
+ 0x1f5a5, 0x1f642,
+ 0x1f645, 0x1f6cf,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f3,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_7_0 */
+
+/* 'Age_8_0': Derived Age 8.0 */
+static const OnigCodePoint CR_Age_8_0[] = {
+ 623,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08b4,
+ 0x08e3, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0af9,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c81, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d01, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1cf8, 0x1cf9,
+ 0x1d00, 0x1df5,
+ 0x1dfc, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20be,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x23fa,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd1,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e42,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fd5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ad,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018c,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123d,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11ac0, 0x11af8,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f579,
+ 0x1f57b, 0x1f5a3,
+ 0x1f5a5, 0x1f6d0,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f3,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f910, 0x1f918,
+ 0x1f980, 0x1f984,
+ 0x1f9c0, 0x1f9c0,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_8_0 */
+
+/* 'Age_9_0': Derived Age 9.0 */
+static const OnigCodePoint CR_Age_9_0[] = {
+ 648,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0af9,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d01, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1cf8, 0x1cf9,
+ 0x1d00, 0x1df5,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20be,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x23fe,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd1,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e44,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fd5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe0,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b001,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f6d2,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f6,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f910, 0x1f91e,
+ 0x1f920, 0x1f927,
+ 0x1f930, 0x1f930,
+ 0x1f933, 0x1f93e,
+ 0x1f940, 0x1f94b,
+ 0x1f950, 0x1f95e,
+ 0x1f980, 0x1f991,
+ 0x1f9c0, 0x1f9c0,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_9_0 */
+
+/* 'Age_10_0': Derived Age 10.0 */
+static const OnigCodePoint CR_Age_10_0[] = {
+ 659,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fd,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e87, 0x0e88,
+ 0x0e8a, 0x0e8a,
+ 0x0e8d, 0x0e8d,
+ 0x0e94, 0x0e97,
+ 0x0e99, 0x0e9f,
+ 0x0ea1, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ea7,
+ 0x0eaa, 0x0eab,
+ 0x0ead, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12d6,
+ 0x12d8, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x135a,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 0x1f15,
+ 0x1f18, 0x1f1d,
+ 0x1f20, 0x1f45,
+ 0x1f48, 0x1f4d,
+ 0x1f50, 0x1f57,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fc4,
+ 0x1fc6, 0x1fd3,
+ 0x1fd6, 0x1fdb,
+ 0x1fdd, 0x1fef,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ffe,
+ 0x2000, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e49,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a5,
+ 0x1d6a8, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_10_0 */
+
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+/* 'Grapheme_Cluster_Break_Prepend': Grapheme_Cluster_Break=Prepend */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_Prepend[] = {
+ 10,
+ 0x0600, 0x0605,
+ 0x06dd, 0x06dd,
+ 0x070f, 0x070f,
+ 0x08e2, 0x08e2,
+ 0x0d4e, 0x0d4e,
+ 0x110bd, 0x110bd,
+ 0x111c2, 0x111c3,
+ 0x11a3a, 0x11a3a,
+ 0x11a86, 0x11a89,
+ 0x11d46, 0x11d46,
+}; /* CR_Grapheme_Cluster_Break_Prepend */
+
+/* 'Grapheme_Cluster_Break_CR': Grapheme_Cluster_Break=CR */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_CR[] = {
+ 1,
+ 0x000d, 0x000d,
+}; /* CR_Grapheme_Cluster_Break_CR */
+
+/* 'Grapheme_Cluster_Break_LF': Grapheme_Cluster_Break=LF */
+#define CR_Grapheme_Cluster_Break_LF CR_NEWLINE
+
+/* 'Grapheme_Cluster_Break_Control': Grapheme_Cluster_Break=Control */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_Control[] = {
+ 19,
+ 0x0000, 0x0009,
+ 0x000b, 0x000c,
+ 0x000e, 0x001f,
+ 0x007f, 0x009f,
+ 0x00ad, 0x00ad,
+ 0x061c, 0x061c,
+ 0x180e, 0x180e,
+ 0x200b, 0x200b,
+ 0x200e, 0x200f,
+ 0x2028, 0x202e,
+ 0x2060, 0x206f,
+ 0xd800, 0xdfff,
+ 0xfeff, 0xfeff,
+ 0xfff0, 0xfffb,
+ 0x1bca0, 0x1bca3,
+ 0x1d173, 0x1d17a,
+ 0xe0000, 0xe001f,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0xe0fff,
+}; /* CR_Grapheme_Cluster_Break_Control */
+
+/* 'Grapheme_Cluster_Break_Extend': Grapheme_Cluster_Break=Extend */
+#define CR_Grapheme_Cluster_Break_Extend CR_Grapheme_Extend
+
+/* 'Grapheme_Cluster_Break_Regional_Indicator': Grapheme_Cluster_Break=Regional_Indicator */
+#define CR_Grapheme_Cluster_Break_Regional_Indicator CR_Regional_Indicator
+
+/* 'Grapheme_Cluster_Break_SpacingMark': Grapheme_Cluster_Break=SpacingMark */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_SpacingMark[] = {
+ 145,
+ 0x0903, 0x0903,
+ 0x093b, 0x093b,
+ 0x093e, 0x0940,
+ 0x0949, 0x094c,
+ 0x094e, 0x094f,
+ 0x0982, 0x0983,
+ 0x09bf, 0x09c0,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x0a03, 0x0a03,
+ 0x0a3e, 0x0a40,
+ 0x0a83, 0x0a83,
+ 0x0abe, 0x0ac0,
+ 0x0ac9, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0b02, 0x0b03,
+ 0x0b40, 0x0b40,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0bbf, 0x0bbf,
+ 0x0bc1, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0c01, 0x0c03,
+ 0x0c41, 0x0c44,
+ 0x0c82, 0x0c83,
+ 0x0cbe, 0x0cbe,
+ 0x0cc0, 0x0cc1,
+ 0x0cc3, 0x0cc4,
+ 0x0cc7, 0x0cc8,
+ 0x0cca, 0x0ccb,
+ 0x0d02, 0x0d03,
+ 0x0d3f, 0x0d40,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d82, 0x0d83,
+ 0x0dd0, 0x0dd1,
+ 0x0dd8, 0x0dde,
+ 0x0df2, 0x0df3,
+ 0x0e33, 0x0e33,
+ 0x0eb3, 0x0eb3,
+ 0x0f3e, 0x0f3f,
+ 0x0f7f, 0x0f7f,
+ 0x1031, 0x1031,
+ 0x103b, 0x103c,
+ 0x1056, 0x1057,
+ 0x1084, 0x1084,
+ 0x17b6, 0x17b6,
+ 0x17be, 0x17c5,
+ 0x17c7, 0x17c8,
+ 0x1923, 0x1926,
+ 0x1929, 0x192b,
+ 0x1930, 0x1931,
+ 0x1933, 0x1938,
+ 0x1a19, 0x1a1a,
+ 0x1a55, 0x1a55,
+ 0x1a57, 0x1a57,
+ 0x1a6d, 0x1a72,
+ 0x1b04, 0x1b04,
+ 0x1b35, 0x1b35,
+ 0x1b3b, 0x1b3b,
+ 0x1b3d, 0x1b41,
+ 0x1b43, 0x1b44,
+ 0x1b82, 0x1b82,
+ 0x1ba1, 0x1ba1,
+ 0x1ba6, 0x1ba7,
+ 0x1baa, 0x1baa,
+ 0x1be7, 0x1be7,
+ 0x1bea, 0x1bec,
+ 0x1bee, 0x1bee,
+ 0x1bf2, 0x1bf3,
+ 0x1c24, 0x1c2b,
+ 0x1c34, 0x1c35,
+ 0x1ce1, 0x1ce1,
+ 0x1cf2, 0x1cf3,
+ 0x1cf7, 0x1cf7,
+ 0xa823, 0xa824,
+ 0xa827, 0xa827,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c3,
+ 0xa952, 0xa953,
+ 0xa983, 0xa983,
+ 0xa9b4, 0xa9b5,
+ 0xa9ba, 0xa9bb,
+ 0xa9bd, 0xa9c0,
+ 0xaa2f, 0xaa30,
+ 0xaa33, 0xaa34,
+ 0xaa4d, 0xaa4d,
+ 0xaaeb, 0xaaeb,
+ 0xaaee, 0xaaef,
+ 0xaaf5, 0xaaf5,
+ 0xabe3, 0xabe4,
+ 0xabe6, 0xabe7,
+ 0xabe9, 0xabea,
+ 0xabec, 0xabec,
+ 0x11000, 0x11000,
+ 0x11002, 0x11002,
+ 0x11082, 0x11082,
+ 0x110b0, 0x110b2,
+ 0x110b7, 0x110b8,
+ 0x1112c, 0x1112c,
+ 0x11182, 0x11182,
+ 0x111b3, 0x111b5,
+ 0x111bf, 0x111c0,
+ 0x1122c, 0x1122e,
+ 0x11232, 0x11233,
+ 0x11235, 0x11235,
+ 0x112e0, 0x112e2,
+ 0x11302, 0x11303,
+ 0x1133f, 0x1133f,
+ 0x11341, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11362, 0x11363,
+ 0x11435, 0x11437,
+ 0x11440, 0x11441,
+ 0x11445, 0x11445,
+ 0x114b1, 0x114b2,
+ 0x114b9, 0x114b9,
+ 0x114bb, 0x114bc,
+ 0x114be, 0x114be,
+ 0x114c1, 0x114c1,
+ 0x115b0, 0x115b1,
+ 0x115b8, 0x115bb,
+ 0x115be, 0x115be,
+ 0x11630, 0x11632,
+ 0x1163b, 0x1163c,
+ 0x1163e, 0x1163e,
+ 0x116ac, 0x116ac,
+ 0x116ae, 0x116af,
+ 0x116b6, 0x116b6,
+ 0x11720, 0x11721,
+ 0x11726, 0x11726,
+ 0x11a07, 0x11a08,
+ 0x11a39, 0x11a39,
+ 0x11a57, 0x11a58,
+ 0x11a97, 0x11a97,
+ 0x11c2f, 0x11c2f,
+ 0x11c3e, 0x11c3e,
+ 0x11ca9, 0x11ca9,
+ 0x11cb1, 0x11cb1,
+ 0x11cb4, 0x11cb4,
+ 0x16f51, 0x16f7e,
+ 0x1d166, 0x1d166,
+ 0x1d16d, 0x1d16d,
+}; /* CR_Grapheme_Cluster_Break_SpacingMark */
+
+/* 'Grapheme_Cluster_Break_L': Grapheme_Cluster_Break=L */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_L[] = {
+ 2,
+ 0x1100, 0x115f,
+ 0xa960, 0xa97c,
+}; /* CR_Grapheme_Cluster_Break_L */
+
+/* 'Grapheme_Cluster_Break_V': Grapheme_Cluster_Break=V */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_V[] = {
+ 2,
+ 0x1160, 0x11a7,
+ 0xd7b0, 0xd7c6,
+}; /* CR_Grapheme_Cluster_Break_V */
+
+/* 'Grapheme_Cluster_Break_T': Grapheme_Cluster_Break=T */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_T[] = {
+ 2,
+ 0x11a8, 0x11ff,
+ 0xd7cb, 0xd7fb,
+}; /* CR_Grapheme_Cluster_Break_T */
+
+/* 'Grapheme_Cluster_Break_LV': Grapheme_Cluster_Break=LV */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_LV[] = {
+ 399,
+ 0xac00, 0xac00,
+ 0xac1c, 0xac1c,
+ 0xac38, 0xac38,
+ 0xac54, 0xac54,
+ 0xac70, 0xac70,
+ 0xac8c, 0xac8c,
+ 0xaca8, 0xaca8,
+ 0xacc4, 0xacc4,
+ 0xace0, 0xace0,
+ 0xacfc, 0xacfc,
+ 0xad18, 0xad18,
+ 0xad34, 0xad34,
+ 0xad50, 0xad50,
+ 0xad6c, 0xad6c,
+ 0xad88, 0xad88,
+ 0xada4, 0xada4,
+ 0xadc0, 0xadc0,
+ 0xaddc, 0xaddc,
+ 0xadf8, 0xadf8,
+ 0xae14, 0xae14,
+ 0xae30, 0xae30,
+ 0xae4c, 0xae4c,
+ 0xae68, 0xae68,
+ 0xae84, 0xae84,
+ 0xaea0, 0xaea0,
+ 0xaebc, 0xaebc,
+ 0xaed8, 0xaed8,
+ 0xaef4, 0xaef4,
+ 0xaf10, 0xaf10,
+ 0xaf2c, 0xaf2c,
+ 0xaf48, 0xaf48,
+ 0xaf64, 0xaf64,
+ 0xaf80, 0xaf80,
+ 0xaf9c, 0xaf9c,
+ 0xafb8, 0xafb8,
+ 0xafd4, 0xafd4,
+ 0xaff0, 0xaff0,
+ 0xb00c, 0xb00c,
+ 0xb028, 0xb028,
+ 0xb044, 0xb044,
+ 0xb060, 0xb060,
+ 0xb07c, 0xb07c,
+ 0xb098, 0xb098,
+ 0xb0b4, 0xb0b4,
+ 0xb0d0, 0xb0d0,
+ 0xb0ec, 0xb0ec,
+ 0xb108, 0xb108,
+ 0xb124, 0xb124,
+ 0xb140, 0xb140,
+ 0xb15c, 0xb15c,
+ 0xb178, 0xb178,
+ 0xb194, 0xb194,
+ 0xb1b0, 0xb1b0,
+ 0xb1cc, 0xb1cc,
+ 0xb1e8, 0xb1e8,
+ 0xb204, 0xb204,
+ 0xb220, 0xb220,
+ 0xb23c, 0xb23c,
+ 0xb258, 0xb258,
+ 0xb274, 0xb274,
+ 0xb290, 0xb290,
+ 0xb2ac, 0xb2ac,
+ 0xb2c8, 0xb2c8,
+ 0xb2e4, 0xb2e4,
+ 0xb300, 0xb300,
+ 0xb31c, 0xb31c,
+ 0xb338, 0xb338,
+ 0xb354, 0xb354,
+ 0xb370, 0xb370,
+ 0xb38c, 0xb38c,
+ 0xb3a8, 0xb3a8,
+ 0xb3c4, 0xb3c4,
+ 0xb3e0, 0xb3e0,
+ 0xb3fc, 0xb3fc,
+ 0xb418, 0xb418,
+ 0xb434, 0xb434,
+ 0xb450, 0xb450,
+ 0xb46c, 0xb46c,
+ 0xb488, 0xb488,
+ 0xb4a4, 0xb4a4,
+ 0xb4c0, 0xb4c0,
+ 0xb4dc, 0xb4dc,
+ 0xb4f8, 0xb4f8,
+ 0xb514, 0xb514,
+ 0xb530, 0xb530,
+ 0xb54c, 0xb54c,
+ 0xb568, 0xb568,
+ 0xb584, 0xb584,
+ 0xb5a0, 0xb5a0,
+ 0xb5bc, 0xb5bc,
+ 0xb5d8, 0xb5d8,
+ 0xb5f4, 0xb5f4,
+ 0xb610, 0xb610,
+ 0xb62c, 0xb62c,
+ 0xb648, 0xb648,
+ 0xb664, 0xb664,
+ 0xb680, 0xb680,
+ 0xb69c, 0xb69c,
+ 0xb6b8, 0xb6b8,
+ 0xb6d4, 0xb6d4,
+ 0xb6f0, 0xb6f0,
+ 0xb70c, 0xb70c,
+ 0xb728, 0xb728,
+ 0xb744, 0xb744,
+ 0xb760, 0xb760,
+ 0xb77c, 0xb77c,
+ 0xb798, 0xb798,
+ 0xb7b4, 0xb7b4,
+ 0xb7d0, 0xb7d0,
+ 0xb7ec, 0xb7ec,
+ 0xb808, 0xb808,
+ 0xb824, 0xb824,
+ 0xb840, 0xb840,
+ 0xb85c, 0xb85c,
+ 0xb878, 0xb878,
+ 0xb894, 0xb894,
+ 0xb8b0, 0xb8b0,
+ 0xb8cc, 0xb8cc,
+ 0xb8e8, 0xb8e8,
+ 0xb904, 0xb904,
+ 0xb920, 0xb920,
+ 0xb93c, 0xb93c,
+ 0xb958, 0xb958,
+ 0xb974, 0xb974,
+ 0xb990, 0xb990,
+ 0xb9ac, 0xb9ac,
+ 0xb9c8, 0xb9c8,
+ 0xb9e4, 0xb9e4,
+ 0xba00, 0xba00,
+ 0xba1c, 0xba1c,
+ 0xba38, 0xba38,
+ 0xba54, 0xba54,
+ 0xba70, 0xba70,
+ 0xba8c, 0xba8c,
+ 0xbaa8, 0xbaa8,
+ 0xbac4, 0xbac4,
+ 0xbae0, 0xbae0,
+ 0xbafc, 0xbafc,
+ 0xbb18, 0xbb18,
+ 0xbb34, 0xbb34,
+ 0xbb50, 0xbb50,
+ 0xbb6c, 0xbb6c,
+ 0xbb88, 0xbb88,
+ 0xbba4, 0xbba4,
+ 0xbbc0, 0xbbc0,
+ 0xbbdc, 0xbbdc,
+ 0xbbf8, 0xbbf8,
+ 0xbc14, 0xbc14,
+ 0xbc30, 0xbc30,
+ 0xbc4c, 0xbc4c,
+ 0xbc68, 0xbc68,
+ 0xbc84, 0xbc84,
+ 0xbca0, 0xbca0,
+ 0xbcbc, 0xbcbc,
+ 0xbcd8, 0xbcd8,
+ 0xbcf4, 0xbcf4,
+ 0xbd10, 0xbd10,
+ 0xbd2c, 0xbd2c,
+ 0xbd48, 0xbd48,
+ 0xbd64, 0xbd64,
+ 0xbd80, 0xbd80,
+ 0xbd9c, 0xbd9c,
+ 0xbdb8, 0xbdb8,
+ 0xbdd4, 0xbdd4,
+ 0xbdf0, 0xbdf0,
+ 0xbe0c, 0xbe0c,
+ 0xbe28, 0xbe28,
+ 0xbe44, 0xbe44,
+ 0xbe60, 0xbe60,
+ 0xbe7c, 0xbe7c,
+ 0xbe98, 0xbe98,
+ 0xbeb4, 0xbeb4,
+ 0xbed0, 0xbed0,
+ 0xbeec, 0xbeec,
+ 0xbf08, 0xbf08,
+ 0xbf24, 0xbf24,
+ 0xbf40, 0xbf40,
+ 0xbf5c, 0xbf5c,
+ 0xbf78, 0xbf78,
+ 0xbf94, 0xbf94,
+ 0xbfb0, 0xbfb0,
+ 0xbfcc, 0xbfcc,
+ 0xbfe8, 0xbfe8,
+ 0xc004, 0xc004,
+ 0xc020, 0xc020,
+ 0xc03c, 0xc03c,
+ 0xc058, 0xc058,
+ 0xc074, 0xc074,
+ 0xc090, 0xc090,
+ 0xc0ac, 0xc0ac,
+ 0xc0c8, 0xc0c8,
+ 0xc0e4, 0xc0e4,
+ 0xc100, 0xc100,
+ 0xc11c, 0xc11c,
+ 0xc138, 0xc138,
+ 0xc154, 0xc154,
+ 0xc170, 0xc170,
+ 0xc18c, 0xc18c,
+ 0xc1a8, 0xc1a8,
+ 0xc1c4, 0xc1c4,
+ 0xc1e0, 0xc1e0,
+ 0xc1fc, 0xc1fc,
+ 0xc218, 0xc218,
+ 0xc234, 0xc234,
+ 0xc250, 0xc250,
+ 0xc26c, 0xc26c,
+ 0xc288, 0xc288,
+ 0xc2a4, 0xc2a4,
+ 0xc2c0, 0xc2c0,
+ 0xc2dc, 0xc2dc,
+ 0xc2f8, 0xc2f8,
+ 0xc314, 0xc314,
+ 0xc330, 0xc330,
+ 0xc34c, 0xc34c,
+ 0xc368, 0xc368,
+ 0xc384, 0xc384,
+ 0xc3a0, 0xc3a0,
+ 0xc3bc, 0xc3bc,
+ 0xc3d8, 0xc3d8,
+ 0xc3f4, 0xc3f4,
+ 0xc410, 0xc410,
+ 0xc42c, 0xc42c,
+ 0xc448, 0xc448,
+ 0xc464, 0xc464,
+ 0xc480, 0xc480,
+ 0xc49c, 0xc49c,
+ 0xc4b8, 0xc4b8,
+ 0xc4d4, 0xc4d4,
+ 0xc4f0, 0xc4f0,
+ 0xc50c, 0xc50c,
+ 0xc528, 0xc528,
+ 0xc544, 0xc544,
+ 0xc560, 0xc560,
+ 0xc57c, 0xc57c,
+ 0xc598, 0xc598,
+ 0xc5b4, 0xc5b4,
+ 0xc5d0, 0xc5d0,
+ 0xc5ec, 0xc5ec,
+ 0xc608, 0xc608,
+ 0xc624, 0xc624,
+ 0xc640, 0xc640,
+ 0xc65c, 0xc65c,
+ 0xc678, 0xc678,
+ 0xc694, 0xc694,
+ 0xc6b0, 0xc6b0,
+ 0xc6cc, 0xc6cc,
+ 0xc6e8, 0xc6e8,
+ 0xc704, 0xc704,
+ 0xc720, 0xc720,
+ 0xc73c, 0xc73c,
+ 0xc758, 0xc758,
+ 0xc774, 0xc774,
+ 0xc790, 0xc790,
+ 0xc7ac, 0xc7ac,
+ 0xc7c8, 0xc7c8,
+ 0xc7e4, 0xc7e4,
+ 0xc800, 0xc800,
+ 0xc81c, 0xc81c,
+ 0xc838, 0xc838,
+ 0xc854, 0xc854,
+ 0xc870, 0xc870,
+ 0xc88c, 0xc88c,
+ 0xc8a8, 0xc8a8,
+ 0xc8c4, 0xc8c4,
+ 0xc8e0, 0xc8e0,
+ 0xc8fc, 0xc8fc,
+ 0xc918, 0xc918,
+ 0xc934, 0xc934,
+ 0xc950, 0xc950,
+ 0xc96c, 0xc96c,
+ 0xc988, 0xc988,
+ 0xc9a4, 0xc9a4,
+ 0xc9c0, 0xc9c0,
+ 0xc9dc, 0xc9dc,
+ 0xc9f8, 0xc9f8,
+ 0xca14, 0xca14,
+ 0xca30, 0xca30,
+ 0xca4c, 0xca4c,
+ 0xca68, 0xca68,
+ 0xca84, 0xca84,
+ 0xcaa0, 0xcaa0,
+ 0xcabc, 0xcabc,
+ 0xcad8, 0xcad8,
+ 0xcaf4, 0xcaf4,
+ 0xcb10, 0xcb10,
+ 0xcb2c, 0xcb2c,
+ 0xcb48, 0xcb48,
+ 0xcb64, 0xcb64,
+ 0xcb80, 0xcb80,
+ 0xcb9c, 0xcb9c,
+ 0xcbb8, 0xcbb8,
+ 0xcbd4, 0xcbd4,
+ 0xcbf0, 0xcbf0,
+ 0xcc0c, 0xcc0c,
+ 0xcc28, 0xcc28,
+ 0xcc44, 0xcc44,
+ 0xcc60, 0xcc60,
+ 0xcc7c, 0xcc7c,
+ 0xcc98, 0xcc98,
+ 0xccb4, 0xccb4,
+ 0xccd0, 0xccd0,
+ 0xccec, 0xccec,
+ 0xcd08, 0xcd08,
+ 0xcd24, 0xcd24,
+ 0xcd40, 0xcd40,
+ 0xcd5c, 0xcd5c,
+ 0xcd78, 0xcd78,
+ 0xcd94, 0xcd94,
+ 0xcdb0, 0xcdb0,
+ 0xcdcc, 0xcdcc,
+ 0xcde8, 0xcde8,
+ 0xce04, 0xce04,
+ 0xce20, 0xce20,
+ 0xce3c, 0xce3c,
+ 0xce58, 0xce58,
+ 0xce74, 0xce74,
+ 0xce90, 0xce90,
+ 0xceac, 0xceac,
+ 0xcec8, 0xcec8,
+ 0xcee4, 0xcee4,
+ 0xcf00, 0xcf00,
+ 0xcf1c, 0xcf1c,
+ 0xcf38, 0xcf38,
+ 0xcf54, 0xcf54,
+ 0xcf70, 0xcf70,
+ 0xcf8c, 0xcf8c,
+ 0xcfa8, 0xcfa8,
+ 0xcfc4, 0xcfc4,
+ 0xcfe0, 0xcfe0,
+ 0xcffc, 0xcffc,
+ 0xd018, 0xd018,
+ 0xd034, 0xd034,
+ 0xd050, 0xd050,
+ 0xd06c, 0xd06c,
+ 0xd088, 0xd088,
+ 0xd0a4, 0xd0a4,
+ 0xd0c0, 0xd0c0,
+ 0xd0dc, 0xd0dc,
+ 0xd0f8, 0xd0f8,
+ 0xd114, 0xd114,
+ 0xd130, 0xd130,
+ 0xd14c, 0xd14c,
+ 0xd168, 0xd168,
+ 0xd184, 0xd184,
+ 0xd1a0, 0xd1a0,
+ 0xd1bc, 0xd1bc,
+ 0xd1d8, 0xd1d8,
+ 0xd1f4, 0xd1f4,
+ 0xd210, 0xd210,
+ 0xd22c, 0xd22c,
+ 0xd248, 0xd248,
+ 0xd264, 0xd264,
+ 0xd280, 0xd280,
+ 0xd29c, 0xd29c,
+ 0xd2b8, 0xd2b8,
+ 0xd2d4, 0xd2d4,
+ 0xd2f0, 0xd2f0,
+ 0xd30c, 0xd30c,
+ 0xd328, 0xd328,
+ 0xd344, 0xd344,
+ 0xd360, 0xd360,
+ 0xd37c, 0xd37c,
+ 0xd398, 0xd398,
+ 0xd3b4, 0xd3b4,
+ 0xd3d0, 0xd3d0,
+ 0xd3ec, 0xd3ec,
+ 0xd408, 0xd408,
+ 0xd424, 0xd424,
+ 0xd440, 0xd440,
+ 0xd45c, 0xd45c,
+ 0xd478, 0xd478,
+ 0xd494, 0xd494,
+ 0xd4b0, 0xd4b0,
+ 0xd4cc, 0xd4cc,
+ 0xd4e8, 0xd4e8,
+ 0xd504, 0xd504,
+ 0xd520, 0xd520,
+ 0xd53c, 0xd53c,
+ 0xd558, 0xd558,
+ 0xd574, 0xd574,
+ 0xd590, 0xd590,
+ 0xd5ac, 0xd5ac,
+ 0xd5c8, 0xd5c8,
+ 0xd5e4, 0xd5e4,
+ 0xd600, 0xd600,
+ 0xd61c, 0xd61c,
+ 0xd638, 0xd638,
+ 0xd654, 0xd654,
+ 0xd670, 0xd670,
+ 0xd68c, 0xd68c,
+ 0xd6a8, 0xd6a8,
+ 0xd6c4, 0xd6c4,
+ 0xd6e0, 0xd6e0,
+ 0xd6fc, 0xd6fc,
+ 0xd718, 0xd718,
+ 0xd734, 0xd734,
+ 0xd750, 0xd750,
+ 0xd76c, 0xd76c,
+ 0xd788, 0xd788,
+}; /* CR_Grapheme_Cluster_Break_LV */
+
+/* 'Grapheme_Cluster_Break_LVT': Grapheme_Cluster_Break=LVT */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_LVT[] = {
+ 399,
+ 0xac01, 0xac1b,
+ 0xac1d, 0xac37,
+ 0xac39, 0xac53,
+ 0xac55, 0xac6f,
+ 0xac71, 0xac8b,
+ 0xac8d, 0xaca7,
+ 0xaca9, 0xacc3,
+ 0xacc5, 0xacdf,
+ 0xace1, 0xacfb,
+ 0xacfd, 0xad17,
+ 0xad19, 0xad33,
+ 0xad35, 0xad4f,
+ 0xad51, 0xad6b,
+ 0xad6d, 0xad87,
+ 0xad89, 0xada3,
+ 0xada5, 0xadbf,
+ 0xadc1, 0xaddb,
+ 0xaddd, 0xadf7,
+ 0xadf9, 0xae13,
+ 0xae15, 0xae2f,
+ 0xae31, 0xae4b,
+ 0xae4d, 0xae67,
+ 0xae69, 0xae83,
+ 0xae85, 0xae9f,
+ 0xaea1, 0xaebb,
+ 0xaebd, 0xaed7,
+ 0xaed9, 0xaef3,
+ 0xaef5, 0xaf0f,
+ 0xaf11, 0xaf2b,
+ 0xaf2d, 0xaf47,
+ 0xaf49, 0xaf63,
+ 0xaf65, 0xaf7f,
+ 0xaf81, 0xaf9b,
+ 0xaf9d, 0xafb7,
+ 0xafb9, 0xafd3,
+ 0xafd5, 0xafef,
+ 0xaff1, 0xb00b,
+ 0xb00d, 0xb027,
+ 0xb029, 0xb043,
+ 0xb045, 0xb05f,
+ 0xb061, 0xb07b,
+ 0xb07d, 0xb097,
+ 0xb099, 0xb0b3,
+ 0xb0b5, 0xb0cf,
+ 0xb0d1, 0xb0eb,
+ 0xb0ed, 0xb107,
+ 0xb109, 0xb123,
+ 0xb125, 0xb13f,
+ 0xb141, 0xb15b,
+ 0xb15d, 0xb177,
+ 0xb179, 0xb193,
+ 0xb195, 0xb1af,
+ 0xb1b1, 0xb1cb,
+ 0xb1cd, 0xb1e7,
+ 0xb1e9, 0xb203,
+ 0xb205, 0xb21f,
+ 0xb221, 0xb23b,
+ 0xb23d, 0xb257,
+ 0xb259, 0xb273,
+ 0xb275, 0xb28f,
+ 0xb291, 0xb2ab,
+ 0xb2ad, 0xb2c7,
+ 0xb2c9, 0xb2e3,
+ 0xb2e5, 0xb2ff,
+ 0xb301, 0xb31b,
+ 0xb31d, 0xb337,
+ 0xb339, 0xb353,
+ 0xb355, 0xb36f,
+ 0xb371, 0xb38b,
+ 0xb38d, 0xb3a7,
+ 0xb3a9, 0xb3c3,
+ 0xb3c5, 0xb3df,
+ 0xb3e1, 0xb3fb,
+ 0xb3fd, 0xb417,
+ 0xb419, 0xb433,
+ 0xb435, 0xb44f,
+ 0xb451, 0xb46b,
+ 0xb46d, 0xb487,
+ 0xb489, 0xb4a3,
+ 0xb4a5, 0xb4bf,
+ 0xb4c1, 0xb4db,
+ 0xb4dd, 0xb4f7,
+ 0xb4f9, 0xb513,
+ 0xb515, 0xb52f,
+ 0xb531, 0xb54b,
+ 0xb54d, 0xb567,
+ 0xb569, 0xb583,
+ 0xb585, 0xb59f,
+ 0xb5a1, 0xb5bb,
+ 0xb5bd, 0xb5d7,
+ 0xb5d9, 0xb5f3,
+ 0xb5f5, 0xb60f,
+ 0xb611, 0xb62b,
+ 0xb62d, 0xb647,
+ 0xb649, 0xb663,
+ 0xb665, 0xb67f,
+ 0xb681, 0xb69b,
+ 0xb69d, 0xb6b7,
+ 0xb6b9, 0xb6d3,
+ 0xb6d5, 0xb6ef,
+ 0xb6f1, 0xb70b,
+ 0xb70d, 0xb727,
+ 0xb729, 0xb743,
+ 0xb745, 0xb75f,
+ 0xb761, 0xb77b,
+ 0xb77d, 0xb797,
+ 0xb799, 0xb7b3,
+ 0xb7b5, 0xb7cf,
+ 0xb7d1, 0xb7eb,
+ 0xb7ed, 0xb807,
+ 0xb809, 0xb823,
+ 0xb825, 0xb83f,
+ 0xb841, 0xb85b,
+ 0xb85d, 0xb877,
+ 0xb879, 0xb893,
+ 0xb895, 0xb8af,
+ 0xb8b1, 0xb8cb,
+ 0xb8cd, 0xb8e7,
+ 0xb8e9, 0xb903,
+ 0xb905, 0xb91f,
+ 0xb921, 0xb93b,
+ 0xb93d, 0xb957,
+ 0xb959, 0xb973,
+ 0xb975, 0xb98f,
+ 0xb991, 0xb9ab,
+ 0xb9ad, 0xb9c7,
+ 0xb9c9, 0xb9e3,
+ 0xb9e5, 0xb9ff,
+ 0xba01, 0xba1b,
+ 0xba1d, 0xba37,
+ 0xba39, 0xba53,
+ 0xba55, 0xba6f,
+ 0xba71, 0xba8b,
+ 0xba8d, 0xbaa7,
+ 0xbaa9, 0xbac3,
+ 0xbac5, 0xbadf,
+ 0xbae1, 0xbafb,
+ 0xbafd, 0xbb17,
+ 0xbb19, 0xbb33,
+ 0xbb35, 0xbb4f,
+ 0xbb51, 0xbb6b,
+ 0xbb6d, 0xbb87,
+ 0xbb89, 0xbba3,
+ 0xbba5, 0xbbbf,
+ 0xbbc1, 0xbbdb,
+ 0xbbdd, 0xbbf7,
+ 0xbbf9, 0xbc13,
+ 0xbc15, 0xbc2f,
+ 0xbc31, 0xbc4b,
+ 0xbc4d, 0xbc67,
+ 0xbc69, 0xbc83,
+ 0xbc85, 0xbc9f,
+ 0xbca1, 0xbcbb,
+ 0xbcbd, 0xbcd7,
+ 0xbcd9, 0xbcf3,
+ 0xbcf5, 0xbd0f,
+ 0xbd11, 0xbd2b,
+ 0xbd2d, 0xbd47,
+ 0xbd49, 0xbd63,
+ 0xbd65, 0xbd7f,
+ 0xbd81, 0xbd9b,
+ 0xbd9d, 0xbdb7,
+ 0xbdb9, 0xbdd3,
+ 0xbdd5, 0xbdef,
+ 0xbdf1, 0xbe0b,
+ 0xbe0d, 0xbe27,
+ 0xbe29, 0xbe43,
+ 0xbe45, 0xbe5f,
+ 0xbe61, 0xbe7b,
+ 0xbe7d, 0xbe97,
+ 0xbe99, 0xbeb3,
+ 0xbeb5, 0xbecf,
+ 0xbed1, 0xbeeb,
+ 0xbeed, 0xbf07,
+ 0xbf09, 0xbf23,
+ 0xbf25, 0xbf3f,
+ 0xbf41, 0xbf5b,
+ 0xbf5d, 0xbf77,
+ 0xbf79, 0xbf93,
+ 0xbf95, 0xbfaf,
+ 0xbfb1, 0xbfcb,
+ 0xbfcd, 0xbfe7,
+ 0xbfe9, 0xc003,
+ 0xc005, 0xc01f,
+ 0xc021, 0xc03b,
+ 0xc03d, 0xc057,
+ 0xc059, 0xc073,
+ 0xc075, 0xc08f,
+ 0xc091, 0xc0ab,
+ 0xc0ad, 0xc0c7,
+ 0xc0c9, 0xc0e3,
+ 0xc0e5, 0xc0ff,
+ 0xc101, 0xc11b,
+ 0xc11d, 0xc137,
+ 0xc139, 0xc153,
+ 0xc155, 0xc16f,
+ 0xc171, 0xc18b,
+ 0xc18d, 0xc1a7,
+ 0xc1a9, 0xc1c3,
+ 0xc1c5, 0xc1df,
+ 0xc1e1, 0xc1fb,
+ 0xc1fd, 0xc217,
+ 0xc219, 0xc233,
+ 0xc235, 0xc24f,
+ 0xc251, 0xc26b,
+ 0xc26d, 0xc287,
+ 0xc289, 0xc2a3,
+ 0xc2a5, 0xc2bf,
+ 0xc2c1, 0xc2db,
+ 0xc2dd, 0xc2f7,
+ 0xc2f9, 0xc313,
+ 0xc315, 0xc32f,
+ 0xc331, 0xc34b,
+ 0xc34d, 0xc367,
+ 0xc369, 0xc383,
+ 0xc385, 0xc39f,
+ 0xc3a1, 0xc3bb,
+ 0xc3bd, 0xc3d7,
+ 0xc3d9, 0xc3f3,
+ 0xc3f5, 0xc40f,
+ 0xc411, 0xc42b,
+ 0xc42d, 0xc447,
+ 0xc449, 0xc463,
+ 0xc465, 0xc47f,
+ 0xc481, 0xc49b,
+ 0xc49d, 0xc4b7,
+ 0xc4b9, 0xc4d3,
+ 0xc4d5, 0xc4ef,
+ 0xc4f1, 0xc50b,
+ 0xc50d, 0xc527,
+ 0xc529, 0xc543,
+ 0xc545, 0xc55f,
+ 0xc561, 0xc57b,
+ 0xc57d, 0xc597,
+ 0xc599, 0xc5b3,
+ 0xc5b5, 0xc5cf,
+ 0xc5d1, 0xc5eb,
+ 0xc5ed, 0xc607,
+ 0xc609, 0xc623,
+ 0xc625, 0xc63f,
+ 0xc641, 0xc65b,
+ 0xc65d, 0xc677,
+ 0xc679, 0xc693,
+ 0xc695, 0xc6af,
+ 0xc6b1, 0xc6cb,
+ 0xc6cd, 0xc6e7,
+ 0xc6e9, 0xc703,
+ 0xc705, 0xc71f,
+ 0xc721, 0xc73b,
+ 0xc73d, 0xc757,
+ 0xc759, 0xc773,
+ 0xc775, 0xc78f,
+ 0xc791, 0xc7ab,
+ 0xc7ad, 0xc7c7,
+ 0xc7c9, 0xc7e3,
+ 0xc7e5, 0xc7ff,
+ 0xc801, 0xc81b,
+ 0xc81d, 0xc837,
+ 0xc839, 0xc853,
+ 0xc855, 0xc86f,
+ 0xc871, 0xc88b,
+ 0xc88d, 0xc8a7,
+ 0xc8a9, 0xc8c3,
+ 0xc8c5, 0xc8df,
+ 0xc8e1, 0xc8fb,
+ 0xc8fd, 0xc917,
+ 0xc919, 0xc933,
+ 0xc935, 0xc94f,
+ 0xc951, 0xc96b,
+ 0xc96d, 0xc987,
+ 0xc989, 0xc9a3,
+ 0xc9a5, 0xc9bf,
+ 0xc9c1, 0xc9db,
+ 0xc9dd, 0xc9f7,
+ 0xc9f9, 0xca13,
+ 0xca15, 0xca2f,
+ 0xca31, 0xca4b,
+ 0xca4d, 0xca67,
+ 0xca69, 0xca83,
+ 0xca85, 0xca9f,
+ 0xcaa1, 0xcabb,
+ 0xcabd, 0xcad7,
+ 0xcad9, 0xcaf3,
+ 0xcaf5, 0xcb0f,
+ 0xcb11, 0xcb2b,
+ 0xcb2d, 0xcb47,
+ 0xcb49, 0xcb63,
+ 0xcb65, 0xcb7f,
+ 0xcb81, 0xcb9b,
+ 0xcb9d, 0xcbb7,
+ 0xcbb9, 0xcbd3,
+ 0xcbd5, 0xcbef,
+ 0xcbf1, 0xcc0b,
+ 0xcc0d, 0xcc27,
+ 0xcc29, 0xcc43,
+ 0xcc45, 0xcc5f,
+ 0xcc61, 0xcc7b,
+ 0xcc7d, 0xcc97,
+ 0xcc99, 0xccb3,
+ 0xccb5, 0xcccf,
+ 0xccd1, 0xcceb,
+ 0xcced, 0xcd07,
+ 0xcd09, 0xcd23,
+ 0xcd25, 0xcd3f,
+ 0xcd41, 0xcd5b,
+ 0xcd5d, 0xcd77,
+ 0xcd79, 0xcd93,
+ 0xcd95, 0xcdaf,
+ 0xcdb1, 0xcdcb,
+ 0xcdcd, 0xcde7,
+ 0xcde9, 0xce03,
+ 0xce05, 0xce1f,
+ 0xce21, 0xce3b,
+ 0xce3d, 0xce57,
+ 0xce59, 0xce73,
+ 0xce75, 0xce8f,
+ 0xce91, 0xceab,
+ 0xcead, 0xcec7,
+ 0xcec9, 0xcee3,
+ 0xcee5, 0xceff,
+ 0xcf01, 0xcf1b,
+ 0xcf1d, 0xcf37,
+ 0xcf39, 0xcf53,
+ 0xcf55, 0xcf6f,
+ 0xcf71, 0xcf8b,
+ 0xcf8d, 0xcfa7,
+ 0xcfa9, 0xcfc3,
+ 0xcfc5, 0xcfdf,
+ 0xcfe1, 0xcffb,
+ 0xcffd, 0xd017,
+ 0xd019, 0xd033,
+ 0xd035, 0xd04f,
+ 0xd051, 0xd06b,
+ 0xd06d, 0xd087,
+ 0xd089, 0xd0a3,
+ 0xd0a5, 0xd0bf,
+ 0xd0c1, 0xd0db,
+ 0xd0dd, 0xd0f7,
+ 0xd0f9, 0xd113,
+ 0xd115, 0xd12f,
+ 0xd131, 0xd14b,
+ 0xd14d, 0xd167,
+ 0xd169, 0xd183,
+ 0xd185, 0xd19f,
+ 0xd1a1, 0xd1bb,
+ 0xd1bd, 0xd1d7,
+ 0xd1d9, 0xd1f3,
+ 0xd1f5, 0xd20f,
+ 0xd211, 0xd22b,
+ 0xd22d, 0xd247,
+ 0xd249, 0xd263,
+ 0xd265, 0xd27f,
+ 0xd281, 0xd29b,
+ 0xd29d, 0xd2b7,
+ 0xd2b9, 0xd2d3,
+ 0xd2d5, 0xd2ef,
+ 0xd2f1, 0xd30b,
+ 0xd30d, 0xd327,
+ 0xd329, 0xd343,
+ 0xd345, 0xd35f,
+ 0xd361, 0xd37b,
+ 0xd37d, 0xd397,
+ 0xd399, 0xd3b3,
+ 0xd3b5, 0xd3cf,
+ 0xd3d1, 0xd3eb,
+ 0xd3ed, 0xd407,
+ 0xd409, 0xd423,
+ 0xd425, 0xd43f,
+ 0xd441, 0xd45b,
+ 0xd45d, 0xd477,
+ 0xd479, 0xd493,
+ 0xd495, 0xd4af,
+ 0xd4b1, 0xd4cb,
+ 0xd4cd, 0xd4e7,
+ 0xd4e9, 0xd503,
+ 0xd505, 0xd51f,
+ 0xd521, 0xd53b,
+ 0xd53d, 0xd557,
+ 0xd559, 0xd573,
+ 0xd575, 0xd58f,
+ 0xd591, 0xd5ab,
+ 0xd5ad, 0xd5c7,
+ 0xd5c9, 0xd5e3,
+ 0xd5e5, 0xd5ff,
+ 0xd601, 0xd61b,
+ 0xd61d, 0xd637,
+ 0xd639, 0xd653,
+ 0xd655, 0xd66f,
+ 0xd671, 0xd68b,
+ 0xd68d, 0xd6a7,
+ 0xd6a9, 0xd6c3,
+ 0xd6c5, 0xd6df,
+ 0xd6e1, 0xd6fb,
+ 0xd6fd, 0xd717,
+ 0xd719, 0xd733,
+ 0xd735, 0xd74f,
+ 0xd751, 0xd76b,
+ 0xd76d, 0xd787,
+ 0xd789, 0xd7a3,
+}; /* CR_Grapheme_Cluster_Break_LVT */
+
+/* 'Grapheme_Cluster_Break_E_Base': Grapheme_Cluster_Break=E_Base */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_E_Base[] = {
+ 31,
+ 0x261d, 0x261d,
+ 0x26f9, 0x26f9,
+ 0x270a, 0x270d,
+ 0x1f385, 0x1f385,
+ 0x1f3c2, 0x1f3c4,
+ 0x1f3c7, 0x1f3c7,
+ 0x1f3ca, 0x1f3cc,
+ 0x1f442, 0x1f443,
+ 0x1f446, 0x1f450,
+ 0x1f46e, 0x1f46e,
+ 0x1f470, 0x1f478,
+ 0x1f47c, 0x1f47c,
+ 0x1f481, 0x1f483,
+ 0x1f485, 0x1f487,
+ 0x1f4aa, 0x1f4aa,
+ 0x1f574, 0x1f575,
+ 0x1f57a, 0x1f57a,
+ 0x1f590, 0x1f590,
+ 0x1f595, 0x1f596,
+ 0x1f645, 0x1f647,
+ 0x1f64b, 0x1f64f,
+ 0x1f6a3, 0x1f6a3,
+ 0x1f6b4, 0x1f6b6,
+ 0x1f6c0, 0x1f6c0,
+ 0x1f6cc, 0x1f6cc,
+ 0x1f918, 0x1f91c,
+ 0x1f91e, 0x1f91f,
+ 0x1f926, 0x1f926,
+ 0x1f930, 0x1f939,
+ 0x1f93d, 0x1f93e,
+ 0x1f9d1, 0x1f9dd,
+}; /* CR_Grapheme_Cluster_Break_E_Base */
+
+/* 'Grapheme_Cluster_Break_E_Modifier': Grapheme_Cluster_Break=E_Modifier */
+#define CR_Grapheme_Cluster_Break_E_Modifier CR_Emoji_Modifier
+
+/* 'Grapheme_Cluster_Break_ZWJ': Grapheme_Cluster_Break=ZWJ */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_ZWJ[] = {
+ 1,
+ 0x200d, 0x200d,
+}; /* CR_Grapheme_Cluster_Break_ZWJ */
+
+/* 'Grapheme_Cluster_Break_Glue_After_Zwj': Grapheme_Cluster_Break=Glue_After_Zwj */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_Glue_After_Zwj[] = {
+ 20,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2695, 0x2696,
+ 0x2708, 0x2708,
+ 0x2764, 0x2764,
+ 0x1f308, 0x1f308,
+ 0x1f33e, 0x1f33e,
+ 0x1f373, 0x1f373,
+ 0x1f393, 0x1f393,
+ 0x1f3a4, 0x1f3a4,
+ 0x1f3a8, 0x1f3a8,
+ 0x1f3eb, 0x1f3eb,
+ 0x1f3ed, 0x1f3ed,
+ 0x1f48b, 0x1f48b,
+ 0x1f4bb, 0x1f4bc,
+ 0x1f527, 0x1f527,
+ 0x1f52c, 0x1f52c,
+ 0x1f5e8, 0x1f5e8,
+ 0x1f680, 0x1f680,
+ 0x1f692, 0x1f692,
+}; /* CR_Grapheme_Cluster_Break_Glue_After_Zwj */
+
+/* 'Grapheme_Cluster_Break_E_Base_GAZ': Grapheme_Cluster_Break=E_Base_GAZ */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_E_Base_GAZ[] = {
+ 1,
+ 0x1f466, 0x1f469,
+}; /* CR_Grapheme_Cluster_Break_E_Base_GAZ */
+
+/* 'In_Basic_Latin': Block */
+#define CR_In_Basic_Latin CR_ASCII
+
+/* 'In_Latin_1_Supplement': Block */
+static const OnigCodePoint CR_In_Latin_1_Supplement[] = {
+ 1,
+ 0x0080, 0x00ff,
+}; /* CR_In_Latin_1_Supplement */
+
+/* 'In_Latin_Extended_A': Block */
+static const OnigCodePoint CR_In_Latin_Extended_A[] = {
+ 1,
+ 0x0100, 0x017f,
+}; /* CR_In_Latin_Extended_A */
+
+/* 'In_Latin_Extended_B': Block */
+static const OnigCodePoint CR_In_Latin_Extended_B[] = {
+ 1,
+ 0x0180, 0x024f,
+}; /* CR_In_Latin_Extended_B */
+
+/* 'In_IPA_Extensions': Block */
+static const OnigCodePoint CR_In_IPA_Extensions[] = {
+ 1,
+ 0x0250, 0x02af,
+}; /* CR_In_IPA_Extensions */
+
+/* 'In_Spacing_Modifier_Letters': Block */
+static const OnigCodePoint CR_In_Spacing_Modifier_Letters[] = {
+ 1,
+ 0x02b0, 0x02ff,
+}; /* CR_In_Spacing_Modifier_Letters */
+
+/* 'In_Combining_Diacritical_Marks': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks[] = {
+ 1,
+ 0x0300, 0x036f,
+}; /* CR_In_Combining_Diacritical_Marks */
+
+/* 'In_Greek_and_Coptic': Block */
+static const OnigCodePoint CR_In_Greek_and_Coptic[] = {
+ 1,
+ 0x0370, 0x03ff,
+}; /* CR_In_Greek_and_Coptic */
+
+/* 'In_Cyrillic': Block */
+static const OnigCodePoint CR_In_Cyrillic[] = {
+ 1,
+ 0x0400, 0x04ff,
+}; /* CR_In_Cyrillic */
+
+/* 'In_Cyrillic_Supplement': Block */
+static const OnigCodePoint CR_In_Cyrillic_Supplement[] = {
+ 1,
+ 0x0500, 0x052f,
+}; /* CR_In_Cyrillic_Supplement */
+
+/* 'In_Armenian': Block */
+static const OnigCodePoint CR_In_Armenian[] = {
+ 1,
+ 0x0530, 0x058f,
+}; /* CR_In_Armenian */
+
+/* 'In_Hebrew': Block */
+static const OnigCodePoint CR_In_Hebrew[] = {
+ 1,
+ 0x0590, 0x05ff,
+}; /* CR_In_Hebrew */
+
+/* 'In_Arabic': Block */
+static const OnigCodePoint CR_In_Arabic[] = {
+ 1,
+ 0x0600, 0x06ff,
+}; /* CR_In_Arabic */
+
+/* 'In_Syriac': Block */
+static const OnigCodePoint CR_In_Syriac[] = {
+ 1,
+ 0x0700, 0x074f,
+}; /* CR_In_Syriac */
+
+/* 'In_Arabic_Supplement': Block */
+static const OnigCodePoint CR_In_Arabic_Supplement[] = {
+ 1,
+ 0x0750, 0x077f,
+}; /* CR_In_Arabic_Supplement */
+
+/* 'In_Thaana': Block */
+static const OnigCodePoint CR_In_Thaana[] = {
+ 1,
+ 0x0780, 0x07bf,
+}; /* CR_In_Thaana */
+
+/* 'In_NKo': Block */
+static const OnigCodePoint CR_In_NKo[] = {
+ 1,
+ 0x07c0, 0x07ff,
+}; /* CR_In_NKo */
+
+/* 'In_Samaritan': Block */
+static const OnigCodePoint CR_In_Samaritan[] = {
+ 1,
+ 0x0800, 0x083f,
+}; /* CR_In_Samaritan */
+
+/* 'In_Mandaic': Block */
+static const OnigCodePoint CR_In_Mandaic[] = {
+ 1,
+ 0x0840, 0x085f,
+}; /* CR_In_Mandaic */
+
+/* 'In_Syriac_Supplement': Block */
+static const OnigCodePoint CR_In_Syriac_Supplement[] = {
+ 1,
+ 0x0860, 0x086f,
+}; /* CR_In_Syriac_Supplement */
+
+/* 'In_Arabic_Extended_A': Block */
+static const OnigCodePoint CR_In_Arabic_Extended_A[] = {
+ 1,
+ 0x08a0, 0x08ff,
+}; /* CR_In_Arabic_Extended_A */
+
+/* 'In_Devanagari': Block */
+static const OnigCodePoint CR_In_Devanagari[] = {
+ 1,
+ 0x0900, 0x097f,
+}; /* CR_In_Devanagari */
+
+/* 'In_Bengali': Block */
+static const OnigCodePoint CR_In_Bengali[] = {
+ 1,
+ 0x0980, 0x09ff,
+}; /* CR_In_Bengali */
+
+/* 'In_Gurmukhi': Block */
+static const OnigCodePoint CR_In_Gurmukhi[] = {
+ 1,
+ 0x0a00, 0x0a7f,
+}; /* CR_In_Gurmukhi */
+
+/* 'In_Gujarati': Block */
+static const OnigCodePoint CR_In_Gujarati[] = {
+ 1,
+ 0x0a80, 0x0aff,
+}; /* CR_In_Gujarati */
+
+/* 'In_Oriya': Block */
+static const OnigCodePoint CR_In_Oriya[] = {
+ 1,
+ 0x0b00, 0x0b7f,
+}; /* CR_In_Oriya */
+
+/* 'In_Tamil': Block */
+static const OnigCodePoint CR_In_Tamil[] = {
+ 1,
+ 0x0b80, 0x0bff,
+}; /* CR_In_Tamil */
+
+/* 'In_Telugu': Block */
+static const OnigCodePoint CR_In_Telugu[] = {
+ 1,
+ 0x0c00, 0x0c7f,
+}; /* CR_In_Telugu */
+
+/* 'In_Kannada': Block */
+static const OnigCodePoint CR_In_Kannada[] = {
+ 1,
+ 0x0c80, 0x0cff,
+}; /* CR_In_Kannada */
+
+/* 'In_Malayalam': Block */
+static const OnigCodePoint CR_In_Malayalam[] = {
+ 1,
+ 0x0d00, 0x0d7f,
+}; /* CR_In_Malayalam */
+
+/* 'In_Sinhala': Block */
+static const OnigCodePoint CR_In_Sinhala[] = {
+ 1,
+ 0x0d80, 0x0dff,
+}; /* CR_In_Sinhala */
+
+/* 'In_Thai': Block */
+static const OnigCodePoint CR_In_Thai[] = {
+ 1,
+ 0x0e00, 0x0e7f,
+}; /* CR_In_Thai */
+
+/* 'In_Lao': Block */
+static const OnigCodePoint CR_In_Lao[] = {
+ 1,
+ 0x0e80, 0x0eff,
+}; /* CR_In_Lao */
+
+/* 'In_Tibetan': Block */
+static const OnigCodePoint CR_In_Tibetan[] = {
+ 1,
+ 0x0f00, 0x0fff,
+}; /* CR_In_Tibetan */
+
+/* 'In_Myanmar': Block */
+static const OnigCodePoint CR_In_Myanmar[] = {
+ 1,
+ 0x1000, 0x109f,
+}; /* CR_In_Myanmar */
+
+/* 'In_Georgian': Block */
+static const OnigCodePoint CR_In_Georgian[] = {
+ 1,
+ 0x10a0, 0x10ff,
+}; /* CR_In_Georgian */
+
+/* 'In_Hangul_Jamo': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo[] = {
+ 1,
+ 0x1100, 0x11ff,
+}; /* CR_In_Hangul_Jamo */
+
+/* 'In_Ethiopic': Block */
+static const OnigCodePoint CR_In_Ethiopic[] = {
+ 1,
+ 0x1200, 0x137f,
+}; /* CR_In_Ethiopic */
+
+/* 'In_Ethiopic_Supplement': Block */
+static const OnigCodePoint CR_In_Ethiopic_Supplement[] = {
+ 1,
+ 0x1380, 0x139f,
+}; /* CR_In_Ethiopic_Supplement */
+
+/* 'In_Cherokee': Block */
+static const OnigCodePoint CR_In_Cherokee[] = {
+ 1,
+ 0x13a0, 0x13ff,
+}; /* CR_In_Cherokee */
+
+/* 'In_Unified_Canadian_Aboriginal_Syllabics': Block */
+static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics[] = {
+ 1,
+ 0x1400, 0x167f,
+}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics */
+
+/* 'In_Ogham': Block */
+static const OnigCodePoint CR_In_Ogham[] = {
+ 1,
+ 0x1680, 0x169f,
+}; /* CR_In_Ogham */
+
+/* 'In_Runic': Block */
+static const OnigCodePoint CR_In_Runic[] = {
+ 1,
+ 0x16a0, 0x16ff,
+}; /* CR_In_Runic */
+
+/* 'In_Tagalog': Block */
+static const OnigCodePoint CR_In_Tagalog[] = {
+ 1,
+ 0x1700, 0x171f,
+}; /* CR_In_Tagalog */
+
+/* 'In_Hanunoo': Block */
+static const OnigCodePoint CR_In_Hanunoo[] = {
+ 1,
+ 0x1720, 0x173f,
+}; /* CR_In_Hanunoo */
+
+/* 'In_Buhid': Block */
+static const OnigCodePoint CR_In_Buhid[] = {
+ 1,
+ 0x1740, 0x175f,
+}; /* CR_In_Buhid */
+
+/* 'In_Tagbanwa': Block */
+static const OnigCodePoint CR_In_Tagbanwa[] = {
+ 1,
+ 0x1760, 0x177f,
+}; /* CR_In_Tagbanwa */
+
+/* 'In_Khmer': Block */
+static const OnigCodePoint CR_In_Khmer[] = {
+ 1,
+ 0x1780, 0x17ff,
+}; /* CR_In_Khmer */
+
+/* 'In_Mongolian': Block */
+static const OnigCodePoint CR_In_Mongolian[] = {
+ 1,
+ 0x1800, 0x18af,
+}; /* CR_In_Mongolian */
+
+/* 'In_Unified_Canadian_Aboriginal_Syllabics_Extended': Block */
+static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended[] = {
+ 1,
+ 0x18b0, 0x18ff,
+}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended */
+
+/* 'In_Limbu': Block */
+static const OnigCodePoint CR_In_Limbu[] = {
+ 1,
+ 0x1900, 0x194f,
+}; /* CR_In_Limbu */
+
+/* 'In_Tai_Le': Block */
+static const OnigCodePoint CR_In_Tai_Le[] = {
+ 1,
+ 0x1950, 0x197f,
+}; /* CR_In_Tai_Le */
+
+/* 'In_New_Tai_Lue': Block */
+static const OnigCodePoint CR_In_New_Tai_Lue[] = {
+ 1,
+ 0x1980, 0x19df,
+}; /* CR_In_New_Tai_Lue */
+
+/* 'In_Khmer_Symbols': Block */
+static const OnigCodePoint CR_In_Khmer_Symbols[] = {
+ 1,
+ 0x19e0, 0x19ff,
+}; /* CR_In_Khmer_Symbols */
+
+/* 'In_Buginese': Block */
+static const OnigCodePoint CR_In_Buginese[] = {
+ 1,
+ 0x1a00, 0x1a1f,
+}; /* CR_In_Buginese */
+
+/* 'In_Tai_Tham': Block */
+static const OnigCodePoint CR_In_Tai_Tham[] = {
+ 1,
+ 0x1a20, 0x1aaf,
+}; /* CR_In_Tai_Tham */
+
+/* 'In_Combining_Diacritical_Marks_Extended': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Extended[] = {
+ 1,
+ 0x1ab0, 0x1aff,
+}; /* CR_In_Combining_Diacritical_Marks_Extended */
+
+/* 'In_Balinese': Block */
+static const OnigCodePoint CR_In_Balinese[] = {
+ 1,
+ 0x1b00, 0x1b7f,
+}; /* CR_In_Balinese */
+
+/* 'In_Sundanese': Block */
+static const OnigCodePoint CR_In_Sundanese[] = {
+ 1,
+ 0x1b80, 0x1bbf,
+}; /* CR_In_Sundanese */
+
+/* 'In_Batak': Block */
+static const OnigCodePoint CR_In_Batak[] = {
+ 1,
+ 0x1bc0, 0x1bff,
+}; /* CR_In_Batak */
+
+/* 'In_Lepcha': Block */
+static const OnigCodePoint CR_In_Lepcha[] = {
+ 1,
+ 0x1c00, 0x1c4f,
+}; /* CR_In_Lepcha */
+
+/* 'In_Ol_Chiki': Block */
+#define CR_In_Ol_Chiki CR_Ol_Chiki
+
+/* 'In_Cyrillic_Extended_C': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_C[] = {
+ 1,
+ 0x1c80, 0x1c8f,
+}; /* CR_In_Cyrillic_Extended_C */
+
+/* 'In_Sundanese_Supplement': Block */
+static const OnigCodePoint CR_In_Sundanese_Supplement[] = {
+ 1,
+ 0x1cc0, 0x1ccf,
+}; /* CR_In_Sundanese_Supplement */
+
+/* 'In_Vedic_Extensions': Block */
+static const OnigCodePoint CR_In_Vedic_Extensions[] = {
+ 1,
+ 0x1cd0, 0x1cff,
+}; /* CR_In_Vedic_Extensions */
+
+/* 'In_Phonetic_Extensions': Block */
+static const OnigCodePoint CR_In_Phonetic_Extensions[] = {
+ 1,
+ 0x1d00, 0x1d7f,
+}; /* CR_In_Phonetic_Extensions */
+
+/* 'In_Phonetic_Extensions_Supplement': Block */
+static const OnigCodePoint CR_In_Phonetic_Extensions_Supplement[] = {
+ 1,
+ 0x1d80, 0x1dbf,
+}; /* CR_In_Phonetic_Extensions_Supplement */
+
+/* 'In_Combining_Diacritical_Marks_Supplement': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Supplement[] = {
+ 1,
+ 0x1dc0, 0x1dff,
+}; /* CR_In_Combining_Diacritical_Marks_Supplement */
+
+/* 'In_Latin_Extended_Additional': Block */
+static const OnigCodePoint CR_In_Latin_Extended_Additional[] = {
+ 1,
+ 0x1e00, 0x1eff,
+}; /* CR_In_Latin_Extended_Additional */
+
+/* 'In_Greek_Extended': Block */
+static const OnigCodePoint CR_In_Greek_Extended[] = {
+ 1,
+ 0x1f00, 0x1fff,
+}; /* CR_In_Greek_Extended */
+
+/* 'In_General_Punctuation': Block */
+static const OnigCodePoint CR_In_General_Punctuation[] = {
+ 1,
+ 0x2000, 0x206f,
+}; /* CR_In_General_Punctuation */
+
+/* 'In_Superscripts_and_Subscripts': Block */
+static const OnigCodePoint CR_In_Superscripts_and_Subscripts[] = {
+ 1,
+ 0x2070, 0x209f,
+}; /* CR_In_Superscripts_and_Subscripts */
+
+/* 'In_Currency_Symbols': Block */
+static const OnigCodePoint CR_In_Currency_Symbols[] = {
+ 1,
+ 0x20a0, 0x20cf,
+}; /* CR_In_Currency_Symbols */
+
+/* 'In_Combining_Diacritical_Marks_for_Symbols': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_for_Symbols[] = {
+ 1,
+ 0x20d0, 0x20ff,
+}; /* CR_In_Combining_Diacritical_Marks_for_Symbols */
+
+/* 'In_Letterlike_Symbols': Block */
+static const OnigCodePoint CR_In_Letterlike_Symbols[] = {
+ 1,
+ 0x2100, 0x214f,
+}; /* CR_In_Letterlike_Symbols */
+
+/* 'In_Number_Forms': Block */
+static const OnigCodePoint CR_In_Number_Forms[] = {
+ 1,
+ 0x2150, 0x218f,
+}; /* CR_In_Number_Forms */
+
+/* 'In_Arrows': Block */
+static const OnigCodePoint CR_In_Arrows[] = {
+ 1,
+ 0x2190, 0x21ff,
+}; /* CR_In_Arrows */
+
+/* 'In_Mathematical_Operators': Block */
+static const OnigCodePoint CR_In_Mathematical_Operators[] = {
+ 1,
+ 0x2200, 0x22ff,
+}; /* CR_In_Mathematical_Operators */
+
+/* 'In_Miscellaneous_Technical': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Technical[] = {
+ 1,
+ 0x2300, 0x23ff,
+}; /* CR_In_Miscellaneous_Technical */
+
+/* 'In_Control_Pictures': Block */
+static const OnigCodePoint CR_In_Control_Pictures[] = {
+ 1,
+ 0x2400, 0x243f,
+}; /* CR_In_Control_Pictures */
+
+/* 'In_Optical_Character_Recognition': Block */
+static const OnigCodePoint CR_In_Optical_Character_Recognition[] = {
+ 1,
+ 0x2440, 0x245f,
+}; /* CR_In_Optical_Character_Recognition */
+
+/* 'In_Enclosed_Alphanumerics': Block */
+static const OnigCodePoint CR_In_Enclosed_Alphanumerics[] = {
+ 1,
+ 0x2460, 0x24ff,
+}; /* CR_In_Enclosed_Alphanumerics */
+
+/* 'In_Box_Drawing': Block */
+static const OnigCodePoint CR_In_Box_Drawing[] = {
+ 1,
+ 0x2500, 0x257f,
+}; /* CR_In_Box_Drawing */
+
+/* 'In_Block_Elements': Block */
+static const OnigCodePoint CR_In_Block_Elements[] = {
+ 1,
+ 0x2580, 0x259f,
+}; /* CR_In_Block_Elements */
+
+/* 'In_Geometric_Shapes': Block */
+static const OnigCodePoint CR_In_Geometric_Shapes[] = {
+ 1,
+ 0x25a0, 0x25ff,
+}; /* CR_In_Geometric_Shapes */
+
+/* 'In_Miscellaneous_Symbols': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols[] = {
+ 1,
+ 0x2600, 0x26ff,
+}; /* CR_In_Miscellaneous_Symbols */
+
+/* 'In_Dingbats': Block */
+static const OnigCodePoint CR_In_Dingbats[] = {
+ 1,
+ 0x2700, 0x27bf,
+}; /* CR_In_Dingbats */
+
+/* 'In_Miscellaneous_Mathematical_Symbols_A': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_A[] = {
+ 1,
+ 0x27c0, 0x27ef,
+}; /* CR_In_Miscellaneous_Mathematical_Symbols_A */
+
+/* 'In_Supplemental_Arrows_A': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_A[] = {
+ 1,
+ 0x27f0, 0x27ff,
+}; /* CR_In_Supplemental_Arrows_A */
+
+/* 'In_Braille_Patterns': Block */
+#define CR_In_Braille_Patterns CR_Braille
+
+/* 'In_Supplemental_Arrows_B': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_B[] = {
+ 1,
+ 0x2900, 0x297f,
+}; /* CR_In_Supplemental_Arrows_B */
+
+/* 'In_Miscellaneous_Mathematical_Symbols_B': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_B[] = {
+ 1,
+ 0x2980, 0x29ff,
+}; /* CR_In_Miscellaneous_Mathematical_Symbols_B */
+
+/* 'In_Supplemental_Mathematical_Operators': Block */
+static const OnigCodePoint CR_In_Supplemental_Mathematical_Operators[] = {
+ 1,
+ 0x2a00, 0x2aff,
+}; /* CR_In_Supplemental_Mathematical_Operators */
+
+/* 'In_Miscellaneous_Symbols_and_Arrows': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Arrows[] = {
+ 1,
+ 0x2b00, 0x2bff,
+}; /* CR_In_Miscellaneous_Symbols_and_Arrows */
+
+/* 'In_Glagolitic': Block */
+static const OnigCodePoint CR_In_Glagolitic[] = {
+ 1,
+ 0x2c00, 0x2c5f,
+}; /* CR_In_Glagolitic */
+
+/* 'In_Latin_Extended_C': Block */
+static const OnigCodePoint CR_In_Latin_Extended_C[] = {
+ 1,
+ 0x2c60, 0x2c7f,
+}; /* CR_In_Latin_Extended_C */
+
+/* 'In_Coptic': Block */
+static const OnigCodePoint CR_In_Coptic[] = {
+ 1,
+ 0x2c80, 0x2cff,
+}; /* CR_In_Coptic */
+
+/* 'In_Georgian_Supplement': Block */
+static const OnigCodePoint CR_In_Georgian_Supplement[] = {
+ 1,
+ 0x2d00, 0x2d2f,
+}; /* CR_In_Georgian_Supplement */
+
+/* 'In_Tifinagh': Block */
+static const OnigCodePoint CR_In_Tifinagh[] = {
+ 1,
+ 0x2d30, 0x2d7f,
+}; /* CR_In_Tifinagh */
+
+/* 'In_Ethiopic_Extended': Block */
+static const OnigCodePoint CR_In_Ethiopic_Extended[] = {
+ 1,
+ 0x2d80, 0x2ddf,
+}; /* CR_In_Ethiopic_Extended */
+
+/* 'In_Cyrillic_Extended_A': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_A[] = {
+ 1,
+ 0x2de0, 0x2dff,
+}; /* CR_In_Cyrillic_Extended_A */
+
+/* 'In_Supplemental_Punctuation': Block */
+static const OnigCodePoint CR_In_Supplemental_Punctuation[] = {
+ 1,
+ 0x2e00, 0x2e7f,
+}; /* CR_In_Supplemental_Punctuation */
+
+/* 'In_CJK_Radicals_Supplement': Block */
+static const OnigCodePoint CR_In_CJK_Radicals_Supplement[] = {
+ 1,
+ 0x2e80, 0x2eff,
+}; /* CR_In_CJK_Radicals_Supplement */
+
+/* 'In_Kangxi_Radicals': Block */
+static const OnigCodePoint CR_In_Kangxi_Radicals[] = {
+ 1,
+ 0x2f00, 0x2fdf,
+}; /* CR_In_Kangxi_Radicals */
+
+/* 'In_Ideographic_Description_Characters': Block */
+static const OnigCodePoint CR_In_Ideographic_Description_Characters[] = {
+ 1,
+ 0x2ff0, 0x2fff,
+}; /* CR_In_Ideographic_Description_Characters */
+
+/* 'In_CJK_Symbols_and_Punctuation': Block */
+static const OnigCodePoint CR_In_CJK_Symbols_and_Punctuation[] = {
+ 1,
+ 0x3000, 0x303f,
+}; /* CR_In_CJK_Symbols_and_Punctuation */
+
+/* 'In_Hiragana': Block */
+static const OnigCodePoint CR_In_Hiragana[] = {
+ 1,
+ 0x3040, 0x309f,
+}; /* CR_In_Hiragana */
+
+/* 'In_Katakana': Block */
+static const OnigCodePoint CR_In_Katakana[] = {
+ 1,
+ 0x30a0, 0x30ff,
+}; /* CR_In_Katakana */
+
+/* 'In_Bopomofo': Block */
+static const OnigCodePoint CR_In_Bopomofo[] = {
+ 1,
+ 0x3100, 0x312f,
+}; /* CR_In_Bopomofo */
+
+/* 'In_Hangul_Compatibility_Jamo': Block */
+static const OnigCodePoint CR_In_Hangul_Compatibility_Jamo[] = {
+ 1,
+ 0x3130, 0x318f,
+}; /* CR_In_Hangul_Compatibility_Jamo */
+
+/* 'In_Kanbun': Block */
+static const OnigCodePoint CR_In_Kanbun[] = {
+ 1,
+ 0x3190, 0x319f,
+}; /* CR_In_Kanbun */
+
+/* 'In_Bopomofo_Extended': Block */
+static const OnigCodePoint CR_In_Bopomofo_Extended[] = {
+ 1,
+ 0x31a0, 0x31bf,
+}; /* CR_In_Bopomofo_Extended */
+
+/* 'In_CJK_Strokes': Block */
+static const OnigCodePoint CR_In_CJK_Strokes[] = {
+ 1,
+ 0x31c0, 0x31ef,
+}; /* CR_In_CJK_Strokes */
+
+/* 'In_Katakana_Phonetic_Extensions': Block */
+static const OnigCodePoint CR_In_Katakana_Phonetic_Extensions[] = {
+ 1,
+ 0x31f0, 0x31ff,
+}; /* CR_In_Katakana_Phonetic_Extensions */
+
+/* 'In_Enclosed_CJK_Letters_and_Months': Block */
+static const OnigCodePoint CR_In_Enclosed_CJK_Letters_and_Months[] = {
+ 1,
+ 0x3200, 0x32ff,
+}; /* CR_In_Enclosed_CJK_Letters_and_Months */
+
+/* 'In_CJK_Compatibility': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility[] = {
+ 1,
+ 0x3300, 0x33ff,
+}; /* CR_In_CJK_Compatibility */
+
+/* 'In_CJK_Unified_Ideographs_Extension_A': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_A[] = {
+ 1,
+ 0x3400, 0x4dbf,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_A */
+
+/* 'In_Yijing_Hexagram_Symbols': Block */
+static const OnigCodePoint CR_In_Yijing_Hexagram_Symbols[] = {
+ 1,
+ 0x4dc0, 0x4dff,
+}; /* CR_In_Yijing_Hexagram_Symbols */
+
+/* 'In_CJK_Unified_Ideographs': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs[] = {
+ 1,
+ 0x4e00, 0x9fff,
+}; /* CR_In_CJK_Unified_Ideographs */
+
+/* 'In_Yi_Syllables': Block */
+static const OnigCodePoint CR_In_Yi_Syllables[] = {
+ 1,
+ 0xa000, 0xa48f,
+}; /* CR_In_Yi_Syllables */
+
+/* 'In_Yi_Radicals': Block */
+static const OnigCodePoint CR_In_Yi_Radicals[] = {
+ 1,
+ 0xa490, 0xa4cf,
+}; /* CR_In_Yi_Radicals */
+
+/* 'In_Lisu': Block */
+#define CR_In_Lisu CR_Lisu
+
+/* 'In_Vai': Block */
+static const OnigCodePoint CR_In_Vai[] = {
+ 1,
+ 0xa500, 0xa63f,
+}; /* CR_In_Vai */
+
+/* 'In_Cyrillic_Extended_B': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_B[] = {
+ 1,
+ 0xa640, 0xa69f,
+}; /* CR_In_Cyrillic_Extended_B */
+
+/* 'In_Bamum': Block */
+static const OnigCodePoint CR_In_Bamum[] = {
+ 1,
+ 0xa6a0, 0xa6ff,
+}; /* CR_In_Bamum */
+
+/* 'In_Modifier_Tone_Letters': Block */
+static const OnigCodePoint CR_In_Modifier_Tone_Letters[] = {
+ 1,
+ 0xa700, 0xa71f,
+}; /* CR_In_Modifier_Tone_Letters */
+
+/* 'In_Latin_Extended_D': Block */
+static const OnigCodePoint CR_In_Latin_Extended_D[] = {
+ 1,
+ 0xa720, 0xa7ff,
+}; /* CR_In_Latin_Extended_D */
+
+/* 'In_Syloti_Nagri': Block */
+static const OnigCodePoint CR_In_Syloti_Nagri[] = {
+ 1,
+ 0xa800, 0xa82f,
+}; /* CR_In_Syloti_Nagri */
+
+/* 'In_Common_Indic_Number_Forms': Block */
+static const OnigCodePoint CR_In_Common_Indic_Number_Forms[] = {
+ 1,
+ 0xa830, 0xa83f,
+}; /* CR_In_Common_Indic_Number_Forms */
+
+/* 'In_Phags_pa': Block */
+static const OnigCodePoint CR_In_Phags_pa[] = {
+ 1,
+ 0xa840, 0xa87f,
+}; /* CR_In_Phags_pa */
+
+/* 'In_Saurashtra': Block */
+static const OnigCodePoint CR_In_Saurashtra[] = {
+ 1,
+ 0xa880, 0xa8df,
+}; /* CR_In_Saurashtra */
+
+/* 'In_Devanagari_Extended': Block */
+static const OnigCodePoint CR_In_Devanagari_Extended[] = {
+ 1,
+ 0xa8e0, 0xa8ff,
+}; /* CR_In_Devanagari_Extended */
+
+/* 'In_Kayah_Li': Block */
+static const OnigCodePoint CR_In_Kayah_Li[] = {
+ 1,
+ 0xa900, 0xa92f,
+}; /* CR_In_Kayah_Li */
+
+/* 'In_Rejang': Block */
+static const OnigCodePoint CR_In_Rejang[] = {
+ 1,
+ 0xa930, 0xa95f,
+}; /* CR_In_Rejang */
+
+/* 'In_Hangul_Jamo_Extended_A': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo_Extended_A[] = {
+ 1,
+ 0xa960, 0xa97f,
+}; /* CR_In_Hangul_Jamo_Extended_A */
+
+/* 'In_Javanese': Block */
+static const OnigCodePoint CR_In_Javanese[] = {
+ 1,
+ 0xa980, 0xa9df,
+}; /* CR_In_Javanese */
+
+/* 'In_Myanmar_Extended_B': Block */
+static const OnigCodePoint CR_In_Myanmar_Extended_B[] = {
+ 1,
+ 0xa9e0, 0xa9ff,
+}; /* CR_In_Myanmar_Extended_B */
+
+/* 'In_Cham': Block */
+static const OnigCodePoint CR_In_Cham[] = {
+ 1,
+ 0xaa00, 0xaa5f,
+}; /* CR_In_Cham */
+
+/* 'In_Myanmar_Extended_A': Block */
+static const OnigCodePoint CR_In_Myanmar_Extended_A[] = {
+ 1,
+ 0xaa60, 0xaa7f,
+}; /* CR_In_Myanmar_Extended_A */
+
+/* 'In_Tai_Viet': Block */
+static const OnigCodePoint CR_In_Tai_Viet[] = {
+ 1,
+ 0xaa80, 0xaadf,
+}; /* CR_In_Tai_Viet */
+
+/* 'In_Meetei_Mayek_Extensions': Block */
+static const OnigCodePoint CR_In_Meetei_Mayek_Extensions[] = {
+ 1,
+ 0xaae0, 0xaaff,
+}; /* CR_In_Meetei_Mayek_Extensions */
+
+/* 'In_Ethiopic_Extended_A': Block */
+static const OnigCodePoint CR_In_Ethiopic_Extended_A[] = {
+ 1,
+ 0xab00, 0xab2f,
+}; /* CR_In_Ethiopic_Extended_A */
+
+/* 'In_Latin_Extended_E': Block */
+static const OnigCodePoint CR_In_Latin_Extended_E[] = {
+ 1,
+ 0xab30, 0xab6f,
+}; /* CR_In_Latin_Extended_E */
+
+/* 'In_Cherokee_Supplement': Block */
+static const OnigCodePoint CR_In_Cherokee_Supplement[] = {
+ 1,
+ 0xab70, 0xabbf,
+}; /* CR_In_Cherokee_Supplement */
+
+/* 'In_Meetei_Mayek': Block */
+static const OnigCodePoint CR_In_Meetei_Mayek[] = {
+ 1,
+ 0xabc0, 0xabff,
+}; /* CR_In_Meetei_Mayek */
+
+/* 'In_Hangul_Syllables': Block */
+static const OnigCodePoint CR_In_Hangul_Syllables[] = {
+ 1,
+ 0xac00, 0xd7af,
+}; /* CR_In_Hangul_Syllables */
+
+/* 'In_Hangul_Jamo_Extended_B': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo_Extended_B[] = {
+ 1,
+ 0xd7b0, 0xd7ff,
+}; /* CR_In_Hangul_Jamo_Extended_B */
+
+/* 'In_High_Surrogates': Block */
+static const OnigCodePoint CR_In_High_Surrogates[] = {
+ 1,
+ 0xd800, 0xdb7f,
+}; /* CR_In_High_Surrogates */
+
+/* 'In_High_Private_Use_Surrogates': Block */
+static const OnigCodePoint CR_In_High_Private_Use_Surrogates[] = {
+ 1,
+ 0xdb80, 0xdbff,
+}; /* CR_In_High_Private_Use_Surrogates */
+
+/* 'In_Low_Surrogates': Block */
+static const OnigCodePoint CR_In_Low_Surrogates[] = {
+ 1,
+ 0xdc00, 0xdfff,
+}; /* CR_In_Low_Surrogates */
+
+/* 'In_Private_Use_Area': Block */
+static const OnigCodePoint CR_In_Private_Use_Area[] = {
+ 1,
+ 0xe000, 0xf8ff,
+}; /* CR_In_Private_Use_Area */
+
+/* 'In_CJK_Compatibility_Ideographs': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs[] = {
+ 1,
+ 0xf900, 0xfaff,
+}; /* CR_In_CJK_Compatibility_Ideographs */
+
+/* 'In_Alphabetic_Presentation_Forms': Block */
+static const OnigCodePoint CR_In_Alphabetic_Presentation_Forms[] = {
+ 1,
+ 0xfb00, 0xfb4f,
+}; /* CR_In_Alphabetic_Presentation_Forms */
+
+/* 'In_Arabic_Presentation_Forms_A': Block */
+static const OnigCodePoint CR_In_Arabic_Presentation_Forms_A[] = {
+ 1,
+ 0xfb50, 0xfdff,
+}; /* CR_In_Arabic_Presentation_Forms_A */
+
+/* 'In_Variation_Selectors': Block */
+static const OnigCodePoint CR_In_Variation_Selectors[] = {
+ 1,
+ 0xfe00, 0xfe0f,
+}; /* CR_In_Variation_Selectors */
+
+/* 'In_Vertical_Forms': Block */
+static const OnigCodePoint CR_In_Vertical_Forms[] = {
+ 1,
+ 0xfe10, 0xfe1f,
+}; /* CR_In_Vertical_Forms */
+
+/* 'In_Combining_Half_Marks': Block */
+static const OnigCodePoint CR_In_Combining_Half_Marks[] = {
+ 1,
+ 0xfe20, 0xfe2f,
+}; /* CR_In_Combining_Half_Marks */
+
+/* 'In_CJK_Compatibility_Forms': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Forms[] = {
+ 1,
+ 0xfe30, 0xfe4f,
+}; /* CR_In_CJK_Compatibility_Forms */
+
+/* 'In_Small_Form_Variants': Block */
+static const OnigCodePoint CR_In_Small_Form_Variants[] = {
+ 1,
+ 0xfe50, 0xfe6f,
+}; /* CR_In_Small_Form_Variants */
+
+/* 'In_Arabic_Presentation_Forms_B': Block */
+static const OnigCodePoint CR_In_Arabic_Presentation_Forms_B[] = {
+ 1,
+ 0xfe70, 0xfeff,
+}; /* CR_In_Arabic_Presentation_Forms_B */
+
+/* 'In_Halfwidth_and_Fullwidth_Forms': Block */
+static const OnigCodePoint CR_In_Halfwidth_and_Fullwidth_Forms[] = {
+ 1,
+ 0xff00, 0xffef,
+}; /* CR_In_Halfwidth_and_Fullwidth_Forms */
+
+/* 'In_Specials': Block */
+static const OnigCodePoint CR_In_Specials[] = {
+ 1,
+ 0xfff0, 0xffff,
+}; /* CR_In_Specials */
+
+/* 'In_Linear_B_Syllabary': Block */
+static const OnigCodePoint CR_In_Linear_B_Syllabary[] = {
+ 1,
+ 0x10000, 0x1007f,
+}; /* CR_In_Linear_B_Syllabary */
+
+/* 'In_Linear_B_Ideograms': Block */
+static const OnigCodePoint CR_In_Linear_B_Ideograms[] = {
+ 1,
+ 0x10080, 0x100ff,
+}; /* CR_In_Linear_B_Ideograms */
+
+/* 'In_Aegean_Numbers': Block */
+static const OnigCodePoint CR_In_Aegean_Numbers[] = {
+ 1,
+ 0x10100, 0x1013f,
+}; /* CR_In_Aegean_Numbers */
+
+/* 'In_Ancient_Greek_Numbers': Block */
+static const OnigCodePoint CR_In_Ancient_Greek_Numbers[] = {
+ 1,
+ 0x10140, 0x1018f,
+}; /* CR_In_Ancient_Greek_Numbers */
+
+/* 'In_Ancient_Symbols': Block */
+static const OnigCodePoint CR_In_Ancient_Symbols[] = {
+ 1,
+ 0x10190, 0x101cf,
+}; /* CR_In_Ancient_Symbols */
+
+/* 'In_Phaistos_Disc': Block */
+static const OnigCodePoint CR_In_Phaistos_Disc[] = {
+ 1,
+ 0x101d0, 0x101ff,
+}; /* CR_In_Phaistos_Disc */
+
+/* 'In_Lycian': Block */
+static const OnigCodePoint CR_In_Lycian[] = {
+ 1,
+ 0x10280, 0x1029f,
+}; /* CR_In_Lycian */
+
+/* 'In_Carian': Block */
+static const OnigCodePoint CR_In_Carian[] = {
+ 1,
+ 0x102a0, 0x102df,
+}; /* CR_In_Carian */
+
+/* 'In_Coptic_Epact_Numbers': Block */
+static const OnigCodePoint CR_In_Coptic_Epact_Numbers[] = {
+ 1,
+ 0x102e0, 0x102ff,
+}; /* CR_In_Coptic_Epact_Numbers */
+
+/* 'In_Old_Italic': Block */
+static const OnigCodePoint CR_In_Old_Italic[] = {
+ 1,
+ 0x10300, 0x1032f,
+}; /* CR_In_Old_Italic */
+
+/* 'In_Gothic': Block */
+static const OnigCodePoint CR_In_Gothic[] = {
+ 1,
+ 0x10330, 0x1034f,
+}; /* CR_In_Gothic */
+
+/* 'In_Old_Permic': Block */
+static const OnigCodePoint CR_In_Old_Permic[] = {
+ 1,
+ 0x10350, 0x1037f,
+}; /* CR_In_Old_Permic */
+
+/* 'In_Ugaritic': Block */
+static const OnigCodePoint CR_In_Ugaritic[] = {
+ 1,
+ 0x10380, 0x1039f,
+}; /* CR_In_Ugaritic */
+
+/* 'In_Old_Persian': Block */
+static const OnigCodePoint CR_In_Old_Persian[] = {
+ 1,
+ 0x103a0, 0x103df,
+}; /* CR_In_Old_Persian */
+
+/* 'In_Deseret': Block */
+#define CR_In_Deseret CR_Deseret
+
+/* 'In_Shavian': Block */
+#define CR_In_Shavian CR_Shavian
+
+/* 'In_Osmanya': Block */
+static const OnigCodePoint CR_In_Osmanya[] = {
+ 1,
+ 0x10480, 0x104af,
+}; /* CR_In_Osmanya */
+
+/* 'In_Osage': Block */
+static const OnigCodePoint CR_In_Osage[] = {
+ 1,
+ 0x104b0, 0x104ff,
+}; /* CR_In_Osage */
+
+/* 'In_Elbasan': Block */
+static const OnigCodePoint CR_In_Elbasan[] = {
+ 1,
+ 0x10500, 0x1052f,
+}; /* CR_In_Elbasan */
+
+/* 'In_Caucasian_Albanian': Block */
+static const OnigCodePoint CR_In_Caucasian_Albanian[] = {
+ 1,
+ 0x10530, 0x1056f,
+}; /* CR_In_Caucasian_Albanian */
+
+/* 'In_Linear_A': Block */
+static const OnigCodePoint CR_In_Linear_A[] = {
+ 1,
+ 0x10600, 0x1077f,
+}; /* CR_In_Linear_A */
+
+/* 'In_Cypriot_Syllabary': Block */
+static const OnigCodePoint CR_In_Cypriot_Syllabary[] = {
+ 1,
+ 0x10800, 0x1083f,
+}; /* CR_In_Cypriot_Syllabary */
+
+/* 'In_Imperial_Aramaic': Block */
+static const OnigCodePoint CR_In_Imperial_Aramaic[] = {
+ 1,
+ 0x10840, 0x1085f,
+}; /* CR_In_Imperial_Aramaic */
+
+/* 'In_Palmyrene': Block */
+#define CR_In_Palmyrene CR_Palmyrene
+
+/* 'In_Nabataean': Block */
+static const OnigCodePoint CR_In_Nabataean[] = {
+ 1,
+ 0x10880, 0x108af,
+}; /* CR_In_Nabataean */
+
+/* 'In_Hatran': Block */
+static const OnigCodePoint CR_In_Hatran[] = {
+ 1,
+ 0x108e0, 0x108ff,
+}; /* CR_In_Hatran */
+
+/* 'In_Phoenician': Block */
+static const OnigCodePoint CR_In_Phoenician[] = {
+ 1,
+ 0x10900, 0x1091f,
+}; /* CR_In_Phoenician */
+
+/* 'In_Lydian': Block */
+static const OnigCodePoint CR_In_Lydian[] = {
+ 1,
+ 0x10920, 0x1093f,
+}; /* CR_In_Lydian */
+
+/* 'In_Meroitic_Hieroglyphs': Block */
+#define CR_In_Meroitic_Hieroglyphs CR_Meroitic_Hieroglyphs
+
+/* 'In_Meroitic_Cursive': Block */
+static const OnigCodePoint CR_In_Meroitic_Cursive[] = {
+ 1,
+ 0x109a0, 0x109ff,
+}; /* CR_In_Meroitic_Cursive */
+
+/* 'In_Kharoshthi': Block */
+static const OnigCodePoint CR_In_Kharoshthi[] = {
+ 1,
+ 0x10a00, 0x10a5f,
+}; /* CR_In_Kharoshthi */
+
+/* 'In_Old_South_Arabian': Block */
+#define CR_In_Old_South_Arabian CR_Old_South_Arabian
+
+/* 'In_Old_North_Arabian': Block */
+#define CR_In_Old_North_Arabian CR_Old_North_Arabian
+
+/* 'In_Manichaean': Block */
+static const OnigCodePoint CR_In_Manichaean[] = {
+ 1,
+ 0x10ac0, 0x10aff,
+}; /* CR_In_Manichaean */
+
+/* 'In_Avestan': Block */
+static const OnigCodePoint CR_In_Avestan[] = {
+ 1,
+ 0x10b00, 0x10b3f,
+}; /* CR_In_Avestan */
+
+/* 'In_Inscriptional_Parthian': Block */
+static const OnigCodePoint CR_In_Inscriptional_Parthian[] = {
+ 1,
+ 0x10b40, 0x10b5f,
+}; /* CR_In_Inscriptional_Parthian */
+
+/* 'In_Inscriptional_Pahlavi': Block */
+static const OnigCodePoint CR_In_Inscriptional_Pahlavi[] = {
+ 1,
+ 0x10b60, 0x10b7f,
+}; /* CR_In_Inscriptional_Pahlavi */
+
+/* 'In_Psalter_Pahlavi': Block */
+static const OnigCodePoint CR_In_Psalter_Pahlavi[] = {
+ 1,
+ 0x10b80, 0x10baf,
+}; /* CR_In_Psalter_Pahlavi */
+
+/* 'In_Old_Turkic': Block */
+static const OnigCodePoint CR_In_Old_Turkic[] = {
+ 1,
+ 0x10c00, 0x10c4f,
+}; /* CR_In_Old_Turkic */
+
+/* 'In_Old_Hungarian': Block */
+static const OnigCodePoint CR_In_Old_Hungarian[] = {
+ 1,
+ 0x10c80, 0x10cff,
+}; /* CR_In_Old_Hungarian */
+
+/* 'In_Rumi_Numeral_Symbols': Block */
+static const OnigCodePoint CR_In_Rumi_Numeral_Symbols[] = {
+ 1,
+ 0x10e60, 0x10e7f,
+}; /* CR_In_Rumi_Numeral_Symbols */
+
+/* 'In_Brahmi': Block */
+static const OnigCodePoint CR_In_Brahmi[] = {
+ 1,
+ 0x11000, 0x1107f,
+}; /* CR_In_Brahmi */
+
+/* 'In_Kaithi': Block */
+static const OnigCodePoint CR_In_Kaithi[] = {
+ 1,
+ 0x11080, 0x110cf,
+}; /* CR_In_Kaithi */
+
+/* 'In_Sora_Sompeng': Block */
+static const OnigCodePoint CR_In_Sora_Sompeng[] = {
+ 1,
+ 0x110d0, 0x110ff,
+}; /* CR_In_Sora_Sompeng */
+
+/* 'In_Chakma': Block */
+static const OnigCodePoint CR_In_Chakma[] = {
+ 1,
+ 0x11100, 0x1114f,
+}; /* CR_In_Chakma */
+
+/* 'In_Mahajani': Block */
+static const OnigCodePoint CR_In_Mahajani[] = {
+ 1,
+ 0x11150, 0x1117f,
+}; /* CR_In_Mahajani */
+
+/* 'In_Sharada': Block */
+static const OnigCodePoint CR_In_Sharada[] = {
+ 1,
+ 0x11180, 0x111df,
+}; /* CR_In_Sharada */
+
+/* 'In_Sinhala_Archaic_Numbers': Block */
+static const OnigCodePoint CR_In_Sinhala_Archaic_Numbers[] = {
+ 1,
+ 0x111e0, 0x111ff,
+}; /* CR_In_Sinhala_Archaic_Numbers */
+
+/* 'In_Khojki': Block */
+static const OnigCodePoint CR_In_Khojki[] = {
+ 1,
+ 0x11200, 0x1124f,
+}; /* CR_In_Khojki */
+
+/* 'In_Multani': Block */
+static const OnigCodePoint CR_In_Multani[] = {
+ 1,
+ 0x11280, 0x112af,
+}; /* CR_In_Multani */
+
+/* 'In_Khudawadi': Block */
+static const OnigCodePoint CR_In_Khudawadi[] = {
+ 1,
+ 0x112b0, 0x112ff,
+}; /* CR_In_Khudawadi */
+
+/* 'In_Grantha': Block */
+static const OnigCodePoint CR_In_Grantha[] = {
+ 1,
+ 0x11300, 0x1137f,
+}; /* CR_In_Grantha */
+
+/* 'In_Newa': Block */
+static const OnigCodePoint CR_In_Newa[] = {
+ 1,
+ 0x11400, 0x1147f,
+}; /* CR_In_Newa */
+
+/* 'In_Tirhuta': Block */
+static const OnigCodePoint CR_In_Tirhuta[] = {
+ 1,
+ 0x11480, 0x114df,
+}; /* CR_In_Tirhuta */
+
+/* 'In_Siddham': Block */
+static const OnigCodePoint CR_In_Siddham[] = {
+ 1,
+ 0x11580, 0x115ff,
+}; /* CR_In_Siddham */
+
+/* 'In_Modi': Block */
+static const OnigCodePoint CR_In_Modi[] = {
+ 1,
+ 0x11600, 0x1165f,
+}; /* CR_In_Modi */
+
+/* 'In_Mongolian_Supplement': Block */
+static const OnigCodePoint CR_In_Mongolian_Supplement[] = {
+ 1,
+ 0x11660, 0x1167f,
+}; /* CR_In_Mongolian_Supplement */
+
+/* 'In_Takri': Block */
+static const OnigCodePoint CR_In_Takri[] = {
+ 1,
+ 0x11680, 0x116cf,
+}; /* CR_In_Takri */
+
+/* 'In_Ahom': Block */
+static const OnigCodePoint CR_In_Ahom[] = {
+ 1,
+ 0x11700, 0x1173f,
+}; /* CR_In_Ahom */
+
+/* 'In_Warang_Citi': Block */
+static const OnigCodePoint CR_In_Warang_Citi[] = {
+ 1,
+ 0x118a0, 0x118ff,
+}; /* CR_In_Warang_Citi */
+
+/* 'In_Zanabazar_Square': Block */
+static const OnigCodePoint CR_In_Zanabazar_Square[] = {
+ 1,
+ 0x11a00, 0x11a4f,
+}; /* CR_In_Zanabazar_Square */
+
+/* 'In_Soyombo': Block */
+static const OnigCodePoint CR_In_Soyombo[] = {
+ 1,
+ 0x11a50, 0x11aaf,
+}; /* CR_In_Soyombo */
+
+/* 'In_Pau_Cin_Hau': Block */
+static const OnigCodePoint CR_In_Pau_Cin_Hau[] = {
+ 1,
+ 0x11ac0, 0x11aff,
+}; /* CR_In_Pau_Cin_Hau */
+
+/* 'In_Bhaiksuki': Block */
+static const OnigCodePoint CR_In_Bhaiksuki[] = {
+ 1,
+ 0x11c00, 0x11c6f,
+}; /* CR_In_Bhaiksuki */
+
+/* 'In_Marchen': Block */
+static const OnigCodePoint CR_In_Marchen[] = {
+ 1,
+ 0x11c70, 0x11cbf,
+}; /* CR_In_Marchen */
+
+/* 'In_Masaram_Gondi': Block */
+static const OnigCodePoint CR_In_Masaram_Gondi[] = {
+ 1,
+ 0x11d00, 0x11d5f,
+}; /* CR_In_Masaram_Gondi */
+
+/* 'In_Cuneiform': Block */
+static const OnigCodePoint CR_In_Cuneiform[] = {
+ 1,
+ 0x12000, 0x123ff,
+}; /* CR_In_Cuneiform */
+
+/* 'In_Cuneiform_Numbers_and_Punctuation': Block */
+static const OnigCodePoint CR_In_Cuneiform_Numbers_and_Punctuation[] = {
+ 1,
+ 0x12400, 0x1247f,
+}; /* CR_In_Cuneiform_Numbers_and_Punctuation */
+
+/* 'In_Early_Dynastic_Cuneiform': Block */
+static const OnigCodePoint CR_In_Early_Dynastic_Cuneiform[] = {
+ 1,
+ 0x12480, 0x1254f,
+}; /* CR_In_Early_Dynastic_Cuneiform */
+
+/* 'In_Egyptian_Hieroglyphs': Block */
+static const OnigCodePoint CR_In_Egyptian_Hieroglyphs[] = {
+ 1,
+ 0x13000, 0x1342f,
+}; /* CR_In_Egyptian_Hieroglyphs */
+
+/* 'In_Anatolian_Hieroglyphs': Block */
+static const OnigCodePoint CR_In_Anatolian_Hieroglyphs[] = {
+ 1,
+ 0x14400, 0x1467f,
+}; /* CR_In_Anatolian_Hieroglyphs */
+
+/* 'In_Bamum_Supplement': Block */
+static const OnigCodePoint CR_In_Bamum_Supplement[] = {
+ 1,
+ 0x16800, 0x16a3f,
+}; /* CR_In_Bamum_Supplement */
+
+/* 'In_Mro': Block */
+static const OnigCodePoint CR_In_Mro[] = {
+ 1,
+ 0x16a40, 0x16a6f,
+}; /* CR_In_Mro */
+
+/* 'In_Bassa_Vah': Block */
+static const OnigCodePoint CR_In_Bassa_Vah[] = {
+ 1,
+ 0x16ad0, 0x16aff,
+}; /* CR_In_Bassa_Vah */
+
+/* 'In_Pahawh_Hmong': Block */
+static const OnigCodePoint CR_In_Pahawh_Hmong[] = {
+ 1,
+ 0x16b00, 0x16b8f,
+}; /* CR_In_Pahawh_Hmong */
+
+/* 'In_Miao': Block */
+static const OnigCodePoint CR_In_Miao[] = {
+ 1,
+ 0x16f00, 0x16f9f,
+}; /* CR_In_Miao */
+
+/* 'In_Ideographic_Symbols_and_Punctuation': Block */
+static const OnigCodePoint CR_In_Ideographic_Symbols_and_Punctuation[] = {
+ 1,
+ 0x16fe0, 0x16fff,
+}; /* CR_In_Ideographic_Symbols_and_Punctuation */
+
+/* 'In_Tangut': Block */
+static const OnigCodePoint CR_In_Tangut[] = {
+ 1,
+ 0x17000, 0x187ff,
+}; /* CR_In_Tangut */
+
+/* 'In_Tangut_Components': Block */
+static const OnigCodePoint CR_In_Tangut_Components[] = {
+ 1,
+ 0x18800, 0x18aff,
+}; /* CR_In_Tangut_Components */
+
+/* 'In_Kana_Supplement': Block */
+static const OnigCodePoint CR_In_Kana_Supplement[] = {
+ 1,
+ 0x1b000, 0x1b0ff,
+}; /* CR_In_Kana_Supplement */
+
+/* 'In_Kana_Extended_A': Block */
+static const OnigCodePoint CR_In_Kana_Extended_A[] = {
+ 1,
+ 0x1b100, 0x1b12f,
+}; /* CR_In_Kana_Extended_A */
+
+/* 'In_Nushu': Block */
+static const OnigCodePoint CR_In_Nushu[] = {
+ 1,
+ 0x1b170, 0x1b2ff,
+}; /* CR_In_Nushu */
+
+/* 'In_Duployan': Block */
+static const OnigCodePoint CR_In_Duployan[] = {
+ 1,
+ 0x1bc00, 0x1bc9f,
+}; /* CR_In_Duployan */
+
+/* 'In_Shorthand_Format_Controls': Block */
+static const OnigCodePoint CR_In_Shorthand_Format_Controls[] = {
+ 1,
+ 0x1bca0, 0x1bcaf,
+}; /* CR_In_Shorthand_Format_Controls */
+
+/* 'In_Byzantine_Musical_Symbols': Block */
+static const OnigCodePoint CR_In_Byzantine_Musical_Symbols[] = {
+ 1,
+ 0x1d000, 0x1d0ff,
+}; /* CR_In_Byzantine_Musical_Symbols */
+
+/* 'In_Musical_Symbols': Block */
+static const OnigCodePoint CR_In_Musical_Symbols[] = {
+ 1,
+ 0x1d100, 0x1d1ff,
+}; /* CR_In_Musical_Symbols */
+
+/* 'In_Ancient_Greek_Musical_Notation': Block */
+static const OnigCodePoint CR_In_Ancient_Greek_Musical_Notation[] = {
+ 1,
+ 0x1d200, 0x1d24f,
+}; /* CR_In_Ancient_Greek_Musical_Notation */
+
+/* 'In_Tai_Xuan_Jing_Symbols': Block */
+static const OnigCodePoint CR_In_Tai_Xuan_Jing_Symbols[] = {
+ 1,
+ 0x1d300, 0x1d35f,
+}; /* CR_In_Tai_Xuan_Jing_Symbols */
+
+/* 'In_Counting_Rod_Numerals': Block */
+static const OnigCodePoint CR_In_Counting_Rod_Numerals[] = {
+ 1,
+ 0x1d360, 0x1d37f,
+}; /* CR_In_Counting_Rod_Numerals */
+
+/* 'In_Mathematical_Alphanumeric_Symbols': Block */
+static const OnigCodePoint CR_In_Mathematical_Alphanumeric_Symbols[] = {
+ 1,
+ 0x1d400, 0x1d7ff,
+}; /* CR_In_Mathematical_Alphanumeric_Symbols */
+
+/* 'In_Sutton_SignWriting': Block */
+static const OnigCodePoint CR_In_Sutton_SignWriting[] = {
+ 1,
+ 0x1d800, 0x1daaf,
+}; /* CR_In_Sutton_SignWriting */
+
+/* 'In_Glagolitic_Supplement': Block */
+static const OnigCodePoint CR_In_Glagolitic_Supplement[] = {
+ 1,
+ 0x1e000, 0x1e02f,
+}; /* CR_In_Glagolitic_Supplement */
+
+/* 'In_Mende_Kikakui': Block */
+static const OnigCodePoint CR_In_Mende_Kikakui[] = {
+ 1,
+ 0x1e800, 0x1e8df,
+}; /* CR_In_Mende_Kikakui */
+
+/* 'In_Adlam': Block */
+static const OnigCodePoint CR_In_Adlam[] = {
+ 1,
+ 0x1e900, 0x1e95f,
+}; /* CR_In_Adlam */
+
+/* 'In_Arabic_Mathematical_Alphabetic_Symbols': Block */
+static const OnigCodePoint CR_In_Arabic_Mathematical_Alphabetic_Symbols[] = {
+ 1,
+ 0x1ee00, 0x1eeff,
+}; /* CR_In_Arabic_Mathematical_Alphabetic_Symbols */
+
+/* 'In_Mahjong_Tiles': Block */
+static const OnigCodePoint CR_In_Mahjong_Tiles[] = {
+ 1,
+ 0x1f000, 0x1f02f,
+}; /* CR_In_Mahjong_Tiles */
+
+/* 'In_Domino_Tiles': Block */
+static const OnigCodePoint CR_In_Domino_Tiles[] = {
+ 1,
+ 0x1f030, 0x1f09f,
+}; /* CR_In_Domino_Tiles */
+
+/* 'In_Playing_Cards': Block */
+static const OnigCodePoint CR_In_Playing_Cards[] = {
+ 1,
+ 0x1f0a0, 0x1f0ff,
+}; /* CR_In_Playing_Cards */
+
+/* 'In_Enclosed_Alphanumeric_Supplement': Block */
+static const OnigCodePoint CR_In_Enclosed_Alphanumeric_Supplement[] = {
+ 1,
+ 0x1f100, 0x1f1ff,
+}; /* CR_In_Enclosed_Alphanumeric_Supplement */
+
+/* 'In_Enclosed_Ideographic_Supplement': Block */
+static const OnigCodePoint CR_In_Enclosed_Ideographic_Supplement[] = {
+ 1,
+ 0x1f200, 0x1f2ff,
+}; /* CR_In_Enclosed_Ideographic_Supplement */
+
+/* 'In_Miscellaneous_Symbols_and_Pictographs': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Pictographs[] = {
+ 1,
+ 0x1f300, 0x1f5ff,
+}; /* CR_In_Miscellaneous_Symbols_and_Pictographs */
+
+/* 'In_Emoticons': Block */
+static const OnigCodePoint CR_In_Emoticons[] = {
+ 1,
+ 0x1f600, 0x1f64f,
+}; /* CR_In_Emoticons */
+
+/* 'In_Ornamental_Dingbats': Block */
+static const OnigCodePoint CR_In_Ornamental_Dingbats[] = {
+ 1,
+ 0x1f650, 0x1f67f,
+}; /* CR_In_Ornamental_Dingbats */
+
+/* 'In_Transport_and_Map_Symbols': Block */
+static const OnigCodePoint CR_In_Transport_and_Map_Symbols[] = {
+ 1,
+ 0x1f680, 0x1f6ff,
+}; /* CR_In_Transport_and_Map_Symbols */
+
+/* 'In_Alchemical_Symbols': Block */
+static const OnigCodePoint CR_In_Alchemical_Symbols[] = {
+ 1,
+ 0x1f700, 0x1f77f,
+}; /* CR_In_Alchemical_Symbols */
+
+/* 'In_Geometric_Shapes_Extended': Block */
+static const OnigCodePoint CR_In_Geometric_Shapes_Extended[] = {
+ 1,
+ 0x1f780, 0x1f7ff,
+}; /* CR_In_Geometric_Shapes_Extended */
+
+/* 'In_Supplemental_Arrows_C': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_C[] = {
+ 1,
+ 0x1f800, 0x1f8ff,
+}; /* CR_In_Supplemental_Arrows_C */
+
+/* 'In_Supplemental_Symbols_and_Pictographs': Block */
+static const OnigCodePoint CR_In_Supplemental_Symbols_and_Pictographs[] = {
+ 1,
+ 0x1f900, 0x1f9ff,
+}; /* CR_In_Supplemental_Symbols_and_Pictographs */
+
+/* 'In_CJK_Unified_Ideographs_Extension_B': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_B[] = {
+ 1,
+ 0x20000, 0x2a6df,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_B */
+
+/* 'In_CJK_Unified_Ideographs_Extension_C': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_C[] = {
+ 1,
+ 0x2a700, 0x2b73f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_C */
+
+/* 'In_CJK_Unified_Ideographs_Extension_D': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_D[] = {
+ 1,
+ 0x2b740, 0x2b81f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_D */
+
+/* 'In_CJK_Unified_Ideographs_Extension_E': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_E[] = {
+ 1,
+ 0x2b820, 0x2ceaf,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_E */
+
+/* 'In_CJK_Unified_Ideographs_Extension_F': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_F[] = {
+ 1,
+ 0x2ceb0, 0x2ebef,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_F */
+
+/* 'In_CJK_Compatibility_Ideographs_Supplement': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs_Supplement[] = {
+ 1,
+ 0x2f800, 0x2fa1f,
+}; /* CR_In_CJK_Compatibility_Ideographs_Supplement */
+
+/* 'In_Tags': Block */
+static const OnigCodePoint CR_In_Tags[] = {
+ 1,
+ 0xe0000, 0xe007f,
+}; /* CR_In_Tags */
+
+/* 'In_Variation_Selectors_Supplement': Block */
+static const OnigCodePoint CR_In_Variation_Selectors_Supplement[] = {
+ 1,
+ 0xe0100, 0xe01ef,
+}; /* CR_In_Variation_Selectors_Supplement */
+
+/* 'In_Supplementary_Private_Use_Area_A': Block */
+static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_A[] = {
+ 1,
+ 0xf0000, 0xfffff,
+}; /* CR_In_Supplementary_Private_Use_Area_A */
+
+/* 'In_Supplementary_Private_Use_Area_B': Block */
+static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_B[] = {
+ 1,
+ 0x100000, 0x10ffff,
+}; /* CR_In_Supplementary_Private_Use_Area_B */
+
+/* 'In_No_Block': Block */
+static const OnigCodePoint CR_In_No_Block[] = {
+ 47,
+ 0x0870, 0x089f,
+ 0x1c90, 0x1cbf,
+ 0x2fe0, 0x2fef,
+ 0x10200, 0x1027f,
+ 0x103e0, 0x103ff,
+ 0x10570, 0x105ff,
+ 0x10780, 0x107ff,
+ 0x108b0, 0x108df,
+ 0x10940, 0x1097f,
+ 0x10aa0, 0x10abf,
+ 0x10bb0, 0x10bff,
+ 0x10c50, 0x10c7f,
+ 0x10d00, 0x10e5f,
+ 0x10e80, 0x10fff,
+ 0x11250, 0x1127f,
+ 0x11380, 0x113ff,
+ 0x114e0, 0x1157f,
+ 0x116d0, 0x116ff,
+ 0x11740, 0x1189f,
+ 0x11900, 0x119ff,
+ 0x11ab0, 0x11abf,
+ 0x11b00, 0x11bff,
+ 0x11cc0, 0x11cff,
+ 0x11d60, 0x11fff,
+ 0x12550, 0x12fff,
+ 0x13430, 0x143ff,
+ 0x14680, 0x167ff,
+ 0x16a70, 0x16acf,
+ 0x16b90, 0x16eff,
+ 0x16fa0, 0x16fdf,
+ 0x18b00, 0x1afff,
+ 0x1b130, 0x1b16f,
+ 0x1b300, 0x1bbff,
+ 0x1bcb0, 0x1cfff,
+ 0x1d250, 0x1d2ff,
+ 0x1d380, 0x1d3ff,
+ 0x1dab0, 0x1dfff,
+ 0x1e030, 0x1e7ff,
+ 0x1e8e0, 0x1e8ff,
+ 0x1e960, 0x1edff,
+ 0x1ef00, 0x1efff,
+ 0x1fa00, 0x1ffff,
+ 0x2a6e0, 0x2a6ff,
+ 0x2ebf0, 0x2f7ff,
+ 0x2fa20, 0xdffff,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0xeffff,
+}; /* CR_In_No_Block */
+
+#endif /* USE_UNICODE_PROPERTIES */
+static const OnigCodePoint* const CodeRanges[] = {
+ CR_NEWLINE,
+ CR_Alpha,
+ CR_Blank,
+ CR_Cntrl,
+ CR_Digit,
+ CR_Graph,
+ CR_Lower,
+ CR_Print,
+ CR_XPosixPunct,
+ CR_Space,
+ CR_Upper,
+ CR_XDigit,
+ CR_Word,
+ CR_Alnum,
+ CR_ASCII,
+ CR_Punct,
+#ifdef USE_UNICODE_PROPERTIES
+ CR_Any,
+ CR_Assigned,
+ CR_C,
+ CR_Cc,
+ CR_Cf,
+ CR_Cn,
+ CR_Co,
+ CR_Cs,
+ CR_L,
+ CR_LC,
+ CR_Ll,
+ CR_Lm,
+ CR_Lo,
+ CR_Lt,
+ CR_Lu,
+ CR_M,
+ CR_Mc,
+ CR_Me,
+ CR_Mn,
+ CR_N,
+ CR_Nd,
+ CR_Nl,
+ CR_No,
+ CR_P,
+ CR_Pc,
+ CR_Pd,
+ CR_Pe,
+ CR_Pf,
+ CR_Pi,
+ CR_Po,
+ CR_Ps,
+ CR_S,
+ CR_Sc,
+ CR_Sk,
+ CR_Sm,
+ CR_So,
+ CR_Z,
+ CR_Zl,
+ CR_Zp,
+ CR_Zs,
+ CR_Math,
+ CR_Alphabetic,
+ CR_Lowercase,
+ CR_Uppercase,
+ CR_Cased,
+ CR_Case_Ignorable,
+ CR_Changes_When_Lowercased,
+ CR_Changes_When_Uppercased,
+ CR_Changes_When_Titlecased,
+ CR_Changes_When_Casefolded,
+ CR_Changes_When_Casemapped,
+ CR_ID_Start,
+ CR_ID_Continue,
+ CR_XID_Start,
+ CR_XID_Continue,
+ CR_Default_Ignorable_Code_Point,
+ CR_Grapheme_Extend,
+ CR_Grapheme_Base,
+ CR_Grapheme_Link,
+ CR_Common,
+ CR_Latin,
+ CR_Greek,
+ CR_Cyrillic,
+ CR_Armenian,
+ CR_Hebrew,
+ CR_Arabic,
+ CR_Syriac,
+ CR_Thaana,
+ CR_Devanagari,
+ CR_Bengali,
+ CR_Gurmukhi,
+ CR_Gujarati,
+ CR_Oriya,
+ CR_Tamil,
+ CR_Telugu,
+ CR_Kannada,
+ CR_Malayalam,
+ CR_Sinhala,
+ CR_Thai,
+ CR_Lao,
+ CR_Tibetan,
+ CR_Myanmar,
+ CR_Georgian,
+ CR_Hangul,
+ CR_Ethiopic,
+ CR_Cherokee,
+ CR_Canadian_Aboriginal,
+ CR_Ogham,
+ CR_Runic,
+ CR_Khmer,
+ CR_Mongolian,
+ CR_Hiragana,
+ CR_Katakana,
+ CR_Bopomofo,
+ CR_Han,
+ CR_Yi,
+ CR_Old_Italic,
+ CR_Gothic,
+ CR_Deseret,
+ CR_Inherited,
+ CR_Tagalog,
+ CR_Hanunoo,
+ CR_Buhid,
+ CR_Tagbanwa,
+ CR_Limbu,
+ CR_Tai_Le,
+ CR_Linear_B,
+ CR_Ugaritic,
+ CR_Shavian,
+ CR_Osmanya,
+ CR_Cypriot,
+ CR_Braille,
+ CR_Buginese,
+ CR_Coptic,
+ CR_New_Tai_Lue,
+ CR_Glagolitic,
+ CR_Tifinagh,
+ CR_Syloti_Nagri,
+ CR_Old_Persian,
+ CR_Kharoshthi,
+ CR_Balinese,
+ CR_Cuneiform,
+ CR_Phoenician,
+ CR_Phags_Pa,
+ CR_Nko,
+ CR_Sundanese,
+ CR_Lepcha,
+ CR_Ol_Chiki,
+ CR_Vai,
+ CR_Saurashtra,
+ CR_Kayah_Li,
+ CR_Rejang,
+ CR_Lycian,
+ CR_Carian,
+ CR_Lydian,
+ CR_Cham,
+ CR_Tai_Tham,
+ CR_Tai_Viet,
+ CR_Avestan,
+ CR_Egyptian_Hieroglyphs,
+ CR_Samaritan,
+ CR_Lisu,
+ CR_Bamum,
+ CR_Javanese,
+ CR_Meetei_Mayek,
+ CR_Imperial_Aramaic,
+ CR_Old_South_Arabian,
+ CR_Inscriptional_Parthian,
+ CR_Inscriptional_Pahlavi,
+ CR_Old_Turkic,
+ CR_Kaithi,
+ CR_Batak,
+ CR_Brahmi,
+ CR_Mandaic,
+ CR_Chakma,
+ CR_Meroitic_Cursive,
+ CR_Meroitic_Hieroglyphs,
+ CR_Miao,
+ CR_Sharada,
+ CR_Sora_Sompeng,
+ CR_Takri,
+ CR_Caucasian_Albanian,
+ CR_Bassa_Vah,
+ CR_Duployan,
+ CR_Elbasan,
+ CR_Grantha,
+ CR_Pahawh_Hmong,
+ CR_Khojki,
+ CR_Linear_A,
+ CR_Mahajani,
+ CR_Manichaean,
+ CR_Mende_Kikakui,
+ CR_Modi,
+ CR_Mro,
+ CR_Old_North_Arabian,
+ CR_Nabataean,
+ CR_Palmyrene,
+ CR_Pau_Cin_Hau,
+ CR_Old_Permic,
+ CR_Psalter_Pahlavi,
+ CR_Siddham,
+ CR_Khudawadi,
+ CR_Tirhuta,
+ CR_Warang_Citi,
+ CR_Ahom,
+ CR_Anatolian_Hieroglyphs,
+ CR_Hatran,
+ CR_Multani,
+ CR_Old_Hungarian,
+ CR_SignWriting,
+ CR_Adlam,
+ CR_Bhaiksuki,
+ CR_Marchen,
+ CR_Newa,
+ CR_Osage,
+ CR_Tangut,
+ CR_Masaram_Gondi,
+ CR_Nushu,
+ CR_Soyombo,
+ CR_Zanabazar_Square,
+ CR_White_Space,
+ CR_Bidi_Control,
+ CR_Join_Control,
+ CR_Dash,
+ CR_Hyphen,
+ CR_Quotation_Mark,
+ CR_Terminal_Punctuation,
+ CR_Other_Math,
+ CR_Hex_Digit,
+ CR_ASCII_Hex_Digit,
+ CR_Other_Alphabetic,
+ CR_Ideographic,
+ CR_Diacritic,
+ CR_Extender,
+ CR_Other_Lowercase,
+ CR_Other_Uppercase,
+ CR_Noncharacter_Code_Point,
+ CR_Other_Grapheme_Extend,
+ CR_IDS_Binary_Operator,
+ CR_IDS_Trinary_Operator,
+ CR_Radical,
+ CR_Unified_Ideograph,
+ CR_Other_Default_Ignorable_Code_Point,
+ CR_Deprecated,
+ CR_Soft_Dotted,
+ CR_Logical_Order_Exception,
+ CR_Other_ID_Start,
+ CR_Other_ID_Continue,
+ CR_Sentence_Terminal,
+ CR_Variation_Selector,
+ CR_Pattern_White_Space,
+ CR_Pattern_Syntax,
+ CR_Prepended_Concatenation_Mark,
+ CR_Regional_Indicator,
+ CR_Emoji,
+ CR_Emoji_Presentation,
+ CR_Emoji_Modifier,
+ CR_Emoji_Modifier_Base,
+ CR_Emoji_Component,
+ CR_Unknown,
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ CR_Age_1_1,
+ CR_Age_2_0,
+ CR_Age_2_1,
+ CR_Age_3_0,
+ CR_Age_3_1,
+ CR_Age_3_2,
+ CR_Age_4_0,
+ CR_Age_4_1,
+ CR_Age_5_0,
+ CR_Age_5_1,
+ CR_Age_5_2,
+ CR_Age_6_0,
+ CR_Age_6_1,
+ CR_Age_6_2,
+ CR_Age_6_3,
+ CR_Age_7_0,
+ CR_Age_8_0,
+ CR_Age_9_0,
+ CR_Age_10_0,
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ CR_Grapheme_Cluster_Break_Prepend,
+ CR_Grapheme_Cluster_Break_CR,
+ CR_Grapheme_Cluster_Break_LF,
+ CR_Grapheme_Cluster_Break_Control,
+ CR_Grapheme_Cluster_Break_Extend,
+ CR_Grapheme_Cluster_Break_Regional_Indicator,
+ CR_Grapheme_Cluster_Break_SpacingMark,
+ CR_Grapheme_Cluster_Break_L,
+ CR_Grapheme_Cluster_Break_V,
+ CR_Grapheme_Cluster_Break_T,
+ CR_Grapheme_Cluster_Break_LV,
+ CR_Grapheme_Cluster_Break_LVT,
+ CR_Grapheme_Cluster_Break_E_Base,
+ CR_Grapheme_Cluster_Break_E_Modifier,
+ CR_Grapheme_Cluster_Break_ZWJ,
+ CR_Grapheme_Cluster_Break_Glue_After_Zwj,
+ CR_Grapheme_Cluster_Break_E_Base_GAZ,
+ CR_In_Basic_Latin,
+ CR_In_Latin_1_Supplement,
+ CR_In_Latin_Extended_A,
+ CR_In_Latin_Extended_B,
+ CR_In_IPA_Extensions,
+ CR_In_Spacing_Modifier_Letters,
+ CR_In_Combining_Diacritical_Marks,
+ CR_In_Greek_and_Coptic,
+ CR_In_Cyrillic,
+ CR_In_Cyrillic_Supplement,
+ CR_In_Armenian,
+ CR_In_Hebrew,
+ CR_In_Arabic,
+ CR_In_Syriac,
+ CR_In_Arabic_Supplement,
+ CR_In_Thaana,
+ CR_In_NKo,
+ CR_In_Samaritan,
+ CR_In_Mandaic,
+ CR_In_Syriac_Supplement,
+ CR_In_Arabic_Extended_A,
+ CR_In_Devanagari,
+ CR_In_Bengali,
+ CR_In_Gurmukhi,
+ CR_In_Gujarati,
+ CR_In_Oriya,
+ CR_In_Tamil,
+ CR_In_Telugu,
+ CR_In_Kannada,
+ CR_In_Malayalam,
+ CR_In_Sinhala,
+ CR_In_Thai,
+ CR_In_Lao,
+ CR_In_Tibetan,
+ CR_In_Myanmar,
+ CR_In_Georgian,
+ CR_In_Hangul_Jamo,
+ CR_In_Ethiopic,
+ CR_In_Ethiopic_Supplement,
+ CR_In_Cherokee,
+ CR_In_Unified_Canadian_Aboriginal_Syllabics,
+ CR_In_Ogham,
+ CR_In_Runic,
+ CR_In_Tagalog,
+ CR_In_Hanunoo,
+ CR_In_Buhid,
+ CR_In_Tagbanwa,
+ CR_In_Khmer,
+ CR_In_Mongolian,
+ CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended,
+ CR_In_Limbu,
+ CR_In_Tai_Le,
+ CR_In_New_Tai_Lue,
+ CR_In_Khmer_Symbols,
+ CR_In_Buginese,
+ CR_In_Tai_Tham,
+ CR_In_Combining_Diacritical_Marks_Extended,
+ CR_In_Balinese,
+ CR_In_Sundanese,
+ CR_In_Batak,
+ CR_In_Lepcha,
+ CR_In_Ol_Chiki,
+ CR_In_Cyrillic_Extended_C,
+ CR_In_Sundanese_Supplement,
+ CR_In_Vedic_Extensions,
+ CR_In_Phonetic_Extensions,
+ CR_In_Phonetic_Extensions_Supplement,
+ CR_In_Combining_Diacritical_Marks_Supplement,
+ CR_In_Latin_Extended_Additional,
+ CR_In_Greek_Extended,
+ CR_In_General_Punctuation,
+ CR_In_Superscripts_and_Subscripts,
+ CR_In_Currency_Symbols,
+ CR_In_Combining_Diacritical_Marks_for_Symbols,
+ CR_In_Letterlike_Symbols,
+ CR_In_Number_Forms,
+ CR_In_Arrows,
+ CR_In_Mathematical_Operators,
+ CR_In_Miscellaneous_Technical,
+ CR_In_Control_Pictures,
+ CR_In_Optical_Character_Recognition,
+ CR_In_Enclosed_Alphanumerics,
+ CR_In_Box_Drawing,
+ CR_In_Block_Elements,
+ CR_In_Geometric_Shapes,
+ CR_In_Miscellaneous_Symbols,
+ CR_In_Dingbats,
+ CR_In_Miscellaneous_Mathematical_Symbols_A,
+ CR_In_Supplemental_Arrows_A,
+ CR_In_Braille_Patterns,
+ CR_In_Supplemental_Arrows_B,
+ CR_In_Miscellaneous_Mathematical_Symbols_B,
+ CR_In_Supplemental_Mathematical_Operators,
+ CR_In_Miscellaneous_Symbols_and_Arrows,
+ CR_In_Glagolitic,
+ CR_In_Latin_Extended_C,
+ CR_In_Coptic,
+ CR_In_Georgian_Supplement,
+ CR_In_Tifinagh,
+ CR_In_Ethiopic_Extended,
+ CR_In_Cyrillic_Extended_A,
+ CR_In_Supplemental_Punctuation,
+ CR_In_CJK_Radicals_Supplement,
+ CR_In_Kangxi_Radicals,
+ CR_In_Ideographic_Description_Characters,
+ CR_In_CJK_Symbols_and_Punctuation,
+ CR_In_Hiragana,
+ CR_In_Katakana,
+ CR_In_Bopomofo,
+ CR_In_Hangul_Compatibility_Jamo,
+ CR_In_Kanbun,
+ CR_In_Bopomofo_Extended,
+ CR_In_CJK_Strokes,
+ CR_In_Katakana_Phonetic_Extensions,
+ CR_In_Enclosed_CJK_Letters_and_Months,
+ CR_In_CJK_Compatibility,
+ CR_In_CJK_Unified_Ideographs_Extension_A,
+ CR_In_Yijing_Hexagram_Symbols,
+ CR_In_CJK_Unified_Ideographs,
+ CR_In_Yi_Syllables,
+ CR_In_Yi_Radicals,
+ CR_In_Lisu,
+ CR_In_Vai,
+ CR_In_Cyrillic_Extended_B,
+ CR_In_Bamum,
+ CR_In_Modifier_Tone_Letters,
+ CR_In_Latin_Extended_D,
+ CR_In_Syloti_Nagri,
+ CR_In_Common_Indic_Number_Forms,
+ CR_In_Phags_pa,
+ CR_In_Saurashtra,
+ CR_In_Devanagari_Extended,
+ CR_In_Kayah_Li,
+ CR_In_Rejang,
+ CR_In_Hangul_Jamo_Extended_A,
+ CR_In_Javanese,
+ CR_In_Myanmar_Extended_B,
+ CR_In_Cham,
+ CR_In_Myanmar_Extended_A,
+ CR_In_Tai_Viet,
+ CR_In_Meetei_Mayek_Extensions,
+ CR_In_Ethiopic_Extended_A,
+ CR_In_Latin_Extended_E,
+ CR_In_Cherokee_Supplement,
+ CR_In_Meetei_Mayek,
+ CR_In_Hangul_Syllables,
+ CR_In_Hangul_Jamo_Extended_B,
+ CR_In_High_Surrogates,
+ CR_In_High_Private_Use_Surrogates,
+ CR_In_Low_Surrogates,
+ CR_In_Private_Use_Area,
+ CR_In_CJK_Compatibility_Ideographs,
+ CR_In_Alphabetic_Presentation_Forms,
+ CR_In_Arabic_Presentation_Forms_A,
+ CR_In_Variation_Selectors,
+ CR_In_Vertical_Forms,
+ CR_In_Combining_Half_Marks,
+ CR_In_CJK_Compatibility_Forms,
+ CR_In_Small_Form_Variants,
+ CR_In_Arabic_Presentation_Forms_B,
+ CR_In_Halfwidth_and_Fullwidth_Forms,
+ CR_In_Specials,
+ CR_In_Linear_B_Syllabary,
+ CR_In_Linear_B_Ideograms,
+ CR_In_Aegean_Numbers,
+ CR_In_Ancient_Greek_Numbers,
+ CR_In_Ancient_Symbols,
+ CR_In_Phaistos_Disc,
+ CR_In_Lycian,
+ CR_In_Carian,
+ CR_In_Coptic_Epact_Numbers,
+ CR_In_Old_Italic,
+ CR_In_Gothic,
+ CR_In_Old_Permic,
+ CR_In_Ugaritic,
+ CR_In_Old_Persian,
+ CR_In_Deseret,
+ CR_In_Shavian,
+ CR_In_Osmanya,
+ CR_In_Osage,
+ CR_In_Elbasan,
+ CR_In_Caucasian_Albanian,
+ CR_In_Linear_A,
+ CR_In_Cypriot_Syllabary,
+ CR_In_Imperial_Aramaic,
+ CR_In_Palmyrene,
+ CR_In_Nabataean,
+ CR_In_Hatran,
+ CR_In_Phoenician,
+ CR_In_Lydian,
+ CR_In_Meroitic_Hieroglyphs,
+ CR_In_Meroitic_Cursive,
+ CR_In_Kharoshthi,
+ CR_In_Old_South_Arabian,
+ CR_In_Old_North_Arabian,
+ CR_In_Manichaean,
+ CR_In_Avestan,
+ CR_In_Inscriptional_Parthian,
+ CR_In_Inscriptional_Pahlavi,
+ CR_In_Psalter_Pahlavi,
+ CR_In_Old_Turkic,
+ CR_In_Old_Hungarian,
+ CR_In_Rumi_Numeral_Symbols,
+ CR_In_Brahmi,
+ CR_In_Kaithi,
+ CR_In_Sora_Sompeng,
+ CR_In_Chakma,
+ CR_In_Mahajani,
+ CR_In_Sharada,
+ CR_In_Sinhala_Archaic_Numbers,
+ CR_In_Khojki,
+ CR_In_Multani,
+ CR_In_Khudawadi,
+ CR_In_Grantha,
+ CR_In_Newa,
+ CR_In_Tirhuta,
+ CR_In_Siddham,
+ CR_In_Modi,
+ CR_In_Mongolian_Supplement,
+ CR_In_Takri,
+ CR_In_Ahom,
+ CR_In_Warang_Citi,
+ CR_In_Zanabazar_Square,
+ CR_In_Soyombo,
+ CR_In_Pau_Cin_Hau,
+ CR_In_Bhaiksuki,
+ CR_In_Marchen,
+ CR_In_Masaram_Gondi,
+ CR_In_Cuneiform,
+ CR_In_Cuneiform_Numbers_and_Punctuation,
+ CR_In_Early_Dynastic_Cuneiform,
+ CR_In_Egyptian_Hieroglyphs,
+ CR_In_Anatolian_Hieroglyphs,
+ CR_In_Bamum_Supplement,
+ CR_In_Mro,
+ CR_In_Bassa_Vah,
+ CR_In_Pahawh_Hmong,
+ CR_In_Miao,
+ CR_In_Ideographic_Symbols_and_Punctuation,
+ CR_In_Tangut,
+ CR_In_Tangut_Components,
+ CR_In_Kana_Supplement,
+ CR_In_Kana_Extended_A,
+ CR_In_Nushu,
+ CR_In_Duployan,
+ CR_In_Shorthand_Format_Controls,
+ CR_In_Byzantine_Musical_Symbols,
+ CR_In_Musical_Symbols,
+ CR_In_Ancient_Greek_Musical_Notation,
+ CR_In_Tai_Xuan_Jing_Symbols,
+ CR_In_Counting_Rod_Numerals,
+ CR_In_Mathematical_Alphanumeric_Symbols,
+ CR_In_Sutton_SignWriting,
+ CR_In_Glagolitic_Supplement,
+ CR_In_Mende_Kikakui,
+ CR_In_Adlam,
+ CR_In_Arabic_Mathematical_Alphabetic_Symbols,
+ CR_In_Mahjong_Tiles,
+ CR_In_Domino_Tiles,
+ CR_In_Playing_Cards,
+ CR_In_Enclosed_Alphanumeric_Supplement,
+ CR_In_Enclosed_Ideographic_Supplement,
+ CR_In_Miscellaneous_Symbols_and_Pictographs,
+ CR_In_Emoticons,
+ CR_In_Ornamental_Dingbats,
+ CR_In_Transport_and_Map_Symbols,
+ CR_In_Alchemical_Symbols,
+ CR_In_Geometric_Shapes_Extended,
+ CR_In_Supplemental_Arrows_C,
+ CR_In_Supplemental_Symbols_and_Pictographs,
+ CR_In_CJK_Unified_Ideographs_Extension_B,
+ CR_In_CJK_Unified_Ideographs_Extension_C,
+ CR_In_CJK_Unified_Ideographs_Extension_D,
+ CR_In_CJK_Unified_Ideographs_Extension_E,
+ CR_In_CJK_Unified_Ideographs_Extension_F,
+ CR_In_CJK_Compatibility_Ideographs_Supplement,
+ CR_In_Tags,
+ CR_In_Variation_Selectors_Supplement,
+ CR_In_Supplementary_Private_Use_Area_A,
+ CR_In_Supplementary_Private_Use_Area_B,
+ CR_In_No_Block,
+#endif /* USE_UNICODE_PROPERTIES */
+};
+struct uniname2ctype_struct {
+ short name;
+ unsigned short ctype;
+};
+#define uniname2ctype_offset(str) offsetof(struct uniname2ctype_pool_t, uniname2ctype_pool_##str)
+
+#if !1+0
+static const struct uniname2ctype_struct *uniname2ctype_p(const char *, unsigned int);
+#endif
+
+#ifndef USE_UNICODE_PROPERTIES
+#define TOTAL_KEYWORDS 15
+#define MIN_WORD_LENGTH 4
+#define MAX_WORD_LENGTH 11
+#define MIN_HASH_VALUE 6
+#define MAX_HASH_VALUE 20
+/* maximum key range = 15, duplicates = 0 */
+#else /* USE_UNICODE_PROPERTIES */
+#ifndef USE_UNICODE_AGE_PROPERTIES
+#define TOTAL_KEYWORDS 775
+#else /* USE_UNICODE_AGE_PROPERTIES */
+#define TOTAL_KEYWORDS 794
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+#define MIN_WORD_LENGTH 1
+#define MAX_WORD_LENGTH 44
+#define MIN_HASH_VALUE 10
+#define MAX_HASH_VALUE 6145
+/* maximum key range = 6136, duplicates = 0 */
+#endif /* USE_UNICODE_PROPERTIES */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+uniname2ctype_hash (register const char *str, register size_t len)
+{
+#ifndef USE_UNICODE_PROPERTIES
+ static const unsigned char asso_values[] =
+#else /* USE_UNICODE_PROPERTIES */
+ static const unsigned short asso_values[] =
+#endif /* USE_UNICODE_PROPERTIES */
+ {
+#ifndef USE_UNICODE_PROPERTIES
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 3, 12, 5,
+ 4, 21, 21, 10, 21, 1, 21, 21, 11, 21,
+ 2, 1, 1, 21, 1, 7, 4, 6, 21, 1,
+ 4, 21, 21, 21, 21, 21, 21, 21
+#else /* USE_UNICODE_PROPERTIES */
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ 6146, 6146, 6146, 6146, 6146, 6146, 1, 6146, 2, 1,
+ 5, 27, 2, 15, 7, 11, 9, 8, 6146, 6146,
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146, 6146,
+ 6146, 6146, 6146, 6146, 6146, 6146, 6146, 5, 1058, 101,
+ 332, 9, 777, 1271, 842, 3, 1142, 17, 491, 70,
+ 1, 15, 741, 1115, 39, 174, 260, 566, 1127, 1473,
+ 502, 1554, 13, 2, 12, 6146, 6146, 6146, 6146, 6146
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+#ifndef USE_UNICODE_PROPERTIES
+ return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]];
+#else /* USE_UNICODE_PROPERTIES */
+ register unsigned int hval = (unsigned int)len;
+
+ switch (hval)
+ {
+ default:
+ hval += asso_values[(unsigned char)str[15]];
+ /*FALLTHROUGH*/
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ hval += asso_values[(unsigned char)str[11]];
+ /*FALLTHROUGH*/
+ case 11:
+ case 10:
+ case 9:
+ case 8:
+ case 7:
+ case 6:
+ hval += asso_values[(unsigned char)str[5]];
+ /*FALLTHROUGH*/
+ case 5:
+ hval += asso_values[(unsigned char)str[4]];
+ /*FALLTHROUGH*/
+ case 4:
+ case 3:
+ hval += asso_values[(unsigned char)str[2]];
+ /*FALLTHROUGH*/
+ case 2:
+ hval += asso_values[(unsigned char)str[1]];
+ /*FALLTHROUGH*/
+ case 1:
+ hval += asso_values[(unsigned char)str[0]+2];
+ break;
+ }
+ return hval + asso_values[(unsigned char)str[len - 1]];
+#endif /* USE_UNICODE_PROPERTIES */
+}
+
+struct uniname2ctype_pool_t
+ {
+#ifndef USE_UNICODE_PROPERTIES
+ char uniname2ctype_pool_str6[sizeof("word")];
+ char uniname2ctype_pool_str7[sizeof("print")];
+ char uniname2ctype_pool_str8[sizeof("punct")];
+ char uniname2ctype_pool_str9[sizeof("alpha")];
+ char uniname2ctype_pool_str10[sizeof("alnum")];
+ char uniname2ctype_pool_str11[sizeof("xdigit")];
+ char uniname2ctype_pool_str12[sizeof("upper")];
+ char uniname2ctype_pool_str13[sizeof("ascii")];
+ char uniname2ctype_pool_str14[sizeof("cntrl")];
+ char uniname2ctype_pool_str15[sizeof("space")];
+ char uniname2ctype_pool_str16[sizeof("xposixpunct")];
+ char uniname2ctype_pool_str17[sizeof("lower")];
+ char uniname2ctype_pool_str18[sizeof("graph")];
+ char uniname2ctype_pool_str19[sizeof("digit")];
+ char uniname2ctype_pool_str20[sizeof("blank")];
+#else /* USE_UNICODE_PROPERTIES */
+ char uniname2ctype_pool_str10[sizeof("yi")];
+ char uniname2ctype_pool_str13[sizeof("cn")];
+ char uniname2ctype_pool_str14[sizeof("lina")];
+ char uniname2ctype_pool_str15[sizeof("yiii")];
+ char uniname2ctype_pool_str16[sizeof("lana")];
+ char uniname2ctype_pool_str17[sizeof("ci")];
+ char uniname2ctype_pool_str19[sizeof("mn")];
+ char uniname2ctype_pool_str26[sizeof("z")];
+ char uniname2ctype_pool_str28[sizeof("mani")];
+ char uniname2ctype_pool_str33[sizeof("lo")];
+ char uniname2ctype_pool_str35[sizeof("me")];
+ char uniname2ctype_pool_str37[sizeof("loe")];
+ char uniname2ctype_pool_str39[sizeof("lao")];
+ char uniname2ctype_pool_str40[sizeof("laoo")];
+ char uniname2ctype_pool_str41[sizeof("co")];
+ char uniname2ctype_pool_str42[sizeof("miao")];
+ char uniname2ctype_pool_str47[sizeof("pi")];
+ char uniname2ctype_pool_str51[sizeof("inkannada")];
+ char uniname2ctype_pool_str52[sizeof("gran")];
+ char uniname2ctype_pool_str54[sizeof("innko")];
+ char uniname2ctype_pool_str55[sizeof("zzzz")];
+ char uniname2ctype_pool_str59[sizeof("pe")];
+ char uniname2ctype_pool_str60[sizeof("cari")];
+ char uniname2ctype_pool_str61[sizeof("lineara")];
+ char uniname2ctype_pool_str66[sizeof("carian")];
+ char uniname2ctype_pool_str69[sizeof("mendekikakui")];
+ char uniname2ctype_pool_str70[sizeof("geor")];
+ char uniname2ctype_pool_str71[sizeof("po")];
+ char uniname2ctype_pool_str72[sizeof("grek")];
+ char uniname2ctype_pool_str73[sizeof("meeteimayek")];
+ char uniname2ctype_pool_str80[sizeof("mark")];
+ char uniname2ctype_pool_str82[sizeof("mero")];
+ char uniname2ctype_pool_str85[sizeof("kana")];
+ char uniname2ctype_pool_str86[sizeof("m")];
+ char uniname2ctype_pool_str87[sizeof("mro")];
+ char uniname2ctype_pool_str88[sizeof("mroo")];
+ char uniname2ctype_pool_str90[sizeof("greek")];
+ char uniname2ctype_pool_str93[sizeof("gonm")];
+ char uniname2ctype_pool_str97[sizeof("inkharoshthi")];
+ char uniname2ctype_pool_str105[sizeof("cakm")];
+ char uniname2ctype_pool_str106[sizeof("inmanichaean")];
+ char uniname2ctype_pool_str111[sizeof("c")];
+ char uniname2ctype_pool_str113[sizeof("inarmenian")];
+ char uniname2ctype_pool_str117[sizeof("common")];
+ char uniname2ctype_pool_str122[sizeof("inosmanya")];
+ char uniname2ctype_pool_str123[sizeof("inmro")];
+ char uniname2ctype_pool_str129[sizeof("inmiao")];
+ char uniname2ctype_pool_str137[sizeof("mandaic")];
+ char uniname2ctype_pool_str142[sizeof("inmyanmar")];
+ char uniname2ctype_pool_str143[sizeof("lm")];
+ char uniname2ctype_pool_str150[sizeof("prependedconcatenationmark")];
+ char uniname2ctype_pool_str153[sizeof("inideographicsymbolsandpunctuation")];
+ char uniname2ctype_pool_str154[sizeof("inchakma")];
+ char uniname2ctype_pool_str160[sizeof("inkhmer")];
+ char uniname2ctype_pool_str161[sizeof("perm")];
+ char uniname2ctype_pool_str162[sizeof("connectorpunctuation")];
+ char uniname2ctype_pool_str164[sizeof("marc")];
+ char uniname2ctype_pool_str167[sizeof("combiningmark")];
+ char uniname2ctype_pool_str168[sizeof("merc")];
+ char uniname2ctype_pool_str169[sizeof("inrunic")];
+ char uniname2ctype_pool_str170[sizeof("incarian")];
+ char uniname2ctype_pool_str172[sizeof("incuneiformnumbersandpunctuation")];
+ char uniname2ctype_pool_str184[sizeof("inahom")];
+ char uniname2ctype_pool_str186[sizeof("incherokee")];
+ char uniname2ctype_pool_str191[sizeof("qaai")];
+ char uniname2ctype_pool_str193[sizeof("cans")];
+ char uniname2ctype_pool_str205[sizeof("lc")];
+ char uniname2ctype_pool_str210[sizeof("incuneiform")];
+ char uniname2ctype_pool_str213[sizeof("cc")];
+ char uniname2ctype_pool_str215[sizeof("armn")];
+ char uniname2ctype_pool_str216[sizeof("inavestan")];
+ char uniname2ctype_pool_str217[sizeof("armi")];
+ char uniname2ctype_pool_str219[sizeof("mc")];
+ char uniname2ctype_pool_str223[sizeof("armenian")];
+ char uniname2ctype_pool_str227[sizeof("inipaextensions")];
+ char uniname2ctype_pool_str238[sizeof("inmarchen")];
+ char uniname2ctype_pool_str243[sizeof("pc")];
+ char uniname2ctype_pool_str250[sizeof("insharada")];
+ char uniname2ctype_pool_str255[sizeof("lineseparator")];
+ char uniname2ctype_pool_str256[sizeof("masaramgondi")];
+ char uniname2ctype_pool_str259[sizeof("inarrows")];
+ char uniname2ctype_pool_str268[sizeof("ri")];
+ char uniname2ctype_pool_str270[sizeof("incham")];
+ char uniname2ctype_pool_str271[sizeof("latn")];
+ char uniname2ctype_pool_str272[sizeof("incyrillic")];
+ char uniname2ctype_pool_str273[sizeof("latin")];
+ char uniname2ctype_pool_str276[sizeof("inzanabazarsquare")];
+ char uniname2ctype_pool_str279[sizeof("insamaritan")];
+ char uniname2ctype_pool_str283[sizeof("pcm")];
+ char uniname2ctype_pool_str285[sizeof("inmasaramgondi")];
+ char uniname2ctype_pool_str288[sizeof("qmark")];
+ char uniname2ctype_pool_str289[sizeof("qaac")];
+ char uniname2ctype_pool_str291[sizeof("mtei")];
+ char uniname2ctype_pool_str295[sizeof("inthai")];
+ char uniname2ctype_pool_str300[sizeof("inscriptionalparthian")];
+ char uniname2ctype_pool_str301[sizeof("inthaana")];
+ char uniname2ctype_pool_str309[sizeof("inkaithi")];
+ char uniname2ctype_pool_str311[sizeof("initialpunctuation")];
+ char uniname2ctype_pool_str315[sizeof("inkatakana")];
+ char uniname2ctype_pool_str317[sizeof("inkhmersymbols")];
+ char uniname2ctype_pool_str343[sizeof("insyriac")];
+ char uniname2ctype_pool_str344[sizeof("intakri")];
+ char uniname2ctype_pool_str345[sizeof("prti")];
+ char uniname2ctype_pool_str356[sizeof("arabic")];
+ char uniname2ctype_pool_str357[sizeof("mand")];
+ char uniname2ctype_pool_str359[sizeof("cs")];
+ char uniname2ctype_pool_str361[sizeof("mend")];
+ char uniname2ctype_pool_str362[sizeof("zs")];
+ char uniname2ctype_pool_str363[sizeof("letter")];
+ char uniname2ctype_pool_str365[sizeof("privateuse")];
+ char uniname2ctype_pool_str369[sizeof("modi")];
+ char uniname2ctype_pool_str370[sizeof("katakana")];
+ char uniname2ctype_pool_str377[sizeof("ideo")];
+ char uniname2ctype_pool_str383[sizeof("brai")];
+ char uniname2ctype_pool_str384[sizeof("xidcontinue")];
+ char uniname2ctype_pool_str386[sizeof("inmyanmarextendeda")];
+ char uniname2ctype_pool_str387[sizeof("ascii")];
+ char uniname2ctype_pool_str389[sizeof("ps")];
+ char uniname2ctype_pool_str393[sizeof("inkanaextendeda")];
+ char uniname2ctype_pool_str396[sizeof("inmeeteimayek")];
+ char uniname2ctype_pool_str399[sizeof("inruminumeralsymbols")];
+ char uniname2ctype_pool_str408[sizeof("letternumber")];
+ char uniname2ctype_pool_str412[sizeof("knda")];
+ char uniname2ctype_pool_str425[sizeof("kannada")];
+ char uniname2ctype_pool_str428[sizeof("inoldnortharabian")];
+ char uniname2ctype_pool_str430[sizeof("inideographicdescriptioncharacters")];
+ char uniname2ctype_pool_str432[sizeof("inmodi")];
+ char uniname2ctype_pool_str440[sizeof("incjkcompatibilityforms")];
+ char uniname2ctype_pool_str445[sizeof("incjkcompatibilityideographs")];
+ char uniname2ctype_pool_str453[sizeof("xidc")];
+ char uniname2ctype_pool_str455[sizeof("inmendekikakui")];
+ char uniname2ctype_pool_str458[sizeof("brahmi")];
+ char uniname2ctype_pool_str480[sizeof("inolditalic")];
+ char uniname2ctype_pool_str482[sizeof("inmiscellaneousmathematicalsymbolsa")];
+ char uniname2ctype_pool_str486[sizeof("inspecials")];
+ char uniname2ctype_pool_str487[sizeof("inemoticons")];
+ char uniname2ctype_pool_str488[sizeof("patternwhitespace")];
+ char uniname2ctype_pool_str489[sizeof("gothic")];
+ char uniname2ctype_pool_str492[sizeof("intransportandmapsymbols")];
+ char uniname2ctype_pool_str493[sizeof("l")];
+ char uniname2ctype_pool_str509[sizeof("psalterpahlavi")];
+ char uniname2ctype_pool_str516[sizeof("vai")];
+ char uniname2ctype_pool_str517[sizeof("vaii")];
+ char uniname2ctype_pool_str523[sizeof("lt")];
+ char uniname2ctype_pool_str524[sizeof("meroiticcursive")];
+ char uniname2ctype_pool_str526[sizeof("xids")];
+ char uniname2ctype_pool_str530[sizeof("incommonindicnumberforms")];
+ char uniname2ctype_pool_str531[sizeof("inmandaic")];
+ char uniname2ctype_pool_str533[sizeof("inlineara")];
+ char uniname2ctype_pool_str541[sizeof("incjkcompatibilityideographssupplement")];
+ char uniname2ctype_pool_str544[sizeof("inlao")];
+ char uniname2ctype_pool_str545[sizeof("insundanese")];
+ char uniname2ctype_pool_str547[sizeof("mongolian")];
+ char uniname2ctype_pool_str552[sizeof("bamum")];
+ char uniname2ctype_pool_str554[sizeof("idc")];
+ char uniname2ctype_pool_str561[sizeof("inancientsymbols")];
+ char uniname2ctype_pool_str573[sizeof("kali")];
+ char uniname2ctype_pool_str574[sizeof("grlink")];
+ char uniname2ctype_pool_str576[sizeof("grext")];
+ char uniname2ctype_pool_str577[sizeof("control")];
+ char uniname2ctype_pool_str586[sizeof("inkanasupplement")];
+ char uniname2ctype_pool_str591[sizeof("inopticalcharacterrecognition")];
+ char uniname2ctype_pool_str596[sizeof("inadlam")];
+ char uniname2ctype_pool_str598[sizeof("so")];
+ char uniname2ctype_pool_str601[sizeof("inoldsoutharabian")];
+ char uniname2ctype_pool_str602[sizeof("sk")];
+ char uniname2ctype_pool_str606[sizeof("print")];
+ char uniname2ctype_pool_str607[sizeof("idsbinaryoperator")];
+ char uniname2ctype_pool_str609[sizeof("palm")];
+ char uniname2ctype_pool_str618[sizeof("batk")];
+ char uniname2ctype_pool_str619[sizeof("indominotiles")];
+ char uniname2ctype_pool_str620[sizeof("intaitham")];
+ char uniname2ctype_pool_str622[sizeof("inlycian")];
+ char uniname2ctype_pool_str629[sizeof("sora")];
+ char uniname2ctype_pool_str636[sizeof("batak")];
+ char uniname2ctype_pool_str642[sizeof("inmodifiertoneletters")];
+ char uniname2ctype_pool_str657[sizeof("patws")];
+ char uniname2ctype_pool_str665[sizeof("inmalayalam")];
+ char uniname2ctype_pool_str670[sizeof("incjkstrokes")];
+ char uniname2ctype_pool_str681[sizeof("incontrolpictures")];
+ char uniname2ctype_pool_str684[sizeof("samr")];
+ char uniname2ctype_pool_str689[sizeof("bass")];
+ char uniname2ctype_pool_str693[sizeof("samaritan")];
+ char uniname2ctype_pool_str699[sizeof("inmusicalsymbols")];
+ char uniname2ctype_pool_str700[sizeof("ids")];
+ char uniname2ctype_pool_str705[sizeof("pd")];
+ char uniname2ctype_pool_str708[sizeof("sm")];
+ char uniname2ctype_pool_str715[sizeof("pauc")];
+ char uniname2ctype_pool_str716[sizeof("joinc")];
+ char uniname2ctype_pool_str725[sizeof("inlinearbideograms")];
+ char uniname2ctype_pool_str730[sizeof("idcontinue")];
+ char uniname2ctype_pool_str732[sizeof("inancientgreekmusicalnotation")];
+ char uniname2ctype_pool_str737[sizeof("inoldturkic")];
+ char uniname2ctype_pool_str738[sizeof("alnum")];
+ char uniname2ctype_pool_str739[sizeof("inugaritic")];
+ char uniname2ctype_pool_str741[sizeof("s")];
+ char uniname2ctype_pool_str742[sizeof("inmiscellaneoussymbols")];
+ char uniname2ctype_pool_str743[sizeof("n")];
+ char uniname2ctype_pool_str748[sizeof("lisu")];
+ char uniname2ctype_pool_str751[sizeof("inmiscellaneoussymbolsandarrows")];
+ char uniname2ctype_pool_str753[sizeof("insylotinagri")];
+ char uniname2ctype_pool_str756[sizeof("inmiscellaneoussymbolsandpictographs")];
+ char uniname2ctype_pool_str770[sizeof("sc")];
+ char uniname2ctype_pool_str773[sizeof("no")];
+ char uniname2ctype_pool_str777[sizeof("ital")];
+ char uniname2ctype_pool_str781[sizeof("p")];
+ char uniname2ctype_pool_str782[sizeof("xpeo")];
+ char uniname2ctype_pool_str785[sizeof("di")];
+ char uniname2ctype_pool_str787[sizeof("idst")];
+ char uniname2ctype_pool_str788[sizeof("intaile")];
+ char uniname2ctype_pool_str791[sizeof("nko")];
+ char uniname2ctype_pool_str792[sizeof("nkoo")];
+ char uniname2ctype_pool_str793[sizeof("dia")];
+ char uniname2ctype_pool_str797[sizeof("inphoenician")];
+ char uniname2ctype_pool_str799[sizeof("inlatinextendeda")];
+ char uniname2ctype_pool_str802[sizeof("indeseret")];
+ char uniname2ctype_pool_str807[sizeof("inlatinextendede")];
+ char uniname2ctype_pool_str812[sizeof("incaucasianalbanian")];
+ char uniname2ctype_pool_str819[sizeof("insaurashtra")];
+ char uniname2ctype_pool_str823[sizeof("inmeeteimayekextensions")];
+ char uniname2ctype_pool_str834[sizeof("idstart")];
+ char uniname2ctype_pool_str835[sizeof("bali")];
+ char uniname2ctype_pool_str837[sizeof("inspacingmodifierletters")];
+ char uniname2ctype_pool_str848[sizeof("bengali")];
+ char uniname2ctype_pool_str849[sizeof("intamil")];
+ char uniname2ctype_pool_str851[sizeof("inmultani")];
+ char uniname2ctype_pool_str852[sizeof("vs")];
+ char uniname2ctype_pool_str853[sizeof("inlydian")];
+ char uniname2ctype_pool_str855[sizeof("balinese")];
+ char uniname2ctype_pool_str856[sizeof("lepc")];
+ char uniname2ctype_pool_str857[sizeof("cased")];
+ char uniname2ctype_pool_str862[sizeof("zinh")];
+ char uniname2ctype_pool_str867[sizeof("blank")];
+ char uniname2ctype_pool_str870[sizeof("runr")];
+ char uniname2ctype_pool_str872[sizeof("patternsyntax")];
+ char uniname2ctype_pool_str874[sizeof("bidic")];
+ char uniname2ctype_pool_str877[sizeof("xdigit")];
+ char uniname2ctype_pool_str881[sizeof("xidstart")];
+ char uniname2ctype_pool_str885[sizeof("inphaistosdisc")];
+ char uniname2ctype_pool_str897[sizeof("inancientgreeknumbers")];
+ char uniname2ctype_pool_str899[sizeof("canadianaboriginal")];
+ char uniname2ctype_pool_str903[sizeof("cher")];
+ char uniname2ctype_pool_str905[sizeof("plrd")];
+ char uniname2ctype_pool_str906[sizeof("sind")];
+ char uniname2ctype_pool_str909[sizeof("cherokee")];
+ char uniname2ctype_pool_str911[sizeof("phoenician")];
+ char uniname2ctype_pool_str918[sizeof("marchen")];
+ char uniname2ctype_pool_str919[sizeof("inhiragana")];
+ char uniname2ctype_pool_str926[sizeof("inearlydynasticcuneiform")];
+ char uniname2ctype_pool_str928[sizeof("graphemebase")];
+ char uniname2ctype_pool_str930[sizeof("cham")];
+ char uniname2ctype_pool_str931[sizeof("inimperialaramaic")];
+ char uniname2ctype_pool_str932[sizeof("kaithi")];
+ char uniname2ctype_pool_str935[sizeof("insiddham")];
+ char uniname2ctype_pool_str937[sizeof("diacritic")];
+ char uniname2ctype_pool_str942[sizeof("chakma")];
+ char uniname2ctype_pool_str944[sizeof("graphemelink")];
+ char uniname2ctype_pool_str947[sizeof("inkhudawadi")];
+ char uniname2ctype_pool_str948[sizeof("inmahajani")];
+ char uniname2ctype_pool_str956[sizeof("khojki")];
+ char uniname2ctype_pool_str957[sizeof("inogham")];
+ char uniname2ctype_pool_str960[sizeof("khar")];
+ char uniname2ctype_pool_str966[sizeof("incountingrodnumerals")];
+ char uniname2ctype_pool_str975[sizeof("manichaean")];
+ char uniname2ctype_pool_str976[sizeof("coptic")];
+ char uniname2ctype_pool_str977[sizeof("bamu")];
+ char uniname2ctype_pool_str980[sizeof("sterm")];
+ char uniname2ctype_pool_str983[sizeof("inethiopic")];
+ char uniname2ctype_pool_str985[sizeof("ll")];
+ char uniname2ctype_pool_str988[sizeof("inolchiki")];
+ char uniname2ctype_pool_str991[sizeof("inlatinextendedc")];
+ char uniname2ctype_pool_str996[sizeof("zl")];
+ char uniname2ctype_pool_str998[sizeof("adlm")];
+ char uniname2ctype_pool_str1016[sizeof("incyrillicsupplement")];
+ char uniname2ctype_pool_str1019[sizeof("incyrillicextendeda")];
+ char uniname2ctype_pool_str1022[sizeof("incherokeesupplement")];
+ char uniname2ctype_pool_str1023[sizeof("decimalnumber")];
+ char uniname2ctype_pool_str1025[sizeof("khmr")];
+ char uniname2ctype_pool_str1029[sizeof("copt")];
+ char uniname2ctype_pool_str1032[sizeof("ahom")];
+ char uniname2ctype_pool_str1034[sizeof("runic")];
+ char uniname2ctype_pool_str1048[sizeof("intaixuanjingsymbols")];
+ char uniname2ctype_pool_str1049[sizeof("insinhala")];
+ char uniname2ctype_pool_str1053[sizeof("cprt")];
+ char uniname2ctype_pool_str1056[sizeof("imperialaramaic")];
+ char uniname2ctype_pool_str1061[sizeof("casedletter")];
+ char uniname2ctype_pool_str1065[sizeof("khmer")];
+ char uniname2ctype_pool_str1067[sizeof("linb")];
+ char uniname2ctype_pool_str1069[sizeof("adlam")];
+ char uniname2ctype_pool_str1076[sizeof("ininscriptionalparthian")];
+ char uniname2ctype_pool_str1077[sizeof("ininscriptionalpahlavi")];
+ char uniname2ctype_pool_str1078[sizeof("sinhala")];
+ char uniname2ctype_pool_str1080[sizeof("zanb")];
+ char uniname2ctype_pool_str1086[sizeof("incjkunifiedideographsextensiona")];
+ char uniname2ctype_pool_str1088[sizeof("multani")];
+ char uniname2ctype_pool_str1089[sizeof("quotationmark")];
+ char uniname2ctype_pool_str1090[sizeof("incjkunifiedideographsextensione")];
+ char uniname2ctype_pool_str1094[sizeof("innabataean")];
+ char uniname2ctype_pool_str1098[sizeof("inbhaiksuki")];
+ char uniname2ctype_pool_str1100[sizeof("inelbasan")];
+ char uniname2ctype_pool_str1103[sizeof("inkanbun")];
+ char uniname2ctype_pool_str1104[sizeof("inscriptionalpahlavi")];
+ char uniname2ctype_pool_str1107[sizeof("bopo")];
+ char uniname2ctype_pool_str1114[sizeof("linearb")];
+ char uniname2ctype_pool_str1115[sizeof("incyrillicextendedc")];
+ char uniname2ctype_pool_str1116[sizeof("glagolitic")];
+ char uniname2ctype_pool_str1119[sizeof("kharoshthi")];
+ char uniname2ctype_pool_str1120[sizeof("inoldpersian")];
+ char uniname2ctype_pool_str1124[sizeof("goth")];
+ char uniname2ctype_pool_str1126[sizeof("math")];
+ char uniname2ctype_pool_str1127[sizeof("joincontrol")];
+ char uniname2ctype_pool_str1131[sizeof("punct")];
+ char uniname2ctype_pool_str1135[sizeof("lu")];
+ char uniname2ctype_pool_str1136[sizeof("limb")];
+ char uniname2ctype_pool_str1147[sizeof("inmiscellaneoustechnical")];
+ char uniname2ctype_pool_str1152[sizeof("han")];
+ char uniname2ctype_pool_str1155[sizeof("hani")];
+ char uniname2ctype_pool_str1156[sizeof("invai")];
+ char uniname2ctype_pool_str1157[sizeof("sundanese")];
+ char uniname2ctype_pool_str1158[sizeof("taile")];
+ char uniname2ctype_pool_str1160[sizeof("takri")];
+ char uniname2ctype_pool_str1161[sizeof("grantha")];
+ char uniname2ctype_pool_str1167[sizeof("hano")];
+ char uniname2ctype_pool_str1168[sizeof("inhatran")];
+ char uniname2ctype_pool_str1172[sizeof("oriya")];
+ char uniname2ctype_pool_str1173[sizeof("intirhuta")];
+ char uniname2ctype_pool_str1178[sizeof("guru")];
+ char uniname2ctype_pool_str1179[sizeof("kthi")];
+ char uniname2ctype_pool_str1180[sizeof("saur")];
+ char uniname2ctype_pool_str1182[sizeof("incjkunifiedideographsextensionc")];
+ char uniname2ctype_pool_str1186[sizeof("hanunoo")];
+ char uniname2ctype_pool_str1189[sizeof("paucinhau")];
+ char uniname2ctype_pool_str1192[sizeof("takr")];
+ char uniname2ctype_pool_str1193[sizeof("hira")];
+ char uniname2ctype_pool_str1195[sizeof("inarabic")];
+ char uniname2ctype_pool_str1196[sizeof("bopomofo")];
+ char uniname2ctype_pool_str1201[sizeof("radical")];
+ char uniname2ctype_pool_str1202[sizeof("gurmukhi")];
+ char uniname2ctype_pool_str1203[sizeof("inkhojki")];
+ char uniname2ctype_pool_str1207[sizeof("arab")];
+ char uniname2ctype_pool_str1211[sizeof("limbu")];
+ char uniname2ctype_pool_str1218[sizeof("inoldpermic")];
+ char uniname2ctype_pool_str1222[sizeof("brah")];
+ char uniname2ctype_pool_str1225[sizeof("inoldhungarian")];
+ char uniname2ctype_pool_str1227[sizeof("inshorthandformatcontrols")];
+ char uniname2ctype_pool_str1229[sizeof("incoptic")];
+ char uniname2ctype_pool_str1232[sizeof("sd")];
+ char uniname2ctype_pool_str1237[sizeof("sidd")];
+ char uniname2ctype_pool_str1243[sizeof("inherited")];
+ char uniname2ctype_pool_str1245[sizeof("incjkunifiedideographs")];
+ char uniname2ctype_pool_str1249[sizeof("term")];
+ char uniname2ctype_pool_str1252[sizeof("incjksymbolsandpunctuation")];
+ char uniname2ctype_pool_str1253[sizeof("graphemeextend")];
+ char uniname2ctype_pool_str1254[sizeof("dsrt")];
+ char uniname2ctype_pool_str1257[sizeof("cntrl")];
+ char uniname2ctype_pool_str1259[sizeof("xsux")];
+ char uniname2ctype_pool_str1262[sizeof("insyriacsupplement")];
+ char uniname2ctype_pool_str1267[sizeof("inbasiclatin")];
+ char uniname2ctype_pool_str1275[sizeof("deseret")];
+ char uniname2ctype_pool_str1281[sizeof("inenclosedideographicsupplement")];
+ char uniname2ctype_pool_str1285[sizeof("bidicontrol")];
+ char uniname2ctype_pool_str1288[sizeof("closepunctuation")];
+ char uniname2ctype_pool_str1294[sizeof("inlatinextendedadditional")];
+ char uniname2ctype_pool_str1296[sizeof("inarabicpresentationformsa")];
+ char uniname2ctype_pool_str1298[sizeof("grbase")];
+ char uniname2ctype_pool_str1306[sizeof("mong")];
+ char uniname2ctype_pool_str1307[sizeof("anatolianhieroglyphs")];
+ char uniname2ctype_pool_str1308[sizeof("inenclosedalphanumerics")];
+ char uniname2ctype_pool_str1309[sizeof("ingrantha")];
+ char uniname2ctype_pool_str1310[sizeof("georgian")];
+ char uniname2ctype_pool_str1317[sizeof("osage")];
+ char uniname2ctype_pool_str1325[sizeof("inosage")];
+ char uniname2ctype_pool_str1326[sizeof("ingeneralpunctuation")];
+ char uniname2ctype_pool_str1331[sizeof("saurashtra")];
+ char uniname2ctype_pool_str1334[sizeof("inshavian")];
+ char uniname2ctype_pool_str1335[sizeof("space")];
+ char uniname2ctype_pool_str1336[sizeof("mult")];
+ char uniname2ctype_pool_str1340[sizeof("inpalmyrene")];
+ char uniname2ctype_pool_str1341[sizeof("inanatolianhieroglyphs")];
+ char uniname2ctype_pool_str1344[sizeof("spacingmark")];
+ char uniname2ctype_pool_str1348[sizeof("alpha")];
+ char uniname2ctype_pool_str1354[sizeof("ingeorgian")];
+ char uniname2ctype_pool_str1355[sizeof("intibetan")];
+ char uniname2ctype_pool_str1364[sizeof("inlepcha")];
+ char uniname2ctype_pool_str1365[sizeof("inbatak")];
+ char uniname2ctype_pool_str1367[sizeof("emoji")];
+ char uniname2ctype_pool_str1368[sizeof("osma")];
+ char uniname2ctype_pool_str1369[sizeof("bhks")];
+ char uniname2ctype_pool_str1372[sizeof("inmongolian")];
+ char uniname2ctype_pool_str1373[sizeof("variationselector")];
+ char uniname2ctype_pool_str1374[sizeof("braille")];
+ char uniname2ctype_pool_str1379[sizeof("phli")];
+ char uniname2ctype_pool_str1382[sizeof("bhaiksuki")];
+ char uniname2ctype_pool_str1388[sizeof("phnx")];
+ char uniname2ctype_pool_str1390[sizeof("inblockelements")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1391[sizeof("age=1.1")];
+ char uniname2ctype_pool_str1392[sizeof("age=4.1")];
+ char uniname2ctype_pool_str1393[sizeof("age=4.0")];
+ char uniname2ctype_pool_str1394[sizeof("age=10.0")];
+ char uniname2ctype_pool_str1395[sizeof("age=2.1")];
+ char uniname2ctype_pool_str1396[sizeof("age=2.0")];
+ char uniname2ctype_pool_str1397[sizeof("age=6.1")];
+ char uniname2ctype_pool_str1398[sizeof("age=6.0")];
+ char uniname2ctype_pool_str1399[sizeof("age=9.0")];
+ char uniname2ctype_pool_str1400[sizeof("age=8.0")];
+ char uniname2ctype_pool_str1401[sizeof("age=6.2")];
+ char uniname2ctype_pool_str1402[sizeof("age=7.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1403[sizeof("inenclosedalphanumericsupplement")];
+ char uniname2ctype_pool_str1404[sizeof("innumberforms")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1405[sizeof("age=5.1")];
+ char uniname2ctype_pool_str1406[sizeof("age=5.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1407[sizeof("nd")];
+ char uniname2ctype_pool_str1408[sizeof("separator")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1409[sizeof("age=5.2")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1411[sizeof("ingurmukhi")];
+ char uniname2ctype_pool_str1413[sizeof("incjkunifiedideographsextensiond")];
+ char uniname2ctype_pool_str1414[sizeof("taiviet")];
+ char uniname2ctype_pool_str1416[sizeof("sinh")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1417[sizeof("age=3.1")];
+ char uniname2ctype_pool_str1418[sizeof("age=3.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1420[sizeof("hatran")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1421[sizeof("age=3.2")];
+ char uniname2ctype_pool_str1423[sizeof("age=6.3")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1427[sizeof("format")];
+ char uniname2ctype_pool_str1429[sizeof("shavian")];
+ char uniname2ctype_pool_str1434[sizeof("insinhalaarchaicnumbers")];
+ char uniname2ctype_pool_str1435[sizeof("cuneiform")];
+ char uniname2ctype_pool_str1439[sizeof("inmyanmarextendedb")];
+ char uniname2ctype_pool_str1444[sizeof("punctuation")];
+ char uniname2ctype_pool_str1449[sizeof("inarabicextendeda")];
+ char uniname2ctype_pool_str1450[sizeof("hatr")];
+ char uniname2ctype_pool_str1451[sizeof("inhanunoo")];
+ char uniname2ctype_pool_str1453[sizeof("inlatinextendedd")];
+ char uniname2ctype_pool_str1455[sizeof("modifierletter")];
+ char uniname2ctype_pool_str1456[sizeof("odi")];
+ char uniname2ctype_pool_str1458[sizeof("ahex")];
+ char uniname2ctype_pool_str1463[sizeof("logicalorderexception")];
+ char uniname2ctype_pool_str1464[sizeof("inbyzantinemusicalsymbols")];
+ char uniname2ctype_pool_str1469[sizeof("sund")];
+ char uniname2ctype_pool_str1470[sizeof("number")];
+ char uniname2ctype_pool_str1471[sizeof("insundanesesupplement")];
+ char uniname2ctype_pool_str1485[sizeof("incopticepactnumbers")];
+ char uniname2ctype_pool_str1490[sizeof("emojimodifier")];
+ char uniname2ctype_pool_str1496[sizeof("zp")];
+ char uniname2ctype_pool_str1497[sizeof("asciihexdigit")];
+ char uniname2ctype_pool_str1500[sizeof("indevanagari")];
+ char uniname2ctype_pool_str1508[sizeof("innewa")];
+ char uniname2ctype_pool_str1510[sizeof("avestan")];
+ char uniname2ctype_pool_str1521[sizeof("insorasompeng")];
+ char uniname2ctype_pool_str1535[sizeof("inmiscellaneousmathematicalsymbolsb")];
+ char uniname2ctype_pool_str1536[sizeof("inbraillepatterns")];
+ char uniname2ctype_pool_str1539[sizeof("nonspacingmark")];
+ char uniname2ctype_pool_str1540[sizeof("ingreekandcoptic")];
+ char uniname2ctype_pool_str1545[sizeof("xposixpunct")];
+ char uniname2ctype_pool_str1553[sizeof("inwarangciti")];
+ char uniname2ctype_pool_str1555[sizeof("oidc")];
+ char uniname2ctype_pool_str1560[sizeof("terminalpunctuation")];
+ char uniname2ctype_pool_str1565[sizeof("cf")];
+ char uniname2ctype_pool_str1572[sizeof("lower")];
+ char uniname2ctype_pool_str1580[sizeof("inunifiedcanadianaboriginalsyllabics")];
+ char uniname2ctype_pool_str1585[sizeof("idsb")];
+ char uniname2ctype_pool_str1589[sizeof("inbalinese")];
+ char uniname2ctype_pool_str1593[sizeof("induployan")];
+ char uniname2ctype_pool_str1594[sizeof("innoblock")];
+ char uniname2ctype_pool_str1595[sizeof("pf")];
+ char uniname2ctype_pool_str1602[sizeof("inoriya")];
+ char uniname2ctype_pool_str1604[sizeof("inkatakanaphoneticextensions")];
+ char uniname2ctype_pool_str1606[sizeof("inkayahli")];
+ char uniname2ctype_pool_str1607[sizeof("wara")];
+ char uniname2ctype_pool_str1608[sizeof("innushu")];
+ char uniname2ctype_pool_str1609[sizeof("lepcha")];
+ char uniname2ctype_pool_str1611[sizeof("inmeroitichieroglyphs")];
+ char uniname2ctype_pool_str1617[sizeof("beng")];
+ char uniname2ctype_pool_str1623[sizeof("idstrinaryoperator")];
+ char uniname2ctype_pool_str1628[sizeof("oids")];
+ char uniname2ctype_pool_str1630[sizeof("regionalindicator")];
+ char uniname2ctype_pool_str1631[sizeof("enclosingmark")];
+ char uniname2ctype_pool_str1632[sizeof("java")];
+ char uniname2ctype_pool_str1636[sizeof("tale")];
+ char uniname2ctype_pool_str1638[sizeof("emojimodifierbase")];
+ char uniname2ctype_pool_str1645[sizeof("inphoneticextensions")];
+ char uniname2ctype_pool_str1647[sizeof("lowercase")];
+ char uniname2ctype_pool_str1648[sizeof("inverticalforms")];
+ char uniname2ctype_pool_str1650[sizeof("javanese")];
+ char uniname2ctype_pool_str1654[sizeof("sentenceterminal")];
+ char uniname2ctype_pool_str1655[sizeof("ingreekextended")];
+ char uniname2ctype_pool_str1656[sizeof("invariationselectors")];
+ char uniname2ctype_pool_str1657[sizeof("cwcm")];
+ char uniname2ctype_pool_str1663[sizeof("lyci")];
+ char uniname2ctype_pool_str1666[sizeof("avst")];
+ char uniname2ctype_pool_str1669[sizeof("lycian")];
+ char uniname2ctype_pool_str1671[sizeof("zanabazarsquare")];
+ char uniname2ctype_pool_str1672[sizeof("sarb")];
+ char uniname2ctype_pool_str1673[sizeof("invedicextensions")];
+ char uniname2ctype_pool_str1674[sizeof("inkangxiradicals")];
+ char uniname2ctype_pool_str1677[sizeof("intaiviet")];
+ char uniname2ctype_pool_str1682[sizeof("mymr")];
+ char uniname2ctype_pool_str1690[sizeof("incjkradicalssupplement")];
+ char uniname2ctype_pool_str1695[sizeof("myanmar")];
+ char uniname2ctype_pool_str1697[sizeof("taml")];
+ char uniname2ctype_pool_str1714[sizeof("olower")];
+ char uniname2ctype_pool_str1725[sizeof("nl")];
+ char uniname2ctype_pool_str1727[sizeof("inethiopicsupplement")];
+ char uniname2ctype_pool_str1728[sizeof("olck")];
+ char uniname2ctype_pool_str1730[sizeof("inethiopicextendeda")];
+ char uniname2ctype_pool_str1736[sizeof("graph")];
+ char uniname2ctype_pool_str1737[sizeof("olchiki")];
+ char uniname2ctype_pool_str1741[sizeof("inphoneticextensionssupplement")];
+ char uniname2ctype_pool_str1743[sizeof("emojicomponent")];
+ char uniname2ctype_pool_str1746[sizeof("inunifiedcanadianaboriginalsyllabicsextended")];
+ char uniname2ctype_pool_str1748[sizeof("ingeometricshapes")];
+ char uniname2ctype_pool_str1752[sizeof("invariationselectorssupplement")];
+ char uniname2ctype_pool_str1754[sizeof("gujr")];
+ char uniname2ctype_pool_str1762[sizeof("sharada")];
+ char uniname2ctype_pool_str1766[sizeof("gujarati")];
+ char uniname2ctype_pool_str1767[sizeof("nchar")];
+ char uniname2ctype_pool_str1772[sizeof("innewtailue")];
+ char uniname2ctype_pool_str1774[sizeof("glag")];
+ char uniname2ctype_pool_str1780[sizeof("ideographic")];
+ char uniname2ctype_pool_str1783[sizeof("shrd")];
+ char uniname2ctype_pool_str1785[sizeof("insoyombo")];
+ char uniname2ctype_pool_str1789[sizeof("inbamum")];
+ char uniname2ctype_pool_str1800[sizeof("inlatin1supplement")];
+ char uniname2ctype_pool_str1802[sizeof("dash")];
+ char uniname2ctype_pool_str1806[sizeof("indingbats")];
+ char uniname2ctype_pool_str1808[sizeof("spaceseparator")];
+ char uniname2ctype_pool_str1813[sizeof("phagspa")];
+ char uniname2ctype_pool_str1814[sizeof("titlecaseletter")];
+ char uniname2ctype_pool_str1815[sizeof("incjkcompatibility")];
+ char uniname2ctype_pool_str1818[sizeof("intangut")];
+ char uniname2ctype_pool_str1819[sizeof("incombiningdiacriticalmarks")];
+ char uniname2ctype_pool_str1821[sizeof("inlisu")];
+ char uniname2ctype_pool_str1825[sizeof("siddham")];
+ char uniname2ctype_pool_str1829[sizeof("incombiningdiacriticalmarksforsymbols")];
+ char uniname2ctype_pool_str1840[sizeof("caucasianalbanian")];
+ char uniname2ctype_pool_str1843[sizeof("uideo")];
+ char uniname2ctype_pool_str1846[sizeof("indevanagariextended")];
+ char uniname2ctype_pool_str1847[sizeof("narb")];
+ char uniname2ctype_pool_str1857[sizeof("inbopomofo")];
+ char uniname2ctype_pool_str1858[sizeof("incjkunifiedideographsextensionf")];
+ char uniname2ctype_pool_str1861[sizeof("inmeroiticcursive")];
+ char uniname2ctype_pool_str1866[sizeof("patsyn")];
+ char uniname2ctype_pool_str1885[sizeof("insuperscriptsandsubscripts")];
+ char uniname2ctype_pool_str1894[sizeof("lydi")];
+ char uniname2ctype_pool_str1900[sizeof("lydian")];
+ char uniname2ctype_pool_str1903[sizeof("intags")];
+ char uniname2ctype_pool_str1909[sizeof("intelugu")];
+ char uniname2ctype_pool_str1910[sizeof("intifinagh")];
+ char uniname2ctype_pool_str1914[sizeof("ingeometricshapesextended")];
+ char uniname2ctype_pool_str1915[sizeof("incombiningdiacriticalmarkssupplement")];
+ char uniname2ctype_pool_str1922[sizeof("deva")];
+ char uniname2ctype_pool_str1924[sizeof("inprivateusearea")];
+ char uniname2ctype_pool_str1932[sizeof("devanagari")];
+ char uniname2ctype_pool_str1933[sizeof("noncharactercodepoint")];
+ char uniname2ctype_pool_str1934[sizeof("inbrahmi")];
+ char uniname2ctype_pool_str1943[sizeof("lowercaseletter")];
+ char uniname2ctype_pool_str1944[sizeof("word")];
+ char uniname2ctype_pool_str1975[sizeof("caseignorable")];
+ char uniname2ctype_pool_str1976[sizeof("inyiradicals")];
+ char uniname2ctype_pool_str1979[sizeof("deprecated")];
+ char uniname2ctype_pool_str1981[sizeof("thai")];
+ char uniname2ctype_pool_str1983[sizeof("thaa")];
+ char uniname2ctype_pool_str1985[sizeof("incombiningdiacriticalmarksextended")];
+ char uniname2ctype_pool_str1989[sizeof("inmathematicalalphanumericsymbols")];
+ char uniname2ctype_pool_str1991[sizeof("thaana")];
+ char uniname2ctype_pool_str1995[sizeof("inornamentaldingbats")];
+ char uniname2ctype_pool_str1997[sizeof("oldpersian")];
+ char uniname2ctype_pool_str1998[sizeof("unassigned")];
+ char uniname2ctype_pool_str1999[sizeof("insupplementalarrowsa")];
+ char uniname2ctype_pool_str2003[sizeof("inpaucinhau")];
+ char uniname2ctype_pool_str2005[sizeof("cwt")];
+ char uniname2ctype_pool_str2007[sizeof("tirhuta")];
+ char uniname2ctype_pool_str2008[sizeof("mahj")];
+ char uniname2ctype_pool_str2013[sizeof("insmallformvariants")];
+ char uniname2ctype_pool_str2015[sizeof("tirh")];
+ char uniname2ctype_pool_str2017[sizeof("orkh")];
+ char uniname2ctype_pool_str2020[sizeof("mahajani")];
+ char uniname2ctype_pool_str2047[sizeof("softdotted")];
+ char uniname2ctype_pool_str2049[sizeof("inphagspa")];
+ char uniname2ctype_pool_str2056[sizeof("inethiopicextended")];
+ char uniname2ctype_pool_str2059[sizeof("taitham")];
+ char uniname2ctype_pool_str2061[sizeof("assigned")];
+ char uniname2ctype_pool_str2068[sizeof("nbat")];
+ char uniname2ctype_pool_str2072[sizeof("incyrillicextendedb")];
+ char uniname2ctype_pool_str2073[sizeof("khoj")];
+ char uniname2ctype_pool_str2076[sizeof("buhd")];
+ char uniname2ctype_pool_str2079[sizeof("nabataean")];
+ char uniname2ctype_pool_str2084[sizeof("inalphabeticpresentationforms")];
+ char uniname2ctype_pool_str2091[sizeof("sorasompeng")];
+ char uniname2ctype_pool_str2095[sizeof("insupplementalarrowsc")];
+ char uniname2ctype_pool_str2096[sizeof("oldpermic")];
+ char uniname2ctype_pool_str2097[sizeof("cyrl")];
+ char uniname2ctype_pool_str2101[sizeof("finalpunctuation")];
+ char uniname2ctype_pool_str2112[sizeof("meroitichieroglyphs")];
+ char uniname2ctype_pool_str2114[sizeof("inarabicsupplement")];
+ char uniname2ctype_pool_str2117[sizeof("phlp")];
+ char uniname2ctype_pool_str2119[sizeof("inpsalterpahlavi")];
+ char uniname2ctype_pool_str2134[sizeof("mlym")];
+ char uniname2ctype_pool_str2139[sizeof("incjkunifiedideographsextensionb")];
+ char uniname2ctype_pool_str2146[sizeof("palmyrene")];
+ char uniname2ctype_pool_str2148[sizeof("insupplementalmathematicaloperators")];
+ char uniname2ctype_pool_str2149[sizeof("malayalam")];
+ char uniname2ctype_pool_str2154[sizeof("soyo")];
+ char uniname2ctype_pool_str2158[sizeof("hex")];
+ char uniname2ctype_pool_str2161[sizeof("phag")];
+ char uniname2ctype_pool_str2165[sizeof("graphemeclusterbreak=ebase")];
+ char uniname2ctype_pool_str2172[sizeof("graphemeclusterbreak=ebasegaz")];
+ char uniname2ctype_pool_str2174[sizeof("inhanguljamo")];
+ char uniname2ctype_pool_str2176[sizeof("bugi")];
+ char uniname2ctype_pool_str2179[sizeof("graphemeclusterbreak=spacingmark")];
+ char uniname2ctype_pool_str2182[sizeof("inhanguljamoextendeda")];
+ char uniname2ctype_pool_str2187[sizeof("currencysymbol")];
+ char uniname2ctype_pool_str2189[sizeof("tamil")];
+ char uniname2ctype_pool_str2192[sizeof("graphemeclusterbreak=cr")];
+ char uniname2ctype_pool_str2193[sizeof("talu")];
+ char uniname2ctype_pool_str2196[sizeof("buginese")];
+ char uniname2ctype_pool_str2197[sizeof("telu")];
+ char uniname2ctype_pool_str2198[sizeof("ingeorgiansupplement")];
+ char uniname2ctype_pool_str2199[sizeof("graphemeclusterbreak=emodifier")];
+ char uniname2ctype_pool_str2207[sizeof("graphemeclusterbreak=regionalindicator")];
+ char uniname2ctype_pool_str2210[sizeof("inlimbu")];
+ char uniname2ctype_pool_str2224[sizeof("inenclosedcjklettersandmonths")];
+ char uniname2ctype_pool_str2225[sizeof("tangut")];
+ char uniname2ctype_pool_str2229[sizeof("inmathematicaloperators")];
+ char uniname2ctype_pool_str2232[sizeof("newa")];
+ char uniname2ctype_pool_str2249[sizeof("newtailue")];
+ char uniname2ctype_pool_str2252[sizeof("hebr")];
+ char uniname2ctype_pool_str2260[sizeof("inbuhid")];
+ char uniname2ctype_pool_str2263[sizeof("insuttonsignwriting")];
+ char uniname2ctype_pool_str2264[sizeof("syrc")];
+ char uniname2ctype_pool_str2271[sizeof("dep")];
+ char uniname2ctype_pool_str2276[sizeof("inbassavah")];
+ char uniname2ctype_pool_str2286[sizeof("otheridcontinue")];
+ char uniname2ctype_pool_str2289[sizeof("inletterlikesymbols")];
+ char uniname2ctype_pool_str2296[sizeof("ext")];
+ char uniname2ctype_pool_str2300[sizeof("other")];
+ char uniname2ctype_pool_str2306[sizeof("inmongoliansupplement")];
+ char uniname2ctype_pool_str2307[sizeof("othernumber")];
+ char uniname2ctype_pool_str2311[sizeof("injavanese")];
+ char uniname2ctype_pool_str2313[sizeof("olditalic")];
+ char uniname2ctype_pool_str2327[sizeof("nshu")];
+ char uniname2ctype_pool_str2349[sizeof("inarabicpresentationformsb")];
+ char uniname2ctype_pool_str2350[sizeof("inlowsurrogates")];
+ char uniname2ctype_pool_str2353[sizeof("incombininghalfmarks")];
+ char uniname2ctype_pool_str2360[sizeof("inbengali")];
+ char uniname2ctype_pool_str2364[sizeof("cwcf")];
+ char uniname2ctype_pool_str2369[sizeof("inbuginese")];
+ char uniname2ctype_pool_str2372[sizeof("syriac")];
+ char uniname2ctype_pool_str2380[sizeof("ethi")];
+ char uniname2ctype_pool_str2386[sizeof("otheralphabetic")];
+ char uniname2ctype_pool_str2393[sizeof("emojipresentation")];
+ char uniname2ctype_pool_str2399[sizeof("inarabicmathematicalalphabeticsymbols")];
+ char uniname2ctype_pool_str2408[sizeof("tang")];
+ char uniname2ctype_pool_str2409[sizeof("buhid")];
+ char uniname2ctype_pool_str2412[sizeof("graphemeclusterbreak=t")];
+ char uniname2ctype_pool_str2413[sizeof("extender")];
+ char uniname2ctype_pool_str2414[sizeof("graphemeclusterbreak=lvt")];
+ char uniname2ctype_pool_str2422[sizeof("tagbanwa")];
+ char uniname2ctype_pool_str2423[sizeof("hang")];
+ char uniname2ctype_pool_str2433[sizeof("incurrencysymbols")];
+ char uniname2ctype_pool_str2449[sizeof("ingujarati")];
+ char uniname2ctype_pool_str2451[sizeof("paragraphseparator")];
+ char uniname2ctype_pool_str2452[sizeof("tibt")];
+ char uniname2ctype_pool_str2461[sizeof("tibetan")];
+ char uniname2ctype_pool_str2465[sizeof("ogam")];
+ char uniname2ctype_pool_str2467[sizeof("cwl")];
+ char uniname2ctype_pool_str2469[sizeof("oalpha")];
+ char uniname2ctype_pool_str2473[sizeof("hiragana")];
+ char uniname2ctype_pool_str2475[sizeof("surrogate")];
+ char uniname2ctype_pool_str2481[sizeof("inbamumsupplement")];
+ char uniname2ctype_pool_str2483[sizeof("inrejang")];
+ char uniname2ctype_pool_str2484[sizeof("intangutcomponents")];
+ char uniname2ctype_pool_str2488[sizeof("hmng")];
+ char uniname2ctype_pool_str2489[sizeof("graphemeclusterbreak=extend")];
+ char uniname2ctype_pool_str2490[sizeof("graphemeclusterbreak=prepend")];
+ char uniname2ctype_pool_str2493[sizeof("bassavah")];
+ char uniname2ctype_pool_str2500[sizeof("ingothic")];
+ char uniname2ctype_pool_str2507[sizeof("alphabetic")];
+ char uniname2ctype_pool_str2509[sizeof("mathsymbol")];
+ char uniname2ctype_pool_str2515[sizeof("oupper")];
+ char uniname2ctype_pool_str2519[sizeof("oldhungarian")];
+ char uniname2ctype_pool_str2523[sizeof("tavt")];
+ char uniname2ctype_pool_str2526[sizeof("insupplementalpunctuation")];
+ char uniname2ctype_pool_str2539[sizeof("dashpunctuation")];
+ char uniname2ctype_pool_str2545[sizeof("inplayingcards")];
+ char uniname2ctype_pool_str2550[sizeof("inaegeannumbers")];
+ char uniname2ctype_pool_str2573[sizeof("osge")];
+ char uniname2ctype_pool_str2576[sizeof("digit")];
+ char uniname2ctype_pool_str2579[sizeof("dupl")];
+ char uniname2ctype_pool_str2587[sizeof("inlinearbsyllabary")];
+ char uniname2ctype_pool_str2589[sizeof("cypriot")];
+ char uniname2ctype_pool_str2594[sizeof("wspace")];
+ char uniname2ctype_pool_str2601[sizeof("whitespace")];
+ char uniname2ctype_pool_str2617[sizeof("cwu")];
+ char uniname2ctype_pool_str2618[sizeof("nushu")];
+ char uniname2ctype_pool_str2622[sizeof("intagbanwa")];
+ char uniname2ctype_pool_str2630[sizeof("sylo")];
+ char uniname2ctype_pool_str2643[sizeof("graphemeclusterbreak=l")];
+ char uniname2ctype_pool_str2649[sizeof("graphemeclusterbreak=control")];
+ char uniname2ctype_pool_str2653[sizeof("oldturkic")];
+ char uniname2ctype_pool_str2660[sizeof("changeswhencasemapped")];
+ char uniname2ctype_pool_str2678[sizeof("rjng")];
+ char uniname2ctype_pool_str2693[sizeof("cyrillic")];
+ char uniname2ctype_pool_str2702[sizeof("hangul")];
+ char uniname2ctype_pool_str2705[sizeof("modifiersymbol")];
+ char uniname2ctype_pool_str2708[sizeof("inalchemicalsymbols")];
+ char uniname2ctype_pool_str2710[sizeof("insupplementaryprivateuseareaa")];
+ char uniname2ctype_pool_str2717[sizeof("orya")];
+ char uniname2ctype_pool_str2751[sizeof("inmahjongtiles")];
+ char uniname2ctype_pool_str2758[sizeof("changeswhentitlecased")];
+ char uniname2ctype_pool_str2763[sizeof("tifinagh")];
+ char uniname2ctype_pool_str2775[sizeof("otherlowercase")];
+ char uniname2ctype_pool_str2779[sizeof("inglagolitic")];
+ char uniname2ctype_pool_str2791[sizeof("otheridstart")];
+ char uniname2ctype_pool_str2792[sizeof("ugar")];
+ char uniname2ctype_pool_str2797[sizeof("otherletter")];
+ char uniname2ctype_pool_str2823[sizeof("inhangulsyllables")];
+ char uniname2ctype_pool_str2829[sizeof("elba")];
+ char uniname2ctype_pool_str2834[sizeof("intagalog")];
+ char uniname2ctype_pool_str2850[sizeof("otheruppercase")];
+ char uniname2ctype_pool_str2879[sizeof("omath")];
+ char uniname2ctype_pool_str2883[sizeof("warangciti")];
+ char uniname2ctype_pool_str2888[sizeof("sylotinagri")];
+ char uniname2ctype_pool_str2890[sizeof("shaw")];
+ char uniname2ctype_pool_str2891[sizeof("inpahawhhmong")];
+ char uniname2ctype_pool_str2901[sizeof("inhalfwidthandfullwidthforms")];
+ char uniname2ctype_pool_str2905[sizeof("inlatinextendedb")];
+ char uniname2ctype_pool_str2926[sizeof("osmanya")];
+ char uniname2ctype_pool_str2930[sizeof("graphemeclusterbreak=lf")];
+ char uniname2ctype_pool_str2932[sizeof("othersymbol")];
+ char uniname2ctype_pool_str2953[sizeof("defaultignorablecodepoint")];
+ char uniname2ctype_pool_str2967[sizeof("incypriotsyllabary")];
+ char uniname2ctype_pool_str2968[sizeof("khudawadi")];
+ char uniname2ctype_pool_str2972[sizeof("kayahli")];
+ char uniname2ctype_pool_str2984[sizeof("hung")];
+ char uniname2ctype_pool_str2987[sizeof("unknown")];
+ char uniname2ctype_pool_str2989[sizeof("inyijinghexagramsymbols")];
+ char uniname2ctype_pool_str3007[sizeof("elbasan")];
+ char uniname2ctype_pool_str3016[sizeof("inbopomofoextended")];
+ char uniname2ctype_pool_str3019[sizeof("changeswhenlowercased")];
+ char uniname2ctype_pool_str3020[sizeof("otherpunctuation")];
+ char uniname2ctype_pool_str3038[sizeof("upper")];
+ char uniname2ctype_pool_str3052[sizeof("insupplementalarrowsb")];
+ char uniname2ctype_pool_str3066[sizeof("oldnortharabian")];
+ char uniname2ctype_pool_str3094[sizeof("changeswhenuppercased")];
+ char uniname2ctype_pool_str3113[sizeof("uppercase")];
+ char uniname2ctype_pool_str3121[sizeof("ugaritic")];
+ char uniname2ctype_pool_str3153[sizeof("otherdefaultignorablecodepoint")];
+ char uniname2ctype_pool_str3177[sizeof("othermath")];
+ char uniname2ctype_pool_str3180[sizeof("tfng")];
+ char uniname2ctype_pool_str3193[sizeof("symbol")];
+ char uniname2ctype_pool_str3195[sizeof("hexdigit")];
+ char uniname2ctype_pool_str3213[sizeof("any")];
+ char uniname2ctype_pool_str3235[sizeof("inhanguljamoextendedb")];
+ char uniname2ctype_pool_str3238[sizeof("ethiopic")];
+ char uniname2ctype_pool_str3276[sizeof("aghb")];
+ char uniname2ctype_pool_str3279[sizeof("graphemeclusterbreak=v")];
+ char uniname2ctype_pool_str3280[sizeof("graphemeclusterbreak=lv")];
+ char uniname2ctype_pool_str3285[sizeof("soyombo")];
+ char uniname2ctype_pool_str3296[sizeof("graphemeclusterbreak=zwj")];
+ char uniname2ctype_pool_str3305[sizeof("graphemeclusterbreak=glueafterzwj")];
+ char uniname2ctype_pool_str3315[sizeof("sgnw")];
+ char uniname2ctype_pool_str3367[sizeof("changeswhencasefolded")];
+ char uniname2ctype_pool_str3373[sizeof("ogham")];
+ char uniname2ctype_pool_str3409[sizeof("uppercaseletter")];
+ char uniname2ctype_pool_str3438[sizeof("inhebrew")];
+ char uniname2ctype_pool_str3442[sizeof("inhighprivateusesurrogates")];
+ char uniname2ctype_pool_str3448[sizeof("openpunctuation")];
+ char uniname2ctype_pool_str3453[sizeof("ogrext")];
+ char uniname2ctype_pool_str3454[sizeof("hyphen")];
+ char uniname2ctype_pool_str3465[sizeof("tagb")];
+ char uniname2ctype_pool_str3496[sizeof("inyisyllables")];
+ char uniname2ctype_pool_str3593[sizeof("oldsoutharabian")];
+ char uniname2ctype_pool_str3662[sizeof("duployan")];
+ char uniname2ctype_pool_str3676[sizeof("hluw")];
+ char uniname2ctype_pool_str3689[sizeof("inglagoliticsupplement")];
+ char uniname2ctype_pool_str3697[sizeof("insupplementalsymbolsandpictographs")];
+ char uniname2ctype_pool_str3763[sizeof("insupplementaryprivateuseareab")];
+ char uniname2ctype_pool_str3791[sizeof("inegyptianhieroglyphs")];
+ char uniname2ctype_pool_str3960[sizeof("rejang")];
+ char uniname2ctype_pool_str3971[sizeof("inhangulcompatibilityjamo")];
+ char uniname2ctype_pool_str4036[sizeof("telugu")];
+ char uniname2ctype_pool_str4164[sizeof("tglg")];
+ char uniname2ctype_pool_str4187[sizeof("tagalog")];
+ char uniname2ctype_pool_str4208[sizeof("othergraphemeextend")];
+ char uniname2ctype_pool_str4460[sizeof("unifiedideograph")];
+ char uniname2ctype_pool_str4464[sizeof("inboxdrawing")];
+ char uniname2ctype_pool_str4483[sizeof("pahawhhmong")];
+ char uniname2ctype_pool_str4608[sizeof("inhighsurrogates")];
+ char uniname2ctype_pool_str4634[sizeof("signwriting")];
+ char uniname2ctype_pool_str4678[sizeof("zyyy")];
+ char uniname2ctype_pool_str4841[sizeof("egyp")];
+ char uniname2ctype_pool_str5170[sizeof("hebrew")];
+ char uniname2ctype_pool_str6145[sizeof("egyptianhieroglyphs")];
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+static const struct uniname2ctype_pool_t uniname2ctype_pool_contents =
+ {
+#ifndef USE_UNICODE_PROPERTIES
+ "word",
+#else /* USE_UNICODE_PROPERTIES */
+ "yi",
+ "cn",
+ "lina",
+ "yiii",
+ "lana",
+ "ci",
+ "mn",
+ "z",
+ "mani",
+ "lo",
+ "me",
+ "loe",
+ "lao",
+ "laoo",
+ "co",
+ "miao",
+ "pi",
+ "inkannada",
+ "gran",
+ "innko",
+ "zzzz",
+ "pe",
+ "cari",
+ "lineara",
+ "carian",
+ "mendekikakui",
+ "geor",
+ "po",
+ "grek",
+ "meeteimayek",
+ "mark",
+ "mero",
+ "kana",
+ "m",
+ "mro",
+ "mroo",
+ "greek",
+ "gonm",
+ "inkharoshthi",
+ "cakm",
+ "inmanichaean",
+ "c",
+ "inarmenian",
+ "common",
+ "inosmanya",
+ "inmro",
+ "inmiao",
+ "mandaic",
+ "inmyanmar",
+ "lm",
+ "prependedconcatenationmark",
+ "inideographicsymbolsandpunctuation",
+ "inchakma",
+ "inkhmer",
+ "perm",
+ "connectorpunctuation",
+ "marc",
+ "combiningmark",
+ "merc",
+ "inrunic",
+ "incarian",
+ "incuneiformnumbersandpunctuation",
+ "inahom",
+ "incherokee",
+ "qaai",
+ "cans",
+ "lc",
+ "incuneiform",
+ "cc",
+ "armn",
+ "inavestan",
+ "armi",
+ "mc",
+ "armenian",
+ "inipaextensions",
+ "inmarchen",
+ "pc",
+ "insharada",
+ "lineseparator",
+ "masaramgondi",
+ "inarrows",
+ "ri",
+ "incham",
+ "latn",
+ "incyrillic",
+ "latin",
+ "inzanabazarsquare",
+ "insamaritan",
+ "pcm",
+ "inmasaramgondi",
+ "qmark",
+ "qaac",
+ "mtei",
+ "inthai",
+ "inscriptionalparthian",
+ "inthaana",
+ "inkaithi",
+ "initialpunctuation",
+ "inkatakana",
+ "inkhmersymbols",
+ "insyriac",
+ "intakri",
+ "prti",
+ "arabic",
+ "mand",
+ "cs",
+ "mend",
+ "zs",
+ "letter",
+ "privateuse",
+ "modi",
+ "katakana",
+ "ideo",
+ "brai",
+ "xidcontinue",
+ "inmyanmarextendeda",
+ "ascii",
+ "ps",
+ "inkanaextendeda",
+ "inmeeteimayek",
+ "inruminumeralsymbols",
+ "letternumber",
+ "knda",
+ "kannada",
+ "inoldnortharabian",
+ "inideographicdescriptioncharacters",
+ "inmodi",
+ "incjkcompatibilityforms",
+ "incjkcompatibilityideographs",
+ "xidc",
+ "inmendekikakui",
+ "brahmi",
+ "inolditalic",
+ "inmiscellaneousmathematicalsymbolsa",
+ "inspecials",
+ "inemoticons",
+ "patternwhitespace",
+ "gothic",
+ "intransportandmapsymbols",
+ "l",
+ "psalterpahlavi",
+ "vai",
+ "vaii",
+ "lt",
+ "meroiticcursive",
+ "xids",
+ "incommonindicnumberforms",
+ "inmandaic",
+ "inlineara",
+ "incjkcompatibilityideographssupplement",
+ "inlao",
+ "insundanese",
+ "mongolian",
+ "bamum",
+ "idc",
+ "inancientsymbols",
+ "kali",
+ "grlink",
+ "grext",
+ "control",
+ "inkanasupplement",
+ "inopticalcharacterrecognition",
+ "inadlam",
+ "so",
+ "inoldsoutharabian",
+ "sk",
+#endif /* USE_UNICODE_PROPERTIES */
+ "print",
+#ifndef USE_UNICODE_PROPERTIES
+ "punct",
+ "alpha",
+#else /* USE_UNICODE_PROPERTIES */
+ "idsbinaryoperator",
+ "palm",
+ "batk",
+ "indominotiles",
+ "intaitham",
+ "inlycian",
+ "sora",
+ "batak",
+ "inmodifiertoneletters",
+ "patws",
+ "inmalayalam",
+ "incjkstrokes",
+ "incontrolpictures",
+ "samr",
+ "bass",
+ "samaritan",
+ "inmusicalsymbols",
+ "ids",
+ "pd",
+ "sm",
+ "pauc",
+ "joinc",
+ "inlinearbideograms",
+ "idcontinue",
+ "inancientgreekmusicalnotation",
+ "inoldturkic",
+#endif /* USE_UNICODE_PROPERTIES */
+ "alnum",
+#ifdef USE_UNICODE_PROPERTIES
+ "inugaritic",
+ "s",
+ "inmiscellaneoussymbols",
+ "n",
+ "lisu",
+ "inmiscellaneoussymbolsandarrows",
+ "insylotinagri",
+ "inmiscellaneoussymbolsandpictographs",
+ "sc",
+ "no",
+ "ital",
+ "p",
+ "xpeo",
+ "di",
+ "idst",
+ "intaile",
+ "nko",
+ "nkoo",
+ "dia",
+ "inphoenician",
+ "inlatinextendeda",
+ "indeseret",
+ "inlatinextendede",
+ "incaucasianalbanian",
+ "insaurashtra",
+ "inmeeteimayekextensions",
+ "idstart",
+ "bali",
+ "inspacingmodifierletters",
+ "bengali",
+ "intamil",
+ "inmultani",
+ "vs",
+ "inlydian",
+ "balinese",
+ "lepc",
+ "cased",
+ "zinh",
+ "blank",
+ "runr",
+ "patternsyntax",
+ "bidic",
+#endif /* USE_UNICODE_PROPERTIES */
+ "xdigit",
+#ifndef USE_UNICODE_PROPERTIES
+ "upper",
+ "ascii",
+#else /* USE_UNICODE_PROPERTIES */
+ "xidstart",
+ "inphaistosdisc",
+ "inancientgreeknumbers",
+ "canadianaboriginal",
+ "cher",
+ "plrd",
+ "sind",
+ "cherokee",
+ "phoenician",
+ "marchen",
+ "inhiragana",
+ "inearlydynasticcuneiform",
+ "graphemebase",
+ "cham",
+ "inimperialaramaic",
+ "kaithi",
+ "insiddham",
+ "diacritic",
+ "chakma",
+ "graphemelink",
+ "inkhudawadi",
+ "inmahajani",
+ "khojki",
+ "inogham",
+ "khar",
+ "incountingrodnumerals",
+ "manichaean",
+ "coptic",
+ "bamu",
+ "sterm",
+ "inethiopic",
+ "ll",
+ "inolchiki",
+ "inlatinextendedc",
+ "zl",
+ "adlm",
+ "incyrillicsupplement",
+ "incyrillicextendeda",
+ "incherokeesupplement",
+ "decimalnumber",
+ "khmr",
+ "copt",
+ "ahom",
+ "runic",
+ "intaixuanjingsymbols",
+ "insinhala",
+ "cprt",
+ "imperialaramaic",
+ "casedletter",
+ "khmer",
+ "linb",
+ "adlam",
+ "ininscriptionalparthian",
+ "ininscriptionalpahlavi",
+ "sinhala",
+ "zanb",
+ "incjkunifiedideographsextensiona",
+ "multani",
+ "quotationmark",
+ "incjkunifiedideographsextensione",
+ "innabataean",
+ "inbhaiksuki",
+ "inelbasan",
+ "inkanbun",
+ "inscriptionalpahlavi",
+ "bopo",
+ "linearb",
+ "incyrillicextendedc",
+ "glagolitic",
+ "kharoshthi",
+ "inoldpersian",
+ "goth",
+ "math",
+ "joincontrol",
+ "punct",
+ "lu",
+ "limb",
+ "inmiscellaneoustechnical",
+ "han",
+ "hani",
+ "invai",
+ "sundanese",
+ "taile",
+ "takri",
+ "grantha",
+ "hano",
+ "inhatran",
+ "oriya",
+ "intirhuta",
+ "guru",
+ "kthi",
+ "saur",
+ "incjkunifiedideographsextensionc",
+ "hanunoo",
+ "paucinhau",
+ "takr",
+ "hira",
+ "inarabic",
+ "bopomofo",
+ "radical",
+ "gurmukhi",
+ "inkhojki",
+ "arab",
+ "limbu",
+ "inoldpermic",
+ "brah",
+ "inoldhungarian",
+ "inshorthandformatcontrols",
+ "incoptic",
+ "sd",
+ "sidd",
+ "inherited",
+ "incjkunifiedideographs",
+ "term",
+ "incjksymbolsandpunctuation",
+ "graphemeextend",
+ "dsrt",
+#endif /* USE_UNICODE_PROPERTIES */
+ "cntrl",
+#ifdef USE_UNICODE_PROPERTIES
+ "xsux",
+ "insyriacsupplement",
+ "inbasiclatin",
+ "deseret",
+ "inenclosedideographicsupplement",
+ "bidicontrol",
+ "closepunctuation",
+ "inlatinextendedadditional",
+ "inarabicpresentationformsa",
+ "grbase",
+ "mong",
+ "anatolianhieroglyphs",
+ "inenclosedalphanumerics",
+ "ingrantha",
+ "georgian",
+ "osage",
+ "inosage",
+ "ingeneralpunctuation",
+ "saurashtra",
+ "inshavian",
+#endif /* USE_UNICODE_PROPERTIES */
+ "space",
+#ifdef USE_UNICODE_PROPERTIES
+ "mult",
+ "inpalmyrene",
+ "inanatolianhieroglyphs",
+ "spacingmark",
+ "alpha",
+ "ingeorgian",
+ "intibetan",
+ "inlepcha",
+ "inbatak",
+ "emoji",
+ "osma",
+ "bhks",
+ "inmongolian",
+ "variationselector",
+ "braille",
+ "phli",
+ "bhaiksuki",
+ "phnx",
+ "inblockelements",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=1.1",
+ "age=4.1",
+ "age=4.0",
+ "age=10.0",
+ "age=2.1",
+ "age=2.0",
+ "age=6.1",
+ "age=6.0",
+ "age=9.0",
+ "age=8.0",
+ "age=6.2",
+ "age=7.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "inenclosedalphanumericsupplement",
+ "innumberforms",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=5.1",
+ "age=5.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "nd",
+ "separator",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=5.2",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "ingurmukhi",
+ "incjkunifiedideographsextensiond",
+ "taiviet",
+ "sinh",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=3.1",
+ "age=3.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "hatran",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=3.2",
+ "age=6.3",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "format",
+ "shavian",
+ "insinhalaarchaicnumbers",
+ "cuneiform",
+ "inmyanmarextendedb",
+ "punctuation",
+ "inarabicextendeda",
+ "hatr",
+ "inhanunoo",
+ "inlatinextendedd",
+ "modifierletter",
+ "odi",
+ "ahex",
+ "logicalorderexception",
+ "inbyzantinemusicalsymbols",
+ "sund",
+ "number",
+ "insundanesesupplement",
+ "incopticepactnumbers",
+ "emojimodifier",
+ "zp",
+ "asciihexdigit",
+ "indevanagari",
+ "innewa",
+ "avestan",
+ "insorasompeng",
+ "inmiscellaneousmathematicalsymbolsb",
+ "inbraillepatterns",
+ "nonspacingmark",
+ "ingreekandcoptic",
+#endif /* USE_UNICODE_PROPERTIES */
+ "xposixpunct",
+#ifdef USE_UNICODE_PROPERTIES
+ "inwarangciti",
+ "oidc",
+ "terminalpunctuation",
+ "cf",
+#endif /* USE_UNICODE_PROPERTIES */
+ "lower",
+#ifdef USE_UNICODE_PROPERTIES
+ "inunifiedcanadianaboriginalsyllabics",
+ "idsb",
+ "inbalinese",
+ "induployan",
+ "innoblock",
+ "pf",
+ "inoriya",
+ "inkatakanaphoneticextensions",
+ "inkayahli",
+ "wara",
+ "innushu",
+ "lepcha",
+ "inmeroitichieroglyphs",
+ "beng",
+ "idstrinaryoperator",
+ "oids",
+ "regionalindicator",
+ "enclosingmark",
+ "java",
+ "tale",
+ "emojimodifierbase",
+ "inphoneticextensions",
+ "lowercase",
+ "inverticalforms",
+ "javanese",
+ "sentenceterminal",
+ "ingreekextended",
+ "invariationselectors",
+ "cwcm",
+ "lyci",
+ "avst",
+ "lycian",
+ "zanabazarsquare",
+ "sarb",
+ "invedicextensions",
+ "inkangxiradicals",
+ "intaiviet",
+ "mymr",
+ "incjkradicalssupplement",
+ "myanmar",
+ "taml",
+ "olower",
+ "nl",
+ "inethiopicsupplement",
+ "olck",
+ "inethiopicextendeda",
+#endif /* USE_UNICODE_PROPERTIES */
+ "graph",
+#ifdef USE_UNICODE_PROPERTIES
+ "olchiki",
+ "inphoneticextensionssupplement",
+ "emojicomponent",
+ "inunifiedcanadianaboriginalsyllabicsextended",
+ "ingeometricshapes",
+ "invariationselectorssupplement",
+ "gujr",
+ "sharada",
+ "gujarati",
+ "nchar",
+ "innewtailue",
+ "glag",
+ "ideographic",
+ "shrd",
+ "insoyombo",
+ "inbamum",
+ "inlatin1supplement",
+ "dash",
+ "indingbats",
+ "spaceseparator",
+ "phagspa",
+ "titlecaseletter",
+ "incjkcompatibility",
+ "intangut",
+ "incombiningdiacriticalmarks",
+ "inlisu",
+ "siddham",
+ "incombiningdiacriticalmarksforsymbols",
+ "caucasianalbanian",
+ "uideo",
+ "indevanagariextended",
+ "narb",
+ "inbopomofo",
+ "incjkunifiedideographsextensionf",
+ "inmeroiticcursive",
+ "patsyn",
+ "insuperscriptsandsubscripts",
+ "lydi",
+ "lydian",
+ "intags",
+ "intelugu",
+ "intifinagh",
+ "ingeometricshapesextended",
+ "incombiningdiacriticalmarkssupplement",
+ "deva",
+ "inprivateusearea",
+ "devanagari",
+ "noncharactercodepoint",
+ "inbrahmi",
+ "lowercaseletter",
+ "word",
+ "caseignorable",
+ "inyiradicals",
+ "deprecated",
+ "thai",
+ "thaa",
+ "incombiningdiacriticalmarksextended",
+ "inmathematicalalphanumericsymbols",
+ "thaana",
+ "inornamentaldingbats",
+ "oldpersian",
+ "unassigned",
+ "insupplementalarrowsa",
+ "inpaucinhau",
+ "cwt",
+ "tirhuta",
+ "mahj",
+ "insmallformvariants",
+ "tirh",
+ "orkh",
+ "mahajani",
+ "softdotted",
+ "inphagspa",
+ "inethiopicextended",
+ "taitham",
+ "assigned",
+ "nbat",
+ "incyrillicextendedb",
+ "khoj",
+ "buhd",
+ "nabataean",
+ "inalphabeticpresentationforms",
+ "sorasompeng",
+ "insupplementalarrowsc",
+ "oldpermic",
+ "cyrl",
+ "finalpunctuation",
+ "meroitichieroglyphs",
+ "inarabicsupplement",
+ "phlp",
+ "inpsalterpahlavi",
+ "mlym",
+ "incjkunifiedideographsextensionb",
+ "palmyrene",
+ "insupplementalmathematicaloperators",
+ "malayalam",
+ "soyo",
+ "hex",
+ "phag",
+ "graphemeclusterbreak=ebase",
+ "graphemeclusterbreak=ebasegaz",
+ "inhanguljamo",
+ "bugi",
+ "graphemeclusterbreak=spacingmark",
+ "inhanguljamoextendeda",
+ "currencysymbol",
+ "tamil",
+ "graphemeclusterbreak=cr",
+ "talu",
+ "buginese",
+ "telu",
+ "ingeorgiansupplement",
+ "graphemeclusterbreak=emodifier",
+ "graphemeclusterbreak=regionalindicator",
+ "inlimbu",
+ "inenclosedcjklettersandmonths",
+ "tangut",
+ "inmathematicaloperators",
+ "newa",
+ "newtailue",
+ "hebr",
+ "inbuhid",
+ "insuttonsignwriting",
+ "syrc",
+ "dep",
+ "inbassavah",
+ "otheridcontinue",
+ "inletterlikesymbols",
+ "ext",
+ "other",
+ "inmongoliansupplement",
+ "othernumber",
+ "injavanese",
+ "olditalic",
+ "nshu",
+ "inarabicpresentationformsb",
+ "inlowsurrogates",
+ "incombininghalfmarks",
+ "inbengali",
+ "cwcf",
+ "inbuginese",
+ "syriac",
+ "ethi",
+ "otheralphabetic",
+ "emojipresentation",
+ "inarabicmathematicalalphabeticsymbols",
+ "tang",
+ "buhid",
+ "graphemeclusterbreak=t",
+ "extender",
+ "graphemeclusterbreak=lvt",
+ "tagbanwa",
+ "hang",
+ "incurrencysymbols",
+ "ingujarati",
+ "paragraphseparator",
+ "tibt",
+ "tibetan",
+ "ogam",
+ "cwl",
+ "oalpha",
+ "hiragana",
+ "surrogate",
+ "inbamumsupplement",
+ "inrejang",
+ "intangutcomponents",
+ "hmng",
+ "graphemeclusterbreak=extend",
+ "graphemeclusterbreak=prepend",
+ "bassavah",
+ "ingothic",
+ "alphabetic",
+ "mathsymbol",
+ "oupper",
+ "oldhungarian",
+ "tavt",
+ "insupplementalpunctuation",
+ "dashpunctuation",
+ "inplayingcards",
+ "inaegeannumbers",
+ "osge",
+#endif /* USE_UNICODE_PROPERTIES */
+ "digit",
+#ifndef USE_UNICODE_PROPERTIES
+ "blank"
+#else /* USE_UNICODE_PROPERTIES */
+ "dupl",
+ "inlinearbsyllabary",
+ "cypriot",
+ "wspace",
+ "whitespace",
+ "cwu",
+ "nushu",
+ "intagbanwa",
+ "sylo",
+ "graphemeclusterbreak=l",
+ "graphemeclusterbreak=control",
+ "oldturkic",
+ "changeswhencasemapped",
+ "rjng",
+ "cyrillic",
+ "hangul",
+ "modifiersymbol",
+ "inalchemicalsymbols",
+ "insupplementaryprivateuseareaa",
+ "orya",
+ "inmahjongtiles",
+ "changeswhentitlecased",
+ "tifinagh",
+ "otherlowercase",
+ "inglagolitic",
+ "otheridstart",
+ "ugar",
+ "otherletter",
+ "inhangulsyllables",
+ "elba",
+ "intagalog",
+ "otheruppercase",
+ "omath",
+ "warangciti",
+ "sylotinagri",
+ "shaw",
+ "inpahawhhmong",
+ "inhalfwidthandfullwidthforms",
+ "inlatinextendedb",
+ "osmanya",
+ "graphemeclusterbreak=lf",
+ "othersymbol",
+ "defaultignorablecodepoint",
+ "incypriotsyllabary",
+ "khudawadi",
+ "kayahli",
+ "hung",
+ "unknown",
+ "inyijinghexagramsymbols",
+ "elbasan",
+ "inbopomofoextended",
+ "changeswhenlowercased",
+ "otherpunctuation",
+ "upper",
+ "insupplementalarrowsb",
+ "oldnortharabian",
+ "changeswhenuppercased",
+ "uppercase",
+ "ugaritic",
+ "otherdefaultignorablecodepoint",
+ "othermath",
+ "tfng",
+ "symbol",
+ "hexdigit",
+ "any",
+ "inhanguljamoextendedb",
+ "ethiopic",
+ "aghb",
+ "graphemeclusterbreak=v",
+ "graphemeclusterbreak=lv",
+ "soyombo",
+ "graphemeclusterbreak=zwj",
+ "graphemeclusterbreak=glueafterzwj",
+ "sgnw",
+ "changeswhencasefolded",
+ "ogham",
+ "uppercaseletter",
+ "inhebrew",
+ "inhighprivateusesurrogates",
+ "openpunctuation",
+ "ogrext",
+ "hyphen",
+ "tagb",
+ "inyisyllables",
+ "oldsoutharabian",
+ "duployan",
+ "hluw",
+ "inglagoliticsupplement",
+ "insupplementalsymbolsandpictographs",
+ "insupplementaryprivateuseareab",
+ "inegyptianhieroglyphs",
+ "rejang",
+ "inhangulcompatibilityjamo",
+ "telugu",
+ "tglg",
+ "tagalog",
+ "othergraphemeextend",
+ "unifiedideograph",
+ "inboxdrawing",
+ "pahawhhmong",
+ "inhighsurrogates",
+ "signwriting",
+ "zyyy",
+ "egyp",
+ "hebrew",
+ "egyptianhieroglyphs"
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+#define uniname2ctype_pool ((const char *) &uniname2ctype_pool_contents)
+const struct uniname2ctype_struct *
+uniname2ctype_p (register const char *str, register size_t len)
+{
+ static const struct uniname2ctype_struct wordlist[] =
+ {
+#ifdef USE_UNICODE_PROPERTIES
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str10), 111},
+ {-1}, {-1},
+ {uniname2ctype_offset(str13), 21},
+ {uniname2ctype_offset(str14), 184},
+ {uniname2ctype_offset(str15), 111},
+ {uniname2ctype_offset(str16), 152},
+ {uniname2ctype_offset(str17), 61},
+ {-1},
+ {uniname2ctype_offset(str19), 34},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str26), 52},
+ {-1},
+ {uniname2ctype_offset(str28), 186},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str33), 28},
+ {-1},
+ {uniname2ctype_offset(str35), 33},
+ {-1},
+ {uniname2ctype_offset(str37), 241},
+ {-1},
+ {uniname2ctype_offset(str39), 95},
+ {uniname2ctype_offset(str40), 95},
+ {uniname2ctype_offset(str41), 22},
+ {uniname2ctype_offset(str42), 173},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str47), 44},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str51), 320},
+ {uniname2ctype_offset(str52), 181},
+ {-1},
+ {uniname2ctype_offset(str54), 308},
+ {uniname2ctype_offset(str55), 255},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str59), 42},
+ {uniname2ctype_offset(str60), 149},
+ {uniname2ctype_offset(str61), 184},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str66), 149},
+ {-1}, {-1},
+ {uniname2ctype_offset(str69), 187},
+ {uniname2ctype_offset(str70), 98},
+ {uniname2ctype_offset(str71), 45},
+ {uniname2ctype_offset(str72), 77},
+ {uniname2ctype_offset(str73), 160},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str80), 31},
+ {-1},
+ {uniname2ctype_offset(str82), 172},
+ {-1}, {-1},
+ {uniname2ctype_offset(str85), 108},
+ {uniname2ctype_offset(str86), 31},
+ {uniname2ctype_offset(str87), 189},
+ {uniname2ctype_offset(str88), 189},
+ {-1},
+ {uniname2ctype_offset(str90), 77},
+ {-1}, {-1},
+ {uniname2ctype_offset(str93), 212},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str97), 484},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str105), 170},
+ {uniname2ctype_offset(str106), 487},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str111), 18},
+ {-1},
+ {uniname2ctype_offset(str113), 302},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str117), 75},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str122), 470},
+ {uniname2ctype_offset(str123), 526},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str129), 529},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str137), 169},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str142), 326},
+ {uniname2ctype_offset(str143), 27},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str150), 248},
+ {-1}, {-1},
+ {uniname2ctype_offset(str153), 530},
+ {uniname2ctype_offset(str154), 498},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str160), 339},
+ {uniname2ctype_offset(str161), 194},
+ {uniname2ctype_offset(str162), 40},
+ {-1},
+ {uniname2ctype_offset(str164), 208},
+ {-1}, {-1},
+ {uniname2ctype_offset(str167), 31},
+ {uniname2ctype_offset(str168), 171},
+ {uniname2ctype_offset(str169), 334},
+ {uniname2ctype_offset(str170), 461},
+ {-1},
+ {uniname2ctype_offset(str172), 521},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str184), 512},
+ {-1},
+ {uniname2ctype_offset(str186), 331},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str191), 115},
+ {-1},
+ {uniname2ctype_offset(str193), 102},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str205), 25},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str210), 520},
+ {-1}, {-1},
+ {uniname2ctype_offset(str213), 19},
+ {-1},
+ {uniname2ctype_offset(str215), 79},
+ {uniname2ctype_offset(str216), 488},
+ {uniname2ctype_offset(str217), 161},
+ {-1},
+ {uniname2ctype_offset(str219), 32},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str223), 79},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str227), 296},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str238), 518},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str243), 40},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str250), 500},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str255), 53},
+ {uniname2ctype_offset(str256), 212},
+ {-1}, {-1},
+ {uniname2ctype_offset(str259), 368},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str268), 249},
+ {-1},
+ {uniname2ctype_offset(str270), 429},
+ {uniname2ctype_offset(str271), 76},
+ {uniname2ctype_offset(str272), 300},
+ {uniname2ctype_offset(str273), 76},
+ {-1}, {-1},
+ {uniname2ctype_offset(str276), 514},
+ {-1}, {-1},
+ {uniname2ctype_offset(str279), 309},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str283), 248},
+ {-1},
+ {uniname2ctype_offset(str285), 519},
+ {-1}, {-1},
+ {uniname2ctype_offset(str288), 221},
+ {uniname2ctype_offset(str289), 129},
+ {-1},
+ {uniname2ctype_offset(str291), 160},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str295), 323},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str300), 163},
+ {uniname2ctype_offset(str301), 307},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str309), 496},
+ {-1},
+ {uniname2ctype_offset(str311), 44},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str315), 399},
+ {-1},
+ {uniname2ctype_offset(str317), 345},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str343), 305},
+ {uniname2ctype_offset(str344), 511},
+ {uniname2ctype_offset(str345), 163},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str356), 81},
+ {uniname2ctype_offset(str357), 169},
+ {-1},
+ {uniname2ctype_offset(str359), 23},
+ {-1},
+ {uniname2ctype_offset(str361), 187},
+ {uniname2ctype_offset(str362), 55},
+ {uniname2ctype_offset(str363), 24},
+ {-1},
+ {uniname2ctype_offset(str365), 22},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str369), 188},
+ {uniname2ctype_offset(str370), 108},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str377), 227},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str383), 127},
+ {uniname2ctype_offset(str384), 70},
+ {-1},
+ {uniname2ctype_offset(str386), 430},
+ {uniname2ctype_offset(str387), 14},
+ {-1},
+ {uniname2ctype_offset(str389), 46},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str393), 534},
+ {-1}, {-1},
+ {uniname2ctype_offset(str396), 436},
+ {-1}, {-1},
+ {uniname2ctype_offset(str399), 494},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str408), 37},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str412), 91},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str425), 91},
+ {-1}, {-1},
+ {uniname2ctype_offset(str428), 486},
+ {-1},
+ {uniname2ctype_offset(str430), 396},
+ {-1},
+ {uniname2ctype_offset(str432), 509},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str440), 449},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str445), 443},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str453), 70},
+ {-1},
+ {uniname2ctype_offset(str455), 546},
+ {-1}, {-1},
+ {uniname2ctype_offset(str458), 168},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str480), 463},
+ {-1},
+ {uniname2ctype_offset(str482), 379},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str486), 453},
+ {uniname2ctype_offset(str487), 555},
+ {uniname2ctype_offset(str488), 246},
+ {uniname2ctype_offset(str489), 113},
+ {-1}, {-1},
+ {uniname2ctype_offset(str492), 557},
+ {uniname2ctype_offset(str493), 24},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str509), 195},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str516), 144},
+ {uniname2ctype_offset(str517), 144},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str523), 29},
+ {uniname2ctype_offset(str524), 171},
+ {-1},
+ {uniname2ctype_offset(str526), 69},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str530), 420},
+ {uniname2ctype_offset(str531), 310},
+ {-1},
+ {uniname2ctype_offset(str533), 474},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str541), 567},
+ {-1}, {-1},
+ {uniname2ctype_offset(str544), 324},
+ {uniname2ctype_offset(str545), 350},
+ {-1},
+ {uniname2ctype_offset(str547), 106},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str552), 158},
+ {-1},
+ {uniname2ctype_offset(str554), 68},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str561), 458},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str573), 146},
+ {uniname2ctype_offset(str574), 74},
+ {-1},
+ {uniname2ctype_offset(str576), 72},
+ {uniname2ctype_offset(str577), 19},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str586), 533},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str591), 372},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str596), 547},
+ {-1},
+ {uniname2ctype_offset(str598), 51},
+ {-1}, {-1},
+ {uniname2ctype_offset(str601), 485},
+ {uniname2ctype_offset(str602), 49},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str606), 7},
+ {uniname2ctype_offset(str607), 234},
+ {-1},
+ {uniname2ctype_offset(str609), 192},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str618), 167},
+ {uniname2ctype_offset(str619), 550},
+ {uniname2ctype_offset(str620), 347},
+ {-1},
+ {uniname2ctype_offset(str622), 460},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str629), 175},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str636), 167},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str642), 417},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str657), 246},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str665), 321},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str670), 404},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str681), 371},
+ {-1}, {-1},
+ {uniname2ctype_offset(str684), 156},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str689), 178},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str693), 156},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str699), 539},
+ {uniname2ctype_offset(str700), 67},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str705), 41},
+ {-1}, {-1},
+ {uniname2ctype_offset(str708), 50},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str715), 193},
+ {uniname2ctype_offset(str716), 218},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str725), 455},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str730), 68},
+ {-1},
+ {uniname2ctype_offset(str732), 540},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str737), 492},
+ {uniname2ctype_offset(str738), 13},
+ {uniname2ctype_offset(str739), 466},
+ {-1},
+ {uniname2ctype_offset(str741), 47},
+ {uniname2ctype_offset(str742), 377},
+ {uniname2ctype_offset(str743), 35},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str748), 157},
+ {-1}, {-1},
+ {uniname2ctype_offset(str751), 385},
+ {-1},
+ {uniname2ctype_offset(str753), 419},
+ {-1}, {-1},
+ {uniname2ctype_offset(str756), 554},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str770), 48},
+ {-1}, {-1},
+ {uniname2ctype_offset(str773), 38},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str777), 112},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str781), 39},
+ {uniname2ctype_offset(str782), 134},
+ {-1}, {-1},
+ {uniname2ctype_offset(str785), 71},
+ {-1},
+ {uniname2ctype_offset(str787), 235},
+ {uniname2ctype_offset(str788), 343},
+ {-1}, {-1},
+ {uniname2ctype_offset(str791), 140},
+ {uniname2ctype_offset(str792), 140},
+ {uniname2ctype_offset(str793), 228},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str797), 480},
+ {-1},
+ {uniname2ctype_offset(str799), 294},
+ {-1}, {-1},
+ {uniname2ctype_offset(str802), 468},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str807), 434},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str812), 473},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str819), 422},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str823), 432},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str834), 67},
+ {uniname2ctype_offset(str835), 136},
+ {-1},
+ {uniname2ctype_offset(str837), 297},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str848), 85},
+ {uniname2ctype_offset(str849), 318},
+ {-1},
+ {uniname2ctype_offset(str851), 503},
+ {uniname2ctype_offset(str852), 245},
+ {uniname2ctype_offset(str853), 481},
+ {-1},
+ {uniname2ctype_offset(str855), 136},
+ {uniname2ctype_offset(str856), 142},
+ {uniname2ctype_offset(str857), 60},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str862), 115},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str867), 2},
+ {-1}, {-1},
+ {uniname2ctype_offset(str870), 104},
+ {-1},
+ {uniname2ctype_offset(str872), 247},
+ {-1},
+ {uniname2ctype_offset(str874), 217},
+ {-1}, {-1},
+ {uniname2ctype_offset(str877), 11},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str881), 69},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str885), 459},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str897), 457},
+ {-1},
+ {uniname2ctype_offset(str899), 102},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str903), 101},
+ {-1},
+ {uniname2ctype_offset(str905), 173},
+ {uniname2ctype_offset(str906), 197},
+ {-1}, {-1},
+ {uniname2ctype_offset(str909), 101},
+ {-1},
+ {uniname2ctype_offset(str911), 138},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str918), 208},
+ {uniname2ctype_offset(str919), 398},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str926), 522},
+ {-1},
+ {uniname2ctype_offset(str928), 73},
+ {-1},
+ {uniname2ctype_offset(str930), 151},
+ {uniname2ctype_offset(str931), 476},
+ {uniname2ctype_offset(str932), 166},
+ {-1}, {-1},
+ {uniname2ctype_offset(str935), 508},
+ {-1},
+ {uniname2ctype_offset(str937), 228},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str942), 170},
+ {-1},
+ {uniname2ctype_offset(str944), 74},
+ {-1}, {-1},
+ {uniname2ctype_offset(str947), 504},
+ {uniname2ctype_offset(str948), 499},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str956), 183},
+ {uniname2ctype_offset(str957), 333},
+ {-1}, {-1},
+ {uniname2ctype_offset(str960), 135},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str966), 542},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str975), 186},
+ {uniname2ctype_offset(str976), 129},
+ {uniname2ctype_offset(str977), 158},
+ {-1}, {-1},
+ {uniname2ctype_offset(str980), 244},
+ {-1}, {-1},
+ {uniname2ctype_offset(str983), 329},
+ {-1},
+ {uniname2ctype_offset(str985), 26},
+ {-1}, {-1},
+ {uniname2ctype_offset(str988), 353},
+ {-1}, {-1},
+ {uniname2ctype_offset(str991), 387},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str996), 53},
+ {-1},
+ {uniname2ctype_offset(str998), 206},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1016), 301},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1019), 392},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1022), 435},
+ {uniname2ctype_offset(str1023), 36},
+ {-1},
+ {uniname2ctype_offset(str1025), 105},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1029), 129},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1032), 200},
+ {-1},
+ {uniname2ctype_offset(str1034), 104},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1048), 541},
+ {uniname2ctype_offset(str1049), 322},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1053), 126},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1056), 161},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1061), 25},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1065), 105},
+ {-1},
+ {uniname2ctype_offset(str1067), 122},
+ {-1},
+ {uniname2ctype_offset(str1069), 206},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1076), 489},
+ {uniname2ctype_offset(str1077), 490},
+ {uniname2ctype_offset(str1078), 93},
+ {-1},
+ {uniname2ctype_offset(str1080), 215},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1086), 408},
+ {-1},
+ {uniname2ctype_offset(str1088), 203},
+ {uniname2ctype_offset(str1089), 221},
+ {uniname2ctype_offset(str1090), 565},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1094), 478},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1098), 517},
+ {-1},
+ {uniname2ctype_offset(str1100), 472},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1103), 402},
+ {uniname2ctype_offset(str1104), 164},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1107), 109},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1114), 122},
+ {uniname2ctype_offset(str1115), 354},
+ {uniname2ctype_offset(str1116), 131},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1119), 135},
+ {uniname2ctype_offset(str1120), 467},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1124), 113},
+ {-1},
+ {uniname2ctype_offset(str1126), 56},
+ {uniname2ctype_offset(str1127), 218},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1131), 15},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1135), 30},
+ {uniname2ctype_offset(str1136), 120},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1147), 370},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1152), 110},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1155), 110},
+ {uniname2ctype_offset(str1156), 414},
+ {uniname2ctype_offset(str1157), 141},
+ {uniname2ctype_offset(str1158), 121},
+ {-1},
+ {uniname2ctype_offset(str1160), 176},
+ {uniname2ctype_offset(str1161), 181},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1167), 117},
+ {uniname2ctype_offset(str1168), 479},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1172), 88},
+ {uniname2ctype_offset(str1173), 507},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1178), 86},
+ {uniname2ctype_offset(str1179), 166},
+ {uniname2ctype_offset(str1180), 145},
+ {-1},
+ {uniname2ctype_offset(str1182), 563},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1186), 117},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1189), 193},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1192), 176},
+ {uniname2ctype_offset(str1193), 107},
+ {-1},
+ {uniname2ctype_offset(str1195), 304},
+ {uniname2ctype_offset(str1196), 109},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1201), 236},
+ {uniname2ctype_offset(str1202), 86},
+ {uniname2ctype_offset(str1203), 502},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1207), 81},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1211), 120},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1218), 465},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1222), 168},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1225), 493},
+ {-1},
+ {uniname2ctype_offset(str1227), 537},
+ {-1},
+ {uniname2ctype_offset(str1229), 388},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1232), 240},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1237), 196},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1243), 115},
+ {-1},
+ {uniname2ctype_offset(str1245), 410},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1249), 222},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1252), 397},
+ {uniname2ctype_offset(str1253), 72},
+ {uniname2ctype_offset(str1254), 114},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1257), 3},
+ {-1},
+ {uniname2ctype_offset(str1259), 137},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1262), 311},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1267), 292},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1275), 114},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1281), 553},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1285), 217},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1288), 42},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1294), 360},
+ {-1},
+ {uniname2ctype_offset(str1296), 445},
+ {-1},
+ {uniname2ctype_offset(str1298), 73},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1306), 106},
+ {uniname2ctype_offset(str1307), 201},
+ {uniname2ctype_offset(str1308), 373},
+ {uniname2ctype_offset(str1309), 505},
+ {uniname2ctype_offset(str1310), 98},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1317), 210},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1325), 471},
+ {uniname2ctype_offset(str1326), 362},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1331), 145},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1334), 469},
+ {uniname2ctype_offset(str1335), 9},
+ {uniname2ctype_offset(str1336), 203},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1340), 477},
+ {uniname2ctype_offset(str1341), 524},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1344), 32},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1348), 1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1354), 327},
+ {uniname2ctype_offset(str1355), 325},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1364), 352},
+ {uniname2ctype_offset(str1365), 351},
+ {-1},
+ {uniname2ctype_offset(str1367), 250},
+ {uniname2ctype_offset(str1368), 125},
+ {uniname2ctype_offset(str1369), 207},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1372), 340},
+ {uniname2ctype_offset(str1373), 245},
+ {uniname2ctype_offset(str1374), 127},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1379), 164},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1382), 207},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1388), 138},
+ {-1},
+ {uniname2ctype_offset(str1390), 375},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1391), 256},
+ {uniname2ctype_offset(str1392), 263},
+ {uniname2ctype_offset(str1393), 262},
+ {uniname2ctype_offset(str1394), 274},
+ {uniname2ctype_offset(str1395), 258},
+ {uniname2ctype_offset(str1396), 257},
+ {uniname2ctype_offset(str1397), 268},
+ {uniname2ctype_offset(str1398), 267},
+ {uniname2ctype_offset(str1399), 273},
+ {uniname2ctype_offset(str1400), 272},
+ {uniname2ctype_offset(str1401), 269},
+ {uniname2ctype_offset(str1402), 271},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1403), 552},
+ {uniname2ctype_offset(str1404), 367},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1405), 265},
+ {uniname2ctype_offset(str1406), 264},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1407), 36},
+ {uniname2ctype_offset(str1408), 52},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1409), 266},
+ {-1},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1411), 315},
+ {-1},
+ {uniname2ctype_offset(str1413), 564},
+ {uniname2ctype_offset(str1414), 153},
+ {-1},
+ {uniname2ctype_offset(str1416), 93},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1417), 260},
+ {uniname2ctype_offset(str1418), 259},
+ {-1},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1420), 202},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1421), 261},
+ {-1},
+ {uniname2ctype_offset(str1423), 270},
+ {-1}, {-1}, {-1},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1427), 20},
+ {-1},
+ {uniname2ctype_offset(str1429), 124},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1434), 501},
+ {uniname2ctype_offset(str1435), 137},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1439), 428},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1444), 39},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1449), 312},
+ {uniname2ctype_offset(str1450), 202},
+ {uniname2ctype_offset(str1451), 336},
+ {-1},
+ {uniname2ctype_offset(str1453), 418},
+ {-1},
+ {uniname2ctype_offset(str1455), 27},
+ {uniname2ctype_offset(str1456), 238},
+ {-1},
+ {uniname2ctype_offset(str1458), 225},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1463), 241},
+ {uniname2ctype_offset(str1464), 538},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1469), 141},
+ {uniname2ctype_offset(str1470), 35},
+ {uniname2ctype_offset(str1471), 355},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1485), 462},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1490), 252},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1496), 54},
+ {uniname2ctype_offset(str1497), 225},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1500), 313},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1508), 506},
+ {-1},
+ {uniname2ctype_offset(str1510), 154},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1521), 497},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1535), 383},
+ {uniname2ctype_offset(str1536), 381},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1539), 34},
+ {uniname2ctype_offset(str1540), 299},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1545), 8},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1553), 513},
+ {-1},
+ {uniname2ctype_offset(str1555), 243},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1560), 222},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1565), 20},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1572), 6},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1580), 332},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1585), 234},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1589), 349},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1593), 536},
+ {uniname2ctype_offset(str1594), 572},
+ {uniname2ctype_offset(str1595), 43},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1602), 317},
+ {-1},
+ {uniname2ctype_offset(str1604), 405},
+ {-1},
+ {uniname2ctype_offset(str1606), 424},
+ {uniname2ctype_offset(str1607), 199},
+ {uniname2ctype_offset(str1608), 535},
+ {uniname2ctype_offset(str1609), 142},
+ {-1},
+ {uniname2ctype_offset(str1611), 482},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1617), 85},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1623), 235},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1628), 242},
+ {-1},
+ {uniname2ctype_offset(str1630), 249},
+ {uniname2ctype_offset(str1631), 33},
+ {uniname2ctype_offset(str1632), 159},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1636), 121},
+ {-1},
+ {uniname2ctype_offset(str1638), 253},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1645), 357},
+ {-1},
+ {uniname2ctype_offset(str1647), 58},
+ {uniname2ctype_offset(str1648), 447},
+ {-1},
+ {uniname2ctype_offset(str1650), 159},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1654), 244},
+ {uniname2ctype_offset(str1655), 361},
+ {uniname2ctype_offset(str1656), 446},
+ {uniname2ctype_offset(str1657), 66},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1663), 148},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1666), 154},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1669), 148},
+ {-1},
+ {uniname2ctype_offset(str1671), 215},
+ {uniname2ctype_offset(str1672), 162},
+ {uniname2ctype_offset(str1673), 356},
+ {uniname2ctype_offset(str1674), 395},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1677), 431},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1682), 97},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1690), 394},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1695), 97},
+ {-1},
+ {uniname2ctype_offset(str1697), 89},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1714), 230},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1725), 37},
+ {-1},
+ {uniname2ctype_offset(str1727), 330},
+ {uniname2ctype_offset(str1728), 143},
+ {-1},
+ {uniname2ctype_offset(str1730), 433},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1736), 5},
+ {uniname2ctype_offset(str1737), 143},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1741), 358},
+ {-1},
+ {uniname2ctype_offset(str1743), 254},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1746), 341},
+ {-1},
+ {uniname2ctype_offset(str1748), 376},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1752), 569},
+ {-1},
+ {uniname2ctype_offset(str1754), 87},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1762), 174},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1766), 87},
+ {uniname2ctype_offset(str1767), 232},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1772), 344},
+ {-1},
+ {uniname2ctype_offset(str1774), 131},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1780), 227},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1783), 174},
+ {-1},
+ {uniname2ctype_offset(str1785), 515},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1789), 416},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1800), 293},
+ {-1},
+ {uniname2ctype_offset(str1802), 219},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1806), 378},
+ {-1},
+ {uniname2ctype_offset(str1808), 55},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1813), 139},
+ {uniname2ctype_offset(str1814), 29},
+ {uniname2ctype_offset(str1815), 407},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1818), 531},
+ {uniname2ctype_offset(str1819), 298},
+ {-1},
+ {uniname2ctype_offset(str1821), 413},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1825), 196},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1829), 365},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1840), 177},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1843), 237},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1846), 423},
+ {uniname2ctype_offset(str1847), 190},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1857), 400},
+ {uniname2ctype_offset(str1858), 566},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1861), 483},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1866), 247},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1885), 363},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1894), 150},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1900), 150},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1903), 568},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1909), 319},
+ {uniname2ctype_offset(str1910), 390},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1914), 559},
+ {uniname2ctype_offset(str1915), 359},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1922), 84},
+ {-1},
+ {uniname2ctype_offset(str1924), 442},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1932), 84},
+ {uniname2ctype_offset(str1933), 232},
+ {uniname2ctype_offset(str1934), 495},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1943), 26},
+ {uniname2ctype_offset(str1944), 12},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1975), 61},
+ {uniname2ctype_offset(str1976), 412},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1979), 239},
+ {-1},
+ {uniname2ctype_offset(str1981), 94},
+ {-1},
+ {uniname2ctype_offset(str1983), 83},
+ {-1},
+ {uniname2ctype_offset(str1985), 348},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1989), 543},
+ {-1},
+ {uniname2ctype_offset(str1991), 83},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1995), 556},
+ {-1},
+ {uniname2ctype_offset(str1997), 134},
+ {uniname2ctype_offset(str1998), 21},
+ {uniname2ctype_offset(str1999), 380},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2003), 516},
+ {-1},
+ {uniname2ctype_offset(str2005), 64},
+ {-1},
+ {uniname2ctype_offset(str2007), 198},
+ {uniname2ctype_offset(str2008), 185},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2013), 450},
+ {-1},
+ {uniname2ctype_offset(str2015), 198},
+ {-1},
+ {uniname2ctype_offset(str2017), 165},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2020), 185},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2047), 240},
+ {-1},
+ {uniname2ctype_offset(str2049), 421},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2056), 391},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2059), 152},
+ {-1},
+ {uniname2ctype_offset(str2061), 17},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2068), 191},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2072), 415},
+ {uniname2ctype_offset(str2073), 183},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2076), 118},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2079), 191},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2084), 444},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2091), 175},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2095), 560},
+ {uniname2ctype_offset(str2096), 194},
+ {uniname2ctype_offset(str2097), 78},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2101), 43},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str2112), 172},
+ {-1},
+ {uniname2ctype_offset(str2114), 306},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2117), 195},
+ {-1},
+ {uniname2ctype_offset(str2119), 491},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2134), 92},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2139), 562},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2146), 192},
+ {-1},
+ {uniname2ctype_offset(str2148), 384},
+ {uniname2ctype_offset(str2149), 92},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2154), 214},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2158), 224},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2161), 139},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2165), 287},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2172), 291},
+ {-1},
+ {uniname2ctype_offset(str2174), 328},
+ {-1},
+ {uniname2ctype_offset(str2176), 128},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2179), 281},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2182), 426},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2187), 48},
+ {-1},
+ {uniname2ctype_offset(str2189), 89},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2192), 276},
+ {uniname2ctype_offset(str2193), 130},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2196), 128},
+ {uniname2ctype_offset(str2197), 90},
+ {uniname2ctype_offset(str2198), 389},
+ {uniname2ctype_offset(str2199), 288},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2207), 280},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2210), 342},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2224), 406},
+ {uniname2ctype_offset(str2225), 211},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2229), 369},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2232), 209},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2249), 130},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2252), 80},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2260), 337},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2263), 544},
+ {uniname2ctype_offset(str2264), 82},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2271), 239},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2276), 527},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2286), 243},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2289), 366},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2296), 229},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2300), 18},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2306), 510},
+ {uniname2ctype_offset(str2307), 38},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2311), 427},
+ {-1},
+ {uniname2ctype_offset(str2313), 112},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2327), 213},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2349), 451},
+ {uniname2ctype_offset(str2350), 441},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2353), 448},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2360), 314},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2364), 65},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2369), 346},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2372), 82},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2380), 100},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2386), 226},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2393), 251},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2399), 548},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2408), 211},
+ {uniname2ctype_offset(str2409), 118},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2412), 284},
+ {uniname2ctype_offset(str2413), 229},
+ {uniname2ctype_offset(str2414), 286},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2422), 119},
+ {uniname2ctype_offset(str2423), 99},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2433), 364},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2449), 316},
+ {-1},
+ {uniname2ctype_offset(str2451), 54},
+ {uniname2ctype_offset(str2452), 96},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2461), 96},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2465), 103},
+ {-1},
+ {uniname2ctype_offset(str2467), 62},
+ {-1},
+ {uniname2ctype_offset(str2469), 226},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2473), 107},
+ {-1},
+ {uniname2ctype_offset(str2475), 23},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2481), 525},
+ {-1},
+ {uniname2ctype_offset(str2483), 425},
+ {uniname2ctype_offset(str2484), 532},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2488), 182},
+ {uniname2ctype_offset(str2489), 279},
+ {uniname2ctype_offset(str2490), 275},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2493), 178},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2500), 464},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2507), 57},
+ {-1},
+ {uniname2ctype_offset(str2509), 50},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2515), 231},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2519), 204},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2523), 153},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2526), 393},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2539), 41},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2545), 551},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2550), 456},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2573), 210},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2576), 4},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2579), 179},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2587), 454},
+ {-1},
+ {uniname2ctype_offset(str2589), 126},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2594), 216},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2601), 216},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2617), 63},
+ {uniname2ctype_offset(str2618), 213},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2622), 338},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2630), 133},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2643), 282},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2649), 278},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2653), 165},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2660), 66},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2678), 147},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2693), 78},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2702), 99},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2705), 49},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2708), 558},
+ {-1},
+ {uniname2ctype_offset(str2710), 570},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2717), 88},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2751), 549},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2758), 64},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2763), 132},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2775), 230},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2779), 386},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2791), 242},
+ {uniname2ctype_offset(str2792), 123},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2797), 28},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2823), 437},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2829), 180},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2834), 335},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2850), 231},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str2879), 223},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2883), 199},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2888), 133},
+ {-1},
+ {uniname2ctype_offset(str2890), 124},
+ {uniname2ctype_offset(str2891), 528},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2901), 452},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2905), 295},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2926), 125},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2930), 277},
+ {-1},
+ {uniname2ctype_offset(str2932), 51},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2953), 71},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2967), 475},
+ {uniname2ctype_offset(str2968), 197},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2972), 146},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2984), 204},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2987), 255},
+ {-1},
+ {uniname2ctype_offset(str2989), 409},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3007), 180},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3016), 403},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3019), 62},
+ {uniname2ctype_offset(str3020), 45},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3038), 10},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3052), 382},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3066), 190},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3094), 63},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3113), 59},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3121), 123},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3153), 238},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3177), 223},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3180), 132},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3193), 47},
+ {-1},
+ {uniname2ctype_offset(str3195), 224},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3213), 16},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3235), 438},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3238), 100},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str3276), 177},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3279), 283},
+ {uniname2ctype_offset(str3280), 285},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3285), 214},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str3296), 289},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3305), 290},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3315), 205},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3367), 65},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3373), 103},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3409), 30},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str3438), 303},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3442), 440},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3448), 46},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3453), 233},
+ {uniname2ctype_offset(str3454), 220},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str3465), 119},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3496), 411},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3593), 162},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3662), 179},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3676), 201},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3689), 545},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3697), 561},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3763), 571},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3791), 523},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#endif /* USE_UNICODE_PROPERTIES */
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#ifndef USE_UNICODE_PROPERTIES
+ {uniname2ctype_offset(str6), 12},
+ {uniname2ctype_offset(str7), 7},
+ {uniname2ctype_offset(str8), 15},
+ {uniname2ctype_offset(str9), 1},
+ {uniname2ctype_offset(str10), 13},
+ {uniname2ctype_offset(str11), 11},
+ {uniname2ctype_offset(str12), 10},
+ {uniname2ctype_offset(str13), 14},
+ {uniname2ctype_offset(str14), 3},
+ {uniname2ctype_offset(str15), 9},
+ {uniname2ctype_offset(str16), 8},
+ {uniname2ctype_offset(str17), 6},
+ {uniname2ctype_offset(str18), 5},
+ {uniname2ctype_offset(str19), 4},
+ {uniname2ctype_offset(str20), 2}
+#else /* USE_UNICODE_PROPERTIES */
+ {uniname2ctype_offset(str3960), 147},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str3971), 401},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str4036), 90},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str4164), 116},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4187), 116},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str4208), 233},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4460), 237},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4464), 374},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4483), 182},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4608), 439},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4634), 205},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4678), 75},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4841), 155},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5170), 80},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str6145), 155}
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register unsigned int key = uniname2ctype_hash (str, len);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register int o = wordlist[key].name;
+ if (o >= 0)
+ {
+ register const char *s = o + uniname2ctype_pool;
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return &wordlist[key];
+ }
+ }
+ }
+ return 0;
+}
+
+static int
+uniname2ctype(const UChar *name, unsigned int len)
+{
+ const struct uniname2ctype_struct *p = uniname2ctype_p((const char *)name, len);
+ if (p) return p->ctype;
+ return -1;
+}
+#if defined ONIG_UNICODE_VERSION_STRING && !( \
+ ONIG_UNICODE_VERSION_MAJOR == 10 && \
+ ONIG_UNICODE_VERSION_MINOR == 0 && \
+ ONIG_UNICODE_VERSION_TEENY == 0 && \
+ 1)
+# error ONIG_UNICODE_VERSION_STRING mismatch
+#endif
+#define ONIG_UNICODE_VERSION_STRING "10.0.0"
+#define ONIG_UNICODE_VERSION_MAJOR 10
+#define ONIG_UNICODE_VERSION_MINOR 0
+#define ONIG_UNICODE_VERSION_TEENY 0
diff --git a/enc/unicode/12.1.0/casefold.h b/enc/unicode/12.1.0/casefold.h
deleted file mode 100644
index 4c62f0faee..0000000000
--- a/enc/unicode/12.1.0/casefold.h
+++ /dev/null
@@ -1,7428 +0,0 @@
-/* DO NOT EDIT THIS FILE. */
-/* Generated by enc/unicode/case-folding.rb */
-
-#if defined ONIG_UNICODE_VERSION_STRING && !( \
- ONIG_UNICODE_VERSION_MAJOR == 12 && \
- ONIG_UNICODE_VERSION_MINOR == 1 && \
- ONIG_UNICODE_VERSION_TEENY == 0 && \
- 1)
-# error ONIG_UNICODE_VERSION_STRING mismatch
-#endif
-#define ONIG_UNICODE_VERSION_STRING "12.1.0"
-#define ONIG_UNICODE_VERSION_MAJOR 12
-#define ONIG_UNICODE_VERSION_MINOR 1
-#define ONIG_UNICODE_VERSION_TEENY 0
-
-static const CaseFold_11_Type CaseFold_11_Table[] = {
-#define CaseFold (*(CaseFold_11_Type (*)[1485])(CaseFold_11_Table+0))
- {0x0041, {1|F|D, {0x0061}}},
- {0x0042, {1|F|D, {0x0062}}},
- {0x0043, {1|F|D, {0x0063}}},
- {0x0044, {1|F|D, {0x0064}}},
- {0x0045, {1|F|D, {0x0065}}},
- {0x0046, {1|F|D, {0x0066}}},
- {0x0047, {1|F|D, {0x0067}}},
- {0x0048, {1|F|D, {0x0068}}},
- {0x004a, {1|F|D, {0x006a}}},
- {0x004b, {1|F|D, {0x006b}}},
- {0x004c, {1|F|D, {0x006c}}},
- {0x004d, {1|F|D, {0x006d}}},
- {0x004e, {1|F|D, {0x006e}}},
- {0x004f, {1|F|D, {0x006f}}},
- {0x0050, {1|F|D, {0x0070}}},
- {0x0051, {1|F|D, {0x0071}}},
- {0x0052, {1|F|D, {0x0072}}},
- {0x0053, {1|F|D, {0x0073}}},
- {0x0054, {1|F|D, {0x0074}}},
- {0x0055, {1|F|D, {0x0075}}},
- {0x0056, {1|F|D, {0x0076}}},
- {0x0057, {1|F|D, {0x0077}}},
- {0x0058, {1|F|D, {0x0078}}},
- {0x0059, {1|F|D, {0x0079}}},
- {0x005a, {1|F|D, {0x007a}}},
- {0x00b5, {1|F|SU|I(0), {0x03bc}}},
- {0x00c0, {1|F|D, {0x00e0}}},
- {0x00c1, {1|F|D, {0x00e1}}},
- {0x00c2, {1|F|D, {0x00e2}}},
- {0x00c3, {1|F|D, {0x00e3}}},
- {0x00c4, {1|F|D, {0x00e4}}},
- {0x00c5, {1|F|D, {0x00e5}}},
- {0x00c6, {1|F|D, {0x00e6}}},
- {0x00c7, {1|F|D, {0x00e7}}},
- {0x00c8, {1|F|D, {0x00e8}}},
- {0x00c9, {1|F|D, {0x00e9}}},
- {0x00ca, {1|F|D, {0x00ea}}},
- {0x00cb, {1|F|D, {0x00eb}}},
- {0x00cc, {1|F|D, {0x00ec}}},
- {0x00cd, {1|F|D, {0x00ed}}},
- {0x00ce, {1|F|D, {0x00ee}}},
- {0x00cf, {1|F|D, {0x00ef}}},
- {0x00d0, {1|F|D, {0x00f0}}},
- {0x00d1, {1|F|D, {0x00f1}}},
- {0x00d2, {1|F|D, {0x00f2}}},
- {0x00d3, {1|F|D, {0x00f3}}},
- {0x00d4, {1|F|D, {0x00f4}}},
- {0x00d5, {1|F|D, {0x00f5}}},
- {0x00d6, {1|F|D, {0x00f6}}},
- {0x00d8, {1|F|D, {0x00f8}}},
- {0x00d9, {1|F|D, {0x00f9}}},
- {0x00da, {1|F|D, {0x00fa}}},
- {0x00db, {1|F|D, {0x00fb}}},
- {0x00dc, {1|F|D, {0x00fc}}},
- {0x00dd, {1|F|D, {0x00fd}}},
- {0x00de, {1|F|D, {0x00fe}}},
- {0x00df, {2|F|ST|SU|I(1), {0x0073, 0x0073}}},
- {0x0100, {1|F|D, {0x0101}}},
- {0x0102, {1|F|D, {0x0103}}},
- {0x0104, {1|F|D, {0x0105}}},
- {0x0106, {1|F|D, {0x0107}}},
- {0x0108, {1|F|D, {0x0109}}},
- {0x010a, {1|F|D, {0x010b}}},
- {0x010c, {1|F|D, {0x010d}}},
- {0x010e, {1|F|D, {0x010f}}},
- {0x0110, {1|F|D, {0x0111}}},
- {0x0112, {1|F|D, {0x0113}}},
- {0x0114, {1|F|D, {0x0115}}},
- {0x0116, {1|F|D, {0x0117}}},
- {0x0118, {1|F|D, {0x0119}}},
- {0x011a, {1|F|D, {0x011b}}},
- {0x011c, {1|F|D, {0x011d}}},
- {0x011e, {1|F|D, {0x011f}}},
- {0x0120, {1|F|D, {0x0121}}},
- {0x0122, {1|F|D, {0x0123}}},
- {0x0124, {1|F|D, {0x0125}}},
- {0x0126, {1|F|D, {0x0127}}},
- {0x0128, {1|F|D, {0x0129}}},
- {0x012a, {1|F|D, {0x012b}}},
- {0x012c, {1|F|D, {0x012d}}},
- {0x012e, {1|F|D, {0x012f}}},
- {0x0132, {1|F|D, {0x0133}}},
- {0x0134, {1|F|D, {0x0135}}},
- {0x0136, {1|F|D, {0x0137}}},
- {0x0139, {1|F|D, {0x013a}}},
- {0x013b, {1|F|D, {0x013c}}},
- {0x013d, {1|F|D, {0x013e}}},
- {0x013f, {1|F|D, {0x0140}}},
- {0x0141, {1|F|D, {0x0142}}},
- {0x0143, {1|F|D, {0x0144}}},
- {0x0145, {1|F|D, {0x0146}}},
- {0x0147, {1|F|D, {0x0148}}},
- {0x0149, {2|F|SU|I(5), {0x02bc, 0x006e}}},
- {0x014a, {1|F|D, {0x014b}}},
- {0x014c, {1|F|D, {0x014d}}},
- {0x014e, {1|F|D, {0x014f}}},
- {0x0150, {1|F|D, {0x0151}}},
- {0x0152, {1|F|D, {0x0153}}},
- {0x0154, {1|F|D, {0x0155}}},
- {0x0156, {1|F|D, {0x0157}}},
- {0x0158, {1|F|D, {0x0159}}},
- {0x015a, {1|F|D, {0x015b}}},
- {0x015c, {1|F|D, {0x015d}}},
- {0x015e, {1|F|D, {0x015f}}},
- {0x0160, {1|F|D, {0x0161}}},
- {0x0162, {1|F|D, {0x0163}}},
- {0x0164, {1|F|D, {0x0165}}},
- {0x0166, {1|F|D, {0x0167}}},
- {0x0168, {1|F|D, {0x0169}}},
- {0x016a, {1|F|D, {0x016b}}},
- {0x016c, {1|F|D, {0x016d}}},
- {0x016e, {1|F|D, {0x016f}}},
- {0x0170, {1|F|D, {0x0171}}},
- {0x0172, {1|F|D, {0x0173}}},
- {0x0174, {1|F|D, {0x0175}}},
- {0x0176, {1|F|D, {0x0177}}},
- {0x0178, {1|F|D, {0x00ff}}},
- {0x0179, {1|F|D, {0x017a}}},
- {0x017b, {1|F|D, {0x017c}}},
- {0x017d, {1|F|D, {0x017e}}},
- {0x017f, {1|F|SU|I(7), {0x0073}}},
- {0x0181, {1|F|D, {0x0253}}},
- {0x0182, {1|F|D, {0x0183}}},
- {0x0184, {1|F|D, {0x0185}}},
- {0x0186, {1|F|D, {0x0254}}},
- {0x0187, {1|F|D, {0x0188}}},
- {0x0189, {1|F|D, {0x0256}}},
- {0x018a, {1|F|D, {0x0257}}},
- {0x018b, {1|F|D, {0x018c}}},
- {0x018e, {1|F|D, {0x01dd}}},
- {0x018f, {1|F|D, {0x0259}}},
- {0x0190, {1|F|D, {0x025b}}},
- {0x0191, {1|F|D, {0x0192}}},
- {0x0193, {1|F|D, {0x0260}}},
- {0x0194, {1|F|D, {0x0263}}},
- {0x0196, {1|F|D, {0x0269}}},
- {0x0197, {1|F|D, {0x0268}}},
- {0x0198, {1|F|D, {0x0199}}},
- {0x019c, {1|F|D, {0x026f}}},
- {0x019d, {1|F|D, {0x0272}}},
- {0x019f, {1|F|D, {0x0275}}},
- {0x01a0, {1|F|D, {0x01a1}}},
- {0x01a2, {1|F|D, {0x01a3}}},
- {0x01a4, {1|F|D, {0x01a5}}},
- {0x01a6, {1|F|D, {0x0280}}},
- {0x01a7, {1|F|D, {0x01a8}}},
- {0x01a9, {1|F|D, {0x0283}}},
- {0x01ac, {1|F|D, {0x01ad}}},
- {0x01ae, {1|F|D, {0x0288}}},
- {0x01af, {1|F|D, {0x01b0}}},
- {0x01b1, {1|F|D, {0x028a}}},
- {0x01b2, {1|F|D, {0x028b}}},
- {0x01b3, {1|F|D, {0x01b4}}},
- {0x01b5, {1|F|D, {0x01b6}}},
- {0x01b7, {1|F|D, {0x0292}}},
- {0x01b8, {1|F|D, {0x01b9}}},
- {0x01bc, {1|F|D, {0x01bd}}},
- {0x01c4, {1|F|D|ST|I(8), {0x01c6}}},
- {0x01c5, {1|F|D|IT|SU|I(9), {0x01c6}}},
- {0x01c7, {1|F|D|ST|I(12), {0x01c9}}},
- {0x01c8, {1|F|D|IT|SU|I(13), {0x01c9}}},
- {0x01ca, {1|F|D|ST|I(16), {0x01cc}}},
- {0x01cb, {1|F|D|IT|SU|I(17), {0x01cc}}},
- {0x01cd, {1|F|D, {0x01ce}}},
- {0x01cf, {1|F|D, {0x01d0}}},
- {0x01d1, {1|F|D, {0x01d2}}},
- {0x01d3, {1|F|D, {0x01d4}}},
- {0x01d5, {1|F|D, {0x01d6}}},
- {0x01d7, {1|F|D, {0x01d8}}},
- {0x01d9, {1|F|D, {0x01da}}},
- {0x01db, {1|F|D, {0x01dc}}},
- {0x01de, {1|F|D, {0x01df}}},
- {0x01e0, {1|F|D, {0x01e1}}},
- {0x01e2, {1|F|D, {0x01e3}}},
- {0x01e4, {1|F|D, {0x01e5}}},
- {0x01e6, {1|F|D, {0x01e7}}},
- {0x01e8, {1|F|D, {0x01e9}}},
- {0x01ea, {1|F|D, {0x01eb}}},
- {0x01ec, {1|F|D, {0x01ed}}},
- {0x01ee, {1|F|D, {0x01ef}}},
- {0x01f0, {2|F|SU|I(20), {0x006a, 0x030c}}},
- {0x01f1, {1|F|D|ST|I(22), {0x01f3}}},
- {0x01f2, {1|F|D|IT|SU|I(23), {0x01f3}}},
- {0x01f4, {1|F|D, {0x01f5}}},
- {0x01f6, {1|F|D, {0x0195}}},
- {0x01f7, {1|F|D, {0x01bf}}},
- {0x01f8, {1|F|D, {0x01f9}}},
- {0x01fa, {1|F|D, {0x01fb}}},
- {0x01fc, {1|F|D, {0x01fd}}},
- {0x01fe, {1|F|D, {0x01ff}}},
- {0x0200, {1|F|D, {0x0201}}},
- {0x0202, {1|F|D, {0x0203}}},
- {0x0204, {1|F|D, {0x0205}}},
- {0x0206, {1|F|D, {0x0207}}},
- {0x0208, {1|F|D, {0x0209}}},
- {0x020a, {1|F|D, {0x020b}}},
- {0x020c, {1|F|D, {0x020d}}},
- {0x020e, {1|F|D, {0x020f}}},
- {0x0210, {1|F|D, {0x0211}}},
- {0x0212, {1|F|D, {0x0213}}},
- {0x0214, {1|F|D, {0x0215}}},
- {0x0216, {1|F|D, {0x0217}}},
- {0x0218, {1|F|D, {0x0219}}},
- {0x021a, {1|F|D, {0x021b}}},
- {0x021c, {1|F|D, {0x021d}}},
- {0x021e, {1|F|D, {0x021f}}},
- {0x0220, {1|F|D, {0x019e}}},
- {0x0222, {1|F|D, {0x0223}}},
- {0x0224, {1|F|D, {0x0225}}},
- {0x0226, {1|F|D, {0x0227}}},
- {0x0228, {1|F|D, {0x0229}}},
- {0x022a, {1|F|D, {0x022b}}},
- {0x022c, {1|F|D, {0x022d}}},
- {0x022e, {1|F|D, {0x022f}}},
- {0x0230, {1|F|D, {0x0231}}},
- {0x0232, {1|F|D, {0x0233}}},
- {0x023a, {1|F|D, {0x2c65}}},
- {0x023b, {1|F|D, {0x023c}}},
- {0x023d, {1|F|D, {0x019a}}},
- {0x023e, {1|F|D, {0x2c66}}},
- {0x0241, {1|F|D, {0x0242}}},
- {0x0243, {1|F|D, {0x0180}}},
- {0x0244, {1|F|D, {0x0289}}},
- {0x0245, {1|F|D, {0x028c}}},
- {0x0246, {1|F|D, {0x0247}}},
- {0x0248, {1|F|D, {0x0249}}},
- {0x024a, {1|F|D, {0x024b}}},
- {0x024c, {1|F|D, {0x024d}}},
- {0x024e, {1|F|D, {0x024f}}},
- {0x0345, {1|F|SU|I(26), {0x03b9}}},
- {0x0370, {1|F|D, {0x0371}}},
- {0x0372, {1|F|D, {0x0373}}},
- {0x0376, {1|F|D, {0x0377}}},
- {0x037f, {1|F|D, {0x03f3}}},
- {0x0386, {1|F|D, {0x03ac}}},
- {0x0388, {1|F|D, {0x03ad}}},
- {0x0389, {1|F|D, {0x03ae}}},
- {0x038a, {1|F|D, {0x03af}}},
- {0x038c, {1|F|D, {0x03cc}}},
- {0x038e, {1|F|D, {0x03cd}}},
- {0x038f, {1|F|D, {0x03ce}}},
- {0x0390, {3|F|SU|I(27), {0x03b9, 0x0308, 0x0301}}},
- {0x0391, {1|F|D, {0x03b1}}},
- {0x0392, {1|F|D, {0x03b2}}},
- {0x0393, {1|F|D, {0x03b3}}},
- {0x0394, {1|F|D, {0x03b4}}},
- {0x0395, {1|F|D, {0x03b5}}},
- {0x0396, {1|F|D, {0x03b6}}},
- {0x0397, {1|F|D, {0x03b7}}},
- {0x0398, {1|F|D, {0x03b8}}},
- {0x0399, {1|F|D, {0x03b9}}},
- {0x039a, {1|F|D, {0x03ba}}},
- {0x039b, {1|F|D, {0x03bb}}},
- {0x039c, {1|F|D, {0x03bc}}},
- {0x039d, {1|F|D, {0x03bd}}},
- {0x039e, {1|F|D, {0x03be}}},
- {0x039f, {1|F|D, {0x03bf}}},
- {0x03a0, {1|F|D, {0x03c0}}},
- {0x03a1, {1|F|D, {0x03c1}}},
- {0x03a3, {1|F|D, {0x03c3}}},
- {0x03a4, {1|F|D, {0x03c4}}},
- {0x03a5, {1|F|D, {0x03c5}}},
- {0x03a6, {1|F|D, {0x03c6}}},
- {0x03a7, {1|F|D, {0x03c7}}},
- {0x03a8, {1|F|D, {0x03c8}}},
- {0x03a9, {1|F|D, {0x03c9}}},
- {0x03aa, {1|F|D, {0x03ca}}},
- {0x03ab, {1|F|D, {0x03cb}}},
- {0x03b0, {3|F|SU|I(30), {0x03c5, 0x0308, 0x0301}}},
- {0x03c2, {1|F|SU|I(33), {0x03c3}}},
- {0x03cf, {1|F|D, {0x03d7}}},
- {0x03d0, {1|F|SU|I(34), {0x03b2}}},
- {0x03d1, {1|F|SU|I(35), {0x03b8}}},
- {0x03d5, {1|F|SU|I(36), {0x03c6}}},
- {0x03d6, {1|F|SU|I(37), {0x03c0}}},
- {0x03d8, {1|F|D, {0x03d9}}},
- {0x03da, {1|F|D, {0x03db}}},
- {0x03dc, {1|F|D, {0x03dd}}},
- {0x03de, {1|F|D, {0x03df}}},
- {0x03e0, {1|F|D, {0x03e1}}},
- {0x03e2, {1|F|D, {0x03e3}}},
- {0x03e4, {1|F|D, {0x03e5}}},
- {0x03e6, {1|F|D, {0x03e7}}},
- {0x03e8, {1|F|D, {0x03e9}}},
- {0x03ea, {1|F|D, {0x03eb}}},
- {0x03ec, {1|F|D, {0x03ed}}},
- {0x03ee, {1|F|D, {0x03ef}}},
- {0x03f0, {1|F|SU|I(38), {0x03ba}}},
- {0x03f1, {1|F|SU|I(39), {0x03c1}}},
- {0x03f4, {1|F|D, {0x03b8}}},
- {0x03f5, {1|F|SU|I(40), {0x03b5}}},
- {0x03f7, {1|F|D, {0x03f8}}},
- {0x03f9, {1|F|D, {0x03f2}}},
- {0x03fa, {1|F|D, {0x03fb}}},
- {0x03fd, {1|F|D, {0x037b}}},
- {0x03fe, {1|F|D, {0x037c}}},
- {0x03ff, {1|F|D, {0x037d}}},
- {0x0400, {1|F|D, {0x0450}}},
- {0x0401, {1|F|D, {0x0451}}},
- {0x0402, {1|F|D, {0x0452}}},
- {0x0403, {1|F|D, {0x0453}}},
- {0x0404, {1|F|D, {0x0454}}},
- {0x0405, {1|F|D, {0x0455}}},
- {0x0406, {1|F|D, {0x0456}}},
- {0x0407, {1|F|D, {0x0457}}},
- {0x0408, {1|F|D, {0x0458}}},
- {0x0409, {1|F|D, {0x0459}}},
- {0x040a, {1|F|D, {0x045a}}},
- {0x040b, {1|F|D, {0x045b}}},
- {0x040c, {1|F|D, {0x045c}}},
- {0x040d, {1|F|D, {0x045d}}},
- {0x040e, {1|F|D, {0x045e}}},
- {0x040f, {1|F|D, {0x045f}}},
- {0x0410, {1|F|D, {0x0430}}},
- {0x0411, {1|F|D, {0x0431}}},
- {0x0412, {1|F|D, {0x0432}}},
- {0x0413, {1|F|D, {0x0433}}},
- {0x0414, {1|F|D, {0x0434}}},
- {0x0415, {1|F|D, {0x0435}}},
- {0x0416, {1|F|D, {0x0436}}},
- {0x0417, {1|F|D, {0x0437}}},
- {0x0418, {1|F|D, {0x0438}}},
- {0x0419, {1|F|D, {0x0439}}},
- {0x041a, {1|F|D, {0x043a}}},
- {0x041b, {1|F|D, {0x043b}}},
- {0x041c, {1|F|D, {0x043c}}},
- {0x041d, {1|F|D, {0x043d}}},
- {0x041e, {1|F|D, {0x043e}}},
- {0x041f, {1|F|D, {0x043f}}},
- {0x0420, {1|F|D, {0x0440}}},
- {0x0421, {1|F|D, {0x0441}}},
- {0x0422, {1|F|D, {0x0442}}},
- {0x0423, {1|F|D, {0x0443}}},
- {0x0424, {1|F|D, {0x0444}}},
- {0x0425, {1|F|D, {0x0445}}},
- {0x0426, {1|F|D, {0x0446}}},
- {0x0427, {1|F|D, {0x0447}}},
- {0x0428, {1|F|D, {0x0448}}},
- {0x0429, {1|F|D, {0x0449}}},
- {0x042a, {1|F|D, {0x044a}}},
- {0x042b, {1|F|D, {0x044b}}},
- {0x042c, {1|F|D, {0x044c}}},
- {0x042d, {1|F|D, {0x044d}}},
- {0x042e, {1|F|D, {0x044e}}},
- {0x042f, {1|F|D, {0x044f}}},
- {0x0460, {1|F|D, {0x0461}}},
- {0x0462, {1|F|D, {0x0463}}},
- {0x0464, {1|F|D, {0x0465}}},
- {0x0466, {1|F|D, {0x0467}}},
- {0x0468, {1|F|D, {0x0469}}},
- {0x046a, {1|F|D, {0x046b}}},
- {0x046c, {1|F|D, {0x046d}}},
- {0x046e, {1|F|D, {0x046f}}},
- {0x0470, {1|F|D, {0x0471}}},
- {0x0472, {1|F|D, {0x0473}}},
- {0x0474, {1|F|D, {0x0475}}},
- {0x0476, {1|F|D, {0x0477}}},
- {0x0478, {1|F|D, {0x0479}}},
- {0x047a, {1|F|D, {0x047b}}},
- {0x047c, {1|F|D, {0x047d}}},
- {0x047e, {1|F|D, {0x047f}}},
- {0x0480, {1|F|D, {0x0481}}},
- {0x048a, {1|F|D, {0x048b}}},
- {0x048c, {1|F|D, {0x048d}}},
- {0x048e, {1|F|D, {0x048f}}},
- {0x0490, {1|F|D, {0x0491}}},
- {0x0492, {1|F|D, {0x0493}}},
- {0x0494, {1|F|D, {0x0495}}},
- {0x0496, {1|F|D, {0x0497}}},
- {0x0498, {1|F|D, {0x0499}}},
- {0x049a, {1|F|D, {0x049b}}},
- {0x049c, {1|F|D, {0x049d}}},
- {0x049e, {1|F|D, {0x049f}}},
- {0x04a0, {1|F|D, {0x04a1}}},
- {0x04a2, {1|F|D, {0x04a3}}},
- {0x04a4, {1|F|D, {0x04a5}}},
- {0x04a6, {1|F|D, {0x04a7}}},
- {0x04a8, {1|F|D, {0x04a9}}},
- {0x04aa, {1|F|D, {0x04ab}}},
- {0x04ac, {1|F|D, {0x04ad}}},
- {0x04ae, {1|F|D, {0x04af}}},
- {0x04b0, {1|F|D, {0x04b1}}},
- {0x04b2, {1|F|D, {0x04b3}}},
- {0x04b4, {1|F|D, {0x04b5}}},
- {0x04b6, {1|F|D, {0x04b7}}},
- {0x04b8, {1|F|D, {0x04b9}}},
- {0x04ba, {1|F|D, {0x04bb}}},
- {0x04bc, {1|F|D, {0x04bd}}},
- {0x04be, {1|F|D, {0x04bf}}},
- {0x04c0, {1|F|D, {0x04cf}}},
- {0x04c1, {1|F|D, {0x04c2}}},
- {0x04c3, {1|F|D, {0x04c4}}},
- {0x04c5, {1|F|D, {0x04c6}}},
- {0x04c7, {1|F|D, {0x04c8}}},
- {0x04c9, {1|F|D, {0x04ca}}},
- {0x04cb, {1|F|D, {0x04cc}}},
- {0x04cd, {1|F|D, {0x04ce}}},
- {0x04d0, {1|F|D, {0x04d1}}},
- {0x04d2, {1|F|D, {0x04d3}}},
- {0x04d4, {1|F|D, {0x04d5}}},
- {0x04d6, {1|F|D, {0x04d7}}},
- {0x04d8, {1|F|D, {0x04d9}}},
- {0x04da, {1|F|D, {0x04db}}},
- {0x04dc, {1|F|D, {0x04dd}}},
- {0x04de, {1|F|D, {0x04df}}},
- {0x04e0, {1|F|D, {0x04e1}}},
- {0x04e2, {1|F|D, {0x04e3}}},
- {0x04e4, {1|F|D, {0x04e5}}},
- {0x04e6, {1|F|D, {0x04e7}}},
- {0x04e8, {1|F|D, {0x04e9}}},
- {0x04ea, {1|F|D, {0x04eb}}},
- {0x04ec, {1|F|D, {0x04ed}}},
- {0x04ee, {1|F|D, {0x04ef}}},
- {0x04f0, {1|F|D, {0x04f1}}},
- {0x04f2, {1|F|D, {0x04f3}}},
- {0x04f4, {1|F|D, {0x04f5}}},
- {0x04f6, {1|F|D, {0x04f7}}},
- {0x04f8, {1|F|D, {0x04f9}}},
- {0x04fa, {1|F|D, {0x04fb}}},
- {0x04fc, {1|F|D, {0x04fd}}},
- {0x04fe, {1|F|D, {0x04ff}}},
- {0x0500, {1|F|D, {0x0501}}},
- {0x0502, {1|F|D, {0x0503}}},
- {0x0504, {1|F|D, {0x0505}}},
- {0x0506, {1|F|D, {0x0507}}},
- {0x0508, {1|F|D, {0x0509}}},
- {0x050a, {1|F|D, {0x050b}}},
- {0x050c, {1|F|D, {0x050d}}},
- {0x050e, {1|F|D, {0x050f}}},
- {0x0510, {1|F|D, {0x0511}}},
- {0x0512, {1|F|D, {0x0513}}},
- {0x0514, {1|F|D, {0x0515}}},
- {0x0516, {1|F|D, {0x0517}}},
- {0x0518, {1|F|D, {0x0519}}},
- {0x051a, {1|F|D, {0x051b}}},
- {0x051c, {1|F|D, {0x051d}}},
- {0x051e, {1|F|D, {0x051f}}},
- {0x0520, {1|F|D, {0x0521}}},
- {0x0522, {1|F|D, {0x0523}}},
- {0x0524, {1|F|D, {0x0525}}},
- {0x0526, {1|F|D, {0x0527}}},
- {0x0528, {1|F|D, {0x0529}}},
- {0x052a, {1|F|D, {0x052b}}},
- {0x052c, {1|F|D, {0x052d}}},
- {0x052e, {1|F|D, {0x052f}}},
- {0x0531, {1|F|D, {0x0561}}},
- {0x0532, {1|F|D, {0x0562}}},
- {0x0533, {1|F|D, {0x0563}}},
- {0x0534, {1|F|D, {0x0564}}},
- {0x0535, {1|F|D, {0x0565}}},
- {0x0536, {1|F|D, {0x0566}}},
- {0x0537, {1|F|D, {0x0567}}},
- {0x0538, {1|F|D, {0x0568}}},
- {0x0539, {1|F|D, {0x0569}}},
- {0x053a, {1|F|D, {0x056a}}},
- {0x053b, {1|F|D, {0x056b}}},
- {0x053c, {1|F|D, {0x056c}}},
- {0x053d, {1|F|D, {0x056d}}},
- {0x053e, {1|F|D, {0x056e}}},
- {0x053f, {1|F|D, {0x056f}}},
- {0x0540, {1|F|D, {0x0570}}},
- {0x0541, {1|F|D, {0x0571}}},
- {0x0542, {1|F|D, {0x0572}}},
- {0x0543, {1|F|D, {0x0573}}},
- {0x0544, {1|F|D, {0x0574}}},
- {0x0545, {1|F|D, {0x0575}}},
- {0x0546, {1|F|D, {0x0576}}},
- {0x0547, {1|F|D, {0x0577}}},
- {0x0548, {1|F|D, {0x0578}}},
- {0x0549, {1|F|D, {0x0579}}},
- {0x054a, {1|F|D, {0x057a}}},
- {0x054b, {1|F|D, {0x057b}}},
- {0x054c, {1|F|D, {0x057c}}},
- {0x054d, {1|F|D, {0x057d}}},
- {0x054e, {1|F|D, {0x057e}}},
- {0x054f, {1|F|D, {0x057f}}},
- {0x0550, {1|F|D, {0x0580}}},
- {0x0551, {1|F|D, {0x0581}}},
- {0x0552, {1|F|D, {0x0582}}},
- {0x0553, {1|F|D, {0x0583}}},
- {0x0554, {1|F|D, {0x0584}}},
- {0x0555, {1|F|D, {0x0585}}},
- {0x0556, {1|F|D, {0x0586}}},
- {0x0587, {2|F|ST|SU|I(41), {0x0565, 0x0582}}},
- {0x10a0, {1|F|D, {0x2d00}}},
- {0x10a1, {1|F|D, {0x2d01}}},
- {0x10a2, {1|F|D, {0x2d02}}},
- {0x10a3, {1|F|D, {0x2d03}}},
- {0x10a4, {1|F|D, {0x2d04}}},
- {0x10a5, {1|F|D, {0x2d05}}},
- {0x10a6, {1|F|D, {0x2d06}}},
- {0x10a7, {1|F|D, {0x2d07}}},
- {0x10a8, {1|F|D, {0x2d08}}},
- {0x10a9, {1|F|D, {0x2d09}}},
- {0x10aa, {1|F|D, {0x2d0a}}},
- {0x10ab, {1|F|D, {0x2d0b}}},
- {0x10ac, {1|F|D, {0x2d0c}}},
- {0x10ad, {1|F|D, {0x2d0d}}},
- {0x10ae, {1|F|D, {0x2d0e}}},
- {0x10af, {1|F|D, {0x2d0f}}},
- {0x10b0, {1|F|D, {0x2d10}}},
- {0x10b1, {1|F|D, {0x2d11}}},
- {0x10b2, {1|F|D, {0x2d12}}},
- {0x10b3, {1|F|D, {0x2d13}}},
- {0x10b4, {1|F|D, {0x2d14}}},
- {0x10b5, {1|F|D, {0x2d15}}},
- {0x10b6, {1|F|D, {0x2d16}}},
- {0x10b7, {1|F|D, {0x2d17}}},
- {0x10b8, {1|F|D, {0x2d18}}},
- {0x10b9, {1|F|D, {0x2d19}}},
- {0x10ba, {1|F|D, {0x2d1a}}},
- {0x10bb, {1|F|D, {0x2d1b}}},
- {0x10bc, {1|F|D, {0x2d1c}}},
- {0x10bd, {1|F|D, {0x2d1d}}},
- {0x10be, {1|F|D, {0x2d1e}}},
- {0x10bf, {1|F|D, {0x2d1f}}},
- {0x10c0, {1|F|D, {0x2d20}}},
- {0x10c1, {1|F|D, {0x2d21}}},
- {0x10c2, {1|F|D, {0x2d22}}},
- {0x10c3, {1|F|D, {0x2d23}}},
- {0x10c4, {1|F|D, {0x2d24}}},
- {0x10c5, {1|F|D, {0x2d25}}},
- {0x10c7, {1|F|D, {0x2d27}}},
- {0x10cd, {1|F|D, {0x2d2d}}},
- {0x13f8, {1|F|U, {0x13f0}}},
- {0x13f9, {1|F|U, {0x13f1}}},
- {0x13fa, {1|F|U, {0x13f2}}},
- {0x13fb, {1|F|U, {0x13f3}}},
- {0x13fc, {1|F|U, {0x13f4}}},
- {0x13fd, {1|F|U, {0x13f5}}},
- {0x1c80, {1|F|SU|I(45), {0x0432}}},
- {0x1c81, {1|F|SU|I(46), {0x0434}}},
- {0x1c82, {1|F|SU|I(47), {0x043e}}},
- {0x1c83, {1|F|SU|I(48), {0x0441}}},
- {0x1c84, {1|F|SU|I(49), {0x0442}}},
- {0x1c85, {1|F|SU|I(50), {0x0442}}},
- {0x1c86, {1|F|SU|I(51), {0x044a}}},
- {0x1c87, {1|F|SU|I(52), {0x0463}}},
- {0x1c88, {1|F|SU|I(53), {0xa64b}}},
- {0x1c90, {1|F|D, {0x10d0}}},
- {0x1c91, {1|F|D, {0x10d1}}},
- {0x1c92, {1|F|D, {0x10d2}}},
- {0x1c93, {1|F|D, {0x10d3}}},
- {0x1c94, {1|F|D, {0x10d4}}},
- {0x1c95, {1|F|D, {0x10d5}}},
- {0x1c96, {1|F|D, {0x10d6}}},
- {0x1c97, {1|F|D, {0x10d7}}},
- {0x1c98, {1|F|D, {0x10d8}}},
- {0x1c99, {1|F|D, {0x10d9}}},
- {0x1c9a, {1|F|D, {0x10da}}},
- {0x1c9b, {1|F|D, {0x10db}}},
- {0x1c9c, {1|F|D, {0x10dc}}},
- {0x1c9d, {1|F|D, {0x10dd}}},
- {0x1c9e, {1|F|D, {0x10de}}},
- {0x1c9f, {1|F|D, {0x10df}}},
- {0x1ca0, {1|F|D, {0x10e0}}},
- {0x1ca1, {1|F|D, {0x10e1}}},
- {0x1ca2, {1|F|D, {0x10e2}}},
- {0x1ca3, {1|F|D, {0x10e3}}},
- {0x1ca4, {1|F|D, {0x10e4}}},
- {0x1ca5, {1|F|D, {0x10e5}}},
- {0x1ca6, {1|F|D, {0x10e6}}},
- {0x1ca7, {1|F|D, {0x10e7}}},
- {0x1ca8, {1|F|D, {0x10e8}}},
- {0x1ca9, {1|F|D, {0x10e9}}},
- {0x1caa, {1|F|D, {0x10ea}}},
- {0x1cab, {1|F|D, {0x10eb}}},
- {0x1cac, {1|F|D, {0x10ec}}},
- {0x1cad, {1|F|D, {0x10ed}}},
- {0x1cae, {1|F|D, {0x10ee}}},
- {0x1caf, {1|F|D, {0x10ef}}},
- {0x1cb0, {1|F|D, {0x10f0}}},
- {0x1cb1, {1|F|D, {0x10f1}}},
- {0x1cb2, {1|F|D, {0x10f2}}},
- {0x1cb3, {1|F|D, {0x10f3}}},
- {0x1cb4, {1|F|D, {0x10f4}}},
- {0x1cb5, {1|F|D, {0x10f5}}},
- {0x1cb6, {1|F|D, {0x10f6}}},
- {0x1cb7, {1|F|D, {0x10f7}}},
- {0x1cb8, {1|F|D, {0x10f8}}},
- {0x1cb9, {1|F|D, {0x10f9}}},
- {0x1cba, {1|F|D, {0x10fa}}},
- {0x1cbd, {1|F|D, {0x10fd}}},
- {0x1cbe, {1|F|D, {0x10fe}}},
- {0x1cbf, {1|F|D, {0x10ff}}},
- {0x1e00, {1|F|D, {0x1e01}}},
- {0x1e02, {1|F|D, {0x1e03}}},
- {0x1e04, {1|F|D, {0x1e05}}},
- {0x1e06, {1|F|D, {0x1e07}}},
- {0x1e08, {1|F|D, {0x1e09}}},
- {0x1e0a, {1|F|D, {0x1e0b}}},
- {0x1e0c, {1|F|D, {0x1e0d}}},
- {0x1e0e, {1|F|D, {0x1e0f}}},
- {0x1e10, {1|F|D, {0x1e11}}},
- {0x1e12, {1|F|D, {0x1e13}}},
- {0x1e14, {1|F|D, {0x1e15}}},
- {0x1e16, {1|F|D, {0x1e17}}},
- {0x1e18, {1|F|D, {0x1e19}}},
- {0x1e1a, {1|F|D, {0x1e1b}}},
- {0x1e1c, {1|F|D, {0x1e1d}}},
- {0x1e1e, {1|F|D, {0x1e1f}}},
- {0x1e20, {1|F|D, {0x1e21}}},
- {0x1e22, {1|F|D, {0x1e23}}},
- {0x1e24, {1|F|D, {0x1e25}}},
- {0x1e26, {1|F|D, {0x1e27}}},
- {0x1e28, {1|F|D, {0x1e29}}},
- {0x1e2a, {1|F|D, {0x1e2b}}},
- {0x1e2c, {1|F|D, {0x1e2d}}},
- {0x1e2e, {1|F|D, {0x1e2f}}},
- {0x1e30, {1|F|D, {0x1e31}}},
- {0x1e32, {1|F|D, {0x1e33}}},
- {0x1e34, {1|F|D, {0x1e35}}},
- {0x1e36, {1|F|D, {0x1e37}}},
- {0x1e38, {1|F|D, {0x1e39}}},
- {0x1e3a, {1|F|D, {0x1e3b}}},
- {0x1e3c, {1|F|D, {0x1e3d}}},
- {0x1e3e, {1|F|D, {0x1e3f}}},
- {0x1e40, {1|F|D, {0x1e41}}},
- {0x1e42, {1|F|D, {0x1e43}}},
- {0x1e44, {1|F|D, {0x1e45}}},
- {0x1e46, {1|F|D, {0x1e47}}},
- {0x1e48, {1|F|D, {0x1e49}}},
- {0x1e4a, {1|F|D, {0x1e4b}}},
- {0x1e4c, {1|F|D, {0x1e4d}}},
- {0x1e4e, {1|F|D, {0x1e4f}}},
- {0x1e50, {1|F|D, {0x1e51}}},
- {0x1e52, {1|F|D, {0x1e53}}},
- {0x1e54, {1|F|D, {0x1e55}}},
- {0x1e56, {1|F|D, {0x1e57}}},
- {0x1e58, {1|F|D, {0x1e59}}},
- {0x1e5a, {1|F|D, {0x1e5b}}},
- {0x1e5c, {1|F|D, {0x1e5d}}},
- {0x1e5e, {1|F|D, {0x1e5f}}},
- {0x1e60, {1|F|D, {0x1e61}}},
- {0x1e62, {1|F|D, {0x1e63}}},
- {0x1e64, {1|F|D, {0x1e65}}},
- {0x1e66, {1|F|D, {0x1e67}}},
- {0x1e68, {1|F|D, {0x1e69}}},
- {0x1e6a, {1|F|D, {0x1e6b}}},
- {0x1e6c, {1|F|D, {0x1e6d}}},
- {0x1e6e, {1|F|D, {0x1e6f}}},
- {0x1e70, {1|F|D, {0x1e71}}},
- {0x1e72, {1|F|D, {0x1e73}}},
- {0x1e74, {1|F|D, {0x1e75}}},
- {0x1e76, {1|F|D, {0x1e77}}},
- {0x1e78, {1|F|D, {0x1e79}}},
- {0x1e7a, {1|F|D, {0x1e7b}}},
- {0x1e7c, {1|F|D, {0x1e7d}}},
- {0x1e7e, {1|F|D, {0x1e7f}}},
- {0x1e80, {1|F|D, {0x1e81}}},
- {0x1e82, {1|F|D, {0x1e83}}},
- {0x1e84, {1|F|D, {0x1e85}}},
- {0x1e86, {1|F|D, {0x1e87}}},
- {0x1e88, {1|F|D, {0x1e89}}},
- {0x1e8a, {1|F|D, {0x1e8b}}},
- {0x1e8c, {1|F|D, {0x1e8d}}},
- {0x1e8e, {1|F|D, {0x1e8f}}},
- {0x1e90, {1|F|D, {0x1e91}}},
- {0x1e92, {1|F|D, {0x1e93}}},
- {0x1e94, {1|F|D, {0x1e95}}},
- {0x1e96, {2|F|SU|I(54), {0x0068, 0x0331}}},
- {0x1e97, {2|F|SU|I(56), {0x0074, 0x0308}}},
- {0x1e98, {2|F|SU|I(58), {0x0077, 0x030a}}},
- {0x1e99, {2|F|SU|I(60), {0x0079, 0x030a}}},
- {0x1e9a, {2|F|SU|I(62), {0x0061, 0x02be}}},
- {0x1e9b, {1|F|SU|I(64), {0x1e61}}},
- {0x1e9e, {2|F|SL|I(65), {0x0073, 0x0073}}},
- {0x1ea0, {1|F|D, {0x1ea1}}},
- {0x1ea2, {1|F|D, {0x1ea3}}},
- {0x1ea4, {1|F|D, {0x1ea5}}},
- {0x1ea6, {1|F|D, {0x1ea7}}},
- {0x1ea8, {1|F|D, {0x1ea9}}},
- {0x1eaa, {1|F|D, {0x1eab}}},
- {0x1eac, {1|F|D, {0x1ead}}},
- {0x1eae, {1|F|D, {0x1eaf}}},
- {0x1eb0, {1|F|D, {0x1eb1}}},
- {0x1eb2, {1|F|D, {0x1eb3}}},
- {0x1eb4, {1|F|D, {0x1eb5}}},
- {0x1eb6, {1|F|D, {0x1eb7}}},
- {0x1eb8, {1|F|D, {0x1eb9}}},
- {0x1eba, {1|F|D, {0x1ebb}}},
- {0x1ebc, {1|F|D, {0x1ebd}}},
- {0x1ebe, {1|F|D, {0x1ebf}}},
- {0x1ec0, {1|F|D, {0x1ec1}}},
- {0x1ec2, {1|F|D, {0x1ec3}}},
- {0x1ec4, {1|F|D, {0x1ec5}}},
- {0x1ec6, {1|F|D, {0x1ec7}}},
- {0x1ec8, {1|F|D, {0x1ec9}}},
- {0x1eca, {1|F|D, {0x1ecb}}},
- {0x1ecc, {1|F|D, {0x1ecd}}},
- {0x1ece, {1|F|D, {0x1ecf}}},
- {0x1ed0, {1|F|D, {0x1ed1}}},
- {0x1ed2, {1|F|D, {0x1ed3}}},
- {0x1ed4, {1|F|D, {0x1ed5}}},
- {0x1ed6, {1|F|D, {0x1ed7}}},
- {0x1ed8, {1|F|D, {0x1ed9}}},
- {0x1eda, {1|F|D, {0x1edb}}},
- {0x1edc, {1|F|D, {0x1edd}}},
- {0x1ede, {1|F|D, {0x1edf}}},
- {0x1ee0, {1|F|D, {0x1ee1}}},
- {0x1ee2, {1|F|D, {0x1ee3}}},
- {0x1ee4, {1|F|D, {0x1ee5}}},
- {0x1ee6, {1|F|D, {0x1ee7}}},
- {0x1ee8, {1|F|D, {0x1ee9}}},
- {0x1eea, {1|F|D, {0x1eeb}}},
- {0x1eec, {1|F|D, {0x1eed}}},
- {0x1eee, {1|F|D, {0x1eef}}},
- {0x1ef0, {1|F|D, {0x1ef1}}},
- {0x1ef2, {1|F|D, {0x1ef3}}},
- {0x1ef4, {1|F|D, {0x1ef5}}},
- {0x1ef6, {1|F|D, {0x1ef7}}},
- {0x1ef8, {1|F|D, {0x1ef9}}},
- {0x1efa, {1|F|D, {0x1efb}}},
- {0x1efc, {1|F|D, {0x1efd}}},
- {0x1efe, {1|F|D, {0x1eff}}},
- {0x1f08, {1|F|D, {0x1f00}}},
- {0x1f09, {1|F|D, {0x1f01}}},
- {0x1f0a, {1|F|D, {0x1f02}}},
- {0x1f0b, {1|F|D, {0x1f03}}},
- {0x1f0c, {1|F|D, {0x1f04}}},
- {0x1f0d, {1|F|D, {0x1f05}}},
- {0x1f0e, {1|F|D, {0x1f06}}},
- {0x1f0f, {1|F|D, {0x1f07}}},
- {0x1f18, {1|F|D, {0x1f10}}},
- {0x1f19, {1|F|D, {0x1f11}}},
- {0x1f1a, {1|F|D, {0x1f12}}},
- {0x1f1b, {1|F|D, {0x1f13}}},
- {0x1f1c, {1|F|D, {0x1f14}}},
- {0x1f1d, {1|F|D, {0x1f15}}},
- {0x1f28, {1|F|D, {0x1f20}}},
- {0x1f29, {1|F|D, {0x1f21}}},
- {0x1f2a, {1|F|D, {0x1f22}}},
- {0x1f2b, {1|F|D, {0x1f23}}},
- {0x1f2c, {1|F|D, {0x1f24}}},
- {0x1f2d, {1|F|D, {0x1f25}}},
- {0x1f2e, {1|F|D, {0x1f26}}},
- {0x1f2f, {1|F|D, {0x1f27}}},
- {0x1f38, {1|F|D, {0x1f30}}},
- {0x1f39, {1|F|D, {0x1f31}}},
- {0x1f3a, {1|F|D, {0x1f32}}},
- {0x1f3b, {1|F|D, {0x1f33}}},
- {0x1f3c, {1|F|D, {0x1f34}}},
- {0x1f3d, {1|F|D, {0x1f35}}},
- {0x1f3e, {1|F|D, {0x1f36}}},
- {0x1f3f, {1|F|D, {0x1f37}}},
- {0x1f48, {1|F|D, {0x1f40}}},
- {0x1f49, {1|F|D, {0x1f41}}},
- {0x1f4a, {1|F|D, {0x1f42}}},
- {0x1f4b, {1|F|D, {0x1f43}}},
- {0x1f4c, {1|F|D, {0x1f44}}},
- {0x1f4d, {1|F|D, {0x1f45}}},
- {0x1f50, {2|F|SU|I(66), {0x03c5, 0x0313}}},
- {0x1f52, {3|F|SU|I(68), {0x03c5, 0x0313, 0x0300}}},
- {0x1f54, {3|F|SU|I(71), {0x03c5, 0x0313, 0x0301}}},
- {0x1f56, {3|F|SU|I(74), {0x03c5, 0x0313, 0x0342}}},
- {0x1f59, {1|F|D, {0x1f51}}},
- {0x1f5b, {1|F|D, {0x1f53}}},
- {0x1f5d, {1|F|D, {0x1f55}}},
- {0x1f5f, {1|F|D, {0x1f57}}},
- {0x1f68, {1|F|D, {0x1f60}}},
- {0x1f69, {1|F|D, {0x1f61}}},
- {0x1f6a, {1|F|D, {0x1f62}}},
- {0x1f6b, {1|F|D, {0x1f63}}},
- {0x1f6c, {1|F|D, {0x1f64}}},
- {0x1f6d, {1|F|D, {0x1f65}}},
- {0x1f6e, {1|F|D, {0x1f66}}},
- {0x1f6f, {1|F|D, {0x1f67}}},
- {0x1f80, {2|F|ST|SU|I(77), {0x1f00, 0x03b9}}},
- {0x1f81, {2|F|ST|SU|I(80), {0x1f01, 0x03b9}}},
- {0x1f82, {2|F|ST|SU|I(83), {0x1f02, 0x03b9}}},
- {0x1f83, {2|F|ST|SU|I(86), {0x1f03, 0x03b9}}},
- {0x1f84, {2|F|ST|SU|I(89), {0x1f04, 0x03b9}}},
- {0x1f85, {2|F|ST|SU|I(92), {0x1f05, 0x03b9}}},
- {0x1f86, {2|F|ST|SU|I(95), {0x1f06, 0x03b9}}},
- {0x1f87, {2|F|ST|SU|I(98), {0x1f07, 0x03b9}}},
- {0x1f88, {2|F|IT|SL|SU|I(101), {0x1f00, 0x03b9}}},
- {0x1f89, {2|F|IT|SL|SU|I(106), {0x1f01, 0x03b9}}},
- {0x1f8a, {2|F|IT|SL|SU|I(111), {0x1f02, 0x03b9}}},
- {0x1f8b, {2|F|IT|SL|SU|I(116), {0x1f03, 0x03b9}}},
- {0x1f8c, {2|F|IT|SL|SU|I(121), {0x1f04, 0x03b9}}},
- {0x1f8d, {2|F|IT|SL|SU|I(126), {0x1f05, 0x03b9}}},
- {0x1f8e, {2|F|IT|SL|SU|I(131), {0x1f06, 0x03b9}}},
- {0x1f8f, {2|F|IT|SL|SU|I(136), {0x1f07, 0x03b9}}},
- {0x1f90, {2|F|ST|SU|I(141), {0x1f20, 0x03b9}}},
- {0x1f91, {2|F|ST|SU|I(144), {0x1f21, 0x03b9}}},
- {0x1f92, {2|F|ST|SU|I(147), {0x1f22, 0x03b9}}},
- {0x1f93, {2|F|ST|SU|I(150), {0x1f23, 0x03b9}}},
- {0x1f94, {2|F|ST|SU|I(153), {0x1f24, 0x03b9}}},
- {0x1f95, {2|F|ST|SU|I(156), {0x1f25, 0x03b9}}},
- {0x1f96, {2|F|ST|SU|I(159), {0x1f26, 0x03b9}}},
- {0x1f97, {2|F|ST|SU|I(162), {0x1f27, 0x03b9}}},
- {0x1f98, {2|F|IT|SL|SU|I(165), {0x1f20, 0x03b9}}},
- {0x1f99, {2|F|IT|SL|SU|I(170), {0x1f21, 0x03b9}}},
- {0x1f9a, {2|F|IT|SL|SU|I(175), {0x1f22, 0x03b9}}},
- {0x1f9b, {2|F|IT|SL|SU|I(180), {0x1f23, 0x03b9}}},
- {0x1f9c, {2|F|IT|SL|SU|I(185), {0x1f24, 0x03b9}}},
- {0x1f9d, {2|F|IT|SL|SU|I(190), {0x1f25, 0x03b9}}},
- {0x1f9e, {2|F|IT|SL|SU|I(195), {0x1f26, 0x03b9}}},
- {0x1f9f, {2|F|IT|SL|SU|I(200), {0x1f27, 0x03b9}}},
- {0x1fa0, {2|F|ST|SU|I(205), {0x1f60, 0x03b9}}},
- {0x1fa1, {2|F|ST|SU|I(208), {0x1f61, 0x03b9}}},
- {0x1fa2, {2|F|ST|SU|I(211), {0x1f62, 0x03b9}}},
- {0x1fa3, {2|F|ST|SU|I(214), {0x1f63, 0x03b9}}},
- {0x1fa4, {2|F|ST|SU|I(217), {0x1f64, 0x03b9}}},
- {0x1fa5, {2|F|ST|SU|I(220), {0x1f65, 0x03b9}}},
- {0x1fa6, {2|F|ST|SU|I(223), {0x1f66, 0x03b9}}},
- {0x1fa7, {2|F|ST|SU|I(226), {0x1f67, 0x03b9}}},
- {0x1fa8, {2|F|IT|SL|SU|I(229), {0x1f60, 0x03b9}}},
- {0x1fa9, {2|F|IT|SL|SU|I(234), {0x1f61, 0x03b9}}},
- {0x1faa, {2|F|IT|SL|SU|I(239), {0x1f62, 0x03b9}}},
- {0x1fab, {2|F|IT|SL|SU|I(244), {0x1f63, 0x03b9}}},
- {0x1fac, {2|F|IT|SL|SU|I(249), {0x1f64, 0x03b9}}},
- {0x1fad, {2|F|IT|SL|SU|I(254), {0x1f65, 0x03b9}}},
- {0x1fae, {2|F|IT|SL|SU|I(259), {0x1f66, 0x03b9}}},
- {0x1faf, {2|F|IT|SL|SU|I(264), {0x1f67, 0x03b9}}},
- {0x1fb2, {2|F|ST|SU|I(269), {0x1f70, 0x03b9}}},
- {0x1fb3, {2|F|ST|SU|I(273), {0x03b1, 0x03b9}}},
- {0x1fb4, {2|F|ST|SU|I(276), {0x03ac, 0x03b9}}},
- {0x1fb6, {2|F|SU|I(280), {0x03b1, 0x0342}}},
- {0x1fb7, {3|F|ST|SU|I(282), {0x03b1, 0x0342, 0x03b9}}},
- {0x1fb8, {1|F|D, {0x1fb0}}},
- {0x1fb9, {1|F|D, {0x1fb1}}},
- {0x1fba, {1|F|D, {0x1f70}}},
- {0x1fbb, {1|F|D, {0x1f71}}},
- {0x1fbc, {2|F|IT|SL|SU|I(288), {0x03b1, 0x03b9}}},
- {0x1fbe, {1|F|SU|I(293), {0x03b9}}},
- {0x1fc2, {2|F|ST|SU|I(294), {0x1f74, 0x03b9}}},
- {0x1fc3, {2|F|ST|SU|I(298), {0x03b7, 0x03b9}}},
- {0x1fc4, {2|F|ST|SU|I(301), {0x03ae, 0x03b9}}},
- {0x1fc6, {2|F|SU|I(305), {0x03b7, 0x0342}}},
- {0x1fc7, {3|F|ST|SU|I(307), {0x03b7, 0x0342, 0x03b9}}},
- {0x1fc8, {1|F|D, {0x1f72}}},
- {0x1fc9, {1|F|D, {0x1f73}}},
- {0x1fca, {1|F|D, {0x1f74}}},
- {0x1fcb, {1|F|D, {0x1f75}}},
- {0x1fcc, {2|F|IT|SL|SU|I(313), {0x03b7, 0x03b9}}},
- {0x1fd2, {3|F|SU|I(318), {0x03b9, 0x0308, 0x0300}}},
- {0x1fd3, {3|F|SU|I(321), {0x03b9, 0x0308, 0x0301}}},
- {0x1fd6, {2|F|SU|I(324), {0x03b9, 0x0342}}},
- {0x1fd7, {3|F|SU|I(326), {0x03b9, 0x0308, 0x0342}}},
- {0x1fd8, {1|F|D, {0x1fd0}}},
- {0x1fd9, {1|F|D, {0x1fd1}}},
- {0x1fda, {1|F|D, {0x1f76}}},
- {0x1fdb, {1|F|D, {0x1f77}}},
- {0x1fe2, {3|F|SU|I(329), {0x03c5, 0x0308, 0x0300}}},
- {0x1fe3, {3|F|SU|I(332), {0x03c5, 0x0308, 0x0301}}},
- {0x1fe4, {2|F|SU|I(335), {0x03c1, 0x0313}}},
- {0x1fe6, {2|F|SU|I(337), {0x03c5, 0x0342}}},
- {0x1fe7, {3|F|SU|I(339), {0x03c5, 0x0308, 0x0342}}},
- {0x1fe8, {1|F|D, {0x1fe0}}},
- {0x1fe9, {1|F|D, {0x1fe1}}},
- {0x1fea, {1|F|D, {0x1f7a}}},
- {0x1feb, {1|F|D, {0x1f7b}}},
- {0x1fec, {1|F|D, {0x1fe5}}},
- {0x1ff2, {2|F|ST|SU|I(342), {0x1f7c, 0x03b9}}},
- {0x1ff3, {2|F|ST|SU|I(346), {0x03c9, 0x03b9}}},
- {0x1ff4, {2|F|ST|SU|I(349), {0x03ce, 0x03b9}}},
- {0x1ff6, {2|F|SU|I(353), {0x03c9, 0x0342}}},
- {0x1ff7, {3|F|ST|SU|I(355), {0x03c9, 0x0342, 0x03b9}}},
- {0x1ff8, {1|F|D, {0x1f78}}},
- {0x1ff9, {1|F|D, {0x1f79}}},
- {0x1ffa, {1|F|D, {0x1f7c}}},
- {0x1ffb, {1|F|D, {0x1f7d}}},
- {0x1ffc, {2|F|IT|SL|SU|I(361), {0x03c9, 0x03b9}}},
- {0x2126, {1|F|D, {0x03c9}}},
- {0x212a, {1|F|D, {0x006b}}},
- {0x212b, {1|F|D, {0x00e5}}},
- {0x2132, {1|F|D, {0x214e}}},
- {0x2160, {1|F|D, {0x2170}}},
- {0x2161, {1|F|D, {0x2171}}},
- {0x2162, {1|F|D, {0x2172}}},
- {0x2163, {1|F|D, {0x2173}}},
- {0x2164, {1|F|D, {0x2174}}},
- {0x2165, {1|F|D, {0x2175}}},
- {0x2166, {1|F|D, {0x2176}}},
- {0x2167, {1|F|D, {0x2177}}},
- {0x2168, {1|F|D, {0x2178}}},
- {0x2169, {1|F|D, {0x2179}}},
- {0x216a, {1|F|D, {0x217a}}},
- {0x216b, {1|F|D, {0x217b}}},
- {0x216c, {1|F|D, {0x217c}}},
- {0x216d, {1|F|D, {0x217d}}},
- {0x216e, {1|F|D, {0x217e}}},
- {0x216f, {1|F|D, {0x217f}}},
- {0x2183, {1|F|D, {0x2184}}},
- {0x24b6, {1|F|D, {0x24d0}}},
- {0x24b7, {1|F|D, {0x24d1}}},
- {0x24b8, {1|F|D, {0x24d2}}},
- {0x24b9, {1|F|D, {0x24d3}}},
- {0x24ba, {1|F|D, {0x24d4}}},
- {0x24bb, {1|F|D, {0x24d5}}},
- {0x24bc, {1|F|D, {0x24d6}}},
- {0x24bd, {1|F|D, {0x24d7}}},
- {0x24be, {1|F|D, {0x24d8}}},
- {0x24bf, {1|F|D, {0x24d9}}},
- {0x24c0, {1|F|D, {0x24da}}},
- {0x24c1, {1|F|D, {0x24db}}},
- {0x24c2, {1|F|D, {0x24dc}}},
- {0x24c3, {1|F|D, {0x24dd}}},
- {0x24c4, {1|F|D, {0x24de}}},
- {0x24c5, {1|F|D, {0x24df}}},
- {0x24c6, {1|F|D, {0x24e0}}},
- {0x24c7, {1|F|D, {0x24e1}}},
- {0x24c8, {1|F|D, {0x24e2}}},
- {0x24c9, {1|F|D, {0x24e3}}},
- {0x24ca, {1|F|D, {0x24e4}}},
- {0x24cb, {1|F|D, {0x24e5}}},
- {0x24cc, {1|F|D, {0x24e6}}},
- {0x24cd, {1|F|D, {0x24e7}}},
- {0x24ce, {1|F|D, {0x24e8}}},
- {0x24cf, {1|F|D, {0x24e9}}},
- {0x2c00, {1|F|D, {0x2c30}}},
- {0x2c01, {1|F|D, {0x2c31}}},
- {0x2c02, {1|F|D, {0x2c32}}},
- {0x2c03, {1|F|D, {0x2c33}}},
- {0x2c04, {1|F|D, {0x2c34}}},
- {0x2c05, {1|F|D, {0x2c35}}},
- {0x2c06, {1|F|D, {0x2c36}}},
- {0x2c07, {1|F|D, {0x2c37}}},
- {0x2c08, {1|F|D, {0x2c38}}},
- {0x2c09, {1|F|D, {0x2c39}}},
- {0x2c0a, {1|F|D, {0x2c3a}}},
- {0x2c0b, {1|F|D, {0x2c3b}}},
- {0x2c0c, {1|F|D, {0x2c3c}}},
- {0x2c0d, {1|F|D, {0x2c3d}}},
- {0x2c0e, {1|F|D, {0x2c3e}}},
- {0x2c0f, {1|F|D, {0x2c3f}}},
- {0x2c10, {1|F|D, {0x2c40}}},
- {0x2c11, {1|F|D, {0x2c41}}},
- {0x2c12, {1|F|D, {0x2c42}}},
- {0x2c13, {1|F|D, {0x2c43}}},
- {0x2c14, {1|F|D, {0x2c44}}},
- {0x2c15, {1|F|D, {0x2c45}}},
- {0x2c16, {1|F|D, {0x2c46}}},
- {0x2c17, {1|F|D, {0x2c47}}},
- {0x2c18, {1|F|D, {0x2c48}}},
- {0x2c19, {1|F|D, {0x2c49}}},
- {0x2c1a, {1|F|D, {0x2c4a}}},
- {0x2c1b, {1|F|D, {0x2c4b}}},
- {0x2c1c, {1|F|D, {0x2c4c}}},
- {0x2c1d, {1|F|D, {0x2c4d}}},
- {0x2c1e, {1|F|D, {0x2c4e}}},
- {0x2c1f, {1|F|D, {0x2c4f}}},
- {0x2c20, {1|F|D, {0x2c50}}},
- {0x2c21, {1|F|D, {0x2c51}}},
- {0x2c22, {1|F|D, {0x2c52}}},
- {0x2c23, {1|F|D, {0x2c53}}},
- {0x2c24, {1|F|D, {0x2c54}}},
- {0x2c25, {1|F|D, {0x2c55}}},
- {0x2c26, {1|F|D, {0x2c56}}},
- {0x2c27, {1|F|D, {0x2c57}}},
- {0x2c28, {1|F|D, {0x2c58}}},
- {0x2c29, {1|F|D, {0x2c59}}},
- {0x2c2a, {1|F|D, {0x2c5a}}},
- {0x2c2b, {1|F|D, {0x2c5b}}},
- {0x2c2c, {1|F|D, {0x2c5c}}},
- {0x2c2d, {1|F|D, {0x2c5d}}},
- {0x2c2e, {1|F|D, {0x2c5e}}},
- {0x2c60, {1|F|D, {0x2c61}}},
- {0x2c62, {1|F|D, {0x026b}}},
- {0x2c63, {1|F|D, {0x1d7d}}},
- {0x2c64, {1|F|D, {0x027d}}},
- {0x2c67, {1|F|D, {0x2c68}}},
- {0x2c69, {1|F|D, {0x2c6a}}},
- {0x2c6b, {1|F|D, {0x2c6c}}},
- {0x2c6d, {1|F|D, {0x0251}}},
- {0x2c6e, {1|F|D, {0x0271}}},
- {0x2c6f, {1|F|D, {0x0250}}},
- {0x2c70, {1|F|D, {0x0252}}},
- {0x2c72, {1|F|D, {0x2c73}}},
- {0x2c75, {1|F|D, {0x2c76}}},
- {0x2c7e, {1|F|D, {0x023f}}},
- {0x2c7f, {1|F|D, {0x0240}}},
- {0x2c80, {1|F|D, {0x2c81}}},
- {0x2c82, {1|F|D, {0x2c83}}},
- {0x2c84, {1|F|D, {0x2c85}}},
- {0x2c86, {1|F|D, {0x2c87}}},
- {0x2c88, {1|F|D, {0x2c89}}},
- {0x2c8a, {1|F|D, {0x2c8b}}},
- {0x2c8c, {1|F|D, {0x2c8d}}},
- {0x2c8e, {1|F|D, {0x2c8f}}},
- {0x2c90, {1|F|D, {0x2c91}}},
- {0x2c92, {1|F|D, {0x2c93}}},
- {0x2c94, {1|F|D, {0x2c95}}},
- {0x2c96, {1|F|D, {0x2c97}}},
- {0x2c98, {1|F|D, {0x2c99}}},
- {0x2c9a, {1|F|D, {0x2c9b}}},
- {0x2c9c, {1|F|D, {0x2c9d}}},
- {0x2c9e, {1|F|D, {0x2c9f}}},
- {0x2ca0, {1|F|D, {0x2ca1}}},
- {0x2ca2, {1|F|D, {0x2ca3}}},
- {0x2ca4, {1|F|D, {0x2ca5}}},
- {0x2ca6, {1|F|D, {0x2ca7}}},
- {0x2ca8, {1|F|D, {0x2ca9}}},
- {0x2caa, {1|F|D, {0x2cab}}},
- {0x2cac, {1|F|D, {0x2cad}}},
- {0x2cae, {1|F|D, {0x2caf}}},
- {0x2cb0, {1|F|D, {0x2cb1}}},
- {0x2cb2, {1|F|D, {0x2cb3}}},
- {0x2cb4, {1|F|D, {0x2cb5}}},
- {0x2cb6, {1|F|D, {0x2cb7}}},
- {0x2cb8, {1|F|D, {0x2cb9}}},
- {0x2cba, {1|F|D, {0x2cbb}}},
- {0x2cbc, {1|F|D, {0x2cbd}}},
- {0x2cbe, {1|F|D, {0x2cbf}}},
- {0x2cc0, {1|F|D, {0x2cc1}}},
- {0x2cc2, {1|F|D, {0x2cc3}}},
- {0x2cc4, {1|F|D, {0x2cc5}}},
- {0x2cc6, {1|F|D, {0x2cc7}}},
- {0x2cc8, {1|F|D, {0x2cc9}}},
- {0x2cca, {1|F|D, {0x2ccb}}},
- {0x2ccc, {1|F|D, {0x2ccd}}},
- {0x2cce, {1|F|D, {0x2ccf}}},
- {0x2cd0, {1|F|D, {0x2cd1}}},
- {0x2cd2, {1|F|D, {0x2cd3}}},
- {0x2cd4, {1|F|D, {0x2cd5}}},
- {0x2cd6, {1|F|D, {0x2cd7}}},
- {0x2cd8, {1|F|D, {0x2cd9}}},
- {0x2cda, {1|F|D, {0x2cdb}}},
- {0x2cdc, {1|F|D, {0x2cdd}}},
- {0x2cde, {1|F|D, {0x2cdf}}},
- {0x2ce0, {1|F|D, {0x2ce1}}},
- {0x2ce2, {1|F|D, {0x2ce3}}},
- {0x2ceb, {1|F|D, {0x2cec}}},
- {0x2ced, {1|F|D, {0x2cee}}},
- {0x2cf2, {1|F|D, {0x2cf3}}},
- {0xa640, {1|F|D, {0xa641}}},
- {0xa642, {1|F|D, {0xa643}}},
- {0xa644, {1|F|D, {0xa645}}},
- {0xa646, {1|F|D, {0xa647}}},
- {0xa648, {1|F|D, {0xa649}}},
- {0xa64a, {1|F|D, {0xa64b}}},
- {0xa64c, {1|F|D, {0xa64d}}},
- {0xa64e, {1|F|D, {0xa64f}}},
- {0xa650, {1|F|D, {0xa651}}},
- {0xa652, {1|F|D, {0xa653}}},
- {0xa654, {1|F|D, {0xa655}}},
- {0xa656, {1|F|D, {0xa657}}},
- {0xa658, {1|F|D, {0xa659}}},
- {0xa65a, {1|F|D, {0xa65b}}},
- {0xa65c, {1|F|D, {0xa65d}}},
- {0xa65e, {1|F|D, {0xa65f}}},
- {0xa660, {1|F|D, {0xa661}}},
- {0xa662, {1|F|D, {0xa663}}},
- {0xa664, {1|F|D, {0xa665}}},
- {0xa666, {1|F|D, {0xa667}}},
- {0xa668, {1|F|D, {0xa669}}},
- {0xa66a, {1|F|D, {0xa66b}}},
- {0xa66c, {1|F|D, {0xa66d}}},
- {0xa680, {1|F|D, {0xa681}}},
- {0xa682, {1|F|D, {0xa683}}},
- {0xa684, {1|F|D, {0xa685}}},
- {0xa686, {1|F|D, {0xa687}}},
- {0xa688, {1|F|D, {0xa689}}},
- {0xa68a, {1|F|D, {0xa68b}}},
- {0xa68c, {1|F|D, {0xa68d}}},
- {0xa68e, {1|F|D, {0xa68f}}},
- {0xa690, {1|F|D, {0xa691}}},
- {0xa692, {1|F|D, {0xa693}}},
- {0xa694, {1|F|D, {0xa695}}},
- {0xa696, {1|F|D, {0xa697}}},
- {0xa698, {1|F|D, {0xa699}}},
- {0xa69a, {1|F|D, {0xa69b}}},
- {0xa722, {1|F|D, {0xa723}}},
- {0xa724, {1|F|D, {0xa725}}},
- {0xa726, {1|F|D, {0xa727}}},
- {0xa728, {1|F|D, {0xa729}}},
- {0xa72a, {1|F|D, {0xa72b}}},
- {0xa72c, {1|F|D, {0xa72d}}},
- {0xa72e, {1|F|D, {0xa72f}}},
- {0xa732, {1|F|D, {0xa733}}},
- {0xa734, {1|F|D, {0xa735}}},
- {0xa736, {1|F|D, {0xa737}}},
- {0xa738, {1|F|D, {0xa739}}},
- {0xa73a, {1|F|D, {0xa73b}}},
- {0xa73c, {1|F|D, {0xa73d}}},
- {0xa73e, {1|F|D, {0xa73f}}},
- {0xa740, {1|F|D, {0xa741}}},
- {0xa742, {1|F|D, {0xa743}}},
- {0xa744, {1|F|D, {0xa745}}},
- {0xa746, {1|F|D, {0xa747}}},
- {0xa748, {1|F|D, {0xa749}}},
- {0xa74a, {1|F|D, {0xa74b}}},
- {0xa74c, {1|F|D, {0xa74d}}},
- {0xa74e, {1|F|D, {0xa74f}}},
- {0xa750, {1|F|D, {0xa751}}},
- {0xa752, {1|F|D, {0xa753}}},
- {0xa754, {1|F|D, {0xa755}}},
- {0xa756, {1|F|D, {0xa757}}},
- {0xa758, {1|F|D, {0xa759}}},
- {0xa75a, {1|F|D, {0xa75b}}},
- {0xa75c, {1|F|D, {0xa75d}}},
- {0xa75e, {1|F|D, {0xa75f}}},
- {0xa760, {1|F|D, {0xa761}}},
- {0xa762, {1|F|D, {0xa763}}},
- {0xa764, {1|F|D, {0xa765}}},
- {0xa766, {1|F|D, {0xa767}}},
- {0xa768, {1|F|D, {0xa769}}},
- {0xa76a, {1|F|D, {0xa76b}}},
- {0xa76c, {1|F|D, {0xa76d}}},
- {0xa76e, {1|F|D, {0xa76f}}},
- {0xa779, {1|F|D, {0xa77a}}},
- {0xa77b, {1|F|D, {0xa77c}}},
- {0xa77d, {1|F|D, {0x1d79}}},
- {0xa77e, {1|F|D, {0xa77f}}},
- {0xa780, {1|F|D, {0xa781}}},
- {0xa782, {1|F|D, {0xa783}}},
- {0xa784, {1|F|D, {0xa785}}},
- {0xa786, {1|F|D, {0xa787}}},
- {0xa78b, {1|F|D, {0xa78c}}},
- {0xa78d, {1|F|D, {0x0265}}},
- {0xa790, {1|F|D, {0xa791}}},
- {0xa792, {1|F|D, {0xa793}}},
- {0xa796, {1|F|D, {0xa797}}},
- {0xa798, {1|F|D, {0xa799}}},
- {0xa79a, {1|F|D, {0xa79b}}},
- {0xa79c, {1|F|D, {0xa79d}}},
- {0xa79e, {1|F|D, {0xa79f}}},
- {0xa7a0, {1|F|D, {0xa7a1}}},
- {0xa7a2, {1|F|D, {0xa7a3}}},
- {0xa7a4, {1|F|D, {0xa7a5}}},
- {0xa7a6, {1|F|D, {0xa7a7}}},
- {0xa7a8, {1|F|D, {0xa7a9}}},
- {0xa7aa, {1|F|D, {0x0266}}},
- {0xa7ab, {1|F|D, {0x025c}}},
- {0xa7ac, {1|F|D, {0x0261}}},
- {0xa7ad, {1|F|D, {0x026c}}},
- {0xa7ae, {1|F|D, {0x026a}}},
- {0xa7b0, {1|F|D, {0x029e}}},
- {0xa7b1, {1|F|D, {0x0287}}},
- {0xa7b2, {1|F|D, {0x029d}}},
- {0xa7b3, {1|F|D, {0xab53}}},
- {0xa7b4, {1|F|D, {0xa7b5}}},
- {0xa7b6, {1|F|D, {0xa7b7}}},
- {0xa7b8, {1|F|D, {0xa7b9}}},
- {0xa7ba, {1|F|D, {0xa7bb}}},
- {0xa7bc, {1|F|D, {0xa7bd}}},
- {0xa7be, {1|F|D, {0xa7bf}}},
- {0xa7c2, {1|F|D, {0xa7c3}}},
- {0xa7c4, {1|F|D, {0xa794}}},
- {0xa7c5, {1|F|D, {0x0282}}},
- {0xa7c6, {1|F|D, {0x1d8e}}},
- {0xab70, {1|F|U, {0x13a0}}},
- {0xab71, {1|F|U, {0x13a1}}},
- {0xab72, {1|F|U, {0x13a2}}},
- {0xab73, {1|F|U, {0x13a3}}},
- {0xab74, {1|F|U, {0x13a4}}},
- {0xab75, {1|F|U, {0x13a5}}},
- {0xab76, {1|F|U, {0x13a6}}},
- {0xab77, {1|F|U, {0x13a7}}},
- {0xab78, {1|F|U, {0x13a8}}},
- {0xab79, {1|F|U, {0x13a9}}},
- {0xab7a, {1|F|U, {0x13aa}}},
- {0xab7b, {1|F|U, {0x13ab}}},
- {0xab7c, {1|F|U, {0x13ac}}},
- {0xab7d, {1|F|U, {0x13ad}}},
- {0xab7e, {1|F|U, {0x13ae}}},
- {0xab7f, {1|F|U, {0x13af}}},
- {0xab80, {1|F|U, {0x13b0}}},
- {0xab81, {1|F|U, {0x13b1}}},
- {0xab82, {1|F|U, {0x13b2}}},
- {0xab83, {1|F|U, {0x13b3}}},
- {0xab84, {1|F|U, {0x13b4}}},
- {0xab85, {1|F|U, {0x13b5}}},
- {0xab86, {1|F|U, {0x13b6}}},
- {0xab87, {1|F|U, {0x13b7}}},
- {0xab88, {1|F|U, {0x13b8}}},
- {0xab89, {1|F|U, {0x13b9}}},
- {0xab8a, {1|F|U, {0x13ba}}},
- {0xab8b, {1|F|U, {0x13bb}}},
- {0xab8c, {1|F|U, {0x13bc}}},
- {0xab8d, {1|F|U, {0x13bd}}},
- {0xab8e, {1|F|U, {0x13be}}},
- {0xab8f, {1|F|U, {0x13bf}}},
- {0xab90, {1|F|U, {0x13c0}}},
- {0xab91, {1|F|U, {0x13c1}}},
- {0xab92, {1|F|U, {0x13c2}}},
- {0xab93, {1|F|U, {0x13c3}}},
- {0xab94, {1|F|U, {0x13c4}}},
- {0xab95, {1|F|U, {0x13c5}}},
- {0xab96, {1|F|U, {0x13c6}}},
- {0xab97, {1|F|U, {0x13c7}}},
- {0xab98, {1|F|U, {0x13c8}}},
- {0xab99, {1|F|U, {0x13c9}}},
- {0xab9a, {1|F|U, {0x13ca}}},
- {0xab9b, {1|F|U, {0x13cb}}},
- {0xab9c, {1|F|U, {0x13cc}}},
- {0xab9d, {1|F|U, {0x13cd}}},
- {0xab9e, {1|F|U, {0x13ce}}},
- {0xab9f, {1|F|U, {0x13cf}}},
- {0xaba0, {1|F|U, {0x13d0}}},
- {0xaba1, {1|F|U, {0x13d1}}},
- {0xaba2, {1|F|U, {0x13d2}}},
- {0xaba3, {1|F|U, {0x13d3}}},
- {0xaba4, {1|F|U, {0x13d4}}},
- {0xaba5, {1|F|U, {0x13d5}}},
- {0xaba6, {1|F|U, {0x13d6}}},
- {0xaba7, {1|F|U, {0x13d7}}},
- {0xaba8, {1|F|U, {0x13d8}}},
- {0xaba9, {1|F|U, {0x13d9}}},
- {0xabaa, {1|F|U, {0x13da}}},
- {0xabab, {1|F|U, {0x13db}}},
- {0xabac, {1|F|U, {0x13dc}}},
- {0xabad, {1|F|U, {0x13dd}}},
- {0xabae, {1|F|U, {0x13de}}},
- {0xabaf, {1|F|U, {0x13df}}},
- {0xabb0, {1|F|U, {0x13e0}}},
- {0xabb1, {1|F|U, {0x13e1}}},
- {0xabb2, {1|F|U, {0x13e2}}},
- {0xabb3, {1|F|U, {0x13e3}}},
- {0xabb4, {1|F|U, {0x13e4}}},
- {0xabb5, {1|F|U, {0x13e5}}},
- {0xabb6, {1|F|U, {0x13e6}}},
- {0xabb7, {1|F|U, {0x13e7}}},
- {0xabb8, {1|F|U, {0x13e8}}},
- {0xabb9, {1|F|U, {0x13e9}}},
- {0xabba, {1|F|U, {0x13ea}}},
- {0xabbb, {1|F|U, {0x13eb}}},
- {0xabbc, {1|F|U, {0x13ec}}},
- {0xabbd, {1|F|U, {0x13ed}}},
- {0xabbe, {1|F|U, {0x13ee}}},
- {0xabbf, {1|F|U, {0x13ef}}},
- {0xfb00, {2|F|ST|SU|I(366), {0x0066, 0x0066}}},
- {0xfb01, {2|F|ST|SU|I(370), {0x0066, 0x0069}}},
- {0xfb02, {2|F|ST|SU|I(374), {0x0066, 0x006c}}},
- {0xfb03, {3|F|ST|SU|I(378), {0x0066, 0x0066, 0x0069}}},
- {0xfb04, {3|F|ST|SU|I(384), {0x0066, 0x0066, 0x006c}}},
- {0xfb05, {2|F|ST|SU|I(390), {0x0073, 0x0074}}},
- {0xfb06, {2|F|ST|SU|I(394), {0x0073, 0x0074}}},
- {0xfb13, {2|F|ST|SU|I(398), {0x0574, 0x0576}}},
- {0xfb14, {2|F|ST|SU|I(402), {0x0574, 0x0565}}},
- {0xfb15, {2|F|ST|SU|I(406), {0x0574, 0x056b}}},
- {0xfb16, {2|F|ST|SU|I(410), {0x057e, 0x0576}}},
- {0xfb17, {2|F|ST|SU|I(414), {0x0574, 0x056d}}},
- {0xff21, {1|F|D, {0xff41}}},
- {0xff22, {1|F|D, {0xff42}}},
- {0xff23, {1|F|D, {0xff43}}},
- {0xff24, {1|F|D, {0xff44}}},
- {0xff25, {1|F|D, {0xff45}}},
- {0xff26, {1|F|D, {0xff46}}},
- {0xff27, {1|F|D, {0xff47}}},
- {0xff28, {1|F|D, {0xff48}}},
- {0xff29, {1|F|D, {0xff49}}},
- {0xff2a, {1|F|D, {0xff4a}}},
- {0xff2b, {1|F|D, {0xff4b}}},
- {0xff2c, {1|F|D, {0xff4c}}},
- {0xff2d, {1|F|D, {0xff4d}}},
- {0xff2e, {1|F|D, {0xff4e}}},
- {0xff2f, {1|F|D, {0xff4f}}},
- {0xff30, {1|F|D, {0xff50}}},
- {0xff31, {1|F|D, {0xff51}}},
- {0xff32, {1|F|D, {0xff52}}},
- {0xff33, {1|F|D, {0xff53}}},
- {0xff34, {1|F|D, {0xff54}}},
- {0xff35, {1|F|D, {0xff55}}},
- {0xff36, {1|F|D, {0xff56}}},
- {0xff37, {1|F|D, {0xff57}}},
- {0xff38, {1|F|D, {0xff58}}},
- {0xff39, {1|F|D, {0xff59}}},
- {0xff3a, {1|F|D, {0xff5a}}},
- {0x10400, {1|F|D, {0x10428}}},
- {0x10401, {1|F|D, {0x10429}}},
- {0x10402, {1|F|D, {0x1042a}}},
- {0x10403, {1|F|D, {0x1042b}}},
- {0x10404, {1|F|D, {0x1042c}}},
- {0x10405, {1|F|D, {0x1042d}}},
- {0x10406, {1|F|D, {0x1042e}}},
- {0x10407, {1|F|D, {0x1042f}}},
- {0x10408, {1|F|D, {0x10430}}},
- {0x10409, {1|F|D, {0x10431}}},
- {0x1040a, {1|F|D, {0x10432}}},
- {0x1040b, {1|F|D, {0x10433}}},
- {0x1040c, {1|F|D, {0x10434}}},
- {0x1040d, {1|F|D, {0x10435}}},
- {0x1040e, {1|F|D, {0x10436}}},
- {0x1040f, {1|F|D, {0x10437}}},
- {0x10410, {1|F|D, {0x10438}}},
- {0x10411, {1|F|D, {0x10439}}},
- {0x10412, {1|F|D, {0x1043a}}},
- {0x10413, {1|F|D, {0x1043b}}},
- {0x10414, {1|F|D, {0x1043c}}},
- {0x10415, {1|F|D, {0x1043d}}},
- {0x10416, {1|F|D, {0x1043e}}},
- {0x10417, {1|F|D, {0x1043f}}},
- {0x10418, {1|F|D, {0x10440}}},
- {0x10419, {1|F|D, {0x10441}}},
- {0x1041a, {1|F|D, {0x10442}}},
- {0x1041b, {1|F|D, {0x10443}}},
- {0x1041c, {1|F|D, {0x10444}}},
- {0x1041d, {1|F|D, {0x10445}}},
- {0x1041e, {1|F|D, {0x10446}}},
- {0x1041f, {1|F|D, {0x10447}}},
- {0x10420, {1|F|D, {0x10448}}},
- {0x10421, {1|F|D, {0x10449}}},
- {0x10422, {1|F|D, {0x1044a}}},
- {0x10423, {1|F|D, {0x1044b}}},
- {0x10424, {1|F|D, {0x1044c}}},
- {0x10425, {1|F|D, {0x1044d}}},
- {0x10426, {1|F|D, {0x1044e}}},
- {0x10427, {1|F|D, {0x1044f}}},
- {0x104b0, {1|F|D, {0x104d8}}},
- {0x104b1, {1|F|D, {0x104d9}}},
- {0x104b2, {1|F|D, {0x104da}}},
- {0x104b3, {1|F|D, {0x104db}}},
- {0x104b4, {1|F|D, {0x104dc}}},
- {0x104b5, {1|F|D, {0x104dd}}},
- {0x104b6, {1|F|D, {0x104de}}},
- {0x104b7, {1|F|D, {0x104df}}},
- {0x104b8, {1|F|D, {0x104e0}}},
- {0x104b9, {1|F|D, {0x104e1}}},
- {0x104ba, {1|F|D, {0x104e2}}},
- {0x104bb, {1|F|D, {0x104e3}}},
- {0x104bc, {1|F|D, {0x104e4}}},
- {0x104bd, {1|F|D, {0x104e5}}},
- {0x104be, {1|F|D, {0x104e6}}},
- {0x104bf, {1|F|D, {0x104e7}}},
- {0x104c0, {1|F|D, {0x104e8}}},
- {0x104c1, {1|F|D, {0x104e9}}},
- {0x104c2, {1|F|D, {0x104ea}}},
- {0x104c3, {1|F|D, {0x104eb}}},
- {0x104c4, {1|F|D, {0x104ec}}},
- {0x104c5, {1|F|D, {0x104ed}}},
- {0x104c6, {1|F|D, {0x104ee}}},
- {0x104c7, {1|F|D, {0x104ef}}},
- {0x104c8, {1|F|D, {0x104f0}}},
- {0x104c9, {1|F|D, {0x104f1}}},
- {0x104ca, {1|F|D, {0x104f2}}},
- {0x104cb, {1|F|D, {0x104f3}}},
- {0x104cc, {1|F|D, {0x104f4}}},
- {0x104cd, {1|F|D, {0x104f5}}},
- {0x104ce, {1|F|D, {0x104f6}}},
- {0x104cf, {1|F|D, {0x104f7}}},
- {0x104d0, {1|F|D, {0x104f8}}},
- {0x104d1, {1|F|D, {0x104f9}}},
- {0x104d2, {1|F|D, {0x104fa}}},
- {0x104d3, {1|F|D, {0x104fb}}},
- {0x10c80, {1|F|D, {0x10cc0}}},
- {0x10c81, {1|F|D, {0x10cc1}}},
- {0x10c82, {1|F|D, {0x10cc2}}},
- {0x10c83, {1|F|D, {0x10cc3}}},
- {0x10c84, {1|F|D, {0x10cc4}}},
- {0x10c85, {1|F|D, {0x10cc5}}},
- {0x10c86, {1|F|D, {0x10cc6}}},
- {0x10c87, {1|F|D, {0x10cc7}}},
- {0x10c88, {1|F|D, {0x10cc8}}},
- {0x10c89, {1|F|D, {0x10cc9}}},
- {0x10c8a, {1|F|D, {0x10cca}}},
- {0x10c8b, {1|F|D, {0x10ccb}}},
- {0x10c8c, {1|F|D, {0x10ccc}}},
- {0x10c8d, {1|F|D, {0x10ccd}}},
- {0x10c8e, {1|F|D, {0x10cce}}},
- {0x10c8f, {1|F|D, {0x10ccf}}},
- {0x10c90, {1|F|D, {0x10cd0}}},
- {0x10c91, {1|F|D, {0x10cd1}}},
- {0x10c92, {1|F|D, {0x10cd2}}},
- {0x10c93, {1|F|D, {0x10cd3}}},
- {0x10c94, {1|F|D, {0x10cd4}}},
- {0x10c95, {1|F|D, {0x10cd5}}},
- {0x10c96, {1|F|D, {0x10cd6}}},
- {0x10c97, {1|F|D, {0x10cd7}}},
- {0x10c98, {1|F|D, {0x10cd8}}},
- {0x10c99, {1|F|D, {0x10cd9}}},
- {0x10c9a, {1|F|D, {0x10cda}}},
- {0x10c9b, {1|F|D, {0x10cdb}}},
- {0x10c9c, {1|F|D, {0x10cdc}}},
- {0x10c9d, {1|F|D, {0x10cdd}}},
- {0x10c9e, {1|F|D, {0x10cde}}},
- {0x10c9f, {1|F|D, {0x10cdf}}},
- {0x10ca0, {1|F|D, {0x10ce0}}},
- {0x10ca1, {1|F|D, {0x10ce1}}},
- {0x10ca2, {1|F|D, {0x10ce2}}},
- {0x10ca3, {1|F|D, {0x10ce3}}},
- {0x10ca4, {1|F|D, {0x10ce4}}},
- {0x10ca5, {1|F|D, {0x10ce5}}},
- {0x10ca6, {1|F|D, {0x10ce6}}},
- {0x10ca7, {1|F|D, {0x10ce7}}},
- {0x10ca8, {1|F|D, {0x10ce8}}},
- {0x10ca9, {1|F|D, {0x10ce9}}},
- {0x10caa, {1|F|D, {0x10cea}}},
- {0x10cab, {1|F|D, {0x10ceb}}},
- {0x10cac, {1|F|D, {0x10cec}}},
- {0x10cad, {1|F|D, {0x10ced}}},
- {0x10cae, {1|F|D, {0x10cee}}},
- {0x10caf, {1|F|D, {0x10cef}}},
- {0x10cb0, {1|F|D, {0x10cf0}}},
- {0x10cb1, {1|F|D, {0x10cf1}}},
- {0x10cb2, {1|F|D, {0x10cf2}}},
- {0x118a0, {1|F|D, {0x118c0}}},
- {0x118a1, {1|F|D, {0x118c1}}},
- {0x118a2, {1|F|D, {0x118c2}}},
- {0x118a3, {1|F|D, {0x118c3}}},
- {0x118a4, {1|F|D, {0x118c4}}},
- {0x118a5, {1|F|D, {0x118c5}}},
- {0x118a6, {1|F|D, {0x118c6}}},
- {0x118a7, {1|F|D, {0x118c7}}},
- {0x118a8, {1|F|D, {0x118c8}}},
- {0x118a9, {1|F|D, {0x118c9}}},
- {0x118aa, {1|F|D, {0x118ca}}},
- {0x118ab, {1|F|D, {0x118cb}}},
- {0x118ac, {1|F|D, {0x118cc}}},
- {0x118ad, {1|F|D, {0x118cd}}},
- {0x118ae, {1|F|D, {0x118ce}}},
- {0x118af, {1|F|D, {0x118cf}}},
- {0x118b0, {1|F|D, {0x118d0}}},
- {0x118b1, {1|F|D, {0x118d1}}},
- {0x118b2, {1|F|D, {0x118d2}}},
- {0x118b3, {1|F|D, {0x118d3}}},
- {0x118b4, {1|F|D, {0x118d4}}},
- {0x118b5, {1|F|D, {0x118d5}}},
- {0x118b6, {1|F|D, {0x118d6}}},
- {0x118b7, {1|F|D, {0x118d7}}},
- {0x118b8, {1|F|D, {0x118d8}}},
- {0x118b9, {1|F|D, {0x118d9}}},
- {0x118ba, {1|F|D, {0x118da}}},
- {0x118bb, {1|F|D, {0x118db}}},
- {0x118bc, {1|F|D, {0x118dc}}},
- {0x118bd, {1|F|D, {0x118dd}}},
- {0x118be, {1|F|D, {0x118de}}},
- {0x118bf, {1|F|D, {0x118df}}},
- {0x16e40, {1|F|D, {0x16e60}}},
- {0x16e41, {1|F|D, {0x16e61}}},
- {0x16e42, {1|F|D, {0x16e62}}},
- {0x16e43, {1|F|D, {0x16e63}}},
- {0x16e44, {1|F|D, {0x16e64}}},
- {0x16e45, {1|F|D, {0x16e65}}},
- {0x16e46, {1|F|D, {0x16e66}}},
- {0x16e47, {1|F|D, {0x16e67}}},
- {0x16e48, {1|F|D, {0x16e68}}},
- {0x16e49, {1|F|D, {0x16e69}}},
- {0x16e4a, {1|F|D, {0x16e6a}}},
- {0x16e4b, {1|F|D, {0x16e6b}}},
- {0x16e4c, {1|F|D, {0x16e6c}}},
- {0x16e4d, {1|F|D, {0x16e6d}}},
- {0x16e4e, {1|F|D, {0x16e6e}}},
- {0x16e4f, {1|F|D, {0x16e6f}}},
- {0x16e50, {1|F|D, {0x16e70}}},
- {0x16e51, {1|F|D, {0x16e71}}},
- {0x16e52, {1|F|D, {0x16e72}}},
- {0x16e53, {1|F|D, {0x16e73}}},
- {0x16e54, {1|F|D, {0x16e74}}},
- {0x16e55, {1|F|D, {0x16e75}}},
- {0x16e56, {1|F|D, {0x16e76}}},
- {0x16e57, {1|F|D, {0x16e77}}},
- {0x16e58, {1|F|D, {0x16e78}}},
- {0x16e59, {1|F|D, {0x16e79}}},
- {0x16e5a, {1|F|D, {0x16e7a}}},
- {0x16e5b, {1|F|D, {0x16e7b}}},
- {0x16e5c, {1|F|D, {0x16e7c}}},
- {0x16e5d, {1|F|D, {0x16e7d}}},
- {0x16e5e, {1|F|D, {0x16e7e}}},
- {0x16e5f, {1|F|D, {0x16e7f}}},
- {0x1e900, {1|F|D, {0x1e922}}},
- {0x1e901, {1|F|D, {0x1e923}}},
- {0x1e902, {1|F|D, {0x1e924}}},
- {0x1e903, {1|F|D, {0x1e925}}},
- {0x1e904, {1|F|D, {0x1e926}}},
- {0x1e905, {1|F|D, {0x1e927}}},
- {0x1e906, {1|F|D, {0x1e928}}},
- {0x1e907, {1|F|D, {0x1e929}}},
- {0x1e908, {1|F|D, {0x1e92a}}},
- {0x1e909, {1|F|D, {0x1e92b}}},
- {0x1e90a, {1|F|D, {0x1e92c}}},
- {0x1e90b, {1|F|D, {0x1e92d}}},
- {0x1e90c, {1|F|D, {0x1e92e}}},
- {0x1e90d, {1|F|D, {0x1e92f}}},
- {0x1e90e, {1|F|D, {0x1e930}}},
- {0x1e90f, {1|F|D, {0x1e931}}},
- {0x1e910, {1|F|D, {0x1e932}}},
- {0x1e911, {1|F|D, {0x1e933}}},
- {0x1e912, {1|F|D, {0x1e934}}},
- {0x1e913, {1|F|D, {0x1e935}}},
- {0x1e914, {1|F|D, {0x1e936}}},
- {0x1e915, {1|F|D, {0x1e937}}},
- {0x1e916, {1|F|D, {0x1e938}}},
- {0x1e917, {1|F|D, {0x1e939}}},
- {0x1e918, {1|F|D, {0x1e93a}}},
- {0x1e919, {1|F|D, {0x1e93b}}},
- {0x1e91a, {1|F|D, {0x1e93c}}},
- {0x1e91b, {1|F|D, {0x1e93d}}},
- {0x1e91c, {1|F|D, {0x1e93e}}},
- {0x1e91d, {1|F|D, {0x1e93f}}},
- {0x1e91e, {1|F|D, {0x1e940}}},
- {0x1e91f, {1|F|D, {0x1e941}}},
- {0x1e920, {1|F|D, {0x1e942}}},
- {0x1e921, {1|F|D, {0x1e943}}},
-#define CaseFold_Locale (*(CaseFold_11_Type (*)[2])(CaseFold_11_Table+1485))
- {0x0049, {1|F|D, {0x0069}}},
- {0x0130, {2|F|D, {0x0069, 0x0307}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseFold_11_hash -N onigenc_unicode_CaseFold_11_lookup -n */
-
-/* maximum key range = 3500, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseFold_11_hash(const OnigCodePoint code)
-{
- static const unsigned short asso_values[] =
- {
- 5, 273, 4, 8, 3, 1, 86, 9, 2, 289,
- 290, 3, 3510, 3510, 3510, 3510, 3510, 3510, 3510, 3510,
- 3510, 3510, 3510, 3510, 3510, 50, 3510, 3510, 3510, 3510,
- 3510, 3510, 3510, 225, 3510, 3510, 3510, 3510, 3510, 28,
- 3510, 3510, 3510, 3510, 3510, 3510, 3510, 3510, 3510, 394,
- 3510, 3510, 3510, 3510, 3510, 3510, 3510, 47, 3510, 3510,
- 255, 40, 286, 1, 3510, 3510, 599, 8, 3510, 3510,
- 3510, 3510, 3510, 282, 3510, 3510, 267, 667, 473, 39,
- 2019, 189, 47, 175, 2001, 107, 1626, 6, 12, 25,
- 1961, 678, 1128, 526, 1945, 148, 1923, 371, 1720, 134,
- 1857, 80, 1375, 66, 1705, 300, 1635, 445, 1611, 472,
- 1795, 216, 1303, 499, 1552, 270, 1511, 243, 121, 619,
- 1284, 540, 875, 592, 1484, 567, 412, 703, 1692, 387,
- 1782, 781, 1767, 664, 1718, 648, 1316, 608, 1647, 715,
- 1592, 771, 1544, 1029, 1563, 887, 1296, 861, 1194, 978,
- 95, 899, 1257, 835, 1335, 765, 1529, 984, 862, 938,
- 1460, 759, 329, 1079, 1159, 940, 234, 1101, 1204, 990,
- 949, 1493, 92, 1438, 77, 1391, 7, 1073, 44, 1377,
- 2, 1435, 4, 1321, 428, 1274, 332, 1206, 11, 1426,
- 46, 478, 200, 1502, 31, 1400, 153, 1663, 352, 1820,
- 229, 1733, 265, 1405, 315, 1879, 198
- };
- return asso_values[bits_of(code, 2)+79] + asso_values[bits_of(code, 1)] + asso_values[bits_of(code, 0)];
-}
-
-static const CodePointList3 *
-onigenc_unicode_CaseFold_11_lookup(const OnigCodePoint code)
-{
- enum
- {
- MIN_CODE_VALUE = 0x41,
- MAX_CODE_VALUE = 0x1e921,
- TOTAL_KEYWORDS = 1487,
- MIN_WORD_LENGTH = 3,
- MAX_WORD_LENGTH = 3,
- MIN_HASH_VALUE = 10,
- MAX_HASH_VALUE = 3509
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x1fe7*/ 848,
- /*0x10408*/ 1268,
- /*0x1f88*/ 775,
- /*0x0408*/ 305,
- /*0x0208*/ 194,
- /*0x0108*/ 61,
- /*0xab88*/ 1166,
- /*0x10409*/ 1269,
- /*0x1f89*/ 776,
- /*0x0409*/ 306,
- /*0x0388*/ 235,
- /*0x2c67*/ 962,
- /*0xab89*/ 1167,
- /*0x2c08*/ 919,
- -1,
- /*0x0189*/ 126,
- /*0x0389*/ 236,
- -1,
- /*0x2c6d*/ 965,
- /*0x2c09*/ 920,
- /*0x1040a*/ 1270,
- /*0x1f8a*/ 777,
- /*0x040a*/ 307,
- /*0x020a*/ 195,
- /*0x010a*/ 62,
- /*0xab8a*/ 1168,
- /*0x2c88*/ 977,
- /*0x1ff3*/ 855,
- /*0x018a*/ 127,
- /*0x038a*/ 237,
- -1,
- /*0x2ced*/ 1024,
- /*0x2c0a*/ 921,
- -1,
- /*0x10400*/ 1260,
- /*0x1f80*/ 767,
- /*0x0400*/ 297,
- /*0x0200*/ 190,
- /*0x0100*/ 57,
- /*0xab80*/ 1158,
- /*0x1fe3*/ 845,
- /*0x1e88*/ 653,
- /*0x10403*/ 1263,
- /*0x1f83*/ 770,
- /*0x0403*/ 300,
- /*0x2c8a*/ 978,
- /*0x2c00*/ 911,
- /*0xab83*/ 1161,
- /*0x1c88*/ 538,
- /*0x10c88*/ 1344,
- /*0x2183*/ 884,
- /*0x2c63*/ 960,
- /*0x1e908*/ 1459,
- /*0x2c6f*/ 967,
- /*0x2c03*/ 914,
- /*0x10c89*/ 1345,
- -1, -1,
- /*0x1e909*/ 1460,
- /*0x2c80*/ 973,
- /*0x1e8a*/ 654,
- /*0x10418*/ 1284,
- /*0x1f98*/ 791,
- /*0x0418*/ 321,
- /*0x0218*/ 202,
- /*0x0118*/ 69,
- /*0xab98*/ 1182,
- -1,
- /*0x10c8a*/ 1346,
- /*0x0198*/ 137,
- /*0x0398*/ 249,
- /*0x1e90a*/ 1461,
- /*0xa780*/ 1105,
- /*0x2c18*/ 935,
- /*0x1e80*/ 649,
- /*0x10416*/ 1282,
- /*0x1f96*/ 789,
- /*0x0416*/ 319,
- /*0x0216*/ 201,
- /*0x0116*/ 68,
- /*0xab96*/ 1180,
- /*0x1c80*/ 530,
- /*0x10c80*/ 1336,
- /*0x0196*/ 135,
- /*0x0396*/ 247,
- /*0x1e900*/ 1451,
- /*0x2c98*/ 985,
- /*0x2c16*/ 933,
- -1,
- /*0x1c83*/ 533,
- /*0x10c83*/ 1339,
- /*0x1fc7*/ 830,
- -1,
- /*0x1e903*/ 1454,
- /*0x0147*/ 91,
- /*0x0047*/ 6,
- -1, -1,
- /*0x01c7*/ 159,
- /*0xa798*/ 1114,
- /*0x2c96*/ 984,
- /*0x1e98*/ 662,
- /*0x10406*/ 1266,
- /*0x1f86*/ 773,
- /*0x0406*/ 303,
- /*0x0206*/ 193,
- /*0x0106*/ 60,
- /*0xab86*/ 1164,
- /*0x1c98*/ 547,
- /*0x10c98*/ 1360,
- /*0x0186*/ 124,
- /*0x0386*/ 234,
- /*0x1e918*/ 1475,
- /*0xa796*/ 1113,
- /*0x2c06*/ 917,
- /*0x1e96*/ 660,
- /*0x10427*/ 1299,
- /*0x1fa7*/ 806,
- /*0x0427*/ 336,
- -1, -1,
- /*0xaba7*/ 1197,
- /*0x1c96*/ 545,
- /*0x10c96*/ 1358,
- /*0x01a7*/ 145,
- /*0x03a7*/ 263,
- /*0x1e916*/ 1473,
- /*0x2c86*/ 976,
- /*0x2c27*/ 950,
- /*0x10414*/ 1280,
- /*0x1f94*/ 787,
- /*0x0414*/ 317,
- /*0x0214*/ 200,
- /*0x0114*/ 67,
- /*0xab94*/ 1178,
- -1, -1,
- /*0x0194*/ 134,
- /*0x0394*/ 245,
- -1,
- /*0xa786*/ 1108,
- /*0x2c14*/ 931,
- /*0x1e86*/ 652,
- /*0x10410*/ 1276,
- /*0x1f90*/ 783,
- /*0x0410*/ 313,
- /*0x0210*/ 198,
- /*0x0110*/ 65,
- /*0xab90*/ 1174,
- /*0x1c86*/ 536,
- /*0x10c86*/ 1342,
- /*0x0190*/ 131,
- /*0x0390*/ 241,
- /*0x1e906*/ 1457,
- /*0x2c94*/ 983,
- /*0x2c10*/ 927,
- -1,
- /*0x03f5*/ 290,
- /*0xfb00*/ 1222,
- -1,
- /*0x2c75*/ 970,
- -1, -1,
- /*0x1ca7*/ 562,
- /*0x10ca7*/ 1375,
- -1,
- /*0xfb03*/ 1225,
- -1,
- /*0x2c90*/ 981,
- /*0x1e94*/ 659,
- /*0x10404*/ 1264,
- /*0x1f84*/ 771,
- /*0x0404*/ 301,
- /*0x0204*/ 192,
- /*0x0104*/ 59,
- /*0xab84*/ 1162,
- /*0x1c94*/ 543,
- /*0x10c94*/ 1356,
- /*0x0184*/ 123,
- -1,
- /*0x1e914*/ 1471,
- /*0xa790*/ 1111,
- /*0x2c04*/ 915,
- /*0x1e90*/ 657,
- /*0x10402*/ 1262,
- /*0x1f82*/ 769,
- /*0x0402*/ 299,
- /*0x0202*/ 191,
- /*0x0102*/ 58,
- /*0xab82*/ 1160,
- /*0x1c90*/ 539,
- /*0x10c90*/ 1352,
- /*0x0182*/ 122,
- -1,
- /*0x1e910*/ 1467,
- /*0x2c84*/ 975,
- /*0x2c02*/ 913,
- /*0x017f*/ 120,
- -1,
- /*0xfb16*/ 1232,
- -1, -1,
- /*0x03ff*/ 296,
- /*0x01f1*/ 181,
- /*0x03f1*/ 288,
- /*0x2c7f*/ 972,
- -1, -1,
- /*0xa784*/ 1107,
- /*0x2c82*/ 974,
- /*0x1e84*/ 651,
- /*0x10420*/ 1292,
- /*0x1fa0*/ 799,
- /*0x0420*/ 329,
- /*0x0220*/ 206,
- /*0x0120*/ 73,
- /*0xaba0*/ 1190,
- /*0x1c84*/ 534,
- /*0x10c84*/ 1340,
- /*0x01a0*/ 141,
- /*0x03a0*/ 257,
- /*0x1e904*/ 1455,
- /*0xa782*/ 1106,
- /*0x2c20*/ 943,
- /*0x1e82*/ 650,
- /*0x1ff9*/ 860,
- /*0xfb06*/ 1228,
- -1,
- /*0x0179*/ 117,
- -1,
- /*0x1fd7*/ 839,
- /*0x1c82*/ 532,
- /*0x10c82*/ 1338,
- /*0x03f9*/ 292,
- /*0x0057*/ 21,
- /*0x1e902*/ 1453,
- /*0x2ca0*/ 989,
- /*0x01d7*/ 168,
- /*0x10426*/ 1298,
- /*0x1fa6*/ 805,
- /*0x0426*/ 335,
- /*0x0226*/ 209,
- /*0x0126*/ 76,
- /*0xaba6*/ 1196,
- -1, -1,
- /*0x01a6*/ 144,
- /*0x03a6*/ 262,
- -1,
- /*0xa7a0*/ 1118,
- /*0x2c26*/ 949,
- /*0x1ea0*/ 667,
- /*0x13f9*/ 525,
- /*0xfb14*/ 1230,
- -1, -1,
- /*0x1e08*/ 589,
- -1,
- /*0x1ca0*/ 555,
- /*0x10ca0*/ 1368,
- -1,
- /*0x1ffb*/ 862,
- /*0x1e920*/ 1483,
- /*0x2ca6*/ 992,
- /*0x017b*/ 118,
- /*0x10424*/ 1296,
- /*0x1fa4*/ 803,
- /*0x0424*/ 333,
- /*0x0224*/ 208,
- /*0x0124*/ 75,
- /*0xaba4*/ 1194,
- -1, -1,
- /*0x01a4*/ 143,
- /*0x03a4*/ 260,
- /*0x1e0a*/ 590,
- /*0xa7a6*/ 1121,
- /*0x2c24*/ 947,
- /*0x1ea6*/ 670,
- /*0x037f*/ 233,
- -1, -1, -1, -1, -1,
- /*0x1ca6*/ 561,
- /*0x10ca6*/ 1374,
- /*0x1f08*/ 715,
- /*0x13fb*/ 527,
- /*0x1e00*/ 585,
- /*0x2ca4*/ 991,
- /*0x0508*/ 425,
- /*0x1f6d*/ 764,
- /*0x1f09*/ 716,
- /*0xfb04*/ 1226,
- /*0x1041a*/ 1286,
- /*0x1f9a*/ 793,
- /*0x041a*/ 323,
- /*0x021a*/ 203,
- /*0x011a*/ 70,
- /*0xab9a*/ 1184,
- -1, -1,
- /*0xa7a4*/ 1120,
- /*0x039a*/ 251,
- /*0x1ea4*/ 669,
- /*0x1f0a*/ 717,
- /*0x2c1a*/ 937,
- /*0xfb02*/ 1224,
- /*0x048a*/ 362,
- /*0x050a*/ 426,
- -1,
- /*0x1ca4*/ 559,
- /*0x10ca4*/ 1372,
- /*0x017d*/ 119,
- /*0x10c7*/ 522,
- /*0x1e18*/ 597,
- -1, -1,
- /*0x03fd*/ 294,
- /*0x2c9a*/ 986,
- -1, -1,
- /*0x0480*/ 361,
- /*0x0500*/ 421,
- /*0x1fd3*/ 837,
- -1,
- /*0x1f6f*/ 766,
- /*0x1feb*/ 852,
- /*0x0053*/ 17,
- /*0x1e16*/ 596,
- -1,
- /*0x01d3*/ 166,
- /*0xa79a*/ 1115,
- -1,
- /*0x1e9a*/ 664,
- -1, -1,
- /*0x13fd*/ 529,
- /*0x2c6b*/ 964,
- -1,
- /*0x10a7*/ 491,
- /*0x1c9a*/ 549,
- /*0x10c9a*/ 1362,
- -1,
- /*0x00df*/ 56,
- /*0x1e91a*/ 1477,
- /*0x1f18*/ 723,
- /*0x1ff7*/ 858,
- -1,
- /*0x0498*/ 369,
- /*0x0518*/ 433,
- /*0x2ceb*/ 1023,
- -1, -1,
- /*0x01f7*/ 185,
- /*0x03f7*/ 291,
- /*0x1e06*/ 588,
- /*0x1f5f*/ 758,
- -1,
- /*0x00dd*/ 54,
- -1, -1,
- /*0x00c7*/ 33,
- /*0x0496*/ 368,
- /*0x0516*/ 432,
- /*0x10412*/ 1278,
- /*0x1f92*/ 785,
- /*0x0412*/ 315,
- /*0x0212*/ 199,
- /*0x0112*/ 66,
- /*0xab92*/ 1176,
- /*0x24c7*/ 902,
- /*0x1f5d*/ 757,
- -1,
- /*0x0392*/ 243,
- -1,
- /*0x104c7*/ 1323,
- /*0x2c12*/ 929,
- /*0x04c7*/ 393,
- /*0x0547*/ 467,
- -1, -1,
- /*0x1fb2*/ 815,
- /*0x1e14*/ 595,
- /*0x0232*/ 215,
- /*0x0132*/ 81,
- /*0xabb2*/ 1208,
- -1, -1,
- /*0x01b2*/ 151,
- /*0x2c92*/ 982,
- /*0x0506*/ 424,
- -1, -1, -1, -1, -1,
- /*0x1e10*/ 593,
- -1, -1, -1, -1, -1,
- /*0xa792*/ 1112,
- -1,
- /*0x1e92*/ 658,
- /*0x2cb2*/ 998,
- /*0x1faf*/ 814,
- /*0x042f*/ 344,
- -1, -1,
- /*0xabaf*/ 1205,
- /*0x1c92*/ 541,
- /*0x10c92*/ 1354,
- /*0x01af*/ 149,
- -1,
- /*0x1e912*/ 1469,
- /*0x0494*/ 367,
- /*0x0514*/ 431,
- /*0xa7b2*/ 1130,
- -1,
- /*0x1eb2*/ 676,
- -1,
- /*0x1fe9*/ 850,
- /*0x1e04*/ 587,
- -1, -1, -1,
- /*0x1cb2*/ 573,
- /*0x10cb2*/ 1386,
- -1,
- /*0x0490*/ 365,
- /*0x0510*/ 429,
- -1,
- /*0x2c69*/ 963,
- /*0x10a0*/ 484,
- -1, -1,
- /*0x1e02*/ 586,
- /*0x1041c*/ 1288,
- /*0x1f9c*/ 795,
- /*0x041c*/ 325,
- /*0x021c*/ 204,
- /*0x011c*/ 71,
- /*0xab9c*/ 1186,
- -1, -1,
- /*0x019c*/ 138,
- /*0x039c*/ 253,
- -1, -1,
- /*0x2c1c*/ 939,
- -1,
- /*0x1caf*/ 570,
- /*0x10caf*/ 1383,
- -1, -1, -1, -1,
- /*0x0504*/ 423,
- -1, -1,
- /*0x10a6*/ 490,
- -1,
- /*0x2c9c*/ 987,
- /*0x1e20*/ 601,
- /*0x1041e*/ 1290,
- /*0x1f9e*/ 797,
- /*0x041e*/ 327,
- /*0x021e*/ 205,
- /*0x011e*/ 72,
- /*0xab9e*/ 1188,
- -1,
- /*0x0502*/ 422,
- /*0x0470*/ 353,
- /*0x039e*/ 255,
- /*0x0170*/ 112,
- /*0xa79c*/ 1116,
- /*0x2c1e*/ 941,
- -1,
- /*0x01f0*/ 180,
- /*0x03f0*/ 287,
- -1, -1,
- /*0x2c70*/ 968,
- -1,
- /*0x1c9c*/ 551,
- /*0x10c9c*/ 1364,
- -1,
- /*0x10a4*/ 488,
- /*0x1e91c*/ 1479,
- /*0x2c9e*/ 988,
- /*0x1e26*/ 604,
- /*0x10422*/ 1294,
- /*0x1fa2*/ 801,
- /*0x0422*/ 331,
- /*0x0222*/ 207,
- /*0x0122*/ 74,
- /*0xaba2*/ 1192,
- /*0x04a0*/ 373,
- /*0x0520*/ 437,
- /*0x01a2*/ 142,
- -1, -1,
- /*0xa79e*/ 1117,
- /*0x2c22*/ 945,
- /*0x1e9e*/ 666,
- /*0x118a7*/ 1394,
- -1, -1, -1, -1,
- /*0x1ef0*/ 707,
- /*0x1c9e*/ 553,
- /*0x10c9e*/ 1366,
- -1, -1,
- /*0x1e91e*/ 1481,
- /*0x2ca2*/ 990,
- /*0x1e24*/ 603,
- /*0x1040e*/ 1274,
- /*0x1f8e*/ 781,
- /*0x040e*/ 311,
- /*0x020e*/ 197,
- /*0x010e*/ 64,
- /*0xab8e*/ 1172,
- /*0x04a6*/ 376,
- /*0x0526*/ 440,
- /*0x018e*/ 129,
- /*0x038e*/ 239,
- /*0xff27*/ 1240,
- /*0xa7a2*/ 1119,
- /*0x2c0e*/ 925,
- /*0x1ea2*/ 668,
- -1,
- /*0x1faa*/ 809,
- /*0x042a*/ 339,
- /*0x022a*/ 211,
- /*0x012a*/ 78,
- /*0xabaa*/ 1200,
- /*0x1ca2*/ 557,
- /*0x10ca2*/ 1370,
- -1,
- /*0x03aa*/ 266,
- -1,
- /*0x2c8e*/ 980,
- /*0x2c2a*/ 953,
- -1, -1,
- /*0x1e1a*/ 598,
- -1, -1, -1,
- /*0x04a4*/ 375,
- /*0x0524*/ 439,
- -1, -1, -1,
- /*0x0370*/ 230,
- /*0x2caa*/ 994,
- /*0x1e8e*/ 656,
- -1,
- /*0x1fae*/ 813,
- /*0x042e*/ 343,
- /*0x022e*/ 213,
- /*0x012e*/ 80,
- /*0xabae*/ 1204,
- -1,
- /*0x10c8e*/ 1350,
- /*0x01ae*/ 148,
- -1,
- /*0x1e90e*/ 1465,
- /*0xa7aa*/ 1123,
- /*0x2c2e*/ 957,
- /*0x1eaa*/ 672,
- -1, -1, -1, -1, -1,
- /*0x1f1a*/ 725,
- /*0x1caa*/ 565,
- /*0x10caa*/ 1378,
- /*0x049a*/ 370,
- /*0x051a*/ 434,
- -1,
- /*0x2cae*/ 996,
- /*0x1fac*/ 811,
- /*0x042c*/ 341,
- /*0x022c*/ 212,
- /*0x012c*/ 79,
- /*0xabac*/ 1202,
- -1, -1,
- /*0x01ac*/ 147,
- /*0x2165*/ 873,
- /*0x00d3*/ 45,
- /*0x2167*/ 875,
- /*0x2c2c*/ 955,
- /*0xa7ae*/ 1127,
- /*0x2161*/ 869,
- /*0x1eae*/ 674,
- /*0x118a0*/ 1387,
- /*0x1fba*/ 822,
- /*0x216d*/ 881,
- /*0x023a*/ 216,
- /*0x10b2*/ 502,
- /*0xabba*/ 1216,
- /*0x1cae*/ 569,
- /*0x10cae*/ 1382,
- /*0x104d3*/ 1335,
- /*0x2cac*/ 995,
- /*0x1f6b*/ 762,
- /*0x0553*/ 479,
- /*0x1fa8*/ 807,
- /*0x0428*/ 337,
- /*0x0228*/ 210,
- /*0x0128*/ 77,
- /*0xaba8*/ 1198,
- -1,
- /*0x1e12*/ 594,
- -1,
- /*0x03a8*/ 264,
- -1,
- /*0xa7ac*/ 1125,
- /*0x2c28*/ 951,
- /*0x1eac*/ 673,
- /*0x2cba*/ 1002,
- -1,
- /*0x118a6*/ 1393,
- -1,
- /*0x10af*/ 499,
- -1,
- /*0x1cac*/ 567,
- /*0x10cac*/ 1380,
- -1,
- /*0x1e32*/ 610,
- /*0x2163*/ 871,
- /*0x2ca8*/ 993,
- /*0x216f*/ 883,
- /*0xa7ba*/ 1135,
- -1,
- /*0x1eba*/ 680,
- /*0x1fb8*/ 820,
- -1, -1, -1,
- /*0xabb8*/ 1214,
- -1,
- /*0x1cba*/ 581,
- /*0x01b8*/ 155,
- /*0xa7a8*/ 1122,
- /*0xff26*/ 1239,
- /*0x1ea8*/ 671,
- /*0x0492*/ 366,
- /*0x0512*/ 430,
- /*0x118a4*/ 1391,
- -1, -1,
- /*0x1fb6*/ 818,
- /*0x1ca8*/ 563,
- /*0x10ca8*/ 1376,
- /*0x0136*/ 83,
- /*0xabb6*/ 1212,
- -1, -1,
- /*0xa688*/ 1053,
- /*0x2cb8*/ 1001,
- /*0x104b2*/ 1302,
- -1,
- /*0x04b2*/ 382,
- /*0x0532*/ 446,
- /*0x1040c*/ 1272,
- /*0x1f8c*/ 779,
- /*0x040c*/ 309,
- /*0x020c*/ 196,
- /*0x010c*/ 63,
- /*0xab8c*/ 1170,
- -1,
- /*0xff24*/ 1237,
- /*0xa7b8*/ 1134,
- /*0x038c*/ 238,
- /*0x1eb8*/ 679,
- /*0x2cb6*/ 1000,
- /*0x2c0c*/ 923,
- /*0xa68a*/ 1054,
- -1, -1, -1,
- /*0x1cb8*/ 579,
- -1, -1,
- /*0x1f2f*/ 736,
- -1,
- /*0x1e1c*/ 599,
- /*0xa779*/ 1101,
- /*0xa7b6*/ 1133,
- /*0x2c8c*/ 979,
- /*0x1eb6*/ 678,
- /*0xa680*/ 1049,
- /*0x0230*/ 214,
- /*0x0130*/ 1486,
- /*0xabb0*/ 1206,
- -1, -1,
- /*0x1cb6*/ 577,
- /*0x03b0*/ 268,
- -1,
- /*0x1f69*/ 760,
- /*0xa726*/ 1065,
- /*0x1fbc*/ 824,
- -1,
- /*0x1e8c*/ 655,
- -1,
- /*0xabbc*/ 1218,
- -1, -1,
- /*0x01bc*/ 156,
- /*0x10a2*/ 486,
- -1,
- /*0x10c8c*/ 1348,
- /*0x1e1e*/ 600,
- /*0x2cb0*/ 997,
- /*0x1e90c*/ 1463,
- -1,
- /*0x1f1c*/ 727,
- /*0xa698*/ 1061,
- /*0x1e70*/ 641,
- /*0x049c*/ 371,
- /*0x051c*/ 435,
- -1,
- /*0xa77b*/ 1102,
- -1, -1,
- /*0x2cbc*/ 1003,
- /*0xa7b0*/ 1128,
- /*0xa724*/ 1064,
- /*0x1eb0*/ 675,
- -1, -1,
- /*0xa696*/ 1060,
- -1, -1, -1,
- /*0x1cb0*/ 571,
- /*0x10cb0*/ 1384,
- -1,
- /*0xa7bc*/ 1136,
- /*0x1e22*/ 602,
- /*0x1ebc*/ 681,
- -1, -1, -1, -1,
- /*0x1fd2*/ 836,
- /*0x049e*/ 372,
- /*0x051e*/ 436,
- /*0x0152*/ 97,
- /*0x0052*/ 16,
- /*0x10aa*/ 494,
- /*0x1fcc*/ 835,
- /*0x04f0*/ 413,
- /*0x024c*/ 227,
- /*0x014c*/ 94,
- /*0x004c*/ 10,
- -1,
- /*0x1fbe*/ 825,
- /*0xa686*/ 1052,
- /*0x023e*/ 219,
- -1,
- /*0xabbe*/ 1220,
- -1, -1,
- /*0x118b2*/ 1405,
- -1,
- /*0x1e0e*/ 592,
- /*0x1fb4*/ 817,
- -1,
- /*0x2cd2*/ 1014,
- /*0x0134*/ 82,
- /*0xabb4*/ 1210,
- /*0xa77d*/ 1103,
- /*0x04a2*/ 374,
- /*0x0522*/ 438,
- /*0x2ccc*/ 1011,
- -1,
- /*0x10ae*/ 498,
- -1, -1,
- /*0x1e2a*/ 606,
- /*0x2cbe*/ 1004,
- -1, -1,
- /*0x1ed2*/ 692,
- /*0xa694*/ 1059,
- -1,
- /*0xff32*/ 1251,
- -1,
- /*0x118af*/ 1402,
- /*0x1ecc*/ 689,
- /*0x2cb4*/ 999,
- -1, -1,
- /*0xa7be*/ 1137,
- -1,
- /*0x1ebe*/ 682,
- /*0x1f0e*/ 721,
- -1,
- /*0xa690*/ 1057,
- /*0x048e*/ 364,
- /*0x050e*/ 428,
- /*0x10ac*/ 496,
- /*0x1cbe*/ 583,
- /*0xa7b4*/ 1132,
- -1,
- /*0x1eb4*/ 677,
- /*0x1e2e*/ 608,
- -1, -1, -1,
- /*0x1f2a*/ 731,
- /*0xff2f*/ 1248,
- /*0x1cb4*/ 575,
- /*0x04aa*/ 378,
- /*0x052a*/ 442,
- -1, -1,
- /*0x10ba*/ 510,
- -1, -1,
- /*0x1fca*/ 833,
- -1,
- /*0x024a*/ 226,
- /*0x014a*/ 93,
- /*0x004a*/ 8,
- /*0xa684*/ 1051,
- /*0x2126*/ 864,
- /*0x01ca*/ 161,
- /*0x10a8*/ 492,
- -1, -1,
- /*0x1e2c*/ 607,
- -1, -1, -1, -1, -1,
- /*0x1f2e*/ 735,
- -1,
- /*0xa682*/ 1050,
- /*0x04ae*/ 380,
- /*0x052e*/ 444,
- -1,
- /*0xa732*/ 1070,
- /*0x2cca*/ 1010,
- -1,
- /*0x1fc4*/ 828,
- /*0x1e3a*/ 614,
- /*0x0244*/ 222,
- -1,
- /*0x0044*/ 3,
- /*0x004f*/ 13,
- -1,
- /*0x01c4*/ 157,
- /*0x01cf*/ 164,
- /*0x03cf*/ 270,
- -1,
- /*0x10b8*/ 508,
- /*0x1e28*/ 605,
- /*0x1eca*/ 688,
- /*0x1fab*/ 810,
- /*0x042b*/ 340,
- /*0x1f2c*/ 733,
- -1,
- /*0xabab*/ 1201,
- /*0x04ac*/ 379,
- /*0x052c*/ 443,
- -1,
- /*0x03ab*/ 267,
- -1,
- /*0x2cc4*/ 1007,
- /*0x2c2b*/ 954,
- /*0x1fc2*/ 826,
- /*0x10b6*/ 506,
- /*0x24ba*/ 889,
- /*0x118a2*/ 1389,
- /*0x0042*/ 1,
- -1,
- /*0x1f3a*/ 739,
- /*0x104ba*/ 1310,
- /*0x03c2*/ 269,
- /*0x04ba*/ 386,
- /*0x053a*/ 454,
- /*0xa7c4*/ 1139,
- /*0x1fc8*/ 831,
- /*0x1ec4*/ 685,
- /*0x0248*/ 225,
- /*0x1e38*/ 613,
- /*0x0048*/ 7,
- /*0x1f28*/ 729,
- -1,
- /*0x01c8*/ 160,
- /*0x04a8*/ 377,
- /*0x0528*/ 441,
- -1, -1,
- /*0x2cc2*/ 1006,
- /*0xa7ab*/ 1124,
- /*0xff22*/ 1235,
- -1, -1, -1, -1,
- /*0x1e36*/ 612,
- -1, -1,
- /*0x1cab*/ 566,
- /*0x10cab*/ 1379,
- /*0x2cc8*/ 1009,
- /*0xa7c2*/ 1138,
- -1,
- /*0x1ec2*/ 684,
- /*0x10b0*/ 500,
- -1,
- /*0x24b8*/ 887,
- /*0x216b*/ 879,
- /*0x118aa*/ 1397,
- /*0x1e0c*/ 591,
- /*0x1f38*/ 737,
- /*0x104b8*/ 1308,
- -1,
- /*0x04b8*/ 385,
- /*0x0538*/ 452,
- /*0x1ec8*/ 687,
- /*0x10bc*/ 512,
- /*0x1fd6*/ 838,
- /*0x0150*/ 96,
- /*0x0050*/ 14,
- /*0x0156*/ 99,
- /*0x0056*/ 20,
- /*0x24b6*/ 885,
- /*0x03d0*/ 271,
- -1,
- /*0x03d6*/ 274,
- /*0x1fdb*/ 843,
- /*0x104b6*/ 1306,
- -1,
- /*0x04b6*/ 384,
- /*0x0536*/ 450,
- /*0xff2a*/ 1243,
- -1,
- /*0x01db*/ 170,
- /*0x1e30*/ 609,
- /*0x118ae*/ 1401,
- -1, -1, -1,
- /*0x2cd0*/ 1013,
- /*0x1f0c*/ 719,
- /*0x2cd6*/ 1016,
- /*0xa69a*/ 1062,
- /*0x048c*/ 363,
- /*0x050c*/ 427,
- -1,
- /*0x1e3c*/ 615,
- /*0xa722*/ 1063,
- -1, -1, -1, -1, -1, -1,
- /*0x1ed0*/ 691,
- /*0x1fc6*/ 829,
- /*0x1ed6*/ 694,
- /*0x0246*/ 224,
- /*0xff2e*/ 1247,
- /*0x0046*/ 5,
- /*0x118ac*/ 1399,
- -1,
- /*0x2132*/ 867,
- /*0x024e*/ 228,
- /*0x014e*/ 95,
- /*0x004e*/ 12,
- /*0x104b0*/ 1300,
- /*0x1fda*/ 842,
- /*0x04b0*/ 381,
- -1,
- /*0x015a*/ 101,
- /*0x005a*/ 24,
- /*0x10be*/ 514,
- /*0x24bc*/ 891,
- -1,
- /*0x03da*/ 276,
- /*0x118ba*/ 1413,
- /*0x1f3c*/ 741,
- /*0x104bc*/ 1312,
- /*0x2cc6*/ 1008,
- /*0x04bc*/ 387,
- /*0x053c*/ 456,
- /*0x10b4*/ 504,
- /*0xff2c*/ 1245,
- -1,
- /*0x2cce*/ 1012,
- -1,
- /*0x118a8*/ 1395,
- /*0xa72a*/ 1067,
- -1,
- /*0x1e52*/ 626,
- /*0x2cda*/ 1018,
- /*0xa7c6*/ 1141,
- -1,
- /*0x1ec6*/ 686,
- -1,
- /*0x1e4c*/ 623,
- -1, -1,
- /*0xff3a*/ 1259,
- /*0x1ece*/ 690,
- /*0xa652*/ 1035,
- /*0x1e3e*/ 616,
- /*0x2169*/ 877,
- -1, -1,
- /*0x1eda*/ 696,
- /*0xa64c*/ 1032,
- /*0x00d2*/ 44,
- -1,
- /*0xff28*/ 1241,
- -1,
- /*0x1e34*/ 611,
- /*0xa692*/ 1058,
- /*0x00cc*/ 38,
- /*0xa72e*/ 1069,
- /*0x118b8*/ 1411,
- -1, -1, -1, -1,
- /*0x1f52*/ 752,
- /*0x104d2*/ 1334,
- /*0x24cc*/ 907,
- /*0x04d2*/ 398,
- /*0x0552*/ 478,
- -1,
- /*0x1f4c*/ 749,
- /*0x104cc*/ 1328,
- /*0x24be*/ 893,
- /*0x2cc0*/ 1005,
- /*0x054c*/ 472,
- /*0x118b6*/ 1409,
- /*0x1f3e*/ 743,
- /*0x104be*/ 1314,
- -1,
- /*0x04be*/ 388,
- /*0x053e*/ 458,
- -1,
- /*0xff38*/ 1257,
- /*0xa72c*/ 1068,
- -1, -1, -1,
- /*0x104b4*/ 1304,
- /*0x1ec0*/ 683,
- /*0x04b4*/ 383,
- /*0x0534*/ 448,
- -1, -1,
- /*0x1fe2*/ 844,
- /*0x0462*/ 346,
- -1,
- /*0x0162*/ 105,
- -1,
- /*0xff36*/ 1255,
- /*0xa73a*/ 1074,
- /*0x01e2*/ 173,
- /*0x03e2*/ 280,
- /*0x0154*/ 98,
- /*0x0054*/ 18,
- /*0x2c62*/ 959,
- /*0x10c4*/ 520,
- -1, -1, -1,
- /*0x1e4a*/ 622,
- /*0xa728*/ 1066,
- -1, -1, -1,
- /*0x118b0*/ 1403,
- -1, -1,
- /*0x2ce2*/ 1022,
- -1,
- /*0x10ab*/ 495,
- /*0xa64a*/ 1031,
- /*0x1fd8*/ 840,
- -1,
- /*0x2cd4*/ 1015,
- /*0x0158*/ 100,
- /*0x0058*/ 22,
- /*0x118bc*/ 1415,
- /*0x00ca*/ 36,
- -1,
- /*0x03d8*/ 275,
- -1,
- /*0x10c2*/ 518,
- /*0x1ee2*/ 700,
- -1, -1,
- /*0x1e44*/ 619,
- /*0x24ca*/ 905,
- /*0xff30*/ 1249,
- /*0x1ed4*/ 693,
- /*0xa738*/ 1073,
- /*0x1f4a*/ 747,
- /*0x104ca*/ 1326,
- -1, -1,
- /*0x054a*/ 470,
- /*0x2cd8*/ 1017,
- /*0xa644*/ 1028,
- /*0x1040d*/ 1273,
- /*0x1f8d*/ 780,
- /*0x040d*/ 310,
- -1, -1,
- /*0xab8d*/ 1171,
- /*0x00c4*/ 30,
- /*0x00cf*/ 41,
- /*0xa736*/ 1072,
- -1, -1,
- /*0x212a*/ 865,
- /*0x2c0d*/ 924,
- /*0x1ed8*/ 695,
- /*0x1e42*/ 618,
- /*0x24c4*/ 899,
- /*0x24cf*/ 910,
- -1, -1, -1,
- /*0x104c4*/ 1320,
- /*0x104cf*/ 1331,
- -1,
- /*0x0544*/ 464,
- /*0x054f*/ 475,
- /*0xa642*/ 1027,
- /*0x1e48*/ 621,
- -1, -1, -1, -1, -1,
- /*0x00c2*/ 28,
- /*0x1f2b*/ 732,
- -1,
- /*0x118be*/ 1417,
- /*0x0055*/ 19,
- /*0xa648*/ 1030,
- /*0xa78d*/ 1110,
- /*0x01d5*/ 167,
- /*0x03d5*/ 273,
- /*0x24c2*/ 897,
- -1, -1,
- /*0x00c8*/ 34,
- /*0x118b4*/ 1407,
- /*0x104c2*/ 1318,
- -1,
- /*0x10c8d*/ 1349,
- /*0x0542*/ 462,
- -1,
- /*0x1e90d*/ 1464,
- -1,
- /*0x24c8*/ 903,
- -1, -1, -1,
- /*0x1f48*/ 745,
- /*0x104c8*/ 1324,
- /*0xa73c*/ 1075,
- -1,
- /*0x0548*/ 468,
- -1, -1,
- /*0xa68e*/ 1056,
- /*0x1e50*/ 625,
- -1,
- /*0x1e56*/ 628,
- /*0xff34*/ 1253,
- /*0x0245*/ 223,
- /*0x0145*/ 90,
- /*0x0045*/ 4,
- -1,
- /*0x16e5f*/ 1450,
- /*0x01c5*/ 158,
- -1,
- /*0xa650*/ 1034,
- /*0x1fd9*/ 841,
- /*0xa656*/ 1037,
- /*0x1fec*/ 853,
- /*0x046c*/ 351,
- /*0x0059*/ 23,
- /*0x016c*/ 110,
- /*0x00d0*/ 42,
- /*0x01d9*/ 169,
- /*0x00d6*/ 48,
- /*0x01ec*/ 178,
- /*0x03ec*/ 285,
- /*0x16e5d*/ 1448,
- -1, -1,
- /*0x16e47*/ 1426,
- -1, -1,
- /*0x00db*/ 52,
- -1,
- /*0x1f50*/ 751,
- /*0x104d0*/ 1332,
- /*0x1f56*/ 754,
- /*0x04d0*/ 397,
- /*0x0550*/ 476,
- /*0x04d6*/ 400,
- /*0x0556*/ 482,
- /*0xa752*/ 1086,
- /*0xa7c5*/ 1140,
- /*0x1e46*/ 620,
- -1,
- /*0x1f5b*/ 756,
- -1,
- /*0xa74c*/ 1083,
- -1,
- /*0x1e4e*/ 624,
- -1, -1, -1,
- /*0xa73e*/ 1076,
- /*0xa646*/ 1029,
- /*0x1e5a*/ 630,
- /*0x1eec*/ 705,
- -1, -1, -1,
- /*0xa64e*/ 1033,
- /*0x00c6*/ 32,
- -1,
- /*0xa734*/ 1071,
- /*0x10c0*/ 516,
- -1,
- /*0xa65a*/ 1039,
- /*0x00ce*/ 40,
- /*0x1fc9*/ 832,
- -1,
- /*0x24c6*/ 901,
- /*0x0149*/ 92,
- /*0x0049*/ 1485,
- /*0x00da*/ 51,
- -1,
- /*0x104c6*/ 1322,
- /*0x24ce*/ 909,
- /*0x118ab*/ 1398,
- /*0x0546*/ 466,
- -1, -1,
- /*0x104ce*/ 1330,
- -1, -1,
- /*0x054e*/ 474,
- /*0x1fea*/ 851,
- /*0x046a*/ 350,
- -1,
- /*0x016a*/ 109,
- /*0x04da*/ 402,
- /*0x0345*/ 229,
- -1,
- /*0x01ea*/ 177,
- /*0x03ea*/ 284,
- /*0x1e40*/ 617,
- /*0x1fa9*/ 808,
- /*0x0429*/ 338,
- -1, -1,
- /*0xaba9*/ 1199,
- /*0xff2b*/ 1244,
- -1,
- /*0x01a9*/ 146,
- /*0x03a9*/ 265,
- -1,
- /*0xa640*/ 1026,
- /*0x2c29*/ 952,
- /*0x1fc3*/ 827,
- -1,
- /*0x0243*/ 221,
- /*0x0143*/ 89,
- /*0x0043*/ 2,
- /*0x00c0*/ 26,
- /*0x10421*/ 1293,
- /*0x1fa1*/ 800,
- /*0x0421*/ 330,
- -1,
- /*0xa74a*/ 1082,
- /*0xaba1*/ 1191,
- -1, -1,
- /*0x24c0*/ 895,
- /*0x03a1*/ 258,
- -1,
- /*0x1eea*/ 704,
- /*0x2c21*/ 944,
- /*0x104c0*/ 1316,
- /*0x1fb9*/ 821,
- /*0x04c0*/ 389,
- /*0x0540*/ 460,
- /*0x0139*/ 84,
- /*0xabb9*/ 1215,
- /*0x1fe8*/ 849,
- /*0x0468*/ 349,
- -1,
- /*0x0168*/ 108,
- -1, -1,
- /*0x1e62*/ 634,
- /*0x01e8*/ 176,
- /*0x03e8*/ 283,
- /*0x1ca9*/ 564,
- /*0x10ca9*/ 1377,
- /*0xa744*/ 1079,
- /*0x1e54*/ 627,
- -1,
- /*0x1fcb*/ 834,
- -1, -1,
- /*0xa662*/ 1043,
- /*0x004b*/ 9,
- -1, -1,
- /*0x01cb*/ 162,
- /*0xa68c*/ 1055,
- /*0xa654*/ 1036,
- -1, -1, -1, -1,
- /*0x1ca1*/ 556,
- /*0x10ca1*/ 1369,
- /*0x00d4*/ 46,
- -1,
- /*0x1e921*/ 1484,
- -1,
- /*0x1e58*/ 629,
- -1,
- /*0x16e57*/ 1442,
- /*0xa742*/ 1078,
- -1,
- /*0x1ee8*/ 703,
- /*0x04e2*/ 406,
- /*0x1cb9*/ 580,
- -1,
- /*0x1f54*/ 753,
- -1,
- /*0xa658*/ 1038,
- /*0x04d4*/ 399,
- /*0x0554*/ 480,
- -1,
- /*0xa748*/ 1081,
- -1, -1,
- /*0x00d8*/ 49,
- /*0x10417*/ 1283,
- /*0x1f97*/ 790,
- /*0x0417*/ 320,
- /*0x1fe4*/ 846,
- /*0x0464*/ 347,
- /*0xab97*/ 1181,
- /*0x0164*/ 106,
- -1,
- /*0x0197*/ 136,
- /*0x0397*/ 248,
- /*0x01e4*/ 174,
- /*0x03e4*/ 281,
- /*0x2c17*/ 934,
- -1,
- /*0x2c64*/ 961,
- /*0x04d8*/ 401,
- -1, -1,
- /*0x0460*/ 345,
- -1,
- /*0x0160*/ 104,
- -1, -1, -1,
- /*0x01e0*/ 172,
- /*0x03e0*/ 279,
- /*0x1ff4*/ 856,
- /*0x0474*/ 355,
- /*0x2c60*/ 958,
- /*0x0174*/ 114,
- -1,
- /*0x1ffc*/ 863,
- /*0x047c*/ 359,
- /*0x01f4*/ 183,
- /*0x03f4*/ 289,
- /*0xa750*/ 1085,
- -1,
- /*0xa756*/ 1088,
- /*0x01fc*/ 188,
- /*0x1f0d*/ 720,
- /*0x1e97*/ 661,
- /*0x2ce0*/ 1021,
- /*0x1ee4*/ 701,
- -1,
- /*0x10c5*/ 521,
- -1, -1,
- /*0x1c97*/ 546,
- /*0x10c97*/ 1359,
- -1, -1,
- /*0x1e917*/ 1474,
- -1,
- /*0x046e*/ 352,
- -1,
- /*0x016e*/ 111,
- /*0x1ee0*/ 699,
- /*0x00d5*/ 47,
- /*0x13fc*/ 528,
- /*0x01ee*/ 179,
- /*0x03ee*/ 286,
- /*0x1fe6*/ 847,
- /*0x0466*/ 348,
- /*0x2c6e*/ 966,
- /*0x0166*/ 107,
- /*0x1ef4*/ 709,
- -1,
- /*0x015e*/ 103,
- /*0x01e6*/ 175,
- /*0x03e6*/ 282,
- /*0x1efc*/ 713,
- /*0x01de*/ 171,
- /*0x03de*/ 278,
- -1,
- /*0x0555*/ 481,
- /*0xa746*/ 1080,
- -1, -1,
- /*0x16e53*/ 1438,
- -1, -1,
- /*0xa74e*/ 1084,
- -1, -1, -1, -1,
- /*0x1e6c*/ 639,
- /*0xa75a*/ 1090,
- /*0x2cde*/ 1020,
- -1,
- /*0x0051*/ 15,
- /*0x1eee*/ 706,
- /*0x00c5*/ 31,
- /*0x01d1*/ 165,
- /*0x03d1*/ 272,
- -1, -1,
- /*0xa66c*/ 1048,
- -1,
- /*0x212b*/ 866,
- /*0x1ee6*/ 702,
- /*0x24c5*/ 900,
- /*0x00d9*/ 50,
- /*0x1ede*/ 698,
- -1, -1,
- /*0x104c5*/ 1321,
- -1,
- /*0x04c5*/ 392,
- /*0x0545*/ 465,
- /*0x1fad*/ 812,
- /*0x042d*/ 342,
- -1, -1,
- /*0xabad*/ 1203,
- /*0x1f59*/ 755,
- -1,
- /*0x1f6c*/ 763,
- -1, -1,
- /*0x04ec*/ 411,
- /*0x2c2d*/ 956,
- /*0x015c*/ 102,
- -1,
- /*0xfb17*/ 1233,
- -1,
- /*0xa740*/ 1077,
- /*0x03dc*/ 277,
- /*0x1ff2*/ 854,
- /*0x0472*/ 354,
- -1,
- /*0x0172*/ 113,
- -1, -1,
- /*0x10a9*/ 493,
- /*0x01f2*/ 182,
- /*0x10425*/ 1297,
- /*0x1fa5*/ 804,
- /*0x0425*/ 334,
- /*0x2c72*/ 969,
- -1,
- /*0xaba5*/ 1195,
- -1,
- /*0x2cdc*/ 1019,
- -1,
- /*0x03a5*/ 261,
- /*0x10c3*/ 519,
- /*0xa7ad*/ 1126,
- /*0x2c25*/ 948,
- -1, -1, -1,
- /*0x2cf2*/ 1025,
- /*0x10a1*/ 485,
- /*0x1e6a*/ 638,
- /*0x00c9*/ 35,
- /*0x1cad*/ 568,
- /*0x10cad*/ 1381,
- /*0x1edc*/ 697,
- /*0x004d*/ 11,
- -1, -1,
- /*0x01cd*/ 163,
- -1,
- /*0x24c9*/ 904,
- /*0xa66a*/ 1047,
- /*0x10b9*/ 509,
- /*0x1ef2*/ 708,
- /*0x1f49*/ 746,
- /*0x104c9*/ 1325,
- /*0xa762*/ 1094,
- /*0x04c9*/ 394,
- /*0x0549*/ 469,
- /*0x013f*/ 87,
- /*0xabbf*/ 1221,
- -1,
- /*0xa754*/ 1087,
- /*0x10423*/ 1295,
- /*0x1fa3*/ 802,
- /*0x0423*/ 332,
- -1, -1,
- /*0xaba3*/ 1193,
- /*0x1ca5*/ 560,
- /*0x10ca5*/ 1373,
- /*0x1f6a*/ 761,
- /*0x03a3*/ 259,
- -1,
- /*0x04ea*/ 410,
- /*0x2c23*/ 946,
- -1,
- /*0x0241*/ 220,
- /*0x0141*/ 88,
- /*0x0041*/ 0,
- /*0x00c3*/ 29,
- /*0x1f29*/ 730,
- -1, -1,
- /*0xa758*/ 1089,
- -1, -1,
- /*0x1e68*/ 637,
- -1,
- /*0x24c3*/ 898,
- -1, -1, -1, -1,
- /*0x104c3*/ 1319,
- -1,
- /*0x04c3*/ 391,
- /*0x0543*/ 463,
- /*0xa668*/ 1046,
- /*0x0372*/ 231,
- -1, -1,
- /*0x1cbf*/ 584,
- -1, -1, -1,
- /*0x023d*/ 218,
- /*0x013d*/ 86,
- /*0xabbd*/ 1219,
- /*0x24b9*/ 888,
- /*0x1ca3*/ 558,
- /*0x10ca3*/ 1371,
- -1,
- /*0x1f39*/ 738,
- /*0x104b9*/ 1309,
- -1, -1,
- /*0x0539*/ 453,
- /*0x1f68*/ 759,
- /*0x00cb*/ 37,
- -1,
- /*0x04e8*/ 409,
- /*0x1041d*/ 1289,
- /*0x1f9d*/ 796,
- /*0x041d*/ 326,
- -1, -1,
- /*0xab9d*/ 1187,
- /*0x24cb*/ 906,
- -1,
- /*0x019d*/ 139,
- /*0x039d*/ 254,
- /*0x1f4b*/ 748,
- /*0x104cb*/ 1327,
- /*0x2c1d*/ 940,
- /*0x04cb*/ 395,
- /*0x054b*/ 471,
- /*0x10407*/ 1267,
- /*0x1f87*/ 774,
- /*0x0407*/ 304,
- /*0x0587*/ 483,
- -1,
- /*0xab87*/ 1165,
- /*0x1e64*/ 635,
- -1,
- /*0x0187*/ 125,
- /*0x1041b*/ 1287,
- /*0x1f9b*/ 794,
- /*0x041b*/ 324,
- /*0x2c07*/ 918,
- /*0x1cbd*/ 582,
- /*0xab9b*/ 1185,
- -1, -1,
- /*0xa664*/ 1044,
- /*0x039b*/ 252,
- -1,
- /*0x1e60*/ 633,
- /*0x2c1b*/ 938,
- /*0x1fbb*/ 823,
- -1,
- /*0x023b*/ 217,
- /*0x013b*/ 85,
- /*0xabbb*/ 1217,
- -1, -1,
- /*0x1e74*/ 643,
- /*0xab73*/ 1145,
- /*0xa660*/ 1042,
- /*0x1c9d*/ 552,
- /*0x10c9d*/ 1365,
- /*0x1e7c*/ 647,
- -1,
- /*0x1e91d*/ 1480,
- -1,
- /*0x1ff6*/ 857,
- /*0x0476*/ 356,
- /*0x04e4*/ 407,
- /*0x0176*/ 115,
- -1, -1, -1,
- /*0x01f6*/ 184,
- /*0x2162*/ 870,
- /*0x1c87*/ 537,
- /*0x10c87*/ 1343,
- /*0x1e9b*/ 665,
- /*0x118a9*/ 1396,
- /*0x1e907*/ 1458,
- /*0xa76c*/ 1099,
- -1,
- /*0x04e0*/ 405,
- /*0x1e6e*/ 640,
- /*0x1c9b*/ 550,
- /*0x10c9b*/ 1363,
- -1, -1,
- /*0x1e91b*/ 1478,
- -1, -1,
- /*0x04f4*/ 415,
- /*0x1e66*/ 636,
- -1, -1,
- /*0x1e5e*/ 632,
- /*0x04fc*/ 419,
- /*0x118a1*/ 1388,
- -1,
- /*0xabb1*/ 1207,
- -1,
- /*0xff29*/ 1242,
- /*0x01b1*/ 150,
- /*0xa666*/ 1045,
- -1,
- /*0x1ef6*/ 710,
- /*0xa65e*/ 1041,
- /*0x10419*/ 1285,
- /*0x1f99*/ 792,
- /*0x0419*/ 322,
- /*0x118b9*/ 1412,
- /*0x10ad*/ 497,
- /*0xab99*/ 1183,
- /*0x00de*/ 55,
- /*0x1f6e*/ 765,
- -1,
- /*0x0399*/ 250,
- /*0x04ee*/ 412,
- -1,
- /*0x2c19*/ 936,
- /*0xff21*/ 1234,
- /*0x1fb7*/ 819,
- /*0x10413*/ 1279,
- /*0x1f93*/ 786,
- /*0x0413*/ 316,
- /*0xabb7*/ 1213,
- /*0x04e6*/ 408,
- /*0xab93*/ 1177,
- /*0x01b7*/ 154,
- /*0x04de*/ 404,
- /*0x0193*/ 133,
- /*0x0393*/ 244,
- /*0xa7b1*/ 1129,
- /*0xff39*/ 1258,
- /*0x2c13*/ 930,
- /*0x00d1*/ 43,
- /*0x1ffa*/ 861,
- /*0x047a*/ 358,
- /*0x10a5*/ 489,
- -1, -1,
- /*0x1cb1*/ 572,
- /*0x10cb1*/ 1385,
- /*0x01fa*/ 187,
- /*0x03fa*/ 293,
- -1, -1,
- /*0x1e99*/ 663,
- /*0xa76a*/ 1098,
- /*0x104d1*/ 1333,
- /*0x1e5c*/ 631,
- /*0x0376*/ 232,
- /*0x0551*/ 477,
- -1,
- /*0x1c99*/ 548,
- /*0x10c99*/ 1361,
- /*0x10cd*/ 523,
- -1,
- /*0x1e919*/ 1476,
- /*0x1e72*/ 642,
- -1,
- /*0xa65c*/ 1040,
- -1,
- /*0x13fa*/ 526,
- -1, -1, -1,
- /*0x1cb7*/ 578,
- /*0x00dc*/ 53,
- /*0x1c93*/ 542,
- /*0x10c93*/ 1355,
- /*0x10bf*/ 515,
- /*0x1f2d*/ 734,
- /*0x1e913*/ 1470,
- /*0xabb5*/ 1211,
- /*0x1efa*/ 712,
- -1,
- /*0x01b5*/ 153,
- -1,
- /*0x10a3*/ 487,
- /*0xab75*/ 1147,
- -1, -1, -1,
- /*0x04dc*/ 403,
- /*0x1fb3*/ 816,
- -1, -1, -1,
- /*0xabb3*/ 1209,
- /*0x10c1*/ 517,
- -1,
- /*0x01b3*/ 152,
- /*0x04f2*/ 414,
- -1,
- /*0xa768*/ 1097,
- -1,
- /*0x1041f*/ 1291,
- /*0x1f9f*/ 798,
- /*0x041f*/ 328,
- -1, -1,
- /*0xab9f*/ 1189,
- -1,
- /*0x00cd*/ 39,
- /*0x019f*/ 140,
- /*0x039f*/ 256,
- /*0x216c*/ 880,
- -1,
- /*0x2c1f*/ 942,
- -1, -1, -1,
- /*0x24cd*/ 908,
- -1, -1,
- /*0x1cb5*/ 576,
- /*0x1f4d*/ 750,
- /*0x104cd*/ 1329,
- /*0x10bd*/ 513,
- /*0x04cd*/ 396,
- /*0x054d*/ 473,
- /*0xa7b3*/ 1131,
- /*0x1ff8*/ 859,
- /*0x0478*/ 357,
- /*0xab7f*/ 1157,
- /*0x0178*/ 116,
- /*0xab71*/ 1143,
- /*0x24bf*/ 894,
- -1,
- /*0x01f8*/ 186,
- /*0x1cb3*/ 574,
- /*0x1f3f*/ 744,
- /*0x104bf*/ 1315,
- -1, -1,
- /*0x053f*/ 459,
- -1,
- /*0x00c1*/ 27,
- -1, -1, -1, -1, -1,
- /*0x1c9f*/ 554,
- /*0x10c9f*/ 1367,
- /*0xfb13*/ 1229,
- /*0x24c1*/ 896,
- /*0x1e91f*/ 1482,
- -1,
- /*0x13f8*/ 524,
- /*0xa764*/ 1095,
- /*0x104c1*/ 1317,
- -1,
- /*0x04c1*/ 390,
- /*0x0541*/ 461,
- /*0xab79*/ 1151,
- -1, -1,
- /*0x10415*/ 1281,
- /*0x1f95*/ 788,
- /*0x0415*/ 318,
- /*0x1ef8*/ 711,
- -1,
- /*0xab95*/ 1179,
- /*0xa760*/ 1093,
- -1, -1,
- /*0x0395*/ 246,
- -1, -1,
- /*0x2c15*/ 932,
- -1, -1,
- /*0x10bb*/ 511,
- /*0x216a*/ 878,
- /*0x24bd*/ 892,
- -1,
- /*0x118ad*/ 1400,
- -1,
- /*0x1f3d*/ 742,
- /*0x104bd*/ 1313,
- -1,
- /*0x047e*/ 360,
- /*0x053d*/ 457,
- /*0x16e52*/ 1437,
- -1, -1, -1,
- /*0x01fe*/ 189,
- /*0x03fe*/ 295,
- /*0x16e4c*/ 1431,
- /*0xab7b*/ 1153,
- /*0x2c7e*/ 971,
- -1, -1, -1, -1, -1,
- /*0x1f1d*/ 728,
- /*0xa76e*/ 1100,
- /*0xff2d*/ 1246,
- -1, -1, -1,
- /*0x118a5*/ 1392,
- /*0x1c95*/ 544,
- /*0x10c95*/ 1357,
- -1,
- /*0xa766*/ 1096,
- /*0x1e915*/ 1472,
- -1,
- /*0xa75e*/ 1092,
- -1, -1, -1, -1, -1, -1,
- /*0x10b1*/ 501,
- /*0x1e76*/ 644,
- /*0x1efe*/ 714,
- /*0x2168*/ 876,
- /*0x1f1b*/ 726,
- -1,
- /*0x10411*/ 1277,
- /*0x1f91*/ 784,
- /*0x0411*/ 314,
- /*0xff25*/ 1238,
- -1,
- /*0xab91*/ 1175,
- /*0x24bb*/ 890,
- -1,
- /*0x0191*/ 132,
- /*0x0391*/ 242,
- /*0x1f3b*/ 740,
- /*0x104bb*/ 1311,
- /*0x2c11*/ 928,
- /*0x118bf*/ 1418,
- /*0x053b*/ 455,
- -1, -1,
- /*0xab7d*/ 1155,
- -1, -1,
- /*0x10b7*/ 507,
- /*0x118a3*/ 1390,
- /*0x1040f*/ 1275,
- /*0x1f8f*/ 782,
- /*0x040f*/ 312,
- -1, -1,
- /*0xab8f*/ 1173,
- -1,
- /*0x04f6*/ 416,
- /*0x018f*/ 130,
- /*0x038f*/ 240,
- -1, -1,
- /*0x2c0f*/ 926,
- -1,
- /*0x16e4a*/ 1429,
- -1,
- /*0x1040b*/ 1271,
- /*0x1f8b*/ 778,
- /*0x040b*/ 308,
- -1,
- /*0xa75c*/ 1091,
- /*0xab8b*/ 1169,
- /*0xff23*/ 1236,
- -1,
- /*0x018b*/ 128,
- /*0x1c91*/ 540,
- /*0x10c91*/ 1353,
- -1,
- /*0x2c0b*/ 922,
- /*0x1e911*/ 1468,
- -1,
- /*0x2164*/ 872,
- /*0xab77*/ 1149,
- -1,
- /*0x104b1*/ 1301,
- -1,
- /*0xfb15*/ 1231,
- /*0x0531*/ 445,
- -1,
- /*0x118bd*/ 1416,
- /*0x16e44*/ 1423,
- /*0x16e4f*/ 1434,
- -1,
- /*0x1e7a*/ 646,
- -1,
- /*0x2160*/ 868,
- /*0x1f19*/ 724,
- /*0x10b5*/ 505,
- /*0x10c8f*/ 1351,
- -1, -1,
- /*0x1e90f*/ 1466,
- -1, -1,
- /*0xa78b*/ 1109,
- /*0x24b7*/ 886,
- /*0x10405*/ 1265,
- /*0x1f85*/ 772,
- /*0x0405*/ 302,
- -1,
- /*0x104b7*/ 1307,
- /*0xab85*/ 1163,
- /*0x10b3*/ 503,
- /*0x0537*/ 451,
- /*0x10c8b*/ 1347,
- -1,
- /*0x16e42*/ 1421,
- /*0x1e90b*/ 1462,
- /*0x2c05*/ 916,
- -1, -1, -1, -1, -1,
- /*0x10401*/ 1261,
- /*0x1f81*/ 768,
- /*0x0401*/ 298,
- /*0x04fa*/ 418,
- /*0x16e48*/ 1427,
- /*0xab81*/ 1159,
- /*0x216e*/ 882,
- -1,
- /*0x0181*/ 121,
- -1, -1, -1,
- /*0x2c01*/ 912,
- -1, -1,
- /*0x2166*/ 874,
- -1, -1, -1, -1,
- /*0x118bb*/ 1414,
- /*0x00b5*/ 25,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x1c85*/ 535,
- /*0x10c85*/ 1341,
- -1, -1,
- /*0x1e905*/ 1456,
- -1,
- /*0x104b5*/ 1305,
- -1, -1,
- /*0x0535*/ 449,
- -1, -1, -1, -1,
- /*0x16e50*/ 1435,
- -1,
- /*0x16e56*/ 1441,
- -1,
- /*0x1c81*/ 531,
- /*0x10c81*/ 1337,
- -1,
- /*0x104b3*/ 1303,
- /*0x1e901*/ 1452,
- -1,
- /*0x0533*/ 447,
- /*0x16e5b*/ 1446,
- -1,
- /*0x1e78*/ 645,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x118b1*/ 1404,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x16e46*/ 1425,
- /*0xab70*/ 1142,
- -1, -1, -1,
- /*0xff31*/ 1250,
- /*0x16e4e*/ 1433,
- /*0x04f8*/ 417,
- /*0x118b7*/ 1410,
- -1, -1, -1,
- /*0x16e5a*/ 1445,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xfb05*/ 1227,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xff37*/ 1256,
- /*0x1e7e*/ 648,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0xfb01*/ 1223,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x16e40*/ 1419,
- -1, -1, -1, -1, -1,
- /*0x118b5*/ 1408,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x04fe*/ 420,
- -1, -1, -1, -1, -1,
- /*0x118b3*/ 1406,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xff35*/ 1254,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0xff33*/ 1252,
- -1, -1, -1, -1, -1,
- /*0x16e54*/ 1439,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x16e58*/ 1443,
- -1, -1, -1, -1, -1,
- /*0x1f0f*/ 722,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x1f0b*/ 718,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x16e55*/ 1440,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x16e45*/ 1424,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x16e59*/ 1444,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xa77e*/ 1104,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x16e49*/ 1428,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x16e43*/ 1422,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x16e4b*/ 1430,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x16e5e*/ 1449,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x16e51*/ 1436,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x16e5c*/ 1447,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x16e4d*/ 1432,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x16e41*/ 1420,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xab74*/ 1146,
- -1, -1, -1, -1,
- /*0xab7c*/ 1154,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0xab72*/ 1144,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xab76*/ 1148,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xab7a*/ 1152,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0xab78*/ 1150,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xab7e*/ 1156
- };
-
- if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseFold_11_hash(code);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code1_equal(code, CaseFold_11_Table[s].from))
- return &CaseFold_11_Table[s].to;
- }
- }
- return 0;
-}
-
-static const CaseUnfold_11_Type CaseUnfold_11_Table[] = {
-#define CaseUnfold_11 (*(CaseUnfold_11_Type (*)[1352])(CaseUnfold_11_Table+0))
- {0x0061, {1|U, {0x0041}}},
- {0x0062, {1|U, {0x0042}}},
- {0x0063, {1|U, {0x0043}}},
- {0x0064, {1|U, {0x0044}}},
- {0x0065, {1|U, {0x0045}}},
- {0x0066, {1|U, {0x0046}}},
- {0x0067, {1|U, {0x0047}}},
- {0x0068, {1|U, {0x0048}}},
- {0x006a, {1|U, {0x004a}}},
- {0x006b, {2|U, {0x004b, 0x212a}}},
- {0x006c, {1|U, {0x004c}}},
- {0x006d, {1|U, {0x004d}}},
- {0x006e, {1|U, {0x004e}}},
- {0x006f, {1|U, {0x004f}}},
- {0x0070, {1|U, {0x0050}}},
- {0x0071, {1|U, {0x0051}}},
- {0x0072, {1|U, {0x0052}}},
- {0x0073, {2|U, {0x0053, 0x017f}}},
- {0x0074, {1|U, {0x0054}}},
- {0x0075, {1|U, {0x0055}}},
- {0x0076, {1|U, {0x0056}}},
- {0x0077, {1|U, {0x0057}}},
- {0x0078, {1|U, {0x0058}}},
- {0x0079, {1|U, {0x0059}}},
- {0x007a, {1|U, {0x005a}}},
- {0x00e0, {1|U, {0x00c0}}},
- {0x00e1, {1|U, {0x00c1}}},
- {0x00e2, {1|U, {0x00c2}}},
- {0x00e3, {1|U, {0x00c3}}},
- {0x00e4, {1|U, {0x00c4}}},
- {0x00e5, {2|U, {0x00c5, 0x212b}}},
- {0x00e6, {1|U, {0x00c6}}},
- {0x00e7, {1|U, {0x00c7}}},
- {0x00e8, {1|U, {0x00c8}}},
- {0x00e9, {1|U, {0x00c9}}},
- {0x00ea, {1|U, {0x00ca}}},
- {0x00eb, {1|U, {0x00cb}}},
- {0x00ec, {1|U, {0x00cc}}},
- {0x00ed, {1|U, {0x00cd}}},
- {0x00ee, {1|U, {0x00ce}}},
- {0x00ef, {1|U, {0x00cf}}},
- {0x00f0, {1|U, {0x00d0}}},
- {0x00f1, {1|U, {0x00d1}}},
- {0x00f2, {1|U, {0x00d2}}},
- {0x00f3, {1|U, {0x00d3}}},
- {0x00f4, {1|U, {0x00d4}}},
- {0x00f5, {1|U, {0x00d5}}},
- {0x00f6, {1|U, {0x00d6}}},
- {0x00f8, {1|U, {0x00d8}}},
- {0x00f9, {1|U, {0x00d9}}},
- {0x00fa, {1|U, {0x00da}}},
- {0x00fb, {1|U, {0x00db}}},
- {0x00fc, {1|U, {0x00dc}}},
- {0x00fd, {1|U, {0x00dd}}},
- {0x00fe, {1|U, {0x00de}}},
- {0x00ff, {1|U, {0x0178}}},
- {0x0101, {1|U, {0x0100}}},
- {0x0103, {1|U, {0x0102}}},
- {0x0105, {1|U, {0x0104}}},
- {0x0107, {1|U, {0x0106}}},
- {0x0109, {1|U, {0x0108}}},
- {0x010b, {1|U, {0x010a}}},
- {0x010d, {1|U, {0x010c}}},
- {0x010f, {1|U, {0x010e}}},
- {0x0111, {1|U, {0x0110}}},
- {0x0113, {1|U, {0x0112}}},
- {0x0115, {1|U, {0x0114}}},
- {0x0117, {1|U, {0x0116}}},
- {0x0119, {1|U, {0x0118}}},
- {0x011b, {1|U, {0x011a}}},
- {0x011d, {1|U, {0x011c}}},
- {0x011f, {1|U, {0x011e}}},
- {0x0121, {1|U, {0x0120}}},
- {0x0123, {1|U, {0x0122}}},
- {0x0125, {1|U, {0x0124}}},
- {0x0127, {1|U, {0x0126}}},
- {0x0129, {1|U, {0x0128}}},
- {0x012b, {1|U, {0x012a}}},
- {0x012d, {1|U, {0x012c}}},
- {0x012f, {1|U, {0x012e}}},
- {0x0133, {1|U, {0x0132}}},
- {0x0135, {1|U, {0x0134}}},
- {0x0137, {1|U, {0x0136}}},
- {0x013a, {1|U, {0x0139}}},
- {0x013c, {1|U, {0x013b}}},
- {0x013e, {1|U, {0x013d}}},
- {0x0140, {1|U, {0x013f}}},
- {0x0142, {1|U, {0x0141}}},
- {0x0144, {1|U, {0x0143}}},
- {0x0146, {1|U, {0x0145}}},
- {0x0148, {1|U, {0x0147}}},
- {0x014b, {1|U, {0x014a}}},
- {0x014d, {1|U, {0x014c}}},
- {0x014f, {1|U, {0x014e}}},
- {0x0151, {1|U, {0x0150}}},
- {0x0153, {1|U, {0x0152}}},
- {0x0155, {1|U, {0x0154}}},
- {0x0157, {1|U, {0x0156}}},
- {0x0159, {1|U, {0x0158}}},
- {0x015b, {1|U, {0x015a}}},
- {0x015d, {1|U, {0x015c}}},
- {0x015f, {1|U, {0x015e}}},
- {0x0161, {1|U, {0x0160}}},
- {0x0163, {1|U, {0x0162}}},
- {0x0165, {1|U, {0x0164}}},
- {0x0167, {1|U, {0x0166}}},
- {0x0169, {1|U, {0x0168}}},
- {0x016b, {1|U, {0x016a}}},
- {0x016d, {1|U, {0x016c}}},
- {0x016f, {1|U, {0x016e}}},
- {0x0171, {1|U, {0x0170}}},
- {0x0173, {1|U, {0x0172}}},
- {0x0175, {1|U, {0x0174}}},
- {0x0177, {1|U, {0x0176}}},
- {0x017a, {1|U, {0x0179}}},
- {0x017c, {1|U, {0x017b}}},
- {0x017e, {1|U, {0x017d}}},
- {0x0180, {1|U, {0x0243}}},
- {0x0183, {1|U, {0x0182}}},
- {0x0185, {1|U, {0x0184}}},
- {0x0188, {1|U, {0x0187}}},
- {0x018c, {1|U, {0x018b}}},
- {0x0192, {1|U, {0x0191}}},
- {0x0195, {1|U, {0x01f6}}},
- {0x0199, {1|U, {0x0198}}},
- {0x019a, {1|U, {0x023d}}},
- {0x019e, {1|U, {0x0220}}},
- {0x01a1, {1|U, {0x01a0}}},
- {0x01a3, {1|U, {0x01a2}}},
- {0x01a5, {1|U, {0x01a4}}},
- {0x01a8, {1|U, {0x01a7}}},
- {0x01ad, {1|U, {0x01ac}}},
- {0x01b0, {1|U, {0x01af}}},
- {0x01b4, {1|U, {0x01b3}}},
- {0x01b6, {1|U, {0x01b5}}},
- {0x01b9, {1|U, {0x01b8}}},
- {0x01bd, {1|U, {0x01bc}}},
- {0x01bf, {1|U, {0x01f7}}},
- {0x01c6, {2|U|ST, {0x01c4, 0x01c5}}},
- {0x01c9, {2|U|ST, {0x01c7, 0x01c8}}},
- {0x01cc, {2|U|ST, {0x01ca, 0x01cb}}},
- {0x01ce, {1|U, {0x01cd}}},
- {0x01d0, {1|U, {0x01cf}}},
- {0x01d2, {1|U, {0x01d1}}},
- {0x01d4, {1|U, {0x01d3}}},
- {0x01d6, {1|U, {0x01d5}}},
- {0x01d8, {1|U, {0x01d7}}},
- {0x01da, {1|U, {0x01d9}}},
- {0x01dc, {1|U, {0x01db}}},
- {0x01dd, {1|U, {0x018e}}},
- {0x01df, {1|U, {0x01de}}},
- {0x01e1, {1|U, {0x01e0}}},
- {0x01e3, {1|U, {0x01e2}}},
- {0x01e5, {1|U, {0x01e4}}},
- {0x01e7, {1|U, {0x01e6}}},
- {0x01e9, {1|U, {0x01e8}}},
- {0x01eb, {1|U, {0x01ea}}},
- {0x01ed, {1|U, {0x01ec}}},
- {0x01ef, {1|U, {0x01ee}}},
- {0x01f3, {2|U|ST, {0x01f1, 0x01f2}}},
- {0x01f5, {1|U, {0x01f4}}},
- {0x01f9, {1|U, {0x01f8}}},
- {0x01fb, {1|U, {0x01fa}}},
- {0x01fd, {1|U, {0x01fc}}},
- {0x01ff, {1|U, {0x01fe}}},
- {0x0201, {1|U, {0x0200}}},
- {0x0203, {1|U, {0x0202}}},
- {0x0205, {1|U, {0x0204}}},
- {0x0207, {1|U, {0x0206}}},
- {0x0209, {1|U, {0x0208}}},
- {0x020b, {1|U, {0x020a}}},
- {0x020d, {1|U, {0x020c}}},
- {0x020f, {1|U, {0x020e}}},
- {0x0211, {1|U, {0x0210}}},
- {0x0213, {1|U, {0x0212}}},
- {0x0215, {1|U, {0x0214}}},
- {0x0217, {1|U, {0x0216}}},
- {0x0219, {1|U, {0x0218}}},
- {0x021b, {1|U, {0x021a}}},
- {0x021d, {1|U, {0x021c}}},
- {0x021f, {1|U, {0x021e}}},
- {0x0223, {1|U, {0x0222}}},
- {0x0225, {1|U, {0x0224}}},
- {0x0227, {1|U, {0x0226}}},
- {0x0229, {1|U, {0x0228}}},
- {0x022b, {1|U, {0x022a}}},
- {0x022d, {1|U, {0x022c}}},
- {0x022f, {1|U, {0x022e}}},
- {0x0231, {1|U, {0x0230}}},
- {0x0233, {1|U, {0x0232}}},
- {0x023c, {1|U, {0x023b}}},
- {0x023f, {1|U, {0x2c7e}}},
- {0x0240, {1|U, {0x2c7f}}},
- {0x0242, {1|U, {0x0241}}},
- {0x0247, {1|U, {0x0246}}},
- {0x0249, {1|U, {0x0248}}},
- {0x024b, {1|U, {0x024a}}},
- {0x024d, {1|U, {0x024c}}},
- {0x024f, {1|U, {0x024e}}},
- {0x0250, {1|U, {0x2c6f}}},
- {0x0251, {1|U, {0x2c6d}}},
- {0x0252, {1|U, {0x2c70}}},
- {0x0253, {1|U, {0x0181}}},
- {0x0254, {1|U, {0x0186}}},
- {0x0256, {1|U, {0x0189}}},
- {0x0257, {1|U, {0x018a}}},
- {0x0259, {1|U, {0x018f}}},
- {0x025b, {1|U, {0x0190}}},
- {0x025c, {1|U, {0xa7ab}}},
- {0x0260, {1|U, {0x0193}}},
- {0x0261, {1|U, {0xa7ac}}},
- {0x0263, {1|U, {0x0194}}},
- {0x0265, {1|U, {0xa78d}}},
- {0x0266, {1|U, {0xa7aa}}},
- {0x0268, {1|U, {0x0197}}},
- {0x0269, {1|U, {0x0196}}},
- {0x026a, {1|U, {0xa7ae}}},
- {0x026b, {1|U, {0x2c62}}},
- {0x026c, {1|U, {0xa7ad}}},
- {0x026f, {1|U, {0x019c}}},
- {0x0271, {1|U, {0x2c6e}}},
- {0x0272, {1|U, {0x019d}}},
- {0x0275, {1|U, {0x019f}}},
- {0x027d, {1|U, {0x2c64}}},
- {0x0280, {1|U, {0x01a6}}},
- {0x0282, {1|U, {0xa7c5}}},
- {0x0283, {1|U, {0x01a9}}},
- {0x0287, {1|U, {0xa7b1}}},
- {0x0288, {1|U, {0x01ae}}},
- {0x0289, {1|U, {0x0244}}},
- {0x028a, {1|U, {0x01b1}}},
- {0x028b, {1|U, {0x01b2}}},
- {0x028c, {1|U, {0x0245}}},
- {0x0292, {1|U, {0x01b7}}},
- {0x029d, {1|U, {0xa7b2}}},
- {0x029e, {1|U, {0xa7b0}}},
- {0x0371, {1|U, {0x0370}}},
- {0x0373, {1|U, {0x0372}}},
- {0x0377, {1|U, {0x0376}}},
- {0x037b, {1|U, {0x03fd}}},
- {0x037c, {1|U, {0x03fe}}},
- {0x037d, {1|U, {0x03ff}}},
- {0x03ac, {1|U, {0x0386}}},
- {0x03ad, {1|U, {0x0388}}},
- {0x03ae, {1|U, {0x0389}}},
- {0x03af, {1|U, {0x038a}}},
- {0x03b1, {1|U, {0x0391}}},
- {0x03b2, {2|U, {0x0392, 0x03d0}}},
- {0x03b3, {1|U, {0x0393}}},
- {0x03b4, {1|U, {0x0394}}},
- {0x03b5, {2|U, {0x0395, 0x03f5}}},
- {0x03b6, {1|U, {0x0396}}},
- {0x03b7, {1|U, {0x0397}}},
- {0x03b8, {3|U, {0x0398, 0x03d1, 0x03f4}}},
- {0x03b9, {3|U, {0x0399, 0x0345, 0x1fbe}}},
- {0x03ba, {2|U, {0x039a, 0x03f0}}},
- {0x03bb, {1|U, {0x039b}}},
- {0x03bc, {2|U, {0x039c, 0x00b5}}},
- {0x03bd, {1|U, {0x039d}}},
- {0x03be, {1|U, {0x039e}}},
- {0x03bf, {1|U, {0x039f}}},
- {0x03c0, {2|U, {0x03a0, 0x03d6}}},
- {0x03c1, {2|U, {0x03a1, 0x03f1}}},
- {0x03c3, {2|U, {0x03a3, 0x03c2}}},
- {0x03c4, {1|U, {0x03a4}}},
- {0x03c5, {1|U, {0x03a5}}},
- {0x03c6, {2|U, {0x03a6, 0x03d5}}},
- {0x03c7, {1|U, {0x03a7}}},
- {0x03c8, {1|U, {0x03a8}}},
- {0x03c9, {2|U, {0x03a9, 0x2126}}},
- {0x03ca, {1|U, {0x03aa}}},
- {0x03cb, {1|U, {0x03ab}}},
- {0x03cc, {1|U, {0x038c}}},
- {0x03cd, {1|U, {0x038e}}},
- {0x03ce, {1|U, {0x038f}}},
- {0x03d7, {1|U, {0x03cf}}},
- {0x03d9, {1|U, {0x03d8}}},
- {0x03db, {1|U, {0x03da}}},
- {0x03dd, {1|U, {0x03dc}}},
- {0x03df, {1|U, {0x03de}}},
- {0x03e1, {1|U, {0x03e0}}},
- {0x03e3, {1|U, {0x03e2}}},
- {0x03e5, {1|U, {0x03e4}}},
- {0x03e7, {1|U, {0x03e6}}},
- {0x03e9, {1|U, {0x03e8}}},
- {0x03eb, {1|U, {0x03ea}}},
- {0x03ed, {1|U, {0x03ec}}},
- {0x03ef, {1|U, {0x03ee}}},
- {0x03f2, {1|U, {0x03f9}}},
- {0x03f3, {1|U, {0x037f}}},
- {0x03f8, {1|U, {0x03f7}}},
- {0x03fb, {1|U, {0x03fa}}},
- {0x0430, {1|U, {0x0410}}},
- {0x0431, {1|U, {0x0411}}},
- {0x0432, {2|U, {0x0412, 0x1c80}}},
- {0x0433, {1|U, {0x0413}}},
- {0x0434, {2|U, {0x0414, 0x1c81}}},
- {0x0435, {1|U, {0x0415}}},
- {0x0436, {1|U, {0x0416}}},
- {0x0437, {1|U, {0x0417}}},
- {0x0438, {1|U, {0x0418}}},
- {0x0439, {1|U, {0x0419}}},
- {0x043a, {1|U, {0x041a}}},
- {0x043b, {1|U, {0x041b}}},
- {0x043c, {1|U, {0x041c}}},
- {0x043d, {1|U, {0x041d}}},
- {0x043e, {2|U, {0x041e, 0x1c82}}},
- {0x043f, {1|U, {0x041f}}},
- {0x0440, {1|U, {0x0420}}},
- {0x0441, {2|U, {0x0421, 0x1c83}}},
- {0x0442, {3|U, {0x0422, 0x1c84, 0x1c85}}},
- {0x0443, {1|U, {0x0423}}},
- {0x0444, {1|U, {0x0424}}},
- {0x0445, {1|U, {0x0425}}},
- {0x0446, {1|U, {0x0426}}},
- {0x0447, {1|U, {0x0427}}},
- {0x0448, {1|U, {0x0428}}},
- {0x0449, {1|U, {0x0429}}},
- {0x044a, {2|U, {0x042a, 0x1c86}}},
- {0x044b, {1|U, {0x042b}}},
- {0x044c, {1|U, {0x042c}}},
- {0x044d, {1|U, {0x042d}}},
- {0x044e, {1|U, {0x042e}}},
- {0x044f, {1|U, {0x042f}}},
- {0x0450, {1|U, {0x0400}}},
- {0x0451, {1|U, {0x0401}}},
- {0x0452, {1|U, {0x0402}}},
- {0x0453, {1|U, {0x0403}}},
- {0x0454, {1|U, {0x0404}}},
- {0x0455, {1|U, {0x0405}}},
- {0x0456, {1|U, {0x0406}}},
- {0x0457, {1|U, {0x0407}}},
- {0x0458, {1|U, {0x0408}}},
- {0x0459, {1|U, {0x0409}}},
- {0x045a, {1|U, {0x040a}}},
- {0x045b, {1|U, {0x040b}}},
- {0x045c, {1|U, {0x040c}}},
- {0x045d, {1|U, {0x040d}}},
- {0x045e, {1|U, {0x040e}}},
- {0x045f, {1|U, {0x040f}}},
- {0x0461, {1|U, {0x0460}}},
- {0x0463, {2|U, {0x0462, 0x1c87}}},
- {0x0465, {1|U, {0x0464}}},
- {0x0467, {1|U, {0x0466}}},
- {0x0469, {1|U, {0x0468}}},
- {0x046b, {1|U, {0x046a}}},
- {0x046d, {1|U, {0x046c}}},
- {0x046f, {1|U, {0x046e}}},
- {0x0471, {1|U, {0x0470}}},
- {0x0473, {1|U, {0x0472}}},
- {0x0475, {1|U, {0x0474}}},
- {0x0477, {1|U, {0x0476}}},
- {0x0479, {1|U, {0x0478}}},
- {0x047b, {1|U, {0x047a}}},
- {0x047d, {1|U, {0x047c}}},
- {0x047f, {1|U, {0x047e}}},
- {0x0481, {1|U, {0x0480}}},
- {0x048b, {1|U, {0x048a}}},
- {0x048d, {1|U, {0x048c}}},
- {0x048f, {1|U, {0x048e}}},
- {0x0491, {1|U, {0x0490}}},
- {0x0493, {1|U, {0x0492}}},
- {0x0495, {1|U, {0x0494}}},
- {0x0497, {1|U, {0x0496}}},
- {0x0499, {1|U, {0x0498}}},
- {0x049b, {1|U, {0x049a}}},
- {0x049d, {1|U, {0x049c}}},
- {0x049f, {1|U, {0x049e}}},
- {0x04a1, {1|U, {0x04a0}}},
- {0x04a3, {1|U, {0x04a2}}},
- {0x04a5, {1|U, {0x04a4}}},
- {0x04a7, {1|U, {0x04a6}}},
- {0x04a9, {1|U, {0x04a8}}},
- {0x04ab, {1|U, {0x04aa}}},
- {0x04ad, {1|U, {0x04ac}}},
- {0x04af, {1|U, {0x04ae}}},
- {0x04b1, {1|U, {0x04b0}}},
- {0x04b3, {1|U, {0x04b2}}},
- {0x04b5, {1|U, {0x04b4}}},
- {0x04b7, {1|U, {0x04b6}}},
- {0x04b9, {1|U, {0x04b8}}},
- {0x04bb, {1|U, {0x04ba}}},
- {0x04bd, {1|U, {0x04bc}}},
- {0x04bf, {1|U, {0x04be}}},
- {0x04c2, {1|U, {0x04c1}}},
- {0x04c4, {1|U, {0x04c3}}},
- {0x04c6, {1|U, {0x04c5}}},
- {0x04c8, {1|U, {0x04c7}}},
- {0x04ca, {1|U, {0x04c9}}},
- {0x04cc, {1|U, {0x04cb}}},
- {0x04ce, {1|U, {0x04cd}}},
- {0x04cf, {1|U, {0x04c0}}},
- {0x04d1, {1|U, {0x04d0}}},
- {0x04d3, {1|U, {0x04d2}}},
- {0x04d5, {1|U, {0x04d4}}},
- {0x04d7, {1|U, {0x04d6}}},
- {0x04d9, {1|U, {0x04d8}}},
- {0x04db, {1|U, {0x04da}}},
- {0x04dd, {1|U, {0x04dc}}},
- {0x04df, {1|U, {0x04de}}},
- {0x04e1, {1|U, {0x04e0}}},
- {0x04e3, {1|U, {0x04e2}}},
- {0x04e5, {1|U, {0x04e4}}},
- {0x04e7, {1|U, {0x04e6}}},
- {0x04e9, {1|U, {0x04e8}}},
- {0x04eb, {1|U, {0x04ea}}},
- {0x04ed, {1|U, {0x04ec}}},
- {0x04ef, {1|U, {0x04ee}}},
- {0x04f1, {1|U, {0x04f0}}},
- {0x04f3, {1|U, {0x04f2}}},
- {0x04f5, {1|U, {0x04f4}}},
- {0x04f7, {1|U, {0x04f6}}},
- {0x04f9, {1|U, {0x04f8}}},
- {0x04fb, {1|U, {0x04fa}}},
- {0x04fd, {1|U, {0x04fc}}},
- {0x04ff, {1|U, {0x04fe}}},
- {0x0501, {1|U, {0x0500}}},
- {0x0503, {1|U, {0x0502}}},
- {0x0505, {1|U, {0x0504}}},
- {0x0507, {1|U, {0x0506}}},
- {0x0509, {1|U, {0x0508}}},
- {0x050b, {1|U, {0x050a}}},
- {0x050d, {1|U, {0x050c}}},
- {0x050f, {1|U, {0x050e}}},
- {0x0511, {1|U, {0x0510}}},
- {0x0513, {1|U, {0x0512}}},
- {0x0515, {1|U, {0x0514}}},
- {0x0517, {1|U, {0x0516}}},
- {0x0519, {1|U, {0x0518}}},
- {0x051b, {1|U, {0x051a}}},
- {0x051d, {1|U, {0x051c}}},
- {0x051f, {1|U, {0x051e}}},
- {0x0521, {1|U, {0x0520}}},
- {0x0523, {1|U, {0x0522}}},
- {0x0525, {1|U, {0x0524}}},
- {0x0527, {1|U, {0x0526}}},
- {0x0529, {1|U, {0x0528}}},
- {0x052b, {1|U, {0x052a}}},
- {0x052d, {1|U, {0x052c}}},
- {0x052f, {1|U, {0x052e}}},
- {0x0561, {1|U, {0x0531}}},
- {0x0562, {1|U, {0x0532}}},
- {0x0563, {1|U, {0x0533}}},
- {0x0564, {1|U, {0x0534}}},
- {0x0565, {1|U, {0x0535}}},
- {0x0566, {1|U, {0x0536}}},
- {0x0567, {1|U, {0x0537}}},
- {0x0568, {1|U, {0x0538}}},
- {0x0569, {1|U, {0x0539}}},
- {0x056a, {1|U, {0x053a}}},
- {0x056b, {1|U, {0x053b}}},
- {0x056c, {1|U, {0x053c}}},
- {0x056d, {1|U, {0x053d}}},
- {0x056e, {1|U, {0x053e}}},
- {0x056f, {1|U, {0x053f}}},
- {0x0570, {1|U, {0x0540}}},
- {0x0571, {1|U, {0x0541}}},
- {0x0572, {1|U, {0x0542}}},
- {0x0573, {1|U, {0x0543}}},
- {0x0574, {1|U, {0x0544}}},
- {0x0575, {1|U, {0x0545}}},
- {0x0576, {1|U, {0x0546}}},
- {0x0577, {1|U, {0x0547}}},
- {0x0578, {1|U, {0x0548}}},
- {0x0579, {1|U, {0x0549}}},
- {0x057a, {1|U, {0x054a}}},
- {0x057b, {1|U, {0x054b}}},
- {0x057c, {1|U, {0x054c}}},
- {0x057d, {1|U, {0x054d}}},
- {0x057e, {1|U, {0x054e}}},
- {0x057f, {1|U, {0x054f}}},
- {0x0580, {1|U, {0x0550}}},
- {0x0581, {1|U, {0x0551}}},
- {0x0582, {1|U, {0x0552}}},
- {0x0583, {1|U, {0x0553}}},
- {0x0584, {1|U, {0x0554}}},
- {0x0585, {1|U, {0x0555}}},
- {0x0586, {1|U, {0x0556}}},
- {0x10d0, {1|U|IT, {0x1c90}}},
- {0x10d1, {1|U|IT, {0x1c91}}},
- {0x10d2, {1|U|IT, {0x1c92}}},
- {0x10d3, {1|U|IT, {0x1c93}}},
- {0x10d4, {1|U|IT, {0x1c94}}},
- {0x10d5, {1|U|IT, {0x1c95}}},
- {0x10d6, {1|U|IT, {0x1c96}}},
- {0x10d7, {1|U|IT, {0x1c97}}},
- {0x10d8, {1|U|IT, {0x1c98}}},
- {0x10d9, {1|U|IT, {0x1c99}}},
- {0x10da, {1|U|IT, {0x1c9a}}},
- {0x10db, {1|U|IT, {0x1c9b}}},
- {0x10dc, {1|U|IT, {0x1c9c}}},
- {0x10dd, {1|U|IT, {0x1c9d}}},
- {0x10de, {1|U|IT, {0x1c9e}}},
- {0x10df, {1|U|IT, {0x1c9f}}},
- {0x10e0, {1|U|IT, {0x1ca0}}},
- {0x10e1, {1|U|IT, {0x1ca1}}},
- {0x10e2, {1|U|IT, {0x1ca2}}},
- {0x10e3, {1|U|IT, {0x1ca3}}},
- {0x10e4, {1|U|IT, {0x1ca4}}},
- {0x10e5, {1|U|IT, {0x1ca5}}},
- {0x10e6, {1|U|IT, {0x1ca6}}},
- {0x10e7, {1|U|IT, {0x1ca7}}},
- {0x10e8, {1|U|IT, {0x1ca8}}},
- {0x10e9, {1|U|IT, {0x1ca9}}},
- {0x10ea, {1|U|IT, {0x1caa}}},
- {0x10eb, {1|U|IT, {0x1cab}}},
- {0x10ec, {1|U|IT, {0x1cac}}},
- {0x10ed, {1|U|IT, {0x1cad}}},
- {0x10ee, {1|U|IT, {0x1cae}}},
- {0x10ef, {1|U|IT, {0x1caf}}},
- {0x10f0, {1|U|IT, {0x1cb0}}},
- {0x10f1, {1|U|IT, {0x1cb1}}},
- {0x10f2, {1|U|IT, {0x1cb2}}},
- {0x10f3, {1|U|IT, {0x1cb3}}},
- {0x10f4, {1|U|IT, {0x1cb4}}},
- {0x10f5, {1|U|IT, {0x1cb5}}},
- {0x10f6, {1|U|IT, {0x1cb6}}},
- {0x10f7, {1|U|IT, {0x1cb7}}},
- {0x10f8, {1|U|IT, {0x1cb8}}},
- {0x10f9, {1|U|IT, {0x1cb9}}},
- {0x10fa, {1|U|IT, {0x1cba}}},
- {0x10fd, {1|U|IT, {0x1cbd}}},
- {0x10fe, {1|U|IT, {0x1cbe}}},
- {0x10ff, {1|U|IT, {0x1cbf}}},
- {0x13a0, {1|D, {0xab70}}},
- {0x13a1, {1|D, {0xab71}}},
- {0x13a2, {1|D, {0xab72}}},
- {0x13a3, {1|D, {0xab73}}},
- {0x13a4, {1|D, {0xab74}}},
- {0x13a5, {1|D, {0xab75}}},
- {0x13a6, {1|D, {0xab76}}},
- {0x13a7, {1|D, {0xab77}}},
- {0x13a8, {1|D, {0xab78}}},
- {0x13a9, {1|D, {0xab79}}},
- {0x13aa, {1|D, {0xab7a}}},
- {0x13ab, {1|D, {0xab7b}}},
- {0x13ac, {1|D, {0xab7c}}},
- {0x13ad, {1|D, {0xab7d}}},
- {0x13ae, {1|D, {0xab7e}}},
- {0x13af, {1|D, {0xab7f}}},
- {0x13b0, {1|D, {0xab80}}},
- {0x13b1, {1|D, {0xab81}}},
- {0x13b2, {1|D, {0xab82}}},
- {0x13b3, {1|D, {0xab83}}},
- {0x13b4, {1|D, {0xab84}}},
- {0x13b5, {1|D, {0xab85}}},
- {0x13b6, {1|D, {0xab86}}},
- {0x13b7, {1|D, {0xab87}}},
- {0x13b8, {1|D, {0xab88}}},
- {0x13b9, {1|D, {0xab89}}},
- {0x13ba, {1|D, {0xab8a}}},
- {0x13bb, {1|D, {0xab8b}}},
- {0x13bc, {1|D, {0xab8c}}},
- {0x13bd, {1|D, {0xab8d}}},
- {0x13be, {1|D, {0xab8e}}},
- {0x13bf, {1|D, {0xab8f}}},
- {0x13c0, {1|D, {0xab90}}},
- {0x13c1, {1|D, {0xab91}}},
- {0x13c2, {1|D, {0xab92}}},
- {0x13c3, {1|D, {0xab93}}},
- {0x13c4, {1|D, {0xab94}}},
- {0x13c5, {1|D, {0xab95}}},
- {0x13c6, {1|D, {0xab96}}},
- {0x13c7, {1|D, {0xab97}}},
- {0x13c8, {1|D, {0xab98}}},
- {0x13c9, {1|D, {0xab99}}},
- {0x13ca, {1|D, {0xab9a}}},
- {0x13cb, {1|D, {0xab9b}}},
- {0x13cc, {1|D, {0xab9c}}},
- {0x13cd, {1|D, {0xab9d}}},
- {0x13ce, {1|D, {0xab9e}}},
- {0x13cf, {1|D, {0xab9f}}},
- {0x13d0, {1|D, {0xaba0}}},
- {0x13d1, {1|D, {0xaba1}}},
- {0x13d2, {1|D, {0xaba2}}},
- {0x13d3, {1|D, {0xaba3}}},
- {0x13d4, {1|D, {0xaba4}}},
- {0x13d5, {1|D, {0xaba5}}},
- {0x13d6, {1|D, {0xaba6}}},
- {0x13d7, {1|D, {0xaba7}}},
- {0x13d8, {1|D, {0xaba8}}},
- {0x13d9, {1|D, {0xaba9}}},
- {0x13da, {1|D, {0xabaa}}},
- {0x13db, {1|D, {0xabab}}},
- {0x13dc, {1|D, {0xabac}}},
- {0x13dd, {1|D, {0xabad}}},
- {0x13de, {1|D, {0xabae}}},
- {0x13df, {1|D, {0xabaf}}},
- {0x13e0, {1|D, {0xabb0}}},
- {0x13e1, {1|D, {0xabb1}}},
- {0x13e2, {1|D, {0xabb2}}},
- {0x13e3, {1|D, {0xabb3}}},
- {0x13e4, {1|D, {0xabb4}}},
- {0x13e5, {1|D, {0xabb5}}},
- {0x13e6, {1|D, {0xabb6}}},
- {0x13e7, {1|D, {0xabb7}}},
- {0x13e8, {1|D, {0xabb8}}},
- {0x13e9, {1|D, {0xabb9}}},
- {0x13ea, {1|D, {0xabba}}},
- {0x13eb, {1|D, {0xabbb}}},
- {0x13ec, {1|D, {0xabbc}}},
- {0x13ed, {1|D, {0xabbd}}},
- {0x13ee, {1|D, {0xabbe}}},
- {0x13ef, {1|D, {0xabbf}}},
- {0x13f0, {1|D, {0x13f8}}},
- {0x13f1, {1|D, {0x13f9}}},
- {0x13f2, {1|D, {0x13fa}}},
- {0x13f3, {1|D, {0x13fb}}},
- {0x13f4, {1|D, {0x13fc}}},
- {0x13f5, {1|D, {0x13fd}}},
- {0x1d79, {1|U, {0xa77d}}},
- {0x1d7d, {1|U, {0x2c63}}},
- {0x1d8e, {1|U, {0xa7c6}}},
- {0x1e01, {1|U, {0x1e00}}},
- {0x1e03, {1|U, {0x1e02}}},
- {0x1e05, {1|U, {0x1e04}}},
- {0x1e07, {1|U, {0x1e06}}},
- {0x1e09, {1|U, {0x1e08}}},
- {0x1e0b, {1|U, {0x1e0a}}},
- {0x1e0d, {1|U, {0x1e0c}}},
- {0x1e0f, {1|U, {0x1e0e}}},
- {0x1e11, {1|U, {0x1e10}}},
- {0x1e13, {1|U, {0x1e12}}},
- {0x1e15, {1|U, {0x1e14}}},
- {0x1e17, {1|U, {0x1e16}}},
- {0x1e19, {1|U, {0x1e18}}},
- {0x1e1b, {1|U, {0x1e1a}}},
- {0x1e1d, {1|U, {0x1e1c}}},
- {0x1e1f, {1|U, {0x1e1e}}},
- {0x1e21, {1|U, {0x1e20}}},
- {0x1e23, {1|U, {0x1e22}}},
- {0x1e25, {1|U, {0x1e24}}},
- {0x1e27, {1|U, {0x1e26}}},
- {0x1e29, {1|U, {0x1e28}}},
- {0x1e2b, {1|U, {0x1e2a}}},
- {0x1e2d, {1|U, {0x1e2c}}},
- {0x1e2f, {1|U, {0x1e2e}}},
- {0x1e31, {1|U, {0x1e30}}},
- {0x1e33, {1|U, {0x1e32}}},
- {0x1e35, {1|U, {0x1e34}}},
- {0x1e37, {1|U, {0x1e36}}},
- {0x1e39, {1|U, {0x1e38}}},
- {0x1e3b, {1|U, {0x1e3a}}},
- {0x1e3d, {1|U, {0x1e3c}}},
- {0x1e3f, {1|U, {0x1e3e}}},
- {0x1e41, {1|U, {0x1e40}}},
- {0x1e43, {1|U, {0x1e42}}},
- {0x1e45, {1|U, {0x1e44}}},
- {0x1e47, {1|U, {0x1e46}}},
- {0x1e49, {1|U, {0x1e48}}},
- {0x1e4b, {1|U, {0x1e4a}}},
- {0x1e4d, {1|U, {0x1e4c}}},
- {0x1e4f, {1|U, {0x1e4e}}},
- {0x1e51, {1|U, {0x1e50}}},
- {0x1e53, {1|U, {0x1e52}}},
- {0x1e55, {1|U, {0x1e54}}},
- {0x1e57, {1|U, {0x1e56}}},
- {0x1e59, {1|U, {0x1e58}}},
- {0x1e5b, {1|U, {0x1e5a}}},
- {0x1e5d, {1|U, {0x1e5c}}},
- {0x1e5f, {1|U, {0x1e5e}}},
- {0x1e61, {2|U, {0x1e60, 0x1e9b}}},
- {0x1e63, {1|U, {0x1e62}}},
- {0x1e65, {1|U, {0x1e64}}},
- {0x1e67, {1|U, {0x1e66}}},
- {0x1e69, {1|U, {0x1e68}}},
- {0x1e6b, {1|U, {0x1e6a}}},
- {0x1e6d, {1|U, {0x1e6c}}},
- {0x1e6f, {1|U, {0x1e6e}}},
- {0x1e71, {1|U, {0x1e70}}},
- {0x1e73, {1|U, {0x1e72}}},
- {0x1e75, {1|U, {0x1e74}}},
- {0x1e77, {1|U, {0x1e76}}},
- {0x1e79, {1|U, {0x1e78}}},
- {0x1e7b, {1|U, {0x1e7a}}},
- {0x1e7d, {1|U, {0x1e7c}}},
- {0x1e7f, {1|U, {0x1e7e}}},
- {0x1e81, {1|U, {0x1e80}}},
- {0x1e83, {1|U, {0x1e82}}},
- {0x1e85, {1|U, {0x1e84}}},
- {0x1e87, {1|U, {0x1e86}}},
- {0x1e89, {1|U, {0x1e88}}},
- {0x1e8b, {1|U, {0x1e8a}}},
- {0x1e8d, {1|U, {0x1e8c}}},
- {0x1e8f, {1|U, {0x1e8e}}},
- {0x1e91, {1|U, {0x1e90}}},
- {0x1e93, {1|U, {0x1e92}}},
- {0x1e95, {1|U, {0x1e94}}},
- {0x1ea1, {1|U, {0x1ea0}}},
- {0x1ea3, {1|U, {0x1ea2}}},
- {0x1ea5, {1|U, {0x1ea4}}},
- {0x1ea7, {1|U, {0x1ea6}}},
- {0x1ea9, {1|U, {0x1ea8}}},
- {0x1eab, {1|U, {0x1eaa}}},
- {0x1ead, {1|U, {0x1eac}}},
- {0x1eaf, {1|U, {0x1eae}}},
- {0x1eb1, {1|U, {0x1eb0}}},
- {0x1eb3, {1|U, {0x1eb2}}},
- {0x1eb5, {1|U, {0x1eb4}}},
- {0x1eb7, {1|U, {0x1eb6}}},
- {0x1eb9, {1|U, {0x1eb8}}},
- {0x1ebb, {1|U, {0x1eba}}},
- {0x1ebd, {1|U, {0x1ebc}}},
- {0x1ebf, {1|U, {0x1ebe}}},
- {0x1ec1, {1|U, {0x1ec0}}},
- {0x1ec3, {1|U, {0x1ec2}}},
- {0x1ec5, {1|U, {0x1ec4}}},
- {0x1ec7, {1|U, {0x1ec6}}},
- {0x1ec9, {1|U, {0x1ec8}}},
- {0x1ecb, {1|U, {0x1eca}}},
- {0x1ecd, {1|U, {0x1ecc}}},
- {0x1ecf, {1|U, {0x1ece}}},
- {0x1ed1, {1|U, {0x1ed0}}},
- {0x1ed3, {1|U, {0x1ed2}}},
- {0x1ed5, {1|U, {0x1ed4}}},
- {0x1ed7, {1|U, {0x1ed6}}},
- {0x1ed9, {1|U, {0x1ed8}}},
- {0x1edb, {1|U, {0x1eda}}},
- {0x1edd, {1|U, {0x1edc}}},
- {0x1edf, {1|U, {0x1ede}}},
- {0x1ee1, {1|U, {0x1ee0}}},
- {0x1ee3, {1|U, {0x1ee2}}},
- {0x1ee5, {1|U, {0x1ee4}}},
- {0x1ee7, {1|U, {0x1ee6}}},
- {0x1ee9, {1|U, {0x1ee8}}},
- {0x1eeb, {1|U, {0x1eea}}},
- {0x1eed, {1|U, {0x1eec}}},
- {0x1eef, {1|U, {0x1eee}}},
- {0x1ef1, {1|U, {0x1ef0}}},
- {0x1ef3, {1|U, {0x1ef2}}},
- {0x1ef5, {1|U, {0x1ef4}}},
- {0x1ef7, {1|U, {0x1ef6}}},
- {0x1ef9, {1|U, {0x1ef8}}},
- {0x1efb, {1|U, {0x1efa}}},
- {0x1efd, {1|U, {0x1efc}}},
- {0x1eff, {1|U, {0x1efe}}},
- {0x1f00, {1|U, {0x1f08}}},
- {0x1f01, {1|U, {0x1f09}}},
- {0x1f02, {1|U, {0x1f0a}}},
- {0x1f03, {1|U, {0x1f0b}}},
- {0x1f04, {1|U, {0x1f0c}}},
- {0x1f05, {1|U, {0x1f0d}}},
- {0x1f06, {1|U, {0x1f0e}}},
- {0x1f07, {1|U, {0x1f0f}}},
- {0x1f10, {1|U, {0x1f18}}},
- {0x1f11, {1|U, {0x1f19}}},
- {0x1f12, {1|U, {0x1f1a}}},
- {0x1f13, {1|U, {0x1f1b}}},
- {0x1f14, {1|U, {0x1f1c}}},
- {0x1f15, {1|U, {0x1f1d}}},
- {0x1f20, {1|U, {0x1f28}}},
- {0x1f21, {1|U, {0x1f29}}},
- {0x1f22, {1|U, {0x1f2a}}},
- {0x1f23, {1|U, {0x1f2b}}},
- {0x1f24, {1|U, {0x1f2c}}},
- {0x1f25, {1|U, {0x1f2d}}},
- {0x1f26, {1|U, {0x1f2e}}},
- {0x1f27, {1|U, {0x1f2f}}},
- {0x1f30, {1|U, {0x1f38}}},
- {0x1f31, {1|U, {0x1f39}}},
- {0x1f32, {1|U, {0x1f3a}}},
- {0x1f33, {1|U, {0x1f3b}}},
- {0x1f34, {1|U, {0x1f3c}}},
- {0x1f35, {1|U, {0x1f3d}}},
- {0x1f36, {1|U, {0x1f3e}}},
- {0x1f37, {1|U, {0x1f3f}}},
- {0x1f40, {1|U, {0x1f48}}},
- {0x1f41, {1|U, {0x1f49}}},
- {0x1f42, {1|U, {0x1f4a}}},
- {0x1f43, {1|U, {0x1f4b}}},
- {0x1f44, {1|U, {0x1f4c}}},
- {0x1f45, {1|U, {0x1f4d}}},
- {0x1f51, {1|U, {0x1f59}}},
- {0x1f53, {1|U, {0x1f5b}}},
- {0x1f55, {1|U, {0x1f5d}}},
- {0x1f57, {1|U, {0x1f5f}}},
- {0x1f60, {1|U, {0x1f68}}},
- {0x1f61, {1|U, {0x1f69}}},
- {0x1f62, {1|U, {0x1f6a}}},
- {0x1f63, {1|U, {0x1f6b}}},
- {0x1f64, {1|U, {0x1f6c}}},
- {0x1f65, {1|U, {0x1f6d}}},
- {0x1f66, {1|U, {0x1f6e}}},
- {0x1f67, {1|U, {0x1f6f}}},
- {0x1f70, {1|U, {0x1fba}}},
- {0x1f71, {1|U, {0x1fbb}}},
- {0x1f72, {1|U, {0x1fc8}}},
- {0x1f73, {1|U, {0x1fc9}}},
- {0x1f74, {1|U, {0x1fca}}},
- {0x1f75, {1|U, {0x1fcb}}},
- {0x1f76, {1|U, {0x1fda}}},
- {0x1f77, {1|U, {0x1fdb}}},
- {0x1f78, {1|U, {0x1ff8}}},
- {0x1f79, {1|U, {0x1ff9}}},
- {0x1f7a, {1|U, {0x1fea}}},
- {0x1f7b, {1|U, {0x1feb}}},
- {0x1f7c, {1|U, {0x1ffa}}},
- {0x1f7d, {1|U, {0x1ffb}}},
- {0x1fb0, {1|U, {0x1fb8}}},
- {0x1fb1, {1|U, {0x1fb9}}},
- {0x1fd0, {1|U, {0x1fd8}}},
- {0x1fd1, {1|U, {0x1fd9}}},
- {0x1fe0, {1|U, {0x1fe8}}},
- {0x1fe1, {1|U, {0x1fe9}}},
- {0x1fe5, {1|U, {0x1fec}}},
- {0x214e, {1|U, {0x2132}}},
- {0x2170, {1|U, {0x2160}}},
- {0x2171, {1|U, {0x2161}}},
- {0x2172, {1|U, {0x2162}}},
- {0x2173, {1|U, {0x2163}}},
- {0x2174, {1|U, {0x2164}}},
- {0x2175, {1|U, {0x2165}}},
- {0x2176, {1|U, {0x2166}}},
- {0x2177, {1|U, {0x2167}}},
- {0x2178, {1|U, {0x2168}}},
- {0x2179, {1|U, {0x2169}}},
- {0x217a, {1|U, {0x216a}}},
- {0x217b, {1|U, {0x216b}}},
- {0x217c, {1|U, {0x216c}}},
- {0x217d, {1|U, {0x216d}}},
- {0x217e, {1|U, {0x216e}}},
- {0x217f, {1|U, {0x216f}}},
- {0x2184, {1|U, {0x2183}}},
- {0x24d0, {1|U, {0x24b6}}},
- {0x24d1, {1|U, {0x24b7}}},
- {0x24d2, {1|U, {0x24b8}}},
- {0x24d3, {1|U, {0x24b9}}},
- {0x24d4, {1|U, {0x24ba}}},
- {0x24d5, {1|U, {0x24bb}}},
- {0x24d6, {1|U, {0x24bc}}},
- {0x24d7, {1|U, {0x24bd}}},
- {0x24d8, {1|U, {0x24be}}},
- {0x24d9, {1|U, {0x24bf}}},
- {0x24da, {1|U, {0x24c0}}},
- {0x24db, {1|U, {0x24c1}}},
- {0x24dc, {1|U, {0x24c2}}},
- {0x24dd, {1|U, {0x24c3}}},
- {0x24de, {1|U, {0x24c4}}},
- {0x24df, {1|U, {0x24c5}}},
- {0x24e0, {1|U, {0x24c6}}},
- {0x24e1, {1|U, {0x24c7}}},
- {0x24e2, {1|U, {0x24c8}}},
- {0x24e3, {1|U, {0x24c9}}},
- {0x24e4, {1|U, {0x24ca}}},
- {0x24e5, {1|U, {0x24cb}}},
- {0x24e6, {1|U, {0x24cc}}},
- {0x24e7, {1|U, {0x24cd}}},
- {0x24e8, {1|U, {0x24ce}}},
- {0x24e9, {1|U, {0x24cf}}},
- {0x2c30, {1|U, {0x2c00}}},
- {0x2c31, {1|U, {0x2c01}}},
- {0x2c32, {1|U, {0x2c02}}},
- {0x2c33, {1|U, {0x2c03}}},
- {0x2c34, {1|U, {0x2c04}}},
- {0x2c35, {1|U, {0x2c05}}},
- {0x2c36, {1|U, {0x2c06}}},
- {0x2c37, {1|U, {0x2c07}}},
- {0x2c38, {1|U, {0x2c08}}},
- {0x2c39, {1|U, {0x2c09}}},
- {0x2c3a, {1|U, {0x2c0a}}},
- {0x2c3b, {1|U, {0x2c0b}}},
- {0x2c3c, {1|U, {0x2c0c}}},
- {0x2c3d, {1|U, {0x2c0d}}},
- {0x2c3e, {1|U, {0x2c0e}}},
- {0x2c3f, {1|U, {0x2c0f}}},
- {0x2c40, {1|U, {0x2c10}}},
- {0x2c41, {1|U, {0x2c11}}},
- {0x2c42, {1|U, {0x2c12}}},
- {0x2c43, {1|U, {0x2c13}}},
- {0x2c44, {1|U, {0x2c14}}},
- {0x2c45, {1|U, {0x2c15}}},
- {0x2c46, {1|U, {0x2c16}}},
- {0x2c47, {1|U, {0x2c17}}},
- {0x2c48, {1|U, {0x2c18}}},
- {0x2c49, {1|U, {0x2c19}}},
- {0x2c4a, {1|U, {0x2c1a}}},
- {0x2c4b, {1|U, {0x2c1b}}},
- {0x2c4c, {1|U, {0x2c1c}}},
- {0x2c4d, {1|U, {0x2c1d}}},
- {0x2c4e, {1|U, {0x2c1e}}},
- {0x2c4f, {1|U, {0x2c1f}}},
- {0x2c50, {1|U, {0x2c20}}},
- {0x2c51, {1|U, {0x2c21}}},
- {0x2c52, {1|U, {0x2c22}}},
- {0x2c53, {1|U, {0x2c23}}},
- {0x2c54, {1|U, {0x2c24}}},
- {0x2c55, {1|U, {0x2c25}}},
- {0x2c56, {1|U, {0x2c26}}},
- {0x2c57, {1|U, {0x2c27}}},
- {0x2c58, {1|U, {0x2c28}}},
- {0x2c59, {1|U, {0x2c29}}},
- {0x2c5a, {1|U, {0x2c2a}}},
- {0x2c5b, {1|U, {0x2c2b}}},
- {0x2c5c, {1|U, {0x2c2c}}},
- {0x2c5d, {1|U, {0x2c2d}}},
- {0x2c5e, {1|U, {0x2c2e}}},
- {0x2c61, {1|U, {0x2c60}}},
- {0x2c65, {1|U, {0x023a}}},
- {0x2c66, {1|U, {0x023e}}},
- {0x2c68, {1|U, {0x2c67}}},
- {0x2c6a, {1|U, {0x2c69}}},
- {0x2c6c, {1|U, {0x2c6b}}},
- {0x2c73, {1|U, {0x2c72}}},
- {0x2c76, {1|U, {0x2c75}}},
- {0x2c81, {1|U, {0x2c80}}},
- {0x2c83, {1|U, {0x2c82}}},
- {0x2c85, {1|U, {0x2c84}}},
- {0x2c87, {1|U, {0x2c86}}},
- {0x2c89, {1|U, {0x2c88}}},
- {0x2c8b, {1|U, {0x2c8a}}},
- {0x2c8d, {1|U, {0x2c8c}}},
- {0x2c8f, {1|U, {0x2c8e}}},
- {0x2c91, {1|U, {0x2c90}}},
- {0x2c93, {1|U, {0x2c92}}},
- {0x2c95, {1|U, {0x2c94}}},
- {0x2c97, {1|U, {0x2c96}}},
- {0x2c99, {1|U, {0x2c98}}},
- {0x2c9b, {1|U, {0x2c9a}}},
- {0x2c9d, {1|U, {0x2c9c}}},
- {0x2c9f, {1|U, {0x2c9e}}},
- {0x2ca1, {1|U, {0x2ca0}}},
- {0x2ca3, {1|U, {0x2ca2}}},
- {0x2ca5, {1|U, {0x2ca4}}},
- {0x2ca7, {1|U, {0x2ca6}}},
- {0x2ca9, {1|U, {0x2ca8}}},
- {0x2cab, {1|U, {0x2caa}}},
- {0x2cad, {1|U, {0x2cac}}},
- {0x2caf, {1|U, {0x2cae}}},
- {0x2cb1, {1|U, {0x2cb0}}},
- {0x2cb3, {1|U, {0x2cb2}}},
- {0x2cb5, {1|U, {0x2cb4}}},
- {0x2cb7, {1|U, {0x2cb6}}},
- {0x2cb9, {1|U, {0x2cb8}}},
- {0x2cbb, {1|U, {0x2cba}}},
- {0x2cbd, {1|U, {0x2cbc}}},
- {0x2cbf, {1|U, {0x2cbe}}},
- {0x2cc1, {1|U, {0x2cc0}}},
- {0x2cc3, {1|U, {0x2cc2}}},
- {0x2cc5, {1|U, {0x2cc4}}},
- {0x2cc7, {1|U, {0x2cc6}}},
- {0x2cc9, {1|U, {0x2cc8}}},
- {0x2ccb, {1|U, {0x2cca}}},
- {0x2ccd, {1|U, {0x2ccc}}},
- {0x2ccf, {1|U, {0x2cce}}},
- {0x2cd1, {1|U, {0x2cd0}}},
- {0x2cd3, {1|U, {0x2cd2}}},
- {0x2cd5, {1|U, {0x2cd4}}},
- {0x2cd7, {1|U, {0x2cd6}}},
- {0x2cd9, {1|U, {0x2cd8}}},
- {0x2cdb, {1|U, {0x2cda}}},
- {0x2cdd, {1|U, {0x2cdc}}},
- {0x2cdf, {1|U, {0x2cde}}},
- {0x2ce1, {1|U, {0x2ce0}}},
- {0x2ce3, {1|U, {0x2ce2}}},
- {0x2cec, {1|U, {0x2ceb}}},
- {0x2cee, {1|U, {0x2ced}}},
- {0x2cf3, {1|U, {0x2cf2}}},
- {0x2d00, {1|U, {0x10a0}}},
- {0x2d01, {1|U, {0x10a1}}},
- {0x2d02, {1|U, {0x10a2}}},
- {0x2d03, {1|U, {0x10a3}}},
- {0x2d04, {1|U, {0x10a4}}},
- {0x2d05, {1|U, {0x10a5}}},
- {0x2d06, {1|U, {0x10a6}}},
- {0x2d07, {1|U, {0x10a7}}},
- {0x2d08, {1|U, {0x10a8}}},
- {0x2d09, {1|U, {0x10a9}}},
- {0x2d0a, {1|U, {0x10aa}}},
- {0x2d0b, {1|U, {0x10ab}}},
- {0x2d0c, {1|U, {0x10ac}}},
- {0x2d0d, {1|U, {0x10ad}}},
- {0x2d0e, {1|U, {0x10ae}}},
- {0x2d0f, {1|U, {0x10af}}},
- {0x2d10, {1|U, {0x10b0}}},
- {0x2d11, {1|U, {0x10b1}}},
- {0x2d12, {1|U, {0x10b2}}},
- {0x2d13, {1|U, {0x10b3}}},
- {0x2d14, {1|U, {0x10b4}}},
- {0x2d15, {1|U, {0x10b5}}},
- {0x2d16, {1|U, {0x10b6}}},
- {0x2d17, {1|U, {0x10b7}}},
- {0x2d18, {1|U, {0x10b8}}},
- {0x2d19, {1|U, {0x10b9}}},
- {0x2d1a, {1|U, {0x10ba}}},
- {0x2d1b, {1|U, {0x10bb}}},
- {0x2d1c, {1|U, {0x10bc}}},
- {0x2d1d, {1|U, {0x10bd}}},
- {0x2d1e, {1|U, {0x10be}}},
- {0x2d1f, {1|U, {0x10bf}}},
- {0x2d20, {1|U, {0x10c0}}},
- {0x2d21, {1|U, {0x10c1}}},
- {0x2d22, {1|U, {0x10c2}}},
- {0x2d23, {1|U, {0x10c3}}},
- {0x2d24, {1|U, {0x10c4}}},
- {0x2d25, {1|U, {0x10c5}}},
- {0x2d27, {1|U, {0x10c7}}},
- {0x2d2d, {1|U, {0x10cd}}},
- {0xa641, {1|U, {0xa640}}},
- {0xa643, {1|U, {0xa642}}},
- {0xa645, {1|U, {0xa644}}},
- {0xa647, {1|U, {0xa646}}},
- {0xa649, {1|U, {0xa648}}},
- {0xa64b, {2|U, {0xa64a, 0x1c88}}},
- {0xa64d, {1|U, {0xa64c}}},
- {0xa64f, {1|U, {0xa64e}}},
- {0xa651, {1|U, {0xa650}}},
- {0xa653, {1|U, {0xa652}}},
- {0xa655, {1|U, {0xa654}}},
- {0xa657, {1|U, {0xa656}}},
- {0xa659, {1|U, {0xa658}}},
- {0xa65b, {1|U, {0xa65a}}},
- {0xa65d, {1|U, {0xa65c}}},
- {0xa65f, {1|U, {0xa65e}}},
- {0xa661, {1|U, {0xa660}}},
- {0xa663, {1|U, {0xa662}}},
- {0xa665, {1|U, {0xa664}}},
- {0xa667, {1|U, {0xa666}}},
- {0xa669, {1|U, {0xa668}}},
- {0xa66b, {1|U, {0xa66a}}},
- {0xa66d, {1|U, {0xa66c}}},
- {0xa681, {1|U, {0xa680}}},
- {0xa683, {1|U, {0xa682}}},
- {0xa685, {1|U, {0xa684}}},
- {0xa687, {1|U, {0xa686}}},
- {0xa689, {1|U, {0xa688}}},
- {0xa68b, {1|U, {0xa68a}}},
- {0xa68d, {1|U, {0xa68c}}},
- {0xa68f, {1|U, {0xa68e}}},
- {0xa691, {1|U, {0xa690}}},
- {0xa693, {1|U, {0xa692}}},
- {0xa695, {1|U, {0xa694}}},
- {0xa697, {1|U, {0xa696}}},
- {0xa699, {1|U, {0xa698}}},
- {0xa69b, {1|U, {0xa69a}}},
- {0xa723, {1|U, {0xa722}}},
- {0xa725, {1|U, {0xa724}}},
- {0xa727, {1|U, {0xa726}}},
- {0xa729, {1|U, {0xa728}}},
- {0xa72b, {1|U, {0xa72a}}},
- {0xa72d, {1|U, {0xa72c}}},
- {0xa72f, {1|U, {0xa72e}}},
- {0xa733, {1|U, {0xa732}}},
- {0xa735, {1|U, {0xa734}}},
- {0xa737, {1|U, {0xa736}}},
- {0xa739, {1|U, {0xa738}}},
- {0xa73b, {1|U, {0xa73a}}},
- {0xa73d, {1|U, {0xa73c}}},
- {0xa73f, {1|U, {0xa73e}}},
- {0xa741, {1|U, {0xa740}}},
- {0xa743, {1|U, {0xa742}}},
- {0xa745, {1|U, {0xa744}}},
- {0xa747, {1|U, {0xa746}}},
- {0xa749, {1|U, {0xa748}}},
- {0xa74b, {1|U, {0xa74a}}},
- {0xa74d, {1|U, {0xa74c}}},
- {0xa74f, {1|U, {0xa74e}}},
- {0xa751, {1|U, {0xa750}}},
- {0xa753, {1|U, {0xa752}}},
- {0xa755, {1|U, {0xa754}}},
- {0xa757, {1|U, {0xa756}}},
- {0xa759, {1|U, {0xa758}}},
- {0xa75b, {1|U, {0xa75a}}},
- {0xa75d, {1|U, {0xa75c}}},
- {0xa75f, {1|U, {0xa75e}}},
- {0xa761, {1|U, {0xa760}}},
- {0xa763, {1|U, {0xa762}}},
- {0xa765, {1|U, {0xa764}}},
- {0xa767, {1|U, {0xa766}}},
- {0xa769, {1|U, {0xa768}}},
- {0xa76b, {1|U, {0xa76a}}},
- {0xa76d, {1|U, {0xa76c}}},
- {0xa76f, {1|U, {0xa76e}}},
- {0xa77a, {1|U, {0xa779}}},
- {0xa77c, {1|U, {0xa77b}}},
- {0xa77f, {1|U, {0xa77e}}},
- {0xa781, {1|U, {0xa780}}},
- {0xa783, {1|U, {0xa782}}},
- {0xa785, {1|U, {0xa784}}},
- {0xa787, {1|U, {0xa786}}},
- {0xa78c, {1|U, {0xa78b}}},
- {0xa791, {1|U, {0xa790}}},
- {0xa793, {1|U, {0xa792}}},
- {0xa794, {1|U, {0xa7c4}}},
- {0xa797, {1|U, {0xa796}}},
- {0xa799, {1|U, {0xa798}}},
- {0xa79b, {1|U, {0xa79a}}},
- {0xa79d, {1|U, {0xa79c}}},
- {0xa79f, {1|U, {0xa79e}}},
- {0xa7a1, {1|U, {0xa7a0}}},
- {0xa7a3, {1|U, {0xa7a2}}},
- {0xa7a5, {1|U, {0xa7a4}}},
- {0xa7a7, {1|U, {0xa7a6}}},
- {0xa7a9, {1|U, {0xa7a8}}},
- {0xa7b5, {1|U, {0xa7b4}}},
- {0xa7b7, {1|U, {0xa7b6}}},
- {0xa7b9, {1|U, {0xa7b8}}},
- {0xa7bb, {1|U, {0xa7ba}}},
- {0xa7bd, {1|U, {0xa7bc}}},
- {0xa7bf, {1|U, {0xa7be}}},
- {0xa7c3, {1|U, {0xa7c2}}},
- {0xab53, {1|U, {0xa7b3}}},
- {0xff41, {1|U, {0xff21}}},
- {0xff42, {1|U, {0xff22}}},
- {0xff43, {1|U, {0xff23}}},
- {0xff44, {1|U, {0xff24}}},
- {0xff45, {1|U, {0xff25}}},
- {0xff46, {1|U, {0xff26}}},
- {0xff47, {1|U, {0xff27}}},
- {0xff48, {1|U, {0xff28}}},
- {0xff49, {1|U, {0xff29}}},
- {0xff4a, {1|U, {0xff2a}}},
- {0xff4b, {1|U, {0xff2b}}},
- {0xff4c, {1|U, {0xff2c}}},
- {0xff4d, {1|U, {0xff2d}}},
- {0xff4e, {1|U, {0xff2e}}},
- {0xff4f, {1|U, {0xff2f}}},
- {0xff50, {1|U, {0xff30}}},
- {0xff51, {1|U, {0xff31}}},
- {0xff52, {1|U, {0xff32}}},
- {0xff53, {1|U, {0xff33}}},
- {0xff54, {1|U, {0xff34}}},
- {0xff55, {1|U, {0xff35}}},
- {0xff56, {1|U, {0xff36}}},
- {0xff57, {1|U, {0xff37}}},
- {0xff58, {1|U, {0xff38}}},
- {0xff59, {1|U, {0xff39}}},
- {0xff5a, {1|U, {0xff3a}}},
- {0x10428, {1|U, {0x10400}}},
- {0x10429, {1|U, {0x10401}}},
- {0x1042a, {1|U, {0x10402}}},
- {0x1042b, {1|U, {0x10403}}},
- {0x1042c, {1|U, {0x10404}}},
- {0x1042d, {1|U, {0x10405}}},
- {0x1042e, {1|U, {0x10406}}},
- {0x1042f, {1|U, {0x10407}}},
- {0x10430, {1|U, {0x10408}}},
- {0x10431, {1|U, {0x10409}}},
- {0x10432, {1|U, {0x1040a}}},
- {0x10433, {1|U, {0x1040b}}},
- {0x10434, {1|U, {0x1040c}}},
- {0x10435, {1|U, {0x1040d}}},
- {0x10436, {1|U, {0x1040e}}},
- {0x10437, {1|U, {0x1040f}}},
- {0x10438, {1|U, {0x10410}}},
- {0x10439, {1|U, {0x10411}}},
- {0x1043a, {1|U, {0x10412}}},
- {0x1043b, {1|U, {0x10413}}},
- {0x1043c, {1|U, {0x10414}}},
- {0x1043d, {1|U, {0x10415}}},
- {0x1043e, {1|U, {0x10416}}},
- {0x1043f, {1|U, {0x10417}}},
- {0x10440, {1|U, {0x10418}}},
- {0x10441, {1|U, {0x10419}}},
- {0x10442, {1|U, {0x1041a}}},
- {0x10443, {1|U, {0x1041b}}},
- {0x10444, {1|U, {0x1041c}}},
- {0x10445, {1|U, {0x1041d}}},
- {0x10446, {1|U, {0x1041e}}},
- {0x10447, {1|U, {0x1041f}}},
- {0x10448, {1|U, {0x10420}}},
- {0x10449, {1|U, {0x10421}}},
- {0x1044a, {1|U, {0x10422}}},
- {0x1044b, {1|U, {0x10423}}},
- {0x1044c, {1|U, {0x10424}}},
- {0x1044d, {1|U, {0x10425}}},
- {0x1044e, {1|U, {0x10426}}},
- {0x1044f, {1|U, {0x10427}}},
- {0x104d8, {1|U, {0x104b0}}},
- {0x104d9, {1|U, {0x104b1}}},
- {0x104da, {1|U, {0x104b2}}},
- {0x104db, {1|U, {0x104b3}}},
- {0x104dc, {1|U, {0x104b4}}},
- {0x104dd, {1|U, {0x104b5}}},
- {0x104de, {1|U, {0x104b6}}},
- {0x104df, {1|U, {0x104b7}}},
- {0x104e0, {1|U, {0x104b8}}},
- {0x104e1, {1|U, {0x104b9}}},
- {0x104e2, {1|U, {0x104ba}}},
- {0x104e3, {1|U, {0x104bb}}},
- {0x104e4, {1|U, {0x104bc}}},
- {0x104e5, {1|U, {0x104bd}}},
- {0x104e6, {1|U, {0x104be}}},
- {0x104e7, {1|U, {0x104bf}}},
- {0x104e8, {1|U, {0x104c0}}},
- {0x104e9, {1|U, {0x104c1}}},
- {0x104ea, {1|U, {0x104c2}}},
- {0x104eb, {1|U, {0x104c3}}},
- {0x104ec, {1|U, {0x104c4}}},
- {0x104ed, {1|U, {0x104c5}}},
- {0x104ee, {1|U, {0x104c6}}},
- {0x104ef, {1|U, {0x104c7}}},
- {0x104f0, {1|U, {0x104c8}}},
- {0x104f1, {1|U, {0x104c9}}},
- {0x104f2, {1|U, {0x104ca}}},
- {0x104f3, {1|U, {0x104cb}}},
- {0x104f4, {1|U, {0x104cc}}},
- {0x104f5, {1|U, {0x104cd}}},
- {0x104f6, {1|U, {0x104ce}}},
- {0x104f7, {1|U, {0x104cf}}},
- {0x104f8, {1|U, {0x104d0}}},
- {0x104f9, {1|U, {0x104d1}}},
- {0x104fa, {1|U, {0x104d2}}},
- {0x104fb, {1|U, {0x104d3}}},
- {0x10cc0, {1|U, {0x10c80}}},
- {0x10cc1, {1|U, {0x10c81}}},
- {0x10cc2, {1|U, {0x10c82}}},
- {0x10cc3, {1|U, {0x10c83}}},
- {0x10cc4, {1|U, {0x10c84}}},
- {0x10cc5, {1|U, {0x10c85}}},
- {0x10cc6, {1|U, {0x10c86}}},
- {0x10cc7, {1|U, {0x10c87}}},
- {0x10cc8, {1|U, {0x10c88}}},
- {0x10cc9, {1|U, {0x10c89}}},
- {0x10cca, {1|U, {0x10c8a}}},
- {0x10ccb, {1|U, {0x10c8b}}},
- {0x10ccc, {1|U, {0x10c8c}}},
- {0x10ccd, {1|U, {0x10c8d}}},
- {0x10cce, {1|U, {0x10c8e}}},
- {0x10ccf, {1|U, {0x10c8f}}},
- {0x10cd0, {1|U, {0x10c90}}},
- {0x10cd1, {1|U, {0x10c91}}},
- {0x10cd2, {1|U, {0x10c92}}},
- {0x10cd3, {1|U, {0x10c93}}},
- {0x10cd4, {1|U, {0x10c94}}},
- {0x10cd5, {1|U, {0x10c95}}},
- {0x10cd6, {1|U, {0x10c96}}},
- {0x10cd7, {1|U, {0x10c97}}},
- {0x10cd8, {1|U, {0x10c98}}},
- {0x10cd9, {1|U, {0x10c99}}},
- {0x10cda, {1|U, {0x10c9a}}},
- {0x10cdb, {1|U, {0x10c9b}}},
- {0x10cdc, {1|U, {0x10c9c}}},
- {0x10cdd, {1|U, {0x10c9d}}},
- {0x10cde, {1|U, {0x10c9e}}},
- {0x10cdf, {1|U, {0x10c9f}}},
- {0x10ce0, {1|U, {0x10ca0}}},
- {0x10ce1, {1|U, {0x10ca1}}},
- {0x10ce2, {1|U, {0x10ca2}}},
- {0x10ce3, {1|U, {0x10ca3}}},
- {0x10ce4, {1|U, {0x10ca4}}},
- {0x10ce5, {1|U, {0x10ca5}}},
- {0x10ce6, {1|U, {0x10ca6}}},
- {0x10ce7, {1|U, {0x10ca7}}},
- {0x10ce8, {1|U, {0x10ca8}}},
- {0x10ce9, {1|U, {0x10ca9}}},
- {0x10cea, {1|U, {0x10caa}}},
- {0x10ceb, {1|U, {0x10cab}}},
- {0x10cec, {1|U, {0x10cac}}},
- {0x10ced, {1|U, {0x10cad}}},
- {0x10cee, {1|U, {0x10cae}}},
- {0x10cef, {1|U, {0x10caf}}},
- {0x10cf0, {1|U, {0x10cb0}}},
- {0x10cf1, {1|U, {0x10cb1}}},
- {0x10cf2, {1|U, {0x10cb2}}},
- {0x118c0, {1|U, {0x118a0}}},
- {0x118c1, {1|U, {0x118a1}}},
- {0x118c2, {1|U, {0x118a2}}},
- {0x118c3, {1|U, {0x118a3}}},
- {0x118c4, {1|U, {0x118a4}}},
- {0x118c5, {1|U, {0x118a5}}},
- {0x118c6, {1|U, {0x118a6}}},
- {0x118c7, {1|U, {0x118a7}}},
- {0x118c8, {1|U, {0x118a8}}},
- {0x118c9, {1|U, {0x118a9}}},
- {0x118ca, {1|U, {0x118aa}}},
- {0x118cb, {1|U, {0x118ab}}},
- {0x118cc, {1|U, {0x118ac}}},
- {0x118cd, {1|U, {0x118ad}}},
- {0x118ce, {1|U, {0x118ae}}},
- {0x118cf, {1|U, {0x118af}}},
- {0x118d0, {1|U, {0x118b0}}},
- {0x118d1, {1|U, {0x118b1}}},
- {0x118d2, {1|U, {0x118b2}}},
- {0x118d3, {1|U, {0x118b3}}},
- {0x118d4, {1|U, {0x118b4}}},
- {0x118d5, {1|U, {0x118b5}}},
- {0x118d6, {1|U, {0x118b6}}},
- {0x118d7, {1|U, {0x118b7}}},
- {0x118d8, {1|U, {0x118b8}}},
- {0x118d9, {1|U, {0x118b9}}},
- {0x118da, {1|U, {0x118ba}}},
- {0x118db, {1|U, {0x118bb}}},
- {0x118dc, {1|U, {0x118bc}}},
- {0x118dd, {1|U, {0x118bd}}},
- {0x118de, {1|U, {0x118be}}},
- {0x118df, {1|U, {0x118bf}}},
- {0x16e60, {1|U, {0x16e40}}},
- {0x16e61, {1|U, {0x16e41}}},
- {0x16e62, {1|U, {0x16e42}}},
- {0x16e63, {1|U, {0x16e43}}},
- {0x16e64, {1|U, {0x16e44}}},
- {0x16e65, {1|U, {0x16e45}}},
- {0x16e66, {1|U, {0x16e46}}},
- {0x16e67, {1|U, {0x16e47}}},
- {0x16e68, {1|U, {0x16e48}}},
- {0x16e69, {1|U, {0x16e49}}},
- {0x16e6a, {1|U, {0x16e4a}}},
- {0x16e6b, {1|U, {0x16e4b}}},
- {0x16e6c, {1|U, {0x16e4c}}},
- {0x16e6d, {1|U, {0x16e4d}}},
- {0x16e6e, {1|U, {0x16e4e}}},
- {0x16e6f, {1|U, {0x16e4f}}},
- {0x16e70, {1|U, {0x16e50}}},
- {0x16e71, {1|U, {0x16e51}}},
- {0x16e72, {1|U, {0x16e52}}},
- {0x16e73, {1|U, {0x16e53}}},
- {0x16e74, {1|U, {0x16e54}}},
- {0x16e75, {1|U, {0x16e55}}},
- {0x16e76, {1|U, {0x16e56}}},
- {0x16e77, {1|U, {0x16e57}}},
- {0x16e78, {1|U, {0x16e58}}},
- {0x16e79, {1|U, {0x16e59}}},
- {0x16e7a, {1|U, {0x16e5a}}},
- {0x16e7b, {1|U, {0x16e5b}}},
- {0x16e7c, {1|U, {0x16e5c}}},
- {0x16e7d, {1|U, {0x16e5d}}},
- {0x16e7e, {1|U, {0x16e5e}}},
- {0x16e7f, {1|U, {0x16e5f}}},
- {0x1e922, {1|U, {0x1e900}}},
- {0x1e923, {1|U, {0x1e901}}},
- {0x1e924, {1|U, {0x1e902}}},
- {0x1e925, {1|U, {0x1e903}}},
- {0x1e926, {1|U, {0x1e904}}},
- {0x1e927, {1|U, {0x1e905}}},
- {0x1e928, {1|U, {0x1e906}}},
- {0x1e929, {1|U, {0x1e907}}},
- {0x1e92a, {1|U, {0x1e908}}},
- {0x1e92b, {1|U, {0x1e909}}},
- {0x1e92c, {1|U, {0x1e90a}}},
- {0x1e92d, {1|U, {0x1e90b}}},
- {0x1e92e, {1|U, {0x1e90c}}},
- {0x1e92f, {1|U, {0x1e90d}}},
- {0x1e930, {1|U, {0x1e90e}}},
- {0x1e931, {1|U, {0x1e90f}}},
- {0x1e932, {1|U, {0x1e910}}},
- {0x1e933, {1|U, {0x1e911}}},
- {0x1e934, {1|U, {0x1e912}}},
- {0x1e935, {1|U, {0x1e913}}},
- {0x1e936, {1|U, {0x1e914}}},
- {0x1e937, {1|U, {0x1e915}}},
- {0x1e938, {1|U, {0x1e916}}},
- {0x1e939, {1|U, {0x1e917}}},
- {0x1e93a, {1|U, {0x1e918}}},
- {0x1e93b, {1|U, {0x1e919}}},
- {0x1e93c, {1|U, {0x1e91a}}},
- {0x1e93d, {1|U, {0x1e91b}}},
- {0x1e93e, {1|U, {0x1e91c}}},
- {0x1e93f, {1|U, {0x1e91d}}},
- {0x1e940, {1|U, {0x1e91e}}},
- {0x1e941, {1|U, {0x1e91f}}},
- {0x1e942, {1|U, {0x1e920}}},
- {0x1e943, {1|U, {0x1e921}}},
-#define CaseUnfold_11_Locale (*(CaseUnfold_11_Type (*)[1])(CaseUnfold_11_Table+1352))
- {0x0069, {1|U, {0x0049}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_11_hash -N onigenc_unicode_CaseUnfold_11_lookup -n */
-
-/* maximum key range = 2507, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseUnfold_11_hash(const OnigCodePoint code)
-{
- static const unsigned short asso_values[] =
- {
- 1, 2510, 2, 7, 4, 582, 9, 308, 197, 674,
- 297, 20, 2, 3, 303, 351, 2510, 2510, 2510, 2510,
- 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 112,
- 2510, 2510, 2510, 2510, 2510, 2510, 2510, 120, 2510, 2510,
- 2510, 2510, 2510, 1, 2510, 2510, 2510, 2510, 2510, 2510,
- 2510, 2510, 2510, 278, 2510, 2510, 2510, 2510, 2510, 2510,
- 2510, 2510, 12, 1, 7, 8, 218, 878, 222, 1178,
- 480, 1102, 54, 1340, 151, 1615, 8, 15, 106, 1607,
- 225, 854, 87, 490, 44, 1351, 5, 1281, 3, 1470,
- 11, 1215, 377, 10, 441, 599, 152, 1642, 127, 1334,
- 702, 841, 594, 827, 123, 916, 146, 1118, 117, 1363,
- 254, 812, 249, 1096, 1630, 945, 437, 745, 1600, 718,
- 1593, 704, 152, 1005, 383, 1064, 1493, 975, 236, 676,
- 761, 579, 1017, 557, 1241, 628, 1195, 614, 1506, 464,
- 1576, 535, 1432, 513, 1159, 423, 1026, 276, 1460, 291,
- 1453, 392, 1263, 201, 1442, 85, 1412, 70, 1430, 100,
- 1632, 129, 1410, 1, 1386, 25, 1373, 35, 656, 55,
- 1188, 45, 1308, 160, 687, 227, 355, 175, 1201, 328,
- 1030, 367, 1483, 414, 1479, 1166, 1418, 783, 994, 937,
- 1083, 959, 1463, 967
- };
- return asso_values[bits_of(code, 2)+66] + asso_values[bits_of(code, 1)+4] + asso_values[bits_of(code, 0)];
-}
-
-static const CodePointList3 *
-onigenc_unicode_CaseUnfold_11_lookup(const OnigCodePoint code)
-{
- enum
- {
- MIN_CODE_VALUE = 0x61,
- MAX_CODE_VALUE = 0x1e943,
- TOTAL_KEYWORDS = 1353,
- MIN_WORD_LENGTH = 3,
- MAX_WORD_LENGTH = 3,
- MIN_HASH_VALUE = 3,
- MAX_HASH_VALUE = 2509
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1,
- /*0x13e1*/ 589,
- /*0x0461*/ 340,
- /*0x04e1*/ 400,
- /*0x0061*/ 0,
- -1,
- /*0x104e1*/ 1176,
- /*0x1e61*/ 661,
- /*0x1ee1*/ 720,
- /*0x0161*/ 102,
- /*0x2ce1*/ 952,
- -1,
- /*0x049b*/ 365,
- -1, -1,
- /*0x24e1*/ 840,
- /*0x1e1b*/ 626,
- /*0x048b*/ 357,
- /*0x011b*/ 69,
- /*0x2c9b*/ 917,
- /*0x03e1*/ 280,
- /*0x1e0b*/ 618,
- /*0x1e8b*/ 682,
- /*0x010b*/ 61,
- /*0x2c8b*/ 909,
- /*0x13e3*/ 591,
- /*0x0463*/ 341,
- /*0x04e3*/ 401,
- /*0x0063*/ 2,
- -1,
- /*0x104e3*/ 1178,
- /*0x1e63*/ 662,
- /*0x1ee3*/ 721,
- /*0x0163*/ 103,
- /*0x2ce3*/ 953,
- /*0x13e5*/ 593,
- /*0x0465*/ 342,
- /*0x04e5*/ 402,
- /*0x0065*/ 4,
- /*0x24e3*/ 842,
- /*0x104e5*/ 1180,
- /*0x1e65*/ 663,
- /*0x1ee5*/ 722,
- /*0x0165*/ 104,
- /*0x03e3*/ 281,
- /*0x13e9*/ 597,
- /*0x0469*/ 344,
- /*0x04e9*/ 404,
- /*0x0069*/ 1352,
- /*0x24e5*/ 844,
- /*0x104e9*/ 1184,
- /*0x1e69*/ 665,
- /*0x1ee9*/ 724,
- /*0x0169*/ 106,
- /*0x03e5*/ 282,
- /*0x13e7*/ 595,
- /*0x0467*/ 343,
- /*0x04e7*/ 403,
- /*0x0067*/ 6,
- /*0x24e9*/ 848,
- /*0x104e7*/ 1182,
- /*0x1e67*/ 664,
- /*0x1ee7*/ 723,
- /*0x0167*/ 105,
- /*0x03e9*/ 284,
- -1, -1, -1, -1,
- /*0x24e7*/ 846,
- /*0x13db*/ 583,
- /*0x045b*/ 335,
- /*0x04db*/ 397,
- -1,
- /*0x03e7*/ 283,
- /*0x104db*/ 1170,
- /*0x1e5b*/ 658,
- /*0x1edb*/ 717,
- /*0x015b*/ 99,
- /*0x2cdb*/ 949,
- -1, -1, -1, -1,
- /*0x24db*/ 834,
- /*0x13d9*/ 581,
- /*0x0459*/ 333,
- /*0x04d9*/ 396,
- /*0xa761*/ 1064,
- /*0x03db*/ 277,
- /*0x104d9*/ 1168,
- /*0x1e59*/ 657,
- /*0x1ed9*/ 716,
- /*0x0159*/ 98,
- /*0x2cd9*/ 948,
- -1, -1, -1, -1,
- /*0x24d9*/ 832,
- /*0x13dd*/ 585,
- /*0x045d*/ 337,
- /*0x04dd*/ 398,
- -1,
- /*0x03d9*/ 276,
- /*0x104dd*/ 1172,
- /*0x1e5d*/ 659,
- /*0x1edd*/ 718,
- /*0x015d*/ 100,
- /*0x2cdd*/ 950,
- -1, -1,
- /*0xa763*/ 1065,
- -1,
- /*0x24dd*/ 836,
- /*0x10ce1*/ 1236,
- -1,
- /*0x13aa*/ 534,
- -1,
- /*0x03dd*/ 278,
- /*0x10e1*/ 495,
- /*0x1042a*/ 1129,
- /*0xa765*/ 1066,
- /*0x13a6*/ 530,
- -1, -1, -1,
- /*0x13a0*/ 524,
- -1,
- /*0x13df*/ 587,
- /*0x045f*/ 339,
- /*0x04df*/ 399,
- /*0xa769*/ 1068,
- -1,
- /*0x104df*/ 1174,
- /*0x1e5f*/ 660,
- /*0x1edf*/ 719,
- /*0x015f*/ 101,
- /*0x2cdf*/ 951,
- /*0x10ce3*/ 1238,
- -1, -1,
- /*0xa767*/ 1067,
- /*0x24df*/ 838,
- /*0x10e3*/ 497,
- -1,
- /*0x13a8*/ 532,
- -1,
- /*0x03df*/ 279,
- /*0x10ce5*/ 1240,
- /*0x10428*/ 1127,
- -1,
- /*0x13b8*/ 548,
- /*0x0438*/ 300,
- /*0x10e5*/ 499,
- -1,
- /*0x10438*/ 1143,
- /*0xa75b*/ 1061,
- -1,
- /*0x10ce9*/ 1244,
- /*0x13eb*/ 599,
- /*0x046b*/ 345,
- /*0x04eb*/ 405,
- /*0x006b*/ 9,
- /*0x10e9*/ 503,
- /*0x104eb*/ 1186,
- /*0x1e6b*/ 666,
- /*0x1eeb*/ 725,
- /*0x016b*/ 107,
- /*0x10ce7*/ 1242,
- -1,
- /*0x03b8*/ 253,
- /*0xa759*/ 1060,
- -1,
- /*0x10e7*/ 501,
- /*0x13ef*/ 603,
- /*0x046f*/ 347,
- /*0x04ef*/ 407,
- /*0x006f*/ 13,
- /*0x03eb*/ 285,
- /*0x104ef*/ 1190,
- /*0x1e6f*/ 668,
- /*0x1eef*/ 727,
- /*0x016f*/ 109,
- /*0x10cdb*/ 1230,
- -1, -1,
- /*0xa75d*/ 1062,
- -1,
- /*0x10db*/ 489,
- -1, -1, -1, -1,
- /*0x03ef*/ 287,
- -1, -1,
- /*0x0261*/ 210,
- -1,
- /*0x10cd9*/ 1228,
- -1,
- /*0x13d7*/ 579,
- /*0x0457*/ 331,
- /*0x04d7*/ 395,
- /*0x10d9*/ 487,
- -1,
- /*0x021b*/ 178,
- /*0x1e57*/ 656,
- /*0x1ed7*/ 715,
- /*0x0157*/ 97,
- /*0x2cd7*/ 947,
- /*0x020b*/ 170,
- -1, -1,
- /*0x10cdd*/ 1232,
- /*0x24d7*/ 830,
- /*0xa75f*/ 1063,
- -1,
- /*0x1f61*/ 777,
- /*0x10dd*/ 491,
- /*0x03d7*/ 275,
- /*0x0263*/ 211,
- /*0x1f14*/ 748,
- -1, -1,
- /*0x1d8e*/ 612,
- /*0xa661*/ 1013,
- /*0x13ed*/ 601,
- /*0x046d*/ 346,
- /*0x04ed*/ 406,
- /*0x006d*/ 11,
- /*0x0265*/ 212,
- /*0x104ed*/ 1188,
- /*0x1e6d*/ 667,
- /*0x1eed*/ 726,
- /*0x016d*/ 108,
- /*0x13be*/ 554,
- /*0x043e*/ 306,
- -1, -1,
- /*0x1043e*/ 1149,
- /*0x0269*/ 215,
- /*0x1f63*/ 779,
- /*0x10cdf*/ 1234,
- /*0x013e*/ 85,
- -1,
- /*0x03ed*/ 286,
- /*0xa76b*/ 1069,
- /*0x10df*/ 493,
- /*0x13ae*/ 538,
- /*0xa663*/ 1014,
- -1,
- /*0x1f65*/ 781,
- /*0x1042e*/ 1133,
- /*0x13ac*/ 536,
- /*0x03be*/ 259,
- -1, -1,
- /*0x1042c*/ 1131,
- -1,
- /*0xa665*/ 1015,
- /*0x1f12*/ 746,
- /*0xa76f*/ 1071,
- -1, -1, -1,
- /*0x025b*/ 207,
- -1,
- /*0x03ae*/ 244,
- -1,
- /*0xa669*/ 1017,
- /*0x1f06*/ 742,
- /*0x1f67*/ 783,
- /*0x03ac*/ 242,
- /*0x10ceb*/ 1246,
- -1,
- /*0x13d1*/ 573,
- /*0x0451*/ 325,
- /*0x04d1*/ 392,
- /*0x10eb*/ 505,
- /*0xa667*/ 1016,
- /*0x0259*/ 206,
- /*0x1e51*/ 653,
- /*0x1ed1*/ 712,
- /*0x0151*/ 94,
- /*0x2cd1*/ 944,
- -1, -1,
- /*0xa757*/ 1059,
- /*0x10cef*/ 1250,
- /*0x24d1*/ 824,
- /*0x13d3*/ 575,
- /*0x0453*/ 327,
- /*0x04d3*/ 393,
- /*0x10ef*/ 509,
- /*0xa65b*/ 1010,
- -1,
- /*0x1e53*/ 654,
- /*0x1ed3*/ 713,
- /*0x0153*/ 95,
- /*0x2cd3*/ 945,
- -1,
- /*0xab53*/ 1100,
- /*0x0561*/ 440,
- /*0x1f10*/ 744,
- /*0x24d3*/ 826,
- -1, -1,
- /*0x01e1*/ 151,
- -1,
- /*0xa659*/ 1009,
- -1,
- /*0x051b*/ 429,
- -1,
- /*0xa76d*/ 1070,
- /*0x10cd7*/ 1226,
- -1,
- /*0x050b*/ 421,
- -1, -1,
- /*0x10d7*/ 485,
- -1, -1, -1, -1,
- /*0xa65d*/ 1011,
- -1,
- /*0x0563*/ 442,
- /*0x13f1*/ 605,
- /*0x0471*/ 348,
- /*0x04f1*/ 408,
- /*0x0071*/ 15,
- /*0x01e3*/ 152,
- /*0x104f1*/ 1192,
- /*0x1e71*/ 669,
- /*0x1ef1*/ 728,
- /*0x0171*/ 110,
- /*0x0565*/ 444,
- -1, -1,
- /*0x1f26*/ 756,
- /*0x10ced*/ 1248,
- /*0x01e5*/ 153,
- -1,
- /*0x1f20*/ 750,
- -1,
- /*0x10ed*/ 507,
- /*0x0569*/ 448,
- -1, -1,
- /*0x118db*/ 1281,
- /*0x0192*/ 122,
- /*0x01e9*/ 155,
- -1,
- /*0xa65f*/ 1012,
- /*0x13ee*/ 602,
- /*0x026b*/ 217,
- /*0x0567*/ 446,
- /*0x006e*/ 12,
- -1,
- /*0x104ee*/ 1189,
- -1,
- /*0x01e7*/ 154,
- /*0xa751*/ 1056,
- /*0x2cee*/ 955,
- /*0x118d9*/ 1279,
- -1,
- /*0x13f3*/ 607,
- /*0x0473*/ 349,
- /*0x04f3*/ 409,
- /*0x0073*/ 17,
- /*0x026f*/ 219,
- /*0x104f3*/ 1194,
- /*0x1e73*/ 670,
- /*0x1ef3*/ 729,
- /*0x0173*/ 111,
- /*0x2cf3*/ 956,
- /*0x2c61*/ 896,
- /*0xa753*/ 1057,
- -1,
- /*0x118dd*/ 1283,
- -1, -1,
- /*0x13ba*/ 550,
- /*0x043a*/ 302,
- /*0xa66b*/ 1018,
- /*0x03f3*/ 289,
- /*0x1043a*/ 1145,
- -1, -1,
- /*0x10cd1*/ 1220,
- /*0x013a*/ 83,
- /*0x13d5*/ 577,
- /*0x0455*/ 329,
- /*0x04d5*/ 394,
- /*0x10d1*/ 479,
- -1,
- /*0x0257*/ 205,
- /*0x1e55*/ 655,
- /*0x1ed5*/ 714,
- /*0x0155*/ 96,
- /*0x2cd5*/ 946,
- /*0x03ba*/ 255,
- -1,
- /*0x0586*/ 477,
- /*0x10cd3*/ 1222,
- /*0x24d5*/ 828,
- /*0x01dd*/ 149,
- -1,
- /*0x118df*/ 1285,
- /*0x10d3*/ 481,
- /*0x2c65*/ 897,
- -1,
- /*0x018c*/ 121,
- /*0x13f5*/ 609,
- /*0x0475*/ 350,
- /*0x04f5*/ 410,
- /*0x0075*/ 19,
- /*0x1f57*/ 775,
- /*0x104f5*/ 1196,
- /*0x1e75*/ 671,
- /*0x1ef5*/ 730,
- /*0x0175*/ 112,
- /*0x13cf*/ 571,
- /*0x044f*/ 323,
- /*0x04cf*/ 391,
- /*0xa657*/ 1008,
- /*0x1044f*/ 1166,
- /*0x1e92a*/ 1326,
- /*0x1e4f*/ 652,
- /*0x1ecf*/ 711,
- /*0x014f*/ 93,
- /*0x2ccf*/ 943,
- -1,
- /*0x1e926*/ 1322,
- /*0x1f00*/ 736,
- /*0x01df*/ 150,
- /*0x13b2*/ 542,
- /*0x0432*/ 294,
- /*0x1f02*/ 738,
- -1,
- /*0x10432*/ 1137,
- /*0x10cf1*/ 1252,
- /*0x2d16*/ 979,
- -1,
- /*0x2d14*/ 977,
- /*0x2c5b*/ 892,
- /*0x10f1*/ 511,
- /*0x2d0a*/ 967,
- -1,
- /*0x2d1b*/ 984,
- /*0x2d18*/ 981,
- /*0xa66d*/ 1019,
- /*0x01a8*/ 130,
- -1,
- /*0x2d0b*/ 968,
- /*0x03b2*/ 247,
- /*0x1e928*/ 1324,
- /*0x0188*/ 120,
- /*0x019e*/ 126,
- -1,
- /*0x2c59*/ 890,
- /*0x056b*/ 450,
- /*0x1e938*/ 1340,
- /*0x13c9*/ 565,
- /*0x0449*/ 317,
- -1,
- /*0x01eb*/ 156,
- /*0x10449*/ 1160,
- /*0x10cee*/ 1249,
- /*0x1e49*/ 649,
- /*0x1ec9*/ 708,
- /*0x0251*/ 200,
- /*0x2cc9*/ 940,
- /*0x10ee*/ 508,
- -1,
- /*0x2c5d*/ 894,
- /*0x056f*/ 454,
- -1,
- /*0xa755*/ 1058,
- -1,
- /*0x118d7*/ 1277,
- /*0x01ef*/ 158,
- /*0x03c9*/ 269,
- /*0x2d12*/ 975,
- -1,
- /*0x10f3*/ 513,
- /*0x0253*/ 202,
- -1, -1, -1, -1,
- /*0x0491*/ 360,
- /*0x1f51*/ 772,
- /*0x2d06*/ 963,
- /*0xa794*/ 1082,
- /*0x1e11*/ 621,
- /*0x1e91*/ 685,
- /*0x0111*/ 64,
- /*0x2c91*/ 912,
- /*0xa79b*/ 1085,
- /*0xa651*/ 1005,
- -1, -1, -1, -1,
- /*0x10cd5*/ 1224,
- -1,
- /*0x1f53*/ 773,
- -1,
- /*0xa74f*/ 1055,
- /*0x10d5*/ 483,
- -1,
- /*0x13cd*/ 569,
- /*0x044d*/ 321,
- -1,
- /*0xa653*/ 1006,
- /*0x1044d*/ 1164,
- -1,
- /*0x1e4d*/ 651,
- /*0x1ecd*/ 710,
- /*0x014d*/ 92,
- /*0x2ccd*/ 942,
- -1,
- /*0x0271*/ 220,
- /*0x0180*/ 117,
- -1,
- /*0x2d10*/ 973,
- /*0x2c38*/ 857,
- /*0x056d*/ 452,
- -1, -1,
- /*0x03cd*/ 273,
- /*0x10f5*/ 515,
- /*0x01ed*/ 157,
- /*0x13cb*/ 567,
- /*0x044b*/ 319,
- /*0x10ccf*/ 1218,
- -1,
- /*0x1044b*/ 1162,
- -1,
- /*0x1e4b*/ 650,
- /*0x1ecb*/ 709,
- /*0x014b*/ 91,
- /*0x2ccb*/ 941,
- /*0x1f71*/ 785,
- /*0x2d0c*/ 969,
- /*0x1e93e*/ 1346,
- -1, -1, -1,
- /*0xa749*/ 1052,
- -1, -1,
- /*0x03cb*/ 271,
- -1,
- /*0x118d1*/ 1271,
- /*0x13c3*/ 559,
- /*0x0443*/ 311,
- -1,
- /*0x1e92e*/ 1330,
- /*0x10443*/ 1154,
- -1,
- /*0x1e43*/ 646,
- /*0x1ec3*/ 705,
- /*0x1e92c*/ 1328,
- /*0x2cc3*/ 937,
- /*0x2d20*/ 989,
- /*0x0580*/ 471,
- -1, -1,
- /*0x118d3*/ 1273,
- /*0x0582*/ 473,
- -1, -1, -1,
- /*0x03c3*/ 263,
- /*0x2c57*/ 888,
- /*0x10cc9*/ 1212,
- /*0x13c1*/ 557,
- /*0x0441*/ 309,
- -1,
- /*0x00e1*/ 26,
- /*0x10441*/ 1152,
- /*0x1f73*/ 787,
- /*0x1e41*/ 645,
- /*0x1ec1*/ 704,
- -1,
- /*0x2cc1*/ 936,
- -1, -1,
- /*0x2d08*/ 965,
- /*0x2d1e*/ 987,
- -1,
- /*0x13a4*/ 528,
- -1,
- /*0xa78c*/ 1079,
- -1,
- /*0x03c1*/ 262,
- -1,
- /*0xa74d*/ 1054,
- /*0x049d*/ 366,
- -1, -1, -1,
- /*0x1e1d*/ 627,
- /*0x00e3*/ 28,
- /*0x011d*/ 70,
- /*0x2c9d*/ 918,
- /*0x1f55*/ 774,
- /*0x0275*/ 222,
- -1,
- /*0x2c3e*/ 863,
- -1,
- /*0x13c7*/ 563,
- /*0x0447*/ 315,
- /*0x00e5*/ 30,
- /*0xa655*/ 1007,
- /*0x10447*/ 1158,
- /*0x024f*/ 198,
- /*0x1e47*/ 648,
- /*0x1ec7*/ 707,
- /*0xa74b*/ 1053,
- /*0x2cc7*/ 939,
- /*0x0371*/ 236,
- -1,
- /*0x00e9*/ 34,
- /*0x10ccd*/ 1216,
- /*0x13c5*/ 561,
- /*0x0445*/ 313,
- /*0x0571*/ 456,
- /*0x1f75*/ 789,
- /*0x10445*/ 1156,
- /*0x03c7*/ 267,
- /*0x1e45*/ 647,
- /*0x1ec5*/ 706,
- /*0x00e7*/ 32,
- /*0x2cc5*/ 938,
- -1, -1, -1, -1, -1, -1,
- /*0xa743*/ 1049,
- -1, -1,
- /*0x03c5*/ 265,
- /*0xa64f*/ 1004,
- /*0x10ccb*/ 1214,
- -1, -1,
- /*0x2c51*/ 882,
- -1,
- /*0x1f32*/ 760,
- -1,
- /*0x13e6*/ 594,
- /*0x056e*/ 453,
- /*0x2d00*/ 957,
- /*0x0066*/ 5,
- /*0x0249*/ 195,
- /*0x104e6*/ 1181,
- /*0x2d02*/ 959,
- /*0x0373*/ 237,
- -1,
- /*0x2d0e*/ 971,
- /*0xa741*/ 1048,
- /*0x2c53*/ 884,
- -1,
- /*0x0573*/ 458,
- /*0x24e6*/ 845,
- /*0x10cc3*/ 1206,
- /*0x118d5*/ 1275,
- -1,
- /*0x01f3*/ 159,
- -1,
- /*0x13bf*/ 555,
- /*0x043f*/ 307,
- /*0x04bf*/ 383,
- -1,
- /*0x1043f*/ 1150,
- /*0x028a*/ 230,
- /*0x1e3f*/ 644,
- /*0x1ebf*/ 703,
- /*0x019a*/ 125,
- /*0x2cbf*/ 935,
- /*0x0211*/ 173,
- /*0x13ec*/ 600,
- /*0x028b*/ 231,
- /*0xa649*/ 1001,
- /*0x006c*/ 10,
- -1,
- /*0x104ec*/ 1187,
- /*0x10cc1*/ 1204,
- /*0x1e93a*/ 1342,
- /*0x03bf*/ 260,
- /*0x2cec*/ 954,
- /*0x1f04*/ 740,
- -1, -1, -1,
- /*0xa747*/ 1051,
- /*0x13a2*/ 526,
- /*0x118cf*/ 1269,
- /*0x13b7*/ 547,
- /*0x0437*/ 299,
- /*0x04b7*/ 379,
- /*0x1f11*/ 745,
- /*0x10437*/ 1142,
- /*0x024d*/ 197,
- /*0x1e37*/ 640,
- /*0x1eb7*/ 699,
- /*0x0137*/ 82,
- /*0x2cb7*/ 931,
- -1,
- /*0xa745*/ 1050,
- /*0x0575*/ 460,
- /*0x0292*/ 233,
- /*0x13b5*/ 545,
- /*0x0435*/ 297,
- /*0x04b5*/ 378,
- /*0x01f5*/ 160,
- /*0x10435*/ 1140,
- /*0x03b7*/ 252,
- /*0x1e35*/ 639,
- /*0x1eb5*/ 698,
- /*0x0135*/ 81,
- /*0x2cb5*/ 930,
- /*0x10cc7*/ 1210,
- -1, -1,
- /*0x024b*/ 196,
- -1,
- /*0x16e61*/ 1287,
- -1, -1, -1,
- /*0x03b5*/ 250,
- /*0xa64d*/ 1003,
- -1, -1,
- /*0x00eb*/ 36,
- /*0x10cc5*/ 1208,
- /*0x2c73*/ 902,
- /*0x118c9*/ 1263,
- /*0x13b3*/ 543,
- /*0x0433*/ 295,
- /*0x04b3*/ 377,
- /*0x1e932*/ 1334,
- /*0x10433*/ 1138,
- -1,
- /*0x1e33*/ 638,
- /*0x1eb3*/ 697,
- /*0x0133*/ 80,
- /*0x2cb3*/ 929,
- -1,
- /*0x00ef*/ 40,
- /*0x16e63*/ 1289,
- -1,
- /*0x2c3a*/ 859,
- /*0xa64b*/ 1002,
- /*0x13c0*/ 556,
- /*0x0440*/ 308,
- /*0xa73f*/ 1047,
- /*0x03b3*/ 248,
- /*0x10440*/ 1151,
- -1,
- /*0x16e65*/ 1291,
- /*0x2c55*/ 886,
- /*0x0140*/ 86,
- /*0x10ce6*/ 1241,
- /*0x01c9*/ 139,
- -1, -1,
- /*0x1f43*/ 769,
- /*0x10e6*/ 500,
- -1,
- /*0x16e69*/ 1295,
- -1,
- /*0x028c*/ 232,
- /*0x03c0*/ 261,
- -1,
- /*0xa643*/ 998,
- -1,
- /*0x0479*/ 352,
- /*0x04f9*/ 412,
- /*0x0079*/ 23,
- /*0x16e67*/ 1293,
- /*0x104f9*/ 1200,
- /*0x1e79*/ 673,
- /*0x1ef9*/ 732,
- /*0xa737*/ 1043,
- /*0x0511*/ 424,
- /*0x118cd*/ 1267,
- /*0x1d79*/ 610,
- /*0x021d*/ 179,
- /*0x1f41*/ 767,
- -1, -1,
- /*0x2c4f*/ 880,
- -1,
- /*0x10cec*/ 1247,
- -1, -1,
- /*0xa641*/ 997,
- /*0xa735*/ 1042,
- /*0x10ec*/ 506,
- /*0x2171*/ 807,
- /*0x00ed*/ 38,
- -1,
- /*0x0247*/ 194,
- /*0x1f24*/ 754,
- /*0x13ad*/ 537,
- /*0x2c32*/ 851,
- /*0x04ad*/ 374,
- /*0x118cb*/ 1265,
- /*0x1042d*/ 1132,
- /*0x2d1a*/ 983,
- /*0x1e2d*/ 635,
- /*0x1ead*/ 694,
- /*0x012d*/ 78,
- /*0x2cad*/ 926,
- -1, -1,
- /*0x0288*/ 228,
- /*0x029e*/ 235,
- -1,
- /*0x13a5*/ 529,
- -1,
- /*0x04a5*/ 370,
- /*0x0584*/ 475,
- /*0x03ad*/ 243,
- /*0xa733*/ 1041,
- /*0x1e25*/ 631,
- /*0x1ea5*/ 690,
- /*0x0125*/ 74,
- /*0x2ca5*/ 922,
- /*0x118c3*/ 1257,
- -1,
- /*0xa647*/ 1000,
- /*0x2c49*/ 874,
- /*0x13a3*/ 527,
- -1,
- /*0x04a3*/ 369,
- -1,
- /*0x1f45*/ 771,
- /*0x2173*/ 809,
- /*0x1e23*/ 630,
- /*0x1ea3*/ 689,
- /*0x0123*/ 73,
- /*0x2ca3*/ 921,
- /*0xff59*/ 1125,
- /*0x0266*/ 213,
- /*0xa645*/ 999,
- -1, -1,
- /*0x048f*/ 359,
- -1, -1,
- /*0x118c1*/ 1255,
- /*0x1e0f*/ 620,
- /*0x1e8f*/ 684,
- /*0x010f*/ 63,
- /*0x2c8f*/ 911,
- /*0xa69b*/ 1033,
- -1, -1, -1,
- /*0x1e943*/ 1351,
- /*0xa68b*/ 1025,
- -1, -1,
- /*0x023f*/ 191,
- /*0x1f66*/ 782,
- -1,
- /*0x10cc0*/ 1203,
- -1, -1,
- /*0x1fe1*/ 803,
- -1,
- /*0x0481*/ 356,
- /*0x2d1c*/ 985,
- -1,
- /*0x026c*/ 218,
- /*0x1e01*/ 613,
- /*0x1e81*/ 677,
- /*0x0101*/ 56,
- /*0x2c81*/ 904,
- -1,
- /*0x2c4d*/ 878,
- /*0x1e941*/ 1349,
- /*0x0280*/ 224,
- /*0x16e6b*/ 1297,
- /*0x2175*/ 811,
- /*0x118c7*/ 1261,
- /*0x0282*/ 225,
- -1, -1, -1,
- /*0xa72d*/ 1039,
- -1,
- /*0x051d*/ 430,
- /*0x10f9*/ 519,
- -1, -1,
- /*0x1e924*/ 1320,
- -1,
- /*0x16e6f*/ 1301,
- /*0x118c5*/ 1259,
- /*0x00f1*/ 42,
- -1,
- /*0x2c4b*/ 876,
- /*0x1fe5*/ 804,
- -1,
- /*0xa725*/ 1035,
- -1,
- /*0x13a7*/ 531,
- -1,
- /*0x04a7*/ 371,
- /*0x1f22*/ 752,
- /*0x2d04*/ 961,
- /*0x1f37*/ 765,
- /*0x1e27*/ 632,
- /*0x1ea7*/ 691,
- /*0x0127*/ 75,
- /*0x2ca7*/ 923,
- -1, -1,
- /*0xa723*/ 1034,
- -1,
- /*0x2d11*/ 974,
- -1, -1,
- /*0x2c43*/ 868,
- -1,
- /*0x1f35*/ 763,
- /*0x00ee*/ 39,
- -1,
- /*0x047b*/ 353,
- /*0x04fb*/ 413,
- -1,
- /*0x0233*/ 189,
- /*0x104fb*/ 1202,
- /*0x1e7b*/ 674,
- /*0x1efb*/ 733,
- /*0x13b1*/ 541,
- /*0x0431*/ 293,
- /*0x04b1*/ 376,
- /*0x00f3*/ 44,
- /*0x10431*/ 1136,
- -1,
- /*0x1e31*/ 637,
- /*0x1eb1*/ 696,
- -1,
- /*0x2cb1*/ 928,
- /*0x2c41*/ 866,
- /*0x03fb*/ 291,
- /*0x0240*/ 192,
- /*0x0566*/ 445,
- /*0x16e6d*/ 1299,
- /*0x047d*/ 354,
- /*0x04fd*/ 414,
- /*0x1f33*/ 761,
- -1,
- /*0x03b1*/ 246,
- /*0x1e7d*/ 675,
- /*0x1efd*/ 734,
- /*0xff57*/ 1123,
- /*0x047f*/ 355,
- /*0x04ff*/ 415,
- /*0x1d7d*/ 611,
- -1, -1,
- /*0x1e7f*/ 676,
- /*0x1eff*/ 735,
- /*0x13bd*/ 553,
- /*0x043d*/ 305,
- /*0x04bd*/ 382,
- /*0x1f40*/ 766,
- /*0x1043d*/ 1148,
- /*0xa791*/ 1080,
- /*0x1e3d*/ 643,
- /*0x1ebd*/ 702,
- /*0x01bf*/ 137,
- /*0x2cbd*/ 934,
- -1, -1,
- /*0x1e93f*/ 1347,
- -1,
- /*0x056c*/ 451,
- /*0x2c47*/ 872,
- -1, -1, -1,
- /*0x03bd*/ 258,
- /*0x00f5*/ 46,
- -1,
- /*0x007a*/ 24,
- -1,
- /*0x104fa*/ 1201,
- /*0x1f79*/ 793,
- -1,
- /*0x017a*/ 114,
- /*0xa727*/ 1036,
- /*0x2c45*/ 870,
- /*0x13b9*/ 549,
- /*0x0439*/ 301,
- /*0x04b9*/ 380,
- /*0x022d*/ 186,
- /*0x10439*/ 1144,
- -1,
- /*0x1e39*/ 641,
- /*0x1eb9*/ 700,
- /*0x1e922*/ 1318,
- /*0x2cb9*/ 932,
- /*0x1e937*/ 1339,
- -1,
- /*0x13c2*/ 558,
- /*0x0442*/ 310,
- /*0x04c2*/ 384,
- -1,
- /*0x10442*/ 1153,
- -1,
- /*0x0225*/ 182,
- /*0x03b9*/ 254,
- /*0x0142*/ 87,
- /*0x13d0*/ 572,
- /*0x0450*/ 324,
- -1,
- /*0x1e935*/ 1337,
- /*0x13f2*/ 606,
- -1,
- /*0x2c66*/ 898,
- /*0x0072*/ 16,
- /*0x2d24*/ 993,
- /*0x104f2*/ 1193,
- -1,
- /*0x0223*/ 181,
- -1,
- /*0x2d1d*/ 986,
- /*0x24d0*/ 823,
- /*0x118c0*/ 1254,
- /*0xff51*/ 1117,
- -1,
- /*0x1f25*/ 755,
- -1, -1,
- /*0xa7c3*/ 1099,
- -1,
- /*0x03f2*/ 288,
- /*0x020f*/ 172,
- -1,
- /*0x2c3f*/ 864,
- -1,
- /*0xa77f*/ 1074,
- -1,
- /*0x1e933*/ 1335,
- /*0xff53*/ 1119,
- /*0x1f23*/ 753,
- -1,
- /*0x16e71*/ 1303,
- -1,
- /*0xa73d*/ 1046,
- /*0x2c6c*/ 901,
- /*0x13bb*/ 551,
- /*0x043b*/ 303,
- /*0x04bb*/ 381,
- -1,
- /*0x1043b*/ 1146,
- -1,
- /*0x1e3b*/ 642,
- /*0x1ebb*/ 701,
- /*0x1e940*/ 1348,
- /*0x2cbb*/ 933,
- /*0x0201*/ 165,
- -1, -1, -1,
- /*0x10fd*/ 521,
- -1,
- /*0x2c37*/ 856,
- /*0xa77a*/ 1072,
- -1,
- /*0x03bb*/ 256,
- -1,
- /*0x0579*/ 464,
- /*0x10ff*/ 523,
- /*0x16e6e*/ 1300,
- -1,
- /*0xa79d*/ 1086,
- /*0x01f9*/ 161,
- /*0x017c*/ 115,
- /*0xa739*/ 1044,
- -1,
- /*0x2c35*/ 854,
- /*0x1f01*/ 737,
- /*0x13af*/ 539,
- -1,
- /*0x04af*/ 375,
- /*0x16e73*/ 1305,
- /*0x1042f*/ 1134,
- -1,
- /*0x1e2f*/ 636,
- /*0x1eaf*/ 695,
- /*0x012f*/ 79,
- /*0x2caf*/ 927,
- -1, -1,
- /*0x1e05*/ 615,
- /*0x1e85*/ 679,
- /*0x0105*/ 58,
- /*0x2c85*/ 906,
- /*0x0227*/ 183,
- /*0x10fa*/ 520,
- /*0x052d*/ 438,
- /*0x03af*/ 245,
- -1, -1,
- /*0x13a9*/ 533,
- /*0x01ad*/ 131,
- /*0x04a9*/ 372,
- /*0x2c33*/ 852,
- /*0x10429*/ 1128,
- /*0x1e92d*/ 1329,
- /*0x1e29*/ 633,
- /*0x1ea9*/ 692,
- /*0x0129*/ 76,
- /*0x2ca9*/ 924,
- -1,
- /*0x0525*/ 434,
- -1,
- /*0x10cc2*/ 1205,
- -1,
- /*0x1f27*/ 757,
- /*0x01a5*/ 129,
- -1, -1,
- /*0x2c40*/ 865,
- /*0x1e925*/ 1321,
- -1,
- /*0x10cd0*/ 1219,
- /*0x0231*/ 188,
- /*0x2d22*/ 991,
- /*0x0523*/ 433,
- /*0x10cf2*/ 1253,
- /*0x10d0*/ 478,
- /*0x16e75*/ 1307,
- -1,
- /*0x01a3*/ 128,
- /*0x10f2*/ 512,
- -1,
- /*0xa73b*/ 1045,
- /*0x1e923*/ 1319,
- /*0x1fd1*/ 801,
- /*0x1f7b*/ 795,
- /*0x027d*/ 223,
- /*0x050f*/ 423,
- -1,
- /*0xff55*/ 1121,
- /*0x13ce*/ 570,
- /*0x044e*/ 322,
- /*0x04ce*/ 390,
- /*0x1f31*/ 759,
- /*0x1044e*/ 1165,
- -1, -1,
- /*0xa7bf*/ 1098,
- /*0x0477*/ 351,
- /*0x04f7*/ 411,
- /*0x0077*/ 21,
- /*0xa77c*/ 1073,
- /*0x104f7*/ 1198,
- /*0x1e77*/ 672,
- /*0x1ef7*/ 731,
- /*0x0177*/ 113,
- -1,
- /*0x1f7d*/ 797,
- -1,
- /*0x03ce*/ 274,
- -1,
- /*0x0501*/ 416,
- -1, -1,
- /*0xa72f*/ 1040,
- /*0x1e03*/ 614,
- /*0x1e83*/ 678,
- /*0x0103*/ 57,
- /*0x2c83*/ 905,
- /*0x13e8*/ 596,
- /*0xff4f*/ 1115,
- -1,
- /*0x0068*/ 7,
- -1,
- /*0x104e8*/ 1183,
- /*0xa7b7*/ 1094,
- /*0x13c6*/ 562,
- /*0x0446*/ 314,
- /*0x04c6*/ 386,
- -1,
- /*0x10446*/ 1157,
- -1,
- /*0x13f0*/ 604,
- /*0x24e8*/ 847,
- /*0x0146*/ 89,
- /*0x0070*/ 14,
- /*0xa729*/ 1037,
- /*0x104f0*/ 1191,
- -1,
- /*0xa7b5*/ 1093,
- -1, -1,
- /*0x1f7a*/ 794,
- -1,
- /*0x0242*/ 193,
- /*0x03c6*/ 266,
- -1, -1,
- /*0x0499*/ 364,
- /*0x0527*/ 435,
- -1, -1,
- /*0x1e19*/ 625,
- /*0x0250*/ 199,
- /*0x0119*/ 68,
- /*0x2c99*/ 916,
- -1,
- /*0x0272*/ 221,
- /*0x1e927*/ 1323,
- /*0x0581*/ 472,
- -1,
- /*0xff49*/ 1109,
- -1, -1,
- /*0x037b*/ 239,
- /*0x1f42*/ 768,
- -1, -1,
- /*0x00e6*/ 31,
- -1,
- /*0x057b*/ 466,
- -1,
- /*0x13c4*/ 560,
- /*0x0444*/ 312,
- /*0x04c4*/ 385,
- /*0x01fb*/ 162,
- /*0x10444*/ 1155,
- -1,
- /*0x1f72*/ 786,
- -1,
- /*0x0144*/ 88,
- -1, -1,
- /*0x2d2d*/ 996,
- -1, -1,
- /*0x037d*/ 241,
- /*0x1e931*/ 1333,
- -1, -1, -1,
- /*0x03c4*/ 264,
- /*0x057d*/ 468,
- /*0x2179*/ 815,
- /*0x13d6*/ 578,
- /*0x0456*/ 330,
- -1,
- /*0x01fd*/ 163,
- /*0x2d25*/ 994,
- /*0x00ec*/ 37,
- /*0x057f*/ 470,
- -1, -1,
- /*0x029d*/ 234,
- /*0x10cce*/ 1217,
- /*0x01ff*/ 164,
- -1, -1,
- /*0x24d6*/ 829,
- -1,
- /*0xff4d*/ 1113,
- -1,
- /*0x2d23*/ 992,
- /*0x01bd*/ 136,
- /*0x0495*/ 362,
- -1,
- /*0x10f7*/ 517,
- /*0x1e93d*/ 1345,
- /*0x1e15*/ 623,
- /*0x1e95*/ 687,
- /*0x0115*/ 66,
- /*0x2c95*/ 914,
- -1,
- /*0x022f*/ 187,
- -1,
- /*0x2d0f*/ 972,
- -1,
- /*0x057a*/ 465,
- /*0x118c2*/ 1256,
- /*0x0205*/ 167,
- -1,
- /*0x1f7c*/ 796,
- /*0xff4b*/ 1111,
- /*0x10ce8*/ 1243,
- -1, -1, -1,
- /*0x118d0*/ 1270,
- /*0x10e8*/ 502,
- /*0x13ea*/ 598,
- /*0x10cc6*/ 1209,
- -1,
- /*0x006a*/ 8,
- /*0x01b9*/ 135,
- /*0x104ea*/ 1185,
- /*0x0229*/ 184,
- /*0x10cf0*/ 1251,
- /*0x1e939*/ 1341,
- /*0xa7a5*/ 1090,
- /*0x2d01*/ 958,
- /*0x1f05*/ 741,
- /*0x10f0*/ 510,
- /*0x2c31*/ 850,
- -1,
- /*0xff43*/ 1103,
- -1, -1, -1, -1,
- /*0x1e942*/ 1350,
- -1, -1,
- /*0xa7a3*/ 1089,
- /*0x0572*/ 457,
- /*0x01d0*/ 142,
- /*0x13a1*/ 525,
- -1,
- /*0x04a1*/ 368,
- -1, -1, -1,
- /*0x1e21*/ 629,
- /*0x1ea1*/ 688,
- /*0x0121*/ 72,
- /*0x2ca1*/ 920,
- /*0xa691*/ 1028,
- /*0xff41*/ 1101,
- /*0x1e07*/ 616,
- /*0x1e87*/ 680,
- /*0x0107*/ 59,
- /*0x2c87*/ 907,
- -1,
- /*0x2c3d*/ 862,
- -1,
- /*0x0493*/ 361,
- -1,
- /*0x10cc4*/ 1207,
- /*0x2d27*/ 995,
- /*0x1e13*/ 622,
- /*0x1e93*/ 686,
- /*0x0113*/ 65,
- /*0x2c93*/ 913,
- -1, -1,
- /*0x13ab*/ 535,
- /*0x00f9*/ 49,
- /*0x04ab*/ 373,
- -1,
- /*0x1042b*/ 1130,
- /*0xa781*/ 1075,
- /*0x1e2b*/ 634,
- /*0x1eab*/ 693,
- /*0x012b*/ 77,
- /*0x2cab*/ 925,
- /*0x13e4*/ 592,
- /*0x0203*/ 166,
- /*0x1e93b*/ 1343,
- /*0x0064*/ 3,
- /*0x10cd6*/ 1225,
- /*0x104e4*/ 1179,
- /*0x037c*/ 240,
- /*0xff47*/ 1107,
- /*0x2c39*/ 858,
- /*0x10d6*/ 484,
- /*0x1f77*/ 791,
- /*0x0268*/ 214,
- /*0x057c*/ 467,
- /*0x13e2*/ 590,
- /*0x24e4*/ 843,
- /*0x16e66*/ 1292,
- /*0x0062*/ 1,
- -1,
- /*0x104e2*/ 1177,
- -1,
- /*0x2c42*/ 867,
- /*0xff45*/ 1105,
- /*0x1f03*/ 739,
- -1, -1,
- /*0x052f*/ 439,
- -1,
- /*0x24e2*/ 841,
- -1,
- /*0x2c50*/ 881,
- -1,
- /*0x0505*/ 418,
- -1,
- /*0xa7a7*/ 1091,
- /*0x1e92f*/ 1331,
- -1,
- /*0x0185*/ 119,
- /*0x13e0*/ 588,
- /*0x0219*/ 177,
- /*0x13da*/ 582,
- /*0x045a*/ 334,
- -1,
- /*0x104e0*/ 1175,
- /*0x217b*/ 817,
- /*0x104da*/ 1169,
- /*0x1f70*/ 784,
- /*0x16e6c*/ 1298,
- /*0x0529*/ 436,
- /*0x0078*/ 22,
- /*0x10cea*/ 1245,
- /*0x104f8*/ 1199,
- /*0x24e0*/ 839,
- -1,
- /*0x24da*/ 833,
- /*0x10ea*/ 504,
- -1,
- /*0x1e929*/ 1325,
- /*0x13dc*/ 584,
- /*0x045c*/ 336,
- /*0x13cc*/ 568,
- /*0x044c*/ 320,
- /*0x04cc*/ 389,
- /*0x104dc*/ 1171,
- /*0x1044c*/ 1163,
- /*0x03f8*/ 290,
- /*0x217d*/ 819,
- /*0x118ce*/ 1268,
- /*0x2c3b*/ 860,
- -1,
- /*0x13d8*/ 580,
- /*0x0458*/ 332,
- /*0x24dc*/ 835,
- -1,
- /*0x217f*/ 821,
- /*0x104d8*/ 1167,
- -1, -1,
- /*0xa72b*/ 1038,
- /*0x03cc*/ 272,
- /*0x0585*/ 476,
- /*0x13d4*/ 576,
- /*0x0454*/ 328,
- -1,
- /*0x24d8*/ 831,
- -1,
- /*0x1f44*/ 770,
- /*0x0256*/ 204,
- /*0x13d2*/ 574,
- /*0x0452*/ 326,
- /*0x0377*/ 238,
- -1, -1,
- /*0xa7bd*/ 1097,
- /*0x01ce*/ 141,
- /*0x24d4*/ 827,
- /*0x0577*/ 462,
- -1, -1,
- /*0x017e*/ 116,
- /*0x0497*/ 363,
- /*0x217a*/ 816,
- /*0x24d2*/ 825,
- /*0x118c6*/ 1260,
- /*0x1e17*/ 624,
- /*0x0215*/ 175,
- /*0x0117*/ 67,
- /*0x2c97*/ 915,
- /*0x0503*/ 417,
- -1,
- /*0x0076*/ 20,
- /*0x13f4*/ 608,
- /*0x104f6*/ 1197,
- /*0x0183*/ 118,
- /*0x0074*/ 18,
- /*0x10ce4*/ 1239,
- /*0x104f4*/ 1195,
- -1,
- /*0x0568*/ 447,
- -1,
- /*0x10e4*/ 498,
- /*0x13bc*/ 552,
- /*0x043c*/ 304,
- /*0xa7b9*/ 1095,
- -1,
- /*0x1043c*/ 1147,
- /*0x1f15*/ 749,
- -1,
- /*0x10ce2*/ 1237,
- /*0x013c*/ 84,
- /*0x01c6*/ 138,
- /*0x0570*/ 455,
- /*0x026a*/ 216,
- /*0x10e2*/ 496,
- /*0x13c8*/ 564,
- /*0x0448*/ 316,
- /*0x04c8*/ 387,
- /*0x2172*/ 808,
- /*0x10448*/ 1159,
- -1,
- /*0x03bc*/ 257,
- -1,
- /*0x0148*/ 90,
- /*0x16e79*/ 1311,
- -1,
- /*0x0519*/ 428,
- /*0x00fb*/ 51,
- -1, -1,
- /*0x118c4*/ 1258,
- /*0x0199*/ 124,
- -1,
- /*0x10ce0*/ 1235,
- /*0x03c8*/ 268,
- /*0x10cda*/ 1229,
- -1,
- /*0x0583*/ 474,
- /*0x10e0*/ 494,
- -1,
- /*0x10da*/ 488,
- -1, -1, -1,
- /*0x2c4e*/ 879,
- /*0x0207*/ 168,
- /*0x10f8*/ 518,
- -1, -1,
- /*0x00fd*/ 53,
- -1,
- /*0x2d05*/ 962,
- /*0x118d6*/ 1276,
- /*0x10cdc*/ 1231,
- -1,
- /*0x10ccc*/ 1215,
- /*0x0213*/ 174,
- /*0x00ff*/ 55,
- /*0x10dc*/ 490,
- -1,
- /*0x1f21*/ 751,
- -1, -1,
- /*0xa7bb*/ 1096,
- -1,
- /*0x10cd8*/ 1227,
- /*0x1f07*/ 743,
- -1,
- /*0x022b*/ 185,
- -1,
- /*0x10d8*/ 486,
- /*0x217c*/ 818,
- -1,
- /*0x2c68*/ 899,
- -1, -1,
- /*0x10cd4*/ 1223,
- /*0x1f13*/ 747,
- -1,
- /*0x01d6*/ 145,
- /*0x2c46*/ 871,
- /*0x10d4*/ 482,
- -1,
- /*0x10cd2*/ 1221,
- /*0x00fa*/ 50,
- /*0x13ca*/ 566,
- /*0x044a*/ 318,
- /*0x04ca*/ 388,
- /*0x10d2*/ 480,
- /*0x1044a*/ 1161,
- /*0x2184*/ 822,
- /*0x10fe*/ 522,
- /*0x0515*/ 426,
- -1, -1, -1, -1,
- /*0x0195*/ 123,
- -1,
- /*0x1f64*/ 780,
- -1,
- /*0xa785*/ 1077,
- /*0x13b6*/ 546,
- /*0x0436*/ 298,
- /*0x03ca*/ 270,
- -1,
- /*0x10436*/ 1141,
- /*0x10f6*/ 516,
- -1,
- /*0x13b4*/ 544,
- /*0x0434*/ 296,
- /*0x10f4*/ 514,
- /*0x1f62*/ 778,
- /*0x10434*/ 1139,
- -1,
- /*0x0260*/ 209,
- -1,
- /*0xa7a9*/ 1092,
- /*0x048d*/ 358,
- /*0x056a*/ 449,
- /*0x00f2*/ 43,
- /*0x03b6*/ 251,
- /*0x1e0d*/ 619,
- /*0x1e8d*/ 683,
- /*0x010d*/ 62,
- /*0x2c8d*/ 910,
- /*0x2c44*/ 869,
- /*0x2d03*/ 960,
- /*0x03b4*/ 249,
- /*0x10cc8*/ 1211,
- /*0x1e09*/ 617,
- /*0x1e89*/ 681,
- /*0x0109*/ 60,
- /*0x2c89*/ 908,
- -1,
- /*0x025c*/ 208,
- /*0x1f60*/ 776,
- -1, -1,
- /*0x13b0*/ 540,
- /*0x0430*/ 292,
- /*0x13de*/ 586,
- /*0x045e*/ 338,
- /*0x10430*/ 1135,
- /*0x1f78*/ 792,
- /*0x0521*/ 432,
- /*0x104de*/ 1173,
- /*0x214e*/ 805,
- /*0x2c56*/ 887,
- -1,
- /*0x01a1*/ 127,
- /*0x0507*/ 419,
- -1,
- /*0x049f*/ 367,
- /*0x2177*/ 813,
- /*0x24de*/ 837,
- -1,
- /*0x1e1f*/ 628,
- /*0x0254*/ 203,
- /*0x011f*/ 71,
- /*0x2c9f*/ 919,
- -1,
- /*0x0513*/ 425,
- -1,
- /*0x2d19*/ 982,
- /*0x0252*/ 201,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x00fc*/ 52,
- /*0x052b*/ 437,
- /*0x0217*/ 176,
- -1,
- /*0xa783*/ 1076,
- /*0x16e7b*/ 1313,
- -1, -1, -1, -1,
- /*0x1e92b*/ 1327,
- /*0x0564*/ 443,
- -1, -1, -1, -1,
- /*0x2170*/ 806,
- -1, -1, -1,
- /*0x2c6a*/ 900,
- -1, -1, -1,
- /*0x0562*/ 441,
- /*0x023c*/ 190,
- /*0x10cca*/ 1213,
- /*0x16e7d*/ 1315,
- /*0x118da*/ 1280,
- -1, -1, -1,
- /*0x1f76*/ 790,
- -1, -1,
- /*0x16e7f*/ 1317,
- /*0x1f74*/ 788,
- -1, -1, -1, -1,
- /*0xa799*/ 1084,
- -1, -1,
- /*0xa68f*/ 1027,
- -1,
- /*0x118dc*/ 1282,
- -1,
- /*0x118cc*/ 1266,
- -1, -1, -1, -1, -1, -1,
- /*0x01da*/ 147,
- /*0x0578*/ 463,
- /*0x2d15*/ 978,
- /*0x118d8*/ 1278,
- -1, -1, -1,
- /*0x16e7a*/ 1312,
- -1, -1, -1, -1, -1,
- /*0xa681*/ 1020,
- /*0x118d4*/ 1274,
- -1, -1, -1,
- /*0x01dc*/ 148,
- -1,
- /*0x01cc*/ 140,
- /*0x118d2*/ 1272,
- -1, -1, -1, -1, -1,
- /*0x10cde*/ 1233,
- -1, -1,
- /*0x01d8*/ 146,
- -1,
- /*0x10de*/ 492,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x01d4*/ 144,
- -1,
- /*0x16e72*/ 1304,
- -1, -1,
- /*0x057e*/ 469,
- -1,
- /*0x01d2*/ 143,
- -1,
- /*0x00e8*/ 33,
- -1, -1,
- /*0x0517*/ 427,
- -1,
- /*0x2d21*/ 990,
- -1, -1, -1, -1, -1,
- /*0x2d07*/ 964,
- /*0x0576*/ 461,
- /*0x00f0*/ 41,
- /*0xff42*/ 1102,
- -1,
- /*0x0574*/ 459,
- /*0x118c8*/ 1262,
- -1,
- /*0x2c5a*/ 891,
- -1, -1,
- /*0x2d13*/ 976,
- /*0xff50*/ 1116,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x020d*/ 171,
- /*0x1e93c*/ 1344,
- -1,
- /*0x2c5c*/ 893,
- -1,
- /*0x2c4c*/ 877,
- -1,
- /*0x1f36*/ 764,
- /*0x0209*/ 169,
- -1, -1, -1,
- /*0x16e7c*/ 1314,
- -1,
- /*0x1f34*/ 762,
- /*0x2c58*/ 889,
- -1, -1, -1,
- /*0x1fb1*/ 799,
- -1,
- /*0xa7a1*/ 1088,
- -1, -1, -1, -1,
- /*0x2c54*/ 885,
- /*0xa787*/ 1078,
- -1, -1, -1, -1, -1,
- /*0x2c52*/ 883,
- -1,
- /*0x021f*/ 180,
- -1, -1,
- /*0xa793*/ 1081,
- -1, -1, -1, -1, -1,
- /*0x1f30*/ 758,
- -1, -1, -1,
- /*0x0283*/ 226,
- -1, -1, -1,
- /*0x2c76*/ 903,
- /*0x118ca*/ 1264,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x2c3c*/ 861,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x2c48*/ 873,
- -1, -1, -1, -1, -1, -1,
- /*0x00ea*/ 35,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x2178*/ 814,
- /*0x16e77*/ 1309,
- -1,
- /*0x01b6*/ 134,
- -1, -1,
- /*0x1fd0*/ 800,
- /*0x1e936*/ 1338,
- -1, -1,
- /*0x01b4*/ 133,
- -1,
- /*0x050d*/ 422,
- /*0x2d17*/ 980,
- /*0x1e934*/ 1336,
- /*0x118de*/ 1284,
- -1, -1, -1, -1,
- /*0x0509*/ 420,
- -1, -1,
- /*0x16e68*/ 1294,
- -1, -1, -1, -1,
- /*0xff4e*/ 1114,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x16e70*/ 1302,
- -1, -1, -1,
- /*0x01b0*/ 132,
- -1, -1, -1,
- /*0x1e930*/ 1332,
- /*0x217e*/ 820,
- -1,
- /*0x051f*/ 431,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x2c4a*/ 875,
- -1,
- /*0x00e4*/ 29,
- -1,
- /*0xa685*/ 1022,
- -1,
- /*0x2176*/ 812,
- -1,
- /*0xa797*/ 1083,
- /*0xff46*/ 1106,
- /*0x2174*/ 810,
- -1, -1, -1, -1,
- /*0x00e2*/ 27,
- -1,
- /*0x2c36*/ 855,
- -1, -1, -1, -1, -1, -1,
- /*0x2c34*/ 853,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x00e0*/ 25,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x00f8*/ 48,
- -1, -1, -1, -1, -1, -1,
- /*0x2c30*/ 849,
- /*0xff44*/ 1104,
- /*0x2c5e*/ 895,
- -1, -1, -1, -1,
- /*0x0287*/ 227,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xff56*/ 1122,
- -1, -1,
- /*0xa683*/ 1021,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x16e6a*/ 1296,
- -1, -1, -1,
- /*0x00fe*/ 54,
- -1, -1,
- /*0x2d0d*/ 970,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x2d09*/ 966,
- -1, -1, -1, -1,
- /*0x00f6*/ 47,
- -1, -1, -1,
- /*0x00f4*/ 45,
- -1, -1, -1, -1,
- /*0xa699*/ 1032,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x2d1f*/ 988,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x16e64*/ 1290,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x16e62*/ 1288,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xa79f*/ 1087,
- -1, -1,
- /*0xa695*/ 1030,
- -1, -1, -1, -1, -1, -1,
- /*0x16e60*/ 1286,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x16e78*/ 1310,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xff5a*/ 1126,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xa687*/ 1023,
- /*0x16e7e*/ 1316,
- -1, -1,
- /*0xff4c*/ 1112,
- -1, -1, -1, -1, -1, -1,
- /*0xa693*/ 1029,
- -1, -1,
- /*0xff58*/ 1124,
- -1, -1,
- /*0x16e76*/ 1308,
- -1, -1, -1,
- /*0x16e74*/ 1306,
- -1, -1, -1,
- /*0xff54*/ 1120,
- -1, -1, -1, -1, -1, -1,
- /*0xff52*/ 1118,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xff48*/ 1108,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x1fe0*/ 802,
- /*0x0289*/ 229,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0xa697*/ 1031,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0xff4a*/ 1110,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xa68d*/ 1026,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xa689*/ 1024,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x1fb0*/ 798
- };
-
- if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseUnfold_11_hash(code);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code1_equal(code, CaseUnfold_11_Table[s].from))
- return &CaseUnfold_11_Table[s].to;
- }
- }
- return 0;
-}
-
-static const CaseUnfold_12_Type CaseUnfold_12_Table[] = {
-#define CaseUnfold_12 (*(CaseUnfold_12_Type (*)[58])(CaseUnfold_12_Table+0))
- {{0x0061, 0x02be}, {1, {0x1e9a}}},
- {{0x0066, 0x0066}, {1, {0xfb00}}},
- {{0x0066, 0x0069}, {1, {0xfb01}}},
- {{0x0066, 0x006c}, {1, {0xfb02}}},
- {{0x0068, 0x0331}, {1, {0x1e96}}},
- {{0x006a, 0x030c}, {1, {0x01f0}}},
- {{0x0073, 0x0073}, {2, {0x00df, 0x1e9e}}},
- {{0x0073, 0x0074}, {2, {0xfb05, 0xfb06}}},
- {{0x0074, 0x0308}, {1, {0x1e97}}},
- {{0x0077, 0x030a}, {1, {0x1e98}}},
- {{0x0079, 0x030a}, {1, {0x1e99}}},
- {{0x02bc, 0x006e}, {1, {0x0149}}},
- {{0x03ac, 0x03b9}, {1, {0x1fb4}}},
- {{0x03ae, 0x03b9}, {1, {0x1fc4}}},
- {{0x03b1, 0x0342}, {1, {0x1fb6}}},
- {{0x03b1, 0x03b9}, {2, {0x1fb3, 0x1fbc}}},
- {{0x03b7, 0x0342}, {1, {0x1fc6}}},
- {{0x03b7, 0x03b9}, {2, {0x1fc3, 0x1fcc}}},
- {{0x03b9, 0x0342}, {1, {0x1fd6}}},
- {{0x03c1, 0x0313}, {1, {0x1fe4}}},
- {{0x03c5, 0x0313}, {1, {0x1f50}}},
- {{0x03c5, 0x0342}, {1, {0x1fe6}}},
- {{0x03c9, 0x0342}, {1, {0x1ff6}}},
- {{0x03c9, 0x03b9}, {2, {0x1ff3, 0x1ffc}}},
- {{0x03ce, 0x03b9}, {1, {0x1ff4}}},
- {{0x0565, 0x0582}, {1, {0x0587}}},
- {{0x0574, 0x0565}, {1, {0xfb14}}},
- {{0x0574, 0x056b}, {1, {0xfb15}}},
- {{0x0574, 0x056d}, {1, {0xfb17}}},
- {{0x0574, 0x0576}, {1, {0xfb13}}},
- {{0x057e, 0x0576}, {1, {0xfb16}}},
- {{0x1f00, 0x03b9}, {2, {0x1f80, 0x1f88}}},
- {{0x1f01, 0x03b9}, {2, {0x1f81, 0x1f89}}},
- {{0x1f02, 0x03b9}, {2, {0x1f82, 0x1f8a}}},
- {{0x1f03, 0x03b9}, {2, {0x1f83, 0x1f8b}}},
- {{0x1f04, 0x03b9}, {2, {0x1f84, 0x1f8c}}},
- {{0x1f05, 0x03b9}, {2, {0x1f85, 0x1f8d}}},
- {{0x1f06, 0x03b9}, {2, {0x1f86, 0x1f8e}}},
- {{0x1f07, 0x03b9}, {2, {0x1f87, 0x1f8f}}},
- {{0x1f20, 0x03b9}, {2, {0x1f90, 0x1f98}}},
- {{0x1f21, 0x03b9}, {2, {0x1f91, 0x1f99}}},
- {{0x1f22, 0x03b9}, {2, {0x1f92, 0x1f9a}}},
- {{0x1f23, 0x03b9}, {2, {0x1f93, 0x1f9b}}},
- {{0x1f24, 0x03b9}, {2, {0x1f94, 0x1f9c}}},
- {{0x1f25, 0x03b9}, {2, {0x1f95, 0x1f9d}}},
- {{0x1f26, 0x03b9}, {2, {0x1f96, 0x1f9e}}},
- {{0x1f27, 0x03b9}, {2, {0x1f97, 0x1f9f}}},
- {{0x1f60, 0x03b9}, {2, {0x1fa0, 0x1fa8}}},
- {{0x1f61, 0x03b9}, {2, {0x1fa1, 0x1fa9}}},
- {{0x1f62, 0x03b9}, {2, {0x1fa2, 0x1faa}}},
- {{0x1f63, 0x03b9}, {2, {0x1fa3, 0x1fab}}},
- {{0x1f64, 0x03b9}, {2, {0x1fa4, 0x1fac}}},
- {{0x1f65, 0x03b9}, {2, {0x1fa5, 0x1fad}}},
- {{0x1f66, 0x03b9}, {2, {0x1fa6, 0x1fae}}},
- {{0x1f67, 0x03b9}, {2, {0x1fa7, 0x1faf}}},
- {{0x1f70, 0x03b9}, {1, {0x1fb2}}},
- {{0x1f74, 0x03b9}, {1, {0x1fc2}}},
- {{0x1f7c, 0x03b9}, {1, {0x1ff2}}},
-#define CaseUnfold_12_Locale (*(CaseUnfold_12_Type (*)[1])(CaseUnfold_12_Table+58))
- {{0x0069, 0x0307}, {1, {0x0130}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3,4,5,6 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_12_hash -N onigenc_unicode_CaseUnfold_12_lookup -n */
-
-/* maximum key range = 71, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseUnfold_12_hash(const OnigCodePoint *codes)
-{
- static const unsigned char asso_values[] =
- {
- 3, 58, 54, 57, 56, 16, 8, 2, 43, 82,
- 3, 1, 23, 82, 82, 82, 82, 82, 82, 4,
- 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
- 82, 82, 52, 51, 50, 49, 48, 47, 46, 45,
- 82, 82, 82, 82, 43, 82, 42, 82, 82, 13,
- 82, 82, 82, 82, 82, 11, 82, 1, 82, 82,
- 14, 82, 1, 82, 82, 31, 3, 82, 82, 30,
- 82, 82, 82, 10, 82, 82, 82, 82, 37, 82,
- 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
- 82, 82, 82, 82, 82, 82, 37, 15, 36, 35,
- 34, 17, 1, 33, 12, 4, 23, 23, 26, 21,
- 13, 82, 27, 82, 82, 2, 5, 82, 11, 16,
- 82, 15, 82, 82, 23, 82, 8, 82
- };
- return asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
-}
-
-static const CodePointList2 *
-onigenc_unicode_CaseUnfold_12_lookup(const OnigCodePoint *codes)
-{
- enum
- {
- MIN_CODE_VALUE = 0x61,
- MAX_CODE_VALUE = 0x1f7c,
- TOTAL_KEYWORDS = 59,
- MIN_WORD_LENGTH = 6,
- MAX_WORD_LENGTH = 6,
- MIN_HASH_VALUE = 11,
- MAX_HASH_VALUE = 81
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x1f66,0x03b9*/ 53,
- /*0x1f07,0x03b9*/ 38,
- /*0x1f00,0x03b9*/ 31,
- /*0x0066,0x0066*/ 1,
- /*0x1f74,0x03b9*/ 56,
- /*0x0073,0x0073*/ 6,
- /*0x0066,0x0069*/ 2,
- /*0x1f06,0x03b9*/ 37,
- /*0x0073,0x0074*/ 7,
- /*0x03b9,0x0342*/ 18,
- /*0x03c9,0x03b9*/ 23,
- /*0x03b7,0x03b9*/ 17,
- /*0x0069,0x0307*/ 58,
- /*0x03b1,0x03b9*/ 15,
- /*0x1f61,0x03b9*/ 48,
- /*0x1f05,0x03b9*/ 36,
- /*0x1f65,0x03b9*/ 52,
- /*0x0574,0x0576*/ 29,
- /*0x03c9,0x0342*/ 22,
- /*0x03b7,0x0342*/ 16,
- /*0x057e,0x0576*/ 30,
- /*0x03b1,0x0342*/ 14,
- /*0x1f7c,0x03b9*/ 57,
- /*0x0574,0x0565*/ 26,
- /*0x0079,0x030a*/ 10,
- /*0x0077,0x030a*/ 9,
- /*0x1f70,0x03b9*/ 55,
- /*0x0574,0x056d*/ 28,
- /*0x0066,0x006c*/ 3,
- /*0x0574,0x056b*/ 27,
- /*0x0061,0x02be*/ 0,
- /*0x0068,0x0331*/ 4,
- /*0x1f67,0x03b9*/ 54,
- /*0x1f64,0x03b9*/ 51,
- /*0x1f63,0x03b9*/ 50,
- /*0x1f62,0x03b9*/ 49,
- /*0x1f60,0x03b9*/ 47,
- /*0x03ce,0x03b9*/ 24,
- /*0x03c5,0x0342*/ 21,
- /*0x03c5,0x0313*/ 20,
- /*0x03c1,0x0313*/ 19,
- /*0x02bc,0x006e*/ 11,
- /*0x03ae,0x03b9*/ 13,
- /*0x03ac,0x03b9*/ 12,
- /*0x1f27,0x03b9*/ 46,
- /*0x1f26,0x03b9*/ 45,
- /*0x1f25,0x03b9*/ 44,
- /*0x1f24,0x03b9*/ 43,
- /*0x1f23,0x03b9*/ 42,
- /*0x1f22,0x03b9*/ 41,
- /*0x1f21,0x03b9*/ 40,
- /*0x1f20,0x03b9*/ 39,
- /*0x006a,0x030c*/ 5,
- /*0x1f02,0x03b9*/ 33,
- /*0x0074,0x0308*/ 8,
- /*0x1f04,0x03b9*/ 35,
- /*0x1f03,0x03b9*/ 34,
- /*0x1f01,0x03b9*/ 32,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x0565,0x0582*/ 25
- };
-
- if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
- codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseUnfold_12_hash(codes);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code2_equal(codes, CaseUnfold_12_Table[s].from))
- return &CaseUnfold_12_Table[s].to;
- }
- }
- return 0;
-}
-
-static const CaseUnfold_13_Type CaseUnfold_13_Table[] = {
-#define CaseUnfold_13 (*(CaseUnfold_13_Type (*)[14])(CaseUnfold_13_Table+0))
- {{0x0066, 0x0066, 0x0069}, {1, {0xfb03}}},
- {{0x0066, 0x0066, 0x006c}, {1, {0xfb04}}},
- {{0x03b1, 0x0342, 0x03b9}, {1, {0x1fb7}}},
- {{0x03b7, 0x0342, 0x03b9}, {1, {0x1fc7}}},
- {{0x03b9, 0x0308, 0x0300}, {1, {0x1fd2}}},
- {{0x03b9, 0x0308, 0x0301}, {2, {0x0390, 0x1fd3}}},
- {{0x03b9, 0x0308, 0x0342}, {1, {0x1fd7}}},
- {{0x03c5, 0x0308, 0x0300}, {1, {0x1fe2}}},
- {{0x03c5, 0x0308, 0x0301}, {2, {0x03b0, 0x1fe3}}},
- {{0x03c5, 0x0308, 0x0342}, {1, {0x1fe7}}},
- {{0x03c5, 0x0313, 0x0300}, {1, {0x1f52}}},
- {{0x03c5, 0x0313, 0x0301}, {1, {0x1f54}}},
- {{0x03c5, 0x0313, 0x0342}, {1, {0x1f56}}},
- {{0x03c9, 0x0342, 0x03b9}, {1, {0x1ff7}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3,4,5,6,7,8,9 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_13_hash -N onigenc_unicode_CaseUnfold_13_lookup -n */
-
-/* maximum key range = 20, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseUnfold_13_hash(const OnigCodePoint *codes)
-{
- static const unsigned char asso_values[] =
- {
- 7, 4, 47, 47, 47, 47, 1, 1, 2, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 1,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 11,
- 47, 47, 47, 47, 47, 10, 47, 2, 47, 47,
- 47, 47, 47, 47, 47, 47, 1, 47, 47, 1,
- 47, 47, 47, 9, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 1, 47, 47, 2, 47, 47, 1, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47
- };
- return asso_values[bits_at(codes, 8)] + asso_values[bits_at(codes, 7)] + asso_values[bits_at(codes, 6)] + asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
-}
-
-static const CodePointList2 *
-onigenc_unicode_CaseUnfold_13_lookup(const OnigCodePoint *codes)
-{
- enum
- {
- MIN_CODE_VALUE = 0x66,
- MAX_CODE_VALUE = 0x3c9,
- TOTAL_KEYWORDS = 14,
- MIN_WORD_LENGTH = 9,
- MAX_WORD_LENGTH = 9,
- MIN_HASH_VALUE = 27,
- MAX_HASH_VALUE = 46
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x03c5,0x0313,0x0342*/ 12,
- /*0x03c5,0x0308,0x0342*/ 9,
- /*0x03b9,0x0308,0x0342*/ 6,
- /*0x03c5,0x0313,0x0301*/ 11,
- /*0x03c5,0x0308,0x0301*/ 8,
- /*0x03b9,0x0308,0x0301*/ 5,
- /*0x03c5,0x0313,0x0300*/ 10,
- /*0x03c5,0x0308,0x0300*/ 7,
- /*0x03b9,0x0308,0x0300*/ 4,
- /*0x03c9,0x0342,0x03b9*/ 13,
- /*0x03b7,0x0342,0x03b9*/ 3,
- /*0x03b1,0x0342,0x03b9*/ 2,
- -1, -1, -1, -1, -1, -1,
- /*0x0066,0x0066,0x006c*/ 1,
- /*0x0066,0x0066,0x0069*/ 0
- };
-
- if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
- codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE &&
- codes[2] <= MAX_CODE_VALUE && codes[2] >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseUnfold_13_hash(codes);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code3_equal(codes, CaseUnfold_13_Table[s].from))
- return &CaseUnfold_13_Table[s].to;
- }
- }
- return 0;
-}
-
-static const OnigCodePoint CaseMappingSpecials[] = {
- L(1)|0x039C,
- L(2)|0x0053, 0x0073, L(2)|0x0053, 0x0053,
- L(2)|0x02BC, 0x004E,
- L(1)|0x0053,
- L(1)|0x01C5,
- L(2)|0x0064, 0x017D, L(1)|0x01C4,
- L(1)|0x01C8,
- L(2)|0x006C, 0x004A, L(1)|0x01C7,
- L(1)|0x01CB,
- L(2)|0x006E, 0x004A, L(1)|0x01CA,
- L(2)|0x004A, 0x030C,
- L(1)|0x01F2,
- L(2)|0x0064, 0x005A, L(1)|0x01F1,
- L(1)|0x0399,
- L(3)|0x0399, 0x0308, 0x0301,
- L(3)|0x03A5, 0x0308, 0x0301,
- L(1)|0x03A3,
- L(1)|0x0392,
- L(1)|0x0398,
- L(1)|0x03A6,
- L(1)|0x03A0,
- L(1)|0x039A,
- L(1)|0x03A1,
- L(1)|0x0395,
- L(2)|0x0535, 0x0582, L(2)|0x0535, 0x0552,
- L(1)|0x0412,
- L(1)|0x0414,
- L(1)|0x041E,
- L(1)|0x0421,
- L(1)|0x0422,
- L(1)|0x0422,
- L(1)|0x042A,
- L(1)|0x0462,
- L(1)|0xA64A,
- L(2)|0x0048, 0x0331,
- L(2)|0x0054, 0x0308,
- L(2)|0x0057, 0x030A,
- L(2)|0x0059, 0x030A,
- L(2)|0x0041, 0x02BE,
- L(1)|0x1E60,
- L(1)|0x00DF,
- L(2)|0x03A5, 0x0313,
- L(3)|0x03A5, 0x0313, 0x0300,
- L(3)|0x03A5, 0x0313, 0x0301,
- L(3)|0x03A5, 0x0313, 0x0342,
- L(1)|0x1F88, L(2)|0x1F08, 0x0399,
- L(1)|0x1F89, L(2)|0x1F09, 0x0399,
- L(1)|0x1F8A, L(2)|0x1F0A, 0x0399,
- L(1)|0x1F8B, L(2)|0x1F0B, 0x0399,
- L(1)|0x1F8C, L(2)|0x1F0C, 0x0399,
- L(1)|0x1F8D, L(2)|0x1F0D, 0x0399,
- L(1)|0x1F8E, L(2)|0x1F0E, 0x0399,
- L(1)|0x1F8F, L(2)|0x1F0F, 0x0399,
- L(2)|0x1F00, 0x0399, L(1)|0x1F80, L(2)|0x1F08, 0x0399,
- L(2)|0x1F01, 0x0399, L(1)|0x1F81, L(2)|0x1F09, 0x0399,
- L(2)|0x1F02, 0x0399, L(1)|0x1F82, L(2)|0x1F0A, 0x0399,
- L(2)|0x1F03, 0x0399, L(1)|0x1F83, L(2)|0x1F0B, 0x0399,
- L(2)|0x1F04, 0x0399, L(1)|0x1F84, L(2)|0x1F0C, 0x0399,
- L(2)|0x1F05, 0x0399, L(1)|0x1F85, L(2)|0x1F0D, 0x0399,
- L(2)|0x1F06, 0x0399, L(1)|0x1F86, L(2)|0x1F0E, 0x0399,
- L(2)|0x1F07, 0x0399, L(1)|0x1F87, L(2)|0x1F0F, 0x0399,
- L(1)|0x1F98, L(2)|0x1F28, 0x0399,
- L(1)|0x1F99, L(2)|0x1F29, 0x0399,
- L(1)|0x1F9A, L(2)|0x1F2A, 0x0399,
- L(1)|0x1F9B, L(2)|0x1F2B, 0x0399,
- L(1)|0x1F9C, L(2)|0x1F2C, 0x0399,
- L(1)|0x1F9D, L(2)|0x1F2D, 0x0399,
- L(1)|0x1F9E, L(2)|0x1F2E, 0x0399,
- L(1)|0x1F9F, L(2)|0x1F2F, 0x0399,
- L(2)|0x1F20, 0x0399, L(1)|0x1F90, L(2)|0x1F28, 0x0399,
- L(2)|0x1F21, 0x0399, L(1)|0x1F91, L(2)|0x1F29, 0x0399,
- L(2)|0x1F22, 0x0399, L(1)|0x1F92, L(2)|0x1F2A, 0x0399,
- L(2)|0x1F23, 0x0399, L(1)|0x1F93, L(2)|0x1F2B, 0x0399,
- L(2)|0x1F24, 0x0399, L(1)|0x1F94, L(2)|0x1F2C, 0x0399,
- L(2)|0x1F25, 0x0399, L(1)|0x1F95, L(2)|0x1F2D, 0x0399,
- L(2)|0x1F26, 0x0399, L(1)|0x1F96, L(2)|0x1F2E, 0x0399,
- L(2)|0x1F27, 0x0399, L(1)|0x1F97, L(2)|0x1F2F, 0x0399,
- L(1)|0x1FA8, L(2)|0x1F68, 0x0399,
- L(1)|0x1FA9, L(2)|0x1F69, 0x0399,
- L(1)|0x1FAA, L(2)|0x1F6A, 0x0399,
- L(1)|0x1FAB, L(2)|0x1F6B, 0x0399,
- L(1)|0x1FAC, L(2)|0x1F6C, 0x0399,
- L(1)|0x1FAD, L(2)|0x1F6D, 0x0399,
- L(1)|0x1FAE, L(2)|0x1F6E, 0x0399,
- L(1)|0x1FAF, L(2)|0x1F6F, 0x0399,
- L(2)|0x1F60, 0x0399, L(1)|0x1FA0, L(2)|0x1F68, 0x0399,
- L(2)|0x1F61, 0x0399, L(1)|0x1FA1, L(2)|0x1F69, 0x0399,
- L(2)|0x1F62, 0x0399, L(1)|0x1FA2, L(2)|0x1F6A, 0x0399,
- L(2)|0x1F63, 0x0399, L(1)|0x1FA3, L(2)|0x1F6B, 0x0399,
- L(2)|0x1F64, 0x0399, L(1)|0x1FA4, L(2)|0x1F6C, 0x0399,
- L(2)|0x1F65, 0x0399, L(1)|0x1FA5, L(2)|0x1F6D, 0x0399,
- L(2)|0x1F66, 0x0399, L(1)|0x1FA6, L(2)|0x1F6E, 0x0399,
- L(2)|0x1F67, 0x0399, L(1)|0x1FA7, L(2)|0x1F6F, 0x0399,
- L(2)|0x1FBA, 0x0345, L(2)|0x1FBA, 0x0399,
- L(1)|0x1FBC, L(2)|0x0391, 0x0399,
- L(2)|0x0386, 0x0345, L(2)|0x0386, 0x0399,
- L(2)|0x0391, 0x0342,
- L(3)|0x0391, 0x0342, 0x0345, L(3)|0x0391, 0x0342, 0x0399,
- L(2)|0x03B1, 0x0399, L(1)|0x1FB3, L(2)|0x0391, 0x0399,
- L(1)|0x0399,
- L(2)|0x1FCA, 0x0345, L(2)|0x1FCA, 0x0399,
- L(1)|0x1FCC, L(2)|0x0397, 0x0399,
- L(2)|0x0389, 0x0345, L(2)|0x0389, 0x0399,
- L(2)|0x0397, 0x0342,
- L(3)|0x0397, 0x0342, 0x0345, L(3)|0x0397, 0x0342, 0x0399,
- L(2)|0x03B7, 0x0399, L(1)|0x1FC3, L(2)|0x0397, 0x0399,
- L(3)|0x0399, 0x0308, 0x0300,
- L(3)|0x0399, 0x0308, 0x0301,
- L(2)|0x0399, 0x0342,
- L(3)|0x0399, 0x0308, 0x0342,
- L(3)|0x03A5, 0x0308, 0x0300,
- L(3)|0x03A5, 0x0308, 0x0301,
- L(2)|0x03A1, 0x0313,
- L(2)|0x03A5, 0x0342,
- L(3)|0x03A5, 0x0308, 0x0342,
- L(2)|0x1FFA, 0x0345, L(2)|0x1FFA, 0x0399,
- L(1)|0x1FFC, L(2)|0x03A9, 0x0399,
- L(2)|0x038F, 0x0345, L(2)|0x038F, 0x0399,
- L(2)|0x03A9, 0x0342,
- L(3)|0x03A9, 0x0342, 0x0345, L(3)|0x03A9, 0x0342, 0x0399,
- L(2)|0x03C9, 0x0399, L(1)|0x1FF3, L(2)|0x03A9, 0x0399,
- L(2)|0x0046, 0x0066, L(2)|0x0046, 0x0046,
- L(2)|0x0046, 0x0069, L(2)|0x0046, 0x0049,
- L(2)|0x0046, 0x006C, L(2)|0x0046, 0x004C,
- L(3)|0x0046, 0x0066, 0x0069, L(3)|0x0046, 0x0046, 0x0049,
- L(3)|0x0046, 0x0066, 0x006C, L(3)|0x0046, 0x0046, 0x004C,
- L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
- L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
- L(2)|0x0544, 0x0576, L(2)|0x0544, 0x0546,
- L(2)|0x0544, 0x0565, L(2)|0x0544, 0x0535,
- L(2)|0x0544, 0x056B, L(2)|0x0544, 0x053B,
- L(2)|0x054E, 0x0576, L(2)|0x054E, 0x0546,
- L(2)|0x0544, 0x056D, L(2)|0x0544, 0x053D,
-};
diff --git a/enc/unicode/12.1.0/name2ctype.h b/enc/unicode/12.1.0/name2ctype.h
deleted file mode 100644
index b2270d5cac..0000000000
--- a/enc/unicode/12.1.0/name2ctype.h
+++ /dev/null
@@ -1,41810 +0,0 @@
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -c -j1 -i1 -t -C -P -T -H uniname2ctype_hash -Q uniname2ctype_pool -N uniname2ctype_p */
-#ifndef USE_UNICODE_PROPERTIES
-/* Computed positions: -k'1,3' */
-#else /* USE_UNICODE_PROPERTIES */
-/* Computed positions: -k'1-3,5-6,12,16,$' */
-#endif /* USE_UNICODE_PROPERTIES */
-
-#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
- && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
- && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
- && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
- && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
- && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
- && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
- && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
- && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
- && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
- && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
- && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
- && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
- && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
- && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
- && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
- && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
- && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
- && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
- && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
- && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
- && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
- && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
-/* The character set is not based on ISO-646. */
-#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
-#endif
-
-
-
-/* 'NEWLINE': [[:NEWLINE:]] */
-static const OnigCodePoint CR_NEWLINE[] = {
- 1,
- 0x000a, 0x000a,
-}; /* CR_NEWLINE */
-
-/* 'Alpha': [[:Alpha:]] */
-static const OnigCodePoint CR_Alpha[] = {
- 679,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0345, 0x0345,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05b0, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0657,
- 0x0659, 0x065f,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06e1, 0x06e8,
- 0x06ed, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x073f,
- 0x074d, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0817,
- 0x081a, 0x082c,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d4, 0x08df,
- 0x08e3, 0x08e9,
- 0x08f0, 0x093b,
- 0x093d, 0x094c,
- 0x094e, 0x0950,
- 0x0955, 0x0963,
- 0x0971, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09ce, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4c,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a70, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0af9, 0x0afc,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4c,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccc,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d7a, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e46,
- 0x0e4d, 0x0e4d,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ecd, 0x0ecd,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f81,
- 0x0f88, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x1000, 0x1036,
- 0x1038, 0x1038,
- 0x103b, 0x103f,
- 0x1050, 0x108f,
- 0x109a, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1713,
- 0x1720, 0x1733,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17b3,
- 0x17b6, 0x17c8,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x1938,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a61, 0x1a74,
- 0x1aa7, 0x1aa7,
- 0x1b00, 0x1b33,
- 0x1b35, 0x1b43,
- 0x1b45, 0x1b4b,
- 0x1b80, 0x1ba9,
- 0x1bac, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1be7, 0x1bf1,
- 0x1c00, 0x1c36,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1de7, 0x1df4,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa674, 0xa67b,
- 0xa67f, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa805,
- 0xa807, 0xa827,
- 0xa840, 0xa873,
- 0xa880, 0xa8c3,
- 0xa8c5, 0xa8c5,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8ff,
- 0xa90a, 0xa92a,
- 0xa930, 0xa952,
- 0xa960, 0xa97c,
- 0xa980, 0xa9b2,
- 0xa9b4, 0xa9bf,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaabe,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf5,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabea,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11045,
- 0x11082, 0x110b8,
- 0x110d0, 0x110e8,
- 0x11100, 0x11132,
- 0x11144, 0x11146,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11180, 0x111bf,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11234,
- 0x11237, 0x11237,
- 0x1123e, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112e8,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134c,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11400, 0x11441,
- 0x11443, 0x11445,
- 0x11447, 0x1144a,
- 0x1145f, 0x1145f,
- 0x11480, 0x114c1,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115b5,
- 0x115b8, 0x115be,
- 0x115d8, 0x115dd,
- 0x11600, 0x1163e,
- 0x11640, 0x11640,
- 0x11644, 0x11644,
- 0x11680, 0x116b5,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172a,
- 0x11800, 0x11838,
- 0x118a0, 0x118df,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119df,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a32,
- 0x11a35, 0x11a3e,
- 0x11a50, 0x11a97,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c3e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d41,
- 0x11d43, 0x11d43,
- 0x11d46, 0x11d47,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d96,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef6,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9e, 0x1bc9e,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2eb,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e947, 0x1e947,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_Alpha */
-
-/* 'Blank': [[:Blank:]] */
-static const OnigCodePoint CR_Blank[] = {
- 8,
- 0x0009, 0x0009,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x2000, 0x200a,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000,
-}; /* CR_Blank */
-
-/* 'Cntrl': [[:Cntrl:]] */
-static const OnigCodePoint CR_Cntrl[] = {
- 2,
- 0x0000, 0x001f,
- 0x007f, 0x009f,
-}; /* CR_Cntrl */
-
-/* 'Digit': [[:Digit:]] */
-static const OnigCodePoint CR_Digit[] = {
- 59,
- 0x0030, 0x0039,
- 0x0660, 0x0669,
- 0x06f0, 0x06f9,
- 0x07c0, 0x07c9,
- 0x0966, 0x096f,
- 0x09e6, 0x09ef,
- 0x0a66, 0x0a6f,
- 0x0ae6, 0x0aef,
- 0x0b66, 0x0b6f,
- 0x0be6, 0x0bef,
- 0x0c66, 0x0c6f,
- 0x0ce6, 0x0cef,
- 0x0d66, 0x0d6f,
- 0x0de6, 0x0def,
- 0x0e50, 0x0e59,
- 0x0ed0, 0x0ed9,
- 0x0f20, 0x0f29,
- 0x1040, 0x1049,
- 0x1090, 0x1099,
- 0x17e0, 0x17e9,
- 0x1810, 0x1819,
- 0x1946, 0x194f,
- 0x19d0, 0x19d9,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1b50, 0x1b59,
- 0x1bb0, 0x1bb9,
- 0x1c40, 0x1c49,
- 0x1c50, 0x1c59,
- 0xa620, 0xa629,
- 0xa8d0, 0xa8d9,
- 0xa900, 0xa909,
- 0xa9d0, 0xa9d9,
- 0xa9f0, 0xa9f9,
- 0xaa50, 0xaa59,
- 0xabf0, 0xabf9,
- 0xff10, 0xff19,
- 0x104a0, 0x104a9,
- 0x10d30, 0x10d39,
- 0x11066, 0x1106f,
- 0x110f0, 0x110f9,
- 0x11136, 0x1113f,
- 0x111d0, 0x111d9,
- 0x112f0, 0x112f9,
- 0x11450, 0x11459,
- 0x114d0, 0x114d9,
- 0x11650, 0x11659,
- 0x116c0, 0x116c9,
- 0x11730, 0x11739,
- 0x118e0, 0x118e9,
- 0x11c50, 0x11c59,
- 0x11d50, 0x11d59,
- 0x11da0, 0x11da9,
- 0x16a60, 0x16a69,
- 0x16b50, 0x16b59,
- 0x1d7ce, 0x1d7ff,
- 0x1e140, 0x1e149,
- 0x1e2f0, 0x1e2f9,
- 0x1e950, 0x1e959,
-}; /* CR_Digit */
-
-/* 'Graph': [[:Graph:]] */
-static const OnigCodePoint CR_Graph[] = {
- 671,
- 0x0021, 0x007e,
- 0x00a1, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x167f,
- 0x1681, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x200b, 0x2027,
- 0x202a, 0x202e,
- 0x2030, 0x205e,
- 0x2060, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3001, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xe000, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd,
-}; /* CR_Graph */
-
-/* 'Lower': [[:Lower:]] */
-static const OnigCodePoint CR_Lower[] = {
- 649,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00df, 0x00f6,
- 0x00f8, 0x00ff,
- 0x0101, 0x0101,
- 0x0103, 0x0103,
- 0x0105, 0x0105,
- 0x0107, 0x0107,
- 0x0109, 0x0109,
- 0x010b, 0x010b,
- 0x010d, 0x010d,
- 0x010f, 0x010f,
- 0x0111, 0x0111,
- 0x0113, 0x0113,
- 0x0115, 0x0115,
- 0x0117, 0x0117,
- 0x0119, 0x0119,
- 0x011b, 0x011b,
- 0x011d, 0x011d,
- 0x011f, 0x011f,
- 0x0121, 0x0121,
- 0x0123, 0x0123,
- 0x0125, 0x0125,
- 0x0127, 0x0127,
- 0x0129, 0x0129,
- 0x012b, 0x012b,
- 0x012d, 0x012d,
- 0x012f, 0x012f,
- 0x0131, 0x0131,
- 0x0133, 0x0133,
- 0x0135, 0x0135,
- 0x0137, 0x0138,
- 0x013a, 0x013a,
- 0x013c, 0x013c,
- 0x013e, 0x013e,
- 0x0140, 0x0140,
- 0x0142, 0x0142,
- 0x0144, 0x0144,
- 0x0146, 0x0146,
- 0x0148, 0x0149,
- 0x014b, 0x014b,
- 0x014d, 0x014d,
- 0x014f, 0x014f,
- 0x0151, 0x0151,
- 0x0153, 0x0153,
- 0x0155, 0x0155,
- 0x0157, 0x0157,
- 0x0159, 0x0159,
- 0x015b, 0x015b,
- 0x015d, 0x015d,
- 0x015f, 0x015f,
- 0x0161, 0x0161,
- 0x0163, 0x0163,
- 0x0165, 0x0165,
- 0x0167, 0x0167,
- 0x0169, 0x0169,
- 0x016b, 0x016b,
- 0x016d, 0x016d,
- 0x016f, 0x016f,
- 0x0171, 0x0171,
- 0x0173, 0x0173,
- 0x0175, 0x0175,
- 0x0177, 0x0177,
- 0x017a, 0x017a,
- 0x017c, 0x017c,
- 0x017e, 0x0180,
- 0x0183, 0x0183,
- 0x0185, 0x0185,
- 0x0188, 0x0188,
- 0x018c, 0x018d,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019b,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01aa, 0x01ab,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01ba,
- 0x01bd, 0x01bf,
- 0x01c6, 0x01c6,
- 0x01c9, 0x01c9,
- 0x01cc, 0x01cc,
- 0x01ce, 0x01ce,
- 0x01d0, 0x01d0,
- 0x01d2, 0x01d2,
- 0x01d4, 0x01d4,
- 0x01d6, 0x01d6,
- 0x01d8, 0x01d8,
- 0x01da, 0x01da,
- 0x01dc, 0x01dd,
- 0x01df, 0x01df,
- 0x01e1, 0x01e1,
- 0x01e3, 0x01e3,
- 0x01e5, 0x01e5,
- 0x01e7, 0x01e7,
- 0x01e9, 0x01e9,
- 0x01eb, 0x01eb,
- 0x01ed, 0x01ed,
- 0x01ef, 0x01f0,
- 0x01f3, 0x01f3,
- 0x01f5, 0x01f5,
- 0x01f9, 0x01f9,
- 0x01fb, 0x01fb,
- 0x01fd, 0x01fd,
- 0x01ff, 0x01ff,
- 0x0201, 0x0201,
- 0x0203, 0x0203,
- 0x0205, 0x0205,
- 0x0207, 0x0207,
- 0x0209, 0x0209,
- 0x020b, 0x020b,
- 0x020d, 0x020d,
- 0x020f, 0x020f,
- 0x0211, 0x0211,
- 0x0213, 0x0213,
- 0x0215, 0x0215,
- 0x0217, 0x0217,
- 0x0219, 0x0219,
- 0x021b, 0x021b,
- 0x021d, 0x021d,
- 0x021f, 0x021f,
- 0x0221, 0x0221,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0239,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0293,
- 0x0295, 0x02b8,
- 0x02c0, 0x02c1,
- 0x02e0, 0x02e4,
- 0x0345, 0x0345,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037a, 0x037d,
- 0x0390, 0x0390,
- 0x03ac, 0x03ce,
- 0x03d0, 0x03d1,
- 0x03d5, 0x03d7,
- 0x03d9, 0x03d9,
- 0x03db, 0x03db,
- 0x03dd, 0x03dd,
- 0x03df, 0x03df,
- 0x03e1, 0x03e1,
- 0x03e3, 0x03e3,
- 0x03e5, 0x03e5,
- 0x03e7, 0x03e7,
- 0x03e9, 0x03e9,
- 0x03eb, 0x03eb,
- 0x03ed, 0x03ed,
- 0x03ef, 0x03f3,
- 0x03f5, 0x03f5,
- 0x03f8, 0x03f8,
- 0x03fb, 0x03fc,
- 0x0430, 0x045f,
- 0x0461, 0x0461,
- 0x0463, 0x0463,
- 0x0465, 0x0465,
- 0x0467, 0x0467,
- 0x0469, 0x0469,
- 0x046b, 0x046b,
- 0x046d, 0x046d,
- 0x046f, 0x046f,
- 0x0471, 0x0471,
- 0x0473, 0x0473,
- 0x0475, 0x0475,
- 0x0477, 0x0477,
- 0x0479, 0x0479,
- 0x047b, 0x047b,
- 0x047d, 0x047d,
- 0x047f, 0x047f,
- 0x0481, 0x0481,
- 0x048b, 0x048b,
- 0x048d, 0x048d,
- 0x048f, 0x048f,
- 0x0491, 0x0491,
- 0x0493, 0x0493,
- 0x0495, 0x0495,
- 0x0497, 0x0497,
- 0x0499, 0x0499,
- 0x049b, 0x049b,
- 0x049d, 0x049d,
- 0x049f, 0x049f,
- 0x04a1, 0x04a1,
- 0x04a3, 0x04a3,
- 0x04a5, 0x04a5,
- 0x04a7, 0x04a7,
- 0x04a9, 0x04a9,
- 0x04ab, 0x04ab,
- 0x04ad, 0x04ad,
- 0x04af, 0x04af,
- 0x04b1, 0x04b1,
- 0x04b3, 0x04b3,
- 0x04b5, 0x04b5,
- 0x04b7, 0x04b7,
- 0x04b9, 0x04b9,
- 0x04bb, 0x04bb,
- 0x04bd, 0x04bd,
- 0x04bf, 0x04bf,
- 0x04c2, 0x04c2,
- 0x04c4, 0x04c4,
- 0x04c6, 0x04c6,
- 0x04c8, 0x04c8,
- 0x04ca, 0x04ca,
- 0x04cc, 0x04cc,
- 0x04ce, 0x04cf,
- 0x04d1, 0x04d1,
- 0x04d3, 0x04d3,
- 0x04d5, 0x04d5,
- 0x04d7, 0x04d7,
- 0x04d9, 0x04d9,
- 0x04db, 0x04db,
- 0x04dd, 0x04dd,
- 0x04df, 0x04df,
- 0x04e1, 0x04e1,
- 0x04e3, 0x04e3,
- 0x04e5, 0x04e5,
- 0x04e7, 0x04e7,
- 0x04e9, 0x04e9,
- 0x04eb, 0x04eb,
- 0x04ed, 0x04ed,
- 0x04ef, 0x04ef,
- 0x04f1, 0x04f1,
- 0x04f3, 0x04f3,
- 0x04f5, 0x04f5,
- 0x04f7, 0x04f7,
- 0x04f9, 0x04f9,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0560, 0x0588,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d00, 0x1dbf,
- 0x1e01, 0x1e01,
- 0x1e03, 0x1e03,
- 0x1e05, 0x1e05,
- 0x1e07, 0x1e07,
- 0x1e09, 0x1e09,
- 0x1e0b, 0x1e0b,
- 0x1e0d, 0x1e0d,
- 0x1e0f, 0x1e0f,
- 0x1e11, 0x1e11,
- 0x1e13, 0x1e13,
- 0x1e15, 0x1e15,
- 0x1e17, 0x1e17,
- 0x1e19, 0x1e19,
- 0x1e1b, 0x1e1b,
- 0x1e1d, 0x1e1d,
- 0x1e1f, 0x1e1f,
- 0x1e21, 0x1e21,
- 0x1e23, 0x1e23,
- 0x1e25, 0x1e25,
- 0x1e27, 0x1e27,
- 0x1e29, 0x1e29,
- 0x1e2b, 0x1e2b,
- 0x1e2d, 0x1e2d,
- 0x1e2f, 0x1e2f,
- 0x1e31, 0x1e31,
- 0x1e33, 0x1e33,
- 0x1e35, 0x1e35,
- 0x1e37, 0x1e37,
- 0x1e39, 0x1e39,
- 0x1e3b, 0x1e3b,
- 0x1e3d, 0x1e3d,
- 0x1e3f, 0x1e3f,
- 0x1e41, 0x1e41,
- 0x1e43, 0x1e43,
- 0x1e45, 0x1e45,
- 0x1e47, 0x1e47,
- 0x1e49, 0x1e49,
- 0x1e4b, 0x1e4b,
- 0x1e4d, 0x1e4d,
- 0x1e4f, 0x1e4f,
- 0x1e51, 0x1e51,
- 0x1e53, 0x1e53,
- 0x1e55, 0x1e55,
- 0x1e57, 0x1e57,
- 0x1e59, 0x1e59,
- 0x1e5b, 0x1e5b,
- 0x1e5d, 0x1e5d,
- 0x1e5f, 0x1e5f,
- 0x1e61, 0x1e61,
- 0x1e63, 0x1e63,
- 0x1e65, 0x1e65,
- 0x1e67, 0x1e67,
- 0x1e69, 0x1e69,
- 0x1e6b, 0x1e6b,
- 0x1e6d, 0x1e6d,
- 0x1e6f, 0x1e6f,
- 0x1e71, 0x1e71,
- 0x1e73, 0x1e73,
- 0x1e75, 0x1e75,
- 0x1e77, 0x1e77,
- 0x1e79, 0x1e79,
- 0x1e7b, 0x1e7b,
- 0x1e7d, 0x1e7d,
- 0x1e7f, 0x1e7f,
- 0x1e81, 0x1e81,
- 0x1e83, 0x1e83,
- 0x1e85, 0x1e85,
- 0x1e87, 0x1e87,
- 0x1e89, 0x1e89,
- 0x1e8b, 0x1e8b,
- 0x1e8d, 0x1e8d,
- 0x1e8f, 0x1e8f,
- 0x1e91, 0x1e91,
- 0x1e93, 0x1e93,
- 0x1e95, 0x1e9d,
- 0x1e9f, 0x1e9f,
- 0x1ea1, 0x1ea1,
- 0x1ea3, 0x1ea3,
- 0x1ea5, 0x1ea5,
- 0x1ea7, 0x1ea7,
- 0x1ea9, 0x1ea9,
- 0x1eab, 0x1eab,
- 0x1ead, 0x1ead,
- 0x1eaf, 0x1eaf,
- 0x1eb1, 0x1eb1,
- 0x1eb3, 0x1eb3,
- 0x1eb5, 0x1eb5,
- 0x1eb7, 0x1eb7,
- 0x1eb9, 0x1eb9,
- 0x1ebb, 0x1ebb,
- 0x1ebd, 0x1ebd,
- 0x1ebf, 0x1ebf,
- 0x1ec1, 0x1ec1,
- 0x1ec3, 0x1ec3,
- 0x1ec5, 0x1ec5,
- 0x1ec7, 0x1ec7,
- 0x1ec9, 0x1ec9,
- 0x1ecb, 0x1ecb,
- 0x1ecd, 0x1ecd,
- 0x1ecf, 0x1ecf,
- 0x1ed1, 0x1ed1,
- 0x1ed3, 0x1ed3,
- 0x1ed5, 0x1ed5,
- 0x1ed7, 0x1ed7,
- 0x1ed9, 0x1ed9,
- 0x1edb, 0x1edb,
- 0x1edd, 0x1edd,
- 0x1edf, 0x1edf,
- 0x1ee1, 0x1ee1,
- 0x1ee3, 0x1ee3,
- 0x1ee5, 0x1ee5,
- 0x1ee7, 0x1ee7,
- 0x1ee9, 0x1ee9,
- 0x1eeb, 0x1eeb,
- 0x1eed, 0x1eed,
- 0x1eef, 0x1eef,
- 0x1ef1, 0x1ef1,
- 0x1ef3, 0x1ef3,
- 0x1ef5, 0x1ef5,
- 0x1ef7, 0x1ef7,
- 0x1ef9, 0x1ef9,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 0x1f07,
- 0x1f10, 0x1f15,
- 0x1f20, 0x1f27,
- 0x1f30, 0x1f37,
- 0x1f40, 0x1f45,
- 0x1f50, 0x1f57,
- 0x1f60, 0x1f67,
- 0x1f70, 0x1f7d,
- 0x1f80, 0x1f87,
- 0x1f90, 0x1f97,
- 0x1fa0, 0x1fa7,
- 0x1fb0, 0x1fb4,
- 0x1fb6, 0x1fb7,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fc7,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fd7,
- 0x1fe0, 0x1fe7,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ff7,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x210a, 0x210a,
- 0x210e, 0x210f,
- 0x2113, 0x2113,
- 0x212f, 0x212f,
- 0x2134, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213d,
- 0x2146, 0x2149,
- 0x214e, 0x214e,
- 0x2170, 0x217f,
- 0x2184, 0x2184,
- 0x24d0, 0x24e9,
- 0x2c30, 0x2c5e,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c71, 0x2c71,
- 0x2c73, 0x2c74,
- 0x2c76, 0x2c7d,
- 0x2c81, 0x2c81,
- 0x2c83, 0x2c83,
- 0x2c85, 0x2c85,
- 0x2c87, 0x2c87,
- 0x2c89, 0x2c89,
- 0x2c8b, 0x2c8b,
- 0x2c8d, 0x2c8d,
- 0x2c8f, 0x2c8f,
- 0x2c91, 0x2c91,
- 0x2c93, 0x2c93,
- 0x2c95, 0x2c95,
- 0x2c97, 0x2c97,
- 0x2c99, 0x2c99,
- 0x2c9b, 0x2c9b,
- 0x2c9d, 0x2c9d,
- 0x2c9f, 0x2c9f,
- 0x2ca1, 0x2ca1,
- 0x2ca3, 0x2ca3,
- 0x2ca5, 0x2ca5,
- 0x2ca7, 0x2ca7,
- 0x2ca9, 0x2ca9,
- 0x2cab, 0x2cab,
- 0x2cad, 0x2cad,
- 0x2caf, 0x2caf,
- 0x2cb1, 0x2cb1,
- 0x2cb3, 0x2cb3,
- 0x2cb5, 0x2cb5,
- 0x2cb7, 0x2cb7,
- 0x2cb9, 0x2cb9,
- 0x2cbb, 0x2cbb,
- 0x2cbd, 0x2cbd,
- 0x2cbf, 0x2cbf,
- 0x2cc1, 0x2cc1,
- 0x2cc3, 0x2cc3,
- 0x2cc5, 0x2cc5,
- 0x2cc7, 0x2cc7,
- 0x2cc9, 0x2cc9,
- 0x2ccb, 0x2ccb,
- 0x2ccd, 0x2ccd,
- 0x2ccf, 0x2ccf,
- 0x2cd1, 0x2cd1,
- 0x2cd3, 0x2cd3,
- 0x2cd5, 0x2cd5,
- 0x2cd7, 0x2cd7,
- 0x2cd9, 0x2cd9,
- 0x2cdb, 0x2cdb,
- 0x2cdd, 0x2cdd,
- 0x2cdf, 0x2cdf,
- 0x2ce1, 0x2ce1,
- 0x2ce3, 0x2ce4,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69d,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa731,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa778,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa78e, 0xa78e,
- 0xa791, 0xa791,
- 0xa793, 0xa795,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7af, 0xa7af,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c3, 0xa7c3,
- 0xa7f8, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 0x1d41a, 0x1d433,
- 0x1d44e, 0x1d454,
- 0x1d456, 0x1d467,
- 0x1d482, 0x1d49b,
- 0x1d4b6, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d4cf,
- 0x1d4ea, 0x1d503,
- 0x1d51e, 0x1d537,
- 0x1d552, 0x1d56b,
- 0x1d586, 0x1d59f,
- 0x1d5ba, 0x1d5d3,
- 0x1d5ee, 0x1d607,
- 0x1d622, 0x1d63b,
- 0x1d656, 0x1d66f,
- 0x1d68a, 0x1d6a5,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6e1,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d71b,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d755,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d78f,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9,
- 0x1d7cb, 0x1d7cb,
- 0x1e922, 0x1e943,
-}; /* CR_Lower */
-
-/* 'Print': [[:Print:]] */
-static const OnigCodePoint CR_Print[] = {
- 668,
- 0x0020, 0x007e,
- 0x00a0, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2027,
- 0x202a, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xe000, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd,
-}; /* CR_Print */
-
-/* 'XPosixPunct': [[:Punct:]] */
-static const OnigCodePoint CR_XPosixPunct[] = {
- 177,
- 0x0021, 0x002f,
- 0x003a, 0x0040,
- 0x005b, 0x0060,
- 0x007b, 0x007e,
- 0x00a1, 0x00a1,
- 0x00a7, 0x00a7,
- 0x00ab, 0x00ab,
- 0x00b6, 0x00b7,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x058a,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x0609, 0x060a,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x07f7, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x09fd, 0x09fd,
- 0x0a76, 0x0a76,
- 0x0af0, 0x0af0,
- 0x0c77, 0x0c77,
- 0x0c84, 0x0c84,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f14, 0x0f14,
- 0x0f3a, 0x0f3d,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd4,
- 0x0fd9, 0x0fda,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1360, 0x1368,
- 0x1400, 0x1400,
- 0x166e, 0x166e,
- 0x169b, 0x169c,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x180a,
- 0x1944, 0x1945,
- 0x1a1e, 0x1a1f,
- 0x1aa0, 0x1aa6,
- 0x1aa8, 0x1aad,
- 0x1b5a, 0x1b60,
- 0x1bfc, 0x1bff,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x2010, 0x2027,
- 0x2030, 0x2043,
- 0x2045, 0x2051,
- 0x2053, 0x205e,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x2308, 0x230b,
- 0x2329, 0x232a,
- 0x2768, 0x2775,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27ef,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2d70, 0x2d70,
- 0x2e00, 0x2e2e,
- 0x2e30, 0x2e4f,
- 0x3001, 0x3003,
- 0x3008, 0x3011,
- 0x3014, 0x301f,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fb,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa673, 0xa673,
- 0xa67e, 0xa67e,
- 0xa6f2, 0xa6f7,
- 0xa874, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa8f8, 0xa8fa,
- 0xa8fc, 0xa8fc,
- 0xa92e, 0xa92f,
- 0xa95f, 0xa95f,
- 0xa9c1, 0xa9cd,
- 0xa9de, 0xa9df,
- 0xaa5c, 0xaa5f,
- 0xaade, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 0xfd3e, 0xfd3f,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe61,
- 0xfe63, 0xfe63,
- 0xfe68, 0xfe68,
- 0xfe6a, 0xfe6b,
- 0xff01, 0xff03,
- 0xff05, 0xff0a,
- 0xff0c, 0xff0f,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff20,
- 0xff3b, 0xff3d,
- 0xff3f, 0xff3f,
- 0xff5b, 0xff5b,
- 0xff5d, 0xff5d,
- 0xff5f, 0xff65,
- 0x10100, 0x10102,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x1056f, 0x1056f,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x1093f, 0x1093f,
- 0x10a50, 0x10a58,
- 0x10a7f, 0x10a7f,
- 0x10af0, 0x10af6,
- 0x10b39, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10f55, 0x10f59,
- 0x11047, 0x1104d,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x11140, 0x11143,
- 0x11174, 0x11175,
- 0x111c5, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111db, 0x111db,
- 0x111dd, 0x111df,
- 0x11238, 0x1123d,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144f,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x114c6, 0x114c6,
- 0x115c1, 0x115d7,
- 0x11641, 0x11643,
- 0x11660, 0x1166c,
- 0x1173c, 0x1173e,
- 0x1183b, 0x1183b,
- 0x119e2, 0x119e2,
- 0x11a3f, 0x11a46,
- 0x11a9a, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11c41, 0x11c45,
- 0x11c70, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x11fff, 0x11fff,
- 0x12470, 0x12474,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b3b,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e9a,
- 0x16fe2, 0x16fe2,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8b,
- 0x1e95e, 0x1e95f,
-}; /* CR_XPosixPunct */
-
-/* 'Space': [[:Space:]] */
-static const OnigCodePoint CR_Space[] = {
- 10,
- 0x0009, 0x000d,
- 0x0020, 0x0020,
- 0x0085, 0x0085,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x2000, 0x200a,
- 0x2028, 0x2029,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000,
-}; /* CR_Space */
-
-/* 'Upper': [[:Upper:]] */
-static const OnigCodePoint CR_Upper[] = {
- 641,
- 0x0041, 0x005a,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00de,
- 0x0100, 0x0100,
- 0x0102, 0x0102,
- 0x0104, 0x0104,
- 0x0106, 0x0106,
- 0x0108, 0x0108,
- 0x010a, 0x010a,
- 0x010c, 0x010c,
- 0x010e, 0x010e,
- 0x0110, 0x0110,
- 0x0112, 0x0112,
- 0x0114, 0x0114,
- 0x0116, 0x0116,
- 0x0118, 0x0118,
- 0x011a, 0x011a,
- 0x011c, 0x011c,
- 0x011e, 0x011e,
- 0x0120, 0x0120,
- 0x0122, 0x0122,
- 0x0124, 0x0124,
- 0x0126, 0x0126,
- 0x0128, 0x0128,
- 0x012a, 0x012a,
- 0x012c, 0x012c,
- 0x012e, 0x012e,
- 0x0130, 0x0130,
- 0x0132, 0x0132,
- 0x0134, 0x0134,
- 0x0136, 0x0136,
- 0x0139, 0x0139,
- 0x013b, 0x013b,
- 0x013d, 0x013d,
- 0x013f, 0x013f,
- 0x0141, 0x0141,
- 0x0143, 0x0143,
- 0x0145, 0x0145,
- 0x0147, 0x0147,
- 0x014a, 0x014a,
- 0x014c, 0x014c,
- 0x014e, 0x014e,
- 0x0150, 0x0150,
- 0x0152, 0x0152,
- 0x0154, 0x0154,
- 0x0156, 0x0156,
- 0x0158, 0x0158,
- 0x015a, 0x015a,
- 0x015c, 0x015c,
- 0x015e, 0x015e,
- 0x0160, 0x0160,
- 0x0162, 0x0162,
- 0x0164, 0x0164,
- 0x0166, 0x0166,
- 0x0168, 0x0168,
- 0x016a, 0x016a,
- 0x016c, 0x016c,
- 0x016e, 0x016e,
- 0x0170, 0x0170,
- 0x0172, 0x0172,
- 0x0174, 0x0174,
- 0x0176, 0x0176,
- 0x0178, 0x0179,
- 0x017b, 0x017b,
- 0x017d, 0x017d,
- 0x0181, 0x0182,
- 0x0184, 0x0184,
- 0x0186, 0x0187,
- 0x0189, 0x018b,
- 0x018e, 0x0191,
- 0x0193, 0x0194,
- 0x0196, 0x0198,
- 0x019c, 0x019d,
- 0x019f, 0x01a0,
- 0x01a2, 0x01a2,
- 0x01a4, 0x01a4,
- 0x01a6, 0x01a7,
- 0x01a9, 0x01a9,
- 0x01ac, 0x01ac,
- 0x01ae, 0x01af,
- 0x01b1, 0x01b3,
- 0x01b5, 0x01b5,
- 0x01b7, 0x01b8,
- 0x01bc, 0x01bc,
- 0x01c4, 0x01c4,
- 0x01c7, 0x01c7,
- 0x01ca, 0x01ca,
- 0x01cd, 0x01cd,
- 0x01cf, 0x01cf,
- 0x01d1, 0x01d1,
- 0x01d3, 0x01d3,
- 0x01d5, 0x01d5,
- 0x01d7, 0x01d7,
- 0x01d9, 0x01d9,
- 0x01db, 0x01db,
- 0x01de, 0x01de,
- 0x01e0, 0x01e0,
- 0x01e2, 0x01e2,
- 0x01e4, 0x01e4,
- 0x01e6, 0x01e6,
- 0x01e8, 0x01e8,
- 0x01ea, 0x01ea,
- 0x01ec, 0x01ec,
- 0x01ee, 0x01ee,
- 0x01f1, 0x01f1,
- 0x01f4, 0x01f4,
- 0x01f6, 0x01f8,
- 0x01fa, 0x01fa,
- 0x01fc, 0x01fc,
- 0x01fe, 0x01fe,
- 0x0200, 0x0200,
- 0x0202, 0x0202,
- 0x0204, 0x0204,
- 0x0206, 0x0206,
- 0x0208, 0x0208,
- 0x020a, 0x020a,
- 0x020c, 0x020c,
- 0x020e, 0x020e,
- 0x0210, 0x0210,
- 0x0212, 0x0212,
- 0x0214, 0x0214,
- 0x0216, 0x0216,
- 0x0218, 0x0218,
- 0x021a, 0x021a,
- 0x021c, 0x021c,
- 0x021e, 0x021e,
- 0x0220, 0x0220,
- 0x0222, 0x0222,
- 0x0224, 0x0224,
- 0x0226, 0x0226,
- 0x0228, 0x0228,
- 0x022a, 0x022a,
- 0x022c, 0x022c,
- 0x022e, 0x022e,
- 0x0230, 0x0230,
- 0x0232, 0x0232,
- 0x023a, 0x023b,
- 0x023d, 0x023e,
- 0x0241, 0x0241,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03cf, 0x03cf,
- 0x03d2, 0x03d4,
- 0x03d8, 0x03d8,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03e2,
- 0x03e4, 0x03e4,
- 0x03e6, 0x03e6,
- 0x03e8, 0x03e8,
- 0x03ea, 0x03ea,
- 0x03ec, 0x03ec,
- 0x03ee, 0x03ee,
- 0x03f4, 0x03f4,
- 0x03f7, 0x03f7,
- 0x03f9, 0x03fa,
- 0x03fd, 0x042f,
- 0x0460, 0x0460,
- 0x0462, 0x0462,
- 0x0464, 0x0464,
- 0x0466, 0x0466,
- 0x0468, 0x0468,
- 0x046a, 0x046a,
- 0x046c, 0x046c,
- 0x046e, 0x046e,
- 0x0470, 0x0470,
- 0x0472, 0x0472,
- 0x0474, 0x0474,
- 0x0476, 0x0476,
- 0x0478, 0x0478,
- 0x047a, 0x047a,
- 0x047c, 0x047c,
- 0x047e, 0x047e,
- 0x0480, 0x0480,
- 0x048a, 0x048a,
- 0x048c, 0x048c,
- 0x048e, 0x048e,
- 0x0490, 0x0490,
- 0x0492, 0x0492,
- 0x0494, 0x0494,
- 0x0496, 0x0496,
- 0x0498, 0x0498,
- 0x049a, 0x049a,
- 0x049c, 0x049c,
- 0x049e, 0x049e,
- 0x04a0, 0x04a0,
- 0x04a2, 0x04a2,
- 0x04a4, 0x04a4,
- 0x04a6, 0x04a6,
- 0x04a8, 0x04a8,
- 0x04aa, 0x04aa,
- 0x04ac, 0x04ac,
- 0x04ae, 0x04ae,
- 0x04b0, 0x04b0,
- 0x04b2, 0x04b2,
- 0x04b4, 0x04b4,
- 0x04b6, 0x04b6,
- 0x04b8, 0x04b8,
- 0x04ba, 0x04ba,
- 0x04bc, 0x04bc,
- 0x04be, 0x04be,
- 0x04c0, 0x04c1,
- 0x04c3, 0x04c3,
- 0x04c5, 0x04c5,
- 0x04c7, 0x04c7,
- 0x04c9, 0x04c9,
- 0x04cb, 0x04cb,
- 0x04cd, 0x04cd,
- 0x04d0, 0x04d0,
- 0x04d2, 0x04d2,
- 0x04d4, 0x04d4,
- 0x04d6, 0x04d6,
- 0x04d8, 0x04d8,
- 0x04da, 0x04da,
- 0x04dc, 0x04dc,
- 0x04de, 0x04de,
- 0x04e0, 0x04e0,
- 0x04e2, 0x04e2,
- 0x04e4, 0x04e4,
- 0x04e6, 0x04e6,
- 0x04e8, 0x04e8,
- 0x04ea, 0x04ea,
- 0x04ec, 0x04ec,
- 0x04ee, 0x04ee,
- 0x04f0, 0x04f0,
- 0x04f2, 0x04f2,
- 0x04f4, 0x04f4,
- 0x04f6, 0x04f6,
- 0x04f8, 0x04f8,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13a0, 0x13f5,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1e00, 0x1e00,
- 0x1e02, 0x1e02,
- 0x1e04, 0x1e04,
- 0x1e06, 0x1e06,
- 0x1e08, 0x1e08,
- 0x1e0a, 0x1e0a,
- 0x1e0c, 0x1e0c,
- 0x1e0e, 0x1e0e,
- 0x1e10, 0x1e10,
- 0x1e12, 0x1e12,
- 0x1e14, 0x1e14,
- 0x1e16, 0x1e16,
- 0x1e18, 0x1e18,
- 0x1e1a, 0x1e1a,
- 0x1e1c, 0x1e1c,
- 0x1e1e, 0x1e1e,
- 0x1e20, 0x1e20,
- 0x1e22, 0x1e22,
- 0x1e24, 0x1e24,
- 0x1e26, 0x1e26,
- 0x1e28, 0x1e28,
- 0x1e2a, 0x1e2a,
- 0x1e2c, 0x1e2c,
- 0x1e2e, 0x1e2e,
- 0x1e30, 0x1e30,
- 0x1e32, 0x1e32,
- 0x1e34, 0x1e34,
- 0x1e36, 0x1e36,
- 0x1e38, 0x1e38,
- 0x1e3a, 0x1e3a,
- 0x1e3c, 0x1e3c,
- 0x1e3e, 0x1e3e,
- 0x1e40, 0x1e40,
- 0x1e42, 0x1e42,
- 0x1e44, 0x1e44,
- 0x1e46, 0x1e46,
- 0x1e48, 0x1e48,
- 0x1e4a, 0x1e4a,
- 0x1e4c, 0x1e4c,
- 0x1e4e, 0x1e4e,
- 0x1e50, 0x1e50,
- 0x1e52, 0x1e52,
- 0x1e54, 0x1e54,
- 0x1e56, 0x1e56,
- 0x1e58, 0x1e58,
- 0x1e5a, 0x1e5a,
- 0x1e5c, 0x1e5c,
- 0x1e5e, 0x1e5e,
- 0x1e60, 0x1e60,
- 0x1e62, 0x1e62,
- 0x1e64, 0x1e64,
- 0x1e66, 0x1e66,
- 0x1e68, 0x1e68,
- 0x1e6a, 0x1e6a,
- 0x1e6c, 0x1e6c,
- 0x1e6e, 0x1e6e,
- 0x1e70, 0x1e70,
- 0x1e72, 0x1e72,
- 0x1e74, 0x1e74,
- 0x1e76, 0x1e76,
- 0x1e78, 0x1e78,
- 0x1e7a, 0x1e7a,
- 0x1e7c, 0x1e7c,
- 0x1e7e, 0x1e7e,
- 0x1e80, 0x1e80,
- 0x1e82, 0x1e82,
- 0x1e84, 0x1e84,
- 0x1e86, 0x1e86,
- 0x1e88, 0x1e88,
- 0x1e8a, 0x1e8a,
- 0x1e8c, 0x1e8c,
- 0x1e8e, 0x1e8e,
- 0x1e90, 0x1e90,
- 0x1e92, 0x1e92,
- 0x1e94, 0x1e94,
- 0x1e9e, 0x1e9e,
- 0x1ea0, 0x1ea0,
- 0x1ea2, 0x1ea2,
- 0x1ea4, 0x1ea4,
- 0x1ea6, 0x1ea6,
- 0x1ea8, 0x1ea8,
- 0x1eaa, 0x1eaa,
- 0x1eac, 0x1eac,
- 0x1eae, 0x1eae,
- 0x1eb0, 0x1eb0,
- 0x1eb2, 0x1eb2,
- 0x1eb4, 0x1eb4,
- 0x1eb6, 0x1eb6,
- 0x1eb8, 0x1eb8,
- 0x1eba, 0x1eba,
- 0x1ebc, 0x1ebc,
- 0x1ebe, 0x1ebe,
- 0x1ec0, 0x1ec0,
- 0x1ec2, 0x1ec2,
- 0x1ec4, 0x1ec4,
- 0x1ec6, 0x1ec6,
- 0x1ec8, 0x1ec8,
- 0x1eca, 0x1eca,
- 0x1ecc, 0x1ecc,
- 0x1ece, 0x1ece,
- 0x1ed0, 0x1ed0,
- 0x1ed2, 0x1ed2,
- 0x1ed4, 0x1ed4,
- 0x1ed6, 0x1ed6,
- 0x1ed8, 0x1ed8,
- 0x1eda, 0x1eda,
- 0x1edc, 0x1edc,
- 0x1ede, 0x1ede,
- 0x1ee0, 0x1ee0,
- 0x1ee2, 0x1ee2,
- 0x1ee4, 0x1ee4,
- 0x1ee6, 0x1ee6,
- 0x1ee8, 0x1ee8,
- 0x1eea, 0x1eea,
- 0x1eec, 0x1eec,
- 0x1eee, 0x1eee,
- 0x1ef0, 0x1ef0,
- 0x1ef2, 0x1ef2,
- 0x1ef4, 0x1ef4,
- 0x1ef6, 0x1ef6,
- 0x1ef8, 0x1ef8,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1fb8, 0x1fbb,
- 0x1fc8, 0x1fcb,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff8, 0x1ffb,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210b, 0x210d,
- 0x2110, 0x2112,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x2130, 0x2133,
- 0x213e, 0x213f,
- 0x2145, 0x2145,
- 0x2160, 0x216f,
- 0x2183, 0x2183,
- 0x24b6, 0x24cf,
- 0x2c00, 0x2c2e,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 0x2c80,
- 0x2c82, 0x2c82,
- 0x2c84, 0x2c84,
- 0x2c86, 0x2c86,
- 0x2c88, 0x2c88,
- 0x2c8a, 0x2c8a,
- 0x2c8c, 0x2c8c,
- 0x2c8e, 0x2c8e,
- 0x2c90, 0x2c90,
- 0x2c92, 0x2c92,
- 0x2c94, 0x2c94,
- 0x2c96, 0x2c96,
- 0x2c98, 0x2c98,
- 0x2c9a, 0x2c9a,
- 0x2c9c, 0x2c9c,
- 0x2c9e, 0x2c9e,
- 0x2ca0, 0x2ca0,
- 0x2ca2, 0x2ca2,
- 0x2ca4, 0x2ca4,
- 0x2ca6, 0x2ca6,
- 0x2ca8, 0x2ca8,
- 0x2caa, 0x2caa,
- 0x2cac, 0x2cac,
- 0x2cae, 0x2cae,
- 0x2cb0, 0x2cb0,
- 0x2cb2, 0x2cb2,
- 0x2cb4, 0x2cb4,
- 0x2cb6, 0x2cb6,
- 0x2cb8, 0x2cb8,
- 0x2cba, 0x2cba,
- 0x2cbc, 0x2cbc,
- 0x2cbe, 0x2cbe,
- 0x2cc0, 0x2cc0,
- 0x2cc2, 0x2cc2,
- 0x2cc4, 0x2cc4,
- 0x2cc6, 0x2cc6,
- 0x2cc8, 0x2cc8,
- 0x2cca, 0x2cca,
- 0x2ccc, 0x2ccc,
- 0x2cce, 0x2cce,
- 0x2cd0, 0x2cd0,
- 0x2cd2, 0x2cd2,
- 0x2cd4, 0x2cd4,
- 0x2cd6, 0x2cd6,
- 0x2cd8, 0x2cd8,
- 0x2cda, 0x2cda,
- 0x2cdc, 0x2cdc,
- 0x2cde, 0x2cde,
- 0x2ce0, 0x2ce0,
- 0x2ce2, 0x2ce2,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c6,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 0x1d400, 0x1d419,
- 0x1d434, 0x1d44d,
- 0x1d468, 0x1d481,
- 0x1d49c, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b5,
- 0x1d4d0, 0x1d4e9,
- 0x1d504, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d538, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d56c, 0x1d585,
- 0x1d5a0, 0x1d5b9,
- 0x1d5d4, 0x1d5ed,
- 0x1d608, 0x1d621,
- 0x1d63c, 0x1d655,
- 0x1d670, 0x1d689,
- 0x1d6a8, 0x1d6c0,
- 0x1d6e2, 0x1d6fa,
- 0x1d71c, 0x1d734,
- 0x1d756, 0x1d76e,
- 0x1d790, 0x1d7a8,
- 0x1d7ca, 0x1d7ca,
- 0x1e900, 0x1e921,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* CR_Upper */
-
-/* 'XDigit': [[:XDigit:]] */
-static const OnigCodePoint CR_XDigit[] = {
- 3,
- 0x0030, 0x0039,
- 0x0041, 0x0046,
- 0x0061, 0x0066,
-}; /* CR_XDigit */
-
-/* 'Word': [[:Word:]] */
-static const OnigCodePoint CR_Word[] = {
- 716,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x005f, 0x005f,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0300, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06df, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0800, 0x082d,
- 0x0840, 0x085b,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x08e1,
- 0x08e3, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09f1,
- 0x09fc, 0x09fc,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b6f,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f29,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x135f,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x180b, 0x180d,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b59,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1bf3,
- 0x1c00, 0x1c37,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x203f, 0x2040,
- 0x2054, 0x2054,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20f0,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3007,
- 0x3021, 0x302f,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309a,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa672,
- 0xa674, 0xa67d,
- 0xa67f, 0xa6f1,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa827,
- 0xa840, 0xa873,
- 0xa880, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8e0, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92d,
- 0xa930, 0xa953,
- 0xa960, 0xa97c,
- 0xa980, 0xa9c0,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabea,
- 0xabec, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xfe33, 0xfe34,
- 0xfe4d, 0xfe4f,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff10, 0xff19,
- 0xff21, 0xff3a,
- 0xff3f, 0xff3f,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10140, 0x10174,
- 0x101fd, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102e0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae6,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f50,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11046,
- 0x11066, 0x1106f,
- 0x1107f, 0x110ba,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x1113f,
- 0x11144, 0x11146,
- 0x11150, 0x11173,
- 0x11176, 0x11176,
- 0x11180, 0x111c4,
- 0x111c9, 0x111cc,
- 0x111d0, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11237,
- 0x1123e, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1144a,
- 0x11450, 0x11459,
- 0x1145e, 0x1145f,
- 0x11480, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115d8, 0x115dd,
- 0x11600, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11739,
- 0x11800, 0x1183a,
- 0x118a0, 0x118e9,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a50, 0x11a99,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af4,
- 0x16b00, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9d, 0x1bc9e,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2f9,
- 0x1e800, 0x1e8c4,
- 0x1e8d0, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0xe0100, 0xe01ef,
-}; /* CR_Word */
-
-/* 'Alnum': [[:Alnum:]] */
-static const OnigCodePoint CR_Alnum[] = {
- 715,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0345, 0x0345,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05b0, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0657,
- 0x0659, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06e1, 0x06e8,
- 0x06ed, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x073f,
- 0x074d, 0x07b1,
- 0x07c0, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0817,
- 0x081a, 0x082c,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d4, 0x08df,
- 0x08e3, 0x08e9,
- 0x08f0, 0x093b,
- 0x093d, 0x094c,
- 0x094e, 0x0950,
- 0x0955, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09ce, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4c,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af9, 0x0afc,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b6f,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4c,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccc,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e46,
- 0x0e4d, 0x0e4d,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ecd, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f20, 0x0f29,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f81,
- 0x0f88, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x1000, 0x1036,
- 0x1038, 0x1038,
- 0x103b, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1713,
- 0x1720, 0x1733,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17b3,
- 0x17b6, 0x17c8,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x1938,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a61, 0x1a74,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1b00, 0x1b33,
- 0x1b35, 0x1b43,
- 0x1b45, 0x1b4b,
- 0x1b50, 0x1b59,
- 0x1b80, 0x1ba9,
- 0x1bac, 0x1be5,
- 0x1be7, 0x1bf1,
- 0x1c00, 0x1c36,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1de7, 0x1df4,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa66e,
- 0xa674, 0xa67b,
- 0xa67f, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa805,
- 0xa807, 0xa827,
- 0xa840, 0xa873,
- 0xa880, 0xa8c3,
- 0xa8c5, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92a,
- 0xa930, 0xa952,
- 0xa960, 0xa97c,
- 0xa980, 0xa9b2,
- 0xa9b4, 0xa9bf,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaabe,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf5,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabea,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff10, 0xff19,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11045,
- 0x11066, 0x1106f,
- 0x11082, 0x110b8,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11132,
- 0x11136, 0x1113f,
- 0x11144, 0x11146,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11180, 0x111bf,
- 0x111c1, 0x111c4,
- 0x111d0, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11234,
- 0x11237, 0x11237,
- 0x1123e, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112e8,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134c,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11400, 0x11441,
- 0x11443, 0x11445,
- 0x11447, 0x1144a,
- 0x11450, 0x11459,
- 0x1145f, 0x1145f,
- 0x11480, 0x114c1,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115be,
- 0x115d8, 0x115dd,
- 0x11600, 0x1163e,
- 0x11640, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b5,
- 0x116b8, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172a,
- 0x11730, 0x11739,
- 0x11800, 0x11838,
- 0x118a0, 0x118e9,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119df,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a32,
- 0x11a35, 0x11a3e,
- 0x11a50, 0x11a97,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c3e,
- 0x11c40, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d41,
- 0x11d43, 0x11d43,
- 0x11d46, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d96,
- 0x11d98, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9e, 0x1bc9e,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2eb,
- 0x1e2f0, 0x1e2f9,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e947, 0x1e947,
- 0x1e94b, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_Alnum */
-
-/* 'ASCII': [[:ASCII:]] */
-static const OnigCodePoint CR_ASCII[] = {
- 1,
- 0x0000, 0x007f,
-}; /* CR_ASCII */
-
-/* 'Punct' */
-static const OnigCodePoint CR_Punct[] = {
- 182,
- 0x0021, 0x0023,
- 0x0025, 0x002a,
- 0x002c, 0x002f,
- 0x003a, 0x003b,
- 0x003f, 0x0040,
- 0x005b, 0x005d,
- 0x005f, 0x005f,
- 0x007b, 0x007b,
- 0x007d, 0x007d,
- 0x00a1, 0x00a1,
- 0x00a7, 0x00a7,
- 0x00ab, 0x00ab,
- 0x00b6, 0x00b7,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x058a,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x0609, 0x060a,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x07f7, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x09fd, 0x09fd,
- 0x0a76, 0x0a76,
- 0x0af0, 0x0af0,
- 0x0c77, 0x0c77,
- 0x0c84, 0x0c84,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f14, 0x0f14,
- 0x0f3a, 0x0f3d,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd4,
- 0x0fd9, 0x0fda,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1360, 0x1368,
- 0x1400, 0x1400,
- 0x166e, 0x166e,
- 0x169b, 0x169c,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x180a,
- 0x1944, 0x1945,
- 0x1a1e, 0x1a1f,
- 0x1aa0, 0x1aa6,
- 0x1aa8, 0x1aad,
- 0x1b5a, 0x1b60,
- 0x1bfc, 0x1bff,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x2010, 0x2027,
- 0x2030, 0x2043,
- 0x2045, 0x2051,
- 0x2053, 0x205e,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x2308, 0x230b,
- 0x2329, 0x232a,
- 0x2768, 0x2775,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27ef,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2d70, 0x2d70,
- 0x2e00, 0x2e2e,
- 0x2e30, 0x2e4f,
- 0x3001, 0x3003,
- 0x3008, 0x3011,
- 0x3014, 0x301f,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fb,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa673, 0xa673,
- 0xa67e, 0xa67e,
- 0xa6f2, 0xa6f7,
- 0xa874, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa8f8, 0xa8fa,
- 0xa8fc, 0xa8fc,
- 0xa92e, 0xa92f,
- 0xa95f, 0xa95f,
- 0xa9c1, 0xa9cd,
- 0xa9de, 0xa9df,
- 0xaa5c, 0xaa5f,
- 0xaade, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 0xfd3e, 0xfd3f,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe61,
- 0xfe63, 0xfe63,
- 0xfe68, 0xfe68,
- 0xfe6a, 0xfe6b,
- 0xff01, 0xff03,
- 0xff05, 0xff0a,
- 0xff0c, 0xff0f,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff20,
- 0xff3b, 0xff3d,
- 0xff3f, 0xff3f,
- 0xff5b, 0xff5b,
- 0xff5d, 0xff5d,
- 0xff5f, 0xff65,
- 0x10100, 0x10102,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x1056f, 0x1056f,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x1093f, 0x1093f,
- 0x10a50, 0x10a58,
- 0x10a7f, 0x10a7f,
- 0x10af0, 0x10af6,
- 0x10b39, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10f55, 0x10f59,
- 0x11047, 0x1104d,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x11140, 0x11143,
- 0x11174, 0x11175,
- 0x111c5, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111db, 0x111db,
- 0x111dd, 0x111df,
- 0x11238, 0x1123d,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144f,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x114c6, 0x114c6,
- 0x115c1, 0x115d7,
- 0x11641, 0x11643,
- 0x11660, 0x1166c,
- 0x1173c, 0x1173e,
- 0x1183b, 0x1183b,
- 0x119e2, 0x119e2,
- 0x11a3f, 0x11a46,
- 0x11a9a, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11c41, 0x11c45,
- 0x11c70, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x11fff, 0x11fff,
- 0x12470, 0x12474,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b3b,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e9a,
- 0x16fe2, 0x16fe2,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8b,
- 0x1e95e, 0x1e95f,
-}; /* CR_Punct */
-
-#ifdef USE_UNICODE_PROPERTIES
-/* 'Any': - */
-static const OnigCodePoint CR_Any[] = {
- 1,
- 0x0000, 0x10ffff,
-}; /* CR_Any */
-
-/* 'Assigned': - */
-static const OnigCodePoint CR_Assigned[] = {
- 666,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd,
-}; /* CR_Assigned */
-
-/* 'C': Major Category */
-static const OnigCodePoint CR_C[] = {
- 668,
- 0x0000, 0x001f,
- 0x007f, 0x009f,
- 0x00ad, 0x00ad,
- 0x0378, 0x0379,
- 0x0380, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x0530, 0x0530,
- 0x0557, 0x0558,
- 0x058b, 0x058c,
- 0x0590, 0x0590,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ee,
- 0x05f5, 0x0605,
- 0x061c, 0x061d,
- 0x06dd, 0x06dd,
- 0x070e, 0x070f,
- 0x074b, 0x074c,
- 0x07b2, 0x07bf,
- 0x07fb, 0x07fc,
- 0x082e, 0x082f,
- 0x083f, 0x083f,
- 0x085c, 0x085d,
- 0x085f, 0x085f,
- 0x086b, 0x089f,
- 0x08b5, 0x08b5,
- 0x08be, 0x08d2,
- 0x08e2, 0x08e2,
- 0x0984, 0x0984,
- 0x098d, 0x098e,
- 0x0991, 0x0992,
- 0x09a9, 0x09a9,
- 0x09b1, 0x09b1,
- 0x09b3, 0x09b5,
- 0x09ba, 0x09bb,
- 0x09c5, 0x09c6,
- 0x09c9, 0x09ca,
- 0x09cf, 0x09d6,
- 0x09d8, 0x09db,
- 0x09de, 0x09de,
- 0x09e4, 0x09e5,
- 0x09ff, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a50,
- 0x0a52, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a77, 0x0a80,
- 0x0a84, 0x0a84,
- 0x0a8e, 0x0a8e,
- 0x0a92, 0x0a92,
- 0x0aa9, 0x0aa9,
- 0x0ab1, 0x0ab1,
- 0x0ab4, 0x0ab4,
- 0x0aba, 0x0abb,
- 0x0ac6, 0x0ac6,
- 0x0aca, 0x0aca,
- 0x0ace, 0x0acf,
- 0x0ad1, 0x0adf,
- 0x0ae4, 0x0ae5,
- 0x0af2, 0x0af8,
- 0x0b00, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b45, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b55,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b64, 0x0b65,
- 0x0b78, 0x0b81,
- 0x0b84, 0x0b84,
- 0x0b8b, 0x0b8d,
- 0x0b91, 0x0b91,
- 0x0b96, 0x0b98,
- 0x0b9b, 0x0b9b,
- 0x0b9d, 0x0b9d,
- 0x0ba0, 0x0ba2,
- 0x0ba5, 0x0ba7,
- 0x0bab, 0x0bad,
- 0x0bba, 0x0bbd,
- 0x0bc3, 0x0bc5,
- 0x0bc9, 0x0bc9,
- 0x0bce, 0x0bcf,
- 0x0bd1, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0bff,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c3a, 0x0c3c,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c57,
- 0x0c5b, 0x0c5f,
- 0x0c64, 0x0c65,
- 0x0c70, 0x0c76,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdd,
- 0x0cdf, 0x0cdf,
- 0x0ce4, 0x0ce5,
- 0x0cf0, 0x0cf0,
- 0x0cf3, 0x0cff,
- 0x0d04, 0x0d04,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d45, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d50, 0x0d53,
- 0x0d64, 0x0d65,
- 0x0d80, 0x0d81,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0de5,
- 0x0df0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e85,
- 0x0e8b, 0x0e8b,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ece, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ee0, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6d, 0x0f70,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fcd,
- 0x0fdb, 0x0fff,
- 0x10c6, 0x10c6,
- 0x10c8, 0x10cc,
- 0x10ce, 0x10cf,
- 0x1249, 0x1249,
- 0x124e, 0x124f,
- 0x1257, 0x1257,
- 0x1259, 0x1259,
- 0x125e, 0x125f,
- 0x1289, 0x1289,
- 0x128e, 0x128f,
- 0x12b1, 0x12b1,
- 0x12b6, 0x12b7,
- 0x12bf, 0x12bf,
- 0x12c1, 0x12c1,
- 0x12c6, 0x12c7,
- 0x12d7, 0x12d7,
- 0x1311, 0x1311,
- 0x1316, 0x1317,
- 0x135b, 0x135c,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f6, 0x13f7,
- 0x13fe, 0x13ff,
- 0x169d, 0x169f,
- 0x16f9, 0x16ff,
- 0x170d, 0x170d,
- 0x1715, 0x171f,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x180e, 0x180f,
- 0x181a, 0x181f,
- 0x1879, 0x187f,
- 0x18ab, 0x18af,
- 0x18f6, 0x18ff,
- 0x191f, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19ac, 0x19af,
- 0x19ca, 0x19cf,
- 0x19db, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a5f, 0x1a5f,
- 0x1a7d, 0x1a7e,
- 0x1a8a, 0x1a8f,
- 0x1a9a, 0x1a9f,
- 0x1aae, 0x1aaf,
- 0x1abf, 0x1aff,
- 0x1b4c, 0x1b4f,
- 0x1b7d, 0x1b7f,
- 0x1bf4, 0x1bfb,
- 0x1c38, 0x1c3a,
- 0x1c4a, 0x1c4c,
- 0x1c89, 0x1c8f,
- 0x1cbb, 0x1cbc,
- 0x1cc8, 0x1ccf,
- 0x1cfb, 0x1cff,
- 0x1dfa, 0x1dfa,
- 0x1f16, 0x1f17,
- 0x1f1e, 0x1f1f,
- 0x1f46, 0x1f47,
- 0x1f4e, 0x1f4f,
- 0x1f58, 0x1f58,
- 0x1f5a, 0x1f5a,
- 0x1f5c, 0x1f5c,
- 0x1f5e, 0x1f5e,
- 0x1f7e, 0x1f7f,
- 0x1fb5, 0x1fb5,
- 0x1fc5, 0x1fc5,
- 0x1fd4, 0x1fd5,
- 0x1fdc, 0x1fdc,
- 0x1ff0, 0x1ff1,
- 0x1ff5, 0x1ff5,
- 0x1fff, 0x1fff,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x206f,
- 0x2072, 0x2073,
- 0x208f, 0x208f,
- 0x209d, 0x209f,
- 0x20c0, 0x20cf,
- 0x20f1, 0x20ff,
- 0x218c, 0x218f,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x2b74, 0x2b75,
- 0x2b96, 0x2b97,
- 0x2c2f, 0x2c2f,
- 0x2c5f, 0x2c5f,
- 0x2cf4, 0x2cf8,
- 0x2d26, 0x2d26,
- 0x2d28, 0x2d2c,
- 0x2d2e, 0x2d2f,
- 0x2d68, 0x2d6e,
- 0x2d71, 0x2d7e,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2ddf,
- 0x2e50, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x3130, 0x3130,
- 0x318f, 0x318f,
- 0x31bb, 0x31bf,
- 0x31e4, 0x31ef,
- 0x321f, 0x321f,
- 0x4db6, 0x4dbf,
- 0x9ff0, 0x9fff,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa4cf,
- 0xa62c, 0xa63f,
- 0xa6f8, 0xa6ff,
- 0xa7c0, 0xa7c1,
- 0xa7c7, 0xa7f6,
- 0xa82c, 0xa82f,
- 0xa83a, 0xa83f,
- 0xa878, 0xa87f,
- 0xa8c6, 0xa8cd,
- 0xa8da, 0xa8df,
- 0xa954, 0xa95e,
- 0xa97d, 0xa97f,
- 0xa9ce, 0xa9ce,
- 0xa9da, 0xa9dd,
- 0xa9ff, 0xa9ff,
- 0xaa37, 0xaa3f,
- 0xaa4e, 0xaa4f,
- 0xaa5a, 0xaa5b,
- 0xaac3, 0xaada,
- 0xaaf7, 0xab00,
- 0xab07, 0xab08,
- 0xab0f, 0xab10,
- 0xab17, 0xab1f,
- 0xab27, 0xab27,
- 0xab2f, 0xab2f,
- 0xab68, 0xab6f,
- 0xabee, 0xabef,
- 0xabfa, 0xabff,
- 0xd7a4, 0xd7af,
- 0xd7c7, 0xd7ca,
- 0xd7fc, 0xf8ff,
- 0xfa6e, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbc2, 0xfbd2,
- 0xfd40, 0xfd4f,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdef,
- 0xfdfe, 0xfdff,
- 0xfe1a, 0xfe1f,
- 0xfe53, 0xfe53,
- 0xfe67, 0xfe67,
- 0xfe6c, 0xfe6f,
- 0xfe75, 0xfe75,
- 0xfefd, 0xff00,
- 0xffbf, 0xffc1,
- 0xffc8, 0xffc9,
- 0xffd0, 0xffd1,
- 0xffd8, 0xffd9,
- 0xffdd, 0xffdf,
- 0xffe7, 0xffe7,
- 0xffef, 0xfffb,
- 0xfffe, 0xffff,
- 0x1000c, 0x1000c,
- 0x10027, 0x10027,
- 0x1003b, 0x1003b,
- 0x1003e, 0x1003e,
- 0x1004e, 0x1004f,
- 0x1005e, 0x1007f,
- 0x100fb, 0x100ff,
- 0x10103, 0x10106,
- 0x10134, 0x10136,
- 0x1018f, 0x1018f,
- 0x1019c, 0x1019f,
- 0x101a1, 0x101cf,
- 0x101fe, 0x1027f,
- 0x1029d, 0x1029f,
- 0x102d1, 0x102df,
- 0x102fc, 0x102ff,
- 0x10324, 0x1032c,
- 0x1034b, 0x1034f,
- 0x1037b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x104af,
- 0x104d4, 0x104d7,
- 0x104fc, 0x104ff,
- 0x10528, 0x1052f,
- 0x10564, 0x1056e,
- 0x10570, 0x105ff,
- 0x10737, 0x1073f,
- 0x10756, 0x1075f,
- 0x10768, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10856, 0x10856,
- 0x1089f, 0x108a6,
- 0x108b0, 0x108df,
- 0x108f3, 0x108f3,
- 0x108f6, 0x108fa,
- 0x1091c, 0x1091e,
- 0x1093a, 0x1093e,
- 0x10940, 0x1097f,
- 0x109b8, 0x109bb,
- 0x109d0, 0x109d1,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a36, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a49, 0x10a4f,
- 0x10a59, 0x10a5f,
- 0x10aa0, 0x10abf,
- 0x10ae7, 0x10aea,
- 0x10af7, 0x10aff,
- 0x10b36, 0x10b38,
- 0x10b56, 0x10b57,
- 0x10b73, 0x10b77,
- 0x10b92, 0x10b98,
- 0x10b9d, 0x10ba8,
- 0x10bb0, 0x10bff,
- 0x10c49, 0x10c7f,
- 0x10cb3, 0x10cbf,
- 0x10cf3, 0x10cf9,
- 0x10d28, 0x10d2f,
- 0x10d3a, 0x10e5f,
- 0x10e7f, 0x10eff,
- 0x10f28, 0x10f2f,
- 0x10f5a, 0x10fdf,
- 0x10ff7, 0x10fff,
- 0x1104e, 0x11051,
- 0x11070, 0x1107e,
- 0x110bd, 0x110bd,
- 0x110c2, 0x110cf,
- 0x110e9, 0x110ef,
- 0x110fa, 0x110ff,
- 0x11135, 0x11135,
- 0x11147, 0x1114f,
- 0x11177, 0x1117f,
- 0x111ce, 0x111cf,
- 0x111e0, 0x111e0,
- 0x111f5, 0x111ff,
- 0x11212, 0x11212,
- 0x1123f, 0x1127f,
- 0x11287, 0x11287,
- 0x11289, 0x11289,
- 0x1128e, 0x1128e,
- 0x1129e, 0x1129e,
- 0x112aa, 0x112af,
- 0x112eb, 0x112ef,
- 0x112fa, 0x112ff,
- 0x11304, 0x11304,
- 0x1130d, 0x1130e,
- 0x11311, 0x11312,
- 0x11329, 0x11329,
- 0x11331, 0x11331,
- 0x11334, 0x11334,
- 0x1133a, 0x1133a,
- 0x11345, 0x11346,
- 0x11349, 0x1134a,
- 0x1134e, 0x1134f,
- 0x11351, 0x11356,
- 0x11358, 0x1135c,
- 0x11364, 0x11365,
- 0x1136d, 0x1136f,
- 0x11375, 0x113ff,
- 0x1145a, 0x1145a,
- 0x1145c, 0x1145c,
- 0x11460, 0x1147f,
- 0x114c8, 0x114cf,
- 0x114da, 0x1157f,
- 0x115b6, 0x115b7,
- 0x115de, 0x115ff,
- 0x11645, 0x1164f,
- 0x1165a, 0x1165f,
- 0x1166d, 0x1167f,
- 0x116b9, 0x116bf,
- 0x116ca, 0x116ff,
- 0x1171b, 0x1171c,
- 0x1172c, 0x1172f,
- 0x11740, 0x117ff,
- 0x1183c, 0x1189f,
- 0x118f3, 0x118fe,
- 0x11900, 0x1199f,
- 0x119a8, 0x119a9,
- 0x119d8, 0x119d9,
- 0x119e5, 0x119ff,
- 0x11a48, 0x11a4f,
- 0x11aa3, 0x11abf,
- 0x11af9, 0x11bff,
- 0x11c09, 0x11c09,
- 0x11c37, 0x11c37,
- 0x11c46, 0x11c4f,
- 0x11c6d, 0x11c6f,
- 0x11c90, 0x11c91,
- 0x11ca8, 0x11ca8,
- 0x11cb7, 0x11cff,
- 0x11d07, 0x11d07,
- 0x11d0a, 0x11d0a,
- 0x11d37, 0x11d39,
- 0x11d3b, 0x11d3b,
- 0x11d3e, 0x11d3e,
- 0x11d48, 0x11d4f,
- 0x11d5a, 0x11d5f,
- 0x11d66, 0x11d66,
- 0x11d69, 0x11d69,
- 0x11d8f, 0x11d8f,
- 0x11d92, 0x11d92,
- 0x11d99, 0x11d9f,
- 0x11daa, 0x11edf,
- 0x11ef9, 0x11fbf,
- 0x11ff2, 0x11ffe,
- 0x1239a, 0x123ff,
- 0x1246f, 0x1246f,
- 0x12475, 0x1247f,
- 0x12544, 0x12fff,
- 0x1342f, 0x143ff,
- 0x14647, 0x167ff,
- 0x16a39, 0x16a3f,
- 0x16a5f, 0x16a5f,
- 0x16a6a, 0x16a6d,
- 0x16a70, 0x16acf,
- 0x16aee, 0x16aef,
- 0x16af6, 0x16aff,
- 0x16b46, 0x16b4f,
- 0x16b5a, 0x16b5a,
- 0x16b62, 0x16b62,
- 0x16b78, 0x16b7c,
- 0x16b90, 0x16e3f,
- 0x16e9b, 0x16eff,
- 0x16f4b, 0x16f4e,
- 0x16f88, 0x16f8e,
- 0x16fa0, 0x16fdf,
- 0x16fe4, 0x16fff,
- 0x187f8, 0x187ff,
- 0x18af3, 0x1afff,
- 0x1b11f, 0x1b14f,
- 0x1b153, 0x1b163,
- 0x1b168, 0x1b16f,
- 0x1b2fc, 0x1bbff,
- 0x1bc6b, 0x1bc6f,
- 0x1bc7d, 0x1bc7f,
- 0x1bc89, 0x1bc8f,
- 0x1bc9a, 0x1bc9b,
- 0x1bca0, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d128,
- 0x1d173, 0x1d17a,
- 0x1d1e9, 0x1d1ff,
- 0x1d246, 0x1d2df,
- 0x1d2f4, 0x1d2ff,
- 0x1d357, 0x1d35f,
- 0x1d379, 0x1d3ff,
- 0x1d455, 0x1d455,
- 0x1d49d, 0x1d49d,
- 0x1d4a0, 0x1d4a1,
- 0x1d4a3, 0x1d4a4,
- 0x1d4a7, 0x1d4a8,
- 0x1d4ad, 0x1d4ad,
- 0x1d4ba, 0x1d4ba,
- 0x1d4bc, 0x1d4bc,
- 0x1d4c4, 0x1d4c4,
- 0x1d506, 0x1d506,
- 0x1d50b, 0x1d50c,
- 0x1d515, 0x1d515,
- 0x1d51d, 0x1d51d,
- 0x1d53a, 0x1d53a,
- 0x1d53f, 0x1d53f,
- 0x1d545, 0x1d545,
- 0x1d547, 0x1d549,
- 0x1d551, 0x1d551,
- 0x1d6a6, 0x1d6a7,
- 0x1d7cc, 0x1d7cd,
- 0x1da8c, 0x1da9a,
- 0x1daa0, 0x1daa0,
- 0x1dab0, 0x1dfff,
- 0x1e007, 0x1e007,
- 0x1e019, 0x1e01a,
- 0x1e022, 0x1e022,
- 0x1e025, 0x1e025,
- 0x1e02b, 0x1e0ff,
- 0x1e12d, 0x1e12f,
- 0x1e13e, 0x1e13f,
- 0x1e14a, 0x1e14d,
- 0x1e150, 0x1e2bf,
- 0x1e2fa, 0x1e2fe,
- 0x1e300, 0x1e7ff,
- 0x1e8c5, 0x1e8c6,
- 0x1e8d7, 0x1e8ff,
- 0x1e94c, 0x1e94f,
- 0x1e95a, 0x1e95d,
- 0x1e960, 0x1ec70,
- 0x1ecb5, 0x1ed00,
- 0x1ed3e, 0x1edff,
- 0x1ee04, 0x1ee04,
- 0x1ee20, 0x1ee20,
- 0x1ee23, 0x1ee23,
- 0x1ee25, 0x1ee26,
- 0x1ee28, 0x1ee28,
- 0x1ee33, 0x1ee33,
- 0x1ee38, 0x1ee38,
- 0x1ee3a, 0x1ee3a,
- 0x1ee3c, 0x1ee41,
- 0x1ee43, 0x1ee46,
- 0x1ee48, 0x1ee48,
- 0x1ee4a, 0x1ee4a,
- 0x1ee4c, 0x1ee4c,
- 0x1ee50, 0x1ee50,
- 0x1ee53, 0x1ee53,
- 0x1ee55, 0x1ee56,
- 0x1ee58, 0x1ee58,
- 0x1ee5a, 0x1ee5a,
- 0x1ee5c, 0x1ee5c,
- 0x1ee5e, 0x1ee5e,
- 0x1ee60, 0x1ee60,
- 0x1ee63, 0x1ee63,
- 0x1ee65, 0x1ee66,
- 0x1ee6b, 0x1ee6b,
- 0x1ee73, 0x1ee73,
- 0x1ee78, 0x1ee78,
- 0x1ee7d, 0x1ee7d,
- 0x1ee7f, 0x1ee7f,
- 0x1ee8a, 0x1ee8a,
- 0x1ee9c, 0x1eea0,
- 0x1eea4, 0x1eea4,
- 0x1eeaa, 0x1eeaa,
- 0x1eebc, 0x1eeef,
- 0x1eef2, 0x1efff,
- 0x1f02c, 0x1f02f,
- 0x1f094, 0x1f09f,
- 0x1f0af, 0x1f0b0,
- 0x1f0c0, 0x1f0c0,
- 0x1f0d0, 0x1f0d0,
- 0x1f0f6, 0x1f0ff,
- 0x1f10d, 0x1f10f,
- 0x1f16d, 0x1f16f,
- 0x1f1ad, 0x1f1e5,
- 0x1f203, 0x1f20f,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f24f,
- 0x1f252, 0x1f25f,
- 0x1f266, 0x1f2ff,
- 0x1f6d6, 0x1f6df,
- 0x1f6ed, 0x1f6ef,
- 0x1f6fb, 0x1f6ff,
- 0x1f774, 0x1f77f,
- 0x1f7d9, 0x1f7df,
- 0x1f7ec, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8ff,
- 0x1f90c, 0x1f90c,
- 0x1f972, 0x1f972,
- 0x1f977, 0x1f979,
- 0x1f9a3, 0x1f9a4,
- 0x1f9ab, 0x1f9ad,
- 0x1f9cb, 0x1f9cc,
- 0x1fa54, 0x1fa5f,
- 0x1fa6e, 0x1fa6f,
- 0x1fa74, 0x1fa77,
- 0x1fa7b, 0x1fa7f,
- 0x1fa83, 0x1fa8f,
- 0x1fa96, 0x1ffff,
- 0x2a6d7, 0x2a6ff,
- 0x2b735, 0x2b73f,
- 0x2b81e, 0x2b81f,
- 0x2cea2, 0x2ceaf,
- 0x2ebe1, 0x2f7ff,
- 0x2fa1e, 0xe00ff,
- 0xe01f0, 0x10ffff,
-}; /* CR_C */
-
-/* 'Cc': General Category */
-#define CR_Cc CR_Cntrl
-
-/* 'Cf': General Category */
-static const OnigCodePoint CR_Cf[] = {
- 20,
- 0x00ad, 0x00ad,
- 0x0600, 0x0605,
- 0x061c, 0x061c,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x08e2, 0x08e2,
- 0x180e, 0x180e,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x2064,
- 0x2066, 0x206f,
- 0xfeff, 0xfeff,
- 0xfff9, 0xfffb,
- 0x110bd, 0x110bd,
- 0x110cd, 0x110cd,
- 0x13430, 0x13438,
- 0x1bca0, 0x1bca3,
- 0x1d173, 0x1d17a,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
-}; /* CR_Cf */
-
-/* 'Cn': General Category */
-static const OnigCodePoint CR_Cn[] = {
- 666,
- 0x0378, 0x0379,
- 0x0380, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x0530, 0x0530,
- 0x0557, 0x0558,
- 0x058b, 0x058c,
- 0x0590, 0x0590,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ee,
- 0x05f5, 0x05ff,
- 0x061d, 0x061d,
- 0x070e, 0x070e,
- 0x074b, 0x074c,
- 0x07b2, 0x07bf,
- 0x07fb, 0x07fc,
- 0x082e, 0x082f,
- 0x083f, 0x083f,
- 0x085c, 0x085d,
- 0x085f, 0x085f,
- 0x086b, 0x089f,
- 0x08b5, 0x08b5,
- 0x08be, 0x08d2,
- 0x0984, 0x0984,
- 0x098d, 0x098e,
- 0x0991, 0x0992,
- 0x09a9, 0x09a9,
- 0x09b1, 0x09b1,
- 0x09b3, 0x09b5,
- 0x09ba, 0x09bb,
- 0x09c5, 0x09c6,
- 0x09c9, 0x09ca,
- 0x09cf, 0x09d6,
- 0x09d8, 0x09db,
- 0x09de, 0x09de,
- 0x09e4, 0x09e5,
- 0x09ff, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a50,
- 0x0a52, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a77, 0x0a80,
- 0x0a84, 0x0a84,
- 0x0a8e, 0x0a8e,
- 0x0a92, 0x0a92,
- 0x0aa9, 0x0aa9,
- 0x0ab1, 0x0ab1,
- 0x0ab4, 0x0ab4,
- 0x0aba, 0x0abb,
- 0x0ac6, 0x0ac6,
- 0x0aca, 0x0aca,
- 0x0ace, 0x0acf,
- 0x0ad1, 0x0adf,
- 0x0ae4, 0x0ae5,
- 0x0af2, 0x0af8,
- 0x0b00, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b45, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b55,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b64, 0x0b65,
- 0x0b78, 0x0b81,
- 0x0b84, 0x0b84,
- 0x0b8b, 0x0b8d,
- 0x0b91, 0x0b91,
- 0x0b96, 0x0b98,
- 0x0b9b, 0x0b9b,
- 0x0b9d, 0x0b9d,
- 0x0ba0, 0x0ba2,
- 0x0ba5, 0x0ba7,
- 0x0bab, 0x0bad,
- 0x0bba, 0x0bbd,
- 0x0bc3, 0x0bc5,
- 0x0bc9, 0x0bc9,
- 0x0bce, 0x0bcf,
- 0x0bd1, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0bff,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c3a, 0x0c3c,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c57,
- 0x0c5b, 0x0c5f,
- 0x0c64, 0x0c65,
- 0x0c70, 0x0c76,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdd,
- 0x0cdf, 0x0cdf,
- 0x0ce4, 0x0ce5,
- 0x0cf0, 0x0cf0,
- 0x0cf3, 0x0cff,
- 0x0d04, 0x0d04,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d45, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d50, 0x0d53,
- 0x0d64, 0x0d65,
- 0x0d80, 0x0d81,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0de5,
- 0x0df0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e85,
- 0x0e8b, 0x0e8b,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ece, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ee0, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6d, 0x0f70,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fcd,
- 0x0fdb, 0x0fff,
- 0x10c6, 0x10c6,
- 0x10c8, 0x10cc,
- 0x10ce, 0x10cf,
- 0x1249, 0x1249,
- 0x124e, 0x124f,
- 0x1257, 0x1257,
- 0x1259, 0x1259,
- 0x125e, 0x125f,
- 0x1289, 0x1289,
- 0x128e, 0x128f,
- 0x12b1, 0x12b1,
- 0x12b6, 0x12b7,
- 0x12bf, 0x12bf,
- 0x12c1, 0x12c1,
- 0x12c6, 0x12c7,
- 0x12d7, 0x12d7,
- 0x1311, 0x1311,
- 0x1316, 0x1317,
- 0x135b, 0x135c,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f6, 0x13f7,
- 0x13fe, 0x13ff,
- 0x169d, 0x169f,
- 0x16f9, 0x16ff,
- 0x170d, 0x170d,
- 0x1715, 0x171f,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x180f, 0x180f,
- 0x181a, 0x181f,
- 0x1879, 0x187f,
- 0x18ab, 0x18af,
- 0x18f6, 0x18ff,
- 0x191f, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19ac, 0x19af,
- 0x19ca, 0x19cf,
- 0x19db, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a5f, 0x1a5f,
- 0x1a7d, 0x1a7e,
- 0x1a8a, 0x1a8f,
- 0x1a9a, 0x1a9f,
- 0x1aae, 0x1aaf,
- 0x1abf, 0x1aff,
- 0x1b4c, 0x1b4f,
- 0x1b7d, 0x1b7f,
- 0x1bf4, 0x1bfb,
- 0x1c38, 0x1c3a,
- 0x1c4a, 0x1c4c,
- 0x1c89, 0x1c8f,
- 0x1cbb, 0x1cbc,
- 0x1cc8, 0x1ccf,
- 0x1cfb, 0x1cff,
- 0x1dfa, 0x1dfa,
- 0x1f16, 0x1f17,
- 0x1f1e, 0x1f1f,
- 0x1f46, 0x1f47,
- 0x1f4e, 0x1f4f,
- 0x1f58, 0x1f58,
- 0x1f5a, 0x1f5a,
- 0x1f5c, 0x1f5c,
- 0x1f5e, 0x1f5e,
- 0x1f7e, 0x1f7f,
- 0x1fb5, 0x1fb5,
- 0x1fc5, 0x1fc5,
- 0x1fd4, 0x1fd5,
- 0x1fdc, 0x1fdc,
- 0x1ff0, 0x1ff1,
- 0x1ff5, 0x1ff5,
- 0x1fff, 0x1fff,
- 0x2065, 0x2065,
- 0x2072, 0x2073,
- 0x208f, 0x208f,
- 0x209d, 0x209f,
- 0x20c0, 0x20cf,
- 0x20f1, 0x20ff,
- 0x218c, 0x218f,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x2b74, 0x2b75,
- 0x2b96, 0x2b97,
- 0x2c2f, 0x2c2f,
- 0x2c5f, 0x2c5f,
- 0x2cf4, 0x2cf8,
- 0x2d26, 0x2d26,
- 0x2d28, 0x2d2c,
- 0x2d2e, 0x2d2f,
- 0x2d68, 0x2d6e,
- 0x2d71, 0x2d7e,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2ddf,
- 0x2e50, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x3130, 0x3130,
- 0x318f, 0x318f,
- 0x31bb, 0x31bf,
- 0x31e4, 0x31ef,
- 0x321f, 0x321f,
- 0x4db6, 0x4dbf,
- 0x9ff0, 0x9fff,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa4cf,
- 0xa62c, 0xa63f,
- 0xa6f8, 0xa6ff,
- 0xa7c0, 0xa7c1,
- 0xa7c7, 0xa7f6,
- 0xa82c, 0xa82f,
- 0xa83a, 0xa83f,
- 0xa878, 0xa87f,
- 0xa8c6, 0xa8cd,
- 0xa8da, 0xa8df,
- 0xa954, 0xa95e,
- 0xa97d, 0xa97f,
- 0xa9ce, 0xa9ce,
- 0xa9da, 0xa9dd,
- 0xa9ff, 0xa9ff,
- 0xaa37, 0xaa3f,
- 0xaa4e, 0xaa4f,
- 0xaa5a, 0xaa5b,
- 0xaac3, 0xaada,
- 0xaaf7, 0xab00,
- 0xab07, 0xab08,
- 0xab0f, 0xab10,
- 0xab17, 0xab1f,
- 0xab27, 0xab27,
- 0xab2f, 0xab2f,
- 0xab68, 0xab6f,
- 0xabee, 0xabef,
- 0xabfa, 0xabff,
- 0xd7a4, 0xd7af,
- 0xd7c7, 0xd7ca,
- 0xd7fc, 0xd7ff,
- 0xfa6e, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbc2, 0xfbd2,
- 0xfd40, 0xfd4f,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdef,
- 0xfdfe, 0xfdff,
- 0xfe1a, 0xfe1f,
- 0xfe53, 0xfe53,
- 0xfe67, 0xfe67,
- 0xfe6c, 0xfe6f,
- 0xfe75, 0xfe75,
- 0xfefd, 0xfefe,
- 0xff00, 0xff00,
- 0xffbf, 0xffc1,
- 0xffc8, 0xffc9,
- 0xffd0, 0xffd1,
- 0xffd8, 0xffd9,
- 0xffdd, 0xffdf,
- 0xffe7, 0xffe7,
- 0xffef, 0xfff8,
- 0xfffe, 0xffff,
- 0x1000c, 0x1000c,
- 0x10027, 0x10027,
- 0x1003b, 0x1003b,
- 0x1003e, 0x1003e,
- 0x1004e, 0x1004f,
- 0x1005e, 0x1007f,
- 0x100fb, 0x100ff,
- 0x10103, 0x10106,
- 0x10134, 0x10136,
- 0x1018f, 0x1018f,
- 0x1019c, 0x1019f,
- 0x101a1, 0x101cf,
- 0x101fe, 0x1027f,
- 0x1029d, 0x1029f,
- 0x102d1, 0x102df,
- 0x102fc, 0x102ff,
- 0x10324, 0x1032c,
- 0x1034b, 0x1034f,
- 0x1037b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x104af,
- 0x104d4, 0x104d7,
- 0x104fc, 0x104ff,
- 0x10528, 0x1052f,
- 0x10564, 0x1056e,
- 0x10570, 0x105ff,
- 0x10737, 0x1073f,
- 0x10756, 0x1075f,
- 0x10768, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10856, 0x10856,
- 0x1089f, 0x108a6,
- 0x108b0, 0x108df,
- 0x108f3, 0x108f3,
- 0x108f6, 0x108fa,
- 0x1091c, 0x1091e,
- 0x1093a, 0x1093e,
- 0x10940, 0x1097f,
- 0x109b8, 0x109bb,
- 0x109d0, 0x109d1,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a36, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a49, 0x10a4f,
- 0x10a59, 0x10a5f,
- 0x10aa0, 0x10abf,
- 0x10ae7, 0x10aea,
- 0x10af7, 0x10aff,
- 0x10b36, 0x10b38,
- 0x10b56, 0x10b57,
- 0x10b73, 0x10b77,
- 0x10b92, 0x10b98,
- 0x10b9d, 0x10ba8,
- 0x10bb0, 0x10bff,
- 0x10c49, 0x10c7f,
- 0x10cb3, 0x10cbf,
- 0x10cf3, 0x10cf9,
- 0x10d28, 0x10d2f,
- 0x10d3a, 0x10e5f,
- 0x10e7f, 0x10eff,
- 0x10f28, 0x10f2f,
- 0x10f5a, 0x10fdf,
- 0x10ff7, 0x10fff,
- 0x1104e, 0x11051,
- 0x11070, 0x1107e,
- 0x110c2, 0x110cc,
- 0x110ce, 0x110cf,
- 0x110e9, 0x110ef,
- 0x110fa, 0x110ff,
- 0x11135, 0x11135,
- 0x11147, 0x1114f,
- 0x11177, 0x1117f,
- 0x111ce, 0x111cf,
- 0x111e0, 0x111e0,
- 0x111f5, 0x111ff,
- 0x11212, 0x11212,
- 0x1123f, 0x1127f,
- 0x11287, 0x11287,
- 0x11289, 0x11289,
- 0x1128e, 0x1128e,
- 0x1129e, 0x1129e,
- 0x112aa, 0x112af,
- 0x112eb, 0x112ef,
- 0x112fa, 0x112ff,
- 0x11304, 0x11304,
- 0x1130d, 0x1130e,
- 0x11311, 0x11312,
- 0x11329, 0x11329,
- 0x11331, 0x11331,
- 0x11334, 0x11334,
- 0x1133a, 0x1133a,
- 0x11345, 0x11346,
- 0x11349, 0x1134a,
- 0x1134e, 0x1134f,
- 0x11351, 0x11356,
- 0x11358, 0x1135c,
- 0x11364, 0x11365,
- 0x1136d, 0x1136f,
- 0x11375, 0x113ff,
- 0x1145a, 0x1145a,
- 0x1145c, 0x1145c,
- 0x11460, 0x1147f,
- 0x114c8, 0x114cf,
- 0x114da, 0x1157f,
- 0x115b6, 0x115b7,
- 0x115de, 0x115ff,
- 0x11645, 0x1164f,
- 0x1165a, 0x1165f,
- 0x1166d, 0x1167f,
- 0x116b9, 0x116bf,
- 0x116ca, 0x116ff,
- 0x1171b, 0x1171c,
- 0x1172c, 0x1172f,
- 0x11740, 0x117ff,
- 0x1183c, 0x1189f,
- 0x118f3, 0x118fe,
- 0x11900, 0x1199f,
- 0x119a8, 0x119a9,
- 0x119d8, 0x119d9,
- 0x119e5, 0x119ff,
- 0x11a48, 0x11a4f,
- 0x11aa3, 0x11abf,
- 0x11af9, 0x11bff,
- 0x11c09, 0x11c09,
- 0x11c37, 0x11c37,
- 0x11c46, 0x11c4f,
- 0x11c6d, 0x11c6f,
- 0x11c90, 0x11c91,
- 0x11ca8, 0x11ca8,
- 0x11cb7, 0x11cff,
- 0x11d07, 0x11d07,
- 0x11d0a, 0x11d0a,
- 0x11d37, 0x11d39,
- 0x11d3b, 0x11d3b,
- 0x11d3e, 0x11d3e,
- 0x11d48, 0x11d4f,
- 0x11d5a, 0x11d5f,
- 0x11d66, 0x11d66,
- 0x11d69, 0x11d69,
- 0x11d8f, 0x11d8f,
- 0x11d92, 0x11d92,
- 0x11d99, 0x11d9f,
- 0x11daa, 0x11edf,
- 0x11ef9, 0x11fbf,
- 0x11ff2, 0x11ffe,
- 0x1239a, 0x123ff,
- 0x1246f, 0x1246f,
- 0x12475, 0x1247f,
- 0x12544, 0x12fff,
- 0x1342f, 0x1342f,
- 0x13439, 0x143ff,
- 0x14647, 0x167ff,
- 0x16a39, 0x16a3f,
- 0x16a5f, 0x16a5f,
- 0x16a6a, 0x16a6d,
- 0x16a70, 0x16acf,
- 0x16aee, 0x16aef,
- 0x16af6, 0x16aff,
- 0x16b46, 0x16b4f,
- 0x16b5a, 0x16b5a,
- 0x16b62, 0x16b62,
- 0x16b78, 0x16b7c,
- 0x16b90, 0x16e3f,
- 0x16e9b, 0x16eff,
- 0x16f4b, 0x16f4e,
- 0x16f88, 0x16f8e,
- 0x16fa0, 0x16fdf,
- 0x16fe4, 0x16fff,
- 0x187f8, 0x187ff,
- 0x18af3, 0x1afff,
- 0x1b11f, 0x1b14f,
- 0x1b153, 0x1b163,
- 0x1b168, 0x1b16f,
- 0x1b2fc, 0x1bbff,
- 0x1bc6b, 0x1bc6f,
- 0x1bc7d, 0x1bc7f,
- 0x1bc89, 0x1bc8f,
- 0x1bc9a, 0x1bc9b,
- 0x1bca4, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d128,
- 0x1d1e9, 0x1d1ff,
- 0x1d246, 0x1d2df,
- 0x1d2f4, 0x1d2ff,
- 0x1d357, 0x1d35f,
- 0x1d379, 0x1d3ff,
- 0x1d455, 0x1d455,
- 0x1d49d, 0x1d49d,
- 0x1d4a0, 0x1d4a1,
- 0x1d4a3, 0x1d4a4,
- 0x1d4a7, 0x1d4a8,
- 0x1d4ad, 0x1d4ad,
- 0x1d4ba, 0x1d4ba,
- 0x1d4bc, 0x1d4bc,
- 0x1d4c4, 0x1d4c4,
- 0x1d506, 0x1d506,
- 0x1d50b, 0x1d50c,
- 0x1d515, 0x1d515,
- 0x1d51d, 0x1d51d,
- 0x1d53a, 0x1d53a,
- 0x1d53f, 0x1d53f,
- 0x1d545, 0x1d545,
- 0x1d547, 0x1d549,
- 0x1d551, 0x1d551,
- 0x1d6a6, 0x1d6a7,
- 0x1d7cc, 0x1d7cd,
- 0x1da8c, 0x1da9a,
- 0x1daa0, 0x1daa0,
- 0x1dab0, 0x1dfff,
- 0x1e007, 0x1e007,
- 0x1e019, 0x1e01a,
- 0x1e022, 0x1e022,
- 0x1e025, 0x1e025,
- 0x1e02b, 0x1e0ff,
- 0x1e12d, 0x1e12f,
- 0x1e13e, 0x1e13f,
- 0x1e14a, 0x1e14d,
- 0x1e150, 0x1e2bf,
- 0x1e2fa, 0x1e2fe,
- 0x1e300, 0x1e7ff,
- 0x1e8c5, 0x1e8c6,
- 0x1e8d7, 0x1e8ff,
- 0x1e94c, 0x1e94f,
- 0x1e95a, 0x1e95d,
- 0x1e960, 0x1ec70,
- 0x1ecb5, 0x1ed00,
- 0x1ed3e, 0x1edff,
- 0x1ee04, 0x1ee04,
- 0x1ee20, 0x1ee20,
- 0x1ee23, 0x1ee23,
- 0x1ee25, 0x1ee26,
- 0x1ee28, 0x1ee28,
- 0x1ee33, 0x1ee33,
- 0x1ee38, 0x1ee38,
- 0x1ee3a, 0x1ee3a,
- 0x1ee3c, 0x1ee41,
- 0x1ee43, 0x1ee46,
- 0x1ee48, 0x1ee48,
- 0x1ee4a, 0x1ee4a,
- 0x1ee4c, 0x1ee4c,
- 0x1ee50, 0x1ee50,
- 0x1ee53, 0x1ee53,
- 0x1ee55, 0x1ee56,
- 0x1ee58, 0x1ee58,
- 0x1ee5a, 0x1ee5a,
- 0x1ee5c, 0x1ee5c,
- 0x1ee5e, 0x1ee5e,
- 0x1ee60, 0x1ee60,
- 0x1ee63, 0x1ee63,
- 0x1ee65, 0x1ee66,
- 0x1ee6b, 0x1ee6b,
- 0x1ee73, 0x1ee73,
- 0x1ee78, 0x1ee78,
- 0x1ee7d, 0x1ee7d,
- 0x1ee7f, 0x1ee7f,
- 0x1ee8a, 0x1ee8a,
- 0x1ee9c, 0x1eea0,
- 0x1eea4, 0x1eea4,
- 0x1eeaa, 0x1eeaa,
- 0x1eebc, 0x1eeef,
- 0x1eef2, 0x1efff,
- 0x1f02c, 0x1f02f,
- 0x1f094, 0x1f09f,
- 0x1f0af, 0x1f0b0,
- 0x1f0c0, 0x1f0c0,
- 0x1f0d0, 0x1f0d0,
- 0x1f0f6, 0x1f0ff,
- 0x1f10d, 0x1f10f,
- 0x1f16d, 0x1f16f,
- 0x1f1ad, 0x1f1e5,
- 0x1f203, 0x1f20f,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f24f,
- 0x1f252, 0x1f25f,
- 0x1f266, 0x1f2ff,
- 0x1f6d6, 0x1f6df,
- 0x1f6ed, 0x1f6ef,
- 0x1f6fb, 0x1f6ff,
- 0x1f774, 0x1f77f,
- 0x1f7d9, 0x1f7df,
- 0x1f7ec, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8ff,
- 0x1f90c, 0x1f90c,
- 0x1f972, 0x1f972,
- 0x1f977, 0x1f979,
- 0x1f9a3, 0x1f9a4,
- 0x1f9ab, 0x1f9ad,
- 0x1f9cb, 0x1f9cc,
- 0x1fa54, 0x1fa5f,
- 0x1fa6e, 0x1fa6f,
- 0x1fa74, 0x1fa77,
- 0x1fa7b, 0x1fa7f,
- 0x1fa83, 0x1fa8f,
- 0x1fa96, 0x1ffff,
- 0x2a6d7, 0x2a6ff,
- 0x2b735, 0x2b73f,
- 0x2b81e, 0x2b81f,
- 0x2cea2, 0x2ceaf,
- 0x2ebe1, 0x2f7ff,
- 0x2fa1e, 0xe0000,
- 0xe0002, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xeffff,
- 0xffffe, 0xfffff,
- 0x10fffe, 0x10ffff,
-}; /* CR_Cn */
-
-/* 'Co': General Category */
-static const OnigCodePoint CR_Co[] = {
- 3,
- 0xe000, 0xf8ff,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd,
-}; /* CR_Co */
-
-/* 'Cs': General Category */
-static const OnigCodePoint CR_Cs[] = {
- 1,
- 0xd800, 0xdfff,
-}; /* CR_Cs */
-
-/* 'L': Major Category */
-static const OnigCodePoint CR_L[] = {
- 609,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06e5, 0x06e6,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0971, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a72, 0x0a74,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0abd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0af9, 0x0af9,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b71, 0x0b71,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e46,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16f1, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1711,
- 0x1720, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x1884,
- 0x1887, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1aa7, 0x1aa7,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4b,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2183, 0x2184,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3006,
- 0x3031, 0x3035,
- 0x303b, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa67f, 0xa69d,
- 0xa6a0, 0xa6e5,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9e4,
- 0xa9e6, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf4,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x10340,
- 0x10342, 0x10349,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d23,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x1145f,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11800, 0x1182b,
- 0x118a0, 0x118df,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x12000, 0x12399,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2eb,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_L */
-
-/* 'LC': General Category */
-static const OnigCodePoint CR_LC[] = {
- 131,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x01ba,
- 0x01bc, 0x01bf,
- 0x01c4, 0x0293,
- 0x0295, 0x02af,
- 0x0370, 0x0373,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0560, 0x0588,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1d00, 0x1d2b,
- 0x1d6b, 0x1d77,
- 0x1d79, 0x1d9a,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2183, 0x2184,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2c7b,
- 0x2c7e, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa640, 0xa66d,
- 0xa680, 0xa69b,
- 0xa722, 0xa76f,
- 0xa771, 0xa787,
- 0xa78b, 0xa78e,
- 0xa790, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7fa, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab60, 0xab67,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0x10400, 0x1044f,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x118a0, 0x118df,
- 0x16e40, 0x16e7f,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1e900, 0x1e943,
-}; /* CR_LC */
-
-/* 'Ll': General Category */
-static const OnigCodePoint CR_Ll[] = {
- 642,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 0x00df, 0x00f6,
- 0x00f8, 0x00ff,
- 0x0101, 0x0101,
- 0x0103, 0x0103,
- 0x0105, 0x0105,
- 0x0107, 0x0107,
- 0x0109, 0x0109,
- 0x010b, 0x010b,
- 0x010d, 0x010d,
- 0x010f, 0x010f,
- 0x0111, 0x0111,
- 0x0113, 0x0113,
- 0x0115, 0x0115,
- 0x0117, 0x0117,
- 0x0119, 0x0119,
- 0x011b, 0x011b,
- 0x011d, 0x011d,
- 0x011f, 0x011f,
- 0x0121, 0x0121,
- 0x0123, 0x0123,
- 0x0125, 0x0125,
- 0x0127, 0x0127,
- 0x0129, 0x0129,
- 0x012b, 0x012b,
- 0x012d, 0x012d,
- 0x012f, 0x012f,
- 0x0131, 0x0131,
- 0x0133, 0x0133,
- 0x0135, 0x0135,
- 0x0137, 0x0138,
- 0x013a, 0x013a,
- 0x013c, 0x013c,
- 0x013e, 0x013e,
- 0x0140, 0x0140,
- 0x0142, 0x0142,
- 0x0144, 0x0144,
- 0x0146, 0x0146,
- 0x0148, 0x0149,
- 0x014b, 0x014b,
- 0x014d, 0x014d,
- 0x014f, 0x014f,
- 0x0151, 0x0151,
- 0x0153, 0x0153,
- 0x0155, 0x0155,
- 0x0157, 0x0157,
- 0x0159, 0x0159,
- 0x015b, 0x015b,
- 0x015d, 0x015d,
- 0x015f, 0x015f,
- 0x0161, 0x0161,
- 0x0163, 0x0163,
- 0x0165, 0x0165,
- 0x0167, 0x0167,
- 0x0169, 0x0169,
- 0x016b, 0x016b,
- 0x016d, 0x016d,
- 0x016f, 0x016f,
- 0x0171, 0x0171,
- 0x0173, 0x0173,
- 0x0175, 0x0175,
- 0x0177, 0x0177,
- 0x017a, 0x017a,
- 0x017c, 0x017c,
- 0x017e, 0x0180,
- 0x0183, 0x0183,
- 0x0185, 0x0185,
- 0x0188, 0x0188,
- 0x018c, 0x018d,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019b,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01aa, 0x01ab,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01ba,
- 0x01bd, 0x01bf,
- 0x01c6, 0x01c6,
- 0x01c9, 0x01c9,
- 0x01cc, 0x01cc,
- 0x01ce, 0x01ce,
- 0x01d0, 0x01d0,
- 0x01d2, 0x01d2,
- 0x01d4, 0x01d4,
- 0x01d6, 0x01d6,
- 0x01d8, 0x01d8,
- 0x01da, 0x01da,
- 0x01dc, 0x01dd,
- 0x01df, 0x01df,
- 0x01e1, 0x01e1,
- 0x01e3, 0x01e3,
- 0x01e5, 0x01e5,
- 0x01e7, 0x01e7,
- 0x01e9, 0x01e9,
- 0x01eb, 0x01eb,
- 0x01ed, 0x01ed,
- 0x01ef, 0x01f0,
- 0x01f3, 0x01f3,
- 0x01f5, 0x01f5,
- 0x01f9, 0x01f9,
- 0x01fb, 0x01fb,
- 0x01fd, 0x01fd,
- 0x01ff, 0x01ff,
- 0x0201, 0x0201,
- 0x0203, 0x0203,
- 0x0205, 0x0205,
- 0x0207, 0x0207,
- 0x0209, 0x0209,
- 0x020b, 0x020b,
- 0x020d, 0x020d,
- 0x020f, 0x020f,
- 0x0211, 0x0211,
- 0x0213, 0x0213,
- 0x0215, 0x0215,
- 0x0217, 0x0217,
- 0x0219, 0x0219,
- 0x021b, 0x021b,
- 0x021d, 0x021d,
- 0x021f, 0x021f,
- 0x0221, 0x0221,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0239,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0293,
- 0x0295, 0x02af,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037b, 0x037d,
- 0x0390, 0x0390,
- 0x03ac, 0x03ce,
- 0x03d0, 0x03d1,
- 0x03d5, 0x03d7,
- 0x03d9, 0x03d9,
- 0x03db, 0x03db,
- 0x03dd, 0x03dd,
- 0x03df, 0x03df,
- 0x03e1, 0x03e1,
- 0x03e3, 0x03e3,
- 0x03e5, 0x03e5,
- 0x03e7, 0x03e7,
- 0x03e9, 0x03e9,
- 0x03eb, 0x03eb,
- 0x03ed, 0x03ed,
- 0x03ef, 0x03f3,
- 0x03f5, 0x03f5,
- 0x03f8, 0x03f8,
- 0x03fb, 0x03fc,
- 0x0430, 0x045f,
- 0x0461, 0x0461,
- 0x0463, 0x0463,
- 0x0465, 0x0465,
- 0x0467, 0x0467,
- 0x0469, 0x0469,
- 0x046b, 0x046b,
- 0x046d, 0x046d,
- 0x046f, 0x046f,
- 0x0471, 0x0471,
- 0x0473, 0x0473,
- 0x0475, 0x0475,
- 0x0477, 0x0477,
- 0x0479, 0x0479,
- 0x047b, 0x047b,
- 0x047d, 0x047d,
- 0x047f, 0x047f,
- 0x0481, 0x0481,
- 0x048b, 0x048b,
- 0x048d, 0x048d,
- 0x048f, 0x048f,
- 0x0491, 0x0491,
- 0x0493, 0x0493,
- 0x0495, 0x0495,
- 0x0497, 0x0497,
- 0x0499, 0x0499,
- 0x049b, 0x049b,
- 0x049d, 0x049d,
- 0x049f, 0x049f,
- 0x04a1, 0x04a1,
- 0x04a3, 0x04a3,
- 0x04a5, 0x04a5,
- 0x04a7, 0x04a7,
- 0x04a9, 0x04a9,
- 0x04ab, 0x04ab,
- 0x04ad, 0x04ad,
- 0x04af, 0x04af,
- 0x04b1, 0x04b1,
- 0x04b3, 0x04b3,
- 0x04b5, 0x04b5,
- 0x04b7, 0x04b7,
- 0x04b9, 0x04b9,
- 0x04bb, 0x04bb,
- 0x04bd, 0x04bd,
- 0x04bf, 0x04bf,
- 0x04c2, 0x04c2,
- 0x04c4, 0x04c4,
- 0x04c6, 0x04c6,
- 0x04c8, 0x04c8,
- 0x04ca, 0x04ca,
- 0x04cc, 0x04cc,
- 0x04ce, 0x04cf,
- 0x04d1, 0x04d1,
- 0x04d3, 0x04d3,
- 0x04d5, 0x04d5,
- 0x04d7, 0x04d7,
- 0x04d9, 0x04d9,
- 0x04db, 0x04db,
- 0x04dd, 0x04dd,
- 0x04df, 0x04df,
- 0x04e1, 0x04e1,
- 0x04e3, 0x04e3,
- 0x04e5, 0x04e5,
- 0x04e7, 0x04e7,
- 0x04e9, 0x04e9,
- 0x04eb, 0x04eb,
- 0x04ed, 0x04ed,
- 0x04ef, 0x04ef,
- 0x04f1, 0x04f1,
- 0x04f3, 0x04f3,
- 0x04f5, 0x04f5,
- 0x04f7, 0x04f7,
- 0x04f9, 0x04f9,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0560, 0x0588,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d00, 0x1d2b,
- 0x1d6b, 0x1d77,
- 0x1d79, 0x1d9a,
- 0x1e01, 0x1e01,
- 0x1e03, 0x1e03,
- 0x1e05, 0x1e05,
- 0x1e07, 0x1e07,
- 0x1e09, 0x1e09,
- 0x1e0b, 0x1e0b,
- 0x1e0d, 0x1e0d,
- 0x1e0f, 0x1e0f,
- 0x1e11, 0x1e11,
- 0x1e13, 0x1e13,
- 0x1e15, 0x1e15,
- 0x1e17, 0x1e17,
- 0x1e19, 0x1e19,
- 0x1e1b, 0x1e1b,
- 0x1e1d, 0x1e1d,
- 0x1e1f, 0x1e1f,
- 0x1e21, 0x1e21,
- 0x1e23, 0x1e23,
- 0x1e25, 0x1e25,
- 0x1e27, 0x1e27,
- 0x1e29, 0x1e29,
- 0x1e2b, 0x1e2b,
- 0x1e2d, 0x1e2d,
- 0x1e2f, 0x1e2f,
- 0x1e31, 0x1e31,
- 0x1e33, 0x1e33,
- 0x1e35, 0x1e35,
- 0x1e37, 0x1e37,
- 0x1e39, 0x1e39,
- 0x1e3b, 0x1e3b,
- 0x1e3d, 0x1e3d,
- 0x1e3f, 0x1e3f,
- 0x1e41, 0x1e41,
- 0x1e43, 0x1e43,
- 0x1e45, 0x1e45,
- 0x1e47, 0x1e47,
- 0x1e49, 0x1e49,
- 0x1e4b, 0x1e4b,
- 0x1e4d, 0x1e4d,
- 0x1e4f, 0x1e4f,
- 0x1e51, 0x1e51,
- 0x1e53, 0x1e53,
- 0x1e55, 0x1e55,
- 0x1e57, 0x1e57,
- 0x1e59, 0x1e59,
- 0x1e5b, 0x1e5b,
- 0x1e5d, 0x1e5d,
- 0x1e5f, 0x1e5f,
- 0x1e61, 0x1e61,
- 0x1e63, 0x1e63,
- 0x1e65, 0x1e65,
- 0x1e67, 0x1e67,
- 0x1e69, 0x1e69,
- 0x1e6b, 0x1e6b,
- 0x1e6d, 0x1e6d,
- 0x1e6f, 0x1e6f,
- 0x1e71, 0x1e71,
- 0x1e73, 0x1e73,
- 0x1e75, 0x1e75,
- 0x1e77, 0x1e77,
- 0x1e79, 0x1e79,
- 0x1e7b, 0x1e7b,
- 0x1e7d, 0x1e7d,
- 0x1e7f, 0x1e7f,
- 0x1e81, 0x1e81,
- 0x1e83, 0x1e83,
- 0x1e85, 0x1e85,
- 0x1e87, 0x1e87,
- 0x1e89, 0x1e89,
- 0x1e8b, 0x1e8b,
- 0x1e8d, 0x1e8d,
- 0x1e8f, 0x1e8f,
- 0x1e91, 0x1e91,
- 0x1e93, 0x1e93,
- 0x1e95, 0x1e9d,
- 0x1e9f, 0x1e9f,
- 0x1ea1, 0x1ea1,
- 0x1ea3, 0x1ea3,
- 0x1ea5, 0x1ea5,
- 0x1ea7, 0x1ea7,
- 0x1ea9, 0x1ea9,
- 0x1eab, 0x1eab,
- 0x1ead, 0x1ead,
- 0x1eaf, 0x1eaf,
- 0x1eb1, 0x1eb1,
- 0x1eb3, 0x1eb3,
- 0x1eb5, 0x1eb5,
- 0x1eb7, 0x1eb7,
- 0x1eb9, 0x1eb9,
- 0x1ebb, 0x1ebb,
- 0x1ebd, 0x1ebd,
- 0x1ebf, 0x1ebf,
- 0x1ec1, 0x1ec1,
- 0x1ec3, 0x1ec3,
- 0x1ec5, 0x1ec5,
- 0x1ec7, 0x1ec7,
- 0x1ec9, 0x1ec9,
- 0x1ecb, 0x1ecb,
- 0x1ecd, 0x1ecd,
- 0x1ecf, 0x1ecf,
- 0x1ed1, 0x1ed1,
- 0x1ed3, 0x1ed3,
- 0x1ed5, 0x1ed5,
- 0x1ed7, 0x1ed7,
- 0x1ed9, 0x1ed9,
- 0x1edb, 0x1edb,
- 0x1edd, 0x1edd,
- 0x1edf, 0x1edf,
- 0x1ee1, 0x1ee1,
- 0x1ee3, 0x1ee3,
- 0x1ee5, 0x1ee5,
- 0x1ee7, 0x1ee7,
- 0x1ee9, 0x1ee9,
- 0x1eeb, 0x1eeb,
- 0x1eed, 0x1eed,
- 0x1eef, 0x1eef,
- 0x1ef1, 0x1ef1,
- 0x1ef3, 0x1ef3,
- 0x1ef5, 0x1ef5,
- 0x1ef7, 0x1ef7,
- 0x1ef9, 0x1ef9,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 0x1f07,
- 0x1f10, 0x1f15,
- 0x1f20, 0x1f27,
- 0x1f30, 0x1f37,
- 0x1f40, 0x1f45,
- 0x1f50, 0x1f57,
- 0x1f60, 0x1f67,
- 0x1f70, 0x1f7d,
- 0x1f80, 0x1f87,
- 0x1f90, 0x1f97,
- 0x1fa0, 0x1fa7,
- 0x1fb0, 0x1fb4,
- 0x1fb6, 0x1fb7,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fc7,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fd7,
- 0x1fe0, 0x1fe7,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ff7,
- 0x210a, 0x210a,
- 0x210e, 0x210f,
- 0x2113, 0x2113,
- 0x212f, 0x212f,
- 0x2134, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213d,
- 0x2146, 0x2149,
- 0x214e, 0x214e,
- 0x2184, 0x2184,
- 0x2c30, 0x2c5e,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c71, 0x2c71,
- 0x2c73, 0x2c74,
- 0x2c76, 0x2c7b,
- 0x2c81, 0x2c81,
- 0x2c83, 0x2c83,
- 0x2c85, 0x2c85,
- 0x2c87, 0x2c87,
- 0x2c89, 0x2c89,
- 0x2c8b, 0x2c8b,
- 0x2c8d, 0x2c8d,
- 0x2c8f, 0x2c8f,
- 0x2c91, 0x2c91,
- 0x2c93, 0x2c93,
- 0x2c95, 0x2c95,
- 0x2c97, 0x2c97,
- 0x2c99, 0x2c99,
- 0x2c9b, 0x2c9b,
- 0x2c9d, 0x2c9d,
- 0x2c9f, 0x2c9f,
- 0x2ca1, 0x2ca1,
- 0x2ca3, 0x2ca3,
- 0x2ca5, 0x2ca5,
- 0x2ca7, 0x2ca7,
- 0x2ca9, 0x2ca9,
- 0x2cab, 0x2cab,
- 0x2cad, 0x2cad,
- 0x2caf, 0x2caf,
- 0x2cb1, 0x2cb1,
- 0x2cb3, 0x2cb3,
- 0x2cb5, 0x2cb5,
- 0x2cb7, 0x2cb7,
- 0x2cb9, 0x2cb9,
- 0x2cbb, 0x2cbb,
- 0x2cbd, 0x2cbd,
- 0x2cbf, 0x2cbf,
- 0x2cc1, 0x2cc1,
- 0x2cc3, 0x2cc3,
- 0x2cc5, 0x2cc5,
- 0x2cc7, 0x2cc7,
- 0x2cc9, 0x2cc9,
- 0x2ccb, 0x2ccb,
- 0x2ccd, 0x2ccd,
- 0x2ccf, 0x2ccf,
- 0x2cd1, 0x2cd1,
- 0x2cd3, 0x2cd3,
- 0x2cd5, 0x2cd5,
- 0x2cd7, 0x2cd7,
- 0x2cd9, 0x2cd9,
- 0x2cdb, 0x2cdb,
- 0x2cdd, 0x2cdd,
- 0x2cdf, 0x2cdf,
- 0x2ce1, 0x2ce1,
- 0x2ce3, 0x2ce4,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69b,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa731,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa76f,
- 0xa771, 0xa778,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa78e, 0xa78e,
- 0xa791, 0xa791,
- 0xa793, 0xa795,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7af, 0xa7af,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c3, 0xa7c3,
- 0xa7fa, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab60, 0xab67,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 0x1d41a, 0x1d433,
- 0x1d44e, 0x1d454,
- 0x1d456, 0x1d467,
- 0x1d482, 0x1d49b,
- 0x1d4b6, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d4cf,
- 0x1d4ea, 0x1d503,
- 0x1d51e, 0x1d537,
- 0x1d552, 0x1d56b,
- 0x1d586, 0x1d59f,
- 0x1d5ba, 0x1d5d3,
- 0x1d5ee, 0x1d607,
- 0x1d622, 0x1d63b,
- 0x1d656, 0x1d66f,
- 0x1d68a, 0x1d6a5,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6e1,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d71b,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d755,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d78f,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9,
- 0x1d7cb, 0x1d7cb,
- 0x1e922, 0x1e943,
-}; /* CR_Ll */
-
-/* 'Lm': General Category */
-static const OnigCodePoint CR_Lm[] = {
- 60,
- 0x02b0, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0374, 0x0374,
- 0x037a, 0x037a,
- 0x0559, 0x0559,
- 0x0640, 0x0640,
- 0x06e5, 0x06e6,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0971, 0x0971,
- 0x0e46, 0x0e46,
- 0x0ec6, 0x0ec6,
- 0x10fc, 0x10fc,
- 0x17d7, 0x17d7,
- 0x1843, 0x1843,
- 0x1aa7, 0x1aa7,
- 0x1c78, 0x1c7d,
- 0x1d2c, 0x1d6a,
- 0x1d78, 0x1d78,
- 0x1d9b, 0x1dbf,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2c7c, 0x2c7d,
- 0x2d6f, 0x2d6f,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3005,
- 0x3031, 0x3035,
- 0x303b, 0x303b,
- 0x309d, 0x309e,
- 0x30fc, 0x30fe,
- 0xa015, 0xa015,
- 0xa4f8, 0xa4fd,
- 0xa60c, 0xa60c,
- 0xa67f, 0xa67f,
- 0xa69c, 0xa69d,
- 0xa717, 0xa71f,
- 0xa770, 0xa770,
- 0xa788, 0xa788,
- 0xa7f8, 0xa7f9,
- 0xa9cf, 0xa9cf,
- 0xa9e6, 0xa9e6,
- 0xaa70, 0xaa70,
- 0xaadd, 0xaadd,
- 0xaaf3, 0xaaf4,
- 0xab5c, 0xab5f,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0x16b40, 0x16b43,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x1e137, 0x1e13d,
- 0x1e94b, 0x1e94b,
-}; /* CR_Lm */
-
-/* 'Lo': General Category */
-static const OnigCodePoint CR_Lo[] = {
- 476,
- 0x00aa, 0x00aa,
- 0x00ba, 0x00ba,
- 0x01bb, 0x01bb,
- 0x01c0, 0x01c3,
- 0x0294, 0x0294,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x063f,
- 0x0641, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x0800, 0x0815,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0972, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a72, 0x0a74,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0abd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0af9, 0x0af9,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b71, 0x0b71,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e45,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x1100, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16f1, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1711,
- 0x1720, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17dc, 0x17dc,
- 0x1820, 0x1842,
- 0x1844, 0x1878,
- 0x1880, 0x1884,
- 0x1887, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4b,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c77,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x2135, 0x2138,
- 0x2d30, 0x2d67,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3006, 0x3006,
- 0x303c, 0x303c,
- 0x3041, 0x3096,
- 0x309f, 0x309f,
- 0x30a1, 0x30fa,
- 0x30ff, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa014,
- 0xa016, 0xa48c,
- 0xa4d0, 0xa4f7,
- 0xa500, 0xa60b,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa66e, 0xa66e,
- 0xa6a0, 0xa6e5,
- 0xa78f, 0xa78f,
- 0xa7f7, 0xa7f7,
- 0xa7fb, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9e0, 0xa9e4,
- 0xa9e7, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa6f,
- 0xaa71, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadc,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf2,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff66, 0xff6f,
- 0xff71, 0xff9d,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x10340,
- 0x10342, 0x10349,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10450, 0x1049d,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10d00, 0x10d23,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x1145f,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11800, 0x1182b,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x12000, 0x12399,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1e100, 0x1e12c,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2eb,
- 0x1e800, 0x1e8c4,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_Lo */
-
-/* 'Lt': General Category */
-static const OnigCodePoint CR_Lt[] = {
- 10,
- 0x01c5, 0x01c5,
- 0x01c8, 0x01c8,
- 0x01cb, 0x01cb,
- 0x01f2, 0x01f2,
- 0x1f88, 0x1f8f,
- 0x1f98, 0x1f9f,
- 0x1fa8, 0x1faf,
- 0x1fbc, 0x1fbc,
- 0x1fcc, 0x1fcc,
- 0x1ffc, 0x1ffc,
-}; /* CR_Lt */
-
-/* 'Lu': General Category */
-static const OnigCodePoint CR_Lu[] = {
- 636,
- 0x0041, 0x005a,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00de,
- 0x0100, 0x0100,
- 0x0102, 0x0102,
- 0x0104, 0x0104,
- 0x0106, 0x0106,
- 0x0108, 0x0108,
- 0x010a, 0x010a,
- 0x010c, 0x010c,
- 0x010e, 0x010e,
- 0x0110, 0x0110,
- 0x0112, 0x0112,
- 0x0114, 0x0114,
- 0x0116, 0x0116,
- 0x0118, 0x0118,
- 0x011a, 0x011a,
- 0x011c, 0x011c,
- 0x011e, 0x011e,
- 0x0120, 0x0120,
- 0x0122, 0x0122,
- 0x0124, 0x0124,
- 0x0126, 0x0126,
- 0x0128, 0x0128,
- 0x012a, 0x012a,
- 0x012c, 0x012c,
- 0x012e, 0x012e,
- 0x0130, 0x0130,
- 0x0132, 0x0132,
- 0x0134, 0x0134,
- 0x0136, 0x0136,
- 0x0139, 0x0139,
- 0x013b, 0x013b,
- 0x013d, 0x013d,
- 0x013f, 0x013f,
- 0x0141, 0x0141,
- 0x0143, 0x0143,
- 0x0145, 0x0145,
- 0x0147, 0x0147,
- 0x014a, 0x014a,
- 0x014c, 0x014c,
- 0x014e, 0x014e,
- 0x0150, 0x0150,
- 0x0152, 0x0152,
- 0x0154, 0x0154,
- 0x0156, 0x0156,
- 0x0158, 0x0158,
- 0x015a, 0x015a,
- 0x015c, 0x015c,
- 0x015e, 0x015e,
- 0x0160, 0x0160,
- 0x0162, 0x0162,
- 0x0164, 0x0164,
- 0x0166, 0x0166,
- 0x0168, 0x0168,
- 0x016a, 0x016a,
- 0x016c, 0x016c,
- 0x016e, 0x016e,
- 0x0170, 0x0170,
- 0x0172, 0x0172,
- 0x0174, 0x0174,
- 0x0176, 0x0176,
- 0x0178, 0x0179,
- 0x017b, 0x017b,
- 0x017d, 0x017d,
- 0x0181, 0x0182,
- 0x0184, 0x0184,
- 0x0186, 0x0187,
- 0x0189, 0x018b,
- 0x018e, 0x0191,
- 0x0193, 0x0194,
- 0x0196, 0x0198,
- 0x019c, 0x019d,
- 0x019f, 0x01a0,
- 0x01a2, 0x01a2,
- 0x01a4, 0x01a4,
- 0x01a6, 0x01a7,
- 0x01a9, 0x01a9,
- 0x01ac, 0x01ac,
- 0x01ae, 0x01af,
- 0x01b1, 0x01b3,
- 0x01b5, 0x01b5,
- 0x01b7, 0x01b8,
- 0x01bc, 0x01bc,
- 0x01c4, 0x01c4,
- 0x01c7, 0x01c7,
- 0x01ca, 0x01ca,
- 0x01cd, 0x01cd,
- 0x01cf, 0x01cf,
- 0x01d1, 0x01d1,
- 0x01d3, 0x01d3,
- 0x01d5, 0x01d5,
- 0x01d7, 0x01d7,
- 0x01d9, 0x01d9,
- 0x01db, 0x01db,
- 0x01de, 0x01de,
- 0x01e0, 0x01e0,
- 0x01e2, 0x01e2,
- 0x01e4, 0x01e4,
- 0x01e6, 0x01e6,
- 0x01e8, 0x01e8,
- 0x01ea, 0x01ea,
- 0x01ec, 0x01ec,
- 0x01ee, 0x01ee,
- 0x01f1, 0x01f1,
- 0x01f4, 0x01f4,
- 0x01f6, 0x01f8,
- 0x01fa, 0x01fa,
- 0x01fc, 0x01fc,
- 0x01fe, 0x01fe,
- 0x0200, 0x0200,
- 0x0202, 0x0202,
- 0x0204, 0x0204,
- 0x0206, 0x0206,
- 0x0208, 0x0208,
- 0x020a, 0x020a,
- 0x020c, 0x020c,
- 0x020e, 0x020e,
- 0x0210, 0x0210,
- 0x0212, 0x0212,
- 0x0214, 0x0214,
- 0x0216, 0x0216,
- 0x0218, 0x0218,
- 0x021a, 0x021a,
- 0x021c, 0x021c,
- 0x021e, 0x021e,
- 0x0220, 0x0220,
- 0x0222, 0x0222,
- 0x0224, 0x0224,
- 0x0226, 0x0226,
- 0x0228, 0x0228,
- 0x022a, 0x022a,
- 0x022c, 0x022c,
- 0x022e, 0x022e,
- 0x0230, 0x0230,
- 0x0232, 0x0232,
- 0x023a, 0x023b,
- 0x023d, 0x023e,
- 0x0241, 0x0241,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03cf, 0x03cf,
- 0x03d2, 0x03d4,
- 0x03d8, 0x03d8,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03e2,
- 0x03e4, 0x03e4,
- 0x03e6, 0x03e6,
- 0x03e8, 0x03e8,
- 0x03ea, 0x03ea,
- 0x03ec, 0x03ec,
- 0x03ee, 0x03ee,
- 0x03f4, 0x03f4,
- 0x03f7, 0x03f7,
- 0x03f9, 0x03fa,
- 0x03fd, 0x042f,
- 0x0460, 0x0460,
- 0x0462, 0x0462,
- 0x0464, 0x0464,
- 0x0466, 0x0466,
- 0x0468, 0x0468,
- 0x046a, 0x046a,
- 0x046c, 0x046c,
- 0x046e, 0x046e,
- 0x0470, 0x0470,
- 0x0472, 0x0472,
- 0x0474, 0x0474,
- 0x0476, 0x0476,
- 0x0478, 0x0478,
- 0x047a, 0x047a,
- 0x047c, 0x047c,
- 0x047e, 0x047e,
- 0x0480, 0x0480,
- 0x048a, 0x048a,
- 0x048c, 0x048c,
- 0x048e, 0x048e,
- 0x0490, 0x0490,
- 0x0492, 0x0492,
- 0x0494, 0x0494,
- 0x0496, 0x0496,
- 0x0498, 0x0498,
- 0x049a, 0x049a,
- 0x049c, 0x049c,
- 0x049e, 0x049e,
- 0x04a0, 0x04a0,
- 0x04a2, 0x04a2,
- 0x04a4, 0x04a4,
- 0x04a6, 0x04a6,
- 0x04a8, 0x04a8,
- 0x04aa, 0x04aa,
- 0x04ac, 0x04ac,
- 0x04ae, 0x04ae,
- 0x04b0, 0x04b0,
- 0x04b2, 0x04b2,
- 0x04b4, 0x04b4,
- 0x04b6, 0x04b6,
- 0x04b8, 0x04b8,
- 0x04ba, 0x04ba,
- 0x04bc, 0x04bc,
- 0x04be, 0x04be,
- 0x04c0, 0x04c1,
- 0x04c3, 0x04c3,
- 0x04c5, 0x04c5,
- 0x04c7, 0x04c7,
- 0x04c9, 0x04c9,
- 0x04cb, 0x04cb,
- 0x04cd, 0x04cd,
- 0x04d0, 0x04d0,
- 0x04d2, 0x04d2,
- 0x04d4, 0x04d4,
- 0x04d6, 0x04d6,
- 0x04d8, 0x04d8,
- 0x04da, 0x04da,
- 0x04dc, 0x04dc,
- 0x04de, 0x04de,
- 0x04e0, 0x04e0,
- 0x04e2, 0x04e2,
- 0x04e4, 0x04e4,
- 0x04e6, 0x04e6,
- 0x04e8, 0x04e8,
- 0x04ea, 0x04ea,
- 0x04ec, 0x04ec,
- 0x04ee, 0x04ee,
- 0x04f0, 0x04f0,
- 0x04f2, 0x04f2,
- 0x04f4, 0x04f4,
- 0x04f6, 0x04f6,
- 0x04f8, 0x04f8,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13a0, 0x13f5,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1e00, 0x1e00,
- 0x1e02, 0x1e02,
- 0x1e04, 0x1e04,
- 0x1e06, 0x1e06,
- 0x1e08, 0x1e08,
- 0x1e0a, 0x1e0a,
- 0x1e0c, 0x1e0c,
- 0x1e0e, 0x1e0e,
- 0x1e10, 0x1e10,
- 0x1e12, 0x1e12,
- 0x1e14, 0x1e14,
- 0x1e16, 0x1e16,
- 0x1e18, 0x1e18,
- 0x1e1a, 0x1e1a,
- 0x1e1c, 0x1e1c,
- 0x1e1e, 0x1e1e,
- 0x1e20, 0x1e20,
- 0x1e22, 0x1e22,
- 0x1e24, 0x1e24,
- 0x1e26, 0x1e26,
- 0x1e28, 0x1e28,
- 0x1e2a, 0x1e2a,
- 0x1e2c, 0x1e2c,
- 0x1e2e, 0x1e2e,
- 0x1e30, 0x1e30,
- 0x1e32, 0x1e32,
- 0x1e34, 0x1e34,
- 0x1e36, 0x1e36,
- 0x1e38, 0x1e38,
- 0x1e3a, 0x1e3a,
- 0x1e3c, 0x1e3c,
- 0x1e3e, 0x1e3e,
- 0x1e40, 0x1e40,
- 0x1e42, 0x1e42,
- 0x1e44, 0x1e44,
- 0x1e46, 0x1e46,
- 0x1e48, 0x1e48,
- 0x1e4a, 0x1e4a,
- 0x1e4c, 0x1e4c,
- 0x1e4e, 0x1e4e,
- 0x1e50, 0x1e50,
- 0x1e52, 0x1e52,
- 0x1e54, 0x1e54,
- 0x1e56, 0x1e56,
- 0x1e58, 0x1e58,
- 0x1e5a, 0x1e5a,
- 0x1e5c, 0x1e5c,
- 0x1e5e, 0x1e5e,
- 0x1e60, 0x1e60,
- 0x1e62, 0x1e62,
- 0x1e64, 0x1e64,
- 0x1e66, 0x1e66,
- 0x1e68, 0x1e68,
- 0x1e6a, 0x1e6a,
- 0x1e6c, 0x1e6c,
- 0x1e6e, 0x1e6e,
- 0x1e70, 0x1e70,
- 0x1e72, 0x1e72,
- 0x1e74, 0x1e74,
- 0x1e76, 0x1e76,
- 0x1e78, 0x1e78,
- 0x1e7a, 0x1e7a,
- 0x1e7c, 0x1e7c,
- 0x1e7e, 0x1e7e,
- 0x1e80, 0x1e80,
- 0x1e82, 0x1e82,
- 0x1e84, 0x1e84,
- 0x1e86, 0x1e86,
- 0x1e88, 0x1e88,
- 0x1e8a, 0x1e8a,
- 0x1e8c, 0x1e8c,
- 0x1e8e, 0x1e8e,
- 0x1e90, 0x1e90,
- 0x1e92, 0x1e92,
- 0x1e94, 0x1e94,
- 0x1e9e, 0x1e9e,
- 0x1ea0, 0x1ea0,
- 0x1ea2, 0x1ea2,
- 0x1ea4, 0x1ea4,
- 0x1ea6, 0x1ea6,
- 0x1ea8, 0x1ea8,
- 0x1eaa, 0x1eaa,
- 0x1eac, 0x1eac,
- 0x1eae, 0x1eae,
- 0x1eb0, 0x1eb0,
- 0x1eb2, 0x1eb2,
- 0x1eb4, 0x1eb4,
- 0x1eb6, 0x1eb6,
- 0x1eb8, 0x1eb8,
- 0x1eba, 0x1eba,
- 0x1ebc, 0x1ebc,
- 0x1ebe, 0x1ebe,
- 0x1ec0, 0x1ec0,
- 0x1ec2, 0x1ec2,
- 0x1ec4, 0x1ec4,
- 0x1ec6, 0x1ec6,
- 0x1ec8, 0x1ec8,
- 0x1eca, 0x1eca,
- 0x1ecc, 0x1ecc,
- 0x1ece, 0x1ece,
- 0x1ed0, 0x1ed0,
- 0x1ed2, 0x1ed2,
- 0x1ed4, 0x1ed4,
- 0x1ed6, 0x1ed6,
- 0x1ed8, 0x1ed8,
- 0x1eda, 0x1eda,
- 0x1edc, 0x1edc,
- 0x1ede, 0x1ede,
- 0x1ee0, 0x1ee0,
- 0x1ee2, 0x1ee2,
- 0x1ee4, 0x1ee4,
- 0x1ee6, 0x1ee6,
- 0x1ee8, 0x1ee8,
- 0x1eea, 0x1eea,
- 0x1eec, 0x1eec,
- 0x1eee, 0x1eee,
- 0x1ef0, 0x1ef0,
- 0x1ef2, 0x1ef2,
- 0x1ef4, 0x1ef4,
- 0x1ef6, 0x1ef6,
- 0x1ef8, 0x1ef8,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1fb8, 0x1fbb,
- 0x1fc8, 0x1fcb,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff8, 0x1ffb,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210b, 0x210d,
- 0x2110, 0x2112,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x2130, 0x2133,
- 0x213e, 0x213f,
- 0x2145, 0x2145,
- 0x2183, 0x2183,
- 0x2c00, 0x2c2e,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 0x2c80,
- 0x2c82, 0x2c82,
- 0x2c84, 0x2c84,
- 0x2c86, 0x2c86,
- 0x2c88, 0x2c88,
- 0x2c8a, 0x2c8a,
- 0x2c8c, 0x2c8c,
- 0x2c8e, 0x2c8e,
- 0x2c90, 0x2c90,
- 0x2c92, 0x2c92,
- 0x2c94, 0x2c94,
- 0x2c96, 0x2c96,
- 0x2c98, 0x2c98,
- 0x2c9a, 0x2c9a,
- 0x2c9c, 0x2c9c,
- 0x2c9e, 0x2c9e,
- 0x2ca0, 0x2ca0,
- 0x2ca2, 0x2ca2,
- 0x2ca4, 0x2ca4,
- 0x2ca6, 0x2ca6,
- 0x2ca8, 0x2ca8,
- 0x2caa, 0x2caa,
- 0x2cac, 0x2cac,
- 0x2cae, 0x2cae,
- 0x2cb0, 0x2cb0,
- 0x2cb2, 0x2cb2,
- 0x2cb4, 0x2cb4,
- 0x2cb6, 0x2cb6,
- 0x2cb8, 0x2cb8,
- 0x2cba, 0x2cba,
- 0x2cbc, 0x2cbc,
- 0x2cbe, 0x2cbe,
- 0x2cc0, 0x2cc0,
- 0x2cc2, 0x2cc2,
- 0x2cc4, 0x2cc4,
- 0x2cc6, 0x2cc6,
- 0x2cc8, 0x2cc8,
- 0x2cca, 0x2cca,
- 0x2ccc, 0x2ccc,
- 0x2cce, 0x2cce,
- 0x2cd0, 0x2cd0,
- 0x2cd2, 0x2cd2,
- 0x2cd4, 0x2cd4,
- 0x2cd6, 0x2cd6,
- 0x2cd8, 0x2cd8,
- 0x2cda, 0x2cda,
- 0x2cdc, 0x2cdc,
- 0x2cde, 0x2cde,
- 0x2ce0, 0x2ce0,
- 0x2ce2, 0x2ce2,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c6,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 0x1d400, 0x1d419,
- 0x1d434, 0x1d44d,
- 0x1d468, 0x1d481,
- 0x1d49c, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b5,
- 0x1d4d0, 0x1d4e9,
- 0x1d504, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d538, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d56c, 0x1d585,
- 0x1d5a0, 0x1d5b9,
- 0x1d5d4, 0x1d5ed,
- 0x1d608, 0x1d621,
- 0x1d63c, 0x1d655,
- 0x1d670, 0x1d689,
- 0x1d6a8, 0x1d6c0,
- 0x1d6e2, 0x1d6fa,
- 0x1d71c, 0x1d734,
- 0x1d756, 0x1d76e,
- 0x1d790, 0x1d7a8,
- 0x1d7ca, 0x1d7ca,
- 0x1e900, 0x1e921,
-}; /* CR_Lu */
-
-/* 'M': Major Category */
-static const OnigCodePoint CR_M[] = {
- 280,
- 0x0300, 0x036f,
- 0x0483, 0x0489,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x08d3, 0x08e1,
- 0x08e3, 0x0903,
- 0x093a, 0x093c,
- 0x093e, 0x094f,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0983,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0abc, 0x0abc,
- 0x0abe, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b3c, 0x0b3c,
- 0x0b3e, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c04,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c83,
- 0x0cbc, 0x0cbc,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d03,
- 0x0d3b, 0x0d3c,
- 0x0d3e, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0d82, 0x0d83,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ecd,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f3f,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102b, 0x103e,
- 0x1056, 0x1059,
- 0x105e, 0x1060,
- 0x1062, 0x1064,
- 0x1067, 0x106d,
- 0x1071, 0x1074,
- 0x1082, 0x108d,
- 0x108f, 0x108f,
- 0x109a, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1a17, 0x1a1b,
- 0x1a55, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b04,
- 0x1b34, 0x1b44,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b82,
- 0x1ba1, 0x1bad,
- 0x1be6, 0x1bf3,
- 0x1c24, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf7, 0x1cf9,
- 0x1dc0, 0x1df9,
- 0x1dfb, 0x1dff,
- 0x20d0, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa823, 0xa827,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa953,
- 0xa980, 0xa983,
- 0xa9b3, 0xa9c0,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4d,
- 0xaa7b, 0xaa7d,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaeb, 0xaaef,
- 0xaaf5, 0xaaf6,
- 0xabe3, 0xabea,
- 0xabec, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10f46, 0x10f50,
- 0x11000, 0x11002,
- 0x11038, 0x11046,
- 0x1107f, 0x11082,
- 0x110b0, 0x110ba,
- 0x11100, 0x11102,
- 0x11127, 0x11134,
- 0x11145, 0x11146,
- 0x11173, 0x11173,
- 0x11180, 0x11182,
- 0x111b3, 0x111c0,
- 0x111c9, 0x111cc,
- 0x1122c, 0x11237,
- 0x1123e, 0x1123e,
- 0x112df, 0x112ea,
- 0x11300, 0x11303,
- 0x1133b, 0x1133c,
- 0x1133e, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11357, 0x11357,
- 0x11362, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11435, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b0, 0x114c3,
- 0x115af, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11630, 0x11640,
- 0x116ab, 0x116b7,
- 0x1171d, 0x1172b,
- 0x1182c, 0x1183a,
- 0x119d1, 0x119d7,
- 0x119da, 0x119e0,
- 0x119e4, 0x119e4,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a39,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a5b,
- 0x11a8a, 0x11a99,
- 0x11c2f, 0x11c36,
- 0x11c38, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d8a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d97,
- 0x11ef3, 0x11ef6,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f51, 0x16f87,
- 0x16f8f, 0x16f92,
- 0x1bc9d, 0x1bc9e,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e130, 0x1e136,
- 0x1e2ec, 0x1e2ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0xe0100, 0xe01ef,
-}; /* CR_M */
-
-/* 'Mc': General Category */
-static const OnigCodePoint CR_Mc[] = {
- 168,
- 0x0903, 0x0903,
- 0x093b, 0x093b,
- 0x093e, 0x0940,
- 0x0949, 0x094c,
- 0x094e, 0x094f,
- 0x0982, 0x0983,
- 0x09be, 0x09c0,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09d7, 0x09d7,
- 0x0a03, 0x0a03,
- 0x0a3e, 0x0a40,
- 0x0a83, 0x0a83,
- 0x0abe, 0x0ac0,
- 0x0ac9, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0b02, 0x0b03,
- 0x0b3e, 0x0b3e,
- 0x0b40, 0x0b40,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b57, 0x0b57,
- 0x0bbe, 0x0bbf,
- 0x0bc1, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd7, 0x0bd7,
- 0x0c01, 0x0c03,
- 0x0c41, 0x0c44,
- 0x0c82, 0x0c83,
- 0x0cbe, 0x0cbe,
- 0x0cc0, 0x0cc4,
- 0x0cc7, 0x0cc8,
- 0x0cca, 0x0ccb,
- 0x0cd5, 0x0cd6,
- 0x0d02, 0x0d03,
- 0x0d3e, 0x0d40,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d57, 0x0d57,
- 0x0d82, 0x0d83,
- 0x0dcf, 0x0dd1,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0f3e, 0x0f3f,
- 0x0f7f, 0x0f7f,
- 0x102b, 0x102c,
- 0x1031, 0x1031,
- 0x1038, 0x1038,
- 0x103b, 0x103c,
- 0x1056, 0x1057,
- 0x1062, 0x1064,
- 0x1067, 0x106d,
- 0x1083, 0x1084,
- 0x1087, 0x108c,
- 0x108f, 0x108f,
- 0x109a, 0x109c,
- 0x17b6, 0x17b6,
- 0x17be, 0x17c5,
- 0x17c7, 0x17c8,
- 0x1923, 0x1926,
- 0x1929, 0x192b,
- 0x1930, 0x1931,
- 0x1933, 0x1938,
- 0x1a19, 0x1a1a,
- 0x1a55, 0x1a55,
- 0x1a57, 0x1a57,
- 0x1a61, 0x1a61,
- 0x1a63, 0x1a64,
- 0x1a6d, 0x1a72,
- 0x1b04, 0x1b04,
- 0x1b35, 0x1b35,
- 0x1b3b, 0x1b3b,
- 0x1b3d, 0x1b41,
- 0x1b43, 0x1b44,
- 0x1b82, 0x1b82,
- 0x1ba1, 0x1ba1,
- 0x1ba6, 0x1ba7,
- 0x1baa, 0x1baa,
- 0x1be7, 0x1be7,
- 0x1bea, 0x1bec,
- 0x1bee, 0x1bee,
- 0x1bf2, 0x1bf3,
- 0x1c24, 0x1c2b,
- 0x1c34, 0x1c35,
- 0x1ce1, 0x1ce1,
- 0x1cf7, 0x1cf7,
- 0x302e, 0x302f,
- 0xa823, 0xa824,
- 0xa827, 0xa827,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c3,
- 0xa952, 0xa953,
- 0xa983, 0xa983,
- 0xa9b4, 0xa9b5,
- 0xa9ba, 0xa9bb,
- 0xa9be, 0xa9c0,
- 0xaa2f, 0xaa30,
- 0xaa33, 0xaa34,
- 0xaa4d, 0xaa4d,
- 0xaa7b, 0xaa7b,
- 0xaa7d, 0xaa7d,
- 0xaaeb, 0xaaeb,
- 0xaaee, 0xaaef,
- 0xaaf5, 0xaaf5,
- 0xabe3, 0xabe4,
- 0xabe6, 0xabe7,
- 0xabe9, 0xabea,
- 0xabec, 0xabec,
- 0x11000, 0x11000,
- 0x11002, 0x11002,
- 0x11082, 0x11082,
- 0x110b0, 0x110b2,
- 0x110b7, 0x110b8,
- 0x1112c, 0x1112c,
- 0x11145, 0x11146,
- 0x11182, 0x11182,
- 0x111b3, 0x111b5,
- 0x111bf, 0x111c0,
- 0x1122c, 0x1122e,
- 0x11232, 0x11233,
- 0x11235, 0x11235,
- 0x112e0, 0x112e2,
- 0x11302, 0x11303,
- 0x1133e, 0x1133f,
- 0x11341, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11357, 0x11357,
- 0x11362, 0x11363,
- 0x11435, 0x11437,
- 0x11440, 0x11441,
- 0x11445, 0x11445,
- 0x114b0, 0x114b2,
- 0x114b9, 0x114b9,
- 0x114bb, 0x114be,
- 0x114c1, 0x114c1,
- 0x115af, 0x115b1,
- 0x115b8, 0x115bb,
- 0x115be, 0x115be,
- 0x11630, 0x11632,
- 0x1163b, 0x1163c,
- 0x1163e, 0x1163e,
- 0x116ac, 0x116ac,
- 0x116ae, 0x116af,
- 0x116b6, 0x116b6,
- 0x11720, 0x11721,
- 0x11726, 0x11726,
- 0x1182c, 0x1182e,
- 0x11838, 0x11838,
- 0x119d1, 0x119d3,
- 0x119dc, 0x119df,
- 0x119e4, 0x119e4,
- 0x11a39, 0x11a39,
- 0x11a57, 0x11a58,
- 0x11a97, 0x11a97,
- 0x11c2f, 0x11c2f,
- 0x11c3e, 0x11c3e,
- 0x11ca9, 0x11ca9,
- 0x11cb1, 0x11cb1,
- 0x11cb4, 0x11cb4,
- 0x11d8a, 0x11d8e,
- 0x11d93, 0x11d94,
- 0x11d96, 0x11d96,
- 0x11ef5, 0x11ef6,
- 0x16f51, 0x16f87,
- 0x1d165, 0x1d166,
- 0x1d16d, 0x1d172,
-}; /* CR_Mc */
-
-/* 'Me': General Category */
-static const OnigCodePoint CR_Me[] = {
- 5,
- 0x0488, 0x0489,
- 0x1abe, 0x1abe,
- 0x20dd, 0x20e0,
- 0x20e2, 0x20e4,
- 0xa670, 0xa672,
-}; /* CR_Me */
-
-/* 'Mn': General Category */
-static const OnigCodePoint CR_Mn[] = {
- 318,
- 0x0300, 0x036f,
- 0x0483, 0x0487,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x08d3, 0x08e1,
- 0x08e3, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3f, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b56, 0x0b56,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d62, 0x0d63,
- 0x0dca, 0x0dca,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ecd,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1abd,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b34,
- 0x1b36, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1df9,
- 0x1dfb, 0x1dff,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302d,
- 0x3099, 0x309a,
- 0xa66f, 0xa66f,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaec, 0xaaed,
- 0xaaf6, 0xaaf6,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10f46, 0x10f50,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x11340, 0x11340,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f92,
- 0x1bc9d, 0x1bc9e,
- 0x1d167, 0x1d169,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e130, 0x1e136,
- 0x1e2ec, 0x1e2ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0xe0100, 0xe01ef,
-}; /* CR_Mn */
-
-/* 'N': Major Category */
-static const OnigCodePoint CR_N[] = {
- 130,
- 0x0030, 0x0039,
- 0x00b2, 0x00b3,
- 0x00b9, 0x00b9,
- 0x00bc, 0x00be,
- 0x0660, 0x0669,
- 0x06f0, 0x06f9,
- 0x07c0, 0x07c9,
- 0x0966, 0x096f,
- 0x09e6, 0x09ef,
- 0x09f4, 0x09f9,
- 0x0a66, 0x0a6f,
- 0x0ae6, 0x0aef,
- 0x0b66, 0x0b6f,
- 0x0b72, 0x0b77,
- 0x0be6, 0x0bf2,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7e,
- 0x0ce6, 0x0cef,
- 0x0d58, 0x0d5e,
- 0x0d66, 0x0d78,
- 0x0de6, 0x0def,
- 0x0e50, 0x0e59,
- 0x0ed0, 0x0ed9,
- 0x0f20, 0x0f33,
- 0x1040, 0x1049,
- 0x1090, 0x1099,
- 0x1369, 0x137c,
- 0x16ee, 0x16f0,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1810, 0x1819,
- 0x1946, 0x194f,
- 0x19d0, 0x19da,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1b50, 0x1b59,
- 0x1bb0, 0x1bb9,
- 0x1c40, 0x1c49,
- 0x1c50, 0x1c59,
- 0x2070, 0x2070,
- 0x2074, 0x2079,
- 0x2080, 0x2089,
- 0x2150, 0x2182,
- 0x2185, 0x2189,
- 0x2460, 0x249b,
- 0x24ea, 0x24ff,
- 0x2776, 0x2793,
- 0x2cfd, 0x2cfd,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0x3192, 0x3195,
- 0x3220, 0x3229,
- 0x3248, 0x324f,
- 0x3251, 0x325f,
- 0x3280, 0x3289,
- 0x32b1, 0x32bf,
- 0xa620, 0xa629,
- 0xa6e6, 0xa6ef,
- 0xa830, 0xa835,
- 0xa8d0, 0xa8d9,
- 0xa900, 0xa909,
- 0xa9d0, 0xa9d9,
- 0xa9f0, 0xa9f9,
- 0xaa50, 0xaa59,
- 0xabf0, 0xabf9,
- 0xff10, 0xff19,
- 0x10107, 0x10133,
- 0x10140, 0x10178,
- 0x1018a, 0x1018b,
- 0x102e1, 0x102fb,
- 0x10320, 0x10323,
- 0x10341, 0x10341,
- 0x1034a, 0x1034a,
- 0x103d1, 0x103d5,
- 0x104a0, 0x104a9,
- 0x10858, 0x1085f,
- 0x10879, 0x1087f,
- 0x108a7, 0x108af,
- 0x108fb, 0x108ff,
- 0x10916, 0x1091b,
- 0x109bc, 0x109bd,
- 0x109c0, 0x109cf,
- 0x109d2, 0x109ff,
- 0x10a40, 0x10a48,
- 0x10a7d, 0x10a7e,
- 0x10a9d, 0x10a9f,
- 0x10aeb, 0x10aef,
- 0x10b58, 0x10b5f,
- 0x10b78, 0x10b7f,
- 0x10ba9, 0x10baf,
- 0x10cfa, 0x10cff,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f1d, 0x10f26,
- 0x10f51, 0x10f54,
- 0x11052, 0x1106f,
- 0x110f0, 0x110f9,
- 0x11136, 0x1113f,
- 0x111d0, 0x111d9,
- 0x111e1, 0x111f4,
- 0x112f0, 0x112f9,
- 0x11450, 0x11459,
- 0x114d0, 0x114d9,
- 0x11650, 0x11659,
- 0x116c0, 0x116c9,
- 0x11730, 0x1173b,
- 0x118e0, 0x118f2,
- 0x11c50, 0x11c6c,
- 0x11d50, 0x11d59,
- 0x11da0, 0x11da9,
- 0x11fc0, 0x11fd4,
- 0x12400, 0x1246e,
- 0x16a60, 0x16a69,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16e80, 0x16e96,
- 0x1d2e0, 0x1d2f3,
- 0x1d360, 0x1d378,
- 0x1d7ce, 0x1d7ff,
- 0x1e140, 0x1e149,
- 0x1e2f0, 0x1e2f9,
- 0x1e8c7, 0x1e8cf,
- 0x1e950, 0x1e959,
- 0x1ec71, 0x1ecab,
- 0x1ecad, 0x1ecaf,
- 0x1ecb1, 0x1ecb4,
- 0x1ed01, 0x1ed2d,
- 0x1ed2f, 0x1ed3d,
- 0x1f100, 0x1f10c,
-}; /* CR_N */
-
-/* 'Nd': General Category */
-#define CR_Nd CR_Digit
-
-/* 'Nl': General Category */
-static const OnigCodePoint CR_Nl[] = {
- 12,
- 0x16ee, 0x16f0,
- 0x2160, 0x2182,
- 0x2185, 0x2188,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0xa6e6, 0xa6ef,
- 0x10140, 0x10174,
- 0x10341, 0x10341,
- 0x1034a, 0x1034a,
- 0x103d1, 0x103d5,
- 0x12400, 0x1246e,
-}; /* CR_Nl */
-
-/* 'No': General Category */
-static const OnigCodePoint CR_No[] = {
- 70,
- 0x00b2, 0x00b3,
- 0x00b9, 0x00b9,
- 0x00bc, 0x00be,
- 0x09f4, 0x09f9,
- 0x0b72, 0x0b77,
- 0x0bf0, 0x0bf2,
- 0x0c78, 0x0c7e,
- 0x0d58, 0x0d5e,
- 0x0d70, 0x0d78,
- 0x0f2a, 0x0f33,
- 0x1369, 0x137c,
- 0x17f0, 0x17f9,
- 0x19da, 0x19da,
- 0x2070, 0x2070,
- 0x2074, 0x2079,
- 0x2080, 0x2089,
- 0x2150, 0x215f,
- 0x2189, 0x2189,
- 0x2460, 0x249b,
- 0x24ea, 0x24ff,
- 0x2776, 0x2793,
- 0x2cfd, 0x2cfd,
- 0x3192, 0x3195,
- 0x3220, 0x3229,
- 0x3248, 0x324f,
- 0x3251, 0x325f,
- 0x3280, 0x3289,
- 0x32b1, 0x32bf,
- 0xa830, 0xa835,
- 0x10107, 0x10133,
- 0x10175, 0x10178,
- 0x1018a, 0x1018b,
- 0x102e1, 0x102fb,
- 0x10320, 0x10323,
- 0x10858, 0x1085f,
- 0x10879, 0x1087f,
- 0x108a7, 0x108af,
- 0x108fb, 0x108ff,
- 0x10916, 0x1091b,
- 0x109bc, 0x109bd,
- 0x109c0, 0x109cf,
- 0x109d2, 0x109ff,
- 0x10a40, 0x10a48,
- 0x10a7d, 0x10a7e,
- 0x10a9d, 0x10a9f,
- 0x10aeb, 0x10aef,
- 0x10b58, 0x10b5f,
- 0x10b78, 0x10b7f,
- 0x10ba9, 0x10baf,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x10f1d, 0x10f26,
- 0x10f51, 0x10f54,
- 0x11052, 0x11065,
- 0x111e1, 0x111f4,
- 0x1173a, 0x1173b,
- 0x118ea, 0x118f2,
- 0x11c5a, 0x11c6c,
- 0x11fc0, 0x11fd4,
- 0x16b5b, 0x16b61,
- 0x16e80, 0x16e96,
- 0x1d2e0, 0x1d2f3,
- 0x1d360, 0x1d378,
- 0x1e8c7, 0x1e8cf,
- 0x1ec71, 0x1ecab,
- 0x1ecad, 0x1ecaf,
- 0x1ecb1, 0x1ecb4,
- 0x1ed01, 0x1ed2d,
- 0x1ed2f, 0x1ed3d,
- 0x1f100, 0x1f10c,
-}; /* CR_No */
-
-/* 'P': Major Category */
-#define CR_P CR_Punct
-
-/* 'Pc': General Category */
-static const OnigCodePoint CR_Pc[] = {
- 6,
- 0x005f, 0x005f,
- 0x203f, 0x2040,
- 0x2054, 0x2054,
- 0xfe33, 0xfe34,
- 0xfe4d, 0xfe4f,
- 0xff3f, 0xff3f,
-}; /* CR_Pc */
-
-/* 'Pd': General Category */
-static const OnigCodePoint CR_Pd[] = {
- 17,
- 0x002d, 0x002d,
- 0x058a, 0x058a,
- 0x05be, 0x05be,
- 0x1400, 0x1400,
- 0x1806, 0x1806,
- 0x2010, 0x2015,
- 0x2e17, 0x2e17,
- 0x2e1a, 0x2e1a,
- 0x2e3a, 0x2e3b,
- 0x2e40, 0x2e40,
- 0x301c, 0x301c,
- 0x3030, 0x3030,
- 0x30a0, 0x30a0,
- 0xfe31, 0xfe32,
- 0xfe58, 0xfe58,
- 0xfe63, 0xfe63,
- 0xff0d, 0xff0d,
-}; /* CR_Pd */
-
-/* 'Pe': General Category */
-static const OnigCodePoint CR_Pe[] = {
- 72,
- 0x0029, 0x0029,
- 0x005d, 0x005d,
- 0x007d, 0x007d,
- 0x0f3b, 0x0f3b,
- 0x0f3d, 0x0f3d,
- 0x169c, 0x169c,
- 0x2046, 0x2046,
- 0x207e, 0x207e,
- 0x208e, 0x208e,
- 0x2309, 0x2309,
- 0x230b, 0x230b,
- 0x232a, 0x232a,
- 0x2769, 0x2769,
- 0x276b, 0x276b,
- 0x276d, 0x276d,
- 0x276f, 0x276f,
- 0x2771, 0x2771,
- 0x2773, 0x2773,
- 0x2775, 0x2775,
- 0x27c6, 0x27c6,
- 0x27e7, 0x27e7,
- 0x27e9, 0x27e9,
- 0x27eb, 0x27eb,
- 0x27ed, 0x27ed,
- 0x27ef, 0x27ef,
- 0x2984, 0x2984,
- 0x2986, 0x2986,
- 0x2988, 0x2988,
- 0x298a, 0x298a,
- 0x298c, 0x298c,
- 0x298e, 0x298e,
- 0x2990, 0x2990,
- 0x2992, 0x2992,
- 0x2994, 0x2994,
- 0x2996, 0x2996,
- 0x2998, 0x2998,
- 0x29d9, 0x29d9,
- 0x29db, 0x29db,
- 0x29fd, 0x29fd,
- 0x2e23, 0x2e23,
- 0x2e25, 0x2e25,
- 0x2e27, 0x2e27,
- 0x2e29, 0x2e29,
- 0x3009, 0x3009,
- 0x300b, 0x300b,
- 0x300d, 0x300d,
- 0x300f, 0x300f,
- 0x3011, 0x3011,
- 0x3015, 0x3015,
- 0x3017, 0x3017,
- 0x3019, 0x3019,
- 0x301b, 0x301b,
- 0x301e, 0x301f,
- 0xfd3e, 0xfd3e,
- 0xfe18, 0xfe18,
- 0xfe36, 0xfe36,
- 0xfe38, 0xfe38,
- 0xfe3a, 0xfe3a,
- 0xfe3c, 0xfe3c,
- 0xfe3e, 0xfe3e,
- 0xfe40, 0xfe40,
- 0xfe42, 0xfe42,
- 0xfe44, 0xfe44,
- 0xfe48, 0xfe48,
- 0xfe5a, 0xfe5a,
- 0xfe5c, 0xfe5c,
- 0xfe5e, 0xfe5e,
- 0xff09, 0xff09,
- 0xff3d, 0xff3d,
- 0xff5d, 0xff5d,
- 0xff60, 0xff60,
- 0xff63, 0xff63,
-}; /* CR_Pe */
-
-/* 'Pf': General Category */
-static const OnigCodePoint CR_Pf[] = {
- 10,
- 0x00bb, 0x00bb,
- 0x2019, 0x2019,
- 0x201d, 0x201d,
- 0x203a, 0x203a,
- 0x2e03, 0x2e03,
- 0x2e05, 0x2e05,
- 0x2e0a, 0x2e0a,
- 0x2e0d, 0x2e0d,
- 0x2e1d, 0x2e1d,
- 0x2e21, 0x2e21,
-}; /* CR_Pf */
-
-/* 'Pi': General Category */
-static const OnigCodePoint CR_Pi[] = {
- 11,
- 0x00ab, 0x00ab,
- 0x2018, 0x2018,
- 0x201b, 0x201c,
- 0x201f, 0x201f,
- 0x2039, 0x2039,
- 0x2e02, 0x2e02,
- 0x2e04, 0x2e04,
- 0x2e09, 0x2e09,
- 0x2e0c, 0x2e0c,
- 0x2e1c, 0x2e1c,
- 0x2e20, 0x2e20,
-}; /* CR_Pi */
-
-/* 'Po': General Category */
-static const OnigCodePoint CR_Po[] = {
- 179,
- 0x0021, 0x0023,
- 0x0025, 0x0027,
- 0x002a, 0x002a,
- 0x002c, 0x002c,
- 0x002e, 0x002f,
- 0x003a, 0x003b,
- 0x003f, 0x0040,
- 0x005c, 0x005c,
- 0x00a1, 0x00a1,
- 0x00a7, 0x00a7,
- 0x00b6, 0x00b7,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x0589,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x0609, 0x060a,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x07f7, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x09fd, 0x09fd,
- 0x0a76, 0x0a76,
- 0x0af0, 0x0af0,
- 0x0c77, 0x0c77,
- 0x0c84, 0x0c84,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f14, 0x0f14,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd4,
- 0x0fd9, 0x0fda,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1360, 0x1368,
- 0x166e, 0x166e,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x1805,
- 0x1807, 0x180a,
- 0x1944, 0x1945,
- 0x1a1e, 0x1a1f,
- 0x1aa0, 0x1aa6,
- 0x1aa8, 0x1aad,
- 0x1b5a, 0x1b60,
- 0x1bfc, 0x1bff,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x2016, 0x2017,
- 0x2020, 0x2027,
- 0x2030, 0x2038,
- 0x203b, 0x203e,
- 0x2041, 0x2043,
- 0x2047, 0x2051,
- 0x2053, 0x2053,
- 0x2055, 0x205e,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2d70, 0x2d70,
- 0x2e00, 0x2e01,
- 0x2e06, 0x2e08,
- 0x2e0b, 0x2e0b,
- 0x2e0e, 0x2e16,
- 0x2e18, 0x2e19,
- 0x2e1b, 0x2e1b,
- 0x2e1e, 0x2e1f,
- 0x2e2a, 0x2e2e,
- 0x2e30, 0x2e39,
- 0x2e3c, 0x2e3f,
- 0x2e41, 0x2e41,
- 0x2e43, 0x2e4f,
- 0x3001, 0x3003,
- 0x303d, 0x303d,
- 0x30fb, 0x30fb,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa673, 0xa673,
- 0xa67e, 0xa67e,
- 0xa6f2, 0xa6f7,
- 0xa874, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa8f8, 0xa8fa,
- 0xa8fc, 0xa8fc,
- 0xa92e, 0xa92f,
- 0xa95f, 0xa95f,
- 0xa9c1, 0xa9cd,
- 0xa9de, 0xa9df,
- 0xaa5c, 0xaa5f,
- 0xaade, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 0xfe10, 0xfe16,
- 0xfe19, 0xfe19,
- 0xfe30, 0xfe30,
- 0xfe45, 0xfe46,
- 0xfe49, 0xfe4c,
- 0xfe50, 0xfe52,
- 0xfe54, 0xfe57,
- 0xfe5f, 0xfe61,
- 0xfe68, 0xfe68,
- 0xfe6a, 0xfe6b,
- 0xff01, 0xff03,
- 0xff05, 0xff07,
- 0xff0a, 0xff0a,
- 0xff0c, 0xff0c,
- 0xff0e, 0xff0f,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff20,
- 0xff3c, 0xff3c,
- 0xff61, 0xff61,
- 0xff64, 0xff65,
- 0x10100, 0x10102,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x1056f, 0x1056f,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x1093f, 0x1093f,
- 0x10a50, 0x10a58,
- 0x10a7f, 0x10a7f,
- 0x10af0, 0x10af6,
- 0x10b39, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10f55, 0x10f59,
- 0x11047, 0x1104d,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x11140, 0x11143,
- 0x11174, 0x11175,
- 0x111c5, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111db, 0x111db,
- 0x111dd, 0x111df,
- 0x11238, 0x1123d,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144f,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x114c6, 0x114c6,
- 0x115c1, 0x115d7,
- 0x11641, 0x11643,
- 0x11660, 0x1166c,
- 0x1173c, 0x1173e,
- 0x1183b, 0x1183b,
- 0x119e2, 0x119e2,
- 0x11a3f, 0x11a46,
- 0x11a9a, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11c41, 0x11c45,
- 0x11c70, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x11fff, 0x11fff,
- 0x12470, 0x12474,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b3b,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e9a,
- 0x16fe2, 0x16fe2,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8b,
- 0x1e95e, 0x1e95f,
-}; /* CR_Po */
-
-/* 'Ps': General Category */
-static const OnigCodePoint CR_Ps[] = {
- 75,
- 0x0028, 0x0028,
- 0x005b, 0x005b,
- 0x007b, 0x007b,
- 0x0f3a, 0x0f3a,
- 0x0f3c, 0x0f3c,
- 0x169b, 0x169b,
- 0x201a, 0x201a,
- 0x201e, 0x201e,
- 0x2045, 0x2045,
- 0x207d, 0x207d,
- 0x208d, 0x208d,
- 0x2308, 0x2308,
- 0x230a, 0x230a,
- 0x2329, 0x2329,
- 0x2768, 0x2768,
- 0x276a, 0x276a,
- 0x276c, 0x276c,
- 0x276e, 0x276e,
- 0x2770, 0x2770,
- 0x2772, 0x2772,
- 0x2774, 0x2774,
- 0x27c5, 0x27c5,
- 0x27e6, 0x27e6,
- 0x27e8, 0x27e8,
- 0x27ea, 0x27ea,
- 0x27ec, 0x27ec,
- 0x27ee, 0x27ee,
- 0x2983, 0x2983,
- 0x2985, 0x2985,
- 0x2987, 0x2987,
- 0x2989, 0x2989,
- 0x298b, 0x298b,
- 0x298d, 0x298d,
- 0x298f, 0x298f,
- 0x2991, 0x2991,
- 0x2993, 0x2993,
- 0x2995, 0x2995,
- 0x2997, 0x2997,
- 0x29d8, 0x29d8,
- 0x29da, 0x29da,
- 0x29fc, 0x29fc,
- 0x2e22, 0x2e22,
- 0x2e24, 0x2e24,
- 0x2e26, 0x2e26,
- 0x2e28, 0x2e28,
- 0x2e42, 0x2e42,
- 0x3008, 0x3008,
- 0x300a, 0x300a,
- 0x300c, 0x300c,
- 0x300e, 0x300e,
- 0x3010, 0x3010,
- 0x3014, 0x3014,
- 0x3016, 0x3016,
- 0x3018, 0x3018,
- 0x301a, 0x301a,
- 0x301d, 0x301d,
- 0xfd3f, 0xfd3f,
- 0xfe17, 0xfe17,
- 0xfe35, 0xfe35,
- 0xfe37, 0xfe37,
- 0xfe39, 0xfe39,
- 0xfe3b, 0xfe3b,
- 0xfe3d, 0xfe3d,
- 0xfe3f, 0xfe3f,
- 0xfe41, 0xfe41,
- 0xfe43, 0xfe43,
- 0xfe47, 0xfe47,
- 0xfe59, 0xfe59,
- 0xfe5b, 0xfe5b,
- 0xfe5d, 0xfe5d,
- 0xff08, 0xff08,
- 0xff3b, 0xff3b,
- 0xff5b, 0xff5b,
- 0xff5f, 0xff5f,
- 0xff62, 0xff62,
-}; /* CR_Ps */
-
-/* 'S': Major Category */
-static const OnigCodePoint CR_S[] = {
- 226,
- 0x0024, 0x0024,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00a2, 0x00a6,
- 0x00a8, 0x00a9,
- 0x00ac, 0x00ac,
- 0x00ae, 0x00b1,
- 0x00b4, 0x00b4,
- 0x00b8, 0x00b8,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x02c2, 0x02c5,
- 0x02d2, 0x02df,
- 0x02e5, 0x02eb,
- 0x02ed, 0x02ed,
- 0x02ef, 0x02ff,
- 0x0375, 0x0375,
- 0x0384, 0x0385,
- 0x03f6, 0x03f6,
- 0x0482, 0x0482,
- 0x058d, 0x058f,
- 0x0606, 0x0608,
- 0x060b, 0x060b,
- 0x060e, 0x060f,
- 0x06de, 0x06de,
- 0x06e9, 0x06e9,
- 0x06fd, 0x06fe,
- 0x07f6, 0x07f6,
- 0x07fe, 0x07ff,
- 0x09f2, 0x09f3,
- 0x09fa, 0x09fb,
- 0x0af1, 0x0af1,
- 0x0b70, 0x0b70,
- 0x0bf3, 0x0bfa,
- 0x0c7f, 0x0c7f,
- 0x0d4f, 0x0d4f,
- 0x0d79, 0x0d79,
- 0x0e3f, 0x0e3f,
- 0x0f01, 0x0f03,
- 0x0f13, 0x0f13,
- 0x0f15, 0x0f17,
- 0x0f1a, 0x0f1f,
- 0x0f34, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fce, 0x0fcf,
- 0x0fd5, 0x0fd8,
- 0x109e, 0x109f,
- 0x1390, 0x1399,
- 0x166d, 0x166d,
- 0x17db, 0x17db,
- 0x1940, 0x1940,
- 0x19de, 0x19ff,
- 0x1b61, 0x1b6a,
- 0x1b74, 0x1b7c,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x207a, 0x207c,
- 0x208a, 0x208c,
- 0x20a0, 0x20bf,
- 0x2100, 0x2101,
- 0x2103, 0x2106,
- 0x2108, 0x2109,
- 0x2114, 0x2114,
- 0x2116, 0x2118,
- 0x211e, 0x2123,
- 0x2125, 0x2125,
- 0x2127, 0x2127,
- 0x2129, 0x2129,
- 0x212e, 0x212e,
- 0x213a, 0x213b,
- 0x2140, 0x2144,
- 0x214a, 0x214d,
- 0x214f, 0x214f,
- 0x218a, 0x218b,
- 0x2190, 0x2307,
- 0x230c, 0x2328,
- 0x232b, 0x2426,
- 0x2440, 0x244a,
- 0x249c, 0x24e9,
- 0x2500, 0x2767,
- 0x2794, 0x27c4,
- 0x27c7, 0x27e5,
- 0x27f0, 0x2982,
- 0x2999, 0x29d7,
- 0x29dc, 0x29fb,
- 0x29fe, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bff,
- 0x2ce5, 0x2cea,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3004, 0x3004,
- 0x3012, 0x3013,
- 0x3020, 0x3020,
- 0x3036, 0x3037,
- 0x303e, 0x303f,
- 0x309b, 0x309c,
- 0x3190, 0x3191,
- 0x3196, 0x319f,
- 0x31c0, 0x31e3,
- 0x3200, 0x321e,
- 0x322a, 0x3247,
- 0x3250, 0x3250,
- 0x3260, 0x327f,
- 0x328a, 0x32b0,
- 0x32c0, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa490, 0xa4c6,
- 0xa700, 0xa716,
- 0xa720, 0xa721,
- 0xa789, 0xa78a,
- 0xa828, 0xa82b,
- 0xa836, 0xa839,
- 0xaa77, 0xaa79,
- 0xab5b, 0xab5b,
- 0xfb29, 0xfb29,
- 0xfbb2, 0xfbc1,
- 0xfdfc, 0xfdfd,
- 0xfe62, 0xfe62,
- 0xfe64, 0xfe66,
- 0xfe69, 0xfe69,
- 0xff04, 0xff04,
- 0xff0b, 0xff0b,
- 0xff1c, 0xff1e,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xff5c, 0xff5c,
- 0xff5e, 0xff5e,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffc, 0xfffd,
- 0x10137, 0x1013f,
- 0x10179, 0x10189,
- 0x1018c, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fc,
- 0x10877, 0x10878,
- 0x10ac8, 0x10ac8,
- 0x1173f, 0x1173f,
- 0x11fd5, 0x11ff1,
- 0x16b3c, 0x16b3f,
- 0x16b45, 0x16b45,
- 0x1bc9c, 0x1bc9c,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d164,
- 0x1d16a, 0x1d16c,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1e8,
- 0x1d200, 0x1d241,
- 0x1d245, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d6c1, 0x1d6c1,
- 0x1d6db, 0x1d6db,
- 0x1d6fb, 0x1d6fb,
- 0x1d715, 0x1d715,
- 0x1d735, 0x1d735,
- 0x1d74f, 0x1d74f,
- 0x1d76f, 0x1d76f,
- 0x1d789, 0x1d789,
- 0x1d7a9, 0x1d7a9,
- 0x1d7c3, 0x1d7c3,
- 0x1d800, 0x1d9ff,
- 0x1da37, 0x1da3a,
- 0x1da6d, 0x1da74,
- 0x1da76, 0x1da83,
- 0x1da85, 0x1da86,
- 0x1e14f, 0x1e14f,
- 0x1e2ff, 0x1e2ff,
- 0x1ecac, 0x1ecac,
- 0x1ecb0, 0x1ecb0,
- 0x1ed2e, 0x1ed2e,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
-}; /* CR_S */
-
-/* 'Sc': General Category */
-static const OnigCodePoint CR_Sc[] = {
- 21,
- 0x0024, 0x0024,
- 0x00a2, 0x00a5,
- 0x058f, 0x058f,
- 0x060b, 0x060b,
- 0x07fe, 0x07ff,
- 0x09f2, 0x09f3,
- 0x09fb, 0x09fb,
- 0x0af1, 0x0af1,
- 0x0bf9, 0x0bf9,
- 0x0e3f, 0x0e3f,
- 0x17db, 0x17db,
- 0x20a0, 0x20bf,
- 0xa838, 0xa838,
- 0xfdfc, 0xfdfc,
- 0xfe69, 0xfe69,
- 0xff04, 0xff04,
- 0xffe0, 0xffe1,
- 0xffe5, 0xffe6,
- 0x11fdd, 0x11fe0,
- 0x1e2ff, 0x1e2ff,
- 0x1ecb0, 0x1ecb0,
-}; /* CR_Sc */
-
-/* 'Sk': General Category */
-static const OnigCodePoint CR_Sk[] = {
- 29,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x00a8, 0x00a8,
- 0x00af, 0x00af,
- 0x00b4, 0x00b4,
- 0x00b8, 0x00b8,
- 0x02c2, 0x02c5,
- 0x02d2, 0x02df,
- 0x02e5, 0x02eb,
- 0x02ed, 0x02ed,
- 0x02ef, 0x02ff,
- 0x0375, 0x0375,
- 0x0384, 0x0385,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x309b, 0x309c,
- 0xa700, 0xa716,
- 0xa720, 0xa721,
- 0xa789, 0xa78a,
- 0xab5b, 0xab5b,
- 0xfbb2, 0xfbc1,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xffe3, 0xffe3,
- 0x1f3fb, 0x1f3ff,
-}; /* CR_Sk */
-
-/* 'Sm': General Category */
-static const OnigCodePoint CR_Sm[] = {
- 64,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00ac, 0x00ac,
- 0x00b1, 0x00b1,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x03f6, 0x03f6,
- 0x0606, 0x0608,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x207a, 0x207c,
- 0x208a, 0x208c,
- 0x2118, 0x2118,
- 0x2140, 0x2144,
- 0x214b, 0x214b,
- 0x2190, 0x2194,
- 0x219a, 0x219b,
- 0x21a0, 0x21a0,
- 0x21a3, 0x21a3,
- 0x21a6, 0x21a6,
- 0x21ae, 0x21ae,
- 0x21ce, 0x21cf,
- 0x21d2, 0x21d2,
- 0x21d4, 0x21d4,
- 0x21f4, 0x22ff,
- 0x2320, 0x2321,
- 0x237c, 0x237c,
- 0x239b, 0x23b3,
- 0x23dc, 0x23e1,
- 0x25b7, 0x25b7,
- 0x25c1, 0x25c1,
- 0x25f8, 0x25ff,
- 0x266f, 0x266f,
- 0x27c0, 0x27c4,
- 0x27c7, 0x27e5,
- 0x27f0, 0x27ff,
- 0x2900, 0x2982,
- 0x2999, 0x29d7,
- 0x29dc, 0x29fb,
- 0x29fe, 0x2aff,
- 0x2b30, 0x2b44,
- 0x2b47, 0x2b4c,
- 0xfb29, 0xfb29,
- 0xfe62, 0xfe62,
- 0xfe64, 0xfe66,
- 0xff0b, 0xff0b,
- 0xff1c, 0xff1e,
- 0xff5c, 0xff5c,
- 0xff5e, 0xff5e,
- 0xffe2, 0xffe2,
- 0xffe9, 0xffec,
- 0x1d6c1, 0x1d6c1,
- 0x1d6db, 0x1d6db,
- 0x1d6fb, 0x1d6fb,
- 0x1d715, 0x1d715,
- 0x1d735, 0x1d735,
- 0x1d74f, 0x1d74f,
- 0x1d76f, 0x1d76f,
- 0x1d789, 0x1d789,
- 0x1d7a9, 0x1d7a9,
- 0x1d7c3, 0x1d7c3,
- 0x1eef0, 0x1eef1,
-}; /* CR_Sm */
-
-/* 'So': General Category */
-static const OnigCodePoint CR_So[] = {
- 180,
- 0x00a6, 0x00a6,
- 0x00a9, 0x00a9,
- 0x00ae, 0x00ae,
- 0x00b0, 0x00b0,
- 0x0482, 0x0482,
- 0x058d, 0x058e,
- 0x060e, 0x060f,
- 0x06de, 0x06de,
- 0x06e9, 0x06e9,
- 0x06fd, 0x06fe,
- 0x07f6, 0x07f6,
- 0x09fa, 0x09fa,
- 0x0b70, 0x0b70,
- 0x0bf3, 0x0bf8,
- 0x0bfa, 0x0bfa,
- 0x0c7f, 0x0c7f,
- 0x0d4f, 0x0d4f,
- 0x0d79, 0x0d79,
- 0x0f01, 0x0f03,
- 0x0f13, 0x0f13,
- 0x0f15, 0x0f17,
- 0x0f1a, 0x0f1f,
- 0x0f34, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fce, 0x0fcf,
- 0x0fd5, 0x0fd8,
- 0x109e, 0x109f,
- 0x1390, 0x1399,
- 0x166d, 0x166d,
- 0x1940, 0x1940,
- 0x19de, 0x19ff,
- 0x1b61, 0x1b6a,
- 0x1b74, 0x1b7c,
- 0x2100, 0x2101,
- 0x2103, 0x2106,
- 0x2108, 0x2109,
- 0x2114, 0x2114,
- 0x2116, 0x2117,
- 0x211e, 0x2123,
- 0x2125, 0x2125,
- 0x2127, 0x2127,
- 0x2129, 0x2129,
- 0x212e, 0x212e,
- 0x213a, 0x213b,
- 0x214a, 0x214a,
- 0x214c, 0x214d,
- 0x214f, 0x214f,
- 0x218a, 0x218b,
- 0x2195, 0x2199,
- 0x219c, 0x219f,
- 0x21a1, 0x21a2,
- 0x21a4, 0x21a5,
- 0x21a7, 0x21ad,
- 0x21af, 0x21cd,
- 0x21d0, 0x21d1,
- 0x21d3, 0x21d3,
- 0x21d5, 0x21f3,
- 0x2300, 0x2307,
- 0x230c, 0x231f,
- 0x2322, 0x2328,
- 0x232b, 0x237b,
- 0x237d, 0x239a,
- 0x23b4, 0x23db,
- 0x23e2, 0x2426,
- 0x2440, 0x244a,
- 0x249c, 0x24e9,
- 0x2500, 0x25b6,
- 0x25b8, 0x25c0,
- 0x25c2, 0x25f7,
- 0x2600, 0x266e,
- 0x2670, 0x2767,
- 0x2794, 0x27bf,
- 0x2800, 0x28ff,
- 0x2b00, 0x2b2f,
- 0x2b45, 0x2b46,
- 0x2b4d, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bff,
- 0x2ce5, 0x2cea,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3004, 0x3004,
- 0x3012, 0x3013,
- 0x3020, 0x3020,
- 0x3036, 0x3037,
- 0x303e, 0x303f,
- 0x3190, 0x3191,
- 0x3196, 0x319f,
- 0x31c0, 0x31e3,
- 0x3200, 0x321e,
- 0x322a, 0x3247,
- 0x3250, 0x3250,
- 0x3260, 0x327f,
- 0x328a, 0x32b0,
- 0x32c0, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa490, 0xa4c6,
- 0xa828, 0xa82b,
- 0xa836, 0xa837,
- 0xa839, 0xa839,
- 0xaa77, 0xaa79,
- 0xfdfd, 0xfdfd,
- 0xffe4, 0xffe4,
- 0xffe8, 0xffe8,
- 0xffed, 0xffee,
- 0xfffc, 0xfffd,
- 0x10137, 0x1013f,
- 0x10179, 0x10189,
- 0x1018c, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fc,
- 0x10877, 0x10878,
- 0x10ac8, 0x10ac8,
- 0x1173f, 0x1173f,
- 0x11fd5, 0x11fdc,
- 0x11fe1, 0x11ff1,
- 0x16b3c, 0x16b3f,
- 0x16b45, 0x16b45,
- 0x1bc9c, 0x1bc9c,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d164,
- 0x1d16a, 0x1d16c,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1e8,
- 0x1d200, 0x1d241,
- 0x1d245, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d800, 0x1d9ff,
- 0x1da37, 0x1da3a,
- 0x1da6d, 0x1da74,
- 0x1da76, 0x1da83,
- 0x1da85, 0x1da86,
- 0x1e14f, 0x1e14f,
- 0x1ecac, 0x1ecac,
- 0x1ed2e, 0x1ed2e,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f3fa,
- 0x1f400, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
-}; /* CR_So */
-
-/* 'Z': Major Category */
-static const OnigCodePoint CR_Z[] = {
- 8,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x2000, 0x200a,
- 0x2028, 0x2029,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000,
-}; /* CR_Z */
-
-/* 'Zl': General Category */
-static const OnigCodePoint CR_Zl[] = {
- 1,
- 0x2028, 0x2028,
-}; /* CR_Zl */
-
-/* 'Zp': General Category */
-static const OnigCodePoint CR_Zp[] = {
- 1,
- 0x2029, 0x2029,
-}; /* CR_Zp */
-
-/* 'Zs': General Category */
-static const OnigCodePoint CR_Zs[] = {
- 7,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x2000, 0x200a,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000,
-}; /* CR_Zs */
-
-/* 'Math': Derived Property */
-static const OnigCodePoint CR_Math[] = {
- 138,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x005e, 0x005e,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00ac, 0x00ac,
- 0x00b1, 0x00b1,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x03d0, 0x03d2,
- 0x03d5, 0x03d5,
- 0x03f0, 0x03f1,
- 0x03f4, 0x03f6,
- 0x0606, 0x0608,
- 0x2016, 0x2016,
- 0x2032, 0x2034,
- 0x2040, 0x2040,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x2061, 0x2064,
- 0x207a, 0x207e,
- 0x208a, 0x208e,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20e6,
- 0x20eb, 0x20ef,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2128, 0x2129,
- 0x212c, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2138,
- 0x213c, 0x2149,
- 0x214b, 0x214b,
- 0x2190, 0x21a7,
- 0x21a9, 0x21ae,
- 0x21b0, 0x21b1,
- 0x21b6, 0x21b7,
- 0x21bc, 0x21db,
- 0x21dd, 0x21dd,
- 0x21e4, 0x21e5,
- 0x21f4, 0x22ff,
- 0x2308, 0x230b,
- 0x2320, 0x2321,
- 0x237c, 0x237c,
- 0x239b, 0x23b5,
- 0x23b7, 0x23b7,
- 0x23d0, 0x23d0,
- 0x23dc, 0x23e2,
- 0x25a0, 0x25a1,
- 0x25ae, 0x25b7,
- 0x25bc, 0x25c1,
- 0x25c6, 0x25c7,
- 0x25ca, 0x25cb,
- 0x25cf, 0x25d3,
- 0x25e2, 0x25e2,
- 0x25e4, 0x25e4,
- 0x25e7, 0x25ec,
- 0x25f8, 0x25ff,
- 0x2605, 0x2606,
- 0x2640, 0x2640,
- 0x2642, 0x2642,
- 0x2660, 0x2663,
- 0x266d, 0x266f,
- 0x27c0, 0x27ff,
- 0x2900, 0x2aff,
- 0x2b30, 0x2b44,
- 0x2b47, 0x2b4c,
- 0xfb29, 0xfb29,
- 0xfe61, 0xfe66,
- 0xfe68, 0xfe68,
- 0xff0b, 0xff0b,
- 0xff1c, 0xff1e,
- 0xff3c, 0xff3c,
- 0xff3e, 0xff3e,
- 0xff5c, 0xff5c,
- 0xff5e, 0xff5e,
- 0xffe2, 0xffe2,
- 0xffe9, 0xffec,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
-}; /* CR_Math */
-
-/* 'Alphabetic': Derived Property */
-#define CR_Alphabetic CR_Alpha
-
-/* 'Lowercase': Derived Property */
-#define CR_Lowercase CR_Lower
-
-/* 'Uppercase': Derived Property */
-#define CR_Uppercase CR_Upper
-
-/* 'Cased': Derived Property */
-static const OnigCodePoint CR_Cased[] = {
- 140,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x01ba,
- 0x01bc, 0x01bf,
- 0x01c4, 0x0293,
- 0x0295, 0x02b8,
- 0x02c0, 0x02c1,
- 0x02e0, 0x02e4,
- 0x0345, 0x0345,
- 0x0370, 0x0373,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0560, 0x0588,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1d00, 0x1dbf,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x217f,
- 0x2183, 0x2184,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa640, 0xa66d,
- 0xa680, 0xa69d,
- 0xa722, 0xa787,
- 0xa78b, 0xa78e,
- 0xa790, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f8, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0x10400, 0x1044f,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x118a0, 0x118df,
- 0x16e40, 0x16e7f,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1e900, 0x1e943,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* CR_Cased */
-
-/* 'Case_Ignorable': Derived Property */
-static const OnigCodePoint CR_Case_Ignorable[] = {
- 401,
- 0x0027, 0x0027,
- 0x002e, 0x002e,
- 0x003a, 0x003a,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x00a8, 0x00a8,
- 0x00ad, 0x00ad,
- 0x00af, 0x00af,
- 0x00b4, 0x00b4,
- 0x00b7, 0x00b8,
- 0x02b0, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x0384, 0x0385,
- 0x0387, 0x0387,
- 0x0483, 0x0489,
- 0x0559, 0x0559,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05f4, 0x05f4,
- 0x0600, 0x0605,
- 0x0610, 0x061a,
- 0x061c, 0x061c,
- 0x0640, 0x0640,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dd,
- 0x06df, 0x06e8,
- 0x06ea, 0x06ed,
- 0x070f, 0x070f,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0816, 0x082d,
- 0x0859, 0x085b,
- 0x08d3, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0971, 0x0971,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3f, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b56, 0x0b56,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d62, 0x0d63,
- 0x0dca, 0x0dca,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e46, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x10fc, 0x10fc,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dd, 0x17dd,
- 0x180b, 0x180e,
- 0x1843, 0x1843,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b34,
- 0x1b36, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1c78, 0x1c7d,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1d2c, 0x1d6a,
- 0x1d78, 0x1d78,
- 0x1d9b, 0x1df9,
- 0x1dfb, 0x1dff,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x200b, 0x200f,
- 0x2018, 0x2019,
- 0x2024, 0x2024,
- 0x2027, 0x2027,
- 0x202a, 0x202e,
- 0x2060, 0x2064,
- 0x2066, 0x206f,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20f0,
- 0x2c7c, 0x2c7d,
- 0x2cef, 0x2cf1,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3005,
- 0x302a, 0x302d,
- 0x3031, 0x3035,
- 0x303b, 0x303b,
- 0x3099, 0x309e,
- 0x30fc, 0x30fe,
- 0xa015, 0xa015,
- 0xa4f8, 0xa4fd,
- 0xa60c, 0xa60c,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa67f, 0xa67f,
- 0xa69c, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa700, 0xa721,
- 0xa770, 0xa770,
- 0xa788, 0xa78a,
- 0xa7f8, 0xa7f9,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9cf, 0xa9cf,
- 0xa9e5, 0xa9e6,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa70, 0xaa70,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaadd, 0xaadd,
- 0xaaec, 0xaaed,
- 0xaaf3, 0xaaf4,
- 0xaaf6, 0xaaf6,
- 0xab5b, 0xab5f,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfbb2, 0xfbc1,
- 0xfe00, 0xfe0f,
- 0xfe13, 0xfe13,
- 0xfe20, 0xfe2f,
- 0xfe52, 0xfe52,
- 0xfe55, 0xfe55,
- 0xfeff, 0xfeff,
- 0xff07, 0xff07,
- 0xff0e, 0xff0e,
- 0xff1a, 0xff1a,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0xffe3, 0xffe3,
- 0xfff9, 0xfffb,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10f46, 0x10f50,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x110bd, 0x110bd,
- 0x110cd, 0x110cd,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x11340, 0x11340,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x13430, 0x13438,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x1bc9d, 0x1bc9e,
- 0x1bca0, 0x1bca3,
- 0x1d167, 0x1d169,
- 0x1d173, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e130, 0x1e13d,
- 0x1e2ec, 0x1e2ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94b,
- 0x1f3fb, 0x1f3ff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
-}; /* CR_Case_Ignorable */
-
-/* 'Changes_When_Lowercased': Derived Property */
-static const OnigCodePoint CR_Changes_When_Lowercased[] = {
- 599,
- 0x0041, 0x005a,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00de,
- 0x0100, 0x0100,
- 0x0102, 0x0102,
- 0x0104, 0x0104,
- 0x0106, 0x0106,
- 0x0108, 0x0108,
- 0x010a, 0x010a,
- 0x010c, 0x010c,
- 0x010e, 0x010e,
- 0x0110, 0x0110,
- 0x0112, 0x0112,
- 0x0114, 0x0114,
- 0x0116, 0x0116,
- 0x0118, 0x0118,
- 0x011a, 0x011a,
- 0x011c, 0x011c,
- 0x011e, 0x011e,
- 0x0120, 0x0120,
- 0x0122, 0x0122,
- 0x0124, 0x0124,
- 0x0126, 0x0126,
- 0x0128, 0x0128,
- 0x012a, 0x012a,
- 0x012c, 0x012c,
- 0x012e, 0x012e,
- 0x0130, 0x0130,
- 0x0132, 0x0132,
- 0x0134, 0x0134,
- 0x0136, 0x0136,
- 0x0139, 0x0139,
- 0x013b, 0x013b,
- 0x013d, 0x013d,
- 0x013f, 0x013f,
- 0x0141, 0x0141,
- 0x0143, 0x0143,
- 0x0145, 0x0145,
- 0x0147, 0x0147,
- 0x014a, 0x014a,
- 0x014c, 0x014c,
- 0x014e, 0x014e,
- 0x0150, 0x0150,
- 0x0152, 0x0152,
- 0x0154, 0x0154,
- 0x0156, 0x0156,
- 0x0158, 0x0158,
- 0x015a, 0x015a,
- 0x015c, 0x015c,
- 0x015e, 0x015e,
- 0x0160, 0x0160,
- 0x0162, 0x0162,
- 0x0164, 0x0164,
- 0x0166, 0x0166,
- 0x0168, 0x0168,
- 0x016a, 0x016a,
- 0x016c, 0x016c,
- 0x016e, 0x016e,
- 0x0170, 0x0170,
- 0x0172, 0x0172,
- 0x0174, 0x0174,
- 0x0176, 0x0176,
- 0x0178, 0x0179,
- 0x017b, 0x017b,
- 0x017d, 0x017d,
- 0x0181, 0x0182,
- 0x0184, 0x0184,
- 0x0186, 0x0187,
- 0x0189, 0x018b,
- 0x018e, 0x0191,
- 0x0193, 0x0194,
- 0x0196, 0x0198,
- 0x019c, 0x019d,
- 0x019f, 0x01a0,
- 0x01a2, 0x01a2,
- 0x01a4, 0x01a4,
- 0x01a6, 0x01a7,
- 0x01a9, 0x01a9,
- 0x01ac, 0x01ac,
- 0x01ae, 0x01af,
- 0x01b1, 0x01b3,
- 0x01b5, 0x01b5,
- 0x01b7, 0x01b8,
- 0x01bc, 0x01bc,
- 0x01c4, 0x01c5,
- 0x01c7, 0x01c8,
- 0x01ca, 0x01cb,
- 0x01cd, 0x01cd,
- 0x01cf, 0x01cf,
- 0x01d1, 0x01d1,
- 0x01d3, 0x01d3,
- 0x01d5, 0x01d5,
- 0x01d7, 0x01d7,
- 0x01d9, 0x01d9,
- 0x01db, 0x01db,
- 0x01de, 0x01de,
- 0x01e0, 0x01e0,
- 0x01e2, 0x01e2,
- 0x01e4, 0x01e4,
- 0x01e6, 0x01e6,
- 0x01e8, 0x01e8,
- 0x01ea, 0x01ea,
- 0x01ec, 0x01ec,
- 0x01ee, 0x01ee,
- 0x01f1, 0x01f2,
- 0x01f4, 0x01f4,
- 0x01f6, 0x01f8,
- 0x01fa, 0x01fa,
- 0x01fc, 0x01fc,
- 0x01fe, 0x01fe,
- 0x0200, 0x0200,
- 0x0202, 0x0202,
- 0x0204, 0x0204,
- 0x0206, 0x0206,
- 0x0208, 0x0208,
- 0x020a, 0x020a,
- 0x020c, 0x020c,
- 0x020e, 0x020e,
- 0x0210, 0x0210,
- 0x0212, 0x0212,
- 0x0214, 0x0214,
- 0x0216, 0x0216,
- 0x0218, 0x0218,
- 0x021a, 0x021a,
- 0x021c, 0x021c,
- 0x021e, 0x021e,
- 0x0220, 0x0220,
- 0x0222, 0x0222,
- 0x0224, 0x0224,
- 0x0226, 0x0226,
- 0x0228, 0x0228,
- 0x022a, 0x022a,
- 0x022c, 0x022c,
- 0x022e, 0x022e,
- 0x0230, 0x0230,
- 0x0232, 0x0232,
- 0x023a, 0x023b,
- 0x023d, 0x023e,
- 0x0241, 0x0241,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03cf, 0x03cf,
- 0x03d8, 0x03d8,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03e2,
- 0x03e4, 0x03e4,
- 0x03e6, 0x03e6,
- 0x03e8, 0x03e8,
- 0x03ea, 0x03ea,
- 0x03ec, 0x03ec,
- 0x03ee, 0x03ee,
- 0x03f4, 0x03f4,
- 0x03f7, 0x03f7,
- 0x03f9, 0x03fa,
- 0x03fd, 0x042f,
- 0x0460, 0x0460,
- 0x0462, 0x0462,
- 0x0464, 0x0464,
- 0x0466, 0x0466,
- 0x0468, 0x0468,
- 0x046a, 0x046a,
- 0x046c, 0x046c,
- 0x046e, 0x046e,
- 0x0470, 0x0470,
- 0x0472, 0x0472,
- 0x0474, 0x0474,
- 0x0476, 0x0476,
- 0x0478, 0x0478,
- 0x047a, 0x047a,
- 0x047c, 0x047c,
- 0x047e, 0x047e,
- 0x0480, 0x0480,
- 0x048a, 0x048a,
- 0x048c, 0x048c,
- 0x048e, 0x048e,
- 0x0490, 0x0490,
- 0x0492, 0x0492,
- 0x0494, 0x0494,
- 0x0496, 0x0496,
- 0x0498, 0x0498,
- 0x049a, 0x049a,
- 0x049c, 0x049c,
- 0x049e, 0x049e,
- 0x04a0, 0x04a0,
- 0x04a2, 0x04a2,
- 0x04a4, 0x04a4,
- 0x04a6, 0x04a6,
- 0x04a8, 0x04a8,
- 0x04aa, 0x04aa,
- 0x04ac, 0x04ac,
- 0x04ae, 0x04ae,
- 0x04b0, 0x04b0,
- 0x04b2, 0x04b2,
- 0x04b4, 0x04b4,
- 0x04b6, 0x04b6,
- 0x04b8, 0x04b8,
- 0x04ba, 0x04ba,
- 0x04bc, 0x04bc,
- 0x04be, 0x04be,
- 0x04c0, 0x04c1,
- 0x04c3, 0x04c3,
- 0x04c5, 0x04c5,
- 0x04c7, 0x04c7,
- 0x04c9, 0x04c9,
- 0x04cb, 0x04cb,
- 0x04cd, 0x04cd,
- 0x04d0, 0x04d0,
- 0x04d2, 0x04d2,
- 0x04d4, 0x04d4,
- 0x04d6, 0x04d6,
- 0x04d8, 0x04d8,
- 0x04da, 0x04da,
- 0x04dc, 0x04dc,
- 0x04de, 0x04de,
- 0x04e0, 0x04e0,
- 0x04e2, 0x04e2,
- 0x04e4, 0x04e4,
- 0x04e6, 0x04e6,
- 0x04e8, 0x04e8,
- 0x04ea, 0x04ea,
- 0x04ec, 0x04ec,
- 0x04ee, 0x04ee,
- 0x04f0, 0x04f0,
- 0x04f2, 0x04f2,
- 0x04f4, 0x04f4,
- 0x04f6, 0x04f6,
- 0x04f8, 0x04f8,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13a0, 0x13f5,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1e00, 0x1e00,
- 0x1e02, 0x1e02,
- 0x1e04, 0x1e04,
- 0x1e06, 0x1e06,
- 0x1e08, 0x1e08,
- 0x1e0a, 0x1e0a,
- 0x1e0c, 0x1e0c,
- 0x1e0e, 0x1e0e,
- 0x1e10, 0x1e10,
- 0x1e12, 0x1e12,
- 0x1e14, 0x1e14,
- 0x1e16, 0x1e16,
- 0x1e18, 0x1e18,
- 0x1e1a, 0x1e1a,
- 0x1e1c, 0x1e1c,
- 0x1e1e, 0x1e1e,
- 0x1e20, 0x1e20,
- 0x1e22, 0x1e22,
- 0x1e24, 0x1e24,
- 0x1e26, 0x1e26,
- 0x1e28, 0x1e28,
- 0x1e2a, 0x1e2a,
- 0x1e2c, 0x1e2c,
- 0x1e2e, 0x1e2e,
- 0x1e30, 0x1e30,
- 0x1e32, 0x1e32,
- 0x1e34, 0x1e34,
- 0x1e36, 0x1e36,
- 0x1e38, 0x1e38,
- 0x1e3a, 0x1e3a,
- 0x1e3c, 0x1e3c,
- 0x1e3e, 0x1e3e,
- 0x1e40, 0x1e40,
- 0x1e42, 0x1e42,
- 0x1e44, 0x1e44,
- 0x1e46, 0x1e46,
- 0x1e48, 0x1e48,
- 0x1e4a, 0x1e4a,
- 0x1e4c, 0x1e4c,
- 0x1e4e, 0x1e4e,
- 0x1e50, 0x1e50,
- 0x1e52, 0x1e52,
- 0x1e54, 0x1e54,
- 0x1e56, 0x1e56,
- 0x1e58, 0x1e58,
- 0x1e5a, 0x1e5a,
- 0x1e5c, 0x1e5c,
- 0x1e5e, 0x1e5e,
- 0x1e60, 0x1e60,
- 0x1e62, 0x1e62,
- 0x1e64, 0x1e64,
- 0x1e66, 0x1e66,
- 0x1e68, 0x1e68,
- 0x1e6a, 0x1e6a,
- 0x1e6c, 0x1e6c,
- 0x1e6e, 0x1e6e,
- 0x1e70, 0x1e70,
- 0x1e72, 0x1e72,
- 0x1e74, 0x1e74,
- 0x1e76, 0x1e76,
- 0x1e78, 0x1e78,
- 0x1e7a, 0x1e7a,
- 0x1e7c, 0x1e7c,
- 0x1e7e, 0x1e7e,
- 0x1e80, 0x1e80,
- 0x1e82, 0x1e82,
- 0x1e84, 0x1e84,
- 0x1e86, 0x1e86,
- 0x1e88, 0x1e88,
- 0x1e8a, 0x1e8a,
- 0x1e8c, 0x1e8c,
- 0x1e8e, 0x1e8e,
- 0x1e90, 0x1e90,
- 0x1e92, 0x1e92,
- 0x1e94, 0x1e94,
- 0x1e9e, 0x1e9e,
- 0x1ea0, 0x1ea0,
- 0x1ea2, 0x1ea2,
- 0x1ea4, 0x1ea4,
- 0x1ea6, 0x1ea6,
- 0x1ea8, 0x1ea8,
- 0x1eaa, 0x1eaa,
- 0x1eac, 0x1eac,
- 0x1eae, 0x1eae,
- 0x1eb0, 0x1eb0,
- 0x1eb2, 0x1eb2,
- 0x1eb4, 0x1eb4,
- 0x1eb6, 0x1eb6,
- 0x1eb8, 0x1eb8,
- 0x1eba, 0x1eba,
- 0x1ebc, 0x1ebc,
- 0x1ebe, 0x1ebe,
- 0x1ec0, 0x1ec0,
- 0x1ec2, 0x1ec2,
- 0x1ec4, 0x1ec4,
- 0x1ec6, 0x1ec6,
- 0x1ec8, 0x1ec8,
- 0x1eca, 0x1eca,
- 0x1ecc, 0x1ecc,
- 0x1ece, 0x1ece,
- 0x1ed0, 0x1ed0,
- 0x1ed2, 0x1ed2,
- 0x1ed4, 0x1ed4,
- 0x1ed6, 0x1ed6,
- 0x1ed8, 0x1ed8,
- 0x1eda, 0x1eda,
- 0x1edc, 0x1edc,
- 0x1ede, 0x1ede,
- 0x1ee0, 0x1ee0,
- 0x1ee2, 0x1ee2,
- 0x1ee4, 0x1ee4,
- 0x1ee6, 0x1ee6,
- 0x1ee8, 0x1ee8,
- 0x1eea, 0x1eea,
- 0x1eec, 0x1eec,
- 0x1eee, 0x1eee,
- 0x1ef0, 0x1ef0,
- 0x1ef2, 0x1ef2,
- 0x1ef4, 0x1ef4,
- 0x1ef6, 0x1ef6,
- 0x1ef8, 0x1ef8,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1f88, 0x1f8f,
- 0x1f98, 0x1f9f,
- 0x1fa8, 0x1faf,
- 0x1fb8, 0x1fbc,
- 0x1fc8, 0x1fcc,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff8, 0x1ffc,
- 0x2126, 0x2126,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x2160, 0x216f,
- 0x2183, 0x2183,
- 0x24b6, 0x24cf,
- 0x2c00, 0x2c2e,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 0x2c80,
- 0x2c82, 0x2c82,
- 0x2c84, 0x2c84,
- 0x2c86, 0x2c86,
- 0x2c88, 0x2c88,
- 0x2c8a, 0x2c8a,
- 0x2c8c, 0x2c8c,
- 0x2c8e, 0x2c8e,
- 0x2c90, 0x2c90,
- 0x2c92, 0x2c92,
- 0x2c94, 0x2c94,
- 0x2c96, 0x2c96,
- 0x2c98, 0x2c98,
- 0x2c9a, 0x2c9a,
- 0x2c9c, 0x2c9c,
- 0x2c9e, 0x2c9e,
- 0x2ca0, 0x2ca0,
- 0x2ca2, 0x2ca2,
- 0x2ca4, 0x2ca4,
- 0x2ca6, 0x2ca6,
- 0x2ca8, 0x2ca8,
- 0x2caa, 0x2caa,
- 0x2cac, 0x2cac,
- 0x2cae, 0x2cae,
- 0x2cb0, 0x2cb0,
- 0x2cb2, 0x2cb2,
- 0x2cb4, 0x2cb4,
- 0x2cb6, 0x2cb6,
- 0x2cb8, 0x2cb8,
- 0x2cba, 0x2cba,
- 0x2cbc, 0x2cbc,
- 0x2cbe, 0x2cbe,
- 0x2cc0, 0x2cc0,
- 0x2cc2, 0x2cc2,
- 0x2cc4, 0x2cc4,
- 0x2cc6, 0x2cc6,
- 0x2cc8, 0x2cc8,
- 0x2cca, 0x2cca,
- 0x2ccc, 0x2ccc,
- 0x2cce, 0x2cce,
- 0x2cd0, 0x2cd0,
- 0x2cd2, 0x2cd2,
- 0x2cd4, 0x2cd4,
- 0x2cd6, 0x2cd6,
- 0x2cd8, 0x2cd8,
- 0x2cda, 0x2cda,
- 0x2cdc, 0x2cdc,
- 0x2cde, 0x2cde,
- 0x2ce0, 0x2ce0,
- 0x2ce2, 0x2ce2,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c6,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 0x1e900, 0x1e921,
-}; /* CR_Changes_When_Lowercased */
-
-/* 'Changes_When_Uppercased': Derived Property */
-static const OnigCodePoint CR_Changes_When_Uppercased[] = {
- 616,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 0x00df, 0x00f6,
- 0x00f8, 0x00ff,
- 0x0101, 0x0101,
- 0x0103, 0x0103,
- 0x0105, 0x0105,
- 0x0107, 0x0107,
- 0x0109, 0x0109,
- 0x010b, 0x010b,
- 0x010d, 0x010d,
- 0x010f, 0x010f,
- 0x0111, 0x0111,
- 0x0113, 0x0113,
- 0x0115, 0x0115,
- 0x0117, 0x0117,
- 0x0119, 0x0119,
- 0x011b, 0x011b,
- 0x011d, 0x011d,
- 0x011f, 0x011f,
- 0x0121, 0x0121,
- 0x0123, 0x0123,
- 0x0125, 0x0125,
- 0x0127, 0x0127,
- 0x0129, 0x0129,
- 0x012b, 0x012b,
- 0x012d, 0x012d,
- 0x012f, 0x012f,
- 0x0131, 0x0131,
- 0x0133, 0x0133,
- 0x0135, 0x0135,
- 0x0137, 0x0137,
- 0x013a, 0x013a,
- 0x013c, 0x013c,
- 0x013e, 0x013e,
- 0x0140, 0x0140,
- 0x0142, 0x0142,
- 0x0144, 0x0144,
- 0x0146, 0x0146,
- 0x0148, 0x0149,
- 0x014b, 0x014b,
- 0x014d, 0x014d,
- 0x014f, 0x014f,
- 0x0151, 0x0151,
- 0x0153, 0x0153,
- 0x0155, 0x0155,
- 0x0157, 0x0157,
- 0x0159, 0x0159,
- 0x015b, 0x015b,
- 0x015d, 0x015d,
- 0x015f, 0x015f,
- 0x0161, 0x0161,
- 0x0163, 0x0163,
- 0x0165, 0x0165,
- 0x0167, 0x0167,
- 0x0169, 0x0169,
- 0x016b, 0x016b,
- 0x016d, 0x016d,
- 0x016f, 0x016f,
- 0x0171, 0x0171,
- 0x0173, 0x0173,
- 0x0175, 0x0175,
- 0x0177, 0x0177,
- 0x017a, 0x017a,
- 0x017c, 0x017c,
- 0x017e, 0x0180,
- 0x0183, 0x0183,
- 0x0185, 0x0185,
- 0x0188, 0x0188,
- 0x018c, 0x018c,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019a,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01b9,
- 0x01bd, 0x01bd,
- 0x01bf, 0x01bf,
- 0x01c5, 0x01c6,
- 0x01c8, 0x01c9,
- 0x01cb, 0x01cc,
- 0x01ce, 0x01ce,
- 0x01d0, 0x01d0,
- 0x01d2, 0x01d2,
- 0x01d4, 0x01d4,
- 0x01d6, 0x01d6,
- 0x01d8, 0x01d8,
- 0x01da, 0x01da,
- 0x01dc, 0x01dd,
- 0x01df, 0x01df,
- 0x01e1, 0x01e1,
- 0x01e3, 0x01e3,
- 0x01e5, 0x01e5,
- 0x01e7, 0x01e7,
- 0x01e9, 0x01e9,
- 0x01eb, 0x01eb,
- 0x01ed, 0x01ed,
- 0x01ef, 0x01f0,
- 0x01f2, 0x01f3,
- 0x01f5, 0x01f5,
- 0x01f9, 0x01f9,
- 0x01fb, 0x01fb,
- 0x01fd, 0x01fd,
- 0x01ff, 0x01ff,
- 0x0201, 0x0201,
- 0x0203, 0x0203,
- 0x0205, 0x0205,
- 0x0207, 0x0207,
- 0x0209, 0x0209,
- 0x020b, 0x020b,
- 0x020d, 0x020d,
- 0x020f, 0x020f,
- 0x0211, 0x0211,
- 0x0213, 0x0213,
- 0x0215, 0x0215,
- 0x0217, 0x0217,
- 0x0219, 0x0219,
- 0x021b, 0x021b,
- 0x021d, 0x021d,
- 0x021f, 0x021f,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0233,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0254,
- 0x0256, 0x0257,
- 0x0259, 0x0259,
- 0x025b, 0x025c,
- 0x0260, 0x0261,
- 0x0263, 0x0263,
- 0x0265, 0x0266,
- 0x0268, 0x026c,
- 0x026f, 0x026f,
- 0x0271, 0x0272,
- 0x0275, 0x0275,
- 0x027d, 0x027d,
- 0x0280, 0x0280,
- 0x0282, 0x0283,
- 0x0287, 0x028c,
- 0x0292, 0x0292,
- 0x029d, 0x029e,
- 0x0345, 0x0345,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037b, 0x037d,
- 0x0390, 0x0390,
- 0x03ac, 0x03ce,
- 0x03d0, 0x03d1,
- 0x03d5, 0x03d7,
- 0x03d9, 0x03d9,
- 0x03db, 0x03db,
- 0x03dd, 0x03dd,
- 0x03df, 0x03df,
- 0x03e1, 0x03e1,
- 0x03e3, 0x03e3,
- 0x03e5, 0x03e5,
- 0x03e7, 0x03e7,
- 0x03e9, 0x03e9,
- 0x03eb, 0x03eb,
- 0x03ed, 0x03ed,
- 0x03ef, 0x03f3,
- 0x03f5, 0x03f5,
- 0x03f8, 0x03f8,
- 0x03fb, 0x03fb,
- 0x0430, 0x045f,
- 0x0461, 0x0461,
- 0x0463, 0x0463,
- 0x0465, 0x0465,
- 0x0467, 0x0467,
- 0x0469, 0x0469,
- 0x046b, 0x046b,
- 0x046d, 0x046d,
- 0x046f, 0x046f,
- 0x0471, 0x0471,
- 0x0473, 0x0473,
- 0x0475, 0x0475,
- 0x0477, 0x0477,
- 0x0479, 0x0479,
- 0x047b, 0x047b,
- 0x047d, 0x047d,
- 0x047f, 0x047f,
- 0x0481, 0x0481,
- 0x048b, 0x048b,
- 0x048d, 0x048d,
- 0x048f, 0x048f,
- 0x0491, 0x0491,
- 0x0493, 0x0493,
- 0x0495, 0x0495,
- 0x0497, 0x0497,
- 0x0499, 0x0499,
- 0x049b, 0x049b,
- 0x049d, 0x049d,
- 0x049f, 0x049f,
- 0x04a1, 0x04a1,
- 0x04a3, 0x04a3,
- 0x04a5, 0x04a5,
- 0x04a7, 0x04a7,
- 0x04a9, 0x04a9,
- 0x04ab, 0x04ab,
- 0x04ad, 0x04ad,
- 0x04af, 0x04af,
- 0x04b1, 0x04b1,
- 0x04b3, 0x04b3,
- 0x04b5, 0x04b5,
- 0x04b7, 0x04b7,
- 0x04b9, 0x04b9,
- 0x04bb, 0x04bb,
- 0x04bd, 0x04bd,
- 0x04bf, 0x04bf,
- 0x04c2, 0x04c2,
- 0x04c4, 0x04c4,
- 0x04c6, 0x04c6,
- 0x04c8, 0x04c8,
- 0x04ca, 0x04ca,
- 0x04cc, 0x04cc,
- 0x04ce, 0x04cf,
- 0x04d1, 0x04d1,
- 0x04d3, 0x04d3,
- 0x04d5, 0x04d5,
- 0x04d7, 0x04d7,
- 0x04d9, 0x04d9,
- 0x04db, 0x04db,
- 0x04dd, 0x04dd,
- 0x04df, 0x04df,
- 0x04e1, 0x04e1,
- 0x04e3, 0x04e3,
- 0x04e5, 0x04e5,
- 0x04e7, 0x04e7,
- 0x04e9, 0x04e9,
- 0x04eb, 0x04eb,
- 0x04ed, 0x04ed,
- 0x04ef, 0x04ef,
- 0x04f1, 0x04f1,
- 0x04f3, 0x04f3,
- 0x04f5, 0x04f5,
- 0x04f7, 0x04f7,
- 0x04f9, 0x04f9,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0561, 0x0587,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d79, 0x1d79,
- 0x1d7d, 0x1d7d,
- 0x1d8e, 0x1d8e,
- 0x1e01, 0x1e01,
- 0x1e03, 0x1e03,
- 0x1e05, 0x1e05,
- 0x1e07, 0x1e07,
- 0x1e09, 0x1e09,
- 0x1e0b, 0x1e0b,
- 0x1e0d, 0x1e0d,
- 0x1e0f, 0x1e0f,
- 0x1e11, 0x1e11,
- 0x1e13, 0x1e13,
- 0x1e15, 0x1e15,
- 0x1e17, 0x1e17,
- 0x1e19, 0x1e19,
- 0x1e1b, 0x1e1b,
- 0x1e1d, 0x1e1d,
- 0x1e1f, 0x1e1f,
- 0x1e21, 0x1e21,
- 0x1e23, 0x1e23,
- 0x1e25, 0x1e25,
- 0x1e27, 0x1e27,
- 0x1e29, 0x1e29,
- 0x1e2b, 0x1e2b,
- 0x1e2d, 0x1e2d,
- 0x1e2f, 0x1e2f,
- 0x1e31, 0x1e31,
- 0x1e33, 0x1e33,
- 0x1e35, 0x1e35,
- 0x1e37, 0x1e37,
- 0x1e39, 0x1e39,
- 0x1e3b, 0x1e3b,
- 0x1e3d, 0x1e3d,
- 0x1e3f, 0x1e3f,
- 0x1e41, 0x1e41,
- 0x1e43, 0x1e43,
- 0x1e45, 0x1e45,
- 0x1e47, 0x1e47,
- 0x1e49, 0x1e49,
- 0x1e4b, 0x1e4b,
- 0x1e4d, 0x1e4d,
- 0x1e4f, 0x1e4f,
- 0x1e51, 0x1e51,
- 0x1e53, 0x1e53,
- 0x1e55, 0x1e55,
- 0x1e57, 0x1e57,
- 0x1e59, 0x1e59,
- 0x1e5b, 0x1e5b,
- 0x1e5d, 0x1e5d,
- 0x1e5f, 0x1e5f,
- 0x1e61, 0x1e61,
- 0x1e63, 0x1e63,
- 0x1e65, 0x1e65,
- 0x1e67, 0x1e67,
- 0x1e69, 0x1e69,
- 0x1e6b, 0x1e6b,
- 0x1e6d, 0x1e6d,
- 0x1e6f, 0x1e6f,
- 0x1e71, 0x1e71,
- 0x1e73, 0x1e73,
- 0x1e75, 0x1e75,
- 0x1e77, 0x1e77,
- 0x1e79, 0x1e79,
- 0x1e7b, 0x1e7b,
- 0x1e7d, 0x1e7d,
- 0x1e7f, 0x1e7f,
- 0x1e81, 0x1e81,
- 0x1e83, 0x1e83,
- 0x1e85, 0x1e85,
- 0x1e87, 0x1e87,
- 0x1e89, 0x1e89,
- 0x1e8b, 0x1e8b,
- 0x1e8d, 0x1e8d,
- 0x1e8f, 0x1e8f,
- 0x1e91, 0x1e91,
- 0x1e93, 0x1e93,
- 0x1e95, 0x1e9b,
- 0x1ea1, 0x1ea1,
- 0x1ea3, 0x1ea3,
- 0x1ea5, 0x1ea5,
- 0x1ea7, 0x1ea7,
- 0x1ea9, 0x1ea9,
- 0x1eab, 0x1eab,
- 0x1ead, 0x1ead,
- 0x1eaf, 0x1eaf,
- 0x1eb1, 0x1eb1,
- 0x1eb3, 0x1eb3,
- 0x1eb5, 0x1eb5,
- 0x1eb7, 0x1eb7,
- 0x1eb9, 0x1eb9,
- 0x1ebb, 0x1ebb,
- 0x1ebd, 0x1ebd,
- 0x1ebf, 0x1ebf,
- 0x1ec1, 0x1ec1,
- 0x1ec3, 0x1ec3,
- 0x1ec5, 0x1ec5,
- 0x1ec7, 0x1ec7,
- 0x1ec9, 0x1ec9,
- 0x1ecb, 0x1ecb,
- 0x1ecd, 0x1ecd,
- 0x1ecf, 0x1ecf,
- 0x1ed1, 0x1ed1,
- 0x1ed3, 0x1ed3,
- 0x1ed5, 0x1ed5,
- 0x1ed7, 0x1ed7,
- 0x1ed9, 0x1ed9,
- 0x1edb, 0x1edb,
- 0x1edd, 0x1edd,
- 0x1edf, 0x1edf,
- 0x1ee1, 0x1ee1,
- 0x1ee3, 0x1ee3,
- 0x1ee5, 0x1ee5,
- 0x1ee7, 0x1ee7,
- 0x1ee9, 0x1ee9,
- 0x1eeb, 0x1eeb,
- 0x1eed, 0x1eed,
- 0x1eef, 0x1eef,
- 0x1ef1, 0x1ef1,
- 0x1ef3, 0x1ef3,
- 0x1ef5, 0x1ef5,
- 0x1ef7, 0x1ef7,
- 0x1ef9, 0x1ef9,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 0x1f07,
- 0x1f10, 0x1f15,
- 0x1f20, 0x1f27,
- 0x1f30, 0x1f37,
- 0x1f40, 0x1f45,
- 0x1f50, 0x1f57,
- 0x1f60, 0x1f67,
- 0x1f70, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fb7,
- 0x1fbc, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fc7,
- 0x1fcc, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fd7,
- 0x1fe0, 0x1fe7,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ff7,
- 0x1ffc, 0x1ffc,
- 0x214e, 0x214e,
- 0x2170, 0x217f,
- 0x2184, 0x2184,
- 0x24d0, 0x24e9,
- 0x2c30, 0x2c5e,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c73, 0x2c73,
- 0x2c76, 0x2c76,
- 0x2c81, 0x2c81,
- 0x2c83, 0x2c83,
- 0x2c85, 0x2c85,
- 0x2c87, 0x2c87,
- 0x2c89, 0x2c89,
- 0x2c8b, 0x2c8b,
- 0x2c8d, 0x2c8d,
- 0x2c8f, 0x2c8f,
- 0x2c91, 0x2c91,
- 0x2c93, 0x2c93,
- 0x2c95, 0x2c95,
- 0x2c97, 0x2c97,
- 0x2c99, 0x2c99,
- 0x2c9b, 0x2c9b,
- 0x2c9d, 0x2c9d,
- 0x2c9f, 0x2c9f,
- 0x2ca1, 0x2ca1,
- 0x2ca3, 0x2ca3,
- 0x2ca5, 0x2ca5,
- 0x2ca7, 0x2ca7,
- 0x2ca9, 0x2ca9,
- 0x2cab, 0x2cab,
- 0x2cad, 0x2cad,
- 0x2caf, 0x2caf,
- 0x2cb1, 0x2cb1,
- 0x2cb3, 0x2cb3,
- 0x2cb5, 0x2cb5,
- 0x2cb7, 0x2cb7,
- 0x2cb9, 0x2cb9,
- 0x2cbb, 0x2cbb,
- 0x2cbd, 0x2cbd,
- 0x2cbf, 0x2cbf,
- 0x2cc1, 0x2cc1,
- 0x2cc3, 0x2cc3,
- 0x2cc5, 0x2cc5,
- 0x2cc7, 0x2cc7,
- 0x2cc9, 0x2cc9,
- 0x2ccb, 0x2ccb,
- 0x2ccd, 0x2ccd,
- 0x2ccf, 0x2ccf,
- 0x2cd1, 0x2cd1,
- 0x2cd3, 0x2cd3,
- 0x2cd5, 0x2cd5,
- 0x2cd7, 0x2cd7,
- 0x2cd9, 0x2cd9,
- 0x2cdb, 0x2cdb,
- 0x2cdd, 0x2cdd,
- 0x2cdf, 0x2cdf,
- 0x2ce1, 0x2ce1,
- 0x2ce3, 0x2ce3,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69b,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa72f,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa76f,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa791, 0xa791,
- 0xa793, 0xa794,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c3, 0xa7c3,
- 0xab53, 0xab53,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 0x1e922, 0x1e943,
-}; /* CR_Changes_When_Uppercased */
-
-/* 'Changes_When_Titlecased': Derived Property */
-static const OnigCodePoint CR_Changes_When_Titlecased[] = {
- 615,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 0x00df, 0x00f6,
- 0x00f8, 0x00ff,
- 0x0101, 0x0101,
- 0x0103, 0x0103,
- 0x0105, 0x0105,
- 0x0107, 0x0107,
- 0x0109, 0x0109,
- 0x010b, 0x010b,
- 0x010d, 0x010d,
- 0x010f, 0x010f,
- 0x0111, 0x0111,
- 0x0113, 0x0113,
- 0x0115, 0x0115,
- 0x0117, 0x0117,
- 0x0119, 0x0119,
- 0x011b, 0x011b,
- 0x011d, 0x011d,
- 0x011f, 0x011f,
- 0x0121, 0x0121,
- 0x0123, 0x0123,
- 0x0125, 0x0125,
- 0x0127, 0x0127,
- 0x0129, 0x0129,
- 0x012b, 0x012b,
- 0x012d, 0x012d,
- 0x012f, 0x012f,
- 0x0131, 0x0131,
- 0x0133, 0x0133,
- 0x0135, 0x0135,
- 0x0137, 0x0137,
- 0x013a, 0x013a,
- 0x013c, 0x013c,
- 0x013e, 0x013e,
- 0x0140, 0x0140,
- 0x0142, 0x0142,
- 0x0144, 0x0144,
- 0x0146, 0x0146,
- 0x0148, 0x0149,
- 0x014b, 0x014b,
- 0x014d, 0x014d,
- 0x014f, 0x014f,
- 0x0151, 0x0151,
- 0x0153, 0x0153,
- 0x0155, 0x0155,
- 0x0157, 0x0157,
- 0x0159, 0x0159,
- 0x015b, 0x015b,
- 0x015d, 0x015d,
- 0x015f, 0x015f,
- 0x0161, 0x0161,
- 0x0163, 0x0163,
- 0x0165, 0x0165,
- 0x0167, 0x0167,
- 0x0169, 0x0169,
- 0x016b, 0x016b,
- 0x016d, 0x016d,
- 0x016f, 0x016f,
- 0x0171, 0x0171,
- 0x0173, 0x0173,
- 0x0175, 0x0175,
- 0x0177, 0x0177,
- 0x017a, 0x017a,
- 0x017c, 0x017c,
- 0x017e, 0x0180,
- 0x0183, 0x0183,
- 0x0185, 0x0185,
- 0x0188, 0x0188,
- 0x018c, 0x018c,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019a,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01b9,
- 0x01bd, 0x01bd,
- 0x01bf, 0x01bf,
- 0x01c4, 0x01c4,
- 0x01c6, 0x01c7,
- 0x01c9, 0x01ca,
- 0x01cc, 0x01cc,
- 0x01ce, 0x01ce,
- 0x01d0, 0x01d0,
- 0x01d2, 0x01d2,
- 0x01d4, 0x01d4,
- 0x01d6, 0x01d6,
- 0x01d8, 0x01d8,
- 0x01da, 0x01da,
- 0x01dc, 0x01dd,
- 0x01df, 0x01df,
- 0x01e1, 0x01e1,
- 0x01e3, 0x01e3,
- 0x01e5, 0x01e5,
- 0x01e7, 0x01e7,
- 0x01e9, 0x01e9,
- 0x01eb, 0x01eb,
- 0x01ed, 0x01ed,
- 0x01ef, 0x01f1,
- 0x01f3, 0x01f3,
- 0x01f5, 0x01f5,
- 0x01f9, 0x01f9,
- 0x01fb, 0x01fb,
- 0x01fd, 0x01fd,
- 0x01ff, 0x01ff,
- 0x0201, 0x0201,
- 0x0203, 0x0203,
- 0x0205, 0x0205,
- 0x0207, 0x0207,
- 0x0209, 0x0209,
- 0x020b, 0x020b,
- 0x020d, 0x020d,
- 0x020f, 0x020f,
- 0x0211, 0x0211,
- 0x0213, 0x0213,
- 0x0215, 0x0215,
- 0x0217, 0x0217,
- 0x0219, 0x0219,
- 0x021b, 0x021b,
- 0x021d, 0x021d,
- 0x021f, 0x021f,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0233,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0254,
- 0x0256, 0x0257,
- 0x0259, 0x0259,
- 0x025b, 0x025c,
- 0x0260, 0x0261,
- 0x0263, 0x0263,
- 0x0265, 0x0266,
- 0x0268, 0x026c,
- 0x026f, 0x026f,
- 0x0271, 0x0272,
- 0x0275, 0x0275,
- 0x027d, 0x027d,
- 0x0280, 0x0280,
- 0x0282, 0x0283,
- 0x0287, 0x028c,
- 0x0292, 0x0292,
- 0x029d, 0x029e,
- 0x0345, 0x0345,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037b, 0x037d,
- 0x0390, 0x0390,
- 0x03ac, 0x03ce,
- 0x03d0, 0x03d1,
- 0x03d5, 0x03d7,
- 0x03d9, 0x03d9,
- 0x03db, 0x03db,
- 0x03dd, 0x03dd,
- 0x03df, 0x03df,
- 0x03e1, 0x03e1,
- 0x03e3, 0x03e3,
- 0x03e5, 0x03e5,
- 0x03e7, 0x03e7,
- 0x03e9, 0x03e9,
- 0x03eb, 0x03eb,
- 0x03ed, 0x03ed,
- 0x03ef, 0x03f3,
- 0x03f5, 0x03f5,
- 0x03f8, 0x03f8,
- 0x03fb, 0x03fb,
- 0x0430, 0x045f,
- 0x0461, 0x0461,
- 0x0463, 0x0463,
- 0x0465, 0x0465,
- 0x0467, 0x0467,
- 0x0469, 0x0469,
- 0x046b, 0x046b,
- 0x046d, 0x046d,
- 0x046f, 0x046f,
- 0x0471, 0x0471,
- 0x0473, 0x0473,
- 0x0475, 0x0475,
- 0x0477, 0x0477,
- 0x0479, 0x0479,
- 0x047b, 0x047b,
- 0x047d, 0x047d,
- 0x047f, 0x047f,
- 0x0481, 0x0481,
- 0x048b, 0x048b,
- 0x048d, 0x048d,
- 0x048f, 0x048f,
- 0x0491, 0x0491,
- 0x0493, 0x0493,
- 0x0495, 0x0495,
- 0x0497, 0x0497,
- 0x0499, 0x0499,
- 0x049b, 0x049b,
- 0x049d, 0x049d,
- 0x049f, 0x049f,
- 0x04a1, 0x04a1,
- 0x04a3, 0x04a3,
- 0x04a5, 0x04a5,
- 0x04a7, 0x04a7,
- 0x04a9, 0x04a9,
- 0x04ab, 0x04ab,
- 0x04ad, 0x04ad,
- 0x04af, 0x04af,
- 0x04b1, 0x04b1,
- 0x04b3, 0x04b3,
- 0x04b5, 0x04b5,
- 0x04b7, 0x04b7,
- 0x04b9, 0x04b9,
- 0x04bb, 0x04bb,
- 0x04bd, 0x04bd,
- 0x04bf, 0x04bf,
- 0x04c2, 0x04c2,
- 0x04c4, 0x04c4,
- 0x04c6, 0x04c6,
- 0x04c8, 0x04c8,
- 0x04ca, 0x04ca,
- 0x04cc, 0x04cc,
- 0x04ce, 0x04cf,
- 0x04d1, 0x04d1,
- 0x04d3, 0x04d3,
- 0x04d5, 0x04d5,
- 0x04d7, 0x04d7,
- 0x04d9, 0x04d9,
- 0x04db, 0x04db,
- 0x04dd, 0x04dd,
- 0x04df, 0x04df,
- 0x04e1, 0x04e1,
- 0x04e3, 0x04e3,
- 0x04e5, 0x04e5,
- 0x04e7, 0x04e7,
- 0x04e9, 0x04e9,
- 0x04eb, 0x04eb,
- 0x04ed, 0x04ed,
- 0x04ef, 0x04ef,
- 0x04f1, 0x04f1,
- 0x04f3, 0x04f3,
- 0x04f5, 0x04f5,
- 0x04f7, 0x04f7,
- 0x04f9, 0x04f9,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0561, 0x0587,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d79, 0x1d79,
- 0x1d7d, 0x1d7d,
- 0x1d8e, 0x1d8e,
- 0x1e01, 0x1e01,
- 0x1e03, 0x1e03,
- 0x1e05, 0x1e05,
- 0x1e07, 0x1e07,
- 0x1e09, 0x1e09,
- 0x1e0b, 0x1e0b,
- 0x1e0d, 0x1e0d,
- 0x1e0f, 0x1e0f,
- 0x1e11, 0x1e11,
- 0x1e13, 0x1e13,
- 0x1e15, 0x1e15,
- 0x1e17, 0x1e17,
- 0x1e19, 0x1e19,
- 0x1e1b, 0x1e1b,
- 0x1e1d, 0x1e1d,
- 0x1e1f, 0x1e1f,
- 0x1e21, 0x1e21,
- 0x1e23, 0x1e23,
- 0x1e25, 0x1e25,
- 0x1e27, 0x1e27,
- 0x1e29, 0x1e29,
- 0x1e2b, 0x1e2b,
- 0x1e2d, 0x1e2d,
- 0x1e2f, 0x1e2f,
- 0x1e31, 0x1e31,
- 0x1e33, 0x1e33,
- 0x1e35, 0x1e35,
- 0x1e37, 0x1e37,
- 0x1e39, 0x1e39,
- 0x1e3b, 0x1e3b,
- 0x1e3d, 0x1e3d,
- 0x1e3f, 0x1e3f,
- 0x1e41, 0x1e41,
- 0x1e43, 0x1e43,
- 0x1e45, 0x1e45,
- 0x1e47, 0x1e47,
- 0x1e49, 0x1e49,
- 0x1e4b, 0x1e4b,
- 0x1e4d, 0x1e4d,
- 0x1e4f, 0x1e4f,
- 0x1e51, 0x1e51,
- 0x1e53, 0x1e53,
- 0x1e55, 0x1e55,
- 0x1e57, 0x1e57,
- 0x1e59, 0x1e59,
- 0x1e5b, 0x1e5b,
- 0x1e5d, 0x1e5d,
- 0x1e5f, 0x1e5f,
- 0x1e61, 0x1e61,
- 0x1e63, 0x1e63,
- 0x1e65, 0x1e65,
- 0x1e67, 0x1e67,
- 0x1e69, 0x1e69,
- 0x1e6b, 0x1e6b,
- 0x1e6d, 0x1e6d,
- 0x1e6f, 0x1e6f,
- 0x1e71, 0x1e71,
- 0x1e73, 0x1e73,
- 0x1e75, 0x1e75,
- 0x1e77, 0x1e77,
- 0x1e79, 0x1e79,
- 0x1e7b, 0x1e7b,
- 0x1e7d, 0x1e7d,
- 0x1e7f, 0x1e7f,
- 0x1e81, 0x1e81,
- 0x1e83, 0x1e83,
- 0x1e85, 0x1e85,
- 0x1e87, 0x1e87,
- 0x1e89, 0x1e89,
- 0x1e8b, 0x1e8b,
- 0x1e8d, 0x1e8d,
- 0x1e8f, 0x1e8f,
- 0x1e91, 0x1e91,
- 0x1e93, 0x1e93,
- 0x1e95, 0x1e9b,
- 0x1ea1, 0x1ea1,
- 0x1ea3, 0x1ea3,
- 0x1ea5, 0x1ea5,
- 0x1ea7, 0x1ea7,
- 0x1ea9, 0x1ea9,
- 0x1eab, 0x1eab,
- 0x1ead, 0x1ead,
- 0x1eaf, 0x1eaf,
- 0x1eb1, 0x1eb1,
- 0x1eb3, 0x1eb3,
- 0x1eb5, 0x1eb5,
- 0x1eb7, 0x1eb7,
- 0x1eb9, 0x1eb9,
- 0x1ebb, 0x1ebb,
- 0x1ebd, 0x1ebd,
- 0x1ebf, 0x1ebf,
- 0x1ec1, 0x1ec1,
- 0x1ec3, 0x1ec3,
- 0x1ec5, 0x1ec5,
- 0x1ec7, 0x1ec7,
- 0x1ec9, 0x1ec9,
- 0x1ecb, 0x1ecb,
- 0x1ecd, 0x1ecd,
- 0x1ecf, 0x1ecf,
- 0x1ed1, 0x1ed1,
- 0x1ed3, 0x1ed3,
- 0x1ed5, 0x1ed5,
- 0x1ed7, 0x1ed7,
- 0x1ed9, 0x1ed9,
- 0x1edb, 0x1edb,
- 0x1edd, 0x1edd,
- 0x1edf, 0x1edf,
- 0x1ee1, 0x1ee1,
- 0x1ee3, 0x1ee3,
- 0x1ee5, 0x1ee5,
- 0x1ee7, 0x1ee7,
- 0x1ee9, 0x1ee9,
- 0x1eeb, 0x1eeb,
- 0x1eed, 0x1eed,
- 0x1eef, 0x1eef,
- 0x1ef1, 0x1ef1,
- 0x1ef3, 0x1ef3,
- 0x1ef5, 0x1ef5,
- 0x1ef7, 0x1ef7,
- 0x1ef9, 0x1ef9,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 0x1f07,
- 0x1f10, 0x1f15,
- 0x1f20, 0x1f27,
- 0x1f30, 0x1f37,
- 0x1f40, 0x1f45,
- 0x1f50, 0x1f57,
- 0x1f60, 0x1f67,
- 0x1f70, 0x1f7d,
- 0x1f80, 0x1f87,
- 0x1f90, 0x1f97,
- 0x1fa0, 0x1fa7,
- 0x1fb0, 0x1fb4,
- 0x1fb6, 0x1fb7,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fc7,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fd7,
- 0x1fe0, 0x1fe7,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ff7,
- 0x214e, 0x214e,
- 0x2170, 0x217f,
- 0x2184, 0x2184,
- 0x24d0, 0x24e9,
- 0x2c30, 0x2c5e,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c73, 0x2c73,
- 0x2c76, 0x2c76,
- 0x2c81, 0x2c81,
- 0x2c83, 0x2c83,
- 0x2c85, 0x2c85,
- 0x2c87, 0x2c87,
- 0x2c89, 0x2c89,
- 0x2c8b, 0x2c8b,
- 0x2c8d, 0x2c8d,
- 0x2c8f, 0x2c8f,
- 0x2c91, 0x2c91,
- 0x2c93, 0x2c93,
- 0x2c95, 0x2c95,
- 0x2c97, 0x2c97,
- 0x2c99, 0x2c99,
- 0x2c9b, 0x2c9b,
- 0x2c9d, 0x2c9d,
- 0x2c9f, 0x2c9f,
- 0x2ca1, 0x2ca1,
- 0x2ca3, 0x2ca3,
- 0x2ca5, 0x2ca5,
- 0x2ca7, 0x2ca7,
- 0x2ca9, 0x2ca9,
- 0x2cab, 0x2cab,
- 0x2cad, 0x2cad,
- 0x2caf, 0x2caf,
- 0x2cb1, 0x2cb1,
- 0x2cb3, 0x2cb3,
- 0x2cb5, 0x2cb5,
- 0x2cb7, 0x2cb7,
- 0x2cb9, 0x2cb9,
- 0x2cbb, 0x2cbb,
- 0x2cbd, 0x2cbd,
- 0x2cbf, 0x2cbf,
- 0x2cc1, 0x2cc1,
- 0x2cc3, 0x2cc3,
- 0x2cc5, 0x2cc5,
- 0x2cc7, 0x2cc7,
- 0x2cc9, 0x2cc9,
- 0x2ccb, 0x2ccb,
- 0x2ccd, 0x2ccd,
- 0x2ccf, 0x2ccf,
- 0x2cd1, 0x2cd1,
- 0x2cd3, 0x2cd3,
- 0x2cd5, 0x2cd5,
- 0x2cd7, 0x2cd7,
- 0x2cd9, 0x2cd9,
- 0x2cdb, 0x2cdb,
- 0x2cdd, 0x2cdd,
- 0x2cdf, 0x2cdf,
- 0x2ce1, 0x2ce1,
- 0x2ce3, 0x2ce3,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69b,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa72f,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa76f,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa791, 0xa791,
- 0xa793, 0xa794,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c3, 0xa7c3,
- 0xab53, 0xab53,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 0x1e922, 0x1e943,
-}; /* CR_Changes_When_Titlecased */
-
-/* 'Changes_When_Casefolded': Derived Property */
-static const OnigCodePoint CR_Changes_When_Casefolded[] = {
- 612,
- 0x0041, 0x005a,
- 0x00b5, 0x00b5,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00df,
- 0x0100, 0x0100,
- 0x0102, 0x0102,
- 0x0104, 0x0104,
- 0x0106, 0x0106,
- 0x0108, 0x0108,
- 0x010a, 0x010a,
- 0x010c, 0x010c,
- 0x010e, 0x010e,
- 0x0110, 0x0110,
- 0x0112, 0x0112,
- 0x0114, 0x0114,
- 0x0116, 0x0116,
- 0x0118, 0x0118,
- 0x011a, 0x011a,
- 0x011c, 0x011c,
- 0x011e, 0x011e,
- 0x0120, 0x0120,
- 0x0122, 0x0122,
- 0x0124, 0x0124,
- 0x0126, 0x0126,
- 0x0128, 0x0128,
- 0x012a, 0x012a,
- 0x012c, 0x012c,
- 0x012e, 0x012e,
- 0x0130, 0x0130,
- 0x0132, 0x0132,
- 0x0134, 0x0134,
- 0x0136, 0x0136,
- 0x0139, 0x0139,
- 0x013b, 0x013b,
- 0x013d, 0x013d,
- 0x013f, 0x013f,
- 0x0141, 0x0141,
- 0x0143, 0x0143,
- 0x0145, 0x0145,
- 0x0147, 0x0147,
- 0x0149, 0x014a,
- 0x014c, 0x014c,
- 0x014e, 0x014e,
- 0x0150, 0x0150,
- 0x0152, 0x0152,
- 0x0154, 0x0154,
- 0x0156, 0x0156,
- 0x0158, 0x0158,
- 0x015a, 0x015a,
- 0x015c, 0x015c,
- 0x015e, 0x015e,
- 0x0160, 0x0160,
- 0x0162, 0x0162,
- 0x0164, 0x0164,
- 0x0166, 0x0166,
- 0x0168, 0x0168,
- 0x016a, 0x016a,
- 0x016c, 0x016c,
- 0x016e, 0x016e,
- 0x0170, 0x0170,
- 0x0172, 0x0172,
- 0x0174, 0x0174,
- 0x0176, 0x0176,
- 0x0178, 0x0179,
- 0x017b, 0x017b,
- 0x017d, 0x017d,
- 0x017f, 0x017f,
- 0x0181, 0x0182,
- 0x0184, 0x0184,
- 0x0186, 0x0187,
- 0x0189, 0x018b,
- 0x018e, 0x0191,
- 0x0193, 0x0194,
- 0x0196, 0x0198,
- 0x019c, 0x019d,
- 0x019f, 0x01a0,
- 0x01a2, 0x01a2,
- 0x01a4, 0x01a4,
- 0x01a6, 0x01a7,
- 0x01a9, 0x01a9,
- 0x01ac, 0x01ac,
- 0x01ae, 0x01af,
- 0x01b1, 0x01b3,
- 0x01b5, 0x01b5,
- 0x01b7, 0x01b8,
- 0x01bc, 0x01bc,
- 0x01c4, 0x01c5,
- 0x01c7, 0x01c8,
- 0x01ca, 0x01cb,
- 0x01cd, 0x01cd,
- 0x01cf, 0x01cf,
- 0x01d1, 0x01d1,
- 0x01d3, 0x01d3,
- 0x01d5, 0x01d5,
- 0x01d7, 0x01d7,
- 0x01d9, 0x01d9,
- 0x01db, 0x01db,
- 0x01de, 0x01de,
- 0x01e0, 0x01e0,
- 0x01e2, 0x01e2,
- 0x01e4, 0x01e4,
- 0x01e6, 0x01e6,
- 0x01e8, 0x01e8,
- 0x01ea, 0x01ea,
- 0x01ec, 0x01ec,
- 0x01ee, 0x01ee,
- 0x01f1, 0x01f2,
- 0x01f4, 0x01f4,
- 0x01f6, 0x01f8,
- 0x01fa, 0x01fa,
- 0x01fc, 0x01fc,
- 0x01fe, 0x01fe,
- 0x0200, 0x0200,
- 0x0202, 0x0202,
- 0x0204, 0x0204,
- 0x0206, 0x0206,
- 0x0208, 0x0208,
- 0x020a, 0x020a,
- 0x020c, 0x020c,
- 0x020e, 0x020e,
- 0x0210, 0x0210,
- 0x0212, 0x0212,
- 0x0214, 0x0214,
- 0x0216, 0x0216,
- 0x0218, 0x0218,
- 0x021a, 0x021a,
- 0x021c, 0x021c,
- 0x021e, 0x021e,
- 0x0220, 0x0220,
- 0x0222, 0x0222,
- 0x0224, 0x0224,
- 0x0226, 0x0226,
- 0x0228, 0x0228,
- 0x022a, 0x022a,
- 0x022c, 0x022c,
- 0x022e, 0x022e,
- 0x0230, 0x0230,
- 0x0232, 0x0232,
- 0x023a, 0x023b,
- 0x023d, 0x023e,
- 0x0241, 0x0241,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0345, 0x0345,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03c2, 0x03c2,
- 0x03cf, 0x03d1,
- 0x03d5, 0x03d6,
- 0x03d8, 0x03d8,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03e2,
- 0x03e4, 0x03e4,
- 0x03e6, 0x03e6,
- 0x03e8, 0x03e8,
- 0x03ea, 0x03ea,
- 0x03ec, 0x03ec,
- 0x03ee, 0x03ee,
- 0x03f0, 0x03f1,
- 0x03f4, 0x03f5,
- 0x03f7, 0x03f7,
- 0x03f9, 0x03fa,
- 0x03fd, 0x042f,
- 0x0460, 0x0460,
- 0x0462, 0x0462,
- 0x0464, 0x0464,
- 0x0466, 0x0466,
- 0x0468, 0x0468,
- 0x046a, 0x046a,
- 0x046c, 0x046c,
- 0x046e, 0x046e,
- 0x0470, 0x0470,
- 0x0472, 0x0472,
- 0x0474, 0x0474,
- 0x0476, 0x0476,
- 0x0478, 0x0478,
- 0x047a, 0x047a,
- 0x047c, 0x047c,
- 0x047e, 0x047e,
- 0x0480, 0x0480,
- 0x048a, 0x048a,
- 0x048c, 0x048c,
- 0x048e, 0x048e,
- 0x0490, 0x0490,
- 0x0492, 0x0492,
- 0x0494, 0x0494,
- 0x0496, 0x0496,
- 0x0498, 0x0498,
- 0x049a, 0x049a,
- 0x049c, 0x049c,
- 0x049e, 0x049e,
- 0x04a0, 0x04a0,
- 0x04a2, 0x04a2,
- 0x04a4, 0x04a4,
- 0x04a6, 0x04a6,
- 0x04a8, 0x04a8,
- 0x04aa, 0x04aa,
- 0x04ac, 0x04ac,
- 0x04ae, 0x04ae,
- 0x04b0, 0x04b0,
- 0x04b2, 0x04b2,
- 0x04b4, 0x04b4,
- 0x04b6, 0x04b6,
- 0x04b8, 0x04b8,
- 0x04ba, 0x04ba,
- 0x04bc, 0x04bc,
- 0x04be, 0x04be,
- 0x04c0, 0x04c1,
- 0x04c3, 0x04c3,
- 0x04c5, 0x04c5,
- 0x04c7, 0x04c7,
- 0x04c9, 0x04c9,
- 0x04cb, 0x04cb,
- 0x04cd, 0x04cd,
- 0x04d0, 0x04d0,
- 0x04d2, 0x04d2,
- 0x04d4, 0x04d4,
- 0x04d6, 0x04d6,
- 0x04d8, 0x04d8,
- 0x04da, 0x04da,
- 0x04dc, 0x04dc,
- 0x04de, 0x04de,
- 0x04e0, 0x04e0,
- 0x04e2, 0x04e2,
- 0x04e4, 0x04e4,
- 0x04e6, 0x04e6,
- 0x04e8, 0x04e8,
- 0x04ea, 0x04ea,
- 0x04ec, 0x04ec,
- 0x04ee, 0x04ee,
- 0x04f0, 0x04f0,
- 0x04f2, 0x04f2,
- 0x04f4, 0x04f4,
- 0x04f6, 0x04f6,
- 0x04f8, 0x04f8,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x0587, 0x0587,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1e00, 0x1e00,
- 0x1e02, 0x1e02,
- 0x1e04, 0x1e04,
- 0x1e06, 0x1e06,
- 0x1e08, 0x1e08,
- 0x1e0a, 0x1e0a,
- 0x1e0c, 0x1e0c,
- 0x1e0e, 0x1e0e,
- 0x1e10, 0x1e10,
- 0x1e12, 0x1e12,
- 0x1e14, 0x1e14,
- 0x1e16, 0x1e16,
- 0x1e18, 0x1e18,
- 0x1e1a, 0x1e1a,
- 0x1e1c, 0x1e1c,
- 0x1e1e, 0x1e1e,
- 0x1e20, 0x1e20,
- 0x1e22, 0x1e22,
- 0x1e24, 0x1e24,
- 0x1e26, 0x1e26,
- 0x1e28, 0x1e28,
- 0x1e2a, 0x1e2a,
- 0x1e2c, 0x1e2c,
- 0x1e2e, 0x1e2e,
- 0x1e30, 0x1e30,
- 0x1e32, 0x1e32,
- 0x1e34, 0x1e34,
- 0x1e36, 0x1e36,
- 0x1e38, 0x1e38,
- 0x1e3a, 0x1e3a,
- 0x1e3c, 0x1e3c,
- 0x1e3e, 0x1e3e,
- 0x1e40, 0x1e40,
- 0x1e42, 0x1e42,
- 0x1e44, 0x1e44,
- 0x1e46, 0x1e46,
- 0x1e48, 0x1e48,
- 0x1e4a, 0x1e4a,
- 0x1e4c, 0x1e4c,
- 0x1e4e, 0x1e4e,
- 0x1e50, 0x1e50,
- 0x1e52, 0x1e52,
- 0x1e54, 0x1e54,
- 0x1e56, 0x1e56,
- 0x1e58, 0x1e58,
- 0x1e5a, 0x1e5a,
- 0x1e5c, 0x1e5c,
- 0x1e5e, 0x1e5e,
- 0x1e60, 0x1e60,
- 0x1e62, 0x1e62,
- 0x1e64, 0x1e64,
- 0x1e66, 0x1e66,
- 0x1e68, 0x1e68,
- 0x1e6a, 0x1e6a,
- 0x1e6c, 0x1e6c,
- 0x1e6e, 0x1e6e,
- 0x1e70, 0x1e70,
- 0x1e72, 0x1e72,
- 0x1e74, 0x1e74,
- 0x1e76, 0x1e76,
- 0x1e78, 0x1e78,
- 0x1e7a, 0x1e7a,
- 0x1e7c, 0x1e7c,
- 0x1e7e, 0x1e7e,
- 0x1e80, 0x1e80,
- 0x1e82, 0x1e82,
- 0x1e84, 0x1e84,
- 0x1e86, 0x1e86,
- 0x1e88, 0x1e88,
- 0x1e8a, 0x1e8a,
- 0x1e8c, 0x1e8c,
- 0x1e8e, 0x1e8e,
- 0x1e90, 0x1e90,
- 0x1e92, 0x1e92,
- 0x1e94, 0x1e94,
- 0x1e9a, 0x1e9b,
- 0x1e9e, 0x1e9e,
- 0x1ea0, 0x1ea0,
- 0x1ea2, 0x1ea2,
- 0x1ea4, 0x1ea4,
- 0x1ea6, 0x1ea6,
- 0x1ea8, 0x1ea8,
- 0x1eaa, 0x1eaa,
- 0x1eac, 0x1eac,
- 0x1eae, 0x1eae,
- 0x1eb0, 0x1eb0,
- 0x1eb2, 0x1eb2,
- 0x1eb4, 0x1eb4,
- 0x1eb6, 0x1eb6,
- 0x1eb8, 0x1eb8,
- 0x1eba, 0x1eba,
- 0x1ebc, 0x1ebc,
- 0x1ebe, 0x1ebe,
- 0x1ec0, 0x1ec0,
- 0x1ec2, 0x1ec2,
- 0x1ec4, 0x1ec4,
- 0x1ec6, 0x1ec6,
- 0x1ec8, 0x1ec8,
- 0x1eca, 0x1eca,
- 0x1ecc, 0x1ecc,
- 0x1ece, 0x1ece,
- 0x1ed0, 0x1ed0,
- 0x1ed2, 0x1ed2,
- 0x1ed4, 0x1ed4,
- 0x1ed6, 0x1ed6,
- 0x1ed8, 0x1ed8,
- 0x1eda, 0x1eda,
- 0x1edc, 0x1edc,
- 0x1ede, 0x1ede,
- 0x1ee0, 0x1ee0,
- 0x1ee2, 0x1ee2,
- 0x1ee4, 0x1ee4,
- 0x1ee6, 0x1ee6,
- 0x1ee8, 0x1ee8,
- 0x1eea, 0x1eea,
- 0x1eec, 0x1eec,
- 0x1eee, 0x1eee,
- 0x1ef0, 0x1ef0,
- 0x1ef2, 0x1ef2,
- 0x1ef4, 0x1ef4,
- 0x1ef6, 0x1ef6,
- 0x1ef8, 0x1ef8,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1f80, 0x1faf,
- 0x1fb2, 0x1fb4,
- 0x1fb7, 0x1fbc,
- 0x1fc2, 0x1fc4,
- 0x1fc7, 0x1fcc,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff7, 0x1ffc,
- 0x2126, 0x2126,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x2160, 0x216f,
- 0x2183, 0x2183,
- 0x24b6, 0x24cf,
- 0x2c00, 0x2c2e,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 0x2c80,
- 0x2c82, 0x2c82,
- 0x2c84, 0x2c84,
- 0x2c86, 0x2c86,
- 0x2c88, 0x2c88,
- 0x2c8a, 0x2c8a,
- 0x2c8c, 0x2c8c,
- 0x2c8e, 0x2c8e,
- 0x2c90, 0x2c90,
- 0x2c92, 0x2c92,
- 0x2c94, 0x2c94,
- 0x2c96, 0x2c96,
- 0x2c98, 0x2c98,
- 0x2c9a, 0x2c9a,
- 0x2c9c, 0x2c9c,
- 0x2c9e, 0x2c9e,
- 0x2ca0, 0x2ca0,
- 0x2ca2, 0x2ca2,
- 0x2ca4, 0x2ca4,
- 0x2ca6, 0x2ca6,
- 0x2ca8, 0x2ca8,
- 0x2caa, 0x2caa,
- 0x2cac, 0x2cac,
- 0x2cae, 0x2cae,
- 0x2cb0, 0x2cb0,
- 0x2cb2, 0x2cb2,
- 0x2cb4, 0x2cb4,
- 0x2cb6, 0x2cb6,
- 0x2cb8, 0x2cb8,
- 0x2cba, 0x2cba,
- 0x2cbc, 0x2cbc,
- 0x2cbe, 0x2cbe,
- 0x2cc0, 0x2cc0,
- 0x2cc2, 0x2cc2,
- 0x2cc4, 0x2cc4,
- 0x2cc6, 0x2cc6,
- 0x2cc8, 0x2cc8,
- 0x2cca, 0x2cca,
- 0x2ccc, 0x2ccc,
- 0x2cce, 0x2cce,
- 0x2cd0, 0x2cd0,
- 0x2cd2, 0x2cd2,
- 0x2cd4, 0x2cd4,
- 0x2cd6, 0x2cd6,
- 0x2cd8, 0x2cd8,
- 0x2cda, 0x2cda,
- 0x2cdc, 0x2cdc,
- 0x2cde, 0x2cde,
- 0x2ce0, 0x2ce0,
- 0x2ce2, 0x2ce2,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c6,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 0x1e900, 0x1e921,
-}; /* CR_Changes_When_Casefolded */
-
-/* 'Changes_When_Casemapped': Derived Property */
-static const OnigCodePoint CR_Changes_When_Casemapped[] = {
- 123,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x0137,
- 0x0139, 0x018c,
- 0x018e, 0x019a,
- 0x019c, 0x01a9,
- 0x01ac, 0x01b9,
- 0x01bc, 0x01bd,
- 0x01bf, 0x01bf,
- 0x01c4, 0x0220,
- 0x0222, 0x0233,
- 0x023a, 0x0254,
- 0x0256, 0x0257,
- 0x0259, 0x0259,
- 0x025b, 0x025c,
- 0x0260, 0x0261,
- 0x0263, 0x0263,
- 0x0265, 0x0266,
- 0x0268, 0x026c,
- 0x026f, 0x026f,
- 0x0271, 0x0272,
- 0x0275, 0x0275,
- 0x027d, 0x027d,
- 0x0280, 0x0280,
- 0x0282, 0x0283,
- 0x0287, 0x028c,
- 0x0292, 0x0292,
- 0x029d, 0x029e,
- 0x0345, 0x0345,
- 0x0370, 0x0373,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03d1,
- 0x03d5, 0x03f5,
- 0x03f7, 0x03fb,
- 0x03fd, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0561, 0x0587,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1d79, 0x1d79,
- 0x1d7d, 0x1d7d,
- 0x1d8e, 0x1d8e,
- 0x1e00, 0x1e9b,
- 0x1e9e, 0x1e9e,
- 0x1ea0, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2126, 0x2126,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x214e, 0x214e,
- 0x2160, 0x217f,
- 0x2183, 0x2184,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2c70,
- 0x2c72, 0x2c73,
- 0x2c75, 0x2c76,
- 0x2c7e, 0x2ce3,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa640, 0xa66d,
- 0xa680, 0xa69b,
- 0xa722, 0xa72f,
- 0xa732, 0xa76f,
- 0xa779, 0xa787,
- 0xa78b, 0xa78d,
- 0xa790, 0xa794,
- 0xa796, 0xa7ae,
- 0xa7b0, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xab53, 0xab53,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0x10400, 0x1044f,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x118a0, 0x118df,
- 0x16e40, 0x16e7f,
- 0x1e900, 0x1e943,
-}; /* CR_Changes_When_Casemapped */
-
-/* 'ID_Start': Derived Property */
-static const OnigCodePoint CR_ID_Start[] = {
- 609,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06e5, 0x06e6,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0971, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a72, 0x0a74,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0abd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0af9, 0x0af9,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b71, 0x0b71,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e46,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1711,
- 0x1720, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1aa7, 0x1aa7,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4b,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309b, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa67f, 0xa69d,
- 0xa6a0, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9e4,
- 0xa9e6, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf4,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d23,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x1145f,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11800, 0x1182b,
- 0x118a0, 0x118df,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2eb,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_ID_Start */
-
-/* 'ID_Continue': Derived Property */
-static const OnigCodePoint CR_ID_Continue[] = {
- 713,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x005f, 0x005f,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00b7, 0x00b7,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0300, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x0487,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06df, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0800, 0x082d,
- 0x0840, 0x085b,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x08e1,
- 0x08e3, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09f1,
- 0x09fc, 0x09fc,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b6f,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f29,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x135f,
- 0x1369, 0x1371,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x180b, 0x180d,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1abd,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b59,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1bf3,
- 0x1c00, 0x1c37,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x203f, 0x2040,
- 0x2054, 0x2054,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20f0,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x3005, 0x3007,
- 0x3021, 0x302f,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa66f,
- 0xa674, 0xa67d,
- 0xa67f, 0xa6f1,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa827,
- 0xa840, 0xa873,
- 0xa880, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8e0, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92d,
- 0xa930, 0xa953,
- 0xa960, 0xa97c,
- 0xa980, 0xa9c0,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabea,
- 0xabec, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xfe33, 0xfe34,
- 0xfe4d, 0xfe4f,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff10, 0xff19,
- 0xff21, 0xff3a,
- 0xff3f, 0xff3f,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10140, 0x10174,
- 0x101fd, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102e0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae6,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f50,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11046,
- 0x11066, 0x1106f,
- 0x1107f, 0x110ba,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x1113f,
- 0x11144, 0x11146,
- 0x11150, 0x11173,
- 0x11176, 0x11176,
- 0x11180, 0x111c4,
- 0x111c9, 0x111cc,
- 0x111d0, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11237,
- 0x1123e, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1144a,
- 0x11450, 0x11459,
- 0x1145e, 0x1145f,
- 0x11480, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115d8, 0x115dd,
- 0x11600, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11739,
- 0x11800, 0x1183a,
- 0x118a0, 0x118e9,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a50, 0x11a99,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af4,
- 0x16b00, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9d, 0x1bc9e,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2f9,
- 0x1e800, 0x1e8c4,
- 0x1e8d0, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0xe0100, 0xe01ef,
-}; /* CR_ID_Continue */
-
-/* 'XID_Start': Derived Property */
-static const OnigCodePoint CR_XID_Start[] = {
- 616,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06e5, 0x06e6,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0971, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a72, 0x0a74,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0abd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0af9, 0x0af9,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b71, 0x0b71,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e32,
- 0x0e40, 0x0e46,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb2,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1711,
- 0x1720, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1aa7, 0x1aa7,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4b,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa67f, 0xa69d,
- 0xa6a0, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9e4,
- 0xa9e6, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf4,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfc5d,
- 0xfc64, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdf9,
- 0xfe71, 0xfe71,
- 0xfe73, 0xfe73,
- 0xfe77, 0xfe77,
- 0xfe79, 0xfe79,
- 0xfe7b, 0xfe7b,
- 0xfe7d, 0xfe7d,
- 0xfe7f, 0xfefc,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xff9d,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d23,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x1145f,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11800, 0x1182b,
- 0x118a0, 0x118df,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2eb,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_XID_Start */
-
-/* 'XID_Continue': Derived Property */
-static const OnigCodePoint CR_XID_Continue[] = {
- 720,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x005f, 0x005f,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00b7, 0x00b7,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0300, 0x0374,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x0487,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06df, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0800, 0x082d,
- 0x0840, 0x085b,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x08e1,
- 0x08e3, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09f1,
- 0x09fc, 0x09fc,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b6f,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f29,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x135f,
- 0x1369, 0x1371,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x180b, 0x180d,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1abd,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b59,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1bf3,
- 0x1c00, 0x1c37,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x203f, 0x2040,
- 0x2054, 0x2054,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20f0,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2ce4,
- 0x2ceb, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x3005, 0x3007,
- 0x3021, 0x302f,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309a,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31ba,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xa000, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa66f,
- 0xa674, 0xa67d,
- 0xa67f, 0xa6f1,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa827,
- 0xa840, 0xa873,
- 0xa880, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8e0, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92d,
- 0xa930, 0xa953,
- 0xa960, 0xa97c,
- 0xa980, 0xa9c0,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab67,
- 0xab70, 0xabea,
- 0xabec, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfc5d,
- 0xfc64, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdf9,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xfe33, 0xfe34,
- 0xfe4d, 0xfe4f,
- 0xfe71, 0xfe71,
- 0xfe73, 0xfe73,
- 0xfe77, 0xfe77,
- 0xfe79, 0xfe79,
- 0xfe7b, 0xfe7b,
- 0xfe7d, 0xfe7d,
- 0xfe7f, 0xfefc,
- 0xff10, 0xff19,
- 0xff21, 0xff3a,
- 0xff3f, 0xff3f,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10140, 0x10174,
- 0x101fd, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102e0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae6,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f50,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11046,
- 0x11066, 0x1106f,
- 0x1107f, 0x110ba,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x1113f,
- 0x11144, 0x11146,
- 0x11150, 0x11173,
- 0x11176, 0x11176,
- 0x11180, 0x111c4,
- 0x111c9, 0x111cc,
- 0x111d0, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11237,
- 0x1123e, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1144a,
- 0x11450, 0x11459,
- 0x1145e, 0x1145f,
- 0x11480, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115d8, 0x115dd,
- 0x11600, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11739,
- 0x11800, 0x1183a,
- 0x118a0, 0x118e9,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a50, 0x11a99,
- 0x11a9d, 0x11a9d,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af4,
- 0x16b00, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9d, 0x1bc9e,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e2c0, 0x1e2f9,
- 0x1e800, 0x1e8c4,
- 0x1e8d0, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0xe0100, 0xe01ef,
-}; /* CR_XID_Continue */
-
-/* 'Default_Ignorable_Code_Point': Derived Property */
-static const OnigCodePoint CR_Default_Ignorable_Code_Point[] = {
- 17,
- 0x00ad, 0x00ad,
- 0x034f, 0x034f,
- 0x061c, 0x061c,
- 0x115f, 0x1160,
- 0x17b4, 0x17b5,
- 0x180b, 0x180e,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x206f,
- 0x3164, 0x3164,
- 0xfe00, 0xfe0f,
- 0xfeff, 0xfeff,
- 0xffa0, 0xffa0,
- 0xfff0, 0xfff8,
- 0x1bca0, 0x1bca3,
- 0x1d173, 0x1d17a,
- 0xe0000, 0xe0fff,
-}; /* CR_Default_Ignorable_Code_Point */
-
-/* 'Grapheme_Extend': Derived Property */
-static const OnigCodePoint CR_Grapheme_Extend[] = {
- 335,
- 0x0300, 0x036f,
- 0x0483, 0x0489,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x08d3, 0x08e1,
- 0x08e3, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09be, 0x09be,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3e, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bbe,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc2, 0x0cc2,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d3e, 0x0d3e,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dcf,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0ddf, 0x0ddf,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ecd,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1df9,
- 0x1dfb, 0x1dff,
- 0x200c, 0x200c,
- 0x20d0, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaec, 0xaaed,
- 0xaaf6, 0xaaf6,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xff9e, 0xff9f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10f46, 0x10f50,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x1133e, 0x1133e,
- 0x11340, 0x11340,
- 0x11357, 0x11357,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b0, 0x114b0,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bd, 0x114bd,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115af, 0x115af,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f92,
- 0x1bc9d, 0x1bc9e,
- 0x1d165, 0x1d165,
- 0x1d167, 0x1d169,
- 0x1d16e, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e130, 0x1e136,
- 0x1e2ec, 0x1e2ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
-}; /* CR_Grapheme_Extend */
-
-/* 'Grapheme_Base': Derived Property */
-static const OnigCodePoint CR_Grapheme_Base[] = {
- 819,
- 0x0020, 0x007e,
- 0x00a0, 0x00ac,
- 0x00ae, 0x02ff,
- 0x0370, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0482,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0606, 0x060f,
- 0x061b, 0x061b,
- 0x061e, 0x064a,
- 0x0660, 0x066f,
- 0x0671, 0x06d5,
- 0x06de, 0x06de,
- 0x06e5, 0x06e6,
- 0x06e9, 0x06e9,
- 0x06ee, 0x070d,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07c0, 0x07ea,
- 0x07f4, 0x07fa,
- 0x07fe, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0830, 0x083e,
- 0x0840, 0x0858,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x0903, 0x0939,
- 0x093b, 0x093b,
- 0x093d, 0x0940,
- 0x0949, 0x094c,
- 0x094e, 0x0950,
- 0x0958, 0x0961,
- 0x0964, 0x0980,
- 0x0982, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09bf, 0x09c0,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09e6, 0x09fd,
- 0x0a03, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3e, 0x0a40,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a6f,
- 0x0a72, 0x0a74,
- 0x0a76, 0x0a76,
- 0x0a83, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0ac0,
- 0x0ac9, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0af9,
- 0x0b02, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b40, 0x0b40,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b77,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbf, 0x0bbf,
- 0x0bc1, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd0, 0x0bd0,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c41, 0x0c44,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c80,
- 0x0c82, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbe,
- 0x0cc0, 0x0cc1,
- 0x0cc3, 0x0cc4,
- 0x0cc7, 0x0cc8,
- 0x0cca, 0x0ccb,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d3f, 0x0d40,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d4e, 0x0d4f,
- 0x0d54, 0x0d56,
- 0x0d58, 0x0d61,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dd0, 0x0dd1,
- 0x0dd8, 0x0dde,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e3f, 0x0e46,
- 0x0e4f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f17,
- 0x0f1a, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0f3a, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f7f, 0x0f7f,
- 0x0f85, 0x0f85,
- 0x0f88, 0x0f8c,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x102c,
- 0x1031, 0x1031,
- 0x1038, 0x1038,
- 0x103b, 0x103c,
- 0x103f, 0x1057,
- 0x105a, 0x105d,
- 0x1061, 0x1070,
- 0x1075, 0x1081,
- 0x1083, 0x1084,
- 0x1087, 0x108c,
- 0x108e, 0x109c,
- 0x109e, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1360, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1711,
- 0x1720, 0x1731,
- 0x1735, 0x1736,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17b6, 0x17b6,
- 0x17be, 0x17c5,
- 0x17c7, 0x17c8,
- 0x17d4, 0x17dc,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180a,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x1884,
- 0x1887, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1923, 0x1926,
- 0x1929, 0x192b,
- 0x1930, 0x1931,
- 0x1933, 0x1938,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a16,
- 0x1a19, 0x1a1a,
- 0x1a1e, 0x1a55,
- 0x1a57, 0x1a57,
- 0x1a61, 0x1a61,
- 0x1a63, 0x1a64,
- 0x1a6d, 0x1a72,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b04, 0x1b33,
- 0x1b3b, 0x1b3b,
- 0x1b3d, 0x1b41,
- 0x1b43, 0x1b4b,
- 0x1b50, 0x1b6a,
- 0x1b74, 0x1b7c,
- 0x1b82, 0x1ba1,
- 0x1ba6, 0x1ba7,
- 0x1baa, 0x1baa,
- 0x1bae, 0x1be5,
- 0x1be7, 0x1be7,
- 0x1bea, 0x1bec,
- 0x1bee, 0x1bee,
- 0x1bf2, 0x1bf3,
- 0x1bfc, 0x1c2b,
- 0x1c34, 0x1c35,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x1ce1, 0x1ce1,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf7,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x200a,
- 0x2010, 0x2027,
- 0x202f, 0x205f,
- 0x2070, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e00, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x3029,
- 0x3030, 0x303f,
- 0x3041, 0x3096,
- 0x309b, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa66e,
- 0xa673, 0xa673,
- 0xa67e, 0xa69d,
- 0xa6a0, 0xa6ef,
- 0xa6f2, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa824,
- 0xa827, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c3,
- 0xa8ce, 0xa8d9,
- 0xa8f2, 0xa8fe,
- 0xa900, 0xa925,
- 0xa92e, 0xa946,
- 0xa952, 0xa953,
- 0xa95f, 0xa97c,
- 0xa983, 0xa9b2,
- 0xa9b4, 0xa9b5,
- 0xa9ba, 0xa9bb,
- 0xa9be, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9e4,
- 0xa9e6, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa2f, 0xaa30,
- 0xaa33, 0xaa34,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa4d, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa7d, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaaeb,
- 0xaaee, 0xaaf5,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabe4,
- 0xabe6, 0xabe7,
- 0xabe9, 0xabec,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff01, 0xff9d,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffc, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fc,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e1, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a40, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae4,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d23,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f51, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11000,
- 0x11002, 0x11037,
- 0x11047, 0x1104d,
- 0x11052, 0x1106f,
- 0x11082, 0x110b2,
- 0x110b7, 0x110b8,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11103, 0x11126,
- 0x1112c, 0x1112c,
- 0x11136, 0x11146,
- 0x11150, 0x11172,
- 0x11174, 0x11176,
- 0x11182, 0x111b5,
- 0x111bf, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1122e,
- 0x11232, 0x11233,
- 0x11235, 0x11235,
- 0x11238, 0x1123d,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112de,
- 0x112e0, 0x112e2,
- 0x112f0, 0x112f9,
- 0x11302, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x1133f, 0x1133f,
- 0x11341, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x1135d, 0x11363,
- 0x11400, 0x11437,
- 0x11440, 0x11441,
- 0x11445, 0x11445,
- 0x11447, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x1145f, 0x1145f,
- 0x11480, 0x114af,
- 0x114b1, 0x114b2,
- 0x114b9, 0x114b9,
- 0x114bb, 0x114bc,
- 0x114be, 0x114be,
- 0x114c1, 0x114c1,
- 0x114c4, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115ae,
- 0x115b0, 0x115b1,
- 0x115b8, 0x115bb,
- 0x115be, 0x115be,
- 0x115c1, 0x115db,
- 0x11600, 0x11632,
- 0x1163b, 0x1163c,
- 0x1163e, 0x1163e,
- 0x11641, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116aa,
- 0x116ac, 0x116ac,
- 0x116ae, 0x116af,
- 0x116b6, 0x116b6,
- 0x116b8, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x11720, 0x11721,
- 0x11726, 0x11726,
- 0x11730, 0x1173f,
- 0x11800, 0x1182e,
- 0x11838, 0x11838,
- 0x1183b, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d3,
- 0x119dc, 0x119df,
- 0x119e1, 0x119e4,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a39, 0x11a3a,
- 0x11a3f, 0x11a46,
- 0x11a50, 0x11a50,
- 0x11a57, 0x11a58,
- 0x11a5c, 0x11a89,
- 0x11a97, 0x11a97,
- 0x11a9a, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2f,
- 0x11c3e, 0x11c3e,
- 0x11c40, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11ca9, 0x11ca9,
- 0x11cb1, 0x11cb1,
- 0x11cb4, 0x11cb4,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d93, 0x11d94,
- 0x11d96, 0x11d96,
- 0x11d98, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef2,
- 0x11ef5, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af5, 0x16af5,
- 0x16b00, 0x16b2f,
- 0x16b37, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f87,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bc9c,
- 0x1bc9f, 0x1bc9f,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d164,
- 0x1d166, 0x1d166,
- 0x1d16a, 0x1d16d,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1e8,
- 0x1d200, 0x1d241,
- 0x1d245, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d9ff,
- 0x1da37, 0x1da3a,
- 0x1da6d, 0x1da74,
- 0x1da76, 0x1da83,
- 0x1da85, 0x1da8b,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2eb,
- 0x1e2f0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8cf,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_Grapheme_Base */
-
-/* 'Grapheme_Link': Derived Property */
-static const OnigCodePoint CR_Grapheme_Link[] = {
- 52,
- 0x094d, 0x094d,
- 0x09cd, 0x09cd,
- 0x0a4d, 0x0a4d,
- 0x0acd, 0x0acd,
- 0x0b4d, 0x0b4d,
- 0x0bcd, 0x0bcd,
- 0x0c4d, 0x0c4d,
- 0x0ccd, 0x0ccd,
- 0x0d3b, 0x0d3c,
- 0x0d4d, 0x0d4d,
- 0x0dca, 0x0dca,
- 0x0e3a, 0x0e3a,
- 0x0eba, 0x0eba,
- 0x0f84, 0x0f84,
- 0x1039, 0x103a,
- 0x1714, 0x1714,
- 0x1734, 0x1734,
- 0x17d2, 0x17d2,
- 0x1a60, 0x1a60,
- 0x1b44, 0x1b44,
- 0x1baa, 0x1bab,
- 0x1bf2, 0x1bf3,
- 0x2d7f, 0x2d7f,
- 0xa806, 0xa806,
- 0xa8c4, 0xa8c4,
- 0xa953, 0xa953,
- 0xa9c0, 0xa9c0,
- 0xaaf6, 0xaaf6,
- 0xabed, 0xabed,
- 0x10a3f, 0x10a3f,
- 0x11046, 0x11046,
- 0x1107f, 0x1107f,
- 0x110b9, 0x110b9,
- 0x11133, 0x11134,
- 0x111c0, 0x111c0,
- 0x11235, 0x11235,
- 0x112ea, 0x112ea,
- 0x1134d, 0x1134d,
- 0x11442, 0x11442,
- 0x114c2, 0x114c2,
- 0x115bf, 0x115bf,
- 0x1163f, 0x1163f,
- 0x116b6, 0x116b6,
- 0x1172b, 0x1172b,
- 0x11839, 0x11839,
- 0x119e0, 0x119e0,
- 0x11a34, 0x11a34,
- 0x11a47, 0x11a47,
- 0x11a99, 0x11a99,
- 0x11c3f, 0x11c3f,
- 0x11d44, 0x11d45,
- 0x11d97, 0x11d97,
-}; /* CR_Grapheme_Link */
-
-/* 'Common': Script */
-static const OnigCodePoint CR_Common[] = {
- 172,
- 0x0000, 0x0040,
- 0x005b, 0x0060,
- 0x007b, 0x00a9,
- 0x00ab, 0x00b9,
- 0x00bb, 0x00bf,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x02b9, 0x02df,
- 0x02e5, 0x02e9,
- 0x02ec, 0x02ff,
- 0x0374, 0x0374,
- 0x037e, 0x037e,
- 0x0385, 0x0385,
- 0x0387, 0x0387,
- 0x0589, 0x0589,
- 0x0605, 0x0605,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0640, 0x0640,
- 0x06dd, 0x06dd,
- 0x08e2, 0x08e2,
- 0x0964, 0x0965,
- 0x0e3f, 0x0e3f,
- 0x0fd5, 0x0fd8,
- 0x10fb, 0x10fb,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x1802, 0x1803,
- 0x1805, 0x1805,
- 0x1cd3, 0x1cd3,
- 0x1ce1, 0x1ce1,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf7,
- 0x1cfa, 0x1cfa,
- 0x2000, 0x200b,
- 0x200e, 0x2064,
- 0x2066, 0x2070,
- 0x2074, 0x207e,
- 0x2080, 0x208e,
- 0x20a0, 0x20bf,
- 0x2100, 0x2125,
- 0x2127, 0x2129,
- 0x212c, 0x2131,
- 0x2133, 0x214d,
- 0x214f, 0x215f,
- 0x2189, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x27ff,
- 0x2900, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bff,
- 0x2e00, 0x2e4f,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x3004,
- 0x3006, 0x3006,
- 0x3008, 0x3020,
- 0x3030, 0x3037,
- 0x303c, 0x303f,
- 0x309b, 0x309c,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fc,
- 0x3190, 0x319f,
- 0x31c0, 0x31e3,
- 0x3220, 0x325f,
- 0x327f, 0x32cf,
- 0x32ff, 0x32ff,
- 0x3358, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa700, 0xa721,
- 0xa788, 0xa78a,
- 0xa830, 0xa839,
- 0xa92e, 0xa92e,
- 0xa9cf, 0xa9cf,
- 0xab5b, 0xab5b,
- 0xfd3e, 0xfd3f,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfeff, 0xfeff,
- 0xff01, 0xff20,
- 0xff3b, 0xff40,
- 0xff5b, 0xff65,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1013f,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fc,
- 0x102e1, 0x102fb,
- 0x16fe2, 0x16fe3,
- 0x1bca0, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d166,
- 0x1d16a, 0x1d17a,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1e8,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f1ff,
- 0x1f201, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
-}; /* CR_Common */
-
-/* 'Latin': Script */
-static const OnigCodePoint CR_Latin[] = {
- 32,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02b8,
- 0x02e0, 0x02e4,
- 0x1d00, 0x1d25,
- 0x1d2c, 0x1d5c,
- 0x1d62, 0x1d65,
- 0x1d6b, 0x1d77,
- 0x1d79, 0x1dbe,
- 0x1e00, 0x1eff,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c60, 0x2c7f,
- 0xa722, 0xa787,
- 0xa78b, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa7ff,
- 0xab30, 0xab5a,
- 0xab5c, 0xab64,
- 0xab66, 0xab67,
- 0xfb00, 0xfb06,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
-}; /* CR_Latin */
-
-/* 'Greek': Script */
-static const OnigCodePoint CR_Greek[] = {
- 36,
- 0x0370, 0x0373,
- 0x0375, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0384, 0x0384,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03e1,
- 0x03f0, 0x03ff,
- 0x1d26, 0x1d2a,
- 0x1d5d, 0x1d61,
- 0x1d66, 0x1d6a,
- 0x1dbf, 0x1dbf,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2126, 0x2126,
- 0xab65, 0xab65,
- 0x10140, 0x1018e,
- 0x101a0, 0x101a0,
- 0x1d200, 0x1d245,
-}; /* CR_Greek */
-
-/* 'Cyrillic': Script */
-static const OnigCodePoint CR_Cyrillic[] = {
- 8,
- 0x0400, 0x0484,
- 0x0487, 0x052f,
- 0x1c80, 0x1c88,
- 0x1d2b, 0x1d2b,
- 0x1d78, 0x1d78,
- 0x2de0, 0x2dff,
- 0xa640, 0xa69f,
- 0xfe2e, 0xfe2f,
-}; /* CR_Cyrillic */
-
-/* 'Armenian': Script */
-static const OnigCodePoint CR_Armenian[] = {
- 5,
- 0x0531, 0x0556,
- 0x0559, 0x0588,
- 0x058a, 0x058a,
- 0x058d, 0x058f,
- 0xfb13, 0xfb17,
-}; /* CR_Armenian */
-
-/* 'Hebrew': Script */
-static const OnigCodePoint CR_Hebrew[] = {
- 9,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfb4f,
-}; /* CR_Hebrew */
-
-/* 'Arabic': Script */
-static const OnigCodePoint CR_Arabic[] = {
- 57,
- 0x0600, 0x0604,
- 0x0606, 0x060b,
- 0x060d, 0x061a,
- 0x061c, 0x061c,
- 0x061e, 0x061e,
- 0x0620, 0x063f,
- 0x0641, 0x064a,
- 0x0656, 0x066f,
- 0x0671, 0x06dc,
- 0x06de, 0x06ff,
- 0x0750, 0x077f,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x08e1,
- 0x08e3, 0x08ff,
- 0xfb50, 0xfbc1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0x10e60, 0x10e7e,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
-}; /* CR_Arabic */
-
-/* 'Syriac': Script */
-static const OnigCodePoint CR_Syriac[] = {
- 4,
- 0x0700, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x074f,
- 0x0860, 0x086a,
-}; /* CR_Syriac */
-
-/* 'Thaana': Script */
-static const OnigCodePoint CR_Thaana[] = {
- 1,
- 0x0780, 0x07b1,
-}; /* CR_Thaana */
-
-/* 'Devanagari': Script */
-static const OnigCodePoint CR_Devanagari[] = {
- 4,
- 0x0900, 0x0950,
- 0x0955, 0x0963,
- 0x0966, 0x097f,
- 0xa8e0, 0xa8ff,
-}; /* CR_Devanagari */
-
-/* 'Bengali': Script */
-static const OnigCodePoint CR_Bengali[] = {
- 14,
- 0x0980, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fe,
-}; /* CR_Bengali */
-
-/* 'Gurmukhi': Script */
-static const OnigCodePoint CR_Gurmukhi[] = {
- 16,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
-}; /* CR_Gurmukhi */
-
-/* 'Gujarati': Script */
-static const OnigCodePoint CR_Gujarati[] = {
- 14,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
-}; /* CR_Gujarati */
-
-/* 'Oriya': Script */
-static const OnigCodePoint CR_Oriya[] = {
- 14,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
-}; /* CR_Oriya */
-
-/* 'Tamil': Script */
-static const OnigCodePoint CR_Tamil[] = {
- 18,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x11fff,
-}; /* CR_Tamil */
-
-/* 'Telugu': Script */
-static const OnigCodePoint CR_Telugu[] = {
- 12,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c7f,
-}; /* CR_Telugu */
-
-/* 'Kannada': Script */
-static const OnigCodePoint CR_Kannada[] = {
- 13,
- 0x0c80, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
-}; /* CR_Kannada */
-
-/* 'Malayalam': Script */
-static const OnigCodePoint CR_Malayalam[] = {
- 8,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
-}; /* CR_Malayalam */
-
-/* 'Sinhala': Script */
-static const OnigCodePoint CR_Sinhala[] = {
- 13,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x111e1, 0x111f4,
-}; /* CR_Sinhala */
-
-/* 'Thai': Script */
-static const OnigCodePoint CR_Thai[] = {
- 2,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e5b,
-}; /* CR_Thai */
-
-/* 'Lao': Script */
-static const OnigCodePoint CR_Lao[] = {
- 11,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
-}; /* CR_Lao */
-
-/* 'Tibetan': Script */
-static const OnigCodePoint CR_Tibetan[] = {
- 7,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fd4,
- 0x0fd9, 0x0fda,
-}; /* CR_Tibetan */
-
-/* 'Myanmar': Script */
-static const OnigCodePoint CR_Myanmar[] = {
- 3,
- 0x1000, 0x109f,
- 0xa9e0, 0xa9fe,
- 0xaa60, 0xaa7f,
-}; /* CR_Myanmar */
-
-/* 'Georgian': Script */
-static const OnigCodePoint CR_Georgian[] = {
- 10,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10ff,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
-}; /* CR_Georgian */
-
-/* 'Hangul': Script */
-static const OnigCodePoint CR_Hangul[] = {
- 14,
- 0x1100, 0x11ff,
- 0x302e, 0x302f,
- 0x3131, 0x318e,
- 0x3200, 0x321e,
- 0x3260, 0x327e,
- 0xa960, 0xa97c,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
-}; /* CR_Hangul */
-
-/* 'Ethiopic': Script */
-static const OnigCodePoint CR_Ethiopic[] = {
- 32,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
-}; /* CR_Ethiopic */
-
-/* 'Cherokee': Script */
-static const OnigCodePoint CR_Cherokee[] = {
- 3,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0xab70, 0xabbf,
-}; /* CR_Cherokee */
-
-/* 'Canadian_Aboriginal': Script */
-static const OnigCodePoint CR_Canadian_Aboriginal[] = {
- 2,
- 0x1400, 0x167f,
- 0x18b0, 0x18f5,
-}; /* CR_Canadian_Aboriginal */
-
-/* 'Ogham': Script */
-static const OnigCodePoint CR_Ogham[] = {
- 1,
- 0x1680, 0x169c,
-}; /* CR_Ogham */
-
-/* 'Runic': Script */
-static const OnigCodePoint CR_Runic[] = {
- 2,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
-}; /* CR_Runic */
-
-/* 'Khmer': Script */
-static const OnigCodePoint CR_Khmer[] = {
- 4,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x19e0, 0x19ff,
-}; /* CR_Khmer */
-
-/* 'Mongolian': Script */
-static const OnigCodePoint CR_Mongolian[] = {
- 7,
- 0x1800, 0x1801,
- 0x1804, 0x1804,
- 0x1806, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x11660, 0x1166c,
-}; /* CR_Mongolian */
-
-/* 'Hiragana': Script */
-static const OnigCodePoint CR_Hiragana[] = {
- 5,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x1b001, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1f200, 0x1f200,
-}; /* CR_Hiragana */
-
-/* 'Katakana': Script */
-static const OnigCodePoint CR_Katakana[] = {
- 9,
- 0x30a1, 0x30fa,
- 0x30fd, 0x30ff,
- 0x31f0, 0x31ff,
- 0x32d0, 0x32fe,
- 0x3300, 0x3357,
- 0xff66, 0xff6f,
- 0xff71, 0xff9d,
- 0x1b000, 0x1b000,
- 0x1b164, 0x1b167,
-}; /* CR_Katakana */
-
-/* 'Bopomofo': Script */
-static const OnigCodePoint CR_Bopomofo[] = {
- 3,
- 0x02ea, 0x02eb,
- 0x3105, 0x312f,
- 0x31a0, 0x31ba,
-}; /* CR_Bopomofo */
-
-/* 'Han': Script */
-static const OnigCodePoint CR_Han[] = {
- 17,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x3005, 0x3005,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303b,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_Han */
-
-/* 'Yi': Script */
-static const OnigCodePoint CR_Yi[] = {
- 2,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
-}; /* CR_Yi */
-
-/* 'Old_Italic': Script */
-static const OnigCodePoint CR_Old_Italic[] = {
- 2,
- 0x10300, 0x10323,
- 0x1032d, 0x1032f,
-}; /* CR_Old_Italic */
-
-/* 'Gothic': Script */
-static const OnigCodePoint CR_Gothic[] = {
- 1,
- 0x10330, 0x1034a,
-}; /* CR_Gothic */
-
-/* 'Deseret': Script */
-static const OnigCodePoint CR_Deseret[] = {
- 1,
- 0x10400, 0x1044f,
-}; /* CR_Deseret */
-
-/* 'Inherited': Script */
-static const OnigCodePoint CR_Inherited[] = {
- 28,
- 0x0300, 0x036f,
- 0x0485, 0x0486,
- 0x064b, 0x0655,
- 0x0670, 0x0670,
- 0x0951, 0x0954,
- 0x1ab0, 0x1abe,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1df9,
- 0x1dfb, 0x1dff,
- 0x200c, 0x200d,
- 0x20d0, 0x20f0,
- 0x302a, 0x302d,
- 0x3099, 0x309a,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2d,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x1133b, 0x1133b,
- 0x1d167, 0x1d169,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0xe0100, 0xe01ef,
-}; /* CR_Inherited */
-
-/* 'Tagalog': Script */
-static const OnigCodePoint CR_Tagalog[] = {
- 2,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
-}; /* CR_Tagalog */
-
-/* 'Hanunoo': Script */
-static const OnigCodePoint CR_Hanunoo[] = {
- 1,
- 0x1720, 0x1734,
-}; /* CR_Hanunoo */
-
-/* 'Buhid': Script */
-static const OnigCodePoint CR_Buhid[] = {
- 1,
- 0x1740, 0x1753,
-}; /* CR_Buhid */
-
-/* 'Tagbanwa': Script */
-static const OnigCodePoint CR_Tagbanwa[] = {
- 3,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
-}; /* CR_Tagbanwa */
-
-/* 'Limbu': Script */
-static const OnigCodePoint CR_Limbu[] = {
- 5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x194f,
-}; /* CR_Limbu */
-
-/* 'Tai_Le': Script */
-static const OnigCodePoint CR_Tai_Le[] = {
- 2,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
-}; /* CR_Tai_Le */
-
-/* 'Linear_B': Script */
-static const OnigCodePoint CR_Linear_B[] = {
- 7,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
-}; /* CR_Linear_B */
-
-/* 'Ugaritic': Script */
-static const OnigCodePoint CR_Ugaritic[] = {
- 2,
- 0x10380, 0x1039d,
- 0x1039f, 0x1039f,
-}; /* CR_Ugaritic */
-
-/* 'Shavian': Script */
-static const OnigCodePoint CR_Shavian[] = {
- 1,
- 0x10450, 0x1047f,
-}; /* CR_Shavian */
-
-/* 'Osmanya': Script */
-static const OnigCodePoint CR_Osmanya[] = {
- 2,
- 0x10480, 0x1049d,
- 0x104a0, 0x104a9,
-}; /* CR_Osmanya */
-
-/* 'Cypriot': Script */
-static const OnigCodePoint CR_Cypriot[] = {
- 6,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
-}; /* CR_Cypriot */
-
-/* 'Braille': Script */
-static const OnigCodePoint CR_Braille[] = {
- 1,
- 0x2800, 0x28ff,
-}; /* CR_Braille */
-
-/* 'Buginese': Script */
-static const OnigCodePoint CR_Buginese[] = {
- 2,
- 0x1a00, 0x1a1b,
- 0x1a1e, 0x1a1f,
-}; /* CR_Buginese */
-
-/* 'Coptic': Script */
-static const OnigCodePoint CR_Coptic[] = {
- 3,
- 0x03e2, 0x03ef,
- 0x2c80, 0x2cf3,
- 0x2cf9, 0x2cff,
-}; /* CR_Coptic */
-
-/* 'New_Tai_Lue': Script */
-static const OnigCodePoint CR_New_Tai_Lue[] = {
- 4,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x19df,
-}; /* CR_New_Tai_Lue */
-
-/* 'Glagolitic': Script */
-static const OnigCodePoint CR_Glagolitic[] = {
- 7,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
-}; /* CR_Glagolitic */
-
-/* 'Tifinagh': Script */
-static const OnigCodePoint CR_Tifinagh[] = {
- 3,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d7f,
-}; /* CR_Tifinagh */
-
-/* 'Syloti_Nagri': Script */
-static const OnigCodePoint CR_Syloti_Nagri[] = {
- 1,
- 0xa800, 0xa82b,
-}; /* CR_Syloti_Nagri */
-
-/* 'Old_Persian': Script */
-static const OnigCodePoint CR_Old_Persian[] = {
- 2,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103d5,
-}; /* CR_Old_Persian */
-
-/* 'Kharoshthi': Script */
-static const OnigCodePoint CR_Kharoshthi[] = {
- 8,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
-}; /* CR_Kharoshthi */
-
-/* 'Balinese': Script */
-static const OnigCodePoint CR_Balinese[] = {
- 2,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
-}; /* CR_Balinese */
-
-/* 'Cuneiform': Script */
-static const OnigCodePoint CR_Cuneiform[] = {
- 4,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
-}; /* CR_Cuneiform */
-
-/* 'Phoenician': Script */
-static const OnigCodePoint CR_Phoenician[] = {
- 2,
- 0x10900, 0x1091b,
- 0x1091f, 0x1091f,
-}; /* CR_Phoenician */
-
-/* 'Phags_Pa': Script */
-static const OnigCodePoint CR_Phags_Pa[] = {
- 1,
- 0xa840, 0xa877,
-}; /* CR_Phags_Pa */
-
-/* 'Nko': Script */
-static const OnigCodePoint CR_Nko[] = {
- 2,
- 0x07c0, 0x07fa,
- 0x07fd, 0x07ff,
-}; /* CR_Nko */
-
-/* 'Sundanese': Script */
-static const OnigCodePoint CR_Sundanese[] = {
- 2,
- 0x1b80, 0x1bbf,
- 0x1cc0, 0x1cc7,
-}; /* CR_Sundanese */
-
-/* 'Lepcha': Script */
-static const OnigCodePoint CR_Lepcha[] = {
- 3,
- 0x1c00, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c4f,
-}; /* CR_Lepcha */
-
-/* 'Ol_Chiki': Script */
-static const OnigCodePoint CR_Ol_Chiki[] = {
- 1,
- 0x1c50, 0x1c7f,
-}; /* CR_Ol_Chiki */
-
-/* 'Vai': Script */
-static const OnigCodePoint CR_Vai[] = {
- 1,
- 0xa500, 0xa62b,
-}; /* CR_Vai */
-
-/* 'Saurashtra': Script */
-static const OnigCodePoint CR_Saurashtra[] = {
- 2,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
-}; /* CR_Saurashtra */
-
-/* 'Kayah_Li': Script */
-static const OnigCodePoint CR_Kayah_Li[] = {
- 2,
- 0xa900, 0xa92d,
- 0xa92f, 0xa92f,
-}; /* CR_Kayah_Li */
-
-/* 'Rejang': Script */
-static const OnigCodePoint CR_Rejang[] = {
- 2,
- 0xa930, 0xa953,
- 0xa95f, 0xa95f,
-}; /* CR_Rejang */
-
-/* 'Lycian': Script */
-static const OnigCodePoint CR_Lycian[] = {
- 1,
- 0x10280, 0x1029c,
-}; /* CR_Lycian */
-
-/* 'Carian': Script */
-static const OnigCodePoint CR_Carian[] = {
- 1,
- 0x102a0, 0x102d0,
-}; /* CR_Carian */
-
-/* 'Lydian': Script */
-static const OnigCodePoint CR_Lydian[] = {
- 2,
- 0x10920, 0x10939,
- 0x1093f, 0x1093f,
-}; /* CR_Lydian */
-
-/* 'Cham': Script */
-static const OnigCodePoint CR_Cham[] = {
- 4,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa5f,
-}; /* CR_Cham */
-
-/* 'Tai_Tham': Script */
-static const OnigCodePoint CR_Tai_Tham[] = {
- 5,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
-}; /* CR_Tai_Tham */
-
-/* 'Tai_Viet': Script */
-static const OnigCodePoint CR_Tai_Viet[] = {
- 2,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaadf,
-}; /* CR_Tai_Viet */
-
-/* 'Avestan': Script */
-static const OnigCodePoint CR_Avestan[] = {
- 2,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b3f,
-}; /* CR_Avestan */
-
-/* 'Egyptian_Hieroglyphs': Script */
-static const OnigCodePoint CR_Egyptian_Hieroglyphs[] = {
- 2,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
-}; /* CR_Egyptian_Hieroglyphs */
-
-/* 'Samaritan': Script */
-static const OnigCodePoint CR_Samaritan[] = {
- 2,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
-}; /* CR_Samaritan */
-
-/* 'Lisu': Script */
-static const OnigCodePoint CR_Lisu[] = {
- 1,
- 0xa4d0, 0xa4ff,
-}; /* CR_Lisu */
-
-/* 'Bamum': Script */
-static const OnigCodePoint CR_Bamum[] = {
- 2,
- 0xa6a0, 0xa6f7,
- 0x16800, 0x16a38,
-}; /* CR_Bamum */
-
-/* 'Javanese': Script */
-static const OnigCodePoint CR_Javanese[] = {
- 3,
- 0xa980, 0xa9cd,
- 0xa9d0, 0xa9d9,
- 0xa9de, 0xa9df,
-}; /* CR_Javanese */
-
-/* 'Meetei_Mayek': Script */
-static const OnigCodePoint CR_Meetei_Mayek[] = {
- 3,
- 0xaae0, 0xaaf6,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
-}; /* CR_Meetei_Mayek */
-
-/* 'Imperial_Aramaic': Script */
-static const OnigCodePoint CR_Imperial_Aramaic[] = {
- 2,
- 0x10840, 0x10855,
- 0x10857, 0x1085f,
-}; /* CR_Imperial_Aramaic */
-
-/* 'Old_South_Arabian': Script */
-static const OnigCodePoint CR_Old_South_Arabian[] = {
- 1,
- 0x10a60, 0x10a7f,
-}; /* CR_Old_South_Arabian */
-
-/* 'Inscriptional_Parthian': Script */
-static const OnigCodePoint CR_Inscriptional_Parthian[] = {
- 2,
- 0x10b40, 0x10b55,
- 0x10b58, 0x10b5f,
-}; /* CR_Inscriptional_Parthian */
-
-/* 'Inscriptional_Pahlavi': Script */
-static const OnigCodePoint CR_Inscriptional_Pahlavi[] = {
- 2,
- 0x10b60, 0x10b72,
- 0x10b78, 0x10b7f,
-}; /* CR_Inscriptional_Pahlavi */
-
-/* 'Old_Turkic': Script */
-static const OnigCodePoint CR_Old_Turkic[] = {
- 1,
- 0x10c00, 0x10c48,
-}; /* CR_Old_Turkic */
-
-/* 'Kaithi': Script */
-static const OnigCodePoint CR_Kaithi[] = {
- 2,
- 0x11080, 0x110c1,
- 0x110cd, 0x110cd,
-}; /* CR_Kaithi */
-
-/* 'Batak': Script */
-static const OnigCodePoint CR_Batak[] = {
- 2,
- 0x1bc0, 0x1bf3,
- 0x1bfc, 0x1bff,
-}; /* CR_Batak */
-
-/* 'Brahmi': Script */
-static const OnigCodePoint CR_Brahmi[] = {
- 3,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x1107f,
-}; /* CR_Brahmi */
-
-/* 'Mandaic': Script */
-static const OnigCodePoint CR_Mandaic[] = {
- 2,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
-}; /* CR_Mandaic */
-
-/* 'Chakma': Script */
-static const OnigCodePoint CR_Chakma[] = {
- 2,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
-}; /* CR_Chakma */
-
-/* 'Meroitic_Cursive': Script */
-static const OnigCodePoint CR_Meroitic_Cursive[] = {
- 3,
- 0x109a0, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x109ff,
-}; /* CR_Meroitic_Cursive */
-
-/* 'Meroitic_Hieroglyphs': Script */
-static const OnigCodePoint CR_Meroitic_Hieroglyphs[] = {
- 1,
- 0x10980, 0x1099f,
-}; /* CR_Meroitic_Hieroglyphs */
-
-/* 'Miao': Script */
-static const OnigCodePoint CR_Miao[] = {
- 3,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
-}; /* CR_Miao */
-
-/* 'Sharada': Script */
-static const OnigCodePoint CR_Sharada[] = {
- 2,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
-}; /* CR_Sharada */
-
-/* 'Sora_Sompeng': Script */
-static const OnigCodePoint CR_Sora_Sompeng[] = {
- 2,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
-}; /* CR_Sora_Sompeng */
-
-/* 'Takri': Script */
-static const OnigCodePoint CR_Takri[] = {
- 2,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
-}; /* CR_Takri */
-
-/* 'Caucasian_Albanian': Script */
-static const OnigCodePoint CR_Caucasian_Albanian[] = {
- 2,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
-}; /* CR_Caucasian_Albanian */
-
-/* 'Bassa_Vah': Script */
-static const OnigCodePoint CR_Bassa_Vah[] = {
- 2,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
-}; /* CR_Bassa_Vah */
-
-/* 'Duployan': Script */
-static const OnigCodePoint CR_Duployan[] = {
- 5,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bc9f,
-}; /* CR_Duployan */
-
-/* 'Elbasan': Script */
-static const OnigCodePoint CR_Elbasan[] = {
- 1,
- 0x10500, 0x10527,
-}; /* CR_Elbasan */
-
-/* 'Grantha': Script */
-static const OnigCodePoint CR_Grantha[] = {
- 15,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
-}; /* CR_Grantha */
-
-/* 'Pahawh_Hmong': Script */
-static const OnigCodePoint CR_Pahawh_Hmong[] = {
- 5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
-}; /* CR_Pahawh_Hmong */
-
-/* 'Khojki': Script */
-static const OnigCodePoint CR_Khojki[] = {
- 2,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
-}; /* CR_Khojki */
-
-/* 'Linear_A': Script */
-static const OnigCodePoint CR_Linear_A[] = {
- 3,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
-}; /* CR_Linear_A */
-
-/* 'Mahajani': Script */
-static const OnigCodePoint CR_Mahajani[] = {
- 1,
- 0x11150, 0x11176,
-}; /* CR_Mahajani */
-
-/* 'Manichaean': Script */
-static const OnigCodePoint CR_Manichaean[] = {
- 2,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
-}; /* CR_Manichaean */
-
-/* 'Mende_Kikakui': Script */
-static const OnigCodePoint CR_Mende_Kikakui[] = {
- 2,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
-}; /* CR_Mende_Kikakui */
-
-/* 'Modi': Script */
-static const OnigCodePoint CR_Modi[] = {
- 2,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
-}; /* CR_Modi */
-
-/* 'Mro': Script */
-static const OnigCodePoint CR_Mro[] = {
- 3,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
-}; /* CR_Mro */
-
-/* 'Old_North_Arabian': Script */
-static const OnigCodePoint CR_Old_North_Arabian[] = {
- 1,
- 0x10a80, 0x10a9f,
-}; /* CR_Old_North_Arabian */
-
-/* 'Nabataean': Script */
-static const OnigCodePoint CR_Nabataean[] = {
- 2,
- 0x10880, 0x1089e,
- 0x108a7, 0x108af,
-}; /* CR_Nabataean */
-
-/* 'Palmyrene': Script */
-static const OnigCodePoint CR_Palmyrene[] = {
- 1,
- 0x10860, 0x1087f,
-}; /* CR_Palmyrene */
-
-/* 'Pau_Cin_Hau': Script */
-static const OnigCodePoint CR_Pau_Cin_Hau[] = {
- 1,
- 0x11ac0, 0x11af8,
-}; /* CR_Pau_Cin_Hau */
-
-/* 'Old_Permic': Script */
-static const OnigCodePoint CR_Old_Permic[] = {
- 1,
- 0x10350, 0x1037a,
-}; /* CR_Old_Permic */
-
-/* 'Psalter_Pahlavi': Script */
-static const OnigCodePoint CR_Psalter_Pahlavi[] = {
- 3,
- 0x10b80, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
-}; /* CR_Psalter_Pahlavi */
-
-/* 'Siddham': Script */
-static const OnigCodePoint CR_Siddham[] = {
- 2,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
-}; /* CR_Siddham */
-
-/* 'Khudawadi': Script */
-static const OnigCodePoint CR_Khudawadi[] = {
- 2,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
-}; /* CR_Khudawadi */
-
-/* 'Tirhuta': Script */
-static const OnigCodePoint CR_Tirhuta[] = {
- 2,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
-}; /* CR_Tirhuta */
-
-/* 'Warang_Citi': Script */
-static const OnigCodePoint CR_Warang_Citi[] = {
- 2,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
-}; /* CR_Warang_Citi */
-
-/* 'Ahom': Script */
-static const OnigCodePoint CR_Ahom[] = {
- 3,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
-}; /* CR_Ahom */
-
-/* 'Anatolian_Hieroglyphs': Script */
-static const OnigCodePoint CR_Anatolian_Hieroglyphs[] = {
- 1,
- 0x14400, 0x14646,
-}; /* CR_Anatolian_Hieroglyphs */
-
-/* 'Hatran': Script */
-static const OnigCodePoint CR_Hatran[] = {
- 3,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x108ff,
-}; /* CR_Hatran */
-
-/* 'Multani': Script */
-static const OnigCodePoint CR_Multani[] = {
- 5,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
-}; /* CR_Multani */
-
-/* 'Old_Hungarian': Script */
-static const OnigCodePoint CR_Old_Hungarian[] = {
- 3,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
-}; /* CR_Old_Hungarian */
-
-/* 'SignWriting': Script */
-static const OnigCodePoint CR_SignWriting[] = {
- 3,
- 0x1d800, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
-}; /* CR_SignWriting */
-
-/* 'Adlam': Script */
-static const OnigCodePoint CR_Adlam[] = {
- 3,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
-}; /* CR_Adlam */
-
-/* 'Bhaiksuki': Script */
-static const OnigCodePoint CR_Bhaiksuki[] = {
- 4,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
-}; /* CR_Bhaiksuki */
-
-/* 'Marchen': Script */
-static const OnigCodePoint CR_Marchen[] = {
- 3,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
-}; /* CR_Marchen */
-
-/* 'Newa': Script */
-static const OnigCodePoint CR_Newa[] = {
- 3,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
-}; /* CR_Newa */
-
-/* 'Osage': Script */
-static const OnigCodePoint CR_Osage[] = {
- 2,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
-}; /* CR_Osage */
-
-/* 'Tangut': Script */
-static const OnigCodePoint CR_Tangut[] = {
- 3,
- 0x16fe0, 0x16fe0,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
-}; /* CR_Tangut */
-
-/* 'Masaram_Gondi': Script */
-static const OnigCodePoint CR_Masaram_Gondi[] = {
- 7,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
-}; /* CR_Masaram_Gondi */
-
-/* 'Nushu': Script */
-static const OnigCodePoint CR_Nushu[] = {
- 2,
- 0x16fe1, 0x16fe1,
- 0x1b170, 0x1b2fb,
-}; /* CR_Nushu */
-
-/* 'Soyombo': Script */
-static const OnigCodePoint CR_Soyombo[] = {
- 1,
- 0x11a50, 0x11aa2,
-}; /* CR_Soyombo */
-
-/* 'Zanabazar_Square': Script */
-static const OnigCodePoint CR_Zanabazar_Square[] = {
- 1,
- 0x11a00, 0x11a47,
-}; /* CR_Zanabazar_Square */
-
-/* 'Dogra': Script */
-static const OnigCodePoint CR_Dogra[] = {
- 1,
- 0x11800, 0x1183b,
-}; /* CR_Dogra */
-
-/* 'Gunjala_Gondi': Script */
-static const OnigCodePoint CR_Gunjala_Gondi[] = {
- 6,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
-}; /* CR_Gunjala_Gondi */
-
-/* 'Makasar': Script */
-static const OnigCodePoint CR_Makasar[] = {
- 1,
- 0x11ee0, 0x11ef8,
-}; /* CR_Makasar */
-
-/* 'Medefaidrin': Script */
-static const OnigCodePoint CR_Medefaidrin[] = {
- 1,
- 0x16e40, 0x16e9a,
-}; /* CR_Medefaidrin */
-
-/* 'Hanifi_Rohingya': Script */
-static const OnigCodePoint CR_Hanifi_Rohingya[] = {
- 2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
-}; /* CR_Hanifi_Rohingya */
-
-/* 'Sogdian': Script */
-static const OnigCodePoint CR_Sogdian[] = {
- 1,
- 0x10f30, 0x10f59,
-}; /* CR_Sogdian */
-
-/* 'Old_Sogdian': Script */
-static const OnigCodePoint CR_Old_Sogdian[] = {
- 1,
- 0x10f00, 0x10f27,
-}; /* CR_Old_Sogdian */
-
-/* 'Elymaic': Script */
-static const OnigCodePoint CR_Elymaic[] = {
- 1,
- 0x10fe0, 0x10ff6,
-}; /* CR_Elymaic */
-
-/* 'Nandinagari': Script */
-static const OnigCodePoint CR_Nandinagari[] = {
- 3,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
-}; /* CR_Nandinagari */
-
-/* 'Nyiakeng_Puachue_Hmong': Script */
-static const OnigCodePoint CR_Nyiakeng_Puachue_Hmong[] = {
- 4,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
-}; /* CR_Nyiakeng_Puachue_Hmong */
-
-/* 'Wancho': Script */
-static const OnigCodePoint CR_Wancho[] = {
- 2,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
-}; /* CR_Wancho */
-
-/* 'White_Space': Binary Property */
-#define CR_White_Space CR_Space
-
-/* 'Bidi_Control': Binary Property */
-static const OnigCodePoint CR_Bidi_Control[] = {
- 4,
- 0x061c, 0x061c,
- 0x200e, 0x200f,
- 0x202a, 0x202e,
- 0x2066, 0x2069,
-}; /* CR_Bidi_Control */
-
-/* 'Join_Control': Binary Property */
-static const OnigCodePoint CR_Join_Control[] = {
- 1,
- 0x200c, 0x200d,
-}; /* CR_Join_Control */
-
-/* 'Dash': Binary Property */
-static const OnigCodePoint CR_Dash[] = {
- 21,
- 0x002d, 0x002d,
- 0x058a, 0x058a,
- 0x05be, 0x05be,
- 0x1400, 0x1400,
- 0x1806, 0x1806,
- 0x2010, 0x2015,
- 0x2053, 0x2053,
- 0x207b, 0x207b,
- 0x208b, 0x208b,
- 0x2212, 0x2212,
- 0x2e17, 0x2e17,
- 0x2e1a, 0x2e1a,
- 0x2e3a, 0x2e3b,
- 0x2e40, 0x2e40,
- 0x301c, 0x301c,
- 0x3030, 0x3030,
- 0x30a0, 0x30a0,
- 0xfe31, 0xfe32,
- 0xfe58, 0xfe58,
- 0xfe63, 0xfe63,
- 0xff0d, 0xff0d,
-}; /* CR_Dash */
-
-/* 'Hyphen': Binary Property */
-static const OnigCodePoint CR_Hyphen[] = {
- 10,
- 0x002d, 0x002d,
- 0x00ad, 0x00ad,
- 0x058a, 0x058a,
- 0x1806, 0x1806,
- 0x2010, 0x2011,
- 0x2e17, 0x2e17,
- 0x30fb, 0x30fb,
- 0xfe63, 0xfe63,
- 0xff0d, 0xff0d,
- 0xff65, 0xff65,
-}; /* CR_Hyphen */
-
-/* 'Quotation_Mark': Binary Property */
-static const OnigCodePoint CR_Quotation_Mark[] = {
- 13,
- 0x0022, 0x0022,
- 0x0027, 0x0027,
- 0x00ab, 0x00ab,
- 0x00bb, 0x00bb,
- 0x2018, 0x201f,
- 0x2039, 0x203a,
- 0x2e42, 0x2e42,
- 0x300c, 0x300f,
- 0x301d, 0x301f,
- 0xfe41, 0xfe44,
- 0xff02, 0xff02,
- 0xff07, 0xff07,
- 0xff62, 0xff63,
-}; /* CR_Quotation_Mark */
-
-/* 'Terminal_Punctuation': Binary Property */
-static const OnigCodePoint CR_Terminal_Punctuation[] = {
- 102,
- 0x0021, 0x0021,
- 0x002c, 0x002c,
- 0x002e, 0x002e,
- 0x003a, 0x003b,
- 0x003f, 0x003f,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x0589, 0x0589,
- 0x05c3, 0x05c3,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x06d4, 0x06d4,
- 0x0700, 0x070a,
- 0x070c, 0x070c,
- 0x07f8, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0e5a, 0x0e5b,
- 0x0f08, 0x0f08,
- 0x0f0d, 0x0f12,
- 0x104a, 0x104b,
- 0x1361, 0x1368,
- 0x166e, 0x166e,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17da, 0x17da,
- 0x1802, 0x1805,
- 0x1808, 0x1809,
- 0x1944, 0x1945,
- 0x1aa8, 0x1aab,
- 0x1b5a, 0x1b5b,
- 0x1b5d, 0x1b5f,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x203c, 0x203d,
- 0x2047, 0x2049,
- 0x2e2e, 0x2e2e,
- 0x2e3c, 0x2e3c,
- 0x2e41, 0x2e41,
- 0x2e4c, 0x2e4c,
- 0x2e4e, 0x2e4f,
- 0x3001, 0x3002,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa6f3, 0xa6f7,
- 0xa876, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa92f, 0xa92f,
- 0xa9c7, 0xa9c9,
- 0xaa5d, 0xaa5f,
- 0xaadf, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 0xfe50, 0xfe52,
- 0xfe54, 0xfe57,
- 0xff01, 0xff01,
- 0xff0c, 0xff0c,
- 0xff0e, 0xff0e,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff1f,
- 0xff61, 0xff61,
- 0xff64, 0xff64,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x10a56, 0x10a57,
- 0x10af0, 0x10af5,
- 0x10b3a, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10f55, 0x10f59,
- 0x11047, 0x1104d,
- 0x110be, 0x110c1,
- 0x11141, 0x11143,
- 0x111c5, 0x111c6,
- 0x111cd, 0x111cd,
- 0x111de, 0x111df,
- 0x11238, 0x1123c,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144d,
- 0x1145b, 0x1145b,
- 0x115c2, 0x115c5,
- 0x115c9, 0x115d7,
- 0x11641, 0x11642,
- 0x1173c, 0x1173e,
- 0x11a42, 0x11a43,
- 0x11a9b, 0x11a9c,
- 0x11aa1, 0x11aa2,
- 0x11c41, 0x11c43,
- 0x11c71, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x12470, 0x12474,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b39,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e98,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8a,
-}; /* CR_Terminal_Punctuation */
-
-/* 'Other_Math': Binary Property */
-static const OnigCodePoint CR_Other_Math[] = {
- 134,
- 0x005e, 0x005e,
- 0x03d0, 0x03d2,
- 0x03d5, 0x03d5,
- 0x03f0, 0x03f1,
- 0x03f4, 0x03f5,
- 0x2016, 0x2016,
- 0x2032, 0x2034,
- 0x2040, 0x2040,
- 0x2061, 0x2064,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20e6,
- 0x20eb, 0x20ef,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2128, 0x2129,
- 0x212c, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2138,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x2195, 0x2199,
- 0x219c, 0x219f,
- 0x21a1, 0x21a2,
- 0x21a4, 0x21a5,
- 0x21a7, 0x21a7,
- 0x21a9, 0x21ad,
- 0x21b0, 0x21b1,
- 0x21b6, 0x21b7,
- 0x21bc, 0x21cd,
- 0x21d0, 0x21d1,
- 0x21d3, 0x21d3,
- 0x21d5, 0x21db,
- 0x21dd, 0x21dd,
- 0x21e4, 0x21e5,
- 0x2308, 0x230b,
- 0x23b4, 0x23b5,
- 0x23b7, 0x23b7,
- 0x23d0, 0x23d0,
- 0x23e2, 0x23e2,
- 0x25a0, 0x25a1,
- 0x25ae, 0x25b6,
- 0x25bc, 0x25c0,
- 0x25c6, 0x25c7,
- 0x25ca, 0x25cb,
- 0x25cf, 0x25d3,
- 0x25e2, 0x25e2,
- 0x25e4, 0x25e4,
- 0x25e7, 0x25ec,
- 0x2605, 0x2606,
- 0x2640, 0x2640,
- 0x2642, 0x2642,
- 0x2660, 0x2663,
- 0x266d, 0x266e,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27ef,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0xfe61, 0xfe61,
- 0xfe63, 0xfe63,
- 0xfe68, 0xfe68,
- 0xff3c, 0xff3c,
- 0xff3e, 0xff3e,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
-}; /* CR_Other_Math */
-
-/* 'Hex_Digit': Binary Property */
-static const OnigCodePoint CR_Hex_Digit[] = {
- 6,
- 0x0030, 0x0039,
- 0x0041, 0x0046,
- 0x0061, 0x0066,
- 0xff10, 0xff19,
- 0xff21, 0xff26,
- 0xff41, 0xff46,
-}; /* CR_Hex_Digit */
-
-/* 'ASCII_Hex_Digit': Binary Property */
-#define CR_ASCII_Hex_Digit CR_XDigit
-
-/* 'Other_Alphabetic': Binary Property */
-static const OnigCodePoint CR_Other_Alphabetic[] = {
- 221,
- 0x0345, 0x0345,
- 0x05b0, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x0657,
- 0x0659, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06e1, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ed, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x073f,
- 0x07a6, 0x07b0,
- 0x0816, 0x0817,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082c,
- 0x08d4, 0x08df,
- 0x08e3, 0x08e9,
- 0x08f0, 0x0903,
- 0x093a, 0x093b,
- 0x093e, 0x094c,
- 0x094e, 0x094f,
- 0x0955, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0983,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x0a01, 0x0a03,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4c,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0abe, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0afc,
- 0x0b01, 0x0b03,
- 0x0b3e, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b56, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c03,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4c,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c83,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccc,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d03,
- 0x0d3e, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0d82, 0x0d83,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e4d, 0x0e4d,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0eb9,
- 0x0ebb, 0x0ebc,
- 0x0ecd, 0x0ecd,
- 0x0f71, 0x0f81,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x102b, 0x1036,
- 0x1038, 0x1038,
- 0x103b, 0x103e,
- 0x1056, 0x1059,
- 0x105e, 0x1060,
- 0x1062, 0x1064,
- 0x1067, 0x106d,
- 0x1071, 0x1074,
- 0x1082, 0x108d,
- 0x108f, 0x108f,
- 0x109a, 0x109d,
- 0x1712, 0x1713,
- 0x1732, 0x1733,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b6, 0x17c8,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x192b,
- 0x1930, 0x1938,
- 0x1a17, 0x1a1b,
- 0x1a55, 0x1a5e,
- 0x1a61, 0x1a74,
- 0x1b00, 0x1b04,
- 0x1b35, 0x1b43,
- 0x1b80, 0x1b82,
- 0x1ba1, 0x1ba9,
- 0x1bac, 0x1bad,
- 0x1be7, 0x1bf1,
- 0x1c24, 0x1c36,
- 0x1de7, 0x1df4,
- 0x24b6, 0x24e9,
- 0x2de0, 0x2dff,
- 0xa674, 0xa67b,
- 0xa69e, 0xa69f,
- 0xa802, 0xa802,
- 0xa80b, 0xa80b,
- 0xa823, 0xa827,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c3,
- 0xa8c5, 0xa8c5,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92a,
- 0xa947, 0xa952,
- 0xa980, 0xa983,
- 0xa9b4, 0xa9bf,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4d,
- 0xaa7b, 0xaa7d,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabe,
- 0xaaeb, 0xaaef,
- 0xaaf5, 0xaaf5,
- 0xabe3, 0xabea,
- 0xfb1e, 0xfb1e,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10d24, 0x10d27,
- 0x11000, 0x11002,
- 0x11038, 0x11045,
- 0x11082, 0x11082,
- 0x110b0, 0x110b8,
- 0x11100, 0x11102,
- 0x11127, 0x11132,
- 0x11145, 0x11146,
- 0x11180, 0x11182,
- 0x111b3, 0x111bf,
- 0x1122c, 0x11234,
- 0x11237, 0x11237,
- 0x1123e, 0x1123e,
- 0x112df, 0x112e8,
- 0x11300, 0x11303,
- 0x1133e, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134c,
- 0x11357, 0x11357,
- 0x11362, 0x11363,
- 0x11435, 0x11441,
- 0x11443, 0x11445,
- 0x114b0, 0x114c1,
- 0x115af, 0x115b5,
- 0x115b8, 0x115be,
- 0x115dc, 0x115dd,
- 0x11630, 0x1163e,
- 0x11640, 0x11640,
- 0x116ab, 0x116b5,
- 0x1171d, 0x1172a,
- 0x1182c, 0x11838,
- 0x119d1, 0x119d7,
- 0x119da, 0x119df,
- 0x119e4, 0x119e4,
- 0x11a01, 0x11a0a,
- 0x11a35, 0x11a39,
- 0x11a3b, 0x11a3e,
- 0x11a51, 0x11a5b,
- 0x11a8a, 0x11a97,
- 0x11c2f, 0x11c36,
- 0x11c38, 0x11c3e,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d41,
- 0x11d43, 0x11d43,
- 0x11d47, 0x11d47,
- 0x11d8a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d96,
- 0x11ef3, 0x11ef6,
- 0x16f4f, 0x16f4f,
- 0x16f51, 0x16f87,
- 0x16f8f, 0x16f92,
- 0x1bc9e, 0x1bc9e,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e947, 0x1e947,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* CR_Other_Alphabetic */
-
-/* 'Ideographic': Binary Property */
-static const OnigCodePoint CR_Ideographic[] = {
- 16,
- 0x3006, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b170, 0x1b2fb,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
-}; /* CR_Ideographic */
-
-/* 'Diacritic': Binary Property */
-static const OnigCodePoint CR_Diacritic[] = {
- 171,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x00a8, 0x00a8,
- 0x00af, 0x00af,
- 0x00b4, 0x00b4,
- 0x00b7, 0x00b8,
- 0x02b0, 0x034e,
- 0x0350, 0x0357,
- 0x035d, 0x0362,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x0384, 0x0385,
- 0x0483, 0x0487,
- 0x0559, 0x0559,
- 0x0591, 0x05a1,
- 0x05a3, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c4,
- 0x064b, 0x0652,
- 0x0657, 0x0658,
- 0x06df, 0x06e0,
- 0x06e5, 0x06e6,
- 0x06ea, 0x06ec,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f5,
- 0x0818, 0x0819,
- 0x08e3, 0x08fe,
- 0x093c, 0x093c,
- 0x094d, 0x094d,
- 0x0951, 0x0954,
- 0x0971, 0x0971,
- 0x09bc, 0x09bc,
- 0x09cd, 0x09cd,
- 0x0a3c, 0x0a3c,
- 0x0a4d, 0x0a4d,
- 0x0abc, 0x0abc,
- 0x0acd, 0x0acd,
- 0x0afd, 0x0aff,
- 0x0b3c, 0x0b3c,
- 0x0b4d, 0x0b4d,
- 0x0bcd, 0x0bcd,
- 0x0c4d, 0x0c4d,
- 0x0cbc, 0x0cbc,
- 0x0ccd, 0x0ccd,
- 0x0d3b, 0x0d3c,
- 0x0d4d, 0x0d4d,
- 0x0dca, 0x0dca,
- 0x0e47, 0x0e4c,
- 0x0e4e, 0x0e4e,
- 0x0eba, 0x0eba,
- 0x0ec8, 0x0ecc,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f3f,
- 0x0f82, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0fc6, 0x0fc6,
- 0x1037, 0x1037,
- 0x1039, 0x103a,
- 0x1063, 0x1064,
- 0x1069, 0x106d,
- 0x1087, 0x108d,
- 0x108f, 0x108f,
- 0x109a, 0x109b,
- 0x135d, 0x135f,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x1939, 0x193b,
- 0x1a75, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1abd,
- 0x1b34, 0x1b34,
- 0x1b44, 0x1b44,
- 0x1b6b, 0x1b73,
- 0x1baa, 0x1bab,
- 0x1c36, 0x1c37,
- 0x1c78, 0x1c7d,
- 0x1cd0, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf7, 0x1cf9,
- 0x1d2c, 0x1d6a,
- 0x1dc4, 0x1dcf,
- 0x1df5, 0x1df9,
- 0x1dfd, 0x1dff,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x2cef, 0x2cf1,
- 0x2e2f, 0x2e2f,
- 0x302a, 0x302f,
- 0x3099, 0x309c,
- 0x30fc, 0x30fc,
- 0xa66f, 0xa66f,
- 0xa67c, 0xa67d,
- 0xa67f, 0xa67f,
- 0xa69c, 0xa69d,
- 0xa6f0, 0xa6f1,
- 0xa700, 0xa721,
- 0xa788, 0xa78a,
- 0xa7f8, 0xa7f9,
- 0xa8c4, 0xa8c4,
- 0xa8e0, 0xa8f1,
- 0xa92b, 0xa92e,
- 0xa953, 0xa953,
- 0xa9b3, 0xa9b3,
- 0xa9c0, 0xa9c0,
- 0xa9e5, 0xa9e5,
- 0xaa7b, 0xaa7d,
- 0xaabf, 0xaac2,
- 0xaaf6, 0xaaf6,
- 0xab5b, 0xab5f,
- 0xabec, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe20, 0xfe2f,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0xffe3, 0xffe3,
- 0x102e0, 0x102e0,
- 0x10ae5, 0x10ae6,
- 0x10d22, 0x10d27,
- 0x10f46, 0x10f50,
- 0x110b9, 0x110ba,
- 0x11133, 0x11134,
- 0x11173, 0x11173,
- 0x111c0, 0x111c0,
- 0x111ca, 0x111cc,
- 0x11235, 0x11236,
- 0x112e9, 0x112ea,
- 0x1133c, 0x1133c,
- 0x1134d, 0x1134d,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11442, 0x11442,
- 0x11446, 0x11446,
- 0x114c2, 0x114c3,
- 0x115bf, 0x115c0,
- 0x1163f, 0x1163f,
- 0x116b6, 0x116b7,
- 0x1172b, 0x1172b,
- 0x11839, 0x1183a,
- 0x119e0, 0x119e0,
- 0x11a34, 0x11a34,
- 0x11a47, 0x11a47,
- 0x11a99, 0x11a99,
- 0x11c3f, 0x11c3f,
- 0x11d42, 0x11d42,
- 0x11d44, 0x11d45,
- 0x11d97, 0x11d97,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f8f, 0x16f9f,
- 0x1d167, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1e130, 0x1e136,
- 0x1e2ec, 0x1e2ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e946,
- 0x1e948, 0x1e94a,
-}; /* CR_Diacritic */
-
-/* 'Extender': Binary Property */
-static const OnigCodePoint CR_Extender[] = {
- 31,
- 0x00b7, 0x00b7,
- 0x02d0, 0x02d1,
- 0x0640, 0x0640,
- 0x07fa, 0x07fa,
- 0x0e46, 0x0e46,
- 0x0ec6, 0x0ec6,
- 0x180a, 0x180a,
- 0x1843, 0x1843,
- 0x1aa7, 0x1aa7,
- 0x1c36, 0x1c36,
- 0x1c7b, 0x1c7b,
- 0x3005, 0x3005,
- 0x3031, 0x3035,
- 0x309d, 0x309e,
- 0x30fc, 0x30fe,
- 0xa015, 0xa015,
- 0xa60c, 0xa60c,
- 0xa9cf, 0xa9cf,
- 0xa9e6, 0xa9e6,
- 0xaa70, 0xaa70,
- 0xaadd, 0xaadd,
- 0xaaf3, 0xaaf4,
- 0xff70, 0xff70,
- 0x1135d, 0x1135d,
- 0x115c6, 0x115c8,
- 0x11a98, 0x11a98,
- 0x16b42, 0x16b43,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x1e13c, 0x1e13d,
- 0x1e944, 0x1e946,
-}; /* CR_Extender */
-
-/* 'Other_Lowercase': Binary Property */
-static const OnigCodePoint CR_Other_Lowercase[] = {
- 20,
- 0x00aa, 0x00aa,
- 0x00ba, 0x00ba,
- 0x02b0, 0x02b8,
- 0x02c0, 0x02c1,
- 0x02e0, 0x02e4,
- 0x0345, 0x0345,
- 0x037a, 0x037a,
- 0x1d2c, 0x1d6a,
- 0x1d78, 0x1d78,
- 0x1d9b, 0x1dbf,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2170, 0x217f,
- 0x24d0, 0x24e9,
- 0x2c7c, 0x2c7d,
- 0xa69c, 0xa69d,
- 0xa770, 0xa770,
- 0xa7f8, 0xa7f9,
- 0xab5c, 0xab5f,
-}; /* CR_Other_Lowercase */
-
-/* 'Other_Uppercase': Binary Property */
-static const OnigCodePoint CR_Other_Uppercase[] = {
- 5,
- 0x2160, 0x216f,
- 0x24b6, 0x24cf,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* CR_Other_Uppercase */
-
-/* 'Noncharacter_Code_Point': Binary Property */
-static const OnigCodePoint CR_Noncharacter_Code_Point[] = {
- 18,
- 0xfdd0, 0xfdef,
- 0xfffe, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0xeffff,
- 0xffffe, 0xfffff,
- 0x10fffe, 0x10ffff,
-}; /* CR_Noncharacter_Code_Point */
-
-/* 'Other_Grapheme_Extend': Binary Property */
-static const OnigCodePoint CR_Other_Grapheme_Extend[] = {
- 24,
- 0x09be, 0x09be,
- 0x09d7, 0x09d7,
- 0x0b3e, 0x0b3e,
- 0x0b57, 0x0b57,
- 0x0bbe, 0x0bbe,
- 0x0bd7, 0x0bd7,
- 0x0cc2, 0x0cc2,
- 0x0cd5, 0x0cd6,
- 0x0d3e, 0x0d3e,
- 0x0d57, 0x0d57,
- 0x0dcf, 0x0dcf,
- 0x0ddf, 0x0ddf,
- 0x1b35, 0x1b35,
- 0x200c, 0x200c,
- 0x302e, 0x302f,
- 0xff9e, 0xff9f,
- 0x1133e, 0x1133e,
- 0x11357, 0x11357,
- 0x114b0, 0x114b0,
- 0x114bd, 0x114bd,
- 0x115af, 0x115af,
- 0x1d165, 0x1d165,
- 0x1d16e, 0x1d172,
- 0xe0020, 0xe007f,
-}; /* CR_Other_Grapheme_Extend */
-
-/* 'IDS_Binary_Operator': Binary Property */
-static const OnigCodePoint CR_IDS_Binary_Operator[] = {
- 2,
- 0x2ff0, 0x2ff1,
- 0x2ff4, 0x2ffb,
-}; /* CR_IDS_Binary_Operator */
-
-/* 'IDS_Trinary_Operator': Binary Property */
-static const OnigCodePoint CR_IDS_Trinary_Operator[] = {
- 1,
- 0x2ff2, 0x2ff3,
-}; /* CR_IDS_Trinary_Operator */
-
-/* 'Radical': Binary Property */
-static const OnigCodePoint CR_Radical[] = {
- 3,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
-}; /* CR_Radical */
-
-/* 'Unified_Ideograph': Binary Property */
-static const OnigCodePoint CR_Unified_Ideograph[] = {
- 14,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fef,
- 0xfa0e, 0xfa0f,
- 0xfa11, 0xfa11,
- 0xfa13, 0xfa14,
- 0xfa1f, 0xfa1f,
- 0xfa21, 0xfa21,
- 0xfa23, 0xfa24,
- 0xfa27, 0xfa29,
- 0x20000, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
-}; /* CR_Unified_Ideograph */
-
-/* 'Other_Default_Ignorable_Code_Point': Binary Property */
-static const OnigCodePoint CR_Other_Default_Ignorable_Code_Point[] = {
- 11,
- 0x034f, 0x034f,
- 0x115f, 0x1160,
- 0x17b4, 0x17b5,
- 0x2065, 0x2065,
- 0x3164, 0x3164,
- 0xffa0, 0xffa0,
- 0xfff0, 0xfff8,
- 0xe0000, 0xe0000,
- 0xe0002, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xe0fff,
-}; /* CR_Other_Default_Ignorable_Code_Point */
-
-/* 'Deprecated': Binary Property */
-static const OnigCodePoint CR_Deprecated[] = {
- 8,
- 0x0149, 0x0149,
- 0x0673, 0x0673,
- 0x0f77, 0x0f77,
- 0x0f79, 0x0f79,
- 0x17a3, 0x17a4,
- 0x206a, 0x206f,
- 0x2329, 0x232a,
- 0xe0001, 0xe0001,
-}; /* CR_Deprecated */
-
-/* 'Soft_Dotted': Binary Property */
-static const OnigCodePoint CR_Soft_Dotted[] = {
- 31,
- 0x0069, 0x006a,
- 0x012f, 0x012f,
- 0x0249, 0x0249,
- 0x0268, 0x0268,
- 0x029d, 0x029d,
- 0x02b2, 0x02b2,
- 0x03f3, 0x03f3,
- 0x0456, 0x0456,
- 0x0458, 0x0458,
- 0x1d62, 0x1d62,
- 0x1d96, 0x1d96,
- 0x1da4, 0x1da4,
- 0x1da8, 0x1da8,
- 0x1e2d, 0x1e2d,
- 0x1ecb, 0x1ecb,
- 0x2071, 0x2071,
- 0x2148, 0x2149,
- 0x2c7c, 0x2c7c,
- 0x1d422, 0x1d423,
- 0x1d456, 0x1d457,
- 0x1d48a, 0x1d48b,
- 0x1d4be, 0x1d4bf,
- 0x1d4f2, 0x1d4f3,
- 0x1d526, 0x1d527,
- 0x1d55a, 0x1d55b,
- 0x1d58e, 0x1d58f,
- 0x1d5c2, 0x1d5c3,
- 0x1d5f6, 0x1d5f7,
- 0x1d62a, 0x1d62b,
- 0x1d65e, 0x1d65f,
- 0x1d692, 0x1d693,
-}; /* CR_Soft_Dotted */
-
-/* 'Logical_Order_Exception': Binary Property */
-static const OnigCodePoint CR_Logical_Order_Exception[] = {
- 7,
- 0x0e40, 0x0e44,
- 0x0ec0, 0x0ec4,
- 0x19b5, 0x19b7,
- 0x19ba, 0x19ba,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaab9,
- 0xaabb, 0xaabc,
-}; /* CR_Logical_Order_Exception */
-
-/* 'Other_ID_Start': Binary Property */
-static const OnigCodePoint CR_Other_ID_Start[] = {
- 4,
- 0x1885, 0x1886,
- 0x2118, 0x2118,
- 0x212e, 0x212e,
- 0x309b, 0x309c,
-}; /* CR_Other_ID_Start */
-
-/* 'Other_ID_Continue': Binary Property */
-static const OnigCodePoint CR_Other_ID_Continue[] = {
- 4,
- 0x00b7, 0x00b7,
- 0x0387, 0x0387,
- 0x1369, 0x1371,
- 0x19da, 0x19da,
-}; /* CR_Other_ID_Continue */
-
-/* 'Sentence_Terminal': Binary Property */
-static const OnigCodePoint CR_Sentence_Terminal[] = {
- 74,
- 0x0021, 0x0021,
- 0x002e, 0x002e,
- 0x003f, 0x003f,
- 0x0589, 0x0589,
- 0x061e, 0x061f,
- 0x06d4, 0x06d4,
- 0x0700, 0x0702,
- 0x07f9, 0x07f9,
- 0x0837, 0x0837,
- 0x0839, 0x0839,
- 0x083d, 0x083e,
- 0x0964, 0x0965,
- 0x104a, 0x104b,
- 0x1362, 0x1362,
- 0x1367, 0x1368,
- 0x166e, 0x166e,
- 0x1735, 0x1736,
- 0x1803, 0x1803,
- 0x1809, 0x1809,
- 0x1944, 0x1945,
- 0x1aa8, 0x1aab,
- 0x1b5a, 0x1b5b,
- 0x1b5e, 0x1b5f,
- 0x1c3b, 0x1c3c,
- 0x1c7e, 0x1c7f,
- 0x203c, 0x203d,
- 0x2047, 0x2049,
- 0x2e2e, 0x2e2e,
- 0x2e3c, 0x2e3c,
- 0x3002, 0x3002,
- 0xa4ff, 0xa4ff,
- 0xa60e, 0xa60f,
- 0xa6f3, 0xa6f3,
- 0xa6f7, 0xa6f7,
- 0xa876, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa92f, 0xa92f,
- 0xa9c8, 0xa9c9,
- 0xaa5d, 0xaa5f,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 0xfe52, 0xfe52,
- 0xfe56, 0xfe57,
- 0xff01, 0xff01,
- 0xff0e, 0xff0e,
- 0xff1f, 0xff1f,
- 0xff61, 0xff61,
- 0x10a56, 0x10a57,
- 0x10f55, 0x10f59,
- 0x11047, 0x11048,
- 0x110be, 0x110c1,
- 0x11141, 0x11143,
- 0x111c5, 0x111c6,
- 0x111cd, 0x111cd,
- 0x111de, 0x111df,
- 0x11238, 0x11239,
- 0x1123b, 0x1123c,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144c,
- 0x115c2, 0x115c3,
- 0x115c9, 0x115d7,
- 0x11641, 0x11642,
- 0x1173c, 0x1173e,
- 0x11a42, 0x11a43,
- 0x11a9b, 0x11a9c,
- 0x11c41, 0x11c42,
- 0x11ef7, 0x11ef8,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b38,
- 0x16b44, 0x16b44,
- 0x16e98, 0x16e98,
- 0x1bc9f, 0x1bc9f,
- 0x1da88, 0x1da88,
-}; /* CR_Sentence_Terminal */
-
-/* 'Variation_Selector': Binary Property */
-static const OnigCodePoint CR_Variation_Selector[] = {
- 3,
- 0x180b, 0x180d,
- 0xfe00, 0xfe0f,
- 0xe0100, 0xe01ef,
-}; /* CR_Variation_Selector */
-
-/* 'Pattern_White_Space': Binary Property */
-static const OnigCodePoint CR_Pattern_White_Space[] = {
- 5,
- 0x0009, 0x000d,
- 0x0020, 0x0020,
- 0x0085, 0x0085,
- 0x200e, 0x200f,
- 0x2028, 0x2029,
-}; /* CR_Pattern_White_Space */
-
-/* 'Pattern_Syntax': Binary Property */
-static const OnigCodePoint CR_Pattern_Syntax[] = {
- 28,
- 0x0021, 0x002f,
- 0x003a, 0x0040,
- 0x005b, 0x005e,
- 0x0060, 0x0060,
- 0x007b, 0x007e,
- 0x00a1, 0x00a7,
- 0x00a9, 0x00a9,
- 0x00ab, 0x00ac,
- 0x00ae, 0x00ae,
- 0x00b0, 0x00b1,
- 0x00b6, 0x00b6,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x2010, 0x2027,
- 0x2030, 0x203e,
- 0x2041, 0x2053,
- 0x2055, 0x205e,
- 0x2190, 0x245f,
- 0x2500, 0x2775,
- 0x2794, 0x2bff,
- 0x2e00, 0x2e7f,
- 0x3001, 0x3003,
- 0x3008, 0x3020,
- 0x3030, 0x3030,
- 0xfd3e, 0xfd3f,
- 0xfe45, 0xfe46,
-}; /* CR_Pattern_Syntax */
-
-/* 'Prepended_Concatenation_Mark': Binary Property */
-static const OnigCodePoint CR_Prepended_Concatenation_Mark[] = {
- 6,
- 0x0600, 0x0605,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x08e2, 0x08e2,
- 0x110bd, 0x110bd,
- 0x110cd, 0x110cd,
-}; /* CR_Prepended_Concatenation_Mark */
-
-/* 'Regional_Indicator': Binary Property */
-static const OnigCodePoint CR_Regional_Indicator[] = {
- 1,
- 0x1f1e6, 0x1f1ff,
-}; /* CR_Regional_Indicator */
-
-/* 'Emoji': Emoji */
-static const OnigCodePoint CR_Emoji[] = {
- 151,
- 0x0023, 0x0023,
- 0x002a, 0x002a,
- 0x0030, 0x0039,
- 0x00a9, 0x00a9,
- 0x00ae, 0x00ae,
- 0x203c, 0x203c,
- 0x2049, 0x2049,
- 0x2122, 0x2122,
- 0x2139, 0x2139,
- 0x2194, 0x2199,
- 0x21a9, 0x21aa,
- 0x231a, 0x231b,
- 0x2328, 0x2328,
- 0x23cf, 0x23cf,
- 0x23e9, 0x23f3,
- 0x23f8, 0x23fa,
- 0x24c2, 0x24c2,
- 0x25aa, 0x25ab,
- 0x25b6, 0x25b6,
- 0x25c0, 0x25c0,
- 0x25fb, 0x25fe,
- 0x2600, 0x2604,
- 0x260e, 0x260e,
- 0x2611, 0x2611,
- 0x2614, 0x2615,
- 0x2618, 0x2618,
- 0x261d, 0x261d,
- 0x2620, 0x2620,
- 0x2622, 0x2623,
- 0x2626, 0x2626,
- 0x262a, 0x262a,
- 0x262e, 0x262f,
- 0x2638, 0x263a,
- 0x2640, 0x2640,
- 0x2642, 0x2642,
- 0x2648, 0x2653,
- 0x265f, 0x2660,
- 0x2663, 0x2663,
- 0x2665, 0x2666,
- 0x2668, 0x2668,
- 0x267b, 0x267b,
- 0x267e, 0x267f,
- 0x2692, 0x2697,
- 0x2699, 0x2699,
- 0x269b, 0x269c,
- 0x26a0, 0x26a1,
- 0x26aa, 0x26ab,
- 0x26b0, 0x26b1,
- 0x26bd, 0x26be,
- 0x26c4, 0x26c5,
- 0x26c8, 0x26c8,
- 0x26ce, 0x26cf,
- 0x26d1, 0x26d1,
- 0x26d3, 0x26d4,
- 0x26e9, 0x26ea,
- 0x26f0, 0x26f5,
- 0x26f7, 0x26fa,
- 0x26fd, 0x26fd,
- 0x2702, 0x2702,
- 0x2705, 0x2705,
- 0x2708, 0x270d,
- 0x270f, 0x270f,
- 0x2712, 0x2712,
- 0x2714, 0x2714,
- 0x2716, 0x2716,
- 0x271d, 0x271d,
- 0x2721, 0x2721,
- 0x2728, 0x2728,
- 0x2733, 0x2734,
- 0x2744, 0x2744,
- 0x2747, 0x2747,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x2763, 0x2764,
- 0x2795, 0x2797,
- 0x27a1, 0x27a1,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x2934, 0x2935,
- 0x2b05, 0x2b07,
- 0x2b1b, 0x2b1c,
- 0x2b50, 0x2b50,
- 0x2b55, 0x2b55,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x3297, 0x3297,
- 0x3299, 0x3299,
- 0x1f004, 0x1f004,
- 0x1f0cf, 0x1f0cf,
- 0x1f170, 0x1f171,
- 0x1f17e, 0x1f17f,
- 0x1f18e, 0x1f18e,
- 0x1f191, 0x1f19a,
- 0x1f1e6, 0x1f1ff,
- 0x1f201, 0x1f202,
- 0x1f21a, 0x1f21a,
- 0x1f22f, 0x1f22f,
- 0x1f232, 0x1f23a,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f321,
- 0x1f324, 0x1f393,
- 0x1f396, 0x1f397,
- 0x1f399, 0x1f39b,
- 0x1f39e, 0x1f3f0,
- 0x1f3f3, 0x1f3f5,
- 0x1f3f7, 0x1f4fd,
- 0x1f4ff, 0x1f53d,
- 0x1f549, 0x1f54e,
- 0x1f550, 0x1f567,
- 0x1f56f, 0x1f570,
- 0x1f573, 0x1f57a,
- 0x1f587, 0x1f587,
- 0x1f58a, 0x1f58d,
- 0x1f590, 0x1f590,
- 0x1f595, 0x1f596,
- 0x1f5a4, 0x1f5a5,
- 0x1f5a8, 0x1f5a8,
- 0x1f5b1, 0x1f5b2,
- 0x1f5bc, 0x1f5bc,
- 0x1f5c2, 0x1f5c4,
- 0x1f5d1, 0x1f5d3,
- 0x1f5dc, 0x1f5de,
- 0x1f5e1, 0x1f5e1,
- 0x1f5e3, 0x1f5e3,
- 0x1f5e8, 0x1f5e8,
- 0x1f5ef, 0x1f5ef,
- 0x1f5f3, 0x1f5f3,
- 0x1f5fa, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f6cb, 0x1f6d2,
- 0x1f6d5, 0x1f6d5,
- 0x1f6e0, 0x1f6e5,
- 0x1f6e9, 0x1f6e9,
- 0x1f6eb, 0x1f6ec,
- 0x1f6f0, 0x1f6f0,
- 0x1f6f3, 0x1f6fa,
- 0x1f7e0, 0x1f7eb,
- 0x1f90d, 0x1f93a,
- 0x1f93c, 0x1f945,
- 0x1f947, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1f9ff,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
-}; /* CR_Emoji */
-
-/* 'Emoji_Presentation': Emoji */
-static const OnigCodePoint CR_Emoji_Presentation[] = {
- 81,
- 0x231a, 0x231b,
- 0x23e9, 0x23ec,
- 0x23f0, 0x23f0,
- 0x23f3, 0x23f3,
- 0x25fd, 0x25fe,
- 0x2614, 0x2615,
- 0x2648, 0x2653,
- 0x267f, 0x267f,
- 0x2693, 0x2693,
- 0x26a1, 0x26a1,
- 0x26aa, 0x26ab,
- 0x26bd, 0x26be,
- 0x26c4, 0x26c5,
- 0x26ce, 0x26ce,
- 0x26d4, 0x26d4,
- 0x26ea, 0x26ea,
- 0x26f2, 0x26f3,
- 0x26f5, 0x26f5,
- 0x26fa, 0x26fa,
- 0x26fd, 0x26fd,
- 0x2705, 0x2705,
- 0x270a, 0x270b,
- 0x2728, 0x2728,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x2795, 0x2797,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x2b1b, 0x2b1c,
- 0x2b50, 0x2b50,
- 0x2b55, 0x2b55,
- 0x1f004, 0x1f004,
- 0x1f0cf, 0x1f0cf,
- 0x1f18e, 0x1f18e,
- 0x1f191, 0x1f19a,
- 0x1f1e6, 0x1f1ff,
- 0x1f201, 0x1f201,
- 0x1f21a, 0x1f21a,
- 0x1f22f, 0x1f22f,
- 0x1f232, 0x1f236,
- 0x1f238, 0x1f23a,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f32d, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f37e, 0x1f393,
- 0x1f3a0, 0x1f3ca,
- 0x1f3cf, 0x1f3d3,
- 0x1f3e0, 0x1f3f0,
- 0x1f3f4, 0x1f3f4,
- 0x1f3f8, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4fc,
- 0x1f4ff, 0x1f53d,
- 0x1f54b, 0x1f54e,
- 0x1f550, 0x1f567,
- 0x1f57a, 0x1f57a,
- 0x1f595, 0x1f596,
- 0x1f5a4, 0x1f5a4,
- 0x1f5fb, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f6cc, 0x1f6cc,
- 0x1f6d0, 0x1f6d2,
- 0x1f6d5, 0x1f6d5,
- 0x1f6eb, 0x1f6ec,
- 0x1f6f4, 0x1f6fa,
- 0x1f7e0, 0x1f7eb,
- 0x1f90d, 0x1f93a,
- 0x1f93c, 0x1f945,
- 0x1f947, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1f9ff,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
-}; /* CR_Emoji_Presentation */
-
-/* 'Emoji_Modifier': Emoji */
-static const OnigCodePoint CR_Emoji_Modifier[] = {
- 1,
- 0x1f3fb, 0x1f3ff,
-}; /* CR_Emoji_Modifier */
-
-/* 'Emoji_Modifier_Base': Emoji */
-static const OnigCodePoint CR_Emoji_Modifier_Base[] = {
- 36,
- 0x261d, 0x261d,
- 0x26f9, 0x26f9,
- 0x270a, 0x270d,
- 0x1f385, 0x1f385,
- 0x1f3c2, 0x1f3c4,
- 0x1f3c7, 0x1f3c7,
- 0x1f3ca, 0x1f3cc,
- 0x1f442, 0x1f443,
- 0x1f446, 0x1f450,
- 0x1f466, 0x1f478,
- 0x1f47c, 0x1f47c,
- 0x1f481, 0x1f483,
- 0x1f485, 0x1f487,
- 0x1f48f, 0x1f48f,
- 0x1f491, 0x1f491,
- 0x1f4aa, 0x1f4aa,
- 0x1f574, 0x1f575,
- 0x1f57a, 0x1f57a,
- 0x1f590, 0x1f590,
- 0x1f595, 0x1f596,
- 0x1f645, 0x1f647,
- 0x1f64b, 0x1f64f,
- 0x1f6a3, 0x1f6a3,
- 0x1f6b4, 0x1f6b6,
- 0x1f6c0, 0x1f6c0,
- 0x1f6cc, 0x1f6cc,
- 0x1f90f, 0x1f90f,
- 0x1f918, 0x1f91f,
- 0x1f926, 0x1f926,
- 0x1f930, 0x1f939,
- 0x1f93c, 0x1f93e,
- 0x1f9b5, 0x1f9b6,
- 0x1f9b8, 0x1f9b9,
- 0x1f9bb, 0x1f9bb,
- 0x1f9cd, 0x1f9cf,
- 0x1f9d1, 0x1f9dd,
-}; /* CR_Emoji_Modifier_Base */
-
-/* 'Emoji_Component': Emoji */
-static const OnigCodePoint CR_Emoji_Component[] = {
- 10,
- 0x0023, 0x0023,
- 0x002a, 0x002a,
- 0x0030, 0x0039,
- 0x200d, 0x200d,
- 0x20e3, 0x20e3,
- 0xfe0f, 0xfe0f,
- 0x1f1e6, 0x1f1ff,
- 0x1f3fb, 0x1f3ff,
- 0x1f9b0, 0x1f9b3,
- 0xe0020, 0xe007f,
-}; /* CR_Emoji_Component */
-
-/* 'Extended_Pictographic': Emoji */
-static const OnigCodePoint CR_Extended_Pictographic[] = {
- 77,
- 0x00a9, 0x00a9,
- 0x00ae, 0x00ae,
- 0x203c, 0x203c,
- 0x2049, 0x2049,
- 0x2122, 0x2122,
- 0x2139, 0x2139,
- 0x2194, 0x2199,
- 0x21a9, 0x21aa,
- 0x231a, 0x231b,
- 0x2328, 0x2328,
- 0x2388, 0x2388,
- 0x23cf, 0x23cf,
- 0x23e9, 0x23f3,
- 0x23f8, 0x23fa,
- 0x24c2, 0x24c2,
- 0x25aa, 0x25ab,
- 0x25b6, 0x25b6,
- 0x25c0, 0x25c0,
- 0x25fb, 0x25fe,
- 0x2600, 0x2605,
- 0x2607, 0x2612,
- 0x2614, 0x2685,
- 0x2690, 0x2705,
- 0x2708, 0x2712,
- 0x2714, 0x2714,
- 0x2716, 0x2716,
- 0x271d, 0x271d,
- 0x2721, 0x2721,
- 0x2728, 0x2728,
- 0x2733, 0x2734,
- 0x2744, 0x2744,
- 0x2747, 0x2747,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x2763, 0x2767,
- 0x2795, 0x2797,
- 0x27a1, 0x27a1,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x2934, 0x2935,
- 0x2b05, 0x2b07,
- 0x2b1b, 0x2b1c,
- 0x2b50, 0x2b50,
- 0x2b55, 0x2b55,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x3297, 0x3297,
- 0x3299, 0x3299,
- 0x1f000, 0x1f0ff,
- 0x1f10d, 0x1f10f,
- 0x1f12f, 0x1f12f,
- 0x1f16c, 0x1f171,
- 0x1f17e, 0x1f17f,
- 0x1f18e, 0x1f18e,
- 0x1f191, 0x1f19a,
- 0x1f1ad, 0x1f1e5,
- 0x1f201, 0x1f20f,
- 0x1f21a, 0x1f21a,
- 0x1f22f, 0x1f22f,
- 0x1f232, 0x1f23a,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f3fa,
- 0x1f400, 0x1f53d,
- 0x1f546, 0x1f64f,
- 0x1f680, 0x1f6ff,
- 0x1f774, 0x1f77f,
- 0x1f7d5, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8ff,
- 0x1f90c, 0x1f93a,
- 0x1f93c, 0x1f945,
- 0x1f947, 0x1fffd,
-}; /* CR_Extended_Pictographic */
-
-/* 'Unknown': Script */
-static const OnigCodePoint CR_Unknown[] = {
- 664,
- 0x0378, 0x0379,
- 0x0380, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x0530, 0x0530,
- 0x0557, 0x0558,
- 0x058b, 0x058c,
- 0x0590, 0x0590,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ee,
- 0x05f5, 0x05ff,
- 0x061d, 0x061d,
- 0x070e, 0x070e,
- 0x074b, 0x074c,
- 0x07b2, 0x07bf,
- 0x07fb, 0x07fc,
- 0x082e, 0x082f,
- 0x083f, 0x083f,
- 0x085c, 0x085d,
- 0x085f, 0x085f,
- 0x086b, 0x089f,
- 0x08b5, 0x08b5,
- 0x08be, 0x08d2,
- 0x0984, 0x0984,
- 0x098d, 0x098e,
- 0x0991, 0x0992,
- 0x09a9, 0x09a9,
- 0x09b1, 0x09b1,
- 0x09b3, 0x09b5,
- 0x09ba, 0x09bb,
- 0x09c5, 0x09c6,
- 0x09c9, 0x09ca,
- 0x09cf, 0x09d6,
- 0x09d8, 0x09db,
- 0x09de, 0x09de,
- 0x09e4, 0x09e5,
- 0x09ff, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a50,
- 0x0a52, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a77, 0x0a80,
- 0x0a84, 0x0a84,
- 0x0a8e, 0x0a8e,
- 0x0a92, 0x0a92,
- 0x0aa9, 0x0aa9,
- 0x0ab1, 0x0ab1,
- 0x0ab4, 0x0ab4,
- 0x0aba, 0x0abb,
- 0x0ac6, 0x0ac6,
- 0x0aca, 0x0aca,
- 0x0ace, 0x0acf,
- 0x0ad1, 0x0adf,
- 0x0ae4, 0x0ae5,
- 0x0af2, 0x0af8,
- 0x0b00, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b45, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b55,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b64, 0x0b65,
- 0x0b78, 0x0b81,
- 0x0b84, 0x0b84,
- 0x0b8b, 0x0b8d,
- 0x0b91, 0x0b91,
- 0x0b96, 0x0b98,
- 0x0b9b, 0x0b9b,
- 0x0b9d, 0x0b9d,
- 0x0ba0, 0x0ba2,
- 0x0ba5, 0x0ba7,
- 0x0bab, 0x0bad,
- 0x0bba, 0x0bbd,
- 0x0bc3, 0x0bc5,
- 0x0bc9, 0x0bc9,
- 0x0bce, 0x0bcf,
- 0x0bd1, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0bff,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c3a, 0x0c3c,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c57,
- 0x0c5b, 0x0c5f,
- 0x0c64, 0x0c65,
- 0x0c70, 0x0c76,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdd,
- 0x0cdf, 0x0cdf,
- 0x0ce4, 0x0ce5,
- 0x0cf0, 0x0cf0,
- 0x0cf3, 0x0cff,
- 0x0d04, 0x0d04,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d45, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d50, 0x0d53,
- 0x0d64, 0x0d65,
- 0x0d80, 0x0d81,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0de5,
- 0x0df0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e85,
- 0x0e8b, 0x0e8b,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ece, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ee0, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6d, 0x0f70,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fcd,
- 0x0fdb, 0x0fff,
- 0x10c6, 0x10c6,
- 0x10c8, 0x10cc,
- 0x10ce, 0x10cf,
- 0x1249, 0x1249,
- 0x124e, 0x124f,
- 0x1257, 0x1257,
- 0x1259, 0x1259,
- 0x125e, 0x125f,
- 0x1289, 0x1289,
- 0x128e, 0x128f,
- 0x12b1, 0x12b1,
- 0x12b6, 0x12b7,
- 0x12bf, 0x12bf,
- 0x12c1, 0x12c1,
- 0x12c6, 0x12c7,
- 0x12d7, 0x12d7,
- 0x1311, 0x1311,
- 0x1316, 0x1317,
- 0x135b, 0x135c,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f6, 0x13f7,
- 0x13fe, 0x13ff,
- 0x169d, 0x169f,
- 0x16f9, 0x16ff,
- 0x170d, 0x170d,
- 0x1715, 0x171f,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x180f, 0x180f,
- 0x181a, 0x181f,
- 0x1879, 0x187f,
- 0x18ab, 0x18af,
- 0x18f6, 0x18ff,
- 0x191f, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19ac, 0x19af,
- 0x19ca, 0x19cf,
- 0x19db, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a5f, 0x1a5f,
- 0x1a7d, 0x1a7e,
- 0x1a8a, 0x1a8f,
- 0x1a9a, 0x1a9f,
- 0x1aae, 0x1aaf,
- 0x1abf, 0x1aff,
- 0x1b4c, 0x1b4f,
- 0x1b7d, 0x1b7f,
- 0x1bf4, 0x1bfb,
- 0x1c38, 0x1c3a,
- 0x1c4a, 0x1c4c,
- 0x1c89, 0x1c8f,
- 0x1cbb, 0x1cbc,
- 0x1cc8, 0x1ccf,
- 0x1cfb, 0x1cff,
- 0x1dfa, 0x1dfa,
- 0x1f16, 0x1f17,
- 0x1f1e, 0x1f1f,
- 0x1f46, 0x1f47,
- 0x1f4e, 0x1f4f,
- 0x1f58, 0x1f58,
- 0x1f5a, 0x1f5a,
- 0x1f5c, 0x1f5c,
- 0x1f5e, 0x1f5e,
- 0x1f7e, 0x1f7f,
- 0x1fb5, 0x1fb5,
- 0x1fc5, 0x1fc5,
- 0x1fd4, 0x1fd5,
- 0x1fdc, 0x1fdc,
- 0x1ff0, 0x1ff1,
- 0x1ff5, 0x1ff5,
- 0x1fff, 0x1fff,
- 0x2065, 0x2065,
- 0x2072, 0x2073,
- 0x208f, 0x208f,
- 0x209d, 0x209f,
- 0x20c0, 0x20cf,
- 0x20f1, 0x20ff,
- 0x218c, 0x218f,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x2b74, 0x2b75,
- 0x2b96, 0x2b97,
- 0x2c2f, 0x2c2f,
- 0x2c5f, 0x2c5f,
- 0x2cf4, 0x2cf8,
- 0x2d26, 0x2d26,
- 0x2d28, 0x2d2c,
- 0x2d2e, 0x2d2f,
- 0x2d68, 0x2d6e,
- 0x2d71, 0x2d7e,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2ddf,
- 0x2e50, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x3130, 0x3130,
- 0x318f, 0x318f,
- 0x31bb, 0x31bf,
- 0x31e4, 0x31ef,
- 0x321f, 0x321f,
- 0x4db6, 0x4dbf,
- 0x9ff0, 0x9fff,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa4cf,
- 0xa62c, 0xa63f,
- 0xa6f8, 0xa6ff,
- 0xa7c0, 0xa7c1,
- 0xa7c7, 0xa7f6,
- 0xa82c, 0xa82f,
- 0xa83a, 0xa83f,
- 0xa878, 0xa87f,
- 0xa8c6, 0xa8cd,
- 0xa8da, 0xa8df,
- 0xa954, 0xa95e,
- 0xa97d, 0xa97f,
- 0xa9ce, 0xa9ce,
- 0xa9da, 0xa9dd,
- 0xa9ff, 0xa9ff,
- 0xaa37, 0xaa3f,
- 0xaa4e, 0xaa4f,
- 0xaa5a, 0xaa5b,
- 0xaac3, 0xaada,
- 0xaaf7, 0xab00,
- 0xab07, 0xab08,
- 0xab0f, 0xab10,
- 0xab17, 0xab1f,
- 0xab27, 0xab27,
- 0xab2f, 0xab2f,
- 0xab68, 0xab6f,
- 0xabee, 0xabef,
- 0xabfa, 0xabff,
- 0xd7a4, 0xd7af,
- 0xd7c7, 0xd7ca,
- 0xd7fc, 0xf8ff,
- 0xfa6e, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbc2, 0xfbd2,
- 0xfd40, 0xfd4f,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdef,
- 0xfdfe, 0xfdff,
- 0xfe1a, 0xfe1f,
- 0xfe53, 0xfe53,
- 0xfe67, 0xfe67,
- 0xfe6c, 0xfe6f,
- 0xfe75, 0xfe75,
- 0xfefd, 0xfefe,
- 0xff00, 0xff00,
- 0xffbf, 0xffc1,
- 0xffc8, 0xffc9,
- 0xffd0, 0xffd1,
- 0xffd8, 0xffd9,
- 0xffdd, 0xffdf,
- 0xffe7, 0xffe7,
- 0xffef, 0xfff8,
- 0xfffe, 0xffff,
- 0x1000c, 0x1000c,
- 0x10027, 0x10027,
- 0x1003b, 0x1003b,
- 0x1003e, 0x1003e,
- 0x1004e, 0x1004f,
- 0x1005e, 0x1007f,
- 0x100fb, 0x100ff,
- 0x10103, 0x10106,
- 0x10134, 0x10136,
- 0x1018f, 0x1018f,
- 0x1019c, 0x1019f,
- 0x101a1, 0x101cf,
- 0x101fe, 0x1027f,
- 0x1029d, 0x1029f,
- 0x102d1, 0x102df,
- 0x102fc, 0x102ff,
- 0x10324, 0x1032c,
- 0x1034b, 0x1034f,
- 0x1037b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x104af,
- 0x104d4, 0x104d7,
- 0x104fc, 0x104ff,
- 0x10528, 0x1052f,
- 0x10564, 0x1056e,
- 0x10570, 0x105ff,
- 0x10737, 0x1073f,
- 0x10756, 0x1075f,
- 0x10768, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10856, 0x10856,
- 0x1089f, 0x108a6,
- 0x108b0, 0x108df,
- 0x108f3, 0x108f3,
- 0x108f6, 0x108fa,
- 0x1091c, 0x1091e,
- 0x1093a, 0x1093e,
- 0x10940, 0x1097f,
- 0x109b8, 0x109bb,
- 0x109d0, 0x109d1,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a36, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a49, 0x10a4f,
- 0x10a59, 0x10a5f,
- 0x10aa0, 0x10abf,
- 0x10ae7, 0x10aea,
- 0x10af7, 0x10aff,
- 0x10b36, 0x10b38,
- 0x10b56, 0x10b57,
- 0x10b73, 0x10b77,
- 0x10b92, 0x10b98,
- 0x10b9d, 0x10ba8,
- 0x10bb0, 0x10bff,
- 0x10c49, 0x10c7f,
- 0x10cb3, 0x10cbf,
- 0x10cf3, 0x10cf9,
- 0x10d28, 0x10d2f,
- 0x10d3a, 0x10e5f,
- 0x10e7f, 0x10eff,
- 0x10f28, 0x10f2f,
- 0x10f5a, 0x10fdf,
- 0x10ff7, 0x10fff,
- 0x1104e, 0x11051,
- 0x11070, 0x1107e,
- 0x110c2, 0x110cc,
- 0x110ce, 0x110cf,
- 0x110e9, 0x110ef,
- 0x110fa, 0x110ff,
- 0x11135, 0x11135,
- 0x11147, 0x1114f,
- 0x11177, 0x1117f,
- 0x111ce, 0x111cf,
- 0x111e0, 0x111e0,
- 0x111f5, 0x111ff,
- 0x11212, 0x11212,
- 0x1123f, 0x1127f,
- 0x11287, 0x11287,
- 0x11289, 0x11289,
- 0x1128e, 0x1128e,
- 0x1129e, 0x1129e,
- 0x112aa, 0x112af,
- 0x112eb, 0x112ef,
- 0x112fa, 0x112ff,
- 0x11304, 0x11304,
- 0x1130d, 0x1130e,
- 0x11311, 0x11312,
- 0x11329, 0x11329,
- 0x11331, 0x11331,
- 0x11334, 0x11334,
- 0x1133a, 0x1133a,
- 0x11345, 0x11346,
- 0x11349, 0x1134a,
- 0x1134e, 0x1134f,
- 0x11351, 0x11356,
- 0x11358, 0x1135c,
- 0x11364, 0x11365,
- 0x1136d, 0x1136f,
- 0x11375, 0x113ff,
- 0x1145a, 0x1145a,
- 0x1145c, 0x1145c,
- 0x11460, 0x1147f,
- 0x114c8, 0x114cf,
- 0x114da, 0x1157f,
- 0x115b6, 0x115b7,
- 0x115de, 0x115ff,
- 0x11645, 0x1164f,
- 0x1165a, 0x1165f,
- 0x1166d, 0x1167f,
- 0x116b9, 0x116bf,
- 0x116ca, 0x116ff,
- 0x1171b, 0x1171c,
- 0x1172c, 0x1172f,
- 0x11740, 0x117ff,
- 0x1183c, 0x1189f,
- 0x118f3, 0x118fe,
- 0x11900, 0x1199f,
- 0x119a8, 0x119a9,
- 0x119d8, 0x119d9,
- 0x119e5, 0x119ff,
- 0x11a48, 0x11a4f,
- 0x11aa3, 0x11abf,
- 0x11af9, 0x11bff,
- 0x11c09, 0x11c09,
- 0x11c37, 0x11c37,
- 0x11c46, 0x11c4f,
- 0x11c6d, 0x11c6f,
- 0x11c90, 0x11c91,
- 0x11ca8, 0x11ca8,
- 0x11cb7, 0x11cff,
- 0x11d07, 0x11d07,
- 0x11d0a, 0x11d0a,
- 0x11d37, 0x11d39,
- 0x11d3b, 0x11d3b,
- 0x11d3e, 0x11d3e,
- 0x11d48, 0x11d4f,
- 0x11d5a, 0x11d5f,
- 0x11d66, 0x11d66,
- 0x11d69, 0x11d69,
- 0x11d8f, 0x11d8f,
- 0x11d92, 0x11d92,
- 0x11d99, 0x11d9f,
- 0x11daa, 0x11edf,
- 0x11ef9, 0x11fbf,
- 0x11ff2, 0x11ffe,
- 0x1239a, 0x123ff,
- 0x1246f, 0x1246f,
- 0x12475, 0x1247f,
- 0x12544, 0x12fff,
- 0x1342f, 0x1342f,
- 0x13439, 0x143ff,
- 0x14647, 0x167ff,
- 0x16a39, 0x16a3f,
- 0x16a5f, 0x16a5f,
- 0x16a6a, 0x16a6d,
- 0x16a70, 0x16acf,
- 0x16aee, 0x16aef,
- 0x16af6, 0x16aff,
- 0x16b46, 0x16b4f,
- 0x16b5a, 0x16b5a,
- 0x16b62, 0x16b62,
- 0x16b78, 0x16b7c,
- 0x16b90, 0x16e3f,
- 0x16e9b, 0x16eff,
- 0x16f4b, 0x16f4e,
- 0x16f88, 0x16f8e,
- 0x16fa0, 0x16fdf,
- 0x16fe4, 0x16fff,
- 0x187f8, 0x187ff,
- 0x18af3, 0x1afff,
- 0x1b11f, 0x1b14f,
- 0x1b153, 0x1b163,
- 0x1b168, 0x1b16f,
- 0x1b2fc, 0x1bbff,
- 0x1bc6b, 0x1bc6f,
- 0x1bc7d, 0x1bc7f,
- 0x1bc89, 0x1bc8f,
- 0x1bc9a, 0x1bc9b,
- 0x1bca4, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d128,
- 0x1d1e9, 0x1d1ff,
- 0x1d246, 0x1d2df,
- 0x1d2f4, 0x1d2ff,
- 0x1d357, 0x1d35f,
- 0x1d379, 0x1d3ff,
- 0x1d455, 0x1d455,
- 0x1d49d, 0x1d49d,
- 0x1d4a0, 0x1d4a1,
- 0x1d4a3, 0x1d4a4,
- 0x1d4a7, 0x1d4a8,
- 0x1d4ad, 0x1d4ad,
- 0x1d4ba, 0x1d4ba,
- 0x1d4bc, 0x1d4bc,
- 0x1d4c4, 0x1d4c4,
- 0x1d506, 0x1d506,
- 0x1d50b, 0x1d50c,
- 0x1d515, 0x1d515,
- 0x1d51d, 0x1d51d,
- 0x1d53a, 0x1d53a,
- 0x1d53f, 0x1d53f,
- 0x1d545, 0x1d545,
- 0x1d547, 0x1d549,
- 0x1d551, 0x1d551,
- 0x1d6a6, 0x1d6a7,
- 0x1d7cc, 0x1d7cd,
- 0x1da8c, 0x1da9a,
- 0x1daa0, 0x1daa0,
- 0x1dab0, 0x1dfff,
- 0x1e007, 0x1e007,
- 0x1e019, 0x1e01a,
- 0x1e022, 0x1e022,
- 0x1e025, 0x1e025,
- 0x1e02b, 0x1e0ff,
- 0x1e12d, 0x1e12f,
- 0x1e13e, 0x1e13f,
- 0x1e14a, 0x1e14d,
- 0x1e150, 0x1e2bf,
- 0x1e2fa, 0x1e2fe,
- 0x1e300, 0x1e7ff,
- 0x1e8c5, 0x1e8c6,
- 0x1e8d7, 0x1e8ff,
- 0x1e94c, 0x1e94f,
- 0x1e95a, 0x1e95d,
- 0x1e960, 0x1ec70,
- 0x1ecb5, 0x1ed00,
- 0x1ed3e, 0x1edff,
- 0x1ee04, 0x1ee04,
- 0x1ee20, 0x1ee20,
- 0x1ee23, 0x1ee23,
- 0x1ee25, 0x1ee26,
- 0x1ee28, 0x1ee28,
- 0x1ee33, 0x1ee33,
- 0x1ee38, 0x1ee38,
- 0x1ee3a, 0x1ee3a,
- 0x1ee3c, 0x1ee41,
- 0x1ee43, 0x1ee46,
- 0x1ee48, 0x1ee48,
- 0x1ee4a, 0x1ee4a,
- 0x1ee4c, 0x1ee4c,
- 0x1ee50, 0x1ee50,
- 0x1ee53, 0x1ee53,
- 0x1ee55, 0x1ee56,
- 0x1ee58, 0x1ee58,
- 0x1ee5a, 0x1ee5a,
- 0x1ee5c, 0x1ee5c,
- 0x1ee5e, 0x1ee5e,
- 0x1ee60, 0x1ee60,
- 0x1ee63, 0x1ee63,
- 0x1ee65, 0x1ee66,
- 0x1ee6b, 0x1ee6b,
- 0x1ee73, 0x1ee73,
- 0x1ee78, 0x1ee78,
- 0x1ee7d, 0x1ee7d,
- 0x1ee7f, 0x1ee7f,
- 0x1ee8a, 0x1ee8a,
- 0x1ee9c, 0x1eea0,
- 0x1eea4, 0x1eea4,
- 0x1eeaa, 0x1eeaa,
- 0x1eebc, 0x1eeef,
- 0x1eef2, 0x1efff,
- 0x1f02c, 0x1f02f,
- 0x1f094, 0x1f09f,
- 0x1f0af, 0x1f0b0,
- 0x1f0c0, 0x1f0c0,
- 0x1f0d0, 0x1f0d0,
- 0x1f0f6, 0x1f0ff,
- 0x1f10d, 0x1f10f,
- 0x1f16d, 0x1f16f,
- 0x1f1ad, 0x1f1e5,
- 0x1f203, 0x1f20f,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f24f,
- 0x1f252, 0x1f25f,
- 0x1f266, 0x1f2ff,
- 0x1f6d6, 0x1f6df,
- 0x1f6ed, 0x1f6ef,
- 0x1f6fb, 0x1f6ff,
- 0x1f774, 0x1f77f,
- 0x1f7d9, 0x1f7df,
- 0x1f7ec, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8ff,
- 0x1f90c, 0x1f90c,
- 0x1f972, 0x1f972,
- 0x1f977, 0x1f979,
- 0x1f9a3, 0x1f9a4,
- 0x1f9ab, 0x1f9ad,
- 0x1f9cb, 0x1f9cc,
- 0x1fa54, 0x1fa5f,
- 0x1fa6e, 0x1fa6f,
- 0x1fa74, 0x1fa77,
- 0x1fa7b, 0x1fa7f,
- 0x1fa83, 0x1fa8f,
- 0x1fa96, 0x1ffff,
- 0x2a6d7, 0x2a6ff,
- 0x2b735, 0x2b73f,
- 0x2b81e, 0x2b81f,
- 0x2cea2, 0x2ceaf,
- 0x2ebe1, 0x2f7ff,
- 0x2fa1e, 0xe0000,
- 0xe0002, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0x10ffff,
-}; /* CR_Unknown */
-
-#ifdef USE_UNICODE_AGE_PROPERTIES
-/* 'Age_1_1': Derived Age 1.1 */
-static const OnigCodePoint CR_Age_1_1[] = {
- 288,
- 0x0000, 0x01f5,
- 0x01fa, 0x0217,
- 0x0250, 0x02a8,
- 0x02b0, 0x02de,
- 0x02e0, 0x02e9,
- 0x0300, 0x0345,
- 0x0360, 0x0361,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d6,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03f3,
- 0x0401, 0x040c,
- 0x040e, 0x044f,
- 0x0451, 0x045c,
- 0x045e, 0x0486,
- 0x0490, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04eb,
- 0x04ee, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x0589,
- 0x05b0, 0x05b9,
- 0x05bb, 0x05c3,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0652,
- 0x0660, 0x066d,
- 0x0670, 0x06b7,
- 0x06ba, 0x06be,
- 0x06c0, 0x06ce,
- 0x06d0, 0x06ed,
- 0x06f0, 0x06f9,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 0x0bf2,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1e00, 0x1e9a,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x202e,
- 0x2030, 0x2046,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20aa,
- 0x20d0, 0x20e1,
- 0x2100, 0x2138,
- 0x2153, 0x2182,
- 0x2190, 0x21ea,
- 0x2200, 0x22f1,
- 0x2300, 0x2300,
- 0x2302, 0x237a,
- 0x2400, 0x2424,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25ef,
- 0x2600, 0x2613,
- 0x261a, 0x266f,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x3000, 0x3037,
- 0x303f, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x319f,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x4e00, 0x9fa5,
- 0xe000, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1e, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffd, 0xffff,
-}; /* CR_Age_1_1 */
-
-/* 'Age_2_0': Derived Age 2.0 */
-static const OnigCodePoint CR_Age_2_0[] = {
- 312,
- 0x0000, 0x01f5,
- 0x01fa, 0x0217,
- 0x0250, 0x02a8,
- 0x02b0, 0x02de,
- 0x02e0, 0x02e9,
- 0x0300, 0x0345,
- 0x0360, 0x0361,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d6,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03f3,
- 0x0401, 0x040c,
- 0x040e, 0x044f,
- 0x0451, 0x045c,
- 0x045e, 0x0486,
- 0x0490, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04eb,
- 0x04ee, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x0589,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0652,
- 0x0660, 0x066d,
- 0x0670, 0x06b7,
- 0x06ba, 0x06be,
- 0x06c0, 0x06ce,
- 0x06d0, 0x06ed,
- 0x06f0, 0x06f9,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 0x0bf2,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f69,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f95,
- 0x0f97, 0x0f97,
- 0x0f99, 0x0fad,
- 0x0fb1, 0x0fb7,
- 0x0fb9, 0x0fb9,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x202e,
- 0x2030, 0x2046,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20ab,
- 0x20d0, 0x20e1,
- 0x2100, 0x2138,
- 0x2153, 0x2182,
- 0x2190, 0x21ea,
- 0x2200, 0x22f1,
- 0x2300, 0x2300,
- 0x2302, 0x237a,
- 0x2400, 0x2424,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25ef,
- 0x2600, 0x2613,
- 0x261a, 0x266f,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x3000, 0x3037,
- 0x303f, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x319f,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x4e00, 0x9fa5,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1e, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffd, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_2_0 */
-
-/* 'Age_2_1': Derived Age 2.1 */
-static const OnigCodePoint CR_Age_2_1[] = {
- 312,
- 0x0000, 0x01f5,
- 0x01fa, 0x0217,
- 0x0250, 0x02a8,
- 0x02b0, 0x02de,
- 0x02e0, 0x02e9,
- 0x0300, 0x0345,
- 0x0360, 0x0361,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d6,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03f3,
- 0x0401, 0x040c,
- 0x040e, 0x044f,
- 0x0451, 0x045c,
- 0x045e, 0x0486,
- 0x0490, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04eb,
- 0x04ee, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x0589,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0652,
- 0x0660, 0x066d,
- 0x0670, 0x06b7,
- 0x06ba, 0x06be,
- 0x06c0, 0x06ce,
- 0x06d0, 0x06ed,
- 0x06f0, 0x06f9,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 0x0bf2,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f69,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f95,
- 0x0f97, 0x0f97,
- 0x0f99, 0x0fad,
- 0x0fb1, 0x0fb7,
- 0x0fb9, 0x0fb9,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x202e,
- 0x2030, 0x2046,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20ac,
- 0x20d0, 0x20e1,
- 0x2100, 0x2138,
- 0x2153, 0x2182,
- 0x2190, 0x21ea,
- 0x2200, 0x22f1,
- 0x2300, 0x2300,
- 0x2302, 0x237a,
- 0x2400, 0x2424,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25ef,
- 0x2600, 0x2613,
- 0x261a, 0x266f,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x3000, 0x3037,
- 0x303f, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x319f,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x4e00, 0x9fa5,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1e, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffc, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_2_1 */
-
-/* 'Age_3_0': Derived Age 3.0 */
-static const OnigCodePoint CR_Age_3_0[] = {
- 369,
- 0x0000, 0x021f,
- 0x0222, 0x0233,
- 0x0250, 0x02ad,
- 0x02b0, 0x02ee,
- 0x0300, 0x034e,
- 0x0360, 0x0362,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d7,
- 0x03da, 0x03f3,
- 0x0400, 0x0486,
- 0x0488, 0x0489,
- 0x048c, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0655,
- 0x0660, 0x066d,
- 0x0670, 0x06ed,
- 0x06f0, 0x06fe,
- 0x0700, 0x070d,
- 0x070f, 0x072c,
- 0x0730, 0x074a,
- 0x0780, 0x07b0,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 0x0bf2,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1780, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2046,
- 0x2048, 0x204d,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20af,
- 0x20d0, 0x20e3,
- 0x2100, 0x213a,
- 0x2153, 0x2183,
- 0x2190, 0x21f3,
- 0x2200, 0x22f1,
- 0x2300, 0x237b,
- 0x237d, 0x239a,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25f7,
- 0x2600, 0x2613,
- 0x2619, 0x2671,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x2800, 0x28ff,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303a,
- 0x303e, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4a1,
- 0xa4a4, 0xa4b3,
- 0xa4b5, 0xa4c0,
- 0xa4c2, 0xa4c4,
- 0xa4c6, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_3_0 */
-
-/* 'Age_3_1': Derived Age 3.1 */
-static const OnigCodePoint CR_Age_3_1[] = {
- 402,
- 0x0000, 0x021f,
- 0x0222, 0x0233,
- 0x0250, 0x02ad,
- 0x02b0, 0x02ee,
- 0x0300, 0x034e,
- 0x0360, 0x0362,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d7,
- 0x03da, 0x03f5,
- 0x0400, 0x0486,
- 0x0488, 0x0489,
- 0x048c, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0655,
- 0x0660, 0x066d,
- 0x0670, 0x06ed,
- 0x06f0, 0x06fe,
- 0x0700, 0x070d,
- 0x070f, 0x072c,
- 0x0730, 0x074a,
- 0x0780, 0x07b0,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 0x0bf2,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1780, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2046,
- 0x2048, 0x204d,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20af,
- 0x20d0, 0x20e3,
- 0x2100, 0x213a,
- 0x2153, 0x2183,
- 0x2190, 0x21f3,
- 0x2200, 0x22f1,
- 0x2300, 0x237b,
- 0x237d, 0x239a,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25f7,
- 0x2600, 0x2613,
- 0x2619, 0x2671,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x2800, 0x28ff,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303a,
- 0x303e, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4a1,
- 0xa4a4, 0xa4b3,
- 0xa4b5, 0xa4c0,
- 0xa4c2, 0xa4c4,
- 0xa4c6, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xffff,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10400, 0x10425,
- 0x10428, 0x1044d,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c0,
- 0x1d4c2, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a3,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_3_1 */
-
-/* 'Age_3_2': Derived Age 3.2 */
-static const OnigCodePoint CR_Age_3_2[] = {
- 397,
- 0x0000, 0x0220,
- 0x0222, 0x0233,
- 0x0250, 0x02ad,
- 0x02b0, 0x02ee,
- 0x0300, 0x034f,
- 0x0360, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03f6,
- 0x0400, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0655,
- 0x0660, 0x06ed,
- 0x06f0, 0x06fe,
- 0x0700, 0x070d,
- 0x070f, 0x072c,
- 0x0730, 0x074a,
- 0x0780, 0x07b1,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 0x0bf2,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f8,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2052,
- 0x2057, 0x2057,
- 0x205f, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x20a0, 0x20b1,
- 0x20d0, 0x20ea,
- 0x2100, 0x213a,
- 0x213d, 0x214b,
- 0x2153, 0x2183,
- 0x2190, 0x23ce,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x24fe,
- 0x2500, 0x2613,
- 0x2616, 0x2617,
- 0x2619, 0x267d,
- 0x2680, 0x2689,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2aff,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31f0, 0x321c,
- 0x3220, 0x3243,
- 0x3251, 0x327b,
- 0x327f, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfc,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe46,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xffff,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10400, 0x10425,
- 0x10428, 0x1044d,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c0,
- 0x1d4c2, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a3,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_3_2 */
-
-/* 'Age_4_0': Derived Age 4.0 */
-static const OnigCodePoint CR_Age_4_0[] = {
- 412,
- 0x0000, 0x0236,
- 0x0250, 0x0357,
- 0x035d, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03fb,
- 0x0400, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x060c, 0x0615,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0658,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x074f,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f8,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x19e0, 0x19ff,
- 0x1d00, 0x1d6b,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2054,
- 0x2057, 0x2057,
- 0x205f, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x20a0, 0x20b1,
- 0x20d0, 0x20ea,
- 0x2100, 0x213b,
- 0x213d, 0x214b,
- 0x2153, 0x2183,
- 0x2190, 0x23d0,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2617,
- 0x2619, 0x267d,
- 0x2680, 0x2691,
- 0x26a0, 0x26a1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b0d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x327d,
- 0x327f, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1013f,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x1039f,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d300, 0x1d356,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a3,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_4_0 */
-
-/* 'Age_4_1': Derived Age 4.1 */
-static const OnigCodePoint CR_Age_4_1[] = {
- 430,
- 0x0000, 0x0241,
- 0x0250, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05b9,
- 0x05bb, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x060b, 0x0615,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x097d, 0x097d,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fd1,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a1f,
- 0x1d00, 0x1dc3,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b5,
- 0x20d0, 0x20eb,
- 0x2100, 0x214c,
- 0x2153, 0x2183,
- 0x2190, 0x23db,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269c,
- 0x26a0, 0x26b1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27c6,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b13,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2cea,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31cf,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa700, 0xa716,
- 0xa800, 0xa82b,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_4_1 */
-
-/* 'Age_5_0': Derived Age 5.0 */
-static const OnigCodePoint CR_Age_5_0[] = {
- 440,
- 0x0000, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x0486,
- 0x0488, 0x0513,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x060b, 0x0615,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x097b, 0x097f,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fd1,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a1f,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1d00, 0x1dca,
- 0x1dfe, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b5,
- 0x20d0, 0x20ef,
- 0x2100, 0x214e,
- 0x2153, 0x2184,
- 0x2190, 0x23e7,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269c,
- 0x26a0, 0x26b2,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27ca,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b1a,
- 0x2b20, 0x2b23,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2c6c,
- 0x2c74, 0x2c77,
- 0x2c80, 0x2cea,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31cf,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa700, 0xa71a,
- 0xa720, 0xa721,
- 0xa800, 0xa82b,
- 0xa840, 0xa877,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10900, 0x10919,
- 0x1091f, 0x1091f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_5_0 */
-
-/* 'Age_5_1': Derived Age 5.1 */
-static const OnigCodePoint CR_Age_5_1[] = {
- 455,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0523,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x0606, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0972,
- 0x097b, 0x097f,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fd4,
- 0x1000, 0x1099,
- 0x109e, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a1f,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1baa,
- 0x1bae, 0x1bb9,
- 0x1c00, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1d00, 0x1de6,
- 0x1dfe, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b5,
- 0x20d0, 0x20f0,
- 0x2100, 0x214f,
- 0x2153, 0x2188,
- 0x2190, 0x23e7,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269d,
- 0x26a0, 0x26bc,
- 0x26c0, 0x26c3,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27ca,
- 0x27cc, 0x27cc,
- 0x27d0, 0x2b4c,
- 0x2b50, 0x2b54,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2c6f,
- 0x2c71, 0x2c7d,
- 0x2c80, 0x2cea,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e30,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fc3,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa500, 0xa62b,
- 0xa640, 0xa65f,
- 0xa662, 0xa673,
- 0xa67c, 0xa697,
- 0xa700, 0xa78c,
- 0xa7fb, 0xa82b,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa900, 0xa953,
- 0xa95f, 0xa95f,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa5f,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10900, 0x10919,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_5_1 */
-
-/* 'Age_5_2': Derived Age 5.2 */
-static const OnigCodePoint CR_Age_5_2[] = {
- 495,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0525,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x0606, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0900, 0x0939,
- 0x093c, 0x094e,
- 0x0950, 0x0955,
- 0x0958, 0x0972,
- 0x0979, 0x097f,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fd8,
- 0x1000, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1baa,
- 0x1bae, 0x1bb9,
- 0x1c00, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cd0, 0x1cf2,
- 0x1d00, 0x1de6,
- 0x1dfd, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b8,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23e8,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26cd,
- 0x26cf, 0x26e1,
- 0x26e3, 0x26e3,
- 0x26e8, 0x26ff,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27ca,
- 0x27cc, 0x27cc,
- 0x27d0, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf1,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e31,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa65f,
- 0xa662, 0xa673,
- 0xa67c, 0xa697,
- 0xa6a0, 0xa6f7,
- 0xa700, 0xa78c,
- 0xa7fb, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaadf,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11080, 0x110c1,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f131, 0x1f131,
- 0x1f13d, 0x1f13d,
- 0x1f13f, 0x1f13f,
- 0x1f142, 0x1f142,
- 0x1f146, 0x1f146,
- 0x1f14a, 0x1f14e,
- 0x1f157, 0x1f157,
- 0x1f15f, 0x1f15f,
- 0x1f179, 0x1f179,
- 0x1f17b, 0x1f17c,
- 0x1f17f, 0x1f17f,
- 0x1f18a, 0x1f18d,
- 0x1f190, 0x1f190,
- 0x1f200, 0x1f200,
- 0x1f210, 0x1f231,
- 0x1f240, 0x1f248,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_5_2 */
-
-/* 'Age_6_0': Derived Age 6.0 */
-static const OnigCodePoint CR_Age_6_0[] = {
- 511,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x0606, 0x061b,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1baa,
- 0x1bae, 0x1bb9,
- 0x1bc0, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cd0, 0x1cf2,
- 0x1d00, 0x1de6,
- 0x1dfc, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20b9,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x27ca,
- 0x27cc, 0x27cc,
- 0x27ce, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf1,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e31,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa673,
- 0xa67c, 0xa697,
- 0xa6a0, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa791,
- 0xa7a0, 0xa7a9,
- 0xa7fa, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaadf,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f169,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f5ff,
- 0x1f601, 0x1f610,
- 0x1f612, 0x1f614,
- 0x1f616, 0x1f616,
- 0x1f618, 0x1f618,
- 0x1f61a, 0x1f61a,
- 0x1f61c, 0x1f61e,
- 0x1f620, 0x1f625,
- 0x1f628, 0x1f62b,
- 0x1f62d, 0x1f62d,
- 0x1f630, 0x1f633,
- 0x1f635, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_0 */
-
-/* 'Age_6_1': Derived Age 6.1 */
-static const OnigCodePoint CR_Age_6_1[] = {
- 549,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058f, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0604,
- 0x0606, 0x061b,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08a0,
- 0x08a2, 0x08ac,
- 0x08e4, 0x08fe,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1d00, 0x1de6,
- 0x1dfc, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20b9,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e3b,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa697,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa793,
- 0xa7a0, 0xa7aa,
- 0xa7f8, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11180, 0x111c8,
- 0x111d0, 0x111d9,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f540, 0x1f543,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_1 */
-
-/* 'Age_6_2': Derived Age 6.2 */
-static const OnigCodePoint CR_Age_6_2[] = {
- 549,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058f, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0604,
- 0x0606, 0x061b,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08a0,
- 0x08a2, 0x08ac,
- 0x08e4, 0x08fe,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1d00, 0x1de6,
- 0x1dfc, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20ba,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e3b,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa697,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa793,
- 0xa7a0, 0xa7aa,
- 0xa7f8, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11180, 0x111c8,
- 0x111d0, 0x111d9,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f540, 0x1f543,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_2 */
-
-/* 'Age_6_3': Derived Age 6.3 */
-static const OnigCodePoint CR_Age_6_3[] = {
- 549,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058f, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0604,
- 0x0606, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08a0,
- 0x08a2, 0x08ac,
- 0x08e4, 0x08fe,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1d00, 0x1de6,
- 0x1dfc, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20ba,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e3b,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa697,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa793,
- 0xa7a0, 0xa7aa,
- 0xa7f8, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11180, 0x111c8,
- 0x111d0, 0x111d9,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f540, 0x1f543,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_3 */
-
-/* 'Age_7_0': Derived Age 7.0 */
-static const OnigCodePoint CR_Age_7_0[] = {
- 610,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08b2,
- 0x08e4, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c81, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d01, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1cf8, 0x1cf9,
- 0x1d00, 0x1df5,
- 0x1dfc, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bd,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23fa,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd1,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e42,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa69d,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa7ad,
- 0xa7b0, 0xa7b1,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5f,
- 0xab64, 0xab65,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe2d,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018c,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x10330, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111d0, 0x111da,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123d,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11301, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c9,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11ac0, 0x11af8,
- 0x12000, 0x12398,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f32c,
- 0x1f330, 0x1f37d,
- 0x1f380, 0x1f3ce,
- 0x1f3d4, 0x1f3f7,
- 0x1f400, 0x1f4fe,
- 0x1f500, 0x1f54a,
- 0x1f550, 0x1f579,
- 0x1f57b, 0x1f5a3,
- 0x1f5a5, 0x1f642,
- 0x1f645, 0x1f6cf,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f3,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_7_0 */
-
-/* 'Age_8_0': Derived Age 8.0 */
-static const OnigCodePoint CR_Age_8_0[] = {
- 623,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08b4,
- 0x08e3, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0af9,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c81, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d01, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1cf8, 0x1cf9,
- 0x1d00, 0x1df5,
- 0x1dfc, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20be,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x23fa,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd1,
- 0x2bec, 0x2bef,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e42,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fd5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ad,
- 0xa7b0, 0xa7b7,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fd,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018c,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x10330, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123d,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x11719,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11ac0, 0x11af8,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f579,
- 0x1f57b, 0x1f5a3,
- 0x1f5a5, 0x1f6d0,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f3,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f910, 0x1f918,
- 0x1f980, 0x1f984,
- 0x1f9c0, 0x1f9c0,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_8_0 */
-
-/* 'Age_9_0': Derived Age 9.0 */
-static const OnigCodePoint CR_Age_9_0[] = {
- 648,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d4, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0af9,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d01, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1cf8, 0x1cf9,
- 0x1d00, 0x1df5,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20be,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x23fe,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd1,
- 0x2bec, 0x2bef,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e44,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fd5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ae,
- 0xa7b0, 0xa7b7,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fd,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x10330, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x11719,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe0,
- 0x17000, 0x187ec,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b001,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94a,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f6d2,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f6,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f910, 0x1f91e,
- 0x1f920, 0x1f927,
- 0x1f930, 0x1f930,
- 0x1f933, 0x1f93e,
- 0x1f940, 0x1f94b,
- 0x1f950, 0x1f95e,
- 0x1f980, 0x1f991,
- 0x1f9c0, 0x1f9c0,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_9_0 */
-
-/* 'Age_10_0': Derived Age 10.0 */
-static const OnigCodePoint CR_Age_10_0[] = {
- 659,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d4, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fd,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf9,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd2,
- 0x2bec, 0x2bef,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e49,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312e,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fea,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ae,
- 0xa7b0, 0xa7b7,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fd,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x11719,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11a83,
- 0x11a86, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x17000, 0x187ec,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94a,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d4,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f8,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f910, 0x1f93e,
- 0x1f940, 0x1f94c,
- 0x1f950, 0x1f96b,
- 0x1f980, 0x1f997,
- 0x1f9c0, 0x1f9c0,
- 0x1f9d0, 0x1f9e6,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_10_0 */
-
-/* 'Age_11_0': Derived Age 11.0 */
-static const OnigCodePoint CR_Age_11_0[] = {
- 668,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cf9,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bc8,
- 0x2bca, 0x2bfe,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4e,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7b9,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145e,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11a83,
- 0x11a86, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x17000, 0x187f1,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94a,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16b,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d4,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f9,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f910, 0x1f93e,
- 0x1f940, 0x1f970,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f97a,
- 0x1f97c, 0x1f9a2,
- 0x1f9b0, 0x1f9b9,
- 0x1f9c0, 0x1f9c2,
- 0x1f9d0, 0x1f9ff,
- 0x1fa60, 0x1fa6d,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_11_0 */
-
-/* 'Age_12_0': Derived Age 12.0 */
-static const OnigCodePoint CR_Age_12_0[] = {
- 677,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_12_0 */
-
-/* 'Age_12_1': Derived Age 12.1 */
-static const OnigCodePoint CR_Age_12_1[] = {
- 676,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_12_1 */
-
-#endif /* USE_UNICODE_AGE_PROPERTIES */
-/* 'Grapheme_Cluster_Break_Prepend': Grapheme_Cluster_Break=Prepend */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_Prepend[] = {
- 11,
- 0x0600, 0x0605,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x08e2, 0x08e2,
- 0x0d4e, 0x0d4e,
- 0x110bd, 0x110bd,
- 0x110cd, 0x110cd,
- 0x111c2, 0x111c3,
- 0x11a3a, 0x11a3a,
- 0x11a84, 0x11a89,
- 0x11d46, 0x11d46,
-}; /* CR_Grapheme_Cluster_Break_Prepend */
-
-/* 'Grapheme_Cluster_Break_CR': Grapheme_Cluster_Break=CR */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_CR[] = {
- 1,
- 0x000d, 0x000d,
-}; /* CR_Grapheme_Cluster_Break_CR */
-
-/* 'Grapheme_Cluster_Break_LF': Grapheme_Cluster_Break=LF */
-#define CR_Grapheme_Cluster_Break_LF CR_NEWLINE
-
-/* 'Grapheme_Cluster_Break_Control': Grapheme_Cluster_Break=Control */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_Control[] = {
- 19,
- 0x0000, 0x0009,
- 0x000b, 0x000c,
- 0x000e, 0x001f,
- 0x007f, 0x009f,
- 0x00ad, 0x00ad,
- 0x061c, 0x061c,
- 0x180e, 0x180e,
- 0x200b, 0x200b,
- 0x200e, 0x200f,
- 0x2028, 0x202e,
- 0x2060, 0x206f,
- 0xfeff, 0xfeff,
- 0xfff0, 0xfffb,
- 0x13430, 0x13438,
- 0x1bca0, 0x1bca3,
- 0x1d173, 0x1d17a,
- 0xe0000, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xe0fff,
-}; /* CR_Grapheme_Cluster_Break_Control */
-
-/* 'Grapheme_Cluster_Break_Extend': Grapheme_Cluster_Break=Extend */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_Extend[] = {
- 336,
- 0x0300, 0x036f,
- 0x0483, 0x0489,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x08d3, 0x08e1,
- 0x08e3, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09be, 0x09be,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3e, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bbe,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc2, 0x0cc2,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d3e, 0x0d3e,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dcf,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0ddf, 0x0ddf,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ecd,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1df9,
- 0x1dfb, 0x1dff,
- 0x200c, 0x200c,
- 0x20d0, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaec, 0xaaed,
- 0xaaf6, 0xaaf6,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xff9e, 0xff9f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10f46, 0x10f50,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x1133e, 0x1133e,
- 0x11340, 0x11340,
- 0x11357, 0x11357,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b0, 0x114b0,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bd, 0x114bd,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115af, 0x115af,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f92,
- 0x1bc9d, 0x1bc9e,
- 0x1d165, 0x1d165,
- 0x1d167, 0x1d169,
- 0x1d16e, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e130, 0x1e136,
- 0x1e2ec, 0x1e2ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0x1f3fb, 0x1f3ff,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
-}; /* CR_Grapheme_Cluster_Break_Extend */
-
-/* 'Grapheme_Cluster_Break_Regional_Indicator': Grapheme_Cluster_Break=Regional_Indicator */
-#define CR_Grapheme_Cluster_Break_Regional_Indicator CR_Regional_Indicator
-
-/* 'Grapheme_Cluster_Break_SpacingMark': Grapheme_Cluster_Break=SpacingMark */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_SpacingMark[] = {
- 152,
- 0x0903, 0x0903,
- 0x093b, 0x093b,
- 0x093e, 0x0940,
- 0x0949, 0x094c,
- 0x094e, 0x094f,
- 0x0982, 0x0983,
- 0x09bf, 0x09c0,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x0a03, 0x0a03,
- 0x0a3e, 0x0a40,
- 0x0a83, 0x0a83,
- 0x0abe, 0x0ac0,
- 0x0ac9, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0b02, 0x0b03,
- 0x0b40, 0x0b40,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0bbf, 0x0bbf,
- 0x0bc1, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0c01, 0x0c03,
- 0x0c41, 0x0c44,
- 0x0c82, 0x0c83,
- 0x0cbe, 0x0cbe,
- 0x0cc0, 0x0cc1,
- 0x0cc3, 0x0cc4,
- 0x0cc7, 0x0cc8,
- 0x0cca, 0x0ccb,
- 0x0d02, 0x0d03,
- 0x0d3f, 0x0d40,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d82, 0x0d83,
- 0x0dd0, 0x0dd1,
- 0x0dd8, 0x0dde,
- 0x0df2, 0x0df3,
- 0x0e33, 0x0e33,
- 0x0eb3, 0x0eb3,
- 0x0f3e, 0x0f3f,
- 0x0f7f, 0x0f7f,
- 0x1031, 0x1031,
- 0x103b, 0x103c,
- 0x1056, 0x1057,
- 0x1084, 0x1084,
- 0x17b6, 0x17b6,
- 0x17be, 0x17c5,
- 0x17c7, 0x17c8,
- 0x1923, 0x1926,
- 0x1929, 0x192b,
- 0x1930, 0x1931,
- 0x1933, 0x1938,
- 0x1a19, 0x1a1a,
- 0x1a55, 0x1a55,
- 0x1a57, 0x1a57,
- 0x1a6d, 0x1a72,
- 0x1b04, 0x1b04,
- 0x1b3b, 0x1b3b,
- 0x1b3d, 0x1b41,
- 0x1b43, 0x1b44,
- 0x1b82, 0x1b82,
- 0x1ba1, 0x1ba1,
- 0x1ba6, 0x1ba7,
- 0x1baa, 0x1baa,
- 0x1be7, 0x1be7,
- 0x1bea, 0x1bec,
- 0x1bee, 0x1bee,
- 0x1bf2, 0x1bf3,
- 0x1c24, 0x1c2b,
- 0x1c34, 0x1c35,
- 0x1ce1, 0x1ce1,
- 0x1cf7, 0x1cf7,
- 0xa823, 0xa824,
- 0xa827, 0xa827,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c3,
- 0xa952, 0xa953,
- 0xa983, 0xa983,
- 0xa9b4, 0xa9b5,
- 0xa9ba, 0xa9bb,
- 0xa9be, 0xa9c0,
- 0xaa2f, 0xaa30,
- 0xaa33, 0xaa34,
- 0xaa4d, 0xaa4d,
- 0xaaeb, 0xaaeb,
- 0xaaee, 0xaaef,
- 0xaaf5, 0xaaf5,
- 0xabe3, 0xabe4,
- 0xabe6, 0xabe7,
- 0xabe9, 0xabea,
- 0xabec, 0xabec,
- 0x11000, 0x11000,
- 0x11002, 0x11002,
- 0x11082, 0x11082,
- 0x110b0, 0x110b2,
- 0x110b7, 0x110b8,
- 0x1112c, 0x1112c,
- 0x11145, 0x11146,
- 0x11182, 0x11182,
- 0x111b3, 0x111b5,
- 0x111bf, 0x111c0,
- 0x1122c, 0x1122e,
- 0x11232, 0x11233,
- 0x11235, 0x11235,
- 0x112e0, 0x112e2,
- 0x11302, 0x11303,
- 0x1133f, 0x1133f,
- 0x11341, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11362, 0x11363,
- 0x11435, 0x11437,
- 0x11440, 0x11441,
- 0x11445, 0x11445,
- 0x114b1, 0x114b2,
- 0x114b9, 0x114b9,
- 0x114bb, 0x114bc,
- 0x114be, 0x114be,
- 0x114c1, 0x114c1,
- 0x115b0, 0x115b1,
- 0x115b8, 0x115bb,
- 0x115be, 0x115be,
- 0x11630, 0x11632,
- 0x1163b, 0x1163c,
- 0x1163e, 0x1163e,
- 0x116ac, 0x116ac,
- 0x116ae, 0x116af,
- 0x116b6, 0x116b6,
- 0x11720, 0x11721,
- 0x11726, 0x11726,
- 0x1182c, 0x1182e,
- 0x11838, 0x11838,
- 0x119d1, 0x119d3,
- 0x119dc, 0x119df,
- 0x119e4, 0x119e4,
- 0x11a39, 0x11a39,
- 0x11a57, 0x11a58,
- 0x11a97, 0x11a97,
- 0x11c2f, 0x11c2f,
- 0x11c3e, 0x11c3e,
- 0x11ca9, 0x11ca9,
- 0x11cb1, 0x11cb1,
- 0x11cb4, 0x11cb4,
- 0x11d8a, 0x11d8e,
- 0x11d93, 0x11d94,
- 0x11d96, 0x11d96,
- 0x11ef5, 0x11ef6,
- 0x16f51, 0x16f87,
- 0x1d166, 0x1d166,
- 0x1d16d, 0x1d16d,
-}; /* CR_Grapheme_Cluster_Break_SpacingMark */
-
-/* 'Grapheme_Cluster_Break_L': Grapheme_Cluster_Break=L */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_L[] = {
- 2,
- 0x1100, 0x115f,
- 0xa960, 0xa97c,
-}; /* CR_Grapheme_Cluster_Break_L */
-
-/* 'Grapheme_Cluster_Break_V': Grapheme_Cluster_Break=V */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_V[] = {
- 2,
- 0x1160, 0x11a7,
- 0xd7b0, 0xd7c6,
-}; /* CR_Grapheme_Cluster_Break_V */
-
-/* 'Grapheme_Cluster_Break_T': Grapheme_Cluster_Break=T */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_T[] = {
- 2,
- 0x11a8, 0x11ff,
- 0xd7cb, 0xd7fb,
-}; /* CR_Grapheme_Cluster_Break_T */
-
-/* 'Grapheme_Cluster_Break_LV': Grapheme_Cluster_Break=LV */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_LV[] = {
- 399,
- 0xac00, 0xac00,
- 0xac1c, 0xac1c,
- 0xac38, 0xac38,
- 0xac54, 0xac54,
- 0xac70, 0xac70,
- 0xac8c, 0xac8c,
- 0xaca8, 0xaca8,
- 0xacc4, 0xacc4,
- 0xace0, 0xace0,
- 0xacfc, 0xacfc,
- 0xad18, 0xad18,
- 0xad34, 0xad34,
- 0xad50, 0xad50,
- 0xad6c, 0xad6c,
- 0xad88, 0xad88,
- 0xada4, 0xada4,
- 0xadc0, 0xadc0,
- 0xaddc, 0xaddc,
- 0xadf8, 0xadf8,
- 0xae14, 0xae14,
- 0xae30, 0xae30,
- 0xae4c, 0xae4c,
- 0xae68, 0xae68,
- 0xae84, 0xae84,
- 0xaea0, 0xaea0,
- 0xaebc, 0xaebc,
- 0xaed8, 0xaed8,
- 0xaef4, 0xaef4,
- 0xaf10, 0xaf10,
- 0xaf2c, 0xaf2c,
- 0xaf48, 0xaf48,
- 0xaf64, 0xaf64,
- 0xaf80, 0xaf80,
- 0xaf9c, 0xaf9c,
- 0xafb8, 0xafb8,
- 0xafd4, 0xafd4,
- 0xaff0, 0xaff0,
- 0xb00c, 0xb00c,
- 0xb028, 0xb028,
- 0xb044, 0xb044,
- 0xb060, 0xb060,
- 0xb07c, 0xb07c,
- 0xb098, 0xb098,
- 0xb0b4, 0xb0b4,
- 0xb0d0, 0xb0d0,
- 0xb0ec, 0xb0ec,
- 0xb108, 0xb108,
- 0xb124, 0xb124,
- 0xb140, 0xb140,
- 0xb15c, 0xb15c,
- 0xb178, 0xb178,
- 0xb194, 0xb194,
- 0xb1b0, 0xb1b0,
- 0xb1cc, 0xb1cc,
- 0xb1e8, 0xb1e8,
- 0xb204, 0xb204,
- 0xb220, 0xb220,
- 0xb23c, 0xb23c,
- 0xb258, 0xb258,
- 0xb274, 0xb274,
- 0xb290, 0xb290,
- 0xb2ac, 0xb2ac,
- 0xb2c8, 0xb2c8,
- 0xb2e4, 0xb2e4,
- 0xb300, 0xb300,
- 0xb31c, 0xb31c,
- 0xb338, 0xb338,
- 0xb354, 0xb354,
- 0xb370, 0xb370,
- 0xb38c, 0xb38c,
- 0xb3a8, 0xb3a8,
- 0xb3c4, 0xb3c4,
- 0xb3e0, 0xb3e0,
- 0xb3fc, 0xb3fc,
- 0xb418, 0xb418,
- 0xb434, 0xb434,
- 0xb450, 0xb450,
- 0xb46c, 0xb46c,
- 0xb488, 0xb488,
- 0xb4a4, 0xb4a4,
- 0xb4c0, 0xb4c0,
- 0xb4dc, 0xb4dc,
- 0xb4f8, 0xb4f8,
- 0xb514, 0xb514,
- 0xb530, 0xb530,
- 0xb54c, 0xb54c,
- 0xb568, 0xb568,
- 0xb584, 0xb584,
- 0xb5a0, 0xb5a0,
- 0xb5bc, 0xb5bc,
- 0xb5d8, 0xb5d8,
- 0xb5f4, 0xb5f4,
- 0xb610, 0xb610,
- 0xb62c, 0xb62c,
- 0xb648, 0xb648,
- 0xb664, 0xb664,
- 0xb680, 0xb680,
- 0xb69c, 0xb69c,
- 0xb6b8, 0xb6b8,
- 0xb6d4, 0xb6d4,
- 0xb6f0, 0xb6f0,
- 0xb70c, 0xb70c,
- 0xb728, 0xb728,
- 0xb744, 0xb744,
- 0xb760, 0xb760,
- 0xb77c, 0xb77c,
- 0xb798, 0xb798,
- 0xb7b4, 0xb7b4,
- 0xb7d0, 0xb7d0,
- 0xb7ec, 0xb7ec,
- 0xb808, 0xb808,
- 0xb824, 0xb824,
- 0xb840, 0xb840,
- 0xb85c, 0xb85c,
- 0xb878, 0xb878,
- 0xb894, 0xb894,
- 0xb8b0, 0xb8b0,
- 0xb8cc, 0xb8cc,
- 0xb8e8, 0xb8e8,
- 0xb904, 0xb904,
- 0xb920, 0xb920,
- 0xb93c, 0xb93c,
- 0xb958, 0xb958,
- 0xb974, 0xb974,
- 0xb990, 0xb990,
- 0xb9ac, 0xb9ac,
- 0xb9c8, 0xb9c8,
- 0xb9e4, 0xb9e4,
- 0xba00, 0xba00,
- 0xba1c, 0xba1c,
- 0xba38, 0xba38,
- 0xba54, 0xba54,
- 0xba70, 0xba70,
- 0xba8c, 0xba8c,
- 0xbaa8, 0xbaa8,
- 0xbac4, 0xbac4,
- 0xbae0, 0xbae0,
- 0xbafc, 0xbafc,
- 0xbb18, 0xbb18,
- 0xbb34, 0xbb34,
- 0xbb50, 0xbb50,
- 0xbb6c, 0xbb6c,
- 0xbb88, 0xbb88,
- 0xbba4, 0xbba4,
- 0xbbc0, 0xbbc0,
- 0xbbdc, 0xbbdc,
- 0xbbf8, 0xbbf8,
- 0xbc14, 0xbc14,
- 0xbc30, 0xbc30,
- 0xbc4c, 0xbc4c,
- 0xbc68, 0xbc68,
- 0xbc84, 0xbc84,
- 0xbca0, 0xbca0,
- 0xbcbc, 0xbcbc,
- 0xbcd8, 0xbcd8,
- 0xbcf4, 0xbcf4,
- 0xbd10, 0xbd10,
- 0xbd2c, 0xbd2c,
- 0xbd48, 0xbd48,
- 0xbd64, 0xbd64,
- 0xbd80, 0xbd80,
- 0xbd9c, 0xbd9c,
- 0xbdb8, 0xbdb8,
- 0xbdd4, 0xbdd4,
- 0xbdf0, 0xbdf0,
- 0xbe0c, 0xbe0c,
- 0xbe28, 0xbe28,
- 0xbe44, 0xbe44,
- 0xbe60, 0xbe60,
- 0xbe7c, 0xbe7c,
- 0xbe98, 0xbe98,
- 0xbeb4, 0xbeb4,
- 0xbed0, 0xbed0,
- 0xbeec, 0xbeec,
- 0xbf08, 0xbf08,
- 0xbf24, 0xbf24,
- 0xbf40, 0xbf40,
- 0xbf5c, 0xbf5c,
- 0xbf78, 0xbf78,
- 0xbf94, 0xbf94,
- 0xbfb0, 0xbfb0,
- 0xbfcc, 0xbfcc,
- 0xbfe8, 0xbfe8,
- 0xc004, 0xc004,
- 0xc020, 0xc020,
- 0xc03c, 0xc03c,
- 0xc058, 0xc058,
- 0xc074, 0xc074,
- 0xc090, 0xc090,
- 0xc0ac, 0xc0ac,
- 0xc0c8, 0xc0c8,
- 0xc0e4, 0xc0e4,
- 0xc100, 0xc100,
- 0xc11c, 0xc11c,
- 0xc138, 0xc138,
- 0xc154, 0xc154,
- 0xc170, 0xc170,
- 0xc18c, 0xc18c,
- 0xc1a8, 0xc1a8,
- 0xc1c4, 0xc1c4,
- 0xc1e0, 0xc1e0,
- 0xc1fc, 0xc1fc,
- 0xc218, 0xc218,
- 0xc234, 0xc234,
- 0xc250, 0xc250,
- 0xc26c, 0xc26c,
- 0xc288, 0xc288,
- 0xc2a4, 0xc2a4,
- 0xc2c0, 0xc2c0,
- 0xc2dc, 0xc2dc,
- 0xc2f8, 0xc2f8,
- 0xc314, 0xc314,
- 0xc330, 0xc330,
- 0xc34c, 0xc34c,
- 0xc368, 0xc368,
- 0xc384, 0xc384,
- 0xc3a0, 0xc3a0,
- 0xc3bc, 0xc3bc,
- 0xc3d8, 0xc3d8,
- 0xc3f4, 0xc3f4,
- 0xc410, 0xc410,
- 0xc42c, 0xc42c,
- 0xc448, 0xc448,
- 0xc464, 0xc464,
- 0xc480, 0xc480,
- 0xc49c, 0xc49c,
- 0xc4b8, 0xc4b8,
- 0xc4d4, 0xc4d4,
- 0xc4f0, 0xc4f0,
- 0xc50c, 0xc50c,
- 0xc528, 0xc528,
- 0xc544, 0xc544,
- 0xc560, 0xc560,
- 0xc57c, 0xc57c,
- 0xc598, 0xc598,
- 0xc5b4, 0xc5b4,
- 0xc5d0, 0xc5d0,
- 0xc5ec, 0xc5ec,
- 0xc608, 0xc608,
- 0xc624, 0xc624,
- 0xc640, 0xc640,
- 0xc65c, 0xc65c,
- 0xc678, 0xc678,
- 0xc694, 0xc694,
- 0xc6b0, 0xc6b0,
- 0xc6cc, 0xc6cc,
- 0xc6e8, 0xc6e8,
- 0xc704, 0xc704,
- 0xc720, 0xc720,
- 0xc73c, 0xc73c,
- 0xc758, 0xc758,
- 0xc774, 0xc774,
- 0xc790, 0xc790,
- 0xc7ac, 0xc7ac,
- 0xc7c8, 0xc7c8,
- 0xc7e4, 0xc7e4,
- 0xc800, 0xc800,
- 0xc81c, 0xc81c,
- 0xc838, 0xc838,
- 0xc854, 0xc854,
- 0xc870, 0xc870,
- 0xc88c, 0xc88c,
- 0xc8a8, 0xc8a8,
- 0xc8c4, 0xc8c4,
- 0xc8e0, 0xc8e0,
- 0xc8fc, 0xc8fc,
- 0xc918, 0xc918,
- 0xc934, 0xc934,
- 0xc950, 0xc950,
- 0xc96c, 0xc96c,
- 0xc988, 0xc988,
- 0xc9a4, 0xc9a4,
- 0xc9c0, 0xc9c0,
- 0xc9dc, 0xc9dc,
- 0xc9f8, 0xc9f8,
- 0xca14, 0xca14,
- 0xca30, 0xca30,
- 0xca4c, 0xca4c,
- 0xca68, 0xca68,
- 0xca84, 0xca84,
- 0xcaa0, 0xcaa0,
- 0xcabc, 0xcabc,
- 0xcad8, 0xcad8,
- 0xcaf4, 0xcaf4,
- 0xcb10, 0xcb10,
- 0xcb2c, 0xcb2c,
- 0xcb48, 0xcb48,
- 0xcb64, 0xcb64,
- 0xcb80, 0xcb80,
- 0xcb9c, 0xcb9c,
- 0xcbb8, 0xcbb8,
- 0xcbd4, 0xcbd4,
- 0xcbf0, 0xcbf0,
- 0xcc0c, 0xcc0c,
- 0xcc28, 0xcc28,
- 0xcc44, 0xcc44,
- 0xcc60, 0xcc60,
- 0xcc7c, 0xcc7c,
- 0xcc98, 0xcc98,
- 0xccb4, 0xccb4,
- 0xccd0, 0xccd0,
- 0xccec, 0xccec,
- 0xcd08, 0xcd08,
- 0xcd24, 0xcd24,
- 0xcd40, 0xcd40,
- 0xcd5c, 0xcd5c,
- 0xcd78, 0xcd78,
- 0xcd94, 0xcd94,
- 0xcdb0, 0xcdb0,
- 0xcdcc, 0xcdcc,
- 0xcde8, 0xcde8,
- 0xce04, 0xce04,
- 0xce20, 0xce20,
- 0xce3c, 0xce3c,
- 0xce58, 0xce58,
- 0xce74, 0xce74,
- 0xce90, 0xce90,
- 0xceac, 0xceac,
- 0xcec8, 0xcec8,
- 0xcee4, 0xcee4,
- 0xcf00, 0xcf00,
- 0xcf1c, 0xcf1c,
- 0xcf38, 0xcf38,
- 0xcf54, 0xcf54,
- 0xcf70, 0xcf70,
- 0xcf8c, 0xcf8c,
- 0xcfa8, 0xcfa8,
- 0xcfc4, 0xcfc4,
- 0xcfe0, 0xcfe0,
- 0xcffc, 0xcffc,
- 0xd018, 0xd018,
- 0xd034, 0xd034,
- 0xd050, 0xd050,
- 0xd06c, 0xd06c,
- 0xd088, 0xd088,
- 0xd0a4, 0xd0a4,
- 0xd0c0, 0xd0c0,
- 0xd0dc, 0xd0dc,
- 0xd0f8, 0xd0f8,
- 0xd114, 0xd114,
- 0xd130, 0xd130,
- 0xd14c, 0xd14c,
- 0xd168, 0xd168,
- 0xd184, 0xd184,
- 0xd1a0, 0xd1a0,
- 0xd1bc, 0xd1bc,
- 0xd1d8, 0xd1d8,
- 0xd1f4, 0xd1f4,
- 0xd210, 0xd210,
- 0xd22c, 0xd22c,
- 0xd248, 0xd248,
- 0xd264, 0xd264,
- 0xd280, 0xd280,
- 0xd29c, 0xd29c,
- 0xd2b8, 0xd2b8,
- 0xd2d4, 0xd2d4,
- 0xd2f0, 0xd2f0,
- 0xd30c, 0xd30c,
- 0xd328, 0xd328,
- 0xd344, 0xd344,
- 0xd360, 0xd360,
- 0xd37c, 0xd37c,
- 0xd398, 0xd398,
- 0xd3b4, 0xd3b4,
- 0xd3d0, 0xd3d0,
- 0xd3ec, 0xd3ec,
- 0xd408, 0xd408,
- 0xd424, 0xd424,
- 0xd440, 0xd440,
- 0xd45c, 0xd45c,
- 0xd478, 0xd478,
- 0xd494, 0xd494,
- 0xd4b0, 0xd4b0,
- 0xd4cc, 0xd4cc,
- 0xd4e8, 0xd4e8,
- 0xd504, 0xd504,
- 0xd520, 0xd520,
- 0xd53c, 0xd53c,
- 0xd558, 0xd558,
- 0xd574, 0xd574,
- 0xd590, 0xd590,
- 0xd5ac, 0xd5ac,
- 0xd5c8, 0xd5c8,
- 0xd5e4, 0xd5e4,
- 0xd600, 0xd600,
- 0xd61c, 0xd61c,
- 0xd638, 0xd638,
- 0xd654, 0xd654,
- 0xd670, 0xd670,
- 0xd68c, 0xd68c,
- 0xd6a8, 0xd6a8,
- 0xd6c4, 0xd6c4,
- 0xd6e0, 0xd6e0,
- 0xd6fc, 0xd6fc,
- 0xd718, 0xd718,
- 0xd734, 0xd734,
- 0xd750, 0xd750,
- 0xd76c, 0xd76c,
- 0xd788, 0xd788,
-}; /* CR_Grapheme_Cluster_Break_LV */
-
-/* 'Grapheme_Cluster_Break_LVT': Grapheme_Cluster_Break=LVT */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_LVT[] = {
- 399,
- 0xac01, 0xac1b,
- 0xac1d, 0xac37,
- 0xac39, 0xac53,
- 0xac55, 0xac6f,
- 0xac71, 0xac8b,
- 0xac8d, 0xaca7,
- 0xaca9, 0xacc3,
- 0xacc5, 0xacdf,
- 0xace1, 0xacfb,
- 0xacfd, 0xad17,
- 0xad19, 0xad33,
- 0xad35, 0xad4f,
- 0xad51, 0xad6b,
- 0xad6d, 0xad87,
- 0xad89, 0xada3,
- 0xada5, 0xadbf,
- 0xadc1, 0xaddb,
- 0xaddd, 0xadf7,
- 0xadf9, 0xae13,
- 0xae15, 0xae2f,
- 0xae31, 0xae4b,
- 0xae4d, 0xae67,
- 0xae69, 0xae83,
- 0xae85, 0xae9f,
- 0xaea1, 0xaebb,
- 0xaebd, 0xaed7,
- 0xaed9, 0xaef3,
- 0xaef5, 0xaf0f,
- 0xaf11, 0xaf2b,
- 0xaf2d, 0xaf47,
- 0xaf49, 0xaf63,
- 0xaf65, 0xaf7f,
- 0xaf81, 0xaf9b,
- 0xaf9d, 0xafb7,
- 0xafb9, 0xafd3,
- 0xafd5, 0xafef,
- 0xaff1, 0xb00b,
- 0xb00d, 0xb027,
- 0xb029, 0xb043,
- 0xb045, 0xb05f,
- 0xb061, 0xb07b,
- 0xb07d, 0xb097,
- 0xb099, 0xb0b3,
- 0xb0b5, 0xb0cf,
- 0xb0d1, 0xb0eb,
- 0xb0ed, 0xb107,
- 0xb109, 0xb123,
- 0xb125, 0xb13f,
- 0xb141, 0xb15b,
- 0xb15d, 0xb177,
- 0xb179, 0xb193,
- 0xb195, 0xb1af,
- 0xb1b1, 0xb1cb,
- 0xb1cd, 0xb1e7,
- 0xb1e9, 0xb203,
- 0xb205, 0xb21f,
- 0xb221, 0xb23b,
- 0xb23d, 0xb257,
- 0xb259, 0xb273,
- 0xb275, 0xb28f,
- 0xb291, 0xb2ab,
- 0xb2ad, 0xb2c7,
- 0xb2c9, 0xb2e3,
- 0xb2e5, 0xb2ff,
- 0xb301, 0xb31b,
- 0xb31d, 0xb337,
- 0xb339, 0xb353,
- 0xb355, 0xb36f,
- 0xb371, 0xb38b,
- 0xb38d, 0xb3a7,
- 0xb3a9, 0xb3c3,
- 0xb3c5, 0xb3df,
- 0xb3e1, 0xb3fb,
- 0xb3fd, 0xb417,
- 0xb419, 0xb433,
- 0xb435, 0xb44f,
- 0xb451, 0xb46b,
- 0xb46d, 0xb487,
- 0xb489, 0xb4a3,
- 0xb4a5, 0xb4bf,
- 0xb4c1, 0xb4db,
- 0xb4dd, 0xb4f7,
- 0xb4f9, 0xb513,
- 0xb515, 0xb52f,
- 0xb531, 0xb54b,
- 0xb54d, 0xb567,
- 0xb569, 0xb583,
- 0xb585, 0xb59f,
- 0xb5a1, 0xb5bb,
- 0xb5bd, 0xb5d7,
- 0xb5d9, 0xb5f3,
- 0xb5f5, 0xb60f,
- 0xb611, 0xb62b,
- 0xb62d, 0xb647,
- 0xb649, 0xb663,
- 0xb665, 0xb67f,
- 0xb681, 0xb69b,
- 0xb69d, 0xb6b7,
- 0xb6b9, 0xb6d3,
- 0xb6d5, 0xb6ef,
- 0xb6f1, 0xb70b,
- 0xb70d, 0xb727,
- 0xb729, 0xb743,
- 0xb745, 0xb75f,
- 0xb761, 0xb77b,
- 0xb77d, 0xb797,
- 0xb799, 0xb7b3,
- 0xb7b5, 0xb7cf,
- 0xb7d1, 0xb7eb,
- 0xb7ed, 0xb807,
- 0xb809, 0xb823,
- 0xb825, 0xb83f,
- 0xb841, 0xb85b,
- 0xb85d, 0xb877,
- 0xb879, 0xb893,
- 0xb895, 0xb8af,
- 0xb8b1, 0xb8cb,
- 0xb8cd, 0xb8e7,
- 0xb8e9, 0xb903,
- 0xb905, 0xb91f,
- 0xb921, 0xb93b,
- 0xb93d, 0xb957,
- 0xb959, 0xb973,
- 0xb975, 0xb98f,
- 0xb991, 0xb9ab,
- 0xb9ad, 0xb9c7,
- 0xb9c9, 0xb9e3,
- 0xb9e5, 0xb9ff,
- 0xba01, 0xba1b,
- 0xba1d, 0xba37,
- 0xba39, 0xba53,
- 0xba55, 0xba6f,
- 0xba71, 0xba8b,
- 0xba8d, 0xbaa7,
- 0xbaa9, 0xbac3,
- 0xbac5, 0xbadf,
- 0xbae1, 0xbafb,
- 0xbafd, 0xbb17,
- 0xbb19, 0xbb33,
- 0xbb35, 0xbb4f,
- 0xbb51, 0xbb6b,
- 0xbb6d, 0xbb87,
- 0xbb89, 0xbba3,
- 0xbba5, 0xbbbf,
- 0xbbc1, 0xbbdb,
- 0xbbdd, 0xbbf7,
- 0xbbf9, 0xbc13,
- 0xbc15, 0xbc2f,
- 0xbc31, 0xbc4b,
- 0xbc4d, 0xbc67,
- 0xbc69, 0xbc83,
- 0xbc85, 0xbc9f,
- 0xbca1, 0xbcbb,
- 0xbcbd, 0xbcd7,
- 0xbcd9, 0xbcf3,
- 0xbcf5, 0xbd0f,
- 0xbd11, 0xbd2b,
- 0xbd2d, 0xbd47,
- 0xbd49, 0xbd63,
- 0xbd65, 0xbd7f,
- 0xbd81, 0xbd9b,
- 0xbd9d, 0xbdb7,
- 0xbdb9, 0xbdd3,
- 0xbdd5, 0xbdef,
- 0xbdf1, 0xbe0b,
- 0xbe0d, 0xbe27,
- 0xbe29, 0xbe43,
- 0xbe45, 0xbe5f,
- 0xbe61, 0xbe7b,
- 0xbe7d, 0xbe97,
- 0xbe99, 0xbeb3,
- 0xbeb5, 0xbecf,
- 0xbed1, 0xbeeb,
- 0xbeed, 0xbf07,
- 0xbf09, 0xbf23,
- 0xbf25, 0xbf3f,
- 0xbf41, 0xbf5b,
- 0xbf5d, 0xbf77,
- 0xbf79, 0xbf93,
- 0xbf95, 0xbfaf,
- 0xbfb1, 0xbfcb,
- 0xbfcd, 0xbfe7,
- 0xbfe9, 0xc003,
- 0xc005, 0xc01f,
- 0xc021, 0xc03b,
- 0xc03d, 0xc057,
- 0xc059, 0xc073,
- 0xc075, 0xc08f,
- 0xc091, 0xc0ab,
- 0xc0ad, 0xc0c7,
- 0xc0c9, 0xc0e3,
- 0xc0e5, 0xc0ff,
- 0xc101, 0xc11b,
- 0xc11d, 0xc137,
- 0xc139, 0xc153,
- 0xc155, 0xc16f,
- 0xc171, 0xc18b,
- 0xc18d, 0xc1a7,
- 0xc1a9, 0xc1c3,
- 0xc1c5, 0xc1df,
- 0xc1e1, 0xc1fb,
- 0xc1fd, 0xc217,
- 0xc219, 0xc233,
- 0xc235, 0xc24f,
- 0xc251, 0xc26b,
- 0xc26d, 0xc287,
- 0xc289, 0xc2a3,
- 0xc2a5, 0xc2bf,
- 0xc2c1, 0xc2db,
- 0xc2dd, 0xc2f7,
- 0xc2f9, 0xc313,
- 0xc315, 0xc32f,
- 0xc331, 0xc34b,
- 0xc34d, 0xc367,
- 0xc369, 0xc383,
- 0xc385, 0xc39f,
- 0xc3a1, 0xc3bb,
- 0xc3bd, 0xc3d7,
- 0xc3d9, 0xc3f3,
- 0xc3f5, 0xc40f,
- 0xc411, 0xc42b,
- 0xc42d, 0xc447,
- 0xc449, 0xc463,
- 0xc465, 0xc47f,
- 0xc481, 0xc49b,
- 0xc49d, 0xc4b7,
- 0xc4b9, 0xc4d3,
- 0xc4d5, 0xc4ef,
- 0xc4f1, 0xc50b,
- 0xc50d, 0xc527,
- 0xc529, 0xc543,
- 0xc545, 0xc55f,
- 0xc561, 0xc57b,
- 0xc57d, 0xc597,
- 0xc599, 0xc5b3,
- 0xc5b5, 0xc5cf,
- 0xc5d1, 0xc5eb,
- 0xc5ed, 0xc607,
- 0xc609, 0xc623,
- 0xc625, 0xc63f,
- 0xc641, 0xc65b,
- 0xc65d, 0xc677,
- 0xc679, 0xc693,
- 0xc695, 0xc6af,
- 0xc6b1, 0xc6cb,
- 0xc6cd, 0xc6e7,
- 0xc6e9, 0xc703,
- 0xc705, 0xc71f,
- 0xc721, 0xc73b,
- 0xc73d, 0xc757,
- 0xc759, 0xc773,
- 0xc775, 0xc78f,
- 0xc791, 0xc7ab,
- 0xc7ad, 0xc7c7,
- 0xc7c9, 0xc7e3,
- 0xc7e5, 0xc7ff,
- 0xc801, 0xc81b,
- 0xc81d, 0xc837,
- 0xc839, 0xc853,
- 0xc855, 0xc86f,
- 0xc871, 0xc88b,
- 0xc88d, 0xc8a7,
- 0xc8a9, 0xc8c3,
- 0xc8c5, 0xc8df,
- 0xc8e1, 0xc8fb,
- 0xc8fd, 0xc917,
- 0xc919, 0xc933,
- 0xc935, 0xc94f,
- 0xc951, 0xc96b,
- 0xc96d, 0xc987,
- 0xc989, 0xc9a3,
- 0xc9a5, 0xc9bf,
- 0xc9c1, 0xc9db,
- 0xc9dd, 0xc9f7,
- 0xc9f9, 0xca13,
- 0xca15, 0xca2f,
- 0xca31, 0xca4b,
- 0xca4d, 0xca67,
- 0xca69, 0xca83,
- 0xca85, 0xca9f,
- 0xcaa1, 0xcabb,
- 0xcabd, 0xcad7,
- 0xcad9, 0xcaf3,
- 0xcaf5, 0xcb0f,
- 0xcb11, 0xcb2b,
- 0xcb2d, 0xcb47,
- 0xcb49, 0xcb63,
- 0xcb65, 0xcb7f,
- 0xcb81, 0xcb9b,
- 0xcb9d, 0xcbb7,
- 0xcbb9, 0xcbd3,
- 0xcbd5, 0xcbef,
- 0xcbf1, 0xcc0b,
- 0xcc0d, 0xcc27,
- 0xcc29, 0xcc43,
- 0xcc45, 0xcc5f,
- 0xcc61, 0xcc7b,
- 0xcc7d, 0xcc97,
- 0xcc99, 0xccb3,
- 0xccb5, 0xcccf,
- 0xccd1, 0xcceb,
- 0xcced, 0xcd07,
- 0xcd09, 0xcd23,
- 0xcd25, 0xcd3f,
- 0xcd41, 0xcd5b,
- 0xcd5d, 0xcd77,
- 0xcd79, 0xcd93,
- 0xcd95, 0xcdaf,
- 0xcdb1, 0xcdcb,
- 0xcdcd, 0xcde7,
- 0xcde9, 0xce03,
- 0xce05, 0xce1f,
- 0xce21, 0xce3b,
- 0xce3d, 0xce57,
- 0xce59, 0xce73,
- 0xce75, 0xce8f,
- 0xce91, 0xceab,
- 0xcead, 0xcec7,
- 0xcec9, 0xcee3,
- 0xcee5, 0xceff,
- 0xcf01, 0xcf1b,
- 0xcf1d, 0xcf37,
- 0xcf39, 0xcf53,
- 0xcf55, 0xcf6f,
- 0xcf71, 0xcf8b,
- 0xcf8d, 0xcfa7,
- 0xcfa9, 0xcfc3,
- 0xcfc5, 0xcfdf,
- 0xcfe1, 0xcffb,
- 0xcffd, 0xd017,
- 0xd019, 0xd033,
- 0xd035, 0xd04f,
- 0xd051, 0xd06b,
- 0xd06d, 0xd087,
- 0xd089, 0xd0a3,
- 0xd0a5, 0xd0bf,
- 0xd0c1, 0xd0db,
- 0xd0dd, 0xd0f7,
- 0xd0f9, 0xd113,
- 0xd115, 0xd12f,
- 0xd131, 0xd14b,
- 0xd14d, 0xd167,
- 0xd169, 0xd183,
- 0xd185, 0xd19f,
- 0xd1a1, 0xd1bb,
- 0xd1bd, 0xd1d7,
- 0xd1d9, 0xd1f3,
- 0xd1f5, 0xd20f,
- 0xd211, 0xd22b,
- 0xd22d, 0xd247,
- 0xd249, 0xd263,
- 0xd265, 0xd27f,
- 0xd281, 0xd29b,
- 0xd29d, 0xd2b7,
- 0xd2b9, 0xd2d3,
- 0xd2d5, 0xd2ef,
- 0xd2f1, 0xd30b,
- 0xd30d, 0xd327,
- 0xd329, 0xd343,
- 0xd345, 0xd35f,
- 0xd361, 0xd37b,
- 0xd37d, 0xd397,
- 0xd399, 0xd3b3,
- 0xd3b5, 0xd3cf,
- 0xd3d1, 0xd3eb,
- 0xd3ed, 0xd407,
- 0xd409, 0xd423,
- 0xd425, 0xd43f,
- 0xd441, 0xd45b,
- 0xd45d, 0xd477,
- 0xd479, 0xd493,
- 0xd495, 0xd4af,
- 0xd4b1, 0xd4cb,
- 0xd4cd, 0xd4e7,
- 0xd4e9, 0xd503,
- 0xd505, 0xd51f,
- 0xd521, 0xd53b,
- 0xd53d, 0xd557,
- 0xd559, 0xd573,
- 0xd575, 0xd58f,
- 0xd591, 0xd5ab,
- 0xd5ad, 0xd5c7,
- 0xd5c9, 0xd5e3,
- 0xd5e5, 0xd5ff,
- 0xd601, 0xd61b,
- 0xd61d, 0xd637,
- 0xd639, 0xd653,
- 0xd655, 0xd66f,
- 0xd671, 0xd68b,
- 0xd68d, 0xd6a7,
- 0xd6a9, 0xd6c3,
- 0xd6c5, 0xd6df,
- 0xd6e1, 0xd6fb,
- 0xd6fd, 0xd717,
- 0xd719, 0xd733,
- 0xd735, 0xd74f,
- 0xd751, 0xd76b,
- 0xd76d, 0xd787,
- 0xd789, 0xd7a3,
-}; /* CR_Grapheme_Cluster_Break_LVT */
-
-/* 'Grapheme_Cluster_Break_ZWJ': Grapheme_Cluster_Break=ZWJ */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_ZWJ[] = {
- 1,
- 0x200d, 0x200d,
-}; /* CR_Grapheme_Cluster_Break_ZWJ */
-
-/* 'In_Basic_Latin': Block */
-#define CR_In_Basic_Latin CR_ASCII
-
-/* 'In_Latin_1_Supplement': Block */
-static const OnigCodePoint CR_In_Latin_1_Supplement[] = {
- 1,
- 0x0080, 0x00ff,
-}; /* CR_In_Latin_1_Supplement */
-
-/* 'In_Latin_Extended_A': Block */
-static const OnigCodePoint CR_In_Latin_Extended_A[] = {
- 1,
- 0x0100, 0x017f,
-}; /* CR_In_Latin_Extended_A */
-
-/* 'In_Latin_Extended_B': Block */
-static const OnigCodePoint CR_In_Latin_Extended_B[] = {
- 1,
- 0x0180, 0x024f,
-}; /* CR_In_Latin_Extended_B */
-
-/* 'In_IPA_Extensions': Block */
-static const OnigCodePoint CR_In_IPA_Extensions[] = {
- 1,
- 0x0250, 0x02af,
-}; /* CR_In_IPA_Extensions */
-
-/* 'In_Spacing_Modifier_Letters': Block */
-static const OnigCodePoint CR_In_Spacing_Modifier_Letters[] = {
- 1,
- 0x02b0, 0x02ff,
-}; /* CR_In_Spacing_Modifier_Letters */
-
-/* 'In_Combining_Diacritical_Marks': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks[] = {
- 1,
- 0x0300, 0x036f,
-}; /* CR_In_Combining_Diacritical_Marks */
-
-/* 'In_Greek_and_Coptic': Block */
-static const OnigCodePoint CR_In_Greek_and_Coptic[] = {
- 1,
- 0x0370, 0x03ff,
-}; /* CR_In_Greek_and_Coptic */
-
-/* 'In_Cyrillic': Block */
-static const OnigCodePoint CR_In_Cyrillic[] = {
- 1,
- 0x0400, 0x04ff,
-}; /* CR_In_Cyrillic */
-
-/* 'In_Cyrillic_Supplement': Block */
-static const OnigCodePoint CR_In_Cyrillic_Supplement[] = {
- 1,
- 0x0500, 0x052f,
-}; /* CR_In_Cyrillic_Supplement */
-
-/* 'In_Armenian': Block */
-static const OnigCodePoint CR_In_Armenian[] = {
- 1,
- 0x0530, 0x058f,
-}; /* CR_In_Armenian */
-
-/* 'In_Hebrew': Block */
-static const OnigCodePoint CR_In_Hebrew[] = {
- 1,
- 0x0590, 0x05ff,
-}; /* CR_In_Hebrew */
-
-/* 'In_Arabic': Block */
-static const OnigCodePoint CR_In_Arabic[] = {
- 1,
- 0x0600, 0x06ff,
-}; /* CR_In_Arabic */
-
-/* 'In_Syriac': Block */
-static const OnigCodePoint CR_In_Syriac[] = {
- 1,
- 0x0700, 0x074f,
-}; /* CR_In_Syriac */
-
-/* 'In_Arabic_Supplement': Block */
-static const OnigCodePoint CR_In_Arabic_Supplement[] = {
- 1,
- 0x0750, 0x077f,
-}; /* CR_In_Arabic_Supplement */
-
-/* 'In_Thaana': Block */
-static const OnigCodePoint CR_In_Thaana[] = {
- 1,
- 0x0780, 0x07bf,
-}; /* CR_In_Thaana */
-
-/* 'In_NKo': Block */
-static const OnigCodePoint CR_In_NKo[] = {
- 1,
- 0x07c0, 0x07ff,
-}; /* CR_In_NKo */
-
-/* 'In_Samaritan': Block */
-static const OnigCodePoint CR_In_Samaritan[] = {
- 1,
- 0x0800, 0x083f,
-}; /* CR_In_Samaritan */
-
-/* 'In_Mandaic': Block */
-static const OnigCodePoint CR_In_Mandaic[] = {
- 1,
- 0x0840, 0x085f,
-}; /* CR_In_Mandaic */
-
-/* 'In_Syriac_Supplement': Block */
-static const OnigCodePoint CR_In_Syriac_Supplement[] = {
- 1,
- 0x0860, 0x086f,
-}; /* CR_In_Syriac_Supplement */
-
-/* 'In_Arabic_Extended_A': Block */
-static const OnigCodePoint CR_In_Arabic_Extended_A[] = {
- 1,
- 0x08a0, 0x08ff,
-}; /* CR_In_Arabic_Extended_A */
-
-/* 'In_Devanagari': Block */
-static const OnigCodePoint CR_In_Devanagari[] = {
- 1,
- 0x0900, 0x097f,
-}; /* CR_In_Devanagari */
-
-/* 'In_Bengali': Block */
-static const OnigCodePoint CR_In_Bengali[] = {
- 1,
- 0x0980, 0x09ff,
-}; /* CR_In_Bengali */
-
-/* 'In_Gurmukhi': Block */
-static const OnigCodePoint CR_In_Gurmukhi[] = {
- 1,
- 0x0a00, 0x0a7f,
-}; /* CR_In_Gurmukhi */
-
-/* 'In_Gujarati': Block */
-static const OnigCodePoint CR_In_Gujarati[] = {
- 1,
- 0x0a80, 0x0aff,
-}; /* CR_In_Gujarati */
-
-/* 'In_Oriya': Block */
-static const OnigCodePoint CR_In_Oriya[] = {
- 1,
- 0x0b00, 0x0b7f,
-}; /* CR_In_Oriya */
-
-/* 'In_Tamil': Block */
-static const OnigCodePoint CR_In_Tamil[] = {
- 1,
- 0x0b80, 0x0bff,
-}; /* CR_In_Tamil */
-
-/* 'In_Telugu': Block */
-static const OnigCodePoint CR_In_Telugu[] = {
- 1,
- 0x0c00, 0x0c7f,
-}; /* CR_In_Telugu */
-
-/* 'In_Kannada': Block */
-static const OnigCodePoint CR_In_Kannada[] = {
- 1,
- 0x0c80, 0x0cff,
-}; /* CR_In_Kannada */
-
-/* 'In_Malayalam': Block */
-static const OnigCodePoint CR_In_Malayalam[] = {
- 1,
- 0x0d00, 0x0d7f,
-}; /* CR_In_Malayalam */
-
-/* 'In_Sinhala': Block */
-static const OnigCodePoint CR_In_Sinhala[] = {
- 1,
- 0x0d80, 0x0dff,
-}; /* CR_In_Sinhala */
-
-/* 'In_Thai': Block */
-static const OnigCodePoint CR_In_Thai[] = {
- 1,
- 0x0e00, 0x0e7f,
-}; /* CR_In_Thai */
-
-/* 'In_Lao': Block */
-static const OnigCodePoint CR_In_Lao[] = {
- 1,
- 0x0e80, 0x0eff,
-}; /* CR_In_Lao */
-
-/* 'In_Tibetan': Block */
-static const OnigCodePoint CR_In_Tibetan[] = {
- 1,
- 0x0f00, 0x0fff,
-}; /* CR_In_Tibetan */
-
-/* 'In_Myanmar': Block */
-static const OnigCodePoint CR_In_Myanmar[] = {
- 1,
- 0x1000, 0x109f,
-}; /* CR_In_Myanmar */
-
-/* 'In_Georgian': Block */
-static const OnigCodePoint CR_In_Georgian[] = {
- 1,
- 0x10a0, 0x10ff,
-}; /* CR_In_Georgian */
-
-/* 'In_Hangul_Jamo': Block */
-static const OnigCodePoint CR_In_Hangul_Jamo[] = {
- 1,
- 0x1100, 0x11ff,
-}; /* CR_In_Hangul_Jamo */
-
-/* 'In_Ethiopic': Block */
-static const OnigCodePoint CR_In_Ethiopic[] = {
- 1,
- 0x1200, 0x137f,
-}; /* CR_In_Ethiopic */
-
-/* 'In_Ethiopic_Supplement': Block */
-static const OnigCodePoint CR_In_Ethiopic_Supplement[] = {
- 1,
- 0x1380, 0x139f,
-}; /* CR_In_Ethiopic_Supplement */
-
-/* 'In_Cherokee': Block */
-static const OnigCodePoint CR_In_Cherokee[] = {
- 1,
- 0x13a0, 0x13ff,
-}; /* CR_In_Cherokee */
-
-/* 'In_Unified_Canadian_Aboriginal_Syllabics': Block */
-static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics[] = {
- 1,
- 0x1400, 0x167f,
-}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics */
-
-/* 'In_Ogham': Block */
-static const OnigCodePoint CR_In_Ogham[] = {
- 1,
- 0x1680, 0x169f,
-}; /* CR_In_Ogham */
-
-/* 'In_Runic': Block */
-static const OnigCodePoint CR_In_Runic[] = {
- 1,
- 0x16a0, 0x16ff,
-}; /* CR_In_Runic */
-
-/* 'In_Tagalog': Block */
-static const OnigCodePoint CR_In_Tagalog[] = {
- 1,
- 0x1700, 0x171f,
-}; /* CR_In_Tagalog */
-
-/* 'In_Hanunoo': Block */
-static const OnigCodePoint CR_In_Hanunoo[] = {
- 1,
- 0x1720, 0x173f,
-}; /* CR_In_Hanunoo */
-
-/* 'In_Buhid': Block */
-static const OnigCodePoint CR_In_Buhid[] = {
- 1,
- 0x1740, 0x175f,
-}; /* CR_In_Buhid */
-
-/* 'In_Tagbanwa': Block */
-static const OnigCodePoint CR_In_Tagbanwa[] = {
- 1,
- 0x1760, 0x177f,
-}; /* CR_In_Tagbanwa */
-
-/* 'In_Khmer': Block */
-static const OnigCodePoint CR_In_Khmer[] = {
- 1,
- 0x1780, 0x17ff,
-}; /* CR_In_Khmer */
-
-/* 'In_Mongolian': Block */
-static const OnigCodePoint CR_In_Mongolian[] = {
- 1,
- 0x1800, 0x18af,
-}; /* CR_In_Mongolian */
-
-/* 'In_Unified_Canadian_Aboriginal_Syllabics_Extended': Block */
-static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended[] = {
- 1,
- 0x18b0, 0x18ff,
-}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended */
-
-/* 'In_Limbu': Block */
-static const OnigCodePoint CR_In_Limbu[] = {
- 1,
- 0x1900, 0x194f,
-}; /* CR_In_Limbu */
-
-/* 'In_Tai_Le': Block */
-static const OnigCodePoint CR_In_Tai_Le[] = {
- 1,
- 0x1950, 0x197f,
-}; /* CR_In_Tai_Le */
-
-/* 'In_New_Tai_Lue': Block */
-static const OnigCodePoint CR_In_New_Tai_Lue[] = {
- 1,
- 0x1980, 0x19df,
-}; /* CR_In_New_Tai_Lue */
-
-/* 'In_Khmer_Symbols': Block */
-static const OnigCodePoint CR_In_Khmer_Symbols[] = {
- 1,
- 0x19e0, 0x19ff,
-}; /* CR_In_Khmer_Symbols */
-
-/* 'In_Buginese': Block */
-static const OnigCodePoint CR_In_Buginese[] = {
- 1,
- 0x1a00, 0x1a1f,
-}; /* CR_In_Buginese */
-
-/* 'In_Tai_Tham': Block */
-static const OnigCodePoint CR_In_Tai_Tham[] = {
- 1,
- 0x1a20, 0x1aaf,
-}; /* CR_In_Tai_Tham */
-
-/* 'In_Combining_Diacritical_Marks_Extended': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Extended[] = {
- 1,
- 0x1ab0, 0x1aff,
-}; /* CR_In_Combining_Diacritical_Marks_Extended */
-
-/* 'In_Balinese': Block */
-static const OnigCodePoint CR_In_Balinese[] = {
- 1,
- 0x1b00, 0x1b7f,
-}; /* CR_In_Balinese */
-
-/* 'In_Sundanese': Block */
-static const OnigCodePoint CR_In_Sundanese[] = {
- 1,
- 0x1b80, 0x1bbf,
-}; /* CR_In_Sundanese */
-
-/* 'In_Batak': Block */
-static const OnigCodePoint CR_In_Batak[] = {
- 1,
- 0x1bc0, 0x1bff,
-}; /* CR_In_Batak */
-
-/* 'In_Lepcha': Block */
-static const OnigCodePoint CR_In_Lepcha[] = {
- 1,
- 0x1c00, 0x1c4f,
-}; /* CR_In_Lepcha */
-
-/* 'In_Ol_Chiki': Block */
-#define CR_In_Ol_Chiki CR_Ol_Chiki
-
-/* 'In_Cyrillic_Extended_C': Block */
-static const OnigCodePoint CR_In_Cyrillic_Extended_C[] = {
- 1,
- 0x1c80, 0x1c8f,
-}; /* CR_In_Cyrillic_Extended_C */
-
-/* 'In_Georgian_Extended': Block */
-static const OnigCodePoint CR_In_Georgian_Extended[] = {
- 1,
- 0x1c90, 0x1cbf,
-}; /* CR_In_Georgian_Extended */
-
-/* 'In_Sundanese_Supplement': Block */
-static const OnigCodePoint CR_In_Sundanese_Supplement[] = {
- 1,
- 0x1cc0, 0x1ccf,
-}; /* CR_In_Sundanese_Supplement */
-
-/* 'In_Vedic_Extensions': Block */
-static const OnigCodePoint CR_In_Vedic_Extensions[] = {
- 1,
- 0x1cd0, 0x1cff,
-}; /* CR_In_Vedic_Extensions */
-
-/* 'In_Phonetic_Extensions': Block */
-static const OnigCodePoint CR_In_Phonetic_Extensions[] = {
- 1,
- 0x1d00, 0x1d7f,
-}; /* CR_In_Phonetic_Extensions */
-
-/* 'In_Phonetic_Extensions_Supplement': Block */
-static const OnigCodePoint CR_In_Phonetic_Extensions_Supplement[] = {
- 1,
- 0x1d80, 0x1dbf,
-}; /* CR_In_Phonetic_Extensions_Supplement */
-
-/* 'In_Combining_Diacritical_Marks_Supplement': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Supplement[] = {
- 1,
- 0x1dc0, 0x1dff,
-}; /* CR_In_Combining_Diacritical_Marks_Supplement */
-
-/* 'In_Latin_Extended_Additional': Block */
-static const OnigCodePoint CR_In_Latin_Extended_Additional[] = {
- 1,
- 0x1e00, 0x1eff,
-}; /* CR_In_Latin_Extended_Additional */
-
-/* 'In_Greek_Extended': Block */
-static const OnigCodePoint CR_In_Greek_Extended[] = {
- 1,
- 0x1f00, 0x1fff,
-}; /* CR_In_Greek_Extended */
-
-/* 'In_General_Punctuation': Block */
-static const OnigCodePoint CR_In_General_Punctuation[] = {
- 1,
- 0x2000, 0x206f,
-}; /* CR_In_General_Punctuation */
-
-/* 'In_Superscripts_and_Subscripts': Block */
-static const OnigCodePoint CR_In_Superscripts_and_Subscripts[] = {
- 1,
- 0x2070, 0x209f,
-}; /* CR_In_Superscripts_and_Subscripts */
-
-/* 'In_Currency_Symbols': Block */
-static const OnigCodePoint CR_In_Currency_Symbols[] = {
- 1,
- 0x20a0, 0x20cf,
-}; /* CR_In_Currency_Symbols */
-
-/* 'In_Combining_Diacritical_Marks_for_Symbols': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks_for_Symbols[] = {
- 1,
- 0x20d0, 0x20ff,
-}; /* CR_In_Combining_Diacritical_Marks_for_Symbols */
-
-/* 'In_Letterlike_Symbols': Block */
-static const OnigCodePoint CR_In_Letterlike_Symbols[] = {
- 1,
- 0x2100, 0x214f,
-}; /* CR_In_Letterlike_Symbols */
-
-/* 'In_Number_Forms': Block */
-static const OnigCodePoint CR_In_Number_Forms[] = {
- 1,
- 0x2150, 0x218f,
-}; /* CR_In_Number_Forms */
-
-/* 'In_Arrows': Block */
-static const OnigCodePoint CR_In_Arrows[] = {
- 1,
- 0x2190, 0x21ff,
-}; /* CR_In_Arrows */
-
-/* 'In_Mathematical_Operators': Block */
-static const OnigCodePoint CR_In_Mathematical_Operators[] = {
- 1,
- 0x2200, 0x22ff,
-}; /* CR_In_Mathematical_Operators */
-
-/* 'In_Miscellaneous_Technical': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Technical[] = {
- 1,
- 0x2300, 0x23ff,
-}; /* CR_In_Miscellaneous_Technical */
-
-/* 'In_Control_Pictures': Block */
-static const OnigCodePoint CR_In_Control_Pictures[] = {
- 1,
- 0x2400, 0x243f,
-}; /* CR_In_Control_Pictures */
-
-/* 'In_Optical_Character_Recognition': Block */
-static const OnigCodePoint CR_In_Optical_Character_Recognition[] = {
- 1,
- 0x2440, 0x245f,
-}; /* CR_In_Optical_Character_Recognition */
-
-/* 'In_Enclosed_Alphanumerics': Block */
-static const OnigCodePoint CR_In_Enclosed_Alphanumerics[] = {
- 1,
- 0x2460, 0x24ff,
-}; /* CR_In_Enclosed_Alphanumerics */
-
-/* 'In_Box_Drawing': Block */
-static const OnigCodePoint CR_In_Box_Drawing[] = {
- 1,
- 0x2500, 0x257f,
-}; /* CR_In_Box_Drawing */
-
-/* 'In_Block_Elements': Block */
-static const OnigCodePoint CR_In_Block_Elements[] = {
- 1,
- 0x2580, 0x259f,
-}; /* CR_In_Block_Elements */
-
-/* 'In_Geometric_Shapes': Block */
-static const OnigCodePoint CR_In_Geometric_Shapes[] = {
- 1,
- 0x25a0, 0x25ff,
-}; /* CR_In_Geometric_Shapes */
-
-/* 'In_Miscellaneous_Symbols': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Symbols[] = {
- 1,
- 0x2600, 0x26ff,
-}; /* CR_In_Miscellaneous_Symbols */
-
-/* 'In_Dingbats': Block */
-static const OnigCodePoint CR_In_Dingbats[] = {
- 1,
- 0x2700, 0x27bf,
-}; /* CR_In_Dingbats */
-
-/* 'In_Miscellaneous_Mathematical_Symbols_A': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_A[] = {
- 1,
- 0x27c0, 0x27ef,
-}; /* CR_In_Miscellaneous_Mathematical_Symbols_A */
-
-/* 'In_Supplemental_Arrows_A': Block */
-static const OnigCodePoint CR_In_Supplemental_Arrows_A[] = {
- 1,
- 0x27f0, 0x27ff,
-}; /* CR_In_Supplemental_Arrows_A */
-
-/* 'In_Braille_Patterns': Block */
-#define CR_In_Braille_Patterns CR_Braille
-
-/* 'In_Supplemental_Arrows_B': Block */
-static const OnigCodePoint CR_In_Supplemental_Arrows_B[] = {
- 1,
- 0x2900, 0x297f,
-}; /* CR_In_Supplemental_Arrows_B */
-
-/* 'In_Miscellaneous_Mathematical_Symbols_B': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_B[] = {
- 1,
- 0x2980, 0x29ff,
-}; /* CR_In_Miscellaneous_Mathematical_Symbols_B */
-
-/* 'In_Supplemental_Mathematical_Operators': Block */
-static const OnigCodePoint CR_In_Supplemental_Mathematical_Operators[] = {
- 1,
- 0x2a00, 0x2aff,
-}; /* CR_In_Supplemental_Mathematical_Operators */
-
-/* 'In_Miscellaneous_Symbols_and_Arrows': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Arrows[] = {
- 1,
- 0x2b00, 0x2bff,
-}; /* CR_In_Miscellaneous_Symbols_and_Arrows */
-
-/* 'In_Glagolitic': Block */
-static const OnigCodePoint CR_In_Glagolitic[] = {
- 1,
- 0x2c00, 0x2c5f,
-}; /* CR_In_Glagolitic */
-
-/* 'In_Latin_Extended_C': Block */
-static const OnigCodePoint CR_In_Latin_Extended_C[] = {
- 1,
- 0x2c60, 0x2c7f,
-}; /* CR_In_Latin_Extended_C */
-
-/* 'In_Coptic': Block */
-static const OnigCodePoint CR_In_Coptic[] = {
- 1,
- 0x2c80, 0x2cff,
-}; /* CR_In_Coptic */
-
-/* 'In_Georgian_Supplement': Block */
-static const OnigCodePoint CR_In_Georgian_Supplement[] = {
- 1,
- 0x2d00, 0x2d2f,
-}; /* CR_In_Georgian_Supplement */
-
-/* 'In_Tifinagh': Block */
-static const OnigCodePoint CR_In_Tifinagh[] = {
- 1,
- 0x2d30, 0x2d7f,
-}; /* CR_In_Tifinagh */
-
-/* 'In_Ethiopic_Extended': Block */
-static const OnigCodePoint CR_In_Ethiopic_Extended[] = {
- 1,
- 0x2d80, 0x2ddf,
-}; /* CR_In_Ethiopic_Extended */
-
-/* 'In_Cyrillic_Extended_A': Block */
-static const OnigCodePoint CR_In_Cyrillic_Extended_A[] = {
- 1,
- 0x2de0, 0x2dff,
-}; /* CR_In_Cyrillic_Extended_A */
-
-/* 'In_Supplemental_Punctuation': Block */
-static const OnigCodePoint CR_In_Supplemental_Punctuation[] = {
- 1,
- 0x2e00, 0x2e7f,
-}; /* CR_In_Supplemental_Punctuation */
-
-/* 'In_CJK_Radicals_Supplement': Block */
-static const OnigCodePoint CR_In_CJK_Radicals_Supplement[] = {
- 1,
- 0x2e80, 0x2eff,
-}; /* CR_In_CJK_Radicals_Supplement */
-
-/* 'In_Kangxi_Radicals': Block */
-static const OnigCodePoint CR_In_Kangxi_Radicals[] = {
- 1,
- 0x2f00, 0x2fdf,
-}; /* CR_In_Kangxi_Radicals */
-
-/* 'In_Ideographic_Description_Characters': Block */
-static const OnigCodePoint CR_In_Ideographic_Description_Characters[] = {
- 1,
- 0x2ff0, 0x2fff,
-}; /* CR_In_Ideographic_Description_Characters */
-
-/* 'In_CJK_Symbols_and_Punctuation': Block */
-static const OnigCodePoint CR_In_CJK_Symbols_and_Punctuation[] = {
- 1,
- 0x3000, 0x303f,
-}; /* CR_In_CJK_Symbols_and_Punctuation */
-
-/* 'In_Hiragana': Block */
-static const OnigCodePoint CR_In_Hiragana[] = {
- 1,
- 0x3040, 0x309f,
-}; /* CR_In_Hiragana */
-
-/* 'In_Katakana': Block */
-static const OnigCodePoint CR_In_Katakana[] = {
- 1,
- 0x30a0, 0x30ff,
-}; /* CR_In_Katakana */
-
-/* 'In_Bopomofo': Block */
-static const OnigCodePoint CR_In_Bopomofo[] = {
- 1,
- 0x3100, 0x312f,
-}; /* CR_In_Bopomofo */
-
-/* 'In_Hangul_Compatibility_Jamo': Block */
-static const OnigCodePoint CR_In_Hangul_Compatibility_Jamo[] = {
- 1,
- 0x3130, 0x318f,
-}; /* CR_In_Hangul_Compatibility_Jamo */
-
-/* 'In_Kanbun': Block */
-static const OnigCodePoint CR_In_Kanbun[] = {
- 1,
- 0x3190, 0x319f,
-}; /* CR_In_Kanbun */
-
-/* 'In_Bopomofo_Extended': Block */
-static const OnigCodePoint CR_In_Bopomofo_Extended[] = {
- 1,
- 0x31a0, 0x31bf,
-}; /* CR_In_Bopomofo_Extended */
-
-/* 'In_CJK_Strokes': Block */
-static const OnigCodePoint CR_In_CJK_Strokes[] = {
- 1,
- 0x31c0, 0x31ef,
-}; /* CR_In_CJK_Strokes */
-
-/* 'In_Katakana_Phonetic_Extensions': Block */
-static const OnigCodePoint CR_In_Katakana_Phonetic_Extensions[] = {
- 1,
- 0x31f0, 0x31ff,
-}; /* CR_In_Katakana_Phonetic_Extensions */
-
-/* 'In_Enclosed_CJK_Letters_and_Months': Block */
-static const OnigCodePoint CR_In_Enclosed_CJK_Letters_and_Months[] = {
- 1,
- 0x3200, 0x32ff,
-}; /* CR_In_Enclosed_CJK_Letters_and_Months */
-
-/* 'In_CJK_Compatibility': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility[] = {
- 1,
- 0x3300, 0x33ff,
-}; /* CR_In_CJK_Compatibility */
-
-/* 'In_CJK_Unified_Ideographs_Extension_A': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_A[] = {
- 1,
- 0x3400, 0x4dbf,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_A */
-
-/* 'In_Yijing_Hexagram_Symbols': Block */
-static const OnigCodePoint CR_In_Yijing_Hexagram_Symbols[] = {
- 1,
- 0x4dc0, 0x4dff,
-}; /* CR_In_Yijing_Hexagram_Symbols */
-
-/* 'In_CJK_Unified_Ideographs': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs[] = {
- 1,
- 0x4e00, 0x9fff,
-}; /* CR_In_CJK_Unified_Ideographs */
-
-/* 'In_Yi_Syllables': Block */
-static const OnigCodePoint CR_In_Yi_Syllables[] = {
- 1,
- 0xa000, 0xa48f,
-}; /* CR_In_Yi_Syllables */
-
-/* 'In_Yi_Radicals': Block */
-static const OnigCodePoint CR_In_Yi_Radicals[] = {
- 1,
- 0xa490, 0xa4cf,
-}; /* CR_In_Yi_Radicals */
-
-/* 'In_Lisu': Block */
-#define CR_In_Lisu CR_Lisu
-
-/* 'In_Vai': Block */
-static const OnigCodePoint CR_In_Vai[] = {
- 1,
- 0xa500, 0xa63f,
-}; /* CR_In_Vai */
-
-/* 'In_Cyrillic_Extended_B': Block */
-static const OnigCodePoint CR_In_Cyrillic_Extended_B[] = {
- 1,
- 0xa640, 0xa69f,
-}; /* CR_In_Cyrillic_Extended_B */
-
-/* 'In_Bamum': Block */
-static const OnigCodePoint CR_In_Bamum[] = {
- 1,
- 0xa6a0, 0xa6ff,
-}; /* CR_In_Bamum */
-
-/* 'In_Modifier_Tone_Letters': Block */
-static const OnigCodePoint CR_In_Modifier_Tone_Letters[] = {
- 1,
- 0xa700, 0xa71f,
-}; /* CR_In_Modifier_Tone_Letters */
-
-/* 'In_Latin_Extended_D': Block */
-static const OnigCodePoint CR_In_Latin_Extended_D[] = {
- 1,
- 0xa720, 0xa7ff,
-}; /* CR_In_Latin_Extended_D */
-
-/* 'In_Syloti_Nagri': Block */
-static const OnigCodePoint CR_In_Syloti_Nagri[] = {
- 1,
- 0xa800, 0xa82f,
-}; /* CR_In_Syloti_Nagri */
-
-/* 'In_Common_Indic_Number_Forms': Block */
-static const OnigCodePoint CR_In_Common_Indic_Number_Forms[] = {
- 1,
- 0xa830, 0xa83f,
-}; /* CR_In_Common_Indic_Number_Forms */
-
-/* 'In_Phags_pa': Block */
-static const OnigCodePoint CR_In_Phags_pa[] = {
- 1,
- 0xa840, 0xa87f,
-}; /* CR_In_Phags_pa */
-
-/* 'In_Saurashtra': Block */
-static const OnigCodePoint CR_In_Saurashtra[] = {
- 1,
- 0xa880, 0xa8df,
-}; /* CR_In_Saurashtra */
-
-/* 'In_Devanagari_Extended': Block */
-static const OnigCodePoint CR_In_Devanagari_Extended[] = {
- 1,
- 0xa8e0, 0xa8ff,
-}; /* CR_In_Devanagari_Extended */
-
-/* 'In_Kayah_Li': Block */
-static const OnigCodePoint CR_In_Kayah_Li[] = {
- 1,
- 0xa900, 0xa92f,
-}; /* CR_In_Kayah_Li */
-
-/* 'In_Rejang': Block */
-static const OnigCodePoint CR_In_Rejang[] = {
- 1,
- 0xa930, 0xa95f,
-}; /* CR_In_Rejang */
-
-/* 'In_Hangul_Jamo_Extended_A': Block */
-static const OnigCodePoint CR_In_Hangul_Jamo_Extended_A[] = {
- 1,
- 0xa960, 0xa97f,
-}; /* CR_In_Hangul_Jamo_Extended_A */
-
-/* 'In_Javanese': Block */
-static const OnigCodePoint CR_In_Javanese[] = {
- 1,
- 0xa980, 0xa9df,
-}; /* CR_In_Javanese */
-
-/* 'In_Myanmar_Extended_B': Block */
-static const OnigCodePoint CR_In_Myanmar_Extended_B[] = {
- 1,
- 0xa9e0, 0xa9ff,
-}; /* CR_In_Myanmar_Extended_B */
-
-/* 'In_Cham': Block */
-static const OnigCodePoint CR_In_Cham[] = {
- 1,
- 0xaa00, 0xaa5f,
-}; /* CR_In_Cham */
-
-/* 'In_Myanmar_Extended_A': Block */
-static const OnigCodePoint CR_In_Myanmar_Extended_A[] = {
- 1,
- 0xaa60, 0xaa7f,
-}; /* CR_In_Myanmar_Extended_A */
-
-/* 'In_Tai_Viet': Block */
-static const OnigCodePoint CR_In_Tai_Viet[] = {
- 1,
- 0xaa80, 0xaadf,
-}; /* CR_In_Tai_Viet */
-
-/* 'In_Meetei_Mayek_Extensions': Block */
-static const OnigCodePoint CR_In_Meetei_Mayek_Extensions[] = {
- 1,
- 0xaae0, 0xaaff,
-}; /* CR_In_Meetei_Mayek_Extensions */
-
-/* 'In_Ethiopic_Extended_A': Block */
-static const OnigCodePoint CR_In_Ethiopic_Extended_A[] = {
- 1,
- 0xab00, 0xab2f,
-}; /* CR_In_Ethiopic_Extended_A */
-
-/* 'In_Latin_Extended_E': Block */
-static const OnigCodePoint CR_In_Latin_Extended_E[] = {
- 1,
- 0xab30, 0xab6f,
-}; /* CR_In_Latin_Extended_E */
-
-/* 'In_Cherokee_Supplement': Block */
-static const OnigCodePoint CR_In_Cherokee_Supplement[] = {
- 1,
- 0xab70, 0xabbf,
-}; /* CR_In_Cherokee_Supplement */
-
-/* 'In_Meetei_Mayek': Block */
-static const OnigCodePoint CR_In_Meetei_Mayek[] = {
- 1,
- 0xabc0, 0xabff,
-}; /* CR_In_Meetei_Mayek */
-
-/* 'In_Hangul_Syllables': Block */
-static const OnigCodePoint CR_In_Hangul_Syllables[] = {
- 1,
- 0xac00, 0xd7af,
-}; /* CR_In_Hangul_Syllables */
-
-/* 'In_Hangul_Jamo_Extended_B': Block */
-static const OnigCodePoint CR_In_Hangul_Jamo_Extended_B[] = {
- 1,
- 0xd7b0, 0xd7ff,
-}; /* CR_In_Hangul_Jamo_Extended_B */
-
-/* 'In_High_Surrogates': Block */
-static const OnigCodePoint CR_In_High_Surrogates[] = {
- 1,
- 0xd800, 0xdb7f,
-}; /* CR_In_High_Surrogates */
-
-/* 'In_High_Private_Use_Surrogates': Block */
-static const OnigCodePoint CR_In_High_Private_Use_Surrogates[] = {
- 1,
- 0xdb80, 0xdbff,
-}; /* CR_In_High_Private_Use_Surrogates */
-
-/* 'In_Low_Surrogates': Block */
-static const OnigCodePoint CR_In_Low_Surrogates[] = {
- 1,
- 0xdc00, 0xdfff,
-}; /* CR_In_Low_Surrogates */
-
-/* 'In_Private_Use_Area': Block */
-static const OnigCodePoint CR_In_Private_Use_Area[] = {
- 1,
- 0xe000, 0xf8ff,
-}; /* CR_In_Private_Use_Area */
-
-/* 'In_CJK_Compatibility_Ideographs': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs[] = {
- 1,
- 0xf900, 0xfaff,
-}; /* CR_In_CJK_Compatibility_Ideographs */
-
-/* 'In_Alphabetic_Presentation_Forms': Block */
-static const OnigCodePoint CR_In_Alphabetic_Presentation_Forms[] = {
- 1,
- 0xfb00, 0xfb4f,
-}; /* CR_In_Alphabetic_Presentation_Forms */
-
-/* 'In_Arabic_Presentation_Forms_A': Block */
-static const OnigCodePoint CR_In_Arabic_Presentation_Forms_A[] = {
- 1,
- 0xfb50, 0xfdff,
-}; /* CR_In_Arabic_Presentation_Forms_A */
-
-/* 'In_Variation_Selectors': Block */
-static const OnigCodePoint CR_In_Variation_Selectors[] = {
- 1,
- 0xfe00, 0xfe0f,
-}; /* CR_In_Variation_Selectors */
-
-/* 'In_Vertical_Forms': Block */
-static const OnigCodePoint CR_In_Vertical_Forms[] = {
- 1,
- 0xfe10, 0xfe1f,
-}; /* CR_In_Vertical_Forms */
-
-/* 'In_Combining_Half_Marks': Block */
-static const OnigCodePoint CR_In_Combining_Half_Marks[] = {
- 1,
- 0xfe20, 0xfe2f,
-}; /* CR_In_Combining_Half_Marks */
-
-/* 'In_CJK_Compatibility_Forms': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility_Forms[] = {
- 1,
- 0xfe30, 0xfe4f,
-}; /* CR_In_CJK_Compatibility_Forms */
-
-/* 'In_Small_Form_Variants': Block */
-static const OnigCodePoint CR_In_Small_Form_Variants[] = {
- 1,
- 0xfe50, 0xfe6f,
-}; /* CR_In_Small_Form_Variants */
-
-/* 'In_Arabic_Presentation_Forms_B': Block */
-static const OnigCodePoint CR_In_Arabic_Presentation_Forms_B[] = {
- 1,
- 0xfe70, 0xfeff,
-}; /* CR_In_Arabic_Presentation_Forms_B */
-
-/* 'In_Halfwidth_and_Fullwidth_Forms': Block */
-static const OnigCodePoint CR_In_Halfwidth_and_Fullwidth_Forms[] = {
- 1,
- 0xff00, 0xffef,
-}; /* CR_In_Halfwidth_and_Fullwidth_Forms */
-
-/* 'In_Specials': Block */
-static const OnigCodePoint CR_In_Specials[] = {
- 1,
- 0xfff0, 0xffff,
-}; /* CR_In_Specials */
-
-/* 'In_Linear_B_Syllabary': Block */
-static const OnigCodePoint CR_In_Linear_B_Syllabary[] = {
- 1,
- 0x10000, 0x1007f,
-}; /* CR_In_Linear_B_Syllabary */
-
-/* 'In_Linear_B_Ideograms': Block */
-static const OnigCodePoint CR_In_Linear_B_Ideograms[] = {
- 1,
- 0x10080, 0x100ff,
-}; /* CR_In_Linear_B_Ideograms */
-
-/* 'In_Aegean_Numbers': Block */
-static const OnigCodePoint CR_In_Aegean_Numbers[] = {
- 1,
- 0x10100, 0x1013f,
-}; /* CR_In_Aegean_Numbers */
-
-/* 'In_Ancient_Greek_Numbers': Block */
-static const OnigCodePoint CR_In_Ancient_Greek_Numbers[] = {
- 1,
- 0x10140, 0x1018f,
-}; /* CR_In_Ancient_Greek_Numbers */
-
-/* 'In_Ancient_Symbols': Block */
-static const OnigCodePoint CR_In_Ancient_Symbols[] = {
- 1,
- 0x10190, 0x101cf,
-}; /* CR_In_Ancient_Symbols */
-
-/* 'In_Phaistos_Disc': Block */
-static const OnigCodePoint CR_In_Phaistos_Disc[] = {
- 1,
- 0x101d0, 0x101ff,
-}; /* CR_In_Phaistos_Disc */
-
-/* 'In_Lycian': Block */
-static const OnigCodePoint CR_In_Lycian[] = {
- 1,
- 0x10280, 0x1029f,
-}; /* CR_In_Lycian */
-
-/* 'In_Carian': Block */
-static const OnigCodePoint CR_In_Carian[] = {
- 1,
- 0x102a0, 0x102df,
-}; /* CR_In_Carian */
-
-/* 'In_Coptic_Epact_Numbers': Block */
-static const OnigCodePoint CR_In_Coptic_Epact_Numbers[] = {
- 1,
- 0x102e0, 0x102ff,
-}; /* CR_In_Coptic_Epact_Numbers */
-
-/* 'In_Old_Italic': Block */
-static const OnigCodePoint CR_In_Old_Italic[] = {
- 1,
- 0x10300, 0x1032f,
-}; /* CR_In_Old_Italic */
-
-/* 'In_Gothic': Block */
-static const OnigCodePoint CR_In_Gothic[] = {
- 1,
- 0x10330, 0x1034f,
-}; /* CR_In_Gothic */
-
-/* 'In_Old_Permic': Block */
-static const OnigCodePoint CR_In_Old_Permic[] = {
- 1,
- 0x10350, 0x1037f,
-}; /* CR_In_Old_Permic */
-
-/* 'In_Ugaritic': Block */
-static const OnigCodePoint CR_In_Ugaritic[] = {
- 1,
- 0x10380, 0x1039f,
-}; /* CR_In_Ugaritic */
-
-/* 'In_Old_Persian': Block */
-static const OnigCodePoint CR_In_Old_Persian[] = {
- 1,
- 0x103a0, 0x103df,
-}; /* CR_In_Old_Persian */
-
-/* 'In_Deseret': Block */
-#define CR_In_Deseret CR_Deseret
-
-/* 'In_Shavian': Block */
-#define CR_In_Shavian CR_Shavian
-
-/* 'In_Osmanya': Block */
-static const OnigCodePoint CR_In_Osmanya[] = {
- 1,
- 0x10480, 0x104af,
-}; /* CR_In_Osmanya */
-
-/* 'In_Osage': Block */
-static const OnigCodePoint CR_In_Osage[] = {
- 1,
- 0x104b0, 0x104ff,
-}; /* CR_In_Osage */
-
-/* 'In_Elbasan': Block */
-static const OnigCodePoint CR_In_Elbasan[] = {
- 1,
- 0x10500, 0x1052f,
-}; /* CR_In_Elbasan */
-
-/* 'In_Caucasian_Albanian': Block */
-static const OnigCodePoint CR_In_Caucasian_Albanian[] = {
- 1,
- 0x10530, 0x1056f,
-}; /* CR_In_Caucasian_Albanian */
-
-/* 'In_Linear_A': Block */
-static const OnigCodePoint CR_In_Linear_A[] = {
- 1,
- 0x10600, 0x1077f,
-}; /* CR_In_Linear_A */
-
-/* 'In_Cypriot_Syllabary': Block */
-static const OnigCodePoint CR_In_Cypriot_Syllabary[] = {
- 1,
- 0x10800, 0x1083f,
-}; /* CR_In_Cypriot_Syllabary */
-
-/* 'In_Imperial_Aramaic': Block */
-static const OnigCodePoint CR_In_Imperial_Aramaic[] = {
- 1,
- 0x10840, 0x1085f,
-}; /* CR_In_Imperial_Aramaic */
-
-/* 'In_Palmyrene': Block */
-#define CR_In_Palmyrene CR_Palmyrene
-
-/* 'In_Nabataean': Block */
-static const OnigCodePoint CR_In_Nabataean[] = {
- 1,
- 0x10880, 0x108af,
-}; /* CR_In_Nabataean */
-
-/* 'In_Hatran': Block */
-static const OnigCodePoint CR_In_Hatran[] = {
- 1,
- 0x108e0, 0x108ff,
-}; /* CR_In_Hatran */
-
-/* 'In_Phoenician': Block */
-static const OnigCodePoint CR_In_Phoenician[] = {
- 1,
- 0x10900, 0x1091f,
-}; /* CR_In_Phoenician */
-
-/* 'In_Lydian': Block */
-static const OnigCodePoint CR_In_Lydian[] = {
- 1,
- 0x10920, 0x1093f,
-}; /* CR_In_Lydian */
-
-/* 'In_Meroitic_Hieroglyphs': Block */
-#define CR_In_Meroitic_Hieroglyphs CR_Meroitic_Hieroglyphs
-
-/* 'In_Meroitic_Cursive': Block */
-static const OnigCodePoint CR_In_Meroitic_Cursive[] = {
- 1,
- 0x109a0, 0x109ff,
-}; /* CR_In_Meroitic_Cursive */
-
-/* 'In_Kharoshthi': Block */
-static const OnigCodePoint CR_In_Kharoshthi[] = {
- 1,
- 0x10a00, 0x10a5f,
-}; /* CR_In_Kharoshthi */
-
-/* 'In_Old_South_Arabian': Block */
-#define CR_In_Old_South_Arabian CR_Old_South_Arabian
-
-/* 'In_Old_North_Arabian': Block */
-#define CR_In_Old_North_Arabian CR_Old_North_Arabian
-
-/* 'In_Manichaean': Block */
-static const OnigCodePoint CR_In_Manichaean[] = {
- 1,
- 0x10ac0, 0x10aff,
-}; /* CR_In_Manichaean */
-
-/* 'In_Avestan': Block */
-static const OnigCodePoint CR_In_Avestan[] = {
- 1,
- 0x10b00, 0x10b3f,
-}; /* CR_In_Avestan */
-
-/* 'In_Inscriptional_Parthian': Block */
-static const OnigCodePoint CR_In_Inscriptional_Parthian[] = {
- 1,
- 0x10b40, 0x10b5f,
-}; /* CR_In_Inscriptional_Parthian */
-
-/* 'In_Inscriptional_Pahlavi': Block */
-static const OnigCodePoint CR_In_Inscriptional_Pahlavi[] = {
- 1,
- 0x10b60, 0x10b7f,
-}; /* CR_In_Inscriptional_Pahlavi */
-
-/* 'In_Psalter_Pahlavi': Block */
-static const OnigCodePoint CR_In_Psalter_Pahlavi[] = {
- 1,
- 0x10b80, 0x10baf,
-}; /* CR_In_Psalter_Pahlavi */
-
-/* 'In_Old_Turkic': Block */
-static const OnigCodePoint CR_In_Old_Turkic[] = {
- 1,
- 0x10c00, 0x10c4f,
-}; /* CR_In_Old_Turkic */
-
-/* 'In_Old_Hungarian': Block */
-static const OnigCodePoint CR_In_Old_Hungarian[] = {
- 1,
- 0x10c80, 0x10cff,
-}; /* CR_In_Old_Hungarian */
-
-/* 'In_Hanifi_Rohingya': Block */
-static const OnigCodePoint CR_In_Hanifi_Rohingya[] = {
- 1,
- 0x10d00, 0x10d3f,
-}; /* CR_In_Hanifi_Rohingya */
-
-/* 'In_Rumi_Numeral_Symbols': Block */
-static const OnigCodePoint CR_In_Rumi_Numeral_Symbols[] = {
- 1,
- 0x10e60, 0x10e7f,
-}; /* CR_In_Rumi_Numeral_Symbols */
-
-/* 'In_Old_Sogdian': Block */
-static const OnigCodePoint CR_In_Old_Sogdian[] = {
- 1,
- 0x10f00, 0x10f2f,
-}; /* CR_In_Old_Sogdian */
-
-/* 'In_Sogdian': Block */
-static const OnigCodePoint CR_In_Sogdian[] = {
- 1,
- 0x10f30, 0x10f6f,
-}; /* CR_In_Sogdian */
-
-/* 'In_Elymaic': Block */
-static const OnigCodePoint CR_In_Elymaic[] = {
- 1,
- 0x10fe0, 0x10fff,
-}; /* CR_In_Elymaic */
-
-/* 'In_Brahmi': Block */
-static const OnigCodePoint CR_In_Brahmi[] = {
- 1,
- 0x11000, 0x1107f,
-}; /* CR_In_Brahmi */
-
-/* 'In_Kaithi': Block */
-static const OnigCodePoint CR_In_Kaithi[] = {
- 1,
- 0x11080, 0x110cf,
-}; /* CR_In_Kaithi */
-
-/* 'In_Sora_Sompeng': Block */
-static const OnigCodePoint CR_In_Sora_Sompeng[] = {
- 1,
- 0x110d0, 0x110ff,
-}; /* CR_In_Sora_Sompeng */
-
-/* 'In_Chakma': Block */
-static const OnigCodePoint CR_In_Chakma[] = {
- 1,
- 0x11100, 0x1114f,
-}; /* CR_In_Chakma */
-
-/* 'In_Mahajani': Block */
-static const OnigCodePoint CR_In_Mahajani[] = {
- 1,
- 0x11150, 0x1117f,
-}; /* CR_In_Mahajani */
-
-/* 'In_Sharada': Block */
-static const OnigCodePoint CR_In_Sharada[] = {
- 1,
- 0x11180, 0x111df,
-}; /* CR_In_Sharada */
-
-/* 'In_Sinhala_Archaic_Numbers': Block */
-static const OnigCodePoint CR_In_Sinhala_Archaic_Numbers[] = {
- 1,
- 0x111e0, 0x111ff,
-}; /* CR_In_Sinhala_Archaic_Numbers */
-
-/* 'In_Khojki': Block */
-static const OnigCodePoint CR_In_Khojki[] = {
- 1,
- 0x11200, 0x1124f,
-}; /* CR_In_Khojki */
-
-/* 'In_Multani': Block */
-static const OnigCodePoint CR_In_Multani[] = {
- 1,
- 0x11280, 0x112af,
-}; /* CR_In_Multani */
-
-/* 'In_Khudawadi': Block */
-static const OnigCodePoint CR_In_Khudawadi[] = {
- 1,
- 0x112b0, 0x112ff,
-}; /* CR_In_Khudawadi */
-
-/* 'In_Grantha': Block */
-static const OnigCodePoint CR_In_Grantha[] = {
- 1,
- 0x11300, 0x1137f,
-}; /* CR_In_Grantha */
-
-/* 'In_Newa': Block */
-static const OnigCodePoint CR_In_Newa[] = {
- 1,
- 0x11400, 0x1147f,
-}; /* CR_In_Newa */
-
-/* 'In_Tirhuta': Block */
-static const OnigCodePoint CR_In_Tirhuta[] = {
- 1,
- 0x11480, 0x114df,
-}; /* CR_In_Tirhuta */
-
-/* 'In_Siddham': Block */
-static const OnigCodePoint CR_In_Siddham[] = {
- 1,
- 0x11580, 0x115ff,
-}; /* CR_In_Siddham */
-
-/* 'In_Modi': Block */
-static const OnigCodePoint CR_In_Modi[] = {
- 1,
- 0x11600, 0x1165f,
-}; /* CR_In_Modi */
-
-/* 'In_Mongolian_Supplement': Block */
-static const OnigCodePoint CR_In_Mongolian_Supplement[] = {
- 1,
- 0x11660, 0x1167f,
-}; /* CR_In_Mongolian_Supplement */
-
-/* 'In_Takri': Block */
-static const OnigCodePoint CR_In_Takri[] = {
- 1,
- 0x11680, 0x116cf,
-}; /* CR_In_Takri */
-
-/* 'In_Ahom': Block */
-static const OnigCodePoint CR_In_Ahom[] = {
- 1,
- 0x11700, 0x1173f,
-}; /* CR_In_Ahom */
-
-/* 'In_Dogra': Block */
-static const OnigCodePoint CR_In_Dogra[] = {
- 1,
- 0x11800, 0x1184f,
-}; /* CR_In_Dogra */
-
-/* 'In_Warang_Citi': Block */
-static const OnigCodePoint CR_In_Warang_Citi[] = {
- 1,
- 0x118a0, 0x118ff,
-}; /* CR_In_Warang_Citi */
-
-/* 'In_Nandinagari': Block */
-static const OnigCodePoint CR_In_Nandinagari[] = {
- 1,
- 0x119a0, 0x119ff,
-}; /* CR_In_Nandinagari */
-
-/* 'In_Zanabazar_Square': Block */
-static const OnigCodePoint CR_In_Zanabazar_Square[] = {
- 1,
- 0x11a00, 0x11a4f,
-}; /* CR_In_Zanabazar_Square */
-
-/* 'In_Soyombo': Block */
-static const OnigCodePoint CR_In_Soyombo[] = {
- 1,
- 0x11a50, 0x11aaf,
-}; /* CR_In_Soyombo */
-
-/* 'In_Pau_Cin_Hau': Block */
-static const OnigCodePoint CR_In_Pau_Cin_Hau[] = {
- 1,
- 0x11ac0, 0x11aff,
-}; /* CR_In_Pau_Cin_Hau */
-
-/* 'In_Bhaiksuki': Block */
-static const OnigCodePoint CR_In_Bhaiksuki[] = {
- 1,
- 0x11c00, 0x11c6f,
-}; /* CR_In_Bhaiksuki */
-
-/* 'In_Marchen': Block */
-static const OnigCodePoint CR_In_Marchen[] = {
- 1,
- 0x11c70, 0x11cbf,
-}; /* CR_In_Marchen */
-
-/* 'In_Masaram_Gondi': Block */
-static const OnigCodePoint CR_In_Masaram_Gondi[] = {
- 1,
- 0x11d00, 0x11d5f,
-}; /* CR_In_Masaram_Gondi */
-
-/* 'In_Gunjala_Gondi': Block */
-static const OnigCodePoint CR_In_Gunjala_Gondi[] = {
- 1,
- 0x11d60, 0x11daf,
-}; /* CR_In_Gunjala_Gondi */
-
-/* 'In_Makasar': Block */
-static const OnigCodePoint CR_In_Makasar[] = {
- 1,
- 0x11ee0, 0x11eff,
-}; /* CR_In_Makasar */
-
-/* 'In_Tamil_Supplement': Block */
-static const OnigCodePoint CR_In_Tamil_Supplement[] = {
- 1,
- 0x11fc0, 0x11fff,
-}; /* CR_In_Tamil_Supplement */
-
-/* 'In_Cuneiform': Block */
-static const OnigCodePoint CR_In_Cuneiform[] = {
- 1,
- 0x12000, 0x123ff,
-}; /* CR_In_Cuneiform */
-
-/* 'In_Cuneiform_Numbers_and_Punctuation': Block */
-static const OnigCodePoint CR_In_Cuneiform_Numbers_and_Punctuation[] = {
- 1,
- 0x12400, 0x1247f,
-}; /* CR_In_Cuneiform_Numbers_and_Punctuation */
-
-/* 'In_Early_Dynastic_Cuneiform': Block */
-static const OnigCodePoint CR_In_Early_Dynastic_Cuneiform[] = {
- 1,
- 0x12480, 0x1254f,
-}; /* CR_In_Early_Dynastic_Cuneiform */
-
-/* 'In_Egyptian_Hieroglyphs': Block */
-static const OnigCodePoint CR_In_Egyptian_Hieroglyphs[] = {
- 1,
- 0x13000, 0x1342f,
-}; /* CR_In_Egyptian_Hieroglyphs */
-
-/* 'In_Egyptian_Hieroglyph_Format_Controls': Block */
-static const OnigCodePoint CR_In_Egyptian_Hieroglyph_Format_Controls[] = {
- 1,
- 0x13430, 0x1343f,
-}; /* CR_In_Egyptian_Hieroglyph_Format_Controls */
-
-/* 'In_Anatolian_Hieroglyphs': Block */
-static const OnigCodePoint CR_In_Anatolian_Hieroglyphs[] = {
- 1,
- 0x14400, 0x1467f,
-}; /* CR_In_Anatolian_Hieroglyphs */
-
-/* 'In_Bamum_Supplement': Block */
-static const OnigCodePoint CR_In_Bamum_Supplement[] = {
- 1,
- 0x16800, 0x16a3f,
-}; /* CR_In_Bamum_Supplement */
-
-/* 'In_Mro': Block */
-static const OnigCodePoint CR_In_Mro[] = {
- 1,
- 0x16a40, 0x16a6f,
-}; /* CR_In_Mro */
-
-/* 'In_Bassa_Vah': Block */
-static const OnigCodePoint CR_In_Bassa_Vah[] = {
- 1,
- 0x16ad0, 0x16aff,
-}; /* CR_In_Bassa_Vah */
-
-/* 'In_Pahawh_Hmong': Block */
-static const OnigCodePoint CR_In_Pahawh_Hmong[] = {
- 1,
- 0x16b00, 0x16b8f,
-}; /* CR_In_Pahawh_Hmong */
-
-/* 'In_Medefaidrin': Block */
-static const OnigCodePoint CR_In_Medefaidrin[] = {
- 1,
- 0x16e40, 0x16e9f,
-}; /* CR_In_Medefaidrin */
-
-/* 'In_Miao': Block */
-static const OnigCodePoint CR_In_Miao[] = {
- 1,
- 0x16f00, 0x16f9f,
-}; /* CR_In_Miao */
-
-/* 'In_Ideographic_Symbols_and_Punctuation': Block */
-static const OnigCodePoint CR_In_Ideographic_Symbols_and_Punctuation[] = {
- 1,
- 0x16fe0, 0x16fff,
-}; /* CR_In_Ideographic_Symbols_and_Punctuation */
-
-/* 'In_Tangut': Block */
-static const OnigCodePoint CR_In_Tangut[] = {
- 1,
- 0x17000, 0x187ff,
-}; /* CR_In_Tangut */
-
-/* 'In_Tangut_Components': Block */
-static const OnigCodePoint CR_In_Tangut_Components[] = {
- 1,
- 0x18800, 0x18aff,
-}; /* CR_In_Tangut_Components */
-
-/* 'In_Kana_Supplement': Block */
-static const OnigCodePoint CR_In_Kana_Supplement[] = {
- 1,
- 0x1b000, 0x1b0ff,
-}; /* CR_In_Kana_Supplement */
-
-/* 'In_Kana_Extended_A': Block */
-static const OnigCodePoint CR_In_Kana_Extended_A[] = {
- 1,
- 0x1b100, 0x1b12f,
-}; /* CR_In_Kana_Extended_A */
-
-/* 'In_Small_Kana_Extension': Block */
-static const OnigCodePoint CR_In_Small_Kana_Extension[] = {
- 1,
- 0x1b130, 0x1b16f,
-}; /* CR_In_Small_Kana_Extension */
-
-/* 'In_Nushu': Block */
-static const OnigCodePoint CR_In_Nushu[] = {
- 1,
- 0x1b170, 0x1b2ff,
-}; /* CR_In_Nushu */
-
-/* 'In_Duployan': Block */
-static const OnigCodePoint CR_In_Duployan[] = {
- 1,
- 0x1bc00, 0x1bc9f,
-}; /* CR_In_Duployan */
-
-/* 'In_Shorthand_Format_Controls': Block */
-static const OnigCodePoint CR_In_Shorthand_Format_Controls[] = {
- 1,
- 0x1bca0, 0x1bcaf,
-}; /* CR_In_Shorthand_Format_Controls */
-
-/* 'In_Byzantine_Musical_Symbols': Block */
-static const OnigCodePoint CR_In_Byzantine_Musical_Symbols[] = {
- 1,
- 0x1d000, 0x1d0ff,
-}; /* CR_In_Byzantine_Musical_Symbols */
-
-/* 'In_Musical_Symbols': Block */
-static const OnigCodePoint CR_In_Musical_Symbols[] = {
- 1,
- 0x1d100, 0x1d1ff,
-}; /* CR_In_Musical_Symbols */
-
-/* 'In_Ancient_Greek_Musical_Notation': Block */
-static const OnigCodePoint CR_In_Ancient_Greek_Musical_Notation[] = {
- 1,
- 0x1d200, 0x1d24f,
-}; /* CR_In_Ancient_Greek_Musical_Notation */
-
-/* 'In_Mayan_Numerals': Block */
-static const OnigCodePoint CR_In_Mayan_Numerals[] = {
- 1,
- 0x1d2e0, 0x1d2ff,
-}; /* CR_In_Mayan_Numerals */
-
-/* 'In_Tai_Xuan_Jing_Symbols': Block */
-static const OnigCodePoint CR_In_Tai_Xuan_Jing_Symbols[] = {
- 1,
- 0x1d300, 0x1d35f,
-}; /* CR_In_Tai_Xuan_Jing_Symbols */
-
-/* 'In_Counting_Rod_Numerals': Block */
-static const OnigCodePoint CR_In_Counting_Rod_Numerals[] = {
- 1,
- 0x1d360, 0x1d37f,
-}; /* CR_In_Counting_Rod_Numerals */
-
-/* 'In_Mathematical_Alphanumeric_Symbols': Block */
-static const OnigCodePoint CR_In_Mathematical_Alphanumeric_Symbols[] = {
- 1,
- 0x1d400, 0x1d7ff,
-}; /* CR_In_Mathematical_Alphanumeric_Symbols */
-
-/* 'In_Sutton_SignWriting': Block */
-static const OnigCodePoint CR_In_Sutton_SignWriting[] = {
- 1,
- 0x1d800, 0x1daaf,
-}; /* CR_In_Sutton_SignWriting */
-
-/* 'In_Glagolitic_Supplement': Block */
-static const OnigCodePoint CR_In_Glagolitic_Supplement[] = {
- 1,
- 0x1e000, 0x1e02f,
-}; /* CR_In_Glagolitic_Supplement */
-
-/* 'In_Nyiakeng_Puachue_Hmong': Block */
-static const OnigCodePoint CR_In_Nyiakeng_Puachue_Hmong[] = {
- 1,
- 0x1e100, 0x1e14f,
-}; /* CR_In_Nyiakeng_Puachue_Hmong */
-
-/* 'In_Wancho': Block */
-static const OnigCodePoint CR_In_Wancho[] = {
- 1,
- 0x1e2c0, 0x1e2ff,
-}; /* CR_In_Wancho */
-
-/* 'In_Mende_Kikakui': Block */
-static const OnigCodePoint CR_In_Mende_Kikakui[] = {
- 1,
- 0x1e800, 0x1e8df,
-}; /* CR_In_Mende_Kikakui */
-
-/* 'In_Adlam': Block */
-static const OnigCodePoint CR_In_Adlam[] = {
- 1,
- 0x1e900, 0x1e95f,
-}; /* CR_In_Adlam */
-
-/* 'In_Indic_Siyaq_Numbers': Block */
-static const OnigCodePoint CR_In_Indic_Siyaq_Numbers[] = {
- 1,
- 0x1ec70, 0x1ecbf,
-}; /* CR_In_Indic_Siyaq_Numbers */
-
-/* 'In_Ottoman_Siyaq_Numbers': Block */
-static const OnigCodePoint CR_In_Ottoman_Siyaq_Numbers[] = {
- 1,
- 0x1ed00, 0x1ed4f,
-}; /* CR_In_Ottoman_Siyaq_Numbers */
-
-/* 'In_Arabic_Mathematical_Alphabetic_Symbols': Block */
-static const OnigCodePoint CR_In_Arabic_Mathematical_Alphabetic_Symbols[] = {
- 1,
- 0x1ee00, 0x1eeff,
-}; /* CR_In_Arabic_Mathematical_Alphabetic_Symbols */
-
-/* 'In_Mahjong_Tiles': Block */
-static const OnigCodePoint CR_In_Mahjong_Tiles[] = {
- 1,
- 0x1f000, 0x1f02f,
-}; /* CR_In_Mahjong_Tiles */
-
-/* 'In_Domino_Tiles': Block */
-static const OnigCodePoint CR_In_Domino_Tiles[] = {
- 1,
- 0x1f030, 0x1f09f,
-}; /* CR_In_Domino_Tiles */
-
-/* 'In_Playing_Cards': Block */
-static const OnigCodePoint CR_In_Playing_Cards[] = {
- 1,
- 0x1f0a0, 0x1f0ff,
-}; /* CR_In_Playing_Cards */
-
-/* 'In_Enclosed_Alphanumeric_Supplement': Block */
-static const OnigCodePoint CR_In_Enclosed_Alphanumeric_Supplement[] = {
- 1,
- 0x1f100, 0x1f1ff,
-}; /* CR_In_Enclosed_Alphanumeric_Supplement */
-
-/* 'In_Enclosed_Ideographic_Supplement': Block */
-static const OnigCodePoint CR_In_Enclosed_Ideographic_Supplement[] = {
- 1,
- 0x1f200, 0x1f2ff,
-}; /* CR_In_Enclosed_Ideographic_Supplement */
-
-/* 'In_Miscellaneous_Symbols_and_Pictographs': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Pictographs[] = {
- 1,
- 0x1f300, 0x1f5ff,
-}; /* CR_In_Miscellaneous_Symbols_and_Pictographs */
-
-/* 'In_Emoticons': Block */
-static const OnigCodePoint CR_In_Emoticons[] = {
- 1,
- 0x1f600, 0x1f64f,
-}; /* CR_In_Emoticons */
-
-/* 'In_Ornamental_Dingbats': Block */
-static const OnigCodePoint CR_In_Ornamental_Dingbats[] = {
- 1,
- 0x1f650, 0x1f67f,
-}; /* CR_In_Ornamental_Dingbats */
-
-/* 'In_Transport_and_Map_Symbols': Block */
-static const OnigCodePoint CR_In_Transport_and_Map_Symbols[] = {
- 1,
- 0x1f680, 0x1f6ff,
-}; /* CR_In_Transport_and_Map_Symbols */
-
-/* 'In_Alchemical_Symbols': Block */
-static const OnigCodePoint CR_In_Alchemical_Symbols[] = {
- 1,
- 0x1f700, 0x1f77f,
-}; /* CR_In_Alchemical_Symbols */
-
-/* 'In_Geometric_Shapes_Extended': Block */
-static const OnigCodePoint CR_In_Geometric_Shapes_Extended[] = {
- 1,
- 0x1f780, 0x1f7ff,
-}; /* CR_In_Geometric_Shapes_Extended */
-
-/* 'In_Supplemental_Arrows_C': Block */
-static const OnigCodePoint CR_In_Supplemental_Arrows_C[] = {
- 1,
- 0x1f800, 0x1f8ff,
-}; /* CR_In_Supplemental_Arrows_C */
-
-/* 'In_Supplemental_Symbols_and_Pictographs': Block */
-static const OnigCodePoint CR_In_Supplemental_Symbols_and_Pictographs[] = {
- 1,
- 0x1f900, 0x1f9ff,
-}; /* CR_In_Supplemental_Symbols_and_Pictographs */
-
-/* 'In_Chess_Symbols': Block */
-static const OnigCodePoint CR_In_Chess_Symbols[] = {
- 1,
- 0x1fa00, 0x1fa6f,
-}; /* CR_In_Chess_Symbols */
-
-/* 'In_Symbols_and_Pictographs_Extended_A': Block */
-static const OnigCodePoint CR_In_Symbols_and_Pictographs_Extended_A[] = {
- 1,
- 0x1fa70, 0x1faff,
-}; /* CR_In_Symbols_and_Pictographs_Extended_A */
-
-/* 'In_CJK_Unified_Ideographs_Extension_B': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_B[] = {
- 1,
- 0x20000, 0x2a6df,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_B */
-
-/* 'In_CJK_Unified_Ideographs_Extension_C': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_C[] = {
- 1,
- 0x2a700, 0x2b73f,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_C */
-
-/* 'In_CJK_Unified_Ideographs_Extension_D': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_D[] = {
- 1,
- 0x2b740, 0x2b81f,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_D */
-
-/* 'In_CJK_Unified_Ideographs_Extension_E': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_E[] = {
- 1,
- 0x2b820, 0x2ceaf,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_E */
-
-/* 'In_CJK_Unified_Ideographs_Extension_F': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_F[] = {
- 1,
- 0x2ceb0, 0x2ebef,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_F */
-
-/* 'In_CJK_Compatibility_Ideographs_Supplement': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs_Supplement[] = {
- 1,
- 0x2f800, 0x2fa1f,
-}; /* CR_In_CJK_Compatibility_Ideographs_Supplement */
-
-/* 'In_Tags': Block */
-static const OnigCodePoint CR_In_Tags[] = {
- 1,
- 0xe0000, 0xe007f,
-}; /* CR_In_Tags */
-
-/* 'In_Variation_Selectors_Supplement': Block */
-static const OnigCodePoint CR_In_Variation_Selectors_Supplement[] = {
- 1,
- 0xe0100, 0xe01ef,
-}; /* CR_In_Variation_Selectors_Supplement */
-
-/* 'In_Supplementary_Private_Use_Area_A': Block */
-static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_A[] = {
- 1,
- 0xf0000, 0xfffff,
-}; /* CR_In_Supplementary_Private_Use_Area_A */
-
-/* 'In_Supplementary_Private_Use_Area_B': Block */
-static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_B[] = {
- 1,
- 0x100000, 0x10ffff,
-}; /* CR_In_Supplementary_Private_Use_Area_B */
-
-/* 'In_No_Block': Block */
-static const OnigCodePoint CR_In_No_Block[] = {
- 53,
- 0x0870, 0x089f,
- 0x2fe0, 0x2fef,
- 0x10200, 0x1027f,
- 0x103e0, 0x103ff,
- 0x10570, 0x105ff,
- 0x10780, 0x107ff,
- 0x108b0, 0x108df,
- 0x10940, 0x1097f,
- 0x10aa0, 0x10abf,
- 0x10bb0, 0x10bff,
- 0x10c50, 0x10c7f,
- 0x10d40, 0x10e5f,
- 0x10e80, 0x10eff,
- 0x10f70, 0x10fdf,
- 0x11250, 0x1127f,
- 0x11380, 0x113ff,
- 0x114e0, 0x1157f,
- 0x116d0, 0x116ff,
- 0x11740, 0x117ff,
- 0x11850, 0x1189f,
- 0x11900, 0x1199f,
- 0x11ab0, 0x11abf,
- 0x11b00, 0x11bff,
- 0x11cc0, 0x11cff,
- 0x11db0, 0x11edf,
- 0x11f00, 0x11fbf,
- 0x12550, 0x12fff,
- 0x13440, 0x143ff,
- 0x14680, 0x167ff,
- 0x16a70, 0x16acf,
- 0x16b90, 0x16e3f,
- 0x16ea0, 0x16eff,
- 0x16fa0, 0x16fdf,
- 0x18b00, 0x1afff,
- 0x1b300, 0x1bbff,
- 0x1bcb0, 0x1cfff,
- 0x1d250, 0x1d2df,
- 0x1d380, 0x1d3ff,
- 0x1dab0, 0x1dfff,
- 0x1e030, 0x1e0ff,
- 0x1e150, 0x1e2bf,
- 0x1e300, 0x1e7ff,
- 0x1e8e0, 0x1e8ff,
- 0x1e960, 0x1ec6f,
- 0x1ecc0, 0x1ecff,
- 0x1ed50, 0x1edff,
- 0x1ef00, 0x1efff,
- 0x1fb00, 0x1ffff,
- 0x2a6e0, 0x2a6ff,
- 0x2ebf0, 0x2f7ff,
- 0x2fa20, 0xdffff,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xeffff,
-}; /* CR_In_No_Block */
-
-#endif /* USE_UNICODE_PROPERTIES */
-static const OnigCodePoint* const CodeRanges[] = {
- CR_NEWLINE,
- CR_Alpha,
- CR_Blank,
- CR_Cntrl,
- CR_Digit,
- CR_Graph,
- CR_Lower,
- CR_Print,
- CR_XPosixPunct,
- CR_Space,
- CR_Upper,
- CR_XDigit,
- CR_Word,
- CR_Alnum,
- CR_ASCII,
- CR_Punct,
-#ifdef USE_UNICODE_PROPERTIES
- CR_Any,
- CR_Assigned,
- CR_C,
- CR_Cc,
- CR_Cf,
- CR_Cn,
- CR_Co,
- CR_Cs,
- CR_L,
- CR_LC,
- CR_Ll,
- CR_Lm,
- CR_Lo,
- CR_Lt,
- CR_Lu,
- CR_M,
- CR_Mc,
- CR_Me,
- CR_Mn,
- CR_N,
- CR_Nd,
- CR_Nl,
- CR_No,
- CR_P,
- CR_Pc,
- CR_Pd,
- CR_Pe,
- CR_Pf,
- CR_Pi,
- CR_Po,
- CR_Ps,
- CR_S,
- CR_Sc,
- CR_Sk,
- CR_Sm,
- CR_So,
- CR_Z,
- CR_Zl,
- CR_Zp,
- CR_Zs,
- CR_Math,
- CR_Alphabetic,
- CR_Lowercase,
- CR_Uppercase,
- CR_Cased,
- CR_Case_Ignorable,
- CR_Changes_When_Lowercased,
- CR_Changes_When_Uppercased,
- CR_Changes_When_Titlecased,
- CR_Changes_When_Casefolded,
- CR_Changes_When_Casemapped,
- CR_ID_Start,
- CR_ID_Continue,
- CR_XID_Start,
- CR_XID_Continue,
- CR_Default_Ignorable_Code_Point,
- CR_Grapheme_Extend,
- CR_Grapheme_Base,
- CR_Grapheme_Link,
- CR_Common,
- CR_Latin,
- CR_Greek,
- CR_Cyrillic,
- CR_Armenian,
- CR_Hebrew,
- CR_Arabic,
- CR_Syriac,
- CR_Thaana,
- CR_Devanagari,
- CR_Bengali,
- CR_Gurmukhi,
- CR_Gujarati,
- CR_Oriya,
- CR_Tamil,
- CR_Telugu,
- CR_Kannada,
- CR_Malayalam,
- CR_Sinhala,
- CR_Thai,
- CR_Lao,
- CR_Tibetan,
- CR_Myanmar,
- CR_Georgian,
- CR_Hangul,
- CR_Ethiopic,
- CR_Cherokee,
- CR_Canadian_Aboriginal,
- CR_Ogham,
- CR_Runic,
- CR_Khmer,
- CR_Mongolian,
- CR_Hiragana,
- CR_Katakana,
- CR_Bopomofo,
- CR_Han,
- CR_Yi,
- CR_Old_Italic,
- CR_Gothic,
- CR_Deseret,
- CR_Inherited,
- CR_Tagalog,
- CR_Hanunoo,
- CR_Buhid,
- CR_Tagbanwa,
- CR_Limbu,
- CR_Tai_Le,
- CR_Linear_B,
- CR_Ugaritic,
- CR_Shavian,
- CR_Osmanya,
- CR_Cypriot,
- CR_Braille,
- CR_Buginese,
- CR_Coptic,
- CR_New_Tai_Lue,
- CR_Glagolitic,
- CR_Tifinagh,
- CR_Syloti_Nagri,
- CR_Old_Persian,
- CR_Kharoshthi,
- CR_Balinese,
- CR_Cuneiform,
- CR_Phoenician,
- CR_Phags_Pa,
- CR_Nko,
- CR_Sundanese,
- CR_Lepcha,
- CR_Ol_Chiki,
- CR_Vai,
- CR_Saurashtra,
- CR_Kayah_Li,
- CR_Rejang,
- CR_Lycian,
- CR_Carian,
- CR_Lydian,
- CR_Cham,
- CR_Tai_Tham,
- CR_Tai_Viet,
- CR_Avestan,
- CR_Egyptian_Hieroglyphs,
- CR_Samaritan,
- CR_Lisu,
- CR_Bamum,
- CR_Javanese,
- CR_Meetei_Mayek,
- CR_Imperial_Aramaic,
- CR_Old_South_Arabian,
- CR_Inscriptional_Parthian,
- CR_Inscriptional_Pahlavi,
- CR_Old_Turkic,
- CR_Kaithi,
- CR_Batak,
- CR_Brahmi,
- CR_Mandaic,
- CR_Chakma,
- CR_Meroitic_Cursive,
- CR_Meroitic_Hieroglyphs,
- CR_Miao,
- CR_Sharada,
- CR_Sora_Sompeng,
- CR_Takri,
- CR_Caucasian_Albanian,
- CR_Bassa_Vah,
- CR_Duployan,
- CR_Elbasan,
- CR_Grantha,
- CR_Pahawh_Hmong,
- CR_Khojki,
- CR_Linear_A,
- CR_Mahajani,
- CR_Manichaean,
- CR_Mende_Kikakui,
- CR_Modi,
- CR_Mro,
- CR_Old_North_Arabian,
- CR_Nabataean,
- CR_Palmyrene,
- CR_Pau_Cin_Hau,
- CR_Old_Permic,
- CR_Psalter_Pahlavi,
- CR_Siddham,
- CR_Khudawadi,
- CR_Tirhuta,
- CR_Warang_Citi,
- CR_Ahom,
- CR_Anatolian_Hieroglyphs,
- CR_Hatran,
- CR_Multani,
- CR_Old_Hungarian,
- CR_SignWriting,
- CR_Adlam,
- CR_Bhaiksuki,
- CR_Marchen,
- CR_Newa,
- CR_Osage,
- CR_Tangut,
- CR_Masaram_Gondi,
- CR_Nushu,
- CR_Soyombo,
- CR_Zanabazar_Square,
- CR_Dogra,
- CR_Gunjala_Gondi,
- CR_Makasar,
- CR_Medefaidrin,
- CR_Hanifi_Rohingya,
- CR_Sogdian,
- CR_Old_Sogdian,
- CR_Elymaic,
- CR_Nandinagari,
- CR_Nyiakeng_Puachue_Hmong,
- CR_Wancho,
- CR_White_Space,
- CR_Bidi_Control,
- CR_Join_Control,
- CR_Dash,
- CR_Hyphen,
- CR_Quotation_Mark,
- CR_Terminal_Punctuation,
- CR_Other_Math,
- CR_Hex_Digit,
- CR_ASCII_Hex_Digit,
- CR_Other_Alphabetic,
- CR_Ideographic,
- CR_Diacritic,
- CR_Extender,
- CR_Other_Lowercase,
- CR_Other_Uppercase,
- CR_Noncharacter_Code_Point,
- CR_Other_Grapheme_Extend,
- CR_IDS_Binary_Operator,
- CR_IDS_Trinary_Operator,
- CR_Radical,
- CR_Unified_Ideograph,
- CR_Other_Default_Ignorable_Code_Point,
- CR_Deprecated,
- CR_Soft_Dotted,
- CR_Logical_Order_Exception,
- CR_Other_ID_Start,
- CR_Other_ID_Continue,
- CR_Sentence_Terminal,
- CR_Variation_Selector,
- CR_Pattern_White_Space,
- CR_Pattern_Syntax,
- CR_Prepended_Concatenation_Mark,
- CR_Regional_Indicator,
- CR_Emoji,
- CR_Emoji_Presentation,
- CR_Emoji_Modifier,
- CR_Emoji_Modifier_Base,
- CR_Emoji_Component,
- CR_Extended_Pictographic,
- CR_Unknown,
-#ifdef USE_UNICODE_AGE_PROPERTIES
- CR_Age_1_1,
- CR_Age_2_0,
- CR_Age_2_1,
- CR_Age_3_0,
- CR_Age_3_1,
- CR_Age_3_2,
- CR_Age_4_0,
- CR_Age_4_1,
- CR_Age_5_0,
- CR_Age_5_1,
- CR_Age_5_2,
- CR_Age_6_0,
- CR_Age_6_1,
- CR_Age_6_2,
- CR_Age_6_3,
- CR_Age_7_0,
- CR_Age_8_0,
- CR_Age_9_0,
- CR_Age_10_0,
- CR_Age_11_0,
- CR_Age_12_0,
- CR_Age_12_1,
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- CR_Grapheme_Cluster_Break_Prepend,
- CR_Grapheme_Cluster_Break_CR,
- CR_Grapheme_Cluster_Break_LF,
- CR_Grapheme_Cluster_Break_Control,
- CR_Grapheme_Cluster_Break_Extend,
- CR_Grapheme_Cluster_Break_Regional_Indicator,
- CR_Grapheme_Cluster_Break_SpacingMark,
- CR_Grapheme_Cluster_Break_L,
- CR_Grapheme_Cluster_Break_V,
- CR_Grapheme_Cluster_Break_T,
- CR_Grapheme_Cluster_Break_LV,
- CR_Grapheme_Cluster_Break_LVT,
- CR_Grapheme_Cluster_Break_ZWJ,
- CR_In_Basic_Latin,
- CR_In_Latin_1_Supplement,
- CR_In_Latin_Extended_A,
- CR_In_Latin_Extended_B,
- CR_In_IPA_Extensions,
- CR_In_Spacing_Modifier_Letters,
- CR_In_Combining_Diacritical_Marks,
- CR_In_Greek_and_Coptic,
- CR_In_Cyrillic,
- CR_In_Cyrillic_Supplement,
- CR_In_Armenian,
- CR_In_Hebrew,
- CR_In_Arabic,
- CR_In_Syriac,
- CR_In_Arabic_Supplement,
- CR_In_Thaana,
- CR_In_NKo,
- CR_In_Samaritan,
- CR_In_Mandaic,
- CR_In_Syriac_Supplement,
- CR_In_Arabic_Extended_A,
- CR_In_Devanagari,
- CR_In_Bengali,
- CR_In_Gurmukhi,
- CR_In_Gujarati,
- CR_In_Oriya,
- CR_In_Tamil,
- CR_In_Telugu,
- CR_In_Kannada,
- CR_In_Malayalam,
- CR_In_Sinhala,
- CR_In_Thai,
- CR_In_Lao,
- CR_In_Tibetan,
- CR_In_Myanmar,
- CR_In_Georgian,
- CR_In_Hangul_Jamo,
- CR_In_Ethiopic,
- CR_In_Ethiopic_Supplement,
- CR_In_Cherokee,
- CR_In_Unified_Canadian_Aboriginal_Syllabics,
- CR_In_Ogham,
- CR_In_Runic,
- CR_In_Tagalog,
- CR_In_Hanunoo,
- CR_In_Buhid,
- CR_In_Tagbanwa,
- CR_In_Khmer,
- CR_In_Mongolian,
- CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended,
- CR_In_Limbu,
- CR_In_Tai_Le,
- CR_In_New_Tai_Lue,
- CR_In_Khmer_Symbols,
- CR_In_Buginese,
- CR_In_Tai_Tham,
- CR_In_Combining_Diacritical_Marks_Extended,
- CR_In_Balinese,
- CR_In_Sundanese,
- CR_In_Batak,
- CR_In_Lepcha,
- CR_In_Ol_Chiki,
- CR_In_Cyrillic_Extended_C,
- CR_In_Georgian_Extended,
- CR_In_Sundanese_Supplement,
- CR_In_Vedic_Extensions,
- CR_In_Phonetic_Extensions,
- CR_In_Phonetic_Extensions_Supplement,
- CR_In_Combining_Diacritical_Marks_Supplement,
- CR_In_Latin_Extended_Additional,
- CR_In_Greek_Extended,
- CR_In_General_Punctuation,
- CR_In_Superscripts_and_Subscripts,
- CR_In_Currency_Symbols,
- CR_In_Combining_Diacritical_Marks_for_Symbols,
- CR_In_Letterlike_Symbols,
- CR_In_Number_Forms,
- CR_In_Arrows,
- CR_In_Mathematical_Operators,
- CR_In_Miscellaneous_Technical,
- CR_In_Control_Pictures,
- CR_In_Optical_Character_Recognition,
- CR_In_Enclosed_Alphanumerics,
- CR_In_Box_Drawing,
- CR_In_Block_Elements,
- CR_In_Geometric_Shapes,
- CR_In_Miscellaneous_Symbols,
- CR_In_Dingbats,
- CR_In_Miscellaneous_Mathematical_Symbols_A,
- CR_In_Supplemental_Arrows_A,
- CR_In_Braille_Patterns,
- CR_In_Supplemental_Arrows_B,
- CR_In_Miscellaneous_Mathematical_Symbols_B,
- CR_In_Supplemental_Mathematical_Operators,
- CR_In_Miscellaneous_Symbols_and_Arrows,
- CR_In_Glagolitic,
- CR_In_Latin_Extended_C,
- CR_In_Coptic,
- CR_In_Georgian_Supplement,
- CR_In_Tifinagh,
- CR_In_Ethiopic_Extended,
- CR_In_Cyrillic_Extended_A,
- CR_In_Supplemental_Punctuation,
- CR_In_CJK_Radicals_Supplement,
- CR_In_Kangxi_Radicals,
- CR_In_Ideographic_Description_Characters,
- CR_In_CJK_Symbols_and_Punctuation,
- CR_In_Hiragana,
- CR_In_Katakana,
- CR_In_Bopomofo,
- CR_In_Hangul_Compatibility_Jamo,
- CR_In_Kanbun,
- CR_In_Bopomofo_Extended,
- CR_In_CJK_Strokes,
- CR_In_Katakana_Phonetic_Extensions,
- CR_In_Enclosed_CJK_Letters_and_Months,
- CR_In_CJK_Compatibility,
- CR_In_CJK_Unified_Ideographs_Extension_A,
- CR_In_Yijing_Hexagram_Symbols,
- CR_In_CJK_Unified_Ideographs,
- CR_In_Yi_Syllables,
- CR_In_Yi_Radicals,
- CR_In_Lisu,
- CR_In_Vai,
- CR_In_Cyrillic_Extended_B,
- CR_In_Bamum,
- CR_In_Modifier_Tone_Letters,
- CR_In_Latin_Extended_D,
- CR_In_Syloti_Nagri,
- CR_In_Common_Indic_Number_Forms,
- CR_In_Phags_pa,
- CR_In_Saurashtra,
- CR_In_Devanagari_Extended,
- CR_In_Kayah_Li,
- CR_In_Rejang,
- CR_In_Hangul_Jamo_Extended_A,
- CR_In_Javanese,
- CR_In_Myanmar_Extended_B,
- CR_In_Cham,
- CR_In_Myanmar_Extended_A,
- CR_In_Tai_Viet,
- CR_In_Meetei_Mayek_Extensions,
- CR_In_Ethiopic_Extended_A,
- CR_In_Latin_Extended_E,
- CR_In_Cherokee_Supplement,
- CR_In_Meetei_Mayek,
- CR_In_Hangul_Syllables,
- CR_In_Hangul_Jamo_Extended_B,
- CR_In_High_Surrogates,
- CR_In_High_Private_Use_Surrogates,
- CR_In_Low_Surrogates,
- CR_In_Private_Use_Area,
- CR_In_CJK_Compatibility_Ideographs,
- CR_In_Alphabetic_Presentation_Forms,
- CR_In_Arabic_Presentation_Forms_A,
- CR_In_Variation_Selectors,
- CR_In_Vertical_Forms,
- CR_In_Combining_Half_Marks,
- CR_In_CJK_Compatibility_Forms,
- CR_In_Small_Form_Variants,
- CR_In_Arabic_Presentation_Forms_B,
- CR_In_Halfwidth_and_Fullwidth_Forms,
- CR_In_Specials,
- CR_In_Linear_B_Syllabary,
- CR_In_Linear_B_Ideograms,
- CR_In_Aegean_Numbers,
- CR_In_Ancient_Greek_Numbers,
- CR_In_Ancient_Symbols,
- CR_In_Phaistos_Disc,
- CR_In_Lycian,
- CR_In_Carian,
- CR_In_Coptic_Epact_Numbers,
- CR_In_Old_Italic,
- CR_In_Gothic,
- CR_In_Old_Permic,
- CR_In_Ugaritic,
- CR_In_Old_Persian,
- CR_In_Deseret,
- CR_In_Shavian,
- CR_In_Osmanya,
- CR_In_Osage,
- CR_In_Elbasan,
- CR_In_Caucasian_Albanian,
- CR_In_Linear_A,
- CR_In_Cypriot_Syllabary,
- CR_In_Imperial_Aramaic,
- CR_In_Palmyrene,
- CR_In_Nabataean,
- CR_In_Hatran,
- CR_In_Phoenician,
- CR_In_Lydian,
- CR_In_Meroitic_Hieroglyphs,
- CR_In_Meroitic_Cursive,
- CR_In_Kharoshthi,
- CR_In_Old_South_Arabian,
- CR_In_Old_North_Arabian,
- CR_In_Manichaean,
- CR_In_Avestan,
- CR_In_Inscriptional_Parthian,
- CR_In_Inscriptional_Pahlavi,
- CR_In_Psalter_Pahlavi,
- CR_In_Old_Turkic,
- CR_In_Old_Hungarian,
- CR_In_Hanifi_Rohingya,
- CR_In_Rumi_Numeral_Symbols,
- CR_In_Old_Sogdian,
- CR_In_Sogdian,
- CR_In_Elymaic,
- CR_In_Brahmi,
- CR_In_Kaithi,
- CR_In_Sora_Sompeng,
- CR_In_Chakma,
- CR_In_Mahajani,
- CR_In_Sharada,
- CR_In_Sinhala_Archaic_Numbers,
- CR_In_Khojki,
- CR_In_Multani,
- CR_In_Khudawadi,
- CR_In_Grantha,
- CR_In_Newa,
- CR_In_Tirhuta,
- CR_In_Siddham,
- CR_In_Modi,
- CR_In_Mongolian_Supplement,
- CR_In_Takri,
- CR_In_Ahom,
- CR_In_Dogra,
- CR_In_Warang_Citi,
- CR_In_Nandinagari,
- CR_In_Zanabazar_Square,
- CR_In_Soyombo,
- CR_In_Pau_Cin_Hau,
- CR_In_Bhaiksuki,
- CR_In_Marchen,
- CR_In_Masaram_Gondi,
- CR_In_Gunjala_Gondi,
- CR_In_Makasar,
- CR_In_Tamil_Supplement,
- CR_In_Cuneiform,
- CR_In_Cuneiform_Numbers_and_Punctuation,
- CR_In_Early_Dynastic_Cuneiform,
- CR_In_Egyptian_Hieroglyphs,
- CR_In_Egyptian_Hieroglyph_Format_Controls,
- CR_In_Anatolian_Hieroglyphs,
- CR_In_Bamum_Supplement,
- CR_In_Mro,
- CR_In_Bassa_Vah,
- CR_In_Pahawh_Hmong,
- CR_In_Medefaidrin,
- CR_In_Miao,
- CR_In_Ideographic_Symbols_and_Punctuation,
- CR_In_Tangut,
- CR_In_Tangut_Components,
- CR_In_Kana_Supplement,
- CR_In_Kana_Extended_A,
- CR_In_Small_Kana_Extension,
- CR_In_Nushu,
- CR_In_Duployan,
- CR_In_Shorthand_Format_Controls,
- CR_In_Byzantine_Musical_Symbols,
- CR_In_Musical_Symbols,
- CR_In_Ancient_Greek_Musical_Notation,
- CR_In_Mayan_Numerals,
- CR_In_Tai_Xuan_Jing_Symbols,
- CR_In_Counting_Rod_Numerals,
- CR_In_Mathematical_Alphanumeric_Symbols,
- CR_In_Sutton_SignWriting,
- CR_In_Glagolitic_Supplement,
- CR_In_Nyiakeng_Puachue_Hmong,
- CR_In_Wancho,
- CR_In_Mende_Kikakui,
- CR_In_Adlam,
- CR_In_Indic_Siyaq_Numbers,
- CR_In_Ottoman_Siyaq_Numbers,
- CR_In_Arabic_Mathematical_Alphabetic_Symbols,
- CR_In_Mahjong_Tiles,
- CR_In_Domino_Tiles,
- CR_In_Playing_Cards,
- CR_In_Enclosed_Alphanumeric_Supplement,
- CR_In_Enclosed_Ideographic_Supplement,
- CR_In_Miscellaneous_Symbols_and_Pictographs,
- CR_In_Emoticons,
- CR_In_Ornamental_Dingbats,
- CR_In_Transport_and_Map_Symbols,
- CR_In_Alchemical_Symbols,
- CR_In_Geometric_Shapes_Extended,
- CR_In_Supplemental_Arrows_C,
- CR_In_Supplemental_Symbols_and_Pictographs,
- CR_In_Chess_Symbols,
- CR_In_Symbols_and_Pictographs_Extended_A,
- CR_In_CJK_Unified_Ideographs_Extension_B,
- CR_In_CJK_Unified_Ideographs_Extension_C,
- CR_In_CJK_Unified_Ideographs_Extension_D,
- CR_In_CJK_Unified_Ideographs_Extension_E,
- CR_In_CJK_Unified_Ideographs_Extension_F,
- CR_In_CJK_Compatibility_Ideographs_Supplement,
- CR_In_Tags,
- CR_In_Variation_Selectors_Supplement,
- CR_In_Supplementary_Private_Use_Area_A,
- CR_In_Supplementary_Private_Use_Area_B,
- CR_In_No_Block,
-#endif /* USE_UNICODE_PROPERTIES */
-};
-struct uniname2ctype_struct {
- short name;
- unsigned short ctype;
-};
-#define uniname2ctype_offset(str) offsetof(struct uniname2ctype_pool_t, uniname2ctype_pool_##str)
-
-static const struct uniname2ctype_struct *uniname2ctype_p(
-#if !(1+0) /* if ANSI, old style not to conflict with generated prototype */
- const char *, unsigned int
-#endif
-);
-
-#ifndef USE_UNICODE_PROPERTIES
-#define TOTAL_KEYWORDS 15
-#define MIN_WORD_LENGTH 4
-#define MAX_WORD_LENGTH 11
-#define MIN_HASH_VALUE 6
-#define MAX_HASH_VALUE 20
-/* maximum key range = 15, duplicates = 0 */
-#else /* USE_UNICODE_PROPERTIES */
-#ifndef USE_UNICODE_AGE_PROPERTIES
-#define TOTAL_KEYWORDS 814
-#else /* USE_UNICODE_AGE_PROPERTIES */
-#define TOTAL_KEYWORDS 836
-#endif /* USE_UNICODE_AGE_PROPERTIES */
-#define MIN_WORD_LENGTH 1
-#define MAX_WORD_LENGTH 44
-#define MIN_HASH_VALUE 11
-#define MAX_HASH_VALUE 6098
-/* maximum key range = 6088, duplicates = 0 */
-#endif /* USE_UNICODE_PROPERTIES */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-uniname2ctype_hash (register const char *str, register size_t len)
-{
-#ifndef USE_UNICODE_PROPERTIES
- static const unsigned char asso_values[] =
-#else /* USE_UNICODE_PROPERTIES */
- static const unsigned short asso_values[] =
-#endif /* USE_UNICODE_PROPERTIES */
- {
-#ifndef USE_UNICODE_PROPERTIES
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 3, 12, 5,
- 4, 21, 21, 10, 21, 1, 21, 21, 11, 21,
- 2, 1, 1, 21, 1, 7, 4, 6, 21, 1,
- 4, 21, 21, 21, 21, 21, 21, 21
-#else /* USE_UNICODE_PROPERTIES */
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
-#ifndef USE_UNICODE_AGE_PROPERTIES
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
-#else /* USE_UNICODE_AGE_PROPERTIES */
- 6099, 6099, 6099, 6099, 6099, 6099, 17, 6099, 3, 1,
- 4, 13, 3, 22, 9, 16, 12, 5, 6099, 6099,
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 1, 1425, 113,
- 437, 37, 1023, 1071, 1051, 4, 1492, 9, 500, 88,
- 8, 18, 1371, 797, 54, 203, 310, 619, 1608, 603,
- 364, 1438, 20, 1, 3, 6099, 6099, 6099, 6099, 6099
-#endif /* USE_UNICODE_PROPERTIES */
- };
-#ifndef USE_UNICODE_PROPERTIES
- return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]];
-#else /* USE_UNICODE_PROPERTIES */
- register unsigned int hval = (unsigned int)len;
-
- switch (hval)
- {
- default:
- hval += asso_values[(unsigned char)str[15]];
- /*FALLTHROUGH*/
- case 15:
- case 14:
- case 13:
- case 12:
- hval += asso_values[(unsigned char)str[11]];
- /*FALLTHROUGH*/
- case 11:
- case 10:
- case 9:
- case 8:
- case 7:
- case 6:
- hval += asso_values[(unsigned char)str[5]];
- /*FALLTHROUGH*/
- case 5:
- hval += asso_values[(unsigned char)str[4]];
- /*FALLTHROUGH*/
- case 4:
- case 3:
- hval += asso_values[(unsigned char)str[2]];
- /*FALLTHROUGH*/
- case 2:
- hval += asso_values[(unsigned char)str[1]];
- /*FALLTHROUGH*/
- case 1:
- hval += asso_values[(unsigned char)str[0]+2];
- break;
- }
- return hval + asso_values[(unsigned char)str[len - 1]];
-#endif /* USE_UNICODE_PROPERTIES */
-}
-
-struct uniname2ctype_pool_t
- {
-#ifndef USE_UNICODE_PROPERTIES
- char uniname2ctype_pool_str6[sizeof("word")];
- char uniname2ctype_pool_str7[sizeof("print")];
- char uniname2ctype_pool_str8[sizeof("punct")];
- char uniname2ctype_pool_str9[sizeof("alpha")];
- char uniname2ctype_pool_str10[sizeof("alnum")];
- char uniname2ctype_pool_str11[sizeof("xdigit")];
- char uniname2ctype_pool_str12[sizeof("upper")];
- char uniname2ctype_pool_str13[sizeof("ascii")];
- char uniname2ctype_pool_str14[sizeof("cntrl")];
- char uniname2ctype_pool_str15[sizeof("space")];
- char uniname2ctype_pool_str16[sizeof("xposixpunct")];
- char uniname2ctype_pool_str17[sizeof("lower")];
- char uniname2ctype_pool_str18[sizeof("graph")];
- char uniname2ctype_pool_str19[sizeof("digit")];
- char uniname2ctype_pool_str20[sizeof("blank")];
-#else /* USE_UNICODE_PROPERTIES */
- char uniname2ctype_pool_str11[sizeof("yi")];
- char uniname2ctype_pool_str17[sizeof("yiii")];
- char uniname2ctype_pool_str22[sizeof("lana")];
- char uniname2ctype_pool_str24[sizeof("z")];
- char uniname2ctype_pool_str25[sizeof("lina")];
- char uniname2ctype_pool_str33[sizeof("maka")];
- char uniname2ctype_pool_str35[sizeof("mani")];
- char uniname2ctype_pool_str36[sizeof("mn")];
- char uniname2ctype_pool_str45[sizeof("miao")];
- char uniname2ctype_pool_str46[sizeof("lo")];
- char uniname2ctype_pool_str47[sizeof("ci")];
- char uniname2ctype_pool_str48[sizeof("lao")];
- char uniname2ctype_pool_str49[sizeof("laoo")];
- char uniname2ctype_pool_str52[sizeof("inkannada")];
- char uniname2ctype_pool_str55[sizeof("cn")];
- char uniname2ctype_pool_str64[sizeof("pi")];
- char uniname2ctype_pool_str66[sizeof("innko")];
- char uniname2ctype_pool_str67[sizeof("zzzz")];
- char uniname2ctype_pool_str71[sizeof("gran")];
- char uniname2ctype_pool_str75[sizeof("co")];
- char uniname2ctype_pool_str83[sizeof("lineara")];
- char uniname2ctype_pool_str86[sizeof("mark")];
- char uniname2ctype_pool_str92[sizeof("po")];
- char uniname2ctype_pool_str94[sizeof("me")];
- char uniname2ctype_pool_str100[sizeof("cari")];
- char uniname2ctype_pool_str101[sizeof("inkharoshthi")];
- char uniname2ctype_pool_str102[sizeof("kana")];
- char uniname2ctype_pool_str103[sizeof("loe")];
- char uniname2ctype_pool_str107[sizeof("m")];
- char uniname2ctype_pool_str108[sizeof("grek")];
- char uniname2ctype_pool_str111[sizeof("mro")];
- char uniname2ctype_pool_str112[sizeof("mroo")];
- char uniname2ctype_pool_str115[sizeof("carian")];
- char uniname2ctype_pool_str117[sizeof("geor")];
- char uniname2ctype_pool_str118[sizeof("greek")];
- char uniname2ctype_pool_str122[sizeof("gonm")];
- char uniname2ctype_pool_str129[sizeof("mendekikakui")];
- char uniname2ctype_pool_str130[sizeof("pe")];
- char uniname2ctype_pool_str131[sizeof("mero")];
- char uniname2ctype_pool_str134[sizeof("inosmanya")];
- char uniname2ctype_pool_str139[sizeof("cakm")];
- char uniname2ctype_pool_str145[sizeof("inmanichaean")];
- char uniname2ctype_pool_str146[sizeof("inmro")];
- char uniname2ctype_pool_str148[sizeof("inmiao")];
- char uniname2ctype_pool_str149[sizeof("inchakma")];
- char uniname2ctype_pool_str151[sizeof("c")];
- char uniname2ctype_pool_str152[sizeof("mandaic")];
- char uniname2ctype_pool_str153[sizeof("meeteimayek")];
- char uniname2ctype_pool_str161[sizeof("inarmenian")];
- char uniname2ctype_pool_str177[sizeof("inmyanmar")];
- char uniname2ctype_pool_str178[sizeof("inmakasar")];
- char uniname2ctype_pool_str183[sizeof("common")];
- char uniname2ctype_pool_str186[sizeof("lm")];
- char uniname2ctype_pool_str190[sizeof("marc")];
- char uniname2ctype_pool_str203[sizeof("inrunic")];
- char uniname2ctype_pool_str204[sizeof("incarian")];
- char uniname2ctype_pool_str210[sizeof("inideographicsymbolsandpunctuation")];
- char uniname2ctype_pool_str212[sizeof("inkhmer")];
- char uniname2ctype_pool_str213[sizeof("qaai")];
- char uniname2ctype_pool_str218[sizeof("inahom")];
- char uniname2ctype_pool_str226[sizeof("merc")];
- char uniname2ctype_pool_str231[sizeof("combiningmark")];
- char uniname2ctype_pool_str236[sizeof("lc")];
- char uniname2ctype_pool_str237[sizeof("perm")];
- char uniname2ctype_pool_str246[sizeof("mc")];
- char uniname2ctype_pool_str250[sizeof("connectorpunctuation")];
- char uniname2ctype_pool_str253[sizeof("cans")];
- char uniname2ctype_pool_str260[sizeof("incuneiformnumbersandpunctuation")];
- char uniname2ctype_pool_str263[sizeof("armi")];
- char uniname2ctype_pool_str265[sizeof("cc")];
- char uniname2ctype_pool_str267[sizeof("armn")];
- char uniname2ctype_pool_str268[sizeof("incherokee")];
- char uniname2ctype_pool_str270[sizeof("prependedconcatenationmark")];
- char uniname2ctype_pool_str274[sizeof("incuneiform")];
- char uniname2ctype_pool_str275[sizeof("inavestan")];
- char uniname2ctype_pool_str281[sizeof("inipaextensions")];
- char uniname2ctype_pool_str282[sizeof("pc")];
- char uniname2ctype_pool_str283[sizeof("armenian")];
- char uniname2ctype_pool_str285[sizeof("insharada")];
- char uniname2ctype_pool_str289[sizeof("inmarchen")];
- char uniname2ctype_pool_str293[sizeof("makasar")];
- char uniname2ctype_pool_str297[sizeof("masaramgondi")];
- char uniname2ctype_pool_str301[sizeof("inarrows")];
- char uniname2ctype_pool_str311[sizeof("incyrillic")];
- char uniname2ctype_pool_str313[sizeof("incham")];
- char uniname2ctype_pool_str315[sizeof("qmark")];
- char uniname2ctype_pool_str320[sizeof("ri")];
- char uniname2ctype_pool_str322[sizeof("qaac")];
- char uniname2ctype_pool_str328[sizeof("insamaritan")];
- char uniname2ctype_pool_str331[sizeof("latn")];
- char uniname2ctype_pool_str335[sizeof("inmasaramgondi")];
- char uniname2ctype_pool_str338[sizeof("inthaana")];
- char uniname2ctype_pool_str340[sizeof("latin")];
- char uniname2ctype_pool_str342[sizeof("inthai")];
- char uniname2ctype_pool_str345[sizeof("lineseparator")];
- char uniname2ctype_pool_str346[sizeof("pcm")];
- char uniname2ctype_pool_str348[sizeof("inkatakana")];
- char uniname2ctype_pool_str352[sizeof("inkaithi")];
- char uniname2ctype_pool_str357[sizeof("inzanabazarsquare")];
- char uniname2ctype_pool_str362[sizeof("inscriptionalparthian")];
- char uniname2ctype_pool_str366[sizeof("initialpunctuation")];
- char uniname2ctype_pool_str373[sizeof("mtei")];
- char uniname2ctype_pool_str376[sizeof("vai")];
- char uniname2ctype_pool_str377[sizeof("vaii")];
- char uniname2ctype_pool_str386[sizeof("inkhmersymbols")];
- char uniname2ctype_pool_str399[sizeof("insyriac")];
- char uniname2ctype_pool_str401[sizeof("intakri")];
- char uniname2ctype_pool_str404[sizeof("arabic")];
- char uniname2ctype_pool_str411[sizeof("zs")];
- char uniname2ctype_pool_str418[sizeof("katakana")];
- char uniname2ctype_pool_str426[sizeof("prti")];
- char uniname2ctype_pool_str442[sizeof("ascii")];
- char uniname2ctype_pool_str445[sizeof("cs")];
- char uniname2ctype_pool_str462[sizeof("ps")];
- char uniname2ctype_pool_str468[sizeof("mand")];
- char uniname2ctype_pool_str470[sizeof("privateuse")];
- char uniname2ctype_pool_str475[sizeof("inruminumeralsymbols")];
- char uniname2ctype_pool_str480[sizeof("inmyanmarextendeda")];
- char uniname2ctype_pool_str481[sizeof("modi")];
- char uniname2ctype_pool_str486[sizeof("incjkcompatibilityforms")];
- char uniname2ctype_pool_str488[sizeof("inkanaextendeda")];
- char uniname2ctype_pool_str491[sizeof("incjkcompatibilityideographs")];
- char uniname2ctype_pool_str500[sizeof("brai")];
- char uniname2ctype_pool_str504[sizeof("mend")];
- char uniname2ctype_pool_str505[sizeof("ideo")];
- char uniname2ctype_pool_str506[sizeof("letter")];
- char uniname2ctype_pool_str509[sizeof("l")];
- char uniname2ctype_pool_str511[sizeof("inmeeteimayek")];
- char uniname2ctype_pool_str520[sizeof("inideographicdescriptioncharacters")];
- char uniname2ctype_pool_str535[sizeof("xidcontinue")];
- char uniname2ctype_pool_str538[sizeof("knda")];
- char uniname2ctype_pool_str541[sizeof("innandinagari")];
- char uniname2ctype_pool_str543[sizeof("kannada")];
- char uniname2ctype_pool_str556[sizeof("inmodi")];
- char uniname2ctype_pool_str558[sizeof("inlao")];
- char uniname2ctype_pool_str560[sizeof("inoldnortharabian")];
- char uniname2ctype_pool_str565[sizeof("intransportandmapsymbols")];
- char uniname2ctype_pool_str566[sizeof("letternumber")];
- char uniname2ctype_pool_str568[sizeof("gothic")];
- char uniname2ctype_pool_str572[sizeof("inlineara")];
- char uniname2ctype_pool_str577[sizeof("inmendekikakui")];
- char uniname2ctype_pool_str578[sizeof("xidc")];
- char uniname2ctype_pool_str579[sizeof("mongolian")];
- char uniname2ctype_pool_str582[sizeof("inmiscellaneousmathematicalsymbolsa")];
- char uniname2ctype_pool_str583[sizeof("inspecials")];
- char uniname2ctype_pool_str590[sizeof("grlink")];
- char uniname2ctype_pool_str594[sizeof("brahmi")];
- char uniname2ctype_pool_str596[sizeof("inemoticons")];
- char uniname2ctype_pool_str597[sizeof("kali")];
- char uniname2ctype_pool_str600[sizeof("inolditalic")];
- char uniname2ctype_pool_str604[sizeof("inmedefaidrin")];
- char uniname2ctype_pool_str605[sizeof("inchesssymbols")];
- char uniname2ctype_pool_str608[sizeof("incjkcompatibilityideographssupplement")];
- char uniname2ctype_pool_str614[sizeof("inadlam")];
- char uniname2ctype_pool_str624[sizeof("psalterpahlavi")];
- char uniname2ctype_pool_str625[sizeof("incommonindicnumberforms")];
- char uniname2ctype_pool_str630[sizeof("lt")];
- char uniname2ctype_pool_str636[sizeof("innewa")];
- char uniname2ctype_pool_str639[sizeof("sk")];
- char uniname2ctype_pool_str642[sizeof("control")];
- char uniname2ctype_pool_str645[sizeof("inancientsymbols")];
- char uniname2ctype_pool_str647[sizeof("palm")];
- char uniname2ctype_pool_str650[sizeof("inlycian")];
- char uniname2ctype_pool_str657[sizeof("so")];
- char uniname2ctype_pool_str660[sizeof("patternwhitespace")];
- char uniname2ctype_pool_str668[sizeof("xids")];
- char uniname2ctype_pool_str672[sizeof("inmandaic")];
- char uniname2ctype_pool_str675[sizeof("idc")];
- char uniname2ctype_pool_str678[sizeof("meroiticcursive")];
- char uniname2ctype_pool_str695[sizeof("inwarangciti")];
- char uniname2ctype_pool_str696[sizeof("sora")];
- char uniname2ctype_pool_str697[sizeof("inopticalcharacterrecognition")];
- char uniname2ctype_pool_str703[sizeof("inoldsogdian")];
- char uniname2ctype_pool_str705[sizeof("inmalayalam")];
- char uniname2ctype_pool_str707[sizeof("bamum")];
- char uniname2ctype_pool_str708[sizeof("inkanasupplement")];
- char uniname2ctype_pool_str713[sizeof("insundanese")];
- char uniname2ctype_pool_str720[sizeof("grext")];
- char uniname2ctype_pool_str737[sizeof("print")];
- char uniname2ctype_pool_str738[sizeof("intaitham")];
- char uniname2ctype_pool_str742[sizeof("lower")];
- char uniname2ctype_pool_str753[sizeof("joinc")];
- char uniname2ctype_pool_str755[sizeof("inoldsoutharabian")];
- char uniname2ctype_pool_str760[sizeof("incjkstrokes")];
- char uniname2ctype_pool_str761[sizeof("batk")];
- char uniname2ctype_pool_str766[sizeof("samr")];
- char uniname2ctype_pool_str767[sizeof("inwancho")];
- char uniname2ctype_pool_str771[sizeof("batak")];
- char uniname2ctype_pool_str772[sizeof("vs")];
- char uniname2ctype_pool_str776[sizeof("patws")];
- char uniname2ctype_pool_str783[sizeof("samaritan")];
- char uniname2ctype_pool_str787[sizeof("idsbinaryoperator")];
- char uniname2ctype_pool_str791[sizeof("pauc")];
- char uniname2ctype_pool_str794[sizeof("insmallkanaextension")];
- char uniname2ctype_pool_str797[sizeof("sm")];
- char uniname2ctype_pool_str799[sizeof("indominotiles")];
- char uniname2ctype_pool_str802[sizeof("alnum")];
- char uniname2ctype_pool_str809[sizeof("insylotinagri")];
- char uniname2ctype_pool_str814[sizeof("inugaritic")];
- char uniname2ctype_pool_str818[sizeof("incontrolpictures")];
- char uniname2ctype_pool_str821[sizeof("inlinearbideograms")];
- char uniname2ctype_pool_str822[sizeof("inmusicalsymbols")];
- char uniname2ctype_pool_str823[sizeof("s")];
- char uniname2ctype_pool_str824[sizeof("ital")];
- char uniname2ctype_pool_str825[sizeof("inmodifiertoneletters")];
- char uniname2ctype_pool_str828[sizeof("inancientgreekmusicalnotation")];
- char uniname2ctype_pool_str834[sizeof("patternsyntax")];
- char uniname2ctype_pool_str838[sizeof("lisu")];
- char uniname2ctype_pool_str842[sizeof("lowercase")];
- char uniname2ctype_pool_str845[sizeof("cwcm")];
- char uniname2ctype_pool_str847[sizeof("sc")];
- char uniname2ctype_pool_str848[sizeof("bass")];
- char uniname2ctype_pool_str855[sizeof("ids")];
- char uniname2ctype_pool_str857[sizeof("inlatinextendeda")];
- char uniname2ctype_pool_str862[sizeof("oriya")];
- char uniname2ctype_pool_str875[sizeof("intaile")];
- char uniname2ctype_pool_str886[sizeof("inmiscellaneoussymbols")];
- char uniname2ctype_pool_str895[sizeof("inmiscellaneoussymbolsandarrows")];
- char uniname2ctype_pool_str898[sizeof("incaucasianalbanian")];
- char uniname2ctype_pool_str900[sizeof("inmiscellaneoussymbolsandpictographs")];
- char uniname2ctype_pool_str906[sizeof("inoldturkic")];
- char uniname2ctype_pool_str907[sizeof("insaurashtra")];
- char uniname2ctype_pool_str924[sizeof("idcontinue")];
- char uniname2ctype_pool_str926[sizeof("intamil")];
- char uniname2ctype_pool_str928[sizeof("inmultani")];
- char uniname2ctype_pool_str929[sizeof("inlatinextendede")];
- char uniname2ctype_pool_str930[sizeof("pd")];
- char uniname2ctype_pool_str946[sizeof("bali")];
- char uniname2ctype_pool_str961[sizeof("blank")];
- char uniname2ctype_pool_str963[sizeof("idst")];
- char uniname2ctype_pool_str974[sizeof("inlydian")];
- char uniname2ctype_pool_str986[sizeof("innewtailue")];
- char uniname2ctype_pool_str994[sizeof("bengali")];
- char uniname2ctype_pool_str995[sizeof("runr")];
- char uniname2ctype_pool_str1005[sizeof("zl")];
- char uniname2ctype_pool_str1009[sizeof("incyrillicextendeda")];
- char uniname2ctype_pool_str1010[sizeof("ll")];
- char uniname2ctype_pool_str1013[sizeof("indeseret")];
- char uniname2ctype_pool_str1014[sizeof("intaixuanjingsymbols")];
- char uniname2ctype_pool_str1015[sizeof("inancientgreeknumbers")];
- char uniname2ctype_pool_str1021[sizeof("idstart")];
- char uniname2ctype_pool_str1025[sizeof("inmeeteimayekextensions")];
- char uniname2ctype_pool_str1028[sizeof("balinese")];
- char uniname2ctype_pool_str1032[sizeof("dia")];
- char uniname2ctype_pool_str1033[sizeof("di")];
- char uniname2ctype_pool_str1035[sizeof("inspacingmodifierletters")];
- char uniname2ctype_pool_str1036[sizeof("inearlydynasticcuneiform")];
- char uniname2ctype_pool_str1049[sizeof("plrd")];
- char uniname2ctype_pool_str1067[sizeof("canadianaboriginal")];
- char uniname2ctype_pool_str1070[sizeof("zinh")];
- char uniname2ctype_pool_str1072[sizeof("sind")];
- char uniname2ctype_pool_str1080[sizeof("osage")];
- char uniname2ctype_pool_str1081[sizeof("inlatinextendedc")];
- char uniname2ctype_pool_str1085[sizeof("uideo")];
- char uniname2ctype_pool_str1087[sizeof("incountingrodnumerals")];
- char uniname2ctype_pool_str1090[sizeof("xidstart")];
- char uniname2ctype_pool_str1091[sizeof("xdigit")];
- char uniname2ctype_pool_str1093[sizeof("osma")];
- char uniname2ctype_pool_str1097[sizeof("inkhudawadi")];
- char uniname2ctype_pool_str1102[sizeof("inhanifirohingya")];
- char uniname2ctype_pool_str1105[sizeof("gong")];
- char uniname2ctype_pool_str1107[sizeof("ingrantha")];
- char uniname2ctype_pool_str1109[sizeof("bidic")];
- char uniname2ctype_pool_str1119[sizeof("mong")];
- char uniname2ctype_pool_str1120[sizeof("cased")];
- char uniname2ctype_pool_str1121[sizeof("incyrillicextendedc")];
- char uniname2ctype_pool_str1134[sizeof("inhiragana")];
- char uniname2ctype_pool_str1140[sizeof("sinhala")];
- char uniname2ctype_pool_str1142[sizeof("adlm")];
- char uniname2ctype_pool_str1146[sizeof("glagolitic")];
- char uniname2ctype_pool_str1147[sizeof("sterm")];
- char uniname2ctype_pool_str1149[sizeof("bamu")];
- char uniname2ctype_pool_str1150[sizeof("georgian")];
- char uniname2ctype_pool_str1151[sizeof("inosage")];
- char uniname2ctype_pool_str1152[sizeof("gunjalagondi")];
- char uniname2ctype_pool_str1153[sizeof("phoenician")];
- char uniname2ctype_pool_str1157[sizeof("multani")];
- char uniname2ctype_pool_str1158[sizeof("kaithi")];
- char uniname2ctype_pool_str1164[sizeof("joincontrol")];
- char uniname2ctype_pool_str1168[sizeof("runic")];
- char uniname2ctype_pool_str1170[sizeof("ingeneralpunctuation")];
- char uniname2ctype_pool_str1171[sizeof("inmahajani")];
- char uniname2ctype_pool_str1174[sizeof("incyrillicsupplement")];
- char uniname2ctype_pool_str1175[sizeof("lowercaseletter")];
- char uniname2ctype_pool_str1176[sizeof("marchen")];
- char uniname2ctype_pool_str1177[sizeof("graphemelink")];
- char uniname2ctype_pool_str1178[sizeof("ingeorgian")];
- char uniname2ctype_pool_str1180[sizeof("khojki")];
- char uniname2ctype_pool_str1181[sizeof("cham")];
- char uniname2ctype_pool_str1182[sizeof("inogham")];
- char uniname2ctype_pool_str1183[sizeof("cher")];
- char uniname2ctype_pool_str1185[sizeof("chakma")];
- char uniname2ctype_pool_str1190[sizeof("emoji")];
- char uniname2ctype_pool_str1191[sizeof("insiddham")];
- char uniname2ctype_pool_str1197[sizeof("cherokee")];
- char uniname2ctype_pool_str1198[sizeof("khar")];
- char uniname2ctype_pool_str1203[sizeof("inmongolian")];
- char uniname2ctype_pool_str1207[sizeof("incherokeesupplement")];
- char uniname2ctype_pool_str1208[sizeof("diacritic")];
- char uniname2ctype_pool_str1209[sizeof("manichaean")];
- char uniname2ctype_pool_str1210[sizeof("xsux")];
- char uniname2ctype_pool_str1212[sizeof("inolchiki")];
- char uniname2ctype_pool_str1227[sizeof("quotationmark")];
- char uniname2ctype_pool_str1231[sizeof("adlam")];
- char uniname2ctype_pool_str1232[sizeof("inethiopic")];
- char uniname2ctype_pool_str1233[sizeof("graphemebase")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1234[sizeof("age=11.0")];
- char uniname2ctype_pool_str1235[sizeof("age=12.1")];
- char uniname2ctype_pool_str1236[sizeof("age=10.0")];
- char uniname2ctype_pool_str1237[sizeof("age=12.0")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1243[sizeof("casedletter")];
- char uniname2ctype_pool_str1244[sizeof("ingurmukhi")];
- char uniname2ctype_pool_str1245[sizeof("odi")];
- char uniname2ctype_pool_str1246[sizeof("incjkunifiedideographsextensiona")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1247[sizeof("age=1.1")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1248[sizeof("lu")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1249[sizeof("age=4.1")];
- char uniname2ctype_pool_str1250[sizeof("age=2.1")];
- char uniname2ctype_pool_str1251[sizeof("age=4.0")];
- char uniname2ctype_pool_str1252[sizeof("age=2.0")];
- char uniname2ctype_pool_str1253[sizeof("age=9.0")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1254[sizeof("intamilsupplement")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1255[sizeof("age=6.1")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1256[sizeof("unknown")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1257[sizeof("age=6.0")];
- char uniname2ctype_pool_str1258[sizeof("age=6.2")];
- char uniname2ctype_pool_str1259[sizeof("age=3.1")];
- char uniname2ctype_pool_str1260[sizeof("age=8.0")];
- char uniname2ctype_pool_str1261[sizeof("age=3.0")];
- char uniname2ctype_pool_str1262[sizeof("age=3.2")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1263[sizeof("cwt")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1264[sizeof("age=7.0")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1266[sizeof("unassigned")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1267[sizeof("age=6.3")];
- char uniname2ctype_pool_str1268[sizeof("age=5.1")];
- char uniname2ctype_pool_str1270[sizeof("age=5.0")];
- char uniname2ctype_pool_str1271[sizeof("age=5.2")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1274[sizeof("ahom")];
- char uniname2ctype_pool_str1282[sizeof("incjkunifiedideographsextensione")];
- char uniname2ctype_pool_str1285[sizeof("khmr")];
- char uniname2ctype_pool_str1289[sizeof("insinhala")];
- char uniname2ctype_pool_str1292[sizeof("inmiscellaneoustechnical")];
- char uniname2ctype_pool_str1297[sizeof("saur")];
- char uniname2ctype_pool_str1300[sizeof("guru")];
- char uniname2ctype_pool_str1301[sizeof("sundanese")];
- char uniname2ctype_pool_str1306[sizeof("punct")];
- char uniname2ctype_pool_str1314[sizeof("paucinhau")];
- char uniname2ctype_pool_str1317[sizeof("gurmukhi")];
- char uniname2ctype_pool_str1319[sizeof("variationselector")];
- char uniname2ctype_pool_str1331[sizeof("logicalorderexception")];
- char uniname2ctype_pool_str1340[sizeof("khmer")];
- char uniname2ctype_pool_str1343[sizeof("limbu")];
- char uniname2ctype_pool_str1354[sizeof("inscriptionalpahlavi")];
- char uniname2ctype_pool_str1355[sizeof("oidc")];
- char uniname2ctype_pool_str1358[sizeof("incjkunifiedideographsextensionc")];
- char uniname2ctype_pool_str1360[sizeof("cntrl")];
- char uniname2ctype_pool_str1365[sizeof("inlatinextendedadditional")];
- char uniname2ctype_pool_str1366[sizeof("decimalnumber")];
- char uniname2ctype_pool_str1367[sizeof("insorasompeng")];
- char uniname2ctype_pool_str1369[sizeof("radical")];
- char uniname2ctype_pool_str1373[sizeof("emojimodifier")];
- char uniname2ctype_pool_str1375[sizeof("kharoshthi")];
- char uniname2ctype_pool_str1380[sizeof("n")];
- char uniname2ctype_pool_str1384[sizeof("math")];
- char uniname2ctype_pool_str1387[sizeof("goth")];
- char uniname2ctype_pool_str1400[sizeof("anatolianhieroglyphs")];
- char uniname2ctype_pool_str1401[sizeof("inenclosedalphanumerics")];
- char uniname2ctype_pool_str1407[sizeof("nandinagari")];
- char uniname2ctype_pool_str1409[sizeof("no")];
- char uniname2ctype_pool_str1419[sizeof("nko")];
- char uniname2ctype_pool_str1420[sizeof("nkoo")];
- char uniname2ctype_pool_str1422[sizeof("ingreekandcoptic")];
- char uniname2ctype_pool_str1423[sizeof("olck")];
- char uniname2ctype_pool_str1426[sizeof("p")];
- char uniname2ctype_pool_str1428[sizeof("grantha")];
- char uniname2ctype_pool_str1434[sizeof("olchiki")];
- char uniname2ctype_pool_str1438[sizeof("incjkunifiedideographs")];
- char uniname2ctype_pool_str1441[sizeof("zanb")];
- char uniname2ctype_pool_str1442[sizeof("intirhuta")];
- char uniname2ctype_pool_str1445[sizeof("oids")];
- char uniname2ctype_pool_str1448[sizeof("inhatran")];
- char uniname2ctype_pool_str1449[sizeof("linb")];
- char uniname2ctype_pool_str1450[sizeof("xpeo")];
- char uniname2ctype_pool_str1451[sizeof("mult")];
- char uniname2ctype_pool_str1454[sizeof("saurashtra")];
- char uniname2ctype_pool_str1457[sizeof("kthi")];
- char uniname2ctype_pool_str1462[sizeof("inbhaiksuki")];
- char uniname2ctype_pool_str1466[sizeof("olower")];
- char uniname2ctype_pool_str1470[sizeof("innabataean")];
- char uniname2ctype_pool_str1471[sizeof("inphoenician")];
- char uniname2ctype_pool_str1475[sizeof("inkanbun")];
- char uniname2ctype_pool_str1476[sizeof("inmeroitichieroglyphs")];
- char uniname2ctype_pool_str1478[sizeof("inkayahli")];
- char uniname2ctype_pool_str1481[sizeof("phnx")];
- char uniname2ctype_pool_str1485[sizeof("inoriya")];
- char uniname2ctype_pool_str1489[sizeof("enclosingmark")];
- char uniname2ctype_pool_str1495[sizeof("sd")];
- char uniname2ctype_pool_str1497[sizeof("inelbasan")];
- char uniname2ctype_pool_str1498[sizeof("wara")];
- char uniname2ctype_pool_str1499[sizeof("inenclosedideographicsupplement")];
- char uniname2ctype_pool_str1501[sizeof("sidd")];
- char uniname2ctype_pool_str1507[sizeof("linearb")];
- char uniname2ctype_pool_str1509[sizeof("hani")];
- char uniname2ctype_pool_str1512[sizeof("han")];
- char uniname2ctype_pool_str1517[sizeof("inenclosedalphanumericsupplement")];
- char uniname2ctype_pool_str1519[sizeof("medf")];
- char uniname2ctype_pool_str1520[sizeof("bidicontrol")];
- char uniname2ctype_pool_str1523[sizeof("hano")];
- char uniname2ctype_pool_str1524[sizeof("inphaistosdisc")];
- char uniname2ctype_pool_str1529[sizeof("limb")];
- char uniname2ctype_pool_str1531[sizeof("inkangxiradicals")];
- char uniname2ctype_pool_str1533[sizeof("lepc")];
- char uniname2ctype_pool_str1535[sizeof("medefaidrin")];
- char uniname2ctype_pool_str1536[sizeof("braille")];
- char uniname2ctype_pool_str1537[sizeof("regionalindicator")];
- char uniname2ctype_pool_str1542[sizeof("inlowsurrogates")];
- char uniname2ctype_pool_str1544[sizeof("inshorthandformatcontrols")];
- char uniname2ctype_pool_str1547[sizeof("brah")];
- char uniname2ctype_pool_str1548[sizeof("inkhojki")];
- char uniname2ctype_pool_str1549[sizeof("inoldhungarian")];
- char uniname2ctype_pool_str1552[sizeof("hanunoo")];
- char uniname2ctype_pool_str1555[sizeof("hira")];
- char uniname2ctype_pool_str1557[sizeof("beng")];
- char uniname2ctype_pool_str1563[sizeof("emojimodifierbase")];
- char uniname2ctype_pool_str1565[sizeof("inarabic")];
- char uniname2ctype_pool_str1567[sizeof("lyci")];
- char uniname2ctype_pool_str1569[sizeof("ahex")];
- char uniname2ctype_pool_str1572[sizeof("inherited")];
- char uniname2ctype_pool_str1580[sizeof("glag")];
- char uniname2ctype_pool_str1582[sizeof("lycian")];
- char uniname2ctype_pool_str1587[sizeof("indogra")];
- char uniname2ctype_pool_str1594[sizeof("dsrt")];
- char uniname2ctype_pool_str1597[sizeof("arab")];
- char uniname2ctype_pool_str1602[sizeof("mymr")];
- char uniname2ctype_pool_str1607[sizeof("myanmar")];
- char uniname2ctype_pool_str1613[sizeof("phli")];
- char uniname2ctype_pool_str1617[sizeof("inimperialaramaic")];
- char uniname2ctype_pool_str1622[sizeof("ingreekextended")];
- char uniname2ctype_pool_str1623[sizeof("inanatolianhieroglyphs")];
- char uniname2ctype_pool_str1629[sizeof("punctuation")];
- char uniname2ctype_pool_str1631[sizeof("takri")];
- char uniname2ctype_pool_str1635[sizeof("graphemeextend")];
- char uniname2ctype_pool_str1638[sizeof("invai")];
- char uniname2ctype_pool_str1643[sizeof("cwl")];
- char uniname2ctype_pool_str1654[sizeof("ingeometricshapes")];
- char uniname2ctype_pool_str1655[sizeof("emojicomponent")];
- char uniname2ctype_pool_str1662[sizeof("coptic")];
- char uniname2ctype_pool_str1671[sizeof("deseret")];
- char uniname2ctype_pool_str1675[sizeof("inarabicpresentationformsa")];
- char uniname2ctype_pool_str1676[sizeof("takr")];
- char uniname2ctype_pool_str1677[sizeof("inbasiclatin")];
- char uniname2ctype_pool_str1682[sizeof("incjkunifiedideographsextensiond")];
- char uniname2ctype_pool_str1686[sizeof("sinh")];
- char uniname2ctype_pool_str1687[sizeof("sund")];
- char uniname2ctype_pool_str1691[sizeof("shavian")];
- char uniname2ctype_pool_str1692[sizeof("taile")];
- char uniname2ctype_pool_str1699[sizeof("insundanesesupplement")];
- char uniname2ctype_pool_str1702[sizeof("inelymaic")];
- char uniname2ctype_pool_str1703[sizeof("insoyombo")];
- char uniname2ctype_pool_str1704[sizeof("bhks")];
- char uniname2ctype_pool_str1714[sizeof("bhaiksuki")];
- char uniname2ctype_pool_str1716[sizeof("incjkcompatibility")];
- char uniname2ctype_pool_str1722[sizeof("inhanunoo")];
- char uniname2ctype_pool_str1724[sizeof("intangut")];
- char uniname2ctype_pool_str1728[sizeof("sogdian")];
- char uniname2ctype_pool_str1729[sizeof("inlatinextendedd")];
- char uniname2ctype_pool_str1730[sizeof("sogo")];
- char uniname2ctype_pool_str1731[sizeof("insinhalaarchaicnumbers")];
- char uniname2ctype_pool_str1732[sizeof("ideographic")];
- char uniname2ctype_pool_str1733[sizeof("ugar")];
- char uniname2ctype_pool_str1740[sizeof("copt")];
- char uniname2ctype_pool_str1742[sizeof("imperialaramaic")];
- char uniname2ctype_pool_str1745[sizeof("insogdian")];
- char uniname2ctype_pool_str1746[sizeof("indingbats")];
- char uniname2ctype_pool_str1750[sizeof("format")];
- char uniname2ctype_pool_str1752[sizeof("ininscriptionalpahlavi")];
- char uniname2ctype_pool_str1757[sizeof("ininscriptionalparthian")];
- char uniname2ctype_pool_str1766[sizeof("grbase")];
- char uniname2ctype_pool_str1769[sizeof("inbatak")];
- char uniname2ctype_pool_str1776[sizeof("cprt")];
- char uniname2ctype_pool_str1780[sizeof("cwcf")];
- char uniname2ctype_pool_str1788[sizeof("cuneiform")];
- char uniname2ctype_pool_str1791[sizeof("term")];
- char uniname2ctype_pool_str1806[sizeof("intibetan")];
- char uniname2ctype_pool_str1810[sizeof("intags")];
- char uniname2ctype_pool_str1811[sizeof("asciihexdigit")];
- char uniname2ctype_pool_str1813[sizeof("sentenceterminal")];
- char uniname2ctype_pool_str1816[sizeof("inmayannumerals")];
- char uniname2ctype_pool_str1821[sizeof("nand")];
- char uniname2ctype_pool_str1825[sizeof("patsyn")];
- char uniname2ctype_pool_str1826[sizeof("hatran")];
- char uniname2ctype_pool_str1828[sizeof("inblockelements")];
- char uniname2ctype_pool_str1838[sizeof("inornamentaldingbats")];
- char uniname2ctype_pool_str1842[sizeof("innumberforms")];
- char uniname2ctype_pool_str1843[sizeof("oldpersian")];
- char uniname2ctype_pool_str1846[sizeof("inshavian")];
- char uniname2ctype_pool_str1848[sizeof("bopo")];
- char uniname2ctype_pool_str1861[sizeof("hatr")];
- char uniname2ctype_pool_str1866[sizeof("caseignorable")];
- char uniname2ctype_pool_str1871[sizeof("inoldpersian")];
- char uniname2ctype_pool_str1878[sizeof("modifierletter")];
- char uniname2ctype_pool_str1881[sizeof("cwu")];
- char uniname2ctype_pool_str1891[sizeof("lydi")];
- char uniname2ctype_pool_str1892[sizeof("inbyzantinemusicalsymbols")];
- char uniname2ctype_pool_str1896[sizeof("ingeometricshapesextended")];
- char uniname2ctype_pool_str1904[sizeof("inmyanmarextendedb")];
- char uniname2ctype_pool_str1905[sizeof("innushu")];
- char uniname2ctype_pool_str1906[sizeof("lydian")];
- char uniname2ctype_pool_str1911[sizeof("inunifiedcanadianaboriginalsyllabics")];
- char uniname2ctype_pool_str1915[sizeof("orkh")];
- char uniname2ctype_pool_str1928[sizeof("inyiradicals")];
- char uniname2ctype_pool_str1929[sizeof("inkatakanaphoneticextensions")];
- char uniname2ctype_pool_str1930[sizeof("inethiopicextendeda")];
- char uniname2ctype_pool_str1932[sizeof("incoptic")];
- char uniname2ctype_pool_str1936[sizeof("inarabicextendeda")];
- char uniname2ctype_pool_str1947[sizeof("oldpermic")];
- char uniname2ctype_pool_str1950[sizeof("incjksymbolsandpunctuation")];
- char uniname2ctype_pool_str1951[sizeof("word")];
- char uniname2ctype_pool_str1958[sizeof("bopomofo")];
- char uniname2ctype_pool_str1961[sizeof("ogam")];
- char uniname2ctype_pool_str1964[sizeof("inlisu")];
- char uniname2ctype_pool_str1967[sizeof("inoldpermic")];
- char uniname2ctype_pool_str1968[sizeof("innoblock")];
- char uniname2ctype_pool_str1971[sizeof("taiviet")];
- char uniname2ctype_pool_str1985[sizeof("inbraillepatterns")];
- char uniname2ctype_pool_str1991[sizeof("alpha")];
- char uniname2ctype_pool_str1993[sizeof("inbalinese")];
- char uniname2ctype_pool_str1994[sizeof("sorasompeng")];
- char uniname2ctype_pool_str1996[sizeof("closepunctuation")];
- char uniname2ctype_pool_str2006[sizeof("inmiscellaneousmathematicalsymbolsb")];
- char uniname2ctype_pool_str2010[sizeof("inlepcha")];
- char uniname2ctype_pool_str2014[sizeof("insyriacsupplement")];
- char uniname2ctype_pool_str2016[sizeof("newa")];
- char uniname2ctype_pool_str2023[sizeof("spacingmark")];
- char uniname2ctype_pool_str2024[sizeof("inpalmyrene")];
- char uniname2ctype_pool_str2033[sizeof("cyrl")];
- char uniname2ctype_pool_str2043[sizeof("assigned")];
- char uniname2ctype_pool_str2048[sizeof("mlym")];
- char uniname2ctype_pool_str2055[sizeof("malayalam")];
- char uniname2ctype_pool_str2058[sizeof("ext")];
- char uniname2ctype_pool_str2062[sizeof("newtailue")];
- char uniname2ctype_pool_str2070[sizeof("space")];
- char uniname2ctype_pool_str2073[sizeof("intelugu")];
- char uniname2ctype_pool_str2078[sizeof("idsb")];
- char uniname2ctype_pool_str2083[sizeof("indevanagari")];
- char uniname2ctype_pool_str2084[sizeof("avestan")];
- char uniname2ctype_pool_str2085[sizeof("cf")];
- char uniname2ctype_pool_str2093[sizeof("palmyrene")];
- char uniname2ctype_pool_str2095[sizeof("inethiopicsupplement")];
- char uniname2ctype_pool_str2097[sizeof("soyo")];
- char uniname2ctype_pool_str2098[sizeof("xposixpunct")];
- char uniname2ctype_pool_str2102[sizeof("pf")];
- char uniname2ctype_pool_str2103[sizeof("sarb")];
- char uniname2ctype_pool_str2109[sizeof("zanabazarsquare")];
- char uniname2ctype_pool_str2110[sizeof("ugaritic")];
- char uniname2ctype_pool_str2112[sizeof("osge")];
- char uniname2ctype_pool_str2114[sizeof("java")];
- char uniname2ctype_pool_str2117[sizeof("sharada")];
- char uniname2ctype_pool_str2119[sizeof("dogra")];
- char uniname2ctype_pool_str2135[sizeof("bugi")];
- char uniname2ctype_pool_str2137[sizeof("meroitichieroglyphs")];
- char uniname2ctype_pool_str2145[sizeof("separator")];
- char uniname2ctype_pool_str2146[sizeof("ingeorgiansupplement")];
- char uniname2ctype_pool_str2149[sizeof("sogd")];
- char uniname2ctype_pool_str2150[sizeof("tale")];
- char uniname2ctype_pool_str2153[sizeof("inunifiedcanadianaboriginalsyllabicsextended")];
- char uniname2ctype_pool_str2161[sizeof("terminalpunctuation")];
- char uniname2ctype_pool_str2165[sizeof("shrd")];
- char uniname2ctype_pool_str2166[sizeof("graph")];
- char uniname2ctype_pool_str2167[sizeof("olditalic")];
- char uniname2ctype_pool_str2170[sizeof("dogr")];
- char uniname2ctype_pool_str2173[sizeof("gujr")];
- char uniname2ctype_pool_str2181[sizeof("phag")];
- char uniname2ctype_pool_str2182[sizeof("gujarati")];
- char uniname2ctype_pool_str2195[sizeof("inhanguljamo")];
- char uniname2ctype_pool_str2199[sizeof("javanese")];
- char uniname2ctype_pool_str2201[sizeof("taml")];
- char uniname2ctype_pool_str2204[sizeof("inphoneticextensions")];
- char uniname2ctype_pool_str2207[sizeof("siddham")];
- char uniname2ctype_pool_str2217[sizeof("buginese")];
- char uniname2ctype_pool_str2218[sizeof("inmongoliansupplement")];
- char uniname2ctype_pool_str2222[sizeof("invariationselectors")];
- char uniname2ctype_pool_str2224[sizeof("inhanguljamoextendeda")];
- char uniname2ctype_pool_str2225[sizeof("inverticalforms")];
- char uniname2ctype_pool_str2228[sizeof("syrc")];
- char uniname2ctype_pool_str2229[sizeof("number")];
- char uniname2ctype_pool_str2235[sizeof("incopticepactnumbers")];
- char uniname2ctype_pool_str2238[sizeof("avst")];
- char uniname2ctype_pool_str2244[sizeof("inbamum")];
- char uniname2ctype_pool_str2247[sizeof("nd")];
- char uniname2ctype_pool_str2248[sizeof("insuttonsignwriting")];
- char uniname2ctype_pool_str2252[sizeof("extender")];
- char uniname2ctype_pool_str2258[sizeof("intaiviet")];
- char uniname2ctype_pool_str2260[sizeof("hex")];
- char uniname2ctype_pool_str2268[sizeof("incjkunifiedideographsextensionf")];
- char uniname2ctype_pool_str2271[sizeof("other")];
- char uniname2ctype_pool_str2272[sizeof("otheridcontinue")];
- char uniname2ctype_pool_str2278[sizeof("shaw")];
- char uniname2ctype_pool_str2282[sizeof("dash")];
- char uniname2ctype_pool_str2285[sizeof("othernumber")];
- char uniname2ctype_pool_str2294[sizeof("orya")];
- char uniname2ctype_pool_str2302[sizeof("invedicextensions")];
- char uniname2ctype_pool_str2305[sizeof("sgnw")];
- char uniname2ctype_pool_str2312[sizeof("caucasianalbanian")];
- char uniname2ctype_pool_str2315[sizeof("inmathematicalalphanumericsymbols")];
- char uniname2ctype_pool_str2321[sizeof("inphoneticextensionssupplement")];
- char uniname2ctype_pool_str2339[sizeof("invariationselectorssupplement")];
- char uniname2ctype_pool_str2343[sizeof("induployan")];
- char uniname2ctype_pool_str2344[sizeof("syriac")];
- char uniname2ctype_pool_str2357[sizeof("oalpha")];
- char uniname2ctype_pool_str2361[sizeof("innyiakengpuachuehmong")];
- char uniname2ctype_pool_str2364[sizeof("incombiningdiacriticalmarks")];
- char uniname2ctype_pool_str2365[sizeof("inethiopicextended")];
- char uniname2ctype_pool_str2373[sizeof("nl")];
- char uniname2ctype_pool_str2374[sizeof("incombiningdiacriticalmarksforsymbols")];
- char uniname2ctype_pool_str2375[sizeof("khudawadi")];
- char uniname2ctype_pool_str2378[sizeof("otheralphabetic")];
- char uniname2ctype_pool_str2389[sizeof("oldhungarian")];
- char uniname2ctype_pool_str2396[sizeof("incurrencysymbols")];
- char uniname2ctype_pool_str2397[sizeof("incjkradicalssupplement")];
- char uniname2ctype_pool_str2398[sizeof("inglagolitic")];
- char uniname2ctype_pool_str2415[sizeof("intifinagh")];
- char uniname2ctype_pool_str2416[sizeof("ingeorgianextended")];
- char uniname2ctype_pool_str2427[sizeof("surrogate")];
- char uniname2ctype_pool_str2433[sizeof("incyrillicextendedb")];
- char uniname2ctype_pool_str2440[sizeof("ethi")];
- char uniname2ctype_pool_str2451[sizeof("titlecaseletter")];
- char uniname2ctype_pool_str2454[sizeof("rohg")];
- char uniname2ctype_pool_str2458[sizeof("inmeroiticcursive")];
- char uniname2ctype_pool_str2460[sizeof("idstrinaryoperator")];
- char uniname2ctype_pool_str2470[sizeof("inphagspa")];
- char uniname2ctype_pool_str2475[sizeof("lepcha")];
- char uniname2ctype_pool_str2479[sizeof("intagalog")];
- char uniname2ctype_pool_str2480[sizeof("mathsymbol")];
- char uniname2ctype_pool_str2481[sizeof("incombiningdiacriticalmarkssupplement")];
- char uniname2ctype_pool_str2506[sizeof("inbrahmi")];
- char uniname2ctype_pool_str2513[sizeof("insymbolsandpictographsextendeda")];
- char uniname2ctype_pool_str2519[sizeof("inlinearbsyllabary")];
- char uniname2ctype_pool_str2529[sizeof("oldturkic")];
- char uniname2ctype_pool_str2534[sizeof("inbengali")];
- char uniname2ctype_pool_str2540[sizeof("wancho")];
- char uniname2ctype_pool_str2542[sizeof("osmanya")];
- char uniname2ctype_pool_str2548[sizeof("buhd")];
- char uniname2ctype_pool_str2552[sizeof("insmallformvariants")];
- char uniname2ctype_pool_str2561[sizeof("indevanagariextended")];
- char uniname2ctype_pool_str2562[sizeof("softdotted")];
- char uniname2ctype_pool_str2564[sizeof("inbuginese")];
- char uniname2ctype_pool_str2566[sizeof("mahj")];
- char uniname2ctype_pool_str2567[sizeof("inlatin1supplement")];
- char uniname2ctype_pool_str2570[sizeof("ingothic")];
- char uniname2ctype_pool_str2575[sizeof("mahajani")];
- char uniname2ctype_pool_str2576[sizeof("hang")];
- char uniname2ctype_pool_str2579[sizeof("sylo")];
- char uniname2ctype_pool_str2586[sizeof("warangciti")];
- char uniname2ctype_pool_str2595[sizeof("ingujarati")];
- char uniname2ctype_pool_str2603[sizeof("tirhuta")];
- char uniname2ctype_pool_str2606[sizeof("incombiningdiacriticalmarksextended")];
- char uniname2ctype_pool_str2609[sizeof("spaceseparator")];
- char uniname2ctype_pool_str2614[sizeof("ingunjalagondi")];
- char uniname2ctype_pool_str2624[sizeof("wcho")];
- char uniname2ctype_pool_str2631[sizeof("hiragana")];
- char uniname2ctype_pool_str2634[sizeof("extendedpictographic")];
- char uniname2ctype_pool_str2643[sizeof("inrejang")];
- char uniname2ctype_pool_str2644[sizeof("inottomansiyaqnumbers")];
- char uniname2ctype_pool_str2648[sizeof("nchar")];
- char uniname2ctype_pool_str2650[sizeof("cyrillic")];
- char uniname2ctype_pool_str2653[sizeof("khoj")];
- char uniname2ctype_pool_str2656[sizeof("inlimbu")];
- char uniname2ctype_pool_str2663[sizeof("hmng")];
- char uniname2ctype_pool_str2665[sizeof("thaa")];
- char uniname2ctype_pool_str2668[sizeof("thai")];
- char uniname2ctype_pool_str2670[sizeof("incjkunifiedideographsextensionb")];
- char uniname2ctype_pool_str2673[sizeof("deva")];
- char uniname2ctype_pool_str2676[sizeof("thaana")];
- char uniname2ctype_pool_str2688[sizeof("phagspa")];
- char uniname2ctype_pool_str2691[sizeof("devanagari")];
- char uniname2ctype_pool_str2692[sizeof("tang")];
- char uniname2ctype_pool_str2694[sizeof("currencysymbol")];
- char uniname2ctype_pool_str2698[sizeof("tagbanwa")];
- char uniname2ctype_pool_str2701[sizeof("inenclosedcjklettersandmonths")];
- char uniname2ctype_pool_str2702[sizeof("tamil")];
- char uniname2ctype_pool_str2721[sizeof("tirh")];
- char uniname2ctype_pool_str2723[sizeof("digit")];
- char uniname2ctype_pool_str2732[sizeof("talu")];
- char uniname2ctype_pool_str2747[sizeof("zp")];
- char uniname2ctype_pool_str2750[sizeof("inpaucinhau")];
- char uniname2ctype_pool_str2760[sizeof("taitham")];
- char uniname2ctype_pool_str2764[sizeof("otherlowercase")];
- char uniname2ctype_pool_str2768[sizeof("telu")];
- char uniname2ctype_pool_str2769[sizeof("inaegeannumbers")];
- char uniname2ctype_pool_str2777[sizeof("otherletter")];
- char uniname2ctype_pool_str2780[sizeof("whitespace")];
- char uniname2ctype_pool_str2793[sizeof("nonspacingmark")];
- char uniname2ctype_pool_str2816[sizeof("graphemeclusterbreak=spacingmark")];
- char uniname2ctype_pool_str2821[sizeof("inletterlikesymbols")];
- char uniname2ctype_pool_str2834[sizeof("intagbanwa")];
- char uniname2ctype_pool_str2841[sizeof("oldsogdian")];
- char uniname2ctype_pool_str2848[sizeof("otheridstart")];
- char uniname2ctype_pool_str2852[sizeof("graphemeclusterbreak=cr")];
- char uniname2ctype_pool_str2855[sizeof("narb")];
- char uniname2ctype_pool_str2856[sizeof("changeswhencasemapped")];
- char uniname2ctype_pool_str2859[sizeof("inbopomofo")];
- char uniname2ctype_pool_str2862[sizeof("tangut")];
- char uniname2ctype_pool_str2867[sizeof("graphemeclusterbreak=regionalindicator")];
- char uniname2ctype_pool_str2871[sizeof("noncharactercodepoint")];
- char uniname2ctype_pool_str2883[sizeof("otheruppercase")];
- char uniname2ctype_pool_str2885[sizeof("rjng")];
- char uniname2ctype_pool_str2886[sizeof("sylotinagri")];
- char uniname2ctype_pool_str2904[sizeof("inhangulsyllables")];
- char uniname2ctype_pool_str2905[sizeof("emojipresentation")];
- char uniname2ctype_pool_str2906[sizeof("inindicsiyaqnumbers")];
- char uniname2ctype_pool_str2909[sizeof("inbassavah")];
- char uniname2ctype_pool_str2912[sizeof("ogrext")];
- char uniname2ctype_pool_str2926[sizeof("othersymbol")];
- char uniname2ctype_pool_str2938[sizeof("oupper")];
- char uniname2ctype_pool_str2941[sizeof("inbuhid")];
- char uniname2ctype_pool_str2963[sizeof("hmnp")];
- char uniname2ctype_pool_str2964[sizeof("inpsalterpahlavi")];
- char uniname2ctype_pool_str2967[sizeof("finalpunctuation")];
- char uniname2ctype_pool_str2980[sizeof("phlp")];
- char uniname2ctype_pool_str2984[sizeof("inbamumsupplement")];
- char uniname2ctype_pool_str2986[sizeof("buhid")];
- char uniname2ctype_pool_str2987[sizeof("paragraphseparator")];
- char uniname2ctype_pool_str2988[sizeof("inalphabeticpresentationforms")];
- char uniname2ctype_pool_str2993[sizeof("omath")];
- char uniname2ctype_pool_str3000[sizeof("any")];
- char uniname2ctype_pool_str3001[sizeof("elba")];
- char uniname2ctype_pool_str3002[sizeof("changeswhentitlecased")];
- char uniname2ctype_pool_str3005[sizeof("incombininghalfmarks")];
- char uniname2ctype_pool_str3006[sizeof("intangutcomponents")];
- char uniname2ctype_pool_str3012[sizeof("hebr")];
- char uniname2ctype_pool_str3028[sizeof("deprecated")];
- char uniname2ctype_pool_str3045[sizeof("inarabicmathematicalalphabeticsymbols")];
- char uniname2ctype_pool_str3055[sizeof("inprivateusearea")];
- char uniname2ctype_pool_str3089[sizeof("kayahli")];
- char uniname2ctype_pool_str3098[sizeof("inplayingcards")];
- char uniname2ctype_pool_str3099[sizeof("inarabicpresentationformsb")];
- char uniname2ctype_pool_str3100[sizeof("ogham")];
- char uniname2ctype_pool_str3101[sizeof("elym")];
- char uniname2ctype_pool_str3107[sizeof("graphemeclusterbreak=t")];
- char uniname2ctype_pool_str3109[sizeof("graphemeclusterbreak=lvt")];
- char uniname2ctype_pool_str3111[sizeof("nbat")];
- char uniname2ctype_pool_str3125[sizeof("nabataean")];
- char uniname2ctype_pool_str3126[sizeof("hangul")];
- char uniname2ctype_pool_str3134[sizeof("elymaic")];
- char uniname2ctype_pool_str3158[sizeof("inhebrew")];
- char uniname2ctype_pool_str3165[sizeof("injavanese")];
- char uniname2ctype_pool_str3169[sizeof("symbol")];
- char uniname2ctype_pool_str3176[sizeof("inmathematicaloperators")];
- char uniname2ctype_pool_str3180[sizeof("inarabicsupplement")];
- char uniname2ctype_pool_str3185[sizeof("cypriot")];
- char uniname2ctype_pool_str3194[sizeof("hung")];
- char uniname2ctype_pool_str3205[sizeof("wspace")];
- char uniname2ctype_pool_str3209[sizeof("changeswhenlowercased")];
- char uniname2ctype_pool_str3215[sizeof("elbasan")];
- char uniname2ctype_pool_str3218[sizeof("hluw")];
- char uniname2ctype_pool_str3237[sizeof("insuperscriptsandsubscripts")];
- char uniname2ctype_pool_str3239[sizeof("graphemeclusterbreak=extend")];
- char uniname2ctype_pool_str3240[sizeof("graphemeclusterbreak=prepend")];
- char uniname2ctype_pool_str3248[sizeof("nshu")];
- char uniname2ctype_pool_str3254[sizeof("oldnortharabian")];
- char uniname2ctype_pool_str3266[sizeof("inyijinghexagramsymbols")];
- char uniname2ctype_pool_str3286[sizeof("hexdigit")];
- char uniname2ctype_pool_str3297[sizeof("graphemeclusterbreak=l")];
- char uniname2ctype_pool_str3303[sizeof("graphemeclusterbreak=control")];
- char uniname2ctype_pool_str3309[sizeof("bassavah")];
- char uniname2ctype_pool_str3317[sizeof("otherdefaultignorablecodepoint")];
- char uniname2ctype_pool_str3328[sizeof("changeswhenuppercased")];
- char uniname2ctype_pool_str3329[sizeof("inalchemicalsymbols")];
- char uniname2ctype_pool_str3348[sizeof("insupplementalarrowsa")];
- char uniname2ctype_pool_str3349[sizeof("inyisyllables")];
- char uniname2ctype_pool_str3351[sizeof("tibt")];
- char uniname2ctype_pool_str3360[sizeof("othermath")];
- char uniname2ctype_pool_str3363[sizeof("tibetan")];
- char uniname2ctype_pool_str3365[sizeof("inmahjongtiles")];
- char uniname2ctype_pool_str3433[sizeof("signwriting")];
- char uniname2ctype_pool_str3436[sizeof("nushu")];
- char uniname2ctype_pool_str3439[sizeof("modifiersymbol")];
- char uniname2ctype_pool_str3442[sizeof("inhalfwidthandfullwidthforms")];
- char uniname2ctype_pool_str3458[sizeof("upper")];
- char uniname2ctype_pool_str3460[sizeof("insupplementalarrowsc")];
- char uniname2ctype_pool_str3511[sizeof("insupplementalmathematicaloperators")];
- char uniname2ctype_pool_str3512[sizeof("incypriotsyllabary")];
- char uniname2ctype_pool_str3517[sizeof("dupl")];
- char uniname2ctype_pool_str3531[sizeof("tavt")];
- char uniname2ctype_pool_str3532[sizeof("inpahawhhmong")];
- char uniname2ctype_pool_str3533[sizeof("alphabetic")];
- char uniname2ctype_pool_str3550[sizeof("dashpunctuation")];
- char uniname2ctype_pool_str3558[sizeof("uppercase")];
- char uniname2ctype_pool_str3613[sizeof("soyombo")];
- char uniname2ctype_pool_str3614[sizeof("hanifirohingya")];
- char uniname2ctype_pool_str3616[sizeof("otherpunctuation")];
- char uniname2ctype_pool_str3628[sizeof("defaultignorablecodepoint")];
- char uniname2ctype_pool_str3648[sizeof("inhanguljamoextendedb")];
- char uniname2ctype_pool_str3664[sizeof("aghb")];
- char uniname2ctype_pool_str3703[sizeof("tifinagh")];
- char uniname2ctype_pool_str3705[sizeof("inlatinextendedb")];
- char uniname2ctype_pool_str3714[sizeof("tfng")];
- char uniname2ctype_pool_str3766[sizeof("inhighprivateusesurrogates")];
- char uniname2ctype_pool_str3791[sizeof("changeswhencasefolded")];
- char uniname2ctype_pool_str3805[sizeof("dep")];
- char uniname2ctype_pool_str3819[sizeof("oldsoutharabian")];
- char uniname2ctype_pool_str3821[sizeof("graphemeclusterbreak=lf")];
- char uniname2ctype_pool_str3842[sizeof("pahawhhmong")];
- char uniname2ctype_pool_str3845[sizeof("unifiedideograph")];
- char uniname2ctype_pool_str3891[sizeof("uppercaseletter")];
- char uniname2ctype_pool_str3924[sizeof("insupplementalpunctuation")];
- char uniname2ctype_pool_str3942[sizeof("ethiopic")];
- char uniname2ctype_pool_str3976[sizeof("inglagoliticsupplement")];
- char uniname2ctype_pool_str3995[sizeof("rejang")];
- char uniname2ctype_pool_str4087[sizeof("inbopomofoextended")];
- char uniname2ctype_pool_str4109[sizeof("tagb")];
- char uniname2ctype_pool_str4137[sizeof("othergraphemeextend")];
- char uniname2ctype_pool_str4162[sizeof("inegyptianhieroglyphs")];
- char uniname2ctype_pool_str4175[sizeof("inegyptianhieroglyphformatcontrols")];
- char uniname2ctype_pool_str4203[sizeof("hebrew")];
- char uniname2ctype_pool_str4254[sizeof("tglg")];
- char uniname2ctype_pool_str4276[sizeof("tagalog")];
- char uniname2ctype_pool_str4291[sizeof("graphemeclusterbreak=zwj")];
- char uniname2ctype_pool_str4321[sizeof("zyyy")];
- char uniname2ctype_pool_str4360[sizeof("hyphen")];
- char uniname2ctype_pool_str4397[sizeof("inboxdrawing")];
- char uniname2ctype_pool_str4405[sizeof("graphemeclusterbreak=v")];
- char uniname2ctype_pool_str4406[sizeof("graphemeclusterbreak=lv")];
- char uniname2ctype_pool_str4460[sizeof("telugu")];
- char uniname2ctype_pool_str4485[sizeof("duployan")];
- char uniname2ctype_pool_str4528[sizeof("openpunctuation")];
- char uniname2ctype_pool_str4674[sizeof("insupplementaryprivateuseareaa")];
- char uniname2ctype_pool_str4683[sizeof("inhighsurrogates")];
- char uniname2ctype_pool_str4772[sizeof("insupplementalarrowsb")];
- char uniname2ctype_pool_str4948[sizeof("insupplementalsymbolsandpictographs")];
- char uniname2ctype_pool_str4955[sizeof("egyp")];
- char uniname2ctype_pool_str4986[sizeof("inhangulcompatibilityjamo")];
- char uniname2ctype_pool_str5114[sizeof("nyiakengpuachuehmong")];
- char uniname2ctype_pool_str5608[sizeof("egyptianhieroglyphs")];
- char uniname2ctype_pool_str6098[sizeof("insupplementaryprivateuseareab")];
-#endif /* USE_UNICODE_PROPERTIES */
- };
-static const struct uniname2ctype_pool_t uniname2ctype_pool_contents =
- {
-#ifndef USE_UNICODE_PROPERTIES
- "word",
-#else /* USE_UNICODE_PROPERTIES */
- "yi",
- "yiii",
- "lana",
- "z",
- "lina",
- "maka",
- "mani",
- "mn",
- "miao",
- "lo",
- "ci",
- "lao",
- "laoo",
- "inkannada",
- "cn",
- "pi",
- "innko",
- "zzzz",
- "gran",
- "co",
- "lineara",
- "mark",
- "po",
- "me",
- "cari",
- "inkharoshthi",
- "kana",
- "loe",
- "m",
- "grek",
- "mro",
- "mroo",
- "carian",
- "geor",
- "greek",
- "gonm",
- "mendekikakui",
- "pe",
- "mero",
- "inosmanya",
- "cakm",
- "inmanichaean",
- "inmro",
- "inmiao",
- "inchakma",
- "c",
- "mandaic",
- "meeteimayek",
- "inarmenian",
- "inmyanmar",
- "inmakasar",
- "common",
- "lm",
- "marc",
- "inrunic",
- "incarian",
- "inideographicsymbolsandpunctuation",
- "inkhmer",
- "qaai",
- "inahom",
- "merc",
- "combiningmark",
- "lc",
- "perm",
- "mc",
- "connectorpunctuation",
- "cans",
- "incuneiformnumbersandpunctuation",
- "armi",
- "cc",
- "armn",
- "incherokee",
- "prependedconcatenationmark",
- "incuneiform",
- "inavestan",
- "inipaextensions",
- "pc",
- "armenian",
- "insharada",
- "inmarchen",
- "makasar",
- "masaramgondi",
- "inarrows",
- "incyrillic",
- "incham",
- "qmark",
- "ri",
- "qaac",
- "insamaritan",
- "latn",
- "inmasaramgondi",
- "inthaana",
- "latin",
- "inthai",
- "lineseparator",
- "pcm",
- "inkatakana",
- "inkaithi",
- "inzanabazarsquare",
- "inscriptionalparthian",
- "initialpunctuation",
- "mtei",
- "vai",
- "vaii",
- "inkhmersymbols",
- "insyriac",
- "intakri",
- "arabic",
- "zs",
- "katakana",
- "prti",
- "ascii",
- "cs",
- "ps",
- "mand",
- "privateuse",
- "inruminumeralsymbols",
- "inmyanmarextendeda",
- "modi",
- "incjkcompatibilityforms",
- "inkanaextendeda",
- "incjkcompatibilityideographs",
- "brai",
- "mend",
- "ideo",
- "letter",
- "l",
- "inmeeteimayek",
- "inideographicdescriptioncharacters",
- "xidcontinue",
- "knda",
- "innandinagari",
- "kannada",
- "inmodi",
- "inlao",
- "inoldnortharabian",
- "intransportandmapsymbols",
- "letternumber",
- "gothic",
- "inlineara",
- "inmendekikakui",
- "xidc",
- "mongolian",
- "inmiscellaneousmathematicalsymbolsa",
- "inspecials",
- "grlink",
- "brahmi",
- "inemoticons",
- "kali",
- "inolditalic",
- "inmedefaidrin",
- "inchesssymbols",
- "incjkcompatibilityideographssupplement",
- "inadlam",
- "psalterpahlavi",
- "incommonindicnumberforms",
- "lt",
- "innewa",
- "sk",
- "control",
- "inancientsymbols",
- "palm",
- "inlycian",
- "so",
- "patternwhitespace",
- "xids",
- "inmandaic",
- "idc",
- "meroiticcursive",
- "inwarangciti",
- "sora",
- "inopticalcharacterrecognition",
- "inoldsogdian",
- "inmalayalam",
- "bamum",
- "inkanasupplement",
- "insundanese",
- "grext",
-#endif /* USE_UNICODE_PROPERTIES */
- "print",
-#ifndef USE_UNICODE_PROPERTIES
- "punct",
- "alpha",
-#else /* USE_UNICODE_PROPERTIES */
- "intaitham",
- "lower",
- "joinc",
- "inoldsoutharabian",
- "incjkstrokes",
- "batk",
- "samr",
- "inwancho",
- "batak",
- "vs",
- "patws",
- "samaritan",
- "idsbinaryoperator",
- "pauc",
- "insmallkanaextension",
- "sm",
- "indominotiles",
-#endif /* USE_UNICODE_PROPERTIES */
- "alnum",
-#ifdef USE_UNICODE_PROPERTIES
- "insylotinagri",
- "inugaritic",
- "incontrolpictures",
- "inlinearbideograms",
- "inmusicalsymbols",
- "s",
- "ital",
- "inmodifiertoneletters",
- "inancientgreekmusicalnotation",
- "patternsyntax",
- "lisu",
- "lowercase",
- "cwcm",
- "sc",
- "bass",
- "ids",
- "inlatinextendeda",
- "oriya",
- "intaile",
- "inmiscellaneoussymbols",
- "inmiscellaneoussymbolsandarrows",
- "incaucasianalbanian",
- "inmiscellaneoussymbolsandpictographs",
- "inoldturkic",
- "insaurashtra",
- "idcontinue",
- "intamil",
- "inmultani",
- "inlatinextendede",
- "pd",
- "bali",
- "blank",
- "idst",
- "inlydian",
- "innewtailue",
- "bengali",
- "runr",
- "zl",
- "incyrillicextendeda",
- "ll",
- "indeseret",
- "intaixuanjingsymbols",
- "inancientgreeknumbers",
- "idstart",
- "inmeeteimayekextensions",
- "balinese",
- "dia",
- "di",
- "inspacingmodifierletters",
- "inearlydynasticcuneiform",
- "plrd",
- "canadianaboriginal",
- "zinh",
- "sind",
- "osage",
- "inlatinextendedc",
- "uideo",
- "incountingrodnumerals",
- "xidstart",
-#endif /* USE_UNICODE_PROPERTIES */
- "xdigit",
-#ifndef USE_UNICODE_PROPERTIES
- "upper",
- "ascii",
-#else /* USE_UNICODE_PROPERTIES */
- "osma",
- "inkhudawadi",
- "inhanifirohingya",
- "gong",
- "ingrantha",
- "bidic",
- "mong",
- "cased",
- "incyrillicextendedc",
- "inhiragana",
- "sinhala",
- "adlm",
- "glagolitic",
- "sterm",
- "bamu",
- "georgian",
- "inosage",
- "gunjalagondi",
- "phoenician",
- "multani",
- "kaithi",
- "joincontrol",
- "runic",
- "ingeneralpunctuation",
- "inmahajani",
- "incyrillicsupplement",
- "lowercaseletter",
- "marchen",
- "graphemelink",
- "ingeorgian",
- "khojki",
- "cham",
- "inogham",
- "cher",
- "chakma",
- "emoji",
- "insiddham",
- "cherokee",
- "khar",
- "inmongolian",
- "incherokeesupplement",
- "diacritic",
- "manichaean",
- "xsux",
- "inolchiki",
- "quotationmark",
- "adlam",
- "inethiopic",
- "graphemebase",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=11.0",
- "age=12.1",
- "age=10.0",
- "age=12.0",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "casedletter",
- "ingurmukhi",
- "odi",
- "incjkunifiedideographsextensiona",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=1.1",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "lu",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=4.1",
- "age=2.1",
- "age=4.0",
- "age=2.0",
- "age=9.0",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "intamilsupplement",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=6.1",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "unknown",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=6.0",
- "age=6.2",
- "age=3.1",
- "age=8.0",
- "age=3.0",
- "age=3.2",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "cwt",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=7.0",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "unassigned",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=6.3",
- "age=5.1",
- "age=5.0",
- "age=5.2",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "ahom",
- "incjkunifiedideographsextensione",
- "khmr",
- "insinhala",
- "inmiscellaneoustechnical",
- "saur",
- "guru",
- "sundanese",
- "punct",
- "paucinhau",
- "gurmukhi",
- "variationselector",
- "logicalorderexception",
- "khmer",
- "limbu",
- "inscriptionalpahlavi",
- "oidc",
- "incjkunifiedideographsextensionc",
-#endif /* USE_UNICODE_PROPERTIES */
- "cntrl",
-#ifdef USE_UNICODE_PROPERTIES
- "inlatinextendedadditional",
- "decimalnumber",
- "insorasompeng",
- "radical",
- "emojimodifier",
- "kharoshthi",
- "n",
- "math",
- "goth",
- "anatolianhieroglyphs",
- "inenclosedalphanumerics",
- "nandinagari",
- "no",
- "nko",
- "nkoo",
- "ingreekandcoptic",
- "olck",
- "p",
- "grantha",
- "olchiki",
- "incjkunifiedideographs",
- "zanb",
- "intirhuta",
- "oids",
- "inhatran",
- "linb",
- "xpeo",
- "mult",
- "saurashtra",
- "kthi",
- "inbhaiksuki",
- "olower",
- "innabataean",
- "inphoenician",
- "inkanbun",
- "inmeroitichieroglyphs",
- "inkayahli",
- "phnx",
- "inoriya",
- "enclosingmark",
- "sd",
- "inelbasan",
- "wara",
- "inenclosedideographicsupplement",
- "sidd",
- "linearb",
- "hani",
- "han",
- "inenclosedalphanumericsupplement",
- "medf",
- "bidicontrol",
- "hano",
- "inphaistosdisc",
- "limb",
- "inkangxiradicals",
- "lepc",
- "medefaidrin",
- "braille",
- "regionalindicator",
- "inlowsurrogates",
- "inshorthandformatcontrols",
- "brah",
- "inkhojki",
- "inoldhungarian",
- "hanunoo",
- "hira",
- "beng",
- "emojimodifierbase",
- "inarabic",
- "lyci",
- "ahex",
- "inherited",
- "glag",
- "lycian",
- "indogra",
- "dsrt",
- "arab",
- "mymr",
- "myanmar",
- "phli",
- "inimperialaramaic",
- "ingreekextended",
- "inanatolianhieroglyphs",
- "punctuation",
- "takri",
- "graphemeextend",
- "invai",
- "cwl",
- "ingeometricshapes",
- "emojicomponent",
- "coptic",
- "deseret",
- "inarabicpresentationformsa",
- "takr",
- "inbasiclatin",
- "incjkunifiedideographsextensiond",
- "sinh",
- "sund",
- "shavian",
- "taile",
- "insundanesesupplement",
- "inelymaic",
- "insoyombo",
- "bhks",
- "bhaiksuki",
- "incjkcompatibility",
- "inhanunoo",
- "intangut",
- "sogdian",
- "inlatinextendedd",
- "sogo",
- "insinhalaarchaicnumbers",
- "ideographic",
- "ugar",
- "copt",
- "imperialaramaic",
- "insogdian",
- "indingbats",
- "format",
- "ininscriptionalpahlavi",
- "ininscriptionalparthian",
- "grbase",
- "inbatak",
- "cprt",
- "cwcf",
- "cuneiform",
- "term",
- "intibetan",
- "intags",
- "asciihexdigit",
- "sentenceterminal",
- "inmayannumerals",
- "nand",
- "patsyn",
- "hatran",
- "inblockelements",
- "inornamentaldingbats",
- "innumberforms",
- "oldpersian",
- "inshavian",
- "bopo",
- "hatr",
- "caseignorable",
- "inoldpersian",
- "modifierletter",
- "cwu",
- "lydi",
- "inbyzantinemusicalsymbols",
- "ingeometricshapesextended",
- "inmyanmarextendedb",
- "innushu",
- "lydian",
- "inunifiedcanadianaboriginalsyllabics",
- "orkh",
- "inyiradicals",
- "inkatakanaphoneticextensions",
- "inethiopicextendeda",
- "incoptic",
- "inarabicextendeda",
- "oldpermic",
- "incjksymbolsandpunctuation",
- "word",
- "bopomofo",
- "ogam",
- "inlisu",
- "inoldpermic",
- "innoblock",
- "taiviet",
- "inbraillepatterns",
- "alpha",
- "inbalinese",
- "sorasompeng",
- "closepunctuation",
- "inmiscellaneousmathematicalsymbolsb",
- "inlepcha",
- "insyriacsupplement",
- "newa",
- "spacingmark",
- "inpalmyrene",
- "cyrl",
- "assigned",
- "mlym",
- "malayalam",
- "ext",
- "newtailue",
-#endif /* USE_UNICODE_PROPERTIES */
- "space",
-#ifdef USE_UNICODE_PROPERTIES
- "intelugu",
- "idsb",
- "indevanagari",
- "avestan",
- "cf",
- "palmyrene",
- "inethiopicsupplement",
- "soyo",
-#endif /* USE_UNICODE_PROPERTIES */
- "xposixpunct",
-#ifndef USE_UNICODE_PROPERTIES
- "lower",
-#else /* USE_UNICODE_PROPERTIES */
- "pf",
- "sarb",
- "zanabazarsquare",
- "ugaritic",
- "osge",
- "java",
- "sharada",
- "dogra",
- "bugi",
- "meroitichieroglyphs",
- "separator",
- "ingeorgiansupplement",
- "sogd",
- "tale",
- "inunifiedcanadianaboriginalsyllabicsextended",
- "terminalpunctuation",
- "shrd",
-#endif /* USE_UNICODE_PROPERTIES */
- "graph",
-#ifdef USE_UNICODE_PROPERTIES
- "olditalic",
- "dogr",
- "gujr",
- "phag",
- "gujarati",
- "inhanguljamo",
- "javanese",
- "taml",
- "inphoneticextensions",
- "siddham",
- "buginese",
- "inmongoliansupplement",
- "invariationselectors",
- "inhanguljamoextendeda",
- "inverticalforms",
- "syrc",
- "number",
- "incopticepactnumbers",
- "avst",
- "inbamum",
- "nd",
- "insuttonsignwriting",
- "extender",
- "intaiviet",
- "hex",
- "incjkunifiedideographsextensionf",
- "other",
- "otheridcontinue",
- "shaw",
- "dash",
- "othernumber",
- "orya",
- "invedicextensions",
- "sgnw",
- "caucasianalbanian",
- "inmathematicalalphanumericsymbols",
- "inphoneticextensionssupplement",
- "invariationselectorssupplement",
- "induployan",
- "syriac",
- "oalpha",
- "innyiakengpuachuehmong",
- "incombiningdiacriticalmarks",
- "inethiopicextended",
- "nl",
- "incombiningdiacriticalmarksforsymbols",
- "khudawadi",
- "otheralphabetic",
- "oldhungarian",
- "incurrencysymbols",
- "incjkradicalssupplement",
- "inglagolitic",
- "intifinagh",
- "ingeorgianextended",
- "surrogate",
- "incyrillicextendedb",
- "ethi",
- "titlecaseletter",
- "rohg",
- "inmeroiticcursive",
- "idstrinaryoperator",
- "inphagspa",
- "lepcha",
- "intagalog",
- "mathsymbol",
- "incombiningdiacriticalmarkssupplement",
- "inbrahmi",
- "insymbolsandpictographsextendeda",
- "inlinearbsyllabary",
- "oldturkic",
- "inbengali",
- "wancho",
- "osmanya",
- "buhd",
- "insmallformvariants",
- "indevanagariextended",
- "softdotted",
- "inbuginese",
- "mahj",
- "inlatin1supplement",
- "ingothic",
- "mahajani",
- "hang",
- "sylo",
- "warangciti",
- "ingujarati",
- "tirhuta",
- "incombiningdiacriticalmarksextended",
- "spaceseparator",
- "ingunjalagondi",
- "wcho",
- "hiragana",
- "extendedpictographic",
- "inrejang",
- "inottomansiyaqnumbers",
- "nchar",
- "cyrillic",
- "khoj",
- "inlimbu",
- "hmng",
- "thaa",
- "thai",
- "incjkunifiedideographsextensionb",
- "deva",
- "thaana",
- "phagspa",
- "devanagari",
- "tang",
- "currencysymbol",
- "tagbanwa",
- "inenclosedcjklettersandmonths",
- "tamil",
- "tirh",
-#endif /* USE_UNICODE_PROPERTIES */
- "digit",
-#ifndef USE_UNICODE_PROPERTIES
- "blank"
-#else /* USE_UNICODE_PROPERTIES */
- "talu",
- "zp",
- "inpaucinhau",
- "taitham",
- "otherlowercase",
- "telu",
- "inaegeannumbers",
- "otherletter",
- "whitespace",
- "nonspacingmark",
- "graphemeclusterbreak=spacingmark",
- "inletterlikesymbols",
- "intagbanwa",
- "oldsogdian",
- "otheridstart",
- "graphemeclusterbreak=cr",
- "narb",
- "changeswhencasemapped",
- "inbopomofo",
- "tangut",
- "graphemeclusterbreak=regionalindicator",
- "noncharactercodepoint",
- "otheruppercase",
- "rjng",
- "sylotinagri",
- "inhangulsyllables",
- "emojipresentation",
- "inindicsiyaqnumbers",
- "inbassavah",
- "ogrext",
- "othersymbol",
- "oupper",
- "inbuhid",
- "hmnp",
- "inpsalterpahlavi",
- "finalpunctuation",
- "phlp",
- "inbamumsupplement",
- "buhid",
- "paragraphseparator",
- "inalphabeticpresentationforms",
- "omath",
- "any",
- "elba",
- "changeswhentitlecased",
- "incombininghalfmarks",
- "intangutcomponents",
- "hebr",
- "deprecated",
- "inarabicmathematicalalphabeticsymbols",
- "inprivateusearea",
- "kayahli",
- "inplayingcards",
- "inarabicpresentationformsb",
- "ogham",
- "elym",
- "graphemeclusterbreak=t",
- "graphemeclusterbreak=lvt",
- "nbat",
- "nabataean",
- "hangul",
- "elymaic",
- "inhebrew",
- "injavanese",
- "symbol",
- "inmathematicaloperators",
- "inarabicsupplement",
- "cypriot",
- "hung",
- "wspace",
- "changeswhenlowercased",
- "elbasan",
- "hluw",
- "insuperscriptsandsubscripts",
- "graphemeclusterbreak=extend",
- "graphemeclusterbreak=prepend",
- "nshu",
- "oldnortharabian",
- "inyijinghexagramsymbols",
- "hexdigit",
- "graphemeclusterbreak=l",
- "graphemeclusterbreak=control",
- "bassavah",
- "otherdefaultignorablecodepoint",
- "changeswhenuppercased",
- "inalchemicalsymbols",
- "insupplementalarrowsa",
- "inyisyllables",
- "tibt",
- "othermath",
- "tibetan",
- "inmahjongtiles",
- "signwriting",
- "nushu",
- "modifiersymbol",
- "inhalfwidthandfullwidthforms",
- "upper",
- "insupplementalarrowsc",
- "insupplementalmathematicaloperators",
- "incypriotsyllabary",
- "dupl",
- "tavt",
- "inpahawhhmong",
- "alphabetic",
- "dashpunctuation",
- "uppercase",
- "soyombo",
- "hanifirohingya",
- "otherpunctuation",
- "defaultignorablecodepoint",
- "inhanguljamoextendedb",
- "aghb",
- "tifinagh",
- "inlatinextendedb",
- "tfng",
- "inhighprivateusesurrogates",
- "changeswhencasefolded",
- "dep",
- "oldsoutharabian",
- "graphemeclusterbreak=lf",
- "pahawhhmong",
- "unifiedideograph",
- "uppercaseletter",
- "insupplementalpunctuation",
- "ethiopic",
- "inglagoliticsupplement",
- "rejang",
- "inbopomofoextended",
- "tagb",
- "othergraphemeextend",
- "inegyptianhieroglyphs",
- "inegyptianhieroglyphformatcontrols",
- "hebrew",
- "tglg",
- "tagalog",
- "graphemeclusterbreak=zwj",
- "zyyy",
- "hyphen",
- "inboxdrawing",
- "graphemeclusterbreak=v",
- "graphemeclusterbreak=lv",
- "telugu",
- "duployan",
- "openpunctuation",
- "insupplementaryprivateuseareaa",
- "inhighsurrogates",
- "insupplementalarrowsb",
- "insupplementalsymbolsandpictographs",
- "egyp",
- "inhangulcompatibilityjamo",
- "nyiakengpuachuehmong",
- "egyptianhieroglyphs",
- "insupplementaryprivateuseareab"
-#endif /* USE_UNICODE_PROPERTIES */
- };
-#define uniname2ctype_pool ((const char *) &uniname2ctype_pool_contents)
-const struct uniname2ctype_struct *
-uniname2ctype_p (register const char *str, register size_t len)
-{
- static const struct uniname2ctype_struct wordlist[] =
- {
-#ifdef USE_UNICODE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str11), 111},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str17), 111},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str22), 152},
- {-1},
- {uniname2ctype_offset(str24), 52},
- {uniname2ctype_offset(str25), 184},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str33), 218},
- {-1},
- {uniname2ctype_offset(str35), 186},
- {uniname2ctype_offset(str36), 34},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str45), 173},
- {uniname2ctype_offset(str46), 28},
- {uniname2ctype_offset(str47), 61},
- {uniname2ctype_offset(str48), 95},
- {uniname2ctype_offset(str49), 95},
- {-1}, {-1},
- {uniname2ctype_offset(str52), 331},
- {-1}, {-1},
- {uniname2ctype_offset(str55), 21},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str64), 44},
- {-1},
- {uniname2ctype_offset(str66), 319},
- {uniname2ctype_offset(str67), 267},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str71), 181},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str75), 22},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str83), 184},
- {-1}, {-1},
- {uniname2ctype_offset(str86), 31},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str92), 45},
- {-1},
- {uniname2ctype_offset(str94), 33},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str100), 149},
- {uniname2ctype_offset(str101), 496},
- {uniname2ctype_offset(str102), 108},
- {uniname2ctype_offset(str103), 252},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str107), 31},
- {uniname2ctype_offset(str108), 77},
- {-1}, {-1},
- {uniname2ctype_offset(str111), 189},
- {uniname2ctype_offset(str112), 189},
- {-1}, {-1},
- {uniname2ctype_offset(str115), 149},
- {-1},
- {uniname2ctype_offset(str117), 98},
- {uniname2ctype_offset(str118), 77},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str122), 212},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str129), 187},
- {uniname2ctype_offset(str130), 42},
- {uniname2ctype_offset(str131), 172},
- {-1}, {-1},
- {uniname2ctype_offset(str134), 482},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str139), 170},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str145), 499},
- {uniname2ctype_offset(str146), 548},
- {-1},
- {uniname2ctype_offset(str148), 552},
- {uniname2ctype_offset(str149), 514},
- {-1},
- {uniname2ctype_offset(str151), 18},
- {uniname2ctype_offset(str152), 169},
- {uniname2ctype_offset(str153), 160},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str161), 313},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str177), 337},
- {uniname2ctype_offset(str178), 539},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str183), 75},
- {-1}, {-1},
- {uniname2ctype_offset(str186), 27},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str190), 208},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str203), 345},
- {uniname2ctype_offset(str204), 473},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str210), 553},
- {-1},
- {uniname2ctype_offset(str212), 350},
- {uniname2ctype_offset(str213), 115},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str218), 528},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str226), 171},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str231), 31},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str236), 25},
- {uniname2ctype_offset(str237), 194},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str246), 32},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str250), 40},
- {-1}, {-1},
- {uniname2ctype_offset(str253), 102},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str260), 542},
- {-1}, {-1},
- {uniname2ctype_offset(str263), 161},
- {-1},
- {uniname2ctype_offset(str265), 19},
- {-1},
- {uniname2ctype_offset(str267), 79},
- {uniname2ctype_offset(str268), 342},
- {-1},
- {uniname2ctype_offset(str270), 259},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str274), 541},
- {uniname2ctype_offset(str275), 500},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str281), 307},
- {uniname2ctype_offset(str282), 40},
- {uniname2ctype_offset(str283), 79},
- {-1},
- {uniname2ctype_offset(str285), 516},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str289), 536},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str293), 218},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str297), 212},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str301), 380},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str311), 311},
- {-1},
- {uniname2ctype_offset(str313), 441},
- {-1},
- {uniname2ctype_offset(str315), 232},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str320), 260},
- {-1},
- {uniname2ctype_offset(str322), 129},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str328), 320},
- {-1}, {-1},
- {uniname2ctype_offset(str331), 76},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str335), 537},
- {-1}, {-1},
- {uniname2ctype_offset(str338), 318},
- {-1},
- {uniname2ctype_offset(str340), 76},
- {-1},
- {uniname2ctype_offset(str342), 334},
- {-1}, {-1},
- {uniname2ctype_offset(str345), 53},
- {uniname2ctype_offset(str346), 259},
- {-1},
- {uniname2ctype_offset(str348), 411},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str352), 512},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str357), 532},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str362), 163},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str366), 44},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str373), 160},
- {-1}, {-1},
- {uniname2ctype_offset(str376), 144},
- {uniname2ctype_offset(str377), 144},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str386), 356},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str399), 316},
- {-1},
- {uniname2ctype_offset(str401), 527},
- {-1}, {-1},
- {uniname2ctype_offset(str404), 81},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str411), 55},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str418), 108},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str426), 163},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str442), 14},
- {-1}, {-1},
- {uniname2ctype_offset(str445), 23},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str462), 46},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str468), 169},
- {-1},
- {uniname2ctype_offset(str470), 22},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str475), 507},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str480), 442},
- {uniname2ctype_offset(str481), 188},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str486), 461},
- {-1},
- {uniname2ctype_offset(str488), 557},
- {-1}, {-1},
- {uniname2ctype_offset(str491), 455},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str500), 127},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str504), 187},
- {uniname2ctype_offset(str505), 238},
- {uniname2ctype_offset(str506), 24},
- {-1}, {-1},
- {uniname2ctype_offset(str509), 24},
- {-1},
- {uniname2ctype_offset(str511), 448},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str520), 408},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str535), 70},
- {-1}, {-1},
- {uniname2ctype_offset(str538), 91},
- {-1}, {-1},
- {uniname2ctype_offset(str541), 531},
- {-1},
- {uniname2ctype_offset(str543), 91},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str556), 525},
- {-1},
- {uniname2ctype_offset(str558), 335},
- {-1},
- {uniname2ctype_offset(str560), 498},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str565), 586},
- {uniname2ctype_offset(str566), 37},
- {-1},
- {uniname2ctype_offset(str568), 113},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str572), 486},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str577), 573},
- {uniname2ctype_offset(str578), 70},
- {uniname2ctype_offset(str579), 106},
- {-1}, {-1},
- {uniname2ctype_offset(str582), 391},
- {uniname2ctype_offset(str583), 465},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str590), 74},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str594), 168},
- {-1},
- {uniname2ctype_offset(str596), 584},
- {uniname2ctype_offset(str597), 146},
- {-1}, {-1},
- {uniname2ctype_offset(str600), 475},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str604), 551},
- {uniname2ctype_offset(str605), 591},
- {-1}, {-1},
- {uniname2ctype_offset(str608), 598},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str614), 574},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str624), 195},
- {uniname2ctype_offset(str625), 432},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str630), 29},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str636), 522},
- {-1}, {-1},
- {uniname2ctype_offset(str639), 49},
- {-1}, {-1},
- {uniname2ctype_offset(str642), 19},
- {-1}, {-1},
- {uniname2ctype_offset(str645), 470},
- {-1},
- {uniname2ctype_offset(str647), 192},
- {-1}, {-1},
- {uniname2ctype_offset(str650), 472},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str657), 51},
- {-1}, {-1},
- {uniname2ctype_offset(str660), 257},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str668), 69},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str672), 321},
- {-1}, {-1},
- {uniname2ctype_offset(str675), 68},
- {-1}, {-1},
- {uniname2ctype_offset(str678), 171},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str695), 530},
- {uniname2ctype_offset(str696), 175},
- {uniname2ctype_offset(str697), 384},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str703), 508},
- {-1},
- {uniname2ctype_offset(str705), 332},
- {-1},
- {uniname2ctype_offset(str707), 158},
- {uniname2ctype_offset(str708), 556},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str713), 361},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str720), 72},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str737), 7},
- {uniname2ctype_offset(str738), 358},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str742), 6},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str753), 229},
- {-1},
- {uniname2ctype_offset(str755), 497},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str760), 416},
- {uniname2ctype_offset(str761), 167},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str766), 156},
- {uniname2ctype_offset(str767), 572},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str771), 167},
- {uniname2ctype_offset(str772), 256},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str776), 257},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str783), 156},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str787), 245},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str791), 193},
- {-1}, {-1},
- {uniname2ctype_offset(str794), 558},
- {-1}, {-1},
- {uniname2ctype_offset(str797), 50},
- {-1},
- {uniname2ctype_offset(str799), 579},
- {-1}, {-1},
- {uniname2ctype_offset(str802), 13},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str809), 431},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str814), 478},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str818), 383},
- {-1}, {-1},
- {uniname2ctype_offset(str821), 467},
- {uniname2ctype_offset(str822), 563},
- {uniname2ctype_offset(str823), 47},
- {uniname2ctype_offset(str824), 112},
- {uniname2ctype_offset(str825), 429},
- {-1}, {-1},
- {uniname2ctype_offset(str828), 564},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str834), 258},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str838), 157},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str842), 58},
- {-1}, {-1},
- {uniname2ctype_offset(str845), 66},
- {-1},
- {uniname2ctype_offset(str847), 48},
- {uniname2ctype_offset(str848), 178},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str855), 67},
- {-1},
- {uniname2ctype_offset(str857), 305},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str862), 88},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str875), 354},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str886), 389},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str895), 397},
- {-1}, {-1},
- {uniname2ctype_offset(str898), 485},
- {-1},
- {uniname2ctype_offset(str900), 583},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str906), 504},
- {uniname2ctype_offset(str907), 434},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str924), 68},
- {-1},
- {uniname2ctype_offset(str926), 329},
- {-1},
- {uniname2ctype_offset(str928), 519},
- {uniname2ctype_offset(str929), 446},
- {uniname2ctype_offset(str930), 41},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str946), 136},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str961), 2},
- {-1},
- {uniname2ctype_offset(str963), 246},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str974), 493},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str986), 355},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str994), 85},
- {uniname2ctype_offset(str995), 104},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1005), 53},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1009), 404},
- {uniname2ctype_offset(str1010), 26},
- {-1}, {-1},
- {uniname2ctype_offset(str1013), 480},
- {uniname2ctype_offset(str1014), 566},
- {uniname2ctype_offset(str1015), 469},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1021), 67},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1025), 444},
- {-1}, {-1},
- {uniname2ctype_offset(str1028), 136},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1032), 239},
- {uniname2ctype_offset(str1033), 71},
- {-1},
- {uniname2ctype_offset(str1035), 308},
- {uniname2ctype_offset(str1036), 543},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1049), 173},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1067), 102},
- {-1}, {-1},
- {uniname2ctype_offset(str1070), 115},
- {-1},
- {uniname2ctype_offset(str1072), 197},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1080), 210},
- {uniname2ctype_offset(str1081), 399},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1085), 248},
- {-1},
- {uniname2ctype_offset(str1087), 567},
- {-1}, {-1},
- {uniname2ctype_offset(str1090), 69},
- {uniname2ctype_offset(str1091), 11},
- {-1},
- {uniname2ctype_offset(str1093), 125},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1097), 520},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1102), 506},
- {-1}, {-1},
- {uniname2ctype_offset(str1105), 217},
- {-1},
- {uniname2ctype_offset(str1107), 521},
- {-1},
- {uniname2ctype_offset(str1109), 228},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1119), 106},
- {uniname2ctype_offset(str1120), 60},
- {uniname2ctype_offset(str1121), 365},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1134), 410},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1140), 93},
- {-1},
- {uniname2ctype_offset(str1142), 206},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1146), 131},
- {uniname2ctype_offset(str1147), 255},
- {-1},
- {uniname2ctype_offset(str1149), 158},
- {uniname2ctype_offset(str1150), 98},
- {uniname2ctype_offset(str1151), 483},
- {uniname2ctype_offset(str1152), 217},
- {uniname2ctype_offset(str1153), 138},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1157), 203},
- {uniname2ctype_offset(str1158), 166},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1164), 229},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1168), 104},
- {-1},
- {uniname2ctype_offset(str1170), 374},
- {uniname2ctype_offset(str1171), 515},
- {-1}, {-1},
- {uniname2ctype_offset(str1174), 312},
- {uniname2ctype_offset(str1175), 26},
- {uniname2ctype_offset(str1176), 208},
- {uniname2ctype_offset(str1177), 74},
- {uniname2ctype_offset(str1178), 338},
- {-1},
- {uniname2ctype_offset(str1180), 183},
- {uniname2ctype_offset(str1181), 151},
- {uniname2ctype_offset(str1182), 344},
- {uniname2ctype_offset(str1183), 101},
- {-1},
- {uniname2ctype_offset(str1185), 170},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1190), 261},
- {uniname2ctype_offset(str1191), 524},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1197), 101},
- {uniname2ctype_offset(str1198), 135},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1203), 351},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1207), 447},
- {uniname2ctype_offset(str1208), 239},
- {uniname2ctype_offset(str1209), 186},
- {uniname2ctype_offset(str1210), 137},
- {-1},
- {uniname2ctype_offset(str1212), 364},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1227), 232},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1231), 206},
- {uniname2ctype_offset(str1232), 340},
- {uniname2ctype_offset(str1233), 73},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1234), 287},
- {uniname2ctype_offset(str1235), 289},
- {uniname2ctype_offset(str1236), 286},
- {uniname2ctype_offset(str1237), 288},
- {-1}, {-1}, {-1}, {-1}, {-1},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1243), 25},
- {uniname2ctype_offset(str1244), 326},
- {uniname2ctype_offset(str1245), 249},
- {uniname2ctype_offset(str1246), 420},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1247), 268},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1248), 30},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1249), 275},
- {uniname2ctype_offset(str1250), 270},
- {uniname2ctype_offset(str1251), 274},
- {uniname2ctype_offset(str1252), 269},
- {uniname2ctype_offset(str1253), 285},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1254), 540},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1255), 280},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1256), 267},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1257), 279},
- {uniname2ctype_offset(str1258), 281},
- {uniname2ctype_offset(str1259), 272},
- {uniname2ctype_offset(str1260), 284},
- {uniname2ctype_offset(str1261), 271},
- {uniname2ctype_offset(str1262), 273},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1263), 64},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1264), 283},
- {-1},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1266), 21},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1267), 282},
- {uniname2ctype_offset(str1268), 277},
- {-1},
- {uniname2ctype_offset(str1270), 276},
- {uniname2ctype_offset(str1271), 278},
- {-1}, {-1},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1274), 200},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1282), 596},
- {-1}, {-1},
- {uniname2ctype_offset(str1285), 105},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1289), 333},
- {-1}, {-1},
- {uniname2ctype_offset(str1292), 382},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1297), 145},
- {-1}, {-1},
- {uniname2ctype_offset(str1300), 86},
- {uniname2ctype_offset(str1301), 141},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1306), 15},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1314), 193},
- {-1}, {-1},
- {uniname2ctype_offset(str1317), 86},
- {-1},
- {uniname2ctype_offset(str1319), 256},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str1331), 252},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1340), 105},
- {-1}, {-1},
- {uniname2ctype_offset(str1343), 120},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str1354), 164},
- {uniname2ctype_offset(str1355), 254},
- {-1}, {-1},
- {uniname2ctype_offset(str1358), 594},
- {-1},
- {uniname2ctype_offset(str1360), 3},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1365), 372},
- {uniname2ctype_offset(str1366), 36},
- {uniname2ctype_offset(str1367), 513},
- {-1},
- {uniname2ctype_offset(str1369), 247},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1373), 263},
- {-1},
- {uniname2ctype_offset(str1375), 135},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1380), 35},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1384), 56},
- {-1}, {-1},
- {uniname2ctype_offset(str1387), 113},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1400), 201},
- {uniname2ctype_offset(str1401), 385},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1407), 224},
- {-1},
- {uniname2ctype_offset(str1409), 38},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1419), 140},
- {uniname2ctype_offset(str1420), 140},
- {-1},
- {uniname2ctype_offset(str1422), 310},
- {uniname2ctype_offset(str1423), 143},
- {-1}, {-1},
- {uniname2ctype_offset(str1426), 39},
- {-1},
- {uniname2ctype_offset(str1428), 181},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1434), 143},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1438), 422},
- {-1}, {-1},
- {uniname2ctype_offset(str1441), 215},
- {uniname2ctype_offset(str1442), 523},
- {-1}, {-1},
- {uniname2ctype_offset(str1445), 253},
- {-1}, {-1},
- {uniname2ctype_offset(str1448), 491},
- {uniname2ctype_offset(str1449), 122},
- {uniname2ctype_offset(str1450), 134},
- {uniname2ctype_offset(str1451), 203},
- {-1}, {-1},
- {uniname2ctype_offset(str1454), 145},
- {-1}, {-1},
- {uniname2ctype_offset(str1457), 166},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1462), 535},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1466), 241},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1470), 490},
- {uniname2ctype_offset(str1471), 492},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1475), 414},
- {uniname2ctype_offset(str1476), 494},
- {-1},
- {uniname2ctype_offset(str1478), 436},
- {-1}, {-1},
- {uniname2ctype_offset(str1481), 138},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1485), 328},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1489), 33},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1495), 251},
- {-1},
- {uniname2ctype_offset(str1497), 484},
- {uniname2ctype_offset(str1498), 199},
- {uniname2ctype_offset(str1499), 582},
- {-1},
- {uniname2ctype_offset(str1501), 196},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1507), 122},
- {-1},
- {uniname2ctype_offset(str1509), 110},
- {-1}, {-1},
- {uniname2ctype_offset(str1512), 110},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1517), 581},
- {-1},
- {uniname2ctype_offset(str1519), 219},
- {uniname2ctype_offset(str1520), 228},
- {-1}, {-1},
- {uniname2ctype_offset(str1523), 117},
- {uniname2ctype_offset(str1524), 471},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1529), 120},
- {-1},
- {uniname2ctype_offset(str1531), 407},
- {-1},
- {uniname2ctype_offset(str1533), 142},
- {-1},
- {uniname2ctype_offset(str1535), 219},
- {uniname2ctype_offset(str1536), 127},
- {uniname2ctype_offset(str1537), 260},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1542), 453},
- {-1},
- {uniname2ctype_offset(str1544), 561},
- {-1}, {-1},
- {uniname2ctype_offset(str1547), 168},
- {uniname2ctype_offset(str1548), 518},
- {uniname2ctype_offset(str1549), 505},
- {-1}, {-1},
- {uniname2ctype_offset(str1552), 117},
- {-1}, {-1},
- {uniname2ctype_offset(str1555), 107},
- {-1},
- {uniname2ctype_offset(str1557), 85},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1563), 264},
- {-1},
- {uniname2ctype_offset(str1565), 315},
- {-1},
- {uniname2ctype_offset(str1567), 148},
- {-1},
- {uniname2ctype_offset(str1569), 236},
- {-1}, {-1},
- {uniname2ctype_offset(str1572), 115},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1580), 131},
- {-1},
- {uniname2ctype_offset(str1582), 148},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1587), 529},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1594), 114},
- {-1}, {-1},
- {uniname2ctype_offset(str1597), 81},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1602), 97},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1607), 97},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1613), 164},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1617), 488},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1622), 373},
- {uniname2ctype_offset(str1623), 546},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1629), 39},
- {-1},
- {uniname2ctype_offset(str1631), 176},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1635), 72},
- {-1}, {-1},
- {uniname2ctype_offset(str1638), 426},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1643), 62},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str1654), 388},
- {uniname2ctype_offset(str1655), 265},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1662), 129},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1671), 114},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1675), 457},
- {uniname2ctype_offset(str1676), 176},
- {uniname2ctype_offset(str1677), 303},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1682), 595},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1686), 93},
- {uniname2ctype_offset(str1687), 141},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1691), 124},
- {uniname2ctype_offset(str1692), 121},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1699), 367},
- {-1}, {-1},
- {uniname2ctype_offset(str1702), 510},
- {uniname2ctype_offset(str1703), 533},
- {uniname2ctype_offset(str1704), 207},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1714), 207},
- {-1},
- {uniname2ctype_offset(str1716), 419},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1722), 347},
- {-1},
- {uniname2ctype_offset(str1724), 554},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1728), 221},
- {uniname2ctype_offset(str1729), 430},
- {uniname2ctype_offset(str1730), 222},
- {uniname2ctype_offset(str1731), 517},
- {uniname2ctype_offset(str1732), 238},
- {uniname2ctype_offset(str1733), 123},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1740), 129},
- {-1},
- {uniname2ctype_offset(str1742), 161},
- {-1}, {-1},
- {uniname2ctype_offset(str1745), 509},
- {uniname2ctype_offset(str1746), 390},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1750), 20},
- {-1},
- {uniname2ctype_offset(str1752), 502},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1757), 501},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1766), 73},
- {-1}, {-1},
- {uniname2ctype_offset(str1769), 362},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1776), 126},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1780), 65},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1788), 137},
- {-1}, {-1},
- {uniname2ctype_offset(str1791), 233},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1806), 336},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1810), 599},
- {uniname2ctype_offset(str1811), 236},
- {-1},
- {uniname2ctype_offset(str1813), 255},
- {-1}, {-1},
- {uniname2ctype_offset(str1816), 565},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1821), 224},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1825), 258},
- {uniname2ctype_offset(str1826), 202},
- {-1},
- {uniname2ctype_offset(str1828), 387},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1838), 585},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1842), 379},
- {uniname2ctype_offset(str1843), 134},
- {-1}, {-1},
- {uniname2ctype_offset(str1846), 481},
- {-1},
- {uniname2ctype_offset(str1848), 109},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1861), 202},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1866), 61},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1871), 479},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1878), 27},
- {-1}, {-1},
- {uniname2ctype_offset(str1881), 63},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1891), 150},
- {uniname2ctype_offset(str1892), 562},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1896), 588},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1904), 440},
- {uniname2ctype_offset(str1905), 559},
- {uniname2ctype_offset(str1906), 150},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1911), 343},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1915), 165},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1928), 424},
- {uniname2ctype_offset(str1929), 417},
- {uniname2ctype_offset(str1930), 445},
- {-1},
- {uniname2ctype_offset(str1932), 400},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1936), 323},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str1947), 194},
- {-1}, {-1},
- {uniname2ctype_offset(str1950), 409},
- {uniname2ctype_offset(str1951), 12},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1958), 109},
- {-1}, {-1},
- {uniname2ctype_offset(str1961), 103},
- {-1}, {-1},
- {uniname2ctype_offset(str1964), 425},
- {-1}, {-1},
- {uniname2ctype_offset(str1967), 477},
- {uniname2ctype_offset(str1968), 603},
- {-1}, {-1},
- {uniname2ctype_offset(str1971), 153},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1985), 393},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1991), 1},
- {-1},
- {uniname2ctype_offset(str1993), 360},
- {uniname2ctype_offset(str1994), 175},
- {-1},
- {uniname2ctype_offset(str1996), 42},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2006), 395},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2010), 363},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2014), 322},
- {-1},
- {uniname2ctype_offset(str2016), 209},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2023), 32},
- {uniname2ctype_offset(str2024), 489},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2033), 78},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2043), 17},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2048), 92},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2055), 92},
- {-1}, {-1},
- {uniname2ctype_offset(str2058), 240},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2062), 130},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2070), 9},
- {-1}, {-1},
- {uniname2ctype_offset(str2073), 330},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2078), 245},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2083), 324},
- {uniname2ctype_offset(str2084), 154},
- {uniname2ctype_offset(str2085), 20},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2093), 192},
- {-1},
- {uniname2ctype_offset(str2095), 341},
- {-1},
- {uniname2ctype_offset(str2097), 214},
- {uniname2ctype_offset(str2098), 8},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2102), 43},
- {uniname2ctype_offset(str2103), 162},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2109), 215},
- {uniname2ctype_offset(str2110), 123},
- {-1},
- {uniname2ctype_offset(str2112), 210},
- {-1},
- {uniname2ctype_offset(str2114), 159},
- {-1}, {-1},
- {uniname2ctype_offset(str2117), 174},
- {-1},
- {uniname2ctype_offset(str2119), 216},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2135), 128},
- {-1},
- {uniname2ctype_offset(str2137), 172},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2145), 52},
- {uniname2ctype_offset(str2146), 401},
- {-1}, {-1},
- {uniname2ctype_offset(str2149), 221},
- {uniname2ctype_offset(str2150), 121},
- {-1}, {-1},
- {uniname2ctype_offset(str2153), 352},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2161), 233},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2165), 174},
- {uniname2ctype_offset(str2166), 5},
- {uniname2ctype_offset(str2167), 112},
- {-1}, {-1},
- {uniname2ctype_offset(str2170), 216},
- {-1}, {-1},
- {uniname2ctype_offset(str2173), 87},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2181), 139},
- {uniname2ctype_offset(str2182), 87},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2195), 339},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2199), 159},
- {-1},
- {uniname2ctype_offset(str2201), 89},
- {-1}, {-1},
- {uniname2ctype_offset(str2204), 369},
- {-1}, {-1},
- {uniname2ctype_offset(str2207), 196},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2217), 128},
- {uniname2ctype_offset(str2218), 526},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2222), 458},
- {-1},
- {uniname2ctype_offset(str2224), 438},
- {uniname2ctype_offset(str2225), 459},
- {-1}, {-1},
- {uniname2ctype_offset(str2228), 82},
- {uniname2ctype_offset(str2229), 35},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2235), 474},
- {-1}, {-1},
- {uniname2ctype_offset(str2238), 154},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2244), 428},
- {-1}, {-1},
- {uniname2ctype_offset(str2247), 36},
- {uniname2ctype_offset(str2248), 569},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2252), 240},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2258), 443},
- {-1},
- {uniname2ctype_offset(str2260), 235},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2268), 597},
- {-1}, {-1},
- {uniname2ctype_offset(str2271), 18},
- {uniname2ctype_offset(str2272), 254},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2278), 124},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2282), 230},
- {-1}, {-1},
- {uniname2ctype_offset(str2285), 38},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2294), 88},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2302), 368},
- {-1}, {-1},
- {uniname2ctype_offset(str2305), 205},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2312), 177},
- {-1}, {-1},
- {uniname2ctype_offset(str2315), 568},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2321), 370},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2339), 600},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2343), 560},
- {uniname2ctype_offset(str2344), 82},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2357), 237},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2361), 571},
- {-1}, {-1},
- {uniname2ctype_offset(str2364), 309},
- {uniname2ctype_offset(str2365), 403},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2373), 37},
- {uniname2ctype_offset(str2374), 377},
- {uniname2ctype_offset(str2375), 197},
- {-1}, {-1},
- {uniname2ctype_offset(str2378), 237},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2389), 204},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2396), 376},
- {uniname2ctype_offset(str2397), 406},
- {uniname2ctype_offset(str2398), 398},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2415), 402},
- {uniname2ctype_offset(str2416), 366},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2427), 23},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2433), 427},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2440), 100},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2451), 29},
- {-1}, {-1},
- {uniname2ctype_offset(str2454), 220},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2458), 495},
- {-1},
- {uniname2ctype_offset(str2460), 246},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2470), 433},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2475), 142},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2479), 346},
- {uniname2ctype_offset(str2480), 50},
- {uniname2ctype_offset(str2481), 371},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2506), 511},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2513), 592},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2519), 466},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2529), 165},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2534), 325},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2540), 226},
- {-1},
- {uniname2ctype_offset(str2542), 125},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2548), 118},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2552), 462},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2561), 435},
- {uniname2ctype_offset(str2562), 251},
- {-1},
- {uniname2ctype_offset(str2564), 357},
- {-1},
- {uniname2ctype_offset(str2566), 185},
- {uniname2ctype_offset(str2567), 304},
- {-1}, {-1},
- {uniname2ctype_offset(str2570), 476},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2575), 185},
- {uniname2ctype_offset(str2576), 99},
- {-1}, {-1},
- {uniname2ctype_offset(str2579), 133},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2586), 199},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2595), 327},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2603), 198},
- {-1}, {-1},
- {uniname2ctype_offset(str2606), 359},
- {-1}, {-1},
- {uniname2ctype_offset(str2609), 55},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2614), 538},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2624), 226},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2631), 107},
- {-1}, {-1},
- {uniname2ctype_offset(str2634), 266},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2643), 437},
- {uniname2ctype_offset(str2644), 576},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2648), 243},
- {-1},
- {uniname2ctype_offset(str2650), 78},
- {-1}, {-1},
- {uniname2ctype_offset(str2653), 183},
- {-1}, {-1},
- {uniname2ctype_offset(str2656), 353},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2663), 182},
- {-1},
- {uniname2ctype_offset(str2665), 83},
- {-1}, {-1},
- {uniname2ctype_offset(str2668), 94},
- {-1},
- {uniname2ctype_offset(str2670), 593},
- {-1}, {-1},
- {uniname2ctype_offset(str2673), 84},
- {-1}, {-1},
- {uniname2ctype_offset(str2676), 83},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str2688), 139},
- {-1}, {-1},
- {uniname2ctype_offset(str2691), 84},
- {uniname2ctype_offset(str2692), 211},
- {-1},
- {uniname2ctype_offset(str2694), 48},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2698), 119},
- {-1}, {-1},
- {uniname2ctype_offset(str2701), 418},
- {uniname2ctype_offset(str2702), 89},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2721), 198},
- {-1},
- {uniname2ctype_offset(str2723), 4},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2732), 130},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2747), 54},
- {-1}, {-1},
- {uniname2ctype_offset(str2750), 534},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2760), 152},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2764), 241},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2768), 90},
- {uniname2ctype_offset(str2769), 468},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2777), 28},
- {-1}, {-1},
- {uniname2ctype_offset(str2780), 227},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2793), 34},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2816), 296},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2821), 378},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2834), 349},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2841), 222},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2848), 253},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2852), 291},
- {-1}, {-1},
- {uniname2ctype_offset(str2855), 190},
- {uniname2ctype_offset(str2856), 66},
- {-1}, {-1},
- {uniname2ctype_offset(str2859), 412},
- {-1}, {-1},
- {uniname2ctype_offset(str2862), 211},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2867), 295},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2871), 243},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str2883), 242},
- {-1},
- {uniname2ctype_offset(str2885), 147},
- {uniname2ctype_offset(str2886), 133},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2904), 449},
- {uniname2ctype_offset(str2905), 262},
- {uniname2ctype_offset(str2906), 575},
- {-1}, {-1},
- {uniname2ctype_offset(str2909), 549},
- {-1}, {-1},
- {uniname2ctype_offset(str2912), 244},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2926), 51},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str2938), 242},
- {-1}, {-1},
- {uniname2ctype_offset(str2941), 348},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2963), 225},
- {uniname2ctype_offset(str2964), 503},
- {-1}, {-1},
- {uniname2ctype_offset(str2967), 43},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2980), 195},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2984), 547},
- {-1},
- {uniname2ctype_offset(str2986), 118},
- {uniname2ctype_offset(str2987), 54},
- {uniname2ctype_offset(str2988), 456},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2993), 234},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3000), 16},
- {uniname2ctype_offset(str3001), 180},
- {uniname2ctype_offset(str3002), 64},
- {-1}, {-1},
- {uniname2ctype_offset(str3005), 460},
- {uniname2ctype_offset(str3006), 555},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3012), 80},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3028), 250},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3045), 577},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3055), 454},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3089), 146},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3098), 580},
- {uniname2ctype_offset(str3099), 463},
- {uniname2ctype_offset(str3100), 103},
- {uniname2ctype_offset(str3101), 223},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3107), 299},
- {-1},
- {uniname2ctype_offset(str3109), 301},
- {-1},
- {uniname2ctype_offset(str3111), 191},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3125), 191},
- {uniname2ctype_offset(str3126), 99},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3134), 223},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3158), 314},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3165), 439},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3169), 47},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3176), 381},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3180), 317},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3185), 126},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3194), 204},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3205), 227},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3209), 62},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3215), 180},
- {-1}, {-1},
- {uniname2ctype_offset(str3218), 201},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3237), 375},
- {-1},
- {uniname2ctype_offset(str3239), 294},
- {uniname2ctype_offset(str3240), 290},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3248), 213},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3254), 190},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3266), 421},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3286), 235},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3297), 297},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3303), 293},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3309), 178},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3317), 249},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3328), 63},
- {uniname2ctype_offset(str3329), 587},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3348), 392},
- {uniname2ctype_offset(str3349), 423},
- {-1},
- {uniname2ctype_offset(str3351), 96},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3360), 234},
- {-1}, {-1},
- {uniname2ctype_offset(str3363), 96},
- {-1},
- {uniname2ctype_offset(str3365), 578},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3433), 205},
- {-1}, {-1},
- {uniname2ctype_offset(str3436), 213},
- {-1}, {-1},
- {uniname2ctype_offset(str3439), 49},
- {-1}, {-1},
- {uniname2ctype_offset(str3442), 464},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3458), 10},
- {-1},
- {uniname2ctype_offset(str3460), 589},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3511), 396},
- {uniname2ctype_offset(str3512), 487},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3517), 179},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3531), 153},
- {uniname2ctype_offset(str3532), 550},
- {uniname2ctype_offset(str3533), 57},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3550), 41},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3558), 59},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3613), 214},
- {uniname2ctype_offset(str3614), 220},
- {-1},
- {uniname2ctype_offset(str3616), 45},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3628), 71},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3648), 450},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3664), 177},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3703), 132},
- {-1},
- {uniname2ctype_offset(str3705), 306},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3714), 132},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3766), 452},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3791), 65},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3805), 250},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3819), 162},
- {-1},
- {uniname2ctype_offset(str3821), 292},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3842), 182},
- {-1}, {-1},
- {uniname2ctype_offset(str3845), 248},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3891), 30},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3924), 405},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3942), 100},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3976), 570},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3995), 147},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str4087), 415},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4109), 119},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4137), 244},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4162), 544},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4175), 545},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4203), 80},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4254), 116},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4276), 116},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4291), 302},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str4321), 75},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str4360), 231},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4397), 386},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4405), 298},
- {uniname2ctype_offset(str4406), 300},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4460), 90},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4485), 179},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4528), 46},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str4674), 601},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4683), 451},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4772), 394},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4948), 590},
-#endif /* USE_UNICODE_PROPERTIES */
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#ifndef USE_UNICODE_PROPERTIES
- {uniname2ctype_offset(str6), 12},
- {uniname2ctype_offset(str7), 7},
- {uniname2ctype_offset(str8), 15},
- {uniname2ctype_offset(str9), 1},
- {uniname2ctype_offset(str10), 13},
- {uniname2ctype_offset(str11), 11},
- {uniname2ctype_offset(str12), 10},
- {uniname2ctype_offset(str13), 14},
- {uniname2ctype_offset(str14), 3},
- {uniname2ctype_offset(str15), 9},
- {uniname2ctype_offset(str16), 8},
- {uniname2ctype_offset(str17), 6},
- {uniname2ctype_offset(str18), 5},
- {uniname2ctype_offset(str19), 4},
- {uniname2ctype_offset(str20), 2}
-#else /* USE_UNICODE_PROPERTIES */
- {uniname2ctype_offset(str4955), 155},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4986), 413},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str5114), 225},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str5608), 155},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str6098), 602}
-#endif /* USE_UNICODE_PROPERTIES */
- };
-
- if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
- {
- register unsigned int key = uniname2ctype_hash (str, len);
-
- if (key <= MAX_HASH_VALUE)
- {
- register int o = wordlist[key].name;
- if (o >= 0)
- {
- register const char *s = o + uniname2ctype_pool;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &wordlist[key];
- }
- }
- }
- return 0;
-}
-
-static int
-uniname2ctype(const UChar *name, unsigned int len)
-{
- const struct uniname2ctype_struct *p = uniname2ctype_p((const char *)name, len);
- if (p) return p->ctype;
- return -1;
-}
-#if defined ONIG_UNICODE_VERSION_STRING && !( \
- ONIG_UNICODE_VERSION_MAJOR == 12 && \
- ONIG_UNICODE_VERSION_MINOR == 1 && \
- ONIG_UNICODE_VERSION_TEENY == 0 && \
- 1)
-# error ONIG_UNICODE_VERSION_STRING mismatch
-#endif
-#define ONIG_UNICODE_VERSION_STRING "12.1.0"
-#define ONIG_UNICODE_VERSION_MAJOR 12
-#define ONIG_UNICODE_VERSION_MINOR 1
-#define ONIG_UNICODE_VERSION_TEENY 0
-#if defined ONIG_UNICODE_EMOJI_VERSION_STRING && !( \
- ONIG_UNICODE_EMOJI_VERSION_MAJOR == 12 && \
- ONIG_UNICODE_EMOJI_VERSION_MINOR == 0 && \
- 1)
-# error ONIG_UNICODE_EMOJI_VERSION_STRING mismatch
-#endif
-#define ONIG_UNICODE_EMOJI_VERSION_STRING "12.0"
-#define ONIG_UNICODE_EMOJI_VERSION_MAJOR 12
-#define ONIG_UNICODE_EMOJI_VERSION_MINOR 0
diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb
index 362d6ebfd9..829efefaf1 100755
--- a/enc/unicode/case-folding.rb
+++ b/enc/unicode/case-folding.rb
@@ -264,6 +264,7 @@ class CaseMapping
from = Array(from).map {|i| "%04X" % i}.join(" ")
to = Array(to).map {|i| "%04X" % i}.join(" ")
item = map(from)
+ specials_index = nil
specials = []
case type
when 'CaseFold_11'
@@ -308,7 +309,7 @@ class CaseMapping
end
unless item.upper == item.title
if item.code == item.title
- flags += '|IT' # was unpredicted case 1
+ raise "Unpredicted case 1 in enc/unicode/case_folding.rb. Please contact https://bugs.ruby-lang.org/."
elsif item.title==to[1]
flags += '|ST'
else
@@ -409,8 +410,8 @@ if $0 == __FILE__
s = f.string
end
if dest
- open(dest, "wb") do |file|
- file.print(s)
+ open(dest, "wb") do |f|
+ f.print(s)
end
else
STDOUT.print(s)
diff --git a/enc/x_emoji.h b/enc/x_emoji.h
index c0a3613f1b..23efa1dd9e 100644
--- a/enc/x_emoji.h
+++ b/enc/x_emoji.h
@@ -2,8 +2,8 @@
/*
* Name: UTF8-DoCoMo, SJIS-DoCoMo
- * Link: https://www.nttdocomo.co.jp/service/developer/make/content/pictograph/basic/index.html
- * Link: https://www.nttdocomo.co.jp/service/developer/make/content/pictograph/extent%69on/index.html
+ * Link: https://www.nttdocomo.co.jp/english/service/developer/make/content/pictograph/basic/index.html
+ * Link: https://www.nttdocomo.co.jp/english/service/developer/make/content/pictograph/extention/index.html
*/
ENC_REPLICATE("UTF8-DoCoMo", "UTF-8")
ENC_REPLICATE("SJIS-DoCoMo", "Windows-31J")
diff --git a/encoding.c b/encoding.c
index 69015cc8fd..2043a69598 100644
--- a/encoding.c
+++ b/encoding.c
@@ -9,7 +9,6 @@
**********************************************************************/
-#include "ruby/encoding.h"
#include "internal.h"
#include "encindex.h"
#include "regenc.h"
@@ -20,7 +19,7 @@
#ifndef ENC_DEBUG
#define ENC_DEBUG 0
#endif
-#define ENC_ASSERT(expr) RUBY_ASSERT_WHEN(ENC_DEBUG, expr)
+#define ENC_ASSERT (!ENC_DEBUG)?(void)0:assert
#define MUST_STRING(str) (ENC_ASSERT(RB_TYPE_P(str, T_STRING)), str)
#undef rb_ascii8bit_encindex
@@ -66,6 +65,8 @@ static struct {
#define ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG)
#define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG)
+void rb_enc_init(void);
+
#define ENCODING_COUNT ENCINDEX_BUILTIN_MAX
#define UNSPECIFIED_ENCODING INT_MAX
@@ -258,6 +259,11 @@ rb_find_encoding(VALUE enc)
return rb_enc_from_index(idx);
}
+void
+rb_gc_mark_encodings(void)
+{
+}
+
static int
enc_table_expand(int newsize)
{
@@ -266,7 +272,8 @@ enc_table_expand(int newsize)
if (enc_table.size >= newsize) return newsize;
newsize = (newsize + 7) / 8 * 8;
- ent = REALLOC_N(enc_table.list, struct rb_encoding_entry, newsize);
+ ent = realloc(enc_table.list, sizeof(*enc_table.list) * newsize);
+ if (!ent) return -1;
memset(ent + enc_table.size, 0, sizeof(*ent)*(newsize - enc_table.size));
enc_table.list = ent;
enc_table.size = newsize;
@@ -440,9 +447,6 @@ enc_replicate_with_index(const char *name, rb_encoding *origenc, int idx)
set_base_encoding(idx, origenc);
set_encoding_const(name, rb_enc_from_index(idx));
}
- else {
- rb_raise(rb_eArgError, "failed to replicate encoding");
- }
return idx;
}
@@ -555,6 +559,9 @@ rb_enc_alias(const char *alias, const char *orig)
int idx;
enc_check_duplication(alias);
+ if (!enc_table.list) {
+ rb_enc_init();
+ }
if ((idx = rb_enc_find_index(orig)) < 0) {
return -1;
}
@@ -608,7 +615,10 @@ rb_enc_init(void)
rb_encoding *
rb_enc_from_index(int index)
{
- if (UNLIKELY(index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK))) {
+ if (!enc_table.list) {
+ rb_enc_init();
+ }
+ if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) {
return 0;
}
return enc_table.list[index].enc;
@@ -649,11 +659,12 @@ load_encoding(const char *name)
else if (ISUPPER(*s)) *s = (char)TOLOWER(*s);
++s;
}
- enclib = rb_fstring(enclib);
+ FL_UNSET(enclib, FL_TAINT);
+ OBJ_FREEZE(enclib);
ruby_verbose = Qfalse;
ruby_debug = Qfalse;
errinfo = rb_errinfo();
- loaded = rb_require_internal(enclib);
+ loaded = rb_require_internal(enclib, rb_safe_level());
ruby_verbose = verbose;
ruby_debug = debug;
rb_set_errinfo(errinfo);
@@ -749,12 +760,6 @@ enc_capable(VALUE obj)
}
}
-int
-rb_enc_capable(VALUE obj)
-{
- return enc_capable(obj);
-}
-
ID
rb_id_encoding(void)
{
@@ -786,26 +791,24 @@ rb_enc_get_index(VALUE obj)
obj = rb_sym2str(obj);
}
switch (BUILTIN_TYPE(obj)) {
+ as_default:
+ default:
case T_STRING:
- case T_SYMBOL:
case T_REGEXP:
i = enc_get_index_str(obj);
break;
case T_FILE:
tmp = rb_funcallv(obj, rb_intern("internal_encoding"), 0, 0);
- if (NIL_P(tmp)) {
- tmp = rb_funcallv(obj, rb_intern("external_encoding"), 0, 0);
- }
- if (is_obj_encoding(tmp)) {
- i = enc_check_encoding(tmp);
- }
- break;
+ if (NIL_P(tmp)) obj = rb_funcallv(obj, rb_intern("external_encoding"), 0, 0);
+ else obj = tmp;
+ if (NIL_P(obj)) break;
case T_DATA:
if (is_data_encoding(obj)) {
i = enc_check_encoding(obj);
}
- break;
- default:
+ else {
+ goto as_default;
+ }
break;
}
return i;
@@ -814,10 +817,6 @@ rb_enc_get_index(VALUE obj)
static void
enc_set_index(VALUE obj, int idx)
{
- if (!enc_capable(obj)) {
- rb_raise(rb_eArgError, "cannot set encoding on non-encoding capable object");
- }
-
if (idx < ENCODING_INLINE_MAX) {
ENCODING_SET_INLINED(obj, idx);
return;
@@ -1162,7 +1161,8 @@ enc_names_i(st_data_t name, st_data_t idx, st_data_t args)
VALUE *arg = (VALUE *)args;
if ((int)idx == (int)arg[0]) {
- VALUE str = rb_fstring_cstr((char *)name);
+ VALUE str = rb_usascii_str_new2((char *)name);
+ OBJ_FREEZE(str);
rb_ary_push(arg[1], str);
}
return ST_CONTINUE;
@@ -1174,7 +1174,7 @@ enc_names_i(st_data_t name, st_data_t idx, st_data_t args)
*
* Returns the list of name and aliases of the encoding.
*
- * Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"]
+ * Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J"]
*/
static VALUE
enc_names(VALUE self)
@@ -1315,6 +1315,9 @@ enc_m_loader(VALUE klass, VALUE str)
rb_encoding *
rb_ascii8bit_encoding(void)
{
+ if (!enc_table.list) {
+ rb_enc_init();
+ }
return enc_table.list[ENCINDEX_ASCII].enc;
}
@@ -1327,6 +1330,9 @@ rb_ascii8bit_encindex(void)
rb_encoding *
rb_utf8_encoding(void)
{
+ if (!enc_table.list) {
+ rb_enc_init();
+ }
return enc_table.list[ENCINDEX_UTF_8].enc;
}
@@ -1339,6 +1345,9 @@ rb_utf8_encindex(void)
rb_encoding *
rb_usascii_encoding(void)
{
+ if (!enc_table.list) {
+ rb_enc_init();
+ }
return enc_table.list[ENCINDEX_US_ASCII].enc;
}
@@ -1547,7 +1556,7 @@ rb_enc_default_internal(void)
* Additionally String#encode and String#encode! use the default internal
* encoding if no encoding is given.
*
- * The script encoding (__ENCODING__), not default_internal, is used as the
+ * The locale encoding (__ENCODING__), not default_internal, is used as the
* encoding of created strings.
*
* Encoding::default_internal is initialized by the source file's
@@ -1687,7 +1696,8 @@ rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
str = rb_fstring_cstr(rb_enc_name(enc));
rb_ary_store(ary, idx, str);
}
- key = rb_fstring_cstr((char *)name);
+ key = rb_usascii_str_new2((char *)name);
+ OBJ_FREEZE(key);
rb_hash_aset(aliases, key, str);
return ST_CONTINUE;
}
@@ -1699,8 +1709,8 @@ rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
* Returns the hash of available encoding alias and original encoding name.
*
* Encoding.aliases
- * #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1968"=>"US-ASCII",
- * "SJIS"=>"Windows-31J", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
+ * #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1986"=>"US-ASCII",
+ * "SJIS"=>"Shift_JIS", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
*
*/
@@ -1740,11 +1750,11 @@ rb_enc_aliases(VALUE klass)
* "some string".encode "ISO-8859-1"
* #=> "some string"
*
- * Encoding::ASCII_8BIT is a special encoding that is usually used for
- * a byte string, not a character string. But as the name insists, its
- * characters in the range of ASCII are considered as ASCII
- * characters. This is useful when you use ASCII-8BIT characters with
- * other ASCII compatible characters.
+ * <code>Encoding::ASCII_8BIT</code> is a special encoding that is usually
+ * used for a byte string, not a character string. But as the name insists,
+ * its characters in the range of ASCII are considered as ASCII characters.
+ * This is useful when you use ASCII-8BIT characters with other ASCII
+ * compatible characters.
*
* == Changing an encoding
*
@@ -1782,12 +1792,11 @@ rb_enc_aliases(VALUE klass)
* All Ruby script code has an associated Encoding which any String literal
* created in the source code will be associated to.
*
- * The default script encoding is Encoding::UTF_8 after v2.0, but it
- * can be changed by a magic comment on the first line of the source
- * code file (or second line, if there is a shebang line on the
- * first). The comment must contain the word <code>coding</code> or
- * <code>encoding</code>, followed by a colon, space and the Encoding
- * name or alias:
+ * The default script encoding is <code>Encoding::UTF-8</code> after v2.0, but it can
+ * be changed by a magic comment on the first line of the source code file (or
+ * second line, if there is a shebang line on the first). The comment must
+ * contain the word <code>coding</code> or <code>encoding</code>, followed
+ * by a colon, space and the Encoding name or alias:
*
* # encoding: UTF-8
*
@@ -1960,12 +1969,6 @@ Init_Encoding(void)
rb_marshal_define_compat(rb_cEncoding, Qnil, NULL, enc_m_loader);
}
-void
-Init_encodings(void)
-{
- rb_enc_init();
-}
-
/* locale insensitive ctype functions */
void
diff --git a/enum.c b/enum.c
index de4d22d92e..86e6125e25 100644
--- a/enum.c
+++ b/enum.c
@@ -9,7 +9,6 @@
**********************************************************************/
-#include "ruby/encoding.h"
#include "internal.h"
#include "ruby/util.h"
#include "id.h"
@@ -20,8 +19,8 @@
VALUE rb_mEnumerable;
static ID id_next;
+static ID id_div;
-#define id_div idDiv
#define id_each idEach
#define id_eqq idEqq
#define id_cmp idCmp
@@ -277,15 +276,13 @@ find_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
*
* If no block is given, an enumerator is returned instead.
*
- * (1..100).detect #=> #<Enumerator: 1..100:detect>
- * (1..100).find #=> #<Enumerator: 1..100:find>
+ * (1..100).detect => #<Enumerator: 1..100:detect>
+ * (1..100).find => #<Enumerator: 1..100:find>
*
- * (1..10).detect { |i| i % 5 == 0 && i % 7 == 0 } #=> nil
- * (1..10).find { |i| i % 5 == 0 && i % 7 == 0 } #=> nil
- * (1..10).detect(-> {0}) { |i| i % 5 == 0 && i % 7 == 0 } #=> 0
- * (1..10).find(-> {0}) { |i| i % 5 == 0 && i % 7 == 0 } #=> 0
- * (1..100).detect { |i| i % 5 == 0 && i % 7 == 0 } #=> 35
- * (1..100).find { |i| i % 5 == 0 && i % 7 == 0 } #=> 35
+ * (1..10).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> nil
+ * (1..10).find { |i| i % 5 == 0 and i % 7 == 0 } #=> nil
+ * (1..100).detect { |i| i % 5 == 0 and i % 7 == 0 } #=> 35
+ * (1..100).find { |i| i % 5 == 0 and i % 7 == 0 } #=> 35
*
*/
@@ -295,7 +292,7 @@ enum_find(int argc, VALUE *argv, VALUE obj)
struct MEMO *memo;
VALUE if_none;
- if_none = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
+ rb_scan_args(argc, argv, "01", &if_none);
RETURN_ENUMERATOR(obj, argc, argv);
memo = MEMO_NEW(Qundef, 0, 0);
rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)memo);
@@ -349,9 +346,9 @@ find_index_iter_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
*
* If neither block nor argument is given, an enumerator is returned instead.
*
- * (1..10).find_index { |i| i % 5 == 0 && i % 7 == 0 } #=> nil
- * (1..100).find_index { |i| i % 5 == 0 && i % 7 == 0 } #=> 34
- * (1..100).find_index(50) #=> 49
+ * (1..10).find_index { |i| i % 5 == 0 and i % 7 == 0 } #=> nil
+ * (1..100).find_index { |i| i % 5 == 0 and i % 7 == 0 } #=> 34
+ * (1..100).find_index(50) #=> 49
*
*/
@@ -418,17 +415,12 @@ enum_size_over_p(VALUE obj, long n)
* call-seq:
* enum.find_all { |obj| block } -> array
* enum.select { |obj| block } -> array
- * enum.filter { |obj| block } -> array
* enum.find_all -> an_enumerator
* enum.select -> an_enumerator
- * enum.filter -> an_enumerator
*
* Returns an array containing all elements of +enum+
* for which the given +block+ returns a true value.
*
- * The <i>find_all</i> and <i>select</i> methods are aliases.
- * There is no performance benefit to either.
- *
* If no block is given, an Enumerator is returned instead.
*
*
@@ -436,9 +428,7 @@ enum_size_over_p(VALUE obj, long n)
*
* [1,2,3,4,5].select { |num| num.even? } #=> [2, 4]
*
- * [:foo, :bar].filter { |x| x == :foo } #=> [:foo]
- *
- * See also Enumerable#reject, Enumerable#grep.
+ * See also Enumerable#reject.
*/
static VALUE
@@ -455,46 +445,6 @@ enum_find_all(VALUE obj)
}
static VALUE
-filter_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
-{
- i = rb_yield_values2(argc, argv);
-
- if (RTEST(i)) {
- rb_ary_push(ary, i);
- }
-
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.filter_map { |obj| block } -> array
- * enum.filter_map -> an_enumerator
- *
- * Returns a new array containing the truthy results (everything except
- * +false+ or +nil+) of running the +block+ for every element in +enum+.
- *
- * If no block is given, an Enumerator is returned instead.
- *
- *
- * (1..10).filter_map { |i| i * 2 if i.even? } #=> [4, 8, 12, 16, 20]
- *
- */
-static VALUE
-enum_filter_map(VALUE obj)
-{
- VALUE ary;
-
- RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
-
- ary = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, filter_map_i, ary);
-
- return ary;
-}
-
-
-static VALUE
reject_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
{
ENUM_WANT_SVALUE();
@@ -546,6 +496,7 @@ collect_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
static VALUE
collect_all(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
{
+ rb_thread_check_ints();
rb_ary_push(ary, rb_enum_values_pack(argc, argv));
return Qnil;
@@ -648,55 +599,49 @@ enum_to_a(int argc, VALUE *argv, VALUE obj)
{
VALUE ary = rb_ary_new();
- rb_block_call_kw(obj, id_each, argc, argv, collect_all, ary, RB_PASS_CALLED_KEYWORDS);
+ rb_block_call(obj, id_each, argc, argv, collect_all, ary);
+ OBJ_INFECT(ary, obj);
return ary;
}
static VALUE
-enum_hashify(VALUE obj, int argc, const VALUE *argv, rb_block_call_func *iter)
-{
- VALUE hash = rb_hash_new();
- rb_block_call(obj, id_each, argc, argv, iter, hash);
- return hash;
-}
-
-static VALUE
enum_to_h_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
{
+ VALUE key_value_pair;
ENUM_WANT_SVALUE();
- return rb_hash_set_pair(hash, i);
-}
-
-static VALUE
-enum_to_h_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
-{
- return rb_hash_set_pair(hash, rb_yield_values2(argc, argv));
+ rb_thread_check_ints();
+ key_value_pair = rb_check_array_type(i);
+ if (NIL_P(key_value_pair)) {
+ rb_raise(rb_eTypeError, "wrong element type %s (expected array)",
+ rb_builtin_class_name(i));
+ }
+ if (RARRAY_LEN(key_value_pair) != 2) {
+ rb_raise(rb_eArgError, "element has wrong array length (expected 2, was %ld)",
+ RARRAY_LEN(key_value_pair));
+ }
+ rb_hash_aset(hash, RARRAY_AREF(key_value_pair, 0), RARRAY_AREF(key_value_pair, 1));
+ return Qnil;
}
/*
* call-seq:
- * enum.to_h(*args) -> hash
- * enum.to_h(*args) {...} -> hash
+ * enum.to_h(*args) -> hash
*
* Returns the result of interpreting <i>enum</i> as a list of
* <tt>[key, value]</tt> pairs.
*
* %i[hello world].each_with_index.to_h
* # => {:hello => 0, :world => 1}
- *
- * If a block is given, the results of the block on each element of
- * the enum will be used as pairs.
- *
- * (1..5).to_h {|x| [x, x ** 2]}
- * #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25}
*/
static VALUE
enum_to_h(int argc, VALUE *argv, VALUE obj)
{
- rb_block_call_func *iter = rb_block_given_p() ? enum_to_h_ii : enum_to_h_i;
- return enum_hashify(obj, argc, argv, iter);
+ VALUE hash = rb_hash_new();
+ rb_block_call(obj, id_each, argc, argv, enum_to_h_i, hash);
+ OBJ_INFECT(hash, obj);
+ return hash;
}
static VALUE
@@ -771,7 +716,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
if (FIXNUM_P(e)) {
n += FIX2LONG(e); /* should not overflow long type */
if (!FIXABLE(n)) {
- v = rb_big_plus(LONG2NUM(n), v);
+ v = rb_big_plus(ULONG2NUM(n), v);
n = 0;
}
}
@@ -790,8 +735,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
}
}
for (; i < RARRAY_LEN(ary); i++) {
- VALUE arg = RARRAY_AREF(ary, i);
- v = rb_funcallv_public(v, id, 1, &arg);
+ v = rb_funcallv_public(v, id, 1, &RARRAY_CONST_PTR(ary)[i]);
}
return v;
}
@@ -969,50 +913,15 @@ group_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
static VALUE
enum_group_by(VALUE obj)
{
- RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
+ VALUE hash;
- return enum_hashify(obj, 0, 0, group_by_i);
-}
-
-static void
-tally_up(VALUE hash, VALUE group)
-{
- VALUE tally = rb_hash_aref(hash, group);
- if (NIL_P(tally)) {
- tally = INT2FIX(1);
- }
- else if (FIXNUM_P(tally) && tally < INT2FIX(FIXNUM_MAX)) {
- tally += INT2FIX(1) & ~FIXNUM_FLAG;
- }
- else {
- tally = rb_big_plus(tally, INT2FIX(1));
- }
- rb_hash_aset(hash, group, tally);
-}
-
-static VALUE
-tally_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
-{
- ENUM_WANT_SVALUE();
- tally_up(hash, i);
- return Qnil;
-}
+ RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
-/*
- * call-seq:
- * enum.tally -> a_hash
- *
- * Tallies the collection, i.e., counts the occurrences of each element.
- * Returns a hash with the elements of the collection as keys and the
- * corresponding counts as values.
- *
- * ["a", "b", "c", "b"].tally #=> {"a"=>1, "b"=>2, "c"=>1}
- */
+ hash = rb_hash_new();
+ rb_block_call(obj, id_each, 0, 0, group_by_i, hash);
+ OBJ_INFECT(hash, obj);
-static VALUE
-enum_tally(VALUE obj)
-{
- return enum_hashify(obj, 0, 0, tally_i);
+ return hash;
}
static VALUE
@@ -1024,7 +933,7 @@ first_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, params))
MEMO_V1_SET(memo, i);
rb_iter_break();
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
static VALUE enum_take(VALUE obj, VALUE n);
@@ -1161,10 +1070,10 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
* %w{apple pear fig}.sort_by { |word| word.length }
* #=> ["fig", "pear", "apple"]
*
- * The current implementation of #sort_by generates an array of
- * tuples containing the original collection element and the mapped
- * value. This makes #sort_by fairly expensive when the keysets are
- * simple.
+ * The current implementation of <code>sort_by</code> generates an
+ * array of tuples containing the original collection element and the
+ * mapped value. This makes <code>sort_by</code> fairly expensive when
+ * the keysets are simple.
*
* require 'benchmark'
*
@@ -1183,15 +1092,15 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
*
* However, consider the case where comparing the keys is a non-trivial
* operation. The following code sorts some files on modification time
- * using the basic #sort method.
+ * using the basic <code>sort</code> method.
*
* files = Dir["*"]
* sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime }
* sorted #=> ["mon", "tues", "wed", "thurs"]
*
- * This sort is inefficient: it generates two new File
+ * This sort is inefficient: it generates two new <code>File</code>
* objects during every comparison. A slightly better technique is to
- * use the Kernel#test method to generate the modification
+ * use the <code>Kernel#test</code> method to generate the modification
* times directly.
*
* files = Dir["*"]
@@ -1200,27 +1109,23 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
* }
* sorted #=> ["mon", "tues", "wed", "thurs"]
*
- * This still generates many unnecessary Time objects. A more
- * efficient technique is to cache the sort keys (modification times
- * in this case) before the sort. Perl users often call this approach
- * a Schwartzian transform, after Randal Schwartz. We construct a
- * temporary array, where each element is an array containing our
- * sort key along with the filename. We sort this array, and then
- * extract the filename from the result.
+ * This still generates many unnecessary <code>Time</code> objects. A
+ * more efficient technique is to cache the sort keys (modification
+ * times in this case) before the sort. Perl users often call this
+ * approach a Schwartzian transform, after Randal Schwartz. We
+ * construct a temporary array, where each element is an array
+ * containing our sort key along with the filename. We sort this array,
+ * and then extract the filename from the result.
*
* sorted = Dir["*"].collect { |f|
* [test(?M, f), f]
* }.sort.collect { |f| f[1] }
* sorted #=> ["mon", "tues", "wed", "thurs"]
*
- * This is exactly what #sort_by does internally.
+ * This is exactly what <code>sort_by</code> does internally.
*
* sorted = Dir["*"].sort_by { |f| test(?M, f) }
* sorted #=> ["mon", "tues", "wed", "thurs"]
- *
- * To produce the reverse of a specific order, the following can be used:
- *
- * ary.sort_by { ... }.reverse!
*/
static VALUE
@@ -1243,6 +1148,7 @@ enum_sort_by(VALUE obj)
buf = rb_ary_tmp_new(SORT_BY_BUFSIZE*2);
rb_ary_store(buf, SORT_BY_BUFSIZE*2-1, Qnil);
memo = MEMO_NEW(0, 0, 0);
+ OBJ_INFECT(memo, obj);
data = (struct sort_by_data *)&memo->v1;
RB_OBJ_WRITE(memo, &data->ary, ary);
RB_OBJ_WRITE(memo, &data->buf, buf);
@@ -1255,9 +1161,9 @@ enum_sort_by(VALUE obj)
rb_ary_concat(ary, buf);
}
if (RARRAY_LEN(ary) > 2) {
- RARRAY_PTR_USE(ary, ptr,
- ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE),
- sort_by_cmp, (void *)ary));
+ RARRAY_PTR_USE(ary, ptr,
+ ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE),
+ sort_by_cmp, (void *)ary));
}
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
@@ -1267,6 +1173,7 @@ enum_sort_by(VALUE obj)
}
rb_ary_resize(ary, RARRAY_LEN(ary)/2);
RBASIC_SET_CLASS_RAW(ary, rb_cArray);
+ OBJ_INFECT(ary, memo);
return ary;
}
@@ -1300,12 +1207,6 @@ name##_eqq(RB_BLOCK_CALL_FUNC_ARGLIST(i, memo)) \
static VALUE \
enum_##name##_func(VALUE result, struct MEMO *memo)
-#define WARN_UNUSED_BLOCK(argc) do { \
- if ((argc) > 0 && rb_block_given_p()) { \
- rb_warn("given block not used"); \
- } \
-} while (0)
-
DEFINE_ENUMFUNCS(all)
{
if (!RTEST(result)) {
@@ -1343,7 +1244,6 @@ static VALUE
enum_all(int argc, VALUE *argv, VALUE obj)
{
struct MEMO *memo = MEMO_ENUM_NEW(Qtrue);
- WARN_UNUSED_BLOCK(argc);
rb_block_call(obj, id_each, 0, 0, ENUMFUNC(all), (VALUE)memo);
return memo->v1;
}
@@ -1385,7 +1285,6 @@ static VALUE
enum_any(int argc, VALUE *argv, VALUE obj)
{
struct MEMO *memo = MEMO_ENUM_NEW(Qfalse);
- WARN_UNUSED_BLOCK(argc);
rb_block_call(obj, id_each, 0, 0, ENUMFUNC(any), (VALUE)memo);
return memo->v1;
}
@@ -1405,23 +1304,22 @@ DEFINE_ENUMFUNCS(one)
}
struct nmin_data {
- long n;
- long bufmax;
- long curlen;
- VALUE buf;
- VALUE limit;
- int (*cmpfunc)(const void *, const void *, void *);
- int rev: 1; /* max if 1 */
- int by: 1; /* min_by if 1 */
+ long n;
+ long bufmax;
+ long curlen;
+ VALUE buf;
+ VALUE limit;
+ int (*cmpfunc)(const void *, const void *, void *);
+ int rev; /* max if 1 */
+ int by; /* min_by if 1 */
+ const char *method;
};
static VALUE
cmpint_reenter_check(struct nmin_data *data, VALUE val)
{
if (RBASIC(data->buf)->klass) {
- rb_raise(rb_eRuntimeError, "%s%s reentered",
- data->rev ? "max" : "min",
- data->by ? "_by" : "");
+ rb_raise(rb_eRuntimeError, "%s reentered", data->method);
}
return val;
}
@@ -1525,13 +1423,13 @@ nmin_filter(struct nmin_data *data)
#undef GETPTR
#undef SWAP
- data->limit = RARRAY_AREF(data->buf, store_index*eltsize); /* the last pivot */
+ data->limit = RARRAY_PTR(data->buf)[store_index*eltsize]; /* the last pivot */
data->curlen = data->n;
rb_ary_resize(data->buf, data->n * eltsize);
}
static VALUE
-nmin_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, _data))
+nmin_i(VALUE i, VALUE *_data, int argc, VALUE *argv)
{
struct nmin_data *data = (struct nmin_data *)_data;
VALUE cmpv;
@@ -1586,12 +1484,14 @@ rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary)
nmin_cmp;
data.rev = rev;
data.by = by;
+ data.method = rev ? (by ? "max_by" : "max")
+ : (by ? "min_by" : "min");
if (ary) {
long i;
for (i = 0; i < RARRAY_LEN(obj); i++) {
VALUE args[1];
args[0] = RARRAY_AREF(obj, i);
- nmin_i(obj, (VALUE)&data, 1, args, Qundef);
+ nmin_i(obj, (VALUE*)&data, 1, args);
}
}
else {
@@ -1601,22 +1501,18 @@ rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary)
result = data.buf;
if (by) {
long i;
- RARRAY_PTR_USE(result, ptr, {
- ruby_qsort(ptr,
- RARRAY_LEN(result)/2,
- sizeof(VALUE)*2,
- data.cmpfunc, (void *)&data);
- for (i=1; i<RARRAY_LEN(result); i+=2) {
- ptr[i/2] = ptr[i];
- }
- });
+ ruby_qsort(RARRAY_PTR(result),
+ RARRAY_LEN(result)/2,
+ sizeof(VALUE)*2,
+ data.cmpfunc, (void *)&data);
+ for (i=1; i<RARRAY_LEN(result); i+=2) {
+ RARRAY_PTR(result)[i/2] = RARRAY_PTR(result)[i];
+ }
rb_ary_resize(result, RARRAY_LEN(result)/2);
}
else {
- RARRAY_PTR_USE(result, ptr, {
- ruby_qsort(ptr, RARRAY_LEN(result), sizeof(VALUE),
- data.cmpfunc, (void *)&data);
- });
+ ruby_qsort(RARRAY_PTR(result), RARRAY_LEN(result), sizeof(VALUE),
+ data.cmpfunc, (void *)&data);
}
if (rev) {
rb_ary_reverse(result);
@@ -1656,7 +1552,6 @@ enum_one(int argc, VALUE *argv, VALUE obj)
struct MEMO *memo = MEMO_ENUM_NEW(Qundef);
VALUE result;
- WARN_UNUSED_BLOCK(argc);
rb_block_call(obj, id_each, 0, 0, ENUMFUNC(one), (VALUE)memo);
result = memo->v1;
if (result == Qundef) return Qfalse;
@@ -1698,8 +1593,6 @@ static VALUE
enum_none(int argc, VALUE *argv, VALUE obj)
{
struct MEMO *memo = MEMO_ENUM_NEW(Qtrue);
-
- WARN_UNUSED_BLOCK(argc);
rb_block_call(obj, id_each, 0, 0, ENUMFUNC(none), (VALUE)memo);
return memo->v1;
}
@@ -1756,7 +1649,7 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
* enum.min(n) { |a, b| block } -> array
*
* Returns the object in _enum_ with the minimum value. The
- * first form assumes all objects implement Comparable;
+ * first form assumes all objects implement <code>Comparable</code>;
* the second uses the block to return <em>a <=> b</em>.
*
* a = %w(albatross dog horse)
@@ -1780,7 +1673,9 @@ enum_min(int argc, VALUE *argv, VALUE obj)
VALUE result;
VALUE num;
- if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0]))
+ rb_scan_args(argc, argv, "01", &num);
+
+ if (!NIL_P(num))
return rb_nmin_run(obj, num, 0, 0, 0);
m->min = Qundef;
@@ -1848,7 +1743,7 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
* enum.max(n) { |a, b| block } -> array
*
* Returns the object in _enum_ with the maximum value. The
- * first form assumes all objects implement Comparable;
+ * first form assumes all objects implement <code>Comparable</code>;
* the second uses the block to return <em>a <=> b</em>.
*
* a = %w(albatross dog horse)
@@ -1872,7 +1767,9 @@ enum_max(int argc, VALUE *argv, VALUE obj)
VALUE result;
VALUE num;
- if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0]))
+ rb_scan_args(argc, argv, "01", &num);
+
+ if (!NIL_P(num))
return rb_nmin_run(obj, num, 0, 1, 0);
m->max = Qundef;
@@ -2007,7 +1904,7 @@ minmax_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
*
* Returns a two element array which contains the minimum and the
* maximum value in the enumerable. The first form assumes all
- * objects implement Comparable; the second uses the
+ * objects implement <code>Comparable</code>; the second uses the
* block to return <em>a <=> b</em>.
*
* a = %w(albatross dog horse)
@@ -2091,11 +1988,11 @@ enum_min_by(int argc, VALUE *argv, VALUE obj)
struct MEMO *memo;
VALUE num;
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", &num);
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size);
- if (argc && !NIL_P(num = argv[0]))
+ if (!NIL_P(num))
return rb_nmin_run(obj, num, 1, 0, 0);
memo = MEMO_NEW(Qundef, Qnil, 0);
@@ -2198,11 +2095,11 @@ enum_max_by(int argc, VALUE *argv, VALUE obj)
struct MEMO *memo;
VALUE num;
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", &num);
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size);
- if (argc && !NIL_P(num = argv[0]))
+ if (!NIL_P(num))
return rb_nmin_run(obj, num, 1, 1, 0);
memo = MEMO_NEW(Qundef, Qnil, 0);
@@ -2339,10 +2236,10 @@ member_i(RB_BLOCK_CALL_FUNC_ARGLIST(iter, args))
* Returns <code>true</code> if any member of <i>enum</i> equals
* <i>obj</i>. Equality is tested using <code>==</code>.
*
- * (1..10).include? 5 #=> true
- * (1..10).include? 15 #=> false
- * (1..10).member? 5 #=> true
- * (1..10).member? 15 #=> false
+ * IO.constants.include? :SEEK_SET #=> true
+ * IO.constants.include? :SEEK_NO_FURTHER #=> false
+ * IO.constants.member? :SEEK_SET #=> true
+ * IO.constants.member? :SEEK_NO_FURTHER #=> false
*
*/
@@ -2406,33 +2303,27 @@ enum_each_with_index(int argc, VALUE *argv, VALUE obj)
*
* If no block is given, an enumerator is returned instead.
*
- * (1..3).reverse_each { |v| p v }
+ * (1..3).reverse_each { |v| p v }
*
- * produces:
+ * produces:
*
- * 3
- * 2
- * 1
+ * 3
+ * 2
+ * 1
*/
static VALUE
enum_reverse_each(int argc, VALUE *argv, VALUE obj)
{
VALUE ary;
- long len;
+ long i;
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size);
ary = enum_to_a(argc, argv, obj);
- len = RARRAY_LEN(ary);
- while (len--) {
- long nlen;
- rb_yield(RARRAY_AREF(ary, len));
- nlen = RARRAY_LEN(ary);
- if (nlen < len) {
- len = nlen;
- }
+ for (i = RARRAY_LEN(ary); --i >= 0; ) {
+ rb_yield(RARRAY_AREF(ary, i));
}
return obj;
@@ -2532,15 +2423,10 @@ enum_each_slice_size(VALUE obj, VALUE args, VALUE eobj)
{
VALUE n, size;
long slice_size = NUM2LONG(RARRAY_AREF(args, 0));
- ID infinite_p;
- CONST_ID(infinite_p, "infinite?");
if (slice_size <= 0) rb_raise(rb_eArgError, "invalid slice size");
size = enum_size(obj, 0, 0);
if (size == Qnil) return Qnil;
- if (RB_FLOAT_TYPE_P(size) && RTEST(rb_funcall(size, infinite_p, 0))) {
- return size;
- }
n = add_int(size, slice_size-1);
return div_int(n, slice_size);
@@ -2725,16 +2611,14 @@ zip_ary(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
}
static VALUE
-call_next(VALUE w)
+call_next(VALUE *v)
{
- VALUE *v = (VALUE *)w;
return v[0] = rb_funcallv(v[1], id_next, 0, 0);
}
static VALUE
-call_stop(VALUE w, VALUE _)
+call_stop(VALUE *v)
{
- VALUE *v = (VALUE *)w;
return v[0] = Qundef;
}
@@ -3032,7 +2916,7 @@ enum_cycle_size(VALUE self, VALUE args, VALUE eobj)
size = enum_size(self, args, 0);
if (NIL_P(size) || FIXNUM_ZERO_P(size)) return size;
- if (NIL_P(n)) return DBL2NUM(HUGE_VAL);
+ if (NIL_P(n)) return DBL2NUM(INFINITY);
if (mul <= 0) return INT2FIX(0);
n = LONG2FIX(mul);
return rb_funcallv(size, '*', 1, &n);
@@ -3066,10 +2950,10 @@ enum_cycle(int argc, VALUE *argv, VALUE obj)
VALUE nv = Qnil;
long n, i, len;
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", &nv);
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_cycle_size);
- if (!argc || NIL_P(nv = argv[0])) {
+ if (NIL_P(nv)) {
n = -1;
}
else {
@@ -4021,7 +3905,7 @@ int_range_sum(VALUE beg, VALUE end, int excl, VALUE init)
* { 1 => 10, 2 => 20 }.sum {|k, v| k * v } #=> 50
* (1..10).sum #=> 55
* (1..10).sum {|v| v * 2 } #=> 110
- * ('a'..'z').sum #=> TypeError
+ * [Object.new].each.sum #=> TypeError
*
* This method can be used for non-numeric objects by
* explicit <i>init</i> argument.
@@ -4029,12 +3913,8 @@ int_range_sum(VALUE beg, VALUE end, int excl, VALUE init)
* { 1 => 10, 2 => 20 }.sum([]) #=> [1, 10, 2, 20]
* "a\nb\nc".each_line.lazy.map(&:chomp).sum("") #=> "abc"
*
- * If the method is applied to an Integer range without a block,
- * the sum is not done by iteration, but instead using Gauss's summation
- * formula.
- *
* Enumerable#sum method may not respect method redefinition of "+"
- * methods such as Integer#+, or "each" methods such as Range#each.
+ * methods such as Integer#+.
*/
static VALUE
enum_sum(int argc, VALUE* argv, VALUE obj)
@@ -4043,8 +3923,11 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
VALUE beg, end;
int excl;
- memo.v = (rb_check_arity(argc, 0, 1) == 0) ? LONG2FIX(0) : argv[0];
+ if (rb_scan_args(argc, argv, "01", &memo.v) == 0)
+ memo.v = LONG2FIX(0);
+
memo.block_given = rb_block_given_p();
+
memo.n = 0;
memo.r = Qundef;
@@ -4052,10 +3935,6 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
memo.f = RFLOAT_VALUE(memo.v);
memo.c = 0.0;
}
- else {
- memo.f = 0.0;
- memo.c = 0.0;
- }
if (RTEST(rb_range_values(obj, &beg, &end, &excl))) {
if (!memo.block_given && !memo.float_value &&
@@ -4131,13 +4010,14 @@ enum_uniq(VALUE obj)
}
/*
- * The Enumerable mixin provides collection classes with several
- * traversal and searching methods, and with the ability to sort. The
- * class must provide a method #each, which yields
- * successive members of the collection. If Enumerable#max, #min, or
- * #sort is used, the objects in the collection must also implement a
- * meaningful <code><=></code> operator, as these methods rely on an
- * ordering between members of the collection.
+ * The <code>Enumerable</code> mixin provides collection classes with
+ * several traversal and searching methods, and with the ability to
+ * sort. The class must provide a method <code>each</code>, which
+ * yields successive members of the collection. If
+ * <code>Enumerable#max</code>, <code>#min</code>, or
+ * <code>#sort</code> is used, the objects in the collection must also
+ * implement a meaningful <code><=></code> operator, as these methods
+ * rely on an ordering between members of the collection.
*/
void
@@ -4162,8 +4042,6 @@ Init_Enumerable(void)
rb_define_method(rb_mEnumerable, "find_index", enum_find_index, -1);
rb_define_method(rb_mEnumerable, "find_all", enum_find_all, 0);
rb_define_method(rb_mEnumerable, "select", enum_find_all, 0);
- rb_define_method(rb_mEnumerable, "filter", enum_find_all, 0);
- rb_define_method(rb_mEnumerable, "filter_map", enum_filter_map, 0);
rb_define_method(rb_mEnumerable, "reject", enum_reject, 0);
rb_define_method(rb_mEnumerable, "collect", enum_collect, 0);
rb_define_method(rb_mEnumerable, "map", enum_collect, 0);
@@ -4173,7 +4051,6 @@ Init_Enumerable(void)
rb_define_method(rb_mEnumerable, "reduce", enum_inject, -1);
rb_define_method(rb_mEnumerable, "partition", enum_partition, 0);
rb_define_method(rb_mEnumerable, "group_by", enum_group_by, 0);
- rb_define_method(rb_mEnumerable, "tally", enum_tally, 0);
rb_define_method(rb_mEnumerable, "first", enum_first, -1);
rb_define_method(rb_mEnumerable, "all?", enum_all, -1);
rb_define_method(rb_mEnumerable, "any?", enum_any, -1);
@@ -4208,4 +4085,5 @@ Init_Enumerable(void)
rb_define_method(rb_mEnumerable, "uniq", enum_uniq, 0);
id_next = rb_intern("next");
+ id_div = rb_intern("div");
}
diff --git a/enumerator.c b/enumerator.c
index 2dc1789974..419f34f9e5 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -12,13 +12,7 @@
************************************************/
-#include "ruby/ruby.h"
#include "internal.h"
-#include "id.h"
-
-#ifdef HAVE_FLOAT_H
-#include <float.h>
-#endif
/*
* Document-class: Enumerator
@@ -26,8 +20,8 @@
* A class which allows both internal and external iteration.
*
* An Enumerator can be created by the following methods.
- * - Object#to_enum
- * - Object#enum_for
+ * - Kernel#to_enum
+ * - Kernel#enum_for
* - Enumerator.new
*
* Most methods have two forms: a block form where the contents
@@ -107,19 +101,10 @@
*
*/
VALUE rb_cEnumerator;
-static VALUE rb_cLazy;
-static ID id_rewind, id_new, id_to_enum;
-static ID id_next, id_result, id_receiver, id_arguments, id_memo, id_method, id_force;
-static ID id_begin, id_end, id_step, id_exclude_end;
-static VALUE sym_each, sym_cycle, sym_yield;
-
-static VALUE lazy_use_super_method;
-
-#define id_call idCall
-#define id_each idEach
-#define id_eqq idEqq
-#define id_initialize idInitialize
-#define id_size idSize
+VALUE rb_cLazy;
+static ID id_rewind, id_each, id_new, id_initialize, id_yield, id_call, id_size, id_to_enum;
+static ID id_eqq, id_next, id_result, id_lazy, id_receiver, id_arguments, id_memo, id_method, id_force;
+static VALUE sym_each, sym_cycle;
VALUE rb_eStopIteration;
@@ -135,10 +120,9 @@ struct enumerator {
VALUE size;
VALUE procs;
rb_enumerator_size_func *size_fn;
- int kw_splat;
};
-static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;
+static VALUE rb_cGenerator, rb_cYielder;
struct generator {
VALUE proc;
@@ -149,11 +133,6 @@ struct yielder {
VALUE proc;
};
-struct producer {
- VALUE init;
- VALUE proc;
-};
-
typedef struct MEMO *lazyenum_proc_func(VALUE, struct MEMO *, VALUE, long);
typedef VALUE lazyenum_size_func(VALUE, VALUE);
typedef struct {
@@ -170,15 +149,6 @@ struct proc_entry {
static VALUE generator_allocate(VALUE klass);
static VALUE generator_init(VALUE obj, VALUE proc);
-static VALUE rb_cEnumChain;
-
-struct enum_chain {
- VALUE enums;
- long pos;
-};
-
-VALUE rb_cArithSeq;
-
/*
* Enumerator
*/
@@ -186,30 +156,15 @@ static void
enumerator_mark(void *p)
{
struct enumerator *ptr = p;
- rb_gc_mark_movable(ptr->obj);
- rb_gc_mark_movable(ptr->args);
- rb_gc_mark_movable(ptr->fib);
- rb_gc_mark_movable(ptr->dst);
- rb_gc_mark_movable(ptr->lookahead);
- rb_gc_mark_movable(ptr->feedvalue);
- rb_gc_mark_movable(ptr->stop_exc);
- rb_gc_mark_movable(ptr->size);
- rb_gc_mark_movable(ptr->procs);
-}
-
-static void
-enumerator_compact(void *p)
-{
- struct enumerator *ptr = p;
- ptr->obj = rb_gc_location(ptr->obj);
- ptr->args = rb_gc_location(ptr->args);
- ptr->fib = rb_gc_location(ptr->fib);
- ptr->dst = rb_gc_location(ptr->dst);
- ptr->lookahead = rb_gc_location(ptr->lookahead);
- ptr->feedvalue = rb_gc_location(ptr->feedvalue);
- ptr->stop_exc = rb_gc_location(ptr->stop_exc);
- ptr->size = rb_gc_location(ptr->size);
- ptr->procs = rb_gc_location(ptr->procs);
+ rb_gc_mark(ptr->obj);
+ rb_gc_mark(ptr->args);
+ rb_gc_mark(ptr->fib);
+ rb_gc_mark(ptr->dst);
+ rb_gc_mark(ptr->lookahead);
+ rb_gc_mark(ptr->feedvalue);
+ rb_gc_mark(ptr->stop_exc);
+ rb_gc_mark(ptr->size);
+ rb_gc_mark(ptr->procs);
}
#define enumerator_free RUBY_TYPED_DEFAULT_FREE
@@ -226,7 +181,6 @@ static const rb_data_type_t enumerator_data_type = {
enumerator_mark,
enumerator_free,
enumerator_memsize,
- enumerator_compact,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -247,16 +201,8 @@ static void
proc_entry_mark(void *p)
{
struct proc_entry *ptr = p;
- rb_gc_mark_movable(ptr->proc);
- rb_gc_mark_movable(ptr->memo);
-}
-
-static void
-proc_entry_compact(void *p)
-{
- struct proc_entry *ptr = p;
- ptr->proc = rb_gc_location(ptr->proc);
- ptr->memo = rb_gc_location(ptr->memo);
+ rb_gc_mark(ptr->proc);
+ rb_gc_mark(ptr->memo);
}
#define proc_entry_free RUBY_TYPED_DEFAULT_FREE
@@ -273,7 +219,6 @@ static const rb_data_type_t proc_entry_data_type = {
proc_entry_mark,
proc_entry_free,
proc_entry_memsize,
- proc_entry_compact,
},
};
@@ -295,8 +240,7 @@ proc_entry_ptr(VALUE proc_entry)
* obj.enum_for(method = :each, *args){|*args| block} -> enum
*
* Creates a new Enumerator which will enumerate by calling +method+ on
- * +obj+, passing +args+ if any. What was _yielded_ by method becomes
- * values of enumerator.
+ * +obj+, passing +args+ if any.
*
* If a block is given, it will be used to calculate the size of
* the enumerator without the need to iterate it (see Enumerator#size).
@@ -315,11 +259,6 @@ proc_entry_ptr(VALUE proc_entry)
* a = [1, 2, 3]
* some_method(a.to_enum)
*
- * # String#split in block form is more memory-effective:
- * very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
- * # This could be rewritten more idiomatically with to_enum:
- * very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
- *
* It is typical to call to_enum when defining methods for
* a generic Enumerable, in case no block is passed.
*
@@ -376,10 +315,8 @@ enumerator_allocate(VALUE klass)
return enum_obj;
}
-#define PASS_KW_SPLAT (rb_empty_keyword_given_p() ? RB_PASS_EMPTY_KEYWORDS : rb_keyword_given_p())
-
static VALUE
-enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, VALUE size, int kw_splat)
+enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, VALUE size)
{
struct enumerator *ptr;
@@ -400,7 +337,6 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *ar
ptr->stop_exc = Qfalse;
ptr->size = size;
ptr->size_fn = size_fn;
- ptr->kw_splat = kw_splat;
return enum_obj;
}
@@ -415,7 +351,7 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *ar
*
* In the first form, iteration is defined by the given block, in
* which a "yielder" object, given as block parameter, can be used to
- * yield a value by calling the +yield+ method (aliased as <code><<</code>):
+ * yield a value by calling the +yield+ method (aliased as +<<+):
*
* fib = Enumerator.new do |y|
* a = b = 1
@@ -425,22 +361,22 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *ar
* end
* end
*
- * fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
+ * p fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
*
* The optional parameter can be used to specify how to calculate the size
* in a lazy fashion (see Enumerator#size). It can either be a value or
* a callable object.
*
- * In the deprecated second form, a generated Enumerator iterates over the
+ * In the second, deprecated, form, a generated Enumerator iterates over the
* given object using the given method with the given arguments passed.
*
- * Use of this form is discouraged. Use Object#enum_for or Object#to_enum
+ * Use of this form is discouraged. Use Kernel#enum_for or Kernel#to_enum
* instead.
*
* e = Enumerator.new(ObjectSpace, :each_object)
* #-> ObjectSpace.enum_for(:each_object)
*
- * e.select { |obj| obj.is_a?(Class) } # => array of all classes
+ * e.select { |obj| obj.is_a?(Class) } #=> array of all classes
*
*/
static VALUE
@@ -448,14 +384,13 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj)
{
VALUE recv, meth = sym_each;
VALUE size = Qnil;
- int kw_splat = 0;
if (rb_block_given_p()) {
rb_check_arity(argc, 0, 1);
recv = generator_init(generator_allocate(rb_cGenerator), rb_block_proc());
if (argc) {
if (NIL_P(argv[0]) || rb_respond_to(argv[0], id_call) ||
- (RB_TYPE_P(argv[0], T_FLOAT) && RFLOAT_VALUE(argv[0]) == HUGE_VAL)) {
+ (RB_TYPE_P(argv[0], T_FLOAT) && RFLOAT_VALUE(argv[0]) == INFINITY)) {
size = argv[0];
}
else {
@@ -466,16 +401,15 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj)
}
else {
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
- rb_warn_deprecated("Enumerator.new without a block", "Object#to_enum");
+ rb_warn("Enumerator.new without a block is deprecated; use Object#to_enum");
recv = *argv++;
if (--argc) {
meth = *argv++;
--argc;
}
- kw_splat = PASS_KW_SPLAT;
}
- return enumerator_init(obj, recv, meth, argc, argv, 0, size, kw_splat);
+ return enumerator_init(obj, recv, meth, argc, argv, 0, size);
}
/* :nodoc: */
@@ -519,7 +453,7 @@ rb_enumeratorize(VALUE obj, VALUE meth, int argc, const VALUE *argv)
}
static VALUE
-lazy_to_enum_i(VALUE self, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, int kw_splat);
+lazy_to_enum_i(VALUE self, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn);
VALUE
rb_enumeratorize_with_size(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn)
@@ -527,22 +461,10 @@ rb_enumeratorize_with_size(VALUE obj, VALUE meth, int argc, const VALUE *argv, r
/* Similar effect as calling obj.to_enum, i.e. dispatching to either
Kernel#to_enum vs Lazy#to_enum */
if (RTEST(rb_obj_is_kind_of(obj, rb_cLazy)))
- return lazy_to_enum_i(obj, meth, argc, argv, size_fn, PASS_KW_SPLAT);
+ return lazy_to_enum_i(obj, meth, argc, argv, size_fn);
else
return enumerator_init(enumerator_allocate(rb_cEnumerator),
- obj, meth, argc, argv, size_fn, Qnil, PASS_KW_SPLAT);
-}
-
-VALUE
-rb_enumeratorize_with_size_kw(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, int kw_splat)
-{
- /* Similar effect as calling obj.to_enum, i.e. dispatching to either
- Kernel#to_enum vs Lazy#to_enum */
- if (RTEST(rb_obj_is_kind_of(obj, rb_cLazy)))
- return lazy_to_enum_i(obj, meth, argc, argv, size_fn, kw_splat);
- else
- return enumerator_init(enumerator_allocate(rb_cEnumerator),
- obj, meth, argc, argv, size_fn, Qnil, kw_splat);
+ obj, meth, argc, argv, size_fn, Qnil);
}
static VALUE
@@ -557,7 +479,7 @@ enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg)
argc = RARRAY_LENINT(e->args);
argv = RARRAY_CONST_PTR(e->args);
}
- return rb_block_call_kw(e->obj, meth, argc, argv, func, arg, e->kw_splat);
+ return rb_block_call(e->obj, meth, argc, argv, func, arg);
}
/*
@@ -614,8 +536,6 @@ enumerator_each(int argc, VALUE *argv, VALUE obj)
args = rb_ary_new4(argc, argv);
}
e->args = args;
- e->size = Qnil;
- e->size_fn = 0;
}
if (!rb_block_given_p()) return obj;
return enumerator_block_call(obj, 0, obj);
@@ -660,9 +580,12 @@ enumerator_with_index(int argc, VALUE *argv, VALUE obj)
{
VALUE memo;
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", &memo);
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_enum_size);
- memo = (!argc || NIL_P(memo = argv[0])) ? INT2FIX(0) : rb_to_int(memo);
+ if (NIL_P(memo))
+ memo = INT2FIX(0);
+ else
+ memo = rb_to_int(memo);
return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)MEMO_NEW(memo, 0, 0));
}
@@ -744,7 +667,7 @@ next_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, obj))
}
static VALUE
-next_i(RB_BLOCK_CALL_FUNC_ARGLIST(_, obj))
+next_i(VALUE curr, VALUE obj)
{
struct enumerator *e = enumerator_ptr(obj);
VALUE nil = Qnil;
@@ -1077,6 +1000,7 @@ inspect_enumerator(VALUE obj, VALUE dummy, int recur)
if (recur) {
str = rb_sprintf("#<%"PRIsVALUE": ...>", rb_class_path(cname));
+ OBJ_TAINT(str);
return str;
}
@@ -1113,22 +1037,6 @@ inspect_enumerator(VALUE obj, VALUE dummy, int recur)
return str;
}
-static int
-key_symbol_p(VALUE key, VALUE val, VALUE arg)
-{
- if (SYMBOL_P(key)) return ST_CONTINUE;
- *(int *)arg = FALSE;
- return ST_STOP;
-}
-
-static int
-kwd_append(VALUE key, VALUE val, VALUE str)
-{
- if (!SYMBOL_P(key)) rb_raise(rb_eRuntimeError, "non-symbol key inserted");
- rb_str_catf(str, "% "PRIsVALUE": %"PRIsVALUE", ", key, val);
- return ST_CONTINUE;
-}
-
static VALUE
append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
{
@@ -1156,27 +1064,15 @@ append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
const VALUE *argv = RARRAY_CONST_PTR(eargs); /* WB: no new reference */
if (argc > 0) {
- VALUE kwds = Qnil;
-
rb_str_buf_cat2(str, "(");
- if (RB_TYPE_P(argv[argc-1], T_HASH) && !RHASH_EMPTY_P(argv[argc-1])) {
- int all_key = TRUE;
- rb_hash_foreach(argv[argc-1], key_symbol_p, (VALUE)&all_key);
- if (all_key) kwds = argv[--argc];
- }
-
while (argc--) {
VALUE arg = *argv++;
rb_str_append(str, rb_inspect(arg));
- rb_str_buf_cat2(str, ", ");
+ rb_str_buf_cat2(str, argc > 0 ? ", " : ")");
+ OBJ_INFECT(str, arg);
}
- if (!NIL_P(kwds)) {
- rb_hash_foreach(kwds, kwd_append, str);
- }
- rb_str_set_len(str, RSTRING_LEN(str)-2);
- rb_str_buf_cat2(str, ")");
}
}
@@ -1239,7 +1135,7 @@ enumerator_size(VALUE obj)
argc = (int)RARRAY_LEN(e->args);
argv = RARRAY_CONST_PTR(e->args);
}
- size = rb_check_funcall_kw(e->size, id_call, argc, argv, e->kw_splat);
+ size = rb_check_funcall(e->size, id_call, argc, argv);
if (size != Qundef) return size;
return e->size;
}
@@ -1251,14 +1147,7 @@ static void
yielder_mark(void *p)
{
struct yielder *ptr = p;
- rb_gc_mark_movable(ptr->proc);
-}
-
-static void
-yielder_compact(void *p)
-{
- struct yielder *ptr = p;
- ptr->proc = rb_gc_location(ptr->proc);
+ rb_gc_mark(ptr->proc);
}
#define yielder_free RUBY_TYPED_DEFAULT_FREE
@@ -1275,7 +1164,6 @@ static const rb_data_type_t yielder_data_type = {
yielder_mark,
yielder_free,
yielder_memsize,
- yielder_compact,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -1336,44 +1224,21 @@ yielder_yield(VALUE obj, VALUE args)
{
struct yielder *ptr = yielder_ptr(obj);
- return rb_proc_call_kw(ptr->proc, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_proc_call(ptr->proc, args);
}
/* :nodoc: */
static VALUE
-yielder_yield_push(VALUE obj, VALUE arg)
+yielder_yield_push(VALUE obj, VALUE args)
{
- struct yielder *ptr = yielder_ptr(obj);
-
- rb_proc_call_with_block(ptr->proc, 1, &arg, Qnil);
-
+ yielder_yield(obj, args);
return obj;
}
-/*
- * Returns a Proc object that takes an argument and yields it.
- *
- * This method is implemented so that a Yielder object can be directly
- * passed to another method as a block argument.
- *
- * enum = Enumerator.new { |y|
- * Dir.glob("*.rb") { |file|
- * File.open(file) { |f| f.each_line(&y) }
- * }
- * }
- */
-static VALUE
-yielder_to_proc(VALUE obj)
-{
- VALUE method = rb_obj_method(obj, sym_yield);
-
- return rb_funcall(method, idTo_proc, 0);
-}
-
static VALUE
yielder_yield_i(RB_BLOCK_CALL_FUNC_ARGLIST(obj, memo))
{
- return rb_yield_values_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
+ return rb_yield_values2(argc, argv);
}
static VALUE
@@ -1389,16 +1254,8 @@ static void
generator_mark(void *p)
{
struct generator *ptr = p;
- rb_gc_mark_movable(ptr->proc);
- rb_gc_mark_movable(ptr->obj);
-}
-
-static void
-generator_compact(void *p)
-{
- struct generator *ptr = p;
- ptr->proc = rb_gc_location(ptr->proc);
- ptr->obj = rb_gc_location(ptr->obj);
+ rb_gc_mark(ptr->proc);
+ rb_gc_mark(ptr->obj);
}
#define generator_free RUBY_TYPED_DEFAULT_FREE
@@ -1415,7 +1272,6 @@ static const rb_data_type_t generator_data_type = {
generator_mark,
generator_free,
generator_memsize,
- generator_compact,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -1522,7 +1378,7 @@ generator_each(int argc, VALUE *argv, VALUE obj)
rb_ary_cat(args, argv, argc);
}
- return rb_proc_call_kw(ptr->proc, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_proc_call(ptr->proc, args);
}
/* Lazy Enumerator methods */
@@ -1596,7 +1452,7 @@ lazy_init_block_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
#define LAZY_MEMO_RESET_PACKED(memo) ((memo)->memo_flags &= ~LAZY_MEMO_PACKED)
static VALUE
-lazy_init_yielder(RB_BLOCK_CALL_FUNC_ARGLIST(_, m))
+lazy_init_yielder(VALUE val, VALUE m, int argc, VALUE *argv)
{
VALUE yielder = RARRAY_AREF(m, 0);
VALUE procs_array = RARRAY_AREF(m, 1);
@@ -1618,7 +1474,7 @@ lazy_init_yielder(RB_BLOCK_CALL_FUNC_ARGLIST(_, m))
}
if (cont) {
- rb_funcall2(yielder, idLTLT, 1, &(result->memo_value));
+ rb_funcall2(yielder, id_yield, 1, &(result->memo_value));
}
if (LAZY_MEMO_BREAK_P(result)) {
rb_iter_break();
@@ -1627,7 +1483,7 @@ lazy_init_yielder(RB_BLOCK_CALL_FUNC_ARGLIST(_, m))
}
static VALUE
-lazy_init_block(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
+lazy_init_block(VALUE val, VALUE m, int argc, VALUE *argv)
{
VALUE procs = RARRAY_AREF(m, 1);
@@ -1665,93 +1521,32 @@ lazy_generator_init(VALUE enumerator, VALUE procs)
}
/*
- * Document-class: Enumerator::Lazy
- *
- * Enumerator::Lazy is a special type of Enumerator, that allows constructing
- * chains of operations without evaluating them immediately, and evaluating
- * values on as-needed basis. In order to do so it redefines most of Enumerable
- * methods so that they just construct another lazy enumerator.
- *
- * Enumerator::Lazy can be constructed from any Enumerable with the
- * Enumerable#lazy method.
- *
- * lazy = (1..Float::INFINITY).lazy.select(&:odd?).drop(10).take_while { |i| i < 30 }
- * # => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:select>:drop(10)>:take_while>
- *
- * The real enumeration is performed when any non-redefined Enumerable method
- * is called, like Enumerable#first or Enumerable#to_a (the latter is aliased
- * as #force for more semantic code):
- *
- * lazy.first(2)
- * #=> [21, 23]
- *
- * lazy.force
- * #=> [21, 23, 25, 27, 29]
- *
- * Note that most Enumerable methods that could be called with or without
- * a block, on Enumerator::Lazy will always require a block:
- *
- * [1, 2, 3].map #=> #<Enumerator: [1, 2, 3]:map>
- * [1, 2, 3].lazy.map # ArgumentError: tried to call lazy map without a block
- *
- * This class allows idiomatic calculations on long or infinite sequences, as well
- * as chaining of calculations without constructing intermediate arrays.
- *
- * Example for working with a slowly calculated sequence:
- *
- * require 'open-uri'
- *
- * # This will fetch all URLs before selecting
- * # necessary data
- * URLS.map { |u| JSON.parse(open(u).read) }
- * .select { |data| data.key?('stats') }
- * .first(5)
- *
- * # This will fetch URLs one-by-one, only till
- * # there is enough data to satisfy the condition
- * URLS.lazy.map { |u| JSON.parse(open(u).read) }
- * .select { |data| data.key?('stats') }
- * .first(5)
- *
- * Ending a chain with ".eager" generates a non-lazy enumerator, which
- * is suitable for returning or passing to another method that expects
- * a normal enumerator.
- *
- * def active_items
- * groups
- * .lazy
- * .flat_map(&:items)
- * .reject(&:disabled)
- * .eager
- * end
- *
- * # This works lazily; if a checked item is found, it stops
- * # iteration and does not look into remaining groups.
- * first_checked = active_items.find(&:checked)
- *
- * # This returns an array of items like a normal enumerator does.
- * all_checked = active_items.select(&:checked)
- *
- */
-
-/*
* call-seq:
- * Lazy.new(obj, size=nil) { |yielder, *values| block }
+ * Lazy.new(obj, size=nil) { |yielder, *values| ... }
*
* Creates a new Lazy enumerator. When the enumerator is actually enumerated
* (e.g. by calling #force), +obj+ will be enumerated and each value passed
* to the given block. The block can yield values back using +yielder+.
- * For example, to create a "filter+map" enumerator:
+ * For example, to create a method +filter_map+ in both lazy and
+ * non-lazy fashions:
*
- * def filter_map(sequence)
- * Lazy.new(sequence) do |yielder, *values|
- * result = yield *values
- * yielder << result if result
+ * module Enumerable
+ * def filter_map(&block)
+ * map(&block).compact
+ * end
+ * end
+ *
+ * class Enumerator::Lazy
+ * def filter_map
+ * Lazy.new(self) do |yielder, *values|
+ * result = yield *values
+ * yielder << result if result
+ * end
* end
* end
*
- * filter_map(1..Float::INFINITY) {|i| i*i if i.even?}.first(5)
- * #=> [4, 16, 36, 64, 100]
+ * (1..Float::INFINITY).lazy.filter_map{|i| i*i if i.even?}.first(5)
+ * # => [4, 16, 36, 64, 100]
*/
static VALUE
lazy_initialize(int argc, VALUE *argv, VALUE self)
@@ -1769,26 +1564,12 @@ lazy_initialize(int argc, VALUE *argv, VALUE self)
}
generator = generator_allocate(rb_cGenerator);
rb_block_call(generator, id_initialize, 0, 0, lazy_init_block_i, obj);
- enumerator_init(self, generator, sym_each, 0, 0, 0, size, 0);
+ enumerator_init(self, generator, sym_each, 0, 0, 0, size);
rb_ivar_set(self, id_receiver, obj);
return self;
}
-#if 0 /* for RDoc */
-/*
- * call-seq:
- * lazy.to_a -> array
- * lazy.force -> array
- *
- * Expands +lazy+ enumerator to an array.
- * See Enumerable#to_a.
- */
-static VALUE lazy_to_a(VALUE self)
-{
-}
-#endif
-
static void
lazy_set_args(VALUE lazy, VALUE args)
{
@@ -1856,9 +1637,11 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
* call-seq:
* e.lazy -> lazy_enumerator
*
- * Returns an Enumerator::Lazy, which redefines most Enumerable
- * methods to postpone enumeration and enumerate values only on an
- * as-needed basis.
+ * Returns a lazy enumerator, whose methods map/collect,
+ * flat_map/collect_concat, select/find_all, reject, grep, grep_v, zip, take,
+ * take_while, drop, and drop_while enumerate values only on an
+ * as-needed basis. However, if a block is given to zip, values
+ * are enumerated immediately.
*
* === Example
*
@@ -1884,33 +1667,33 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
static VALUE
enumerable_lazy(VALUE obj)
{
- VALUE result = lazy_to_enum_i(obj, sym_each, 0, 0, lazyenum_size, PASS_KW_SPLAT);
+ VALUE result = lazy_to_enum_i(obj, sym_each, 0, 0, lazyenum_size);
/* Qfalse indicates that the Enumerator::Lazy has no method name */
rb_ivar_set(result, id_method, Qfalse);
return result;
}
static VALUE
-lazy_to_enum_i(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, int kw_splat)
+lazy_to_enum_i(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn)
{
return enumerator_init(enumerator_allocate(rb_cLazy),
- obj, meth, argc, argv, size_fn, Qnil, kw_splat);
+ obj, meth, argc, argv, size_fn, Qnil);
}
/*
* call-seq:
- * lzy.to_enum(method = :each, *args) -> lazy_enum
- * lzy.enum_for(method = :each, *args) -> lazy_enum
- * lzy.to_enum(method = :each, *args) {|*args| block } -> lazy_enum
- * lzy.enum_for(method = :each, *args) {|*args| block } -> lazy_enum
+ * lzy.to_enum(method = :each, *args) -> lazy_enum
+ * lzy.enum_for(method = :each, *args) -> lazy_enum
+ * lzy.to_enum(method = :each, *args) {|*args| block} -> lazy_enum
+ * lzy.enum_for(method = :each, *args){|*args| block} -> lazy_enum
*
- * Similar to Object#to_enum, except it returns a lazy enumerator.
+ * Similar to Kernel#to_enum, except it returns a lazy enumerator.
* This makes it easy to define Enumerable methods that will
* naturally remain lazy if called from a lazy enumerator.
*
- * For example, continuing from the example in Object#to_enum:
+ * For example, continuing from the example in Kernel#to_enum:
*
- * # See Object#to_enum for the definition of repeat
+ * # See Kernel#to_enum for the definition of repeat
* r = 1..Float::INFINITY
* r.repeat(2).first(5) # => [1, 1, 2, 2, 3]
* r.repeat(2).class # => Enumerator
@@ -1923,16 +1706,13 @@ lazy_to_enum_i(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator
static VALUE
lazy_to_enum(int argc, VALUE *argv, VALUE self)
{
- VALUE lazy, meth = sym_each, super_meth;
+ VALUE lazy, meth = sym_each;
if (argc > 0) {
--argc;
meth = *argv++;
}
- if (RTEST((super_meth = rb_hash_aref(lazy_use_super_method, meth)))) {
- meth = super_meth;
- }
- lazy = lazy_to_enum_i(self, meth, argc, argv, 0, PASS_KW_SPLAT);
+ lazy = lazy_to_enum_i(self, meth, argc, argv, 0);
if (rb_block_given_p()) {
enumerator_ptr(lazy)->size = rb_block_proc();
}
@@ -1940,26 +1720,6 @@ lazy_to_enum(int argc, VALUE *argv, VALUE self)
}
static VALUE
-lazy_eager_size(VALUE self, VALUE args, VALUE eobj)
-{
- return enum_size(self);
-}
-
-/*
- * call-seq:
- * lzy.eager -> enum
- *
- * Returns a non-lazy Enumerator converted from the lazy enumerator.
- */
-
-static VALUE
-lazy_eager(VALUE self)
-{
- return enumerator_init(enumerator_allocate(rb_cEnumerator),
- self, sym_each, 0, 0, lazy_eager_size, Qnil, 0);
-}
-
-static VALUE
lazyenum_yield(VALUE proc_entry, struct MEMO *result)
{
struct proc_entry *entry = proc_entry_ptr(proc_entry);
@@ -1999,19 +1759,6 @@ static const lazyenum_funcs lazy_map_funcs = {
lazy_map_proc, lazy_map_size,
};
-/*
- * call-seq:
- * lazy.collect { |obj| block } -> lazy_enumerator
- * lazy.map { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#map, but chains operation to be lazy-evaluated.
- *
- * (1..Float::INFINITY).lazy.map {|i| i**2 }
- * #=> #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:map>
- * (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3)
- * #=> [1, 4, 9]
- */
-
static VALUE
lazy_map(VALUE obj)
{
@@ -2025,9 +1772,7 @@ lazy_map(VALUE obj)
static VALUE
lazy_flat_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, yielder))
{
- VALUE arg = rb_enum_values_pack(argc, argv);
-
- return rb_funcallv(yielder, idLTLT, 1, &arg);
+ return rb_funcallv(yielder, id_yield, argc, argv);
}
static VALUE
@@ -2042,12 +1787,12 @@ lazy_flat_map_to_ary(VALUE obj, VALUE yielder)
{
VALUE ary = rb_check_array_type(obj);
if (NIL_P(ary)) {
- rb_funcall(yielder, idLTLT, 1, obj);
+ rb_funcall(yielder, id_yield, 1, obj);
}
else {
long i;
for (i = 0; i < RARRAY_LEN(ary); i++) {
- rb_funcall(yielder, idLTLT, 1, RARRAY_AREF(ary, i));
+ rb_funcall(yielder, id_yield, 1, RARRAY_AREF(ary, i));
}
}
return Qnil;
@@ -2060,7 +1805,7 @@ lazy_flat_map_proc(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
if (RB_TYPE_P(result, T_ARRAY)) {
long i;
for (i = 0; i < RARRAY_LEN(result); i++) {
- rb_funcall(argv[0], idLTLT, 1, RARRAY_AREF(result, i));
+ rb_funcall(argv[0], id_yield, 1, RARRAY_AREF(result, i));
}
}
else {
@@ -2080,19 +1825,19 @@ lazy_flat_map_proc(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
* lazy.flat_map { |obj| block } -> a_lazy_enumerator
*
* Returns a new lazy enumerator with the concatenated results of running
- * +block+ once for every element in the lazy enumerator.
+ * <i>block</i> once for every element in <i>lazy</i>.
*
* ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
* #=> ["f", "o", "o", "b", "a", "r"]
*
- * A value +x+ returned by +block+ is decomposed if either of
+ * A value <i>x</i> returned by <i>block</i> is decomposed if either of
* the following conditions is true:
*
- * * +x+ responds to both each and force, which means that
- * +x+ is a lazy enumerator.
- * * +x+ is an array or responds to to_ary.
+ * a) <i>x</i> responds to both each and force, which means that
+ * <i>x</i> is a lazy enumerator.
+ * b) <i>x</i> is an array or responds to to_ary.
*
- * Otherwise, +x+ is contained as-is in the return value.
+ * Otherwise, <i>x</i> is contained as-is in the return value.
*
* [{a:1}, {b:2}].lazy.flat_map {|i| i}.force
* #=> [{:a=>1}, {:b=>2}]
@@ -2121,14 +1866,6 @@ static const lazyenum_funcs lazy_select_funcs = {
lazy_select_proc, 0,
};
-/*
- * call-seq:
- * lazy.find_all { |obj| block } -> lazy_enumerator
- * lazy.select { |obj| block } -> lazy_enumerator
- * lazy.filter { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#select, but chains operation to be lazy-evaluated.
- */
static VALUE
lazy_select(VALUE obj)
{
@@ -2140,40 +1877,6 @@ lazy_select(VALUE obj)
}
static struct MEMO *
-lazy_filter_map_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
-{
- VALUE value = lazyenum_yield_values(proc_entry, result);
- if (!RTEST(value)) return 0;
- LAZY_MEMO_SET_VALUE(result, value);
- LAZY_MEMO_RESET_PACKED(result);
- return result;
-}
-
-static const lazyenum_funcs lazy_filter_map_funcs = {
- lazy_filter_map_proc, 0,
-};
-
-/*
- * call-seq:
- * lazy.filter_map { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#filter_map, but chains operation to be lazy-evaluated.
- *
- * (1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5)
- * #=> [4, 8, 12, 16, 20]
- */
-
-static VALUE
-lazy_filter_map(VALUE obj)
-{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy filter_map without a block");
- }
-
- return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_filter_map_funcs);
-}
-
-static struct MEMO *
lazy_reject_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
{
VALUE chain = lazyenum_yield(proc_entry, result);
@@ -2185,13 +1888,6 @@ static const lazyenum_funcs lazy_reject_funcs = {
lazy_reject_proc, 0,
};
-/*
- * call-seq:
- * lazy.reject { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#reject, but chains operation to be lazy-evaluated.
- */
-
static VALUE
lazy_reject(VALUE obj)
{
@@ -2233,14 +1929,6 @@ static const lazyenum_funcs lazy_grep_funcs = {
lazy_grep_proc, 0,
};
-/*
- * call-seq:
- * lazy.grep(pattern) -> lazy_enumerator
- * lazy.grep(pattern) { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#grep, but chains operation to be lazy-evaluated.
- */
-
static VALUE
lazy_grep(VALUE obj, VALUE pattern)
{
@@ -2249,51 +1937,38 @@ lazy_grep(VALUE obj, VALUE pattern)
return lazy_add_method(obj, 0, 0, pattern, rb_ary_new3(1, pattern), funcs);
}
-static struct MEMO *
-lazy_grep_v_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
+static VALUE
+lazy_grep_v_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
{
- struct proc_entry *entry = proc_entry_ptr(proc_entry);
- VALUE chain = rb_funcall(entry->memo, id_eqq, 1, result->memo_value);
- if (RTEST(chain)) return 0;
- return result;
+ VALUE i = rb_enum_values_pack(argc - 1, argv + 1);
+ VALUE result = rb_funcall(m, id_eqq, 1, i);
+
+ if (!RTEST(result)) {
+ rb_funcall(argv[0], id_yield, 1, i);
+ }
+ return Qnil;
}
-static struct MEMO *
-lazy_grep_v_iter_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
+static VALUE
+lazy_grep_v_iter(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
{
- struct proc_entry *entry = proc_entry_ptr(proc_entry);
- VALUE value, chain = rb_funcall(entry->memo, id_eqq, 1, result->memo_value);
+ VALUE i = rb_enum_values_pack(argc - 1, argv + 1);
+ VALUE result = rb_funcall(m, id_eqq, 1, i);
- if (RTEST(chain)) return 0;
- value = rb_proc_call_with_block(entry->proc, 1, &(result->memo_value), Qnil);
- LAZY_MEMO_SET_VALUE(result, value);
- LAZY_MEMO_RESET_PACKED(result);
-
- return result;
+ if (!RTEST(result)) {
+ rb_funcall(argv[0], id_yield, 1, rb_yield(i));
+ }
+ return Qnil;
}
-static const lazyenum_funcs lazy_grep_v_iter_funcs = {
- lazy_grep_v_iter_proc, 0,
-};
-
-static const lazyenum_funcs lazy_grep_v_funcs = {
- lazy_grep_v_proc, 0,
-};
-
-/*
- * call-seq:
- * lazy.grep_v(pattern) -> lazy_enumerator
- * lazy.grep_v(pattern) { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#grep_v, but chains operation to be lazy-evaluated.
- */
-
static VALUE
lazy_grep_v(VALUE obj, VALUE pattern)
{
- const lazyenum_funcs *const funcs = rb_block_given_p() ?
- &lazy_grep_v_iter_funcs : &lazy_grep_v_funcs;
- return lazy_add_method(obj, 0, 0, pattern, rb_ary_new3(1, pattern), funcs);
+ return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj,
+ rb_block_given_p() ?
+ lazy_grep_v_iter : lazy_grep_v_func,
+ pattern),
+ rb_ary_new3(1, pattern), 0);
}
static VALUE
@@ -2303,7 +1978,7 @@ call_next(VALUE obj)
}
static VALUE
-next_stopped(VALUE obj, VALUE _)
+next_stopped(VALUE obj)
{
return Qnil;
}
@@ -2323,7 +1998,7 @@ lazy_zip_arrays_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, arrays))
for (i = 0; i < RARRAY_LEN(arrays); i++) {
rb_ary_push(ary, rb_ary_entry(RARRAY_AREF(arrays, i), count));
}
- rb_funcall(yielder, idLTLT, 1, ary);
+ rb_funcall(yielder, id_yield, 1, ary);
rb_ivar_set(yielder, id_memo, LONG2NUM(++count));
return Qnil;
}
@@ -2356,18 +2031,10 @@ lazy_zip_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, zip_args))
rb_eStopIteration, (VALUE)0);
rb_ary_push(ary, v);
}
- rb_funcall(yielder, idLTLT, 1, ary);
+ rb_funcall(yielder, id_yield, 1, ary);
return Qnil;
}
-/*
- * call-seq:
- * lazy.zip(arg, ...) -> lazy_enumerator
- * lazy.zip(arg, ...) { |arr| block } -> nil
- *
- * Like Enumerable#zip, but chains operation to be lazy-evaluated.
- * However, if a block is given to zip, values are enumerated immediately.
- */
static VALUE
lazy_zip(int argc, VALUE *argv, VALUE obj)
{
@@ -2436,13 +2103,6 @@ static const lazyenum_funcs lazy_take_funcs = {
lazy_take_proc, lazy_take_size,
};
-/*
- * call-seq:
- * lazy.take(n) -> lazy_enumerator
- *
- * Like Enumerable#take, but chains operation to be lazy-evaluated.
- */
-
static VALUE
lazy_take(VALUE obj, VALUE n)
{
@@ -2478,13 +2138,6 @@ static const lazyenum_funcs lazy_take_while_funcs = {
lazy_take_while_proc, 0,
};
-/*
- * call-seq:
- * lazy.take_while { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#take_while, but chains operation to be lazy-evaluated.
- */
-
static VALUE
lazy_take_while(VALUE obj)
{
@@ -2532,13 +2185,6 @@ static const lazyenum_funcs lazy_drop_funcs = {
lazy_drop_proc, lazy_drop_size,
};
-/*
- * call-seq:
- * lazy.drop(n) -> lazy_enumerator
- *
- * Like Enumerable#drop, but chains operation to be lazy-evaluated.
- */
-
static VALUE
lazy_drop(VALUE obj, VALUE n)
{
@@ -2576,13 +2222,6 @@ static const lazyenum_funcs lazy_drop_while_funcs = {
lazy_drop_while_proc, 0,
};
-/*
- * call-seq:
- * lazy.drop_while { |obj| block } -> lazy_enumerator
- *
- * Like Enumerable#drop_while, but chains operation to be lazy-evaluated.
- */
-
static VALUE
lazy_drop_while(VALUE obj)
{
@@ -2593,169 +2232,47 @@ lazy_drop_while(VALUE obj)
return lazy_add_method(obj, 0, 0, Qfalse, Qnil, &lazy_drop_while_funcs);
}
-static int
-lazy_uniq_check(VALUE chain, VALUE memos, long memo_index)
+static VALUE
+lazy_uniq_i(VALUE i, int argc, const VALUE *argv, VALUE yielder)
{
- VALUE hash = rb_ary_entry(memos, memo_index);
+ VALUE hash;
+ hash = rb_attr_get(yielder, id_memo);
if (NIL_P(hash)) {
hash = rb_obj_hide(rb_hash_new());
- rb_ary_store(memos, memo_index, hash);
+ rb_ivar_set(yielder, id_memo, hash);
}
- return rb_hash_add_new_element(hash, chain, Qfalse);
-}
-
-static struct MEMO *
-lazy_uniq_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
-{
- if (lazy_uniq_check(result->memo_value, memos, memo_index)) return 0;
- return result;
+ if (rb_hash_add_new_element(hash, i, Qfalse))
+ return Qnil;
+ return rb_funcallv(yielder, id_yield, argc, argv);
}
-static struct MEMO *
-lazy_uniq_iter_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
-{
- VALUE chain = lazyenum_yield(proc_entry, result);
-
- if (lazy_uniq_check(chain, memos, memo_index)) return 0;
- return result;
-}
-
-static const lazyenum_funcs lazy_uniq_iter_funcs = {
- lazy_uniq_iter_proc, 0,
-};
-
-static const lazyenum_funcs lazy_uniq_funcs = {
- lazy_uniq_proc, 0,
-};
-
-/*
- * call-seq:
- * lazy.uniq -> lazy_enumerator
- * lazy.uniq { |item| block } -> lazy_enumerator
- *
- * Like Enumerable#uniq, but chains operation to be lazy-evaluated.
- */
-
static VALUE
-lazy_uniq(VALUE obj)
+lazy_uniq_func(RB_BLOCK_CALL_FUNC_ARGLIST(i, m))
{
- const lazyenum_funcs *const funcs =
- rb_block_given_p() ? &lazy_uniq_iter_funcs : &lazy_uniq_funcs;
- return lazy_add_method(obj, 0, 0, Qnil, Qnil, funcs);
+ VALUE yielder = (--argc, *argv++);
+ i = rb_enum_values_pack(argc, argv);
+ return lazy_uniq_i(i, argc, argv, yielder);
}
-static struct MEMO *
-lazy_with_index_proc(VALUE proc_entry, struct MEMO* result, VALUE memos, long memo_index)
-{
- struct proc_entry *entry = proc_entry_ptr(proc_entry);
- VALUE memo = rb_ary_entry(memos, memo_index);
- VALUE argv[2];
-
- if (NIL_P(memo)) {
- memo = entry->memo;
- }
-
- argv[0] = result->memo_value;
- argv[1] = memo;
- if (entry->proc) {
- rb_proc_call_with_block(entry->proc, 2, argv, Qnil);
- LAZY_MEMO_RESET_PACKED(result);
- } else {
- LAZY_MEMO_SET_VALUE(result, rb_ary_new_from_values(2, argv));
- LAZY_MEMO_SET_PACKED(result);
- }
- rb_ary_store(memos, memo_index, LONG2NUM(NUM2LONG(memo) + 1));
- return result;
-}
-
-static const lazyenum_funcs lazy_with_index_funcs = {
- lazy_with_index_proc, 0,
-};
-
-/*
- * call-seq:
- * lazy.with_index(offset = 0) {|(*args), idx| block }
- * lazy.with_index(offset = 0)
- *
- * If a block is given, iterates the given block for each element
- * with an index, which starts from +offset+, and returns a
- * lazy enumerator that yields the same values (without the index).
- *
- * If a block is not given, returns a new lazy enumerator that
- * includes the index, starting from +offset+.
- *
- * +offset+:: the starting index to use
- *
- * See Enumerator#with_index.
- */
static VALUE
-lazy_with_index(int argc, VALUE *argv, VALUE obj)
-{
- VALUE memo;
-
- rb_scan_args(argc, argv, "01", &memo);
- if (NIL_P(memo))
- memo = LONG2NUM(0);
-
- return lazy_add_method(obj, 0, 0, memo, rb_ary_new_from_values(1, &memo), &lazy_with_index_funcs);
-}
-
-#if 0 /* for RDoc */
-
-/*
- * call-seq:
- * lazy.chunk { |elt| ... } -> lazy_enumerator
- *
- * Like Enumerable#chunk, but chains operation to be lazy-evaluated.
- */
-static VALUE lazy_chunk(VALUE self)
+lazy_uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, m))
{
+ VALUE yielder = (--argc, *argv++);
+ i = rb_yield_values2(argc, argv);
+ return lazy_uniq_i(i, argc, argv, yielder);
}
-/*
- * call-seq:
- * lazy.chunk_while {|elt_before, elt_after| bool } -> lazy_enumerator
- *
- * Like Enumerable#chunk_while, but chains operation to be lazy-evaluated.
- */
-static VALUE lazy_chunk_while(VALUE self)
-{
-}
-
-/*
- * call-seq:
- * lazy.slice_after(pattern) -> lazy_enumerator
- * lazy.slice_after { |elt| bool } -> lazy_enumerator
- *
- * Like Enumerable#slice_after, but chains operation to be lazy-evaluated.
- */
-static VALUE lazy_slice_after(VALUE self)
-{
-}
-
-/*
- * call-seq:
- * lazy.slice_before(pattern) -> lazy_enumerator
- * lazy.slice_before { |elt| bool } -> lazy_enumerator
- *
- * Like Enumerable#slice_before, but chains operation to be lazy-evaluated.
- */
-static VALUE lazy_slice_before(VALUE self)
-{
-}
-
-/*
- * call-seq:
- * lazy.slice_when {|elt_before, elt_after| bool } -> lazy_enumerator
- *
- * Like Enumerable#slice_when, but chains operation to be lazy-evaluated.
- */
-static VALUE lazy_slice_when(VALUE self)
+static VALUE
+lazy_uniq(VALUE obj)
{
+ rb_block_call_func *const func =
+ rb_block_given_p() ? lazy_uniq_iter : lazy_uniq_func;
+ return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj,
+ func, 0),
+ 0, 0);
}
-# endif
static VALUE
lazy_super(int argc, VALUE *argv, VALUE lazy)
@@ -2763,13 +2280,6 @@ lazy_super(int argc, VALUE *argv, VALUE lazy)
return enumerable_lazy(rb_call_super(argc, argv));
}
-/*
- * call-seq:
- * enum.lazy -> lazy_enumerator
- *
- * Returns self.
- */
-
static VALUE
lazy_lazy(VALUE obj)
{
@@ -2829,1160 +2339,9 @@ stop_result(VALUE self)
return rb_attr_get(self, id_result);
}
-/*
- * Producer
- */
-
-static void
-producer_mark(void *p)
-{
- struct producer *ptr = p;
- rb_gc_mark_movable(ptr->init);
- rb_gc_mark_movable(ptr->proc);
-}
-
-static void
-producer_compact(void *p)
-{
- struct producer *ptr = p;
- ptr->init = rb_gc_location(ptr->init);
- ptr->proc = rb_gc_location(ptr->proc);
-}
-
-#define producer_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-producer_memsize(const void *p)
-{
- return sizeof(struct producer);
-}
-
-static const rb_data_type_t producer_data_type = {
- "producer",
- {
- producer_mark,
- producer_free,
- producer_memsize,
- producer_compact,
- },
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static struct producer *
-producer_ptr(VALUE obj)
-{
- struct producer *ptr;
-
- TypedData_Get_Struct(obj, struct producer, &producer_data_type, ptr);
- if (!ptr || ptr->proc == Qundef) {
- rb_raise(rb_eArgError, "uninitialized producer");
- }
- return ptr;
-}
-
-/* :nodoc: */
-static VALUE
-producer_allocate(VALUE klass)
-{
- struct producer *ptr;
- VALUE obj;
-
- obj = TypedData_Make_Struct(klass, struct producer, &producer_data_type, ptr);
- ptr->init = Qundef;
- ptr->proc = Qundef;
-
- return obj;
-}
-
-static VALUE
-producer_init(VALUE obj, VALUE init, VALUE proc)
-{
- struct producer *ptr;
-
- TypedData_Get_Struct(obj, struct producer, &producer_data_type, ptr);
-
- if (!ptr) {
- rb_raise(rb_eArgError, "unallocated producer");
- }
-
- ptr->init = init;
- ptr->proc = proc;
-
- return obj;
-}
-
-static VALUE
-producer_each_stop(VALUE dummy, VALUE exc)
-{
- return rb_attr_get(exc, id_result);
-}
-
-static VALUE
-producer_each_i(VALUE obj)
-{
- struct producer *ptr;
- VALUE init, proc, curr;
-
- ptr = producer_ptr(obj);
- init = ptr->init;
- proc = ptr->proc;
-
- if (init == Qundef) {
- curr = Qnil;
- } else {
- rb_yield(init);
- curr = init;
- }
-
- for (;;) {
- curr = rb_funcall(proc, id_call, 1, curr);
- rb_yield(curr);
- }
-
- return Qnil;
-}
-
-/* :nodoc: */
-static VALUE
-producer_each(VALUE obj)
-{
- rb_need_block();
-
- return rb_rescue2(producer_each_i, obj, producer_each_stop, (VALUE)0, rb_eStopIteration, (VALUE)0);
-}
-
-static VALUE
-producer_size(VALUE obj, VALUE args, VALUE eobj)
-{
- return DBL2NUM(HUGE_VAL);
-}
-
-/*
- * call-seq:
- * Enumerator.produce(initial = nil) { |prev| block } -> enumerator
- *
- * Creates an infinite enumerator from any block, just called over and
- * over. The result of the previous iteration is passed to the next one.
- * If +initial+ is provided, it is passed to the first iteration, and
- * becomes the first element of the enumerator; if it is not provided,
- * the first iteration receives +nil+, and its result becomes the first
- * element of the iterator.
- *
- * Raising StopIteration from the block stops an iteration.
- *
- * Enumerator.produce(1, &:succ) # => enumerator of 1, 2, 3, 4, ....
- *
- * Enumerator.produce { rand(10) } # => infinite random number sequence
- *
- * ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration }
- * enclosing_section = ancestors.find { |n| n.type == :section }
- *
- * Using ::produce together with Enumerable methods like Enumerable#detect,
- * Enumerable#slice, Enumerable#take_while can provide Enumerator-based alternatives
- * for +while+ and +until+ cycles:
- *
- * # Find next Tuesday
- * require "date"
- * Enumerator.produce(Date.today, &:succ).detect(&:tuesday?)
- *
- * # Simple lexer:
- * require "strscan"
- * scanner = StringScanner.new("7+38/6")
- * PATTERN = %r{\d+|[-/+*]}
- * Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
- * # => ["7", "+", "38", "/", "6"]
- */
-static VALUE
-enumerator_s_produce(int argc, VALUE *argv, VALUE klass)
-{
- VALUE init, producer;
-
- if (!rb_block_given_p()) rb_raise(rb_eArgError, "no block given");
-
- if (rb_scan_args(argc, argv, "01", &init) == 0) {
- init = Qundef;
- }
-
- producer = producer_init(producer_allocate(rb_cEnumProducer), init, rb_block_proc());
-
- return rb_enumeratorize_with_size_kw(producer, sym_each, 0, 0, producer_size, RB_NO_KEYWORDS);
-}
-
-/*
- * Document-class: Enumerator::Chain
- *
- * Enumerator::Chain is a subclass of Enumerator, which represents a
- * chain of enumerables that works as a single enumerator.
- *
- * This type of objects can be created by Enumerable#chain and
- * Enumerator#+.
- */
-
-static void
-enum_chain_mark(void *p)
-{
- struct enum_chain *ptr = p;
- rb_gc_mark_movable(ptr->enums);
-}
-
-static void
-enum_chain_compact(void *p)
-{
- struct enum_chain *ptr = p;
- ptr->enums = rb_gc_location(ptr->enums);
-}
-
-#define enum_chain_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-enum_chain_memsize(const void *p)
-{
- return sizeof(struct enum_chain);
-}
-
-static const rb_data_type_t enum_chain_data_type = {
- "chain",
- {
- enum_chain_mark,
- enum_chain_free,
- enum_chain_memsize,
- enum_chain_compact,
- },
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static struct enum_chain *
-enum_chain_ptr(VALUE obj)
-{
- struct enum_chain *ptr;
-
- TypedData_Get_Struct(obj, struct enum_chain, &enum_chain_data_type, ptr);
- if (!ptr || ptr->enums == Qundef) {
- rb_raise(rb_eArgError, "uninitialized chain");
- }
- return ptr;
-}
-
-/* :nodoc: */
-static VALUE
-enum_chain_allocate(VALUE klass)
-{
- struct enum_chain *ptr;
- VALUE obj;
-
- obj = TypedData_Make_Struct(klass, struct enum_chain, &enum_chain_data_type, ptr);
- ptr->enums = Qundef;
- ptr->pos = -1;
-
- return obj;
-}
-
-/*
- * call-seq:
- * Enumerator::Chain.new(*enums) -> enum
- *
- * Generates a new enumerator object that iterates over the elements
- * of given enumerable objects in sequence.
- *
- * e = Enumerator::Chain.new(1..3, [4, 5])
- * e.to_a #=> [1, 2, 3, 4, 5]
- * e.size #=> 5
- */
-static VALUE
-enum_chain_initialize(VALUE obj, VALUE enums)
-{
- struct enum_chain *ptr;
-
- rb_check_frozen(obj);
- TypedData_Get_Struct(obj, struct enum_chain, &enum_chain_data_type, ptr);
-
- if (!ptr) rb_raise(rb_eArgError, "unallocated chain");
-
- ptr->enums = rb_obj_freeze(enums);
- ptr->pos = -1;
-
- return obj;
-}
-
-/* :nodoc: */
-static VALUE
-enum_chain_init_copy(VALUE obj, VALUE orig)
-{
- struct enum_chain *ptr0, *ptr1;
-
- if (!OBJ_INIT_COPY(obj, orig)) return obj;
- ptr0 = enum_chain_ptr(orig);
-
- TypedData_Get_Struct(obj, struct enum_chain, &enum_chain_data_type, ptr1);
-
- if (!ptr1) rb_raise(rb_eArgError, "unallocated chain");
-
- ptr1->enums = ptr0->enums;
- ptr1->pos = ptr0->pos;
-
- return obj;
-}
-
-static VALUE
-enum_chain_total_size(VALUE enums)
-{
- VALUE total = INT2FIX(0);
- long i;
-
- for (i = 0; i < RARRAY_LEN(enums); i++) {
- VALUE size = enum_size(RARRAY_AREF(enums, i));
-
- if (NIL_P(size) || (RB_TYPE_P(size, T_FLOAT) && isinf(NUM2DBL(size)))) {
- return size;
- }
- if (!RB_INTEGER_TYPE_P(size)) {
- return Qnil;
- }
-
- total = rb_funcall(total, '+', 1, size);
- }
-
- return total;
-}
-
-/*
- * call-seq:
- * obj.size -> int, Float::INFINITY or nil
- *
- * Returns the total size of the enumerator chain calculated by
- * summing up the size of each enumerable in the chain. If any of the
- * enumerables reports its size as nil or Float::INFINITY, that value
- * is returned as the total size.
- */
-static VALUE
-enum_chain_size(VALUE obj)
-{
- return enum_chain_total_size(enum_chain_ptr(obj)->enums);
-}
-
-static VALUE
-enum_chain_enum_size(VALUE obj, VALUE args, VALUE eobj)
-{
- return enum_chain_size(obj);
-}
-
-static VALUE
-enum_chain_enum_no_size(VALUE obj, VALUE args, VALUE eobj)
-{
- return Qnil;
-}
-
-/*
- * call-seq:
- * obj.each(*args) { |...| ... } -> obj
- * obj.each(*args) -> enumerator
- *
- * Iterates over the elements of the first enumerable by calling the
- * "each" method on it with the given arguments, then proceeds to the
- * following enumerables in sequence until all of the enumerables are
- * exhausted.
- *
- * If no block is given, returns an enumerator.
- */
-static VALUE
-enum_chain_each(int argc, VALUE *argv, VALUE obj)
-{
- VALUE enums, block;
- struct enum_chain *objptr;
- long i;
-
- RETURN_SIZED_ENUMERATOR(obj, argc, argv, argc > 0 ? enum_chain_enum_no_size : enum_chain_enum_size);
-
- objptr = enum_chain_ptr(obj);
- enums = objptr->enums;
- block = rb_block_proc();
-
- for (i = 0; i < RARRAY_LEN(enums); i++) {
- objptr->pos = i;
- rb_funcall_with_block(RARRAY_AREF(enums, i), id_each, argc, argv, block);
- }
-
- return obj;
-}
-
-/*
- * call-seq:
- * obj.rewind -> obj
- *
- * Rewinds the enumerator chain by calling the "rewind" method on each
- * enumerable in reverse order. Each call is performed only if the
- * enumerable responds to the method.
- */
-static VALUE
-enum_chain_rewind(VALUE obj)
-{
- struct enum_chain *objptr = enum_chain_ptr(obj);
- VALUE enums = objptr->enums;
- long i;
-
- for (i = objptr->pos; 0 <= i && i < RARRAY_LEN(enums); objptr->pos = --i) {
- rb_check_funcall(RARRAY_AREF(enums, i), id_rewind, 0, 0);
- }
-
- return obj;
-}
-
-static VALUE
-inspect_enum_chain(VALUE obj, VALUE dummy, int recur)
-{
- VALUE klass = rb_obj_class(obj);
- struct enum_chain *ptr;
-
- TypedData_Get_Struct(obj, struct enum_chain, &enum_chain_data_type, ptr);
-
- if (!ptr || ptr->enums == Qundef) {
- return rb_sprintf("#<%"PRIsVALUE": uninitialized>", rb_class_path(klass));
- }
-
- if (recur) {
- return rb_sprintf("#<%"PRIsVALUE": ...>", rb_class_path(klass));
- }
-
- return rb_sprintf("#<%"PRIsVALUE": %+"PRIsVALUE">", rb_class_path(klass), ptr->enums);
-}
-
-/*
- * call-seq:
- * obj.inspect -> string
- *
- * Returns a printable version of the enumerator chain.
- */
-static VALUE
-enum_chain_inspect(VALUE obj)
-{
- return rb_exec_recursive(inspect_enum_chain, obj, 0);
-}
-
-/*
- * call-seq:
- * e.chain(*enums) -> enumerator
- *
- * Returns an enumerator object generated from this enumerator and
- * given enumerables.
- *
- * e = (1..3).chain([4, 5])
- * e.to_a #=> [1, 2, 3, 4, 5]
- */
-static VALUE
-enum_chain(int argc, VALUE *argv, VALUE obj)
-{
- VALUE enums = rb_ary_new_from_values(1, &obj);
- rb_ary_cat(enums, argv, argc);
-
- return enum_chain_initialize(enum_chain_allocate(rb_cEnumChain), enums);
-}
-
-/*
- * call-seq:
- * e + enum -> enumerator
- *
- * Returns an enumerator object generated from this enumerator and a
- * given enumerable.
- *
- * e = (1..3).each + [4, 5]
- * e.to_a #=> [1, 2, 3, 4, 5]
- */
-static VALUE
-enumerator_plus(VALUE obj, VALUE eobj)
-{
- VALUE enums = rb_ary_new_from_args(2, obj, eobj);
-
- return enum_chain_initialize(enum_chain_allocate(rb_cEnumChain), enums);
-}
-
-/*
- * Document-class: Enumerator::ArithmeticSequence
- *
- * Enumerator::ArithmeticSequence is a subclass of Enumerator,
- * that is a representation of sequences of numbers with common difference.
- * Instances of this class can be generated by the Range#step and Numeric#step
- * methods.
- */
-
-VALUE
-rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv,
- rb_enumerator_size_func *size_fn,
- VALUE beg, VALUE end, VALUE step, int excl)
-{
- VALUE aseq = enumerator_init(enumerator_allocate(rb_cArithSeq),
- obj, meth, argc, argv, size_fn, Qnil, PASS_KW_SPLAT);
- rb_ivar_set(aseq, id_begin, beg);
- rb_ivar_set(aseq, id_end, end);
- rb_ivar_set(aseq, id_step, step);
- rb_ivar_set(aseq, id_exclude_end, excl ? Qtrue : Qfalse);
- return aseq;
-}
-
-/*
- * call-seq: aseq.begin -> num or nil
- *
- * Returns the number that defines the first element of this arithmetic
- * sequence.
- */
-static inline VALUE
-arith_seq_begin(VALUE self)
-{
- return rb_ivar_get(self, id_begin);
-}
-
-/*
- * call-seq: aseq.end -> num or nil
- *
- * Returns the number that defines the end of this arithmetic sequence.
- */
-static inline VALUE
-arith_seq_end(VALUE self)
-{
- return rb_ivar_get(self, id_end);
-}
-
-/*
- * call-seq: aseq.step -> num
- *
- * Returns the number that defines the common difference between
- * two adjacent elements in this arithmetic sequence.
- */
-static inline VALUE
-arith_seq_step(VALUE self)
-{
- return rb_ivar_get(self, id_step);
-}
-
-/*
- * call-seq: aseq.exclude_end? -> true or false
- *
- * Returns <code>true</code> if this arithmetic sequence excludes its end value.
- */
-static inline VALUE
-arith_seq_exclude_end(VALUE self)
-{
- return rb_ivar_get(self, id_exclude_end);
-}
-
-static inline int
-arith_seq_exclude_end_p(VALUE self)
-{
- return RTEST(arith_seq_exclude_end(self));
-}
-
-int
-rb_arithmetic_sequence_extract(VALUE obj, rb_arithmetic_sequence_components_t *component)
-{
- if (rb_obj_is_kind_of(obj, rb_cArithSeq)) {
- component->begin = arith_seq_begin(obj);
- component->end = arith_seq_end(obj);
- component->step = arith_seq_step(obj);
- component->exclude_end = arith_seq_exclude_end_p(obj);
- return 1;
- }
- else if (rb_obj_is_kind_of(obj, rb_cRange)) {
- component->begin = RANGE_BEG(obj);
- component->end = RANGE_END(obj);
- component->step = INT2FIX(1);
- component->exclude_end = RTEST(RANGE_EXCL(obj));
- return 1;
- }
-
- return 0;
-}
-
-/*
- * call-seq:
- * aseq.first -> num or nil
- * aseq.first(n) -> an_array
- *
- * Returns the first number in this arithmetic sequence,
- * or an array of the first +n+ elements.
- */
-static VALUE
-arith_seq_first(int argc, VALUE *argv, VALUE self)
-{
- VALUE b, e, s, ary;
- long n;
- int x;
-
- rb_check_arity(argc, 0, 1);
-
- b = arith_seq_begin(self);
- e = arith_seq_end(self);
- s = arith_seq_step(self);
- if (argc == 0) {
- if (NIL_P(b)) {
- return Qnil;
- }
- if (!NIL_P(e)) {
- VALUE zero = INT2FIX(0);
- int r = rb_cmpint(rb_num_coerce_cmp(s, zero, idCmp), s, zero);
- if (r > 0 && RTEST(rb_funcall(b, '>', 1, e))) {
- return Qnil;
- }
- if (r < 0 && RTEST(rb_funcall(b, '<', 1, e))) {
- return Qnil;
- }
- }
- return b;
- }
-
- // TODO: the following code should be extracted as arith_seq_take
-
- n = NUM2LONG(argv[0]);
- if (n < 0) {
- rb_raise(rb_eArgError, "attempt to take negative size");
- }
- if (n == 0) {
- return rb_ary_new_capa(0);
- }
-
- x = arith_seq_exclude_end_p(self);
-
- if (FIXNUM_P(b) && NIL_P(e) && FIXNUM_P(s)) {
- long i = FIX2LONG(b), unit = FIX2LONG(s);
- ary = rb_ary_new_capa(n);
- while (n > 0 && FIXABLE(i)) {
- rb_ary_push(ary, LONG2FIX(i));
- i += unit; // FIXABLE + FIXABLE never overflow;
- --n;
- }
- if (n > 0) {
- b = LONG2NUM(i);
- while (n > 0) {
- rb_ary_push(ary, b);
- b = rb_big_plus(b, s);
- --n;
- }
- }
- return ary;
- }
- else if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(s)) {
- long i = FIX2LONG(b);
- long end = FIX2LONG(e);
- long unit = FIX2LONG(s);
- long len;
-
- if (unit >= 0) {
- if (!x) end += 1;
-
- len = end - i;
- if (len < 0) len = 0;
- ary = rb_ary_new_capa((n < len) ? n : len);
- while (n > 0 && i < end) {
- rb_ary_push(ary, LONG2FIX(i));
- if (i + unit < i) break;
- i += unit;
- --n;
- }
- }
- else {
- if (!x) end -= 1;
-
- len = i - end;
- if (len < 0) len = 0;
- ary = rb_ary_new_capa((n < len) ? n : len);
- while (n > 0 && i > end) {
- rb_ary_push(ary, LONG2FIX(i));
- if (i + unit > i) break;
- i += unit;
- --n;
- }
- }
- return ary;
- }
- else if (RB_FLOAT_TYPE_P(b) || RB_FLOAT_TYPE_P(e) || RB_FLOAT_TYPE_P(s)) {
- /* generate values like ruby_float_step */
-
- double unit = NUM2DBL(s);
- double beg = NUM2DBL(b);
- double end = NIL_P(e) ? (unit < 0 ? -1 : 1)*HUGE_VAL : NUM2DBL(e);
- double len = ruby_float_step_size(beg, end, unit, x);
- long i;
-
- if (n > len)
- n = (long)len;
-
- if (isinf(unit)) {
- if (len > 0) {
- ary = rb_ary_new_capa(1);
- rb_ary_push(ary, DBL2NUM(beg));
- }
- else {
- ary = rb_ary_new_capa(0);
- }
- }
- else if (unit == 0) {
- VALUE val = DBL2NUM(beg);
- ary = rb_ary_new_capa(n);
- for (i = 0; i < len; ++i) {
- rb_ary_push(ary, val);
- }
- }
- else {
- ary = rb_ary_new_capa(n);
- for (i = 0; i < n; ++i) {
- double d = i*unit+beg;
- if (unit >= 0 ? end < d : d < end) d = end;
- rb_ary_push(ary, DBL2NUM(d));
- }
- }
-
- return ary;
- }
-
- return rb_call_super(argc, argv);
-}
-
-static inline VALUE
-num_plus(VALUE a, VALUE b)
-{
- if (RB_INTEGER_TYPE_P(a)) {
- return rb_int_plus(a, b);
- }
- else if (RB_FLOAT_TYPE_P(a)) {
- return rb_float_plus(a, b);
- }
- else if (RB_TYPE_P(a, T_RATIONAL)) {
- return rb_rational_plus(a, b);
- }
- else {
- return rb_funcallv(a, '+', 1, &b);
- }
-}
-
-static inline VALUE
-num_minus(VALUE a, VALUE b)
-{
- if (RB_INTEGER_TYPE_P(a)) {
- return rb_int_minus(a, b);
- }
- else if (RB_FLOAT_TYPE_P(a)) {
- return rb_float_minus(a, b);
- }
- else if (RB_TYPE_P(a, T_RATIONAL)) {
- return rb_rational_minus(a, b);
- }
- else {
- return rb_funcallv(a, '-', 1, &b);
- }
-}
-
-static inline VALUE
-num_mul(VALUE a, VALUE b)
-{
- if (RB_INTEGER_TYPE_P(a)) {
- return rb_int_mul(a, b);
- }
- else if (RB_FLOAT_TYPE_P(a)) {
- return rb_float_mul(a, b);
- }
- else if (RB_TYPE_P(a, T_RATIONAL)) {
- return rb_rational_mul(a, b);
- }
- else {
- return rb_funcallv(a, '*', 1, &b);
- }
-}
-
-static inline VALUE
-num_idiv(VALUE a, VALUE b)
-{
- VALUE q;
- if (RB_INTEGER_TYPE_P(a)) {
- q = rb_int_idiv(a, b);
- }
- else if (RB_FLOAT_TYPE_P(a)) {
- q = rb_float_div(a, b);
- }
- else if (RB_TYPE_P(a, T_RATIONAL)) {
- q = rb_rational_div(a, b);
- }
- else {
- q = rb_funcallv(a, idDiv, 1, &b);
- }
-
- if (RB_INTEGER_TYPE_P(q)) {
- return q;
- }
- else if (RB_FLOAT_TYPE_P(q)) {
- return rb_float_floor(q, 0);
- }
- else if (RB_TYPE_P(q, T_RATIONAL)) {
- return rb_rational_floor(q, 0);
- }
- else {
- return rb_funcall(q, rb_intern("floor"), 0);
- }
-}
-
-/*
- * call-seq:
- * aseq.last -> num or nil
- * aseq.last(n) -> an_array
- *
- * Returns the last number in this arithmetic sequence,
- * or an array of the last +n+ elements.
- */
-static VALUE
-arith_seq_last(int argc, VALUE *argv, VALUE self)
-{
- VALUE b, e, s, len_1, len, last, nv, ary;
- int last_is_adjusted;
- long n;
-
- e = arith_seq_end(self);
- if (NIL_P(e)) {
- rb_raise(rb_eRangeError,
- "cannot get the last element of endless arithmetic sequence");
- }
-
- b = arith_seq_begin(self);
- s = arith_seq_step(self);
-
- len_1 = num_idiv(num_minus(e, b), s);
- if (rb_num_negative_int_p(len_1)) {
- if (argc == 0) {
- return Qnil;
- }
- return rb_ary_new_capa(0);
- }
-
- last = num_plus(b, num_mul(s, len_1));
- if ((last_is_adjusted = arith_seq_exclude_end_p(self) && rb_equal(last, e))) {
- last = num_minus(last, s);
- }
-
- if (argc == 0) {
- return last;
- }
-
- if (last_is_adjusted) {
- len = len_1;
- }
- else {
- len = rb_int_plus(len_1, INT2FIX(1));
- }
-
- rb_scan_args(argc, argv, "1", &nv);
- if (!RB_INTEGER_TYPE_P(nv)) {
- nv = rb_to_int(nv);
- }
- if (RTEST(rb_int_gt(nv, len))) {
- nv = len;
- }
- n = NUM2LONG(nv);
- if (n < 0) {
- rb_raise(rb_eArgError, "negative array size");
- }
-
- ary = rb_ary_new_capa(n);
- b = rb_int_minus(last, rb_int_mul(s, nv));
- while (n) {
- b = rb_int_plus(b, s);
- rb_ary_push(ary, b);
- --n;
- }
-
- return ary;
-}
-
-/*
- * call-seq:
- * aseq.inspect -> string
- *
- * Convert this arithmetic sequence to a printable form.
- */
-static VALUE
-arith_seq_inspect(VALUE self)
-{
- struct enumerator *e;
- VALUE eobj, str, eargs;
- int range_p;
-
- TypedData_Get_Struct(self, struct enumerator, &enumerator_data_type, e);
-
- eobj = rb_attr_get(self, id_receiver);
- if (NIL_P(eobj)) {
- eobj = e->obj;
- }
-
- range_p = RTEST(rb_obj_is_kind_of(eobj, rb_cRange));
- str = rb_sprintf("(%s%"PRIsVALUE"%s.", range_p ? "(" : "", eobj, range_p ? ")" : "");
-
- rb_str_buf_append(str, rb_id2str(e->meth));
-
- eargs = rb_attr_get(eobj, id_arguments);
- if (NIL_P(eargs)) {
- eargs = e->args;
- }
- if (eargs != Qfalse) {
- long argc = RARRAY_LEN(eargs);
- const VALUE *argv = RARRAY_CONST_PTR(eargs); /* WB: no new reference */
-
- if (argc > 0) {
- VALUE kwds = Qnil;
-
- rb_str_buf_cat2(str, "(");
-
- if (RB_TYPE_P(argv[argc-1], T_HASH)) {
- int all_key = TRUE;
- rb_hash_foreach(argv[argc-1], key_symbol_p, (VALUE)&all_key);
- if (all_key) kwds = argv[--argc];
- }
-
- while (argc--) {
- VALUE arg = *argv++;
-
- rb_str_append(str, rb_inspect(arg));
- rb_str_buf_cat2(str, ", ");
- }
- if (!NIL_P(kwds)) {
- rb_hash_foreach(kwds, kwd_append, str);
- }
- rb_str_set_len(str, RSTRING_LEN(str)-2); /* drop the last ", " */
- rb_str_buf_cat2(str, ")");
- }
- }
-
- rb_str_buf_cat2(str, ")");
-
- return str;
-}
-
-/*
- * call-seq:
- * aseq == obj -> true or false
- *
- * Returns <code>true</code> only if +obj+ is an Enumerator::ArithmeticSequence,
- * has equivalent begin, end, step, and exclude_end? settings.
- */
-static VALUE
-arith_seq_eq(VALUE self, VALUE other)
-{
- if (!RTEST(rb_obj_is_kind_of(other, rb_cArithSeq))) {
- return Qfalse;
- }
-
- if (!rb_equal(arith_seq_begin(self), arith_seq_begin(other))) {
- return Qfalse;
- }
-
- if (!rb_equal(arith_seq_end(self), arith_seq_end(other))) {
- return Qfalse;
- }
-
- if (!rb_equal(arith_seq_step(self), arith_seq_step(other))) {
- return Qfalse;
- }
-
- if (arith_seq_exclude_end_p(self) != arith_seq_exclude_end_p(other)) {
- return Qfalse;
- }
-
- return Qtrue;
-}
-
-/*
- * call-seq:
- * aseq.hash -> integer
- *
- * Compute a hash-value for this arithmetic sequence.
- * Two arithmetic sequences with same begin, end, step, and exclude_end?
- * values will generate the same hash-value.
- *
- * See also Object#hash.
- */
-static VALUE
-arith_seq_hash(VALUE self)
-{
- st_index_t hash;
- VALUE v;
-
- hash = rb_hash_start(arith_seq_exclude_end_p(self));
- v = rb_hash(arith_seq_begin(self));
- hash = rb_hash_uint(hash, NUM2LONG(v));
- v = rb_hash(arith_seq_end(self));
- hash = rb_hash_uint(hash, NUM2LONG(v));
- v = rb_hash(arith_seq_step(self));
- hash = rb_hash_uint(hash, NUM2LONG(v));
- hash = rb_hash_end(hash);
-
- return ST2FIX(hash);
-}
-
-#define NUM_GE(x, y) RTEST(rb_num_coerce_relop((x), (y), idGE))
-
-struct arith_seq_gen {
- VALUE current;
- VALUE end;
- VALUE step;
- int excl;
-};
-
-/*
- * call-seq:
- * aseq.each {|i| block } -> aseq
- * aseq.each -> aseq
- */
-static VALUE
-arith_seq_each(VALUE self)
-{
- VALUE c, e, s, len_1, last;
- int x;
-
- if (!rb_block_given_p()) return self;
-
- c = arith_seq_begin(self);
- e = arith_seq_end(self);
- s = arith_seq_step(self);
- x = arith_seq_exclude_end_p(self);
-
- if (!RB_TYPE_P(s, T_COMPLEX) && ruby_float_step(c, e, s, x, TRUE)) {
- return self;
- }
-
- if (NIL_P(e)) {
- while (1) {
- rb_yield(c);
- c = rb_int_plus(c, s);
- }
-
- return self;
- }
-
- if (rb_equal(s, INT2FIX(0))) {
- while (1) {
- rb_yield(c);
- }
-
- return self;
- }
-
- len_1 = num_idiv(num_minus(e, c), s);
- last = num_plus(c, num_mul(s, len_1));
- if (x && rb_equal(last, e)) {
- last = num_minus(last, s);
- }
-
- if (rb_num_negative_int_p(s)) {
- while (NUM_GE(c, last)) {
- rb_yield(c);
- c = num_plus(c, s);
- }
- }
- else {
- while (NUM_GE(last, c)) {
- rb_yield(c);
- c = num_plus(c, s);
- }
- }
-
- return self;
-}
-
-static double
-arith_seq_float_step_size(double beg, double end, double step, int excl)
-{
- double const epsilon = DBL_EPSILON;
- double n, err;
-
- if (step == 0) {
- return HUGE_VAL;
- }
- n = (end - beg) / step;
- err = (fabs(beg) + fabs(end) + fabs(end - beg)) / fabs(step) * epsilon;
- if (isinf(step)) {
- return step > 0 ? beg <= end : beg >= end;
- }
- if (err > 0.5) err = 0.5;
- if (excl) {
- if (n <= 0) return 0;
- if (n < 1)
- n = 0;
- else
- n = floor(n - err);
- }
- else {
- if (n < 0) return 0;
- n = floor(n + err);
- }
- return n + 1;
-}
-
-/*
- * call-seq:
- * aseq.size -> num or nil
- *
- * Returns the number of elements in this arithmetic sequence if it is a finite
- * sequence. Otherwise, returns <code>nil</code>.
- */
-static VALUE
-arith_seq_size(VALUE self)
-{
- VALUE b, e, s, len_1, len, last;
- int x;
-
- b = arith_seq_begin(self);
- e = arith_seq_end(self);
- s = arith_seq_step(self);
- x = arith_seq_exclude_end_p(self);
-
- if (RB_FLOAT_TYPE_P(b) || RB_FLOAT_TYPE_P(e) || RB_FLOAT_TYPE_P(s)) {
- double ee, n;
-
- if (NIL_P(e)) {
- if (rb_num_negative_int_p(s)) {
- ee = -HUGE_VAL;
- }
- else {
- ee = HUGE_VAL;
- }
- }
- else {
- ee = NUM2DBL(e);
- }
-
- n = arith_seq_float_step_size(NUM2DBL(b), ee, NUM2DBL(s), x);
- if (isinf(n)) return DBL2NUM(n);
- if (POSFIXABLE(n)) return LONG2FIX(n);
- return rb_dbl2big(n);
- }
-
- if (NIL_P(e)) {
- return DBL2NUM(HUGE_VAL);
- }
-
- if (!rb_obj_is_kind_of(s, rb_cNumeric)) {
- s = rb_to_int(s);
- }
-
- if (rb_equal(s, INT2FIX(0))) {
- return DBL2NUM(HUGE_VAL);
- }
-
- len_1 = rb_int_idiv(rb_int_minus(e, b), s);
- if (rb_num_negative_int_p(len_1)) {
- return INT2FIX(0);
- }
-
- last = rb_int_plus(b, rb_int_mul(s, len_1));
- if (x && rb_equal(last, e)) {
- len = len_1;
- }
- else {
- len = rb_int_plus(len_1, INT2FIX(1));
- }
-
- return len;
-}
-
void
InitVM_Enumerator(void)
{
- ID id_private = rb_intern("private");
-
rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -1);
rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -1);
@@ -4005,62 +2364,19 @@ InitVM_Enumerator(void)
rb_define_method(rb_cEnumerator, "rewind", enumerator_rewind, 0);
rb_define_method(rb_cEnumerator, "inspect", enumerator_inspect, 0);
rb_define_method(rb_cEnumerator, "size", enumerator_size, 0);
- rb_define_method(rb_cEnumerator, "+", enumerator_plus, 1);
- rb_define_method(rb_mEnumerable, "chain", enum_chain, -1);
/* Lazy */
rb_cLazy = rb_define_class_under(rb_cEnumerator, "Lazy", rb_cEnumerator);
rb_define_method(rb_mEnumerable, "lazy", enumerable_lazy, 0);
-
- rb_define_alias(rb_cLazy, "_enumerable_map", "map");
- rb_define_alias(rb_cLazy, "_enumerable_collect", "collect");
- rb_define_alias(rb_cLazy, "_enumerable_flat_map", "flat_map");
- rb_define_alias(rb_cLazy, "_enumerable_collect_concat", "collect_concat");
- rb_define_alias(rb_cLazy, "_enumerable_select", "select");
- rb_define_alias(rb_cLazy, "_enumerable_find_all", "find_all");
- rb_define_alias(rb_cLazy, "_enumerable_filter", "filter");
- rb_define_alias(rb_cLazy, "_enumerable_filter_map", "filter_map");
- rb_define_alias(rb_cLazy, "_enumerable_reject", "reject");
- rb_define_alias(rb_cLazy, "_enumerable_grep", "grep");
- rb_define_alias(rb_cLazy, "_enumerable_grep_v", "grep_v");
- rb_define_alias(rb_cLazy, "_enumerable_zip", "zip");
- rb_define_alias(rb_cLazy, "_enumerable_take", "take");
- rb_define_alias(rb_cLazy, "_enumerable_take_while", "take_while");
- rb_define_alias(rb_cLazy, "_enumerable_drop", "drop");
- rb_define_alias(rb_cLazy, "_enumerable_drop_while", "drop_while");
- rb_define_alias(rb_cLazy, "_enumerable_uniq", "uniq");
- rb_define_private_method(rb_cLazy, "_enumerable_with_index", enumerator_with_index, -1);
-
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_map")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_collect")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_flat_map")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_collect_concat")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_select")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_find_all")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_filter")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_filter_map")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_reject")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_grep")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_grep_v")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_zip")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_take")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_take_while")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_drop")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_drop_while")));
- rb_funcall(rb_cLazy, id_private, 1, ID2SYM(rb_intern("_enumerable_uniq")));
-
rb_define_method(rb_cLazy, "initialize", lazy_initialize, -1);
rb_define_method(rb_cLazy, "to_enum", lazy_to_enum, -1);
rb_define_method(rb_cLazy, "enum_for", lazy_to_enum, -1);
- rb_define_method(rb_cLazy, "eager", lazy_eager, 0);
rb_define_method(rb_cLazy, "map", lazy_map, 0);
rb_define_method(rb_cLazy, "collect", lazy_map, 0);
rb_define_method(rb_cLazy, "flat_map", lazy_flat_map, 0);
rb_define_method(rb_cLazy, "collect_concat", lazy_flat_map, 0);
rb_define_method(rb_cLazy, "select", lazy_select, 0);
rb_define_method(rb_cLazy, "find_all", lazy_select, 0);
- rb_define_method(rb_cLazy, "filter", lazy_select, 0);
- rb_define_method(rb_cLazy, "filter_map", lazy_filter_map, 0);
rb_define_method(rb_cLazy, "reject", lazy_reject, 0);
rb_define_method(rb_cLazy, "grep", lazy_grep, 1);
rb_define_method(rb_cLazy, "grep_v", lazy_grep_v, 1);
@@ -4076,38 +2392,7 @@ InitVM_Enumerator(void)
rb_define_method(rb_cLazy, "slice_when", lazy_super, -1);
rb_define_method(rb_cLazy, "chunk_while", lazy_super, -1);
rb_define_method(rb_cLazy, "uniq", lazy_uniq, 0);
- rb_define_method(rb_cLazy, "with_index", lazy_with_index, -1);
-
- lazy_use_super_method = rb_hash_new_with_size(18);
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("map")), ID2SYM(rb_intern("_enumerable_map")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("collect")), ID2SYM(rb_intern("_enumerable_collect")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("flat_map")), ID2SYM(rb_intern("_enumerable_flat_map")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("collect_concat")), ID2SYM(rb_intern("_enumerable_collect_concat")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("select")), ID2SYM(rb_intern("_enumerable_select")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("find_all")), ID2SYM(rb_intern("_enumerable_find_all")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("filter")), ID2SYM(rb_intern("_enumerable_filter")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("filter_map")), ID2SYM(rb_intern("_enumerable_filter_map")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("reject")), ID2SYM(rb_intern("_enumerable_reject")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("grep")), ID2SYM(rb_intern("_enumerable_grep")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("grep_v")), ID2SYM(rb_intern("_enumerable_grep_v")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("zip")), ID2SYM(rb_intern("_enumerable_zip")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("take")), ID2SYM(rb_intern("_enumerable_take")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("take_while")), ID2SYM(rb_intern("_enumerable_take_while")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("drop")), ID2SYM(rb_intern("_enumerable_drop")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("drop_while")), ID2SYM(rb_intern("_enumerable_drop_while")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("uniq")), ID2SYM(rb_intern("_enumerable_uniq")));
- rb_hash_aset(lazy_use_super_method, ID2SYM(rb_intern("with_index")), ID2SYM(rb_intern("_enumerable_with_index")));
- rb_obj_freeze(lazy_use_super_method);
- rb_gc_register_mark_object(lazy_use_super_method);
-
-#if 0 /* for RDoc */
- rb_define_method(rb_cLazy, "to_a", lazy_to_a, 0);
- rb_define_method(rb_cLazy, "chunk", lazy_chunk, 0);
- rb_define_method(rb_cLazy, "chunk_while", lazy_chunk_while, 0);
- rb_define_method(rb_cLazy, "slice_after", lazy_slice_after, 0);
- rb_define_method(rb_cLazy, "slice_before", lazy_slice_before, 0);
- rb_define_method(rb_cLazy, "slice_when", lazy_slice_when, 0);
-#endif
+
rb_define_alias(rb_cLazy, "force", "to_a");
rb_eStopIteration = rb_define_class("StopIteration", rb_eIndexError);
@@ -4126,42 +2411,7 @@ InitVM_Enumerator(void)
rb_define_alloc_func(rb_cYielder, yielder_allocate);
rb_define_method(rb_cYielder, "initialize", yielder_initialize, 0);
rb_define_method(rb_cYielder, "yield", yielder_yield, -2);
- rb_define_method(rb_cYielder, "<<", yielder_yield_push, 1);
- rb_define_method(rb_cYielder, "to_proc", yielder_to_proc, 0);
-
- /* Producer */
- rb_cEnumProducer = rb_define_class_under(rb_cEnumerator, "Producer", rb_cObject);
- rb_define_alloc_func(rb_cEnumProducer, producer_allocate);
- rb_define_method(rb_cEnumProducer, "each", producer_each, 0);
- rb_define_singleton_method(rb_cEnumerator, "produce", enumerator_s_produce, -1);
-
- /* Chain */
- rb_cEnumChain = rb_define_class_under(rb_cEnumerator, "Chain", rb_cEnumerator);
- rb_define_alloc_func(rb_cEnumChain, enum_chain_allocate);
- rb_define_method(rb_cEnumChain, "initialize", enum_chain_initialize, -2);
- rb_define_method(rb_cEnumChain, "initialize_copy", enum_chain_init_copy, 1);
- rb_define_method(rb_cEnumChain, "each", enum_chain_each, -1);
- rb_define_method(rb_cEnumChain, "size", enum_chain_size, 0);
- rb_define_method(rb_cEnumChain, "rewind", enum_chain_rewind, 0);
- rb_define_method(rb_cEnumChain, "inspect", enum_chain_inspect, 0);
-
- /* ArithmeticSequence */
- rb_cArithSeq = rb_define_class_under(rb_cEnumerator, "ArithmeticSequence", rb_cEnumerator);
- rb_undef_alloc_func(rb_cArithSeq);
- rb_undef_method(CLASS_OF(rb_cArithSeq), "new");
- rb_define_method(rb_cArithSeq, "begin", arith_seq_begin, 0);
- rb_define_method(rb_cArithSeq, "end", arith_seq_end, 0);
- rb_define_method(rb_cArithSeq, "exclude_end?", arith_seq_exclude_end, 0);
- rb_define_method(rb_cArithSeq, "step", arith_seq_step, 0);
- rb_define_method(rb_cArithSeq, "first", arith_seq_first, -1);
- rb_define_method(rb_cArithSeq, "last", arith_seq_last, -1);
- rb_define_method(rb_cArithSeq, "inspect", arith_seq_inspect, 0);
- rb_define_method(rb_cArithSeq, "==", arith_seq_eq, 1);
- rb_define_method(rb_cArithSeq, "===", arith_seq_eq, 1);
- rb_define_method(rb_cArithSeq, "eql?", arith_seq_eq, 1);
- rb_define_method(rb_cArithSeq, "hash", arith_seq_hash, 0);
- rb_define_method(rb_cArithSeq, "each", arith_seq_each, 0);
- rb_define_method(rb_cArithSeq, "size", arith_seq_size, 0);
+ rb_define_method(rb_cYielder, "<<", yielder_yield_push, -2);
rb_provide("enumerator.so"); /* for backward compatibility */
}
@@ -4171,22 +2421,24 @@ void
Init_Enumerator(void)
{
id_rewind = rb_intern("rewind");
+ id_each = rb_intern("each");
+ id_call = rb_intern("call");
+ id_size = rb_intern("size");
+ id_yield = rb_intern("yield");
id_new = rb_intern("new");
+ id_initialize = rb_intern("initialize");
id_next = rb_intern("next");
id_result = rb_intern("result");
+ id_lazy = rb_intern("lazy");
+ id_eqq = rb_intern("===");
id_receiver = rb_intern("receiver");
id_arguments = rb_intern("arguments");
id_memo = rb_intern("memo");
id_method = rb_intern("method");
id_force = rb_intern("force");
id_to_enum = rb_intern("to_enum");
- id_begin = rb_intern("begin");
- id_end = rb_intern("end");
- id_step = rb_intern("step");
- id_exclude_end = rb_intern("exclude_end");
sym_each = ID2SYM(id_each);
sym_cycle = ID2SYM(rb_intern("cycle"));
- sym_yield = ID2SYM(rb_intern("yield"));
InitVM(Enumerator);
}
diff --git a/error.c b/error.c
index c29e90244a..079f01d6a6 100644
--- a/error.c
+++ b/error.c
@@ -9,12 +9,10 @@
**********************************************************************/
-#include "ruby/encoding.h"
-#include "ruby/st.h"
#include "internal.h"
+#include "ruby/st.h"
#include "ruby_assert.h"
#include "vm_core.h"
-#include "builtin.h"
#include <stdio.h>
#include <stdarg.h>
@@ -54,13 +52,22 @@ int rb_str_end_with_asciichar(VALUE str, int c);
VALUE rb_eEAGAIN;
VALUE rb_eEWOULDBLOCK;
VALUE rb_eEINPROGRESS;
-static VALUE rb_mWarning;
-static VALUE rb_cWarningBuffer;
+VALUE rb_mWarning;
+VALUE rb_cWarningBuffer;
static ID id_warn;
extern const char ruby_description[];
+static const char REPORTBUG_MSG[] =
+ "[NOTE]\n" \
+ "You may have encountered a bug in the Ruby interpreter" \
+ " or extension libraries.\n" \
+ "Bug reports are welcome.\n" \
+ ""
+ "For details: http://www.ruby-lang.org/bugreport.html\n\n" \
+ ;
+
static const char *
rb_strerrno(int err)
{
@@ -128,99 +135,20 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column,
return exc;
}
-static unsigned int warning_disabled_categories = (
- 1U << RB_WARN_CATEGORY_DEPRECATED |
- 0);
-
-static unsigned int
-rb_warning_category_mask(VALUE category)
-{
- return 1U << rb_warning_category_from_name(category);
-}
-
-rb_warning_category_t
-rb_warning_category_from_name(VALUE category)
-{
- rb_warning_category_t cat = RB_WARN_CATEGORY_NONE;
- Check_Type(category, T_SYMBOL);
- if (category == ID2SYM(rb_intern("deprecated"))) {
- cat = RB_WARN_CATEGORY_DEPRECATED;
- }
- else if (category == ID2SYM(rb_intern("experimental"))) {
- cat = RB_WARN_CATEGORY_EXPERIMENTAL;
- }
- else {
- rb_raise(rb_eArgError, "unknown category: %"PRIsVALUE, category);
- }
- return cat;
-}
-
void
-rb_warning_category_update(unsigned int mask, unsigned int bits)
-{
- warning_disabled_categories &= ~mask;
- warning_disabled_categories |= mask & ~bits;
-}
-
-MJIT_FUNC_EXPORTED bool
-rb_warning_category_enabled_p(rb_warning_category_t category)
+ruby_deprecated_internal_feature(const char *func)
{
- return !(warning_disabled_categories & (1U << category));
-}
-
-/*
- * call-seq
- * Warning[category] -> true or false
- *
- * Returns the flag to show the warning messages for +category+.
- * Supported categories are:
- *
- * +:deprecated+ :: deprecation warnings
- * * assignment of non-nil value to <code>$,</code> and <code>$;</code>
- * * keyword arguments
- * * proc/lambda without block
- * etc.
- *
- * +:experimental+ :: experimental features
- * * Pattern matching
- */
-
-static VALUE
-rb_warning_s_aref(VALUE mod, VALUE category)
-{
- rb_warning_category_t cat = rb_warning_category_from_name(category);
- if (rb_warning_category_enabled_p(cat))
- return Qtrue;
- return Qfalse;
-}
-
-/*
- * call-seq
- * Warning[category] = flag -> flag
- *
- * Sets the warning flags for +category+.
- * See Warning.[] for the categories.
- */
-
-static VALUE
-rb_warning_s_aset(VALUE mod, VALUE category, VALUE flag)
-{
- unsigned int mask = rb_warning_category_mask(category);
- unsigned int disabled = warning_disabled_categories;
- if (!RTEST(flag))
- disabled |= mask;
- else
- disabled &= ~mask;
- warning_disabled_categories = disabled;
- return flag;
+ rb_print_backtrace();
+ rb_fatal("%s is only for internal use and deprecated; do not use", func);
}
/*
* call-seq:
* warn(msg) -> nil
*
- * Writes warning message +msg+ to $stderr. This method is called by
- * Ruby for all emitted warnings.
+ * Writes warning message +msg+ to $stderr, followed by a newline
+ * if the message does not end in a newline. This method is called
+ * by Ruby for all emitted warnings.
*/
static VALUE
@@ -236,7 +164,7 @@ rb_warning_s_warn(VALUE mod, VALUE str)
* Document-module: Warning
*
* The Warning module contains a single method named #warn, and the
- * module extends itself, making Warning.warn available.
+ * module extends itself, making <code>Warning.warn</code> available.
* Warning.warn is called for all warnings issued by Ruby.
* By default, warnings are printed to $stderr.
*
@@ -247,7 +175,7 @@ rb_warning_s_warn(VALUE mod, VALUE str)
* printing the warning to $stderr.
*/
-static VALUE
+VALUE
rb_warning_warn(VALUE mod, VALUE str)
{
return rb_funcallv(mod, id_warn, 1, &str);
@@ -362,22 +290,6 @@ rb_enc_warning(rb_encoding *enc, const char *fmt, ...)
}
#endif
-void
-rb_warn_deprecated(const char *fmt, const char *suggest, ...)
-{
- if (NIL_P(ruby_verbose)) return;
- if (!rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) return;
- va_list args;
- va_start(args, suggest);
- VALUE mesg = warning_string(0, fmt, args);
- va_end(args);
- rb_str_set_len(mesg, RSTRING_LEN(mesg) - 1);
- rb_str_cat_cstr(mesg, " is deprecated");
- if (suggest) rb_str_catf(mesg, "; use %s instead", suggest);
- rb_str_cat_cstr(mesg, "\n");
- rb_write_warning_str(mesg);
-}
-
static inline int
end_with_asciichar(VALUE str, int c)
{
@@ -385,7 +297,6 @@ end_with_asciichar(VALUE str, int c)
rb_str_end_with_asciichar(str, c);
}
-/* :nodoc: */
static VALUE
warning_write(int argc, VALUE *argv, VALUE buf)
{
@@ -395,25 +306,54 @@ warning_write(int argc, VALUE *argv, VALUE buf)
return buf;
}
-VALUE rb_ec_backtrace_location_ary(rb_execution_context_t *ec, long lev, long n);
+/*
+ * call-seq:
+ * warn(msg, ...) -> nil
+ *
+ * If warnings have been disabled (for example with the
+ * <code>-W0</code> flag), does nothing. Otherwise,
+ * converts each of the messages to strings, appends a newline
+ * character to the string if the string does not end in a newline,
+ * and calls <code>Warning.warn</code> with the string.
+ *
+ * warn("warning 1", "warning 2")
+ *
+ * <em>produces:</em>
+ *
+ * warning 1
+ * warning 2
+ */
+
static VALUE
-rb_warn_m(rb_execution_context_t *ec, VALUE exc, VALUE msgs, VALUE uplevel)
-{
- VALUE location = Qnil;
- int argc = RARRAY_LENINT(msgs);
- const VALUE *argv = RARRAY_CONST_PTR(msgs);
-
- if (!NIL_P(ruby_verbose) && argc > 0) {
- VALUE str = argv[0];
- if (!NIL_P(uplevel)) {
- long lev = NUM2LONG(uplevel);
- if (lev < 0) {
- rb_raise(rb_eArgError, "negative level (%ld)", lev);
- }
- location = rb_ec_backtrace_location_ary(ec, lev + 1, 1);
- if (!NIL_P(location)) {
- location = rb_ary_entry(location, 0);
- }
+rb_warn_m(int argc, VALUE *argv, VALUE exc)
+{
+ VALUE opts, location = Qnil;
+
+ if (!NIL_P(ruby_verbose) && argc > 0 &&
+ (argc = rb_scan_args(argc, argv, "*:", NULL, &opts)) > 0) {
+ VALUE str = argv[0], uplevel = Qnil;
+ if (!NIL_P(opts)) {
+ static ID kwds[1];
+ if (!kwds[0]) {
+ CONST_ID(kwds[0], "uplevel");
+ }
+ rb_get_kwargs(opts, kwds, 0, 1, &uplevel);
+ if (uplevel == Qundef) {
+ uplevel = Qnil;
+ }
+ else if (!NIL_P(uplevel)) {
+ VALUE args[2];
+ long lev = NUM2LONG(uplevel);
+ if (lev < 0) {
+ rb_raise(rb_eArgError, "negative level (%ld)", lev);
+ }
+ args[0] = LONG2NUM(lev + 1);
+ args[1] = INT2FIX(1);
+ location = rb_vm_thread_backtrace_locations(2, args, GET_THREAD()->self);
+ if (!NIL_P(location)) {
+ location = rb_ary_entry(location, 0);
+ }
+ }
}
if (argc > 1 || !NIL_P(uplevel) || !end_with_asciichar(str, '\n')) {
VALUE path;
@@ -478,9 +418,8 @@ bug_report_file(const char *file, int line)
if ((ssize_t)fwrite(buf, 1, len, out) == (ssize_t)len ||
(ssize_t)fwrite(buf, 1, len, (out = stdout)) == (ssize_t)len) {
- return out;
+ return out;
}
-
return NULL;
}
@@ -569,17 +508,6 @@ bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
snprintf(buf, sizeof(buf), "\n%s\n\n", ruby_description);
fputs(buf, out);
preface_dump(out);
-
-#if RUBY_DEVEL
- const char *cmd = getenv("RUBY_ON_BUG");
- if (cmd) {
- snprintf(buf, sizeof(buf), "%s %"PRI_PIDT_PREFIX"d", cmd, getpid());
- int r = system(buf);
- if (r == -1) {
- snprintf(buf, sizeof(buf), "Launching RUBY_ON_BUG command failed.");
- }
- }
-#endif
}
#define bug_report_begin(out, fmt) do { \
@@ -600,6 +528,7 @@ bug_report_end(FILE *out)
(*reporter->func)(out, reporter->data);
}
}
+ fputs(REPORTBUG_MSG, out);
postscript_dump(out);
}
@@ -648,7 +577,7 @@ rb_bug(const char *fmt, ...)
}
void
-rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const void *ctx, const char *fmt, ...)
+rb_bug_context(const void *ctx, const char *fmt, ...)
{
const char *file = NULL;
int line = 0;
@@ -659,8 +588,6 @@ rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const voi
report_bug(file, line, fmt, ctx);
- if (default_sighandler) default_sighandler(sig);
-
die();
}
@@ -705,6 +632,8 @@ rb_async_bug_errno(const char *mesg, int errno_arg)
}
WRITE_CONST(2, "\n\n");
write_or_abort(2, ruby_description, strlen(ruby_description));
+ WRITE_CONST(2, "\n\n");
+ WRITE_CONST(2, REPORTBUG_MSG);
abort();
}
@@ -714,7 +643,7 @@ rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args)
report_bug_valist(RSTRING_PTR(file), line, fmt, NULL, args);
}
-MJIT_FUNC_EXPORTED void
+void
rb_assert_failure(const char *file, int line, const char *name, const char *expr)
{
FILE *out = stderr;
@@ -880,13 +809,6 @@ rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
return 1;
}
-#undef rb_typeddata_is_instance_of
-int
-rb_typeddata_is_instance_of(VALUE obj, const rb_data_type_t *data_type)
-{
- return rb_typeddata_is_instance_of_inline(obj, data_type);
-}
-
void *
rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type)
{
@@ -934,7 +856,6 @@ VALUE rb_eSecurityError;
VALUE rb_eNotImpError;
VALUE rb_eNoMemError;
VALUE rb_cNameErrorMesg;
-VALUE rb_eNoMatchingPatternError;
VALUE rb_eScriptError;
VALUE rb_eSyntaxError;
@@ -944,24 +865,22 @@ VALUE rb_eSystemCallError;
VALUE rb_mErrno;
static VALUE rb_eNOERROR;
-ID ruby_static_id_cause;
-#define id_cause ruby_static_id_cause
-static ID id_message, id_backtrace;
-static ID id_key, id_args, id_Errno, id_errno, id_i_path;
-static ID id_receiver, id_recv, id_iseq, id_local_variables;
+static ID id_new, id_cause, id_message, id_backtrace;
+static ID id_name, id_key, id_args, id_Errno, id_errno, id_i_path;
+static ID id_receiver, id_iseq, id_local_variables;
static ID id_private_call_p, id_top, id_bottom;
+extern ID ruby_static_id_status;
#define id_bt idBt
#define id_bt_locations idBt_locations
#define id_mesg idMesg
-#define id_name idName
+#define id_status ruby_static_id_status
#undef rb_exc_new_cstr
VALUE
rb_exc_new(VALUE etype, const char *ptr, long len)
{
- VALUE mesg = rb_str_new(ptr, len);
- return rb_class_new_instance(1, &mesg, etype);
+ return rb_funcall(etype, id_new, 1, rb_str_new(ptr, len));
}
VALUE
@@ -974,16 +893,7 @@ VALUE
rb_exc_new_str(VALUE etype, VALUE str)
{
StringValue(str);
- return rb_class_new_instance(1, &str, etype);
-}
-
-static VALUE
-exc_init(VALUE exc, VALUE mesg)
-{
- rb_ivar_set(exc, id_mesg, mesg);
- rb_ivar_set(exc, id_bt, Qnil);
-
- return exc;
+ return rb_funcall(etype, id_new, 1, str);
}
/*
@@ -999,8 +909,11 @@ exc_initialize(int argc, VALUE *argv, VALUE exc)
{
VALUE arg;
- arg = (!rb_check_arity(argc, 0, 1) ? Qnil : argv[0]);
- return exc_init(exc, arg);
+ rb_scan_args(argc, argv, "01", &arg);
+ rb_ivar_set(exc, id_mesg, arg);
+ rb_ivar_set(exc, id_bt, Qnil);
+
+ return exc;
}
/*
@@ -1021,11 +934,11 @@ exc_exception(int argc, VALUE *argv, VALUE self)
{
VALUE exc;
- argc = rb_check_arity(argc, 0, 1);
if (argc == 0) return self;
if (argc == 1 && self == argv[0]) return self;
exc = rb_obj_clone(self);
- rb_ivar_set(exc, id_mesg, argv[0]);
+ exc_initialize(argc, argv, exc);
+
return exc;
}
@@ -1120,7 +1033,7 @@ exc_full_message(int argc, VALUE *argv, VALUE exc)
if (id == id_bottom) args[kw_order] = Qtrue;
else if (id == id_top) args[kw_order] = Qfalse;
else {
- rb_raise(rb_eArgError, "expected :top or :bottom as "
+ rb_raise(rb_eArgError, "expected :top or :down as "
"order: %+"PRIsVALUE, args[kw_order]);
}
}
@@ -1151,7 +1064,7 @@ exc_message(VALUE exc)
* call-seq:
* exception.inspect -> string
*
- * Return this exception's class name and message.
+ * Return this exception's class name and message
*/
static VALUE
@@ -1162,7 +1075,7 @@ exc_inspect(VALUE exc)
klass = CLASS_OF(exc);
exc = rb_obj_as_string(exc);
if (RSTRING_LEN(exc) == 0) {
- return rb_class_name(klass);
+ return rb_str_dup(rb_class_name(klass));
}
str = rb_str_buf_new2("#<");
@@ -1177,7 +1090,7 @@ exc_inspect(VALUE exc)
/*
* call-seq:
- * exception.backtrace -> array or nil
+ * exception.backtrace -> array
*
* Returns any backtrace associated with the exception. The backtrace
* is an array of strings, each containing either ``filename:lineNo: in
@@ -1202,12 +1115,6 @@ exc_inspect(VALUE exc)
* prog.rb:2:in `a'
* prog.rb:6:in `b'
* prog.rb:10
- *
- * In the case no backtrace has been set, +nil+ is returned
- *
- * ex = StandardError.new
- * ex.backtrace
- * #=> nil
*/
static VALUE
@@ -1225,8 +1132,6 @@ exc_backtrace(VALUE exc)
return obj;
}
-static VALUE rb_check_backtrace(VALUE);
-
VALUE
rb_get_backtrace(VALUE exc)
{
@@ -1250,13 +1155,13 @@ rb_get_backtrace(VALUE exc)
/*
* call-seq:
- * exception.backtrace_locations -> array or nil
+ * exception.backtrace_locations -> array
*
* Returns any backtrace associated with the exception. This method is
* similar to Exception#backtrace, but the backtrace is an array of
* Thread::Backtrace::Location.
*
- * This method is not affected by Exception#set_backtrace().
+ * Now, this method is not affected by Exception#set_backtrace().
*/
static VALUE
exc_backtrace_locations(VALUE exc)
@@ -1270,7 +1175,7 @@ exc_backtrace_locations(VALUE exc)
return obj;
}
-static VALUE
+VALUE
rb_check_backtrace(VALUE bt)
{
long i;
@@ -1308,7 +1213,7 @@ exc_set_backtrace(VALUE exc, VALUE bt)
return rb_ivar_set(exc, id_bt, rb_check_backtrace(bt));
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_exc_set_backtrace(VALUE exc, VALUE bt)
{
return exc_set_backtrace(exc, bt);
@@ -1339,7 +1244,7 @@ try_convert_to_exception(VALUE obj)
* call-seq:
* exc == obj -> true or false
*
- * Equality---If <i>obj</i> is not an Exception, returns
+ * Equality---If <i>obj</i> is not an <code>Exception</code>, returns
* <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
* <i>obj</i> share same class, messages, and backtrace.
*/
@@ -1468,49 +1373,6 @@ exit_success_p(VALUE exc)
return Qfalse;
}
-static VALUE
-err_init_recv(VALUE exc, VALUE recv)
-{
- if (recv != Qundef) rb_ivar_set(exc, id_recv, recv);
- return exc;
-}
-
-/*
- * call-seq:
- * FrozenError.new(msg=nil, receiver: nil) -> frozen_error
- *
- * Construct a new FrozenError exception. If given the <i>receiver</i>
- * parameter may subsequently be examined using the FrozenError#receiver
- * method.
- *
- * a = [].freeze
- * raise FrozenError.new("can't modify frozen array", receiver: a)
- */
-
-static VALUE
-frozen_err_initialize(int argc, VALUE *argv, VALUE self)
-{
- ID keywords[1];
- VALUE values[numberof(keywords)], options;
-
- argc = rb_scan_args(argc, argv, "*:", NULL, &options);
- keywords[0] = id_receiver;
- rb_get_kwargs(options, keywords, 0, numberof(values), values);
- rb_call_super(argc, argv);
- err_init_recv(self, values[0]);
- return self;
-}
-
-/*
- * Document-method: FrozenError#receiver
- * call-seq:
- * frozen_error.receiver -> object
- *
- * Return the receiver associated with this FrozenError exception.
- */
-
-#define frozen_err_receiver name_err_receiver
-
void
rb_name_error(ID id, const char *fmt, ...)
{
@@ -1541,62 +1403,34 @@ rb_name_error_str(VALUE str, const char *fmt, ...)
rb_exc_raise(exc);
}
-static VALUE
-name_err_init_attr(VALUE exc, VALUE recv, VALUE method)
-{
- const rb_execution_context_t *ec = GET_EC();
- rb_control_frame_t *cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp);
- cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp);
- rb_ivar_set(exc, id_name, method);
- err_init_recv(exc, recv);
- if (cfp) rb_ivar_set(exc, id_iseq, rb_iseqw_new(cfp->iseq));
- return exc;
-}
-
/*
* call-seq:
- * NameError.new(msg=nil, name=nil, receiver: nil) -> name_error
+ * NameError.new([msg, *, name]) -> name_error
*
* Construct a new NameError exception. If given the <i>name</i>
- * parameter may subsequently be examined using the NameError#name
- * method. <i>receiver</i> parameter allows to pass object in
- * context of which the error happened. Example:
- *
- * [1, 2, 3].method(:rject) # NameError with name "rject" and receiver: Array
- * [1, 2, 3].singleton_method(:rject) # NameError with name "rject" and receiver: [1, 2, 3]
+ * parameter may subsequently be examined using the <code>NameError.name</code>
+ * method.
*/
static VALUE
name_err_initialize(int argc, VALUE *argv, VALUE self)
{
- ID keywords[1];
- VALUE values[numberof(keywords)], name, options;
+ VALUE name;
+ VALUE iseqw = Qnil;
- argc = rb_scan_args(argc, argv, "*:", NULL, &options);
- keywords[0] = id_receiver;
- rb_get_kwargs(options, keywords, 0, numberof(values), values);
name = (argc > 1) ? argv[--argc] : Qnil;
rb_call_super(argc, argv);
- name_err_init_attr(self, values[0], name);
+ rb_ivar_set(self, id_name, name);
+ {
+ const rb_execution_context_t *ec = GET_EC();
+ rb_control_frame_t *cfp =
+ rb_vm_get_ruby_level_next_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp));
+ if (cfp) iseqw = rb_iseqw_new(cfp->iseq);
+ }
+ rb_ivar_set(self, id_iseq, iseqw);
return self;
}
-static VALUE rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method);
-
-static VALUE
-name_err_init(VALUE exc, VALUE mesg, VALUE recv, VALUE method)
-{
- exc_init(exc, rb_name_err_mesg_new(mesg, recv, method));
- return name_err_init_attr(exc, recv, method);
-}
-
-VALUE
-rb_name_err_new(VALUE mesg, VALUE recv, VALUE method)
-{
- VALUE exc = rb_obj_alloc(rb_eNameError);
- return name_err_init(exc, mesg, recv, method);
-}
-
/*
* call-seq:
* name_error.name -> string or nil
@@ -1634,49 +1468,25 @@ name_err_local_variables(VALUE self)
return vars;
}
-static VALUE
-nometh_err_init_attr(VALUE exc, VALUE args, int priv)
-{
- rb_ivar_set(exc, id_args, args);
- rb_ivar_set(exc, id_private_call_p, priv ? Qtrue : Qfalse);
- return exc;
-}
-
/*
* call-seq:
- * NoMethodError.new(msg=nil, name=nil, args=nil, private=false, receiver: nil) -> no_method_error
+ * NoMethodError.new([msg, *, name [, args]]) -> no_method_error
*
* Construct a NoMethodError exception for a method of the given name
* called with the given arguments. The name may be accessed using
* the <code>#name</code> method on the resulting object, and the
* arguments using the <code>#args</code> method.
- *
- * If <i>private</i> argument were passed, it designates method was
- * attempted to call in private context, and can be accessed with
- * <code>#private_call?</code> method.
- *
- * <i>receiver</i> argument stores an object whose method was called.
*/
static VALUE
nometh_err_initialize(int argc, VALUE *argv, VALUE self)
{
- int priv;
- VALUE args, options;
- argc = rb_scan_args(argc, argv, "*:", NULL, &options);
- priv = (argc > 3) && (--argc, RTEST(argv[argc]));
- args = (argc > 2) ? argv[--argc] : Qnil;
- if (!NIL_P(options)) argv[argc++] = options;
- rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
- return nometh_err_init_attr(self, args, priv);
-}
-
-VALUE
-rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv)
-{
- VALUE exc = rb_obj_alloc(rb_eNoMethodError);
- name_err_init(exc, mesg, recv, method);
- return nometh_err_init_attr(exc, args, priv);
+ VALUE priv = (argc > 3) && (--argc, RTEST(argv[argc])) ? Qtrue : Qfalse;
+ VALUE args = (argc > 2) ? argv[--argc] : Qnil;
+ name_err_initialize(argc, argv, self);
+ rb_ivar_set(self, id_args, args);
+ rb_ivar_set(self, id_private_call_p, RTEST(priv) ? Qtrue : Qfalse);
+ return self;
}
/* :nodoc: */
@@ -1713,7 +1523,7 @@ static const rb_data_type_t name_err_mesg_data_type = {
};
/* :nodoc: */
-static VALUE
+VALUE
rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method)
{
VALUE result = TypedData_Wrap_Struct(rb_cNameErrorMesg, &name_err_mesg_data_type, 0);
@@ -1726,6 +1536,17 @@ rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method)
return result;
}
+VALUE
+rb_name_err_new(VALUE mesg, VALUE recv, VALUE method)
+{
+ VALUE exc = rb_obj_alloc(rb_eNameError);
+ rb_ivar_set(exc, id_mesg, rb_name_err_mesg_new(mesg, recv, method));
+ rb_ivar_set(exc, id_bt, Qnil);
+ rb_ivar_set(exc, id_name, method);
+ rb_ivar_set(exc, id_receiver, recv);
+ return exc;
+}
+
/* :nodoc: */
static VALUE
name_err_mesg_equal(VALUE obj1, VALUE obj2)
@@ -1781,6 +1602,7 @@ name_err_mesg_to_str(VALUE obj)
d = rb_any_to_s(obj);
}
singleton = (RSTRING_LEN(d) > 0 && RSTRING_PTR(d)[0] == '#');
+ d = QUOTE(d);
break;
}
if (!singleton) {
@@ -1790,7 +1612,7 @@ name_err_mesg_to_str(VALUE obj)
else {
c = s = FAKE_CSTR(&s_str, "");
}
- args[0] = rb_obj_as_string(ptr[NAME_ERR_MESG__NAME]);
+ args[0] = QUOTE(rb_obj_as_string(ptr[NAME_ERR_MESG__NAME]));
args[1] = d;
args[2] = s;
args[3] = c;
@@ -1825,7 +1647,7 @@ name_err_receiver(VALUE self)
{
VALUE *ptr, recv, mesg;
- recv = rb_ivar_lookup(self, id_recv, Qundef);
+ recv = rb_ivar_lookup(self, id_receiver, Qundef);
if (recv != Qundef) return recv;
mesg = rb_attr_get(self, id_mesg);
@@ -1850,13 +1672,6 @@ nometh_err_args(VALUE self)
return rb_attr_get(self, id_args);
}
-/*
- * call-seq:
- * no_method_error.private_call? -> true or false
- *
- * Return true if the caused method was called as private.
- */
-
static VALUE
nometh_err_private_call_p(VALUE self)
{
@@ -1918,38 +1733,6 @@ rb_key_err_new(VALUE mesg, VALUE recv, VALUE key)
/*
* call-seq:
- * KeyError.new(message=nil, receiver: nil, key: nil) -> key_error
- *
- * Construct a new +KeyError+ exception with the given message,
- * receiver and key.
- */
-
-static VALUE
-key_err_initialize(int argc, VALUE *argv, VALUE self)
-{
- VALUE options;
-
- rb_call_super(rb_scan_args(argc, argv, "01:", NULL, &options), argv);
-
- if (!NIL_P(options)) {
- ID keywords[2];
- VALUE values[numberof(keywords)];
- int i;
- keywords[0] = id_receiver;
- keywords[1] = id_key;
- rb_get_kwargs(options, keywords, 0, numberof(values), values);
- for (i = 0; i < numberof(values); ++i) {
- if (values[i] != Qundef) {
- rb_ivar_set(self, keywords[i], values[i]);
- }
- }
- }
-
- return self;
-}
-
-/*
- * call-seq:
* SyntaxError.new([msg]) -> syntax_error
*
* Construct a SyntaxError exception.
@@ -1960,7 +1743,7 @@ syntax_error_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE mesg;
if (argc == 0) {
- mesg = rb_fstring_lit("compile error");
+ mesg = rb_fstring_cstr("compile error");
argc = 1;
argv = &mesg;
}
@@ -1970,18 +1753,19 @@ syntax_error_initialize(int argc, VALUE *argv, VALUE self)
/*
* Document-module: Errno
*
- * Ruby exception objects are subclasses of Exception. However,
- * operating systems typically report errors using plain
- * integers. Module Errno is created dynamically to map these
- * operating system errors to Ruby classes, with each error number
- * generating its own subclass of SystemCallError. As the subclass
- * is created in module Errno, its name will start
- * <code>Errno::</code>.
+ * Ruby exception objects are subclasses of <code>Exception</code>.
+ * However, operating systems typically report errors using plain
+ * integers. Module <code>Errno</code> is created dynamically to map
+ * these operating system errors to Ruby classes, with each error
+ * number generating its own subclass of <code>SystemCallError</code>.
+ * As the subclass is created in module <code>Errno</code>, its name
+ * will start <code>Errno::</code>.
*
- * The names of the <code>Errno::</code> classes depend on the
- * environment in which Ruby runs. On a typical Unix or Windows
- * platform, there are Errno classes such as Errno::EACCES,
- * Errno::EAGAIN, Errno::EINTR, and so on.
+ * The names of the <code>Errno::</code> classes depend on
+ * the environment in which Ruby runs. On a typical Unix or Windows
+ * platform, there are <code>Errno</code> classes such as
+ * <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
+ * <code>Errno::EINTR</code>, and so on.
*
* The integer operating system error number corresponding to a
* particular error is available as the class constant
@@ -1992,7 +1776,7 @@ syntax_error_initialize(int argc, VALUE *argv, VALUE self)
* Errno::EINTR::Errno #=> 4
*
* The full list of operating system errors on your particular platform
- * are available as the constants of Errno.
+ * are available as the constants of <code>Errno</code>.
*
* Errno.constants #=> :E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, ...
*/
@@ -2051,10 +1835,11 @@ get_syserr(int n)
* call-seq:
* SystemCallError.new(msg, errno) -> system_call_error_subclass
*
- * If _errno_ corresponds to a known system error code, constructs the
- * appropriate Errno class for that error, otherwise constructs a
- * generic SystemCallError object. The error number is subsequently
- * available via the #errno method.
+ * If _errno_ corresponds to a known system error code, constructs
+ * the appropriate <code>Errno</code> class for that error, otherwise
+ * constructs a generic <code>SystemCallError</code> object. The
+ * error number is subsequently available via the <code>errno</code>
+ * method.
*/
static VALUE
@@ -2095,6 +1880,7 @@ syserr_initialize(int argc, VALUE *argv, VALUE self)
if (!NIL_P(func)) rb_str_catf(errmsg, " @ %"PRIsVALUE, func);
rb_str_catf(errmsg, " - %"PRIsVALUE, str);
+ OBJ_INFECT(errmsg, mesg);
}
mesg = errmsg;
@@ -2193,8 +1979,8 @@ syserr_eqq(VALUE self, VALUE exc)
/*
* Document-class: Interrupt
*
- * Raised when the interrupt signal is received, typically because the
- * user has pressed Control-C (on most posix platforms). As such, it is a
+ * Raised with the interrupt signal is received, typically because the
+ * user pressed on Control-C (on most posix platforms). As such, it is a
* subclass of +SignalException+.
*
* begin
@@ -2395,7 +2181,19 @@ syserr_eqq(VALUE self, VALUE exc)
/*
* Document-class: SecurityError
*
- * No longer used by internal code.
+ * Raised when attempting a potential unsafe operation, typically when
+ * the $SAFE level is raised above 0.
+ *
+ * foo = "bar"
+ * proc = Proc.new do
+ * $SAFE = 3
+ * foo.untaint
+ * end
+ * proc.call
+ *
+ * <em>raises the exception:</em>
+ *
+ * SecurityError: Insecure: Insecure operation `untaint' at level 3
*/
/*
@@ -2437,7 +2235,7 @@ syserr_eqq(VALUE self, VALUE exc)
* Document-class: fatal
*
* fatal is an Exception that is raised when Ruby has encountered a fatal
- * error and must exit.
+ * error and must exit. You are not able to rescue fatal.
*/
/*
@@ -2446,46 +2244,32 @@ syserr_eqq(VALUE self, VALUE exc)
*/
/*
- * \Class Exception and its subclasses are used to communicate between
+ * Descendants of class Exception are used to communicate between
* Kernel#raise and +rescue+ statements in <code>begin ... end</code> blocks.
+ * Exception objects carry information about the exception -- its type (the
+ * exception's class name), an optional descriptive string, and optional
+ * traceback information. Exception subclasses may add additional
+ * information like NameError#name.
*
- * An Exception object carries information about an exception:
- * - Its type (the exception's class).
- * - An optional descriptive message.
- * - Optional backtrace information.
- *
- * Some built-in subclasses of Exception have additional methods: e.g., NameError#name.
- *
- * == Defaults
- *
- * Two Ruby statements have default exception classes:
- * - +raise+: defaults to RuntimeError.
- * - +rescue+: defaults to StandardError.
- *
- * == Global Variables
+ * Programs may make subclasses of Exception, typically of StandardError or
+ * RuntimeError, to provide custom classes and add additional information.
+ * See the subclass list below for defaults for +raise+ and +rescue+.
*
* When an exception has been raised but not yet handled (in +rescue+,
- * +ensure+, +at_exit+ and +END+ blocks), two global variables are set:
- * - <code>$!</code> contains the current exception.
- * - <code>$@</code> contains its backtrace.
- *
- * == Custom Exceptions
+ * +ensure+, +at_exit+ and +END+ blocks) the global variable <code>$!</code>
+ * will contain the current exception and <code>$@</code> contains the
+ * current exception's backtrace.
*
- * To provide additional or alternate information,
- * a program may create custom exception classes
- * that derive from the built-in exception classes.
- *
- * A good practice is for a library to create a single "generic" exception class
- * (typically a subclass of StandardError or RuntimeError)
- * and have its other exception classes derive from that class.
- * This allows the user to rescue the generic exception, thus catching all exceptions
+ * It is recommended that a library should have one subclass of StandardError
+ * or RuntimeError and have specific exception types inherit from it. This
+ * allows the user to rescue a generic exception type to catch all exceptions
* the library may raise even if future versions of the library add new
* exception subclasses.
*
* For example:
*
* class MyLibrary
- * class Error < ::StandardError
+ * class Error < RuntimeError
* end
*
* class WidgetError < Error
@@ -2496,10 +2280,8 @@ syserr_eqq(VALUE self, VALUE exc)
*
* end
*
- * To handle both MyLibrary::WidgetError and MyLibrary::FrobError the library
- * user can rescue MyLibrary::Error.
- *
- * == Built-In Exception Classes
+ * To handle both WidgetError and FrobError the library user can rescue
+ * MyLibrary::Error.
*
* The built-in subclasses of Exception are:
*
@@ -2511,7 +2293,7 @@ syserr_eqq(VALUE self, VALUE exc)
* * SecurityError
* * SignalException
* * Interrupt
- * * StandardError
+ * * StandardError -- default for +rescue+
* * ArgumentError
* * UncaughtThrowError
* * EncodingError
@@ -2521,14 +2303,13 @@ syserr_eqq(VALUE self, VALUE exc)
* * IndexError
* * KeyError
* * StopIteration
- * * ClosedQueueError
* * LocalJumpError
* * NameError
* * NoMethodError
* * RangeError
* * FloatDomainError
* * RegexpError
- * * RuntimeError
+ * * RuntimeError -- default for +raise+
* * FrozenError
* * SystemCallError
* * Errno::*
@@ -2537,7 +2318,7 @@ syserr_eqq(VALUE self, VALUE exc)
* * ZeroDivisionError
* * SystemExit
* * SystemStackError
- * * fatal
+ * * fatal -- impossible to rescue
*/
void
@@ -2572,7 +2353,6 @@ Init_Exception(void)
rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
rb_eKeyError = rb_define_class("KeyError", rb_eIndexError);
- rb_define_method(rb_eKeyError, "initialize", key_err_initialize, -1);
rb_define_method(rb_eKeyError, "receiver", key_err_receiver, 0);
rb_define_method(rb_eKeyError, "key", key_err_key, 0);
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
@@ -2604,13 +2384,10 @@ Init_Exception(void)
rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
rb_eFrozenError = rb_define_class("FrozenError", rb_eRuntimeError);
- rb_define_method(rb_eFrozenError, "initialize", frozen_err_initialize, -1);
- rb_define_method(rb_eFrozenError, "receiver", frozen_err_receiver, 0);
rb_eSecurityError = rb_define_class("SecurityError", rb_eException);
rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
rb_eEncodingError = rb_define_class("EncodingError", rb_eStandardError);
rb_eEncCompatError = rb_define_class_under(rb_cEncoding, "CompatibilityError", rb_eEncodingError);
- rb_eNoMatchingPatternError = rb_define_class("NoMatchingPatternError", rb_eRuntimeError);
syserr_tbl = st_init_numtable();
rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError);
@@ -2621,18 +2398,19 @@ Init_Exception(void)
rb_mErrno = rb_define_module("Errno");
rb_mWarning = rb_define_module("Warning");
- rb_define_singleton_method(rb_mWarning, "[]", rb_warning_s_aref, 1);
- rb_define_singleton_method(rb_mWarning, "[]=", rb_warning_s_aset, 2);
rb_define_method(rb_mWarning, "warn", rb_warning_s_warn, 1);
rb_extend_object(rb_mWarning, rb_mWarning);
- /* :nodoc: */
rb_cWarningBuffer = rb_define_class_under(rb_mWarning, "buffer", rb_cString);
rb_define_method(rb_cWarningBuffer, "write", warning_write, -1);
+ rb_define_global_function("warn", rb_warn_m, -1);
+
+ id_new = rb_intern_const("new");
id_cause = rb_intern_const("cause");
id_message = rb_intern_const("message");
id_backtrace = rb_intern_const("backtrace");
+ id_name = rb_intern_const("name");
id_key = rb_intern_const("key");
id_args = rb_intern_const("args");
id_receiver = rb_intern_const("receiver");
@@ -2645,7 +2423,6 @@ Init_Exception(void)
id_top = rb_intern_const("top");
id_bottom = rb_intern_const("bottom");
id_iseq = rb_make_internal_id();
- id_recv = rb_make_internal_id();
}
void
@@ -2662,18 +2439,15 @@ rb_enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
}
void
-rb_vraise(VALUE exc, const char *fmt, va_list ap)
-{
- rb_exc_raise(rb_exc_new3(exc, rb_vsprintf(fmt, ap)));
-}
-
-void
rb_raise(VALUE exc, const char *fmt, ...)
{
va_list args;
+ VALUE mesg;
+
va_start(args, fmt);
- rb_vraise(exc, fmt, args);
+ mesg = rb_vsprintf(fmt, args);
va_end(args);
+ rb_exc_raise(rb_exc_new3(exc, mesg));
}
NORETURN(static void raise_loaderror(VALUE path, VALUE mesg));
@@ -2724,14 +2498,6 @@ rb_fatal(const char *fmt, ...)
va_list args;
VALUE mesg;
- if (! ruby_thread_has_gvl_p()) {
- /* The thread has no GVL. Object allocation impossible (cant run GC),
- * thus no message can be printed out. */
- fprintf(stderr, "[FATAL] rb_fatal() outside of GVL\n");
- rb_print_backtrace();
- die();
- }
-
va_start(args, fmt);
mesg = rb_vsprintf(fmt, args);
va_end(args);
@@ -2979,50 +2745,22 @@ rb_error_frozen(const char *what)
}
void
-rb_frozen_error_raise(VALUE frozen_obj, const char *fmt, ...)
-{
- va_list args;
- VALUE exc, mesg;
-
- va_start(args, fmt);
- mesg = rb_vsprintf(fmt, args);
- va_end(args);
- exc = rb_exc_new3(rb_eFrozenError, mesg);
- rb_ivar_set(exc, id_recv, frozen_obj);
- rb_exc_raise(exc);
-}
-
-static VALUE
-inspect_frozen_obj(VALUE obj, VALUE mesg, int recur)
-{
- if (recur) {
- rb_str_cat_cstr(mesg, " ...");
- }
- else {
- rb_str_append(mesg, rb_inspect(obj));
- }
- return mesg;
-}
-
-void
rb_error_frozen_object(VALUE frozen_obj)
{
VALUE debug_info;
const ID created_info = id_debug_created_info;
- VALUE mesg = rb_sprintf("can't modify frozen %"PRIsVALUE": ",
- CLASS_OF(frozen_obj));
- VALUE exc = rb_exc_new_str(rb_eFrozenError, mesg);
-
- rb_ivar_set(exc, id_recv, frozen_obj);
- rb_exec_recursive(inspect_frozen_obj, frozen_obj, mesg);
if (!NIL_P(debug_info = rb_attr_get(frozen_obj, created_info))) {
VALUE path = rb_ary_entry(debug_info, 0);
VALUE line = rb_ary_entry(debug_info, 1);
- rb_str_catf(mesg, ", created at %"PRIsVALUE":%"PRIsVALUE, path, line);
+ rb_raise(rb_eFrozenError, "can't modify frozen %"PRIsVALUE", created at %"PRIsVALUE":%"PRIsVALUE,
+ CLASS_OF(frozen_obj), path, line);
+ }
+ else {
+ rb_raise(rb_eFrozenError, "can't modify frozen %"PRIsVALUE,
+ CLASS_OF(frozen_obj));
}
- rb_exc_raise(exc);
}
#undef rb_check_frozen
@@ -3035,14 +2773,12 @@ rb_check_frozen(VALUE obj)
void
rb_error_untrusted(VALUE obj)
{
- rb_warning("rb_error_untrusted is deprecated and will be removed in Ruby 3.2.");
}
#undef rb_check_trusted
void
rb_check_trusted(VALUE obj)
{
- rb_warning("rb_check_trusted is deprecated and will be removed in Ruby 3.2.");
}
void
@@ -3051,6 +2787,12 @@ rb_check_copyable(VALUE obj, VALUE orig)
if (!FL_ABLE(obj)) return;
rb_check_frozen_internal(obj);
if (!FL_ABLE(orig)) return;
+ if ((~RBASIC(obj)->flags & RBASIC(orig)->flags) & FL_TAINT) {
+ if (rb_safe_level() > 0) {
+ rb_raise(rb_eSecurityError, "Insecure: can't modify %"PRIsVALUE,
+ RBASIC(obj)->klass);
+ }
+ }
}
void
@@ -3064,14 +2806,6 @@ Init_syserr(void)
#undef undefined_error
}
-#include "warning.rbinc"
-
-void
-Init_warning(void)
-{
- load_warning();
-}
-
/*!
* \}
*/
diff --git a/eval.c b/eval.c
index 08f7ba97de..9e6f9295c7 100644
--- a/eval.c
+++ b/eval.c
@@ -17,26 +17,17 @@
#include "gc.h"
#include "ruby/vm.h"
#include "vm_core.h"
-#include "mjit.h"
-#include "probes.h"
#include "probes_helper.h"
-#ifdef HAVE_SYS_PRCTL_H
-#include <sys/prctl.h>
-#endif
NORETURN(void rb_raise_jump(VALUE, VALUE));
-void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec);
-void rb_ec_clear_all_trace_func(const rb_execution_context_t *ec);
-
-static int rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex);
-static int rb_ec_exec_node(rb_execution_context_t *ec, void *n);
VALUE rb_eLocalJumpError;
VALUE rb_eSysStackError;
ID ruby_static_id_signo, ruby_static_id_status;
-extern ID ruby_static_id_cause;
-#define id_cause ruby_static_id_cause
+static ID id_cause;
+#define id_signo ruby_static_id_signo
+#define id_status ruby_static_id_status
#define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
@@ -48,7 +39,7 @@ extern ID ruby_static_id_cause;
(BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE))
/*!
- * Initializes the VM and builtin libraries.
+ * Initializes the Ruby VM and builtin libraries.
* @retval 0 if succeeded.
* @retval non-zero an error occurred.
*/
@@ -61,17 +52,8 @@ ruby_setup(void)
return 0;
ruby_init_stack((void *)&state);
-
- /*
- * Disable THP early before mallocs happen because we want this to
- * affect as many future pages as possible for CoW-friendliness
- */
-#if defined(__linux__) && defined(PR_SET_THP_DISABLE)
- prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0);
-#endif
Init_BareVM();
Init_heap();
- rb_vm_encoded_insn_data_table_init();
Init_vm_objects();
EC_PUSH_TAG(GET_EC());
@@ -114,18 +96,17 @@ ruby_init(void)
void *
ruby_options(int argc, char **argv)
{
- rb_execution_context_t *ec = GET_EC();
enum ruby_tag_type state;
void *volatile iseq = 0;
ruby_init_stack((void *)&iseq);
- EC_PUSH_TAG(ec);
+ EC_PUSH_TAG(GET_EC());
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv));
}
else {
- rb_ec_clear_current_thread_trace_func(ec);
- state = error_handle(ec, state);
+ rb_clear_trace_func();
+ state = error_handle(state);
iseq = (void *)INT2FIX(state);
}
EC_POP_TAG();
@@ -133,23 +114,23 @@ ruby_options(int argc, char **argv)
}
static void
-rb_ec_teardown(rb_execution_context_t *ec)
+ruby_finalize_0(void)
{
- EC_PUSH_TAG(ec);
+ EC_PUSH_TAG(GET_EC());
if (EC_EXEC_TAG() == TAG_NONE) {
- rb_vm_trap_exit(rb_ec_vm_ptr(ec));
+ rb_trap_exit();
}
EC_POP_TAG();
- rb_ec_exec_end_proc(ec);
- rb_ec_clear_all_trace_func(ec);
+ rb_exec_end_proc();
+ rb_clear_trace_func();
}
static void
-rb_ec_finalize(rb_execution_context_t *ec)
+ruby_finalize_1(void)
{
ruby_sig_finalize();
- ec->errinfo = Qnil;
- rb_objspace_call_finalizer(rb_ec_vm_ptr(ec)->objspace);
+ GET_EC()->errinfo = Qnil;
+ rb_gc_call_finalizer_at_exit();
}
/** Runs the VM finalization processes.
@@ -162,9 +143,8 @@ rb_ec_finalize(rb_execution_context_t *ec)
void
ruby_finalize(void)
{
- rb_execution_context_t *ec = GET_EC();
- rb_ec_teardown(ec);
- rb_ec_finalize(ec);
+ ruby_finalize_0();
+ ruby_finalize_1();
}
/** Destructs the VM.
@@ -180,41 +160,32 @@ ruby_finalize(void)
int
ruby_cleanup(volatile int ex)
{
- return rb_ec_cleanup(GET_EC(), ex);
-}
-
-static int
-rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex)
-{
int state;
- volatile VALUE errs[2] = { Qundef, Qundef };
+ volatile VALUE errs[2];
+ rb_thread_t *th = GET_THREAD();
int nerr;
- rb_thread_t *th = rb_ec_thread_ptr(ec);
- rb_thread_t *const volatile th0 = th;
volatile int sysex = EXIT_SUCCESS;
volatile int step = 0;
rb_threadptr_interrupt(th);
rb_threadptr_check_signal(th);
- EC_PUSH_TAG(ec);
+ EC_PUSH_TAG(th->ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- th = th0;
- SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(ec); });
+ SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th->ec); });
step_0: step++;
- th = th0;
- errs[1] = ec->errinfo;
- if (THROW_DATA_P(ec->errinfo)) ec->errinfo = Qnil;
+ errs[1] = th->ec->errinfo;
+ if (THROW_DATA_P(th->ec->errinfo)) th->ec->errinfo = Qnil;
+ th->ec->safe_level = 0;
ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
- SAVE_ROOT_JMPBUF(th, rb_ec_teardown(ec));
+ SAVE_ROOT_JMPBUF(th, ruby_finalize_0());
step_1: step++;
- th = th0;
/* protect from Thread#raise */
th->status = THREAD_KILLED;
- errs[0] = ec->errinfo;
+ errs[0] = th->ec->errinfo;
SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
}
else {
@@ -224,9 +195,8 @@ rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex)
}
if (ex == 0) ex = state;
}
- th = th0;
- ec->errinfo = errs[1];
- sysex = error_handle(ec, ex);
+ th->ec->errinfo = errs[1];
+ sysex = error_handle(ex);
state = 0;
for (nerr = 0; nerr < numberof(errs); ++nerr) {
@@ -234,7 +204,7 @@ rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex)
if (!RTEST(err)) continue;
- /* ec->errinfo contains a NODE while break'ing */
+ /* th->ec->errinfo contains a NODE while break'ing */
if (THROW_DATA_P(err)) continue;
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
@@ -251,30 +221,29 @@ rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex)
}
}
- mjit_finish(true); // We still need ISeqs here.
-
- rb_ec_finalize(ec);
+ ruby_finalize_1();
/* unlock again if finalizer took mutexes. */
- rb_threadptr_unlock_all_locking_mutexes(th);
+ rb_threadptr_unlock_all_locking_mutexes(GET_THREAD());
EC_POP_TAG();
rb_thread_stop_timer_thread();
- ruby_vm_destruct(th->vm);
+ ruby_vm_destruct(GET_VM());
if (state) ruby_default_signal(state);
return sysex;
}
static int
-rb_ec_exec_node(rb_execution_context_t *ec, void *n)
+ruby_exec_internal(void *n)
{
volatile int state;
rb_iseq_t *iseq = (rb_iseq_t *)n;
+ rb_thread_t * volatile th = GET_THREAD();
+
if (!n) return 0;
- EC_PUSH_TAG(ec);
+ EC_PUSH_TAG(th->ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- rb_thread_t *const th = rb_ec_thread_ptr(ec);
SAVE_ROOT_JMPBUF(th, {
rb_iseq_eval_main(iseq);
});
@@ -326,14 +295,12 @@ ruby_executable_node(void *n, int *status)
int
ruby_run_node(void *n)
{
- rb_execution_context_t *ec = GET_EC();
int status;
if (!ruby_executable_node(n, &status)) {
- rb_ec_cleanup(ec, 0);
+ ruby_cleanup(0);
return status;
}
- ruby_init_stack((void *)&status);
- return rb_ec_cleanup(ec, rb_ec_exec_node(ec, n));
+ return ruby_cleanup(ruby_exec_node(n));
}
/*! Runs the given compiled source */
@@ -341,7 +308,7 @@ int
ruby_exec_node(void *n)
{
ruby_init_stack((void *)&n);
- return rb_ec_exec_node(GET_EC(), n);
+ return ruby_exec_internal(n);
}
/*
@@ -360,7 +327,7 @@ ruby_exec_node(void *n)
*/
static VALUE
-rb_mod_nesting(VALUE _)
+rb_mod_nesting(void)
{
VALUE ary = rb_ary_new();
const rb_cref_t *cref = rb_vm_cref();
@@ -435,7 +402,7 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
* \ingroup class
*/
void
-rb_class_modify_check(VALUE klass)
+rb_frozen_class_p(VALUE klass)
{
if (SPECIAL_CONST_P(klass)) {
noclass:
@@ -472,18 +439,18 @@ rb_class_modify_check(VALUE klass)
goto noclass;
}
}
- rb_frozen_error_raise(klass, "can't modify frozen %s: %"PRIsVALUE, desc, klass);
+ rb_error_frozen(desc);
}
}
NORETURN(static void rb_longjmp(rb_execution_context_t *, int, volatile VALUE, VALUE));
static VALUE get_errinfo(void);
-#define get_ec_errinfo(ec) rb_ec_get_errinfo(ec)
+static VALUE get_ec_errinfo(const rb_execution_context_t *ec);
static VALUE
exc_setup_cause(VALUE exc, VALUE cause)
{
-#if OPT_SUPPORT_JOKE
+#if SUPPORT_JOKE
if (NIL_P(cause)) {
ID id_true_cause;
CONST_ID(id_true_cause, "true_cause");
@@ -510,7 +477,6 @@ static inline VALUE
exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause)
{
int nocause = 0;
- int nocircular = 0;
if (NIL_P(mesg)) {
mesg = ec->errinfo;
@@ -520,31 +486,14 @@ exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause)
if (NIL_P(mesg)) {
mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
nocause = 0;
- nocircular = 1;
}
if (*cause == Qundef) {
if (nocause) {
*cause = Qnil;
- nocircular = 1;
}
else if (!rb_ivar_defined(mesg, id_cause)) {
*cause = get_ec_errinfo(ec);
}
- else {
- nocircular = 1;
- }
- }
- else if (!NIL_P(*cause) && !rb_obj_is_kind_of(*cause, rb_eException)) {
- rb_raise(rb_eTypeError, "exception object expected");
- }
-
- if (!nocircular && !NIL_P(*cause) && *cause != Qundef && *cause != mesg) {
- VALUE c = *cause;
- while (!NIL_P(c = rb_attr_get(c, id_cause))) {
- if (c == mesg) {
- rb_raise(rb_eArgError, "circular causes");
- }
- }
}
return mesg;
}
@@ -553,10 +502,10 @@ static void
setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause)
{
VALUE e;
+ const char *file = 0;
int line;
- const char *file = rb_source_location_cstr(&line);
- const char *const volatile file0 = file;
+ file = rb_source_location_cstr(&line);
if ((file && !NIL_P(mesg)) || (cause != Qundef)) {
volatile int state = 0;
@@ -568,7 +517,7 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
mesg = rb_obj_dup(mesg);
}
}
- if (cause != Qundef && !THROW_DATA_P(cause)) {
+ if (cause != Qundef && !THROW_DATA_P(cause)) {
exc_setup_cause(mesg, cause);
}
if (NIL_P(bt)) {
@@ -579,7 +528,6 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
rb_ec_reset_raised(ec);
}
EC_POP_TAG();
- file = file0;
if (state) goto fatal;
}
@@ -696,7 +644,7 @@ rb_exc_fatal(VALUE mesg)
void
rb_interrupt(void)
{
- rb_exc_raise(rb_exc_new(rb_eInterrupt, 0, 0));
+ rb_raise(rb_eInterrupt, "%s", "");
}
enum {raise_opt_cause, raise_max_opt}; /*< \private */
@@ -723,61 +671,50 @@ extract_raise_opts(int argc, const VALUE *argv, VALUE *opts)
return argc;
}
-VALUE
-rb_f_raise(int argc, VALUE *argv)
-{
- VALUE err;
- VALUE opts[raise_max_opt], *const cause = &opts[raise_opt_cause];
-
- argc = extract_raise_opts(argc, argv, opts);
- if (argc == 0) {
- if (*cause != Qundef) {
- rb_raise(rb_eArgError, "only cause is given with no arguments");
- }
- err = get_errinfo();
- if (!NIL_P(err)) {
- argc = 1;
- argv = &err;
- }
- }
- rb_raise_jump(rb_make_exception(argc, argv), *cause);
-
- UNREACHABLE_RETURN(Qnil);
-}
-
/*
* call-seq:
* raise
- * raise(string, cause: $!)
- * raise(exception [, string [, array]], cause: $!)
+ * raise(string)
+ * raise(exception [, string [, array]])
* fail
- * fail(string, cause: $!)
- * fail(exception [, string [, array]], cause: $!)
+ * fail(string)
+ * fail(exception [, string [, array]])
*
* With no arguments, raises the exception in <code>$!</code> or raises
- * a RuntimeError if <code>$!</code> is +nil+. With a single +String+
- * argument, raises a +RuntimeError+ with the string as a message. Otherwise,
- * the first parameter should be an +Exception+ class (or another
- * object that returns an +Exception+ object when sent an +exception+
- * message). The optional second parameter sets the message associated with
- * the exception (accessible via Exception#message), and the third parameter
- * is an array of callback information (accessible via Exception#backtrace).
- * The +cause+ of the generated exception (accessible via Exception#cause)
- * is automatically set to the "current" exception (<code>$!</code>), if any.
- * An alternative value, either an +Exception+ object or +nil+, can be
- * specified via the +:cause+ argument.
- *
- * Exceptions are caught by the +rescue+ clause of
- * <code>begin...end</code> blocks.
+ * a <code>RuntimeError</code> if <code>$!</code> is +nil+.
+ * With a single +String+ argument, raises a
+ * +RuntimeError+ with the string as a message. Otherwise,
+ * the first parameter should be the name of an +Exception+
+ * class (or an object that returns an +Exception+ object when sent
+ * an +exception+ message). The optional second parameter sets the
+ * message associated with the exception, and the third parameter is an
+ * array of callback information. Exceptions are caught by the
+ * +rescue+ clause of <code>begin...end</code> blocks.
*
* raise "Failed to create socket"
* raise ArgumentError, "No parameters", caller
*/
static VALUE
-f_raise(int c, VALUE *v, VALUE _)
+rb_f_raise(int argc, VALUE *argv)
{
- return rb_f_raise(c, v);
+ VALUE err;
+ VALUE opts[raise_max_opt], *const cause = &opts[raise_opt_cause];
+
+ argc = extract_raise_opts(argc, argv, opts);
+ if (argc == 0) {
+ if (*cause != Qundef) {
+ rb_raise(rb_eArgError, "only cause is given with no arguments");
+ }
+ err = get_errinfo();
+ if (!NIL_P(err)) {
+ argc = 1;
+ argv = &err;
+ }
+ }
+ rb_raise_jump(rb_make_exception(argc, argv), *cause);
+
+ UNREACHABLE;
}
static VALUE
@@ -815,7 +752,8 @@ make_exception(int argc, const VALUE *argv, int isstr)
}
break;
default:
- rb_error_arity(argc, 0, 3);
+ rb_check_arity(argc, 0, 3);
+ break;
}
if (argc > 0) {
if (!rb_obj_is_kind_of(mesg, rb_eException))
@@ -905,22 +843,6 @@ rb_block_given_p(void)
}
}
-int rb_vm_cframe_keyword_p(const rb_control_frame_t *cfp);
-
-int
-rb_keyword_given_p(void)
-{
- return rb_vm_cframe_keyword_p(GET_EC()->cfp);
-}
-
-/* -- Remove In 3.0 -- */
-int rb_vm_cframe_empty_keyword_p(const rb_control_frame_t *cfp);
-int
-rb_empty_keyword_given_p(void)
-{
- return rb_vm_cframe_empty_keyword_p(GET_EC()->cfp);
-}
-
VALUE rb_eThreadError;
/*! Declares that the current method needs a block.
@@ -959,30 +881,15 @@ rb_need_block(void)
* \ingroup exception
*/
VALUE
-rb_rescue2(VALUE (* b_proc) (VALUE), VALUE data1,
- VALUE (* r_proc) (VALUE, VALUE), VALUE data2, ...)
-{
- va_list ap;
- va_start(ap, data2);
- VALUE ret = rb_vrescue2(b_proc, data1, r_proc, data2, ap);
- va_end(ap);
- return ret;
-}
-
-/*!
- * \copydoc rb_rescue2
- * \param[in] args exception classes, terminated by 0.
- */
-VALUE
-rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
- VALUE (* r_proc) (VALUE, VALUE), VALUE data2,
- va_list args)
+rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
+ VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
{
enum ruby_tag_type state;
rb_execution_context_t * volatile ec = GET_EC();
rb_control_frame_t *volatile cfp = ec->cfp;
volatile VALUE result = Qfalse;
volatile VALUE e_info = ec->errinfo;
+ va_list args;
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
@@ -1005,12 +912,14 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
int handle = FALSE;
VALUE eclass;
+ va_init_list(args, data2);
while ((eclass = va_arg(args, VALUE)) != 0) {
if (rb_obj_is_kind_of(ec->errinfo, eclass)) {
handle = TRUE;
break;
}
}
+ va_end(args);
if (handle) {
result = Qnil;
@@ -1044,8 +953,8 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
* \ingroup exception
*/
VALUE
-rb_rescue(VALUE (* b_proc)(VALUE), VALUE data1,
- VALUE (* r_proc)(VALUE, VALUE), VALUE data2)
+rb_rescue(VALUE (* b_proc)(ANYARGS), VALUE data1,
+ VALUE (* r_proc)(ANYARGS), VALUE data2)
{
return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError,
(VALUE)0);
@@ -1112,7 +1021,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
* \ingroup exception
*/
VALUE
-rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2)
+rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE data2)
{
int state;
volatile VALUE result = Qnil;
@@ -1253,11 +1162,11 @@ rb_frame_last_func(void)
* append_features(mod) -> mod
*
* When this module is included in another, Ruby calls
- * #append_features in this module, passing it the receiving module
- * in _mod_. Ruby's default implementation is to add the constants,
- * methods, and module variables of this module to _mod_ if this
- * module has not already been added to _mod_ or one of its
- * ancestors. See also Module#include.
+ * <code>append_features</code> in this module, passing it the
+ * receiving module in _mod_. Ruby's default implementation is
+ * to add the constants, methods, and module variables of this module
+ * to _mod_ if this module has not already been added to
+ * _mod_ or one of its ancestors. See also <code>Module#include</code>.
*/
static VALUE
@@ -1275,7 +1184,7 @@ rb_mod_append_features(VALUE module, VALUE include)
* call-seq:
* include(module, ...) -> self
*
- * Invokes Module.append_features on each parameter in reverse order.
+ * Invokes <code>Module.append_features</code> on each parameter in reverse order.
*/
static VALUE
@@ -1302,11 +1211,11 @@ rb_mod_include(int argc, VALUE *argv, VALUE module)
* prepend_features(mod) -> mod
*
* When this module is prepended in another, Ruby calls
- * #prepend_features in this module, passing it the receiving module
- * in _mod_. Ruby's default implementation is to overlay the
- * constants, methods, and module variables of this module to _mod_
- * if this module has not already been added to _mod_ or one of its
- * ancestors. See also Module#prepend.
+ * <code>prepend_features</code> in this module, passing it the
+ * receiving module in _mod_. Ruby's default implementation is
+ * to overlay the constants, methods, and module variables of this module
+ * to _mod_ if this module has not already been added to
+ * _mod_ or one of its ancestors. See also <code>Module#prepend</code>.
*/
static VALUE
@@ -1324,7 +1233,7 @@ rb_mod_prepend_features(VALUE module, VALUE prepend)
* call-seq:
* prepend(module, ...) -> self
*
- * Invokes Module.prepend_features on each parameter in reverse order.
+ * Invokes <code>Module.prepend_features</code> on each parameter in reverse order.
*/
static VALUE
@@ -1410,7 +1319,7 @@ rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module)
FL_SET(module, RMODULE_IS_OVERLAID);
superclass = refinement_superclass(superclass);
c = iclass = rb_include_class_new(module, superclass);
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
+ RCLASS_REFINED_CLASS(c) = klass;
RCLASS_M_TBL(OBJ_WB_UNPROTECT(c)) =
RCLASS_M_TBL(OBJ_WB_UNPROTECT(module)); /* TODO: check unprotecting */
@@ -1419,8 +1328,8 @@ rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module)
while (module && module != klass) {
FL_SET(module, RMODULE_IS_OVERLAID);
c = RCLASS_SET_SUPER(c, rb_include_class_new(module, RCLASS_SUPER(c)));
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
- module = RCLASS_SUPER(module);
+ RCLASS_REFINED_CLASS(c) = klass;
+ module = RCLASS_SUPER(module);
}
rb_hash_aset(CREF_REFINEMENTS(cref), klass, iclass);
}
@@ -1505,12 +1414,12 @@ add_activated_refinement(VALUE activated_refinements,
FL_SET(refinement, RMODULE_IS_OVERLAID);
superclass = refinement_superclass(superclass);
c = iclass = rb_include_class_new(refinement, superclass);
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
+ RCLASS_REFINED_CLASS(c) = klass;
refinement = RCLASS_SUPER(refinement);
while (refinement && refinement != klass) {
FL_SET(refinement, RMODULE_IS_OVERLAID);
c = RCLASS_SET_SUPER(c, rb_include_class_new(refinement, RCLASS_SUPER(c)));
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
+ RCLASS_REFINED_CLASS(c) = klass;
refinement = RCLASS_SUPER(refinement);
}
rb_hash_aset(activated_refinements, klass, iclass);
@@ -1543,9 +1452,6 @@ rb_mod_refine(VALUE module, VALUE klass)
}
ensure_class_or_module(klass);
- if (RB_TYPE_P(klass, T_MODULE)) {
- FL_SET(klass, RCLASS_REFINED_BY_ANY);
- }
CONST_ID(id_refinements, "__refinements__");
refinements = rb_attr_get(module, id_refinements);
if (NIL_P(refinements)) {
@@ -1652,13 +1558,13 @@ used_modules_i(VALUE _, VALUE mod, VALUE ary)
* [B, A]
*/
static VALUE
-rb_mod_s_used_modules(VALUE _)
+rb_mod_s_used_modules(void)
{
const rb_cref_t *cref = rb_vm_cref();
VALUE ary = rb_ary_new();
- while (cref) {
- if (!NIL_P(CREF_REFINEMENTS(cref))) {
+ while(cref) {
+ if(!NIL_P(CREF_REFINEMENTS(cref))) {
rb_hash_foreach(CREF_REFINEMENTS(cref), used_modules_i, ary);
}
cref = CREF_NEXT(cref);
@@ -1681,14 +1587,7 @@ void
rb_obj_call_init(VALUE obj, int argc, const VALUE *argv)
{
PASS_PASSED_BLOCK_HANDLER();
- rb_funcallv_kw(obj, idInitialize, argc, argv, RB_NO_KEYWORDS);
-}
-
-void
-rb_obj_call_init_kw(VALUE obj, int argc, const VALUE *argv, int kw_splat)
-{
- PASS_PASSED_BLOCK_HANDLER();
- rb_funcallv_kw(obj, idInitialize, argc, argv, kw_splat);
+ rb_funcallv(obj, idInitialize, argc, argv);
}
/*!
@@ -1709,7 +1608,7 @@ rb_extend_object(VALUE obj, VALUE module)
*
* Extends the specified object by adding this module's constants and
* methods (which are added as singleton methods). This is the callback
- * method used by Object#extend.
+ * method used by <code>Object#extend</code>.
*
* module Picky
* def Picky.extend_object(o)
@@ -1785,9 +1684,9 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj)
* call-seq:
* include(module, ...) -> self
*
- * Invokes Module.append_features on each parameter in turn.
- * Effectively adds the methods and constants in each module to the
- * receiver.
+ * Invokes <code>Module.append_features</code>
+ * on each parameter in turn. Effectively adds the methods and constants
+ * in each module to the receiver.
*/
static VALUE
@@ -1807,7 +1706,7 @@ top_include(int argc, VALUE *argv, VALUE self)
* using(module) -> self
*
* Import class refinements from <i>module</i> into the scope where
- * #using is called.
+ * <code>using</code> is called.
*/
static VALUE
@@ -1848,8 +1747,8 @@ errinfo_place(const rb_execution_context_t *ec)
return 0;
}
-VALUE
-rb_ec_get_errinfo(const rb_execution_context_t *ec)
+static VALUE
+get_ec_errinfo(const rb_execution_context_t *ec)
{
const VALUE *ptr = errinfo_place(ec);
if (ptr) {
@@ -1867,7 +1766,7 @@ get_errinfo(void)
}
static VALUE
-errinfo_getter(ID id, VALUE *_)
+errinfo_getter(ID id)
{
return get_errinfo();
}
@@ -1902,7 +1801,7 @@ rb_set_errinfo(VALUE err)
}
static VALUE
-errat_getter(ID id, VALUE *_)
+errat_getter(ID id)
{
VALUE err = get_errinfo();
if (!NIL_P(err)) {
@@ -1934,7 +1833,7 @@ errat_setter(VALUE val, ID id, VALUE *var)
*/
static VALUE
-rb_f_method_name(VALUE _)
+rb_f_method_name(void)
{
ID fname = prev_frame_func(); /* need *method* ID */
@@ -1956,7 +1855,7 @@ rb_f_method_name(VALUE _)
*/
static VALUE
-rb_f_callee_name(VALUE _)
+rb_f_callee_name(void)
{
ID fname = prev_frame_callee(); /* need *callee* ID */
@@ -1979,7 +1878,7 @@ rb_f_callee_name(VALUE _)
*
*/
static VALUE
-f_current_dirname(VALUE _)
+f_current_dirname(void)
{
VALUE base = rb_current_realfilepath();
if (NIL_P(base)) {
@@ -1989,76 +1888,16 @@ f_current_dirname(VALUE _)
return base;
}
-/*
- * call-seq:
- * global_variables -> array
- *
- * Returns an array of the names of global variables.
- *
- * global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
- */
-
-static VALUE
-f_global_variables(VALUE _)
-{
- return rb_f_global_variables();
-}
-
-/*
- * call-seq:
- * trace_var(symbol, cmd ) -> nil
- * trace_var(symbol) {|val| block } -> nil
- *
- * Controls tracing of assignments to global variables. The parameter
- * +symbol+ identifies the variable (as either a string name or a
- * symbol identifier). _cmd_ (which may be a string or a
- * +Proc+ object) or block is executed whenever the variable
- * is assigned. The block or +Proc+ object receives the
- * variable's new value as a parameter. Also see
- * Kernel::untrace_var.
- *
- * trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
- * $_ = "hello"
- * $_ = ' there'
- *
- * <em>produces:</em>
- *
- * $_ is now 'hello'
- * $_ is now ' there'
- */
-
-static VALUE
-f_trace_var(int c, const VALUE *a, VALUE _)
-{
- return rb_f_trace_var(c, a);
-}
-
-/*
- * call-seq:
- * untrace_var(symbol [, cmd] ) -> array or nil
- *
- * Removes tracing for the specified command on the given global
- * variable and returns +nil+. If no command is specified,
- * removes all tracing for that variable and returns an array
- * containing the commands actually removed.
- */
-
-static VALUE
-f_untrace_var(int c, const VALUE *a, VALUE _)
-{
- return rb_f_untrace_var(c, a);
-}
-
void
Init_eval(void)
{
rb_define_virtual_variable("$@", errat_getter, errat_setter);
rb_define_virtual_variable("$!", errinfo_getter, 0);
- rb_define_global_function("raise", f_raise, -1);
- rb_define_global_function("fail", f_raise, -1);
+ rb_define_global_function("raise", rb_f_raise, -1);
+ rb_define_global_function("fail", rb_f_raise, -1);
- rb_define_global_function("global_variables", f_global_variables, 0);
+ rb_define_global_function("global_variables", rb_f_global_variables, 0); /* in variable.c */
rb_define_global_function("__method__", rb_f_method_name, 0);
rb_define_global_function("__callee__", rb_f_callee_name, 0);
@@ -2091,12 +1930,13 @@ Init_eval(void)
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
- rb_define_global_function("trace_var", f_trace_var, -1);
- rb_define_global_function("untrace_var", f_untrace_var, -1);
+ rb_define_global_function("trace_var", rb_f_trace_var, -1); /* in variable.c */
+ rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
rb_vm_register_special_exception(ruby_error_reenter, rb_eFatal, "exception reentered");
rb_vm_register_special_exception(ruby_error_stackfatal, rb_eFatal, "machine stack overflow in critical region");
id_signo = rb_intern_const("signo");
id_status = rb_intern_const("status");
+ id_cause = rb_intern_const("cause");
}
diff --git a/eval_error.c b/eval_error.c
index 9d2de6dbc5..cd7a607eaa 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -3,20 +3,26 @@
* included by eval.c
*/
-#define write_warn(str, x) \
- (NIL_P(str) ? warn_print(x) : (void)rb_str_cat_cstr(str, x))
-#define write_warn2(str, x, l) \
- (NIL_P(str) ? warn_print2(x, l) : (void)rb_str_cat(str, x, l))
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
+#define write_warn(str, x) RB_GNUC_EXTENSION_BLOCK( \
+ NIL_P(str) ? \
+ warn_print(x) : (void)( \
+ (__builtin_constant_p(x)) ? \
+ rb_str_concat((str), rb_str_new((x), (long)strlen(x))) : \
+ rb_str_concat((str), rb_str_new2(x)) \
+ ) \
+ )
#define warn_print(x) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(x)) ? \
rb_write_error2((x), (long)strlen(x)) : \
rb_write_error(x) \
)
#else
+#define write_warn(str, x) NIL_P(str) ? rb_write_error((x)) : (void)rb_str_concat((str), rb_str_new2(x))
#define warn_print(x) rb_write_error(x)
#endif
+#define write_warn2(str,x,l) NIL_P(str) ? warn_print2(x,l) : (void)rb_str_concat((str), rb_str_new((x),(l)))
#define warn_print2(x,l) rb_write_error2((x),(l))
#define write_warn_str(str,x) NIL_P(str) ? rb_write_error_str(x) : (void)rb_str_concat((str), (x))
@@ -79,47 +85,6 @@ error_print(rb_execution_context_t *ec)
rb_ec_error_print(ec, ec->errinfo);
}
-static void
-write_warnq(VALUE out, VALUE str, const char *ptr, long len)
-{
- if (NIL_P(out)) {
- const char *beg = ptr;
- const long olen = len;
- for (; len > 0; --len, ++ptr) {
- unsigned char c = *ptr;
- switch (c) {
- case '\n': case '\t': continue;
- }
- if (rb_iscntrl(c)) {
- char buf[5];
- const char *cc = 0;
- if (ptr > beg) rb_write_error2(beg, ptr - beg);
- beg = ptr + 1;
- cc = ruby_escaped_char(c);
- if (cc) {
- rb_write_error2(cc, strlen(cc));
- }
- else {
- rb_write_error2(buf, snprintf(buf, sizeof(buf), "\\x%02X", c));
- }
- }
- else if (c == '\\') {
- rb_write_error2(beg, ptr - beg + 1);
- beg = ptr;
- }
- }
- if (ptr > beg) {
- if (beg == RSTRING_PTR(str) && olen == RSTRING_LEN(str))
- rb_write_error_str(str);
- else
- rb_write_error2(beg, ptr - beg);
- }
- }
- else {
- rb_str_cat(out, ptr, len);
- }
-}
-
#define CSI_BEGIN "\033["
#define CSI_SGR "m"
@@ -128,7 +93,7 @@ static const char bold[] = CSI_BEGIN"1"CSI_SGR;
static const char reset[] = CSI_BEGIN""CSI_SGR;
static void
-print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VALUE str, int highlight)
+print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VALUE str, int colored)
{
const char *einfo = "";
long elen = 0;
@@ -144,6 +109,8 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA
write_warn(str, ": ");
}
+ if (colored) write_warn(str, bold);
+
if (!NIL_P(emesg)) {
einfo = RSTRING_PTR(emesg);
elen = RSTRING_LEN(emesg);
@@ -151,80 +118,44 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA
}
if (eclass == rb_eRuntimeError && elen == 0) {
- if (highlight) write_warn(str, underline);
- write_warn(str, "unhandled exception");
- if (highlight) write_warn(str, reset);
- write_warn2(str, "\n", 1);
+ if (colored) write_warn(str, underline);
+ write_warn(str, "unhandled exception\n");
}
else {
VALUE epath;
epath = rb_class_name(eclass);
if (elen == 0) {
- if (highlight) write_warn(str, underline);
+ if (colored) write_warn(str, underline);
write_warn_str(str, epath);
- if (highlight) write_warn(str, reset);
write_warn(str, "\n");
}
else {
- /* emesg is a String instance */
const char *tail = 0;
+ long len = elen;
- if (highlight) write_warn(str, bold);
if (RSTRING_PTR(epath)[0] == '#')
epath = 0;
if ((tail = memchr(einfo, '\n', elen)) != 0) {
- write_warnq(str, emesg, einfo, tail - einfo);
+ len = tail - einfo;
tail++; /* skip newline */
}
- else {
- write_warnq(str, emesg, einfo, elen);
- }
+ write_warn_str(str, tail ? rb_str_subseq(emesg, 0, len) : emesg);
if (epath) {
write_warn(str, " (");
- if (highlight) write_warn(str, underline);
+ if (colored) write_warn(str, underline);
write_warn_str(str, epath);
- if (highlight) {
- write_warn(str, reset);
- write_warn(str, bold);
- }
- write_warn2(str, ")", 1);
- if (highlight) write_warn(str, reset);
- write_warn2(str, "\n", 1);
- }
- if (tail && einfo+elen > tail) {
- if (!highlight) {
- write_warnq(str, emesg, tail, einfo+elen-tail);
- if (einfo[elen-1] != '\n') write_warn2(str, "\n", 1);
- }
- else {
- elen -= tail - einfo;
- einfo = tail;
- while (elen > 0) {
- tail = memchr(einfo, '\n', elen);
- if (!tail || tail > einfo) {
- write_warn(str, bold);
- write_warnq(str, emesg, einfo, tail ? tail-einfo : elen);
- write_warn(str, reset);
- if (!tail) {
- write_warn2(str, "\n", 1);
- break;
- }
- }
- elen -= tail - einfo;
- einfo = tail;
- do ++tail; while (tail < einfo+elen && *tail == '\n');
- write_warnq(str, emesg, einfo, tail-einfo);
- elen -= tail - einfo;
- einfo = tail;
- }
- }
+ if (colored) write_warn(str, reset);
+ if (colored) write_warn(str, bold);
+ write_warn(str, ")\n");
}
- else if (!epath) {
- write_warn2(str, "\n", 1);
+ if (tail) {
+ write_warn_str(str, rb_str_subseq(emesg, tail - einfo, elen - len - 1));
}
+ if (tail ? einfo[elen-1] != '\n' : !epath) write_warn2(str, "\n", 1);
}
}
+ if (colored) write_warn(str, reset);
}
static void
@@ -235,7 +166,7 @@ print_backtrace(const VALUE eclass, const VALUE errat, const VALUE str, int reve
long len = RARRAY_LEN(errat);
int skip = eclass == rb_eSysStackError;
const int threshold = 1000000000;
- int width = (len <= 1) ? INT_MIN : ((int)log10((double)(len > threshold ?
+ int width = ((int)log10((double)(len > threshold ?
((len - 1) / threshold) :
len - 1)) +
(len < threshold ? 0 : 9) + 1);
@@ -260,47 +191,10 @@ print_backtrace(const VALUE eclass, const VALUE errat, const VALUE str, int reve
}
}
-VALUE rb_get_message(VALUE exc);
-
-static int
-shown_cause_p(VALUE cause, VALUE *shown_causes)
-{
- VALUE shown = *shown_causes;
- if (!shown) {
- *shown_causes = shown = rb_obj_hide(rb_ident_hash_new());
- }
- if (rb_hash_has_key(shown, cause)) return TRUE;
- rb_hash_aset(shown, cause, Qtrue);
- return FALSE;
-}
-
-static void
-show_cause(VALUE errinfo, VALUE str, VALUE highlight, VALUE reverse, VALUE *shown_causes)
-{
- VALUE cause = rb_attr_get(errinfo, id_cause);
- if (!NIL_P(cause) && rb_obj_is_kind_of(cause, rb_eException) &&
- !shown_cause_p(cause, shown_causes)) {
- volatile VALUE eclass = CLASS_OF(cause);
- VALUE errat = rb_get_backtrace(cause);
- VALUE emesg = rb_get_message(cause);
- if (reverse) {
- show_cause(cause, str, highlight, reverse, shown_causes);
- print_backtrace(eclass, errat, str, TRUE);
- print_errinfo(eclass, errat, emesg, str, highlight!=0);
- }
- else {
- print_errinfo(eclass, errat, emesg, str, highlight!=0);
- print_backtrace(eclass, errat, str, FALSE);
- show_cause(cause, str, highlight, reverse, shown_causes);
- }
- }
-}
-
void
rb_error_write(VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE highlight, VALUE reverse)
{
volatile VALUE eclass;
- VALUE shown_causes = 0;
if (NIL_P(errinfo))
return;
@@ -331,24 +225,23 @@ rb_error_write(VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE highlig
len = p - (msg = buff);
}
write_warn2(str, msg, len);
- show_cause(errinfo, str, highlight, reverse, &shown_causes);
print_backtrace(eclass, errat, str, TRUE);
print_errinfo(eclass, errat, emesg, str, highlight!=0);
}
else {
print_errinfo(eclass, errat, emesg, str, highlight!=0);
print_backtrace(eclass, errat, str, FALSE);
- show_cause(errinfo, str, highlight, reverse, &shown_causes);
}
}
+VALUE rb_get_message(VALUE exc);
+
void
rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo)
{
- volatile uint8_t raised_flag = ec->raised_flag;
+ volatile int raised_flag = ec->raised_flag;
volatile VALUE errat = Qundef;
volatile VALUE emesg = Qundef;
- volatile bool written = false;
if (NIL_P(errinfo))
return;
@@ -363,17 +256,14 @@ rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo)
emesg = rb_get_message(errinfo);
}
- if (!written) {
- written = true;
- rb_error_write(errinfo, emesg, errat, Qnil, Qnil, Qnil);
- }
+ rb_error_write(errinfo, emesg, errat, Qnil, Qnil, Qnil);
EC_POP_TAG();
ec->errinfo = errinfo;
rb_ec_raised_set(ec, raised_flag);
}
-#define undef_mesg_for(v, k) rb_fstring_lit("undefined"v" method `%1$s' for "k" `%2$s'")
+#define undef_mesg_for(v, k) rb_fstring_cstr("undefined"v" method `%1$s' for "k" `%2$s'")
#define undef_mesg(v) ( \
is_mod ? \
undef_mesg_for(v, "module") : \
@@ -401,7 +291,7 @@ rb_print_undef_str(VALUE klass, VALUE name)
rb_name_err_raise_str(undef_mesg(""), klass, name);
}
-#define inaccessible_mesg_for(v, k) rb_fstring_lit("method `%1$s' for "k" `%2$s' is "v)
+#define inaccessible_mesg_for(v, k) rb_fstring_cstr("method `%1$s' for "k" `%2$s' is "v)
#define inaccessible_mesg(v) ( \
is_mod ? \
inaccessible_mesg_for(v, "module") : \
@@ -433,9 +323,10 @@ sysexit_status(VALUE err)
rb_bug("Unknown longjmp status %d", status)
static int
-error_handle(rb_execution_context_t *ec, int ex)
+error_handle(int ex)
{
int status = EXIT_FAILURE;
+ rb_execution_context_t *ec = GET_EC();
if (rb_ec_set_raised(ec))
return EXIT_FAILURE;
diff --git a/eval_intern.h b/eval_intern.h
index a8eb828597..420f3d3b36 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -15,6 +15,7 @@ static inline void
pass_passed_block_handler(rb_execution_context_t *ec)
{
VALUE block_handler = rb_vm_frame_block_handler(ec->cfp);
+ vm_block_handler_verify(block_handler);
vm_passed_block_handler_set(ec, block_handler);
VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_PASSED);
}
@@ -157,6 +158,23 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
# define VAR_NOCLOBBERED(var) var
#endif
+#if defined(USE_UNALIGNED_MEMBER_ACCESS) && USE_UNALIGNED_MEMBER_ACCESS && \
+ defined(__clang__)
+# define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\""); \
+ typeof(expr) unaligned_member_access_result = (expr); \
+ _Pragma("GCC diagnostic pop"); \
+ unaligned_member_access_result; \
+})
+#else
+# define UNALIGNED_MEMBER_ACCESS(expr) expr
+#endif
+#define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
+
+#undef RB_OBJ_WRITE
+#define RB_OBJ_WRITE(a, slot, b) UNALIGNED_MEMBER_ACCESS(rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__))
+
/* clear ec->tag->state, and return the value */
static inline int
rb_ec_tag_state(const rb_execution_context_t *ec)
@@ -250,6 +268,9 @@ CREF_OMOD_SHARED_UNSET(rb_cref_t *cref)
cref->flags &= ~CREF_FL_OMOD_SHARED;
}
+void rb_thread_cleanup(void);
+void rb_thread_wait_other_threads(void);
+
enum {
RAISED_EXCEPTION = 1,
RAISED_STACKOVERFLOW = 2,
@@ -274,7 +295,9 @@ NORETURN(void rb_print_undef(VALUE, ID, rb_method_visibility_t));
NORETURN(void rb_print_undef_str(VALUE, VALUE));
NORETURN(void rb_print_inaccessible(VALUE, ID, rb_method_visibility_t));
NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
+#if 0
NORETURN(void rb_vm_jump_tag_but_local_jump(int));
+#endif
VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
rb_cref_t *rb_vm_cref(void);
@@ -287,20 +310,10 @@ VALUE rb_vm_cbase(void);
/* vm_backtrace.c */
VALUE rb_ec_backtrace_object(const rb_execution_context_t *ec);
VALUE rb_ec_backtrace_str_ary(const rb_execution_context_t *ec, long lev, long n);
-VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, long n);
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
# ifdef HAVE_MBLEN
-# define CharNext(p) rb_char_next(p)
-static inline const char *
-rb_char_next(const char *p)
-{
- if (p) {
- int len = mblen(p, RUBY_MBCHAR_MAXSIZE);
- p += len > 0 ? len : 1;
- }
- return p;
-}
+# define CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))
# else
# define CharNext(p) ((p) + 1)
# endif
diff --git a/eval_jump.c b/eval_jump.c
index 75d4ad0207..9ea69736cf 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -35,7 +35,7 @@ rb_call_end_proc(VALUE data)
*/
static VALUE
-rb_f_at_exit(VALUE _)
+rb_f_at_exit(void)
{
VALUE proc;
@@ -50,6 +50,7 @@ rb_f_at_exit(VALUE _)
struct end_proc_data {
void (*func) ();
VALUE data;
+ int safe;
struct end_proc_data *next;
};
@@ -71,6 +72,7 @@ rb_set_end_proc(void (*func)(VALUE), VALUE data)
link->next = *list;
link->func = func;
link->data = data;
+ link->safe = rb_safe_level();
*list = link;
}
@@ -102,15 +104,18 @@ exec_end_procs_chain(struct end_proc_data *volatile *procs, VALUE *errp)
*procs = link->next;
endproc = *link;
xfree(link);
+ rb_set_safe_level_force(endproc.safe);
(*endproc.func) (endproc.data);
*errp = errinfo;
}
}
-static void
-rb_ec_exec_end_proc(rb_execution_context_t * ec)
+void
+rb_exec_end_proc(void)
{
enum ruby_tag_type state;
+ volatile int safe = rb_safe_level();
+ rb_execution_context_t * volatile ec = GET_EC();
volatile VALUE errinfo = ec->errinfo;
EC_PUSH_TAG(ec);
@@ -121,13 +126,14 @@ rb_ec_exec_end_proc(rb_execution_context_t * ec)
}
else {
EC_TMPPOP_TAG();
- error_handle(ec, state);
+ error_handle(state);
if (!NIL_P(ec->errinfo)) errinfo = ec->errinfo;
EC_REPUSH_TAG();
goto again;
}
EC_POP_TAG();
+ rb_set_safe_level_force(safe);
ec->errinfo = errinfo;
}
diff --git a/ext/-test-/arith_seq/extract/depend b/ext/-test-/arith_seq/extract/depend
deleted file mode 100644
index bb0719941f..0000000000
--- a/ext/-test-/arith_seq/extract/depend
+++ /dev/null
@@ -1,13 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-extract.o: $(RUBY_EXTCONF_H)
-extract.o: $(arch_hdrdir)/ruby/config.h
-extract.o: $(hdrdir)/ruby/assert.h
-extract.o: $(hdrdir)/ruby/backward.h
-extract.o: $(hdrdir)/ruby/defines.h
-extract.o: $(hdrdir)/ruby/intern.h
-extract.o: $(hdrdir)/ruby/missing.h
-extract.o: $(hdrdir)/ruby/ruby.h
-extract.o: $(hdrdir)/ruby/st.h
-extract.o: $(hdrdir)/ruby/subst.h
-extract.o: extract.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/arith_seq/extract/extconf.rb b/ext/-test-/arith_seq/extract/extconf.rb
deleted file mode 100644
index 9c368bf50e..0000000000
--- a/ext/-test-/arith_seq/extract/extconf.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# frozen_string_literal: false
-create_makefile("-test-/arith_seq/extract")
diff --git a/ext/-test-/arith_seq/extract/extract.c b/ext/-test-/arith_seq/extract/extract.c
deleted file mode 100644
index 93b89c239a..0000000000
--- a/ext/-test-/arith_seq/extract/extract.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "ruby/ruby.h"
-
-static VALUE
-arith_seq_s_extract(VALUE mod, VALUE obj)
-{
- rb_arithmetic_sequence_components_t x;
- VALUE ret;
- int r;
-
- r = rb_arithmetic_sequence_extract(obj, &x);
-
- ret = rb_ary_new2(5);
- rb_ary_store(ret, 0, r ? x.begin : Qnil);
- rb_ary_store(ret, 1, r ? x.end : Qnil);
- rb_ary_store(ret, 2, r ? x.step : Qnil);
- rb_ary_store(ret, 3, r ? INT2FIX(x.exclude_end) : Qnil);
- rb_ary_store(ret, 4, INT2FIX(r));
-
- return ret;
-}
-
-void
-Init_extract(void)
-{
- VALUE cArithSeq = rb_path2class("Enumerator::ArithmeticSequence");
- rb_define_singleton_method(cArithSeq, "__extract__", arith_seq_s_extract, 1);
-}
diff --git a/ext/-test-/array/resize/depend b/ext/-test-/array/resize/depend
index a03cc47d51..177c527db2 100644
--- a/ext/-test-/array/resize/depend
+++ b/ext/-test-/array/resize/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
resize.o: $(RUBY_EXTCONF_H)
resize.o: $(arch_hdrdir)/ruby/config.h
-resize.o: $(hdrdir)/ruby/assert.h
resize.o: $(hdrdir)/ruby/backward.h
resize.o: $(hdrdir)/ruby/defines.h
resize.o: $(hdrdir)/ruby/intern.h
diff --git a/ext/-test-/bignum/depend b/ext/-test-/bignum/depend
index 38c9f6114e..60e711489c 100644
--- a/ext/-test-/bignum/depend
+++ b/ext/-test-/bignum/depend
@@ -1,47 +1,60 @@
+big2str.o: big2str.c
+div.o: div.c
+intpack.o: intpack.c
+mul.o: mul.c
+str2big.o: str2big.c
+
# AUTOGENERATED DEPENDENCIES START
big2str.o: $(RUBY_EXTCONF_H)
big2str.o: $(arch_hdrdir)/ruby/config.h
-big2str.o: $(hdrdir)/ruby.h
-big2str.o: $(hdrdir)/ruby/assert.h
big2str.o: $(hdrdir)/ruby/backward.h
big2str.o: $(hdrdir)/ruby/defines.h
+big2str.o: $(hdrdir)/ruby/encoding.h
big2str.o: $(hdrdir)/ruby/intern.h
+big2str.o: $(hdrdir)/ruby/io.h
big2str.o: $(hdrdir)/ruby/missing.h
+big2str.o: $(hdrdir)/ruby/onigmo.h
+big2str.o: $(hdrdir)/ruby/oniguruma.h
big2str.o: $(hdrdir)/ruby/ruby.h
big2str.o: $(hdrdir)/ruby/st.h
big2str.o: $(hdrdir)/ruby/subst.h
+big2str.o: $(top_srcdir)/include/ruby.h
big2str.o: $(top_srcdir)/internal.h
big2str.o: big2str.c
bigzero.o: $(RUBY_EXTCONF_H)
bigzero.o: $(arch_hdrdir)/ruby/config.h
-bigzero.o: $(hdrdir)/ruby.h
-bigzero.o: $(hdrdir)/ruby/assert.h
bigzero.o: $(hdrdir)/ruby/backward.h
bigzero.o: $(hdrdir)/ruby/defines.h
+bigzero.o: $(hdrdir)/ruby/encoding.h
bigzero.o: $(hdrdir)/ruby/intern.h
+bigzero.o: $(hdrdir)/ruby/io.h
bigzero.o: $(hdrdir)/ruby/missing.h
+bigzero.o: $(hdrdir)/ruby/onigmo.h
+bigzero.o: $(hdrdir)/ruby/oniguruma.h
bigzero.o: $(hdrdir)/ruby/ruby.h
bigzero.o: $(hdrdir)/ruby/st.h
bigzero.o: $(hdrdir)/ruby/subst.h
+bigzero.o: $(top_srcdir)/include/ruby.h
bigzero.o: $(top_srcdir)/internal.h
bigzero.o: bigzero.c
div.o: $(RUBY_EXTCONF_H)
div.o: $(arch_hdrdir)/ruby/config.h
-div.o: $(hdrdir)/ruby.h
-div.o: $(hdrdir)/ruby/assert.h
div.o: $(hdrdir)/ruby/backward.h
div.o: $(hdrdir)/ruby/defines.h
+div.o: $(hdrdir)/ruby/encoding.h
div.o: $(hdrdir)/ruby/intern.h
+div.o: $(hdrdir)/ruby/io.h
div.o: $(hdrdir)/ruby/missing.h
+div.o: $(hdrdir)/ruby/onigmo.h
+div.o: $(hdrdir)/ruby/oniguruma.h
div.o: $(hdrdir)/ruby/ruby.h
div.o: $(hdrdir)/ruby/st.h
div.o: $(hdrdir)/ruby/subst.h
+div.o: $(top_srcdir)/include/ruby.h
div.o: $(top_srcdir)/internal.h
div.o: div.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -49,44 +62,54 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
intpack.o: $(RUBY_EXTCONF_H)
intpack.o: $(arch_hdrdir)/ruby/config.h
-intpack.o: $(hdrdir)/ruby.h
-intpack.o: $(hdrdir)/ruby/assert.h
intpack.o: $(hdrdir)/ruby/backward.h
intpack.o: $(hdrdir)/ruby/defines.h
+intpack.o: $(hdrdir)/ruby/encoding.h
intpack.o: $(hdrdir)/ruby/intern.h
+intpack.o: $(hdrdir)/ruby/io.h
intpack.o: $(hdrdir)/ruby/missing.h
+intpack.o: $(hdrdir)/ruby/onigmo.h
+intpack.o: $(hdrdir)/ruby/oniguruma.h
intpack.o: $(hdrdir)/ruby/ruby.h
intpack.o: $(hdrdir)/ruby/st.h
intpack.o: $(hdrdir)/ruby/subst.h
+intpack.o: $(top_srcdir)/include/ruby.h
intpack.o: $(top_srcdir)/internal.h
intpack.o: intpack.c
mul.o: $(RUBY_EXTCONF_H)
mul.o: $(arch_hdrdir)/ruby/config.h
-mul.o: $(hdrdir)/ruby.h
-mul.o: $(hdrdir)/ruby/assert.h
mul.o: $(hdrdir)/ruby/backward.h
mul.o: $(hdrdir)/ruby/defines.h
+mul.o: $(hdrdir)/ruby/encoding.h
mul.o: $(hdrdir)/ruby/intern.h
+mul.o: $(hdrdir)/ruby/io.h
mul.o: $(hdrdir)/ruby/missing.h
+mul.o: $(hdrdir)/ruby/onigmo.h
+mul.o: $(hdrdir)/ruby/oniguruma.h
mul.o: $(hdrdir)/ruby/ruby.h
mul.o: $(hdrdir)/ruby/st.h
mul.o: $(hdrdir)/ruby/subst.h
+mul.o: $(top_srcdir)/include/ruby.h
mul.o: $(top_srcdir)/internal.h
mul.o: mul.c
str2big.o: $(RUBY_EXTCONF_H)
str2big.o: $(arch_hdrdir)/ruby/config.h
-str2big.o: $(hdrdir)/ruby.h
-str2big.o: $(hdrdir)/ruby/assert.h
str2big.o: $(hdrdir)/ruby/backward.h
str2big.o: $(hdrdir)/ruby/defines.h
+str2big.o: $(hdrdir)/ruby/encoding.h
str2big.o: $(hdrdir)/ruby/intern.h
+str2big.o: $(hdrdir)/ruby/io.h
str2big.o: $(hdrdir)/ruby/missing.h
+str2big.o: $(hdrdir)/ruby/onigmo.h
+str2big.o: $(hdrdir)/ruby/oniguruma.h
str2big.o: $(hdrdir)/ruby/ruby.h
str2big.o: $(hdrdir)/ruby/st.h
str2big.o: $(hdrdir)/ruby/subst.h
+str2big.o: $(top_srcdir)/include/ruby.h
str2big.o: $(top_srcdir)/internal.h
str2big.o: str2big.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/bug-14834/bug-14384.c b/ext/-test-/bug-14834/bug-14384.c
deleted file mode 100644
index 3a16a2d222..0000000000
--- a/ext/-test-/bug-14834/bug-14384.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <ruby/ruby.h>
-#include <ruby/debug.h>
-
-#ifndef MAYBE_UNUSED
-# define MAYBE_UNUSED(x) x
-#endif
-
-static NOINLINE(VALUE f(VALUE));
-static NOINLINE(void g(VALUE, void*));
-extern NOINLINE(void Init_bug_14384(void));
-
-void
-Init_bug_14834(void)
-{
- VALUE q = rb_define_module("Bug");
- rb_define_module_function(q, "bug_14834", f, 0);
-}
-
-VALUE
-f(VALUE q)
-{
- int w[] = { 0, 1024 };
- VALUE e = rb_tracepoint_new(Qnil, RUBY_INTERNAL_EVENT_NEWOBJ, g, w);
-
- rb_tracepoint_enable(e);
- return rb_ensure(rb_yield, q, rb_tracepoint_disable, e);
-}
-
-void
-g(MAYBE_UNUSED(VALUE q), void* w)
-{
- const int *e = (const int *)w;
- const int r = *e++;
- const int t = *e++;
- VALUE *y = ALLOCA_N(VALUE, t);
- int *u = ALLOCA_N(int, t);
-
- rb_profile_frames(r, t, y, u);
-}
diff --git a/ext/-test-/bug-14834/depend b/ext/-test-/bug-14834/depend
deleted file mode 100644
index 5206f995be..0000000000
--- a/ext/-test-/bug-14834/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-bug-14384.o: $(RUBY_EXTCONF_H)
-bug-14384.o: $(arch_hdrdir)/ruby/config.h
-bug-14384.o: $(hdrdir)/ruby/assert.h
-bug-14384.o: $(hdrdir)/ruby/backward.h
-bug-14384.o: $(hdrdir)/ruby/debug.h
-bug-14384.o: $(hdrdir)/ruby/defines.h
-bug-14384.o: $(hdrdir)/ruby/intern.h
-bug-14384.o: $(hdrdir)/ruby/missing.h
-bug-14384.o: $(hdrdir)/ruby/ruby.h
-bug-14384.o: $(hdrdir)/ruby/st.h
-bug-14384.o: $(hdrdir)/ruby/subst.h
-bug-14384.o: bug-14384.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/bug-14834/extconf.rb b/ext/-test-/bug-14834/extconf.rb
deleted file mode 100644
index e8f3f1f437..0000000000
--- a/ext/-test-/bug-14834/extconf.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# frozen_string_literal: true
-create_makefile("-test-/bug_14834")
diff --git a/ext/-test-/bug-3571/bug.c b/ext/-test-/bug-3571/bug.c
index dd3c85cd79..a64f054740 100644
--- a/ext/-test-/bug-3571/bug.c
+++ b/ext/-test-/bug-3571/bug.c
@@ -8,7 +8,7 @@ bug_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
}
static VALUE
-bug_start(VALUE self)
+bug_start(VALUE self, VALUE hash)
{
VALUE ary = rb_ary_new3(1, Qnil);
rb_block_call(ary, rb_intern("map"), 0, 0, bug_i, self);
diff --git a/ext/-test-/bug-3571/depend b/ext/-test-/bug-3571/depend
deleted file mode 100644
index 74911f0af4..0000000000
--- a/ext/-test-/bug-3571/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-bug.o: $(RUBY_EXTCONF_H)
-bug.o: $(arch_hdrdir)/ruby/config.h
-bug.o: $(hdrdir)/ruby.h
-bug.o: $(hdrdir)/ruby/assert.h
-bug.o: $(hdrdir)/ruby/backward.h
-bug.o: $(hdrdir)/ruby/defines.h
-bug.o: $(hdrdir)/ruby/intern.h
-bug.o: $(hdrdir)/ruby/missing.h
-bug.o: $(hdrdir)/ruby/ruby.h
-bug.o: $(hdrdir)/ruby/st.h
-bug.o: $(hdrdir)/ruby/subst.h
-bug.o: bug.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/bug-5832/depend b/ext/-test-/bug-5832/depend
deleted file mode 100644
index 74911f0af4..0000000000
--- a/ext/-test-/bug-5832/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-bug.o: $(RUBY_EXTCONF_H)
-bug.o: $(arch_hdrdir)/ruby/config.h
-bug.o: $(hdrdir)/ruby.h
-bug.o: $(hdrdir)/ruby/assert.h
-bug.o: $(hdrdir)/ruby/backward.h
-bug.o: $(hdrdir)/ruby/defines.h
-bug.o: $(hdrdir)/ruby/intern.h
-bug.o: $(hdrdir)/ruby/missing.h
-bug.o: $(hdrdir)/ruby/ruby.h
-bug.o: $(hdrdir)/ruby/st.h
-bug.o: $(hdrdir)/ruby/subst.h
-bug.o: bug.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/bug_reporter/depend b/ext/-test-/bug_reporter/depend
deleted file mode 100644
index 62bac03566..0000000000
--- a/ext/-test-/bug_reporter/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-bug_reporter.o: $(RUBY_EXTCONF_H)
-bug_reporter.o: $(arch_hdrdir)/ruby/config.h
-bug_reporter.o: $(hdrdir)/ruby.h
-bug_reporter.o: $(hdrdir)/ruby/assert.h
-bug_reporter.o: $(hdrdir)/ruby/backward.h
-bug_reporter.o: $(hdrdir)/ruby/defines.h
-bug_reporter.o: $(hdrdir)/ruby/intern.h
-bug_reporter.o: $(hdrdir)/ruby/missing.h
-bug_reporter.o: $(hdrdir)/ruby/ruby.h
-bug_reporter.o: $(hdrdir)/ruby/st.h
-bug_reporter.o: $(hdrdir)/ruby/subst.h
-bug_reporter.o: bug_reporter.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/class/depend b/ext/-test-/class/depend
index 451256cc75..40f3d7ab6d 100644
--- a/ext/-test-/class/depend
+++ b/ext/-test-/class/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
class2name.o: $(RUBY_EXTCONF_H)
class2name.o: $(arch_hdrdir)/ruby/config.h
-class2name.o: $(hdrdir)/ruby/assert.h
class2name.o: $(hdrdir)/ruby/backward.h
class2name.o: $(hdrdir)/ruby/defines.h
class2name.o: $(hdrdir)/ruby/intern.h
@@ -12,8 +11,6 @@ class2name.o: $(hdrdir)/ruby/subst.h
class2name.o: class2name.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -21,5 +18,6 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/cxxanyargs/cxxanyargs.cpp b/ext/-test-/cxxanyargs/cxxanyargs.cpp
deleted file mode 100644
index efe35fa359..0000000000
--- a/ext/-test-/cxxanyargs/cxxanyargs.cpp
+++ /dev/null
@@ -1,619 +0,0 @@
-#include <ruby/ruby.h>
-
-#if 0 // Warnings expected, should just suppress them
-
-#elif defined(_MSC_VER)
-#pragma warning(disable : 4996)
-
-#elif defined(__clang__)
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
-#elif defined(__GNUC__)
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
-#else
-// :FIXME: improve here for your compiler.
-
-#endif
-
-namespace test_rb_define_virtual_variable {
- VALUE
- getter(ID, VALUE *data)
- {
- return *data;
- }
-
- void
- setter(VALUE val, ID, VALUE *data)
- {
- *data = val;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_define_virtual_variable("test",
- RUBY_METHOD_FUNC(getter),
- reinterpret_cast<void(*)(ANYARGS)>(setter)); // old
- rb_define_virtual_variable("test", getter, setter); // new
- return self;
- }
-}
-
-struct test_rb_define_hooked_variable {
- static VALUE v;
-
- static VALUE
- getter(ID, VALUE *data)
- {
- return *data;
- }
-
- static void
- setter(VALUE val, ID, VALUE *data)
- {
- *data = val;
- }
-
- static VALUE
- test(VALUE self)
- {
- rb_define_hooked_variable("test", &v,
- RUBY_METHOD_FUNC(getter),
- reinterpret_cast<void(*)(ANYARGS)>(setter)); // old
- rb_define_hooked_variable("test", &v, getter, setter); // new
- return self;
- }
-};
-VALUE test_rb_define_hooked_variable::v = Qundef;
-
-namespace test_rb_iterate {
- VALUE
- iter(VALUE self)
- {
- return rb_funcall(self, rb_intern("yield"), 0);
- }
-
- VALUE
- block(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
- {
- return rb_funcall(arg, rb_intern("=="), 1, param);
- }
-
- VALUE
- test(VALUE self)
- {
- rb_iterate(iter, self, RUBY_METHOD_FUNC(block), self); // old
- return rb_iterate(iter, self, block, self); // new
- }
-}
-
-namespace test_rb_block_call {
- VALUE
- block(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
- {
- return rb_funcall(arg, rb_intern("=="), 1, param);
- }
-
- VALUE
- test(VALUE self)
- {
- const ID mid = rb_intern("each");
- const VALUE argv[] = { Qundef };
- rb_block_call(self, mid, 0, argv, RUBY_METHOD_FUNC(block), self); // old
- return rb_block_call(self, mid, 0, argv, block, self); // new
- }
-}
-
-namespace test_rb_rescue {
- VALUE
- begin(VALUE arg)
- {
- return arg;
- }
-
- VALUE
- rescue(VALUE arg, VALUE exc)
- {
- return exc;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_rescue(RUBY_METHOD_FUNC(begin), self, RUBY_METHOD_FUNC(rescue), self); // old
- return rb_rescue(begin, self, rescue, self); // new
- }
-}
-
-namespace test_rb_rescue2 {
- VALUE
- begin(VALUE arg)
- {
- return arg;
- }
-
- VALUE
- rescue(VALUE arg, VALUE exc)
- {
- return exc;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_rescue2(RUBY_METHOD_FUNC(begin), self, RUBY_METHOD_FUNC(rescue), self,
- rb_eStandardError, rb_eFatal, 0); // old
- return rb_rescue2(begin, self, rescue, self, rb_eStandardError, rb_eFatal, 0); // new
- }
-}
-
-namespace test_rb_ensure {
- VALUE
- begin(VALUE arg)
- {
- return arg;
- }
-
- VALUE
- ensure(VALUE arg)
- {
- return arg;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_ensure(RUBY_METHOD_FUNC(begin), self, RUBY_METHOD_FUNC(ensure), self); // old
- return rb_ensure(begin, self, ensure, self); // new
- }
-}
-
-namespace test_rb_catch {
- VALUE
- catcher(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
- {
- return arg;
- }
-
- VALUE
- test(VALUE self)
- {
- static const char *zero = 0;
- rb_catch(zero, RUBY_METHOD_FUNC(catcher), self); // old
- return rb_catch(zero, catcher, self); // new
- }
-}
-
-namespace test_rb_catch_obj {
- VALUE
- catcher(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
- {
- return arg;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_catch_obj(self, RUBY_METHOD_FUNC(catcher), self); // old
- return rb_catch_obj(self, catcher, self); // new
- }
-}
-
-namespace test_rb_fiber_new {
- VALUE
- fiber(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
- {
- return arg;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_fiber_new(RUBY_METHOD_FUNC(fiber), self); // old
- return rb_fiber_new(fiber, self); // new
- }
-}
-
-namespace test_rb_proc_new {
- VALUE
- proc(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
- {
- return arg;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_fiber_new(RUBY_METHOD_FUNC(proc), self); // old
- return rb_fiber_new(proc, self); // new
- }
-}
-
-struct test_rb_thread_create {
- static VALUE v;
-
- static VALUE
- thread(void *ptr)
- {
- const VALUE *w = reinterpret_cast<const VALUE*>(ptr);
- return *w;
- }
-
- static VALUE
- test(VALUE self)
- {
- v = self;
- rb_thread_create(RUBY_METHOD_FUNC(thread), &v); // old
- return rb_thread_create(thread, &v); // new
- }
-};
-VALUE test_rb_thread_create::v = Qundef;
-
-namespace test_st_foreach {
- static int
- iter(st_data_t, st_data_t, st_data_t)
- {
- return ST_CONTINUE;
- }
-
- VALUE
- test(VALUE self)
- {
- st_data_t data = 0;
- st_table *st = st_init_numtable();
- st_foreach(st, reinterpret_cast<int(*)(ANYARGS)>(iter), data); // old
- st_foreach(st, iter, data); // new
- return self;
- }
-}
-
-namespace test_st_foreach_check {
- static int
- iter(st_data_t, st_data_t, st_data_t, int x)
- {
- return x ? ST_STOP : ST_CONTINUE;
- }
-
- VALUE
- test(VALUE self)
- {
- st_data_t data = 0;
- st_table *st = st_init_numtable();
- st_foreach_check(st, reinterpret_cast<int(*)(ANYARGS)>(iter), data, data); // old
- st_foreach_check(st, iter, data, data); // new
- return self;
- }
-}
-
-namespace test_st_foreach_safe {
- static int
- iter(st_data_t, st_data_t, st_data_t)
- {
- return ST_CONTINUE;
- }
-
- VALUE
- test(VALUE self)
- {
- st_data_t data = 0;
- st_table *st = st_init_numtable();
- st_foreach_safe(st, reinterpret_cast<int(*)(ANYARGS)>(iter), data); // old
- st_foreach_safe(st, iter, data); // new
- return self;
- }
-}
-
-namespace test_rb_hash_foreach {
- static int
- iter(VALUE, VALUE, VALUE)
- {
- return ST_CONTINUE;
- }
-
- VALUE
- test(VALUE self)
- {
- VALUE h = rb_hash_new();
- rb_hash_foreach(h, reinterpret_cast<int(*)(ANYARGS)>(iter), self); // old
- rb_hash_foreach(h, iter, self); // new
- return self;
- }
-}
-
-namespace test_rb_ivar_foreach {
- static int
- iter(VALUE, VALUE, VALUE)
- {
- return ST_CONTINUE;
- }
-
- VALUE
- test(VALUE self)
- {
- rb_ivar_foreach(self, reinterpret_cast<int(*)(ANYARGS)>(iter), self); // old
- rb_ivar_foreach(self, iter, self); // new
- return self;
- }
-}
-
-namespace test_rb_define_method {
- static VALUE
- m1(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- m2(VALUE, VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- ma(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- mv(int, VALUE*, VALUE)
- {
- return Qnil;
- }
-
- VALUE
- test(VALUE self)
- {
- // No cast
- rb_define_method(self, "m1", m1, 1);
- rb_define_method(self, "m2", m2, 2);
- rb_define_method(self, "ma", ma, -2);
- rb_define_method(self, "mv", mv, -1);
-
- // Cast by RUBY_METHOD_FUNC
- rb_define_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
- rb_define_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
- rb_define_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
- rb_define_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
-
- // Explicit cast instead of RUBY_METHOD_FUNC
- rb_define_method(self, "m1", (VALUE (*)(...))(m1), 1);
- rb_define_method(self, "m2", (VALUE (*)(...))(m2), 2);
- rb_define_method(self, "ma", (VALUE (*)(...))(ma), -2);
- rb_define_method(self, "mv", (VALUE (*)(...))(mv), -1);
-
- return self;
- }
-}
-
-namespace test_rb_define_module_function {
- static VALUE
- m1(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- m2(VALUE, VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- ma(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- mv(int, VALUE*, VALUE)
- {
- return Qnil;
- }
-
- VALUE
- test(VALUE self)
- {
- // No cast
- rb_define_module_function(self, "m1", m1, 1);
- rb_define_module_function(self, "m2", m2, 2);
- rb_define_module_function(self, "ma", ma, -2);
- rb_define_module_function(self, "mv", mv, -1);
-
- // Cast by RUBY_METHOD_FUNC
- rb_define_module_function(self, "m1", RUBY_METHOD_FUNC(m1), 1);
- rb_define_module_function(self, "m2", RUBY_METHOD_FUNC(m2), 2);
- rb_define_module_function(self, "ma", RUBY_METHOD_FUNC(ma), -2);
- rb_define_module_function(self, "mv", RUBY_METHOD_FUNC(mv), -1);
-
- // Explicit cast instead of RUBY_METHOD_FUNC
- rb_define_module_function(self, "m1", (VALUE (*)(...))(m1), 1);
- rb_define_module_function(self, "m2", (VALUE (*)(...))(m2), 2);
- rb_define_module_function(self, "ma", (VALUE (*)(...))(ma), -2);
- rb_define_module_function(self, "mv", (VALUE (*)(...))(mv), -1);
-
- return self;
- }
-}
-
-namespace test_rb_define_singleton_method {
- static VALUE
- m1(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- m2(VALUE, VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- ma(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- mv(int, VALUE*, VALUE)
- {
- return Qnil;
- }
-
- VALUE
- test(VALUE self)
- {
- // No cast
- rb_define_singleton_method(self, "m1", m1, 1);
- rb_define_singleton_method(self, "m2", m2, 2);
- rb_define_singleton_method(self, "ma", ma, -2);
- rb_define_singleton_method(self, "mv", mv, -1);
-
- // Cast by RUBY_METHOD_FUNC
- rb_define_singleton_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
- rb_define_singleton_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
- rb_define_singleton_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
- rb_define_singleton_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
-
- // Explicit cast instead of RUBY_METHOD_FUNC
- rb_define_singleton_method(self, "m1", (VALUE (*)(...))(m1), 1);
- rb_define_singleton_method(self, "m2", (VALUE (*)(...))(m2), 2);
- rb_define_singleton_method(self, "ma", (VALUE (*)(...))(ma), -2);
- rb_define_singleton_method(self, "mv", (VALUE (*)(...))(mv), -1);
-
- return self;
- }
-}
-
-namespace test_rb_define_protected_method {
- static VALUE
- m1(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- m2(VALUE, VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- ma(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- mv(int, VALUE*, VALUE)
- {
- return Qnil;
- }
-
- VALUE
- test(VALUE self)
- {
- // No cast
- rb_define_protected_method(self, "m1", m1, 1);
- rb_define_protected_method(self, "m2", m2, 2);
- rb_define_protected_method(self, "ma", ma, -2);
- rb_define_protected_method(self, "mv", mv, -1);
-
- // Cast by RUBY_METHOD_FUNC
- rb_define_protected_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
- rb_define_protected_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
- rb_define_protected_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
- rb_define_protected_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
-
- // Explicit cast instead of RUBY_METHOD_FUNC
- rb_define_protected_method(self, "m1", (VALUE (*)(...))(m1), 1);
- rb_define_protected_method(self, "m2", (VALUE (*)(...))(m2), 2);
- rb_define_protected_method(self, "ma", (VALUE (*)(...))(ma), -2);
- rb_define_protected_method(self, "mv", (VALUE (*)(...))(mv), -1);
-
- return self;
- }
-}
-
-namespace test_rb_define_private_method {
- static VALUE
- m1(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- m2(VALUE, VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- ma(VALUE, VALUE)
- {
- return Qnil;
- }
-
- static VALUE
- mv(int, VALUE*, VALUE)
- {
- return Qnil;
- }
-
- VALUE
- test(VALUE self)
- {
- // No cast
- rb_define_private_method(self, "m1", m1, 1);
- rb_define_private_method(self, "m2", m2, 2);
- rb_define_private_method(self, "ma", ma, -2);
- rb_define_private_method(self, "mv", mv, -1);
-
- // Cast by RUBY_METHOD_FUNC
- rb_define_private_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
- rb_define_private_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
- rb_define_private_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
- rb_define_private_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
-
- // Explicit cast instead of RUBY_METHOD_FUNC
- rb_define_private_method(self, "m1", (VALUE (*)(...))(m1), 1);
- rb_define_private_method(self, "m2", (VALUE (*)(...))(m2), 2);
- rb_define_private_method(self, "ma", (VALUE (*)(...))(ma), -2);
- rb_define_private_method(self, "mv", (VALUE (*)(...))(mv), -1);
-
- return self;
- }
-}
-
-extern "C" void
-Init_cxxanyargs(void)
-{
- VALUE b = rb_define_module("Bug");
-#define test(sym) \
- rb_define_module_function(b, #sym, RUBY_METHOD_FUNC(test_ ## sym::test), 0)
-
- test(rb_define_virtual_variable);
- test(rb_define_hooked_variable);
- test(rb_iterate);
- test(rb_block_call);
- test(rb_rescue);
- test(rb_rescue2);
- test(rb_ensure);
- test(rb_catch);
- test(rb_catch_obj);
- test(rb_fiber_new);
- test(rb_proc_new);
- test(rb_thread_create);
- test(st_foreach);
- test(st_foreach_check);
- test(st_foreach_safe);
- test(rb_hash_foreach);
- test(rb_ivar_foreach);
- test(rb_define_method);
- test(rb_define_module_function);
- test(rb_define_singleton_method);
- test(rb_define_protected_method);
- test(rb_define_private_method);
-}
diff --git a/ext/-test-/cxxanyargs/depend b/ext/-test-/cxxanyargs/depend
deleted file mode 100644
index 02113b6c26..0000000000
--- a/ext/-test-/cxxanyargs/depend
+++ /dev/null
@@ -1,25 +0,0 @@
-$(TARGET_SO) $(STATIC_LIB): $(FAILURES:.cpp=.failed)
-
-.SUFFIXES: .failed
-
-.cpp.failed:
- $(Q)$(RUBY) -rfileutils \
- -e "t = ARGV.shift" \
- -e "err = IO.popen(ARGV, err:[:child, :out], &:read)" \
- -e "abort err unless /rb_define_method/ =~ err" \
- -e "File.write(t, err)" $@ $(MAKE) $(*F).o
-
-# AUTOGENERATED DEPENDENCIES START
-cxxanyargs.o: $(RUBY_EXTCONF_H)
-cxxanyargs.o: $(arch_hdrdir)/ruby/config.h
-cxxanyargs.o: $(hdrdir)/ruby/assert.h
-cxxanyargs.o: $(hdrdir)/ruby/backward.h
-cxxanyargs.o: $(hdrdir)/ruby/backward/cxxanyargs.hpp
-cxxanyargs.o: $(hdrdir)/ruby/defines.h
-cxxanyargs.o: $(hdrdir)/ruby/intern.h
-cxxanyargs.o: $(hdrdir)/ruby/missing.h
-cxxanyargs.o: $(hdrdir)/ruby/ruby.h
-cxxanyargs.o: $(hdrdir)/ruby/st.h
-cxxanyargs.o: $(hdrdir)/ruby/subst.h
-cxxanyargs.o: cxxanyargs.cpp
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/cxxanyargs/extconf.rb b/ext/-test-/cxxanyargs/extconf.rb
deleted file mode 100644
index 08d8c83010..0000000000
--- a/ext/-test-/cxxanyargs/extconf.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: false
-
-cxx = MakeMakefile["C++"]
-
-ok = cxx.try_compile(<<~'begin', "") do |x|
- #include "ruby/config.h"
-
- namespace {
- typedef int conftest[SIZEOF_LONG == sizeof(long) ? 1 : -1];
- typedef int conftest[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
- }
-
- int
- main(int argc, const char** argv)
- {
- return !!argv[argc];
- }
-begin
- # We are wiping ruby.h from the source because that header file is the
- # subject we are going to test in this extension library.
- x.sub! %<#include "ruby.h">, ''
-end
-
-if ok
- $srcs = %w[cxxanyargs.cpp]
- failures = Dir.glob($srcdir + "/failure*.cpp").map {|n| File.basename(n)}
- $cleanfiles << "$(FAILURES:.cpp=.failed)"
- create_makefile("-test-/cxxanyargs") do |mk|
- mk << "FAILURES #{['=', failures].join(' ')}\n"
- mk << ".IGNORE: $(FAILURES:.cpp=.o)\n" unless $mswin
- mk
- end
-end
diff --git a/ext/-test-/cxxanyargs/failure.cpp b/ext/-test-/cxxanyargs/failure.cpp
deleted file mode 100644
index 039beb1633..0000000000
--- a/ext/-test-/cxxanyargs/failure.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <ruby/ruby.h>
-
-static VALUE
-func_arg1(VALUE self, VALUE arg1)
-{
- return arg1;
-}
-
-extern "C" void
-Init_failure(void)
-{
- rb_define_method(rb_cObject, "arg1", func_arg1, 0);
-}
diff --git a/ext/-test-/cxxanyargs/failurem1.cpp b/ext/-test-/cxxanyargs/failurem1.cpp
deleted file mode 100644
index e58a0f4e0d..0000000000
--- a/ext/-test-/cxxanyargs/failurem1.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <ruby/ruby.h>
-
-static VALUE
-func_argm1(int argc, VALUE *argv, VALUE self)
-{
- return argc > 0 ? argv[0] : Qnil;
-}
-
-extern "C" void
-Init_failure(void)
-{
- rb_define_method(rb_cObject, "argm1", func_argm1, 0);
-}
diff --git a/ext/-test-/debug/depend b/ext/-test-/debug/depend
index 662ed87510..392677239a 100644
--- a/ext/-test-/debug/depend
+++ b/ext/-test-/debug/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -10,10 +8,10 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
inspector.o: $(RUBY_EXTCONF_H)
inspector.o: $(arch_hdrdir)/ruby/config.h
-inspector.o: $(hdrdir)/ruby/assert.h
inspector.o: $(hdrdir)/ruby/backward.h
inspector.o: $(hdrdir)/ruby/debug.h
inspector.o: $(hdrdir)/ruby/defines.h
@@ -25,7 +23,6 @@ inspector.o: $(hdrdir)/ruby/subst.h
inspector.o: inspector.c
profile_frames.o: $(RUBY_EXTCONF_H)
profile_frames.o: $(arch_hdrdir)/ruby/config.h
-profile_frames.o: $(hdrdir)/ruby/assert.h
profile_frames.o: $(hdrdir)/ruby/backward.h
profile_frames.o: $(hdrdir)/ruby/debug.h
profile_frames.o: $(hdrdir)/ruby/defines.h
diff --git a/ext/-test-/enumerator_kw/depend b/ext/-test-/enumerator_kw/depend
deleted file mode 100644
index b7489eaf73..0000000000
--- a/ext/-test-/enumerator_kw/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-enumerator_kw.o: $(RUBY_EXTCONF_H)
-enumerator_kw.o: $(arch_hdrdir)/ruby/config.h
-enumerator_kw.o: $(hdrdir)/ruby.h
-enumerator_kw.o: $(hdrdir)/ruby/assert.h
-enumerator_kw.o: $(hdrdir)/ruby/backward.h
-enumerator_kw.o: $(hdrdir)/ruby/defines.h
-enumerator_kw.o: $(hdrdir)/ruby/intern.h
-enumerator_kw.o: $(hdrdir)/ruby/missing.h
-enumerator_kw.o: $(hdrdir)/ruby/ruby.h
-enumerator_kw.o: $(hdrdir)/ruby/st.h
-enumerator_kw.o: $(hdrdir)/ruby/subst.h
-enumerator_kw.o: enumerator_kw.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/enumerator_kw/enumerator_kw.c b/ext/-test-/enumerator_kw/enumerator_kw.c
deleted file mode 100644
index 947d2b37e6..0000000000
--- a/ext/-test-/enumerator_kw/enumerator_kw.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <ruby.h>
-
-static VALUE
-enumerator_kw(int argc, VALUE *argv, VALUE self)
-{
- VALUE opt, enum_args[4];
- enum_args[0] = Qnil;
- enum_args[1] = Qnil;
- rb_scan_args(argc, argv, "01*:", enum_args, enum_args+1, &opt);
- enum_args[3] = self;
- enum_args[2] = opt;
- RETURN_SIZED_ENUMERATOR_KW(self, 4, enum_args, 0, RB_NO_KEYWORDS);
- return rb_yield_values_kw(4, enum_args, RB_NO_KEYWORDS);
-}
-
-void
-Init_enumerator_kw(void) {
- VALUE module = rb_define_module("Bug");
- module = rb_define_module_under(module, "EnumeratorKw");
- rb_define_method(module, "m", enumerator_kw, -1);
-}
diff --git a/ext/-test-/enumerator_kw/extconf.rb b/ext/-test-/enumerator_kw/extconf.rb
deleted file mode 100644
index ab2be73fa8..0000000000
--- a/ext/-test-/enumerator_kw/extconf.rb
+++ /dev/null
@@ -1 +0,0 @@
-create_makefile("-test-/enumerator_kw")
diff --git a/ext/-test-/exception/depend b/ext/-test-/exception/depend
index d0958de9b8..9e5ccff274 100644
--- a/ext/-test-/exception/depend
+++ b/ext/-test-/exception/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
dataerror.o: $(RUBY_EXTCONF_H)
dataerror.o: $(arch_hdrdir)/ruby/config.h
-dataerror.o: $(hdrdir)/ruby/assert.h
dataerror.o: $(hdrdir)/ruby/backward.h
dataerror.o: $(hdrdir)/ruby/defines.h
dataerror.o: $(hdrdir)/ruby/intern.h
@@ -12,8 +11,6 @@ dataerror.o: $(hdrdir)/ruby/subst.h
dataerror.o: dataerror.c
enc_raise.o: $(RUBY_EXTCONF_H)
enc_raise.o: $(arch_hdrdir)/ruby/config.h
-enc_raise.o: $(hdrdir)/ruby.h
-enc_raise.o: $(hdrdir)/ruby/assert.h
enc_raise.o: $(hdrdir)/ruby/backward.h
enc_raise.o: $(hdrdir)/ruby/defines.h
enc_raise.o: $(hdrdir)/ruby/encoding.h
@@ -24,11 +21,10 @@ enc_raise.o: $(hdrdir)/ruby/oniguruma.h
enc_raise.o: $(hdrdir)/ruby/ruby.h
enc_raise.o: $(hdrdir)/ruby/st.h
enc_raise.o: $(hdrdir)/ruby/subst.h
+enc_raise.o: $(top_srcdir)/include/ruby.h
enc_raise.o: enc_raise.c
ensured.o: $(RUBY_EXTCONF_H)
ensured.o: $(arch_hdrdir)/ruby/config.h
-ensured.o: $(hdrdir)/ruby.h
-ensured.o: $(hdrdir)/ruby/assert.h
ensured.o: $(hdrdir)/ruby/backward.h
ensured.o: $(hdrdir)/ruby/defines.h
ensured.o: $(hdrdir)/ruby/intern.h
@@ -36,11 +32,10 @@ ensured.o: $(hdrdir)/ruby/missing.h
ensured.o: $(hdrdir)/ruby/ruby.h
ensured.o: $(hdrdir)/ruby/st.h
ensured.o: $(hdrdir)/ruby/subst.h
+ensured.o: $(top_srcdir)/include/ruby.h
ensured.o: ensured.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -48,5 +43,6 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/exception/enc_raise.c b/ext/-test-/exception/enc_raise.c
index 68d7b4ebc1..dc8a42cf3f 100644
--- a/ext/-test-/exception/enc_raise.c
+++ b/ext/-test-/exception/enc_raise.c
@@ -5,7 +5,7 @@ static VALUE
enc_raise(VALUE exc, VALUE encoding, VALUE mesg)
{
rb_enc_raise(rb_to_encoding(encoding), exc, "%s", StringValueCStr(mesg));
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
void
diff --git a/ext/-test-/fatal/depend b/ext/-test-/fatal/depend
deleted file mode 100644
index c74360fdf9..0000000000
--- a/ext/-test-/fatal/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-rb_fatal.o: $(RUBY_EXTCONF_H)
-rb_fatal.o: $(arch_hdrdir)/ruby/config.h
-rb_fatal.o: $(hdrdir)/ruby.h
-rb_fatal.o: $(hdrdir)/ruby/assert.h
-rb_fatal.o: $(hdrdir)/ruby/backward.h
-rb_fatal.o: $(hdrdir)/ruby/defines.h
-rb_fatal.o: $(hdrdir)/ruby/intern.h
-rb_fatal.o: $(hdrdir)/ruby/missing.h
-rb_fatal.o: $(hdrdir)/ruby/ruby.h
-rb_fatal.o: $(hdrdir)/ruby/st.h
-rb_fatal.o: $(hdrdir)/ruby/subst.h
-rb_fatal.o: rb_fatal.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/file/depend b/ext/-test-/file/depend
index afdf116a9d..0eea6063dd 100644
--- a/ext/-test-/file/depend
+++ b/ext/-test-/file/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
fs.o: $(RUBY_EXTCONF_H)
fs.o: $(arch_hdrdir)/ruby/config.h
-fs.o: $(hdrdir)/ruby/assert.h
fs.o: $(hdrdir)/ruby/backward.h
fs.o: $(hdrdir)/ruby/defines.h
fs.o: $(hdrdir)/ruby/encoding.h
@@ -16,8 +15,6 @@ fs.o: $(hdrdir)/ruby/subst.h
fs.o: fs.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -25,10 +22,10 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
stat.o: $(RUBY_EXTCONF_H)
stat.o: $(arch_hdrdir)/ruby/config.h
-stat.o: $(hdrdir)/ruby/assert.h
stat.o: $(hdrdir)/ruby/backward.h
stat.o: $(hdrdir)/ruby/defines.h
stat.o: $(hdrdir)/ruby/encoding.h
diff --git a/ext/-test-/float/depend b/ext/-test-/float/depend
index 6007bd3c0b..dff14550f7 100644
--- a/ext/-test-/float/depend
+++ b/ext/-test-/float/depend
@@ -1,30 +1,3 @@
-# for FreeBSD make
-nextafter.o: nextafter.c $(top_srcdir)/missing/nextafter.c
+$(OBJS): $(HDRS) $(ruby_headers)
-# AUTOGENERATED DEPENDENCIES START
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-nextafter.o: $(RUBY_EXTCONF_H)
-nextafter.o: $(arch_hdrdir)/ruby/config.h
-nextafter.o: $(hdrdir)/ruby.h
-nextafter.o: $(hdrdir)/ruby/assert.h
-nextafter.o: $(hdrdir)/ruby/backward.h
-nextafter.o: $(hdrdir)/ruby/defines.h
-nextafter.o: $(hdrdir)/ruby/intern.h
-nextafter.o: $(hdrdir)/ruby/missing.h
-nextafter.o: $(hdrdir)/ruby/ruby.h
-nextafter.o: $(hdrdir)/ruby/st.h
-nextafter.o: $(hdrdir)/ruby/subst.h
-nextafter.o: $(top_srcdir)/missing/nextafter.c
-nextafter.o: nextafter.c
-# AUTOGENERATED DEPENDENCIES END
+nextafter.o: nextafter.c $(top_srcdir)/missing/nextafter.c
diff --git a/ext/-test-/funcall/depend b/ext/-test-/funcall/depend
deleted file mode 100644
index a5f43a8046..0000000000
--- a/ext/-test-/funcall/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-funcall.o: $(RUBY_EXTCONF_H)
-funcall.o: $(arch_hdrdir)/ruby/config.h
-funcall.o: $(hdrdir)/ruby.h
-funcall.o: $(hdrdir)/ruby/assert.h
-funcall.o: $(hdrdir)/ruby/backward.h
-funcall.o: $(hdrdir)/ruby/defines.h
-funcall.o: $(hdrdir)/ruby/intern.h
-funcall.o: $(hdrdir)/ruby/missing.h
-funcall.o: $(hdrdir)/ruby/ruby.h
-funcall.o: $(hdrdir)/ruby/st.h
-funcall.o: $(hdrdir)/ruby/subst.h
-funcall.o: funcall.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/funcall/funcall.c b/ext/-test-/funcall/funcall.c
index 43521bf2e9..4e13c952e5 100644
--- a/ext/-test-/funcall/funcall.c
+++ b/ext/-test-/funcall/funcall.c
@@ -1,5 +1,7 @@
#include "ruby.h"
+VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
+
static VALUE
with_funcall2(int argc, VALUE *argv, VALUE self)
{
@@ -13,24 +15,6 @@ with_funcall_passing_block(int argc, VALUE *argv, VALUE self)
}
static VALUE
-with_funcall_passing_block_kw(int argc, VALUE *argv, VALUE self)
-{
- return rb_funcall_passing_block_kw(self, rb_intern("target"), argc-1, argv+1, FIX2INT(argv[0]));
-}
-
-static VALUE
-with_funcallv_public_kw(int argc, VALUE *argv, VALUE self)
-{
- return rb_funcallv_public_kw(argv[0], SYM2ID(argv[1]), argc-3, argv+3, FIX2INT(argv[2]));
-}
-
-static VALUE
-with_yield_splat_kw(int argc, VALUE *argv, VALUE self)
-{
- return rb_yield_splat_kw(argv[1], FIX2INT(argv[0]));
-}
-
-static VALUE
extra_args_name(VALUE self)
{
/*
@@ -51,21 +35,9 @@ Init_funcall(void)
with_funcall2,
-1);
rb_define_singleton_method(cRelay,
- "with_funcall_passing_block_kw",
- with_funcall_passing_block_kw,
- -1);
- rb_define_singleton_method(cRelay,
"with_funcall_passing_block",
with_funcall_passing_block,
-1);
- rb_define_singleton_method(cRelay,
- "with_funcallv_public_kw",
- with_funcallv_public_kw,
- -1);
- rb_define_singleton_method(cRelay,
- "with_yield_splat_kw",
- with_yield_splat_kw,
- -1);
rb_define_singleton_method(cTestFuncall, "extra_args_name",
extra_args_name,
0);
diff --git a/ext/-test-/gvl/call_without_gvl/call_without_gvl.c b/ext/-test-/gvl/call_without_gvl/call_without_gvl.c
index d77c2f323e..f3071d5768 100644
--- a/ext/-test-/gvl/call_without_gvl/call_without_gvl.c
+++ b/ext/-test-/gvl/call_without_gvl/call_without_gvl.c
@@ -27,50 +27,8 @@ thread_runnable_sleep(VALUE thread, VALUE timeout)
return thread;
}
-struct loop_ctl {
- int notify_fd;
- volatile int stop;
-};
-
-static void *
-do_loop(void *p)
-{
- struct loop_ctl *ctl = p;
-
- /* tell the waiting process they can interrupt us, now */
- ssize_t err = write(ctl->notify_fd, "", 1);
- if (err == -1) rb_bug("write error");
-
- while (!ctl->stop) {
- struct timeval tv = { 0, 10000 };
- select(0, NULL, NULL, NULL, &tv);
- }
- return 0;
-}
-
-static void
-stop_set(void *p)
-{
- struct loop_ctl *ctl = p;
-
- ctl->stop = 1;
-}
-
-static VALUE
-thread_ubf_async_safe(VALUE thread, VALUE notify_fd)
-{
- struct loop_ctl ctl;
-
- ctl.notify_fd = NUM2INT(notify_fd);
- ctl.stop = 0;
-
- rb_nogvl(do_loop, &ctl, stop_set, &ctl, RB_NOGVL_UBF_ASYNC_SAFE);
- return thread;
-}
-
void
Init_call_without_gvl(void)
{
rb_define_method(rb_cThread, "__runnable_sleep__", thread_runnable_sleep, 1);
- rb_define_method(rb_cThread, "__ubf_async_safe__", thread_ubf_async_safe, 1);
}
diff --git a/ext/-test-/gvl/call_without_gvl/depend b/ext/-test-/gvl/call_without_gvl/depend
index 3d4253b977..1f7443898d 100644
--- a/ext/-test-/gvl/call_without_gvl/depend
+++ b/ext/-test-/gvl/call_without_gvl/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
call_without_gvl.o: $(RUBY_EXTCONF_H)
call_without_gvl.o: $(arch_hdrdir)/ruby/config.h
-call_without_gvl.o: $(hdrdir)/ruby/assert.h
call_without_gvl.o: $(hdrdir)/ruby/backward.h
call_without_gvl.o: $(hdrdir)/ruby/defines.h
call_without_gvl.o: $(hdrdir)/ruby/intern.h
diff --git a/ext/-test-/hash/depend b/ext/-test-/hash/depend
deleted file mode 100644
index 5e2b8056c8..0000000000
--- a/ext/-test-/hash/depend
+++ /dev/null
@@ -1,26 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-delete.o: $(RUBY_EXTCONF_H)
-delete.o: $(arch_hdrdir)/ruby/config.h
-delete.o: $(hdrdir)/ruby.h
-delete.o: $(hdrdir)/ruby/assert.h
-delete.o: $(hdrdir)/ruby/backward.h
-delete.o: $(hdrdir)/ruby/defines.h
-delete.o: $(hdrdir)/ruby/intern.h
-delete.o: $(hdrdir)/ruby/missing.h
-delete.o: $(hdrdir)/ruby/ruby.h
-delete.o: $(hdrdir)/ruby/st.h
-delete.o: $(hdrdir)/ruby/subst.h
-delete.o: delete.c
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/integer/depend b/ext/-test-/integer/depend
index 5c9d581389..48f04d9ca0 100644
--- a/ext/-test-/integer/depend
+++ b/ext/-test-/integer/depend
@@ -1,21 +1,22 @@
# AUTOGENERATED DEPENDENCIES START
core_ext.o: $(RUBY_EXTCONF_H)
core_ext.o: $(arch_hdrdir)/ruby/config.h
-core_ext.o: $(hdrdir)/ruby.h
-core_ext.o: $(hdrdir)/ruby/assert.h
core_ext.o: $(hdrdir)/ruby/backward.h
core_ext.o: $(hdrdir)/ruby/defines.h
+core_ext.o: $(hdrdir)/ruby/encoding.h
core_ext.o: $(hdrdir)/ruby/intern.h
+core_ext.o: $(hdrdir)/ruby/io.h
core_ext.o: $(hdrdir)/ruby/missing.h
+core_ext.o: $(hdrdir)/ruby/onigmo.h
+core_ext.o: $(hdrdir)/ruby/oniguruma.h
core_ext.o: $(hdrdir)/ruby/ruby.h
core_ext.o: $(hdrdir)/ruby/st.h
core_ext.o: $(hdrdir)/ruby/subst.h
+core_ext.o: $(top_srcdir)/include/ruby.h
core_ext.o: $(top_srcdir)/internal.h
core_ext.o: core_ext.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -23,11 +24,10 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
my_integer.o: $(RUBY_EXTCONF_H)
my_integer.o: $(arch_hdrdir)/ruby/config.h
-my_integer.o: $(hdrdir)/ruby.h
-my_integer.o: $(hdrdir)/ruby/assert.h
my_integer.o: $(hdrdir)/ruby/backward.h
my_integer.o: $(hdrdir)/ruby/defines.h
my_integer.o: $(hdrdir)/ruby/intern.h
@@ -35,5 +35,6 @@ my_integer.o: $(hdrdir)/ruby/missing.h
my_integer.o: $(hdrdir)/ruby/ruby.h
my_integer.o: $(hdrdir)/ruby/st.h
my_integer.o: $(hdrdir)/ruby/subst.h
+my_integer.o: $(top_srcdir)/include/ruby.h
my_integer.o: my_integer.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/iseq_load/depend b/ext/-test-/iseq_load/depend
deleted file mode 100644
index ac549546ec..0000000000
--- a/ext/-test-/iseq_load/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-iseq_load.o: $(RUBY_EXTCONF_H)
-iseq_load.o: $(arch_hdrdir)/ruby/config.h
-iseq_load.o: $(hdrdir)/ruby.h
-iseq_load.o: $(hdrdir)/ruby/assert.h
-iseq_load.o: $(hdrdir)/ruby/backward.h
-iseq_load.o: $(hdrdir)/ruby/defines.h
-iseq_load.o: $(hdrdir)/ruby/intern.h
-iseq_load.o: $(hdrdir)/ruby/missing.h
-iseq_load.o: $(hdrdir)/ruby/ruby.h
-iseq_load.o: $(hdrdir)/ruby/st.h
-iseq_load.o: $(hdrdir)/ruby/subst.h
-iseq_load.o: iseq_load.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/iter/break.c b/ext/-test-/iter/break.c
index 4d43c5d0cf..66ed26a9b8 100644
--- a/ext/-test-/iter/break.c
+++ b/ext/-test-/iter/break.c
@@ -5,7 +5,7 @@ iter_break(VALUE self)
{
rb_iter_break();
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
static VALUE
@@ -13,7 +13,7 @@ iter_break_value(VALUE self, VALUE val)
{
rb_iter_break_value(val);
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
void
diff --git a/ext/-test-/iter/depend b/ext/-test-/iter/depend
deleted file mode 100644
index 5e754950c1..0000000000
--- a/ext/-test-/iter/depend
+++ /dev/null
@@ -1,38 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-break.o: $(RUBY_EXTCONF_H)
-break.o: $(arch_hdrdir)/ruby/config.h
-break.o: $(hdrdir)/ruby.h
-break.o: $(hdrdir)/ruby/assert.h
-break.o: $(hdrdir)/ruby/backward.h
-break.o: $(hdrdir)/ruby/defines.h
-break.o: $(hdrdir)/ruby/intern.h
-break.o: $(hdrdir)/ruby/missing.h
-break.o: $(hdrdir)/ruby/ruby.h
-break.o: $(hdrdir)/ruby/st.h
-break.o: $(hdrdir)/ruby/subst.h
-break.o: break.c
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-yield.o: $(RUBY_EXTCONF_H)
-yield.o: $(arch_hdrdir)/ruby/config.h
-yield.o: $(hdrdir)/ruby.h
-yield.o: $(hdrdir)/ruby/assert.h
-yield.o: $(hdrdir)/ruby/backward.h
-yield.o: $(hdrdir)/ruby/defines.h
-yield.o: $(hdrdir)/ruby/intern.h
-yield.o: $(hdrdir)/ruby/missing.h
-yield.o: $(hdrdir)/ruby/ruby.h
-yield.o: $(hdrdir)/ruby/st.h
-yield.o: $(hdrdir)/ruby/subst.h
-yield.o: yield.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/iter/yield.c b/ext/-test-/iter/yield.c
index 0f6f3e87eb..3cd408a928 100644
--- a/ext/-test-/iter/yield.c
+++ b/ext/-test-/iter/yield.c
@@ -4,7 +4,7 @@ static VALUE
yield_block(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
- return rb_block_call_kw(self, rb_to_id(argv[0]), argc-1, argv+1, rb_yield_block, 0, RB_PASS_CALLED_KEYWORDS);
+ return rb_block_call(self, rb_to_id(argv[0]), argc-1, argv+1, rb_yield_block, 0);
}
void
diff --git a/ext/-test-/load/protect/depend b/ext/-test-/load/protect/depend
deleted file mode 100644
index b62393f1cb..0000000000
--- a/ext/-test-/load/protect/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-protect.o: $(RUBY_EXTCONF_H)
-protect.o: $(arch_hdrdir)/ruby/config.h
-protect.o: $(hdrdir)/ruby.h
-protect.o: $(hdrdir)/ruby/assert.h
-protect.o: $(hdrdir)/ruby/backward.h
-protect.o: $(hdrdir)/ruby/defines.h
-protect.o: $(hdrdir)/ruby/intern.h
-protect.o: $(hdrdir)/ruby/missing.h
-protect.o: $(hdrdir)/ruby/ruby.h
-protect.o: $(hdrdir)/ruby/st.h
-protect.o: $(hdrdir)/ruby/subst.h
-protect.o: protect.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/marshal/compat/depend b/ext/-test-/marshal/compat/depend
deleted file mode 100644
index f159506960..0000000000
--- a/ext/-test-/marshal/compat/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-usrcompat.o: $(RUBY_EXTCONF_H)
-usrcompat.o: $(arch_hdrdir)/ruby/config.h
-usrcompat.o: $(hdrdir)/ruby.h
-usrcompat.o: $(hdrdir)/ruby/assert.h
-usrcompat.o: $(hdrdir)/ruby/backward.h
-usrcompat.o: $(hdrdir)/ruby/defines.h
-usrcompat.o: $(hdrdir)/ruby/intern.h
-usrcompat.o: $(hdrdir)/ruby/missing.h
-usrcompat.o: $(hdrdir)/ruby/ruby.h
-usrcompat.o: $(hdrdir)/ruby/st.h
-usrcompat.o: $(hdrdir)/ruby/subst.h
-usrcompat.o: usrcompat.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/marshal/internal_ivar/depend b/ext/-test-/marshal/internal_ivar/depend
deleted file mode 100644
index f280347c01..0000000000
--- a/ext/-test-/marshal/internal_ivar/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-internal_ivar.o: $(RUBY_EXTCONF_H)
-internal_ivar.o: $(arch_hdrdir)/ruby/config.h
-internal_ivar.o: $(hdrdir)/ruby.h
-internal_ivar.o: $(hdrdir)/ruby/assert.h
-internal_ivar.o: $(hdrdir)/ruby/backward.h
-internal_ivar.o: $(hdrdir)/ruby/defines.h
-internal_ivar.o: $(hdrdir)/ruby/intern.h
-internal_ivar.o: $(hdrdir)/ruby/missing.h
-internal_ivar.o: $(hdrdir)/ruby/ruby.h
-internal_ivar.o: $(hdrdir)/ruby/st.h
-internal_ivar.o: $(hdrdir)/ruby/subst.h
-internal_ivar.o: internal_ivar.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/marshal/internal_ivar/internal_ivar.c b/ext/-test-/marshal/internal_ivar/internal_ivar.c
index de0cf711aa..299da27f23 100644
--- a/ext/-test-/marshal/internal_ivar/internal_ivar.c
+++ b/ext/-test-/marshal/internal_ivar/internal_ivar.c
@@ -1,13 +1,12 @@
#include <ruby.h>
-static ID id_normal_ivar, id_internal_ivar, id_encoding_short;
+static ID id_normal_ivar, id_internal_ivar;
static VALUE
-init(VALUE self, VALUE arg1, VALUE arg2, VALUE arg3)
+init(VALUE self, VALUE arg1, VALUE arg2)
{
rb_ivar_set(self, id_normal_ivar, arg1);
rb_ivar_set(self, id_internal_ivar, arg2);
- rb_ivar_set(self, id_encoding_short, arg3);
return self;
}
@@ -23,12 +22,6 @@ get_internal(VALUE self)
return rb_attr_get(self, id_internal_ivar);
}
-static VALUE
-get_encoding_short(VALUE self)
-{
- return rb_attr_get(self, id_encoding_short);
-}
-
void
Init_internal_ivar(void)
{
@@ -40,9 +33,7 @@ Init_internal_ivar(void)
/* leave id_internal_ivar being 0 */
id_internal_ivar = rb_make_internal_id();
#endif
- id_encoding_short = rb_intern_const("E");
- rb_define_method(newclass, "initialize", init, 3);
+ rb_define_method(newclass, "initialize", init, 2);
rb_define_method(newclass, "normal", get_normal, 0);
rb_define_method(newclass, "internal", get_internal, 0);
- rb_define_method(newclass, "encoding_short", get_encoding_short, 0);
}
diff --git a/ext/-test-/marshal/usr/depend b/ext/-test-/marshal/usr/depend
deleted file mode 100644
index 21c0c2d744..0000000000
--- a/ext/-test-/marshal/usr/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-usrmarshal.o: $(RUBY_EXTCONF_H)
-usrmarshal.o: $(arch_hdrdir)/ruby/config.h
-usrmarshal.o: $(hdrdir)/ruby.h
-usrmarshal.o: $(hdrdir)/ruby/assert.h
-usrmarshal.o: $(hdrdir)/ruby/backward.h
-usrmarshal.o: $(hdrdir)/ruby/defines.h
-usrmarshal.o: $(hdrdir)/ruby/intern.h
-usrmarshal.o: $(hdrdir)/ruby/missing.h
-usrmarshal.o: $(hdrdir)/ruby/ruby.h
-usrmarshal.o: $(hdrdir)/ruby/st.h
-usrmarshal.o: $(hdrdir)/ruby/subst.h
-usrmarshal.o: usrmarshal.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/memory_status/depend b/ext/-test-/memory_status/depend
deleted file mode 100644
index 657ef59c35..0000000000
--- a/ext/-test-/memory_status/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-memory_status.o: $(RUBY_EXTCONF_H)
-memory_status.o: $(arch_hdrdir)/ruby/config.h
-memory_status.o: $(hdrdir)/ruby.h
-memory_status.o: $(hdrdir)/ruby/assert.h
-memory_status.o: $(hdrdir)/ruby/backward.h
-memory_status.o: $(hdrdir)/ruby/defines.h
-memory_status.o: $(hdrdir)/ruby/intern.h
-memory_status.o: $(hdrdir)/ruby/missing.h
-memory_status.o: $(hdrdir)/ruby/ruby.h
-memory_status.o: $(hdrdir)/ruby/st.h
-memory_status.o: $(hdrdir)/ruby/subst.h
-memory_status.o: memory_status.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/memory_status/memory_status.c b/ext/-test-/memory_status/memory_status.c
index 5775fa56f3..23c4806472 100644
--- a/ext/-test-/memory_status/memory_status.c
+++ b/ext/-test-/memory_status/memory_status.c
@@ -32,10 +32,6 @@ read_status(VALUE self)
error = task_info(mach_task_self(), flavor,
(task_info_t)&taskinfo, &out_count);
if (error != KERN_SUCCESS) return Qnil;
-#ifndef ULL2NUM
-/* "long long" does not exist here, use size_t instead. */
-#define ULL2NUM SIZET2NUM
-#endif
size = ULL2NUM(taskinfo.virtual_size);
rss = ULL2NUM(taskinfo.resident_size);
rb_struct_aset(self, INT2FIX(1), rss);
diff --git a/ext/-test-/method/depend b/ext/-test-/method/depend
deleted file mode 100644
index 028d97e1a9..0000000000
--- a/ext/-test-/method/depend
+++ /dev/null
@@ -1,26 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-arity.o: $(RUBY_EXTCONF_H)
-arity.o: $(arch_hdrdir)/ruby/config.h
-arity.o: $(hdrdir)/ruby.h
-arity.o: $(hdrdir)/ruby/assert.h
-arity.o: $(hdrdir)/ruby/backward.h
-arity.o: $(hdrdir)/ruby/defines.h
-arity.o: $(hdrdir)/ruby/intern.h
-arity.o: $(hdrdir)/ruby/missing.h
-arity.o: $(hdrdir)/ruby/ruby.h
-arity.o: $(hdrdir)/ruby/st.h
-arity.o: $(hdrdir)/ruby/subst.h
-arity.o: arity.c
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/notimplement/bug.c b/ext/-test-/notimplement/bug.c
index 82e243a81d..8e9cae707a 100644
--- a/ext/-test-/notimplement/bug.c
+++ b/ext/-test-/notimplement/bug.c
@@ -11,8 +11,6 @@ void
Init_notimplement(void)
{
VALUE mBug = rb_define_module("Bug");
- VALUE klass = rb_define_class_under(mBug, "NotImplement", rb_cObject);
rb_define_module_function(mBug, "funcall", bug_funcall, -1);
rb_define_module_function(mBug, "notimplement", rb_f_notimplement, -1);
- rb_define_method(klass, "notimplement", rb_f_notimplement, -1);
}
diff --git a/ext/-test-/notimplement/depend b/ext/-test-/notimplement/depend
deleted file mode 100644
index 74911f0af4..0000000000
--- a/ext/-test-/notimplement/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-bug.o: $(RUBY_EXTCONF_H)
-bug.o: $(arch_hdrdir)/ruby/config.h
-bug.o: $(hdrdir)/ruby.h
-bug.o: $(hdrdir)/ruby/assert.h
-bug.o: $(hdrdir)/ruby/backward.h
-bug.o: $(hdrdir)/ruby/defines.h
-bug.o: $(hdrdir)/ruby/intern.h
-bug.o: $(hdrdir)/ruby/missing.h
-bug.o: $(hdrdir)/ruby/ruby.h
-bug.o: $(hdrdir)/ruby/st.h
-bug.o: $(hdrdir)/ruby/subst.h
-bug.o: bug.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/num2int/depend b/ext/-test-/num2int/depend
deleted file mode 100644
index 76b69de851..0000000000
--- a/ext/-test-/num2int/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-num2int.o: $(RUBY_EXTCONF_H)
-num2int.o: $(arch_hdrdir)/ruby/config.h
-num2int.o: $(hdrdir)/ruby.h
-num2int.o: $(hdrdir)/ruby/assert.h
-num2int.o: $(hdrdir)/ruby/backward.h
-num2int.o: $(hdrdir)/ruby/defines.h
-num2int.o: $(hdrdir)/ruby/intern.h
-num2int.o: $(hdrdir)/ruby/missing.h
-num2int.o: $(hdrdir)/ruby/ruby.h
-num2int.o: $(hdrdir)/ruby/st.h
-num2int.o: $(hdrdir)/ruby/subst.h
-num2int.o: num2int.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/path_to_class/depend b/ext/-test-/path_to_class/depend
deleted file mode 100644
index 9a7f7d0176..0000000000
--- a/ext/-test-/path_to_class/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-path_to_class.o: $(RUBY_EXTCONF_H)
-path_to_class.o: $(arch_hdrdir)/ruby/config.h
-path_to_class.o: $(hdrdir)/ruby.h
-path_to_class.o: $(hdrdir)/ruby/assert.h
-path_to_class.o: $(hdrdir)/ruby/backward.h
-path_to_class.o: $(hdrdir)/ruby/defines.h
-path_to_class.o: $(hdrdir)/ruby/intern.h
-path_to_class.o: $(hdrdir)/ruby/missing.h
-path_to_class.o: $(hdrdir)/ruby/ruby.h
-path_to_class.o: $(hdrdir)/ruby/st.h
-path_to_class.o: $(hdrdir)/ruby/subst.h
-path_to_class.o: path_to_class.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/popen_deadlock/depend b/ext/-test-/popen_deadlock/depend
deleted file mode 100644
index 4c3f3853fd..0000000000
--- a/ext/-test-/popen_deadlock/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-infinite_loop_dlsym.o: $(RUBY_EXTCONF_H)
-infinite_loop_dlsym.o: $(arch_hdrdir)/ruby/config.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/assert.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/backward.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/defines.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/intern.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/missing.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/ruby.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/st.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/subst.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/thread.h
-infinite_loop_dlsym.o: infinite_loop_dlsym.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/postponed_job/depend b/ext/-test-/postponed_job/depend
index 998e2dcc9e..d672e53f00 100644
--- a/ext/-test-/postponed_job/depend
+++ b/ext/-test-/postponed_job/depend
@@ -1,15 +1 @@
-# AUTOGENERATED DEPENDENCIES START
-postponed_job.o: $(RUBY_EXTCONF_H)
-postponed_job.o: $(arch_hdrdir)/ruby/config.h
-postponed_job.o: $(hdrdir)/ruby.h
-postponed_job.o: $(hdrdir)/ruby/assert.h
-postponed_job.o: $(hdrdir)/ruby/backward.h
-postponed_job.o: $(hdrdir)/ruby/debug.h
-postponed_job.o: $(hdrdir)/ruby/defines.h
-postponed_job.o: $(hdrdir)/ruby/intern.h
-postponed_job.o: $(hdrdir)/ruby/missing.h
-postponed_job.o: $(hdrdir)/ruby/ruby.h
-postponed_job.o: $(hdrdir)/ruby/st.h
-postponed_job.o: $(hdrdir)/ruby/subst.h
-postponed_job.o: postponed_job.c
-# AUTOGENERATED DEPENDENCIES END
+postponed_job.o: $(HDRS) $(ruby_headers) $(hdrdir)/ruby/debug.h
diff --git a/ext/-test-/postponed_job/postponed_job.c b/ext/-test-/postponed_job/postponed_job.c
index d8684d475a..157230e33b 100644
--- a/ext/-test-/postponed_job/postponed_job.c
+++ b/ext/-test-/postponed_job/postponed_job.c
@@ -1,28 +1,19 @@
#include "ruby.h"
#include "ruby/debug.h"
-static int counter;
-
static void
pjob_callback(void *data)
{
VALUE ary = (VALUE)data;
Check_Type(ary, T_ARRAY);
- rb_ary_push(ary, INT2FIX(counter));
+ rb_ary_replace(ary, rb_funcall(Qnil, rb_intern("caller"), 0));
}
static VALUE
pjob_register(VALUE self, VALUE obj)
{
- counter = 0;
rb_postponed_job_register(0, pjob_callback, (void *)obj);
- rb_gc_start();
- counter++;
- rb_gc_start();
- counter++;
- rb_gc_start();
- counter++;
return self;
}
@@ -47,14 +38,7 @@ pjob_register_one(VALUE self, VALUE obj)
static VALUE
pjob_call_direct(VALUE self, VALUE obj)
{
- counter = 0;
pjob_callback((void *)obj);
- rb_gc_start();
- counter++;
- rb_gc_start();
- counter++;
- rb_gc_start();
- counter++;
return self;
}
diff --git a/ext/-test-/printf/depend b/ext/-test-/printf/depend
index 7860797f50..79b6c53f50 100644
--- a/ext/-test-/printf/depend
+++ b/ext/-test-/printf/depend
@@ -1,17 +1,3 @@
-# AUTOGENERATED DEPENDENCIES START
-printf.o: $(RUBY_EXTCONF_H)
-printf.o: $(arch_hdrdir)/ruby/config.h
-printf.o: $(hdrdir)/ruby.h
-printf.o: $(hdrdir)/ruby/assert.h
-printf.o: $(hdrdir)/ruby/backward.h
-printf.o: $(hdrdir)/ruby/defines.h
-printf.o: $(hdrdir)/ruby/encoding.h
-printf.o: $(hdrdir)/ruby/intern.h
-printf.o: $(hdrdir)/ruby/missing.h
-printf.o: $(hdrdir)/ruby/onigmo.h
-printf.o: $(hdrdir)/ruby/oniguruma.h
-printf.o: $(hdrdir)/ruby/ruby.h
-printf.o: $(hdrdir)/ruby/st.h
-printf.o: $(hdrdir)/ruby/subst.h
-printf.o: printf.c
-# AUTOGENERATED DEPENDENCIES END
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/ext/-test-/proc/depend b/ext/-test-/proc/depend
deleted file mode 100644
index 5946e4ca0d..0000000000
--- a/ext/-test-/proc/depend
+++ /dev/null
@@ -1,38 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-receiver.o: $(RUBY_EXTCONF_H)
-receiver.o: $(arch_hdrdir)/ruby/config.h
-receiver.o: $(hdrdir)/ruby.h
-receiver.o: $(hdrdir)/ruby/assert.h
-receiver.o: $(hdrdir)/ruby/backward.h
-receiver.o: $(hdrdir)/ruby/defines.h
-receiver.o: $(hdrdir)/ruby/intern.h
-receiver.o: $(hdrdir)/ruby/missing.h
-receiver.o: $(hdrdir)/ruby/ruby.h
-receiver.o: $(hdrdir)/ruby/st.h
-receiver.o: $(hdrdir)/ruby/subst.h
-receiver.o: receiver.c
-super.o: $(RUBY_EXTCONF_H)
-super.o: $(arch_hdrdir)/ruby/config.h
-super.o: $(hdrdir)/ruby.h
-super.o: $(hdrdir)/ruby/assert.h
-super.o: $(hdrdir)/ruby/backward.h
-super.o: $(hdrdir)/ruby/defines.h
-super.o: $(hdrdir)/ruby/intern.h
-super.o: $(hdrdir)/ruby/missing.h
-super.o: $(hdrdir)/ruby/ruby.h
-super.o: $(hdrdir)/ruby/st.h
-super.o: $(hdrdir)/ruby/subst.h
-super.o: super.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/rational/depend b/ext/-test-/rational/depend
index 39e65933f3..4f7c4e4900 100644
--- a/ext/-test-/rational/depend
+++ b/ext/-test-/rational/depend
@@ -5,15 +5,18 @@ rat.o: rat.c $(top_srcdir)/internal.h
# AUTOGENERATED DEPENDENCIES START
rat.o: $(RUBY_EXTCONF_H)
rat.o: $(arch_hdrdir)/ruby/config.h
-rat.o: $(hdrdir)/ruby.h
-rat.o: $(hdrdir)/ruby/assert.h
rat.o: $(hdrdir)/ruby/backward.h
rat.o: $(hdrdir)/ruby/defines.h
+rat.o: $(hdrdir)/ruby/encoding.h
rat.o: $(hdrdir)/ruby/intern.h
+rat.o: $(hdrdir)/ruby/io.h
rat.o: $(hdrdir)/ruby/missing.h
+rat.o: $(hdrdir)/ruby/onigmo.h
+rat.o: $(hdrdir)/ruby/oniguruma.h
rat.o: $(hdrdir)/ruby/ruby.h
rat.o: $(hdrdir)/ruby/st.h
rat.o: $(hdrdir)/ruby/subst.h
+rat.o: $(top_srcdir)/include/ruby.h
rat.o: $(top_srcdir)/internal.h
rat.o: rat.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/rb_call_super_kw/depend b/ext/-test-/rb_call_super_kw/depend
deleted file mode 100644
index f65dcf9694..0000000000
--- a/ext/-test-/rb_call_super_kw/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-rb_call_super_kw.o: $(RUBY_EXTCONF_H)
-rb_call_super_kw.o: $(arch_hdrdir)/ruby/config.h
-rb_call_super_kw.o: $(hdrdir)/ruby.h
-rb_call_super_kw.o: $(hdrdir)/ruby/assert.h
-rb_call_super_kw.o: $(hdrdir)/ruby/backward.h
-rb_call_super_kw.o: $(hdrdir)/ruby/defines.h
-rb_call_super_kw.o: $(hdrdir)/ruby/intern.h
-rb_call_super_kw.o: $(hdrdir)/ruby/missing.h
-rb_call_super_kw.o: $(hdrdir)/ruby/ruby.h
-rb_call_super_kw.o: $(hdrdir)/ruby/st.h
-rb_call_super_kw.o: $(hdrdir)/ruby/subst.h
-rb_call_super_kw.o: rb_call_super_kw.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/rb_call_super_kw/extconf.rb b/ext/-test-/rb_call_super_kw/extconf.rb
deleted file mode 100644
index c6a5c720d7..0000000000
--- a/ext/-test-/rb_call_super_kw/extconf.rb
+++ /dev/null
@@ -1 +0,0 @@
-create_makefile("-test-/rb_call_super_kw")
diff --git a/ext/-test-/rb_call_super_kw/rb_call_super_kw.c b/ext/-test-/rb_call_super_kw/rb_call_super_kw.c
deleted file mode 100644
index 7f094545d2..0000000000
--- a/ext/-test-/rb_call_super_kw/rb_call_super_kw.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <ruby.h>
-
-static VALUE
-rb_call_super_kw_m(int argc, VALUE *argv, VALUE self)
-{
- return rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
-}
-
-void
-Init_rb_call_super_kw(void) {
- VALUE module = rb_define_module("Bug");
- module = rb_define_module_under(module, "RbCallSuperKw");
- rb_define_method(module, "m", rb_call_super_kw_m, -1);
-}
diff --git a/ext/-test-/recursion/depend b/ext/-test-/recursion/depend
deleted file mode 100644
index bf8005724a..0000000000
--- a/ext/-test-/recursion/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-recursion.o: $(RUBY_EXTCONF_H)
-recursion.o: $(arch_hdrdir)/ruby/config.h
-recursion.o: $(hdrdir)/ruby.h
-recursion.o: $(hdrdir)/ruby/assert.h
-recursion.o: $(hdrdir)/ruby/backward.h
-recursion.o: $(hdrdir)/ruby/defines.h
-recursion.o: $(hdrdir)/ruby/intern.h
-recursion.o: $(hdrdir)/ruby/missing.h
-recursion.o: $(hdrdir)/ruby/ruby.h
-recursion.o: $(hdrdir)/ruby/st.h
-recursion.o: $(hdrdir)/ruby/subst.h
-recursion.o: recursion.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/regexp/depend b/ext/-test-/regexp/depend
deleted file mode 100644
index 7c88e1235c..0000000000
--- a/ext/-test-/regexp/depend
+++ /dev/null
@@ -1,27 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-parse_depth_limit.o: $(RUBY_EXTCONF_H)
-parse_depth_limit.o: $(arch_hdrdir)/ruby/config.h
-parse_depth_limit.o: $(hdrdir)/ruby.h
-parse_depth_limit.o: $(hdrdir)/ruby/assert.h
-parse_depth_limit.o: $(hdrdir)/ruby/backward.h
-parse_depth_limit.o: $(hdrdir)/ruby/defines.h
-parse_depth_limit.o: $(hdrdir)/ruby/intern.h
-parse_depth_limit.o: $(hdrdir)/ruby/missing.h
-parse_depth_limit.o: $(hdrdir)/ruby/onigmo.h
-parse_depth_limit.o: $(hdrdir)/ruby/ruby.h
-parse_depth_limit.o: $(hdrdir)/ruby/st.h
-parse_depth_limit.o: $(hdrdir)/ruby/subst.h
-parse_depth_limit.o: parse_depth_limit.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/scan_args/depend b/ext/-test-/scan_args/depend
deleted file mode 100644
index c230961ae3..0000000000
--- a/ext/-test-/scan_args/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-scan_args.o: $(RUBY_EXTCONF_H)
-scan_args.o: $(arch_hdrdir)/ruby/config.h
-scan_args.o: $(hdrdir)/ruby.h
-scan_args.o: $(hdrdir)/ruby/assert.h
-scan_args.o: $(hdrdir)/ruby/backward.h
-scan_args.o: $(hdrdir)/ruby/defines.h
-scan_args.o: $(hdrdir)/ruby/intern.h
-scan_args.o: $(hdrdir)/ruby/missing.h
-scan_args.o: $(hdrdir)/ruby/ruby.h
-scan_args.o: $(hdrdir)/ruby/st.h
-scan_args.o: $(hdrdir)/ruby/subst.h
-scan_args.o: scan_args.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/scan_args/extconf.rb b/ext/-test-/scan_args/extconf.rb
index 6cae9c2779..6cae9c2779 100644..100755
--- a/ext/-test-/scan_args/extconf.rb
+++ b/ext/-test-/scan_args/extconf.rb
diff --git a/ext/-test-/scan_args/scan_args.c b/ext/-test-/scan_args/scan_args.c
index 9c374da66f..dca353f643 100644
--- a/ext/-test-/scan_args/scan_args.c
+++ b/ext/-test-/scan_args/scan_args.c
@@ -250,33 +250,6 @@ scan_args_lead_opt_var_trail_hash(int argc, VALUE *argv, VALUE self)
return rb_ary_new_from_values(numberof(args), args);
}
-static VALUE
-scan_args_k_lead_opt_hash(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n = rb_scan_args_kw(RB_SCAN_ARGS_KEYWORDS, argc, argv, "11:", args+1, args+2, args+3);
- args[0] = INT2NUM(n);
- return rb_ary_new_from_values(numberof(args), args);
-}
-
-static VALUE
-scan_args_e_lead_opt_hash(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n = rb_scan_args_kw(RB_SCAN_ARGS_EMPTY_KEYWORDS, argc, argv, "11:", args+1, args+2, args+3);
- args[0] = INT2NUM(n);
- return rb_ary_new_from_values(numberof(args), args);
-}
-
-static VALUE
-scan_args_n_lead_opt_hash(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n = rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS, argc, argv, "11:", args+1, args+2, args+3);
- args[0] = INT2NUM(n);
- return rb_ary_new_from_values(numberof(args), args);
-}
-
void
Init_scan_args(void)
{
@@ -309,7 +282,5 @@ Init_scan_args(void)
rb_define_singleton_method(module, "lead_var_trail_hash", scan_args_lead_var_trail_hash, -1);
rb_define_singleton_method(module, "opt_var_trail_hash", scan_args_opt_var_trail_hash, -1);
rb_define_singleton_method(module, "lead_opt_var_trail_hash", scan_args_lead_opt_var_trail_hash, -1);
- rb_define_singleton_method(module, "k_lead_opt_hash", scan_args_k_lead_opt_hash, -1);
- rb_define_singleton_method(module, "e_lead_opt_hash", scan_args_e_lead_opt_hash, -1);
- rb_define_singleton_method(module, "n_lead_opt_hash", scan_args_n_lead_opt_hash, -1);
}
+
diff --git a/ext/-test-/st/foreach/depend b/ext/-test-/st/foreach/depend
deleted file mode 100644
index 42d3909f49..0000000000
--- a/ext/-test-/st/foreach/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-foreach.o: $(RUBY_EXTCONF_H)
-foreach.o: $(arch_hdrdir)/ruby/config.h
-foreach.o: $(hdrdir)/ruby.h
-foreach.o: $(hdrdir)/ruby/assert.h
-foreach.o: $(hdrdir)/ruby/backward.h
-foreach.o: $(hdrdir)/ruby/defines.h
-foreach.o: $(hdrdir)/ruby/intern.h
-foreach.o: $(hdrdir)/ruby/missing.h
-foreach.o: $(hdrdir)/ruby/ruby.h
-foreach.o: $(hdrdir)/ruby/st.h
-foreach.o: $(hdrdir)/ruby/subst.h
-foreach.o: foreach.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/st/foreach/foreach.c b/ext/-test-/st/foreach/foreach.c
index 27ac18046f..209b535503 100644
--- a/ext/-test-/st/foreach/foreach.c
+++ b/ext/-test-/st/foreach/foreach.c
@@ -106,7 +106,7 @@ unp_fec(VALUE self, VALUE test)
}
static int
-unp_fe_i(st_data_t key, st_data_t val, st_data_t args)
+unp_fe_i(st_data_t key, st_data_t val, st_data_t args, int error)
{
struct checker *c = (struct checker *)args;
diff --git a/ext/-test-/st/numhash/depend b/ext/-test-/st/numhash/depend
deleted file mode 100644
index 98dcef881b..0000000000
--- a/ext/-test-/st/numhash/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-numhash.o: $(RUBY_EXTCONF_H)
-numhash.o: $(arch_hdrdir)/ruby/config.h
-numhash.o: $(hdrdir)/ruby.h
-numhash.o: $(hdrdir)/ruby/assert.h
-numhash.o: $(hdrdir)/ruby/backward.h
-numhash.o: $(hdrdir)/ruby/defines.h
-numhash.o: $(hdrdir)/ruby/intern.h
-numhash.o: $(hdrdir)/ruby/missing.h
-numhash.o: $(hdrdir)/ruby/ruby.h
-numhash.o: $(hdrdir)/ruby/st.h
-numhash.o: $(hdrdir)/ruby/subst.h
-numhash.o: numhash.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/st/numhash/numhash.c b/ext/-test-/st/numhash/numhash.c
index 71eeed4910..fc35f476cd 100644
--- a/ext/-test-/st/numhash/numhash.c
+++ b/ext/-test-/st/numhash/numhash.c
@@ -57,7 +57,7 @@ numhash_aset(VALUE self, VALUE key, VALUE data)
}
static int
-numhash_i(st_data_t key, st_data_t value, st_data_t arg, int _)
+numhash_i(st_data_t key, st_data_t value, st_data_t arg)
{
VALUE ret;
ret = rb_yield_values(3, (VALUE)key, (VALUE)value, (VALUE)arg);
@@ -135,3 +135,4 @@ Init_numhash(void)
rb_define_method(st, "size", numhash_size, 0);
rb_define_method(st, "delete_safe", numhash_delete_safe, 1);
}
+
diff --git a/ext/-test-/st/update/depend b/ext/-test-/st/update/depend
deleted file mode 100644
index 241e6f9e6d..0000000000
--- a/ext/-test-/st/update/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-update.o: $(RUBY_EXTCONF_H)
-update.o: $(arch_hdrdir)/ruby/config.h
-update.o: $(hdrdir)/ruby.h
-update.o: $(hdrdir)/ruby/assert.h
-update.o: $(hdrdir)/ruby/backward.h
-update.o: $(hdrdir)/ruby/defines.h
-update.o: $(hdrdir)/ruby/intern.h
-update.o: $(hdrdir)/ruby/missing.h
-update.o: $(hdrdir)/ruby/ruby.h
-update.o: $(hdrdir)/ruby/st.h
-update.o: $(hdrdir)/ruby/subst.h
-update.o: update.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/string/coderange.c b/ext/-test-/string/coderange.c
index 1342ce20da..df83fb5d44 100644
--- a/ext/-test-/string/coderange.c
+++ b/ext/-test-/string/coderange.c
@@ -17,7 +17,7 @@ coderange_int2sym(int coderange)
return sym_broken;
}
rb_bug("wrong condition of coderange");
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
/* return coderange without scan */
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c
index 71eafdb703..2a41b932db 100644
--- a/ext/-test-/string/cstr.c
+++ b/ext/-test-/string/cstr.c
@@ -1,4 +1,3 @@
-#include "ruby/encoding.h"
#include "internal.h"
static VALUE
diff --git a/ext/-test-/string/depend b/ext/-test-/string/depend
index f6888b5da7..71e995a523 100644
--- a/ext/-test-/string/depend
+++ b/ext/-test-/string/depend
@@ -1,20 +1,22 @@
# AUTOGENERATED DEPENDENCIES START
capacity.o: $(RUBY_EXTCONF_H)
capacity.o: $(arch_hdrdir)/ruby/config.h
-capacity.o: $(hdrdir)/ruby.h
-capacity.o: $(hdrdir)/ruby/assert.h
capacity.o: $(hdrdir)/ruby/backward.h
capacity.o: $(hdrdir)/ruby/defines.h
+capacity.o: $(hdrdir)/ruby/encoding.h
capacity.o: $(hdrdir)/ruby/intern.h
+capacity.o: $(hdrdir)/ruby/io.h
capacity.o: $(hdrdir)/ruby/missing.h
+capacity.o: $(hdrdir)/ruby/onigmo.h
+capacity.o: $(hdrdir)/ruby/oniguruma.h
capacity.o: $(hdrdir)/ruby/ruby.h
capacity.o: $(hdrdir)/ruby/st.h
capacity.o: $(hdrdir)/ruby/subst.h
+capacity.o: $(top_srcdir)/include/ruby.h
capacity.o: $(top_srcdir)/internal.h
capacity.o: capacity.c
coderange.o: $(RUBY_EXTCONF_H)
coderange.o: $(arch_hdrdir)/ruby/config.h
-coderange.o: $(hdrdir)/ruby/assert.h
coderange.o: $(hdrdir)/ruby/backward.h
coderange.o: $(hdrdir)/ruby/defines.h
coderange.o: $(hdrdir)/ruby/encoding.h
@@ -28,24 +30,22 @@ coderange.o: $(hdrdir)/ruby/subst.h
coderange.o: coderange.c
cstr.o: $(RUBY_EXTCONF_H)
cstr.o: $(arch_hdrdir)/ruby/config.h
-cstr.o: $(hdrdir)/ruby.h
-cstr.o: $(hdrdir)/ruby/assert.h
cstr.o: $(hdrdir)/ruby/backward.h
cstr.o: $(hdrdir)/ruby/defines.h
cstr.o: $(hdrdir)/ruby/encoding.h
cstr.o: $(hdrdir)/ruby/intern.h
+cstr.o: $(hdrdir)/ruby/io.h
cstr.o: $(hdrdir)/ruby/missing.h
cstr.o: $(hdrdir)/ruby/onigmo.h
cstr.o: $(hdrdir)/ruby/oniguruma.h
cstr.o: $(hdrdir)/ruby/ruby.h
cstr.o: $(hdrdir)/ruby/st.h
cstr.o: $(hdrdir)/ruby/subst.h
+cstr.o: $(top_srcdir)/include/ruby.h
cstr.o: $(top_srcdir)/internal.h
cstr.o: cstr.c
ellipsize.o: $(RUBY_EXTCONF_H)
ellipsize.o: $(arch_hdrdir)/ruby/config.h
-ellipsize.o: $(hdrdir)/ruby.h
-ellipsize.o: $(hdrdir)/ruby/assert.h
ellipsize.o: $(hdrdir)/ruby/backward.h
ellipsize.o: $(hdrdir)/ruby/defines.h
ellipsize.o: $(hdrdir)/ruby/intern.h
@@ -53,11 +53,10 @@ ellipsize.o: $(hdrdir)/ruby/missing.h
ellipsize.o: $(hdrdir)/ruby/ruby.h
ellipsize.o: $(hdrdir)/ruby/st.h
ellipsize.o: $(hdrdir)/ruby/subst.h
+ellipsize.o: $(top_srcdir)/include/ruby.h
ellipsize.o: ellipsize.c
enc_associate.o: $(RUBY_EXTCONF_H)
enc_associate.o: $(arch_hdrdir)/ruby/config.h
-enc_associate.o: $(hdrdir)/ruby.h
-enc_associate.o: $(hdrdir)/ruby/assert.h
enc_associate.o: $(hdrdir)/ruby/backward.h
enc_associate.o: $(hdrdir)/ruby/defines.h
enc_associate.o: $(hdrdir)/ruby/encoding.h
@@ -68,10 +67,10 @@ enc_associate.o: $(hdrdir)/ruby/oniguruma.h
enc_associate.o: $(hdrdir)/ruby/ruby.h
enc_associate.o: $(hdrdir)/ruby/st.h
enc_associate.o: $(hdrdir)/ruby/subst.h
+enc_associate.o: $(top_srcdir)/include/ruby.h
enc_associate.o: enc_associate.c
enc_str_buf_cat.o: $(RUBY_EXTCONF_H)
enc_str_buf_cat.o: $(arch_hdrdir)/ruby/config.h
-enc_str_buf_cat.o: $(hdrdir)/ruby/assert.h
enc_str_buf_cat.o: $(hdrdir)/ruby/backward.h
enc_str_buf_cat.o: $(hdrdir)/ruby/defines.h
enc_str_buf_cat.o: $(hdrdir)/ruby/encoding.h
@@ -85,8 +84,6 @@ enc_str_buf_cat.o: $(hdrdir)/ruby/subst.h
enc_str_buf_cat.o: enc_str_buf_cat.c
fstring.o: $(RUBY_EXTCONF_H)
fstring.o: $(arch_hdrdir)/ruby/config.h
-fstring.o: $(hdrdir)/ruby.h
-fstring.o: $(hdrdir)/ruby/assert.h
fstring.o: $(hdrdir)/ruby/backward.h
fstring.o: $(hdrdir)/ruby/defines.h
fstring.o: $(hdrdir)/ruby/intern.h
@@ -94,11 +91,10 @@ fstring.o: $(hdrdir)/ruby/missing.h
fstring.o: $(hdrdir)/ruby/ruby.h
fstring.o: $(hdrdir)/ruby/st.h
fstring.o: $(hdrdir)/ruby/subst.h
+fstring.o: $(top_srcdir)/include/ruby.h
fstring.o: fstring.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -106,11 +102,10 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
modify.o: $(RUBY_EXTCONF_H)
modify.o: $(arch_hdrdir)/ruby/config.h
-modify.o: $(hdrdir)/ruby.h
-modify.o: $(hdrdir)/ruby/assert.h
modify.o: $(hdrdir)/ruby/backward.h
modify.o: $(hdrdir)/ruby/defines.h
modify.o: $(hdrdir)/ruby/intern.h
@@ -118,26 +113,26 @@ modify.o: $(hdrdir)/ruby/missing.h
modify.o: $(hdrdir)/ruby/ruby.h
modify.o: $(hdrdir)/ruby/st.h
modify.o: $(hdrdir)/ruby/subst.h
+modify.o: $(top_srcdir)/include/ruby.h
modify.o: modify.c
new.o: $(RUBY_EXTCONF_H)
new.o: $(arch_hdrdir)/ruby/config.h
-new.o: $(hdrdir)/ruby.h
-new.o: $(hdrdir)/ruby/assert.h
new.o: $(hdrdir)/ruby/backward.h
new.o: $(hdrdir)/ruby/defines.h
new.o: $(hdrdir)/ruby/encoding.h
new.o: $(hdrdir)/ruby/intern.h
+new.o: $(hdrdir)/ruby/io.h
new.o: $(hdrdir)/ruby/missing.h
new.o: $(hdrdir)/ruby/onigmo.h
new.o: $(hdrdir)/ruby/oniguruma.h
new.o: $(hdrdir)/ruby/ruby.h
new.o: $(hdrdir)/ruby/st.h
new.o: $(hdrdir)/ruby/subst.h
+new.o: $(top_srcdir)/include/ruby.h
+new.o: $(top_srcdir)/internal.h
new.o: new.c
nofree.o: $(RUBY_EXTCONF_H)
nofree.o: $(arch_hdrdir)/ruby/config.h
-nofree.o: $(hdrdir)/ruby.h
-nofree.o: $(hdrdir)/ruby/assert.h
nofree.o: $(hdrdir)/ruby/backward.h
nofree.o: $(hdrdir)/ruby/defines.h
nofree.o: $(hdrdir)/ruby/intern.h
@@ -145,24 +140,26 @@ nofree.o: $(hdrdir)/ruby/missing.h
nofree.o: $(hdrdir)/ruby/ruby.h
nofree.o: $(hdrdir)/ruby/st.h
nofree.o: $(hdrdir)/ruby/subst.h
+nofree.o: $(top_srcdir)/include/ruby.h
nofree.o: nofree.c
normalize.o: $(RUBY_EXTCONF_H)
normalize.o: $(arch_hdrdir)/ruby/config.h
-normalize.o: $(hdrdir)/ruby.h
-normalize.o: $(hdrdir)/ruby/assert.h
normalize.o: $(hdrdir)/ruby/backward.h
normalize.o: $(hdrdir)/ruby/defines.h
+normalize.o: $(hdrdir)/ruby/encoding.h
normalize.o: $(hdrdir)/ruby/intern.h
+normalize.o: $(hdrdir)/ruby/io.h
normalize.o: $(hdrdir)/ruby/missing.h
+normalize.o: $(hdrdir)/ruby/onigmo.h
+normalize.o: $(hdrdir)/ruby/oniguruma.h
normalize.o: $(hdrdir)/ruby/ruby.h
normalize.o: $(hdrdir)/ruby/st.h
normalize.o: $(hdrdir)/ruby/subst.h
+normalize.o: $(top_srcdir)/include/ruby.h
normalize.o: $(top_srcdir)/internal.h
normalize.o: normalize.c
qsort.o: $(RUBY_EXTCONF_H)
qsort.o: $(arch_hdrdir)/ruby/config.h
-qsort.o: $(hdrdir)/ruby.h
-qsort.o: $(hdrdir)/ruby/assert.h
qsort.o: $(hdrdir)/ruby/backward.h
qsort.o: $(hdrdir)/ruby/defines.h
qsort.o: $(hdrdir)/ruby/encoding.h
@@ -174,11 +171,11 @@ qsort.o: $(hdrdir)/ruby/ruby.h
qsort.o: $(hdrdir)/ruby/st.h
qsort.o: $(hdrdir)/ruby/subst.h
qsort.o: $(hdrdir)/ruby/util.h
+qsort.o: $(top_srcdir)/include/ruby.h
qsort.o: qsort.c
rb_str_dup.o: $(RUBY_EXTCONF_H)
rb_str_dup.o: $(arch_hdrdir)/ruby/config.h
rb_str_dup.o: $(hdrdir)/ruby.h
-rb_str_dup.o: $(hdrdir)/ruby/assert.h
rb_str_dup.o: $(hdrdir)/ruby/backward.h
rb_str_dup.o: $(hdrdir)/ruby/defines.h
rb_str_dup.o: $(hdrdir)/ruby/intern.h
@@ -189,8 +186,6 @@ rb_str_dup.o: $(hdrdir)/ruby/subst.h
rb_str_dup.o: rb_str_dup.c
set_len.o: $(RUBY_EXTCONF_H)
set_len.o: $(arch_hdrdir)/ruby/config.h
-set_len.o: $(hdrdir)/ruby.h
-set_len.o: $(hdrdir)/ruby/assert.h
set_len.o: $(hdrdir)/ruby/backward.h
set_len.o: $(hdrdir)/ruby/defines.h
set_len.o: $(hdrdir)/ruby/intern.h
@@ -198,5 +193,6 @@ set_len.o: $(hdrdir)/ruby/missing.h
set_len.o: $(hdrdir)/ruby/ruby.h
set_len.o: $(hdrdir)/ruby/st.h
set_len.o: $(hdrdir)/ruby/subst.h
+set_len.o: $(top_srcdir)/include/ruby.h
set_len.o: set_len.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/struct/depend b/ext/-test-/struct/depend
index 552daf0ac5..58ededbff9 100644
--- a/ext/-test-/struct/depend
+++ b/ext/-test-/struct/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
duplicate.o: $(RUBY_EXTCONF_H)
duplicate.o: $(arch_hdrdir)/ruby/config.h
-duplicate.o: $(hdrdir)/ruby.h
-duplicate.o: $(hdrdir)/ruby/assert.h
duplicate.o: $(hdrdir)/ruby/backward.h
duplicate.o: $(hdrdir)/ruby/defines.h
duplicate.o: $(hdrdir)/ruby/intern.h
@@ -10,11 +8,10 @@ duplicate.o: $(hdrdir)/ruby/missing.h
duplicate.o: $(hdrdir)/ruby/ruby.h
duplicate.o: $(hdrdir)/ruby/st.h
duplicate.o: $(hdrdir)/ruby/subst.h
+duplicate.o: $(top_srcdir)/include/ruby.h
duplicate.o: duplicate.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -22,11 +19,10 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
len.o: $(RUBY_EXTCONF_H)
len.o: $(arch_hdrdir)/ruby/config.h
-len.o: $(hdrdir)/ruby.h
-len.o: $(hdrdir)/ruby/assert.h
len.o: $(hdrdir)/ruby/backward.h
len.o: $(hdrdir)/ruby/defines.h
len.o: $(hdrdir)/ruby/intern.h
@@ -34,11 +30,10 @@ len.o: $(hdrdir)/ruby/missing.h
len.o: $(hdrdir)/ruby/ruby.h
len.o: $(hdrdir)/ruby/st.h
len.o: $(hdrdir)/ruby/subst.h
+len.o: $(top_srcdir)/include/ruby.h
len.o: len.c
member.o: $(RUBY_EXTCONF_H)
member.o: $(arch_hdrdir)/ruby/config.h
-member.o: $(hdrdir)/ruby.h
-member.o: $(hdrdir)/ruby/assert.h
member.o: $(hdrdir)/ruby/backward.h
member.o: $(hdrdir)/ruby/defines.h
member.o: $(hdrdir)/ruby/intern.h
@@ -46,5 +41,6 @@ member.o: $(hdrdir)/ruby/missing.h
member.o: $(hdrdir)/ruby/ruby.h
member.o: $(hdrdir)/ruby/st.h
member.o: $(hdrdir)/ruby/subst.h
+member.o: $(top_srcdir)/include/ruby.h
member.o: member.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/symbol/depend b/ext/-test-/symbol/depend
deleted file mode 100644
index bccb4afc15..0000000000
--- a/ext/-test-/symbol/depend
+++ /dev/null
@@ -1,26 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-type.o: $(RUBY_EXTCONF_H)
-type.o: $(arch_hdrdir)/ruby/config.h
-type.o: $(hdrdir)/ruby.h
-type.o: $(hdrdir)/ruby/assert.h
-type.o: $(hdrdir)/ruby/backward.h
-type.o: $(hdrdir)/ruby/defines.h
-type.o: $(hdrdir)/ruby/intern.h
-type.o: $(hdrdir)/ruby/missing.h
-type.o: $(hdrdir)/ruby/ruby.h
-type.o: $(hdrdir)/ruby/st.h
-type.o: $(hdrdir)/ruby/subst.h
-type.o: type.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/symbol/init.c b/ext/-test-/symbol/init.c
index 4038701ac9..20cf2fa079 100644
--- a/ext/-test-/symbol/init.c
+++ b/ext/-test-/symbol/init.c
@@ -20,13 +20,6 @@ sym_pinneddown_p(VALUE dummy, VALUE sym)
#endif
}
-static VALUE
-sym_iv_get(VALUE dummy, VALUE obj, VALUE name)
-{
- const char *n = StringValueCStr(name);
- return rb_iv_get(obj, n);
-}
-
void
Init_symbol(void)
{
@@ -34,6 +27,5 @@ Init_symbol(void)
VALUE klass = rb_define_class_under(mBug, "Symbol", rb_cSymbol);
rb_define_singleton_method(klass, "find", sym_find, 1);
rb_define_singleton_method(klass, "pinneddown?", sym_pinneddown_p, 1);
- rb_define_singleton_method(klass, "iv_get", sym_iv_get, 2);
TEST_INIT_FUNCS(init);
}
diff --git a/ext/-test-/thread_fd_close/depend b/ext/-test-/thread_fd_close/depend
index 8c49c2d4fe..7bc04c3db3 100644
--- a/ext/-test-/thread_fd_close/depend
+++ b/ext/-test-/thread_fd_close/depend
@@ -1,11 +1,14 @@
# AUTOGENERATED DEPENDENCIES START
thread_fd_close.o: $(RUBY_EXTCONF_H)
thread_fd_close.o: $(arch_hdrdir)/ruby/config.h
-thread_fd_close.o: $(hdrdir)/ruby/assert.h
thread_fd_close.o: $(hdrdir)/ruby/backward.h
thread_fd_close.o: $(hdrdir)/ruby/defines.h
+thread_fd_close.o: $(hdrdir)/ruby/encoding.h
thread_fd_close.o: $(hdrdir)/ruby/intern.h
+thread_fd_close.o: $(hdrdir)/ruby/io.h
thread_fd_close.o: $(hdrdir)/ruby/missing.h
+thread_fd_close.o: $(hdrdir)/ruby/onigmo.h
+thread_fd_close.o: $(hdrdir)/ruby/oniguruma.h
thread_fd_close.o: $(hdrdir)/ruby/ruby.h
thread_fd_close.o: $(hdrdir)/ruby/st.h
thread_fd_close.o: $(hdrdir)/ruby/subst.h
diff --git a/ext/-test-/time/depend b/ext/-test-/time/depend
deleted file mode 100644
index 2f4b8d1f13..0000000000
--- a/ext/-test-/time/depend
+++ /dev/null
@@ -1,38 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-init.o: $(RUBY_EXTCONF_H)
-init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
-init.o: $(hdrdir)/ruby/backward.h
-init.o: $(hdrdir)/ruby/defines.h
-init.o: $(hdrdir)/ruby/intern.h
-init.o: $(hdrdir)/ruby/missing.h
-init.o: $(hdrdir)/ruby/ruby.h
-init.o: $(hdrdir)/ruby/st.h
-init.o: $(hdrdir)/ruby/subst.h
-init.o: init.c
-leap_second.o: $(RUBY_EXTCONF_H)
-leap_second.o: $(arch_hdrdir)/ruby/config.h
-leap_second.o: $(hdrdir)/ruby.h
-leap_second.o: $(hdrdir)/ruby/assert.h
-leap_second.o: $(hdrdir)/ruby/backward.h
-leap_second.o: $(hdrdir)/ruby/defines.h
-leap_second.o: $(hdrdir)/ruby/intern.h
-leap_second.o: $(hdrdir)/ruby/missing.h
-leap_second.o: $(hdrdir)/ruby/ruby.h
-leap_second.o: $(hdrdir)/ruby/st.h
-leap_second.o: $(hdrdir)/ruby/subst.h
-leap_second.o: leap_second.c
-new.o: $(RUBY_EXTCONF_H)
-new.o: $(arch_hdrdir)/ruby/config.h
-new.o: $(hdrdir)/ruby.h
-new.o: $(hdrdir)/ruby/assert.h
-new.o: $(hdrdir)/ruby/backward.h
-new.o: $(hdrdir)/ruby/defines.h
-new.o: $(hdrdir)/ruby/intern.h
-new.o: $(hdrdir)/ruby/missing.h
-new.o: $(hdrdir)/ruby/ruby.h
-new.o: $(hdrdir)/ruby/st.h
-new.o: $(hdrdir)/ruby/subst.h
-new.o: new.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/time/leap_second.c b/ext/-test-/time/leap_second.c
deleted file mode 100644
index 7eed421b73..0000000000
--- a/ext/-test-/time/leap_second.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "ruby.h"
-
-void ruby_reset_leap_second_info(void);
-static VALUE
-bug_time_s_reset_leap_second_info(VALUE klass)
-{
- ruby_reset_leap_second_info();
- return Qnil;
-}
-
-void
-Init_time_leap_second(VALUE klass)
-{
- rb_define_singleton_method(klass, "reset_leap_second_info", bug_time_s_reset_leap_second_info, 0);
-}
diff --git a/ext/-test-/tracepoint/depend b/ext/-test-/tracepoint/depend
index b811df4472..5b2b2f7369 100644
--- a/ext/-test-/tracepoint/depend
+++ b/ext/-test-/tracepoint/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
gc_hook.o: $(RUBY_EXTCONF_H)
gc_hook.o: $(arch_hdrdir)/ruby/config.h
-gc_hook.o: $(hdrdir)/ruby/assert.h
gc_hook.o: $(hdrdir)/ruby/backward.h
gc_hook.o: $(hdrdir)/ruby/debug.h
gc_hook.o: $(hdrdir)/ruby/defines.h
@@ -13,7 +12,6 @@ gc_hook.o: $(hdrdir)/ruby/subst.h
gc_hook.o: gc_hook.c
tracepoint.o: $(RUBY_EXTCONF_H)
tracepoint.o: $(arch_hdrdir)/ruby/config.h
-tracepoint.o: $(hdrdir)/ruby/assert.h
tracepoint.o: $(hdrdir)/ruby/backward.h
tracepoint.o: $(hdrdir)/ruby/debug.h
tracepoint.o: $(hdrdir)/ruby/defines.h
diff --git a/ext/-test-/tracepoint/gc_hook.c b/ext/-test-/tracepoint/gc_hook.c
index 54b469dcad..6d8485ecb1 100644
--- a/ext/-test-/tracepoint/gc_hook.c
+++ b/ext/-test-/tracepoint/gc_hook.c
@@ -4,7 +4,7 @@
static int invoking; /* TODO: should not be global variable */
static VALUE
-invoke_proc_ensure(VALUE _)
+invoke_proc_ensure(void *dmy)
{
invoking = 0;
return Qnil;
@@ -73,16 +73,8 @@ set_after_gc_start(VALUE module, VALUE proc)
"__set_after_gc_start_tpval__", "__set_after_gc_start_proc__");
}
-static VALUE
-start_after_gc_exit(VALUE module, VALUE proc)
-{
- return set_gc_hook(module, proc, RUBY_INTERNAL_EVENT_GC_EXIT,
- "__set_after_gc_exit_tpval__", "__set_after_gc_exit_proc__");
-}
-
void
Init_gc_hook(VALUE module)
{
rb_define_module_function(module, "after_gc_start_hook=", set_after_gc_start, 1);
- rb_define_module_function(module, "after_gc_exit_hook=", start_after_gc_exit, 1);
}
diff --git a/ext/-test-/typeddata/depend b/ext/-test-/typeddata/depend
deleted file mode 100644
index e0dd0653a8..0000000000
--- a/ext/-test-/typeddata/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-typeddata.o: $(RUBY_EXTCONF_H)
-typeddata.o: $(arch_hdrdir)/ruby/config.h
-typeddata.o: $(hdrdir)/ruby.h
-typeddata.o: $(hdrdir)/ruby/assert.h
-typeddata.o: $(hdrdir)/ruby/backward.h
-typeddata.o: $(hdrdir)/ruby/defines.h
-typeddata.o: $(hdrdir)/ruby/intern.h
-typeddata.o: $(hdrdir)/ruby/missing.h
-typeddata.o: $(hdrdir)/ruby/ruby.h
-typeddata.o: $(hdrdir)/ruby/st.h
-typeddata.o: $(hdrdir)/ruby/subst.h
-typeddata.o: typeddata.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/vm/depend b/ext/-test-/vm/depend
index 0f85d69bb0..dd56dd0e0d 100644
--- a/ext/-test-/vm/depend
+++ b/ext/-test-/vm/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
at_exit.o: $(RUBY_EXTCONF_H)
at_exit.o: $(arch_hdrdir)/ruby/config.h
-at_exit.o: $(hdrdir)/ruby/assert.h
at_exit.o: $(hdrdir)/ruby/backward.h
at_exit.o: $(hdrdir)/ruby/defines.h
at_exit.o: $(hdrdir)/ruby/intern.h
diff --git a/ext/-test-/wait_for_single_fd/depend b/ext/-test-/wait_for_single_fd/depend
index 8549fca781..edd2f88dcf 100644
--- a/ext/-test-/wait_for_single_fd/depend
+++ b/ext/-test-/wait_for_single_fd/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
wait_for_single_fd.o: $(RUBY_EXTCONF_H)
wait_for_single_fd.o: $(arch_hdrdir)/ruby/config.h
-wait_for_single_fd.o: $(hdrdir)/ruby/assert.h
wait_for_single_fd.o: $(hdrdir)/ruby/backward.h
wait_for_single_fd.o: $(hdrdir)/ruby/defines.h
wait_for_single_fd.o: $(hdrdir)/ruby/encoding.h
diff --git a/ext/-test-/wait_for_single_fd/extconf.rb b/ext/-test-/wait_for_single_fd/extconf.rb
index 2a976c8f4b..931662c040 100644
--- a/ext/-test-/wait_for_single_fd/extconf.rb
+++ b/ext/-test-/wait_for_single_fd/extconf.rb
@@ -1,4 +1,2 @@
# frozen_string_literal: false
-headers = %w(sys/types.h sys/time.h sys/event.h).select { |h| have_header(h) }
-have_func('kqueue', headers)
create_makefile("-test-/wait_for_single_fd")
diff --git a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c
index b8a33979bc..d406724a3f 100644
--- a/ext/-test-/wait_for_single_fd/wait_for_single_fd.c
+++ b/ext/-test-/wait_for_single_fd/wait_for_single_fd.c
@@ -19,67 +19,6 @@ wait_for_single_fd(VALUE ign, VALUE fd, VALUE events, VALUE timeout)
return INT2NUM(rc);
}
-#ifdef HAVE_KQUEUE
-/* ensure rb_wait_for_single_fd works on kqueue descriptors */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/event.h>
-static VALUE
-kqueue_test_wait(VALUE klass)
-{
- int kqfd = -1;
- int p[2] = { -1, -1 };
- struct timeval tv = { 0, 0 };
- const struct timespec ts = { 1, 0 };
- struct kevent kev;
- const char *msg;
- VALUE ret = Qfalse;
- int e = 0;
- int n;
-
- msg = "pipe";
- if (rb_cloexec_pipe(p) < 0) goto err;
-
- msg = "kqueue";
- kqfd = kqueue();
- if (kqfd < 0) goto err;
-
- n = rb_wait_for_single_fd(kqfd, RB_WAITFD_IN, &tv);
- if (n != 0) {
- msg = "spurious wakeup";
- errno = 0;
- goto err;
- }
-
- msg = "write";
- if (write(p[1], "", 1) < 0) goto err;
-
- EV_SET(&kev, p[0], EVFILT_READ, EV_ADD, 0, 0, 0);
-
- msg = "kevent";
- n = kevent(kqfd, &kev, 1, &kev, 1, &ts);
- if (n < 0) goto err;
- msg = NULL;
- if (n == 1) {
- n = rb_wait_for_single_fd(kqfd, RB_WAITFD_IN, &tv);
- ret = INT2NUM(n);
- }
- else {
- rb_warn("kevent did not return readiness");
- }
-err:
- if (msg) e = errno;
- if (p[0] >= 0) close(p[0]);
- if (p[1] >= 0) close(p[1]);
- if (kqfd >= 0) close(kqfd);
- if (msg) {
- if (e) rb_syserr_fail(e, msg);
- rb_raise(rb_eRuntimeError, "%s", msg);
- }
- return ret;
-}
-#endif /* HAVE_KQUEUE */
-
void
Init_wait_for_single_fd(void)
{
@@ -88,7 +27,4 @@ Init_wait_for_single_fd(void)
rb_define_const(rb_cObject, "RB_WAITFD_PRI", INT2NUM(RB_WAITFD_PRI));
rb_define_singleton_method(rb_cIO, "wait_for_single_fd",
wait_for_single_fd, 3);
-#ifdef HAVE_KQUEUE
- rb_define_singleton_method(rb_cIO, "kqueue_test_wait", kqueue_test_wait, 0);
-#endif
}
diff --git a/ext/-test-/win32/console/attribute.c b/ext/-test-/win32/console/attribute.c
index a5f80fcaff..6d706fbfe7 100644
--- a/ext/-test-/win32/console/attribute.c
+++ b/ext/-test-/win32/console/attribute.c
@@ -61,9 +61,4 @@ Init_attribute(VALUE m)
rb_define_const(m, "BACKGROUND_GREEN", INT2FIX(BACKGROUND_GREEN));
rb_define_const(m, "BACKGROUND_RED", INT2FIX(BACKGROUND_RED));
rb_define_const(m, "BACKGROUND_INTENSITY", INT2FIX(BACKGROUND_INTENSITY));
-
-#ifndef COMMON_LVB_REVERSE_VIDEO
-#define COMMON_LVB_REVERSE_VIDEO 0x4000
-#endif
- rb_define_const(m, "REVERSE_VIDEO", INT2FIX(COMMON_LVB_REVERSE_VIDEO));
}
diff --git a/ext/.document b/ext/.document
index 354601569b..6a491576a1 100644
--- a/ext/.document
+++ b/ext/.document
@@ -30,8 +30,6 @@ io/wait/wait.c
json/generator/generator.c
json/lib
json/parser/parser.c
-monitor/lib
-monitor/monitor.c
nkf/lib
nkf/nkf.c
objspace/objspace.c
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 7ac883730d..cdd00388d4 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -110,7 +110,7 @@ rb_rational_num(VALUE rat)
#ifdef HAVE_TYPE_STRUCT_RRATIONAL
return RRATIONAL(rat)->num;
#else
- return rb_funcall(rat, rb_intern("numerator"), 0);
+ return rb_funcall(rat, rb_intern("numerator"));
#endif
}
#endif
@@ -122,7 +122,7 @@ rb_rational_den(VALUE rat)
#ifdef HAVE_TYPE_STRUCT_RRATIONAL
return RRATIONAL(rat)->den;
#else
- return rb_funcall(rat, rb_intern("denominator"), 0);
+ return rb_funcall(rat, rb_intern("denominator"));
#endif
}
#endif
@@ -136,6 +136,24 @@ rb_rational_den(VALUE rat)
#define DoSomeOne(x,y,f) rb_num_coerce_bin(x,y,f)
/*
+ * Returns the BigDecimal version number.
+ */
+static VALUE
+BigDecimal_version(VALUE self)
+{
+ /*
+ * 1.0.0: Ruby 1.8.0
+ * 1.0.1: Ruby 1.8.1
+ * 1.1.0: Ruby 1.9.3
+ */
+#ifndef RUBY_BIGDECIMAL_VERSION
+# error RUBY_BIGDECIMAL_VERSION is not defined
+#endif
+ rb_warning("BigDecimal.ver is deprecated; use BigDecimal::VERSION instead.");
+ return rb_str_new2(RUBY_BIGDECIMAL_VERSION);
+}
+
+/*
* VP routines used in BigDecimal part
*/
static unsigned short VpGetException(void);
@@ -276,6 +294,7 @@ again:
#ifdef ENABLE_NUMERIC_STRING
case T_STRING:
StringValueCStr(v);
+ rb_check_safe_obj(v);
return VpCreateRbObject(RSTRING_LEN(v) + VpBaseFig() + 1,
RSTRING_PTR(v));
#endif /* ENABLE_NUMERIC_STRING */
@@ -417,6 +436,7 @@ BigDecimal_load(VALUE self, VALUE str)
unsigned long m=0;
pch = (unsigned char *)StringValueCStr(str);
+ rb_check_safe_obj(str);
/* First get max prec */
while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') {
if(!ISDIGIT(ch)) {
@@ -644,10 +664,9 @@ VP_EXPORT Real *
VpNewRbClass(size_t mx, const char *str, VALUE klass)
{
VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0);
- Real *pv = VpAlloc(mx, str, 1, 1);
+ Real *pv = VpAlloc(mx,str);
RTYPEDDATA_DATA(obj) = pv;
pv->obj = obj;
- RB_OBJ_FREEZE(obj);
return pv;
}
@@ -1754,15 +1773,12 @@ BigDecimal_fix(VALUE self)
* round(n, mode)
*
* Round to the nearest integer (by default), returning the result as a
- * BigDecimal if n is specified, or as an Integer if it isn't.
+ * BigDecimal.
*
* BigDecimal('3.14159').round #=> 3
* BigDecimal('8.7').round #=> 9
* BigDecimal('-9.9').round #=> -10
*
- * BigDecimal('3.14159').round(2).class.name #=> "BigDecimal"
- * BigDecimal('3.14159').round.class.name #=> "Integer"
- *
* If n is specified and positive, the fractional part of the result has no
* more than that many digits.
*
@@ -2028,6 +2044,7 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
if (rb_scan_args(argc, argv, "01", &f) == 1) {
if (RB_TYPE_P(f, T_STRING)) {
psz = StringValueCStr(f);
+ rb_check_safe_obj(f);
if (*psz == ' ') {
fPlus = 1;
psz++;
@@ -2148,10 +2165,15 @@ BigDecimal_exponent(VALUE self)
return INT2NUM(e);
}
-/* Returns a string representation of self.
+/* Returns debugging information about the value as a string of comma-separated
+ * values in angle brackets with a leading #:
*
* BigDecimal("1234.5678").inspect
* #=> "0.12345678e4"
+ *
+ * The first part is the address, the second is the value as a string, and
+ * the final part ss(mm) is the current number of significant digits and the
+ * maximum number of significant digits, respectively.
*/
static VALUE
BigDecimal_inspect(VALUE self)
@@ -2313,7 +2335,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self)
n = NIL_P(prec) ? (ssize_t)(x->Prec*VpBaseFig()) : NUM2SSIZET(prec);
if (VpIsNaN(x)) {
- y = VpCreateRbObject(n, "0");
+ y = VpCreateRbObject(n, "0#");
RB_GC_GUARD(y->obj);
VpSetNaN(y);
return ToValue(y);
@@ -2437,7 +2459,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self)
}
}
else {
- y = VpCreateRbObject(n, "0");
+ y = VpCreateRbObject(n, "0#");
if (BIGDECIMAL_NEGATIVE_P(x)) {
if (is_integer(vexp)) {
if (is_even(vexp)) {
@@ -2470,7 +2492,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self)
}
else if (RTEST(rb_funcall(abs_value, '<', 1, INT2FIX(1)))) {
if (is_negative(vexp)) {
- y = VpCreateRbObject(n, "0");
+ y = VpCreateRbObject(n, "0#");
if (is_even(vexp)) {
VpSetInf(y, VpGetSign(x));
}
@@ -2488,7 +2510,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self)
}
else {
if (is_positive(vexp)) {
- y = VpCreateRbObject(n, "0");
+ y = VpCreateRbObject(n, "0#");
if (is_even(vexp)) {
VpSetInf(y, VpGetSign(x));
}
@@ -2538,6 +2560,72 @@ BigDecimal_power_op(VALUE self, VALUE exp)
return BigDecimal_power(1, &exp, self);
}
+static VALUE
+BigDecimal_s_allocate(VALUE klass)
+{
+ return VpNewRbClass(0, NULL, klass)->obj;
+}
+
+static Real *BigDecimal_new(int argc, VALUE *argv);
+
+/* call-seq:
+ * new(initial, digits)
+ *
+ * Create a new BigDecimal object.
+ *
+ * initial:: The initial value, as an Integer, a Float, a Rational,
+ * a BigDecimal, or a String.
+ *
+ * If it is a String, spaces are ignored and unrecognized characters
+ * terminate the value.
+ *
+ * digits:: The number of significant digits, as an Integer. If omitted or 0,
+ * the number of significant digits is determined from the initial
+ * value.
+ *
+ * The actual number of significant digits used in computation is usually
+ * larger than the specified number.
+ *
+ * ==== Exceptions
+ *
+ * TypeError:: If the +initial+ type is neither Integer, Float,
+ * Rational, nor BigDecimal, this exception is raised.
+ *
+ * TypeError:: If the +digits+ is not an Integer, this exception is raised.
+ *
+ * ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than
+ * Float::DIG + 1, this exception is raised.
+ *
+ * ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+
+ * value is omitted, this exception is raised.
+ */
+static VALUE
+BigDecimal_s_new(int argc, VALUE *argv, VALUE self)
+{
+ rb_warning("BigDecimal.new is deprecated; use Kernel.BigDecimal method instead.");
+ return rb_call_super(argc, argv);
+}
+
+static VALUE
+BigDecimal_initialize(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(1);
+ Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
+ Real *x;
+
+ GUARD_OBJ(x, BigDecimal_new(argc, argv));
+ if (ToValue(x)) {
+ pv = VpCopy(pv, x);
+ }
+ else {
+ VpFree(pv);
+ pv = x;
+ }
+ DATA_PTR(self) = pv;
+ pv->obj = self;
+ return self;
+}
+
/* :nodoc:
*
* private method for dup and clone the provided BigDecimal +other+
@@ -2560,72 +2648,19 @@ BigDecimal_clone(VALUE self)
return self;
}
-#ifdef HAVE_RB_OPTS_EXCEPTION_P
-int rb_opts_exception_p(VALUE opts, int default_value);
-#define opts_exception_p(opts) rb_opts_exception_p((opts), 1)
-#else
-static int
-opts_exception_p(VALUE opts)
-{
- static ID kwds[1];
- VALUE exception;
- if (!kwds[0]) {
- kwds[0] = rb_intern_const("exception");
- }
- if (!rb_get_kwargs(opts, kwds, 0, 1, &exception)) return 1;
- switch (exception) {
- case Qtrue: case Qfalse:
- break;
- default:
- rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE,
- exception);
- }
- return exception != Qfalse;
-}
-#endif
-
static Real *
-VpNewVarArg(int argc, VALUE *argv)
+BigDecimal_new(int argc, VALUE *argv)
{
size_t mf;
- VALUE opts = Qnil;
VALUE nFig;
VALUE iniValue;
double d;
- int exc;
-
- argc = rb_scan_args(argc, argv, "11:", &iniValue, &nFig, &opts);
- exc = opts_exception_p(opts);
- if (argc == 1) {
+ if (rb_scan_args(argc, argv, "11", &iniValue, &nFig) == 1) {
mf = 0;
}
else {
- /* expand GetPrecisionInt for exception suppression */
- ssize_t n = NUM2INT(nFig);
- if (n < 0) {
- if (!exc) {
- return NULL;
- }
- rb_raise(rb_eArgError, "negative precision");
- }
- mf = (size_t)n;
- }
-
- if (SPECIAL_CONST_P(iniValue)) {
- switch (iniValue) {
- case Qnil:
- if (!exc) return NULL;
- rb_raise(rb_eTypeError, "can't convert nil into BigDecimal");
- case Qtrue:
- if (!exc) return NULL;
- rb_raise(rb_eTypeError, "can't convert true into BigDecimal");
- case Qfalse:
- if (!exc) return NULL;
- rb_raise(rb_eTypeError, "can't convert false into BigDecimal");
- default:
- break;
- }
+ mf = GetPrecisionInt(nFig);
}
switch (TYPE(iniValue)) {
@@ -2648,17 +2683,11 @@ VpNewVarArg(int argc, VALUE *argv)
return pv;
}
if (mf > DBL_DIG+1) {
- if (!exc) {
- return NULL;
- }
rb_raise(rb_eArgError, "precision too large.");
}
/* fall through */
case T_RATIONAL:
if (NIL_P(nFig)) {
- if (!exc) {
- return NULL;
- }
rb_raise(rb_eArgError,
"can't omit precision for a %"PRIsVALUE".",
RB_OBJ_CLASSNAME(iniValue));
@@ -2670,85 +2699,25 @@ VpNewVarArg(int argc, VALUE *argv)
default:
break;
}
- /* TODO: support to_d */
- if (!exc) {
- iniValue = rb_check_convert_type(iniValue, T_STRING, "String", "to_str");
- if (NIL_P(iniValue)) return NULL;
- }
StringValueCStr(iniValue);
- return VpAlloc(mf, RSTRING_PTR(iniValue), 1, exc);
+ return VpAlloc(mf, RSTRING_PTR(iniValue));
}
-/* call-seq:
- * BigDecimal(initial, digits, exception: true)
- *
- * Create a new BigDecimal object.
- *
- * initial:: The initial value, as an Integer, a Float, a Rational,
- * a BigDecimal, or a String.
- *
- * If it is a String, spaces are ignored and unrecognized characters
- * terminate the value.
- *
- * digits:: The number of significant digits, as an Integer. If omitted or 0,
- * the number of significant digits is determined from the initial
- * value.
- *
- * The actual number of significant digits used in computation is
- * usually larger than the specified number.
- *
- * exception:: Whether an exception should be raised on invalid arguments.
- * +true+ by default, if passed +false+, just returns +nil+
- * for invalid.
- *
- *
- * ==== Exceptions
- *
- * TypeError:: If the +initial+ type is neither Integer, Float,
- * Rational, nor BigDecimal, this exception is raised.
- *
- * TypeError:: If the +digits+ is not an Integer, this exception is raised.
- *
- * ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than
- * Float::DIG + 1, this exception is raised.
- *
- * ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+
- * value is omitted, this exception is raised.
- */
+/* See also BigDecimal.new */
static VALUE
-f_BigDecimal(int argc, VALUE *argv, VALUE self)
+BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
{
ENTER(1);
Real *pv;
VALUE obj;
- if (argc > 0 && CLASS_OF(argv[0]) == rb_cBigDecimal) {
- if (argc == 1 || (argc == 2 && RB_TYPE_P(argv[1], T_HASH))) return argv[0];
- }
obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0);
- pv = VpNewVarArg(argc, argv);
- if (pv == NULL) return Qnil;
- SAVE(pv);
+ GUARD_OBJ(pv, BigDecimal_new(argc, argv));
if (ToValue(pv)) pv = VpCopy(NULL, pv);
RTYPEDDATA_DATA(obj) = pv;
- RB_OBJ_FREEZE(obj);
return pv->obj = obj;
}
-static VALUE
-BigDecimal_s_interpret_loosely(VALUE klass, VALUE str)
-{
- ENTER(1);
- char const *c_str;
- Real *pv;
-
- c_str = StringValueCStr(str);
- GUARD_OBJ(pv, VpAlloc(0, c_str, 0, 1));
- pv->obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, pv);
- RB_OBJ_FREEZE(pv->obj);
- return pv->obj;
-}
-
/* call-seq:
* BigDecimal.limit(digits)
*
@@ -2968,10 +2937,6 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
n = prec + rmpd_double_figures();
negative = BIGDECIMAL_NEGATIVE_P(vx);
if (negative) {
- VALUE x_zero = INT2NUM(1);
- VALUE x_copy = f_BigDecimal(1, &x_zero, klass);
- x = BigDecimal_initialize_copy(x_copy, x);
- vx = DATA_PTR(x);
VpSetSign(vx, 1);
}
@@ -3312,18 +3277,18 @@ Init_bigdecimal(void)
/* Class and method registration */
rb_cBigDecimal = rb_define_class("BigDecimal", rb_cNumeric);
+ rb_define_alloc_func(rb_cBigDecimal, BigDecimal_s_allocate);
/* Global function */
- rb_define_global_function("BigDecimal", f_BigDecimal, -1);
+ rb_define_global_function("BigDecimal", BigDecimal_global_new, -1);
/* Class methods */
- rb_undef_method(CLASS_OF(rb_cBigDecimal), "allocate");
- rb_undef_method(CLASS_OF(rb_cBigDecimal), "new");
- rb_define_singleton_method(rb_cBigDecimal, "interpret_loosely", BigDecimal_s_interpret_loosely, 1);
+ rb_define_singleton_method(rb_cBigDecimal, "new", BigDecimal_s_new, -1);
rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1);
+ rb_define_singleton_method(rb_cBigDecimal, "ver", BigDecimal_version, 0);
rb_define_singleton_method(rb_cBigDecimal, "save_exception_mode", BigDecimal_save_exception_mode, 0);
rb_define_singleton_method(rb_cBigDecimal, "save_rounding_mode", BigDecimal_save_rounding_mode, 0);
@@ -3443,13 +3408,14 @@ Init_bigdecimal(void)
arg = rb_str_new2("+Infinity");
/* Positive infinity value. */
- rb_define_const(rb_cBigDecimal, "INFINITY", f_BigDecimal(1, &arg, rb_cBigDecimal));
+ rb_define_const(rb_cBigDecimal, "INFINITY", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
arg = rb_str_new2("NaN");
/* 'Not a Number' value. */
- rb_define_const(rb_cBigDecimal, "NAN", f_BigDecimal(1, &arg, rb_cBigDecimal));
+ rb_define_const(rb_cBigDecimal, "NAN", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
/* instance methods */
+ rb_define_method(rb_cBigDecimal, "initialize", BigDecimal_initialize, -1);
rb_define_method(rb_cBigDecimal, "initialize_copy", BigDecimal_initialize_copy, 1);
rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);
@@ -3748,7 +3714,13 @@ VpSetRoundMode(unsigned short n)
* (to let the compiler know they may be changed in outside
* (... but not actually..)).
*/
+volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
+static double
+Zero(void)
+{
+ return gZero_ABCED9B1_CE73__00400511F31D;
+}
static double
One(void)
@@ -3773,19 +3745,25 @@ One(void)
VP_EXPORT double
VpGetDoubleNaN(void) /* Returns the value of NaN */
{
- return nan("");
+ static double fNaN = 0.0;
+ if (fNaN == 0.0) fNaN = Zero()/Zero();
+ return fNaN;
}
VP_EXPORT double
VpGetDoublePosInf(void) /* Returns the value of +Infinity */
{
- return HUGE_VAL;
+ static double fInf = 0.0;
+ if (fInf == 0.0) fInf = One()/Zero();
+ return fInf;
}
VP_EXPORT double
VpGetDoubleNegInf(void) /* Returns the value of -Infinity */
{
- return -HUGE_VAL;
+ static double fInf = 0.0;
+ if (fInf == 0.0) fInf = -(One()/Zero());
+ return fInf;
}
VP_EXPORT double
@@ -3980,11 +3958,14 @@ VP_EXPORT size_t
VpInit(BDIGIT BaseVal)
{
/* Setup +/- Inf NaN -0 */
+ VpGetDoubleNaN();
+ VpGetDoublePosInf();
+ VpGetDoubleNegInf();
VpGetDoubleNegZero();
/* Allocates Vp constants. */
- VpConstOne = VpAlloc(1UL, "1", 1, 1);
- VpPt5 = VpAlloc(1UL, ".5", 1, 1);
+ VpConstOne = VpAlloc(1UL, "1");
+ VpPt5 = VpAlloc(1UL, ".5");
#ifdef BIGDECIMAL_DEBUG
gnAlloc = 0;
@@ -4048,52 +4029,6 @@ overflow:
return VpException(VP_EXCEPTION_OVERFLOW, "Exponent overflow", 0);
}
-Real *
-rmpd_parse_special_string(const char *str)
-{
- static const struct {
- const char *str;
- size_t len;
- int sign;
- } table[] = {
- { SZ_INF, sizeof(SZ_INF) - 1, VP_SIGN_POSITIVE_INFINITE },
- { SZ_PINF, sizeof(SZ_PINF) - 1, VP_SIGN_POSITIVE_INFINITE },
- { SZ_NINF, sizeof(SZ_NINF) - 1, VP_SIGN_NEGATIVE_INFINITE },
- { SZ_NaN, sizeof(SZ_NaN) - 1, VP_SIGN_NaN }
- };
- static const size_t table_length = sizeof(table) / sizeof(table[0]);
- size_t i;
-
- for (i = 0; i < table_length; ++i) {
- const char *p;
- if (strncmp(str, table[i].str, table[i].len) != 0) {
- continue;
- }
-
- p = str + table[i].len;
- while (*p && ISSPACE(*p)) ++p;
- if (*p == '\0') {
- Real *vp = VpAllocReal(1);
- vp->MaxPrec = 1;
- switch (table[i].sign) {
- default:
- UNREACHABLE; break;
- case VP_SIGN_POSITIVE_INFINITE:
- VpSetPosInf(vp);
- return vp;
- case VP_SIGN_NEGATIVE_INFINITE:
- VpSetNegInf(vp);
- return vp;
- case VP_SIGN_NaN:
- VpSetNaN(vp);
- return vp;
- }
- }
- }
-
- return NULL;
-}
-
/*
* Allocates variable.
* [Input]
@@ -4108,10 +4043,10 @@ rmpd_parse_special_string(const char *str)
* NULL be returned if memory allocation is failed,or any error.
*/
VP_EXPORT Real *
-VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
+VpAlloc(size_t mx, const char *szVal)
{
const char *orig_szVal = szVal;
- size_t i, j, ni, ipf, nf, ipe, ne, dot_seen, exp_seen, nalloc;
+ size_t i, ni, ipn, ipf, nf, ipe, ne, dot_seen, exp_seen, nalloc;
char v, *psz;
int sign=1;
Real *vp = NULL;
@@ -4122,10 +4057,7 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
if (mx == 0) ++mx;
if (szVal) {
- /* Skipping leading spaces */
while (ISSPACE(*szVal)) szVal++;
-
- /* Processing the leading one `#` */
if (*szVal != '#') {
if (mf) {
mf = (mf + BASE_FIG - 1) / BASE_FIG + 2; /* Needs 1 more for div */
@@ -4139,7 +4071,6 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
}
}
else {
- return_zero:
/* necessary to be able to store */
/* at least mx digits. */
/* szVal==NULL ==> allocate zero value. */
@@ -4150,168 +4081,105 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
return vp;
}
- /* Check on Inf & NaN */
- if ((vp = rmpd_parse_special_string(szVal)) != NULL) {
- return vp;
- }
-
- /* Scanning digits */
-
- /* A buffer for keeping scanned digits */
+ /* Skip all '_' after digit: 2006-6-30 */
+ ni = 0;
buf = rb_str_tmp_new(strlen(szVal) + 1);
psz = RSTRING_PTR(buf);
-
- /* cursor: i for psz, and j for szVal */
- i = j = 0;
-
- /* Scanning: sign part */
- v = psz[i] = szVal[j];
- if ((v == '-') || (v == '+')) {
- sign = -(v == '-');
- ++i;
- ++j;
- }
-
- /* Scanning: integer part */
- ni = 0; /* number of digits in the integer part */
- while ((v = psz[i] = szVal[j]) != '\0') {
- if (!strict_p && ISSPACE(v)) {
- v = psz[i] = '\0';
+ i = 0;
+ ipn = 0;
+ while ((psz[i] = szVal[ipn]) != 0) {
+ if (ISSPACE(psz[i])) {
+ psz[i] = 0;
break;
}
- if (v == '_') {
+ if (ISDIGIT(psz[i])) ++ni;
+ if (psz[i] == '_') {
if (ni > 0) {
- v = szVal[j+1];
- if (v == '\0' || ISSPACE(v) || ISDIGIT(v)) {
- ++j;
- continue;
- }
- if (!strict_p) {
- v = psz[i] = '\0';
- break;
- }
+ ipn++;
+ continue;
}
- goto invalid_value;
- }
- if (!ISDIGIT(v)) {
+ psz[i] = 0;
break;
}
- ++ni;
++i;
- ++j;
+ ++ipn;
+ }
+ szVal = psz;
+
+ /* Check on Inf & NaN */
+ if (StrCmp(szVal, SZ_PINF) == 0 || StrCmp(szVal, SZ_INF) == 0 ) {
+ vp = VpAllocReal(1);
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetPosInf(vp);
+ return vp;
+ }
+ if (StrCmp(szVal, SZ_NINF) == 0) {
+ vp = VpAllocReal(1);
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetNegInf(vp);
+ return vp;
+ }
+ if (StrCmp(szVal, SZ_NaN) == 0) {
+ vp = VpAllocReal(1);
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetNaN(vp);
+ return vp;
}
- /* Scanning: fractional part */
- nf = 0; /* number of digits in the fractional part */
- ne = 0; /* number of digits in the exponential part */
- ipf = 0; /* index of the beginning of the fractional part */
- ipe = 0; /* index of the beginning of the exponential part */
+ /* check on number szVal[] */
+ ipn = i = 0;
+ if (szVal[i] == '-') { sign=-1; ++i; }
+ else if (szVal[i] == '+') ++i;
+ /* Skip digits */
+ ni = 0; /* digits in mantissa */
+ while ((v = szVal[i]) != 0) {
+ if (!ISDIGIT(v)) break;
+ ++i;
+ ++ni;
+ }
+ nf = 0;
+ ipf = 0;
+ ipe = 0;
+ ne = 0;
dot_seen = 0;
exp_seen = 0;
-
- if (v != '\0') {
- /* Scanning fractional part */
- if ((psz[i] = szVal[j]) == '.') {
+ if (v) {
+ /* other than digit nor \0 */
+ if (szVal[i] == '.') { /* xxx. */
dot_seen = 1;
++i;
- ++j;
ipf = i;
- while ((v = psz[i] = szVal[j]) != '\0') {
- if (!strict_p && ISSPACE(v)) {
- v = psz[i] = '\0';
- break;
- }
- if (v == '_') {
- if (nf > 0 && ISDIGIT(szVal[j+1])) {
- ++j;
- continue;
- }
- if (!strict_p) {
- v = psz[i] = '\0';
- if (nf == 0) {
- dot_seen = 0;
- }
- break;
- }
- goto invalid_value;
- }
+ while ((v = szVal[i]) != 0) { /* get fraction part. */
if (!ISDIGIT(v)) break;
++i;
- ++j;
++nf;
}
}
-
- /* Scanning exponential part */
- if (v != '\0') {
- switch ((psz[i] = szVal[j])) {
- case '\0':
- break;
- case 'e': case 'E':
- case 'd': case 'D':
- exp_seen = 1;
+ ipe = 0; /* Exponent */
+
+ switch (szVal[i]) {
+ case '\0':
+ break;
+ case 'e': case 'E':
+ case 'd': case 'D':
+ exp_seen = 1;
+ ++i;
+ ipe = i;
+ v = szVal[i];
+ if ((v == '-') || (v == '+')) ++i;
+ while ((v=szVal[i]) != 0) {
+ if (!ISDIGIT(v)) break;
++i;
- ++j;
- ipe = i;
- v = psz[i] = szVal[j];
- if ((v == '-') || (v == '+')) {
- ++i;
- ++j;
- }
- while ((v = psz[i] = szVal[j]) != '\0') {
- if (!strict_p && ISSPACE(v)) {
- v = psz[i] = '\0';
- break;
- }
- if (v == '_') {
- if (ne > 0 && ISDIGIT(szVal[j+1])) {
- ++j;
- continue;
- }
- if (!strict_p) {
- v = psz[i] = '\0';
- if (ne == 0) {
- exp_seen = 0;
- }
- break;
- }
- goto invalid_value;
- }
- if (!ISDIGIT(v)) break;
- ++i;
- ++j;
- ++ne;
- }
- break;
- default:
- break;
- }
- }
-
- if (v != '\0') {
- /* Scanning trailing spaces */
- while (ISSPACE(szVal[j])) ++j;
-
- /* Invalid character */
- if (szVal[j] && strict_p) {
- goto invalid_value;
- }
+ ++ne;
+ }
+ break;
+ default:
+ break;
}
}
-
- psz[i] = '\0';
-
- if (strict_p && (((ni == 0 || dot_seen) && nf == 0) || (exp_seen && ne == 0))) {
- VALUE str;
- invalid_value:
- if (!strict_p) {
- goto return_zero;
- }
- if (!exc) {
- return NULL;
- }
- str = rb_str_new2(orig_szVal);
- rb_raise(rb_eArgError, "invalid value for BigDecimal(): \"%"PRIsVALUE"\"", str);
+ if (((ni == 0 || dot_seen) && nf == 0) || (exp_seen && ne == 0)) {
+ VALUE str = rb_str_new2(orig_szVal);
+ rb_raise(rb_eArgError, "invalid value for BigDecimal(): \"%"PRIsVALUE"\"", str);
}
nalloc = (ni + nf + BASE_FIG - 1) / BASE_FIG + 1; /* set effective allocation */
@@ -4323,7 +4191,7 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
/* xmalloc() alway returns(or throw interruption) */
vp->MaxPrec = mx; /* set max precision */
VpSetZero(vp, sign);
- VpCtoV(vp, psz, ni, psz + ipf, nf, psz + ipe, ne);
+ VpCtoV(vp, &szVal[ipn], ni, &szVal[ipf], nf, &szVal[ipe], ne);
rb_str_resize(buf, 0);
return vp;
}
@@ -4886,7 +4754,7 @@ VpMult(Real *c, Real *a, Real *b)
if (MxIndC < MxIndAB) { /* The Max. prec. of c < Prec(a)+Prec(b) */
w = c;
- c = VpAlloc((size_t)((MxIndAB + 1) * BASE_FIG), "#0", 1, 1);
+ c = VpAlloc((size_t)((MxIndAB + 1) * BASE_FIG), "#0");
MxIndC = MxIndAB;
}
@@ -6054,8 +5922,8 @@ VpSqrt(Real *y, Real *x)
if (x->MaxPrec > (size_t)n) n = (ssize_t)x->MaxPrec;
/* allocate temporally variables */
- f = VpAlloc(y->MaxPrec * (BASE_FIG + 2), "#1", 1, 1);
- r = VpAlloc((n + n) * (BASE_FIG + 2), "#1", 1, 1);
+ f = VpAlloc(y->MaxPrec * (BASE_FIG + 2), "#1");
+ r = VpAlloc((n + n) * (BASE_FIG + 2), "#1");
nr = 0;
y_prec = y->MaxPrec;
@@ -6507,8 +6375,8 @@ VpPower(Real *y, Real *x, SIGNED_VALUE n)
/* Allocate working variables */
- w1 = VpAlloc((y->MaxPrec + 2) * BASE_FIG, "#0", 1, 1);
- w2 = VpAlloc((w1->MaxPrec * 2 + 1) * BASE_FIG, "#0", 1, 1);
+ w1 = VpAlloc((y->MaxPrec + 2) * BASE_FIG, "#0");
+ w2 = VpAlloc((w1->MaxPrec * 2 + 1) * BASE_FIG, "#0");
/* calculation start */
VpAsgn(y, x, 1);
diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
index 7d767f598b..c8c90870ea 100644
--- a/ext/bigdecimal/bigdecimal.gemspec
+++ b/ext/bigdecimal/bigdecimal.gemspec
@@ -1,6 +1,6 @@
# coding: utf-8
-bigdecimal_version = '2.0.0'
+bigdecimal_version = '1.3.4'
Gem::Specification.new do |s|
s.name = "bigdecimal"
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
bigdecimal.gemspec
ext/bigdecimal/bigdecimal.c
ext/bigdecimal/bigdecimal.h
- lib/bigdecimal.rb
+ ext/bigdecimal/depend
+ ext/bigdecimal/extconf.rb
lib/bigdecimal/jacobian.rb
lib/bigdecimal/ludcmp.rb
lib/bigdecimal/math.rb
@@ -30,10 +31,9 @@ Gem::Specification.new do |s|
sample/pi.rb
]
- s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
-
s.add_development_dependency "rake", "~> 10.0"
s.add_development_dependency "rake-compiler", ">= 0.9"
- s.add_development_dependency "minitest", "< 5.0.0"
+ s.add_development_dependency "rake-compiler-dock", ">= 0.6.1"
+ s.add_development_dependency "minitest", "~> 4.7.5"
s.add_development_dependency "pry"
end
diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h
index e3eae06e67..e53a752aa5 100644
--- a/ext/bigdecimal/bigdecimal.h
+++ b/ext/bigdecimal/bigdecimal.h
@@ -227,9 +227,7 @@ extern VALUE rb_cBigDecimal;
#define VP_SIGN_POSITIVE_INFINITE 3 /* Positive infinite number */
#define VP_SIGN_NEGATIVE_INFINITE -3 /* Negative infinite number */
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-#define FLEXIBLE_ARRAY_SIZE /* */
-#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#ifdef __GNUC__
#define FLEXIBLE_ARRAY_SIZE 0
#else
#define FLEXIBLE_ARRAY_SIZE 1
@@ -308,7 +306,7 @@ VP_EXPORT size_t VpInit(BDIGIT BaseVal);
VP_EXPORT void *VpMemAlloc(size_t mb);
VP_EXPORT void *VpMemRealloc(void *ptr, size_t mb);
VP_EXPORT void VpFree(Real *pv);
-VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal, int strict_p, int exc);
+VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal);
VP_EXPORT size_t VpAsgn(Real *c, Real *a, int isw);
VP_EXPORT size_t VpAddSub(Real *c,Real *a,Real *b,int operation);
VP_EXPORT size_t VpMult(Real *c,Real *a,Real *b);
diff --git a/ext/bigdecimal/depend b/ext/bigdecimal/depend
index ffd61b8960..6783192b30 100644
--- a/ext/bigdecimal/depend
+++ b/ext/bigdecimal/depend
@@ -1,10 +1,6 @@
-extconf.h: $(srcdir)/$(GEMSPEC)
-Makefile: $(BIGDECIMAL_RB)
-
# AUTOGENERATED DEPENDENCIES START
bigdecimal.o: $(RUBY_EXTCONF_H)
bigdecimal.o: $(arch_hdrdir)/ruby/config.h
-bigdecimal.o: $(hdrdir)/ruby/assert.h
bigdecimal.o: $(hdrdir)/ruby/defines.h
bigdecimal.o: $(hdrdir)/ruby/intern.h
bigdecimal.o: $(hdrdir)/ruby/missing.h
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index b4098fdacf..e565da891a 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -1,21 +1,6 @@
# frozen_string_literal: false
require 'mkmf'
-def check_bigdecimal_version(gemspec_path)
- message "checking RUBY_BIGDECIMAL_VERSION... "
-
- bigdecimal_version =
- IO.readlines(gemspec_path)
- .grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([^\']+)\'/, 1]
-
- version_components = bigdecimal_version.split('.')
- bigdecimal_version = version_components[0, 3].join('.')
- bigdecimal_version << "-#{version_components[3]}" if version_components[3]
- $defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
-
- message "#{bigdecimal_version}\n"
-end
-
gemspec_name = gemspec_path = nil
unless ['', '../../'].any? {|dir|
gemspec_name = "#{dir}bigdecimal.gemspec"
@@ -26,7 +11,13 @@ unless ['', '../../'].any? {|dir|
abort
end
-check_bigdecimal_version(gemspec_path)
+bigdecimal_version =
+ IO.readlines(gemspec_path)
+ .grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([\d\.]+)\'/, 1]
+
+$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
+
+alias __have_macro__ have_macro
have_func("labs", "stdlib.h")
have_func("llabs", "stdlib.h")
@@ -38,15 +29,7 @@ have_func("rb_rational_num", "ruby.h")
have_func("rb_rational_den", "ruby.h")
have_func("rb_array_const_ptr", "ruby.h")
have_func("rb_sym2str", "ruby.h")
-have_func("rb_opts_exception_p", "ruby.h")
-
-if File.file?(File.expand_path('../lib/bigdecimal.rb', __FILE__))
- bigdecimal_rb = "$(srcdir)/lib/bigdecimal.rb"
-else
- bigdecimal_rb = "$(srcdir)/../../lib/bigdecimal.rb"
-end
create_makefile('bigdecimal') {|mf|
- mf << "GEMSPEC = #{gemspec_name}\n"
- mf << "BIGDECIMAL_RB = #{bigdecimal_rb}\n"
+ mf << "\nall:\n\nextconf.h: $(srcdir)/#{gemspec_name}\n"
}
diff --git a/ext/bigdecimal/lib/bigdecimal.rb b/ext/bigdecimal/lib/bigdecimal.rb
deleted file mode 100644
index 8fd2587c84..0000000000
--- a/ext/bigdecimal/lib/bigdecimal.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'bigdecimal.so'
diff --git a/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
index 5e29304299..9cad06c09b 100644
--- a/ext/bigdecimal/lib/bigdecimal/jacobian.rb
+++ b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: false
-
-require 'bigdecimal'
-
+#
# require 'bigdecimal/jacobian'
#
# Provides methods to compute the Jacobian matrix of a set of equations at a
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
index 4ece8347bd..911fa6fe3a 100644
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -5,7 +5,6 @@
# and provides BigDecimal#to_d and BigDecimal#to_digits.
#++
-require 'bigdecimal'
class Integer < Numeric
# call-seq:
@@ -43,8 +42,8 @@ class Float < Numeric
#
# See also BigDecimal::new.
#
- def to_d(precision=Float::DIG)
- BigDecimal(self, precision)
+ def to_d(precision=nil)
+ BigDecimal(self, precision || Float::DIG)
end
end
@@ -66,7 +65,11 @@ class String
# See also BigDecimal::new.
#
def to_d
- BigDecimal.interpret_loosely(self)
+ begin
+ BigDecimal(self)
+ rescue ArgumentError
+ BigDecimal(0)
+ end
end
end
@@ -129,20 +132,3 @@ class Rational < Numeric
BigDecimal(self, precision)
end
end
-
-
-class NilClass
- # call-seq:
- # nil.to_d -> bigdecimal
- #
- # Returns nil represented as a BigDecimal.
- #
- # require 'bigdecimal'
- # require 'bigdecimal/util'
- #
- # nil.to_d # => 0.0
- #
- def to_d
- BigDecimal(0)
- end
-end
diff --git a/ext/bigdecimal/sample/linear.rb b/ext/bigdecimal/sample/linear.rb
index 516c2473be..3b23269f8a 100644
--- a/ext/bigdecimal/sample/linear.rb
+++ b/ext/bigdecimal/sample/linear.rb
@@ -28,8 +28,8 @@ def rd_order(na)
end
na = ARGV.size
-zero = BigDecimal("0.0")
-one = BigDecimal("1.0")
+zero = BigDecimal.new("0.0")
+one = BigDecimal.new("1.0")
while (n=rd_order(na))>0
a = []
@@ -37,28 +37,27 @@ while (n=rd_order(na))>0
b = []
if na <= 0
# Read data from console.
- printf("\nEnter coefficient matrix element A[i,j]\n")
+ printf("\nEnter coefficient matrix element A[i,j]\n");
for i in 0...n do
for j in 0...n do
printf("A[%d,%d]? ",i,j); s = ARGF.gets
- a << BigDecimal(s)
- as << BigDecimal(s)
+ a << BigDecimal.new(s);
+ as << BigDecimal.new(s);
end
- printf("Contatant vector element b[%d] ? ",i)
- b << BigDecimal(ARGF.gets)
+ printf("Contatant vector element b[%d] ? ",i); b << BigDecimal.new(ARGF.gets);
end
else
# Read data from specified file.
- printf("Coefficient matrix and constant vector.\n")
+ printf("Coefficient matrix and constant vector.\n");
for i in 0...n do
s = ARGF.gets
printf("%d) %s",i,s)
s = s.split
for j in 0...n do
- a << BigDecimal(s[j])
- as << BigDecimal(s[j])
+ a << BigDecimal.new(s[j]);
+ as << BigDecimal.new(s[j]);
end
- b << BigDecimal(s[n])
+ b << BigDecimal.new(s[n]);
end
end
x = lusolve(a,b,ludecomp(a,n,zero,one),zero)
diff --git a/ext/bigdecimal/sample/nlsolve.rb b/ext/bigdecimal/sample/nlsolve.rb
index c2227dac73..b1dd08e0a3 100644
--- a/ext/bigdecimal/sample/nlsolve.rb
+++ b/ext/bigdecimal/sample/nlsolve.rb
@@ -12,11 +12,11 @@ include Newton
class Function # :nodoc: all
def initialize()
- @zero = BigDecimal("0.0")
- @one = BigDecimal("1.0")
- @two = BigDecimal("2.0")
- @ten = BigDecimal("10.0")
- @eps = BigDecimal("1.0e-16")
+ @zero = BigDecimal.new("0.0")
+ @one = BigDecimal.new("1.0")
+ @two = BigDecimal.new("2.0")
+ @ten = BigDecimal.new("10.0")
+ @eps = BigDecimal.new("1.0e-16")
end
def zero;@zero;end
def one ;@one ;end
diff --git a/ext/bigdecimal/util/depend b/ext/bigdecimal/util/depend
deleted file mode 100644
index 96b6a7fea0..0000000000
--- a/ext/bigdecimal/util/depend
+++ /dev/null
@@ -1,14 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-util.o: $(RUBY_EXTCONF_H)
-util.o: $(arch_hdrdir)/ruby/config.h
-util.o: $(hdrdir)/ruby.h
-util.o: $(hdrdir)/ruby/assert.h
-util.o: $(hdrdir)/ruby/backward.h
-util.o: $(hdrdir)/ruby/defines.h
-util.o: $(hdrdir)/ruby/intern.h
-util.o: $(hdrdir)/ruby/missing.h
-util.o: $(hdrdir)/ruby/ruby.h
-util.o: $(hdrdir)/ruby/st.h
-util.o: $(hdrdir)/ruby/subst.h
-util.o: util.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/cgi/escape/depend b/ext/cgi/escape/depend
index 8d4736616f..099bb3f14b 100644
--- a/ext/cgi/escape/depend
+++ b/ext/cgi/escape/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
escape.o: $(RUBY_EXTCONF_H)
escape.o: $(arch_hdrdir)/ruby/config.h
-escape.o: $(hdrdir)/ruby.h
-escape.o: $(hdrdir)/ruby/assert.h
escape.o: $(hdrdir)/ruby/backward.h
escape.o: $(hdrdir)/ruby/defines.h
escape.o: $(hdrdir)/ruby/encoding.h
@@ -13,5 +11,6 @@ escape.o: $(hdrdir)/ruby/oniguruma.h
escape.o: $(hdrdir)/ruby/ruby.h
escape.o: $(hdrdir)/ruby/st.h
escape.o: $(hdrdir)/ruby/subst.h
+escape.o: $(top_srcdir)/include/ruby.h
escape.o: escape.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/cgi/escape/escape.c b/ext/cgi/escape/escape.c
index feedea34c8..ced1b182eb 100644
--- a/ext/cgi/escape/escape.c
+++ b/ext/cgi/escape/escape.c
@@ -11,59 +11,73 @@ RUBY_EXTERN const signed char ruby_digit36_to_number_table[];
static VALUE rb_cCGI, rb_mUtil, rb_mEscape;
static ID id_accept_charset;
-#define HTML_ESCAPE_MAX_LEN 6
-
-static const struct {
- uint8_t len;
- char str[HTML_ESCAPE_MAX_LEN+1];
-} html_escape_table[UCHAR_MAX+1] = {
-#define HTML_ESCAPE(c, str) [c] = {rb_strlen_lit(str), str}
- HTML_ESCAPE('\'', "&#39;"),
- HTML_ESCAPE('&', "&amp;"),
- HTML_ESCAPE('"', "&quot;"),
- HTML_ESCAPE('<', "&lt;"),
- HTML_ESCAPE('>', "&gt;"),
-#undef HTML_ESCAPE
-};
+static void
+html_escaped_cat(VALUE str, char c)
+{
+ switch (c) {
+ case '\'':
+ rb_str_cat_cstr(str, "&#39;");
+ break;
+ case '&':
+ rb_str_cat_cstr(str, "&amp;");
+ break;
+ case '"':
+ rb_str_cat_cstr(str, "&quot;");
+ break;
+ case '<':
+ rb_str_cat_cstr(str, "&lt;");
+ break;
+ case '>':
+ rb_str_cat_cstr(str, "&gt;");
+ break;
+ }
+}
static inline void
preserve_original_state(VALUE orig, VALUE dest)
{
rb_enc_associate(dest, rb_enc_get(orig));
+
+ RB_OBJ_INFECT_RAW(dest, orig);
}
static VALUE
optimized_escape_html(VALUE str)
{
- VALUE vbuf;
- typedef char escape_buf[HTML_ESCAPE_MAX_LEN];
- char *buf = *ALLOCV_N(escape_buf, vbuf, RSTRING_LEN(str));
- const char *cstr = RSTRING_PTR(str);
- const char *end = cstr + RSTRING_LEN(str);
-
- char *dest = buf;
- while (cstr < end) {
- const unsigned char c = *cstr++;
- uint8_t len = html_escape_table[c].len;
- if (len) {
- memcpy(dest, html_escape_table[c].str, len);
- dest += len;
- }
- else {
- *dest++ = c;
- }
+ long i, len, beg = 0;
+ VALUE dest = 0;
+ const char *cstr;
+
+ len = RSTRING_LEN(str);
+ cstr = RSTRING_PTR(str);
+
+ for (i = 0; i < len; i++) {
+ switch (cstr[i]) {
+ case '\'':
+ case '&':
+ case '"':
+ case '<':
+ case '>':
+ if (!dest) {
+ dest = rb_str_buf_new(len);
+ }
+
+ rb_str_cat(dest, cstr + beg, i - beg);
+ beg = i + 1;
+
+ html_escaped_cat(dest, cstr[i]);
+ break;
+ }
}
- VALUE escaped;
- if (RSTRING_LEN(str) < (dest - buf)) {
- escaped = rb_str_new(buf, dest - buf);
- preserve_original_state(str, escaped);
+ if (dest) {
+ rb_str_cat(dest, cstr + beg, len - beg);
+ preserve_original_state(str, dest);
+ return dest;
}
else {
- escaped = rb_str_dup(str);
+ return rb_str_dup(str);
}
- ALLOCV_END(vbuf);
- return escaped;
}
static VALUE
diff --git a/ext/continuation/depend b/ext/continuation/depend
index 08844aa6bb..9e47f27f3a 100644
--- a/ext/continuation/depend
+++ b/ext/continuation/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
continuation.o: $(RUBY_EXTCONF_H)
continuation.o: $(arch_hdrdir)/ruby/config.h
-continuation.o: $(hdrdir)/ruby/assert.h
continuation.o: $(hdrdir)/ruby/backward.h
continuation.o: $(hdrdir)/ruby/defines.h
continuation.o: $(hdrdir)/ruby/intern.h
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index 8503c9d6c6..f46955aae2 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -45,16 +45,13 @@ rb_coverage_start(int argc, VALUE *argv, VALUE klass)
mode |= COVERAGE_TARGET_BRANCHES;
if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("methods")))))
mode |= COVERAGE_TARGET_METHODS;
- if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("oneshot_lines"))))) {
- if (mode & COVERAGE_TARGET_LINES)
- rb_raise(rb_eRuntimeError, "cannot enable lines and oneshot_lines simultaneously");
- mode |= COVERAGE_TARGET_LINES;
- mode |= COVERAGE_TARGET_ONESHOT_LINES;
- }
+ if (mode == 0) {
+ rb_raise(rb_eRuntimeError, "no measuring target is specified");
+ }
}
if (mode & COVERAGE_TARGET_METHODS) {
- me2counter = rb_ident_hash_new();
+ me2counter = rb_hash_new_compare_by_id();
}
else {
me2counter = Qnil;
@@ -182,10 +179,9 @@ coverage_peek_result_i(st_data_t key, st_data_t val, st_data_t h)
if (current_mode & COVERAGE_TARGET_LINES) {
VALUE lines = RARRAY_AREF(coverage, COVERAGE_INDEX_LINES);
- const char *kw = (current_mode & COVERAGE_TARGET_ONESHOT_LINES) ? "oneshot_lines" : "lines";
lines = rb_ary_dup(lines);
rb_ary_freeze(lines);
- rb_hash_aset(h, ID2SYM(rb_intern(kw)), lines);
+ rb_hash_aset(h, ID2SYM(rb_intern("lines")), lines);
}
if (current_mode & COVERAGE_TARGET_BRANCHES) {
@@ -209,7 +205,6 @@ coverage_peek_result_i(st_data_t key, st_data_t val, st_data_t h)
* Coverage.peek_result => hash
*
* Returns a hash that contains filename as key and coverage array as value.
- * This is the same as `Coverage.result(stop: false, clear: false)`.
*
* {
* "file.rb" => [1, 2, nil],
@@ -234,54 +229,22 @@ rb_coverage_peek_result(VALUE klass)
return ncoverages;
}
-
-static int
-clear_me2counter_i(VALUE key, VALUE value, VALUE unused)
-{
- rb_hash_aset(me2counter, key, INT2FIX(0));
- return ST_CONTINUE;
-}
-
/*
* call-seq:
- * Coverage.result(stop: true, clear: true) => hash
+ * Coverage.result => hash
*
- * Returns a hash that contains filename as key and coverage array as value.
- * If +clear+ is true, it clears the counters to zero.
- * If +stop+ is true, it disables coverage measurement.
+ * Returns a hash that contains filename as key and coverage array as value
+ * and disables coverage measurement.
*/
static VALUE
-rb_coverage_result(int argc, VALUE *argv, VALUE klass)
+rb_coverage_result(VALUE klass)
{
- VALUE ncoverages;
- VALUE opt;
- int stop = 1, clear = 1;
-
- rb_scan_args(argc, argv, "01", &opt);
-
- if (argc == 1) {
- opt = rb_convert_type(opt, T_HASH, "Hash", "to_hash");
- stop = RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("stop"))));
- clear = RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("clear"))));
- }
-
- ncoverages = rb_coverage_peek_result(klass);
- if (stop && !clear) {
- rb_warn("stop implies clear");
- clear = 1;
- }
- if (clear) {
- rb_clear_coverages();
- if (!NIL_P(me2counter)) rb_hash_foreach(me2counter, clear_me2counter_i, Qnil);
- }
- if (stop) {
- rb_reset_coverages();
- me2counter = Qnil;
- }
+ VALUE ncoverages = rb_coverage_peek_result(klass);
+ rb_reset_coverages();
+ me2counter = Qnil;
return ncoverages;
}
-
/*
* call-seq:
* Coverage.running? => bool
@@ -334,7 +297,7 @@ Init_coverage(void)
{
VALUE rb_mCoverage = rb_define_module("Coverage");
rb_define_module_function(rb_mCoverage, "start", rb_coverage_start, -1);
- rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, -1);
+ rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, 0);
rb_define_module_function(rb_mCoverage, "peek_result", rb_coverage_peek_result, 0);
rb_define_module_function(rb_mCoverage, "running?", rb_coverage_running, 0);
rb_global_variable(&me2counter);
diff --git a/ext/coverage/depend b/ext/coverage/depend
index 20b76be04c..b6871fc9cb 100644
--- a/ext/coverage/depend
+++ b/ext/coverage/depend
@@ -1,12 +1,26 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(top_srcdir)/vm_core.h \
+ $(top_srcdir)/node.h \
+ $(top_srcdir)/vm_debug.h \
+ $(top_srcdir)/vm_opts.h \
+ {$(VPATH)}id.h \
+ $(top_srcdir)/method.h \
+ $(top_srcdir)/ruby_atomic.h \
+ $(top_srcdir)/thread_pthread.h \
+ $(top_srcdir)/internal.h \
+ $(top_srcdir)/include/ruby/thread_native.h
+
# AUTOGENERATED DEPENDENCIES START
coverage.o: $(RUBY_EXTCONF_H)
coverage.o: $(arch_hdrdir)/ruby/config.h
-coverage.o: $(hdrdir)/ruby.h
-coverage.o: $(hdrdir)/ruby/assert.h
coverage.o: $(hdrdir)/ruby/backward.h
coverage.o: $(hdrdir)/ruby/defines.h
+coverage.o: $(hdrdir)/ruby/encoding.h
coverage.o: $(hdrdir)/ruby/intern.h
+coverage.o: $(hdrdir)/ruby/io.h
coverage.o: $(hdrdir)/ruby/missing.h
+coverage.o: $(hdrdir)/ruby/onigmo.h
+coverage.o: $(hdrdir)/ruby/oniguruma.h
coverage.o: $(hdrdir)/ruby/ruby.h
coverage.o: $(hdrdir)/ruby/st.h
coverage.o: $(hdrdir)/ruby/subst.h
@@ -15,7 +29,7 @@ coverage.o: $(top_srcdir)/ccan/check_type/check_type.h
coverage.o: $(top_srcdir)/ccan/container_of/container_of.h
coverage.o: $(top_srcdir)/ccan/list/list.h
coverage.o: $(top_srcdir)/ccan/str/str.h
-coverage.o: $(top_srcdir)/gc.h
+coverage.o: $(top_srcdir)/include/ruby.h
coverage.o: $(top_srcdir)/internal.h
coverage.o: $(top_srcdir)/method.h
coverage.o: $(top_srcdir)/node.h
@@ -23,6 +37,7 @@ coverage.o: $(top_srcdir)/ruby_assert.h
coverage.o: $(top_srcdir)/ruby_atomic.h
coverage.o: $(top_srcdir)/thread_pthread.h
coverage.o: $(top_srcdir)/vm_core.h
+coverage.o: $(top_srcdir)/vm_debug.h
coverage.o: $(top_srcdir)/vm_opts.h
coverage.o: coverage.c
coverage.o: {$(VPATH)}id.h
diff --git a/ext/coverage/lib/coverage.rb b/ext/coverage/lib/coverage.rb
deleted file mode 100644
index f1923ef366..0000000000
--- a/ext/coverage/lib/coverage.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require "coverage.so"
-
-module Coverage
- def self.line_stub(file)
- lines = File.foreach(file).map { nil }
- iseqs = [RubyVM::InstructionSequence.compile_file(file)]
- until iseqs.empty?
- iseq = iseqs.pop
- iseq.trace_points.each {|n, type| lines[n - 1] = 0 if type == :line }
- iseq.each_child {|child| iseqs << child }
- end
- lines
- end
-end
diff --git a/ext/date/date.gemspec b/ext/date/date.gemspec
index 847cd0b295..9d5de998b7 100644
--- a/ext/date/date.gemspec
+++ b/ext/date/date.gemspec
@@ -1,12 +1,8 @@
# frozen_string_literal: true
-
-version = File.foreach(File.expand_path("../lib/date.rb", __FILE__)).find do |line|
- /^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1
-end
-
Gem::Specification.new do |s|
s.name = "date"
- s.version = version
+ s.version = '1.0.0'
+ s.date = '2017-12-11'
s.summary = "A subclass of Object includes Comparable module for handling dates."
s.description = "A subclass of Object includes Comparable module for handling dates."
@@ -23,4 +19,6 @@ Gem::Specification.new do |s|
s.email = [nil]
s.homepage = "https://github.com/ruby/date"
s.license = "BSD-2-Clause"
+
+ s.add_development_dependency "rake-compiler"
end
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 3917f3e38b..c250633426 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -11,7 +11,6 @@
#include <sys/time.h>
#endif
-#undef NDEBUG
#define NDEBUG
#include <assert.h>
@@ -23,7 +22,6 @@
static ID id_cmp, id_le_p, id_ge_p, id_eqeq_p;
static VALUE cDate, cDateTime;
-static VALUE eDateError;
static VALUE half_days_in_day, day_in_nanoseconds;
static double positive_inf, negative_inf;
@@ -53,17 +51,6 @@ static double positive_inf, negative_inf;
#define f_add3(x,y,z) f_add(f_add(x, y), z)
#define f_sub3(x,y,z) f_sub(f_sub(x, y), z)
-static VALUE date_initialize(int argc, VALUE *argv, VALUE self);
-static VALUE datetime_initialize(int argc, VALUE *argv, VALUE self);
-
-#define RETURN_FALSE_UNLESS_NUMERIC(obj) if(!RTEST(rb_obj_is_kind_of((obj), rb_cNumeric))) return Qfalse
-inline static void
-check_numeric(VALUE obj, const char* field) {
- if(!RTEST(rb_obj_is_kind_of(obj, rb_cNumeric))) {
- rb_raise(rb_eTypeError, "invalid %s (not numeric)", field);
- }
-}
-
inline static int
f_cmp(VALUE x, VALUE y)
{
@@ -107,7 +94,7 @@ f_ge_p(VALUE x, VALUE y)
{
if (FIXNUM_P(x) && FIXNUM_P(y))
return f_boolcast(FIX2LONG(x) >= FIX2LONG(y));
- return rb_funcall(x, id_ge_p, 1, y);
+ return rb_funcall(x, rb_intern(">="), 1, y);
}
inline static VALUE
@@ -115,7 +102,7 @@ f_eqeq_p(VALUE x, VALUE y)
{
if (FIXNUM_P(x) && FIXNUM_P(y))
return f_boolcast(FIX2LONG(x) == FIX2LONG(y));
- return rb_funcall(x, id_eqeq_p, 1, y);
+ return rb_funcall(x, rb_intern("=="), 1, y);
}
inline static VALUE
@@ -249,8 +236,11 @@ f_negative_p(VALUE x)
struct SimpleDateData
{
unsigned flags;
- int jd; /* as utc */
VALUE nth; /* not always canonicalized */
+ int jd; /* as utc */
+ /* df is zero */
+ /* sf is zero */
+ /* of is zero */
date_sg_t sg; /* 2298874..2426355 or -/+oo -- at most 22 bits */
/* decoded as utc=local */
int year; /* truncated */
@@ -269,8 +259,11 @@ struct SimpleDateData
struct ComplexDateData
{
unsigned flags;
- int jd; /* as utc */
VALUE nth; /* not always canonicalized */
+ int jd; /* as utc */
+ int df; /* as utc, in secs */
+ VALUE sf; /* in nano secs */
+ int of; /* in secs */
date_sg_t sg; /* 2298874..2426355 or -/+oo -- at most 22 bits */
/* decoded as local */
int year; /* truncated */
@@ -284,9 +277,6 @@ struct ComplexDateData
/* packed civil */
unsigned pc;
#endif
- int df; /* as utc, in secs */
- int of; /* in secs */
- VALUE sf; /* in nano secs */
};
union DateData {
@@ -325,31 +315,31 @@ canon(VALUE x)
#ifndef USE_PACK
#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
(x)->jd = _jd;\
(x)->sg = (date_sg_t)(_sg);\
(x)->year = _year;\
(x)->mon = _mon;\
(x)->mday = _mday;\
- (x)->flags = (_flags) & ~COMPLEX_DAT;\
-} while (0)
+ (x)->flags = _flags;\
+}
#else
#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
(x)->jd = _jd;\
(x)->sg = (date_sg_t)(_sg);\
(x)->year = _year;\
(x)->pc = PACK2(_mon, _mday);\
- (x)->flags = (_flags) & ~COMPLEX_DAT;\
-} while (0)
+ (x)->flags = _flags;\
+}
#endif
#ifndef USE_PACK
#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
_year, _mon, _mday, _hour, _min, _sec, _flags) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
(x)->jd = _jd;\
(x)->df = _df;\
@@ -362,12 +352,12 @@ do {\
(x)->hour = _hour;\
(x)->min = _min;\
(x)->sec = _sec;\
- (x)->flags = (_flags) | COMPLEX_DAT;\
-} while (0)
+ (x)->flags = _flags;\
+}
#else
#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
_year, _mon, _mday, _hour, _min, _sec, _flags) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
(x)->jd = _jd;\
(x)->df = _df;\
@@ -376,13 +366,13 @@ do {\
(x)->sg = (date_sg_t)(_sg);\
(x)->year = _year;\
(x)->pc = PACK5(_mon, _mday, _hour, _min, _sec);\
- (x)->flags = (_flags) | COMPLEX_DAT;\
-} while (0)
+ (x)->flags = _flags;\
+}
#endif
#ifndef USE_PACK
#define copy_simple_to_complex(obj, x, y) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->df = 0;\
@@ -396,10 +386,10 @@ do {\
(x)->min = 0;\
(x)->sec = 0;\
(x)->flags = (y)->flags;\
-} while (0)
+}
#else
#define copy_simple_to_complex(obj, x, y) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->df = 0;\
@@ -409,12 +399,12 @@ do {\
(x)->year = (y)->year;\
(x)->pc = PACK5(EX_MON((y)->pc), EX_MDAY((y)->pc), 0, 0, 0);\
(x)->flags = (y)->flags;\
-} while (0)
+}
#endif
#ifndef USE_PACK
#define copy_complex_to_simple(obj, x, y) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->sg = (date_sg_t)((y)->sg);\
@@ -422,17 +412,17 @@ do {\
(x)->mon = (y)->mon;\
(x)->mday = (y)->mday;\
(x)->flags = (y)->flags;\
-} while (0)
+}
#else
#define copy_complex_to_simple(obj, x, y) \
-do {\
+{\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->sg = (date_sg_t)((y)->sg);\
(x)->year = (y)->year;\
(x)->pc = PACK2(EX_MON((y)->pc), EX_MDAY((y)->pc));\
(x)->flags = (y)->flags;\
-} while (0)
+}
#endif
/* base */
@@ -1119,7 +1109,7 @@ m_virtual_sg(union DateData *x)
}
#define canonicalize_jd(_nth, _jd) \
-do {\
+{\
if (_jd < 0) {\
_nth = f_sub(_nth, INT2FIX(1));\
_jd += CM_PERIOD;\
@@ -1128,7 +1118,7 @@ do {\
_nth = f_add(_nth, INT2FIX(1));\
_jd -= CM_PERIOD;\
}\
-} while (0)
+}
inline static void
canonicalize_s_jd(VALUE obj, union DateData *x)
@@ -1938,13 +1928,13 @@ m_sec(union DateData *x)
}
#define decode_offset(of,s,h,m)\
-do {\
+{\
int a;\
s = (of < 0) ? '-' : '+';\
a = (of < 0) ? -of : of;\
h = a / HOUR_IN_SECONDS;\
m = a % HOUR_IN_SECONDS / MINUTE_IN_SECONDS;\
-} while (0)
+}
static VALUE
of2str(int of)
@@ -2343,9 +2333,6 @@ VALUE date_zone_to_diff(VALUE);
static int
offset_to_sec(VALUE vof, int *rof)
{
- int try_rational = 1;
-
- again:
switch (TYPE(vof)) {
case T_FIXNUM:
{
@@ -2372,11 +2359,10 @@ offset_to_sec(VALUE vof, int *rof)
default:
expect_numeric(vof);
vof = f_to_r(vof);
- if (!k_rational_p(vof)) {
- if (!try_rational) Check_Type(vof, T_RATIONAL);
- try_rational = 0;
- goto again;
- }
+#ifdef CANONICALIZATION_FOR_MATHN
+ if (!k_rational_p(vof))
+ return offset_to_sec(vof, rof);
+#endif
/* fall through */
case T_RATIONAL:
{
@@ -2385,10 +2371,17 @@ offset_to_sec(VALUE vof, int *rof)
vs = day_to_sec(vof);
+#ifdef CANONICALIZATION_FOR_MATHN
if (!k_rational_p(vs)) {
- vn = vs;
- goto rounded;
+ if (!FIXNUM_P(vs))
+ return 0;
+ n = FIX2LONG(vs);
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ *rof = (int)n;
+ return 1;
}
+#endif
vn = rb_rational_num(vs);
vd = rb_rational_den(vs);
@@ -2398,7 +2391,6 @@ offset_to_sec(VALUE vof, int *rof)
vn = f_round(vs);
if (!f_eqeq_p(vn, vs))
rb_warning("fraction of offset is ignored");
- rounded:
if (!FIXNUM_P(vn))
return 0;
n = FIX2LONG(vn);
@@ -2428,12 +2420,12 @@ offset_to_sec(VALUE vof, int *rof)
/* date */
#define valid_sg(sg) \
-do {\
+{\
if (!c_valid_start_p(sg)) {\
sg = 0;\
rb_warning("invalid start is ignored");\
}\
-} while (0)
+}
static VALUE
valid_jd_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
@@ -2480,7 +2472,6 @@ date_s_valid_jd_p(int argc, VALUE *argv, VALUE klass)
rb_scan_args(argc, argv, "11", &vjd, &vsg);
- RETURN_FALSE_UNLESS_NUMERIC(vjd);
argv2[0] = vjd;
if (argc < 2)
argv2[1] = INT2FIX(DEFAULT_SG);
@@ -2556,12 +2547,9 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
* Date.valid_date?(year, month, mday[, start=Date::ITALY]) -> bool
*
* Returns true if the given calendar date is valid, and false if not.
- * Valid in this context is whether the arguments passed to this
- * method would be accepted by ::new.
*
* Date.valid_date?(2001,2,3) #=> true
* Date.valid_date?(2001,2,29) #=> false
- * Date.valid_date?(2001,2,-1) #=> true
*
* See also ::jd and ::civil.
*/
@@ -2573,9 +2561,6 @@ date_s_valid_civil_p(int argc, VALUE *argv, VALUE klass)
rb_scan_args(argc, argv, "31", &vy, &vm, &vd, &vsg);
- RETURN_FALSE_UNLESS_NUMERIC(vy);
- RETURN_FALSE_UNLESS_NUMERIC(vm);
- RETURN_FALSE_UNLESS_NUMERIC(vd);
argv2[0] = vy;
argv2[1] = vm;
argv2[2] = vd;
@@ -2657,8 +2642,6 @@ date_s_valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
rb_scan_args(argc, argv, "21", &vy, &vd, &vsg);
- RETURN_FALSE_UNLESS_NUMERIC(vy);
- RETURN_FALSE_UNLESS_NUMERIC(vd);
argv2[0] = vy;
argv2[1] = vd;
if (argc < 3)
@@ -2741,9 +2724,6 @@ date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)
rb_scan_args(argc, argv, "31", &vy, &vw, &vd, &vsg);
- RETURN_FALSE_UNLESS_NUMERIC(vy);
- RETURN_FALSE_UNLESS_NUMERIC(vw);
- RETURN_FALSE_UNLESS_NUMERIC(vd);
argv2[0] = vy;
argv2[1] = vw;
argv2[2] = vd;
@@ -2925,7 +2905,6 @@ date_s_julian_leap_p(VALUE klass, VALUE y)
VALUE nth;
int ry;
- check_numeric(y, "year");
decode_year(y, +1, &nth, &ry);
return f_boolcast(c_julian_leap_p(ry));
}
@@ -2947,7 +2926,6 @@ date_s_gregorian_leap_p(VALUE klass, VALUE y)
VALUE nth;
int ry;
- check_numeric(y, "year");
decode_year(y, -1, &nth, &ry);
return f_boolcast(c_gregorian_leap_p(ry));
}
@@ -2990,7 +2968,7 @@ d_simple_new_internal(VALUE klass,
obj = TypedData_Make_Struct(klass, struct SimpleDateData,
&d_lite_type, dat);
- set_to_simple(obj, dat, nth, jd, sg, y, m, d, flags);
+ set_to_simple(obj, dat, nth, jd, sg, y, m, d, flags & ~COMPLEX_DAT);
assert(have_jd_p(dat) || have_civil_p(dat));
@@ -3012,7 +2990,7 @@ d_complex_new_internal(VALUE klass,
obj = TypedData_Make_Struct(klass, struct ComplexDateData,
&d_lite_type, dat);
set_to_complex(obj, dat, nth, jd, df, sf, of, sg,
- y, m, d, h, min, s, flags);
+ y, m, d, h, min, s, flags | COMPLEX_DAT);
assert(have_jd_p(dat) || have_civil_p(dat));
assert(have_df_p(dat) || have_time_p(dat));
@@ -3071,7 +3049,7 @@ old_to_new(VALUE ajd, VALUE of, VALUE sg,
*rsg = NUM2DBL(sg);
if (*rdf < 0 || *rdf >= DAY_IN_SECONDS)
- rb_raise(eDateError, "invalid day fraction");
+ rb_raise(rb_eArgError, "invalid day fraction");
if (f_lt_p(*rsf, INT2FIX(0)) ||
f_ge_p(*rsf, INT2FIX(SECOND_IN_NANOSECONDS)))
@@ -3229,47 +3207,47 @@ s_trunc(VALUE s, VALUE *fr)
}
#define num2num_with_frac(s,n) \
-do {\
+{\
s = s##_trunc(v##s, &fr);\
if (f_nonzero_p(fr)) {\
if (argc > n)\
- rb_raise(eDateError, "invalid fraction");\
+ rb_raise(rb_eArgError, "invalid fraction");\
fr2 = fr;\
}\
-} while (0)
+}
#define num2int_with_frac(s,n) \
-do {\
+{\
s = NUM2INT(s##_trunc(v##s, &fr));\
if (f_nonzero_p(fr)) {\
if (argc > n)\
- rb_raise(eDateError, "invalid fraction");\
+ rb_raise(rb_eArgError, "invalid fraction");\
fr2 = fr;\
}\
-} while (0)
+}
#define canon24oc() \
-do {\
+{\
if (rh == 24) {\
rh = 0;\
fr2 = f_add(fr2, INT2FIX(1));\
}\
-} while (0)
+}
#define add_frac() \
-do {\
+{\
if (f_nonzero_p(fr2))\
ret = d_lite_plus(ret, fr2);\
-} while (0)
+}
#define val2sg(vsg,dsg) \
-do {\
+{\
dsg = NUM2DBL(vsg);\
if (!c_valid_start_p(dsg)) {\
dsg = DEFAULT_SG;\
rb_warning("invalid start is ignored");\
}\
-} while (0)
+}
static VALUE d_lite_plus(VALUE, VALUE);
@@ -3302,7 +3280,6 @@ date_s_jd(int argc, VALUE *argv, VALUE klass)
case 2:
val2sg(vsg, sg);
case 1:
- check_numeric(vjd, "jd");
num2num_with_frac(jd, positive_inf);
}
@@ -3355,10 +3332,8 @@ date_s_ordinal(int argc, VALUE *argv, VALUE klass)
case 3:
val2sg(vsg, sg);
case 2:
- check_numeric(vd, "yday");
num2int_with_frac(d, positive_inf);
case 1:
- check_numeric(vy, "year");
y = vy;
}
@@ -3370,7 +3345,7 @@ date_s_ordinal(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
ret = d_simple_new_internal(klass,
nth, rjd,
@@ -3410,20 +3385,9 @@ date_s_ordinal(int argc, VALUE *argv, VALUE klass)
static VALUE
date_s_civil(int argc, VALUE *argv, VALUE klass)
{
- return date_initialize(argc, argv, d_lite_s_alloc_simple(klass));
-}
-
-static VALUE
-date_initialize(int argc, VALUE *argv, VALUE self)
-{
VALUE vy, vm, vd, vsg, y, fr, fr2, ret;
int m, d;
double sg;
- struct SimpleDateData *dat = rb_check_typeddata(self, &d_lite_type);
-
- if (!simple_dat_p(dat)) {
- rb_raise(rb_eTypeError, "Date expected");
- }
rb_scan_args(argc, argv, "04", &vy, &vm, &vd, &vsg);
@@ -3437,13 +3401,10 @@ date_initialize(int argc, VALUE *argv, VALUE self)
case 4:
val2sg(vsg, sg);
case 3:
- check_numeric(vd, "day");
num2int_with_frac(d, positive_inf);
case 2:
- check_numeric(vm, "month");
m = NUM2INT(vm);
case 1:
- check_numeric(vy, "year");
y = vy;
}
@@ -3454,9 +3415,13 @@ date_initialize(int argc, VALUE *argv, VALUE self)
if (!valid_gregorian_p(y, m, d,
&nth, &ry,
&rm, &rd))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
- set_to_simple(self, dat, nth, 0, sg, ry, rm, rd, HAVE_CIVIL);
+ ret = d_simple_new_internal(klass,
+ nth, 0,
+ sg,
+ ry, rm, rd,
+ HAVE_CIVIL);
}
else {
VALUE nth;
@@ -3466,11 +3431,14 @@ date_initialize(int argc, VALUE *argv, VALUE self)
&nth, &ry,
&rm, &rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
- set_to_simple(self, dat, nth, rjd, sg, ry, rm, rd, HAVE_JD | HAVE_CIVIL);
+ ret = d_simple_new_internal(klass,
+ nth, rjd,
+ sg,
+ ry, rm, rd,
+ HAVE_JD | HAVE_CIVIL);
}
- ret = self;
add_frac();
return ret;
}
@@ -3510,13 +3478,10 @@ date_s_commercial(int argc, VALUE *argv, VALUE klass)
case 4:
val2sg(vsg, sg);
case 3:
- check_numeric(vd, "cwday");
num2int_with_frac(d, positive_inf);
case 2:
- check_numeric(vw, "cweek");
w = NUM2INT(vw);
case 1:
- check_numeric(vy, "year");
y = vy;
}
@@ -3528,7 +3493,7 @@ date_s_commercial(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rw, &rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
ret = d_simple_new_internal(klass,
nth, rjd,
@@ -3578,7 +3543,7 @@ date_s_weeknum(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rw, &rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
ret = d_simple_new_internal(klass,
nth, rjd,
@@ -3627,7 +3592,7 @@ date_s_nth_kday(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rm, &rn, &rk, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
ret = d_simple_new_internal(klass,
nth, rjd,
@@ -3714,18 +3679,16 @@ date_s_today(int argc, VALUE *argv, VALUE klass)
#define ref_hash0(k) rb_hash_aref(hash, k)
#define del_hash0(k) rb_hash_delete(hash, k)
-#define sym(x) ID2SYM(rb_intern(x""))
-
-#define set_hash(k,v) set_hash0(sym(k), v)
-#define ref_hash(k) ref_hash0(sym(k))
-#define del_hash(k) del_hash0(sym(k))
+#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
+#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
+#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
static VALUE
rt_rewrite_frags(VALUE hash)
{
VALUE seconds;
- seconds = del_hash("seconds");
+ seconds = ref_hash("seconds");
if (!NIL_P(seconds)) {
VALUE offset, d, h, min, s, fr;
@@ -3750,10 +3713,13 @@ rt_rewrite_frags(VALUE hash)
set_hash("min", min);
set_hash("sec", s);
set_hash("sec_fraction", fr);
+ del_hash("seconds");
}
return hash;
}
+#define sym(x) ID2SYM(rb_intern(x))
+
static VALUE d_lite_year(VALUE);
static VALUE d_lite_wday(VALUE);
static VALUE d_lite_jd(VALUE);
@@ -4174,7 +4140,7 @@ d_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
}
if (NIL_P(hash))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (NIL_P(ref_hash("jd")) &&
NIL_P(ref_hash("yday")) &&
@@ -4191,7 +4157,7 @@ d_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
}
if (NIL_P(jd))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
{
VALUE nth;
int rjd;
@@ -4246,10 +4212,12 @@ date_s__strptime_internal(int argc, VALUE *argv, VALUE klass,
if (!NIL_P(zone)) {
rb_enc_copy(zone, vstr);
+ OBJ_INFECT(zone, vstr);
set_hash("zone", zone);
}
if (!NIL_P(left)) {
rb_enc_copy(left, vstr);
+ OBJ_INFECT(left, vstr);
set_hash("leftover", left);
}
}
@@ -4322,40 +4290,12 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
VALUE date__parse(VALUE str, VALUE comp);
-static size_t
-get_limit(VALUE opt)
-{
- if (!NIL_P(opt)) {
- VALUE limit = rb_hash_aref(opt, ID2SYM(rb_intern("limit")));
- if (NIL_P(limit)) return SIZE_MAX;
- return NUM2SIZET(limit);
- }
- return 128;
-}
-
-static void
-check_limit(VALUE str, VALUE opt)
-{
- if (NIL_P(str)) return;
- if (SYMBOL_P(str)) str = rb_sym2str(str);
-
- StringValue(str);
- size_t slen = RSTRING_LEN(str);
- size_t limit = get_limit(opt);
- if (slen > limit) {
- rb_raise(rb_eArgError,
- "string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
- }
-}
-
static VALUE
date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
{
- VALUE vstr, vcomp, hash, opt;
+ VALUE vstr, vcomp, hash;
- rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
- if (!NIL_P(opt)) argc--;
- check_limit(vstr, opt);
+ rb_scan_args(argc, argv, "11", &vstr, &vcomp);
StringValue(vstr);
if (!rb_enc_str_asciicompat_p(vstr))
rb_raise(rb_eArgError,
@@ -4365,12 +4305,22 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
hash = date__parse(vstr, vcomp);
+ {
+ VALUE zone = ref_hash("zone");
+
+ if (!NIL_P(zone)) {
+ rb_enc_copy(zone, vstr);
+ OBJ_INFECT(zone, vstr);
+ set_hash("zone", zone);
+ }
+ }
+
return hash;
}
/*
* call-seq:
- * Date._parse(string[, comp=true], limit: 128) -> hash
+ * Date._parse(string[, comp=true]) -> hash
*
* Parses the given representation of date and time, and returns a
* hash of parsed elements. This method does not function as a
@@ -4381,10 +4331,6 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
* it full.
*
* Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s__parse(int argc, VALUE *argv, VALUE klass)
@@ -4394,7 +4340,7 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128) -> date
+ * Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]) -> date
*
* Parses the given representation of date and time, and creates a
* date object. This method does not function as a validator.
@@ -4406,18 +4352,13 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
* Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
* Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
* Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s_parse(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, comp, sg, opt;
+ VALUE str, comp, sg;
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "03", &str, &comp, &sg);
switch (argc) {
case 0:
@@ -4429,12 +4370,11 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 2;
- VALUE argv2[3];
- argv2[0] = str;
- argv2[1] = comp;
- if (!NIL_P(opt)) argv2[argc2++] = opt;
- VALUE hash = date_s__parse(argc2, argv2, klass);
+ VALUE argv2[2], hash;
+
+ argv2[0] = str;
+ argv2[1] = comp;
+ hash = date_s__parse(2, argv2, klass);
return d_new_by_frags(klass, hash, sg);
}
}
@@ -4448,28 +4388,19 @@ VALUE date__jisx0301(VALUE);
/*
* call-seq:
- * Date._iso8601(string, limit: 128) -> hash
+ * Date._iso8601(string) -> hash
*
* Returns a hash of parsed elements.
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
-date_s__iso8601(int argc, VALUE *argv, VALUE klass)
+date_s__iso8601(VALUE klass, VALUE str)
{
- VALUE str, opt;
-
- rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
-
return date__iso8601(str);
}
/*
* call-seq:
- * Date.iso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
+ * Date.iso8601(string='-4712-01-01'[, start=Date::ITALY]) -> date
*
* Creates a new Date object by parsing from a string according to
* some typical ISO 8601 formats.
@@ -4477,18 +4408,13 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
* Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
* Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
* Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s_iso8601(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -4498,56 +4424,38 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- if (!NIL_P(opt)) argv2[argc2++] = opt;
- VALUE hash = date_s__iso8601(argc2, argv2, klass);
+ VALUE hash = date_s__iso8601(klass, str);
return d_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * Date._rfc3339(string, limit: 128) -> hash
+ * Date._rfc3339(string) -> hash
*
* Returns a hash of parsed elements.
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
-date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
+date_s__rfc3339(VALUE klass, VALUE str)
{
- VALUE str, opt;
-
- rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
-
return date__rfc3339(str);
}
/*
* call-seq:
- * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> date
+ * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> date
*
* Creates a new Date object by parsing from a string according to
* some typical RFC 3339 formats.
*
* Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -4557,56 +4465,38 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- if (!NIL_P(opt)) argv2[argc2++] = opt;
- VALUE hash = date_s__rfc3339(argc2, argv2, klass);
+ VALUE hash = date_s__rfc3339(klass, str);
return d_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * Date._xmlschema(string, limit: 128) -> hash
+ * Date._xmlschema(string) -> hash
*
* Returns a hash of parsed elements.
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
-date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
+date_s__xmlschema(VALUE klass, VALUE str)
{
- VALUE str, opt;
-
- rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
-
return date__xmlschema(str);
}
/*
* call-seq:
- * Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
+ * Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY]) -> date
*
* Creates a new Date object by parsing from a string according to
* some typical XML Schema formats.
*
* Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -4616,58 +4506,41 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- if (!NIL_P(opt)) argv2[argc2++] = opt;
- VALUE hash = date_s__xmlschema(argc2, argv2, klass);
+ VALUE hash = date_s__xmlschema(klass, str);
return d_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * Date._rfc2822(string, limit: 128) -> hash
- * Date._rfc822(string, limit: 128) -> hash
+ * Date._rfc2822(string) -> hash
+ * Date._rfc822(string) -> hash
*
* Returns a hash of parsed elements.
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
-date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
+date_s__rfc2822(VALUE klass, VALUE str)
{
- VALUE str, opt;
-
- rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
-
return date__rfc2822(str);
}
/*
* call-seq:
- * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
- * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
+ * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
+ * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
*
* Creates a new Date object by parsing from a string according to
* some typical RFC 2822 formats.
*
* Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
* #=> #<Date: 2001-02-03 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -4677,56 +4550,39 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- if (!NIL_P(opt)) argv2[argc2++] = opt;
- VALUE hash = date_s__rfc2822(argc2, argv2, klass);
+ VALUE hash = date_s__rfc2822(klass, str);
return d_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * Date._httpdate(string, limit: 128) -> hash
+ * Date._httpdate(string) -> hash
*
* Returns a hash of parsed elements.
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
-date_s__httpdate(int argc, VALUE *argv, VALUE klass)
+date_s__httpdate(VALUE klass, VALUE str)
{
- VALUE str, opt;
-
- rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
-
return date__httpdate(str);
}
/*
* call-seq:
- * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128) -> date
+ * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) -> date
*
* Creates a new Date object by parsing from a string according to
* some RFC 2616 format.
*
* Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
* #=> #<Date: 2001-02-03 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s_httpdate(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -4736,60 +4592,38 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- if (!NIL_P(opt)) argv2[argc2++] = opt;
- VALUE hash = date_s__httpdate(argc2, argv2, klass);
+ VALUE hash = date_s__httpdate(klass, str);
return d_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * Date._jisx0301(string, limit: 128) -> hash
+ * Date._jisx0301(string) -> hash
*
* Returns a hash of parsed elements.
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
-date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
+date_s__jisx0301(VALUE klass, VALUE str)
{
- VALUE str, opt;
-
- rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
-
return date__jisx0301(str);
}
/*
* call-seq:
- * Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
+ * Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY]) -> date
*
* Creates a new Date object by parsing from a string according to
* some typical JIS X 0301 formats.
*
* Date.jisx0301('H13.02.03') #=> #<Date: 2001-02-03 ...>
- *
- * For no-era year, legacy format, Heisei is assumed.
- *
- * Date.jisx0301('13.02.03') #=> #<Date: 2001-02-03 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -4799,11 +4633,7 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- if (!NIL_P(opt)) argv2[argc2++] = opt;
- VALUE hash = date_s__jisx0301(argc2, argv2, klass);
+ VALUE hash = date_s__jisx0301(klass, str);
return d_new_by_frags(klass, hash, sg);
}
}
@@ -4861,14 +4691,14 @@ dup_obj_as_complex(VALUE self)
}
#define val2off(vof,iof) \
-do {\
+{\
if (!offset_to_sec(vof, &iof)) {\
iof = 0;\
rb_warning("invalid offset is ignored");\
}\
-} while (0)
+}
-#if 0
+#ifndef NDEBUG
static VALUE
d_lite_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -4877,6 +4707,7 @@ d_lite_initialize(int argc, VALUE *argv, VALUE self)
double sg;
rb_check_frozen(self);
+ rb_check_trusted(self);
rb_scan_args(argc, argv, "05", &vjd, &vdf, &vsf, &vof, &vsg);
@@ -4895,11 +4726,11 @@ d_lite_initialize(int argc, VALUE *argv, VALUE self)
sf = vsf;
if (f_lt_p(sf, INT2FIX(0)) ||
f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS)))
- rb_raise(eDateError, "invalid second fraction");
+ rb_raise(rb_eArgError, "invalid second fraction");
case 2:
df = NUM2INT(vdf);
if (df < 0 || df >= DAY_IN_SECONDS)
- rb_raise(eDateError, "invalid day fraction");
+ rb_raise(rb_eArgError, "invalid day fraction");
case 1:
jd = vjd;
}
@@ -4920,7 +4751,7 @@ d_lite_initialize(int argc, VALUE *argv, VALUE self)
"cannot load complex into simple");
set_to_complex(self, &dat->c, nth, rjd, df, sf, of, sg,
- 0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF);
+ 0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF | COMPLEX_DAT);
}
}
return self;
@@ -4932,34 +4763,15 @@ static VALUE
d_lite_initialize_copy(VALUE copy, VALUE date)
{
rb_check_frozen(copy);
+ rb_check_trusted(copy);
if (copy == date)
return copy;
{
get_d2(copy, date);
if (simple_dat_p(bdat)) {
- if (simple_dat_p(adat)) {
- adat->s = bdat->s;
- }
- else {
- adat->c.flags = bdat->s.flags | COMPLEX_DAT;
- adat->c.nth = bdat->s.nth;
- adat->c.jd = bdat->s.jd;
- adat->c.df = 0;
- adat->c.sf = INT2FIX(0);
- adat->c.of = 0;
- adat->c.sg = bdat->s.sg;
- adat->c.year = bdat->s.year;
-#ifndef USE_PACK
- adat->c.mon = bdat->s.mon;
- adat->c.mday = bdat->s.mday;
- adat->c.hour = bdat->s.hour;
- adat->c.min = bdat->s.min;
- adat->c.sec = bdat->s.sec;
-#else
- adat->c.pc = bdat->s.pc;
-#endif
- }
+ adat->s = bdat->s;
+ adat->s.flags &= ~COMPLEX_DAT;
}
else {
if (!complex_dat_p(adat))
@@ -4967,6 +4779,7 @@ d_lite_initialize_copy(VALUE copy, VALUE date)
"cannot load complex into simple");
adat->c = bdat->c;
+ adat->c.flags |= COMPLEX_DAT;
}
}
return copy;
@@ -5700,10 +5513,8 @@ d_lite_new_offset(int argc, VALUE *argv, VALUE self)
static VALUE
d_lite_plus(VALUE self, VALUE other)
{
- int try_rational = 1;
get_d1(self);
- again:
switch (TYPE(other)) {
case T_FIXNUM:
{
@@ -5913,21 +5724,18 @@ d_lite_plus(VALUE self, VALUE other)
default:
expect_numeric(other);
other = f_to_r(other);
- if (!k_rational_p(other)) {
- if (!try_rational) Check_Type(other, T_RATIONAL);
- try_rational = 0;
- goto again;
- }
+#ifdef CANONICALIZATION_FOR_MATHN
+ if (!k_rational_p(other))
+ return d_lite_plus(self, other);
+#endif
/* fall through */
case T_RATIONAL:
{
VALUE nth, sf, t;
int jd, df, s;
- if (wholenum_p(other)) {
- other = rb_rational_num(other);
- goto again;
- }
+ if (wholenum_p(other))
+ return d_lite_plus(self, rb_rational_num(other));
if (f_positive_p(other))
s = +1;
@@ -6209,7 +6017,7 @@ d_lite_rshift(VALUE self, VALUE other)
&rm, &rd, &rjd, &ns))
break;
if (--d < 1)
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
}
encode_jd(nth, rjd, &rjd2);
return d_lite_plus(self, f_sub(rjd2, m_real_local_jd(dat)));
@@ -6434,7 +6242,7 @@ cmp_gen(VALUE self, VALUE other)
return INT2FIX(f_cmp(m_ajd(dat), other));
else if (k_date_p(other))
return INT2FIX(f_cmp(m_ajd(dat), f_ajd(other)));
- return rb_num_coerce_cmp(self, other, id_cmp);
+ return rb_num_coerce_cmp(self, other, rb_intern("<=>"));
}
static VALUE
@@ -6563,7 +6371,7 @@ equal_gen(VALUE self, VALUE other)
return f_eqeq_p(m_real_local_jd(dat), other);
else if (k_date_p(other))
return f_eqeq_p(m_real_local_jd(dat), f_jd(other));
- return rb_num_coerce_cmp(self, other, id_eqeq_p);
+ return rb_num_coerce_cmp(self, other, rb_intern("=="));
}
/*
@@ -6661,7 +6469,7 @@ d_lite_to_s(VALUE self)
static VALUE
mk_inspect_raw(union DateData *x, VALUE klass)
{
- char flags[6];
+ char flags[5];
flags[0] = (x->flags & COMPLEX_DAT) ? 'C' : 'S';
flags[1] = (x->flags & HAVE_JD) ? 'j' : '-';
@@ -6733,9 +6541,9 @@ mk_inspect(union DateData *x, VALUE klass, VALUE to_s)
* Returns the value as a string for inspection.
*
* Date.new(2001,2,3).inspect
- * #=> "#<Date: 2001-02-03>"
+ * #=> "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"
* DateTime.new(2001,2,3,4,5,6,'-7').inspect
- * #=> "#<DateTime: 2001-02-03T04:05:06-07:00>"
+ * #=> "#<DateTime: 2001-02-03T04:05:06-07:00 ((2451944j,39906s,0n),-25200s,2299161j)>"
*/
static VALUE
d_lite_inspect(VALUE self)
@@ -6827,9 +6635,7 @@ tmx_m_of(union DateData *x)
static char *
tmx_m_zone(union DateData *x)
{
- VALUE zone = m_zone(x);
- /* TODO: fix potential dangling pointer */
- return RSTRING_PTR(zone);
+ return RSTRING_PTR(m_zone(x));
}
static const struct tmx_funcs tmx_funcs = {
@@ -6904,6 +6710,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
if (p > fmt) rb_str_cat(str, fmt, p - fmt);
}
rb_enc_copy(str, vfmt);
+ OBJ_INFECT(str, vfmt);
return str;
}
else
@@ -6912,6 +6719,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
str = rb_str_new(buf, len);
if (buf != buffer) xfree(buf);
rb_enc_copy(str, vfmt);
+ OBJ_INFECT(str, vfmt);
return str;
}
@@ -6977,7 +6785,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
*
* %M - Minute of the hour (00..59)
*
- * %S - Second of the minute (00..60)
+ * %S - Second of the minute (00..59)
*
* %L - Millisecond of the second (000..999)
* %N - Fractional seconds digits, default is 9 digits (nanosecond)
@@ -7210,14 +7018,10 @@ jisx0301_date_format(char *fmt, size_t size, VALUE jd, VALUE y)
c = 'S';
s = 1925;
}
- else if (d < 2458605) {
+ else {
c = 'H';
s = 1988;
}
- else {
- c = 'R';
- s = 2018;
- }
snprintf(fmt, size, "%c%02ld" ".%%m.%%d", c, FIX2INT(y) - s);
return fmt;
}
@@ -7295,13 +7099,10 @@ d_lite_marshal_dump(VALUE self)
static VALUE
d_lite_marshal_load(VALUE self, VALUE a)
{
- VALUE nth, sf;
- int jd, df, of;
- double sg;
-
get_d1(self);
rb_check_frozen(self);
+ rb_check_trusted(self);
if (!RB_TYPE_P(a, T_ARRAY))
rb_raise(rb_eTypeError, "expected an array");
@@ -7310,33 +7111,63 @@ d_lite_marshal_load(VALUE self, VALUE a)
case 2: /* 1.6.x */
case 3: /* 1.8.x, 1.9.2 */
{
- VALUE ajd, vof, vsg;
+ VALUE ajd, of, sg, nth, sf;
+ int jd, df, rof;
+ double rsg;
+
if (RARRAY_LEN(a) == 2) {
ajd = f_sub(RARRAY_AREF(a, 0), half_days_in_day);
- vof = INT2FIX(0);
- vsg = RARRAY_AREF(a, 1);
- if (!k_numeric_p(vsg))
- vsg = DBL2NUM(RTEST(vsg) ? GREGORIAN : JULIAN);
+ of = INT2FIX(0);
+ sg = RARRAY_AREF(a, 1);
+ if (!k_numeric_p(sg))
+ sg = DBL2NUM(RTEST(sg) ? GREGORIAN : JULIAN);
}
else {
ajd = RARRAY_AREF(a, 0);
- vof = RARRAY_AREF(a, 1);
- vsg = RARRAY_AREF(a, 2);
+ of = RARRAY_AREF(a, 1);
+ sg = RARRAY_AREF(a, 2);
}
- old_to_new(ajd, vof, vsg,
- &nth, &jd, &df, &sf, &of, &sg);
+ old_to_new(ajd, of, sg,
+ &nth, &jd, &df, &sf, &rof, &rsg);
+
+ if (!df && f_zero_p(sf) && !rof) {
+ set_to_simple(self, &dat->s, nth, jd, rsg, 0, 0, 0, HAVE_JD);
+ } else {
+ if (!complex_dat_p(dat))
+ rb_raise(rb_eArgError,
+ "cannot load complex into simple");
+
+ set_to_complex(self, &dat->c, nth, jd, df, sf, rof, rsg,
+ 0, 0, 0, 0, 0, 0,
+ HAVE_JD | HAVE_DF | COMPLEX_DAT);
+ }
}
break;
case 6:
{
+ VALUE nth, sf;
+ int jd, df, of;
+ double sg;
+
nth = RARRAY_AREF(a, 0);
jd = NUM2INT(RARRAY_AREF(a, 1));
df = NUM2INT(RARRAY_AREF(a, 2));
sf = RARRAY_AREF(a, 3);
of = NUM2INT(RARRAY_AREF(a, 4));
sg = NUM2DBL(RARRAY_AREF(a, 5));
+ if (!df && f_zero_p(sf) && !of) {
+ set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
+ } else {
+ if (!complex_dat_p(dat))
+ rb_raise(rb_eArgError,
+ "cannot load complex into simple");
+
+ set_to_complex(self, &dat->c, nth, jd, df, sf, of, sg,
+ 0, 0, 0, 0, 0, 0,
+ HAVE_JD | HAVE_DF | COMPLEX_DAT);
+ }
}
break;
default:
@@ -7344,21 +7175,6 @@ d_lite_marshal_load(VALUE self, VALUE a)
break;
}
- if (simple_dat_p(dat)) {
- if (df || !f_zero_p(sf) || of) {
- /* loading a fractional date; promote to complex */
- dat = ruby_xrealloc(dat, sizeof(struct ComplexDateData));
- RTYPEDDATA(self)->data = dat;
- goto complex_data;
- }
- set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
- } else {
- complex_data:
- set_to_complex(self, &dat->c, nth, jd, df, sf, of, sg,
- 0, 0, 0, 0, 0, 0,
- HAVE_JD | HAVE_DF);
- }
-
if (FL_TEST(a, FL_EXIVAR)) {
rb_copy_generic_ivar(self, a);
FL_SET(self, FL_EXIVAR);
@@ -7414,16 +7230,12 @@ datetime_s_jd(int argc, VALUE *argv, VALUE klass)
case 5:
val2off(vof, rof);
case 4:
- check_numeric(vs, "second");
num2int_with_frac(s, positive_inf);
case 3:
- check_numeric(vmin, "minute");
num2int_with_frac(min, 3);
case 2:
- check_numeric(vh, "hour");
num2int_with_frac(h, 2);
case 1:
- check_numeric(vjd, "jd");
num2num_with_frac(jd, 1);
}
@@ -7432,7 +7244,7 @@ datetime_s_jd(int argc, VALUE *argv, VALUE klass)
int rh, rmin, rs, rjd, rjd2;
if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
canon24oc();
decode_jd(jd, &nth, &rjd);
@@ -7487,19 +7299,14 @@ datetime_s_ordinal(int argc, VALUE *argv, VALUE klass)
case 6:
val2off(vof, rof);
case 5:
- check_numeric(vs, "second");
num2int_with_frac(s, positive_inf);
case 4:
- check_numeric(vmin, "minute");
num2int_with_frac(min, 4);
case 3:
- check_numeric(vh, "hour");
num2int_with_frac(h, 3);
case 2:
- check_numeric(vd, "yday");
num2int_with_frac(d, 2);
case 1:
- check_numeric(vy, "year");
y = vy;
}
@@ -7511,9 +7318,9 @@ datetime_s_ordinal(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
canon24oc();
rjd2 = jd_local_to_utc(rjd,
@@ -7548,20 +7355,9 @@ datetime_s_ordinal(int argc, VALUE *argv, VALUE klass)
static VALUE
datetime_s_civil(int argc, VALUE *argv, VALUE klass)
{
- return datetime_initialize(argc, argv, d_lite_s_alloc_complex(klass));
-}
-
-static VALUE
-datetime_initialize(int argc, VALUE *argv, VALUE self)
-{
VALUE vy, vm, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;
int m, d, h, min, s, rof;
double sg;
- struct ComplexDateData *dat = rb_check_typeddata(self, &d_lite_type);
-
- if (!complex_dat_p(dat)) {
- rb_raise(rb_eTypeError, "DateTime expected");
- }
rb_scan_args(argc, argv, "08", &vy, &vm, &vd, &vh, &vmin, &vs, &vof, &vsg);
@@ -7580,22 +7376,16 @@ datetime_initialize(int argc, VALUE *argv, VALUE self)
case 7:
val2off(vof, rof);
case 6:
- check_numeric(vs, "second");
num2int_with_frac(s, positive_inf);
case 5:
- check_numeric(vmin, "minute");
num2int_with_frac(min, 5);
case 4:
- check_numeric(vh, "hour");
num2int_with_frac(h, 4);
case 3:
- check_numeric(vd, "day");
num2int_with_frac(d, 3);
case 2:
- check_numeric(vm, "month");
m = NUM2INT(vm);
case 1:
- check_numeric(vy, "year");
y = vy;
}
@@ -7606,18 +7396,18 @@ datetime_initialize(int argc, VALUE *argv, VALUE self)
if (!valid_gregorian_p(y, m, d,
&nth, &ry,
&rm, &rd))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
canon24oc();
- set_to_complex(self, dat,
- nth, 0,
- 0, INT2FIX(0),
- rof, sg,
- ry, rm, rd,
- rh, rmin, rs,
- HAVE_CIVIL | HAVE_TIME);
+ ret = d_complex_new_internal(klass,
+ nth, 0,
+ 0, INT2FIX(0),
+ rof, sg,
+ ry, rm, rd,
+ rh, rmin, rs,
+ HAVE_CIVIL | HAVE_TIME);
}
else {
VALUE nth;
@@ -7627,24 +7417,23 @@ datetime_initialize(int argc, VALUE *argv, VALUE self)
&nth, &ry,
&rm, &rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
canon24oc();
rjd2 = jd_local_to_utc(rjd,
time_to_df(rh, rmin, rs),
rof);
- set_to_complex(self, dat,
- nth, rjd2,
- 0, INT2FIX(0),
- rof, sg,
- ry, rm, rd,
- rh, rmin, rs,
- HAVE_JD | HAVE_CIVIL | HAVE_TIME);
+ ret = d_complex_new_internal(klass,
+ nth, rjd2,
+ 0, INT2FIX(0),
+ rof, sg,
+ ry, rm, rd,
+ rh, rmin, rs,
+ HAVE_JD | HAVE_CIVIL | HAVE_TIME);
}
- ret = self;
add_frac();
return ret;
}
@@ -7684,22 +7473,16 @@ datetime_s_commercial(int argc, VALUE *argv, VALUE klass)
case 7:
val2off(vof, rof);
case 6:
- check_numeric(vs, "second");
num2int_with_frac(s, positive_inf);
case 5:
- check_numeric(vmin, "minute");
num2int_with_frac(min, 5);
case 4:
- check_numeric(vh, "hour");
num2int_with_frac(h, 4);
case 3:
- check_numeric(vd, "cwday");
num2int_with_frac(d, 3);
case 2:
- check_numeric(vw, "cweek");
w = NUM2INT(vw);
case 1:
- check_numeric(vy, "year");
y = vy;
}
@@ -7711,9 +7494,9 @@ datetime_s_commercial(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rw, &rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
canon24oc();
rjd2 = jd_local_to_utc(rjd,
@@ -7782,9 +7565,9 @@ datetime_s_weeknum(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rw, &rd, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
canon24oc();
rjd2 = jd_local_to_utc(rjd,
@@ -7851,9 +7634,9 @@ datetime_s_nth_kday(int argc, VALUE *argv, VALUE klass)
&nth, &ry,
&rm, &rn, &rk, &rjd,
&ns))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
canon24oc();
rjd2 = jd_local_to_utc(rjd,
@@ -7996,7 +7779,7 @@ dt_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
}
if (NIL_P(hash))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
if (NIL_P(ref_hash("jd")) &&
NIL_P(ref_hash("yday")) &&
@@ -8023,7 +7806,7 @@ dt_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
}
if (NIL_P(jd))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
{
int rh, rmin, rs;
@@ -8032,7 +7815,7 @@ dt_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
NUM2INT(ref_hash("min")),
NUM2INT(ref_hash("sec")),
&rh, &rmin, &rs))
- rb_raise(eDateError, "invalid date");
+ rb_raise(rb_eArgError, "invalid date");
df = time_to_df(rh, rmin, rs);
}
@@ -8142,7 +7925,7 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]], limit: 128) -> datetime
+ * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]) -> datetime
*
* Parses the given representation of date and time, and creates a
* DateTime object. This method does not function as a validator.
@@ -8156,18 +7939,13 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
* DateTime.parse('3rd Feb 2001 04:05:06 PM')
* #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
datetime_s_parse(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, comp, sg, opt;
+ VALUE str, comp, sg;
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "03", &str, &comp, &sg);
switch (argc) {
case 0:
@@ -8179,20 +7957,18 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 2;
- VALUE argv2[3];
- argv2[0] = str;
- argv2[1] = comp;
- argv2[2] = opt;
- if (!NIL_P(opt)) argc2++;
- VALUE hash = date_s__parse(argc2, argv2, klass);
+ VALUE argv2[2], hash;
+
+ argv2[0] = str;
+ argv2[1] = comp;
+ hash = date_s__parse(2, argv2, klass);
return dt_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
+ * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
*
* Creates a new DateTime object by parsing from a string according to
* some typical ISO 8601 formats.
@@ -8203,18 +7979,13 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
* DateTime.iso8601('2001-W05-6T04:05:06+07:00')
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -8224,37 +7995,27 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- argv2[1] = opt;
- if (!NIL_P(opt)) argc2--;
- VALUE hash = date_s__iso8601(argc2, argv2, klass);
+ VALUE hash = date_s__iso8601(klass, str);
return dt_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
+ * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
*
* Creates a new DateTime object by parsing from a string according to
* some typical RFC 3339 formats.
*
* DateTime.rfc3339('2001-02-03T04:05:06+07:00')
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -8264,37 +8025,27 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- argv2[1] = opt;
- if (!NIL_P(opt)) argc2++;
- VALUE hash = date_s__rfc3339(argc2, argv2, klass);
+ VALUE hash = date_s__rfc3339(klass, str);
return dt_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
+ * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
*
* Creates a new DateTime object by parsing from a string according to
* some typical XML Schema formats.
*
* DateTime.xmlschema('2001-02-03T04:05:06+07:00')
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -8304,38 +8055,28 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- argv2[1] = opt;
- if (!NIL_P(opt)) argc2++;
- VALUE hash = date_s__xmlschema(argc2, argv2, klass);
+ VALUE hash = date_s__xmlschema(klass, str);
return dt_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
- * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
+ * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
+ * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
*
* Creates a new DateTime object by parsing from a string according to
* some typical RFC 2822 formats.
*
* DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -8345,12 +8086,7 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- argv2[1] = opt;
- if (!NIL_P(opt)) argc2++;
- VALUE hash = date_s__rfc2822(argc2, argv2, klass);
+ VALUE hash = date_s__rfc2822(klass, str);
return dt_new_by_frags(klass, hash, sg);
}
}
@@ -8364,18 +8100,13 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
*
* DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
* #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -8385,42 +8116,27 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- argv2[1] = opt;
- if (!NIL_P(opt)) argc2++;
- VALUE hash = date_s__httpdate(argc2, argv2, klass);
+ VALUE hash = date_s__httpdate(klass, str);
return dt_new_by_frags(klass, hash, sg);
}
}
/*
* call-seq:
- * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
+ * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
*
* Creates a new DateTime object by parsing from a string according to
* some typical JIS X 0301 formats.
*
* DateTime.jisx0301('H13.02.03T04:05:06+07:00')
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
- *
- * For no-era year, legacy format, Heisei is assumed.
- *
- * DateTime.jisx0301('13.02.03T04:05:06+07:00')
- * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
- *
- * Raise an ArgumentError when the string length is longer than _limit_.
- * You can stop this check by passing `limit: nil`, but note that
- * it may take a long time to parse.
*/
static VALUE
datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
{
- VALUE str, sg, opt;
+ VALUE str, sg;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
@@ -8430,12 +8146,7 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
}
{
- int argc2 = 1;
- VALUE argv2[2];
- argv2[0] = str;
- argv2[1] = opt;
- if (!NIL_P(opt)) argc2++;
- VALUE hash = date_s__jisx0301(argc2, argv2, klass);
+ VALUE hash = date_s__jisx0301(klass, str);
return dt_new_by_frags(klass, hash, sg);
}
}
@@ -8519,7 +8230,7 @@ dt_lite_to_s(VALUE self)
*
* %M - Minute of the hour (00..59)
*
- * %S - Second of the minute (00..60)
+ * %S - Second of the minute (00..59)
*
* %L - Millisecond of the second (000..999)
* %N - Fractional seconds digits, default is 9 digits (nanosecond)
@@ -8813,24 +8524,17 @@ time_to_datetime(VALUE self)
* call-seq:
* d.to_time -> time
*
- * Returns a Time object which denotes self. If self is a julian date,
- * convert it to a gregorian date before converting it to Time.
+ * Returns a Time object which denotes self.
*/
static VALUE
date_to_time(VALUE self)
{
- get_d1a(self);
-
- if (m_julian_p(adat)) {
- VALUE tmp = d_lite_gregorian(self);
- get_d1b(tmp);
- adat = bdat;
- }
+ get_d1(self);
return f_local3(rb_cTime,
- m_real_year(adat),
- INT2FIX(m_mon(adat)),
- INT2FIX(m_mday(adat)));
+ m_real_year(dat),
+ INT2FIX(m_mon(dat)),
+ INT2FIX(m_mday(dat)));
}
/*
@@ -8939,7 +8643,7 @@ datetime_to_date(VALUE self)
VALUE new = d_lite_s_alloc_simple(cDate);
{
get_d1b(new);
- copy_complex_to_simple(new, &bdat->s, &adat->c);
+ copy_complex_to_simple(new, &bdat->s, &adat->c)
bdat->s.jd = m_local_jd(adat);
bdat->s.flags &= ~(HAVE_DF | HAVE_TIME | COMPLEX_DAT);
return new;
@@ -9304,18 +9008,14 @@ mk_ary_of_str(long len, const char *a[])
return o;
}
-static VALUE
-d_lite_zero(VALUE x)
-{
- return INT2FIX(0);
-}
-
void
Init_date_core(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
+ assert(fprintf(stderr, "assert() is now active\n"));
+
id_cmp = rb_intern("<=>");
id_le_p = rb_intern("<=");
id_ge_p = rb_intern(">=");
@@ -9487,7 +9187,6 @@ Init_date_core(void)
*
*/
cDate = rb_define_class("Date", rb_cObject);
- eDateError = rb_define_class_under(cDate, "Error", rb_eArgError);
rb_include_module(cDate, rb_mComparable);
@@ -9532,22 +9231,23 @@ Init_date_core(void)
*/
rb_define_const(cDate, "GREGORIAN", DBL2NUM(GREGORIAN));
- rb_define_alloc_func(cDate, d_lite_s_alloc_simple);
+ rb_define_alloc_func(cDate, d_lite_s_alloc);
#ifndef NDEBUG
- rb_define_private_method(CLASS_OF(cDate), "_valid_jd?",
+#define de_define_private_method rb_define_private_method
+ de_define_private_method(CLASS_OF(cDate), "_valid_jd?",
date_s__valid_jd_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "_valid_ordinal?",
+ de_define_private_method(CLASS_OF(cDate), "_valid_ordinal?",
date_s__valid_ordinal_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "_valid_civil?",
+ de_define_private_method(CLASS_OF(cDate), "_valid_civil?",
date_s__valid_civil_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "_valid_date?",
+ de_define_private_method(CLASS_OF(cDate), "_valid_date?",
date_s__valid_civil_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "_valid_commercial?",
+ de_define_private_method(CLASS_OF(cDate), "_valid_commercial?",
date_s__valid_commercial_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "_valid_weeknum?",
+ de_define_private_method(CLASS_OF(cDate), "_valid_weeknum?",
date_s__valid_weeknum_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "_valid_nth_kday?",
+ de_define_private_method(CLASS_OF(cDate), "_valid_nth_kday?",
date_s__valid_nth_kday_p, -1);
#endif
@@ -9560,11 +9260,11 @@ Init_date_core(void)
date_s_valid_commercial_p, -1);
#ifndef NDEBUG
- rb_define_private_method(CLASS_OF(cDate), "valid_weeknum?",
+ de_define_private_method(CLASS_OF(cDate), "valid_weeknum?",
date_s_valid_weeknum_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "valid_nth_kday?",
+ de_define_private_method(CLASS_OF(cDate), "valid_nth_kday?",
date_s_valid_nth_kday_p, -1);
- rb_define_private_method(CLASS_OF(cDate), "zone_to_diff",
+ de_define_private_method(CLASS_OF(cDate), "zone_to_diff",
date_s_zone_to_diff, 1);
#endif
@@ -9575,18 +9275,21 @@ Init_date_core(void)
date_s_gregorian_leap_p, 1);
#ifndef NDEBUG
- rb_define_singleton_method(cDate, "new!", date_s_new_bang, -1);
- rb_define_alias(rb_singleton_class(cDate), "new_l!", "new");
+#define de_define_singleton_method rb_define_singleton_method
+#define de_define_alias rb_define_alias
+ de_define_singleton_method(cDate, "new!", date_s_new_bang, -1);
+ de_define_alias(rb_singleton_class(cDate), "new_l!", "new");
#endif
rb_define_singleton_method(cDate, "jd", date_s_jd, -1);
rb_define_singleton_method(cDate, "ordinal", date_s_ordinal, -1);
rb_define_singleton_method(cDate, "civil", date_s_civil, -1);
+ rb_define_singleton_method(cDate, "new", date_s_civil, -1);
rb_define_singleton_method(cDate, "commercial", date_s_commercial, -1);
#ifndef NDEBUG
- rb_define_singleton_method(cDate, "weeknum", date_s_weeknum, -1);
- rb_define_singleton_method(cDate, "nth_kday", date_s_nth_kday, -1);
+ de_define_singleton_method(cDate, "weeknum", date_s_weeknum, -1);
+ de_define_singleton_method(cDate, "nth_kday", date_s_nth_kday, -1);
#endif
rb_define_singleton_method(cDate, "today", date_s_today, -1);
@@ -9594,26 +9297,29 @@ Init_date_core(void)
rb_define_singleton_method(cDate, "strptime", date_s_strptime, -1);
rb_define_singleton_method(cDate, "_parse", date_s__parse, -1);
rb_define_singleton_method(cDate, "parse", date_s_parse, -1);
- rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, -1);
+ rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, 1);
rb_define_singleton_method(cDate, "iso8601", date_s_iso8601, -1);
- rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, -1);
+ rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, 1);
rb_define_singleton_method(cDate, "rfc3339", date_s_rfc3339, -1);
- rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, -1);
+ rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, 1);
rb_define_singleton_method(cDate, "xmlschema", date_s_xmlschema, -1);
- rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, -1);
- rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, -1);
+ rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, 1);
+ rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, 1);
rb_define_singleton_method(cDate, "rfc2822", date_s_rfc2822, -1);
rb_define_singleton_method(cDate, "rfc822", date_s_rfc2822, -1);
- rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, -1);
+ rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, 1);
rb_define_singleton_method(cDate, "httpdate", date_s_httpdate, -1);
- rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, -1);
+ rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, 1);
rb_define_singleton_method(cDate, "jisx0301", date_s_jisx0301, -1);
- rb_define_method(cDate, "initialize", date_initialize, -1);
+#ifndef NDEBUG
+#define de_define_method rb_define_method
+ de_define_method(cDate, "initialize", d_lite_initialize, -1);
+#endif
rb_define_method(cDate, "initialize_copy", d_lite_initialize_copy, 1);
#ifndef NDEBUG
- rb_define_method(cDate, "fill", d_lite_fill, 0);
+ de_define_method(cDate, "fill", d_lite_fill, 0);
#endif
rb_define_method(cDate, "ajd", d_lite_ajd, 0);
@@ -9635,8 +9341,8 @@ Init_date_core(void)
rb_define_method(cDate, "cwday", d_lite_cwday, 0);
#ifndef NDEBUG
- rb_define_private_method(cDate, "wnum0", d_lite_wnum0, 0);
- rb_define_private_method(cDate, "wnum1", d_lite_wnum1, 0);
+ de_define_private_method(cDate, "wnum0", d_lite_wnum0, 0);
+ de_define_private_method(cDate, "wnum1", d_lite_wnum1, 0);
#endif
rb_define_method(cDate, "wday", d_lite_wday, 0);
@@ -9650,14 +9356,18 @@ Init_date_core(void)
rb_define_method(cDate, "saturday?", d_lite_saturday_p, 0);
#ifndef NDEBUG
- rb_define_method(cDate, "nth_kday?", d_lite_nth_kday_p, 2);
+ de_define_method(cDate, "nth_kday?", d_lite_nth_kday_p, 2);
#endif
- rb_define_private_method(cDate, "hour", d_lite_zero, 0);
- rb_define_private_method(cDate, "min", d_lite_zero, 0);
- rb_define_private_method(cDate, "minute", d_lite_zero, 0);
- rb_define_private_method(cDate, "sec", d_lite_zero, 0);
- rb_define_private_method(cDate, "second", d_lite_zero, 0);
+ rb_define_private_method(cDate, "hour", d_lite_hour, 0);
+ rb_define_private_method(cDate, "min", d_lite_min, 0);
+ rb_define_private_method(cDate, "minute", d_lite_min, 0);
+ rb_define_private_method(cDate, "sec", d_lite_sec, 0);
+ rb_define_private_method(cDate, "second", d_lite_sec, 0);
+ rb_define_private_method(cDate, "sec_fraction", d_lite_sec_fraction, 0);
+ rb_define_private_method(cDate, "second_fraction", d_lite_sec_fraction, 0);
+ rb_define_private_method(cDate, "offset", d_lite_offset, 0);
+ rb_define_private_method(cDate, "zone", d_lite_zone, 0);
rb_define_method(cDate, "julian?", d_lite_julian_p, 0);
rb_define_method(cDate, "gregorian?", d_lite_gregorian_p, 0);
@@ -9670,6 +9380,8 @@ Init_date_core(void)
rb_define_method(cDate, "julian", d_lite_julian, 0);
rb_define_method(cDate, "gregorian", d_lite_gregorian, 0);
+ rb_define_private_method(cDate, "new_offset", d_lite_new_offset, -1);
+
rb_define_method(cDate, "+", d_lite_plus, 1);
rb_define_method(cDate, "-", d_lite_minus, 1);
@@ -9697,7 +9409,7 @@ Init_date_core(void)
rb_define_method(cDate, "to_s", d_lite_to_s, 0);
#ifndef NDEBUG
- rb_define_method(cDate, "inspect_raw", d_lite_inspect_raw, 0);
+ de_define_method(cDate, "inspect_raw", d_lite_inspect_raw, 0);
#endif
rb_define_method(cDate, "inspect", d_lite_inspect, 0);
@@ -9714,7 +9426,7 @@ Init_date_core(void)
rb_define_method(cDate, "jisx0301", d_lite_jisx0301, 0);
#ifndef NDEBUG
- rb_define_method(cDate, "marshal_dump_old", d_lite_marshal_dump_old, 0);
+ de_define_method(cDate, "marshal_dump_old", d_lite_marshal_dump_old, 0);
#endif
rb_define_method(cDate, "marshal_dump", d_lite_marshal_dump, 0);
rb_define_method(cDate, "marshal_load", d_lite_marshal_load, 1);
@@ -9861,7 +9573,6 @@ Init_date_core(void)
*/
cDateTime = rb_define_class("DateTime", cDate);
- rb_define_alloc_func(cDateTime, d_lite_s_alloc_complex);
rb_define_singleton_method(cDateTime, "jd", datetime_s_jd, -1);
rb_define_singleton_method(cDateTime, "ordinal", datetime_s_ordinal, -1);
@@ -9871,9 +9582,9 @@ Init_date_core(void)
datetime_s_commercial, -1);
#ifndef NDEBUG
- rb_define_singleton_method(cDateTime, "weeknum",
+ de_define_singleton_method(cDateTime, "weeknum",
datetime_s_weeknum, -1);
- rb_define_singleton_method(cDateTime, "nth_kday",
+ de_define_singleton_method(cDateTime, "nth_kday",
datetime_s_nth_kday, -1);
#endif
@@ -9901,16 +9612,19 @@ Init_date_core(void)
rb_define_singleton_method(cDateTime, "jisx0301",
datetime_s_jisx0301, -1);
- rb_define_method(cDateTime, "hour", d_lite_hour, 0);
- rb_define_method(cDateTime, "min", d_lite_min, 0);
- rb_define_method(cDateTime, "minute", d_lite_min, 0);
- rb_define_method(cDateTime, "sec", d_lite_sec, 0);
- rb_define_method(cDateTime, "second", d_lite_sec, 0);
- rb_define_method(cDateTime, "sec_fraction", d_lite_sec_fraction, 0);
- rb_define_method(cDateTime, "second_fraction", d_lite_sec_fraction, 0);
- rb_define_method(cDateTime, "offset", d_lite_offset, 0);
- rb_define_method(cDateTime, "zone", d_lite_zone, 0);
- rb_define_method(cDateTime, "new_offset", d_lite_new_offset, -1);
+#define f_public(m,s) rb_funcall(m, rb_intern("public"), 1,\
+ ID2SYM(rb_intern(s)))
+
+ f_public(cDateTime, "hour");
+ f_public(cDateTime, "min");
+ f_public(cDateTime, "minute");
+ f_public(cDateTime, "sec");
+ f_public(cDateTime, "second");
+ f_public(cDateTime, "sec_fraction");
+ f_public(cDateTime, "second_fraction");
+ f_public(cDateTime, "offset");
+ f_public(cDateTime, "zone");
+ f_public(cDateTime, "new_offset");
rb_define_method(cDateTime, "to_s", dt_lite_to_s, 0);
@@ -9938,15 +9652,15 @@ Init_date_core(void)
#ifndef NDEBUG
/* tests */
- rb_define_singleton_method(cDate, "test_civil", date_s_test_civil, 0);
- rb_define_singleton_method(cDate, "test_ordinal", date_s_test_ordinal, 0);
- rb_define_singleton_method(cDate, "test_commercial",
+ de_define_singleton_method(cDate, "test_civil", date_s_test_civil, 0);
+ de_define_singleton_method(cDate, "test_ordinal", date_s_test_ordinal, 0);
+ de_define_singleton_method(cDate, "test_commercial",
date_s_test_commercial, 0);
- rb_define_singleton_method(cDate, "test_weeknum", date_s_test_weeknum, 0);
- rb_define_singleton_method(cDate, "test_nth_kday", date_s_test_nth_kday, 0);
- rb_define_singleton_method(cDate, "test_unit_conv",
+ de_define_singleton_method(cDate, "test_weeknum", date_s_test_weeknum, 0);
+ de_define_singleton_method(cDate, "test_nth_kday", date_s_test_nth_kday, 0);
+ de_define_singleton_method(cDate, "test_unit_conv",
date_s_test_unit_conv, 0);
- rb_define_singleton_method(cDate, "test_all", date_s_test_all, 0);
+ de_define_singleton_method(cDate, "test_all", date_s_test_all, 0);
#endif
}
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index 0378e50cf7..b74230d291 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -40,9 +40,9 @@ RUBY_EXTERN unsigned long ruby_scan_digits(const char *str, ssize_t len, int bas
#define f_sub_bang(s,r,x) rb_funcall(s, rb_intern("sub!"), 2, r, x)
#define f_gsub_bang(s,r,x) rb_funcall(s, rb_intern("gsub!"), 2, r, x)
-#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k"")), v)
-#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k"")))
-#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k"")))
+#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
+#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
+#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
#define cstr2num(s) rb_cstr_to_inum(s, 10, 0)
#define str2num(s) rb_str_to_inum(s, 10, 0)
@@ -66,13 +66,7 @@ static const char abbr_months[][4] = {
#define asubt_string() rb_str_new("\024", 1)
#endif
-static size_t
-digit_span(const char *s, const char *e)
-{
- size_t i = 0;
- while (s + i < e && isdigit((unsigned char)s[i])) i++;
- return i;
-}
+#define DECDIGIT "0123456789"
static void
s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
@@ -98,7 +92,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
y = d;
d = Qnil;
}
- if (!NIL_P(d) && RSTRING_LEN(d) > 0 && *RSTRING_PTR(d) == '\'') {
+ if (!NIL_P(d) && *RSTRING_PTR(d) == '\'') {
y = d;
d = Qnil;
}
@@ -109,20 +103,17 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
size_t l;
s = RSTRING_PTR(y);
- ep = RSTRING_END(y);
- while (s < ep && !issign(*s) && !isdigit((unsigned char)*s))
+ while (!issign((unsigned char)*s) && !isdigit((unsigned char)*s))
s++;
- if (s >= ep) goto no_date;
bp = s;
if (issign((unsigned char)*s))
s++;
- l = digit_span(s, ep);
+ l = strspn(s, DECDIGIT);
ep = s + l;
if (*ep) {
y = d;
d = rb_str_new(bp, ep - bp);
}
- no_date:;
}
if (!NIL_P(m)) {
@@ -161,10 +152,8 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
VALUE iy;
s = RSTRING_PTR(y);
- ep = RSTRING_END(y);
- while (s < ep && !issign(*s) && !isdigit((unsigned char)*s))
+ while (!issign((unsigned char)*s) && !isdigit((unsigned char)*s))
s++;
- if (s >= ep) goto no_year;
bp = s;
if (issign(*s)) {
s++;
@@ -172,7 +161,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
}
if (sign)
c = Qfalse;
- l = digit_span(s, ep);
+ l = strspn(s, DECDIGIT);
ep = s + l;
if (l > 2)
c = Qfalse;
@@ -186,7 +175,6 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
ALLOCV_END(vbuf);
}
set_hash("year", iy);
- no_year:;
}
if (bc)
@@ -198,12 +186,10 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
VALUE im;
s = RSTRING_PTR(m);
- ep = RSTRING_END(m);
- while (s < ep && !isdigit((unsigned char)*s))
+ while (!isdigit((unsigned char)*s))
s++;
- if (s >= ep) goto no_month;
bp = s;
- l = digit_span(s, ep);
+ l = strspn(s, DECDIGIT);
ep = s + l;
{
char *buf;
@@ -215,7 +201,6 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
ALLOCV_END(vbuf);
}
set_hash("mon", im);
- no_month:;
}
if (!NIL_P(d)) {
@@ -224,12 +209,10 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
VALUE id;
s = RSTRING_PTR(d);
- ep = RSTRING_END(d);
- while (s < ep && !isdigit((unsigned char)*s))
+ while (!isdigit((unsigned char)*s))
s++;
- if (s >= ep) goto no_mday;
bp = s;
- l = digit_span(s, ep);
+ l = strspn(s, DECDIGIT);
ep = s + l;
{
char *buf;
@@ -241,7 +224,6 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
ALLOCV_END(vbuf);
}
set_hash("mday", id);
- no_mday:;
}
if (!NIL_P(c))
@@ -281,18 +263,18 @@ regcomp(const char *source, long len, int opt)
}
#define REGCOMP(pat,opt) \
-do { \
+{ \
if (NIL_P(pat)) \
pat = regcomp(pat##_source, sizeof pat##_source - 1, opt); \
-} while (0)
+}
#define REGCOMP_0(pat) REGCOMP(pat, 0)
#define REGCOMP_I(pat) REGCOMP(pat, ONIG_OPTION_IGNORECASE)
#define MATCH(s,p,c) \
-do { \
+{ \
return match(s, p, hash, c); \
-} while (0)
+}
static int
match(VALUE str, VALUE pat, VALUE hash, int (*cb)(VALUE, VALUE))
@@ -332,78 +314,39 @@ subx(VALUE str, VALUE rep, VALUE pat, VALUE hash, int (*cb)(VALUE, VALUE))
}
#define SUBS(s,p,c) \
-do { \
+{ \
return subx(s, asp_string(), p, hash, c); \
-} while (0)
+}
#ifdef TIGHT_PARSER
#define SUBA(s,p,c) \
-do { \
+{ \
return subx(s, asuba_string(), p, hash, c); \
-} while (0)
+}
#define SUBB(s,p,c) \
-do { \
+{ \
return subx(s, asubb_string(), p, hash, c); \
-} while (0)
+}
#define SUBW(s,p,c) \
-do { \
+{ \
return subx(s, asubw_string(), p, hash, c); \
-} while (0)
+}
#define SUBT(s,p,c) \
-do { \
+{ \
return subx(s, asubt_string(), p, hash, c); \
-} while (0)
+}
#endif
#include "zonetab.h"
static int
-str_end_with_word(const char *s, long l, const char *w)
+str_end_with(const char *s, long l, const char *w)
{
int n = (int)strlen(w);
- if (l <= n || !isspace((unsigned char)s[l - n - 1])) return 0;
- if (strncasecmp(&s[l - n], w, n)) return 0;
- do ++n; while (l > n && isspace((unsigned char)s[l - n - 1]));
- return n;
-}
-
-static long
-shrunk_size(const char *s, long l)
-{
- long i, ni;
- int sp = 0;
- for (i = ni = 0; i < l; ++i) {
- if (!isspace((unsigned char)s[i])) {
- if (sp) ni++;
- sp = 0;
- ni++;
- }
- else {
- sp = 1;
- }
- }
- return ni < l ? ni : 0;
-}
-
-static long
-shrink_space(char *d, const char *s, long l)
-{
- long i, ni;
- int sp = 0;
- for (i = ni = 0; i < l; ++i) {
- if (!isspace((unsigned char)s[i])) {
- if (sp) d[ni++] = ' ';
- sp = 0;
- d[ni++] = s[i];
- }
- else {
- sp = 1;
- }
- }
- return ni;
+ return (l >= n && strncmp(s - n, w, n) == 0);
}
VALUE
@@ -411,40 +354,55 @@ date_zone_to_diff(VALUE str)
{
VALUE offset = Qnil;
VALUE vbuf = 0;
- long l = RSTRING_LEN(str);
- const char *s = RSTRING_PTR(str);
+ long l, i;
+ char *s, *dest, *d;
+ int sp = 1;
+
+ l = RSTRING_LEN(str);
+ s = RSTRING_PTR(str);
+
+ dest = d = ALLOCV_N(char, vbuf, l + 1);
+
+ for (i = 0; i < l; i++) {
+ if (isspace((unsigned char)s[i]) || s[i] == '\0') {
+ if (!sp)
+ *d++ = ' ';
+ sp = 1;
+ }
+ else {
+ if (isalpha((unsigned char)s[i]))
+ *d++ = tolower((unsigned char)s[i]);
+ else
+ *d++ = s[i];
+ sp = 0;
+ }
+ }
+ if (d > dest) {
+ if (*(d - 1) == ' ')
+ --d;
+ *d = '\0';
+ }
+ l = d - dest;
+ s = dest;
{
+ static const char STD[] = " standard time";
+ static const char DST1[] = " daylight time";
+ static const char DST2[] = " dst";
int dst = 0;
- int w;
- if ((w = str_end_with_word(s, l, "time")) > 0) {
- int wtime = w;
- l -= w;
- if ((w = str_end_with_word(s, l, "standard")) > 0) {
- l -= w;
- }
- else if ((w = str_end_with_word(s, l, "daylight")) > 0) {
- l -= w;
- dst = 1;
- }
- else {
- l += wtime;
- }
+ if (str_end_with(d, l, STD)) {
+ l -= sizeof(STD) - 1;
}
- else if ((w = str_end_with_word(s, l, "dst")) > 0) {
- l -= w;
+ else if (str_end_with(d, l, DST1)) {
+ l -= sizeof(DST1) - 1;
dst = 1;
}
- {
- long sl = shrunk_size(s, l);
- if (sl > 0 && sl <= MAX_WORD_LENGTH) {
- char *d = ALLOCV_N(char, vbuf, sl);
- l = shrink_space(d, s, l);
- s = d;
- }
+ else if (str_end_with(d, l, DST2)) {
+ l -= sizeof(DST2) - 1;
+ dst = 1;
}
- if (l > 0 && l <= MAX_WORD_LENGTH) {
+ {
const struct zone *z = zonetab(s, (unsigned int)l);
if (z) {
int d = z->offset;
@@ -460,8 +418,8 @@ date_zone_to_diff(VALUE str)
long hour = 0, min = 0, sec = 0;
if (l > 3 &&
- (strncasecmp(s, "gmt", 3) == 0 ||
- strncasecmp(s, "utc", 3) == 0)) {
+ (strncmp(s, "gmt", 3) == 0 ||
+ strncmp(s, "utc", 3) == 0)) {
s += 3;
l -= 3;
}
@@ -748,14 +706,16 @@ parse_era(VALUE str, VALUE hash)
static int
check_year_width(VALUE y)
{
- const char *s;
- long l;
+ char *s;
+ size_t l;
- l = RSTRING_LEN(y);
- if (l < 2) return 0;
s = RSTRING_PTR(y);
- if (!isdigit((unsigned char)s[1])) return 0;
- return (l == 2 || !isdigit((unsigned char)s[2]));
+ l = strcspn(s, DECDIGIT);
+ s += l;
+ l = strspn(s, DECDIGIT);
+ if (l != 2)
+ return 0;
+ return 1;
}
static int
@@ -1236,9 +1196,6 @@ parse_iso2(VALUE str, VALUE hash)
return 1;
}
-#define JISX0301_ERA_INITIALS "mtshr"
-#define JISX0301_DEFAULT_ERA 'H' /* obsolete */
-
static int
gengo(int c)
{
@@ -1249,7 +1206,6 @@ gengo(int c)
case 'T': case 't': e = 1911; break;
case 'S': case 's': e = 1925; break;
case 'H': case 'h': e = 1988; break;
- case 'R': case 'r': e = 2018; break;
default: e = 0; break;
}
return e;
@@ -1280,11 +1236,11 @@ parse_jis(VALUE str, VALUE hash)
{
static const char pat_source[] =
#ifndef TIGHT_PARSER
- "\\b([" JISX0301_ERA_INITIALS "])(\\d+)\\.(\\d+)\\.(\\d+)"
+ "\\b([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)"
#else
BOS
FPW_COM FPT_COM
- "([" JISX0301_ERA_INITIALS "])(\\d+)\\.(\\d+)\\.(\\d+)"
+ "([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)"
TEE_FPT COM_FPW
EOS
#endif
@@ -1887,26 +1843,30 @@ parse_ddd_cb(VALUE m, VALUE hash)
set_hash("zone", s5);
if (*cs5 == '[') {
- const char *s1, *s2;
+ VALUE vbuf = 0;
+ char *buf = ALLOCV_N(char, vbuf, l5 + 1);
+ char *s1, *s2, *s3;
VALUE zone;
- l5 -= 2;
- s1 = cs5 + 1;
- s2 = memchr(s1, ':', l5);
+ memcpy(buf, cs5, l5);
+ buf[l5 - 1] = '\0';
+
+ s1 = buf + 1;
+ s2 = strchr(buf, ':');
if (s2) {
+ *s2 = '\0';
s2++;
- zone = rb_str_subseq(s5, s2 - cs5, l5 - (s2 - s1));
- s5 = rb_str_subseq(s5, 1, s2 - s1);
}
- else {
- zone = rb_str_subseq(s5, 1, l5);
- if (isdigit((unsigned char)*s1))
- s5 = rb_str_append(rb_str_new_cstr("+"), zone);
- else
- s5 = zone;
- }
+ if (s2)
+ s3 = s2;
+ else
+ s3 = s1;
+ zone = rb_str_new2(s3);
set_hash("zone", zone);
- set_hash("offset", date_zone_to_diff(s5));
+ if (isdigit((unsigned char)*s1))
+ *--s1 = '+';
+ set_hash("offset", date_zone_to_diff(rb_str_new2(s1)));
+ ALLOCV_END(vbuf);
}
RB_GC_GUARD(s5);
}
@@ -2199,7 +2159,7 @@ date__parse(VALUE str, VALUE comp)
#endif
{
- if (RTEST(del_hash("_bc"))) {
+ if (RTEST(ref_hash("_bc"))) {
VALUE y;
y = ref_hash("cwyear");
@@ -2214,7 +2174,7 @@ date__parse(VALUE str, VALUE comp)
}
}
- if (RTEST(del_hash("_comp"))) {
+ if (RTEST(ref_hash("_comp"))) {
VALUE y;
y = ref_hash("cwyear");
@@ -2237,6 +2197,9 @@ date__parse(VALUE str, VALUE comp)
}
+ del_hash("_bc");
+ del_hash("_comp");
+
{
VALUE zone = ref_hash("zone");
if (!NIL_P(zone) && NIL_P(ref_hash("offset")))
@@ -2286,8 +2249,8 @@ iso8601_ext_datetime_cb(VALUE m, VALUE hash)
s[i] = rb_reg_nth_match(i, m);
}
- if (!NIL_P(s[1])) {
- if (!NIL_P(s[3])) set_hash("mday", str2num(s[3]));
+ if (!NIL_P(s[3])) {
+ set_hash("mday", str2num(s[3]));
if (strcmp(RSTRING_PTR(s[1]), "-") != 0) {
y = str2num(s[1]);
if (RSTRING_LEN(s[1]) < 4)
@@ -2344,7 +2307,7 @@ static int
iso8601_ext_datetime(VALUE str, VALUE hash)
{
static const char pat_source[] =
- "\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?(?:-(\\d{2}))?|"
+ "\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?-(\\d{2})|"
"([-+]?\\d{2,})?-(\\d{3})|"
"(\\d{4}|\\d{2})?-w(\\d{2})-(\\d)|"
"-w-(\\d))"
@@ -2975,7 +2938,7 @@ jisx0301_cb(VALUE m, VALUE hash)
s[i] = rb_reg_nth_match(i, m);
}
- ep = gengo(NIL_P(s[1]) ? JISX0301_DEFAULT_ERA : *RSTRING_PTR(s[1]));
+ ep = gengo(NIL_P(s[1]) ? 'h' : *RSTRING_PTR(s[1]));
set_hash("year", f_add(str2num(s[2]), INT2FIX(ep)));
set_hash("mon", str2num(s[3]));
set_hash("mday", str2num(s[4]));
@@ -3000,7 +2963,7 @@ static int
jisx0301(VALUE str, VALUE hash)
{
static const char pat_source[] =
- "\\A\\s*([" JISX0301_ERA_INITIALS "])?(\\d{2})\\.(\\d{2})\\.(\\d{2})"
+ "\\A\\s*([mtsh])?(\\d{2})\\.(\\d{2})\\.(\\d{2})"
"(?:t"
"(?:(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d*))?)?"
"(z|[-+]\\d{2}(?::?\\d{2})?)?)?)?\\s*\\z";
diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c
index 26d9fd11bf..4f93219317 100644
--- a/ext/date/date_strptime.c
+++ b/ext/date/date_strptime.c
@@ -79,17 +79,14 @@ read_digits(const char *s, VALUE *n, size_t width)
{
size_t l;
- if (!width)
- return 0;
-
- l = 0;
- while (ISDIGIT(s[l])) {
- if (++l == width) break;
- }
+ l = strspn(s, "0123456789");
if (l == 0)
return 0;
+ if (width < l)
+ l = width;
+
if ((4 * l * sizeof(char)) <= (sizeof(long)*CHAR_BIT)) {
const char *os = s;
long v;
@@ -116,26 +113,26 @@ read_digits(const char *s, VALUE *n, size_t width)
}
}
-#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k"")), v)
-#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k"")))
-#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k"")))
+#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
+#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
+#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
#define fail() \
-do { \
+{ \
set_hash("_fail", Qtrue); \
return 0; \
-} while (0)
+}
#define fail_p() (!NIL_P(ref_hash("_fail")))
#define READ_DIGITS(n,w) \
-do { \
+{ \
size_t l; \
l = read_digits(&str[si], &n, w); \
if (l == 0) \
fail(); \
si += l; \
-} while (0)
+}
#define READ_DIGITS_MAX(n) READ_DIGITS(n, LONG_MAX)
@@ -150,14 +147,14 @@ valid_range_p(VALUE v, int a, int b)
}
#define recur(fmt) \
-do { \
+{ \
size_t l; \
l = date__strptime_internal(&str[si], slen - si, \
fmt, sizeof fmt - 1, hash); \
if (fail_p()) \
return 0; \
si += l; \
-} while (0)
+}
VALUE date_zone_to_diff(VALUE);
@@ -240,9 +237,9 @@ date__strptime_internal(const char *str, size_t slen,
VALUE n;
if (NUM_PATTERN_P())
- READ_DIGITS(n, 2);
+ READ_DIGITS(n, 2)
else
- READ_DIGITS_MAX(n);
+ READ_DIGITS_MAX(n)
set_hash("_cent", n);
goto matched;
}
@@ -281,9 +278,9 @@ date__strptime_internal(const char *str, size_t slen,
VALUE n;
if (NUM_PATTERN_P())
- READ_DIGITS(n, 4);
+ READ_DIGITS(n, 4)
else
- READ_DIGITS_MAX(n);
+ READ_DIGITS_MAX(n)
set_hash("cwyear", n);
goto matched;
}
@@ -361,9 +358,9 @@ date__strptime_internal(const char *str, size_t slen,
}
osi = si;
if (NUM_PATTERN_P())
- READ_DIGITS(n, c == 'L' ? 3 : 9);
+ READ_DIGITS(n, c == 'L' ? 3 : 9)
else
- READ_DIGITS_MAX(n);
+ READ_DIGITS_MAX(n)
if (sign == -1)
n = f_negate(n);
set_hash("sec_fraction",
@@ -429,7 +426,9 @@ date__strptime_internal(const char *str, size_t slen,
if (sign == -1)
n = f_negate(n);
set_hash("seconds",
- rb_rational_new2(n, INT2FIX(1000)));
+ rb_rational_new2(n,
+ f_expt(INT2FIX(10),
+ INT2FIX(3))));
goto matched;
}
@@ -530,24 +529,24 @@ date__strptime_internal(const char *str, size_t slen,
goto matched;
case 'Y':
- {
- VALUE n;
- int sign = 1;
-
- if (issign(str[si])) {
- if (str[si] == '-')
- sign = -1;
- si++;
- }
- if (NUM_PATTERN_P())
- READ_DIGITS(n, 4);
- else
- READ_DIGITS_MAX(n);
+ {
+ VALUE n;
+ int sign = 1;
+
+ if (issign(str[si])) {
+ if (str[si] == '-')
+ sign = -1;
+ si++;
+ }
+ if (NUM_PATTERN_P())
+ READ_DIGITS(n, 4)
+ else
+ READ_DIGITS_MAX(n)
if (sign == -1)
n = f_negate(n);
- set_hash("year", n);
- goto matched;
- }
+ set_hash("year", n);
+ goto matched;
+ }
case 'y':
{
@@ -669,7 +668,7 @@ date__strptime(const char *str, size_t slen,
if (fail_p())
return Qnil;
- cent = del_hash("_cent");
+ cent = ref_hash("_cent");
if (!NIL_P(cent)) {
VALUE year;
@@ -679,9 +678,10 @@ date__strptime(const char *str, size_t slen,
year = ref_hash("year");
if (!NIL_P(year))
set_hash("year", f_add(year, f_mul(cent, INT2FIX(100))));
+ del_hash("_cent");
}
- merid = del_hash("_merid");
+ merid = ref_hash("_merid");
if (!NIL_P(merid)) {
VALUE hour;
@@ -690,6 +690,7 @@ date__strptime(const char *str, size_t slen,
hour = f_mod(hour, INT2FIX(12));
set_hash("hour", f_add(hour, merid));
}
+ del_hash("_merid");
}
return hash;
diff --git a/ext/date/depend b/ext/date/depend
index 28847bef13..864fcc5302 100644
--- a/ext/date/depend
+++ b/ext/date/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
date_core.o: $(RUBY_EXTCONF_H)
date_core.o: $(arch_hdrdir)/ruby/config.h
-date_core.o: $(hdrdir)/ruby.h
-date_core.o: $(hdrdir)/ruby/assert.h
date_core.o: $(hdrdir)/ruby/backward.h
date_core.o: $(hdrdir)/ruby/defines.h
date_core.o: $(hdrdir)/ruby/encoding.h
@@ -14,12 +12,11 @@ date_core.o: $(hdrdir)/ruby/ruby.h
date_core.o: $(hdrdir)/ruby/st.h
date_core.o: $(hdrdir)/ruby/subst.h
date_core.o: $(hdrdir)/ruby/util.h
+date_core.o: $(top_srcdir)/include/ruby.h
date_core.o: date_core.c
date_core.o: date_tmx.h
date_parse.o: $(RUBY_EXTCONF_H)
date_parse.o: $(arch_hdrdir)/ruby/config.h
-date_parse.o: $(hdrdir)/ruby.h
-date_parse.o: $(hdrdir)/ruby/assert.h
date_parse.o: $(hdrdir)/ruby/backward.h
date_parse.o: $(hdrdir)/ruby/defines.h
date_parse.o: $(hdrdir)/ruby/encoding.h
@@ -32,12 +29,12 @@ date_parse.o: $(hdrdir)/ruby/regex.h
date_parse.o: $(hdrdir)/ruby/ruby.h
date_parse.o: $(hdrdir)/ruby/st.h
date_parse.o: $(hdrdir)/ruby/subst.h
+date_parse.o: $(top_srcdir)/include/ruby.h
date_parse.o: date_parse.c
date_parse.o: zonetab.h
date_parse.o: zonetab.list
date_strftime.o: $(RUBY_EXTCONF_H)
date_strftime.o: $(arch_hdrdir)/ruby/config.h
-date_strftime.o: $(hdrdir)/ruby/assert.h
date_strftime.o: $(hdrdir)/ruby/backward.h
date_strftime.o: $(hdrdir)/ruby/defines.h
date_strftime.o: $(hdrdir)/ruby/intern.h
@@ -49,8 +46,6 @@ date_strftime.o: date_strftime.c
date_strftime.o: date_tmx.h
date_strptime.o: $(RUBY_EXTCONF_H)
date_strptime.o: $(arch_hdrdir)/ruby/config.h
-date_strptime.o: $(hdrdir)/ruby.h
-date_strptime.o: $(hdrdir)/ruby/assert.h
date_strptime.o: $(hdrdir)/ruby/backward.h
date_strptime.o: $(hdrdir)/ruby/defines.h
date_strptime.o: $(hdrdir)/ruby/encoding.h
@@ -63,5 +58,6 @@ date_strptime.o: $(hdrdir)/ruby/regex.h
date_strptime.o: $(hdrdir)/ruby/ruby.h
date_strptime.o: $(hdrdir)/ruby/st.h
date_strptime.o: $(hdrdir)/ruby/subst.h
+date_strptime.o: $(top_srcdir)/include/ruby.h
date_strptime.o: date_strptime.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/date/lib/date.rb b/ext/date/lib/date.rb
index 94abd6451a..9170a99ae9 100644
--- a/ext/date/lib/date.rb
+++ b/ext/date/lib/date.rb
@@ -4,11 +4,6 @@
require 'date_core'
class Date
- VERSION = '3.0.3' # :nodoc:
-
- def infinite?
- false
- end
class Infinity < Numeric # :nodoc:
diff --git a/ext/date/prereq.mk b/ext/date/prereq.mk
index fa371e0d47..c0c55d2c27 100644
--- a/ext/date/prereq.mk
+++ b/ext/date/prereq.mk
@@ -1,12 +1,8 @@
.SUFFIXES: .list
.list.h:
- gperf --ignore-case -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
+ gperf -E -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
| sed -f $(top_srcdir)/tool/gperf.sed \
> $(@F)
zonetab.h: zonetab.list
-
-.PHONY: update-zonetab
-update-zonetab:
- $(RUBY) -C $(srcdir) update-abbr.rb
diff --git a/ext/date/update-abbr b/ext/date/update-abbr
deleted file mode 100644
index e5f6a78c82..0000000000
--- a/ext/date/update-abbr
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- mode: ruby -*-
-require 'nokogiri'
-require 'open-uri'
-
-doc = Nokogiri::HTML(URI.open('https://www.timeanddate.com/time/zones/'))
-
-h = {}
-
-doc.css('#tz-abb tbody tr').each do |tr|
- tds = tr.css('td')
- abbr = tds[0].text.strip.downcase
- offset = tds[3].text.strip.gsub(/UTC\s*/, '')
- next if offset.include?('/') # skip ambiguous timezones
- next if offset.empty?
-
-
- hour, min = offset.split(':', 2)
- offset = (Integer(hour) * 60 + (Integer(min || 0)))*60
- if h.has_key?(abbr)
- h[abbr] = false
- else
- h[abbr] = offset
- end
-end
-
-h.delete_if{|_,v| !v}
-
-lines = File.readlines('zonetab.list')
-lines.select{|l| l.include?(',')}.
- map{|l| l.split(',', 2)[0]}.
- each{|a| h.delete(a)}
-
-lines.insert(-2, h.sort.map{|k,v| "#{k},#{v}\n"})
-lines.flatten!
-File.write('zonetab.list', lines.join)
diff --git a/ext/date/zonetab.h b/ext/date/zonetab.h
index 379f78e1b8..2dfa9b988a 100644
--- a/ext/date/zonetab.h
+++ b/ext/date/zonetab.h
@@ -1,6 +1,6 @@
/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf --ignore-case -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list */
-/* Computed positions: -k'1-4,9' */
+/* Command-line: gperf -E -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list */
+/* Computed positions: -k'1-4,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -39,58 +39,7 @@ struct zone {
static const struct zone *zonetab();
#line 9 "zonetab.list"
struct zone;
-
-#define TOTAL_KEYWORDS 316
-#define MIN_WORD_LENGTH 1
-#define MAX_WORD_LENGTH 17
-#define MIN_HASH_VALUE 2
-#define MAX_HASH_VALUE 619
-/* maximum key range = 618, duplicates = 0 */
-
-#ifndef GPERF_DOWNCASE
-#define GPERF_DOWNCASE 1
-static unsigned char gperf_downcase[256] =
- {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
- 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
- 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
- 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
- 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
- 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
- 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
- 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
- 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
- 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
- 255
- };
-#endif
-
-#ifndef GPERF_CASE_STRNCMP
-#define GPERF_CASE_STRNCMP 1
-static int
-gperf_case_strncmp (register const char *s1, register const char *s2, register size_t n)
-{
- for (; n > 0;)
- {
- unsigned char c1 = gperf_downcase[(unsigned char)*s1++];
- unsigned char c2 = gperf_downcase[(unsigned char)*s2++];
- if (c1 != 0 && c1 == c2)
- {
- n--;
- continue;
- }
- return (int)c1 - (int)c2;
- }
- return 0;
-}
-#endif
+/* maximum key range = 434, duplicates = 0 */
#ifdef __GNUC__
__inline
@@ -104,1440 +53,824 @@ hash (register const char *str, register size_t len)
{
static const unsigned short asso_values[] =
{
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 17, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 3, 2, 620, 620, 620,
- 620, 620, 70, 8, 3, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 39, 176, 207, 70, 168,
- 1, 5, 18, 74, 218, 2, 117, 130, 48, 88,
- 125, 225, 92, 1, 1, 12, 54, 30, 36, 13,
- 48, 168, 263, 59, 114, 166, 109, 39, 176, 207,
- 70, 168, 1, 5, 18, 74, 218, 2, 117, 130,
- 48, 88, 125, 225, 92, 1, 1, 12, 54, 30,
- 36, 13, 48, 168, 263, 59, 114, 166, 109, 27,
- 104, 1, 9, 4, 309, 190, 188, 177, 255, 108,
- 2, 341, 3, 620, 620, 620, 620, 620, 620, 12,
- 54, 30, 36, 13, 48, 168, 263, 59, 114, 166,
- 109, 27, 104, 1, 9, 4, 309, 190, 188, 177,
- 255, 108, 2, 341, 3, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620, 620, 620,
- 620, 620, 620, 620, 620, 620, 620, 620
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 19, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 2, 4, 439, 439, 439,
+ 439, 439, 8, 6, 3, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 7, 63, 53,
+ 2, 4, 32, 110, 88, 78, 90, 68, 47, 108,
+ 10, 73, 81, 124, 3, 1, 4, 77, 116, 88,
+ 15, 96, 45, 5, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439, 439, 439, 439,
+ 439, 439, 439, 439, 439, 439, 439
};
register unsigned int hval = (unsigned int)len;
switch (hval)
{
default:
- hval += asso_values[(unsigned char)str[8]];
- /*FALLTHROUGH*/
- case 8:
- case 7:
- case 6:
- case 5:
- case 4:
hval += asso_values[(unsigned char)str[3]];
/*FALLTHROUGH*/
case 3:
hval += asso_values[(unsigned char)str[2]];
/*FALLTHROUGH*/
case 2:
- hval += asso_values[(unsigned char)str[1]+6];
+ hval += asso_values[(unsigned char)str[1]];
/*FALLTHROUGH*/
case 1:
- hval += asso_values[(unsigned char)str[0]+52];
+ hval += asso_values[(unsigned char)str[0]+1];
break;
}
- return (unsigned int)hval;
+ return (unsigned int)hval + asso_values[(unsigned char)str[len - 1]];
}
struct stringpool_t
{
- char stringpool_str2[sizeof("o")];
- char stringpool_str3[sizeof("x")];
- char stringpool_str4[sizeof("z")];
- char stringpool_str5[sizeof("q")];
- char stringpool_str8[sizeof("omst")];
- char stringpool_str9[sizeof("omsst")];
- char stringpool_str10[sizeof("p")];
- char stringpool_str13[sizeof("a")];
- char stringpool_str14[sizeof("e")];
- char stringpool_str15[sizeof("pet")];
- char stringpool_str16[sizeof("pmst")];
- char stringpool_str17[sizeof("pett")];
- char stringpool_str18[sizeof("petst")];
- char stringpool_str19[sizeof("eet")];
- char stringpool_str20[sizeof("aest")];
- char stringpool_str21[sizeof("eest")];
- char stringpool_str22[sizeof("eat")];
- char stringpool_str24[sizeof("east")];
- char stringpool_str25[sizeof("easst")];
- char stringpool_str26[sizeof("pst")];
- char stringpool_str27[sizeof("eastern")];
- char stringpool_str28[sizeof("m")];
- char stringpool_str29[sizeof("ast")];
- char stringpool_str30[sizeof("est")];
- char stringpool_str31[sizeof("c")];
- char stringpool_str32[sizeof("mmt")];
- char stringpool_str33[sizeof("met")];
- char stringpool_str35[sizeof("mest")];
- char stringpool_str36[sizeof("cet")];
- char stringpool_str37[sizeof("d")];
- char stringpool_str38[sizeof("cest")];
- char stringpool_str39[sizeof("cat")];
- char stringpool_str41[sizeof("cast")];
- char stringpool_str42[sizeof("magt")];
- char stringpool_str43[sizeof("magst")];
- char stringpool_str44[sizeof("mst")];
- char stringpool_str45[sizeof("msk")];
- char stringpool_str46[sizeof("cot")];
- char stringpool_str47[sizeof("cst")];
- char stringpool_str48[sizeof("aqtt")];
- char stringpool_str49[sizeof("f")];
- char stringpool_str52[sizeof("art")];
- char stringpool_str53[sizeof("fnt")];
- char stringpool_str54[sizeof("fet")];
- char stringpool_str55[sizeof("b")];
- char stringpool_str57[sizeof("anat")];
- char stringpool_str58[sizeof("anast")];
- char stringpool_str59[sizeof("bnt")];
- char stringpool_str60[sizeof("i")];
- char stringpool_str61[sizeof("pht")];
- char stringpool_str62[sizeof("at")];
- char stringpool_str63[sizeof("zp6")];
- char stringpool_str64[sizeof("mewt")];
- char stringpool_str65[sizeof("fst")];
- char stringpool_str66[sizeof("ahst")];
- char stringpool_str67[sizeof("mawt")];
- char stringpool_str68[sizeof("zp5")];
- char stringpool_str70[sizeof("bot")];
- char stringpool_str71[sizeof("bst")];
- char stringpool_str72[sizeof("pwt")];
- char stringpool_str74[sizeof("pont")];
- char stringpool_str75[sizeof("iot")];
- char stringpool_str76[sizeof("ist")];
- char stringpool_str77[sizeof("awst")];
- char stringpool_str79[sizeof("mht")];
- char stringpool_str80[sizeof("mez")];
- char stringpool_str81[sizeof("orat")];
- char stringpool_str82[sizeof("mesz")];
- char stringpool_str84[sizeof("chst")];
- char stringpool_str85[sizeof("pmdt")];
- char stringpool_str88[sizeof("central")];
- char stringpool_str89[sizeof("aedt")];
- char stringpool_str90[sizeof("act")];
- char stringpool_str91[sizeof("ect")];
- char stringpool_str92[sizeof("acst")];
- char stringpool_str93[sizeof("eadt")];
- char stringpool_str94[sizeof("brt")];
- char stringpool_str95[sizeof("chut")];
- char stringpool_str96[sizeof("brst")];
- char stringpool_str97[sizeof("cen. australia")];
- char stringpool_str100[sizeof("davt")];
- char stringpool_str101[sizeof("irst")];
- char stringpool_str102[sizeof("irkt")];
- char stringpool_str103[sizeof("irkst")];
- char stringpool_str104[sizeof("bt")];
- char stringpool_str105[sizeof("n")];
- char stringpool_str106[sizeof("btt")];
- char stringpool_str107[sizeof("mountain")];
- char stringpool_str108[sizeof("cct")];
- char stringpool_str109[sizeof("w")];
- char stringpool_str110[sizeof("l")];
- char stringpool_str111[sizeof("fwt")];
- char stringpool_str113[sizeof("msd")];
- char stringpool_str114[sizeof("wet")];
- char stringpool_str116[sizeof("west")];
- char stringpool_str117[sizeof("wat")];
- char stringpool_str119[sizeof("wast")];
- char stringpool_str120[sizeof("wakt")];
- char stringpool_str121[sizeof("nst")];
- char stringpool_str122[sizeof("acwst")];
- char stringpool_str123[sizeof("chast")];
- char stringpool_str124[sizeof("cist")];
- char stringpool_str125[sizeof("azt")];
- char stringpool_str126[sizeof("clt")];
- char stringpool_str127[sizeof("azst")];
- char stringpool_str128[sizeof("clst")];
- char stringpool_str129[sizeof("mart")];
- char stringpool_str130[sizeof("zp4")];
- char stringpool_str131[sizeof("jst")];
- char stringpool_str132[sizeof("central asia")];
- char stringpool_str133[sizeof("aft")];
- char stringpool_str134[sizeof("e. south america")];
- char stringpool_str135[sizeof("central america")];
- char stringpool_str137[sizeof("ict")];
- char stringpool_str143[sizeof("pgt")];
- char stringpool_str144[sizeof("nrt")];
- char stringpool_str145[sizeof("mexico")];
- char stringpool_str146[sizeof("awdt")];
- char stringpool_str147[sizeof("egt")];
- char stringpool_str148[sizeof("cxt")];
- char stringpool_str149[sizeof("egst")];
- char stringpool_str150[sizeof("phot")];
- char stringpool_str151[sizeof("alaskan")];
- char stringpool_str154[sizeof("nt")];
- char stringpool_str158[sizeof("wt")];
- char stringpool_str160[sizeof("west asia")];
- char stringpool_str161[sizeof("acdt")];
- char stringpool_str162[sizeof("npt")];
- char stringpool_str163[sizeof("lhst")];
- char stringpool_str164[sizeof("afghanistan")];
- char stringpool_str167[sizeof("k")];
- char stringpool_str169[sizeof("g")];
- char stringpool_str170[sizeof("irdt")];
- char stringpool_str171[sizeof("chot")];
- char stringpool_str172[sizeof("chost")];
- char stringpool_str173[sizeof("gmt")];
- char stringpool_str174[sizeof("get")];
- char stringpool_str175[sizeof("novt")];
- char stringpool_str176[sizeof("novst")];
- char stringpool_str177[sizeof("fjt")];
- char stringpool_str178[sizeof("u")];
- char stringpool_str179[sizeof("fjst")];
- char stringpool_str181[sizeof("pyst")];
- char stringpool_str182[sizeof("nct")];
- char stringpool_str183[sizeof("kst")];
- char stringpool_str184[sizeof("kost")];
- char stringpool_str185[sizeof("gst")];
- char stringpool_str186[sizeof("iran")];
- char stringpool_str187[sizeof("e. africa")];
- char stringpool_str188[sizeof("wadt")];
- char stringpool_str189[sizeof("t")];
- char stringpool_str190[sizeof("e. australia")];
- char stringpool_str191[sizeof("s")];
- char stringpool_str192[sizeof("chadt")];
- char stringpool_str193[sizeof("tmt")];
- char stringpool_str194[sizeof("cidst")];
- char stringpool_str195[sizeof("aoe")];
- char stringpool_str197[sizeof("myt")];
- char stringpool_str198[sizeof("west pacific")];
- char stringpool_str199[sizeof("mut")];
- char stringpool_str200[sizeof("wit")];
- char stringpool_str201[sizeof("sast")];
- char stringpool_str202[sizeof("sakt")];
- char stringpool_str203[sizeof("new zealand")];
- char stringpool_str204[sizeof("tot")];
- char stringpool_str205[sizeof("china")];
- char stringpool_str206[sizeof("tost")];
- char stringpool_str207[sizeof("sst")];
- char stringpool_str209[sizeof("india")];
- char stringpool_str211[sizeof("warst")];
- char stringpool_str212[sizeof("sbt")];
- char stringpool_str214[sizeof("azot")];
- char stringpool_str215[sizeof("azost")];
- char stringpool_str216[sizeof("taht")];
- char stringpool_str217[sizeof("nzt")];
- char stringpool_str218[sizeof("dateline")];
- char stringpool_str219[sizeof("nzst")];
- char stringpool_str220[sizeof("tokyo")];
- char stringpool_str221[sizeof("central pacific")];
- char stringpool_str223[sizeof("qyzt")];
- char stringpool_str224[sizeof("atlantic")];
- char stringpool_str225[sizeof("nft")];
- char stringpool_str227[sizeof("ut")];
- char stringpool_str228[sizeof("trt")];
- char stringpool_str229[sizeof("wft")];
- char stringpool_str230[sizeof("srt")];
- char stringpool_str231[sizeof("pdt")];
- char stringpool_str232[sizeof("lhdt")];
- char stringpool_str234[sizeof("adt")];
- char stringpool_str235[sizeof("edt")];
- char stringpool_str238[sizeof("pkt")];
- char stringpool_str239[sizeof("almt")];
- char stringpool_str240[sizeof("wita")];
- char stringpool_str242[sizeof("wgt")];
- char stringpool_str243[sizeof("akst")];
- char stringpool_str244[sizeof("wgst")];
- char stringpool_str246[sizeof("krat")];
- char stringpool_str247[sizeof("krast")];
- char stringpool_str248[sizeof("mid-atlantic")];
- char stringpool_str249[sizeof("mdt")];
- char stringpool_str250[sizeof("lint")];
- char stringpool_str251[sizeof("malay peninsula")];
- char stringpool_str252[sizeof("cdt")];
- char stringpool_str253[sizeof("swt")];
- char stringpool_str255[sizeof("se asia")];
- char stringpool_str256[sizeof("v")];
- char stringpool_str258[sizeof("tonga")];
- char stringpool_str259[sizeof("ckt")];
- char stringpool_str261[sizeof("vet")];
- char stringpool_str262[sizeof("caucasus")];
- char stringpool_str263[sizeof("central europe")];
- char stringpool_str264[sizeof("h")];
- char stringpool_str265[sizeof("central european")];
- char stringpool_str266[sizeof("newfoundland")];
- char stringpool_str267[sizeof("arab")];
- char stringpool_str268[sizeof("sct")];
- char stringpool_str269[sizeof("arabic")];
- char stringpool_str270[sizeof("arabian")];
- char stringpool_str271[sizeof("ddut")];
- char stringpool_str273[sizeof("vost")];
- char stringpool_str274[sizeof("hast")];
- char stringpool_str275[sizeof("nepal")];
- char stringpool_str276[sizeof("nut")];
- char stringpool_str277[sizeof("fkt")];
- char stringpool_str279[sizeof("fkst")];
- char stringpool_str280[sizeof("hst")];
- char stringpool_str281[sizeof("idt")];
- char stringpool_str284[sizeof("tlt")];
- char stringpool_str285[sizeof("w. australia")];
- char stringpool_str286[sizeof("egypt")];
- char stringpool_str287[sizeof("myanmar")];
- char stringpool_str288[sizeof("nzdt")];
- char stringpool_str289[sizeof("gft")];
- char stringpool_str290[sizeof("uzt")];
- char stringpool_str293[sizeof("north asia")];
- char stringpool_str294[sizeof("mvt")];
- char stringpool_str295[sizeof("galt")];
- char stringpool_str296[sizeof("nfdt")];
- char stringpool_str297[sizeof("cvt")];
- char stringpool_str298[sizeof("north asia east")];
- char stringpool_str300[sizeof("kgt")];
- char stringpool_str301[sizeof("aus central")];
- char stringpool_str302[sizeof("pacific")];
- char stringpool_str304[sizeof("canada central")];
- char stringpool_str306[sizeof("pacific sa")];
- char stringpool_str307[sizeof("azores")];
- char stringpool_str308[sizeof("gamt")];
- char stringpool_str309[sizeof("tft")];
- char stringpool_str310[sizeof("r")];
- char stringpool_str311[sizeof("fle")];
- char stringpool_str312[sizeof("akdt")];
- char stringpool_str313[sizeof("ulat")];
- char stringpool_str314[sizeof("ulast")];
- char stringpool_str315[sizeof("ret")];
- char stringpool_str317[sizeof("tjt")];
- char stringpool_str319[sizeof("south africa")];
- char stringpool_str324[sizeof("sgt")];
- char stringpool_str326[sizeof("ndt")];
- char stringpool_str327[sizeof("rott")];
- char stringpool_str330[sizeof("samt")];
- char stringpool_str332[sizeof("tasmania")];
- char stringpool_str334[sizeof("hovt")];
- char stringpool_str335[sizeof("hovst")];
- char stringpool_str338[sizeof("gyt")];
- char stringpool_str342[sizeof("y")];
- char stringpool_str343[sizeof("hadt")];
- char stringpool_str344[sizeof("sa western")];
- char stringpool_str345[sizeof("hawaiian")];
- char stringpool_str347[sizeof("uyt")];
- char stringpool_str349[sizeof("uyst")];
- char stringpool_str350[sizeof("yekt")];
- char stringpool_str351[sizeof("yekst")];
- char stringpool_str352[sizeof("kuyt")];
- char stringpool_str353[sizeof("yakt")];
- char stringpool_str354[sizeof("yakst")];
- char stringpool_str358[sizeof("yst")];
- char stringpool_str359[sizeof("jerusalem")];
- char stringpool_str365[sizeof("sri lanka")];
- char stringpool_str367[sizeof("yakutsk")];
- char stringpool_str375[sizeof("wib")];
- char stringpool_str377[sizeof("aus eastern")];
- char stringpool_str378[sizeof("gilt")];
- char stringpool_str387[sizeof("us mountain")];
- char stringpool_str391[sizeof("vlat")];
- char stringpool_str392[sizeof("vlast")];
- char stringpool_str395[sizeof("gtb")];
- char stringpool_str398[sizeof("taipei")];
- char stringpool_str399[sizeof("sret")];
- char stringpool_str408[sizeof("cape verde")];
- char stringpool_str417[sizeof("tkt")];
- char stringpool_str418[sizeof("samoa")];
- char stringpool_str421[sizeof("sa pacific")];
- char stringpool_str427[sizeof("vut")];
- char stringpool_str428[sizeof("idlw")];
- char stringpool_str432[sizeof("fiji")];
- char stringpool_str435[sizeof("utc")];
- char stringpool_str443[sizeof("korea")];
- char stringpool_str445[sizeof("e. europe")];
- char stringpool_str449[sizeof("syot")];
- char stringpool_str452[sizeof("n. central asia")];
- char stringpool_str455[sizeof("tvt")];
- char stringpool_str458[sizeof("w. central africa")];
- char stringpool_str466[sizeof("ekaterinburg")];
- char stringpool_str468[sizeof("vladivostok")];
- char stringpool_str476[sizeof("yapt")];
- char stringpool_str477[sizeof("us eastern")];
- char stringpool_str482[sizeof("sa eastern")];
- char stringpool_str485[sizeof("hdt")];
- char stringpool_str486[sizeof("russian")];
- char stringpool_str492[sizeof("hkt")];
- char stringpool_str497[sizeof("romance")];
- char stringpool_str540[sizeof("w. europe")];
- char stringpool_str563[sizeof("ydt")];
- char stringpool_str566[sizeof("idle")];
- char stringpool_str567[sizeof("greenwich")];
- char stringpool_str619[sizeof("greenland")];
+ char stringpool_str5[sizeof("r")];
+ char stringpool_str6[sizeof("s")];
+ char stringpool_str7[sizeof("d")];
+ char stringpool_str14[sizeof("cst")];
+ char stringpool_str15[sizeof("cdt")];
+ char stringpool_str16[sizeof("sst")];
+ char stringpool_str17[sizeof("cet")];
+ char stringpool_str18[sizeof("msd")];
+ char stringpool_str19[sizeof("cest")];
+ char stringpool_str20[sizeof("cat")];
+ char stringpool_str22[sizeof("mst")];
+ char stringpool_str23[sizeof("mdt")];
+ char stringpool_str24[sizeof("sast")];
+ char stringpool_str25[sizeof("met")];
+ char stringpool_str27[sizeof("mest")];
+ char stringpool_str30[sizeof("wet")];
+ char stringpool_str31[sizeof("dateline")];
+ char stringpool_str32[sizeof("west")];
+ char stringpool_str33[sizeof("wat")];
+ char stringpool_str35[sizeof("wast")];
+ char stringpool_str36[sizeof("wadt")];
+ char stringpool_str37[sizeof("e")];
+ char stringpool_str38[sizeof("central europe")];
+ char stringpool_str39[sizeof("central asia")];
+ char stringpool_str40[sizeof("west asia")];
+ char stringpool_str41[sizeof("cen. australia")];
+ char stringpool_str42[sizeof("central america")];
+ char stringpool_str44[sizeof("est")];
+ char stringpool_str45[sizeof("edt")];
+ char stringpool_str46[sizeof("central european")];
+ char stringpool_str47[sizeof("eet")];
+ char stringpool_str48[sizeof("se asia")];
+ char stringpool_str49[sizeof("eest")];
+ char stringpool_str50[sizeof("eat")];
+ char stringpool_str51[sizeof("z")];
+ char stringpool_str52[sizeof("east")];
+ char stringpool_str53[sizeof("eadt")];
+ char stringpool_str54[sizeof("sa eastern")];
+ char stringpool_str55[sizeof("w. europe")];
+ char stringpool_str56[sizeof("c")];
+ char stringpool_str57[sizeof("yst")];
+ char stringpool_str58[sizeof("ydt")];
+ char stringpool_str59[sizeof("kst")];
+ char stringpool_str60[sizeof("clt")];
+ char stringpool_str61[sizeof("eastern")];
+ char stringpool_str62[sizeof("clst")];
+ char stringpool_str63[sizeof("bt")];
+ char stringpool_str64[sizeof("w. australia")];
+ char stringpool_str65[sizeof("bst")];
+ char stringpool_str66[sizeof("cct")];
+ char stringpool_str67[sizeof("brt")];
+ char stringpool_str69[sizeof("brst")];
+ char stringpool_str71[sizeof("a")];
+ char stringpool_str72[sizeof("e. europe")];
+ char stringpool_str73[sizeof("at")];
+ char stringpool_str74[sizeof("central")];
+ char stringpool_str75[sizeof("ast")];
+ char stringpool_str76[sizeof("adt")];
+ char stringpool_str77[sizeof("art")];
+ char stringpool_str78[sizeof("e. africa")];
+ char stringpool_str79[sizeof("e. south america")];
+ char stringpool_str80[sizeof("jst")];
+ char stringpool_str81[sizeof("e. australia")];
+ char stringpool_str82[sizeof("t")];
+ char stringpool_str83[sizeof("nt")];
+ char stringpool_str84[sizeof("n")];
+ char stringpool_str85[sizeof("nst")];
+ char stringpool_str86[sizeof("ndt")];
+ char stringpool_str87[sizeof("canada central")];
+ char stringpool_str88[sizeof("central pacific")];
+ char stringpool_str89[sizeof("west pacific")];
+ char stringpool_str90[sizeof("hst")];
+ char stringpool_str91[sizeof("hdt")];
+ char stringpool_str93[sizeof("malay peninsula")];
+ char stringpool_str95[sizeof("zp6")];
+ char stringpool_str97[sizeof("russian")];
+ char stringpool_str98[sizeof("hast")];
+ char stringpool_str99[sizeof("hadt")];
+ char stringpool_str100[sizeof("gst")];
+ char stringpool_str101[sizeof("zp5")];
+ char stringpool_str102[sizeof("ist")];
+ char stringpool_str103[sizeof("swt")];
+ char stringpool_str104[sizeof("w")];
+ char stringpool_str105[sizeof("zp4")];
+ char stringpool_str107[sizeof("mez")];
+ char stringpool_str108[sizeof("cape verde")];
+ char stringpool_str109[sizeof("mesz")];
+ char stringpool_str110[sizeof("greenland")];
+ char stringpool_str112[sizeof("x")];
+ char stringpool_str114[sizeof("mewt")];
+ char stringpool_str115[sizeof("w. central africa")];
+ char stringpool_str116[sizeof("k")];
+ char stringpool_str117[sizeof("b")];
+ char stringpool_str119[sizeof("m")];
+ char stringpool_str120[sizeof("sri lanka")];
+ char stringpool_str122[sizeof("fst")];
+ char stringpool_str124[sizeof("iran")];
+ char stringpool_str125[sizeof("sgt")];
+ char stringpool_str126[sizeof("ut")];
+ char stringpool_str128[sizeof("q")];
+ char stringpool_str129[sizeof("nzt")];
+ char stringpool_str131[sizeof("nzst")];
+ char stringpool_str132[sizeof("nzdt")];
+ char stringpool_str133[sizeof("myanmar")];
+ char stringpool_str135[sizeof("alaskan")];
+ char stringpool_str136[sizeof("pst")];
+ char stringpool_str137[sizeof("pdt")];
+ char stringpool_str138[sizeof("sa western")];
+ char stringpool_str139[sizeof("korea")];
+ char stringpool_str142[sizeof("y")];
+ char stringpool_str143[sizeof("f")];
+ char stringpool_str144[sizeof("akst")];
+ char stringpool_str145[sizeof("akdt")];
+ char stringpool_str148[sizeof("caucasus")];
+ char stringpool_str150[sizeof("msk")];
+ char stringpool_str151[sizeof("idle")];
+ char stringpool_str153[sizeof("arabian")];
+ char stringpool_str155[sizeof("o")];
+ char stringpool_str156[sizeof("l")];
+ char stringpool_str157[sizeof("mid-atlantic")];
+ char stringpool_str160[sizeof("us eastern")];
+ char stringpool_str164[sizeof("ahst")];
+ char stringpool_str167[sizeof("h")];
+ char stringpool_str168[sizeof("fle")];
+ char stringpool_str169[sizeof("i")];
+ char stringpool_str170[sizeof("north asia")];
+ char stringpool_str171[sizeof("n. central asia")];
+ char stringpool_str172[sizeof("north asia east")];
+ char stringpool_str174[sizeof("sa pacific")];
+ char stringpool_str177[sizeof("south africa")];
+ char stringpool_str181[sizeof("aus eastern")];
+ char stringpool_str182[sizeof("atlantic")];
+ char stringpool_str186[sizeof("mexico")];
+ char stringpool_str188[sizeof("mountain")];
+ char stringpool_str190[sizeof("china")];
+ char stringpool_str191[sizeof("azores")];
+ char stringpool_str192[sizeof("india")];
+ char stringpool_str194[sizeof("u")];
+ char stringpool_str195[sizeof("arabic")];
+ char stringpool_str196[sizeof("greenwich")];
+ char stringpool_str197[sizeof("new zealand")];
+ char stringpool_str198[sizeof("hawaiian")];
+ char stringpool_str199[sizeof("g")];
+ char stringpool_str200[sizeof("romance")];
+ char stringpool_str203[sizeof("arab")];
+ char stringpool_str204[sizeof("samoa")];
+ char stringpool_str205[sizeof("v")];
+ char stringpool_str206[sizeof("p")];
+ char stringpool_str207[sizeof("gmt")];
+ char stringpool_str208[sizeof("tasmania")];
+ char stringpool_str209[sizeof("fwt")];
+ char stringpool_str211[sizeof("newfoundland")];
+ char stringpool_str217[sizeof("nepal")];
+ char stringpool_str218[sizeof("aus central")];
+ char stringpool_str221[sizeof("gtb")];
+ char stringpool_str223[sizeof("vladivostok")];
+ char stringpool_str229[sizeof("utc")];
+ char stringpool_str233[sizeof("ekaterinburg")];
+ char stringpool_str265[sizeof("us mountain")];
+ char stringpool_str269[sizeof("jerusalem")];
+ char stringpool_str272[sizeof("yakutsk")];
+ char stringpool_str279[sizeof("pacific sa")];
+ char stringpool_str282[sizeof("tonga")];
+ char stringpool_str314[sizeof("afghanistan")];
+ char stringpool_str319[sizeof("idlw")];
+ char stringpool_str322[sizeof("pacific")];
+ char stringpool_str327[sizeof("taipei")];
+ char stringpool_str328[sizeof("egypt")];
+ char stringpool_str392[sizeof("tokyo")];
+ char stringpool_str438[sizeof("fiji")];
};
static const struct stringpool_t stringpool_contents =
{
- "o",
- "x",
- "z",
- "q",
- "omst",
- "omsst",
- "p",
- "a",
+ "r",
+ "s",
+ "d",
+ "cst",
+ "cdt",
+ "sst",
+ "cet",
+ "msd",
+ "cest",
+ "cat",
+ "mst",
+ "mdt",
+ "sast",
+ "met",
+ "mest",
+ "wet",
+ "dateline",
+ "west",
+ "wat",
+ "wast",
+ "wadt",
"e",
- "pet",
- "pmst",
- "pett",
- "petst",
+ "central europe",
+ "central asia",
+ "west asia",
+ "cen. australia",
+ "central america",
+ "est",
+ "edt",
+ "central european",
"eet",
- "aest",
+ "se asia",
"eest",
"eat",
+ "z",
"east",
- "easst",
- "pst",
+ "eadt",
+ "sa eastern",
+ "w. europe",
+ "c",
+ "yst",
+ "ydt",
+ "kst",
+ "clt",
"eastern",
- "m",
+ "clst",
+ "bt",
+ "w. australia",
+ "bst",
+ "cct",
+ "brt",
+ "brst",
+ "a",
+ "e. europe",
+ "at",
+ "central",
"ast",
- "est",
- "c",
- "mmt",
- "met",
- "mest",
- "cet",
- "d",
- "cest",
- "cat",
- "cast",
- "magt",
- "magst",
- "mst",
- "msk",
- "cot",
- "cst",
- "aqtt",
- "f",
+ "adt",
"art",
- "fnt",
- "fet",
- "b",
- "anat",
- "anast",
- "bnt",
- "i",
- "pht",
- "at",
+ "e. africa",
+ "e. south america",
+ "jst",
+ "e. australia",
+ "t",
+ "nt",
+ "n",
+ "nst",
+ "ndt",
+ "canada central",
+ "central pacific",
+ "west pacific",
+ "hst",
+ "hdt",
+ "malay peninsula",
"zp6",
- "mewt",
- "fst",
- "ahst",
- "mawt",
+ "russian",
+ "hast",
+ "hadt",
+ "gst",
"zp5",
- "bot",
- "bst",
- "pwt",
- "pont",
- "iot",
"ist",
- "awst",
- "mht",
- "mez",
- "orat",
- "mesz",
- "chst",
- "pmdt",
- "central",
- "aedt",
- "act",
- "ect",
- "acst",
- "eadt",
- "brt",
- "chut",
- "brst",
- "cen. australia",
- "davt",
- "irst",
- "irkt",
- "irkst",
- "bt",
- "n",
- "btt",
- "mountain",
- "cct",
+ "swt",
"w",
- "l",
- "fwt",
- "msd",
- "wet",
- "west",
- "wat",
- "wast",
- "wakt",
- "nst",
- "acwst",
- "chast",
- "cist",
- "azt",
- "clt",
- "azst",
- "clst",
- "mart",
"zp4",
- "jst",
- "central asia",
- "aft",
- "e. south america",
- "central america",
- "ict",
- "pgt",
- "nrt",
- "mexico",
- "awdt",
- "egt",
- "cxt",
- "egst",
- "phot",
- "alaskan",
- "nt",
- "wt",
- "west asia",
- "acdt",
- "npt",
- "lhst",
- "afghanistan",
+ "mez",
+ "cape verde",
+ "mesz",
+ "greenland",
+ "x",
+ "mewt",
+ "w. central africa",
"k",
- "g",
- "irdt",
- "chot",
- "chost",
- "gmt",
- "get",
- "novt",
- "novst",
- "fjt",
- "u",
- "fjst",
- "pyst",
- "nct",
- "kst",
- "kost",
- "gst",
+ "b",
+ "m",
+ "sri lanka",
+ "fst",
"iran",
- "e. africa",
- "wadt",
- "t",
- "e. australia",
- "s",
- "chadt",
- "tmt",
- "cidst",
- "aoe",
- "myt",
- "west pacific",
- "mut",
- "wit",
- "sast",
- "sakt",
- "new zealand",
- "tot",
- "china",
- "tost",
- "sst",
- "india",
- "warst",
- "sbt",
- "azot",
- "azost",
- "taht",
+ "sgt",
+ "ut",
+ "q",
"nzt",
- "dateline",
"nzst",
- "tokyo",
- "central pacific",
- "qyzt",
- "atlantic",
- "nft",
- "ut",
- "trt",
- "wft",
- "srt",
+ "nzdt",
+ "myanmar",
+ "alaskan",
+ "pst",
"pdt",
- "lhdt",
- "adt",
- "edt",
- "pkt",
- "almt",
- "wita",
- "wgt",
+ "sa western",
+ "korea",
+ "y",
+ "f",
"akst",
- "wgst",
- "krat",
- "krast",
- "mid-atlantic",
- "mdt",
- "lint",
- "malay peninsula",
- "cdt",
- "swt",
- "se asia",
- "v",
- "tonga",
- "ckt",
- "vet",
+ "akdt",
"caucasus",
- "central europe",
- "h",
- "central european",
- "newfoundland",
- "arab",
- "sct",
- "arabic",
+ "msk",
+ "idle",
"arabian",
- "ddut",
- "vost",
- "hast",
- "nepal",
- "nut",
- "fkt",
- "fkst",
- "hst",
- "idt",
- "tlt",
- "w. australia",
- "egypt",
- "myanmar",
- "nzdt",
- "gft",
- "uzt",
+ "o",
+ "l",
+ "mid-atlantic",
+ "us eastern",
+ "ahst",
+ "h",
+ "fle",
+ "i",
"north asia",
- "mvt",
- "galt",
- "nfdt",
- "cvt",
+ "n. central asia",
"north asia east",
- "kgt",
- "aus central",
- "pacific",
- "canada central",
- "pacific sa",
- "azores",
- "gamt",
- "tft",
- "r",
- "fle",
- "akdt",
- "ulat",
- "ulast",
- "ret",
- "tjt",
+ "sa pacific",
"south africa",
- "sgt",
- "ndt",
- "rott",
- "samt",
- "tasmania",
- "hovt",
- "hovst",
- "gyt",
- "y",
- "hadt",
- "sa western",
- "hawaiian",
- "uyt",
- "uyst",
- "yekt",
- "yekst",
- "kuyt",
- "yakt",
- "yakst",
- "yst",
- "jerusalem",
- "sri lanka",
- "yakutsk",
- "wib",
"aus eastern",
- "gilt",
- "us mountain",
- "vlat",
- "vlast",
- "gtb",
- "taipei",
- "sret",
- "cape verde",
- "tkt",
+ "atlantic",
+ "mexico",
+ "mountain",
+ "china",
+ "azores",
+ "india",
+ "u",
+ "arabic",
+ "greenwich",
+ "new zealand",
+ "hawaiian",
+ "g",
+ "romance",
+ "arab",
"samoa",
- "sa pacific",
- "vut",
- "idlw",
- "fiji",
+ "v",
+ "p",
+ "gmt",
+ "tasmania",
+ "fwt",
+ "newfoundland",
+ "nepal",
+ "aus central",
+ "gtb",
+ "vladivostok",
"utc",
- "korea",
- "e. europe",
- "syot",
- "n. central asia",
- "tvt",
- "w. central africa",
"ekaterinburg",
- "vladivostok",
- "yapt",
- "us eastern",
- "sa eastern",
- "hdt",
- "russian",
- "hkt",
- "romance",
- "w. europe",
- "ydt",
- "idle",
- "greenwich",
- "greenland"
+ "us mountain",
+ "jerusalem",
+ "yakutsk",
+ "pacific sa",
+ "tonga",
+ "afghanistan",
+ "idlw",
+ "pacific",
+ "taipei",
+ "egypt",
+ "tokyo",
+ "fiji"
};
#define stringpool ((const char *) &stringpool_contents)
const struct zone *
zonetab (register const char *str, register size_t len)
{
+ enum
+ {
+ TOTAL_KEYWORDS = 170,
+ MIN_WORD_LENGTH = 1,
+ MAX_WORD_LENGTH = 17,
+ MIN_HASH_VALUE = 5,
+ MAX_HASH_VALUE = 438
+ };
+
static const struct zone wordlist[] =
{
- {-1}, {-1},
-#line 34 "zonetab.list"
- {gperf_offsetof(stringpool, 2), -2*3600},
-#line 43 "zonetab.list"
- {gperf_offsetof(stringpool, 3), -11*3600},
-#line 45 "zonetab.list"
- {gperf_offsetof(stringpool, 4), 0*3600},
-#line 36 "zonetab.list"
- {gperf_offsetof(stringpool, 5), -4*3600},
- {-1}, {-1},
-#line 269 "zonetab.list"
- {gperf_offsetof(stringpool, 8),21600},
-#line 268 "zonetab.list"
- {gperf_offsetof(stringpool, 9),25200},
-#line 35 "zonetab.list"
- {gperf_offsetof(stringpool, 10), -3*3600},
- {-1}, {-1},
-#line 21 "zonetab.list"
- {gperf_offsetof(stringpool, 13), 1*3600},
-#line 25 "zonetab.list"
- {gperf_offsetof(stringpool, 14), 5*3600},
-#line 271 "zonetab.list"
- {gperf_offsetof(stringpool, 15),-18000},
-#line 279 "zonetab.list"
- {gperf_offsetof(stringpool, 16),-10800},
-#line 273 "zonetab.list"
- {gperf_offsetof(stringpool, 17),43200},
-#line 272 "zonetab.list"
- {gperf_offsetof(stringpool, 18),43200},
-#line 80 "zonetab.list"
- {gperf_offsetof(stringpool, 19), 2*3600},
-#line 186 "zonetab.list"
- {gperf_offsetof(stringpool, 20),36000},
-#line 88 "zonetab.list"
- {gperf_offsetof(stringpool, 21), 3*3600},
-#line 87 "zonetab.list"
- {gperf_offsetof(stringpool, 22), 3*3600},
- {-1},
-#line 101 "zonetab.list"
- {gperf_offsetof(stringpool, 24),10*3600},
-#line 217 "zonetab.list"
- {gperf_offsetof(stringpool, 25),-18000},
-#line 19 "zonetab.list"
- {gperf_offsetof(stringpool, 26), -8*3600},
-#line 133 "zonetab.list"
- {gperf_offsetof(stringpool, 27), -18000},
-#line 32 "zonetab.list"
- {gperf_offsetof(stringpool, 28), 12*3600},
-#line 56 "zonetab.list"
- {gperf_offsetof(stringpool, 29), -4*3600},
-#line 13 "zonetab.list"
- {gperf_offsetof(stringpool, 30), -5*3600},
-#line 23 "zonetab.list"
- {gperf_offsetof(stringpool, 31), 3*3600},
-#line 256 "zonetab.list"
- {gperf_offsetof(stringpool, 32),23400},
-#line 73 "zonetab.list"
- {gperf_offsetof(stringpool, 33), 1*3600},
- {-1},
-#line 82 "zonetab.list"
- {gperf_offsetof(stringpool, 35), 2*3600},
-#line 71 "zonetab.list"
- {gperf_offsetof(stringpool, 36), 1*3600},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+#line 37 "zonetab.list"
+ {gperf_offsetof(stringpool, 5), -5*3600},
+#line 38 "zonetab.list"
+ {gperf_offsetof(stringpool, 6), -6*3600},
#line 24 "zonetab.list"
- {gperf_offsetof(stringpool, 37), 4*3600},
+ {gperf_offsetof(stringpool, 7), 4*3600},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 15 "zonetab.list"
+ {gperf_offsetof(stringpool, 14), -6*3600},
+#line 16 "zonetab.list"
+ {gperf_offsetof(stringpool, 15), -5*3600},
+#line 85 "zonetab.list"
+ {gperf_offsetof(stringpool, 16), 2*3600},
+#line 71 "zonetab.list"
+ {gperf_offsetof(stringpool, 17), 1*3600},
+#line 90 "zonetab.list"
+ {gperf_offsetof(stringpool, 18), 4*3600},
#line 79 "zonetab.list"
- {gperf_offsetof(stringpool, 38), 2*3600},
+ {gperf_offsetof(stringpool, 19), 2*3600},
#line 65 "zonetab.list"
- {gperf_offsetof(stringpool, 39),-10*3600},
+ {gperf_offsetof(stringpool, 20),-10*3600},
{-1},
-#line 202 "zonetab.list"
- {gperf_offsetof(stringpool, 41),28800},
-#line 252 "zonetab.list"
- {gperf_offsetof(stringpool, 42),39600},
-#line 251 "zonetab.list"
- {gperf_offsetof(stringpool, 43),43200},
#line 17 "zonetab.list"
- {gperf_offsetof(stringpool, 44), -7*3600},
-#line 89 "zonetab.list"
- {gperf_offsetof(stringpool, 45), 3*3600},
-#line 212 "zonetab.list"
- {gperf_offsetof(stringpool, 46),-18000},
-#line 15 "zonetab.list"
- {gperf_offsetof(stringpool, 47), -6*3600},
-#line 192 "zonetab.list"
- {gperf_offsetof(stringpool, 48),18000},
-#line 26 "zonetab.list"
- {gperf_offsetof(stringpool, 49), 6*3600},
- {-1}, {-1},
-#line 51 "zonetab.list"
- {gperf_offsetof(stringpool, 52), -3*3600},
-#line 226 "zonetab.list"
- {gperf_offsetof(stringpool, 53),-7200},
-#line 221 "zonetab.list"
- {gperf_offsetof(stringpool, 54),10800},
-#line 22 "zonetab.list"
- {gperf_offsetof(stringpool, 55), 2*3600},
- {-1},
-#line 190 "zonetab.list"
- {gperf_offsetof(stringpool, 57),43200},
-#line 189 "zonetab.list"
- {gperf_offsetof(stringpool, 58),43200},
-#line 199 "zonetab.list"
- {gperf_offsetof(stringpool, 59),28800},
-#line 29 "zonetab.list"
- {gperf_offsetof(stringpool, 60), 9*3600},
-#line 276 "zonetab.list"
- {gperf_offsetof(stringpool, 61),28800},
-#line 48 "zonetab.list"
- {gperf_offsetof(stringpool, 62), -2*3600},
-#line 94 "zonetab.list"
- {gperf_offsetof(stringpool, 63), 6*3600},
-#line 74 "zonetab.list"
- {gperf_offsetof(stringpool, 64), 1*3600},
-#line 81 "zonetab.list"
- {gperf_offsetof(stringpool, 65), 2*3600},
-#line 64 "zonetab.list"
- {gperf_offsetof(stringpool, 66),-10*3600},
-#line 254 "zonetab.list"
- {gperf_offsetof(stringpool, 67),18000},
-#line 92 "zonetab.list"
- {gperf_offsetof(stringpool, 68), 5*3600},
- {-1},
-#line 200 "zonetab.list"
- {gperf_offsetof(stringpool, 70),-14400},
-#line 70 "zonetab.list"
- {gperf_offsetof(stringpool, 71), 1*3600},
-#line 281 "zonetab.list"
- {gperf_offsetof(stringpool, 72),32400},
- {-1},
-#line 280 "zonetab.list"
- {gperf_offsetof(stringpool, 74),39600},
-#line 238 "zonetab.list"
- {gperf_offsetof(stringpool, 75),21600},
-#line 93 "zonetab.list"
- {gperf_offsetof(stringpool, 76), (5*3600+1800)},
-#line 194 "zonetab.list"
- {gperf_offsetof(stringpool, 77),28800},
- {-1},
-#line 255 "zonetab.list"
- {gperf_offsetof(stringpool, 79),43200},
-#line 75 "zonetab.list"
- {gperf_offsetof(stringpool, 80), 1*3600},
-#line 270 "zonetab.list"
- {gperf_offsetof(stringpool, 81),18000},
-#line 83 "zonetab.list"
- {gperf_offsetof(stringpool, 82), 2*3600},
+ {gperf_offsetof(stringpool, 22), -7*3600},
+#line 18 "zonetab.list"
+ {gperf_offsetof(stringpool, 23), -6*3600},
+#line 84 "zonetab.list"
+ {gperf_offsetof(stringpool, 24), 2*3600},
+#line 73 "zonetab.list"
+ {gperf_offsetof(stringpool, 25), 1*3600},
{-1},
-#line 207 "zonetab.list"
- {gperf_offsetof(stringpool, 84),36000},
-#line 278 "zonetab.list"
- {gperf_offsetof(stringpool, 85),-7200},
- {-1}, {-1},
-#line 126 "zonetab.list"
- {gperf_offsetof(stringpool, 88), -21600},
-#line 185 "zonetab.list"
- {gperf_offsetof(stringpool, 89),39600},
-#line 183 "zonetab.list"
- {gperf_offsetof(stringpool, 90),-18000},
-#line 218 "zonetab.list"
- {gperf_offsetof(stringpool, 91),-18000},
-#line 182 "zonetab.list"
- {gperf_offsetof(stringpool, 92),34200},
-#line 103 "zonetab.list"
- {gperf_offsetof(stringpool, 93),11*3600},
-#line 53 "zonetab.list"
- {gperf_offsetof(stringpool, 94), -3*3600},
-#line 208 "zonetab.list"
- {gperf_offsetof(stringpool, 95),36000},
-#line 49 "zonetab.list"
- {gperf_offsetof(stringpool, 96),-2*3600},
-#line 120 "zonetab.list"
- {gperf_offsetof(stringpool, 97), 34200},
+#line 82 "zonetab.list"
+ {gperf_offsetof(stringpool, 27), 2*3600},
{-1}, {-1},
-#line 215 "zonetab.list"
- {gperf_offsetof(stringpool, 100),25200},
-#line 242 "zonetab.list"
- {gperf_offsetof(stringpool, 101),12600},
-#line 241 "zonetab.list"
- {gperf_offsetof(stringpool, 102),28800},
-#line 240 "zonetab.list"
- {gperf_offsetof(stringpool, 103),32400},
-#line 86 "zonetab.list"
- {gperf_offsetof(stringpool, 104), 3*3600},
-#line 33 "zonetab.list"
- {gperf_offsetof(stringpool, 105), -1*3600},
-#line 201 "zonetab.list"
- {gperf_offsetof(stringpool, 106),21600},
-#line 148 "zonetab.list"
- {gperf_offsetof(stringpool, 107), -25200},
-#line 96 "zonetab.list"
- {gperf_offsetof(stringpool, 108), 8*3600},
-#line 42 "zonetab.list"
- {gperf_offsetof(stringpool, 109), -10*3600},
-#line 31 "zonetab.list"
- {gperf_offsetof(stringpool, 110), 11*3600},
-#line 72 "zonetab.list"
- {gperf_offsetof(stringpool, 111), 1*3600},
- {-1},
-#line 90 "zonetab.list"
- {gperf_offsetof(stringpool, 113), 4*3600},
#line 47 "zonetab.list"
- {gperf_offsetof(stringpool, 114), 0*3600},
- {-1},
+ {gperf_offsetof(stringpool, 30), 0*3600},
+#line 128 "zonetab.list"
+ {gperf_offsetof(stringpool, 31), -43200},
#line 78 "zonetab.list"
- {gperf_offsetof(stringpool, 116), 1*3600},
+ {gperf_offsetof(stringpool, 32), 1*3600},
#line 77 "zonetab.list"
- {gperf_offsetof(stringpool, 117), 1*3600},
+ {gperf_offsetof(stringpool, 33), 1*3600},
{-1},
#line 95 "zonetab.list"
- {gperf_offsetof(stringpool, 119), 7*3600},
-#line 313 "zonetab.list"
- {gperf_offsetof(stringpool, 120),43200},
-#line 55 "zonetab.list"
- {gperf_offsetof(stringpool, 121), -(3*3600+1800)},
-#line 184 "zonetab.list"
- {gperf_offsetof(stringpool, 122),31500},
-#line 204 "zonetab.list"
- {gperf_offsetof(stringpool, 123),45900},
-#line 210 "zonetab.list"
- {gperf_offsetof(stringpool, 124),-18000},
-#line 198 "zonetab.list"
- {gperf_offsetof(stringpool, 125),14400},
-#line 57 "zonetab.list"
- {gperf_offsetof(stringpool, 126), -4*3600},
-#line 197 "zonetab.list"
- {gperf_offsetof(stringpool, 127),18000},
-#line 54 "zonetab.list"
- {gperf_offsetof(stringpool, 128),-3*3600},
-#line 253 "zonetab.list"
- {gperf_offsetof(stringpool, 129),-30600},
-#line 91 "zonetab.list"
- {gperf_offsetof(stringpool, 130), 4*3600},
-#line 99 "zonetab.list"
- {gperf_offsetof(stringpool, 131), 9*3600},
+ {gperf_offsetof(stringpool, 35), 7*3600},
+#line 98 "zonetab.list"
+ {gperf_offsetof(stringpool, 36), 8*3600},
+#line 25 "zonetab.list"
+ {gperf_offsetof(stringpool, 37), 5*3600},
+#line 123 "zonetab.list"
+ {gperf_offsetof(stringpool, 38), 3600},
#line 122 "zonetab.list"
- {gperf_offsetof(stringpool, 132), 21600},
-#line 187 "zonetab.list"
- {gperf_offsetof(stringpool, 133),16200},
-#line 132 "zonetab.list"
- {gperf_offsetof(stringpool, 134), -10800},
+ {gperf_offsetof(stringpool, 39), 21600},
+#line 178 "zonetab.list"
+ {gperf_offsetof(stringpool, 40), 18000},
+#line 120 "zonetab.list"
+ {gperf_offsetof(stringpool, 41), 34200},
#line 121 "zonetab.list"
- {gperf_offsetof(stringpool, 135), -21600},
+ {gperf_offsetof(stringpool, 42), -21600},
{-1},
-#line 236 "zonetab.list"
- {gperf_offsetof(stringpool, 137),25200},
- {-1}, {-1}, {-1}, {-1}, {-1},
-#line 274 "zonetab.list"
- {gperf_offsetof(stringpool, 143),36000},
-#line 266 "zonetab.list"
- {gperf_offsetof(stringpool, 144),43200},
-#line 146 "zonetab.list"
- {gperf_offsetof(stringpool, 145), -21600},
-#line 193 "zonetab.list"
- {gperf_offsetof(stringpool, 146),32400},
-#line 220 "zonetab.list"
- {gperf_offsetof(stringpool, 147),-3600},
-#line 214 "zonetab.list"
- {gperf_offsetof(stringpool, 148),25200},
-#line 219 "zonetab.list"
- {gperf_offsetof(stringpool, 149),0},
-#line 275 "zonetab.list"
- {gperf_offsetof(stringpool, 150),46800},
-#line 109 "zonetab.list"
- {gperf_offsetof(stringpool, 151), -32400},
- {-1}, {-1},
-#line 68 "zonetab.list"
- {gperf_offsetof(stringpool, 154), -11*3600},
- {-1}, {-1}, {-1},
-#line 321 "zonetab.list"
- {gperf_offsetof(stringpool, 158),0},
- {-1},
-#line 178 "zonetab.list"
- {gperf_offsetof(stringpool, 160), 18000},
-#line 181 "zonetab.list"
- {gperf_offsetof(stringpool, 161),37800},
-#line 265 "zonetab.list"
- {gperf_offsetof(stringpool, 162),20700},
-#line 249 "zonetab.list"
- {gperf_offsetof(stringpool, 163),37800},
-#line 108 "zonetab.list"
- {gperf_offsetof(stringpool, 164), 16200},
- {-1}, {-1},
-#line 30 "zonetab.list"
- {gperf_offsetof(stringpool, 167), 10*3600},
+#line 13 "zonetab.list"
+ {gperf_offsetof(stringpool, 44), -5*3600},
+#line 14 "zonetab.list"
+ {gperf_offsetof(stringpool, 45), -4*3600},
+#line 124 "zonetab.list"
+ {gperf_offsetof(stringpool, 46), 3600},
+#line 80 "zonetab.list"
+ {gperf_offsetof(stringpool, 47), 2*3600},
+#line 164 "zonetab.list"
+ {gperf_offsetof(stringpool, 48), 25200},
+#line 88 "zonetab.list"
+ {gperf_offsetof(stringpool, 49), 3*3600},
+#line 87 "zonetab.list"
+ {gperf_offsetof(stringpool, 50), 3*3600},
+#line 45 "zonetab.list"
+ {gperf_offsetof(stringpool, 51), 0*3600},
+#line 101 "zonetab.list"
+ {gperf_offsetof(stringpool, 52),10*3600},
+#line 103 "zonetab.list"
+ {gperf_offsetof(stringpool, 53),11*3600},
+#line 160 "zonetab.list"
+ {gperf_offsetof(stringpool, 54), -10800},
+#line 177 "zonetab.list"
+ {gperf_offsetof(stringpool, 55), 3600},
+#line 23 "zonetab.list"
+ {gperf_offsetof(stringpool, 56), 3*3600},
+#line 63 "zonetab.list"
+ {gperf_offsetof(stringpool, 57), -9*3600},
+#line 59 "zonetab.list"
+ {gperf_offsetof(stringpool, 58), -8*3600},
+#line 100 "zonetab.list"
+ {gperf_offsetof(stringpool, 59), 9*3600},
+#line 57 "zonetab.list"
+ {gperf_offsetof(stringpool, 60), -4*3600},
+#line 133 "zonetab.list"
+ {gperf_offsetof(stringpool, 61), -18000},
+#line 54 "zonetab.list"
+ {gperf_offsetof(stringpool, 62),-3*3600},
+#line 86 "zonetab.list"
+ {gperf_offsetof(stringpool, 63), 3*3600},
+#line 175 "zonetab.list"
+ {gperf_offsetof(stringpool, 64), 28800},
+#line 70 "zonetab.list"
+ {gperf_offsetof(stringpool, 65), 1*3600},
+#line 96 "zonetab.list"
+ {gperf_offsetof(stringpool, 66), 8*3600},
+#line 53 "zonetab.list"
+ {gperf_offsetof(stringpool, 67), -3*3600},
{-1},
-#line 27 "zonetab.list"
- {gperf_offsetof(stringpool, 169), 7*3600},
-#line 239 "zonetab.list"
- {gperf_offsetof(stringpool, 170),16200},
-#line 206 "zonetab.list"
- {gperf_offsetof(stringpool, 171),28800},
-#line 205 "zonetab.list"
- {gperf_offsetof(stringpool, 172),32400},
-#line 12 "zonetab.list"
- {gperf_offsetof(stringpool, 173), 0*3600},
-#line 229 "zonetab.list"
- {gperf_offsetof(stringpool, 174),14400},
-#line 264 "zonetab.list"
- {gperf_offsetof(stringpool, 175),25200},
-#line 263 "zonetab.list"
- {gperf_offsetof(stringpool, 176),25200},
-#line 223 "zonetab.list"
- {gperf_offsetof(stringpool, 177),43200},
-#line 40 "zonetab.list"
- {gperf_offsetof(stringpool, 178), -8*3600},
-#line 222 "zonetab.list"
- {gperf_offsetof(stringpool, 179),46800},
+#line 49 "zonetab.list"
+ {gperf_offsetof(stringpool, 69),-2*3600},
{-1},
-#line 282 "zonetab.list"
- {gperf_offsetof(stringpool, 181),-10800},
-#line 260 "zonetab.list"
- {gperf_offsetof(stringpool, 182),39600},
-#line 100 "zonetab.list"
- {gperf_offsetof(stringpool, 183), 9*3600},
-#line 244 "zonetab.list"
- {gperf_offsetof(stringpool, 184),39600},
-#line 102 "zonetab.list"
- {gperf_offsetof(stringpool, 185), 10*3600},
-#line 143 "zonetab.list"
- {gperf_offsetof(stringpool, 186), 12600},
+#line 21 "zonetab.list"
+ {gperf_offsetof(stringpool, 71), 1*3600},
+#line 131 "zonetab.list"
+ {gperf_offsetof(stringpool, 72), 7200},
+#line 48 "zonetab.list"
+ {gperf_offsetof(stringpool, 73), -2*3600},
+#line 126 "zonetab.list"
+ {gperf_offsetof(stringpool, 74), -21600},
+#line 56 "zonetab.list"
+ {gperf_offsetof(stringpool, 75), -4*3600},
+#line 52 "zonetab.list"
+ {gperf_offsetof(stringpool, 76), -3*3600},
+#line 51 "zonetab.list"
+ {gperf_offsetof(stringpool, 77), -3*3600},
#line 129 "zonetab.list"
- {gperf_offsetof(stringpool, 187), 10800},
-#line 98 "zonetab.list"
- {gperf_offsetof(stringpool, 188), 8*3600},
-#line 39 "zonetab.list"
- {gperf_offsetof(stringpool, 189), -7*3600},
+ {gperf_offsetof(stringpool, 78), 10800},
+#line 132 "zonetab.list"
+ {gperf_offsetof(stringpool, 79), -10800},
+#line 99 "zonetab.list"
+ {gperf_offsetof(stringpool, 80), 9*3600},
#line 130 "zonetab.list"
- {gperf_offsetof(stringpool, 190), 36000},
-#line 38 "zonetab.list"
- {gperf_offsetof(stringpool, 191), -6*3600},
-#line 203 "zonetab.list"
- {gperf_offsetof(stringpool, 192),49500},
-#line 298 "zonetab.list"
- {gperf_offsetof(stringpool, 193),18000},
-#line 209 "zonetab.list"
- {gperf_offsetof(stringpool, 194),-14400},
-#line 191 "zonetab.list"
- {gperf_offsetof(stringpool, 195),-43200},
- {-1},
-#line 259 "zonetab.list"
- {gperf_offsetof(stringpool, 197),28800},
+ {gperf_offsetof(stringpool, 81), 36000},
+#line 39 "zonetab.list"
+ {gperf_offsetof(stringpool, 82), -7*3600},
+#line 68 "zonetab.list"
+ {gperf_offsetof(stringpool, 83), -11*3600},
+#line 33 "zonetab.list"
+ {gperf_offsetof(stringpool, 84), -1*3600},
+#line 55 "zonetab.list"
+ {gperf_offsetof(stringpool, 85), -(3*3600+1800)},
+#line 50 "zonetab.list"
+ {gperf_offsetof(stringpool, 86), -(2*3600+1800)},
+#line 117 "zonetab.list"
+ {gperf_offsetof(stringpool, 87), -21600},
+#line 125 "zonetab.list"
+ {gperf_offsetof(stringpool, 88), 39600},
#line 179 "zonetab.list"
- {gperf_offsetof(stringpool, 198), 36000},
-#line 257 "zonetab.list"
- {gperf_offsetof(stringpool, 199),14400},
-#line 319 "zonetab.list"
- {gperf_offsetof(stringpool, 200),32400},
-#line 84 "zonetab.list"
- {gperf_offsetof(stringpool, 201), 2*3600},
-#line 286 "zonetab.list"
- {gperf_offsetof(stringpool, 202),39600},
-#line 152 "zonetab.list"
- {gperf_offsetof(stringpool, 203), 43200},
-#line 300 "zonetab.list"
- {gperf_offsetof(stringpool, 204),46800},
-#line 127 "zonetab.list"
- {gperf_offsetof(stringpool, 205), 28800},
-#line 299 "zonetab.list"
- {gperf_offsetof(stringpool, 206),50400},
-#line 85 "zonetab.list"
- {gperf_offsetof(stringpool, 207), 2*3600},
+ {gperf_offsetof(stringpool, 89), 36000},
+#line 67 "zonetab.list"
+ {gperf_offsetof(stringpool, 90),-10*3600},
+#line 62 "zonetab.list"
+ {gperf_offsetof(stringpool, 91), -9*3600},
{-1},
-#line 142 "zonetab.list"
- {gperf_offsetof(stringpool, 209), 19800},
+#line 165 "zonetab.list"
+ {gperf_offsetof(stringpool, 93), 28800},
{-1},
-#line 314 "zonetab.list"
- {gperf_offsetof(stringpool, 211),-10800},
-#line 288 "zonetab.list"
- {gperf_offsetof(stringpool, 212),39600},
+#line 94 "zonetab.list"
+ {gperf_offsetof(stringpool, 95), 6*3600},
{-1},
-#line 196 "zonetab.list"
- {gperf_offsetof(stringpool, 214),-3600},
-#line 195 "zonetab.list"
- {gperf_offsetof(stringpool, 215),0},
-#line 293 "zonetab.list"
- {gperf_offsetof(stringpool, 216),-36000},
-#line 106 "zonetab.list"
- {gperf_offsetof(stringpool, 217), 12*3600},
-#line 128 "zonetab.list"
- {gperf_offsetof(stringpool, 218), -43200},
-#line 105 "zonetab.list"
- {gperf_offsetof(stringpool, 219),12*3600},
-#line 170 "zonetab.list"
- {gperf_offsetof(stringpool, 220), 32400},
-#line 125 "zonetab.list"
- {gperf_offsetof(stringpool, 221), 39600},
+#line 159 "zonetab.list"
+ {gperf_offsetof(stringpool, 97), 10800},
+#line 66 "zonetab.list"
+ {gperf_offsetof(stringpool, 98),-10*3600},
+#line 61 "zonetab.list"
+ {gperf_offsetof(stringpool, 99),-9*3600},
+#line 102 "zonetab.list"
+ {gperf_offsetof(stringpool, 100), 10*3600},
+#line 92 "zonetab.list"
+ {gperf_offsetof(stringpool, 101), 5*3600},
+#line 93 "zonetab.list"
+ {gperf_offsetof(stringpool, 102), (5*3600+1800)},
+#line 76 "zonetab.list"
+ {gperf_offsetof(stringpool, 103), 1*3600},
+#line 42 "zonetab.list"
+ {gperf_offsetof(stringpool, 104), -10*3600},
+#line 91 "zonetab.list"
+ {gperf_offsetof(stringpool, 105), 4*3600},
{-1},
-#line 283 "zonetab.list"
- {gperf_offsetof(stringpool, 223),21600},
-#line 113 "zonetab.list"
- {gperf_offsetof(stringpool, 224), -14400},
-#line 262 "zonetab.list"
- {gperf_offsetof(stringpool, 225),39600},
+#line 75 "zonetab.list"
+ {gperf_offsetof(stringpool, 107), 1*3600},
+#line 118 "zonetab.list"
+ {gperf_offsetof(stringpool, 108), -3600},
+#line 83 "zonetab.list"
+ {gperf_offsetof(stringpool, 109), 2*3600},
+#line 138 "zonetab.list"
+ {gperf_offsetof(stringpool, 110), -10800},
{-1},
-#line 11 "zonetab.list"
- {gperf_offsetof(stringpool, 227), 0*3600},
-#line 301 "zonetab.list"
- {gperf_offsetof(stringpool, 228),10800},
-#line 315 "zonetab.list"
- {gperf_offsetof(stringpool, 229),43200},
-#line 291 "zonetab.list"
- {gperf_offsetof(stringpool, 230),-10800},
-#line 20 "zonetab.list"
- {gperf_offsetof(stringpool, 231), -7*3600},
-#line 248 "zonetab.list"
- {gperf_offsetof(stringpool, 232),39600},
+#line 43 "zonetab.list"
+ {gperf_offsetof(stringpool, 112), -11*3600},
{-1},
-#line 52 "zonetab.list"
- {gperf_offsetof(stringpool, 234), -3*3600},
-#line 14 "zonetab.list"
- {gperf_offsetof(stringpool, 235), -4*3600},
- {-1}, {-1},
-#line 277 "zonetab.list"
- {gperf_offsetof(stringpool, 238),18000},
-#line 188 "zonetab.list"
- {gperf_offsetof(stringpool, 239),21600},
-#line 320 "zonetab.list"
- {gperf_offsetof(stringpool, 240),28800},
+#line 74 "zonetab.list"
+ {gperf_offsetof(stringpool, 114), 1*3600},
+#line 176 "zonetab.list"
+ {gperf_offsetof(stringpool, 115), 3600},
+#line 30 "zonetab.list"
+ {gperf_offsetof(stringpool, 116), 10*3600},
+#line 22 "zonetab.list"
+ {gperf_offsetof(stringpool, 117), 2*3600},
{-1},
-#line 317 "zonetab.list"
- {gperf_offsetof(stringpool, 242),-10800},
-#line 60 "zonetab.list"
- {gperf_offsetof(stringpool, 243),-9*3600},
-#line 316 "zonetab.list"
- {gperf_offsetof(stringpool, 244),-7200},
+#line 32 "zonetab.list"
+ {gperf_offsetof(stringpool, 119), 12*3600},
+#line 167 "zonetab.list"
+ {gperf_offsetof(stringpool, 120), 21600},
{-1},
-#line 246 "zonetab.list"
- {gperf_offsetof(stringpool, 246),25200},
-#line 245 "zonetab.list"
- {gperf_offsetof(stringpool, 247),28800},
-#line 147 "zonetab.list"
- {gperf_offsetof(stringpool, 248), -7200},
-#line 18 "zonetab.list"
- {gperf_offsetof(stringpool, 249), -6*3600},
-#line 250 "zonetab.list"
- {gperf_offsetof(stringpool, 250),50400},
-#line 165 "zonetab.list"
- {gperf_offsetof(stringpool, 251), 28800},
-#line 16 "zonetab.list"
- {gperf_offsetof(stringpool, 252), -5*3600},
-#line 76 "zonetab.list"
- {gperf_offsetof(stringpool, 253), 1*3600},
+#line 81 "zonetab.list"
+ {gperf_offsetof(stringpool, 122), 2*3600},
{-1},
-#line 164 "zonetab.list"
- {gperf_offsetof(stringpool, 255), 25200},
-#line 41 "zonetab.list"
- {gperf_offsetof(stringpool, 256), -9*3600},
+#line 143 "zonetab.list"
+ {gperf_offsetof(stringpool, 124), 12600},
+#line 97 "zonetab.list"
+ {gperf_offsetof(stringpool, 125), 8*3600},
+#line 11 "zonetab.list"
+ {gperf_offsetof(stringpool, 126), 0*3600},
{-1},
-#line 171 "zonetab.list"
- {gperf_offsetof(stringpool, 258), 46800},
-#line 211 "zonetab.list"
- {gperf_offsetof(stringpool, 259),-36000},
+#line 36 "zonetab.list"
+ {gperf_offsetof(stringpool, 128), -4*3600},
+#line 106 "zonetab.list"
+ {gperf_offsetof(stringpool, 129), 12*3600},
{-1},
-#line 308 "zonetab.list"
- {gperf_offsetof(stringpool, 261),-14400},
+#line 105 "zonetab.list"
+ {gperf_offsetof(stringpool, 131),12*3600},
+#line 107 "zonetab.list"
+ {gperf_offsetof(stringpool, 132),13*3600},
+#line 149 "zonetab.list"
+ {gperf_offsetof(stringpool, 133), 23400},
+ {-1},
+#line 109 "zonetab.list"
+ {gperf_offsetof(stringpool, 135), -32400},
+#line 19 "zonetab.list"
+ {gperf_offsetof(stringpool, 136), -8*3600},
+#line 20 "zonetab.list"
+ {gperf_offsetof(stringpool, 137), -7*3600},
+#line 162 "zonetab.list"
+ {gperf_offsetof(stringpool, 138), -14400},
+#line 145 "zonetab.list"
+ {gperf_offsetof(stringpool, 139), 32400},
+ {-1}, {-1},
+#line 44 "zonetab.list"
+ {gperf_offsetof(stringpool, 142), -12*3600},
+#line 26 "zonetab.list"
+ {gperf_offsetof(stringpool, 143), 6*3600},
+#line 60 "zonetab.list"
+ {gperf_offsetof(stringpool, 144),-9*3600},
+#line 58 "zonetab.list"
+ {gperf_offsetof(stringpool, 145),-8*3600},
+ {-1}, {-1},
#line 119 "zonetab.list"
- {gperf_offsetof(stringpool, 262), 14400},
-#line 123 "zonetab.list"
- {gperf_offsetof(stringpool, 263), 3600},
-#line 28 "zonetab.list"
- {gperf_offsetof(stringpool, 264), 8*3600},
-#line 124 "zonetab.list"
- {gperf_offsetof(stringpool, 265), 3600},
-#line 153 "zonetab.list"
- {gperf_offsetof(stringpool, 266), -12600},
-#line 110 "zonetab.list"
- {gperf_offsetof(stringpool, 267), 10800},
-#line 289 "zonetab.list"
- {gperf_offsetof(stringpool, 268),14400},
-#line 112 "zonetab.list"
- {gperf_offsetof(stringpool, 269), 10800},
-#line 111 "zonetab.list"
- {gperf_offsetof(stringpool, 270), 14400},
-#line 216 "zonetab.list"
- {gperf_offsetof(stringpool, 271),36000},
+ {gperf_offsetof(stringpool, 148), 14400},
{-1},
-#line 311 "zonetab.list"
- {gperf_offsetof(stringpool, 273),21600},
-#line 66 "zonetab.list"
- {gperf_offsetof(stringpool, 274),-10*3600},
-#line 151 "zonetab.list"
- {gperf_offsetof(stringpool, 275), 20700},
-#line 267 "zonetab.list"
- {gperf_offsetof(stringpool, 276),-39600},
-#line 225 "zonetab.list"
- {gperf_offsetof(stringpool, 277),-14400},
+#line 89 "zonetab.list"
+ {gperf_offsetof(stringpool, 150), 3*3600},
+#line 104 "zonetab.list"
+ {gperf_offsetof(stringpool, 151),12*3600},
{-1},
-#line 224 "zonetab.list"
- {gperf_offsetof(stringpool, 279),-10800},
-#line 67 "zonetab.list"
- {gperf_offsetof(stringpool, 280),-10*3600},
-#line 237 "zonetab.list"
- {gperf_offsetof(stringpool, 281),10800},
+#line 111 "zonetab.list"
+ {gperf_offsetof(stringpool, 153), 14400},
+ {-1},
+#line 34 "zonetab.list"
+ {gperf_offsetof(stringpool, 155), -2*3600},
+#line 31 "zonetab.list"
+ {gperf_offsetof(stringpool, 156), 11*3600},
+#line 147 "zonetab.list"
+ {gperf_offsetof(stringpool, 157), -7200},
{-1}, {-1},
-#line 297 "zonetab.list"
- {gperf_offsetof(stringpool, 284),32400},
-#line 175 "zonetab.list"
- {gperf_offsetof(stringpool, 285), 28800},
-#line 134 "zonetab.list"
- {gperf_offsetof(stringpool, 286), 7200},
-#line 149 "zonetab.list"
- {gperf_offsetof(stringpool, 287), 23400},
-#line 107 "zonetab.list"
- {gperf_offsetof(stringpool, 288),13*3600},
-#line 230 "zonetab.list"
- {gperf_offsetof(stringpool, 289),-10800},
-#line 307 "zonetab.list"
- {gperf_offsetof(stringpool, 290),18000},
+#line 172 "zonetab.list"
+ {gperf_offsetof(stringpool, 160), -18000},
+ {-1}, {-1}, {-1},
+#line 64 "zonetab.list"
+ {gperf_offsetof(stringpool, 164),-10*3600},
{-1}, {-1},
+#line 28 "zonetab.list"
+ {gperf_offsetof(stringpool, 167), 8*3600},
+#line 137 "zonetab.list"
+ {gperf_offsetof(stringpool, 168), 7200},
+#line 29 "zonetab.list"
+ {gperf_offsetof(stringpool, 169), 9*3600},
#line 155 "zonetab.list"
- {gperf_offsetof(stringpool, 293), 25200},
-#line 258 "zonetab.list"
- {gperf_offsetof(stringpool, 294),18000},
-#line 227 "zonetab.list"
- {gperf_offsetof(stringpool, 295),-21600},
-#line 261 "zonetab.list"
- {gperf_offsetof(stringpool, 296),43200},
-#line 213 "zonetab.list"
- {gperf_offsetof(stringpool, 297),-3600},
+ {gperf_offsetof(stringpool, 170), 25200},
+#line 150 "zonetab.list"
+ {gperf_offsetof(stringpool, 171), 21600},
#line 154 "zonetab.list"
- {gperf_offsetof(stringpool, 298), 28800},
+ {gperf_offsetof(stringpool, 172), 28800},
{-1},
-#line 243 "zonetab.list"
- {gperf_offsetof(stringpool, 300),21600},
-#line 114 "zonetab.list"
- {gperf_offsetof(stringpool, 301), 34200},
-#line 157 "zonetab.list"
- {gperf_offsetof(stringpool, 302), -28800},
+#line 161 "zonetab.list"
+ {gperf_offsetof(stringpool, 174), -18000},
+ {-1}, {-1},
+#line 166 "zonetab.list"
+ {gperf_offsetof(stringpool, 177), 7200},
+ {-1}, {-1}, {-1},
+#line 115 "zonetab.list"
+ {gperf_offsetof(stringpool, 181), 36000},
+#line 113 "zonetab.list"
+ {gperf_offsetof(stringpool, 182), -14400},
+ {-1}, {-1}, {-1},
+#line 146 "zonetab.list"
+ {gperf_offsetof(stringpool, 186), -21600},
{-1},
-#line 117 "zonetab.list"
- {gperf_offsetof(stringpool, 304), -21600},
+#line 148 "zonetab.list"
+ {gperf_offsetof(stringpool, 188), -25200},
{-1},
-#line 156 "zonetab.list"
- {gperf_offsetof(stringpool, 306), -14400},
+#line 127 "zonetab.list"
+ {gperf_offsetof(stringpool, 190), 28800},
#line 116 "zonetab.list"
- {gperf_offsetof(stringpool, 307), -3600},
-#line 228 "zonetab.list"
- {gperf_offsetof(stringpool, 308),-32400},
-#line 294 "zonetab.list"
- {gperf_offsetof(stringpool, 309),18000},
-#line 37 "zonetab.list"
- {gperf_offsetof(stringpool, 310), -5*3600},
-#line 137 "zonetab.list"
- {gperf_offsetof(stringpool, 311), 7200},
-#line 58 "zonetab.list"
- {gperf_offsetof(stringpool, 312),-8*3600},
-#line 304 "zonetab.list"
- {gperf_offsetof(stringpool, 313),28800},
-#line 303 "zonetab.list"
- {gperf_offsetof(stringpool, 314),32400},
-#line 284 "zonetab.list"
- {gperf_offsetof(stringpool, 315),14400},
- {-1},
-#line 295 "zonetab.list"
- {gperf_offsetof(stringpool, 317),18000},
- {-1},
-#line 166 "zonetab.list"
- {gperf_offsetof(stringpool, 319), 7200},
- {-1}, {-1}, {-1}, {-1},
-#line 97 "zonetab.list"
- {gperf_offsetof(stringpool, 324), 8*3600},
+ {gperf_offsetof(stringpool, 191), -3600},
+#line 142 "zonetab.list"
+ {gperf_offsetof(stringpool, 192), 19800},
{-1},
-#line 50 "zonetab.list"
- {gperf_offsetof(stringpool, 326), -(2*3600+1800)},
-#line 285 "zonetab.list"
- {gperf_offsetof(stringpool, 327),-10800},
+#line 40 "zonetab.list"
+ {gperf_offsetof(stringpool, 194), -8*3600},
+#line 112 "zonetab.list"
+ {gperf_offsetof(stringpool, 195), 10800},
+#line 139 "zonetab.list"
+ {gperf_offsetof(stringpool, 196), 0},
+#line 152 "zonetab.list"
+ {gperf_offsetof(stringpool, 197), 43200},
+#line 141 "zonetab.list"
+ {gperf_offsetof(stringpool, 198), -36000},
+#line 27 "zonetab.list"
+ {gperf_offsetof(stringpool, 199), 7*3600},
+#line 158 "zonetab.list"
+ {gperf_offsetof(stringpool, 200), 3600},
{-1}, {-1},
-#line 287 "zonetab.list"
- {gperf_offsetof(stringpool, 330),14400},
- {-1},
+#line 110 "zonetab.list"
+ {gperf_offsetof(stringpool, 203), 10800},
+#line 163 "zonetab.list"
+ {gperf_offsetof(stringpool, 204), -39600},
+#line 41 "zonetab.list"
+ {gperf_offsetof(stringpool, 205), -9*3600},
+#line 35 "zonetab.list"
+ {gperf_offsetof(stringpool, 206), -3*3600},
+#line 12 "zonetab.list"
+ {gperf_offsetof(stringpool, 207), 0*3600},
#line 169 "zonetab.list"
- {gperf_offsetof(stringpool, 332), 36000},
- {-1},
-#line 235 "zonetab.list"
- {gperf_offsetof(stringpool, 334),25200},
-#line 234 "zonetab.list"
- {gperf_offsetof(stringpool, 335),28800},
- {-1}, {-1},
-#line 232 "zonetab.list"
- {gperf_offsetof(stringpool, 338),-14400},
- {-1}, {-1}, {-1},
-#line 44 "zonetab.list"
- {gperf_offsetof(stringpool, 342), -12*3600},
-#line 61 "zonetab.list"
- {gperf_offsetof(stringpool, 343),-9*3600},
-#line 162 "zonetab.list"
- {gperf_offsetof(stringpool, 344), -14400},
-#line 141 "zonetab.list"
- {gperf_offsetof(stringpool, 345), -36000},
- {-1},
-#line 306 "zonetab.list"
- {gperf_offsetof(stringpool, 347),-10800},
+ {gperf_offsetof(stringpool, 208), 36000},
+#line 72 "zonetab.list"
+ {gperf_offsetof(stringpool, 209), 1*3600},
{-1},
-#line 305 "zonetab.list"
- {gperf_offsetof(stringpool, 349),-7200},
-#line 326 "zonetab.list"
- {gperf_offsetof(stringpool, 350),18000},
-#line 325 "zonetab.list"
- {gperf_offsetof(stringpool, 351),21600},
-#line 247 "zonetab.list"
- {gperf_offsetof(stringpool, 352),14400},
-#line 323 "zonetab.list"
- {gperf_offsetof(stringpool, 353),32400},
-#line 322 "zonetab.list"
- {gperf_offsetof(stringpool, 354),36000},
- {-1}, {-1}, {-1},
-#line 63 "zonetab.list"
- {gperf_offsetof(stringpool, 358), -9*3600},
-#line 144 "zonetab.list"
- {gperf_offsetof(stringpool, 359), 7200},
+#line 153 "zonetab.list"
+ {gperf_offsetof(stringpool, 211), -12600},
{-1}, {-1}, {-1}, {-1}, {-1},
-#line 167 "zonetab.list"
- {gperf_offsetof(stringpool, 365), 21600},
- {-1},
-#line 180 "zonetab.list"
- {gperf_offsetof(stringpool, 367), 32400},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 318 "zonetab.list"
- {gperf_offsetof(stringpool, 375),25200},
- {-1},
-#line 115 "zonetab.list"
- {gperf_offsetof(stringpool, 377), 36000},
-#line 231 "zonetab.list"
- {gperf_offsetof(stringpool, 378),43200},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 173 "zonetab.list"
- {gperf_offsetof(stringpool, 387), -25200},
- {-1}, {-1}, {-1},
-#line 310 "zonetab.list"
- {gperf_offsetof(stringpool, 391),36000},
-#line 309 "zonetab.list"
- {gperf_offsetof(stringpool, 392),39600},
+#line 151 "zonetab.list"
+ {gperf_offsetof(stringpool, 217), 20700},
+#line 114 "zonetab.list"
+ {gperf_offsetof(stringpool, 218), 34200},
{-1}, {-1},
#line 140 "zonetab.list"
- {gperf_offsetof(stringpool, 395), 7200},
- {-1}, {-1},
-#line 168 "zonetab.list"
- {gperf_offsetof(stringpool, 398), 28800},
-#line 290 "zonetab.list"
- {gperf_offsetof(stringpool, 399),39600},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 118 "zonetab.list"
- {gperf_offsetof(stringpool, 408), -3600},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 296 "zonetab.list"
- {gperf_offsetof(stringpool, 417),46800},
-#line 163 "zonetab.list"
- {gperf_offsetof(stringpool, 418), -39600},
- {-1}, {-1},
-#line 161 "zonetab.list"
- {gperf_offsetof(stringpool, 421), -18000},
+ {gperf_offsetof(stringpool, 221), 7200},
+ {-1},
+#line 174 "zonetab.list"
+ {gperf_offsetof(stringpool, 223), 36000},
{-1}, {-1}, {-1}, {-1}, {-1},
-#line 312 "zonetab.list"
- {gperf_offsetof(stringpool, 427),39600},
-#line 69 "zonetab.list"
- {gperf_offsetof(stringpool, 428),-12*3600},
- {-1}, {-1}, {-1},
-#line 136 "zonetab.list"
- {gperf_offsetof(stringpool, 432), 43200},
- {-1}, {-1},
#line 46 "zonetab.list"
- {gperf_offsetof(stringpool, 435), 0*3600},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 145 "zonetab.list"
- {gperf_offsetof(stringpool, 443), 32400},
- {-1},
-#line 131 "zonetab.list"
- {gperf_offsetof(stringpool, 445), 7200},
+ {gperf_offsetof(stringpool, 229), 0*3600},
{-1}, {-1}, {-1},
-#line 292 "zonetab.list"
- {gperf_offsetof(stringpool, 449),10800},
- {-1}, {-1},
-#line 150 "zonetab.list"
- {gperf_offsetof(stringpool, 452), 21600},
+#line 135 "zonetab.list"
+ {gperf_offsetof(stringpool, 233), 18000},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+#line 173 "zonetab.list"
+ {gperf_offsetof(stringpool, 265), -25200},
+ {-1}, {-1}, {-1},
+#line 144 "zonetab.list"
+ {gperf_offsetof(stringpool, 269), 7200},
{-1}, {-1},
-#line 302 "zonetab.list"
- {gperf_offsetof(stringpool, 455),43200},
+#line 180 "zonetab.list"
+ {gperf_offsetof(stringpool, 272), 32400},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 156 "zonetab.list"
+ {gperf_offsetof(stringpool, 279), -14400},
{-1}, {-1},
-#line 176 "zonetab.list"
- {gperf_offsetof(stringpool, 458), 3600},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 135 "zonetab.list"
- {gperf_offsetof(stringpool, 466), 18000},
- {-1},
-#line 174 "zonetab.list"
- {gperf_offsetof(stringpool, 468), 36000},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 324 "zonetab.list"
- {gperf_offsetof(stringpool, 476),36000},
-#line 172 "zonetab.list"
- {gperf_offsetof(stringpool, 477), -18000},
+#line 171 "zonetab.list"
+ {gperf_offsetof(stringpool, 282), 46800},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1},
-#line 160 "zonetab.list"
- {gperf_offsetof(stringpool, 482), -10800},
+#line 108 "zonetab.list"
+ {gperf_offsetof(stringpool, 314), 16200},
+ {-1}, {-1}, {-1}, {-1},
+#line 69 "zonetab.list"
+ {gperf_offsetof(stringpool, 319),-12*3600},
{-1}, {-1},
-#line 62 "zonetab.list"
- {gperf_offsetof(stringpool, 485), -9*3600},
-#line 159 "zonetab.list"
- {gperf_offsetof(stringpool, 486), 10800},
- {-1}, {-1}, {-1}, {-1}, {-1},
-#line 233 "zonetab.list"
- {gperf_offsetof(stringpool, 492),28800},
+#line 157 "zonetab.list"
+ {gperf_offsetof(stringpool, 322), -28800},
{-1}, {-1}, {-1}, {-1},
-#line 158 "zonetab.list"
- {gperf_offsetof(stringpool, 497), 3600},
+#line 168 "zonetab.list"
+ {gperf_offsetof(stringpool, 327), 28800},
+#line 134 "zonetab.list"
+ {gperf_offsetof(stringpool, 328), 7200},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 177 "zonetab.list"
- {gperf_offsetof(stringpool, 540), 3600},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
-#line 59 "zonetab.list"
- {gperf_offsetof(stringpool, 563), -8*3600},
- {-1}, {-1},
-#line 104 "zonetab.list"
- {gperf_offsetof(stringpool, 566),12*3600},
-#line 139 "zonetab.list"
- {gperf_offsetof(stringpool, 567), 0},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 170 "zonetab.list"
+ {gperf_offsetof(stringpool, 392), 32400},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 138 "zonetab.list"
- {gperf_offsetof(stringpool, 619), -10800}
+#line 136 "zonetab.list"
+ {gperf_offsetof(stringpool, 438), 43200}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -1551,12 +884,12 @@ zonetab (register const char *str, register size_t len)
{
register const char *s = o + stringpool;
- if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strncmp (str, s, len) && s[len] == '\0')
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
return &wordlist[key];
}
}
}
return 0;
}
-#line 327 "zonetab.list"
+#line 181 "zonetab.list"
diff --git a/ext/date/zonetab.list b/ext/date/zonetab.list
index 0618546eb0..3a4d121d2e 100644
--- a/ext/date/zonetab.list
+++ b/ext/date/zonetab.list
@@ -178,150 +178,4 @@ w. europe, 3600
west asia, 18000
west pacific, 36000
yakutsk, 32400
-acdt,37800
-acst,34200
-act,-18000
-acwst,31500
-aedt,39600
-aest,36000
-aft,16200
-almt,21600
-anast,43200
-anat,43200
-aoe,-43200
-aqtt,18000
-awdt,32400
-awst,28800
-azost,0
-azot,-3600
-azst,18000
-azt,14400
-bnt,28800
-bot,-14400
-btt,21600
-cast,28800
-chadt,49500
-chast,45900
-chost,32400
-chot,28800
-chst,36000
-chut,36000
-cidst,-14400
-cist,-18000
-ckt,-36000
-cot,-18000
-cvt,-3600
-cxt,25200
-davt,25200
-ddut,36000
-easst,-18000
-ect,-18000
-egst,0
-egt,-3600
-fet,10800
-fjst,46800
-fjt,43200
-fkst,-10800
-fkt,-14400
-fnt,-7200
-galt,-21600
-gamt,-32400
-get,14400
-gft,-10800
-gilt,43200
-gyt,-14400
-hkt,28800
-hovst,28800
-hovt,25200
-ict,25200
-idt,10800
-iot,21600
-irdt,16200
-irkst,32400
-irkt,28800
-irst,12600
-kgt,21600
-kost,39600
-krast,28800
-krat,25200
-kuyt,14400
-lhdt,39600
-lhst,37800
-lint,50400
-magst,43200
-magt,39600
-mart,-30600
-mawt,18000
-mht,43200
-mmt,23400
-mut,14400
-mvt,18000
-myt,28800
-nct,39600
-nfdt,43200
-nft,39600
-novst,25200
-novt,25200
-npt,20700
-nrt,43200
-nut,-39600
-omsst,25200
-omst,21600
-orat,18000
-pet,-18000
-petst,43200
-pett,43200
-pgt,36000
-phot,46800
-pht,28800
-pkt,18000
-pmdt,-7200
-pmst,-10800
-pont,39600
-pwt,32400
-pyst,-10800
-qyzt,21600
-ret,14400
-rott,-10800
-sakt,39600
-samt,14400
-sbt,39600
-sct,14400
-sret,39600
-srt,-10800
-syot,10800
-taht,-36000
-tft,18000
-tjt,18000
-tkt,46800
-tlt,32400
-tmt,18000
-tost,50400
-tot,46800
-trt,10800
-tvt,43200
-ulast,32400
-ulat,28800
-uyst,-7200
-uyt,-10800
-uzt,18000
-vet,-14400
-vlast,39600
-vlat,36000
-vost,21600
-vut,39600
-wakt,43200
-warst,-10800
-wft,43200
-wgst,-7200
-wgt,-10800
-wib,25200
-wit,32400
-wita,28800
-wt,0
-yakst,36000
-yakt,32400
-yapt,36000
-yekst,21600
-yekt,18000
%%
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index bc1d527735..4ac6898848 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -39,8 +39,6 @@ struct dbmdata {
DBM *di_dbm;
};
-NORETURN(static void closed_dbm(void));
-
static void
closed_dbm(void)
{
@@ -279,11 +277,12 @@ fdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
not_found:
if (NIL_P(ifnone) && rb_block_given_p()) {
keystr = rb_str_dup(keystr);
+ OBJ_TAINT(keystr);
return rb_yield(keystr);
}
return ifnone;
}
- return rb_str_new(value.dptr, value.dsize);
+ return rb_tainted_str_new(value.dptr, value.dsize);
}
/*
@@ -343,7 +342,7 @@ fdbm_key(VALUE obj, VALUE valstr)
val = dbm_fetch(dbm, key);
if ((long)val.dsize == RSTRING_LEN(valstr) &&
memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) {
- return rb_str_new(key.dptr, key.dsize);
+ return rb_tainted_str_new(key.dptr, key.dsize);
}
}
return Qnil;
@@ -376,8 +375,8 @@ fdbm_select(VALUE obj)
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
VALUE assoc, v;
val = dbm_fetch(dbm, key);
- assoc = rb_assoc_new(rb_str_new(key.dptr, key.dsize),
- rb_str_new(val.dptr, val.dsize));
+ assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
v = rb_yield(assoc);
if (RTEST(v)) {
rb_ary_push(new, assoc);
@@ -445,7 +444,7 @@ fdbm_delete(VALUE obj, VALUE keystr)
}
/* need to save value before dbm_delete() */
- valstr = rb_str_new(value.dptr, value.dsize);
+ valstr = rb_tainted_str_new(value.dptr, value.dsize);
if (dbm_delete(dbm, key)) {
dbmp->di_size = -1;
@@ -480,8 +479,8 @@ fdbm_shift(VALUE obj)
key = dbm_firstkey(dbm);
if (!key.dptr) return Qnil;
val = dbm_fetch(dbm, key);
- keystr = rb_str_new(key.dptr, key.dsize);
- valstr = rb_str_new(val.dptr, val.dsize);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
dbm_delete(dbm, key);
return rb_assoc_new(keystr, valstr);
@@ -513,9 +512,9 @@ fdbm_delete_if(VALUE obj)
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- keystr = rb_str_new(key.dptr, key.dsize);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
OBJ_FREEZE(keystr);
- valstr = rb_str_new(val.dptr, val.dsize);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
if (status != 0) break;
if (RTEST(ret)) rb_ary_push(ary, keystr);
@@ -582,8 +581,8 @@ fdbm_invert(VALUE obj)
GetDBM2(obj, dbmp, dbm);
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- keystr = rb_str_new(key.dptr, key.dsize);
- valstr = rb_str_new(val.dptr, val.dsize);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
rb_hash_aset(hash, valstr, keystr);
}
return hash;
@@ -743,7 +742,7 @@ fdbm_each_value(VALUE obj)
GetDBM2(obj, dbmp, dbm);
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- rb_yield(rb_str_new(val.dptr, val.dsize));
+ rb_yield(rb_tainted_str_new(val.dptr, val.dsize));
GetDBM2(obj, dbmp, dbm);
}
return obj;
@@ -766,7 +765,7 @@ fdbm_each_key(VALUE obj)
GetDBM2(obj, dbmp, dbm);
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
- rb_yield(rb_str_new(key.dptr, key.dsize));
+ rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
GetDBM2(obj, dbmp, dbm);
}
return obj;
@@ -793,8 +792,8 @@ fdbm_each_pair(VALUE obj)
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- keystr = rb_str_new(key.dptr, key.dsize);
- valstr = rb_str_new(val.dptr, val.dsize);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
rb_yield(rb_assoc_new(keystr, valstr));
GetDBM2(obj, dbmp, dbm);
}
@@ -820,7 +819,7 @@ fdbm_keys(VALUE obj)
ary = rb_ary_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
- rb_ary_push(ary, rb_str_new(key.dptr, key.dsize));
+ rb_ary_push(ary, rb_tainted_str_new(key.dptr, key.dsize));
}
return ary;
@@ -844,7 +843,7 @@ fdbm_values(VALUE obj)
ary = rb_ary_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- rb_ary_push(ary, rb_str_new(val.dptr, val.dsize));
+ rb_ary_push(ary, rb_tainted_str_new(val.dptr, val.dsize));
}
return ary;
@@ -930,8 +929,8 @@ fdbm_to_a(VALUE obj)
ary = rb_ary_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- rb_ary_push(ary, rb_assoc_new(rb_str_new(key.dptr, key.dsize),
- rb_str_new(val.dptr, val.dsize)));
+ rb_ary_push(ary, rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize)));
}
return ary;
@@ -956,8 +955,8 @@ fdbm_to_hash(VALUE obj)
hash = rb_hash_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- rb_hash_aset(hash, rb_str_new(key.dptr, key.dsize),
- rb_str_new(val.dptr, val.dsize));
+ rb_hash_aset(hash, rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
}
return hash;
@@ -993,7 +992,7 @@ fdbm_reject(VALUE obj)
* It is based on dbm library in Unix Version 7 but has different API to
* support multiple databases in a process.
* - {Berkeley DB}[http://en.wikipedia.org/wiki/Berkeley_DB] versions
- * 1 thru 6, also known as BDB and Sleepycat DB, now owned by Oracle
+ * 1 thru 5, also known as BDB and Sleepycat DB, now owned by Oracle
* Corporation.
* - Berkeley DB 1.x, still found in 4.4BSD derivatives (FreeBSD, OpenBSD, etc).
* - {gdbm}[http://www.gnu.org/software/gdbm/], the GNU implementation of dbm.
diff --git a/ext/dbm/dbm.gemspec b/ext/dbm/dbm.gemspec
index 9de425b521..9f3333a2b1 100644
--- a/ext/dbm/dbm.gemspec
+++ b/ext/dbm/dbm.gemspec
@@ -1,7 +1,8 @@
# frozen_string_literal: true
Gem::Specification.new do |s|
s.name = "dbm"
- s.version = '1.1.0'
+ s.version = '1.0.0'
+ s.date = '2017-02-08'
s.summary = "Provides a wrapper for the UNIX-style Database Manager Library"
s.description = "Provides a wrapper for the UNIX-style Database Manager Library"
diff --git a/ext/dbm/depend b/ext/dbm/depend
index 192527a8eb..b0de2ae2ee 100644
--- a/ext/dbm/depend
+++ b/ext/dbm/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
dbm.o: $(RUBY_EXTCONF_H)
dbm.o: $(arch_hdrdir)/ruby/config.h
-dbm.o: $(hdrdir)/ruby.h
-dbm.o: $(hdrdir)/ruby/assert.h
dbm.o: $(hdrdir)/ruby/backward.h
dbm.o: $(hdrdir)/ruby/defines.h
dbm.o: $(hdrdir)/ruby/intern.h
@@ -10,5 +8,6 @@ dbm.o: $(hdrdir)/ruby/missing.h
dbm.o: $(hdrdir)/ruby/ruby.h
dbm.o: $(hdrdir)/ruby/st.h
dbm.o: $(hdrdir)/ruby/subst.h
+dbm.o: $(top_srcdir)/include/ruby.h
dbm.o: dbm.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index c9a5518bf6..514aa3f8b0 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -7,7 +7,6 @@
# db Berkeley DB (libdb)
# db2 Berkeley DB (libdb2)
# db1 Berkeley DB (libdb1)
-# db6 Berkeley DB (libdb6)
# db5 Berkeley DB (libdb5)
# db4 Berkeley DB (libdb4)
# db3 Berkeley DB (libdb3)
@@ -24,7 +23,7 @@ dir_config("dbm")
if dblib = with_config("dbm-type", nil)
dblib = dblib.split(/[ ,]+/)
else
- dblib = %w(libc db db2 db1 db6 db5 db4 db3 gdbm_compat gdbm qdbm)
+ dblib = %w(libc db db2 db1 db5 db4 db3 gdbm_compat gdbm qdbm)
end
headers = {
@@ -35,7 +34,6 @@ headers = {
"db3" => ["db3/db.h", "db3.h", "db.h"],
"db4" => ["db4/db.h", "db4.h", "db.h"],
"db5" => ["db5/db.h", "db5.h", "db.h"],
- "db6" => ["db6/db.h", "db6.h", "db.h"],
"gdbm_compat" => ["gdbm-ndbm.h", "gdbm/ndbm.h", "ndbm.h"], # GDBM since 1.8.1
"gdbm" => ["gdbm-ndbm.h", "gdbm/ndbm.h", "ndbm.h"], # GDBM until 1.8.0
"qdbm" => ["qdbm/relic.h", "relic.h"],
@@ -133,7 +131,7 @@ def headers.db_check2(db, hdr)
hsearch = nil
case db
- when /^db[2-6]?$/
+ when /^db[2-5]?$/
hsearch = "-DDB_DBM_HSEARCH"
when "gdbm_compat"
have_library("gdbm") or return false
diff --git a/ext/digest/bubblebabble/bubblebabble.c b/ext/digest/bubblebabble/bubblebabble.c
index 6557e43c9d..8f436908d3 100644
--- a/ext/digest/bubblebabble/bubblebabble.c
+++ b/ext/digest/bubblebabble/bubblebabble.c
@@ -124,7 +124,6 @@ rb_digest_instance_bubblebabble(VALUE self)
void
Init_bubblebabble(void)
{
-#undef rb_intern
VALUE rb_mDigest, rb_mDigest_Instance, rb_cDigest_Class;
rb_require("digest");
diff --git a/ext/digest/bubblebabble/depend b/ext/digest/bubblebabble/depend
index e7e2a8889d..c0550f3180 100644
--- a/ext/digest/bubblebabble/depend
+++ b/ext/digest/bubblebabble/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
bubblebabble.o: $(RUBY_EXTCONF_H)
bubblebabble.o: $(arch_hdrdir)/ruby/config.h
-bubblebabble.o: $(hdrdir)/ruby.h
-bubblebabble.o: $(hdrdir)/ruby/assert.h
bubblebabble.o: $(hdrdir)/ruby/backward.h
bubblebabble.o: $(hdrdir)/ruby/defines.h
bubblebabble.o: $(hdrdir)/ruby/intern.h
@@ -10,6 +8,7 @@ bubblebabble.o: $(hdrdir)/ruby/missing.h
bubblebabble.o: $(hdrdir)/ruby/ruby.h
bubblebabble.o: $(hdrdir)/ruby/st.h
bubblebabble.o: $(hdrdir)/ruby/subst.h
-bubblebabble.o: $(srcdir)/../digest.h
+bubblebabble.o: $(top_srcdir)/ext/digest/digest.h
+bubblebabble.o: $(top_srcdir)/include/ruby.h
bubblebabble.o: bubblebabble.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/digest/depend b/ext/digest/depend
index 87c39c8b8d..8e3b4691e8 100644
--- a/ext/digest/depend
+++ b/ext/digest/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
digest.o: $(RUBY_EXTCONF_H)
digest.o: $(arch_hdrdir)/ruby/config.h
-digest.o: $(hdrdir)/ruby.h
-digest.o: $(hdrdir)/ruby/assert.h
digest.o: $(hdrdir)/ruby/backward.h
digest.o: $(hdrdir)/ruby/defines.h
digest.o: $(hdrdir)/ruby/intern.h
@@ -10,6 +8,7 @@ digest.o: $(hdrdir)/ruby/missing.h
digest.o: $(hdrdir)/ruby/ruby.h
digest.o: $(hdrdir)/ruby/st.h
digest.o: $(hdrdir)/ruby/subst.h
+digest.o: $(top_srcdir)/include/ruby.h
digest.o: digest.c
digest.o: digest.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index a59f880ac7..9838ed33de 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -554,22 +554,10 @@ get_digest_base_metadata(VALUE klass)
if (NIL_P(p))
rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby");
- if (!RB_TYPE_P(obj, T_DATA) || RTYPEDDATA_P(obj)) {
- wrong:
- if (p == klass)
- rb_raise(rb_eTypeError, "%"PRIsVALUE"::metadata is not initialized properly",
- klass);
- else
- rb_raise(rb_eTypeError, "%"PRIsVALUE"(%"PRIsVALUE")::metadata is not initialized properly",
- klass, p);
- }
-
#undef RUBY_UNTYPED_DATA_WARNING
#define RUBY_UNTYPED_DATA_WARNING 0
Data_Get_Struct(obj, rb_digest_metadata_t, algo);
- if (!algo) goto wrong;
-
switch (algo->api_version) {
case 3:
break;
@@ -585,12 +573,6 @@ get_digest_base_metadata(VALUE klass)
return algo;
}
-static rb_digest_metadata_t *
-get_digest_obj_metadata(VALUE obj)
-{
- return get_digest_base_metadata(rb_obj_class(obj));
-}
-
static const rb_data_type_t digest_type = {
"digest",
{0, RUBY_TYPED_DEFAULT_FREE, 0,},
@@ -637,8 +619,8 @@ rb_digest_base_copy(VALUE copy, VALUE obj)
rb_check_frozen(copy);
- algo = get_digest_obj_metadata(copy);
- if (algo != get_digest_obj_metadata(obj))
+ algo = get_digest_base_metadata(rb_obj_class(copy));
+ if (algo != get_digest_base_metadata(rb_obj_class(obj)))
rb_raise(rb_eTypeError, "different algorithms");
TypedData_Get_Struct(obj, void, &digest_type, pctx1);
@@ -659,7 +641,7 @@ rb_digest_base_reset(VALUE self)
rb_digest_metadata_t *algo;
void *pctx;
- algo = get_digest_obj_metadata(self);
+ algo = get_digest_base_metadata(rb_obj_class(self));
TypedData_Get_Struct(self, void, &digest_type, pctx);
@@ -681,7 +663,7 @@ rb_digest_base_update(VALUE self, VALUE str)
rb_digest_metadata_t *algo;
void *pctx;
- algo = get_digest_obj_metadata(self);
+ algo = get_digest_base_metadata(rb_obj_class(self));
TypedData_Get_Struct(self, void, &digest_type, pctx);
@@ -700,7 +682,7 @@ rb_digest_base_finish(VALUE self)
void *pctx;
VALUE str;
- algo = get_digest_obj_metadata(self);
+ algo = get_digest_base_metadata(rb_obj_class(self));
TypedData_Get_Struct(self, void, &digest_type, pctx);
@@ -723,7 +705,7 @@ rb_digest_base_digest_length(VALUE self)
{
rb_digest_metadata_t *algo;
- algo = get_digest_obj_metadata(self);
+ algo = get_digest_base_metadata(rb_obj_class(self));
return INT2NUM(algo->digest_len);
}
@@ -738,7 +720,7 @@ rb_digest_base_block_length(VALUE self)
{
rb_digest_metadata_t *algo;
- algo = get_digest_obj_metadata(self);
+ algo = get_digest_base_metadata(rb_obj_class(self));
return INT2NUM(algo->block_len);
}
@@ -746,20 +728,13 @@ rb_digest_base_block_length(VALUE self)
void
Init_digest(void)
{
-#undef rb_intern
id_reset = rb_intern("reset");
id_update = rb_intern("update");
id_finish = rb_intern("finish");
id_digest = rb_intern("digest");
id_hexdigest = rb_intern("hexdigest");
id_digest_length = rb_intern("digest_length");
- id_metadata = rb_id_metadata();
- InitVM(digest);
-}
-void
-InitVM_digest(void)
-{
/*
* module Digest
*/
@@ -806,6 +781,8 @@ InitVM_digest(void)
rb_define_singleton_method(rb_cDigest_Class, "digest", rb_digest_class_s_digest, -1);
rb_define_singleton_method(rb_cDigest_Class, "hexdigest", rb_digest_class_s_hexdigest, -1);
+ id_metadata = rb_intern("metadata");
+
/* class Digest::Base < Digest::Class */
rb_cDigest_Base = rb_define_class_under(rb_mDigest, "Base", rb_cDigest_Class);
diff --git a/ext/digest/digest.h b/ext/digest/digest.h
index 4b6954089f..30359ad348 100644
--- a/ext/digest/digest.h
+++ b/ext/digest/digest.h
@@ -49,16 +49,3 @@ rb_digest_##name##_finish(void *ctx, unsigned char *ptr) \
{ \
return name##_Final(ptr, ctx); \
}
-
-static inline VALUE
-rb_digest_namespace(void)
-{
- rb_require("digest");
- return rb_path2class("Digest");
-}
-
-static inline ID
-rb_id_metadata(void)
-{
- return rb_intern_const("metadata");
-}
diff --git a/ext/digest/md5/depend b/ext/digest/md5/depend
index abfd8de6a5..03c4cc8640 100644
--- a/ext/digest/md5/depend
+++ b/ext/digest/md5/depend
@@ -4,8 +4,6 @@ md5init.o: $(LOCAL_HDRS)
# AUTOGENERATED DEPENDENCIES START
md5init.o: $(RUBY_EXTCONF_H)
md5init.o: $(arch_hdrdir)/ruby/config.h
-md5init.o: $(hdrdir)/ruby.h
-md5init.o: $(hdrdir)/ruby/assert.h
md5init.o: $(hdrdir)/ruby/backward.h
md5init.o: $(hdrdir)/ruby/defines.h
md5init.o: $(hdrdir)/ruby/intern.h
@@ -13,7 +11,8 @@ md5init.o: $(hdrdir)/ruby/missing.h
md5init.o: $(hdrdir)/ruby/ruby.h
md5init.o: $(hdrdir)/ruby/st.h
md5init.o: $(hdrdir)/ruby/subst.h
-md5init.o: $(srcdir)/../digest.h
+md5init.o: $(top_srcdir)/ext/digest/digest.h
+md5init.o: $(top_srcdir)/include/ruby.h
md5init.o: md5init.c
md5init.o: md5ossl.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/digest/md5/md5cc.h b/ext/digest/md5/md5cc.h
index e34d7d5c11..35652eac6a 100644
--- a/ext/digest/md5/md5cc.h
+++ b/ext/digest/md5/md5cc.h
@@ -1,13 +1,6 @@
#define COMMON_DIGEST_FOR_OPENSSL 1
#include <CommonCrypto/CommonDigest.h>
-#ifdef __clang__
-# pragma clang diagnostic ignored "-Wdeprecated-declarations"
-/* Suppress deprecation warnings of MD5 from Xcode 11.1 */
-/* Although we know MD5 is deprecated too, provide just for backward
- * compatibility, as well as Apple does. */
-#endif
-
#define MD5_BLOCK_LENGTH CC_MD5_BLOCK_BYTES
static DEFINE_UPDATE_FUNC_FOR_UINT(MD5)
diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c
index dafd38a29c..fdd8b36c5d 100644
--- a/ext/digest/md5/md5init.c
+++ b/ext/digest/md5/md5init.c
@@ -51,10 +51,12 @@ Init_md5(void)
{
VALUE mDigest, cDigest_Base, cDigest_MD5;
+ rb_require("digest");
+
#if 0
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
- mDigest = rb_digest_namespace();
+ mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend
index 07c406a7d2..2dfeecf034 100644
--- a/ext/digest/rmd160/depend
+++ b/ext/digest/rmd160/depend
@@ -4,8 +4,6 @@ rmd160init.o: $(LOCAL_HDRS)
# AUTOGENERATED DEPENDENCIES START
rmd160init.o: $(RUBY_EXTCONF_H)
rmd160init.o: $(arch_hdrdir)/ruby/config.h
-rmd160init.o: $(hdrdir)/ruby.h
-rmd160init.o: $(hdrdir)/ruby/assert.h
rmd160init.o: $(hdrdir)/ruby/backward.h
rmd160init.o: $(hdrdir)/ruby/defines.h
rmd160init.o: $(hdrdir)/ruby/intern.h
@@ -13,7 +11,8 @@ rmd160init.o: $(hdrdir)/ruby/missing.h
rmd160init.o: $(hdrdir)/ruby/ruby.h
rmd160init.o: $(hdrdir)/ruby/st.h
rmd160init.o: $(hdrdir)/ruby/subst.h
-rmd160init.o: $(srcdir)/../digest.h
+rmd160init.o: $(top_srcdir)/ext/digest/digest.h
+rmd160init.o: $(top_srcdir)/include/ruby.h
rmd160init.o: rmd160init.c
rmd160init.o: rmd160ossl.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/digest/rmd160/rmd160init.c b/ext/digest/rmd160/rmd160init.c
index a2c0a023c0..10d9370163 100644
--- a/ext/digest/rmd160/rmd160init.c
+++ b/ext/digest/rmd160/rmd160init.c
@@ -49,10 +49,12 @@ Init_rmd160(void)
{
VALUE mDigest, cDigest_Base, cDigest_RMD160;
+ rb_require("digest");
+
#if 0
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
- mDigest = rb_digest_namespace();
+ mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
diff --git a/ext/digest/sha1/depend b/ext/digest/sha1/depend
index bc9e216eed..5139f44ff4 100644
--- a/ext/digest/sha1/depend
+++ b/ext/digest/sha1/depend
@@ -4,8 +4,6 @@ sha1init.o: $(LOCAL_HDRS)
# AUTOGENERATED DEPENDENCIES START
sha1init.o: $(RUBY_EXTCONF_H)
sha1init.o: $(arch_hdrdir)/ruby/config.h
-sha1init.o: $(hdrdir)/ruby.h
-sha1init.o: $(hdrdir)/ruby/assert.h
sha1init.o: $(hdrdir)/ruby/backward.h
sha1init.o: $(hdrdir)/ruby/defines.h
sha1init.o: $(hdrdir)/ruby/intern.h
@@ -13,7 +11,8 @@ sha1init.o: $(hdrdir)/ruby/missing.h
sha1init.o: $(hdrdir)/ruby/ruby.h
sha1init.o: $(hdrdir)/ruby/st.h
sha1init.o: $(hdrdir)/ruby/subst.h
-sha1init.o: $(srcdir)/../digest.h
+sha1init.o: $(top_srcdir)/ext/digest/digest.h
+sha1init.o: $(top_srcdir)/include/ruby.h
sha1init.o: sha1init.c
sha1init.o: sha1ossl.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/digest/sha1/sha1init.c b/ext/digest/sha1/sha1init.c
index 3adf424b1d..e12d297699 100644
--- a/ext/digest/sha1/sha1init.c
+++ b/ext/digest/sha1/sha1init.c
@@ -53,10 +53,12 @@ Init_sha1(void)
{
VALUE mDigest, cDigest_Base, cDigest_SHA1;
+ rb_require("digest");
+
#if 0
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
- mDigest = rb_digest_namespace();
+ mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
diff --git a/ext/digest/sha2/depend b/ext/digest/sha2/depend
index 8946d44f31..1152fe4dac 100644
--- a/ext/digest/sha2/depend
+++ b/ext/digest/sha2/depend
@@ -4,8 +4,6 @@ sha2init.o: $(LOCAL_HDRS)
# AUTOGENERATED DEPENDENCIES START
sha2init.o: $(RUBY_EXTCONF_H)
sha2init.o: $(arch_hdrdir)/ruby/config.h
-sha2init.o: $(hdrdir)/ruby.h
-sha2init.o: $(hdrdir)/ruby/assert.h
sha2init.o: $(hdrdir)/ruby/backward.h
sha2init.o: $(hdrdir)/ruby/defines.h
sha2init.o: $(hdrdir)/ruby/intern.h
@@ -13,7 +11,8 @@ sha2init.o: $(hdrdir)/ruby/missing.h
sha2init.o: $(hdrdir)/ruby/ruby.h
sha2init.o: $(hdrdir)/ruby/st.h
sha2init.o: $(hdrdir)/ruby/subst.h
-sha2init.o: $(srcdir)/../digest.h
+sha2init.o: $(top_srcdir)/ext/digest/digest.h
+sha2init.o: $(top_srcdir)/include/ruby.h
sha2init.o: sha2init.c
sha2init.o: sha2ossl.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c
index 7d211784a3..9fd8ece7fe 100644
--- a/ext/digest/sha2/sha2init.c
+++ b/ext/digest/sha2/sha2init.c
@@ -35,14 +35,18 @@ void
Init_sha2(void)
{
VALUE mDigest, cDigest_Base;
- ID id_metadata = rb_id_metadata();
+ ID id_metadata;
#define DECLARE_ALGO_CLASS(bitlen) \
VALUE cDigest_SHA##bitlen;
FOREACH_BITLEN(DECLARE_ALGO_CLASS)
- mDigest = rb_digest_namespace();
+ rb_require("digest");
+
+ id_metadata = rb_intern_const("metadata");
+
+ mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
#define DEFINE_ALGO_CLASS(bitlen) \
diff --git a/ext/etc/depend b/ext/etc/depend
index 99e812c7e4..2d986c5913 100644
--- a/ext/etc/depend
+++ b/ext/etc/depend
@@ -5,8 +5,6 @@ constdefs.h : $(srcdir)/mkconstants.rb
# AUTOGENERATED DEPENDENCIES START
etc.o: $(RUBY_EXTCONF_H)
etc.o: $(arch_hdrdir)/ruby/config.h
-etc.o: $(hdrdir)/ruby.h
-etc.o: $(hdrdir)/ruby/assert.h
etc.o: $(hdrdir)/ruby/backward.h
etc.o: $(hdrdir)/ruby/defines.h
etc.o: $(hdrdir)/ruby/encoding.h
@@ -18,6 +16,7 @@ etc.o: $(hdrdir)/ruby/oniguruma.h
etc.o: $(hdrdir)/ruby/ruby.h
etc.o: $(hdrdir)/ruby/st.h
etc.o: $(hdrdir)/ruby/subst.h
+etc.o: $(top_srcdir)/include/ruby.h
etc.o: constdefs.h
etc.o: etc.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 2f3fbb737b..2dd4ed673e 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -52,8 +52,6 @@ char *getenv();
#endif
char *getlogin();
-#define RUBY_ETC_VERSION "1.1.0"
-
#include "constdefs.h"
/* call-seq:
@@ -100,7 +98,7 @@ static VALUE
safe_setup_str(const char *str)
{
if (str == 0) str = "";
- return rb_str_new2(str);
+ return rb_tainted_str_new2(str);
}
static VALUE
@@ -219,6 +217,7 @@ etc_getpwnam(VALUE obj, VALUE nam)
struct passwd *pwd;
const char *p = StringValueCStr(nam);
+ rb_check_safe_obj(nam);
pwd = getpwnam(p);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam);
return setup_passwd(pwd);
@@ -230,7 +229,7 @@ etc_getpwnam(VALUE obj, VALUE nam)
#ifdef HAVE_GETPWENT
static int passwd_blocking = 0;
static VALUE
-passwd_ensure(VALUE _)
+passwd_ensure(void)
{
endpwent();
passwd_blocking = (int)Qfalse;
@@ -238,7 +237,7 @@ passwd_ensure(VALUE _)
}
static VALUE
-passwd_iterate(VALUE _)
+passwd_iterate(void)
{
struct passwd *pw;
@@ -462,6 +461,7 @@ etc_getgrnam(VALUE obj, VALUE nam)
struct group *grp;
const char *p = StringValueCStr(nam);
+ rb_check_safe_obj(nam);
grp = getgrnam(p);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, nam);
return setup_group(grp);
@@ -473,7 +473,7 @@ etc_getgrnam(VALUE obj, VALUE nam)
#ifdef HAVE_GETGRENT
static int group_blocking = 0;
static VALUE
-group_ensure(VALUE _)
+group_ensure(void)
{
endgrent();
group_blocking = (int)Qfalse;
@@ -482,7 +482,7 @@ group_ensure(VALUE _)
static VALUE
-group_iterate(VALUE _)
+group_iterate(void)
{
struct group *pw;
@@ -645,7 +645,7 @@ etc_sysconfdir(VALUE obj)
* Returns system temporary directory; typically "/tmp".
*/
static VALUE
-etc_systmpdir(VALUE _)
+etc_systmpdir(void)
{
VALUE tmpdir;
#ifdef _WIN32
@@ -677,10 +677,7 @@ etc_systmpdir(VALUE _)
}
# endif
#endif
-#ifndef RB_PASS_KEYWORDS
- /* untaint on Ruby < 2.7 */
FL_UNSET(tmpdir, FL_TAINT);
-#endif
return tmpdir;
}
@@ -757,6 +754,9 @@ etc_uname(VALUE obj)
# ifndef PROCESSOR_ARCHITECTURE_AMD64
# define PROCESSOR_ARCHITECTURE_AMD64 9
# endif
+# ifndef PROCESSOR_ARCHITECTURE_IA64
+# define PROCESSOR_ARCHITECTURE_IA64 6
+# endif
# ifndef PROCESSOR_ARCHITECTURE_INTEL
# define PROCESSOR_ARCHITECTURE_INTEL 0
# endif
@@ -768,6 +768,9 @@ etc_uname(VALUE obj)
case PROCESSOR_ARCHITECTURE_ARM:
mach = "ARM";
break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ mach = "IA64";
+ break;
case PROCESSOR_ARCHITECTURE_INTEL:
mach = "x86";
break;
@@ -1065,7 +1068,6 @@ Init_etc(void)
VALUE mEtc;
mEtc = rb_define_module("Etc");
- rb_define_const(mEtc, "VERSION", rb_str_new_cstr(RUBY_ETC_VERSION));
init_constants(mEtc);
rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);
diff --git a/ext/etc/etc.gemspec b/ext/etc/etc.gemspec
index f28016925f..a6a018c2a1 100644
--- a/ext/etc/etc.gemspec
+++ b/ext/etc/etc.gemspec
@@ -1,38 +1,35 @@
+# coding: utf-8
# frozen_string_literal: true
-version = ["", "ext/etc/"].find do |dir|
- begin
- break File.open(File.expand_path("../#{dir}/etc.c", __FILE__)) do |f|
- f.gets "\n#define RUBY_ETC_VERSION "
- f.gets[/"(.+)"/, 1]
- end
- rescue
- next
- end
-end
-
Gem::Specification.new do |spec|
spec.name = "etc"
- spec.version = version
+ spec.version = "1.0.0"
+ spec.date = '2017-12-13'
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
spec.summary = %q{Provides access to information typically stored in UNIX /etc directory.}
- spec.description = spec.summary
+ spec.description = %q{Provides access to information typically stored in UNIX /etc directory.}
spec.homepage = "https://github.com/ruby/etc"
spec.license = "BSD-2-Clause"
spec.files = %w[
+ .gitignore
+ .travis.yml
+ Gemfile
LICENSE.txt
README.md
- ext/etc/constdefs.h
+ Rakefile
+ bin/console
+ bin/setup
+ etc.gemspec
ext/etc/etc.c
ext/etc/extconf.rb
ext/etc/mkconstants.rb
- stub/etc.rb
test/etc/test_etc.rb
]
spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.extensions = %w{ext/etc/extconf.rb}
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 435fbe7f3d..20a7dd00d6 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -41,12 +41,6 @@ have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
have_struct_member('struct group', 'gr_passwd', 'grp.h')
-# for https://github.com/ruby/etc
-srcdir = File.expand_path("..", __FILE__)
-if !File.exist?("#{srcdir}/depend")
- %x[#{RbConfig.ruby} #{srcdir}/mkconstants.rb -o #{srcdir}/constdefs.h]
-end
-
$distcleanfiles << "constdefs.h"
create_makefile("etc")
diff --git a/ext/etc/mkconstants.rb b/ext/etc/mkconstants.rb
index a752d64519..18f34c9875 100644
--- a/ext/etc/mkconstants.rb
+++ b/ext/etc/mkconstants.rb
@@ -66,15 +66,7 @@ def each_name(pat)
}
end
-erb_new = lambda do |src, safe, trim|
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- ERB.new(src, trim_mode: trim)
- else
- ERB.new(src, safe, trim)
- end
-end
-
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% each_const {|name, default_value|
#if !defined(<%=name%>)
# if defined(HAVE_CONST_<%=name.upcase%>)
@@ -88,7 +80,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
% each_const {|name, default_value|
#if defined(<%=name%>)
% if comment = COMMENTS[name]
@@ -99,13 +91,13 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
% }
EOS
-header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
+header_result = ERB.new(<<'EOS', nil, '%').result(binding)
/* autogenerated file */
<%= gen_const_decls %>
EOS
-result = erb_new.call(<<'EOS', nil, '%').result(binding)
+result = ERB.new(<<'EOS', nil, '%').result(binding)
/* autogenerated file */
#ifdef HAVE_LONG_LONG
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 80a0a1208d..e83a0e5d8c 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -463,11 +463,7 @@ end unless $extstatic
if ARGV[0]
ext_prefix, exts = ARGV.shift.split('/', 2)
$extension = [exts] if exts
- if ext_prefix == 'gems'
- @gemname = exts
- elsif exts
- $static_ext.delete_if {|t, *| !File.fnmatch(t, exts)}
- end
+ @gemname = exts if ext_prefix == 'gems'
end
ext_prefix = "#{$top_srcdir}/#{ext_prefix || 'ext'}"
exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t}
@@ -500,17 +496,13 @@ cond = proc {|ext, *|
}
($extension || %w[*]).each do |e|
e = e.sub(/\A(?:\.\/)+/, '')
- incl, excl = Dir.glob("#{ext_prefix}/#{e}/**/extconf.rb").collect {|d|
+ exts |= Dir.glob("#{ext_prefix}/#{e}/**/extconf.rb").collect {|d|
d = File.dirname(d)
d.slice!(0, ext_prefix.length + 1)
d
- }.partition {|ext|
+ }.find_all {|ext|
with_config(ext, &cond)
- }
- incl.sort!
- excl.sort!.collect! {|d| d+"/"}
- nil while incl.reject! {|d| excl << d+"/" if excl.any? {|x| d.start_with?(x)}}
- exts |= incl
+ }.sort
if $LIBRUBYARG_SHARED.empty? and CONFIG["EXTSTATIC"] == "static"
exts.delete_if {|d| File.fnmatch?("-*", d)}
end
@@ -692,8 +684,8 @@ begin
submakeopts << 'UPDATE_LIBRARIES="$(UPDATE_LIBRARIES)"'
submakeopts << 'SHOWFLAGS='
mf.macro "SUBMAKEOPTS", submakeopts
- mf.macro "NOTE_MESG", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb skip]
- mf.macro "NOTE_NAME", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb fail]
+ mf.macro "NOTE_MESG", %w[$(RUBY) $(top_srcdir)/tool/colorize.rb skip]
+ mf.macro "NOTE_NAME", %w[$(RUBY) $(top_srcdir)/tool/colorize.rb fail]
mf.puts
targets = %w[all install static install-so install-rb clean distclean realclean]
targets.each do |tgt|
@@ -726,16 +718,7 @@ begin
end
targets.each do |tgt|
exts.each do |d|
- d = d[0..-2]
- t = "#{d}#{tgt}"
- if /^(dist|real)?clean$/ =~ tgt
- deps = exts.select {|e|e.start_with?(d)}.map {|e|"#{e[0..-2]}#{tgt}"} - [t]
- pd = ' ' + deps.join(' ') unless deps.empty?
- else
- pext = File.dirname(d)
- pd = " #{pext}/#{tgt}" if exts.include?("#{pext}/.")
- end
- mf.puts "#{t}:#{pd}\n\t$(Q)#{submake} $(MFLAGS) V=$(V) $(@F)"
+ mf.puts "#{d[0..-2]}#{tgt}:\n\t$(Q)#{submake} $(MFLAGS) V=$(V) $(@F)"
end
end
mf.puts "\n""extso:\n"
diff --git a/ext/fcntl/depend b/ext/fcntl/depend
index 60d6be6b89..61d7dc20ee 100644
--- a/ext/fcntl/depend
+++ b/ext/fcntl/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
fcntl.o: $(RUBY_EXTCONF_H)
fcntl.o: $(arch_hdrdir)/ruby/config.h
-fcntl.o: $(hdrdir)/ruby.h
-fcntl.o: $(hdrdir)/ruby/assert.h
fcntl.o: $(hdrdir)/ruby/backward.h
fcntl.o: $(hdrdir)/ruby/defines.h
fcntl.o: $(hdrdir)/ruby/intern.h
@@ -10,5 +8,6 @@ fcntl.o: $(hdrdir)/ruby/missing.h
fcntl.o: $(hdrdir)/ruby/ruby.h
fcntl.o: $(hdrdir)/ruby/st.h
fcntl.o: $(hdrdir)/ruby/subst.h
+fcntl.o: $(top_srcdir)/include/ruby.h
fcntl.o: fcntl.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/fcntl/fcntl.gemspec b/ext/fcntl/fcntl.gemspec
index 0e3194fbdc..2bdefa0888 100644
--- a/ext/fcntl/fcntl.gemspec
+++ b/ext/fcntl/fcntl.gemspec
@@ -4,6 +4,7 @@
Gem::Specification.new do |spec|
spec.name = "fcntl"
spec.version = "1.0.0"
+ spec.date = '2017-12-11'
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/ext/fiber/depend b/ext/fiber/depend
index 675263b95c..85cac2f03c 100644
--- a/ext/fiber/depend
+++ b/ext/fiber/depend
@@ -1,3 +1 @@
-# AUTOGENERATED DEPENDENCIES START
fiber.o: fiber.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
index 2044c836ea..1a80b2b02a 100644
--- a/ext/fiddle/closure.c
+++ b/ext/fiddle/closure.c
@@ -14,7 +14,10 @@ typedef struct {
} fiddle_closure;
#if defined(USE_FFI_CLOSURE_ALLOC)
-#elif !defined(HAVE_FFI_CLOSURE_ALLOC)
+#elif defined(__OpenBSD__) || defined(__APPLE__) || defined(__linux__)
+# define USE_FFI_CLOSURE_ALLOC 0
+#elif defined(RUBY_LIBFFI_MODVERSION) && RUBY_LIBFFI_MODVERSION < 3000005 && \
+ (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64))
# define USE_FFI_CLOSURE_ALLOC 0
#else
# define USE_FFI_CLOSURE_ALLOC 1
diff --git a/ext/fiddle/depend b/ext/fiddle/depend
index 5ed745fa0f..7209469260 100644
--- a/ext/fiddle/depend
+++ b/ext/fiddle/depend
@@ -54,16 +54,20 @@ realclean: realclean-$(LIBFFI_CLEAN)
# AUTOGENERATED DEPENDENCIES START
closure.o: $(RUBY_EXTCONF_H)
closure.o: $(arch_hdrdir)/ruby/config.h
-closure.o: $(hdrdir)/ruby.h
-closure.o: $(hdrdir)/ruby/assert.h
closure.o: $(hdrdir)/ruby/backward.h
closure.o: $(hdrdir)/ruby/defines.h
+closure.o: $(hdrdir)/ruby/encoding.h
closure.o: $(hdrdir)/ruby/intern.h
+closure.o: $(hdrdir)/ruby/io.h
closure.o: $(hdrdir)/ruby/missing.h
+closure.o: $(hdrdir)/ruby/onigmo.h
+closure.o: $(hdrdir)/ruby/oniguruma.h
closure.o: $(hdrdir)/ruby/ruby.h
closure.o: $(hdrdir)/ruby/st.h
closure.o: $(hdrdir)/ruby/subst.h
closure.o: $(hdrdir)/ruby/thread.h
+closure.o: $(top_srcdir)/include/ruby.h
+closure.o: $(top_srcdir)/internal.h
closure.o: closure.c
closure.o: closure.h
closure.o: conversions.h
@@ -71,8 +75,6 @@ closure.o: fiddle.h
closure.o: function.h
conversions.o: $(RUBY_EXTCONF_H)
conversions.o: $(arch_hdrdir)/ruby/config.h
-conversions.o: $(hdrdir)/ruby.h
-conversions.o: $(hdrdir)/ruby/assert.h
conversions.o: $(hdrdir)/ruby/backward.h
conversions.o: $(hdrdir)/ruby/defines.h
conversions.o: $(hdrdir)/ruby/intern.h
@@ -80,6 +82,7 @@ conversions.o: $(hdrdir)/ruby/missing.h
conversions.o: $(hdrdir)/ruby/ruby.h
conversions.o: $(hdrdir)/ruby/st.h
conversions.o: $(hdrdir)/ruby/subst.h
+conversions.o: $(top_srcdir)/include/ruby.h
conversions.o: closure.h
conversions.o: conversions.c
conversions.o: conversions.h
@@ -87,8 +90,6 @@ conversions.o: fiddle.h
conversions.o: function.h
fiddle.o: $(RUBY_EXTCONF_H)
fiddle.o: $(arch_hdrdir)/ruby/config.h
-fiddle.o: $(hdrdir)/ruby.h
-fiddle.o: $(hdrdir)/ruby/assert.h
fiddle.o: $(hdrdir)/ruby/backward.h
fiddle.o: $(hdrdir)/ruby/defines.h
fiddle.o: $(hdrdir)/ruby/intern.h
@@ -96,6 +97,7 @@ fiddle.o: $(hdrdir)/ruby/missing.h
fiddle.o: $(hdrdir)/ruby/ruby.h
fiddle.o: $(hdrdir)/ruby/st.h
fiddle.o: $(hdrdir)/ruby/subst.h
+fiddle.o: $(top_srcdir)/include/ruby.h
fiddle.o: closure.h
fiddle.o: conversions.h
fiddle.o: fiddle.c
@@ -103,8 +105,6 @@ fiddle.o: fiddle.h
fiddle.o: function.h
function.o: $(RUBY_EXTCONF_H)
function.o: $(arch_hdrdir)/ruby/config.h
-function.o: $(hdrdir)/ruby.h
-function.o: $(hdrdir)/ruby/assert.h
function.o: $(hdrdir)/ruby/backward.h
function.o: $(hdrdir)/ruby/defines.h
function.o: $(hdrdir)/ruby/intern.h
@@ -113,6 +113,7 @@ function.o: $(hdrdir)/ruby/ruby.h
function.o: $(hdrdir)/ruby/st.h
function.o: $(hdrdir)/ruby/subst.h
function.o: $(hdrdir)/ruby/thread.h
+function.o: $(top_srcdir)/include/ruby.h
function.o: closure.h
function.o: conversions.h
function.o: fiddle.h
@@ -120,8 +121,6 @@ function.o: function.c
function.o: function.h
handle.o: $(RUBY_EXTCONF_H)
handle.o: $(arch_hdrdir)/ruby/config.h
-handle.o: $(hdrdir)/ruby.h
-handle.o: $(hdrdir)/ruby/assert.h
handle.o: $(hdrdir)/ruby/backward.h
handle.o: $(hdrdir)/ruby/defines.h
handle.o: $(hdrdir)/ruby/intern.h
@@ -129,6 +128,7 @@ handle.o: $(hdrdir)/ruby/missing.h
handle.o: $(hdrdir)/ruby/ruby.h
handle.o: $(hdrdir)/ruby/st.h
handle.o: $(hdrdir)/ruby/subst.h
+handle.o: $(top_srcdir)/include/ruby.h
handle.o: closure.h
handle.o: conversions.h
handle.o: fiddle.h
@@ -136,8 +136,6 @@ handle.o: function.h
handle.o: handle.c
pointer.o: $(RUBY_EXTCONF_H)
pointer.o: $(arch_hdrdir)/ruby/config.h
-pointer.o: $(hdrdir)/ruby.h
-pointer.o: $(hdrdir)/ruby/assert.h
pointer.o: $(hdrdir)/ruby/backward.h
pointer.o: $(hdrdir)/ruby/defines.h
pointer.o: $(hdrdir)/ruby/encoding.h
@@ -149,6 +147,7 @@ pointer.o: $(hdrdir)/ruby/oniguruma.h
pointer.o: $(hdrdir)/ruby/ruby.h
pointer.o: $(hdrdir)/ruby/st.h
pointer.o: $(hdrdir)/ruby/subst.h
+pointer.o: $(top_srcdir)/include/ruby.h
pointer.o: closure.h
pointer.o: conversions.h
pointer.o: fiddle.h
diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb
index f8a94d41e7..2c333001e5 100644
--- a/ext/fiddle/extconf.rb
+++ b/ext/fiddle/extconf.rb
@@ -13,21 +13,11 @@ if ! bundle
if have_header(ffi_header = 'ffi.h')
true
elsif have_header(ffi_header = 'ffi/ffi.h')
- $defs.push('-DUSE_HEADER_HACKS')
+ $defs.push(format('-DUSE_HEADER_HACKS'))
true
end and (have_library('ffi') || have_library('libffi'))
end or
begin
- # for https://github.com/ruby/fiddle
- if bundle && File.exist?("../../bin/extlibs.rb")
- require "fileutils"
- require_relative "../../bin/extlibs"
- extlibs = ExtLibs.new
- cache_dir = File.expand_path("../../tmp/.download_cache", $srcdir)
- ext_dir = File.expand_path("../../ext", $srcdir)
- Dir.glob("#{$srcdir}/libffi-*/").each{|dir| FileUtils.rm_rf(dir)}
- extlibs.run(["--cache=#{cache_dir}", ext_dir])
- end
ver = bundle != false &&
Dir.glob("#{$srcdir}/libffi-*/")
.map {|n| File.basename(n)}
@@ -114,17 +104,8 @@ end
if ver
ver = ver.gsub(/-rc\d+/, '') # If ver contains rc version, just ignored.
- ver = (ver.split('.').map(&:to_i) + [0,0])[0,3]
+ ver = (ver.split('.') + [0,0])[0,3]
$defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver }})
- warn "libffi_version: #{ver.join('.')}"
-end
-
-case
-when $mswin, $mingw, (ver && (ver <=> [3, 2]) >= 0)
- $defs << "-DUSE_FFI_CLOSURE_ALLOC=1"
-when (ver && (ver <=> [3, 2]) < 0)
-else
- have_func('ffi_closure_alloc', ffi_header)
end
have_header 'sys/mman.h'
@@ -151,7 +132,7 @@ types.each do |type, signed|
if /^\#define\s+SIZEOF_#{type}\s+(SIZEOF_(.+)|\d+)/ =~ config
if size = $2 and size != 'VOIDP'
size = types.fetch(size) {size}
- $defs << "-DTYPE_#{signed||type}=TYPE_#{size}"
+ $defs << format("-DTYPE_%s=TYPE_%s", signed||type, size)
end
if signed
check_signedness(type.downcase, "stddef.h")
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c
index 994402e26b..8e280567db 100644
--- a/ext/fiddle/function.c
+++ b/ext/fiddle/function.c
@@ -99,8 +99,6 @@ initialize(int argc, VALUE argv[], VALUE self)
void *cfunc;
rb_scan_args(argc, argv, "31:", &ptr, &args, &ret_type, &abi, &kwds);
- rb_iv_set(self, "@closure", ptr);
-
ptr = rb_Integer(ptr);
cfunc = NUM2PTR(ptr);
PTR2NUM(cfunc);
@@ -115,7 +113,7 @@ initialize(int argc, VALUE argv[], VALUE self)
Check_Max_Args("args", len);
ary = rb_ary_subseq(args, 0, len);
for (i = 0; i < RARRAY_LEN(args); i++) {
- VALUE a = RARRAY_AREF(args, i);
+ VALUE a = RARRAY_PTR(args)[i];
int type = NUM2INT(a);
(void)INT2FFI_TYPE(type); /* raise */
if (INT2FIX(type) != a) rb_ary_store(ary, i, INT2FIX(type));
@@ -184,6 +182,15 @@ function_call(int argc, VALUE argv[], VALUE self)
TypedData_Get_Struct(self, ffi_cif, &function_data_type, args.cif);
+ if (rb_safe_level() >= 1) {
+ for (i = 0; i < argc; i++) {
+ VALUE src = argv[i];
+ if (OBJ_TAINTED(src)) {
+ rb_raise(rb_eSecurityError, "tainted parameter not allowed");
+ }
+ }
+ }
+
generic_args = ALLOCV(alloc_buffer,
(size_t)(argc + 1) * sizeof(void *) + (size_t)argc * sizeof(fiddle_generic));
args.values = (void **)((char *)generic_args +
@@ -207,7 +214,7 @@ function_call(int argc, VALUE argv[], VALUE self)
args.values[i] = (void *)&generic_args[i];
}
args.values[argc] = NULL;
- args.fn = (void(*)(void))NUM2PTR(cfunc);
+ args.fn = NUM2PTR(cfunc);
(void)rb_thread_call_without_gvl(nogvl_ffi_call, &args, 0, 0);
diff --git a/ext/fiddle/handle.c b/ext/fiddle/handle.c
index 700924afb5..e727ccfd00 100644
--- a/ext/fiddle/handle.c
+++ b/ext/fiddle/handle.c
@@ -1,6 +1,8 @@
#include <ruby.h>
#include <fiddle.h>
+#define SafeStringValueCStr(v) (rb_check_safe_obj(rb_string_value(&v)), StringValueCStr(v))
+
VALUE rb_cHandle;
struct dl_handle {
@@ -143,11 +145,11 @@ rb_fiddle_handle_initialize(int argc, VALUE argv[], VALUE self)
cflag = RTLD_LAZY | RTLD_GLOBAL;
break;
case 1:
- clib = NIL_P(lib) ? NULL : StringValueCStr(lib);
+ clib = NIL_P(lib) ? NULL : SafeStringValueCStr(lib);
cflag = RTLD_LAZY | RTLD_GLOBAL;
break;
case 2:
- clib = NIL_P(lib) ? NULL : StringValueCStr(lib);
+ clib = NIL_P(lib) ? NULL : SafeStringValueCStr(lib);
cflag = NUM2INT(flag);
break;
default:
@@ -317,7 +319,7 @@ fiddle_handle_sym(void *handle, VALUE symbol)
# define CHECK_DLERROR
#endif
void (*func)();
- const char *name = StringValueCStr(symbol);
+ const char *name = SafeStringValueCStr(symbol);
#ifdef HAVE_DLERROR
dlerror();
diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb
index 178ebb8c76..59ab3ee6f7 100644
--- a/ext/fiddle/lib/fiddle/import.rb
+++ b/ext/fiddle/lib/fiddle/import.rb
@@ -115,6 +115,8 @@ module Fiddle
return SIZEOF_INT
when TYPE_LONG
return SIZEOF_LONG
+ when TYPE_LONG_LONG
+ return SIZEOF_LONG_LONG
when TYPE_FLOAT
return SIZEOF_FLOAT
when TYPE_DOUBLE
@@ -122,12 +124,7 @@ module Fiddle
when TYPE_VOIDP
return SIZEOF_VOIDP
else
- if defined?(TYPE_LONG_LONG) and
- ty == TYPE_LONG_LONG
- return SIZEOF_LONG_LONG
- else
- raise(DLError, "unknown type: #{ty}")
- end
+ raise(DLError, "unknown type: #{ty}")
end
when Class
if( ty.instance_methods().include?(:to_ptr) )
@@ -157,8 +154,7 @@ module Fiddle
# :stopdoc:
CALL_TYPE_TO_ABI = Hash.new { |h, k|
raise RuntimeError, "unsupported call type: #{k}"
- }.merge({ :stdcall => Function.const_defined?(:STDCALL) ? Function::STDCALL :
- Function::DEFAULT,
+ }.merge({ :stdcall => (Function::STDCALL rescue Function::DEFAULT),
:cdecl => Function::DEFAULT,
nil => Function::DEFAULT
}).freeze
diff --git a/ext/fiddle/lib/fiddle/pack.rb b/ext/fiddle/lib/fiddle/pack.rb
index 22eccedb76..3c9e3c8ad7 100644
--- a/ext/fiddle/lib/fiddle/pack.rb
+++ b/ext/fiddle/lib/fiddle/pack.rb
@@ -18,7 +18,7 @@ module Fiddle
}
PACK_MAP = {
- TYPE_VOIDP => "l!",
+ TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG) ? "q" : "l!"),
TYPE_CHAR => "c",
TYPE_SHORT => "s!",
TYPE_INT => "i!",
@@ -48,7 +48,6 @@ module Fiddle
ALIGN_MAP[TYPE_LONG_LONG] = ALIGN_MAP[-TYPE_LONG_LONG] = ALIGN_LONG_LONG
PACK_MAP[TYPE_LONG_LONG] = PACK_MAP[-TYPE_LONG_LONG] = "q"
SIZE_MAP[TYPE_LONG_LONG] = SIZE_MAP[-TYPE_LONG_LONG] = SIZEOF_LONG_LONG
- PACK_MAP[TYPE_VOIDP] = "q" if SIZEOF_LONG_LONG == SIZEOF_VOIDP
end
def align(addr, align)
@@ -81,13 +80,10 @@ module Fiddle
case SIZEOF_VOIDP
when SIZEOF_LONG
ary.pack(@template)
+ when SIZEOF_LONG_LONG
+ ary.pack(@template)
else
- if defined?(TYPE_LONG_LONG) and
- SIZEOF_VOIDP == SIZEOF_LONG_LONG
- ary.pack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
+ raise(RuntimeError, "sizeof(void*)?")
end
end
@@ -95,13 +91,10 @@ module Fiddle
case SIZEOF_VOIDP
when SIZEOF_LONG
ary.join().unpack(@template)
+ when SIZEOF_LONG_LONG
+ ary.join().unpack(@template)
else
- if defined?(TYPE_LONG_LONG) and
- SIZEOF_VOIDP == SIZEOF_LONG_LONG
- ary.join().unpack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
+ raise(RuntimeError, "sizeof(void*)?")
end
end
diff --git a/ext/fiddle/lib/fiddle/types.rb b/ext/fiddle/lib/fiddle/types.rb
index 7baf31ec9e..8dc811d3e4 100644
--- a/ext/fiddle/lib/fiddle/types.rb
+++ b/ext/fiddle/lib/fiddle/types.rb
@@ -27,29 +27,28 @@ module Fiddle
# * WORD
module Win32Types
def included(m) # :nodoc:
- # https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types
m.module_eval{
- typealias "ATOM", "WORD"
+ typealias "DWORD", "unsigned long"
+ typealias "PDWORD", "unsigned long *"
+ typealias "DWORD32", "unsigned long"
+ typealias "DWORD64", "unsigned long long"
+ typealias "WORD", "unsigned short"
+ typealias "PWORD", "unsigned short *"
typealias "BOOL", "int"
+ typealias "ATOM", "int"
typealias "BYTE", "unsigned char"
- typealias "DWORD", "unsigned long"
- typealias "DWORD32", "uint32_t"
- typealias "DWORD64", "uint64_t"
- typealias "HANDLE", "PVOID"
- typealias "HDC", "HANDLE"
- typealias "HINSTANCE", "HANDLE"
- typealias "HWND", "HANDLE"
- typealias "LPCSTR", "const char *"
- typealias "LPSTR", "char *"
- typealias "PBYTE", "BYTE *"
- typealias "PDWORD", "DWORD *"
- typealias "PHANDLE", "HANDLE *"
- typealias "PVOID", "void *"
- typealias "PWORD", "WORD *"
- typealias "UCHAR", "unsigned char"
+ typealias "PBYTE", "unsigned char *"
typealias "UINT", "unsigned int"
typealias "ULONG", "unsigned long"
- typealias "WORD", "unsigned short"
+ typealias "UCHAR", "unsigned char"
+ typealias "HANDLE", "uintptr_t"
+ typealias "PHANDLE", "void*"
+ typealias "PVOID", "void*"
+ typealias "LPCSTR", "char*"
+ typealias "LPSTR", "char*"
+ typealias "HINSTANCE", "unsigned int"
+ typealias "HDC", "unsigned int"
+ typealias "HWND", "unsigned int"
}
end
module_function :included
diff --git a/ext/fiddle/lib/fiddle/value.rb b/ext/fiddle/lib/fiddle/value.rb
index 01fec1c206..a043b9b066 100644
--- a/ext/fiddle/lib/fiddle/value.rb
+++ b/ext/fiddle/lib/fiddle/value.rb
@@ -13,13 +13,10 @@ module Fiddle
[val].pack("i!").unpack("I!")[0]
when TYPE_LONG
[val].pack("l!").unpack("L!")[0]
+ when TYPE_LONG_LONG
+ [val].pack("q").unpack("Q")[0]
else
- if defined?(TYPE_LONG_LONG) and
- ty.abs == TYPE_LONG_LONG
- [val].pack("q").unpack("Q")[0]
- else
- val
- end
+ val
end
end
@@ -33,13 +30,10 @@ module Fiddle
[val].pack("I!").unpack("i!")[0]
when TYPE_LONG
[val].pack("L!").unpack("l!")[0]
+ when TYPE_LONG_LONG
+ [val].pack("Q").unpack("q")[0]
else
- if defined?(TYPE_LONG_LONG) and
- ty.abs == TYPE_LONG_LONG
- [val].pack("Q").unpack("q")[0]
- else
- val
- end
+ val
end
end
@@ -81,13 +75,10 @@ module Fiddle
case SIZEOF_VOIDP
when SIZEOF_LONG
return [arg].pack("p").unpack("l!")[0]
+ when SIZEOF_LONG_LONG
+ return [arg].pack("p").unpack("q")[0]
else
- if defined?(SIZEOF_LONG_LONG) and
- SIZEOF_VOIDP == SIZEOF_LONG_LONG
- return [arg].pack("p").unpack("q")[0]
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
+ raise(RuntimeError, "sizeof(void*)?")
end
end
when Float, Integer
diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c
index 117cc9b826..932bc576c5 100644
--- a/ext/fiddle/pointer.c
+++ b/ext/fiddle/pointer.c
@@ -90,6 +90,7 @@ rb_fiddle_ptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
data->ptr = ptr;
data->free = func;
data->size = size;
+ OBJ_TAINT(val);
return val;
}
@@ -375,11 +376,11 @@ rb_fiddle_ptr_to_s(int argc, VALUE argv[], VALUE self)
TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
switch (rb_scan_args(argc, argv, "01", &arg1)) {
case 0:
- val = rb_str_new2((char*)(data->ptr));
+ val = rb_tainted_str_new2((char*)(data->ptr));
break;
case 1:
len = NUM2INT(arg1);
- val = rb_str_new((char*)(data->ptr), len);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
break;
default:
rb_bug("rb_fiddle_ptr_to_s");
@@ -413,11 +414,11 @@ rb_fiddle_ptr_to_str(int argc, VALUE argv[], VALUE self)
TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
switch (rb_scan_args(argc, argv, "01", &arg1)) {
case 0:
- val = rb_str_new((char*)(data->ptr),data->size);
+ val = rb_tainted_str_new((char*)(data->ptr),data->size);
break;
case 1:
len = NUM2INT(arg1);
- val = rb_str_new((char*)(data->ptr), len);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
break;
default:
rb_bug("rb_fiddle_ptr_to_str");
@@ -439,7 +440,7 @@ rb_fiddle_ptr_inspect(VALUE self)
TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
- RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free);
+ RB_OBJ_CLASSNAME(self), data, data->ptr, data->size, data->free);
}
/*
@@ -550,7 +551,7 @@ rb_fiddle_ptr_aref(int argc, VALUE argv[], VALUE self)
case 2:
offset = NUM2ULONG(arg0);
len = NUM2ULONG(arg1);
- retval = rb_str_new((char *)data->ptr + offset, len);
+ retval = rb_tainted_str_new((char *)data->ptr + offset, len);
break;
default:
rb_bug("rb_fiddle_ptr_aref()");
@@ -668,6 +669,7 @@ rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val)
if (num == val) wrap = 0;
ptr = rb_fiddle_ptr_new(NUM2PTR(num), 0, NULL);
}
+ OBJ_INFECT(ptr, val);
if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap;
return ptr;
}
@@ -675,7 +677,6 @@ rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val)
void
Init_fiddle_pointer(void)
{
-#undef rb_intern
id_to_ptr = rb_intern("to_ptr");
/* Document-class: Fiddle::Pointer
diff --git a/ext/gdbm/depend b/ext/gdbm/depend
index 33635bc099..98def40879 100644
--- a/ext/gdbm/depend
+++ b/ext/gdbm/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
gdbm.o: $(RUBY_EXTCONF_H)
gdbm.o: $(arch_hdrdir)/ruby/config.h
-gdbm.o: $(hdrdir)/ruby.h
-gdbm.o: $(hdrdir)/ruby/assert.h
gdbm.o: $(hdrdir)/ruby/backward.h
gdbm.o: $(hdrdir)/ruby/defines.h
gdbm.o: $(hdrdir)/ruby/intern.h
@@ -10,5 +8,6 @@ gdbm.o: $(hdrdir)/ruby/missing.h
gdbm.o: $(hdrdir)/ruby/ruby.h
gdbm.o: $(hdrdir)/ruby/st.h
gdbm.o: $(hdrdir)/ruby/subst.h
+gdbm.o: $(top_srcdir)/include/ruby.h
gdbm.o: gdbm.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 4a6377b685..85e2b33f31 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -83,10 +83,6 @@ static VALUE rb_cGDBM, rb_eGDBMError, rb_eGDBMFatalError;
#define MY_BLOCK_SIZE (2048)
#define MY_FATAL_FUNC rb_gdbm_fatal
-
-NORETURN(static void rb_gdbm_fatal(const char *msg));
-NORETURN(static void closed_dbm(void));
-
static void
rb_gdbm_fatal(const char *msg)
{
@@ -324,6 +320,7 @@ rb_gdbm_fetch(GDBM_FILE dbm, datum key)
str = rb_str_new(val.dptr, val.dsize);
free(val.dptr);
+ OBJ_TAINT(str);
return str;
}
@@ -364,6 +361,7 @@ rb_gdbm_firstkey(GDBM_FILE dbm)
str = rb_str_new(key.dptr, key.dsize);
free(key.dptr);
+ OBJ_TAINT(str);
return str;
}
@@ -384,6 +382,7 @@ rb_gdbm_nextkey(GDBM_FILE dbm, VALUE keystr)
str = rb_str_new(key2.dptr, key2.dsize);
free(key2.dptr);
+ OBJ_TAINT(str);
return str;
}
diff --git a/ext/gdbm/gdbm.gemspec b/ext/gdbm/gdbm.gemspec
index da074b0180..753888e4b8 100644
--- a/ext/gdbm/gdbm.gemspec
+++ b/ext/gdbm/gdbm.gemspec
@@ -3,7 +3,8 @@
Gem::Specification.new do |spec|
spec.name = "gdbm"
- spec.version = "2.1.0"
+ spec.version = "2.0.0"
+ spec.date = '2017-04-28'
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
@@ -18,4 +19,9 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.extensions = ["ext/gdbm/extconf.rb"]
spec.required_ruby_version = ">= 2.3.0"
+
+ spec.add_development_dependency "bundler", "~> 1.14"
+ spec.add_development_dependency "rake", "~> 10.0"
+ spec.add_development_dependency "rake-compiler"
+ spec.add_development_dependency "test-unit"
end
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 9baad2bf17..04cf9e3f9c 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -4,7 +4,6 @@
*/
#include "ruby.h"
#include "ruby/io.h"
-#include "ruby/thread.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -15,6 +14,12 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#ifndef RARRAY_CONST_PTR
+# define RARRAY_CONST_PTR(ary) RARRAY_PTR(ary)
+#endif
+#ifndef HAVE_RB_FUNCALLV
+# define rb_funcallv rb_funcall2
+#endif
#if defined HAVE_TERMIOS_H
# include <termios.h>
@@ -23,7 +28,7 @@ typedef struct termios conmode;
static int
setattr(int fd, conmode *t)
{
- while (tcsetattr(fd, TCSANOW, t)) {
+ while (tcsetattr(fd, TCSAFLUSH, t)) {
if (errno != EINTR) return 0;
}
return 1;
@@ -49,7 +54,6 @@ typedef struct sgttyb conmode;
# endif
#elif defined _WIN32
#include <winioctl.h>
-#include <conio.h>
typedef DWORD conmode;
#define LAST_ERROR rb_w32_map_errno(GetLastError())
@@ -75,7 +79,7 @@ getattr(int fd, conmode *t)
#define SET_LAST_ERROR (0)
#endif
-static ID id_getc, id_console, id_close, id_min, id_time, id_intr;
+static ID id_getc, id_console, id_close, id_min, id_time;
#if ENABLE_IO_GETPASS
static ID id_gets;
#endif
@@ -99,40 +103,27 @@ rb_f_send(int argc, VALUE *argv, VALUE recv)
}
#endif
+#ifndef HAVE_RB_SYM2STR
+# define rb_sym2str(sym) rb_id2str(SYM2ID(sym))
+#endif
+
typedef struct {
int vmin;
int vtime;
- int intr;
} rawmode_arg_t;
static rawmode_arg_t *
-rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t *opts)
+rawmode_opt(int argc, VALUE *argv, rawmode_arg_t *opts)
{
- int argc = *argcp;
rawmode_arg_t *optp = NULL;
- VALUE vopts = Qnil;
-#ifdef RB_SCAN_ARGS_PASS_CALLED_KEYWORDS
- argc = rb_scan_args(argc, argv, "*:", NULL, &vopts);
-#else
- if (argc > min_argc) {
- vopts = rb_check_hash_type(argv[argc-1]);
- if (!NIL_P(vopts)) {
- argv[argc-1] = vopts;
- vopts = rb_extract_keywords(&argv[argc-1]);
- if (!argv[argc-1]) *argcp = --argc;
- if (!vopts) vopts = Qnil;
- }
- }
-#endif
- rb_check_arity(argc, min_argc, max_argc);
+ VALUE vopts;
+ rb_scan_args(argc, argv, "0:", &vopts);
if (!NIL_P(vopts)) {
VALUE vmin = rb_hash_aref(vopts, ID2SYM(id_min));
VALUE vtime = rb_hash_aref(vopts, ID2SYM(id_time));
- VALUE intr = rb_hash_aref(vopts, ID2SYM(id_intr));
/* default values by `stty raw` */
opts->vmin = 1;
opts->vtime = 0;
- opts->intr = 0;
if (!NIL_P(vmin)) {
opts->vmin = NUM2INT(vmin);
optp = opts;
@@ -143,21 +134,6 @@ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t *
opts->vtime = NUM2INT(vtime);
optp = opts;
}
- switch (intr) {
- case Qtrue:
- opts->intr = 1;
- optp = opts;
- break;
- case Qfalse:
- opts->intr = 0;
- optp = opts;
- break;
- case Qnil:
- break;
- default:
- rb_raise(rb_eArgError, "true or false expected as intr: %"PRIsVALUE,
- intr);
- }
}
return optp;
}
@@ -169,36 +145,24 @@ set_rawmode(conmode *t, void *arg)
cfmakeraw(t);
t->c_lflag &= ~(ECHOE|ECHOK);
#elif defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- t->c_iflag &= ~(IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IXOFF|IXANY|IMAXBEL);
+ t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
t->c_oflag &= ~OPOST;
- t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|XCASE);
+ t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN);
t->c_cflag &= ~(CSIZE|PARENB);
t->c_cflag |= CS8;
- t->c_cc[VMIN] = 1;
- t->c_cc[VTIME] = 0;
#elif defined HAVE_SGTTY_H
t->sg_flags &= ~ECHO;
t->sg_flags |= RAW;
#elif defined _WIN32
*t = 0;
#endif
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
if (arg) {
const rawmode_arg_t *r = arg;
-#ifdef VMIN
if (r->vmin >= 0) t->c_cc[VMIN] = r->vmin;
-#endif
-#ifdef VTIME
if (r->vtime >= 0) t->c_cc[VTIME] = r->vtime;
-#endif
-#ifdef ISIG
- if (r->intr) {
- t->c_iflag |= BRKINT;
- t->c_lflag |= ISIG;
- t->c_oflag |= OPOST;
- }
-#endif
- (void)r;
}
+#endif
}
static void
@@ -278,7 +242,7 @@ get_write_fd(const rb_io_t *fptr)
#define FD_PER_IO 2
static VALUE
-ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, void *), void *arg)
+ttymode(VALUE io, VALUE (*func)(VALUE), void (*setter)(conmode *, void *), void *arg)
{
rb_io_t *fptr;
int status = -1;
@@ -309,7 +273,7 @@ ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, vo
}
}
if (status == 0) {
- result = rb_protect(func, farg, &status);
+ result = rb_protect(func, io, &status);
}
GetOpenFile(io, fptr);
if (fd[0] != -1 && fd[0] == GetReadFD(fptr)) {
@@ -333,36 +297,11 @@ ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, vo
return result;
}
-#if !defined _WIN32
-struct ttymode_callback_args {
- VALUE (*func)(VALUE, VALUE);
- VALUE io;
- VALUE farg;
-};
-
-static VALUE
-ttymode_callback(VALUE args)
-{
- struct ttymode_callback_args *argp = (struct ttymode_callback_args *)args;
- return argp->func(argp->io, argp->farg);
-}
-
-static VALUE
-ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter)(conmode *, void *), void *arg)
-{
- struct ttymode_callback_args cargs;
- cargs.func = func;
- cargs.io = io;
- cargs.farg = farg;
- return ttymode(io, ttymode_callback, (VALUE)&cargs, setter, arg);
-}
-#endif
-
/*
* call-seq:
- * io.raw(min: nil, time: nil, intr: nil) {|io| }
+ * io.raw(min: nil, time: nil) {|io| }
*
- * Yields +self+ within raw mode, and returns the result of the block.
+ * Yields +self+ within raw mode.
*
* STDIN.raw(&:gets)
*
@@ -374,9 +313,6 @@ ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter
* The parameter +time+ specifies the timeout in _seconds_ with a
* precision of 1/10 of a second. (default: 0)
*
- * If the parameter +intr+ is +true+, enables break, interrupt, quit,
- * and suspend special characters.
- *
* Refer to the manual page of termios for further details.
*
* You must require 'io/console' to use this method.
@@ -384,17 +320,17 @@ ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter
static VALUE
console_raw(int argc, VALUE *argv, VALUE io)
{
- rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
- return ttymode(io, rb_yield, io, set_rawmode, optp);
+ rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts);
+ return ttymode(io, rb_yield, set_rawmode, optp);
}
/*
* call-seq:
- * io.raw!(min: nil, time: nil, intr: nil) -> io
+ * io.raw!(min: nil, time: nil)
*
- * Enables raw mode, and returns +io+.
+ * Enables raw mode.
*
- * If the terminal mode needs to be back, use <code>io.raw { ... }</code>.
+ * If the terminal mode needs to be back, use io.raw { ... }.
*
* See IO#raw for details on the parameters.
*
@@ -406,7 +342,7 @@ console_set_raw(int argc, VALUE *argv, VALUE io)
conmode t;
rb_io_t *fptr;
int fd;
- rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
+ rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts);
GetOpenFile(io, fptr);
fd = GetReadFD(fptr);
@@ -431,7 +367,7 @@ console_set_raw(int argc, VALUE *argv, VALUE io)
static VALUE
console_cooked(VALUE io)
{
- return ttymode(io, rb_yield, io, set_cookedmode, NULL);
+ return ttymode(io, rb_yield, set_cookedmode, NULL);
}
/*
@@ -459,38 +395,15 @@ console_set_cooked(VALUE io)
return io;
}
-#ifndef _WIN32
static VALUE
getc_call(VALUE io)
{
return rb_funcallv(io, id_getc, 0, 0);
}
-#else
-static void *
-nogvl_getch(void *p)
-{
- int len = 0;
- wint_t *buf = p, c = _getwch();
-
- switch (c) {
- case WEOF:
- break;
- case 0x00:
- case 0xe0:
- buf[len++] = c;
- c = _getwch();
- /* fall through */
- default:
- buf[len++] = c;
- break;
- }
- return (void *)(VALUE)len;
-}
-#endif
/*
* call-seq:
- * io.getch(min: nil, time: nil, intr: nil) -> char
+ * io.getch(min: nil, time: nil) -> char
*
* Reads and returns a character in raw mode.
*
@@ -501,56 +414,8 @@ nogvl_getch(void *p)
static VALUE
console_getch(int argc, VALUE *argv, VALUE io)
{
- rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
-#ifndef _WIN32
- return ttymode(io, getc_call, io, set_rawmode, optp);
-#else
- rb_io_t *fptr;
- VALUE str;
- wint_t c;
- int w, len;
- char buf[8];
- wint_t wbuf[2];
- struct timeval *to = NULL, tv;
-
- GetOpenFile(io, fptr);
- if (optp) {
- if (optp->vtime) {
- to = &tv;
- tv.tv_sec = optp->vtime / 10;
- tv.tv_usec = (optp->vtime % 10) * 100000;
- }
- if (optp->vmin != 1) {
- rb_warning("min option ignored");
- }
- if (optp->intr) {
- w = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, to);
- if (w < 0) rb_eof_error();
- if (!(w & RB_WAITFD_IN)) return Qnil;
- }
- else {
- rb_warning("vtime option ignored if intr flag is unset");
- }
- }
- len = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getch, wbuf, RUBY_UBF_IO, 0);
- switch (len) {
- case 0:
- return Qnil;
- case 2:
- buf[0] = (char)wbuf[0];
- c = wbuf[1];
- len = 1;
- do {
- buf[len++] = (unsigned char)c;
- } while ((c >>= CHAR_BIT) && len < (int)sizeof(buf));
- return rb_str_new(buf, len);
- default:
- c = wbuf[0];
- len = rb_uv_to_utf8(buf, c);
- str = rb_utf8_str_new(buf, len);
- return rb_str_conv_enc(str, NULL, rb_default_external_encoding());
- }
-#endif
+ rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts);
+ return ttymode(io, getc_call, set_rawmode, optp);
}
/*
@@ -568,7 +433,7 @@ console_getch(int argc, VALUE *argv, VALUE io)
static VALUE
console_noecho(VALUE io)
{
- return ttymode(io, rb_yield, io, set_noecho, NULL);
+ return ttymode(io, rb_yield, set_noecho, NULL);
}
/*
@@ -620,115 +485,6 @@ console_echo_p(VALUE io)
return echo_p(&t) ? Qtrue : Qfalse;
}
-static const rb_data_type_t conmode_type = {
- "console-mode",
- {0, RUBY_TYPED_DEFAULT_FREE,},
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
-};
-static VALUE cConmode;
-
-static VALUE
-conmode_alloc(VALUE klass)
-{
- return rb_data_typed_object_zalloc(klass, sizeof(conmode), &conmode_type);
-}
-
-static VALUE
-conmode_new(VALUE klass, const conmode *t)
-{
- VALUE obj = conmode_alloc(klass);
- *(conmode *)DATA_PTR(obj) = *t;
- return obj;
-}
-
-static VALUE
-conmode_init_copy(VALUE obj, VALUE obj2)
-{
- conmode *t = rb_check_typeddata(obj, &conmode_type);
- conmode *t2 = rb_check_typeddata(obj2, &conmode_type);
- *t = *t2;
- return obj;
-}
-
-static VALUE
-conmode_set_echo(VALUE obj, VALUE f)
-{
- conmode *t = rb_check_typeddata(obj, &conmode_type);
- if (RTEST(f))
- set_echo(t, NULL);
- else
- set_noecho(t, NULL);
- return obj;
-}
-
-static VALUE
-conmode_set_raw(int argc, VALUE *argv, VALUE obj)
-{
- conmode *t = rb_check_typeddata(obj, &conmode_type);
- rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
-
- set_rawmode(t, optp);
- return obj;
-}
-
-static VALUE
-conmode_raw_new(int argc, VALUE *argv, VALUE obj)
-{
- conmode *r = rb_check_typeddata(obj, &conmode_type);
- conmode t = *r;
- rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
-
- set_rawmode(&t, optp);
- return conmode_new(rb_obj_class(obj), &t);
-}
-
-/*
- * call-seq:
- * io.console_mode -> mode
- *
- * Returns a data represents the current console mode.
- *
- * You must require 'io/console' to use this method.
- */
-static VALUE
-console_conmode_get(VALUE io)
-{
- conmode t;
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) rb_sys_fail(0);
-
- return conmode_new(cConmode, &t);
-}
-
-/*
- * call-seq:
- * io.console_mode = mode
- *
- * Sets the console mode to +mode+.
- *
- * You must require 'io/console' to use this method.
- */
-static VALUE
-console_conmode_set(VALUE io, VALUE mode)
-{
- conmode *t, r;
- rb_io_t *fptr;
- int fd;
-
- TypedData_Get_Struct(mode, conmode, &conmode_type, t);
- r = *t;
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!setattr(fd, &r)) rb_sys_fail(0);
-
- return mode;
-}
-
#if defined TIOCGWINSZ
typedef struct winsize rb_console_size_t;
#define getwinsize(fd, buf) (ioctl((fd), TIOCGWINSZ, (buf)) == 0)
@@ -847,30 +603,6 @@ console_set_winsize(VALUE io, VALUE size)
}
#endif
-#ifdef _WIN32
-static VALUE
-console_check_winsize_changed(VALUE io)
-{
- rb_io_t *fptr;
- HANDLE h;
- DWORD num;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetReadFD(fptr));
- while (GetNumberOfConsoleInputEvents(h, &num) && num > 0) {
- INPUT_RECORD rec;
- if (ReadConsoleInput(h, &rec, 1, &num)) {
- if (rec.EventType == WINDOW_BUFFER_SIZE_EVENT) {
- rb_yield(Qnil);
- }
- }
- }
- return io;
-}
-#else
-#define console_check_winsize_changed rb_f_notimplement
-#endif
-
/*
* call-seq:
* io.iflush
@@ -966,24 +698,9 @@ console_beep(VALUE io)
return io;
}
-static int
-mode_in_range(VALUE val, int high, const char *modename)
-{
- int mode;
- if (NIL_P(val)) return 0;
- if (!RB_INTEGER_TYPE_P(val)) {
- wrong_value:
- rb_raise(rb_eArgError, "wrong %s mode: %"PRIsVALUE, modename, val);
- }
- if ((mode = NUM2INT(val)) < 0 || mode > high) {
- goto wrong_value;
- }
- return mode;
-}
-
#if defined _WIN32
static VALUE
-console_goto(VALUE io, VALUE y, VALUE x)
+console_goto(VALUE io, VALUE x, VALUE y)
{
rb_io_t *fptr;
int fd;
@@ -1011,159 +728,15 @@ console_cursor_pos(VALUE io)
if (!GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), &ws)) {
rb_syserr_fail(LAST_ERROR, 0);
}
- return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.Y), UINT2NUM(ws.dwCursorPosition.X));
+ return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.X), UINT2NUM(ws.dwCursorPosition.Y));
}
static VALUE
-console_move(VALUE io, int y, int x)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- pos->X += x;
- pos->Y += y;
- if (!SetConsoleCursorPosition(h, *pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
-static VALUE
-console_goto_column(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- pos->X = NUM2INT(val);
- if (!SetConsoleCursorPosition(h, *pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
-static void
-constat_clear(HANDLE handle, WORD attr, DWORD len, COORD pos)
-{
- DWORD written;
-
- FillConsoleOutputAttribute(handle, attr, len, pos, &written);
- FillConsoleOutputCharacterW(handle, L' ', len, pos, &written);
-}
-
-static VALUE
-console_erase_line(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
- DWORD w;
- int mode = mode_in_range(val, 2, "line erase");
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- w = winsize_col(&ws);
- switch (mode) {
- case 0: /* after cursor */
- w -= pos->X;
- break;
- case 1: /* before *and* cursor */
- w = pos->X + 1;
- pos->X = 0;
- break;
- case 2: /* entire line */
- pos->X = 0;
- break;
- }
- constat_clear(h, ws.wAttributes, w, *pos);
- return io;
-}
-
-static VALUE
-console_erase_screen(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
- DWORD w;
- int mode = mode_in_range(val, 3, "screen erase");
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- w = winsize_col(&ws);
- switch (mode) {
- case 0: /* erase after cursor */
- w = (w * (ws.srWindow.Bottom - pos->Y + 1) - pos->X);
- break;
- case 1: /* erase before *and* cursor */
- w = (w * (pos->Y - ws.srWindow.Top) + pos->X + 1);
- pos->X = 0;
- pos->Y = ws.srWindow.Top;
- break;
- case 2: /* erase entire screen */
- w = (w * winsize_row(&ws));
- pos->X = 0;
- pos->Y = ws.srWindow.Top;
- break;
- case 3: /* erase entire screen */
- w = (w * ws.dwSize.Y);
- pos->X = 0;
- pos->Y = 0;
- break;
- }
- constat_clear(h, ws.wAttributes, w, *pos);
- return io;
-}
-
-static VALUE
-console_scroll(VALUE io, int line)
+console_cursor_set(VALUE io, VALUE cpos)
{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- if (line) {
- SMALL_RECT scroll;
- COORD destination;
- CHAR_INFO fill;
- scroll.Left = 0;
- scroll.Top = line > 0 ? line : 0;
- scroll.Right = winsize_col(&ws) - 1;
- scroll.Bottom = winsize_row(&ws) - 1 + (line < 0 ? line : 0);
- destination.X = 0;
- destination.Y = line < 0 ? -line : 0;
- fill.Char.UnicodeChar = L' ';
- fill.Attributes = ws.wAttributes;
-
- ScrollConsoleScreenBuffer(h, &scroll, NULL, destination, &fill);
- }
- return io;
+ cpos = rb_convert_type(cpos, T_ARRAY, "Array", "to_ary");
+ if (RARRAY_LEN(cpos) != 2) rb_raise(rb_eArgError, "expected 2D coordinate");
+ return console_goto(io, RARRAY_AREF(cpos, 0), RARRAY_AREF(cpos, 1));
}
#include "win32_vk.inc"
@@ -1194,210 +767,12 @@ console_key_pressed_p(VALUE io, VALUE k)
return GetKeyState(vk) & 0x80 ? Qtrue : Qfalse;
}
#else
-struct query_args {
- const char *qstr;
- int opt;
-};
-
-static int
-direct_query(VALUE io, const struct query_args *query)
-{
- if (RB_TYPE_P(io, T_FILE)) {
- rb_io_t *fptr;
- VALUE wio;
- GetOpenFile(io, fptr);
- wio = fptr->tied_io_for_writing;
- if (wio) {
- VALUE s = rb_str_new_cstr(query->qstr);
- rb_io_write(wio, s);
- rb_io_flush(wio);
- return 1;
- }
- if (write(fptr->fd, query->qstr, strlen(query->qstr)) != -1) {
- return 1;
- }
- if (fptr->fd == 0 &&
- write(1, query->qstr, strlen(query->qstr)) != -1) {
- return 1;
- }
- }
- return 0;
-}
-
-static VALUE
-read_vt_response(VALUE io, VALUE query)
-{
- struct query_args *qargs = (struct query_args *)query;
- VALUE result, b;
- int opt = 0;
- int num = 0;
- if (qargs) {
- opt = qargs->opt;
- if (!direct_query(io, qargs)) return Qnil;
- }
- if (rb_io_getbyte(io) != INT2FIX(0x1b)) return Qnil;
- if (rb_io_getbyte(io) != INT2FIX('[')) return Qnil;
- result = rb_ary_new();
- while (!NIL_P(b = rb_io_getbyte(io))) {
- int c = NUM2UINT(b);
- if (c == ';') {
- rb_ary_push(result, INT2NUM(num));
- num = 0;
- }
- else if (ISDIGIT(c)) {
- num = num * 10 + c - '0';
- }
- else if (opt && c == opt) {
- opt = 0;
- }
- else {
- char last = (char)c;
- rb_ary_push(result, INT2NUM(num));
- b = rb_str_new(&last, 1);
- break;
- }
- }
- return rb_ary_push(result, b);
-}
-
-static VALUE
-console_vt_response(int argc, VALUE *argv, VALUE io, const struct query_args *qargs)
-{
- rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 1, &opts);
- VALUE query = (VALUE)qargs;
- VALUE ret = ttymode_with_io(io, read_vt_response, query, set_rawmode, optp);
- return ret;
-}
-
-static VALUE
-console_cursor_pos(VALUE io)
-{
- static const struct query_args query = {"\033[6n", 0};
- VALUE resp = console_vt_response(0, 0, io, &query);
- VALUE row, column, term;
- unsigned int r, c;
- if (!RB_TYPE_P(resp, T_ARRAY) || RARRAY_LEN(resp) != 3) return Qnil;
- term = RARRAY_AREF(resp, 2);
- if (!RB_TYPE_P(term, T_STRING) || RSTRING_LEN(term) != 1) return Qnil;
- if (RSTRING_PTR(term)[0] != 'R') return Qnil;
- row = RARRAY_AREF(resp, 0);
- column = RARRAY_AREF(resp, 1);
- rb_ary_resize(resp, 2);
- r = NUM2UINT(row) - 1;
- c = NUM2UINT(column) - 1;
- RARRAY_ASET(resp, 0, INT2NUM(r));
- RARRAY_ASET(resp, 1, INT2NUM(c));
- return resp;
-}
-
-static VALUE
-console_goto(VALUE io, VALUE y, VALUE x)
-{
- rb_io_write(io, rb_sprintf("\x1b[%d;%dH", NUM2UINT(y)+1, NUM2UINT(x)+1));
- return io;
-}
-
-static VALUE
-console_move(VALUE io, int y, int x)
-{
- if (x || y) {
- VALUE s = rb_str_new_cstr("");
- if (y) rb_str_catf(s, "\x1b[%d%c", y < 0 ? -y : y, y < 0 ? 'A' : 'B');
- if (x) rb_str_catf(s, "\x1b[%d%c", x < 0 ? -x : x, x < 0 ? 'D' : 'C');
- rb_io_write(io, s);
- rb_io_flush(io);
- }
- return io;
-}
-
-static VALUE
-console_goto_column(VALUE io, VALUE val)
-{
- rb_io_write(io, rb_sprintf("\x1b[%dG", NUM2UINT(val)+1));
- return io;
-}
-
-static VALUE
-console_erase_line(VALUE io, VALUE val)
-{
- int mode = mode_in_range(val, 2, "line erase");
- rb_io_write(io, rb_sprintf("\x1b[%dK", mode));
- return io;
-}
-
-static VALUE
-console_erase_screen(VALUE io, VALUE val)
-{
- int mode = mode_in_range(val, 3, "screen erase");
- rb_io_write(io, rb_sprintf("\x1b[%dJ", mode));
- return io;
-}
-
-static VALUE
-console_scroll(VALUE io, int line)
-{
- if (line) {
- VALUE s = rb_sprintf("\x1b[%d%c", line < 0 ? -line : line,
- line < 0 ? 'T' : 'S');
- rb_io_write(io, s);
- }
- return io;
-}
+# define console_goto rb_f_notimplement
+# define console_cursor_pos rb_f_notimplement
+# define console_cursor_set rb_f_notimplement
# define console_key_pressed_p rb_f_notimplement
#endif
-static VALUE
-console_cursor_set(VALUE io, VALUE cpos)
-{
- cpos = rb_convert_type(cpos, T_ARRAY, "Array", "to_ary");
- if (RARRAY_LEN(cpos) != 2) rb_raise(rb_eArgError, "expected 2D coordinate");
- return console_goto(io, RARRAY_AREF(cpos, 0), RARRAY_AREF(cpos, 1));
-}
-
-static VALUE
-console_cursor_up(VALUE io, VALUE val)
-{
- return console_move(io, -NUM2INT(val), 0);
-}
-
-static VALUE
-console_cursor_down(VALUE io, VALUE val)
-{
- return console_move(io, +NUM2INT(val), 0);
-}
-
-static VALUE
-console_cursor_left(VALUE io, VALUE val)
-{
- return console_move(io, 0, -NUM2INT(val));
-}
-
-static VALUE
-console_cursor_right(VALUE io, VALUE val)
-{
- return console_move(io, 0, +NUM2INT(val));
-}
-
-static VALUE
-console_scroll_forward(VALUE io, VALUE val)
-{
- return console_scroll(io, +NUM2INT(val));
-}
-
-static VALUE
-console_scroll_backward(VALUE io, VALUE val)
-{
- return console_scroll(io, -NUM2INT(val));
-}
-
-static VALUE
-console_clear_screen(VALUE io)
-{
- console_erase_screen(io, INT2FIX(2));
- console_goto(io, INT2FIX(0), INT2FIX(0));
- return io;
-}
-
/*
* call-seq:
* IO.console -> #<File:/dev/tty>
@@ -1497,7 +872,7 @@ console_dev(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * io.getch(min: nil, time: nil, intr: nil) -> char
+ * io.getch(min: nil, time: nil) -> char
*
* See IO#getch.
*/
@@ -1517,7 +892,7 @@ puts_call(VALUE io)
static VALUE
getpass_call(VALUE io)
{
- return ttymode(io, rb_io_gets, io, set_noecho, NULL);
+ return ttymode(io, rb_io_gets, set_noecho, NULL);
}
static void
@@ -1526,6 +901,7 @@ prompt(int argc, VALUE *argv, VALUE io)
if (argc > 0 && !NIL_P(argv[0])) {
VALUE str = argv[0];
StringValueCStr(str);
+ rb_check_safe_obj(str);
rb_io_write(io, str);
}
}
@@ -1595,7 +971,6 @@ Init_console(void)
id_close = rb_intern("close");
id_min = rb_intern("min");
id_time = rb_intern("time");
- id_intr = rb_intern("intr");
#ifndef HAVE_RB_F_SEND
id___send__ = rb_intern("__send__");
#endif
@@ -1612,8 +987,6 @@ InitVM_console(void)
rb_define_method(rb_cIO, "getch", console_getch, -1);
rb_define_method(rb_cIO, "echo=", console_set_echo, 1);
rb_define_method(rb_cIO, "echo?", console_echo_p, 0);
- rb_define_method(rb_cIO, "console_mode", console_conmode_get, 0);
- rb_define_method(rb_cIO, "console_mode=", console_conmode_set, 1);
rb_define_method(rb_cIO, "noecho", console_noecho, 0);
rb_define_method(rb_cIO, "winsize", console_winsize, 0);
rb_define_method(rb_cIO, "winsize=", console_set_winsize, 1);
@@ -1624,18 +997,7 @@ InitVM_console(void)
rb_define_method(rb_cIO, "goto", console_goto, 2);
rb_define_method(rb_cIO, "cursor", console_cursor_pos, 0);
rb_define_method(rb_cIO, "cursor=", console_cursor_set, 1);
- rb_define_method(rb_cIO, "cursor_up", console_cursor_up, 1);
- rb_define_method(rb_cIO, "cursor_down", console_cursor_down, 1);
- rb_define_method(rb_cIO, "cursor_left", console_cursor_left, 1);
- rb_define_method(rb_cIO, "cursor_right", console_cursor_right, 1);
- rb_define_method(rb_cIO, "goto_column", console_goto_column, 1);
- rb_define_method(rb_cIO, "erase_line", console_erase_line, 1);
- rb_define_method(rb_cIO, "erase_screen", console_erase_screen, 1);
- rb_define_method(rb_cIO, "scroll_forward", console_scroll_forward, 1);
- rb_define_method(rb_cIO, "scroll_backward", console_scroll_backward, 1);
- rb_define_method(rb_cIO, "clear_screen", console_clear_screen, 0);
rb_define_method(rb_cIO, "pressed?", console_key_pressed_p, 1);
- rb_define_method(rb_cIO, "check_winsize_changed", console_check_winsize_changed, 0);
#if ENABLE_IO_GETPASS
rb_define_method(rb_cIO, "getpass", console_getpass, -1);
#endif
@@ -1647,15 +1009,4 @@ InitVM_console(void)
rb_define_method(mReadable, "getpass", io_getpass, -1);
#endif
}
- {
- /* :stopdoc: */
- cConmode = rb_define_class_under(rb_cIO, "ConsoleMode", rb_cObject);
- rb_define_alloc_func(cConmode, conmode_alloc);
- rb_undef_method(cConmode, "initialize");
- rb_define_method(cConmode, "initialize_copy", conmode_init_copy, 1);
- rb_define_method(cConmode, "echo=", conmode_set_echo, 1);
- rb_define_method(cConmode, "raw!", conmode_set_raw, -1);
- rb_define_method(cConmode, "raw", conmode_raw_new, -1);
- /* :startdoc: */
- }
}
diff --git a/ext/io/console/depend b/ext/io/console/depend
index 9c8f9cd22e..821b28d3fc 100644
--- a/ext/io/console/depend
+++ b/ext/io/console/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
console.o: $(RUBY_EXTCONF_H)
console.o: $(arch_hdrdir)/ruby/config.h
-console.o: $(hdrdir)/ruby.h
-console.o: $(hdrdir)/ruby/assert.h
console.o: $(hdrdir)/ruby/backward.h
console.o: $(hdrdir)/ruby/defines.h
console.o: $(hdrdir)/ruby/encoding.h
@@ -14,7 +12,7 @@ console.o: $(hdrdir)/ruby/oniguruma.h
console.o: $(hdrdir)/ruby/ruby.h
console.o: $(hdrdir)/ruby/st.h
console.o: $(hdrdir)/ruby/subst.h
-console.o: $(hdrdir)/ruby/thread.h
+console.o: $(top_srcdir)/include/ruby.h
console.o: console.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb
index 3d7e75e2af..be536dff9f 100644
--- a/ext/io/console/extconf.rb
+++ b/ext/io/console/extconf.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
require 'mkmf'
-ok = true if RUBY_ENGINE == "ruby"
+ok = true
hdr = nil
case
when macro_defined?("_WIN32", "")
@@ -14,20 +14,16 @@ when have_header(hdr = "sgtty.h")
%w"stty gtty".each {|f| have_func(f, hdr)}
else
ok = false
-end if ok
-case ok
-when true
+end
+if ok
have_header("sys/ioctl.h") if hdr
+ have_func("rb_funcallv")
+ have_func("rb_sym2str")
# rb_check_hash_type: 1.9.3
# rb_io_get_write_io: 1.9.1
# rb_cloexec_open: 2.0.0
- # rb_funcallv: 2.1.0
- # RARRAY_CONST_PTR: 2.1.0
- # rb_sym2str: 2.2.0
$defs << "-D""ENABLE_IO_GETPASS=1"
create_makefile("io/console") {|conf|
conf << "\n""VK_HEADER = #{vk_header}\n"
}
-when nil
- File.write("Makefile", dummy_makefile($srcdir).join(""))
end
diff --git a/ext/io/console/io-console.gemspec b/ext/io/console/io-console.gemspec
index 814bd4ef7d..1256162468 100644
--- a/ext/io/console/io-console.gemspec
+++ b/ext/io/console/io-console.gemspec
@@ -1,5 +1,5 @@
# -*- ruby -*-
-_VERSION = "0.5.6"
+_VERSION = "0.4.6"
date = %w$Date:: $[1]
Gem::Specification.new do |s|
@@ -9,19 +9,16 @@ Gem::Specification.new do |s|
s.summary = "Console interface"
s.email = "nobu@ruby-lang.org"
s.description = "add console capabilities to IO instances."
- s.required_ruby_version = ">= 2.4.0"
+ s.required_ruby_version = ">= 2.0.0"
s.homepage = "https://github.com/ruby/io-console"
- s.metadata["source_code_url"] = s.homepage
s.authors = ["Nobu Nakada"]
s.require_path = %[lib]
- s.files = %w[
- LICENSE.txt
- README.md
- ext/io/console/console.c
- ext/io/console/extconf.rb
- ext/io/console/win32_vk.inc
- lib/io/console/size.rb
- ]
+ s.files = %w[ext/io/console/console.c ext/io/console/extconf.rb lib/console/size.rb ext/io/console/win32_vk.inc]
s.extensions = %w[ext/io/console/extconf.rb]
s.license = "BSD-2-Clause"
+ s.cert_chain = %w[certs/nobu.pem]
+ s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
+
+ s.add_development_dependency 'rake-compiler'
+ s.add_development_dependency 'rake-compiler-dock', ">= 0.6.1"
end
diff --git a/ext/io/nonblock/depend b/ext/io/nonblock/depend
index bea4a15e23..4402898de6 100644
--- a/ext/io/nonblock/depend
+++ b/ext/io/nonblock/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
nonblock.o: $(RUBY_EXTCONF_H)
nonblock.o: $(arch_hdrdir)/ruby/config.h
-nonblock.o: $(hdrdir)/ruby.h
-nonblock.o: $(hdrdir)/ruby/assert.h
nonblock.o: $(hdrdir)/ruby/backward.h
nonblock.o: $(hdrdir)/ruby/defines.h
nonblock.o: $(hdrdir)/ruby/encoding.h
@@ -14,5 +12,6 @@ nonblock.o: $(hdrdir)/ruby/oniguruma.h
nonblock.o: $(hdrdir)/ruby/ruby.h
nonblock.o: $(hdrdir)/ruby/st.h
nonblock.o: $(hdrdir)/ruby/subst.h
+nonblock.o: $(top_srcdir)/include/ruby.h
nonblock.o: nonblock.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/io/wait/depend b/ext/io/wait/depend
index bbf1266aba..f509dcd8a4 100644
--- a/ext/io/wait/depend
+++ b/ext/io/wait/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
wait.o: $(RUBY_EXTCONF_H)
wait.o: $(arch_hdrdir)/ruby/config.h
-wait.o: $(hdrdir)/ruby.h
-wait.o: $(hdrdir)/ruby/assert.h
wait.o: $(hdrdir)/ruby/backward.h
wait.o: $(hdrdir)/ruby/defines.h
wait.o: $(hdrdir)/ruby/encoding.h
@@ -14,5 +12,6 @@ wait.o: $(hdrdir)/ruby/oniguruma.h
wait.o: $(hdrdir)/ruby/ruby.h
wait.o: $(hdrdir)/ruby/st.h
wait.o: $(hdrdir)/ruby/subst.h
+wait.o: $(top_srcdir)/include/ruby.h
wait.o: wait.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index d846bba49e..f7a7508eeb 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -95,9 +95,10 @@ io_nread(VALUE io)
/*
* call-seq:
- * io.ready? -> true or false
+ * io.ready? -> true, false or nil
*
* Returns true if input available without blocking, or false.
+ * Returns nil if no information available.
*/
static VALUE
diff --git a/ext/json/depend b/ext/json/depend
deleted file mode 100644
index 0301ce074c..0000000000
--- a/ext/json/depend
+++ /dev/null
@@ -1,2 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/json/generator/depend b/ext/json/generator/depend
index 3f04c0d625..54e8ae3eb4 100644
--- a/ext/json/generator/depend
+++ b/ext/json/generator/depend
@@ -4,8 +4,6 @@ generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h
# AUTOGENERATED DEPENDENCIES START
generator.o: $(RUBY_EXTCONF_H)
generator.o: $(arch_hdrdir)/ruby/config.h
-generator.o: $(hdrdir)/ruby.h
-generator.o: $(hdrdir)/ruby/assert.h
generator.o: $(hdrdir)/ruby/backward.h
generator.o: $(hdrdir)/ruby/defines.h
generator.o: $(hdrdir)/ruby/encoding.h
@@ -18,7 +16,8 @@ generator.o: $(hdrdir)/ruby/regex.h
generator.o: $(hdrdir)/ruby/ruby.h
generator.o: $(hdrdir)/ruby/st.h
generator.o: $(hdrdir)/ruby/subst.h
-generator.o: $(srcdir)/../fbuffer/fbuffer.h
+generator.o: $(top_srcdir)/ext/json/fbuffer/fbuffer.h
+generator.o: $(top_srcdir)/include/ruby.h
generator.o: generator.c
generator.o: generator.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index 881435e3dc..2bf8074562 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -15,7 +15,7 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
#endif
mFloat, mString, mString_Extend,
mTrueClass, mFalseClass, mNilClass, eGeneratorError,
- eNestingError,
+ eNestingError, CRegexp_MULTILINE, CJSON_SAFE_STATE_PROTOTYPE,
i_SAFE_STATE_PROTOTYPE;
static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
@@ -237,7 +237,6 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
int escape_len;
unsigned char c;
char buf[6] = { '\\', 'u' };
- int ascii_only = rb_enc_str_asciionly_p(string);
for (start = 0, end = 0; end < len;) {
p = ptr + end;
@@ -282,17 +281,14 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
break;
default:
{
- unsigned short clen = 1;
- if (!ascii_only) {
- clen += trailingBytesForUTF8[c];
- if (end + clen > len) {
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "partial character in source, but hit end");
- }
- if (!isLegalUTF8((UTF8 *) p, clen)) {
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed utf-8");
- }
+ unsigned short clen = trailingBytesForUTF8[c] + 1;
+ if (end + clen > len) {
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "partial character in source, but hit end");
+ }
+ if (!isLegalUTF8((UTF8 *) p, clen)) {
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "source sequence is illegal/malformed utf-8");
}
end += clen;
}
@@ -696,7 +692,7 @@ static VALUE cState_aref(VALUE self, VALUE name)
if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
return rb_funcall(self, i_send, 1, name);
} else {
- return rb_attr_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)));
+ return rb_ivar_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)));
}
}
@@ -719,83 +715,43 @@ static VALUE cState_aset(VALUE self, VALUE name, VALUE value)
return Qnil;
}
-struct hash_foreach_arg {
- FBuffer *buffer;
- JSON_Generator_State *state;
- VALUE Vstate;
- int iter;
-};
-
-static int
-json_object_i(VALUE key, VALUE val, VALUE _arg)
+static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
{
- struct hash_foreach_arg *arg = (struct hash_foreach_arg *)_arg;
- FBuffer *buffer = arg->buffer;
- JSON_Generator_State *state = arg->state;
- VALUE Vstate = arg->Vstate;
-
char *object_nl = state->object_nl;
long object_nl_len = state->object_nl_len;
char *indent = state->indent;
long indent_len = state->indent_len;
+ long max_nesting = state->max_nesting;
char *delim = FBUFFER_PTR(state->object_delim);
long delim_len = FBUFFER_LEN(state->object_delim);
char *delim2 = FBUFFER_PTR(state->object_delim2);
long delim2_len = FBUFFER_LEN(state->object_delim2);
- long depth = state->depth;
- int j;
- VALUE klass, key_to_s;
-
- if (arg->iter > 0) fbuffer_append(buffer, delim, delim_len);
- if (object_nl) {
- fbuffer_append(buffer, object_nl, object_nl_len);
- }
- if (indent) {
- for (j = 0; j < depth; j++) {
- fbuffer_append(buffer, indent, indent_len);
- }
- }
-
- klass = CLASS_OF(key);
- if (klass == rb_cString) {
- key_to_s = key;
- } else if (klass == rb_cSymbol) {
- key_to_s = rb_id2str(SYM2ID(key));
- } else {
- key_to_s = rb_funcall(key, i_to_s, 0);
- }
- Check_Type(key_to_s, T_STRING);
- generate_json(buffer, Vstate, state, key_to_s);
- fbuffer_append(buffer, delim2, delim2_len);
- generate_json(buffer, Vstate, state, val);
-
- arg->iter++;
- return ST_CONTINUE;
-}
-
-static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
-{
- char *object_nl = state->object_nl;
- long object_nl_len = state->object_nl_len;
- char *indent = state->indent;
- long indent_len = state->indent_len;
- long max_nesting = state->max_nesting;
long depth = ++state->depth;
- int j;
- struct hash_foreach_arg arg;
-
+ int i, j;
+ VALUE key, key_to_s, keys;
if (max_nesting != 0 && depth > max_nesting) {
fbuffer_free(buffer);
rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
}
fbuffer_append_char(buffer, '{');
-
- arg.buffer = buffer;
- arg.state = state;
- arg.Vstate = Vstate;
- arg.iter = 0;
- rb_hash_foreach(obj, json_object_i, (VALUE)&arg);
-
+ keys = rb_funcall(obj, i_keys, 0);
+ for(i = 0; i < RARRAY_LEN(keys); i++) {
+ if (i > 0) fbuffer_append(buffer, delim, delim_len);
+ if (object_nl) {
+ fbuffer_append(buffer, object_nl, object_nl_len);
+ }
+ if (indent) {
+ for (j = 0; j < depth; j++) {
+ fbuffer_append(buffer, indent, indent_len);
+ }
+ }
+ key = rb_ary_entry(keys, i);
+ key_to_s = rb_funcall(key, i_to_s, 0);
+ Check_Type(key_to_s, T_STRING);
+ generate_json(buffer, Vstate, state, key_to_s);
+ fbuffer_append(buffer, delim2, delim2_len);
+ generate_json(buffer, Vstate, state, rb_hash_aref(obj, key));
+ }
depth = --state->depth;
if (object_nl) {
fbuffer_append(buffer, object_nl, object_nl_len);
@@ -846,22 +802,11 @@ static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_St
fbuffer_append_char(buffer, ']');
}
-#ifdef HAVE_RUBY_ENCODING_H
-static int enc_utf8_compatible_p(rb_encoding *enc)
-{
- if (enc == rb_usascii_encoding()) return 1;
- if (enc == rb_utf8_encoding()) return 1;
- return 0;
-}
-#endif
-
static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
{
fbuffer_append_char(buffer, '"');
#ifdef HAVE_RUBY_ENCODING_H
- if (!enc_utf8_compatible_p(rb_enc_get(obj))) {
- obj = rb_str_encode(obj, CEncoding_UTF_8, 0, Qnil);
- }
+ obj = rb_funcall(obj, i_encode, 1, CEncoding_UTF_8);
#endif
if (state->ascii_only) {
convert_UTF8_to_JSON_ASCII(buffer, obj);
@@ -1025,8 +970,6 @@ static VALUE cState_generate(VALUE self, VALUE obj)
* * *allow_nan*: true if NaN, Infinity, and -Infinity should be
* generated, otherwise an exception is thrown, if these values are
* encountered. This options defaults to false.
- * * *ascii_only*: true if only ASCII characters should be generated. This
- * ontions defaults to false.
* * *buffer_initial_length*: sets the initial length of the generator's
* internal buffer.
*/
@@ -1082,8 +1025,10 @@ static VALUE cState_from_state_s(VALUE self, VALUE opts)
} else if (rb_obj_is_kind_of(opts, rb_cHash)) {
return rb_funcall(self, i_new, 1, opts);
} else {
- VALUE prototype = rb_const_get(mJSON, i_SAFE_STATE_PROTOTYPE);
- return rb_funcall(prototype, i_dup, 0);
+ if (NIL_P(CJSON_SAFE_STATE_PROTOTYPE)) {
+ CJSON_SAFE_STATE_PROTOTYPE = rb_const_get(mJSON, i_SAFE_STATE_PROTOTYPE);
+ }
+ return rb_funcall(CJSON_SAFE_STATE_PROTOTYPE, i_dup, 0);
}
}
@@ -1322,7 +1267,7 @@ static VALUE cState_allow_nan_p(VALUE self)
/*
* call-seq: ascii_only?
*
- * Returns true, if only ASCII characters should be generated. Otherwise
+ * Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
* returns false.
*/
static VALUE cState_ascii_only_p(VALUE self)
@@ -1390,7 +1335,6 @@ static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_l
*/
void Init_generator(void)
{
-#undef rb_intern
rb_require("json/common");
mJSON = rb_define_module("JSON");
@@ -1399,8 +1343,6 @@ void Init_generator(void)
eGeneratorError = rb_path2class("JSON::GeneratorError");
eNestingError = rb_path2class("JSON::NestingError");
- rb_gc_register_mark_object(eGeneratorError);
- rb_gc_register_mark_object(eNestingError);
cState = rb_define_class_under(mGenerator, "State", rb_cObject);
rb_define_alloc_func(cState, cState_s_allocate);
@@ -1466,6 +1408,7 @@ void Init_generator(void)
mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);
+ CRegexp_MULTILINE = rb_const_get(rb_cRegexp, rb_intern("MULTILINE"));
i_to_s = rb_intern("to_s");
i_to_json = rb_intern("to_json");
i_new = rb_intern("new");
@@ -1496,4 +1439,5 @@ void Init_generator(void)
i_encode = rb_intern("encode");
#endif
i_SAFE_STATE_PROTOTYPE = rb_intern("SAFE_STATE_PROTOTYPE");
+ CJSON_SAFE_STATE_PROTOTYPE = Qnil;
}
diff --git a/ext/json/json.gemspec b/ext/json/json.gemspec
index d8be2e52c6..b8f3009a9c 100644
--- a/ext/json/json.gemspec
+++ b/ext/json/json.gemspec
Binary files differ
diff --git a/ext/json/lib/json/add/bigdecimal.rb b/ext/json/lib/json/add/bigdecimal.rb
index c8b4f567cb..539daeeaf5 100644
--- a/ext/json/lib/json/add/bigdecimal.rb
+++ b/ext/json/lib/json/add/bigdecimal.rb
@@ -23,7 +23,7 @@ class BigDecimal
end
# return the JSON value
- def to_json(*args)
- as_json.to_json(*args)
+ def to_json(*)
+ as_json.to_json
end
end
diff --git a/ext/json/lib/json/add/complex.rb b/ext/json/lib/json/add/complex.rb
index 4d977e7589..28ef734daf 100644
--- a/ext/json/lib/json/add/complex.rb
+++ b/ext/json/lib/json/add/complex.rb
@@ -23,7 +23,7 @@ class Complex
end
# Stores class name (Complex) along with real value <tt>r</tt> and imaginary value <tt>i</tt> as JSON string
- def to_json(*args)
- as_json.to_json(*args)
+ def to_json(*)
+ as_json.to_json
end
end
diff --git a/ext/json/lib/json/add/ostruct.rb b/ext/json/lib/json/add/ostruct.rb
index 686cf0025d..e064c85ff4 100644
--- a/ext/json/lib/json/add/ostruct.rb
+++ b/ext/json/lib/json/add/ostruct.rb
@@ -23,7 +23,7 @@ class OpenStruct
}
end
- # Stores class name (OpenStruct) with this struct's values <tt>t</tt> as a
+ # Stores class name (OpenStruct) with this struct's values <tt>v</tt> as a
# JSON string.
def to_json(*args)
as_json.to_json(*args)
diff --git a/ext/json/lib/json/add/rational.rb b/ext/json/lib/json/add/rational.rb
index 6be4034581..356940b225 100644
--- a/ext/json/lib/json/add/rational.rb
+++ b/ext/json/lib/json/add/rational.rb
@@ -22,7 +22,7 @@ class Rational
end
# Stores class name (Rational) along with numerator value <tt>n</tt> and denominator value <tt>d</tt> as JSON string
- def to_json(*args)
- as_json.to_json(*args)
+ def to_json(*)
+ as_json.to_json
end
end
diff --git a/ext/json/lib/json/add/regexp.rb b/ext/json/lib/json/add/regexp.rb
index 39d69fede7..a93866b05a 100644
--- a/ext/json/lib/json/add/regexp.rb
+++ b/ext/json/lib/json/add/regexp.rb
@@ -24,7 +24,7 @@ class Regexp
# Stores class name (Regexp) with options <tt>o</tt> and source <tt>s</tt>
# (Regexp or String) as JSON string
- def to_json(*args)
- as_json.to_json(*args)
+ def to_json(*)
+ as_json.to_json
end
end
diff --git a/ext/json/lib/json/add/set.rb b/ext/json/lib/json/add/set.rb
deleted file mode 100644
index 71e2a0ac8b..0000000000
--- a/ext/json/lib/json/add/set.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-defined?(::Set) or require 'set'
-
-class Set
- # Import a JSON Marshalled object.
- #
- # method used for JSON marshalling support.
- def self.json_create(object)
- new object['a']
- end
-
- # Marshal the object to JSON.
- #
- # method used for JSON marshalling support.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'a' => to_a,
- }
- end
-
- # return the JSON value
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
-
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index 3be9fd8dc5..7cc852916c 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -153,7 +153,7 @@ module JSON
# * *object_class*: Defaults to Hash
# * *array_class*: Defaults to Array
def parse(source, opts = {})
- Parser.new(source, **(opts||{})).parse
+ Parser.new(source, opts).parse
end
# Parse the JSON document _source_ into a Ruby data structure and return it.
@@ -176,7 +176,7 @@ module JSON
:max_nesting => false,
:allow_nan => true
}.merge(opts)
- Parser.new(source, **(opts||{})).parse
+ Parser.new(source, opts).parse
end
# Generate a JSON document from the Ruby data structure _obj_ and return
diff --git a/ext/json/lib/json/version.rb b/ext/json/lib/json/version.rb
index 9d781df875..b65ed87f98 100644
--- a/ext/json/lib/json/version.rb
+++ b/ext/json/lib/json/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module JSON
# JSON version
- VERSION = '2.3.0'
+ VERSION = '2.1.0'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
diff --git a/ext/json/parser/depend b/ext/json/parser/depend
index d0c9c2d2a6..2ffd904475 100644
--- a/ext/json/parser/depend
+++ b/ext/json/parser/depend
@@ -4,8 +4,6 @@ parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h
# AUTOGENERATED DEPENDENCIES START
parser.o: $(RUBY_EXTCONF_H)
parser.o: $(arch_hdrdir)/ruby/config.h
-parser.o: $(hdrdir)/ruby.h
-parser.o: $(hdrdir)/ruby/assert.h
parser.o: $(hdrdir)/ruby/backward.h
parser.o: $(hdrdir)/ruby/defines.h
parser.o: $(hdrdir)/ruby/encoding.h
@@ -16,7 +14,8 @@ parser.o: $(hdrdir)/ruby/oniguruma.h
parser.o: $(hdrdir)/ruby/ruby.h
parser.o: $(hdrdir)/ruby/st.h
parser.o: $(hdrdir)/ruby/subst.h
-parser.o: $(srcdir)/../fbuffer/fbuffer.h
+parser.o: $(top_srcdir)/ext/json/fbuffer/fbuffer.h
+parser.o: $(top_srcdir)/include/ruby.h
parser.o: parser.c
parser.o: parser.h
parser.o: parser.rl
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
index 0f98cf9827..ae90b2e8fd 100644
--- a/ext/json/parser/parser.c
+++ b/ext/json/parser/parser.c
@@ -1,4 +1,4 @@
-/* This file is automatically generated from parser.rl by using ragel */
+
#line 1 "parser.rl"
#include "../fbuffer/fbuffer.h"
#include "parser.h"
@@ -27,7 +27,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
/* unicode */
-static const signed char digit_values[256] = {
+static const char digit_values[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
@@ -46,7 +46,7 @@ static const signed char digit_values[256] = {
static UTF32 unescape_unicode(const unsigned char *p)
{
- signed char b;
+ char b;
UTF32 result = 0;
b = digit_values[p[0]];
if (b < 0) return UNI_REPLACEMENT_CHAR;
@@ -91,20 +91,19 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
static VALUE CNaN, CInfinity, CMinusInfinity;
-static VALUE cBigDecimal = Qundef;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
i_object_class, i_array_class, i_decimal_class, i_key_p,
i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
- i_leftshift, i_new, i_BigDecimal;
+ i_leftshift, i_new;
-#line 126 "parser.rl"
+#line 125 "parser.rl"
-#line 108 "parser.c"
+#line 107 "parser.c"
enum {JSON_object_start = 1};
enum {JSON_object_first_final = 27};
enum {JSON_object_error = 0};
@@ -112,7 +111,7 @@ enum {JSON_object_error = 0};
enum {JSON_object_en_main = 1};
-#line 167 "parser.rl"
+#line 166 "parser.rl"
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -128,14 +127,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
*result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
-#line 132 "parser.c"
+#line 131 "parser.c"
{
cs = JSON_object_start;
}
-#line 182 "parser.rl"
+#line 181 "parser.rl"
-#line 139 "parser.c"
+#line 138 "parser.c"
{
if ( p == pe )
goto _test_eof;
@@ -163,7 +162,7 @@ case 2:
goto st2;
goto st0;
tr2:
-#line 149 "parser.rl"
+#line 148 "parser.rl"
{
char *np;
json->parsing_name = 1;
@@ -176,7 +175,7 @@ st3:
if ( ++p == pe )
goto _test_eof3;
case 3:
-#line 180 "parser.c"
+#line 179 "parser.c"
switch( (*p) ) {
case 13: goto st3;
case 32: goto st3;
@@ -243,7 +242,7 @@ case 8:
goto st8;
goto st0;
tr11:
-#line 134 "parser.rl"
+#line 133 "parser.rl"
{
VALUE v = Qnil;
char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -263,7 +262,7 @@ st9:
if ( ++p == pe )
goto _test_eof9;
case 9:
-#line 267 "parser.c"
+#line 266 "parser.c"
switch( (*p) ) {
case 13: goto st9;
case 32: goto st9;
@@ -352,14 +351,14 @@ case 18:
goto st9;
goto st18;
tr4:
-#line 157 "parser.rl"
+#line 156 "parser.rl"
{ p--; {p++; cs = 27; goto _out;} }
goto st27;
st27:
if ( ++p == pe )
goto _test_eof27;
case 27:
-#line 363 "parser.c"
+#line 362 "parser.c"
goto st0;
st19:
if ( ++p == pe )
@@ -457,7 +456,7 @@ case 26:
_out: {}
}
-#line 183 "parser.rl"
+#line 182 "parser.rl"
if (cs >= JSON_object_first_final) {
if (json->create_additions) {
@@ -482,7 +481,7 @@ case 26:
-#line 486 "parser.c"
+#line 485 "parser.c"
enum {JSON_value_start = 1};
enum {JSON_value_first_final = 29};
enum {JSON_value_error = 0};
@@ -490,7 +489,7 @@ enum {JSON_value_error = 0};
enum {JSON_value_en_main = 1};
-#line 283 "parser.rl"
+#line 282 "parser.rl"
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -498,14 +497,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
int cs = EVIL;
-#line 502 "parser.c"
+#line 501 "parser.c"
{
cs = JSON_value_start;
}
-#line 290 "parser.rl"
+#line 289 "parser.rl"
-#line 509 "parser.c"
+#line 508 "parser.c"
{
if ( p == pe )
goto _test_eof;
@@ -539,14 +538,14 @@ st0:
cs = 0;
goto _out;
tr2:
-#line 235 "parser.rl"
+#line 234 "parser.rl"
{
char *np = JSON_parse_string(json, p, pe, result);
if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
}
goto st29;
tr3:
-#line 240 "parser.rl"
+#line 239 "parser.rl"
{
char *np;
if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
@@ -566,7 +565,7 @@ tr3:
}
goto st29;
tr7:
-#line 258 "parser.rl"
+#line 257 "parser.rl"
{
char *np;
np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
@@ -574,7 +573,7 @@ tr7:
}
goto st29;
tr11:
-#line 264 "parser.rl"
+#line 263 "parser.rl"
{
char *np;
np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
@@ -582,7 +581,7 @@ tr11:
}
goto st29;
tr25:
-#line 228 "parser.rl"
+#line 227 "parser.rl"
{
if (json->allow_nan) {
*result = CInfinity;
@@ -592,7 +591,7 @@ tr25:
}
goto st29;
tr27:
-#line 221 "parser.rl"
+#line 220 "parser.rl"
{
if (json->allow_nan) {
*result = CNaN;
@@ -602,19 +601,19 @@ tr27:
}
goto st29;
tr31:
-#line 215 "parser.rl"
+#line 214 "parser.rl"
{
*result = Qfalse;
}
goto st29;
tr34:
-#line 212 "parser.rl"
+#line 211 "parser.rl"
{
*result = Qnil;
}
goto st29;
tr37:
-#line 218 "parser.rl"
+#line 217 "parser.rl"
{
*result = Qtrue;
}
@@ -623,9 +622,9 @@ st29:
if ( ++p == pe )
goto _test_eof29;
case 29:
-#line 270 "parser.rl"
+#line 269 "parser.rl"
{ p--; {p++; cs = 29; goto _out;} }
-#line 629 "parser.c"
+#line 628 "parser.c"
switch( (*p) ) {
case 13: goto st29;
case 32: goto st29;
@@ -866,7 +865,7 @@ case 28:
_out: {}
}
-#line 291 "parser.rl"
+#line 290 "parser.rl"
if (cs >= JSON_value_first_final) {
return p;
@@ -876,7 +875,7 @@ case 28:
}
-#line 880 "parser.c"
+#line 879 "parser.c"
enum {JSON_integer_start = 1};
enum {JSON_integer_first_final = 3};
enum {JSON_integer_error = 0};
@@ -884,7 +883,7 @@ enum {JSON_integer_error = 0};
enum {JSON_integer_en_main = 1};
-#line 307 "parser.rl"
+#line 306 "parser.rl"
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -892,15 +891,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
int cs = EVIL;
-#line 896 "parser.c"
+#line 895 "parser.c"
{
cs = JSON_integer_start;
}
-#line 314 "parser.rl"
+#line 313 "parser.rl"
json->memo = p;
-#line 904 "parser.c"
+#line 903 "parser.c"
{
if ( p == pe )
goto _test_eof;
@@ -934,14 +933,14 @@ case 3:
goto st0;
goto tr4;
tr4:
-#line 304 "parser.rl"
+#line 303 "parser.rl"
{ p--; {p++; cs = 4; goto _out;} }
goto st4;
st4:
if ( ++p == pe )
goto _test_eof4;
case 4:
-#line 945 "parser.c"
+#line 944 "parser.c"
goto st0;
st5:
if ( ++p == pe )
@@ -960,7 +959,7 @@ case 5:
_out: {}
}
-#line 316 "parser.rl"
+#line 315 "parser.rl"
if (cs >= JSON_integer_first_final) {
long len = p - json->memo;
@@ -975,7 +974,7 @@ case 5:
}
-#line 979 "parser.c"
+#line 978 "parser.c"
enum {JSON_float_start = 1};
enum {JSON_float_first_final = 8};
enum {JSON_float_error = 0};
@@ -983,36 +982,23 @@ enum {JSON_float_error = 0};
enum {JSON_float_en_main = 1};
-#line 341 "parser.rl"
+#line 340 "parser.rl"
-static int is_bigdecimal_class(VALUE obj)
-{
- if (cBigDecimal == Qundef) {
- if (rb_const_defined(rb_cObject, i_BigDecimal)) {
- cBigDecimal = rb_const_get_at(rb_cObject, i_BigDecimal);
- }
- else {
- return 0;
- }
- }
- return obj == cBigDecimal;
-}
-
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
{
int cs = EVIL;
-#line 1008 "parser.c"
+#line 994 "parser.c"
{
cs = JSON_float_start;
}
-#line 361 "parser.rl"
+#line 347 "parser.rl"
json->memo = p;
-#line 1016 "parser.c"
+#line 1002 "parser.c"
{
if ( p == pe )
goto _test_eof;
@@ -1070,14 +1056,14 @@ case 8:
goto st0;
goto tr9;
tr9:
-#line 335 "parser.rl"
+#line 334 "parser.rl"
{ p--; {p++; cs = 9; goto _out;} }
goto st9;
st9:
if ( ++p == pe )
goto _test_eof9;
case 9:
-#line 1081 "parser.c"
+#line 1067 "parser.c"
goto st0;
st5:
if ( ++p == pe )
@@ -1138,7 +1124,7 @@ case 7:
_out: {}
}
-#line 363 "parser.rl"
+#line 349 "parser.rl"
if (cs >= JSON_float_first_final) {
long len = p - json->memo;
@@ -1150,11 +1136,7 @@ case 7:
} else {
VALUE text;
text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
- if (is_bigdecimal_class(json->decimal_class)) {
- *result = rb_funcall(Qnil, i_BigDecimal, 1, text);
- } else {
- *result = rb_funcall(json->decimal_class, i_new, 1, text);
- }
+ *result = rb_funcall(json->decimal_class, i_new, 1, text);
}
return p + 1;
} else {
@@ -1164,7 +1146,7 @@ case 7:
-#line 1168 "parser.c"
+#line 1150 "parser.c"
enum {JSON_array_start = 1};
enum {JSON_array_first_final = 17};
enum {JSON_array_error = 0};
@@ -1172,7 +1154,7 @@ enum {JSON_array_error = 0};
enum {JSON_array_en_main = 1};
-#line 416 "parser.rl"
+#line 398 "parser.rl"
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -1186,14 +1168,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
*result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
-#line 1190 "parser.c"
+#line 1172 "parser.c"
{
cs = JSON_array_start;
}
-#line 429 "parser.rl"
+#line 411 "parser.rl"
-#line 1197 "parser.c"
+#line 1179 "parser.c"
{
if ( p == pe )
goto _test_eof;
@@ -1232,7 +1214,7 @@ case 2:
goto st2;
goto st0;
tr2:
-#line 393 "parser.rl"
+#line 375 "parser.rl"
{
VALUE v = Qnil;
char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -1252,7 +1234,7 @@ st3:
if ( ++p == pe )
goto _test_eof3;
case 3:
-#line 1256 "parser.c"
+#line 1238 "parser.c"
switch( (*p) ) {
case 13: goto st3;
case 32: goto st3;
@@ -1352,14 +1334,14 @@ case 12:
goto st3;
goto st12;
tr4:
-#line 408 "parser.rl"
+#line 390 "parser.rl"
{ p--; {p++; cs = 17; goto _out;} }
goto st17;
st17:
if ( ++p == pe )
goto _test_eof17;
case 17:
-#line 1363 "parser.c"
+#line 1345 "parser.c"
goto st0;
st13:
if ( ++p == pe )
@@ -1415,7 +1397,7 @@ case 16:
_out: {}
}
-#line 430 "parser.rl"
+#line 412 "parser.rl"
if(cs >= JSON_array_first_final) {
return p + 1;
@@ -1504,7 +1486,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
}
-#line 1508 "parser.c"
+#line 1490 "parser.c"
enum {JSON_string_start = 1};
enum {JSON_string_first_final = 8};
enum {JSON_string_error = 0};
@@ -1512,7 +1494,7 @@ enum {JSON_string_error = 0};
enum {JSON_string_en_main = 1};
-#line 537 "parser.rl"
+#line 519 "parser.rl"
static int
@@ -1534,15 +1516,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
*result = rb_str_buf_new(0);
-#line 1538 "parser.c"
+#line 1520 "parser.c"
{
cs = JSON_string_start;
}
-#line 558 "parser.rl"
+#line 540 "parser.rl"
json->memo = p;
-#line 1546 "parser.c"
+#line 1528 "parser.c"
{
if ( p == pe )
goto _test_eof;
@@ -1567,7 +1549,7 @@ case 2:
goto st0;
goto st2;
tr2:
-#line 523 "parser.rl"
+#line 505 "parser.rl"
{
*result = json_string_unescape(*result, json->memo + 1, p);
if (NIL_P(*result)) {
@@ -1578,14 +1560,14 @@ tr2:
{p = (( p + 1))-1;}
}
}
-#line 534 "parser.rl"
+#line 516 "parser.rl"
{ p--; {p++; cs = 8; goto _out;} }
goto st8;
st8:
if ( ++p == pe )
goto _test_eof8;
case 8:
-#line 1589 "parser.c"
+#line 1571 "parser.c"
goto st0;
st3:
if ( ++p == pe )
@@ -1661,7 +1643,7 @@ case 7:
_out: {}
}
-#line 560 "parser.rl"
+#line 542 "parser.rl"
if (json->create_additions && RTEST(match_string = json->match_string)) {
VALUE klass;
@@ -1676,7 +1658,7 @@ case 7:
if (json->symbolize_names && json->parsing_name) {
*result = rb_str_intern(*result);
- } else if (RB_TYPE_P(*result, T_STRING)) {
+ } else {
rb_str_resize(*result, RSTRING_LEN(*result));
}
if (cs >= JSON_string_first_final) {
@@ -1848,7 +1830,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
}
-#line 1852 "parser.c"
+#line 1834 "parser.c"
enum {JSON_start = 1};
enum {JSON_first_final = 10};
enum {JSON_error = 0};
@@ -1856,7 +1838,7 @@ enum {JSON_error = 0};
enum {JSON_en_main = 1};
-#line 760 "parser.rl"
+#line 742 "parser.rl"
/*
@@ -1873,16 +1855,16 @@ static VALUE cParser_parse(VALUE self)
GET_PARSER;
-#line 1877 "parser.c"
+#line 1859 "parser.c"
{
cs = JSON_start;
}
-#line 776 "parser.rl"
+#line 758 "parser.rl"
p = json->source;
pe = p + json->len;
-#line 1886 "parser.c"
+#line 1868 "parser.c"
{
if ( p == pe )
goto _test_eof;
@@ -1916,7 +1898,7 @@ st0:
cs = 0;
goto _out;
tr2:
-#line 752 "parser.rl"
+#line 734 "parser.rl"
{
char *np = JSON_parse_value(json, p, pe, &result, 0);
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
@@ -1926,7 +1908,7 @@ st10:
if ( ++p == pe )
goto _test_eof10;
case 10:
-#line 1930 "parser.c"
+#line 1912 "parser.c"
switch( (*p) ) {
case 13: goto st10;
case 32: goto st10;
@@ -2015,7 +1997,7 @@ case 9:
_out: {}
}
-#line 779 "parser.rl"
+#line 761 "parser.rl"
if (cs >= JSON_first_final && p == pe) {
return result;
@@ -2082,28 +2064,20 @@ static VALUE cParser_source(VALUE self)
void Init_parser(void)
{
-#undef rb_intern
rb_require("json/common");
mJSON = rb_define_module("JSON");
mExt = rb_define_module_under(mJSON, "Ext");
cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
eParserError = rb_path2class("JSON::ParserError");
eNestingError = rb_path2class("JSON::NestingError");
- rb_gc_register_mark_object(eParserError);
- rb_gc_register_mark_object(eNestingError);
rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
rb_define_method(cParser, "initialize", cParser_initialize, -1);
rb_define_method(cParser, "parse", cParser_parse, 0);
rb_define_method(cParser, "source", cParser_source, 0);
CNaN = rb_const_get(mJSON, rb_intern("NaN"));
- rb_gc_register_mark_object(CNaN);
-
CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
- rb_gc_register_mark_object(CInfinity);
-
CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
- rb_gc_register_mark_object(CMinusInfinity);
i_json_creatable_p = rb_intern("json_creatable?");
i_json_create = rb_intern("json_create");
@@ -2124,7 +2098,6 @@ void Init_parser(void)
i_aref = rb_intern("[]");
i_leftshift = rb_intern("<<");
i_new = rb_intern("new");
- i_BigDecimal = rb_intern("BigDecimal");
}
/*
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
index 6b38bb283a..f7dbcffb5f 100644
--- a/ext/json/parser/parser.rl
+++ b/ext/json/parser/parser.rl
@@ -25,7 +25,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
/* unicode */
-static const signed char digit_values[256] = {
+static const char digit_values[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
@@ -44,7 +44,7 @@ static const signed char digit_values[256] = {
static UTF32 unescape_unicode(const unsigned char *p)
{
- signed char b;
+ char b;
UTF32 result = 0;
b = digit_values[p[0]];
if (b < 0) return UNI_REPLACEMENT_CHAR;
@@ -89,13 +89,12 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
static VALUE CNaN, CInfinity, CMinusInfinity;
-static VALUE cBigDecimal = Qundef;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
i_object_class, i_array_class, i_decimal_class, i_key_p,
i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
- i_leftshift, i_new, i_BigDecimal;
+ i_leftshift, i_new;
%%{
machine JSON_common;
@@ -340,19 +339,6 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
) (^[0-9Ee.\-]? @exit );
}%%
-static int is_bigdecimal_class(VALUE obj)
-{
- if (cBigDecimal == Qundef) {
- if (rb_const_defined(rb_cObject, i_BigDecimal)) {
- cBigDecimal = rb_const_get_at(rb_cObject, i_BigDecimal);
- }
- else {
- return 0;
- }
- }
- return obj == cBigDecimal;
-}
-
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
{
int cs = EVIL;
@@ -371,11 +357,7 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
} else {
VALUE text;
text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
- if (is_bigdecimal_class(json->decimal_class)) {
- *result = rb_funcall(Qnil, i_BigDecimal, 1, text);
- } else {
- *result = rb_funcall(json->decimal_class, i_new, 1, text);
- }
+ *result = rb_funcall(json->decimal_class, i_new, 1, text);
}
return p + 1;
} else {
@@ -571,7 +553,7 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
if (json->symbolize_names && json->parsing_name) {
*result = rb_str_intern(*result);
- } else if (RB_TYPE_P(*result, T_STRING)) {
+ } else {
rb_str_resize(*result, RSTRING_LEN(*result));
}
if (cs >= JSON_string_first_final) {
@@ -842,28 +824,20 @@ static VALUE cParser_source(VALUE self)
void Init_parser(void)
{
-#undef rb_intern
rb_require("json/common");
mJSON = rb_define_module("JSON");
mExt = rb_define_module_under(mJSON, "Ext");
cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
eParserError = rb_path2class("JSON::ParserError");
eNestingError = rb_path2class("JSON::NestingError");
- rb_gc_register_mark_object(eParserError);
- rb_gc_register_mark_object(eNestingError);
rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
rb_define_method(cParser, "initialize", cParser_initialize, -1);
rb_define_method(cParser, "parse", cParser_parse, 0);
rb_define_method(cParser, "source", cParser_source, 0);
CNaN = rb_const_get(mJSON, rb_intern("NaN"));
- rb_gc_register_mark_object(CNaN);
-
CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
- rb_gc_register_mark_object(CInfinity);
-
CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
- rb_gc_register_mark_object(CMinusInfinity);
i_json_creatable_p = rb_intern("json_creatable?");
i_json_create = rb_intern("json_create");
@@ -884,7 +858,6 @@ void Init_parser(void)
i_aref = rb_intern("[]");
i_leftshift = rb_intern("<<");
i_new = rb_intern("new");
- i_BigDecimal = rb_intern("BigDecimal");
}
/*
diff --git a/ext/json/parser/prereq.mk b/ext/json/parser/prereq.mk
index 37bacc3380..be7bcb4319 100644
--- a/ext/json/parser/prereq.mk
+++ b/ext/json/parser/prereq.mk
@@ -5,7 +5,6 @@ RAGEL = ragel
.rl.c:
$(RAGEL) -G2 $<
$(BASERUBY) -pli -e '$$_.sub!(/[ \t]+$$/, "")' \
- -e '$$_.sub!(/^static const int (JSON_.*=.*);$$/, "enum {\\1};")' \
- -e '$$_ = "/* This file is automatically generated from parser.rl by using ragel */" + $$_ if $$. == 1' $@
+ -e '$$_.sub!(/^static const int (JSON_.*=.*);$$/, "enum {\\1};")' $@
parser.c:
diff --git a/ext/monitor/depend b/ext/monitor/depend
deleted file mode 100644
index 89efe1766b..0000000000
--- a/ext/monitor/depend
+++ /dev/null
@@ -1,13 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-monitor.o: $(RUBY_EXTCONF_H)
-monitor.o: $(arch_hdrdir)/ruby/config.h
-monitor.o: $(hdrdir)/ruby/assert.h
-monitor.o: $(hdrdir)/ruby/backward.h
-monitor.o: $(hdrdir)/ruby/defines.h
-monitor.o: $(hdrdir)/ruby/intern.h
-monitor.o: $(hdrdir)/ruby/missing.h
-monitor.o: $(hdrdir)/ruby/ruby.h
-monitor.o: $(hdrdir)/ruby/st.h
-monitor.o: $(hdrdir)/ruby/subst.h
-monitor.o: monitor.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/monitor/extconf.rb b/ext/monitor/extconf.rb
deleted file mode 100644
index 78c53fa0c5..0000000000
--- a/ext/monitor/extconf.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'mkmf'
-create_makefile('monitor')
diff --git a/ext/monitor/lib/monitor.rb b/ext/monitor/lib/monitor.rb
deleted file mode 100644
index 1883cb72f6..0000000000
--- a/ext/monitor/lib/monitor.rb
+++ /dev/null
@@ -1,284 +0,0 @@
-# frozen_string_literal: false
-# = monitor.rb
-#
-# Copyright (C) 2001 Shugo Maeda <shugo@ruby-lang.org>
-#
-# This library is distributed under the terms of the Ruby license.
-# You can freely distribute/modify this library.
-#
-
-#
-# In concurrent programming, a monitor is an object or module intended to be
-# used safely by more than one thread. The defining characteristic of a
-# monitor is that its methods are executed with mutual exclusion. That is, at
-# each point in time, at most one thread may be executing any of its methods.
-# This mutual exclusion greatly simplifies reasoning about the implementation
-# of monitors compared to reasoning about parallel code that updates a data
-# structure.
-#
-# You can read more about the general principles on the Wikipedia page for
-# Monitors[http://en.wikipedia.org/wiki/Monitor_%28synchronization%29]
-#
-# == Examples
-#
-# === Simple object.extend
-#
-# require 'monitor.rb'
-#
-# buf = []
-# buf.extend(MonitorMixin)
-# empty_cond = buf.new_cond
-#
-# # consumer
-# Thread.start do
-# loop do
-# buf.synchronize do
-# empty_cond.wait_while { buf.empty? }
-# print buf.shift
-# end
-# end
-# end
-#
-# # producer
-# while line = ARGF.gets
-# buf.synchronize do
-# buf.push(line)
-# empty_cond.signal
-# end
-# end
-#
-# The consumer thread waits for the producer thread to push a line to buf
-# while <tt>buf.empty?</tt>. The producer thread (main thread) reads a
-# line from ARGF and pushes it into buf then calls <tt>empty_cond.signal</tt>
-# to notify the consumer thread of new data.
-#
-# === Simple Class include
-#
-# require 'monitor'
-#
-# class SynchronizedArray < Array
-#
-# include MonitorMixin
-#
-# def initialize(*args)
-# super(*args)
-# end
-#
-# alias :old_shift :shift
-# alias :old_unshift :unshift
-#
-# def shift(n=1)
-# self.synchronize do
-# self.old_shift(n)
-# end
-# end
-#
-# def unshift(item)
-# self.synchronize do
-# self.old_unshift(item)
-# end
-# end
-#
-# # other methods ...
-# end
-#
-# +SynchronizedArray+ implements an Array with synchronized access to items.
-# This Class is implemented as subclass of Array which includes the
-# MonitorMixin module.
-#
-
-require 'monitor.so'
-
-module MonitorMixin
- #
- # FIXME: This isn't documented in Nutshell.
- #
- # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
- # above calls while_wait and signal, this class should be documented.
- #
- class ConditionVariable
- #
- # Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
- #
- # If +timeout+ is given, this method returns after +timeout+ seconds passed,
- # even if no other thread doesn't signal.
- #
- def wait(timeout = nil)
- @monitor.mon_check_owner
- @monitor.wait_for_cond(@cond, timeout)
- end
-
- #
- # Calls wait repeatedly while the given block yields a truthy value.
- #
- def wait_while
- while yield
- wait
- end
- end
-
- #
- # Calls wait repeatedly until the given block yields a truthy value.
- #
- def wait_until
- until yield
- wait
- end
- end
-
- #
- # Wakes up the first thread in line waiting for this lock.
- #
- def signal
- @monitor.mon_check_owner
- @cond.signal
- end
-
- #
- # Wakes up all threads waiting for this lock.
- #
- def broadcast
- @monitor.mon_check_owner
- @cond.broadcast
- end
-
- private
-
- def initialize(monitor)
- @monitor = monitor
- @cond = Thread::ConditionVariable.new
- end
- end
-
- def self.extend_object(obj)
- super(obj)
- obj.__send__(:mon_initialize)
- end
-
- #
- # Attempts to enter exclusive section. Returns +false+ if lock fails.
- #
- def mon_try_enter
- @mon_data.try_enter
- end
- # For backward compatibility
- alias try_mon_enter mon_try_enter
-
- #
- # Enters exclusive section.
- #
- def mon_enter
- @mon_data.enter
- end
-
- #
- # Leaves exclusive section.
- #
- def mon_exit
- mon_check_owner
- @mon_data.exit
- end
-
- #
- # Returns true if this monitor is locked by any thread
- #
- def mon_locked?
- @mon_data.mon_locked?
- end
-
- #
- # Returns true if this monitor is locked by current thread.
- #
- def mon_owned?
- @mon_data.mon_owned?
- end
-
- #
- # Enters exclusive section and executes the block. Leaves the exclusive
- # section automatically when the block exits. See example under
- # +MonitorMixin+.
- #
- def mon_synchronize(&b)
- @mon_data.synchronize(&b)
- end
- alias synchronize mon_synchronize
-
- #
- # Creates a new MonitorMixin::ConditionVariable associated with the
- # Monitor object.
- #
- def new_cond
- unless defined?(@mon_data)
- mon_initialize
- @mon_initialized_by_new_cond = true
- end
- return ConditionVariable.new(@mon_data)
- end
-
- private
-
- # Use <tt>extend MonitorMixin</tt> or <tt>include MonitorMixin</tt> instead
- # of this constructor. Have look at the examples above to understand how to
- # use this module.
- def initialize(*args)
- super
- mon_initialize
- end
-
- # Initializes the MonitorMixin after being included in a class or when an
- # object has been extended with the MonitorMixin
- def mon_initialize
- if defined?(@mon_data)
- if defined?(@mon_initialized_by_new_cond)
- return # already initalized.
- elsif @mon_data_owner_object_id == self.object_id
- raise ThreadError, "already initialized"
- end
- end
- @mon_data = ::Monitor.new
- @mon_data_owner_object_id = self.object_id
- end
-
- def mon_check_owner
- @mon_data.mon_check_owner
- end
-end
-
-# Use the Monitor class when you want to have a lock object for blocks with
-# mutual exclusion.
-#
-# require 'monitor'
-#
-# lock = Monitor.new
-# lock.synchronize do
-# # exclusive access
-# end
-#
-class Monitor
- def new_cond
- ::MonitorMixin::ConditionVariable.new(self)
- end
-
- # for compatibility
- alias try_mon_enter try_enter
- alias mon_try_enter try_enter
- alias mon_enter enter
- alias mon_exit exit
- alias mon_synchronize synchronize
-end
-
-# Documentation comments:
-# - All documentation comes from Nutshell.
-# - MonitorMixin.new_cond appears in the example, but is not documented in
-# Nutshell.
-# - All the internals (internal modules Accessible and Initializable, class
-# ConditionVariable) appear in RDoc. It might be good to hide them, by
-# making them private, or marking them :nodoc:, etc.
-# - RDoc doesn't recognise aliases, so we have mon_synchronize documented, but
-# not synchronize.
-# - mon_owner is in Nutshell, but appears as an accessor in a separate module
-# here, so is hard/impossible to RDoc. Some other useful accessors
-# (mon_count and some queue stuff) are also in this module, and don't appear
-# directly in the RDoc output.
-# - in short, it may be worth changing the code layout in this file to make the
-# documentation easier
diff --git a/ext/monitor/monitor.c b/ext/monitor/monitor.c
deleted file mode 100644
index 256fc4d7db..0000000000
--- a/ext/monitor/monitor.c
+++ /dev/null
@@ -1,221 +0,0 @@
-#include "ruby/ruby.h"
-
-/* Thread::Monitor */
-
-struct rb_monitor {
- long count;
- const VALUE owner;
- const VALUE mutex;
-};
-
-static void
-monitor_mark(void *ptr)
-{
- struct rb_monitor *mc = ptr;
- rb_gc_mark(mc->owner);
- rb_gc_mark(mc->mutex);
-}
-
-static size_t
-monitor_memsize(const void *ptr)
-{
- return sizeof(struct rb_monitor);
-}
-
-static const rb_data_type_t monitor_data_type = {
- "monitor",
- {monitor_mark, RUBY_TYPED_DEFAULT_FREE, monitor_memsize,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED
-};
-
-static VALUE
-monitor_alloc(VALUE klass)
-{
- struct rb_monitor *mc;
- VALUE obj;
-
- obj = TypedData_Make_Struct(klass, struct rb_monitor, &monitor_data_type, mc);
- RB_OBJ_WRITE(obj, &mc->mutex, rb_mutex_new());
- RB_OBJ_WRITE(obj, &mc->owner, Qnil);
- mc->count = 0;
-
- return obj;
-}
-
-static struct rb_monitor *
-monitor_ptr(VALUE monitor)
-{
- struct rb_monitor *mc;
- TypedData_Get_Struct(monitor, struct rb_monitor, &monitor_data_type, mc);
- return mc;
-}
-
-static int
-mc_owner_p(struct rb_monitor *mc)
-{
- return mc->owner == rb_thread_current();
-}
-
-static VALUE
-monitor_try_enter(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
-
- if (!mc_owner_p(mc)) {
- if (!rb_mutex_trylock(mc->mutex)) {
- return Qfalse;
- }
- RB_OBJ_WRITE(monitor, &mc->owner, rb_thread_current());
- mc->count = 0;
- }
- mc->count += 1;
- return Qtrue;
-}
-
-static VALUE
-monitor_enter(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- if (!mc_owner_p(mc)) {
- rb_mutex_lock(mc->mutex);
- RB_OBJ_WRITE(monitor, &mc->owner, rb_thread_current());
- mc->count = 0;
- }
- mc->count++;
- return Qnil;
-}
-
-static VALUE
-monitor_check_owner(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- if (!mc_owner_p(mc)) {
- rb_raise(rb_eThreadError, "current thread not owner");
- }
- return Qnil;
-}
-
-static VALUE
-monitor_exit(VALUE monitor)
-{
- monitor_check_owner(monitor);
-
- struct rb_monitor *mc = monitor_ptr(monitor);
-
- if (mc->count <= 0) rb_bug("monitor_exit: count:%d\n", (int)mc->count);
- mc->count--;
-
- if (mc->count == 0) {
- RB_OBJ_WRITE(monitor, &mc->owner, Qnil);
- rb_mutex_unlock(mc->mutex);
- }
- return Qnil;
-}
-
-static VALUE
-monitor_locked_p(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- return rb_mutex_locked_p(mc->mutex);
-}
-
-static VALUE
-monitor_owned_p(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- return (rb_mutex_locked_p(mc->mutex) && mc_owner_p(mc)) ? Qtrue : Qfalse;
-}
-
-static VALUE
-monitor_exit_for_cond(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- long cnt = mc->count;
- RB_OBJ_WRITE(monitor, &mc->owner, Qnil);
- mc->count = 0;
- return LONG2NUM(cnt);
-}
-
-struct wait_for_cond_data {
- VALUE monitor;
- VALUE cond;
- VALUE timeout;
- VALUE count;
-};
-
-static VALUE
-monitor_wait_for_cond_body(VALUE v)
-{
- struct wait_for_cond_data *data = (struct wait_for_cond_data *)v;
- struct rb_monitor *mc = monitor_ptr(data->monitor);
- // cond.wait(monitor.mutex, timeout)
- rb_funcall(data->cond, rb_intern("wait"), 2, mc->mutex, data->timeout);
- return Qtrue;
-}
-
-static VALUE
-monitor_enter_for_cond(VALUE v)
-{
- // assert(rb_mutex_owned_p(mc->mutex) == Qtrue)
- // but rb_mutex_owned_p is not exported...
-
- struct wait_for_cond_data *data = (struct wait_for_cond_data *)v;
- struct rb_monitor *mc = monitor_ptr(data->monitor);
- RB_OBJ_WRITE(data->monitor, &mc->owner, rb_thread_current());
- mc->count = NUM2LONG(data->count);
- return Qnil;
-}
-
-static VALUE
-monitor_wait_for_cond(VALUE monitor, VALUE cond, VALUE timeout)
-{
- VALUE count = monitor_exit_for_cond(monitor);
- struct wait_for_cond_data data = {
- monitor,
- cond,
- timeout,
- count,
- };
-
- return rb_ensure(monitor_wait_for_cond_body, (VALUE)&data,
- monitor_enter_for_cond, (VALUE)&data);
-}
-
-static VALUE
-monitor_sync_body(VALUE monitor)
-{
- return rb_yield_values(0);
-}
-
-static VALUE
-monitor_sync_ensure(VALUE monitor)
-{
- return monitor_exit(monitor);
-}
-
-static VALUE
-monitor_synchronize(VALUE monitor)
-{
- monitor_enter(monitor);
- return rb_ensure(monitor_sync_body, monitor, monitor_sync_ensure, monitor);
-}
-
-void
-Init_monitor(void)
-{
- VALUE rb_cMonitor = rb_define_class("Monitor", rb_cObject);
- rb_define_alloc_func(rb_cMonitor, monitor_alloc);
-
- rb_define_method(rb_cMonitor, "try_enter", monitor_try_enter, 0);
- rb_define_method(rb_cMonitor, "enter", monitor_enter, 0);
- rb_define_method(rb_cMonitor, "exit", monitor_exit, 0);
- rb_define_method(rb_cMonitor, "synchronize", monitor_synchronize, 0);
-
- /* internal methods for MonitorMixin */
- rb_define_method(rb_cMonitor, "mon_locked?", monitor_locked_p, 0);
- rb_define_method(rb_cMonitor, "mon_check_owner", monitor_check_owner, 0);
- rb_define_method(rb_cMonitor, "mon_owned?", monitor_owned_p, 0);
-
- /* internal methods for MonitorMixin::ConditionalVariable */
- rb_define_method(rb_cMonitor, "wait_for_cond", monitor_wait_for_cond, 2);
-}
diff --git a/ext/nkf/depend b/ext/nkf/depend
index 82580ff7fe..4ea8544a95 100644
--- a/ext/nkf/depend
+++ b/ext/nkf/depend
@@ -5,7 +5,6 @@ nkf.o: nkf.c
# AUTOGENERATED DEPENDENCIES START
nkf.o: $(RUBY_EXTCONF_H)
nkf.o: $(arch_hdrdir)/ruby/config.h
-nkf.o: $(hdrdir)/ruby/assert.h
nkf.o: $(hdrdir)/ruby/backward.h
nkf.o: $(hdrdir)/ruby/defines.h
nkf.o: $(hdrdir)/ruby/encoding.h
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
index cc438a50d6..b58c437d3c 100644
--- a/ext/nkf/nkf-utf8/nkf.c
+++ b/ext/nkf/nkf-utf8/nkf.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
- * Copyright (c) 1996-2018, The nkf Project.
+ * Copyright (c) 1996-2013, The nkf Project.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -20,11 +20,11 @@
*
* 3. This notice may not be removed or altered from any source distribution.
*/
-#define NKF_VERSION "2.1.5"
-#define NKF_RELEASE_DATE "2018-12-15"
+#define NKF_VERSION "2.1.4"
+#define NKF_RELEASE_DATE "2015-12-12"
#define COPY_RIGHT \
"Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
- "Copyright (C) 1996-2018, The nkf Project."
+ "Copyright (C) 1996-2015, The nkf Project."
#include "config.h"
#include "nkf.h"
@@ -1111,26 +1111,18 @@ encode_fallback_java(nkf_char c)
(*oconv)(0, '\\');
c &= VALUE_MASK;
if(!nkf_char_unicode_bmp_p(c)){
- int high = (c >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */
- int low = (c & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */
- (*oconv)(0, 'u');
- (*oconv)(0, bin2hex(high>>12));
- (*oconv)(0, bin2hex(high>> 8));
- (*oconv)(0, bin2hex(high>> 4));
- (*oconv)(0, bin2hex(high ));
- (*oconv)(0, '\\');
- (*oconv)(0, 'u');
- (*oconv)(0, bin2hex(low>>12));
- (*oconv)(0, bin2hex(low>> 8));
- (*oconv)(0, bin2hex(low>> 4));
- (*oconv)(0, bin2hex(low ));
+ (*oconv)(0, 'U');
+ (*oconv)(0, '0');
+ (*oconv)(0, '0');
+ (*oconv)(0, bin2hex(c>>20));
+ (*oconv)(0, bin2hex(c>>16));
}else{
(*oconv)(0, 'u');
- (*oconv)(0, bin2hex(c>>12));
- (*oconv)(0, bin2hex(c>> 8));
- (*oconv)(0, bin2hex(c>> 4));
- (*oconv)(0, bin2hex(c ));
}
+ (*oconv)(0, bin2hex(c>>12));
+ (*oconv)(0, bin2hex(c>> 8));
+ (*oconv)(0, bin2hex(c>> 4));
+ (*oconv)(0, bin2hex(c ));
return;
}
@@ -1955,17 +1947,12 @@ unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_c
ret = unicode_to_jis_common2(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
}else return -1;
#ifdef SHIFTJIS_CP932
- if (!ret&& is_eucg3(*p2)) {
- if (cp932inv_f) {
- if (encode_fallback) ret = 1;
- }
- else {
- nkf_char s2, s1;
- if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
- s2e_conv(s2, s1, p2, p1);
- }else{
- ret = 1;
- }
+ if (!ret && !cp932inv_f && is_eucg3(*p2)) {
+ nkf_char s2, s1;
+ if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
+ s2e_conv(s2, s1, p2, p1);
+ }else{
+ ret = 1;
}
}
#endif
diff --git a/ext/nkf/nkf-utf8/utf8tbl.c b/ext/nkf/nkf-utf8/utf8tbl.c
index a31e4e7805..3821c59468 100644
--- a/ext/nkf/nkf-utf8/utf8tbl.c
+++ b/ext/nkf/nkf-utf8/utf8tbl.c
@@ -5445,7 +5445,7 @@ static const unsigned short utf8_to_euc_E4BB_x0213[] = {
0xB047, 0x2E28, 0xB049, 0x4265, 0x4E61, 0x304A, 0, 0,
0xB04A, 0, 0, 0xA13B, 0, 0x5041, 0x323E, 0xB04B,
0x3644, 0xA13D, 0x4367, 0xB04D, 0, 0xA13E, 0x376F, 0x5043,
- 0, 0, 0, 0x4724, 0, 0x2E29, 0xB050, 0x2E2A,
+ 0, 0, 0, 0x4724, 0xF42F, 0x2E29, 0xB050, 0x2E2A,
};
static const unsigned short utf8_to_euc_E4BC[] = {
0xB052, 0x346B, 0xB053, 0xB054, 0, 0, 0, 0,
@@ -5465,7 +5465,7 @@ static const unsigned short utf8_to_euc_E4BC_x0213[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0xB05D, 0x476C,
0x5046, 0xB05E, 0, 0xB060, 0x483C, 0xB061, 0x4E62, 0xA142,
- 0x3F2D, 0, 0x3B47, 0xB064, 0x3B77, 0x3240, 0xA143, 0,
+ 0x3F2D, 0xB063, 0x3B47, 0xB064, 0x3B77, 0x3240, 0xA143, 0,
};
static const unsigned short utf8_to_euc_E4BD[] = {
0xB066, 0, 0xB067, 0x4451, 0, 0, 0x4322, 0x504A,
@@ -5519,13 +5519,13 @@ static const unsigned short utf8_to_euc_E4BF[] = {
};
static const unsigned short utf8_to_euc_E4BF_x0213[] = {
0xB136, 0xB137, 0x3738, 0x4225, 0x3264, 0xA152, 0xB139, 0,
- 0xB13A, 0x2E39, 0x3D53, 0xA153, 0xB13D, 0, 0x5059, 0xA154,
+ 0xB13A, 0x2E39, 0x3D53, 0xA153, 0xB13D, 0xB13E, 0x5059, 0xA154,
0x505E, 0x505C, 0xA155, 0, 0x5057, 0, 0, 0x422F,
0x505A, 0, 0x505D, 0x505B, 0xB141, 0x4A5D, 0, 0x5058,
0x2E3A, 0x3F2E, 0xB143, 0x4B73, 0x505F, 0x5060, 0xA14F, 0,
0, 0, 0, 0, 0, 0, 0x3D24, 0x506D,
0xB144, 0x2E21, 0xA157, 0x4750, 0, 0x4936, 0x5068, 0,
- 0x4A70, 0, 0x3236, 0, 0xB146, 0xB147, 0x506C, 0,
+ 0x4A70, 0, 0x3236, 0, 0xB146, 0xB147, 0x506C, 0xB148,
};
static const unsigned short utf8_to_euc_E580[] = {
0xB149, 0xB14A, 0, 0, 0xB14B, 0x5066, 0x506F, 0xB14C,
@@ -5601,10 +5601,10 @@ static const unsigned short utf8_to_euc_E583_x0213[] = {
0xB232, 0, 0x5124, 0xB233, 0xA174, 0x364F, 0, 0xA175,
0, 0x5121, 0x5122, 0, 0x2E45, 0x462F, 0xA178, 0x417C,
0x2E47, 0x3623, 0, 0xB239, 0xA17A, 0x4B4D, 0x5125, 0,
- 0, 0xA17B, 0x4E3D, 0, 0xB23C, 0xB23D, 0x5126, 0xB23E,
+ 0xB23B, 0xA17B, 0x4E3D, 0, 0xB23C, 0xB23D, 0x5126, 0xB23E,
0, 0xA17C, 0xB23F, 0x5129, 0xB240, 0x5127, 0x2E48, 0x414E,
0xB242, 0xA17D, 0, 0, 0, 0x5128, 0x512A, 0xB244,
- 0, 0xB245, 0x2E46, 0xA176, 0, 0x512C, 0xB246, 0,
+ 0, 0xB245, 0x2E46, 0xA176, 0xF430, 0x512C, 0xB246, 0,
0, 0x512B, 0xB247, 0x4A48, 0, 0, 0xB248, 0,
};
static const unsigned short utf8_to_euc_E584[] = {
@@ -5642,7 +5642,7 @@ static const unsigned short utf8_to_euc_E585_x0213[] = {
0x4068, 0x3877, 0x2E4F, 0x396E, 0x513C, 0x4C48, 0x4546, 0xB267,
0x3B79, 0, 0x513B, 0xB268, 0x513D, 0x2E51, 0, 0x2E52,
0xB26B, 0, 0x455E, 0, 0x3375, 0, 0, 0xB26C,
- 0xA326, 0, 0x513E, 0, 0, 0x467E, 0xB26E, 0,
+ 0xA326, 0, 0x513E, 0, 0xB26D, 0x467E, 0xB26E, 0,
0x4134, 0x5140, 0x5141, 0x482C, 0x3878, 0x4F3B, 0x5142, 0,
0, 0x3626, 0, 0xA328, 0, 0x4A3C, 0x4236, 0x3671,
0x4535, 0, 0, 0xF474, 0x3773, 0, 0xB26F, 0,
@@ -5665,7 +5665,7 @@ static const unsigned short utf8_to_euc_E586_x0213[] = {
0x3427, 0xB276, 0x514F, 0xA32D, 0x514D, 0x4C3D, 0x514E, 0,
0x495A, 0x5150, 0x5151, 0x5152, 0x455F, 0xA32E, 0, 0,
0x5156, 0x5154, 0x5155, 0x5153, 0x3A63, 0x5157, 0x4C6A, 0x4E64,
- 0xB279, 0, 0xB27A, 0, 0xA330, 0x5158, 0, 0xB27D,
+ 0xB279, 0, 0xB27A, 0, 0xA330, 0x5158, 0xB27C, 0xB27D,
};
static const unsigned short utf8_to_euc_E587[] = {
0, 0, 0xB27E, 0, 0x4028, 0x5159, 0x3D5A, 0,
@@ -5683,7 +5683,7 @@ static const unsigned short utf8_to_euc_E587_x0213[] = {
0, 0xB323, 0xB324, 0xB325, 0, 0xB326, 0x5245, 0,
0xB327, 0, 0, 0x515B, 0x7425, 0x3645, 0x2E57, 0,
0x515C, 0x4B5E, 0x2E58, 0, 0, 0xB32A, 0x3D68, 0x427C,
- 0, 0x515E, 0x4664, 0, 0, 0x515F, 0x2E59, 0,
+ 0, 0x515E, 0x4664, 0, 0xF431, 0x515F, 0x2E59, 0,
0x5160, 0x332E, 0xB32C, 0xA333, 0xA334, 0x5161, 0x3627, 0xB32F,
0x464C, 0x317A, 0x3D50, 0, 0, 0x4821, 0x5162, 0,
};
@@ -5741,7 +5741,7 @@ static const unsigned short utf8_to_euc_E58A_x0213[] = {
0xB34D, 0, 0xA33E, 0x3344, 0xA33D, 0xB34F, 0, 0x3760,
0x517C, 0x4E2D, 0xB350, 0, 0xB351, 0x5178, 0, 0,
0, 0x517D, 0x517A, 0x2E61, 0x5179, 0xB353, 0xB354, 0xB355,
- 0xA340, 0, 0xB357, 0x4E4F, 0, 0, 0, 0x3879,
+ 0xA340, 0, 0xB357, 0x4E4F, 0xB358, 0, 0, 0x3879,
0x3243, 0, 0, 0x4E74, 0xA342, 0xB35A, 0xA343, 0xB35C,
0, 0x3D75, 0x4558, 0x3965, 0x5222, 0x5223, 0, 0xA344,
0xB35E, 0x4E65, 0, 0, 0x4F2B, 0x5225, 0xB35F, 0xB360,
@@ -5758,7 +5758,7 @@ static const unsigned short utf8_to_euc_E58B[] = {
0x5230, 0x5231, 0x3C5B, 0, 0, 0, 0x387B, 0x4C5E,
};
static const unsigned short utf8_to_euc_E58B_x0213[] = {
- 0, 0x5226, 0, 0x4B56, 0xB366, 0x443C, 0xB367, 0x4D26,
+ 0xB365, 0x5226, 0, 0x4B56, 0xB366, 0x443C, 0xB367, 0x4D26,
0x2E62, 0x4A59, 0xA347, 0, 0x2E64, 0x5227, 0, 0xB36A,
0x2E65, 0xA349, 0x7055, 0, 0xB36C, 0x4630, 0x2E66, 0x5228,
0x342A, 0x4C33, 0, 0x2E67, 0xB36F, 0x3E21, 0x5229, 0x4A67,
@@ -5804,7 +5804,7 @@ static const unsigned short utf8_to_euc_E58D_x0213[] = {
0x4331, 0xB439, 0x476E, 0xB43A, 0x4B4E, 0, 0x5246, 0,
0x406A, 0x2E6F, 0, 0x2E70, 0, 0xB43D, 0x3735, 0xA354,
0, 0x5247, 0, 0, 0xA355, 0xB43F, 0x5248, 0x312C,
- 0x3075, 0x346D, 0, 0x4228, 0x3551, 0x4D71, 0, 0x524B,
+ 0x3075, 0x346D, 0xB440, 0x4228, 0x3551, 0x4D71, 0, 0x524B,
0x3237, 0xB441, 0xA356, 0x524A, 0, 0x2E71, 0xB442, 0x362A,
};
static const unsigned short utf8_to_euc_E58E[] = {
@@ -5841,7 +5841,7 @@ static const unsigned short utf8_to_euc_E58F_x0213[] = {
0xA35B, 0, 0x3B32, 0x5254, 0, 0xB458, 0, 0,
0x4B74, 0x3A35, 0x355A, 0x4D27, 0x4150, 0x483F, 0x3C7D, 0xB459,
0, 0, 0xB45A, 0xB45B, 0x3D47, 0xA35F, 0x3C68, 0x3C75,
- 0, 0x3D76, 0xA360, 0x4840, 0, 0, 0xB45F, 0x5257,
+ 0, 0x3D76, 0xA360, 0x4840, 0, 0xB45E, 0xB45F, 0x5257,
0xB460, 0x3143, 0x4151, 0x387D, 0x3845, 0x3667, 0xB461, 0xB462,
0x525B, 0x4321, 0x427E, 0x362B, 0x3E24, 0x525C, 0x525A, 0x3244,
0x4266, 0x3C38, 0x3B4B, 0x3126, 0xA362, 0xA363, 0x3370, 0x3966,
@@ -6121,8 +6121,8 @@ static const unsigned short utf8_to_euc_E59D_x0213[] = {
0x542E, 0, 0x3A64, 0, 0, 0xA45F, 0xA460, 0x3651,
0, 0, 0x4B37, 0, 0xA461, 0xA462, 0x542C, 0x542F,
0x3A41, 0x3923, 0xB740, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x5433, 0xB741, 0, 0x3A25, 0, 0x4333, 0xB743,
+ 0, 0xF436, 0, 0, 0, 0, 0, 0,
+ 0, 0x5433, 0xB741, 0, 0x3A25, 0xB742, 0x4333, 0xB743,
0xA464, 0x5430, 0x445A, 0xB745, 0, 0xB746, 0xB747, 0xA465,
0x2F47, 0xB74A, 0, 0xA466, 0xA467, 0xA468, 0, 0x2F48,
0, 0xB74F, 0xB750, 0xA469, 0x2F49, 0, 0xB753, 0x5434,
@@ -6224,7 +6224,7 @@ static const unsigned short utf8_to_euc_E5A2_x0213[] = {
0, 0, 0, 0, 0x4446, 0xA52F, 0x2F5D, 0x5452,
0xB848, 0xB849, 0xB84A, 0, 0, 0, 0xB84B, 0,
0x4B4F, 0x2F5F, 0xA530, 0x5453, 0, 0, 0x5458, 0,
- 0, 0xA531, 0, 0x4A2F, 0, 0, 0, 0,
+ 0, 0xA531, 0xB84E, 0x4A2F, 0, 0, 0, 0,
0x5457, 0x5451, 0x5454, 0x5456, 0xB850, 0, 0x3A26, 0,
};
static const unsigned short utf8_to_euc_E5A3[] = {
@@ -6280,9 +6280,9 @@ static const unsigned short utf8_to_euc_E5A5[] = {
static const unsigned short utf8_to_euc_E5A5_x0213[] = {
0, 0, 0, 0xB872, 0x3162, 0, 0xA542, 0x3471,
0x4660, 0x4A74, 0, 0, 0, 0, 0x5477, 0x4155,
- 0x5476, 0x3740, 0xB874, 0, 0x4B5B, 0x5475, 0, 0x4565,
+ 0x5476, 0x3740, 0xB874, 0xB875, 0x4B5B, 0x5475, 0, 0x4565,
0x5479, 0xB876, 0x5478, 0xA545, 0, 0x2F69, 0xB879, 0xA546,
- 0x547B, 0xB87B, 0x547A, 0, 0, 0x317C, 0, 0x547C,
+ 0x547B, 0xB87B, 0x547A, 0xB87C, 0, 0x317C, 0, 0x547C,
0x3E29, 0x547E, 0x4325, 0xB87D, 0x547D, 0x2F6A, 0x4A33, 0xB921,
0, 0, 0xB922, 0x3D77, 0x455B, 0xA548, 0xA549, 0,
0x5521, 0xB925, 0, 0xB926, 0xA54A, 0x3925, 0, 0,
@@ -6305,7 +6305,7 @@ static const unsigned short utf8_to_euc_E5A6_x0213[] = {
0, 0, 0, 0x5526, 0x2F6D, 0x4245, 0, 0xB930,
0x4B38, 0, 0, 0, 0x454A, 0xB931, 0xA54C, 0xB933,
0xB934, 0, 0x5527, 0xB935, 0, 0, 0, 0xB936,
- 0, 0x4B65, 0, 0x3A4A, 0xA54D, 0, 0x3E2A, 0,
+ 0, 0x4B65, 0xB937, 0x3A4A, 0xA54D, 0, 0x3E2A, 0,
};
static const unsigned short utf8_to_euc_E5A7[] = {
0, 0xB939, 0, 0xB93A, 0xB93B, 0, 0x5528, 0,
@@ -6564,7 +6564,7 @@ static const unsigned short utf8_to_euc_E5B3_x0213[] = {
0, 0x5635, 0, 0, 0, 0xBB3C, 0, 0,
0x463D, 0x362E, 0, 0, 0, 0, 0, 0,
0x3265, 0x5636, 0x563B, 0, 0, 0x5639, 0xBB3E, 0x4A77,
- 0x4A76, 0xBB3F, 0xBB40, 0, 0x4F6D, 0, 0x4567, 0,
+ 0x4A76, 0xBB3F, 0xBB40, 0, 0x4F6D, 0xF43B, 0x4567, 0,
0, 0, 0x5638, 0x3D54, 0, 0x5637, 0, 0,
};
static const unsigned short utf8_to_euc_E5B4[] = {
@@ -6640,7 +6640,7 @@ static const unsigned short utf8_to_euc_E5B7[] = {
static const unsigned short utf8_to_euc_E5B7_x0213[] = {
0, 0, 0, 0xBB76, 0, 0, 0, 0xBB77,
0, 0x565A, 0, 0x4F7D, 0x3460, 0x565B, 0xBB7A, 0,
- 0, 0xA868, 0x565D, 0x565C, 0, 0, 0x565E, 0xA869,
+ 0xBB79, 0xA868, 0x565D, 0x565C, 0, 0, 0x565E, 0xA869,
0xA86A, 0xBB7C, 0, 0x565F, 0, 0x406E, 0x3D23, 0,
0xA86B, 0x3D64, 0x7428, 0x4163, 0xA86D, 0x3929, 0x3A38, 0x392A,
0x3570, 0xA86E, 0, 0x5660, 0, 0, 0x3A39, 0,
@@ -6742,7 +6742,7 @@ static const unsigned short utf8_to_euc_E5BC_x0213[] = {
0xAC2D, 0x5732, 0x4A40, 0x5735, 0x5021, 0x5031, 0xAC2E, 0x3C30,
0x4675, 0x5736, 0, 0x355D, 0x4424, 0x307A, 0x5737, 0x4A26,
0x3930, 0xBC61, 0, 0x4350, 0xAC2F, 0x7434, 0xAC31, 0x446F,
- 0, 0, 0xBC65, 0x7435, 0xBC67, 0x4C6F, 0x3839, 0x384C,
+ 0, 0xBC64, 0xBC65, 0x7435, 0xBC67, 0x4C6F, 0x3839, 0x384C,
0xBC68, 0x5738, 0, 0xBC69, 0xBC6A, 0x5739, 0xBC6B, 0x573F,
0xBC6C, 0x3C65, 0, 0, 0x7436, 0x4425, 0x7437, 0x362F,
0x573A, 0, 0, 0xBC6F, 0x492B, 0x7438, 0x4346, 0xBC71,
@@ -6841,7 +6841,7 @@ static const unsigned short utf8_to_euc_E681_x0213[] = {
0xBD5E, 0x576C, 0x5776, 0x5774, 0, 0, 0x5771, 0x744F,
0xBD60, 0xBD61, 0x5770, 0x4E78, 0xAC4B, 0x5772, 0, 0,
0x3632, 0xBD63, 0x3931, 0, 0xBD64, 0x3D7A, 0xBD65, 0xBD66,
- 0, 0x5779, 0x576B, 0, 0, 0, 0, 0x576F,
+ 0, 0x5779, 0x576B, 0, 0, 0xBD67, 0, 0x576F,
0x575F, 0xBD68, 0x327A, 0x5773, 0x5775, 0x4351, 0, 0xBD69,
0x3A28, 0x3238, 0x576D, 0x5778, 0x5777, 0x3633, 0, 0x4229,
0x3366, 0xBD6A, 0, 0, 0, 0x3743, 0, 0x576E,
@@ -6858,7 +6858,7 @@ static const unsigned short utf8_to_euc_E682[] = {
0x5829, 0, 0, 0xBE21, 0x4569, 0x582E, 0xBE22, 0,
};
static const unsigned short utf8_to_euc_E682_x0213[] = {
- 0, 0x577A, 0xBD6D, 0x577D, 0x5821, 0, 0xBD6E, 0,
+ 0, 0x577A, 0xBD6D, 0x577D, 0x5821, 0xF43F, 0xBD6E, 0,
0xBD6F, 0x3C3D, 0xAC4D, 0x5827, 0x4470, 0x577B, 0xBD71, 0,
0, 0xBD72, 0x5825, 0xBD73, 0x3279, 0xAC4E, 0x5823, 0x5824,
0xBD75, 0, 0x577E, 0x5822, 0, 0x7451, 0x7452, 0x3867,
@@ -6881,7 +6881,7 @@ static const unsigned short utf8_to_euc_E683_x0213[] = {
0, 0, 0xBE23, 0, 0xBE24, 0x3E70, 0x582F, 0x4657,
0xAC54, 0xBE26, 0xBE27, 0x7453, 0, 0, 0xBE29, 0xBE2A,
0, 0x4F47, 0, 0x582B, 0x7454, 0x7455, 0, 0,
- 0x5831, 0xAC55, 0x397B, 0xAC56, 0x404B, 0x7456, 0, 0x3054,
+ 0x5831, 0xAC55, 0x397B, 0xAC56, 0x404B, 0x7456, 0xBE30, 0x3054,
0x582A, 0x5828, 0xBE31, 0x415A, 0, 0xBE32, 0, 0x577C,
0x3B34, 0, 0, 0, 0, 0, 0xAC57, 0,
0x4246, 0x583D, 0xAC58, 0x415B, 0x5838, 0xAC59, 0x5835, 0x5836,
@@ -6900,9 +6900,9 @@ static const unsigned short utf8_to_euc_E684[] = {
static const unsigned short utf8_to_euc_E684_x0213[] = {
0x5837, 0x3D25, 0xBE38, 0x583A, 0, 0, 0x5834, 0xBE39,
0x4C7C, 0x4C7B, 0xBE3A, 0, 0xBE3B, 0x583E, 0x583F, 0x3055,
- 0xAC5A, 0, 0xAC5B, 0xAC5C, 0xBE40, 0x5833, 0xBE41, 0xBE42,
+ 0xAC5A, 0xBE3D, 0xAC5B, 0xAC5C, 0xBE40, 0x5833, 0xBE41, 0xBE42,
0, 0xAC5D, 0x3672, 0x3026, 0x7458, 0, 0xAC5E, 0x3436,
- 0, 0x583B, 0xBE46, 0, 0, 0, 0, 0x5843,
+ 0xF440, 0x583B, 0xBE46, 0, 0, 0, 0, 0x5843,
0x5842, 0, 0xBE47, 0x7459, 0x5847, 0, 0, 0,
0x745A, 0xBE4A, 0, 0, 0x5848, 0xBE4B, 0xBE4C, 0x745B,
0, 0xBE4E, 0xAC5F, 0, 0x5846, 0x5849, 0x5841, 0x5845,
@@ -6980,7 +6980,7 @@ static const unsigned short utf8_to_euc_E688[] = {
static const unsigned short utf8_to_euc_E688_x0213[] = {
0x5878, 0xBF24, 0, 0xBF25, 0xBF26, 0, 0, 0xBF27,
0x5879, 0x587A, 0x4A6A, 0, 0x587C, 0x587B, 0x3D3F, 0,
- 0x402E, 0x3266, 0x327C, 0, 0x587D, 0xAC73, 0x303F, 0,
+ 0x402E, 0x3266, 0x327C, 0xBF28, 0x587D, 0xAC73, 0x303F, 0,
0, 0, 0x404C, 0x587E, 0xBF2A, 0x6C43, 0x5921, 0x3761,
0xBF2B, 0x5922, 0x7462, 0xAC74, 0, 0, 0x406F, 0xBF2E,
0, 0xAC75, 0x5923, 0xBF30, 0, 0, 0x5924, 0x353A,
@@ -7239,7 +7239,7 @@ static const unsigned short utf8_to_euc_E695[] = {
};
static const unsigned short utf8_to_euc_E695_x0213[] = {
0, 0, 0, 0xC14A, 0xAD62, 0x384E, 0, 0xC14B,
- 0x5A43, 0xC14C, 0, 0, 0, 0x5A46, 0, 0x4952,
+ 0x5A43, 0xC14C, 0, 0, 0, 0x5A46, 0xF441, 0x4952,
0xC14D, 0x355F, 0xC14E, 0, 0xAD63, 0x5A45, 0x5A44, 0x4754,
0x5A47, 0x3635, 0, 0, 0, 0x5A49, 0x5A48, 0xC150,
0xC151, 0, 0x343A, 0x3B36, 0, 0, 0x4658, 0x7529,
@@ -7303,9 +7303,9 @@ static const unsigned short utf8_to_euc_E698_x0213[] = {
0, 0xC17A, 0xC17B, 0x3057, 0x404E, 0x752E, 0xC17D, 0,
0, 0, 0, 0, 0x5A66, 0xC17E, 0x752F, 0x4031,
0x3147, 0xAD77, 0x7531, 0xC224, 0x7532, 0x3D55, 0xC226, 0x4B66,
- 0x3A72, 0xC227, 0xAD78, 0x7533, 0xC22A, 0x3E3C, 0, 0x4027,
+ 0x3A72, 0xC227, 0xAD78, 0x7533, 0xC22A, 0x3E3C, 0xC22B, 0x4027,
0x7534, 0x7535, 0, 0x7536, 0x5A65, 0x5A63, 0x5A64, 0xC230,
- 0, 0xC22F, 0x7530, 0, 0x436B, 0, 0, 0x5B26,
+ 0, 0xC22F, 0x7530, 0xF442, 0x436B, 0, 0, 0x5B26,
};
static const unsigned short utf8_to_euc_E699[] = {
0xC231, 0x5A6A, 0x3B7E, 0x3938, 0x5A68, 0xC232, 0xC233, 0,
@@ -7379,7 +7379,7 @@ static const unsigned short utf8_to_euc_E69C[] = {
};
static const unsigned short utf8_to_euc_E69C_x0213[] = {
0x3A47, 0xAE37, 0, 0x5072, 0, 0xAE38, 0, 0xC26F,
- 0x376E, 0x4D2D, 0, 0x4A7E, 0, 0x497E, 0, 0x5B2C,
+ 0x376E, 0x4D2D, 0, 0x4A7E, 0, 0x497E, 0xC270, 0x5B2C,
0, 0, 0xAE39, 0x754D, 0x3A73, 0x443F, 0x5B2D, 0x4F2F,
0, 0xAE3B, 0, 0x4B3E, 0xC273, 0x442B, 0x5B2E, 0x347C,
0xC274, 0, 0xC275, 0, 0, 0, 0x5B2F, 0x5B30,
@@ -7682,7 +7682,7 @@ static const unsigned short utf8_to_euc_E6AB_x0213[] = {
0xC54D, 0xC54C, 0, 0, 0xC54E, 0, 0, 0,
0xAF66, 0x5D2A, 0, 0x4F26, 0xAF65, 0xC551, 0xC552, 0,
0, 0, 0x5D2D, 0x367B, 0xAF67, 0xAF68, 0x5D29, 0x5D2B,
- 0, 0, 0, 0, 0x7638, 0, 0, 0x7639,
+ 0, 0, 0xF44A, 0, 0x7638, 0, 0, 0x7639,
0x4827, 0, 0x5D2E, 0, 0xAF6B, 0, 0, 0,
0xC558, 0xAF6C, 0xAF6D, 0xAF6E, 0, 0, 0, 0,
0, 0, 0x5D32, 0x5D2F, 0xC55B, 0xAF6F, 0, 0,
@@ -7803,7 +7803,7 @@ static const unsigned short utf8_to_euc_E6B1_x0213[] = {
0x3C2E, 0, 0xC65C, 0, 0xC65D, 0x5D68, 0, 0x3440,
0, 0x7651, 0x3178, 0xEE37, 0x7652, 0x4672, 0x5D67, 0x393E,
0x4353, 0, 0x5D69, 0, 0, 0, 0, 0xEE4F,
- 0x5D71, 0, 0x5D6A, 0xC661, 0, 0xEE38, 0, 0,
+ 0x5D71, 0, 0x5D6A, 0xC661, 0, 0xEE38, 0, 0xC663,
0x4241, 0, 0x3562, 0x5D72, 0x7654, 0, 0x7655, 0,
0xC666, 0xC667, 0x3768, 0xC668, 0, 0x3525, 0x5D70, 0,
};
@@ -7883,7 +7883,7 @@ static const unsigned short utf8_to_euc_E6B5_x0213[] = {
0, 0, 0, 0, 0, 0, 0, 0xC73D,
0x7667, 0x5E36, 0x5E34, 0xEE52, 0x494D, 0, 0xEE53, 0xC73F,
0xEE54, 0xC740, 0, 0x5E31, 0x5E33, 0x7668, 0x313A, 0xC742,
- 0, 0x3940, 0x4F32, 0, 0x333D, 0, 0x4962, 0,
+ 0, 0x3940, 0x4F32, 0, 0x333D, 0, 0x4962, 0xC743,
0xEE55, 0, 0, 0, 0x4D61, 0, 0, 0x3324,
0x3F3B, 0x5E35, 0, 0, 0xC745, 0, 0, 0,
};
@@ -7900,7 +7900,7 @@ static const unsigned short utf8_to_euc_E6B6[] = {
static const unsigned short utf8_to_euc_E6B6_x0213[] = {
0xEE56, 0xEE57, 0x766A, 0, 0, 0x5E3A, 0, 0x766B,
0x3E43, 0x766C, 0xEE58, 0, 0x4D30, 0xEE59, 0x5E37, 0,
- 0, 0xEE5A, 0xC749, 0x5E32, 0x766D, 0x5E38, 0, 0xC74C,
+ 0, 0xEE5A, 0xC749, 0x5E32, 0x766D, 0x5E38, 0xC74B, 0xC74C,
0xEE5B, 0x4E5E, 0, 0x4573, 0x4642, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0x766E, 0xEE61, 0x766F, 0, 0xEE62, 0x3336,
@@ -7924,8 +7924,8 @@ static const unsigned short utf8_to_euc_E6B7_x0213[] = {
0x4571, 0x5E4A, 0x7673, 0x7674, 0, 0x7675, 0x5E44, 0xEE6A,
0xC75E, 0x4338, 0xC75F, 0, 0x5E4B, 0xC760, 0x5E40, 0,
0x5E46, 0xEE6B, 0x5E4D, 0x307C, 0x5E43, 0, 0x5E4E, 0xC762,
- 0xC763, 0x3F3C, 0, 0x3D5F, 0xC764, 0x4A25, 0xEE6C, 0x3A2E,
- 0, 0x5E3B, 0x5E49, 0x453A, 0x7676, 0, 0, 0,
+ 0xC763, 0x3F3C, 0xF44C, 0x3D5F, 0xC764, 0x4A25, 0xEE6C, 0x3A2E,
+ 0xF44B, 0x5E3B, 0x5E49, 0x453A, 0x7676, 0, 0, 0,
};
static const unsigned short utf8_to_euc_E6B8[] = {
0xC767, 0, 0, 0, 0xC768, 0x4036, 0, 0x3369,
@@ -7945,7 +7945,7 @@ static const unsigned short utf8_to_euc_E6B8_x0213[] = {
0x3574, 0x454F, 0xEE6F, 0x5E56, 0x5E5F, 0x302F, 0x3132, 0xEE70,
0, 0x3239, 0, 0x5E58, 0x422C, 0x5E4F, 0x5E51, 0x3941,
0, 0, 0xEE72, 0, 0x7678, 0, 0xEE6D, 0,
- 0x5E62, 0, 0x5E5D, 0xC76F, 0xEE73, 0, 0x5E55, 0,
+ 0x5E62, 0xC76E, 0x5E5D, 0xC76F, 0xEE73, 0, 0x5E55, 0,
};
static const unsigned short utf8_to_euc_E6B9[] = {
0, 0, 0, 0x5E5C, 0xC771, 0xC772, 0, 0,
@@ -8342,7 +8342,7 @@ static const unsigned short utf8_to_euc_E78C_x0213[] = {
0, 0, 0x6049, 0xCB26, 0, 0xCB27, 0, 0,
0, 0, 0xF046, 0xCB29, 0, 0, 0x604B, 0x6048,
0xF047, 0xF048, 0, 0x4C54, 0x604A, 0x604C, 0xCB2C, 0x4E44,
- 0, 0, 0xCB2D, 0, 0, 0x6050, 0, 0x776D,
+ 0, 0, 0xCB2D, 0, 0xCB2E, 0x6050, 0, 0x776D,
0x776E, 0x604F, 0x4376, 0x472D, 0xF04B, 0, 0x3825, 0x604E,
0, 0xF04C, 0xCB33, 0xF04D, 0x604D, 0xCB34, 0x4D31, 0x4D32,
0, 0xF04A, 0xCB35, 0xCB36, 0, 0xF04E, 0x6051, 0x316E,
@@ -8385,7 +8385,7 @@ static const unsigned short utf8_to_euc_E78E_x0213[] = {
0x7775, 0, 0x7776, 0, 0, 0xF05F, 0x7777, 0,
0xF060, 0x3461, 0xCB5F, 0x7778, 0, 0xCB61, 0, 0,
0, 0, 0x4E68, 0x605E, 0, 0xF061, 0, 0xF062,
- 0, 0xF063, 0, 0x6060, 0xF064, 0, 0, 0xF065,
+ 0, 0xF063, 0, 0x6060, 0xF064, 0xCB66, 0, 0xF065,
};
static const unsigned short utf8_to_euc_E78F[] = {
0x6061, 0, 0x3251, 0, 0, 0xCB68, 0xCB69, 0,
@@ -8400,11 +8400,11 @@ static const unsigned short utf8_to_euc_E78F[] = {
static const unsigned short utf8_to_euc_E78F_x0213[] = {
0x6061, 0, 0x3251, 0, 0, 0xF066, 0xCB69, 0,
0x605D, 0x7779, 0x3B39, 0xF067, 0xCB6C, 0x4441, 0x605F, 0x777A,
- 0, 0, 0, 0xCB6F, 0, 0, 0x777B, 0,
+ 0, 0, 0xCB6E, 0xCB6F, 0, 0, 0x777B, 0,
0, 0x777C, 0, 0, 0, 0xCB72, 0x6064, 0,
0x3C6E, 0xF068, 0, 0x777D, 0, 0x6062, 0xCB75, 0xF069,
0, 0x777E, 0x373E, 0, 0, 0x4849, 0x6063, 0,
- 0, 0x607E, 0, 0, 0xCB78, 0, 0, 0xCB7A,
+ 0, 0x607E, 0, 0, 0xCB78, 0xCB79, 0, 0xCB7A,
0x6069, 0xF06A, 0xF06C, 0xCB7D, 0, 0xCB7E, 0x383D, 0xCC21,
};
static const unsigned short utf8_to_euc_E790[] = {
@@ -8423,7 +8423,7 @@ static const unsigned short utf8_to_euc_E790_x0213[] = {
0, 0xCC27, 0, 0xF06B, 0, 0, 0, 0,
0, 0, 0x7823, 0x7824, 0, 0, 0, 0,
0, 0, 0x4276, 0, 0xF06E, 0x6068, 0x7826, 0,
- 0x7827, 0, 0x7828, 0x7829, 0x782A, 0xCC31, 0x782B, 0x782C,
+ 0x7827, 0xCC2D, 0x7828, 0x7829, 0x782A, 0xCC31, 0x782B, 0x782C,
0x782D, 0xF06F, 0x606A, 0x4E56, 0x3657, 0x487C, 0x474A, 0,
0, 0xF070, 0x606B, 0, 0, 0, 0, 0x606D,
};
@@ -8618,7 +8618,7 @@ static const unsigned short utf8_to_euc_E79A[] = {
0x6230, 0x6231, 0x6232, 0, 0, 0xCE48, 0, 0x3B2E,
};
static const unsigned short utf8_to_euc_E79A_x0213[] = {
- 0x6225, 0x7860, 0, 0x6226, 0x452A, 0xCE36, 0x3327, 0x3944,
+ 0x6225, 0x7860, 0xF451, 0x6226, 0x452A, 0xCE36, 0x3327, 0x3944,
0x6227, 0, 0, 0x6228, 0xCE37, 0xCE38, 0x6229, 0,
0x3B29, 0, 0, 0x622B, 0, 0xF16E, 0x622A, 0,
0, 0x622C, 0x622D, 0x7861, 0xF16F, 0x7862, 0x7863, 0xCE3D,
@@ -8765,7 +8765,7 @@ static const unsigned short utf8_to_euc_E7A1_x0213[] = {
0xCF66, 0xCF67, 0, 0xCF68, 0xF246, 0, 0, 0,
0x7925, 0, 0xF247, 0x4E32, 0x3945, 0, 0x7926, 0x3827,
0, 0, 0x4823, 0, 0x626D, 0, 0, 0,
- 0, 0, 0, 0, 0x626F, 0, 0xCF6E, 0,
+ 0, 0, 0xCF6D, 0, 0x626F, 0, 0xCF6E, 0,
};
static const unsigned short utf8_to_euc_E7A2[] = {
0, 0x386B, 0, 0, 0, 0, 0x626E, 0x4476,
@@ -9322,7 +9322,7 @@ static const unsigned short utf8_to_euc_E7BE_x0213[] = {
0x6633, 0, 0x4D53, 0xD526, 0x6635, 0xD527, 0x487E, 0xD528,
0xF473, 0x7A3B, 0, 0, 0x6636, 0, 0xF476, 0x7A3C,
0, 0, 0x6639, 0, 0xF477, 0x6638, 0x6637, 0,
- 0, 0, 0xD52F, 0x663A, 0x3732, 0, 0xD530, 0,
+ 0, 0xD52E, 0xD52F, 0x663A, 0x3732, 0, 0xD530, 0,
0x4122, 0x3541, 0xD531, 0, 0, 0xF478, 0x663E, 0x663B,
0, 0, 0x663C, 0, 0xD533, 0, 0x663F, 0,
0x6640, 0x663D, 0, 0, 0xD534, 0x3129, 0, 0x7A3D,
@@ -9664,7 +9664,7 @@ static const unsigned short utf8_to_euc_E88F_x0213[] = {
0x6845, 0, 0, 0, 0x3A5A, 0xF63E, 0, 0x4551,
0x684A, 0x7B22, 0, 0, 0, 0xF63F, 0, 0,
0xD83F, 0x4A6E, 0x7B23, 0x6841, 0, 0, 0, 0x325A,
- 0x3856, 0x4929, 0x684B, 0, 0x683F, 0, 0, 0x6848,
+ 0x3856, 0x4929, 0x684B, 0, 0x683F, 0, 0xD841, 0x6848,
0xD842, 0xF640, 0, 0x6852, 0xD844, 0x6843, 0, 0,
};
static const unsigned short utf8_to_euc_E890[] = {
@@ -9783,7 +9783,7 @@ static const unsigned short utf8_to_euc_E895_x0213[] = {
0xD943, 0xF670, 0xD945, 0xF671, 0, 0x6924, 0xD947, 0x4979,
0x687D, 0x7B38, 0x6856, 0, 0xD949, 0xD94A, 0xF672, 0xD94C,
0xD94D, 0xF673, 0xF674, 0x687C, 0x7B39, 0, 0, 0,
- 0x4F4F, 0x4622, 0x4973, 0, 0, 0x692B, 0, 0xF66C,
+ 0x4F4F, 0x4622, 0x4973, 0xD951, 0, 0x692B, 0, 0xF66C,
0, 0, 0, 0, 0, 0, 0, 0x6931,
0, 0xD953, 0x7B3C, 0xF676, 0, 0xF677, 0x6932, 0xF678,
};
@@ -9998,7 +9998,7 @@ static const unsigned short utf8_to_euc_E8A0[] = {
0, 0x6A45, 0xDC21, 0x6A47, 0xDC22, 0, 0, 0,
};
static const unsigned short utf8_to_euc_E8A0_x0213[] = {
- 0, 0xF77A, 0, 0xF77B, 0, 0x6A24, 0x7B63, 0,
+ 0, 0xF77A, 0, 0xF77B, 0, 0x6A24, 0x7B63, 0xF464,
0, 0xDB6B, 0x7B64, 0xF77C, 0, 0x6A38, 0x6A3C, 0x6A37,
0x7B65, 0x6A3E, 0xDB70, 0xF77D, 0x7B66, 0x6A40, 0x6A3F, 0,
0xDB73, 0xDB6F, 0xDB74, 0xDB75, 0xDB76, 0, 0xDB77, 0x7B67,
@@ -10260,7 +10260,7 @@ static const unsigned short utf8_to_euc_E8AD[] = {
static const unsigned short utf8_to_euc_E8AD_x0213[] = {
0, 0x6B76, 0xDE44, 0xF86A, 0xDE46, 0xDE47, 0x7C31, 0,
0xDE49, 0x6B7A, 0, 0, 0x6B77, 0xDE4E, 0x6B79, 0x6B78,
- 0, 0xF86C, 0xDE4A, 0, 0x7C32, 0, 0x6B7B, 0,
+ 0, 0xF86C, 0xDE4A, 0xDE4B, 0x7C32, 0, 0x6B7B, 0,
0x3C31, 0x7C33, 0x6B7D, 0x6B7C, 0x4968, 0, 0xF86D, 0x6C21,
0, 0, 0, 0xDE50, 0, 0, 0x3759, 0,
0, 0x7C34, 0, 0x6B7E, 0x6C22, 0xDE51, 0, 0x6C23,
@@ -10404,7 +10404,7 @@ static const unsigned short utf8_to_euc_E8B5_x0213[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0x4056, 0xDF46, 0x3C4F, 0x6C5F,
0, 0xDF47, 0, 0x3352, 0xF935, 0x6C60, 0xDF49, 0,
- 0x4176, 0x6C61, 0, 0x6C62, 0x496B, 0, 0, 0x352F,
+ 0x4176, 0x6C61, 0, 0x6C62, 0x496B, 0, 0xF468, 0x352F,
0, 0, 0, 0, 0, 0, 0, 0xDF4A,
};
static const unsigned short utf8_to_euc_E8B6[] = {
@@ -10519,7 +10519,7 @@ static const unsigned short utf8_to_euc_E8BB[] = {
};
static const unsigned short utf8_to_euc_E8BB_x0213[] = {
0x7C4A, 0xE055, 0, 0xE056, 0xE057, 0x6D40, 0x6D3D, 0xE058,
- 0x6D41, 0, 0x3C56, 0x6D42, 0x3530, 0x3733, 0, 0,
+ 0x6D41, 0, 0x3C56, 0x6D42, 0x3530, 0x3733, 0, 0xE059,
0, 0xF95A, 0x382E, 0, 0xF95B, 0, 0, 0,
0, 0, 0, 0x6D43, 0xE05C, 0, 0, 0x4670,
0, 0, 0x453E, 0x6D44, 0, 0, 0, 0,
@@ -10642,7 +10642,7 @@ static const unsigned short utf8_to_euc_E981_x0213[] = {
0, 0x6E26, 0x4D37, 0x313F, 0xE15D, 0x4A57, 0x3261, 0x6E21,
0x6E22, 0x6E23, 0x6E24, 0x463B, 0x4323, 0x3063, 0x6E28, 0,
0x6E29, 0x7423, 0, 0xE15E, 0x423D, 0xF97D, 0x6E2A, 0,
- 0x3173, 0x414C, 0xE160, 0x382F, 0, 0x4D5A, 0xE161, 0,
+ 0x3173, 0x414C, 0xE160, 0x382F, 0, 0x4D5A, 0xE161, 0xE162,
0x6E2B, 0x452C, 0, 0, 0xE163, 0x4178, 0x3C57, 0x6E2C,
0xE164, 0, 0x6E2F, 0, 0xE165, 0x3D65, 0x6E2D, 0x412B,
0x412A, 0xE166, 0x3064, 0, 0x4E4B, 0x6E31, 0, 0x4872,
@@ -10761,7 +10761,7 @@ static const unsigned short utf8_to_euc_E987_x0213[] = {
0x6E56, 0x6E57, 0xE321, 0xFA4C, 0xFA4D, 0xE323, 0x4850, 0x3A53,
0x3C61, 0x6E58, 0, 0x6E59, 0x4E24, 0x3D45, 0x4C6E, 0x4E4C,
0x6E5A, 0x3662, 0, 0xE324, 0xE325, 0, 0x6E5B, 0x7C7C,
- 0x4523, 0xE327, 0xFA4E, 0x6E5E, 0x3378, 0x3F4B, 0, 0x6E5C,
+ 0x4523, 0xE327, 0xFA4E, 0x6E5E, 0x3378, 0x3F4B, 0xE329, 0x6E5C,
0, 0x6E5D, 0, 0x4460, 0x7C7E, 0x7D21, 0x4B55, 0x367C,
0, 0xE32C, 0xE32D, 0, 0xFA51, 0x7D22, 0xFA52, 0xE331,
0xE332, 0x7D23, 0, 0, 0, 0x6E60, 0x6E61, 0xE334,
@@ -10778,7 +10778,7 @@ static const unsigned short utf8_to_euc_E988[] = {
0xE353, 0xE354, 0xE355, 0, 0xE356, 0, 0xE357, 0x6E6F,
};
static const unsigned short utf8_to_euc_E988_x0213[] = {
- 0xE338, 0xFA53, 0, 0, 0xE33A, 0xE33B, 0, 0x7D24,
+ 0xE338, 0xFA53, 0, 0, 0xE33A, 0xE33B, 0xE33C, 0x7D24,
0, 0xE33E, 0xFA54, 0, 0xE340, 0x465F, 0x3343, 0,
0x7D25, 0x6E67, 0xE342, 0xE343, 0x6E64, 0x6E66, 0xFA55, 0xFA56,
0xE345, 0, 0, 0, 0xE346, 0xE347, 0x6E62, 0,
@@ -10804,7 +10804,7 @@ static const unsigned short utf8_to_euc_E989_x0213[] = {
0xE362, 0xFA5F, 0x6E76, 0x3174, 0xE364, 0xE365, 0x6E68, 0,
0xFA60, 0xFA61, 0x482D, 0, 0x6E6C, 0xFA62, 0x3E60, 0xFA63,
0xFA64, 0xE36B, 0, 0, 0, 0, 0xE36C, 0xE36D,
- 0xE36E, 0x395B, 0, 0, 0, 0xE36F, 0xE370, 0,
+ 0xE36E, 0x395B, 0, 0, 0, 0xE36F, 0xE370, 0xE371,
0x7D2D, 0xE373, 0, 0xE374, 0xFA67, 0xFA68, 0x4B48, 0xFA69,
};
static const unsigned short utf8_to_euc_E98A[] = {
@@ -10840,7 +10840,7 @@ static const unsigned short utf8_to_euc_E98B[] = {
static const unsigned short utf8_to_euc_E98B_x0213[] = {
0xFA75, 0xE433, 0x7D2F, 0xE435, 0, 0xE436, 0xFA76, 0xE438,
0xE439, 0, 0, 0x7D30, 0x7D31, 0xE43C, 0xFA77, 0x6E77,
- 0xFA78, 0, 0x4B2F, 0x7D32, 0, 0, 0, 0xFA79,
+ 0xFA78, 0, 0x4B2F, 0x7D32, 0, 0xE440, 0, 0xFA79,
0xE442, 0xFA7A, 0, 0, 0xE444, 0xE445, 0, 0xE446,
0x7D33, 0xE448, 0, 0xE449, 0x3D7B, 0xFA7B, 0, 0xFA7C,
0xE44C, 0x6E7A, 0x4A5F, 0, 0xE44D, 0x3154, 0xE44E, 0,
@@ -10902,7 +10902,7 @@ static const unsigned short utf8_to_euc_E98E_x0213[] = {
0xFB38, 0, 0xE528, 0xFB39, 0x3379, 0xE52A, 0, 0xFB3A,
0, 0, 0xE52C, 0, 0x6F30, 0xE52D, 0x3A3F, 0x4179,
0xE52E, 0, 0x444A, 0x7D40, 0, 0, 0xFB3B, 0,
- 0, 0xFB35, 0, 0x7D41, 0, 0, 0xE534, 0x333B,
+ 0, 0xFB35, 0, 0x7D41, 0xE533, 0, 0xE534, 0x333B,
0xE535, 0xE53B, 0, 0xE536, 0x6F2E, 0x6F2F, 0x4443, 0,
0x6F2D, 0, 0, 0, 0xE537, 0xE538, 0xE539, 0,
0, 0x6F31, 0x7D42, 0, 0, 0, 0, 0,
@@ -10925,7 +10925,7 @@ static const unsigned short utf8_to_euc_E98F_x0213[] = {
0, 0x3640, 0xFB43, 0, 0x6F3B, 0x6F35, 0xE54C, 0xFB44,
0x6F34, 0, 0, 0, 0, 0, 0, 0,
0, 0xFB3F, 0, 0, 0, 0xFB3C, 0, 0xE54F,
- 0, 0xE54E, 0xE551, 0xFB49, 0, 0x7D47, 0, 0,
+ 0xE550, 0xE54E, 0xE551, 0xFB49, 0, 0x7D47, 0, 0,
};
static const unsigned short utf8_to_euc_E990[] = {
0, 0xE554, 0xE555, 0x6F3F, 0xE556, 0, 0, 0x6F40,
@@ -10944,7 +10944,7 @@ static const unsigned short utf8_to_euc_E990_x0213[] = {
0x3E62, 0x462A, 0x6F3C, 0, 0, 0, 0, 0xE55F,
0, 0x6F45, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0x6F43, 0, 0, 0xE560, 0xE561,
- 0, 0, 0xFB4A, 0x7D48, 0xFB4B, 0x6F44, 0x6F42, 0,
+ 0, 0xE562, 0xFB4A, 0x7D48, 0xFB4B, 0x6F44, 0x6F42, 0,
0x4278, 0, 0x6F46, 0xFB4C, 0, 0xE568, 0, 0xE567,
};
static const unsigned short utf8_to_euc_E991[] = {
@@ -10959,7 +10959,7 @@ static const unsigned short utf8_to_euc_E991[] = {
};
static const unsigned short utf8_to_euc_E991_x0213[] = {
0, 0x6F47, 0, 0xE569, 0x6F49, 0xFB4D, 0, 0,
- 0, 0, 0x7D49, 0, 0xE56D, 0, 0, 0,
+ 0xE56B, 0, 0x7D49, 0, 0xE56D, 0, 0, 0,
0, 0x3455, 0x6F48, 0x4C7A, 0, 0xE56E, 0, 0,
0, 0xE56F, 0x6F54, 0x6F4A, 0xE570, 0, 0x6F4D, 0xE571,
0x6F4B, 0xE572, 0x6F4C, 0x7D4A, 0, 0, 0, 0,
@@ -11010,7 +11010,7 @@ static const unsigned short utf8_to_euc_E996[] = {
static const unsigned short utf8_to_euc_E996_x0213[] = {
0x4C67, 0, 0x6F59, 0x412E, 0xE622, 0, 0xFB54, 0x6F5A,
0xE623, 0x4A44, 0x6F5B, 0x332B, 0xFB55, 0xFB56, 0x7D4E, 0x313C,
- 0, 0x3457, 0, 0x3456, 0x6F5C, 0, 0x6F5D, 0,
+ 0, 0x3457, 0xF471, 0x3456, 0x6F5C, 0, 0x6F5D, 0,
0x6F5E, 0x6F5F, 0, 0, 0, 0xE627, 0xE628, 0x7D4F,
0x6F60, 0xE62A, 0x3458, 0x3355, 0x395E, 0x4836, 0x7D50, 0x6F62,
0x6F61, 0x7D51, 0, 0xFB58, 0x7D52, 0x6F63, 0, 0,
@@ -11148,9 +11148,9 @@ static const unsigned short utf8_to_euc_E99D[] = {
0xE73E, 0x7058, 0x705C, 0xE73F, 0x705A, 0xE740, 0, 0xE741,
};
static const unsigned short utf8_to_euc_E99D_x0213[] = {
- 0, 0xFB7A, 0x704E, 0, 0x704B, 0, 0x704C, 0xFB7B,
+ 0, 0xFB7A, 0x704E, 0xE72E, 0x704B, 0, 0x704C, 0xFB7B,
0x704D, 0x704F, 0xE72F, 0, 0, 0x7D68, 0x7D69, 0x7D6A,
- 0, 0, 0x4044, 0, 0, 0xFB7C, 0x4C77, 0xFB7D,
+ 0, 0xF476, 0x4044, 0, 0, 0xFB7C, 0x4C77, 0xFB7D,
0xE734, 0x4045, 0x7D6B, 0xFB7E, 0x7050, 0, 0x4873, 0,
0x7051, 0x7353, 0x4C4C, 0xE737, 0x7052, 0, 0x7053, 0xE738,
0x7054, 0x3357, 0xFC21, 0x7056, 0, 0x3F59, 0x7D6C, 0,
@@ -11292,7 +11292,7 @@ static const unsigned short utf8_to_euc_E9A4_x0213[] = {
0xFC54, 0x712E, 0x4D5C, 0, 0x3142, 0, 0, 0,
0x3B41, 0xE853, 0x712F, 0x326E, 0x7130, 0xE854, 0xFC57, 0xFC58,
0x7131, 0, 0xFC5A, 0xFC5B, 0xFC5C, 0x7133, 0x7134, 0xE85A,
- 0x7136, 0x7132, 0xE85B, 0, 0x7135, 0, 0xE85C, 0,
+ 0x7136, 0x7132, 0xE85B, 0, 0x7135, 0, 0xE85C, 0xE85D,
0x345B, 0, 0, 0xE85E, 0x7137, 0, 0x7138, 0,
0, 0xFC5E, 0xFC5F, 0xFC60, 0xE862, 0xE863, 0, 0,
0, 0xE864, 0xFC61, 0xFC62, 0xFC63, 0x7139, 0x713A, 0,
@@ -11431,7 +11431,7 @@ static const unsigned short utf8_to_euc_E9AB_x0213[] = {
0x716F, 0x7E36, 0, 0x7E37, 0x3F71, 0, 0xFD2D, 0,
0xE965, 0, 0, 0, 0, 0, 0x7E38, 0x7170,
0xFD2E, 0x7171, 0xFD2F, 0x7172, 0x7173, 0xFD30, 0x7E39, 0xE96B,
- 0x3962, 0, 0, 0xE96C, 0xFD32, 0, 0x7174, 0x7175,
+ 0x3962, 0xF47B, 0, 0xE96C, 0xFD32, 0, 0x7174, 0x7175,
0xFD33, 0, 0x7176, 0x7177, 0xE96F, 0xFD34, 0x7178, 0xE971,
0, 0xFD35, 0x4831, 0x717A, 0xE973, 0x4926, 0x717B, 0x7179,
0, 0x717D, 0xE974, 0xE975, 0x717C, 0xE976, 0, 0x717E,
@@ -11495,7 +11495,7 @@ static const unsigned short utf8_to_euc_E9AE_x0213[] = {
0x723E, 0, 0, 0, 0, 0, 0xFD48, 0x7E49,
0x723F, 0xEA63, 0x4B6E, 0x3B2D, 0xFD49, 0x3A7A, 0x412F, 0,
0xEA65, 0xFD4A, 0xFD4D, 0, 0x7240, 0, 0, 0xEA68,
- 0xFD4E, 0x7243, 0, 0, 0xEA6B, 0, 0xFD4F, 0xEA6D,
+ 0xFD4E, 0x7243, 0, 0xEA6A, 0xEA6B, 0, 0xFD4F, 0xEA6D,
};
static const unsigned short utf8_to_euc_E9AF[] = {
0x7241, 0xEA6E, 0, 0, 0, 0, 0x7244, 0xEA6F,
@@ -11859,11 +11859,11 @@ static const unsigned short utf8_to_euc_EFA8[] = {
};
static const unsigned short utf8_to_euc_EFA8_x0213[] = {
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x2F4B,
- 0x2F57, 0x4F72, 0, 0xAE79, 0x757A, 0x775A, 0x776F, 0,
- 0, 0x793C, 0x793D, 0x7941, 0, 0, 0, 0x7B3A,
- 0xF738, 0xF745, 0x7C2E, 0, 0xF96E, 0, 0x7C6A, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF434, 0x2F4B,
+ 0x2F57, 0x4F72, 0xF444, 0xAE79, 0x757A, 0x775A, 0x776F, 0xF453,
+ 0xF455, 0x793C, 0x793D, 0x7941, 0xF45A, 0xF45B, 0xF45E, 0x7B3A,
+ 0xF738, 0xF745, 0x7C2E, 0xF469, 0xF96E, 0xF46B, 0x7C6A, 0xF46F,
+ 0xF470, 0xF473, 0xF477, 0xF478, 0xF479, 0xF47D, 0, 0,
0x2E38, 0x2E49, 0x2E50, 0x2E63, 0x2E68, 0x2E6E, 0x2F2C, 0x2F2F,
0x2F36, 0x2F5A, 0x2F5E, 0x4F61, 0x4F62, 0x7450, 0x745C, 0x745E,
};
@@ -11957,16 +11957,6 @@ static const unsigned short utf8_to_euc_EFBF[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
-static const unsigned short utf8_to_euc_EFBF_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2131, 0, 0x216F, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
static const unsigned short *const utf8_to_euc_E1_x0213[] = {
0, 0, 0, 0,
0, 0, 0, 0,
@@ -12415,7 +12405,7 @@ static const unsigned short *const utf8_to_euc_EF_x0213[] = {
0, 0, 0, 0,
0, 0, 0, 0,
0, utf8_to_euc_EFB9_x0213, 0, 0,
- utf8_to_euc_EFBC_x0213, utf8_to_euc_EFBD_x0213, utf8_to_euc_EFBE, utf8_to_euc_EFBF_x0213,
+ utf8_to_euc_EFBC_x0213, utf8_to_euc_EFBD_x0213, utf8_to_euc_EFBE, utf8_to_euc_EFBF,
};
const unsigned short *const utf8_to_euc_2bytes[] = {
0, 0, 0, 0,
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 37717e4799..c958c91753 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -168,6 +168,7 @@ rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
/* use _result_ end */
rb_str_set_len(tmp, output_ctr);
+ OBJ_INFECT(tmp, src);
if (mimeout_f)
rb_enc_associate(tmp, rb_usascii_encoding());
diff --git a/ext/objspace/depend b/ext/objspace/depend
index 18be4fe8a8..642265618c 100644
--- a/ext/objspace/depend
+++ b/ext/objspace/depend
@@ -1,23 +1,24 @@
# AUTOGENERATED DEPENDENCIES START
object_tracing.o: $(RUBY_EXTCONF_H)
object_tracing.o: $(arch_hdrdir)/ruby/config.h
-object_tracing.o: $(hdrdir)/ruby.h
-object_tracing.o: $(hdrdir)/ruby/assert.h
object_tracing.o: $(hdrdir)/ruby/backward.h
object_tracing.o: $(hdrdir)/ruby/debug.h
object_tracing.o: $(hdrdir)/ruby/defines.h
+object_tracing.o: $(hdrdir)/ruby/encoding.h
object_tracing.o: $(hdrdir)/ruby/intern.h
+object_tracing.o: $(hdrdir)/ruby/io.h
object_tracing.o: $(hdrdir)/ruby/missing.h
+object_tracing.o: $(hdrdir)/ruby/onigmo.h
+object_tracing.o: $(hdrdir)/ruby/oniguruma.h
object_tracing.o: $(hdrdir)/ruby/ruby.h
object_tracing.o: $(hdrdir)/ruby/st.h
object_tracing.o: $(hdrdir)/ruby/subst.h
+object_tracing.o: $(top_srcdir)/include/ruby.h
object_tracing.o: $(top_srcdir)/internal.h
object_tracing.o: object_tracing.c
object_tracing.o: objspace.h
objspace.o: $(RUBY_EXTCONF_H)
objspace.o: $(arch_hdrdir)/ruby/config.h
-objspace.o: $(hdrdir)/ruby.h
-objspace.o: $(hdrdir)/ruby/assert.h
objspace.o: $(hdrdir)/ruby/backward.h
objspace.o: $(hdrdir)/ruby/defines.h
objspace.o: $(hdrdir)/ruby/encoding.h
@@ -32,6 +33,7 @@ objspace.o: $(hdrdir)/ruby/ruby.h
objspace.o: $(hdrdir)/ruby/st.h
objspace.o: $(hdrdir)/ruby/subst.h
objspace.o: $(top_srcdir)/gc.h
+objspace.o: $(top_srcdir)/include/ruby.h
objspace.o: $(top_srcdir)/internal.h
objspace.o: $(top_srcdir)/node.h
objspace.o: $(top_srcdir)/symbol.h
@@ -39,8 +41,6 @@ objspace.o: objspace.c
objspace.o: {$(VPATH)}id.h
objspace_dump.o: $(RUBY_EXTCONF_H)
objspace_dump.o: $(arch_hdrdir)/ruby/config.h
-objspace_dump.o: $(hdrdir)/ruby.h
-objspace_dump.o: $(hdrdir)/ruby/assert.h
objspace_dump.o: $(hdrdir)/ruby/backward.h
objspace_dump.o: $(hdrdir)/ruby/debug.h
objspace_dump.o: $(hdrdir)/ruby/defines.h
@@ -59,6 +59,7 @@ objspace_dump.o: $(top_srcdir)/ccan/container_of/container_of.h
objspace_dump.o: $(top_srcdir)/ccan/list/list.h
objspace_dump.o: $(top_srcdir)/ccan/str/str.h
objspace_dump.o: $(top_srcdir)/gc.h
+objspace_dump.o: $(top_srcdir)/include/ruby.h
objspace_dump.o: $(top_srcdir)/internal.h
objspace_dump.o: $(top_srcdir)/method.h
objspace_dump.o: $(top_srcdir)/node.h
@@ -66,6 +67,7 @@ objspace_dump.o: $(top_srcdir)/ruby_assert.h
objspace_dump.o: $(top_srcdir)/ruby_atomic.h
objspace_dump.o: $(top_srcdir)/thread_pthread.h
objspace_dump.o: $(top_srcdir)/vm_core.h
+objspace_dump.o: $(top_srcdir)/vm_debug.h
objspace_dump.o: $(top_srcdir)/vm_opts.h
objspace_dump.o: objspace.h
objspace_dump.o: objspace_dump.c
diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c
index a057ac2a96..611d059b9e 100644
--- a/ext/objspace/object_tracing.c
+++ b/ext/objspace/object_tracing.c
@@ -39,8 +39,7 @@ make_unique_str(st_table *tbl, const char *str, long len)
if (st_lookup(tbl, (st_data_t)str, &n)) {
st_insert(tbl, (st_data_t)str, n+1);
- st_get_key(tbl, (st_data_t)str, &n);
- result = (char *)n;
+ st_get_key(tbl, (st_data_t)str, (st_data_t *)&result);
}
else {
result = (char *)ruby_xmalloc(len+1);
@@ -60,9 +59,8 @@ delete_unique_str(st_table *tbl, const char *str)
st_lookup(tbl, (st_data_t)str, &n);
if (n == 1) {
- n = (st_data_t)str;
- st_delete(tbl, &n, 0);
- ruby_xfree((char *)n);
+ st_delete(tbl, (st_data_t *)&str, 0);
+ ruby_xfree((char *)str);
}
else {
st_insert(tbl, (st_data_t)str, n-1);
@@ -84,10 +82,8 @@ newobj_i(VALUE tpval, void *data)
const char *path_cstr = RTEST(path) ? make_unique_str(arg->str_table, RSTRING_PTR(path), RSTRING_LEN(path)) : 0;
VALUE class_path = (RTEST(klass) && !OBJ_FROZEN(klass)) ? rb_class_path_cached(klass) : Qnil;
const char *class_path_cstr = RTEST(class_path) ? make_unique_str(arg->str_table, RSTRING_PTR(class_path), RSTRING_LEN(class_path)) : 0;
- st_data_t v;
- if (st_lookup(arg->object_table, (st_data_t)obj, &v)) {
- info = (struct allocation_info *)v;
+ if (st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) {
if (arg->keep_remains) {
if (info->living) {
/* do nothing. there is possibility to keep living if FREEOBJ events while suppressing tracing */
@@ -117,19 +113,15 @@ freeobj_i(VALUE tpval, void *data)
{
struct traceobj_arg *arg = (struct traceobj_arg *)data;
rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
- st_data_t obj = (st_data_t)rb_tracearg_object(tparg);
- st_data_t v;
+ VALUE obj = rb_tracearg_object(tparg);
struct allocation_info *info;
- if (arg->keep_remains) {
- if (st_lookup(arg->object_table, obj, &v)) {
- info = (struct allocation_info *)v;
+ if (st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) {
+ if (arg->keep_remains) {
info->living = 0;
}
- }
- else {
- if (st_delete(arg->object_table, &obj, &v)) {
- info = (struct allocation_info *)v;
+ else {
+ st_delete(arg->object_table, (st_data_t *)&obj, (st_data_t *)&info);
delete_unique_str(arg->str_table, info->path);
delete_unique_str(arg->str_table, info->class_path);
ruby_xfree(info);
@@ -138,14 +130,14 @@ freeobj_i(VALUE tpval, void *data)
}
static int
-free_keys_i(st_data_t key, st_data_t value, st_data_t data)
+free_keys_i(st_data_t key, st_data_t value, void *data)
{
ruby_xfree((void *)key);
return ST_CONTINUE;
}
static int
-free_values_i(st_data_t key, st_data_t value, st_data_t data)
+free_values_i(st_data_t key, st_data_t value, void *data)
{
ruby_xfree((void *)value);
return ST_CONTINUE;
@@ -186,9 +178,7 @@ trace_object_allocations_start(VALUE self)
else {
if (arg->newobj_trace == 0) {
arg->newobj_trace = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ, newobj_i, arg);
- rb_gc_register_mark_object(arg->newobj_trace);
arg->freeobj_trace = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_FREEOBJ, freeobj_i, arg);
- rb_gc_register_mark_object(arg->freeobj_trace);
}
rb_tracepoint_enable(arg->newobj_trace);
rb_tracepoint_enable(arg->freeobj_trace);
@@ -218,6 +208,8 @@ trace_object_allocations_stop(VALUE self)
if (arg->running == 0) {
rb_tracepoint_disable(arg->newobj_trace);
rb_tracepoint_disable(arg->freeobj_trace);
+ arg->newobj_trace = 0;
+ arg->freeobj_trace = 0;
}
return Qnil;
@@ -329,9 +321,9 @@ static struct allocation_info *
lookup_allocation_info(VALUE obj)
{
if (tmp_trace_arg) {
- st_data_t info;
- if (st_lookup(tmp_trace_arg->object_table, obj, &info)) {
- return (struct allocation_info *)info;
+ struct allocation_info *info;
+ if (st_lookup(tmp_trace_arg->object_table, obj, (st_data_t *)&info)) {
+ return info;
}
}
return NULL;
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index 311e687206..d5e86353f1 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -12,9 +12,9 @@
**********************************************************************/
-#include <ruby/io.h>
#include "internal.h"
#include <ruby/st.h>
+#include <ruby/io.h>
#include <ruby/re.h>
#include "node.h"
#include "gc.h"
@@ -188,7 +188,6 @@ type2sym(enum ruby_value_type i)
CASE_TYPE(T_IMEMO);
CASE_TYPE(T_NODE);
CASE_TYPE(T_ICLASS);
- CASE_TYPE(T_MOVED);
CASE_TYPE(T_ZOMBIE);
#undef CASE_TYPE
default: rb_bug("type2sym: unknown type (%d)", i);
@@ -378,14 +377,11 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_UNLESS);
COUNT_NODE(NODE_CASE);
COUNT_NODE(NODE_CASE2);
- COUNT_NODE(NODE_CASE3);
COUNT_NODE(NODE_WHEN);
- COUNT_NODE(NODE_IN);
COUNT_NODE(NODE_WHILE);
COUNT_NODE(NODE_UNTIL);
COUNT_NODE(NODE_ITER);
COUNT_NODE(NODE_FOR);
- COUNT_NODE(NODE_FOR_MASGN);
COUNT_NODE(NODE_BREAK);
COUNT_NODE(NODE_NEXT);
COUNT_NODE(NODE_REDO);
@@ -416,8 +412,8 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_QCALL);
COUNT_NODE(NODE_SUPER);
COUNT_NODE(NODE_ZSUPER);
- COUNT_NODE(NODE_LIST);
- COUNT_NODE(NODE_ZLIST);
+ COUNT_NODE(NODE_ARRAY);
+ COUNT_NODE(NODE_ZARRAY);
COUNT_NODE(NODE_VALUES);
COUNT_NODE(NODE_HASH);
COUNT_NODE(NODE_RETURN);
@@ -440,7 +436,6 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_DXSTR);
COUNT_NODE(NODE_EVSTR);
COUNT_NODE(NODE_DREGX);
- COUNT_NODE(NODE_ONCE);
COUNT_NODE(NODE_ARGS);
COUNT_NODE(NODE_ARGS_AUX);
COUNT_NODE(NODE_OPT_ARG);
@@ -473,9 +468,8 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_POSTEXE);
COUNT_NODE(NODE_DSYM);
COUNT_NODE(NODE_ATTRASGN);
+ COUNT_NODE(NODE_PRELUDE);
COUNT_NODE(NODE_LAMBDA);
- COUNT_NODE(NODE_ARYPTN);
- COUNT_NODE(NODE_HSHPTN);
#undef COUNT_NODE
case NODE_LAST: break;
}
@@ -622,7 +616,7 @@ count_imemo_objects(int argc, VALUE *argv, VALUE self)
VALUE hash = setup_hash(argc, argv);
if (imemo_type_ids[0] == 0) {
- imemo_type_ids[0] = rb_intern("imemo_env");
+ imemo_type_ids[0] = rb_intern("imemo_none");
imemo_type_ids[1] = rb_intern("imemo_cref");
imemo_type_ids[2] = rb_intern("imemo_svar");
imemo_type_ids[3] = rb_intern("imemo_throw_data");
@@ -630,9 +624,8 @@ count_imemo_objects(int argc, VALUE *argv, VALUE self)
imemo_type_ids[5] = rb_intern("imemo_memo");
imemo_type_ids[6] = rb_intern("imemo_ment");
imemo_type_ids[7] = rb_intern("imemo_iseq");
- imemo_type_ids[8] = rb_intern("imemo_tmpbuf");
- imemo_type_ids[9] = rb_intern("imemo_ast");
- imemo_type_ids[10] = rb_intern("imemo_parser_strterm");
+ imemo_type_ids[8] = rb_intern("imemo_alloc");
+ imemo_type_ids[9] = rb_intern("imemo_parser_strterm");
}
rb_objspace_each_objects(count_imemo_objects_i, (void *)hash);
@@ -830,7 +823,7 @@ static int
collect_values_of_values(VALUE category, VALUE category_objects, VALUE categories)
{
VALUE ary = rb_ary_new();
- rb_hash_foreach(category_objects, collect_values, ary);
+ st_foreach(rb_hash_tbl(category_objects), collect_values, ary);
rb_hash_aset(categories, category, ary);
return ST_CONTINUE;
}
@@ -942,7 +935,6 @@ void Init_objspace_dump(VALUE rb_mObjSpace);
void
Init_objspace(void)
{
-#undef rb_intern
VALUE rb_mObjSpace;
#if 0
rb_mObjSpace = rb_define_module("ObjectSpace"); /* let rdoc know */
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index 5fa9d98e38..19ba1f2e8b 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -12,9 +12,9 @@
**********************************************************************/
-#include "ruby/io.h"
#include "internal.h"
#include "ruby/debug.h"
+#include "ruby/io.h"
#include "gc.h"
#include "node.h"
#include "vm_core.h"
@@ -27,12 +27,12 @@ struct dump_config {
VALUE type;
FILE *stream;
VALUE string;
+ int roots;
const char *root_category;
VALUE cur_obj;
VALUE cur_obj_klass;
size_t cur_obj_references;
- unsigned int roots: 1;
- unsigned int full_heap: 1;
+ int full_heap;
};
PRINTF_ARGS(static void dump_append(struct dump_config *, const char *, ...), 2, 3);
@@ -172,9 +172,9 @@ reachable_object_i(VALUE ref, void *data)
return;
if (dc->cur_obj_references == 0)
- dump_append(dc, ", \"references\":[\"%#"PRIxVALUE"\"", ref);
+ dump_append(dc, ", \"references\":[\"%p\"", (void *)ref);
else
- dump_append(dc, ", \"%#"PRIxVALUE"\"", ref);
+ dump_append(dc, ", \"%p\"", (void *)ref);
dc->cur_obj_references++;
}
@@ -205,7 +205,7 @@ imemo_name(int imemo)
TYPE_STR(memo);
TYPE_STR(ment);
TYPE_STR(iseq);
- TYPE_STR(tmpbuf);
+ TYPE_STR(alloc);
TYPE_STR(ast);
TYPE_STR(parser_strterm);
default:
@@ -235,10 +235,10 @@ dump_object(VALUE obj, struct dump_config *dc)
if (dc->cur_obj == dc->string)
return;
- dump_append(dc, "{\"address\":\"%#"PRIxVALUE"\", \"type\":\"%s\"", obj, obj_type(obj));
+ dump_append(dc, "{\"address\":\"%p\", \"type\":\"%s\"", (void *)obj, obj_type(obj));
if (dc->cur_obj_klass)
- dump_append(dc, ", \"class\":\"%#"PRIxVALUE"\"", dc->cur_obj_klass);
+ dump_append(dc, ", \"class\":\"%p\"", (void *)dc->cur_obj_klass);
if (rb_obj_frozen_p(obj))
dump_append(dc, ", \"frozen\":true");
@@ -273,8 +273,8 @@ dump_object(VALUE obj, struct dump_config *dc)
case T_HASH:
dump_append(dc, ", \"size\":%"PRIuSIZE, (size_t)RHASH_SIZE(obj));
- if (FL_TEST(obj, RHASH_PROC_DEFAULT))
- dump_append(dc, ", \"default\":\"%#"PRIxVALUE"\"", RHASH_IFNONE(obj));
+ if (FL_TEST(obj, HASH_PROC_DEFAULT))
+ dump_append(dc, ", \"default\":\"%p\"", (void *)RHASH_IFNONE(obj));
break;
case T_ARRAY:
@@ -363,12 +363,12 @@ root_obj_i(const char *category, VALUE obj, void *data)
if (dc->root_category != NULL && category != dc->root_category)
dump_append(dc, "]}\n");
if (dc->root_category == NULL || category != dc->root_category)
- dump_append(dc, "{\"type\":\"ROOT\", \"root\":\"%s\", \"references\":[\"%#"PRIxVALUE"\"", category, obj);
+ dump_append(dc, "{\"type\":\"ROOT\", \"root\":\"%s\", \"references\":[\"%p\"", category, (void *)obj);
else
- dump_append(dc, ", \"%#"PRIxVALUE"\"", obj);
+ dump_append(dc, ", \"%p\"", (void *)obj);
dc->root_category = category;
- dc->roots = 1;
+ dc->roots++;
}
static VALUE
@@ -498,7 +498,6 @@ objspace_dump_all(int argc, VALUE *argv, VALUE os)
void
Init_objspace_dump(VALUE rb_mObjSpace)
{
-#undef rb_intern
#if 0
rb_mObjSpace = rb_define_module("ObjectSpace"); /* let rdoc know */
#endif
diff --git a/ext/openssl/History.md b/ext/openssl/History.md
index 9e7ee53397..db5050014e 100644
--- a/ext/openssl/History.md
+++ b/ext/openssl/History.md
@@ -1,39 +1,3 @@
-Version 2.1.3
-=============
-
-Bug fixes
----------
-
-* Fix deprecation warnings on Ruby 3.0.
-* Add ".include" directive support in `OpenSSL::Config`.
- [[GitHub #216]](https://github.com/ruby/openssl/pull/216)
-* Fix handling of IPv6 address SANs.
- [[GitHub #185]](https://github.com/ruby/openssl/pull/185)
-* Hostname verification failure with `OpenSSL::SSL::SSLContext#verify_hostname=`
- sets a proper error code.
- [[GitHub #350]](https://github.com/ruby/openssl/pull/350)
-* Fix crash with `OpenSSL::BN.new(nil, 2)`.
- [[Bug #15760]](https://bugs.ruby-lang.org/issues/15760)
-* `OpenSSL::SSL::SSLSocket#sys{read,write}` prevent internal string buffers from
- being modified by another thread.
- [[GitHub #453]](https://github.com/ruby/openssl/pull/453)
-* Fix misuse of input record separator in `OpenSSL::Buffering` where it was
- for output.
-* Fix wrong interger casting in `OpenSSL::PKey::EC#dsa_verify_asn1`.
- [[GitHub #460]](https://github.com/ruby/openssl/pull/460)
-* `extconf.rb` explicitly checks that OpenSSL's version number is 1.0.1 or
- newer but also less than 3.0. Ruby/OpenSSL v2.1.x and v2.2.x will not support
- OpenSSL 3.0 API.
- [[GitHub #458]](https://github.com/ruby/openssl/pull/458)
-* Activate `digest` gem correctly. `digest` library could go into an
- inconsistent state if there are multiple versions of `digest` is installed
- and `openssl` is `require`d before `digest`.
- [[GitHub #463]](https://github.com/ruby/openssl/pull/463)
-* Fix GC.compact compatibility.
- [[GitHub #464]](https://github.com/ruby/openssl/issues/464)
- [[GitHub #465]](https://github.com/ruby/openssl/pull/465)
-
-
Version 2.1.2
=============
diff --git a/ext/openssl/depend b/ext/openssl/depend
index 68cf357294..021c6d99a8 100644
--- a/ext/openssl/depend
+++ b/ext/openssl/depend
@@ -5,8 +5,6 @@ openssl_missing.o: openssl_missing.c
openssl_missing.o: openssl_missing.h
ossl.o: $(RUBY_EXTCONF_H)
ossl.o: $(arch_hdrdir)/ruby/config.h
-ossl.o: $(hdrdir)/ruby.h
-ossl.o: $(hdrdir)/ruby/assert.h
ossl.o: $(hdrdir)/ruby/backward.h
ossl.o: $(hdrdir)/ruby/defines.h
ossl.o: $(hdrdir)/ruby/encoding.h
@@ -20,6 +18,7 @@ ossl.o: $(hdrdir)/ruby/st.h
ossl.o: $(hdrdir)/ruby/subst.h
ossl.o: $(hdrdir)/ruby/thread.h
ossl.o: $(hdrdir)/ruby/thread_native.h
+ossl.o: $(top_srcdir)/include/ruby.h
ossl.o: openssl_missing.h
ossl.o: ossl.c
ossl.o: ossl.h
@@ -44,8 +43,6 @@ ossl.o: ossl_x509.h
ossl.o: ruby_missing.h
ossl_asn1.o: $(RUBY_EXTCONF_H)
ossl_asn1.o: $(arch_hdrdir)/ruby/config.h
-ossl_asn1.o: $(hdrdir)/ruby.h
-ossl_asn1.o: $(hdrdir)/ruby/assert.h
ossl_asn1.o: $(hdrdir)/ruby/backward.h
ossl_asn1.o: $(hdrdir)/ruby/defines.h
ossl_asn1.o: $(hdrdir)/ruby/encoding.h
@@ -58,6 +55,7 @@ ossl_asn1.o: $(hdrdir)/ruby/ruby.h
ossl_asn1.o: $(hdrdir)/ruby/st.h
ossl_asn1.o: $(hdrdir)/ruby/subst.h
ossl_asn1.o: $(hdrdir)/ruby/thread.h
+ossl_asn1.o: $(top_srcdir)/include/ruby.h
ossl_asn1.o: openssl_missing.h
ossl_asn1.o: ossl.h
ossl_asn1.o: ossl_asn1.c
@@ -82,8 +80,6 @@ ossl_asn1.o: ossl_x509.h
ossl_asn1.o: ruby_missing.h
ossl_bio.o: $(RUBY_EXTCONF_H)
ossl_bio.o: $(arch_hdrdir)/ruby/config.h
-ossl_bio.o: $(hdrdir)/ruby.h
-ossl_bio.o: $(hdrdir)/ruby/assert.h
ossl_bio.o: $(hdrdir)/ruby/backward.h
ossl_bio.o: $(hdrdir)/ruby/defines.h
ossl_bio.o: $(hdrdir)/ruby/encoding.h
@@ -96,6 +92,7 @@ ossl_bio.o: $(hdrdir)/ruby/ruby.h
ossl_bio.o: $(hdrdir)/ruby/st.h
ossl_bio.o: $(hdrdir)/ruby/subst.h
ossl_bio.o: $(hdrdir)/ruby/thread.h
+ossl_bio.o: $(top_srcdir)/include/ruby.h
ossl_bio.o: openssl_missing.h
ossl_bio.o: ossl.h
ossl_bio.o: ossl_asn1.h
@@ -120,8 +117,6 @@ ossl_bio.o: ossl_x509.h
ossl_bio.o: ruby_missing.h
ossl_bn.o: $(RUBY_EXTCONF_H)
ossl_bn.o: $(arch_hdrdir)/ruby/config.h
-ossl_bn.o: $(hdrdir)/ruby.h
-ossl_bn.o: $(hdrdir)/ruby/assert.h
ossl_bn.o: $(hdrdir)/ruby/backward.h
ossl_bn.o: $(hdrdir)/ruby/defines.h
ossl_bn.o: $(hdrdir)/ruby/encoding.h
@@ -134,6 +129,7 @@ ossl_bn.o: $(hdrdir)/ruby/ruby.h
ossl_bn.o: $(hdrdir)/ruby/st.h
ossl_bn.o: $(hdrdir)/ruby/subst.h
ossl_bn.o: $(hdrdir)/ruby/thread.h
+ossl_bn.o: $(top_srcdir)/include/ruby.h
ossl_bn.o: openssl_missing.h
ossl_bn.o: ossl.h
ossl_bn.o: ossl_asn1.h
@@ -158,8 +154,6 @@ ossl_bn.o: ossl_x509.h
ossl_bn.o: ruby_missing.h
ossl_cipher.o: $(RUBY_EXTCONF_H)
ossl_cipher.o: $(arch_hdrdir)/ruby/config.h
-ossl_cipher.o: $(hdrdir)/ruby.h
-ossl_cipher.o: $(hdrdir)/ruby/assert.h
ossl_cipher.o: $(hdrdir)/ruby/backward.h
ossl_cipher.o: $(hdrdir)/ruby/defines.h
ossl_cipher.o: $(hdrdir)/ruby/encoding.h
@@ -172,6 +166,7 @@ ossl_cipher.o: $(hdrdir)/ruby/ruby.h
ossl_cipher.o: $(hdrdir)/ruby/st.h
ossl_cipher.o: $(hdrdir)/ruby/subst.h
ossl_cipher.o: $(hdrdir)/ruby/thread.h
+ossl_cipher.o: $(top_srcdir)/include/ruby.h
ossl_cipher.o: openssl_missing.h
ossl_cipher.o: ossl.h
ossl_cipher.o: ossl_asn1.h
@@ -196,8 +191,6 @@ ossl_cipher.o: ossl_x509.h
ossl_cipher.o: ruby_missing.h
ossl_config.o: $(RUBY_EXTCONF_H)
ossl_config.o: $(arch_hdrdir)/ruby/config.h
-ossl_config.o: $(hdrdir)/ruby.h
-ossl_config.o: $(hdrdir)/ruby/assert.h
ossl_config.o: $(hdrdir)/ruby/backward.h
ossl_config.o: $(hdrdir)/ruby/defines.h
ossl_config.o: $(hdrdir)/ruby/encoding.h
@@ -210,6 +203,7 @@ ossl_config.o: $(hdrdir)/ruby/ruby.h
ossl_config.o: $(hdrdir)/ruby/st.h
ossl_config.o: $(hdrdir)/ruby/subst.h
ossl_config.o: $(hdrdir)/ruby/thread.h
+ossl_config.o: $(top_srcdir)/include/ruby.h
ossl_config.o: openssl_missing.h
ossl_config.o: ossl.h
ossl_config.o: ossl_asn1.h
@@ -234,8 +228,6 @@ ossl_config.o: ossl_x509.h
ossl_config.o: ruby_missing.h
ossl_digest.o: $(RUBY_EXTCONF_H)
ossl_digest.o: $(arch_hdrdir)/ruby/config.h
-ossl_digest.o: $(hdrdir)/ruby.h
-ossl_digest.o: $(hdrdir)/ruby/assert.h
ossl_digest.o: $(hdrdir)/ruby/backward.h
ossl_digest.o: $(hdrdir)/ruby/defines.h
ossl_digest.o: $(hdrdir)/ruby/encoding.h
@@ -248,6 +240,7 @@ ossl_digest.o: $(hdrdir)/ruby/ruby.h
ossl_digest.o: $(hdrdir)/ruby/st.h
ossl_digest.o: $(hdrdir)/ruby/subst.h
ossl_digest.o: $(hdrdir)/ruby/thread.h
+ossl_digest.o: $(top_srcdir)/include/ruby.h
ossl_digest.o: openssl_missing.h
ossl_digest.o: ossl.h
ossl_digest.o: ossl_asn1.h
@@ -272,8 +265,6 @@ ossl_digest.o: ossl_x509.h
ossl_digest.o: ruby_missing.h
ossl_engine.o: $(RUBY_EXTCONF_H)
ossl_engine.o: $(arch_hdrdir)/ruby/config.h
-ossl_engine.o: $(hdrdir)/ruby.h
-ossl_engine.o: $(hdrdir)/ruby/assert.h
ossl_engine.o: $(hdrdir)/ruby/backward.h
ossl_engine.o: $(hdrdir)/ruby/defines.h
ossl_engine.o: $(hdrdir)/ruby/encoding.h
@@ -286,6 +277,7 @@ ossl_engine.o: $(hdrdir)/ruby/ruby.h
ossl_engine.o: $(hdrdir)/ruby/st.h
ossl_engine.o: $(hdrdir)/ruby/subst.h
ossl_engine.o: $(hdrdir)/ruby/thread.h
+ossl_engine.o: $(top_srcdir)/include/ruby.h
ossl_engine.o: openssl_missing.h
ossl_engine.o: ossl.h
ossl_engine.o: ossl_asn1.h
@@ -310,8 +302,6 @@ ossl_engine.o: ossl_x509.h
ossl_engine.o: ruby_missing.h
ossl_hmac.o: $(RUBY_EXTCONF_H)
ossl_hmac.o: $(arch_hdrdir)/ruby/config.h
-ossl_hmac.o: $(hdrdir)/ruby.h
-ossl_hmac.o: $(hdrdir)/ruby/assert.h
ossl_hmac.o: $(hdrdir)/ruby/backward.h
ossl_hmac.o: $(hdrdir)/ruby/defines.h
ossl_hmac.o: $(hdrdir)/ruby/encoding.h
@@ -324,6 +314,7 @@ ossl_hmac.o: $(hdrdir)/ruby/ruby.h
ossl_hmac.o: $(hdrdir)/ruby/st.h
ossl_hmac.o: $(hdrdir)/ruby/subst.h
ossl_hmac.o: $(hdrdir)/ruby/thread.h
+ossl_hmac.o: $(top_srcdir)/include/ruby.h
ossl_hmac.o: openssl_missing.h
ossl_hmac.o: ossl.h
ossl_hmac.o: ossl_asn1.h
@@ -348,8 +339,6 @@ ossl_hmac.o: ossl_x509.h
ossl_hmac.o: ruby_missing.h
ossl_kdf.o: $(RUBY_EXTCONF_H)
ossl_kdf.o: $(arch_hdrdir)/ruby/config.h
-ossl_kdf.o: $(hdrdir)/ruby.h
-ossl_kdf.o: $(hdrdir)/ruby/assert.h
ossl_kdf.o: $(hdrdir)/ruby/backward.h
ossl_kdf.o: $(hdrdir)/ruby/defines.h
ossl_kdf.o: $(hdrdir)/ruby/encoding.h
@@ -362,6 +351,7 @@ ossl_kdf.o: $(hdrdir)/ruby/ruby.h
ossl_kdf.o: $(hdrdir)/ruby/st.h
ossl_kdf.o: $(hdrdir)/ruby/subst.h
ossl_kdf.o: $(hdrdir)/ruby/thread.h
+ossl_kdf.o: $(top_srcdir)/include/ruby.h
ossl_kdf.o: openssl_missing.h
ossl_kdf.o: ossl.h
ossl_kdf.o: ossl_asn1.h
@@ -386,8 +376,6 @@ ossl_kdf.o: ossl_x509.h
ossl_kdf.o: ruby_missing.h
ossl_ns_spki.o: $(RUBY_EXTCONF_H)
ossl_ns_spki.o: $(arch_hdrdir)/ruby/config.h
-ossl_ns_spki.o: $(hdrdir)/ruby.h
-ossl_ns_spki.o: $(hdrdir)/ruby/assert.h
ossl_ns_spki.o: $(hdrdir)/ruby/backward.h
ossl_ns_spki.o: $(hdrdir)/ruby/defines.h
ossl_ns_spki.o: $(hdrdir)/ruby/encoding.h
@@ -400,6 +388,7 @@ ossl_ns_spki.o: $(hdrdir)/ruby/ruby.h
ossl_ns_spki.o: $(hdrdir)/ruby/st.h
ossl_ns_spki.o: $(hdrdir)/ruby/subst.h
ossl_ns_spki.o: $(hdrdir)/ruby/thread.h
+ossl_ns_spki.o: $(top_srcdir)/include/ruby.h
ossl_ns_spki.o: openssl_missing.h
ossl_ns_spki.o: ossl.h
ossl_ns_spki.o: ossl_asn1.h
@@ -424,8 +413,6 @@ ossl_ns_spki.o: ossl_x509.h
ossl_ns_spki.o: ruby_missing.h
ossl_ocsp.o: $(RUBY_EXTCONF_H)
ossl_ocsp.o: $(arch_hdrdir)/ruby/config.h
-ossl_ocsp.o: $(hdrdir)/ruby.h
-ossl_ocsp.o: $(hdrdir)/ruby/assert.h
ossl_ocsp.o: $(hdrdir)/ruby/backward.h
ossl_ocsp.o: $(hdrdir)/ruby/defines.h
ossl_ocsp.o: $(hdrdir)/ruby/encoding.h
@@ -438,6 +425,7 @@ ossl_ocsp.o: $(hdrdir)/ruby/ruby.h
ossl_ocsp.o: $(hdrdir)/ruby/st.h
ossl_ocsp.o: $(hdrdir)/ruby/subst.h
ossl_ocsp.o: $(hdrdir)/ruby/thread.h
+ossl_ocsp.o: $(top_srcdir)/include/ruby.h
ossl_ocsp.o: openssl_missing.h
ossl_ocsp.o: ossl.h
ossl_ocsp.o: ossl_asn1.h
@@ -462,8 +450,6 @@ ossl_ocsp.o: ossl_x509.h
ossl_ocsp.o: ruby_missing.h
ossl_pkcs12.o: $(RUBY_EXTCONF_H)
ossl_pkcs12.o: $(arch_hdrdir)/ruby/config.h
-ossl_pkcs12.o: $(hdrdir)/ruby.h
-ossl_pkcs12.o: $(hdrdir)/ruby/assert.h
ossl_pkcs12.o: $(hdrdir)/ruby/backward.h
ossl_pkcs12.o: $(hdrdir)/ruby/defines.h
ossl_pkcs12.o: $(hdrdir)/ruby/encoding.h
@@ -476,6 +462,7 @@ ossl_pkcs12.o: $(hdrdir)/ruby/ruby.h
ossl_pkcs12.o: $(hdrdir)/ruby/st.h
ossl_pkcs12.o: $(hdrdir)/ruby/subst.h
ossl_pkcs12.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs12.o: $(top_srcdir)/include/ruby.h
ossl_pkcs12.o: openssl_missing.h
ossl_pkcs12.o: ossl.h
ossl_pkcs12.o: ossl_asn1.h
@@ -500,8 +487,6 @@ ossl_pkcs12.o: ossl_x509.h
ossl_pkcs12.o: ruby_missing.h
ossl_pkcs7.o: $(RUBY_EXTCONF_H)
ossl_pkcs7.o: $(arch_hdrdir)/ruby/config.h
-ossl_pkcs7.o: $(hdrdir)/ruby.h
-ossl_pkcs7.o: $(hdrdir)/ruby/assert.h
ossl_pkcs7.o: $(hdrdir)/ruby/backward.h
ossl_pkcs7.o: $(hdrdir)/ruby/defines.h
ossl_pkcs7.o: $(hdrdir)/ruby/encoding.h
@@ -514,6 +499,7 @@ ossl_pkcs7.o: $(hdrdir)/ruby/ruby.h
ossl_pkcs7.o: $(hdrdir)/ruby/st.h
ossl_pkcs7.o: $(hdrdir)/ruby/subst.h
ossl_pkcs7.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs7.o: $(top_srcdir)/include/ruby.h
ossl_pkcs7.o: openssl_missing.h
ossl_pkcs7.o: ossl.h
ossl_pkcs7.o: ossl_asn1.h
@@ -538,8 +524,6 @@ ossl_pkcs7.o: ossl_x509.h
ossl_pkcs7.o: ruby_missing.h
ossl_pkey.o: $(RUBY_EXTCONF_H)
ossl_pkey.o: $(arch_hdrdir)/ruby/config.h
-ossl_pkey.o: $(hdrdir)/ruby.h
-ossl_pkey.o: $(hdrdir)/ruby/assert.h
ossl_pkey.o: $(hdrdir)/ruby/backward.h
ossl_pkey.o: $(hdrdir)/ruby/defines.h
ossl_pkey.o: $(hdrdir)/ruby/encoding.h
@@ -552,6 +536,7 @@ ossl_pkey.o: $(hdrdir)/ruby/ruby.h
ossl_pkey.o: $(hdrdir)/ruby/st.h
ossl_pkey.o: $(hdrdir)/ruby/subst.h
ossl_pkey.o: $(hdrdir)/ruby/thread.h
+ossl_pkey.o: $(top_srcdir)/include/ruby.h
ossl_pkey.o: openssl_missing.h
ossl_pkey.o: ossl.h
ossl_pkey.o: ossl_asn1.h
@@ -576,8 +561,6 @@ ossl_pkey.o: ossl_x509.h
ossl_pkey.o: ruby_missing.h
ossl_pkey_dh.o: $(RUBY_EXTCONF_H)
ossl_pkey_dh.o: $(arch_hdrdir)/ruby/config.h
-ossl_pkey_dh.o: $(hdrdir)/ruby.h
-ossl_pkey_dh.o: $(hdrdir)/ruby/assert.h
ossl_pkey_dh.o: $(hdrdir)/ruby/backward.h
ossl_pkey_dh.o: $(hdrdir)/ruby/defines.h
ossl_pkey_dh.o: $(hdrdir)/ruby/encoding.h
@@ -590,6 +573,7 @@ ossl_pkey_dh.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_dh.o: $(hdrdir)/ruby/st.h
ossl_pkey_dh.o: $(hdrdir)/ruby/subst.h
ossl_pkey_dh.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_dh.o: $(top_srcdir)/include/ruby.h
ossl_pkey_dh.o: openssl_missing.h
ossl_pkey_dh.o: ossl.h
ossl_pkey_dh.o: ossl_asn1.h
@@ -614,8 +598,6 @@ ossl_pkey_dh.o: ossl_x509.h
ossl_pkey_dh.o: ruby_missing.h
ossl_pkey_dsa.o: $(RUBY_EXTCONF_H)
ossl_pkey_dsa.o: $(arch_hdrdir)/ruby/config.h
-ossl_pkey_dsa.o: $(hdrdir)/ruby.h
-ossl_pkey_dsa.o: $(hdrdir)/ruby/assert.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/backward.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/defines.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/encoding.h
@@ -628,6 +610,7 @@ ossl_pkey_dsa.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/st.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/subst.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_dsa.o: $(top_srcdir)/include/ruby.h
ossl_pkey_dsa.o: openssl_missing.h
ossl_pkey_dsa.o: ossl.h
ossl_pkey_dsa.o: ossl_asn1.h
@@ -652,8 +635,6 @@ ossl_pkey_dsa.o: ossl_x509.h
ossl_pkey_dsa.o: ruby_missing.h
ossl_pkey_ec.o: $(RUBY_EXTCONF_H)
ossl_pkey_ec.o: $(arch_hdrdir)/ruby/config.h
-ossl_pkey_ec.o: $(hdrdir)/ruby.h
-ossl_pkey_ec.o: $(hdrdir)/ruby/assert.h
ossl_pkey_ec.o: $(hdrdir)/ruby/backward.h
ossl_pkey_ec.o: $(hdrdir)/ruby/defines.h
ossl_pkey_ec.o: $(hdrdir)/ruby/encoding.h
@@ -666,6 +647,7 @@ ossl_pkey_ec.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_ec.o: $(hdrdir)/ruby/st.h
ossl_pkey_ec.o: $(hdrdir)/ruby/subst.h
ossl_pkey_ec.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_ec.o: $(top_srcdir)/include/ruby.h
ossl_pkey_ec.o: openssl_missing.h
ossl_pkey_ec.o: ossl.h
ossl_pkey_ec.o: ossl_asn1.h
@@ -690,8 +672,6 @@ ossl_pkey_ec.o: ossl_x509.h
ossl_pkey_ec.o: ruby_missing.h
ossl_pkey_rsa.o: $(RUBY_EXTCONF_H)
ossl_pkey_rsa.o: $(arch_hdrdir)/ruby/config.h
-ossl_pkey_rsa.o: $(hdrdir)/ruby.h
-ossl_pkey_rsa.o: $(hdrdir)/ruby/assert.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/backward.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/defines.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/encoding.h
@@ -704,6 +684,7 @@ ossl_pkey_rsa.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/st.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/subst.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_rsa.o: $(top_srcdir)/include/ruby.h
ossl_pkey_rsa.o: openssl_missing.h
ossl_pkey_rsa.o: ossl.h
ossl_pkey_rsa.o: ossl_asn1.h
@@ -728,8 +709,6 @@ ossl_pkey_rsa.o: ossl_x509.h
ossl_pkey_rsa.o: ruby_missing.h
ossl_rand.o: $(RUBY_EXTCONF_H)
ossl_rand.o: $(arch_hdrdir)/ruby/config.h
-ossl_rand.o: $(hdrdir)/ruby.h
-ossl_rand.o: $(hdrdir)/ruby/assert.h
ossl_rand.o: $(hdrdir)/ruby/backward.h
ossl_rand.o: $(hdrdir)/ruby/defines.h
ossl_rand.o: $(hdrdir)/ruby/encoding.h
@@ -742,6 +721,7 @@ ossl_rand.o: $(hdrdir)/ruby/ruby.h
ossl_rand.o: $(hdrdir)/ruby/st.h
ossl_rand.o: $(hdrdir)/ruby/subst.h
ossl_rand.o: $(hdrdir)/ruby/thread.h
+ossl_rand.o: $(top_srcdir)/include/ruby.h
ossl_rand.o: openssl_missing.h
ossl_rand.o: ossl.h
ossl_rand.o: ossl_asn1.h
@@ -766,8 +746,6 @@ ossl_rand.o: ossl_x509.h
ossl_rand.o: ruby_missing.h
ossl_ssl.o: $(RUBY_EXTCONF_H)
ossl_ssl.o: $(arch_hdrdir)/ruby/config.h
-ossl_ssl.o: $(hdrdir)/ruby.h
-ossl_ssl.o: $(hdrdir)/ruby/assert.h
ossl_ssl.o: $(hdrdir)/ruby/backward.h
ossl_ssl.o: $(hdrdir)/ruby/defines.h
ossl_ssl.o: $(hdrdir)/ruby/encoding.h
@@ -780,6 +758,7 @@ ossl_ssl.o: $(hdrdir)/ruby/ruby.h
ossl_ssl.o: $(hdrdir)/ruby/st.h
ossl_ssl.o: $(hdrdir)/ruby/subst.h
ossl_ssl.o: $(hdrdir)/ruby/thread.h
+ossl_ssl.o: $(top_srcdir)/include/ruby.h
ossl_ssl.o: openssl_missing.h
ossl_ssl.o: ossl.h
ossl_ssl.o: ossl_asn1.h
@@ -804,8 +783,6 @@ ossl_ssl.o: ossl_x509.h
ossl_ssl.o: ruby_missing.h
ossl_ssl_session.o: $(RUBY_EXTCONF_H)
ossl_ssl_session.o: $(arch_hdrdir)/ruby/config.h
-ossl_ssl_session.o: $(hdrdir)/ruby.h
-ossl_ssl_session.o: $(hdrdir)/ruby/assert.h
ossl_ssl_session.o: $(hdrdir)/ruby/backward.h
ossl_ssl_session.o: $(hdrdir)/ruby/defines.h
ossl_ssl_session.o: $(hdrdir)/ruby/encoding.h
@@ -818,6 +795,7 @@ ossl_ssl_session.o: $(hdrdir)/ruby/ruby.h
ossl_ssl_session.o: $(hdrdir)/ruby/st.h
ossl_ssl_session.o: $(hdrdir)/ruby/subst.h
ossl_ssl_session.o: $(hdrdir)/ruby/thread.h
+ossl_ssl_session.o: $(top_srcdir)/include/ruby.h
ossl_ssl_session.o: openssl_missing.h
ossl_ssl_session.o: ossl.h
ossl_ssl_session.o: ossl_asn1.h
@@ -842,8 +820,6 @@ ossl_ssl_session.o: ossl_x509.h
ossl_ssl_session.o: ruby_missing.h
ossl_x509.o: $(RUBY_EXTCONF_H)
ossl_x509.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509.o: $(hdrdir)/ruby.h
-ossl_x509.o: $(hdrdir)/ruby/assert.h
ossl_x509.o: $(hdrdir)/ruby/backward.h
ossl_x509.o: $(hdrdir)/ruby/defines.h
ossl_x509.o: $(hdrdir)/ruby/encoding.h
@@ -856,6 +832,7 @@ ossl_x509.o: $(hdrdir)/ruby/ruby.h
ossl_x509.o: $(hdrdir)/ruby/st.h
ossl_x509.o: $(hdrdir)/ruby/subst.h
ossl_x509.o: $(hdrdir)/ruby/thread.h
+ossl_x509.o: $(top_srcdir)/include/ruby.h
ossl_x509.o: openssl_missing.h
ossl_x509.o: ossl.h
ossl_x509.o: ossl_asn1.h
@@ -880,8 +857,6 @@ ossl_x509.o: ossl_x509.h
ossl_x509.o: ruby_missing.h
ossl_x509attr.o: $(RUBY_EXTCONF_H)
ossl_x509attr.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509attr.o: $(hdrdir)/ruby.h
-ossl_x509attr.o: $(hdrdir)/ruby/assert.h
ossl_x509attr.o: $(hdrdir)/ruby/backward.h
ossl_x509attr.o: $(hdrdir)/ruby/defines.h
ossl_x509attr.o: $(hdrdir)/ruby/encoding.h
@@ -894,6 +869,7 @@ ossl_x509attr.o: $(hdrdir)/ruby/ruby.h
ossl_x509attr.o: $(hdrdir)/ruby/st.h
ossl_x509attr.o: $(hdrdir)/ruby/subst.h
ossl_x509attr.o: $(hdrdir)/ruby/thread.h
+ossl_x509attr.o: $(top_srcdir)/include/ruby.h
ossl_x509attr.o: openssl_missing.h
ossl_x509attr.o: ossl.h
ossl_x509attr.o: ossl_asn1.h
@@ -918,8 +894,6 @@ ossl_x509attr.o: ossl_x509attr.c
ossl_x509attr.o: ruby_missing.h
ossl_x509cert.o: $(RUBY_EXTCONF_H)
ossl_x509cert.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509cert.o: $(hdrdir)/ruby.h
-ossl_x509cert.o: $(hdrdir)/ruby/assert.h
ossl_x509cert.o: $(hdrdir)/ruby/backward.h
ossl_x509cert.o: $(hdrdir)/ruby/defines.h
ossl_x509cert.o: $(hdrdir)/ruby/encoding.h
@@ -932,6 +906,7 @@ ossl_x509cert.o: $(hdrdir)/ruby/ruby.h
ossl_x509cert.o: $(hdrdir)/ruby/st.h
ossl_x509cert.o: $(hdrdir)/ruby/subst.h
ossl_x509cert.o: $(hdrdir)/ruby/thread.h
+ossl_x509cert.o: $(top_srcdir)/include/ruby.h
ossl_x509cert.o: openssl_missing.h
ossl_x509cert.o: ossl.h
ossl_x509cert.o: ossl_asn1.h
@@ -956,8 +931,6 @@ ossl_x509cert.o: ossl_x509cert.c
ossl_x509cert.o: ruby_missing.h
ossl_x509crl.o: $(RUBY_EXTCONF_H)
ossl_x509crl.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509crl.o: $(hdrdir)/ruby.h
-ossl_x509crl.o: $(hdrdir)/ruby/assert.h
ossl_x509crl.o: $(hdrdir)/ruby/backward.h
ossl_x509crl.o: $(hdrdir)/ruby/defines.h
ossl_x509crl.o: $(hdrdir)/ruby/encoding.h
@@ -970,6 +943,7 @@ ossl_x509crl.o: $(hdrdir)/ruby/ruby.h
ossl_x509crl.o: $(hdrdir)/ruby/st.h
ossl_x509crl.o: $(hdrdir)/ruby/subst.h
ossl_x509crl.o: $(hdrdir)/ruby/thread.h
+ossl_x509crl.o: $(top_srcdir)/include/ruby.h
ossl_x509crl.o: openssl_missing.h
ossl_x509crl.o: ossl.h
ossl_x509crl.o: ossl_asn1.h
@@ -994,8 +968,6 @@ ossl_x509crl.o: ossl_x509crl.c
ossl_x509crl.o: ruby_missing.h
ossl_x509ext.o: $(RUBY_EXTCONF_H)
ossl_x509ext.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509ext.o: $(hdrdir)/ruby.h
-ossl_x509ext.o: $(hdrdir)/ruby/assert.h
ossl_x509ext.o: $(hdrdir)/ruby/backward.h
ossl_x509ext.o: $(hdrdir)/ruby/defines.h
ossl_x509ext.o: $(hdrdir)/ruby/encoding.h
@@ -1008,6 +980,7 @@ ossl_x509ext.o: $(hdrdir)/ruby/ruby.h
ossl_x509ext.o: $(hdrdir)/ruby/st.h
ossl_x509ext.o: $(hdrdir)/ruby/subst.h
ossl_x509ext.o: $(hdrdir)/ruby/thread.h
+ossl_x509ext.o: $(top_srcdir)/include/ruby.h
ossl_x509ext.o: openssl_missing.h
ossl_x509ext.o: ossl.h
ossl_x509ext.o: ossl_asn1.h
@@ -1032,8 +1005,6 @@ ossl_x509ext.o: ossl_x509ext.c
ossl_x509ext.o: ruby_missing.h
ossl_x509name.o: $(RUBY_EXTCONF_H)
ossl_x509name.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509name.o: $(hdrdir)/ruby.h
-ossl_x509name.o: $(hdrdir)/ruby/assert.h
ossl_x509name.o: $(hdrdir)/ruby/backward.h
ossl_x509name.o: $(hdrdir)/ruby/defines.h
ossl_x509name.o: $(hdrdir)/ruby/encoding.h
@@ -1046,6 +1017,7 @@ ossl_x509name.o: $(hdrdir)/ruby/ruby.h
ossl_x509name.o: $(hdrdir)/ruby/st.h
ossl_x509name.o: $(hdrdir)/ruby/subst.h
ossl_x509name.o: $(hdrdir)/ruby/thread.h
+ossl_x509name.o: $(top_srcdir)/include/ruby.h
ossl_x509name.o: openssl_missing.h
ossl_x509name.o: ossl.h
ossl_x509name.o: ossl_asn1.h
@@ -1070,8 +1042,6 @@ ossl_x509name.o: ossl_x509name.c
ossl_x509name.o: ruby_missing.h
ossl_x509req.o: $(RUBY_EXTCONF_H)
ossl_x509req.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509req.o: $(hdrdir)/ruby.h
-ossl_x509req.o: $(hdrdir)/ruby/assert.h
ossl_x509req.o: $(hdrdir)/ruby/backward.h
ossl_x509req.o: $(hdrdir)/ruby/defines.h
ossl_x509req.o: $(hdrdir)/ruby/encoding.h
@@ -1084,6 +1054,7 @@ ossl_x509req.o: $(hdrdir)/ruby/ruby.h
ossl_x509req.o: $(hdrdir)/ruby/st.h
ossl_x509req.o: $(hdrdir)/ruby/subst.h
ossl_x509req.o: $(hdrdir)/ruby/thread.h
+ossl_x509req.o: $(top_srcdir)/include/ruby.h
ossl_x509req.o: openssl_missing.h
ossl_x509req.o: ossl.h
ossl_x509req.o: ossl_asn1.h
@@ -1108,8 +1079,6 @@ ossl_x509req.o: ossl_x509req.c
ossl_x509req.o: ruby_missing.h
ossl_x509revoked.o: $(RUBY_EXTCONF_H)
ossl_x509revoked.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509revoked.o: $(hdrdir)/ruby.h
-ossl_x509revoked.o: $(hdrdir)/ruby/assert.h
ossl_x509revoked.o: $(hdrdir)/ruby/backward.h
ossl_x509revoked.o: $(hdrdir)/ruby/defines.h
ossl_x509revoked.o: $(hdrdir)/ruby/encoding.h
@@ -1122,6 +1091,7 @@ ossl_x509revoked.o: $(hdrdir)/ruby/ruby.h
ossl_x509revoked.o: $(hdrdir)/ruby/st.h
ossl_x509revoked.o: $(hdrdir)/ruby/subst.h
ossl_x509revoked.o: $(hdrdir)/ruby/thread.h
+ossl_x509revoked.o: $(top_srcdir)/include/ruby.h
ossl_x509revoked.o: openssl_missing.h
ossl_x509revoked.o: ossl.h
ossl_x509revoked.o: ossl_asn1.h
@@ -1146,8 +1116,6 @@ ossl_x509revoked.o: ossl_x509revoked.c
ossl_x509revoked.o: ruby_missing.h
ossl_x509store.o: $(RUBY_EXTCONF_H)
ossl_x509store.o: $(arch_hdrdir)/ruby/config.h
-ossl_x509store.o: $(hdrdir)/ruby.h
-ossl_x509store.o: $(hdrdir)/ruby/assert.h
ossl_x509store.o: $(hdrdir)/ruby/backward.h
ossl_x509store.o: $(hdrdir)/ruby/defines.h
ossl_x509store.o: $(hdrdir)/ruby/encoding.h
@@ -1160,6 +1128,7 @@ ossl_x509store.o: $(hdrdir)/ruby/ruby.h
ossl_x509store.o: $(hdrdir)/ruby/st.h
ossl_x509store.o: $(hdrdir)/ruby/subst.h
ossl_x509store.o: $(hdrdir)/ruby/thread.h
+ossl_x509store.o: $(top_srcdir)/include/ruby.h
ossl_x509store.o: openssl_missing.h
ossl_x509store.o: ossl.h
ossl_x509store.o: ossl_asn1.h
diff --git a/ext/openssl/deprecation.rb b/ext/openssl/deprecation.rb
index afe989ead1..1d51d065a9 100644
--- a/ext/openssl/deprecation.rb
+++ b/ext/openssl/deprecation.rb
@@ -3,7 +3,7 @@ module OpenSSL
def self.deprecated_warning_flag
unless flag = (@deprecated_warning_flag ||= nil)
if try_compile("", flag = "-Werror=deprecated-declarations")
- $warnflags = "#{@warnflags = $warnflags}" #{flag}"
+ $warnflags << " #{flag}"
else
flag = ""
end
@@ -12,10 +12,6 @@ module OpenSSL
flag
end
- def self.restore_warning_flag
- $warnflags = @warnflags
- end
-
def self.check_func(func, header)
have_func(func, header, deprecated_warning_flag)
end
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index 7e817ae2da..4f218562b1 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -19,7 +19,7 @@ dir_config("kerberos")
Logging::message "=== OpenSSL for Ruby configurator ===\n"
-# Check with -Werror=deprecated-declarations if available
+# Add -Werror=deprecated-declarations to $warnflags if available
OpenSSL.deprecated_warning_flag
##
@@ -37,6 +37,9 @@ if $mswin || $mingw
have_library("ws2_32")
end
+Logging::message "=== Checking for required stuff... ===\n"
+result = pkg_config("openssl") && have_header("openssl/ssl.h")
+
def find_openssl_library
if $mswin || $mingw
# required for static OpenSSL libraries
@@ -87,33 +90,19 @@ def find_openssl_library
return false
end
-Logging::message "=== Checking for required stuff... ===\n"
-pkg_config_found = pkg_config("openssl") && have_header("openssl/ssl.h")
-
-if !pkg_config_found && !find_openssl_library
- Logging::message "=== Checking for required stuff failed. ===\n"
- Logging::message "Makefile wasn't created. Fix the errors above.\n"
- raise "OpenSSL library could not be found. You might want to use " \
- "--with-openssl-dir=<dir> option to specify the prefix where OpenSSL " \
- "is installed."
-end
-
-version_ok = if have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
- is_libressl = true
- checking_for("LibreSSL version >= 2.5.0") {
- try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x20500000L", "openssl/opensslv.h") }
-else
- checking_for("OpenSSL version >= 1.0.1 and < 3.0.0") {
- try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10001000L", "openssl/opensslv.h") &&
- !try_static_assert("OPENSSL_VERSION_MAJOR >= 3", "openssl/opensslv.h") }
-end
-unless version_ok
- raise "OpenSSL >= 1.0.1, < 3.0.0 or LibreSSL >= 2.5.0 is required"
+unless result
+ unless find_openssl_library
+ Logging::message "=== Checking for required stuff failed. ===\n"
+ Logging::message "Makefile wasn't created. Fix the errors above.\n"
+ raise "OpenSSL library could not be found. You might want to use " \
+ "--with-openssl-dir=<dir> option to specify the prefix where OpenSSL " \
+ "is installed."
+ end
end
-# Prevent wincrypt.h from being included, which defines conflicting macro with openssl/x509.h
-if is_libressl && ($mswin || $mingw)
- $defs.push("-DNOCRYPT")
+unless checking_for("OpenSSL version is 1.0.1 or later") {
+ try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10001000L", "openssl/opensslv.h") }
+ raise "OpenSSL >= 1.0.1 or LibreSSL is required"
end
Logging::message "=== Checking for OpenSSL features... ===\n"
@@ -125,6 +114,10 @@ engines.each { |name|
OpenSSL.check_func_or_macro("ENGINE_load_#{name}", "openssl/engine.h")
}
+if ($mswin || $mingw) && have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
+ $defs.push("-DNOCRYPT")
+end
+
# added in 1.0.2
have_func("EC_curve_nist2nid")
have_func("X509_REVOKED_dup")
@@ -176,6 +169,5 @@ have_func("EVP_PBE_scrypt")
Logging::message "=== Checking done. ===\n"
create_header
-OpenSSL.restore_warning_flag
create_makefile("openssl")
Logging::message "Done.\n"
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index 5d1586e594..935f61f0ef 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -316,15 +316,20 @@ module OpenSSL::Buffering
@wbuffer << s
@wbuffer.force_encoding(Encoding::BINARY)
@sync ||= false
- if @sync or @wbuffer.size > BLOCK_SIZE
- until @wbuffer.empty?
+ if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
+ remain = idx ? idx + $/.size : @wbuffer.length
+ nwritten = 0
+ while remain > 0
+ str = @wbuffer[nwritten,remain]
begin
- nwrote = syswrite(@wbuffer)
+ nwrote = syswrite(str)
rescue Errno::EAGAIN
retry
end
- @wbuffer[0, nwrote] = ""
+ remain -= nwrote
+ nwritten += nwrote
end
+ @wbuffer[0,nwritten] = ""
end
end
@@ -404,7 +409,9 @@ module OpenSSL::Buffering
end
args.each{|arg|
s << arg.to_s
- s.sub!(/(?<!\n)\z/, "\n")
+ if $/ && /\n\z/ !~ s
+ s << "\n"
+ end
}
do_write(s)
nil
diff --git a/ext/openssl/lib/openssl/config.rb b/ext/openssl/lib/openssl/config.rb
index 78a2da9eb9..48d8be0069 100644
--- a/ext/openssl/lib/openssl/config.rb
+++ b/ext/openssl/lib/openssl/config.rb
@@ -77,44 +77,29 @@ module OpenSSL
def parse_config_lines(io)
section = 'default'
data = {section => {}}
- io_stack = [io]
- while definition = get_definition(io_stack)
+ while definition = get_definition(io)
definition = clear_comments(definition)
next if definition.empty?
- case definition
- when /\A\[/
+ if definition[0] == ?[
if /\[([^\]]*)\]/ =~ definition
section = $1.strip
data[section] ||= {}
else
raise ConfigError, "missing close square bracket"
end
- when /\A\.include (\s*=\s*)?(.+)\z/
- path = $2
- if File.directory?(path)
- files = Dir.glob(File.join(path, "*.{cnf,conf}"), File::FNM_EXTGLOB)
- else
- files = [path]
- end
-
- files.each do |filename|
- begin
- io_stack << StringIO.new(File.read(filename))
- rescue
- raise ConfigError, "could not include file '%s'" % filename
+ else
+ if /\A([^:\s]*)(?:::([^:\s]*))?\s*=(.*)\z/ =~ definition
+ if $2
+ section = $1
+ key = $2
+ else
+ key = $1
end
- end
- when /\A([^:\s]*)(?:::([^:\s]*))?\s*=(.*)\z/
- if $2
- section = $1
- key = $2
+ value = unescape_value(data, section, $3)
+ (data[section] ||= {})[key] = value.strip
else
- key = $1
+ raise ConfigError, "missing equal sign"
end
- value = unescape_value(data, section, $3)
- (data[section] ||= {})[key] = value.strip
- else
- raise ConfigError, "missing equal sign"
end
end
data
@@ -227,10 +212,10 @@ module OpenSSL
scanned.join
end
- def get_definition(io_stack)
- if line = get_line(io_stack)
+ def get_definition(io)
+ if line = get_line(io)
while /[^\\]\\\z/ =~ line
- if extra = get_line(io_stack)
+ if extra = get_line(io)
line += extra
else
break
@@ -240,12 +225,9 @@ module OpenSSL
end
end
- def get_line(io_stack)
- while io = io_stack.last
- if line = io.gets
- return line.gsub(/[\r\n]*/, '')
- end
- io_stack.pop
+ def get_line(io)
+ if line = io.gets
+ line.gsub(/[\r\n]*/, '')
end
end
end
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index 355eb2ebbb..6a6f2b9431 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -12,7 +12,6 @@
require "openssl/buffering"
require "io/nonblock"
-require "ipaddr"
module OpenSSL
module SSL
@@ -273,11 +272,11 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
return true if verify_hostname(hostname, san.value)
when 7 # iPAddress in GeneralName (RFC5280)
should_verify_common_name = false
- if san.value.size == 4 || san.value.size == 16
- begin
- return true if san.value == IPAddr.new(hostname).hton
- rescue IPAddr::InvalidAddressError
- end
+ # follows GENERAL_NAME_print() in x509v3/v3_alt.c
+ if san.value.size == 4
+ return true if san.value.unpack('C*').join('.') == hostname
+ elsif san.value.size == 16
+ return true if san.value.unpack('n*').map { |e| sprintf("%X", e) }.join(':') == hostname
end
end
}
diff --git a/ext/openssl/openssl.gemspec b/ext/openssl/openssl.gemspec
index c22eece7d6..7a6c14422f 100644
--- a/ext/openssl/openssl.gemspec
+++ b/ext/openssl/openssl.gemspec
@@ -1,27 +1,46 @@
-Gem::Specification.new do |spec|
- spec.name = "openssl"
- spec.version = "2.1.3"
- spec.authors = ["Martin Bosslet", "SHIBATA Hiroshi", "Zachary Scott", "Kazuki Yamaguchi"]
- spec.email = ["ruby-core@ruby-lang.org"]
- spec.summary = %q{OpenSSL provides SSL, TLS and general purpose cryptography.}
- spec.description = %q{It wraps the OpenSSL library.}
- spec.homepage = "https://github.com/ruby/openssl"
- spec.license = "Ruby"
+# -*- encoding: utf-8 -*-
+# stub: openssl 2.1.2 ruby lib
+# stub: ext/openssl/extconf.rb
- spec.files = Dir["lib/**/*.rb", "ext/**/*.{c,h,rb}", "*.md", "BSDL", "LICENSE.txt"]
- spec.require_paths = ["lib"]
- spec.extensions = ["ext/openssl/extconf.rb"]
+Gem::Specification.new do |s|
+ s.name = "openssl".freeze
+ s.version = "2.1.2"
- spec.extra_rdoc_files = Dir["*.md"]
- spec.rdoc_options = ["--main", "README.md"]
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
+ s.metadata = { "msys2_mingw_dependencies" => "openssl" } if s.respond_to? :metadata=
+ s.require_paths = ["lib".freeze]
+ s.authors = ["Martin Bosslet".freeze, "SHIBATA Hiroshi".freeze, "Zachary Scott".freeze, "Kazuki Yamaguchi".freeze]
+ s.date = "2018-10-17"
+ s.description = "It wraps the OpenSSL library.".freeze
+ s.email = ["ruby-core@ruby-lang.org".freeze]
+ s.extensions = ["ext/openssl/extconf.rb".freeze]
+ s.extra_rdoc_files = ["CONTRIBUTING.md".freeze, "README.md".freeze, "History.md".freeze]
+ s.files = ["BSDL".freeze, "CONTRIBUTING.md".freeze, "History.md".freeze, "LICENSE.txt".freeze, "README.md".freeze, "ext/openssl/deprecation.rb".freeze, "ext/openssl/extconf.rb".freeze, "ext/openssl/openssl_missing.c".freeze, "ext/openssl/openssl_missing.h".freeze, "ext/openssl/ossl.c".freeze, "ext/openssl/ossl.h".freeze, "ext/openssl/ossl_asn1.c".freeze, "ext/openssl/ossl_asn1.h".freeze, "ext/openssl/ossl_bio.c".freeze, "ext/openssl/ossl_bio.h".freeze, "ext/openssl/ossl_bn.c".freeze, "ext/openssl/ossl_bn.h".freeze, "ext/openssl/ossl_cipher.c".freeze, "ext/openssl/ossl_cipher.h".freeze, "ext/openssl/ossl_config.c".freeze, "ext/openssl/ossl_config.h".freeze, "ext/openssl/ossl_digest.c".freeze, "ext/openssl/ossl_digest.h".freeze, "ext/openssl/ossl_engine.c".freeze, "ext/openssl/ossl_engine.h".freeze, "ext/openssl/ossl_hmac.c".freeze, "ext/openssl/ossl_hmac.h".freeze, "ext/openssl/ossl_kdf.c".freeze, "ext/openssl/ossl_kdf.h".freeze, "ext/openssl/ossl_ns_spki.c".freeze, "ext/openssl/ossl_ns_spki.h".freeze, "ext/openssl/ossl_ocsp.c".freeze, "ext/openssl/ossl_ocsp.h".freeze, "ext/openssl/ossl_pkcs12.c".freeze, "ext/openssl/ossl_pkcs12.h".freeze, "ext/openssl/ossl_pkcs7.c".freeze, "ext/openssl/ossl_pkcs7.h".freeze, "ext/openssl/ossl_pkey.c".freeze, "ext/openssl/ossl_pkey.h".freeze, "ext/openssl/ossl_pkey_dh.c".freeze, "ext/openssl/ossl_pkey_dsa.c".freeze, "ext/openssl/ossl_pkey_ec.c".freeze, "ext/openssl/ossl_pkey_rsa.c".freeze, "ext/openssl/ossl_rand.c".freeze, "ext/openssl/ossl_rand.h".freeze, "ext/openssl/ossl_ssl.c".freeze, "ext/openssl/ossl_ssl.h".freeze, "ext/openssl/ossl_ssl_session.c".freeze, "ext/openssl/ossl_version.h".freeze, "ext/openssl/ossl_x509.c".freeze, "ext/openssl/ossl_x509.h".freeze, "ext/openssl/ossl_x509attr.c".freeze, "ext/openssl/ossl_x509cert.c".freeze, "ext/openssl/ossl_x509crl.c".freeze, "ext/openssl/ossl_x509ext.c".freeze, "ext/openssl/ossl_x509name.c".freeze, "ext/openssl/ossl_x509req.c".freeze, "ext/openssl/ossl_x509revoked.c".freeze, "ext/openssl/ossl_x509store.c".freeze, "ext/openssl/ruby_missing.h".freeze, "lib/openssl.rb".freeze, "lib/openssl/bn.rb".freeze, "lib/openssl/buffering.rb".freeze, "lib/openssl/cipher.rb".freeze, "lib/openssl/config.rb".freeze, "lib/openssl/digest.rb".freeze, "lib/openssl/pkcs5.rb".freeze, "lib/openssl/pkey.rb".freeze, "lib/openssl/ssl.rb".freeze, "lib/openssl/x509.rb".freeze]
+ s.homepage = "https://github.com/ruby/openssl".freeze
+ s.licenses = ["Ruby".freeze]
+ s.rdoc_options = ["--main".freeze, "README.md".freeze]
+ s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze)
+ s.rubygems_version = "3.0.0.beta1".freeze
+ s.summary = "OpenSSL provides SSL, TLS and general purpose cryptography.".freeze
- spec.required_ruby_version = ">= 2.3.0"
+ if s.respond_to? :specification_version then
+ s.specification_version = 4
- spec.add_runtime_dependency "ipaddr"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "rake-compiler"
- spec.add_development_dependency "test-unit", "~> 3.0"
- spec.add_development_dependency "rdoc"
-
- spec.metadata["msys2_mingw_dependencies"] = "openssl"
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_development_dependency(%q<rake>.freeze, [">= 0"])
+ s.add_development_dependency(%q<rake-compiler>.freeze, [">= 0"])
+ s.add_development_dependency(%q<test-unit>.freeze, ["~> 3.0"])
+ s.add_development_dependency(%q<rdoc>.freeze, [">= 0"])
+ else
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
+ s.add_dependency(%q<rake-compiler>.freeze, [">= 0"])
+ s.add_dependency(%q<test-unit>.freeze, ["~> 3.0"])
+ s.add_dependency(%q<rdoc>.freeze, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
+ s.add_dependency(%q<rake-compiler>.freeze, [">= 0"])
+ s.add_dependency(%q<test-unit>.freeze, ["~> 3.0"])
+ s.add_dependency(%q<rdoc>.freeze, [">= 0"])
+ end
end
diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h
index 09998214e1..69a7df71d0 100644
--- a/ext/openssl/openssl_missing.h
+++ b/ext/openssl/openssl_missing.h
@@ -185,7 +185,7 @@ IMPL_KEY_ACCESSOR3(DSA, pqg, p, q, g, (p == obj->p || q == obj->q || g == obj->g
#if !defined(OPENSSL_NO_DH)
IMPL_PKEY_GETTER(DH, dh)
IMPL_KEY_ACCESSOR2(DH, key, pub_key, priv_key, (pub_key == obj->pub_key || (obj->priv_key && priv_key == obj->priv_key)))
-IMPL_KEY_ACCESSOR3(DH, pqg, p, q, g, (p == obj->p || (obj->q && q == obj->q) || g == obj->g))
+IMPL_KEY_ACCESSOR3(DH, pqg, p, q, g, (p == obj->p || obj->q && q == obj->q || g == obj->g))
static inline ENGINE *DH_get0_engine(DH *dh) { return dh->engine; }
#endif
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index e4196f0754..38e650e1a3 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -338,7 +338,7 @@ ossl_clear_error(void)
* implementation.
*/
VALUE
-ossl_get_errors(VALUE _)
+ossl_get_errors(void)
{
VALUE ary;
long e;
@@ -398,7 +398,7 @@ ossl_debug_set(VALUE self, VALUE val)
}
/*
- * call-seq:
+ * call-seq
* OpenSSL.fips_mode -> true | false
*/
static VALUE
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
index 39699bd5e6..5a15839cb4 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -13,8 +13,8 @@
#include RUBY_EXTCONF_H
#include <assert.h>
-#include <ruby.h>
#include <errno.h>
+#include <ruby.h>
#include <ruby/io.h>
#include <ruby/thread.h>
#include <openssl/opensslv.h>
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 0085d4beab..3c048ab926 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -1848,6 +1848,7 @@ do{\
rb_hash_aset(class_tag_map, cASN1GeneralString, INT2NUM(V_ASN1_GENERALSTRING));
rb_hash_aset(class_tag_map, cASN1UniversalString, INT2NUM(V_ASN1_UNIVERSALSTRING));
rb_hash_aset(class_tag_map, cASN1BMPString, INT2NUM(V_ASN1_BMPSTRING));
+ rb_global_variable(&class_tag_map);
id_each = rb_intern_const("each");
}
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index e3846d2df9..4666ce6c2f 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -187,7 +187,6 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
BIGNUM *bn;
VALUE str, bs;
int base = 10;
- char *ptr;
if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) {
base = NUM2INT(bs);
@@ -214,14 +213,12 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
GetBN(self, bn);
switch (base) {
case 0:
- ptr = StringValuePtr(str);
- if (!BN_mpi2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) {
+ if (!BN_mpi2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) {
ossl_raise(eBNError, NULL);
}
break;
case 2:
- ptr = StringValuePtr(str);
- if (!BN_bin2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) {
+ if (!BN_bin2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) {
ossl_raise(eBNError, NULL);
}
break;
@@ -400,7 +397,7 @@ ossl_bn_is_negative(VALUE self)
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
- if (BN_##func(result, bn, ossl_bn_ctx) <= 0) { \
+ if (!BN_##func(result, bn, ossl_bn_ctx)) { \
BN_free(result); \
ossl_raise(eBNError, NULL); \
} \
@@ -426,7 +423,7 @@ BIGNUM_1c(sqr)
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
- if (BN_##func(result, bn1, bn2) <= 0) { \
+ if (!BN_##func(result, bn1, bn2)) { \
BN_free(result); \
ossl_raise(eBNError, NULL); \
} \
@@ -459,7 +456,7 @@ BIGNUM_2(sub)
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
- if (BN_##func(result, bn1, bn2, ossl_bn_ctx) <= 0) { \
+ if (!BN_##func(result, bn1, bn2, ossl_bn_ctx)) { \
BN_free(result); \
ossl_raise(eBNError, NULL); \
} \
@@ -503,21 +500,11 @@ BIGNUM_2c(gcd)
BIGNUM_2c(mod_sqr)
/*
+ * Document-method: OpenSSL::BN#mod_inverse
* call-seq:
- * bn.mod_inverse(bn2) => aBN
+ * bn.mod_inverse(bn2) => aBN
*/
-static VALUE
-ossl_bn_mod_inverse(VALUE self, VALUE other)
-{
- BIGNUM *bn1, *bn2 = GetBNPtr(other), *result;
- VALUE obj;
- GetBN(self, bn1);
- obj = NewBN(rb_obj_class(self));
- if (!(result = BN_mod_inverse(NULL, bn1, bn2, ossl_bn_ctx)))
- ossl_raise(eBNError, "BN_mod_inverse");
- SetBN(obj, result);
- return obj;
-}
+BIGNUM_2c(mod_inverse)
/*
* call-seq:
@@ -566,7 +553,7 @@ ossl_bn_div(VALUE self, VALUE other)
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
- if (BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx) <= 0) { \
+ if (!BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx)) { \
BN_free(result); \
ossl_raise(eBNError, NULL); \
} \
@@ -608,7 +595,7 @@ BIGNUM_3c(mod_exp)
{ \
BIGNUM *bn; \
GetBN(self, bn); \
- if (BN_##func(bn, NUM2INT(bit)) <= 0) { \
+ if (!BN_##func(bn, NUM2INT(bit))) { \
ossl_raise(eBNError, NULL); \
} \
return self; \
@@ -668,7 +655,7 @@ ossl_bn_is_bit_set(VALUE self, VALUE bit)
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
- if (BN_##func(result, bn, b) <= 0) { \
+ if (!BN_##func(result, bn, b)) { \
BN_free(result); \
ossl_raise(eBNError, NULL); \
} \
@@ -698,7 +685,7 @@ BIGNUM_SHIFT(rshift)
int b; \
b = NUM2INT(bits); \
GetBN(self, bn); \
- if (BN_##func(bn, bn, b) <= 0) \
+ if (!BN_##func(bn, bn, b)) \
ossl_raise(eBNError, NULL); \
return self; \
}
@@ -737,7 +724,7 @@ BIGNUM_SELF_SHIFT(rshift)
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
- if (BN_##func(result, b, top, bottom) <= 0) { \
+ if (!BN_##func(result, b, top, bottom)) { \
BN_free(result); \
ossl_raise(eBNError, NULL); \
} \
@@ -766,7 +753,7 @@ BIGNUM_RAND(pseudo_rand)
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
- if (BN_##func##_range(result, bn) <= 0) { \
+ if (!BN_##func##_range(result, bn)) { \
BN_free(result); \
ossl_raise(eBNError, NULL); \
} \
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index 8674a3947c..112ce33647 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -313,6 +313,8 @@ ossl_digest_block_length(VALUE self)
void
Init_ossl_digest(void)
{
+ rb_require("digest");
+
#if 0
mOSSL = rb_define_module("OpenSSL");
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
@@ -431,12 +433,6 @@ Init_ossl_digest(void)
* digest2 = sha256.digest(data2)
*
*/
-
- /*
- * Digest::Class is defined by the digest library. rb_require() cannot be
- * used here because it bypasses RubyGems.
- */
- rb_funcall(Qnil, rb_intern_const("require"), 1, rb_str_new_cstr("digest"));
cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
/* Document-class: OpenSSL::Digest::DigestError
*
diff --git a/ext/openssl/ossl_pkey.h b/ext/openssl/ossl_pkey.h
index 0db59305f7..a2a9fc0df3 100644
--- a/ext/openssl/ossl_pkey.h
+++ b/ext/openssl/ossl_pkey.h
@@ -133,9 +133,9 @@ static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2, VALU
BIGNUM *bn3 = NULL, *orig_bn3 = NIL_P(v3) ? NULL : GetBNPtr(v3);\
\
Get##_type(self, obj); \
- if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
- (orig_bn2 && !(bn2 = BN_dup(orig_bn2))) || \
- (orig_bn3 && !(bn3 = BN_dup(orig_bn3)))) { \
+ if (orig_bn1 && !(bn1 = BN_dup(orig_bn1)) || \
+ orig_bn2 && !(bn2 = BN_dup(orig_bn2)) || \
+ orig_bn3 && !(bn3 = BN_dup(orig_bn3))) { \
BN_clear_free(bn1); \
BN_clear_free(bn2); \
BN_clear_free(bn3); \
@@ -163,8 +163,8 @@ static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2) \
BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
\
Get##_type(self, obj); \
- if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
- (orig_bn2 && !(bn2 = BN_dup(orig_bn2)))) { \
+ if (orig_bn1 && !(bn1 = BN_dup(orig_bn1)) || \
+ orig_bn2 && !(bn2 = BN_dup(orig_bn2))) { \
BN_clear_free(bn1); \
BN_clear_free(bn2); \
ossl_raise(eBNError, NULL); \
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index bf4e3f9322..31f3b8e726 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -262,7 +262,7 @@ ossl_dh_initialize_copy(VALUE self, VALUE other)
BIGNUM *pub2 = BN_dup(pub);
BIGNUM *priv2 = BN_dup(priv);
- if (!pub2 || (priv && !priv2)) {
+ if (!pub2 || priv && !priv2) {
BN_clear_free(pub2);
BN_clear_free(priv2);
ossl_raise(eDHError, "BN_dup");
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c
index b47678dc1d..8bb611248b 100644
--- a/ext/openssl/ossl_pkey_ec.c
+++ b/ext/openssl/ossl_pkey_ec.c
@@ -653,15 +653,15 @@ static VALUE ossl_ec_key_dsa_verify_asn1(VALUE self, VALUE data, VALUE sig)
StringValue(data);
StringValue(sig);
- switch (ECDSA_verify(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data),
- (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), ec)) {
- case 1:
- return Qtrue;
- case 0:
- return Qfalse;
- default:
- ossl_raise(eECError, "ECDSA_verify");
+ switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(sig), (int)RSTRING_LEN(sig), ec)) {
+ case 1: return Qtrue;
+ case 0: return Qfalse;
+ default: break;
}
+
+ ossl_raise(eECError, "ECDSA_verify");
+
+ UNREACHABLE;
}
/*
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
index 4a4f9dd5bf..c95857060a 100644
--- a/ext/openssl/ossl_rand.c
+++ b/ext/openssl/ossl_rand.c
@@ -67,6 +67,8 @@ ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
static VALUE
ossl_rand_load_file(VALUE self, VALUE filename)
{
+ rb_check_safe_obj(filename);
+
if(!RAND_load_file(StringValueCStr(filename), -1)) {
ossl_raise(eRandomError, NULL);
}
@@ -84,6 +86,8 @@ ossl_rand_load_file(VALUE self, VALUE filename)
static VALUE
ossl_rand_write_file(VALUE self, VALUE filename)
{
+ rb_check_safe_obj(filename);
+
if (RAND_write_file(StringValueCStr(filename)) == -1) {
ossl_raise(eRandomError, NULL);
}
@@ -160,6 +164,8 @@ ossl_rand_pseudo_bytes(VALUE self, VALUE len)
static VALUE
ossl_rand_egd(VALUE self, VALUE filename)
{
+ rb_check_safe_obj(filename);
+
if (RAND_egd(StringValueCStr(filename)) == -1) {
ossl_raise(eRandomError, NULL);
}
@@ -180,6 +186,8 @@ ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
{
int n = NUM2INT(len);
+ rb_check_safe_obj(filename);
+
if (RAND_egd_bytes(StringValueCStr(filename), n) == -1) {
ossl_raise(eRandomError, NULL);
}
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index bfd80126c2..a85be17f07 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -13,12 +13,6 @@
#define numberof(ary) (int)(sizeof(ary)/sizeof((ary)[0]))
-#if !defined(TLS1_3_VERSION) && \
- defined(LIBRESSL_VERSION_NUMBER) && \
- LIBRESSL_VERSION_NUMBER >= 0x3020000fL
-# define TLS1_3_VERSION 0x0304
-#endif
-
#ifdef _WIN32
# define TO_SOCKET(s) _get_osfhandle(s)
#else
@@ -39,7 +33,7 @@ static VALUE eSSLErrorWaitReadable;
static VALUE eSSLErrorWaitWritable;
static ID id_call, ID_callback_state, id_tmp_dh_callback, id_tmp_ecdh_callback,
- id_npn_protocols_encoded, id_each;
+ id_npn_protocols_encoded;
static VALUE sym_exception, sym_wait_readable, sym_wait_writable;
static ID id_i_cert_store, id_i_ca_file, id_i_ca_path, id_i_verify_mode,
@@ -60,13 +54,6 @@ static int ossl_sslctx_ex_store_p;
#endif
static void
-ossl_sslctx_mark(void *ptr)
-{
- SSL_CTX *ctx = ptr;
- rb_gc_mark((VALUE)SSL_CTX_get_ex_data(ctx, ossl_sslctx_ex_ptr_idx));
-}
-
-static void
ossl_sslctx_free(void *ptr)
{
SSL_CTX *ctx = ptr;
@@ -80,7 +67,7 @@ ossl_sslctx_free(void *ptr)
static const rb_data_type_t ossl_sslctx_type = {
"OpenSSL/SSL/CTX",
{
- ossl_sslctx_mark, ossl_sslctx_free,
+ 0, ossl_sslctx_free,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
};
@@ -197,10 +184,8 @@ ossl_sslctx_set_minmax_proto_version(VALUE self, VALUE min_v, VALUE max_v)
for (i = 0; i < numberof(options_map); i++) {
sum |= options_map[i].opts;
- if ((min && min > options_map[i].ver) ||
- (max && max < options_map[i].ver)) {
+ if (min && min > options_map[i].ver || max && max < options_map[i].ver)
opts |= options_map[i].opts;
- }
}
SSL_CTX_clear_options(ctx, sum);
SSL_CTX_set_options(ctx, opts);
@@ -372,14 +357,7 @@ ossl_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(status));
return 0;
}
- if (ret != Qtrue) {
- preverify_ok = 0;
-#if defined(X509_V_ERR_HOSTNAME_MISMATCH)
- X509_STORE_CTX_set_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH);
-#else
- X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REJECTED);
-#endif
- }
+ preverify_ok = ret == Qtrue;
}
return ossl_verify_cb_call(cb, preverify_ok, ctx);
@@ -400,7 +378,7 @@ ossl_call_session_get_cb(VALUE ary)
}
static SSL_SESSION *
-#if (!defined(LIBRESSL_VERSION_NUMBER) ? OPENSSL_VERSION_NUMBER >= 0x10100000 : LIBRESSL_VERSION_NUMBER >= 0x2080000f)
+#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
ossl_sslctx_session_get_cb(SSL *ssl, const unsigned char *buf, int len, int *copy)
#else
ossl_sslctx_session_get_cb(SSL *ssl, unsigned char *buf, int len, int *copy)
@@ -612,7 +590,7 @@ ssl_renegotiation_cb(const SSL *ssl)
#if !defined(OPENSSL_NO_NEXTPROTONEG) || \
defined(HAVE_SSL_CTX_SET_ALPN_SELECT_CB)
static VALUE
-ssl_npn_encode_protocol_i(RB_BLOCK_CALL_FUNC_ARGLIST(cur, encoded))
+ssl_npn_encode_protocol_i(VALUE cur, VALUE encoded)
{
int len = RSTRING_LENINT(cur);
char len_byte;
@@ -629,7 +607,7 @@ static VALUE
ssl_encode_npn_protocols(VALUE protocols)
{
VALUE encoded = rb_str_new(NULL, 0);
- rb_block_call(protocols, id_each, 0, 0, ssl_npn_encode_protocol_i, encoded);
+ rb_iterate(rb_each, protocols, ssl_npn_encode_protocol_i, encoded);
return encoded;
}
@@ -699,7 +677,7 @@ static int
ssl_npn_advertise_cb(SSL *ssl, const unsigned char **out, unsigned int *outlen,
void *arg)
{
- VALUE protocols = rb_attr_get((VALUE)arg, id_npn_protocols_encoded);
+ VALUE protocols = (VALUE)arg;
*out = (const unsigned char *) RSTRING_PTR(protocols);
*outlen = RSTRING_LENINT(protocols);
@@ -917,7 +895,7 @@ ossl_sslctx_setup(VALUE self)
if (!NIL_P(val)) {
VALUE encoded = ssl_encode_npn_protocols(val);
rb_ivar_set(self, id_npn_protocols_encoded, encoded);
- SSL_CTX_set_next_protos_advertised_cb(ctx, ssl_npn_advertise_cb, (void *)self);
+ SSL_CTX_set_next_protos_advertised_cb(ctx, ssl_npn_advertise_cb, (void *)encoded);
OSSL_Debug("SSL NPN advertise callback added");
}
if (RTEST(rb_attr_get(self, id_i_npn_select_cb))) {
@@ -1536,14 +1514,6 @@ ssl_started(SSL *ssl)
}
static void
-ossl_ssl_mark(void *ptr)
-{
- SSL *ssl = ptr;
- rb_gc_mark((VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx));
- rb_gc_mark((VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_vcb_idx));
-}
-
-static void
ossl_ssl_free(void *ssl)
{
SSL_free(ssl);
@@ -1552,7 +1522,7 @@ ossl_ssl_free(void *ssl)
const rb_data_type_t ossl_ssl_type = {
"OpenSSL/SSL",
{
- ossl_ssl_mark, ossl_ssl_free,
+ 0, ossl_ssl_free,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
};
@@ -1708,11 +1678,6 @@ ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, VALUE opts)
rb_io_wait_readable(fptr->fd);
continue;
case SSL_ERROR_SYSCALL:
-#ifdef __APPLE__
- /* See ossl_ssl_write_internal() */
- if (errno == EPROTOTYPE)
- continue;
-#endif
if (errno) rb_sys_fail(funcname);
ossl_raise(eSSLError, "%s SYSCALL returned=%d errno=%d state=%s", funcname, ret2, errno, SSL_state_string_long(ssl));
#if defined(SSL_R_CERTIFICATE_VERIFY_FAILED)
@@ -1861,6 +1826,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
else
rb_str_modify_expand(str, ilen - RSTRING_LEN(str));
}
+ OBJ_TAINT(str);
rb_str_set_len(str, 0);
if (ilen == 0)
return str;
@@ -1869,36 +1835,26 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
io = rb_attr_get(self, id_i_io);
GetOpenFile(io, fptr);
if (ssl_started(ssl)) {
- rb_str_locktmp(str);
- for (;;) {
+ for (;;){
nread = SSL_read(ssl, RSTRING_PTR(str), ilen);
switch(ssl_get_error(ssl, nread)){
case SSL_ERROR_NONE:
- rb_str_unlocktmp(str);
goto end;
case SSL_ERROR_ZERO_RETURN:
- rb_str_unlocktmp(str);
if (no_exception_p(opts)) { return Qnil; }
rb_eof_error();
case SSL_ERROR_WANT_WRITE:
- if (nonblock) {
- rb_str_unlocktmp(str);
- if (no_exception_p(opts)) { return sym_wait_writable; }
- write_would_block(nonblock);
- }
+ if (no_exception_p(opts)) { return sym_wait_writable; }
+ write_would_block(nonblock);
rb_io_wait_writable(fptr->fd);
continue;
case SSL_ERROR_WANT_READ:
- if (nonblock) {
- rb_str_unlocktmp(str);
- if (no_exception_p(opts)) { return sym_wait_readable; }
- read_would_block(nonblock);
- }
+ if (no_exception_p(opts)) { return sym_wait_readable; }
+ read_would_block(nonblock);
rb_io_wait_readable(fptr->fd);
continue;
case SSL_ERROR_SYSCALL:
if (!ERR_peek_error()) {
- rb_str_unlocktmp(str);
if (errno)
rb_sys_fail(0);
else {
@@ -1913,32 +1869,19 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
rb_eof_error();
}
}
- /* fall through */
default:
- rb_str_unlocktmp(str);
ossl_raise(eSSLError, "SSL_read");
}
}
}
else {
- ID meth = nonblock ? rb_intern("read_nonblock") : rb_intern("sysread");
-
- rb_warning("SSL session is not started yet.");
-#if defined(RB_PASS_KEYWORDS)
- if (nonblock) {
- VALUE argv[3];
- argv[0] = len;
- argv[1] = str;
- argv[2] = opts;
- return rb_funcallv_kw(io, meth, 3, argv, RB_PASS_KEYWORDS);
- }
-#else
- if (nonblock) {
- return rb_funcall(io, meth, 3, len, str, opts);
- }
-#endif
- else
- return rb_funcall(io, meth, 2, len, str);
+ ID meth = nonblock ? rb_intern("read_nonblock") : rb_intern("sysread");
+
+ rb_warning("SSL session is not started yet.");
+ if (nonblock)
+ return rb_funcall(io, meth, 3, len, str, opts);
+ else
+ return rb_funcall(io, meth, 2, len, str);
}
end:
@@ -1986,21 +1929,21 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
int nwrite = 0;
rb_io_t *fptr;
int nonblock = opts != Qfalse;
- VALUE tmp, io;
+ VALUE io;
- tmp = rb_str_new_frozen(StringValue(str));
+ StringValue(str);
GetSSL(self, ssl);
io = rb_attr_get(self, id_i_io);
GetOpenFile(io, fptr);
if (ssl_started(ssl)) {
- for (;;) {
- int num = RSTRING_LENINT(tmp);
+ for (;;){
+ int num = RSTRING_LENINT(str);
/* SSL_write(3ssl) manpage states num == 0 is undefined */
if (num == 0)
goto end;
- nwrite = SSL_write(ssl, RSTRING_PTR(tmp), num);
+ nwrite = SSL_write(ssl, RSTRING_PTR(str), num);
switch(ssl_get_error(ssl, nwrite)){
case SSL_ERROR_NONE:
goto end;
@@ -2015,16 +1958,6 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
rb_io_wait_readable(fptr->fd);
continue;
case SSL_ERROR_SYSCALL:
-#ifdef __APPLE__
- /*
- * It appears that send syscall can return EPROTOTYPE if the
- * socket is being torn down. Retry to get a proper errno to
- * make the error handling in line with the socket library.
- * [Bug #14713] https://bugs.ruby-lang.org/issues/14713
- */
- if (errno == EPROTOTYPE)
- continue;
-#endif
if (errno) rb_sys_fail(0);
default:
ossl_raise(eSSLError, "SSL_write");
@@ -2035,21 +1968,11 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
ID meth = nonblock ?
rb_intern("write_nonblock") : rb_intern("syswrite");
- rb_warning("SSL session is not started yet.");
-#if defined(RB_PASS_KEYWORDS)
- if (nonblock) {
- VALUE argv[2];
- argv[0] = str;
- argv[1] = opts;
- return rb_funcallv_kw(io, meth, 2, argv, RB_PASS_KEYWORDS);
- }
-#else
- if (nonblock) {
- return rb_funcall(io, meth, 2, str, opts);
- }
-#endif
- else
- return rb_funcall(io, meth, 1, str);
+ rb_warning("SSL session is not started yet.");
+ if (nonblock)
+ return rb_funcall(io, meth, 2, str, opts);
+ else
+ return rb_funcall(io, meth, 1, str);
}
end:
@@ -2992,7 +2915,6 @@ Init_ossl_ssl(void)
id_tmp_dh_callback = rb_intern("tmp_dh_callback");
id_tmp_ecdh_callback = rb_intern("tmp_ecdh_callback");
id_npn_protocols_encoded = rb_intern("npn_protocols_encoded");
- id_each = rb_intern_const("each");
#define DefIVarID(name) do \
id_i_##name = rb_intern("@"#name); while (0)
diff --git a/ext/openssl/ossl_version.h b/ext/openssl/ossl_version.h
index edbd8ce3fa..c162f8c2a8 100644
--- a/ext/openssl/ossl_version.h
+++ b/ext/openssl/ossl_version.h
@@ -10,6 +10,6 @@
#if !defined(_OSSL_VERSION_H_)
#define _OSSL_VERSION_H_
-#define OSSL_VERSION "2.1.3"
+#define OSSL_VERSION "2.1.2"
#endif /* _OSSL_VERSION_H_ */
diff --git a/ext/openssl/ossl_x509.c b/ext/openssl/ossl_x509.c
index 4fc0648614..8a061b0687 100644
--- a/ext/openssl/ossl_x509.c
+++ b/ext/openssl/ossl_x509.c
@@ -44,13 +44,7 @@ Init_ossl_x509(void)
Init_ossl_x509revoked();
Init_ossl_x509store();
- /* Constants are up-to-date with 1.1.1. */
-
- /* Certificate verification error code */
DefX509Const(V_OK);
-#if defined(X509_V_ERR_UNSPECIFIED) /* 1.0.1r, 1.0.2f, 1.1.0 */
- DefX509Const(V_ERR_UNSPECIFIED);
-#endif
DefX509Const(V_ERR_UNABLE_TO_GET_ISSUER_CERT);
DefX509Const(V_ERR_UNABLE_TO_GET_CRL);
DefX509Const(V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
@@ -82,73 +76,8 @@ Init_ossl_x509(void)
DefX509Const(V_ERR_AKID_SKID_MISMATCH);
DefX509Const(V_ERR_AKID_ISSUER_SERIAL_MISMATCH);
DefX509Const(V_ERR_KEYUSAGE_NO_CERTSIGN);
- DefX509Const(V_ERR_UNABLE_TO_GET_CRL_ISSUER);
- DefX509Const(V_ERR_UNHANDLED_CRITICAL_EXTENSION);
- DefX509Const(V_ERR_KEYUSAGE_NO_CRL_SIGN);
- DefX509Const(V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION);
- DefX509Const(V_ERR_INVALID_NON_CA);
- DefX509Const(V_ERR_PROXY_PATH_LENGTH_EXCEEDED);
- DefX509Const(V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE);
- DefX509Const(V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED);
- DefX509Const(V_ERR_INVALID_EXTENSION);
- DefX509Const(V_ERR_INVALID_POLICY_EXTENSION);
- DefX509Const(V_ERR_NO_EXPLICIT_POLICY);
- DefX509Const(V_ERR_DIFFERENT_CRL_SCOPE);
- DefX509Const(V_ERR_UNSUPPORTED_EXTENSION_FEATURE);
- DefX509Const(V_ERR_UNNESTED_RESOURCE);
- DefX509Const(V_ERR_PERMITTED_VIOLATION);
- DefX509Const(V_ERR_EXCLUDED_VIOLATION);
- DefX509Const(V_ERR_SUBTREE_MINMAX);
DefX509Const(V_ERR_APPLICATION_VERIFICATION);
- DefX509Const(V_ERR_UNSUPPORTED_CONSTRAINT_TYPE);
- DefX509Const(V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
- DefX509Const(V_ERR_UNSUPPORTED_NAME_SYNTAX);
- DefX509Const(V_ERR_CRL_PATH_VALIDATION_ERROR);
-#if defined(X509_V_ERR_PATH_LOOP)
- DefX509Const(V_ERR_PATH_LOOP);
-#endif
-#if defined(X509_V_ERR_SUITE_B_INVALID_VERSION)
- DefX509Const(V_ERR_SUITE_B_INVALID_VERSION);
- DefX509Const(V_ERR_SUITE_B_INVALID_ALGORITHM);
- DefX509Const(V_ERR_SUITE_B_INVALID_CURVE);
- DefX509Const(V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM);
- DefX509Const(V_ERR_SUITE_B_LOS_NOT_ALLOWED);
- DefX509Const(V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256);
-#endif
-#if defined(X509_V_ERR_HOSTNAME_MISMATCH)
- DefX509Const(V_ERR_HOSTNAME_MISMATCH);
- DefX509Const(V_ERR_EMAIL_MISMATCH);
- DefX509Const(V_ERR_IP_ADDRESS_MISMATCH);
-#endif
-#if defined(X509_V_ERR_DANE_NO_MATCH)
- DefX509Const(V_ERR_DANE_NO_MATCH);
-#endif
-#if defined(X509_V_ERR_EE_KEY_TOO_SMALL)
- DefX509Const(V_ERR_EE_KEY_TOO_SMALL);
- DefX509Const(V_ERR_CA_KEY_TOO_SMALL);
- DefX509Const(V_ERR_CA_MD_TOO_WEAK);
-#endif
-#if defined(X509_V_ERR_INVALID_CALL)
- DefX509Const(V_ERR_INVALID_CALL);
-#endif
-#if defined(X509_V_ERR_STORE_LOOKUP)
- DefX509Const(V_ERR_STORE_LOOKUP);
-#endif
-#if defined(X509_V_ERR_NO_VALID_SCTS)
- DefX509Const(V_ERR_NO_VALID_SCTS);
-#endif
-#if defined(X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION)
- DefX509Const(V_ERR_PROXY_SUBJECT_NAME_VIOLATION);
-#endif
-#if defined(X509_V_ERR_OCSP_VERIFY_NEEDED)
- DefX509Const(V_ERR_OCSP_VERIFY_NEEDED);
- DefX509Const(V_ERR_OCSP_VERIFY_FAILED);
- DefX509Const(V_ERR_OCSP_CERT_UNKNOWN);
-#endif
- /* Certificate verify flags */
- /* Set by Store#flags= and StoreContext#flags=. */
- DefX509Const(V_FLAG_USE_CHECK_TIME);
/* Set by Store#flags= and StoreContext#flags=. Enables CRL checking for the
* certificate chain leaf. */
DefX509Const(V_FLAG_CRL_CHECK);
@@ -193,26 +122,6 @@ Init_ossl_x509(void)
* Enabled by default in OpenSSL >= 1.1.0. */
DefX509Const(V_FLAG_TRUSTED_FIRST);
#endif
-#if defined(X509_V_FLAG_SUITEB_128_LOS_ONLY)
- /* Set by Store#flags= and StoreContext#flags=.
- * Enables Suite B 128 bit only mode. */
- DefX509Const(V_FLAG_SUITEB_128_LOS_ONLY);
-#endif
-#if defined(X509_V_FLAG_SUITEB_192_LOS)
- /* Set by Store#flags= and StoreContext#flags=.
- * Enables Suite B 192 bit only mode. */
- DefX509Const(V_FLAG_SUITEB_192_LOS);
-#endif
-#if defined(X509_V_FLAG_SUITEB_128_LOS)
- /* Set by Store#flags= and StoreContext#flags=.
- * Enables Suite B 128 bit mode allowing 192 bit algorithms. */
- DefX509Const(V_FLAG_SUITEB_128_LOS);
-#endif
-#if defined(X509_V_FLAG_PARTIAL_CHAIN)
- /* Set by Store#flags= and StoreContext#flags=.
- * Allows partial chains if at least one certificate is in trusted store. */
- DefX509Const(V_FLAG_PARTIAL_CHAIN);
-#endif
#if defined(X509_V_FLAG_NO_ALT_CHAINS)
/* Set by Store#flags= and StoreContext#flags=. Suppresses searching for
* a alternative chain. No effect in OpenSSL >= 1.1.0. */
diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c
index 1ea8400dbb..0053f2e372 100644
--- a/ext/openssl/ossl_x509name.c
+++ b/ext/openssl/ossl_x509name.c
@@ -270,7 +270,7 @@ x509name_print(VALUE self, unsigned long iflag)
if (!out)
ossl_raise(eX509NameError, NULL);
ret = X509_NAME_print_ex(out, name, 0, iflag);
- if (ret < 0 || (iflag == XN_FLAG_COMPAT && ret == 0)) {
+ if (ret < 0 || iflag == XN_FLAG_COMPAT && ret == 0) {
BIO_free(out);
ossl_raise(eX509NameError, "X509_NAME_print_ex");
}
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 9035a70aa9..2909eeda17 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -106,13 +106,6 @@ VALUE cX509StoreContext;
VALUE eX509StoreError;
static void
-ossl_x509store_mark(void *ptr)
-{
- X509_STORE *store = ptr;
- rb_gc_mark((VALUE)X509_STORE_get_ex_data(store, store_ex_verify_cb_idx));
-}
-
-static void
ossl_x509store_free(void *ptr)
{
X509_STORE_free(ptr);
@@ -121,7 +114,7 @@ ossl_x509store_free(void *ptr)
static const rb_data_type_t ossl_x509store_type = {
"OpenSSL/X509/STORE",
{
- ossl_x509store_mark, ossl_x509store_free,
+ 0, ossl_x509store_free,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
};
@@ -311,6 +304,7 @@ ossl_x509store_add_file(VALUE self, VALUE file)
char *path = NULL;
if(file != Qnil){
+ rb_check_safe_obj(file);
path = StringValueCStr(file);
}
GetX509Store(self, store);
@@ -346,6 +340,7 @@ ossl_x509store_add_path(VALUE self, VALUE dir)
char *path = NULL;
if(dir != Qnil){
+ rb_check_safe_obj(dir);
path = StringValueCStr(dir);
}
GetX509Store(self, store);
@@ -464,15 +459,22 @@ ossl_x509store_verify(int argc, VALUE *argv, VALUE self)
}
/*
- * Private functions
+ * Public Functions
*/
-static void
-ossl_x509stctx_mark(void *ptr)
-{
- X509_STORE_CTX *ctx = ptr;
- rb_gc_mark((VALUE)X509_STORE_CTX_get_ex_data(ctx, stctx_ex_verify_cb_idx));
-}
+static void ossl_x509stctx_free(void*);
+
+static const rb_data_type_t ossl_x509stctx_type = {
+ "OpenSSL/X509/STORE_CTX",
+ {
+ 0, ossl_x509stctx_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Private functions
+ */
static void
ossl_x509stctx_free(void *ptr)
{
@@ -484,14 +486,6 @@ ossl_x509stctx_free(void *ptr)
X509_STORE_CTX_free(ctx);
}
-static const rb_data_type_t ossl_x509stctx_type = {
- "OpenSSL/X509/STORE_CTX",
- {
- ossl_x509stctx_mark, ossl_x509stctx_free,
- },
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
-};
-
static VALUE
ossl_x509stctx_alloc(VALUE klass)
{
@@ -525,9 +519,7 @@ static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
/*
* call-seq:
- * StoreContext.new(store, cert = nil, untrusted = nil)
- *
- * Sets up a StoreContext for a verification of the X.509 certificate _cert_.
+ * StoreContext.new(store, cert = nil, chain = nil)
*/
static VALUE
ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
@@ -537,24 +529,15 @@ ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
X509_STORE *x509st;
X509 *x509 = NULL;
STACK_OF(X509) *x509s = NULL;
- int state;
rb_scan_args(argc, argv, "12", &store, &cert, &chain);
GetX509StCtx(self, ctx);
GetX509Store(store, x509st);
- if (!NIL_P(cert))
- x509 = DupX509CertPtr(cert); /* NEED TO DUP */
- if (!NIL_P(chain)) {
- x509s = ossl_protect_x509_ary2sk(chain, &state);
- if (state) {
- X509_free(x509);
- rb_jump_tag(state);
- }
- }
- if (X509_STORE_CTX_init(ctx, x509st, x509, x509s) != 1){
- X509_free(x509);
+ if(!NIL_P(cert)) x509 = DupX509CertPtr(cert); /* NEED TO DUP */
+ if(!NIL_P(chain)) x509s = ossl_x509_ary2sk(chain);
+ if(X509_STORE_CTX_init(ctx, x509st, x509, x509s) != 1){
sk_X509_pop_free(x509s, X509_free);
- ossl_raise(eX509StoreError, "X509_STORE_CTX_init");
+ ossl_raise(eX509StoreError, NULL);
}
if (!NIL_P(t = rb_iv_get(store, "@time")))
ossl_x509stctx_set_time(self, t);
diff --git a/ext/pathname/depend b/ext/pathname/depend
index 1e13dd5f37..42abd32130 100644
--- a/ext/pathname/depend
+++ b/ext/pathname/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
pathname.o: $(RUBY_EXTCONF_H)
pathname.o: $(arch_hdrdir)/ruby/config.h
-pathname.o: $(hdrdir)/ruby.h
-pathname.o: $(hdrdir)/ruby/assert.h
pathname.o: $(hdrdir)/ruby/backward.h
pathname.o: $(hdrdir)/ruby/defines.h
pathname.o: $(hdrdir)/ruby/encoding.h
@@ -13,5 +11,6 @@ pathname.o: $(hdrdir)/ruby/oniguruma.h
pathname.o: $(hdrdir)/ruby/ruby.h
pathname.o: $(hdrdir)/ruby/st.h
pathname.o: $(hdrdir)/ruby/subst.h
+pathname.o: $(top_srcdir)/include/ruby.h
pathname.o: pathname.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/pathname/extconf.rb b/ext/pathname/extconf.rb
index 84e68277aa..c9133bc153 100644
--- a/ext/pathname/extconf.rb
+++ b/ext/pathname/extconf.rb
@@ -1,4 +1,4 @@
# frozen_string_literal: false
require 'mkmf'
-have_func("rb_file_s_birthtime")
+have_struct_member("struct stat", "st_birthtimespec", "sys/stat.h")
create_makefile('pathname')
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index dc4a7c0220..ed7d8c791b 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -40,7 +40,7 @@ class Pathname
# chop_basename(path) -> [pre-basename, basename] or nil
def chop_basename(path) # :nodoc:
base = File.basename(path)
- if /\A#{SEPARATOR_PAT}?\z/o.match?(base)
+ if /\A#{SEPARATOR_PAT}?\z/o =~ base
return nil
else
return path[0, path.rindex(base)], base
@@ -62,7 +62,7 @@ class Pathname
def prepend_prefix(prefix, relpath) # :nodoc:
if relpath.empty?
File.dirname(prefix)
- elsif /#{SEPARATOR_PAT}/o.match?(prefix)
+ elsif /#{SEPARATOR_PAT}/o =~ prefix
prefix = File.dirname(prefix)
prefix = File.join(prefix, "") if File.basename(prefix + 'a') != 'a'
prefix + relpath
@@ -113,7 +113,7 @@ class Pathname
end
end
pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
- if /#{SEPARATOR_PAT}/o.match?(File.basename(pre))
+ if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
names.shift while names[0] == '..'
end
self.class.new(prepend_prefix(pre, File.join(*names)))
@@ -162,7 +162,7 @@ class Pathname
names.unshift base if base != '.'
end
pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
- if /#{SEPARATOR_PAT}/o.match?(File.basename(pre))
+ if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
names.shift while names[0] == '..'
end
if names.empty?
@@ -193,7 +193,8 @@ class Pathname
begin
stat1 = self.lstat
stat2 = self.parent.lstat
- stat1.dev != stat2.dev || stat1.ino == stat2.ino
+ stat1.dev == stat2.dev && stat1.ino == stat2.ino ||
+ stat1.dev != stat2.dev
rescue Errno::ENOENT
false
end
@@ -207,7 +208,7 @@ class Pathname
# pathnames which points to roots such as <tt>/usr/..</tt>.
#
def root?
- chop_basename(@path) == nil && /#{SEPARATOR_PAT}/o.match?(@path)
+ !!(chop_basename(@path) == nil && /#{SEPARATOR_PAT}/o =~ @path)
end
# Predicate method for testing whether a path is absolute.
@@ -379,7 +380,7 @@ class Pathname
basename_list2.shift
end
r1 = chop_basename(prefix1)
- if !r1 && (r1 = /#{SEPARATOR_PAT}/o.match?(File.basename(prefix1)))
+ if !r1 && (r1 = /#{SEPARATOR_PAT}/o =~ File.basename(prefix1))
while !basename_list2.empty? && basename_list2.first == '..'
index_list2.shift
basename_list2.shift
@@ -503,7 +504,6 @@ class Pathname
# ArgumentError is raised when it cannot find a relative path.
#
def relative_path_from(base_directory)
- base_directory = Pathname.new(base_directory) unless base_directory.is_a? Pathname
dest_directory = self.cleanpath.to_s
base_directory = base_directory.cleanpath.to_s
dest_prefix = dest_directory
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 0f4854580e..2d74e9cf80 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -110,6 +110,7 @@ path_initialize(VALUE self, VALUE arg)
str = rb_obj_dup(str);
set_strpath(self, str);
+ OBJ_INFECT(self, str);
return self;
}
@@ -133,12 +134,15 @@ path_freeze(VALUE self)
* call-seq:
* pathname.taint -> obj
*
- * Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
+ * Taints this Pathname.
+ *
+ * See Object.taint.
*/
static VALUE
path_taint(VALUE self)
{
- rb_warning("Pathname#taint is deprecated and will be removed in Ruby 3.2.");
+ rb_call_super(0, 0);
+ rb_obj_taint(get_strpath(self));
return self;
}
@@ -146,12 +150,15 @@ path_taint(VALUE self)
* call-seq:
* pathname.untaint -> obj
*
- * Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
+ * Untaints this Pathname.
+ *
+ * See Object.untaint.
*/
static VALUE
path_untaint(VALUE self)
{
- rb_warning("Pathname#untaint is deprecated and will be removed in Ruby 3.2.");
+ rb_call_super(0, 0);
+ rb_obj_untaint(get_strpath(self));
return self;
}
@@ -301,6 +308,7 @@ path_sub_ext(VALUE self, VALUE repl)
}
str2 = rb_str_subseq(str, 0, ext-p);
rb_str_append(str2, repl);
+ OBJ_INFECT(str2, str);
return rb_class_new_instance(1, &str2, rb_obj_class(self));
}
@@ -360,10 +368,10 @@ path_each_line(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cFile, id_foreach, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
+ return rb_block_call(rb_cIO, id_foreach, 1+n, args, 0, 0);
}
else {
- return rb_funcallv_kw(rb_cFile, id_foreach, 1+n, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_funcallv(rb_cIO, id_foreach, 1+n, args);
}
}
@@ -374,7 +382,7 @@ path_each_line(int argc, VALUE *argv, VALUE self)
*
* Returns all data from the file, or the first +N+ bytes if specified.
*
- * See File.read.
+ * See IO.read.
*
*/
static VALUE
@@ -385,7 +393,7 @@ path_read(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_read, 1+n, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_funcallv(rb_cIO, id_read, 1+n, args);
}
/*
@@ -394,7 +402,7 @@ path_read(int argc, VALUE *argv, VALUE self)
*
* Returns all the bytes from the file, or the first +N+ if specified.
*
- * See File.binread.
+ * See IO.binread.
*
*/
static VALUE
@@ -405,7 +413,7 @@ path_binread(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
- return rb_funcallv(rb_cFile, id_binread, 1+n, args);
+ return rb_funcallv(rb_cIO, id_binread, 1+n, args);
}
/*
@@ -415,7 +423,7 @@ path_binread(int argc, VALUE *argv, VALUE self)
*
* Writes +contents+ to the file.
*
- * See File.write.
+ * See IO.write.
*
*/
static VALUE
@@ -426,7 +434,7 @@ path_write(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_write, 1+n, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_funcallv(rb_cIO, id_write, 1+n, args);
}
/*
@@ -436,7 +444,7 @@ path_write(int argc, VALUE *argv, VALUE self)
*
* Writes +contents+ to the file, opening it in binary mode.
*
- * See File.binwrite.
+ * See IO.binwrite.
*
*/
static VALUE
@@ -447,7 +455,7 @@ path_binwrite(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_binwrite, 1+n, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_funcallv(rb_cIO, id_binwrite, 1+n, args);
}
/*
@@ -458,7 +466,7 @@ path_binwrite(int argc, VALUE *argv, VALUE self)
*
* Returns all the lines from the file.
*
- * See File.readlines.
+ * See IO.readlines.
*
*/
static VALUE
@@ -469,7 +477,7 @@ path_readlines(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_readlines, 1+n, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_funcallv(rb_cIO, id_readlines, 1+n, args);
}
/*
@@ -504,7 +512,7 @@ path_atime(VALUE self)
return rb_funcall(rb_cFile, id_atime, 1, get_strpath(self));
}
-#if defined(HAVE_RB_FILE_S_BIRTHTIME)
+#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC) || defined(_WIN32)
/*
* call-seq:
* pathname.birthtime -> time
@@ -520,7 +528,6 @@ path_birthtime(VALUE self)
return rb_funcall(rb_cFile, id_birthtime, 1, get_strpath(self));
}
#else
-/* check at compilation time for `respond_to?` */
# define path_birthtime rb_f_notimplement
#endif
@@ -670,10 +677,10 @@ path_open(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cFile, id_open, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
+ return rb_block_call(rb_cFile, id_open, 1+n, args, 0, 0);
}
else {
- return rb_funcallv_kw(rb_cFile, id_open, 1+n, args, RB_PASS_CALLED_KEYWORDS);
+ return rb_funcallv(rb_cFile, id_open, 1+n, args);
}
}
@@ -1084,17 +1091,17 @@ s_glob_i(RB_BLOCK_CALL_FUNC_ARGLIST(elt, klass))
static VALUE
path_s_glob(int argc, VALUE *argv, VALUE klass)
{
- VALUE args[3];
+ VALUE args[2];
int n;
- n = rb_scan_args(argc, argv, "12", &args[0], &args[1], &args[2]);
+ n = rb_scan_args(argc, argv, "11", &args[0], &args[1]);
if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cDir, id_glob, n, args, s_glob_i, klass, RB_PASS_CALLED_KEYWORDS);
+ return rb_block_call(rb_cDir, id_glob, n, args, s_glob_i, klass);
}
else {
VALUE ary;
long i;
- ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_CALLED_KEYWORDS);
+ ary = rb_funcallv(rb_cDir, id_glob, n, args);
ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
for (i = 0; i < RARRAY_LEN(ary); i++) {
VALUE elt = RARRAY_AREF(ary, i);
@@ -1137,12 +1144,12 @@ path_glob(int argc, VALUE *argv, VALUE self)
n = 3;
if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cDir, id_glob, n, args, glob_i, self, RB_PASS_KEYWORDS);
+ return rb_block_call(rb_cDir, id_glob, n, args, glob_i, self);
}
else {
VALUE ary;
long i;
- ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_KEYWORDS);
+ ary = rb_funcallv(rb_cDir, id_glob, n, args);
ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
for (i = 0; i < RARRAY_LEN(ary); i++) {
VALUE elt = RARRAY_AREF(ary, i);
@@ -1315,8 +1322,6 @@ path_unlink(VALUE self)
static VALUE
path_f_pathname(VALUE self, VALUE str)
{
- if (CLASS_OF(str) == rb_cPathname)
- return str;
return rb_class_new_instance(1, &str, rb_cPathname);
}
diff --git a/ext/psych/.gitignore b/ext/psych/.gitignore
new file mode 100644
index 0000000000..836058c169
--- /dev/null
+++ b/ext/psych/.gitignore
@@ -0,0 +1,11 @@
+/api.c
+/config.h
+/dumper.c
+/emitter.c
+/loader.c
+/parser.c
+/reader.c
+/scanner.c
+/writer.c
+/yaml.h
+/yaml_private.h
diff --git a/ext/psych/depend b/ext/psych/depend
index dc358eaed3..c5ca1f6b13 100644
--- a/ext/psych/depend
+++ b/ext/psych/depend
@@ -1,10 +1,6 @@
-$(OBJS): $(YAML_H)
-
# AUTOGENERATED DEPENDENCIES START
psych.o: $(RUBY_EXTCONF_H)
psych.o: $(arch_hdrdir)/ruby/config.h
-psych.o: $(hdrdir)/ruby.h
-psych.o: $(hdrdir)/ruby/assert.h
psych.o: $(hdrdir)/ruby/backward.h
psych.o: $(hdrdir)/ruby/defines.h
psych.o: $(hdrdir)/ruby/encoding.h
@@ -15,6 +11,7 @@ psych.o: $(hdrdir)/ruby/oniguruma.h
psych.o: $(hdrdir)/ruby/ruby.h
psych.o: $(hdrdir)/ruby/st.h
psych.o: $(hdrdir)/ruby/subst.h
+psych.o: $(top_srcdir)/include/ruby.h
psych.o: psych.c
psych.o: psych.h
psych.o: psych_emitter.h
@@ -23,8 +20,6 @@ psych.o: psych_to_ruby.h
psych.o: psych_yaml_tree.h
psych_emitter.o: $(RUBY_EXTCONF_H)
psych_emitter.o: $(arch_hdrdir)/ruby/config.h
-psych_emitter.o: $(hdrdir)/ruby.h
-psych_emitter.o: $(hdrdir)/ruby/assert.h
psych_emitter.o: $(hdrdir)/ruby/backward.h
psych_emitter.o: $(hdrdir)/ruby/defines.h
psych_emitter.o: $(hdrdir)/ruby/encoding.h
@@ -35,6 +30,7 @@ psych_emitter.o: $(hdrdir)/ruby/oniguruma.h
psych_emitter.o: $(hdrdir)/ruby/ruby.h
psych_emitter.o: $(hdrdir)/ruby/st.h
psych_emitter.o: $(hdrdir)/ruby/subst.h
+psych_emitter.o: $(top_srcdir)/include/ruby.h
psych_emitter.o: psych.h
psych_emitter.o: psych_emitter.c
psych_emitter.o: psych_emitter.h
@@ -43,8 +39,6 @@ psych_emitter.o: psych_to_ruby.h
psych_emitter.o: psych_yaml_tree.h
psych_parser.o: $(RUBY_EXTCONF_H)
psych_parser.o: $(arch_hdrdir)/ruby/config.h
-psych_parser.o: $(hdrdir)/ruby.h
-psych_parser.o: $(hdrdir)/ruby/assert.h
psych_parser.o: $(hdrdir)/ruby/backward.h
psych_parser.o: $(hdrdir)/ruby/defines.h
psych_parser.o: $(hdrdir)/ruby/encoding.h
@@ -55,6 +49,7 @@ psych_parser.o: $(hdrdir)/ruby/oniguruma.h
psych_parser.o: $(hdrdir)/ruby/ruby.h
psych_parser.o: $(hdrdir)/ruby/st.h
psych_parser.o: $(hdrdir)/ruby/subst.h
+psych_parser.o: $(top_srcdir)/include/ruby.h
psych_parser.o: psych.h
psych_parser.o: psych_emitter.h
psych_parser.o: psych_parser.c
@@ -63,8 +58,6 @@ psych_parser.o: psych_to_ruby.h
psych_parser.o: psych_yaml_tree.h
psych_to_ruby.o: $(RUBY_EXTCONF_H)
psych_to_ruby.o: $(arch_hdrdir)/ruby/config.h
-psych_to_ruby.o: $(hdrdir)/ruby.h
-psych_to_ruby.o: $(hdrdir)/ruby/assert.h
psych_to_ruby.o: $(hdrdir)/ruby/backward.h
psych_to_ruby.o: $(hdrdir)/ruby/defines.h
psych_to_ruby.o: $(hdrdir)/ruby/encoding.h
@@ -75,6 +68,7 @@ psych_to_ruby.o: $(hdrdir)/ruby/oniguruma.h
psych_to_ruby.o: $(hdrdir)/ruby/ruby.h
psych_to_ruby.o: $(hdrdir)/ruby/st.h
psych_to_ruby.o: $(hdrdir)/ruby/subst.h
+psych_to_ruby.o: $(top_srcdir)/include/ruby.h
psych_to_ruby.o: psych.h
psych_to_ruby.o: psych_emitter.h
psych_to_ruby.o: psych_parser.h
@@ -83,8 +77,6 @@ psych_to_ruby.o: psych_to_ruby.h
psych_to_ruby.o: psych_yaml_tree.h
psych_yaml_tree.o: $(RUBY_EXTCONF_H)
psych_yaml_tree.o: $(arch_hdrdir)/ruby/config.h
-psych_yaml_tree.o: $(hdrdir)/ruby.h
-psych_yaml_tree.o: $(hdrdir)/ruby/assert.h
psych_yaml_tree.o: $(hdrdir)/ruby/backward.h
psych_yaml_tree.o: $(hdrdir)/ruby/defines.h
psych_yaml_tree.o: $(hdrdir)/ruby/encoding.h
@@ -95,6 +87,7 @@ psych_yaml_tree.o: $(hdrdir)/ruby/oniguruma.h
psych_yaml_tree.o: $(hdrdir)/ruby/ruby.h
psych_yaml_tree.o: $(hdrdir)/ruby/st.h
psych_yaml_tree.o: $(hdrdir)/ruby/subst.h
+psych_yaml_tree.o: $(top_srcdir)/include/ruby.h
psych_yaml_tree.o: psych.h
psych_yaml_tree.o: psych_emitter.h
psych_yaml_tree.o: psych_parser.h
diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb
index 857f8e68c4..6d8390ebe5 100644
--- a/ext/psych/extconf.rb
+++ b/ext/psych/extconf.rb
@@ -13,10 +13,8 @@ if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_li
$VPATH << "$(srcdir)/yaml"
$INCFLAGS << " -I$(srcdir)/yaml"
- $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}.sort
+ $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}
- header = 'yaml/yaml.h'
- header = "{$(VPATH)}#{header}" if $nmake
if have_macro("_WIN32")
$CPPFLAGS << " -DYAML_DECLARE_STATIC -DHAVE_CONFIG_H"
end
@@ -36,8 +34,6 @@ if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_li
have_header 'config.h'
end
-create_makefile 'psych' do |mk|
- mk << "YAML_H = #{header}".strip << "\n"
-end
+create_makefile 'psych'
# :startdoc:
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index c719b036d0..a4d5a96dce 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -3,14 +3,13 @@ require 'psych/versions'
case RUBY_ENGINE
when 'jruby'
require 'psych_jars'
- if JRuby::Util.respond_to?(:load_ext)
- JRuby::Util.load_ext('org.jruby.ext.psych.PsychLibrary')
- else
- require 'java'; require 'jruby'
- org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false)
- end
+ org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false)
else
- require 'psych.so'
+ begin
+ require "#{RUBY_VERSION[/\d+\.\d+/]}/psych.so"
+ rescue LoadError
+ require 'psych.so'
+ end
end
require 'psych/nodes'
require 'psych/streaming'
@@ -32,7 +31,7 @@ require 'psych/class_loader'
# = Overview
#
# Psych is a YAML parser and emitter.
-# Psych leverages libyaml [Home page: https://pyyaml.org/wiki/LibYAML]
+# Psych leverages libyaml [Home page: http://pyyaml.org/wiki/LibYAML]
# or [HG repo: https://bitbucket.org/xi/libyaml] for its YAML parsing
# and emitting capabilities. In addition to wrapping libyaml, Psych also
# knows how to serialize and de-serialize most Ruby objects to and from
@@ -231,16 +230,14 @@ require 'psych/class_loader'
module Psych
# The version of libyaml Psych is using
LIBYAML_VERSION = Psych.libyaml_version.join '.'
- # Deprecation guard
- NOT_GIVEN = Object.new
- private_constant :NOT_GIVEN
+
+ FALLBACK = Struct.new :to_ruby # :nodoc:
###
# Load +yaml+ in to a Ruby data structure. If multiple documents are
# provided, the object contained in the first document will be returned.
- # +filename+ will be used in the exception message if any exception
- # is raised while parsing. If +yaml+ is empty, it returns
- # the specified +fallback+ return value, which defaults to +false+.
+ # +filename+ will be used in the exception message if any exception is raised
+ # while parsing.
#
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
#
@@ -250,7 +247,7 @@ module Psych
# Psych.load("---\n - a\n - b") # => ['a', 'b']
#
# begin
- # Psych.load("--- `", filename: "file.txt")
+ # Psych.load("--- `", "file.txt")
# rescue Psych::SyntaxError => ex
# ex.file # => 'file.txt'
# ex.message # => "(file.txt): found character that cannot start any token"
@@ -262,20 +259,8 @@ module Psych
# Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
# Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
#
- # Raises a TypeError when `yaml` parameter is NilClass
- #
- # NOTE: This method *should not* be used to parse untrusted documents, such as
- # YAML documents that are supplied via user input. Instead, please use the
- # safe_load method.
- #
- def self.load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false
- if legacy_filename != NOT_GIVEN
- warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load is deprecated. Use keyword argument like Psych.load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
- filename = legacy_filename
- end
-
- result = parse(yaml, filename: filename)
- return fallback unless result
+ def self.load yaml, filename = nil, fallback: false, symbolize_names: false
+ result = parse(yaml, filename, fallback: fallback)
result = result.to_ruby if result
symbolize_names!(result) if symbolize_names
result
@@ -294,27 +279,27 @@ module Psych
# * Hash
#
# Recursive data structures are not allowed by default. Arbitrary classes
- # can be allowed by adding those classes to the +permitted_classes+ keyword argument. They are
+ # can be allowed by adding those classes to the +whitelist+. They are
# additive. For example, to allow Date deserialization:
#
- # Psych.safe_load(yaml, permitted_classes: [Date])
+ # Psych.safe_load(yaml, [Date])
#
# Now the Date class can be loaded in addition to the classes listed above.
#
- # Aliases can be explicitly allowed by changing the +aliases+ keyword argument.
+ # Aliases can be explicitly allowed by changing the +aliases+ parameter.
# For example:
#
# x = []
# x << x
# yaml = Psych.dump x
# Psych.safe_load yaml # => raises an exception
- # Psych.safe_load yaml, aliases: true # => loads the aliases
+ # Psych.safe_load yaml, [], [], true # => loads the aliases
#
# A Psych::DisallowedClass exception will be raised if the yaml contains a
- # class that isn't in the +permitted_classes+ list.
+ # class that isn't in the whitelist.
#
# A Psych::BadAlias exception will be raised if the yaml contains aliases
- # but the +aliases+ keyword argument is set to false.
+ # but the +aliases+ parameter is set to false.
#
# +filename+ will be used in the exception message if any exception is raised
# while parsing.
@@ -325,38 +310,18 @@ module Psych
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
#
- def self.safe_load yaml, legacy_permitted_classes = NOT_GIVEN, legacy_permitted_symbols = NOT_GIVEN, legacy_aliases = NOT_GIVEN, legacy_filename = NOT_GIVEN, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false
- if legacy_permitted_classes != NOT_GIVEN
- warn_with_uplevel 'Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.', uplevel: 1 if $VERBOSE
- permitted_classes = legacy_permitted_classes
- end
-
- if legacy_permitted_symbols != NOT_GIVEN
- warn_with_uplevel 'Passing permitted_symbols with the 3rd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_symbols: ...) instead.', uplevel: 1 if $VERBOSE
- permitted_symbols = legacy_permitted_symbols
- end
-
- if legacy_aliases != NOT_GIVEN
- warn_with_uplevel 'Passing aliases with the 4th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, aliases: ...) instead.', uplevel: 1 if $VERBOSE
- aliases = legacy_aliases
- end
-
- if legacy_filename != NOT_GIVEN
- warn_with_uplevel 'Passing filename with the 5th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
- filename = legacy_filename
- end
-
- result = parse(yaml, filename: filename)
- return fallback unless result
+ def self.safe_load yaml, whitelist_classes = [], whitelist_symbols = [], aliases = false, filename = nil, symbolize_names: false
+ result = parse(yaml, filename)
+ return unless result
- class_loader = ClassLoader::Restricted.new(permitted_classes.map(&:to_s),
- permitted_symbols.map(&:to_s))
+ class_loader = ClassLoader::Restricted.new(whitelist_classes.map(&:to_s),
+ whitelist_symbols.map(&:to_s))
scanner = ScalarScanner.new class_loader
- visitor = if aliases
- Visitors::ToRuby.new scanner, class_loader
- else
- Visitors::NoAliasRuby.new scanner, class_loader
- end
+ if aliases
+ visitor = Visitors::ToRuby.new scanner, class_loader
+ else
+ visitor = Visitors::NoAliasRuby.new scanner, class_loader
+ end
result = visitor.accept result
symbolize_names!(result) if symbolize_names
result
@@ -374,40 +339,28 @@ module Psych
# Psych.parse("---\n - a\n - b") # => #<Psych::Nodes::Document:0x00>
#
# begin
- # Psych.parse("--- `", filename: "file.txt")
+ # Psych.parse("--- `", "file.txt")
# rescue Psych::SyntaxError => ex
# ex.file # => 'file.txt'
# ex.message # => "(file.txt): found character that cannot start any token"
# end
#
# See Psych::Nodes for more information about YAML AST.
- def self.parse yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: NOT_GIVEN
- if legacy_filename != NOT_GIVEN
- warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse is deprecated. Use keyword argument like Psych.parse(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
- filename = legacy_filename
- end
-
- parse_stream(yaml, filename: filename) do |node|
+ def self.parse yaml, filename = nil, fallback: false
+ parse_stream(yaml, filename) do |node|
return node
end
-
- if fallback != NOT_GIVEN
- warn_with_uplevel 'Passing the `fallback` keyword argument of Psych.parse is deprecated.', uplevel: 1 if $VERBOSE
- fallback
- else
- false
- end
+ fallback
end
###
# Parse a file at +filename+. Returns the Psych::Nodes::Document.
#
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
- def self.parse_file filename, fallback: false
- result = File.open filename, 'r:bom|utf-8' do |f|
- parse f, filename: filename
+ def self.parse_file filename
+ File.open filename, 'r:bom|utf-8' do |f|
+ parse f, filename
end
- result || fallback
end
###
@@ -436,21 +389,14 @@ module Psych
# end
#
# begin
- # Psych.parse_stream("--- `", filename: "file.txt")
+ # Psych.parse_stream("--- `", "file.txt")
# rescue Psych::SyntaxError => ex
# ex.file # => 'file.txt'
# ex.message # => "(file.txt): found character that cannot start any token"
# end
#
- # Raises a TypeError when NilClass is passed.
- #
# See Psych::Nodes for more information about YAML AST.
- def self.parse_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, &block
- if legacy_filename != NOT_GIVEN
- warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse_stream is deprecated. Use keyword argument like Psych.parse_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
- filename = legacy_filename
- end
-
+ def self.parse_stream yaml, filename = nil, &block
if block_given?
parser = Psych::Parser.new(Handlers::DocumentStream.new(&block))
parser.parse yaml, filename
@@ -472,24 +418,6 @@ module Psych
# to control the output format. If an IO object is passed in, the YAML will
# be dumped to that IO object.
#
- # Currently supported options are:
- #
- # [<tt>:indentation</tt>] Number of space characters used to indent.
- # Acceptable value should be in <tt>0..9</tt> range,
- # otherwise option is ignored.
- #
- # Default: <tt>2</tt>.
- # [<tt>:line_width</tt>] Max character to wrap line at.
- #
- # Default: <tt>0</tt> (meaning "wrap at 81").
- # [<tt>:canonical</tt>] Write "canonical" YAML form (very verbose, yet
- # strictly formal).
- #
- # Default: <tt>false</tt>.
- # [<tt>:header</tt>] Write <tt>%YAML [version]</tt> at the beginning of document.
- #
- # Default: <tt>false</tt>.
- #
# Example:
#
# # Dump an array, get back a YAML string
@@ -499,10 +427,10 @@ module Psych
# Psych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>
#
# # Dump an array with indentation set
- # Psych.dump(['a', ['b']], indentation: 3) # => "---\n- a\n- - b\n"
+ # Psych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n"
#
# # Dump an array to an IO with indentation set
- # Psych.dump(['a', ['b']], StringIO.new, indentation: 3)
+ # Psych.dump(['a', ['b']], StringIO.new, :indentation => 3)
def self.dump o, io = nil, options = {}
if Hash === io
options = io
@@ -551,31 +479,23 @@ module Psych
# end
# list # => ['foo', 'bar']
#
- def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: []
- if legacy_filename != NOT_GIVEN
- warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load_stream is deprecated. Use keyword argument like Psych.load_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
- filename = legacy_filename
+ def self.load_stream yaml, filename = nil
+ if block_given?
+ parse_stream(yaml, filename) do |node|
+ yield node.to_ruby
+ end
+ else
+ parse_stream(yaml, filename).children.map { |child| child.to_ruby }
end
-
- result = if block_given?
- parse_stream(yaml, filename: filename) do |node|
- yield node.to_ruby
- end
- else
- parse_stream(yaml, filename: filename).children.map(&:to_ruby)
- end
-
- return fallback if result.is_a?(Array) && result.empty?
- result
end
###
# Load the document contained in +filename+. Returns the yaml contained in
# +filename+ as a Ruby object, or if the file is empty, it returns
- # the specified +fallback+ return value, which defaults to +false+.
+ # the specified default return value, which defaults to an empty Hash
def self.load_file filename, fallback: false
File.open(filename, 'r:bom|utf-8') { |f|
- self.load f, filename: filename, fallback: fallback
+ self.load f, filename, fallback: FALLBACK.new(fallback)
}
end
@@ -617,21 +537,6 @@ module Psych
end
private_class_method :symbolize_names!
- # Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
- def self.warn_with_uplevel(message, uplevel: 1)
- at = parse_caller(caller[uplevel]).join(':')
- warn "#{at}: #{message}"
- end
-
- def self.parse_caller(at)
- if /^(.+?):(\d+)(?::in `.*')?/ =~ at
- file = $1
- line = $2.to_i
- [file, line]
- end
- end
- private_class_method :warn_with_uplevel, :parse_caller
-
class << self
attr_accessor :load_tags
attr_accessor :dump_tags
diff --git a/ext/psych/lib/psych/handler.rb b/ext/psych/lib/psych/handler.rb
index 8f23e366fa..84a3b4f2bc 100644
--- a/ext/psych/lib/psych/handler.rb
+++ b/ext/psych/lib/psych/handler.rb
@@ -105,7 +105,7 @@ module Psych
# - first element
# - *ponies
#
- # &ponies is the anchor, *ponies is the alias. In this case, alias is
+ # &ponies is the achor, *ponies is the alias. In this case, alias is
# called with "ponies".
def alias anchor
end
diff --git a/ext/psych/lib/psych/nodes/alias.rb b/ext/psych/lib/psych/nodes/alias.rb
index 6da655f0fd..8131a4befb 100644
--- a/ext/psych/lib/psych/nodes/alias.rb
+++ b/ext/psych/lib/psych/nodes/alias.rb
@@ -14,8 +14,6 @@ module Psych
def initialize anchor
@anchor = anchor
end
-
- def alias?; true; end
end
end
end
diff --git a/ext/psych/lib/psych/nodes/document.rb b/ext/psych/lib/psych/nodes/document.rb
index f57410d636..3cd418eaf3 100644
--- a/ext/psych/lib/psych/nodes/document.rb
+++ b/ext/psych/lib/psych/nodes/document.rb
@@ -56,8 +56,6 @@ module Psych
def root
children.first
end
-
- def document?; true; end
end
end
end
diff --git a/ext/psych/lib/psych/nodes/mapping.rb b/ext/psych/lib/psych/nodes/mapping.rb
index d49678cb0e..b921ddc862 100644
--- a/ext/psych/lib/psych/nodes/mapping.rb
+++ b/ext/psych/lib/psych/nodes/mapping.rb
@@ -52,8 +52,6 @@ module Psych
@implicit = implicit
@style = style
end
-
- def mapping?; true; end
end
end
end
diff --git a/ext/psych/lib/psych/nodes/node.rb b/ext/psych/lib/psych/nodes/node.rb
index f59fb8916b..6d86669a17 100644
--- a/ext/psych/lib/psych/nodes/node.rb
+++ b/ext/psych/lib/psych/nodes/node.rb
@@ -63,13 +63,6 @@ module Psych
io
end
alias :to_yaml :yaml
-
- def alias?; false; end
- def document?; false; end
- def mapping?; false; end
- def scalar?; false; end
- def sequence?; false; end
- def stream?; false; end
end
end
end
diff --git a/ext/psych/lib/psych/nodes/scalar.rb b/ext/psych/lib/psych/nodes/scalar.rb
index e2616b6a84..b448858831 100644
--- a/ext/psych/lib/psych/nodes/scalar.rb
+++ b/ext/psych/lib/psych/nodes/scalar.rb
@@ -63,8 +63,6 @@ module Psych
@quoted = quoted
@style = style
end
-
- def scalar?; true; end
end
end
end
diff --git a/ext/psych/lib/psych/nodes/sequence.rb b/ext/psych/lib/psych/nodes/sequence.rb
index 740f1938a4..77c2c602b9 100644
--- a/ext/psych/lib/psych/nodes/sequence.rb
+++ b/ext/psych/lib/psych/nodes/sequence.rb
@@ -77,8 +77,6 @@ module Psych
@implicit = implicit
@style = style
end
-
- def sequence?; true; end
end
end
end
diff --git a/ext/psych/lib/psych/nodes/stream.rb b/ext/psych/lib/psych/nodes/stream.rb
index b525217821..2474fe62c4 100644
--- a/ext/psych/lib/psych/nodes/stream.rb
+++ b/ext/psych/lib/psych/nodes/stream.rb
@@ -33,8 +33,6 @@ module Psych
super()
@encoding = encoding
end
-
- def stream?; true; end
end
end
end
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb
index cea2a453dd..29c156c212 100644
--- a/ext/psych/lib/psych/scalar_scanner.rb
+++ b/ext/psych/lib/psych/scalar_scanner.rb
@@ -14,15 +14,16 @@ module Psych
|\.(nan|NaN|NAN)(?# not a number))$/x
# Taken from http://yaml.org/type/int.html
- INTEGER = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
- |[-+]?0[0-7_,]+ (?# base 8)
- |[-+]?(?:0|[1-9][0-9_,]*) (?# base 10)
- |[-+]?0x[0-9a-fA-F_,]+ (?# base 16))$/x
+ INTEGER = /^(?:[-+]?0b[0-1_]+ (?# base 2)
+ |[-+]?0[0-7_]+ (?# base 8)
+ |[-+]?(?:0|[1-9][0-9_]*) (?# base 10)
+ |[-+]?0x[0-9a-fA-F_]+ (?# base 16))$/x
attr_reader :class_loader
# Create a new scanner
def initialize class_loader
+ @string_cache = {}
@symbol_cache = {}
@class_loader = class_loader
end
@@ -30,70 +31,81 @@ module Psych
# Tokenize +string+ returning the Ruby object
def tokenize string
return nil if string.empty?
+ return string if @string_cache.key?(string)
return @symbol_cache[string] if @symbol_cache.key?(string)
+ case string
# Check for a String type, being careful not to get caught by hash keys, hex values, and
# special floats (e.g., -.inf).
- if string.match?(/^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/) || string.match?(/\n/)
- return string if string.length > 5
+ when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/, /\n/
+ if string.length > 5
+ @string_cache[string] = true
+ return string
+ end
- if string.match?(/^[^ytonf~]/i)
+ case string
+ when /^[^ytonf~]/i
+ @string_cache[string] = true
string
- elsif string == '~' || string.match?(/^null$/i)
+ when '~', /^null$/i
nil
- elsif string.match?(/^(yes|true|on)$/i)
+ when /^(yes|true|on)$/i
true
- elsif string.match?(/^(no|false|off)$/i)
+ when /^(no|false|off)$/i
false
else
+ @string_cache[string] = true
string
end
- elsif string.match?(TIME)
+ when TIME
begin
parse_time string
rescue ArgumentError
string
end
- elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
+ when /^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/
require 'date'
begin
class_loader.date.strptime(string, '%Y-%m-%d')
rescue ArgumentError
string
end
- elsif string.match?(/^\.inf$/i)
+ when /^\.inf$/i
Float::INFINITY
- elsif string.match?(/^-\.inf$/i)
+ when /^-\.inf$/i
-Float::INFINITY
- elsif string.match?(/^\.nan$/i)
+ when /^\.nan$/i
Float::NAN
- elsif string.match?(/^:./)
+ when /^:./
if string =~ /^:(["'])(.*)\1/
@symbol_cache[string] = class_loader.symbolize($2.sub(/^:/, ''))
else
@symbol_cache[string] = class_loader.symbolize(string.sub(/^:/, ''))
end
- elsif string.match?(/^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}$/)
+ when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}$/
i = 0
string.split(':').each_with_index do |n,e|
i += (n.to_i * 60 ** (e - 2).abs)
end
i
- elsif string.match?(/^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}\.[0-9_]*$/)
+ when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}\.[0-9_]*$/
i = 0
string.split(':').each_with_index do |n,e|
i += (n.to_f * 60 ** (e - 2).abs)
end
i
- elsif string.match?(FLOAT)
- if string.match?(/\A[-+]?\.\Z/)
+ when FLOAT
+ if string =~ /\A[-+]?\.\Z/
+ @string_cache[string] = true
string
else
Float(string.gsub(/[,_]|\.([Ee]|$)/, '\1'))
end
- elsif string.match?(INTEGER)
- parse_int string
else
+ int = parse_int string.gsub(/[,_]/, '')
+ return int if int
+
+ @string_cache[string] = true
string
end
end
@@ -101,7 +113,8 @@ module Psych
###
# Parse and return an int from +string+
def parse_int string
- Integer(string.gsub(/[,]/, ''))
+ return unless INTEGER === string
+ Integer(string)
end
###
diff --git a/ext/psych/lib/psych/versions.rb b/ext/psych/lib/psych/versions.rb
index 731ba9545e..33993ec837 100644
--- a/ext/psych/lib/psych/versions.rb
+++ b/ext/psych/lib/psych/versions.rb
@@ -1,10 +1,9 @@
-
# frozen_string_literal: true
module Psych
- # The version of Psych you are using
- VERSION = '3.1.0' unless defined?(::Psych::VERSION)
+ # The version is Psych you're using
+ VERSION = '3.0.2'
if RUBY_ENGINE == 'jruby'
- DEFAULT_SNAKEYAML_VERSION = '1.23'.freeze
+ DEFAULT_SNAKEYAML_VERSION = '1.18'.freeze
end
end
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index b72fb4a1dc..74a52df866 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -252,8 +252,6 @@ module Psych
e = build_exception((resolve_class($1) || class_loader.exception),
h.delete('message'))
-
- e.set_backtrace h.delete('backtrace') if h.key? 'backtrace'
init_with(e, h, o)
when '!set', 'tag:yaml.org,2002:set'
@@ -336,7 +334,7 @@ module Psych
SHOVEL = '<<'
def revive_hash hash, o
o.children.each_slice(2) { |k,v|
- key = deduplicate(accept(k))
+ key = accept(k)
val = accept(v)
if key == SHOVEL && k.tag != "tag:yaml.org,2002:str"
@@ -368,24 +366,6 @@ module Psych
hash
end
- if RUBY_VERSION < '2.7'
- def deduplicate key
- if key.is_a?(String)
- -(key.untaint)
- else
- key
- end
- end
- else
- def deduplicate key
- if key.is_a?(String)
- -key
- else
- key
- end
- end
- end
-
def merge_key hash, key, val
end
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 79ca129b83..cfed8f1814 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -181,11 +181,41 @@ module Psych
end
def visit_Exception o
- dump_exception o, private_iv_get(o, 'mesg')
+ tag = ['!ruby/exception', o.class.name].join ':'
+
+ @emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
+
+ {
+ 'message' => private_iv_get(o, 'mesg'),
+ 'backtrace' => private_iv_get(o, 'backtrace'),
+ }.each do |k,v|
+ next unless v
+ @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
+ accept v
+ end
+
+ dump_ivars o
+
+ @emitter.end_mapping
end
def visit_NameError o
- dump_exception o, o.message.to_s
+ tag = ['!ruby/exception', o.class.name].join ':'
+
+ @emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
+
+ {
+ 'message' => o.message.to_s,
+ 'backtrace' => private_iv_get(o, 'backtrace'),
+ }.each do |k,v|
+ next unless v
+ @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
+ accept v
+ end
+
+ dump_ivars o
+
+ @emitter.end_mapping
end
def visit_Regexp o
@@ -428,15 +458,6 @@ module Psych
node = @emitter.start_mapping(nil, tag, false, Psych::Nodes::Mapping::BLOCK)
register(o, node)
- # Dump the ivars
- accept 'ivars'
- @emitter.start_mapping nil, nil, true, Nodes::Mapping::BLOCK
- o.instance_variables.each do |ivar|
- accept ivar
- accept o.instance_variable_get ivar
- end
- @emitter.end_mapping
-
# Dump the elements
accept 'elements'
@emitter.start_mapping nil, nil, true, Nodes::Mapping::BLOCK
@@ -446,6 +467,15 @@ module Psych
end
@emitter.end_mapping
+ # Dump the ivars
+ accept 'ivars'
+ @emitter.start_mapping nil, nil, true, Nodes::Mapping::BLOCK
+ o.instance_variables.each do |ivar|
+ accept ivar
+ accept o.instance_variable_get ivar
+ end
+ @emitter.end_mapping
+
@emitter.end_mapping
else
tag = "!ruby/hash:#{o.class}"
@@ -462,24 +492,6 @@ module Psych
def dump_list o
end
- def dump_exception o, msg
- tag = ['!ruby/exception', o.class.name].join ':'
-
- @emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
-
- if msg
- @emitter.scalar 'message', nil, nil, true, false, Nodes::Scalar::ANY
- accept msg
- end
-
- @emitter.scalar 'backtrace', nil, nil, true, false, Nodes::Scalar::ANY
- accept o.backtrace
-
- dump_ivars o
-
- @emitter.end_mapping
- end
-
def format_time time
if time.utc?
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec
index e0168af7d8..2254d46829 100644
--- a/ext/psych/psych.gemspec
+++ b/ext/psych/psych.gemspec
@@ -1,21 +1,15 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true
-begin
- require_relative 'lib/psych/versions'
-rescue LoadError
- # for Ruby core repository
- require_relative 'versions'
-end
-
Gem::Specification.new do |s|
s.name = "psych"
- s.version = Psych::VERSION
+ s.version = "3.0.2"
s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org", "headius@headius.com"]
+ s.date = "2017-12-04"
s.summary = "Psych is a YAML parser and emitter"
s.description = <<-DESCRIPTION
-Psych is a YAML parser and emitter. Psych leverages libyaml[https://pyyaml.org/wiki/LibYAML]
+Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
for its YAML parsing and emitting capabilities. In addition to wrapping libyaml,
Psych also knows how to serialize and de-serialize most Ruby objects to and from the YAML format.
DESCRIPTION
@@ -25,8 +19,8 @@ DESCRIPTION
# for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
s.files = [
- ".gitignore", ".travis.yml", "Gemfile", "Mavenfile", "README.md", "Rakefile", "bin/console",
- "bin/setup", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
+ ".gitignore", ".travis.yml", "CHANGELOG.rdoc", "Gemfile", "Mavenfile", "README.md", "Rakefile", "bin/console",
+ "bin/setup", "ext/psych/.gitignore", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
"ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h",
"ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h",
"ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c",
@@ -45,26 +39,26 @@ DESCRIPTION
]
s.rdoc_options = ["--main", "README.md"]
- s.extra_rdoc_files = ["README.md"]
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md"]
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
+ s.required_ruby_version = Gem::Requirement.new(">= 2.2.2")
s.rubygems_version = "2.5.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0")
+ s.add_development_dependency 'rake-compiler', ">= 0.4.1"
+ s.add_development_dependency 'minitest', "~> 5.0"
+
if RUBY_ENGINE == 'jruby'
s.platform = 'java'
s.files.concat [
- "ext/java/org/jruby/ext/psych/PsychEmitter.java",
- "ext/java/org/jruby/ext/psych/PsychLibrary.java",
- "ext/java/org/jruby/ext/psych/PsychParser.java",
- "ext/java/org/jruby/ext/psych/PsychToRuby.java",
- "ext/java/org/jruby/ext/psych/PsychYamlTree.java",
- "lib/psych_jars.rb",
- "lib/psych.jar"
+ "ext/java/PsychEmitter.java", "ext/java/PsychLibrary.java", "ext/java/PsychParser.java", "ext/java/PsychToRuby.java",
+ "ext/java/PsychYamlTree.java", "lib/psych_jars.rb", "lib/psych.jar"
]
- s.requirements = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}"
+ s.requirements = "jar org.yaml:snakeyaml, 1.18"
s.add_dependency 'jar-dependencies', '>= 0.1.7'
+ s.add_development_dependency 'ruby-maven'
else
s.extensions = ["ext/psych/extconf.rb"]
+ s.add_development_dependency 'rake-compiler-dock', ">= 0.6.1"
end
end
diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c
index 022ffa0946..55bd417004 100644
--- a/ext/psych/psych_emitter.c
+++ b/ext/psych/psych_emitter.c
@@ -521,7 +521,6 @@ static VALUE set_line_width(VALUE self, VALUE width)
void Init_psych_emitter(void)
{
-#undef rb_intern
VALUE psych = rb_define_module("Psych");
VALUE handler = rb_define_class_under(psych, "Handler", rb_cObject);
cPsychEmitter = rb_define_class_under(psych, "Emitter", handler);
diff --git a/ext/psych/psych_parser.c b/ext/psych/psych_parser.c
index fb1a917bb2..ca196ddba4 100644
--- a/ext/psych/psych_parser.c
+++ b/ext/psych/psych_parser.c
@@ -1,6 +1,7 @@
#include <psych.h>
VALUE cPsychParser;
+VALUE ePsychSyntaxError;
static ID id_read;
static ID id_path;
@@ -80,13 +81,10 @@ static VALUE allocate(VALUE klass)
static VALUE make_exception(yaml_parser_t * parser, VALUE path)
{
size_t line, column;
- VALUE ePsychSyntaxError;
line = parser->context_mark.line + 1;
column = parser->context_mark.column + 1;
- ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
-
return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6,
path,
INT2NUM(line),
@@ -256,6 +254,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
yaml_parser_t * parser;
yaml_event_t event;
int done = 0;
+ int tainted = 0;
int state = 0;
int parser_encoding = YAML_ANY_ENCODING;
int encoding = rb_utf8_encindex();
@@ -274,10 +273,13 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
yaml_parser_delete(parser);
yaml_parser_initialize(parser);
+ if (OBJ_TAINTED(yaml)) tainted = 1;
+
if (rb_respond_to(yaml, id_read)) {
yaml = transcode_io(yaml, &parser_encoding);
yaml_parser_set_encoding(parser, parser_encoding);
yaml_parser_set_input(parser, io_reader, (void *)yaml);
+ if (RTEST(rb_obj_is_kind_of(yaml, rb_cIO))) tainted = 1;
} else {
StringValue(yaml);
yaml = transcode_string(yaml, &parser_encoding);
@@ -348,11 +350,13 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
VALUE prefix = Qnil;
if(start->handle) {
handle = rb_str_new2((const char *)start->handle);
+ if (tainted) OBJ_TAINT(handle);
PSYCH_TRANSCODE(handle, encoding, internal_enc);
}
if(start->prefix) {
prefix = rb_str_new2((const char *)start->prefix);
+ if (tainted) OBJ_TAINT(prefix);
PSYCH_TRANSCODE(prefix, encoding, internal_enc);
}
@@ -381,6 +385,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
VALUE alias = Qnil;
if(event.data.alias.anchor) {
alias = rb_str_new2((const char *)event.data.alias.anchor);
+ if (tainted) OBJ_TAINT(alias);
PSYCH_TRANSCODE(alias, encoding, internal_enc);
}
@@ -399,16 +404,19 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
(const char *)event.data.scalar.value,
(long)event.data.scalar.length
);
+ if (tainted) OBJ_TAINT(val);
PSYCH_TRANSCODE(val, encoding, internal_enc);
if(event.data.scalar.anchor) {
anchor = rb_str_new2((const char *)event.data.scalar.anchor);
+ if (tainted) OBJ_TAINT(anchor);
PSYCH_TRANSCODE(anchor, encoding, internal_enc);
}
if(event.data.scalar.tag) {
tag = rb_str_new2((const char *)event.data.scalar.tag);
+ if (tainted) OBJ_TAINT(tag);
PSYCH_TRANSCODE(tag, encoding, internal_enc);
}
@@ -438,12 +446,14 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
VALUE implicit, style;
if(event.data.sequence_start.anchor) {
anchor = rb_str_new2((const char *)event.data.sequence_start.anchor);
+ if (tainted) OBJ_TAINT(anchor);
PSYCH_TRANSCODE(anchor, encoding, internal_enc);
}
tag = Qnil;
if(event.data.sequence_start.tag) {
tag = rb_str_new2((const char *)event.data.sequence_start.tag);
+ if (tainted) OBJ_TAINT(tag);
PSYCH_TRANSCODE(tag, encoding, internal_enc);
}
@@ -472,11 +482,13 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
VALUE implicit, style;
if(event.data.mapping_start.anchor) {
anchor = rb_str_new2((const char *)event.data.mapping_start.anchor);
+ if (tainted) OBJ_TAINT(anchor);
PSYCH_TRANSCODE(anchor, encoding, internal_enc);
}
if(event.data.mapping_start.tag) {
tag = rb_str_new2((const char *)event.data.mapping_start.tag);
+ if (tainted) OBJ_TAINT(tag);
PSYCH_TRANSCODE(tag, encoding, internal_enc);
}
@@ -536,7 +548,6 @@ static VALUE mark(VALUE self)
void Init_psych_parser(void)
{
-#undef rb_intern
#if 0
mPsych = rb_define_module("Psych");
#endif
@@ -557,6 +568,7 @@ void Init_psych_parser(void)
rb_define_const(cPsychParser, "UTF16BE", INT2NUM(YAML_UTF16BE_ENCODING));
rb_require("psych/syntax_error");
+ ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
rb_define_method(cPsychParser, "parse", parse, -1);
rb_define_method(cPsychParser, "mark", mark, 0);
diff --git a/ext/psych/yaml/api.c b/ext/psych/yaml/api.c
index 95dc6b4de3..b1a8da0bda 100644
--- a/ext/psych/yaml/api.c
+++ b/ext/psych/yaml/api.c
@@ -74,7 +74,7 @@ YAML_DECLARE(int)
yaml_string_extend(yaml_char_t **start,
yaml_char_t **pointer, yaml_char_t **end)
{
- yaml_char_t *new_start = (yaml_char_t *)yaml_realloc((void*)*start, (*end - *start)*2);
+ yaml_char_t *new_start = yaml_realloc(*start, (*end - *start)*2);
if (!new_start) return 0;
@@ -94,9 +94,8 @@ yaml_string_extend(yaml_char_t **start,
YAML_DECLARE(int)
yaml_string_join(
yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
- yaml_char_t **b_start, yaml_char_t **b_pointer, SHIM(yaml_char_t **b_end))
+ yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end)
{
- UNUSED_PARAM(b_end)
if (*b_start == *b_pointer)
return 1;
@@ -178,17 +177,17 @@ yaml_parser_initialize(yaml_parser_t *parser)
goto error;
if (!BUFFER_INIT(parser, parser->buffer, INPUT_BUFFER_SIZE))
goto error;
- if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE, yaml_token_t*))
+ if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE))
goto error;
- if (!STACK_INIT(parser, parser->indents, int*))
+ if (!STACK_INIT(parser, parser->indents, INITIAL_STACK_SIZE))
goto error;
- if (!STACK_INIT(parser, parser->simple_keys, yaml_simple_key_t*))
+ if (!STACK_INIT(parser, parser->simple_keys, INITIAL_STACK_SIZE))
goto error;
- if (!STACK_INIT(parser, parser->states, yaml_parser_state_t*))
+ if (!STACK_INIT(parser, parser->states, INITIAL_STACK_SIZE))
goto error;
- if (!STACK_INIT(parser, parser->marks, yaml_mark_t*))
+ if (!STACK_INIT(parser, parser->marks, INITIAL_STACK_SIZE))
goto error;
- if (!STACK_INIT(parser, parser->tag_directives, yaml_tag_directive_t*))
+ if (!STACK_INIT(parser, parser->tag_directives, INITIAL_STACK_SIZE))
goto error;
return 1;
@@ -244,7 +243,7 @@ static int
yaml_string_read_handler(void *data, unsigned char *buffer, size_t size,
size_t *size_read)
{
- yaml_parser_t *parser = (yaml_parser_t *)data;
+ yaml_parser_t *parser = data;
if (parser->input.string.current == parser->input.string.end) {
*size_read = 0;
@@ -270,7 +269,7 @@ static int
yaml_file_read_handler(void *data, unsigned char *buffer, size_t size,
size_t *size_read)
{
- yaml_parser_t *parser = (yaml_parser_t *)data;
+ yaml_parser_t *parser = data;
*size_read = fread(buffer, 1, size, parser->input.file);
return !ferror(parser->input.file);
@@ -356,13 +355,13 @@ yaml_emitter_initialize(yaml_emitter_t *emitter)
goto error;
if (!BUFFER_INIT(emitter, emitter->raw_buffer, OUTPUT_RAW_BUFFER_SIZE))
goto error;
- if (!STACK_INIT(emitter, emitter->states, yaml_emitter_state_t*))
+ if (!STACK_INIT(emitter, emitter->states, INITIAL_STACK_SIZE))
goto error;
- if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE, yaml_event_t*))
+ if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE))
goto error;
- if (!STACK_INIT(emitter, emitter->indents, int*))
+ if (!STACK_INIT(emitter, emitter->indents, INITIAL_STACK_SIZE))
goto error;
- if (!STACK_INIT(emitter, emitter->tag_directives, yaml_tag_directive_t*))
+ if (!STACK_INIT(emitter, emitter->tag_directives, INITIAL_STACK_SIZE))
goto error;
return 1;
@@ -414,7 +413,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter)
static int
yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
{
- yaml_emitter_t *emitter = (yaml_emitter_t *)data;
+ yaml_emitter_t *emitter = data;
if (emitter->output.string.size - *emitter->output.string.size_written
< size) {
@@ -440,7 +439,7 @@ yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
static int
yaml_file_write_handler(void *data, unsigned char *buffer, size_t size)
{
- yaml_emitter_t *emitter = (yaml_emitter_t *)data;
+ yaml_emitter_t *emitter = data;
return (fwrite(buffer, 1, size, emitter->output.file) == size);
}
@@ -718,7 +717,7 @@ yaml_document_start_event_initialize(yaml_event_t *event,
/* Valid tag directives are expected. */
if (version_directive) {
- version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
+ version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t));
if (!version_directive_copy) goto error;
version_directive_copy->major = version_directive->major;
version_directive_copy->minor = version_directive->minor;
@@ -726,7 +725,7 @@ yaml_document_start_event_initialize(yaml_event_t *event,
if (tag_directives_start != tag_directives_end) {
yaml_tag_directive_t *tag_directive;
- if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
+ if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
goto error;
for (tag_directive = tag_directives_start;
tag_directive != tag_directives_end; tag_directive ++) {
@@ -840,11 +839,11 @@ yaml_scalar_event_initialize(yaml_event_t *event,
}
if (length < 0) {
- length = (int)strlen((char *)value);
+ length = strlen((char *)value);
}
if (!yaml_check_utf8(value, length)) goto error;
- value_copy = YAML_MALLOC(length+1);
+ value_copy = yaml_malloc(length+1);
if (!value_copy) goto error;
memcpy(value_copy, value, length);
value_copy[length] = '\0';
@@ -1056,10 +1055,10 @@ yaml_document_initialize(yaml_document_t *document,
(tag_directives_start == tag_directives_end));
/* Valid tag directives are expected. */
- if (!STACK_INIT(&context, nodes, yaml_node_t*)) goto error;
+ if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error;
if (version_directive) {
- version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
+ version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t));
if (!version_directive_copy) goto error;
version_directive_copy->major = version_directive->major;
version_directive_copy->minor = version_directive->minor;
@@ -1067,7 +1066,7 @@ yaml_document_initialize(yaml_document_t *document,
if (tag_directives_start != tag_directives_end) {
yaml_tag_directive_t *tag_directive;
- if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
+ if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
goto error;
for (tag_directive = tag_directives_start;
tag_directive != tag_directives_end; tag_directive ++) {
@@ -1122,9 +1121,7 @@ yaml_document_delete(yaml_document_t *document)
} context;
yaml_tag_directive_t *tag_directive;
- /* Eliminate a compliler warning. */
- context.error = YAML_NO_ERROR;
- (void)context.error;
+ context.error = YAML_NO_ERROR; /* Eliminate a compliler warning. */
assert(document); /* Non-NULL document object is expected. */
@@ -1218,11 +1215,11 @@ yaml_document_add_scalar(yaml_document_t *document,
if (!tag_copy) goto error;
if (length < 0) {
- length = (int)strlen((char *)value);
+ length = strlen((char *)value);
}
if (!yaml_check_utf8(value, length)) goto error;
- value_copy = YAML_MALLOC(length+1);
+ value_copy = yaml_malloc(length+1);
if (!value_copy) goto error;
memcpy(value_copy, value, length);
value_copy[length] = '\0';
@@ -1230,7 +1227,7 @@ yaml_document_add_scalar(yaml_document_t *document,
SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark);
if (!PUSH(&context, document->nodes, node)) goto error;
- return (int)(document->nodes.top - document->nodes.start);
+ return document->nodes.top - document->nodes.start;
error:
yaml_free(tag_copy);
@@ -1269,13 +1266,13 @@ yaml_document_add_sequence(yaml_document_t *document,
tag_copy = yaml_strdup(tag);
if (!tag_copy) goto error;
- if (!STACK_INIT(&context, items, yaml_node_item_t*)) goto error;
+ if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error;
SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
style, mark, mark);
if (!PUSH(&context, document->nodes, node)) goto error;
- return (int)(document->nodes.top - document->nodes.start);
+ return document->nodes.top - document->nodes.start;
error:
STACK_DEL(&context, items);
@@ -1314,13 +1311,13 @@ yaml_document_add_mapping(yaml_document_t *document,
tag_copy = yaml_strdup(tag);
if (!tag_copy) goto error;
- if (!STACK_INIT(&context, pairs, yaml_node_pair_t*)) goto error;
+ if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error;
MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
style, mark, mark);
if (!PUSH(&context, document->nodes, node)) goto error;
- return (int)(document->nodes.top - document->nodes.start);
+ return document->nodes.top - document->nodes.start;
error:
STACK_DEL(&context, pairs);
diff --git a/ext/psych/yaml/config.h b/ext/psych/yaml/config.h
index da905133ff..79e8501f4f 100644
--- a/ext/psych/yaml/config.h
+++ b/ext/psych/yaml/config.h
@@ -1,10 +1,10 @@
#define PACKAGE_NAME "yaml"
#define PACKAGE_TARNAME "yaml"
-#define PACKAGE_VERSION "0.2.1"
-#define PACKAGE_STRING "yaml 0.2.1"
+#define PACKAGE_VERSION "0.1.7"
+#define PACKAGE_STRING "yaml 0.1.7"
#define PACKAGE_BUGREPORT "https://github.com/yaml/libyaml/issues"
#define PACKAGE_URL "https://github.com/yaml/libyaml"
#define YAML_VERSION_MAJOR 0
-#define YAML_VERSION_MINOR 2
-#define YAML_VERSION_PATCH 1
-#define YAML_VERSION_STRING "0.2.1"
+#define YAML_VERSION_MINOR 1
+#define YAML_VERSION_PATCH 7
+#define YAML_VERSION_STRING "0.1.7"
diff --git a/ext/psych/yaml/dumper.c b/ext/psych/yaml/dumper.c
index 29fb9c0784..203c6a709c 100644
--- a/ext/psych/yaml/dumper.c
+++ b/ext/psych/yaml/dumper.c
@@ -245,9 +245,9 @@ yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index)
#define ANCHOR_TEMPLATE_LENGTH 16
static yaml_char_t *
-yaml_emitter_generate_anchor(SHIM(yaml_emitter_t *emitter), int anchor_id)
+yaml_emitter_generate_anchor(yaml_emitter_t *emitter, int anchor_id)
{
- yaml_char_t *anchor = YAML_MALLOC(ANCHOR_TEMPLATE_LENGTH);
+ yaml_char_t *anchor = yaml_malloc(ANCHOR_TEMPLATE_LENGTH);
if (!anchor) return NULL;
diff --git a/ext/psych/yaml/emitter.c b/ext/psych/yaml/emitter.c
index 92e21cdb73..580a8d2123 100644
--- a/ext/psych/yaml/emitter.c
+++ b/ext/psych/yaml/emitter.c
@@ -24,7 +24,7 @@
*/
#define PUT_BREAK(emitter) \
- (FLUSH(emitter) ? \
+ (FLUSH(emitter) ? \
((emitter->line_break == YAML_CR_BREAK ? \
(*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \
emitter->line_break == YAML_LN_BREAK ? \
@@ -1002,7 +1002,7 @@ yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
*/
static int
-yaml_emitter_emit_alias(yaml_emitter_t *emitter, SHIM(yaml_event_t *event))
+yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event)
{
if (!yaml_emitter_process_anchor(emitter))
return 0;
@@ -1087,7 +1087,7 @@ yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event)
*/
static int
-yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter))
+yaml_emitter_check_empty_document(yaml_emitter_t *emitter)
{
return 0;
}
@@ -1234,7 +1234,7 @@ yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event)
}
/*
- * Write an anchor.
+ * Write an achor.
*/
static int
@@ -1946,6 +1946,10 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
emitter->whitespace = 0;
emitter->indention = 0;
+ if (emitter->root_context)
+ {
+ emitter->open_ended = 1;
+ }
return 1;
}
@@ -2322,3 +2326,4 @@ yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
return 1;
}
+
diff --git a/ext/psych/yaml/loader.c b/ext/psych/yaml/loader.c
index e5d90be9bc..3ba99f087e 100644
--- a/ext/psych/yaml/loader.c
+++ b/ext/psych/yaml/loader.c
@@ -72,7 +72,7 @@ yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document)
assert(document); /* Non-NULL document object is expected. */
memset(document, 0, sizeof(yaml_document_t));
- if (!STACK_INIT(parser, document->nodes, yaml_node_t*))
+ if (!STACK_INIT(parser, document->nodes, INITIAL_STACK_SIZE))
goto error;
if (!parser->stream_start_produced) {
@@ -90,7 +90,7 @@ yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document)
return 1;
}
- if (!STACK_INIT(parser, parser->aliases, yaml_alias_data_t*))
+ if (!STACK_INIT(parser, parser->aliases, INITIAL_STACK_SIZE))
goto error;
parser->document = document;
@@ -300,7 +300,7 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
if (!PUSH(parser, parser->document->nodes, node)) goto error;
- index = (int)(parser->document->nodes.top - parser->document->nodes.start);
+ index = parser->document->nodes.top - parser->document->nodes.start;
if (!yaml_parser_register_anchor(parser, index,
first_event->data.scalar.anchor)) return 0;
@@ -339,7 +339,7 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
if (!tag) goto error;
}
- if (!STACK_INIT(parser, items, yaml_node_item_t*)) goto error;
+ if (!STACK_INIT(parser, items, INITIAL_STACK_SIZE)) goto error;
SEQUENCE_NODE_INIT(node, tag, items.start, items.end,
first_event->data.sequence_start.style,
@@ -347,7 +347,7 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
if (!PUSH(parser, parser->document->nodes, node)) goto error;
- index = (int)(parser->document->nodes.top - parser->document->nodes.start);
+ index = parser->document->nodes.top - parser->document->nodes.start;
if (!yaml_parser_register_anchor(parser, index,
first_event->data.sequence_start.anchor)) return 0;
@@ -402,7 +402,7 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
if (!tag) goto error;
}
- if (!STACK_INIT(parser, pairs, yaml_node_pair_t*)) goto error;
+ if (!STACK_INIT(parser, pairs, INITIAL_STACK_SIZE)) goto error;
MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end,
first_event->data.mapping_start.style,
@@ -410,7 +410,7 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
if (!PUSH(parser, parser->document->nodes, node)) goto error;
- index = (int)(parser->document->nodes.top - parser->document->nodes.start);
+ index = parser->document->nodes.top - parser->document->nodes.start;
if (!yaml_parser_register_anchor(parser, index,
first_event->data.mapping_start.anchor)) return 0;
diff --git a/ext/psych/yaml/parser.c b/ext/psych/yaml/parser.c
index 621f676bf2..32671b252c 100644
--- a/ext/psych/yaml/parser.c
+++ b/ext/psych/yaml/parser.c
@@ -605,7 +605,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
size_t prefix_len = strlen((char *)tag_directive->prefix);
size_t suffix_len = strlen((char *)tag_suffix);
- tag = YAML_MALLOC(prefix_len+suffix_len+1);
+ tag = yaml_malloc(prefix_len+suffix_len+1);
if (!tag) {
parser->error = YAML_MEMORY_ERROR;
goto error;
@@ -685,7 +685,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
return 1;
}
else if (anchor || tag) {
- yaml_char_t *value = YAML_MALLOC(1);
+ yaml_char_t *value = yaml_malloc(1);
if (!value) {
parser->error = YAML_MEMORY_ERROR;
goto error;
@@ -1208,7 +1208,7 @@ yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event,
{
yaml_char_t *value;
- value = YAML_MALLOC(1);
+ value = yaml_malloc(1);
if (!value) {
parser->error = YAML_MEMORY_ERROR;
return 0;
@@ -1245,7 +1245,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
} tag_directives = { NULL, NULL, NULL };
yaml_token_t *token;
- if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
+ if (!STACK_INIT(parser, tag_directives, INITIAL_STACK_SIZE))
goto error;
token = PEEK_TOKEN(parser);
@@ -1266,7 +1266,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
"found incompatible YAML document", token->start_mark);
goto error;
}
- version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
+ version_directive = yaml_malloc(sizeof(yaml_version_directive_t));
if (!version_directive) {
parser->error = YAML_MEMORY_ERROR;
goto error;
diff --git a/ext/psych/yaml/reader.c b/ext/psych/yaml/reader.c
index f3ac54c251..f1a06deb9d 100644
--- a/ext/psych/yaml/reader.c
+++ b/ext/psych/yaml/reader.c
@@ -460,10 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
}
- if (parser->offset >= MAX_FILE_SIZE) {
+ if (parser->offset >= PTRDIFF_MAX)
return yaml_parser_set_reader_error(parser, "input is too long",
- parser->offset, -1);
- }
+ PTRDIFF_MAX, -1);
return 1;
}
+
diff --git a/ext/psych/yaml/scanner.c b/ext/psych/yaml/scanner.c
index 204593d910..d8d90325e0 100644
--- a/ext/psych/yaml/scanner.c
+++ b/ext/psych/yaml/scanner.c
@@ -1188,7 +1188,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
{
if (parser->flow_level) {
parser->flow_level --;
- (void)POP(parser, parser->simple_keys);
+ (void)POP(parser, parser->simple_keys);
}
return 1;
@@ -1227,7 +1227,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
return 0;
}
- parser->indent = (int)column;
+ parser->indent = column;
/* Create a token and insert it into the queue. */
@@ -2399,7 +2399,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
{
/* Set the handle to '' */
- handle = YAML_MALLOC(1);
+ handle = yaml_malloc(1);
if (!handle) goto error;
handle[0] = '\0';
@@ -2451,7 +2451,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
/* Set the handle to '!'. */
yaml_free(handle);
- handle = YAML_MALLOC(2);
+ handle = yaml_malloc(2);
if (!handle) goto error;
handle[0] = '!';
handle[1] = '\0';
@@ -3160,8 +3160,8 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
*(string.pointer++) = '"';
break;
- case '/':
- *(string.pointer++) = '/';
+ case '\'':
+ *(string.pointer++) = '\'';
break;
case '\\':
@@ -3278,11 +3278,6 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
/* Check if we are at the end of the scalar. */
- /* Fix for crash unitialized value crash
- * Credit for the bug and input is to OSS Fuzz
- * Credit for the fix to Alex Gaynor
- */
- if (!CACHE(parser, 1)) goto error;
if (CHECK(parser->buffer, single ? '\'' : '"'))
break;
@@ -3512,7 +3507,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
if (leading_blanks && (int)parser->mark.column < indent
&& IS_TAB(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
- start_mark, "found a tab character that violate indentation");
+ start_mark, "found a tab character that violates indentation");
goto error;
}
@@ -3576,3 +3571,4 @@ error:
return 0;
}
+
diff --git a/ext/psych/yaml/yaml_private.h b/ext/psych/yaml/yaml_private.h
index f4f244cbc8..ce262d3086 100644
--- a/ext/psych/yaml/yaml_private.h
+++ b/ext/psych/yaml/yaml_private.h
@@ -12,6 +12,16 @@
#include <limits.h>
#include <stddef.h>
+#ifndef _MSC_VER
+#include <stdint.h>
+#else
+#ifdef _WIN64
+#define PTRDIFF_MAX _I64_MAX
+#else
+#define PTRDIFF_MAX INT_MAX
+#endif
+#endif
+
/*
* Memory management.
*/
@@ -71,17 +81,6 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
#define OUTPUT_RAW_BUFFER_SIZE (OUTPUT_BUFFER_SIZE*2+2)
/*
- * The maximum size of a YAML input file.
- * This used to be PTRDIFF_MAX, but that's not entirely portable
- * because stdint.h isn't available on all platforms.
- * It is not entirely clear why this isn't the maximum value
- * that can fit into the parser->offset field.
- */
-
-#define MAX_FILE_SIZE (~(size_t)0 / 2)
-
-
-/*
* The size of other stacks and queues.
*/
@@ -94,7 +93,7 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
*/
#define BUFFER_INIT(context,buffer,size) \
- (((buffer).start = (yaml_char_t *)yaml_malloc(size)) ? \
+ (((buffer).start = yaml_malloc(size)) ? \
((buffer).last = (buffer).pointer = (buffer).start, \
(buffer).end = (buffer).start+(size), \
1) : \
@@ -134,7 +133,7 @@ yaml_string_join(
(value).pointer = (string))
#define STRING_INIT(context,string,size) \
- (((string).start = YAML_MALLOC(size)) ? \
+ (((string).start = yaml_malloc(size)) ? \
((string).pointer = (string).start, \
(string).end = (string).start+(size), \
memset((string).start, 0, (size)), \
@@ -424,10 +423,10 @@ yaml_stack_extend(void **start, void **top, void **end);
YAML_DECLARE(int)
yaml_queue_extend(void **start, void **head, void **tail, void **end);
-#define STACK_INIT(context,stack,type) \
- (((stack).start = (type)yaml_malloc(INITIAL_STACK_SIZE*sizeof(*(stack).start))) ? \
+#define STACK_INIT(context,stack,size) \
+ (((stack).start = yaml_malloc((size)*sizeof(*(stack).start))) ? \
((stack).top = (stack).start, \
- (stack).end = (stack).start+INITIAL_STACK_SIZE, \
+ (stack).end = (stack).start+(size), \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
@@ -457,8 +456,8 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
#define POP(context,stack) \
(*(--(stack).top))
-#define QUEUE_INIT(context,queue,size,type) \
- (((queue).start = (type)yaml_malloc((size)*sizeof(*(queue).start))) ? \
+#define QUEUE_INIT(context,queue,size) \
+ (((queue).start = yaml_malloc((size)*sizeof(*(queue).start))) ? \
((queue).head = (queue).tail = (queue).start, \
(queue).end = (queue).start+(size), \
1) : \
@@ -661,28 +660,3 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
(node).data.mapping.pairs.end = (node_pairs_end), \
(node).data.mapping.pairs.top = (node_pairs_start), \
(node).data.mapping.style = (node_style))
-
-/* Strict C compiler warning helpers */
-
-#if defined(__clang__) || defined(__GNUC__)
-# define HASATTRIBUTE_UNUSED
-#endif
-#ifdef HASATTRIBUTE_UNUSED
-# define __attribute__unused__ __attribute__((__unused__))
-#else
-# define __attribute__unused__
-#endif
-
-/* Shim arguments are arguments that must be included in your function,
- * but serve no purpose inside. Silence compiler warnings. */
-#define SHIM(a) /*@unused@*/ a __attribute__unused__
-
-/* UNUSED_PARAM() marks a shim argument in the body to silence compiler warnings */
-#ifdef __clang__
-# define UNUSED_PARAM(a) (void)(a);
-#else
-# define UNUSED_PARAM(a) /*@-noeffect*/if (0) (void)(a)/*@=noeffect*/;
-#endif
-
-#define YAML_MALLOC_STATIC(type) (type*)yaml_malloc(sizeof(type))
-#define YAML_MALLOC(size) (yaml_char_t *)yaml_malloc(size)
diff --git a/ext/pty/depend b/ext/pty/depend
index 1e89dc824c..4f0595c99d 100644
--- a/ext/pty/depend
+++ b/ext/pty/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
pty.o: $(RUBY_EXTCONF_H)
pty.o: $(arch_hdrdir)/ruby/config.h
-pty.o: $(hdrdir)/ruby.h
-pty.o: $(hdrdir)/ruby/assert.h
pty.o: $(hdrdir)/ruby/backward.h
pty.o: $(hdrdir)/ruby/defines.h
pty.o: $(hdrdir)/ruby/encoding.h
@@ -15,6 +13,7 @@ pty.o: $(hdrdir)/ruby/ruby.h
pty.o: $(hdrdir)/ruby/st.h
pty.o: $(hdrdir)/ruby/subst.h
pty.o: $(hdrdir)/ruby/util.h
+pty.o: $(top_srcdir)/include/ruby.h
pty.o: $(top_srcdir)/internal.h
pty.o: pty.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb
index 7721a744c8..4379177755 100644
--- a/ext/pty/extconf.rb
+++ b/ext/pty/extconf.rb
@@ -3,7 +3,7 @@ require 'mkmf'
$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
-if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
+if /mswin|mingw|bccwin|nacl/ !~ RUBY_PLATFORM
have_header("sys/stropts.h")
have_func("setresuid")
have_header("libutil.h")
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 4c6ae26127..341dbbf88b 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -35,8 +35,8 @@
#endif
#include <ctype.h>
-#include "ruby/io.h"
#include "internal.h"
+#include "ruby/io.h"
#include "ruby/util.h"
#include <signal.h>
@@ -143,7 +143,7 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
dup2(slave,0);
dup2(slave,1);
dup2(slave,2);
- if (slave < 0 || slave > 2) (void)!close(slave);
+ close(slave);
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRESUID)
if (seteuid(getuid())) ERROR_EXIT("seteuid()");
#endif
@@ -182,7 +182,7 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
argv = &v;
}
- carg.execarg_obj = rb_execarg_new(argc, argv, 1, 0);
+ carg.execarg_obj = rb_execarg_new(argc, argv, 1);
carg.eargp = rb_execarg_get(carg.execarg_obj);
rb_execarg_parent_start(carg.execarg_obj);
@@ -224,21 +224,6 @@ no_mesg(char *slavedevice, int nomesg)
}
#endif
-#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
-static inline int
-ioctl_I_PUSH(int fd, const char *const name)
-{
- int ret = 0;
-# if defined(I_FIND)
- ret = ioctl(fd, I_FIND, name);
-# endif
- if (ret == 0) {
- ret = ioctl(fd, I_PUSH, name);
- }
- return ret;
-}
-#endif
-
static int
get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg, int fail)
{
@@ -246,13 +231,19 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
/* Unix98 PTY */
int masterfd = -1, slavefd = -1;
char *slavedevice;
+ struct sigaction dfl, old;
+
+ dfl.sa_handler = SIG_DFL;
+ dfl.sa_flags = 0;
+ sigemptyset(&dfl.sa_mask);
#if defined(__sun) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 902000)
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
/* FreeBSD 9.2 or later supports O_CLOEXEC
* http://www.freebsd.org/cgi/query-pr.cgi?pr=162374 */
if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
- if (rb_grantpt(masterfd) == -1) goto error;
+ if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
+ if (grantpt(masterfd) == -1) goto grantpt_error;
rb_fd_fix_cloexec(masterfd);
#else
{
@@ -266,8 +257,10 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
if ((masterfd = posix_openpt(flags)) == -1) goto error;
}
rb_fd_fix_cloexec(masterfd);
- if (rb_grantpt(masterfd) == -1) goto error;
+ if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
+ if (grantpt(masterfd) == -1) goto grantpt_error;
#endif
+ if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
if (unlockpt(masterfd) == -1) goto error;
if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
if (no_mesg(slavedevice, nomesg) == -1) goto error;
@@ -275,9 +268,9 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
rb_update_max_fd(slavefd);
#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
- if (ioctl_I_PUSH(slavefd, "ptem") == -1) goto error;
- if (ioctl_I_PUSH(slavefd, "ldterm") == -1) goto error;
- if (ioctl_I_PUSH(slavefd, "ttcompat") == -1) goto error;
+ if (ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
+ if (ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
+ if (ioctl(slavefd, I_PUSH, "ttcompat") == -1) goto error;
#endif
*master = masterfd;
@@ -285,6 +278,8 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
strlcpy(SlaveName, slavedevice, DEVICELEN);
return 0;
+ grantpt_error:
+ sigaction(SIGCHLD, &old, NULL);
error:
if (slavefd != -1) close(slavefd);
if (masterfd != -1) close(masterfd);
@@ -336,26 +331,30 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
extern char *ptsname(int);
extern int unlockpt(int);
+ extern int grantpt(int);
#if defined(__sun)
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
- if(rb_grantpt(masterfd) == -1) goto error;
+ s = signal(SIGCHLD, SIG_DFL);
+ if(grantpt(masterfd) == -1) goto error;
rb_fd_fix_cloexec(masterfd);
#else
if((masterfd = rb_cloexec_open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
rb_update_max_fd(masterfd);
- if(rb_grantpt(masterfd) == -1) goto error;
+ s = signal(SIGCHLD, SIG_DFL);
+ if(grantpt(masterfd) == -1) goto error;
#endif
+ signal(SIGCHLD, s);
if(unlockpt(masterfd) == -1) goto error;
if((slavedevice = ptsname(masterfd)) == NULL) goto error;
if (no_mesg(slavedevice, nomesg) == -1) goto error;
if((slavefd = rb_cloexec_open(slavedevice, O_RDWR, 0)) == -1) goto error;
rb_update_max_fd(slavefd);
#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
- if(ioctl_I_PUSH(slavefd, "ptem") == -1) goto error;
- if(ioctl_I_PUSH(slavefd, "ldterm") == -1) goto error;
- ioctl_I_PUSH(slavefd, "ttcompat");
+ if(ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
+ if(ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
+ ioctl(slavefd, I_PUSH, "ttcompat");
#endif
*master = masterfd;
*slave = slavefd;
@@ -520,9 +519,8 @@ pty_open(VALUE klass)
}
static VALUE
-pty_detach_process(VALUE v)
+pty_detach_process(struct pty_info *info)
{
- struct pty_info *info = (void *)v;
#ifdef WNOHANG
int st;
if (rb_waitpid(info->child_pid, &st, WNOHANG) <= 0)
@@ -666,7 +664,7 @@ pty_check(int argc, VALUE *argv, VALUE self)
if (!RTEST(exc)) return rb_last_status_get();
raise_from_check(cpid, status);
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
static VALUE cPTY;
@@ -681,7 +679,7 @@ static VALUE cPTY;
/*
* Document-class: PTY
*
- * Creates and manages pseudo terminals (PTYs). See also
+ * Creates and managed pseudo terminals (PTYs). See also
* http://en.wikipedia.org/wiki/Pseudo_terminal
*
* PTY allows you to allocate new terminals using ::open or ::spawn a new
diff --git a/ext/racc/cparse/README b/ext/racc/cparse/README
index 550e8d49fe..7771108b84 100644
--- a/ext/racc/cparse/README
+++ b/ext/racc/cparse/README
@@ -7,5 +7,5 @@ your own parser, you must get Racc full package.
Get it from:
- http://i.loveruby.net/en/projects/racc
- - https://github.com/ruby/racc
+ - https://github.com/tenderlove/racc
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index ca74b80000..b4429ed5f3 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -11,7 +11,7 @@
*/
-#include <ruby.h>
+#include "ruby/ruby.h"
#ifndef FALSE
#define FALSE 0
@@ -24,7 +24,7 @@
Important Constants
----------------------------------------------------------------------- */
-#define RACC_VERSION "1.4.15"
+#define RACC_VERSION "1.4.5"
#define DEFAULT_TOKEN -1
#define ERROR_TOKEN 1
@@ -72,10 +72,6 @@ static ID id_d_e_pop;
# define LONG2NUM(i) INT2NUM(i)
#endif
-#ifndef HAVE_RB_ARY_SUBSEQ
-# define rb_ary_subseq(ary, beg, len) rb_ary_new4(len, RARRAY_PTR(ary) + beg)
-#endif
-
static ID value_to_id _((VALUE v));
static inline long num_to_long _((VALUE n));
@@ -212,7 +208,7 @@ static void extract_user_token _((struct cparse_params *v,
VALUE block_args, VALUE *tok, VALUE *val));
static void shift _((struct cparse_params* v, long act, VALUE tok, VALUE val));
static int reduce _((struct cparse_params* v, long act));
-static rb_block_call_func reduce0;
+static VALUE reduce0 _((VALUE block_args, VALUE data, VALUE self));
#ifdef DEBUG
# define D_puts(msg) if (v->sys_debug) puts(msg)
@@ -708,7 +704,7 @@ reduce(struct cparse_params *v, long act)
}
static VALUE
-reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data))
+reduce0(VALUE val, VALUE data, VALUE self)
{
struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
VALUE reduce_to, reduce_len, method_id;
diff --git a/ext/racc/cparse/depend b/ext/racc/cparse/depend
index a156b32343..441d4df0f7 100644
--- a/ext/racc/cparse/depend
+++ b/ext/racc/cparse/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
cparse.o: $(RUBY_EXTCONF_H)
cparse.o: $(arch_hdrdir)/ruby/config.h
-cparse.o: $(hdrdir)/ruby.h
-cparse.o: $(hdrdir)/ruby/assert.h
cparse.o: $(hdrdir)/ruby/backward.h
cparse.o: $(hdrdir)/ruby/defines.h
cparse.o: $(hdrdir)/ruby/intern.h
diff --git a/ext/racc/cparse/extconf.rb b/ext/racc/cparse/extconf.rb
index 47b455d992..dfddf57111 100644
--- a/ext/racc/cparse/extconf.rb
+++ b/ext/racc/cparse/extconf.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: false
-# $Id: a9187b5bc40e6adf05e7b6ee5b370b39a3429ecd $
+# $Id$
require 'mkmf'
-
-have_func('rb_ary_subseq')
-
+have_func('rb_block_call', 'ruby/ruby.h')
create_makefile 'racc/cparse'
diff --git a/ext/rbconfig/sizeof/depend b/ext/rbconfig/sizeof/depend
index 9433dd4156..143cbb0ee5 100644
--- a/ext/rbconfig/sizeof/depend
+++ b/ext/rbconfig/sizeof/depend
@@ -16,7 +16,6 @@ sizes.c: $(top_srcdir)/tool/generic_erb.rb \
# AUTOGENERATED DEPENDENCIES START
limits.o: $(RUBY_EXTCONF_H)
limits.o: $(arch_hdrdir)/ruby/config.h
-limits.o: $(hdrdir)/ruby/assert.h
limits.o: $(hdrdir)/ruby/backward.h
limits.o: $(hdrdir)/ruby/defines.h
limits.o: $(hdrdir)/ruby/intern.h
@@ -27,7 +26,6 @@ limits.o: $(hdrdir)/ruby/subst.h
limits.o: limits.c
sizes.o: $(RUBY_EXTCONF_H)
sizes.o: $(arch_hdrdir)/ruby/config.h
-sizes.o: $(hdrdir)/ruby/assert.h
sizes.o: $(hdrdir)/ruby/backward.h
sizes.o: $(hdrdir)/ruby/defines.h
sizes.o: $(hdrdir)/ruby/intern.h
diff --git a/ext/readline/.gitignore b/ext/readline/.gitignore
deleted file mode 100644
index 3d372989ae..0000000000
--- a/ext/readline/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/readline-[1-9]*.*
diff --git a/ext/readline/depend b/ext/readline/depend
index 2dde7fca58..eb7a047473 100644
--- a/ext/readline/depend
+++ b/ext/readline/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
readline.o: $(RUBY_EXTCONF_H)
readline.o: $(arch_hdrdir)/ruby/config.h
-readline.o: $(hdrdir)/ruby/assert.h
readline.o: $(hdrdir)/ruby/backward.h
readline.o: $(hdrdir)/ruby/defines.h
readline.o: $(hdrdir)/ruby/encoding.h
@@ -14,5 +13,6 @@ readline.o: $(hdrdir)/ruby/ruby.h
readline.o: $(hdrdir)/ruby/st.h
readline.o: $(hdrdir)/ruby/subst.h
readline.o: $(hdrdir)/ruby/thread.h
+readline.o: $(top_srcdir)/include/ruby.h
readline.o: readline.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index d3e7872e65..7bba386540 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -71,7 +71,6 @@ readline.have_func("rl_completion_matches")
readline.have_func("rl_refresh_line")
readline.have_var("rl_deprep_term_function")
readline.have_var("rl_completion_append_character")
-readline.have_var("rl_completion_quote_character")
readline.have_var("rl_basic_word_break_characters")
readline.have_var("rl_completer_word_break_characters")
readline.have_var("rl_basic_quote_characters")
@@ -84,9 +83,9 @@ readline.have_var("rl_line_buffer")
readline.have_var("rl_point")
readline.have_var("rl_char_is_quoted_p")
# workaround for native windows.
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_event_hook")
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_sigwinch")
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_signals")
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_event_hook")
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_sigwinch")
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_signals")
readline.have_var("rl_pre_input_hook")
readline.have_var("rl_special_prefixes")
readline.have_func("rl_cleanup_after_signal")
@@ -109,4 +108,5 @@ unless readline.have_type("rl_hook_func_t*")
$defs << "-Drl_hook_func_t=Function"
end
+$INCFLAGS << " -I$(top_srcdir)"
create_makefile("readline")
diff --git a/ext/readline/readline-ext.gemspec b/ext/readline/readline-ext.gemspec
deleted file mode 100644
index 66db14d14a..0000000000
--- a/ext/readline/readline-ext.gemspec
+++ /dev/null
@@ -1,26 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "readline-ext"
- spec.version = "0.1.0"
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Provides an interface for GNU Readline and Edit Line (libedit).}
- spec.description = %q{Provides an interface for GNU Readline and Edit Line (libedit).}
- spec.homepage = "https://github.com/ruby/readline-ext"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.extensions = %w[ext/readline/extconf.rb]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "rake-compiler"
-end
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 646be2b194..5b52422563 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -77,8 +77,6 @@ static ID id_special_prefixes;
#endif
#ifndef HAVE_RL_USERNAME_COMPLETION_FUNCTION
# define rl_username_completion_function username_completion_function
-#else
-char *rl_username_completion_function(const char *, int);
#endif
#ifndef HAVE_RL_COMPLETION_MATCHES
# define rl_completion_matches completion_matches
@@ -95,6 +93,7 @@ static char **readline_attempted_completion_function(const char *text,
#define OutputStringValue(str) do {\
StringValueCStr(str);\
+ rb_check_safe_obj(str);\
(str) = rb_str_conv_enc((str), rb_enc_get(str), rb_locale_encoding());\
} while (0)\
@@ -689,7 +688,6 @@ readline_s_insert_text(VALUE self, VALUE str)
#endif
#if defined(HAVE_RL_DELETE_TEXT)
-int rl_delete_text(int, int);
static const char *
str_subpos(const char *ptr, const char *end, long beg, long *sublen, rb_encoding *enc)
{
@@ -822,7 +820,7 @@ readline_s_redisplay(VALUE self)
*
* When working with auto-complete there are some strategies that work well.
* To get some ideas you can take a look at the
- * completion.rb[https://git.ruby-lang.org/ruby.git/tree/lib/irb/completion.rb]
+ * completion.rb[http://svn.ruby-lang.org/repos/ruby/trunk/lib/irb/completion.rb]
* file for irb.
*
* The common strategy is to take a list of possible completions and filter it
@@ -1148,7 +1146,6 @@ readline_s_get_screen_size(VALUE self)
#endif
#ifdef HAVE_RL_VI_EDITING_MODE
-int rl_vi_editing_mode(int, int);
/*
* call-seq:
* Readline.vi_editing_mode -> nil
@@ -1187,7 +1184,6 @@ readline_s_vi_editing_mode_p(VALUE self)
#endif
#ifdef HAVE_RL_EMACS_EDITING_MODE
-int rl_emacs_editing_mode(int, int);
/*
* call-seq:
* Readline.emacs_editing_mode -> nil
@@ -1307,35 +1303,6 @@ readline_s_get_completion_append_character(VALUE self)
#define readline_s_get_completion_append_character rb_f_notimplement
#endif
-#ifdef HAVE_RL_COMPLETION_QUOTE_CHARACTER
-/*
- * call-seq:
- * Readline.completion_quote_character -> char
- *
- * When called during a completion (e.g. from within your completion_proc),
- * it will return a string containing the character used to quote the
- * argument being completed, or nil if the argument is unquoted.
- *
- * When called at other times, it will always return nil.
- *
- * Note that Readline.completer_quote_characters must be set,
- * or this method will always return nil.
- */
-static VALUE
-readline_s_get_completion_quote_character(VALUE self)
-{
- char buf[1];
-
- if (rl_completion_quote_character == '\0')
- return Qnil;
-
- buf[0] = (char) rl_completion_quote_character;
- return rb_locale_str_new(buf, 1);
-}
-#else
-#define readline_s_get_completion_quote_character rb_f_notimplement
-#endif
-
#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
/*
* call-seq:
@@ -1381,7 +1348,7 @@ readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
* Raises NotImplementedError if the using readline library does not support.
*/
static VALUE
-readline_s_get_basic_word_break_characters(VALUE self)
+readline_s_get_basic_word_break_characters(VALUE self, VALUE str)
{
if (rl_basic_word_break_characters == NULL)
return Qnil;
@@ -1436,7 +1403,7 @@ readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
* Raises NotImplementedError if the using readline library does not support.
*/
static VALUE
-readline_s_get_completer_word_break_characters(VALUE self)
+readline_s_get_completer_word_break_characters(VALUE self, VALUE str)
{
if (rl_completer_word_break_characters == NULL)
return Qnil;
@@ -1551,7 +1518,7 @@ readline_s_set_basic_quote_characters(VALUE self, VALUE str)
* Raises NotImplementedError if the using readline library does not support.
*/
static VALUE
-readline_s_get_basic_quote_characters(VALUE self)
+readline_s_get_basic_quote_characters(VALUE self, VALUE str)
{
if (rl_basic_quote_characters == NULL)
return Qnil;
@@ -1607,7 +1574,7 @@ readline_s_set_completer_quote_characters(VALUE self, VALUE str)
* Raises NotImplementedError if the using readline library does not support.
*/
static VALUE
-readline_s_get_completer_quote_characters(VALUE self)
+readline_s_get_completer_quote_characters(VALUE self, VALUE str)
{
if (rl_completer_quote_characters == NULL)
return Qnil;
@@ -1661,7 +1628,7 @@ readline_s_set_filename_quote_characters(VALUE self, VALUE str)
* Raises NotImplementedError if the using readline library does not support.
*/
static VALUE
-readline_s_get_filename_quote_characters(VALUE self)
+readline_s_get_filename_quote_characters(VALUE self, VALUE str)
{
if (rl_filename_quote_characters == NULL)
return Qnil;
@@ -1672,7 +1639,6 @@ readline_s_get_filename_quote_characters(VALUE self)
#endif
#ifdef HAVE_RL_REFRESH_LINE
-int rl_refresh_line(int, int);
/*
* call-seq:
* Readline.refresh_line -> nil
@@ -1790,7 +1756,7 @@ rb_remove_history(int index)
#else
rb_notimplement();
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
#endif
}
@@ -1918,10 +1884,6 @@ username_completion_proc_call(VALUE self, VALUE str)
return result;
}
-#ifdef HAVE_RL_CLEAR_SIGNALS
-int rl_clear_signals(void);
-#endif
-
#undef rb_intern
void
Init_readline(void)
@@ -1996,8 +1958,6 @@ Init_readline(void)
readline_s_set_completion_append_character, 1);
rb_define_singleton_method(mReadline, "completion_append_character",
readline_s_get_completion_append_character, 0);
- rb_define_singleton_method(mReadline, "completion_quote_character",
- readline_s_get_completion_quote_character, 0);
rb_define_singleton_method(mReadline, "basic_word_break_characters=",
readline_s_set_basic_word_break_characters, 1);
rb_define_singleton_method(mReadline, "basic_word_break_characters",
@@ -2036,8 +1996,8 @@ Init_readline(void)
readline_s_get_special_prefixes, 0);
#if USE_INSERT_IGNORE_ESCAPE
- id_orig_prompt = rb_intern("orig_prompt");
- id_last_prompt = rb_intern("last_prompt");
+ CONST_ID(id_orig_prompt, "orig_prompt");
+ CONST_ID(id_last_prompt, "last_prompt");
#endif
history = rb_obj_alloc(rb_cObject);
diff --git a/ext/ripper/depend b/ext/ripper/depend
index 69759ec716..5d3bce4ec3 100644
--- a/ext/ripper/depend
+++ b/ext/ripper/depend
@@ -1,6 +1,7 @@
GEN = $(srcdir)/tools/generate.rb
SRC1 = $(top_srcdir)/parse.y
SRC2 = $(srcdir)/eventids2.c
+BISON = bison
.SUFFIXES: .y
@@ -17,11 +18,10 @@ ripper.o: ripper.c
all: check
static: check
-ripper.y: $(srcdir)/tools/preproc.rb $(srcdir)/tools/dsl.rb $(top_srcdir)/parse.y {$(VPATH)}id.h
+ripper.y: $(srcdir)/tools/preproc.rb $(top_srcdir)/parse.y
$(ECHO) extracting $@ from $(top_srcdir)/parse.y
$(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ \
--vpath=$(VPATH)$(PATH_SEPARATOR)$(top_srcdir) id.h $(top_srcdir)/parse.y > ripper.tmp.y
- $(Q) $(RUBY) $(top_srcdir)/tool/pure_parser.rb ripper.tmp.y $(BISON)
$(Q) $(RUBY) $(srcdir)/tools/preproc.rb ripper.tmp.y --output=$@
$(Q) $(RM) ripper.tmp.y
@@ -32,11 +32,11 @@ check: .eventids2-check
$(Q) $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
@exit > $@
-eventids1.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC1)
+eventids1.c: $(srcdir)/tools/generate.rb $(SRC1)
$(ECHO) generating $@ from $(SRC1)
$(Q) $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
-eventids2table.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC2)
+eventids2table.c: $(srcdir)/tools/generate.rb $(SRC2)
$(ECHO) generating $@ from $(SRC2)
$(Q) $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
@@ -50,12 +50,11 @@ ripper.E: ripper.c
# AUTOGENERATED DEPENDENCIES START
ripper.o: $(RUBY_EXTCONF_H)
ripper.o: $(arch_hdrdir)/ruby/config.h
-ripper.o: $(hdrdir)/ruby.h
-ripper.o: $(hdrdir)/ruby/assert.h
ripper.o: $(hdrdir)/ruby/backward.h
ripper.o: $(hdrdir)/ruby/defines.h
ripper.o: $(hdrdir)/ruby/encoding.h
ripper.o: $(hdrdir)/ruby/intern.h
+ripper.o: $(hdrdir)/ruby/io.h
ripper.o: $(hdrdir)/ruby/missing.h
ripper.o: $(hdrdir)/ruby/onigmo.h
ripper.o: $(hdrdir)/ruby/oniguruma.h
@@ -64,6 +63,7 @@ ripper.o: $(hdrdir)/ruby/ruby.h
ripper.o: $(hdrdir)/ruby/st.h
ripper.o: $(hdrdir)/ruby/subst.h
ripper.o: $(hdrdir)/ruby/util.h
+ripper.o: $(top_srcdir)/include/ruby.h
ripper.o: $(top_srcdir)/internal.h
ripper.o: $(top_srcdir)/node.h
ripper.o: $(top_srcdir)/regenc.h
diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c
index cdac2081e6..04a40e0da7 100644
--- a/ext/ripper/eventids2.c
+++ b/ext/ripper/eventids2.c
@@ -1,13 +1,12 @@
-enum {
- tIGNORED_NL = tLAST_TOKEN + 1,
- tCOMMENT,
- tEMBDOC_BEG,
- tEMBDOC,
- tEMBDOC_END,
- tHEREDOC_BEG,
- tHEREDOC_END,
- k__END__
-};
+#define tIGNORED_NL (tLAST_TOKEN + 1)
+#define tCOMMENT (tLAST_TOKEN + 2)
+#define tEMBDOC_BEG (tLAST_TOKEN + 3)
+#define tEMBDOC (tLAST_TOKEN + 4)
+#define tEMBDOC_END (tLAST_TOKEN + 5)
+#define tSP (tLAST_TOKEN + 6)
+#define tHEREDOC_BEG (tLAST_TOKEN + 7)
+#define tHEREDOC_END (tLAST_TOKEN + 8)
+#define k__END__ (tLAST_TOKEN + 9)
typedef struct {
ID ripper_id_backref;
@@ -128,178 +127,180 @@ ripper_init_eventids2(void)
STATIC_ASSERT(k__END___range, k__END__ < SHRT_MAX);
STATIC_ASSERT(ripper_scanner_ids_size, sizeof(ripper_scanner_ids) < SHRT_MAX);
+#define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member)
+
+static const struct token_assoc {
+ unsigned short token;
+ unsigned short id_offset;
+} token_to_eventid[] = {
+ {' ', O(words_sep)},
+ {'!', O(op)},
+ {'%', O(op)},
+ {'&', O(op)},
+ {'*', O(op)},
+ {'+', O(op)},
+ {'-', O(op)},
+ {'/', O(op)},
+ {'<', O(op)},
+ {'=', O(op)},
+ {'>', O(op)},
+ {'?', O(op)},
+ {'^', O(op)},
+ {'|', O(op)},
+ {'~', O(op)},
+ {':', O(op)},
+ {',', O(comma)},
+ {'.', O(period)},
+ {';', O(semicolon)},
+ {'`', O(backtick)},
+ {'\n', O(nl)},
+ {keyword_alias, O(kw)},
+ {keyword_and, O(kw)},
+ {keyword_begin, O(kw)},
+ {keyword_break, O(kw)},
+ {keyword_case, O(kw)},
+ {keyword_class, O(kw)},
+ {keyword_def, O(kw)},
+ {keyword_defined, O(kw)},
+ {keyword_do, O(kw)},
+ {keyword_do_block, O(kw)},
+ {keyword_do_cond, O(kw)},
+ {keyword_else, O(kw)},
+ {keyword_elsif, O(kw)},
+ {keyword_end, O(kw)},
+ {keyword_ensure, O(kw)},
+ {keyword_false, O(kw)},
+ {keyword_for, O(kw)},
+ {keyword_if, O(kw)},
+ {modifier_if, O(kw)},
+ {keyword_in, O(kw)},
+ {keyword_module, O(kw)},
+ {keyword_next, O(kw)},
+ {keyword_nil, O(kw)},
+ {keyword_not, O(kw)},
+ {keyword_or, O(kw)},
+ {keyword_redo, O(kw)},
+ {keyword_rescue, O(kw)},
+ {modifier_rescue, O(kw)},
+ {keyword_retry, O(kw)},
+ {keyword_return, O(kw)},
+ {keyword_self, O(kw)},
+ {keyword_super, O(kw)},
+ {keyword_then, O(kw)},
+ {keyword_true, O(kw)},
+ {keyword_undef, O(kw)},
+ {keyword_unless, O(kw)},
+ {modifier_unless, O(kw)},
+ {keyword_until, O(kw)},
+ {modifier_until, O(kw)},
+ {keyword_when, O(kw)},
+ {keyword_while, O(kw)},
+ {modifier_while, O(kw)},
+ {keyword_yield, O(kw)},
+ {keyword__FILE__, O(kw)},
+ {keyword__LINE__, O(kw)},
+ {keyword__ENCODING__, O(kw)},
+ {keyword_BEGIN, O(kw)},
+ {keyword_END, O(kw)},
+ {keyword_do_LAMBDA, O(kw)},
+ {tAMPER, O(op)},
+ {tANDOP, O(op)},
+ {tAREF, O(op)},
+ {tASET, O(op)},
+ {tASSOC, O(op)},
+ {tBACK_REF, O(backref)},
+ {tCHAR, O(CHAR)},
+ {tCMP, O(op)},
+ {tCOLON2, O(op)},
+ {tCOLON3, O(op)},
+ {tCONSTANT, O(const)},
+ {tCVAR, O(cvar)},
+ {tDOT2, O(op)},
+ {tDOT3, O(op)},
+ {tEQ, O(op)},
+ {tEQQ, O(op)},
+ {tFID, O(ident)},
+ {tFLOAT, O(float)},
+ {tGEQ, O(op)},
+ {tGVAR, O(gvar)},
+ {tIDENTIFIER, O(ident)},
+ {tIMAGINARY, O(imaginary)},
+ {tINTEGER, O(int)},
+ {tIVAR, O(ivar)},
+ {tLBRACE, O(lbrace)},
+ {tLBRACE_ARG, O(lbrace)},
+ {'{', O(lbrace)},
+ {'}', O(rbrace)},
+ {tLBRACK, O(lbracket)},
+ {'[', O(lbracket)},
+ {']', O(rbracket)},
+ {tLEQ, O(op)},
+ {tLPAREN, O(lparen)},
+ {tLPAREN_ARG, O(lparen)},
+ {'(', O(lparen)},
+ {')', O(rparen)},
+ {tLSHFT, O(op)},
+ {tMATCH, O(op)},
+ {tNEQ, O(op)},
+ {tNMATCH, O(op)},
+ {tNTH_REF, O(backref)},
+ {tOP_ASGN, O(op)},
+ {tOROP, O(op)},
+ {tPOW, O(op)},
+ {tQWORDS_BEG, O(qwords_beg)},
+ {tQSYMBOLS_BEG, O(qsymbols_beg)},
+ {tSYMBOLS_BEG, O(symbols_beg)},
+ {tRATIONAL, O(rational)},
+ {tREGEXP_BEG, O(regexp_beg)},
+ {tREGEXP_END, O(regexp_end)},
+ {tRPAREN, O(rparen)},
+ {tRSHFT, O(op)},
+ {tSTAR, O(op)},
+ {tDSTAR, O(op)},
+ {tANDDOT, O(op)},
+ {tSTRING_BEG, O(tstring_beg)},
+ {tSTRING_CONTENT, O(tstring_content)},
+ {tSTRING_DBEG, O(embexpr_beg)},
+ {tSTRING_DEND, O(embexpr_end)},
+ {tSTRING_DVAR, O(embvar)},
+ {tSTRING_END, O(tstring_end)},
+ {tSYMBEG, O(symbeg)},
+ {tUMINUS, O(op)},
+ {tUMINUS_NUM, O(op)},
+ {tUPLUS, O(op)},
+ {tWORDS_BEG, O(words_beg)},
+ {tXSTRING_BEG, O(backtick)},
+ {tLABEL, O(label)},
+ {tLABEL_END, O(label_end)},
+ {tLAMBDA, O(tlambda)},
+ {tLAMBEG, O(tlambeg)},
+
+ /* ripper specific tokens */
+ {tIGNORED_NL, O(ignored_nl)},
+ {tCOMMENT, O(comment)},
+ {tEMBDOC_BEG, O(embdoc_beg)},
+ {tEMBDOC, O(embdoc)},
+ {tEMBDOC_END, O(embdoc_end)},
+ {tSP, O(sp)},
+ {tHEREDOC_BEG, O(heredoc_beg)},
+ {tHEREDOC_END, O(heredoc_end)},
+ {k__END__, O(__end__)},
+};
static ID
-ripper_token2eventid(enum yytokentype tok)
+ripper_token2eventid(int tok)
{
-#define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member)+1
- static const unsigned short offsets[] = {
- [' '] = O(words_sep),
- ['!'] = O(op),
- ['%'] = O(op),
- ['&'] = O(op),
- ['*'] = O(op),
- ['+'] = O(op),
- ['-'] = O(op),
- ['/'] = O(op),
- ['<'] = O(op),
- ['='] = O(op),
- ['>'] = O(op),
- ['?'] = O(op),
- ['^'] = O(op),
- ['|'] = O(op),
- ['~'] = O(op),
- [':'] = O(op),
- [','] = O(comma),
- ['.'] = O(period),
- [';'] = O(semicolon),
- ['`'] = O(backtick),
- ['\n'] = O(nl),
- [keyword_alias] = O(kw),
- [keyword_and] = O(kw),
- [keyword_begin] = O(kw),
- [keyword_break] = O(kw),
- [keyword_case] = O(kw),
- [keyword_class] = O(kw),
- [keyword_def] = O(kw),
- [keyword_defined] = O(kw),
- [keyword_do] = O(kw),
- [keyword_do_block] = O(kw),
- [keyword_do_cond] = O(kw),
- [keyword_else] = O(kw),
- [keyword_elsif] = O(kw),
- [keyword_end] = O(kw),
- [keyword_ensure] = O(kw),
- [keyword_false] = O(kw),
- [keyword_for] = O(kw),
- [keyword_if] = O(kw),
- [modifier_if] = O(kw),
- [keyword_in] = O(kw),
- [keyword_module] = O(kw),
- [keyword_next] = O(kw),
- [keyword_nil] = O(kw),
- [keyword_not] = O(kw),
- [keyword_or] = O(kw),
- [keyword_redo] = O(kw),
- [keyword_rescue] = O(kw),
- [modifier_rescue] = O(kw),
- [keyword_retry] = O(kw),
- [keyword_return] = O(kw),
- [keyword_self] = O(kw),
- [keyword_super] = O(kw),
- [keyword_then] = O(kw),
- [keyword_true] = O(kw),
- [keyword_undef] = O(kw),
- [keyword_unless] = O(kw),
- [modifier_unless] = O(kw),
- [keyword_until] = O(kw),
- [modifier_until] = O(kw),
- [keyword_when] = O(kw),
- [keyword_while] = O(kw),
- [modifier_while] = O(kw),
- [keyword_yield] = O(kw),
- [keyword__FILE__] = O(kw),
- [keyword__LINE__] = O(kw),
- [keyword__ENCODING__] = O(kw),
- [keyword_BEGIN] = O(kw),
- [keyword_END] = O(kw),
- [keyword_do_LAMBDA] = O(kw),
- [tAMPER] = O(op),
- [tANDOP] = O(op),
- [tAREF] = O(op),
- [tASET] = O(op),
- [tASSOC] = O(op),
- [tBACK_REF] = O(backref),
- [tCHAR] = O(CHAR),
- [tCMP] = O(op),
- [tCOLON2] = O(op),
- [tCOLON3] = O(op),
- [tCONSTANT] = O(const),
- [tCVAR] = O(cvar),
- [tDOT2] = O(op),
- [tDOT3] = O(op),
- [tBDOT2] = O(op),
- [tBDOT3] = O(op),
- [tEQ] = O(op),
- [tEQQ] = O(op),
- [tFID] = O(ident),
- [tFLOAT] = O(float),
- [tGEQ] = O(op),
- [tGVAR] = O(gvar),
- [tIDENTIFIER] = O(ident),
- [tIMAGINARY] = O(imaginary),
- [tINTEGER] = O(int),
- [tIVAR] = O(ivar),
- [tLBRACE] = O(lbrace),
- [tLBRACE_ARG] = O(lbrace),
- ['{'] = O(lbrace),
- ['}'] = O(rbrace),
- [tLBRACK] = O(lbracket),
- ['['] = O(lbracket),
- [']'] = O(rbracket),
- [tLEQ] = O(op),
- [tLPAREN] = O(lparen),
- [tLPAREN_ARG] = O(lparen),
- ['('] = O(lparen),
- [')'] = O(rparen),
- [tLSHFT] = O(op),
- [tMATCH] = O(op),
- [tNEQ] = O(op),
- [tNMATCH] = O(op),
- [tNTH_REF] = O(backref),
- [tOP_ASGN] = O(op),
- [tOROP] = O(op),
- [tPOW] = O(op),
- [tQWORDS_BEG] = O(qwords_beg),
- [tQSYMBOLS_BEG] = O(qsymbols_beg),
- [tSYMBOLS_BEG] = O(symbols_beg),
- [tRATIONAL] = O(rational),
- [tREGEXP_BEG] = O(regexp_beg),
- [tREGEXP_END] = O(regexp_end),
- [tRPAREN] = O(rparen),
- [tRSHFT] = O(op),
- [tSTAR] = O(op),
- [tDSTAR] = O(op),
- [tANDDOT] = O(op),
- [tSTRING_BEG] = O(tstring_beg),
- [tSTRING_CONTENT] = O(tstring_content),
- [tSTRING_DBEG] = O(embexpr_beg),
- [tSTRING_DEND] = O(embexpr_end),
- [tSTRING_DVAR] = O(embvar),
- [tSTRING_END] = O(tstring_end),
- [tSYMBEG] = O(symbeg),
- [tUMINUS] = O(op),
- [tUMINUS_NUM] = O(op),
- [tUPLUS] = O(op),
- [tWORDS_BEG] = O(words_beg),
- [tXSTRING_BEG] = O(backtick),
- [tLABEL] = O(label),
- [tLABEL_END] = O(label_end),
- [tLAMBDA] = O(tlambda),
- [tLAMBEG] = O(tlambeg),
-
- /* ripper specific tokens */
- [tIGNORED_NL] = O(ignored_nl),
- [tCOMMENT] = O(comment),
- [tEMBDOC_BEG] = O(embdoc_beg),
- [tEMBDOC] = O(embdoc),
- [tEMBDOC_END] = O(embdoc_end),
- [tSP] = O(sp),
- [tHEREDOC_BEG] = O(heredoc_beg),
- [tHEREDOC_END] = O(heredoc_end),
- [k__END__] = O(__end__),
- };
-#undef O
+ int i;
- int i = (int)tok;
- if (i >= 0 && i < numberof(offsets) && (i = offsets[i]) > 0) {
- return *(const ID *)((const char *)&ripper_scanner_ids-1+i);
+ for (i = 0; i < numberof(token_to_eventid); i++) {
+ const struct token_assoc *const a = &token_to_eventid[i];
+ if (a->token == tok)
+ return *(const ID *)((const char *)&ripper_scanner_ids + a->id_offset);
}
- /* 128..256 are used as operator tokens */
- if (tok < 128) {
+ if (tok < 256) {
return ripper_scanner_ids.ripper_id_CHAR;
}
rb_raise(rb_eRuntimeError, "[Ripper FATAL] unknown token %d", tok);
- UNREACHABLE_RETURN(0);
+ UNREACHABLE;
}
diff --git a/ext/ripper/extconf.rb b/ext/ripper/extconf.rb
index 2dde565bd9..89b46abcfd 100644
--- a/ext/ripper/extconf.rb
+++ b/ext/ripper/extconf.rb
@@ -5,9 +5,7 @@ require 'mkmf'
require 'rbconfig'
def main
- yacc = ENV["YACC"] || "bison"
-
- unless find_executable(yacc)
+ unless find_executable('bison')
unless File.exist?('ripper.c') or File.exist?("#{$srcdir}/ripper.c")
raise 'missing bison; abort'
end
@@ -18,9 +16,7 @@ def main
$defs << '-DRIPPER_DEBUG' if $debug
$VPATH << '$(topdir)' << '$(top_srcdir)'
$INCFLAGS << ' -I$(topdir) -I$(top_srcdir)'
- create_makefile 'ripper' do |conf|
- conf << "BISON = #{yacc}"
- end
+ create_makefile 'ripper'
end
main
diff --git a/ext/ripper/lib/ripper/core.rb b/ext/ripper/lib/ripper/core.rb
index fa075da5b9..cdbaf7dd34 100644
--- a/ext/ripper/lib/ripper/core.rb
+++ b/ext/ripper/lib/ripper/core.rb
@@ -30,7 +30,6 @@ class Ripper
private
- # :stopdoc:
def _dispatch_0() nil end
def _dispatch_1(a) a end
def _dispatch_2(a, b) a end
@@ -39,7 +38,6 @@ class Ripper
def _dispatch_5(a, b, c, d, e) a end
def _dispatch_6(a, b, c, d, e, f) a end
def _dispatch_7(a, b, c, d, e, f, g) a end
- # :startdoc:
#
# Parser Events
diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb
index 9f613c3475..72cc9104de 100644
--- a/ext/ripper/lib/ripper/lexer.rb
+++ b/ext/ripper/lib/ripper/lexer.rb
@@ -30,16 +30,16 @@ class Ripper
# require 'pp'
#
# pp Ripper.lex("def m(a) nil end")
- # #=> [[[1, 0], :on_kw, "def", FNAME ],
- # [[1, 3], :on_sp, " ", FNAME ],
- # [[1, 4], :on_ident, "m", ENDFN ],
- # [[1, 5], :on_lparen, "(", BEG|LABEL],
- # [[1, 6], :on_ident, "a", ARG ],
- # [[1, 7], :on_rparen, ")", ENDFN ],
- # [[1, 8], :on_sp, " ", BEG ],
- # [[1, 9], :on_kw, "nil", END ],
- # [[1, 12], :on_sp, " ", END ],
- # [[1, 13], :on_kw, "end", END ]]
+ # #=> [[[1, 0], :on_kw, "def", Ripper::EXPR_FNAME ],
+ # [[1, 3], :on_sp, " ", Ripper::EXPR_FNAME ],
+ # [[1, 4], :on_ident, "m", Ripper::EXPR_ENDFN ],
+ # [[1, 5], :on_lparen, "(", Ripper::EXPR_LABEL | Ripper::EXPR_BEG],
+ # [[1, 6], :on_ident, "a", Ripper::EXPR_ARG ],
+ # [[1, 7], :on_rparen, ")", Ripper::EXPR_ENDFN ],
+ # [[1, 8], :on_sp, " ", Ripper::EXPR_BEG ],
+ # [[1, 9], :on_kw, "nil", Ripper::EXPR_END ],
+ # [[1, 12], :on_sp, " ", Ripper::EXPR_END ],
+ # [[1, 13], :on_kw, "end", Ripper::EXPR_END ]]
#
def Ripper.lex(src, filename = '-', lineno = 1)
Lexer.new(src, filename, lineno).lex
@@ -49,52 +49,22 @@ class Ripper
State = Struct.new(:to_int, :to_s) do
alias to_i to_int
def initialize(i) super(i, Ripper.lex_state_name(i)).freeze end
- # def inspect; "#<#{self.class}: #{self}>" end
- alias inspect to_s
+ def inspect; "#<#{self.class}: #{self}>" end
def pretty_print(q) q.text(to_s) end
def ==(i) super or to_int == i end
def &(i) self.class.new(to_int & i) end
- def |(i) self.class.new(to_int | i) end
+ def |(i) self.class.new(to_int & i) end
def allbits?(i) to_int.allbits?(i) end
def anybits?(i) to_int.anybits?(i) end
def nobits?(i) to_int.nobits?(i) end
end
- Elem = Struct.new(:pos, :event, :tok, :state, :message) do
- def initialize(pos, event, tok, state, message = nil)
- super(pos, event, tok, State.new(state), message)
- end
-
- def inspect
- "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if message}#{message}>"
- end
-
- def pretty_print(q)
- q.group(2, "#<#{self.class}:", ">") {
- q.breakable
- q.text("#{event}@#{pos[0]}:#{pos[1]}")
- q.breakable
- q.text(state)
- q.breakable
- q.text("token: ")
- tok.pretty_print(q)
- if message
- q.breakable
- q.text("message: ")
- q.text(message)
- end
- }
- end
-
- def to_a
- a = super
- a.pop unless a.last
- a
+ Elem = Struct.new(:pos, :event, :tok, :state) do
+ def initialize(pos, event, tok, state)
+ super(pos, event, tok, State.new(state))
end
end
- attr_reader :errors
-
def tokenize
parse().sort_by(&:pos).map(&:tok)
end
@@ -103,23 +73,7 @@ class Ripper
parse().sort_by(&:pos).map(&:to_a)
end
- # parse the code and returns elements including errors.
- def scan
- result = (parse() + errors + @stack.flatten).uniq.sort_by {|e| [*e.pos, (e.message ? -1 : 0)]}
- result.each_with_index do |e, i|
- if e.event == :on_parse_error and e.tok.empty? and (pre = result[i-1]) and
- pre.pos[0] == e.pos[0] and (pre.pos[1] + pre.tok.size) == e.pos[1]
- e.tok = pre.tok
- e.pos[1] = pre.pos[1]
- result[i-1] = e
- result[i] = pre
- end
- end
- result
- end
-
def parse
- @errors = []
@buf = []
@stack = []
super
@@ -161,7 +115,7 @@ class Ripper
def on_heredoc_beg(tok)
@stack.push @buf
buf = []
- @buf.push buf
+ @buf << buf
@buf = buf
@buf.push Elem.new([lineno(), column()], __callee__, tok, state())
end
@@ -175,12 +129,6 @@ class Ripper
@buf.push Elem.new([lineno(), column()], __callee__, tok, state())
end
- def on_error(mesg)
- @errors.push Elem.new([lineno(), column()], __callee__, token(), state(), mesg)
- end
- alias on_parse_error on_error
- alias compile_error on_error
-
(SCANNER_EVENTS.map {|event|:"on_#{event}"} - private_instance_methods(false)).each do |event|
alias_method event, :_push_token
end
@@ -265,14 +213,14 @@ class Ripper
end
def map_tokens(tokens)
- tokens.map {|pos,type,str| map_token(type.to_s.delete_prefix('on_')) }.join
+ tokens.map {|pos,type,str| map_token(type.to_s.sub(/\Aon_/,'')) }.join
end
MAP = {}
seed = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
SCANNER_EVENT_TABLE.each do |ev, |
raise CompileError, "[RIPPER FATAL] too many system token" if seed.empty?
- MAP[ev.to_s.delete_prefix('on_')] = seed.shift
+ MAP[ev.to_s.sub(/\Aon_/,'')] = seed.shift
end
def map_token(tok)
diff --git a/ext/ripper/lib/ripper/sexp.rb b/ext/ripper/lib/ripper/sexp.rb
index e71d52cd45..b52dd30ddc 100644
--- a/ext/ripper/lib/ripper/sexp.rb
+++ b/ext/ripper/lib/ripper/sexp.rb
@@ -25,7 +25,7 @@ class Ripper
# #=> [:program,
# [[:def,
# [:@ident, "m", [1, 4]],
- # [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil, nil, nil]],
+ # [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil]],
# [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]]
#
def Ripper.sexp(src, filename = '-', lineno = 1)
diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb
deleted file mode 100644
index d2b9715a71..0000000000
--- a/ext/ripper/tools/dsl.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-# Simple DSL implementation for Ripper code generation
-#
-# input: /*% ripper: stmts_add(stmts_new, void_stmt) %*/
-# output:
-# VALUE v1, v2;
-# v1 = dispatch0(stmts_new);
-# v2 = dispatch0(void_stmt);
-# $$ = dispatch2(stmts_add, v1, v2);
-
-class DSL
- def initialize(code, options)
- @events = {}
- @error = options.include?("error")
- @brace = options.include?("brace")
- if options.include?("final")
- @final = "p->result"
- else
- @final = (options.grep(/\A\$(?:\$|\d+)\z/)[0] || "$$")
- end
- @vars = 0
-
- # create $1 == "$1", $2 == "$2", ...
- s = (1..20).map {|n| "$#{n}"}
- re = Array.new(s.size, "([^\0]+)")
- /#{re.join("\0")}/ =~ s.join("\0")
-
- # struct parser_params *p
- p = p = "p"
-
- @code = ""
- @last_value = eval(code)
- end
-
- attr_reader :events
-
- undef lambda
- undef hash
- undef class
-
- def generate
- s = "#@code#@final=#@last_value;"
- s = "{VALUE #{ (1..@vars).map {|v| "v#{ v }" }.join(",") };#{ s }}" if @vars > 0
- s << "ripper_error(p);" if @error
- s = "{#{ s }}" if @brace
- "\t\t\t#{s}"
- end
-
- def new_var
- "v#{ @vars += 1 }"
- end
-
- def opt_event(event, default, addend)
- add_event(event, [default, addend], true)
- end
-
- def add_event(event, args, qundef_check = false)
- event = event.to_s.sub(/!\z/, "")
- @events[event] = args.size
- vars = []
- args.each do |arg|
- vars << v = new_var
- @code << "#{ v }=#{ arg };"
- end
- v = new_var
- d = "dispatch#{ args.size }(#{ [event, *vars].join(",") })"
- d = "#{ vars.last }==Qundef ? #{ vars.first } : #{ d }" if qundef_check
- @code << "#{ v }=#{ d };"
- v
- end
-
- def method_missing(event, *args)
- if event.to_s =~ /!\z/
- add_event(event, args)
- elsif args.empty? and /\Aid[A-Z_]/ =~ event.to_s
- event
- else
- "#{ event }(#{ args.join(", ") })"
- end
- end
-
- def self.const_missing(name)
- name
- end
-end
-
diff --git a/ext/ripper/tools/generate-param-macros.rb b/ext/ripper/tools/generate-param-macros.rb
index f0de55a5f2..f0de55a5f2 100644..100755
--- a/ext/ripper/tools/generate-param-macros.rb
+++ b/ext/ripper/tools/generate-param-macros.rb
diff --git a/ext/ripper/tools/generate.rb b/ext/ripper/tools/generate.rb
index 883e6ef2df..cf24f1398d 100644..100755
--- a/ext/ripper/tools/generate.rb
+++ b/ext/ripper/tools/generate.rb
@@ -135,8 +135,6 @@ def check_arity(h)
abort if invalid
end
-require_relative "dsl"
-
def read_ids1_with_locations(path)
h = {}
File.open(path) {|f|
@@ -146,13 +144,6 @@ def read_ids1_with_locations(path)
line.scan(/\bdispatch(\d)\((\w+)/) do |arity, event|
(h[event] ||= []).push [f.lineno, arity.to_i]
end
- if line =~ %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>
- gen = DSL.new($2, ($1 || "").split(","))
- gen.generate
- gen.events.each do |event, arity|
- (h[event] ||= []).push [f.lineno, arity.to_i]
- end
- end
end
}
h
diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb
index 7639a901df..8b68579164 100644..100755
--- a/ext/ripper/tools/preproc.rb
+++ b/ext/ripper/tools/preproc.rb
@@ -41,9 +41,14 @@ end
def prelude(f, out)
@exprs = {}
- lex_state_def = false
while line = f.gets
case line
+ when %r</\*%%%\*/>
+ out << '/*' << $/
+ when %r</\*%>
+ out << '*/' << $/
+ when %r<%\*/>
+ out << $/
when /\A%%/
out << '%%' << $/
return
@@ -51,37 +56,31 @@ def prelude(f, out)
out << line.sub(/<\w+>/, '<val>')
when /\A%type/
out << line.sub(/<\w+>/, '<val>')
- when /^enum lex_state_(?:bits|e) \{/
- lex_state_def = true
- out << line
- when /^\}/
- lex_state_def = false
- out << line
else
- out << line
- end
- if lex_state_def
- case line
- when /^\s*(EXPR_\w+),\s+\/\*(.+)\*\//
- @exprs[$1.chomp("_bit")] = $2.strip
- when /^\s*(EXPR_\w+)\s+=\s+(.+)$/
- name = $1
- val = $2.chomp(",")
- @exprs[name] = "equals to " + (val.start_with?("(") ? "<tt>#{val}</tt>" : "+#{val}+")
+ if (/^enum lex_state_(?:bits|e) \{/ =~ line)..(/^\}/ =~ line)
+ case line
+ when /^\s*(EXPR_\w+),\s+\/\*(.+)\*\//
+ @exprs[$1.chomp("_bit")] = $2.strip
+ when /^\s*(EXPR_\w+)\s+=\s+(.+)$/
+ name = $1
+ val = $2.chomp(",")
+ @exprs[name] = "equals to " + (val.start_with?("(") ? "<tt>#{val}</tt>" : "+#{val}+")
+ end
end
+ out << line
end
end
end
-require_relative "dsl"
-
def grammar(f, out)
while line = f.gets
case line
- when %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>
- out << DSL.new($2, ($1 || "").split(",")).generate << $/
when %r</\*%%%\*/>
out << '#if 0' << $/
+ when %r</\*%c%\*/>
+ out << '/*' << $/
+ when %r</\*%c>
+ out << '*/' << $/
when %r</\*%>
out << '#endif' << $/
when %r<%\*/>
diff --git a/ext/ripper/tools/strip.rb b/ext/ripper/tools/strip.rb
index 23102f797a..23102f797a 100644..100755
--- a/ext/ripper/tools/strip.rb
+++ b/ext/ripper/tools/strip.rb
diff --git a/ext/rubyvm/depend b/ext/rubyvm/depend
deleted file mode 100644
index 0301ce074c..0000000000
--- a/ext/rubyvm/depend
+++ /dev/null
@@ -1,2 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/rubyvm/lib/forwardable/impl.rb b/ext/rubyvm/lib/forwardable/impl.rb
index e9bde2f299..e9ada26e74 100644
--- a/ext/rubyvm/lib/forwardable/impl.rb
+++ b/ext/rubyvm/lib/forwardable/impl.rb
@@ -1,5 +1,7 @@
# :stopdoc:
module Forwardable
+ FILTER_EXCEPTION = ""
+
def self._valid_method?(method)
iseq = RubyVM::InstructionSequence.compile("().#{method}", nil, nil, 0, false)
rescue SyntaxError
@@ -10,7 +12,8 @@ module Forwardable
def self._compile_method(src, file, line)
RubyVM::InstructionSequence.compile(src, file, file, line,
- trace_instruction: false)
+ trace_instruction: false,
+ tailcall_optimization: true)
.eval
end
end
diff --git a/ext/sdbm/depend b/ext/sdbm/depend
index d475ecccef..aeb2099e18 100644
--- a/ext/sdbm/depend
+++ b/ext/sdbm/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
_sdbm.o: $(RUBY_EXTCONF_H)
_sdbm.o: $(arch_hdrdir)/ruby/config.h
-_sdbm.o: $(hdrdir)/ruby/assert.h
_sdbm.o: $(hdrdir)/ruby/backward.h
_sdbm.o: $(hdrdir)/ruby/defines.h
_sdbm.o: $(hdrdir)/ruby/intern.h
@@ -13,8 +12,6 @@ _sdbm.o: _sdbm.c
_sdbm.o: sdbm.h
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/intern.h
@@ -22,6 +19,7 @@ init.o: $(hdrdir)/ruby/missing.h
init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: init.c
init.o: sdbm.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 42292b99cd..f28eeb2f5e 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -71,8 +71,6 @@ struct dbmdata {
DBM *di_dbm;
};
-NORETURN(static void closed_sdbm(void));
-
static void
closed_sdbm(void)
{
diff --git a/ext/sdbm/sdbm.gemspec b/ext/sdbm/sdbm.gemspec
index 6cf000b453..3627d2800b 100644
--- a/ext/sdbm/sdbm.gemspec
+++ b/ext/sdbm/sdbm.gemspec
@@ -3,11 +3,12 @@
Gem::Specification.new do |s|
s.name = "sdbm"
s.version = '1.0.0'
+ s.date = '2017-12-11'
s.summary = "Provides a simple file-based key-value store with String keys and values."
s.description = "Provides a simple file-based key-value store with String keys and values."
s.require_path = %w{lib}
- s.files = %w{ext/sdbm/_sdbm.c ext/sdbm/extconf.rb ext/sdbm/init.c ext/sdbm/sdbm.h}
+ s.files = %w{ext/sdbm/_sdbm.c ext/sdbm/depend ext/sdbm/extconf.rb ext/sdbm/init.c ext/sdbm/sdbm.h}
s.extensions = ["ext/sdbm/extconf.rb"]
s.required_ruby_version = ">= 2.3.0"
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 84463af061..f5451c9569 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1137,7 +1137,6 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
rb_io_t *fptr;
struct msghdr mh;
struct iovec iov;
- VALUE tmp;
int controls_num;
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
VALUE controls_str = 0;
@@ -1152,7 +1151,6 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
#endif
StringValue(data);
- tmp = rb_str_tmp_frozen_acquire(data);
if (!RB_TYPE_P(controls, T_ARRAY)) {
controls = rb_ary_new();
@@ -1263,8 +1261,8 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
}
mh.msg_iovlen = 1;
mh.msg_iov = &iov;
- iov.iov_base = RSTRING_PTR(tmp);
- iov.iov_len = RSTRING_LEN(tmp);
+ iov.iov_base = RSTRING_PTR(data);
+ iov.iov_len = RSTRING_LEN(data);
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
if (controls_str) {
mh.msg_control = RSTRING_PTR(controls_str);
@@ -1297,7 +1295,6 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
RB_GC_GUARD(controls_str);
#endif
- rb_str_tmp_frozen_release(data, tmp);
return SSIZET2NUM(ss);
}
@@ -1631,9 +1628,10 @@ bsock_recvmsg_internal(VALUE sock,
}
if (NIL_P(dat_str))
- dat_str = rb_str_new(datbuf, ss);
+ dat_str = rb_tainted_str_new(datbuf, ss);
else {
rb_str_resize(dat_str, ss);
+ OBJ_TAINT(dat_str);
rb_obj_reveal(dat_str, rb_cString);
}
@@ -1659,7 +1657,7 @@ bsock_recvmsg_internal(VALUE sock,
}
ctl_end = (char*)cmh + cmh->cmsg_len;
clen = (ctl_end <= msg_end ? ctl_end : msg_end) - (char*)CMSG_DATA(cmh);
- ctl = ancdata_new(family, cmh->cmsg_level, cmh->cmsg_type, rb_str_new((char*)CMSG_DATA(cmh), clen));
+ ctl = ancdata_new(family, cmh->cmsg_level, cmh->cmsg_type, rb_tainted_str_new((char*)CMSG_DATA(cmh), clen));
if (request_scm_rights)
make_io_for_unix_rights(ctl, cmh, msg_end);
else
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index fb5beed81a..a1065608e6 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -322,7 +322,7 @@ bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
case SO_DONTROUTE:
case SO_BROADCAST:
case SO_OOBINLINE:
- /* AIX doesn't set len for boolean options */
+ /* AIX doesn' set len for boolean options */
len = sizeof(int);
}
#endif
@@ -672,7 +672,7 @@ bsock_recv_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex)
* BasicSocket.do_not_reverse_lookup #=> false
*/
static VALUE
-bsock_do_not_rev_lookup(VALUE _)
+bsock_do_not_rev_lookup(void)
{
return rsock_do_not_reverse_lookup?Qtrue:Qfalse;
}
diff --git a/ext/socket/constants.c b/ext/socket/constants.c
index 1bbb53b173..6fc862777e 100644
--- a/ext/socket/constants.c
+++ b/ext/socket/constants.c
@@ -28,6 +28,7 @@ constant_arg(VALUE arg, int (*str_to_int)(const char*, long, int*), const char *
else if (!NIL_P(tmp = rb_check_string_type(arg))) {
arg = tmp;
str:
+ rb_check_safe_obj(arg);
ptr = RSTRING_PTR(arg);
if (str_to_int(ptr, RSTRING_LEN(arg), &ret) == -1)
rb_raise(rb_eSocket, "%s: %s", errmsg, ptr);
diff --git a/ext/socket/depend b/ext/socket/depend
index e958b3dc5d..41b00406a4 100644
--- a/ext/socket/depend
+++ b/ext/socket/depend
@@ -12,8 +12,6 @@ constdefs.c: constdefs.h
# AUTOGENERATED DEPENDENCIES START
ancdata.o: $(RUBY_EXTCONF_H)
ancdata.o: $(arch_hdrdir)/ruby/config.h
-ancdata.o: $(hdrdir)/ruby.h
-ancdata.o: $(hdrdir)/ruby/assert.h
ancdata.o: $(hdrdir)/ruby/backward.h
ancdata.o: $(hdrdir)/ruby/defines.h
ancdata.o: $(hdrdir)/ruby/encoding.h
@@ -27,6 +25,7 @@ ancdata.o: $(hdrdir)/ruby/st.h
ancdata.o: $(hdrdir)/ruby/subst.h
ancdata.o: $(hdrdir)/ruby/thread.h
ancdata.o: $(hdrdir)/ruby/util.h
+ancdata.o: $(top_srcdir)/include/ruby.h
ancdata.o: $(top_srcdir)/internal.h
ancdata.o: ancdata.c
ancdata.o: constdefs.h
@@ -34,8 +33,6 @@ ancdata.o: rubysocket.h
ancdata.o: sockport.h
basicsocket.o: $(RUBY_EXTCONF_H)
basicsocket.o: $(arch_hdrdir)/ruby/config.h
-basicsocket.o: $(hdrdir)/ruby.h
-basicsocket.o: $(hdrdir)/ruby/assert.h
basicsocket.o: $(hdrdir)/ruby/backward.h
basicsocket.o: $(hdrdir)/ruby/defines.h
basicsocket.o: $(hdrdir)/ruby/encoding.h
@@ -49,6 +46,7 @@ basicsocket.o: $(hdrdir)/ruby/st.h
basicsocket.o: $(hdrdir)/ruby/subst.h
basicsocket.o: $(hdrdir)/ruby/thread.h
basicsocket.o: $(hdrdir)/ruby/util.h
+basicsocket.o: $(top_srcdir)/include/ruby.h
basicsocket.o: $(top_srcdir)/internal.h
basicsocket.o: basicsocket.c
basicsocket.o: constdefs.h
@@ -56,8 +54,6 @@ basicsocket.o: rubysocket.h
basicsocket.o: sockport.h
constants.o: $(RUBY_EXTCONF_H)
constants.o: $(arch_hdrdir)/ruby/config.h
-constants.o: $(hdrdir)/ruby.h
-constants.o: $(hdrdir)/ruby/assert.h
constants.o: $(hdrdir)/ruby/backward.h
constants.o: $(hdrdir)/ruby/defines.h
constants.o: $(hdrdir)/ruby/encoding.h
@@ -71,6 +67,7 @@ constants.o: $(hdrdir)/ruby/st.h
constants.o: $(hdrdir)/ruby/subst.h
constants.o: $(hdrdir)/ruby/thread.h
constants.o: $(hdrdir)/ruby/util.h
+constants.o: $(top_srcdir)/include/ruby.h
constants.o: $(top_srcdir)/internal.h
constants.o: constants.c
constants.o: constdefs.c
@@ -79,8 +76,6 @@ constants.o: rubysocket.h
constants.o: sockport.h
ifaddr.o: $(RUBY_EXTCONF_H)
ifaddr.o: $(arch_hdrdir)/ruby/config.h
-ifaddr.o: $(hdrdir)/ruby.h
-ifaddr.o: $(hdrdir)/ruby/assert.h
ifaddr.o: $(hdrdir)/ruby/backward.h
ifaddr.o: $(hdrdir)/ruby/defines.h
ifaddr.o: $(hdrdir)/ruby/encoding.h
@@ -94,6 +89,7 @@ ifaddr.o: $(hdrdir)/ruby/st.h
ifaddr.o: $(hdrdir)/ruby/subst.h
ifaddr.o: $(hdrdir)/ruby/thread.h
ifaddr.o: $(hdrdir)/ruby/util.h
+ifaddr.o: $(top_srcdir)/include/ruby.h
ifaddr.o: $(top_srcdir)/internal.h
ifaddr.o: constdefs.h
ifaddr.o: ifaddr.c
@@ -101,8 +97,6 @@ ifaddr.o: rubysocket.h
ifaddr.o: sockport.h
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
-init.o: $(hdrdir)/ruby.h
-init.o: $(hdrdir)/ruby/assert.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/defines.h
init.o: $(hdrdir)/ruby/encoding.h
@@ -116,6 +110,7 @@ init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
init.o: $(hdrdir)/ruby/thread.h
init.o: $(hdrdir)/ruby/util.h
+init.o: $(top_srcdir)/include/ruby.h
init.o: $(top_srcdir)/internal.h
init.o: constdefs.h
init.o: init.c
@@ -123,8 +118,6 @@ init.o: rubysocket.h
init.o: sockport.h
ipsocket.o: $(RUBY_EXTCONF_H)
ipsocket.o: $(arch_hdrdir)/ruby/config.h
-ipsocket.o: $(hdrdir)/ruby.h
-ipsocket.o: $(hdrdir)/ruby/assert.h
ipsocket.o: $(hdrdir)/ruby/backward.h
ipsocket.o: $(hdrdir)/ruby/defines.h
ipsocket.o: $(hdrdir)/ruby/encoding.h
@@ -138,6 +131,7 @@ ipsocket.o: $(hdrdir)/ruby/st.h
ipsocket.o: $(hdrdir)/ruby/subst.h
ipsocket.o: $(hdrdir)/ruby/thread.h
ipsocket.o: $(hdrdir)/ruby/util.h
+ipsocket.o: $(top_srcdir)/include/ruby.h
ipsocket.o: $(top_srcdir)/internal.h
ipsocket.o: constdefs.h
ipsocket.o: ipsocket.c
@@ -145,8 +139,6 @@ ipsocket.o: rubysocket.h
ipsocket.o: sockport.h
option.o: $(RUBY_EXTCONF_H)
option.o: $(arch_hdrdir)/ruby/config.h
-option.o: $(hdrdir)/ruby.h
-option.o: $(hdrdir)/ruby/assert.h
option.o: $(hdrdir)/ruby/backward.h
option.o: $(hdrdir)/ruby/defines.h
option.o: $(hdrdir)/ruby/encoding.h
@@ -160,6 +152,7 @@ option.o: $(hdrdir)/ruby/st.h
option.o: $(hdrdir)/ruby/subst.h
option.o: $(hdrdir)/ruby/thread.h
option.o: $(hdrdir)/ruby/util.h
+option.o: $(top_srcdir)/include/ruby.h
option.o: $(top_srcdir)/internal.h
option.o: constdefs.h
option.o: option.c
@@ -167,8 +160,6 @@ option.o: rubysocket.h
option.o: sockport.h
raddrinfo.o: $(RUBY_EXTCONF_H)
raddrinfo.o: $(arch_hdrdir)/ruby/config.h
-raddrinfo.o: $(hdrdir)/ruby.h
-raddrinfo.o: $(hdrdir)/ruby/assert.h
raddrinfo.o: $(hdrdir)/ruby/backward.h
raddrinfo.o: $(hdrdir)/ruby/defines.h
raddrinfo.o: $(hdrdir)/ruby/encoding.h
@@ -182,6 +173,7 @@ raddrinfo.o: $(hdrdir)/ruby/st.h
raddrinfo.o: $(hdrdir)/ruby/subst.h
raddrinfo.o: $(hdrdir)/ruby/thread.h
raddrinfo.o: $(hdrdir)/ruby/util.h
+raddrinfo.o: $(top_srcdir)/include/ruby.h
raddrinfo.o: $(top_srcdir)/internal.h
raddrinfo.o: constdefs.h
raddrinfo.o: raddrinfo.c
@@ -189,8 +181,6 @@ raddrinfo.o: rubysocket.h
raddrinfo.o: sockport.h
socket.o: $(RUBY_EXTCONF_H)
socket.o: $(arch_hdrdir)/ruby/config.h
-socket.o: $(hdrdir)/ruby.h
-socket.o: $(hdrdir)/ruby/assert.h
socket.o: $(hdrdir)/ruby/backward.h
socket.o: $(hdrdir)/ruby/defines.h
socket.o: $(hdrdir)/ruby/encoding.h
@@ -204,6 +194,7 @@ socket.o: $(hdrdir)/ruby/st.h
socket.o: $(hdrdir)/ruby/subst.h
socket.o: $(hdrdir)/ruby/thread.h
socket.o: $(hdrdir)/ruby/util.h
+socket.o: $(top_srcdir)/include/ruby.h
socket.o: $(top_srcdir)/internal.h
socket.o: constdefs.h
socket.o: rubysocket.h
@@ -211,8 +202,6 @@ socket.o: socket.c
socket.o: sockport.h
sockssocket.o: $(RUBY_EXTCONF_H)
sockssocket.o: $(arch_hdrdir)/ruby/config.h
-sockssocket.o: $(hdrdir)/ruby.h
-sockssocket.o: $(hdrdir)/ruby/assert.h
sockssocket.o: $(hdrdir)/ruby/backward.h
sockssocket.o: $(hdrdir)/ruby/defines.h
sockssocket.o: $(hdrdir)/ruby/encoding.h
@@ -226,6 +215,7 @@ sockssocket.o: $(hdrdir)/ruby/st.h
sockssocket.o: $(hdrdir)/ruby/subst.h
sockssocket.o: $(hdrdir)/ruby/thread.h
sockssocket.o: $(hdrdir)/ruby/util.h
+sockssocket.o: $(top_srcdir)/include/ruby.h
sockssocket.o: $(top_srcdir)/internal.h
sockssocket.o: constdefs.h
sockssocket.o: rubysocket.h
@@ -233,8 +223,6 @@ sockssocket.o: sockport.h
sockssocket.o: sockssocket.c
tcpserver.o: $(RUBY_EXTCONF_H)
tcpserver.o: $(arch_hdrdir)/ruby/config.h
-tcpserver.o: $(hdrdir)/ruby.h
-tcpserver.o: $(hdrdir)/ruby/assert.h
tcpserver.o: $(hdrdir)/ruby/backward.h
tcpserver.o: $(hdrdir)/ruby/defines.h
tcpserver.o: $(hdrdir)/ruby/encoding.h
@@ -248,6 +236,7 @@ tcpserver.o: $(hdrdir)/ruby/st.h
tcpserver.o: $(hdrdir)/ruby/subst.h
tcpserver.o: $(hdrdir)/ruby/thread.h
tcpserver.o: $(hdrdir)/ruby/util.h
+tcpserver.o: $(top_srcdir)/include/ruby.h
tcpserver.o: $(top_srcdir)/internal.h
tcpserver.o: constdefs.h
tcpserver.o: rubysocket.h
@@ -255,8 +244,6 @@ tcpserver.o: sockport.h
tcpserver.o: tcpserver.c
tcpsocket.o: $(RUBY_EXTCONF_H)
tcpsocket.o: $(arch_hdrdir)/ruby/config.h
-tcpsocket.o: $(hdrdir)/ruby.h
-tcpsocket.o: $(hdrdir)/ruby/assert.h
tcpsocket.o: $(hdrdir)/ruby/backward.h
tcpsocket.o: $(hdrdir)/ruby/defines.h
tcpsocket.o: $(hdrdir)/ruby/encoding.h
@@ -270,6 +257,7 @@ tcpsocket.o: $(hdrdir)/ruby/st.h
tcpsocket.o: $(hdrdir)/ruby/subst.h
tcpsocket.o: $(hdrdir)/ruby/thread.h
tcpsocket.o: $(hdrdir)/ruby/util.h
+tcpsocket.o: $(top_srcdir)/include/ruby.h
tcpsocket.o: $(top_srcdir)/internal.h
tcpsocket.o: constdefs.h
tcpsocket.o: rubysocket.h
@@ -277,8 +265,6 @@ tcpsocket.o: sockport.h
tcpsocket.o: tcpsocket.c
udpsocket.o: $(RUBY_EXTCONF_H)
udpsocket.o: $(arch_hdrdir)/ruby/config.h
-udpsocket.o: $(hdrdir)/ruby.h
-udpsocket.o: $(hdrdir)/ruby/assert.h
udpsocket.o: $(hdrdir)/ruby/backward.h
udpsocket.o: $(hdrdir)/ruby/defines.h
udpsocket.o: $(hdrdir)/ruby/encoding.h
@@ -292,6 +278,7 @@ udpsocket.o: $(hdrdir)/ruby/st.h
udpsocket.o: $(hdrdir)/ruby/subst.h
udpsocket.o: $(hdrdir)/ruby/thread.h
udpsocket.o: $(hdrdir)/ruby/util.h
+udpsocket.o: $(top_srcdir)/include/ruby.h
udpsocket.o: $(top_srcdir)/internal.h
udpsocket.o: constdefs.h
udpsocket.o: rubysocket.h
@@ -299,8 +286,6 @@ udpsocket.o: sockport.h
udpsocket.o: udpsocket.c
unixserver.o: $(RUBY_EXTCONF_H)
unixserver.o: $(arch_hdrdir)/ruby/config.h
-unixserver.o: $(hdrdir)/ruby.h
-unixserver.o: $(hdrdir)/ruby/assert.h
unixserver.o: $(hdrdir)/ruby/backward.h
unixserver.o: $(hdrdir)/ruby/defines.h
unixserver.o: $(hdrdir)/ruby/encoding.h
@@ -314,6 +299,7 @@ unixserver.o: $(hdrdir)/ruby/st.h
unixserver.o: $(hdrdir)/ruby/subst.h
unixserver.o: $(hdrdir)/ruby/thread.h
unixserver.o: $(hdrdir)/ruby/util.h
+unixserver.o: $(top_srcdir)/include/ruby.h
unixserver.o: $(top_srcdir)/internal.h
unixserver.o: constdefs.h
unixserver.o: rubysocket.h
@@ -321,8 +307,6 @@ unixserver.o: sockport.h
unixserver.o: unixserver.c
unixsocket.o: $(RUBY_EXTCONF_H)
unixsocket.o: $(arch_hdrdir)/ruby/config.h
-unixsocket.o: $(hdrdir)/ruby.h
-unixsocket.o: $(hdrdir)/ruby/assert.h
unixsocket.o: $(hdrdir)/ruby/backward.h
unixsocket.o: $(hdrdir)/ruby/defines.h
unixsocket.o: $(hdrdir)/ruby/encoding.h
@@ -336,6 +320,7 @@ unixsocket.o: $(hdrdir)/ruby/st.h
unixsocket.o: $(hdrdir)/ruby/subst.h
unixsocket.o: $(hdrdir)/ruby/thread.h
unixsocket.o: $(hdrdir)/ruby/util.h
+unixsocket.o: $(top_srcdir)/include/ruby.h
unixsocket.o: $(top_srcdir)/internal.h
unixsocket.o: constdefs.h
unixsocket.o: rubysocket.h
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 1a67e0013e..ec89bed7c2 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -433,7 +433,6 @@ end
case RUBY_PLATFORM
when /mswin(32|64)|mingw/
test_func = "WSACleanup"
- have_library("iphlpapi")
have_library("ws2_32", "WSACleanup", headers)
when /cygwin/
test_func = "socket(0,0,0)"
@@ -444,7 +443,6 @@ else
test_func = "socket(0,0,0)"
have_library("nsl", 't_open("", 0, (struct t_info *)NULL)', headers) # SunOS
have_library("socket", "socket(0,0,0)", headers) # SunOS
- have_library("anl", 'getaddrinfo_a', headers)
end
if have_func(test_func, headers)
@@ -506,7 +504,6 @@ EOF
unless have_func("gethostname((char *)0, 0)", headers)
have_func("uname((struct utsname *)NULL)", headers)
end
- have_func("getaddrinfo_a", headers)
ipv6 = false
default_ipv6 = /haiku/ !~ RUBY_PLATFORM
@@ -648,7 +645,7 @@ EOS
if enable_config("socks", ENV["SOCKS_SERVER"])
if have_library("socks5", "SOCKSinit")
$defs << "-DSOCKS5" << "-DSOCKS"
- elsif have_library("socksd", "Rconnect") || have_library("socks", "Rconnect")
+ elsif have_library("socks", "Rconnect")
$defs << "-DSOCKS"
end
end
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index ce6dc40478..b01f1cb82e 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -149,7 +149,6 @@ static int get_addr __P((const char *, int, struct addrinfo **,
struct addrinfo *, int));
static int str_isnumber __P((const char *));
-#ifndef HAVE_GAI_STRERROR
static const char *const ai_errlist[] = {
"success.",
"address family for hostname not supported.", /* EAI_ADDRFAMILY */
@@ -167,7 +166,6 @@ static const char *const ai_errlist[] = {
"resolved protocol is unknown.", /* EAI_PROTOCOL */
"unknown error.", /* EAI_MAX */
};
-#endif
#define GET_CANONNAME(ai, str) \
if (pai->ai_flags & AI_CANONNAME) {\
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 6d17ecfb4e..db51cb230e 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -10,10 +10,6 @@
#include "rubysocket.h"
-#ifdef _WIN32
-VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc);
-#endif
-
VALUE rb_cBasicSocket;
VALUE rb_cIPSocket;
VALUE rb_cTCPSocket;
@@ -43,15 +39,7 @@ rsock_raise_socket_error(const char *reason, int error)
if (error == EAI_SYSTEM && (e = errno) != 0)
rb_syserr_fail(e, reason);
#endif
-#ifdef _WIN32
- rb_encoding *enc = rb_default_internal_encoding();
- VALUE msg = rb_sprintf("%s: ", reason);
- if (!enc) enc = rb_default_internal_encoding();
- rb_str_concat(msg, rb_w32_conv_from_wchar(gai_strerrorW(error), enc));
- rb_exc_raise(rb_exc_new_str(rb_eSocket, msg));
-#else
rb_raise(rb_eSocket, "%s: %s", reason, gai_strerror(error));
-#endif
}
#ifdef _WIN32
@@ -145,7 +133,7 @@ rsock_strbuf(VALUE str, long buflen)
{
long len;
- if (NIL_P(str)) return rb_str_new(0, buflen);
+ if (NIL_P(str)) return rb_tainted_str_new(0, buflen);
StringValue(str);
len = RSTRING_LEN(str);
@@ -202,6 +190,7 @@ rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
/* Resize the string to the amount of data received */
rb_str_set_len(str, slen);
+ rb_obj_taint(str);
switch (from) {
case RECV_RECV:
return str;
@@ -282,6 +271,7 @@ rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str,
if (slen != RSTRING_LEN(str)) {
rb_str_set_len(str, slen);
}
+ rb_obj_taint(str);
switch (from) {
case RECV_RECV:
return str;
@@ -328,6 +318,7 @@ rsock_read_nonblock(VALUE sock, VALUE length, VALUE buf, VALUE ex)
VALUE str = rsock_strbuf(buf, len);
char *ptr;
+ OBJ_TAINT(str);
GetOpenFile(sock, fptr);
if (len == 0) {
@@ -431,7 +422,7 @@ rsock_socket0(int domain, int type, int proto)
static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */
- ret = socket(domain, type|SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT, proto);
+ ret = socket(domain, type|SOCK_CLOEXEC, proto);
if (ret >= 0) {
if (ret <= 2)
goto fix_cloexec;
@@ -439,7 +430,7 @@ rsock_socket0(int domain, int type, int proto)
}
}
else if (cloexec_state < 0) { /* usually runs once only for detection */
- ret = socket(domain, type|SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT, proto);
+ ret = socket(domain, type|SOCK_CLOEXEC, proto);
if (ret >= 0) {
cloexec_state = rsock_detect_cloexec(ret);
if (cloexec_state == 0 || ret <= 2)
@@ -462,9 +453,6 @@ rsock_socket0(int domain, int type, int proto)
return -1;
fix_cloexec:
rb_maygvl_fd_fix_cloexec(ret);
- if (RSOCK_NONBLOCK_DEFAULT) {
- rsock_make_fd_nonblock(ret);
- }
update_max_fd:
rb_update_max_fd(ret);
@@ -479,9 +467,6 @@ rsock_socket0(int domain, int type, int proto)
if (ret == -1)
return -1;
rb_fd_fix_cloexec(ret);
- if (RSOCK_NONBLOCK_DEFAULT) {
- rsock_make_fd_nonblock(ret);
- }
return ret;
}
@@ -510,30 +495,11 @@ wait_connectable(int fd)
int sockerr, revents;
socklen_t sockerrlen;
+ /* only to clear pending error */
sockerrlen = (socklen_t)sizeof(sockerr);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen) < 0)
return -1;
- /* necessary for non-blocking sockets (at least ECONNREFUSED) */
- switch (sockerr) {
- case 0:
- break;
-#ifdef EALREADY
- case EALREADY:
-#endif
-#ifdef EISCONN
- case EISCONN:
-#endif
-#ifdef ECONNREFUSED
- case ECONNREFUSED:
-#endif
-#ifdef EHOSTUNREACH
- case EHOSTUNREACH:
-#endif
- errno = sockerr;
- return -1;
- }
-
/*
* Stevens book says, successful finish turn on RB_WAITFD_OUT and
* failure finish turn on both RB_WAITFD_IN and RB_WAITFD_OUT.
@@ -634,8 +600,8 @@ rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks)
return status;
}
-void
-rsock_make_fd_nonblock(int fd)
+static void
+make_fd_nonblock(int fd)
{
int flags;
#ifdef F_GETFL
@@ -661,9 +627,6 @@ cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len,
#ifdef HAVE_ACCEPT4
static int try_accept4 = 1;
#endif
- if (RSOCK_NONBLOCK_DEFAULT) {
- nonblock = 1;
- }
if (address_len) len0 = *address_len;
#ifdef HAVE_ACCEPT4
if (try_accept4) {
@@ -683,7 +646,7 @@ cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len,
rb_maygvl_fd_fix_cloexec(ret);
#ifndef SOCK_NONBLOCK
if (nonblock) {
- rsock_make_fd_nonblock(ret);
+ make_fd_nonblock(ret);
}
#endif
if (address_len && len0 < *address_len) *address_len = len0;
@@ -700,7 +663,7 @@ cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len,
if (address_len && len0 < *address_len) *address_len = len0;
rb_maygvl_fd_fix_cloexec(ret);
if (nonblock) {
- rsock_make_fd_nonblock(ret);
+ make_fd_nonblock(ret);
}
return ret;
}
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c
index a2cb6e0e12..dadf10f6a5 100644
--- a/ext/socket/ipsocket.c
+++ b/ext/socket/ipsocket.c
@@ -22,9 +22,8 @@ struct inetsock_arg
};
static VALUE
-inetsock_cleanup(VALUE v)
+inetsock_cleanup(struct inetsock_arg *arg)
{
- struct inetsock_arg *arg = (void *)v;
if (arg->remote.res) {
rb_freeaddrinfo(arg->remote.res);
arg->remote.res = 0;
@@ -40,9 +39,8 @@ inetsock_cleanup(VALUE v)
}
static VALUE
-init_inetsock_internal(VALUE v)
+init_inetsock_internal(struct inetsock_arg *arg)
{
- struct inetsock_arg *arg = (void *)v;
int error = 0;
int type = arg->type;
struct addrinfo *res, *lres;
@@ -101,11 +99,6 @@ init_inetsock_internal(VALUE v)
}
else {
if (lres) {
-#if !defined(_WIN32) && !defined(__CYGWIN__)
- status = 1;
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
- (char*)&status, (socklen_t)sizeof(status));
-#endif
status = bind(fd, lres->ai_addr, lres->ai_addrlen);
local = status;
syscall = "bind(2)";
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index d756a32a5a..18f79b3f08 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -77,7 +77,7 @@ class Addrinfo
sock
end
end
- protected :connect_internal
+ private :connect_internal
# :call-seq:
# addrinfo.connect_from([local_addr_args], [opts]) {|socket| ... }
@@ -158,7 +158,7 @@ class Addrinfo
#
def connect_to(*args, timeout: nil, &block)
remote_addrinfo = family_addrinfo(*args)
- remote_addrinfo.connect_internal(self, timeout, &block)
+ remote_addrinfo.send(:connect_internal, self, timeout, &block)
end
# creates a socket bound to self.
@@ -223,8 +223,8 @@ class Addrinfo
# # #<Addrinfo: [::1]:80 TCP (:80)>
# # #<Addrinfo: [::1]:80 UDP (:80)>
#
- def self.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=nil, timeout: nil, &block)
- Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags, timeout: timeout).each(&block)
+ def self.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=nil, &block)
+ Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags).each(&block)
end
end
@@ -606,7 +606,6 @@ class Socket < BasicSocket
# _opts_ may have following options:
#
# [:connect_timeout] specify the timeout in seconds.
- # [:resolv_timeout] specify the name resolution timeout in seconds.
#
# If a block is given, the block is called with the socket.
# The value of the block is returned.
@@ -620,7 +619,7 @@ class Socket < BasicSocket
# puts sock.read
# }
#
- def self.tcp(host, port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil) # :yield: socket
+ def self.tcp(host, port, local_host = nil, local_port = nil, connect_timeout: nil) # :yield: socket
last_error = nil
ret = nil
@@ -629,7 +628,7 @@ class Socket < BasicSocket
local_addr_list = Addrinfo.getaddrinfo(local_host, local_port, nil, :STREAM, nil)
end
- Addrinfo.foreach(host, port, nil, :STREAM, timeout: resolv_timeout) {|ai|
+ Addrinfo.foreach(host, port, nil, :STREAM) {|ai|
if local_addr_list
local_addr = local_addr_list.find {|local_ai| local_ai.afamily == ai.afamily }
next unless local_addr
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index 620a5f60ff..0ebf628b46 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -73,15 +73,7 @@ def each_name(pat)
}
end
-erb_new = lambda do |src, safe, trim|
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- ERB.new(src, trim_mode: trim)
- else
- ERB.new(src, safe, trim)
- end
-end
-
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% each_const {|guard, name, default_value|
#if !defined(<%=name%>)
# if defined(HAVE_CONST_<%=name.upcase%>)
@@ -95,7 +87,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
#if defined(<%=name%>)
/* <%= COMMENTS[name] %> */
rb_define_const(rb_cSocket, <%=c_str name%>, INTEGER2NUM(<%=name%>));
@@ -104,7 +96,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name
#endif
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
% each_const {|guard, name, default_value|
% if guard
#if <%=guard%>
@@ -154,7 +146,7 @@ def each_names_with_len(pat, prefix_optional=nil)
}
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
%if guard
#ifdef <%=guard%>
int <%=funcname%>(const char *str, long len, int *valp);
@@ -164,7 +156,7 @@ int <%=funcname%>(const char *str, long len, int *valp);
%end
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
int
<%=funcname%>(const char *str, long len, int *valp)
{
@@ -180,13 +172,12 @@ int
% }
default:
- if (!str || !valp) {/* wrong argument */}
return -1;
}
}
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
%if guard
#ifdef <%=guard%>
<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
@@ -215,7 +206,7 @@ def reverse_each_name_with_prefix_optional(pat, prefix_pat)
end
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
<%=hash_var%> = st_init_numtable();
% reverse_each_name_with_prefix_optional(pat, prefix_pat) {|n,s|
#ifdef <%=n%>
@@ -224,7 +215,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_va
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
ID
<%=func_name%>(int val)
{
@@ -235,7 +226,7 @@ ID
}
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
ID <%=func_name%>(int val);
EOS
@@ -284,7 +275,7 @@ def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_")
def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_")
def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_")
-result = erb_new.call(<<'EOS', nil, '%').result(binding)
+result = ERB.new(<<'EOS', nil, '%').result(binding)
/* autogenerated file */
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
@@ -327,7 +318,7 @@ init_constants(void)
EOS
-header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
+header_result = ERB.new(<<'EOS', nil, '%').result(binding)
/* autogenerated file */
<%= gen_const_decls %>
<%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %>
diff --git a/ext/socket/option.c b/ext/socket/option.c
index 5ad44cdcd8..bf3af171a2 100644
--- a/ext/socket/option.c
+++ b/ext/socket/option.c
@@ -424,7 +424,7 @@ sockopt_ipv4_multicast_loop(VALUE self)
}
#endif
rb_raise(rb_eTypeError, "ipv4_multicast_loop socket option expected");
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
#define inspect_ipv4_multicast_loop(a,b,c,d) \
@@ -475,7 +475,7 @@ sockopt_ipv4_multicast_ttl(VALUE self)
}
#endif
rb_raise(rb_eTypeError, "ipv4_multicast_ttl socket option expected");
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
#define inspect_ipv4_multicast_ttl(a,b,c,d) \
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index c4de1b09e1..dcabb2022e 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -145,6 +145,15 @@ ruby_getaddrinfo__darwin(const char *nodename, const char *servname,
#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__darwin((node),(serv),(hints),(res))
#endif
+#ifndef GETADDRINFO_EMU
+struct getaddrinfo_arg
+{
+ const char *node;
+ const char *service;
+ const struct addrinfo *hints;
+ struct addrinfo **res;
+};
+
#ifdef HAVE_INET_PTON
static int
parse_numeric_port(const char *service, int *portp)
@@ -173,15 +182,6 @@ parse_numeric_port(const char *service, int *portp)
}
#endif
-#ifndef GETADDRINFO_EMU
-struct getaddrinfo_arg
-{
- const char *node;
- const char *service;
- const struct addrinfo *hints;
- struct addrinfo **res;
-};
-
static void *
nogvl_getaddrinfo(void *arg)
{
@@ -199,27 +199,6 @@ nogvl_getaddrinfo(void *arg)
}
#endif
-#ifdef HAVE_GETADDRINFO_A
-struct gai_suspend_arg
-{
- struct gaicb *req;
- struct timespec *timeout;
-};
-
-static void *
-nogvl_gai_suspend(void *arg)
-{
- int ret;
- struct gai_suspend_arg *ptr = arg;
- struct gaicb const *wait_reqs[1];
-
- wait_reqs[0] = ptr->req;
- ret = gai_suspend(wait_reqs, 1, ptr->timeout);
-
- return (void *)(VALUE)ret;
-}
-#endif
-
static int
numeric_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
@@ -339,59 +318,6 @@ rb_getaddrinfo(const char *node, const char *service,
return ret;
}
-#ifdef HAVE_GETADDRINFO_A
-int
-rb_getaddrinfo_a(const char *node, const char *service,
- const struct addrinfo *hints,
- struct rb_addrinfo **res, struct timespec *timeout)
-{
- struct addrinfo *ai;
- int ret;
- int allocated_by_malloc = 0;
-
- ret = numeric_getaddrinfo(node, service, hints, &ai);
- if (ret == 0)
- allocated_by_malloc = 1;
- else {
- struct gai_suspend_arg arg;
- struct gaicb *reqs[1];
- struct gaicb req;
-
- req.ar_name = node;
- req.ar_service = service;
- req.ar_request = hints;
-
- reqs[0] = &req;
- ret = getaddrinfo_a(GAI_NOWAIT, reqs, 1, NULL);
- if (ret) return ret;
-
- arg.req = &req;
- arg.timeout = timeout;
-
- ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_gai_suspend, &arg, RUBY_UBF_IO, 0);
-
- if (ret) {
- /* on Ubuntu 18.04 (or other systems), gai_suspend(3) returns EAI_SYSTEM/ENOENT on timeout */
- if (ret == EAI_SYSTEM && errno == ENOENT) {
- return EAI_AGAIN;
- } else {
- return ret;
- }
- }
-
- ret = gai_error(reqs[0]);
- ai = reqs[0]->ar_result;
- }
-
- if (ret == 0) {
- *res = (struct rb_addrinfo *)xmalloc(sizeof(struct rb_addrinfo));
- (*res)->allocated_by_malloc = allocated_by_malloc;
- (*res)->ai = ai;
- }
- return ret;
-}
-#endif
-
void
rb_freeaddrinfo(struct rb_addrinfo *ai)
{
@@ -491,18 +417,22 @@ str_is_number(const char *p)
char *ep;
if (!p || *p == '\0')
- return 0;
+ return 0;
ep = NULL;
(void)STRTOUL(p, &ep, 10);
if (ep && *ep == '\0')
- return 1;
+ return 1;
else
- return 0;
+ return 0;
}
#define str_equal(ptr, len, name) \
((ptr)[0] == name[0] && \
rb_strlen_lit(name) == (len) && memcmp(ptr, name, len) == 0)
+#define SafeStringValueCStr(v) do {\
+ StringValueCStr(v);\
+ rb_check_safe_obj(v);\
+} while(0)
static char*
host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
@@ -521,7 +451,7 @@ host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
const char *name;
size_t len;
- StringValueCStr(host);
+ SafeStringValueCStr(host);
RSTRING_GETMEM(host, name, len);
if (!len || str_equal(name, len, "<any>")) {
make_inetaddr(INADDR_ANY, hbuf, hbuflen);
@@ -560,7 +490,7 @@ port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr)
const char *serv;
size_t len;
- StringValueCStr(port);
+ SafeStringValueCStr(port);
RSTRING_GETMEM(port, serv, len);
if (len >= pbuflen) {
rb_raise(rb_eArgError, "service name too long (%"PRIuSIZE")",
@@ -585,7 +515,7 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
portp = port_str(port, pbuf, sizeof(pbuf), &additional_flags);
if (socktype_hack && hints->ai_socktype == 0 && str_is_number(portp)) {
- hints->ai_socktype = SOCK_DGRAM;
+ hints->ai_socktype = SOCK_DGRAM;
}
hints->ai_flags |= additional_flags;
@@ -600,42 +530,6 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
return res;
}
-#ifdef HAVE_GETADDRINFO_A
-static struct rb_addrinfo*
-rsock_getaddrinfo_a(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack, VALUE timeout)
-{
- struct rb_addrinfo* res = NULL;
- char *hostp, *portp;
- int error;
- char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
- int additional_flags = 0;
-
- hostp = host_str(host, hbuf, sizeof(hbuf), &additional_flags);
- portp = port_str(port, pbuf, sizeof(pbuf), &additional_flags);
-
- if (socktype_hack && hints->ai_socktype == 0 && str_is_number(portp)) {
- hints->ai_socktype = SOCK_DGRAM;
- }
- hints->ai_flags |= additional_flags;
-
- if (NIL_P(timeout)) {
- error = rb_getaddrinfo(hostp, portp, hints, &res);
- } else {
- struct timespec _timeout = rb_time_timespec_interval(timeout);
- error = rb_getaddrinfo_a(hostp, portp, hints, &res, &_timeout);
- }
-
- if (error) {
- if (hostp && hostp[strlen(hostp)-1] == '\n') {
- rb_raise(rb_eSocket, "newline at the end of hostname");
- }
- rsock_raise_socket_error("getaddrinfo_a", error);
- }
-
- return res;
-}
-#endif
-
int
rsock_fd_family(int fd)
{
@@ -703,21 +597,16 @@ rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
}
#ifdef HAVE_SYS_UN_H
-static long
-unixsocket_len(const struct sockaddr_un *su, socklen_t socklen)
-{
- const char *s = su->sun_path, *e = (const char*)su + socklen;
- while (s < e && *(e-1) == '\0')
- e--;
- return e - s;
-}
-
VALUE
rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len)
{
- long n = unixsocket_len(sockaddr, len);
- if (n >= 0)
- return rb_str_new(sockaddr->sun_path, n);
+ char *s, *e;
+ s = sockaddr->sun_path;
+ e = (char *)sockaddr + len;
+ while (s < e && *(e-1) == '\0')
+ e--;
+ if (s <= e)
+ return rb_str_new(s, e-s);
else
return rb_str_new2("");
}
@@ -760,9 +649,8 @@ struct hostent_arg {
};
static VALUE
-make_hostent_internal(VALUE v)
+make_hostent_internal(struct hostent_arg *arg)
{
- struct hostent_arg *arg = (void *)v;
VALUE host = arg->host;
struct addrinfo* addr = arg->addr->ai;
VALUE (*ipaddr)(struct sockaddr*, socklen_t) = arg->ipaddr;
@@ -923,7 +811,7 @@ rsock_addrinfo_new(struct sockaddr *addr, socklen_t len,
static struct rb_addrinfo *
call_getaddrinfo(VALUE node, VALUE service,
VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
- int socktype_hack, VALUE timeout)
+ int socktype_hack)
{
struct addrinfo hints;
struct rb_addrinfo *res;
@@ -940,16 +828,7 @@ call_getaddrinfo(VALUE node, VALUE service,
if (!NIL_P(flags)) {
hints.ai_flags = NUM2INT(flags);
}
-
-#ifdef HAVE_GETADDRINFO_A
- if (NIL_P(timeout)) {
- res = rsock_getaddrinfo(node, service, &hints, socktype_hack);
- } else {
- res = rsock_getaddrinfo_a(node, service, &hints, socktype_hack, timeout);
- }
-#else
res = rsock_getaddrinfo(node, service, &hints, socktype_hack);
-#endif
if (res == NULL)
rb_raise(rb_eSocket, "host not found");
@@ -963,13 +842,13 @@ init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service,
VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
VALUE inspectnode, VALUE inspectservice)
{
- struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 1, Qnil);
+ struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 1);
VALUE canonname;
VALUE inspectname = rb_str_equal(node, inspectnode) ? Qnil : make_inspectname(inspectnode, inspectservice, res->ai);
canonname = Qnil;
if (res->ai->ai_canonname) {
- canonname = rb_str_new_cstr(res->ai->ai_canonname);
+ canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname);
OBJ_FREEZE(canonname);
}
@@ -1019,6 +898,8 @@ make_inspectname(VALUE node, VALUE service, struct addrinfo *res)
rb_str_catf(inspectname, ":%d", FIX2INT(service));
}
if (!NIL_P(inspectname)) {
+ OBJ_INFECT(inspectname, node);
+ OBJ_INFECT(inspectname, service);
OBJ_FREEZE(inspectname);
}
return inspectname;
@@ -1031,13 +912,13 @@ addrinfo_firstonly_new(VALUE node, VALUE service, VALUE family, VALUE socktype,
VALUE canonname;
VALUE inspectname;
- struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0, Qnil);
+ struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
inspectname = make_inspectname(node, service, res->ai);
canonname = Qnil;
if (res->ai->ai_canonname) {
- canonname = rb_str_new_cstr(res->ai->ai_canonname);
+ canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname);
OBJ_FREEZE(canonname);
}
@@ -1051,13 +932,13 @@ addrinfo_firstonly_new(VALUE node, VALUE service, VALUE family, VALUE socktype,
}
static VALUE
-addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags, VALUE timeout)
+addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags)
{
VALUE ret;
struct addrinfo *r;
VALUE inspectname;
- struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0, timeout);
+ struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
inspectname = make_inspectname(node, service, res->ai);
@@ -1067,7 +948,7 @@ addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE
VALUE canonname = Qnil;
if (r->ai_canonname) {
- canonname = rb_str_new_cstr(r->ai_canonname);
+ canonname = rb_tainted_str_new_cstr(r->ai_canonname);
OBJ_FREEZE(canonname);
}
@@ -1104,12 +985,6 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
init_addrinfo(rai, (struct sockaddr *)&un, len,
PF_UNIX, socktype, 0, Qnil, Qnil);
}
-
-static long
-rai_unixsocket_len(const rb_addrinfo_t *rai)
-{
- return unixsocket_len(&rai->addr.un, rai->sockaddr_len);
-}
#endif
/*
@@ -1239,16 +1114,16 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self)
}
static int
-get_afamily(const struct sockaddr *addr, socklen_t len)
+get_afamily(struct sockaddr *addr, socklen_t len)
{
- if ((socklen_t)((const char*)&addr->sa_family + sizeof(addr->sa_family) - (char*)addr) <= len)
+ if ((socklen_t)((char*)&addr->sa_family + sizeof(addr->sa_family) - (char*)addr) <= len)
return addr->sa_family;
else
return AF_UNSPEC;
}
static int
-ai_get_afamily(const rb_addrinfo_t *rai)
+ai_get_afamily(rb_addrinfo_t *rai)
{
return get_afamily(&rai->addr.addr, rai->sockaddr_len);
}
@@ -1357,15 +1232,16 @@ rsock_inspect_sockaddr(struct sockaddr *sockaddr_arg, socklen_t socklen, VALUE r
{
struct sockaddr_un *addr = &sockaddr->un;
char *p, *s, *e;
- long len = unixsocket_len(addr, socklen);
s = addr->sun_path;
- if (len < 0)
+ e = (char*)addr + socklen;
+ while (s < e && *(e-1) == '\0')
+ e--;
+ if (e < s)
rb_str_cat2(ret, "too-short-AF_UNIX-sockaddr");
- else if (len == 0)
+ else if (s == e)
rb_str_cat2(ret, "empty-path-AF_UNIX-sockaddr");
else {
int printable_only = 1;
- e = s + len;
p = s;
while (p < e) {
printable_only = printable_only && ISPRINT(*p) && !ISSPACE(*p);
@@ -1691,7 +1567,13 @@ addrinfo_mdump(VALUE self)
#ifdef HAVE_SYS_UN_H
case AF_UNIX:
{
- sockaddr = rb_str_new(rai->addr.un.sun_path, rai_unixsocket_len(rai));
+ struct sockaddr_un *su = &rai->addr.un;
+ char *s, *e;
+ s = su->sun_path;
+ e = (char*)su + rai->sockaddr_len;
+ while (s < e && *(e-1) == '\0')
+ e--;
+ sockaddr = rb_str_new(s, e-s);
break;
}
#endif
@@ -1809,7 +1691,7 @@ addrinfo_mload(VALUE self, VALUE ary)
#endif
res = call_getaddrinfo(rb_ary_entry(pair, 0), rb_ary_entry(pair, 1),
INT2NUM(pfamily), INT2NUM(socktype), INT2NUM(protocol),
- INT2NUM(flags), 1, Qnil);
+ INT2NUM(flags), 1);
len = res->ai->ai_addrlen;
memcpy(&ss, res->ai->ai_addr, res->ai->ai_addrlen);
@@ -1906,6 +1788,7 @@ addrinfo_to_sockaddr(VALUE self)
rb_addrinfo_t *rai = get_addrinfo(self);
VALUE ret;
ret = rb_str_new((char*)&rai->addr, rai->sockaddr_len);
+ OBJ_INFECT(ret, self);
return ret;
}
@@ -2424,27 +2307,28 @@ addrinfo_unix_path(VALUE self)
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
struct sockaddr_un *addr;
- long n;
+ char *s, *e;
if (family != AF_UNIX)
rb_raise(rb_eSocket, "need AF_UNIX address");
addr = &rai->addr.un;
- n = rai_unixsocket_len(rai);
- if (n < 0)
+ s = addr->sun_path;
+ e = (char*)addr + rai->sockaddr_len;
+ if (e < s)
rb_raise(rb_eSocket, "too short AF_UNIX address: %"PRIuSIZE" bytes given for minimum %"PRIuSIZE" bytes.",
- (size_t)rai->sockaddr_len, offsetof(struct sockaddr_un, sun_path));
- if ((long)sizeof(addr->sun_path) < n)
+ (size_t)rai->sockaddr_len, (size_t)(s - (char *)addr));
+ if (addr->sun_path + sizeof(addr->sun_path) < e)
rb_raise(rb_eSocket,
"too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
- (size_t)n, sizeof(addr->sun_path));
- return rb_str_new(addr->sun_path, n);
+ (size_t)(e - addr->sun_path), sizeof(addr->sun_path));
+ while (s < e && *(e-1) == '\0')
+ e--;
+ return rb_str_new(s, e-s);
}
#endif
-static ID id_timeout;
-
/*
* call-seq:
* Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags) => [addrinfo, ...]
@@ -2491,14 +2375,10 @@ static ID id_timeout;
static VALUE
addrinfo_s_getaddrinfo(int argc, VALUE *argv, VALUE self)
{
- VALUE node, service, family, socktype, protocol, flags, opts, timeout;
-
- rb_scan_args(argc, argv, "24:", &node, &service, &family, &socktype,
- &protocol, &flags, &opts);
- rb_get_kwargs(opts, &id_timeout, 0, 1, &timeout);
- timeout = Qnil;
+ VALUE node, service, family, socktype, protocol, flags;
- return addrinfo_list_new(node, service, family, socktype, protocol, flags, timeout);
+ rb_scan_args(argc, argv, "24", &node, &service, &family, &socktype, &protocol, &flags);
+ return addrinfo_list_new(node, service, family, socktype, protocol, flags);
}
/*
@@ -2586,6 +2466,7 @@ addrinfo_s_unix(int argc, VALUE *argv, VALUE self)
addr = addrinfo_s_allocate(rb_cAddrinfo);
DATA_PTR(addr) = rai = alloc_addrinfo();
init_unix_addrinfo(rai, path, socktype);
+ OBJ_INFECT(addr, path);
return addr;
}
@@ -2669,7 +2550,7 @@ rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
rb_raise(rb_eTypeError, "neither IO nor file descriptor");
}
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
/*
@@ -2682,8 +2563,6 @@ rsock_init_addrinfo(void)
* The Addrinfo class maps <tt>struct addrinfo</tt> to ruby. This
* structure identifies an Internet host and a service.
*/
- id_timeout = rb_intern("timeout");
-
rb_cAddrinfo = rb_define_class("Addrinfo", rb_cData);
rb_define_alloc_func(rb_cAddrinfo, addrinfo_s_allocate);
rb_define_method(rb_cAddrinfo, "initialize", addrinfo_initialize, -1);
diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
index 0ce77a5f6e..922df9b87b 100644
--- a/ext/socket/rubysocket.h
+++ b/ext/socket/rubysocket.h
@@ -26,13 +26,7 @@
# if defined(_MSC_VER)
# undef HAVE_TYPE_STRUCT_SOCKADDR_DL
# endif
-/*
- * FIXME: failures if we make nonblocking the default
- * [ruby-core:89973] [ruby-core:89976] [ruby-core:89977] [Bug #14968]
- */
-# define RSOCK_NONBLOCK_DEFAULT (0)
#else
-# define RSOCK_NONBLOCK_DEFAULT (0)
# include <sys/socket.h>
# include <netinet/in.h>
# ifdef HAVE_NETINET_IN_SYSTM_H
@@ -414,7 +408,7 @@ NORETURN(void rsock_sys_fail_raddrinfo_or_sockaddr(const char *, VALUE addr, VAL
* all cases. For some syscalls (e.g. accept/accept4), blocking on the
* syscall instead of relying on select/poll allows the kernel to use
* "wake-one" behavior and avoid the thundering herd problem.
- * This is likely safe on all other *nix-like systems, so this safe list
+ * This is likely safe on all other *nix-like systems, so this whitelist
* can be expanded by interested parties.
*/
#if defined(__linux__)
@@ -439,8 +433,6 @@ static inline void rsock_maybe_wait_fd(int fd) { }
VALUE rsock_read_nonblock(VALUE sock, VALUE length, VALUE buf, VALUE ex);
VALUE rsock_write_nonblock(VALUE sock, VALUE buf, VALUE ex);
-void rsock_make_fd_nonblock(int fd);
-
#if !defined HAVE_INET_NTOP && ! defined _WIN32
const char *inet_ntop(int, const void *, char *, size_t);
#elif defined __MINGW32__
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index bfeb30340c..8846770097 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -175,17 +175,16 @@ rsock_socketpair0(int domain, int type, int protocol, int sv[2])
{
int ret;
static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
- static const int default_flags = SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT;
if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */
- ret = socketpair(domain, type|default_flags, protocol, sv);
+ ret = socketpair(domain, type|SOCK_CLOEXEC, protocol, sv);
if (ret == 0 && (sv[0] <= 2 || sv[1] <= 2)) {
goto fix_cloexec; /* highly unlikely */
}
goto update_max_fd;
}
else if (cloexec_state < 0) { /* usually runs once only for detection */
- ret = socketpair(domain, type|default_flags, protocol, sv);
+ ret = socketpair(domain, type|SOCK_CLOEXEC, protocol, sv);
if (ret == 0) {
cloexec_state = rsock_detect_cloexec(sv[0]);
if ((cloexec_state == 0) || (sv[0] <= 2 || sv[1] <= 2))
@@ -214,10 +213,6 @@ rsock_socketpair0(int domain, int type, int protocol, int sv[2])
fix_cloexec:
rb_maygvl_fd_fix_cloexec(sv[0]);
rb_maygvl_fd_fix_cloexec(sv[1]);
- if (RSOCK_NONBLOCK_DEFAULT) {
- rsock_make_fd_nonblock(sv[0]);
- rsock_make_fd_nonblock(sv[1]);
- }
update_max_fd:
rb_update_max_fd(sv[0]);
@@ -236,10 +231,6 @@ rsock_socketpair0(int domain, int type, int protocol, int sv[2])
rb_fd_fix_cloexec(sv[0]);
rb_fd_fix_cloexec(sv[1]);
- if (RSOCK_NONBLOCK_DEFAULT) {
- rsock_make_fd_nonblock(sv[0]);
- rsock_make_fd_nonblock(sv[1]);
- }
return ret;
}
#endif /* !SOCK_CLOEXEC */
@@ -1042,7 +1033,7 @@ sock_s_gethostbyname(VALUE obj, VALUE host)
*
*/
static VALUE
-sock_s_gethostbyaddr(int argc, VALUE *argv, VALUE _)
+sock_s_gethostbyaddr(int argc, VALUE *argv)
{
VALUE addr, family;
struct hostent *h;
@@ -1104,7 +1095,7 @@ sock_s_gethostbyaddr(int argc, VALUE *argv, VALUE _)
* Socket.getservbyname("syslog", "udp") #=> 514
*/
static VALUE
-sock_s_getservbyname(int argc, VALUE *argv, VALUE _)
+sock_s_getservbyname(int argc, VALUE *argv)
{
VALUE service, proto;
struct servent *sp;
@@ -1145,7 +1136,7 @@ sock_s_getservbyname(int argc, VALUE *argv, VALUE _)
*
*/
static VALUE
-sock_s_getservbyport(int argc, VALUE *argv, VALUE _)
+sock_s_getservbyport(int argc, VALUE *argv)
{
VALUE port, proto;
struct servent *sp;
@@ -1164,7 +1155,7 @@ sock_s_getservbyport(int argc, VALUE *argv, VALUE _)
if (!sp) {
rb_raise(rb_eSocket, "no such service for port %d/%s", (int)portnum, protoname);
}
- return rb_str_new2(sp->s_name);
+ return rb_tainted_str_new2(sp->s_name);
}
/*
@@ -1203,7 +1194,7 @@ sock_s_getservbyport(int argc, VALUE *argv, VALUE _)
* If Addrinfo object is preferred, use Addrinfo.getaddrinfo.
*/
static VALUE
-sock_s_getaddrinfo(int argc, VALUE *argv, VALUE _)
+sock_s_getaddrinfo(int argc, VALUE *argv)
{
VALUE host, port, family, socktype, protocol, flags, ret, revlookup;
struct addrinfo hints;
@@ -1257,7 +1248,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv, VALUE _)
* If Addrinfo object is preferred, use Addrinfo#getnameinfo.
*/
static VALUE
-sock_s_getnameinfo(int argc, VALUE *argv, VALUE _)
+sock_s_getnameinfo(int argc, VALUE *argv)
{
VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags, tmp;
char *hptr, *pptr;
@@ -1390,7 +1381,7 @@ sock_s_getnameinfo(int argc, VALUE *argv, VALUE _)
errno = saved_errno;
rsock_raise_socket_error("getnameinfo", error);
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
/*
@@ -1414,6 +1405,8 @@ sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host)
VALUE addr = rb_str_new((char*)res->ai->ai_addr, res->ai->ai_addrlen);
rb_freeaddrinfo(res);
+ OBJ_INFECT(addr, port);
+ OBJ_INFECT(addr, host);
return addr;
}
@@ -1455,6 +1448,7 @@ sock_s_unpack_sockaddr_in(VALUE self, VALUE addr)
#endif
}
host = rsock_make_ipaddr((struct sockaddr*)sockaddr, RSTRING_SOCKLEN(addr));
+ OBJ_INFECT(host, addr);
return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host);
}
@@ -1484,6 +1478,7 @@ sock_s_pack_sockaddr_un(VALUE self, VALUE path)
}
memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
addr = rb_str_new((char*)&sockaddr, rsock_unix_sockaddr_len(path));
+ OBJ_INFECT(addr, path);
return addr;
}
@@ -1520,6 +1515,7 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
RSTRING_LEN(addr), (int)sizeof(struct sockaddr_un));
}
path = rsock_unixpath_str(sockaddr, RSTRING_SOCKLEN(addr));
+ OBJ_INFECT(path, addr);
return path;
}
#endif
diff --git a/ext/socket/sockssocket.c b/ext/socket/sockssocket.c
index 82789eeaab..81f77a67c5 100644
--- a/ext/socket/sockssocket.c
+++ b/ext/socket/sockssocket.c
@@ -13,19 +13,13 @@
#ifdef SOCKS
/*
* call-seq:
- * SOCKSSocket.new(host, port) => socket
+ * SOCKSSocket.new(host, serv) => socket
*
- * Opens a SOCKS connection to +host+ via the SOCKS server.
- *
- * The SOCKS server configuration varies by implementation
- *
- * When using the Dante libsocks/libsocksd implementation it is configured as SOCKS_SERVER env var.
- *
- * See: https://manpages.debian.org/testing/dante-client/socksify.1.en.html for full env variable support.
+ * Opens a SOCKS connection to +host+ via the SOCKS server +serv+.
*
*/
static VALUE
-socks_init(VALUE sock, VALUE host, VALUE port)
+socks_init(VALUE sock, VALUE host, VALUE serv)
{
static int init = 0;
@@ -34,7 +28,7 @@ socks_init(VALUE sock, VALUE host, VALUE port)
init = 1;
}
- return rsock_init_inetsock(sock, host, port, Qnil, Qnil, INET_SOCKS);
+ return rsock_init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS);
}
#ifdef SOCKS5
diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c
index 6ef8242a1e..c2e273c2a3 100644
--- a/ext/socket/udpsocket.c
+++ b/ext/socket/udpsocket.c
@@ -50,9 +50,8 @@ struct udp_arg
};
static VALUE
-udp_connect_internal(VALUE v)
+udp_connect_internal(struct udp_arg *arg)
{
- struct udp_arg *arg = (void *)v;
rb_io_t *fptr;
int fd;
struct addrinfo *res;
@@ -98,9 +97,8 @@ udp_connect(VALUE sock, VALUE host, VALUE port)
}
static VALUE
-udp_bind_internal(VALUE v)
+udp_bind_internal(struct udp_arg *arg)
{
- struct udp_arg *arg = (void *)v;
rb_io_t *fptr;
int fd;
struct addrinfo *res;
@@ -149,9 +147,8 @@ struct udp_send_arg {
};
static VALUE
-udp_send_internal(VALUE v)
+udp_send_internal(struct udp_send_arg *arg)
{
- struct udp_send_arg *arg = (void *)v;
rb_io_t *fptr;
int n;
struct addrinfo *res;
diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c
index 0c3a01d21e..75f17d6c10 100644
--- a/ext/socket/unixsocket.c
+++ b/ext/socket/unixsocket.c
@@ -39,6 +39,7 @@ unixsock_path_value(VALUE path)
#endif
if (isstr) {
if (RSTRING_LEN(name) == 0 || RSTRING_PTR(name)[0] == '\0') {
+ rb_check_safe_obj(name);
return name; /* ignore encoding */
}
}
@@ -338,12 +339,6 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
struct iomsg_arg arg;
struct iovec vec[2];
char buf[1];
- unsigned int gc_reason = 0;
- enum {
- GC_REASON_EMSGSIZE = 0x1,
- GC_REASON_TRUNCATE = 0x2,
- GC_REASON_ENOMEM = 0x4
- };
int fd;
#if FD_PASSING_BY_MSG_CONTROL
@@ -359,7 +354,6 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
if (argc <= 1)
mode = Qnil;
-retry:
GetOpenFile(sock, fptr);
arg.msg.msg_name = NULL;
@@ -387,31 +381,12 @@ retry:
arg.fd = fptr->fd;
while ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1) {
- int e = errno;
- if (e == EMSGSIZE && !(gc_reason & GC_REASON_EMSGSIZE)) {
- /* FreeBSD gets here when we're out of FDs */
- gc_reason |= GC_REASON_EMSGSIZE;
- rb_gc_for_fd(EMFILE);
- goto retry;
- }
- else if (e == ENOMEM && !(gc_reason & GC_REASON_ENOMEM)) {
- /* ENOMEM is documented in recvmsg manpages */
- gc_reason |= GC_REASON_ENOMEM;
- rb_gc_for_fd(e);
- goto retry;
- }
if (!rb_io_wait_readable(arg.fd))
- rsock_syserr_fail_path(e, "recvmsg(2)", fptr->pathv);
+ rsock_sys_fail_path("recvmsg(2)", fptr->pathv);
}
#if FD_PASSING_BY_MSG_CONTROL
if (arg.msg.msg_controllen < (socklen_t)sizeof(struct cmsghdr)) {
- /* FreeBSD and Linux both get here when we're out of FDs */
- if (!(gc_reason & GC_REASON_TRUNCATE)) {
- gc_reason |= GC_REASON_TRUNCATE;
- rb_gc_for_fd(EMFILE);
- goto retry;
- }
rb_raise(rb_eSocket,
"file descriptor was not passed (msg_controllen=%d smaller than sizeof(struct cmsghdr)=%d)",
(int)arg.msg.msg_controllen, (int)sizeof(struct cmsghdr));
diff --git a/ext/stringio/depend b/ext/stringio/depend
index 02d468b306..852146f503 100644
--- a/ext/stringio/depend
+++ b/ext/stringio/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
stringio.o: $(RUBY_EXTCONF_H)
stringio.o: $(arch_hdrdir)/ruby/config.h
-stringio.o: $(hdrdir)/ruby.h
-stringio.o: $(hdrdir)/ruby/assert.h
stringio.o: $(hdrdir)/ruby/backward.h
stringio.o: $(hdrdir)/ruby/defines.h
stringio.o: $(hdrdir)/ruby/encoding.h
@@ -14,5 +12,6 @@ stringio.o: $(hdrdir)/ruby/oniguruma.h
stringio.o: $(hdrdir)/ruby/ruby.h
stringio.o: $(hdrdir)/ruby/st.h
stringio.o: $(hdrdir)/ruby/subst.h
+stringio.o: $(top_srcdir)/include/ruby.h
stringio.o: stringio.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/stringio/extconf.rb b/ext/stringio/extconf.rb
index a933159766..ad8650dce2 100644
--- a/ext/stringio/extconf.rb
+++ b/ext/stringio/extconf.rb
@@ -1,4 +1,3 @@
# frozen_string_literal: false
require 'mkmf'
-have_func("rb_io_extract_modeenc", "ruby/io.h")
create_makefile('stringio')
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index b31e801b2a..f537054b5d 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -11,8 +11,6 @@
**********************************************************************/
-#define STRINGIO_VERSION "0.1.0"
-
#include "ruby.h"
#include "ruby/io.h"
#include "ruby/encoding.h"
@@ -26,86 +24,6 @@
# define RB_INTEGER_TYPE_P(c) (FIXNUM_P(c) || RB_TYPE_P(c, T_BIGNUM))
#endif
-#ifndef RB_PASS_CALLED_KEYWORDS
-# define rb_funcallv_kw(recv, mid, arg, argv, kw_splat) rb_funcallv(recv, mid, arg, argv)
-# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
-#endif
-
-#ifndef HAVE_RB_IO_EXTRACT_MODEENC
-#define rb_io_extract_modeenc strio_extract_modeenc
-static void
-strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
- int *oflags_p, int *fmode_p, struct rb_io_enc_t *convconfig_p)
-{
- VALUE mode = *vmode_p;
- VALUE intmode;
- int fmode;
- int has_enc = 0, has_vmode = 0;
-
- convconfig_p->enc = convconfig_p->enc2 = 0;
-
- vmode_handle:
- if (NIL_P(mode)) {
- fmode = FMODE_READABLE;
- }
- else if (!NIL_P(intmode = rb_check_to_integer(mode, "to_int"))) {
- int flags = NUM2INT(intmode);
- fmode = rb_io_oflags_fmode(flags);
- }
- else {
- const char *m = StringValueCStr(mode), *n, *e;
- fmode = rb_io_modestr_fmode(m);
- n = strchr(m, ':');
- if (n) {
- long len;
- char encname[ENCODING_MAXNAMELEN+1];
- has_enc = 1;
- if (fmode & FMODE_SETENC_BY_BOM) {
- n = strchr(n, '|');
- }
- e = strchr(++n, ':');
- len = e ? e - n : strlen(n);
- if (len > 0 && len <= ENCODING_MAXNAMELEN) {
- if (e) {
- memcpy(encname, n, len);
- encname[len] = '\0';
- n = encname;
- }
- convconfig_p->enc = rb_enc_find(n);
- }
- if (e && (len = strlen(++e)) > 0 && len <= ENCODING_MAXNAMELEN) {
- convconfig_p->enc2 = rb_enc_find(e);
- }
- }
- }
-
- if (!NIL_P(opthash)) {
- rb_encoding *extenc = 0, *intenc = 0;
- VALUE v;
- if (!has_vmode) {
- ID id_mode;
- CONST_ID(id_mode, "mode");
- v = rb_hash_aref(opthash, ID2SYM(id_mode));
- if (!NIL_P(v)) {
- if (!NIL_P(mode)) {
- rb_raise(rb_eArgError, "mode specified twice");
- }
- has_vmode = 1;
- mode = v;
- goto vmode_handle;
- }
- }
-
- if (rb_io_extract_encoding_option(opthash, &extenc, &intenc, &fmode)) {
- if (has_enc) {
- rb_raise(rb_eArgError, "encoding specified twice");
- }
- }
- }
- *fmode_p = fmode;
-}
-#endif
-
struct StringIO {
VALUE string;
rb_encoding *enc;
@@ -267,111 +185,45 @@ strio_initialize(int argc, VALUE *argv, VALUE self)
return strio_init(argc, argv, ptr, self);
}
-static int
-detect_bom(VALUE str, int *bomlen)
+static VALUE
+strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
{
- const char *p;
- long len;
+ VALUE string, mode;
+ int trunc = 0;
- RSTRING_GETMEM(str, p, len);
- if (len < 1) return 0;
- switch ((unsigned char)p[0]) {
- case 0xEF:
- if (len < 2) break;
- if ((unsigned char)p[1] == 0xBB && len > 2) {
- if ((unsigned char)p[2] == 0xBF) {
- *bomlen = 3;
- return rb_utf8_encindex();
- }
+ switch (rb_scan_args(argc, argv, "02", &string, &mode)) {
+ case 2:
+ if (FIXNUM_P(mode)) {
+ int flags = FIX2INT(mode);
+ ptr->flags = rb_io_oflags_fmode(flags);
+ trunc = flags & O_TRUNC;
}
- break;
-
- case 0xFE:
- if (len < 2) break;
- if ((unsigned char)p[1] == 0xFF) {
- *bomlen = 2;
- return rb_enc_find_index("UTF-16BE");
+ else {
+ const char *m = StringValueCStr(mode);
+ ptr->flags = rb_io_modestr_fmode(m);
+ trunc = *m == 'w';
}
- break;
-
- case 0xFF:
- if (len < 2) break;
- if ((unsigned char)p[1] == 0xFE) {
- if (len >= 4 && (unsigned char)p[2] == 0 && (unsigned char)p[3] == 0) {
- *bomlen = 4;
- return rb_enc_find_index("UTF-32LE");
- }
- *bomlen = 2;
- return rb_enc_find_index("UTF-16LE");
+ StringValue(string);
+ if ((ptr->flags & FMODE_WRITABLE) && OBJ_FROZEN(string)) {
+ rb_syserr_fail(EACCES, 0);
}
- break;
-
- case 0:
- if (len < 4) break;
- if ((unsigned char)p[1] == 0 && (unsigned char)p[2] == 0xFE && (unsigned char)p[3] == 0xFF) {
- *bomlen = 4;
- return rb_enc_find_index("UTF-32BE");
+ if (trunc) {
+ rb_str_resize(string, 0);
}
break;
- }
- return 0;
-}
-
-static rb_encoding *
-set_encoding_by_bom(struct StringIO *ptr)
-{
- int bomlen, idx = detect_bom(ptr->string, &bomlen);
- rb_encoding *extenc = NULL;
-
- if (idx) {
- extenc = rb_enc_from_index(idx);
- ptr->pos = bomlen;
- if (ptr->flags & FMODE_WRITABLE) {
- rb_enc_associate_index(ptr->string, idx);
- }
- }
- ptr->enc = extenc;
- return extenc;
-}
-
-static VALUE
-strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
-{
- VALUE string, vmode, opt;
- int oflags;
- struct rb_io_enc_t convconfig;
-
- argc = rb_scan_args(argc, argv, "02:", &string, &vmode, &opt);
- rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &ptr->flags, &convconfig);
- if (argc) {
+ case 1:
StringValue(string);
- }
- else {
+ ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
+ break;
+ case 0:
string = rb_enc_str_new("", 0, rb_default_external_encoding());
- }
- if (OBJ_FROZEN_RAW(string)) {
- if (ptr->flags & FMODE_WRITABLE) {
- rb_syserr_fail(EACCES, 0);
- }
- }
- else {
- if (NIL_P(vmode)) {
- ptr->flags |= FMODE_WRITABLE;
- }
- }
- if (ptr->flags & FMODE_TRUNC) {
- rb_str_resize(string, 0);
+ ptr->flags = FMODE_READWRITE;
+ break;
}
ptr->string = string;
- if (argc == 1) {
- ptr->enc = rb_enc_get(string);
- }
- else {
- ptr->enc = convconfig.enc;
- }
+ ptr->enc = 0;
ptr->pos = 0;
ptr->lineno = 0;
- if (ptr->flags & FMODE_SETENC_BY_BOM) set_encoding_by_bom(ptr);
RBASIC(self)->flags |= (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE);
return self;
}
@@ -395,7 +247,7 @@ strio_finalize(VALUE self)
static VALUE
strio_s_open(int argc, VALUE *argv, VALUE klass)
{
- VALUE obj = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
+ VALUE obj = rb_class_new_instance(argc, argv, klass);
if (!rb_block_given_p()) return obj;
return rb_ensure(rb_yield, obj, strio_finalize, obj);
}
@@ -410,7 +262,7 @@ strio_s_new(int argc, VALUE *argv, VALUE klass)
rb_warn("%"PRIsVALUE"::new() does not take block; use %"PRIsVALUE"::open() instead",
cname, cname);
}
- return rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
+ return rb_class_new_instance(argc, argv, klass);
}
/*
@@ -434,7 +286,7 @@ strio_nil(VALUE self)
}
/*
- * Returns an object itself. Just for compatibility to IO.
+ * Returns *strio* itself. Just for compatibility to IO.
*/
static VALUE
strio_self(VALUE self)
@@ -510,7 +362,7 @@ strio_set_string(VALUE self, VALUE string)
* call-seq:
* strio.close -> nil
*
- * Closes a StringIO. The stream is unavailable for any further data
+ * Closes strio. The *strio* is unavailable for any further data
* operations; an +IOError+ is raised if such an attempt is made.
*/
static VALUE
@@ -526,7 +378,7 @@ strio_close(VALUE self)
* strio.close_read -> nil
*
* Closes the read end of a StringIO. Will raise an +IOError+ if the
- * receiver is not readable.
+ * *strio* is not readable.
*/
static VALUE
strio_close_read(VALUE self)
@@ -544,7 +396,7 @@ strio_close_read(VALUE self)
* strio.close_write -> nil
*
* Closes the write end of a StringIO. Will raise an +IOError+ if the
- * receiver is not writeable.
+ * *strio* is not writeable.
*/
static VALUE
strio_close_write(VALUE self)
@@ -561,7 +413,7 @@ strio_close_write(VALUE self)
* call-seq:
* strio.closed? -> true or false
*
- * Returns +true+ if the stream is completely closed, +false+ otherwise.
+ * Returns +true+ if *strio* is completely closed, +false+ otherwise.
*/
static VALUE
strio_closed(VALUE self)
@@ -575,7 +427,7 @@ strio_closed(VALUE self)
* call-seq:
* strio.closed_read? -> true or false
*
- * Returns +true+ if the stream is not readable, +false+ otherwise.
+ * Returns +true+ if *strio* is not readable, +false+ otherwise.
*/
static VALUE
strio_closed_read(VALUE self)
@@ -589,7 +441,7 @@ strio_closed_read(VALUE self)
* call-seq:
* strio.closed_write? -> true or false
*
- * Returns +true+ if the stream is not writable, +false+ otherwise.
+ * Returns +true+ if *strio* is not writable, +false+ otherwise.
*/
static VALUE
strio_closed_write(VALUE self)
@@ -604,8 +456,8 @@ strio_closed_write(VALUE self)
* strio.eof -> true or false
* strio.eof? -> true or false
*
- * Returns true if the stream is at the end of the data (underlying string).
- * The stream must be opened for reading or an +IOError+ will be raised.
+ * Returns true if *strio* is at end of file. The stringio must be
+ * opened for reading or an +IOError+ will be raised.
*/
static VALUE
strio_eof(VALUE self)
@@ -628,6 +480,7 @@ strio_copy(VALUE copy, VALUE orig)
strio_free(DATA_PTR(copy));
}
DATA_PTR(copy) = ptr;
+ OBJ_INFECT(copy, orig);
RBASIC(copy)->flags &= ~STRIO_READWRITE;
RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE;
++ptr->count;
@@ -638,7 +491,7 @@ strio_copy(VALUE copy, VALUE orig)
* call-seq:
* strio.lineno -> integer
*
- * Returns the current line number. The stream must be
+ * Returns the current line number in *strio*. The stringio must be
* opened for reading. +lineno+ counts the number of times +gets+ is
* called, rather than the number of newlines encountered. The two
* values will differ if +gets+ is called with a separator other than
@@ -664,13 +517,6 @@ strio_set_lineno(VALUE self, VALUE lineno)
return lineno;
}
-/*
- * call-seq:
- * strio.binmode -> stringio
- *
- * Puts stream into binary mode. See IO#binmode.
- *
- */
static VALUE
strio_binmode(VALUE self)
{
@@ -695,7 +541,7 @@ strio_binmode(VALUE self)
* strio.reopen(other_StrIO) -> strio
* strio.reopen(string, mode) -> strio
*
- * Reinitializes the stream with the given <i>other_StrIO</i> or _string_
+ * Reinitializes *strio* with the given <i>other_StrIO</i> or _string_
* and _mode_ (see StringIO#new).
*/
static VALUE
@@ -713,7 +559,7 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
* strio.pos -> integer
* strio.tell -> integer
*
- * Returns the current offset (in bytes).
+ * Returns the current offset (in bytes) of *strio*.
*/
static VALUE
strio_get_pos(VALUE self)
@@ -725,7 +571,7 @@ strio_get_pos(VALUE self)
* call-seq:
* strio.pos = integer -> integer
*
- * Seeks to the given position (in bytes).
+ * Seeks to the given position (in bytes) in *strio*.
*/
static VALUE
strio_set_pos(VALUE self, VALUE pos)
@@ -743,7 +589,7 @@ strio_set_pos(VALUE self, VALUE pos)
* call-seq:
* strio.rewind -> 0
*
- * Positions the stream to the beginning of input, resetting
+ * Positions *strio* to the beginning of input, resetting
* +lineno+ to zero.
*/
static VALUE
@@ -911,7 +757,7 @@ strio_extend(struct StringIO *ptr, long pos, long len)
* call-seq:
* strio.ungetc(string) -> nil
*
- * Pushes back one character (passed as a parameter)
+ * Pushes back one character (passed as a parameter) onto *strio*
* such that a subsequent buffered read will return it. There is no
* limitation for multiple pushbacks including pushing back behind the
* beginning of the buffer string.
@@ -957,25 +803,24 @@ static VALUE
strio_ungetbyte(VALUE self, VALUE c)
{
struct StringIO *ptr = readable(self);
+ char buf[1], *cp = buf;
+ long cl = 1;
check_modifiable(ptr);
if (NIL_P(c)) return Qnil;
- if (RB_INTEGER_TYPE_P(c)) {
- /* rb_int_and() not visible from exts */
- VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff));
- const char cc = NUM2INT(v) & 0xFF;
- strio_unget_bytes(ptr, &cc, 1);
+ if (FIXNUM_P(c)) {
+ buf[0] = (char)FIX2INT(c);
+ return strio_unget_bytes(ptr, buf, 1);
}
else {
- long cl;
SafeStringValue(c);
+ cp = RSTRING_PTR(c);
cl = RSTRING_LEN(c);
- if (cl > 0) {
- strio_unget_bytes(ptr, RSTRING_PTR(c), cl);
- RB_GC_GUARD(c);
- }
+ if (cl == 0) return Qnil;
+ strio_unget_bytes(ptr, cp, cl);
+ RB_GC_GUARD(c);
+ return Qnil;
}
- return Qnil;
}
static VALUE
@@ -1018,7 +863,7 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)
static VALUE
strio_readchar(VALUE self)
{
- VALUE c = rb_funcallv(self, rb_intern("getc"), 0, 0);
+ VALUE c = rb_funcall2(self, rb_intern("getc"), 0, 0);
if (NIL_P(c)) rb_eof_error();
return c;
}
@@ -1032,7 +877,7 @@ strio_readchar(VALUE self)
static VALUE
strio_readbyte(VALUE self)
{
- VALUE c = rb_funcallv(self, rb_intern("getbyte"), 0, 0);
+ VALUE c = rb_funcall2(self, rb_intern("getbyte"), 0, 0);
if (NIL_P(c)) rb_eof_error();
return c;
}
@@ -1058,7 +903,7 @@ strio_each_char(VALUE self)
}
/*
- * This is a deprecated alias for #each_char.
+ * This is a deprecated alias for <code>each_char</code>.
*/
static VALUE
strio_chars(VALUE self)
@@ -1102,7 +947,7 @@ strio_each_codepoint(VALUE self)
}
/*
- * This is a deprecated alias for #each_codepoint.
+ * This is a deprecated alias for <code>each_codepoint</code>.
*/
static VALUE
strio_codepoints(VALUE self)
@@ -1292,9 +1137,9 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
/*
* call-seq:
- * strio.gets(sep=$/, chomp: false) -> string or nil
- * strio.gets(limit, chomp: false) -> string or nil
- * strio.gets(sep, limit, chomp: false) -> string or nil
+ * strio.gets(sep=$/) -> string or nil
+ * strio.gets(limit) -> string or nil
+ * strio.gets(sep, limit) -> string or nil
*
* See IO#gets.
*/
@@ -1316,31 +1161,31 @@ strio_gets(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * strio.readline(sep=$/, chomp: false) -> string
- * strio.readline(limit, chomp: false) -> string or nil
- * strio.readline(sep, limit, chomp: false) -> string or nil
+ * strio.readline(sep=$/) -> string
+ * strio.readline(limit) -> string or nil
+ * strio.readline(sep, limit) -> string or nil
*
* See IO#readline.
*/
static VALUE
strio_readline(int argc, VALUE *argv, VALUE self)
{
- VALUE line = rb_funcallv_kw(self, rb_intern("gets"), argc, argv, RB_PASS_CALLED_KEYWORDS);
+ VALUE line = rb_funcall2(self, rb_intern("gets"), argc, argv);
if (NIL_P(line)) rb_eof_error();
return line;
}
/*
* call-seq:
- * strio.each(sep=$/, chomp: false) {|line| block } -> strio
- * strio.each(limit, chomp: false) {|line| block } -> strio
- * strio.each(sep, limit, chomp: false) {|line| block } -> strio
- * strio.each(...) -> anEnumerator
+ * strio.each(sep=$/) {|line| block } -> strio
+ * strio.each(limit) {|line| block } -> strio
+ * strio.each(sep, limit) {|line| block } -> strio
+ * strio.each(...) -> anEnumerator
*
- * strio.each_line(sep=$/, chomp: false) {|line| block } -> strio
- * strio.each_line(limit, chomp: false) {|line| block } -> strio
- * strio.each_line(sep, limit, chomp: false) {|line| block } -> strio
- * strio.each_line(...) -> anEnumerator
+ * strio.each_line(sep=$/) {|line| block } -> strio
+ * strio.each_line(limit) {|line| block } -> strio
+ * strio.each_line(sep,limit) {|line| block } -> strio
+ * strio.each_line(...) -> anEnumerator
*
* See IO#each.
*/
@@ -1364,7 +1209,7 @@ strio_each(int argc, VALUE *argv, VALUE self)
}
/*
- * This is a deprecated alias for #each_line.
+ * This is a deprecated alias for <code>each_line</code>.
*/
static VALUE
strio_lines(int argc, VALUE *argv, VALUE self)
@@ -1377,9 +1222,9 @@ strio_lines(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * strio.readlines(sep=$/, chomp: false) -> array
- * strio.readlines(limit, chomp: false) -> array
- * strio.readlines(sep, limit, chomp: false) -> array
+ * strio.readlines(sep=$/) -> array
+ * strio.readlines(limit) -> array
+ * strio.readlines(sep,limit) -> array
*
* See IO#readlines.
*/
@@ -1406,7 +1251,7 @@ strio_readlines(int argc, VALUE *argv, VALUE self)
* strio.write(string, ...) -> integer
* strio.syswrite(string) -> integer
*
- * Appends the given string to the underlying buffer string.
+ * Appends the given string to the underlying buffer string of *strio*.
* The stream must be opened for writing. If the argument is not a
* string, it will be converted to a string using <code>to_s</code>.
* Returns the number of bytes written. See IO#write.
@@ -1447,6 +1292,7 @@ strio_write(VALUE self, VALUE str)
if (ptr->pos == olen) {
if (enc == ascii8bit || enc2 == ascii8bit) {
rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc);
+ OBJ_INFECT(ptr->string, str);
}
else {
rb_str_buf_append(ptr->string, str);
@@ -1455,7 +1301,9 @@ strio_write(VALUE self, VALUE str)
else {
strio_extend(ptr, ptr->pos, len);
memmove(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_PTR(str), len);
+ OBJ_INFECT(ptr->string, str);
}
+ OBJ_INFECT(ptr->string, self);
RB_GC_GUARD(str);
ptr->pos += len;
return len;
@@ -1558,7 +1406,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
case 0:
len = RSTRING_LEN(ptr->string);
if (len <= ptr->pos) {
- rb_encoding *enc = get_enc(ptr);
+ rb_encoding *enc = binary ? rb_ascii8bit_encoding() : get_enc(ptr);
if (NIL_P(str)) {
str = rb_str_new(0, 0);
}
@@ -1602,7 +1450,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
static VALUE
strio_sysread(int argc, VALUE *argv, VALUE self)
{
- VALUE val = rb_funcallv_kw(self, rb_intern("read"), argc, argv, RB_PASS_CALLED_KEYWORDS);
+ VALUE val = rb_funcall2(self, rb_intern("read"), argc, argv);
if (NIL_P(val)) {
rb_eof_error();
}
@@ -1677,7 +1525,7 @@ strio_size(VALUE self)
* call-seq:
* strio.truncate(integer) -> 0
*
- * Truncates the buffer string to at most _integer_ bytes. The stream
+ * Truncates the buffer string to at most _integer_ bytes. The *strio*
* must be opened for writing.
*/
static VALUE
@@ -1701,8 +1549,7 @@ strio_truncate(VALUE self, VALUE len)
* strio.external_encoding => encoding
*
* Returns the Encoding object that represents the encoding of the file.
- * If the stream is write mode and no encoding is specified, returns
- * +nil+.
+ * If strio is write mode and no encoding is specified, returns <code>nil</code>.
*/
static VALUE
@@ -1717,7 +1564,7 @@ strio_external_encoding(VALUE self)
* strio.internal_encoding => encoding
*
* Returns the Encoding of the internal string if conversion is
- * specified. Otherwise returns +nil+.
+ * specified. Otherwise returns nil.
*/
static VALUE
@@ -1759,43 +1606,24 @@ strio_set_encoding(int argc, VALUE *argv, VALUE self)
return self;
}
-static VALUE
-strio_set_encoding_by_bom(VALUE self)
-{
- struct StringIO *ptr = StringIO(self);
-
- if (!set_encoding_by_bom(ptr)) return Qnil;
- return rb_enc_from_encoding(ptr->enc);
-}
-
/*
- * Pseudo I/O on String object, with interface corresponding to IO.
+ * Pseudo I/O on String object.
*
- * Commonly used to simulate <code>$stdio</code> or <code>$stderr</code>
+ * Commonly used to simulate `$stdio` or `$stderr`
*
* === Examples
*
* require 'stringio'
*
- * # Writing stream emulation
* io = StringIO.new
* io.puts "Hello World"
* io.string #=> "Hello World\n"
- *
- * # Reading stream emulation
- * io = StringIO.new "first\nsecond\nlast\n"
- * io.getc #=> "f"
- * io.gets #=> "irst\n"
- * io.read #=> "second\nlast\n"
*/
void
Init_stringio(void)
{
-#undef rb_intern
VALUE StringIO = rb_define_class("StringIO", rb_cData);
- rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));
-
rb_include_module(StringIO, rb_mEnumerable);
rb_define_alloc_func(StringIO, strio_s_allocate);
rb_define_singleton_method(StringIO, "new", strio_s_new, -1);
@@ -1876,7 +1704,6 @@ Init_stringio(void)
rb_define_method(StringIO, "external_encoding", strio_external_encoding, 0);
rb_define_method(StringIO, "internal_encoding", strio_internal_encoding, 0);
rb_define_method(StringIO, "set_encoding", strio_set_encoding, -1);
- rb_define_method(StringIO, "set_encoding_by_bom", strio_set_encoding_by_bom, 0);
{
VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
diff --git a/ext/stringio/stringio.gemspec b/ext/stringio/stringio.gemspec
index a16c75753f..fa1e767f5f 100644
--- a/ext/stringio/stringio.gemspec
+++ b/ext/stringio/stringio.gemspec
@@ -1,34 +1,27 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true
+# stub: stringio 0.0.0 ruby lib
+# stub: extconf.rb
-source_version = ["", "ext/stringio/"].find do |dir|
- begin
- break File.open(File.join(__dir__, "#{dir}stringio.c")) {|f|
- f.gets("\n#define STRINGIO_VERSION ")
- f.gets[/\s*"(.+)"/, 1]
- }
- rescue Errno::ENOENT
- end
-end
Gem::Specification.new do |s|
- s.name = "stringio"
- s.version = source_version
-
- s.required_rubygems_version = Gem::Requirement.new(">= 2.6")
- s.require_paths = ["lib"]
- s.authors = ["Nobu Nakada"]
- s.description = "Pseudo `IO` class from/to `String`."
- s.email = "nobu@ruby-lang.org"
- s.extensions = ["ext/stringio/extconf.rb"]
- s.files = ["README.md", "ext/stringio/extconf.rb", "ext/stringio/stringio.c"]
- s.homepage = "https://github.com/ruby/stringio"
- s.licenses = ["BSD-2-Clause"]
- s.required_ruby_version = ">= 2.5"
- s.rubygems_version = "2.6.11"
- s.summary = "Pseudo IO on String"
+ s.name = "stringio".freeze
+ s.version = "0.0.1"
- # s.cert_chain = %w[certs/nobu.pem]
- # s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
+ s.required_rubygems_version = Gem::Requirement.new(">= 2.6".freeze)
+ s.require_paths = ["lib".freeze]
+ s.authors = ["Nobu Nakada".freeze]
+ s.date = "2016-06-09"
+ s.description = "Pseudo `IO` class from/to `String`.".freeze
+ s.email = "nobu@ruby-lang.org".freeze
+ s.extensions = ["extconf.rb".freeze]
+ s.files = ["README.md".freeze, "depend".freeze, "extconf.rb".freeze, "stringio.c".freeze]
+ s.homepage = "https://github.com/ruby/stringio".freeze
+ s.licenses = ["BSD-2-Clause".freeze]
+ s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze)
+ s.rubygems_version = "2.6.11".freeze
+ s.summary = "Pseudo IO on String".freeze
+ s.cert_chain = %w[certs/nobu.pem]
+ s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
s.add_development_dependency 'rake-compiler'
end
diff --git a/ext/strscan/depend b/ext/strscan/depend
index 212d386f83..1c396b00cf 100644
--- a/ext/strscan/depend
+++ b/ext/strscan/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
strscan.o: $(RUBY_EXTCONF_H)
strscan.o: $(arch_hdrdir)/ruby/config.h
-strscan.o: $(hdrdir)/ruby/assert.h
strscan.o: $(hdrdir)/ruby/backward.h
strscan.o: $(hdrdir)/ruby/defines.h
strscan.o: $(hdrdir)/ruby/encoding.h
@@ -14,5 +13,7 @@ strscan.o: $(hdrdir)/ruby/regex.h
strscan.o: $(hdrdir)/ruby/ruby.h
strscan.o: $(hdrdir)/ruby/st.h
strscan.o: $(hdrdir)/ruby/subst.h
+strscan.o: $(top_srcdir)/regenc.h
+strscan.o: $(top_srcdir)/regint.h
strscan.o: strscan.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/strscan/extconf.rb b/ext/strscan/extconf.rb
index f0ecbf85d8..714fa99fae 100644
--- a/ext/strscan/extconf.rb
+++ b/ext/strscan/extconf.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'mkmf'
-$INCFLAGS << " -I$(top_srcdir)" if $extmk
-have_func("onig_region_memsize", "ruby.h")
+$INCFLAGS << " -I$(top_srcdir)"
create_makefile 'strscan'
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index b6d17992c9..d6168a0d4f 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -11,18 +11,9 @@
#include "ruby/ruby.h"
#include "ruby/re.h"
#include "ruby/encoding.h"
+#include "regint.h"
-#ifdef RUBY_EXTCONF_H
-# include RUBY_EXTCONF_H
-#endif
-
-#ifdef HAVE_ONIG_REGION_MEMSIZE
-extern size_t onig_region_memsize(const struct re_registers *regs);
-#endif
-
-#include <stdbool.h>
-
-#define STRSCAN_VERSION "1.0.3"
+#define STRSCAN_VERSION "0.7.0"
/* =======================================================================
Data Type Definitions
@@ -50,9 +41,6 @@ struct strscanner
/* regexp used for last scan */
VALUE regex;
-
- /* anchor mode */
- bool fixed_anchor_p;
};
#define MATCHED_P(s) ((s)->flags & FLAG_MATCHED)
@@ -77,6 +65,7 @@ struct strscanner
======================================================================= */
static inline long minl _((const long n, const long x));
+static VALUE infect _((VALUE str, struct strscanner *p));
static VALUE extract_range _((struct strscanner *p, long beg_i, long end_i));
static VALUE extract_beg_len _((struct strscanner *p, long beg_i, long len));
@@ -138,6 +127,13 @@ static VALUE inspect2 _((struct strscanner *p));
======================================================================= */
static VALUE
+infect(VALUE str, struct strscanner *p)
+{
+ OBJ_INFECT(str, p->str);
+ return str;
+}
+
+static VALUE
str_new(struct strscanner *p, const char *ptr, long len)
{
VALUE str = rb_str_new(ptr, len);
@@ -156,7 +152,7 @@ extract_range(struct strscanner *p, long beg_i, long end_i)
{
if (beg_i > S_LEN(p)) return Qnil;
end_i = minl(end_i, S_LEN(p));
- return str_new(p, S_PBEG(p) + beg_i, end_i - beg_i);
+ return infect(str_new(p, S_PBEG(p) + beg_i, end_i - beg_i), p);
}
static VALUE
@@ -164,7 +160,7 @@ extract_beg_len(struct strscanner *p, long beg_i, long len)
{
if (beg_i > S_LEN(p)) return Qnil;
len = minl(len, S_LEN(p) - beg_i);
- return str_new(p, S_PBEG(p) + beg_i, len);
+ return infect(str_new(p, S_PBEG(p) + beg_i, len), p);
}
/* =======================================================================
@@ -190,11 +186,7 @@ static size_t
strscan_memsize(const void *ptr)
{
const struct strscanner *p = ptr;
- size_t size = sizeof(*p) - sizeof(p->regs);
-#ifdef HAVE_ONIG_REGION_MEMSIZE
- size += onig_region_memsize(&p->regs);
-#endif
- return size;
+ return sizeof(*p) - sizeof(p->regs) + onig_region_memsize(&p->regs);
}
static const rb_data_type_t strscanner_type = {
@@ -216,41 +208,19 @@ strscan_s_allocate(VALUE klass)
}
/*
- * call-seq:
- * StringScanner.new(string, fixed_anchor: false)
- * StringScanner.new(string, dup = false)
+ * call-seq: StringScanner.new(string, dup = false)
*
* Creates a new StringScanner object to scan over the given +string+.
- *
- * If +fixed_anchor+ is +true+, +\A+ always matches the beginning of
- * the string. Otherwise, +\A+ always matches the current position.
- *
* +dup+ argument is obsolete and not used now.
*/
static VALUE
strscan_initialize(int argc, VALUE *argv, VALUE self)
{
struct strscanner *p;
- VALUE str, options;
+ VALUE str, need_dup;
p = check_strscan(self);
- rb_scan_args(argc, argv, "11", &str, &options);
- options = rb_check_hash_type(options);
- if (!NIL_P(options)) {
- VALUE fixed_anchor;
- ID keyword_ids[1];
- keyword_ids[0] = rb_intern("fixed_anchor");
- rb_get_kwargs(options, keyword_ids, 0, 1, &fixed_anchor);
- if (fixed_anchor == Qundef) {
- p->fixed_anchor_p = false;
- }
- else {
- p->fixed_anchor_p = RTEST(fixed_anchor);
- }
- }
- else {
- p->fixed_anchor_p = false;
- }
+ rb_scan_args(argc, argv, "11", &str, &need_dup);
StringValue(str);
p->str = str;
@@ -324,7 +294,7 @@ strscan_reset(VALUE self)
* terminate
* clear
*
- * Sets the scan pointer to the end of the string and clear matching data.
+ * Set the scan pointer to the end of the string and clear matching data.
*/
static VALUE
strscan_terminate(VALUE self)
@@ -455,7 +425,7 @@ strscan_get_charpos(VALUE self)
/*
* call-seq: pos=(n)
*
- * Sets the byte position of the scan pointer.
+ * Set the byte position of the scan pointer.
*
* s = StringScanner.new('test string')
* s.pos = 7 # -> 7
@@ -476,83 +446,16 @@ strscan_set_pos(VALUE self, VALUE v)
return INT2NUM(i);
}
-static inline UChar *
-match_target(struct strscanner *p)
-{
- if (p->fixed_anchor_p) {
- return (UChar *)S_PBEG(p);
- }
- else
- {
- return (UChar *)CURPTR(p);
- }
-}
-
-static inline void
-set_registers(struct strscanner *p, size_t length)
-{
- const int at = 0;
- OnigRegion *regs = &(p->regs);
- onig_region_clear(regs);
- if (onig_region_set(regs, at, 0, 0)) return;
- if (p->fixed_anchor_p) {
- regs->beg[at] = p->curr;
- regs->end[at] = p->curr + length;
- }
- else
- {
- regs->end[at] = length;
- }
-}
-
-static inline void
-succ(struct strscanner *p)
-{
- if (p->fixed_anchor_p) {
- p->curr = p->regs.end[0];
- }
- else
- {
- p->curr += p->regs.end[0];
- }
-}
-
-static inline long
-last_match_length(struct strscanner *p)
-{
- if (p->fixed_anchor_p) {
- return p->regs.end[0] - p->prev;
- }
- else
- {
- return p->regs.end[0];
- }
-}
-
-static inline long
-adjust_register_position(struct strscanner *p, long position)
-{
- if (p->fixed_anchor_p) {
- return position;
- }
- else {
- return p->prev + position;
- }
-}
-
static VALUE
-strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly)
+strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly)
{
+ regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
struct strscanner *p;
+ regex_t *re;
+ long ret;
+ int tmpreg;
- if (headonly) {
- if (!RB_TYPE_P(pattern, T_REGEXP)) {
- StringValue(pattern);
- }
- }
- else {
- Check_Type(pattern, T_REGEXP);
- }
+ Check_Type(regex, T_REGEXP);
GET_SCANNER(self, p);
CLEAR_MATCH_STATUS(p);
@@ -560,76 +463,49 @@ strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly
return Qnil;
}
- if (RB_TYPE_P(pattern, T_REGEXP)) {
- regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
- regex_t *re;
- long ret;
- int tmpreg;
-
- p->regex = pattern;
- re = rb_reg_prepare_re(pattern, p->str);
- tmpreg = re != RREGEXP_PTR(pattern);
- if (!tmpreg) RREGEXP(pattern)->usecnt++;
-
- if (headonly) {
- ret = onig_match(re,
- match_target(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p),
- &(p->regs),
- ONIG_OPTION_NONE);
- }
- else {
- ret = onig_search(re,
- match_target(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- &(p->regs),
- ONIG_OPTION_NONE);
- }
- if (!tmpreg) RREGEXP(pattern)->usecnt--;
- if (tmpreg) {
- if (RREGEXP(pattern)->usecnt) {
- onig_free(re);
- }
- else {
- onig_free(RREGEXP_PTR(pattern));
- RREGEXP_PTR(pattern) = re;
- }
- }
+ p->regex = regex;
+ re = rb_reg_prepare_re(regex, p->str);
+ tmpreg = re != RREGEXP_PTR(regex);
+ if (!tmpreg) RREGEXP(regex)->usecnt++;
- if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
- if (ret < 0) {
- /* not matched */
- return Qnil;
- }
+ if (headonly) {
+ ret = onig_match(re, (UChar* )CURPTR(p),
+ (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ (UChar* )CURPTR(p), &(p->regs), ONIG_OPTION_NONE);
}
else {
- rb_enc_check(p->str, pattern);
- if (S_RESTLEN(p) < RSTRING_LEN(pattern)) {
- return Qnil;
+ ret = onig_search(re,
+ (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ &(p->regs), ONIG_OPTION_NONE);
+ }
+ if (!tmpreg) RREGEXP(regex)->usecnt--;
+ if (tmpreg) {
+ if (RREGEXP(regex)->usecnt) {
+ onig_free(re);
}
- if (memcmp(CURPTR(p), RSTRING_PTR(pattern), RSTRING_LEN(pattern)) != 0) {
- return Qnil;
+ else {
+ onig_free(RREGEXP_PTR(regex));
+ RREGEXP_PTR(regex) = re;
}
- set_registers(p, RSTRING_LEN(pattern));
+ }
+
+ if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
+ if (ret < 0) {
+ /* not matched */
+ return Qnil;
}
MATCHED(p);
p->prev = p->curr;
-
if (succptr) {
- succ(p);
+ p->curr += p->regs.end[0];
}
- {
- const long length = last_match_length(p);
- if (getstr) {
- return extract_beg_len(p, p->prev, length);
- }
- else {
- return INT2FIX(length);
- }
+ if (getstr) {
+ return extract_beg_len(p, p->prev, p->regs.end[0]);
+ }
+ else {
+ return INT2FIX(p->regs.end[0]);
}
}
@@ -644,8 +520,7 @@ strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly
* p s.scan(/\w+/) # -> "test"
* p s.scan(/\w+/) # -> nil
* p s.scan(/\s+/) # -> " "
- * p s.scan("str") # -> "str"
- * p s.scan(/\w+/) # -> "ing"
+ * p s.scan(/\w+/) # -> "string"
* p s.scan(/./) # -> nil
*
*/
@@ -664,7 +539,6 @@ strscan_scan(VALUE self, VALUE re)
* s = StringScanner.new('test string')
* p s.match?(/\w+/) # -> 4
* p s.match?(/\w+/) # -> 4
- * p s.match?("test") # -> 4
* p s.match?(/\s+/) # -> nil
*/
static VALUE
@@ -686,8 +560,7 @@ strscan_match_p(VALUE self, VALUE re)
* p s.skip(/\w+/) # -> 4
* p s.skip(/\w+/) # -> nil
* p s.skip(/\s+/) # -> 1
- * p s.skip("st") # -> 2
- * p s.skip(/\w+/) # -> 4
+ * p s.skip(/\w+/) # -> 6
* p s.skip(/./) # -> nil
*
*/
@@ -831,12 +704,7 @@ static void
adjust_registers_to_matched(struct strscanner *p)
{
onig_region_clear(&(p->regs));
- if (p->fixed_anchor_p) {
- onig_region_set(&(p->regs), 0, (int)p->prev, (int)p->curr);
- }
- else {
- onig_region_set(&(p->regs), 0, 0, (int)(p->curr - p->prev));
- }
+ onig_region_set(&(p->regs), 0, 0, (int)(p->curr - p->prev));
}
/*
@@ -870,9 +738,8 @@ strscan_getch(VALUE self)
p->curr += len;
MATCHED(p);
adjust_registers_to_matched(p);
- return extract_range(p,
- adjust_register_position(p, p->regs.beg[0]),
- adjust_register_position(p, p->regs.end[0]));
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
}
/*
@@ -905,9 +772,8 @@ strscan_get_byte(VALUE self)
p->curr++;
MATCHED(p);
adjust_registers_to_matched(p);
- return extract_range(p,
- adjust_register_position(p, p->regs.beg[0]),
- adjust_register_position(p, p->regs.end[0]));
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
}
/*
@@ -942,7 +808,7 @@ strscan_peek(VALUE self, VALUE vlen)
len = NUM2LONG(vlen);
if (EOS_P(p))
- return str_new(p, "", 0);
+ return infect(str_new(p, "", 0), p);
len = minl(len, S_RESTLEN(p));
return extract_beg_len(p, p->curr, len);
@@ -960,7 +826,7 @@ strscan_peep(VALUE self, VALUE vlen)
}
/*
- * Sets the scan pointer to the previous position. Only one previous position is
+ * Set the scan pointer to the previous position. Only one previous position is
* remembered, and it changes with each scanning operation.
*
* s = StringScanner.new('test string')
@@ -1085,9 +951,8 @@ strscan_matched(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
- return extract_range(p,
- adjust_register_position(p, p->regs.beg[0]),
- adjust_register_position(p, p->regs.end[0]));
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
}
/*
@@ -1183,9 +1048,8 @@ strscan_aref(VALUE self, VALUE idx)
if (i >= p->regs.num_regs) return Qnil;
if (p->regs.beg[i] == -1) return Qnil;
- return extract_range(p,
- adjust_register_position(p, p->regs.beg[i]),
- adjust_register_position(p, p->regs.end[i]));
+ return extract_range(p, p->prev + p->regs.beg[i],
+ p->prev + p->regs.end[i]);
}
/*
@@ -1234,9 +1098,8 @@ strscan_captures(VALUE self)
new_ary = rb_ary_new2(num_regs);
for (i = 1; i < num_regs; i++) {
- VALUE str = extract_range(p,
- adjust_register_position(p, p->regs.beg[i]),
- adjust_register_position(p, p->regs.end[i]));
+ VALUE str = extract_range(p, p->prev + p->regs.beg[i],
+ p->prev + p->regs.end[i]);
rb_ary_push(new_ary, str);
}
@@ -1291,9 +1154,7 @@ strscan_pre_match(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
- return extract_range(p,
- 0,
- adjust_register_position(p, p->regs.beg[0]));
+ return extract_range(p, 0, p->prev + p->regs.beg[0]);
}
/*
@@ -1312,9 +1173,7 @@ strscan_post_match(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
- return extract_range(p,
- adjust_register_position(p, p->regs.end[0]),
- S_LEN(p));
+ return extract_range(p, p->prev + p->regs.end[0], S_LEN(p));
}
/*
@@ -1328,7 +1187,7 @@ strscan_rest(VALUE self)
GET_SCANNER(self, p);
if (EOS_P(p)) {
- return str_new(p, "", 0);
+ return infect(str_new(p, "", 0), p);
}
return extract_range(p, p->curr, S_LEN(p));
}
@@ -1383,11 +1242,11 @@ strscan_inspect(VALUE self)
p = check_strscan(self);
if (NIL_P(p->str)) {
a = rb_sprintf("#<%"PRIsVALUE" (uninitialized)>", rb_obj_class(self));
- return a;
+ return infect(a, p);
}
if (EOS_P(p)) {
a = rb_sprintf("#<%"PRIsVALUE" fin>", rb_obj_class(self));
- return a;
+ return infect(a, p);
}
if (p->curr == 0) {
b = inspect2(p);
@@ -1395,7 +1254,7 @@ strscan_inspect(VALUE self)
rb_obj_class(self),
p->curr, S_LEN(p),
b);
- return a;
+ return infect(a, p);
}
a = inspect1(p);
b = inspect2(p);
@@ -1403,7 +1262,7 @@ strscan_inspect(VALUE self)
rb_obj_class(self),
p->curr, S_LEN(p),
a, b);
- return a;
+ return infect(a, p);
}
static VALUE
@@ -1443,23 +1302,6 @@ inspect2(struct strscanner *p)
return rb_str_dump(str);
}
-/*
- * call-seq:
- * scanner.fixed_anchor? -> true or false
- *
- * Whether +scanner+ uses fixed anchor mode or not.
- *
- * If fixed anchor mode is used, +\A+ always matches the beginning of
- * the string. Otherwise, +\A+ always matches the current position.
- */
-static VALUE
-strscan_fixed_anchor_p(VALUE self)
-{
- struct strscanner *p;
- p = check_strscan(self);
- return p->fixed_anchor_p ? Qtrue : Qfalse;
-}
-
/* =======================================================================
Ruby Interface
======================================================================= */
@@ -1570,7 +1412,6 @@ strscan_fixed_anchor_p(VALUE self)
void
Init_strscan(void)
{
-#undef rb_intern
ID id_scanerr = rb_intern("ScanError");
VALUE tmp;
@@ -1646,6 +1487,4 @@ Init_strscan(void)
rb_define_method(StringScanner, "restsize", strscan_restsize, 0);
rb_define_method(StringScanner, "inspect", strscan_inspect, 0);
-
- rb_define_method(StringScanner, "fixed_anchor?", strscan_fixed_anchor_p, 0);
}
diff --git a/ext/strscan/strscan.gemspec b/ext/strscan/strscan.gemspec
index 4759c6c860..e2f6cf5503 100644
--- a/ext/strscan/strscan.gemspec
+++ b/ext/strscan/strscan.gemspec
@@ -1,20 +1,20 @@
# frozen_string_literal: true
Gem::Specification.new do |s|
s.name = "strscan"
- s.version = '1.0.3'
+ s.version = '1.0.0'
+ s.date = '2017-12-19'
s.summary = "Provides lexical scanning operations on a String."
s.description = "Provides lexical scanning operations on a String."
s.require_path = %w{lib}
- s.files = %w{ext/strscan/extconf.rb ext/strscan/strscan.c}
+ s.files = %w{ext/strscan/extconf.rb ext/strscan/strscan.c ext/strscan/regenc.h ext/strscan/regint.h}
s.extensions = %w{ext/strscan/extconf.rb}
s.required_ruby_version = ">= 2.4.0"
- s.authors = ["Minero Aoki", "Sutou Kouhei"]
- s.email = [nil, "kou@cozmixng.org"]
+ s.authors = ["Minero Aoki"]
+ s.email = [nil]
s.homepage = "https://github.com/ruby/strscan"
s.license = "BSD-2-Clause"
s.add_development_dependency "rake-compiler"
- s.add_development_dependency "benchmark-driver"
end
diff --git a/ext/syslog/depend b/ext/syslog/depend
index a3f7db8371..ee2ad79052 100644
--- a/ext/syslog/depend
+++ b/ext/syslog/depend
@@ -1,7 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
syslog.o: $(RUBY_EXTCONF_H)
syslog.o: $(arch_hdrdir)/ruby/config.h
-syslog.o: $(hdrdir)/ruby/assert.h
syslog.o: $(hdrdir)/ruby/backward.h
syslog.o: $(hdrdir)/ruby/defines.h
syslog.o: $(hdrdir)/ruby/intern.h
diff --git a/ext/syslog/extconf.rb b/ext/syslog/extconf.rb
index 1230a4d52e..3bfea1fa73 100644
--- a/ext/syslog/extconf.rb
+++ b/ext/syslog/extconf.rb
@@ -4,8 +4,6 @@
require 'mkmf'
-have_library("log") # for Android
-
have_header("syslog.h") &&
have_func("openlog") &&
have_func("setlogmask") &&
diff --git a/ext/syslog/lib/syslog/logger.rb b/ext/syslog/lib/syslog/logger.rb
index 453ca2785c..06cbe5b19d 100644
--- a/ext/syslog/lib/syslog/logger.rb
+++ b/ext/syslog/lib/syslog/logger.rb
@@ -112,7 +112,7 @@ class Syslog::Logger
end
def #{meth}?
- level <= #{level}
+ @level <= #{level}
end
EOM
end
@@ -202,7 +202,7 @@ class Syslog::Logger
def add severity, message = nil, progname = nil, &block
severity ||= ::Logger::UNKNOWN
- level <= severity and
+ @level <= severity and
@@syslog.log( (LEVEL_MAP[severity] | @facility), '%s', formatter.call(severity, Time.now, progname, (message || block.call)) )
true
end
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
index 4c540fc9c7..317607eeef 100644
--- a/ext/syslog/syslog.c
+++ b/ext/syslog/syslog.c
@@ -162,6 +162,7 @@ static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
ident = rb_gv_get("$0");
}
ident_ptr = StringValueCStr(ident);
+ rb_check_safe_obj(ident);
syslog_ident = strdup(ident_ptr);
if (NIL_P(opt)) {
@@ -296,6 +297,10 @@ static VALUE mSyslog_set_mask(VALUE self, VALUE mask)
* Syslog.log(Syslog::LOG_ALERT, "Out of memory")
* Syslog.alert("Out of memory")
*
+ * Format strings are as for printf/sprintf, except that in addition %m is
+ * replaced with the error message string that would be returned by
+ * strerror(errno).
+ *
*/
static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
{
@@ -415,7 +420,6 @@ static VALUE mSyslogMacros_included(VALUE mod, VALUE target)
*/
void Init_syslog(void)
{
-#undef rb_intern
mSyslog = rb_define_module("Syslog");
mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
diff --git a/ext/win32/depend b/ext/win32/depend
deleted file mode 100644
index 0301ce074c..0000000000
--- a/ext/win32/depend
+++ /dev/null
@@ -1,2 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/win32/lib/Win32API.rb b/ext/win32/lib/Win32API.rb
index 97b29fbf74..d03ecc1c46 100644
--- a/ext/win32/lib/Win32API.rb
+++ b/ext/win32/lib/Win32API.rb
@@ -2,7 +2,7 @@
# frozen_string_literal: true
# for backward compatibility
-warn "Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead", uplevel: 2
+warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead" if $VERBOSE
require 'fiddle/import'
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index 451499b166..ea04bb34bf 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -575,9 +575,9 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
begin
type, data = read(subkey)
rescue Error
- else
- yield subkey, type, data
+ next
end
+ yield subkey, type, data
index += 1
end
index
diff --git a/ext/win32/lib/win32/resolv.rb b/ext/win32/lib/win32/resolv.rb
index 1eb70d5dc6..340a9b9d2b 100644
--- a/ext/win32/lib/win32/resolv.rb
+++ b/ext/win32/lib/win32/resolv.rb
@@ -42,19 +42,19 @@ begin
rescue LoadError
end
-if [nil].pack("p").size <= 4 # 32bit env
- begin
- f = Fiddle
- osid = f::Handle.new["rb_w32_osid"]
- rescue f::DLError # not ix86, cannot be Windows 9x
- else
- if f::Function.new(osid, [], f::TYPE_INT).call < 2 # VER_PLATFORM_WIN32_NT
- require_relative 'resolv9x'
- return
- end
- end
+nt = Module.new do
+ break true if [nil].pack("p").size > 4
+ extend Importer
+ dlload "kernel32.dll"
+ getv = extern "int GetVersionExA(void *)", :stdcall
+ info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
+ getv.call(info)
+ break info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
end
-
+if not nt
+ require_relative 'resolv9x'
+ # return # does not work yet
+else
module Win32
#====================================================================
# Windows NT
@@ -146,3 +146,4 @@ module Win32
end
end
end
+end
diff --git a/ext/win32/resolv/depend b/ext/win32/resolv/depend
deleted file mode 100644
index a6d24c3738..0000000000
--- a/ext/win32/resolv/depend
+++ /dev/null
@@ -1,17 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-resolv.o: $(RUBY_EXTCONF_H)
-resolv.o: $(arch_hdrdir)/ruby/config.h
-resolv.o: $(hdrdir)/ruby.h
-resolv.o: $(hdrdir)/ruby/assert.h
-resolv.o: $(hdrdir)/ruby/backward.h
-resolv.o: $(hdrdir)/ruby/defines.h
-resolv.o: $(hdrdir)/ruby/encoding.h
-resolv.o: $(hdrdir)/ruby/intern.h
-resolv.o: $(hdrdir)/ruby/missing.h
-resolv.o: $(hdrdir)/ruby/onigmo.h
-resolv.o: $(hdrdir)/ruby/oniguruma.h
-resolv.o: $(hdrdir)/ruby/ruby.h
-resolv.o: $(hdrdir)/ruby/st.h
-resolv.o: $(hdrdir)/ruby/subst.h
-resolv.o: resolv.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/win32ole/lib/win32ole.rb b/ext/win32ole/lib/win32ole.rb
index d7034f7845..635510b277 100644
--- a/ext/win32ole/lib/win32ole.rb
+++ b/ext/win32ole/lib/win32ole.rb
@@ -19,7 +19,7 @@ if defined?(WIN32OLE)
# #=> Did you mean? Add
#
def methods(*args)
- super + ole_methods_safely.map(&:name).map(&:to_sym)
+ super + ole_methods_safely.map(&:name)
end
private
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 4f4550c5b9..9d0b1b0431 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -1,7 +1,6 @@
/*
* (c) 1995 Microsoft Corporation. All rights reserved.
- * Developed by ActiveWare Internet Corp., now known as
- * ActiveState Tool Corp., http://www.ActiveState.com
+ * Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
*
* Other modifications Copyright (c) 1997, 1998 by Gurusamy Sarathy
* <gsar@umich.edu> and Jan Dubois <jan.dubois@ibm.net>
@@ -1985,6 +1984,10 @@ fole_s_connect(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "1*", &svr_name, &others);
StringValue(svr_name);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) {
+ rb_raise(rb_eSecurityError, "insecure connection - `%s'",
+ StringValuePtr(svr_name));
+ }
/* get CLSID from OLE server name */
pBuf = ole_vstr2wc(svr_name);
@@ -2474,8 +2477,16 @@ fole_initialize(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "11*:", &svr_name, &host, &others, &opts);
StringValue(svr_name);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) {
+ rb_raise(rb_eSecurityError, "insecure object creation - `%s'",
+ StringValuePtr(svr_name));
+ }
if (!NIL_P(host)) {
StringValue(host);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(host)) {
+ rb_raise(rb_eSecurityError, "insecure object creation - `%s'",
+ StringValuePtr(host));
+ }
return ole_create_dcom(self, svr_name, host, others);
}
@@ -2651,7 +2662,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
/*------------------------------------------
hash object ==> named dispatch parameters
--------------------------------------------*/
- cNamedArgs = rb_long2int((long)RHASH_SIZE(param));
+ cNamedArgs = rb_long2int(RHASH_SIZE(param));
op.dp.cArgs = cNamedArgs + argc - 2;
op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
@@ -3962,7 +3973,6 @@ check_nano_server(void)
}
}
-LCID cWIN32OLE_lcid;
void
Init_win32ole(void)
diff --git a/ext/win32ole/win32ole.h b/ext/win32ole/win32ole.h
index cd627ef765..c019930397 100644
--- a/ext/win32ole/win32ole.h
+++ b/ext/win32ole/win32ole.h
@@ -112,8 +112,8 @@ struct oledata {
IDispatch *pDispatch;
};
-extern VALUE cWIN32OLE;
-extern LCID cWIN32OLE_lcid;
+VALUE cWIN32OLE;
+LCID cWIN32OLE_lcid;
struct oledata *oledata_get_struct(VALUE obj);
LPWSTR ole_vstr2wc(VALUE vstr);
diff --git a/ext/win32ole/win32ole_error.c b/ext/win32ole/win32ole_error.c
index 2bb5156263..022527617e 100644
--- a/ext/win32ole/win32ole_error.c
+++ b/ext/win32ole/win32ole_error.c
@@ -60,9 +60,6 @@ ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...)
rb_exc_raise(rb_exc_new_str(ecs, msg));
}
-VALUE eWIN32OLERuntimeError;
-VALUE eWIN32OLEQueryInterfaceError;
-
void
Init_win32ole_error(void)
{
diff --git a/ext/win32ole/win32ole_error.h b/ext/win32ole/win32ole_error.h
index a2f329856f..296eb101ad 100644
--- a/ext/win32ole/win32ole_error.h
+++ b/ext/win32ole/win32ole_error.h
@@ -1,8 +1,8 @@
#ifndef WIN32OLE_ERROR_H
#define WIN32OLE_ERROR_H 1
-extern VALUE eWIN32OLERuntimeError;
-extern VALUE eWIN32OLEQueryInterfaceError;
+VALUE eWIN32OLERuntimeError;
+VALUE eWIN32OLEQueryInterfaceError;
NORETURN(PRINTF_ARGS(void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...), 3, 4));
void Init_win32ole_error(void);
diff --git a/ext/win32ole/win32ole_event.c b/ext/win32ole/win32ole_event.c
index 041639af6c..899480d7d0 100644
--- a/ext/win32ole/win32ole_event.c
+++ b/ext/win32ole/win32ole_event.c
@@ -922,6 +922,10 @@ ev_advise(int argc, VALUE *argv, VALUE self)
if(!RB_TYPE_P(itf, T_NIL)) {
pitf = StringValuePtr(itf);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(itf)) {
+ rb_raise(rb_eSecurityError, "insecure event creation - `%s'",
+ StringValuePtr(itf));
+ }
hr = find_iid(ole, pitf, &iid, &pTypeInfo);
}
else {
@@ -1260,7 +1264,6 @@ fev_get_handler(VALUE self)
void
Init_win32ole_event(void)
{
-#undef rb_intern
ary_ole_event = rb_ary_new();
rb_gc_register_mark_object(ary_ole_event);
id_events = rb_intern("events");
diff --git a/ext/win32ole/win32ole_method.c b/ext/win32ole/win32ole_method.c
index bf668300c2..456a45cfc4 100644
--- a/ext/win32ole/win32ole_method.c
+++ b/ext/win32ole/win32ole_method.c
@@ -283,7 +283,7 @@ folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
}
/*
- * call-seq:
+ * call-seq
* WIN32OLE_METHOD#name
*
* Returns the name of the method.
@@ -923,8 +923,6 @@ folemethod_inspect(VALUE self)
return default_inspect(self, "WIN32OLE_METHOD");
}
-VALUE cWIN32OLE_METHOD;
-
void Init_win32ole_method(void)
{
cWIN32OLE_METHOD = rb_define_class("WIN32OLE_METHOD", rb_cObject);
diff --git a/ext/win32ole/win32ole_method.h b/ext/win32ole/win32ole_method.h
index ef907d2fac..ff2898ebeb 100644
--- a/ext/win32ole/win32ole_method.h
+++ b/ext/win32ole/win32ole_method.h
@@ -7,7 +7,7 @@ struct olemethoddata {
UINT index;
};
-extern VALUE cWIN32OLE_METHOD;
+VALUE cWIN32OLE_METHOD;
VALUE folemethod_s_allocate(VALUE klass);
VALUE ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask);
VALUE create_win32ole_method(ITypeInfo *pTypeInfo, VALUE name);
diff --git a/ext/win32ole/win32ole_record.c b/ext/win32ole/win32ole_record.c
index 03523bc47d..e8838832a7 100644
--- a/ext/win32ole/win32ole_record.c
+++ b/ext/win32ole/win32ole_record.c
@@ -589,8 +589,6 @@ folerecord_inspect(VALUE self)
field);
}
-VALUE cWIN32OLE_RECORD;
-
void
Init_win32ole_record(void)
{
diff --git a/ext/win32ole/win32ole_record.h b/ext/win32ole/win32ole_record.h
index ab1df0ee7f..ea431e91f7 100644
--- a/ext/win32ole/win32ole_record.h
+++ b/ext/win32ole/win32ole_record.h
@@ -1,7 +1,7 @@
#ifndef WIN32OLE_RECORD_H
#define WIN32OLE_RECORD_H 1
-extern VALUE cWIN32OLE_RECORD;
+VALUE cWIN32OLE_RECORD;
void ole_rec2variant(VALUE rec, VARIANT *var);
void olerecord_set_ivar(VALUE obj, IRecordInfo *pri, void *prec);
VALUE create_win32ole_record(IRecordInfo *pri, void *prec);
diff --git a/ext/win32ole/win32ole_type.c b/ext/win32ole/win32ole_type.c
index fa39bf3696..e6ac402ecf 100644
--- a/ext/win32ole/win32ole_type.c
+++ b/ext/win32ole/win32ole_type.c
@@ -883,8 +883,6 @@ foletype_inspect(VALUE self)
return default_inspect(self, "WIN32OLE_TYPE");
}
-VALUE cWIN32OLE_TYPE;
-
void Init_win32ole_type(void)
{
cWIN32OLE_TYPE = rb_define_class("WIN32OLE_TYPE", rb_cObject);
diff --git a/ext/win32ole/win32ole_type.h b/ext/win32ole/win32ole_type.h
index 87b551e502..a26bf3e043 100644
--- a/ext/win32ole/win32ole_type.h
+++ b/ext/win32ole/win32ole_type.h
@@ -1,6 +1,6 @@
#ifndef WIN32OLE_TYPE_H
#define WIN32OLE_TYPE_H 1
-extern VALUE cWIN32OLE_TYPE;
+VALUE cWIN32OLE_TYPE;
VALUE create_win32ole_type(ITypeInfo *pTypeInfo, VALUE name);
ITypeInfo *itypeinfo(VALUE self);
VALUE ole_type_from_itypeinfo(ITypeInfo *pTypeInfo);
diff --git a/ext/win32ole/win32ole_typelib.c b/ext/win32ole/win32ole_typelib.c
index d89f181e07..35376c644b 100644
--- a/ext/win32ole/win32ole_typelib.c
+++ b/ext/win32ole/win32ole_typelib.c
@@ -822,8 +822,6 @@ foletypelib_inspect(VALUE self)
return default_inspect(self, "WIN32OLE_TYPELIB");
}
-VALUE cWIN32OLE_TYPELIB;
-
void
Init_win32ole_typelib(void)
{
diff --git a/ext/win32ole/win32ole_typelib.h b/ext/win32ole/win32ole_typelib.h
index 2c2730bb58..9fc117fcb4 100644
--- a/ext/win32ole/win32ole_typelib.h
+++ b/ext/win32ole/win32ole_typelib.h
@@ -1,7 +1,7 @@
#ifndef WIN32OLE_TYPELIB_H
#define WIN32OLE_TYPELIB_H 1
-extern VALUE cWIN32OLE_TYPELIB;
+VALUE cWIN32OLE_TYPELIB;
void Init_win32ole_typelib(void);
ITypeLib * itypelib(VALUE self);
diff --git a/ext/win32ole/win32ole_variable.c b/ext/win32ole/win32ole_variable.c
index 803083156c..3dc9972ee7 100644
--- a/ext/win32ole/win32ole_variable.c
+++ b/ext/win32ole/win32ole_variable.c
@@ -365,8 +365,6 @@ folevariable_inspect(VALUE self)
return make_inspect("WIN32OLE_VARIABLE", detail);
}
-VALUE cWIN32OLE_VARIABLE;
-
void Init_win32ole_variable(void)
{
cWIN32OLE_VARIABLE = rb_define_class("WIN32OLE_VARIABLE", rb_cObject);
diff --git a/ext/win32ole/win32ole_variable.h b/ext/win32ole/win32ole_variable.h
index 209613fd44..704dc13508 100644
--- a/ext/win32ole/win32ole_variable.h
+++ b/ext/win32ole/win32ole_variable.h
@@ -1,7 +1,7 @@
#ifndef WIN32OLE_VARIABLE_H
#define WIN32OLE_VARIABLE_H 1
-extern VALUE cWIN32OLE_VARIABLE;
+VALUE cWIN32OLE_VARIABLE;
VALUE create_win32ole_variable(ITypeInfo *pTypeInfo, UINT index, VALUE name);
void Init_win32ole_variable(void);
diff --git a/ext/win32ole/win32ole_variant.c b/ext/win32ole/win32ole_variant.c
index 93f0636593..eb0a463f93 100644
--- a/ext/win32ole/win32ole_variant.c
+++ b/ext/win32ole/win32ole_variant.c
@@ -689,12 +689,9 @@ ole_variant2variant(VALUE val, VARIANT *var)
VariantCopy(var, &(pvar->var));
}
-VALUE cWIN32OLE_VARIANT;
-
void
Init_win32ole_variant(void)
{
-#undef rb_intern
cWIN32OLE_VARIANT = rb_define_class("WIN32OLE_VARIANT", rb_cObject);
rb_define_alloc_func(cWIN32OLE_VARIANT, folevariant_s_allocate);
rb_define_singleton_method(cWIN32OLE_VARIANT, "array", folevariant_s_array, 2);
diff --git a/ext/win32ole/win32ole_variant.h b/ext/win32ole/win32ole_variant.h
index 4bd3b0aeea..efe7ea8bef 100644
--- a/ext/win32ole/win32ole_variant.h
+++ b/ext/win32ole/win32ole_variant.h
@@ -1,7 +1,7 @@
#ifndef WIN32OLE_VARIANT_H
#define WIN32OLE_VARIANT_H 1
-extern VALUE cWIN32OLE_VARIANT;
+VALUE cWIN32OLE_VARIANT;
void ole_variant2variant(VALUE val, VARIANT *var);
void Init_win32ole_variant(void);
diff --git a/ext/win32ole/win32ole_variant_m.c b/ext/win32ole/win32ole_variant_m.c
index 145c08a16e..4d76fdc790 100644
--- a/ext/win32ole/win32ole_variant_m.c
+++ b/ext/win32ole/win32ole_variant_m.c
@@ -1,7 +1,5 @@
#include "win32ole.h"
-VALUE mWIN32OLE_VARIANT;
-
void Init_win32ole_variant_m(void)
{
/*
diff --git a/ext/win32ole/win32ole_variant_m.h b/ext/win32ole/win32ole_variant_m.h
index 6272a6578f..afbef30218 100644
--- a/ext/win32ole/win32ole_variant_m.h
+++ b/ext/win32ole/win32ole_variant_m.h
@@ -1,7 +1,7 @@
#ifndef WIN32OLE_VARIANT_M_H
#define WIN32OLE_VARIANT_M_H 1
-extern VALUE mWIN32OLE_VARIANT;
+VALUE mWIN32OLE_VARIANT;
void Init_win32ole_variant_m(void);
#endif
diff --git a/ext/zlib/.gitignore b/ext/zlib/.gitignore
deleted file mode 100644
index 069491b4b4..0000000000
--- a/ext/zlib/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/zlib-[1-9]*.*.*
diff --git a/ext/zlib/depend b/ext/zlib/depend
index 5ab5684fb0..bfba309dae 100644
--- a/ext/zlib/depend
+++ b/ext/zlib/depend
@@ -1,8 +1,6 @@
# AUTOGENERATED DEPENDENCIES START
zlib.o: $(RUBY_EXTCONF_H)
zlib.o: $(arch_hdrdir)/ruby/config.h
-zlib.o: $(hdrdir)/ruby.h
-zlib.o: $(hdrdir)/ruby/assert.h
zlib.o: $(hdrdir)/ruby/backward.h
zlib.o: $(hdrdir)/ruby/defines.h
zlib.o: $(hdrdir)/ruby/encoding.h
@@ -15,5 +13,6 @@ zlib.o: $(hdrdir)/ruby/ruby.h
zlib.o: $(hdrdir)/ruby/st.h
zlib.o: $(hdrdir)/ruby/subst.h
zlib.o: $(hdrdir)/ruby/thread.h
+zlib.o: $(top_srcdir)/include/ruby.h
zlib.o: zlib.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 82e9fc42da..4cae484937 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -25,11 +25,7 @@
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#endif
-#define RUBY_ZLIB_VERSION "1.1.0"
-
-#ifndef RB_PASS_CALLED_KEYWORDS
-# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
-#endif
+#define RUBY_ZLIB_VERSION "0.6.0"
#ifndef GZIP_SUPPORT
#define GZIP_SUPPORT 1
@@ -89,7 +85,6 @@ static void zstream_passthrough_input(struct zstream*);
static VALUE zstream_detach_input(struct zstream*);
static void zstream_reset(struct zstream*);
static VALUE zstream_end(struct zstream*);
-static VALUE zstream_ensure_end(VALUE v);
static void zstream_run(struct zstream*, Bytef*, long, int);
static VALUE zstream_sync(struct zstream*, Bytef*, long);
static void zstream_mark(void*);
@@ -145,19 +140,19 @@ static void gzfile_reset(struct gzfile*);
static void gzfile_close(struct gzfile*, int);
static void gzfile_write_raw(struct gzfile*);
static VALUE gzfile_read_raw_partial(VALUE);
-static VALUE gzfile_read_raw_rescue(VALUE,VALUE);
-static VALUE gzfile_read_raw(struct gzfile*, VALUE outbuf);
-static int gzfile_read_raw_ensure(struct gzfile*, long, VALUE outbuf);
+static VALUE gzfile_read_raw_rescue(VALUE);
+static VALUE gzfile_read_raw(struct gzfile*);
+static int gzfile_read_raw_ensure(struct gzfile*, long);
static char *gzfile_read_raw_until_zero(struct gzfile*, long);
static unsigned int gzfile_get16(const unsigned char*);
static unsigned long gzfile_get32(const unsigned char*);
static void gzfile_set32(unsigned long n, unsigned char*);
static void gzfile_make_header(struct gzfile*);
static void gzfile_make_footer(struct gzfile*);
-static void gzfile_read_header(struct gzfile*, VALUE outbuf);
-static void gzfile_check_footer(struct gzfile*, VALUE outbuf);
+static void gzfile_read_header(struct gzfile*);
+static void gzfile_check_footer(struct gzfile*);
static void gzfile_write(struct gzfile*, Bytef*, long);
-static long gzfile_read_more(struct gzfile*, VALUE outbuf);
+static long gzfile_read_more(struct gzfile*);
static void gzfile_calc_crc(struct gzfile*, VALUE);
static VALUE gzfile_read(struct gzfile*, long);
static VALUE gzfile_read_all(struct gzfile*);
@@ -285,7 +280,6 @@ static VALUE rb_gzreader_readlines(int, VALUE*, VALUE);
* - Zlib::MemError
* - Zlib::BufError
* - Zlib::VersionError
- * - Zlib::InProgressError
*
* (if you have GZIP_SUPPORT)
* - Zlib::GzipReader
@@ -302,7 +296,7 @@ void Init_zlib(void);
/*--------- Exceptions --------*/
static VALUE cZError, cStreamEnd, cNeedDict;
-static VALUE cStreamError, cDataError, cMemError, cBufError, cVersionError, cInProgressError;
+static VALUE cStreamError, cDataError, cMemError, cBufError, cVersionError;
static void
raise_zlib_error(int err, const char *msg)
@@ -366,7 +360,11 @@ finalizer_warn(const char *msg)
static VALUE
rb_zlib_version(VALUE klass)
{
- return rb_str_new2(zlibVersion());
+ VALUE str;
+
+ str = rb_str_new2(zlibVersion());
+ OBJ_TAINT(str); /* for safe */
+ return str;
}
#if SIZEOF_LONG > SIZEOF_INT
@@ -531,7 +529,6 @@ struct zstream {
unsigned long flags;
VALUE buf;
VALUE input;
- VALUE mutex;
z_stream stream;
const struct zstream_funcs {
int (*reset)(z_streamp);
@@ -540,14 +537,13 @@ struct zstream {
} *func;
};
-#define ZSTREAM_FLAG_READY (1 << 0)
-#define ZSTREAM_FLAG_IN_STREAM (1 << 1)
-#define ZSTREAM_FLAG_FINISHED (1 << 2)
-#define ZSTREAM_FLAG_CLOSING (1 << 3)
-#define ZSTREAM_FLAG_GZFILE (1 << 4) /* disallows yield from expand_buffer for
+#define ZSTREAM_FLAG_READY 0x1
+#define ZSTREAM_FLAG_IN_STREAM 0x2
+#define ZSTREAM_FLAG_FINISHED 0x4
+#define ZSTREAM_FLAG_CLOSING 0x8
+#define ZSTREAM_FLAG_GZFILE 0x10 /* disallows yield from expand_buffer for
gzip*/
-#define ZSTREAM_IN_PROGRESS (1 << 5)
-#define ZSTREAM_FLAG_UNUSED (1 << 6)
+#define ZSTREAM_FLAG_UNUSED 0x20
#define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
#define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
@@ -574,9 +570,7 @@ static const struct zstream_funcs inflate_funcs = {
};
struct zstream_run_args {
- struct zstream *const z;
- Bytef *src;
- long len;
+ struct zstream * z;
int flush; /* stream flush value for inflate() or deflate() */
int interrupt; /* stop processing the stream and return to ruby */
int jump_state; /* for buffer expansion block break or exception */
@@ -607,7 +601,6 @@ zstream_init(struct zstream *z, const struct zstream_funcs *func)
z->flags = 0;
z->buf = Qnil;
z->input = Qnil;
- z->mutex = rb_mutex_new();
z->stream.zalloc = zlib_mem_alloc;
z->stream.zfree = zlib_mem_free;
z->stream.opaque = Z_NULL;
@@ -634,12 +627,12 @@ zstream_expand_buffer(struct zstream *z)
long buf_filled = ZSTREAM_BUF_FILLED(z);
if (buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
int state = 0;
+ VALUE self = (VALUE)z->stream.opaque;
rb_obj_reveal(z->buf, rb_cString);
+ OBJ_INFECT(z->buf, self);
- rb_mutex_unlock(z->mutex);
rb_protect(rb_yield, z->buf, &state);
- rb_mutex_lock(z->mutex);
z->buf = Qnil;
zstream_expand_buffer_into(z, ZSTREAM_AVAIL_OUT_STEP_MAX);
@@ -745,7 +738,7 @@ zstream_append_buffer(struct zstream *z, const Bytef *src, long len)
static VALUE
zstream_detach_buffer(struct zstream *z)
{
- VALUE dst;
+ VALUE dst, self = (VALUE)z->stream.opaque;
if (!ZSTREAM_IS_FINISHED(z) && !ZSTREAM_IS_GZFILE(z) &&
rb_block_given_p()) {
@@ -762,6 +755,8 @@ zstream_detach_buffer(struct zstream *z)
rb_obj_reveal(dst, rb_cString);
}
+ OBJ_INFECT(dst, self);
+
z->buf = Qnil;
z->stream.next_out = 0;
z->stream.avail_out = 0;
@@ -850,50 +845,19 @@ zstream_append_input(struct zstream *z, const Bytef *src, long len)
static void
zstream_discard_input(struct zstream *z, long len)
{
- if (NIL_P(z->input)) {
- }
- else if (RBASIC_CLASS(z->input) == 0) {
- /* hidden, we created z->input and have complete control */
- char *ptr;
- long oldlen, newlen;
-
- RSTRING_GETMEM(z->input, ptr, oldlen);
- newlen = oldlen - len;
- if (newlen > 0) {
- memmove(ptr, ptr + len, newlen);
- }
- if (newlen < 0) {
- newlen = 0;
- }
- rb_str_resize(z->input, newlen);
- if (newlen == 0) {
- rb_gc_force_recycle(z->input);
- z->input = Qnil;
- }
- else {
- rb_str_set_len(z->input, newlen);
- }
+ if (NIL_P(z->input) || RSTRING_LEN(z->input) <= len) {
+ z->input = Qnil;
}
- else { /* do not mangle user-provided data */
- if (RSTRING_LEN(z->input) <= len) {
- z->input = Qnil;
- }
- else {
- z->input = rb_str_substr(z->input, len,
- RSTRING_LEN(z->input) - len);
- }
+ else {
+ z->input = rb_str_substr(z->input, len,
+ RSTRING_LEN(z->input) - len);
}
}
static void
zstream_reset_input(struct zstream *z)
{
- if (!NIL_P(z->input) && RBASIC_CLASS(z->input) == 0) {
- rb_str_resize(z->input, 0);
- }
- else {
- z->input = Qnil;
- }
+ z->input = Qnil;
}
static void
@@ -918,6 +882,7 @@ zstream_detach_input(struct zstream *z)
rb_obj_reveal(dst, rb_cString);
}
z->input = Qnil;
+ rb_obj_reveal(dst, rb_cString);
return dst;
}
@@ -960,12 +925,6 @@ zstream_end(struct zstream *z)
return Qnil;
}
-static VALUE
-zstream_ensure_end(VALUE v)
-{
- return zstream_end((struct zstream *)v);
-}
-
static void *
zstream_run_func(void *ptr)
{
@@ -1022,7 +981,6 @@ zstream_run_func(void *ptr)
/*
* There is no safe way to interrupt z->run->func().
- * async-signal-safe
*/
static void
zstream_unblock_func(void *ptr)
@@ -1032,17 +990,18 @@ zstream_unblock_func(void *ptr)
args->interrupt = 1;
}
-static VALUE
-zstream_run_try(VALUE value_arg)
+static void
+zstream_run(struct zstream *z, Bytef *src, long len, int flush)
{
- struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
- struct zstream *z = args->z;
- Bytef *src = args->src;
- long len = args->len;
- int flush = args->flush;
-
+ struct zstream_run_args args;
int err;
- VALUE old_input = Qnil;
+ VALUE guard = Qnil;
+
+ args.z = z;
+ args.flush = flush;
+ args.interrupt = 0;
+ args.jump_state = 0;
+ args.stream_output = !ZSTREAM_IS_GZFILE(z) && rb_block_given_p();
if (NIL_P(z->input) && len == 0) {
z->stream.next_in = (Bytef*)"";
@@ -1050,13 +1009,12 @@ zstream_run_try(VALUE value_arg)
}
else {
zstream_append_input(z, src, len);
+ z->stream.next_in = (Bytef*)RSTRING_PTR(z->input);
+ z->stream.avail_in = MAX_UINT(RSTRING_LEN(z->input));
/* keep reference to `z->input' so as not to be garbage collected
after zstream_reset_input() and prevent `z->stream.next_in'
from dangling. */
- old_input = zstream_detach_input(z);
- rb_obj_hide(old_input); /* for GVL release and later recycle */
- z->stream.next_in = (Bytef*)RSTRING_PTR(old_input);
- z->stream.avail_in = MAX_UINT(RSTRING_LEN(old_input));
+ guard = z->input;
}
if (z->stream.avail_out == 0) {
@@ -1064,20 +1022,8 @@ zstream_run_try(VALUE value_arg)
}
loop:
-#ifndef RB_NOGVL_UBF_ASYNC_SAFE
- err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)args,
- zstream_unblock_func, (void *)args);
-#else
- err = (int)(VALUE)rb_nogvl(zstream_run_func, (void *)args,
- zstream_unblock_func, (void *)args,
- RB_NOGVL_UBF_ASYNC_SAFE);
-#endif
-
- /* retry if no exception is thrown */
- if (err == Z_OK && args->interrupt) {
- args->interrupt = 0;
- goto loop;
- }
+ err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)&args,
+ zstream_unblock_func, (void *)&args);
if (flush != Z_FINISH && err == Z_BUF_ERROR
&& z->stream.avail_out > 0) {
@@ -1106,58 +1052,13 @@ loop:
if (z->stream.avail_in > 0) {
zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
+ RB_GC_GUARD(guard); /* prevent tail call to make guard effective */
}
- if (!NIL_P(old_input)) {
- rb_str_resize(old_input, 0);
- rb_gc_force_recycle(old_input);
- }
-
- if (args->jump_state)
- rb_jump_tag(args->jump_state);
- return Qnil;
-}
-
-static VALUE
-zstream_run_ensure(VALUE value_arg)
-{
- struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
-
- /* Remove ZSTREAM_IN_PROGRESS flag to signal that this zstream is not in use. */
- args->z->flags &= ~ZSTREAM_IN_PROGRESS;
-
- return Qnil;
-}
-
-static VALUE
-zstream_run_synchronized(VALUE value_arg)
-{
- struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
-
- /* Cannot start zstream while it is in progress. */
- if (args->z->flags & ZSTREAM_IN_PROGRESS) {
- rb_raise(cInProgressError, "zlib stream is in progress");
- }
- args->z->flags |= ZSTREAM_IN_PROGRESS;
-
- rb_ensure(zstream_run_try, value_arg, zstream_run_ensure, value_arg);
- return Qnil;
+ if (args.jump_state)
+ rb_jump_tag(args.jump_state);
}
-static void
-zstream_run(struct zstream *z, Bytef *src, long len, int flush)
-{
- struct zstream_run_args args = {
- .z = z,
- .src = src,
- .len = len,
- .flush = flush,
- .interrupt = 0,
- .jump_state = 0,
- .stream_output = !ZSTREAM_IS_GZFILE(z) && rb_block_given_p(),
- };
- rb_mutex_synchronize(z->mutex, zstream_run_synchronized, (VALUE)&args);
-}
static VALUE
zstream_sync(struct zstream *z, Bytef *src, long len)
{
@@ -1203,7 +1104,6 @@ zstream_mark(void *p)
struct zstream *z = p;
rb_gc_mark(z->buf);
rb_gc_mark(z->input);
- rb_gc_mark(z->mutex);
}
static void
@@ -1385,6 +1285,7 @@ rb_zstream_flush_next_in(VALUE obj)
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
dst = zstream_detach_input(z);
+ OBJ_INFECT(dst, obj);
return dst;
}
@@ -1703,8 +1604,9 @@ rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
args[0] = (VALUE)&z;
args[1] = src;
- dst = rb_ensure(deflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z);
+ dst = rb_ensure(deflate_run, (VALUE)args, zstream_end, (VALUE)&z);
+ OBJ_INFECT(dst, src);
return dst;
}
@@ -1754,6 +1656,7 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
VALUE src, flush;
rb_scan_args(argc, argv, "11", &src, &flush);
+ OBJ_INFECT(obj, src);
do_deflate(z, src, ARG_FLUSH(flush));
return zstream_detach_buffer(z);
@@ -1771,6 +1674,7 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
static VALUE
rb_deflate_addstr(VALUE obj, VALUE src)
{
+ OBJ_INFECT(obj, src);
do_deflate(get_zstream(obj), src, Z_NO_FLUSH);
return obj;
}
@@ -1870,6 +1774,7 @@ rb_deflate_set_dictionary(VALUE obj, VALUE dic)
VALUE src = dic;
int err;
+ OBJ_INFECT(obj, dic);
StringValue(src);
err = deflateSetDictionary(&z->stream,
(Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src));
@@ -2014,8 +1919,9 @@ rb_inflate_s_inflate(VALUE obj, VALUE src)
args[0] = (VALUE)&z;
args[1] = src;
- dst = rb_ensure(inflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z);
+ dst = rb_ensure(inflate_run, (VALUE)args, zstream_end, (VALUE)&z);
+ OBJ_INFECT(dst, src);
return dst;
}
@@ -2095,6 +2001,8 @@ rb_inflate_inflate(VALUE obj, VALUE src)
struct zstream *z = get_zstream(obj);
VALUE dst;
+ OBJ_INFECT(obj, src);
+
if (ZSTREAM_IS_FINISHED(z)) {
if (NIL_P(src)) {
dst = zstream_detach_buffer(z);
@@ -2103,6 +2011,7 @@ rb_inflate_inflate(VALUE obj, VALUE src)
StringValue(src);
zstream_append_buffer2(z, src);
dst = rb_str_new(0, 0);
+ OBJ_INFECT(dst, obj);
}
}
else {
@@ -2128,6 +2037,8 @@ rb_inflate_addstr(VALUE obj, VALUE src)
{
struct zstream *z = get_zstream(obj);
+ OBJ_INFECT(obj, src);
+
if (ZSTREAM_IS_FINISHED(z)) {
if (!NIL_P(src)) {
StringValue(src);
@@ -2157,6 +2068,7 @@ rb_inflate_sync(VALUE obj, VALUE src)
{
struct zstream *z = get_zstream(obj);
+ OBJ_INFECT(obj, src);
StringValue(src);
return zstream_sync(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src));
}
@@ -2198,6 +2110,7 @@ rb_inflate_set_dictionary(VALUE obj, VALUE dic)
VALUE src = dic;
int err;
+ OBJ_INFECT(obj, dic);
StringValue(src);
err = inflateSetDictionary(&z->stream,
(Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src));
@@ -2278,6 +2191,7 @@ struct gzfile {
rb_encoding *enc2;
rb_econv_t *ec;
VALUE ecopts;
+ char *cbuf;
VALUE path;
};
#define GZFILE_CBUF_CAPA 10
@@ -2285,23 +2199,12 @@ struct gzfile {
#define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED
#define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)
#define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
-#define GZFILE_FLAG_MTIME_IS_SET (ZSTREAM_FLAG_UNUSED << 3)
#define GZFILE_IS_FINISHED(gz) \
(ZSTREAM_IS_FINISHED(&(gz)->z) && ZSTREAM_BUF_FILLED(&(gz)->z) == 0)
#define GZFILE_READ_SIZE 2048
-struct read_raw_arg {
- VALUE io;
- union {
- const VALUE argv[2]; /* for rb_funcallv */
- struct {
- VALUE len;
- VALUE buf;
- } in;
- } as;
-};
static void
gzfile_mark(void *p)
@@ -2328,13 +2231,22 @@ gzfile_free(void *p)
}
zstream_finalize(z);
}
+ if (gz->cbuf) {
+ xfree(gz->cbuf);
+ }
xfree(gz);
}
static size_t
gzfile_memsize(const void *p)
{
- return sizeof(struct gzfile);
+ const struct gzfile *gz = p;
+ size_t size = sizeof(struct gzfile);
+
+ if (gz->cbuf)
+ size += GZFILE_CBUF_CAPA;
+
+ return size;
}
static const rb_data_type_t gzfile_data_type = {
@@ -2363,6 +2275,7 @@ gzfile_init(struct gzfile *gz, const struct zstream_funcs *funcs, void (*endfunc
gz->ec = NULL;
gz->ecflags = 0;
gz->ecopts = Qnil;
+ gz->cbuf = 0;
gz->path = Qnil;
}
@@ -2416,6 +2329,7 @@ gzfile_write_raw(struct gzfile *gz)
if (ZSTREAM_BUF_FILLED(&gz->z) > 0) {
str = zstream_detach_buffer(&gz->z);
+ OBJ_TAINT(str); /* for safe */
rb_funcall(gz->io, id_write, 1, str);
if ((gz->z.flags & GZFILE_FLAG_SYNC)
&& rb_respond_to(gz->io, id_flush))
@@ -2426,23 +2340,21 @@ gzfile_write_raw(struct gzfile *gz)
static VALUE
gzfile_read_raw_partial(VALUE arg)
{
- struct read_raw_arg *ra = (struct read_raw_arg *)arg;
+ struct gzfile *gz = (struct gzfile*)arg;
VALUE str;
- int argc = NIL_P(ra->as.argv[1]) ? 1 : 2;
- str = rb_funcallv(ra->io, id_readpartial, argc, ra->as.argv);
+ str = rb_funcall(gz->io, id_readpartial, 1, INT2FIX(GZFILE_READ_SIZE));
Check_Type(str, T_STRING);
return str;
}
static VALUE
-gzfile_read_raw_rescue(VALUE arg, VALUE _)
+gzfile_read_raw_rescue(VALUE arg)
{
- struct read_raw_arg *ra = (struct read_raw_arg *)arg;
+ struct gzfile *gz = (struct gzfile*)arg;
VALUE str = Qnil;
if (rb_obj_is_kind_of(rb_errinfo(), rb_eNoMethodError)) {
- int argc = NIL_P(ra->as.argv[1]) ? 1 : 2;
- str = rb_funcallv(ra->io, id_read, argc, ra->as.argv);
+ str = rb_funcall(gz->io, id_read, 1, INT2FIX(GZFILE_READ_SIZE));
if (!NIL_P(str)) {
Check_Type(str, T_STRING);
}
@@ -2451,21 +2363,15 @@ gzfile_read_raw_rescue(VALUE arg, VALUE _)
}
static VALUE
-gzfile_read_raw(struct gzfile *gz, VALUE outbuf)
+gzfile_read_raw(struct gzfile *gz)
{
- struct read_raw_arg ra;
-
- ra.io = gz->io;
- ra.as.in.len = INT2FIX(GZFILE_READ_SIZE);
- ra.as.in.buf = outbuf;
-
- return rb_rescue2(gzfile_read_raw_partial, (VALUE)&ra,
- gzfile_read_raw_rescue, (VALUE)&ra,
+ return rb_rescue2(gzfile_read_raw_partial, (VALUE)gz,
+ gzfile_read_raw_rescue, (VALUE)gz,
rb_eEOFError, rb_eNoMethodError, (VALUE)0);
}
static int
-gzfile_read_raw_ensure(struct gzfile *gz, long size, VALUE outbuf)
+gzfile_read_raw_ensure(struct gzfile *gz, long size)
{
VALUE str;
@@ -2474,7 +2380,7 @@ gzfile_read_raw_ensure(struct gzfile *gz, long size, VALUE outbuf)
rb_raise(cGzError, "unexpected end of string");
}
while (NIL_P(gz->z.input) || RSTRING_LEN(gz->z.input) < size) {
- str = gzfile_read_raw(gz, outbuf);
+ str = gzfile_read_raw(gz);
if (NIL_P(str)) return 0;
zstream_append_input2(&gz->z, str);
}
@@ -2491,7 +2397,7 @@ gzfile_read_raw_until_zero(struct gzfile *gz, long offset)
p = memchr(RSTRING_PTR(gz->z.input) + offset, '\0',
RSTRING_LEN(gz->z.input) - offset);
if (p) break;
- str = gzfile_read_raw(gz, Qnil);
+ str = gzfile_read_raw(gz);
if (NIL_P(str)) {
rb_raise(cGzError, "unexpected end of file");
}
@@ -2572,7 +2478,7 @@ gzfile_make_header(struct gzfile *gz)
if (!NIL_P(gz->comment)) {
flags |= GZ_FLAG_COMMENT;
}
- if (!(gz->z.flags & GZFILE_FLAG_MTIME_IS_SET)) {
+ if (gz->mtime == 0) {
gz->mtime = time(0);
}
@@ -2616,14 +2522,13 @@ gzfile_make_footer(struct gzfile *gz)
}
static void
-gzfile_read_header(struct gzfile *gz, VALUE outbuf)
+gzfile_read_header(struct gzfile *gz)
{
const unsigned char *head;
long len;
char flags, *p;
- /* 10 is the size of gzip header */
- if (!gzfile_read_raw_ensure(gz, 10, outbuf)) {
+ if (!gzfile_read_raw_ensure(gz, 10)) { /* 10 is the size of gzip header */
gzfile_raise(gz, cGzError, "not in gzip format");
}
@@ -2662,31 +2567,33 @@ gzfile_read_header(struct gzfile *gz, VALUE outbuf)
zstream_discard_input(&gz->z, 10);
if (flags & GZ_FLAG_EXTRA) {
- if (!gzfile_read_raw_ensure(gz, 2, outbuf)) {
+ if (!gzfile_read_raw_ensure(gz, 2)) {
rb_raise(cGzError, "unexpected end of file");
}
len = gzfile_get16((Bytef*)RSTRING_PTR(gz->z.input));
- if (!gzfile_read_raw_ensure(gz, 2 + len, outbuf)) {
+ if (!gzfile_read_raw_ensure(gz, 2 + len)) {
rb_raise(cGzError, "unexpected end of file");
}
zstream_discard_input(&gz->z, 2 + len);
}
if (flags & GZ_FLAG_ORIG_NAME) {
- if (!gzfile_read_raw_ensure(gz, 1, outbuf)) {
+ if (!gzfile_read_raw_ensure(gz, 1)) {
rb_raise(cGzError, "unexpected end of file");
}
p = gzfile_read_raw_until_zero(gz, 0);
len = p - RSTRING_PTR(gz->z.input);
gz->orig_name = rb_str_new(RSTRING_PTR(gz->z.input), len);
+ OBJ_TAINT(gz->orig_name); /* for safe */
zstream_discard_input(&gz->z, len + 1);
}
if (flags & GZ_FLAG_COMMENT) {
- if (!gzfile_read_raw_ensure(gz, 1, outbuf)) {
+ if (!gzfile_read_raw_ensure(gz, 1)) {
rb_raise(cGzError, "unexpected end of file");
}
p = gzfile_read_raw_until_zero(gz, 0);
len = p - RSTRING_PTR(gz->z.input);
gz->comment = rb_str_new(RSTRING_PTR(gz->z.input), len);
+ OBJ_TAINT(gz->comment); /* for safe */
zstream_discard_input(&gz->z, len + 1);
}
@@ -2696,14 +2603,13 @@ gzfile_read_header(struct gzfile *gz, VALUE outbuf)
}
static void
-gzfile_check_footer(struct gzfile *gz, VALUE outbuf)
+gzfile_check_footer(struct gzfile *gz)
{
unsigned long crc, length;
gz->z.flags |= GZFILE_FLAG_FOOTER_FINISHED;
- /* 8 is the size of gzip footer */
- if (!gzfile_read_raw_ensure(gz, 8, outbuf)) {
+ if (!gzfile_read_raw_ensure(gz, 8)) { /* 8 is the size of gzip footer */
gzfile_raise(gz, cNoFooter, "footer is not found");
}
@@ -2737,12 +2643,12 @@ gzfile_write(struct gzfile *gz, Bytef *str, long len)
}
static long
-gzfile_read_more(struct gzfile *gz, VALUE outbuf)
+gzfile_read_more(struct gzfile *gz)
{
VALUE str;
while (!ZSTREAM_IS_FINISHED(&gz->z)) {
- str = gzfile_read_raw(gz, outbuf);
+ str = gzfile_read_raw(gz);
if (NIL_P(str)) {
if (!ZSTREAM_IS_FINISHED(&gz->z)) {
rb_raise(cGzError, "unexpected end of file");
@@ -2777,11 +2683,13 @@ gzfile_newstr(struct gzfile *gz, VALUE str)
{
if (!gz->enc2) {
rb_enc_associate(str, gz->enc);
+ OBJ_TAINT(str); /* for safe */
return str;
}
if (gz->ec && rb_enc_dummy_p(gz->enc2)) {
str = rb_econv_str_convert(gz->ec, str, ECONV_PARTIAL_INPUT);
rb_enc_associate(str, gz->enc);
+ OBJ_TAINT(str);
return str;
}
return rb_str_conv_enc_opts(str, gz->enc2, gz->enc,
@@ -2796,11 +2704,11 @@ gzfile_fill(struct gzfile *gz, long len)
if (len == 0)
return 0;
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz);
}
if (GZFILE_IS_FINISHED(gz)) {
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz);
}
return -1;
}
@@ -2828,6 +2736,9 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
if (len < 0)
rb_raise(rb_eArgError, "negative length %ld given", len);
+ if (!NIL_P(outbuf))
+ OBJ_TAINT(outbuf);
+
if (len == 0) {
if (NIL_P(outbuf))
return rb_str_new(0, 0);
@@ -2837,11 +2748,11 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
}
}
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) == 0) {
- gzfile_read_more(gz, outbuf);
+ gzfile_read_more(gz);
}
if (GZFILE_IS_FINISHED(gz)) {
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, outbuf);
+ gzfile_check_footer(gz);
}
if (!NIL_P(outbuf))
rb_str_resize(outbuf, 0);
@@ -2854,10 +2765,10 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
if (!NIL_P(outbuf)) {
rb_str_resize(outbuf, RSTRING_LEN(dst));
memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
- rb_str_resize(dst, 0);
- rb_gc_force_recycle(dst);
+ RB_GC_GUARD(dst);
dst = outbuf;
}
+ OBJ_TAINT(dst); /* for safe */
return dst;
}
@@ -2867,11 +2778,11 @@ gzfile_read_all(struct gzfile *gz)
VALUE dst;
while (!ZSTREAM_IS_FINISHED(&gz->z)) {
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz);
}
if (GZFILE_IS_FINISHED(gz)) {
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz);
}
return rb_str_new(0, 0);
}
@@ -2879,6 +2790,7 @@ gzfile_read_all(struct gzfile *gz)
dst = zstream_detach_buffer(&gz->z);
if (NIL_P(dst)) return dst;
gzfile_calc_crc(gz, dst);
+ OBJ_TAINT(dst);
return gzfile_newstr(gz, dst);
}
@@ -2890,11 +2802,11 @@ gzfile_getc(struct gzfile *gz)
len = rb_enc_mbmaxlen(gz->enc);
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz);
}
if (GZFILE_IS_FINISHED(gz)) {
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz);
}
return Qnil;
}
@@ -2902,18 +2814,22 @@ gzfile_getc(struct gzfile *gz)
if (gz->ec && rb_enc_dummy_p(gz->enc2)) {
const unsigned char *ss, *sp, *se;
unsigned char *ds, *dp, *de;
- VALUE cbuf = rb_enc_str_new(0, GZFILE_CBUF_CAPA, gz->enc);
+ if (!gz->cbuf) {
+ gz->cbuf = ALLOC_N(char, GZFILE_CBUF_CAPA);
+ }
ss = sp = (const unsigned char*)RSTRING_PTR(gz->z.buf);
se = sp + ZSTREAM_BUF_FILLED(&gz->z);
- ds = dp = (unsigned char *)RSTRING_PTR(cbuf);
+ ds = dp = (unsigned char *)gz->cbuf;
de = (unsigned char *)ds + GZFILE_CBUF_CAPA;
(void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT);
rb_econv_check_error(gz->ec);
dst = zstream_shift_buffer(&gz->z, sp - ss);
gzfile_calc_crc(gz, dst);
- rb_str_resize(cbuf, dp - ds);
- return cbuf;
+ dst = rb_str_new(gz->cbuf, dp - ds);
+ rb_enc_associate(dst, gz->enc);
+ OBJ_TAINT(dst);
+ return dst;
}
else {
buf = gz->z.buf;
@@ -2960,7 +2876,7 @@ gzfile_writer_end(struct gzfile *gz)
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
- rb_ensure(gzfile_writer_end_run, (VALUE)gz, zstream_ensure_end, (VALUE)&gz->z);
+ rb_ensure(gzfile_writer_end_run, (VALUE)gz, zstream_end, (VALUE)&gz->z);
}
static VALUE
@@ -2970,7 +2886,7 @@ gzfile_reader_end_run(VALUE arg)
if (GZFILE_IS_FINISHED(gz)
&& !(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz);
}
return Qnil;
@@ -2982,7 +2898,7 @@ gzfile_reader_end(struct gzfile *gz)
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
- rb_ensure(gzfile_reader_end_run, (VALUE)gz, zstream_ensure_end, (VALUE)&gz->z);
+ rb_ensure(gzfile_reader_end_run, (VALUE)gz, zstream_end, (VALUE)&gz->z);
}
static void
@@ -3007,11 +2923,12 @@ gzfile_reader_get_unused(struct gzfile *gz)
if (!ZSTREAM_IS_READY(&gz->z)) return Qnil;
if (!GZFILE_IS_FINISHED(gz)) return Qnil;
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz);
}
if (NIL_P(gz->z.input)) return Qnil;
str = rb_str_resurrect(gz->z.input);
+ OBJ_TAINT(str); /* for safe */
return str;
}
@@ -3078,7 +2995,7 @@ static VALUE
new_wrap(VALUE tmp)
{
new_wrap_arg_t *arg = (new_wrap_arg_t *)tmp;
- return rb_class_new_instance_kw(arg->argc, arg->argv, arg->klass, RB_PASS_CALLED_KEYWORDS);
+ return rb_class_new_instance(arg->argc, arg->argv, arg->klass);
}
static VALUE
@@ -3111,7 +3028,7 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
}
}
else {
- obj = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
+ obj = rb_class_new_instance(argc, argv, klass);
}
if (rb_block_given_p()) {
@@ -3228,6 +3145,7 @@ rb_gzfile_orig_name(VALUE obj)
if (!NIL_P(str)) {
str = rb_str_dup(str);
}
+ OBJ_TAINT(str); /* for safe */
return str;
}
@@ -3244,6 +3162,7 @@ rb_gzfile_comment(VALUE obj)
if (!NIL_P(str)) {
str = rb_str_dup(str);
}
+ OBJ_TAINT(str); /* for safe */
return str;
}
@@ -3302,7 +3221,6 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
val = rb_Integer(mtime);
gz->mtime = NUM2UINT(val);
- gz->z.flags |= GZFILE_FLAG_MTIME_IS_SET;
return mtime;
}
@@ -3813,7 +3731,7 @@ rb_gzreader_initialize(int argc, VALUE *argv, VALUE obj)
}
gz->io = io;
ZSTREAM_READY(&gz->z);
- gzfile_read_header(gz, Qnil);
+ gzfile_read_header(gz);
rb_gzfile_ecopts(gz, opt);
if (rb_respond_to(io, id_path)) {
@@ -4063,7 +3981,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
if (GZFILE_IS_FINISHED(gz)) return;
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz);
}
n = 0;
p = RSTRING_PTR(gz->z.buf);
@@ -4074,7 +3992,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
gzfile_calc_crc(gz, str);
while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
if (GZFILE_IS_FINISHED(gz)) return;
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz);
}
n = 0;
p = RSTRING_PTR(gz->z.buf);
@@ -4196,7 +4114,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
if (ZSTREAM_BUF_FILLED(&gz->z) > 0) gz->lineno++;
return gzfile_read(gz, rslen);
}
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz);
}
p = RSTRING_PTR(gz->z.buf);
@@ -4205,7 +4123,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
long filled;
if (n > ZSTREAM_BUF_FILLED(&gz->z)) {
if (ZSTREAM_IS_FINISHED(&gz->z)) break;
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz);
p = RSTRING_PTR(gz->z.buf) + n - rslen;
}
if (!rspara) rscheck(rsptr, rslen, rs);
@@ -4333,19 +4251,13 @@ rb_gzreader_external_encoding(VALUE self)
}
static VALUE
-zlib_gzip_end_rescue(VALUE arg)
+zlib_gzip_ensure(VALUE arg)
{
struct gzfile *gz = (struct gzfile *)arg;
- gz->end(gz);
+ rb_rescue((VALUE(*)())gz->end, arg, NULL, Qnil);
return Qnil;
}
-static VALUE
-zlib_gzip_ensure(VALUE arg)
-{
- return rb_rescue(zlib_gzip_end_rescue, arg, NULL, Qnil);
-}
-
static void
zlib_gzip_end(struct gzfile *gz)
{
@@ -4491,7 +4403,7 @@ zlib_gunzip_run(VALUE arg)
struct gzfile *gz = (struct gzfile *)arg;
VALUE dst;
- gzfile_read_header(gz, Qnil);
+ gzfile_read_header(gz);
dst = zstream_detach_buffer(&gz->z);
gzfile_calc_crc(gz, dst);
if (!ZSTREAM_IS_FINISHED(&gz->z)) {
@@ -4500,7 +4412,7 @@ zlib_gunzip_run(VALUE arg)
if (NIL_P(gz->z.input)) {
rb_raise(cNoFooter, "footer is not found");
}
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz);
return dst;
}
@@ -4509,7 +4421,6 @@ zlib_gunzip_run(VALUE arg)
void
Init_zlib(void)
{
-#undef rb_intern
VALUE mZlib, cZStream, cDeflate, cInflate;
#if GZIP_SUPPORT
VALUE cGzipFile, cGzipWriter, cGzipReader;
@@ -4527,7 +4438,6 @@ Init_zlib(void)
cMemError = rb_define_class_under(mZlib, "MemError", cZError);
cBufError = rb_define_class_under(mZlib, "BufError", cZError);
cVersionError = rb_define_class_under(mZlib, "VersionError", cZError);
- cInProgressError = rb_define_class_under(mZlib, "InProgressError", cZError);
rb_define_module_function(mZlib, "zlib_version", rb_zlib_version, 0);
rb_define_module_function(mZlib, "adler32", rb_zlib_adler32, -1);
@@ -4835,7 +4745,6 @@ Init_zlib(void)
* - Zlib::MemError
* - Zlib::BufError
* - Zlib::VersionError
- * - Zlib::InProgressError
*
*/
@@ -4911,20 +4820,6 @@ Init_zlib(void)
*/
/*
- * Document-class: Zlib::InProgressError
- *
- * Subclass of Zlib::Error. This error is raised when the zlib
- * stream is currently in progress.
- *
- * For example:
- *
- * inflater = Zlib::Inflate.new
- * inflater.inflate(compressed) do
- * inflater.inflate(compressed) # Raises Zlib::InProgressError
- * end
- */
-
-/*
* Document-class: Zlib::GzipFile::Error
*
* Base class of errors that occur when processing GZIP files.
@@ -4949,3 +4844,5 @@ Init_zlib(void)
* Raised when the data length recorded in the gzip file footer is not equivalent
* to the length of the actual uncompressed data.
*/
+
+
diff --git a/ext/zlib/zlib.gemspec b/ext/zlib/zlib.gemspec
index 4a77ae325e..bdb32f0ea5 100644
--- a/ext/zlib/zlib.gemspec
+++ b/ext/zlib/zlib.gemspec
@@ -1,19 +1,9 @@
# coding: utf-8
# frozen_string_literal: true
-
-source_version = ["", "ext/zlib/"].find do |dir|
- begin
- break File.open(File.join(__dir__, "#{dir}zlib.c")) {|f|
- f.gets("\n#define RUBY_ZLIB_VERSION ")
- f.gets[/\s*"(.+)"/, 1]
- }
- rescue Errno::ENOENT
- end
-end
-
Gem::Specification.new do |spec|
spec.name = "zlib"
- spec.version = source_version
+ spec.version = "1.0.0"
+ spec.date = '2017-12-11'
spec.authors = ["Yukihiro Matsumoto", "UENO Katsuhiro"]
spec.email = ["matz@ruby-lang.org", nil]
diff --git a/file.c b/file.c
index a7cf696c10..3bf092c05c 100644
--- a/file.c
+++ b/file.c
@@ -20,23 +20,14 @@
#include <wchar.h>
#endif
#ifdef __APPLE__
-# if !(defined(__has_feature) && defined(__has_attribute))
-/* Maybe a bug in SDK of Xcode 10.2.1 */
-/* In this condition, <os/availability.h> does not define
- * API_AVAILABLE and similar, but __API_AVAILABLE and similar which
- * are defined in <Availability.h> */
-# define API_AVAILABLE(...)
-# define API_DEPRECATED(...)
-# endif
#include <CoreFoundation/CFString.h>
#endif
#include "id.h"
-#include "ruby/encoding.h"
+#include "internal.h"
#include "ruby/io.h"
#include "ruby/util.h"
#include "ruby/thread.h"
-#include "internal.h"
#include "dln.h"
#include "encindex.h"
@@ -123,12 +114,6 @@ int flock(int, int);
#define rename(f, t) rb_w32_urename((f), (t))
#undef symlink
#define symlink(s, l) rb_w32_usymlink((s), (l))
-
-#ifdef HAVE_REALPATH
-/* Don't use native realpath(3) on Windows, as the check for
- absolute paths does not work for drive letters. */
-#undef HAVE_REALPATH
-#endif
#else
#define STAT(p, s) stat((p), (s))
#endif
@@ -146,20 +131,12 @@ int flock(int, int);
# define UTIME_EINVAL
#endif
-/* Solaris 10 realpath(3) doesn't support File.realpath */
-#if defined HAVE_REALPATH && defined __sun && defined __SVR4
-#undef HAVE_REALPATH
-#endif
-
-#ifdef HAVE_REALPATH
-#include <limits.h>
-#include <stdlib.h>
-#endif
-
VALUE rb_cFile;
VALUE rb_mFileTest;
VALUE rb_cStat;
+#define insecure_obj_p(obj, level) ((level) > 0 && OBJ_TAINTED(obj))
+
static VALUE
file_path_convert(VALUE name)
{
@@ -193,11 +170,15 @@ check_path_encoding(VALUE str)
}
VALUE
-rb_get_path_check_to_string(VALUE obj)
+rb_get_path_check_to_string(VALUE obj, int level)
{
VALUE tmp;
ID to_path;
+ if (insecure_obj_p(obj, level)) {
+ rb_insecure_operation();
+ }
+
if (RB_TYPE_P(obj, T_STRING)) {
return obj;
}
@@ -208,28 +189,38 @@ rb_get_path_check_to_string(VALUE obj)
}
VALUE
-rb_get_path_check_convert(VALUE obj)
+rb_get_path_check_convert(VALUE obj, VALUE tmp, int level)
{
- obj = file_path_convert(obj);
+ tmp = file_path_convert(tmp);
+ if (obj != tmp && insecure_obj_p(tmp, level)) {
+ rb_insecure_operation();
+ }
- check_path_encoding(obj);
- if (!rb_str_to_cstr(obj)) {
+ check_path_encoding(tmp);
+ if (!rb_str_to_cstr(tmp)) {
rb_raise(rb_eArgError, "path name contains null byte");
}
- return rb_str_new4(obj);
+ return rb_str_new4(tmp);
+}
+
+VALUE
+rb_get_path_check(VALUE obj, int level)
+{
+ VALUE tmp = rb_get_path_check_to_string(obj, level);
+ return rb_get_path_check_convert(obj, tmp, level);
}
VALUE
rb_get_path_no_checksafe(VALUE obj)
{
- return rb_get_path(obj);
+ return rb_get_path_check(obj, 0);
}
VALUE
rb_get_path(VALUE obj)
{
- return rb_get_path_check_convert(rb_get_path_check_to_string(obj));
+ return rb_get_path_check(obj, rb_safe_level());
}
VALUE
@@ -237,12 +228,12 @@ rb_str_encode_ospath(VALUE path)
{
#if USE_OSPATH
int encidx = ENCODING_GET(path);
-#if 0 && defined _WIN32
+#ifdef _WIN32
if (encidx == ENCINDEX_ASCII) {
encidx = rb_filesystem_encindex();
}
#endif
- if (encidx != ENCINDEX_ASCII && encidx != ENCINDEX_UTF_8) {
+ if (encidx != ENCINDEX_UTF_8) {
rb_encoding *enc = rb_enc_from_index(encidx);
rb_encoding *utf8 = rb_utf8_encoding();
path = rb_str_conv_enc(path, enc, utf8);
@@ -369,7 +360,7 @@ struct apply_arg {
int errnum;
int (*func)(const char *, void *);
void *arg;
- struct apply_filename fn[FLEX_ARY_LEN];
+ struct apply_filename fn[1]; /* flexible array */
};
static void *
@@ -439,8 +430,8 @@ apply2files(int (*func)(const char *, void *), int argc, VALUE *argv, void *arg)
* For instance, the pathname becomes void when the file has been
* moved or deleted.
*
- * This method raises IOError for a <i>file</i> created using
- * File::Constants::TMPFILE because they don't have a pathname.
+ * This method raises <code>IOError</code> for a <i>file</i> created using
+ * <code>File::Constants::TMPFILE</code> because they don't have a pathname.
*
* File.new("testfile").path #=> "testfile"
* File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
@@ -459,7 +450,7 @@ rb_file_path(VALUE obj)
rb_raise(rb_eIOError, "File is unnamed (TMPFILE?)");
}
- return rb_str_dup(fptr->pathv);
+ return rb_obj_taint(rb_str_dup(fptr->pathv));
}
static size_t
@@ -503,7 +494,7 @@ get_stat(VALUE self)
return st;
}
-static struct timespec stat_mtimespec(const struct stat *st);
+static struct timespec stat_mtimespec(struct stat *st);
/*
* call-seq:
@@ -580,7 +571,7 @@ static VALUE
rb_stat_dev_major(VALUE self)
{
#if defined(major)
- return UINT2NUM(major(get_stat(self)->st_dev));
+ return DEVT2NUM(major(get_stat(self)->st_dev));
#else
return Qnil;
#endif
@@ -601,7 +592,7 @@ static VALUE
rb_stat_dev_minor(VALUE self)
{
#if defined(minor)
- return UINT2NUM(minor(get_stat(self)->st_dev));
+ return DEVT2NUM(minor(get_stat(self)->st_dev));
#else
return Qnil;
#endif
@@ -739,7 +730,7 @@ static VALUE
rb_stat_rdev_major(VALUE self)
{
#if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(major)
- return UINT2NUM(major(get_stat(self)->st_rdev));
+ return DEVT2NUM(major(get_stat(self)->st_rdev));
#else
return Qnil;
#endif
@@ -760,7 +751,7 @@ static VALUE
rb_stat_rdev_minor(VALUE self)
{
#if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(minor)
- return UINT2NUM(minor(get_stat(self)->st_rdev));
+ return DEVT2NUM(minor(get_stat(self)->st_rdev));
#else
return Qnil;
#endif
@@ -828,7 +819,7 @@ rb_stat_blocks(VALUE self)
}
static struct timespec
-stat_atimespec(const struct stat *st)
+stat_atimespec(struct stat *st)
{
struct timespec ts;
ts.tv_sec = st->st_atime;
@@ -845,14 +836,14 @@ stat_atimespec(const struct stat *st)
}
static VALUE
-stat_atime(const struct stat *st)
+stat_atime(struct stat *st)
{
struct timespec ts = stat_atimespec(st);
return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
}
static struct timespec
-stat_mtimespec(const struct stat *st)
+stat_mtimespec(struct stat *st)
{
struct timespec ts;
ts.tv_sec = st->st_mtime;
@@ -869,14 +860,14 @@ stat_mtimespec(const struct stat *st)
}
static VALUE
-stat_mtime(const struct stat *st)
+stat_mtime(struct stat *st)
{
struct timespec ts = stat_mtimespec(st);
return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
}
static struct timespec
-stat_ctimespec(const struct stat *st)
+stat_ctimespec(struct stat *st)
{
struct timespec ts;
ts.tv_sec = st->st_ctime;
@@ -893,7 +884,7 @@ stat_ctimespec(const struct stat *st)
}
static VALUE
-stat_ctime(const struct stat *st)
+stat_ctime(struct stat *st)
{
struct timespec ts = stat_ctimespec(st);
return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
@@ -901,15 +892,13 @@ stat_ctime(const struct stat *st)
#define HAVE_STAT_BIRTHTIME
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC)
-typedef struct stat statx_data;
static VALUE
-stat_birthtime(const struct stat *st)
+stat_birthtime(struct stat *st)
{
- const struct timespec *ts = &st->st_birthtimespec;
+ struct timespec *ts = &st->st_birthtimespec;
return rb_time_nano_new(ts->tv_sec, ts->tv_nsec);
}
#elif defined(_WIN32)
-typedef struct stat statx_data;
# define stat_birthtime stat_ctime
#else
# undef HAVE_STAT_BIRTHTIME
@@ -920,7 +909,7 @@ typedef struct stat statx_data;
* stat.atime -> time
*
* Returns the last access time for this file as an object of class
- * Time.
+ * <code>Time</code>.
*
* File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
*
@@ -1072,6 +1061,7 @@ rb_stat_inspect(VALUE self)
}
}
rb_str_buf_cat2(str, ">");
+ OBJ_INFECT(str, self);
return str;
}
@@ -1121,125 +1111,6 @@ stat_without_gvl(const char *path, struct stat *st)
RUBY_UBF_IO, NULL);
}
-#if !defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC) && \
- defined(HAVE_STRUCT_STATX_STX_BTIME)
-
-# ifndef HAVE_STATX
-# ifdef HAVE_SYSCALL_H
-# include <syscall.h>
-# elif defined HAVE_SYS_SYSCALL_H
-# include <sys/syscall.h>
-# endif
-# if defined __linux__
-# include <linux/stat.h>
-static inline int
-statx(int dirfd, const char *pathname, int flags,
- unsigned int mask, struct statx *statxbuf)
-{
- return (int)syscall(__NR_statx, dirfd, pathname, flags, mask, statxbuf);
-}
-# endif
-# endif
-
-typedef struct no_gvl_statx_data {
- struct statx *stx;
- int fd;
- const char *path;
- int flags;
- unsigned int mask;
-} no_gvl_statx_data;
-
-static VALUE
-io_blocking_statx(void *data)
-{
- no_gvl_statx_data *arg = data;
- return (VALUE)statx(arg->fd, arg->path, arg->flags, arg->mask, arg->stx);
-}
-
-static void *
-no_gvl_statx(void *data)
-{
- return (void *)io_blocking_statx(data);
-}
-
-static int
-statx_without_gvl(const char *path, struct statx *stx, unsigned int mask)
-{
- no_gvl_statx_data data = {stx, AT_FDCWD, path, 0, mask};
-
- /* call statx(2) with pathname */
- return (int)(VALUE)rb_thread_call_without_gvl(no_gvl_statx, &data,
- RUBY_UBF_IO, NULL);
-}
-
-static int
-fstatx_without_gvl(int fd, struct statx *stx, unsigned int mask)
-{
- no_gvl_statx_data data = {stx, fd, "", AT_EMPTY_PATH, mask};
-
- /* call statx(2) with fd */
- return (int)rb_thread_io_blocking_region(io_blocking_statx, &data, fd);
-}
-
-static int
-rb_statx(VALUE file, struct statx *stx, unsigned int mask)
-{
- VALUE tmp;
- int result;
-
- tmp = rb_check_convert_type_with_id(file, T_FILE, "IO", idTo_io);
- if (!NIL_P(tmp)) {
- rb_io_t *fptr;
- GetOpenFile(tmp, fptr);
- result = fstatx_without_gvl(fptr->fd, stx, mask);
- file = tmp;
- }
- else {
- FilePathValue(file);
- file = rb_str_encode_ospath(file);
- result = statx_without_gvl(RSTRING_PTR(file), stx, mask);
- }
- RB_GC_GUARD(file);
- return result;
-}
-
-# define statx_has_birthtime(st) ((st)->stx_mask & STATX_BTIME)
-
-NORETURN(static void statx_notimplement(const char *field_name));
-
-/* rb_notimplement() shows "function is unimplemented on this machine".
- It is not applicable to statx which behavior depends on the filesystem. */
-static void
-statx_notimplement(const char *field_name)
-{
- rb_raise(rb_eNotImpError,
- "%s is unimplemented on this filesystem",
- field_name);
-}
-
-static VALUE
-statx_birthtime(const struct statx *stx, VALUE fname)
-{
- if (!statx_has_birthtime(stx)) {
- /* birthtime is not supported on the filesystem */
- statx_notimplement("birthtime");
- }
- return rb_time_nano_new((time_t)stx->stx_btime.tv_sec, stx->stx_btime.tv_nsec);
-}
-
-typedef struct statx statx_data;
-# define HAVE_STAT_BIRTHTIME
-
-#elif defined(HAVE_STAT_BIRTHTIME)
-# define statx_without_gvl(path, st, mask) stat_without_gvl(path, st)
-# define fstatx_without_gvl(fd, st, mask) fstat_without_gvl(fd, st)
-# define statx_birthtime(st, fname) stat_birthtime(st)
-# define statx_has_birthtime(st) 1
-# define rb_statx(file, st, mask) rb_stat(file, st)
-#else
-# define statx_has_birthtime(st) 0
-#endif
-
static int
rb_stat(VALUE file, struct stat *st)
{
@@ -1267,7 +1138,8 @@ rb_stat(VALUE file, struct stat *st)
* call-seq:
* File.stat(file_name) -> stat
*
- * Returns a File::Stat object for the named file (see File::Stat).
+ * Returns a <code>File::Stat</code> object for the named file (see
+ * <code>File::Stat</code>).
*
* File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003
*
@@ -1291,7 +1163,7 @@ rb_file_s_stat(VALUE klass, VALUE fname)
* ios.stat -> stat
*
* Returns status information for <em>ios</em> as an object of type
- * File::Stat.
+ * <code>File::Stat</code>.
*
* f = File.new("testfile")
* s = f.stat
@@ -1339,8 +1211,8 @@ lstat_without_gvl(const char *path, struct stat *st)
* call-seq:
* File.lstat(file_name) -> stat
*
- * Same as File::stat, but does not follow the last symbolic link.
- * Instead, reports on the link itself.
+ * Same as <code>File::stat</code>, but does not follow the last symbolic
+ * link. Instead, reports on the link itself.
*
* File.symlink("testfile", "link2test") #=> 0
* File.stat("testfile").size #=> 66
@@ -1370,8 +1242,8 @@ rb_file_s_lstat(VALUE klass, VALUE fname)
* call-seq:
* file.lstat -> stat
*
- * Same as IO#stat, but does not follow the last symbolic link.
- * Instead, reports on the link itself.
+ * Same as <code>IO#stat</code>, but does not follow the last symbolic
+ * link. Instead, reports on the link itself.
*
* File.symlink("testfile", "link2test") #=> 0
* File.stat("testfile").size #=> 66
@@ -1551,10 +1423,10 @@ rb_access(VALUE fname, int mode)
/*
* Document-class: FileTest
*
- * FileTest implements file test operations similar to those used in
- * File::Stat. It exists as a standalone module, and its methods are
- * also insinuated into the File class. (Note that this is not done
- * by inclusion: the interpreter cheats).
+ * <code>FileTest</code> implements file test operations similar to
+ * those used in <code>File::Stat</code>. It exists as a standalone
+ * module, and its methods are also insinuated into the <code>File</code>
+ * class. (Note that this is not done by inclusion: the interpreter cheats).
*
*/
@@ -1786,9 +1658,6 @@ rb_file_exists_p(VALUE obj, VALUE fname)
*
* Returns <code>true</code> if the named file is readable by the effective
* user and group id of this process. See eaccess(3).
- *
- * Note that some OS-level security features may cause this to return true
- * even though the file is not readable by the effective user/group.
*/
static VALUE
@@ -1804,9 +1673,6 @@ rb_file_readable_p(VALUE obj, VALUE fname)
*
* Returns <code>true</code> if the named file is readable by the real
* user and group id of this process. See access(3).
- *
- * Note that some OS-level security features may cause this to return true
- * even though the file is not readable by the real user/group.
*/
static VALUE
@@ -1860,9 +1726,6 @@ rb_file_world_readable_p(VALUE obj, VALUE fname)
*
* Returns <code>true</code> if the named file is writable by the effective
* user and group id of this process. See eaccess(3).
- *
- * Note that some OS-level security features may cause this to return true
- * even though the file is not writable by the effective user/group.
*/
static VALUE
@@ -1877,10 +1740,7 @@ rb_file_writable_p(VALUE obj, VALUE fname)
* File.writable_real?(file_name) -> true or false
*
* Returns <code>true</code> if the named file is writable by the real
- * user and group id of this process. See access(3).
- *
- * Note that some OS-level security features may cause this to return true
- * even though the file is not writable by the real user/group.
+ * user and group id of this process. See access(3)
*/
static VALUE
@@ -1926,13 +1786,6 @@ rb_file_world_writable_p(VALUE obj, VALUE fname)
*
* Returns <code>true</code> if the named file is executable by the effective
* user and group id of this process. See eaccess(3).
- *
- * Windows does not support execute permissions separately from read
- * permissions. On Windows, a file is only considered executable if it ends in
- * .bat, .cmd, .com, or .exe.
- *
- * Note that some OS-level security features may cause this to return true
- * even though the file is not executable by the effective user/group.
*/
static VALUE
@@ -1948,13 +1801,6 @@ rb_file_executable_p(VALUE obj, VALUE fname)
*
* Returns <code>true</code> if the named file is executable by the real
* user and group id of this process. See access(3).
- *
- * Windows does not support execute permissions separately from read
- * permissions. On Windows, a file is only considered executable if it ends in
- * .bat, .cmd, .com, or .exe.
- *
- * Note that some OS-level security features may cause this to return true
- * even though the file is not executable by the real user/group.
*/
static VALUE
@@ -2101,8 +1947,6 @@ check3rdbyte(VALUE fname, int mode)
* File.setuid?(file_name) -> true or false
*
* Returns <code>true</code> if the named file has the setuid bit set.
- *
- * _file_name_ can be an IO object.
*/
static VALUE
@@ -2120,8 +1964,6 @@ rb_file_suid_p(VALUE obj, VALUE fname)
* File.setgid?(file_name) -> true or false
*
* Returns <code>true</code> if the named file has the setgid bit set.
- *
- * _file_name_ can be an IO object.
*/
static VALUE
@@ -2139,8 +1981,6 @@ rb_file_sgid_p(VALUE obj, VALUE fname)
* File.sticky?(file_name) -> true or false
*
* Returns <code>true</code> if the named file has the sticky bit set.
- *
- * _file_name_ can be an IO object.
*/
static VALUE
@@ -2310,8 +2150,8 @@ rb_file_s_atime(VALUE klass, VALUE fname)
* call-seq:
* file.atime -> time
*
- * Returns the last access time (a Time object) for <i>file</i>, or
- * epoch if <i>file</i> has not been accessed.
+ * Returns the last access time (a <code>Time</code> object)
+ * for <i>file</i>, or epoch if <i>file</i> has not been accessed.
*
* File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
*
@@ -2433,6 +2273,7 @@ rb_file_ctime(VALUE obj)
return stat_ctime(&st);
}
+#if defined(HAVE_STAT_BIRTHTIME)
/*
* call-seq:
* File.birthtime(file_name) -> time
@@ -2447,18 +2288,17 @@ rb_file_ctime(VALUE obj)
*
*/
-#if defined(HAVE_STAT_BIRTHTIME)
-RUBY_FUNC_EXPORTED VALUE
+static VALUE
rb_file_s_birthtime(VALUE klass, VALUE fname)
{
- statx_data st;
+ struct stat st;
- if (rb_statx(fname, &st, STATX_BTIME) < 0) {
+ if (rb_stat(fname, &st) < 0) {
int e = errno;
FilePathValue(fname);
rb_syserr_fail_path(e, fname);
}
- return statx_birthtime(&st, fname);
+ return stat_birthtime(&st);
}
#else
# define rb_file_s_birthtime rb_f_notimplement
@@ -2481,13 +2321,13 @@ static VALUE
rb_file_birthtime(VALUE obj)
{
rb_io_t *fptr;
- statx_data st;
+ struct stat st;
GetOpenFile(obj, fptr);
- if (fstatx_without_gvl(fptr->fd, &st, STATX_BTIME) == -1) {
+ if (fstat(fptr->fd, &st) == -1) {
rb_sys_fail_path(fptr->pathv);
}
- return statx_birthtime(&st, fptr->pathv);
+ return stat_birthtime(&st);
}
#else
# define rb_file_birthtime rb_f_notimplement
@@ -2539,7 +2379,7 @@ chmod_internal(const char *path, void *mode)
*/
static VALUE
-rb_file_s_chmod(int argc, VALUE *argv, VALUE _)
+rb_file_s_chmod(int argc, VALUE *argv)
{
mode_t mode;
@@ -2556,7 +2396,7 @@ rb_file_s_chmod(int argc, VALUE *argv, VALUE _)
* Changes permission bits on <i>file</i> to the bit pattern
* represented by <i>mode_int</i>. Actual effects are platform
* dependent; on Unix systems, see <code>chmod(2)</code> for details.
- * Follows symbolic links. Also see File#lchmod.
+ * Follows symbolic links. Also see <code>File#lchmod</code>.
*
* f = File.new("out", "w");
* f.chmod(0644) #=> 0
@@ -2566,12 +2406,12 @@ static VALUE
rb_file_chmod(VALUE obj, VALUE vmode)
{
rb_io_t *fptr;
- mode_t mode;
+ int mode;
#if !defined HAVE_FCHMOD || !HAVE_FCHMOD
VALUE path;
#endif
- mode = NUM2MODET(vmode);
+ mode = NUM2INT(vmode);
GetOpenFile(obj, fptr);
#ifdef HAVE_FCHMOD
@@ -2604,14 +2444,14 @@ lchmod_internal(const char *path, void *mode)
* call-seq:
* File.lchmod(mode_int, file_name, ...) -> integer
*
- * Equivalent to File::chmod, but does not follow symbolic links (so
- * it will change the permissions associated with the link, not the
- * file referenced by the link). Often not available.
+ * Equivalent to <code>File::chmod</code>, but does not follow symbolic
+ * links (so it will change the permissions associated with the link,
+ * not the file referenced by the link). Often not available.
*
*/
static VALUE
-rb_file_s_lchmod(int argc, VALUE *argv, VALUE _)
+rb_file_s_lchmod(int argc, VALUE *argv)
{
mode_t mode;
@@ -2656,7 +2496,7 @@ chown_internal(const char *path, void *arg)
/*
* call-seq:
- * File.chown(owner_int, group_int, file_name, ...) -> integer
+ * File.chown(owner_int, group_int, file_name,... ) -> integer
*
* Changes the owner and group of the named file(s) to the given
* numeric owner and group id's. Only a process with superuser
@@ -2670,7 +2510,7 @@ chown_internal(const char *path, void *arg)
*/
static VALUE
-rb_file_s_chown(int argc, VALUE *argv, VALUE _)
+rb_file_s_chown(int argc, VALUE *argv)
{
struct chown_args arg;
@@ -2690,7 +2530,7 @@ rb_file_s_chown(int argc, VALUE *argv, VALUE _)
* change the owner of a file. The current owner of a file may change
* the file's group to any group to which the owner belongs. A
* <code>nil</code> or -1 owner or group id is ignored. Follows
- * symbolic links. See also File#lchown.
+ * symbolic links. See also <code>File#lchown</code>.
*
* File.new("testfile").chown(502, 1000)
*
@@ -2734,7 +2574,7 @@ lchown_internal(const char *path, void *arg)
* call-seq:
* File.lchown(owner_int, group_int, file_name,..) -> integer
*
- * Equivalent to File::chown, but does not follow symbolic
+ * Equivalent to <code>File::chown</code>, but does not follow symbolic
* links (so it will change the owner associated with the link, not the
* file referenced by the link). Often not available. Returns number
* of files in the argument list.
@@ -2742,7 +2582,7 @@ lchown_internal(const char *path, void *arg)
*/
static VALUE
-rb_file_s_lchown(int argc, VALUE *argv, VALUE _)
+rb_file_s_lchown(int argc, VALUE *argv)
{
struct chown_args arg;
@@ -2910,7 +2750,7 @@ utime_internal_i(int argc, VALUE *argv, int follow)
/*
* call-seq:
- * File.utime(atime, mtime, file_name, ...) -> integer
+ * File.utime(atime, mtime, file_name,...) -> integer
*
* Sets the access and modification times of each named file to the
* first two arguments. If a file is a symlink, this method acts upon
@@ -2920,7 +2760,7 @@ utime_internal_i(int argc, VALUE *argv, int follow)
*/
static VALUE
-rb_file_s_utime(int argc, VALUE *argv, VALUE _)
+rb_file_s_utime(int argc, VALUE *argv)
{
return utime_internal_i(argc, argv, FALSE);
}
@@ -2929,7 +2769,7 @@ rb_file_s_utime(int argc, VALUE *argv, VALUE _)
/*
* call-seq:
- * File.lutime(atime, mtime, file_name, ...) -> integer
+ * File.lutime(atime, mtime, file_name,...) -> integer
*
* Sets the access and modification times of each named file to the
* first two arguments. If a file is a symlink, this method acts upon
@@ -2939,7 +2779,7 @@ rb_file_s_utime(int argc, VALUE *argv, VALUE _)
*/
static VALUE
-rb_file_s_lutime(int argc, VALUE *argv, VALUE _)
+rb_file_s_lutime(int argc, VALUE *argv)
{
return utime_internal_i(argc, argv, TRUE);
}
@@ -2986,7 +2826,7 @@ syserr_fail2_in(const char *func, int e, VALUE s1, VALUE s2)
*
* Creates a new name for an existing file using a hard link. Will not
* overwrite <i>new_name</i> if it already exists (raising a subclass
- * of SystemCallError). Not available on all platforms.
+ * of <code>SystemCallError</code>). Not available on all platforms.
*
* File.link("testfile", ".testfile") #=> 0
* IO.readlines(".testfile")[0] #=> "This is line one\n"
@@ -3015,7 +2855,7 @@ rb_file_s_link(VALUE klass, VALUE from, VALUE to)
* File.symlink(old_name, new_name) -> 0
*
* Creates a symbolic link called <i>new_name</i> for the existing file
- * <i>old_name</i>. Raises a NotImplemented exception on
+ * <i>old_name</i>. Raises a <code>NotImplemented</code> exception on
* platforms that do not support symbolic links.
*
* File.symlink("testfile", "link2test") #=> 0
@@ -3135,9 +2975,9 @@ unlink_internal(const char *path, void *arg)
* <code>unlink(2)</code> system call, the type of
* exception raised depends on its error type (see
* https://linux.die.net/man/2/unlink) and has the form of
- * e.g. Errno::ENOENT.
+ * e.g. <code>Errno::ENOENT</code>.
*
- * See also Dir::rmdir.
+ * See also <code>Dir::rmdir</code>.
*/
static VALUE
@@ -3163,8 +3003,8 @@ no_gvl_rename(void *ptr)
* call-seq:
* File.rename(old_name, new_name) -> 0
*
- * Renames the given file to the new name. Raises a SystemCallError
- * if the file cannot be renamed.
+ * Renames the given file to the new name. Raises a
+ * <code>SystemCallError</code> if the file cannot be renamed.
*
* File.rename("afile", "afile.bak") #=> 0
*/
@@ -3218,20 +3058,19 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
*/
static VALUE
-rb_file_s_umask(int argc, VALUE *argv, VALUE _)
+rb_file_s_umask(int argc, VALUE *argv)
{
mode_t omask = 0;
- switch (argc) {
- case 0:
+ if (argc == 0) {
omask = umask(0);
umask(omask);
- break;
- case 1:
+ }
+ else if (argc == 1) {
omask = umask(NUM2MODET(argv[0]));
- break;
- default:
- rb_error_arity(argc, 0, 1);
+ }
+ else {
+ rb_check_arity(argc, 0, 1);
}
return MODET2NUM(omask);
}
@@ -3579,42 +3418,21 @@ rb_default_home_dir(VALUE result)
#if defined HAVE_PWD_H
if (!dir) {
- /* We'll look up the user's default home dir in the password db by
- * login name, if possible, and failing that will fall back to looking
- * the information up by uid (as would be needed for processes that
- * are not a descendant of login(1) or a work-alike).
- *
- * While the lookup by uid is more likely to succeed (since we always
- * have a uid, but may or may not have a login name), we prefer first
- * looking up by name to accommodate the possibility of multiple login
- * names (each with its own record in the password database, so each
- * with a potentially different home directory) being mapped to the
- * same uid (as explicitly allowed for by POSIX; see getlogin(3posix)).
- */
- VALUE login_name = rb_getlogin();
-
-# if !defined(HAVE_GETPWUID_R) && !defined(HAVE_GETPWUID)
- /* This is a corner case, but for backward compatibility reasons we
- * want to emit this error if neither the lookup by login name nor
- * lookup by getuid() has a chance of succeeding.
- */
- if (NIL_P(login_name)) {
- rb_raise(rb_eArgError, "couldn't find login name -- expanding `~'");
- }
-# endif
-
- VALUE pw_dir = rb_getpwdirnam_for_login(login_name);
- if (NIL_P(pw_dir)) {
- pw_dir = rb_getpwdiruid();
- if (NIL_P(pw_dir)) {
- rb_raise(rb_eArgError, "couldn't find home for uid `%ld'", (long)getuid());
- }
- }
-
- /* found it */
- copy_home_path(result, RSTRING_PTR(pw_dir));
- rb_str_resize(pw_dir, 0);
- return result;
+ const char *login = getlogin();
+ if (login) {
+ struct passwd *pw = getpwnam(login);
+ if (pw) {
+ copy_home_path(result, pw->pw_dir);
+ endpwent();
+ return result;
+ }
+ endpwent();
+ rb_raise(rb_eArgError, "couldn't find HOME for login `%s' -- expanding `~'",
+ login);
+ }
+ else {
+ rb_raise(rb_eArgError, "couldn't find login name -- expanding `~'");
+ }
}
#endif
if (!dir) {
@@ -3669,15 +3487,18 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
const char *s, *b, *fend;
char *buf, *p, *pend, *root;
size_t buflen, bdiff;
+ int tainted;
rb_encoding *enc, *fsenc = rb_filesystem_encoding();
s = StringValuePtr(fname);
fend = s + RSTRING_LEN(fname);
enc = rb_enc_get(fname);
BUFINIT();
+ tainted = OBJ_TAINTED(fname);
if (s[0] == '~' && abs_mode == 0) { /* execute only if NOT absolute_path() */
long userlen = 0;
+ tainted = 1;
if (isdirsep(s[1]) || s[1] == '\0') {
buf = 0;
b = 0;
@@ -3735,6 +3556,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
}
if (!same) {
char *e = append_fspath(result, fname, getcwdofdrv(*s), &enc, fsenc);
+ tainted = 1;
BUFINIT();
p = e;
}
@@ -3756,6 +3578,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
}
else {
char *e = append_fspath(result, fname, ruby_getcwd(), &enc, fsenc);
+ tainted = 1;
BUFINIT();
p = e;
}
@@ -4006,6 +3829,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
}
#endif
+ if (tainted) OBJ_TAINT(result);
rb_str_set_len(result, p - buf);
rb_enc_check(fname, result);
ENC_CODERANGE_CLEAR(result);
@@ -4048,13 +3872,6 @@ rb_file_expand_path_fast(VALUE fname, VALUE dname)
return expand_path(fname, dname, 0, 0, EXPAND_PATH_BUFFER());
}
-VALUE
-rb_file_s_expand_path(int argc, const VALUE *argv)
-{
- rb_check_arity(argc, 1, 2);
- return rb_file_expand_path(argv[0], argc > 1 ? argv[1] : Qnil);
-}
-
/*
* call-seq:
* File.expand_path(file_name [, dir_string] ) -> abs_file_name
@@ -4083,10 +3900,11 @@ rb_file_s_expand_path(int argc, const VALUE *argv)
* parent, the root of the project and appends +lib/mygem.rb+.
*/
-static VALUE
-s_expand_path(int c, const VALUE * v, VALUE _)
+VALUE
+rb_file_s_expand_path(int argc, const VALUE *argv)
{
- return rb_file_s_expand_path(c, v);
+ rb_check_arity(argc, 1, 2);
+ return rb_file_expand_path(argv[0], argc > 1 ? argv[1] : Qnil);
}
VALUE
@@ -4096,13 +3914,6 @@ rb_file_absolute_path(VALUE fname, VALUE dname)
return expand_path(fname, dname, 1, 1, EXPAND_PATH_BUFFER());
}
-VALUE
-rb_file_s_absolute_path(int argc, const VALUE *argv)
-{
- rb_check_arity(argc, 1, 2);
- return rb_file_absolute_path(argv[0], argc > 1 ? argv[1] : Qnil);
-}
-
/*
* call-seq:
* File.absolute_path(file_name [, dir_string] ) -> abs_file_name
@@ -4116,29 +3927,11 @@ rb_file_s_absolute_path(int argc, const VALUE *argv)
* File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
*/
-static VALUE
-s_absolute_path(int c, const VALUE * v, VALUE _)
-{
- return rb_file_s_absolute_path(c, v);
-}
-
-/*
- * call-seq:
- * File.absolute_path?(file_name) -> true or false
- *
- * Returns <code>true</code> if +file_name+ is an absolute path, and
- * <code>false</code> otherwise.
- *
- * File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
- */
-
-static VALUE
-s_absolute_path_p(VALUE klass, VALUE fname)
+VALUE
+rb_file_s_absolute_path(int argc, const VALUE *argv)
{
- VALUE path = rb_get_path(fname);
-
- if (!rb_is_absolute_path(RSTRING_PTR(path))) return Qfalse;
- return Qtrue;
+ rb_check_arity(argc, 1, 2);
+ return rb_file_absolute_path(argv[0], argc > 1 ? argv[1] : Qnil);
}
enum rb_realpath_mode {
@@ -4264,7 +4057,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE f
}
static VALUE
-rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum rb_realpath_mode mode)
+rb_check_realpath_internal(VALUE basedir, VALUE path, enum rb_realpath_mode mode)
{
long prefixlen;
VALUE resolved;
@@ -4272,7 +4065,7 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum
VALUE loopcheck;
VALUE curdir = Qnil;
- rb_encoding *enc;
+ rb_encoding *enc, *origenc;
char *path_names = NULL, *basedir_names = NULL, *curdir_names = NULL;
char *ptr, *prefixptr = NULL, *pend;
long len;
@@ -4285,6 +4078,7 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum
}
enc = rb_enc_get(unresolved_path);
+ origenc = enc;
unresolved_path = TO_OSPATH(unresolved_path);
RSTRING_GETMEM(unresolved_path, ptr, len);
path_names = skipprefixroot(ptr, ptr + len, rb_enc_get(unresolved_path));
@@ -4342,7 +4136,7 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum
if (realpath_rec(&prefixlen, &resolved, path_names, Qnil, loopcheck, mode, 1))
return Qnil;
- if (origenc && origenc != rb_enc_get(resolved)) {
+ if (origenc != rb_enc_get(resolved)) {
if (rb_enc_str_asciionly_p(resolved)) {
rb_enc_associate(resolved, origenc);
}
@@ -4351,93 +4145,24 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum
}
}
+ rb_obj_taint(resolved);
RB_GC_GUARD(unresolved_path);
RB_GC_GUARD(curdir);
return resolved;
}
-static VALUE rb_file_join(VALUE ary);
-
-static VALUE
-rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum rb_realpath_mode mode)
-{
-#ifdef HAVE_REALPATH
- VALUE unresolved_path;
- char *resolved_ptr = NULL;
- VALUE resolved;
- struct stat st;
-
- if (mode == RB_REALPATH_DIR) {
- return rb_check_realpath_emulate(basedir, path, origenc, mode);
- }
-
- unresolved_path = rb_str_dup_frozen(path);
- if (*RSTRING_PTR(unresolved_path) != '/' && !NIL_P(basedir)) {
- unresolved_path = rb_file_join(rb_assoc_new(basedir, unresolved_path));
- }
- if (origenc) unresolved_path = TO_OSPATH(unresolved_path);
-
- if ((resolved_ptr = realpath(RSTRING_PTR(unresolved_path), NULL)) == NULL) {
- /* glibc realpath(3) does not allow /path/to/file.rb/../other_file.rb,
- returning ENOTDIR in that case.
- glibc realpath(3) can also return ENOENT for paths that exist,
- such as /dev/fd/5.
- Fallback to the emulated approach in either of those cases. */
- if (errno == ENOTDIR ||
- (errno == ENOENT && rb_file_exist_p(0, unresolved_path))) {
- return rb_check_realpath_emulate(basedir, path, origenc, mode);
-
- }
- if (mode == RB_REALPATH_CHECK) {
- return Qnil;
- }
- rb_sys_fail_path(unresolved_path);
- }
- resolved = ospath_new(resolved_ptr, strlen(resolved_ptr), rb_filesystem_encoding());
- free(resolved_ptr);
-
- /* As `resolved` is a String in the filesystem encoding, no
- * conversion is needed */
- if (stat_without_gvl(RSTRING_PTR(resolved), &st) < 0) {
- if (mode == RB_REALPATH_CHECK) {
- return Qnil;
- }
- rb_sys_fail_path(unresolved_path);
- }
-
- if (origenc && origenc != rb_enc_get(resolved)) {
- if (!rb_enc_str_asciionly_p(resolved)) {
- resolved = rb_str_conv_enc(resolved, NULL, origenc);
- }
- rb_enc_associate(resolved, origenc);
- }
-
- if (rb_enc_str_coderange(resolved) == ENC_CODERANGE_BROKEN) {
- rb_enc_associate(resolved, rb_filesystem_encoding());
- if (rb_enc_str_coderange(resolved) == ENC_CODERANGE_BROKEN) {
- rb_enc_associate(resolved, rb_ascii8bit_encoding());
- }
- }
-
- RB_GC_GUARD(unresolved_path);
- return resolved;
-#else
- return rb_check_realpath_emulate(basedir, path, origenc, mode);
-#endif /* HAVE_REALPATH */
-}
-
VALUE
rb_realpath_internal(VALUE basedir, VALUE path, int strict)
{
const enum rb_realpath_mode mode =
strict ? RB_REALPATH_STRICT : RB_REALPATH_DIR;
- return rb_check_realpath_internal(basedir, path, rb_enc_get(path), mode);
+ return rb_check_realpath_internal(basedir, path, mode);
}
VALUE
-rb_check_realpath(VALUE basedir, VALUE path, rb_encoding *enc)
+rb_check_realpath(VALUE basedir, VALUE path)
{
- return rb_check_realpath_internal(basedir, path, enc, RB_REALPATH_CHECK);
+ return rb_check_realpath_internal(basedir, path, RB_REALPATH_CHECK);
}
/*
@@ -4588,11 +4313,12 @@ ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encodin
*
* Returns the last component of the filename given in
* <i>file_name</i> (after first stripping trailing separators),
- * which can be formed using both File::SEPARATOR and
- * File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is
- * not <code>nil</code>. If <i>suffix</i> is given and present at the
- * end of <i>file_name</i>, it is removed. If <i>suffix</i> is ".*",
- * any extension will be removed.
+ * which can be formed using both <code>File::SEPARATOR</code> and
+ * <code>File::ALT_SEPARATOR</code> as the separator when
+ * <code>File::ALT_SEPARATOR</code> is not <code>nil</code>. If
+ * <i>suffix</i> is given and present at the end of <i>file_name</i>,
+ * it is removed. If <i>suffix</i> is ".*", any extension will be
+ * removed.
*
* File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
* File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
@@ -4600,7 +4326,7 @@ ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encodin
*/
static VALUE
-rb_file_s_basename(int argc, VALUE *argv, VALUE _)
+rb_file_s_basename(int argc, VALUE *argv)
{
VALUE fname, fext, basename;
const char *name, *p;
@@ -4640,6 +4366,7 @@ rb_file_s_basename(int argc, VALUE *argv, VALUE _)
basename = rb_str_new(p, f);
rb_enc_copy(basename, fname);
+ OBJ_INFECT(basename, fname);
return basename;
}
@@ -4649,9 +4376,9 @@ rb_file_s_basename(int argc, VALUE *argv, VALUE _)
*
* Returns all components of the filename given in <i>file_name</i>
* except the last one (after first stripping trailing separators).
- * The filename can be formed using both File::SEPARATOR and
- * File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is
- * not <code>nil</code>.
+ * The filename can be formed using both <code>File::SEPARATOR</code>
+ * and <code>File::ALT_SEPARATOR</code> as the separator when
+ * <code>File::ALT_SEPARATOR</code> is not <code>nil</code>.
*
* File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work"
*/
@@ -4701,6 +4428,7 @@ rb_file_dirname(VALUE fname)
rb_str_cat(dirname, ".", 1);
#endif
rb_enc_copy(dirname, fname);
+ OBJ_INFECT(dirname, fname);
return dirname;
}
@@ -4782,13 +4510,10 @@ ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
* An empty string will also be returned when the period is the last character
* in +path+.
*
- * On Windows, trailing dots are truncated.
- *
* File.extname("test.rb") #=> ".rb"
* File.extname("a/b/d/test.rb") #=> ".rb"
* File.extname(".a/b/d/test.rb") #=> ".rb"
- * File.extname("foo.") #=> "" on Windows
- * File.extname("foo.") #=> "." on non-Windows
+ * File.extname("foo.") #=> ""
* File.extname("test") #=> ""
* File.extname(".profile") #=> ""
* File.extname(".profile.sh") #=> ".sh"
@@ -4806,9 +4531,10 @@ rb_file_s_extname(VALUE klass, VALUE fname)
name = StringValueCStr(fname);
len = RSTRING_LEN(fname);
e = ruby_enc_find_extname(name, &len, rb_enc_get(fname));
- if (len < 1)
+ if (len <= 1)
return rb_str_new(0, 0);
extname = rb_str_subseq(fname, e - name, len); /* keep the dot, too! */
+ OBJ_INFECT(extname, fname);
return extname;
}
@@ -4834,8 +4560,8 @@ rb_file_s_path(VALUE klass, VALUE fname)
* File.split(file_name) -> array
*
* Splits the given string into a directory and a file component and
- * returns them in a two-element array. See also File::dirname and
- * File::basename.
+ * returns them in a two-element array. See also
+ * <code>File::dirname</code> and <code>File::basename</code>.
*
* File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
*/
@@ -4844,9 +4570,11 @@ static VALUE
rb_file_s_split(VALUE klass, VALUE path)
{
FilePathStringValue(path); /* get rid of converting twice */
- return rb_assoc_new(rb_file_dirname(path), rb_file_s_basename(1,&path,Qundef));
+ return rb_assoc_new(rb_file_dirname(path), rb_file_s_basename(1,&path));
}
+static VALUE rb_file_join(VALUE ary);
+
static VALUE
file_inspect_join(VALUE ary, VALUE arg, int recur)
{
@@ -4879,6 +4607,7 @@ rb_file_join(VALUE ary)
len += RARRAY_LEN(ary) - 1;
result = rb_str_buf_new(len);
RBASIC_CLEAR_CLASS(result);
+ OBJ_INFECT(result, ary);
for (i=0; i<RARRAY_LEN(ary); i++) {
tmp = RARRAY_AREF(ary, i);
switch (OBJ_BUILTIN_TYPE(tmp)) {
@@ -5112,9 +4841,9 @@ rb_thread_flock(void *data)
*
* Locks or unlocks a file according to <i>locking_constant</i> (a
* logical <em>or</em> of the values in the table below).
- * Returns <code>false</code> if File::LOCK_NB is specified and the
- * operation would otherwise have blocked. Not available on all
- * platforms.
+ * Returns <code>false</code> if <code>File::LOCK_NB</code> is
+ * specified and the operation would otherwise have blocked. Not
+ * available on all platforms.
*
* Locking constants (in class File):
*
@@ -5268,7 +4997,7 @@ test_check(int n, int argc, VALUE *argv)
*/
static VALUE
-rb_f_test(int argc, VALUE *argv, VALUE _)
+rb_f_test(int argc, VALUE *argv)
{
int cmd;
@@ -5415,13 +5144,15 @@ rb_f_test(int argc, VALUE *argv, VALUE _)
/*
* Document-class: File::Stat
*
- * Objects of class File::Stat encapsulate common status information
- * for File objects. The information is recorded at the moment the
- * File::Stat object is created; changes made to the file after that
- * point will not be reflected. File::Stat objects are returned by
- * IO#stat, File::stat, File#lstat, and File::lstat. Many of these
+ * Objects of class <code>File::Stat</code> encapsulate common status
+ * information for <code>File</code> objects. The information is
+ * recorded at the moment the <code>File::Stat</code> object is
+ * created; changes made to the file after that point will not be
+ * reflected. <code>File::Stat</code> objects are returned by
+ * <code>IO#stat</code>, <code>File::stat</code>,
+ * <code>File#lstat</code>, and <code>File::lstat</code>. Many of these
* methods return platform-specific values, and not all values are
- * meaningful on all systems. See also Kernel#test.
+ * meaningful on all systems. See also <code>Kernel#test</code>.
*/
static VALUE
@@ -5542,9 +5273,10 @@ rb_stat_p(VALUE obj)
*
* Returns <code>true</code> if <i>stat</i> is a symbolic link,
* <code>false</code> if it isn't or if the operating system doesn't
- * support this feature. As File::stat automatically follows symbolic
- * links, #symlink? will always be <code>false</code> for an object
- * returned by File::stat.
+ * support this feature. As <code>File::stat</code> automatically
+ * follows symbolic links, <code>symlink?</code> will always be
+ * <code>false</code> for an object returned by
+ * <code>File::stat</code>.
*
* File.symlink("testfile", "alink") #=> 0
* File.stat("alink").symlink? #=> false
@@ -6075,7 +5807,7 @@ nogvl_mkfifo(void *ptr)
*/
static VALUE
-rb_file_s_mkfifo(int argc, VALUE *argv, VALUE _)
+rb_file_s_mkfifo(int argc, VALUE *argv)
{
VALUE path;
struct mkfifo_arg ma;
@@ -6098,7 +5830,7 @@ rb_file_s_mkfifo(int argc, VALUE *argv, VALUE _)
#define rb_file_s_mkfifo rb_f_notimplement
#endif
-static VALUE rb_mFConst;
+VALUE rb_mFConst;
void
rb_file_const(const char *name, VALUE value)
@@ -6226,7 +5958,7 @@ ruby_is_fd_loadable(int fd)
if (S_ISREG(st.st_mode))
return 1;
- if (S_ISFIFO(st.st_mode) || S_ISCHR(st.st_mode))
+ if (S_ISFIFO(st.st_mode))
return -1;
if (S_ISDIR(st.st_mode))
@@ -6281,14 +6013,13 @@ copy_path_class(VALUE path, VALUE orig)
}
int
-rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int _level)
+rb_find_file_ext(VALUE *filep, const char *const *ext)
{
- rb_warn("rb_find_file_ext_safe will be removed in Ruby 3.0");
- return rb_find_file_ext(filep, ext);
+ return rb_find_file_ext_safe(filep, ext, rb_safe_level());
}
int
-rb_find_file_ext(VALUE *filep, const char *const *ext)
+rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level)
{
const char *f = StringValueCStr(*filep);
VALUE fname = *filep, load_path, tmp;
@@ -6299,12 +6030,18 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
if (f[0] == '~') {
fname = file_expand_path_1(fname);
+ if (safe_level >= 1 && OBJ_TAINTED(fname)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
+ }
f = RSTRING_PTR(fname);
*filep = fname;
expanded = 1;
}
if (expanded || rb_is_absolute_path(f) || is_explicit_relative(f)) {
+ if (safe_level >= 1 && !fpath_check(fname)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);
+ }
if (!expanded) fname = file_expand_path_1(fname);
fnlen = RSTRING_LEN(fname);
for (i=0; ext[i]; i++) {
@@ -6331,13 +6068,14 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
for (i = 0; i < RARRAY_LEN(load_path); i++) {
VALUE str = RARRAY_AREF(load_path, i);
- RB_GC_GUARD(str) = rb_get_path(str);
+ RB_GC_GUARD(str) = rb_get_path_check(str, safe_level);
if (RSTRING_LEN(str) == 0) continue;
rb_file_expand_path_internal(fname, str, 0, 0, tmp);
if (rb_file_load_ok(RSTRING_PTR(tmp))) {
*filep = copy_path_class(tmp, *filep);
return (int)(j+1);
}
+ FL_UNSET(tmp, FL_TAINT);
}
rb_str_set_len(fname, fnlen);
}
@@ -6347,14 +6085,13 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
}
VALUE
-rb_find_file_safe(VALUE path, int _level)
+rb_find_file(VALUE path)
{
- rb_warn("rb_find_file_safe will be removed in Ruby 3.0");
- return rb_find_file(path);
+ return rb_find_file_safe(path, rb_safe_level());
}
VALUE
-rb_find_file(VALUE path)
+rb_find_file_safe(VALUE path, int safe_level)
{
VALUE tmp, load_path;
const char *f = StringValueCStr(path);
@@ -6362,12 +6099,18 @@ rb_find_file(VALUE path)
if (f[0] == '~') {
tmp = file_expand_path_1(path);
+ if (safe_level >= 1 && OBJ_TAINTED(tmp)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe file %"PRIsVALUE, tmp);
+ }
path = copy_path_class(tmp, path);
f = RSTRING_PTR(path);
expanded = 1;
}
if (expanded || rb_is_absolute_path(f) || is_explicit_relative(f)) {
+ if (safe_level >= 1 && !fpath_check(path)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe path %"PRIsVALUE, path);
+ }
if (!rb_file_load_ok(f)) return 0;
if (!expanded)
path = copy_path_class(file_expand_path_1(path), path);
@@ -6382,7 +6125,7 @@ rb_find_file(VALUE path)
rb_enc_associate_index(tmp, rb_usascii_encindex());
for (i = 0; i < RARRAY_LEN(load_path); i++) {
VALUE str = RARRAY_AREF(load_path, i);
- RB_GC_GUARD(str) = rb_get_path(str);
+ RB_GC_GUARD(str) = rb_get_path_check(str, safe_level);
if (RSTRING_LEN(str) > 0) {
rb_file_expand_path_internal(path, str, 0, 0, tmp);
f = RSTRING_PTR(tmp);
@@ -6397,6 +6140,10 @@ rb_find_file(VALUE path)
}
found:
+ if (safe_level >= 1 && !fpath_check(tmp)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe file %"PRIsVALUE, tmp);
+ }
+
return copy_path_class(tmp, path);
}
@@ -6407,7 +6154,7 @@ define_filetest_function(const char *name, VALUE (*func)(ANYARGS), int argc)
rb_define_singleton_method(rb_cFile, name, func, argc);
}
-const char ruby_null_device[] =
+static const char null_device[] =
#if defined DOSISH
"NUL"
#elif defined AMIGA || defined __amigaos__
@@ -6420,10 +6167,11 @@ const char ruby_null_device[] =
;
/*
- * A File is an abstraction of any file object accessible by the
- * program and is closely associated with class IO. File includes
- * the methods of module FileTest as class methods, allowing you to
- * write (for example) <code>File.exist?("foo")</code>.
+ * A <code>File</code> is an abstraction of any file object accessible
+ * by the program and is closely associated with class <code>IO</code>.
+ * <code>File</code> includes the methods of module
+ * <code>FileTest</code> as class methods, allowing you to write (for
+ * example) <code>File.exist?("foo")</code>.
*
* In the description of File methods,
* <em>permission bits</em> are a platform-specific
@@ -6518,9 +6266,8 @@ Init_File(void)
rb_define_singleton_method(rb_cFile, "umask", rb_file_s_umask, -1);
rb_define_singleton_method(rb_cFile, "truncate", rb_file_s_truncate, 2);
rb_define_singleton_method(rb_cFile, "mkfifo", rb_file_s_mkfifo, -1);
- rb_define_singleton_method(rb_cFile, "expand_path", s_expand_path, -1);
- rb_define_singleton_method(rb_cFile, "absolute_path", s_absolute_path, -1);
- rb_define_singleton_method(rb_cFile, "absolute_path?", s_absolute_path_p, 1);
+ rb_define_singleton_method(rb_cFile, "expand_path", rb_file_s_expand_path, -1);
+ rb_define_singleton_method(rb_cFile, "absolute_path", rb_file_s_absolute_path, -1);
rb_define_singleton_method(rb_cFile, "realpath", rb_file_s_realpath, -1);
rb_define_singleton_method(rb_cFile, "realdirpath", rb_file_s_realdirpath, -1);
rb_define_singleton_method(rb_cFile, "basename", rb_file_s_basename, -1);
@@ -6528,10 +6275,9 @@ Init_File(void)
rb_define_singleton_method(rb_cFile, "extname", rb_file_s_extname, 1);
rb_define_singleton_method(rb_cFile, "path", rb_file_s_path, 1);
- separator = rb_fstring_lit("/");
+ separator = rb_fstring_cstr("/");
/* separates directory parts in path */
rb_define_const(rb_cFile, "Separator", separator);
- /* separates directory parts in path */
rb_define_const(rb_cFile, "SEPARATOR", separator);
rb_define_singleton_method(rb_cFile, "split", rb_file_s_split, 1);
rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2);
@@ -6650,7 +6396,7 @@ Init_File(void)
rb_define_const(rb_mFConst, "LOCK_NB", INT2FIX(LOCK_NB));
/* Name of the null device */
- rb_define_const(rb_mFConst, "NULL", rb_fstring_cstr(ruby_null_device));
+ rb_define_const(rb_mFConst, "NULL", rb_fstring_cstr(null_device));
rb_define_method(rb_cFile, "path", rb_file_path, 0);
rb_define_method(rb_cFile, "to_path", rb_file_path, 0);
diff --git a/gc.c b/gc.c
index 67a709ff79..c02ac627f0 100644
--- a/gc.c
+++ b/gc.c
@@ -14,31 +14,26 @@
#define rb_data_object_alloc rb_data_object_alloc
#define rb_data_typed_object_alloc rb_data_typed_object_alloc
-#include "ruby/encoding.h"
-#include "ruby/io.h"
+#include "internal.h"
#include "ruby/st.h"
#include "ruby/re.h"
+#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "ruby/debug.h"
-#include "internal.h"
#include "eval_intern.h"
#include "vm_core.h"
-#include "builtin.h"
#include "gc.h"
#include "constant.h"
#include "ruby_atomic.h"
#include "probes.h"
#include "id_table.h"
-#include "symbol.h"
#include <stdio.h>
#include <stdarg.h>
#include <setjmp.h>
#include <sys/types.h>
#include "ruby_assert.h"
#include "debug_counter.h"
-#include "transient_heap.h"
-#include "mjit.h"
#undef rb_data_object_wrap
@@ -52,9 +47,7 @@
# endif
#endif
#ifdef HAVE_MALLOC_USABLE_SIZE
-# ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
-# include RUBY_ALTERNATIVE_MALLOC_HEADER
-# elif HAVE_MALLOC_H
+# ifdef HAVE_MALLOC_H
# include <malloc.h>
# elif defined(HAVE_MALLOC_NP_H)
# include <malloc_np.h>
@@ -63,6 +56,16 @@
# endif
#endif
+#if /* is ASAN enabled? */ \
+ __has_feature(address_sanitizer) /* Clang */ || \
+ defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x */
+ #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \
+ __attribute__((no_address_safety_analysis)) \
+ __attribute__((noinline))
+#else
+ #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
+#endif
+
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@@ -81,168 +84,6 @@
#define rb_setjmp(env) RUBY_SETJMP(env)
#define rb_jmp_buf rb_jmpbuf_t
-#if defined(_MSC_VER) && defined(_WIN64)
-#include <intrin.h>
-#pragma intrinsic(_umul128)
-#endif
-
-/* Expecting this struct to be eliminated by function inlinings */
-struct optional {
- bool left;
- size_t right;
-};
-
-static inline struct optional
-size_mul_overflow(size_t x, size_t y)
-{
- bool p;
- size_t z;
-#if 0
-
-#elif defined(HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW)
- p = __builtin_mul_overflow(x, y, &z);
-
-#elif defined(DSIZE_T)
- RB_GNUC_EXTENSION DSIZE_T dx = x;
- RB_GNUC_EXTENSION DSIZE_T dy = y;
- RB_GNUC_EXTENSION DSIZE_T dz = dx * dy;
- p = dz > SIZE_MAX;
- z = (size_t)dz;
-
-#elif defined(_MSC_VER) && defined(_WIN64)
- unsigned __int64 dp;
- unsigned __int64 dz = _umul128(x, y, &dp);
- p = (bool)dp;
- z = (size_t)dz;
-
-#else
- /* https://wiki.sei.cmu.edu/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap */
- p = (y != 0) && (x > SIZE_MAX / y);
- z = x * y;
-
-#endif
- return (struct optional) { p, z, };
-}
-
-static inline struct optional
-size_add_overflow(size_t x, size_t y)
-{
- size_t z;
- bool p;
-#if 0
-
-#elif defined(HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW)
- p = __builtin_add_overflow(x, y, &z);
-
-#elif defined(DSIZE_T)
- RB_GNUC_EXTENSION DSIZE_T dx = x;
- RB_GNUC_EXTENSION DSIZE_T dy = y;
- RB_GNUC_EXTENSION DSIZE_T dz = dx + dy;
- p = dz > SIZE_MAX;
- z = (size_t)dz;
-
-#else
- z = x + y;
- p = z < y;
-
-#endif
- return (struct optional) { p, z, };
-}
-
-static inline struct optional
-size_mul_add_overflow(size_t x, size_t y, size_t z) /* x * y + z */
-{
- struct optional t = size_mul_overflow(x, y);
- struct optional u = size_add_overflow(t.right, z);
- return (struct optional) { t.left || u.left, u.right };
-}
-
-static inline struct optional
-size_mul_add_mul_overflow(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
-{
- struct optional t = size_mul_overflow(x, y);
- struct optional u = size_mul_overflow(z, w);
- struct optional v = size_add_overflow(t.right, u.right);
- return (struct optional) { t.left || u.left || v.left, v.right };
-}
-
-PRINTF_ARGS(NORETURN(static void gc_raise(VALUE, const char*, ...)), 2, 3);
-
-static inline size_t
-size_mul_or_raise(size_t x, size_t y, VALUE exc)
-{
- struct optional t = size_mul_overflow(x, y);
- if (LIKELY(!t.left)) {
- return t.right;
- }
- else if (rb_during_gc()) {
- rb_memerror(); /* or...? */
- }
- else {
- gc_raise(
- exc,
- "integer overflow: %"PRIuSIZE
- " * %"PRIuSIZE
- " > %"PRIuSIZE,
- x, y, SIZE_MAX);
- }
-}
-
-size_t
-rb_size_mul_or_raise(size_t x, size_t y, VALUE exc)
-{
- return size_mul_or_raise(x, y, exc);
-}
-
-static inline size_t
-size_mul_add_or_raise(size_t x, size_t y, size_t z, VALUE exc)
-{
- struct optional t = size_mul_add_overflow(x, y, z);
- if (LIKELY(!t.left)) {
- return t.right;
- }
- else if (rb_during_gc()) {
- rb_memerror(); /* or...? */
- }
- else {
- gc_raise(
- exc,
- "integer overflow: %"PRIuSIZE
- " * %"PRIuSIZE
- " + %"PRIuSIZE
- " > %"PRIuSIZE,
- x, y, z, SIZE_MAX);
- }
-}
-
-size_t
-rb_size_mul_add_or_raise(size_t x, size_t y, size_t z, VALUE exc)
-{
- return size_mul_add_or_raise(x, y, z, exc);
-}
-
-static inline size_t
-size_mul_add_mul_or_raise(size_t x, size_t y, size_t z, size_t w, VALUE exc)
-{
- struct optional t = size_mul_add_mul_overflow(x, y, z, w);
- if (LIKELY(!t.left)) {
- return t.right;
- }
- else if (rb_during_gc()) {
- rb_memerror(); /* or...? */
- }
- else {
- gc_raise(
- exc,
- "integer overflow: %"PRIdSIZE
- " * %"PRIdSIZE
- " + %"PRIdSIZE
- " * %"PRIdSIZE
- " > %"PRIdSIZE,
- x, y, z, w, SIZE_MAX);
- }
-}
-
#if defined(HAVE_RB_GC_GUARDED_PTR_VAL) && HAVE_RB_GC_GUARDED_PTR_VAL
/* trick the compiler into thinking a external signal handler uses this */
volatile VALUE rb_gc_guarded_val;
@@ -399,8 +240,11 @@ int ruby_rgengc_debug;
#define RGENGC_CHECK_MODE 0
#endif
-// Note: using RUBY_ASSERT_WHEN() extend a macro in expr (info by nobu).
+#if RGENGC_CHECK_MODE > 0
#define GC_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RGENGC_CHECK_MODE > 0, expr, #expr)
+#else
+#define GC_ASSERT(expr) ((void)0)
+#endif
/* RGENGC_OLD_NEWOBJ_CHECK
* 0: disable all assertions
@@ -467,7 +311,7 @@ int ruby_rgengc_debug;
#define GC_ENABLE_LAZY_SWEEP 1
#endif
#ifndef CALC_EXACT_MALLOC_SIZE
-#define CALC_EXACT_MALLOC_SIZE USE_GC_MALLOC_OBJ_INFO_DETAILS
+#define CALC_EXACT_MALLOC_SIZE 0
#endif
#if defined(HAVE_MALLOC_USABLE_SIZE) || CALC_EXACT_MALLOC_SIZE > 0
#ifndef MALLOC_ALLOCATED_SIZE
@@ -509,13 +353,7 @@ typedef enum {
/* others */
GPR_FLAG_IMMEDIATE_SWEEP = 0x2000,
- GPR_FLAG_HAVE_FINALIZE = 0x4000,
- GPR_FLAG_IMMEDIATE_MARK = 0x8000,
- GPR_FLAG_FULL_MARK = 0x10000,
-
- GPR_DEFAULT_REASON =
- (GPR_FLAG_FULL_MARK | GPR_FLAG_IMMEDIATE_MARK |
- GPR_FLAG_IMMEDIATE_SWEEP | GPR_FLAG_CAPI),
+ GPR_FLAG_HAVE_FINALIZE = 0x4000
} gc_profile_record_flag;
typedef struct gc_profile_record {
@@ -569,7 +407,6 @@ typedef struct RVALUE {
VALUE flags; /* always 0 for freed obj */
struct RVALUE *next;
} free;
- struct RMoved moved;
struct RBasic basic;
struct RObject object;
struct RClass klass;
@@ -595,7 +432,7 @@ typedef struct RVALUE {
struct rb_method_entry_struct ment;
const rb_iseq_t iseq;
rb_env_t env;
- struct rb_imemo_tmpbuf_struct alloc;
+ struct rb_imemo_alloc_struct alloc;
rb_ast_t ast;
} imemo;
struct {
@@ -620,7 +457,6 @@ enum {
BITS_SIZE = sizeof(bits_t),
BITS_BITLENGTH = ( BITS_SIZE * CHAR_BIT )
};
-#define popcount_bits rb_popcount_intptr
struct heap_page_header {
struct heap_page *page;
@@ -658,8 +494,8 @@ typedef struct rb_heap_struct {
struct heap_page *free_pages;
struct heap_page *using_page;
- struct list_head pages;
- struct heap_page *sweeping_page; /* iterator for .pages */
+ struct heap_page *pages;
+ struct heap_page *sweep_pages;
#if GC_ENABLE_INCREMENTAL_MARK
struct heap_page *pooled_pages;
#endif
@@ -689,7 +525,6 @@ typedef struct rb_objspace {
unsigned int dont_gc : 1;
unsigned int dont_incremental : 1;
unsigned int during_gc : 1;
- unsigned int during_compacting : 1;
unsigned int gc_stressful: 1;
unsigned int has_hook: 1;
#if USE_RGENGC
@@ -702,7 +537,6 @@ typedef struct rb_objspace {
rb_event_flag_t hook_events;
size_t total_allocated_objects;
- VALUE next_object_id;
rb_heap_t eden_heap;
rb_heap_t tomb_heap; /* heap for zombies and ghosts */
@@ -750,7 +584,6 @@ typedef struct rb_objspace {
#if USE_RGENGC
size_t minor_gc_count;
size_t major_gc_count;
- size_t compact_count;
#if RGENGC_PROFILE > 0
size_t total_generated_normal_object_count;
size_t total_generated_shady_object_count;
@@ -805,12 +638,6 @@ typedef struct rb_objspace {
size_t error_count;
#endif
} rgengc;
-
- struct {
- size_t considered_count_table[T_MASK];
- size_t moved_count_table[T_MASK];
- } rcompactor;
-
#if GC_ENABLE_INCREMENTAL_MARK
struct {
size_t pooled_slots;
@@ -819,17 +646,16 @@ typedef struct rb_objspace {
#endif
#endif /* USE_RGENGC */
- st_table *id_to_obj_tbl;
- st_table *obj_to_id_tbl;
-
#if GC_DEBUG_STRESS_TO_CLASS
VALUE stress_to_class;
#endif
} rb_objspace_t;
+#ifndef HEAP_PAGE_ALIGN_LOG
/* default tiny heap size: 16KB */
#define HEAP_PAGE_ALIGN_LOG 14
+#endif
#define CEILDIV(i, mod) (((i) + (mod) - 1)/(mod))
enum {
HEAP_PAGE_ALIGN = (1UL << HEAP_PAGE_ALIGN_LOG),
@@ -843,9 +669,9 @@ enum {
};
struct heap_page {
+ struct heap_page *prev;
short total_slots;
short free_slots;
- short pinned_slots;
short final_slots;
struct {
unsigned int before_sweep : 1;
@@ -857,7 +683,7 @@ struct heap_page {
struct heap_page *free_next;
RVALUE *start;
RVALUE *freelist;
- struct list_node page_node;
+ struct heap_page *next;
#if USE_RGENGC
bits_t wb_unprotected_bits[HEAP_PAGE_BITMAP_LIMIT];
@@ -868,9 +694,6 @@ struct heap_page {
bits_t uncollectible_bits[HEAP_PAGE_BITMAP_LIMIT];
bits_t marking_bits[HEAP_PAGE_BITMAP_LIMIT];
#endif
-
- /* If set, the object is not movable */
- bits_t pinned_bits[HEAP_PAGE_BITMAP_LIMIT];
};
#define GET_PAGE_BODY(x) ((struct heap_page_body *)((bits_t)(x) & ~(HEAP_PAGE_ALIGN_MASK)))
@@ -889,16 +712,24 @@ struct heap_page {
/* getting bitmap */
#define GET_HEAP_MARK_BITS(x) (&GET_HEAP_PAGE(x)->mark_bits[0])
-#define GET_HEAP_PINNED_BITS(x) (&GET_HEAP_PAGE(x)->pinned_bits[0])
#if USE_RGENGC
#define GET_HEAP_UNCOLLECTIBLE_BITS(x) (&GET_HEAP_PAGE(x)->uncollectible_bits[0])
#define GET_HEAP_WB_UNPROTECTED_BITS(x) (&GET_HEAP_PAGE(x)->wb_unprotected_bits[0])
#define GET_HEAP_MARKING_BITS(x) (&GET_HEAP_PAGE(x)->marking_bits[0])
#endif
+#ifndef ENABLE_VM_OBJSPACE
+# define ENABLE_VM_OBJSPACE 1
+#endif
+
/* Aliases */
+#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
#define rb_objspace (*rb_objspace_of(GET_VM()))
#define rb_objspace_of(vm) ((vm)->objspace)
+#else
+static rb_objspace_t rb_objspace = {{GC_MALLOC_LIMIT_MIN}};
+#define rb_objspace_of(vm) (&rb_objspace)
+#endif
#define ruby_initial_gc_stress gc_params.gc_stress
@@ -967,7 +798,7 @@ gc_mode_verify(enum gc_mode mode)
#else
#define will_be_incremental_marking(objspace) FALSE
#endif
-#define has_sweeping_pages(heap) ((heap)->sweeping_page != 0)
+#define has_sweeping_pages(heap) ((heap)->sweep_pages != 0)
#define is_lazy_sweeping(heap) (GC_ENABLE_LAZY_SWEEP && has_sweeping_pages(heap))
#if SIZEOF_LONG == SIZEOF_VOIDP
@@ -994,31 +825,29 @@ struct RZombie {
#define nomem_error GET_VM()->special_exceptions[ruby_error_nomemory]
-#if RUBY_MARK_FREE_DEBUG
int ruby_gc_debug_indent = 0;
-#endif
VALUE rb_mGC;
int ruby_disable_gc = 0;
void rb_iseq_mark(const rb_iseq_t *iseq);
-void rb_iseq_update_references(rb_iseq_t *iseq);
void rb_iseq_free(const rb_iseq_t *iseq);
-size_t rb_iseq_memsize(const rb_iseq_t *iseq);
-void rb_vm_update_references(void *ptr);
void rb_gcdebug_print_obj_condition(VALUE obj);
+static void rb_objspace_call_finalizer(rb_objspace_t *objspace);
static VALUE define_final0(VALUE obj, VALUE block);
-NORETURN(static void negative_size_allocation_error(const char *));
+static void negative_size_allocation_error(const char *);
+static void *aligned_malloc(size_t, size_t);
+static void aligned_free(void *);
static void init_mark_stack(mark_stack_t *stack);
static int ready_to_gc(rb_objspace_t *objspace);
-static int garbage_collect(rb_objspace_t *, int reason);
+static int garbage_collect(rb_objspace_t *, int full_mark, int immediate_mark, int immediate_sweep, int reason);
-static int gc_start(rb_objspace_t *objspace, int reason);
+static int gc_start(rb_objspace_t *objspace, const int full_mark, const int immediate_mark, const unsigned int immediate_sweep, int reason);
static void gc_rest(rb_objspace_t *objspace);
static inline void gc_enter(rb_objspace_t *objspace, const char *event);
static inline void gc_exit(rb_objspace_t *objspace, const char *event);
@@ -1027,21 +856,23 @@ static void gc_marks(rb_objspace_t *objspace, int full_mark);
static void gc_marks_start(rb_objspace_t *objspace, int full);
static int gc_marks_finish(rb_objspace_t *objspace);
static void gc_marks_rest(rb_objspace_t *objspace);
+#if GC_ENABLE_INCREMENTAL_MARK
static void gc_marks_step(rb_objspace_t *objspace, int slots);
static void gc_marks_continue(rb_objspace_t *objspace, rb_heap_t *heap);
+#endif
static void gc_sweep(rb_objspace_t *objspace);
static void gc_sweep_start(rb_objspace_t *objspace);
static void gc_sweep_finish(rb_objspace_t *objspace);
static int gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap);
static void gc_sweep_rest(rb_objspace_t *objspace);
+#if GC_ENABLE_LAZY_SWEEP
static void gc_sweep_continue(rb_objspace_t *objspace, rb_heap_t *heap);
+#endif
static inline void gc_mark(rb_objspace_t *objspace, VALUE ptr);
-static inline void gc_pin(rb_objspace_t *objspace, VALUE ptr);
-static inline void gc_mark_and_pin(rb_objspace_t *objspace, VALUE ptr);
static void gc_mark_ptr(rb_objspace_t *objspace, VALUE ptr);
-NO_SANITIZE("memory", static void gc_mark_maybe(rb_objspace_t *objspace, VALUE ptr));
+static void gc_mark_maybe(rb_objspace_t *objspace, VALUE ptr);
static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr);
static int gc_mark_stacked_objects_incremental(rb_objspace_t *, size_t count);
@@ -1049,7 +880,7 @@ static int gc_mark_stacked_objects_all(rb_objspace_t *);
static void gc_grey(rb_objspace_t *objspace, VALUE ptr);
static inline int gc_mark_set(rb_objspace_t *objspace, VALUE obj);
-NO_SANITIZE("memory", static inline int is_pointer_to_heap(rb_objspace_t *objspace, void *ptr));
+static inline int is_pointer_to_heap(rb_objspace_t *objspace, void *ptr);
static void push_mark_stack(mark_stack_t *, VALUE);
static int pop_mark_stack(mark_stack_t *, VALUE *);
@@ -1057,12 +888,11 @@ static size_t mark_stack_size(mark_stack_t *stack);
static void shrink_stack_chunk_cache(mark_stack_t *stack);
static size_t obj_memsize_of(VALUE obj, int use_all_types);
-static void gc_verify_internal_consistency(rb_objspace_t *objspace);
+static VALUE gc_verify_internal_consistency(VALUE self);
static int gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj);
static int gc_verify_heap_pages(rb_objspace_t *objspace);
static void gc_stress_set(rb_objspace_t *objspace, VALUE flag);
-static VALUE gc_disable_no_rest(rb_objspace_t *);
static double getrusage_time(void);
static inline void gc_prof_setup_new_record(rb_objspace_t *objspace, int reason);
@@ -1075,14 +905,6 @@ static inline void gc_prof_sweep_timer_stop(rb_objspace_t *);
static inline void gc_prof_set_malloc_info(rb_objspace_t *);
static inline void gc_prof_set_heap_info(rb_objspace_t *);
-#define TYPED_UPDATE_IF_MOVED(_objspace, _type, _thing) do { \
- if (gc_object_moved_p(_objspace, (VALUE)_thing)) { \
- *((_type *)(&_thing)) = (_type)RMOVED((_thing))->destination; \
- } \
-} while (0)
-
-#define UPDATE_IF_MOVED(_objspace, _thing) TYPED_UPDATE_IF_MOVED(_objspace, VALUE, _thing)
-
#define gc_prof_record(objspace) (objspace)->profile.current_record
#define gc_prof_enabled(objspace) ((objspace)->profile.run && (objspace)->profile.current_record)
@@ -1153,19 +975,6 @@ tick(void)
return val;
}
-#elif defined(__aarch64__) && defined(__GNUC__)
-typedef unsigned long tick_t;
-#define PRItick "lu"
-
-static __inline__ tick_t
-tick(void)
-{
- unsigned long val;
- __asm__ __volatile__ ("mrs %0, cntvct_el0", : "=r" (val));
- return val;
-}
-
-
#elif defined(_WIN32) && defined(_MSC_VER)
#include <intrin.h>
typedef unsigned __int64 tick_t;
@@ -1221,7 +1030,6 @@ tick(void)
#define FL_UNSET2(x,f) FL_CHECK2("FL_UNSET2", x, RBASIC(x)->flags &= ~(f))
#define RVALUE_MARK_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), (obj))
-#define RVALUE_PIN_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), (obj))
#define RVALUE_PAGE_MARKED(page, obj) MARKED_IN_BITMAP((page)->mark_bits, (obj))
#if USE_RGENGC
@@ -1237,7 +1045,6 @@ tick(void)
#define RVALUE_AGE_SHIFT 5 /* FL_PROMOTED0 bit */
static int rgengc_remembered(rb_objspace_t *objspace, VALUE obj);
-static int rgengc_remembered_sweep(rb_objspace_t *objspace, VALUE obj);
static int rgengc_remember(rb_objspace_t *objspace, VALUE obj);
static void rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap);
static void rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap);
@@ -1250,153 +1057,79 @@ RVALUE_FLAGS_AGE(VALUE flags)
#endif /* USE_RGENGC */
-static int
-check_rvalue_consistency_force(const VALUE obj, int terminate)
+
+#if RGENGC_CHECK_MODE == 0
+static inline VALUE
+check_rvalue_consistency(const VALUE obj)
+{
+ return obj;
+}
+#else
+static VALUE
+check_rvalue_consistency(const VALUE obj)
{
rb_objspace_t *objspace = &rb_objspace;
- int err = 0;
if (SPECIAL_CONST_P(obj)) {
- fprintf(stderr, "check_rvalue_consistency: %p is a special const.\n", (void *)obj);
- err++;
+ rb_bug("check_rvalue_consistency: %p is a special const.", (void *)obj);
}
else if (!is_pointer_to_heap(objspace, (void *)obj)) {
- /* check if it is in tomb_pages */
- struct heap_page *page = NULL;
- list_for_each(&heap_tomb->pages, page, page_node) {
- if (&page->start[0] <= (RVALUE *)obj &&
- (RVALUE *)obj < &page->start[page->total_slots]) {
- fprintf(stderr, "check_rvalue_consistency: %p is in a tomb_heap (%p).\n",
- (void *)obj, (void *)page);
- err++;
- goto skip;
- }
- }
- fprintf(stderr, "check_rvalue_consistency: %p is not a Ruby object.\n", (void *)obj);
- err++;
- skip:
- ;
+ rb_bug("check_rvalue_consistency: %p is not a Ruby object.", (void *)obj);
}
else {
- const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
- const int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
- const int mark_bit = RVALUE_MARK_BITMAP(obj) != 0;
- const int marking_bit = RVALUE_MARKING_BITMAP(obj) != 0, remembered_bit = marking_bit;
- const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
-
- if (GET_HEAP_PAGE(obj)->flags.in_tomb) {
- fprintf(stderr, "check_rvalue_consistency: %s is in tomb page.\n", obj_info(obj));
- err++;
- }
- if (BUILTIN_TYPE(obj) == T_NONE) {
- fprintf(stderr, "check_rvalue_consistency: %s is T_NONE.\n", obj_info(obj));
- err++;
- }
- if (BUILTIN_TYPE(obj) == T_ZOMBIE) {
- fprintf(stderr, "check_rvalue_consistency: %s is T_ZOMBIE.\n", obj_info(obj));
- err++;
- }
-
- obj_memsize_of((VALUE)obj, FALSE);
+ const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
+ const int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
+ const int mark_bit = RVALUE_MARK_BITMAP(obj) != 0;
+ const int marking_bit = RVALUE_MARKING_BITMAP(obj) != 0, remembered_bit = marking_bit;
+ const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
- /* check generation
- *
- * OLD == age == 3 && old-bitmap && mark-bit (except incremental marking)
- */
- if (age > 0 && wb_unprotected_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is not WB protected, but age is %d > 0.\n", obj_info(obj), age);
- err++;
- }
+ if (BUILTIN_TYPE(obj) == T_NONE) rb_bug("check_rvalue_consistency: %s is T_NONE", obj_info(obj));
+ if (BUILTIN_TYPE(obj) == T_ZOMBIE) rb_bug("check_rvalue_consistency: %s is T_ZOMBIE", obj_info(obj));
+ obj_memsize_of((VALUE)obj, FALSE);
- if (!is_marking(objspace) && uncollectible_bit && !mark_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is uncollectible, but is not marked while !gc.\n", obj_info(obj));
- err++;
- }
+ /* check generation
+ *
+ * OLD == age == 3 && old-bitmap && mark-bit (except incremental marking)
+ */
+ if (age > 0 && wb_unprotected_bit) {
+ rb_bug("check_rvalue_consistency: %s is not WB protected, but age is %d > 0.", obj_info(obj), age);
+ }
- if (!is_full_marking(objspace)) {
- if (uncollectible_bit && age != RVALUE_OLD_AGE && !wb_unprotected_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is uncollectible, but not old (age: %d) and not WB unprotected.\n",
- obj_info(obj), age);
- err++;
- }
- if (remembered_bit && age != RVALUE_OLD_AGE) {
- fprintf(stderr, "check_rvalue_consistency: %s is remembered, but not old (age: %d).\n",
- obj_info(obj), age);
- err++;
- }
- }
+ if (!is_marking(objspace) && uncollectible_bit && !mark_bit) {
+ rb_bug("check_rvalue_consistency: %s is uncollectible, but is not marked while !gc.", obj_info(obj));
+ }
- /*
- * check coloring
- *
- * marking:false marking:true
- * marked:false white *invalid*
- * marked:true black grey
- */
- if (is_incremental_marking(objspace) && marking_bit) {
- if (!is_marking(objspace) && !mark_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is marking, but not marked.\n", obj_info(obj));
- err++;
- }
- }
- }
+ if (!is_full_marking(objspace)) {
+ if (uncollectible_bit && age != RVALUE_OLD_AGE && !wb_unprotected_bit) {
+ rb_bug("check_rvalue_consistency: %s is uncollectible, but not old (age: %d) and not WB unprotected.", obj_info(obj), age);
+ }
+ if (remembered_bit && age != RVALUE_OLD_AGE) {
+ rb_bug("check_rvalue_consistency: %s is rememberd, but not old (age: %d).", obj_info(obj), age);
+ }
+ }
- if (err > 0 && terminate) {
- rb_bug("check_rvalue_consistency_force: there is %d errors.", err);
+ /*
+ * check coloring
+ *
+ * marking:false marking:true
+ * marked:false white *invalid*
+ * marked:true black grey
+ */
+ if (is_incremental_marking(objspace) && marking_bit) {
+ if (!is_marking(objspace) && !mark_bit) rb_bug("check_rvalue_consistency: %s is marking, but not marked.", obj_info(obj));
+ }
}
-
- return err;
-}
-
-#if RGENGC_CHECK_MODE == 0
-static inline VALUE
-check_rvalue_consistency(const VALUE obj)
-{
- return obj;
-}
-#else
-static VALUE
-check_rvalue_consistency(const VALUE obj)
-{
- check_rvalue_consistency_force(obj, TRUE);
return obj;
}
#endif
static inline int
-gc_object_moved_p(rb_objspace_t * objspace, VALUE obj)
-{
- if (RB_SPECIAL_CONST_P(obj)) {
- return FALSE;
- }
- else {
- void *poisoned = asan_poisoned_object_p(obj);
- asan_unpoison_object(obj, false);
-
- int ret = BUILTIN_TYPE(obj) == T_MOVED;
- /* Re-poison slot if it's not the one we want */
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
- asan_poison_object(obj);
- }
- return ret;
- }
-}
-
-static inline int
RVALUE_MARKED(VALUE obj)
{
check_rvalue_consistency(obj);
return RVALUE_MARK_BITMAP(obj) != 0;
}
-static inline int
-RVALUE_PINNED(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_PIN_BITMAP(obj) != 0;
-}
-
#if USE_RGENGC
static inline int
RVALUE_WB_UNPROTECTED(VALUE obj)
@@ -1454,7 +1187,6 @@ RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, struct heap_page *pag
{
MARK_IN_BITMAP(&page->uncollectible_bits[0], obj);
objspace->rgengc.old_objects++;
- rb_transient_heap_promote(obj);
#if RGENGC_PROFILE >= 2
objspace->profile.total_promoted_count++;
@@ -1465,7 +1197,6 @@ RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, struct heap_page *pag
static inline void
RVALUE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, VALUE obj)
{
- RB_DEBUG_COUNTER_INC(obj_promote);
RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(objspace, GET_HEAP_PAGE(obj), obj);
}
@@ -1590,20 +1321,15 @@ RVALUE_WHITE_P(VALUE obj)
--------------------------- ObjectSpace -----------------------------
*/
-static inline void *
-calloc1(size_t n)
-{
- return calloc(1, n);
-}
-
rb_objspace_t *
rb_objspace_alloc(void)
{
- rb_objspace_t *objspace = calloc1(sizeof(rb_objspace_t));
+#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
+ rb_objspace_t *objspace = calloc(1, sizeof(rb_objspace_t));
+#else
+ rb_objspace_t *objspace = &rb_objspace;
+#endif
malloc_limit = gc_params.malloc_limit_min;
- list_head_init(&objspace->eden_heap.pages);
- list_head_init(&objspace->tomb_heap.pages);
- dont_gc = TRUE;
return objspace;
}
@@ -1642,10 +1368,12 @@ rb_objspace_free(rb_objspace_t *objspace)
objspace->eden_heap.total_pages = 0;
objspace->eden_heap.total_slots = 0;
+ objspace->eden_heap.pages = NULL;
}
- st_free_table(objspace->id_to_obj_tbl);
- st_free_table(objspace->obj_to_id_tbl);
free_stack_chunks(&objspace->mark_stack);
+#if !(defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE)
+ if (objspace == &rb_objspace) return;
+#endif
free(objspace);
}
@@ -1653,7 +1381,7 @@ static void
heap_pages_expand_sorted_to(rb_objspace_t *objspace, size_t next_length)
{
struct heap_page **sorted;
- size_t size = size_mul_or_raise(next_length, sizeof(struct heap_page *), rb_eRuntimeError);
+ size_t size = next_length * sizeof(struct heap_page *);
gc_report(3, objspace, "heap_pages_expand_sorted: next_length: %d, size: %d\n", (int)next_length, (int)size);
@@ -1676,8 +1404,8 @@ static void
heap_pages_expand_sorted(rb_objspace_t *objspace)
{
/* usually heap_allocatable_pages + heap_eden->total_pages == heap_pages_sorted_length
- * because heap_allocatable_pages contains heap_tomb->total_pages (recycle heap_tomb pages).
- * however, if there are pages which do not have empty slots, then try to create new pages
+ * beacuse heap_allocatable_pages contains heap_tomb->total_pages (recycle heap_tomb pages).
+ * howerver, if there are pages which do not have empty slots, then try to create new pages
* so that the additional allocatable_pages counts (heap_tomb->total_pages) are added.
*/
size_t next_length = heap_allocatable_pages;
@@ -1704,54 +1432,37 @@ static inline void
heap_page_add_freeobj(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
{
RVALUE *p = (RVALUE *)obj;
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
-
p->as.free.flags = 0;
p->as.free.next = page->freelist;
page->freelist = p;
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
- if (RGENGC_CHECK_MODE &&
- /* obj should belong to page */
- !(&page->start[0] <= (RVALUE *)obj &&
- (RVALUE *)obj < &page->start[page->total_slots] &&
- obj % sizeof(RVALUE) == 0)) {
- rb_bug("heap_page_add_freeobj: %p is not rvalue.", (void *)p);
+ if (RGENGC_CHECK_MODE && !is_pointer_to_heap(objspace, p)) {
+ rb_bug("heap_page_add_freeobj: %p is not rvalue.", p);
}
- asan_poison_object(obj);
-
gc_report(3, objspace, "heap_page_add_freeobj: add %p to freelist\n", (void *)obj);
}
static inline void
-heap_add_freepage(rb_heap_t *heap, struct heap_page *page)
+heap_add_freepage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
{
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
- GC_ASSERT(page->free_slots != 0);
if (page->freelist) {
page->free_next = heap->free_pages;
heap->free_pages = page;
}
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
}
#if GC_ENABLE_INCREMENTAL_MARK
static inline int
heap_add_poolpage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
{
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
if (page->freelist) {
page->free_next = heap->pooled_pages;
heap->pooled_pages = page;
objspace->rincgc.pooled_slots += page->free_slots;
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
-
return TRUE;
}
else {
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
-
return FALSE;
}
}
@@ -1760,19 +1471,21 @@ heap_add_poolpage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *pa
static void
heap_unlink_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
{
- list_del(&page->page_node);
+ if (page->prev) page->prev->next = page->next;
+ if (page->next) page->next->prev = page->prev;
+ if (heap->pages == page) heap->pages = page->next;
+ page->prev = NULL;
+ page->next = NULL;
heap->total_pages--;
heap->total_slots -= page->total_slots;
}
-static void rb_aligned_free(void *ptr);
-
static void
heap_page_free(rb_objspace_t *objspace, struct heap_page *page)
{
heap_allocated_pages--;
objspace->profile.total_freed_pages++;
- rb_aligned_free(GET_PAGE_BODY(page->start));
+ aligned_free(GET_PAGE_BODY(page->start));
free(page);
}
@@ -1781,7 +1494,7 @@ heap_pages_free_unused_pages(rb_objspace_t *objspace)
{
size_t i, j;
- if (!list_empty(&heap_tomb->pages)) {
+ if (heap_tomb->pages) {
for (i = j = 1; j < heap_allocated_pages; i++) {
struct heap_page *page = heap_pages_sorted[i];
@@ -1810,15 +1523,15 @@ heap_page_allocate(rb_objspace_t *objspace)
int limit = HEAP_PAGE_OBJ_LIMIT;
/* assign heap_page body (contains heap_page_header and RVALUEs) */
- page_body = (struct heap_page_body *)rb_aligned_malloc(HEAP_PAGE_ALIGN, HEAP_PAGE_SIZE);
+ page_body = (struct heap_page_body *)aligned_malloc(HEAP_PAGE_ALIGN, HEAP_PAGE_SIZE);
if (page_body == 0) {
rb_memerror();
}
/* assign heap_page entry */
- page = calloc1(sizeof(struct heap_page));
+ page = (struct heap_page *)calloc(1, sizeof(struct heap_page));
if (page == 0) {
- rb_aligned_free(page_body);
+ aligned_free(page_body);
rb_memerror();
}
@@ -1877,29 +1590,29 @@ heap_page_allocate(rb_objspace_t *objspace)
page_body->header.page = page;
for (p = start; p != end; p++) {
- gc_report(3, objspace, "assign_heap_page: %p is added to freelist\n", (void *)p);
+ gc_report(3, objspace, "assign_heap_page: %p is added to freelist\n", p);
heap_page_add_freeobj(objspace, page, (VALUE)p);
}
page->free_slots = limit;
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
return page;
}
static struct heap_page *
heap_page_resurrect(rb_objspace_t *objspace)
{
- struct heap_page *page = 0, *next;
+ struct heap_page *page = heap_tomb->pages;
- list_for_each_safe(&heap_tomb->pages, page, next, page_node) {
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
+ while (page) {
if (page->freelist != NULL) {
heap_unlink_page(objspace, heap_tomb, page);
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
return page;
}
+ page = page->next;
}
+
+
return NULL;
}
@@ -1918,7 +1631,7 @@ heap_page_create(rb_objspace_t *objspace)
method = "allocate";
}
if (0) fprintf(stderr, "heap_page_create: %s - %p, heap_allocated_pages: %d, heap_allocated_pages: %d, tomb->total_pages: %d\n",
- method, (void *)page, (int)heap_pages_sorted_length, (int)heap_allocated_pages, (int)heap_tomb->total_pages);
+ method, page, (int)heap_pages_sorted_length, (int)heap_allocated_pages, (int)heap_tomb->total_pages);
return page;
}
@@ -1926,7 +1639,9 @@ static void
heap_add_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
{
page->flags.in_tomb = (heap == heap_tomb);
- list_add(&heap->pages, &page->page_node);
+ page->next = heap->pages;
+ if (heap->pages) heap->pages->prev = page;
+ heap->pages = page;
heap->total_pages++;
heap->total_slots += page->total_slots;
}
@@ -1936,7 +1651,7 @@ heap_assign_page(rb_objspace_t *objspace, rb_heap_t *heap)
{
struct heap_page *page = heap_page_create(objspace);
heap_add_page(objspace, heap, page);
- heap_add_freepage(heap, page);
+ heap_add_freepage(objspace, heap, page);
}
static void
@@ -2026,16 +1741,20 @@ heap_prepare(rb_objspace_t *objspace, rb_heap_t *heap)
{
GC_ASSERT(heap->free_pages == NULL);
+#if GC_ENABLE_LAZY_SWEEP
if (is_lazy_sweeping(heap)) {
gc_sweep_continue(objspace, heap);
}
+#endif
+#if GC_ENABLE_INCREMENTAL_MARK
else if (is_incremental_marking(objspace)) {
gc_marks_continue(objspace, heap);
}
+#endif
if (heap->free_pages == NULL &&
(will_be_incremental_marking(objspace) || heap_increment(objspace, heap) == FALSE) &&
- gc_start(objspace, GPR_FLAG_NEWOBJ) == FALSE) {
+ gc_start(objspace, FALSE, FALSE, FALSE, GPR_FLAG_NEWOBJ) == FALSE) {
rb_memerror();
}
}
@@ -2054,12 +1773,9 @@ heap_get_freeobj_from_next_freepage(rb_objspace_t *objspace, rb_heap_t *heap)
heap->using_page = page;
GC_ASSERT(page->free_slots != 0);
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
p = page->freelist;
page->freelist = NULL;
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
page->free_slots = 0;
- asan_unpoison_object((VALUE)p, true);
return p;
}
@@ -2070,7 +1786,6 @@ heap_get_freeobj_head(rb_objspace_t *objspace, rb_heap_t *heap)
if (LIKELY(p != NULL)) {
heap->freelist = p->as.free.next;
}
- asan_unpoison_object((VALUE)p, true);
return (VALUE)p;
}
@@ -2081,7 +1796,6 @@ heap_get_freeobj(rb_objspace_t *objspace, rb_heap_t *heap)
while (1) {
if (LIKELY(p != NULL)) {
- asan_unpoison_object((VALUE)p, true);
heap->freelist = p->as.free.next;
return (VALUE)p;
}
@@ -2102,13 +1816,7 @@ rb_objspace_set_event_hook(const rb_event_flag_t event)
static void
gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data)
{
- const VALUE *pc = ec->cfp->pc;
- if (pc && VM_FRAME_RUBYFRAME_P(ec->cfp)) {
- /* increment PC because source line is calculated with PC-1 */
- ec->cfp->pc++;
- }
EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, data);
- ec->cfp->pc = pc;
}
#define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook)
@@ -2123,26 +1831,15 @@ gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb
static inline VALUE
newobj_init(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, rb_objspace_t *objspace, VALUE obj)
{
-#if !__has_feature(memory_sanitizer)
GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
-#endif
/* OBJSETUP */
- struct RVALUE buf = {
- .as = {
- .values = {
- .basic = {
- .flags = flags,
- .klass = klass,
- },
- .v1 = v1,
- .v2 = v2,
- .v3 = v3,
- },
- },
- };
- MEMCPY(RANY(obj), &buf, RVALUE, 1);
+ RBASIC(obj)->flags = flags;
+ RBASIC_SET_CLASS_RAW(obj, klass);
+ RANY(obj)->as.values.v1 = v1;
+ RANY(obj)->as.values.v2 = v2;
+ RANY(obj)->as.values.v3 = v3;
#if RGENGC_CHECK_MODE
GC_ASSERT(RVALUE_MARKED(obj) == FALSE);
@@ -2224,7 +1921,7 @@ newobj_slowpath(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, rb_objsp
}
if (ruby_gc_stressful) {
- if (!garbage_collect(objspace, GPR_FLAG_NEWOBJ)) {
+ if (!garbage_collect(objspace, FALSE, FALSE, FALSE, GPR_FLAG_NEWOBJ)) {
rb_memerror();
}
}
@@ -2257,15 +1954,13 @@ newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protect
rb_objspace_t *objspace = &rb_objspace;
VALUE obj;
- RB_DEBUG_COUNTER_INC(obj_newobj);
- (void)RB_DEBUG_COUNTER_INC_IF(obj_newobj_wb_unprotected, !wb_protected);
-
#if GC_DEBUG_STRESS_TO_CLASS
if (UNLIKELY(stress_to_class)) {
- long i, cnt = RARRAY_LEN(stress_to_class);
- for (i = 0; i < cnt; ++i) {
- if (klass == RARRAY_AREF(stress_to_class, i)) rb_memerror();
- }
+ long i, cnt = RARRAY_LEN(stress_to_class);
+ const VALUE *ptr = RARRAY_CONST_PTR(stress_to_class);
+ for (i = 0; i < cnt; ++i) {
+ if (klass == ptr[i]) rb_memerror();
+ }
}
#endif
if (!(during_gc ||
@@ -2275,8 +1970,6 @@ newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protect
return newobj_init(klass, flags, v1, v2, v3, wb_protected, objspace, obj);
}
else {
- RB_DEBUG_COUNTER_INC(obj_newobj_slowpath);
-
return wb_protected ?
newobj_slowpath_wb_protected(klass, flags, v1, v2, v3, objspace) :
newobj_slowpath_wb_unprotected(klass, flags, v1, v2, v3, objspace);
@@ -2324,57 +2017,11 @@ rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
return newobj_of(v0, flags, v1, v2, v3, TRUE);
}
-static VALUE
-rb_imemo_tmpbuf_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
-{
- VALUE flags = T_IMEMO | (imemo_tmpbuf << FL_USHIFT);
- return newobj_of(v0, flags, v1, v2, v3, FALSE);
-}
-
-static VALUE
-rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(void *buf, size_t cnt)
-{
- return rb_imemo_tmpbuf_new((VALUE)buf, 0, (VALUE)cnt, 0);
-}
-
-rb_imemo_tmpbuf_t *
-rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
-{
- return (rb_imemo_tmpbuf_t *)rb_imemo_tmpbuf_new((VALUE)buf, (VALUE)old_heap, (VALUE)cnt, 0);
-}
-
-static size_t
-imemo_memsize(VALUE obj)
+rb_imemo_alloc_t *
+rb_imemo_alloc_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
{
- size_t size = 0;
- switch (imemo_type(obj)) {
- case imemo_ment:
- size += sizeof(RANY(obj)->as.imemo.ment.def);
- break;
- case imemo_iseq:
- size += rb_iseq_memsize((rb_iseq_t *)obj);
- break;
- case imemo_env:
- size += RANY(obj)->as.imemo.env.env_size * sizeof(VALUE);
- break;
- case imemo_tmpbuf:
- size += RANY(obj)->as.imemo.alloc.cnt * sizeof(VALUE);
- break;
- case imemo_ast:
- size += rb_ast_memsize(&RANY(obj)->as.imemo.ast);
- break;
- case imemo_cref:
- case imemo_svar:
- case imemo_throw_data:
- case imemo_ifunc:
- case imemo_memo:
- case imemo_parser_strterm:
- break;
- default:
- /* unreachable */
- break;
- }
- return size;
+ VALUE flags = T_IMEMO | (imemo_alloc << FL_USHIFT);
+ return (rb_imemo_alloc_t *)newobj_of(v0, flags, v1, v2, v3, FALSE);
}
#if IMEMO_DEBUG
@@ -2382,7 +2029,7 @@ VALUE
rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line)
{
VALUE memo = rb_imemo_new(type, v1, v2, v3, v0);
- fprintf(stderr, "memo %p (type: %d) @ %s:%d\n", (void *)memo, imemo_type(memo), file, line);
+ fprintf(stderr, "memo %p (type: %d) @ %s:%d\n", memo, imemo_type(memo), file, line);
return memo;
}
#endif
@@ -2460,13 +2107,8 @@ is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
register struct heap_page *page;
register size_t hi, lo, mid;
- RB_DEBUG_COUNTER_INC(gc_isptr_trial);
-
if (p < heap_pages_lomem || p > heap_pages_himem) return FALSE;
- RB_DEBUG_COUNTER_INC(gc_isptr_range);
-
if ((VALUE)p % sizeof(RVALUE) != 0) return FALSE;
- RB_DEBUG_COUNTER_INC(gc_isptr_align);
/* check if p looks like a pointer using bsearch*/
lo = 0;
@@ -2476,14 +2118,7 @@ is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
page = heap_pages_sorted[mid];
if (page->start <= p) {
if (p < page->start + page->total_slots) {
- RB_DEBUG_COUNTER_INC(gc_isptr_maybe);
-
- if (page->flags.in_tomb) {
- return FALSE;
- }
- else {
- return TRUE;
- }
+ return TRUE;
}
lo = mid + 1;
}
@@ -2513,7 +2148,7 @@ static inline void
make_zombie(rb_objspace_t *objspace, VALUE obj, void (*dfree)(void *), void *data)
{
struct RZombie *zombie = RZOMBIE(obj);
- zombie->basic.flags = T_ZOMBIE | (zombie->basic.flags & FL_SEEN_OBJ_ID);
+ zombie->basic.flags = T_ZOMBIE;
zombie->dfree = dfree;
zombie->data = data;
zombie->next = heap_pages_deferred_final;
@@ -2527,23 +2162,6 @@ make_io_zombie(rb_objspace_t *objspace, VALUE obj)
make_zombie(objspace, obj, (void (*)(void*))rb_io_fptr_finalize, fptr);
}
-static void
-obj_free_object_id(rb_objspace_t *objspace, VALUE obj)
-{
- VALUE id;
-
- GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID));
- FL_UNSET(obj, FL_SEEN_OBJ_ID);
-
- if (st_delete(objspace->obj_to_id_tbl, (st_data_t *)&obj, &id)) {
- GC_ASSERT(id);
- st_delete(objspace->id_to_obj_tbl, (st_data_t *)&id, NULL);
- }
- else {
- rb_bug("Object ID seen, but not in mapping table: %s\n", obj_info(obj));
- }
-}
-
static int
obj_free(rb_objspace_t *objspace, VALUE obj)
{
@@ -2565,10 +2183,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
FL_UNSET(obj, FL_EXIVAR);
}
- if (FL_TEST(obj, FL_SEEN_OBJ_ID) && !FL_TEST(obj, FL_FINALIZE)) {
- obj_free_object_id(objspace, obj);
- }
-
#if USE_RGENGC
if (RVALUE_WB_UNPROTECTED(obj)) CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
@@ -2584,21 +2198,17 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
- if ((RANY(obj)->as.basic.flags & ROBJECT_EMBED) ||
- RANY(obj)->as.object.as.heap.ivptr == NULL) {
- RB_DEBUG_COUNTER_INC(obj_obj_embed);
- }
- else if (ROBJ_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_obj_transient);
- }
- else {
- xfree(RANY(obj)->as.object.as.heap.ivptr);
- RB_DEBUG_COUNTER_INC(obj_obj_ptr);
- }
- break;
+ if (!(RANY(obj)->as.basic.flags & ROBJECT_EMBED) &&
+ RANY(obj)->as.object.as.heap.ivptr) {
+ xfree(RANY(obj)->as.object.as.heap.ivptr);
+ RB_DEBUG_COUNTER_INC(obj_obj_ptr);
+ }
+ else {
+ RB_DEBUG_COUNTER_INC(obj_obj_embed);
+ }
+ break;
case T_MODULE:
case T_CLASS:
- mjit_remove_class_serial(RCLASS_SERIAL(obj));
rb_id_table_free(RCLASS_M_TBL(obj));
if (RCLASS_IV_TBL(obj)) {
st_free_table(RCLASS_IV_TBL(obj));
@@ -2623,78 +2233,21 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
if (RANY(obj)->as.klass.ptr)
xfree(RANY(obj)->as.klass.ptr);
RANY(obj)->as.klass.ptr = NULL;
-
- (void)RB_DEBUG_COUNTER_INC_IF(obj_module_ptr, BUILTIN_TYPE(obj) == T_MODULE);
- (void)RB_DEBUG_COUNTER_INC_IF(obj_class_ptr, BUILTIN_TYPE(obj) == T_CLASS);
break;
case T_STRING:
rb_str_free(obj);
break;
case T_ARRAY:
- rb_ary_free(obj);
+ rb_ary_free(obj);
break;
case T_HASH:
-#if USE_DEBUG_COUNTER
- switch RHASH_SIZE(obj) {
- case 0:
- RB_DEBUG_COUNTER_INC(obj_hash_empty);
- break;
- case 1:
- RB_DEBUG_COUNTER_INC(obj_hash_1);
- break;
- case 2:
- RB_DEBUG_COUNTER_INC(obj_hash_2);
- break;
- case 3:
- RB_DEBUG_COUNTER_INC(obj_hash_3);
- break;
- case 4:
- RB_DEBUG_COUNTER_INC(obj_hash_4);
- break;
- case 5:
- case 6:
- case 7:
- case 8:
- RB_DEBUG_COUNTER_INC(obj_hash_5_8);
- break;
- default:
- GC_ASSERT(RHASH_SIZE(obj) > 8);
- RB_DEBUG_COUNTER_INC(obj_hash_g8);
- }
-
- if (RHASH_AR_TABLE_P(obj)) {
- if (RHASH_AR_TABLE(obj) == NULL) {
- RB_DEBUG_COUNTER_INC(obj_hash_null);
- }
- else {
- RB_DEBUG_COUNTER_INC(obj_hash_ar);
- }
- }
- else {
- RB_DEBUG_COUNTER_INC(obj_hash_st);
- }
-#endif
- if (/* RHASH_AR_TABLE_P(obj) */ !FL_TEST_RAW(obj, RHASH_ST_TABLE_FLAG)) {
- struct ar_table_struct *tab = RHASH(obj)->as.ar;
-
- if (tab) {
- if (RHASH_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_hash_transient);
- }
- else {
- ruby_xfree(tab);
- }
- }
- }
- else {
- GC_ASSERT(RHASH_ST_TABLE_P(obj));
- st_free_table(RHASH(obj)->as.st);
- }
+ if (RANY(obj)->as.hash.ntbl) {
+ st_free_table(RANY(obj)->as.hash.ntbl);
+ }
break;
case T_REGEXP:
if (RANY(obj)->as.regexp.ptr) {
onig_free(RANY(obj)->as.regexp.ptr);
- RB_DEBUG_COUNTER_INC(obj_regexp_ptr);
}
break;
case T_DATA:
@@ -2718,59 +2271,34 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
if (dfree) {
if (dfree == RUBY_DEFAULT_FREE) {
xfree(data);
- RB_DEBUG_COUNTER_INC(obj_data_xfree);
}
else if (free_immediately) {
(*dfree)(data);
- RB_DEBUG_COUNTER_INC(obj_data_imm_free);
}
else {
make_zombie(objspace, obj, dfree, data);
- RB_DEBUG_COUNTER_INC(obj_data_zombie);
return 1;
}
}
- else {
- RB_DEBUG_COUNTER_INC(obj_data_empty);
- }
}
break;
case T_MATCH:
if (RANY(obj)->as.match.rmatch) {
struct rmatch *rm = RANY(obj)->as.match.rmatch;
-#if USE_DEBUG_COUNTER
- if (rm->regs.num_regs >= 8) {
- RB_DEBUG_COUNTER_INC(obj_match_ge8);
- }
- else if (rm->regs.num_regs >= 4) {
- RB_DEBUG_COUNTER_INC(obj_match_ge4);
- }
- else if (rm->regs.num_regs >= 1) {
- RB_DEBUG_COUNTER_INC(obj_match_under4);
- }
-#endif
onig_region_free(&rm->regs, 0);
if (rm->char_offset)
xfree(rm->char_offset);
xfree(rm);
-
- RB_DEBUG_COUNTER_INC(obj_match_ptr);
}
break;
case T_FILE:
if (RANY(obj)->as.file.fptr) {
make_io_zombie(objspace, obj);
- RB_DEBUG_COUNTER_INC(obj_file_ptr);
return 1;
}
break;
case T_RATIONAL:
- RB_DEBUG_COUNTER_INC(obj_rational);
- break;
case T_COMPLEX:
- RB_DEBUG_COUNTER_INC(obj_complex);
- break;
- case T_MOVED:
break;
case T_ICLASS:
/* Basically , T_ICLASS shares table with the module */
@@ -2788,22 +2316,15 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
rb_class_remove_from_super_subclasses(obj);
xfree(RANY(obj)->as.klass.ptr);
RANY(obj)->as.klass.ptr = NULL;
-
- RB_DEBUG_COUNTER_INC(obj_iclass_ptr);
break;
case T_FLOAT:
- RB_DEBUG_COUNTER_INC(obj_float);
break;
case T_BIGNUM:
if (!(RBASIC(obj)->flags & BIGNUM_EMBED_FLAG) && BIGNUM_DIGITS(obj)) {
xfree(BIGNUM_DIGITS(obj));
- RB_DEBUG_COUNTER_INC(obj_bignum_ptr);
}
- else {
- RB_DEBUG_COUNTER_INC(obj_bignum_embed);
- }
break;
case T_NODE:
@@ -2811,23 +2332,15 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break;
case T_STRUCT:
- if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) ||
- RANY(obj)->as.rstruct.as.heap.ptr == NULL) {
- RB_DEBUG_COUNTER_INC(obj_struct_embed);
- }
- else if (RSTRUCT_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_struct_transient);
- }
- else {
- xfree((void *)RANY(obj)->as.rstruct.as.heap.ptr);
- RB_DEBUG_COUNTER_INC(obj_struct_ptr);
+ if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) == 0 &&
+ RANY(obj)->as.rstruct.as.heap.ptr) {
+ xfree((void *)RANY(obj)->as.rstruct.as.heap.ptr);
}
break;
case T_SYMBOL:
{
rb_gc_free_dsymbol(obj);
- RB_DEBUG_COUNTER_INC(obj_symbol);
}
break;
@@ -2835,45 +2348,21 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
switch (imemo_type(obj)) {
case imemo_ment:
rb_free_method_entry(&RANY(obj)->as.imemo.ment);
- RB_DEBUG_COUNTER_INC(obj_imemo_ment);
break;
case imemo_iseq:
rb_iseq_free(&RANY(obj)->as.imemo.iseq);
- RB_DEBUG_COUNTER_INC(obj_imemo_iseq);
break;
case imemo_env:
GC_ASSERT(VM_ENV_ESCAPED_P(RANY(obj)->as.imemo.env.ep));
xfree((VALUE *)RANY(obj)->as.imemo.env.env);
- RB_DEBUG_COUNTER_INC(obj_imemo_env);
break;
- case imemo_tmpbuf:
+ case imemo_alloc:
xfree(RANY(obj)->as.imemo.alloc.ptr);
- RB_DEBUG_COUNTER_INC(obj_imemo_tmpbuf);
break;
case imemo_ast:
rb_ast_free(&RANY(obj)->as.imemo.ast);
- RB_DEBUG_COUNTER_INC(obj_imemo_ast);
break;
- case imemo_cref:
- RB_DEBUG_COUNTER_INC(obj_imemo_cref);
- break;
- case imemo_svar:
- RB_DEBUG_COUNTER_INC(obj_imemo_svar);
- break;
- case imemo_throw_data:
- RB_DEBUG_COUNTER_INC(obj_imemo_throw_data);
- break;
- case imemo_ifunc:
- RB_DEBUG_COUNTER_INC(obj_imemo_ifunc);
- break;
- case imemo_memo:
- RB_DEBUG_COUNTER_INC(obj_imemo_memo);
- break;
- case imemo_parser_strterm:
- RB_DEBUG_COUNTER_INC(obj_imemo_parser_strterm);
- break;
default:
- /* unreachable */
break;
}
return 0;
@@ -2884,7 +2373,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
}
if (FL_TEST(obj, FL_FINALIZE)) {
- make_zombie(objspace, obj, 0, 0);
+ make_zombie(objspace, obj, 0, 0);
return 1;
}
else {
@@ -2892,43 +2381,11 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
}
}
-
-#define OBJ_ID_INCREMENT (sizeof(RVALUE) / 2)
-#define OBJ_ID_INITIAL (OBJ_ID_INCREMENT * 2)
-
-static int
-object_id_cmp(st_data_t x, st_data_t y)
-{
- if (RB_TYPE_P(x, T_BIGNUM)) {
- return !rb_big_eql(x, y);
- } else {
- return x != y;
- }
-}
-
-static st_index_t
-object_id_hash(st_data_t n)
-{
- if (RB_TYPE_P(n, T_BIGNUM)) {
- return FIX2LONG(rb_big_hash(n));
- } else {
- return st_numhash(n);
- }
-}
-static const struct st_hash_type object_id_hash_type = {
- object_id_cmp,
- object_id_hash,
-};
-
void
Init_heap(void)
{
rb_objspace_t *objspace = &rb_objspace;
- objspace->next_object_id = INT2FIX(OBJ_ID_INITIAL);
- objspace->id_to_obj_tbl = st_init_table(&object_id_hash_type);
- objspace->obj_to_id_tbl = st_init_numtable();
-
#if RGENGC_ESTIMATE_OLDMALLOC
objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
#endif
@@ -2936,6 +2393,16 @@ Init_heap(void)
heap_add_pages(objspace, heap_eden, gc_params.heap_init_slots / HEAP_PAGE_OBJ_LIMIT);
init_mark_stack(&objspace->mark_stack);
+#ifdef USE_SIGALTSTACK
+ {
+ /* altstack of another threads are allocated in another place */
+ rb_thread_t *th = GET_THREAD();
+ void *tmp = th->altstack;
+ th->altstack = malloc(rb_sigaltstack_size());
+ free(tmp); /* free previously allocated area */
+ }
+#endif
+
objspace->profile.invoke_time = getrusage_time();
finalizer_table = st_init_numtable();
}
@@ -2950,21 +2417,19 @@ Init_gc_stress(void)
typedef int each_obj_callback(void *, void *, size_t, void *);
-static void objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data);
-static void objspace_reachable_objects_from_root(rb_objspace_t *, void (func)(const char *, VALUE, void *), void *);
-
struct each_obj_args {
- rb_objspace_t *objspace;
each_obj_callback *callback;
void *data;
};
-static void
-objspace_each_objects_without_setup(rb_objspace_t *objspace, each_obj_callback *callback, void *data)
+static VALUE
+objspace_each_objects(VALUE arg)
{
size_t i;
struct heap_page *page;
RVALUE *pstart = NULL, *pend;
+ rb_objspace_t *objspace = &rb_objspace;
+ struct each_obj_args *args = (struct each_obj_args *)arg;
i = 0;
while (i < heap_allocated_pages) {
@@ -2977,22 +2442,16 @@ objspace_each_objects_without_setup(rb_objspace_t *objspace, each_obj_callback *
pstart = page->start;
pend = pstart + page->total_slots;
- if ((*callback)(pstart, pend, sizeof(RVALUE), data)) {
+ if ((*args->callback)(pstart, pend, sizeof(RVALUE), args->data)) {
break;
}
}
-}
-static VALUE
-objspace_each_objects_protected(VALUE arg)
-{
- struct each_obj_args *args = (struct each_obj_args *)arg;
- objspace_each_objects_without_setup(args->objspace, args->callback, args->data);
return Qnil;
}
static VALUE
-incremental_enable(VALUE _)
+incremental_enable(void)
{
rb_objspace_t *objspace = &rb_objspace;
@@ -3039,30 +2498,32 @@ incremental_enable(VALUE _)
void
rb_objspace_each_objects(each_obj_callback *callback, void *data)
{
- objspace_each_objects(&rb_objspace, callback, data);
-}
-
-static void
-objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data)
-{
+ struct each_obj_args args;
+ rb_objspace_t *objspace = &rb_objspace;
int prev_dont_incremental = objspace->flags.dont_incremental;
gc_rest(objspace);
objspace->flags.dont_incremental = TRUE;
+ args.callback = callback;
+ args.data = data;
+
if (prev_dont_incremental) {
- objspace_each_objects_without_setup(objspace, callback, data);
+ objspace_each_objects((VALUE)&args);
}
else {
- struct each_obj_args args = {objspace, callback, data};
- rb_ensure(objspace_each_objects_protected, (VALUE)&args, incremental_enable, Qnil);
+ rb_ensure(objspace_each_objects, (VALUE)&args, incremental_enable, Qnil);
}
}
void
rb_objspace_each_objects_without_setup(each_obj_callback *callback, void *data)
{
- objspace_each_objects_without_setup(&rb_objspace, callback, data);
+ struct each_obj_args args;
+ args.callback = callback;
+ args.data = data;
+
+ objspace_each_objects((VALUE)&args);
}
struct os_each_struct {
@@ -3074,17 +2535,13 @@ static int
internal_object_p(VALUE obj)
{
RVALUE *p = (RVALUE *)obj;
- void *ptr = __asan_region_is_poisoned(p, SIZEOF_VALUE);
- asan_unpoison_object(obj, false);
- bool used_p = p->as.basic.flags;
- if (used_p) {
+ if (p->as.basic.flags) {
switch (BUILTIN_TYPE(p)) {
case T_NODE:
UNEXPECTED_NODE(internal_object_p);
break;
case T_NONE:
- case T_MOVED:
case T_IMEMO:
case T_ICLASS:
case T_ZOMBIE:
@@ -3100,9 +2557,6 @@ internal_object_p(VALUE obj)
return 0;
}
}
- if (ptr || ! used_p) {
- asan_poison_object(obj);
- }
return 1;
}
@@ -3153,9 +2607,9 @@ os_obj_of(VALUE of)
* <i>module</i>. Returns the number of objects found. Immediate
* objects (<code>Fixnum</code>s, <code>Symbol</code>s
* <code>true</code>, <code>false</code>, and <code>nil</code>) are
- * never returned. In the example below, #each_object returns both
- * the numbers we defined and several constants defined in the Math
- * module.
+ * never returned. In the example below, <code>each_object</code>
+ * returns both the numbers we defined and several constants defined in
+ * the <code>Math</code> module.
*
* If no block is given, an enumerator is returned instead.
*
@@ -3183,7 +2637,12 @@ os_each_obj(int argc, VALUE *argv, VALUE os)
{
VALUE of;
- of = (!rb_check_arity(argc, 0, 1) ? 0 : argv[0]);
+ if (argc == 0) {
+ of = 0;
+ }
+ else {
+ rb_scan_args(argc, argv, "01", &of);
+ }
RETURN_ENUMERATOR(os, 1, &of);
return os_obj_of(of);
}
@@ -3216,12 +2675,11 @@ rb_undefine_finalizer(VALUE obj)
static void
should_be_callable(VALUE block)
{
- if (!rb_obj_respond_to(block, idCall, TRUE)) {
+ if (!rb_obj_respond_to(block, rb_intern("call"), TRUE)) {
rb_raise(rb_eArgError, "wrong type argument %"PRIsVALUE" (should be callable)",
rb_obj_class(block));
}
}
-
static void
should_be_finalizable(VALUE obj)
{
@@ -3269,7 +2727,7 @@ define_final0(VALUE obj, VALUE block)
RBASIC(obj)->flags |= FL_FINALIZE;
- block = rb_ary_new3(2, INT2FIX(0), block);
+ block = rb_ary_new3(2, INT2FIX(rb_safe_level()), block);
OBJ_FREEZE(block);
if (st_lookup(finalizer_table, obj, &data)) {
@@ -3277,13 +2735,13 @@ define_final0(VALUE obj, VALUE block)
/* avoid duplicate block, table is usually small */
{
+ const VALUE *ptr = RARRAY_CONST_PTR(table);
long len = RARRAY_LEN(table);
long i;
- for (i = 0; i < len; i++) {
- VALUE recv = RARRAY_AREF(table, i);
- if (rb_funcall(recv, idEq, 1, block)) {
- return recv;
+ for (i = 0; i < len; i++, ptr++) {
+ if (rb_funcall(*ptr, idEq, 1, block)) {
+ return *ptr;
}
}
}
@@ -3325,6 +2783,10 @@ static VALUE
run_single_final(VALUE final, VALUE objid)
{
const VALUE cmd = RARRAY_AREF(final, 1);
+ const int level = OBJ_TAINTED(cmd) ?
+ RUBY_SAFE_LEVEL_MAX : FIX2INT(RARRAY_AREF(final, 0));
+
+ rb_set_safe_level_force(level);
return rb_check_funcall(cmd, idCall, 1, &objid);
}
@@ -3338,14 +2800,17 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
VALUE objid;
rb_control_frame_t *cfp;
long finished;
+ int safe;
} saved;
rb_execution_context_t * volatile ec = GET_EC();
#define RESTORE_FINALIZER() (\
ec->cfp = saved.cfp, \
+ rb_set_safe_level_force(saved.safe), \
rb_set_errinfo(saved.errinfo))
+ saved.safe = rb_safe_level();
saved.errinfo = rb_errinfo();
- saved.objid = rb_obj_id(obj);
+ saved.objid = nonspecial_obj_id(obj);
saved.cfp = ec->cfp;
saved.finished = 0;
@@ -3382,21 +2847,13 @@ static void
finalize_list(rb_objspace_t *objspace, VALUE zombie)
{
while (zombie) {
- VALUE next_zombie;
- struct heap_page *page;
- asan_unpoison_object(zombie, false);
- next_zombie = RZOMBIE(zombie)->next;
- page = GET_HEAP_PAGE(zombie);
+ VALUE next_zombie = RZOMBIE(zombie)->next;
+ struct heap_page *page = GET_HEAP_PAGE(zombie);
run_final(objspace, zombie);
- GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE);
- if (FL_TEST(zombie, FL_SEEN_OBJ_ID)) {
- obj_free_object_id(objspace, zombie);
- }
-
RZOMBIE(zombie)->basic.flags = 0;
- if (LIKELY(heap_pages_final_slots)) heap_pages_final_slots--;
+ heap_pages_final_slots--;
page->final_slots--;
page->free_slots++;
heap_page_add_freeobj(objspace, GET_HEAP_PAGE(zombie), zombie);
@@ -3426,6 +2883,13 @@ gc_finalize_deferred(void *dmy)
ATOMIC_SET(finalizing, 0);
}
+/* TODO: to keep compatibility, maybe unused. */
+void
+rb_gc_finalize_deferred(void)
+{
+ gc_finalize_deferred(0);
+}
+
static void
gc_finalize_deferred_register(rb_objspace_t *objspace)
{
@@ -3453,14 +2917,20 @@ force_chain_object(st_data_t key, st_data_t val, st_data_t arg)
}
void
+rb_gc_call_finalizer_at_exit(void)
+{
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(Qnil);
+#endif
+ rb_objspace_call_finalizer(&rb_objspace);
+}
+
+static void
rb_objspace_call_finalizer(rb_objspace_t *objspace)
{
RVALUE *p, *pend;
size_t i;
-#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
-#endif
gc_rest(objspace);
if (ATOMIC_EXCHANGE(finalizing, 1)) return;
@@ -3497,8 +2967,6 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
for (i = 0; i < heap_allocated_pages; i++) {
p = heap_pages_sorted[i]->start; pend = p + heap_pages_sorted[i]->total_slots;
while (p < pend) {
- void *poisoned = asan_poisoned_object_p((VALUE)p);
- asan_unpoison_object((VALUE)p, false);
switch (BUILTIN_TYPE(p)) {
case T_DATA:
if (!DATA_PTR(p) || !RANY(p)->as.data.dfree) break;
@@ -3509,7 +2977,7 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
if (RTYPEDDATA_P(p)) {
RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
}
- if (RANY(p)->as.data.dfree == RUBY_DEFAULT_FREE) {
+ if (RANY(p)->as.data.dfree == (RUBY_DATA_FUNC)-1) {
xfree(DATA_PTR(p));
}
else if (RANY(p)->as.data.dfree) {
@@ -3522,10 +2990,6 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
}
break;
}
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(p) == T_NONE);
- asan_poison_object((VALUE)p);
- }
p++;
}
}
@@ -3623,18 +3087,6 @@ rb_objspace_garbage_object_p(VALUE obj)
return is_garbage_object(objspace, obj);
}
-static VALUE
-id2ref_obj_tbl(rb_objspace_t *objspace, VALUE objid)
-{
- VALUE orig;
- if (st_lookup(objspace->id_to_obj_tbl, objid, &orig)) {
- return orig;
- }
- else {
- return Qundef;
- }
-}
-
/*
* call-seq:
* ObjectSpace._id2ref(object_id) -> an_object
@@ -3649,7 +3101,7 @@ id2ref_obj_tbl(rb_objspace_t *objspace, VALUE objid)
*/
static VALUE
-id2ref(VALUE objid)
+id2ref(VALUE obj, VALUE objid)
{
#if SIZEOF_LONG == SIZEOF_VOIDP
#define NUM2PTR(x) NUM2ULONG(x)
@@ -3658,101 +3110,35 @@ id2ref(VALUE objid)
#endif
rb_objspace_t *objspace = &rb_objspace;
VALUE ptr;
- VALUE orig;
void *p0;
- objid = rb_to_int(objid);
- if (FIXNUM_P(objid) || rb_big_size(objid) <= SIZEOF_VOIDP) {
- ptr = NUM2PTR(objid);
- if (ptr == Qtrue) return Qtrue;
- if (ptr == Qfalse) return Qfalse;
- if (ptr == Qnil) return Qnil;
- if (FIXNUM_P(ptr)) return (VALUE)ptr;
- if (FLONUM_P(ptr)) return (VALUE)ptr;
-
- ptr = obj_id_to_ref(objid);
- if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
- ID symid = ptr / sizeof(RVALUE);
- p0 = (void *)ptr;
- if (rb_id2str(symid) == 0)
- rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
- return ID2SYM(symid);
- }
- }
+ ptr = NUM2PTR(objid);
+ p0 = (void *)ptr;
- if ((orig = id2ref_obj_tbl(objspace, objid)) != Qundef &&
- is_live_object(objspace, orig)) {
- return orig;
- }
+ if (ptr == Qtrue) return Qtrue;
+ if (ptr == Qfalse) return Qfalse;
+ if (ptr == Qnil) return Qnil;
+ if (FIXNUM_P(ptr)) return (VALUE)ptr;
+ if (FLONUM_P(ptr)) return (VALUE)ptr;
+ ptr = obj_id_to_ref(objid);
- if (rb_int_ge(objid, objspace->next_object_id)) {
- rb_raise(rb_eRangeError, "%+"PRIsVALUE" is not id value", rb_int2str(objid, 10));
- } else {
- rb_raise(rb_eRangeError, "%+"PRIsVALUE" is recycled object", rb_int2str(objid, 10));
+ if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
+ ID symid = ptr / sizeof(RVALUE);
+ if (rb_id2str(symid) == 0)
+ rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
+ return ID2SYM(symid);
}
-}
-
-static VALUE
-os_id2ref(VALUE os, VALUE objid)
-{
- return id2ref(objid);
-}
-static VALUE
-rb_find_object_id(VALUE obj, VALUE (*get_heap_object_id)(VALUE))
-{
- if (STATIC_SYM_P(obj)) {
- return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
+ if (!is_id_value(objspace, ptr)) {
+ rb_raise(rb_eRangeError, "%p is not id value", p0);
}
- else if (FLONUM_P(obj)) {
-#if SIZEOF_LONG == SIZEOF_VOIDP
- return LONG2NUM((SIGNED_VALUE)obj);
-#else
- return LL2NUM((SIGNED_VALUE)obj);
-#endif
+ if (!is_live_object(objspace, ptr)) {
+ rb_raise(rb_eRangeError, "%p is recycled object", p0);
}
- else if (SPECIAL_CONST_P(obj)) {
- return LONG2NUM((SIGNED_VALUE)obj);
+ if (RBASIC(ptr)->klass == 0) {
+ rb_raise(rb_eRangeError, "%p is internal object", p0);
}
-
- return get_heap_object_id(obj);
-}
-
-static VALUE
-cached_object_id(VALUE obj)
-{
- VALUE id;
- rb_objspace_t *objspace = &rb_objspace;
-
- if (st_lookup(objspace->obj_to_id_tbl, (st_data_t)obj, &id)) {
- GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID));
- return id;
- }
- else {
- GC_ASSERT(!FL_TEST(obj, FL_SEEN_OBJ_ID));
-
- id = objspace->next_object_id;
- objspace->next_object_id = rb_int_plus(id, INT2FIX(OBJ_ID_INCREMENT));
-
- st_insert(objspace->obj_to_id_tbl, (st_data_t)obj, (st_data_t)id);
- st_insert(objspace->id_to_obj_tbl, (st_data_t)id, (st_data_t)obj);
- FL_SET(obj, FL_SEEN_OBJ_ID);
-
- return id;
- }
-}
-
-static VALUE
-nonspecial_obj_id_(VALUE obj)
-{
- return nonspecial_obj_id(obj);
-}
-
-
-VALUE
-rb_memory_id(VALUE obj)
-{
- return rb_find_object_id(obj, nonspecial_obj_id_);
+ return (VALUE)ptr;
}
/*
@@ -3771,8 +3157,6 @@ rb_memory_id(VALUE obj)
* Note: that some objects of builtin classes are reused for optimization.
* This is the case for immediate values and frozen string literals.
*
- * BasicObject implements +__id__+, Kernel implements +object_id+.
- *
* Immediate values are not passed by reference but are passed by value:
* +nil+, +true+, +false+, Fixnums, Symbols, and some Floats.
*
@@ -3813,8 +3197,20 @@ rb_obj_id(VALUE obj)
* 24 if 32-bit, double is 8-byte aligned
* 40 if 64-bit
*/
-
- return rb_find_object_id(obj, cached_object_id);
+ if (STATIC_SYM_P(obj)) {
+ return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
+ }
+ else if (FLONUM_P(obj)) {
+#if SIZEOF_LONG == SIZEOF_VOIDP
+ return LONG2NUM((SIGNED_VALUE)obj);
+#else
+ return LL2NUM((SIGNED_VALUE)obj);
+#endif
+ }
+ else if (SPECIAL_CONST_P(obj)) {
+ return LONG2NUM((SIGNED_VALUE)obj);
+ }
+ return nonspecial_obj_id(obj);
}
#include "regint.h"
@@ -3841,10 +3237,10 @@ obj_memsize_of(VALUE obj, int use_all_types)
break;
case T_MODULE:
case T_CLASS:
+ if (RCLASS_M_TBL(obj)) {
+ size += rb_id_table_memsize(RCLASS_M_TBL(obj));
+ }
if (RCLASS_EXT(obj)) {
- if (RCLASS_M_TBL(obj)) {
- size += rb_id_table_memsize(RCLASS_M_TBL(obj));
- }
if (RCLASS_IV_TBL(obj)) {
size += st_memsize(RCLASS_IV_TBL(obj));
}
@@ -3874,16 +3270,9 @@ obj_memsize_of(VALUE obj, int use_all_types)
size += rb_ary_memsize(obj);
break;
case T_HASH:
- if (RHASH_AR_TABLE_P(obj)) {
- if (RHASH_AR_TABLE(obj) != NULL) {
- size_t rb_hash_ar_table_size();
- size += rb_hash_ar_table_size();
- }
+ if (RHASH(obj)->ntbl) {
+ size += st_memsize(RHASH(obj)->ntbl);
}
- else {
- VM_ASSERT(RHASH_ST_TABLE(obj) != NULL);
- size += st_memsize(RHASH_ST_TABLE(obj));
- }
break;
case T_REGEXP:
if (RREGEXP_PTR(obj)) {
@@ -3908,9 +3297,10 @@ obj_memsize_of(VALUE obj, int use_all_types)
break;
case T_RATIONAL:
case T_COMPLEX:
- break;
case T_IMEMO:
- size += imemo_memsize(obj);
+ if (imemo_type_p(obj, imemo_alloc)) {
+ size += RANY(obj)->as.imemo.alloc.cnt * sizeof(VALUE);
+ }
break;
case T_FLOAT:
@@ -3935,7 +3325,6 @@ obj_memsize_of(VALUE obj, int use_all_types)
break;
case T_ZOMBIE:
- case T_MOVED:
break;
default:
@@ -3961,43 +3350,6 @@ set_zero(st_data_t key, st_data_t val, st_data_t arg)
return ST_CONTINUE;
}
-static VALUE
-type_sym(size_t type)
-{
- switch (type) {
-#define COUNT_TYPE(t) case (t): return ID2SYM(rb_intern(#t)); break;
- COUNT_TYPE(T_NONE);
- COUNT_TYPE(T_OBJECT);
- COUNT_TYPE(T_CLASS);
- COUNT_TYPE(T_MODULE);
- COUNT_TYPE(T_FLOAT);
- COUNT_TYPE(T_STRING);
- COUNT_TYPE(T_REGEXP);
- COUNT_TYPE(T_ARRAY);
- COUNT_TYPE(T_HASH);
- COUNT_TYPE(T_STRUCT);
- COUNT_TYPE(T_BIGNUM);
- COUNT_TYPE(T_FILE);
- COUNT_TYPE(T_DATA);
- COUNT_TYPE(T_MATCH);
- COUNT_TYPE(T_COMPLEX);
- COUNT_TYPE(T_RATIONAL);
- COUNT_TYPE(T_NIL);
- COUNT_TYPE(T_TRUE);
- COUNT_TYPE(T_FALSE);
- COUNT_TYPE(T_SYMBOL);
- COUNT_TYPE(T_FIXNUM);
- COUNT_TYPE(T_IMEMO);
- COUNT_TYPE(T_UNDEF);
- COUNT_TYPE(T_NODE);
- COUNT_TYPE(T_ICLASS);
- COUNT_TYPE(T_ZOMBIE);
- COUNT_TYPE(T_MOVED);
-#undef COUNT_TYPE
- default: return INT2NUM(type); break;
- }
-}
-
/*
* call-seq:
* ObjectSpace.count_objects([result_hash]) -> hash
@@ -4041,10 +3393,9 @@ count_objects(int argc, VALUE *argv, VALUE os)
size_t freed = 0;
size_t total = 0;
size_t i;
- VALUE hash = Qnil;
+ VALUE hash;
- if (rb_check_arity(argc, 0, 1) == 1) {
- hash = argv[0];
+ if (rb_scan_args(argc, argv, "01", &hash) == 1) {
if (!RB_TYPE_P(hash, T_HASH))
rb_raise(rb_eTypeError, "non-hash given");
}
@@ -4059,18 +3410,12 @@ count_objects(int argc, VALUE *argv, VALUE os)
p = page->start; pend = p + page->total_slots;
for (;p < pend; p++) {
- void *poisoned = asan_poisoned_object_p((VALUE)p);
- asan_unpoison_object((VALUE)p, false);
if (p->as.basic.flags) {
counts[BUILTIN_TYPE(p)]++;
}
else {
freed++;
}
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE((VALUE)p) == T_NONE);
- asan_poison_object((VALUE)p);
- }
}
total += page->total_slots;
}
@@ -4079,13 +3424,43 @@ count_objects(int argc, VALUE *argv, VALUE os)
hash = rb_hash_new();
}
else if (!RHASH_EMPTY_P(hash)) {
- rb_hash_stlike_foreach(hash, set_zero, hash);
+ st_foreach(RHASH_TBL_RAW(hash), set_zero, hash);
}
rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total));
rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed));
for (i = 0; i <= T_MASK; i++) {
- VALUE type = type_sym(i);
+ VALUE type;
+ switch (i) {
+#define COUNT_TYPE(t) case (t): type = ID2SYM(rb_intern(#t)); break;
+ COUNT_TYPE(T_NONE);
+ COUNT_TYPE(T_OBJECT);
+ COUNT_TYPE(T_CLASS);
+ COUNT_TYPE(T_MODULE);
+ COUNT_TYPE(T_FLOAT);
+ COUNT_TYPE(T_STRING);
+ COUNT_TYPE(T_REGEXP);
+ COUNT_TYPE(T_ARRAY);
+ COUNT_TYPE(T_HASH);
+ COUNT_TYPE(T_STRUCT);
+ COUNT_TYPE(T_BIGNUM);
+ COUNT_TYPE(T_FILE);
+ COUNT_TYPE(T_DATA);
+ COUNT_TYPE(T_MATCH);
+ COUNT_TYPE(T_COMPLEX);
+ COUNT_TYPE(T_RATIONAL);
+ COUNT_TYPE(T_NIL);
+ COUNT_TYPE(T_TRUE);
+ COUNT_TYPE(T_FALSE);
+ COUNT_TYPE(T_SYMBOL);
+ COUNT_TYPE(T_FIXNUM);
+ COUNT_TYPE(T_IMEMO);
+ COUNT_TYPE(T_UNDEF);
+ COUNT_TYPE(T_ICLASS);
+ COUNT_TYPE(T_ZOMBIE);
+#undef COUNT_TYPE
+ default: type = INT2NUM(i); break;
+ }
if (counts[i])
rb_hash_aset(hash, type, SIZET2NUM(counts[i]));
}
@@ -4154,7 +3529,6 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
if (bitset) {
p = offset + i * BITS_BITLENGTH;
do {
- asan_unpoison_object((VALUE)p, false);
if (bitset & 1) {
switch (BUILTIN_TYPE(p)) {
default: { /* majority case */
@@ -4162,7 +3536,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
#if USE_RGENGC && RGENGC_CHECK_MODE
if (!is_full_marking(objspace)) {
if (RVALUE_OLD_P((VALUE)p)) rb_bug("page_sweep: %p - old while minor GC.", (void *)p);
- if (rgengc_remembered_sweep(objspace, (VALUE)p)) rb_bug("page_sweep: %p - remembered.", (void *)p);
+ if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("page_sweep: %p - remembered.", (void *)p);
}
#endif
if (obj_free(objspace, (VALUE)p)) {
@@ -4173,7 +3547,6 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
heap_page_add_freeobj(objspace, sweep_page, (VALUE)p);
gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info((VALUE)p));
freed_slots++;
- asan_poison_object((VALUE)p);
}
break;
}
@@ -4266,22 +3639,18 @@ gc_mode_transition(rb_objspace_t *objspace, enum gc_mode mode)
static void
gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap)
{
- heap->sweeping_page = list_top(&heap->pages, struct heap_page, page_node);
+ heap->sweep_pages = heap->pages;
heap->free_pages = NULL;
#if GC_ENABLE_INCREMENTAL_MARK
heap->pooled_pages = NULL;
objspace->rincgc.pooled_slots = 0;
#endif
if (heap->using_page) {
- struct heap_page *page = heap->using_page;
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
-
- RVALUE **p = &page->freelist;
+ RVALUE **p = &heap->using_page->freelist;
while (*p) {
p = &(*p)->as.free.next;
}
*p = heap->freelist;
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
heap->using_page = NULL;
}
heap->freelist = NULL;
@@ -4314,14 +3683,14 @@ gc_sweep_finish(rb_objspace_t *objspace)
gc_mode_transition(objspace, gc_mode_none);
#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
+ gc_verify_internal_consistency(Qnil);
#endif
}
static int
gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap)
{
- struct heap_page *sweep_page = heap->sweeping_page;
+ struct heap_page *sweep_page = heap->sweep_pages;
int unlink_limit = 3;
#if GC_ENABLE_INCREMENTAL_MARK
int need_pool = will_be_incremental_marking(objspace) ? TRUE : FALSE;
@@ -4337,9 +3706,9 @@ gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap)
gc_prof_sweep_timer_start(objspace);
#endif
- do {
+ while (sweep_page) {
+ struct heap_page *next_sweep_page = heap->sweep_pages = sweep_page->next;
int free_slots = gc_page_sweep(objspace, heap, sweep_page);
- heap->sweeping_page = list_next(&heap->pages, sweep_page, page_node);
if (sweep_page->final_slots + free_slots == sweep_page->total_slots &&
heap_pages_freeable_pages > 0 &&
@@ -4358,20 +3727,22 @@ gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap)
}
}
else {
- heap_add_freepage(heap, sweep_page);
+ heap_add_freepage(objspace, heap, sweep_page);
break;
}
#else
- heap_add_freepage(heap, sweep_page);
+ heap_add_freepage(objspace, heap, sweep_page);
break;
#endif
}
else {
sweep_page->free_next = NULL;
}
- } while ((sweep_page = heap->sweeping_page));
- if (!heap->sweeping_page) {
+ sweep_page = next_sweep_page;
+ }
+
+ if (heap->sweep_pages == NULL) {
gc_sweep_finish(objspace);
}
@@ -4392,11 +3763,11 @@ gc_sweep_rest(rb_objspace_t *objspace)
}
}
+#if GC_ENABLE_LAZY_SWEEP
static void
gc_sweep_continue(rb_objspace_t *objspace, rb_heap_t *heap)
{
GC_ASSERT(dont_gc == FALSE);
- if (!GC_ENABLE_LAZY_SWEEP) return;
gc_enter(objspace, "sweep_continue");
#if USE_RGENGC
@@ -4407,6 +3778,7 @@ gc_sweep_continue(rb_objspace_t *objspace, rb_heap_t *heap)
gc_sweep_step(objspace, heap);
gc_exit(objspace, "sweep_continue");
}
+#endif
static void
gc_sweep(rb_objspace_t *objspace)
@@ -4426,12 +3798,13 @@ gc_sweep(rb_objspace_t *objspace)
#endif
}
else {
- struct heap_page *page = NULL;
+ struct heap_page *page;
gc_sweep_start(objspace);
-
- list_for_each(&heap_eden->pages, page, page_node) {
- page->flags.before_sweep = TRUE;
- }
+ page = heap_eden->sweep_pages;
+ while (page) {
+ page->flags.before_sweep = TRUE;
+ page = page->next;
+ }
gc_sweep_step(objspace, heap_eden);
}
@@ -4611,17 +3984,16 @@ init_mark_stack(mark_stack_t *stack)
/* Marking */
+#ifdef __ia64
+#define SET_STACK_END (SET_MACHINE_STACK_END(&ec->machine.stack_end), ec->machine.register_stack_end = rb_ia64_bsp())
+#else
#define SET_STACK_END SET_MACHINE_STACK_END(&ec->machine.stack_end)
+#endif
#define STACK_START (ec->machine.stack_start)
#define STACK_END (ec->machine.stack_end)
#define STACK_LEVEL_MAX (ec->machine.stack_maxsize/sizeof(VALUE))
-#ifdef __EMSCRIPTEN__
-#undef STACK_GROW_DIRECTION
-#define STACK_GROW_DIRECTION 1
-#endif
-
#if STACK_GROW_DIRECTION < 0
# define STACK_LENGTH (size_t)(STACK_START - STACK_END)
#elif STACK_GROW_DIRECTION > 0
@@ -4664,20 +4036,24 @@ ruby_stack_length(VALUE **p)
static int
stack_check(rb_execution_context_t *ec, int water_mark)
{
+ int ret;
SET_STACK_END;
-
- size_t length = STACK_LENGTH;
- size_t maximum_length = STACK_LEVEL_MAX - water_mark;
-
- return length > maximum_length;
+ ret = STACK_LENGTH > STACK_LEVEL_MAX - water_mark;
+#ifdef __ia64
+ if (!ret) {
+ ret = (VALUE*)rb_ia64_bsp() - ec->machine.register_stack_start >
+ ec->machine.register_stack_maxsize/sizeof(VALUE) - water_mark;
+ }
+#endif
+ return ret;
}
#else
#define stack_check(ec, water_mark) FALSE
#endif
-#define STACKFRAME_FOR_CALL_CFUNC 2048
+#define STACKFRAME_FOR_CALL_CFUNC 838
-MJIT_FUNC_EXPORTED int
+int
rb_ec_stack_check(rb_execution_context_t *ec)
{
return stack_check(ec, STACKFRAME_FOR_CALL_CFUNC);
@@ -4689,14 +4065,14 @@ ruby_stack_check(void)
return stack_check(GET_EC(), STACKFRAME_FOR_CALL_CFUNC);
}
-ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(static void mark_locations_array(rb_objspace_t *objspace, register const VALUE *x, register long n));
+ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
static void
mark_locations_array(rb_objspace_t *objspace, register const VALUE *x, register long n)
{
VALUE v;
while (n--) {
v = *x;
- gc_mark_maybe(objspace, v);
+ gc_mark_maybe(objspace, v);
x++;
}
}
@@ -4723,76 +4099,37 @@ gc_mark_values(rb_objspace_t *objspace, long n, const VALUE *values)
long i;
for (i=0; i<n; i++) {
- gc_mark(objspace, values[i]);
+ gc_mark(objspace, values[i]);
}
}
void
rb_gc_mark_values(long n, const VALUE *values)
{
- long i;
rb_objspace_t *objspace = &rb_objspace;
-
- for (i=0; i<n; i++) {
- gc_mark_and_pin(objspace, values[i]);
- }
-}
-
-static void
-gc_mark_and_pin_stack_values(rb_objspace_t *objspace, long n, const VALUE *values)
-{
- long i;
-
- for (i=0; i<n; i++) {
- /* skip MOVED objects that are on the stack */
- if (is_markable_object(objspace, values[i]) && T_MOVED != BUILTIN_TYPE(values[i])) {
- gc_mark_and_pin(objspace, values[i]);
- }
- }
-}
-
-void
-rb_gc_mark_vm_stack_values(long n, const VALUE *values)
-{
- rb_objspace_t *objspace = &rb_objspace;
- gc_mark_and_pin_stack_values(objspace, n, values);
+ gc_mark_values(objspace, n, values);
}
static int
-mark_value(st_data_t key, st_data_t value, st_data_t data)
+mark_entry(st_data_t key, st_data_t value, st_data_t data)
{
rb_objspace_t *objspace = (rb_objspace_t *)data;
gc_mark(objspace, (VALUE)value);
return ST_CONTINUE;
}
-static int
-mark_value_pin(st_data_t key, st_data_t value, st_data_t data)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
- gc_mark_and_pin(objspace, (VALUE)value);
- return ST_CONTINUE;
-}
-
-static void
-mark_tbl_no_pin(rb_objspace_t *objspace, st_table *tbl)
-{
- if (!tbl || tbl->num_entries == 0) return;
- st_foreach(tbl, mark_value, (st_data_t)objspace);
-}
-
static void
mark_tbl(rb_objspace_t *objspace, st_table *tbl)
{
if (!tbl || tbl->num_entries == 0) return;
- st_foreach(tbl, mark_value_pin, (st_data_t)objspace);
+ st_foreach(tbl, mark_entry, (st_data_t)objspace);
}
static int
mark_key(st_data_t key, st_data_t value, st_data_t data)
{
rb_objspace_t *objspace = (rb_objspace_t *)data;
- gc_mark_and_pin(objspace, (VALUE)key);
+ gc_mark(objspace, (VALUE)key);
return ST_CONTINUE;
}
@@ -4803,13 +4140,6 @@ mark_set(rb_objspace_t *objspace, st_table *tbl)
st_foreach(tbl, mark_key, (st_data_t)objspace);
}
-static void
-mark_finalizer_tbl(rb_objspace_t *objspace, st_table *tbl)
-{
- if (!tbl) return;
- st_foreach(tbl, mark_value, (st_data_t)objspace);
-}
-
void
rb_mark_set(st_table *tbl)
{
@@ -4826,58 +4156,17 @@ mark_keyvalue(st_data_t key, st_data_t value, st_data_t data)
return ST_CONTINUE;
}
-static int
-pin_key_pin_value(st_data_t key, st_data_t value, st_data_t data)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
-
- gc_mark_and_pin(objspace, (VALUE)key);
- gc_mark_and_pin(objspace, (VALUE)value);
- return ST_CONTINUE;
-}
-
-static int
-pin_key_mark_value(st_data_t key, st_data_t value, st_data_t data)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
-
- gc_mark_and_pin(objspace, (VALUE)key);
- gc_mark(objspace, (VALUE)value);
- return ST_CONTINUE;
-}
-
-static void
-mark_hash(rb_objspace_t *objspace, VALUE hash)
-{
- if (rb_hash_compare_by_id_p(hash)) {
- rb_hash_stlike_foreach(hash, pin_key_mark_value, (st_data_t)objspace);
- }
- else {
- rb_hash_stlike_foreach(hash, mark_keyvalue, (st_data_t)objspace);
- }
-
- if (RHASH_AR_TABLE_P(hash)) {
- if (objspace->mark_func_data == NULL && RHASH_TRANSIENT_P(hash)) {
- rb_transient_heap_mark(hash, RHASH_AR_TABLE(hash));
- }
- }
- else {
- VM_ASSERT(!RHASH_TRANSIENT_P(hash));
- }
- gc_mark(objspace, RHASH(hash)->ifnone);
-}
-
static void
-mark_st(rb_objspace_t *objspace, st_table *tbl)
+mark_hash(rb_objspace_t *objspace, st_table *tbl)
{
if (!tbl) return;
- st_foreach(tbl, pin_key_pin_value, (st_data_t)objspace);
+ st_foreach(tbl, mark_keyvalue, (st_data_t)objspace);
}
void
rb_mark_hash(st_table *tbl)
{
- mark_st(&rb_objspace, tbl);
+ mark_hash(&rb_objspace, tbl);
}
static void
@@ -4899,8 +4188,7 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)
gc_mark(objspace, def->body.attr.location);
break;
case VM_METHOD_TYPE_BMETHOD:
- gc_mark(objspace, def->body.bmethod.proc);
- if (def->body.bmethod.hooks) rb_hook_list_mark(def->body.bmethod.hooks);
+ gc_mark(objspace, def->body.proc);
break;
case VM_METHOD_TYPE_ALIAS:
gc_mark(objspace, (VALUE)def->body.alias.original_me);
@@ -4978,7 +4266,6 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec
VALUE *stack_start, *stack_end;
FLUSH_REGISTER_WINDOWS;
- memset(&save_regs_gc_mark, 0, sizeof(save_regs_gc_mark));
/* This assumes that all registers are saved into the jmp_buf (and stack) */
rb_setjmp(save_regs_gc_mark.j);
@@ -5009,7 +4296,11 @@ mark_stack_locations(rb_objspace_t *objspace, const rb_execution_context_t *ec,
{
gc_mark_locations(objspace, stack_start, stack_end);
-
+#ifdef __ia64
+ gc_mark_locations(objspace,
+ ec->machine.register_stack_start,
+ ec->machine.register_stack_end);
+#endif
#if defined(__mc68000__)
gc_mark_locations(objspace,
(VALUE*)((char*)stack_start + 2),
@@ -5023,36 +4314,15 @@ rb_mark_tbl(st_table *tbl)
mark_tbl(&rb_objspace, tbl);
}
-void
-rb_mark_tbl_no_pin(st_table *tbl)
-{
- mark_tbl_no_pin(&rb_objspace, tbl);
-}
-
static void
gc_mark_maybe(rb_objspace_t *objspace, VALUE obj)
{
(void)VALGRIND_MAKE_MEM_DEFINED(&obj, sizeof(obj));
-
if (is_pointer_to_heap(objspace, (void *)obj)) {
- void *ptr = __asan_region_is_poisoned((void *)obj, SIZEOF_VALUE);
- asan_unpoison_object(obj, false);
-
- /* Garbage can live on the stack, so do not mark or pin */
- switch (BUILTIN_TYPE(obj)) {
- case T_MOVED:
- case T_ZOMBIE:
- case T_NONE:
- break;
- default:
- gc_mark_and_pin(objspace, obj);
- break;
- }
-
- if (ptr) {
- GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
- asan_poison_object(obj);
- }
+ int type = BUILTIN_TYPE(obj);
+ if (type != T_ZOMBIE && type != T_NONE) {
+ gc_mark_ptr(objspace, obj);
+ }
}
}
@@ -5185,7 +4455,6 @@ gc_mark_ptr(rb_objspace_t *objspace, VALUE obj)
if (LIKELY(objspace->mark_func_data == NULL)) {
rgengc_check_relation(objspace, obj);
if (!gc_mark_set(objspace, obj)) return; /* already marked */
- if (RB_TYPE_P(obj, T_NONE)) rb_bug("try to mark T_NONE object"); /* check here will help debugging */
gc_aging(objspace, obj);
gc_grey(objspace, obj);
}
@@ -5195,23 +4464,6 @@ gc_mark_ptr(rb_objspace_t *objspace, VALUE obj)
}
static inline void
-gc_pin(rb_objspace_t *objspace, VALUE obj)
-{
- GC_ASSERT(is_markable_object(objspace, obj));
- if (UNLIKELY(objspace->flags.during_compacting)) {
- MARK_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj);
- }
-}
-
-static inline void
-gc_mark_and_pin(rb_objspace_t *objspace, VALUE obj)
-{
- if (!is_markable_object(objspace, obj)) return;
- gc_pin(objspace, obj);
- gc_mark_ptr(objspace, obj);
-}
-
-static inline void
gc_mark(rb_objspace_t *objspace, VALUE obj)
{
if (!is_markable_object(objspace, obj)) return;
@@ -5219,15 +4471,9 @@ gc_mark(rb_objspace_t *objspace, VALUE obj)
}
void
-rb_gc_mark_movable(VALUE ptr)
-{
- gc_mark(&rb_objspace, ptr);
-}
-
-void
rb_gc_mark(VALUE ptr)
{
- gc_mark_and_pin(&rb_objspace, ptr);
+ gc_mark(&rb_objspace, ptr);
}
/* CAUTION: THIS FUNCTION ENABLE *ONLY BEFORE* SWEEPING.
@@ -5261,9 +4507,9 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
{
const rb_env_t *env = (const rb_env_t *)obj;
GC_ASSERT(VM_ENV_ESCAPED_P(env->ep));
- gc_mark_values(objspace, (long)env->env_size, env->env);
+ gc_mark_values(objspace, (long)env->env_size, env->env);
VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
- gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
+ gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
gc_mark(objspace, (VALUE)env->iseq);
}
return;
@@ -5295,9 +4541,9 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
case imemo_iseq:
rb_iseq_mark((rb_iseq_t *)obj);
return;
- case imemo_tmpbuf:
+ case imemo_alloc:
{
- const rb_imemo_tmpbuf_t *m = &RANY(obj)->as.imemo.alloc;
+ const rb_imemo_alloc_t *m = &RANY(obj)->as.imemo.alloc;
do {
rb_gc_mark_locations(m->ptr, m->ptr + m->cnt);
} while ((m = m->next) != NULL);
@@ -5327,13 +4573,6 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
}
switch (BUILTIN_TYPE(obj)) {
- case T_FLOAT:
- case T_BIGNUM:
- case T_SYMBOL:
- /* Not immediates, but does not have references and singleton
- * class */
- return;
-
case T_NIL:
case T_FIXNUM:
rb_bug("rb_gc_mark() called for broken object");
@@ -5353,49 +4592,38 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
switch (BUILTIN_TYPE(obj)) {
case T_CLASS:
case T_MODULE:
- if (RCLASS_SUPER(obj)) {
- gc_mark(objspace, RCLASS_SUPER(obj));
- }
+ mark_m_tbl(objspace, RCLASS_M_TBL(obj));
if (!RCLASS_EXT(obj)) break;
- mark_m_tbl(objspace, RCLASS_M_TBL(obj));
- mark_tbl_no_pin(objspace, RCLASS_IV_TBL(obj));
+ mark_tbl(objspace, RCLASS_IV_TBL(obj));
mark_const_tbl(objspace, RCLASS_CONST_TBL(obj));
+ gc_mark(objspace, RCLASS_SUPER((VALUE)obj));
break;
case T_ICLASS:
if (FL_TEST(obj, RICLASS_IS_ORIGIN)) {
mark_m_tbl(objspace, RCLASS_M_TBL(obj));
}
- if (RCLASS_SUPER(obj)) {
- gc_mark(objspace, RCLASS_SUPER(obj));
- }
if (!RCLASS_EXT(obj)) break;
mark_m_tbl(objspace, RCLASS_CALLABLE_M_TBL(obj));
+ gc_mark(objspace, RCLASS_SUPER((VALUE)obj));
break;
case T_ARRAY:
- if (FL_TEST(obj, ELTS_SHARED)) {
- VALUE root = any->as.array.as.heap.aux.shared_root;
- gc_mark(objspace, root);
+ if (FL_TEST(obj, ELTS_SHARED)) {
+ gc_mark(objspace, any->as.array.as.heap.aux.shared);
}
else {
long i, len = RARRAY_LEN(obj);
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(obj);
+ const VALUE *ptr = RARRAY_CONST_PTR(obj);
for (i=0; i < len; i++) {
- gc_mark(objspace, ptr[i]);
+ gc_mark(objspace, *ptr++);
}
-
- if (objspace->mark_func_data == NULL) {
- if (!FL_TEST_RAW(obj, RARRAY_EMBED_FLAG) &&
- RARRAY_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
- }
- }
+ }
break;
case T_HASH:
- mark_hash(objspace, obj);
+ mark_hash(objspace, any->as.hash.ntbl);
+ gc_mark(objspace, any->as.hash.ifnone);
break;
case T_STRING:
@@ -5418,18 +4646,10 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
case T_OBJECT:
{
- const VALUE * const ptr = ROBJECT_IVPTR(obj);
-
- if (ptr) {
- uint32_t i, len = ROBJECT_NUMIV(obj);
- for (i = 0; i < len; i++) {
- gc_mark(objspace, ptr[i]);
- }
-
- if (objspace->mark_func_data == NULL &&
- ROBJ_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
+ uint32_t i, len = ROBJECT_NUMIV(obj);
+ VALUE *ptr = ROBJECT_IVPTR(obj);
+ for (i = 0; i < len; i++) {
+ gc_mark(objspace, *ptr++);
}
}
break;
@@ -5449,6 +4669,11 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
gc_mark(objspace, any->as.regexp.src);
break;
+ case T_FLOAT:
+ case T_BIGNUM:
+ case T_SYMBOL:
+ break;
+
case T_MATCH:
gc_mark(objspace, any->as.match.regexp);
if (any->as.match.str) {
@@ -5468,18 +4693,12 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
case T_STRUCT:
{
- long i;
- const long len = RSTRUCT_LEN(obj);
- const VALUE * const ptr = RSTRUCT_CONST_PTR(obj);
-
- for (i=0; i<len; i++) {
- gc_mark(objspace, ptr[i]);
- }
+ long len = RSTRUCT_LEN(obj);
+ const VALUE *ptr = RSTRUCT_CONST_PTR(obj);
- if (objspace->mark_func_data == NULL &&
- RSTRUCT_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
+ while (len--) {
+ gc_mark(objspace, *ptr++);
+ }
}
break;
@@ -5487,11 +4706,10 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
#if GC_DEBUG
rb_gcdebug_print_obj_condition((VALUE)obj);
#endif
- if (BUILTIN_TYPE(obj) == T_MOVED) rb_bug("rb_gc_mark(): %p is T_MOVED", (void *)obj);
if (BUILTIN_TYPE(obj) == T_NONE) rb_bug("rb_gc_mark(): %p is T_NONE", (void *)obj);
if (BUILTIN_TYPE(obj) == T_ZOMBIE) rb_bug("rb_gc_mark(): %p is T_ZOMBIE", (void *)obj);
rb_bug("rb_gc_mark(): unknown data type 0x%x(%p) %s",
- BUILTIN_TYPE(obj), (void *)any,
+ BUILTIN_TYPE(obj), any,
is_pointer_to_heap(objspace, any) ? "corrupted object" : "non object");
}
}
@@ -5536,7 +4754,7 @@ gc_mark_stacked_objects(rb_objspace_t *objspace, int incremental, size_t count)
#endif
}
- if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(objspace);
+ if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(Qnil);
if (is_mark_stack_empty(mstack)) {
shrink_stack_chunk_cache(mstack);
@@ -5580,7 +4798,7 @@ show_mark_ticks(void)
}
}
-#endif /* PRINT_ROOT_TICKS */
+#endif /* PRITNT_ROOT_TICKS */
static void
gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
@@ -5616,7 +4834,7 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
prev_category = category; \
start_tick = tick(); \
} while (0)
-#else /* PRINT_ROOT_TICKS */
+#else /* PRITNT_ROOT_TICKS */
#define MARK_CHECKPOINT_PRINT_TICK(category)
#endif
@@ -5631,15 +4849,18 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
if (vm->self) gc_mark(objspace, vm->self);
MARK_CHECKPOINT("finalizers");
- mark_finalizer_tbl(objspace, finalizer_table);
+ mark_tbl(objspace, finalizer_table);
MARK_CHECKPOINT("machine_context");
mark_current_machine_context(objspace, ec);
+ MARK_CHECKPOINT("encodings");
+ rb_gc_mark_encodings();
+
/* mark protected global variables */
MARK_CHECKPOINT("global_list");
for (list = global_list; list; list = list->next) {
- gc_mark_maybe(objspace, *list->varptr);
+ rb_gc_mark_maybe(*list->varptr);
}
MARK_CHECKPOINT("end_proc");
@@ -5648,10 +4869,6 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
MARK_CHECKPOINT("global_tbl");
rb_gc_mark_global_tbl();
- MARK_CHECKPOINT("object_id");
- rb_gc_mark(objspace->next_object_id);
- mark_tbl_no_pin(objspace, objspace->obj_to_id_tbl); /* Only mark ids */
-
if (stress_to_class) rb_gc_mark(stress_to_class);
MARK_CHECKPOINT("finish");
@@ -5716,7 +4933,7 @@ reflist_dump(struct reflist *refs)
}
static int
-reflist_referred_from_machine_context(struct reflist *refs)
+reflist_refered_from_machine_context(struct reflist *refs)
{
int i;
for (i=0; i<refs->pos; i++) {
@@ -5859,7 +5076,7 @@ gc_check_after_marks_i(st_data_t k, st_data_t v, void *ptr)
fprintf(stderr, "gc_check_after_marks_i: %p is referred from ", (void *)obj);
reflist_dump(refs);
- if (reflist_referred_from_machine_context(refs)) {
+ if (reflist_refered_from_machine_context(refs)) {
fprintf(stderr, " (marked from machine stack).\n");
/* marked from machine context can be false positive */
}
@@ -5872,13 +5089,13 @@ gc_check_after_marks_i(st_data_t k, st_data_t v, void *ptr)
}
static void
-gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func, const char *checker_name)
+gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char *checker_name)
{
size_t saved_malloc_increase = objspace->malloc_params.increase;
#if RGENGC_ESTIMATE_OLDMALLOC
size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase;
#endif
- VALUE already_disabled = rb_objspace_gc_disable(objspace);
+ VALUE already_disabled = rb_gc_disable();
objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
@@ -5896,7 +5113,7 @@ gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func,
objspace_allrefs_destruct(objspace->rgengc.allrefs_table);
objspace->rgengc.allrefs_table = 0;
- if (already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
+ if (already_disabled == Qfalse) rb_gc_enable();
objspace->malloc_params.increase = saved_malloc_increase;
#if RGENGC_ESTIMATE_OLDMALLOC
objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase;
@@ -5953,14 +5170,7 @@ check_color_i(const VALUE child, void *ptr)
static void
check_children_i(const VALUE child, void *ptr)
{
- struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
- if (check_rvalue_consistency_force(child, FALSE) != 0) {
- fprintf(stderr, "check_children_i: %s has error (referenced from %s)",
- obj_info(child), obj_info(data->parent));
- rb_print_backtrace(); /* C backtrace will help to debug */
-
- data->err_count++;
- }
+ check_rvalue_consistency(child);
}
static int
@@ -5971,23 +5181,16 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, v
rb_objspace_t *objspace = data->objspace;
for (obj = (VALUE)page_start; obj != (VALUE)page_end; obj += stride) {
- void *poisoned = asan_poisoned_object_p(obj);
- asan_unpoison_object(obj, false);
-
if (is_live_object(objspace, obj)) {
/* count objects */
data->live_object_count++;
- data->parent = obj;
- /* Normally, we don't expect T_MOVED objects to be in the heap.
- * But they can stay alive on the stack, */
- if (!gc_object_moved_p(objspace, obj)) {
- /* moved slots don't have children */
- rb_objspace_reachable_objects_from(obj, check_children_i, (void *)data);
- }
+ rb_objspace_reachable_objects_from(obj, check_children_i, (void *)data);
#if USE_RGENGC
/* check health of children */
+ data->parent = obj;
+
if (RVALUE_OLD_P(obj)) data->old_object_count++;
if (RVALUE_WB_UNPROTECTED(obj) && RVALUE_UNCOLLECTIBLE(obj)) data->remembered_shady_count++;
@@ -6008,14 +5211,10 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, v
}
else {
if (BUILTIN_TYPE(obj) == T_ZOMBIE) {
- GC_ASSERT((RBASIC(obj)->flags & ~FL_SEEN_OBJ_ID) == T_ZOMBIE);
+ GC_ASSERT(RBASIC(obj)->flags == T_ZOMBIE);
data->zombie_object_count++;
}
}
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
- asan_poison_object(obj);
- }
}
return 0;
@@ -6028,15 +5227,12 @@ gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
int i;
unsigned int has_remembered_shady = FALSE;
unsigned int has_remembered_old = FALSE;
- int remembered_old_objects = 0;
+ int rememberd_old_objects = 0;
int free_objects = 0;
int zombie_objects = 0;
for (i=0; i<page->total_slots; i++) {
VALUE val = (VALUE)&page->start[i];
- void *poisoned = asan_poisoned_object_p(val);
- asan_unpoison_object(val, false);
-
if (RBASIC(val) == 0) free_objects++;
if (BUILTIN_TYPE(val) == T_ZOMBIE) zombie_objects++;
if (RVALUE_PAGE_UNCOLLECTIBLE(page, val) && RVALUE_PAGE_WB_UNPROTECTED(page, val)) {
@@ -6044,13 +5240,8 @@ gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
}
if (RVALUE_PAGE_MARKING(page, val)) {
has_remembered_old = TRUE;
- remembered_old_objects++;
+ rememberd_old_objects++;
}
-
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(val) == T_NONE);
- asan_poison_object(val);
- }
}
if (!is_incremental_marking(objspace) &&
@@ -6063,65 +5254,52 @@ gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
}
}
rb_bug("page %p's has_remembered_objects should be false, but there are remembered old objects (%d). %s",
- (void *)page, remembered_old_objects, obj ? obj_info(obj) : "");
+ page, rememberd_old_objects, obj ? obj_info(obj) : "");
}
if (page->flags.has_uncollectible_shady_objects == FALSE && has_remembered_shady == TRUE) {
rb_bug("page %p's has_remembered_shady should be false, but there are remembered shady objects. %s",
- (void *)page, obj ? obj_info(obj) : "");
+ page, obj ? obj_info(obj) : "");
}
if (0) {
/* free_slots may not equal to free_objects */
if (page->free_slots != free_objects) {
- rb_bug("page %p's free_slots should be %d, but %d\n", (void *)page, (int)page->free_slots, free_objects);
+ rb_bug("page %p's free_slots should be %d, but %d\n", page, (int)page->free_slots, free_objects);
}
}
if (page->final_slots != zombie_objects) {
- rb_bug("page %p's final_slots should be %d, but %d\n", (void *)page, (int)page->final_slots, zombie_objects);
+ rb_bug("page %p's final_slots should be %d, but %d\n", page, (int)page->final_slots, zombie_objects);
}
- return remembered_old_objects;
+ return rememberd_old_objects;
#else
return 0;
#endif
}
static int
-gc_verify_heap_pages_(rb_objspace_t *objspace, struct list_head *head)
-{
- int remembered_old_objects = 0;
- struct heap_page *page = 0;
-
- list_for_each(head, page, page_node) {
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
- RVALUE *p = page->freelist;
- while (p) {
- RVALUE *prev = p;
- asan_unpoison_object((VALUE)p, false);
- if (BUILTIN_TYPE(p) != T_NONE) {
- fprintf(stderr, "freelist slot expected to be T_NONE but was: %s\n", obj_info((VALUE)p));
- }
- p = p->as.free.next;
- asan_poison_object((VALUE)prev);
- }
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
+gc_verify_heap_pages_(rb_objspace_t *objspace, struct heap_page *page)
+{
+ int rememberd_old_objects = 0;
+ while (page) {
if (page->flags.has_remembered_objects == FALSE) {
- remembered_old_objects += gc_verify_heap_page(objspace, page, Qfalse);
+ rememberd_old_objects += gc_verify_heap_page(objspace, page, Qfalse);
}
+ page = page->next;
}
- return remembered_old_objects;
+ return rememberd_old_objects;
}
static int
gc_verify_heap_pages(rb_objspace_t *objspace)
{
- int remembered_old_objects = 0;
- remembered_old_objects += gc_verify_heap_pages_(objspace, &heap_eden->pages);
- remembered_old_objects += gc_verify_heap_pages_(objspace, &heap_tomb->pages);
- return remembered_old_objects;
+ int rememberd_old_objects = 0;
+ rememberd_old_objects = gc_verify_heap_pages_(objspace, heap_eden->pages);
+ rememberd_old_objects = gc_verify_heap_pages_(objspace, heap_tomb->pages);
+ return rememberd_old_objects;
}
/*
@@ -6135,24 +5313,20 @@ gc_verify_heap_pages(rb_objspace_t *objspace)
* if RGenGC is supported.
*/
static VALUE
-gc_verify_internal_consistency_m(VALUE dummy)
-{
- gc_verify_internal_consistency(&rb_objspace);
-
- return Qnil;
-}
-
-static void
-gc_verify_internal_consistency(rb_objspace_t *objspace)
+gc_verify_internal_consistency(VALUE dummy)
{
+ rb_objspace_t *objspace = &rb_objspace;
struct verify_internal_consistency_struct data = {0};
+ struct each_obj_args eo_args;
data.objspace = objspace;
gc_report(5, objspace, "gc_verify_internal_consistency: start\n");
/* check relations */
- objspace_each_objects_without_setup(objspace, verify_internal_consistency_i, &data);
+ eo_args.callback = verify_internal_consistency_i;
+ eo_args.data = (void *)&data;
+ objspace_each_objects((VALUE)&eo_args);
if (data.err_count != 0) {
#if RGENGC_CHECK_MODE >= 5
@@ -6212,19 +5386,14 @@ gc_verify_internal_consistency(rb_objspace_t *objspace)
}
gc_report(5, objspace, "gc_verify_internal_consistency: OK\n");
+
+ return Qnil;
}
void
rb_gc_verify_internal_consistency(void)
{
- gc_verify_internal_consistency(&rb_objspace);
-}
-
-static VALUE
-gc_verify_transient_heap_internal_consistency(VALUE dmy)
-{
- rb_transient_heap_verify();
- return Qnil;
+ gc_verify_internal_consistency(Qnil);
}
/* marks */
@@ -6270,9 +5439,9 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
static void
gc_marks_wb_unprotected_objects(rb_objspace_t *objspace)
{
- struct heap_page *page = 0;
+ struct heap_page *page = heap_eden->pages;
- list_for_each(&heap_eden->pages, page, page_node) {
+ while (page) {
bits_t *mark_bits = page->mark_bits;
bits_t *wbun_bits = page->wb_unprotected_bits;
RVALUE *p = page->start;
@@ -6297,6 +5466,8 @@ gc_marks_wb_unprotected_objects(rb_objspace_t *objspace)
} while (bits);
}
}
+
+ page = page->next;
}
gc_mark_stacked_objects_all(objspace);
@@ -6309,7 +5480,8 @@ heap_move_pooled_pages_to_free_pages(rb_heap_t *heap)
if (page) {
heap->pooled_pages = page->free_next;
- heap_add_freepage(heap, page);
+ page->free_next = heap->free_pages;
+ heap->free_pages = page;
}
return page;
@@ -6352,7 +5524,7 @@ gc_marks_finish(rb_objspace_t *objspace)
#endif /* GC_ENABLE_INCREMENTAL_MARK */
#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
+ gc_verify_internal_consistency(Qnil);
#endif
#if USE_RGENGC
@@ -6442,17 +5614,15 @@ gc_marks_finish(rb_objspace_t *objspace)
#endif
}
- rb_transient_heap_finish_marking();
-
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_MARK, 0);
return TRUE;
}
+#if GC_ENABLE_INCREMENTAL_MARK
static void
gc_marks_step(rb_objspace_t *objspace, int slots)
{
-#if GC_ENABLE_INCREMENTAL_MARK
GC_ASSERT(is_marking(objspace));
if (gc_mark_stacked_objects_incremental(objspace, slots)) {
@@ -6462,8 +5632,8 @@ gc_marks_step(rb_objspace_t *objspace, int slots)
}
}
if (0) fprintf(stderr, "objspace->marked_slots: %d\n", (int)objspace->marked_slots);
-#endif
}
+#endif
static void
gc_marks_rest(rb_objspace_t *objspace)
@@ -6488,19 +5658,19 @@ gc_marks_rest(rb_objspace_t *objspace)
gc_sweep(objspace);
}
+#if GC_ENABLE_INCREMENTAL_MARK
static void
gc_marks_continue(rb_objspace_t *objspace, rb_heap_t *heap)
{
+ int slots = 0;
+ const char *from;
+
GC_ASSERT(dont_gc == FALSE);
-#if GC_ENABLE_INCREMENTAL_MARK
gc_enter(objspace, "marks_continue");
PUSH_MARK_FUNC_DATA(NULL);
{
- int slots = 0;
- const char *from;
-
if (heap->pooled_pages) {
while (heap->pooled_pages && slots < HEAP_PAGE_OBJ_LIMIT) {
struct heap_page *page = heap_move_pooled_pages_to_free_pages(heap);
@@ -6525,8 +5695,8 @@ gc_marks_continue(rb_objspace_t *objspace, rb_heap_t *heap)
POP_MARK_FUNC_DATA();
gc_exit(objspace, "marks_continue");
-#endif
}
+#endif
static void
gc_marks(rb_objspace_t *objspace, int full_mark)
@@ -6651,18 +5821,12 @@ rgengc_remember(rb_objspace_t *objspace, VALUE obj)
}
static int
-rgengc_remembered_sweep(rb_objspace_t *objspace, VALUE obj)
+rgengc_remembered(rb_objspace_t *objspace, VALUE obj)
{
int result = rgengc_remembersetbits_get(objspace, obj);
check_rvalue_consistency(obj);
- return result;
-}
-
-static int
-rgengc_remembered(rb_objspace_t *objspace, VALUE obj)
-{
gc_report(6, objspace, "rgengc_remembered: %s\n", obj_info(obj));
- return rgengc_remembered_sweep(objspace, obj);
+ return result;
}
#ifndef PROFILE_REMEMBERSET_MARK
@@ -6673,13 +5837,13 @@ static void
rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
{
size_t j;
- struct heap_page *page = 0;
+ struct heap_page *page = heap->pages;
#if PROFILE_REMEMBERSET_MARK
int has_old = 0, has_shady = 0, has_both = 0, skip = 0;
#endif
gc_report(1, objspace, "rgengc_rememberset_mark: start\n");
- list_for_each(&heap->pages, page, page_node) {
+ while (page) {
if (page->flags.has_remembered_objects | page->flags.has_uncollectible_shady_objects) {
RVALUE *p = page->start;
RVALUE *offset = p - NUM_IN_PAGE(p);
@@ -6724,6 +5888,8 @@ rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
skip++;
}
#endif
+
+ page = page->next;
}
#if PROFILE_REMEMBERSET_MARK
@@ -6735,15 +5901,15 @@ rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
static void
rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap)
{
- struct heap_page *page = 0;
+ struct heap_page *page = heap->pages;
- list_for_each(&heap->pages, page, page_node) {
+ while (page) {
memset(&page->mark_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ memset(&page->marking_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
memset(&page->uncollectible_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
- memset(&page->marking_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
- memset(&page->pinned_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
page->flags.has_uncollectible_shady_objects = FALSE;
page->flags.has_remembered_objects = FALSE;
+ page = page->next;
}
}
@@ -6879,7 +6045,6 @@ rb_gc_writebarrier_unprotect(VALUE obj)
RVALUE_AGE_RESET(obj);
}
- RB_DEBUG_COUNTER_INC(obj_wb_unprotect);
MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
}
}
@@ -6887,7 +6052,7 @@ rb_gc_writebarrier_unprotect(VALUE obj)
/*
* remember `obj' if needed.
*/
-MJIT_FUNC_EXPORTED void
+void
rb_gc_writebarrier_remember(VALUE obj)
{
rb_objspace_t *objspace = &rb_objspace;
@@ -6994,7 +6159,7 @@ rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
size_t n = 0;
static ID ID_marked;
#if USE_RGENGC
- static ID ID_wb_protected, ID_old, ID_marking, ID_uncollectible, ID_pinned;
+ static ID ID_wb_protected, ID_old, ID_marking, ID_uncollectible;
#endif
if (!ID_marked) {
@@ -7005,7 +6170,6 @@ rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
I(old);
I(marking);
I(uncollectible);
- I(pinned);
#endif
#undef I
}
@@ -7017,7 +6181,6 @@ rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
if (MARKED_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj) && n<max) flags[n++] = ID_marking;
#endif
if (MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj) && n<max) flags[n++] = ID_marked;
- if (MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj) && n<max) flags[n++] = ID_pinned;
return n;
}
@@ -7175,7 +6338,8 @@ gc_reset_malloc_info(rb_objspace_t *objspace)
if (inc > malloc_limit) {
malloc_limit = (size_t)(inc * gc_params.malloc_limit_growth_factor);
- if (malloc_limit > gc_params.malloc_limit_max) {
+ if (gc_params.malloc_limit_max > 0 && /* ignore max-check if 0 */
+ malloc_limit > gc_params.malloc_limit_max) {
malloc_limit = gc_params.malloc_limit_max;
}
}
@@ -7234,7 +6398,7 @@ gc_reset_malloc_info(rb_objspace_t *objspace)
}
static int
-garbage_collect(rb_objspace_t *objspace, int reason)
+garbage_collect(rb_objspace_t *objspace, int full_mark, int immediate_mark, int immediate_sweep, int reason)
{
#if GC_PROFILE_MORE_DETAIL
objspace->profile.prepare_time = getrusage_time();
@@ -7246,26 +6410,23 @@ garbage_collect(rb_objspace_t *objspace, int reason)
objspace->profile.prepare_time = getrusage_time() - objspace->profile.prepare_time;
#endif
- return gc_start(objspace, reason);
+ return gc_start(objspace, full_mark, immediate_mark, immediate_sweep, reason);
}
static int
-gc_start(rb_objspace_t *objspace, int reason)
+gc_start(rb_objspace_t *objspace, const int full_mark, const int immediate_mark, const unsigned int immediate_sweep, int reason)
{
- unsigned int do_full_mark = !!((unsigned)reason & GPR_FLAG_FULL_MARK);
- unsigned int immediate_mark = (unsigned)reason & GPR_FLAG_IMMEDIATE_MARK;
-
- /* reason may be clobbered, later, so keep set immediate_sweep here */
- objspace->flags.immediate_sweep = !!((unsigned)reason & GPR_FLAG_IMMEDIATE_SWEEP);
+ int do_full_mark = full_mark;
+ objspace->flags.immediate_sweep = immediate_sweep;
if (!heap_allocated_pages) return FALSE; /* heap is not ready */
- if (!(reason & GPR_FLAG_METHOD) && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
+ if (reason != GPR_FLAG_METHOD && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
GC_ASSERT(gc_mode(objspace) == gc_mode_none);
GC_ASSERT(!is_lazy_sweeping(heap_eden));
GC_ASSERT(!is_incremental_marking(objspace));
#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
+ gc_verify_internal_consistency(Qnil);
#endif
gc_enter(objspace, "gc_start");
@@ -7313,38 +6474,16 @@ gc_start(rb_objspace_t *objspace, int reason)
if (objspace->flags.immediate_sweep) reason |= GPR_FLAG_IMMEDIATE_SWEEP;
- gc_report(1, objspace, "gc_start(reason: %d) => %u, %d, %d\n",
- reason,
+ gc_report(1, objspace, "gc_start(%d, %d, %d, reason: %d) => %d, %d, %d\n",
+ full_mark, immediate_mark, immediate_sweep, reason,
do_full_mark, !is_incremental_marking(objspace), objspace->flags.immediate_sweep);
-#if USE_DEBUG_COUNTER
- RB_DEBUG_COUNTER_INC(gc_count);
-
- if (reason & GPR_FLAG_MAJOR_MASK) {
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_nofree, reason & GPR_FLAG_MAJOR_BY_NOFREE);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_oldgen, reason & GPR_FLAG_MAJOR_BY_OLDGEN);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_shady, reason & GPR_FLAG_MAJOR_BY_SHADY);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_force, reason & GPR_FLAG_MAJOR_BY_FORCE);
-#if RGENGC_ESTIMATE_OLDMALLOC
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_oldmalloc, reason & GPR_FLAG_MAJOR_BY_OLDMALLOC);
-#endif
- }
- else {
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_newobj, reason & GPR_FLAG_NEWOBJ);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_malloc, reason & GPR_FLAG_MALLOC);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_method, reason & GPR_FLAG_METHOD);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_capi, reason & GPR_FLAG_CAPI);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_stress, reason & GPR_FLAG_STRESS);
- }
-#endif
-
objspace->profile.count++;
objspace->profile.latest_gc_info = reason;
objspace->profile.total_allocated_objects_at_gc_start = objspace->total_allocated_objects;
objspace->profile.heap_used_at_gc_start = heap_allocated_pages;
gc_prof_setup_new_record(objspace, reason);
gc_reset_malloc_info(objspace);
- rb_transient_heap_start_marking(do_full_mark);
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);
GC_ASSERT(during_gc);
@@ -7368,7 +6507,7 @@ gc_rest(rb_objspace_t *objspace)
if (marking || sweeping) {
gc_enter(objspace, "gc_rest");
- if (RGENGC_CHECK_MODE >= 2) gc_verify_internal_consistency(objspace);
+ if (RGENGC_CHECK_MODE >= 2) gc_verify_internal_consistency(Qnil);
if (is_incremental_marking(objspace)) {
PUSH_MARK_FUNC_DATA(NULL);
@@ -7385,6 +6524,9 @@ gc_rest(rb_objspace_t *objspace)
struct objspace_and_reason {
rb_objspace_t *objspace;
int reason;
+ int full_mark;
+ int immediate_mark;
+ int immediate_sweep;
};
static void
@@ -7469,12 +6611,10 @@ static inline void
gc_enter(rb_objspace_t *objspace, const char *event)
{
GC_ASSERT(during_gc == 0);
- if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(objspace);
-
- mjit_gc_start_hook();
+ if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(Qnil);
during_gc = TRUE;
- gc_report(1, objspace, "gc_enter: %s [%s]\n", event, gc_current_status(objspace));
+ gc_report(1, objspace, "gc_entr: %s [%s]\n", event, gc_current_status(objspace));
gc_record(objspace, 0, event);
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_ENTER, 0); /* TODO: which parameter should be passed? */
}
@@ -7488,29 +6628,30 @@ gc_exit(rb_objspace_t *objspace, const char *event)
gc_record(objspace, 1, event);
gc_report(1, objspace, "gc_exit: %s [%s]\n", event, gc_current_status(objspace));
during_gc = FALSE;
-
- mjit_gc_exit_hook();
}
static void *
gc_with_gvl(void *ptr)
{
struct objspace_and_reason *oar = (struct objspace_and_reason *)ptr;
- return (void *)(VALUE)garbage_collect(oar->objspace, oar->reason);
+ return (void *)(VALUE)garbage_collect(oar->objspace, oar->full_mark, oar->immediate_mark, oar->immediate_sweep, oar->reason);
}
static int
-garbage_collect_with_gvl(rb_objspace_t *objspace, int reason)
+garbage_collect_with_gvl(rb_objspace_t *objspace, int full_mark, int immediate_mark, int immediate_sweep, int reason)
{
if (dont_gc) return TRUE;
if (ruby_thread_has_gvl_p()) {
- return garbage_collect(objspace, reason);
+ return garbage_collect(objspace, full_mark, immediate_mark, immediate_sweep, reason);
}
else {
if (ruby_native_thread_p()) {
struct objspace_and_reason oar;
oar.objspace = objspace;
oar.reason = reason;
+ oar.full_mark = full_mark;
+ oar.immediate_mark = immediate_mark;
+ oar.immediate_sweep = immediate_sweep;
return (int)(VALUE)rb_thread_call_with_gvl(gc_with_gvl, (void *)&oar);
}
else {
@@ -7521,1167 +6662,67 @@ garbage_collect_with_gvl(rb_objspace_t *objspace, int reason)
}
}
-static VALUE
-gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE immediate_mark, VALUE immediate_sweep)
-{
- rb_objspace_t *objspace = &rb_objspace;
- int reason = GPR_FLAG_FULL_MARK |
- GPR_FLAG_IMMEDIATE_MARK |
- GPR_FLAG_IMMEDIATE_SWEEP |
- GPR_FLAG_METHOD;
-
- if (!RTEST(full_mark)) reason &= ~GPR_FLAG_FULL_MARK;
- if (!RTEST(immediate_mark)) reason &= ~GPR_FLAG_IMMEDIATE_MARK;
- if (!RTEST(immediate_sweep)) reason &= ~GPR_FLAG_IMMEDIATE_SWEEP;
-
- garbage_collect(objspace, reason);
- gc_finalize_deferred(objspace);
-
- return Qnil;
-}
-
-static int
-gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
-{
- if (SPECIAL_CONST_P(obj)) {
- return FALSE;
- }
-
- switch (BUILTIN_TYPE(obj)) {
- case T_NONE:
- case T_NIL:
- case T_MOVED:
- case T_ZOMBIE:
- return FALSE;
- break;
- case T_SYMBOL:
- if (DYNAMIC_SYM_P(obj) && (RSYMBOL(obj)->id & ~ID_SCOPE_MASK)) {
- return FALSE;
- }
- /* fall through */
- case T_STRING:
- case T_OBJECT:
- case T_FLOAT:
- case T_IMEMO:
- case T_ARRAY:
- case T_BIGNUM:
- case T_ICLASS:
- case T_MODULE:
- case T_REGEXP:
- case T_DATA:
- case T_MATCH:
- case T_STRUCT:
- case T_HASH:
- case T_FILE:
- case T_COMPLEX:
- case T_RATIONAL:
- case T_NODE:
- case T_CLASS:
- if (FL_TEST(obj, FL_FINALIZE)) {
- if (st_is_member(finalizer_table, obj)) {
- return FALSE;
- }
- }
- return RVALUE_MARKED(obj) && !RVALUE_PINNED(obj);
- break;
-
- default:
- rb_bug("gc_is_moveable_obj: unreachable (%d)", (int)BUILTIN_TYPE(obj));
- break;
- }
-
- return FALSE;
-}
-
-static VALUE
-gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, VALUE moved_list)
-{
- int marked;
- int wb_unprotected;
- int uncollectible;
- int marking;
- RVALUE *dest = (RVALUE *)free;
- RVALUE *src = (RVALUE *)scan;
-
- gc_report(4, objspace, "Moving object: %p -> %p\n", (void*)scan, (void *)free);
-
- GC_ASSERT(BUILTIN_TYPE(scan) != T_NONE);
- GC_ASSERT(BUILTIN_TYPE(free) == T_NONE);
-
- /* Save off bits for current object. */
- marked = rb_objspace_marked_object_p((VALUE)src);
- wb_unprotected = RVALUE_WB_UNPROTECTED((VALUE)src);
- uncollectible = RVALUE_UNCOLLECTIBLE((VALUE)src);
- marking = RVALUE_MARKING((VALUE)src);
-
- objspace->total_allocated_objects++;
-
- /* Clear bits for eventual T_MOVED */
- CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS((VALUE)src), (VALUE)src);
- CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS((VALUE)src), (VALUE)src);
- CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)src), (VALUE)src);
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)src), (VALUE)src);
-
- if (FL_TEST(src, FL_EXIVAR)) {
- rb_mv_generic_ivar((VALUE)src, (VALUE)dest);
- }
-
- VALUE id;
-
- /* If the source object's object_id has been seen, we need to update
- * the object to object id mapping. */
- if (st_lookup(objspace->obj_to_id_tbl, (VALUE)src, &id)) {
- gc_report(4, objspace, "Moving object with seen id: %p -> %p\n", (void *)src, (void *)dest);
- st_delete(objspace->obj_to_id_tbl, (st_data_t *)&src, 0);
- st_insert(objspace->obj_to_id_tbl, (VALUE)dest, id);
- }
-
- /* Move the object */
- memcpy(dest, src, sizeof(RVALUE));
- memset(src, 0, sizeof(RVALUE));
-
- /* Set bits for object in new location */
- if (marking) {
- MARK_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)dest), (VALUE)dest);
- }
- else {
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)dest), (VALUE)dest);
- }
-
- if (marked) {
- MARK_IN_BITMAP(GET_HEAP_MARK_BITS((VALUE)dest), (VALUE)dest);
- }
- else {
- CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS((VALUE)dest), (VALUE)dest);
- }
-
- if (wb_unprotected) {
- MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS((VALUE)dest), (VALUE)dest);
- }
- else {
- CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS((VALUE)dest), (VALUE)dest);
- }
-
- if (uncollectible) {
- MARK_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)dest), (VALUE)dest);
- }
- else {
- CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)dest), (VALUE)dest);
- }
-
- /* Assign forwarding address */
- src->as.moved.flags = T_MOVED;
- src->as.moved.destination = (VALUE)dest;
- src->as.moved.next = moved_list;
- GC_ASSERT(BUILTIN_TYPE((VALUE)dest) != T_NONE);
-
- return (VALUE)src;
-}
-
-struct heap_cursor {
- RVALUE *slot;
- size_t index;
- struct heap_page *page;
- rb_objspace_t * objspace;
-};
-
-static void
-advance_cursor(struct heap_cursor *free, struct heap_page **page_list)
-{
- if (free->slot == free->page->start + free->page->total_slots - 1) {
- free->index++;
- free->page = page_list[free->index];
- free->slot = free->page->start;
- }
- else {
- free->slot++;
- }
-}
-
-static void
-retreat_cursor(struct heap_cursor *scan, struct heap_page **page_list)
-{
- if (scan->slot == scan->page->start) {
- scan->index--;
- scan->page = page_list[scan->index];
- scan->slot = scan->page->start + scan->page->total_slots - 1;
- }
- else {
- scan->slot--;
- }
-}
-
-static int
-not_met(struct heap_cursor *free, struct heap_cursor *scan)
-{
- if (free->index < scan->index)
- return 1;
-
- if (free->index > scan->index)
- return 0;
-
- return free->slot < scan->slot;
-}
-
-static void
-init_cursors(rb_objspace_t *objspace, struct heap_cursor *free, struct heap_cursor *scan, struct heap_page **page_list)
-{
- struct heap_page *page;
- size_t total_pages = heap_eden->total_pages;
- page = page_list[0];
-
- free->index = 0;
- free->page = page;
- free->slot = page->start;
- free->objspace = objspace;
-
- page = page_list[total_pages - 1];
- scan->index = total_pages - 1;
- scan->page = page;
- scan->slot = page->start + page->total_slots - 1;
- scan->objspace = objspace;
-}
-
-static int
-count_pinned(struct heap_page *page)
-{
- int pinned = 0;
- int i;
-
- for (i = 0; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
- pinned += popcount_bits(page->pinned_bits[i]);
- }
-
- return pinned;
-}
-
-static int
-compare_pinned(const void *left, const void *right, void *dummy)
-{
- struct heap_page *left_page;
- struct heap_page *right_page;
-
- left_page = *(struct heap_page * const *)left;
- right_page = *(struct heap_page * const *)right;
-
- return right_page->pinned_slots - left_page->pinned_slots;
-}
-
-static int
-compare_free_slots(const void *left, const void *right, void *dummy)
-{
- struct heap_page *left_page;
- struct heap_page *right_page;
-
- left_page = *(struct heap_page * const *)left;
- right_page = *(struct heap_page * const *)right;
-
- return right_page->free_slots - left_page->free_slots;
-}
-
-typedef int page_compare_func_t(const void *, const void *, void *);
-
-static struct heap_page **
-allocate_page_list(rb_objspace_t *objspace, page_compare_func_t *comparator)
-{
- size_t total_pages = heap_eden->total_pages;
- size_t size = size_mul_or_raise(total_pages, sizeof(struct heap_page *), rb_eRuntimeError);
- struct heap_page *page = 0, **page_list = malloc(size);
- int i = 0;
-
- list_for_each(&heap_eden->pages, page, page_node) {
- page_list[i++] = page;
- page->pinned_slots = count_pinned(page);
- GC_ASSERT(page != NULL);
- }
- GC_ASSERT(total_pages > 0);
- GC_ASSERT((size_t)i == total_pages);
-
- ruby_qsort(page_list, total_pages, sizeof(struct heap_page *), comparator, NULL);
-
- return page_list;
-}
-
-static VALUE
-gc_compact_heap(rb_objspace_t *objspace, page_compare_func_t *comparator)
-{
- struct heap_cursor free_cursor;
- struct heap_cursor scan_cursor;
- struct heap_page **page_list;
- VALUE moved_list;
-
- moved_list = Qfalse;
- memset(objspace->rcompactor.considered_count_table, 0, T_MASK * sizeof(size_t));
- memset(objspace->rcompactor.moved_count_table, 0, T_MASK * sizeof(size_t));
-
- page_list = allocate_page_list(objspace, comparator);
-
- init_cursors(objspace, &free_cursor, &scan_cursor, page_list);
-
- /* Two finger algorithm */
- while (not_met(&free_cursor, &scan_cursor)) {
- /* Free cursor movement */
-
- /* Unpoison free_cursor slot */
- void *free_slot_poison = asan_poisoned_object_p((VALUE)free_cursor.slot);
- asan_unpoison_object((VALUE)free_cursor.slot, false);
-
- while (BUILTIN_TYPE(free_cursor.slot) != T_NONE && not_met(&free_cursor, &scan_cursor)) {
- /* Re-poison slot if it's not the one we want */
- if (free_slot_poison) {
- GC_ASSERT(BUILTIN_TYPE(free_cursor.slot) == T_NONE);
- asan_poison_object((VALUE)free_cursor.slot);
- }
-
- advance_cursor(&free_cursor, page_list);
-
- /* Unpoison free_cursor slot */
- free_slot_poison = asan_poisoned_object_p((VALUE)free_cursor.slot);
- asan_unpoison_object((VALUE)free_cursor.slot, false);
- }
-
- /* Unpoison scan_cursor slot */
- void *scan_slot_poison = asan_poisoned_object_p((VALUE)scan_cursor.slot);
- asan_unpoison_object((VALUE)scan_cursor.slot, false);
-
- /* Scan cursor movement */
- objspace->rcompactor.considered_count_table[BUILTIN_TYPE((VALUE)scan_cursor.slot)]++;
-
- while (!gc_is_moveable_obj(objspace, (VALUE)scan_cursor.slot) && not_met(&free_cursor, &scan_cursor)) {
-
- /* Re-poison slot if it's not the one we want */
- if (scan_slot_poison) {
- GC_ASSERT(BUILTIN_TYPE(scan_cursor.slot) == T_NONE);
- asan_poison_object((VALUE)scan_cursor.slot);
- }
-
- retreat_cursor(&scan_cursor, page_list);
-
- /* Unpoison scan_cursor slot */
- scan_slot_poison = asan_poisoned_object_p((VALUE)scan_cursor.slot);
- asan_unpoison_object((VALUE)scan_cursor.slot, false);
-
- objspace->rcompactor.considered_count_table[BUILTIN_TYPE((VALUE)scan_cursor.slot)]++;
- }
-
- if (not_met(&free_cursor, &scan_cursor)) {
- objspace->rcompactor.moved_count_table[BUILTIN_TYPE((VALUE)scan_cursor.slot)]++;
-
- GC_ASSERT(BUILTIN_TYPE(free_cursor.slot) == T_NONE);
- GC_ASSERT(BUILTIN_TYPE(scan_cursor.slot) != T_NONE);
- GC_ASSERT(BUILTIN_TYPE(scan_cursor.slot) != T_MOVED);
-
- moved_list = gc_move(objspace, (VALUE)scan_cursor.slot, (VALUE)free_cursor.slot, moved_list);
-
- GC_ASSERT(BUILTIN_TYPE(free_cursor.slot) != T_MOVED);
- GC_ASSERT(BUILTIN_TYPE(free_cursor.slot) != T_NONE);
- GC_ASSERT(BUILTIN_TYPE(scan_cursor.slot) == T_MOVED);
-
- advance_cursor(&free_cursor, page_list);
- retreat_cursor(&scan_cursor, page_list);
- }
- }
- free(page_list);
-
- return moved_list;
-}
-
-static void
-gc_ref_update_array(rb_objspace_t * objspace, VALUE v)
-{
- long i, len;
-
- if (FL_TEST(v, ELTS_SHARED))
- return;
-
- len = RARRAY_LEN(v);
- if (len > 0) {
- VALUE *ptr = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(v);
- for (i = 0; i < len; i++) {
- UPDATE_IF_MOVED(objspace, ptr[i]);
- }
- }
-}
-
-static void
-gc_ref_update_object(rb_objspace_t * objspace, VALUE v)
-{
- VALUE *ptr = ROBJECT_IVPTR(v);
-
- if (ptr) {
- uint32_t i, len = ROBJECT_NUMIV(v);
- for (i = 0; i < len; i++) {
- UPDATE_IF_MOVED(objspace, ptr[i]);
- }
- }
-}
-
-static int
-hash_replace_ref(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)*key)) {
- *key = rb_gc_location((VALUE)*key);
- }
-
- if (gc_object_moved_p(objspace, (VALUE)*value)) {
- *value = rb_gc_location((VALUE)*value);
- }
-
- return ST_CONTINUE;
-}
-
-static int
-hash_foreach_replace(st_data_t key, st_data_t value, st_data_t argp, int error)
-{
- rb_objspace_t *objspace;
+#undef Init_stack
- objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)key)) {
- return ST_REPLACE;
- }
-
- if (gc_object_moved_p(objspace, (VALUE)value)) {
- return ST_REPLACE;
- }
- return ST_CONTINUE;
-}
-
-static int
-hash_replace_ref_value(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)*value)) {
- *value = rb_gc_location((VALUE)*value);
- }
-
- return ST_CONTINUE;
-}
-
-static int
-hash_foreach_replace_value(st_data_t key, st_data_t value, st_data_t argp, int error)
-{
- rb_objspace_t *objspace;
-
- objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)value)) {
- return ST_REPLACE;
- }
- return ST_CONTINUE;
-}
-
-static void
-gc_update_tbl_refs(rb_objspace_t * objspace, st_table *tbl)
-{
- if (!tbl || tbl->num_entries == 0) return;
-
- if (st_foreach_with_replace(tbl, hash_foreach_replace_value, hash_replace_ref_value, (st_data_t)objspace)) {
- rb_raise(rb_eRuntimeError, "hash modified during iteration");
- }
-}
-
-static void
-gc_update_table_refs(rb_objspace_t * objspace, st_table *tbl)
-{
- if (!tbl || tbl->num_entries == 0) return;
-
- if (st_foreach_with_replace(tbl, hash_foreach_replace, hash_replace_ref, (st_data_t)objspace)) {
- rb_raise(rb_eRuntimeError, "hash modified during iteration");
- }
-}
-
-/* Update MOVED references in an st_table */
void
-rb_gc_update_tbl_refs(st_table *ptr)
-{
- rb_objspace_t *objspace = &rb_objspace;
- gc_update_table_refs(objspace, ptr);
-}
-
-static void
-gc_ref_update_hash(rb_objspace_t * objspace, VALUE v)
-{
- rb_hash_stlike_foreach_with_replace(v, hash_foreach_replace, hash_replace_ref, (st_data_t)objspace);
-}
-
-static void
-gc_ref_update_method_entry(rb_objspace_t *objspace, rb_method_entry_t *me)
-{
- rb_method_definition_t *def = me->def;
-
- UPDATE_IF_MOVED(objspace, me->owner);
- UPDATE_IF_MOVED(objspace, me->defined_class);
-
- if (def) {
- switch (def->type) {
- case VM_METHOD_TYPE_ISEQ:
- if (def->body.iseq.iseqptr) {
- TYPED_UPDATE_IF_MOVED(objspace, rb_iseq_t *, def->body.iseq.iseqptr);
- }
- TYPED_UPDATE_IF_MOVED(objspace, rb_cref_t *, def->body.iseq.cref);
- break;
- case VM_METHOD_TYPE_ATTRSET:
- case VM_METHOD_TYPE_IVAR:
- UPDATE_IF_MOVED(objspace, def->body.attr.location);
- break;
- case VM_METHOD_TYPE_BMETHOD:
- UPDATE_IF_MOVED(objspace, def->body.bmethod.proc);
- break;
- case VM_METHOD_TYPE_ALIAS:
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_method_entry_struct *, def->body.alias.original_me);
- return;
- case VM_METHOD_TYPE_REFINED:
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_method_entry_struct *, def->body.refined.orig_me);
- UPDATE_IF_MOVED(objspace, def->body.refined.owner);
- break;
- case VM_METHOD_TYPE_CFUNC:
- case VM_METHOD_TYPE_ZSUPER:
- case VM_METHOD_TYPE_MISSING:
- case VM_METHOD_TYPE_OPTIMIZED:
- case VM_METHOD_TYPE_UNDEF:
- case VM_METHOD_TYPE_NOTIMPLEMENTED:
- break;
- }
- }
-}
-
-static void
-gc_update_values(rb_objspace_t *objspace, long n, VALUE *values)
-{
- long i;
-
- for (i=0; i<n; i++) {
- UPDATE_IF_MOVED(objspace, values[i]);
- }
-}
-
-static void
-gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
-{
- switch (imemo_type(obj)) {
- case imemo_env:
- {
- rb_env_t *env = (rb_env_t *)obj;
- TYPED_UPDATE_IF_MOVED(objspace, rb_iseq_t *, env->iseq);
- UPDATE_IF_MOVED(objspace, env->ep[VM_ENV_DATA_INDEX_ENV]);
- gc_update_values(objspace, (long)env->env_size, (VALUE *)env->env);
- }
- break;
- case imemo_cref:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.cref.klass);
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_cref_struct *, RANY(obj)->as.imemo.cref.next);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.cref.refinements);
- break;
- case imemo_svar:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.cref_or_me);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.lastline);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.backref);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.others);
- break;
- case imemo_throw_data:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.throw_data.throw_obj);
- break;
- case imemo_ifunc:
- break;
- case imemo_memo:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.memo.v1);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.memo.v2);
- break;
- case imemo_ment:
- gc_ref_update_method_entry(objspace, &RANY(obj)->as.imemo.ment);
- break;
- case imemo_iseq:
- rb_iseq_update_references((rb_iseq_t *)obj);
- break;
- case imemo_ast:
- rb_ast_update_references((rb_ast_t *)obj);
- break;
- case imemo_parser_strterm:
- case imemo_tmpbuf:
- break;
- default:
- rb_bug("not reachable %d", imemo_type(obj));
- break;
- }
-}
-
-static enum rb_id_table_iterator_result
-check_id_table_move(ID id, VALUE value, void *data)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
-
- if (gc_object_moved_p(objspace, (VALUE)value)) {
- return ID_TABLE_REPLACE;
- }
-
- return ID_TABLE_CONTINUE;
-}
-
-/* Returns the new location of an object, if it moved. Otherwise returns
- * the existing location. */
-VALUE
-rb_gc_location(VALUE value)
-{
-
- VALUE destination;
-
- if (!SPECIAL_CONST_P((void *)value)) {
- void *poisoned = asan_poisoned_object_p(value);
- asan_unpoison_object(value, false);
-
- if (BUILTIN_TYPE(value) == T_MOVED) {
- destination = (VALUE)RMOVED(value)->destination;
- GC_ASSERT(BUILTIN_TYPE(destination) != T_NONE);
- }
- else {
- destination = value;
- }
-
- /* Re-poison slot if it's not the one we want */
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(value) == T_NONE);
- asan_poison_object(value);
- }
- }
- else {
- destination = value;
- }
-
- return destination;
-}
-
-static enum rb_id_table_iterator_result
-update_id_table(ID *key, VALUE * value, void *data, int existing)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
-
- if (gc_object_moved_p(objspace, (VALUE)*value)) {
- *value = rb_gc_location((VALUE)*value);
- }
-
- return ID_TABLE_CONTINUE;
-}
-
-static void
-update_m_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
-{
- if (tbl) {
- rb_id_table_foreach_with_replace(tbl, check_id_table_move, update_id_table, objspace);
- }
-}
-
-static enum rb_id_table_iterator_result
-update_const_table(VALUE value, void *data)
-{
- rb_const_entry_t *ce = (rb_const_entry_t *)value;
- rb_objspace_t * objspace = (rb_objspace_t *)data;
-
- if (gc_object_moved_p(objspace, ce->value)) {
- ce->value = rb_gc_location(ce->value);
- }
-
- if (gc_object_moved_p(objspace, ce->file)) {
- ce->file = rb_gc_location(ce->file);
- }
-
- return ID_TABLE_CONTINUE;
-}
-
-static void
-update_const_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
-{
- if (!tbl) return;
- rb_id_table_foreach_values(tbl, update_const_table, objspace);
-}
-
-static void
-update_subclass_entries(rb_objspace_t *objspace, rb_subclass_entry_t *entry)
-{
- while (entry) {
- UPDATE_IF_MOVED(objspace, entry->klass);
- entry = entry->next;
- }
-}
-
-static void
-update_class_ext(rb_objspace_t *objspace, rb_classext_t *ext)
-{
- UPDATE_IF_MOVED(objspace, ext->origin_);
- UPDATE_IF_MOVED(objspace, ext->refined_class);
- update_subclass_entries(objspace, ext->subclasses);
-}
-
-static void
-gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
-{
- RVALUE *any = RANY(obj);
-
- gc_report(4, objspace, "update-refs: %p ->", (void *)obj);
-
- switch (BUILTIN_TYPE(obj)) {
- case T_CLASS:
- case T_MODULE:
- if (RCLASS_SUPER((VALUE)obj)) {
- UPDATE_IF_MOVED(objspace, RCLASS(obj)->super);
- }
- if (!RCLASS_EXT(obj)) break;
- update_m_tbl(objspace, RCLASS_M_TBL(obj));
- gc_update_tbl_refs(objspace, RCLASS_IV_TBL(obj));
- update_class_ext(objspace, RCLASS_EXT(obj));
- update_const_tbl(objspace, RCLASS_CONST_TBL(obj));
- break;
-
- case T_ICLASS:
- if (FL_TEST(obj, RICLASS_IS_ORIGIN)) {
- update_m_tbl(objspace, RCLASS_M_TBL(obj));
- }
- if (RCLASS_SUPER((VALUE)obj)) {
- UPDATE_IF_MOVED(objspace, RCLASS(obj)->super);
- }
- if (!RCLASS_EXT(obj)) break;
- if (RCLASS_IV_TBL(obj)) {
- gc_update_tbl_refs(objspace, RCLASS_IV_TBL(obj));
- }
- update_class_ext(objspace, RCLASS_EXT(obj));
- update_m_tbl(objspace, RCLASS_CALLABLE_M_TBL(obj));
- break;
-
- case T_IMEMO:
- gc_ref_update_imemo(objspace, obj);
- return;
-
- case T_NIL:
- case T_FIXNUM:
- case T_NODE:
- case T_MOVED:
- case T_NONE:
- /* These can't move */
- return;
-
- case T_ARRAY:
- if (FL_TEST(obj, ELTS_SHARED)) {
- UPDATE_IF_MOVED(objspace, any->as.array.as.heap.aux.shared_root);
- }
- else {
- gc_ref_update_array(objspace, obj);
- }
- break;
-
- case T_HASH:
- gc_ref_update_hash(objspace, obj);
- UPDATE_IF_MOVED(objspace, any->as.hash.ifnone);
- break;
-
- case T_STRING:
- if (STR_SHARED_P(obj)) {
- UPDATE_IF_MOVED(objspace, any->as.string.as.heap.aux.shared);
- }
- break;
-
- case T_DATA:
- /* Call the compaction callback, if it exists */
- {
- void *const ptr = DATA_PTR(obj);
- if (ptr) {
- if (RTYPEDDATA_P(obj)) {
- RUBY_DATA_FUNC compact_func = any->as.typeddata.type->function.dcompact;
- if (compact_func) (*compact_func)(ptr);
- }
- }
- }
- break;
-
- case T_OBJECT:
- gc_ref_update_object(objspace, obj);
- break;
-
- case T_FILE:
- if (any->as.file.fptr) {
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->pathv);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->tied_io_for_writing);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->writeconv_asciicompat);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->writeconv_pre_ecopts);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->encs.ecopts);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->write_lock);
- }
- break;
- case T_REGEXP:
- UPDATE_IF_MOVED(objspace, any->as.regexp.src);
- break;
-
- case T_SYMBOL:
- if (DYNAMIC_SYM_P((VALUE)any)) {
- UPDATE_IF_MOVED(objspace, RSYMBOL(any)->fstr);
- }
- break;
-
- case T_FLOAT:
- case T_BIGNUM:
- break;
-
- case T_MATCH:
- UPDATE_IF_MOVED(objspace, any->as.match.regexp);
-
- if (any->as.match.str) {
- UPDATE_IF_MOVED(objspace, any->as.match.str);
- }
- break;
-
- case T_RATIONAL:
- UPDATE_IF_MOVED(objspace, any->as.rational.num);
- UPDATE_IF_MOVED(objspace, any->as.rational.den);
- break;
-
- case T_COMPLEX:
- UPDATE_IF_MOVED(objspace, any->as.complex.real);
- UPDATE_IF_MOVED(objspace, any->as.complex.imag);
-
- break;
-
- case T_STRUCT:
- {
- long i, len = RSTRUCT_LEN(obj);
- VALUE *ptr = (VALUE *)RSTRUCT_CONST_PTR(obj);
-
- for (i = 0; i < len; i++) {
- UPDATE_IF_MOVED(objspace, ptr[i]);
- }
- }
- break;
- default:
-#if GC_DEBUG
- rb_gcdebug_print_obj_condition((VALUE)obj);
- rb_obj_info_dump(obj);
- rb_bug("unreachable");
-#endif
- break;
-
- }
-
- UPDATE_IF_MOVED(objspace, RBASIC(obj)->klass);
-
- gc_report(4, objspace, "update-refs: %p <-", (void *)obj);
-}
-
-static int
-gc_ref_update(void *vstart, void *vend, size_t stride, void * data)
-{
- rb_objspace_t * objspace;
- struct heap_page *page;
- short free_slots = 0;
-
- VALUE v = (VALUE)vstart;
- objspace = (rb_objspace_t *)data;
- page = GET_HEAP_PAGE(v);
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
- page->freelist = NULL;
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
- page->flags.has_uncollectible_shady_objects = FALSE;
- page->flags.has_remembered_objects = FALSE;
-
- /* For each object on the page */
- for (; v != (VALUE)vend; v += stride) {
- if (!SPECIAL_CONST_P(v)) {
- void *poisoned = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
-
- switch (BUILTIN_TYPE(v)) {
- case T_NONE:
- heap_page_add_freeobj(objspace, page, v);
- free_slots++;
- break;
- case T_MOVED:
- break;
- case T_ZOMBIE:
- break;
- default:
- if (RVALUE_WB_UNPROTECTED(v)) {
- page->flags.has_uncollectible_shady_objects = TRUE;
- }
- if (RVALUE_PAGE_MARKING(page, v)) {
- page->flags.has_remembered_objects = TRUE;
- }
- gc_update_object_references(objspace, v);
- }
-
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(v) == T_NONE);
- asan_poison_object(v);
- }
- }
- }
-
- page->free_slots = free_slots;
- return 0;
-}
-
-extern rb_symbols_t ruby_global_symbols;
-#define global_symbols ruby_global_symbols
-
-static void
-gc_update_references(rb_objspace_t * objspace)
-{
- rb_execution_context_t *ec = GET_EC();
- rb_vm_t *vm = rb_ec_vm_ptr(ec);
-
- objspace_each_objects_without_setup(objspace, gc_ref_update, objspace);
- rb_vm_update_references(vm);
- rb_transient_heap_update_references();
- global_symbols.ids = rb_gc_location(global_symbols.ids);
- global_symbols.dsymbol_fstr_hash = rb_gc_location(global_symbols.dsymbol_fstr_hash);
- gc_update_tbl_refs(objspace, objspace->obj_to_id_tbl);
- gc_update_table_refs(objspace, objspace->id_to_obj_tbl);
- gc_update_table_refs(objspace, global_symbols.str_sym);
- gc_update_table_refs(objspace, finalizer_table);
-}
-
-static VALUE type_sym(size_t type);
-
-static VALUE
-gc_compact_stats(rb_objspace_t *objspace)
+Init_stack(volatile VALUE *addr)
{
- size_t i;
- VALUE h = rb_hash_new();
- VALUE considered = rb_hash_new();
- VALUE moved = rb_hash_new();
-
- for (i=0; i<T_MASK; i++) {
- rb_hash_aset(considered, type_sym(i), SIZET2NUM(objspace->rcompactor.considered_count_table[i]));
- }
-
- for (i=0; i<T_MASK; i++) {
- rb_hash_aset(moved, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_count_table[i]));
- }
-
- rb_hash_aset(h, ID2SYM(rb_intern("considered")), considered);
- rb_hash_aset(h, ID2SYM(rb_intern("moved")), moved);
-
- return h;
-}
-
-static void gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier);
-
-static void
-gc_compact(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier)
-{
-
- objspace->flags.during_compacting = TRUE;
- {
- /* pin objects referenced by maybe pointers */
- garbage_collect(objspace, GPR_DEFAULT_REASON);
- /* compact */
- gc_compact_after_gc(objspace, use_toward_empty, use_double_pages, use_verifier);
- }
- objspace->flags.during_compacting = FALSE;
-}
-
-static VALUE
-rb_gc_compact(rb_execution_context_t *ec, VALUE self)
-{
- rb_objspace_t *objspace = &rb_objspace;
- if (dont_gc) return Qnil;
-
- gc_compact(objspace, FALSE, FALSE, FALSE);
- return gc_compact_stats(objspace);
-}
-
-static void
-root_obj_check_moved_i(const char *category, VALUE obj, void *data)
-{
- if (gc_object_moved_p(&rb_objspace, obj)) {
- rb_bug("ROOT %s points to MOVED: %p -> %s\n", category, (void *)obj, obj_info(rb_gc_location(obj)));
- }
-}
-
-static void
-reachable_object_check_moved_i(VALUE ref, void *data)
-{
- VALUE parent = (VALUE)data;
- if (gc_object_moved_p(&rb_objspace, ref)) {
- rb_bug("Object %s points to MOVED: %p -> %s\n", obj_info(parent), (void *)ref, obj_info(rb_gc_location(ref)));
- }
-}
-
-static int
-heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)
-{
- VALUE v = (VALUE)vstart;
- for (; v != (VALUE)vend; v += stride) {
- if (gc_object_moved_p(&rb_objspace, v)) {
- /* Moved object still on the heap, something may have a reference. */
- }
- else {
- void *poisoned = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
-
- switch (BUILTIN_TYPE(v)) {
- case T_NONE:
- case T_ZOMBIE:
- break;
- default:
- rb_objspace_reachable_objects_from(v, reachable_object_check_moved_i, (void *)v);
- }
-
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(v) == T_NONE);
- asan_poison_object(v);
- }
- }
- }
-
- return 0;
-}
-
-static VALUE
-gc_check_references_for_moved(rb_objspace_t *objspace)
-{
- objspace_reachable_objects_from_root(objspace, root_obj_check_moved_i, NULL);
- objspace_each_objects(objspace, heap_check_moved_i, NULL);
- return Qnil;
-}
-
-static void
-gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier)
-{
- if (0) fprintf(stderr, "gc_compact_after_gc: %d,%d,%d\n", use_toward_empty, use_double_pages, use_verifier);
-
- mjit_gc_start_hook(); // prevent MJIT from running while moving pointers related to ISeq
-
- objspace->profile.compact_count++;
-
- if (use_verifier) {
- gc_verify_internal_consistency(objspace);
- }
-
- if (use_double_pages) {
- /* Double heap size */
- heap_add_pages(objspace, heap_eden, heap_allocated_pages);
- }
-
- VALUE moved_list_head;
- VALUE disabled = rb_objspace_gc_disable(objspace);
-
- if (use_toward_empty) {
- moved_list_head = gc_compact_heap(objspace, compare_free_slots);
- }
- else {
- moved_list_head = gc_compact_heap(objspace, compare_pinned);
- }
- heap_eden->freelist = NULL;
-
- gc_update_references(objspace);
- if (!RTEST(disabled)) rb_objspace_gc_enable(objspace);
-
- if (use_verifier) {
- gc_check_references_for_moved(objspace);
- }
-
- rb_clear_method_cache_by_class(rb_cObject);
- rb_clear_constant_cache();
- heap_eden->free_pages = NULL;
- heap_eden->using_page = NULL;
-
- /* For each moved slot */
- while (moved_list_head) {
- VALUE next_moved;
- struct heap_page *page;
-
- page = GET_HEAP_PAGE(moved_list_head);
- next_moved = RMOVED(moved_list_head)->next;
-
- /* clear the memory for that moved slot */
- RMOVED(moved_list_head)->flags = 0;
- RMOVED(moved_list_head)->destination = 0;
- RMOVED(moved_list_head)->next = 0;
- page->free_slots++;
- heap_page_add_freeobj(objspace, page, moved_list_head);
-
- if (page->free_slots == page->total_slots && heap_pages_freeable_pages > 0) {
- heap_pages_freeable_pages--;
- heap_unlink_page(objspace, heap_eden, page);
- heap_add_page(objspace, heap_tomb, page);
- }
- objspace->profile.total_freed_objects++;
- moved_list_head = next_moved;
- }
-
- /* Add any eden pages with free slots back to the free pages list */
- struct heap_page *page = NULL;
- list_for_each(&heap_eden->pages, page, page_node) {
- if (page->free_slots > 0) {
- heap_add_freepage(heap_eden, page);
- } else {
- page->free_next = NULL;
- }
- }
-
- /* Set up "using_page" if we have any pages with free slots */
- if (heap_eden->free_pages) {
- heap_eden->using_page = heap_eden->free_pages;
- heap_eden->free_pages = heap_eden->free_pages->free_next;
- }
-
- if (use_verifier) {
- gc_verify_internal_consistency(objspace);
- }
-
- mjit_gc_exit_hook(); // unlock MJIT here, because `rb_gc()` calls `mjit_gc_start_hook()` again.
+ ruby_init_stack(addr);
}
/*
* call-seq:
- * GC.verify_compaction_references(toward: nil, double_heap: nil) -> nil
+ * GC.start -> nil
+ * ObjectSpace.garbage_collect -> nil
+ * include GC; garbage_collect -> nil
+ * GC.start(full_mark: true, immediate_sweep: true) -> nil
+ * ObjectSpace.garbage_collect(full_mark: true, immediate_sweep: true) -> nil
+ * include GC; garbage_collect(full_mark: true, immediate_sweep: true) -> nil
+ *
+ * Initiates garbage collection, unless manually disabled.
+ *
+ * This method is defined with keyword arguments that default to true:
*
- * Verify compaction reference consistency.
+ * def GC.start(full_mark: true, immediate_sweep: true); end
*
- * This method is implementation specific. During compaction, objects that
- * were moved are replaced with T_MOVED objects. No object should have a
- * reference to a T_MOVED object after compaction.
+ * Use full_mark: false to perform a minor GC.
+ * Use immediate_sweep: false to defer sweeping (use lazy sweep).
*
- * This function doubles the heap to ensure room to move all objects,
- * compacts the heap to make sure everything moves, updates all references,
- * then performs a full GC. If any object contains a reference to a T_MOVED
- * object, that object should be pushed on the mark stack, and will
- * make a SEGV.
+ * Note: These keyword arguments are implementation and version dependent. They
+ * are not guaranteed to be future-compatible, and may be ignored if the
+ * underlying implementation does not support them.
*/
+
static VALUE
-gc_verify_compaction_references(int argc, VALUE *argv, VALUE mod)
+gc_start_internal(int argc, VALUE *argv, VALUE self)
{
rb_objspace_t *objspace = &rb_objspace;
- int use_toward_empty = FALSE;
- int use_double_pages = FALSE;
-
- if (dont_gc) return Qnil;
-
+ int full_mark = TRUE, immediate_mark = TRUE, immediate_sweep = TRUE;
VALUE opt = Qnil;
- static ID keyword_ids[2];
- VALUE kwvals[2];
-
- kwvals[1] = Qtrue;
+ static ID keyword_ids[3];
rb_scan_args(argc, argv, "0:", &opt);
if (!NIL_P(opt)) {
- if (!keyword_ids[0]) {
- keyword_ids[0] = rb_intern("toward");
- keyword_ids[1] = rb_intern("double_heap");
- }
+ VALUE kwvals[3];
- rb_get_kwargs(opt, keyword_ids, 0, 2, kwvals);
- if (kwvals[0] != Qundef && rb_intern("empty") == rb_sym2id(kwvals[0])) {
- use_toward_empty = TRUE;
- }
- if (kwvals[1] != Qundef && RTEST(kwvals[1])) {
- use_double_pages = TRUE;
- }
+ if (!keyword_ids[0]) {
+ keyword_ids[0] = rb_intern("full_mark");
+ keyword_ids[1] = rb_intern("immediate_mark");
+ keyword_ids[2] = rb_intern("immediate_sweep");
+ }
+
+ rb_get_kwargs(opt, keyword_ids, 0, 3, kwvals);
+
+ if (kwvals[0] != Qundef) full_mark = RTEST(kwvals[0]);
+ if (kwvals[1] != Qundef) immediate_mark = RTEST(kwvals[1]);
+ if (kwvals[2] != Qundef) immediate_sweep = RTEST(kwvals[2]);
}
- gc_compact(objspace, use_toward_empty, use_double_pages, TRUE);
- return gc_compact_stats(objspace);
+ garbage_collect(objspace, full_mark, immediate_mark, immediate_sweep, GPR_FLAG_METHOD);
+ gc_finalize_deferred(objspace);
+
+ return Qnil;
}
VALUE
@@ -8695,8 +6736,8 @@ void
rb_gc(void)
{
rb_objspace_t *objspace = &rb_objspace;
- int reason = GPR_DEFAULT_REASON;
- garbage_collect(objspace, reason);
+ garbage_collect(objspace, TRUE, TRUE, TRUE, GPR_FLAG_CAPI);
+ gc_finalize_deferred(objspace);
}
int
@@ -8716,8 +6757,8 @@ gc_count_add_each_types(VALUE hash, const char *name, const size_t *types)
VALUE result = rb_hash_new_with_size(T_MASK);
int i;
for (i=0; i<T_MASK; i++) {
- const char *type = type_name(i, 0);
- rb_hash_aset(result, ID2SYM(rb_intern(type)), SIZET2NUM(types[i]));
+ const char *type = type_name(i, 0);
+ rb_hash_aset(result, ID2SYM(rb_intern(type)), SIZET2NUM(types[i]));
}
rb_hash_aset(hash, ID2SYM(rb_intern(name)), result);
}
@@ -8729,8 +6770,18 @@ rb_gc_count(void)
return rb_objspace.profile.count;
}
+/*
+ * call-seq:
+ * GC.count -> Integer
+ *
+ * The number of times GC occurred.
+ *
+ * It returns the number of times GC occurred since the process started.
+ *
+ */
+
static VALUE
-gc_count(rb_execution_context_t *ec, VALUE self)
+gc_count(VALUE self)
{
return SIZET2NUM(rb_gc_count());
}
@@ -8750,47 +6801,47 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const int orig_
VALUE flags = orig_flags ? orig_flags : objspace->profile.latest_gc_info;
if (SYMBOL_P(hash_or_key)) {
- key = hash_or_key;
+ key = hash_or_key;
}
else if (RB_TYPE_P(hash_or_key, T_HASH)) {
- hash = hash_or_key;
+ hash = hash_or_key;
}
else {
- rb_raise(rb_eTypeError, "non-hash or symbol given");
+ rb_raise(rb_eTypeError, "non-hash or symbol given");
}
if (sym_major_by == Qnil) {
#define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
- S(major_by);
- S(gc_by);
- S(immediate_sweep);
- S(have_finalizer);
- S(state);
-
- S(stress);
- S(nofree);
- S(oldgen);
- S(shady);
- S(force);
+ S(major_by);
+ S(gc_by);
+ S(immediate_sweep);
+ S(have_finalizer);
+ S(state);
+
+ S(stress);
+ S(nofree);
+ S(oldgen);
+ S(shady);
+ S(force);
#if RGENGC_ESTIMATE_OLDMALLOC
- S(oldmalloc);
+ S(oldmalloc);
#endif
- S(newobj);
- S(malloc);
- S(method);
- S(capi);
+ S(newobj);
+ S(malloc);
+ S(method);
+ S(capi);
- S(none);
- S(marking);
- S(sweeping);
+ S(none);
+ S(marking);
+ S(sweeping);
#undef S
}
#define SET(name, attr) \
if (key == sym_##name) \
- return (attr); \
+ return (attr); \
else if (hash != Qnil) \
- rb_hash_aset(hash, sym_##name, (attr));
+ rb_hash_aset(hash, sym_##name, (attr));
major_by =
(flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
@@ -8804,25 +6855,25 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const int orig_
SET(major_by, major_by);
SET(gc_by,
- (flags & GPR_FLAG_NEWOBJ) ? sym_newobj :
- (flags & GPR_FLAG_MALLOC) ? sym_malloc :
- (flags & GPR_FLAG_METHOD) ? sym_method :
- (flags & GPR_FLAG_CAPI) ? sym_capi :
- (flags & GPR_FLAG_STRESS) ? sym_stress :
- Qnil
+ (flags & GPR_FLAG_NEWOBJ) ? sym_newobj :
+ (flags & GPR_FLAG_MALLOC) ? sym_malloc :
+ (flags & GPR_FLAG_METHOD) ? sym_method :
+ (flags & GPR_FLAG_CAPI) ? sym_capi :
+ (flags & GPR_FLAG_STRESS) ? sym_stress :
+ Qnil
);
SET(have_finalizer, (flags & GPR_FLAG_HAVE_FINALIZE) ? Qtrue : Qfalse);
SET(immediate_sweep, (flags & GPR_FLAG_IMMEDIATE_SWEEP) ? Qtrue : Qfalse);
if (orig_flags == 0) {
- SET(state, gc_mode(objspace) == gc_mode_none ? sym_none :
- gc_mode(objspace) == gc_mode_marking ? sym_marking : sym_sweeping);
+ SET(state, gc_mode(objspace) == gc_mode_none ? sym_none :
+ gc_mode(objspace) == gc_mode_marking ? sym_marking : sym_sweeping);
}
#undef SET
if (!NIL_P(key)) {/* matched key should return above */
- rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
+ rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
}
return hash;
@@ -8835,16 +6886,29 @@ rb_gc_latest_gc_info(VALUE key)
return gc_info_decode(objspace, key, 0);
}
+/*
+ * call-seq:
+ * GC.latest_gc_info -> {:gc_by=>:newobj}
+ * GC.latest_gc_info(hash) -> hash
+ * GC.latest_gc_info(:major_by) -> :malloc
+ *
+ * Returns information about the most recent garbage collection.
+ */
+
static VALUE
-gc_latest_gc_info(rb_execution_context_t *ec, VALUE self, VALUE arg)
+gc_latest_gc_info(int argc, VALUE *argv, VALUE self)
{
rb_objspace_t *objspace = &rb_objspace;
+ VALUE arg = Qnil;
- if (NIL_P(arg)) {
- arg = rb_hash_new();
+ if (rb_scan_args(argc, argv, "01", &arg) == 1) {
+ if (!SYMBOL_P(arg) && !RB_TYPE_P(arg, T_HASH)) {
+ rb_raise(rb_eTypeError, "non-hash or symbol given");
+ }
}
- else if (!SYMBOL_P(arg) && !RB_TYPE_P(arg, T_HASH)) {
- rb_raise(rb_eTypeError, "non-hash or symbol given");
+
+ if (arg == Qnil) {
+ arg = rb_hash_new();
}
return gc_info_decode(objspace, arg, 0);
@@ -8871,7 +6935,6 @@ enum gc_stat_sym {
#if USE_RGENGC
gc_stat_sym_minor_gc_count,
gc_stat_sym_major_gc_count,
- gc_stat_sym_compact_count,
gc_stat_sym_remembered_wb_unprotected_objects,
gc_stat_sym_remembered_wb_unprotected_objects_limit,
gc_stat_sym_old_objects,
@@ -8948,7 +7011,6 @@ setup_gc_stat_symbols(void)
#if USE_RGENGC
S(minor_gc_count);
S(major_gc_count);
- S(compact_count);
S(remembered_wb_unprotected_objects);
S(remembered_wb_unprotected_objects_limit);
S(old_objects);
@@ -9050,7 +7112,7 @@ compat_key(VALUE key)
}
static VALUE
-default_proc_for_compat_func(RB_BLOCK_CALL_FUNC_ARGLIST(hash, _))
+default_proc_for_compat_func(VALUE hash, VALUE dmy, int argc, VALUE *argv)
{
VALUE key, new_key;
@@ -9121,7 +7183,6 @@ gc_stat_internal(VALUE hash_or_sym)
#if USE_RGENGC
SET(minor_gc_count, objspace->profile.minor_gc_count);
SET(major_gc_count, objspace->profile.major_gc_count);
- SET(compact_count, objspace->profile.compact_count);
SET(remembered_wb_unprotected_objects, objspace->rgengc.uncollectible_wb_unprotected_objects);
SET(remembered_wb_unprotected_objects_limit, objspace->rgengc.uncollectible_wb_unprotected_objects_limit);
SET(old_objects, objspace->rgengc.old_objects);
@@ -9165,23 +7226,69 @@ gc_stat_internal(VALUE hash_or_sym)
return 0;
}
+/*
+ * call-seq:
+ * GC.stat -> Hash
+ * GC.stat(hash) -> hash
+ * GC.stat(:key) -> Numeric
+ *
+ * Returns a Hash containing information about the GC.
+ *
+ * The hash includes information about internal statistics about GC such as:
+ *
+ * {
+ * :count=>0,
+ * :heap_allocated_pages=>24,
+ * :heap_sorted_length=>24,
+ * :heap_allocatable_pages=>0,
+ * :heap_available_slots=>9783,
+ * :heap_live_slots=>7713,
+ * :heap_free_slots=>2070,
+ * :heap_final_slots=>0,
+ * :heap_marked_slots=>0,
+ * :heap_eden_pages=>24,
+ * :heap_tomb_pages=>0,
+ * :total_allocated_pages=>24,
+ * :total_freed_pages=>0,
+ * :total_allocated_objects=>7796,
+ * :total_freed_objects=>83,
+ * :malloc_increase_bytes=>2389312,
+ * :malloc_increase_bytes_limit=>16777216,
+ * :minor_gc_count=>0,
+ * :major_gc_count=>0,
+ * :remembered_wb_unprotected_objects=>0,
+ * :remembered_wb_unprotected_objects_limit=>0,
+ * :old_objects=>0,
+ * :old_objects_limit=>0,
+ * :oldmalloc_increase_bytes=>2389760,
+ * :oldmalloc_increase_bytes_limit=>16777216
+ * }
+ *
+ * The contents of the hash are implementation specific and may be changed in
+ * the future.
+ *
+ * This method is only expected to work on C Ruby.
+ *
+ */
+
static VALUE
-gc_stat(rb_execution_context_t *ec, VALUE self, VALUE arg) // arg is (nil || hash || symbol)
+gc_stat(int argc, VALUE *argv, VALUE self)
{
- if (NIL_P(arg)) {
- arg = rb_hash_new();
- }
- else if (SYMBOL_P(arg)) {
- size_t value = gc_stat_internal(arg);
- return SIZET2NUM(value);
- }
- else if (RB_TYPE_P(arg, T_HASH)) {
- // ok
- }
- else {
- rb_raise(rb_eTypeError, "non-hash or symbol given");
+ VALUE arg = Qnil;
+
+ if (rb_scan_args(argc, argv, "01", &arg) == 1) {
+ if (SYMBOL_P(arg)) {
+ size_t value = gc_stat_internal(arg);
+ return SIZET2NUM(value);
+ }
+ else if (!RB_TYPE_P(arg, T_HASH)) {
+ rb_raise(rb_eTypeError, "non-hash or symbol given");
+ }
}
+ if (arg == Qnil) {
+ arg = rb_hash_new();
+ }
gc_stat_internal(arg);
return arg;
}
@@ -9199,8 +7306,15 @@ rb_gc_stat(VALUE key)
}
}
+/*
+ * call-seq:
+ * GC.stress -> integer, true or false
+ *
+ * Returns current status of GC stress mode.
+ */
+
static VALUE
-gc_stress_get(rb_execution_context_t *ec, VALUE self)
+gc_stress_get(VALUE self)
{
rb_objspace_t *objspace = &rb_objspace;
return ruby_gc_stress_mode;
@@ -9213,69 +7327,76 @@ gc_stress_set(rb_objspace_t *objspace, VALUE flag)
objspace->gc_stress_mode = flag;
}
+/*
+ * call-seq:
+ * GC.stress = flag -> flag
+ *
+ * Updates the GC stress mode.
+ *
+ * When stress mode is enabled, the GC is invoked at every GC opportunity:
+ * all memory and object allocations.
+ *
+ * Enabling stress mode will degrade performance, it is only for debugging.
+ *
+ * flag can be true, false, or an integer bit-ORed following flags.
+ * 0x01:: no major GC
+ * 0x02:: no immediate sweep
+ * 0x04:: full mark after malloc/calloc/realloc
+ */
+
static VALUE
-gc_stress_set_m(rb_execution_context_t *ec, VALUE self, VALUE flag)
+gc_stress_set_m(VALUE self, VALUE flag)
{
rb_objspace_t *objspace = &rb_objspace;
gc_stress_set(objspace, flag);
return flag;
}
+/*
+ * call-seq:
+ * GC.enable -> true or false
+ *
+ * Enables garbage collection, returning +true+ if garbage
+ * collection was previously disabled.
+ *
+ * GC.disable #=> false
+ * GC.enable #=> true
+ * GC.enable #=> false
+ *
+ */
+
VALUE
rb_gc_enable(void)
{
rb_objspace_t *objspace = &rb_objspace;
- return rb_objspace_gc_enable(objspace);
-}
-
-VALUE
-rb_objspace_gc_enable(rb_objspace_t *objspace)
-{
int old = dont_gc;
dont_gc = FALSE;
return old ? Qtrue : Qfalse;
}
-static VALUE
-gc_enable(rb_execution_context_t *ec, VALUE _)
-{
- return rb_gc_enable();
-}
-
-VALUE
-rb_gc_disable_no_rest(void)
-{
- rb_objspace_t *objspace = &rb_objspace;
- return gc_disable_no_rest(objspace);
-}
-
-static VALUE
-gc_disable_no_rest(rb_objspace_t *objspace)
-{
- int old = dont_gc;
- dont_gc = TRUE;
- return old ? Qtrue : Qfalse;
-}
+/*
+ * call-seq:
+ * GC.disable -> true or false
+ *
+ * Disables garbage collection, returning +true+ if garbage
+ * collection was already disabled.
+ *
+ * GC.disable #=> false
+ * GC.disable #=> true
+ *
+ */
VALUE
rb_gc_disable(void)
{
rb_objspace_t *objspace = &rb_objspace;
- return rb_objspace_gc_disable(objspace);
-}
+ int old = dont_gc;
-VALUE
-rb_objspace_gc_disable(rb_objspace_t *objspace)
-{
gc_rest(objspace);
- return gc_disable_no_rest(objspace);
-}
-static VALUE
-gc_disable(rb_execution_context_t *ec, VALUE _)
-{
- return rb_gc_disable();
+ dont_gc = TRUE;
+ return old ? Qtrue : Qfalse;
}
static int
@@ -9431,8 +7552,10 @@ gc_set_initial_pages(void)
*/
void
-ruby_gc_set_params(void)
+ruby_gc_set_params(int safe_level)
{
+ if (safe_level > 0) return;
+
/* RUBY_GC_HEAP_FREE_SLOTS */
if (get_envparam_size("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0)) {
/* ok */
@@ -9462,9 +7585,6 @@ ruby_gc_set_params(void)
get_envparam_size ("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0);
get_envparam_size ("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);
- if (!gc_params.malloc_limit_max) { /* ignore max-check if 0 */
- gc_params.malloc_limit_max = SIZE_MAX;
- }
get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0, 0.0, FALSE);
#if RGENGC_ESTIMATE_OLDMALLOC
@@ -9509,12 +7629,6 @@ void
rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *passing_data)
{
rb_objspace_t *objspace = &rb_objspace;
- objspace_reachable_objects_from_root(objspace, func, passing_data);
-}
-
-static void
-objspace_reachable_objects_from_root(rb_objspace_t *objspace, void (func)(const char *category, VALUE, void *), void *passing_data)
-{
struct root_objects_data data;
struct mark_func_data_struct mfd;
@@ -9533,53 +7647,30 @@ objspace_reachable_objects_from_root(rb_objspace_t *objspace, void (func)(const
------------------------ Extended allocator ------------------------
*/
-struct gc_raise_tag {
- VALUE exc;
- const char *fmt;
- va_list *ap;
-};
+static void objspace_xfree(rb_objspace_t *objspace, void *ptr, size_t size);
static void *
-gc_vraise(void *ptr)
+negative_size_allocation_error_with_gvl(void *ptr)
{
- struct gc_raise_tag *argv = ptr;
- rb_vraise(argv->exc, argv->fmt, *argv->ap);
- UNREACHABLE_RETURN(NULL);
+ rb_raise(rb_eNoMemError, "%s", (const char *)ptr);
+ return 0; /* should not be reached */
}
static void
-gc_raise(VALUE exc, const char *fmt, ...)
+negative_size_allocation_error(const char *msg)
{
- va_list ap;
- va_start(ap, fmt);
- struct gc_raise_tag argv = {
- exc, fmt, &ap,
- };
-
if (ruby_thread_has_gvl_p()) {
- gc_vraise(&argv);
- UNREACHABLE;
- }
- else if (ruby_native_thread_p()) {
- rb_thread_call_with_gvl(gc_vraise, &argv);
- UNREACHABLE;
+ rb_raise(rb_eNoMemError, "%s", msg);
}
else {
- /* Not in a ruby thread */
- fprintf(stderr, "%s", "[FATAL] ");
- vfprintf(stderr, fmt, ap);
- abort();
+ if (ruby_native_thread_p()) {
+ rb_thread_call_with_gvl(negative_size_allocation_error_with_gvl, (void *)msg);
+ }
+ else {
+ fprintf(stderr, "[FATAL] %s\n", msg);
+ exit(EXIT_FAILURE);
+ }
}
-
- va_end(ap);
-}
-
-static void objspace_xfree(rb_objspace_t *objspace, void *ptr, size_t size);
-
-static void
-negative_size_allocation_error(const char *msg)
-{
- gc_raise(rb_eNoMemError, "%s", msg);
}
static void *
@@ -9614,12 +7705,6 @@ rb_memerror(void)
rb_objspace_t *objspace = rb_objspace_of(rb_ec_vm_ptr(ec));
VALUE exc;
- if (0) {
- // Print out pid, sleep, so you can attach debugger to see what went wrong:
- fprintf(stderr, "rb_memerror pid=%"PRI_PIDT_PREFIX"d\n", getpid());
- sleep(60);
- }
-
if (during_gc) gc_exit(objspace, "rb_memerror");
exc = nomem_error;
@@ -9639,8 +7724,8 @@ rb_memerror(void)
EC_JUMP_TAG(ec, TAG_RAISE);
}
-void *
-rb_aligned_malloc(size_t alignment, size_t size)
+static void *
+aligned_malloc(size_t alignment, size_t size)
{
void *res;
@@ -9674,7 +7759,7 @@ rb_aligned_malloc(size_t alignment, size_t size)
}
static void
-rb_aligned_free(void *ptr)
+aligned_free(void *ptr)
{
#if defined __MINGW32__
__mingw_aligned_free(ptr);
@@ -9698,9 +7783,9 @@ objspace_malloc_size(rb_objspace_t *objspace, void *ptr, size_t hint)
}
enum memop_type {
- MEMOP_TYPE_MALLOC = 0,
- MEMOP_TYPE_FREE,
- MEMOP_TYPE_REALLOC
+ MEMOP_TYPE_MALLOC = 1,
+ MEMOP_TYPE_FREE = 2,
+ MEMOP_TYPE_REALLOC = 3
};
static inline void
@@ -9719,13 +7804,7 @@ static void
objspace_malloc_gc_stress(rb_objspace_t *objspace)
{
if (ruby_gc_stressful && ruby_native_thread_p()) {
- int reason = GPR_FLAG_IMMEDIATE_MARK | GPR_FLAG_IMMEDIATE_SWEEP |
- GPR_FLAG_STRESS | GPR_FLAG_MALLOC;
-
- if (gc_stress_full_mark_after_malloc_p()) {
- reason |= GPR_FLAG_FULL_MARK;
- }
- garbage_collect_with_gvl(objspace, reason);
+ garbage_collect_with_gvl(objspace, gc_stress_full_mark_after_malloc_p(), TRUE, TRUE, GPR_FLAG_STRESS | GPR_FLAG_MALLOC);
}
}
@@ -9752,7 +7831,7 @@ objspace_malloc_increase(rb_objspace_t *objspace, void *mem, size_t new_size, si
gc_rest(objspace); /* gc_rest can reduce malloc_increase */
goto retry;
}
- garbage_collect_with_gvl(objspace, GPR_FLAG_MALLOC);
+ garbage_collect_with_gvl(objspace, FALSE, FALSE, FALSE, GPR_FLAG_MALLOC);
}
}
@@ -9801,27 +7880,13 @@ objspace_malloc_increase(rb_objspace_t *objspace, void *mem, size_t new_size, si
#endif
}
-struct malloc_obj_info { /* 4 words */
- size_t size;
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- size_t gen;
- const char *file;
- size_t line;
-#endif
-};
-
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
-const char *ruby_malloc_info_file;
-int ruby_malloc_info_line;
-#endif
-
static inline size_t
objspace_malloc_prepare(rb_objspace_t *objspace, size_t size)
{
if (size == 0) size = 1;
#if CALC_EXACT_MALLOC_SIZE
- size += sizeof(struct malloc_obj_info);
+ size += sizeof(size_t);
#endif
return size;
@@ -9834,18 +7899,8 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
objspace_malloc_increase(objspace, mem, size, 0, MEMOP_TYPE_MALLOC);
#if CALC_EXACT_MALLOC_SIZE
- {
- struct malloc_obj_info *info = mem;
- info->size = size;
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- info->gen = objspace->profile.count;
- info->file = ruby_malloc_info_file;
- info->line = info->file ? ruby_malloc_info_line : 0;
-#else
- info->file = NULL;
-#endif
- mem = info + 1;
- }
+ ((size_t *)mem)[0] = size;
+ mem = (size_t *)mem + 1;
#endif
return mem;
@@ -9854,9 +7909,7 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
#define TRY_WITH_GC(alloc) do { \
objspace_malloc_gc_stress(objspace); \
if (!(alloc) && \
- (!garbage_collect_with_gvl(objspace, GPR_FLAG_FULL_MARK | \
- GPR_FLAG_IMMEDIATE_MARK | GPR_FLAG_IMMEDIATE_SWEEP | \
- GPR_FLAG_MALLOC) || \
+ (!garbage_collect_with_gvl(objspace, TRUE, TRUE, TRUE, GPR_FLAG_MALLOC) || /* full/immediate mark && immediate sweep */ \
!(alloc))) { \
ruby_memerror(); \
} \
@@ -9872,14 +7925,17 @@ objspace_xmalloc0(rb_objspace_t *objspace, size_t size)
size = objspace_malloc_prepare(objspace, size);
TRY_WITH_GC(mem = malloc(size));
- RB_DEBUG_COUNTER_INC(heap_xmalloc);
return objspace_malloc_fixup(objspace, mem, size);
}
static inline size_t
xmalloc2_size(const size_t count, const size_t elsize)
{
- return size_mul_or_raise(count, elsize, rb_eArgError);
+ size_t ret;
+ if (rb_mul_size_overflow(count, elsize, SSIZE_MAX, &ret)) {
+ ruby_malloc_size_overflow(count, elsize);
+ }
+ return ret;
}
static void *
@@ -9895,50 +7951,14 @@ objspace_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t ol
* see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_400.htm
*/
if (new_size == 0) {
- if ((mem = objspace_xmalloc0(objspace, 0)) != NULL) {
- /*
- * - OpenBSD's malloc(3) man page says that when 0 is passed, it
- * returns a non-NULL pointer to an access-protected memory page.
- * The returned pointer cannot be read / written at all, but
- * still be a valid argument of free().
- *
- * https://man.openbsd.org/malloc.3
- *
- * - Linux's malloc(3) man page says that it _might_ perhaps return
- * a non-NULL pointer when its argument is 0. That return value
- * is safe (and is expected) to be passed to free().
- *
- * http://man7.org/linux/man-pages/man3/malloc.3.html
- *
- * - As I read the implementation jemalloc's malloc() returns fully
- * normal 16 bytes memory region when its argument is 0.
- *
- * - As I read the implementation musl libc's malloc() returns
- * fully normal 32 bytes memory region when its argument is 0.
- *
- * - Other malloc implementations can also return non-NULL.
- */
- objspace_xfree(objspace, ptr, old_size);
- return mem;
- }
- else {
- /*
- * It is dangerous to return NULL here, because that could lead to
- * RCE. Fallback to 1 byte instead of zero.
- *
- * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-11932
- */
- new_size = 1;
- }
+ objspace_xfree(objspace, ptr, old_size);
+ return 0;
}
#if CALC_EXACT_MALLOC_SIZE
- {
- struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
- new_size += sizeof(struct malloc_obj_info);
- ptr = info;
- old_size = info->size;
- }
+ new_size += sizeof(size_t);
+ ptr = (size_t *)ptr - 1;
+ old_size = ((size_t *)ptr)[0];
#endif
old_size = objspace_malloc_size(objspace, ptr, old_size);
@@ -9946,144 +7966,25 @@ objspace_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t ol
new_size = objspace_malloc_size(objspace, mem, new_size);
#if CALC_EXACT_MALLOC_SIZE
- {
- struct malloc_obj_info *info = mem;
- info->size = new_size;
- mem = info + 1;
- }
+ ((size_t *)mem)[0] = new_size;
+ mem = (size_t *)mem + 1;
#endif
objspace_malloc_increase(objspace, mem, new_size, old_size, MEMOP_TYPE_REALLOC);
- RB_DEBUG_COUNTER_INC(heap_xrealloc);
return mem;
}
-#if CALC_EXACT_MALLOC_SIZE && USE_GC_MALLOC_OBJ_INFO_DETAILS
-
-#define MALLOC_INFO_GEN_SIZE 100
-#define MALLOC_INFO_SIZE_SIZE 10
-static size_t malloc_info_gen_cnt[MALLOC_INFO_GEN_SIZE];
-static size_t malloc_info_gen_size[MALLOC_INFO_GEN_SIZE];
-static size_t malloc_info_size[MALLOC_INFO_SIZE_SIZE+1];
-static st_table *malloc_info_file_table;
-
-static int
-mmalloc_info_file_i(st_data_t key, st_data_t val, st_data_t dmy)
-{
- const char *file = (void *)key;
- const size_t *data = (void *)val;
-
- fprintf(stderr, "%s\t%d\t%d\n", file, (int)data[0], (int)data[1]);
-
- return ST_CONTINUE;
-}
-
-__attribute__((destructor))
-void
-rb_malloc_info_show_results(void)
-{
- int i;
-
- fprintf(stderr, "* malloc_info gen statistics\n");
- for (i=0; i<MALLOC_INFO_GEN_SIZE; i++) {
- if (i == MALLOC_INFO_GEN_SIZE-1) {
- fprintf(stderr, "more\t%d\t%d\n", (int)malloc_info_gen_cnt[i], (int)malloc_info_gen_size[i]);
- }
- else {
- fprintf(stderr, "%d\t%d\t%d\n", i, (int)malloc_info_gen_cnt[i], (int)malloc_info_gen_size[i]);
- }
- }
-
- fprintf(stderr, "* malloc_info size statistics\n");
- for (i=0; i<MALLOC_INFO_SIZE_SIZE; i++) {
- int s = 16 << i;
- fprintf(stderr, "%d\t%d\n", (int)s, (int)malloc_info_size[i]);
- }
- fprintf(stderr, "more\t%d\n", (int)malloc_info_size[i]);
-
- if (malloc_info_file_table) {
- fprintf(stderr, "* malloc_info file statistics\n");
- st_foreach(malloc_info_file_table, mmalloc_info_file_i, 0);
- }
-}
-#else
-void
-rb_malloc_info_show_results(void)
-{
-}
-#endif
-
static void
objspace_xfree(rb_objspace_t *objspace, void *ptr, size_t old_size)
{
- if (!ptr) {
- /*
- * ISO/IEC 9899 says "If ptr is a null pointer, no action occurs" since
- * its first version. We would better follow.
- */
- return;
- }
#if CALC_EXACT_MALLOC_SIZE
- struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
- ptr = info;
- old_size = info->size;
-
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- {
- int gen = (int)(objspace->profile.count - info->gen);
- int gen_index = gen >= MALLOC_INFO_GEN_SIZE ? MALLOC_INFO_GEN_SIZE-1 : gen;
- int i;
-
- malloc_info_gen_cnt[gen_index]++;
- malloc_info_gen_size[gen_index] += info->size;
-
- for (i=0; i<MALLOC_INFO_SIZE_SIZE; i++) {
- size_t s = 16 << i;
- if (info->size <= s) {
- malloc_info_size[i]++;
- goto found;
- }
- }
- malloc_info_size[i]++;
- found:;
-
- {
- st_data_t key = (st_data_t)info->file;
- size_t *data;
-
- if (malloc_info_file_table == NULL) {
- malloc_info_file_table = st_init_numtable_with_size(1024);
- }
- if (st_lookup(malloc_info_file_table, key, (st_data_t *)&data)) {
- /* hit */
- }
- else {
- data = malloc(xmalloc2_size(2, sizeof(size_t)));
- if (data == NULL) rb_bug("objspace_xfree: can not allocate memory");
- data[0] = data[1] = 0;
- st_insert(malloc_info_file_table, key, (st_data_t)data);
- }
- data[0] ++;
- data[1] += info->size;
- };
-#if 0 /* verbose output */
- if (gen >= 2) {
- if (info->file) {
- fprintf(stderr, "free - size:%d, gen:%d, pos: %s:%d\n", (int)info->size, gen, info->file, (int)info->line);
- }
- else {
- fprintf(stderr, "free - size:%d, gen:%d\n", (int)info->size, gen);
- }
- }
-#endif
- }
-#endif
+ ptr = ((size_t *)ptr) - 1;
+ old_size = ((size_t*)ptr)[0];
#endif
old_size = objspace_malloc_size(objspace, ptr, old_size);
free(ptr);
- RB_DEBUG_COUNTER_INC(heap_xfree);
objspace_malloc_increase(objspace, ptr, 0, old_size, MEMOP_TYPE_FREE);
}
@@ -10095,7 +7996,7 @@ ruby_xmalloc0(size_t size)
}
void *
-ruby_xmalloc_body(size_t size)
+ruby_xmalloc(size_t size)
{
if ((ssize_t)size < 0) {
negative_size_allocation_error("too large allocation size");
@@ -10112,7 +8013,7 @@ ruby_malloc_size_overflow(size_t count, size_t elsize)
}
void *
-ruby_xmalloc2_body(size_t n, size_t size)
+ruby_xmalloc2(size_t n, size_t size)
{
return objspace_xmalloc0(&rb_objspace, xmalloc2_size(n, size));
}
@@ -10123,12 +8024,12 @@ objspace_xcalloc(rb_objspace_t *objspace, size_t size)
void *mem;
size = objspace_malloc_prepare(objspace, size);
- TRY_WITH_GC(mem = calloc1(size));
+ TRY_WITH_GC(mem = calloc(1, size));
return objspace_malloc_fixup(objspace, mem, size);
}
void *
-ruby_xcalloc_body(size_t n, size_t size)
+ruby_xcalloc(size_t n, size_t size)
{
return objspace_xcalloc(&rb_objspace, xmalloc2_size(n, size));
}
@@ -10147,7 +8048,7 @@ ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size)
}
void *
-ruby_xrealloc_body(void *ptr, size_t new_size)
+ruby_xrealloc(void *ptr, size_t new_size)
{
return ruby_sized_xrealloc(ptr, new_size, 0);
}
@@ -10158,12 +8059,15 @@ ruby_xrealloc_body(void *ptr, size_t new_size)
void *
ruby_sized_xrealloc2(void *ptr, size_t n, size_t size, size_t old_n)
{
- size_t len = xmalloc2_size(n, size);
+ size_t len = size * n;
+ if (n != 0 && size != len / n) {
+ rb_raise(rb_eArgError, "realloc: possible integer overflow");
+ }
return objspace_xrealloc(&rb_objspace, ptr, len, old_n * size);
}
void *
-ruby_xrealloc2_body(void *ptr, size_t n, size_t size)
+ruby_xrealloc2(void *ptr, size_t n, size_t size)
{
return ruby_sized_xrealloc2(ptr, n, size, 0);
}
@@ -10185,34 +8089,6 @@ ruby_xfree(void *x)
ruby_sized_xfree(x, 0);
}
-void *
-rb_xmalloc_mul_add(size_t x, size_t y, size_t z) /* x * y + z */
-{
- size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
- return ruby_xmalloc(w);
-}
-
-void *
-rb_xrealloc_mul_add(const void *p, size_t x, size_t y, size_t z) /* x * y + z */
-{
- size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
- return ruby_xrealloc((void *)p, w);
-}
-
-void *
-rb_xmalloc_mul_add_mul(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
-{
- size_t u = size_mul_add_mul_or_raise(x, y, z, w, rb_eArgError);
- return ruby_xmalloc(u);
-}
-
-void *
-rb_xcalloc_mul_add_mul(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
-{
- size_t u = size_mul_add_mul_or_raise(x, y, z, w, rb_eArgError);
- return ruby_xcalloc(u, 1);
-}
-
/* Mimic ruby_xmalloc, but need not rb_objspace.
* should return pointer suitable for ruby_xfree
*/
@@ -10221,27 +8097,13 @@ ruby_mimmalloc(size_t size)
{
void *mem;
#if CALC_EXACT_MALLOC_SIZE
- size += sizeof(struct malloc_obj_info);
+ size += sizeof(size_t);
#endif
mem = malloc(size);
#if CALC_EXACT_MALLOC_SIZE
- if (!mem) {
- return NULL;
- }
- else
/* set 0 for consistency of allocated_size/allocations */
- {
- struct malloc_obj_info *info = mem;
- info->size = 0;
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- info->gen = 0;
- info->file = NULL;
- info->line = 0;
-#else
- info->file = NULL;
-#endif
- mem = info + 1;
- }
+ ((size_t *)mem)[0] = 0;
+ mem = (size_t *)mem + 1;
#endif
return mem;
}
@@ -10249,28 +8111,24 @@ ruby_mimmalloc(size_t size)
void
ruby_mimfree(void *ptr)
{
+ size_t *mem = (size_t *)ptr;
#if CALC_EXACT_MALLOC_SIZE
- struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
- ptr = info;
+ mem = mem - 1;
#endif
- free(ptr);
+ free(mem);
}
void *
rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
{
+ rb_imemo_alloc_t *s;
void *ptr;
- VALUE imemo;
- rb_imemo_tmpbuf_t *tmpbuf;
- /* Keep the order; allocate an empty imemo first then xmalloc, to
- * get rid of potential memory leak */
- imemo = rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(NULL, 0);
- *store = imemo;
+ s = rb_imemo_alloc_new(0, 0, 0, 0);
ptr = ruby_xmalloc0(size);
- tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
- tmpbuf->ptr = ptr;
- tmpbuf->cnt = cnt;
+ s->ptr = (VALUE*)ptr;
+ s->cnt = cnt;
+ *store = (VALUE)s;
return ptr;
}
@@ -10289,7 +8147,7 @@ rb_alloc_tmp_buffer(volatile VALUE *store, long len)
void
rb_free_tmp_buffer(volatile VALUE *store)
{
- rb_imemo_tmpbuf_t *s = (rb_imemo_tmpbuf_t*)ATOMIC_VALUE_EXCHANGE(*store, 0);
+ rb_imemo_alloc_t *s = (rb_imemo_alloc_t*)ATOMIC_VALUE_EXCHANGE(*store, 0);
if (s) {
void *ptr = ATOMIC_PTR_EXCHANGE(s->ptr, 0);
s->cnt = 0;
@@ -10365,22 +8223,13 @@ wmap_mark_map(st_data_t key, st_data_t val, st_data_t arg)
#endif
static void
-wmap_compact(void *ptr)
-{
- struct weakmap *w = ptr;
- if (w->wmap2obj) rb_gc_update_tbl_refs(w->wmap2obj);
- if (w->obj2wmap) rb_gc_update_tbl_refs(w->obj2wmap);
- w->final = rb_gc_location(w->final);
-}
-
-static void
wmap_mark(void *ptr)
{
struct weakmap *w = ptr;
#if WMAP_DELETE_DEAD_OBJECT_IN_MARK
if (w->obj2wmap) st_foreach(w->obj2wmap, wmap_mark_map, (st_data_t)&rb_objspace);
#endif
- rb_gc_mark_movable(w->final);
+ rb_gc_mark(w->final);
}
static int
@@ -10426,35 +8275,22 @@ static const rb_data_type_t weakmap_type = {
wmap_mark,
wmap_free,
wmap_memsize,
- wmap_compact,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
-extern const struct st_hash_type rb_hashtype_ident;
-static VALUE wmap_finalize(RB_BLOCK_CALL_FUNC_ARGLIST(objid, self));
-
static VALUE
wmap_allocate(VALUE klass)
{
struct weakmap *w;
VALUE obj = TypedData_Make_Struct(klass, struct weakmap, &weakmap_type, w);
- w->obj2wmap = st_init_table(&rb_hashtype_ident);
- w->wmap2obj = st_init_table(&rb_hashtype_ident);
- w->final = rb_func_lambda_new(wmap_finalize, obj, 1, 1);
+ w->obj2wmap = st_init_numtable();
+ w->wmap2obj = st_init_numtable();
+ w->final = rb_obj_method(obj, ID2SYM(rb_intern("finalize")));
return obj;
}
static int
-wmap_live_p(rb_objspace_t *objspace, VALUE obj)
-{
- if (!FL_ABLE(obj)) return TRUE;
- if (!is_id_value(objspace, obj)) return FALSE;
- if (!is_live_object(objspace, obj)) return FALSE;
- return TRUE;
-}
-
-static int
wmap_final_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
{
VALUE wmap, *ptr, size, i, j;
@@ -10470,16 +8306,15 @@ wmap_final_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
return ST_DELETE;
}
if (j < i) {
- SIZED_REALLOC_N(ptr, VALUE, j + 1, i);
+ ptr = ruby_sized_xrealloc2(ptr, j + 1, sizeof(VALUE), i);
ptr[0] = j;
*value = (st_data_t)ptr;
}
return ST_CONTINUE;
}
-/* :nodoc: */
static VALUE
-wmap_finalize(RB_BLOCK_CALL_FUNC_ARGLIST(objid, self))
+wmap_finalize(VALUE self, VALUE objid)
{
st_data_t orig, wmap, data;
VALUE obj, *rids, i, size;
@@ -10487,9 +8322,7 @@ wmap_finalize(RB_BLOCK_CALL_FUNC_ARGLIST(objid, self))
TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
/* Get reference from object id. */
- if ((obj = id2ref_obj_tbl(&rb_objspace, objid)) == Qundef) {
- rb_bug("wmap_finalize: objid is not found.");
- }
+ obj = obj_id_to_ref(objid);
/* obj is original referenced object and/or weak reference. */
orig = (st_data_t)obj;
@@ -10516,26 +8349,10 @@ struct wmap_iter_arg {
VALUE value;
};
-static VALUE
-wmap_inspect_append(rb_objspace_t *objspace, VALUE str, VALUE obj)
-{
- if (SPECIAL_CONST_P(obj)) {
- return rb_str_append(str, rb_inspect(obj));
- }
- else if (wmap_live_p(objspace, obj)) {
- return rb_str_append(str, rb_any_to_s(obj));
- }
- else {
- return rb_str_catf(str, "#<collected:%p>", (void*)obj);
- }
-}
-
static int
wmap_inspect_i(st_data_t key, st_data_t val, st_data_t arg)
{
- struct wmap_iter_arg *argp = (struct wmap_iter_arg *)arg;
- rb_objspace_t *objspace = argp->objspace;
- VALUE str = argp->value;
+ VALUE str = (VALUE)arg;
VALUE k = (VALUE)key, v = (VALUE)val;
if (RSTRING_PTR(str)[0] == '#') {
@@ -10545,9 +8362,13 @@ wmap_inspect_i(st_data_t key, st_data_t val, st_data_t arg)
rb_str_cat2(str, ": ");
RSTRING_PTR(str)[0] = '#';
}
- wmap_inspect_append(objspace, str, k);
+ k = SPECIAL_CONST_P(k) ? rb_inspect(k) : rb_any_to_s(k);
+ rb_str_append(str, k);
rb_str_cat2(str, " => ");
- wmap_inspect_append(objspace, str, v);
+ v = SPECIAL_CONST_P(v) ? rb_inspect(v) : rb_any_to_s(v);
+ rb_str_append(str, v);
+ OBJ_INFECT(str, k);
+ OBJ_INFECT(str, v);
return ST_CONTINUE;
}
@@ -10558,14 +8379,11 @@ wmap_inspect(VALUE self)
VALUE str;
VALUE c = rb_class_name(CLASS_OF(self));
struct weakmap *w;
- struct wmap_iter_arg args;
TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void *)self);
if (w->wmap2obj) {
- args.objspace = &rb_objspace;
- args.value = str;
- st_foreach(w->wmap2obj, wmap_inspect_i, (st_data_t)&args);
+ st_foreach(w->wmap2obj, wmap_inspect_i, str);
}
RSTRING_PTR(str)[0] = '#';
rb_str_cat2(str, ">");
@@ -10577,7 +8395,7 @@ wmap_each_i(st_data_t key, st_data_t val, st_data_t arg)
{
rb_objspace_t *objspace = (rb_objspace_t *)arg;
VALUE obj = (VALUE)val;
- if (wmap_live_p(objspace, obj)) {
+ if (is_id_value(objspace, obj) && is_live_object(objspace, obj)) {
rb_yield_values(2, (VALUE)key, obj);
}
return ST_CONTINUE;
@@ -10600,7 +8418,7 @@ wmap_each_key_i(st_data_t key, st_data_t val, st_data_t arg)
{
rb_objspace_t *objspace = (rb_objspace_t *)arg;
VALUE obj = (VALUE)val;
- if (wmap_live_p(objspace, obj)) {
+ if (is_id_value(objspace, obj) && is_live_object(objspace, obj)) {
rb_yield((VALUE)key);
}
return ST_CONTINUE;
@@ -10623,7 +8441,7 @@ wmap_each_value_i(st_data_t key, st_data_t val, st_data_t arg)
{
rb_objspace_t *objspace = (rb_objspace_t *)arg;
VALUE obj = (VALUE)val;
- if (wmap_live_p(objspace, obj)) {
+ if (is_id_value(objspace, obj) && is_live_object(objspace, obj)) {
rb_yield(obj);
}
return ST_CONTINUE;
@@ -10648,7 +8466,7 @@ wmap_keys_i(st_data_t key, st_data_t val, st_data_t arg)
rb_objspace_t *objspace = argp->objspace;
VALUE ary = argp->value;
VALUE obj = (VALUE)val;
- if (wmap_live_p(objspace, obj)) {
+ if (is_id_value(objspace, obj) && is_live_object(objspace, obj)) {
rb_ary_push(ary, (VALUE)key);
}
return ST_CONTINUE;
@@ -10675,7 +8493,7 @@ wmap_values_i(st_data_t key, st_data_t val, st_data_t arg)
rb_objspace_t *objspace = argp->objspace;
VALUE ary = argp->value;
VALUE obj = (VALUE)val;
- if (wmap_live_p(objspace, obj)) {
+ if (is_id_value(objspace, obj) && is_live_object(objspace, obj)) {
rb_ary_push(ary, obj);
}
return ST_CONTINUE;
@@ -10702,7 +8520,7 @@ wmap_aset_update(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
if (existing) {
size = (ptr = optr = (VALUE *)*val)[0];
++size;
- SIZED_REALLOC_N(ptr, VALUE, size + 1, size);
+ ptr = ruby_sized_xrealloc2(ptr, size + 1, sizeof(VALUE), size);
}
else {
optr = 0;
@@ -10723,13 +8541,10 @@ wmap_aset(VALUE self, VALUE wmap, VALUE orig)
struct weakmap *w;
TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- if (FL_ABLE(orig)) {
- define_final0(orig, w->final);
- }
- if (FL_ABLE(wmap)) {
- define_final0(wmap, w->final);
- }
-
+ should_be_finalizable(orig);
+ should_be_finalizable(wmap);
+ define_final0(orig, w->final);
+ define_final0(wmap, w->final);
st_update(w->obj2wmap, (st_data_t)orig, wmap_aset_update, wmap);
st_insert(w->wmap2obj, (st_data_t)wmap, (st_data_t)orig);
return nonspecial_obj_id(orig);
@@ -10737,7 +8552,7 @@ wmap_aset(VALUE self, VALUE wmap, VALUE orig)
/* Retrieves a weakly referenced object with the given key */
static VALUE
-wmap_lookup(VALUE self, VALUE key)
+wmap_aref(VALUE self, VALUE wmap)
{
st_data_t data;
VALUE obj;
@@ -10745,28 +8560,20 @@ wmap_lookup(VALUE self, VALUE key)
rb_objspace_t *objspace = &rb_objspace;
TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- if (!st_lookup(w->wmap2obj, (st_data_t)key, &data)) return Qundef;
+ if (!st_lookup(w->wmap2obj, (st_data_t)wmap, &data)) return Qnil;
obj = (VALUE)data;
- if (!wmap_live_p(objspace, obj)) return Qundef;
+ if (!is_id_value(objspace, obj)) return Qnil;
+ if (!is_live_object(objspace, obj)) return Qnil;
return obj;
}
-/* Retrieves a weakly referenced object with the given key */
-static VALUE
-wmap_aref(VALUE self, VALUE key)
-{
- VALUE obj = wmap_lookup(self, key);
- return obj != Qundef ? obj : Qnil;
-}
-
/* Returns +true+ if +key+ is registered */
static VALUE
wmap_has_key(VALUE self, VALUE key)
{
- return wmap_lookup(self, key) == Qundef ? Qfalse : Qtrue;
+ return NIL_P(wmap_aref(self, key)) ? Qfalse : Qtrue;
}
-/* Returns the number of referenced objects */
static VALUE
wmap_size(VALUE self)
{
@@ -10855,12 +8662,12 @@ gc_prof_setup_new_record(rb_objspace_t *objspace, int reason)
if (!objspace->profile.records) {
objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE;
- objspace->profile.records = malloc(xmalloc2_size(sizeof(gc_profile_record), objspace->profile.size));
+ objspace->profile.records = malloc(sizeof(gc_profile_record) * objspace->profile.size);
}
if (index >= objspace->profile.size) {
void *ptr;
objspace->profile.size += 1000;
- ptr = realloc(objspace->profile.records, xmalloc2_size(sizeof(gc_profile_record), objspace->profile.size));
+ ptr = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size);
if (!ptr) rb_memerror();
objspace->profile.records = ptr;
}
@@ -11030,17 +8837,19 @@ gc_prof_set_heap_info(rb_objspace_t *objspace)
*/
static VALUE
-gc_profile_clear(VALUE _)
+gc_profile_clear(void)
{
rb_objspace_t *objspace = &rb_objspace;
- void *p = objspace->profile.records;
- objspace->profile.records = NULL;
- objspace->profile.size = 0;
+ if (GC_PROFILE_RECORD_DEFAULT_SIZE * 2 < objspace->profile.size) {
+ objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE * 2;
+ objspace->profile.records = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size);
+ if (!objspace->profile.records) {
+ rb_memerror();
+ }
+ }
+ MEMZERO(objspace->profile.records, gc_profile_record, objspace->profile.size);
objspace->profile.next_index = 0;
objspace->profile.current_record = 0;
- if (p) {
- free(p);
- }
return Qnil;
}
@@ -11095,7 +8904,7 @@ gc_profile_clear(VALUE _)
*/
static VALUE
-gc_profile_record_get(VALUE _)
+gc_profile_record_get(void)
{
VALUE prof;
VALUE gc_profile = rb_ary_new();
@@ -11282,7 +9091,7 @@ gc_profile_dump_on(VALUE out, VALUE (*append)(VALUE, VALUE))
*/
static VALUE
-gc_profile_result(VALUE _)
+gc_profile_result(void)
{
VALUE str = rb_str_buf_new(0);
gc_profile_dump_on(str, rb_str_buf_append);
@@ -11303,7 +9112,12 @@ gc_profile_report(int argc, VALUE *argv, VALUE self)
{
VALUE out;
- out = (!rb_check_arity(argc, 0, 1) ? rb_stdout : argv[0]);
+ if (argc == 0) {
+ out = rb_stdout;
+ }
+ else {
+ rb_scan_args(argc, argv, "01", &out);
+ }
gc_profile_dump_on(out, rb_io_write);
return Qnil;
@@ -11356,7 +9170,7 @@ gc_profile_enable_get(VALUE self)
*/
static VALUE
-gc_profile_enable(VALUE _)
+gc_profile_enable(void)
{
rb_objspace_t *objspace = &rb_objspace;
objspace->profile.run = TRUE;
@@ -11373,7 +9187,7 @@ gc_profile_enable(VALUE _)
*/
static VALUE
-gc_profile_disable(VALUE _)
+gc_profile_disable(void)
{
rb_objspace_t *objspace = &rb_objspace;
@@ -11414,7 +9228,6 @@ type_name(int type, VALUE obj)
TYPE_NAME(T_UNDEF);
TYPE_NAME(T_IMEMO);
TYPE_NAME(T_ICLASS);
- TYPE_NAME(T_MOVED);
TYPE_NAME(T_ZOMBIE);
case T_DATA:
if (obj && rb_objspace_data_type_name(obj)) {
@@ -11432,8 +9245,8 @@ obj_type_name(VALUE obj)
return type_name(TYPE(obj), obj);
}
-const char *
-rb_method_type_name(rb_method_type_t type)
+static const char *
+method_type_name(rb_method_type_t type)
{
switch (type) {
case VM_METHOD_TYPE_ISEQ: return "iseq";
@@ -11449,7 +9262,7 @@ rb_method_type_name(rb_method_type_t type)
case VM_METHOD_TYPE_UNDEF: return "undef";
case VM_METHOD_TYPE_NOTIMPLEMENTED: return "notimplemented";
}
- rb_bug("rb_method_type_name: unreachable (type: %d)", type);
+ rb_bug("method_type_name: unreachable (type: %d)", type);
}
/* from array.c */
@@ -11463,10 +9276,10 @@ rb_method_type_name(rb_method_type_t type)
static void
rb_raw_iseq_info(char *buff, const int buff_size, const rb_iseq_t *iseq)
{
- if (buff_size > 0 && iseq->body && iseq->body->location.label && !RB_TYPE_P(iseq->body->location.pathobj, T_MOVED)) {
+ if (iseq->body && iseq->body->location.label) {
VALUE path = rb_iseq_path(iseq);
VALUE n = iseq->body->location.first_lineno;
- snprintf(buff, buff_size, " %s@%s:%d",
+ snprintf(buff, buff_size, "%s %s@%s:%d", buff,
RSTRING_PTR(iseq->body->location.label),
RSTRING_PTR(path),
n ? FIX2INT(n) : 0 );
@@ -11476,19 +9289,8 @@ rb_raw_iseq_info(char *buff, const int buff_size, const rb_iseq_t *iseq)
const char *
rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
{
- int pos = 0;
-
-#define BUFF_ARGS buff + pos, buff_size - pos
-#define APPENDF(f) if ((pos += snprintf f) >= buff_size) goto end
if (SPECIAL_CONST_P(obj)) {
- APPENDF((BUFF_ARGS, "%s", obj_type_name(obj)));
-
- if (FIXNUM_P(obj)) {
- APPENDF((BUFF_ARGS, " %ld", FIX2LONG(obj)));
- }
- else if (SYMBOL_P(obj)) {
- APPENDF((BUFF_ARGS, " %s", rb_id2name(SYM2ID(obj))));
- }
+ snprintf(buff, buff_size, "%s", obj_type_name(obj));
}
else {
#define TF(c) ((c) != 0 ? "true" : "false")
@@ -11497,46 +9299,35 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
#if USE_RGENGC
const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
- if (is_pointer_to_heap(&rb_objspace, (void *)obj)) {
- APPENDF((BUFF_ARGS, "%p [%d%s%s%s%s%s] %s ",
- (void *)obj, age,
- C(RVALUE_UNCOLLECTIBLE_BITMAP(obj), "L"),
- C(RVALUE_MARK_BITMAP(obj), "M"),
- C(RVALUE_PIN_BITMAP(obj), "P"),
- C(RVALUE_MARKING_BITMAP(obj), "R"),
- C(RVALUE_WB_UNPROTECTED_BITMAP(obj), "U"),
- obj_type_name(obj)));
- }
- else {
- /* fake */
- APPENDF((BUFF_ARGS, "%p [%dXXXX] %s",
- (void *)obj, age,
- obj_type_name(obj)));
- }
+ snprintf(buff, buff_size, "%p [%d%s%s%s%s] %s",
+ (void *)obj, age,
+ C(RVALUE_UNCOLLECTIBLE_BITMAP(obj), "L"),
+ C(RVALUE_MARK_BITMAP(obj), "M"),
+ C(RVALUE_MARKING_BITMAP(obj), "R"),
+ C(RVALUE_WB_UNPROTECTED_BITMAP(obj), "U"),
+ obj_type_name(obj));
#else
- APPENDF((BUFF_ARGS, "%p [%s] %s",
+ snprintf(buff, buff_size, "%p [%s] %s",
(void *)obj,
C(RVALUE_MARK_BITMAP(obj), "M"),
- obj_type_name(obj)));
+ obj_type_name(obj));
#endif
if (internal_object_p(obj)) {
/* ignore */
}
else if (RBASIC(obj)->klass == 0) {
- APPENDF((BUFF_ARGS, "(temporary internal)"));
+ snprintf(buff, buff_size, "%s (temporary internal)", buff);
}
else {
- if (RTEST(RBASIC(obj)->klass)) {
- VALUE class_path = rb_class_path_cached(RBASIC(obj)->klass);
+ VALUE class_path = rb_class_path_cached(RBASIC(obj)->klass);
if (!NIL_P(class_path)) {
- APPENDF((BUFF_ARGS, "(%s)", RSTRING_PTR(class_path)));
+ snprintf(buff, buff_size, "%s (%s)", buff, RSTRING_PTR(class_path));
}
- }
}
#if GC_DEBUG
- APPENDF((BUFF_ARGS, "@%s:%d", RANY(obj)->file, RANY(obj)->line));
+ snprintf(buff, buff_size, "%s @%s:%d", buff, RANY(obj)->file, RANY(obj)->line);
#endif
switch (type) {
@@ -11544,71 +9335,22 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
UNEXPECTED_NODE(rb_raw_obj_info);
break;
case T_ARRAY:
- if (FL_TEST(obj, ELTS_SHARED)) {
- APPENDF((BUFF_ARGS, "shared -> %s",
- rb_obj_info(RARRAY(obj)->as.heap.aux.shared_root)));
- }
- else if (FL_TEST(obj, RARRAY_EMBED_FLAG)) {
- APPENDF((BUFF_ARGS, "[%s%s] len: %d (embed)",
- C(ARY_EMBED_P(obj), "E"),
- C(ARY_SHARED_P(obj), "S"),
- (int)RARRAY_LEN(obj)));
- }
- else {
- APPENDF((BUFF_ARGS, "[%s%s%s] len: %d, capa:%d ptr:%p",
- C(ARY_EMBED_P(obj), "E"),
- C(ARY_SHARED_P(obj), "S"),
- C(RARRAY_TRANSIENT_P(obj), "T"),
- (int)RARRAY_LEN(obj),
- ARY_EMBED_P(obj) ? -1 : (int)RARRAY(obj)->as.heap.aux.capa,
- (void *)RARRAY_CONST_PTR_TRANSIENT(obj)));
- }
+ snprintf(buff, buff_size, "%s [%s%s] len: %d", buff,
+ C(ARY_EMBED_P(obj), "E"),
+ C(ARY_SHARED_P(obj), "S"),
+ (int)RARRAY_LEN(obj));
break;
case T_STRING: {
- APPENDF((BUFF_ARGS, "%s", RSTRING_PTR(obj)));
+ snprintf(buff, buff_size, "%s %s", buff, RSTRING_PTR(obj));
+ break;
+ }
+ case T_CLASS: {
+ VALUE class_path = rb_class_path_cached(obj);
+ if (!NIL_P(class_path)) {
+ snprintf(buff, buff_size, "%s %s", buff, RSTRING_PTR(class_path));
+ }
break;
}
- case T_MOVED: {
- APPENDF((BUFF_ARGS, "-> %p", (void*)rb_gc_location(obj)));
- break;
- }
- case T_HASH: {
- APPENDF((BUFF_ARGS, "[%c%c] %d",
- RHASH_AR_TABLE_P(obj) ? 'A' : 'S',
- RHASH_TRANSIENT_P(obj) ? 'T' : ' ',
- (int)RHASH_SIZE(obj)));
- break;
- }
- case T_CLASS:
- case T_MODULE:
- {
- VALUE class_path = rb_class_path_cached(obj);
- if (!NIL_P(class_path)) {
- APPENDF((BUFF_ARGS, "%s", RSTRING_PTR(class_path)));
- }
- break;
- }
- case T_ICLASS:
- {
- VALUE class_path = rb_class_path_cached(RBASIC_CLASS(obj));
- if (!NIL_P(class_path)) {
- APPENDF((BUFF_ARGS, "src:%s", RSTRING_PTR(class_path)));
- }
- break;
- }
- case T_OBJECT:
- {
- uint32_t len = ROBJECT_NUMIV(obj);
-
- if (RANY(obj)->as.basic.flags & ROBJECT_EMBED) {
- APPENDF((BUFF_ARGS, "(embed) len:%d", len));
- }
- else {
- VALUE *ptr = ROBJECT_IVPTR(obj);
- APPENDF((BUFF_ARGS, "len:%d ptr:%p", len, (void *)ptr));
- }
- }
- break;
case T_DATA: {
const struct rb_block *block;
const rb_iseq_t *iseq;
@@ -11616,12 +9358,12 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
(block = vm_proc_block(obj)) != NULL &&
(vm_block_type(block) == block_type_iseq) &&
(iseq = vm_block_iseq(block)) != NULL) {
- rb_raw_iseq_info(BUFF_ARGS, iseq);
+ rb_raw_iseq_info(buff, buff_size, iseq);
}
else {
const char * const type_name = rb_objspace_data_type_name(obj);
if (type_name) {
- APPENDF((BUFF_ARGS, "%s", type_name));
+ snprintf(buff, buff_size, "%s %s", buff, type_name);
}
}
break;
@@ -11638,33 +9380,31 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
IMEMO_NAME(memo);
IMEMO_NAME(ment);
IMEMO_NAME(iseq);
- IMEMO_NAME(tmpbuf);
- IMEMO_NAME(ast);
- IMEMO_NAME(parser_strterm);
+ IMEMO_NAME(alloc);
#undef IMEMO_NAME
default: UNREACHABLE;
}
- APPENDF((BUFF_ARGS, "/%s", imemo_name));
+ snprintf(buff, buff_size, "%s %s", buff, imemo_name);
switch (imemo_type(obj)) {
case imemo_ment: {
const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment;
if (me->def) {
- APPENDF((BUFF_ARGS, "(called_id: %s, type: %s, alias: %d, owner: %s, defined_class: %s)",
+ snprintf(buff, buff_size, "%s (called_id: %s, type: %s, alias: %d, owner: %s, defined_class: %s)", buff,
rb_id2name(me->called_id),
- rb_method_type_name(me->def->type),
+ method_type_name(me->def->type),
me->def->alias_count,
obj_info(me->owner),
- obj_info(me->defined_class)));
+ obj_info(me->defined_class));
}
else {
- APPENDF((BUFF_ARGS, "%s", rb_id2name(me->called_id)));
+ snprintf(buff, buff_size, "%s", rb_id2name(me->called_id));
}
break;
}
case imemo_iseq: {
const rb_iseq_t *iseq = (const rb_iseq_t *)obj;
- rb_raw_iseq_info(BUFF_ARGS, iseq);
+ rb_raw_iseq_info(buff, buff_size, iseq);
break;
}
default:
@@ -11677,10 +9417,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
#undef TF
#undef C
}
- end:
return buff;
-#undef APPENDF
-#undef BUFF_ARGS
}
#if RGENGC_OBJ_INFO
@@ -11709,10 +9446,15 @@ obj_info(VALUE obj)
}
#endif
-MJIT_FUNC_EXPORTED const char *
+const char *
rb_obj_info(VALUE obj)
{
- return obj_info(obj);
+ if (!rb_special_const_p(obj)) {
+ return obj_info(obj);
+ }
+ else {
+ return obj_type_name(obj);
+ }
}
void
@@ -11722,13 +9464,6 @@ rb_obj_info_dump(VALUE obj)
fprintf(stderr, "rb_obj_info_dump: %s\n", rb_raw_obj_info(buff, 0x100, obj));
}
-void
-rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func)
-{
- char buff[0x100];
- fprintf(stderr, "<OBJ_INFO:%s@%s:%d> %s\n", func, file, line, rb_raw_obj_info(buff, 0x100, obj));
-}
-
#if GC_DEBUG
void
@@ -11738,12 +9473,6 @@ rb_gcdebug_print_obj_condition(VALUE obj)
fprintf(stderr, "created at: %s:%d\n", RANY(obj)->file, RANY(obj)->line);
- if (BUILTIN_TYPE(obj) == T_MOVED) {
- fprintf(stderr, "moved?: true\n");
- }
- else {
- fprintf(stderr, "moved?: false\n");
- }
if (is_pointer_to_heap(objspace, (void *)obj)) {
fprintf(stderr, "pointer to heap?: true\n");
}
@@ -11753,7 +9482,6 @@ rb_gcdebug_print_obj_condition(VALUE obj)
}
fprintf(stderr, "marked? : %s\n", MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj) ? "true" : "false");
- fprintf(stderr, "pinned? : %s\n", MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj) ? "true" : "false");
#if USE_RGENGC
fprintf(stderr, "age? : %d\n", RVALUE_AGE(obj));
fprintf(stderr, "old? : %s\n", RVALUE_OLD_P(obj) ? "true" : "false");
@@ -11771,7 +9499,7 @@ rb_gcdebug_print_obj_condition(VALUE obj)
}
static VALUE
-gcdebug_sentinel(RB_BLOCK_CALL_FUNC_ARGLIST(obj, name))
+gcdebug_sentinel(VALUE obj, VALUE name)
{
fprintf(stderr, "WARNING: object %s(%p) is inadvertently collected\n", (char *)name, (void *)obj);
return Qnil;
@@ -11786,13 +9514,6 @@ rb_gcdebug_sentinel(VALUE obj, const char *name)
#endif /* GC_DEBUG */
#if GC_DEBUG_STRESS_TO_CLASS
-/*
- * call-seq:
- * GC.add_stress_to_class(class[, ...])
- *
- * Raises NoMemoryError when allocating an instance of the given classes.
- *
- */
static VALUE
rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
{
@@ -11805,14 +9526,6 @@ rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
return self;
}
-/*
- * call-seq:
- * GC.remove_stress_to_class(class[, ...])
- *
- * No longer raises NoMemoryError when allocating an instance of the
- * given classes.
- *
- */
static VALUE
rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
{
@@ -11884,7 +9597,16 @@ rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
* See also GC.count, GC.malloc_allocated_size and GC.malloc_allocations
*/
-#include "gc.rbinc"
+/*
+ * The GC module provides an interface to Ruby's mark and
+ * sweep garbage collection mechanism.
+ *
+ * Some of the underlying methods are also available via the ObjectSpace
+ * module.
+ *
+ * You may obtain information about the operation of the GC through
+ * GC::Profiler.
+ */
void
Init_GC(void)
@@ -11895,7 +9617,15 @@ Init_GC(void)
VALUE gc_constants;
rb_mGC = rb_define_module("GC");
- load_gc();
+ rb_define_singleton_method(rb_mGC, "start", gc_start_internal, -1);
+ rb_define_singleton_method(rb_mGC, "enable", rb_gc_enable, 0);
+ rb_define_singleton_method(rb_mGC, "disable", rb_gc_disable, 0);
+ rb_define_singleton_method(rb_mGC, "stress", gc_stress_get, 0);
+ rb_define_singleton_method(rb_mGC, "stress=", gc_stress_set_m, 1);
+ rb_define_singleton_method(rb_mGC, "count", gc_count, 0);
+ rb_define_singleton_method(rb_mGC, "stat", gc_stat, -1);
+ rb_define_singleton_method(rb_mGC, "latest_gc_info", gc_latest_gc_info, -1);
+ rb_define_method(rb_mGC, "garbage_collect", gc_start_internal, -1);
gc_constants = rb_hash_new();
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(sizeof(RVALUE)));
@@ -11903,7 +9633,6 @@ Init_GC(void)
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_PLANES")), SIZET2NUM(HEAP_PAGE_BITMAP_PLANES));
OBJ_FREEZE(gc_constants);
- /* internal constants */
rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants);
rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler");
@@ -11917,13 +9646,13 @@ Init_GC(void)
rb_define_singleton_method(rb_mProfiler, "total_time", gc_profile_total_time, 0);
rb_mObjSpace = rb_define_module("ObjectSpace");
-
rb_define_module_function(rb_mObjSpace, "each_object", os_each_obj, -1);
+ rb_define_module_function(rb_mObjSpace, "garbage_collect", gc_start_internal, -1);
rb_define_module_function(rb_mObjSpace, "define_finalizer", define_final, -1);
rb_define_module_function(rb_mObjSpace, "undefine_finalizer", undefine_final, 1);
- rb_define_module_function(rb_mObjSpace, "_id2ref", os_id2ref, 1);
+ rb_define_module_function(rb_mObjSpace, "_id2ref", id2ref, 1);
rb_vm_register_special_exception(ruby_error_nomemory, rb_eNoMemError, "failed to allocate memory");
@@ -11949,13 +9678,12 @@ Init_GC(void)
rb_define_method(rb_cWeakMap, "values", wmap_values, 0);
rb_define_method(rb_cWeakMap, "size", wmap_size, 0);
rb_define_method(rb_cWeakMap, "length", wmap_size, 0);
+ rb_define_private_method(rb_cWeakMap, "finalize", wmap_finalize, 1);
rb_include_module(rb_cWeakMap, rb_mEnumerable);
}
/* internal methods */
- rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency_m, 0);
- rb_define_singleton_method(rb_mGC, "verify_compaction_references", gc_verify_compaction_references, -1);
- rb_define_singleton_method(rb_mGC, "verify_transient_heap_internal_consistency", gc_verify_transient_heap_internal_consistency, 0);
+ rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency, 0);
#if MALLOC_ALLOCATED_SIZE
rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);
rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);
@@ -11966,9 +9694,9 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
#endif
+ /* ::GC::OPTS, which shows GC build options */
{
VALUE opts;
- /* GC build options */
rb_define_const(rb_mGC, "OPTS", opts = rb_ary_new());
#define OPT(o) if (o) rb_ary_push(opts, rb_fstring_lit(#o))
OPT(GC_DEBUG);
@@ -11987,69 +9715,3 @@ Init_GC(void)
OBJ_FREEZE(opts);
}
}
-
-#ifdef ruby_xmalloc
-#undef ruby_xmalloc
-#endif
-#ifdef ruby_xmalloc2
-#undef ruby_xmalloc2
-#endif
-#ifdef ruby_xcalloc
-#undef ruby_xcalloc
-#endif
-#ifdef ruby_xrealloc
-#undef ruby_xrealloc
-#endif
-#ifdef ruby_xrealloc2
-#undef ruby_xrealloc2
-#endif
-
-void *
-ruby_xmalloc(size_t size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xmalloc_body(size);
-}
-
-void *
-ruby_xmalloc2(size_t n, size_t size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xmalloc2_body(n, size);
-}
-
-void *
-ruby_xcalloc(size_t n, size_t size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xcalloc_body(n, size);
-}
-
-void *
-ruby_xrealloc(void *ptr, size_t new_size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xrealloc_body(ptr, new_size);
-}
-
-void *
-ruby_xrealloc2(void *ptr, size_t n, size_t new_size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xrealloc2_body(ptr, n, new_size);
-}
diff --git a/gc.h b/gc.h
index 72e3935799..2c91e06620 100644
--- a/gc.h
+++ b/gc.h
@@ -6,10 +6,6 @@
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p)))
#elif defined(__i386) && defined(__GNUC__)
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p)))
-#elif defined(__powerpc64__) && defined(__GNUC__)
-#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p)))
-#elif defined(__aarch64__) && defined(__GNUC__)
-#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mov\t%0, sp" : "=r" (*(p)))
#else
NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
@@ -61,10 +57,6 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
#define RUBY_GC_INFO if(0)printf
#endif
-#define RUBY_MARK_NO_PIN_UNLESS_NULL(ptr) do { \
- VALUE markobj = (ptr); \
- if (RTEST(markobj)) {rb_gc_mark_movable(markobj);} \
-} while (0)
#define RUBY_MARK_UNLESS_NULL(ptr) do { \
VALUE markobj = (ptr); \
if (RTEST(markobj)) {rb_gc_mark(markobj);} \
@@ -85,14 +77,6 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr);
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
#endif
-/*
- STACK_GROW_DIR_DETECTION is used with STACK_DIR_UPPER.
-
- On most normal systems, stacks grow from high address to lower address. In
- this case, STACK_DIR_UPPER(a, b) will return (b), but on exotic systems where
- the stack grows UP (from low address to high address), it will return (a).
-*/
-
#if STACK_GROW_DIRECTION
#define STACK_GROW_DIR_DETECTION
#define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b))
@@ -104,8 +88,7 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr);
const char *rb_obj_info(VALUE obj);
const char *rb_raw_obj_info(char *buff, const int buff_size, VALUE obj);
-
-VALUE rb_gc_disable_no_rest(void);
+void rb_obj_info_dump(VALUE obj);
struct rb_thread_struct;
diff --git a/gc.rb b/gc.rb
deleted file mode 100644
index fcfa48fbe1..0000000000
--- a/gc.rb
+++ /dev/null
@@ -1,169 +0,0 @@
-# for gc.c
-
-# The GC module provides an interface to Ruby's mark and
-# sweep garbage collection mechanism.
-#
-# Some of the underlying methods are also available via the ObjectSpace
-# module.
-#
-# You may obtain information about the operation of the GC through
-# GC::Profiler.
-module GC
-
- # call-seq:
- # GC.start -> nil
- # ObjectSpace.garbage_collect -> nil
- # include GC; garbage_collect -> nil
- # GC.start(full_mark: true, immediate_sweep: true) -> nil
- # ObjectSpace.garbage_collect(full_mark: true, immediate_sweep: true) -> nil
- # include GC; garbage_collect(full_mark: true, immediate_sweep: true) -> nil
- #
- # Initiates garbage collection, even if manually disabled.
- #
- # This method is defined with keyword arguments that default to true:
- #
- # def GC.start(full_mark: true, immediate_sweep: true); end
- #
- # Use full_mark: false to perform a minor GC.
- # Use immediate_sweep: false to defer sweeping (use lazy sweep).
- #
- # Note: These keyword arguments are implementation and version dependent. They
- # are not guaranteed to be future-compatible, and may be ignored if the
- # underlying implementation does not support them.
- def self.start full_mark: true, immediate_mark: true, immediate_sweep: true
- __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep
- end
-
- def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
- __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep
- end
-
- # call-seq:
- # GC.enable -> true or false
- #
- # Enables garbage collection, returning +true+ if garbage
- # collection was previously disabled.
- #
- # GC.disable #=> false
- # GC.enable #=> true
- # GC.enable #=> false
- #
- def self.enable
- __builtin_gc_enable
- end
-
- # call-seq:
- # GC.disable -> true or false
- #
- # Disables garbage collection, returning +true+ if garbage
- # collection was already disabled.
- #
- # GC.disable #=> false
- # GC.disable #=> true
- def self.disable
- __builtin_gc_disable
- end
-
- # call-seq:
- # GC.stress -> integer, true or false
- #
- # Returns current status of GC stress mode.
- def self.stress
- __builtin_gc_stress_get
- end
-
- # call-seq:
- # GC.stress = flag -> flag
- #
- # Updates the GC stress mode.
- #
- # When stress mode is enabled, the GC is invoked at every GC opportunity:
- # all memory and object allocations.
- #
- # Enabling stress mode will degrade performance, it is only for debugging.
- #
- # flag can be true, false, or an integer bit-ORed following flags.
- # 0x01:: no major GC
- # 0x02:: no immediate sweep
- # 0x04:: full mark after malloc/calloc/realloc
- def self.stress=(flag)
- __builtin_gc_stress_set_m flag
- end
-
- # call-seq:
- # GC.count -> Integer
- #
- # The number of times GC occurred.
- #
- # It returns the number of times GC occurred since the process started.
- def self.count
- __builtin_gc_count
- end
-
- # call-seq:
- # GC.stat -> Hash
- # GC.stat(hash) -> hash
- # GC.stat(:key) -> Numeric
- #
- # Returns a Hash containing information about the GC.
- #
- # The hash includes information about internal statistics about GC such as:
- #
- # {
- # :count=>0,
- # :heap_allocated_pages=>24,
- # :heap_sorted_length=>24,
- # :heap_allocatable_pages=>0,
- # :heap_available_slots=>9783,
- # :heap_live_slots=>7713,
- # :heap_free_slots=>2070,
- # :heap_final_slots=>0,
- # :heap_marked_slots=>0,
- # :heap_eden_pages=>24,
- # :heap_tomb_pages=>0,
- # :total_allocated_pages=>24,
- # :total_freed_pages=>0,
- # :total_allocated_objects=>7796,
- # :total_freed_objects=>83,
- # :malloc_increase_bytes=>2389312,
- # :malloc_increase_bytes_limit=>16777216,
- # :minor_gc_count=>0,
- # :major_gc_count=>0,
- # :remembered_wb_unprotected_objects=>0,
- # :remembered_wb_unprotected_objects_limit=>0,
- # :old_objects=>0,
- # :old_objects_limit=>0,
- # :oldmalloc_increase_bytes=>2389760,
- # :oldmalloc_increase_bytes_limit=>16777216
- # }
- #
- # The contents of the hash are implementation specific and may be changed in
- # the future.
- #
- # This method is only expected to work on C Ruby.
- def self.stat hash_or_key = nil
- __builtin_gc_stat hash_or_key
- end
-
- # call-seq:
- # GC.latest_gc_info -> {:gc_by=>:newobj}
- # GC.latest_gc_info(hash) -> hash
- # GC.latest_gc_info(:major_by) -> :malloc
- #
- # Returns information about the most recent garbage collection.
- def self.latest_gc_info hash_or_key = nil
- __builtin_gc_latest_gc_info hash_or_key
- end
-
- def self.compact
- __builtin_rb_gc_compact
- end
-end
-
-module ObjectSpace
- def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
- __builtin_gc_start_internal full_mark, immediate_mark, immediate_sweep
- end
-
- module_function :garbage_collect
-end
diff --git a/gem_prelude.rb b/gem_prelude.rb
index 1d0158d00a..be9c41933c 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -1,2 +1,8 @@
-require 'rubygems.rb' if defined?(Gem)
-require 'did_you_mean' if defined?(DidYouMean)
+if defined?(Gem)
+ require 'rubygems.rb'
+ begin
+ gem 'did_you_mean'
+ require 'did_you_mean'
+ rescue Gem::LoadError, LoadError
+ end if defined?(DidYouMean)
+end
diff --git a/gems/bundled_gems b/gems/bundled_gems
index ce2dd1bdb8..8038a60375 100644
--- a/gems/bundled_gems
+++ b/gems/bundled_gems
@@ -1,6 +1,7 @@
-minitest 5.13.0 https://github.com/seattlerb/minitest
-net-telnet 0.2.0 https://github.com/ruby/net-telnet
-power_assert 1.1.7 https://github.com/k-tsj/power_assert
-rake 13.0.1 https://github.com/ruby/rake
-test-unit 3.3.4 https://github.com/test-unit/test-unit
+did_you_mean 1.2.0 https://github.com/yuki24/did_you_mean
+minitest 5.10.3 https://github.com/seattlerb/minitest
+net-telnet 0.1.1 https://github.com/ruby/net-telnet
+power_assert 1.1.1 https://github.com/k-tsj/power_assert
+rake 12.3.3 https://github.com/ruby/rake
+test-unit 3.2.7 https://github.com/test-unit/test-unit
xmlrpc 0.3.0 https://github.com/ruby/xmlrpc
diff --git a/golf_prelude.rb b/golf_prelude.rb
index a13d3f71bc..e45f4cafd9 100644
--- a/golf_prelude.rb
+++ b/golf_prelude.rb
@@ -1,7 +1,6 @@
class Object
@@golf_hash = {}
- verbose, $VERBOSE = $VERBOSE, nil
def method_missing m, *a, &b
t = @@golf_hash[ [m, self.class] ] ||= matching_methods(m)[0]
if t && b
@@ -13,7 +12,6 @@ class Object
t ? __send__(t, *a, &b) : super
end
end
- $VERBOSE = verbose
def matching_methods(s = '', m = callable_methods)
r = /^#{s.to_s.gsub(/./){"(.*?)" + Regexp.escape($&)}}/
@@ -52,11 +50,6 @@ class Object
puts "#{a}ello, #{b}orld#{c}"
end
- def f(m = 100)
- 1.upto(m){|n|puts'FizzBuzz
-'[i=n**4%-15,i+13]||n}
- end
-
alias say puts
def do_while
diff --git a/hash.c b/hash.c
index 63b228f501..0a9a5ee261 100644
--- a/hash.c
+++ b/hash.c
@@ -11,17 +11,15 @@
**********************************************************************/
-#include "ruby/encoding.h"
+#include "internal.h"
#include "ruby/st.h"
#include "ruby/util.h"
-#include "internal.h"
#include <errno.h>
#include "probes.h"
#include "id.h"
#include "symbol.h"
-#include "debug_counter.h"
-#include "transient_heap.h"
-#include "ruby_assert.h"
+#include "gc.h"
+
#ifdef __APPLE__
# ifdef HAVE_CRT_EXTERNS_H
# include <crt_externs.h>
@@ -30,21 +28,13 @@
# endif
#endif
-#ifndef HASH_DEBUG
-#define HASH_DEBUG 0
-#endif
-
-#if HASH_DEBUG
-#include "gc.h"
-#endif
-
#define HAS_EXTRA_STATES(hash, klass) ( \
((klass = has_extra_methods(rb_obj_class(hash))) != 0) || \
- FL_TEST((hash), FL_EXIVAR|RHASH_PROC_DEFAULT) || \
+ FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \
!NIL_P(RHASH_IFNONE(hash)))
#define SET_DEFAULT(hash, ifnone) ( \
- FL_UNSET_RAW(hash, RHASH_PROC_DEFAULT), \
+ FL_UNSET_RAW(hash, HASH_PROC_DEFAULT), \
RHASH_SET_IFNONE(hash, ifnone))
#define SET_PROC_DEFAULT(hash, proc) set_proc_default(hash, proc)
@@ -54,8 +44,8 @@
static inline void
copy_default(struct RHash *hash, const struct RHash *hash2)
{
- hash->basic.flags &= ~RHASH_PROC_DEFAULT;
- hash->basic.flags |= hash2->basic.flags & RHASH_PROC_DEFAULT;
+ hash->basic.flags &= ~HASH_PROC_DEFAULT;
+ hash->basic.flags |= hash2->basic.flags & HASH_PROC_DEFAULT;
RHASH_SET_IFNONE(hash, RHASH_IFNONE(hash2));
}
@@ -93,7 +83,6 @@ VALUE rb_cHash;
static VALUE envtbl;
static ID id_hash, id_yield, id_default, id_flatten_bang;
-static ID id_hash_iter_lev;
VALUE
rb_hash_set_ifnone(VALUE hash, VALUE ifnone)
@@ -106,6 +95,9 @@ static int
rb_any_cmp(VALUE a, VALUE b)
{
if (a == b) return 0;
+ if (FIXNUM_P(a) && FIXNUM_P(b)) {
+ return a != b;
+ }
if (RB_TYPE_P(a, T_STRING) && RBASIC(a)->klass == rb_cString &&
RB_TYPE_P(b, T_STRING) && RBASIC(b)->klass == rb_cString) {
return rb_str_hash_cmp(a, b);
@@ -146,15 +138,7 @@ rb_hash(VALUE obj)
return hval;
}
-static long rb_objid_hash(st_index_t index);
-
-static st_index_t
-dbl_to_index(double d)
-{
- union {double d; st_index_t i;} u;
- u.d = d;
- return u.i;
-}
+long rb_objid_hash(st_index_t index);
long
rb_dbl_long_hash(double d)
@@ -164,7 +148,12 @@ rb_dbl_long_hash(double d)
#if SIZEOF_INT == SIZEOF_VOIDP
return rb_memhash(&d, sizeof(d));
#else
- return rb_objid_hash(dbl_to_index(d));
+ {
+ union {double d; uint64_t i;} u;
+
+ u.d = d;
+ return rb_objid_hash(rb_hash_start(u.i));
+ }
#endif
}
@@ -176,10 +165,10 @@ any_hash(VALUE a, st_index_t (*other_func)(VALUE))
if (SPECIAL_CONST_P(a)) {
if (STATIC_SYM_P(a)) {
- hnum = a >> (RUBY_SPECIAL_SHIFT + ID_SCOPE_SHIFT);
- hnum = rb_hash_start(hnum);
- goto out;
- }
+ hnum = a >> (RUBY_SPECIAL_SHIFT + ID_SCOPE_SHIFT);
+ hnum = rb_hash_start(hnum);
+ goto out;
+ }
else if (FLONUM_P(a)) {
/* prevent pathological behavior: [Bug #10761] */
goto flt;
@@ -235,7 +224,7 @@ rb_any_hash(VALUE a)
/* Here we two primes with random bit generation. */
static const uint64_t prime1 = ((uint64_t)0x2e0bb864 << 32) | 0xe9ea7df5;
-static const uint32_t prime2 = 0x830fcab9;
+static const uint64_t prime2 = ((uint64_t)0xcdb32970 << 32) | 0x830fcaa1;
static inline uint64_t
@@ -261,48 +250,18 @@ key64_hash(uint64_t key, uint32_t seed)
return mult_and_mix(key + seed, prime1);
}
-/* Should cast down the result for each purpose */
-#define st_index_hash(index) key64_hash(rb_hash_start(index), prime2)
-
-static long
+long
rb_objid_hash(st_index_t index)
{
- return (long)st_index_hash(index);
+ return (long)key64_hash(rb_hash_start(index), (uint32_t)prime2);
}
static st_index_t
objid_hash(VALUE obj)
{
- VALUE object_id = rb_obj_id(obj);
- if (!FIXNUM_P(object_id))
- object_id = rb_big_hash(object_id);
-
-#if SIZEOF_LONG == SIZEOF_VOIDP
- return (st_index_t)st_index_hash((st_index_t)NUM2LONG(object_id));
-#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
- return (st_index_t)st_index_hash((st_index_t)NUM2LL(object_id));
-#endif
+ return rb_objid_hash((st_index_t)obj);
}
-/**
- * call-seq:
- * obj.hash -> integer
- *
- * Generates an Integer hash value for this object. This function must have the
- * property that <code>a.eql?(b)</code> implies <code>a.hash == b.hash</code>.
- *
- * The hash value is used along with #eql? by the Hash class to determine if
- * two objects reference the same hash key. Any hash value that exceeds the
- * capacity of an Integer will be truncated before being used.
- *
- * The hash value for an object may not be identical across invocations or
- * implementations of Ruby. If you need a stable identifier across Ruby
- * invocations and implementations you will need to generate one with a custom
- * method.
- *--
- * \private
- *++
- */
VALUE
rb_obj_hash(VALUE obj)
{
@@ -327,963 +286,18 @@ rb_ident_hash(st_data_t n)
* many integers get interpreted as 2.0 or -2.0 [Bug #10761]
*/
if (FLONUM_P(n)) {
- n ^= dbl_to_index(rb_float_value(n));
+ n ^= (st_data_t)rb_float_value(n);
}
#endif
- return (st_index_t)st_index_hash((st_index_t)n);
+ return (st_index_t)key64_hash(rb_hash_start((st_index_t)n), (uint32_t)prime2);
}
-#define identhash rb_hashtype_ident
-const struct st_hash_type rb_hashtype_ident = {
+static const struct st_hash_type identhash = {
rb_ident_cmp,
rb_ident_hash,
};
-typedef st_index_t st_hash_t;
-
-/*
- * RHASH_AR_TABLE_P(h):
- * * as.ar == NULL or
- * as.ar points ar_table.
- * * as.ar is allocated by transient heap or xmalloc.
- *
- * !RHASH_AR_TABLE_P(h):
- * * as.st points st_table.
- */
-
-#define RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE
-
-#define RHASH_AR_TABLE_REF(hash, n) (&RHASH_AR_TABLE(hash)->pairs[n])
-#define RHASH_AR_CLEARED_HINT 0xff
-
-typedef struct ar_table_pair_struct {
- VALUE key;
- VALUE val;
-} ar_table_pair;
-
-typedef struct ar_table_struct {
- /* 64bit CPU: 8B * 2 * 8 = 128B */
- ar_table_pair pairs[RHASH_AR_TABLE_MAX_SIZE];
-} ar_table;
-
-size_t
-rb_hash_ar_table_size(void)
-{
- return sizeof(ar_table);
-}
-
-static inline st_hash_t
-ar_do_hash(st_data_t key)
-{
- return (st_hash_t)rb_any_hash(key);
-}
-
-static inline ar_hint_t
-ar_do_hash_hint(st_hash_t hash_value)
-{
- return (ar_hint_t)hash_value;
-}
-
-static inline ar_hint_t
-ar_hint(VALUE hash, unsigned int index)
-{
- return RHASH(hash)->ar_hint.ary[index];
-}
-
-static inline void
-ar_hint_set_hint(VALUE hash, unsigned int index, ar_hint_t hint)
-{
- RHASH(hash)->ar_hint.ary[index] = hint;
-}
-
-static inline void
-ar_hint_set(VALUE hash, unsigned int index, st_hash_t hash_value)
-{
- ar_hint_set_hint(hash, index, ar_do_hash_hint(hash_value));
-}
-
-static inline void
-ar_clear_entry(VALUE hash, unsigned int index)
-{
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, index);
- pair->key = Qundef;
- ar_hint_set_hint(hash, index, RHASH_AR_CLEARED_HINT);
-}
-
-static inline int
-ar_cleared_entry(VALUE hash, unsigned int index)
-{
- if (ar_hint(hash, index) == RHASH_AR_CLEARED_HINT) {
- /* RHASH_AR_CLEARED_HINT is only a hint, not mean cleared entry,
- * so you need to check key == Qundef
- */
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, index);
- return pair->key == Qundef;
- }
- else {
- return FALSE;
- }
-}
-
-static inline void
-ar_set_entry(VALUE hash, unsigned int index, st_data_t key, st_data_t val, st_hash_t hash_value)
-{
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, index);
- pair->key = key;
- pair->val = val;
- ar_hint_set(hash, index, hash_value);
-}
-
-#define RHASH_AR_TABLE_SIZE(h) (HASH_ASSERT(RHASH_AR_TABLE_P(h)), \
- RHASH_AR_TABLE_SIZE_RAW(h))
-
-#define RHASH_AR_TABLE_BOUND_RAW(h) \
- ((unsigned int)((RBASIC(h)->flags >> RHASH_AR_TABLE_BOUND_SHIFT) & \
- (RHASH_AR_TABLE_BOUND_MASK >> RHASH_AR_TABLE_BOUND_SHIFT)))
-
-#define RHASH_AR_TABLE_BOUND(h) (HASH_ASSERT(RHASH_AR_TABLE_P(h)), \
- RHASH_AR_TABLE_BOUND_RAW(h))
-
-#define RHASH_ST_TABLE_SET(h, s) rb_hash_st_table_set(h, s)
-#define RHASH_TYPE(hash) (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type)
-
-#define HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(HASH_DEBUG, expr, #expr)
-
-#if HASH_DEBUG
-#define hash_verify(hash) hash_verify_(hash, __FILE__, __LINE__)
-
-void
-rb_hash_dump(VALUE hash)
-{
- rb_obj_info_dump(hash);
-
- if (RHASH_AR_TABLE_P(hash)) {
- unsigned i, n = 0, bound = RHASH_AR_TABLE_BOUND(hash);
-
- fprintf(stderr, " size:%u bound:%u\n",
- RHASH_AR_TABLE_SIZE(hash), RHASH_AR_TABLE_BOUND(hash));
-
- for (i=0; i<bound; i++) {
- st_data_t k, v;
-
- if (!ar_cleared_entry(hash, i)) {
- char b1[0x100], b2[0x100];
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- k = pair->key;
- v = pair->val;
- fprintf(stderr, " %d key:%s val:%s hint:%02x\n", i,
- rb_raw_obj_info(b1, 0x100, k),
- rb_raw_obj_info(b2, 0x100, v),
- ar_hint(hash, i));
- n++;
- }
- else {
- fprintf(stderr, " %d empty\n", i);
- }
- }
- }
-}
-
-static VALUE
-hash_verify_(VALUE hash, const char *file, int line)
-{
- HASH_ASSERT(RB_TYPE_P(hash, T_HASH));
-
- if (RHASH_AR_TABLE_P(hash)) {
- unsigned i, n = 0, bound = RHASH_AR_TABLE_BOUND(hash);
-
- for (i=0; i<bound; i++) {
- st_data_t k, v;
- if (!ar_cleared_entry(hash, i)) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- k = pair->key;
- v = pair->val;
- HASH_ASSERT(k != Qundef);
- HASH_ASSERT(v != Qundef);
- n++;
- }
- }
- if (n != RHASH_AR_TABLE_SIZE(hash)) {
- rb_bug("n:%u, RHASH_AR_TABLE_SIZE:%u", n, RHASH_AR_TABLE_SIZE(hash));
- }
- }
- else {
- HASH_ASSERT(RHASH_ST_TABLE(hash) != NULL);
- HASH_ASSERT(RHASH_AR_TABLE_SIZE_RAW(hash) == 0);
- HASH_ASSERT(RHASH_AR_TABLE_BOUND_RAW(hash) == 0);
- }
-
- if (RHASH_TRANSIENT_P(hash)) {
- volatile st_data_t MAYBE_UNUSED(key) = RHASH_AR_TABLE_REF(hash, 0)->key; /* read */
- HASH_ASSERT(RHASH_AR_TABLE(hash) != NULL);
- HASH_ASSERT(rb_transient_heap_managed_ptr_p(RHASH_AR_TABLE(hash)));
- }
- return hash;
-}
-
-#else
-#define hash_verify(h) ((void)0)
-#endif
-
-static inline int
-RHASH_TABLE_NULL_P(VALUE hash)
-{
- if (RHASH(hash)->as.ar == NULL) {
- HASH_ASSERT(RHASH_AR_TABLE_P(hash));
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-static inline int
-RHASH_TABLE_EMPTY_P(VALUE hash)
-{
- return RHASH_SIZE(hash) == 0;
-}
-
-int
-rb_hash_ar_table_p(VALUE hash)
-{
- if (FL_TEST_RAW((hash), RHASH_ST_TABLE_FLAG)) {
- HASH_ASSERT(RHASH(hash)->as.st != NULL);
- return FALSE;
- }
- else {
- return TRUE;
- }
-}
-
-ar_table *
-rb_hash_ar_table(VALUE hash)
-{
- HASH_ASSERT(RHASH_AR_TABLE_P(hash));
- return RHASH(hash)->as.ar;
-}
-
-st_table *
-rb_hash_st_table(VALUE hash)
-{
- HASH_ASSERT(!RHASH_AR_TABLE_P(hash));
- return RHASH(hash)->as.st;
-}
-
-void
-rb_hash_st_table_set(VALUE hash, st_table *st)
-{
- HASH_ASSERT(st != NULL);
- FL_SET_RAW((hash), RHASH_ST_TABLE_FLAG);
- RHASH(hash)->as.st = st;
-}
-
-static void
-hash_ar_table_set(VALUE hash, ar_table *ar)
-{
- HASH_ASSERT(RHASH_AR_TABLE_P(hash));
- HASH_ASSERT((RHASH_TRANSIENT_P(hash) && ar == NULL) ? FALSE : TRUE);
- RHASH(hash)->as.ar = ar;
- hash_verify(hash);
-}
-
-#define RHASH_SET_ST_FLAG(h) FL_SET_RAW(h, RHASH_ST_TABLE_FLAG)
-#define RHASH_UNSET_ST_FLAG(h) FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG)
-
-static inline void
-RHASH_AR_TABLE_BOUND_SET(VALUE h, st_index_t n)
-{
- HASH_ASSERT(RHASH_AR_TABLE_P(h));
- HASH_ASSERT(n <= RHASH_AR_TABLE_MAX_BOUND);
-
- RBASIC(h)->flags &= ~RHASH_AR_TABLE_BOUND_MASK;
- RBASIC(h)->flags |= n << RHASH_AR_TABLE_BOUND_SHIFT;
-}
-
-static inline void
-RHASH_AR_TABLE_SIZE_SET(VALUE h, st_index_t n)
-{
- HASH_ASSERT(RHASH_AR_TABLE_P(h));
- HASH_ASSERT(n <= RHASH_AR_TABLE_MAX_SIZE);
-
- RBASIC(h)->flags &= ~RHASH_AR_TABLE_SIZE_MASK;
- RBASIC(h)->flags |= n << RHASH_AR_TABLE_SIZE_SHIFT;
-}
-
-static inline void
-HASH_AR_TABLE_SIZE_ADD(VALUE h, st_index_t n)
-{
- HASH_ASSERT(RHASH_AR_TABLE_P(h));
-
- RHASH_AR_TABLE_SIZE_SET(h, RHASH_AR_TABLE_SIZE(h) + n);
-
- hash_verify(h);
-}
-
-#define RHASH_AR_TABLE_SIZE_INC(h) HASH_AR_TABLE_SIZE_ADD(h, 1)
-
-static inline void
-RHASH_AR_TABLE_SIZE_DEC(VALUE h)
-{
- HASH_ASSERT(RHASH_AR_TABLE_P(h));
- int new_size = RHASH_AR_TABLE_SIZE(h) - 1;
-
- if (new_size != 0) {
- RHASH_AR_TABLE_SIZE_SET(h, new_size);
- }
- else {
- RHASH_AR_TABLE_SIZE_SET(h, 0);
- RHASH_AR_TABLE_BOUND_SET(h, 0);
- }
- hash_verify(h);
-}
-
-static inline void
-RHASH_AR_TABLE_CLEAR(VALUE h)
-{
- RBASIC(h)->flags &= ~RHASH_AR_TABLE_SIZE_MASK;
- RBASIC(h)->flags &= ~RHASH_AR_TABLE_BOUND_MASK;
-
- hash_ar_table_set(h, NULL);
-}
-
-static ar_table*
-ar_alloc_table(VALUE hash)
-{
- ar_table *tab = (ar_table*)rb_transient_heap_alloc(hash, sizeof(ar_table));
-
- if (tab != NULL) {
- RHASH_SET_TRANSIENT_FLAG(hash);
- }
- else {
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- tab = (ar_table*)ruby_xmalloc(sizeof(ar_table));
- }
-
- RHASH_AR_TABLE_SIZE_SET(hash, 0);
- RHASH_AR_TABLE_BOUND_SET(hash, 0);
- hash_ar_table_set(hash, tab);
-
- return tab;
-}
-
-NOINLINE(static int ar_equal(VALUE x, VALUE y));
-
-static int
-ar_equal(VALUE x, VALUE y)
-{
- return rb_any_cmp(x, y) == 0;
-}
-
-static unsigned
-ar_find_entry_hint(VALUE hash, ar_hint_t hint, st_data_t key)
-{
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
- const ar_hint_t *hints = RHASH(hash)->ar_hint.ary;
-
- /* if table is NULL, then bound also should be 0 */
-
- for (i = 0; i < bound; i++) {
- if (hints[i] == hint) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- if (ar_equal(key, pair->key)) {
- RB_DEBUG_COUNTER_INC(artable_hint_hit);
- return i;
- }
- else {
-#if 0
- static int pid;
- static char fname[256];
- static FILE *fp;
-
- if (pid != getpid()) {
- snprintf(fname, sizeof(fname), "/tmp/ruby-armiss.%d", pid = getpid());
- if ((fp = fopen(fname, "w")) == NULL) rb_bug("fopen");
- }
-
- st_hash_t h1 = ar_do_hash(key);
- st_hash_t h2 = ar_do_hash(pair->key);
-
- fprintf(fp, "miss: hash_eq:%d hints[%d]:%02x hint:%02x\n"
- " key :%016lx %s\n"
- " pair->key:%016lx %s\n",
- h1 == h2, i, hints[i], hint,
- h1, rb_obj_info(key), h2, rb_obj_info(pair->key));
-#endif
- RB_DEBUG_COUNTER_INC(artable_hint_miss);
- }
- }
- }
- RB_DEBUG_COUNTER_INC(artable_hint_notfound);
- return RHASH_AR_TABLE_MAX_BOUND;
-}
-
-static unsigned
-ar_find_entry(VALUE hash, st_hash_t hash_value, st_data_t key)
-{
- ar_hint_t hint = ar_do_hash_hint(hash_value);
- return ar_find_entry_hint(hash, hint, key);
-}
-
-static inline void
-ar_free_and_clear_table(VALUE hash)
-{
- ar_table *tab = RHASH_AR_TABLE(hash);
-
- if (tab) {
- if (RHASH_TRANSIENT_P(hash)) {
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- }
- else {
- ruby_xfree(RHASH_AR_TABLE(hash));
- }
- RHASH_AR_TABLE_CLEAR(hash);
- }
- HASH_ASSERT(RHASH_AR_TABLE_SIZE(hash) == 0);
- HASH_ASSERT(RHASH_AR_TABLE_BOUND(hash) == 0);
- HASH_ASSERT(RHASH_TRANSIENT_P(hash) == 0);
-}
-
-static void
-ar_try_convert_table(VALUE hash)
-{
- if (!RHASH_AR_TABLE_P(hash)) return;
-
- const unsigned size = RHASH_AR_TABLE_SIZE(hash);
-
- st_table *new_tab;
- st_index_t i;
-
- if (size < RHASH_AR_TABLE_MAX_SIZE) {
- return;
- }
-
- new_tab = st_init_table_with_size(&objhash, size * 2);
-
- for (i = 0; i < RHASH_AR_TABLE_MAX_BOUND; i++) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- st_add_direct(new_tab, pair->key, pair->val);
- }
- ar_free_and_clear_table(hash);
- RHASH_ST_TABLE_SET(hash, new_tab);
- return;
-}
-
-static st_table *
-ar_force_convert_table(VALUE hash, const char *file, int line)
-{
- st_table *new_tab;
-
- if (RHASH_ST_TABLE_P(hash)) {
- return RHASH_ST_TABLE(hash);
- }
-
- if (RHASH_AR_TABLE(hash)) {
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
-
-#if RHASH_CONVERT_TABLE_DEBUG
- rb_obj_info_dump(hash);
- fprintf(stderr, "force_convert: %s:%d\n", file, line);
- RB_DEBUG_COUNTER_INC(obj_hash_force_convert);
-#endif
-
- new_tab = st_init_table_with_size(&objhash, RHASH_AR_TABLE_SIZE(hash));
-
- for (i = 0; i < bound; i++) {
- if (ar_cleared_entry(hash, i)) continue;
-
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- st_add_direct(new_tab, pair->key, pair->val);
- }
- ar_free_and_clear_table(hash);
- }
- else {
- new_tab = st_init_table(&objhash);
- }
- RHASH_ST_TABLE_SET(hash, new_tab);
-
- return new_tab;
-}
-
-static ar_table *
-hash_ar_table(VALUE hash)
-{
- if (RHASH_TABLE_NULL_P(hash)) {
- ar_alloc_table(hash);
- }
- return RHASH_AR_TABLE(hash);
-}
-
-static int
-ar_compact_table(VALUE hash)
-{
- const unsigned bound = RHASH_AR_TABLE_BOUND(hash);
- const unsigned size = RHASH_AR_TABLE_SIZE(hash);
-
- if (size == bound) {
- return size;
- }
- else {
- unsigned i, j=0;
- ar_table_pair *pairs = RHASH_AR_TABLE(hash)->pairs;
-
- for (i=0; i<bound; i++) {
- if (ar_cleared_entry(hash, i)) {
- if (j <= i) j = i+1;
- for (; j<bound; j++) {
- if (!ar_cleared_entry(hash, j)) {
- pairs[i] = pairs[j];
- ar_hint_set_hint(hash, i, (st_hash_t)ar_hint(hash, j));
- ar_clear_entry(hash, j);
- j++;
- goto found;
- }
- }
- /* non-empty is not found */
- goto done;
- found:;
- }
- }
- done:
- HASH_ASSERT(i<=bound);
-
- RHASH_AR_TABLE_BOUND_SET(hash, size);
- hash_verify(hash);
- return size;
- }
-}
-
-static int
-ar_add_direct_with_hash(VALUE hash, st_data_t key, st_data_t val, st_hash_t hash_value)
-{
- unsigned bin = RHASH_AR_TABLE_BOUND(hash);
-
- if (RHASH_AR_TABLE_SIZE(hash) >= RHASH_AR_TABLE_MAX_SIZE) {
- return 1;
- }
- else {
- if (UNLIKELY(bin >= RHASH_AR_TABLE_MAX_BOUND)) {
- bin = ar_compact_table(hash);
- hash_ar_table(hash);
- }
- HASH_ASSERT(bin < RHASH_AR_TABLE_MAX_BOUND);
-
- ar_set_entry(hash, bin, key, val, hash_value);
- RHASH_AR_TABLE_BOUND_SET(hash, bin+1);
- RHASH_AR_TABLE_SIZE_INC(hash);
- return 0;
- }
-}
-
-static int
-ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
-{
- if (RHASH_AR_TABLE_SIZE(hash) > 0) {
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
-
- for (i = 0; i < bound; i++) {
- if (ar_cleared_entry(hash, i)) continue;
-
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- enum st_retval retval = (*func)(pair->key, pair->val, arg, 0);
- /* pair may be not valid here because of theap */
-
- switch (retval) {
- case ST_CONTINUE:
- break;
- case ST_CHECK:
- case ST_STOP:
- return 0;
- case ST_REPLACE:
- if (replace) {
- VALUE key = pair->key;
- VALUE val = pair->val;
- retval = (*replace)(&key, &val, arg, TRUE);
-
- // TODO: pair should be same as pair before.
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- pair->key = key;
- pair->val = val;
- }
- break;
- case ST_DELETE:
- ar_clear_entry(hash, i);
- RHASH_AR_TABLE_SIZE_DEC(hash);
- break;
- }
- }
- }
- return 0;
-}
-
-static int
-ar_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
-{
- return ar_general_foreach(hash, func, replace, arg);
-}
-
-struct functor {
- st_foreach_callback_func *func;
- st_data_t arg;
-};
-
-static int
-apply_functor(st_data_t k, st_data_t v, st_data_t d, int _)
-{
- const struct functor *f = (void *)d;
- return f->func(k, v, f->arg);
-}
-
-static int
-ar_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg)
-{
- const struct functor f = { func, arg };
- return ar_general_foreach(hash, apply_functor, NULL, (st_data_t)&f);
-}
-
-static int
-ar_foreach_check(VALUE hash, st_foreach_check_callback_func *func, st_data_t arg,
- st_data_t never)
-{
- if (RHASH_AR_TABLE_SIZE(hash) > 0) {
- unsigned i, ret = 0, bound = RHASH_AR_TABLE_BOUND(hash);
- enum st_retval retval;
- st_data_t key;
- ar_table_pair *pair;
- ar_hint_t hint;
-
- for (i = 0; i < bound; i++) {
- if (ar_cleared_entry(hash, i)) continue;
-
- pair = RHASH_AR_TABLE_REF(hash, i);
- key = pair->key;
- hint = ar_hint(hash, i);
-
- retval = (*func)(key, pair->val, arg, 0);
- hash_verify(hash);
-
- switch (retval) {
- case ST_CHECK: {
- pair = RHASH_AR_TABLE_REF(hash, i);
- if (pair->key == never) break;
- ret = ar_find_entry_hint(hash, hint, key);
- if (ret == RHASH_AR_TABLE_MAX_BOUND) {
- retval = (*func)(0, 0, arg, 1);
- return 2;
- }
- }
- case ST_CONTINUE:
- break;
- case ST_STOP:
- case ST_REPLACE:
- return 0;
- case ST_DELETE: {
- if (!ar_cleared_entry(hash, i)) {
- ar_clear_entry(hash, i);
- RHASH_AR_TABLE_SIZE_DEC(hash);
- }
- break;
- }
- }
- }
- }
- return 0;
-}
-
-static int
-ar_update(VALUE hash, st_data_t key,
- st_update_callback_func *func, st_data_t arg)
-{
- int retval, existing;
- unsigned bin = RHASH_AR_TABLE_MAX_BOUND;
- st_data_t value = 0, old_key;
- st_hash_t hash_value = ar_do_hash(key);
-
- if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) {
- // `#hash` changes ar_table -> st_table
- return -1;
- }
-
- if (RHASH_AR_TABLE_SIZE(hash) > 0) {
- bin = ar_find_entry(hash, hash_value, key);
- existing = (bin != RHASH_AR_TABLE_MAX_BOUND) ? TRUE : FALSE;
- }
- else {
- hash_ar_table(hash); /* allocate ltbl if needed */
- existing = FALSE;
- }
-
- if (existing) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, bin);
- key = pair->key;
- value = pair->val;
- }
- old_key = key;
- retval = (*func)(&key, &value, arg, existing);
- /* pair can be invalid here because of theap */
-
- switch (retval) {
- case ST_CONTINUE:
- if (!existing) {
- if (ar_add_direct_with_hash(hash, key, value, hash_value)) {
- return -1;
- }
- }
- else {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, bin);
- if (old_key != key) {
- pair->key = key;
- }
- pair->val = value;
- }
- break;
- case ST_DELETE:
- if (existing) {
- ar_clear_entry(hash, bin);
- RHASH_AR_TABLE_SIZE_DEC(hash);
- }
- break;
- }
- return existing;
-}
-
-static int
-ar_insert(VALUE hash, st_data_t key, st_data_t value)
-{
- unsigned bin = RHASH_AR_TABLE_BOUND(hash);
- st_hash_t hash_value = ar_do_hash(key);
-
- if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) {
- // `#hash` changes ar_table -> st_table
- return -1;
- }
-
- hash_ar_table(hash); /* prepare ltbl */
-
- bin = ar_find_entry(hash, hash_value, key);
- if (bin == RHASH_AR_TABLE_MAX_BOUND) {
- if (RHASH_AR_TABLE_SIZE(hash) >= RHASH_AR_TABLE_MAX_SIZE) {
- return -1;
- }
- else if (bin >= RHASH_AR_TABLE_MAX_BOUND) {
- bin = ar_compact_table(hash);
- hash_ar_table(hash);
- }
- HASH_ASSERT(bin < RHASH_AR_TABLE_MAX_BOUND);
-
- ar_set_entry(hash, bin, key, value, hash_value);
- RHASH_AR_TABLE_BOUND_SET(hash, bin+1);
- RHASH_AR_TABLE_SIZE_INC(hash);
- return 0;
- }
- else {
- RHASH_AR_TABLE_REF(hash, bin)->val = value;
- return 1;
- }
-}
-
-static int
-ar_lookup(VALUE hash, st_data_t key, st_data_t *value)
-{
- if (RHASH_AR_TABLE_SIZE(hash) == 0) {
- return 0;
- }
- else {
- st_hash_t hash_value = ar_do_hash(key);
- if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) {
- // `#hash` changes ar_table -> st_table
- return st_lookup(RHASH_ST_TABLE(hash), key, value);
- }
- unsigned bin = ar_find_entry(hash, hash_value, key);
-
- if (bin == RHASH_AR_TABLE_MAX_BOUND) {
- return 0;
- }
- else {
- HASH_ASSERT(bin < RHASH_AR_TABLE_MAX_BOUND);
- if (value != NULL) {
- *value = RHASH_AR_TABLE_REF(hash, bin)->val;
- }
- return 1;
- }
- }
-}
-
-static int
-ar_delete(VALUE hash, st_data_t *key, st_data_t *value)
-{
- unsigned bin;
- st_hash_t hash_value = ar_do_hash(*key);
-
- if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) {
- // `#hash` changes ar_table -> st_table
- return st_delete(RHASH_ST_TABLE(hash), key, value);
- }
-
- bin = ar_find_entry(hash, hash_value, *key);
-
- if (bin == RHASH_AR_TABLE_MAX_BOUND) {
- if (value != 0) *value = 0;
- return 0;
- }
- else {
- if (value != 0) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, bin);
- *value = pair->val;
- }
- ar_clear_entry(hash, bin);
- RHASH_AR_TABLE_SIZE_DEC(hash);
- return 1;
- }
-}
-
-static int
-ar_shift(VALUE hash, st_data_t *key, st_data_t *value)
-{
- if (RHASH_AR_TABLE_SIZE(hash) > 0) {
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
-
- for (i = 0; i < bound; i++) {
- if (!ar_cleared_entry(hash, i)) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- if (value != 0) *value = pair->val;
- *key = pair->key;
- ar_clear_entry(hash, i);
- RHASH_AR_TABLE_SIZE_DEC(hash);
- return 1;
- }
- }
- }
- if (value != NULL) *value = 0;
- return 0;
-}
-
-static long
-ar_keys(VALUE hash, st_data_t *keys, st_index_t size)
-{
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
- st_data_t *keys_start = keys, *keys_end = keys + size;
-
- for (i = 0; i < bound; i++) {
- if (keys == keys_end) {
- break;
- }
- else {
- if (!ar_cleared_entry(hash, i)) {
- *keys++ = RHASH_AR_TABLE_REF(hash, i)->key;
- }
- }
- }
-
- return keys - keys_start;
-}
-
-static long
-ar_values(VALUE hash, st_data_t *values, st_index_t size)
-{
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
- st_data_t *values_start = values, *values_end = values + size;
-
- for (i = 0; i < bound; i++) {
- if (values == values_end) {
- break;
- }
- else {
- if (!ar_cleared_entry(hash, i)) {
- *values++ = RHASH_AR_TABLE_REF(hash, i)->val;
- }
- }
- }
-
- return values - values_start;
-}
-
-static ar_table*
-ar_copy(VALUE hash1, VALUE hash2)
-{
- ar_table *old_tab = RHASH_AR_TABLE(hash2);
-
- if (old_tab != NULL) {
- ar_table *new_tab = RHASH_AR_TABLE(hash1);
- if (new_tab == NULL) {
- new_tab = (ar_table*) rb_transient_heap_alloc(hash1, sizeof(ar_table));
- if (new_tab != NULL) {
- RHASH_SET_TRANSIENT_FLAG(hash1);
- }
- else {
- RHASH_UNSET_TRANSIENT_FLAG(hash1);
- new_tab = (ar_table*)ruby_xmalloc(sizeof(ar_table));
- }
- }
- *new_tab = *old_tab;
- RHASH(hash1)->ar_hint.word = RHASH(hash2)->ar_hint.word;
- RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
- RHASH_AR_TABLE_SIZE_SET(hash1, RHASH_AR_TABLE_SIZE(hash2));
- hash_ar_table_set(hash1, new_tab);
-
- rb_gc_writebarrier_remember(hash1);
- return new_tab;
- }
- else {
- RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
- RHASH_AR_TABLE_SIZE_SET(hash1, RHASH_AR_TABLE_SIZE(hash2));
-
- if (RHASH_TRANSIENT_P(hash1)) {
- RHASH_UNSET_TRANSIENT_FLAG(hash1);
- }
- else if (RHASH_AR_TABLE(hash1)) {
- ruby_xfree(RHASH_AR_TABLE(hash1));
- }
-
- hash_ar_table_set(hash1, NULL);
-
- rb_gc_writebarrier_remember(hash1);
- return old_tab;
- }
-}
-
-static void
-ar_clear(VALUE hash)
-{
- if (RHASH_AR_TABLE(hash) != NULL) {
- RHASH_AR_TABLE_SIZE_SET(hash, 0);
- RHASH_AR_TABLE_BOUND_SET(hash, 0);
- }
- else {
- HASH_ASSERT(RHASH_AR_TABLE_SIZE(hash) == 0);
- HASH_ASSERT(RHASH_AR_TABLE_BOUND(hash) == 0);
- }
-}
-
-#if USE_TRANSIENT_HEAP
-void
-rb_hash_transient_heap_evacuate(VALUE hash, int promote)
-{
- if (RHASH_TRANSIENT_P(hash)) {
- ar_table *new_tab;
- ar_table *old_tab = RHASH_AR_TABLE(hash);
-
- if (UNLIKELY(old_tab == NULL)) {
- rb_gc_force_recycle(hash);
- return;
- }
- HASH_ASSERT(old_tab != NULL);
- if (promote) {
- promote:
- new_tab = ruby_xmalloc(sizeof(ar_table));
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- }
- else {
- new_tab = rb_transient_heap_alloc(hash, sizeof(ar_table));
- if (new_tab == NULL) goto promote;
- }
- *new_tab = *old_tab;
- hash_ar_table_set(hash, new_tab);
- }
- hash_verify(hash);
-}
-#endif
-
typedef int st_foreach_func(st_data_t, st_data_t, st_data_t);
struct foreach_safe_arg {
@@ -1307,7 +321,7 @@ foreach_safe_i(st_data_t key, st_data_t value, st_data_t args, int error)
}
void
-st_foreach_safe(st_table *table, st_foreach_func *func, st_data_t a)
+st_foreach_safe(st_table *table, int (*func)(ANYARGS), st_data_t a)
{
struct foreach_safe_arg arg;
@@ -1328,27 +342,6 @@ struct hash_foreach_arg {
};
static int
-hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
-{
- struct hash_foreach_arg *arg = (struct hash_foreach_arg *)argp;
- int status;
-
- if (error) return ST_STOP;
- status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
- /* TODO: rehash check? rb_raise(rb_eRuntimeError, "rehash occurred during iteration"); */
-
- switch (status) {
- case ST_DELETE:
- return ST_DELETE;
- case ST_CONTINUE:
- break;
- case ST_STOP:
- return ST_STOP;
- }
- return ST_CHECK;
-}
-
-static int
hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
{
struct hash_foreach_arg *arg = (struct hash_foreach_arg *)argp;
@@ -1356,10 +349,10 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
st_table *tbl;
if (error) return ST_STOP;
- tbl = RHASH_ST_TABLE(arg->hash);
+ tbl = RHASH(arg->hash)->ntbl;
status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
- if (RHASH_ST_TABLE(arg->hash) != tbl) {
- rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
+ if (RHASH(arg->hash)->ntbl != tbl) {
+ rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
}
switch (status) {
case ST_DELETE:
@@ -1372,142 +365,42 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
return ST_CHECK;
}
-static int
-iter_lev_in_ivar(VALUE hash)
-{
- VALUE levval = rb_ivar_get(hash, id_hash_iter_lev);
- HASH_ASSERT(FIXNUM_P(levval));
- return FIX2INT(levval);
-}
-
-void rb_ivar_set_internal(VALUE obj, ID id, VALUE val);
-
-static void
-iter_lev_in_ivar_set(VALUE hash, int lev)
-{
- rb_ivar_set_internal(hash, id_hash_iter_lev, INT2FIX(lev));
-}
-
-static int
-iter_lev_in_flags(VALUE hash)
-{
- unsigned int u = (unsigned int)((RBASIC(hash)->flags >> RHASH_LEV_SHIFT) & RHASH_LEV_MAX);
- return (int)u;
-}
-
-static int
-RHASH_ITER_LEV(VALUE hash)
-{
- int lev = iter_lev_in_flags(hash);
-
- if (lev == RHASH_LEV_MAX) {
- return iter_lev_in_ivar(hash);
- }
- else {
- return lev;
- }
-}
-
-static void
-hash_iter_lev_inc(VALUE hash)
-{
- int lev = iter_lev_in_flags(hash);
- if (lev == RHASH_LEV_MAX) {
- lev = iter_lev_in_ivar(hash);
- iter_lev_in_ivar_set(hash, lev+1);
- }
- else {
- lev += 1;
- RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | (lev << RHASH_LEV_SHIFT));
- if (lev == RHASH_LEV_MAX) {
- iter_lev_in_ivar_set(hash, lev);
- }
- }
-}
-
-static void
-hash_iter_lev_dec(VALUE hash)
-{
- int lev = iter_lev_in_flags(hash);
- if (lev == RHASH_LEV_MAX) {
- lev = iter_lev_in_ivar(hash);
- HASH_ASSERT(lev > 0);
- iter_lev_in_ivar_set(hash, lev-1);
- }
- else {
- HASH_ASSERT(lev > 0);
- RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((lev-1) << RHASH_LEV_SHIFT));
- }
-}
-
static VALUE
hash_foreach_ensure_rollback(VALUE hash)
{
- hash_iter_lev_inc(hash);
+ RHASH_ITER_LEV(hash)++;
return 0;
}
static VALUE
hash_foreach_ensure(VALUE hash)
{
- hash_iter_lev_dec(hash);
+ RHASH_ITER_LEV(hash)--;
return 0;
}
-int
-rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg)
-{
- if (RHASH_AR_TABLE_P(hash)) {
- return ar_foreach(hash, func, arg);
- }
- else {
- return st_foreach(RHASH_ST_TABLE(hash), func, arg);
- }
-}
-
-int
-rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
-{
- if (RHASH_AR_TABLE_P(hash)) {
- return ar_foreach_with_replace(hash, func, replace, arg);
- }
- else {
- return st_foreach_with_replace(RHASH_ST_TABLE(hash), func, replace, arg);
- }
-}
-
static VALUE
hash_foreach_call(VALUE arg)
{
VALUE hash = ((struct hash_foreach_arg *)arg)->hash;
- int ret = 0;
- if (RHASH_AR_TABLE_P(hash)) {
- ret = ar_foreach_check(hash, hash_ar_foreach_iter,
- (st_data_t)arg, (st_data_t)Qundef);
- }
- else if (RHASH_ST_TABLE_P(hash)) {
- ret = st_foreach_check(RHASH_ST_TABLE(hash), hash_foreach_iter,
- (st_data_t)arg, (st_data_t)Qundef);
- }
- if (ret) {
- rb_raise(rb_eRuntimeError, "ret: %d, hash modified during iteration", ret);
+ if (st_foreach_check(RHASH(hash)->ntbl, hash_foreach_iter, (st_data_t)arg, (st_data_t)Qundef)) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
}
return Qnil;
}
void
-rb_hash_foreach(VALUE hash, rb_foreach_func *func, VALUE farg)
+rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg)
{
struct hash_foreach_arg arg;
- if (RHASH_TABLE_EMPTY_P(hash))
+ if (!RHASH(hash)->ntbl)
return;
- hash_iter_lev_inc(hash);
+ RHASH_ITER_LEV(hash)++;
arg.hash = hash;
arg.func = (rb_foreach_func *)func;
arg.arg = farg;
rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
- hash_verify(hash);
}
static VALUE
@@ -1541,39 +434,31 @@ rb_hash_new(void)
return hash_alloc(rb_cHash);
}
-MJIT_FUNC_EXPORTED VALUE
-rb_hash_new_with_size(st_index_t size)
+VALUE
+rb_hash_new_compare_by_id(void)
{
- VALUE ret = rb_hash_new();
- if (size == 0) {
- /* do nothing */
- }
- else if (size <= RHASH_AR_TABLE_MAX_SIZE) {
- ar_alloc_table(ret);
- }
- else {
- RHASH_ST_TABLE_SET(ret, st_init_table_with_size(&objhash, size));
- }
- return ret;
+ VALUE hash = rb_hash_new();
+ RHASH(hash)->ntbl = rb_init_identtable();
+ return hash;
}
-static VALUE
-hash_copy(VALUE ret, VALUE hash)
+VALUE
+rb_hash_new_with_size(st_index_t size)
{
- if (!RHASH_EMPTY_P(hash)) {
- if (RHASH_AR_TABLE_P(hash))
- ar_copy(ret, hash);
- else if (RHASH_ST_TABLE_P(hash))
- RHASH_ST_TABLE_SET(ret, st_copy(RHASH_ST_TABLE(hash)));
- }
+ VALUE ret = rb_hash_new();
+ if (size)
+ RHASH(ret)->ntbl = st_init_table_with_size(&objhash, size);
return ret;
}
static VALUE
hash_dup(VALUE hash, VALUE klass, VALUE flags)
{
- return hash_copy(hash_alloc_flags(klass, flags, RHASH_IFNONE(hash)),
- hash);
+ VALUE ret = hash_alloc_flags(klass, flags,
+ RHASH_IFNONE(hash));
+ if (!RHASH_EMPTY_P(hash))
+ RHASH(ret)->ntbl = st_copy(RHASH(hash)->ntbl);
+ return ret;
}
VALUE
@@ -1581,49 +466,45 @@ rb_hash_dup(VALUE hash)
{
const VALUE flags = RBASIC(hash)->flags;
VALUE ret = hash_dup(hash, rb_obj_class(hash),
- flags & (FL_EXIVAR|RHASH_PROC_DEFAULT));
+ flags & (FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT));
if (flags & FL_EXIVAR)
rb_copy_generic_ivar(ret, hash);
return ret;
}
-MJIT_FUNC_EXPORTED VALUE
-rb_hash_resurrect(VALUE hash)
-{
- VALUE ret = hash_dup(hash, rb_cHash, 0);
- return ret;
-}
-
static void
rb_hash_modify_check(VALUE hash)
{
rb_check_frozen(hash);
}
-MJIT_FUNC_EXPORTED struct st_table *
-#if RHASH_CONVERT_TABLE_DEBUG
-rb_hash_tbl_raw(VALUE hash, const char *file, int line)
+static struct st_table *
+hash_tbl(VALUE hash)
{
- return ar_force_convert_table(hash, file, line);
+ if (!RHASH(hash)->ntbl) {
+ RHASH(hash)->ntbl = st_init_table(&objhash);
+ }
+ return RHASH(hash)->ntbl;
}
-#else
-rb_hash_tbl_raw(VALUE hash)
+
+struct st_table *
+rb_hash_tbl(VALUE hash)
{
- return ar_force_convert_table(hash, NULL, 0);
+ OBJ_WB_UNPROTECT(hash);
+ return hash_tbl(hash);
}
-#endif
struct st_table *
-rb_hash_tbl(VALUE hash, const char *file, int line)
+rb_hash_tbl_raw(VALUE hash)
{
- OBJ_WB_UNPROTECT(hash);
- return RHASH_TBL_RAW(hash);
+ return hash_tbl(hash);
}
static void
rb_hash_modify(VALUE hash)
{
rb_hash_modify_check(hash);
+ hash_tbl(hash);
}
NORETURN(static void no_new_key(void));
@@ -1663,22 +544,6 @@ struct update_arg {
typedef int (*tbl_update_func)(st_data_t *, st_data_t *, st_data_t, int);
-int
-rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func func, st_data_t arg)
-{
- if (RHASH_AR_TABLE_P(hash)) {
- int result = ar_update(hash, (st_data_t)key, func, arg);
- if (result == -1) {
- ar_try_convert_table(hash);
- }
- else {
- return result;
- }
- }
-
- return st_update(RHASH_ST_TABLE(hash), (st_data_t)key, func, arg);
-}
-
static int
tbl_update(VALUE hash, VALUE key, tbl_update_func func, st_data_t optional_arg)
{
@@ -1692,7 +557,7 @@ tbl_update(VALUE hash, VALUE key, tbl_update_func func, st_data_t optional_arg)
arg.new_value = 0;
arg.old_value = Qundef;
- result = rb_hash_stlike_update(hash, key, func, (st_data_t)&arg);
+ result = st_update(RHASH(hash)->ntbl, (st_data_t)key, func, (st_data_t)&arg);
/* write barrier */
if (arg.new_key) RB_OBJ_WRITTEN(hash, arg.old_key, arg.new_key);
@@ -1722,7 +587,7 @@ set_proc_default(VALUE hash, VALUE proc)
}
}
- FL_SET_RAW(hash, RHASH_PROC_DEFAULT);
+ FL_SET_RAW(hash, HASH_PROC_DEFAULT);
RHASH_SET_IFNONE(hash, proc);
}
@@ -1807,15 +672,12 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
VALUE hash, tmp;
if (argc == 1) {
- tmp = rb_hash_s_try_convert(Qnil, argv[0]);
+ tmp = rb_hash_s_try_convert(Qnil, argv[0]);
if (!NIL_P(tmp)) {
hash = hash_alloc(klass);
- if (RHASH_AR_TABLE_P(tmp)) {
- ar_copy(hash, tmp);
+ if (RHASH(tmp)->ntbl) {
+ RHASH(hash)->ntbl = st_copy(RHASH(tmp)->ntbl);
}
- else {
- RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(tmp)));
- }
return hash;
}
@@ -1830,8 +692,17 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
VALUE key, val = Qnil;
if (NIL_P(v)) {
+#if 0 /* refix in the next release */
rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)",
rb_builtin_class_name(e), i);
+
+#else
+ rb_warn("wrong element type %s at %ld (expected array)",
+ rb_builtin_class_name(e), i);
+ rb_warn("ignoring wrong elements is deprecated, remove them explicitly");
+ rb_warn("this causes ArgumentError in the next release");
+ continue;
+#endif
}
switch (RARRAY_LEN(v)) {
default:
@@ -1853,7 +724,7 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
hash = hash_alloc(klass);
rb_hash_bulk_insert(argc, argv, hash);
- hash_verify(hash);
+
return hash;
}
@@ -1887,52 +758,6 @@ rb_hash_s_try_convert(VALUE dummy, VALUE hash)
return rb_check_hash_type(hash);
}
-/*
- * call-seq:
- * Hash.ruby2_keywords_hash?(hash) -> true or false
- *
- * Checks if a given hash is flagged by Module#ruby2_keywords (or
- * Proc#ruby2_keywords).
- * This method is not for casual use; debugging, researching, and
- * some truly necessary cases like serialization of arguments.
- *
- * ruby2_keywords def foo(*args)
- * Hash.ruby2_keywords_hash?(args.last)
- * end
- * foo(k: 1) #=> true
- * foo({k: 1}) #=> false
- */
-static VALUE
-rb_hash_s_ruby2_keywords_hash_p(VALUE dummy, VALUE hash)
-{
- Check_Type(hash, T_HASH);
- return (RHASH(hash)->basic.flags & RHASH_PASS_AS_KEYWORDS) ? Qtrue : Qfalse;
-}
-
-/*
- * call-seq:
- * Hash.ruby2_keywords_hash(hash) -> hash
- *
- * Duplicates a given hash and adds a ruby2_keywords flag.
- * This method is not for casual use; debugging, researching, and
- * some truly necessary cases like deserialization of arguments.
- *
- * h = {k: 1}
- * h = Hash.ruby2_keywords_hash(h)
- * def foo(k: 42)
- * k
- * end
- * foo(*[h]) #=> 1 with neither a warning or an error
- */
-static VALUE
-rb_hash_s_ruby2_keywords_hash(VALUE dummy, VALUE hash)
-{
- Check_Type(hash, T_HASH);
- hash = rb_hash_dup(hash);
- RHASH(hash)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
- return hash;
-}
-
struct rehash_arg {
VALUE hash;
st_table *tbl;
@@ -1941,12 +766,9 @@ struct rehash_arg {
static int
rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg)
{
- if (RHASH_AR_TABLE_P(arg)) {
- ar_insert(arg, (st_data_t)key, (st_data_t)value);
- }
- else {
- st_insert(RHASH_ST_TABLE(arg), (st_data_t)key, (st_data_t)value);
- }
+ st_table *tbl = (st_table *)arg;
+
+ st_insert(tbl, (st_data_t)key, (st_data_t)value);
return ST_CONTINUE;
}
@@ -1956,9 +778,9 @@ rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg)
*
* Rebuilds the hash based on the current hash values for each key. If
* values of key objects have changed since they were inserted, this
- * method will reindex <i>hsh</i>. If Hash#rehash is
+ * method will reindex <i>hsh</i>. If <code>Hash#rehash</code> is
* called while an iterator is traversing the hash, a
- * RuntimeError will be raised in the iterator.
+ * <code>RuntimeError</code> will be raised in the iterator.
*
* a = [ "a", "b" ]
* c = [ "c", "d" ]
@@ -1980,25 +802,17 @@ rb_hash_rehash(VALUE hash)
rb_raise(rb_eRuntimeError, "rehash during iteration");
}
rb_hash_modify_check(hash);
- if (RHASH_AR_TABLE_P(hash)) {
- tmp = hash_alloc(0);
- ar_alloc_table(tmp);
- rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- ar_free_and_clear_table(hash);
- ar_copy(hash, tmp);
- ar_free_and_clear_table(tmp);
- }
- else if (RHASH_ST_TABLE_P(hash)) {
- st_table *old_tab = RHASH_ST_TABLE(hash);
- tmp = hash_alloc(0);
- tbl = st_init_table_with_size(old_tab->type, old_tab->num_entries);
- RHASH_ST_TABLE_SET(tmp, tbl);
- rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- st_free_table(old_tab);
- RHASH_ST_TABLE_SET(hash, tbl);
- RHASH_ST_CLEAR(tmp);
- }
- hash_verify(hash);
+ if (!RHASH(hash)->ntbl)
+ return hash;
+ tmp = hash_alloc(0);
+ tbl = st_init_table_with_size(RHASH(hash)->ntbl->type, RHASH(hash)->ntbl->num_entries);
+ RHASH(tmp)->ntbl = tbl;
+
+ rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tbl);
+ st_free_table(RHASH(hash)->ntbl);
+ RHASH(hash)->ntbl = tbl;
+ RHASH(tmp)->ntbl = 0;
+
return hash;
}
@@ -2007,7 +821,7 @@ rb_hash_default_value(VALUE hash, VALUE key)
{
if (rb_method_basic_definition_p(CLASS_OF(hash), id_default)) {
VALUE ifnone = RHASH_IFNONE(hash);
- if (!FL_TEST(hash, RHASH_PROC_DEFAULT)) return ifnone;
+ if (!FL_TEST(hash, HASH_PROC_DEFAULT)) return ifnone;
if (key == Qundef) return Qnil;
return rb_funcall(ifnone, id_yield, 2, hash, key);
}
@@ -2016,32 +830,13 @@ rb_hash_default_value(VALUE hash, VALUE key)
}
}
-static inline int
-hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
-{
- hash_verify(hash);
-
- if (RHASH_AR_TABLE_P(hash)) {
- return ar_lookup(hash, key, pval);
- }
- else {
- return st_lookup(RHASH_ST_TABLE(hash), key, pval);
- }
-}
-
-MJIT_FUNC_EXPORTED int
-rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
-{
- return hash_stlike_lookup(hash, key, pval);
-}
-
/*
* call-seq:
* hsh[key] -> value
*
* Element Reference---Retrieves the <i>value</i> object corresponding
* to the <i>key</i> object. If not found, returns the default value (see
- * Hash::new for details).
+ * <code>Hash::new</code> for details).
*
* h = { "a" => 100, "b" => 200 }
* h["a"] #=> 100
@@ -2054,12 +849,10 @@ rb_hash_aref(VALUE hash, VALUE key)
{
st_data_t val;
- if (hash_stlike_lookup(hash, key, &val)) {
- return (VALUE)val;
- }
- else {
- return rb_hash_default_value(hash, key);
+ if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
+ return rb_hash_default_value(hash, key);
}
+ return (VALUE)val;
}
VALUE
@@ -2067,12 +860,10 @@ rb_hash_lookup2(VALUE hash, VALUE key, VALUE def)
{
st_data_t val;
- if (hash_stlike_lookup(hash, key, &val)) {
- return (VALUE)val;
- }
- else {
- return def; /* without Hash#default */
+ if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
+ return def; /* without Hash#default */
}
+ return (VALUE)val;
}
VALUE
@@ -2088,7 +879,7 @@ rb_hash_lookup(VALUE hash, VALUE key)
*
* Returns a value from the hash for the given key. If the key can't be
* found, there are several options: With no other arguments, it will
- * raise a KeyError exception; if <i>default</i> is given,
+ * raise a <code>KeyError</code> exception; if <i>default</i> is given,
* then that will be returned; if the optional code block is specified,
* then that will be run and its result returned.
*
@@ -2124,26 +915,19 @@ rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
if (block_given && argc == 2) {
rb_warn("block supersedes default value argument");
}
-
- if (hash_stlike_lookup(hash, key, &val)) {
- return (VALUE)val;
- }
- else {
- if (block_given) {
- return rb_yield(key);
- }
- else if (argc == 1) {
- VALUE desc = rb_protect(rb_inspect, key, 0);
- if (NIL_P(desc)) {
- desc = rb_any_to_s(key);
- }
- desc = rb_str_ellipsize(desc, 65);
- rb_key_err_raise(rb_sprintf("key not found: %"PRIsVALUE, desc), hash, key);
- }
- else {
- return argv[1];
- }
+ if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
+ if (block_given) return rb_yield(key);
+ if (argc == 1) {
+ VALUE desc = rb_protect(rb_inspect, key, 0);
+ if (NIL_P(desc)) {
+ desc = rb_any_to_s(key);
+ }
+ desc = rb_str_ellipsize(desc, 65);
+ rb_key_err_raise(rb_sprintf("key not found: %"PRIsVALUE, desc), hash, key);
+ }
+ return argv[1];
}
+ return (VALUE)val;
}
VALUE
@@ -2158,7 +942,7 @@ rb_hash_fetch(VALUE hash, VALUE key)
*
* Returns the default value, the value that would be returned by
* <i>hsh</i>[<i>key</i>] if <i>key</i> did not exist in <i>hsh</i>.
- * See also Hash::new and Hash#default=.
+ * See also <code>Hash::new</code> and <code>Hash#default=</code>.
*
* h = Hash.new #=> {}
* h.default #=> nil
@@ -2180,7 +964,7 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
rb_check_arity(argc, 0, 1);
ifnone = RHASH_IFNONE(hash);
- if (FL_TEST(hash, RHASH_PROC_DEFAULT)) {
+ if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
if (argc == 0) return Qnil;
args[0] = hash;
args[1] = argv[0];
@@ -2195,7 +979,7 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
*
* Sets the default value, the value returned for a key that does not
* exist in the hash. It is not possible to set the default to a
- * Proc that will be executed on each key lookup.
+ * <code>Proc</code> that will be executed on each key lookup.
*
* h = { "a" => 100, "b" => 200 }
* h.default = "Go fish"
@@ -2221,7 +1005,7 @@ rb_hash_set_default(VALUE hash, VALUE ifnone)
* call-seq:
* hsh.default_proc -> anObject
*
- * If Hash::new was invoked with a block, return that
+ * If <code>Hash::new</code> was invoked with a block, return that
* block, otherwise return <code>nil</code>.
*
* h = Hash.new {|h,k| h[k] = k*k } #=> {}
@@ -2235,7 +1019,7 @@ rb_hash_set_default(VALUE hash, VALUE ifnone)
static VALUE
rb_hash_default_proc(VALUE hash)
{
- if (FL_TEST(hash, RHASH_PROC_DEFAULT)) {
+ if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
return RHASH_IFNONE(hash);
}
return Qnil;
@@ -2318,21 +1102,10 @@ rb_hash_key(VALUE hash, VALUE value)
static VALUE
rb_hash_index(VALUE hash, VALUE value)
{
- rb_warn_deprecated("Hash#index", "Hash#key");
+ rb_warn("Hash#index is deprecated; use Hash#key");
return rb_hash_key(hash, value);
}
-int
-rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval)
-{
- if (RHASH_AR_TABLE_P(hash)) {
- return ar_delete(hash, pkey, pval);
- }
- else {
- return st_delete(RHASH_ST_TABLE(hash), pkey, pval);
- }
-}
-
/*
* delete a specified entry a given key.
* if there is the corresponding entry, return a value of the entry.
@@ -2343,11 +1116,14 @@ rb_hash_delete_entry(VALUE hash, VALUE key)
{
st_data_t ktmp = (st_data_t)key, val;
- if (rb_hash_stlike_delete(hash, &ktmp, &val)) {
- return (VALUE)val;
+ if (!RHASH(hash)->ntbl) {
+ return Qundef;
+ }
+ else if (st_delete(RHASH(hash)->ntbl, &ktmp, &val)) {
+ return (VALUE)val;
}
else {
- return Qundef;
+ return Qundef;
}
}
@@ -2442,29 +1218,14 @@ rb_hash_shift(VALUE hash)
struct shift_var var;
rb_hash_modify_check(hash);
- if (RHASH_AR_TABLE_P(hash)) {
+ if (RHASH(hash)->ntbl) {
var.key = Qundef;
if (RHASH_ITER_LEV(hash) == 0) {
- if (ar_shift(hash, &var.key, &var.val)) {
+ if (st_shift(RHASH(hash)->ntbl, &var.key, &var.val)) {
return rb_assoc_new(var.key, var.val);
}
}
else {
- rb_hash_foreach(hash, shift_i_safe, (VALUE)&var);
- if (var.key != Qundef) {
- rb_hash_delete_entry(hash, var.key);
- return rb_assoc_new(var.key, var.val);
- }
- }
- }
- if (RHASH_ST_TABLE_P(hash)) {
- var.key = Qundef;
- if (RHASH_ITER_LEV(hash) == 0) {
- if (st_shift(RHASH_ST_TABLE(hash), &var.key, &var.val)) {
- return rb_assoc_new(var.key, var.val);
- }
- }
- else {
rb_hash_foreach(hash, shift_i_safe, (VALUE)&var);
if (var.key != Qundef) {
rb_hash_delete_entry(hash, var.key);
@@ -2510,9 +1271,8 @@ rb_hash_delete_if(VALUE hash)
{
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
rb_hash_modify_check(hash);
- if (!RHASH_TABLE_EMPTY_P(hash)) {
- rb_hash_foreach(hash, delete_if_i, hash);
- }
+ if (RHASH(hash)->ntbl)
+ rb_hash_foreach(hash, delete_if_i, hash);
return hash;
}
@@ -2521,7 +1281,7 @@ rb_hash_delete_if(VALUE hash)
* hsh.reject! {| key, value | block } -> hsh or nil
* hsh.reject! -> an_enumerator
*
- * Equivalent to Hash#delete_if, but returns
+ * Equivalent to <code>Hash#delete_if</code>, but returns
* <code>nil</code> if no changes were made.
*/
@@ -2535,7 +1295,7 @@ rb_hash_reject_bang(VALUE hash)
n = RHASH_SIZE(hash);
if (!n) return Qnil;
rb_hash_foreach(hash, delete_if_i, hash);
- if (n == RHASH_SIZE(hash)) return Qnil;
+ if (n == RHASH(hash)->ntbl->num_entries) return Qnil;
return hash;
}
@@ -2618,7 +1378,7 @@ rb_hash_slice(int argc, VALUE *argv, VALUE hash)
* hsh.values_at(key, ...) -> array
*
* Return an array containing the values associated with the given keys.
- * Also see Hash.select.
+ * Also see <code>Hash.select</code>.
*
* h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
* h.values_at("cow", "cat") #=> ["bovine", "feline"]
@@ -2642,8 +1402,8 @@ rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
* hsh.fetch_values(key, ...) { |key| block } -> array
*
* Returns an array containing the values associated with the given keys
- * but also raises KeyError when one of keys can't be found.
- * Also see Hash#values_at and Hash#fetch.
+ * but also raises <code>KeyError</code> when one of keys can't be found.
+ * Also see <code>Hash#values_at</code> and <code>Hash#fetch</code>.
*
* h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
*
@@ -2677,8 +1437,6 @@ select_i(VALUE key, VALUE value, VALUE result)
* call-seq:
* hsh.select {|key, value| block} -> a_hash
* hsh.select -> an_enumerator
- * hsh.filter {|key, value| block} -> a_hash
- * hsh.filter -> an_enumerator
*
* Returns a new hash consisting of entries for which the block returns true.
*
@@ -2687,8 +1445,6 @@ select_i(VALUE key, VALUE value, VALUE result)
* h = { "a" => 100, "b" => 200, "c" => 300 }
* h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300}
* h.select {|k,v| v < 200} #=> {"a" => 100}
- *
- * Hash#filter is an alias for Hash#select.
*/
VALUE
@@ -2717,13 +1473,9 @@ keep_if_i(VALUE key, VALUE value, VALUE hash)
* call-seq:
* hsh.select! {| key, value | block } -> hsh or nil
* hsh.select! -> an_enumerator
- * hsh.filter! {| key, value | block } -> hsh or nil
- * hsh.filter! -> an_enumerator
- *
- * Equivalent to Hash#keep_if, but returns
- * +nil+ if no changes were made.
*
- * Hash#filter! is an alias for Hash#select!.
+ * Equivalent to <code>Hash#keep_if</code>, but returns
+ * <code>nil</code> if no changes were made.
*/
VALUE
@@ -2733,10 +1485,11 @@ rb_hash_select_bang(VALUE hash)
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
rb_hash_modify_check(hash);
- n = RHASH_SIZE(hash);
- if (!n) return Qnil;
+ if (!RHASH(hash)->ntbl)
+ return Qnil;
+ n = RHASH(hash)->ntbl->num_entries;
rb_hash_foreach(hash, keep_if_i, hash);
- if (n == RHASH_SIZE(hash)) return Qnil;
+ if (n == RHASH(hash)->ntbl->num_entries) return Qnil;
return hash;
}
@@ -2746,11 +1499,10 @@ rb_hash_select_bang(VALUE hash)
* hsh.keep_if -> an_enumerator
*
* Deletes every key-value pair from <i>hsh</i> for which <i>block</i>
- * evaluates to +false+.
+ * evaluates to false.
*
* If no block is given, an enumerator is returned instead.
*
- * See also Hash#select!.
*/
VALUE
@@ -2758,9 +1510,8 @@ rb_hash_keep_if(VALUE hash)
{
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
rb_hash_modify_check(hash);
- if (!RHASH_TABLE_EMPTY_P(hash)) {
- rb_hash_foreach(hash, keep_if_i, hash);
- }
+ if (RHASH(hash)->ntbl)
+ rb_hash_foreach(hash, keep_if_i, hash);
return hash;
}
@@ -2785,15 +1536,13 @@ VALUE
rb_hash_clear(VALUE hash)
{
rb_hash_modify_check(hash);
-
- if (RHASH_ITER_LEV(hash) > 0) {
- rb_hash_foreach(hash, clear_i, 0);
- }
- else if (RHASH_AR_TABLE_P(hash)) {
- ar_clear(hash);
- }
- else {
- st_clear(RHASH_ST_TABLE(hash));
+ if (!RHASH(hash)->ntbl)
+ return hash;
+ if (RHASH(hash)->ntbl->num_entries > 0) {
+ if (RHASH_ITER_LEV(hash) > 0)
+ rb_hash_foreach(hash, clear_i, 0);
+ else
+ st_clear(RHASH(hash)->ntbl);
}
return hash;
@@ -2814,14 +1563,22 @@ hash_aset(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
return ST_CONTINUE;
}
-VALUE
-rb_hash_key_str(VALUE key)
+static VALUE
+fstring_existing_str(VALUE str)
{
- if (!RB_FL_ANY_RAW(key, FL_EXIVAR) && RBASIC_CLASS(key) == rb_cString) {
- return rb_fstring(key);
+ st_data_t fstr;
+ st_table *tbl = rb_vm_fstring_table();
+
+ if (st_lookup(tbl, str, &fstr)) {
+ if (rb_objspace_garbage_object_p(fstr)) {
+ return rb_fstring(str);
+ }
+ else {
+ return (VALUE)fstr;
+ }
}
else {
- return rb_str_new_frozen(key);
+ return Qnil;
}
}
@@ -2829,7 +1586,15 @@ static int
hash_aset_str(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
{
if (!existing && !RB_OBJ_FROZEN(*key)) {
- *key = rb_hash_key_str(*key);
+ VALUE k;
+
+ if (!RB_OBJ_TAINTED(*key) &&
+ (k = fstring_existing_str(*key)) != Qnil) {
+ *key = k;
+ }
+ else {
+ *key = rb_str_new_frozen(*key);
+ }
}
return hash_aset(key, val, arg, existing);
}
@@ -2868,15 +1633,14 @@ VALUE
rb_hash_aset(VALUE hash, VALUE key, VALUE val)
{
int iter_lev = RHASH_ITER_LEV(hash);
+ st_table *tbl = RHASH(hash)->ntbl;
rb_hash_modify(hash);
-
- if (RHASH_TABLE_NULL_P(hash)) {
+ if (!tbl) {
if (iter_lev > 0) no_new_key();
- ar_alloc_table(hash);
+ tbl = hash_tbl(hash);
}
-
- if (RHASH_TYPE(hash) == &identhash || rb_obj_class(key) != rb_cString) {
+ if (tbl->type == &identhash || rb_obj_class(key) != rb_cString) {
RHASH_UPDATE_ITER(hash, iter_lev, key, hash_aset, val);
}
else {
@@ -2885,6 +1649,43 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val)
return val;
}
+static int
+replace_i(VALUE key, VALUE val, VALUE hash)
+{
+ rb_hash_aset(hash, key, val);
+
+ return ST_CONTINUE;
+}
+
+/* :nodoc: */
+static VALUE
+rb_hash_initialize_copy(VALUE hash, VALUE hash2)
+{
+ st_table *ntbl;
+
+ rb_hash_modify_check(hash);
+ hash2 = to_hash(hash2);
+
+ Check_Type(hash2, T_HASH);
+
+ if (hash == hash2) return hash;
+
+ ntbl = RHASH(hash)->ntbl;
+ if (RHASH(hash2)->ntbl) {
+ if (ntbl) st_free_table(ntbl);
+ RHASH(hash)->ntbl = st_copy(RHASH(hash2)->ntbl);
+ if (RHASH(hash)->ntbl->num_entries)
+ rb_hash_rehash(hash);
+ }
+ else if (ntbl) {
+ st_clear(ntbl);
+ }
+
+ COPY_DEFAULT(hash, hash2);
+
+ return hash;
+}
+
/*
* call-seq:
* hsh.replace(other_hash) -> hsh
@@ -2900,37 +1701,19 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static VALUE
rb_hash_replace(VALUE hash, VALUE hash2)
{
+ st_table *table2;
+
rb_hash_modify_check(hash);
if (hash == hash2) return hash;
- if (RHASH_ITER_LEV(hash) > 0) {
- rb_raise(rb_eRuntimeError, "can't replace hash during iteration");
- }
hash2 = to_hash(hash2);
COPY_DEFAULT(hash, hash2);
- if (RHASH_AR_TABLE_P(hash)) {
- if (RHASH_AR_TABLE_P(hash2)) {
- ar_clear(hash);
- }
- else {
- ar_free_and_clear_table(hash);
- RHASH_ST_TABLE_SET(hash, st_init_table_with_size(RHASH_TYPE(hash2), RHASH_SIZE(hash2)));
- }
- }
- else {
- if (RHASH_AR_TABLE_P(hash2)) {
- st_free_table(RHASH_ST_TABLE(hash));
- RHASH_ST_CLEAR(hash);
- }
- else {
- st_clear(RHASH_ST_TABLE(hash));
- RHASH_TBL_RAW(hash)->type = RHASH_ST_TABLE(hash2)->type;
- }
- }
- rb_hash_foreach(hash2, rb_hash_rehash_i, (VALUE)hash);
+ table2 = RHASH(hash2)->ntbl;
- rb_gc_writebarrier_remember(hash);
+ rb_hash_clear(hash);
+ if (table2) hash_tbl(hash)->type = table2->type;
+ rb_hash_foreach(hash2, replace_i, hash);
return hash;
}
@@ -2943,12 +1726,9 @@ rb_hash_replace(VALUE hash, VALUE hash2)
* Returns the number of key-value pairs in the hash.
*
* h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
- * h.size #=> 4
+ * h.length #=> 4
* h.delete("a") #=> 200
- * h.size #=> 3
* h.length #=> 3
- *
- * Hash#length is an alias for Hash#size.
*/
VALUE
@@ -2957,11 +1737,6 @@ rb_hash_size(VALUE hash)
return INT2FIX(RHASH_SIZE(hash));
}
-size_t
-rb_hash_size_num(VALUE hash)
-{
- return (long)RHASH_SIZE(hash);
-}
/*
* call-seq:
@@ -2980,7 +1755,7 @@ rb_hash_empty_p(VALUE hash)
}
static int
-each_value_i(VALUE key, VALUE value, VALUE _)
+each_value_i(VALUE key, VALUE value)
{
rb_yield(value);
return ST_CONTINUE;
@@ -3014,7 +1789,7 @@ rb_hash_each_value(VALUE hash)
}
static int
-each_key_i(VALUE key, VALUE value, VALUE _)
+each_key_i(VALUE key, VALUE value)
{
rb_yield(key);
return ST_CONTINUE;
@@ -3047,14 +1822,14 @@ rb_hash_each_key(VALUE hash)
}
static int
-each_pair_i(VALUE key, VALUE value, VALUE _)
+each_pair_i(VALUE key, VALUE value)
{
rb_yield(rb_assoc_new(key, value));
return ST_CONTINUE;
}
static int
-each_pair_i_fast(VALUE key, VALUE value, VALUE _)
+each_pair_i_fast(VALUE key, VALUE value)
{
VALUE argv[2];
argv[0] = key;
@@ -3159,7 +1934,7 @@ rb_hash_transform_keys_bang(VALUE hash)
{
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
rb_hash_modify_check(hash);
- if (!RHASH_TABLE_EMPTY_P(hash)) {
+ if (RHASH(hash)->ntbl) {
long i;
VALUE pairs = rb_hash_flatten(0, NULL, hash);
rb_hash_clear(hash);
@@ -3173,17 +1948,10 @@ rb_hash_transform_keys_bang(VALUE hash)
}
static int
-transform_values_foreach_func(st_data_t key, st_data_t value, st_data_t argp, int error)
+transform_values_i(VALUE key, VALUE value, VALUE result)
{
- return ST_REPLACE;
-}
-
-static int
-transform_values_foreach_replace(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
-{
- VALUE new_value = rb_yield((VALUE)*value);
- VALUE hash = (VALUE)argp;
- RB_OBJ_WRITE(hash, value, new_value);
+ VALUE new_value = rb_yield(value);
+ rb_hash_aset(result, key, new_value);
return ST_CONTINUE;
}
@@ -3210,11 +1978,9 @@ rb_hash_transform_values(VALUE hash)
VALUE result;
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
- result = hash_copy(hash_alloc(rb_cHash), hash);
- SET_DEFAULT(result, Qnil);
-
+ result = rb_hash_new_with_size(RHASH_SIZE(hash));
if (!RHASH_EMPTY_P(hash)) {
- rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result);
+ rb_hash_foreach(hash, transform_values_i, result);
}
return result;
@@ -3242,11 +2008,8 @@ rb_hash_transform_values_bang(VALUE hash)
{
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
rb_hash_modify_check(hash);
-
- if (!RHASH_TABLE_EMPTY_P(hash)) {
- rb_hash_stlike_foreach_with_replace(hash, transform_values_foreach_func, transform_values_foreach_replace, hash);
- }
-
+ if (RHASH(hash)->ntbl)
+ rb_hash_foreach(hash, transform_values_i, hash);
return hash;
}
@@ -3275,6 +2038,7 @@ rb_hash_to_a(VALUE hash)
ary = rb_ary_new_capa(RHASH_SIZE(hash));
rb_hash_foreach(hash, to_a_i, ary);
+ OBJ_INFECT(ary, hash);
return ary;
}
@@ -3292,9 +2056,11 @@ inspect_i(VALUE key, VALUE value, VALUE str)
rb_enc_copy(str, str2);
}
rb_str_buf_append(str, str2);
+ OBJ_INFECT(str, str2);
rb_str_buf_cat_ascii(str, "=>");
str2 = rb_inspect(value);
rb_str_buf_append(str, str2);
+ OBJ_INFECT(str, str2);
return ST_CONTINUE;
}
@@ -3308,6 +2074,7 @@ inspect_hash(VALUE hash, VALUE dummy, int recur)
str = rb_str_buf_new2("{");
rb_hash_foreach(hash, inspect_i, str);
rb_str_buf_cat2(str, "}");
+ OBJ_INFECT(str, hash);
return str;
}
@@ -3344,60 +2111,20 @@ rb_hash_to_hash(VALUE hash)
return hash;
}
-VALUE
-rb_hash_set_pair(VALUE hash, VALUE arg)
-{
- VALUE pair;
-
- pair = rb_check_array_type(arg);
- if (NIL_P(pair)) {
- rb_raise(rb_eTypeError, "wrong element type %s (expected array)",
- rb_builtin_class_name(arg));
- }
- if (RARRAY_LEN(pair) != 2) {
- rb_raise(rb_eArgError, "element has wrong array length (expected 2, was %ld)",
- RARRAY_LEN(pair));
- }
- rb_hash_aset(hash, RARRAY_AREF(pair, 0), RARRAY_AREF(pair, 1));
- return hash;
-}
-
-static int
-to_h_i(VALUE key, VALUE value, VALUE hash)
-{
- rb_hash_set_pair(hash, rb_yield_values(2, key, value));
- return ST_CONTINUE;
-}
-
-static VALUE
-rb_hash_to_h_block(VALUE hash)
-{
- VALUE h = rb_hash_new_with_size(RHASH_SIZE(hash));
- rb_hash_foreach(hash, to_h_i, h);
- return h;
-}
-
/*
* call-seq:
- * hsh.to_h -> hsh or new_hash
- * hsh.to_h {|key, value| block } -> new_hash
+ * hsh.to_h -> hsh or new_hash
*
* Returns +self+. If called on a subclass of Hash, converts
* the receiver to a Hash object.
- *
- * If a block is given, the results of the block on each pair of
- * the receiver will be used as pairs.
*/
static VALUE
rb_hash_to_h(VALUE hash)
{
- if (rb_block_given_p()) {
- return rb_hash_to_h_block(hash);
- }
if (rb_obj_class(hash) != rb_cHash) {
const VALUE flags = RBASIC(hash)->flags;
- hash = hash_dup(hash, rb_cHash, flags & RHASH_PROC_DEFAULT);
+ hash = hash_dup(hash, rb_cHash, flags & HASH_PROC_DEFAULT);
}
return hash;
}
@@ -3414,32 +2141,29 @@ keys_i(VALUE key, VALUE value, VALUE ary)
* hsh.keys -> array
*
* Returns a new array populated with the keys from this hash. See also
- * Hash#values.
+ * <code>Hash#values</code>.
*
* h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 }
* h.keys #=> ["a", "b", "c", "d"]
*
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_keys(VALUE hash)
{
+ VALUE keys;
st_index_t size = RHASH_SIZE(hash);
- VALUE keys = rb_ary_new_capa(size);
+ keys = rb_ary_new_capa(size);
if (size == 0) return keys;
if (ST_DATA_COMPATIBLE_P(VALUE)) {
- RARRAY_PTR_USE_TRANSIENT(keys, ptr, {
- if (RHASH_AR_TABLE_P(hash)) {
- size = ar_keys(hash, ptr, size);
- }
- else {
- st_table *table = RHASH_ST_TABLE(hash);
- size = st_keys(table, ptr, size);
- }
- });
- rb_gc_writebarrier_remember(keys);
+ st_table *table = RHASH(hash)->ntbl;
+
+ rb_gc_writebarrier_remember(keys);
+ RARRAY_PTR_USE(keys, ptr, {
+ size = st_keys(table, ptr, size);
+ });
rb_ary_set_len(keys, size);
}
else {
@@ -3461,7 +2185,7 @@ values_i(VALUE key, VALUE value, VALUE ary)
* hsh.values -> array
*
* Returns a new array populated with the values from <i>hsh</i>. See
- * also Hash#keys.
+ * also <code>Hash#keys</code>.
*
* h = { "a" => 100, "b" => 200, "c" => 300 }
* h.values #=> [100, 200, 300]
@@ -3478,19 +2202,12 @@ rb_hash_values(VALUE hash)
if (size == 0) return values;
if (ST_DATA_COMPATIBLE_P(VALUE)) {
- if (RHASH_AR_TABLE_P(hash)) {
- rb_gc_writebarrier_remember(values);
- RARRAY_PTR_USE_TRANSIENT(values, ptr, {
- size = ar_values(hash, ptr, size);
- });
- }
- else if (RHASH_ST_TABLE_P(hash)) {
- st_table *table = RHASH_ST_TABLE(hash);
- rb_gc_writebarrier_remember(values);
- RARRAY_PTR_USE_TRANSIENT(values, ptr, {
- size = st_values(table, ptr, size);
- });
- }
+ st_table *table = RHASH(hash)->ntbl;
+
+ rb_gc_writebarrier_remember(values);
+ RARRAY_PTR_USE(values, ptr, {
+ size = st_values(table, ptr, size);
+ });
rb_ary_set_len(values, size);
}
else {
@@ -3513,21 +2230,21 @@ rb_hash_values(VALUE hash)
* h.has_key?("a") #=> true
* h.has_key?("z") #=> false
*
- * Note that #include? and #member? do not test member
+ * Note that <code>include?</code> and <code>member?</code> do not test member
* equality using <code>==</code> as do other Enumerables.
*
* See also Enumerable#include?
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_has_key(VALUE hash, VALUE key)
{
- if (hash_stlike_lookup(hash, key, NULL)) {
- return Qtrue;
- }
- else {
+ if (!RHASH(hash)->ntbl)
return Qfalse;
+ if (st_lookup(RHASH(hash)->ntbl, key, 0)) {
+ return Qtrue;
}
+ return Qfalse;
}
static int
@@ -3568,7 +2285,7 @@ rb_hash_has_value(VALUE hash, VALUE val)
struct equal_data {
VALUE result;
- VALUE hash;
+ st_table *tbl;
int eql;
};
@@ -3578,17 +2295,15 @@ eql_i(VALUE key, VALUE val1, VALUE arg)
struct equal_data *data = (struct equal_data *)arg;
st_data_t val2;
- if (!hash_stlike_lookup(data->hash, key, &val2)) {
- data->result = Qfalse;
- return ST_STOP;
+ if (!st_lookup(data->tbl, key, &val2)) {
+ data->result = Qfalse;
+ return ST_STOP;
}
- else {
- if (!(data->eql ? rb_eql(val1, (VALUE)val2) : (int)rb_equal(val1, (VALUE)val2))) {
- data->result = Qfalse;
- return ST_STOP;
- }
- return ST_CONTINUE;
+ if (!(data->eql ? rb_eql(val1, (VALUE)val2) : (int)rb_equal(val1, (VALUE)val2))) {
+ data->result = Qfalse;
+ return ST_STOP;
}
+ return ST_CONTINUE;
}
static VALUE
@@ -3628,23 +2343,19 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
}
if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2))
return Qfalse;
- if (!RHASH_TABLE_EMPTY_P(hash1) && !RHASH_TABLE_EMPTY_P(hash2)) {
- if (RHASH_TYPE(hash1) != RHASH_TYPE(hash2)) {
- return Qfalse;
- }
- else {
- data.hash = hash2;
- data.eql = eql;
- return rb_exec_recursive_paired(recursive_eql, hash1, hash2, (VALUE)&data);
- }
- }
-
+ if (!RHASH(hash1)->ntbl || !RHASH(hash2)->ntbl)
+ return Qtrue;
+ if (RHASH(hash1)->ntbl->type != RHASH(hash2)->ntbl->type)
+ return Qfalse;
#if 0
if (!(rb_equal(RHASH_IFNONE(hash1), RHASH_IFNONE(hash2)) &&
- FL_TEST(hash1, RHASH_PROC_DEFAULT) == FL_TEST(hash2, RHASH_PROC_DEFAULT)))
+ FL_TEST(hash1, HASH_PROC_DEFAULT) == FL_TEST(hash2, HASH_PROC_DEFAULT)))
return Qfalse;
#endif
- return Qtrue;
+
+ data.tbl = RHASH(hash2)->ntbl;
+ data.eql = eql;
+ return rb_exec_recursive_paired(recursive_eql, hash1, hash2, (VALUE)&data);
}
/*
@@ -3653,7 +2364,8 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
*
* Equality---Two hashes are equal if they each contain the same number
* of keys and if each key-value pair is equal to (according to
- * Object#==) the corresponding elements in the other hash.
+ * <code>Object#==</code>) the corresponding elements in the other
+ * hash.
*
* h1 = { "a" => 1, "c" => 2 }
* h2 = { 7 => 35, "c" => 2, "a" => 1 }
@@ -3825,64 +2537,41 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
/*
* call-seq:
- * hsh.merge!(other_hash1, other_hash2, ...) -> hsh
- * hsh.update(other_hash1, other_hash2, ...) -> hsh
- * hsh.merge!(other_hash1, other_hash2, ...) {|key, oldval, newval| block}
- * -> hsh
- * hsh.update(other_hash1, other_hash2, ...) {|key, oldval, newval| block}
- * -> hsh
- *
- * Adds the contents of the given hashes to the receiver.
- *
- * If no block is given, entries with duplicate keys are overwritten
- * with the values from each +other_hash+ successively,
- * otherwise the value for each duplicate key is determined by
- * calling the block with the key, its value in the receiver and
- * its value in each +other_hash+.
+ * hsh.merge!(other_hash) -> hsh
+ * hsh.update(other_hash) -> hsh
+ * hsh.merge!(other_hash){|key, oldval, newval| block} -> hsh
+ * hsh.update(other_hash){|key, oldval, newval| block} -> hsh
*
- * h1 = { "a" => 100, "b" => 200 }
- * h1.merge! #=> {"a"=>100, "b"=>200}
- * h1 #=> {"a"=>100, "b"=>200}
- *
- * h1 = { "a" => 100, "b" => 200 }
- * h2 = { "b" => 246, "c" => 300 }
- * h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
- * h1 #=> {"a"=>100, "b"=>246, "c"=>300}
+ * Adds the contents of _other_hash_ to _hsh_. If no block is specified,
+ * entries with duplicate keys are overwritten with the values from
+ * _other_hash_, otherwise the value of each duplicate key is determined by
+ * calling the block with the key, its value in _hsh_ and its value in
+ * _other_hash_.
*
* h1 = { "a" => 100, "b" => 200 }
- * h2 = { "b" => 246, "c" => 300 }
- * h3 = { "b" => 357, "d" => 400 }
- * h1.merge!(h2, h3)
- * #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
- * h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
+ * h2 = { "b" => 254, "c" => 300 }
+ * h1.merge!(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
+ * h1 #=> {"a"=>100, "b"=>254, "c"=>300}
*
* h1 = { "a" => 100, "b" => 200 }
- * h2 = { "b" => 246, "c" => 300 }
- * h3 = { "b" => 357, "d" => 400 }
- * h1.merge!(h2, h3) {|key, v1, v2| v1 }
- * #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
- * h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
- *
- * Hash#update is an alias for Hash#merge!.
+ * h2 = { "b" => 254, "c" => 300 }
+ * h1.merge!(h2) { |key, v1, v2| v1 }
+ * #=> {"a"=>100, "b"=>200, "c"=>300}
+ * h1 #=> {"a"=>100, "b"=>200, "c"=>300}
*/
static VALUE
-rb_hash_update(int argc, VALUE *argv, VALUE self)
+rb_hash_update(VALUE hash1, VALUE hash2)
{
- int i;
- bool block_given = rb_block_given_p();
-
- rb_hash_modify(self);
- for (i = 0; i < argc; i++){
- VALUE hash = to_hash(argv[i]);
- if (block_given) {
- rb_hash_foreach(hash, rb_hash_update_block_i, self);
- }
- else {
- rb_hash_foreach(hash, rb_hash_update_i, self);
- }
+ rb_hash_modify(hash1);
+ hash2 = to_hash(hash2);
+ if (rb_block_given_p()) {
+ rb_hash_foreach(hash2, rb_hash_update_block_i, hash1);
}
- return self;
+ else {
+ rb_hash_foreach(hash2, rb_hash_update_i, hash1);
+ }
+ return hash1;
}
struct update_func_arg {
@@ -3941,39 +2630,28 @@ rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func)
/*
* call-seq:
- * hsh.merge(other_hash1, other_hash2, ...) -> new_hash
- * hsh.merge(other_hash1, other_hash2, ...) {|key, oldval, newval| block}
- * -> new_hash
- *
- * Returns a new hash that combines the contents of the receiver and
- * the contents of the given hashes.
- *
- * If no block is given, entries with duplicate keys are overwritten
- * with the values from each +other_hash+ successively,
- * otherwise the value for each duplicate key is determined by
- * calling the block with the key, its value in the receiver and
- * its value in each +other_hash+.
+ * hsh.merge(other_hash) -> new_hash
+ * hsh.merge(other_hash){|key, oldval, newval| block} -> new_hash
*
- * When called without any argument, returns a copy of the receiver.
+ * Returns a new hash containing the contents of <i>other_hash</i> and
+ * the contents of <i>hsh</i>. If no block is specified, the value for
+ * entries with duplicate keys will be that of <i>other_hash</i>. Otherwise
+ * the value for each duplicate key is determined by calling the block
+ * with the key, its value in <i>hsh</i> and its value in <i>other_hash</i>.
*
* h1 = { "a" => 100, "b" => 200 }
- * h2 = { "b" => 246, "c" => 300 }
- * h3 = { "b" => 357, "d" => 400 }
- * h1.merge #=> {"a"=>100, "b"=>200}
- * h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
- * h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
- * h1.merge(h2) {|key, oldval, newval| newval - oldval}
- * #=> {"a"=>100, "b"=>46, "c"=>300}
- * h1.merge(h2, h3) {|key, oldval, newval| newval - oldval}
- * #=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
- * h1 #=> {"a"=>100, "b"=>200}
+ * h2 = { "b" => 254, "c" => 300 }
+ * h1.merge(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
+ * h1.merge(h2){|key, oldval, newval| newval - oldval}
+ * #=> {"a"=>100, "b"=>54, "c"=>300}
+ * h1 #=> {"a"=>100, "b"=>200}
*
*/
static VALUE
-rb_hash_merge(int argc, VALUE *argv, VALUE self)
+rb_hash_merge(VALUE hash1, VALUE hash2)
{
- return rb_hash_update(argc, argv, rb_hash_dup(self));
+ return rb_hash_update(rb_hash_dup(hash1), hash2);
}
static int
@@ -3998,8 +2676,7 @@ static VALUE
reset_hash_type(VALUE arg)
{
struct reset_hash_type_arg *p = (struct reset_hash_type_arg *)arg;
- HASH_ASSERT(RHASH_ST_TABLE_P(p->hash));
- RHASH_ST_TABLE(p->hash)->type = p->orighash;
+ RHASH(p->hash)->ntbl->type = p->orighash;
return Qundef;
}
@@ -4021,7 +2698,7 @@ assoc_i(VALUE key, VALUE val, VALUE arg)
*
* Searches through the hash comparing _obj_ with the key using <code>==</code>.
* Returns the key-value pair (two elements array) or +nil+
- * if no match is found. See Array#assoc.
+ * if no match is found. See <code>Array#assoc</code>.
*
* h = {"colors" => ["red", "blue", "green"],
* "letters" => ["a", "b", "c" ]}
@@ -4037,10 +2714,7 @@ rb_hash_assoc(VALUE hash, VALUE key)
VALUE args[2];
if (RHASH_EMPTY_P(hash)) return Qnil;
-
- ar_force_convert_table(hash, __FILE__, __LINE__);
- HASH_ASSERT(RHASH_ST_TABLE_P(hash));
- table = RHASH_ST_TABLE(hash);
+ table = RHASH(hash)->ntbl;
orighash = table->type;
if (orighash != &identhash) {
@@ -4050,7 +2724,7 @@ rb_hash_assoc(VALUE hash, VALUE key)
assochash.compare = assoc_cmp;
assochash.hash = orighash->hash;
- table->type = &assochash;
+ table->type = &assochash;
args[0] = hash;
args[1] = key;
ensure_arg.hash = hash;
@@ -4083,7 +2757,7 @@ rassoc_i(VALUE key, VALUE val, VALUE arg)
*
* Searches through the hash comparing _obj_ with the value using <code>==</code>.
* Returns the first key-value pair (two-element array) that matches. See
- * also Array#rassoc.
+ * also <code>Array#rassoc</code>.
*
* a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"}
* a.rassoc("two") #=> [2, "two"]
@@ -4217,19 +2891,16 @@ rb_hash_compact(VALUE hash)
static VALUE
rb_hash_compact_bang(VALUE hash)
{
- st_index_t n;
rb_hash_modify_check(hash);
- n = RHASH_SIZE(hash);
- if (n) {
+ if (RHASH(hash)->ntbl) {
+ st_index_t n = RHASH(hash)->ntbl->num_entries;
rb_hash_foreach(hash, delete_if_nil, hash);
- if (n != RHASH_SIZE(hash))
+ if (n != RHASH(hash)->ntbl->num_entries)
return hash;
}
return Qnil;
}
-static st_table *rb_init_identtable_with_size(st_index_t size);
-
/*
* call-seq:
* hsh.compare_by_identity -> hsh
@@ -4249,23 +2920,15 @@ static st_table *rb_init_identtable_with_size(st_index_t size);
static VALUE
rb_hash_compare_by_id(VALUE hash)
{
- VALUE tmp;
st_table *identtable;
-
if (rb_hash_compare_by_id_p(hash)) return hash;
-
rb_hash_modify_check(hash);
- ar_force_convert_table(hash, __FILE__, __LINE__);
- HASH_ASSERT(RHASH_ST_TABLE_P(hash));
- tmp = hash_alloc(0);
identtable = rb_init_identtable_with_size(RHASH_SIZE(hash));
- RHASH_ST_TABLE_SET(tmp, identtable);
- rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- st_free_table(RHASH_ST_TABLE(hash));
- RHASH_ST_TABLE_SET(hash, identtable);
- RHASH_ST_CLEAR(tmp);
- rb_gc_force_recycle(tmp);
+ rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)identtable);
+ if (RHASH(hash)->ntbl)
+ st_free_table(RHASH(hash)->ntbl);
+ RHASH(hash)->ntbl = identtable;
return hash;
}
@@ -4275,26 +2938,26 @@ rb_hash_compare_by_id(VALUE hash)
* hsh.compare_by_identity? -> true or false
*
* Returns <code>true</code> if <i>hsh</i> will compare its keys by
- * their identity. Also see Hash#compare_by_identity.
+ * their identity. Also see <code>Hash#compare_by_identity</code>.
*
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_compare_by_id_p(VALUE hash)
{
- if (RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash) {
- return Qtrue;
- }
- else {
+ if (!RHASH(hash)->ntbl)
return Qfalse;
+ if (RHASH(hash)->ntbl->type == &identhash) {
+ return Qtrue;
}
+ return Qfalse;
}
VALUE
rb_ident_hash_new(void)
{
VALUE hash = rb_hash_new();
- RHASH_ST_TABLE_SET(hash, st_init_table(&identhash));
+ RHASH(hash)->ntbl = st_init_table(&identhash);
return hash;
}
@@ -4304,7 +2967,7 @@ rb_init_identtable(void)
return st_init_table(&identhash);
}
-static st_table *
+st_table *
rb_init_identtable_with_size(st_index_t size)
{
return st_init_table_with_size(&identhash, size);
@@ -4346,7 +3009,6 @@ any_p_i_pattern(VALUE key, VALUE value, VALUE arg)
/*
* call-seq:
* hsh.any? [{ |(key, value)| block }] -> true or false
- * hsh.any?(pattern) -> true or false
*
* See also Enumerable#any?
*/
@@ -4360,9 +3022,6 @@ rb_hash_any_p(int argc, VALUE *argv, VALUE hash)
rb_check_arity(argc, 0, 1);
if (RHASH_EMPTY_P(hash)) return Qfalse;
if (argc) {
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
args[1] = argv[0];
rb_hash_foreach(hash, any_p_i_pattern, (VALUE)args);
@@ -4399,7 +3058,7 @@ rb_hash_any_p(int argc, VALUE *argv, VALUE hash)
* g.dig(:foo, :bar) #=> TypeError: no implicit conversion of Symbol into Integer
*/
-static VALUE
+VALUE
rb_hash_dig(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
@@ -4514,37 +3173,18 @@ rb_hash_gt(VALUE hash, VALUE other)
}
static VALUE
-hash_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(key, hash))
+hash_proc_call(VALUE key, VALUE hash, int argc, const VALUE *argv, VALUE passed_proc)
{
rb_check_arity(argc, 1, 1);
return rb_hash_aref(hash, *argv);
}
-/*
- * call-seq:
- * hash.to_proc -> proc
- *
- * Returns a Proc which maps keys to values.
- *
- * h = {a:1, b:2}
- * hp = h.to_proc
- * hp.call(:a) #=> 1
- * hp.call(:b) #=> 2
- * hp.call(:c) #=> nil
- * [:a, :b, :c].map(&h) #=> [1, 2, nil]
- */
static VALUE
rb_hash_to_proc(VALUE hash)
{
return rb_func_proc_new(hash_proc_call, hash);
}
-static VALUE
-rb_hash_deconstruct_keys(VALUE hash, VALUE keys)
-{
- return hash;
-}
-
static int
add_new_i(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
{
@@ -4562,71 +3202,14 @@ add_new_i(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
int
rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val)
{
- st_table *tbl;
- int ret = 0;
+ st_table *tbl = rb_hash_tbl_raw(hash);
VALUE args[2];
args[0] = hash;
args[1] = val;
-
- if (RHASH_AR_TABLE_P(hash)) {
- hash_ar_table(hash);
-
- ret = ar_update(hash, (st_data_t)key, add_new_i, (st_data_t)args);
- if (ret != -1) {
- return ret;
- }
- ar_try_convert_table(hash);
- }
- tbl = RHASH_TBL_RAW(hash);
return st_update(tbl, (st_data_t)key, add_new_i, (st_data_t)args);
-
}
-static st_data_t
-key_stringify(VALUE key)
-{
- return (rb_obj_class(key) == rb_cString && !RB_OBJ_FROZEN(key)) ?
- rb_hash_key_str(key) : key;
-}
-
-static void
-ar_bulk_insert(VALUE hash, long argc, const VALUE *argv)
-{
- long i;
- for (i = 0; i < argc; ) {
- st_data_t k = key_stringify(argv[i++]);
- st_data_t v = argv[i++];
- ar_insert(hash, k, v);
- RB_OBJ_WRITTEN(hash, Qundef, k);
- RB_OBJ_WRITTEN(hash, Qundef, v);
- }
-}
-
-void
-rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
-{
- HASH_ASSERT(argc % 2 == 0);
- if (argc > 0) {
- st_index_t size = argc / 2;
-
- if (RHASH_TABLE_NULL_P(hash)) {
- if (size <= RHASH_AR_TABLE_MAX_SIZE) {
- hash_ar_table(hash);
- }
- else {
- RHASH_TBL_RAW(hash);
- }
- }
-
- if (RHASH_AR_TABLE_P(hash) &&
- (RHASH_AR_TABLE_SIZE(hash) + size <= RHASH_AR_TABLE_MAX_SIZE)) {
- ar_bulk_insert(hash, argc, argv);
- }
- else {
- rb_hash_bulk_insert_into_st_table(argc, argv, hash);
- }
- }
-}
+static int path_tainted = -1;
static char **origenviron;
#ifdef _WIN32
@@ -4685,6 +3268,7 @@ env_enc_str_new(const char *ptr, long len, rb_encoding *enc)
VALUE str = rb_external_str_new_with_enc(ptr, len, enc);
#endif
+ OBJ_TAINT(str);
rb_obj_freeze(str);
return str;
}
@@ -4708,13 +3292,15 @@ env_str_new2(const char *ptr)
return env_str_new(ptr, strlen(ptr));
}
+static int env_path_tainted(const char *);
+
static const char TZ_ENV[] = "TZ";
-extern bool ruby_tz_uptodate_p;
+extern int ruby_tz_update;
static rb_encoding *
env_encoding_for(const char *name, const char *ptr)
{
- if (ENVMATCH(name, PATH_ENV)) {
+ if (ENVMATCH(name, PATH_ENV) && !env_path_tainted(ptr)) {
return rb_filesystem_encoding();
}
else {
@@ -4777,32 +3363,23 @@ env_name(volatile VALUE *s)
#define env_name(s) env_name(&(s))
-static VALUE env_aset(VALUE nm, VALUE val);
-
static VALUE
-env_delete(VALUE name)
+env_delete(VALUE obj, VALUE name)
{
const char *nam, *val;
nam = env_name(name);
val = getenv(nam);
-
- /*
- * ENV['TZ'] = nil has a special meaning.
- * TZ is no longer considered up-to-date and ruby call tzset() as needed.
- * It could be useful if sysadmin change /etc/localtime.
- * This hack might works only on Linux glibc.
- */
- if (ENVMATCH(nam, TZ_ENV)) {
- ruby_tz_uptodate_p = FALSE;
- }
-
if (val) {
VALUE value = env_str_new2(val);
ruby_setenv(nam, 0);
if (ENVMATCH(nam, PATH_ENV)) {
RB_GC_GUARD(name);
+ path_tainted = 0;
+ }
+ else if (ENVMATCH(nam, TZ_ENV)) {
+ ruby_tz_update = 0;
}
return value;
}
@@ -4811,31 +3388,19 @@ env_delete(VALUE name)
/*
* call-seq:
- * ENV.delete(name) -> value
- * ENV.delete(name) { |name| block } -> value
- *
- * Deletes the environment variable with +name+ if it exists and returns its value:
- * ENV['foo'] = '0'
- * ENV.delete('foo') # => '0'
- * Returns +nil+ if the named environment variable does not exist:
- * ENV.delete('foo') # => nil
- * If a block given and the environment variable does not exist,
- * yields +name+ to the block and returns +nil+:
- * ENV.delete('foo') { |name| puts name } # => nil
- * foo
- * If a block given and the environment variable exists,
- * deletes the environment variable and returns its value (ignoring the block):
- * ENV['foo'] = '0'
- * ENV.delete('foo') { |name| fail 'ignored' } # => "0"
- * Raises an exception if +name+ is invalid.
- * See {Invalid Names and Values}[#class-ENV-label-Invalid-Names+and+Values].
+ * ENV.delete(name) -> value
+ * ENV.delete(name) { |name| } -> value
+ *
+ * Deletes the environment variable with +name+ and returns the value of the
+ * variable. If a block is given it will be called when the named environment
+ * does not exist.
*/
static VALUE
env_delete_m(VALUE obj, VALUE name)
{
VALUE val;
- val = env_delete(name);
+ val = env_delete(obj, name);
if (NIL_P(val) && rb_block_given_p()) rb_yield(name);
return val;
}
@@ -4844,14 +3409,8 @@ env_delete_m(VALUE obj, VALUE name)
* call-seq:
* ENV[name] -> value
*
- * Returns the value for the environment variable +name+ if it exists:
- * ENV['foo'] = '0'
- * ENV['foo'] # => "0"
- * Returns nil if the named variable does not exist:
- * ENV.clear
- * ENV['foo'] # => nil
- * Raises an exception if +name+ is invalid.
- * See {Invalid Names and Values}[#class-ENV-label-Invalid-Names+and+Values].
+ * Retrieves the +value+ for environment variable +name+ as a String. Returns
+ * +nil+ if the named variable does not exist.
*/
static VALUE
rb_f_getenv(VALUE obj, VALUE name)
@@ -4867,32 +3426,21 @@ rb_f_getenv(VALUE obj, VALUE name)
}
/*
+ * :yield: missing_name
* call-seq:
- * ENV.fetch(name) -> value
- * ENV.fetch(name, default) -> value
- * ENV.fetch(name) { |name| block } -> value
- *
- * If +name+ is the name of an environment variable, returns its value:
- * ENV['foo'] = '0'
- * ENV.fetch('foo') # => '0'
- * Otherwise if a block is given (but not a default value),
- * yields +name+ to the block and returns the block's return value:
- * ENV.fetch('foo') { |name| :need_not_return_a_string } # => :need_not_return_a_string
- * Otherwise if a default value is given (but not a block), returns the default value:
- * ENV.delete('foo')
- * ENV.fetch('foo', :default_need_not_be_a_string) # => :default_need_not_be_a_string
- * If the environment variable does not exist and both default and block are given,
- * issues a warning ("warning: block supersedes default value argument"),
- * yields +name+ to the block, and returns the block's return value:
- * ENV.fetch('foo', :default) { |name| :block_return } # => :block_return
- * Raises KeyError if +name+ is valid, but not found,
- * and neither default value nor block is given:
- * ENV.fetch('foo') # Raises KeyError (key not found: "foo")
- * Raises an exception if +name+ is invalid.
- * See {Invalid Names and Values}[#class-ENV-label-Invalid-Names+and+Values].
+ * ENV.fetch(name) -> value
+ * ENV.fetch(name, default) -> value
+ * ENV.fetch(name) { |missing_name| ... } -> value
+ *
+ * Retrieves the environment variable +name+.
+ *
+ * If the given name does not exist and neither +default+ nor a block a
+ * provided an KeyError is raised. If a block is given it is called with
+ * the missing name to provide a value. If a default value is given it will
+ * be returned when no block is given.
*/
static VALUE
-env_fetch(int argc, VALUE *argv, VALUE _)
+env_fetch(int argc, VALUE *argv)
{
VALUE key;
long block_given;
@@ -4916,11 +3464,28 @@ env_fetch(int argc, VALUE *argv, VALUE _)
return env_name_new(nam, env);
}
+static void
+path_tainted_p(const char *path)
+{
+ path_tainted = rb_path_check(path)?0:1;
+}
+
+static int
+env_path_tainted(const char *path)
+{
+ if (path_tainted < 0) {
+ path_tainted_p(path);
+ }
+ return path_tainted;
+}
+
int
rb_env_path_tainted(void)
{
- rb_warning("rb_env_path_tainted is deprecated and will be removed in Ruby 3.2.");
- return 0;
+ if (path_tainted < 0) {
+ path_tainted_p(getenv(PATH_ENV));
+ }
+ return path_tainted;
}
#if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
@@ -4959,33 +3524,10 @@ getenvsize(const WCHAR* p)
while (*p++) p += lstrlenW(p) + 1;
return p - porg + 1;
}
-
static size_t
getenvblocksize(void)
{
-#ifdef _MAX_ENV
- return _MAX_ENV;
-#else
return 32767;
-#endif
-}
-
-static int
-check_envsize(size_t n)
-{
- if (_WIN32_WINNT < 0x0600 && rb_w32_osver() < 6) {
- /* https://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx */
- /* Windows Server 2003 and Windows XP: The maximum size of the
- * environment block for the process is 32,767 characters. */
- WCHAR* p = GetEnvironmentStringsW();
- if (!p) return -1; /* never happen */
- n += getenvsize(p);
- FreeEnvironmentStringsW(p);
- if (n >= getenvblocksize()) {
- return -1;
- }
- }
- return 0;
}
#endif
@@ -5025,11 +3567,16 @@ ruby_setenv(const char *name, const char *value)
check_envname(name);
len = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0);
if (value) {
+ WCHAR* p = GetEnvironmentStringsW();
+ size_t n;
int len2;
- len2 = MultiByteToWideChar(CP_UTF8, 0, value, -1, NULL, 0);
- if (check_envsize((size_t)len + len2)) { /* len and len2 include '\0' */
+ if (!p) goto fail; /* never happen */
+ n = lstrlen(name) + 2 + strlen(value) + getenvsize(p);
+ FreeEnvironmentStringsW(p);
+ if (n >= getenvblocksize()) {
goto fail; /* 2 for '=' & '\0' */
}
+ len2 = MultiByteToWideChar(CP_UTF8, 0, value, -1, NULL, 0);
wname = ALLOCV_N(WCHAR, buf, len + len2);
wvalue = wname + len;
MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, len);
@@ -5157,61 +3704,21 @@ ruby_unsetenv(const char *name)
/*
* call-seq:
- * ENV[name] = value -> value
+ * ENV[name] = value
* ENV.store(name, value) -> value
*
- * ENV.store is an alias for ENV.[]=.
- *
- * Creates, updates, or deletes the named environment variable, returning the value.
- * Both +name+ and +value+ may be instances of String.
- * See {Valid Names and Values}[#class-ENV-label-Valid+Names+and+Values].
- *
- * - If the named environment variable does not exist:
- * - If +value+ is +nil+, does nothing.
- * ENV.clear
- * ENV['foo'] = nil # => nil
- * ENV.include?('foo') # => false
- * ENV.store('bar', nil) # => nil
- * ENV.include?('bar') # => false
- * - If +value+ is not +nil+, creates the environment variable with +name+ and +value+:
- * # Create 'foo' using ENV.[]=.
- * ENV['foo'] = '0' # => '0'
- * ENV['foo'] # => '0'
- * # Create 'bar' using ENV.store.
- * ENV.store('bar', '1') # => '1'
- * ENV['bar'] # => '1'
- * - If the named environment variable exists:
- * - If +value+ is not +nil+, updates the environment variable with value +value+:
- * # Update 'foo' using ENV.[]=.
- * ENV['foo'] = '2' # => '2'
- * ENV['foo'] # => '2'
- * # Update 'bar' using ENV.store.
- * ENV.store('bar', '3') # => '3'
- * ENV['bar'] # => '3'
- * - If +value+ is +nil+, deletes the environment variable:
- * # Delete 'foo' using ENV.[]=.
- * ENV['foo'] = nil # => nil
- * ENV.include?('foo') # => false
- * # Delete 'bar' using ENV.store.
- * ENV.store('bar', nil) # => nil
- * ENV.include?('bar') # => false
- *
- * Raises an exception if +name+ or +value+ is invalid.
- * See {Invalid Names and Values}[#class-ENV-label-Invalid+Names+and+Values].
+ * Sets the environment variable +name+ to +value+. If the value given is
+ * +nil+ the environment variable is deleted.
+ * +name+ must be a string.
+ *
*/
static VALUE
-env_aset_m(VALUE obj, VALUE nm, VALUE val)
-{
- return env_aset(nm, val);
-}
-
-static VALUE
-env_aset(VALUE nm, VALUE val)
+env_aset(VALUE obj, VALUE nm, VALUE val)
{
char *name, *value;
if (NIL_P(val)) {
- env_delete(nm);
+ env_delete(obj, nm);
return Qnil;
}
SafeStringValue(nm);
@@ -5224,13 +3731,27 @@ env_aset(VALUE nm, VALUE val)
ruby_setenv(name, value);
if (ENVMATCH(name, PATH_ENV)) {
RB_GC_GUARD(nm);
+ if (OBJ_TAINTED(val)) {
+ /* already tainted, no check */
+ path_tainted = 1;
+ return val;
+ }
+ else {
+ path_tainted_p(value);
+ }
}
else if (ENVMATCH(name, TZ_ENV)) {
- ruby_tz_uptodate_p = FALSE;
+ ruby_tz_update = 0;
}
return val;
}
+/*
+ * call-seq:
+ * ENV.keys -> Array
+ *
+ * Returns every environment variable name in an Array
+ */
static VALUE
env_keys(void)
{
@@ -5250,27 +3771,6 @@ env_keys(void)
return ary;
}
-/*
- * call-seq:
- * ENV.keys -> Array
- *
- * Returns all variable names in an Array:
- * ENV.replace('foo' => '0', 'bar' => '1')
- * ENV.keys # => ['bar', 'foo']
- * The order of the names is OS-dependent.
- * See {About Ordering}[#class-ENV-label-About+Ordering].
- *
- * Returns the empty Array if ENV is empty:
- * ENV.clear
- * ENV.keys # => []
- */
-
-static VALUE
-env_f_keys(VALUE _)
-{
- return env_keys();
-}
-
static VALUE
rb_env_size(VALUE ehash, VALUE args, VALUE eobj)
{
@@ -5289,20 +3789,12 @@ rb_env_size(VALUE ehash, VALUE args, VALUE eobj)
/*
* call-seq:
- * ENV.each_key { |name| block } -> ENV
- * ENV.each_key -> Enumerator
- *
- * Yields each environment variable name:
- * ENV.replace('foo' => '0', 'bar' => '1') # => ENV
- * names = []
- * ENV.each_key { |name| names.push(name) } # => ENV
- * names # => ["bar", "foo"]
- *
- * Returns an Enumerator if no block given:
- * e = ENV.each_key # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_key>
- * names = []
- * e.each { |name| names.push(name) } # => ENV
- * names # => ["bar", "foo"]
+ * ENV.each_key { |name| } -> Hash
+ * ENV.each_key -> Enumerator
+ *
+ * Yields each environment variable name.
+ *
+ * An Enumerator is returned if no block is given.
*/
static VALUE
env_each_key(VALUE ehash)
@@ -5318,6 +3810,12 @@ env_each_key(VALUE ehash)
return ehash;
}
+/*
+ * call-seq:
+ * ENV.values -> Array
+ *
+ * Returns every environment variable value as an Array
+ */
static VALUE
env_values(void)
{
@@ -5339,40 +3837,12 @@ env_values(void)
/*
* call-seq:
- * ENV.values -> Array
+ * ENV.each_value { |value| } -> Hash
+ * ENV.each_value -> Enumerator
*
- * Returns all environment variable values in an Array:
- * ENV.replace('foo' => '0', 'bar' => '1')
- * ENV.values # => ['1', '0']
- * The order of the values is OS-dependent.
- * See {About Ordering}[#class-ENV-label-About+Ordering].
+ * Yields each environment variable +value+.
*
- * Returns the empty Array if ENV is empty:
- * ENV.clear
- * ENV.values # => []
- */
-static VALUE
-env_f_values(VALUE _)
-{
- return env_values();
-}
-
-/*
- * call-seq:
- * ENV.each_value { |value| block } -> ENV
- * ENV.each_value -> Enumerator
- *
- * Yields each environment variable value:
- * ENV.replace('foo' => '0', 'bar' => '1') # => ENV
- * values = []
- * ENV.each_value { |value| values.push(value) } # => ENV
- * values # => ["1", "0"]
- *
- * Returns an Enumerator if no block given:
- * e = ENV.each_value # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_value>
- * values = []
- * e.each { |value| values.push(value) } # => ENV
- * values # => ["1", "0"]
+ * An Enumerator is returned if no block was given.
*/
static VALUE
env_each_value(VALUE ehash)
@@ -5390,21 +3860,14 @@ env_each_value(VALUE ehash)
/*
* call-seq:
- * ENV.each { |name, value| block } -> ENV
- * ENV.each -> Enumerator
- * ENV.each_pair { |name, value| block } -> ENV
- * ENV.each_pair -> Enumerator
- *
- * Yields each environment variable name and its value as a 2-element Array:
- * h = {}
- * ENV.each_pair { |name, value| h[name] = value } # => ENV
- * h # => {"bar"=>"1", "foo"=>"0"}
- *
- * Returns an Enumerator if no block given:
- * h = {}
- * e = ENV.each_pair # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_pair>
- * e.each { |name, value| h[name] = value } # => ENV
- * h # => {"bar"=>"1", "foo"=>"0"}
+ * ENV.each { |name, value| } -> Hash
+ * ENV.each -> Enumerator
+ * ENV.each_pair { |name, value| } -> Hash
+ * ENV.each_pair -> Enumerator
+ *
+ * Yields each environment variable +name+ and +value+.
+ *
+ * If no block is given an Enumerator is returned.
*/
static VALUE
env_each_pair(VALUE ehash)
@@ -5442,24 +3905,12 @@ env_each_pair(VALUE ehash)
/*
* call-seq:
- * ENV.reject! { |name, value| block } -> ENV or nil
- * ENV.reject! -> Enumerator
- *
- * Similar to ENV.delete_if, but returns +nil+ if no changes were made.
- *
- * Deletes each environment variable for which the block returns a truthy value,
- * returning ENV (if any deletions) or +nil+ (if not):
- * ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
- * ENV.reject! { |name, value| name.start_with?('b') } # => ENV
- * ENV # => {"foo"=>"0"}
- * ENV.reject! { |name, value| name.start_with?('b') } # => nil
- *
- * Returns an Enumerator if no block given:
- * ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
- * e = ENV.reject! # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:reject!>
- * e.each { |name, value| name.start_with?('b') } # => ENV
- * ENV # => {"foo"=>"0"}
- * e.each { |name, value| name.start_with?('b') } # => nil
+ * ENV.reject! { |name, value| } -> ENV or nil
+ * ENV.reject! -> Enumerator
+ *
+ * Equivalent to ENV#delete_if but returns +nil+ if no changes were made.
+ *
+ * Returns an Enumerator if no block was given.
*/
static VALUE
env_reject_bang(VALUE ehash)
@@ -5475,7 +3926,8 @@ env_reject_bang(VALUE ehash)
VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i));
if (!NIL_P(val)) {
if (RTEST(rb_yield_values(2, RARRAY_AREF(keys, i), val))) {
- env_delete(RARRAY_AREF(keys, i));
+ FL_UNSET(RARRAY_AREF(keys, i), FL_TAINT);
+ env_delete(Qnil, RARRAY_AREF(keys, i));
del++;
}
}
@@ -5487,8 +3939,8 @@ env_reject_bang(VALUE ehash)
/*
* call-seq:
- * ENV.delete_if { |name, value| block } -> ENV
- * ENV.delete_if -> Enumerator
+ * ENV.delete_if { |name, value| } -> Hash
+ * ENV.delete_if -> Enumerator
*
* Deletes every environment variable for which the block evaluates to +true+.
*
@@ -5510,7 +3962,7 @@ env_delete_if(VALUE ehash)
* the given names. See also ENV.select.
*/
static VALUE
-env_values_at(int argc, VALUE *argv, VALUE _)
+env_values_at(int argc, VALUE *argv)
{
VALUE result;
long i;
@@ -5524,16 +3976,12 @@ env_values_at(int argc, VALUE *argv, VALUE _)
/*
* call-seq:
- * ENV.select { |name, value| block } -> Hash
- * ENV.select -> Enumerator
- * ENV.filter { |name, value| block } -> Hash
- * ENV.filter -> Enumerator
+ * ENV.select { |name, value| } -> Hash
+ * ENV.select -> Enumerator
*
* Returns a copy of the environment for entries where the block returns true.
*
* Returns an Enumerator if no block was given.
- *
- * ENV.filter is an alias for ENV.select.
*/
static VALUE
env_select(VALUE ehash)
@@ -5561,14 +4009,10 @@ env_select(VALUE ehash)
/*
* call-seq:
- * ENV.select! { |name, value| block } -> ENV or nil
- * ENV.select! -> Enumerator
- * ENV.filter! { |name, value| block } -> ENV or nil
- * ENV.filter! -> Enumerator
+ * ENV.select! { |name, value| } -> ENV or nil
+ * ENV.select! -> Enumerator
*
- * Equivalent to ENV.keep_if but returns +nil+ if no changes were made.
- *
- * ENV.filter! is an alias for ENV.select!.
+ * Equivalent to ENV#keep_if but returns +nil+ if no changes were made.
*/
static VALUE
env_select_bang(VALUE ehash)
@@ -5584,7 +4028,8 @@ env_select_bang(VALUE ehash)
VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i));
if (!NIL_P(val)) {
if (!RTEST(rb_yield_values(2, RARRAY_AREF(keys, i), val))) {
- env_delete(RARRAY_AREF(keys, i));
+ FL_UNSET(RARRAY_AREF(keys, i), FL_TAINT);
+ env_delete(Qnil, RARRAY_AREF(keys, i));
del++;
}
}
@@ -5596,8 +4041,8 @@ env_select_bang(VALUE ehash)
/*
* call-seq:
- * ENV.keep_if { |name, value| block } -> ENV
- * ENV.keep_if -> Enumerator
+ * ENV.keep_if { |name, value| } -> Hash
+ * ENV.keep_if -> Enumerator
*
* Deletes every environment variable where the block evaluates to +false+.
*
@@ -5612,34 +4057,11 @@ env_keep_if(VALUE ehash)
}
/*
- * call-seq:
- * ENV.slice(*keys) -> a_hash
- *
- * Returns a hash containing only the given keys from ENV and their values.
+ * call-seq:
+ * ENV.clear
*
- * ENV.slice("TERM","HOME") #=> {"TERM"=>"xterm-256color", "HOME"=>"/Users/rhc"}
+ * Removes every environment variable.
*/
-static VALUE
-env_slice(int argc, VALUE *argv, VALUE _)
-{
- int i;
- VALUE key, value, result;
-
- if (argc == 0) {
- return rb_hash_new();
- }
- result = rb_hash_new_with_size(argc);
-
- for (i = 0; i < argc; i++) {
- key = argv[i];
- value = rb_f_getenv(Qnil, key);
- if (value != Qnil)
- rb_hash_aset(result, key, value);
- }
-
- return result;
-}
-
VALUE
rb_env_clear(void)
{
@@ -5650,7 +4072,7 @@ rb_env_clear(void)
for (i=0; i<RARRAY_LEN(keys); i++) {
VALUE val = rb_f_getenv(Qnil, RARRAY_AREF(keys, i));
if (!NIL_P(val)) {
- env_delete(RARRAY_AREF(keys, i));
+ env_delete(Qnil, RARRAY_AREF(keys, i));
}
}
RB_GC_GUARD(keys);
@@ -5659,28 +4081,12 @@ rb_env_clear(void)
/*
* call-seq:
- * ENV.clear -> ENV
- *
- * Removes every environment variable; returns ENV:
- * ENV.replace('foo' => '0', 'bar' => '1')
- * ENV.size # => 2
- * ENV.clear # => ENV
- * ENV.size # => 0
- */
-static VALUE
-env_clear(VALUE _)
-{
- return rb_env_clear();
-}
-
-/*
- * call-seq:
* ENV.to_s -> "ENV"
*
* Returns "ENV"
*/
static VALUE
-env_to_s(VALUE _)
+env_to_s(void)
{
return rb_usascii_str_new2("ENV");
}
@@ -5692,7 +4098,7 @@ env_to_s(VALUE _)
* Returns the contents of the environment as a String.
*/
static VALUE
-env_inspect(VALUE _)
+env_inspect(void)
{
char **env;
VALUE str, i;
@@ -5716,6 +4122,7 @@ env_inspect(VALUE _)
}
FREE_ENVIRON(environ);
rb_str_buf_cat2(str, "}");
+ OBJ_TAINT(str);
return str;
}
@@ -5730,7 +4137,7 @@ env_inspect(VALUE _)
*
*/
static VALUE
-env_to_a(VALUE _)
+env_to_a(void)
{
char **env;
VALUE ary;
@@ -5757,7 +4164,7 @@ env_to_a(VALUE _)
* compatibility with Hash.
*/
static VALUE
-env_none(VALUE _)
+env_none(void)
{
return Qnil;
}
@@ -5770,7 +4177,7 @@ env_none(VALUE _)
* Returns the number of environment variables.
*/
static VALUE
-env_size(VALUE _)
+env_size(void)
{
int i;
char **env;
@@ -5789,7 +4196,7 @@ env_size(VALUE _)
* Returns true when there are no environment variables
*/
static VALUE
-env_empty_p(VALUE _)
+env_empty_p(void)
{
char **env;
@@ -5804,28 +4211,12 @@ env_empty_p(VALUE _)
/*
* call-seq:
+ * ENV.key?(name) -> true or false
* ENV.include?(name) -> true or false
* ENV.has_key?(name) -> true or false
* ENV.member?(name) -> true or false
- * ENV.key?(name) -> true or false
*
- * ENV.has_key?, ENV.member?, and ENV.key? are aliases for ENV.include?.
- *
- * Returns +true+ if there is an environment variable with the given +name+:
- * ENV.replace('foo' => '0', 'bar' => '1')
- * ENV.include?('foo') # => true
- * Returns +false+ if +name+ is a valid String and there is no such environment variable:
- * ENV.include?('baz') # => false
- * Returns +false+ if +name+ is the empty String or is a String containing character <code>'='</code>:
- * ENV.include?('') # => false
- * ENV.include?('=') # => false
- * Raises an exception if +name+ is a String containing the NUL character <code>"\0"</code>:
- * ENV.include?("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
- * Raises an exception if +name+ has an encoding that is not ASCII-compatible:
- * ENV.include?("\xa1\xa1".force_encoding(Encoding::UTF_16LE))
- * # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
- * Raises an exception if +name+ is not a String:
- * ENV.include?(Object.new) # TypeError (no implicit conversion of Object into String)
+ * Returns +true+ if there is an environment variable with the given +name+.
*/
static VALUE
env_has_key(VALUE env, VALUE key)
@@ -5841,22 +4232,8 @@ env_has_key(VALUE env, VALUE key)
* call-seq:
* ENV.assoc(name) -> Array or nil
*
- * Returns a 2-element Array containing the name and value of the environment variable
- * for +name+ if it exists:
- * ENV.replace('foo' => '0', 'bar' => '1')
- * ENV.assoc('foo') # => ['foo' '0']
- * Returns +nil+ if +name+ is a valid String and there is no such environment variable:
- * ENV.assoc('baz') # => false
- * Returns +nil+ if +name+ is the empty String or is a String containing character <code>'='</code>:
- * ENV.assoc('') # => false
- * ENV.assoc('=') # => false
- * Raises an exception if +name+ is a String containing the NUL character <code>"\0"</code>:
- * ENV.assoc("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
- * Raises an exception if +name+ has an encoding that is not ASCII-compatible:
- * ENV.assoc("\xa1\xa1".force_encoding(Encoding::UTF_16LE))
- * # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
- * Raises an exception if +name+ is not a String:
- * ENV.assoc(Object.new) # TypeError (no implicit conversion of Object into String)
+ * Returns an Array of the name and value of the environment variable with
+ * +name+ or +nil+ if the name cannot be found.
*/
static VALUE
env_assoc(VALUE env, VALUE key)
@@ -5883,6 +4260,7 @@ env_has_value(VALUE dmy, VALUE obj)
obj = rb_check_string_type(obj);
if (NIL_P(obj)) return Qnil;
+ rb_check_safe_obj(obj);
env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
@@ -5913,13 +4291,14 @@ env_rassoc(VALUE dmy, VALUE obj)
obj = rb_check_string_type(obj);
if (NIL_P(obj)) return Qnil;
+ rb_check_safe_obj(obj);
env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s++) {
long len = strlen(s);
if (RSTRING_LEN(obj) == len && strncmp(s, RSTRING_PTR(obj), len) == 0) {
- VALUE result = rb_assoc_new(rb_str_new(*env, s-*env-1), obj);
+ VALUE result = rb_assoc_new(rb_tainted_str_new(*env, s-*env-1), obj);
FREE_ENVIRON(environ);
return result;
}
@@ -5932,18 +4311,10 @@ env_rassoc(VALUE dmy, VALUE obj)
/*
* call-seq:
- * ENV.key(value) -> name or nil
- *
- * Returns the name of the first environment variable with +value+ if it exists:
- * ENV.replace('foo' => '0', 'bar' => '1')
- * ENV.key('0') # =>'foo'
- * The order in which environment variables are examined is OS-dependent.
- * See {About Ordering}[#class-ENV-label-About+Ordering].
- *
- * Returns +nil+ if there is no such value:
- * ENV.key('2') # => nil
- * Raises an exception if +value+ is not a String:
- * ENV.key(Object.new) # raises TypeError (no implicit conversion of Object into String)
+ * ENV.key(value) -> name
+ *
+ * Returns the name of the environment variable with +value+. If the value is
+ * not found +nil+ is returned.
*/
static VALUE
env_key(VALUE dmy, VALUE value)
@@ -5978,10 +4349,18 @@ env_key(VALUE dmy, VALUE value)
static VALUE
env_index(VALUE dmy, VALUE value)
{
- rb_warn_deprecated("ENV.index", "ENV.key");
+ rb_warn("ENV.index is deprecated; use ENV.key");
return env_key(dmy, value);
}
+/*
+ * call-seq:
+ * ENV.to_hash -> hash
+ * ENV.to_h -> hash
+ *
+ * Creates a hash with a copy of the environment variables.
+ *
+ */
static VALUE
env_to_hash(void)
{
@@ -6004,83 +4383,27 @@ env_to_hash(void)
/*
* call-seq:
- * ENV.to_hash -> hash
- *
- * Creates a hash with a copy of the environment variables.
+ * ENV.reject { |name, value| } -> Hash
+ * ENV.reject -> Enumerator
*
- */
-
-static VALUE
-env_f_to_hash(VALUE _)
-{
- return env_to_hash();
-}
-
-/*
- * call-seq:
- * ENV.to_h -> hash
- * ENV.to_h {|name, value| block } -> hash
- *
- * Creates a hash with a copy of the environment variables.
- *
- */
-static VALUE
-env_to_h(VALUE _)
-{
- VALUE hash = env_to_hash();
- if (rb_block_given_p()) {
- hash = rb_hash_to_h_block(hash);
- }
- return hash;
-}
-
-/*
- * call-seq:
- * ENV.reject { |name, value| block } -> Hash
- * ENV.reject -> Enumerator
- *
- * Same as ENV.delete_if, but works on (and returns) a copy of the
+ * Same as ENV#delete_if, but works on (and returns) a copy of the
* environment.
*/
static VALUE
-env_reject(VALUE _)
+env_reject(void)
{
return rb_hash_delete_if(env_to_hash());
}
/*
* call-seq:
- * ENV.freeze -> raises TypeError
+ * ENV.shift -> Array or nil
*
- * Ruby does not allow ENV to be frozen, so calling ENV.freeze
- * raises TypeError.
+ * Removes an environment variable name-value pair from ENV and returns it as
+ * an Array. Returns +nil+ if when the environment is empty.
*/
static VALUE
-env_freeze(VALUE self)
-{
- rb_raise(rb_eTypeError, "cannot freeze ENV");
- return self; /* Not reached */
-}
-
-/*
- * call-seq:
- * ENV.shift -> [name, value] or nil
- *
- * Removes the first environment variable from ENV and returns
- * a 2-element Array containing its name and value:
- * ENV.replace('foo' => '0', 'bar' => '1')
- * ENV.to_hash # => {'bar' => '1', 'foo' => '0'}
- * ENV.shift # => ['bar', '1']
- * ENV.to_hash # => {'foo' => '0'}
- * Exactly which environment variable is "first" is OS-dependent.
- * See {About Ordering}[#class-ENV-label-About+Ordering].
- *
- * Returns +nil+ if the environment is empty:
- * ENV.clear
- * ENV.shift # => nil
- */
-static VALUE
-env_shift(VALUE _)
+env_shift(void)
{
char **env;
VALUE result = Qnil;
@@ -6091,7 +4414,7 @@ env_shift(VALUE _)
if (s) {
VALUE key = env_str_new(*env, s-*env);
VALUE val = env_str_new2(getenv(RSTRING_PTR(key)));
- env_delete(key);
+ env_delete(Qnil, key);
result = rb_assoc_new(key, val);
}
}
@@ -6107,51 +4430,27 @@ env_shift(VALUE _)
* and values as names.
*/
static VALUE
-env_invert(VALUE _)
+env_invert(void)
{
return rb_hash_invert(env_to_hash());
}
-static void
-keylist_delete(VALUE keys, VALUE key)
-{
- long keylen, elen;
- const char *keyptr, *eptr;
- RSTRING_GETMEM(key, keyptr, keylen);
- for (long i=0; i<RARRAY_LEN(keys); i++) {
- VALUE e = RARRAY_AREF(keys, i);
- RSTRING_GETMEM(e, eptr, elen);
- if (elen != keylen) continue;
- if (!ENVNMATCH(keyptr, eptr, elen)) continue;
- rb_ary_delete_at(keys, i);
- return;
- }
-}
-
static int
env_replace_i(VALUE key, VALUE val, VALUE keys)
{
- env_name(key);
- env_aset(key, val);
-
- keylist_delete(keys, key);
+ env_aset(Qnil, key, val);
+ if (rb_ary_includes(keys, key)) {
+ rb_ary_delete(keys, key);
+ }
return ST_CONTINUE;
}
/*
* call-seq:
- * ENV.replace(hash) -> ENV
- *
- * Replaces the entire content of the environment variables
- * with the name/value pairs in the given +hash+;
- * returns ENV.
+ * ENV.replace(hash) -> env
*
- * Replaces the content of ENV with the given pairs:
- * ENV.replace('foo' => '0', 'bar' => '1') # => ENV
- * ENV.to_hash # => {"bar"=>"1", "foo"=>"0"}
- *
- * Raises an exception if a name or value is invalid.
- * See {Invalid Names and Values}[#class-ENV-label-Invalid-Names+and+Values].
+ * Replaces the contents of the environment variables with the contents of
+ * +hash+.
*/
static VALUE
env_replace(VALUE env, VALUE hash)
@@ -6165,36 +4464,26 @@ env_replace(VALUE env, VALUE hash)
rb_hash_foreach(hash, env_replace_i, keys);
for (i=0; i<RARRAY_LEN(keys); i++) {
- env_delete(RARRAY_AREF(keys, i));
+ env_delete(env, RARRAY_AREF(keys, i));
}
RB_GC_GUARD(keys);
return env;
}
static int
-env_update_i(VALUE key, VALUE val, VALUE _)
-{
- env_aset(key, val);
- return ST_CONTINUE;
-}
-
-static int
-env_update_block_i(VALUE key, VALUE val, VALUE _)
+env_update_i(VALUE key, VALUE val)
{
- VALUE oldval = rb_f_getenv(Qnil, key);
- if (!NIL_P(oldval)) {
- val = rb_yield_values(3, key, oldval, val);
+ if (rb_block_given_p()) {
+ val = rb_yield_values(3, key, rb_f_getenv(Qnil, key), val);
}
- env_aset(key, val);
+ env_aset(Qnil, key, val);
return ST_CONTINUE;
}
/*
* call-seq:
- * ENV.update(hash) -> ENV
- * ENV.update(hash) { |name, old_value, new_value| block } -> ENV
- * ENV.merge!(hash) -> ENV
- * ENV.merge!(hash) { |name, old_value, new_value| block } -> ENV
+ * ENV.update(hash) -> Hash
+ * ENV.update(hash) { |name, old_value, new_value| } -> Hash
*
* Adds the contents of +hash+ to the environment variables. If no block is
* specified entries with duplicate keys are overwritten, otherwise the value
@@ -6206,9 +4495,7 @@ env_update(VALUE env, VALUE hash)
{
if (env == hash) return env;
hash = to_hash(hash);
- rb_foreach_func *func = rb_block_given_p() ?
- env_update_block_i : env_update_i;
- rb_hash_foreach(hash, func, 0);
+ rb_hash_foreach(hash, env_update_i, 0);
return env;
}
@@ -6330,11 +4617,11 @@ Init_Hash(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
+
id_hash = rb_intern("hash");
id_yield = rb_intern("yield");
id_default = rb_intern("default");
id_flatten_bang = rb_intern("flatten!");
- id_hash_iter_lev = rb_make_internal_id();
rb_cHash = rb_define_class("Hash", rb_cObject);
@@ -6344,7 +4631,7 @@ Init_Hash(void)
rb_define_singleton_method(rb_cHash, "[]", rb_hash_s_create, -1);
rb_define_singleton_method(rb_cHash, "try_convert", rb_hash_s_try_convert, 1);
rb_define_method(rb_cHash, "initialize", rb_hash_initialize, -1);
- rb_define_method(rb_cHash, "initialize_copy", rb_hash_replace, 1);
+ rb_define_method(rb_cHash, "initialize_copy", rb_hash_initialize_copy, 1);
rb_define_method(rb_cHash, "rehash", rb_hash_rehash, 0);
rb_define_method(rb_cHash, "to_hash", rb_hash_to_hash, 0);
@@ -6392,17 +4679,15 @@ Init_Hash(void)
rb_define_method(rb_cHash, "keep_if", rb_hash_keep_if, 0);
rb_define_method(rb_cHash, "select", rb_hash_select, 0);
rb_define_method(rb_cHash, "select!", rb_hash_select_bang, 0);
- rb_define_method(rb_cHash, "filter", rb_hash_select, 0);
- rb_define_method(rb_cHash, "filter!", rb_hash_select_bang, 0);
rb_define_method(rb_cHash, "reject", rb_hash_reject, 0);
rb_define_method(rb_cHash, "reject!", rb_hash_reject_bang, 0);
rb_define_method(rb_cHash, "slice", rb_hash_slice, -1);
rb_define_method(rb_cHash, "clear", rb_hash_clear, 0);
rb_define_method(rb_cHash, "invert", rb_hash_invert, 0);
- rb_define_method(rb_cHash, "update", rb_hash_update, -1);
+ rb_define_method(rb_cHash, "update", rb_hash_update, 1);
rb_define_method(rb_cHash, "replace", rb_hash_replace, 1);
- rb_define_method(rb_cHash, "merge!", rb_hash_update, -1);
- rb_define_method(rb_cHash, "merge", rb_hash_merge, -1);
+ rb_define_method(rb_cHash, "merge!", rb_hash_update, 1);
+ rb_define_method(rb_cHash, "merge", rb_hash_merge, 1);
rb_define_method(rb_cHash, "assoc", rb_hash_assoc, 1);
rb_define_method(rb_cHash, "rassoc", rb_hash_rassoc, 1);
rb_define_method(rb_cHash, "flatten", rb_hash_flatten, -1);
@@ -6427,89 +4712,9 @@ Init_Hash(void)
rb_define_method(rb_cHash, ">=", rb_hash_ge, 1);
rb_define_method(rb_cHash, ">", rb_hash_gt, 1);
- rb_define_method(rb_cHash, "deconstruct_keys", rb_hash_deconstruct_keys, 1);
-
- rb_define_singleton_method(rb_cHash, "ruby2_keywords_hash?", rb_hash_s_ruby2_keywords_hash_p, 1);
- rb_define_singleton_method(rb_cHash, "ruby2_keywords_hash", rb_hash_s_ruby2_keywords_hash, 1);
-
/* Document-class: ENV
*
* ENV is a hash-like accessor for environment variables.
- *
- * === Interaction with the Operating System
- *
- * The ENV object interacts with the operating system's environment variables:
- *
- * - When you get the value for a name in ENV, the value is retrieved from among the current environment variables.
- * - When you create or set a name-value pair in ENV, the name and value are immediately set in the environment variables.
- * - When you delete a name-value pair in ENV, it is immediately deleted from the environment variables.
- *
- * === Names and Values
- *
- * Generally, a name or value is a String.
- *
- * ==== Valid Names and Values
- *
- * Each name or value must be one of the following:
- *
- * - A String.
- * - An object that responds to \#to_str by returning a String, in which case that String will be used as the name or value.
- *
- * ==== Invalid Names and Values
- *
- * A new name:
- *
- * - May not be the empty string:
- * ENV[''] = '0'
- * # Raises Errno::EINVAL (Invalid argument - ruby_setenv())
- *
- * - May not contain character <code>"="</code>:
- * ENV['='] = '0'
- * # Raises Errno::EINVAL (Invalid argument - ruby_setenv(=))
- *
- * A new name or value:
- *
- * - May not be a non-String that does not respond to \#to_str:
- *
- * ENV['foo'] = Object.new
- * # Raises TypeError (no implicit conversion of Object into String)
- * ENV[Object.new] = '0'
- * # Raises TypeError (no implicit conversion of Object into String)
- *
- * - May not contain the NUL character <code>"\0"</code>:
- *
- * ENV['foo'] = "\0"
- * # Raises ArgumentError (bad environment variable value: contains null byte)
- * ENV["\0"] == '0'
- * # Raises ArgumentError (bad environment variable name: contains null byte)
- *
- * - May not have an ASCII-incompatible encoding such as UTF-16LE or ISO-2022-JP:
- *
- * ENV['foo'] = '0'.force_encoding(Encoding::ISO_2022_JP)
- * # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP)
- * ENV["foo".force_encoding(Encoding::ISO_2022_JP)] = '0'
- * # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP)
- *
- * === About Ordering
- *
- * ENV enumerates its name/value pairs in the order found
- * in the operating system's environment variables.
- * Therefore the ordering of ENV content is OS-dependent, and may be indeterminate.
- *
- * This will be seen in:
- * - A Hash returned by an ENV method.
- * - An Enumerator returned by an ENV method.
- * - An Array returned by ENV.keys, ENV.values, or ENV.to_a.
- * - The String returned by ENV.inspect.
- * - The Array returned by ENV.shift.
- * - The name returned by ENV.key.
- *
- * === About the Examples
- * Some methods in ENV return ENV itself. Typically, there are many environment variables.
- * It's not useful to display a large ENV in the examples here,
- * so most example snippets begin by resetting the contents of ENV:
- * - ENV.replace replaces ENV with a new collection of entries.
- * - ENV.clear empties ENV.
*/
/*
@@ -6522,8 +4727,8 @@ Init_Hash(void)
rb_define_singleton_method(envtbl, "[]", rb_f_getenv, 1);
rb_define_singleton_method(envtbl, "fetch", env_fetch, -1);
- rb_define_singleton_method(envtbl, "[]=", env_aset_m, 2);
- rb_define_singleton_method(envtbl, "store", env_aset_m, 2);
+ rb_define_singleton_method(envtbl, "[]=", env_aset, 2);
+ rb_define_singleton_method(envtbl, "store", env_aset, 2);
rb_define_singleton_method(envtbl, "each", env_each_pair, 0);
rb_define_singleton_method(envtbl, "each_pair", env_each_pair, 0);
rb_define_singleton_method(envtbl, "each_key", env_each_key, 0);
@@ -6531,20 +4736,15 @@ Init_Hash(void)
rb_define_singleton_method(envtbl, "delete", env_delete_m, 1);
rb_define_singleton_method(envtbl, "delete_if", env_delete_if, 0);
rb_define_singleton_method(envtbl, "keep_if", env_keep_if, 0);
- rb_define_singleton_method(envtbl, "slice", env_slice, -1);
- rb_define_singleton_method(envtbl, "clear", env_clear, 0);
+ rb_define_singleton_method(envtbl, "clear", rb_env_clear, 0);
rb_define_singleton_method(envtbl, "reject", env_reject, 0);
rb_define_singleton_method(envtbl, "reject!", env_reject_bang, 0);
rb_define_singleton_method(envtbl, "select", env_select, 0);
rb_define_singleton_method(envtbl, "select!", env_select_bang, 0);
- rb_define_singleton_method(envtbl, "filter", env_select, 0);
- rb_define_singleton_method(envtbl, "filter!", env_select_bang, 0);
rb_define_singleton_method(envtbl, "shift", env_shift, 0);
- rb_define_singleton_method(envtbl, "freeze", env_freeze, 0);
rb_define_singleton_method(envtbl, "invert", env_invert, 0);
rb_define_singleton_method(envtbl, "replace", env_replace, 1);
rb_define_singleton_method(envtbl, "update", env_update, 1);
- rb_define_singleton_method(envtbl, "merge!", env_update, 1);
rb_define_singleton_method(envtbl, "inspect", env_inspect, 0);
rb_define_singleton_method(envtbl, "rehash", env_none, 0);
rb_define_singleton_method(envtbl, "to_a", env_to_a, 0);
@@ -6554,8 +4754,8 @@ Init_Hash(void)
rb_define_singleton_method(envtbl, "size", env_size, 0);
rb_define_singleton_method(envtbl, "length", env_size, 0);
rb_define_singleton_method(envtbl, "empty?", env_empty_p, 0);
- rb_define_singleton_method(envtbl, "keys", env_f_keys, 0);
- rb_define_singleton_method(envtbl, "values", env_f_values, 0);
+ rb_define_singleton_method(envtbl, "keys", env_keys, 0);
+ rb_define_singleton_method(envtbl, "values", env_values, 0);
rb_define_singleton_method(envtbl, "values_at", env_values_at, -1);
rb_define_singleton_method(envtbl, "include?", env_has_key, 1);
rb_define_singleton_method(envtbl, "member?", env_has_key, 1);
@@ -6563,8 +4763,8 @@ Init_Hash(void)
rb_define_singleton_method(envtbl, "has_value?", env_has_value, 1);
rb_define_singleton_method(envtbl, "key?", env_has_key, 1);
rb_define_singleton_method(envtbl, "value?", env_has_value, 1);
- rb_define_singleton_method(envtbl, "to_hash", env_f_to_hash, 0);
- rb_define_singleton_method(envtbl, "to_h", env_to_h, 0);
+ rb_define_singleton_method(envtbl, "to_hash", env_to_hash, 0);
+ rb_define_singleton_method(envtbl, "to_h", env_to_hash, 0);
rb_define_singleton_method(envtbl, "assoc", env_assoc, 1);
rb_define_singleton_method(envtbl, "rassoc", env_rassoc, 1);
@@ -6577,6 +4777,4 @@ Init_Hash(void)
/* for callcc */
ruby_register_rollback_func_for_ensure(hash_foreach_ensure, hash_foreach_ensure_rollback);
-
- HASH_ASSERT(sizeof(ar_hint_t) * RHASH_AR_TABLE_MAX_SIZE == sizeof(VALUE));
}
diff --git a/hrtime.h b/hrtime.h
deleted file mode 100644
index f133bdb1ac..0000000000
--- a/hrtime.h
+++ /dev/null
@@ -1,168 +0,0 @@
-#ifndef RB_HRTIME_H
-#define RB_HRTIME_H
-#include "ruby/ruby.h"
-#include <time.h>
-#if defined(HAVE_SYS_TIME_H)
-# include <sys/time.h>
-#endif
-
-/*
- * Hi-res monotonic clock. It is currently nsec resolution, which has over
- * 500 years of range (with an unsigned 64-bit integer). Developers
- * targeting small systems may try 32-bit and low-resolution (milliseconds).
- *
- * TBD: Is nsec even necessary? usec resolution seems enough for userspace
- * and it'll be suitable for use with devices lasting over 500,000 years
- * (maybe some devices designed for long-term space travel)
- *
- * Current API:
- *
- * * rb_hrtime_now - current clock value (monotonic if available)
- * * rb_hrtime_mul - multiply with overflow check
- * * rb_hrtime_add - add with overflow check
- * * rb_timeval2hrtime - convert from timeval
- * * rb_timespec2hrtime - convert from timespec
- * * rb_msec2hrtime - convert from millisecond
- * * rb_sec2hrtime - convert from time_t (seconds)
- * * rb_hrtime2timeval - convert to timeval
- * * rb_hrtime2timespec - convert to timespec
- *
- * Note: no conversion to milliseconds is provided here because different
- * functions have different limits (e.g. epoll_wait vs w32_wait_events).
- * So we provide RB_HRTIME_PER_MSEC and similar macros for implementing
- * this for each use case.
- */
-#define RB_HRTIME_PER_USEC ((rb_hrtime_t)1000)
-#define RB_HRTIME_PER_MSEC (RB_HRTIME_PER_USEC * (rb_hrtime_t)1000)
-#define RB_HRTIME_PER_SEC (RB_HRTIME_PER_MSEC * (rb_hrtime_t)1000)
-#define RB_HRTIME_MAX UINT64_MAX
-
-/*
- * Lets try to support time travelers. Lets assume anybody with a time machine
- * also has access to a modern gcc or clang with 128-bit int support
- */
-#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
-typedef int128_t rb_hrtime_t;
-#else
-typedef uint64_t rb_hrtime_t;
-#endif
-
-/* thread.c */
-/* returns the value of the monotonic clock (if available) */
-rb_hrtime_t rb_hrtime_now(void);
-
-/*
- * multiply @a and @b with overflow check and return the
- * (clamped to RB_HRTIME_MAX) result.
- */
-static inline rb_hrtime_t
-rb_hrtime_mul(rb_hrtime_t a, rb_hrtime_t b)
-{
- rb_hrtime_t c;
-
-#ifdef HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW
- if (__builtin_mul_overflow(a, b, &c))
- return RB_HRTIME_MAX;
-#else
- if (b != 0 && a > RB_HRTIME_MAX / b) /* overflow */
- return RB_HRTIME_MAX;
- c = a * b;
-#endif
- return c;
-}
-
-/*
- * add @a and @b with overflow check and return the
- * (clamped to RB_HRTIME_MAX) result.
- */
-static inline rb_hrtime_t
-rb_hrtime_add(rb_hrtime_t a, rb_hrtime_t b)
-{
- rb_hrtime_t c;
-
-#ifdef HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
- if (__builtin_add_overflow(a, b, &c))
- return RB_HRTIME_MAX;
-#else
- c = a + b;
- if (c < a) /* overflow */
- return RB_HRTIME_MAX;
-#endif
- return c;
-}
-
-/*
- * convert a timeval struct to rb_hrtime_t, clamping at RB_HRTIME_MAX
- */
-static inline rb_hrtime_t
-rb_timeval2hrtime(const struct timeval *tv)
-{
- rb_hrtime_t s = rb_hrtime_mul((rb_hrtime_t)tv->tv_sec, RB_HRTIME_PER_SEC);
- rb_hrtime_t u = rb_hrtime_mul((rb_hrtime_t)tv->tv_usec, RB_HRTIME_PER_USEC);
-
- return rb_hrtime_add(s, u);
-}
-
-/*
- * convert a timespec struct to rb_hrtime_t, clamping at RB_HRTIME_MAX
- */
-static inline rb_hrtime_t
-rb_timespec2hrtime(const struct timespec *ts)
-{
- rb_hrtime_t s = rb_hrtime_mul((rb_hrtime_t)ts->tv_sec, RB_HRTIME_PER_SEC);
-
- return rb_hrtime_add(s, (rb_hrtime_t)ts->tv_nsec);
-}
-
-/*
- * convert a millisecond value to rb_hrtime_t, clamping at RB_HRTIME_MAX
- */
-static inline rb_hrtime_t
-rb_msec2hrtime(unsigned long msec)
-{
- return rb_hrtime_mul((rb_hrtime_t)msec, RB_HRTIME_PER_MSEC);
-}
-
-/*
- * convert a time_t value to rb_hrtime_t, clamping at RB_HRTIME_MAX
- * Negative values will be clamped at 0.
- */
-static inline rb_hrtime_t
-rb_sec2hrtime(time_t sec)
-{
- if (sec <= 0) return 0;
-
- return rb_hrtime_mul((rb_hrtime_t)sec, RB_HRTIME_PER_SEC);
-}
-
-/*
- * convert a rb_hrtime_t value to a timespec, suitable for calling
- * functions like ppoll(2) or kevent(2)
- */
-static inline struct timespec *
-rb_hrtime2timespec(struct timespec *ts, const rb_hrtime_t *hrt)
-{
- if (hrt) {
- ts->tv_sec = (time_t)(*hrt / RB_HRTIME_PER_SEC);
- ts->tv_nsec = (int32_t)(*hrt % RB_HRTIME_PER_SEC);
- return ts;
- }
- return 0;
-}
-
-/*
- * convert a rb_hrtime_t value to a timeval, suitable for calling
- * functions like select(2)
- */
-static inline struct timeval *
-rb_hrtime2timeval(struct timeval *tv, const rb_hrtime_t *hrt)
-{
- if (hrt) {
- tv->tv_sec = (time_t)(*hrt / RB_HRTIME_PER_SEC);
- tv->tv_usec = (int32_t)((*hrt % RB_HRTIME_PER_SEC)/RB_HRTIME_PER_USEC);
-
- return tv;
- }
- return 0;
-}
-#endif /* RB_HRTIME_H */
diff --git a/ia64.s b/ia64.s
new file mode 100644
index 0000000000..1087105585
--- /dev/null
+++ b/ia64.s
@@ -0,0 +1,42 @@
+// rb_ia64_flushrs and rb_ia64_bsp is written in IA64 assembly language
+// because Intel Compiler for IA64 doesn't support inline assembly.
+//
+// This file is based on following C program compiled by gcc.
+//
+// void rb_ia64_flushrs(void) { __builtin_ia64_flushrs(); }
+// void *rb_ia64_bsp(void) { return __builtin_ia64_bsp(); }
+//
+// Note that rb_ia64_flushrs and rb_ia64_bsp works in its own stack frame.
+// It's because BSP is updated by br.call/brl.call (not alloc instruction).
+// So rb_ia64_flushrs flushes stack frames including caller's one.
+// rb_ia64_bsp returns the address next to caller's register stack frame.
+//
+// See also
+// Intel Itanium Architecture Software Developer's Manual
+// Volume 2: System Architecture.
+//
+ .file "ia64.c"
+ .text
+ .align 16
+ .global rb_ia64_flushrs#
+ .proc rb_ia64_flushrs#
+rb_ia64_flushrs:
+ .prologue
+ .body
+ flushrs
+ ;;
+ nop.i 0
+ br.ret.sptk.many b0
+ .endp rb_ia64_flushrs#
+ .align 16
+ .global rb_ia64_bsp#
+ .proc rb_ia64_bsp#
+rb_ia64_bsp:
+ .prologue
+ .body
+ nop.m 0
+ ;;
+ mov r8 = ar.bsp
+ br.ret.sptk.many b0
+ .endp rb_ia64_bsp#
+ .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-13)"
diff --git a/id_table.c b/id_table.c
index f566582479..74c9e756a0 100644
--- a/id_table.c
+++ b/id_table.c
@@ -267,28 +267,6 @@ rb_id_table_delete(struct rb_id_table *tbl, ID id)
}
void
-rb_id_table_foreach_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data)
-{
- int i, capa = tbl->capa;
-
- for (i=0; i<capa; i++) {
- if (ITEM_KEY_ISSET(tbl, i)) {
- const id_key_t key = ITEM_GET_KEY(tbl, i);
- enum rb_id_table_iterator_result ret = (*func)(Qundef, tbl->items[i].val, data);
- assert(key != 0);
-
- if (ret == ID_TABLE_REPLACE) {
- VALUE val = tbl->items[i].val;
- ret = (*replace)(NULL, &val, data, TRUE);
- tbl->items[i].val = val;
- }
- else if (ret == ID_TABLE_STOP)
- return;
- }
- }
-}
-
-void
rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data)
{
int i, capa = tbl->capa;
diff --git a/id_table.h b/id_table.h
index abd9eb5f38..b10b4ac164 100644
--- a/id_table.h
+++ b/id_table.h
@@ -9,7 +9,6 @@ enum rb_id_table_iterator_result {
ID_TABLE_CONTINUE = ST_CONTINUE,
ID_TABLE_STOP = ST_STOP,
ID_TABLE_DELETE = ST_DELETE,
- ID_TABLE_REPLACE = ST_REPLACE,
ID_TABLE_ITERATOR_RESULT_END
};
@@ -24,11 +23,9 @@ int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
int rb_id_table_delete(struct rb_id_table *tbl, ID id);
-typedef enum rb_id_table_iterator_result rb_id_table_update_callback_func_t(ID *id, VALUE *val, void *data, int existing);
typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
-void rb_id_table_foreach_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data);
void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
#endif /* RUBY_ID_TABLE_H */
diff --git a/include/ruby/assert.h b/include/ruby/assert.h
deleted file mode 100644
index d19d8e4e32..0000000000
--- a/include/ruby/assert.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef RUBY_ASSERT_H
-#define RUBY_ASSERT_H
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-NORETURN(void rb_assert_failure(const char *, int, const char *, const char *));
-#ifdef RUBY_FUNCTION_NAME_STRING
-# define RUBY_ASSERT_FAIL(expr) \
- rb_assert_failure(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, expr)
-#else
-# define RUBY_ASSERT_FAIL(expr) \
- rb_assert_failure(__FILE__, __LINE__, NULL, expr)
-#endif
-#define RUBY_ASSERT_MESG(expr, mesg) \
- ((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg))
-#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P
-# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
- ((RUBY_DEBUG+0) ? RUBY_ASSERT_MESG((expr), mesg) : \
- __builtin_choose_expr( \
- __builtin_constant_p(cond), \
- __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \
- RUBY_ASSERT_MESG(!(cond) || (expr), mesg)))
-#else
-# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
- RUBY_ASSERT_MESG(!((RUBY_DEBUG+0) || (cond)) || (expr), mesg)
-#endif
-#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN((!RUBY_NDEBUG+0), expr, #expr)
-#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr)
-#define RUBY_ASSERT_ALWAYS(expr) RUBY_ASSERT_MESG_WHEN(TRUE, expr, #expr)
-
-#ifndef RUBY_DEBUG
-# define RUBY_DEBUG 0
-#endif
-#ifndef RUBY_NDEBUG
-# ifdef NDEBUG
-# define RUBY_NDEBUG 1
-# else
-# define RUBY_NDEBUG 0
-# endif
-#endif
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif
diff --git a/include/ruby/backward.h b/include/ruby/backward.h
index 863edf0ed5..76bd162cb2 100644
--- a/include/ruby/backward.h
+++ b/include/ruby/backward.h
@@ -12,6 +12,10 @@ struct RClass {
#define DECLARE_DEPRECATED_FEATURE(ver, func) \
NORETURN(ERRORFUNC(("deprecated since "#ver), DEPRECATED(void func(void))))
+/* complex.c */
+DECLARE_DEPRECATED_FEATURE(2.2, rb_complex_set_real);
+DECLARE_DEPRECATED_FEATURE(2.2, rb_complex_set_imag);
+
/* eval.c */
DECLARE_DEPRECATED_FEATURE(2.2, rb_disable_super);
DECLARE_DEPRECATED_FEATURE(2.2, rb_enable_super);
@@ -34,30 +38,19 @@ DECLARE_DEPRECATED_FEATURE(2.2, rb_frame_pop);
#define DECLARE_DEPRECATED_INTERNAL_FEATURE(func) \
NORETURN(ERRORFUNC(("deprecated internal function"), DEPRECATED(void func(void))))
-/* eval.c */
-NORETURN(ERRORFUNC(("internal function"), void rb_frozen_class_p(VALUE)));
-DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_exec_end_proc);
-
/* error.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error);
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error_with_enc);
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error_append);
-/* gc.c */
-DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_gc_call_finalizer_at_exit);
-
-/* signal.c */
-DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_trap_exit);
-
/* struct.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_struct_ptr);
-/* thread.c */
-DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_clear_trace_func);
-
/* variable.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_generic_ivar_table);
-NORETURN(ERRORFUNC(("internal function"), VALUE rb_mod_const_missing(VALUE, VALUE)));
+
+/* vm.c */
+DEPRECATED(int rb_frame_method_id_and_class(ID *idp, VALUE *klassp));
/* from version.c */
#ifndef RUBY_SHOW_COPYRIGHT_TO_DIE
diff --git a/include/ruby/backward/cxxanyargs.hpp b/include/ruby/backward/cxxanyargs.hpp
deleted file mode 100644
index 3585f678b8..0000000000
--- a/include/ruby/backward/cxxanyargs.hpp
+++ /dev/null
@@ -1,439 +0,0 @@
-#ifndef RUBY_BACKWARD_CXXANYARGS_HPP // -*- C++ -*-
-#define RUBY_BACKWARD_CXXANYARGS_HPP
-/// @file
-/// @brief Provides old prototypes for C++ programs.
-/// @author \@shyouhei
-/// @copyright This file is a part of the programming language Ruby.
-/// Permission is hereby granted, to either redistribute and/or
-/// modify this file, provided that the conditions mentioned in the
-/// file COPYING are met. Consult the file for details.
-/// @note DO NOT MODERNIZE THIS FILE! As the file name implies it is
-/// meant to be a backwards compatibility shim. Please stick to
-/// C++ 98 and never use newer features, like `constexpr`.
-
-/// @brief The main namespace.
-/// @note The name "ruby" might already be taken, but that must not be a
-/// problem because namespaces are allowed to reopen.
-namespace ruby {
-
-/// @brief Backwards compatibility layer.
-namespace backward {
-
-/// @brief Provides ANYARGS deprecation warnings.
-///
-/// In C, ANYARGS means there is no function prototype. Literally anything,
-/// even including nothing, can be a valid ANYARGS. So passing a correctly
-/// prototyped function pointer to an ANYARGS-ed function parameter is valid,
-/// at the same time passing an ANYARGS-ed function pointer to a granular typed
-/// function parameter is also valid. However on the other hand in C++,
-/// ANYARGS doesn't actually mean any number of arguments. C++'s ANYARGS means
-/// _variadic_ number of arguments. This is incompatible with ordinal, correct
-/// function prototypes.
-///
-/// Luckily, function prototypes being distinct each other means they can be
-/// overloaded. We can provide a compatibility layer for older Ruby APIs which
-/// used to have ANYARGS. This namespace includes such attempts.
-namespace cxxanyargs {
-
-/// @brief ANYARGS-ed function type.
-typedef VALUE type(ANYARGS);
-
-/// @brief ANYARGS-ed function type, void variant.
-typedef void void_type(ANYARGS);
-
-/// @brief ANYARGS-ed function type, int variant.
-typedef int int_type(ANYARGS);
-
-/// @name Hooking global variables
-/// @{
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Define a function-backended global variable.
-/// @param[in] q Name of the variable.
-/// @param[in] w Getter function.
-/// @param[in] e Setter function.
-/// @note Both functions can be nullptr.
-/// @see rb_define_hooked_variable()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_define_virtual_variable(const char *q, type *w, void_type *e)
-{
- rb_gvar_getter_t *r = reinterpret_cast<rb_gvar_getter_t*>(w);
- rb_gvar_setter_t *t = reinterpret_cast<rb_gvar_setter_t*>(e);
- ::rb_define_virtual_variable(q, r, t);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Define a function-backended global variable.
-/// @param[in] q Name of the variable.
-/// @param[in] w Getter function.
-/// @param[in] e Setter function.
-/// @note Both functions can be nullptr.
-/// @see rb_define_hooked_variable()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_define_virtual_variable(const char *q, rb_gvar_getter_t *w, void_type *e)
-{
- rb_gvar_setter_t *t = reinterpret_cast<rb_gvar_setter_t*>(e);
- ::rb_define_virtual_variable(q, w, t);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Define a function-backended global variable.
-/// @param[in] q Name of the variable.
-/// @param[in] w Getter function.
-/// @param[in] e Setter function.
-/// @note Both functions can be nullptr.
-/// @see rb_define_hooked_variable()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_define_virtual_variable(const char *q, type *w, rb_gvar_setter_t *e)
-{
- rb_gvar_getter_t *r = reinterpret_cast<rb_gvar_getter_t*>(w);
- ::rb_define_virtual_variable(q, r, e);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Define a function-backended global variable.
-/// @param[in] q Name of the variable.
-/// @param[in] w Variable storage.
-/// @param[in] e Getter function.
-/// @param[in] r Setter function.
-/// @note Both functions can be nullptr.
-/// @see rb_define_virtual_variable()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_define_hooked_variable(const char *q, VALUE *w, type *e, void_type *r)
-{
- rb_gvar_getter_t *t = reinterpret_cast<rb_gvar_getter_t*>(e);
- rb_gvar_setter_t *y = reinterpret_cast<rb_gvar_setter_t*>(r);
- ::rb_define_hooked_variable(q, w, t, y);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Define a function-backended global variable.
-/// @param[in] q Name of the variable.
-/// @param[in] w Variable storage.
-/// @param[in] e Getter function.
-/// @param[in] r Setter function.
-/// @note Both functions can be nullptr.
-/// @see rb_define_virtual_variable()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_define_hooked_variable(const char *q, VALUE *w, rb_gvar_getter_t *e, void_type *r)
-{
- rb_gvar_setter_t *y = reinterpret_cast<rb_gvar_setter_t*>(r);
- ::rb_define_hooked_variable(q, w, e, y);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Define a function-backended global variable.
-/// @param[in] q Name of the variable.
-/// @param[in] w Variable storage.
-/// @param[in] e Getter function.
-/// @param[in] r Setter function.
-/// @note Both functions can be nullptr.
-/// @see rb_define_virtual_variable()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_define_hooked_variable(const char *q, VALUE *w, type *e, rb_gvar_setter_t *r)
-{
- rb_gvar_getter_t *t = reinterpret_cast<rb_gvar_getter_t*>(e);
- ::rb_define_hooked_variable(q, w, t, r);
-}
-
-/// @}
-/// @name Exceptions and tag jumps
-/// @{
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Old way to implement iterators.
-/// @param[in] q A function that can yield.
-/// @param[in] w Passed to `q`.
-/// @param[in] e What is to be yielded.
-/// @param[in] r Passed to `e`.
-/// @return The return value of `q`.
-/// @note `e` can be nullptr.
-/// @deprecated This function is obsolated since long before 2.x era. Do not
-/// use it any longer. rb_block_call() is provided instead.
-inline VALUE
-rb_iterate(VALUE(*q)(VALUE), VALUE w, type *e, VALUE r)
-{
- rb_block_call_func_t t = reinterpret_cast<rb_block_call_func_t>(e);
- return ::rb_iterate(q, w, t, r);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Call a method with a block.
-/// @param[in] q The self.
-/// @param[in] w The method.
-/// @param[in] e The # of elems of `r`
-/// @param[in] r The arguments.
-/// @param[in] t What is to be yielded.
-/// @param[in] y Passed to `t`
-/// @return Return value of `q#w(*r,&t)`
-/// @note 't' can be nullptr.
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_block_call(VALUE q, ID w, int e, const VALUE *r, type *t, VALUE y)
-{
- rb_block_call_func_t u = reinterpret_cast<rb_block_call_func_t>(t);
- return ::rb_block_call(q, w, e, r, u, y);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief An equivalent of `rescue` clause.
-/// @param[in] q A function that can raise.
-/// @param[in] w Passed to `q`.
-/// @param[in] e A function that cleans-up.
-/// @param[in] r Passed to `e`.
-/// @return The return value of `q` if no exception occurs, or the return
-/// value of `e` if otherwise.
-/// @note `e` can be nullptr.
-/// @see rb_ensure()
-/// @see rb_rescue2()
-/// @see rb_protect()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_rescue(type *q, VALUE w, type *e, VALUE r)
-{
- typedef VALUE func1_t(VALUE);
- typedef VALUE func2_t(VALUE, VALUE);
- func1_t *t = reinterpret_cast<func1_t*>(q);
- func2_t *y = reinterpret_cast<func2_t*>(e);
- return ::rb_rescue(t, w, y, r);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief An equivalent of `rescue` clause.
-/// @param[in] q A function that can raise.
-/// @param[in] w Passed to `q`.
-/// @param[in] e A function that cleans-up.
-/// @param[in] r Passed to `e`.
-/// @param[in] ... 0-terminated list of subclass of @ref rb_eException.
-/// @return The return value of `q` if no exception occurs, or the return
-/// value of `e` if otherwise.
-/// @note `e` can be nullptr.
-/// @see rb_ensure()
-/// @see rb_rescue()
-/// @see rb_protect()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_rescue2(type *q, VALUE w, type *e, VALUE r, ...)
-{
- typedef VALUE func1_t(VALUE);
- typedef VALUE func2_t(VALUE, VALUE);
- func1_t *t = reinterpret_cast<func1_t*>(q);
- func2_t *y = reinterpret_cast<func2_t*>(e);
- va_list ap;
- va_start(ap, r);
- VALUE ret = ::rb_vrescue2(t, w, y, r, ap);
- va_end(ap);
- return ret;
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief An equivalent of `ensure` clause.
-/// @param[in] q A function that can raise.
-/// @param[in] w Passed to `q`.
-/// @param[in] e A function that ensures.
-/// @param[in] r Passed to `e`.
-/// @return The return value of `q`.
-/// @note It makes no sense to pass nullptr to `e`.
-/// @see rb_rescue()
-/// @see rb_rescue2()
-/// @see rb_protect()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_ensure(type *q, VALUE w, type *e, VALUE r)
-{
- typedef VALUE func1_t(VALUE);
- func1_t *t = reinterpret_cast<func1_t*>(q);
- func1_t *y = reinterpret_cast<func1_t*>(e);
- return ::rb_ensure(t, w, y, r);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief An equivalent of `Kernel#catch`.
-/// @param[in] q The "tag" string.
-/// @param[in] w A function that can throw.
-/// @param[in] e Passed to `w`.
-/// @return What was thrown.
-/// @note `q` can be a nullptr but makes no sense to pass nullptr to`w`.
-/// @see rb_block_call()
-/// @see rb_protect()
-/// @see rb_rb_catch_obj()
-/// @see rb_rescue()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_catch(const char *q, type *w, VALUE e)
-{
- rb_block_call_func_t r = reinterpret_cast<rb_block_call_func_t>(w);
- return ::rb_catch(q, r, e);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief An equivalent of `Kernel#catch`.
-/// @param[in] q The "tag" object.
-/// @param[in] w A function that can throw.
-/// @param[in] e Passed to `w`.
-/// @return What was thrown.
-/// @note It makes no sense to pass nullptr to`w`.
-/// @see rb_block_call()
-/// @see rb_protect()
-/// @see rb_rb_catch_obj()
-/// @see rb_rescue()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_catch_obj(VALUE q, type *w, VALUE e)
-{
- rb_block_call_func_t r = reinterpret_cast<rb_block_call_func_t>(w);
- return ::rb_catch_obj(q, r, e);
-}
-
-/// @}
-/// @name Procs, Fibers and Threads
-/// @{
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Creates a @ref rb_cFiber instance.
-/// @param[in] q The fiber body.
-/// @param[in] w Passed to `q`.
-/// @return What was allocated.
-/// @note It makes no sense to pass nullptr to`q`.
-/// @see rb_proc_new()
-/// @see rb_thread_creatr()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_fiber_new(type *q, VALUE w)
-{
- rb_block_call_func_t e = reinterpret_cast<rb_block_call_func_t>(q);
- return ::rb_fiber_new(e, w);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Creates a @ref rb_cProc instance.
-/// @param[in] q The proc body.
-/// @param[in] w Passed to `q`.
-/// @return What was allocated.
-/// @note It makes no sense to pass nullptr to`q`.
-/// @see rb_fiber_new()
-/// @see rb_thread_creatr()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_proc_new(type *q, VALUE w)
-{
- rb_block_call_func_t e = reinterpret_cast<rb_block_call_func_t>(q);
- return ::rb_proc_new(e, w);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Creates a @ref rb_cThread instance.
-/// @param[in] q The thread body.
-/// @param[in] w Passed to `q`.
-/// @return What was allocated.
-/// @note It makes no sense to pass nullptr to`q`.
-/// @see rb_proc_new()
-/// @see rb_fiber_new()
-/// @deprecated Use glanular typed overload instead.
-inline VALUE
-rb_thread_create(type *q, void *w)
-{
- typedef VALUE ptr_t(void*);
- ptr_t *e = reinterpret_cast<ptr_t*>(q);
- return ::rb_thread_create(e, w);
-}
-
-/// @}
-/// @name Hash and st_table
-/// @{
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Iteration over the given table.
-/// @param[in] q A table to scan.
-/// @param[in] w A function to iterate.
-/// @param[in] e Passed to `w`.
-/// @retval 0 Always returns 0.
-/// @note It makes no sense to pass nullptr to`w`.
-/// @see st_foreach_check()
-/// @see rb_hash_foreach()
-/// @deprecated Use glanular typed overload instead.
-inline int
-st_foreach(st_table *q, int_type *w, st_data_t e)
-{
- st_foreach_callback_func *r =
- reinterpret_cast<st_foreach_callback_func*>(w);
- return ::st_foreach(q, r, e);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Iteration over the given table.
-/// @param[in] q A table to scan.
-/// @param[in] w A function to iterate.
-/// @param[in] e Passed to `w`.
-/// @retval 0 Successful end of iteration.
-/// @retval 1 Element removed during traversing.
-/// @note It makes no sense to pass nullptr to`w`.
-/// @see st_foreach()
-/// @deprecated Use glanular typed overload instead.
-inline int
-st_foreach_check(st_table *q, int_type *w, st_data_t e, st_data_t)
-{
- st_foreach_check_callback_func *t =
- reinterpret_cast<st_foreach_check_callback_func*>(w);
- return ::st_foreach_check(q, t, e, 0);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Iteration over the given table.
-/// @param[in] q A table to scan.
-/// @param[in] w A function to iterate.
-/// @param[in] e Passed to `w`.
-/// @note It makes no sense to pass nullptr to`w`.
-/// @see st_foreach_check()
-/// @deprecated Use glanular typed overload instead.
-inline void
-st_foreach_safe(st_table *q, int_type *w, st_data_t e)
-{
- st_foreach_callback_func *r =
- reinterpret_cast<st_foreach_callback_func*>(w);
- ::st_foreach_safe(q, r, e);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Iteration over the given hash.
-/// @param[in] q A hash to scan.
-/// @param[in] w A function to iterate.
-/// @param[in] e Passed to `w`.
-/// @note It makes no sense to pass nullptr to`w`.
-/// @see st_foreach()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_hash_foreach(VALUE q, int_type *w, VALUE e)
-{
- st_foreach_callback_func *r =
- reinterpret_cast<st_foreach_callback_func*>(w);
- ::rb_hash_foreach(q, r, e);
-}
-
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Iteration over each instance variable of the object.
-/// @param[in] q An object.
-/// @param[in] w A function to iterate.
-/// @param[in] e Passed to `w`.
-/// @note It makes no sense to pass nullptr to`w`.
-/// @see st_foreach()
-/// @deprecated Use glanular typed overload instead.
-inline void
-rb_ivar_foreach(VALUE q, int_type *w, VALUE e)
-{
- st_foreach_callback_func *r =
- reinterpret_cast<st_foreach_callback_func*>(w);
- ::rb_ivar_foreach(q, r, e);
-}
-
-/// @}
-}}}
-
-using namespace ruby::backward::cxxanyargs;
-#endif // RUBY_BACKWARD_CXXANYARGS_HPP
diff --git a/include/ruby/debug.h b/include/ruby/debug.h
index 8a831e61ab..0456c73b9c 100644
--- a/include/ruby/debug.h
+++ b/include/ruby/debug.h
@@ -83,11 +83,7 @@ VALUE rb_tracearg_return_value(rb_trace_arg_t *trace_arg);
VALUE rb_tracearg_raised_exception(rb_trace_arg_t *trace_arg);
VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg);
-/*
- * Postponed Job API
- * rb_postponed_job_register and rb_postponed_job_register_one are
- * async-signal-safe and used via SIGPROF by the "stackprof" RubyGem
- */
+/* Postponed Job API */
typedef void (*rb_postponed_job_func_t)(void *arg);
int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data);
int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data);
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index dc71d65100..2c72a7cb8a 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -29,6 +29,10 @@ extern "C" {
#ifndef PUREFUNC
# define PUREFUNC(x) x
#endif
+#define NORETURN_STYLE_NEW 1
+#ifndef NORETURN
+# define NORETURN(x) x
+#endif
#ifndef DEPRECATED
# define DEPRECATED(x) x
#endif
@@ -38,9 +42,6 @@ extern "C" {
#ifndef DEPRECATED_TYPE
# define DEPRECATED_TYPE(mesg, decl) decl
#endif
-#ifndef RUBY_CXX_DEPRECATED
-# define RUBY_CXX_DEPRECATED(mesg) /* nothing */
-#endif
#ifndef NOINLINE
# define NOINLINE(x) x
#endif
@@ -92,24 +93,9 @@ extern "C" {
#define RB_UNLIKELY(x) (x)
#endif /* __GNUC__ >= 3 */
-/*
- cold attribute for code layout improvements
- RUBY_FUNC_ATTRIBUTE not used because MSVC does not like nested func macros
- */
-#if defined(__clang__) || GCC_VERSION_SINCE(4, 3, 0)
-#define COLDFUNC __attribute__((cold))
-#else
-#define COLDFUNC
-#endif
-
#ifdef __GNUC__
-#if defined __MINGW_PRINTF_FORMAT
-#define PRINTF_ARGS(decl, string_index, first_to_check) \
- decl __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
-#else
#define PRINTF_ARGS(decl, string_index, first_to_check) \
decl __attribute__((format(printf, string_index, first_to_check)))
-#endif
#else
#define PRINTF_ARGS(decl, string_index, first_to_check) decl
#endif
@@ -153,9 +139,6 @@ extern "C" {
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
-#ifdef HAVE_STDALIGN_H
-# include <stdalign.h>
-#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@@ -217,116 +200,16 @@ RUBY_SYMBOL_EXPORT_BEGIN
#if GCC_VERSION_SINCE(4,3,0)
# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((alloc_size params))
-#elif defined(__has_attribute)
-# if __has_attribute(alloc_size)
-# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__((__alloc_size__ params))
-# endif
-#endif
-#ifndef RUBY_ATTR_ALLOC_SIZE
+#else
# define RUBY_ATTR_ALLOC_SIZE(params)
#endif
-#ifdef __has_attribute
-# if __has_attribute(malloc)
-# define RUBY_ATTR_MALLOC __attribute__((__malloc__))
-# endif
-#endif
-#ifndef RUBY_ATTR_MALLOC
-# define RUBY_ATTR_MALLOC
-#endif
-
-#ifdef __has_attribute
-# if __has_attribute(returns_nonnull)
-# define RUBY_ATTR_RETURNS_NONNULL __attribute__((__returns_nonnull__))
-# endif
-#endif
-#ifndef RUBY_ATTR_RETURNS_NONNULL
-# define RUBY_ATTR_RETURNS_NONNULL
-#endif
-
-void *ruby_xmalloc(size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1));
-void *ruby_xmalloc2(size_t,size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1,2));
-void *ruby_xcalloc(size_t,size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1,2));
-void *ruby_xrealloc(void*,size_t) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
-void *ruby_xrealloc2(void*,size_t,size_t) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2,3));
-void ruby_xfree(void*);
-
-#ifndef USE_GC_MALLOC_OBJ_INFO_DETAILS
-#define USE_GC_MALLOC_OBJ_INFO_DETAILS 0
-#endif
-
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
-
-void *ruby_xmalloc_body(size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1));
-void *ruby_xmalloc2_body(size_t,size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1,2));
-void *ruby_xcalloc_body(size_t,size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1,2));
-void *ruby_xrealloc_body(void*,size_t) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
-void *ruby_xrealloc2_body(void*,size_t,size_t) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2,3));
-
-#define ruby_xmalloc(s1) ruby_xmalloc_with_location(s1, __FILE__, __LINE__)
-#define ruby_xmalloc2(s1, s2) ruby_xmalloc2_with_location(s1, s2, __FILE__, __LINE__)
-#define ruby_xcalloc(s1, s2) ruby_xcalloc_with_location(s1, s2, __FILE__, __LINE__)
-#define ruby_xrealloc(ptr, s1) ruby_xrealloc_with_location(ptr, s1, __FILE__, __LINE__)
-#define ruby_xrealloc2(ptr, s1, s2) ruby_xrealloc2_with_location(ptr, s1, s2, __FILE__, __LINE__)
-
-extern const char *ruby_malloc_info_file;
-extern int ruby_malloc_info_line;
-
-static inline void *
-ruby_xmalloc_with_location(size_t s, const char *file, int line)
-{
- void *ptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- ptr = ruby_xmalloc_body(s);
- ruby_malloc_info_file = NULL;
- return ptr;
-}
-
-static inline void *
-ruby_xmalloc2_with_location(size_t s1, size_t s2, const char *file, int line)
-{
- void *ptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- ptr = ruby_xmalloc2_body(s1, s2);
- ruby_malloc_info_file = NULL;
- return ptr;
-}
-
-static inline void *
-ruby_xcalloc_with_location(size_t s1, size_t s2, const char *file, int line)
-{
- void *ptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- ptr = ruby_xcalloc_body(s1, s2);
- ruby_malloc_info_file = NULL;
- return ptr;
-}
-
-static inline void *
-ruby_xrealloc_with_location(void *ptr, size_t s, const char *file, int line)
-{
- void *rptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- rptr = ruby_xrealloc_body(ptr, s);
- ruby_malloc_info_file = NULL;
- return rptr;
-}
-
-static inline void *
-ruby_xrealloc2_with_location(void *ptr, size_t s1, size_t s2, const char *file, int line)
-{
- void *rptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- rptr = ruby_xrealloc2_body(ptr, s1, s2);
- ruby_malloc_info_file = NULL;
- return rptr;
-}
-#endif
+void *xmalloc(size_t) RUBY_ATTR_ALLOC_SIZE((1));
+void *xmalloc2(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
+void *xcalloc(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
+void *xrealloc(void*,size_t) RUBY_ATTR_ALLOC_SIZE((2));
+void *xrealloc2(void*,size_t,size_t) RUBY_ATTR_ALLOC_SIZE((2,3));
+void xfree(void*);
#define STRINGIZE(expr) STRINGIZE0(expr)
#ifndef STRINGIZE0
@@ -391,17 +274,6 @@ ruby_xrealloc2_with_location(void *ptr, size_t s1, size_t s2, const char *file,
#define RUBY_FUNC_EXPORTED
#endif
-/* These macros are used for functions which are exported only for MJIT
- and NOT ensured to be exported in future versions. */
-#define MJIT_FUNC_EXPORTED RUBY_FUNC_EXPORTED
-#define MJIT_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN
-#define MJIT_SYMBOL_EXPORT_END RUBY_SYMBOL_EXPORT_END
-
-#if defined(MJIT_HEADER) && defined(_MSC_VER)
-# undef MJIT_FUNC_EXPORTED
-# define MJIT_FUNC_EXPORTED static
-#endif
-
#ifndef RUBY_EXTERN
#define RUBY_EXTERN extern
#endif
@@ -427,6 +299,10 @@ ruby_xrealloc2_with_location(void *ptr, size_t s1, size_t s2, const char *file,
#if defined(__sparc)
void rb_sparc_flush_register_windows(void);
# define FLUSH_REGISTER_WINDOWS rb_sparc_flush_register_windows()
+#elif defined(__ia64)
+void *rb_ia64_bsp(void);
+void rb_ia64_flushrs(void);
+# define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
#else
# define FLUSH_REGISTER_WINDOWS ((void)0)
#endif
@@ -478,15 +354,11 @@ void rb_sparc_flush_register_windows(void);
#define RUBY_ALIAS_FUNCTION(prot, name, args) \
RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
#endif
-#ifndef RUBY_FUNC_NONNULL
-#define RUBY_FUNC_NONNULL(n, x) x
-#endif
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
defined(__powerpc64__) || \
- defined(__aarch64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# else
@@ -504,31 +376,6 @@ void rb_sparc_flush_register_windows(void);
# endif
#endif
-#ifndef RUBY_ALIGNAS
-#define RUBY_ALIGNAS(x) /* x */
-#endif
-
-#ifdef RUBY_ALIGNOF
-/* OK, take that definition */
-#elif defined(__cplusplus) && (__cplusplus >= 201103L)
-#define RUBY_ALIGNOF alignof
-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
-#define RUBY_ALIGNOF _Alignof
-#else
-#define RUBY_ALIGNOF(type) ((size_t)offsetof(struct { char f1; type f2; }, f2))
-#endif
-
-#define NORETURN_STYLE_NEW 1
-#ifdef NORETURN
-/* OK, take that definition */
-#elif defined(__cplusplus) && (__cplusplus >= 201103L)
-#define NORETURN(x) [[ noreturn ]] x
-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
-#define NORETURN(x) _Noreturn x
-#else
-#define NORETURN(x) x
-#endif
-
RUBY_SYMBOL_EXPORT_END
#if defined(__cplusplus)
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index 93939ee7db..e6ceb19cdf 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -12,10 +12,6 @@
#ifndef RUBY_ENCODING_H
#define RUBY_ENCODING_H 1
-#ifdef RUBY_INTERNAL_H
-#error "Include this file before internal.h"
-#endif
-
#if defined(__cplusplus)
extern "C" {
#if 0
@@ -122,9 +118,7 @@ PUREFUNC(int rb_enc_dummy_p(rb_encoding *enc));
PUREFUNC(int rb_enc_to_index(rb_encoding *enc));
int rb_enc_get_index(VALUE obj);
void rb_enc_set_index(VALUE obj, int encindex);
-int rb_enc_capable(VALUE obj);
int rb_enc_find_index(const char *name);
-int rb_enc_alias(const char *alias, const char *orig);
int rb_to_encoding_index(VALUE);
rb_encoding *rb_to_encoding(VALUE);
rb_encoding *rb_find_encoding(VALUE);
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 2f60fb569e..a711b86115 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -21,10 +21,6 @@ extern "C" {
#endif
#endif
-#if !defined(__has_attribute)
-#define __has_attribute(x) 0
-#endif
-
#include "ruby/defines.h"
#ifdef RUBY_EXTCONF_H
#include RUBY_EXTCONF_H
@@ -38,15 +34,6 @@ extern "C" {
#include "ruby/st.h"
-/* On mswin, MJIT header transformation can't be used since cl.exe can't output
- preprocessed output preserving macros. So this `MJIT_STATIC` is needed
- to force non-static function to static on MJIT header to avoid symbol conflict. */
-#ifdef MJIT_HEADER
-# define MJIT_STATIC static
-#else
-# define MJIT_STATIC
-#endif
-
RUBY_SYMBOL_EXPORT_BEGIN
/*
@@ -57,7 +44,7 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define UNLIMITED_ARGUMENTS (-1)
/* array.c */
-void rb_mem_clear(VALUE*, long);
+void rb_mem_clear(register VALUE*, register long);
VALUE rb_assoc_new(VALUE, VALUE);
VALUE rb_check_array_type(VALUE);
VALUE rb_ary_new(void);
@@ -192,24 +179,7 @@ VALUE rb_complex_raw(VALUE, VALUE);
VALUE rb_complex_new(VALUE, VALUE);
#define rb_complex_new1(x) rb_complex_new((x), INT2FIX(0))
#define rb_complex_new2(x,y) rb_complex_new((x), (y))
-VALUE rb_complex_new_polar(VALUE abs, VALUE arg);
-DEPRECATED_BY(rb_complex_new_polar, VALUE rb_complex_polar(VALUE abs, VALUE arg));
-VALUE rb_complex_real(VALUE z);
-VALUE rb_complex_imag(VALUE z);
-VALUE rb_complex_plus(VALUE x, VALUE y);
-VALUE rb_complex_minus(VALUE x, VALUE y);
-VALUE rb_complex_mul(VALUE x, VALUE y);
-VALUE rb_complex_div(VALUE x, VALUE y);
-VALUE rb_complex_uminus(VALUE z);
-VALUE rb_complex_conjugate(VALUE z);
-VALUE rb_complex_abs(VALUE z);
-VALUE rb_complex_arg(VALUE z);
-VALUE rb_complex_pow(VALUE base, VALUE exp);
-VALUE rb_dbl_complex_new(double real, double imag);
-#define rb_complex_add rb_complex_plus
-#define rb_complex_sub rb_complex_minus
-#define rb_complex_nagate rb_complex_uminus
-
+VALUE rb_complex_polar(VALUE, VALUE);
VALUE rb_Complex(VALUE, VALUE);
#define rb_Complex1(x) rb_Complex((x), INT2FIX(0))
#define rb_Complex2(x,y) rb_Complex((x), (y))
@@ -233,6 +203,7 @@ VALUE rb_class_protected_instance_methods(int, const VALUE*, VALUE);
VALUE rb_class_private_instance_methods(int, const VALUE*, VALUE);
VALUE rb_obj_singleton_methods(int, const VALUE*, VALUE);
void rb_define_method_id(VALUE, ID, VALUE (*)(ANYARGS), int);
+void rb_frozen_class_p(VALUE);
void rb_undef(VALUE, ID);
void rb_define_protected_method(VALUE, const char*, VALUE (*)(ANYARGS), int);
void rb_define_private_method(VALUE, const char*, VALUE (*)(ANYARGS), int);
@@ -242,11 +213,9 @@ VALUE rb_singleton_class(VALUE);
int rb_cmpint(VALUE, VALUE, VALUE);
NORETURN(void rb_cmperr(VALUE, VALUE));
/* cont.c */
-VALUE rb_fiber_new(rb_block_call_func_t, VALUE);
+VALUE rb_fiber_new(VALUE (*)(ANYARGS), VALUE);
VALUE rb_fiber_resume(VALUE fib, int argc, const VALUE *argv);
-VALUE rb_fiber_resume_kw(VALUE fib, int argc, const VALUE *argv, int kw_splat);
VALUE rb_fiber_yield(int argc, const VALUE *argv);
-VALUE rb_fiber_yield_kw(int argc, const VALUE *argv, int kw_splat);
VALUE rb_fiber_current(void);
VALUE rb_fiber_alive_p(VALUE);
/* enum.c */
@@ -255,36 +224,18 @@ VALUE rb_enum_values_pack(int, const VALUE*);
VALUE rb_enumeratorize(VALUE, VALUE, int, const VALUE *);
typedef VALUE rb_enumerator_size_func(VALUE, VALUE, VALUE);
VALUE rb_enumeratorize_with_size(VALUE, VALUE, int, const VALUE *, rb_enumerator_size_func *);
-VALUE rb_enumeratorize_with_size_kw(VALUE, VALUE, int, const VALUE *, rb_enumerator_size_func *, int);
#ifndef RUBY_EXPORT
#define rb_enumeratorize_with_size(obj, id, argc, argv, size_fn) \
rb_enumeratorize_with_size(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn))
-#define rb_enumeratorize_with_size_kw(obj, id, argc, argv, size_fn, kw_splat) \
- rb_enumeratorize_with_size_kw(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn), kw_splat)
#endif
#define SIZED_ENUMERATOR(obj, argc, argv, size_fn) \
rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()), \
(argc), (argv), (size_fn))
-#define SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) \
- rb_enumeratorize_with_size_kw((obj), ID2SYM(rb_frame_this_func()), \
- (argc), (argv), (size_fn), (kw_splat))
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn) do { \
if (!rb_block_given_p()) \
return SIZED_ENUMERATOR(obj, argc, argv, size_fn); \
} while (0)
-#define RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) do { \
- if (!rb_block_given_p()) \
- return SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat); \
- } while (0)
#define RETURN_ENUMERATOR(obj, argc, argv) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0)
-#define RETURN_ENUMERATOR_KW(obj, argc, argv, kw_splat) RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, 0, kw_splat)
-typedef struct {
- VALUE begin;
- VALUE end;
- VALUE step;
- int exclude_end;
-} rb_arithmetic_sequence_components_t;
-int rb_arithmetic_sequence_extract(VALUE, rb_arithmetic_sequence_components_t *);
/* error.c */
VALUE rb_exc_new(VALUE, const char*, long);
VALUE rb_exc_new_cstr(VALUE, const char*);
@@ -295,7 +246,6 @@ PRINTF_ARGS(NORETURN(void rb_loaderror(const char*, ...)), 1, 2);
PRINTF_ARGS(NORETURN(void rb_loaderror_with_path(VALUE path, const char*, ...)), 2, 3);
PRINTF_ARGS(NORETURN(void rb_name_error(ID, const char*, ...)), 2, 3);
PRINTF_ARGS(NORETURN(void rb_name_error_str(VALUE, const char*, ...)), 2, 3);
-PRINTF_ARGS(NORETURN(void rb_frozen_error_raise(VALUE, const char*, ...)), 2, 3);
NORETURN(void rb_invalid_str(const char*, const char*));
NORETURN(void rb_error_frozen(const char*));
NORETURN(void rb_error_frozen_object(VALUE));
@@ -304,12 +254,14 @@ void rb_check_frozen(VALUE);
void rb_check_trusted(VALUE);
#define rb_check_frozen_internal(obj) do { \
VALUE frozen_obj = (obj); \
- if (RB_UNLIKELY(RB_OBJ_FROZEN(frozen_obj))) { \
+ if (OBJ_FROZEN(frozen_obj)) { \
rb_error_frozen_object(frozen_obj); \
} \
} while (0)
+#define rb_check_trusted_internal(obj) ((void) 0)
#ifdef __GNUC__
#define rb_check_frozen(obj) __extension__({rb_check_frozen_internal(obj);})
+#define rb_check_trusted(obj) __extension__({rb_check_trusted_internal(obj);})
#else
static inline void
rb_check_frozen_inline(VALUE obj)
@@ -320,7 +272,7 @@ rb_check_frozen_inline(VALUE obj)
static inline void
rb_check_trusted_inline(VALUE obj)
{
- rb_check_trusted(obj);
+ rb_check_trusted_internal(obj);
}
#define rb_check_trusted(obj) rb_check_trusted_inline(obj)
#endif
@@ -334,9 +286,8 @@ void rb_check_copyable(VALUE obj, VALUE orig);
int rb_sourceline(void);
const char *rb_sourcefile(void);
VALUE rb_check_funcall(VALUE, ID, int, const VALUE*);
-VALUE rb_check_funcall_kw(VALUE, ID, int, const VALUE*, int);
-NORETURN(MJIT_STATIC void rb_error_arity(int, int, int));
+NORETURN(void rb_error_arity(int, int, int));
static inline int
rb_check_arity(int argc, int min, int max)
{
@@ -384,15 +335,7 @@ void rb_fd_set(int, rb_fdset_t *);
void rb_w32_fd_copy(rb_fdset_t *, const fd_set *, int);
#define rb_fd_dup(d, s) rb_w32_fd_dup((d), (s))
void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src);
-static inline int
-rb_fd_select(int n, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout)
-{
- return rb_w32_select(n,
- rfds ? rfds->fdset : NULL,
- wfds ? wfds->fdset : NULL,
- efds ? efds->fdset : NULL,
- timeout);
-}
+#define rb_fd_select(n, rfds, wfds, efds, timeout) rb_w32_select((n), (rfds) ? ((rb_fdset_t*)(rfds))->fdset : NULL, (wfds) ? ((rb_fdset_t*)(wfds))->fdset : NULL, (efds) ? ((rb_fdset_t*)(efds))->fdset: NULL, (timeout))
#define rb_fd_resize(n, f) ((void)(f))
#define rb_fd_ptr(f) ((f)->fdset)
@@ -435,12 +378,11 @@ void rb_attr(VALUE,ID,int,int,int);
int rb_method_boundp(VALUE, ID, int);
int rb_method_basic_definition_p(VALUE, ID);
VALUE rb_eval_cmd(VALUE, VALUE, int);
-VALUE rb_eval_cmd_kw(VALUE, VALUE, int);
int rb_obj_respond_to(VALUE, ID, int);
int rb_respond_to(VALUE, ID);
-NORETURN(VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker));
+NORETURN(VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj));
#if !defined(RUBY_EXPORT) && defined(_WIN32)
-RUBY_EXTERN VALUE (*const rb_f_notimplement_)(int, const VALUE *, VALUE, VALUE marker);
+RUBY_EXTERN VALUE (*const rb_f_notimplement_)(int, const VALUE *, VALUE);
#define rb_f_notimplement (*rb_f_notimplement_)
#endif
NORETURN(void rb_interrupt(void));
@@ -458,33 +400,27 @@ int rb_provided(const char*);
int rb_feature_provided(const char *, const char **);
void rb_provide(const char*);
VALUE rb_f_require(VALUE, VALUE);
-VALUE rb_require_safe(VALUE, int); /* Remove in 3.0 */
-VALUE rb_require_string(VALUE);
+VALUE rb_require_safe(VALUE, int);
void rb_obj_call_init(VALUE, int, const VALUE*);
-void rb_obj_call_init_kw(VALUE, int, const VALUE*, int);
VALUE rb_class_new_instance(int, const VALUE*, VALUE);
-VALUE rb_class_new_instance_kw(int, const VALUE*, VALUE, int);
VALUE rb_block_proc(void);
VALUE rb_block_lambda(void);
-VALUE rb_proc_new(rb_block_call_func_t, VALUE);
+VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
VALUE rb_obj_is_proc(VALUE);
VALUE rb_proc_call(VALUE, VALUE);
-VALUE rb_proc_call_kw(VALUE, VALUE, int);
VALUE rb_proc_call_with_block(VALUE, int argc, const VALUE *argv, VALUE);
-VALUE rb_proc_call_with_block_kw(VALUE, int argc, const VALUE *argv, VALUE, int);
int rb_proc_arity(VALUE);
VALUE rb_proc_lambda_p(VALUE);
VALUE rb_binding_new(void);
VALUE rb_obj_method(VALUE, VALUE);
VALUE rb_obj_is_method(VALUE);
VALUE rb_method_call(int, const VALUE*, VALUE);
-VALUE rb_method_call_kw(int, const VALUE*, VALUE, int);
VALUE rb_method_call_with_block(int, const VALUE *, VALUE, VALUE);
-VALUE rb_method_call_with_block_kw(int, const VALUE *, VALUE, VALUE, int);
int rb_mod_method_arity(VALUE, ID);
int rb_obj_method_arity(VALUE, ID);
VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*);
void rb_set_end_proc(void (*)(VALUE), VALUE);
+void rb_exec_end_proc(void);
void rb_thread_schedule(void);
void rb_thread_wait_fd(int);
int rb_thread_fd_writable(int);
@@ -498,7 +434,7 @@ VALUE rb_thread_wakeup(VALUE);
VALUE rb_thread_wakeup_alive(VALUE);
VALUE rb_thread_run(VALUE);
VALUE rb_thread_kill(VALUE);
-VALUE rb_thread_create(VALUE (*)(void *), void*);
+VALUE rb_thread_create(VALUE (*)(ANYARGS), void*);
int rb_thread_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
void rb_thread_wait_for(struct timeval);
VALUE rb_thread_current(void);
@@ -519,29 +455,27 @@ VALUE rb_file_expand_path(VALUE, VALUE);
VALUE rb_file_s_absolute_path(int, const VALUE *);
VALUE rb_file_absolute_path(VALUE, VALUE);
VALUE rb_file_dirname(VALUE fname);
-int rb_find_file_ext_safe(VALUE*, const char* const*, int); /* Remove in 3.0 */
-VALUE rb_find_file_safe(VALUE, int); /* Remove in 3.0 */
+int rb_find_file_ext_safe(VALUE*, const char* const*, int);
+VALUE rb_find_file_safe(VALUE, int);
int rb_find_file_ext(VALUE*, const char* const*);
VALUE rb_find_file(VALUE);
VALUE rb_file_directory_p(VALUE,VALUE);
VALUE rb_str_encode_ospath(VALUE);
int rb_is_absolute_path(const char *);
/* gc.c */
-COLDFUNC NORETURN(void rb_memerror(void));
+NORETURN(void rb_memerror(void));
PUREFUNC(int rb_during_gc(void));
void rb_gc_mark_locations(const VALUE*, const VALUE*);
void rb_mark_tbl(struct st_table*);
-void rb_mark_tbl_no_pin(struct st_table*);
void rb_mark_set(struct st_table*);
void rb_mark_hash(struct st_table*);
-void rb_gc_update_tbl_refs(st_table *ptr);
void rb_gc_mark_maybe(VALUE);
void rb_gc_mark(VALUE);
-void rb_gc_mark_movable(VALUE);
-VALUE rb_gc_location(VALUE);
void rb_gc_force_recycle(VALUE);
void rb_gc(void);
void rb_gc_copy_finalizer(VALUE,VALUE);
+void rb_gc_finalize_deferred(void);
+void rb_gc_call_finalizer_at_exit(void);
VALUE rb_gc_enable(void);
VALUE rb_gc_disable(void);
VALUE rb_gc_start(void);
@@ -552,10 +486,9 @@ size_t rb_gc_stat(VALUE);
VALUE rb_gc_latest_gc_info(VALUE);
void rb_gc_adjust_memory_usage(ssize_t);
/* hash.c */
-void rb_st_foreach_safe(struct st_table *, int (*)(st_data_t, st_data_t, st_data_t), st_data_t);
-#define st_foreach_safe rb_st_foreach_safe
+void st_foreach_safe(struct st_table *, int (*)(ANYARGS), st_data_t);
VALUE rb_check_hash_type(VALUE);
-void rb_hash_foreach(VALUE, int (*)(VALUE, VALUE, VALUE), VALUE);
+void rb_hash_foreach(VALUE, int (*)(ANYARGS), VALUE);
VALUE rb_hash(VALUE);
VALUE rb_hash_new(void);
VALUE rb_hash_dup(VALUE);
@@ -569,15 +502,13 @@ VALUE rb_hash_clear(VALUE);
VALUE rb_hash_delete_if(VALUE);
VALUE rb_hash_delete(VALUE,VALUE);
VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone);
-void rb_hash_bulk_insert(long, const VALUE *, VALUE);
typedef VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value);
VALUE rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func);
-struct st_table *rb_hash_tbl(VALUE, const char *file, int line);
+struct st_table *rb_hash_tbl(VALUE);
int rb_path_check(const char*);
int rb_env_path_tainted(void);
VALUE rb_env_clear(void);
VALUE rb_hash_size(VALUE);
-void rb_hash_free(VALUE);
/* io.c */
#define rb_defout rb_stdout
RUBY_EXTERN VALUE rb_fs;
@@ -650,7 +581,6 @@ VALUE rb_obj_trust(VALUE);
VALUE rb_obj_freeze(VALUE);
PUREFUNC(VALUE rb_obj_frozen_p(VALUE));
VALUE rb_obj_id(VALUE);
-VALUE rb_memory_id(VALUE);
VALUE rb_obj_class(VALUE);
PUREFUNC(VALUE rb_class_real(VALUE));
PUREFUNC(VALUE rb_class_inherited_p(VALUE, VALUE));
@@ -741,6 +671,8 @@ VALUE rb_f_kill(int, const VALUE*);
#define posix_signal ruby_posix_signal
RETSIGTYPE (*posix_signal(int, RETSIGTYPE (*)(int)))(int);
#endif
+void rb_trap_exit(void);
+void rb_trap_exec(void);
const char *ruby_signal_name(int);
void ruby_default_signal(int);
/* sprintf.c */
@@ -825,7 +757,7 @@ VALUE rb_str_replace(VALUE, VALUE);
VALUE rb_str_inspect(VALUE);
VALUE rb_str_dump(VALUE);
VALUE rb_str_split(VALUE, const char*);
-rb_gvar_setter_t rb_str_setter;
+void rb_str_setter(VALUE, ID, VALUE*);
VALUE rb_str_intern(VALUE);
VALUE rb_sym_to_s(VALUE);
long rb_str_strlen(VALUE);
@@ -952,7 +884,6 @@ VALUE rb_mutex_unlock(VALUE mutex);
VALUE rb_mutex_sleep(VALUE self, VALUE timeout);
VALUE rb_mutex_synchronize(VALUE mutex, VALUE (*func)(VALUE arg), VALUE arg);
/* time.c */
-struct timespec;
void rb_timespec_now(struct timespec *);
VALUE rb_time_new(time_t, long);
VALUE rb_time_nano_new(time_t, long);
@@ -961,7 +892,6 @@ VALUE rb_time_num_new(VALUE, VALUE);
struct timeval rb_time_interval(VALUE num);
struct timeval rb_time_timeval(VALUE time);
struct timespec rb_time_timespec(VALUE time);
-struct timespec rb_time_timespec_interval(VALUE num);
VALUE rb_time_utc_offset(VALUE time);
/* variable.c */
VALUE rb_mod_name(VALUE);
@@ -971,6 +901,7 @@ void rb_set_class_path(VALUE, VALUE, const char*);
void rb_set_class_path_string(VALUE, VALUE, VALUE);
VALUE rb_path_to_class(VALUE);
VALUE rb_path2class(const char*);
+void rb_name_class(VALUE, ID);
VALUE rb_class_name(VALUE);
VALUE rb_autoload_load(VALUE, ID);
VALUE rb_autoload_p(VALUE, ID);
@@ -983,7 +914,7 @@ void rb_free_generic_ivar(VALUE);
VALUE rb_ivar_get(VALUE, ID);
VALUE rb_ivar_set(VALUE, ID, VALUE);
VALUE rb_ivar_defined(VALUE, ID);
-void rb_ivar_foreach(VALUE, int (*)(ID, VALUE, st_data_t), st_data_t);
+void rb_ivar_foreach(VALUE, int (*)(ANYARGS), st_data_t);
st_index_t rb_ivar_count(VALUE);
VALUE rb_attr_get(VALUE, ID);
VALUE rb_obj_instance_variables(VALUE);
@@ -1001,9 +932,7 @@ VALUE rb_const_get_at(VALUE, ID);
VALUE rb_const_get_from(VALUE, ID);
void rb_const_set(VALUE, ID, VALUE);
VALUE rb_const_remove(VALUE, ID);
-#if 0 /* EXPERIMENTAL: remove if no problem */
NORETURN(VALUE rb_mod_const_missing(VALUE,VALUE));
-#endif
VALUE rb_cvar_defined(VALUE, ID);
void rb_cvar_set(VALUE, ID, VALUE);
VALUE rb_cvar_get(VALUE, ID);
@@ -1014,7 +943,6 @@ VALUE rb_mod_class_variables(int, const VALUE*, VALUE);
VALUE rb_mod_remove_cvar(VALUE, VALUE);
ID rb_frame_callee(void);
-int rb_frame_method_id_and_class(ID *idp, VALUE *klassp);
VALUE rb_str_succ(VALUE);
VALUE rb_time_succ(VALUE);
VALUE rb_make_backtrace(void);
@@ -1027,204 +955,6 @@ RUBY_SYMBOL_EXPORT_END
{ /* satisfy cc-mode */
#endif
} /* extern "C" { */
-extern "C++" {
-#endif
-
-#if defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
-# define rb_f_notimplement_p(f) __builtin_types_compatible_p(__typeof__(f),__typeof__(rb_f_notimplement))
-#else
-# define rb_f_notimplement_p(f) 0
-#endif
-
-#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && !defined(_WIN32) && !defined(__CYGWIN__)
-#if defined(__has_attribute) && __has_attribute(transparent_union) && __has_attribute(unused) && __has_attribute(weakref) && __has_attribute(nonnull)
-#define RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
- __attribute__((__unused__,__weakref__(#def),__nonnull__ nonnull))static void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity);
-#endif
-#endif
-
-#if defined(RB_METHOD_DEFINITION_DECL_C) || defined(__cplusplus)
-#ifndef RB_METHOD_DEFINITION_DECL_C
-#define RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
- static inline void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity) \
- { \
- def(RB_UNWRAP_MACRO vars,(VALUE(*)(ANYARGS))(func),arity); \
- }
-#endif
-
-#define RB_UNWRAP_MACRO(...) __VA_ARGS__
-
-#ifdef __cplusplus
-#define RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) template <int Arity> struct def##_tmpl {};
-#define RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity) \
- template <> struct def##_tmpl<arity> { \
- static void define(RB_UNWRAP_MACRO decl, VALUE (*func)funcargs) {::defname(RB_UNWRAP_MACRO vars, func, arity);} \
- static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, reinterpret_cast<VALUE(*)funcargs>(func), arity);} \
- };
-#else
-#define RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) /* nothing */
-#define RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity) /* nothing */
-#endif
-#define RB_METHOD_DEFINITION_DECL_1(def,nonnull,defname,arity,decl,vars,funcargs) \
- RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
- RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity)
-
-#define RB_METHOD_DEFINITION_DECL(def,nonnull,decl,vars) \
-RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##0 ,0 ,decl,vars,(VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##1 ,1 ,decl,vars,(VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##2 ,2 ,decl,vars,(VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##3 ,3 ,decl,vars,(VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##4 ,4 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##5 ,5 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##6 ,6 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##7 ,7 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##8 ,8 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##9 ,9 ,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##10,10,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##11,11,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##12,12,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##13,13,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##14,14,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##15,15,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_M3(def,nonnull,def##m3,decl,vars) \
-RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##m2,-2,decl,vars,(VALUE,VALUE)) \
-RB_METHOD_DEFINITION_DECL_M1(def,nonnull,def##m1,decl,vars) /* END */
-#ifdef __cplusplus
-#define RB_METHOD_DEFINITION_DECL_M1(def,nonnull,defname,decl,vars) \
- RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,VALUE*,VALUE)) \
- RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE)) \
- RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE,VALUE)) \
- RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(...)) \
- template <> struct def##_tmpl<-1> { \
- static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
- static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
- static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
- static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \
- };
-#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) /* nothing */
-#else
-#define RB_METHOD_DEFINITION_DECL_M1(def,nonnull,defname,decl,vars) \
- RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,union{VALUE*x;const VALUE*y;}__attribute__((__transparent_union__)),VALUE))
-#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) \
- RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,())
-#endif
-
-#endif
-
-#ifdef RB_METHOD_DEFINITION_DECL
-
-RB_METHOD_DEFINITION_DECL(rb_define_method_id, (3), (VALUE klass, ID name), (klass, name))
-#ifdef __cplusplus
-#define rb_define_method_id(m, n, f, a) rb_define_method_id_tmpl<a>::define(m, n, f)
-#else
-#define rb_define_method_id_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_method_id15,rb_define_method_idm3)
-#define rb_define_method_id_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_method_id14,rb_define_method_id_choose_prototype15(n))
-#define rb_define_method_id_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_method_id13,rb_define_method_id_choose_prototype14(n))
-#define rb_define_method_id_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_method_id12,rb_define_method_id_choose_prototype13(n))
-#define rb_define_method_id_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_method_id11,rb_define_method_id_choose_prototype12(n))
-#define rb_define_method_id_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_method_id10,rb_define_method_id_choose_prototype11(n))
-#define rb_define_method_id_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_method_id9, rb_define_method_id_choose_prototype10(n))
-#define rb_define_method_id_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_method_id8, rb_define_method_id_choose_prototype9(n))
-#define rb_define_method_id_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_method_id7, rb_define_method_id_choose_prototype8(n))
-#define rb_define_method_id_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_method_id6, rb_define_method_id_choose_prototype7(n))
-#define rb_define_method_id_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_method_id5, rb_define_method_id_choose_prototype6(n))
-#define rb_define_method_id_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_method_id4, rb_define_method_id_choose_prototype5(n))
-#define rb_define_method_id_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_method_id3, rb_define_method_id_choose_prototype4(n))
-#define rb_define_method_id_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_method_id2, rb_define_method_id_choose_prototype3(n))
-#define rb_define_method_id_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_method_id1, rb_define_method_id_choose_prototype2(n))
-#define rb_define_method_id_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_method_id0, rb_define_method_id_choose_prototype1(n))
-#define rb_define_method_id_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_method_idm1,rb_define_method_id_choose_prototype0(n))
-#define rb_define_method_id_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_method_idm2,rb_define_method_id_choose_prototypem1(n))
-#define rb_define_method_id_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_method_idm3,rb_define_method_id_choose_prototypem2(n))
-#define rb_define_method_id(klass, mid, func, arity) rb_define_method_id_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
-#endif
-
-RB_METHOD_DEFINITION_DECL(rb_define_protected_method, (2,3), (VALUE klass, const char *name), (klass, name))
-#ifdef __cplusplus
-#define rb_define_protected_method(m, n, f, a) rb_define_protected_method_tmpl<a>::define(m, n, f)
-#else
-#define rb_define_protected_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_protected_method15,rb_define_protected_methodm3)
-#define rb_define_protected_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_protected_method14,rb_define_protected_method_choose_prototype15(n))
-#define rb_define_protected_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_protected_method13,rb_define_protected_method_choose_prototype14(n))
-#define rb_define_protected_method_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_protected_method12,rb_define_protected_method_choose_prototype13(n))
-#define rb_define_protected_method_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_protected_method11,rb_define_protected_method_choose_prototype12(n))
-#define rb_define_protected_method_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_protected_method10,rb_define_protected_method_choose_prototype11(n))
-#define rb_define_protected_method_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_protected_method9, rb_define_protected_method_choose_prototype10(n))
-#define rb_define_protected_method_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_protected_method8, rb_define_protected_method_choose_prototype9(n))
-#define rb_define_protected_method_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_protected_method7, rb_define_protected_method_choose_prototype8(n))
-#define rb_define_protected_method_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_protected_method6, rb_define_protected_method_choose_prototype7(n))
-#define rb_define_protected_method_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_protected_method5, rb_define_protected_method_choose_prototype6(n))
-#define rb_define_protected_method_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_protected_method4, rb_define_protected_method_choose_prototype5(n))
-#define rb_define_protected_method_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_protected_method3, rb_define_protected_method_choose_prototype4(n))
-#define rb_define_protected_method_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_protected_method2, rb_define_protected_method_choose_prototype3(n))
-#define rb_define_protected_method_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_protected_method1, rb_define_protected_method_choose_prototype2(n))
-#define rb_define_protected_method_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_protected_method0, rb_define_protected_method_choose_prototype1(n))
-#define rb_define_protected_method_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_protected_methodm1,rb_define_protected_method_choose_prototype0(n))
-#define rb_define_protected_method_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_protected_methodm2,rb_define_protected_method_choose_prototypem1(n))
-#define rb_define_protected_method_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_protected_methodm3,rb_define_protected_method_choose_prototypem2(n))
-#define rb_define_protected_method(klass, mid, func, arity) rb_define_protected_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
-#endif
-
-RB_METHOD_DEFINITION_DECL(rb_define_private_method, (2,3), (VALUE klass, const char *name), (klass, name))
-#ifdef __cplusplus
-#define rb_define_private_method(m, n, f, a) rb_define_private_method_tmpl<a>::define(m, n, f)
-#else
-#define rb_define_private_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_private_method15,rb_define_private_methodm3)
-#define rb_define_private_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_private_method14,rb_define_private_method_choose_prototype15(n))
-#define rb_define_private_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_private_method13,rb_define_private_method_choose_prototype14(n))
-#define rb_define_private_method_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_private_method12,rb_define_private_method_choose_prototype13(n))
-#define rb_define_private_method_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_private_method11,rb_define_private_method_choose_prototype12(n))
-#define rb_define_private_method_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_private_method10,rb_define_private_method_choose_prototype11(n))
-#define rb_define_private_method_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_private_method9, rb_define_private_method_choose_prototype10(n))
-#define rb_define_private_method_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_private_method8, rb_define_private_method_choose_prototype9(n))
-#define rb_define_private_method_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_private_method7, rb_define_private_method_choose_prototype8(n))
-#define rb_define_private_method_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_private_method6, rb_define_private_method_choose_prototype7(n))
-#define rb_define_private_method_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_private_method5, rb_define_private_method_choose_prototype6(n))
-#define rb_define_private_method_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_private_method4, rb_define_private_method_choose_prototype5(n))
-#define rb_define_private_method_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_private_method3, rb_define_private_method_choose_prototype4(n))
-#define rb_define_private_method_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_private_method2, rb_define_private_method_choose_prototype3(n))
-#define rb_define_private_method_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_private_method1, rb_define_private_method_choose_prototype2(n))
-#define rb_define_private_method_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_private_method0, rb_define_private_method_choose_prototype1(n))
-#define rb_define_private_method_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_private_methodm1,rb_define_private_method_choose_prototype0(n))
-#define rb_define_private_method_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_private_methodm2,rb_define_private_method_choose_prototypem1(n))
-#define rb_define_private_method_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_private_methodm3,rb_define_private_method_choose_prototypem2(n))
-#define rb_define_private_method(klass, mid, func, arity) rb_define_private_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
-#endif
-
-RB_METHOD_DEFINITION_DECL(rb_define_singleton_method, (2,3), (VALUE klass, const char *name), (klass, name))
-#ifdef __cplusplus
-#define rb_define_singleton_method(m, n, f, a) rb_define_singleton_method_tmpl<a>::define(m, n, f)
-#else
-#define rb_define_singleton_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_singleton_method15,rb_define_singleton_methodm3)
-#define rb_define_singleton_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_singleton_method14,rb_define_singleton_method_choose_prototype15(n))
-#define rb_define_singleton_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_singleton_method13,rb_define_singleton_method_choose_prototype14(n))
-#define rb_define_singleton_method_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_singleton_method12,rb_define_singleton_method_choose_prototype13(n))
-#define rb_define_singleton_method_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_singleton_method11,rb_define_singleton_method_choose_prototype12(n))
-#define rb_define_singleton_method_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_singleton_method10,rb_define_singleton_method_choose_prototype11(n))
-#define rb_define_singleton_method_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_singleton_method9, rb_define_singleton_method_choose_prototype10(n))
-#define rb_define_singleton_method_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_singleton_method8, rb_define_singleton_method_choose_prototype9(n))
-#define rb_define_singleton_method_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_singleton_method7, rb_define_singleton_method_choose_prototype8(n))
-#define rb_define_singleton_method_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_singleton_method6, rb_define_singleton_method_choose_prototype7(n))
-#define rb_define_singleton_method_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_singleton_method5, rb_define_singleton_method_choose_prototype6(n))
-#define rb_define_singleton_method_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_singleton_method4, rb_define_singleton_method_choose_prototype5(n))
-#define rb_define_singleton_method_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_singleton_method3, rb_define_singleton_method_choose_prototype4(n))
-#define rb_define_singleton_method_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_singleton_method2, rb_define_singleton_method_choose_prototype3(n))
-#define rb_define_singleton_method_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_singleton_method1, rb_define_singleton_method_choose_prototype2(n))
-#define rb_define_singleton_method_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_singleton_method0, rb_define_singleton_method_choose_prototype1(n))
-#define rb_define_singleton_method_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_singleton_methodm1,rb_define_singleton_method_choose_prototype0(n))
-#define rb_define_singleton_method_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_singleton_methodm2,rb_define_singleton_method_choose_prototypem1(n))
-#define rb_define_singleton_method_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_singleton_methodm3,rb_define_singleton_method_choose_prototypem2(n))
-#define rb_define_singleton_method(klass, mid, func, arity) rb_define_singleton_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
-#endif
-
-#endif
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C++" { */
#endif
#endif /* RUBY_INTERN_H */
diff --git a/include/ruby/io.h b/include/ruby/io.h
index 152f4ef763..60d6f6d32e 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -12,10 +12,6 @@
#ifndef RUBY_IO_H
#define RUBY_IO_H 1
-#ifdef RUBY_INTERNAL_H
-#error "Include this file before internal.h"
-#endif
-
#if defined(__cplusplus)
extern "C" {
#if 0
@@ -24,6 +20,7 @@ extern "C" {
#endif
#include <stdio.h>
+#include <errno.h>
#include "ruby/encoding.h"
#if defined(HAVE_STDIO_EXT_H)
@@ -31,7 +28,6 @@ extern "C" {
#endif
#include "ruby/config.h"
-#include <errno.h>
#if defined(HAVE_POLL)
# ifdef _AIX
# define reqevents events
@@ -101,8 +97,6 @@ typedef struct rb_io_t {
VALUE write_lock;
} rb_io_t;
-typedef struct rb_io_enc_t rb_io_enc_t;
-
#define HAVE_RB_IO_T 1
#define FMODE_READABLE 0x00000001
@@ -115,7 +109,6 @@ typedef struct rb_io_enc_t rb_io_enc_t;
#define FMODE_APPEND 0x00000040
#define FMODE_CREATE 0x00000080
/* #define FMODE_NOREVLOOKUP 0x00000100 */
-#define FMODE_EXCL 0x00000400
#define FMODE_TRUNC 0x00000800
#define FMODE_TEXTMODE 0x00001000
/* #define FMODE_PREP 0x00010000 */
@@ -155,7 +148,6 @@ int rb_io_wait_writable(int);
int rb_wait_for_single_fd(int fd, int events, struct timeval *tv);
void rb_io_set_nonblock(rb_io_t *fptr);
int rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p);
-void rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, int *fmode_p, rb_io_enc_t *convconfig_p);
ssize_t rb_io_bufwrite(VALUE io, const void *buf, size_t size);
/* compatibility for ruby 1.8 and older */
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
index 03657042ce..4b88c9ea07 100644
--- a/include/ruby/missing.h
+++ b/include/ruby/missing.h
@@ -136,7 +136,7 @@ RUBY_EXTERN double lgamma_r(double, int *);
RUBY_EXTERN double cbrt(double);
#endif
-#if !defined(INFINITY) || !defined(NAN)
+#if !defined(HAVE_INFINITY) || !defined(HAVE_NAN)
union bytesequence4_or_float {
unsigned char bytesequence[4];
float float_value;
@@ -147,18 +147,12 @@ union bytesequence4_or_float {
/** @internal */
RUBY_EXTERN const union bytesequence4_or_float rb_infinity;
# define INFINITY (rb_infinity.float_value)
-# define USE_RB_INFINITY 1
#endif
#ifndef NAN
/** @internal */
RUBY_EXTERN const union bytesequence4_or_float rb_nan;
# define NAN (rb_nan.float_value)
-# define USE_RB_NAN 1
-#endif
-
-#ifndef HUGE_VAL
-# define HUGE_VAL ((double)INFINITY)
#endif
#ifndef isinf
@@ -193,10 +187,6 @@ RUBY_EXTERN int isnan(double);
# endif
#endif
-#ifndef HAVE_NAN
-RUBY_EXTERN double nan(const char *);
-#endif
-
#ifndef HAVE_NEXTAFTER
RUBY_EXTERN double nextafter(double x, double y);
#endif
diff --git a/include/ruby/onigmo.h b/include/ruby/onigmo.h
index 6187b37dc3..385f2d6a8b 100644
--- a/include/ruby/onigmo.h
+++ b/include/ruby/onigmo.h
@@ -434,7 +434,7 @@ int onigenc_str_bytelen_null(OnigEncoding enc, const OnigUChar* p);
/* PART: regular expression */
/* config parameters */
-#define ONIG_NREGION 4
+#define ONIG_NREGION 10
#define ONIG_MAX_CAPTURE_GROUP_NUM 32767
#define ONIG_MAX_BACKREF_NUM 1000
#define ONIG_MAX_REPEAT_NUM 100000
@@ -701,7 +701,6 @@ ONIG_EXTERN const OnigSyntaxType* OnigDefaultSyntax;
#define ONIG_IS_CAPTURE_HISTORY_GROUP(r, i) \
((i) <= ONIG_MAX_CAPTURE_HISTORY_GROUP && (r)->list && (r)->list[i])
-#ifdef USE_CAPTURE_HISTORY
typedef struct OnigCaptureTreeNodeStruct {
int group; /* group number */
OnigPosition beg;
@@ -710,7 +709,6 @@ typedef struct OnigCaptureTreeNodeStruct {
int num_childs;
struct OnigCaptureTreeNodeStruct** childs;
} OnigCaptureTreeNode;
-#endif
/* match result region type */
struct re_registers {
@@ -718,10 +716,8 @@ struct re_registers {
int num_regs;
OnigPosition* beg;
OnigPosition* end;
-#ifdef USE_CAPTURE_HISTORY
/* extended */
OnigCaptureTreeNode* history_root; /* capture history tree root */
-#endif
};
/* capture tree traverse */
@@ -870,10 +866,8 @@ ONIG_EXTERN
int onig_number_of_captures(const OnigRegexType *reg);
ONIG_EXTERN
int onig_number_of_capture_histories(const OnigRegexType *reg);
-#ifdef USE_CAPTURE_HISTORY
ONIG_EXTERN
OnigCaptureTreeNode* onig_get_capture_tree(OnigRegion* region);
-#endif
ONIG_EXTERN
int onig_capture_tree_traverse(OnigRegion* region, int at, int(*callback_func)(int,OnigPosition,OnigPosition,int,int,void*), void* arg);
ONIG_EXTERN
diff --git a/include/ruby/re.h b/include/ruby/re.h
index 7102c7ace4..166f254aa5 100644
--- a/include/ruby/re.h
+++ b/include/ruby/re.h
@@ -36,8 +36,9 @@ struct rmatch_offset {
struct rmatch {
struct re_registers regs;
- struct rmatch_offset *char_offset;
+ int char_offset_updated;
int char_offset_num_allocated;
+ struct rmatch_offset *char_offset;
};
struct RMatch {
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index bd95d5b0b1..56b773b380 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -27,14 +27,6 @@ extern "C" {
#endif
#include "defines.h"
-#include "ruby/assert.h"
-
-/* For MinGW, we need __declspec(dllimport) for RUBY_EXTERN on MJIT.
- mswin's RUBY_EXTERN already has that. See also: win32/Makefile.sub */
-#if defined(MJIT_HEADER) && defined(_WIN32) && defined(__GNUC__)
-# undef RUBY_EXTERN
-# define RUBY_EXTERN extern __declspec(dllimport)
-#endif
#if defined(__cplusplus)
/* __builtin_choose_expr and __builtin_types_compatible aren't available
@@ -52,13 +44,6 @@ extern "C" {
# define ASSUME(x) ((void)(x))
# endif
#endif
-#ifndef UNREACHABLE_RETURN
-# ifdef UNREACHABLE
-# define UNREACHABLE_RETURN(val) UNREACHABLE
-# else
-# define UNREACHABLE_RETURN(val) return (val)
-# endif
-#endif
#ifndef UNREACHABLE
# define UNREACHABLE ((void)0) /* unreachable */
#endif
@@ -128,26 +113,12 @@ typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
#ifndef PRI_LONG_PREFIX
#define PRI_LONG_PREFIX "l"
#endif
-#ifndef PRI_SHORT_PREFIX
-#define PRI_SHORT_PREFIX "h"
-#endif
-#ifndef PRI_64_PREFIX
#if SIZEOF_LONG == 8
#define PRI_64_PREFIX PRI_LONG_PREFIX
#elif SIZEOF_LONG_LONG == 8
#define PRI_64_PREFIX PRI_LL_PREFIX
#endif
-#endif
-
-#ifndef PRIdPTR
-#define PRIdPTR PRI_PTR_PREFIX"d"
-#define PRIiPTR PRI_PTR_PREFIX"i"
-#define PRIoPTR PRI_PTR_PREFIX"o"
-#define PRIuPTR PRI_PTR_PREFIX"u"
-#define PRIxPTR PRI_PTR_PREFIX"x"
-#define PRIXPTR PRI_PTR_PREFIX"X"
-#endif
#define RUBY_PRI_VALUE_MARK "\v"
#if defined PRIdPTR && !defined PRI_VALUE_PREFIX
@@ -264,10 +235,10 @@ typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
#define RB_LONG2FIX(i) RB_INT2FIX(i)
#define LONG2FIX(i) RB_INT2FIX(i)
#define rb_fix_new(v) RB_INT2FIX(v)
-VALUE rb_int2inum(intptr_t);
+VALUE rb_int2inum(SIGNED_VALUE);
#define rb_int_new(v) rb_int2inum(v)
-VALUE rb_uint2inum(uintptr_t);
+VALUE rb_uint2inum(VALUE);
#define rb_uint_new(v) rb_uint2inum(v)
@@ -513,7 +484,6 @@ enum ruby_value_type {
RUBY_T_NODE = 0x1b,
RUBY_T_ICLASS = 0x1c,
RUBY_T_ZOMBIE = 0x1d,
- RUBY_T_MOVED = 0x1e,
RUBY_T_MASK = 0x1f
};
@@ -544,7 +514,6 @@ enum ruby_value_type {
#define T_UNDEF RUBY_T_UNDEF
#define T_NODE RUBY_T_NODE
#define T_ZOMBIE RUBY_T_ZOMBIE
-#define T_MOVED RUBY_T_MOVED
#define T_MASK RUBY_T_MASK
#define RB_BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & RUBY_T_MASK)
@@ -604,18 +573,21 @@ char *rb_string_value_cstr(volatile VALUE*);
#define StringValueCStr(v) rb_string_value_cstr(&(v))
void rb_check_safe_obj(VALUE);
-#define SafeStringValue(v) StringValue(v)
+#define SafeStringValue(v) do {\
+ StringValue(v);\
+ rb_check_safe_obj(v);\
+} while (0)
#if GCC_VERSION_SINCE(4,4,0)
-void rb_check_safe_str(VALUE) __attribute__((error("rb_check_safe_str() and Check_SafeStr() are obsolete; use StringValue() instead")));
+void rb_check_safe_str(VALUE) __attribute__((error("rb_check_safe_str() and Check_SafeStr() are obsolete; use SafeStringValue() instead")));
# define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
#else
-# define rb_check_safe_str(x) [<"rb_check_safe_str() is obsolete; use StringValue() instead">]
-# define Check_SafeStr(v) [<"Check_SafeStr() is obsolete; use StringValue() instead">]
+# define rb_check_safe_str(x) [<"rb_check_safe_str() is obsolete; use SafeStringValue() instead">]
+# define Check_SafeStr(v) [<"Check_SafeStr() is obsolete; use SafeStringValue() instead">]
#endif
VALUE rb_str_export(VALUE);
#define ExportStringValue(v) do {\
- StringValue(v);\
+ SafeStringValue(v);\
(v) = rb_str_export(v);\
} while (0)
VALUE rb_str_export_locale(VALUE);
@@ -624,9 +596,8 @@ VALUE rb_get_path(VALUE);
#define FilePathValue(v) (RB_GC_GUARD(v) = rb_get_path(v))
VALUE rb_get_path_no_checksafe(VALUE);
-#define FilePathStringValue(v) ((v) = rb_get_path(v))
+#define FilePathStringValue(v) ((v) = rb_get_path_no_checksafe(v))
-/* Remove in 3.0 */
#define RUBY_SAFE_LEVEL_MAX 1
void rb_secure(int);
int rb_safe_level(void);
@@ -773,8 +744,8 @@ rb_num2ll_inline(VALUE x)
double rb_num2dbl(VALUE);
#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
-VALUE rb_uint2big(uintptr_t);
-VALUE rb_int2big(intptr_t);
+VALUE rb_uint2big(VALUE);
+VALUE rb_int2big(SIGNED_VALUE);
VALUE rb_newobj(void);
VALUE rb_newobj_of(VALUE, VALUE);
@@ -846,7 +817,6 @@ enum ruby_fl_type {
RUBY_FL_FINALIZE = (1<<7),
RUBY_FL_TAINT = (1<<8),
RUBY_FL_UNTRUSTED = RUBY_FL_TAINT,
- RUBY_FL_SEEN_OBJ_ID = (1<<9),
RUBY_FL_EXIVAR = (1<<10),
RUBY_FL_FREEZE = (1<<11),
@@ -883,10 +853,14 @@ enum ruby_fl_type {
RUBY_FL_SINGLETON = RUBY_FL_USER0
};
-struct RUBY_ALIGNAS(SIZEOF_VALUE) RBasic {
+struct RBasic {
VALUE flags;
const VALUE klass;
-};
+}
+#ifdef __GNUC__
+ __attribute__((aligned(sizeof(VALUE))))
+#endif
+;
VALUE rb_obj_hide(VALUE obj);
VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change klass information */
@@ -905,15 +879,10 @@ VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change kl
#define RBASIC_CLASS(obj) (RBASIC(obj)->klass)
-#define RVALUE_EMBED_LEN_MAX RVALUE_EMBED_LEN_MAX
-enum ruby_rvalue_flags {
- RVALUE_EMBED_LEN_MAX = 3,
-};
-
#define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
#define ROBJECT_EMBED ROBJECT_EMBED
enum ruby_robject_flags {
- ROBJECT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
+ ROBJECT_EMBED_LEN_MAX = 3,
ROBJECT_EMBED = RUBY_FL_USER1,
ROBJECT_ENUM_END
@@ -979,12 +948,11 @@ enum ruby_rstring_flags {
RSTRING_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|
RUBY_FL_USER5|RUBY_FL_USER6),
RSTRING_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+2),
- RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*RVALUE_EMBED_LEN_MAX)/sizeof(char)-1),
+ RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*3)/sizeof(char)-1),
RSTRING_FSTR = RUBY_FL_USER17,
RSTRING_ENUM_END
};
-
struct RString {
struct RBasic basic;
union {
@@ -1020,31 +988,19 @@ struct RString {
((ptrvar) = RSTRING(str)->as.ary, (lenvar) = RSTRING_EMBED_LEN(str)) : \
((ptrvar) = RSTRING(str)->as.heap.ptr, (lenvar) = RSTRING(str)->as.heap.len))
-#ifndef USE_TRANSIENT_HEAP
-#define USE_TRANSIENT_HEAP 1
-#endif
-
enum ruby_rarray_flags {
- RARRAY_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
+ RARRAY_EMBED_LEN_MAX = 3,
RARRAY_EMBED_FLAG = RUBY_FL_USER1,
/* RUBY_FL_USER2 is for ELTS_SHARED */
RARRAY_EMBED_LEN_MASK = (RUBY_FL_USER4|RUBY_FL_USER3),
RARRAY_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+3),
-#if USE_TRANSIENT_HEAP
- RARRAY_TRANSIENT_FLAG = RUBY_FL_USER13,
-#define RARRAY_TRANSIENT_FLAG RARRAY_TRANSIENT_FLAG
-#else
-#define RARRAY_TRANSIENT_FLAG 0
-#endif
-
RARRAY_ENUM_END
};
#define RARRAY_EMBED_FLAG (VALUE)RARRAY_EMBED_FLAG
#define RARRAY_EMBED_LEN_MASK (VALUE)RARRAY_EMBED_LEN_MASK
#define RARRAY_EMBED_LEN_MAX RARRAY_EMBED_LEN_MAX
#define RARRAY_EMBED_LEN_SHIFT RARRAY_EMBED_LEN_SHIFT
-
struct RArray {
struct RBasic basic;
union {
@@ -1052,12 +1008,7 @@ struct RArray {
long len;
union {
long capa;
-#if defined(__clang__) /* <- clang++ is sane */ || \
- !defined(__cplusplus) /* <- C99 is sane */ || \
- (__cplusplus > 199711L) /* <- C++11 is sane */
- const
-#endif
- VALUE shared_root;
+ VALUE shared;
} aux;
const VALUE *ptr;
} heap;
@@ -1070,26 +1021,9 @@ struct RArray {
#define RARRAY_LEN(a) rb_array_len(a)
#define RARRAY_LENINT(ary) rb_long2int(RARRAY_LEN(ary))
#define RARRAY_CONST_PTR(a) rb_array_const_ptr(a)
-#define RARRAY_CONST_PTR_TRANSIENT(a) rb_array_const_ptr_transient(a)
-#if USE_TRANSIENT_HEAP
-#define RARRAY_TRANSIENT_P(ary) FL_TEST_RAW((ary), RARRAY_TRANSIENT_FLAG)
-#else
-#define RARRAY_TRANSIENT_P(ary) 0
-#endif
-
-#define RARRAY_PTR_USE_START_TRANSIENT(a) rb_array_ptr_use_start(a, 1)
-#define RARRAY_PTR_USE_END_TRANSIENT(a) rb_array_ptr_use_end(a, 1)
-
-#define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr) do { \
- const VALUE _ary = (ary); \
- VALUE *ptr_name = (VALUE *)RARRAY_PTR_USE_START_TRANSIENT(_ary); \
- expr; \
- RARRAY_PTR_USE_END_TRANSIENT(_ary); \
-} while (0)
-
-#define RARRAY_PTR_USE_START(a) rb_array_ptr_use_start(a, 0)
-#define RARRAY_PTR_USE_END(a) rb_array_ptr_use_end(a, 0)
+#define RARRAY_PTR_USE_START(a) ((VALUE *)RARRAY_CONST_PTR(a))
+#define RARRAY_PTR_USE_END(a) /* */
#define RARRAY_PTR_USE(ary, ptr_name, expr) do { \
const VALUE _ary = (ary); \
@@ -1098,13 +1032,12 @@ struct RArray {
RARRAY_PTR_USE_END(_ary); \
} while (0)
-#define RARRAY_AREF(a, i) (RARRAY_CONST_PTR_TRANSIENT(a)[i])
+#define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i])
#define RARRAY_ASET(a, i, v) do { \
const VALUE _ary = (a); \
- const VALUE _v = (v); \
- VALUE *ptr = (VALUE *)RARRAY_PTR_USE_START_TRANSIENT(_ary); \
- RB_OBJ_WRITE(_ary, &ptr[i], _v); \
- RARRAY_PTR_USE_END_TRANSIENT(_ary); \
+ VALUE *ptr = (VALUE *)RARRAY_PTR_USE_START(_ary); \
+ RB_OBJ_WRITE(_ary, &ptr[i], (v)); \
+ RARRAY_PTR_USE_END(_ary); \
} while (0)
#define RARRAY_PTR(a) ((VALUE *)RARRAY_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(ARRAY, a)))
@@ -1121,13 +1054,11 @@ struct RRegexp {
#define RREGEXP_SRC_LEN(r) RSTRING_LEN(RREGEXP(r)->src)
#define RREGEXP_SRC_END(r) RSTRING_END(RREGEXP(r)->src)
-/* RHash is defined at internal.h */
-size_t rb_hash_size_num(VALUE hash);
-
-#define RHASH_TBL(h) rb_hash_tbl(h, __FILE__, __LINE__)
+/* RHASH_TBL allocates st_table if not available. */
+#define RHASH_TBL(h) rb_hash_tbl(h)
#define RHASH_ITER_LEV(h) rb_hash_iter_lev(h)
#define RHASH_IFNONE(h) rb_hash_ifnone(h)
-#define RHASH_SIZE(h) rb_hash_size_num(h)
+#define RHASH_SIZE(h) NUM2SIZET(rb_hash_size(h))
#define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
#define RHASH_SET_IFNONE(h, ifnone) rb_hash_set_ifnone((VALUE)h, ifnone)
@@ -1136,6 +1067,9 @@ struct RFile {
struct rb_io_t *fptr;
};
+#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
+#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
+
struct RData {
struct RBasic basic;
void (*dmark)(void*);
@@ -1151,8 +1085,7 @@ struct rb_data_type_struct {
void (*dmark)(void*);
void (*dfree)(void*);
size_t (*dsize)(const void *);
- void (*dcompact)(void*);
- void *reserved[1]; /* For future extension.
+ void *reserved[2]; /* For future extension.
This array *must* be filled with ZERO. */
} function;
const rb_data_type_t *parent;
@@ -1263,7 +1196,6 @@ int rb_big_sign(VALUE);
#define RBIGNUM_NEGATIVE_P(b) (RBIGNUM_SIGN(b)==0)
#define R_CAST(st) (struct st*)
-#define RMOVED(obj) (R_CAST(RMoved)(obj))
#define RBASIC(obj) (R_CAST(RBasic)(obj))
#define ROBJECT(obj) (R_CAST(RObject)(obj))
#define RCLASS(obj) (R_CAST(RClass)(obj))
@@ -1282,7 +1214,6 @@ int rb_big_sign(VALUE);
#define FL_FINALIZE ((VALUE)RUBY_FL_FINALIZE)
#define FL_TAINT ((VALUE)RUBY_FL_TAINT)
#define FL_UNTRUSTED ((VALUE)RUBY_FL_UNTRUSTED)
-#define FL_SEEN_OBJ_ID ((VALUE)RUBY_FL_SEEN_OBJ_ID)
#define FL_EXIVAR ((VALUE)RUBY_FL_EXIVAR)
#define FL_FREEZE ((VALUE)RUBY_FL_FREEZE)
@@ -1307,7 +1238,7 @@ int rb_big_sign(VALUE);
#define FL_USER16 ((VALUE)RUBY_FL_USER16)
#define FL_USER17 ((VALUE)RUBY_FL_USER17)
#define FL_USER18 ((VALUE)RUBY_FL_USER18)
-#define FL_USER19 ((VALUE)(unsigned int)RUBY_FL_USER19)
+#define FL_USER19 ((VALUE)RUBY_FL_USER19)
#define RB_SPECIAL_CONST_P(x) (RB_IMMEDIATE_P(x) || !RB_TEST(x))
#define SPECIAL_CONST_P(x) RB_SPECIAL_CONST_P(x)
@@ -1643,7 +1574,6 @@ rb_num2char_inline(VALUE x)
#define LONG2NUM(x) RB_LONG2NUM(x)
#define ULONG2NUM(x) RB_ULONG2NUM(x)
-#define USHORT2NUM(x) RB_INT2FIX(x)
#define NUM2CHR(x) RB_NUM2CHR(x)
#define CHR2FIX(x) RB_CHR2FIX(x)
@@ -1666,23 +1596,7 @@ rb_num2char_inline(VALUE x)
#define ZALLOC(type) RB_ZALLOC(type)
#define REALLOC_N(var,type,n) RB_REALLOC_N(var,type,n)
-#if GCC_VERSION_BEFORE(4,9,5)
-/* GCC 4.9.2 reportedly has this feature and is broken.
- * The function is not officially documented below.
- * Seems we should not use it.
- * https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Other-Builtins.html#Other-Builtins */
-# undef HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
-#endif
-
-#if defined(HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN) && defined(RUBY_ALIGNOF)
-/* I don't know why but __builtin_alloca_with_align's second argument
- takes bits rather than bytes. */
-#define ALLOCA_N(type, n) \
- (type*)__builtin_alloca_with_align((sizeof(type)*(n)), \
- RUBY_ALIGNOF(type) * CHAR_BIT)
-#else
#define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
-#endif
void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2));
void *rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len,size_t count) RUBY_ATTR_ALLOC_SIZE((2,3));
@@ -1736,11 +1650,11 @@ rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
#else
# define RUBY_ALLOCV_LIMIT 1024
# define RB_ALLOCV(v, n) ((n) < RUBY_ALLOCV_LIMIT ? \
- ((v) = 0, alloca(n)) : \
+ (RB_GC_GUARD(v) = 0, alloca(n)) : \
rb_alloc_tmp_buffer(&(v), (n)))
# define RB_ALLOCV_N(type, v, n) \
((type*)(((size_t)(n) < RUBY_ALLOCV_LIMIT / sizeof(type)) ? \
- ((v) = 0, alloca((size_t)(n) * sizeof(type))) : \
+ (RB_GC_GUARD(v) = 0, alloca((size_t)(n) * sizeof(type))) : \
rb_alloc_tmp_buffer2(&(v), (long)(n), sizeof(type))))
#endif
#define RB_ALLOCV_END(v) rb_free_tmp_buffer(&(v))
@@ -1753,15 +1667,6 @@ rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(size_t)(n))
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(size_t)(n))
#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(size_t)(n))
-#ifdef __GLIBC__
-static inline void *
-ruby_nonempty_memcpy(void *dest, const void *src, size_t n)
-{
- /* if nothing to be copied, src may be NULL */
- return (n ? memcpy(dest, src, n) : dest);
-}
-#define memcpy(p1,p2,n) ruby_nonempty_memcpy(p1, p2, n)
-#endif
void rb_obj_infect(VALUE victim, VALUE carrier);
@@ -1779,31 +1684,34 @@ void rb_include_module(VALUE,VALUE);
void rb_extend_object(VALUE,VALUE);
void rb_prepend_module(VALUE,VALUE);
-typedef VALUE rb_gvar_getter_t(ID id, VALUE *data);
-typedef void rb_gvar_setter_t(VALUE val, ID id, VALUE *data);
+struct rb_global_variable;
+
+typedef VALUE rb_gvar_getter_t(ID id, void *data, struct rb_global_variable *gvar);
+typedef void rb_gvar_setter_t(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
typedef void rb_gvar_marker_t(VALUE *var);
-rb_gvar_getter_t rb_gvar_undef_getter;
-rb_gvar_setter_t rb_gvar_undef_setter;
-rb_gvar_marker_t rb_gvar_undef_marker;
+VALUE rb_gvar_undef_getter(ID id, void *data, struct rb_global_variable *gvar);
+void rb_gvar_undef_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
+void rb_gvar_undef_marker(VALUE *var);
-rb_gvar_getter_t rb_gvar_val_getter;
-rb_gvar_setter_t rb_gvar_val_setter;
-rb_gvar_marker_t rb_gvar_val_marker;
+VALUE rb_gvar_val_getter(ID id, void *data, struct rb_global_variable *gvar);
+void rb_gvar_val_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
+void rb_gvar_val_marker(VALUE *var);
-rb_gvar_getter_t rb_gvar_var_getter;
-rb_gvar_setter_t rb_gvar_var_setter;
-rb_gvar_marker_t rb_gvar_var_marker;
+VALUE rb_gvar_var_getter(ID id, void *data, struct rb_global_variable *gvar);
+void rb_gvar_var_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
+void rb_gvar_var_marker(VALUE *var);
-NORETURN(rb_gvar_setter_t rb_gvar_readonly_setter);
+NORETURN(void rb_gvar_readonly_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar));
void rb_define_variable(const char*,VALUE*);
-void rb_define_virtual_variable(const char*,rb_gvar_getter_t*,rb_gvar_setter_t*);
-void rb_define_hooked_variable(const char*,VALUE*,rb_gvar_getter_t*,rb_gvar_setter_t*);
+void rb_define_virtual_variable(const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS));
+void rb_define_hooked_variable(const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS));
void rb_define_readonly_variable(const char*,const VALUE*);
void rb_define_const(VALUE,const char*,VALUE);
void rb_define_global_const(const char*,VALUE);
+#define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))(func))
void rb_define_method(VALUE,const char*,VALUE(*)(ANYARGS),int);
void rb_define_module_function(VALUE,const char*,VALUE(*)(ANYARGS),int);
void rb_define_global_function(const char*,VALUE(*)(ANYARGS),int);
@@ -1828,25 +1736,23 @@ VALUE rb_sym2str(VALUE);
VALUE rb_to_symbol(VALUE name);
VALUE rb_check_symbol(volatile VALUE *namep);
-#define RUBY_CONST_ID_CACHE_NB(result, str) \
+#define RUBY_CONST_ID_CACHE(result, str) \
+ { \
static ID rb_intern_id_cache; \
if (!rb_intern_id_cache) \
rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
- result rb_intern_id_cache;
-#define RUBY_CONST_ID_CACHE(result, str) \
- { \
- RUBY_CONST_ID_CACHE_NB(result, str) \
+ result rb_intern_id_cache; \
}
#define RUBY_CONST_ID(var, str) \
do RUBY_CONST_ID_CACHE((var) =, (str)) while (0)
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
#define CONST_ID(var, str) RUBY_CONST_ID(var, str)
-#if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR)
+#ifdef __GNUC__
/* __builtin_constant_p and statement expression is available
* since gcc-2.7.2.3 at least. */
#define rb_intern(str) \
(__builtin_constant_p(str) ? \
- __extension__ ({RUBY_CONST_ID_CACHE_NB((ID), (str))}) : \
+ __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
rb_intern(str))
#define rb_intern_const(str) \
(__builtin_constant_p(str) ? \
@@ -1891,23 +1797,13 @@ VALUE rb_eval_string_protect(const char*, int*);
VALUE rb_eval_string_wrap(const char*, int*);
VALUE rb_funcall(VALUE, ID, int, ...);
VALUE rb_funcallv(VALUE, ID, int, const VALUE*);
-VALUE rb_funcallv_kw(VALUE, ID, int, const VALUE*, int);
VALUE rb_funcallv_public(VALUE, ID, int, const VALUE*);
-VALUE rb_funcallv_public_kw(VALUE, ID, int, const VALUE*, int);
#define rb_funcall2 rb_funcallv
#define rb_funcall3 rb_funcallv_public
VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
-VALUE rb_funcall_passing_block_kw(VALUE, ID, int, const VALUE*, int);
VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE*, VALUE);
-VALUE rb_funcall_with_block_kw(VALUE, ID, int, const VALUE*, VALUE, int);
int rb_scan_args(int, const VALUE*, const char*, ...);
-#define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS 0
-#define RB_SCAN_ARGS_KEYWORDS 1
-#define RB_SCAN_ARGS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */
-#define RB_SCAN_ARGS_LAST_HASH_KEYWORDS 3
-int rb_scan_args_kw(int, int, const VALUE*, const char*, ...);
VALUE rb_call_super(int, const VALUE*);
-VALUE rb_call_super_kw(int, const VALUE*, int);
VALUE rb_current_receiver(void);
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *);
VALUE rb_extract_keywords(VALUE *orighash);
@@ -1934,7 +1830,7 @@ enum rb_io_wait_readwrite {RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE};
PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3);
PRINTF_ARGS(NORETURN(void rb_fatal(const char*, ...)), 1, 2);
-COLDFUNC PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
+PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
NORETURN(void rb_bug_errno(const char*, int));
NORETURN(void rb_sys_fail(const char*));
NORETURN(void rb_sys_fail_str(VALUE));
@@ -1958,40 +1854,35 @@ PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2);
PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4);
PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
/* reports always */
-COLDFUNC PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
+PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
-#define RB_BLOCK_CALL_FUNC_STRICT 1
#define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) \
VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg
typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
+
+#if defined RB_BLOCK_CALL_FUNC_STRICT && RB_BLOCK_CALL_FUNC_STRICT
typedef rb_block_call_func *rb_block_call_func_t;
+#else
+typedef VALUE (*rb_block_call_func_t)(ANYARGS);
+#endif
VALUE rb_each(VALUE);
VALUE rb_yield(VALUE);
VALUE rb_yield_values(int n, ...);
VALUE rb_yield_values2(int n, const VALUE *argv);
-VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat);
VALUE rb_yield_splat(VALUE);
-VALUE rb_yield_splat_kw(VALUE, int);
-VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)); /* rb_block_call_func */
-#define RB_NO_KEYWORDS 0
-#define RB_PASS_KEYWORDS 1
-#define RB_PASS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */
-#define RB_PASS_CALLED_KEYWORDS 3
-int rb_keyword_given_p(void);
+VALUE rb_yield_block(VALUE, VALUE, int, const VALUE *, VALUE); /* rb_block_call_func */
int rb_block_given_p(void);
void rb_need_block(void);
-VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
+VALUE rb_iterate(VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE);
VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE);
-VALUE rb_block_call_kw(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE,int);
-VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
-VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
-VALUE rb_vrescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,va_list);
-VALUE rb_ensure(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE),VALUE);
-VALUE rb_catch(const char*,rb_block_call_func_t,VALUE);
-VALUE rb_catch_obj(VALUE,rb_block_call_func_t,VALUE);
+VALUE rb_rescue(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
+VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...);
+VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
+VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE);
+VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE);
NORETURN(void rb_throw(const char*,VALUE));
NORETURN(void rb_throw_obj(VALUE,VALUE));
@@ -2017,20 +1908,19 @@ RUBY_EXTERN VALUE rb_cBignum;
RUBY_EXTERN VALUE rb_cBinding;
RUBY_EXTERN VALUE rb_cClass;
RUBY_EXTERN VALUE rb_cCont;
-RUBY_EXTERN VALUE rb_cData;
RUBY_EXTERN VALUE rb_cDir;
+RUBY_EXTERN VALUE rb_cData;
+RUBY_EXTERN VALUE rb_cFalseClass;
RUBY_EXTERN VALUE rb_cEncoding;
RUBY_EXTERN VALUE rb_cEnumerator;
-RUBY_EXTERN VALUE rb_cFalseClass;
RUBY_EXTERN VALUE rb_cFile;
#ifndef RUBY_INTEGER_UNIFICATION
RUBY_EXTERN VALUE rb_cFixnum;
#endif
-RUBY_EXTERN VALUE rb_cComplex;
RUBY_EXTERN VALUE rb_cFloat;
RUBY_EXTERN VALUE rb_cHash;
-RUBY_EXTERN VALUE rb_cIO;
RUBY_EXTERN VALUE rb_cInteger;
+RUBY_EXTERN VALUE rb_cIO;
RUBY_EXTERN VALUE rb_cMatch;
RUBY_EXTERN VALUE rb_cMethod;
RUBY_EXTERN VALUE rb_cModule;
@@ -2041,6 +1931,7 @@ RUBY_EXTERN VALUE rb_cProc;
RUBY_EXTERN VALUE rb_cRandom;
RUBY_EXTERN VALUE rb_cRange;
RUBY_EXTERN VALUE rb_cRational;
+RUBY_EXTERN VALUE rb_cComplex;
RUBY_EXTERN VALUE rb_cRegexp;
RUBY_EXTERN VALUE rb_cStat;
RUBY_EXTERN VALUE rb_cString;
@@ -2080,7 +1971,6 @@ RUBY_EXTERN VALUE rb_eSysStackError;
RUBY_EXTERN VALUE rb_eRegexpError;
RUBY_EXTERN VALUE rb_eEncodingError;
RUBY_EXTERN VALUE rb_eEncCompatError;
-RUBY_EXTERN VALUE rb_eNoMatchingPatternError;
RUBY_EXTERN VALUE rb_eScriptError;
RUBY_EXTERN VALUE rb_eNameError;
@@ -2180,56 +2070,13 @@ rb_array_len(VALUE a)
# define FIX_CONST_VALUE_PTR(x) (x)
#endif
-/* internal function. do not use this function */
static inline const VALUE *
-rb_array_const_ptr_transient(VALUE a)
+rb_array_const_ptr(VALUE a)
{
return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
}
-/* internal function. do not use this function */
-static inline const VALUE *
-rb_array_const_ptr(VALUE a)
-{
-#if USE_TRANSIENT_HEAP
- void rb_ary_detransient(VALUE a);
-
- if (RARRAY_TRANSIENT_P(a)) {
- rb_ary_detransient(a);
- }
-#endif
- return rb_array_const_ptr_transient(a);
-}
-
-/* internal function. do not use this function */
-static inline VALUE *
-rb_array_ptr_use_start(VALUE a, int allow_transient)
-{
- VALUE *rb_ary_ptr_use_start(VALUE ary);
-
-#if USE_TRANSIENT_HEAP
- if (!allow_transient) {
- if (RARRAY_TRANSIENT_P(a)) {
- void rb_ary_detransient(VALUE a);
- rb_ary_detransient(a);
- }
- }
-#endif
- (void)allow_transient;
-
- return rb_ary_ptr_use_start(a);
-}
-
-/* internal function. do not use this function */
-static inline void
-rb_array_ptr_use_end(VALUE a, int allow_transient)
-{
- void rb_ary_ptr_use_end(VALUE a);
- rb_ary_ptr_use_end(a);
- (void)allow_transient;
-}
-
#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
/* hook for external modules */
static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
@@ -2257,7 +2104,6 @@ int ruby_native_thread_p(void);
#define RUBY_EVENT_THREAD_BEGIN 0x0400
#define RUBY_EVENT_THREAD_END 0x0800
#define RUBY_EVENT_FIBER_SWITCH 0x1000
-#define RUBY_EVENT_SCRIPT_COMPILED 0x2000
#define RUBY_EVENT_TRACEPOINT_ALL 0xffff
/* special events */
@@ -2313,9 +2159,6 @@ static inline int rb_toupper(int c) { return rb_islower(c) ? (c&0x5f) : c; }
#define ISALPHA(c) rb_isalpha(c)
#define ISDIGIT(c) rb_isdigit(c)
#define ISXDIGIT(c) rb_isxdigit(c)
-#define ISBLANK(c) rb_isblank(c)
-#define ISCNTRL(c) rb_iscntrl(c)
-#define ISPUNCT(c) rb_ispunct(c)
#endif
#define TOUPPER(c) rb_toupper(c)
#define TOLOWER(c) rb_tolower(c)
@@ -2333,70 +2176,74 @@ unsigned long ruby_strtoul(const char *str, char **endptr, int base);
PRINTF_ARGS(int ruby_snprintf(char *str, size_t n, char const *fmt, ...), 3, 4);
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
-/* -- Remove In 3.0, Only public for rb_scan_args optimized version -- */
-int rb_empty_keyword_given_p(void);
-
-#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
+#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && defined(__OPTIMIZE__)
# define rb_scan_args(argc,argvp,fmt,...) \
__builtin_choose_expr(__builtin_constant_p(fmt), \
rb_scan_args0(argc,argvp,fmt,\
(sizeof((VALUE*[]){__VA_ARGS__})/sizeof(VALUE*)), \
((VALUE*[]){__VA_ARGS__})), \
- rb_scan_args(argc,argvp,fmt,##__VA_ARGS__))
+ rb_scan_args(argc,argvp,fmt,__VA_ARGS__))
# if HAVE_ATTRIBUTE_ERRORFUNC
-ERRORFUNC(("bad scan arg format"), void rb_scan_args_bad_format(const char*));
-ERRORFUNC(("variable argument length doesn't match"), void rb_scan_args_length_mismatch(const char*,int));
+ERRORFUNC(("bad scan arg format"), int rb_scan_args_bad_format(const char*));
+ERRORFUNC(("variable argument length doesn't match"), int rb_scan_args_length_mismatch(const char*,int));
# else
-# define rb_scan_args_bad_format(fmt) ((void)0)
-# define rb_scan_args_length_mismatch(fmt, varc) ((void)0)
+# define rb_scan_args_bad_format(fmt) 0
+# define rb_scan_args_length_mismatch(fmt, varc) 0
# endif
# define rb_scan_args_isdigit(c) ((unsigned char)((c)-'0')<10)
-# define rb_scan_args_count_end(fmt, ofs, vari) \
- (fmt[ofs] ? -1 : (vari))
+# define rb_scan_args_count_end(fmt, ofs, varc, vari) \
+ ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
-# define rb_scan_args_count_block(fmt, ofs, vari) \
+# define rb_scan_args_count_block(fmt, ofs, varc, vari) \
(fmt[ofs]!='&' ? \
- rb_scan_args_count_end(fmt, ofs, vari) : \
- rb_scan_args_count_end(fmt, ofs+1, vari+1))
+ rb_scan_args_count_end(fmt, ofs, varc, vari) : \
+ rb_scan_args_count_end(fmt, ofs+1, varc, vari+1))
-# define rb_scan_args_count_hash(fmt, ofs, vari) \
+# define rb_scan_args_count_hash(fmt, ofs, varc, vari) \
(fmt[ofs]!=':' ? \
- rb_scan_args_count_block(fmt, ofs, vari) : \
- rb_scan_args_count_block(fmt, ofs+1, vari+1))
+ rb_scan_args_count_block(fmt, ofs, varc, vari) : \
+ rb_scan_args_count_block(fmt, ofs+1, varc, vari+1))
-# define rb_scan_args_count_trail(fmt, ofs, vari) \
+# define rb_scan_args_count_trail(fmt, ofs, varc, vari) \
(!rb_scan_args_isdigit(fmt[ofs]) ? \
- rb_scan_args_count_hash(fmt, ofs, vari) : \
- rb_scan_args_count_hash(fmt, ofs+1, vari+(fmt[ofs]-'0')))
+ rb_scan_args_count_hash(fmt, ofs, varc, vari) : \
+ rb_scan_args_count_hash(fmt, ofs+1, varc, vari+(fmt[ofs]-'0')))
-# define rb_scan_args_count_var(fmt, ofs, vari) \
+# define rb_scan_args_count_var(fmt, ofs, varc, vari) \
(fmt[ofs]!='*' ? \
- rb_scan_args_count_trail(fmt, ofs, vari) : \
- rb_scan_args_count_trail(fmt, ofs+1, vari+1))
+ rb_scan_args_count_trail(fmt, ofs, varc, vari) : \
+ rb_scan_args_count_trail(fmt, ofs+1, varc, vari+1))
-# define rb_scan_args_count_opt(fmt, ofs, vari) \
- (!rb_scan_args_isdigit(fmt[ofs]) ? \
- rb_scan_args_count_var(fmt, ofs, vari) : \
- rb_scan_args_count_var(fmt, ofs+1, vari+fmt[ofs]-'0'))
+# define rb_scan_args_count_opt(fmt, ofs, varc, vari) \
+ (!rb_scan_args_isdigit(fmt[1]) ? \
+ rb_scan_args_count_var(fmt, ofs, varc, vari) : \
+ rb_scan_args_count_var(fmt, ofs+1, varc, vari+fmt[ofs]-'0'))
-# define rb_scan_args_count_lead(fmt, ofs, vari) \
- (!rb_scan_args_isdigit(fmt[ofs]) ? \
- rb_scan_args_count_var(fmt, ofs, vari) : \
- rb_scan_args_count_opt(fmt, ofs+1, vari+fmt[ofs]-'0'))
+# define rb_scan_args_count(fmt, varc) \
+ ((!rb_scan_args_isdigit(fmt[0]) ? \
+ rb_scan_args_count_var(fmt, 0, varc, 0) : \
+ rb_scan_args_count_opt(fmt, 1, varc, fmt[0]-'0')) \
+ == (varc) || \
+ rb_scan_args_length_mismatch(fmt, varc))
-# define rb_scan_args_count(fmt) rb_scan_args_count_lead(fmt, 0, 0)
+# define rb_scan_args_verify_count(fmt, varc) \
+ ((varc)/(rb_scan_args_count(fmt, varc)))
-# if defined(__has_attribute) && __has_attribute(diagnose_if)
-# define rb_scan_args_verify(fmt, varc) (void)0
+# ifdef __GNUC__
+# define rb_scan_args_verify(fmt, varc) \
+ ({ \
+ int verify; \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Warray-bounds\""); \
+ verify = rb_scan_args_verify_count(fmt, varc); \
+ _Pragma("GCC diagnostic pop"); \
+ verify; \
+ })
# else
# define rb_scan_args_verify(fmt, varc) \
- (sizeof(char[1-2*(rb_scan_args_count(fmt)<0)])!=1 ? \
- rb_scan_args_bad_format(fmt) : \
- sizeof(char[1-2*(rb_scan_args_count(fmt)!=(varc))])!=1 ? \
- rb_scan_args_length_mismatch(fmt, varc) : \
- (void)0)
+ rb_scan_args_verify_count(fmt, varc)
# endif
ALWAYS_INLINE(static int rb_scan_args_lead_p(const char *fmt));
@@ -2497,8 +2344,6 @@ rb_scan_args_end_idx(const char *fmt)
}
# endif
-/* NOTE: Use `char *fmt` instead of `const char *fmt` because of clang's bug*/
-/* https://bugs.llvm.org/show_bug.cgi?id=38095 */
# define rb_scan_args0(argc, argv, fmt, varc, vars) \
rb_scan_args_set(argc, argv, \
rb_scan_args_n_lead(fmt), \
@@ -2507,101 +2352,45 @@ rb_scan_args_end_idx(const char *fmt)
rb_scan_args_f_var(fmt), \
rb_scan_args_f_hash(fmt), \
rb_scan_args_f_block(fmt), \
- (rb_scan_args_verify(fmt, varc), vars), (char *)fmt, varc)
+ (rb_scan_args_verify(fmt, varc), vars))
ALWAYS_INLINE(static int
rb_scan_args_set(int argc, const VALUE *argv,
int n_lead, int n_opt, int n_trail,
int f_var, int f_hash, int f_block,
- VALUE *vars[], char *fmt, int varc));
-
+ VALUE *vars[]));
inline int
rb_scan_args_set(int argc, const VALUE *argv,
int n_lead, int n_opt, int n_trail,
int f_var, int f_hash, int f_block,
- VALUE *vars[], RB_UNUSED_VAR(char *fmt), RB_UNUSED_VAR(int varc))
-# if defined(__has_attribute) && __has_attribute(diagnose_if)
- __attribute__((diagnose_if(rb_scan_args_count(fmt)<0,"bad scan arg format","error")))
- __attribute__((diagnose_if(rb_scan_args_count(fmt)!=varc,"variable argument length doesn't match","error")))
-# endif
+ VALUE *vars[])
{
int i, argi = 0, vari = 0, last_idx = -1;
VALUE *var, hash = Qnil, last_hash = 0;
const int n_mand = n_lead + n_trail;
- int keyword_given = rb_keyword_given_p();
- int empty_keyword_given = 0;
- VALUE tmp_buffer = 0;
-
- if (!keyword_given) {
- empty_keyword_given = rb_empty_keyword_given_p();
- }
/* capture an option hash - phase 1: pop */
- /* Ignore final positional hash if empty keywords given */
- if (argc > 0 && !(f_hash && empty_keyword_given)) {
- VALUE last = argv[argc - 1];
-
- if (f_hash && n_mand < argc) {
- if (keyword_given) {
- if (!RB_TYPE_P(last, T_HASH)) {
- rb_warn("Keyword flag set when calling rb_scan_args, but last entry is not a hash");
- }
- else {
- hash = last;
- }
- }
- else if (NIL_P(last)) {
- /* For backwards compatibility, nil is taken as an empty
- option hash only if it is not ambiguous; i.e. '*' is
- not specified and arguments are given more than sufficient.
- This will be removed in Ruby 3. */
- if (!f_var && n_mand + n_opt < argc) {
- rb_warn("The last argument is nil, treating as empty keywords");
- argc--;
- }
- }
- else {
- hash = rb_check_hash_type(last);
- }
-
- /* Ruby 3: Remove if branch, as it will not attempt to split hashes */
- if (!NIL_P(hash)) {
- VALUE opts = rb_extract_keywords(&hash);
-
- if (!(last_hash = hash)) {
- if (!keyword_given) {
- /* Warn if treating positional as keyword, as in Ruby 3,
- this will be an error */
- rb_warn("Using the last argument as keyword parameters is deprecated");
- }
- argc--;
- }
- else {
- /* Warn if splitting either positional hash to keywords or keywords
- to positional hash, as in Ruby 3, no splitting will be done */
- rb_warn("The last argument is split into positional and keyword parameters");
- last_idx = argc - 1;
- }
- hash = opts ? opts : Qnil;
- }
- }
- else if (f_hash && keyword_given && n_mand == argc) {
- /* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
- rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
- }
- }
- if (f_hash && n_mand > 0 && n_mand == argc+1 && empty_keyword_given) {
- VALUE *ptr = (VALUE *)rb_alloc_tmp_buffer2(&tmp_buffer, argc+1, sizeof(VALUE));
- memcpy(ptr, argv, sizeof(VALUE)*argc);
- ptr[argc] = rb_hash_new();
- argc++;
- *(&argv) = ptr;
- rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
+ if (f_hash && n_mand < argc) {
+ VALUE last = argv[argc - 1];
+
+ if (RB_NIL_P(last)) {
+ /* nil is taken as an empty option hash only if it is not
+ ambiguous; i.e. '*' is not specified and arguments are
+ given more than sufficient */
+ if (!f_var && n_mand + n_opt < argc)
+ argc--;
+ }
+ else {
+ hash = rb_check_hash_type(last);
+ if (!RB_NIL_P(hash)) {
+ VALUE opts = rb_extract_keywords(&hash);
+ if (!(last_hash = hash)) argc--;
+ else last_idx = argc - 1;
+ hash = opts ? opts : Qnil;
+ }
+ }
}
-
- if (argc < n_mand) {
- goto argc_error;
- }
+ rb_check_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
/* capture leading mandatory arguments */
for (i = n_lead; i-- > 0; ) {
@@ -2659,18 +2448,11 @@ rb_scan_args_set(int argc, const VALUE *argv,
}
}
- if (argi < argc) {
- argc_error:
- if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer);
- rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
- }
-
- if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer);
return argc;
}
#endif
-#if defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
+#if defined(__GNUC__) && defined(__OPTIMIZE__)
# define rb_yield_values(argc, ...) \
__extension__({ \
const int rb_yield_values_argc = (argc); \
@@ -2688,7 +2470,7 @@ __extension__({ \
const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
const int rb_funcall_nargs = \
(int)(sizeof(rb_funcall_args) / sizeof(VALUE)); \
- rb_funcallv(recv, mid, \
+ rb_funcallv(recv, mid, \
rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
rb_funcall_nargs ? rb_funcall_args : NULL); \
})
@@ -2732,7 +2514,13 @@ void ruby_show_copyright(void);
ruby_init_stack(&variable_in_this_stack_frame);
/*! @} */
+#ifdef __ia64
+void ruby_init_stack(volatile VALUE*, void*);
+#define ruby_init_stack(addr) ruby_init_stack((addr), rb_ia64_bsp())
+#else
void ruby_init_stack(volatile VALUE*);
+#endif
+#define Init_stack(addr) ruby_init_stack(addr)
int ruby_setup(void);
int ruby_cleanup(volatile int);
@@ -2769,105 +2557,5 @@ RUBY_SYMBOL_EXPORT_END
{ /* satisfy cc-mode */
#endif
} /* extern "C" { */
-extern "C++" {
#endif
-
-#ifdef RB_METHOD_DEFINITION_DECL
-
-RB_METHOD_DEFINITION_DECL(rb_define_method, (2,3), (VALUE klass, const char *name), (klass, name))
-#ifdef __cplusplus
-#define rb_define_method(m, n, f, a) rb_define_method_tmpl<a>::define(m, n, f)
-#else
-#define rb_define_method_if_constexpr(x, t, f) __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(x),(x),0),(t),(f))
-#define rb_define_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_method15,rb_define_methodm3)
-#define rb_define_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_method14,rb_define_method_choose_prototype15(n))
-#define rb_define_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_method13,rb_define_method_choose_prototype14(n))
-#define rb_define_method_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_method12,rb_define_method_choose_prototype13(n))
-#define rb_define_method_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_method11,rb_define_method_choose_prototype12(n))
-#define rb_define_method_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_method10,rb_define_method_choose_prototype11(n))
-#define rb_define_method_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_method9, rb_define_method_choose_prototype10(n))
-#define rb_define_method_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_method8, rb_define_method_choose_prototype9(n))
-#define rb_define_method_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_method7, rb_define_method_choose_prototype8(n))
-#define rb_define_method_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_method6, rb_define_method_choose_prototype7(n))
-#define rb_define_method_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_method5, rb_define_method_choose_prototype6(n))
-#define rb_define_method_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_method4, rb_define_method_choose_prototype5(n))
-#define rb_define_method_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_method3, rb_define_method_choose_prototype4(n))
-#define rb_define_method_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_method2, rb_define_method_choose_prototype3(n))
-#define rb_define_method_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_method1, rb_define_method_choose_prototype2(n))
-#define rb_define_method_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_method0, rb_define_method_choose_prototype1(n))
-#define rb_define_method_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_methodm1,rb_define_method_choose_prototype0(n))
-#define rb_define_method_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_methodm2,rb_define_method_choose_prototypem1(n))
-#define rb_define_method_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_methodm3,rb_define_method_choose_prototypem2(n))
-#define rb_define_method(klass, mid, func, arity) rb_define_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
-#endif
-
-RB_METHOD_DEFINITION_DECL(rb_define_module_function, (2,3), (VALUE klass, const char *name), (klass, name))
-#ifdef __cplusplus
-#define rb_define_module_function(m, n, f, a) rb_define_module_function_tmpl<a>::define(m, n, f)
-#else
-#define rb_define_module_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_module_function15,rb_define_module_functionm3)
-#define rb_define_module_function_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_module_function14,rb_define_module_function_choose_prototype15(n))
-#define rb_define_module_function_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_module_function13,rb_define_module_function_choose_prototype14(n))
-#define rb_define_module_function_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_module_function12,rb_define_module_function_choose_prototype13(n))
-#define rb_define_module_function_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_module_function11,rb_define_module_function_choose_prototype12(n))
-#define rb_define_module_function_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_module_function10,rb_define_module_function_choose_prototype11(n))
-#define rb_define_module_function_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_module_function9, rb_define_module_function_choose_prototype10(n))
-#define rb_define_module_function_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_module_function8, rb_define_module_function_choose_prototype9(n))
-#define rb_define_module_function_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_module_function7, rb_define_module_function_choose_prototype8(n))
-#define rb_define_module_function_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_module_function6, rb_define_module_function_choose_prototype7(n))
-#define rb_define_module_function_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_module_function5, rb_define_module_function_choose_prototype6(n))
-#define rb_define_module_function_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_module_function4, rb_define_module_function_choose_prototype5(n))
-#define rb_define_module_function_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_module_function3, rb_define_module_function_choose_prototype4(n))
-#define rb_define_module_function_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_module_function2, rb_define_module_function_choose_prototype3(n))
-#define rb_define_module_function_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_module_function1, rb_define_module_function_choose_prototype2(n))
-#define rb_define_module_function_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_module_function0, rb_define_module_function_choose_prototype1(n))
-#define rb_define_module_function_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_module_functionm1,rb_define_module_function_choose_prototype0(n))
-#define rb_define_module_function_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_module_functionm2,rb_define_module_function_choose_prototypem1(n))
-#define rb_define_module_function_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_module_functionm3,rb_define_module_function_choose_prototypem2(n))
-#define rb_define_module_function(klass, mid, func, arity) rb_define_module_function_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
-#endif
-
-RB_METHOD_DEFINITION_DECL(rb_define_global_function, (1,2), (const char *name), (name))
-#ifdef __cplusplus
-#define rb_define_global_function(n, f, a) rb_define_global_function_tmpl<a>::define(n, f)
-#else
-#define rb_define_global_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_global_function15,rb_define_global_functionm3)
-#define rb_define_global_function_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_global_function14,rb_define_global_function_choose_prototype15(n))
-#define rb_define_global_function_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_global_function13,rb_define_global_function_choose_prototype14(n))
-#define rb_define_global_function_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_global_function12,rb_define_global_function_choose_prototype13(n))
-#define rb_define_global_function_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_global_function11,rb_define_global_function_choose_prototype12(n))
-#define rb_define_global_function_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_global_function10,rb_define_global_function_choose_prototype11(n))
-#define rb_define_global_function_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_global_function9, rb_define_global_function_choose_prototype10(n))
-#define rb_define_global_function_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_global_function8, rb_define_global_function_choose_prototype9(n))
-#define rb_define_global_function_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_global_function7, rb_define_global_function_choose_prototype8(n))
-#define rb_define_global_function_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_global_function6, rb_define_global_function_choose_prototype7(n))
-#define rb_define_global_function_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_global_function5, rb_define_global_function_choose_prototype6(n))
-#define rb_define_global_function_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_global_function4, rb_define_global_function_choose_prototype5(n))
-#define rb_define_global_function_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_global_function3, rb_define_global_function_choose_prototype4(n))
-#define rb_define_global_function_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_global_function2, rb_define_global_function_choose_prototype3(n))
-#define rb_define_global_function_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_global_function1, rb_define_global_function_choose_prototype2(n))
-#define rb_define_global_function_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_global_function0, rb_define_global_function_choose_prototype1(n))
-#define rb_define_global_function_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_global_functionm1,rb_define_global_function_choose_prototype0(n))
-#define rb_define_global_function_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_global_functionm2,rb_define_global_function_choose_prototypem1(n))
-#define rb_define_global_function_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_global_functionm3,rb_define_global_function_choose_prototypem2(n))
-#define rb_define_global_function(mid, func, arity) rb_define_global_function_choose_prototypem3((arity),(func))((mid),(func),(arity));
-#endif
-
-#endif
-
-#if defined(RUBY_DEVEL) && RUBY_DEVEL && (!defined(__cplusplus) || defined(RB_METHOD_DEFINITION_DECL))
-# define RUBY_METHOD_FUNC(func) (func)
-#else
-# define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))(func))
-#endif
-
-#ifdef __cplusplus
-#include "backward/cxxanyargs.hpp"
-
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C++" { */
-#endif
-
#endif /* RUBY_RUBY_H */
diff --git a/include/ruby/st.h b/include/ruby/st.h
index ea1637bd9f..47e14a3e2c 100644
--- a/include/ruby/st.h
+++ b/include/ruby/st.h
@@ -59,8 +59,8 @@ typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index
#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
struct st_hash_type {
- int (*compare)(st_data_t, st_data_t); /* st_compare_func* */
- st_index_t (*hash)(st_data_t); /* st_hash_func* */
+ int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
+ st_index_t (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
};
#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
@@ -96,95 +96,53 @@ struct st_table {
#define st_is_member(table,key) st_lookup((table),(key),(st_data_t *)0)
-enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK, ST_REPLACE};
-
-st_table *rb_st_init_table(const struct st_hash_type *);
-#define st_init_table rb_st_init_table
-st_table *rb_st_init_table_with_size(const struct st_hash_type *, st_index_t);
-#define st_init_table_with_size rb_st_init_table_with_size
-st_table *rb_st_init_numtable(void);
-#define st_init_numtable rb_st_init_numtable
-st_table *rb_st_init_numtable_with_size(st_index_t);
-#define st_init_numtable_with_size rb_st_init_numtable_with_size
-st_table *rb_st_init_strtable(void);
-#define st_init_strtable rb_st_init_strtable
-st_table *rb_st_init_strtable_with_size(st_index_t);
-#define st_init_strtable_with_size rb_st_init_strtable_with_size
-st_table *rb_st_init_strcasetable(void);
-#define st_init_strcasetable rb_st_init_strcasetable
-st_table *rb_st_init_strcasetable_with_size(st_index_t);
-#define st_init_strcasetable_with_size rb_st_init_strcasetable_with_size
-int rb_st_delete(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
-#define st_delete rb_st_delete
-int rb_st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
-#define st_delete_safe rb_st_delete_safe
-int rb_st_shift(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
-#define st_shift rb_st_shift
-int rb_st_insert(st_table *, st_data_t, st_data_t);
-#define st_insert rb_st_insert
-int rb_st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
-#define st_insert2 rb_st_insert2
-int rb_st_lookup(st_table *, st_data_t, st_data_t *);
-#define st_lookup rb_st_lookup
-int rb_st_get_key(st_table *, st_data_t, st_data_t *);
-#define st_get_key rb_st_get_key
+enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
+
+st_table *st_init_table(const struct st_hash_type *);
+st_table *st_init_table_with_size(const struct st_hash_type *, st_index_t);
+st_table *st_init_numtable(void);
+st_table *st_init_numtable_with_size(st_index_t);
+st_table *st_init_strtable(void);
+st_table *st_init_strtable_with_size(st_index_t);
+st_table *st_init_strcasetable(void);
+st_table *st_init_strcasetable_with_size(st_index_t);
+int st_delete(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
+int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
+int st_shift(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
+int st_insert(st_table *, st_data_t, st_data_t);
+int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
+int st_lookup(st_table *, st_data_t, st_data_t *);
+int st_get_key(st_table *, st_data_t, st_data_t *);
typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing);
/* *key may be altered, but must equal to the old key, i.e., the
* results of hash() are same and compare() returns 0, otherwise the
* behavior is undefined */
-int rb_st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
-#define st_update rb_st_update
-typedef int st_foreach_callback_func(st_data_t, st_data_t, st_data_t);
-typedef int st_foreach_check_callback_func(st_data_t, st_data_t, st_data_t, int);
-int rb_st_foreach_with_replace(st_table *tab, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
-#define st_foreach_with_replace rb_st_foreach_with_replace
-int rb_st_foreach(st_table *, st_foreach_callback_func *, st_data_t);
-#define st_foreach rb_st_foreach
-int rb_st_foreach_check(st_table *, st_foreach_check_callback_func *, st_data_t, st_data_t);
-#define st_foreach_check rb_st_foreach_check
-st_index_t rb_st_keys(st_table *table, st_data_t *keys, st_index_t size);
-#define st_keys rb_st_keys
-st_index_t rb_st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never);
-#define st_keys_check rb_st_keys_check
-st_index_t rb_st_values(st_table *table, st_data_t *values, st_index_t size);
-#define st_values rb_st_values
-st_index_t rb_st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never);
-#define st_values_check rb_st_values_check
-void rb_st_add_direct(st_table *, st_data_t, st_data_t);
-#define st_add_direct rb_st_add_direct
-void rb_st_free_table(st_table *);
-#define st_free_table rb_st_free_table
-void rb_st_cleanup_safe(st_table *, st_data_t);
-#define st_cleanup_safe rb_st_cleanup_safe
-void rb_st_clear(st_table *);
-#define st_clear rb_st_clear
-st_table *rb_st_copy(st_table *);
-#define st_copy rb_st_copy
-CONSTFUNC(int rb_st_numcmp(st_data_t, st_data_t));
-#define st_numcmp rb_st_numcmp
-CONSTFUNC(st_index_t rb_st_numhash(st_data_t));
-#define st_numhash rb_st_numhash
-PUREFUNC(int rb_st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
-#define st_locale_insensitive_strcasecmp rb_st_locale_insensitive_strcasecmp
-PUREFUNC(int rb_st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
-#define st_locale_insensitive_strncasecmp rb_st_locale_insensitive_strncasecmp
-#define st_strcasecmp rb_st_locale_insensitive_strcasecmp
-#define st_strncasecmp rb_st_locale_insensitive_strncasecmp
-PUREFUNC(size_t rb_st_memsize(const st_table *));
-#define st_memsize rb_st_memsize
-PUREFUNC(st_index_t rb_st_hash(const void *ptr, size_t len, st_index_t h));
-#define st_hash rb_st_hash
-CONSTFUNC(st_index_t rb_st_hash_uint32(st_index_t h, uint32_t i));
-#define st_hash_uint32 rb_st_hash_uint32
-CONSTFUNC(st_index_t rb_st_hash_uint(st_index_t h, st_index_t i));
-#define st_hash_uint rb_st_hash_uint
-CONSTFUNC(st_index_t rb_st_hash_end(st_index_t h));
-#define st_hash_end rb_st_hash_end
-CONSTFUNC(st_index_t rb_st_hash_start(st_index_t h));
+int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
+int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
+int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
+st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size);
+st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never);
+st_index_t st_values(st_table *table, st_data_t *values, st_index_t size);
+st_index_t st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never);
+void st_add_direct(st_table *, st_data_t, st_data_t);
+void st_free_table(st_table *);
+void st_cleanup_safe(st_table *, st_data_t);
+void st_clear(st_table *);
+st_table *st_copy(st_table *);
+CONSTFUNC(int st_numcmp(st_data_t, st_data_t));
+CONSTFUNC(st_index_t st_numhash(st_data_t));
+PUREFUNC(int st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
+PUREFUNC(int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
+#define st_strcasecmp st_locale_insensitive_strcasecmp
+#define st_strncasecmp st_locale_insensitive_strncasecmp
+PUREFUNC(size_t st_memsize(const st_table *));
+PUREFUNC(st_index_t st_hash(const void *ptr, size_t len, st_index_t h));
+CONSTFUNC(st_index_t st_hash_uint32(st_index_t h, uint32_t i));
+CONSTFUNC(st_index_t st_hash_uint(st_index_t h, st_index_t i));
+CONSTFUNC(st_index_t st_hash_end(st_index_t h));
+CONSTFUNC(st_index_t st_hash_start(st_index_t h));
#define st_hash_start(h) ((st_index_t)(h))
-void rb_hash_bulk_insert_into_st_table(long, const VALUE *, VALUE);
-
RUBY_SYMBOL_EXPORT_END
#if defined(__cplusplus)
diff --git a/include/ruby/thread.h b/include/ruby/thread.h
index d398cc127e..550f678e54 100644
--- a/include/ruby/thread.h
+++ b/include/ruby/thread.h
@@ -21,10 +21,6 @@ extern "C" {
#include "ruby/intern.h"
-/* flags for rb_nogvl */
-#define RB_NOGVL_INTR_FAIL (0x1)
-#define RB_NOGVL_UBF_ASYNC_SAFE (0x2)
-
RUBY_SYMBOL_EXPORT_BEGIN
void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
@@ -34,14 +30,6 @@ void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
void *rb_thread_call_without_gvl2(void *(*func)(void *), void *data1,
rb_unblock_function_t *ubf, void *data2);
-/*
- * XXX: unstable/unapproved - out-of-tree code should NOT not depend
- * on this until it hits Ruby 2.6.1
- */
-void *rb_nogvl(void *(*func)(void *), void *data1,
- rb_unblock_function_t *ubf, void *data2,
- int flags);
-
#define RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS_AFTER 0x01
#define RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS_
diff --git a/include/ruby/version.h b/include/ruby/version.h
index 64c5c614e0..10b1b05436 100644
--- a/include/ruby/version.h
+++ b/include/ruby/version.h
@@ -31,7 +31,7 @@
/* API version */
#define RUBY_API_VERSION_MAJOR 2
-#define RUBY_API_VERSION_MINOR 7
+#define RUBY_API_VERSION_MINOR 5
#define RUBY_API_VERSION_TEENY 0
#define RUBY_API_VERSION_CODE (RUBY_API_VERSION_MAJOR*10000+RUBY_API_VERSION_MINOR*100+RUBY_API_VERSION_TEENY)
diff --git a/include/ruby/vm.h b/include/ruby/vm.h
index b137a280c9..73345264bd 100644
--- a/include/ruby/vm.h
+++ b/include/ruby/vm.h
@@ -24,7 +24,8 @@ RUBY_SYMBOL_EXPORT_BEGIN
/* Place holder.
*
* We will prepare VM creation/control APIs on 1.9.2 or later.
- *
+ * If you have an interest about it, please see mvm branch.
+ * http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/mvm/
*/
/* VM type declaration */
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index b29470b0c4..fe1978fdde 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -146,7 +146,7 @@ typedef int clockid_t;
#define HAVE_UTIMENSAT 1
#define AT_FDCWD -100
#define utimensat(_d, _p, _t, _f) rb_w32_utimensat(_d, _p, _t, _f)
-#define lseek(_f, _o, _w) rb_w32_lseek(_f, _o, _w)
+#define lseek(_f, _o, _w) _lseeki64(_f, _o, _w)
#define pipe(p) rb_w32_pipe(p)
#define open rb_w32_open
@@ -751,7 +751,6 @@ int rb_w32_fclose(FILE*);
int rb_w32_pipe(int[2]);
ssize_t rb_w32_read(int, void *, size_t);
ssize_t rb_w32_write(int, const void *, size_t);
-off_t rb_w32_lseek(int, off_t, int);
int rb_w32_utime(const char *, const struct utimbuf *);
int rb_w32_uutime(const char *, const struct utimbuf *);
int rb_w32_utimes(const char *, const struct timeval *);
diff --git a/inits.c b/inits.c
index 79a6cf014e..d6cc0cbc78 100644
--- a/inits.c
+++ b/inits.c
@@ -10,21 +10,14 @@
**********************************************************************/
#include "internal.h"
-#include "builtin.h"
-#include "prelude.rbinc"
#define CALL(n) {void Init_##n(void); Init_##n();}
void
rb_call_inits(void)
{
-#if USE_TRANSIENT_HEAP
- CALL(TransientHeap);
-#endif
- CALL(vm_postponed_job);
CALL(Method);
CALL(RandomSeedCore);
- CALL(encodings);
CALL(sym);
CALL(var_tables);
CALL(Object);
@@ -44,6 +37,7 @@ rb_call_inits(void)
CALL(Hash);
CALL(Struct);
CALL(Regexp);
+ CALL(pack);
CALL(transcode);
CALL(marshal);
CALL(Range);
@@ -56,6 +50,7 @@ rb_call_inits(void)
CALL(Proc);
CALL(Binding);
CALL(Math);
+ CALL(GC);
CALL(Enumerator);
CALL(VM);
CALL(ISeq);
@@ -65,18 +60,7 @@ rb_call_inits(void)
CALL(Rational);
CALL(Complex);
CALL(version);
- CALL(vm_stack_canary);
- CALL(gc_stress);
-
- // enable builtin loading
- CALL(builtin);
-
- CALL(GC);
- CALL(IO_nonblock);
- CALL(ast);
CALL(vm_trace);
- CALL(pack);
- CALL(warning);
- load_prelude();
+ CALL(gc_stress);
}
#undef CALL
diff --git a/insns.def b/insns.def
index 71b9f44072..d23fef0649 100644
--- a/insns.def
+++ b/insns.def
@@ -1,62 +1,36 @@
-/* -*- C -*-
+/** ##skip -*- mode:c; style:ruby; coding: utf-8 -*-
insns.def - YARV instruction definitions
$Author: $
created at: 04/01/01 01:17:55 JST
Copyright (C) 2004-2007 Koichi Sasada
- Massive rewrite by @shyouhei in 2017.
- */
-
-/* Some comments about this file's contents:
-
- - The new format aims to be editable by C editor of your choice;
- your mileage might vary of course.
-
- - Each instructions are in following format:
-
- DEFINE_INSN
- instruction_name
- (type operand, type operand, ..)
- (pop_values, ..)
- (return values ..)
- // attr type name contents..
- {
+*/
+
+/** ##skip
+ instruction comment
+ @c: category
+ @e: english description
+ @j: japanese description
+
+ instruction form:
+ DEFINE_INSN
+ instruction_name
+ (instruction_operands, ..)
+ (pop_values, ..)
+ (return value)
+ {
.. // insn body
- }
-
- - Unlike the old format which was line-oriented, you can now place
- newlines and comments at liberal positions.
-
- - `DEFINE_INSN` is a keyword.
-
- - An instruction name must be a valid C identifier.
-
- - Operands, pop values, return values are series of either variable
- declarations, keyword `void`, or keyword `...`. They are much
- like C function declarations.
-
- - Attribute pragmas are optional, and can include arbitrary C
- expressions. You can write anything there but as of writing,
- supported attributes are:
-
- * sp_inc: Used to dynamically calculate sp increase in
- `insn_stack_increase`.
-
- * handles_sp: If it is true, VM deals with sp in the insn.
- Default is if the instruction takes ISEQ operand or not.
+ }
- * leaf: indicates that the instruction is "leaf" i.e. it does
- not introduce new stack frame on top of it.
- If an instruction handles sp, that can never be a leaf.
+ */
- - Attributes can access operands, but not stack (push/pop) variables.
- - An instruction's body is a pure C block, copied verbatimly into
- the generated C source code.
+/**
+ @c nop
+ @e nop
+ @j nop
*/
-
-/* nop */
DEFINE_INSN
nop
()
@@ -70,8 +44,12 @@ nop
/* deal with variables */
/**********************************************************/
-/* Get local variable (pointed by `idx' and `level').
+/**
+ @c variable
+ @e Get local variable (pointed by `idx' and `level').
'level' indicates the nesting depth from the current block.
+ @j level, idx ã§æŒ‡å®šã•れãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã®å€¤ã‚’スタックã«ç½®ã。
+ level ã¯ãƒ–ロックã®ãƒã‚¹ãƒˆãƒ¬ãƒ™ãƒ«ã§ã€ä½•段上ã‹ã‚’示ã™ã€‚
*/
DEFINE_INSN
getlocal
@@ -84,8 +62,12 @@ getlocal
(void)RB_DEBUG_COUNTER_INC_IF(lvar_get_dynamic, level > 0);
}
-/* Set a local variable (pointed to by 'idx') as val.
+/**
+ @c variable
+ @e Set a local variable (pointed to by 'idx') as val.
'level' indicates the nesting depth from the current block.
+ @j level, idx ã§æŒ‡å®šã•れãŸãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã®å€¤ã‚’ val ã«ã™ã‚‹ã€‚
+ level ã¯ãƒ–ロックã®ãƒã‚¹ãƒˆãƒ¬ãƒ™ãƒ«ã§ã€ä½•段上ã‹ã‚’示ã™ã€‚
*/
DEFINE_INSN
setlocal
@@ -98,7 +80,11 @@ setlocal
(void)RB_DEBUG_COUNTER_INC_IF(lvar_set_dynamic, level > 0);
}
-/* Get a block parameter. */
+/**
+ @c variable
+ @e Get a block parameter.
+ @j ブロックパラメータをå–å¾—ã™ã‚‹ã€‚
+ */
DEFINE_INSN
getblockparam
(lindex_t idx, rb_num_t level)
@@ -120,7 +106,11 @@ getblockparam
}
}
-/* Set block parameter. */
+/**
+ @c variable
+ @e Set block parameter.
+ @j ブロックパラメータを設定ã™ã‚‹ã€‚
+ */
DEFINE_INSN
setblockparam
(lindex_t idx, rb_num_t level)
@@ -137,64 +127,25 @@ setblockparam
VM_ENV_FLAGS_SET(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM);
}
-/* Get special proxy object which only responds to `call` method if the block parameter
- represents a iseq/ifunc block. Otherwise, same as `getblockparam`.
+/**
+ @c variable
+ @e Get value of special local variable ($~, $_, ..).
+ @j 特殊ãªãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ï¼ˆ$~, $_, ...)ã®å€¤ã‚’得る。
*/
DEFINE_INSN
-getblockparamproxy
-(lindex_t idx, rb_num_t level)
-()
-(VALUE val)
-{
- const VALUE *ep = vm_get_ep(GET_EP(), level);
- VM_ASSERT(VM_ENV_LOCAL_P(ep));
-
- if (!VM_ENV_FLAGS(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM)) {
- VALUE block_handler = VM_ENV_BLOCK_HANDLER(ep);
-
- if (block_handler) {
- switch (vm_block_handler_type(block_handler)) {
- case block_handler_type_iseq:
- case block_handler_type_ifunc:
- val = rb_block_param_proxy;
- break;
- case block_handler_type_symbol:
- val = rb_sym_to_proc(VM_BH_TO_SYMBOL(block_handler));
- goto INSN_LABEL(set);
- case block_handler_type_proc:
- val = VM_BH_TO_PROC(block_handler);
- goto INSN_LABEL(set);
- default:
- VM_UNREACHABLE(getblockparamproxy);
- }
- }
- else {
- val = Qnil;
- INSN_LABEL(set):
- vm_env_write(ep, -(int)idx, val);
- VM_ENV_FLAGS_SET(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM);
- }
- }
- else {
- val = *(ep - idx);
- RB_DEBUG_COUNTER_INC(lvar_get);
- (void)RB_DEBUG_COUNTER_INC_IF(lvar_get_dynamic, level > 0);
- }
-}
-
-/* Get value of special local variable ($~, $_, ..). */
-DEFINE_INSN
getspecial
(rb_num_t key, rb_num_t type)
()
(VALUE val)
-/* `$~ = MatchData.allocate; $&` can raise. */
-// attr bool leaf = (type == 0) ? true : false;
{
val = vm_getspecial(ec, GET_LEP(), key, type);
}
-/* Set value of special local variable ($~, $_, ...) to obj. */
+/**
+ @c variable
+ @e Set value of special local variable ($~, $_, ...) to obj.
+ @j 特別ãªãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ï¼ˆ$~, $_, ...)ã®å€¤ã‚’設定ã™ã‚‹ã€‚
+ */
DEFINE_INSN
setspecial
(rb_num_t key)
@@ -204,116 +155,146 @@ setspecial
lep_svar_set(ec, GET_LEP(), key, obj);
}
-/* Get value of instance variable id of self. */
+/**
+ @c variable
+ @e Get value of instance variable id of self.
+ @j self ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹å¤‰æ•° id ã®å€¤ã‚’得る。
+ */
DEFINE_INSN
getinstancevariable
-(ID id, IVC ic)
+(ID id, IC ic)
()
(VALUE val)
-/* "instance variable not initialized" warning can be hooked. */
-// attr bool leaf = false; /* has rb_warning() */
{
val = vm_getinstancevariable(GET_SELF(), id, ic);
}
-/* Set value of instance variable id of self to val. */
+/**
+ @c variable
+ @e Set value of instance variable id of self to val.
+ @j self ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹å¤‰æ•° id ã‚’ val ã«ã™ã‚‹ã€‚
+ */
DEFINE_INSN
setinstancevariable
-(ID id, IVC ic)
+(ID id, IC ic)
(VALUE val)
()
-// attr bool leaf = false; /* has rb_check_frozen_internal() */
{
vm_setinstancevariable(GET_SELF(), id, val, ic);
}
-/* Get value of class variable id of klass as val. */
+/**
+ @c variable
+ @e Get value of class variable id of klass as val.
+ @j ç¾åœ¨ã®ã‚¹ã‚³ãƒ¼ãƒ—ã®ã‚¯ãƒ©ã‚¹å¤‰æ•° id ã®å€¤ã‚’得る。
+ */
DEFINE_INSN
getclassvariable
(ID id)
()
(VALUE val)
-/* "class variable access from toplevel" warning can be hooked. */
-// attr bool leaf = false; /* has rb_warning() */
{
- val = rb_cvar_get(vm_get_cvar_base(vm_get_cref(GET_EP()), GET_CFP()), id);
+ val = rb_cvar_get(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id);
}
-/* Set value of class variable id of klass as val. */
+/**
+ @c variable
+ @e Set value of class variable id of klass as val.
+ @j klass ã®ã‚¯ãƒ©ã‚¹å¤‰æ•° id ã‚’ val ã«ã™ã‚‹ã€‚
+ */
DEFINE_INSN
setclassvariable
(ID id)
(VALUE val)
()
-/* "class variable access from toplevel" warning can be hooked. */
-// attr bool leaf = false; /* has rb_warning() */
{
vm_ensure_not_refinement_module(GET_SELF());
- rb_cvar_set(vm_get_cvar_base(vm_get_cref(GET_EP()), GET_CFP()), id, val);
+ rb_cvar_set(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id, val);
}
-/* Get constant variable id. If klass is Qnil and allow_nil is Qtrue, constants
- are searched in the current scope. Otherwise, get constant under klass
+/**
+ @c variable
+ @e
+ Get constant variable id. If klass is Qnil, constants
+ are searched in the current scope. If klass is Qfalse, constants
+ are searched as top level constants. Otherwise, get constant under klass
class or module.
+ @j 定数 id ã®å€¤ã‚’得る。
+ klass ㌠Qnil ãªã‚‰ã€ãã®ã‚¹ã‚³ãƒ¼ãƒ—ã§å¾—られる定数ã®å€¤ã‚’得る。
+ Qfalse ãªã‚‰ã€ãƒˆãƒƒãƒ—レベルスコープを得る。
+ ãれ以外ãªã‚‰ã€klass クラスã®ä¸‹ã®å®šæ•°ã‚’得る。
*/
DEFINE_INSN
getconstant
(ID id)
-(VALUE klass, VALUE allow_nil)
+(VALUE klass)
(VALUE val)
-/* getconstant can kick autoload */
-// attr bool leaf = false; /* has rb_autoload_load() */
{
- val = vm_get_ev_const(ec, klass, id, allow_nil == Qtrue, 0);
+ val = vm_get_ev_const(ec, klass, id, 0);
}
-/* Set constant variable id under cbase class or module.
+/**
+ @c variable
+ @e
+ Set constant variable id. If klass is Qfalse, constant
+ is able to access in this scope. if klass is Qnil, set
+ top level constant. otherwise, set constant under klass
+ class or module.
+
+ @j 定数 id ã®å€¤ã‚’ val ã«ã™ã‚‹ã€‚
+ klass ㌠Qfalse ãªã‚‰ã€ãã®ã‚¹ã‚³ãƒ¼ãƒ—ã§å¾—られる定数 id ã®å€¤ã‚’設定ã™ã‚‹ã€‚
+ Qnil ãªã‚‰ã€ãƒˆãƒƒãƒ—レベルスコープã®å€¤ã‚’設定ã™ã‚‹ã€‚
+ ãれ以外ãªã‚‰ã€klass クラスã®ä¸‹ã®å®šæ•°ã‚’設定ã™ã‚‹ã€‚
*/
DEFINE_INSN
setconstant
(ID id)
(VALUE val, VALUE cbase)
()
-/* Assigning an object to a constant is basically a leaf operation.
- * The problem is, assigning a Module instance to a constant _names_
- * that module. Naming involves string manipulations, which are
- * method calls. */
-// attr bool leaf = false; /* has StringValue() */
{
vm_check_if_namespace(cbase);
vm_ensure_not_refinement_module(GET_SELF());
rb_const_set(cbase, id, val);
}
-/* get global variable id. */
+/**
+ @c variable
+ @e get global variable id.
+ @j グローãƒãƒ«å¤‰æ•° id ã®å€¤ã‚’得る。
+ */
DEFINE_INSN
getglobal
(GENTRY entry)
()
(VALUE val)
-// attr bool leaf = leafness_of_getglobal(entry);
{
- struct rb_global_entry *gentry = (void *)entry;
- val = rb_gvar_get(gentry);
+ val = GET_GLOBAL((VALUE)entry);
}
-/* set global variable id as val. */
+/**
+ @c variable
+ @e set global variable id as val.
+ @j グローãƒãƒ«å¤‰æ•° id ã®å€¤ã‚’設定ã™ã‚‹ã€‚
+ */
DEFINE_INSN
setglobal
(GENTRY entry)
(VALUE val)
()
-// attr bool leaf = leafness_of_setglobal(entry);
{
- struct rb_global_entry *gentry = (void *)entry;
- rb_gvar_set(gentry, val);
+ SET_GLOBAL((VALUE)entry, val);
}
+
/**********************************************************/
/* deal with values */
/**********************************************************/
-/* put nil to stack. */
+/**
+ @c put
+ @e put nil to stack.
+ @j スタック㫠nil をプッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
putnil
()
@@ -323,7 +304,11 @@ putnil
val = Qnil;
}
-/* put self. */
+/**
+ @c put
+ @e put self.
+ @j スタック㫠self をプッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
putself
()
@@ -333,7 +318,11 @@ putself
val = GET_SELF();
}
-/* put some object.
+/**
+ @c put
+ @e put some object.
+ i.e. Fixnum, true, false, nil, and so on.
+ @j オブジェクト val をスタックã«ãƒ—ッシュã™ã‚‹ã€‚
i.e. Fixnum, true, false, nil, and so on.
*/
DEFINE_INSN
@@ -345,7 +334,12 @@ putobject
/* */
}
-/* put special object. "value_type" is for expansion. */
+/**
+ @c put
+ @e put special object. "value_type" is for expansion.
+ @j 特別ãªã‚ªãƒ–ジェクト val をスタックã«ãƒ—ッシュã™ã‚‹ã€‚
+ オブジェクトã®ç¨®é¡žã¯ value_type ã«ã‚ˆã‚‹ï¼Ž
+ */
DEFINE_INSN
putspecialobject
(rb_num_t value_type)
@@ -358,7 +352,25 @@ putspecialobject
val = vm_get_special_object(GET_EP(), type);
}
-/* put string val. string will be copied. */
+/**
+ @c put
+ @e put iseq value.
+ @j iseq をスタックã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
+DEFINE_INSN
+putiseq
+(ISEQ iseq)
+()
+(VALUE ret)
+{
+ ret = (VALUE)iseq;
+}
+
+/**
+ @c put
+ @e put string val. string will be copied.
+ @j 文字列をコピーã—ã¦ã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
putstring
(VALUE str)
@@ -368,31 +380,41 @@ putstring
val = rb_str_resurrect(str);
}
-/* put concatenate strings */
+/**
+ @c put
+ @e put concatenate strings
+ @j ã‚¹ã‚¿ãƒƒã‚¯ãƒˆãƒƒãƒ—ã®æ–‡å­—列を n 個連çµã—ï¼Œçµæžœã‚’スタックã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
concatstrings
(rb_num_t num)
(...)
-(VALUE val)
-/* This instruction can concat UTF-8 and binary strings, resulting in
- * Encoding::CompatiblityError. */
-// attr bool leaf = false; /* has rb_enc_cr_str_buf_cat() */
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
+(VALUE val) // inc += 1 - num;
{
val = rb_str_concat_literals(num, STACK_ADDR_FROM_TOP(num));
+ POPN(num);
}
-/* push the result of to_s. */
+/**
+ @c put
+ @e push the result of to_s.
+ @j to_s ã®çµæžœã‚’スタックã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
tostring
()
(VALUE val, VALUE str)
(VALUE val)
{
+ VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
val = rb_obj_as_string_result(str, val);
}
-/* Freeze (dynamically) created strings. if debug_info is given, set it. */
+/**
+ @c put
+ @e Freeze (dynamically) created strings. if debug_info is given, set it.
+ @j (埋ã‚è¾¼ã¿ï¼‰æ–‡å­—列を freeze ã™ã‚‹ã€‚ã‚‚ã—ã€debug_info ãŒä¸Žãˆã‚‰ã‚Œã¦ã„れã°ã€ãれを設定ã™ã‚‹ã€‚
+ */
DEFINE_INSN
freezestring
(VALUE debug_info)
@@ -402,25 +424,32 @@ freezestring
vm_freezestring(str, debug_info);
}
-/* compile str to Regexp and push it.
+/**
+ @c put
+ @e compile str to Regexp and push it.
opt is the option for the Regexp.
+ @j 文字列 str ã‚’æ­£è¦è¡¨ç¾ã«ã‚³ãƒ³ãƒ‘イルã—ã¦ã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ—ッシュã™ã‚‹ã€‚
+ コンパイル時,opt ã‚’æ­£è¦è¡¨ç¾ã®ã‚ªãƒ—ションã¨ã™ã‚‹ã€‚
*/
DEFINE_INSN
toregexp
(rb_num_t opt, rb_num_t cnt)
(...)
-(VALUE val)
-/* This instruction can raise RegexpError, thus can call
- * RegexpError#initialize */
-// attr bool leaf = false;
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)cnt;
+(VALUE val) // inc += 1 - cnt;
{
+ VALUE rb_reg_new_ary(VALUE ary, int options);
+ VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
const VALUE ary = rb_ary_tmp_new_from_values(0, cnt, STACK_ADDR_FROM_TOP(cnt));
+ POPN(cnt);
val = rb_reg_new_ary(ary, (int)opt);
rb_ary_clear(ary);
}
-/* intern str to Symbol and push it. */
+/**
+ @c put
+ @e intern str to Symbol and push it.
+ @j 文字列 str をシンボルã«å¤‰æ›ã—ã¦ã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
intern
()
@@ -430,60 +459,38 @@ intern
sym = rb_str_intern(str);
}
-/* put new array initialized with num values on the stack. */
+/**
+ @c put
+ @e put new array initialized with num values on the stack.
+ @j æ–°ã—ã„é…列をスタック上㮠num 個ã®å€¤ã§åˆæœŸåŒ–ã—ã¦ç”Ÿæˆã—プッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
newarray
(rb_num_t num)
(...)
-(VALUE val)
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
+(VALUE val) // inc += 1 - num;
{
val = rb_ary_new4(num, STACK_ADDR_FROM_TOP(num));
+ POPN(num);
}
-/* put new array initialized with num values on the stack. There
- should be at least one element on the stack, and the top element
- should be a hash. If the top element is empty, it is not
- included in the array.
+/**
+ @c put
+ @e dup array
+ @j é…列 ary ã‚’ dup ã—ã¦ã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ—ッシュã™ã‚‹ã€‚
*/
DEFINE_INSN
-newarraykwsplat
-(rb_num_t num)
-(...)
-(VALUE val)
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
-{
- if (RHASH_EMPTY_P(*STACK_ADDR_FROM_TOP(1))) {
- val = rb_ary_new4(num-1, STACK_ADDR_FROM_TOP(num));
- }
- else {
- val = rb_ary_new4(num, STACK_ADDR_FROM_TOP(num));
- }
-}
-
-/* dup array */
-DEFINE_INSN
duparray
(VALUE ary)
()
(VALUE val)
{
- RUBY_DTRACE_CREATE_HOOK(ARRAY, RARRAY_LEN(ary));
val = rb_ary_resurrect(ary);
}
-/* dup hash */
-DEFINE_INSN
-duphash
-(VALUE hash)
-()
-(VALUE val)
-{
- RUBY_DTRACE_CREATE_HOOK(HASH, RHASH_SIZE(hash) << 1);
- val = rb_hash_resurrect(hash);
-}
-
-/* if TOS is an array expand, expand it to num objects.
+/**
+ @c put
+ @e if TOS is an array expand, expand it to num objects.
if the number of the array is less than num, push nils to fill.
if it is greater than num, exceeding elements are dropped.
unless TOS is an array, push num - 1 nils.
@@ -491,48 +498,63 @@ duphash
flag: 0x01 - rest args array
flag: 0x02 - for postarg
flag: 0x04 - reverse?
+ @j スタックトップã®ã‚ªãƒ–ジェクトãŒé…列ã§ã‚れã°ã€ãれを展開ã™ã‚‹ã€‚
+ é…列オブジェクトã®è¦ç´ æ•°ãŒ num以下ãªã‚‰ã°ã€ä»£ã‚り㫠nil ã‚’ç©ã‚€ã€‚num以上ãªã‚‰ã€
+ num以上ã®è¦ç´ ã¯åˆ‡ã‚Šæ¨ã¦ã‚‹ã€‚
+ é…列オブジェクトã§ãªã‘れã°ã€num - 1 個㮠nil ã‚’ç©ã‚€ã€‚
+ ã‚‚ã— flag ãŒçœŸãªã‚‰ã€æ®‹ã‚Šè¦ç´ ã®é…列をç©ã‚€
+ flag: 0x01 - 最後をé…列ã«
+ flag: 0x02 - postarg 用
+ flag: 0x04 - reverse?
*/
DEFINE_INSN
expandarray
(rb_num_t num, rb_num_t flag)
(..., VALUE ary)
-(...)
-// attr bool leaf = false; /* has rb_check_array_type() */
-// attr rb_snum_t sp_inc = (rb_snum_t)num - 1 + (flag & 1 ? 1 : 0);
+(...) // inc += num - 1 + (flag & 1 ? 1 : 0);
{
- vm_expandarray(GET_SP(), ary, num, (int)flag);
+ vm_expandarray(GET_CFP(), ary, num, (int)flag);
}
-/* concat two arrays */
+/**
+ @c put
+ @e concat two arrays
+ @j 二ã¤ã®é…列 ary1, ary2 を連çµã—スタックã¸ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
concatarray
()
(VALUE ary1, VALUE ary2)
(VALUE ary)
-// attr bool leaf = false; /* has rb_check_array_type() */
{
ary = vm_concat_array(ary1, ary2);
}
-/* call to_a on array ary to splat */
+/**
+ @c put
+ @e call to_a on array ary to splat
+ @j splat ã®ãŸã‚ã«é…列 ary ã«å¯¾ã—㦠to_a を呼ã³å‡ºã™ã€‚
+ */
DEFINE_INSN
splatarray
(VALUE flag)
(VALUE ary)
(VALUE obj)
-// attr bool leaf = false; /* has rb_check_array_type() */
{
obj = vm_splat_array(flag, ary);
}
-/* put new Hash from n elements. n must be an even number. */
+/**
+ @c put
+ @e put new Hash from n elements. n must be an even number.
+ @j æ–°ã—ã„ãƒãƒƒã‚·ãƒ¥ã‚’スタックトップ㮠n å€‹ã‚’åˆæœŸå€¤ã¨ã—ã¦ç”Ÿæˆã™ã‚‹ã€‚
+ n ã¯ã‚­ãƒ¼ã¨å€¤ã®ãƒšã‚¢ãªã®ã§ 2 ã®å€æ•°ã§ãªã‘れã°ãªã‚‰ãªã„。
+ */
DEFINE_INSN
newhash
(rb_num_t num)
(...)
-(VALUE val)
-// attr bool leaf = false; /* has rb_hash_key_str() */
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
+(VALUE val) // inc += 1 - num;
{
RUBY_DTRACE_CREATE_HOOK(HASH, num);
@@ -541,16 +563,19 @@ newhash
if (num) {
rb_hash_bulk_insert(num, STACK_ADDR_FROM_TOP(num), val);
}
+ POPN(num);
}
-/* put new Range object.(Range.new(low, high, flag)) */
+/**
+ @c put
+ @e put new Range object.(Range.new(low, high, flag))
+ @j Range.new(low, high, flag) ã®ã‚ˆã†ãªã‚ªãƒ–ジェクトを生æˆã—スタックã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
newrange
(rb_num_t flag)
(VALUE low, VALUE high)
(VALUE val)
-/* rb_range_new() exercises "bad value for range" check. */
-// attr bool leaf = false; /* see also: range.c:range_init() */
{
val = rb_range_new(low, high, (int)flag);
}
@@ -559,7 +584,11 @@ newrange
/* deal with stack operation */
/**********************************************************/
-/* pop from stack. */
+/**
+ @c stack
+ @e pop from stack.
+ @j スタックã‹ã‚‰ä¸€ã¤ãƒãƒƒãƒ—ã™ã‚‹ã€‚
+ */
DEFINE_INSN
pop
()
@@ -570,7 +599,11 @@ pop
/* none */
}
-/* duplicate stack top. */
+/**
+ @c stack
+ @e duplicate stack top.
+ @j スタックトップをコピーã—ã¦ã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
dup
()
@@ -580,21 +613,30 @@ dup
val1 = val2 = val;
}
-/* duplicate stack top n elements */
+/**
+ @c stack
+ @e duplicate stack top n elements
+ @j スタックトップ㮠n 個をコピーã—ã¦ã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
dupn
(rb_num_t n)
(...)
-(...)
-// attr rb_snum_t sp_inc = n;
+(...) // inc += n;
{
void *dst = GET_SP();
void *src = STACK_ADDR_FROM_TOP(n);
+ INC_SP(n); /* alloca */
MEMCPY(dst, src, VALUE, n);
}
-/* swap top 2 vals */
+
+/**
+ @c stack
+ @e swap top 2 vals
+ @j スタックトップ㮠2 ã¤ã®å€¤ã‚’交æ›ã™ã‚‹ã€‚
+ */
DEFINE_INSN
swap
()
@@ -604,13 +646,16 @@ swap
/* none */
}
-/* reverse stack top N order. */
+/**
+ @c stack
+ @e reverse stack top N order.
+ @j スタックトップ㮠n 個ã®å€¤ã‚’逆転ã™ã‚‹ã€‚
+ */
DEFINE_INSN
reverse
(rb_num_t n)
(...)
-(...)
-// attr rb_snum_t sp_inc = 0;
+(...) // inc += 0;
{
rb_num_t i;
VALUE *sp = STACK_ADDR_FROM_TOP(n);
@@ -623,83 +668,105 @@ reverse
}
}
-/* for stack caching. */
-DEFINE_INSN_IF(STACK_CACHING)
+/**
+ @c stack
+ @e for stack caching.
+ @j スタックキャッシングã®çŠ¶æ…‹ã‚’èª¿æ•´ã™ã‚‹ãŸã‚ã«å¿…è¦ãªå‘½ä»¤ã€‚
+ */
+DEFINE_INSN
reput
()
(..., VALUE val)
-(VALUE val)
-// attr rb_snum_t sp_inc = 0;
+(VALUE val) // inc += 0;
{
/* none */
}
-/* get nth stack value from stack top */
+/**
+ @c stack
+ @e get nth stack value from stack top
+ @j スタックトップã‹ã‚‰ n 個目をスタックã«ãƒ—ッシュã™ã‚‹ã€‚
+ */
DEFINE_INSN
topn
(rb_num_t n)
(...)
-(VALUE val)
-// attr rb_snum_t sp_inc = 1;
+(VALUE val) // inc += 1;
{
val = TOPN(n);
}
-/* set Nth stack entry to stack top */
+/**
+ @c stack
+ @e set Nth stack entry to stack top
+ @j スタックトップã®å€¤ã‚’ n 個目ã®ã‚¹ã‚¿ãƒƒã‚¯ã«ã‚³ãƒ”ー
+ */
DEFINE_INSN
setn
(rb_num_t n)
(..., VALUE val)
-(VALUE val)
-// attr rb_snum_t sp_inc = 0;
+(VALUE val) // inc += 0
{
- TOPN(n) = val;
+ TOPN(n-1) = val;
}
-/* empty current stack */
+/**
+ @c stack
+ @e empty current stack
+ @j current stack を空ã«ã™ã‚‹ã€‚
+ */
DEFINE_INSN
adjuststack
(rb_num_t n)
(...)
-(...)
-// attr rb_snum_t sp_inc = -(rb_snum_t)n;
+(...) // inc -= n
{
- /* none */
+ DEC_SP(n);
}
+
/**********************************************************/
/* deal with setting */
/**********************************************************/
-/* defined? */
+/**
+ @c setting
+ @e defined?
+ @j defined? を行ã†ã€‚
+ */
DEFINE_INSN
defined
(rb_num_t op_type, VALUE obj, VALUE needstr)
(VALUE v)
(VALUE val)
-// attr bool leaf = leafness_of_defined(op_type);
{
val = vm_defined(ec, GET_CFP(), op_type, obj, needstr, v);
}
-/* check `target' matches `pattern'.
+/**
+ @c setting
+ @e check `target' matches `pattern'.
`flag & VM_CHECKMATCH_TYPE_MASK' describe how to check pattern.
VM_CHECKMATCH_TYPE_WHEN: ignore target and check pattern is truthy.
VM_CHECKMATCH_TYPE_CASE: check `patten === target'.
- VM_CHECKMATCH_TYPE_RESCUE: check `pattern.kind_op?(Module) && pattern === target'.
+ VM_CHECKMATCH_TYPE_RESCUE: check `pattern.kind_op?(Module) && pattern == target'.
if `flag & VM_CHECKMATCH_ARRAY' is not 0, then `patten' is array of patterns.
+ @j see above comments.
*/
DEFINE_INSN
checkmatch
(rb_num_t flag)
(VALUE target, VALUE pattern)
(VALUE result)
-// attr bool leaf = leafness_of_checkmatch(flag);
{
result = vm_check_match(ec, target, pattern, flag);
}
-/* check keywords are specified or not. */
+/**
+ @c setting
+ @e check keywords are specified or not.
+ @j ã‚­ãƒ¼ãƒ¯ãƒ¼ãƒ‰ãŒæŒ‡å®šã•れã¦ã„ã‚‹ã‹ã©ã†ã‹ãƒã‚§ãƒƒã‚¯ã™ã‚‹
+ */
DEFINE_INSN
checkkeyword
(lindex_t kw_bits_index, lindex_t keyword_index)
@@ -709,22 +776,35 @@ checkkeyword
ret = vm_check_keyword(kw_bits_index, keyword_index, GET_EP());
}
-/* check if val is type. */
+/**
+ @c setting
+ @e fire a coverage event (currently, this is used for line coverage and branch coverage)
+ @j ã‚«ãƒãƒ¬ãƒƒã‚¸ã‚¤ãƒ™ãƒ³ãƒˆã‚’ trace ã™ã‚‹
+ */
DEFINE_INSN
-checktype
-(rb_num_t type)
-(VALUE val)
-(VALUE ret)
+tracecoverage
+(rb_num_t nf, VALUE data)
+()
+()
{
- ret = (TYPE(val) == (int)type) ? Qtrue : Qfalse;
+ rb_event_flag_t flag = (rb_event_flag_t)nf;
+
+ vm_dtrace(flag, ec);
+ EXEC_EVENT_HOOK(ec, flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */, data);
}
/**********************************************************/
/* deal with control flow 1: class/module */
/**********************************************************/
-/* enter class definition scope. if super is Qfalse, and class
+/**
+ @c class/module
+ @e
+ enter class definition scope. if super is Qfalse, and class
"klass" is defined, it's redefine. otherwise, define "klass" class.
+ @j クラス定義スコープã¸ç§»è¡Œã™ã‚‹ã€‚
+ ã‚‚ã— super ㌠Qfalse ã§ klassクラスãŒå®šç¾©ã•れã¦ã„れã°å†å®šç¾©ã§ã‚る。
+ ãã†ã§ãªã‘れã°ã€klass クラスを定義ã™ã‚‹ã€‚
*/
DEFINE_INSN
defineclass
@@ -747,104 +827,54 @@ defineclass
NEXT_INSN();
}
-DEFINE_INSN
-definemethod
-(ID id, ISEQ iseq)
-()
-()
-{
- vm_define_method(ec, Qnil, id, (VALUE)iseq, FALSE);
-}
-
-DEFINE_INSN
-definesmethod
-(ID id, ISEQ iseq)
-(VALUE obj)
-()
-{
- vm_define_method(ec, obj, id, (VALUE)iseq, TRUE);
-}
/**********************************************************/
/* deal with control flow 2: method/iterator */
/**********************************************************/
-/* invoke method. */
+/**
+ @c method/iterator
+ @e invoke method.
+ @j メソッド呼ã³å‡ºã—を行ã†ã€‚ci ã«å¿…è¦ãªæƒ…å ±ãŒæ ¼ç´ã•れã¦ã„る。
+ */
DEFINE_INSN
send
-(CALL_DATA cd, ISEQ blockiseq)
+(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
(...)
-(VALUE val)
-// attr rb_snum_t sp_inc = sp_inc_of_sendish(&cd->ci);
-// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
+(VALUE val) // inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
{
- VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), &cd->ci, blockiseq, false);
- val = vm_sendish(ec, GET_CFP(), cd, bh, vm_search_method_wrap);
+ struct rb_calling_info calling;
- if (val == Qundef) {
- RESTORE_REGS();
- NEXT_INSN();
- }
-}
-
-/* Invoke method without block */
-DEFINE_INSN
-opt_send_without_block
-(CALL_DATA cd)
-(...)
-(VALUE val)
-// attr bool handles_sp = true;
-// attr rb_snum_t sp_inc = sp_inc_of_sendish(&cd->ci);
-// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
-{
- VALUE bh = VM_BLOCK_HANDLER_NONE;
- val = vm_sendish(ec, GET_CFP(), cd, bh, vm_search_method_wrap);
-
- if (val == Qundef) {
- RESTORE_REGS();
- NEXT_INSN();
- }
+ vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, FALSE);
+ vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
+ CALL_METHOD(&calling, ci, cc);
}
DEFINE_INSN
opt_str_freeze
-(VALUE str, CALL_DATA cd)
+(VALUE str)
()
(VALUE val)
{
- val = vm_opt_str_freeze(str, BOP_FREEZE, idFreeze);
-
- if (val == Qundef) {
- PUSH(rb_str_resurrect(str));
- CALL_SIMPLE_METHOD();
+ if (BASIC_OP_UNREDEFINED_P(BOP_FREEZE, STRING_REDEFINED_OP_FLAG)) {
+ val = str;
}
-}
-
-/* optimized nil? */
-DEFINE_INSN
-opt_nil_p
-(CALL_DATA cd)
-(VALUE recv)
-(VALUE val)
-{
- val = vm_opt_nil_p(cd, recv);
-
- if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ else {
+ val = rb_funcall(rb_str_resurrect(str), idFreeze, 0);
}
}
DEFINE_INSN
opt_str_uminus
-(VALUE str, CALL_DATA cd)
+(VALUE str)
()
(VALUE val)
{
- val = vm_opt_str_freeze(str, BOP_UMINUS, idUMinus);
-
- if (val == Qundef) {
- PUSH(rb_str_resurrect(str));
- CALL_SIMPLE_METHOD();
+ if (BASIC_OP_UNREDEFINED_P(BOP_UMINUS, STRING_REDEFINED_OP_FLAG)) {
+ val = str;
+ }
+ else {
+ val = rb_funcall(rb_str_resurrect(str), idUMinus, 0);
}
}
@@ -852,89 +882,102 @@ DEFINE_INSN
opt_newarray_max
(rb_num_t num)
(...)
-(VALUE val)
-/* This instruction typically has no funcalls. But it compares array
- * contents each other by nature. That part could call methods when
- * necessary. No way to detect such method calls beforehand. We
- * cannot but mark it being not leaf. */
-// attr bool leaf = false; /* has rb_funcall() */
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
+(VALUE val) // inc += 1 - num;
{
val = vm_opt_newarray_max(num, STACK_ADDR_FROM_TOP(num));
+ POPN(num);
}
DEFINE_INSN
opt_newarray_min
(rb_num_t num)
(...)
-(VALUE val)
-/* Same discussion as opt_newarray_max. */
-// attr bool leaf = false; /* has rb_funcall() */
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
+(VALUE val) // inc += 1 - num;
{
val = vm_opt_newarray_min(num, STACK_ADDR_FROM_TOP(num));
+ POPN(num);
+}
+
+/**
+ @c optimize
+ @e Invoke method without block
+ @j ブロックãªã—ã§ãƒ¡ã‚½ãƒƒãƒ‰å‘¼ã³å‡ºã—を行ã†ã€‚
+ */
+DEFINE_INSN
+opt_send_without_block
+(CALL_INFO ci, CALL_CACHE cc)
+(...)
+(VALUE val) // inc += -ci->orig_argc;
+{
+ struct rb_calling_info calling;
+ calling.block_handler = VM_BLOCK_HANDLER_NONE;
+ vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
+ CALL_METHOD(&calling, ci, cc);
}
-/* super(args) # args.size => num */
+/**
+ @c method/iterator
+ @e super(args) # args.size => num
+ @j super を実行ã™ã‚‹ã€‚ci ã«å¿…è¦ãªæƒ…å ±ãŒæ ¼ç´ã•れã¦ã„る。
+ */
DEFINE_INSN
invokesuper
-(CALL_DATA cd, ISEQ blockiseq)
+(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
(...)
-(VALUE val)
-// attr rb_snum_t sp_inc = sp_inc_of_sendish(&cd->ci);
-// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
+(VALUE val) // inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
{
- VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), &cd->ci, blockiseq, true);
- val = vm_sendish(ec, GET_CFP(), cd, bh, vm_search_super_method);
+ struct rb_calling_info calling;
+ calling.argc = ci->orig_argc;
- if (val == Qundef) {
- RESTORE_REGS();
- NEXT_INSN();
- }
+ vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, TRUE);
+ calling.recv = GET_SELF();
+ vm_search_super_method(ec, GET_CFP(), &calling, ci, cc);
+ CALL_METHOD(&calling, ci, cc);
}
-/* yield(args) */
+/**
+ @c method/iterator
+ @e yield(args)
+ @j yield を実行ã™ã‚‹ã€‚
+ */
DEFINE_INSN
invokeblock
-(CALL_DATA cd)
+(CALL_INFO ci)
(...)
-(VALUE val)
-// attr bool handles_sp = true;
-// attr rb_snum_t sp_inc = sp_inc_of_invokeblock(&cd->ci);
-// attr rb_snum_t comptime_sp_inc = sp_inc_of_invokeblock(ci);
+(VALUE val) // inc += 1 - ci->orig_argc;
{
- if (UNLIKELY(cd->cc.call != vm_invokeblock_i)) {
- cd->cc.call = vm_invokeblock_i; // check before setting to avoid CoW
- }
-
- VALUE bh = VM_BLOCK_HANDLER_NONE;
- val = vm_sendish(ec, GET_CFP(), cd, bh, vm_search_invokeblock);
+ struct rb_calling_info calling;
+ calling.argc = ci->orig_argc;
+ calling.block_handler = VM_BLOCK_HANDLER_NONE;
+ calling.recv = GET_SELF();
+ val = vm_invoke_block(ec, GET_CFP(), &calling, ci);
if (val == Qundef) {
- RESTORE_REGS();
- NEXT_INSN();
+ RESTORE_REGS();
+ NEXT_INSN();
}
}
-/* return from this scope. */
+/**
+ @c method/iterator
+ @e return from this scope.
+ @j ã“ã®ã‚¹ã‚³ãƒ¼ãƒ—ã‹ã‚‰æŠœã‘る。
+ */
DEFINE_INSN
leave
()
(VALUE val)
(VALUE val)
-/* This is super surprising but when leaving from a frame, we check
- * for interrupts. If any, that should be executed on top of the
- * current execution context. This is a method call. */
-// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
-// attr bool handles_sp = true;
{
if (OPT_CHECKED_RUN) {
- const VALUE *const bp = vm_base_ptr(GET_CFP());
- if (GET_SP() != bp) {
- vm_stack_consistency_error(ec, GET_CFP(), bp);
+ const VALUE *const bp = vm_base_ptr(reg_cfp);
+ if (reg_cfp->sp != bp) {
+ vm_stack_consistency_error(ec, reg_cfp, bp);
}
}
+ RUBY_VM_CHECK_INTS(ec);
+
if (vm_pop_frame(ec, GET_CFP(), GET_EP())) {
#if OPT_CALL_THREADED_CODE
rb_ec_thread_ptr(ec)->retval = val;
@@ -952,15 +995,18 @@ leave
/* deal with control flow 3: exception */
/**********************************************************/
-/* longjump */
+/**
+ @c exception
+ @e longjump
+ @j 大域ジャンプを行ã†ã€‚
+ */
DEFINE_INSN
throw
(rb_num_t throw_state)
(VALUE throwobj)
(VALUE val)
-/* Same discussion as leave. */
-// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
+ RUBY_VM_CHECK_INTS(ec);
val = vm_throw(ec, GET_CFP(), throw_state, throwobj);
THROW_EXCEPTION(val);
/* unreachable */
@@ -970,27 +1016,31 @@ throw
/* deal with control flow 4: local jump */
/**********************************************************/
-/* set PC to (PC + dst). */
+/**
+ @c jump
+ @e set PC to (PC + dst).
+ @j PC ã‚’ (PC + dst) ã«ã™ã‚‹ã€‚
+ */
DEFINE_INSN
jump
(OFFSET dst)
()
()
-/* Same discussion as leave. */
-// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
RUBY_VM_CHECK_INTS(ec);
JUMP(dst);
}
-/* if val is not false or nil, set PC to (PC + dst). */
+/**
+ @c jump
+ @e if val is not false or nil, set PC to (PC + dst).
+ @j ã‚‚ã— val ㌠false ã‹ nil ã§ãªã‘れã°ã€PC ã‚’ (PC + dst) ã«ã™ã‚‹ã€‚
+ */
DEFINE_INSN
branchif
(OFFSET dst)
(VALUE val)
()
-/* Same discussion as jump. */
-// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
if (RTEST(val)) {
RUBY_VM_CHECK_INTS(ec);
@@ -998,14 +1048,16 @@ branchif
}
}
-/* if val is false or nil, set PC to (PC + dst). */
+/**
+ @c jump
+ @e if val is false or nil, set PC to (PC + dst).
+ @j ã‚‚ã— val ㌠false ã‹ nil ãªã‚‰ã°ã€PC ã‚’ (PC + dst) ã«ã™ã‚‹ã€‚
+ */
DEFINE_INSN
branchunless
(OFFSET dst)
(VALUE val)
()
-/* Same discussion as jump. */
-// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
if (!RTEST(val)) {
RUBY_VM_CHECK_INTS(ec);
@@ -1013,14 +1065,16 @@ branchunless
}
}
-/* if val is nil, set PC to (PC + dst). */
+/**
+ @c jump
+ @e if val is nil, set PC to (PC + dst).
+ @j ã‚‚ã— val ㌠nil ãªã‚‰ã°ã€PC ã‚’ (PC + dst) ã«ã™ã‚‹ã€‚
+ */
DEFINE_INSN
branchnil
(OFFSET dst)
(VALUE val)
()
-/* Same discussion as jump. */
-// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
if (NIL_P(val)) {
RUBY_VM_CHECK_INTS(ec);
@@ -1028,29 +1082,52 @@ branchnil
}
}
+/**
+ @c jump
+ @e if val is type, set PC to (PC + dst).
+ @j ã‚‚ã— val ㌠type ãªã‚‰ã°ã€PC ã‚’ (PC + dst) ã«ã™ã‚‹ã€‚
+ */
+DEFINE_INSN
+branchiftype
+(rb_num_t type, OFFSET dst)
+(VALUE val)
+()
+{
+ if (TYPE(val) == (int)type) {
+ RUBY_VM_CHECK_INTS(ec);
+ JUMP(dst);
+ }
+}
+
+
/**********************************************************/
/* for optimize */
/**********************************************************/
-/* push inline-cached value and go to dst if it is valid */
+/**
+ @c optimize
+ @e push inline-cached value and go to dst if it is valid
+ @j ã‚¤ãƒ³ãƒ©ã‚¤ãƒ³ã‚­ãƒ£ãƒƒã‚·ãƒ¥ãŒæœ‰åйãªã‚‰ã€å€¤ã‚’スタックã«ãƒ—ッシュã—㦠dst ã¸ã‚¸ãƒ£ãƒ³ãƒ—ã™ã‚‹ã€‚
+ */
DEFINE_INSN
-opt_getinlinecache
+getinlinecache
(OFFSET dst, IC ic)
()
(VALUE val)
{
- if (vm_ic_hit_p(ic, GET_EP())) {
- val = ic->value;
+ val = vm_ic_hit_p(ic, GET_EP());
+ if (val != Qnil) {
JUMP(dst);
}
- else {
- val = Qnil;
- }
}
-/* set inline cache */
+/**
+ @c optimize
+ @e set inline cache
+ @j インラインキャッシュã®å€¤ã‚’設定ã™ã‚‹ã€‚
+ */
DEFINE_INSN
-opt_setinlinecache
+setinlinecache
(IC ic)
(VALUE val)
(VALUE val)
@@ -1058,23 +1135,30 @@ opt_setinlinecache
vm_ic_update(ic, val, GET_EP());
}
-/* run iseq only once */
+/**
+ @c optimize
+ @e run iseq only once
+ @j once を実ç¾ã™ã‚‹ã€‚
+ */
DEFINE_INSN
once
-(ISEQ iseq, ISE ise)
+(ISEQ iseq, IC ic)
()
(VALUE val)
{
- val = vm_once_dispatch(ec, iseq, ise);
+ val = vm_once_dispatch(ec, iseq, ic);
}
-/* case dispatcher, jump by table if possible */
+/**
+ @c optimize
+ @e case dispatcher, jump by table if possible
+ @j case æ–‡ã§ã€å¯èƒ½ãªã‚‰è¡¨å¼•ãã§ã‚¸ãƒ£ãƒ³ãƒ—ã™ã‚‹ã€‚
+ */
DEFINE_INSN
opt_case_dispatch
(CDHASH hash, OFFSET else_offset)
(..., VALUE key)
-()
-// attr rb_snum_t sp_inc = -1;
+() // inc += -1;
{
OFFSET dst = vm_case_dispatch(hash, else_offset, key);
@@ -1085,255 +1169,311 @@ opt_case_dispatch
/** simple functions */
-/* optimized X+Y. */
+/**
+ @c optimize
+ @e optimized X+Y.
+ @j 最é©åŒ–ã•れ㟠X+Y。
+ */
DEFINE_INSN
opt_plus
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_plus(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X-Y. */
+/**
+ @c optimize
+ @e optimized X-Y.
+ @j 最é©åŒ–ã•れ㟠X-Y。
+ */
DEFINE_INSN
opt_minus
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_minus(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X*Y. */
+/**
+ @c optimize
+ @e optimized X*Y.
+ @j 最é©åŒ–ã•れ㟠X*Y。
+ */
DEFINE_INSN
opt_mult
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_mult(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X/Y. */
+/**
+ @c optimize
+ @e optimized X/Y.
+ @j 最é©åŒ–ã•れ㟠X/Y。
+ */
DEFINE_INSN
opt_div
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
-/* In case of division by zero, it raises. Thus
- * ZeroDivisionError#initialize is called. */
-// attr bool leaf = false;
{
val = vm_opt_div(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X%Y. */
+/**
+ @c optimize
+ @e optimized X%Y.
+ @j 最é©åŒ–ã•れ㟠X%Y。
+ */
DEFINE_INSN
opt_mod
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
-/* Same discussion as opt_mod. */
-// attr bool leaf = false;
{
val = vm_opt_mod(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X==Y. */
+/**
+ @c optimize
+ @e optimized X==Y.
+ @j 最é©åŒ–ã•れ㟠X==Y。
+ */
DEFINE_INSN
opt_eq
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
- val = opt_eq_func(recv, obj, cd);
+ val = opt_eq_func(recv, obj, ci, cc);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X!=Y. */
+/**
+ @c optimize
+ @e optimized X!=Y.
+ @j 最é©åŒ–ã•れ㟠X!=Y。
+ */
DEFINE_INSN
opt_neq
-(CALL_DATA cd_eq, CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc, CALL_INFO ci_eq, CALL_CACHE cc_eq)
(VALUE recv, VALUE obj)
(VALUE val)
{
- val = vm_opt_neq(cd, cd_eq, recv, obj);
+ val = vm_opt_neq(ci, cc, ci_eq, cc_eq, recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X<Y. */
+/**
+ @c optimize
+ @e optimized X<Y.
+ @j 最é©åŒ–ã•れ㟠X<Y。
+ */
DEFINE_INSN
opt_lt
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_lt(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X<=Y. */
+/**
+ @c optimize
+ @e optimized X<=Y.
+ @j 最é©åŒ–ã•れ㟠X<=Y。
+ */
DEFINE_INSN
opt_le
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_le(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X>Y. */
+/**
+ @c optimize
+ @e optimized X>Y.
+ @j 最é©åŒ–ã•れ㟠X>Y。
+ */
DEFINE_INSN
opt_gt
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_gt(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized X>=Y. */
+/**
+ @c optimize
+ @e optimized X>=Y.
+ @j 最é©åŒ–ã•れ㟠X>=Y。
+ */
DEFINE_INSN
opt_ge
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_ge(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* << */
+/**
+ @c optimize
+ @e <<
+ @j 最é©åŒ–ã•れ㟠X<<Y。
+ */
DEFINE_INSN
opt_ltlt
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
-/* This instruction can append an integer, as a codepoint, into a
- * string. Then what happens if that codepoint does not exist in the
- * string's encoding? Of course an exception. That's not a leaf. */
-// attr bool leaf = false; /* has "invalid codepoint" exception */
{
val = vm_opt_ltlt(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
- }
-}
-
-/* optimized X&Y. */
-DEFINE_INSN
-opt_and
-(CALL_DATA cd)
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- val = vm_opt_and(recv, obj);
-
- if (val == Qundef) {
- CALL_SIMPLE_METHOD();
- }
-}
-
-/* optimized X|Y. */
-DEFINE_INSN
-opt_or
-(CALL_DATA cd)
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- val = vm_opt_or(recv, obj);
-
- if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* [] */
+/**
+ @c optimize
+ @e []
+ @j 最é©åŒ–ã•れ㟠recv[obj]。
+ */
DEFINE_INSN
opt_aref
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj)
(VALUE val)
-/* This is complicated. In case of hash, vm_opt_aref() resorts to
- * rb_hash_aref(). If `recv` has no `obj`, this function then yields
- * default_proc. This is a method call. So opt_aref is
- * (surprisingly) not leaf. */
-// attr bool leaf = false; /* has rb_funcall() */ /* calls #yield */
{
val = vm_opt_aref(recv, obj);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* recv[obj] = set */
+/**
+ @c optimize
+ @e recv[obj] = set
+ @j 最é©åŒ–ã•れ㟠recv[obj] = set。
+ */
DEFINE_INSN
opt_aset
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv, VALUE obj, VALUE set)
(VALUE val)
-/* This is another story than opt_aref. When vm_opt_aset() resorts
- * to rb_hash_aset(), which should call #hash for `obj`. */
-// attr bool leaf = false; /* has rb_funcall() */ /* calls #hash */
{
val = vm_opt_aset(recv, obj, set);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ PUSH(obj);
+ PUSH(set);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* recv[str] = set */
+/**
+ @c optimize
+ @e recv[str] = set
+ @j 最é©åŒ–ã•れ㟠recv[str] = set。
+ */
DEFINE_INSN
opt_aset_with
-(VALUE key, CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc, VALUE key)
(VALUE recv, VALUE val)
(VALUE val)
-/* Same discussion as opt_aset. */
-// attr bool leaf = false; /* has rb_funcall() */ /* calls #hash */
{
VALUE tmp = vm_opt_aset_with(recv, key, val);
@@ -1341,126 +1481,181 @@ opt_aset_with
val = tmp;
}
else {
-#ifndef MJIT_HEADER
- TOPN(0) = rb_str_resurrect(key);
+ /* other */
+ PUSH(recv);
+ PUSH(rb_str_resurrect(key));
PUSH(val);
-#endif
- CALL_SIMPLE_METHOD();
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* recv[str] */
+/**
+ @c optimize
+ @e recv[str]
+ @j 最é©åŒ–ã•れ㟠recv[str]。
+ */
DEFINE_INSN
opt_aref_with
-(VALUE key, CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc, VALUE key)
(VALUE recv)
(VALUE val)
-/* Same discussion as opt_aref. */
-// attr bool leaf = false; /* has rb_funcall() */ /* calls #yield */
{
val = vm_opt_aref_with(recv, key);
if (val == Qundef) {
-#ifndef MJIT_HEADER
+ /* other */
+ PUSH(recv);
PUSH(rb_str_resurrect(key));
-#endif
- CALL_SIMPLE_METHOD();
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized length */
+/**
+ @c optimize
+ @e optimized length
+ @j 最é©åŒ–ã•れ㟠recv.length()。
+ */
DEFINE_INSN
opt_length
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv)
(VALUE val)
{
val = vm_opt_length(recv, BOP_LENGTH);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized size */
+/**
+ @c optimize
+ @e optimized size
+ @j 最é©åŒ–ã•れ㟠recv.size()。
+ */
DEFINE_INSN
opt_size
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv)
(VALUE val)
{
val = vm_opt_length(recv, BOP_SIZE);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized empty? */
+/**
+ @c optimize
+ @e optimized empty?
+ @j 最é©åŒ–ã•れ㟠recv.empty?()。
+ */
DEFINE_INSN
opt_empty_p
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv)
(VALUE val)
{
val = vm_opt_empty_p(recv);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized succ */
+/**
+ @c optimize
+ @e optimized succ
+ @j 最é©åŒ–ã•れ㟠recv.succ()。
+ */
DEFINE_INSN
opt_succ
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv)
(VALUE val)
{
val = vm_opt_succ(recv);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized not */
+/**
+ @c optimize
+ @e optimized not
+ @j 最é©åŒ–ã•れ㟠recv.!()。
+ */
DEFINE_INSN
opt_not
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv)
(VALUE val)
{
- val = vm_opt_not(cd, recv);
+ val = vm_opt_not(ci, cc, recv);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(recv);
+ CALL_SIMPLE_METHOD(recv);
}
}
-/* optimized regexp match 2 */
+
+/**
+ @c optimize
+ @e optimized regexp match
+ @j 最é©åŒ–ã•ã‚ŒãŸæ­£è¦è¡¨ç¾ãƒžãƒƒãƒã€‚
+ */
+DEFINE_INSN
+opt_regexpmatch1
+(VALUE recv)
+(VALUE obj)
+(VALUE val)
+{
+ val = vm_opt_regexpmatch1(recv, obj);
+}
+
+/**
+ @c optimize
+ @e optimized regexp match 2
+ @j 最é©åŒ–ã•ã‚ŒãŸæ­£è¦è¡¨ç¾ãƒžãƒƒãƒ 2
+ */
DEFINE_INSN
opt_regexpmatch2
-(CALL_DATA cd)
+(CALL_INFO ci, CALL_CACHE cc)
(VALUE obj2, VALUE obj1)
(VALUE val)
-// attr bool leaf = false; /* match_at() has rb_thread_check_ints() */
{
val = vm_opt_regexpmatch2(obj2, obj1);
if (val == Qundef) {
- CALL_SIMPLE_METHOD();
+ /* other */
+ PUSH(obj2);
+ PUSH(obj1);
+ CALL_SIMPLE_METHOD(obj2);
}
}
-/* call native compiled method */
+/**
+ @c optimize
+ @e call native compiled method
+ @j ãƒã‚¤ãƒ†ã‚£ãƒ–コンパイルã—ãŸãƒ¡ã‚½ãƒƒãƒ‰ã‚’起動。
+ */
DEFINE_INSN
opt_call_c_function
(rb_insn_func_t funcptr)
()
()
-// attr bool leaf = false; /* anything can happen inside */
-// attr bool handles_sp = true;
{
reg_cfp = (funcptr)(ec, reg_cfp);
@@ -1474,56 +1669,12 @@ opt_call_c_function
NEXT_INSN();
}
-/* call specific function with args */
-DEFINE_INSN
-invokebuiltin
-(RB_BUILTIN bf)
-(...)
-(VALUE ret)
-// attr bool leaf = false; /* anything can happen inside */
-// attr rb_snum_t sp_inc = 1 - bf->argc;
-{
- ret = vm_invoke_builtin(ec, reg_cfp, bf, STACK_ADDR_FROM_TOP(bf->argc));
-}
-
-/* call specific function with args (same parameters) */
-DEFINE_INSN
-opt_invokebuiltin_delegate
-(RB_BUILTIN bf, rb_num_t index)
-()
-(VALUE ret)
-// attr bool leaf = false; /* anything can happen inside */
-{
- ret = vm_invoke_builtin_delegate(ec, reg_cfp, bf, (unsigned int)index);
-}
-
-/* call specific function with args (same parameters) and leave */
+/**
+ @c joke
+ @e BLT
+ @j BLT
+ */
DEFINE_INSN
-opt_invokebuiltin_delegate_leave
-(RB_BUILTIN bf, rb_num_t index)
-()
-(VALUE val)
-// attr bool leaf = false; /* anything can happen inside */
-{
- val = vm_invoke_builtin_delegate(ec, reg_cfp, bf, (unsigned int)index);
-
- /* leave fastpath */
- /* TracePoint/return fallbacks this insn to opt_invokebuiltin_delegate */
- if (vm_pop_frame(ec, GET_CFP(), GET_EP())) {
-#if OPT_CALL_THREADED_CODE
- rb_ec_thread_ptr(ec)->retval = val;
- return 0;
-#else
- return val;
-#endif
- }
- else {
- RESTORE_REGS();
- }
-}
-
-/* BLT */
-DEFINE_INSN_IF(SUPPORT_JOKE)
bitblt
()
()
@@ -1532,8 +1683,12 @@ bitblt
ret = rb_str_new2("a bit of bacon, lettuce and tomato");
}
-/* The Answer to Life, the Universe, and Everything */
-DEFINE_INSN_IF(SUPPORT_JOKE)
+/**
+ @c joke
+ @e The Answer to Life, the Universe, and Everything
+ @j 人生ã€å®‡å®™ã€ã™ã¹ã¦ã®ç­”ãˆã€‚
+ */
+DEFINE_INSN
answer
()
()
@@ -1541,3 +1696,4 @@ answer
{
ret = INT2FIX(42);
}
+
diff --git a/internal.h b/internal.h
index b6cc07d5b9..2e2fa7ba75 100644
--- a/internal.h
+++ b/internal.h
@@ -13,6 +13,8 @@
#define RUBY_INTERNAL_H 1
#include "ruby.h"
+#include "ruby/encoding.h"
+#include "ruby/io.h"
#if defined(__cplusplus)
extern "C" {
@@ -23,8 +25,18 @@ extern "C" {
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
-#else
-# include "missing/stdbool.h"
+#endif
+
+#ifndef __bool_true_false_are_defined
+# ifndef __cplusplus
+# undef bool
+# undef false
+# undef true
+# define bool signed char
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
+# endif
#endif
/* The most significant bit of the lower part of half-long integer.
@@ -44,45 +56,6 @@ extern "C" {
# define WARN_UNUSED_RESULT(x) x
#endif
-#ifndef __has_feature
-# define __has_feature(x) 0
-#endif
-
-#ifndef __has_extension
-# define __has_extension __has_feature
-#endif
-
-#if 0
-#elif defined(NO_SANITIZE) && __has_feature(memory_sanitizer)
-# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
- NO_SANITIZE("memory", NO_SANITIZE("address", NOINLINE(x)))
-#elif defined(NO_SANITIZE)
-# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
- NO_SANITIZE("address", NOINLINE(x))
-#elif defined(NO_SANITIZE_ADDRESS)
-# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
- NO_SANITIZE_ADDRESS(NOINLINE(x))
-#elif defined(NO_ADDRESS_SAFETY_ANALYSIS)
-# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
- NO_ADDRESS_SAFETY_ANALYSIS(NOINLINE(x))
-#else
-# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) x
-#endif
-
-#if defined(NO_SANITIZE) && defined(__GNUC__) &&! defined(__clang__)
-/* GCC warns about unknown sanitizer, which is annoying. */
-#undef NO_SANITIZE
-#define NO_SANITIZE(x, y) \
- COMPILER_WARNING_PUSH; \
- COMPILER_WARNING_IGNORED(-Wattributes); \
- __attribute__((__no_sanitize__(x))) y; \
- COMPILER_WARNING_POP
-#endif
-
-#ifndef NO_SANITIZE
-# define NO_SANITIZE(x, y) y
-#endif
-
#ifdef HAVE_VALGRIND_MEMCHECK_H
# include <valgrind/memcheck.h>
# ifndef VALGRIND_MAKE_MEM_DEFINED
@@ -98,134 +71,16 @@ extern "C" {
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
-#ifndef MJIT_HEADER
-
-#ifdef HAVE_SANITIZER_ASAN_INTERFACE_H
-# include <sanitizer/asan_interface.h>
-#endif
-
-#if !__has_feature(address_sanitizer)
-# define __asan_poison_memory_region(x, y)
-# define __asan_unpoison_memory_region(x, y)
-# define __asan_region_is_poisoned(x, y) 0
-#endif
-
-#ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
-# if __has_feature(memory_sanitizer)
-# include <sanitizer/msan_interface.h>
-# endif
-#endif
-
-#if !__has_feature(memory_sanitizer)
-# define __msan_allocated_memory(x, y) ((void)(x), (void)(y))
-# define __msan_poison(x, y) ((void)(x), (void)(y))
-# define __msan_unpoison(x, y) ((void)(x), (void)(y))
-# define __msan_unpoison_string(x) ((void)(x))
-#endif
-
-/*!
- * This function asserts that a (continuous) memory region from ptr to size
- * being "poisoned". Both read / write access to such memory region are
- * prohibited until properly unpoisoned. The region must be previously
- * allocated (do not pass a freed pointer here), but not necessarily be an
- * entire object that the malloc returns. You can punch hole a part of a
- * gigantic heap arena. This is handy when you do not free an allocated memory
- * region to reuse later: poison when you keep it unused, and unpoison when you
- * reuse.
- *
- * \param[in] ptr pointer to the beginning of the memory region to poison.
- * \param[in] size the length of the memory region to poison.
- */
-static inline void
-asan_poison_memory_region(const volatile void *ptr, size_t size)
-{
- __msan_poison(ptr, size);
- __asan_poison_memory_region(ptr, size);
-}
-
-/*!
- * This is a variant of asan_poison_memory_region that takes a VALUE.
- *
- * \param[in] obj target object.
- */
-static inline void
-asan_poison_object(VALUE obj)
-{
- MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
- asan_poison_memory_region(ptr, SIZEOF_VALUE);
-}
-
-#if !__has_feature(address_sanitizer)
-#define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
-#else
-#define asan_poison_object_if(ptr, obj) do { \
- if (ptr) asan_poison_object(obj); \
- } while (0)
+#ifndef __has_feature
+# define __has_feature(x) 0
#endif
-/*!
- * This function predicates if the given object is fully addressable or not.
- *
- * \param[in] obj target object.
- * \retval 0 the given object is fully addressable.
- * \retval otherwise pointer to first such byte who is poisoned.
- */
-static inline void *
-asan_poisoned_object_p(VALUE obj)
-{
- MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
- return __asan_region_is_poisoned(ptr, SIZEOF_VALUE);
-}
-
-/*!
- * This function asserts that a (formally poisoned) memory region from ptr to
- * size is now addressable. Write access to such memory region gets allowed.
- * However read access might or might not be possible depending on situations,
- * because the region can have contents of previous usages. That information
- * should be passed by the malloc_p flag. If that is true, the contents of the
- * region is _not_ fully defined (like the return value of malloc behaves).
- * Reading from there is NG; write something first. If malloc_p is false on
- * the other hand, that memory region is fully defined and can be read
- * immediately.
- *
- * \param[in] ptr pointer to the beginning of the memory region to unpoison.
- * \param[in] size the length of the memory region.
- * \param[in] malloc_p if the memory region is like a malloc's return value or not.
- */
-static inline void
-asan_unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
-{
- __asan_unpoison_memory_region(ptr, size);
- if (malloc_p) {
- __msan_allocated_memory(ptr, size);
- }
- else {
- __msan_unpoison(ptr, size);
- }
-}
-
-/*!
- * This is a variant of asan_unpoison_memory_region that takes a VALUE.
- *
- * \param[in] obj target object.
- * \param[in] malloc_p if the memory region is like a malloc's return value or not.
- */
-static inline void
-asan_unpoison_object(VALUE obj, bool newobj_p)
-{
- MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
- asan_unpoison_memory_region(ptr, SIZEOF_VALUE, newobj_p);
-}
-
+#ifndef __has_extension
+# define __has_extension __has_feature
#endif
-/* Prevent compiler from reordering access */
-#define ACCESS_ONCE(type,x) (*((volatile type *)&(x)))
-
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+#if GCC_VERSION_SINCE(4, 6, 0) || __has_extension(c_static_assert)
# define STATIC_ASSERT(name, expr) _Static_assert(expr, #name ": " #expr)
-#elif GCC_VERSION_SINCE(4, 6, 0) || __has_extension(c_static_assert)
-# define STATIC_ASSERT(name, expr) RB_GNUC_EXTENSION _Static_assert(expr, #name ": " #expr)
#else
# define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
#endif
@@ -438,15 +293,10 @@ nlz_int128(uint128_t x)
static inline unsigned int
nlz_intptr(uintptr_t x)
{
-#if SIZEOF_UINTPTR_T == SIZEOF_INT
- return nlz_int(x);
-#elif SIZEOF_UINTPTR_T == SIZEOF_LONG
- return nlz_long(x);
-#elif SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG
+#if SIZEOF_VOIDP == 8
return nlz_long_long(x);
-#else
- #error no known integer type corresponds uintptr_t
- return /* sane compiler */ ~0;
+#elif SIZEOF_VOIDP == 4
+ return nlz_int(x);
#endif
}
@@ -657,19 +507,13 @@ rb_fix_mod_fix(VALUE x, VALUE y)
return mod;
}
-#if defined(HAVE_UINT128_T) && defined(HAVE_LONG_LONG)
+#if defined(HAVE_UINT128_T)
# define bit_length(x) \
(unsigned int) \
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
sizeof(x) <= SIZEOF_LONG_LONG ? SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)) : \
SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
-#elif defined(HAVE_UINT128_T)
-# define bit_length(x) \
- (unsigned int) \
- (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
- sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
- SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
#elif defined(HAVE_LONG_LONG)
# define bit_length(x) \
(unsigned int) \
@@ -739,8 +583,8 @@ rb_fix_mod_fix(VALUE x, VALUE y)
#define BIGNUM_EMBED_LEN_NUMBITS 3
#ifndef BIGNUM_EMBED_LEN_MAX
-# if (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
-# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT)
+# if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
+# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
# else
# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
# endif
@@ -767,10 +611,8 @@ struct RBignum {
#define BIGNUM_NEGATE(b) (RBASIC(b)->flags ^= BIGNUM_SIGN_BIT)
#define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
-#define BIGNUM_EMBED_LEN_MASK \
- (~(~(VALUE)0U << BIGNUM_EMBED_LEN_NUMBITS) << BIGNUM_EMBED_LEN_SHIFT)
-#define BIGNUM_EMBED_LEN_SHIFT \
- (FL_USHIFT+3) /* bit offset of BIGNUM_EMBED_LEN_MASK */
+#define BIGNUM_EMBED_LEN_MASK ((VALUE)(FL_USER5|FL_USER4|FL_USER3))
+#define BIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+BIGNUM_EMBED_LEN_NUMBITS)
#define BIGNUM_LEN(b) \
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
(size_t)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \
@@ -787,8 +629,8 @@ struct RBignum {
struct RRational {
struct RBasic basic;
- VALUE num;
- VALUE den;
+ const VALUE num;
+ const VALUE den;
};
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
@@ -804,112 +646,36 @@ struct RFloat {
struct RComplex {
struct RBasic basic;
- VALUE real;
- VALUE imag;
+ const VALUE real;
+ const VALUE imag;
};
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
-/* shortcut macro for internal only */
+#ifdef RCOMPLEX_SET_REAL /* shortcut macro for internal only */
+#undef RCOMPLEX_SET_REAL
+#undef RCOMPLEX_SET_IMAG
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
-
-enum ruby_rhash_flags {
- RHASH_PASS_AS_KEYWORDS = FL_USER1, /* FL 1 */
- RHASH_PROC_DEFAULT = FL_USER2, /* FL 2 */
- RHASH_ST_TABLE_FLAG = FL_USER3, /* FL 3 */
-#define RHASH_AR_TABLE_MAX_SIZE SIZEOF_VALUE
- RHASH_AR_TABLE_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7), /* FL 4..7 */
- RHASH_AR_TABLE_SIZE_SHIFT = (FL_USHIFT+4),
- RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11), /* FL 8..11 */
- RHASH_AR_TABLE_BOUND_SHIFT = (FL_USHIFT+8),
-
- // we can not put it in "enum" because it can exceed "int" range.
-#define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */ \
- FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
-
-#if USE_TRANSIENT_HEAP
- RHASH_TRANSIENT_FLAG = FL_USER12, /* FL 12 */
-#endif
-
- RHASH_LEV_SHIFT = (FL_USHIFT + 13),
- RHASH_LEV_MAX = 127, /* 7 bits */
-
- RHASH_ENUM_END
-};
-
-#define RHASH_AR_TABLE_SIZE_RAW(h) \
- ((unsigned int)((RBASIC(h)->flags & RHASH_AR_TABLE_SIZE_MASK) >> RHASH_AR_TABLE_SIZE_SHIFT))
-
-void rb_hash_st_table_set(VALUE hash, st_table *st);
-
-#if 0 /* for debug */
-int rb_hash_ar_table_p(VALUE hash);
-struct ar_table_struct *rb_hash_ar_table(VALUE hash);
-st_table *rb_hash_st_table(VALUE hash);
-#define RHASH_AR_TABLE_P(hash) rb_hash_ar_table_p(hash)
-#define RHASH_AR_TABLE(h) rb_hash_ar_table(h)
-#define RHASH_ST_TABLE(h) rb_hash_st_table(h)
-#else
-#define RHASH_AR_TABLE_P(hash) (!FL_TEST_RAW((hash), RHASH_ST_TABLE_FLAG))
-#define RHASH_AR_TABLE(hash) (RHASH(hash)->as.ar)
-#define RHASH_ST_TABLE(hash) (RHASH(hash)->as.st)
-#endif
-
-#define RHASH(obj) (R_CAST(RHash)(obj))
-#define RHASH_ST_SIZE(h) (RHASH_ST_TABLE(h)->num_entries)
-#define RHASH_ST_TABLE_P(h) (!RHASH_AR_TABLE_P(h))
-#define RHASH_ST_CLEAR(h) (FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG), RHASH(h)->as.ar = NULL)
-
-#define RHASH_AR_TABLE_SIZE_MASK (VALUE)RHASH_AR_TABLE_SIZE_MASK
-#define RHASH_AR_TABLE_SIZE_SHIFT RHASH_AR_TABLE_SIZE_SHIFT
-#define RHASH_AR_TABLE_BOUND_MASK (VALUE)RHASH_AR_TABLE_BOUND_MASK
-#define RHASH_AR_TABLE_BOUND_SHIFT RHASH_AR_TABLE_BOUND_SHIFT
-
-#if USE_TRANSIENT_HEAP
-#define RHASH_TRANSIENT_P(hash) FL_TEST_RAW((hash), RHASH_TRANSIENT_FLAG)
-#define RHASH_SET_TRANSIENT_FLAG(h) FL_SET_RAW(h, RHASH_TRANSIENT_FLAG)
-#define RHASH_UNSET_TRANSIENT_FLAG(h) FL_UNSET_RAW(h, RHASH_TRANSIENT_FLAG)
-#else
-#define RHASH_TRANSIENT_P(hash) 0
-#define RHASH_SET_TRANSIENT_FLAG(h) ((void)0)
-#define RHASH_UNSET_TRANSIENT_FLAG(h) ((void)0)
-#endif
-
-#if SIZEOF_VALUE / RHASH_AR_TABLE_MAX_SIZE == 2
-typedef uint16_t ar_hint_t;
-#elif SIZEOF_VALUE / RHASH_AR_TABLE_MAX_SIZE == 1
-typedef unsigned char ar_hint_t;
-#else
-#error unsupported
#endif
struct RHash {
struct RBasic basic;
- union {
- st_table *st;
- struct ar_table_struct *ar; /* possibly 0 */
- } as;
+ struct st_table *ntbl; /* possibly 0 */
+ int iter_lev;
const VALUE ifnone;
- union {
- ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
- VALUE word;
- } ar_hint;
};
-#ifdef RHASH_IFNONE
-# undef RHASH_IFNONE
-# undef RHASH_SIZE
-
-# define RHASH_IFNONE(h) (RHASH(h)->ifnone)
-# define RHASH_SIZE(h) (RHASH_AR_TABLE_P(h) ? RHASH_AR_TABLE_SIZE_RAW(h) : RHASH_ST_SIZE(h))
-#endif /* ifdef RHASH_IFNONE */
+#define RHASH(obj) (R_CAST(RHash)(obj))
-struct RMoved {
- VALUE flags;
- VALUE destination;
- VALUE next;
-};
+#ifdef RHASH_ITER_LEV
+#undef RHASH_ITER_LEV
+#undef RHASH_IFNONE
+#undef RHASH_SIZE
+#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
+#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
+#define RHASH_SIZE(h) (RHASH(h)->ntbl ? RHASH(h)->ntbl->num_entries : (st_index_t)0)
+#endif
/* missing/setproctitle.c */
#ifndef HAVE_SETPROCTITLE
@@ -919,26 +685,14 @@ extern void ruby_init_setproctitle(int argc, char *argv[]);
#define RSTRUCT_EMBED_LEN_MAX RSTRUCT_EMBED_LEN_MAX
#define RSTRUCT_EMBED_LEN_MASK RSTRUCT_EMBED_LEN_MASK
#define RSTRUCT_EMBED_LEN_SHIFT RSTRUCT_EMBED_LEN_SHIFT
-
enum {
- RSTRUCT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
+ RSTRUCT_EMBED_LEN_MAX = 3,
RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
- RSTRUCT_TRANSIENT_FLAG = FL_USER3,
RSTRUCT_ENUM_END
};
-#if USE_TRANSIENT_HEAP
-#define RSTRUCT_TRANSIENT_P(st) FL_TEST_RAW((obj), RSTRUCT_TRANSIENT_FLAG)
-#define RSTRUCT_TRANSIENT_SET(st) FL_SET_RAW((st), RSTRUCT_TRANSIENT_FLAG)
-#define RSTRUCT_TRANSIENT_UNSET(st) FL_UNSET_RAW((st), RSTRUCT_TRANSIENT_FLAG)
-#else
-#define RSTRUCT_TRANSIENT_P(st) 0
-#define RSTRUCT_TRANSIENT_SET(st) ((void)0)
-#define RSTRUCT_TRANSIENT_UNSET(st) ((void)0)
-#endif
-
struct RStruct {
struct RBasic basic;
union {
@@ -979,13 +733,6 @@ rb_struct_const_ptr(VALUE st)
RSTRUCT(st)->as.ary : RSTRUCT(st)->as.heap.ptr);
}
-static inline const VALUE *
-rb_struct_const_heap_ptr(VALUE st)
-{
- /* TODO: check embed on debug mode */
- return RSTRUCT(st)->as.heap.ptr;
-}
-
/* class.c */
struct rb_deprecated_classext_struct {
@@ -1003,26 +750,17 @@ struct rb_subclass_entry {
#if defined(HAVE_LONG_LONG)
typedef unsigned LONG_LONG rb_serial_t;
#define SERIALT2NUM ULL2NUM
-#define PRI_SERIALT_PREFIX PRI_LL_PREFIX
-#define SIZEOF_SERIAL_T SIZEOF_LONG_LONG
#elif defined(HAVE_UINT64_T)
typedef uint64_t rb_serial_t;
#define SERIALT2NUM SIZET2NUM
-#define PRI_SERIALT_PREFIX PRI_64_PREFIX
-#define SIZEOF_SERIAL_T SIZEOF_UINT64_T
#else
typedef unsigned long rb_serial_t;
#define SERIALT2NUM ULONG2NUM
-#define PRI_SERIALT_PREFIX PRI_LONG_PREFIX
-#define SIZEOF_SERIAL_T SIZEOF_LONG
#endif
struct rb_classext_struct {
struct st_table *iv_index_tbl;
struct st_table *iv_tbl;
-#if SIZEOF_SERIAL_T == SIZEOF_VALUE /* otherwise m_tbl is in struct RClass */
- struct rb_id_table *m_tbl;
-#endif
struct rb_id_table *const_tbl;
struct rb_id_table *callable_m_tbl;
rb_subclass_entry_t *subclasses;
@@ -1033,13 +771,10 @@ struct rb_classext_struct {
* included. Hopefully that makes sense.
*/
rb_subclass_entry_t **module_subclasses;
-#if SIZEOF_SERIAL_T != SIZEOF_VALUE /* otherwise class_serial is in struct RClass */
rb_serial_t class_serial;
-#endif
const VALUE origin_;
- const VALUE refined_class;
+ VALUE refined_class;
rb_alloc_func_t allocator;
- const VALUE includer;
};
typedef struct rb_classext_struct rb_classext_t;
@@ -1049,13 +784,7 @@ struct RClass {
struct RBasic basic;
VALUE super;
rb_classext_t *ptr;
-#if SIZEOF_SERIAL_T == SIZEOF_VALUE
- /* Class serial is as wide as VALUE. Place it here. */
- rb_serial_t class_serial;
-#else
- /* Class serial does not fit into struct RClass. Place m_tbl instead. */
struct rb_id_table *m_tbl;
-#endif
};
void rb_class_subclass_add(VALUE super, VALUE klass);
@@ -1065,25 +794,14 @@ int rb_singleton_class_internal_p(VALUE sklass);
#define RCLASS_EXT(c) (RCLASS(c)->ptr)
#define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
-#if SIZEOF_SERIAL_T == SIZEOF_VALUE
-# define RCLASS_M_TBL(c) (RCLASS_EXT(c)->m_tbl)
-#else
-# define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
-#endif
+#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
#define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
#define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
-#if SIZEOF_SERIAL_T == SIZEOF_VALUE
-# define RCLASS_SERIAL(c) (RCLASS(c)->class_serial)
-#else
-# define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
-#endif
-#define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
+#define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
-#define RCLASS_CLONED FL_USER6
#define RICLASS_IS_ORIGIN FL_USER5
-#define RCLASS_REFINED_BY_ANY FL_USER7
static inline void
RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
@@ -1092,12 +810,6 @@ RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
}
-static inline void
-RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass)
-{
- RB_OBJ_WRITE(iclass, &RCLASS_INCLUDER(iclass), klass);
-}
-
#undef RCLASS_SUPER
static inline VALUE
RCLASS_SUPER(VALUE klass)
@@ -1138,7 +850,7 @@ enum imemo_type {
imemo_memo = 5,
imemo_ment = 6,
imemo_iseq = 7,
- imemo_tmpbuf = 8,
+ imemo_alloc = 8,
imemo_ast = 9,
imemo_parser_strterm = 10
};
@@ -1165,8 +877,6 @@ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
}
}
-VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
-
/* FL_USER0 to FL_USER3 is for type */
#define IMEMO_FL_USHIFT (FL_USHIFT + 4)
#define IMEMO_FL_USER0 FL_USER4
@@ -1195,7 +905,7 @@ struct vm_throw_data {
VALUE reserved;
const VALUE throw_obj;
const struct rb_control_frame_struct *catch_frame;
- int throw_state;
+ VALUE throw_state;
};
#define THROW_DATA_P(err) RB_TYPE_P((VALUE)(err), T_IMEMO)
@@ -1215,59 +925,28 @@ struct vm_ifunc_argc {
struct vm_ifunc {
VALUE flags;
VALUE reserved;
- rb_block_call_func_t func;
+ VALUE (*func)(ANYARGS);
const void *data;
struct vm_ifunc_argc argc;
};
#define IFUNC_NEW(a, b, c) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
-struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
+struct vm_ifunc *rb_vm_ifunc_new(VALUE (*func)(ANYARGS), const void *data, int min_argc, int max_argc);
static inline struct vm_ifunc *
-rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data)
+rb_vm_ifunc_proc_new(VALUE (*func)(ANYARGS), const void *data)
{
return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
}
-typedef struct rb_imemo_tmpbuf_struct {
+typedef struct rb_imemo_alloc_struct {
VALUE flags;
VALUE reserved;
VALUE *ptr; /* malloc'ed buffer */
- struct rb_imemo_tmpbuf_struct *next; /* next imemo */
+ struct rb_imemo_alloc_struct *next; /* next imemo */
size_t cnt; /* buffer size in VALUE */
-} rb_imemo_tmpbuf_t;
-
-#define rb_imemo_tmpbuf_auto_free_pointer() rb_imemo_new(imemo_tmpbuf, 0, 0, 0, 0)
-rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
-
-#define RB_IMEMO_TMPBUF_PTR(v) \
- ((void *)(((const struct rb_imemo_tmpbuf_struct *)(v))->ptr))
+} rb_imemo_alloc_t;
-static inline void *
-rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr)
-{
- return ((rb_imemo_tmpbuf_t *)v)->ptr = ptr;
-}
-
-static inline VALUE
-rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str)
-{
- const void *src;
- VALUE imemo;
- rb_imemo_tmpbuf_t *tmpbuf;
- void *dst;
- size_t len;
-
- SafeStringValue(str);
- /* create tmpbuf to keep the pointer before xmalloc */
- imemo = rb_imemo_tmpbuf_auto_free_pointer();
- tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
- len = RSTRING_LEN(str);
- src = RSTRING_PTR(str);
- dst = ruby_xmalloc(len);
- memcpy(dst, src, len);
- tmpbuf->ptr = dst;
- return imemo;
-}
+rb_imemo_alloc_t *rb_imemo_alloc_new(VALUE, VALUE, VALUE, VALUE);
void rb_strterm_mark(VALUE obj);
@@ -1283,8 +962,8 @@ struct MEMO {
union {
long cnt;
long state;
- const VALUE value;
- void (*func)(void);
+ const VALUE value;
+ VALUE (*func)(ANYARGS);
} u3;
};
@@ -1357,49 +1036,19 @@ VALUE rb_gvar_get(struct rb_global_entry *);
VALUE rb_gvar_set(struct rb_global_entry *, VALUE);
VALUE rb_gvar_defined(struct rb_global_entry *);
-/* array.c */
-
-#ifndef ARRAY_DEBUG
-#define ARRAY_DEBUG (0+RUBY_DEBUG)
-#endif
-
-#ifdef ARRAY_DEBUG
-#define RARRAY_PTR_IN_USE_FLAG FL_USER14
-#define ARY_PTR_USING_P(ary) FL_TEST_RAW((ary), RARRAY_PTR_IN_USE_FLAG)
-#else
-
-/* disable debug function */
-#undef RARRAY_PTR_USE_START_TRANSIENT
-#undef RARRAY_PTR_USE_END_TRANSIENT
-#define RARRAY_PTR_USE_START_TRANSIENT(a) ((VALUE *)RARRAY_CONST_PTR_TRANSIENT(a))
-#define RARRAY_PTR_USE_END_TRANSIENT(a)
-#define ARY_PTR_USING_P(ary) 0
-
-#endif
-
-#if USE_TRANSIENT_HEAP
-#define RARY_TRANSIENT_SET(ary) FL_SET_RAW((ary), RARRAY_TRANSIENT_FLAG);
-#define RARY_TRANSIENT_UNSET(ary) FL_UNSET_RAW((ary), RARRAY_TRANSIENT_FLAG);
-#else
-#undef RARRAY_TRANSIENT_P
-#define RARRAY_TRANSIENT_P(a) 0
-#define RARY_TRANSIENT_SET(ary) ((void)0)
-#define RARY_TRANSIENT_UNSET(ary) ((void)0)
-#endif
-
+struct vtm; /* defined by timev.h */
+/* array.c */
VALUE rb_ary_last(int, const VALUE *, VALUE);
void rb_ary_set_len(VALUE, long);
void rb_ary_delete_same(VALUE, VALUE);
VALUE rb_ary_tmp_new_fill(long capa);
VALUE rb_ary_at(VALUE, VALUE);
VALUE rb_ary_aref1(VALUE ary, VALUE i);
+VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
size_t rb_ary_memsize(VALUE);
VALUE rb_to_array_type(VALUE obj);
-VALUE rb_check_to_array(VALUE ary);
-VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
-VALUE rb_ary_behead(VALUE, long);
-#if defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
+#ifdef __GNUC__
#define rb_ary_new_from_args(n, ...) \
__extension__ ({ \
const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
@@ -1410,40 +1059,6 @@ VALUE rb_ary_behead(VALUE, long);
})
#endif
-static inline VALUE
-rb_ary_entry_internal(VALUE ary, long offset)
-{
- long len = RARRAY_LEN(ary);
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
- if (len == 0) return Qnil;
- if (offset < 0) {
- offset += len;
- if (offset < 0) return Qnil;
- }
- else if (len <= offset) {
- return Qnil;
- }
- return ptr[offset];
-}
-
-/* MRI debug support */
-void rb_obj_info_dump(VALUE obj);
-void rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func);
-void ruby_debug_breakpoint(void);
-
-// show obj data structure without any side-effect
-#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, __func__)
-
-// same as rp, but add message header
-#define rp_m(msg, obj) do { \
- fprintf(stderr, "%s", (msg)); \
- rb_obj_info_dump((VALUE)obj); \
-} while (0)
-
-// `ruby_debug_breakpoint()` does nothing,
-// but breakpoint is set in run.gdb, so `make gdb` can stop here.
-#define bp() ruby_debug_breakpoint()
-
/* bignum.c */
extern const char ruby_digitmap[];
double rb_big_fdiv_double(VALUE x, VALUE y);
@@ -1454,7 +1069,7 @@ VALUE rb_big_even_p(VALUE);
size_t rb_big_size(VALUE);
VALUE rb_integer_float_cmp(VALUE x, VALUE y);
VALUE rb_integer_float_eq(VALUE x, VALUE y);
-VALUE rb_str_convert_to_inum(VALUE str, int base, int badcheck, int raise_exception);
+VALUE rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base);
VALUE rb_big_comp(VALUE x);
VALUE rb_big_aref(VALUE x, VALUE y);
VALUE rb_big_abs(VALUE x);
@@ -1493,23 +1108,21 @@ VALUE rb_invcmp(VALUE, VALUE);
/* compile.c */
struct rb_block;
-struct rb_iseq_struct;
-int rb_dvar_defined(ID, const struct rb_iseq_struct *);
-int rb_local_defined(ID, const struct rb_iseq_struct *);
+int rb_dvar_defined(ID, const struct rb_block *);
+int rb_local_defined(ID, const struct rb_block *);
const char * rb_insns_name(int i);
VALUE rb_insns_name_array(void);
-int rb_vm_insn_addr2insn(const void *);
/* complex.c */
-VALUE rb_dbl_complex_new_polar_pi(double abs, double ang);
+VALUE rb_complex_plus(VALUE, VALUE);
+VALUE rb_complex_mul(VALUE, VALUE);
+VALUE rb_complex_abs(VALUE x);
+VALUE rb_complex_sqrt(VALUE x);
-struct rb_thread_struct;
/* cont.c */
-struct rb_fiber_struct;
VALUE rb_obj_is_fiber(VALUE);
-void rb_fiber_reset_root_local_storage(struct rb_thread_struct *);
-void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(VALUE), VALUE (*rollback_func)(VALUE));
-void rb_fiber_init_mjit_cont(struct rb_fiber_struct *fiber);
+void rb_fiber_reset_root_local_storage(VALUE);
+void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*rollback_func)(ANYARGS));
/* debug.c */
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
@@ -1523,10 +1136,9 @@ void Init_ext(void);
/* encoding.c */
ID rb_id_encoding(void);
-#ifdef RUBY_ENCODING_H
+void rb_gc_mark_encodings(void);
rb_encoding *rb_enc_get_from_index(int index);
rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
-#endif
int rb_encdb_replicate(const char *alias, const char *orig);
int rb_encdb_alias(const char *alias, const char *orig);
int rb_encdb_dummy(const char *name);
@@ -1537,7 +1149,6 @@ void rb_encdb_set_unicode(int index);
PUREFUNC(int rb_data_is_encoding(VALUE obj));
/* enum.c */
-extern VALUE rb_cArithSeq;
VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
VALUE rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary);
@@ -1546,25 +1157,21 @@ extern VALUE rb_eEAGAIN;
extern VALUE rb_eEWOULDBLOCK;
extern VALUE rb_eEINPROGRESS;
void rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args);
+VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
+VALUE rb_check_backtrace(VALUE);
NORETURN(void rb_async_bug_errno(const char *,int));
const char *rb_builtin_type_name(int t);
const char *rb_builtin_class_name(VALUE x);
-PRINTF_ARGS(void rb_warn_deprecated(const char *fmt, const char *suggest, ...), 1, 3);
-#ifdef RUBY_ENCODING_H
-VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
+PRINTF_ARGS(void rb_sys_warn(const char *fmt, ...), 1, 2);
+PRINTF_ARGS(void rb_syserr_warn(int err, const char *fmt, ...), 2, 3);
PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
+PRINTF_ARGS(void rb_sys_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
+PRINTF_ARGS(void rb_syserr_enc_warn(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
+PRINTF_ARGS(void rb_sys_warning(const char *fmt, ...), 1, 2);
+PRINTF_ARGS(void rb_syserr_warning(int err, const char *fmt, ...), 2, 3);
+PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
PRINTF_ARGS(void rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
-#endif
-
-typedef enum {
- RB_WARN_CATEGORY_NONE,
- RB_WARN_CATEGORY_DEPRECATED,
- RB_WARN_CATEGORY_EXPERIMENTAL,
- RB_WARN_CATEGORY_ALL_BITS = 0x6, /* no RB_WARN_CATEGORY_NONE bit */
-} rb_warning_category_t;
-rb_warning_category_t rb_warning_category_from_name(VALUE category);
-bool rb_warning_category_enabled_p(rb_warning_category_t category);
#define rb_raise_cstr(etype, mesg) \
rb_exc_raise(rb_exc_new_str(etype, rb_str_new_cstr(mesg)))
@@ -1576,20 +1183,17 @@ VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method);
rb_exc_raise(rb_name_err_new(mesg, recv, name))
#define rb_name_err_raise(mesg, recv, name) \
rb_name_err_raise_str(rb_fstring_cstr(mesg), (recv), (name))
-VALUE rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv);
VALUE rb_key_err_new(VALUE mesg, VALUE recv, VALUE name);
#define rb_key_err_raise(mesg, recv, name) \
rb_exc_raise(rb_key_err_new(mesg, recv, name))
-PRINTF_ARGS(VALUE rb_warning_string(const char *fmt, ...), 1, 2);
-NORETURN(void rb_vraise(VALUE, const char *, va_list));
+NORETURN(void ruby_deprecated_internal_feature(const char *));
+#define DEPRECATED_INTERNAL_FEATURE(func) \
+ (ruby_deprecated_internal_feature(func), UNREACHABLE)
+VALUE rb_warning_warn(VALUE mod, VALUE str);
+VALUE rb_warning_string(const char *fmt, ...);
/* eval.c */
VALUE rb_refinement_module_get_refined_class(VALUE module);
-extern ID ruby_static_id_signo, ruby_static_id_status;
-void rb_class_modify_check(VALUE);
-#define id_signo ruby_static_id_signo
-#define id_status ruby_static_id_status
-NORETURN(VALUE rb_f_raise(int argc, VALUE *argv));
/* eval_error.c */
VALUE rb_get_backtrace(VALUE info);
@@ -1599,19 +1203,17 @@ void rb_call_end_proc(VALUE data);
void rb_mark_end_proc(void);
/* file.c */
-extern const char ruby_null_device[];
VALUE rb_home_dir_of(VALUE user, VALUE result);
VALUE rb_default_home_dir(VALUE result);
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
-#ifdef RUBY_ENCODING_H
-VALUE rb_check_realpath(VALUE basedir, VALUE path, rb_encoding *origenc);
-#endif
+VALUE rb_check_realpath(VALUE basedir, VALUE path);
void rb_file_const(const char*, VALUE);
int rb_file_load_ok(const char *);
VALUE rb_file_expand_path_fast(VALUE, VALUE);
VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
-VALUE rb_get_path_check_to_string(VALUE);
-VALUE rb_get_path_check_convert(VALUE);
+VALUE rb_get_path_check_to_string(VALUE, int);
+VALUE rb_get_path_check_convert(VALUE, VALUE, int);
+VALUE rb_get_path_check(VALUE, int);
void Init_File(void);
int ruby_is_fd_loadable(int fd);
@@ -1634,33 +1236,28 @@ NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path)
/* gc.c */
extern VALUE *ruby_initial_gc_stress_ptr;
extern int ruby_disable_gc;
-struct rb_objspace; /* in vm_core.h */
void Init_heap(void);
-void *ruby_mimmalloc(size_t size) RUBY_ATTR_MALLOC;
+void *ruby_mimmalloc(size_t size);
void ruby_mimfree(void *ptr);
void rb_objspace_set_event_hook(const rb_event_flag_t event);
-VALUE rb_objspace_gc_enable(struct rb_objspace *);
-VALUE rb_objspace_gc_disable(struct rb_objspace *);
#if USE_RGENGC
void rb_gc_writebarrier_remember(VALUE obj);
#else
#define rb_gc_writebarrier_remember(obj) 0
#endif
-void ruby_gc_set_params(void);
+void ruby_gc_set_params(int safe_level);
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
#define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
-#define ruby_sized_xrealloc2(ptr, new_count, element_size, old_count) ruby_xrealloc2(ptr, new_count, element_size)
+#define ruby_sized_xrealloc2(ptr, new_count, element_size, old_count) ruby_xrealloc(ptr, new_count, element_size)
#define ruby_sized_xfree(ptr, size) ruby_xfree(ptr)
#define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)
#else
-RUBY_SYMBOL_EXPORT_BEGIN
-void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
-void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
+void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));
+void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_ALLOC_SIZE((2, 3));
void ruby_sized_xfree(void *x, size_t size);
-RUBY_SYMBOL_EXPORT_END
-#define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc2((void*)(var), (n), sizeof(type), (old_n)))
+#define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
#endif
/* optimized version of NEWOBJ() */
@@ -1672,70 +1269,45 @@ RUBY_SYMBOL_EXPORT_END
rb_wb_unprotected_newobj_of(klass, flags))
#define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags)
-#ifdef __has_attribute
-#if __has_attribute(alloc_align)
-__attribute__((__alloc_align__(1)))
-#endif
-#endif
-void *rb_aligned_malloc(size_t, size_t) RUBY_ATTR_MALLOC RUBY_ATTR_ALLOC_SIZE((2));
-
-size_t rb_size_mul_or_raise(size_t, size_t, VALUE); /* used in compile.c */
-size_t rb_size_mul_add_or_raise(size_t, size_t, size_t, VALUE); /* used in iseq.h */
-void *rb_xmalloc_mul_add(size_t, size_t, size_t) RUBY_ATTR_MALLOC;
-void *rb_xrealloc_mul_add(const void *, size_t, size_t, size_t);
-void *rb_xmalloc_mul_add_mul(size_t, size_t, size_t, size_t) RUBY_ATTR_MALLOC;
-void *rb_xcalloc_mul_add_mul(size_t, size_t, size_t, size_t) RUBY_ATTR_MALLOC;
-
/* hash.c */
-#if RHASH_CONVERT_TABLE_DEBUG
-struct st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
-#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
-#else
struct st_table *rb_hash_tbl_raw(VALUE hash);
-#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
-#endif
-
VALUE rb_hash_new_with_size(st_index_t size);
+RUBY_SYMBOL_EXPORT_BEGIN
+VALUE rb_hash_new_compare_by_id(void);
+RUBY_SYMBOL_EXPORT_END
VALUE rb_hash_has_key(VALUE hash, VALUE key);
VALUE rb_hash_default_value(VALUE hash, VALUE key);
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
+long rb_objid_hash(st_index_t index);
long rb_dbl_long_hash(double d);
st_table *rb_init_identtable(void);
+st_table *rb_init_identtable_with_size(st_index_t size);
VALUE rb_hash_compare_by_id_p(VALUE hash);
VALUE rb_to_hash_type(VALUE obj);
-VALUE rb_hash_key_str(VALUE);
+
+#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
VALUE rb_hash_keys(VALUE hash);
VALUE rb_hash_values(VALUE hash);
VALUE rb_hash_rehash(VALUE hash);
-VALUE rb_hash_resurrect(VALUE hash);
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
-VALUE rb_hash_set_pair(VALUE hash, VALUE pair);
-
-int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
-int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
-RUBY_SYMBOL_EXPORT_BEGIN
-int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg);
-RUBY_SYMBOL_EXPORT_END
-int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
-int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func func, st_data_t arg);
+#define HASH_PROC_DEFAULT FL_USER2
/* inits.c */
void rb_call_inits(void);
/* io.c */
+const char *ruby_get_inplace_mode(void);
void ruby_set_inplace_mode(const char *);
+ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
void rb_stdio_set_default_encoding(void);
VALUE rb_io_flush_raw(VALUE, int);
-#ifdef RUBY_IO_H
size_t rb_io_memsize(const rb_io_t *);
-#endif
int rb_stderr_tty_p(void);
-void rb_io_fptr_finalize_internal(void *ptr);
-#define rb_io_fptr_finalize rb_io_fptr_finalize_internal
/* load.c */
+VALUE rb_get_load_path(void);
VALUE rb_get_expanded_load_path(void);
-int rb_require_internal(VALUE fname);
+int rb_require_internal(VALUE fname, int safe);
NORETURN(void rb_load_fail(VALUE, const char*));
/* loadpath.c */
@@ -1754,20 +1326,7 @@ VALUE rb_math_hypot(VALUE, VALUE);
VALUE rb_math_log(int argc, const VALUE *argv);
VALUE rb_math_sin(VALUE);
VALUE rb_math_sinh(VALUE);
-
-/* mjit.c */
-
-#if USE_MJIT
-extern bool mjit_enabled;
-VALUE mjit_pause(bool wait_p);
-VALUE mjit_resume(void);
-void mjit_finish(bool close_handle_p);
-#else
-#define mjit_enabled 0
-static inline VALUE mjit_pause(bool wait_p){ return Qnil; } // unreachable
-static inline VALUE mjit_resume(void){ return Qnil; } // unreachable
-static inline void mjit_finish(bool close_handle_p){}
-#endif
+VALUE rb_math_sqrt(VALUE);
/* newline.c */
void Init_newline(void);
@@ -1780,8 +1339,6 @@ void Init_newline(void);
#define INT_NEGATIVE_P(x) (FIXNUM_P(x) ? FIXNUM_NEGATIVE_P(x) : BIGNUM_NEGATIVE_P(x))
-#define FLOAT_ZERO_P(x) (RFLOAT_VALUE(x) == 0.0)
-
#ifndef ROUND_DEFAULT
# define ROUND_DEFAULT RUBY_NUM_ROUND_HALF_UP
#endif
@@ -1802,25 +1359,22 @@ enum ruby_num_rounding_mode {
int rb_num_to_uint(VALUE val, unsigned int *ret);
VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
-double ruby_float_step_size(double beg, double end, double unit, int excl);
-int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless);
+int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
double ruby_float_mod(double x, double y);
int rb_num_negative_p(VALUE);
VALUE rb_int_succ(VALUE num);
+VALUE rb_int_pred(VALUE num);
VALUE rb_int_uminus(VALUE num);
VALUE rb_float_uminus(VALUE num);
VALUE rb_int_plus(VALUE x, VALUE y);
-VALUE rb_float_plus(VALUE x, VALUE y);
VALUE rb_int_minus(VALUE x, VALUE y);
-VALUE rb_float_minus(VALUE x, VALUE y);
VALUE rb_int_mul(VALUE x, VALUE y);
-VALUE rb_float_mul(VALUE x, VALUE y);
-VALUE rb_float_div(VALUE x, VALUE y);
VALUE rb_int_idiv(VALUE x, VALUE y);
VALUE rb_int_modulo(VALUE x, VALUE y);
+VALUE rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode);
VALUE rb_int2str(VALUE num, int base);
+VALUE rb_dbl_hash(double d);
VALUE rb_fix_plus(VALUE x, VALUE y);
-VALUE rb_fix_aref(VALUE fix, VALUE idx);
VALUE rb_int_gt(VALUE x, VALUE y);
int rb_float_cmp(VALUE x, VALUE y);
VALUE rb_float_gt(VALUE x, VALUE y);
@@ -1837,11 +1391,6 @@ VALUE rb_int_lshift(VALUE x, VALUE y);
VALUE rb_int_div(VALUE x, VALUE y);
VALUE rb_int_abs(VALUE num);
VALUE rb_int_odd_p(VALUE num);
-int rb_int_positive_p(VALUE num);
-int rb_int_negative_p(VALUE num);
-VALUE rb_num_pow(VALUE x, VALUE y);
-VALUE rb_float_ceil(VALUE num, int ndigits);
-VALUE rb_float_floor(VALUE x, int ndigits);
static inline VALUE
rb_num_compare_with_zero(VALUE num, ID mid)
@@ -1891,7 +1440,6 @@ rb_num_negative_int_p(VALUE num)
VALUE rb_float_abs(VALUE flt);
VALUE rb_float_equal(VALUE x, VALUE y);
VALUE rb_float_eql(VALUE x, VALUE y);
-VALUE rb_flo_div_flo(VALUE x, VALUE y);
#if USE_FLONUM
#define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
@@ -1979,7 +1527,6 @@ VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
VALUE rb_convert_type_with_id(VALUE,int,const char*,ID);
VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
-int rb_bool_expected(VALUE, const char *);
struct RBasicRaw {
VALUE flags;
@@ -1997,19 +1544,29 @@ struct RBasicRaw {
#ifndef USE_SYMBOL_GC
#define USE_SYMBOL_GC 1
#endif
+VALUE rb_parser_get_yydebug(VALUE);
VALUE rb_parser_set_yydebug(VALUE, VALUE);
-RUBY_SYMBOL_EXPORT_BEGIN
-VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
-RUBY_SYMBOL_EXPORT_END
+VALUE rb_parser_set_context(VALUE, const struct rb_block *, int);
void *rb_parser_load_file(VALUE parser, VALUE name);
int rb_is_const_name(VALUE name);
int rb_is_class_name(VALUE name);
+int rb_is_global_name(VALUE name);
int rb_is_instance_name(VALUE name);
+int rb_is_attrset_name(VALUE name);
int rb_is_local_name(VALUE name);
+int rb_is_method_name(VALUE name);
+int rb_is_junk_name(VALUE name);
PUREFUNC(int rb_is_const_sym(VALUE sym));
+PUREFUNC(int rb_is_class_sym(VALUE sym));
+PUREFUNC(int rb_is_global_sym(VALUE sym));
+PUREFUNC(int rb_is_instance_sym(VALUE sym));
PUREFUNC(int rb_is_attrset_sym(VALUE sym));
+PUREFUNC(int rb_is_local_sym(VALUE sym));
+PUREFUNC(int rb_is_method_sym(VALUE sym));
+PUREFUNC(int rb_is_junk_sym(VALUE sym));
ID rb_make_internal_id(void);
void rb_gc_free_dsymbol(VALUE);
+ID rb_id_attrget(ID id);
/* proc.c */
VALUE rb_proc_location(VALUE self);
@@ -2023,7 +1580,6 @@ VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additi
/* process.c */
#define RB_MAX_GROUPS (65536)
-struct waitpid_state;
struct rb_execarg {
union {
struct {
@@ -2052,9 +1608,6 @@ struct rb_execarg {
unsigned new_pgroup_flag : 1;
unsigned uid_given : 1;
unsigned gid_given : 1;
- unsigned exception : 1;
- unsigned exception_given : 1;
- struct waitpid_state *waitpid_state; /* for async process management */
rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
mode_t umask_mask;
@@ -2074,49 +1627,21 @@ struct rb_execarg {
* The beginning one is for /bin/sh used by exec_with_sh.
* The last one for terminating NULL used by execve.
* See rb_exec_fillarg() in process.c. */
-#define ARGVSTR2ARGV(argv_str) ((char **)RB_IMEMO_TMPBUF_PTR(argv_str) + 1)
-
-static inline size_t
-ARGVSTR2ARGC(VALUE argv_str)
-{
- size_t i = 0;
- char *const *p = ARGVSTR2ARGV(argv_str);
- while (p[i++])
- ;
- return i - 1;
-}
-
-#ifdef HAVE_PWD_H
-VALUE rb_getlogin(void);
-VALUE rb_getpwdirnam_for_login(VALUE login); /* read as: "get pwd db home dir by username for login" */
-VALUE rb_getpwdiruid(void); /* read as: "get pwd db home dir for getuid()" */
-#endif
+#define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
+#define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
rb_pid_t rb_fork_ruby(int *status);
void rb_last_status_clear(void);
-/* range.c */
-#define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0])
-#define RANGE_END(r) (RSTRUCT(r)->as.ary[1])
-#define RANGE_EXCL(r) (RSTRUCT(r)->as.ary[2])
-
/* rational.c */
-VALUE rb_rational_canonicalize(VALUE x);
VALUE rb_rational_uminus(VALUE self);
VALUE rb_rational_plus(VALUE self, VALUE other);
-VALUE rb_rational_minus(VALUE self, VALUE other);
-VALUE rb_rational_mul(VALUE self, VALUE other);
-VALUE rb_rational_div(VALUE self, VALUE other);
VALUE rb_lcm(VALUE x, VALUE y);
VALUE rb_rational_reciprocal(VALUE x);
VALUE rb_cstr_to_rat(const char *, int);
VALUE rb_rational_abs(VALUE self);
VALUE rb_rational_cmp(VALUE self, VALUE other);
-VALUE rb_rational_pow(VALUE self, VALUE other);
-VALUE rb_rational_floor(VALUE self, int ndigits);
VALUE rb_numeric_quo(VALUE x, VALUE y);
-VALUE rb_float_numerator(VALUE x);
-VALUE rb_float_denominator(VALUE x);
/* re.c */
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
@@ -2125,14 +1650,24 @@ long rb_reg_search0(VALUE, VALUE, long, int, int);
VALUE rb_reg_match_p(VALUE re, VALUE str, long pos);
bool rb_reg_start_with_p(VALUE re, VALUE str);
void rb_backref_set_string(VALUE string, long pos, long len);
-void rb_match_unbusy(VALUE);
int rb_match_count(VALUE match);
int rb_match_nth_defined(int nth, VALUE match);
-VALUE rb_reg_new_ary(VALUE ary, int options);
/* signal.c */
extern int ruby_enable_coredump;
int rb_get_next_signal(void);
+int rb_sigaltstack_size(void);
+
+/* st.c */
+extern void rb_hash_bulk_insert(long, const VALUE *, VALUE);
+
+/* strftime.c */
+#ifdef RUBY_ENCODING_H
+VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc,
+ const struct vtm *vtm, struct timespec *ts, int gmt);
+VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc,
+ const struct vtm *vtm, VALUE timev, int gmt);
+#endif
/* string.c */
VALUE rb_fstring(VALUE);
@@ -2151,6 +1686,14 @@ VALUE rb_fstring_cstr(const char *str);
VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
#define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
#define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
+VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
+# ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
+# define rb_fstring_enc_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
+ (__builtin_constant_p(str)) ? \
+ rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
+ rb_fstring_enc_cstr(str, enc) \
+)
+# endif
#endif
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
int rb_str_symname_p(VALUE);
@@ -2161,6 +1704,8 @@ VALUE rb_id_quote_unprintable(ID);
char *rb_str_fill_terminator(VALUE str, const int termlen);
void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
+VALUE rb_str_tmp_frozen_acquire(VALUE str);
+void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
#ifdef RUBY_ENCODING_H
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
@@ -2176,33 +1721,23 @@ VALUE rb_str_initialize(VALUE str, const char *ptr, long len, rb_encoding *enc);
#define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
#define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
size_t rb_str_memsize(VALUE);
-VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc);
+VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, VALUE passed_proc);
VALUE rb_sym_to_proc(VALUE sym);
char *rb_str_to_cstr(VALUE str);
VALUE rb_str_eql(VALUE str1, VALUE str2);
-VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
-const char *ruby_escaped_char(int c);
-VALUE rb_str_opt_plus(VALUE, VALUE);
-
-/* expect tail call optimization */
-static inline VALUE
-rb_str_eql_internal(const VALUE str1, const VALUE str2)
-{
- const long len = RSTRING_LEN(str1);
- const char *ptr1, *ptr2;
-
- if (len != RSTRING_LEN(str2)) return Qfalse;
- if (!rb_str_comparable(str1, str2)) return Qfalse;
- if ((ptr1 = RSTRING_PTR(str1)) == (ptr2 = RSTRING_PTR(str2)))
- return Qtrue;
- if (memcmp(ptr1, ptr2, len) == 0)
- return Qtrue;
- return Qfalse;
-}
/* symbol.c */
#ifdef RUBY_ENCODING_H
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
+VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc);
+#ifdef __GNUC__
+#define rb_sym_intern_cstr(ptr, enc) __extension__ ( \
+{ \
+ (__builtin_constant_p(ptr)) ? \
+ rb_sym_intern((ptr), (long)strlen(ptr), (enc)) : \
+ rb_sym_intern_cstr((ptr), (enc)); \
+})
+#endif
#endif
VALUE rb_sym_intern_ascii(const char *ptr, long len);
VALUE rb_sym_intern_ascii_cstr(const char *ptr);
@@ -2230,13 +1765,12 @@ struct timeval rb_time_timeval(VALUE);
#define COVERAGE_TARGET_LINES 1
#define COVERAGE_TARGET_BRANCHES 2
#define COVERAGE_TARGET_METHODS 4
-#define COVERAGE_TARGET_ONESHOT_LINES 8
VALUE rb_obj_is_mutex(VALUE obj);
VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
void rb_thread_execute_interrupts(VALUE th);
+void rb_clear_trace_func(void);
VALUE rb_get_coverages(void);
-int rb_get_coverage_mode(void);
VALUE rb_default_coverage(int);
VALUE rb_thread_shield_new(void);
VALUE rb_thread_shield_wait(VALUE self);
@@ -2244,53 +1778,37 @@ VALUE rb_thread_shield_release(VALUE self);
VALUE rb_thread_shield_destroy(VALUE self);
int rb_thread_to_be_killed(VALUE thread);
void rb_mutex_allow_trap(VALUE self, int val);
-VALUE rb_uninterruptible(VALUE (*b_proc)(VALUE), VALUE data);
+VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
VALUE rb_mutex_owned_p(VALUE self);
+/* thread_pthread.c, thread_win32.c */
+int rb_divert_reserved_fd(int fd);
+
/* transcode.c */
extern VALUE rb_cEncodingConverter;
-#ifdef RUBY_ENCODING_H
size_t rb_econv_memsize(rb_econv_t *);
-#endif
/* us_ascii.c */
-#ifdef RUBY_ENCODING_H
extern rb_encoding OnigEncodingUS_ASCII;
-#endif
/* util.c */
char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
char *ruby_hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve);
/* utf_8.c */
-#ifdef RUBY_ENCODING_H
extern rb_encoding OnigEncodingUTF_8;
-#endif
/* variable.c */
-#if USE_TRANSIENT_HEAP
-#define ROBJECT_TRANSIENT_FLAG FL_USER13
-#define ROBJ_TRANSIENT_P(obj) FL_TEST_RAW((obj), ROBJECT_TRANSIENT_FLAG)
-#define ROBJ_TRANSIENT_SET(obj) FL_SET_RAW((obj), ROBJECT_TRANSIENT_FLAG)
-#define ROBJ_TRANSIENT_UNSET(obj) FL_UNSET_RAW((obj), ROBJECT_TRANSIENT_FLAG)
-#else
-#define ROBJ_TRANSIENT_P(obj) 0
-#define ROBJ_TRANSIENT_SET(obj) ((void)0)
-#define ROBJ_TRANSIENT_UNSET(obj) ((void)0)
-#endif
void rb_gc_mark_global_tbl(void);
size_t rb_generic_ivar_memsize(VALUE);
VALUE rb_search_class_path(VALUE);
VALUE rb_attr_delete(VALUE, ID);
VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
void rb_autoload_str(VALUE mod, ID id, VALUE file);
-VALUE rb_autoload_at_p(VALUE, ID, int);
void rb_deprecate_constant(VALUE mod, const char *name);
-NORETURN(VALUE rb_mod_const_missing(VALUE,VALUE));
-rb_gvar_getter_t *rb_gvar_getter_function_of(const struct rb_global_entry *);
-rb_gvar_setter_t *rb_gvar_setter_function_of(const struct rb_global_entry *);
-bool rb_gvar_is_traced(const struct rb_global_entry *);
-void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_);
+
+/* version.c */
+extern const char ruby_engine[];
/* vm_insnhelper.h */
rb_serial_t rb_next_class_serial(void);
@@ -2301,16 +1819,17 @@ void rb_vm_mark(void *ptr);
void Init_BareVM(void);
void Init_vm_objects(void);
PUREFUNC(VALUE rb_vm_top_self(void));
+void rb_thread_recycle_stack_release(VALUE *);
+void rb_vm_change_state(void);
void rb_vm_inc_const_missing_count(void);
const void **rb_vm_get_insns_address_table(void);
VALUE rb_source_location(int *pline);
const char *rb_source_location_cstr(int *pline);
-MJIT_STATIC void rb_vm_pop_cfunc_frame(void);
+void rb_vm_pop_cfunc_frame(void);
int rb_vm_add_root_module(ID id, VALUE module);
void rb_vm_check_redefinition_by_prepend(VALUE klass);
-int rb_vm_check_optimizable_mid(VALUE mid);
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
-MJIT_STATIC VALUE ruby_vm_special_exception_copy(VALUE);
+VALUE ruby_vm_special_exception_copy(VALUE);
PUREFUNC(st_table *rb_vm_fstring_table(void));
@@ -2319,14 +1838,11 @@ void rb_print_backtrace(void);
/* vm_eval.c */
void Init_vm_eval(void);
-VALUE rb_adjust_argv_kw_splat(int *, const VALUE **, int *);
VALUE rb_current_realfilepath(void);
VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
rb_check_funcall_hook *hook, VALUE arg);
-VALUE rb_check_funcall_with_hook_kw(VALUE recv, ID mid, int argc, const VALUE *argv,
- rb_check_funcall_hook *hook, VALUE arg, int kw_splat);
const char *rb_type_str(enum ruby_value_type type);
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_yield_1(VALUE val);
@@ -2338,97 +1854,13 @@ VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
/* vm_insnhelper.c */
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
-void Init_vm_stack_canary(void);
/* vm_method.c */
void Init_eval_method(void);
+int rb_method_defined_by(VALUE obj, ID mid, VALUE (*cfunc)(ANYARGS));
-enum method_missing_reason {
- MISSING_NOENTRY = 0x00,
- MISSING_PRIVATE = 0x01,
- MISSING_PROTECTED = 0x02,
- MISSING_FCALL = 0x04,
- MISSING_VCALL = 0x08,
- MISSING_SUPER = 0x10,
- MISSING_MISSING = 0x20,
- MISSING_NONE = 0x40
-};
-struct rb_callable_method_entry_struct;
-struct rb_method_definition_struct;
-struct rb_execution_context_struct;
-struct rb_control_frame_struct;
-struct rb_calling_info;
-struct rb_call_data;
-/* I have several reasons to chose 64 here:
- *
- * - A cache line must be a power-of-two size.
- * - Setting this to anything less than or equal to 32 boosts nothing.
- * - I have never seen an architecture that has 128 byte L1 cache line.
- * - I know Intel Core and Sparc T4 at least uses 64.
- * - I know jemalloc internally has this exact same `#define CACHE_LINE 64`.
- * https://github.com/jemalloc/jemalloc/blob/dev/include/jemalloc/internal/jemalloc_internal_types.h
- */
-#define CACHELINE 64
-struct rb_call_cache {
- /* inline cache: keys */
- rb_serial_t method_state;
- rb_serial_t class_serial[
- (CACHELINE
- - sizeof(rb_serial_t) /* method_state */
- - sizeof(struct rb_callable_method_entry_struct *) /* me */
- - sizeof(uintptr_t) /* method_serial */
- - sizeof(enum method_missing_reason) /* aux */
- - sizeof(VALUE (*)( /* call */
- struct rb_execution_context_struct *e,
- struct rb_control_frame_struct *,
- struct rb_calling_info *,
- const struct rb_call_data *)))
- / sizeof(rb_serial_t)
- ];
-
- /* inline cache: values */
- const struct rb_callable_method_entry_struct *me;
- uintptr_t method_serial; /* me->def->method_serial */
-
- VALUE (*call)(struct rb_execution_context_struct *ec,
- struct rb_control_frame_struct *cfp,
- struct rb_calling_info *calling,
- struct rb_call_data *cd);
-
- union {
- unsigned int index; /* used by ivar */
- enum method_missing_reason method_missing_reason; /* used by method_missing */
- } aux;
-};
-STATIC_ASSERT(cachelined, sizeof(struct rb_call_cache) <= CACHELINE);
-struct rb_call_info {
- /* fixed at compile time */
- ID mid;
- unsigned int flag;
- int orig_argc;
-};
-struct rb_call_data {
- struct rb_call_cache cc;
- struct rb_call_info ci;
-};
-RUBY_FUNC_EXPORTED
-RUBY_FUNC_NONNULL(1, VALUE rb_funcallv_with_cc(struct rb_call_data*, VALUE, ID, int, const VALUE*));
-RUBY_FUNC_EXPORTED
-RUBY_FUNC_NONNULL(1, bool rb_method_basic_definition_p_with_cc(struct rb_call_data *, VALUE, ID));
-
-#ifdef __GNUC__
-# define rb_funcallv(recv, mid, argc, argv) \
- __extension__({ \
- static struct rb_call_data rb_funcallv_data; \
- rb_funcallv_with_cc(&rb_funcallv_data, recv, mid, argc, argv); \
- })
-# define rb_method_basic_definition_p(klass, mid) \
- __extension__({ \
- static struct rb_call_data rb_mbdp; \
- (klass == Qfalse) ? /* hidden object cannot be overridden */ true : \
- rb_method_basic_definition_p_with_cc(&rb_mbdp, klass, mid); \
- })
-#endif
+/* miniprelude.c, prelude.c */
+void Init_prelude(void);
/* vm_backtrace.c */
void Init_vm_backtrace(void);
@@ -2442,23 +1874,12 @@ VALUE rb_backtrace_to_str_ary(VALUE obj);
VALUE rb_backtrace_to_location_ary(VALUE obj);
void rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output);
-#ifdef HAVE_PWD_H
-VALUE rb_getlogin(void);
-VALUE rb_getpwdirnam_for_login(VALUE login); /* read as: "get pwd db home dir by username for login" */
-VALUE rb_getpwdiruid(void); /* read as: "get pwd db home dir for getuid()" */
-#endif
-
RUBY_SYMBOL_EXPORT_BEGIN
const char *rb_objspace_data_type_name(VALUE obj);
/* Temporary. This API will be removed (renamed). */
VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
-/* array.c (export) */
-void rb_ary_detransient(VALUE a);
-VALUE *rb_ary_ptr_use_start(VALUE ary);
-void rb_ary_ptr_use_end(VALUE ary);
-
/* bignum.c (export) */
VALUE rb_big_mul_normal(VALUE x, VALUE y);
VALUE rb_big_mul_balance(VALUE x, VALUE y);
@@ -2486,11 +1907,6 @@ enum rb_int_parse_flags {
};
VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
-/* enumerator.c (export) */
-VALUE rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv,
- rb_enumerator_size_func *size_fn,
- VALUE beg, VALUE end, VALUE step, int excl);
-
/* error.c (export) */
int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
NORETURN(void rb_unexpected_type(VALUE,int));
@@ -2500,15 +1916,8 @@ NORETURN(void rb_unexpected_type(VALUE,int));
((t) == RUBY_T_DATA && RTYPEDDATA_P(v)) ? \
rb_unexpected_type((VALUE)(v), (t)) : (void)0)
-static inline int
-rb_typeddata_is_instance_of_inline(VALUE obj, const rb_data_type_t *data_type)
-{
- return RB_TYPE_P(obj, T_DATA) && RTYPEDDATA_P(obj) && (RTYPEDDATA_TYPE(obj) == data_type);
-}
-#define rb_typeddata_is_instance_of rb_typeddata_is_instance_of_inline
-
/* file.c (export) */
-#if defined HAVE_READLINK && defined RUBY_ENCODING_H
+#ifdef HAVE_READLINK
VALUE rb_readlink(VALUE path, rb_encoding *enc);
#endif
#ifdef __APPLE__
@@ -2527,14 +1936,12 @@ void rb_write_error_str(VALUE mesg);
/* numeric.c (export) */
VALUE rb_int_positive_pow(long x, unsigned long y);
-/* object.c (export) */
-int rb_opts_exception_p(VALUE opts, int default_value);
-
/* process.c (export) */
int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
-VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell, int allow_exc_opt);
+VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell);
struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
+VALUE rb_execarg_init(int argc, const VALUE *argv, int accept_shell, VALUE execarg_obj);
int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
void rb_execarg_parent_start(VALUE execarg_obj);
void rb_execarg_parent_end(VALUE execarg_obj);
@@ -2549,25 +1956,15 @@ VALUE rb_gcd_normal(VALUE self, VALUE other);
VALUE rb_gcd_gmp(VALUE x, VALUE y);
#endif
-/* signal.c (export) */
-int rb_grantpt(int fd);
-
/* string.c (export) */
-VALUE rb_str_tmp_frozen_acquire(VALUE str);
-void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
#ifdef RUBY_ENCODING_H
/* internal use */
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
#endif
-VALUE rb_str_upto_each(VALUE, VALUE, int, int (*each)(VALUE, VALUE), VALUE);
-VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE);
/* thread.c (export) */
int ruby_thread_has_gvl_p(void); /* for ext/fiddle/closure.c */
-/* time.c (export) */
-void ruby_reset_leap_second_info(void);
-
/* util.c (export) */
extern const signed char ruby_digit36_to_number_table[];
extern const char ruby_hexdigits[];
@@ -2575,10 +1972,9 @@ extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, si
/* variable.c (export) */
void rb_mark_generic_ivar(VALUE);
-void rb_mv_generic_ivar(VALUE src, VALUE dst);
VALUE rb_const_missing(VALUE klass, VALUE name);
int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
-void rb_iv_tbl_copy(VALUE dst, VALUE src);
+st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
/* gc.c (export) */
VALUE rb_wb_protected_newobj_of(VALUE, VALUE);
@@ -2587,10 +1983,9 @@ VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE);
size_t rb_obj_memsize_of(VALUE);
void rb_gc_verify_internal_consistency(void);
-#define RB_OBJ_GC_FLAGS_MAX 6
+#define RB_OBJ_GC_FLAGS_MAX 5
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
void rb_gc_mark_values(long n, const VALUE *values);
-void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
#if IMEMO_DEBUG
VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
@@ -2599,9 +1994,6 @@ VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VAL
VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
#endif
-/* random.c */
-int ruby_fill_random_bytes(void *, size_t, int);
-
RUBY_SYMBOL_EXPORT_END
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
@@ -2634,82 +2026,6 @@ rb_obj_builtin_type(VALUE obj)
}
#endif
-/* A macro for defining a flexible array, like: VALUE ary[FLEX_ARY_LEN]; */
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-# define FLEX_ARY_LEN /* VALUE ary[]; */
-#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
-# define FLEX_ARY_LEN 0 /* VALUE ary[0]; */
-#else
-# define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
-#endif
-
-/*
- * For declaring bitfields out of non-unsigned int types:
- * struct date {
- * BITFIELD(enum months, month, 4);
- * ...
- * };
- */
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-# define BITFIELD(type, name, size) type name : size
-#else
-# define BITFIELD(type, name, size) unsigned int name : size
-#endif
-
-#if defined(_MSC_VER)
-# define COMPILER_WARNING_PUSH __pragma(warning(push))
-# define COMPILER_WARNING_POP __pragma(warning(pop))
-# define COMPILER_WARNING_ERROR(flag) __pragma(warning(error: flag)))
-# define COMPILER_WARNING_IGNORED(flag) __pragma(warning(suppress: flag)))
-
-#elif defined(__clang__) /* clang 2.6 already had this feature */
-# define COMPILER_WARNING_PUSH _Pragma("clang diagnostic push")
-# define COMPILER_WARNING_POP _Pragma("clang diagnostic pop")
-# define COMPILER_WARNING_SPECIFIER(kind, msg) \
- clang diagnostic kind # msg
-# define COMPILER_WARNING_ERROR(flag) \
- COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(error, flag))
-# define COMPILER_WARNING_IGNORED(flag) \
- COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(ignored, flag))
-
-#elif GCC_VERSION_SINCE(4, 6, 0)
-/* https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Diagnostic-Pragmas.html */
-# define COMPILER_WARNING_PUSH _Pragma("GCC diagnostic push")
-# define COMPILER_WARNING_POP _Pragma("GCC diagnostic pop")
-# define COMPILER_WARNING_SPECIFIER(kind, msg) \
- GCC diagnostic kind # msg
-# define COMPILER_WARNING_ERROR(flag) \
- COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(error, flag))
-# define COMPILER_WARNING_IGNORED(flag) \
- COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(ignored, flag))
-
-#else /* other compilers to follow? */
-# define COMPILER_WARNING_PUSH /* nop */
-# define COMPILER_WARNING_POP /* nop */
-# define COMPILER_WARNING_ERROR(flag) /* nop */
-# define COMPILER_WARNING_IGNORED(flag) /* nop */
-#endif
-
-#define COMPILER_WARNING_PRAGMA(str) COMPILER_WARNING_PRAGMA_(str)
-#define COMPILER_WARNING_PRAGMA_(str) _Pragma(#str)
-
-#if defined(USE_UNALIGNED_MEMBER_ACCESS) && USE_UNALIGNED_MEMBER_ACCESS && \
- (defined(__clang__) || GCC_VERSION_SINCE(9, 0, 0))
-# define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
- COMPILER_WARNING_PUSH; \
- COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
- typeof(expr) unaligned_member_access_result = (expr); \
- COMPILER_WARNING_POP; \
- unaligned_member_access_result; \
-})
-#else
-# define UNALIGNED_MEMBER_ACCESS(expr) expr
-#endif
-#define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
-
-#undef RB_OBJ_WRITE
-#define RB_OBJ_WRITE(a, slot, b) UNALIGNED_MEMBER_ACCESS(rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__))
-
#if defined(__cplusplus)
#if 0
{ /* satisfy cc-mode */
diff --git a/io.c b/io.c
index be6c6b637f..178ec14b58 100644
--- a/io.c
+++ b/io.c
@@ -11,37 +11,15 @@
**********************************************************************/
-#include "ruby/encoding.h"
+#include "internal.h"
#include "ruby/io.h"
#include "ruby/thread.h"
-#include "internal.h"
#include "dln.h"
#include "encindex.h"
#include "id.h"
#include <ctype.h>
#include <errno.h>
#include "ruby_atomic.h"
-#include "ccan/list/list.h"
-
-/* non-Linux poll may not work on all FDs */
-#if defined(HAVE_POLL)
-# if defined(__linux__)
-# define USE_POLL 1
-# endif
-# if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
-# define USE_POLL 1
-# endif
-#endif
-
-#ifndef USE_POLL
-# define USE_POLL 0
-#endif
-
-#if !USE_POLL
-# include "vm_core.h"
-#endif
-
-#include "builtin.h"
#undef free
#define free(x) xfree(x)
@@ -66,7 +44,7 @@
#endif
#ifdef __QNXNTO__
-#include <unix.h>
+#include "unix.h"
#endif
#include <sys/types.h>
@@ -115,10 +93,6 @@
# include <sys/wait.h> /* for WNOHANG on BSD */
#endif
-#ifdef HAVE_COPYFILE_H
-# include <copyfile.h>
-#endif
-
#include "ruby/util.h"
#ifndef O_ACCMODE
@@ -159,15 +133,6 @@ off_t __syscall(quad_t number, ...);
#define rename(f, t) rb_w32_urename((f), (t))
#endif
-#if defined(_WIN32)
-# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
-#elif defined(O_NONBLOCK)
- /* disabled for [Bug #15356] (Rack::Deflater + rails) failure: */
-# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
-#else /* any platforms where O_NONBLOCK does not exist? */
-# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
-#endif
-
VALUE rb_cIO;
VALUE rb_eEOFError;
VALUE rb_eIOError;
@@ -191,6 +156,7 @@ VALUE rb_default_rs;
static VALUE argf;
+#define id_exception idException
static ID id_write, id_read, id_getc, id_flush, id_readpartial, id_set_encoding;
static VALUE sym_mode, sym_perm, sym_flags, sym_extenc, sym_intenc, sym_encoding, sym_open_args;
static VALUE sym_textmode, sym_binmode, sym_autoclose;
@@ -217,22 +183,14 @@ static rb_atomic_t max_file_descriptor = NOFILE;
void
rb_update_max_fd(int fd)
{
+ struct stat buf;
rb_atomic_t afd = (rb_atomic_t)fd;
rb_atomic_t max_fd = max_file_descriptor;
- int err;
- if (fd < 0 || afd <= max_fd)
+ if (afd <= max_fd)
return;
-#if defined(HAVE_FCNTL) && defined(F_GETFL)
- err = fcntl(fd, F_GETFL) == -1;
-#else
- {
- struct stat buf;
- err = fstat(fd, &buf) != 0;
- }
-#endif
- if (err && errno == EBADF) {
+ if (fstat(fd, &buf) != 0 && errno == EBADF) {
rb_bug("rb_update_max_fd: invalid fd (%d) given.", fd);
}
@@ -257,7 +215,7 @@ rb_maygvl_fd_fix_cloexec(int fd)
flags2 = flags | FD_CLOEXEC; /* Set CLOEXEC for non-standard file descriptors: 3, 4, 5, ... */
if (flags != flags2) {
ret = fcntl(fd, F_SETFD, flags2);
- if (ret != 0) {
+ if (ret == -1) {
rb_bug("rb_maygvl_fd_fix_cloexec: fcntl(%d, F_SETFD, %d) failed: %s", fd, flags2, strerror(errno));
}
}
@@ -301,7 +259,7 @@ rb_cloexec_open(const char *pathname, int flags, mode_t mode)
flags |= O_NOINHERIT;
#endif
ret = open(pathname, flags, mode);
- if (ret < 0) return ret;
+ if (ret == -1) return -1;
if (ret <= 2 || o_cloexec_state == 0) {
rb_maygvl_fd_fix_cloexec(ret);
}
@@ -350,30 +308,12 @@ rb_cloexec_dup2(int oldfd, int newfd)
#else
ret = dup2(oldfd, newfd);
#endif
- if (ret < 0) return ret;
+ if (ret == -1) return -1;
}
rb_maygvl_fd_fix_cloexec(ret);
return ret;
}
-static int
-rb_fd_set_nonblock(int fd)
-{
-#ifdef _WIN32
- return rb_w32_set_nonblock(fd);
-#elif defined(F_GETFL)
- int oflags = fcntl(fd, F_GETFL);
-
- if (oflags == -1)
- return -1;
- if (oflags & O_NONBLOCK)
- return 0;
- oflags |= O_NONBLOCK;
- return fcntl(fd, F_SETFL, oflags);
-#endif
- return 0;
-}
-
int
rb_cloexec_pipe(int fildes[2])
{
@@ -382,7 +322,7 @@ rb_cloexec_pipe(int fildes[2])
#if defined(HAVE_PIPE2)
static int try_pipe2 = 1;
if (try_pipe2) {
- ret = pipe2(fildes, O_CLOEXEC | RUBY_PIPE_NONBLOCK_DEFAULT);
+ ret = pipe2(fildes, O_CLOEXEC);
if (ret != -1)
return ret;
/* pipe2 is available since Linux 2.6.27, glibc 2.9. */
@@ -397,7 +337,7 @@ rb_cloexec_pipe(int fildes[2])
#else
ret = pipe(fildes);
#endif
- if (ret < 0) return ret;
+ if (ret == -1) return -1;
#ifdef __CYGWIN__
if (ret == 0 && fildes[1] == -1) {
close(fildes[0]);
@@ -408,10 +348,6 @@ rb_cloexec_pipe(int fildes[2])
#endif
rb_maygvl_fd_fix_cloexec(fildes[0]);
rb_maygvl_fd_fix_cloexec(fildes[1]);
- if (RUBY_PIPE_NONBLOCK_DEFAULT) {
- rb_fd_set_nonblock(fildes[0]);
- rb_fd_set_nonblock(fildes[1]);
- }
return ret;
}
@@ -444,7 +380,7 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
ret = fcntl(fd, F_DUPFD, minfd);
#elif defined(HAVE_DUP)
ret = dup(fd);
- if (ret >= 0 && ret < minfd) {
+ if (ret != -1 && ret < minfd) {
const int prev_fd = ret;
ret = rb_cloexec_fcntl_dupfd(fd, minfd);
close(prev_fd);
@@ -453,7 +389,7 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
#else
# error "dup() or fcntl(F_DUPFD) must be supported."
#endif
- if (ret < 0) return ret;
+ if (ret == -1) return -1;
rb_maygvl_fd_fix_cloexec(ret);
return ret;
}
@@ -517,14 +453,7 @@ static rb_io_t *flush_before_seek(rb_io_t *fptr);
* conversion IO process and universal newline decorator by default.
*/
#define NEED_READCONV(fptr) ((fptr)->encs.enc2 != NULL || (fptr)->encs.ecflags & ~ECONV_CRLF_NEWLINE_DECORATOR)
-#define WRITECONV_MASK ( \
- (ECONV_DECORATOR_MASK & ~ECONV_CRLF_NEWLINE_DECORATOR)|\
- ECONV_STATEFUL_DECORATOR_MASK|\
- 0)
-#define NEED_WRITECONV(fptr) ( \
- ((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || \
- ((fptr)->encs.ecflags & WRITECONV_MASK) || \
- 0)
+#define NEED_WRITECONV(fptr) (((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || ((fptr)->encs.ecflags & ((ECONV_DECORATOR_MASK & ~ECONV_CRLF_NEWLINE_DECORATOR)|ECONV_STATEFUL_DECORATOR_MASK)))
#define SET_BINARY_MODE(fptr) setmode((fptr)->fd, O_BINARY)
#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr) do {\
@@ -652,11 +581,7 @@ set_binary_mode_with_seek_cur(rb_io_t *fptr)
/* Unix */
# define DEFAULT_TEXTMODE 0
#define NEED_READCONV(fptr) ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr))
-#define NEED_WRITECONV(fptr) ( \
- ((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || \
- NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) || \
- ((fptr)->encs.ecflags & (ECONV_DECORATOR_MASK|ECONV_STATEFUL_DECORATOR_MASK)) || \
- 0)
+#define NEED_WRITECONV(fptr) (((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) || ((fptr)->encs.ecflags & (ECONV_DECORATOR_MASK|ECONV_STATEFUL_DECORATOR_MASK)))
#define SET_BINARY_MODE(fptr) (void)(fptr)
#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr) (void)(fptr)
#define SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(enc2, ecflags) ((void)(enc2), (void)(ecflags))
@@ -684,15 +609,6 @@ is_socket(int fd, VALUE path)
static const char closed_stream[] = "closed stream";
-static void
-io_fd_check_closed(int fd)
-{
- if (fd < 0) {
- rb_thread_check_ints(); /* check for ruby_error_stream_closed */
- rb_raise(rb_eIOError, closed_stream);
- }
-}
-
void
rb_eof_error(void)
{
@@ -718,7 +634,9 @@ void
rb_io_check_closed(rb_io_t *fptr)
{
rb_io_check_initialized(fptr);
- io_fd_check_closed(fptr->fd);
+ if (fptr->fd < 0) {
+ rb_raise(rb_eIOError, closed_stream);
+ }
}
static rb_io_t *
@@ -994,7 +912,6 @@ io_alloc(VALUE klass)
struct io_internal_read_struct {
int fd;
- int nonblock;
void *buf;
size_t capa;
};
@@ -1013,24 +930,11 @@ struct io_internal_writev_struct {
};
#endif
-static int nogvl_wait_for_single_fd(int fd, short events);
static VALUE
internal_read_func(void *ptr)
{
struct io_internal_read_struct *iis = ptr;
- ssize_t r;
-retry:
- r = read(iis->fd, iis->buf, iis->capa);
- if (r < 0 && !iis->nonblock) {
- int e = errno;
- if (e == EAGAIN || e == EWOULDBLOCK) {
- if (nogvl_wait_for_single_fd(iis->fd, RB_WAITFD_IN) != -1) {
- goto retry;
- }
- errno = e;
- }
- }
- return r;
+ return read(iis->fd, iis->buf, iis->capa);
}
#if defined __APPLE__
@@ -1050,7 +954,8 @@ internal_write_func(void *ptr)
static void*
internal_write_func2(void *ptr)
{
- return (void*)internal_write_func(ptr);
+ struct io_internal_write_struct *iis = ptr;
+ return (void*)(intptr_t)write(iis->fd, iis->buf, iis->capa);
}
#ifdef HAVE_WRITEV
@@ -1068,9 +973,7 @@ static ssize_t
rb_read_internal(int fd, void *buf, size_t count)
{
struct io_internal_read_struct iis;
-
iis.fd = fd;
- iis.nonblock = 0;
iis.buf = buf;
iis.capa = count;
@@ -1192,6 +1095,7 @@ io_fflush(rb_io_t *fptr)
rb_io_check_closed(fptr);
if (fptr->wbuf.len == 0)
return 0;
+ rb_io_check_closed(fptr);
while (fptr->wbuf.len > 0 && io_flush_buffer(fptr) != 0) {
if (!rb_io_wait_writable(fptr->fd))
return -1;
@@ -1203,7 +1107,9 @@ io_fflush(rb_io_t *fptr)
int
rb_io_wait_readable(int f)
{
- io_fd_check_closed(f);
+ if (f < 0) {
+ rb_raise(rb_eIOError, closed_stream);
+ }
switch (errno) {
case EINTR:
#if defined(ERESTART)
@@ -1227,7 +1133,9 @@ rb_io_wait_readable(int f)
int
rb_io_wait_writable(int f)
{
- io_fd_check_closed(f);
+ if (f < 0) {
+ rb_raise(rb_eIOError, closed_stream);
+ }
switch (errno) {
case EINTR:
#if defined(ERESTART)
@@ -1344,8 +1252,8 @@ io_binwrite_string(VALUE arg)
r = rb_writev_internal(fptr->fd, iov, 2);
- if (r < 0)
- return r;
+ if (r == -1)
+ return -1;
if (fptr->wbuf.len <= r) {
r -= fptr->wbuf.len;
@@ -1458,11 +1366,6 @@ io_binwrite(VALUE str, const char *ptr, long len, rb_io_t *fptr, int nosync)
# define MODE_BTMODE(a,b,c) ((fmode & FMODE_BINMODE) ? (b) : \
(fmode & FMODE_TEXTMODE) ? (c) : (a))
-
-#define MODE_BTXMODE(a, b, c, d, e, f) ((fmode & FMODE_EXCL) ? \
- MODE_BTMODE(d, e, f) : \
- MODE_BTMODE(a, b, c))
-
static VALUE
do_writeconv(VALUE str, rb_io_t *fptr, int *converted)
{
@@ -1576,7 +1479,7 @@ io_write(VALUE io, VALUE str, int nosync)
rb_io_check_writable(fptr);
n = io_fwrite(str, fptr, nosync);
- if (n < 0L) rb_sys_fail_path(fptr->pathv);
+ if (n == -1L) rb_sys_fail_path(fptr->pathv);
return LONG2FIX(n);
}
@@ -1720,16 +1623,6 @@ io_fwritev(int argc, VALUE *argv, rb_io_t *fptr)
return n;
}
-
-static int
-iovcnt_ok(int iovcnt)
-{
-#ifdef IOV_MAX
- return iovcnt < IOV_MAX;
-#else /* GNU/Hurd has writev, but no IOV_MAX */
- return 1;
-#endif
-}
#endif /* HAVE_WRITEV */
static VALUE
@@ -1753,7 +1646,7 @@ io_writev(int argc, VALUE *argv, VALUE io)
for (i = 0; i < argc; i += cnt) {
#ifdef HAVE_WRITEV
- if ((fptr->mode & (FMODE_SYNC|FMODE_TTY)) && iovcnt_ok(cnt = argc - i)) {
+ if ((fptr->mode & (FMODE_SYNC|FMODE_TTY)) && ((cnt = argc - i) < IOV_MAX)) {
n = io_fwritev(cnt, &argv[i], fptr);
}
else
@@ -1763,7 +1656,7 @@ io_writev(int argc, VALUE *argv, VALUE io)
/* sync at last item */
n = io_fwrite(rb_obj_as_string(argv[i]), fptr, (i < argc-1));
}
- if (n < 0L) rb_sys_fail_path(fptr->pathv);
+ if (n == -1L) rb_sys_fail_path(fptr->pathv);
total = rb_fix_plus(LONG2FIX(n), total);
}
@@ -1791,7 +1684,7 @@ io_writev(int argc, VALUE *argv, VALUE io)
static VALUE
io_write_m(int argc, VALUE *argv, VALUE io)
{
- if (argc != 1) {
+ if (argc > 1) {
return io_writev(argc, argv, io);
}
else {
@@ -2033,7 +1926,7 @@ static void clear_readconv(rb_io_t *fptr);
* ios.rewind -> 0
*
* Positions <em>ios</em> to the beginning of input, resetting
- * #lineno to zero.
+ * <code>lineno</code> to zero.
*
* f = File.new("testfile")
* f.readline #=> "This is line one\n"
@@ -2063,16 +1956,6 @@ rb_io_rewind(VALUE io)
}
static int
-fptr_wait_readable(rb_io_t *fptr)
-{
- int ret = rb_io_wait_readable(fptr->fd);
-
- if (ret)
- rb_io_check_closed(fptr);
- return ret;
-}
-
-static int
io_fillbuf(rb_io_t *fptr)
{
ssize_t r;
@@ -2092,7 +1975,7 @@ io_fillbuf(rb_io_t *fptr)
r = rb_read_internal(fptr->fd, fptr->rbuf.ptr, fptr->rbuf.capa);
}
if (r < 0) {
- if (fptr_wait_readable(fptr))
+ if (rb_io_wait_readable(fptr->fd))
goto retry;
{
int e = errno;
@@ -2119,14 +2002,14 @@ io_fillbuf(rb_io_t *fptr)
*
* Returns true if <em>ios</em> is at end of file that means
* there are no more data to read.
- * The stream must be opened for reading or an IOError will be
+ * The stream must be opened for reading or an <code>IOError</code> will be
* raised.
*
* f = File.new("testfile")
* dummy = f.readlines
* f.eof #=> true
*
- * If <em>ios</em> is a stream such as pipe or socket, IO#eof?
+ * If <em>ios</em> is a stream such as pipe or socket, <code>IO#eof?</code>
* blocks until the other end sends some data or closes it.
*
* r, w = IO.pipe
@@ -2140,9 +2023,10 @@ io_fillbuf(rb_io_t *fptr)
* r, w = IO.pipe
* r.eof? # blocks forever
*
- * Note that IO#eof? reads data to the input byte buffer. So
- * IO#sysread may not behave as you intend with IO#eof?, unless you
- * call IO#rewind first (which is not available for some streams).
+ * Note that <code>IO#eof?</code> reads data to the input byte buffer.
+ * So <code>IO#sysread</code> may not behave as you intend with
+ * <code>IO#eof?</code>, unless you call <code>IO#rewind</code>
+ * first (which is not available for some streams).
*/
VALUE
@@ -2174,7 +2058,7 @@ rb_io_eof(VALUE io)
* Returns the current ``sync mode'' of <em>ios</em>. When sync mode is
* true, all output is immediately flushed to the underlying operating
* system and is not buffered by Ruby internally. See also
- * IO#fsync.
+ * <code>IO#fsync</code>.
*
* f = File.new("testfile")
* f.sync #=> false
@@ -2199,7 +2083,7 @@ rb_io_sync(VALUE io)
* Sets the ``sync mode'' to <code>true</code> or <code>false</code>.
* When sync mode is true, all output is immediately flushed to the
* underlying operating system and is not buffered internally. Returns
- * the new state. See also IO#fsync.
+ * the new state. See also <code>IO#fsync</code>.
*
* f = File.new("testfile")
* f.sync = true
@@ -2226,11 +2110,12 @@ rb_io_set_sync(VALUE io, VALUE sync)
* ios.fsync -> 0 or nil
*
* Immediately writes all buffered data in <em>ios</em> to disk.
- * Note that #fsync differs from using IO#sync=. The latter ensures
- * that data is flushed from Ruby's buffers, but does not guarantee
- * that the underlying operating system actually writes it to disk.
+ * Note that <code>fsync</code> differs from
+ * using <code>IO#sync=</code>. The latter ensures that data is flushed
+ * from Ruby's buffers, but does not guarantee that the underlying
+ * operating system actually writes it to disk.
*
- * NotImplementedError is raised
+ * <code>NotImplementedError</code> is raised
* if the underlying operating system does not support <em>fsync(2)</em>.
*/
@@ -2279,8 +2164,8 @@ nogvl_fdatasync(void *ptr)
* Immediately writes all buffered data in <em>ios</em> to disk.
*
* If the underlying operating system does not support <em>fdatasync(2)</em>,
- * IO#fsync is called instead (which might raise a
- * NotImplementedError).
+ * <code>IO#fsync</code> is called instead (which might raise a
+ * <code>NotImplementedError</code>).
*/
static VALUE
@@ -2333,7 +2218,7 @@ rb_io_fileno(VALUE io)
* ios.pid -> integer
*
* Returns the process ID of a child process associated with
- * <em>ios</em>. This will be set by IO.popen.
+ * <em>ios</em>. This will be set by <code>IO.popen</code>.
*
* pipe = IO.popen("-")
* if pipe
@@ -2437,7 +2322,7 @@ io_bufread(char *ptr, long len, rb_io_t *fptr)
c = rb_read_internal(fptr->fd, ptr+offset, n);
if (c == 0) break;
if (c < 0) {
- if (fptr_wait_readable(fptr))
+ if (rb_io_wait_readable(fptr->fd))
goto again;
return -1;
}
@@ -2493,6 +2378,16 @@ io_fread(VALUE str, long offset, long size, rb_io_t *fptr)
return len;
}
+ssize_t
+rb_io_bufread(VALUE io, void *buf, size_t size)
+{
+ rb_io_t *fptr;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ return (ssize_t)io_bufread(buf, (long)size, fptr);
+}
+
static long
remain_size(rb_io_t *fptr)
{
@@ -2525,6 +2420,7 @@ remain_size(rb_io_t *fptr)
static VALUE
io_enc_str(VALUE str, rb_io_t *fptr)
{
+ OBJ_TAINT(str);
rb_enc_associate(str, io_read_encoding(fptr));
return str;
}
@@ -2612,7 +2508,7 @@ fill_cbuf(rb_io_t *fptr, int ec_flags)
if (res == econv_source_buffer_empty) {
if (fptr->rbuf.len == 0) {
READ_CHECK(fptr);
- if (io_fillbuf(fptr) < 0) {
+ if (io_fillbuf(fptr) == -1) {
if (!fptr->readconv) {
return MORE_CHAR_FINISHED;
}
@@ -2654,6 +2550,7 @@ io_shift_cbuf(rb_io_t *fptr, int len, VALUE *strp)
else {
rb_str_cat(str, fptr->cbuf.ptr+fptr->cbuf.off, len);
}
+ OBJ_TAINT(str);
rb_enc_associate(str, fptr->encs.enc);
}
fptr->cbuf.off += len;
@@ -2781,34 +2678,60 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
void
rb_io_set_nonblock(rb_io_t *fptr)
{
- if (rb_fd_set_nonblock(fptr->fd) != 0) {
+#ifdef _WIN32
+ if (rb_w32_set_nonblock(fptr->fd) != 0) {
rb_sys_fail_path(fptr->pathv);
}
+#else
+ int oflags;
+#ifdef F_GETFL
+ oflags = fcntl(fptr->fd, F_GETFL);
+ if (oflags == -1) {
+ rb_sys_fail_path(fptr->pathv);
+ }
+#else
+ oflags = 0;
+#endif
+ if ((oflags & O_NONBLOCK) == 0) {
+ oflags |= O_NONBLOCK;
+ if (fcntl(fptr->fd, F_SETFL, oflags) == -1) {
+ rb_sys_fail_path(fptr->pathv);
+ }
+ }
+#endif
}
+struct read_internal_arg {
+ int fd;
+ char *str_ptr;
+ long len;
+};
+
static VALUE
read_internal_call(VALUE arg)
{
- struct io_internal_read_struct *iis = (struct io_internal_read_struct *)arg;
-
- return rb_thread_io_blocking_region(internal_read_func, iis, iis->fd);
+ struct read_internal_arg *p = (struct read_internal_arg *)arg;
+ p->len = rb_read_internal(p->fd, p->str_ptr, p->len);
+ return Qundef;
}
-static long
-read_internal_locktmp(VALUE str, struct io_internal_read_struct *iis)
+static int
+no_exception_p(VALUE opts)
{
- return (long)rb_str_locktmp_ensure(str, read_internal_call, (VALUE)iis);
-}
+ VALUE except;
+ ID id = id_exception;
-#define no_exception_p(opts) !rb_opts_exception_p((opts), TRUE)
+ rb_get_kwargs(opts, &id, 0, 1, &except);
+ return except == Qfalse;
+}
static VALUE
-io_getpartial(int argc, VALUE *argv, VALUE io, int no_exception, int nonblock)
+io_getpartial(int argc, VALUE *argv, VALUE io, VALUE opts, int nonblock)
{
rb_io_t *fptr;
VALUE length, str;
long n, len;
- struct io_internal_read_struct iis;
+ struct read_internal_arg arg;
int shrinkable;
rb_scan_args(argc, argv, "11", &length, &str);
@@ -2818,14 +2741,13 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int no_exception, int nonblock)
}
shrinkable = io_setstrbuf(&str, len);
+ OBJ_TAINT(str);
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
- if (len == 0) {
- io_set_read_length(str, 0, shrinkable);
+ if (len == 0)
return str;
- }
if (!nonblock)
READ_CHECK(fptr);
@@ -2836,17 +2758,17 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int no_exception, int nonblock)
rb_io_set_nonblock(fptr);
}
io_setstrbuf(&str, len);
- iis.fd = fptr->fd;
- iis.nonblock = nonblock;
- iis.buf = RSTRING_PTR(str);
- iis.capa = len;
- n = read_internal_locktmp(str, &iis);
+ arg.fd = fptr->fd;
+ arg.str_ptr = RSTRING_PTR(str);
+ arg.len = len;
+ rb_str_locktmp_ensure(str, read_internal_call, (VALUE)&arg);
+ n = arg.len;
if (n < 0) {
int e = errno;
- if (!nonblock && fptr_wait_readable(fptr))
+ if (!nonblock && rb_io_wait_readable(fptr->fd))
goto again;
if (nonblock && (e == EWOULDBLOCK || e == EAGAIN)) {
- if (no_exception)
+ if (no_exception_p(opts))
return sym_wait_readable;
else
rb_readwrite_syserr_fail(RB_IO_WAIT_READABLE,
@@ -2877,7 +2799,7 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int no_exception, int nonblock)
* The _outbuf_ will contain only the received data after the method call
* even if it is not empty at the beginning.
*
- * It raises EOFError on end of file.
+ * It raises <code>EOFError</code> on end of file.
*
* readpartial is designed for streams such as pipe, socket, tty, etc.
* It blocks only when no data immediately available.
@@ -2916,15 +2838,11 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int no_exception, int nonblock)
*
* Note that readpartial behaves similar to sysread.
* The differences are:
- * * If the byte buffer is not empty, read from the byte buffer
- * instead of "sysread for buffered IO (IOError)".
- * * It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When
- * readpartial meets EWOULDBLOCK and EINTR by read system call,
- * readpartial retry the system call.
+ * * If the byte buffer is not empty, read from the byte buffer instead of "sysread for buffered IO (IOError)".
+ * * It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When readpartial meets EWOULDBLOCK and EINTR by read system call, readpartial retry the system call.
*
* The latter means that readpartial is nonblocking-flag insensitive.
- * It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as
- * if the fd is blocking mode.
+ * It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode.
*
*/
@@ -2940,9 +2858,9 @@ io_readpartial(int argc, VALUE *argv, VALUE io)
}
static VALUE
-io_nonblock_eof(int no_exception)
+io_nonblock_eof(VALUE opts)
{
- if (!no_exception) {
+ if (!no_exception_p(opts)) {
rb_eof_error();
}
return Qnil;
@@ -2950,11 +2868,11 @@ io_nonblock_eof(int no_exception)
/* :nodoc: */
static VALUE
-io_read_nonblock(rb_execution_context_t *ec, VALUE io, VALUE length, VALUE str, VALUE ex)
+io_read_nonblock(VALUE io, VALUE length, VALUE str, VALUE ex)
{
rb_io_t *fptr;
long n, len;
- struct io_internal_read_struct iis;
+ struct read_internal_arg arg;
int shrinkable;
if ((len = NUM2LONG(length)) < 0) {
@@ -2962,29 +2880,26 @@ io_read_nonblock(rb_execution_context_t *ec, VALUE io, VALUE length, VALUE str,
}
shrinkable = io_setstrbuf(&str, len);
- rb_bool_expected(ex, "exception");
-
+ OBJ_TAINT(str);
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
- if (len == 0) {
- io_set_read_length(str, 0, shrinkable);
+ if (len == 0)
return str;
- }
n = read_buffered_data(RSTRING_PTR(str), len, fptr);
if (n <= 0) {
rb_io_set_nonblock(fptr);
shrinkable |= io_setstrbuf(&str, len);
- iis.fd = fptr->fd;
- iis.nonblock = 1;
- iis.buf = RSTRING_PTR(str);
- iis.capa = len;
- n = read_internal_locktmp(str, &iis);
+ arg.fd = fptr->fd;
+ arg.str_ptr = RSTRING_PTR(str);
+ arg.len = len;
+ rb_str_locktmp_ensure(str, read_internal_call, (VALUE)&arg);
+ n = arg.len;
if (n < 0) {
int e = errno;
if ((e == EWOULDBLOCK || e == EAGAIN)) {
- if (!ex) return sym_wait_readable;
+ if (ex == Qfalse) return sym_wait_readable;
rb_readwrite_syserr_fail(RB_IO_WAIT_READABLE,
e, "read would block");
}
@@ -2994,7 +2909,7 @@ io_read_nonblock(rb_execution_context_t *ec, VALUE io, VALUE length, VALUE str,
io_set_read_length(str, n, shrinkable);
if (n == 0) {
- if (!ex) return Qnil;
+ if (ex == Qfalse) return Qnil;
rb_eof_error();
}
@@ -3003,14 +2918,13 @@ io_read_nonblock(rb_execution_context_t *ec, VALUE io, VALUE length, VALUE str,
/* :nodoc: */
static VALUE
-io_write_nonblock(rb_execution_context_t *ec, VALUE io, VALUE str, VALUE ex)
+io_write_nonblock(VALUE io, VALUE str, VALUE ex)
{
rb_io_t *fptr;
long n;
if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
- rb_bool_expected(ex, "exception");
io = GetWriteIO(io);
GetOpenFile(io, fptr);
@@ -3023,10 +2937,10 @@ io_write_nonblock(rb_execution_context_t *ec, VALUE io, VALUE str, VALUE ex)
n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));
RB_GC_GUARD(str);
- if (n < 0) {
+ if (n == -1) {
int e = errno;
if (e == EWOULDBLOCK || e == EAGAIN) {
- if (!ex) {
+ if (ex == Qfalse) {
return sym_wait_writable;
}
else {
@@ -3150,6 +3064,7 @@ io_read(int argc, VALUE *argv, VALUE io)
}
#endif
if (n == 0) return Qnil;
+ OBJ_TAINT(str);
return str;
}
@@ -3597,12 +3512,12 @@ rb_io_gets_internal(VALUE io)
* <i>sep</i>. A separator of +nil+ reads the entire
* contents, and a zero-length separator reads the input a paragraph at
* a time (two successive newlines in the input separate paragraphs).
- * The stream must be opened for reading or an IOError will be raised.
- * The line read in will be returned and also assigned to
- * <code>$_</code>. Returns +nil+ if called at end of file. If the
- * first argument is an integer, or optional second argument is given,
- * the returning string would not be longer than the given value in
- * bytes.
+ * The stream must be opened for reading or an <code>IOError</code>
+ * will be raised. The line read in will be returned and also assigned
+ * to <code>$_</code>. Returns +nil+ if called at end of
+ * file. If the first argument is an integer, or optional second
+ * argument is given, the returning string would not be longer than the
+ * given value in bytes.
*
* File.new("testfile").gets #=> "This is line one\n"
* $_ #=> "This is line one\n"
@@ -3636,12 +3551,12 @@ rb_io_gets_m(int argc, VALUE *argv, VALUE io)
* ios.lineno -> integer
*
* Returns the current line number in <em>ios</em>. The stream must be
- * opened for reading. #lineno counts the number of times #gets is called
- * rather than the number of newlines encountered. The two values will
- * differ if #gets is called with a separator other than newline.
+ * opened for reading. <code>lineno</code> counts the number of times
+ * #gets is called rather than the number of newlines encountered. The two
+ * values will differ if #gets is called with a separator other than newline.
*
* Methods that use <code>$/</code> like #each, #lines and #readline will
- * also increment #lineno.
+ * also increment <code>lineno</code>.
*
* See also the <code>$.</code> variable.
*
@@ -3697,7 +3612,8 @@ rb_io_set_lineno(VALUE io, VALUE lineno)
* ios.readline(limit [, getline_args]) -> string
* ios.readline(sep, limit [, getline_args]) -> string
*
- * Reads a line as with IO#gets, but raises an EOFError on end of file.
+ * Reads a line as with <code>IO#gets</code>, but raises an
+ * <code>EOFError</code> on end of file.
*/
static VALUE
@@ -3726,7 +3642,7 @@ static VALUE io_readlines(const struct getline_arg *arg, VALUE io);
* If the first argument is an integer, or an
* optional second argument is given, the returning string would not be
* longer than the given value in bytes. The stream must be opened for
- * reading or an IOError will be raised.
+ * reading or an <code>IOError</code> will be raised.
*
* f = File.new("testfile")
* f.readlines[0] #=> "This is line one\n"
@@ -3774,7 +3690,7 @@ io_readlines(const struct getline_arg *arg, VALUE io)
*
* Executes the block for every line in <em>ios</em>, where lines are
* separated by <i>sep</i>. <em>ios</em> must be opened for
- * reading or an IOError will be raised.
+ * reading or an <code>IOError</code> will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@@ -3808,13 +3724,13 @@ rb_io_each_line(int argc, VALUE *argv, VALUE io)
}
/*
- * This is a deprecated alias for #each_line.
+ * This is a deprecated alias for <code>each_line</code>.
*/
static VALUE
rb_io_lines(int argc, VALUE *argv, VALUE io)
{
- rb_warn_deprecated("IO#lines", "#each_line");
+ rb_warn("IO#lines is deprecated; use #each_line instead");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_line")), argc, argv);
return rb_io_each_line(argc, argv, io);
@@ -3827,7 +3743,7 @@ rb_io_lines(int argc, VALUE *argv, VALUE io)
*
* Calls the given block once for each byte (0..255) in <em>ios</em>,
* passing the byte as an argument. The stream must be opened for
- * reading or an IOError will be raised.
+ * reading or an <code>IOError</code> will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@@ -3859,13 +3775,13 @@ rb_io_each_byte(VALUE io)
}
/*
- * This is a deprecated alias for #each_byte.
+ * This is a deprecated alias for <code>each_byte</code>.
*/
static VALUE
rb_io_bytes(VALUE io)
{
- rb_warn_deprecated("IO#bytes", "#each_byte");
+ rb_warn("IO#bytes is deprecated; use #each_byte instead");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_byte")), 0, 0);
return rb_io_each_byte(io);
@@ -3985,7 +3901,7 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
*
* Calls the given block once for each character in <em>ios</em>,
* passing the character as an argument. The stream must be opened for
- * reading or an IOError will be raised.
+ * reading or an <code>IOError</code> will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@@ -4013,13 +3929,13 @@ rb_io_each_char(VALUE io)
}
/*
- * This is a deprecated alias for #each_char.
+ * This is a deprecated alias for <code>each_char</code>.
*/
static VALUE
rb_io_chars(VALUE io)
{
- rb_warn_deprecated("IO#chars", "#each_char");
+ rb_warn("IO#chars is deprecated; use #each_char instead");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_char")), 0, 0);
return rb_io_each_char(io);
@@ -4033,9 +3949,9 @@ rb_io_chars(VALUE io)
* ios.each_codepoint -> an_enumerator
* ios.codepoints -> an_enumerator
*
- * Passes the Integer ordinal of each character in <i>ios</i>,
+ * Passes the <code>Integer</code> ordinal of each character in <i>ios</i>,
* passing the codepoint as an argument. The stream must be opened for
- * reading or an IOError will be raised.
+ * reading or an <code>IOError</code> will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@@ -4141,13 +4057,13 @@ rb_io_each_codepoint(VALUE io)
}
/*
- * This is a deprecated alias for #each_codepoint.
+ * This is a deprecated alias for <code>each_codepoint</code>.
*/
static VALUE
rb_io_codepoints(VALUE io)
{
- rb_warn_deprecated("IO#codepoints", "#each_codepoint");
+ rb_warn("IO#codepoints is deprecated; use #each_codepoint instead");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_codepoint")), 0, 0);
return rb_io_each_codepoint(io);
@@ -4185,7 +4101,7 @@ rb_io_getc(VALUE io)
* ios.readchar -> string
*
* Reads a one-character string from <em>ios</em>. Raises an
- * EOFError on end of file.
+ * <code>EOFError</code> on end of file.
*
* f = File.new("testfile")
* f.readchar #=> "h"
@@ -4244,8 +4160,8 @@ rb_io_getbyte(VALUE io)
* call-seq:
* ios.readbyte -> integer
*
- * Reads a byte as with IO#getbyte, but raises an EOFError on end of
- * file.
+ * Reads a byte as with <code>IO#getbyte</code>, but raises an
+ * <code>EOFError</code> on end of file.
*/
static VALUE
@@ -4268,7 +4184,7 @@ rb_io_readbyte(VALUE io)
* such that a subsequent buffered read will return it. Only one byte
* may be pushed back before a subsequent read operation (that is,
* you will be able to read only the last of several bytes that have been pushed
- * back). Has no effect with unbuffered reads (such as IO#sysread).
+ * back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
*
* f = File.new("testfile") #=> #<File:testfile>
* b = f.getbyte #=> 0x38
@@ -4283,17 +4199,13 @@ rb_io_ungetbyte(VALUE io, VALUE b)
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
- switch (TYPE(b)) {
- case T_NIL:
- return Qnil;
- case T_FIXNUM:
- case T_BIGNUM: ;
- VALUE v = rb_int_modulo(b, INT2FIX(256));
- unsigned char c = NUM2INT(v) & 0xFF;
- b = rb_str_new((const char *)&c, 1);
- break;
- default:
- SafeStringValue(b);
+ if (NIL_P(b)) return Qnil;
+ if (FIXNUM_P(b)) {
+ char cc = FIX2INT(b);
+ b = rb_str_new(&cc, 1);
+ }
+ else {
+ SafeStringValue(b);
}
io_ungetbyte(b, fptr);
return Qnil;
@@ -4307,7 +4219,7 @@ rb_io_ungetbyte(VALUE io, VALUE b)
* such that a subsequent buffered character read will return it. Only one character
* may be pushed back before a subsequent read operation (that is,
* you will be able to read only the last of several characters that have been pushed
- * back). Has no effect with unbuffered reads (such as IO#sysread).
+ * back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
*
* f = File.new("testfile") #=> #<File:testfile>
* c = f.getc #=> "8"
@@ -4462,7 +4374,7 @@ rb_io_set_close_on_exec(VALUE io, VALUE arg)
if ((ret & FD_CLOEXEC) != flag) {
ret = (ret & ~FD_CLOEXEC) | flag;
ret = fcntl(fd, F_SETFD, ret);
- if (ret != 0) rb_sys_fail_path(fptr->pathv);
+ if (ret == -1) rb_sys_fail_path(fptr->pathv);
}
}
@@ -4474,7 +4386,7 @@ rb_io_set_close_on_exec(VALUE io, VALUE arg)
if ((ret & FD_CLOEXEC) != flag) {
ret = (ret & ~FD_CLOEXEC) | flag;
ret = fcntl(fd, F_SETFD, ret);
- if (ret != 0) rb_sys_fail_path(fptr->pathv);
+ if (ret == -1) rb_sys_fail_path(fptr->pathv);
}
}
return Qnil;
@@ -4604,8 +4516,7 @@ static void free_io_buffer(rb_io_buffer_t *buf);
static void clear_codeconv(rb_io_t *fptr);
static void
-fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
- struct list_head *busy)
+fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl)
{
VALUE err = Qnil;
int fd = fptr->fd;
@@ -4625,7 +4536,8 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
}
if (fptr->wbuf.len) {
if (noraise) {
- io_flush_buffer_sync(fptr);
+ if ((int)io_flush_buffer_sync(fptr) < 0 && NIL_P(err))
+ err = Qtrue;
}
else {
if (io_fflush(fptr) < 0 && NIL_P(err))
@@ -4637,14 +4549,6 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
fptr->stdio_file = 0;
fptr->mode &= ~(FMODE_READABLE|FMODE_WRITABLE);
- /*
- * ensure waiting_fd users do not hit EBADF, wait for them
- * to exit before we call close().
- */
- if (busy) {
- do rb_thread_schedule(); while (!list_empty(busy));
- }
-
if (IS_PREP_STDIO(fptr) || fd <= 2) {
/* need to keep FILE objects of stdin, stdout and stderr */
}
@@ -4652,7 +4556,7 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
/* stdio_file is deallocated anyway
* even if fclose failed. */
if ((maygvl_fclose(stdio_file, noraise) < 0) && NIL_P(err))
- if (!noraise) err = INT2NUM(errno);
+ err = noraise ? Qtrue : INT2NUM(errno);
}
else if (0 <= fd) {
/* fptr->fd may be closed even if close fails.
@@ -4663,7 +4567,7 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
keepgvl |= !(mode & FMODE_WRITABLE);
keepgvl |= noraise;
if ((maygvl_close(fd, keepgvl) < 0) && NIL_P(err))
- if (!noraise) err = INT2NUM(errno);
+ err = noraise ? Qtrue : INT2NUM(errno);
}
if (!NIL_P(err) && !noraise) {
@@ -4677,7 +4581,7 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
static void
fptr_finalize(rb_io_t *fptr, int noraise)
{
- fptr_finalize_flush(fptr, noraise, FALSE, 0);
+ fptr_finalize_flush(fptr, noraise, FALSE);
free_io_buffer(&fptr->rbuf);
free_io_buffer(&fptr->wbuf);
clear_codeconv(fptr);
@@ -4730,36 +4634,21 @@ clear_codeconv(rb_io_t *fptr)
clear_writeconv(fptr);
}
-void
-rb_io_fptr_finalize_internal(void *ptr)
+int
+rb_io_fptr_finalize(rb_io_t *fptr)
{
- rb_io_t *fptr = ptr;
-
- if (!ptr) return;
+ if (!fptr) return 0;
fptr->pathv = Qnil;
if (0 <= fptr->fd)
- rb_io_fptr_cleanup(fptr, TRUE);
+ rb_io_fptr_cleanup(fptr, TRUE);
fptr->write_lock = 0;
free_io_buffer(&fptr->rbuf);
free_io_buffer(&fptr->wbuf);
clear_codeconv(fptr);
free(fptr);
+ return 1;
}
-#undef rb_io_fptr_finalize
-int
-rb_io_fptr_finalize(rb_io_t *fptr)
-{
- if (!fptr) {
- return 0;
- }
- else {
- rb_io_fptr_finalize_internal(fptr);
- return 1;
- }
-}
-#define rb_io_fptr_finalize(fptr) rb_io_fptr_finalize_internal(fptr)
-
RUBY_FUNC_EXPORTED size_t
rb_io_memsize(const rb_io_t *fptr)
{
@@ -4779,16 +4668,16 @@ rb_io_memsize(const rb_io_t *fptr)
# define KEEPGVL FALSE
#endif
-int rb_notify_fd_close(int fd, struct list_head *);
+int rb_notify_fd_close(int fd);
static rb_io_t *
io_close_fptr(VALUE io)
{
rb_io_t *fptr;
+ int fd;
VALUE write_io;
rb_io_t *write_fptr;
- struct list_head busy;
+ int busy;
- list_head_init(&busy);
write_io = GetWriteIO(io);
if (io != write_io) {
write_fptr = RFILE(write_io)->fptr;
@@ -4801,9 +4690,11 @@ io_close_fptr(VALUE io)
if (!fptr) return 0;
if (fptr->fd < 0) return 0;
- if (rb_notify_fd_close(fptr->fd, &busy)) {
- /* calls close(fptr->fd): */
- fptr_finalize_flush(fptr, FALSE, KEEPGVL, &busy);
+ fd = fptr->fd;
+ busy = rb_notify_fd_close(fd);
+ if (busy) {
+ fptr_finalize_flush(fptr, FALSE, KEEPGVL);
+ do rb_thread_schedule(); while (rb_notify_fd_close(fd));
}
rb_io_fptr_cleanup(fptr, FALSE);
return fptr;
@@ -4834,11 +4725,12 @@ rb_io_close(VALUE io)
*
* Closes <em>ios</em> and flushes any pending writes to the operating
* system. The stream is unavailable for any further data operations;
- * an IOError is raised if such an attempt is made. I/O streams are
- * automatically closed when they are claimed by the garbage collector.
+ * an <code>IOError</code> is raised if such an attempt is made. I/O
+ * streams are automatically closed when they are claimed by the
+ * garbage collector.
*
- * If <em>ios</em> is opened by IO.popen, #close sets
- * <code>$?</code>.
+ * If <em>ios</em> is opened by <code>IO.popen</code>,
+ * <code>close</code> sets <code>$?</code>.
*
* Calling this method on closed IO object is just ignored since Ruby 2.3.
*/
@@ -4865,7 +4757,7 @@ static VALUE
ignore_closed_stream(VALUE io, VALUE exc)
{
enum {mesg_len = sizeof(closed_stream)-1};
- VALUE mesg = rb_attr_get(exc, idMesg);
+ VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
if (!RB_TYPE_P(mesg, T_STRING) ||
RSTRING_LEN(mesg) != mesg_len ||
memcmp(RSTRING_PTR(mesg), closed_stream, mesg_len)) {
@@ -4928,7 +4820,7 @@ rb_io_closed(VALUE io)
*
* Closes the read end of a duplex I/O stream (i.e., one that contains
* both a read and a write stream, such as a pipe). Will raise an
- * IOError if the stream is not duplexed.
+ * <code>IOError</code> if the stream is not duplexed.
*
* f = IO.popen("/bin/sh","r+")
* f.close_read
@@ -4989,7 +4881,7 @@ rb_io_close_read(VALUE io)
*
* Closes the write end of a duplex I/O stream (i.e., one that contains
* both a read and a write stream, such as a pipe). Will raise an
- * IOError if the stream is not duplexed.
+ * <code>IOError</code> if the stream is not duplexed.
*
* f = IO.popen("/bin/sh","r+")
* f.close_write
@@ -5042,8 +4934,8 @@ rb_io_close_write(VALUE io)
* ios.sysseek(offset, whence=IO::SEEK_SET) -> integer
*
* Seeks to a given <i>offset</i> in the stream according to the value
- * of <i>whence</i> (see IO#seek for values of <i>whence</i>). Returns
- * the new offset into the file.
+ * of <i>whence</i> (see <code>IO#seek</code> for values of
+ * <i>whence</i>). Returns the new offset into the file.
*
* f = File.new("testfile")
* f.sysseek(-13, IO::SEEK_END) #=> 53
@@ -5072,7 +4964,7 @@ rb_io_sysseek(int argc, VALUE *argv, VALUE io)
}
errno = 0;
pos = lseek(fptr->fd, pos, whence);
- if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv);
+ if (pos == -1 && errno) rb_sys_fail_path(fptr->pathv);
return OFFT2NUM(pos);
}
@@ -5084,7 +4976,7 @@ rb_io_sysseek(int argc, VALUE *argv, VALUE io)
* Writes the given string to <em>ios</em> using a low-level write.
* Returns the number of bytes written. Do not mix with other methods
* that write to <em>ios</em> or you may get unpredictable results.
- * Raises SystemCallError on error.
+ * Raises <code>SystemCallError</code> on error.
*
* f = File.new("out", "w")
* f.syswrite("ABCDEF") #=> 6
@@ -5112,7 +5004,7 @@ rb_io_syswrite(VALUE io, VALUE str)
tmp = rb_str_tmp_frozen_acquire(str);
RSTRING_GETMEM(tmp, ptr, len);
n = rb_write_internal(fptr->fd, ptr, len);
- if (n < 0) rb_sys_fail_path(fptr->pathv);
+ if (n == -1) rb_sys_fail_path(fptr->pathv);
rb_str_tmp_frozen_release(str, tmp);
return LONG2FIX(n);
@@ -5131,7 +5023,8 @@ rb_io_syswrite(VALUE io, VALUE str)
* The _outbuf_ will contain only the received data after the method call
* even if it is not empty at the beginning.
*
- * Raises SystemCallError on error and EOFError at end of file.
+ * Raises <code>SystemCallError</code> on error and
+ * <code>EOFError</code> at end of file.
*
* f = File.new("testfile")
* f.sysread(16) #=> "This is line one"
@@ -5143,7 +5036,7 @@ rb_io_sysread(int argc, VALUE *argv, VALUE io)
VALUE len, str;
rb_io_t *fptr;
long n, ilen;
- struct io_internal_read_struct iis;
+ struct read_internal_arg arg;
int shrinkable;
rb_scan_args(argc, argv, "11", &len, &str);
@@ -5171,19 +5064,21 @@ rb_io_sysread(int argc, VALUE *argv, VALUE io)
rb_io_check_closed(fptr);
io_setstrbuf(&str, ilen);
- iis.fd = fptr->fd;
- iis.nonblock = 1; /* for historical reasons, maybe (see above) */
- iis.buf = RSTRING_PTR(str);
- iis.capa = ilen;
- n = read_internal_locktmp(str, &iis);
+ rb_str_locktmp(str);
+ arg.fd = fptr->fd;
+ arg.str_ptr = RSTRING_PTR(str);
+ arg.len = ilen;
+ rb_ensure(read_internal_call, (VALUE)&arg, rb_str_unlocktmp, str);
+ n = arg.len;
- if (n < 0) {
+ if (n == -1) {
rb_sys_fail_path(fptr->pathv);
}
io_set_read_length(str, n, shrinkable);
if (n == 0 && ilen > 0) {
rb_eof_error();
}
+ OBJ_TAINT(str);
return str;
}
@@ -5224,8 +5119,9 @@ pread_internal_call(VALUE arg)
* This bypasses any userspace buffering of the IO layer.
* If the optional <i>outbuf</i> argument is present, it must
* reference a String, which will receive the data.
- * Raises SystemCallError on error, EOFError at end of file and
- * NotImplementedError if platform does not implement the system call.
+ * Raises <code>SystemCallError</code> on error, <code>EOFError</code>
+ * at end of file and <code>NotImplementedError</code> if platform does not
+ * implement the system call.
*
* File.write("testfile", "This is line one\nThis is line two\n")
* File.open("testfile") do |f|
@@ -5260,13 +5156,14 @@ rb_io_pread(int argc, VALUE *argv, VALUE io)
rb_str_locktmp(str);
n = (ssize_t)rb_ensure(pread_internal_call, (VALUE)&arg, rb_str_unlocktmp, str);
- if (n < 0) {
+ if (n == -1) {
rb_sys_fail_path(fptr->pathv);
}
io_set_read_length(str, n, shrinkable);
if (n == 0 && arg.count > 0) {
rb_eof_error();
}
+ OBJ_TAINT(str);
return str;
}
@@ -5293,7 +5190,7 @@ internal_pwrite_func(void *ptr)
* same IO object for reading the file at various locations.
* This bypasses any userspace buffering of the IO layer.
* Returns the number of bytes written.
- * Raises SystemCallError on error and NotImplementedError
+ * Raises <code>SystemCallError</code> on error and <code>NotImplementedError</code>
* if platform does not implement the system call.
*
* File.open("out", "w") do |f|
@@ -5325,7 +5222,7 @@ rb_io_pwrite(VALUE io, VALUE str, VALUE offset)
arg.count = (size_t)RSTRING_LEN(tmp);
n = (ssize_t)rb_thread_io_blocking_region(internal_pwrite_func, &arg, fptr->fd);
- if (n < 0) rb_sys_fail_path(fptr->pathv);
+ if (n == -1) rb_sys_fail_path(fptr->pathv);
rb_str_tmp_frozen_release(str, tmp);
return SSIZET2NUM(n);
@@ -5445,10 +5342,10 @@ rb_io_fmode_modestr(int fmode)
case FMODE_READABLE:
return MODE_BTMODE("r", "rb", "rt");
case FMODE_WRITABLE:
- return MODE_BTXMODE("w", "wb", "wt", "wx", "wbx", "wtx");
+ return MODE_BTMODE("w", "wb", "wt");
case FMODE_READWRITE:
if (fmode & FMODE_CREATE) {
- return MODE_BTXMODE("w+", "wb+", "wt+", "w+x", "wb+x", "wt+x");
+ return MODE_BTMODE("w+", "wb+", "wt+");
}
return MODE_BTMODE("r+", "rb+", "rt+");
}
@@ -5497,11 +5394,6 @@ rb_io_modestr_fmode(const char *modestr)
case '+':
fmode |= FMODE_READWRITE;
break;
- case 'x':
- if (modestr[0] != 'w')
- goto error;
- fmode |= FMODE_EXCL;
- break;
default:
goto error;
case ':':
@@ -5545,9 +5437,6 @@ rb_io_oflags_fmode(int oflags)
if (oflags & O_CREAT) {
fmode |= FMODE_CREATE;
}
- if (oflags & O_EXCL) {
- fmode |= FMODE_EXCL;
- }
#ifdef O_BINARY
if (oflags & O_BINARY) {
fmode |= FMODE_BINMODE;
@@ -5583,9 +5472,6 @@ rb_io_fmode_oflags(int fmode)
if (fmode & FMODE_CREATE) {
oflags |= O_CREAT;
}
- if (fmode & FMODE_EXCL) {
- oflags |= O_EXCL;
- }
#ifdef O_BINARY
if (fmode & FMODE_BINMODE) {
oflags |= O_BINARY;
@@ -5609,11 +5495,7 @@ rb_io_oflags_modestr(int oflags)
#else
# define MODE_BINARY(a,b) (a)
#endif
- int accmode;
- if (oflags & O_EXCL) {
- rb_raise(rb_eArgError, "exclusive access mode is not supported");
- }
- accmode = oflags & (O_RDONLY|O_WRONLY|O_RDWR);
+ int accmode = oflags & (O_RDONLY|O_WRONLY|O_RDWR);
if (oflags & O_APPEND) {
if (accmode == O_WRONLY) {
return MODE_BINARY("a", "ab");
@@ -5622,7 +5504,7 @@ rb_io_oflags_modestr(int oflags)
return MODE_BINARY("a+", "ab+");
}
}
- switch (accmode) {
+ switch (oflags & (O_RDONLY|O_WRONLY|O_RDWR)) {
default:
rb_raise(rb_eArgError, "invalid access oflags 0x%x", oflags);
case O_RDONLY:
@@ -5871,7 +5753,7 @@ extract_binmode(VALUE opthash, int *fmode)
}
}
-void
+static void
rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
int *oflags_p, int *fmode_p, convconfig_t *convconfig_p)
{
@@ -6144,8 +6026,8 @@ io_strip_bom(VALUE io)
}
rb_io_ungetbyte(io, b4);
}
- rb_io_ungetbyte(io, b3);
- return ENCINDEX_UTF_16LE;
+ rb_io_ungetbyte(io, b3);
+ return ENCINDEX_UTF_16LE;
}
rb_io_ungetbyte(io, b2);
break;
@@ -6168,23 +6050,20 @@ io_strip_bom(VALUE io)
return 0;
}
-static rb_encoding *
+static void
io_set_encoding_by_bom(VALUE io)
{
int idx = io_strip_bom(io);
rb_io_t *fptr;
- rb_encoding *extenc = NULL;
GetOpenFile(io, fptr);
if (idx) {
- extenc = rb_enc_from_index(idx);
- io_encoding_set(fptr, rb_enc_from_encoding(extenc),
- rb_io_internal_encoding(io), Qnil);
+ io_encoding_set(fptr, rb_enc_from_encoding(rb_enc_from_index(idx)),
+ rb_io_internal_encoding(io), Qnil);
}
else {
fptr->encs.enc2 = NULL;
}
- return extenc;
}
static VALUE
@@ -6232,8 +6111,6 @@ rb_file_open_internal(VALUE io, VALUE filename, const char *modestr)
if (p) {
parse_mode_enc(p+1, rb_usascii_encoding(),
&convconfig.enc, &convconfig.enc2, &fmode);
- convconfig.ecflags = 0;
- convconfig.ecopts = Qnil;
}
else {
rb_encoding *e;
@@ -6285,16 +6162,23 @@ pipe_add_fptr(rb_io_t *fptr)
static void
pipe_del_fptr(rb_io_t *fptr)
{
- struct pipe_list **prev = &pipe_list;
+ struct pipe_list *list = pipe_list;
struct pipe_list *tmp;
- while ((tmp = *prev) != 0) {
- if (tmp->fptr == fptr) {
- *prev = tmp->next;
+ if (list->fptr == fptr) {
+ pipe_list = list->next;
+ free(list);
+ return;
+ }
+
+ while (list->next) {
+ if (list->next->fptr == fptr) {
+ tmp = list->next;
+ list->next = list->next->next;
free(tmp);
return;
}
- prev = &tmp->next;
+ list = list->next;
}
}
@@ -6331,31 +6215,6 @@ pipe_finalize(rb_io_t *fptr, int noraise)
}
#endif
-static void
-fptr_copy_finalizer(rb_io_t *fptr, const rb_io_t *orig)
-{
-#if defined(__CYGWIN__) || !defined(HAVE_WORKING_FORK)
- void (*const old_finalize)(struct rb_io_t*,int) = fptr->finalize;
-
- if (old_finalize == orig->finalize) return;
-#endif
-
- fptr->finalize = orig->finalize;
-
-#if defined(__CYGWIN__) || !defined(HAVE_WORKING_FORK)
- if (old_finalize != pipe_finalize) {
- struct pipe_list *list;
- for (list = pipe_list; list; list = list->next) {
- if (list->fptr == fptr) break;
- }
- if (!list) pipe_add_fptr(fptr);
- }
- else {
- pipe_del_fptr(fptr);
- }
-#endif
-}
-
void
rb_io_synchronized(rb_io_t *fptr)
{
@@ -6374,7 +6233,7 @@ rb_pipe(int *pipes)
{
int ret;
ret = rb_cloexec_pipe(pipes);
- if (ret < 0) {
+ if (ret == -1) {
if (rb_gc_for_fd(errno)) {
ret = rb_cloexec_pipe(pipes);
}
@@ -6451,9 +6310,9 @@ linux_get_maxfd(void)
char buf[4096], *p, *np, *e;
ssize_t ss;
fd = rb_cloexec_open("/proc/self/status", O_RDONLY|O_NOCTTY, 0);
- if (fd < 0) return fd;
+ if (fd == -1) return -1;
ss = read(fd, buf, sizeof(buf));
- if (ss < 0) goto err;
+ if (ss == -1) goto err;
p = buf;
e = buf + ss;
while ((int)sizeof("FDSize:\t0\n")-1 <= e-p &&
@@ -6472,7 +6331,7 @@ linux_get_maxfd(void)
err:
close(fd);
- return (int)ss;
+ return -1;
}
#endif
@@ -6642,7 +6501,7 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
# if defined(HAVE_SPAWNVE)
if (eargp->envp_str) envp = (char **)RSTRING_PTR(eargp->envp_str);
# endif
- while ((pid = DO_SPAWN(cmd, args, envp)) < 0) {
+ while ((pid = DO_SPAWN(cmd, args, envp)) == -1) {
/* exec failed */
switch (e = errno) {
case EAGAIN:
@@ -6675,7 +6534,7 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
}
/* parent */
- if (pid < 0) {
+ if (pid == -1) {
# if defined(HAVE_WORKING_FORK)
e = errno;
# endif
@@ -6786,7 +6645,7 @@ pipe_open_s(VALUE prog, const char *modestr, int fmode,
VALUE execarg_obj = Qnil;
if (!is_popen_fork(prog))
- execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
+ execarg_obj = rb_execarg_new(argc, argv, TRUE);
return pipe_open(execarg_obj, modestr, fmode, convconfig);
}
@@ -6807,7 +6666,7 @@ pipe_close(VALUE io)
*
* Runs the specified command as a subprocess; the subprocess's
* standard input and output will be connected to the returned
- * IO object.
+ * <code>IO</code> object.
*
* The PID of the started process can be obtained by IO#pid method.
*
@@ -6826,7 +6685,7 @@ pipe_close(VALUE io)
* If <i>cmd</i> is an +Array+ of +String+,
* then it will be used as the subprocess's +argv+ bypassing a shell.
* The array can contain a hash at first for environments and
- * a hash at last for options similar to #spawn.
+ * a hash at last for options similar to <code>spawn</code>.
*
* The default mode for the new file object is ``r'',
* but <i>mode</i> may be set to any of the modes listed in the description for class IO.
@@ -6848,13 +6707,15 @@ pipe_close(VALUE io)
* ls_result_with_error = ls_io.read
* }
*
- * Raises exceptions which IO.pipe and Kernel.spawn raise.
+ * Raises exceptions which <code>IO.pipe</code> and
+ * <code>Kernel.spawn</code> raise.
*
* If a block is given, Ruby will run the command as a child connected
* to Ruby with a pipe. Ruby's end of the pipe will be passed as a
* parameter to the block.
* At the end of block, Ruby closes the pipe and sets <code>$?</code>.
- * In this case IO.popen returns the value of the block.
+ * In this case <code>IO.popen</code> returns
+ * the value of the block.
*
* If a block is given with a _cmd_ of ``<code>-</code>'',
* the block will be run in two separate processes: once in the parent,
@@ -6917,14 +6778,14 @@ rb_io_s_popen(int argc, VALUE *argv, VALUE klass)
rb_raise(rb_eArgError, "too many arguments");
}
#endif
- execarg_obj = rb_execarg_new((int)len, RARRAY_CONST_PTR(tmp), FALSE, FALSE);
+ execarg_obj = rb_execarg_new((int)len, RARRAY_CONST_PTR(tmp), FALSE);
RB_GC_GUARD(tmp);
}
else {
SafeStringValue(pname);
execarg_obj = Qnil;
if (!is_popen_fork(pname))
- execarg_obj = rb_execarg_new(1, &pname, TRUE, FALSE);
+ execarg_obj = rb_execarg_new(1, &pname, TRUE);
}
if (!NIL_P(execarg_obj)) {
if (!NIL_P(opt))
@@ -6999,11 +6860,11 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
* File.open(filename, mode="r" [, opt]) {|file| block } -> obj
* File.open(filename [, mode [, perm]] [, opt]) {|file| block } -> obj
*
- * With no associated block, File.open is a synonym for
+ * With no associated block, <code>File.open</code> is a synonym for
* File.new. If the optional code block is given, it will
* be passed the opened +file+ as an argument and the File object will
* automatically be closed when the block terminates. The value of the block
- * will be returned from File.open.
+ * will be returned from <code>File.open</code>.
*
* If a file is being created, its initial permissions may be set using the
* +perm+ parameter. See File.new for further discussion.
@@ -7018,7 +6879,7 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
* IO.open(fd, mode="r" [, opt]) -> io
* IO.open(fd, mode="r" [, opt]) {|io| block } -> obj
*
- * With no associated block, IO.open is a synonym for IO.new. If
+ * With no associated block, <code>IO.open</code> is a synonym for IO.new. If
* the optional code block is given, it will be passed +io+ as an argument,
* and the IO object will automatically be closed when the block terminates.
* In this instance, IO.open returns the value of the block.
@@ -7029,7 +6890,7 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
static VALUE
rb_io_s_open(int argc, VALUE *argv, VALUE klass)
{
- VALUE io = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
+ VALUE io = rb_class_new_instance(argc, argv, klass);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, io, io_close, io);
@@ -7043,13 +6904,13 @@ rb_io_s_open(int argc, VALUE *argv, VALUE klass)
* IO.sysopen(path, [mode, [perm]]) -> integer
*
* Opens the given path, returning the underlying file descriptor as a
- * Integer.
+ * <code>Integer</code>.
*
* IO.sysopen("testfile") #=> 3
*/
static VALUE
-rb_io_s_sysopen(int argc, VALUE *argv, VALUE _)
+rb_io_s_sysopen(int argc, VALUE *argv)
{
VALUE fname, vmode, vperm;
VALUE intmode;
@@ -7085,6 +6946,7 @@ check_pipe_command(VALUE filename_or_command)
if (rb_enc_ascget(s, e, &chlen, rb_enc_get(filename_or_command)) == '|') {
VALUE cmd = rb_str_new(s+chlen, l-chlen);
+ OBJ_INFECT(cmd, filename_or_command);
return cmd;
}
return Qnil;
@@ -7189,7 +7051,7 @@ check_pipe_command(VALUE filename_or_command)
*/
static VALUE
-rb_f_open(int argc, VALUE *argv, VALUE _)
+rb_f_open(int argc, VALUE *argv)
{
ID to_open = 0;
int redirect = FALSE;
@@ -7215,7 +7077,7 @@ rb_f_open(int argc, VALUE *argv, VALUE _)
}
}
if (redirect) {
- VALUE io = rb_funcallv_kw(argv[0], to_open, argc-1, argv+1, RB_PASS_CALLED_KEYWORDS);
+ VALUE io = rb_funcallv(argv[0], to_open, argc-1, argv+1);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, io, io_close, io);
@@ -7244,7 +7106,12 @@ rb_io_open_generic(VALUE klass, VALUE filename, int oflags, int fmode,
const convconfig_t *convconfig, mode_t perm)
{
VALUE cmd;
- if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) {
+ const int warn = klass == rb_cFile;
+ if ((warn || klass == rb_cIO) && !NIL_P(cmd = check_pipe_command(filename))) {
+ if (warn) {
+ rb_warn("IO.%"PRIsVALUE" called on File to invoke external command",
+ rb_id2str(rb_frame_this_func()));
+ }
return pipe_open_s(cmd, rb_io_oflags_modestr(oflags), fmode, convconfig);
}
else {
@@ -7280,7 +7147,7 @@ io_reopen(VALUE io, VALUE nfile)
rb_sys_fail(0);
}
else {
- flush_before_seek(fptr);
+ io_tell(fptr);
}
if (orig->mode & FMODE_READABLE) {
pos = io_tell(orig);
@@ -7296,7 +7163,11 @@ io_reopen(VALUE io, VALUE nfile)
fptr->lineno = orig->lineno;
if (RTEST(orig->pathv)) fptr->pathv = orig->pathv;
else if (!IS_PREP_STDIO(fptr)) fptr->pathv = Qnil;
- fptr_copy_finalizer(fptr, orig);
+ fptr->finalize = orig->finalize;
+#if defined (__CYGWIN__) || !defined(HAVE_WORKING_FORK)
+ if (fptr->finalize == pipe_finalize)
+ pipe_add_fptr(fptr);
+#endif
fd = fptr->fd;
fd2 = orig->fd;
@@ -7316,7 +7187,7 @@ io_reopen(VALUE io, VALUE nfile)
rb_update_max_fd(fd);
fptr->fd = fd;
}
- rb_thread_fd_close(fd);
+ rb_notify_fd_close(fd);
if ((orig->mode & FMODE_READABLE) && pos >= 0) {
if (io_seek(fptr, pos, SEEK_SET) < 0 && errno) {
rb_sys_fail_path(fptr->pathv);
@@ -7351,13 +7222,12 @@ rb_freopen(VALUE fname, const char *mode, FILE *fp)
/*
* call-seq:
- * ios.reopen(other_IO) -> ios
- * ios.reopen(path, mode [, opt]) -> ios
+ * ios.reopen(other_IO) -> ios
+ * ios.reopen(path, mode_str) -> ios
*
* Reassociates <em>ios</em> with the I/O stream given in
* <i>other_IO</i> or to a new stream opened on <i>path</i>. This may
* dynamically change the actual class of this stream.
- * The +mode+ and +opt+ parameters accept the same values as IO.open.
*
* f1 = File.new("testfile")
* f2 = File.new("testfile")
@@ -7476,7 +7346,11 @@ rb_io_init_copy(VALUE dest, VALUE io)
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
if (!NIL_P(orig->pathv)) fptr->pathv = orig->pathv;
- fptr_copy_finalizer(fptr, orig);
+ fptr->finalize = orig->finalize;
+#if defined (__CYGWIN__) || !defined(HAVE_WORKING_FORK)
+ if (fptr->finalize == pipe_finalize)
+ pipe_add_fptr(fptr);
+#endif
fd = ruby_dup(orig->fd);
fptr->fd = fd;
@@ -7502,7 +7376,8 @@ rb_io_init_copy(VALUE dest, VALUE io)
* ios.printf(format_string [, obj, ...]) -> nil
*
* Formats and writes to <em>ios</em>, converting parameters under
- * control of the format string. See Kernel#sprintf for details.
+ * control of the format string. See <code>Kernel#sprintf</code>
+ * for details.
*/
VALUE
@@ -7524,7 +7399,7 @@ rb_io_printf(int argc, const VALUE *argv, VALUE out)
*/
static VALUE
-rb_f_printf(int argc, VALUE *argv, VALUE _)
+rb_f_printf(int argc, VALUE *argv)
{
VALUE out;
@@ -7542,16 +7417,6 @@ rb_f_printf(int argc, VALUE *argv, VALUE _)
return Qnil;
}
-static void
-rb_output_fs_setter(VALUE val, ID id, VALUE *var)
-{
- rb_str_setter(val, id, &val);
- if (!NIL_P(val)) {
- rb_warn_deprecated("`$,'", NULL);
- }
- *var = val;
-}
-
/*
* call-seq:
* ios.print -> nil
@@ -7625,7 +7490,7 @@ rb_io_print(int argc, const VALUE *argv, VALUE out)
*/
static VALUE
-rb_f_print(int argc, const VALUE *argv, VALUE _)
+rb_f_print(int argc, const VALUE *argv)
{
rb_io_print(argc, argv, rb_stdout);
return Qnil;
@@ -7635,10 +7500,11 @@ rb_f_print(int argc, const VALUE *argv, VALUE _)
* call-seq:
* ios.putc(obj) -> obj
*
- * If <i>obj</i> is Numeric, write the character whose code is the
- * least-significant byte of <i>obj</i>. If <i>obj</i> is String,
- * write the first character of <i>obj</i> to <em>ios</em>. Otherwise,
- * raise TypeError.
+ * If <i>obj</i> is <code>Numeric</code>, write the character whose code is
+ * the least-significant byte of <i>obj</i>.
+ * If <i>obj</i> is <code>String</code>, write the first character
+ * of <i>obj</i> to <em>ios</em>.
+ * Otherwise, raise <code>TypeError</code>.
*
* $stdout.putc "A"
* $stdout.putc 65
@@ -7899,22 +7765,21 @@ rb_obj_display(int argc, VALUE *argv, VALUE self)
{
VALUE out;
- out = (!rb_check_arity(argc, 0, 1) ? rb_stdout : argv[0]);
+ if (argc == 0) {
+ out = rb_stdout;
+ }
+ else {
+ rb_scan_args(argc, argv, "01", &out);
+ }
rb_io_write(out, self);
return Qnil;
}
-static int
-rb_stderr_to_original_p(void)
-{
- return (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0);
-}
-
void
rb_write_error2(const char *mesg, long len)
{
- if (rb_stderr_to_original_p()) {
+ if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) {
#ifdef _WIN32
if (isatty(fileno(stderr))) {
if (rb_w32_write_console(rb_str_new(mesg, len), fileno(stderr)) > 0) return;
@@ -7940,7 +7805,7 @@ void
rb_write_error_str(VALUE mesg)
{
/* a stopgap measure for the time being */
- if (rb_stderr_to_original_p()) {
+ if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) {
size_t len = (size_t)RSTRING_LEN(mesg);
#ifdef _WIN32
if (isatty(fileno(stderr))) {
@@ -7961,7 +7826,7 @@ rb_write_error_str(VALUE mesg)
int
rb_stderr_tty_p(void)
{
- if (rb_stderr_to_original_p())
+ if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0)
return isatty(fileno(stderr));
return 0;
}
@@ -8036,7 +7901,7 @@ FILE *
rb_io_stdio_file(rb_io_t *fptr)
{
if (!fptr->stdio_file) {
- int oflags = rb_io_fmode_oflags(fptr->mode) & ~O_EXCL;
+ int oflags = rb_io_fmode_oflags(fptr->mode);
fptr->stdio_file = rb_fdopen(fptr->fd, rb_io_oflags_modestr(oflags));
}
return fptr->stdio_file;
@@ -8154,10 +8019,6 @@ rb_io_make_open_file(VALUE obj)
*
* "t" Text file mode
*
- * The exclusive access mode ("x") can be used together with "w" to ensure
- * the file is created. Errno::EEXIST is raised when it already exists.
- * It may not be supported with all kinds of streams (e.g. pipes).
- *
* When the open mode of original IO is read only, the mode cannot be
* changed to be writable. Similarly, the open mode cannot be changed from
* write only to readable.
@@ -8246,7 +8107,7 @@ rb_io_make_open_file(VALUE obj)
* io.puts "Hello, World!"
*
* Both of above print "Hello, World!" in UTF-16LE to standard error output
- * with converting EOL generated by #puts to CR.
+ * with converting EOL generated by <code>puts</code> to CR.
*/
static VALUE
@@ -8275,7 +8136,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
oflags = fcntl(fd, F_GETFL);
if (oflags == -1) rb_sys_fail(0);
#else
- if (fstat(fd, &st) < 0) rb_sys_fail(0);
+ if (fstat(fd, &st) == -1) rb_sys_fail(0);
#endif
rb_update_max_fd(fd);
#if defined(HAVE_FCNTL) && defined(F_GETFL)
@@ -8310,44 +8171,6 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
- * ios.set_encoding_by_bom -> encoding or nil
- *
- * Checks if +ios+ starts with a BOM, and then consumes it and sets
- * the external encoding. Returns the result encoding if found, or
- * nil. If +ios+ is not binmode or its encoding has been set
- * already, an exception will be raised.
- *
- * File.write("bom.txt", "\u{FEFF}abc")
- * ios = File.open("bom.txt", "rb")
- * ios.set_encoding_by_bom #=> #<Encoding:UTF-8>
- *
- * File.write("nobom.txt", "abc")
- * ios = File.open("nobom.txt", "rb")
- * ios.set_encoding_by_bom #=> nil
- */
-
-static VALUE
-rb_io_set_encoding_by_bom(VALUE io)
-{
- rb_io_t *fptr;
-
- GetOpenFile(io, fptr);
- if (!(fptr->mode & FMODE_BINMODE)) {
- rb_raise(rb_eArgError, "ASCII incompatible encoding needs binmode");
- }
- if (fptr->encs.enc2) {
- rb_raise(rb_eArgError, "encoding conversion is set");
- }
- else if (fptr->encs.enc && fptr->encs.enc != rb_ascii8bit_encoding()) {
- rb_raise(rb_eArgError, "encoding is set to %s already",
- rb_enc_name(fptr->encs.enc));
- }
- if (!io_set_encoding_by_bom(io)) return Qnil;
- return rb_enc_from_encoding(fptr->encs.enc);
-}
-
-/*
- * call-seq:
* File.new(filename, mode="r" [, opt]) -> file
* File.new(filename [, mode [, perm]] [, opt]) -> file
*
@@ -8362,7 +8185,8 @@ rb_io_set_encoding_by_bom(VALUE io)
*
* The new File object is buffered mode (or non-sync mode), unless
* +filename+ is a tty.
- * See IO#flush, IO#fsync, IO#fdatasync, and IO#sync= about sync mode.
+ * See IO#flush, IO#fsync, IO#fdatasync, and <code>IO#sync=</code>
+ * about sync mode.
*
* === Examples
*
@@ -8400,7 +8224,7 @@ rb_io_s_new(int argc, VALUE *argv, VALUE klass)
rb_warn("%"PRIsVALUE"::new() does not take block; use %"PRIsVALUE"::open() instead",
cname, cname);
}
- return rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
+ return rb_class_new_instance(argc, argv, klass);
}
@@ -8408,7 +8232,7 @@ rb_io_s_new(int argc, VALUE *argv, VALUE klass)
* call-seq:
* IO.for_fd(fd, mode [, opt]) -> io
*
- * Synonym for IO.new.
+ * Synonym for <code>IO.new</code>.
*
*/
@@ -8445,12 +8269,12 @@ rb_io_autoclose_p(VALUE io)
* f = open("/dev/null")
* IO.for_fd(f.fileno)
* # ...
- * f.gets # may cause Errno::EBADF
+ * f.gets # may cause IOError
*
* f = open("/dev/null")
- * IO.for_fd(f.fileno).autoclose = false
+ * IO.for_fd(f.fileno).autoclose = true
* # ...
- * f.gets # won't cause Errno::EBADF
+ * f.gets # won't cause IOError
*/
static VALUE
@@ -8462,7 +8286,7 @@ rb_io_set_autoclose(VALUE io, VALUE autoclose)
fptr->mode |= FMODE_PREP;
else
fptr->mode &= ~FMODE_PREP;
- return autoclose;
+ return io;
}
static void
@@ -8645,7 +8469,6 @@ argf_next_argv(VALUE argf)
VALUE filename = rb_ary_shift(ARGF.argv);
FilePathValue(filename);
ARGF.filename = filename;
- filename = rb_str_encode_ospath(filename);
fn = StringValueCStr(filename);
if (RSTRING_LEN(filename) == 1 && fn[0] == '-') {
ARGF.current_file = rb_stdin;
@@ -8747,7 +8570,6 @@ argf_next_argv(VALUE argf)
if (!NIL_P(write_io)) {
rb_io_set_write_io(ARGF.current_file, write_io);
}
- RB_GC_GUARD(filename);
}
if (ARGF.binmode) rb_io_ascii8bit_binmode(ARGF.current_file);
GetOpenFile(ARGF.current_file, fptr);
@@ -8936,7 +8758,7 @@ static VALUE argf_readline(int, VALUE *, VALUE);
* readline(limit) -> string
* readline(sep, limit) -> string
*
- * Equivalent to Kernel::gets, except
+ * Equivalent to <code>Kernel::gets</code>, except
* +readline+ raises +EOFError+ at end of file.
*/
@@ -9369,17 +9191,17 @@ advice_arg_check(VALUE advice)
*
* If an error occurs, one of the following exceptions will be raised:
*
- * IOError:: The IO stream is closed.
- * Errno::EBADF::
+ * <code>IOError</code>:: The <code>IO</code> stream is closed.
+ * <code>Errno::EBADF</code>::
* The file descriptor of the current file is invalid.
- * Errno::EINVAL:: An invalid value for _advice_ was given.
- * Errno::ESPIPE::
+ * <code>Errno::EINVAL</code>:: An invalid value for _advice_ was given.
+ * <code>Errno::ESPIPE</code>::
* The file descriptor of the current file refers to a FIFO or
- * pipe. (Linux raises Errno::EINVAL in this case).
- * TypeError::
+ * pipe. (Linux raises <code>Errno::EINVAL</code> in this case).
+ * <code>TypeError</code>::
* Either _advice_ was not a Symbol, or one of the
- * other arguments was not an Integer.
- * RangeError:: One of the arguments given was too big/small.
+ * other arguments was not an <code>Integer</code>.
+ * <code>RangeError</code>:: One of the arguments given was too big/small.
*
* This list is not exhaustive; other Errno:: exceptions are also possible.
*/
@@ -9412,28 +9234,29 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* IO.select(read_array [, write_array [, error_array [, timeout]]]) -> array or nil
*
* Calls select(2) system call.
- * It monitors given arrays of IO objects, waits until one or more of
- * IO objects are ready for reading, are ready for writing, and have
- * pending exceptions respectively, and returns an array that contains
- * arrays of those IO objects. It will return +nil+ if optional
- * <i>timeout</i> value is given and no IO object is ready in
- * <i>timeout</i> seconds.
- *
- * IO.select peeks the buffer of IO objects for testing readability.
- * If the IO buffer is not empty, IO.select immediately notifies
- * readability. This "peek" only happens for IO objects. It does not
- * happen for IO-like objects such as OpenSSL::SSL::SSLSocket.
- *
- * The best way to use IO.select is invoking it after nonblocking
- * methods such as #read_nonblock, #write_nonblock, etc. The methods
- * raise an exception which is extended by IO::WaitReadable or
- * IO::WaitWritable. The modules notify how the caller should wait
- * with IO.select. If IO::WaitReadable is raised, the caller should
- * wait for reading. If IO::WaitWritable is raised, the caller should
- * wait for writing.
- *
- * So, blocking read (#readpartial) can be emulated using
- * #read_nonblock and IO.select as follows:
+ * It monitors given arrays of <code>IO</code> objects, waits until one or more
+ * of <code>IO</code> objects are ready for reading, are ready for writing,
+ * and have pending exceptions respectively, and returns an array that
+ * contains arrays of those IO objects. It will return +nil+
+ * if optional <i>timeout</i> value is given and no <code>IO</code> object
+ * is ready in <i>timeout</i> seconds.
+ *
+ * <code>IO.select</code> peeks the buffer of <code>IO</code> objects for testing readability.
+ * If the <code>IO</code> buffer is not empty,
+ * <code>IO.select</code> immediately notifies readability.
+ * This "peek" only happens for <code>IO</code> objects.
+ * It does not happen for IO-like objects such as OpenSSL::SSL::SSLSocket.
+ *
+ * The best way to use <code>IO.select</code> is invoking it
+ * after nonblocking methods such as <code>read_nonblock</code>, <code>write_nonblock</code>, etc.
+ * The methods raise an exception which is extended by
+ * <code>IO::WaitReadable</code> or <code>IO::WaitWritable</code>.
+ * The modules notify how the caller should wait with <code>IO.select</code>.
+ * If <code>IO::WaitReadable</code> is raised, the caller should wait for reading.
+ * If <code>IO::WaitWritable</code> is raised, the caller should wait for writing.
+ *
+ * So, blocking read (<code>readpartial</code>) can be emulated using
+ * <code>read_nonblock</code> and <code>IO.select</code> as follows:
*
* begin
* result = io_like.read_nonblock(maxlen)
@@ -9445,57 +9268,57 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* retry
* end
*
- * Especially, the combination of nonblocking methods and IO.select is
- * preferred for IO like objects such as OpenSSL::SSL::SSLSocket. It
- * has #to_io method to return underlying IO object. IO.select calls
- * #to_io to obtain the file descriptor to wait.
+ * Especially, the combination of nonblocking methods and
+ * <code>IO.select</code> is preferred for <code>IO</code> like
+ * objects such as <code>OpenSSL::SSL::SSLSocket</code>.
+ * It has <code>to_io</code> method to return underlying <code>IO</code> object.
+ * <code>IO.select</code> calls <code>to_io</code> to obtain the file descriptor to wait.
*
- * This means that readability notified by IO.select doesn't mean
- * readability from OpenSSL::SSL::SSLSocket object.
+ * This means that readability notified by <code>IO.select</code> doesn't mean
+ * readability from <code>OpenSSL::SSL::SSLSocket</code> object.
*
- * The most likely situation is that OpenSSL::SSL::SSLSocket buffers
- * some data. IO.select doesn't see the buffer. So IO.select can
- * block when OpenSSL::SSL::SSLSocket#readpartial doesn't block.
+ * The most likely situation is that <code>OpenSSL::SSL::SSLSocket</code> buffers some data.
+ * <code>IO.select</code> doesn't see the buffer.
+ * So <code>IO.select</code> can block when <code>OpenSSL::SSL::SSLSocket#readpartial</code> doesn't block.
*
* However, several more complicated situations exist.
*
* SSL is a protocol which is sequence of records.
* The record consists of multiple bytes.
- * So, the remote side of SSL sends a partial record, IO.select
- * notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a
- * byte and OpenSSL::SSL::SSLSocket#readpartial will block.
+ * So, the remote side of SSL sends a partial record,
+ * <code>IO.select</code> notifies readability but
+ * <code>OpenSSL::SSL::SSLSocket</code> cannot decrypt a byte and
+ * <code>OpenSSL::SSL::SSLSocket#readpartial</code> will blocks.
*
* Also, the remote side can request SSL renegotiation which forces
* the local SSL engine to write some data.
- * This means OpenSSL::SSL::SSLSocket#readpartial may invoke #write
- * system call and it can block.
- * In such a situation, OpenSSL::SSL::SSLSocket#read_nonblock raises
- * IO::WaitWritable instead of blocking.
- * So, the caller should wait for ready for writability as above
- * example.
+ * This means <code>OpenSSL::SSL::SSLSocket#readpartial</code> may
+ * invoke <code>write</code> system call and it can block.
+ * In such a situation, <code>OpenSSL::SSL::SSLSocket#read_nonblock</code>
+ * raises IO::WaitWritable instead of blocking.
+ * So, the caller should wait for ready for writability as above example.
*
- * The combination of nonblocking methods and IO.select is also useful
- * for streams such as tty, pipe socket socket when multiple processes
- * read from a stream.
+ * The combination of nonblocking methods and <code>IO.select</code> is
+ * also useful for streams such as tty, pipe socket socket when
+ * multiple processes read from a stream.
*
* Finally, Linux kernel developers don't guarantee that
* readability of select(2) means readability of following read(2) even
* for a single process.
* See select(2) manual on GNU/Linux system.
*
- * Invoking IO.select before IO#readpartial works well as usual.
- * However it is not the best way to use IO.select.
+ * Invoking <code>IO.select</code> before <code>IO#readpartial</code> works well as usual.
+ * However it is not the best way to use <code>IO.select</code>.
*
* The writability notified by select(2) doesn't show
- * how many bytes are writable.
- * IO#write method blocks until given whole string is written.
- * So, <code>IO#write(two or more bytes)</code> can block after
- * writability is notified by IO.select. IO#write_nonblock is required
- * to avoid the blocking.
+ * how many bytes writable.
+ * <code>IO#write</code> method blocks until given whole string is written.
+ * So, <code>IO#write(two or more bytes)</code> can block after writability is notified by <code>IO.select</code>.
+ * <code>IO#write_nonblock</code> is required to avoid the blocking.
*
- * Blocking write (#write) can be emulated using #write_nonblock and
- * IO.select as follows: IO::WaitReadable should also be rescued for
- * SSL renegotiation in OpenSSL::SSL::SSLSocket.
+ * Blocking write (<code>write</code>) can be emulated using
+ * <code>write_nonblock</code> and <code>IO.select</code> as follows:
+ * IO::WaitReadable should also be rescued for SSL renegotiation in <code>OpenSSL::SSL::SSLSocket</code>.
*
* while 0 < string.bytesize
* begin
@@ -9511,9 +9334,9 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* end
*
* === Parameters
- * read_array:: an array of IO objects that wait until ready for read
- * write_array:: an array of IO objects that wait until ready for write
- * error_array:: an array of IO objects that wait for exceptions
+ * read_array:: an array of <code>IO</code> objects that wait until ready for read
+ * write_array:: an array of <code>IO</code> objects that wait until ready for write
+ * error_array:: an array of <code>IO</code> objects that wait for exceptions
* timeout:: a numeric value in second
*
* === Example
@@ -9570,12 +9393,12 @@ rb_f_select(int argc, VALUE *argv, VALUE obj)
return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args);
}
-#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
typedef unsigned long ioctl_req_t;
# define NUM2IOCTLREQ(num) NUM2ULONG(num)
#else
typedef int ioctl_req_t;
-# define NUM2IOCTLREQ(num) ((int)NUM2LONG(num))
+# define NUM2IOCTLREQ(num) NUM2INT(num)
#endif
#ifdef HAVE_IOCTL
@@ -9964,9 +9787,9 @@ rb_fcntl(VALUE io, VALUE req, VALUE arg)
* query file-oriented I/O streams. Arguments and results are platform
* dependent. If <i>arg</i> is a number, its value is passed
* directly. If it is a string, it is interpreted as a binary sequence
- * of bytes (Array#pack might be a useful way to build this string). On
- * Unix platforms, see <code>fcntl(2)</code> for details. Not
- * implemented on all platforms.
+ * of bytes (<code>Array#pack</code> might be a useful way to build this
+ * string). On Unix platforms, see <code>fcntl(2)</code> for details.
+ * Not implemented on all platforms.
*/
static VALUE
@@ -10017,7 +9840,7 @@ rb_io_fcntl(int argc, VALUE *argv, VALUE io)
*/
static VALUE
-rb_f_syscall(int argc, VALUE *argv, VALUE _)
+rb_f_syscall(int argc, VALUE *argv)
{
VALUE arg[8];
#if SIZEOF_VOIDP == 8 && defined(HAVE___SYSCALL) && SIZEOF_INT != 8 /* mainly *BSD */
@@ -10220,7 +10043,7 @@ pipe_pair_close(VALUE rw)
* IO.pipe(...) {|read_io, write_io| ... }
*
* Creates a pair of pipe endpoints (connected to each other) and
- * returns them as a two-element array of IO objects:
+ * returns them as a two-element array of <code>IO</code> objects:
* <code>[</code> <i>read_io</i>, <i>write_io</i> <code>]</code>.
*
* If a block is given, the block is called and
@@ -10282,7 +10105,7 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
VALUE ret;
argc = rb_scan_args(argc, argv, "02:", &v1, &v2, &opt);
- if (rb_pipe(pipes) < 0)
+ if (rb_pipe(pipes) == -1)
rb_sys_fail(0);
args[0] = klass;
@@ -10319,12 +10142,6 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
rb_io_synchronized(fptr2);
extract_binmode(opt, &fmode);
-
- if ((fmode & FMODE_BINMODE) && v1 == Qnil) {
- rb_io_ascii8bit_binmode(r);
- rb_io_ascii8bit_binmode(w);
- }
-
#if DEFAULT_TEXTMODE
if ((fptr->mode & FMODE_TEXTMODE) && (fmode & FMODE_BINMODE)) {
fptr->mode &= ~FMODE_TEXTMODE;
@@ -10383,15 +10200,14 @@ open_key_args(VALUE klass, int argc, VALUE *argv, VALUE opt, struct foreach_arg
v = rb_to_array_type(v);
n = RARRAY_LENINT(v);
rb_check_arity(n, 0, 3); /* rb_io_open */
- rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS, n, RARRAY_CONST_PTR(v), "02:", &vmode, &vperm, &opt);
+ rb_scan_args(n, RARRAY_CONST_PTR(v), "02:", &vmode, &vperm, &opt);
}
arg->io = rb_io_open(klass, path, vmode, vperm, opt);
}
static VALUE
-io_s_foreach(VALUE v)
+io_s_foreach(struct getline_arg *arg)
{
- struct getline_arg *arg = (void *)v;
VALUE str;
while (!NIL_P(str = rb_io_getline_1(arg->rs, arg->limit, arg->chomp, arg->io))) {
@@ -10448,9 +10264,8 @@ rb_io_s_foreach(int argc, VALUE *argv, VALUE self)
}
static VALUE
-io_s_readlines(VALUE v)
+io_s_readlines(struct getline_arg *arg)
{
- struct getline_arg *arg = (void *)v;
return io_readlines(arg, arg->io);
}
@@ -10501,9 +10316,8 @@ rb_io_s_readlines(int argc, VALUE *argv, VALUE io)
}
static VALUE
-io_s_read(VALUE v)
+io_s_read(struct foreach_arg *arg)
{
- struct foreach_arg *arg = (void *)v;
return io_read(arg->argc, arg->argv, arg->io);
}
@@ -10526,8 +10340,8 @@ seek_before_access(VALUE argp)
* IO.read(name, [length [, offset]] [, opt] ) -> string
*
* Opens the file, optionally seeks to the given +offset+, then returns
- * +length+ bytes (defaulting to the rest of the file). #read ensures
- * the file is closed before returning.
+ * +length+ bytes (defaulting to the rest of the file). <code>read</code>
+ * ensures the file is closed before returning.
*
* If +name+ starts with a pipe character (<code>"|"</code>), a subprocess is
* created in the same way as Kernel#open, and its output is returned.
@@ -10592,10 +10406,10 @@ rb_io_s_read(int argc, VALUE *argv, VALUE io)
* call-seq:
* IO.binread(name, [length [, offset]] ) -> string
*
- * Opens the file, optionally seeks to the given <i>offset</i>, then
- * returns <i>length</i> bytes (defaulting to the rest of the file).
- * #binread ensures the file is closed before returning. The open mode
- * would be <code>"rb:ASCII-8BIT"</code>.
+ * Opens the file, optionally seeks to the given <i>offset</i>, then returns
+ * <i>length</i> bytes (defaulting to the rest of the file).
+ * <code>binread</code> ensures the file is closed before returning.
+ * The open mode would be "rb:ASCII-8BIT".
*
* IO.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
* IO.binread("testfile", 20) #=> "This is line one\nThi"
@@ -10639,9 +10453,8 @@ rb_io_s_binread(int argc, VALUE *argv, VALUE io)
}
static VALUE
-io_s_write0(VALUE v)
+io_s_write0(struct write_arg *arg)
{
- struct write_arg *arg = (void * )v;
return io_write(arg->io,arg->str,arg->nosync);
}
@@ -10699,9 +10512,10 @@ io_s_write(int argc, VALUE *argv, VALUE klass, int binary)
* IO.write(name, string [, offset] [, opt]) -> integer
*
* Opens the file, optionally seeks to the given <i>offset</i>, writes
- * <i>string</i>, then returns the length written. #write ensures the
- * file is closed before returning. If <i>offset</i> is not given in
- * write mode, the file is truncated. Otherwise, it is not truncated.
+ * <i>string</i>, then returns the length written.
+ * <code>write</code> ensures the file is closed before returning.
+ * If <i>offset</i> is not given in write mode, the file is truncated.
+ * Otherwise, it is not truncated.
*
* IO.write("testfile", "0123456789", 20) #=> 10
* # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
@@ -10747,8 +10561,8 @@ rb_io_s_write(int argc, VALUE *argv, VALUE io)
* IO.binwrite(name, string, [offset] ) -> integer
* IO.binwrite(name, string, [offset], open_args ) -> integer
*
- * Same as IO.write except opening the file in binary mode and
- * ASCII-8BIT encoding (<code>"wb:ASCII-8BIT"</code>).
+ * Same as <code>IO.write</code> except opening the file in binary mode
+ * and ASCII-8BIT encoding ("wb:ASCII-8BIT").
*/
static VALUE
@@ -10765,18 +10579,14 @@ struct copy_stream_struct {
int src_fd;
int dst_fd;
- unsigned close_src : 1;
- unsigned close_dst : 1;
- int error_no;
+ int close_src;
+ int close_dst;
off_t total;
const char *syserr;
+ int error_no;
const char *notimp;
+ rb_fdset_t fds;
VALUE th;
- struct stat src_stat;
- struct stat dst_stat;
-#ifdef HAVE_FCOPYFILE
- copyfile_state_t copyfile_state;
-#endif
};
static void *
@@ -10811,10 +10621,16 @@ maygvl_copy_stream_continue_p(int has_gvl, struct copy_stream_struct *stp)
return FALSE;
}
-#if USE_POLL
+/* non-Linux poll may not work on all FDs */
+#if defined(HAVE_POLL) && defined(__linux__)
+# define USE_POLL 1
# define IOWAIT_SYSCALL "poll"
-STATIC_ASSERT(pollin_expected, POLLIN == RB_WAITFD_IN);
-STATIC_ASSERT(pollout_expected, POLLOUT == RB_WAITFD_OUT);
+#else
+# define IOWAIT_SYSCALL "select"
+# define USE_POLL 0
+#endif
+
+#if USE_POLL
static int
nogvl_wait_for_single_fd(int fd, short events)
{
@@ -10825,32 +10641,37 @@ nogvl_wait_for_single_fd(int fd, short events)
return poll(&fds, 1, -1);
}
-#else /* !USE_POLL */
-# define IOWAIT_SYSCALL "select"
+
static int
-nogvl_wait_for_single_fd(int fd, short events)
+maygvl_copy_stream_wait_read(int has_gvl, struct copy_stream_struct *stp)
{
- rb_fdset_t fds;
int ret;
- rb_fd_init(&fds);
- rb_fd_set(fd, &fds);
+ do {
+ if (has_gvl) {
+ ret = rb_wait_for_single_fd(stp->src_fd, RB_WAITFD_IN, NULL);
+ }
+ else {
+ ret = nogvl_wait_for_single_fd(stp->src_fd, POLLIN);
+ }
+ } while (ret == -1 && maygvl_copy_stream_continue_p(has_gvl, stp));
- switch (events) {
- case RB_WAITFD_IN:
- ret = rb_fd_select(fd + 1, &fds, 0, 0, 0);
- break;
- case RB_WAITFD_OUT:
- ret = rb_fd_select(fd + 1, 0, &fds, 0, 0);
- break;
- default:
- VM_UNREACHABLE(nogvl_wait_for_single_fd);
+ if (ret == -1) {
+ stp->syserr = "poll";
+ stp->error_no = errno;
+ return -1;
}
-
- rb_fd_term(&fds);
- return ret;
+ return 0;
+}
+#else /* !USE_POLL */
+static int
+maygvl_select(int has_gvl, int n, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout)
+{
+ if (has_gvl)
+ return rb_thread_fd_select(n, rfds, wfds, efds, timeout);
+ else
+ return rb_fd_select(n, rfds, wfds, efds, timeout);
}
-#endif /* !USE_POLL */
static int
maygvl_copy_stream_wait_read(int has_gvl, struct copy_stream_struct *stp)
@@ -10858,21 +10679,19 @@ maygvl_copy_stream_wait_read(int has_gvl, struct copy_stream_struct *stp)
int ret;
do {
- if (has_gvl) {
- ret = rb_wait_for_single_fd(stp->src_fd, RB_WAITFD_IN, NULL);
- }
- else {
- ret = nogvl_wait_for_single_fd(stp->src_fd, RB_WAITFD_IN);
- }
- } while (ret < 0 && maygvl_copy_stream_continue_p(has_gvl, stp));
+ rb_fd_zero(&stp->fds);
+ rb_fd_set(stp->src_fd, &stp->fds);
+ ret = maygvl_select(has_gvl, rb_fd_max(&stp->fds), &stp->fds, NULL, NULL, NULL);
+ } while (ret == -1 && maygvl_copy_stream_continue_p(has_gvl, stp));
- if (ret < 0) {
- stp->syserr = IOWAIT_SYSCALL;
+ if (ret == -1) {
+ stp->syserr = "select";
stp->error_no = errno;
- return ret;
+ return -1;
}
return 0;
}
+#endif /* !USE_POLL */
static int
nogvl_copy_stream_wait_write(struct copy_stream_struct *stp)
@@ -10880,18 +10699,24 @@ nogvl_copy_stream_wait_write(struct copy_stream_struct *stp)
int ret;
do {
- ret = nogvl_wait_for_single_fd(stp->dst_fd, RB_WAITFD_OUT);
- } while (ret < 0 && maygvl_copy_stream_continue_p(0, stp));
+#if USE_POLL
+ ret = nogvl_wait_for_single_fd(stp->dst_fd, POLLOUT);
+#else
+ rb_fd_zero(&stp->fds);
+ rb_fd_set(stp->dst_fd, &stp->fds);
+ ret = rb_fd_select(rb_fd_max(&stp->fds), NULL, &stp->fds, NULL, NULL);
+#endif
+ } while (ret == -1 && maygvl_copy_stream_continue_p(0, stp));
- if (ret < 0) {
+ if (ret == -1) {
stp->syserr = IOWAIT_SYSCALL;
stp->error_no = errno;
- return ret;
+ return -1;
}
return 0;
}
-#if defined HAVE_COPY_FILE_RANGE || (defined __linux__ && defined __NR_copy_file_range)
+#if defined __linux__ && defined __NR_copy_file_range
# define USE_COPY_FILE_RANGE
#endif
@@ -10900,26 +10725,36 @@ nogvl_copy_stream_wait_write(struct copy_stream_struct *stp)
static ssize_t
simple_copy_file_range(int in_fd, off_t *in_offset, int out_fd, off_t *out_offset, size_t count, unsigned int flags)
{
-#ifdef HAVE_COPY_FILE_RANGE
- return copy_file_range(in_fd, in_offset, out_fd, out_offset, count, flags);
-#else
return syscall(__NR_copy_file_range, in_fd, in_offset, out_fd, out_offset, count, flags);
-#endif
}
static int
nogvl_copy_file_range(struct copy_stream_struct *stp)
{
+ struct stat src_stat, dst_stat;
ssize_t ss;
- off_t src_size;
+ int ret;
+
off_t copy_length, src_offset, *src_offset_ptr;
- if (!S_ISREG(stp->src_stat.st_mode))
+ ret = fstat(stp->src_fd, &src_stat);
+ if (ret == -1) {
+ stp->syserr = "fstat";
+ stp->error_no = errno;
+ return -1;
+ }
+ if (!S_ISREG(src_stat.st_mode))
return 0;
- src_size = stp->src_stat.st_size;
+ ret = fstat(stp->dst_fd, &dst_stat);
+ if (ret == -1) {
+ stp->syserr = "fstat";
+ stp->error_no = errno;
+ return -1;
+ }
+
src_offset = stp->src_offset;
- if (src_offset >= (off_t)0) {
+ if (src_offset != (off_t)-1) {
src_offset_ptr = &src_offset;
}
else {
@@ -10927,20 +10762,20 @@ nogvl_copy_file_range(struct copy_stream_struct *stp)
}
copy_length = stp->copy_length;
- if (copy_length < (off_t)0) {
- if (src_offset < (off_t)0) {
+ if (copy_length == (off_t)-1) {
+ if (src_offset == (off_t)-1) {
off_t current_offset;
errno = 0;
current_offset = lseek(stp->src_fd, 0, SEEK_CUR);
- if (current_offset < (off_t)0 && errno) {
+ if (current_offset == (off_t)-1 && errno) {
stp->syserr = "lseek";
stp->error_no = errno;
- return (int)current_offset;
+ return -1;
}
- copy_length = src_size - current_offset;
+ copy_length = src_stat.st_size - current_offset;
}
else {
- copy_length = src_size - src_offset;
+ copy_length = src_stat.st_size - src_offset;
}
}
@@ -10959,7 +10794,7 @@ nogvl_copy_file_range(struct copy_stream_struct *stp)
goto retry_copy_file_range;
}
}
- if (ss < 0) {
+ if (ss == -1) {
if (maygvl_copy_stream_continue_p(0, stp)) {
goto retry_copy_file_range;
}
@@ -10978,10 +10813,8 @@ nogvl_copy_file_range(struct copy_stream_struct *stp)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- {
- int ret = nogvl_copy_stream_wait_write(stp);
- if (ret < 0) return ret;
- }
+ if (nogvl_copy_stream_wait_write(stp) == -1)
+ return -1;
goto retry_copy_file_range;
case EBADF:
{
@@ -10996,86 +10829,7 @@ nogvl_copy_file_range(struct copy_stream_struct *stp)
}
stp->syserr = "copy_file_range";
stp->error_no = errno;
- return (int)ss;
- }
- return 1;
-}
-#endif
-
-#ifdef HAVE_FCOPYFILE
-static int
-nogvl_fcopyfile(struct copy_stream_struct *stp)
-{
- off_t cur, ss = 0;
- const off_t src_offset = stp->src_offset;
- int ret;
-
- if (stp->copy_length >= (off_t)0) {
- /* copy_length can't be specified in fcopyfile(3) */
- return 0;
- }
-
- if (!S_ISREG(stp->src_stat.st_mode))
- return 0;
-
- if (!S_ISREG(stp->dst_stat.st_mode))
- return 0;
- if (lseek(stp->dst_fd, 0, SEEK_CUR) > (off_t)0) /* if dst IO was already written */
- return 0;
- if (fcntl(stp->dst_fd, F_GETFL) & O_APPEND) {
- /* fcopyfile(3) appends src IO to dst IO and then truncates
- * dst IO to src IO's original size. */
- off_t end = lseek(stp->dst_fd, 0, SEEK_END);
- lseek(stp->dst_fd, 0, SEEK_SET);
- if (end > (off_t)0) return 0;
- }
-
- if (src_offset > (off_t)0) {
- off_t r;
-
- /* get current offset */
- errno = 0;
- cur = lseek(stp->src_fd, 0, SEEK_CUR);
- if (cur < (off_t)0 && errno) {
- stp->error_no = errno;
- return 1;
- }
-
- errno = 0;
- r = lseek(stp->src_fd, src_offset, SEEK_SET);
- if (r < (off_t)0 && errno) {
- stp->error_no = errno;
- return 1;
- }
- }
-
- stp->copyfile_state = copyfile_state_alloc(); /* this will be freed by copy_stream_finalize() */
- ret = fcopyfile(stp->src_fd, stp->dst_fd, stp->copyfile_state, COPYFILE_DATA);
- copyfile_state_get(stp->copyfile_state, COPYFILE_STATE_COPIED, &ss); /* get copied bytes */
-
- if (ret == 0) { /* success */
- stp->total = ss;
- if (src_offset > (off_t)0) {
- off_t r;
- errno = 0;
- /* reset offset */
- r = lseek(stp->src_fd, cur, SEEK_SET);
- if (r < (off_t)0 && errno) {
- stp->error_no = errno;
- return 1;
- }
- }
- }
- else {
- switch (errno) {
- case ENOTSUP:
- case EPERM:
- case EINVAL:
- return 0;
- }
- stp->syserr = "fcopyfile";
- stp->error_no = errno;
- return (int)ret;
+ return -1;
}
return 1;
}
@@ -11114,7 +10868,7 @@ simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
# else
r = sendfile(in_fd, out_fd, pos, (size_t)count, NULL, &sbytes, 0);
# endif
- if (r != 0 && sbytes == 0) return r;
+ if (r != 0 && sbytes == 0) return -1;
if (offset) {
*offset += sbytes;
}
@@ -11132,38 +10886,51 @@ simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
static int
nogvl_copy_stream_sendfile(struct copy_stream_struct *stp)
{
+ struct stat src_stat, dst_stat;
ssize_t ss;
- off_t src_size;
+ int ret;
+
off_t copy_length;
off_t src_offset;
int use_pread;
- if (!S_ISREG(stp->src_stat.st_mode))
+ ret = fstat(stp->src_fd, &src_stat);
+ if (ret == -1) {
+ stp->syserr = "fstat";
+ stp->error_no = errno;
+ return -1;
+ }
+ if (!S_ISREG(src_stat.st_mode))
return 0;
- src_size = stp->src_stat.st_size;
+ ret = fstat(stp->dst_fd, &dst_stat);
+ if (ret == -1) {
+ stp->syserr = "fstat";
+ stp->error_no = errno;
+ return -1;
+ }
#ifndef __linux__
- if ((stp->dst_stat.st_mode & S_IFMT) != S_IFSOCK)
+ if ((dst_stat.st_mode & S_IFMT) != S_IFSOCK)
return 0;
#endif
src_offset = stp->src_offset;
- use_pread = src_offset >= (off_t)0;
+ use_pread = src_offset != (off_t)-1;
copy_length = stp->copy_length;
- if (copy_length < (off_t)0) {
+ if (copy_length == (off_t)-1) {
if (use_pread)
- copy_length = src_size - src_offset;
+ copy_length = src_stat.st_size - src_offset;
else {
off_t cur;
errno = 0;
cur = lseek(stp->src_fd, 0, SEEK_CUR);
- if (cur < (off_t)0 && errno) {
+ if (cur == (off_t)-1 && errno) {
stp->syserr = "lseek";
stp->error_no = errno;
- return (int)cur;
+ return -1;
}
- copy_length = src_size - cur;
+ copy_length = src_stat.st_size - cur;
}
}
@@ -11187,7 +10954,7 @@ nogvl_copy_stream_sendfile(struct copy_stream_struct *stp)
goto retry_sendfile;
}
}
- if (ss < 0) {
+ if (ss == -1) {
if (maygvl_copy_stream_continue_p(0, stp))
goto retry_sendfile;
switch (errno) {
@@ -11200,27 +10967,24 @@ nogvl_copy_stream_sendfile(struct copy_stream_struct *stp)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- {
- int ret;
#ifndef __linux__
- /*
- * Linux requires stp->src_fd to be a mmap-able (regular) file,
- * select() reports regular files to always be "ready", so
- * there is no need to select() on it.
- * Other OSes may have the same limitation for sendfile() which
- * allow us to bypass maygvl_copy_stream_wait_read()...
- */
- ret = maygvl_copy_stream_wait_read(0, stp);
- if (ret < 0) return ret;
-#endif
- ret = nogvl_copy_stream_wait_write(stp);
- if (ret < 0) return ret;
- }
+ /*
+ * Linux requires stp->src_fd to be a mmap-able (regular) file,
+ * select() reports regular files to always be "ready", so
+ * there is no need to select() on it.
+ * Other OSes may have the same limitation for sendfile() which
+ * allow us to bypass maygvl_copy_stream_wait_read()...
+ */
+ if (maygvl_copy_stream_wait_read(0, stp) == -1)
+ return -1;
+#endif
+ if (nogvl_copy_stream_wait_write(stp) == -1)
+ return -1;
goto retry_sendfile;
}
stp->syserr = "sendfile";
stp->error_no = errno;
- return (int)ss;
+ return -1;
}
return 1;
}
@@ -11240,7 +11004,7 @@ maygvl_copy_stream_read(int has_gvl, struct copy_stream_struct *stp, char *buf,
{
ssize_t ss;
retry_read:
- if (offset < (off_t)0) {
+ if (offset == (off_t)-1) {
ss = maygvl_read(has_gvl, stp->src_fd, buf, len);
}
else {
@@ -11254,7 +11018,7 @@ maygvl_copy_stream_read(int has_gvl, struct copy_stream_struct *stp, char *buf,
if (ss == 0) {
return 0;
}
- if (ss < 0) {
+ if (ss == -1) {
if (maygvl_copy_stream_continue_p(has_gvl, stp))
goto retry_read;
switch (errno) {
@@ -11262,19 +11026,18 @@ maygvl_copy_stream_read(int has_gvl, struct copy_stream_struct *stp, char *buf,
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- {
- int ret = maygvl_copy_stream_wait_read(has_gvl, stp);
- if (ret < 0) return ret;
- }
+ if (maygvl_copy_stream_wait_read(has_gvl, stp) == -1)
+ return -1;
goto retry_read;
#ifdef ENOSYS
case ENOSYS:
stp->notimp = "pread";
- return ss;
+ return -1;
#endif
}
- stp->syserr = offset < (off_t)0 ? "read" : "pread";
+ stp->syserr = offset == (off_t)-1 ? "read" : "pread";
stp->error_no = errno;
+ return -1;
}
return ss;
}
@@ -11286,17 +11049,17 @@ nogvl_copy_stream_write(struct copy_stream_struct *stp, char *buf, size_t len)
int off = 0;
while (len) {
ss = write(stp->dst_fd, buf+off, len);
- if (ss < 0) {
- if (maygvl_copy_stream_continue_p(0, stp))
- continue;
+ if (ss == -1) {
+ if (maygvl_copy_stream_continue_p(0, stp))
+ continue;
if (errno == EAGAIN || errno == EWOULDBLOCK) {
- int ret = nogvl_copy_stream_wait_write(stp);
- if (ret < 0) return ret;
+ if (nogvl_copy_stream_wait_write(stp) == -1)
+ return -1;
continue;
}
stp->syserr = "write";
stp->error_no = errno;
- return (int)ss;
+ return -1;
}
off += (int)ss;
len -= (int)ss;
@@ -11318,15 +11081,15 @@ nogvl_copy_stream_read_write(struct copy_stream_struct *stp)
int use_pread;
copy_length = stp->copy_length;
- use_eof = copy_length < (off_t)0;
+ use_eof = copy_length == (off_t)-1;
src_offset = stp->src_offset;
- use_pread = src_offset >= (off_t)0;
+ use_pread = src_offset != (off_t)-1;
if (use_pread && stp->close_src) {
off_t r;
errno = 0;
r = lseek(stp->src_fd, src_offset, SEEK_SET);
- if (r < (off_t)0 && errno) {
+ if (r == (off_t)-1 && errno) {
stp->syserr = "lseek";
stp->error_no = errno;
return;
@@ -11366,7 +11129,7 @@ static void *
nogvl_copy_stream_func(void *arg)
{
struct copy_stream_struct *stp = (struct copy_stream_struct *)arg;
-#if defined(USE_SENDFILE) || defined(USE_COPY_FILE_RANGE) || defined(HAVE_FCOPYFILE)
+#ifdef USE_SENDFILE
int ret;
#endif
@@ -11376,12 +11139,6 @@ nogvl_copy_stream_func(void *arg)
goto finish; /* error or success */
#endif
-#ifdef HAVE_FCOPYFILE
- ret = nogvl_fcopyfile(stp);
- if (ret != 0)
- goto finish; /* error or success */
-#endif
-
#ifdef USE_SENDFILE
ret = nogvl_copy_stream_sendfile(stp);
if (ret != 0)
@@ -11390,7 +11147,7 @@ nogvl_copy_stream_func(void *arg)
nogvl_copy_stream_read_write(stp);
-#if defined(USE_SENDFILE) || defined(USE_COPY_FILE_RANGE) || defined(HAVE_FCOPYFILE)
+#ifdef USE_SENDFILE
finish:
#endif
return 0;
@@ -11407,7 +11164,7 @@ copy_stream_fallback_body(VALUE arg)
off_t off = stp->src_offset;
ID read_method = id_readpartial;
- if (stp->src_fd < 0) {
+ if (stp->src_fd == -1) {
if (!rb_respond_to(stp->src, read_method)) {
read_method = id_read;
}
@@ -11416,17 +11173,15 @@ copy_stream_fallback_body(VALUE arg)
while (1) {
long numwrote;
long l;
- if (stp->copy_length < (off_t)0) {
+ if (stp->copy_length == (off_t)-1) {
l = buflen;
}
else {
- if (rest == 0) {
- rb_str_resize(buf, 0);
- break;
- }
+ if (rest == 0)
+ break;
l = buflen < rest ? buflen : (long)rest;
}
- if (stp->src_fd < 0) {
+ if (stp->src_fd == -1) {
VALUE rc = rb_funcall(stp->src, read_method, 2, INT2FIX(l), buf);
if (read_method == id_read && NIL_P(rc))
@@ -11437,11 +11192,11 @@ copy_stream_fallback_body(VALUE arg)
rb_str_resize(buf, buflen);
ss = maygvl_copy_stream_read(1, stp, RSTRING_PTR(buf), l, off);
rb_str_resize(buf, ss > 0 ? ss : 0);
- if (ss < 0)
+ if (ss == -1)
return Qnil;
if (ss == 0)
rb_eof_error();
- if (off >= (off_t)0)
+ if (off != (off_t)-1)
off += ss;
}
n = rb_io_write(stp->dst, buf);
@@ -11459,11 +11214,11 @@ copy_stream_fallback_body(VALUE arg)
static VALUE
copy_stream_fallback(struct copy_stream_struct *stp)
{
- if (stp->src_fd < 0 && stp->src_offset >= (off_t)0) {
+ if (stp->src_fd == -1 && stp->src_offset != (off_t)-1) {
rb_raise(rb_eArgError, "cannot specify src_offset for non-IO");
}
rb_rescue2(copy_stream_fallback_body, (VALUE)stp,
- (VALUE (*) (VALUE, VALUE))0, (VALUE)0,
+ (VALUE (*) (ANYARGS))0, (VALUE)0,
rb_eEOFError, (VALUE)0);
return Qnil;
}
@@ -11492,7 +11247,6 @@ copy_stream_body(VALUE arg)
src_fd = -1;
}
else {
- int stat_ret;
VALUE tmp_io = rb_io_check_io(src_io);
if (!NIL_P(tmp_io)) {
src_io = tmp_io;
@@ -11509,13 +11263,6 @@ copy_stream_body(VALUE arg)
GetOpenFile(src_io, src_fptr);
rb_io_check_byte_readable(src_fptr);
src_fd = src_fptr->fd;
-
- stat_ret = fstat(src_fd, &stp->src_stat);
- if (stat_ret < 0) {
- stp->syserr = "fstat";
- stp->error_no = errno;
- return Qnil;
- }
}
stp->src_fd = src_fd;
@@ -11526,8 +11273,7 @@ copy_stream_body(VALUE arg)
dst_fd = -1;
}
else {
- int stat_ret;
- VALUE tmp_io = rb_io_check_io(dst_io);
+ VALUE tmp_io = rb_io_check_io(dst_io);
if (!NIL_P(tmp_io)) {
dst_io = GetWriteIO(tmp_io);
}
@@ -11548,13 +11294,6 @@ copy_stream_body(VALUE arg)
GetOpenFile(dst_io, dst_fptr);
rb_io_check_writable(dst_fptr);
dst_fd = dst_fptr->fd;
-
- stat_ret = fstat(dst_fd, &stp->dst_stat);
- if (stat_ret < 0) {
- stp->syserr = "fstat";
- stp->error_no = errno;
- return Qnil;
- }
}
stp->dst_fd = dst_fd;
@@ -11565,10 +11304,10 @@ copy_stream_body(VALUE arg)
if (dst_fptr)
io_ascii8bit_binmode(dst_fptr);
- if (stp->src_offset < (off_t)0 && src_fptr && src_fptr->rbuf.len) {
+ if (stp->src_offset == (off_t)-1 && src_fptr && src_fptr->rbuf.len) {
size_t len = src_fptr->rbuf.len;
VALUE str;
- if (stp->copy_length >= (off_t)0 && stp->copy_length < (off_t)len) {
+ if (stp->copy_length != (off_t)-1 && stp->copy_length < (off_t)len) {
len = (size_t)stp->copy_length;
}
str = rb_str_buf_new(len);
@@ -11580,9 +11319,8 @@ copy_stream_body(VALUE arg)
}
else /* others such as StringIO */
rb_io_write(dst_io, str);
- rb_str_resize(str, 0);
stp->total += len;
- if (stp->copy_length >= (off_t)0)
+ if (stp->copy_length != (off_t)-1)
stp->copy_length -= len;
}
@@ -11593,10 +11331,13 @@ copy_stream_body(VALUE arg)
if (stp->copy_length == 0)
return Qnil;
- if (src_fd < 0 || dst_fd < 0) {
+ if (src_fd == -1 || dst_fd == -1) {
return copy_stream_fallback(stp);
}
+ rb_fd_set(src_fd, &stp->fds);
+ rb_fd_set(dst_fd, &stp->fds);
+
rb_thread_call_without_gvl(nogvl_copy_stream_func, (void*)stp, RUBY_UBF_IO, 0);
return Qnil;
}
@@ -11605,19 +11346,13 @@ static VALUE
copy_stream_finalize(VALUE arg)
{
struct copy_stream_struct *stp = (struct copy_stream_struct *)arg;
-
-#ifdef HAVE_FCOPYFILE
- if (stp->copyfile_state) {
- copyfile_state_free(stp->copyfile_state);
- }
-#endif
-
if (stp->close_src) {
rb_io_close_m(stp->src);
}
if (stp->close_dst) {
rb_io_close_m(stp->dst);
}
+ rb_fd_term(&stp->fds);
if (stp->syserr) {
rb_syserr_fail(stp->error_no, stp->syserr);
}
@@ -11635,8 +11370,9 @@ copy_stream_finalize(VALUE arg)
*
* IO.copy_stream copies <i>src</i> to <i>dst</i>.
* <i>src</i> and <i>dst</i> is either a filename or an IO-like object.
- * IO-like object for <i>src</i> should have #readpartial or #read
- * method. IO-like object for <i>dst</i> should have #write method.
+ * IO-like object for <i>src</i> should have <code>readpartial</code> or
+ * <code>read</code> method.
+ * IO-like object for <i>dst</i> should have <code>write</code> method.
* (Specialized mechanisms, such as sendfile system call, may be used
* on appropriate situation.)
*
@@ -11682,6 +11418,7 @@ rb_io_s_copy_stream(int argc, VALUE *argv, VALUE io)
else
st.src_offset = NUM2OFFT(src_offset);
+ rb_fd_init(&st.fds);
rb_ensure(copy_stream_body, (VALUE)&st, copy_stream_finalize, (VALUE)&st);
return OFFT2NUM(st.total);
@@ -12159,11 +11896,11 @@ static VALUE argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts,
* The _outbuf_ will contain only the received data after the method call
* even if it is not empty at the beginning.
*
- * It raises EOFError on end of ARGF stream.
+ * It raises <code>EOFError</code> on end of ARGF stream.
* Since ARGF stream is a concatenation of multiple files,
* internally EOF is occur for each file.
* ARGF.readpartial returns empty strings for EOFs except the last one and
- * raises EOFError for the last one.
+ * raises <code>EOFError</code> for the last one.
*
*/
@@ -12198,14 +11935,12 @@ static VALUE
argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts, int nonblock)
{
VALUE tmp, str, length;
- int no_exception;
rb_scan_args(argc, argv, "11", &length, &str);
if (!NIL_P(str)) {
StringValue(str);
argv[1] = str;
}
- no_exception = no_exception_p(opts);
if (!next_argv()) {
if (!NIL_P(str)) {
@@ -12214,25 +11949,24 @@ argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts, int nonblock)
rb_eof_error();
}
if (ARGF_GENERIC_INPUT_P()) {
- VALUE (*const rescue_does_nothing)(VALUE, VALUE) = 0;
struct argf_call_arg arg;
arg.argc = argc;
arg.argv = argv;
arg.argf = argf;
tmp = rb_rescue2(argf_forward_call, (VALUE)&arg,
- rescue_does_nothing, Qnil, rb_eEOFError, (VALUE)0);
+ RUBY_METHOD_FUNC(0), Qnil, rb_eEOFError, (VALUE)0);
}
else {
- tmp = io_getpartial(argc, argv, ARGF.current_file, no_exception, nonblock);
+ tmp = io_getpartial(argc, argv, ARGF.current_file, opts, nonblock);
}
if (NIL_P(tmp)) {
if (ARGF.next_p == -1) {
- return io_nonblock_eof(no_exception);
+ return io_nonblock_eof(opts);
}
argf_close(argf);
ARGF.next_p = 1;
if (RARRAY_LEN(ARGF.argv) == 0) {
- return io_nonblock_eof(no_exception);
+ return io_nonblock_eof(opts);
}
if (NIL_P(str))
str = rb_str_new(NULL, 0);
@@ -12410,14 +12144,10 @@ argf_block_call_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, argf))
return Qnil;
}
-#define ARGF_block_call(mid, argc, argv, func, argf) \
- rb_block_call_kw(ARGF.current_file, mid, argc, argv, \
- func, argf, rb_keyword_given_p())
-
static void
argf_block_call(ID mid, int argc, VALUE *argv, VALUE argf)
{
- VALUE ret = ARGF_block_call(mid, argc, argv, argf_block_call_i, argf);
+ VALUE ret = rb_block_call(ARGF.current_file, mid, argc, argv, argf_block_call_i, argf);
if (ret != Qundef) ARGF.next_p = 1;
}
@@ -12433,7 +12163,7 @@ argf_block_call_line_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, argf))
static void
argf_block_call_line(ID mid, int argc, VALUE *argv, VALUE argf)
{
- VALUE ret = ARGF_block_call(mid, argc, argv, argf_block_call_line_i, argf);
+ VALUE ret = rb_block_call(ARGF.current_file, mid, argc, argv, argf_block_call_line_i, argf);
if (ret != Qundef) ARGF.next_p = 1;
}
@@ -12488,13 +12218,13 @@ argf_each_line(int argc, VALUE *argv, VALUE argf)
}
/*
- * This is a deprecated alias for #each_line.
+ * This is a deprecated alias for <code>each_line</code>.
*/
static VALUE
argf_lines(int argc, VALUE *argv, VALUE argf)
{
- rb_warn_deprecated("ARGF#lines", "#each_line");
+ rb_warn("ARGF#lines is deprecated; use #each_line instead");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_line")), argc, argv);
return argf_each_line(argc, argv, argf);
@@ -12535,13 +12265,13 @@ argf_each_byte(VALUE argf)
}
/*
- * This is a deprecated alias for #each_byte.
+ * This is a deprecated alias for <code>each_byte</code>.
*/
static VALUE
argf_bytes(VALUE argf)
{
- rb_warn_deprecated("ARGF#bytes", "#each_byte");
+ rb_warn("ARGF#bytes is deprecated; use #each_byte instead");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_byte")), 0, 0);
return argf_each_byte(argf);
@@ -12574,13 +12304,13 @@ argf_each_char(VALUE argf)
}
/*
- * This is a deprecated alias for #each_char.
+ * This is a deprecated alias for <code>each_char</code>.
*/
static VALUE
argf_chars(VALUE argf)
{
- rb_warn_deprecated("ARGF#chars", "#each_char");
+ rb_warn("ARGF#chars is deprecated; use #each_char instead");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_char")), 0, 0);
return argf_each_char(argf);
@@ -12613,13 +12343,13 @@ argf_each_codepoint(VALUE argf)
}
/*
- * This is a deprecated alias for #each_codepoint.
+ * This is a deprecated alias for <code>each_codepoint</code>.
*/
static VALUE
argf_codepoints(VALUE argf)
{
- rb_warn_deprecated("ARGF#codepoints", "#each_codepoint");
+ rb_warn("ARGF#codepoints is deprecated; use #each_codepoint instead");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_codepoint")), 0, 0);
return argf_each_codepoint(argf);
@@ -12850,6 +12580,9 @@ opt_i_get(ID id, VALUE *var)
static VALUE
argf_inplace_mode_set(VALUE argf, VALUE val)
{
+ if (rb_safe_level() >= 1 && OBJ_TAINTED(val))
+ rb_insecure_operation();
+
if (!RTEST(val)) {
ARGF.inplace = Qfalse;
}
@@ -12868,6 +12601,12 @@ opt_i_set(VALUE val, ID id, VALUE *var)
argf_inplace_mode_set(*var, val);
}
+const char *
+ruby_get_inplace_mode(void)
+{
+ return RSTRING_PTR(ARGF.inplace);
+}
+
void
ruby_set_inplace_mode(const char *suffix)
{
@@ -12984,18 +12723,6 @@ rb_readwrite_syserr_fail(enum rb_io_wait_readwrite writable, int n, const char *
}
}
-static VALUE
-get_LAST_READ_LINE(ID _x, VALUE *_y)
-{
- return rb_lastline_get();
-}
-
-static void
-set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
-{
- rb_lastline_set(val);
-}
-
/*
* Document-class: IOError
*
@@ -13202,14 +12929,10 @@ Init_IO(void)
rb_cIO = rb_define_class("IO", rb_cObject);
rb_include_module(rb_cIO, rb_mEnumerable);
- /* exception to wait for reading. see IO.select. */
rb_mWaitReadable = rb_define_module_under(rb_cIO, "WaitReadable");
- /* exception to wait for writing. see IO.select. */
rb_mWaitWritable = rb_define_module_under(rb_cIO, "WaitWritable");
- /* exception to wait for reading by EAGAIN. see IO.select. */
rb_eEAGAINWaitReadable = rb_define_class_under(rb_cIO, "EAGAINWaitReadable", rb_eEAGAIN);
rb_include_module(rb_eEAGAINWaitReadable, rb_mWaitReadable);
- /* exception to wait for writing by EAGAIN. see IO.select. */
rb_eEAGAINWaitWritable = rb_define_class_under(rb_cIO, "EAGAINWaitWritable", rb_eEAGAIN);
rb_include_module(rb_eEAGAINWaitWritable, rb_mWaitWritable);
#if EAGAIN == EWOULDBLOCK
@@ -13220,17 +12943,13 @@ Init_IO(void)
/* same as IO::EAGAINWaitWritable */
rb_define_const(rb_cIO, "EWOULDBLOCKWaitWritable", rb_eEAGAINWaitWritable);
#else
- /* exception to wait for reading by EWOULDBLOCK. see IO.select. */
rb_eEWOULDBLOCKWaitReadable = rb_define_class_under(rb_cIO, "EWOULDBLOCKWaitReadable", rb_eEWOULDBLOCK);
rb_include_module(rb_eEWOULDBLOCKWaitReadable, rb_mWaitReadable);
- /* exception to wait for writing by EWOULDBLOCK. see IO.select. */
rb_eEWOULDBLOCKWaitWritable = rb_define_class_under(rb_cIO, "EWOULDBLOCKWaitWritable", rb_eEWOULDBLOCK);
rb_include_module(rb_eEWOULDBLOCKWaitWritable, rb_mWaitWritable);
#endif
- /* exception to wait for reading by EINPROGRESS. see IO.select. */
rb_eEINPROGRESSWaitReadable = rb_define_class_under(rb_cIO, "EINPROGRESSWaitReadable", rb_eEINPROGRESS);
rb_include_module(rb_eEINPROGRESSWaitReadable, rb_mWaitReadable);
- /* exception to wait for writing by EINPROGRESS. see IO.select. */
rb_eEINPROGRESSWaitWritable = rb_define_class_under(rb_cIO, "EINPROGRESSWaitWritable", rb_eEINPROGRESS);
rb_include_module(rb_eEINPROGRESSWaitWritable, rb_mWaitWritable);
@@ -13259,9 +12978,9 @@ Init_IO(void)
rb_define_method(rb_cIO, "initialize", rb_io_initialize, -1);
rb_output_fs = Qnil;
- rb_define_hooked_variable("$,", &rb_output_fs, 0, rb_output_fs_setter);
+ rb_define_hooked_variable("$,", &rb_output_fs, 0, rb_str_setter);
- rb_default_rs = rb_fstring_lit("\n"); /* avoid modifying RS_default */
+ rb_default_rs = rb_fstring_cstr("\n"); /* avoid modifying RS_default */
rb_gc_register_mark_object(rb_default_rs);
rb_rs = rb_default_rs;
rb_output_rs = Qnil;
@@ -13269,7 +12988,7 @@ Init_IO(void)
rb_define_hooked_variable("$-0", &rb_rs, 0, rb_str_setter);
rb_define_hooked_variable("$\\", &rb_output_rs, 0, rb_str_setter);
- rb_define_virtual_variable("$_", get_LAST_READ_LINE, set_LAST_READ_LINE);
+ rb_define_virtual_variable("$_", rb_lastline_get, rb_lastline_set);
rb_define_method(rb_cIO, "initialize_copy", rb_io_init_copy, 1);
rb_define_method(rb_cIO, "reopen", rb_io_reopen, -1);
@@ -13309,6 +13028,10 @@ Init_IO(void)
rb_define_method(rb_cIO, "readlines", rb_io_readlines, -1);
+ /* for prelude.rb use only: */
+ rb_define_private_method(rb_cIO, "__read_nonblock", io_read_nonblock, 3);
+ rb_define_private_method(rb_cIO, "__write_nonblock", io_write_nonblock, 2);
+
rb_define_method(rb_cIO, "readpartial", io_readpartial, -1);
rb_define_method(rb_cIO, "read", io_read, -1);
rb_define_method(rb_cIO, "write", io_write_m, -1);
@@ -13367,7 +13090,6 @@ Init_IO(void)
rb_define_method(rb_cIO, "external_encoding", rb_io_external_encoding, 0);
rb_define_method(rb_cIO, "internal_encoding", rb_io_internal_encoding, 0);
rb_define_method(rb_cIO, "set_encoding", rb_io_set_encoding, -1);
- rb_define_method(rb_cIO, "set_encoding_by_bom", rb_io_set_encoding_by_bom, 0);
rb_define_method(rb_cIO, "autoclose?", rb_io_autoclose_p, 0);
rb_define_method(rb_cIO, "autoclose=", rb_io_set_autoclose, 1);
@@ -13518,11 +13240,3 @@ Init_IO(void)
sym_wait_readable = ID2SYM(rb_intern("wait_readable"));
sym_wait_writable = ID2SYM(rb_intern("wait_writable"));
}
-
-#include "io.rbinc"
-
-void
-Init_IO_nonblock(void)
-{
- load_io();
-}
diff --git a/io.rb b/io.rb
deleted file mode 100644
index 1b6dddf9e5..0000000000
--- a/io.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-class IO
- # other IO methods are defined in io.c
-
- # call-seq:
- # ios.read_nonblock(maxlen [, options]) -> string
- # ios.read_nonblock(maxlen, outbuf [, options]) -> outbuf
- #
- # Reads at most <i>maxlen</i> bytes from <em>ios</em> using
- # the read(2) system call after O_NONBLOCK is set for
- # the underlying file descriptor.
- #
- # If the optional <i>outbuf</i> argument is present,
- # it must reference a String, which will receive the data.
- # The <i>outbuf</i> will contain only the received data after the method call
- # even if it is not empty at the beginning.
- #
- # read_nonblock just calls the read(2) system call.
- # It causes all errors the read(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
- # The caller should care such errors.
- #
- # If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN,
- # it is extended by IO::WaitReadable.
- # So IO::WaitReadable can be used to rescue the exceptions for retrying
- # read_nonblock.
- #
- # read_nonblock causes EOFError on EOF.
- #
- # On some platforms, such as Windows, non-blocking mode is not supported
- # on IO objects other than sockets. In such cases, Errno::EBADF will
- # be raised.
- #
- # If the read byte buffer is not empty,
- # read_nonblock reads from the buffer like readpartial.
- # In this case, the read(2) system call is not called.
- #
- # When read_nonblock raises an exception kind of IO::WaitReadable,
- # read_nonblock should not be called
- # until io is readable for avoiding busy loop.
- # This can be done as follows.
- #
- # # emulates blocking read (readpartial).
- # begin
- # result = io.read_nonblock(maxlen)
- # rescue IO::WaitReadable
- # IO.select([io])
- # retry
- # end
- #
- # Although IO#read_nonblock doesn't raise IO::WaitWritable.
- # OpenSSL::Buffering#read_nonblock can raise IO::WaitWritable.
- # If IO and SSL should be used polymorphically,
- # IO::WaitWritable should be rescued too.
- # See the document of OpenSSL::Buffering#read_nonblock for sample code.
- #
- # Note that this method is identical to readpartial
- # except the non-blocking flag is set.
- #
- # By specifying a keyword argument _exception_ to +false+, you can indicate
- # that read_nonblock should not raise an IO::WaitReadable exception, but
- # return the symbol +:wait_readable+ instead. At EOF, it will return nil
- # instead of raising EOFError.
- def read_nonblock(len, buf = nil, exception: true)
- __builtin_io_read_nonblock(len, buf, exception)
- end
-
- # call-seq:
- # ios.write_nonblock(string) -> integer
- # ios.write_nonblock(string [, options]) -> integer
- #
- # Writes the given string to <em>ios</em> using
- # the write(2) system call after O_NONBLOCK is set for
- # the underlying file descriptor.
- #
- # It returns the number of bytes written.
- #
- # write_nonblock just calls the write(2) system call.
- # It causes all errors the write(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
- # The result may also be smaller than string.length (partial write).
- # The caller should care such errors and partial write.
- #
- # If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN,
- # it is extended by IO::WaitWritable.
- # So IO::WaitWritable can be used to rescue the exceptions for retrying write_nonblock.
- #
- # # Creates a pipe.
- # r, w = IO.pipe
- #
- # # write_nonblock writes only 65536 bytes and return 65536.
- # # (The pipe size is 65536 bytes on this environment.)
- # s = "a" * 100000
- # p w.write_nonblock(s) #=> 65536
- #
- # # write_nonblock cannot write a byte and raise EWOULDBLOCK (EAGAIN).
- # p w.write_nonblock("b") # Resource temporarily unavailable (Errno::EAGAIN)
- #
- # If the write buffer is not empty, it is flushed at first.
- #
- # When write_nonblock raises an exception kind of IO::WaitWritable,
- # write_nonblock should not be called
- # until io is writable for avoiding busy loop.
- # This can be done as follows.
- #
- # begin
- # result = io.write_nonblock(string)
- # rescue IO::WaitWritable, Errno::EINTR
- # IO.select(nil, [io])
- # retry
- # end
- #
- # Note that this doesn't guarantee to write all data in string.
- # The length written is reported as result and it should be checked later.
- #
- # On some platforms such as Windows, write_nonblock is not supported
- # according to the kind of the IO object.
- # In such cases, write_nonblock raises <code>Errno::EBADF</code>.
- #
- # By specifying a keyword argument _exception_ to +false+, you can indicate
- # that write_nonblock should not raise an IO::WaitWritable exception, but
- # return the symbol +:wait_writable+ instead.
- def write_nonblock(buf, exception: true)
- __builtin_io_write_nonblock(buf, exception)
- end
-end
diff --git a/iseq.c b/iseq.c
index 46066938c7..868c4ee4f8 100644
--- a/iseq.c
+++ b/iseq.c
@@ -17,28 +17,19 @@
# include <dlfcn.h>
#endif
-#define RUBY_VM_INSNS_INFO 1
/* #define RUBY_MARK_FREE_DEBUG 1 */
#include "gc.h"
#include "vm_core.h"
#include "iseq.h"
#include "id_table.h"
-#include "builtin.h"
#include "insns.inc"
#include "insns_info.inc"
-#include "mjit.h"
VALUE rb_cISeq;
static VALUE iseqw_new(const rb_iseq_t *iseq);
static const rb_iseq_t *iseqw_check(VALUE iseqw);
-#if VM_INSN_INFO_TABLE_IMPL == 2
-static struct succ_index_table *succ_index_table_create(int max_pos, int *data, int size);
-static unsigned int *succ_index_table_invert(int max_pos, struct succ_index_table *sd, int size);
-static int succ_index_lookup(const struct succ_index_table *sd, int x);
-#endif
-
#define hidden_obj_p(obj) (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass)
static inline VALUE
@@ -52,32 +43,22 @@ obj_resurrect(VALUE obj)
case T_ARRAY:
obj = rb_ary_resurrect(obj);
break;
- case T_HASH:
- obj = rb_hash_resurrect(obj);
- break;
}
}
return obj;
}
static void
-free_arena(struct iseq_compile_data_storage *cur)
-{
- struct iseq_compile_data_storage *next;
-
- while (cur) {
- next = cur->next;
- ruby_xfree(cur);
- cur = next;
- }
-}
-
-static void
compile_data_free(struct iseq_compile_data *compile_data)
{
if (compile_data) {
- free_arena(compile_data->node.storage_head);
- free_arena(compile_data->insn.storage_head);
+ struct iseq_compile_data_storage *cur, *next;
+ cur = compile_data->storage_head;
+ while (cur) {
+ next = cur->next;
+ ruby_xfree(cur);
+ cur = next;
+ }
if (compile_data->ivar_cache_table) {
rb_id_table_free(compile_data->ivar_cache_table);
}
@@ -90,267 +71,60 @@ rb_iseq_free(const rb_iseq_t *iseq)
{
RUBY_FREE_ENTER("iseq");
- if (iseq && iseq->body) {
- struct rb_iseq_constant_body *const body = iseq->body;
- mjit_free_iseq(iseq); /* Notify MJIT */
- ruby_xfree((void *)body->iseq_encoded);
- ruby_xfree((void *)body->insns_info.body);
- if (body->insns_info.positions) ruby_xfree((void *)body->insns_info.positions);
-#if VM_INSN_INFO_TABLE_IMPL == 2
- if (body->insns_info.succ_index_table) ruby_xfree(body->insns_info.succ_index_table);
-#endif
- if (LIKELY(body->local_table != rb_iseq_shared_exc_local_tbl))
- ruby_xfree((void *)body->local_table);
- ruby_xfree((void *)body->is_entries);
-
- if (body->call_data) {
- unsigned int i;
- struct rb_kwarg_call_data *kw_calls = (struct rb_kwarg_call_data *)&body->call_data[body->ci_size];
- for (i=0; i<body->ci_kw_size; i++) {
- const struct rb_call_info_kw_arg *kw_arg = kw_calls[i].ci_kw.kw_arg;
- ruby_xfree((void *)kw_arg);
+ if (iseq) {
+ if (iseq->body) {
+ ruby_xfree((void *)iseq->body->iseq_encoded);
+ ruby_xfree((void *)iseq->body->insns_info);
+ ruby_xfree((void *)iseq->body->local_table);
+ ruby_xfree((void *)iseq->body->is_entries);
+
+ if (iseq->body->ci_entries) {
+ unsigned int i;
+ struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&iseq->body->ci_entries[iseq->body->ci_size];
+ for (i=0; i<iseq->body->ci_kw_size; i++) {
+ const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg;
+ ruby_xfree((void *)kw_arg);
+ }
+ ruby_xfree(iseq->body->ci_entries);
+ ruby_xfree(iseq->body->cc_entries);
}
- ruby_xfree(body->call_data);
- }
- ruby_xfree((void *)body->catch_table);
- ruby_xfree((void *)body->param.opt_table);
+ ruby_xfree((void *)iseq->body->catch_table);
+ ruby_xfree((void *)iseq->body->param.opt_table);
- if (body->param.keyword != NULL) {
- ruby_xfree((void *)body->param.keyword->default_values);
- ruby_xfree((void *)body->param.keyword);
+ if (iseq->body->param.keyword != NULL) {
+ ruby_xfree((void *)iseq->body->param.keyword->default_values);
+ ruby_xfree((void *)iseq->body->param.keyword);
+ }
+ compile_data_free(ISEQ_COMPILE_DATA(iseq));
+ ruby_xfree(iseq->body);
}
- compile_data_free(ISEQ_COMPILE_DATA(iseq));
- ruby_xfree(body);
- }
-
- if (iseq && ISEQ_EXECUTABLE_P(iseq) && iseq->aux.exec.local_hooks) {
- rb_hook_list_free(iseq->aux.exec.local_hooks);
}
-
RUBY_FREE_LEAVE("iseq");
}
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
-static VALUE
-rb_vm_insn_addr2insn2(const void *addr)
-{
- return (VALUE)rb_vm_insn_addr2insn(addr);
-}
-#endif
-
-static VALUE
-rb_vm_insn_null_translator(const void *addr)
-{
- return (VALUE)addr;
-}
-
-typedef VALUE iseq_value_itr_t(void *ctx, VALUE obj);
-typedef VALUE rb_vm_insns_translator_t(const void *addr);
-
-static int
-iseq_extract_values(VALUE *code, size_t pos, iseq_value_itr_t * func, void *data, rb_vm_insns_translator_t * translator)
-{
- VALUE insn = translator((void *)code[pos]);
- int len = insn_len(insn);
- int op_no;
- const char *types = insn_op_types(insn);
-
- for (op_no = 0; types[op_no]; op_no++) {
- char type = types[op_no];
- switch (type) {
- case TS_CDHASH:
- case TS_ISEQ:
- case TS_VALUE:
- {
- VALUE op = code[pos + op_no + 1];
- if (!SPECIAL_CONST_P(op)) {
- VALUE newop = func(data, op);
- if (newop != op) {
- code[pos + op_no + 1] = newop;
- }
- }
- }
- break;
- case TS_ISE:
- {
- union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)code[pos + op_no + 1];
- if (is->once.value) {
- VALUE nv = func(data, is->once.value);
- if (is->once.value != nv) {
- is->once.value = nv;
- }
- }
- }
- break;
- default:
- break;
- }
- }
-
- return len;
-}
-
-static void
-rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data)
-{
- unsigned int size;
- VALUE *code;
- size_t n;
- rb_vm_insns_translator_t *const translator =
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
- (FL_TEST(iseq, ISEQ_TRANSLATED)) ? rb_vm_insn_addr2insn2 :
-#endif
- rb_vm_insn_null_translator;
- const struct rb_iseq_constant_body *const body = iseq->body;
-
- size = body->iseq_size;
- code = body->iseq_encoded;
-
- for (n = 0; n < size;) {
- n += iseq_extract_values(code, n, func, data, translator);
- }
-}
-
-static VALUE
-update_each_insn_value(void *ctx, VALUE obj)
-{
- return rb_gc_location(obj);
-}
-
-void
-rb_iseq_update_references(rb_iseq_t *iseq)
-{
- if (iseq->body) {
- struct rb_iseq_constant_body *body = iseq->body;
-
- body->variable.coverage = rb_gc_location(body->variable.coverage);
- body->variable.pc2branchindex = rb_gc_location(body->variable.pc2branchindex);
- body->location.label = rb_gc_location(body->location.label);
- body->location.base_label = rb_gc_location(body->location.base_label);
- body->location.pathobj = rb_gc_location(body->location.pathobj);
- if (body->local_iseq) {
- body->local_iseq = (struct rb_iseq_struct *)rb_gc_location((VALUE)body->local_iseq);
- }
- if (body->parent_iseq) {
- body->parent_iseq = (struct rb_iseq_struct *)rb_gc_location((VALUE)body->parent_iseq);
- }
- if (FL_TEST(iseq, ISEQ_MARKABLE_ISEQ)) {
- rb_iseq_each_value(iseq, update_each_insn_value, NULL);
- VALUE *original_iseq = ISEQ_ORIGINAL_ISEQ(iseq);
- if (original_iseq) {
- size_t n = 0;
- const unsigned int size = body->iseq_size;
- while (n < size) {
- n += iseq_extract_values(original_iseq, n, update_each_insn_value, NULL, rb_vm_insn_null_translator);
- }
- }
- }
-
- if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
- int i, j;
-
- i = body->param.keyword->required_num;
-
- for (j = 0; i < body->param.keyword->num; i++, j++) {
- VALUE obj = body->param.keyword->default_values[j];
- if (obj != Qundef) {
- body->param.keyword->default_values[j] = rb_gc_location(obj);
- }
- }
- }
-
- if (body->catch_table) {
- struct iseq_catch_table *table = body->catch_table;
- unsigned int i;
- for (i = 0; i < table->size; i++) {
- struct iseq_catch_table_entry *entry;
- entry = UNALIGNED_MEMBER_PTR(table, entries[i]);
- if (entry->iseq) {
- entry->iseq = (rb_iseq_t *)rb_gc_location((VALUE)entry->iseq);
- }
- }
- }
-#if USE_MJIT
- mjit_update_references(iseq);
-#endif
- }
-}
-
-static VALUE
-each_insn_value(void *ctx, VALUE obj)
-{
- rb_gc_mark_movable(obj);
- return obj;
-}
-
void
rb_iseq_mark(const rb_iseq_t *iseq)
{
RUBY_MARK_ENTER("iseq");
- RUBY_MARK_UNLESS_NULL(iseq->wrapper);
-
if (iseq->body) {
- const struct rb_iseq_constant_body *const body = iseq->body;
-
- if (FL_TEST(iseq, ISEQ_MARKABLE_ISEQ)) {
- rb_iseq_each_value(iseq, each_insn_value, NULL);
- }
-
- rb_gc_mark_movable(body->variable.coverage);
- rb_gc_mark_movable(body->variable.pc2branchindex);
- rb_gc_mark_movable(body->location.label);
- rb_gc_mark_movable(body->location.base_label);
- rb_gc_mark_movable(body->location.pathobj);
- RUBY_MARK_NO_PIN_UNLESS_NULL((VALUE)body->parent_iseq);
-
- if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
- const struct rb_iseq_param_keyword *const keyword = body->param.keyword;
- int i, j;
+ const struct rb_iseq_constant_body *body = iseq->body;
- i = keyword->required_num;
-
- for (j = 0; i < keyword->num; i++, j++) {
- VALUE obj = keyword->default_values[j];
- if (!SPECIAL_CONST_P(obj)) {
- rb_gc_mark_movable(obj);
- }
- }
- }
-
- if (body->catch_table) {
- const struct iseq_catch_table *table = body->catch_table;
- unsigned int i;
- for (i = 0; i < table->size; i++) {
- const struct iseq_catch_table_entry *entry;
- entry = UNALIGNED_MEMBER_PTR(table, entries[i]);
- if (entry->iseq) {
- rb_gc_mark_movable((VALUE)entry->iseq);
- }
- }
- }
+ RUBY_MARK_UNLESS_NULL(body->mark_ary);
+ rb_gc_mark(body->location.label);
+ rb_gc_mark(body->location.base_label);
+ rb_gc_mark(body->location.pathobj);
+ RUBY_MARK_UNLESS_NULL((VALUE)body->parent_iseq);
}
- if (FL_TEST_RAW(iseq, ISEQ_NOT_LOADED_YET)) {
+ if (FL_TEST(iseq, ISEQ_NOT_LOADED_YET)) {
rb_gc_mark(iseq->aux.loader.obj);
}
- else if (FL_TEST_RAW(iseq, ISEQ_USE_COMPILE_DATA)) {
+ else if (ISEQ_COMPILE_DATA(iseq) != NULL) {
const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
-
- rb_iseq_mark_insn_storage(compile_data->insn.storage_head);
-
- RUBY_MARK_UNLESS_NULL(compile_data->err_info);
- if (RTEST(compile_data->catch_table_ary)) {
- rb_gc_mark(compile_data->catch_table_ary);
- }
- VM_ASSERT(compile_data != NULL);
- }
- else {
- /* executable */
- VM_ASSERT(ISEQ_EXECUTABLE_P(iseq));
- if (iseq->aux.exec.local_hooks) {
- rb_hook_list_mark(iseq->aux.exec.local_hooks);
- }
+ RUBY_MARK_UNLESS_NULL(compile_data->mark_ary);
+ RUBY_MARK_UNLESS_NULL(compile_data->err_info);
+ RUBY_MARK_UNLESS_NULL(compile_data->catch_table_ary);
}
RUBY_MARK_LEAVE("iseq");
@@ -369,8 +143,8 @@ param_keyword_size(const struct rb_iseq_param_keyword *pkw)
return size;
}
-size_t
-rb_iseq_memsize(const rb_iseq_t *iseq)
+static size_t
+iseq_memsize(const rb_iseq_t *iseq)
{
size_t size = 0; /* struct already counted as RVALUE size */
const struct rb_iseq_constant_body *body = iseq->body;
@@ -378,37 +152,41 @@ rb_iseq_memsize(const rb_iseq_t *iseq)
/* TODO: should we count original_iseq? */
- if (ISEQ_EXECUTABLE_P(iseq) && body) {
- struct rb_kwarg_call_data *kw_calls = (struct rb_kwarg_call_data *)&body->call_data[body->ci_size];
+ if (body) {
+ struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size];
- size += sizeof(struct rb_iseq_constant_body);
- size += body->iseq_size * sizeof(VALUE);
- size += body->insns_info.size * (sizeof(struct iseq_insn_info_entry) + sizeof(unsigned int));
- size += body->local_table_size * sizeof(ID);
- if (body->catch_table) {
- size += iseq_catch_table_bytes(body->catch_table->size);
- }
- size += (body->param.opt_num + 1) * sizeof(VALUE);
- size += param_keyword_size(body->param.keyword);
+ size += sizeof(struct rb_iseq_constant_body);
+ size += body->iseq_size * sizeof(VALUE);
+ size += body->insns_info_size * sizeof(struct iseq_insn_info_entry);
+ size += body->local_table_size * sizeof(ID);
+ if (body->catch_table) {
+ size += iseq_catch_table_bytes(body->catch_table->size);
+ }
+ size += (body->param.opt_num + 1) * sizeof(VALUE);
+ size += param_keyword_size(body->param.keyword);
+
+ /* body->is_entries */
+ size += body->is_size * sizeof(union iseq_inline_storage_entry);
- /* body->is_entries */
- size += body->is_size * sizeof(union iseq_inline_storage_entry);
+ /* body->ci_entries */
+ size += body->ci_size * sizeof(struct rb_call_info);
+ size += body->ci_kw_size * sizeof(struct rb_call_info_with_kwarg);
- /* body->call_data */
- size += body->ci_size * sizeof(struct rb_call_data);
- size += body->ci_kw_size * sizeof(struct rb_kwarg_call_data);
+ /* body->cc_entries */
+ size += body->ci_size * sizeof(struct rb_call_cache);
+ size += body->ci_kw_size * sizeof(struct rb_call_cache);
- if (kw_calls) {
- unsigned int i;
+ if (ci_kw_entries) {
+ unsigned int i;
- for (i = 0; i < body->ci_kw_size; i++) {
- const struct rb_call_info_kw_arg *kw_arg = kw_calls[i].ci_kw.kw_arg;
+ for (i = 0; i < body->ci_kw_size; i++) {
+ const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg;
- if (kw_arg) {
- size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len);
- }
- }
- }
+ if (kw_arg) {
+ size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len);
+ }
+ }
+ }
}
compile_data = ISEQ_COMPILE_DATA(iseq);
@@ -417,9 +195,9 @@ rb_iseq_memsize(const rb_iseq_t *iseq)
size += sizeof(struct iseq_compile_data);
- cur = compile_data->node.storage_head;
+ cur = compile_data->storage_head;
while (cur) {
- size += cur->size + offsetof(struct iseq_compile_data_storage, buff);
+ size += cur->size + SIZEOF_ISEQ_COMPILE_DATA_STORAGE;
cur = cur->next;
}
}
@@ -427,22 +205,11 @@ rb_iseq_memsize(const rb_iseq_t *iseq)
return size;
}
-static uintptr_t fresh_iseq_unique_id = 0; /* -- Remove In 3.0 -- */
-
-struct rb_iseq_constant_body *
-rb_iseq_constant_body_alloc(void)
-{
- struct rb_iseq_constant_body *iseq_body;
- iseq_body = ZALLOC(struct rb_iseq_constant_body);
- iseq_body->iseq_unique_id = fresh_iseq_unique_id++; /* -- Remove In 3.0 -- */
- return iseq_body;
-}
-
static rb_iseq_t *
iseq_alloc(void)
{
rb_iseq_t *iseq = iseq_imemo_alloc();
- iseq->body = rb_iseq_constant_body_alloc();
+ iseq->body = ZALLOC(struct rb_iseq_constant_body);
return iseq;
}
@@ -473,7 +240,7 @@ rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath)
}
static rb_iseq_location_t *
-iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_location_t *code_location, const int node_id)
+iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_range_t *code_range)
{
rb_iseq_location_t *loc = &iseq->body->location;
@@ -481,15 +248,14 @@ iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VAL
RB_OBJ_WRITE(iseq, &loc->label, name);
RB_OBJ_WRITE(iseq, &loc->base_label, name);
loc->first_lineno = first_lineno;
- if (code_location) {
- loc->node_id = node_id;
- loc->code_location = *code_location;
+ if (code_range) {
+ loc->code_range = *code_range;
}
else {
- loc->code_location.beg_pos.lineno = 0;
- loc->code_location.beg_pos.column = 0;
- loc->code_location.end_pos.lineno = -1;
- loc->code_location.end_pos.column = -1;
+ loc->code_range.first_loc.lineno = 0;
+ loc->code_range.first_loc.column = 0;
+ loc->code_range.last_loc.lineno = -1;
+ loc->code_range.last_loc.column = -1;
}
return loc;
@@ -498,81 +264,75 @@ iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VAL
static void
set_relation(rb_iseq_t *iseq, const rb_iseq_t *piseq)
{
- struct rb_iseq_constant_body *const body = iseq->body;
- const VALUE type = body->type;
+ const VALUE type = iseq->body->type;
/* set class nest stack */
if (type == ISEQ_TYPE_TOP) {
- body->local_iseq = iseq;
+ iseq->body->local_iseq = iseq;
}
else if (type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
- body->local_iseq = iseq;
+ iseq->body->local_iseq = iseq;
}
else if (piseq) {
- body->local_iseq = piseq->body->local_iseq;
+ iseq->body->local_iseq = piseq->body->local_iseq;
}
if (piseq) {
- body->parent_iseq = piseq;
+ iseq->body->parent_iseq = piseq;
}
if (type == ISEQ_TYPE_MAIN) {
- body->local_iseq = iseq;
+ iseq->body->local_iseq = iseq;
}
}
-static struct iseq_compile_data_storage *
-new_arena(void)
+void
+rb_iseq_add_mark_object(const rb_iseq_t *iseq, VALUE obj)
{
- struct iseq_compile_data_storage * new_arena =
- (struct iseq_compile_data_storage *)
- ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
- offsetof(struct iseq_compile_data_storage, buff));
-
- new_arena->pos = 0;
- new_arena->next = 0;
- new_arena->size = INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE;
-
- return new_arena;
+ /* TODO: check dedup */
+ rb_ary_push(ISEQ_MARK_ARY(iseq), obj);
}
static VALUE
prepare_iseq_build(rb_iseq_t *iseq,
- VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_location_t *code_location, const int node_id,
+ VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_range_t *code_range,
const rb_iseq_t *parent, enum iseq_type type,
const rb_compile_option_t *option)
{
VALUE coverage = Qfalse;
VALUE err_info = Qnil;
- struct rb_iseq_constant_body *const body = iseq->body;
if (parent && (type == ISEQ_TYPE_MAIN || type == ISEQ_TYPE_TOP))
err_info = Qfalse;
- body->type = type;
+ iseq->body->type = type;
set_relation(iseq, parent);
name = rb_fstring(name);
- iseq_location_setup(iseq, name, path, realpath, first_lineno, code_location, node_id);
- if (iseq != body->local_iseq) {
- RB_OBJ_WRITE(iseq, &body->location.base_label, body->local_iseq->body->location.label);
+ iseq_location_setup(iseq, name, path, realpath, first_lineno, code_range);
+ if (iseq != iseq->body->local_iseq) {
+ RB_OBJ_WRITE(iseq, &iseq->body->location.base_label, iseq->body->local_iseq->body->location.label);
}
- ISEQ_COVERAGE_SET(iseq, Qnil);
- ISEQ_ORIGINAL_ISEQ_CLEAR(iseq);
- body->variable.flip_count = 0;
+ RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, iseq_mark_ary_create(0));
ISEQ_COMPILE_DATA_ALLOC(iseq);
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err_info);
- RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, Qnil);
-
- ISEQ_COMPILE_DATA(iseq)->node.storage_head = ISEQ_COMPILE_DATA(iseq)->node.storage_current = new_arena();
- ISEQ_COMPILE_DATA(iseq)->insn.storage_head = ISEQ_COMPILE_DATA(iseq)->insn.storage_current = new_arena();
+ RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->mark_ary, rb_ary_tmp_new(3));
+
+ ISEQ_COMPILE_DATA(iseq)->storage_head = ISEQ_COMPILE_DATA(iseq)->storage_current =
+ (struct iseq_compile_data_storage *)
+ ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
+ SIZEOF_ISEQ_COMPILE_DATA_STORAGE);
+
+ RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_tmp_new(3));
+ ISEQ_COMPILE_DATA(iseq)->storage_head->pos = 0;
+ ISEQ_COMPILE_DATA(iseq)->storage_head->next = 0;
+ ISEQ_COMPILE_DATA(iseq)->storage_head->size =
+ INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE;
ISEQ_COMPILE_DATA(iseq)->option = option;
ISEQ_COMPILE_DATA(iseq)->ivar_cache_table = NULL;
- ISEQ_COMPILE_DATA(iseq)->builtin_function_table = GET_VM()->builtin_function_table;
-
if (option->coverage_enabled) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages)) {
@@ -581,50 +341,20 @@ prepare_iseq_build(rb_iseq_t *iseq,
}
}
ISEQ_COVERAGE_SET(iseq, coverage);
- if (coverage && ISEQ_BRANCH_COVERAGE(iseq))
- ISEQ_PC2BRANCHINDEX_SET(iseq, rb_ary_tmp_new(0));
return Qtrue;
}
-#if VM_CHECK_MODE > 0 && VM_INSN_INFO_TABLE_IMPL > 0
-static void validate_get_insn_info(const rb_iseq_t *iseq);
-#endif
-
-void
-rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq)
-{
-#if VM_INSN_INFO_TABLE_IMPL == 2
- struct rb_iseq_constant_body *const body = iseq->body;
- int size = body->insns_info.size;
- int max_pos = body->iseq_size;
- int *data = (int *)body->insns_info.positions;
- if (body->insns_info.succ_index_table) ruby_xfree(body->insns_info.succ_index_table);
- body->insns_info.succ_index_table = succ_index_table_create(max_pos, data, size);
-#if VM_CHECK_MODE == 0
- ruby_xfree(body->insns_info.positions);
- body->insns_info.positions = NULL;
-#endif
-#endif
-}
-
-#if VM_INSN_INFO_TABLE_IMPL == 2
-unsigned int *
-rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body)
-{
- int size = body->insns_info.size;
- int max_pos = body->iseq_size;
- struct succ_index_table *sd = body->insns_info.succ_index_table;
- return succ_index_table_invert(max_pos, sd, size);
-}
+#if VM_CHECK_MODE > 0
+static void validate_get_insn_info(rb_iseq_t *iseq);
#endif
void
rb_iseq_init_trace(rb_iseq_t *iseq)
{
- iseq->aux.exec.global_trace_events = 0;
- if (ruby_vm_event_enabled_global_flags & ISEQ_TRACE_EVENTS) {
- rb_iseq_trace_set(iseq, ruby_vm_event_enabled_global_flags & ISEQ_TRACE_EVENTS);
+ iseq->aux.trace_events = 0;
+ if (ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS) {
+ rb_iseq_trace_set(iseq, ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS);
}
}
@@ -632,24 +362,16 @@ static VALUE
finish_iseq_build(rb_iseq_t *iseq)
{
struct iseq_compile_data *data = ISEQ_COMPILE_DATA(iseq);
- const struct rb_iseq_constant_body *const body = iseq->body;
VALUE err = data->err_info;
ISEQ_COMPILE_DATA_CLEAR(iseq);
compile_data_free(data);
-#if VM_INSN_INFO_TABLE_IMPL == 2 /* succinct bitvector */
- /* create succ_index_table */
- if (body->insns_info.succ_index_table == NULL) {
- rb_iseq_insns_info_encode_positions(iseq);
- }
-#endif
-
-#if VM_CHECK_MODE > 0 && VM_INSN_INFO_TABLE_IMPL > 0
+#if VM_CHECK_MODE > 0
validate_get_insn_info(iseq);
#endif
if (RTEST(err)) {
- VALUE path = pathobj_path(body->location.pathobj);
+ VALUE path = pathobj_path(iseq->body->location.pathobj);
if (err == Qtrue) err = rb_exc_new_cstr(rb_eSyntaxError, "compile error");
rb_funcallv(err, rb_intern("set_backtrace"), 1, &path);
rb_exc_raise(err);
@@ -701,7 +423,7 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
#undef SET_COMPILE_OPTION_NUM
}
-static void
+void
rb_iseq_make_compile_option(rb_compile_option_t *option, VALUE opt)
{
Check_Type(opt, T_HASH);
@@ -734,7 +456,7 @@ make_compile_option(rb_compile_option_t *option, VALUE opt)
static VALUE
make_compile_option_value(rb_compile_option_t *option)
{
- VALUE opt = rb_hash_new_with_size(11);
+ VALUE opt = rb_hash_new();
#define SET_COMPILE_OPTION(o, h, mem) \
rb_hash_aset((h), ID2SYM(rb_intern(#mem)), (o)->mem ? Qtrue : Qfalse)
#define SET_COMPILE_OPTION_NUM(o, h, mem) \
@@ -758,33 +480,24 @@ make_compile_option_value(rb_compile_option_t *option)
}
rb_iseq_t *
-rb_iseq_new(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
+rb_iseq_new(const NODE *node, VALUE name, VALUE path, VALUE realpath,
const rb_iseq_t *parent, enum iseq_type type)
{
- return rb_iseq_new_with_opt(ast, name, path, realpath, INT2FIX(0), parent, type,
+ return rb_iseq_new_with_opt(node, name, path, realpath, INT2FIX(0), parent, type,
&COMPILE_OPTION_DEFAULT);
}
rb_iseq_t *
-rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
-{
- VALUE coverages = rb_get_coverages();
- if (RTEST(coverages)) {
- if (ast->line_count >= 0) {
- int len = (rb_get_coverage_mode() & COVERAGE_TARGET_ONESHOT_LINES) ? 0 : ast->line_count;
- VALUE coverage = rb_default_coverage(len);
- rb_hash_aset(coverages, path, coverage);
- }
- }
-
- return rb_iseq_new_with_opt(ast, name, path, realpath, INT2FIX(0), parent, ISEQ_TYPE_TOP,
+rb_iseq_new_top(const NODE *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
+{
+ return rb_iseq_new_with_opt(node, name, path, realpath, INT2FIX(0), parent, ISEQ_TYPE_TOP,
&COMPILE_OPTION_DEFAULT);
}
rb_iseq_t *
-rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent)
+rb_iseq_new_main(const NODE *node, VALUE path, VALUE realpath, const rb_iseq_t *parent)
{
- return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
+ return rb_iseq_new_with_opt(node, rb_fstring_cstr("<main>"),
path, realpath, INT2FIX(0),
parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
}
@@ -804,40 +517,19 @@ iseq_translate(rb_iseq_t *iseq)
}
rb_iseq_t *
-rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
+rb_iseq_new_with_opt(const NODE *node, VALUE name, VALUE path, VALUE realpath,
VALUE first_lineno, const rb_iseq_t *parent,
enum iseq_type type, const rb_compile_option_t *option)
{
- const NODE *node = ast ? ast->root : 0;
- /* TODO: argument check */
- rb_iseq_t *iseq = iseq_alloc();
- rb_compile_option_t new_opt;
-
- new_opt = option ? *option : COMPILE_OPTION_DEFAULT;
- if (ast && ast->compile_option) rb_iseq_make_compile_option(&new_opt, ast->compile_option);
-
- prepare_iseq_build(iseq, name, path, realpath, first_lineno, node ? &node->nd_loc : NULL, node ? nd_node_id(node) : -1, parent, type, &new_opt);
-
- rb_iseq_compile_node(iseq, node);
- finish_iseq_build(iseq);
-
- return iseq_translate(iseq);
-}
-
-rb_iseq_t *
-rb_iseq_new_with_callback(
- const struct rb_iseq_new_with_callback_callback_func * ifunc,
- VALUE name, VALUE path, VALUE realpath,
- VALUE first_lineno, const rb_iseq_t *parent,
- enum iseq_type type, const rb_compile_option_t *option)
-{
/* TODO: argument check */
rb_iseq_t *iseq = iseq_alloc();
+ const rb_code_range_t *code_range = NULL;
if (!option) option = &COMPILE_OPTION_DEFAULT;
- prepare_iseq_build(iseq, name, path, realpath, first_lineno, NULL, -1, parent, type, option);
+ if (node && !imemo_type_p((VALUE)node, imemo_ifunc)) code_range = &node->nd_loc;
+ prepare_iseq_build(iseq, name, path, realpath, first_lineno, code_range, parent, type, option);
- rb_iseq_compile_callback(iseq, ifunc);
+ rb_iseq_compile_node(iseq, node);
finish_iseq_build(iseq);
return iseq_translate(iseq);
@@ -872,7 +564,7 @@ iseq_type_from_sym(VALUE type)
const ID id_ensure = rb_intern("ensure");
const ID id_eval = rb_intern("eval");
const ID id_main = rb_intern("main");
- const ID id_plain = rb_intern("plain");
+ const ID id_defined_guard = rb_intern("defined_guard");
/* ensure all symbols are static or pinned down before
* conversion */
const ID typeid = rb_check_id(&type);
@@ -884,7 +576,7 @@ iseq_type_from_sym(VALUE type)
if (typeid == id_ensure) return ISEQ_TYPE_ENSURE;
if (typeid == id_eval) return ISEQ_TYPE_EVAL;
if (typeid == id_main) return ISEQ_TYPE_MAIN;
- if (typeid == id_plain) return ISEQ_TYPE_PLAIN;
+ if (typeid == id_defined_guard) return ISEQ_TYPE_DEFINED_GUARD;
return (enum iseq_type)-1;
}
@@ -894,13 +586,13 @@ iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt)
rb_iseq_t *iseq = iseq_alloc();
VALUE magic, version1, version2, format_type, misc;
- VALUE name, path, realpath, first_lineno, code_location, node_id;
+ VALUE name, path, realpath, first_lineno, code_range;
VALUE type, body, locals, params, exception;
st_data_t iseq_type;
rb_compile_option_t option;
int i = 0;
- rb_code_location_t tmp_loc = { {0, 0}, {-1, -1} };
+ rb_code_range_t tmp_loc = { {0, 0}, {-1, -1} };
/* [magic, major_version, minor_version, format_type, misc,
* label, path, first_lineno,
@@ -932,22 +624,20 @@ iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt)
iseq_type = iseq_type_from_sym(type);
if (iseq_type == (enum iseq_type)-1) {
- rb_raise(rb_eTypeError, "unsupported type: :%"PRIsVALUE, rb_sym2str(type));
+ rb_raise(rb_eTypeError, "unsupport type: :%"PRIsVALUE, rb_sym2str(type));
}
- node_id = rb_hash_aref(misc, ID2SYM(rb_intern("node_id")));
-
- code_location = rb_hash_aref(misc, ID2SYM(rb_intern("code_location")));
- if (RB_TYPE_P(code_location, T_ARRAY) && RARRAY_LEN(code_location) == 4) {
- tmp_loc.beg_pos.lineno = NUM2INT(rb_ary_entry(code_location, 0));
- tmp_loc.beg_pos.column = NUM2INT(rb_ary_entry(code_location, 1));
- tmp_loc.end_pos.lineno = NUM2INT(rb_ary_entry(code_location, 2));
- tmp_loc.end_pos.column = NUM2INT(rb_ary_entry(code_location, 3));
+ code_range = rb_hash_aref(misc, ID2SYM(rb_intern("code_range")));
+ if (RB_TYPE_P(code_range, T_ARRAY) && RARRAY_LEN(code_range) == 4) {
+ tmp_loc.first_loc.lineno = NUM2INT(rb_ary_entry(code_range, 0));
+ tmp_loc.first_loc.column = NUM2INT(rb_ary_entry(code_range, 1));
+ tmp_loc.last_loc.lineno = NUM2INT(rb_ary_entry(code_range, 2));
+ tmp_loc.last_loc.column = NUM2INT(rb_ary_entry(code_range, 3));
}
make_compile_option(&option, opt);
option.peephole_optimization = FALSE; /* because peephole optimization can modify original iseq */
- prepare_iseq_build(iseq, name, path, realpath, first_lineno, &tmp_loc, NUM2INT(node_id),
+ prepare_iseq_build(iseq, name, path, realpath, first_lineno, &tmp_loc,
parent, (enum iseq_type)iseq_type, &option);
rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body);
@@ -974,11 +664,13 @@ rb_iseq_load(VALUE data, VALUE parent, VALUE opt)
return iseq_load(data, RTEST(parent) ? (rb_iseq_t *)parent : NULL, opt);
}
-static rb_iseq_t *
-rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, VALUE opt)
+rb_iseq_t *
+rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, const struct rb_block *base_block, VALUE opt)
{
rb_iseq_t *iseq = NULL;
+ const rb_iseq_t *const parent = base_block ? vm_block_iseq(base_block) : NULL;
rb_compile_option_t option;
+ const enum iseq_type type = parent ? ISEQ_TYPE_EVAL : ISEQ_TYPE_TOP;
#if !defined(__GNUC__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 8)
# define INITIALIZED volatile /* suppress warnings by gcc 4.8 */
#else
@@ -1001,28 +693,38 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
}
{
const VALUE parser = rb_parser_new();
- VALUE name = rb_fstring_lit("<compiled>");
- const rb_iseq_t *outer_scope = rb_iseq_new(NULL, name, name, Qnil, 0, ISEQ_TYPE_TOP);
- VALUE outer_scope_v = (VALUE)outer_scope;
- rb_parser_set_context(parser, outer_scope, FALSE);
- RB_GC_GUARD(outer_scope_v);
+ rb_parser_set_context(parser, base_block, FALSE);
ast = (*parse)(parser, file, src, ln);
}
- if (!ast->body.root) {
+ if (!ast->root) {
rb_ast_dispose(ast);
rb_exc_raise(GET_EC()->errinfo);
}
else {
- INITIALIZED VALUE label = rb_fstring_lit("<compiled>");
- iseq = rb_iseq_new_with_opt(&ast->body, label, file, realpath, line,
- 0, ISEQ_TYPE_TOP, &option);
+ INITIALIZED VALUE label = parent ?
+ parent->body->location.label :
+ rb_fstring_cstr("<compiled>");
+ iseq = rb_iseq_new_with_opt(ast->root, label, file, realpath, line,
+ parent, type, &option);
rb_ast_dispose(ast);
}
return iseq;
}
+rb_iseq_t *
+rb_iseq_compile(VALUE src, VALUE file, VALUE line)
+{
+ return rb_iseq_compile_with_option(src, file, Qnil, line, 0, Qnil);
+}
+
+rb_iseq_t *
+rb_iseq_compile_on_base(VALUE src, VALUE file, VALUE line, const struct rb_block *base_block)
+{
+ return rb_iseq_compile_with_option(src, file, Qnil, line, base_block, Qnil);
+}
+
VALUE
rb_iseq_path(const rb_iseq_t *iseq)
{
@@ -1062,10 +764,12 @@ rb_iseq_first_lineno(const rb_iseq_t *iseq)
VALUE
rb_iseq_method_name(const rb_iseq_t *iseq)
{
- struct rb_iseq_constant_body *const body = iseq->body->local_iseq->body;
+ const rb_iseq_t *local_iseq;
- if (body->type == ISEQ_TYPE_METHOD) {
- return body->location.base_label;
+ local_iseq = iseq->body->local_iseq;
+
+ if (local_iseq->body->type == ISEQ_TYPE_METHOD) {
+ return local_iseq->body->location.base_label;
}
else {
return Qnil;
@@ -1073,13 +777,12 @@ rb_iseq_method_name(const rb_iseq_t *iseq)
}
void
-rb_iseq_code_location(const rb_iseq_t *iseq, int *beg_pos_lineno, int *beg_pos_column, int *end_pos_lineno, int *end_pos_column)
+rb_iseq_code_range(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column)
{
- const rb_code_location_t *loc = &iseq->body->location.code_location;
- if (beg_pos_lineno) *beg_pos_lineno = loc->beg_pos.lineno;
- if (beg_pos_column) *beg_pos_column = loc->beg_pos.column;
- if (end_pos_lineno) *end_pos_lineno = loc->end_pos.lineno;
- if (end_pos_column) *end_pos_column = loc->end_pos.column;
+ if (first_lineno) *first_lineno = iseq->body->location.code_range.first_loc.lineno;
+ if (first_column) *first_column = iseq->body->location.code_range.first_loc.column;
+ if (last_lineno) *last_lineno = iseq->body->location.code_range.last_loc.lineno;
+ if (last_column) *last_column = iseq->body->location.code_range.last_loc.column;
}
VALUE
@@ -1088,30 +791,6 @@ rb_iseq_coverage(const rb_iseq_t *iseq)
return ISEQ_COVERAGE(iseq);
}
-static int
-remove_coverage_i(void *vstart, void *vend, size_t stride, void *data)
-{
- VALUE v = (VALUE)vstart;
- for (; v != (VALUE)vend; v += stride) {
- void *ptr = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
-
- if (rb_obj_is_iseq(v)) {
- rb_iseq_t *iseq = (rb_iseq_t *)v;
- ISEQ_COVERAGE_SET(iseq, Qnil);
- }
-
- asan_poison_object_if(ptr, v);
- }
- return 0;
-}
-
-void
-rb_iseq_remove_coverage_all(void)
-{
- rb_objspace_each_objects(remove_coverage_i, NULL);
-}
-
/* define wrapper class methods (RubyVM::InstructionSequence) */
static void
@@ -1123,7 +802,7 @@ iseqw_mark(void *ptr)
static size_t
iseqw_memsize(const void *ptr)
{
- return rb_iseq_memsize((const rb_iseq_t *)ptr);
+ return iseq_memsize((const rb_iseq_t *)ptr);
}
static const rb_data_type_t iseqw_data_type = {
@@ -1135,22 +814,14 @@ static const rb_data_type_t iseqw_data_type = {
static VALUE
iseqw_new(const rb_iseq_t *iseq)
{
- if (iseq->wrapper) {
- return iseq->wrapper;
- }
- else {
- union { const rb_iseq_t *in; void *out; } deconst;
- VALUE obj;
- deconst.in = iseq;
- obj = TypedData_Wrap_Struct(rb_cISeq, &iseqw_data_type, deconst.out);
- RB_OBJ_WRITTEN(obj, Qundef, iseq);
+ union { const rb_iseq_t *in; void *out; } deconst;
+ VALUE obj;
- /* cache a wrapper object */
- RB_OBJ_WRITE((VALUE)iseq, &iseq->wrapper, obj);
- RB_OBJ_FREEZE((VALUE)iseq);
+ deconst.in = iseq;
+ obj = TypedData_Wrap_Struct(rb_cISeq, &iseqw_data_type, deconst.out);
+ RB_OBJ_WRITTEN(obj, Qundef, iseq);
- return obj;
- }
+ return obj;
}
VALUE
@@ -1167,14 +838,10 @@ rb_iseqw_new(const rb_iseq_t *iseq)
* Takes +source+, a String of Ruby code and compiles it to an
* InstructionSequence.
*
- * Optionally takes +file+, +path+, and +line+ which describe the file path,
- * real path and first line number of the ruby code in +source+ which are
+ * Optionally takes +file+, +path+, and +line+ which describe the filename,
+ * absolute path and first line number of the ruby code in +source+ which are
* metadata attached to the returned +iseq+.
*
- * +file+ is used for `__FILE__` and exception backtrace. +path+ is used for
- * +require_relative+ base. It is recommended these should be the same full
- * path.
- *
* +options+, which can be +true+, +false+ or a +Hash+, is used to
* modify the default behavior of the Ruby iseq compiler.
*
@@ -1183,14 +850,6 @@ rb_iseqw_new(const rb_iseq_t *iseq)
* RubyVM::InstructionSequence.compile("a = 1 + 2")
* #=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
*
- * path = "test.rb"
- * RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path))
- * #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1>
- *
- * path = File.expand_path("test.rb")
- * RubyVM::InstructionSequence.compile(File.read(path), path, path)
- * #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
- *
*/
static VALUE
iseqw_s_compile(int argc, VALUE *argv, VALUE self)
@@ -1198,6 +857,8 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil;
int i;
+ rb_secure(1);
+
i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5);
switch (i) {
@@ -1207,14 +868,14 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
case 2: file = argv[--i];
}
- if (NIL_P(file)) file = rb_fstring_lit("<compiled>");
+ if (NIL_P(file)) file = rb_fstring_cstr("<compiled>");
if (NIL_P(path)) path = file;
if (NIL_P(line)) line = INT2FIX(1);
Check_Type(path, T_STRING);
Check_Type(file, T_STRING);
- return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, opt));
+ return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, 0, opt));
}
/*
@@ -1246,6 +907,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
rb_compile_option_t option;
int i;
+ rb_secure(1);
i = rb_scan_args(argc, argv, "1*:", &file, NULL, &opt);
if (i > 1+NIL_P(opt)) rb_error_arity(argc, 1, 2);
switch (i) {
@@ -1259,17 +921,17 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
parser = rb_parser_new();
rb_parser_set_context(parser, NULL, FALSE);
ast = rb_parser_compile_file_path(parser, file, f, NUM2INT(line));
- if (!ast->body.root) exc = GET_EC()->errinfo;
+ if (!ast->root) exc = GET_EC()->errinfo;
rb_io_close(f);
- if (!ast->body.root) {
+ if (!ast->root) {
rb_ast_dispose(ast);
rb_exc_raise(exc);
}
make_compile_option(&option, opt);
- ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_lit("<main>"),
+ ret = iseqw_new(rb_iseq_new_with_opt(ast->root, rb_fstring_cstr("<main>"),
file,
rb_realpath_internal(Qnil, file, 1),
line, NULL, ISEQ_TYPE_TOP, &option));
@@ -1312,6 +974,7 @@ static VALUE
iseqw_s_compile_option_set(VALUE self, VALUE opt)
{
rb_compile_option_t option;
+ rb_secure(1);
make_compile_option(&option, opt);
COMPILE_OPTION_DEFAULT = option;
return opt;
@@ -1363,6 +1026,7 @@ rb_iseqw_to_iseq(VALUE iseqw)
static VALUE
iseqw_eval(VALUE self)
{
+ rb_secure(1);
return rb_iseq_eval(iseqw_check(self));
}
@@ -1374,16 +1038,15 @@ static VALUE
iseqw_inspect(VALUE self)
{
const rb_iseq_t *iseq = iseqw_check(self);
- const struct rb_iseq_constant_body *const body = iseq->body;
VALUE klass = rb_class_name(rb_obj_class(self));
- if (!body->location.label) {
+ if (!iseq->body->location.label) {
return rb_sprintf("#<%"PRIsVALUE": uninitialized>", klass);
}
else {
return rb_sprintf("<%"PRIsVALUE":%"PRIsVALUE"@%"PRIsVALUE":%d>",
klass,
- body->location.label, rb_iseq_path(iseq),
+ iseq->body->location.label, rb_iseq_path(iseq),
FIX2INT(rb_iseq_first_lineno(iseq)));
}
}
@@ -1571,7 +1234,7 @@ static VALUE iseq_data_to_ary(const rb_iseq_t *iseq);
* The type of the instruction sequence.
*
* Valid values are +:top+, +:method+, +:block+, +:class+, +:rescue+,
- * +:ensure+, +:eval+, +:main+, and +plain+.
+ * +:ensure+, +:eval+, +:main+, and +:defined_guard+.
*
* [locals]
* An array containing the names of all arguments and local variables as
@@ -1597,23 +1260,21 @@ static VALUE
iseqw_to_a(VALUE self)
{
const rb_iseq_t *iseq = iseqw_check(self);
+ rb_secure(1);
return iseq_data_to_ary(iseq);
}
-#if VM_INSN_INFO_TABLE_IMPL == 1 /* binary search */
static const struct iseq_insn_info_entry *
get_insn_info_binary_search(const rb_iseq_t *iseq, size_t pos)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
- size_t size = body->insns_info.size;
- const struct iseq_insn_info_entry *insns_info = body->insns_info.body;
- const unsigned int *positions = body->insns_info.positions;
+ size_t size = iseq->body->insns_info_size;
+ const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info;
const int debug = 0;
if (debug) {
printf("size: %"PRIuSIZE"\n", size);
printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n",
- (size_t)0, positions[0], insns_info[0].line_no, pos);
+ (size_t)0, insns_info[0].position, insns_info[0].line_no, pos);
}
if (size == 0) {
@@ -1626,10 +1287,10 @@ get_insn_info_binary_search(const rb_iseq_t *iseq, size_t pos)
size_t l = 1, r = size - 1;
while (l <= r) {
size_t m = l + (r - l) / 2;
- if (positions[m] == pos) {
+ if (insns_info[m].position == pos) {
return &insns_info[m];
}
- if (positions[m] < pos) {
+ if (insns_info[m].position < pos) {
l = m + 1;
}
else {
@@ -1639,77 +1300,25 @@ get_insn_info_binary_search(const rb_iseq_t *iseq, size_t pos)
if (l >= size) {
return &insns_info[size-1];
}
- if (positions[l] > pos) {
+ if (insns_info[l].position > pos) {
return &insns_info[l-1];
}
return &insns_info[l];
}
}
-static const struct iseq_insn_info_entry *
-get_insn_info(const rb_iseq_t *iseq, size_t pos)
-{
- return get_insn_info_binary_search(iseq, pos);
-}
-#endif
-
-#if VM_INSN_INFO_TABLE_IMPL == 2 /* succinct bitvector */
-static const struct iseq_insn_info_entry *
-get_insn_info_succinct_bitvector(const rb_iseq_t *iseq, size_t pos)
-{
- const struct rb_iseq_constant_body *const body = iseq->body;
- size_t size = body->insns_info.size;
- const struct iseq_insn_info_entry *insns_info = body->insns_info.body;
- const int debug = 0;
-
- if (debug) {
#if VM_CHECK_MODE > 0
- const unsigned int *positions = body->insns_info.positions;
- printf("size: %"PRIuSIZE"\n", size);
- printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n",
- (size_t)0, positions[0], insns_info[0].line_no, pos);
-#else
- printf("size: %"PRIuSIZE"\n", size);
- printf("insns_info[%"PRIuSIZE"]: line: %d, pos: %"PRIuSIZE"\n",
- (size_t)0, insns_info[0].line_no, pos);
-#endif
- }
-
- if (size == 0) {
- return NULL;
- }
- else if (size == 1) {
- return &insns_info[0];
- }
- else {
- int index;
- VM_ASSERT(body->insns_info.succ_index_table != NULL);
- index = succ_index_lookup(body->insns_info.succ_index_table, (int)pos);
- return &insns_info[index-1];
- }
-}
-
-static const struct iseq_insn_info_entry *
-get_insn_info(const rb_iseq_t *iseq, size_t pos)
-{
- return get_insn_info_succinct_bitvector(iseq, pos);
-}
-#endif
-
-#if VM_CHECK_MODE > 0 || VM_INSN_INFO_TABLE_IMPL == 0
static const struct iseq_insn_info_entry *
get_insn_info_linear_search(const rb_iseq_t *iseq, size_t pos)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
- size_t i = 0, size = body->insns_info.size;
- const struct iseq_insn_info_entry *insns_info = body->insns_info.body;
- const unsigned int *positions = body->insns_info.positions;
+ size_t i = 0, size = iseq->body->insns_info_size;
+ const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info.body;
const int debug = 0;
if (debug) {
printf("size: %"PRIuSIZE"\n", size);
printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n",
- i, positions[i], insns_info[i].line_no, pos);
+ i, insns_info[i].position, insns_info[i].line_no, pos);
}
if (size == 0) {
@@ -1721,37 +1330,26 @@ get_insn_info_linear_search(const rb_iseq_t *iseq, size_t pos)
else {
for (i=1; i<size; i++) {
if (debug) printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n",
- i, positions[i], insns_info[i].line_no, pos);
+ i, insns_info[i].position, insns_info[i].line_no, pos);
- if (positions[i] == pos) {
+ if (insns_info[i].position == pos) {
return &insns_info[i];
}
- if (positions[i] > pos) {
+ if (insns_info[i].position > pos) {
return &insns_info[i-1];
}
}
}
return &insns_info[i-1];
}
-#endif
-
-#if VM_INSN_INFO_TABLE_IMPL == 0 /* linear search */
-static const struct iseq_insn_info_entry *
-get_insn_info(const rb_iseq_t *iseq, size_t pos)
-{
- return get_insn_info_linear_search(iseq, pos);
-}
-#endif
-#if VM_CHECK_MODE > 0 && VM_INSN_INFO_TABLE_IMPL > 0
static void
-validate_get_insn_info(const rb_iseq_t *iseq)
+validate_get_insn_info(rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
size_t i;
- for (i = 0; i < body->iseq_size; i++) {
- if (get_insn_info_linear_search(iseq, i) != get_insn_info(iseq, i)) {
- rb_bug("validate_get_insn_info: get_insn_info_linear_search(iseq, %"PRIuSIZE") != get_insn_info(iseq, %"PRIuSIZE")", i, i);
+ for (i = 0; i < iseq->body->iseq_size; i++) {
+ if (get_insn_info_linear_search(iseq, i) != get_insn_info_binary_search(iseq, i)) {
+ rb_bug("validate_get_insn_info: get_insn_info_linear_search(iseq, %"PRIuSIZE") != get_insn_info_binary_search(iseq, %"PRIuSIZE")", i, i);
}
}
}
@@ -1760,7 +1358,7 @@ validate_get_insn_info(const rb_iseq_t *iseq)
unsigned int
rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos)
{
- const struct iseq_insn_info_entry *entry = get_insn_info(iseq, pos);
+ const struct iseq_insn_info_entry *entry = get_insn_info_binary_search(iseq, pos);
if (entry) {
return entry->line_no;
@@ -1770,10 +1368,10 @@ rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos)
}
}
-MJIT_FUNC_EXPORTED rb_event_flag_t
+rb_event_flag_t
rb_iseq_event_flags(const rb_iseq_t *iseq, size_t pos)
{
- const struct iseq_insn_info_entry *entry = get_insn_info(iseq, pos);
+ const struct iseq_insn_info_entry *entry = get_insn_info_binary_search(iseq, pos);
if (entry) {
return entry->events;
}
@@ -1782,44 +1380,31 @@ rb_iseq_event_flags(const rb_iseq_t *iseq, size_t pos)
}
}
-void
-rb_iseq_clear_event_flags(const rb_iseq_t *iseq, size_t pos, rb_event_flag_t reset)
+static VALUE
+id_to_name(ID id, VALUE default_value)
{
- struct iseq_insn_info_entry *entry = (struct iseq_insn_info_entry *)get_insn_info(iseq, pos);
- if (entry) {
- entry->events &= ~reset;
- if (!(entry->events & iseq->aux.exec.global_trace_events)) {
- void rb_iseq_trace_flag_cleared(const rb_iseq_t *iseq, size_t pos);
- rb_iseq_trace_flag_cleared(iseq, pos);
- }
+ VALUE str = rb_id2str(id);
+ if (!str) {
+ str = default_value;
+ }
+ else if (!rb_str_symname_p(str)) {
+ str = rb_str_inspect(str);
}
+ return str;
}
static VALUE
local_var_name(const rb_iseq_t *diseq, VALUE level, VALUE op)
{
VALUE i;
- VALUE name;
ID lid;
- int idx;
for (i = 0; i < level; i++) {
diseq = diseq->body->parent_iseq;
}
- idx = diseq->body->local_table_size - (int)op - 1;
- lid = diseq->body->local_table[idx];
- name = rb_id2str(lid);
- if (!name) {
- name = rb_str_new_cstr("?");
- }
- else if (!rb_str_symname_p(name)) {
- name = rb_str_inspect(name);
- }
- else {
- name = rb_str_dup(name);
- }
- rb_str_catf(name, "@%d", idx);
- return name;
+ lid = diseq->body->local_table[diseq->body->local_table_size +
+ VM_ENV_DATA_SIZE - 1 - op];
+ return id_to_name(lid, INT2FIX('*'));
}
int rb_insn_unified_local_var_level(VALUE);
@@ -1839,40 +1424,30 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
break;
case TS_NUM: /* ULONG */
- if (insn == BIN(defined) && op_no == 0) {
- enum defined_type deftype = (enum defined_type)op;
- switch (deftype) {
- case DEFINED_FUNC:
- ret = rb_fstring_lit("func");
- break;
- case DEFINED_REF:
- ret = rb_fstring_lit("ref");
- break;
- case DEFINED_CONST_FROM:
- ret = rb_fstring_lit("constant-from");
- break;
- default:
- ret = rb_iseq_defined_string(deftype);
- break;
+ {
+ const char *type_str;
+ if (insn == BIN(branchiftype) && (type_str = rb_type_str((enum ruby_value_type)op)) != NULL) {
+ ret = rb_str_new_cstr(type_str);
}
- if (ret) break;
- }
- else if (insn == BIN(checktype) && op_no == 0) {
- const char *type_str = rb_type_str((enum ruby_value_type)op);
- if (type_str) {
- ret = rb_str_new_cstr(type_str); break;
+ else if (insn == BIN(defined) && op_no == 0 &&
+ ((enum defined_type)op == DEFINED_FUNC ? (ret = rb_fstring_cstr("func"), 1) :
+ (enum defined_type)op == DEFINED_REF ? (ret = rb_fstring_cstr("ref"), 1) :
+ (ret = rb_iseq_defined_string((enum defined_type)op)) != 0)) {
+ /* ok */
+ }
+ else {
+ ret = rb_sprintf("%"PRIuVALUE, op);
}
}
- ret = rb_sprintf("%"PRIuVALUE, op);
break;
case TS_LINDEX:{
int level;
if (types[op_no+1] == TS_NUM && pnop) {
- ret = local_var_name(iseq, *pnop, op - VM_ENV_DATA_SIZE);
+ ret = local_var_name(iseq, *pnop, op);
}
else if ((level = rb_insn_unified_local_var_level(insn)) >= 0) {
- ret = local_var_name(iseq, (VALUE)level, op - VM_ENV_DATA_SIZE);
+ ret = local_var_name(iseq, (VALUE)level, op);
}
else {
ret = rb_inspect(INT2FIX(op));
@@ -1928,15 +1503,12 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
break;
case TS_IC:
- case TS_IVC:
- case TS_ISE:
ret = rb_sprintf("<is:%"PRIdPTRDIFF">", (union iseq_inline_storage_entry *)op - iseq->body->is_entries);
break;
- case TS_CALLDATA:
+ case TS_CALLINFO:
{
- struct rb_call_data *cd = (struct rb_call_data *)op;
- struct rb_call_info *ci = &cd->ci;
+ struct rb_call_info *ci = (struct rb_call_info *)op;
VALUE ary = rb_ary_new();
if (ci->mid) {
@@ -1956,21 +1528,24 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
# define CALL_FLAG(n) if (ci->flag & VM_CALL_##n) rb_ary_push(flags, rb_str_new2(#n))
CALL_FLAG(ARGS_SPLAT);
CALL_FLAG(ARGS_BLOCKARG);
+ CALL_FLAG(ARGS_BLOCKARG_BLOCKPARAM);
CALL_FLAG(FCALL);
CALL_FLAG(VCALL);
CALL_FLAG(ARGS_SIMPLE);
CALL_FLAG(BLOCKISEQ);
CALL_FLAG(TAILCALL);
CALL_FLAG(SUPER);
- CALL_FLAG(ZSUPER);
CALL_FLAG(KWARG);
CALL_FLAG(KW_SPLAT);
CALL_FLAG(OPT_SEND); /* maybe not reachable */
rb_ary_push(ary, rb_ary_join(flags, rb_str_new2("|")));
}
+ ret = rb_sprintf("<callinfo!%"PRIsVALUE">", rb_ary_join(ary, rb_str_new2(", ")));
+ }
+ break;
- ret = rb_sprintf("<calldata!%"PRIsVALUE">", rb_ary_join(ary, rb_str_new2(", ")));
- }
+ case TS_CALLCACHE:
+ ret = rb_str_new2("<callcache>");
break;
case TS_CDHASH:
@@ -1990,29 +1565,12 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
}
break;
- case TS_BUILTIN:
- {
- const struct rb_builtin_function *bf = (const struct rb_builtin_function *)op;
- ret = rb_sprintf("<builtin!%s/%d>",
- bf->name, bf->argc);
- }
- break;
-
default:
- rb_bug("unknown operand type: %c", type);
+ rb_bug("insn_operand_intern: unknown operand type: %c", type);
}
return ret;
}
-static VALUE
-right_strip(VALUE str)
-{
- const char *beg = RSTRING_PTR(str), *end = RSTRING_END(str);
- while (end-- > beg && *end == ' ');
- rb_str_set_len(str, end - beg + 1);
- return str;
-}
-
/**
* Disassemble a instruction
* Iseq -> Iseq inspect object
@@ -2030,11 +1588,10 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
insn_name_buff = insn_name(insn);
if (1) {
- extern const int rb_vm_max_insn_name_size;
- rb_str_catf(str, "%04"PRIuSIZE" %-*s ", pos, rb_vm_max_insn_name_size, insn_name_buff);
+ rb_str_catf(str, "%04"PRIuSIZE" %-16s ", pos, insn_name_buff);
}
else {
- rb_str_catf(str, "%04"PRIuSIZE" %-28.*s ", pos,
+ rb_str_catf(str, "%04"PRIuSIZE" %-16.*s ", pos,
(int)strcspn(insn_name_buff, "_"), insn_name_buff);
}
@@ -2062,7 +1619,7 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
{
rb_event_flag_t events = rb_iseq_event_flags(iseq, pos);
if (events) {
- str = rb_str_catf(str, "[%s%s%s%s%s%s%s%s%s%s%s]",
+ str = rb_str_catf(str, "[%s%s%s%s%s%s%s%s%s]",
events & RUBY_EVENT_LINE ? "Li" : "",
events & RUBY_EVENT_CLASS ? "Cl" : "",
events & RUBY_EVENT_END ? "En" : "",
@@ -2071,19 +1628,16 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
events & RUBY_EVENT_C_CALL ? "Cc" : "",
events & RUBY_EVENT_C_RETURN ? "Cr" : "",
events & RUBY_EVENT_B_CALL ? "Bc" : "",
- events & RUBY_EVENT_B_RETURN ? "Br" : "",
- events & RUBY_EVENT_COVERAGE_LINE ? "Cli" : "",
- events & RUBY_EVENT_COVERAGE_BRANCH ? "Cbr" : "");
+ events & RUBY_EVENT_B_RETURN ? "Br" : "");
}
}
- right_strip(str);
if (ret) {
rb_str_cat2(str, "\n");
rb_str_concat(ret, str);
}
else {
- printf("%.*s\n", (int)RSTRING_LEN(str), RSTRING_PTR(str));
+ printf("%s\n", RSTRING_PTR(str));
}
return len;
}
@@ -2105,7 +1659,7 @@ catch_type(int type)
case CATCH_TYPE_NEXT:
return "next";
default:
- rb_bug("unknown catch type: %d", type);
+ rb_bug("unknown catch type (%d)", type);
return 0;
}
}
@@ -2113,171 +1667,176 @@ catch_type(int type)
static VALUE
iseq_inspect(const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
- if (!body->location.label) {
+ if (!iseq->body->location.label) {
return rb_sprintf("#<ISeq: uninitialized>");
}
else {
- const rb_code_location_t *loc = &body->location.code_location;
- return rb_sprintf("#<ISeq:%"PRIsVALUE"@%"PRIsVALUE":%d (%d,%d)-(%d,%d)>",
- body->location.label, rb_iseq_path(iseq),
- loc->beg_pos.lineno,
- loc->beg_pos.lineno,
- loc->beg_pos.column,
- loc->end_pos.lineno,
- loc->end_pos.column);
+ return rb_sprintf("#<ISeq:%s@%s:%d (%d,%d)-(%d,%d)>",
+ RSTRING_PTR(iseq->body->location.label), RSTRING_PTR(rb_iseq_path(iseq)),
+ iseq->body->location.code_range.first_loc.lineno,
+ iseq->body->location.code_range.first_loc.lineno,
+ iseq->body->location.code_range.first_loc.column,
+ iseq->body->location.code_range.last_loc.lineno,
+ iseq->body->location.code_range.last_loc.column);
}
}
-static const rb_data_type_t tmp_set = {
- "tmpset",
- {(void (*)(void *))rb_mark_set, (void (*)(void *))st_free_table, 0, 0,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static VALUE
-rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent)
+VALUE
+rb_iseq_disasm(const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
VALUE *code;
VALUE str = rb_str_new(0, 0);
VALUE child = rb_ary_tmp_new(3);
unsigned int size;
unsigned int i;
long l;
+ const ID *tbl;
size_t n;
enum {header_minlen = 72};
st_table *done_iseq = 0;
- VALUE done_iseq_wrapper = Qnil;
- const char *indent_str;
- long indent_len;
- size = body->iseq_size;
+ rb_secure(1);
- indent_len = RSTRING_LEN(indent);
- indent_str = RSTRING_PTR(indent);
+ size = iseq->body->iseq_size;
- rb_str_cat(str, indent_str, indent_len);
rb_str_cat2(str, "== disasm: ");
- rb_str_append(str, iseq_inspect(iseq));
- rb_str_catf(str, " (catch: %s)", body->catch_except_p ? "TRUE" : "FALSE");
- if ((l = RSTRING_LEN(str) - indent_len) < header_minlen) {
- rb_str_modify_expand(str, header_minlen - l);
- memset(RSTRING_END(str), '=', header_minlen - l);
+ rb_str_concat(str, iseq_inspect(iseq));
+ if ((l = RSTRING_LEN(str)) < header_minlen) {
+ rb_str_resize(str, header_minlen);
+ memset(RSTRING_PTR(str) + l, '=', header_minlen - l);
}
rb_str_cat2(str, "\n");
/* show catch table information */
- if (body->catch_table) {
- rb_str_cat(str, indent_str, indent_len);
+ if (iseq->body->catch_table) {
rb_str_cat2(str, "== catch table\n");
}
- if (body->catch_table) {
- rb_str_cat_cstr(indent, "| ");
- indent_str = RSTRING_PTR(indent);
- for (i = 0; i < body->catch_table->size; i++) {
- const struct iseq_catch_table_entry *entry =
- UNALIGNED_MEMBER_PTR(body->catch_table, entries[i]);
- rb_str_cat(str, indent_str, indent_len);
+ if (iseq->body->catch_table) {
+ for (i = 0; i < iseq->body->catch_table->size; i++) {
+ const struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
rb_str_catf(str,
"| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n",
catch_type((int)entry->type), (int)entry->start,
(int)entry->end, (int)entry->sp, (int)entry->cont);
if (entry->iseq && !(done_iseq && st_is_member(done_iseq, (st_data_t)entry->iseq))) {
- rb_str_concat(str, rb_iseq_disasm_recursive(rb_iseq_check(entry->iseq), indent));
- if (!done_iseq) {
- done_iseq = st_init_numtable();
- done_iseq_wrapper = TypedData_Wrap_Struct(0, &tmp_set, done_iseq);
- }
+ rb_str_concat(str, rb_iseq_disasm(rb_iseq_check(entry->iseq)));
+ if (!done_iseq) done_iseq = st_init_numtable();
st_insert(done_iseq, (st_data_t)entry->iseq, (st_data_t)0);
- indent_str = RSTRING_PTR(indent);
}
}
- rb_str_resize(indent, indent_len);
- indent_str = RSTRING_PTR(indent);
}
- if (body->catch_table) {
- rb_str_cat(str, indent_str, indent_len);
+ if (iseq->body->catch_table) {
rb_str_cat2(str, "|-------------------------------------"
"-----------------------------------\n");
}
/* show local table information */
- if (body->local_table) {
- const struct rb_iseq_param_keyword *const keyword = body->param.keyword;
- rb_str_cat(str, indent_str, indent_len);
+ tbl = iseq->body->local_table;
+
+ if (tbl) {
rb_str_catf(str,
"local table (size: %d, argc: %d "
"[opts: %d, rest: %d, post: %d, block: %d, kw: %d@%d, kwrest: %d])\n",
- body->local_table_size,
- body->param.lead_num,
- body->param.opt_num,
- body->param.flags.has_rest ? body->param.rest_start : -1,
- body->param.post_num,
- body->param.flags.has_block ? body->param.block_start : -1,
- body->param.flags.has_kw ? keyword->num : -1,
- body->param.flags.has_kw ? keyword->required_num : -1,
- body->param.flags.has_kwrest ? keyword->rest_start : -1);
-
- for (i = body->local_table_size; i > 0;) {
- int li = body->local_table_size - --i - 1;
+ iseq->body->local_table_size,
+ iseq->body->param.lead_num,
+ iseq->body->param.opt_num,
+ iseq->body->param.flags.has_rest ? iseq->body->param.rest_start : -1,
+ iseq->body->param.post_num,
+ iseq->body->param.flags.has_block ? iseq->body->param.block_start : -1,
+ iseq->body->param.flags.has_kw ? iseq->body->param.keyword->num : -1,
+ iseq->body->param.flags.has_kw ? iseq->body->param.keyword->required_num : -1,
+ iseq->body->param.flags.has_kwrest ? iseq->body->param.keyword->rest_start : -1);
+
+ for (i = 0; i < iseq->body->local_table_size; i++) {
+ int li = (int)i;
long width;
- VALUE name = local_var_name(iseq, 0, i);
- char argi[0x100];
- char opti[0x100];
-
- opti[0] = '\0';
- if (body->param.flags.has_opt) {
- int argc = body->param.lead_num;
- int opts = body->param.opt_num;
+ VALUE name = id_to_name(tbl[i], 0);
+ char argi[0x100] = "";
+ char opti[0x100] = "";
+
+ if (iseq->body->param.flags.has_opt) {
+ int argc = iseq->body->param.lead_num;
+ int opts = iseq->body->param.opt_num;
if (li >= argc && li < argc + opts) {
snprintf(opti, sizeof(opti), "Opt=%"PRIdVALUE,
- body->param.opt_table[li - argc]);
+ iseq->body->param.opt_table[li - argc]);
}
}
- snprintf(argi, sizeof(argi), "%s%s%s%s%s%s", /* arg, opts, rest, post, kwrest, block */
- body->param.lead_num > li ? "Arg" : "",
+ snprintf(argi, sizeof(argi), "%s%s%s%s%s", /* arg, opts, rest, post block */
+ iseq->body->param.lead_num > li ? "Arg" : "",
opti,
- (body->param.flags.has_rest && body->param.rest_start == li) ? "Rest" : "",
- (body->param.flags.has_post && body->param.post_start <= li && li < body->param.post_start + body->param.post_num) ? "Post" : "",
- (body->param.flags.has_kwrest && keyword->rest_start == li) ? "Kwrest" : "",
- (body->param.flags.has_block && body->param.block_start == li) ? "Block" : "");
+ (iseq->body->param.flags.has_rest && iseq->body->param.rest_start == li) ? "Rest" : "",
+ (iseq->body->param.flags.has_post && iseq->body->param.post_start <= li && li < iseq->body->param.post_start + iseq->body->param.post_num) ? "Post" : "",
+ (iseq->body->param.flags.has_block && iseq->body->param.block_start == li) ? "Block" : "");
- rb_str_cat(str, indent_str, indent_len);
- rb_str_catf(str, "[%2d] ", i + 1);
+ rb_str_catf(str, "[%2d] ", iseq->body->local_table_size - i);
width = RSTRING_LEN(str) + 11;
- rb_str_append(str, name);
+ if (name)
+ rb_str_append(str, name);
+ else
+ rb_str_cat2(str, "?");
if (*argi) rb_str_catf(str, "<%s>", argi);
if ((width -= RSTRING_LEN(str)) > 0) rb_str_catf(str, "%*s", (int)width, "");
}
- rb_str_cat_cstr(right_strip(str), "\n");
+ rb_str_cat2(str, "\n");
}
/* show each line */
code = rb_iseq_original_iseq(iseq);
for (n = 0; n < size;) {
- rb_str_cat(str, indent_str, indent_len);
n += rb_iseq_disasm_insn(str, code, n, iseq, child);
}
for (l = 0; l < RARRAY_LEN(child); l++) {
VALUE isv = rb_ary_entry(child, l);
if (done_iseq && st_is_member(done_iseq, (st_data_t)isv)) continue;
- rb_str_cat_cstr(str, "\n");
- rb_str_concat(str, rb_iseq_disasm_recursive(rb_iseq_check((rb_iseq_t *)isv), indent));
- indent_str = RSTRING_PTR(indent);
+ rb_str_concat(str, rb_iseq_disasm(rb_iseq_check((rb_iseq_t *)isv)));
}
- RB_GC_GUARD(done_iseq_wrapper);
+ if (done_iseq) st_free_table(done_iseq);
return str;
}
-VALUE
-rb_iseq_disasm(const rb_iseq_t *iseq)
+static VALUE
+rb_iseq_all_children(const rb_iseq_t *iseq)
{
- return rb_iseq_disasm_recursive(iseq, rb_str_new(0, 0));
+ unsigned int i;
+ VALUE *code = rb_iseq_original_iseq(iseq);
+ VALUE all_children = rb_obj_hide(rb_ident_hash_new());
+ VALUE child;
+
+ if (iseq->body->catch_table) {
+ for (i = 0; i < iseq->body->catch_table->size; i++) {
+ const struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
+ child = (VALUE)entry->iseq;
+ if (child) {
+ rb_hash_aset(all_children, child, Qtrue);
+ }
+ }
+ }
+ for (i=0; i<iseq->body->iseq_size;) {
+ VALUE insn = code[i];
+ int len = insn_len(insn);
+ const char *types = insn_op_types(insn);
+ int j;
+
+ for (j=0; types[j]; j++) {
+ switch (types[j]) {
+ case TS_ISEQ:
+ child = code[i+j+1];
+ if (child) {
+ rb_hash_aset(all_children, child, Qtrue);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ i += len;
+ }
+ return all_children;
}
/*
@@ -2305,59 +1864,10 @@ iseqw_disasm(VALUE self)
}
static int
-iseq_iterate_children(const rb_iseq_t *iseq, void (*iter_func)(const rb_iseq_t *child_iseq, void *data), void *data)
-{
- unsigned int i;
- VALUE *code = rb_iseq_original_iseq(iseq);
- const struct rb_iseq_constant_body *const body = iseq->body;
- const rb_iseq_t *child;
- VALUE all_children = rb_obj_hide(rb_ident_hash_new());
-
- if (body->catch_table) {
- for (i = 0; i < body->catch_table->size; i++) {
- const struct iseq_catch_table_entry *entry =
- UNALIGNED_MEMBER_PTR(body->catch_table, entries[i]);
- child = entry->iseq;
- if (child) {
- if (rb_hash_aref(all_children, (VALUE)child) == Qnil) {
- rb_hash_aset(all_children, (VALUE)child, Qtrue);
- (*iter_func)(child, data);
- }
- }
- }
- }
-
- for (i=0; i<body->iseq_size;) {
- VALUE insn = code[i];
- int len = insn_len(insn);
- const char *types = insn_op_types(insn);
- int j;
-
- for (j=0; types[j]; j++) {
- switch (types[j]) {
- case TS_ISEQ:
- child = (const rb_iseq_t *)code[i+j+1];
- if (child) {
- if (rb_hash_aref(all_children, (VALUE)child) == Qnil) {
- rb_hash_aset(all_children, (VALUE)child, Qtrue);
- (*iter_func)(child, data);
- }
- }
- break;
- default:
- break;
- }
- }
- i += len;
- }
-
- return (int)RHASH_SIZE(all_children);
-}
-
-static void
-yield_each_children(const rb_iseq_t *child_iseq, void *data)
+iseqw_each_child_i(VALUE key, VALUE value, VALUE dummy)
{
- rb_yield(iseqw_new(child_iseq));
+ rb_yield(iseqw_new((const rb_iseq_t *)key));
+ return ST_CONTINUE;
}
/*
@@ -2372,7 +1882,8 @@ static VALUE
iseqw_each_child(VALUE self)
{
const rb_iseq_t *iseq = iseqw_check(self);
- iseq_iterate_children(iseq, yield_each_children, NULL);
+ VALUE all_children = rb_iseq_all_children(iseq);
+ rb_hash_foreach(all_children, iseqw_each_child_i, Qnil);
return self;
}
@@ -2401,12 +1912,11 @@ static VALUE
iseqw_trace_points(VALUE self)
{
const rb_iseq_t *iseq = iseqw_check(self);
- const struct rb_iseq_constant_body *const body = iseq->body;
unsigned int i;
VALUE ary = rb_ary_new();
- for (i=0; i<body->insns_info.size; i++) {
- const struct iseq_insn_info_entry *entry = &body->insns_info.body[i];
+ for (i=0; i<iseq->body->insns_info_size; i++) {
+ const struct iseq_insn_info_entry *entry = &iseq->body->insns_info[i];
if (entry->events) {
push_event_info(iseq, entry->events, entry->line_no, ary);
}
@@ -2454,18 +1964,17 @@ iseqw_s_of(VALUE klass, VALUE body)
{
const rb_iseq_t *iseq = NULL;
+ rb_secure(1);
+
if (rb_obj_is_proc(body)) {
- iseq = vm_proc_iseq(body);
+ iseq = vm_proc_iseq(body);
- if (!rb_obj_is_iseq((VALUE)iseq)) {
- iseq = NULL;
- }
- }
- else if (rb_obj_is_method(body)) {
- iseq = rb_method_iseq(body);
+ if (!rb_obj_is_iseq((VALUE)iseq)) {
+ iseq = NULL;
+ }
}
- else if (rb_typeddata_is_instance_of(body, &iseqw_data_type)) {
- return body;
+ else {
+ iseq = rb_method_iseq(body);
}
return iseq ? iseqw_new(iseq) : Qnil;
@@ -2536,16 +2045,16 @@ ruby_node_name(int node)
switch (node) {
#include "node_name.inc"
default:
- rb_bug("unknown node: %d", node);
+ rb_bug("unknown node (%d)", node);
return 0;
}
}
#define DECL_SYMBOL(name) \
- static ID sym_##name
+ static VALUE sym_##name
#define INIT_SYMBOL(name) \
- sym_##name = rb_intern(#name)
+ sym_##name = ID2SYM(rb_intern(#name))
static VALUE
register_label(struct st_table *table, unsigned long idx)
@@ -2567,7 +2076,7 @@ exception_type2symbol(VALUE type)
case CATCH_TYPE_REDO: CONST_ID(id, "redo"); break;
case CATCH_TYPE_NEXT: CONST_ID(id, "next"); break;
default:
- rb_bug("unknown exception type: %d", (int)type);
+ rb_bug("exception_type2symbol: unknown type %d", (int)type);
}
return ID2SYM(id);
}
@@ -2580,25 +2089,18 @@ cdhash_each(VALUE key, VALUE value, VALUE ary)
return ST_CONTINUE;
}
-static const rb_data_type_t label_wrapper = {
- "label_wrapper",
- {(void (*)(void *))rb_mark_tbl, (void (*)(void *))st_free_table, 0, 0,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
static VALUE
iseq_data_to_ary(const rb_iseq_t *iseq)
{
unsigned int i;
long l;
- const struct rb_iseq_constant_body *const iseq_body = iseq->body;
- const struct iseq_insn_info_entry *prev_insn_info;
+ size_t ti;
unsigned int pos;
int last_line = 0;
VALUE *seq, *iseq_original;
VALUE val = rb_ary_new();
- ID type; /* Symbol */
+ VALUE type; /* Symbol */
VALUE locals = rb_ary_new();
VALUE params = rb_hash_new();
VALUE body = rb_ary_new(); /* [[:insn1, ...], ...] */
@@ -2606,9 +2108,8 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
VALUE exception = rb_ary_new(); /* [[....]] */
VALUE misc = rb_hash_new();
- static ID insn_syms[VM_INSTRUCTION_SIZE/2]; /* w/o-trace only */
+ static VALUE insn_syms[VM_INSTRUCTION_SIZE];
struct st_table *labels_table = st_init_numtable();
- VALUE labels_wrapper = TypedData_Wrap_Struct(0, &label_wrapper, labels_table);
DECL_SYMBOL(top);
DECL_SYMBOL(method);
@@ -2618,12 +2119,12 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
DECL_SYMBOL(ensure);
DECL_SYMBOL(eval);
DECL_SYMBOL(main);
- DECL_SYMBOL(plain);
+ DECL_SYMBOL(defined_guard);
if (sym_top == 0) {
int i;
- for (i=0; i<numberof(insn_syms); i++) {
- insn_syms[i] = rb_intern(insn_name(i));
+ for (i=0; i<VM_INSTRUCTION_SIZE; i++) {
+ insn_syms[i] = ID2SYM(rb_intern(insn_name(i)));
}
INIT_SYMBOL(top);
INIT_SYMBOL(method);
@@ -2633,11 +2134,11 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
INIT_SYMBOL(ensure);
INIT_SYMBOL(eval);
INIT_SYMBOL(main);
- INIT_SYMBOL(plain);
+ INIT_SYMBOL(defined_guard);
}
/* type */
- switch (iseq_body->type) {
+ switch (iseq->body->type) {
case ISEQ_TYPE_TOP: type = sym_top; break;
case ISEQ_TYPE_METHOD: type = sym_method; break;
case ISEQ_TYPE_BLOCK: type = sym_block; break;
@@ -2646,19 +2147,19 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
case ISEQ_TYPE_ENSURE: type = sym_ensure; break;
case ISEQ_TYPE_EVAL: type = sym_eval; break;
case ISEQ_TYPE_MAIN: type = sym_main; break;
- case ISEQ_TYPE_PLAIN: type = sym_plain; break;
- default: rb_bug("unsupported iseq type: %d", (int)iseq_body->type);
+ case ISEQ_TYPE_DEFINED_GUARD: type = sym_defined_guard; break;
+ default: rb_bug("unsupported iseq type");
};
/* locals */
- for (i=0; i<iseq_body->local_table_size; i++) {
- ID lid = iseq_body->local_table[i];
+ for (i=0; i<iseq->body->local_table_size; i++) {
+ ID lid = iseq->body->local_table[i];
if (lid) {
if (rb_id2str(lid)) {
rb_ary_push(locals, ID2SYM(lid));
}
else { /* hidden variable from id_internal() */
- rb_ary_push(locals, ULONG2NUM(iseq_body->local_table_size-i+1));
+ rb_ary_push(locals, ULONG2NUM(iseq->body->local_table_size-i+1));
}
}
else {
@@ -2668,58 +2169,57 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
/* params */
{
- const struct rb_iseq_param_keyword *const keyword = iseq_body->param.keyword;
int j;
- if (iseq_body->param.flags.has_opt) {
- int len = iseq_body->param.opt_num + 1;
- VALUE arg_opt_labels = rb_ary_new2(len);
+ if (iseq->body->param.flags.has_opt) {
+ int len = iseq->body->param.opt_num + 1;
+ VALUE arg_opt_labels = rb_ary_new2(len);
- for (j = 0; j < len; j++) {
- VALUE l = register_label(labels_table, iseq_body->param.opt_table[j]);
- rb_ary_push(arg_opt_labels, l);
- }
- rb_hash_aset(params, ID2SYM(rb_intern("opt")), arg_opt_labels);
+ for (j = 0; j < len; j++) {
+ VALUE l = register_label(labels_table, iseq->body->param.opt_table[j]);
+ rb_ary_push(arg_opt_labels, l);
+ }
+ rb_hash_aset(params, ID2SYM(rb_intern("opt")), arg_opt_labels);
}
/* commit */
- if (iseq_body->param.flags.has_lead) rb_hash_aset(params, ID2SYM(rb_intern("lead_num")), INT2FIX(iseq_body->param.lead_num));
- if (iseq_body->param.flags.has_post) rb_hash_aset(params, ID2SYM(rb_intern("post_num")), INT2FIX(iseq_body->param.post_num));
- if (iseq_body->param.flags.has_post) rb_hash_aset(params, ID2SYM(rb_intern("post_start")), INT2FIX(iseq_body->param.post_start));
- if (iseq_body->param.flags.has_rest) rb_hash_aset(params, ID2SYM(rb_intern("rest_start")), INT2FIX(iseq_body->param.rest_start));
- if (iseq_body->param.flags.has_block) rb_hash_aset(params, ID2SYM(rb_intern("block_start")), INT2FIX(iseq_body->param.block_start));
- if (iseq_body->param.flags.has_kw) {
+ if (iseq->body->param.flags.has_lead) rb_hash_aset(params, ID2SYM(rb_intern("lead_num")), INT2FIX(iseq->body->param.lead_num));
+ if (iseq->body->param.flags.has_post) rb_hash_aset(params, ID2SYM(rb_intern("post_num")), INT2FIX(iseq->body->param.post_num));
+ if (iseq->body->param.flags.has_post) rb_hash_aset(params, ID2SYM(rb_intern("post_start")), INT2FIX(iseq->body->param.post_start));
+ if (iseq->body->param.flags.has_rest) rb_hash_aset(params, ID2SYM(rb_intern("rest_start")), INT2FIX(iseq->body->param.rest_start));
+ if (iseq->body->param.flags.has_block) rb_hash_aset(params, ID2SYM(rb_intern("block_start")), INT2FIX(iseq->body->param.block_start));
+ if (iseq->body->param.flags.has_kw) {
VALUE keywords = rb_ary_new();
int i, j;
- for (i=0; i<keyword->required_num; i++) {
- rb_ary_push(keywords, ID2SYM(keyword->table[i]));
+ for (i=0; i<iseq->body->param.keyword->required_num; i++) {
+ rb_ary_push(keywords, ID2SYM(iseq->body->param.keyword->table[i]));
}
- for (j=0; i<keyword->num; i++, j++) {
- VALUE key = rb_ary_new_from_args(1, ID2SYM(keyword->table[i]));
- if (keyword->default_values[j] != Qundef) {
- rb_ary_push(key, keyword->default_values[j]);
+ for (j=0; i<iseq->body->param.keyword->num; i++, j++) {
+ VALUE key = rb_ary_new_from_args(1, ID2SYM(iseq->body->param.keyword->table[i]));
+ if (iseq->body->param.keyword->default_values[j] != Qundef) {
+ rb_ary_push(key, iseq->body->param.keyword->default_values[j]);
}
rb_ary_push(keywords, key);
}
rb_hash_aset(params, ID2SYM(rb_intern("kwbits")),
- INT2FIX(keyword->bits_start));
+ INT2FIX(iseq->body->param.keyword->bits_start));
rb_hash_aset(params, ID2SYM(rb_intern("keyword")), keywords);
}
- if (iseq_body->param.flags.has_kwrest) rb_hash_aset(params, ID2SYM(rb_intern("kwrest")), INT2FIX(keyword->rest_start));
- if (iseq_body->param.flags.ambiguous_param0) rb_hash_aset(params, ID2SYM(rb_intern("ambiguous_param0")), Qtrue);
+ if (iseq->body->param.flags.has_kwrest) rb_hash_aset(params, ID2SYM(rb_intern("kwrest")), INT2FIX(iseq->body->param.keyword->rest_start));
+ if (iseq->body->param.flags.ambiguous_param0) rb_hash_aset(params, ID2SYM(rb_intern("ambiguous_param0")), Qtrue);
}
/* body */
iseq_original = rb_iseq_original_iseq((rb_iseq_t *)iseq);
- for (seq = iseq_original; seq < iseq_original + iseq_body->iseq_size; ) {
+ for (seq = iseq_original; seq < iseq_original + iseq->body->iseq_size; ) {
VALUE insn = *seq++;
int j, len = insn_len(insn);
VALUE *nseq = seq + len - 1;
VALUE ary = rb_ary_new2(len);
- rb_ary_push(ary, ID2SYM(insn_syms[insn%numberof(insn_syms)]));
+ rb_ary_push(ary, insn_syms[insn]);
for (j=0; j<len-1; j++, seq++) {
switch (insn_op_type(insn, j)) {
case TS_OFFSET: {
@@ -2753,17 +2253,14 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
}
break;
case TS_IC:
- case TS_IVC:
- case TS_ISE:
{
union iseq_inline_storage_entry *is = (union iseq_inline_storage_entry *)*seq;
- rb_ary_push(ary, INT2FIX(is - iseq_body->is_entries));
+ rb_ary_push(ary, INT2FIX(is - iseq->body->is_entries));
}
break;
- case TS_CALLDATA:
+ case TS_CALLINFO:
{
- struct rb_call_data *cd = (struct rb_call_data *)*seq;
- struct rb_call_info *ci = &cd->ci;
+ struct rb_call_info *ci = (struct rb_call_info *)*seq;
VALUE e = rb_hash_new();
int orig_argc = ci->orig_argc;
@@ -2787,6 +2284,9 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_ary_push(ary, e);
}
break;
+ case TS_CALLCACHE:
+ rb_ary_push(ary, Qfalse);
+ break;
case TS_ID:
rb_ary_push(ary, ID2SYM(*seq));
break;
@@ -2818,21 +2318,6 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_ary_push(ary, val);
}
break;
- case TS_BUILTIN:
- {
- VALUE val = rb_hash_new();
-#if SIZEOF_VALUE <= SIZEOF_LONG
- VALUE func_ptr = LONG2NUM((SIGNED_VALUE)((RB_BUILTIN)*seq)->func_ptr);
-#else
- VALUE func_ptr = LL2NUM((SIGNED_VALUE)((RB_BUILTIN)*seq)->func_ptr);
-#endif
- rb_hash_aset(val, ID2SYM(rb_intern("func_ptr")), func_ptr);
- rb_hash_aset(val, ID2SYM(rb_intern("argc")), INT2NUM(((RB_BUILTIN)*seq)->argc));
- rb_hash_aset(val, ID2SYM(rb_intern("index")), INT2NUM(((RB_BUILTIN)*seq)->index));
- rb_hash_aset(val, ID2SYM(rb_intern("name")), rb_str_new_cstr(((RB_BUILTIN)*seq)->name));
- rb_ary_push(ary, val);
- }
- break;
default:
rb_bug("unknown operand: %c", insn_op_type(insn, j));
}
@@ -2843,10 +2328,9 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
nbody = body;
/* exception */
- if (iseq_body->catch_table) for (i=0; i<iseq_body->catch_table->size; i++) {
+ if (iseq->body->catch_table) for (i=0; i<iseq->body->catch_table->size; i++) {
VALUE ary = rb_ary_new();
- const struct iseq_catch_table_entry *entry =
- UNALIGNED_MEMBER_PTR(iseq_body->catch_table, entries[i]);
+ const struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
rb_ary_push(ary, exception_type2symbol(entry->type));
if (entry->iseq) {
rb_ary_push(ary, iseq_data_to_ary(rb_iseq_check(entry->iseq)));
@@ -2863,10 +2347,9 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
/* make body with labels and insert line number */
body = rb_ary_new();
- prev_insn_info = NULL;
+ ti = 0;
for (l=0, pos=0; l<RARRAY_LEN(nbody); l++) {
- const struct iseq_insn_info_entry *info;
VALUE ary = RARRAY_AREF(nbody, l);
st_data_t label;
@@ -2874,44 +2357,45 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_ary_push(body, (VALUE)label);
}
- info = get_insn_info(iseq, pos);
-
- if (prev_insn_info != info) {
- int line = info->line_no;
- rb_event_flag_t events = info->events;
+ if (ti < iseq->body->insns_info_size) {
+ const struct iseq_insn_info_entry *info = &iseq->body->insns_info[ti];
+ if (info->position == pos) {
+ int line = info->line_no;
+ rb_event_flag_t events = info->events;
- if (line > 0 && last_line != line) {
- rb_ary_push(body, INT2FIX(line));
- last_line = line;
- }
+ if (line > 0 && last_line != line) {
+ rb_ary_push(body, INT2FIX(line));
+ last_line = line;
+ }
#define CHECK_EVENT(ev) if (events & ev) rb_ary_push(body, ID2SYM(rb_intern(#ev)));
- CHECK_EVENT(RUBY_EVENT_LINE);
- CHECK_EVENT(RUBY_EVENT_CLASS);
- CHECK_EVENT(RUBY_EVENT_END);
- CHECK_EVENT(RUBY_EVENT_CALL);
- CHECK_EVENT(RUBY_EVENT_RETURN);
- CHECK_EVENT(RUBY_EVENT_B_CALL);
- CHECK_EVENT(RUBY_EVENT_B_RETURN);
+ CHECK_EVENT(RUBY_EVENT_LINE);
+ CHECK_EVENT(RUBY_EVENT_CLASS);
+ CHECK_EVENT(RUBY_EVENT_END);
+ CHECK_EVENT(RUBY_EVENT_CALL);
+ CHECK_EVENT(RUBY_EVENT_RETURN);
+ CHECK_EVENT(RUBY_EVENT_B_CALL);
+ CHECK_EVENT(RUBY_EVENT_B_RETURN);
#undef CHECK_EVENT
- prev_insn_info = info;
+ ti++;
+ }
}
rb_ary_push(body, ary);
pos += RARRAY_LENINT(ary); /* reject too huge data */
}
RB_GC_GUARD(nbody);
- RB_GC_GUARD(labels_wrapper);
- rb_hash_aset(misc, ID2SYM(rb_intern("arg_size")), INT2FIX(iseq_body->param.size));
- rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq_body->local_table_size));
- rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq_body->stack_max));
- rb_hash_aset(misc, ID2SYM(rb_intern("node_id")), INT2FIX(iseq_body->location.node_id));
- rb_hash_aset(misc, ID2SYM(rb_intern("code_location")),
+ st_free_table(labels_table);
+
+ rb_hash_aset(misc, ID2SYM(rb_intern("arg_size")), INT2FIX(iseq->body->param.size));
+ rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq->body->local_table_size));
+ rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq->body->stack_max));
+ rb_hash_aset(misc, ID2SYM(rb_intern("code_range")),
rb_ary_new_from_args(4,
- INT2FIX(iseq_body->location.code_location.beg_pos.lineno),
- INT2FIX(iseq_body->location.code_location.beg_pos.column),
- INT2FIX(iseq_body->location.code_location.end_pos.lineno),
- INT2FIX(iseq_body->location.code_location.end_pos.column)));
+ INT2FIX(iseq->body->location.code_range.first_loc.lineno),
+ INT2FIX(iseq->body->location.code_range.first_loc.column),
+ INT2FIX(iseq->body->location.code_range.last_loc.lineno),
+ INT2FIX(iseq->body->location.code_range.last_loc.column)));
/*
* [:magic, :major_version, :minor_version, :format_type, :misc,
@@ -2923,11 +2407,11 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_ary_push(val, INT2FIX(ISEQ_MINOR_VERSION)); /* minor */
rb_ary_push(val, INT2FIX(1));
rb_ary_push(val, misc);
- rb_ary_push(val, iseq_body->location.label);
+ rb_ary_push(val, iseq->body->location.label);
rb_ary_push(val, rb_iseq_path(iseq));
rb_ary_push(val, rb_iseq_realpath(iseq));
- rb_ary_push(val, iseq_body->location.first_lineno);
- rb_ary_push(val, ID2SYM(type));
+ rb_ary_push(val, iseq->body->location.first_lineno);
+ rb_ary_push(val, type);
rb_ary_push(val, locals);
rb_ary_push(val, params);
rb_ary_push(val, exception);
@@ -2939,12 +2423,10 @@ VALUE
rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
{
int i, r;
- const struct rb_iseq_constant_body *const body = iseq->body;
- const struct rb_iseq_param_keyword *const keyword = body->param.keyword;
- VALUE a, args = rb_ary_new2(body->param.size);
+ VALUE a, args = rb_ary_new2(iseq->body->param.size);
ID req, opt, rest, block, key, keyrest;
#define PARAM_TYPE(type) rb_ary_push(a = rb_ary_new2(2), ID2SYM(type))
-#define PARAM_ID(i) body->local_table[(i)]
+#define PARAM_ID(i) iseq->body->local_table[(i)]
#define PARAM(i, type) ( \
PARAM_TYPE(type), \
rb_id2str(PARAM_ID(i)) ? \
@@ -2954,18 +2436,18 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
CONST_ID(req, "req");
CONST_ID(opt, "opt");
if (is_proc) {
- for (i = 0; i < body->param.lead_num; i++) {
+ for (i = 0; i < iseq->body->param.lead_num; i++) {
PARAM_TYPE(opt);
rb_ary_push(a, rb_id2str(PARAM_ID(i)) ? ID2SYM(PARAM_ID(i)) : Qnil);
rb_ary_push(args, a);
}
}
else {
- for (i = 0; i < body->param.lead_num; i++) {
+ for (i = 0; i < iseq->body->param.lead_num; i++) {
rb_ary_push(args, PARAM(i, req));
}
}
- r = body->param.lead_num + body->param.opt_num;
+ r = iseq->body->param.lead_num + iseq->body->param.opt_num;
for (; i < r; i++) {
PARAM_TYPE(opt);
if (rb_id2str(PARAM_ID(i))) {
@@ -2973,58 +2455,52 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
}
rb_ary_push(args, a);
}
- if (body->param.flags.has_rest) {
+ if (iseq->body->param.flags.has_rest) {
CONST_ID(rest, "rest");
- rb_ary_push(args, PARAM(body->param.rest_start, rest));
+ rb_ary_push(args, PARAM(iseq->body->param.rest_start, rest));
}
- r = body->param.post_start + body->param.post_num;
+ r = iseq->body->param.post_start + iseq->body->param.post_num;
if (is_proc) {
- for (i = body->param.post_start; i < r; i++) {
+ for (i = iseq->body->param.post_start; i < r; i++) {
PARAM_TYPE(opt);
rb_ary_push(a, rb_id2str(PARAM_ID(i)) ? ID2SYM(PARAM_ID(i)) : Qnil);
rb_ary_push(args, a);
}
}
else {
- for (i = body->param.post_start; i < r; i++) {
+ for (i = iseq->body->param.post_start; i < r; i++) {
rb_ary_push(args, PARAM(i, req));
}
}
- if (body->param.flags.accepts_no_kwarg) {
- ID nokey;
- CONST_ID(nokey, "nokey");
- PARAM_TYPE(nokey);
- rb_ary_push(args, a);
- }
- if (body->param.flags.has_kw) {
+ if (iseq->body->param.flags.has_kw) {
i = 0;
- if (keyword->required_num > 0) {
+ if (iseq->body->param.keyword->required_num > 0) {
ID keyreq;
CONST_ID(keyreq, "keyreq");
- for (; i < keyword->required_num; i++) {
+ for (; i < iseq->body->param.keyword->required_num; i++) {
PARAM_TYPE(keyreq);
- if (rb_id2str(keyword->table[i])) {
- rb_ary_push(a, ID2SYM(keyword->table[i]));
+ if (rb_id2str(iseq->body->param.keyword->table[i])) {
+ rb_ary_push(a, ID2SYM(iseq->body->param.keyword->table[i]));
}
rb_ary_push(args, a);
}
}
CONST_ID(key, "key");
- for (; i < keyword->num; i++) {
+ for (; i < iseq->body->param.keyword->num; i++) {
PARAM_TYPE(key);
- if (rb_id2str(keyword->table[i])) {
- rb_ary_push(a, ID2SYM(keyword->table[i]));
+ if (rb_id2str(iseq->body->param.keyword->table[i])) {
+ rb_ary_push(a, ID2SYM(iseq->body->param.keyword->table[i]));
}
rb_ary_push(args, a);
}
}
- if (body->param.flags.has_kwrest) {
+ if (iseq->body->param.flags.has_kwrest) {
CONST_ID(keyrest, "keyrest");
- rb_ary_push(args, PARAM(keyword->rest_start, keyrest));
+ rb_ary_push(args, PARAM(iseq->body->param.keyword->rest_start, keyrest));
}
- if (body->param.flags.has_block) {
+ if (iseq->body->param.flags.has_block) {
CONST_ID(block, "block");
- rb_ary_push(args, PARAM(body->param.block_start, block));
+ rb_ary_push(args, PARAM(iseq->body->param.block_start, block));
}
return args;
}
@@ -3069,230 +2545,56 @@ rb_iseq_defined_string(enum defined_type type)
return str;
}
-/* A map from encoded_insn to insn_data: decoded insn number, its len,
- * non-trace version of encoded insn, and trace version. */
-
-static st_table *encoded_insn_data;
-typedef struct insn_data_struct {
- int insn;
- int insn_len;
- void *notrace_encoded_insn;
- void *trace_encoded_insn;
-} insn_data_t;
-static insn_data_t insn_data[VM_INSTRUCTION_SIZE/2];
-void
-rb_vm_encoded_insn_data_table_init(void)
-{
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
- const void * const *table = rb_vm_get_insns_address_table();
#define INSN_CODE(insn) ((VALUE)table[insn])
+#define TRACE_INSN_P(insn, insn_encoded) ((VALUE)table[insn] != insn_encoded)
#else
#define INSN_CODE(insn) (insn)
+#define TRACE_INSN_P(insn, insn_encoded) ((insn_encoded) >= VM_INSTRUCTION_SIZE/2)
#endif
- st_data_t insn;
- encoded_insn_data = st_init_numtable_with_size(VM_INSTRUCTION_SIZE / 2);
-
- for (insn = 0; insn < VM_INSTRUCTION_SIZE/2; insn++) {
- int traced_insn = (int)insn;
- if (traced_insn == BIN(opt_invokebuiltin_delegate_leave)) {
- traced_insn = BIN(opt_invokebuiltin_delegate); // to dispatch :return from leave
- }
- st_data_t key1 = (st_data_t)INSN_CODE(insn);
- st_data_t key2 = (st_data_t)INSN_CODE(traced_insn + VM_INSTRUCTION_SIZE/2);
-
- insn_data[insn].insn = (int)insn;
- insn_data[insn].insn_len = insn_len(insn);
- insn_data[insn].notrace_encoded_insn = (void *) key1;
- insn_data[insn].trace_encoded_insn = (void *) key2;
-
- st_add_direct(encoded_insn_data, key1, (st_data_t)&insn_data[insn]);
- st_add_direct(encoded_insn_data, key2, (st_data_t)&insn_data[insn]);
- }
-}
-
-int
-rb_vm_insn_addr2insn(const void *addr)
-{
- st_data_t key = (st_data_t)addr;
- st_data_t val;
-
- if (st_lookup(encoded_insn_data, key, &val)) {
- insn_data_t *e = (insn_data_t *)val;
- return (int)e->insn;
- }
-
- rb_bug("rb_vm_insn_addr2insn: invalid insn address: %p", addr);
-}
-
-static inline int
-encoded_iseq_trace_instrument(VALUE *iseq_encoded_insn, rb_event_flag_t turnon)
-{
- st_data_t key = (st_data_t)*iseq_encoded_insn;
- st_data_t val;
-
- if (st_lookup(encoded_insn_data, key, &val)) {
- insn_data_t *e = (insn_data_t *)val;
- *iseq_encoded_insn = (VALUE) (turnon ? e->trace_encoded_insn : e->notrace_encoded_insn);
- return e->insn_len;
- }
-
- rb_bug("trace_instrument: invalid insn address: %p", (void *)*iseq_encoded_insn);
-}
-
-void
-rb_iseq_trace_flag_cleared(const rb_iseq_t *iseq, size_t pos)
-{
- const struct rb_iseq_constant_body *const body = iseq->body;
- VALUE *iseq_encoded = (VALUE *)body->iseq_encoded;
- encoded_iseq_trace_instrument(&iseq_encoded[pos], 0);
-}
-
-static int
-iseq_add_local_tracepoint(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line)
-{
- unsigned int pc;
- int n = 0;
- const struct rb_iseq_constant_body *const body = iseq->body;
- VALUE *iseq_encoded = (VALUE *)body->iseq_encoded;
-
- VM_ASSERT(ISEQ_EXECUTABLE_P(iseq));
-
- for (pc=0; pc<body->iseq_size;) {
- const struct iseq_insn_info_entry *entry = get_insn_info(iseq, pc);
- rb_event_flag_t pc_events = entry->events;
- rb_event_flag_t target_events = turnon_events;
- unsigned int line = (int)entry->line_no;
-
- if (target_line == 0 || target_line == line) {
- /* ok */
- }
- else {
- target_events &= ~RUBY_EVENT_LINE;
- }
-
- if (pc_events & target_events) {
- n++;
- }
- pc += encoded_iseq_trace_instrument(&iseq_encoded[pc], pc_events & (target_events | iseq->aux.exec.global_trace_events));
- }
-
- if (n > 0) {
- if (iseq->aux.exec.local_hooks == NULL) {
- ((rb_iseq_t *)iseq)->aux.exec.local_hooks = RB_ZALLOC(rb_hook_list_t);
- }
- rb_hook_list_connect_tracepoint((VALUE)iseq, iseq->aux.exec.local_hooks, tpval, target_line);
- }
-
- return n;
-}
-
-struct trace_set_local_events_struct {
- rb_event_flag_t turnon_events;
- VALUE tpval;
- unsigned int target_line;
- int n;
-};
-
-static void
-iseq_add_local_tracepoint_i(const rb_iseq_t *iseq, void *p)
-{
- struct trace_set_local_events_struct *data = (struct trace_set_local_events_struct *)p;
- data->n += iseq_add_local_tracepoint(iseq, data->turnon_events, data->tpval, data->target_line);
- iseq_iterate_children(iseq, iseq_add_local_tracepoint_i, p);
-}
-
-int
-rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line)
-{
- struct trace_set_local_events_struct data;
- data.turnon_events = turnon_events;
- data.tpval = tpval;
- data.target_line = target_line;
- data.n = 0;
-
- iseq_add_local_tracepoint_i(iseq, (void *)&data);
- if (0) rb_funcall(Qnil, rb_intern("puts"), 1, rb_iseq_disasm(iseq)); /* for debug */
- return data.n;
-}
-
-static int
-iseq_remove_local_tracepoint(const rb_iseq_t *iseq, VALUE tpval)
-{
- int n = 0;
-
- if (iseq->aux.exec.local_hooks) {
- unsigned int pc;
- const struct rb_iseq_constant_body *const body = iseq->body;
- VALUE *iseq_encoded = (VALUE *)body->iseq_encoded;
- rb_event_flag_t local_events = 0;
-
- rb_hook_list_remove_tracepoint(iseq->aux.exec.local_hooks, tpval);
- local_events = iseq->aux.exec.local_hooks->events;
-
- if (local_events == 0) {
- if (iseq->aux.exec.local_hooks->running == 0) {
- rb_hook_list_free(iseq->aux.exec.local_hooks);
- }
- ((rb_iseq_t *)iseq)->aux.exec.local_hooks = NULL;
- }
-
- for (pc = 0; pc<body->iseq_size;) {
- rb_event_flag_t pc_events = rb_iseq_event_flags(iseq, pc);
- pc += encoded_iseq_trace_instrument(&iseq_encoded[pc], pc_events & (local_events | iseq->aux.exec.global_trace_events));
- }
- }
- return n;
-}
-
-struct trace_clear_local_events_struct {
- VALUE tpval;
- int n;
-};
-
-static void
-iseq_remove_local_tracepoint_i(const rb_iseq_t *iseq, void *p)
-{
- struct trace_clear_local_events_struct *data = (struct trace_clear_local_events_struct *)p;
- data->n += iseq_remove_local_tracepoint(iseq, data->tpval);
- iseq_iterate_children(iseq, iseq_remove_local_tracepoint_i, p);
-}
-
-int
-rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval)
-{
- struct trace_clear_local_events_struct data;
- data.tpval = tpval;
- data.n = 0;
-
- iseq_remove_local_tracepoint_i(iseq, (void *)&data);
- return data.n;
-}
void
rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events)
{
- if (iseq->aux.exec.global_trace_events == turnon_events) {
+ VM_ASSERT((turnon_events & ~ISEQ_TRACE_EVENTS) == 0);
+
+ if (iseq->aux.trace_events == turnon_events) {
return;
}
-
- if (!ISEQ_EXECUTABLE_P(iseq)) {
+ if (iseq->flags & ISEQ_USE_COMPILE_DATA) {
/* this is building ISeq */
return;
}
else {
- unsigned int pc;
- const struct rb_iseq_constant_body *const body = iseq->body;
- VALUE *iseq_encoded = (VALUE *)body->iseq_encoded;
- rb_event_flag_t enabled_events;
- rb_event_flag_t local_events = iseq->aux.exec.local_hooks ? iseq->aux.exec.local_hooks->events : 0;
- ((rb_iseq_t *)iseq)->aux.exec.global_trace_events = turnon_events;
- enabled_events = turnon_events | local_events;
-
- for (pc=0; pc<body->iseq_size;) {
- rb_event_flag_t pc_events = rb_iseq_event_flags(iseq, pc);
- pc += encoded_iseq_trace_instrument(&iseq_encoded[pc], pc_events & enabled_events);
+ unsigned int i;
+ VALUE *iseq_encoded = (VALUE *)iseq->body->iseq_encoded;
+#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
+ VALUE *code = rb_iseq_original_iseq(iseq);
+ const void * const *table = rb_vm_get_insns_address_table();
+#else
+ const VALUE *code = iseq->body->iseq_encoded;
+#endif
+ ((rb_iseq_t *)iseq)->aux.trace_events = turnon_events;
+
+ for (i=0; i<iseq->body->iseq_size;) {
+ int insn = (int)code[i];
+ rb_event_flag_t events = rb_iseq_event_flags(iseq, i);
+
+ /* code represents before transformation */
+ VM_ASSERT(insn < VM_INSTRUCTION_SIZE/2);
+
+ if (events & turnon_events) {
+ if (!TRACE_INSN_P(insn, iseq_encoded[i])) {
+ iseq_encoded[i] = INSN_CODE(insn + VM_INSTRUCTION_SIZE/2);
+ }
+ }
+ else if (TRACE_INSN_P(insn, iseq_encoded[i])) {
+ iseq_encoded[i] = INSN_CODE(insn);
+ }
+ i += insn_len(insn);
}
+ /* clear for debugging: ISEQ_ORIGINAL_ISEQ_CLEAR(iseq); */
}
}
@@ -3303,14 +2605,9 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data)
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
- void *ptr = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
-
if (rb_obj_is_iseq(v)) {
rb_iseq_trace_set(rb_iseq_check((rb_iseq_t *)v), turnon_events);
}
-
- asan_poison_object_if(ptr, v);
}
return 0;
}
@@ -3321,6 +2618,12 @@ rb_iseq_trace_set_all(rb_event_flag_t turnon_events)
rb_objspace_each_objects(trace_set_i, &turnon_events);
}
+void
+rb_iseq_trace_on_all(void)
+{
+ rb_iseq_trace_set_all(RUBY_EVENT_TRACEPOINT_ALL);
+}
+
VALUE
rb_iseqw_local_variables(VALUE iseqval)
{
@@ -3347,7 +2650,8 @@ rb_iseqw_local_variables(VALUE iseqval)
static VALUE
iseqw_to_binary(int argc, VALUE *argv, VALUE self)
{
- VALUE opt = !rb_check_arity(argc, 0, 1) ? Qnil : argv[0];
+ VALUE opt;
+ rb_scan_args(argc, argv, "01", &opt);
return rb_iseq_ibf_dump(iseqw_check(self), opt);
}
@@ -3382,153 +2686,16 @@ iseqw_s_load_from_binary_extra_data(VALUE self, VALUE str)
return rb_iseq_ibf_load_extra_data(str);
}
-#if VM_INSN_INFO_TABLE_IMPL == 2
-
-/* An implementation of succinct bit-vector for insn_info table.
- *
- * A succinct bit-vector is a small and efficient data structure that provides
- * a bit-vector augmented with an index for O(1) rank operation:
- *
- * rank(bv, n): the number of 1's within a range from index 0 to index n
- *
- * This can be used to lookup insn_info table from PC.
- * For example, consider the following iseq and insn_info_table:
- *
- * iseq insn_info_table
- * PC insn+operand position lineno event
- * 0: insn1 0: 1 [Li]
- * 2: insn2 2: 2 [Li] <= (A)
- * 5: insn3 8: 3 [Li] <= (B)
- * 8: insn4
- *
- * In this case, a succinct bit-vector whose indexes 0, 2, 8 is "1" and
- * other indexes is "0", i.e., "101000001", is created.
- * To lookup the lineno of insn2, calculate rank("10100001", 2) = 2, so
- * the line (A) is the entry in question.
- * To lookup the lineno of insn4, calculate rank("10100001", 8) = 3, so
- * the line (B) is the entry in question.
- *
- * A naive implementation of succinct bit-vector works really well
- * not only for large size but also for small size. However, it has
- * tiny overhead for very small size. So, this implementation consist
- * of two parts: one part is the "immediate" table that keeps rank result
- * as a raw table, and the other part is a normal succinct bit-vector.
- */
-
-#define IMMEDIATE_TABLE_SIZE 54 /* a multiple of 9, and < 128 */
-
-struct succ_index_table {
- uint64_t imm_part[IMMEDIATE_TABLE_SIZE / 9];
- struct succ_dict_block {
- unsigned int rank;
- uint64_t small_block_ranks; /* 9 bits * 7 = 63 bits */
- uint64_t bits[512/64];
- } succ_part[FLEX_ARY_LEN];
-};
-
-#define imm_block_rank_set(v, i, r) (v) |= (uint64_t)(r) << (7 * (i))
-#define imm_block_rank_get(v, i) (((int)((v) >> ((i) * 7))) & 0x7f)
-#define small_block_rank_set(v, i, r) (v) |= (uint64_t)(r) << (9 * ((i) - 1))
-#define small_block_rank_get(v, i) ((i) == 0 ? 0 : (((int)((v) >> (((i) - 1) * 9))) & 0x1ff))
-
-static struct succ_index_table *
-succ_index_table_create(int max_pos, int *data, int size)
-{
- const int imm_size = (max_pos < IMMEDIATE_TABLE_SIZE ? max_pos + 8 : IMMEDIATE_TABLE_SIZE) / 9;
- const int succ_size = (max_pos < IMMEDIATE_TABLE_SIZE ? 0 : (max_pos - IMMEDIATE_TABLE_SIZE + 511)) / 512;
- struct succ_index_table *sd =
- rb_xcalloc_mul_add_mul(
- imm_size, sizeof(uint64_t),
- succ_size, sizeof(struct succ_dict_block));
- int i, j, k, r;
-
- r = 0;
- for (j = 0; j < imm_size; j++) {
- for (i = 0; i < 9; i++) {
- if (r < size && data[r] == j * 9 + i) r++;
- imm_block_rank_set(sd->imm_part[j], i, r);
- }
- }
- for (k = 0; k < succ_size; k++) {
- struct succ_dict_block *sd_block = &sd->succ_part[k];
- int small_rank = 0;
- sd_block->rank = r;
- for (j = 0; j < 8; j++) {
- uint64_t bits = 0;
- if (j) small_block_rank_set(sd_block->small_block_ranks, j, small_rank);
- for (i = 0; i < 64; i++) {
- if (r < size && data[r] == k * 512 + j * 64 + i + IMMEDIATE_TABLE_SIZE) {
- bits |= ((uint64_t)1) << i;
- r++;
- }
- }
- sd_block->bits[j] = bits;
- small_rank += rb_popcount64(bits);
- }
- }
- return sd;
-}
-
-static unsigned int *
-succ_index_table_invert(int max_pos, struct succ_index_table *sd, int size)
-{
- const int imm_size = (max_pos < IMMEDIATE_TABLE_SIZE ? max_pos + 8 : IMMEDIATE_TABLE_SIZE) / 9;
- const int succ_size = (max_pos < IMMEDIATE_TABLE_SIZE ? 0 : (max_pos - IMMEDIATE_TABLE_SIZE + 511)) / 512;
- unsigned int *positions = ALLOC_N(unsigned int, size), *p;
- int i, j, k, r = -1;
- p = positions;
- for (j = 0; j < imm_size; j++) {
- for (i = 0; i < 9; i++) {
- int nr = imm_block_rank_get(sd->imm_part[j], i);
- if (r != nr) *p++ = j * 9 + i;
- r = nr;
- }
- }
- for (k = 0; k < succ_size; k++) {
- for (j = 0; j < 8; j++) {
- for (i = 0; i < 64; i++) {
- if (sd->succ_part[k].bits[j] & (((uint64_t)1) << i)) {
- *p++ = k * 512 + j * 64 + i + IMMEDIATE_TABLE_SIZE;
- }
- }
- }
- }
- return positions;
-}
-
-static int
-succ_index_lookup(const struct succ_index_table *sd, int x)
-{
- if (x < IMMEDIATE_TABLE_SIZE) {
- const int i = x / 9;
- const int j = x % 9;
- return imm_block_rank_get(sd->imm_part[i], j);
- }
- else {
- const int block_index = (x - IMMEDIATE_TABLE_SIZE) / 512;
- const struct succ_dict_block *block = &sd->succ_part[block_index];
- const int block_bit_index = (x - IMMEDIATE_TABLE_SIZE) % 512;
- const int small_block_index = block_bit_index / 64;
- const int small_block_popcount = small_block_rank_get(block->small_block_ranks, small_block_index);
- const int popcnt = rb_popcount64(block->bits[small_block_index] << (63 - block_bit_index % 64));
-
- return block->rank + small_block_popcount + popcnt;
- }
-}
-#endif
-
/*
* Document-class: RubyVM::InstructionSequence
*
* The InstructionSequence class represents a compiled sequence of
- * instructions for the Virtual Machine used in MRI. Not all implementations of Ruby
- * may implement this class, and for the implementations that implement it,
- * the methods defined and behavior of the methods can change in any version.
+ * instructions for the Ruby Virtual Machine.
*
* With it, you can get a handle to the instructions that make up a method or
* a proc, compile strings of Ruby code down to VM instructions, and
* disassemble instruction sequences to strings for easy inspection. It is
- * mostly useful if you want to learn how YARV works, but it also lets
+ * mostly useful if you want to learn how the Ruby VM works, but it also lets
* you control various settings for the Ruby iseq compiler.
*
* You can find the source for the VM instructions in +insns.def+ in the Ruby
@@ -3537,8 +2704,6 @@ succ_index_lookup(const struct succ_index_table *sd, int x)
* The instruction sequence results will almost certainly change as Ruby
* changes, so example output in this documentation may be different from what
* you see.
- *
- * Of course, this class is MRI specific.
*/
void
diff --git a/iseq.h b/iseq.h
index 25c62a384f..65cf653e52 100644
--- a/iseq.h
+++ b/iseq.h
@@ -12,64 +12,76 @@
#ifndef RUBY_ISEQ_H
#define RUBY_ISEQ_H 1
-RUBY_EXTERN const int ruby_api_version[];
-#define ISEQ_MAJOR_VERSION ((unsigned int)ruby_api_version[0])
-#define ISEQ_MINOR_VERSION ((unsigned int)ruby_api_version[1])
+#include "ruby/version.h"
+
+#define ISEQ_MAJOR_VERSION RUBY_API_VERSION_MAJOR
+#define ISEQ_MINOR_VERSION RUBY_API_VERSION_MINOR
#ifndef rb_iseq_t
typedef struct rb_iseq_struct rb_iseq_t;
#define rb_iseq_t rb_iseq_t
#endif
-extern const ID rb_iseq_shared_exc_local_tbl[];
-
static inline size_t
rb_call_info_kw_arg_bytes(int keyword_len)
{
- return rb_size_mul_add_or_raise(
- keyword_len - 1, sizeof(VALUE), sizeof(struct rb_call_info_kw_arg),
- rb_eRuntimeError);
+ return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
}
-#define ISEQ_COVERAGE(iseq) iseq->body->variable.coverage
-#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, cov)
+enum iseq_mark_ary_index {
+ ISEQ_MARK_ARY_COVERAGE,
+ ISEQ_MARK_ARY_FLIP_CNT,
+ ISEQ_MARK_ARY_ORIGINAL_ISEQ,
+ ISEQ_MARK_ARY_INITIAL_SIZE
+};
+
+static inline VALUE
+iseq_mark_ary_create(int flip_cnt)
+{
+ VALUE ary = rb_ary_tmp_new(ISEQ_MARK_ARY_INITIAL_SIZE);
+ rb_ary_push(ary, Qnil); /* ISEQ_MARK_ARY_COVERAGE */
+ rb_ary_push(ary, INT2FIX(flip_cnt)); /* ISEQ_MARK_ARY_FLIP_CNT */
+ rb_ary_push(ary, Qnil); /* ISEQ_MARK_ARY_ORIGINAL_ISEQ */
+ return ary;
+}
+
+#define ISEQ_MARK_ARY(iseq) (iseq)->body->mark_ary
+
+#define ISEQ_COVERAGE(iseq) RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_COVERAGE)
+#define ISEQ_COVERAGE_SET(iseq, cov) RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_COVERAGE, cov)
#define ISEQ_LINE_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_LINES)
#define ISEQ_BRANCH_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_BRANCHES)
-#define ISEQ_PC2BRANCHINDEX(iseq) iseq->body->variable.pc2branchindex
-#define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &iseq->body->variable.pc2branchindex, h)
-
-#define ISEQ_FLIP_CNT(iseq) (iseq)->body->variable.flip_count
+#define ISEQ_FLIP_CNT(iseq) FIX2INT(RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_FLIP_CNT))
-static inline rb_snum_t
+static inline int
ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
{
- rb_snum_t cnt = iseq->body->variable.flip_count;
- iseq->body->variable.flip_count += 1;
+ int cnt = ISEQ_FLIP_CNT(iseq);
+ RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_FLIP_CNT, INT2FIX(cnt+1));
return cnt;
}
static inline VALUE *
ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
{
- return iseq->body->variable.original_iseq;
+ VALUE str = RARRAY_AREF(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ);
+ if (RTEST(str)) return (VALUE *)RSTRING_PTR(str);
+ return NULL;
}
static inline void
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
{
- void *ptr = iseq->body->variable.original_iseq;
- iseq->body->variable.original_iseq = NULL;
- if (ptr) {
- ruby_xfree(ptr);
- }
+ RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ, Qnil);
}
static inline VALUE *
ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
{
- return iseq->body->variable.original_iseq =
- ALLOC_N(VALUE, size);
+ VALUE str = rb_str_tmp_new(size * sizeof(VALUE));
+ RARRAY_ASET(ISEQ_MARK_ARY(iseq), ISEQ_MARK_ARY_ORIGINAL_ISEQ, str);
+ return (VALUE *)RSTRING_PTR(str);
}
#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
@@ -78,20 +90,15 @@ ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
RUBY_EVENT_CALL | \
RUBY_EVENT_RETURN| \
RUBY_EVENT_B_CALL| \
- RUBY_EVENT_B_RETURN| \
- RUBY_EVENT_COVERAGE_LINE| \
- RUBY_EVENT_COVERAGE_BRANCH)
+ RUBY_EVENT_B_RETURN)
#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
-#define ISEQ_TRANSLATED IMEMO_FL_USER3
-#define ISEQ_MARKABLE_ISEQ IMEMO_FL_USER4
-
-#define ISEQ_EXECUTABLE_P(iseq) (FL_TEST_RAW((iseq), ISEQ_NOT_LOADED_YET | ISEQ_USE_COMPILE_DATA) == 0)
struct iseq_compile_data {
/* GC is needed */
const VALUE err_info;
+ VALUE mark_ary;
const VALUE catch_table_ary; /* Array */
/* GC is not needed */
@@ -99,16 +106,13 @@ struct iseq_compile_data {
struct iseq_label_data *end_label;
struct iseq_label_data *redo_label;
const rb_iseq_t *current_block;
+ VALUE ensure_node;
+ VALUE for_iseq;
struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
- struct {
- struct iseq_compile_data_storage *storage_head;
- struct iseq_compile_data_storage *storage_current;
- } node;
- struct {
- struct iseq_compile_data_storage *storage_head;
- struct iseq_compile_data_storage *storage_current;
- } insn;
int loopval_popped; /* used by NODE_BREAK */
+ int cached_const;
+ struct iseq_compile_data_storage *storage_head;
+ struct iseq_compile_data_storage *storage_current;
int last_line;
int label_no;
int node_level;
@@ -116,8 +120,7 @@ struct iseq_compile_data {
unsigned int ci_kw_index;
const rb_compile_option_t *option;
struct rb_id_table *ivar_cache_table;
- const struct rb_builtin_function *builtin_function_table;
-#if OPT_SUPPORT_JOKE
+#if SUPPORT_JOKE
st_table *labels_table;
#endif
};
@@ -136,8 +139,8 @@ ISEQ_COMPILE_DATA(const rb_iseq_t *iseq)
static inline void
ISEQ_COMPILE_DATA_ALLOC(rb_iseq_t *iseq)
{
- iseq->aux.compile_data = ZALLOC(struct iseq_compile_data);
iseq->flags |= ISEQ_USE_COMPILE_DATA;
+ iseq->aux.compile_data = ZALLOC(struct iseq_compile_data);
}
static inline void
@@ -156,37 +159,29 @@ iseq_imemo_alloc(void)
VALUE rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
void rb_ibf_load_iseq_complete(rb_iseq_t *iseq);
const rb_iseq_t *rb_iseq_ibf_load(VALUE str);
-const rb_iseq_t *rb_iseq_ibf_load_bytes(const char *cstr, size_t);
VALUE rb_iseq_ibf_load_extra_data(VALUE str);
void rb_iseq_init_trace(rb_iseq_t *iseq);
-int rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line);
-int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval);
-const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
-
-#if VM_INSN_INFO_TABLE_IMPL == 2
-unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
-#endif
RUBY_SYMBOL_EXPORT_BEGIN
/* compile.c */
VALUE rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node);
-VALUE rb_iseq_compile_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_callback_callback_func * ifunc);
+int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
VALUE *rb_iseq_original_iseq(const rb_iseq_t *iseq);
void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc,
VALUE locals, VALUE args,
VALUE exception, VALUE body);
-void rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *arena);
/* iseq.c */
+void rb_iseq_add_mark_object(const rb_iseq_t *iseq, VALUE obj);
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
+struct st_table *ruby_insn_make_insn_table(void);
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
void rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
void rb_iseq_trace_set_all(rb_event_flag_t turnon_events);
-void rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq);
+void rb_iseq_trace_on_all(void);
-struct rb_iseq_constant_body *rb_iseq_constant_body_alloc(void);
VALUE rb_iseqw_new(const rb_iseq_t *iseq);
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
@@ -195,9 +190,7 @@ VALUE rb_iseq_label(const rb_iseq_t *iseq);
VALUE rb_iseq_base_label(const rb_iseq_t *iseq);
VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq);
VALUE rb_iseq_method_name(const rb_iseq_t *iseq);
-void rb_iseq_code_location(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
-
-void rb_iseq_remove_coverage_all(void);
+void rb_iseq_code_range(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
/* proc.c */
const rb_iseq_t *rb_method_iseq(VALUE body);
@@ -218,6 +211,7 @@ struct rb_compile_option_struct {
};
struct iseq_insn_info_entry {
+ unsigned int position;
int line_no;
rb_event_flag_t events;
};
@@ -244,7 +238,7 @@ struct iseq_catch_table_entry {
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
* NULL.
*/
- rb_iseq_t *iseq;
+ const rb_iseq_t *iseq;
unsigned int start;
unsigned int end;
@@ -254,19 +248,18 @@ struct iseq_catch_table_entry {
PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
unsigned int size;
- struct iseq_catch_table_entry entries[FLEX_ARY_LEN];
+ struct iseq_catch_table_entry entries[1]; /* flexible array */
});
static inline int
iseq_catch_table_bytes(int n)
{
enum {
- catch_table_entry_size = sizeof(struct iseq_catch_table_entry),
- catch_table_entries_max = (INT_MAX - offsetof(struct iseq_catch_table, entries)) / catch_table_entry_size
+ catch_table_entries_max = (INT_MAX - sizeof(struct iseq_catch_table)) / sizeof(struct iseq_catch_table_entry)
};
if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n);
- return (int)(offsetof(struct iseq_catch_table, entries) +
- n * catch_table_entry_size);
+ return (int)(sizeof(struct iseq_catch_table) +
+ (n - 1) * sizeof(struct iseq_catch_table_entry));
}
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
@@ -275,13 +268,16 @@ struct iseq_compile_data_storage {
struct iseq_compile_data_storage *next;
unsigned int pos;
unsigned int size;
- char buff[FLEX_ARY_LEN];
+ char buff[1]; /* flexible array */
};
+/* account for flexible array */
+#define SIZEOF_ISEQ_COMPILE_DATA_STORAGE \
+ (sizeof(struct iseq_compile_data_storage) - 1)
+
/* defined? */
enum defined_type {
- DEFINED_NOT_DEFINED,
DEFINED_NIL = 1,
DEFINED_IVAR,
DEFINED_LVAR,
@@ -298,11 +294,11 @@ enum defined_type {
DEFINED_EXPR,
DEFINED_IVAR2,
DEFINED_REF,
- DEFINED_FUNC,
- DEFINED_CONST_FROM
+ DEFINED_FUNC
};
VALUE rb_iseq_defined_string(enum defined_type type);
+void rb_iseq_make_compile_option(struct rb_compile_option_struct *option, VALUE opt);
/* vm.c */
VALUE rb_iseq_local_variables(const rb_iseq_t *iseq);
diff --git a/lex.c.blt b/lex.c.blt
index 92a4793b00..d93a0b84b5 100644
--- a/lex.c.blt
+++ b/lex.c.blt
@@ -31,7 +31,7 @@
#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
#line 1 "defs/keywords"
-struct kwtable {short name, id[2], state;};
+struct kwtable {int name, id[2], state;};
const struct kwtable *rb_reserved_word(const char *, unsigned int);
#ifndef RIPPER
static const struct kwtable *reserved_word(/*const char *, unsigned int*/);
diff --git a/lib/.document b/lib/.document
index 668152021d..225feca10c 100644
--- a/lib/.document
+++ b/lib/.document
@@ -4,7 +4,6 @@
bundler
cgi
-csv
drb
forwardable
irb
diff --git a/lib/English.rb b/lib/English.rb
index ec90ff10cd..a4f5bb6620 100644
--- a/lib/English.rb
+++ b/lib/English.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Include the English library file in a Ruby script, and you can
-# reference the global variables such as <tt>$_</tt> using less
-# cryptic names, listed below.
+# reference the global variables such as \VAR{\$\_} using less
+# cryptic names, listed in the following table.% \vref{tab:english}.
#
# Without 'English':
#
@@ -52,43 +52,45 @@ module English end if false
alias $ERROR_INFO $!
# The stack backtrace generated by the last
-# exception. See Kernel#caller for details. Thread local.
+# exception. <tt>See Kernel.caller</tt> for details. Thread local.
alias $ERROR_POSITION $@
-# The default separator pattern used by String#split. May be set from
-# the command line using the <tt>-F</tt> flag.
+# The default separator pattern used by <tt>String.split</tt>. May be
+# set from the command line using the <tt>-F</tt> flag.
alias $FS $;
-# The default separator pattern used by String#split. May be set from
-# the command line using the <tt>-F</tt> flag.
+# The default separator pattern used by <tt>String.split</tt>. May be
+# set from the command line using the <tt>-F</tt> flag.
alias $FIELD_SEPARATOR $;
# The separator string output between the parameters to methods such
-# as Kernel#print and Array#join. Defaults to +nil+, which adds no
-# text.
+# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+,
+# which adds no text.
alias $OFS $,
# The separator string output between the parameters to methods such
-# as Kernel#print and Array#join. Defaults to +nil+, which adds no
-# text.
+# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+,
+# which adds no text.
alias $OUTPUT_FIELD_SEPARATOR $,
# The input record separator (newline by default). This is the value
-# that routines such as Kernel#gets use to determine record
+# that routines such as <tt>Kernel.gets</tt> use to determine record
# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $RS $/
# The input record separator (newline by default). This is the value
-# that routines such as Kernel#gets use to determine record
+# that routines such as <tt>Kernel.gets</tt> use to determine record
# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $INPUT_RECORD_SEPARATOR $/
# The string appended to the output of every call to methods such as
-# Kernel#print and IO#write. The default value is +nil+.
+# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is
+# +nil+.
alias $ORS $\
# The string appended to the output of every call to methods such as
-# Kernel#print and IO#write. The default value is +nil+.
+# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is
+# +nil+.
alias $OUTPUT_RECORD_SEPARATOR $\
# The number of the last line read from the current input file.
@@ -97,14 +99,14 @@ alias $INPUT_LINE_NUMBER $.
# The number of the last line read from the current input file.
alias $NR $.
-# The last line read by Kernel#gets or
-# Kernel#readline. Many string-related functions in the
-# Kernel module operate on <tt>$_</tt> by default. The variable is
+# The last line read by <tt>Kernel.gets</tt> or
+# <tt>Kernel.readline</tt>. Many string-related functions in the
+# +Kernel+ module operate on <tt>$_</tt> by default. The variable is
# local to the current scope. Thread local.
alias $LAST_READ_LINE $_
-# The destination of output for Kernel#print
-# and Kernel#printf. The default value is
+# The destination of output for <tt>Kernel.print</tt>
+# and <tt>Kernel.printf</tt>. The default value is
# <tt>$stdout</tt>.
alias $DEFAULT_OUTPUT $>
@@ -113,7 +115,7 @@ alias $DEFAULT_OUTPUT $>
# given as command-line arguments, or <tt>$stdin</tt>
# (in the case where there are no
# arguments). <tt>$<</tt> supports methods similar to a
-# File object:
+# +File+ object:
# +inmode+, +close+,
# <tt>closed?</tt>, +each+,
# <tt>each_byte</tt>, <tt>each_line</tt>,
@@ -127,8 +129,8 @@ alias $DEFAULT_OUTPUT $>
# +rewind+, +seek+, +skip+,
# +tell+, <tt>to_a</tt>, <tt>to_i</tt>,
# <tt>to_io</tt>, <tt>to_s</tt>, along with the
-# methods in Enumerable. The method +file+
-# returns a File object for the file currently
+# methods in +Enumerable+. The method +file+
+# returns a +File+ object for the file currently
# being read. This may change as <tt>$<</tt> reads
# through the files on the command line. Read only.
alias $DEFAULT_INPUT $<
diff --git a/lib/base64.rb b/lib/base64.rb
index 5c8df841f1..24f0b02966 100644
--- a/lib/base64.rb
+++ b/lib/base64.rb
@@ -81,9 +81,8 @@ module Base64
# Note that the result can still contain '='.
# You can remove the padding by setting +padding+ as false.
def urlsafe_encode64(bin, padding: true)
- str = strict_encode64(bin)
- str.tr!("+/", "-_")
- str.delete!("=") unless padding
+ str = strict_encode64(bin).tr("+/", "-_")
+ str = str.delete("=") unless padding
str
end
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index 5ce9710586..8d768b631e 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -439,9 +439,6 @@ module Benchmark
#
# An in-place version of #add.
- # Changes the times of this Tms object by making it the sum of the times
- # for this Tms object, plus the time required to execute
- # the code block (+blk+).
#
def add!(&blk)
t = Benchmark.measure(&blk)
@@ -455,7 +452,7 @@ module Benchmark
#
# Returns a new Tms object obtained by memberwise summation
- # of the individual times for this Tms object with those of the +other+
+ # of the individual times for this Tms object with those of the other
# Tms object.
# This method and #/() are useful for taking statistics.
#
@@ -463,20 +460,20 @@ module Benchmark
#
# Returns a new Tms object obtained by memberwise subtraction
- # of the individual times for the +other+ Tms object from those of this
+ # of the individual times for the other Tms object from those of this
# Tms object.
#
def -(other); memberwise(:-, other) end
#
# Returns a new Tms object obtained by memberwise multiplication
- # of the individual times for this Tms object by +x+.
+ # of the individual times for this Tms object by _x_.
#
def *(x); memberwise(:*, x) end
#
# Returns a new Tms object obtained by memberwise division
- # of the individual times for this Tms object by +x+.
+ # of the individual times for this Tms object by _x_.
# This method and #+() are useful for taking statistics.
#
def /(x); memberwise(:/, x) end
@@ -532,7 +529,7 @@ module Benchmark
#
# Returns a new Tms object obtained by memberwise operation +op+
# of the individual times for this Tms object with those of the other
- # Tms object (+x+).
+ # Tms object.
#
# +op+ can be a mathematical operation such as <tt>+</tt>, <tt>-</tt>,
# <tt>*</tt>, <tt>/</tt>
diff --git a/lib/benchmark/benchmark.gemspec b/lib/benchmark/benchmark.gemspec
deleted file mode 100644
index 773cab19b0..0000000000
--- a/lib/benchmark/benchmark.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/benchmark/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "benchmark"
- spec.version = Benchmark::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{a performance benchmarking library}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/benchmark"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/benchmark/version.rb b/lib/benchmark/version.rb
deleted file mode 100644
index d74cc74ee7..0000000000
--- a/lib/benchmark/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Benchmark
- VERSION = "0.1.0"
-end
diff --git a/lib/bundler.rb b/lib/bundler.rb
deleted file mode 100644
index df345539c8..0000000000
--- a/lib/bundler.rb
+++ /dev/null
@@ -1,682 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "bundler/vendored_fileutils"
-require "pathname"
-require "rbconfig"
-
-require_relative "bundler/errors"
-require_relative "bundler/environment_preserver"
-require_relative "bundler/plugin"
-require_relative "bundler/rubygems_ext"
-require_relative "bundler/rubygems_integration"
-require_relative "bundler/version"
-require_relative "bundler/constants"
-require_relative "bundler/current_ruby"
-require_relative "bundler/build_metadata"
-
-# Bundler provides a consistent environment for Ruby projects by
-# tracking and installing the exact gems and versions that are needed.
-#
-# Since Ruby 2.6, Bundler is a part of Ruby's standard library.
-#
-# Bunder is used by creating _gemfiles_ listing all the project dependencies
-# and (optionally) their versions and then using
-#
-# require 'bundler/setup'
-#
-# or Bundler.setup to setup environment where only specified gems and their
-# specified versions could be used.
-#
-# See {Bundler website}[https://bundler.io/docs.html] for extensive documentation
-# on gemfiles creation and Bundler usage.
-#
-# As a standard library inside project, Bundler could be used for introspection
-# of loaded and required modules.
-#
-module Bundler
- environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS)
- ORIGINAL_ENV = environment_preserver.restore
- ENV.replace(environment_preserver.backup)
- SUDO_MUTEX = Mutex.new
-
- autoload :Definition, File.expand_path("bundler/definition", __dir__)
- autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
- autoload :DepProxy, File.expand_path("bundler/dep_proxy", __dir__)
- autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
- autoload :Dsl, File.expand_path("bundler/dsl", __dir__)
- autoload :EndpointSpecification, File.expand_path("bundler/endpoint_specification", __dir__)
- autoload :Env, File.expand_path("bundler/env", __dir__)
- autoload :Fetcher, File.expand_path("bundler/fetcher", __dir__)
- autoload :FeatureFlag, File.expand_path("bundler/feature_flag", __dir__)
- autoload :GemHelper, File.expand_path("bundler/gem_helper", __dir__)
- autoload :GemHelpers, File.expand_path("bundler/gem_helpers", __dir__)
- autoload :GemVersionPromoter, File.expand_path("bundler/gem_version_promoter", __dir__)
- autoload :Graph, File.expand_path("bundler/graph", __dir__)
- autoload :Index, File.expand_path("bundler/index", __dir__)
- autoload :Injector, File.expand_path("bundler/injector", __dir__)
- autoload :Installer, File.expand_path("bundler/installer", __dir__)
- autoload :LazySpecification, File.expand_path("bundler/lazy_specification", __dir__)
- autoload :LockfileParser, File.expand_path("bundler/lockfile_parser", __dir__)
- autoload :MatchPlatform, File.expand_path("bundler/match_platform", __dir__)
- autoload :ProcessLock, File.expand_path("bundler/process_lock", __dir__)
- autoload :RemoteSpecification, File.expand_path("bundler/remote_specification", __dir__)
- autoload :Resolver, File.expand_path("bundler/resolver", __dir__)
- autoload :Retry, File.expand_path("bundler/retry", __dir__)
- autoload :RubyDsl, File.expand_path("bundler/ruby_dsl", __dir__)
- autoload :RubyGemsGemInstaller, File.expand_path("bundler/rubygems_gem_installer", __dir__)
- autoload :RubyVersion, File.expand_path("bundler/ruby_version", __dir__)
- autoload :Runtime, File.expand_path("bundler/runtime", __dir__)
- autoload :Settings, File.expand_path("bundler/settings", __dir__)
- autoload :SharedHelpers, File.expand_path("bundler/shared_helpers", __dir__)
- autoload :Source, File.expand_path("bundler/source", __dir__)
- autoload :SourceList, File.expand_path("bundler/source_list", __dir__)
- autoload :SpecSet, File.expand_path("bundler/spec_set", __dir__)
- autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
- autoload :UI, File.expand_path("bundler/ui", __dir__)
- autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
- autoload :VersionRanges, File.expand_path("bundler/version_ranges", __dir__)
-
- class << self
- def configure
- @configured ||= configure_gem_home_and_path
- end
-
- def ui
- (defined?(@ui) && @ui) || (self.ui = UI::Shell.new)
- end
-
- def ui=(ui)
- Bundler.rubygems.ui = UI::RGProxy.new(ui)
- @ui = ui
- end
-
- # Returns absolute path of where gems are installed on the filesystem.
- def bundle_path
- @bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)
- end
-
- def configured_bundle_path
- @configured_bundle_path ||= settings.path.tap(&:validate!)
- end
-
- # Returns absolute location of where binstubs are installed to.
- def bin_path
- @bin_path ||= begin
- path = settings[:bin] || "bin"
- path = Pathname.new(path).expand_path(root).expand_path
- SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }
- path
- end
- end
-
- # Turns on the Bundler runtime. After +Bundler.setup+ call, all +load+ or
- # +require+ of the gems would be allowed only if they are part of
- # the Gemfile or Ruby's standard library. If the versions specified
- # in Gemfile, only those versions would be loaded.
- #
- # Assuming Gemfile
- #
- # gem 'first_gem', '= 1.0'
- # group :test do
- # gem 'second_gem', '= 1.0'
- # end
- #
- # The code using Bundler.setup works as follows:
- #
- # require 'third_gem' # allowed, required from global gems
- # require 'first_gem' # allowed, loads the last installed version
- # Bundler.setup
- # require 'fourth_gem' # fails with LoadError
- # require 'second_gem' # loads exactly version 1.0
- #
- # +Bundler.setup+ can be called only once, all subsequent calls are no-op.
- #
- # If _groups_ list is provided, only gems from specified groups would
- # be allowed (gems specified outside groups belong to special +:default+ group).
- #
- # To require all gems from Gemfile (or only some groups), see Bundler.require.
- #
- def setup(*groups)
- # Return if all groups are already loaded
- return @setup if defined?(@setup) && @setup
-
- definition.validate_runtime!
-
- SharedHelpers.print_major_deprecations!
-
- if groups.empty?
- # Load all groups, but only once
- @setup = load.setup
- else
- load.setup(*groups)
- end
- end
-
- # Setups Bundler environment (see Bundler.setup) if it is not already set,
- # and loads all gems from groups specified. Unlike ::setup, can be called
- # multiple times with different groups (if they were allowed by setup).
- #
- # Assuming Gemfile
- #
- # gem 'first_gem', '= 1.0'
- # group :test do
- # gem 'second_gem', '= 1.0'
- # end
- #
- # The code will work as follows:
- #
- # Bundler.setup # allow all groups
- # Bundler.require(:default) # requires only first_gem
- # # ...later
- # Bundler.require(:test) # requires second_gem
- #
- def require(*groups)
- setup(*groups).require(*groups)
- end
-
- def load
- @load ||= Runtime.new(root, definition)
- end
-
- def environment
- SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", :print_caller_location => true
- load
- end
-
- # Returns an instance of Bundler::Definition for given Gemfile and lockfile
- #
- # @param unlock [Hash, Boolean, nil] Gems that have been requested
- # to be updated or true if all gems should be updated
- # @return [Bundler::Definition]
- def definition(unlock = nil)
- @definition = nil if unlock
- @definition ||= begin
- configure
- Definition.build(default_gemfile, default_lockfile, unlock)
- end
- end
-
- def frozen_bundle?
- frozen = settings[:deployment]
- frozen ||= settings[:frozen] unless feature_flag.deployment_means_frozen?
- frozen
- end
-
- def locked_gems
- @locked_gems ||=
- if defined?(@definition) && @definition
- definition.locked_gems
- elsif Bundler.default_lockfile.file?
- lock = Bundler.read_file(Bundler.default_lockfile)
- LockfileParser.new(lock)
- end
- end
-
- def ruby_scope
- "#{Bundler.rubygems.ruby_engine}/#{RbConfig::CONFIG["ruby_version"]}"
- end
-
- def user_home
- @user_home ||= begin
- home = Bundler.rubygems.user_home
- bundle_home = home ? File.join(home, ".bundle") : nil
-
- warning = if home.nil?
- "Your home directory is not set."
- elsif !File.directory?(home)
- "`#{home}` is not a directory."
- elsif !File.writable?(home) && (!File.directory?(bundle_home) || !File.writable?(bundle_home))
- "`#{home}` is not writable."
- end
-
- if warning
- user_home = tmp_home_path(warning)
- Bundler.ui.warn "#{warning}\nBundler will use `#{user_home}' as your home directory temporarily.\n"
- user_home
- else
- Pathname.new(home)
- end
- end
- end
-
- def user_bundle_path(dir = "home")
- env_var, fallback = case dir
- when "home"
- ["BUNDLE_USER_HOME", proc { Pathname.new(user_home).join(".bundle") }]
- when "cache"
- ["BUNDLE_USER_CACHE", proc { user_bundle_path.join("cache") }]
- when "config"
- ["BUNDLE_USER_CONFIG", proc { user_bundle_path.join("config") }]
- when "plugin"
- ["BUNDLE_USER_PLUGIN", proc { user_bundle_path.join("plugin") }]
- else
- raise BundlerError, "Unknown user path requested: #{dir}"
- end
- # `fallback` will already be a Pathname, but Pathname.new() is
- # idempotent so it's OK
- Pathname.new(ENV.fetch(env_var, &fallback))
- end
-
- def user_cache
- user_bundle_path("cache")
- end
-
- def home
- bundle_path.join("bundler")
- end
-
- def install_path
- home.join("gems")
- end
-
- def specs_path
- bundle_path.join("specifications")
- end
-
- def root
- @root ||= begin
- SharedHelpers.root
- rescue GemfileNotFound
- bundle_dir = default_bundle_dir
- raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
- Pathname.new(File.expand_path("..", bundle_dir))
- end
- end
-
- def app_config_path
- if app_config = ENV["BUNDLE_APP_CONFIG"]
- Pathname.new(app_config).expand_path(root)
- else
- root.join(".bundle")
- end
- end
-
- def app_cache(custom_path = nil)
- path = custom_path || root
- Pathname.new(path).join(settings.app_cache_path)
- end
-
- def tmp(name = Process.pid.to_s)
- Kernel.send(:require, "tmpdir")
- Pathname.new(Dir.mktmpdir(["bundler", name]))
- end
-
- def rm_rf(path)
- FileUtils.remove_entry_secure(path) if path && File.exist?(path)
- rescue ArgumentError
- message = <<EOF
-It is a security vulnerability to allow your home directory to be world-writable, and bundler can not continue.
-You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
-Please refer to https://ruby-doc.org/stdlib-2.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
-EOF
- File.world_writable?(path) ? Bundler.ui.warn(message) : raise
- raise PathError, "Please fix the world-writable issue with your #{path} directory"
- end
-
- def settings
- @settings ||= Settings.new(app_config_path)
- rescue GemfileNotFound
- @settings = Settings.new(Pathname.new(".bundle").expand_path)
- end
-
- # @return [Hash] Environment present before Bundler was activated
- def original_env
- ORIGINAL_ENV.clone
- end
-
- # @deprecated Use `unbundled_env` instead
- def clean_env
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`",
- :print_caller_location => true
- )
-
- unbundled_env
- end
-
- # @return [Hash] Environment with all bundler-related variables removed
- def unbundled_env
- env = original_env
-
- if env.key?("BUNDLER_ORIG_MANPATH")
- env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
- end
-
- env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
-
- if env.key?("RUBYOPT")
- env["RUBYOPT"] = env["RUBYOPT"].sub "-rbundler/setup", ""
- end
-
- if env.key?("RUBYLIB")
- rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
- rubylib.delete(File.expand_path("..", __FILE__))
- env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
- end
-
- env
- end
-
- # Run block with environment present before Bundler was activated
- def with_original_env
- with_env(original_env) { yield }
- end
-
- # @deprecated Use `with_unbundled_env` instead
- def with_clean_env
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`",
- :print_caller_location => true
- )
-
- with_env(unbundled_env) { yield }
- end
-
- # Run block with all bundler-related variables removed
- def with_unbundled_env
- with_env(unbundled_env) { yield }
- end
-
- # Run subcommand with the environment present before Bundler was activated
- def original_system(*args)
- with_original_env { Kernel.system(*args) }
- end
-
- # @deprecated Use `unbundled_system` instead
- def clean_system(*args)
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
- "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`",
- :print_caller_location => true
- )
-
- with_env(unbundled_env) { Kernel.system(*args) }
- end
-
- # Run subcommand in an environment with all bundler related variables removed
- def unbundled_system(*args)
- with_unbundled_env { Kernel.system(*args) }
- end
-
- # Run a `Kernel.exec` to a subcommand with the environment present before Bundler was activated
- def original_exec(*args)
- with_original_env { Kernel.exec(*args) }
- end
-
- # @deprecated Use `unbundled_exec` instead
- def clean_exec(*args)
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
- "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`",
- :print_caller_location => true
- )
-
- with_env(unbundled_env) { Kernel.exec(*args) }
- end
-
- # Run a `Kernel.exec` to a subcommand in an environment with all bundler related variables removed
- def unbundled_exec(*args)
- with_env(unbundled_env) { Kernel.exec(*args) }
- end
-
- def local_platform
- return Gem::Platform::RUBY if settings[:force_ruby_platform]
- Gem::Platform.local
- end
-
- def default_gemfile
- SharedHelpers.default_gemfile
- end
-
- def default_lockfile
- SharedHelpers.default_lockfile
- end
-
- def default_bundle_dir
- SharedHelpers.default_bundle_dir
- end
-
- def system_bindir
- # Gem.bindir doesn't always return the location that RubyGems will install
- # system binaries. If you put '-n foo' in your .gemrc, RubyGems will
- # install binstubs there instead. Unfortunately, RubyGems doesn't expose
- # that directory at all, so rather than parse .gemrc ourselves, we allow
- # the directory to be set as well, via `bundle config set bindir foo`.
- Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
- end
-
- def use_system_gems?
- configured_bundle_path.use_system_gems?
- end
-
- def requires_sudo?
- return @requires_sudo if defined?(@requires_sudo_ran)
-
- sudo_present = which "sudo" if settings.allow_sudo?
-
- if sudo_present
- # the bundle path and subdirectories need to be writable for RubyGems
- # to be able to unpack and install gems without exploding
- path = bundle_path
- path = path.parent until path.exist?
-
- # bins are written to a different location on OS X
- bin_dir = Pathname.new(Bundler.system_bindir)
- bin_dir = bin_dir.parent until bin_dir.exist?
-
- # if any directory is not writable, we need sudo
- files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s]
- unwritable_files = files.reject {|f| File.writable?(f) }
- sudo_needed = !unwritable_files.empty?
- if sudo_needed
- Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.map(&:to_s).sort.join("\n ")}"
- end
- end
-
- @requires_sudo_ran = true
- @requires_sudo = settings.allow_sudo? && sudo_present && sudo_needed
- end
-
- def mkdir_p(path, options = {})
- if requires_sudo? && !options[:no_sudo]
- sudo "mkdir -p '#{path}'" unless File.exist?(path)
- else
- SharedHelpers.filesystem_access(path, :write) do |p|
- FileUtils.mkdir_p(p)
- end
- end
- end
-
- def which(executable)
- if File.file?(executable) && File.executable?(executable)
- executable
- elsif paths = ENV["PATH"]
- quote = '"'.freeze
- paths.split(File::PATH_SEPARATOR).find do |path|
- path = path[1..-2] if path.start_with?(quote) && path.end_with?(quote)
- executable_path = File.expand_path(executable, path)
- return executable_path if File.file?(executable_path) && File.executable?(executable_path)
- end
- end
- end
-
- def sudo(str)
- SUDO_MUTEX.synchronize do
- prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, "").strip + " "
- Your user account isn't allowed to install to the system RubyGems.
- You can cancel this installation and run:
-
- bundle install --path vendor/bundle
-
- to install the gems into ./vendor/bundle/, or you can enter your password
- and install the bundled gems to RubyGems using sudo.
-
- Password:
- PROMPT
-
- unless @prompted_for_sudo ||= system(%(sudo -k -p "#{prompt}" true))
- raise SudoNotPermittedError,
- "Bundler requires sudo access to install at the moment. " \
- "Try installing again, granting Bundler sudo access when prompted, or installing into a different path."
- end
-
- `sudo -p "#{prompt}" #{str}`
- end
- end
-
- def read_file(file)
- SharedHelpers.filesystem_access(file, :read) do
- File.open(file, "r:UTF-8", &:read)
- end
- end
-
- def load_marshal(data)
- Marshal.load(data)
- rescue StandardError => e
- raise MarshalError, "#{e.class}: #{e.message}"
- end
-
- def load_gemspec(file, validate = false)
- @gemspec_cache ||= {}
- key = File.expand_path(file)
- @gemspec_cache[key] ||= load_gemspec_uncached(file, validate)
- # Protect against caching side-effected gemspecs by returning a
- # new instance each time.
- @gemspec_cache[key].dup if @gemspec_cache[key]
- end
-
- def load_gemspec_uncached(file, validate = false)
- path = Pathname.new(file)
- contents = read_file(file)
- spec = if contents.start_with?("---") # YAML header
- eval_yaml_gemspec(path, contents)
- else
- # Eval the gemspec from its parent directory, because some gemspecs
- # depend on "./" relative paths.
- SharedHelpers.chdir(path.dirname.to_s) do
- eval_gemspec(path, contents)
- end
- end
- return unless spec
- spec.loaded_from = path.expand_path.to_s
- Bundler.rubygems.validate(spec) if validate
- spec
- end
-
- def clear_gemspec_cache
- @gemspec_cache = {}
- end
-
- def git_present?
- return @git_present if defined?(@git_present)
- @git_present = Bundler.which("git") || Bundler.which("git.exe")
- end
-
- def feature_flag
- @feature_flag ||= FeatureFlag.new(VERSION)
- end
-
- def reset!
- reset_paths!
- Plugin.reset!
- reset_rubygems!
- end
-
- def reset_paths!
- @bin_path = nil
- @bundler_major_version = nil
- @bundle_path = nil
- @configured = nil
- @configured_bundle_path = nil
- @definition = nil
- @load = nil
- @locked_gems = nil
- @root = nil
- @settings = nil
- @setup = nil
- @user_home = nil
- end
-
- def reset_rubygems!
- return unless defined?(@rubygems) && @rubygems
- rubygems.undo_replacements
- rubygems.reset
- @rubygems = nil
- end
-
- private
-
- def eval_yaml_gemspec(path, contents)
- require_relative "bundler/psyched_yaml"
-
- # If the YAML is invalid, Syck raises an ArgumentError, and Psych
- # raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
- Gem::Specification.from_yaml(contents)
- rescue YamlLibrarySyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
- eval_gemspec(path, contents)
- end
-
- def eval_gemspec(path, contents)
- eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
- rescue ScriptError, StandardError => e
- msg = "There was an error while loading `#{path.basename}`: #{e.message}"
-
- if e.is_a?(LoadError)
- msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
- end
-
- raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
- end
-
- def configure_gem_home_and_path
- configure_gem_path
- configure_gem_home
- bundle_path
- end
-
- def configure_gem_path(env = ENV)
- blank_home = env["GEM_HOME"].nil? || env["GEM_HOME"].empty?
- if !use_system_gems?
- # this needs to be empty string to cause
- # PathSupport.split_gem_path to only load up the
- # Bundler --path setting as the GEM_PATH.
- env["GEM_PATH"] = ""
- elsif blank_home
- possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
- paths = possibles.flatten.compact.uniq.reject(&:empty?)
- env["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
- end
- end
-
- def configure_gem_home
- Bundler::SharedHelpers.set_env "GEM_HOME", File.expand_path(bundle_path, root)
- Bundler.rubygems.clear_paths
- end
-
- def tmp_home_path(warning)
- Kernel.send(:require, "tmpdir")
- SharedHelpers.filesystem_access(Dir.tmpdir) do
- path = Bundler.tmp
- at_exit { Bundler.rm_rf(path) }
- path
- end
- rescue RuntimeError => e
- raise e.exception("#{warning}\nBundler also failed to create a temporary home directory':\n#{e}")
- end
-
- # @param env [Hash]
- def with_env(env)
- backup = ENV.to_hash
- ENV.replace(env)
- yield
- ensure
- ENV.replace(backup)
- end
- end
-end
diff --git a/lib/bundler/build_metadata.rb b/lib/bundler/build_metadata.rb
deleted file mode 100644
index 4dfad2f8d8..0000000000
--- a/lib/bundler/build_metadata.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # Represents metadata from when the Bundler gem was built.
- module BuildMetadata
- # begin ivars
- @release = false
- # end ivars
-
- # A hash representation of the build metadata.
- def self.to_h
- {
- "Built At" => built_at,
- "Git SHA" => git_commit_sha,
- "Released Version" => release?,
- }
- end
-
- # A string representing the date the bundler gem was built.
- def self.built_at
- @built_at ||= Time.now.utc.strftime("%Y-%m-%d").freeze
- end
-
- # The SHA for the git commit the bundler gem was built from.
- def self.git_commit_sha
- return @git_commit_sha if instance_variable_defined? :@git_commit_sha
-
- # If Bundler has been installed without its .git directory and without a
- # commit instance variable then we can't determine its commits SHA.
- git_dir = File.join(File.expand_path("../../..", __FILE__), ".git")
- if File.directory?(git_dir)
- return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze }
- end
-
- # If Bundler is a submodule in RubyGems, get the submodule commit
- git_sub_dir = File.join(File.expand_path("../../../..", __FILE__), ".git")
- if File.directory?(git_sub_dir)
- return @git_commit_sha = Dir.chdir(git_sub_dir) do
- `git ls-tree --abbrev=8 HEAD bundler`.split(/\s/).fetch(2, "").strip.freeze
- end
- end
-
- @git_commit_sha ||= "unknown"
- end
-
- # Whether this is an official release build of Bundler.
- def self.release?
- @release
- end
- end
-end
diff --git a/lib/bundler/bundler.gemspec b/lib/bundler/bundler.gemspec
deleted file mode 100644
index 30a21f155f..0000000000
--- a/lib/bundler/bundler.gemspec
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require_relative "lib/bundler/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |s|
- s.name = "bundler"
- s.version = Bundler::VERSION
- s.license = "MIT"
- s.authors = [
- "André Arko", "Samuel Giddins", "Colby Swandale", "Hiroshi Shibata",
- "David Rodríguez", "Grey Baker", "Stephanie Morillo", "Chris Morris", "James Wen", "Tim Moore",
- "André Medeiros", "Jessica Lynn Suttles", "Terence Lee", "Carl Lerche",
- "Yehuda Katz"
- ]
- s.email = ["team@bundler.io"]
- s.homepage = "https://bundler.io"
- s.summary = "The best way to manage your application's dependencies"
- s.description = "Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably"
-
- if s.respond_to?(:metadata=)
- s.metadata = {
- "bug_tracker_uri" => "https://github.com/bundler/bundler/issues",
- "changelog_uri" => "https://github.com/bundler/bundler/blob/master/CHANGELOG.md",
- "homepage_uri" => "https://bundler.io/",
- "source_code_uri" => "https://github.com/bundler/bundler/",
- }
- end
-
- s.required_ruby_version = ">= 2.3.0"
- s.required_rubygems_version = ">= 2.5.2"
-
- s.files = (Dir.glob("lib/bundler/**/*", File::FNM_DOTMATCH) + Dir.glob("man/bundler*") + Dir.glob("libexec/bundle*")).reject {|f| File.directory?(f) }
-
- s.files += ["lib/bundler.rb"]
-
- s.bindir = "libexec"
- s.executables = %w[bundle bundler]
- s.require_paths = ["lib"]
-end
diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb
deleted file mode 100644
index 1f3712d48e..0000000000
--- a/lib/bundler/capistrano.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "shared_helpers"
-Bundler::SharedHelpers.major_deprecation 2,
- "The Bundler task for Capistrano. Please use https://github.com/capistrano/bundler"
-
-# Capistrano task for Bundler.
-#
-# Add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
-# Bundler will be activated after each new deployment.
-require_relative "deployment"
-require "capistrano/version"
-
-if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
- raise "For Capistrano 3.x integration, please use https://github.com/capistrano/bundler"
-end
-
-Capistrano::Configuration.instance(:must_exist).load do
- before "deploy:finalize_update", "bundle:install"
- Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
- set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }
-end
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
deleted file mode 100644
index 443458f2d9..0000000000
--- a/lib/bundler/cli.rb
+++ /dev/null
@@ -1,828 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "vendored_thor"
-
-module Bundler
- class CLI < Thor
- require_relative "cli/common"
-
- package_name "Bundler"
-
- AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean].freeze
- PARSEABLE_COMMANDS = %w[check config help exec platform show version].freeze
-
- COMMAND_ALIASES = {
- "check" => "c",
- "install" => "i",
- "list" => "ls",
- "exec" => ["e", "ex", "exe"],
- "cache" => ["package", "pack"],
- "version" => ["-v", "--version"],
- }.freeze
-
- def self.start(*)
- super
- ensure
- Bundler::SharedHelpers.print_major_deprecations!
- end
-
- def self.dispatch(*)
- super do |i|
- i.send(:print_command)
- i.send(:warn_on_outdated_bundler)
- end
- end
-
- def self.all_aliases
- @all_aliases ||= begin
- command_aliases = {}
-
- COMMAND_ALIASES.each do |name, aliases|
- Array(aliases).each do |one_alias|
- command_aliases[one_alias] = name
- end
- end
-
- command_aliases
- end
- end
-
- def self.aliases_for(command_name)
- COMMAND_ALIASES.select {|k, _| k == command_name }.invert
- end
-
- def initialize(*args)
- super
-
- custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
- if custom_gemfile && !custom_gemfile.empty?
- Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile)
- Bundler.reset_paths!
- end
-
- Bundler.settings.set_command_option_if_given :retry, options[:retry]
-
- current_cmd = args.last[:current_command].name
- auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
- rescue UnknownArgumentError => e
- raise InvalidOption, e.message
- ensure
- self.options ||= {}
- unprinted_warnings = Bundler.ui.unprinted_warnings
- Bundler.ui = UI::Shell.new(options)
- Bundler.ui.level = "debug" if options["verbose"]
- unprinted_warnings.each {|w| Bundler.ui.warn(w) }
-
- if ENV["RUBYGEMS_GEMDEPS"] && !ENV["RUBYGEMS_GEMDEPS"].empty?
- Bundler.ui.warn(
- "The RUBYGEMS_GEMDEPS environment variable is set. This enables RubyGems' " \
- "experimental Gemfile mode, which may conflict with Bundler and cause unexpected errors. " \
- "To remove this warning, unset RUBYGEMS_GEMDEPS.", :wrap => true
- )
- end
- end
-
- check_unknown_options!(:except => [:config, :exec])
- stop_on_unknown_option! :exec
-
- desc "cli_help", "Prints a summary of bundler commands", :hide => true
- def cli_help
- version
- Bundler.ui.info "\n"
-
- primary_commands = ["install", "update", "cache", "exec", "config", "help"]
-
- list = self.class.printable_commands(true)
- by_name = list.group_by {|name, _message| name.match(/^bundle (\w+)/)[1] }
- utilities = by_name.keys.sort - primary_commands
- primary_commands.map! {|name| (by_name[name] || raise("no primary command #{name}")).first }
- utilities.map! {|name| by_name[name].first }
-
- shell.say "Bundler commands:\n\n"
-
- shell.say " Primary commands:\n"
- shell.print_table(primary_commands, :indent => 4, :truncate => true)
- shell.say
- shell.say " Utilities:\n"
- shell.print_table(utilities, :indent => 4, :truncate => true)
- shell.say
- self.class.send(:class_options_help, shell)
- end
- default_task(Bundler.feature_flag.default_cli_command)
-
- class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
- class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
- :desc => "Specify the number of times you wish to attempt network commands"
- class_option "verbose", :type => :boolean, :desc => "Enable verbose output mode", :aliases => "-V"
-
- def help(cli = nil)
- case cli
- when "gemfile" then command = "gemfile"
- when nil then command = "bundle"
- else command = "bundle-#{cli}"
- end
-
- man_path = File.expand_path("../../../man", __FILE__)
- man_pages = Hash[Dir.glob(File.join(man_path, "*")).grep(/.*\.\d*\Z/).collect do |f|
- [File.basename(f, ".*"), f]
- end]
-
- if man_pages.include?(command)
- if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
- Kernel.exec "man #{man_pages[command]}"
- else
- puts File.read("#{man_path}/#{File.basename(man_pages[command])}.txt")
- end
- elsif command_path = Bundler.which("bundler-#{cli}")
- Kernel.exec(command_path, "--help")
- else
- super
- end
- end
-
- def self.handle_no_command_error(command, has_namespace = $thor_runner)
- if Bundler.feature_flag.plugins? && Bundler::Plugin.command?(command)
- return Bundler::Plugin.exec_command(command, ARGV[1..-1])
- end
-
- return super unless command_path = Bundler.which("bundler-#{command}")
-
- Kernel.exec(command_path, *ARGV[1..-1])
- end
-
- desc "init [OPTIONS]", "Generates a Gemfile into the current working directory"
- long_desc <<-D
- Init generates a default Gemfile in the current working directory. When adding a
- Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
- dependency listed in the gemspec file to the newly created Gemfile.
- D
- method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
- def init
- require_relative "cli/init"
- Init.new(options.dup).run
- end
-
- desc "check [OPTIONS]", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
- long_desc <<-D
- Check searches the local machine for each of the gems requested in the Gemfile. If
- all gems are found, Bundler prints a success message and exits with a status of 0.
- If not, the first missing gem is listed and Bundler exits status 1.
- D
- method_option "dry-run", :type => :boolean, :default => false, :banner =>
- "Lock the Gemfile"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
- def check
- remembered_flag_deprecation("path")
-
- require_relative "cli/check"
- Check.new(options).run
- end
-
- map aliases_for("check")
-
- desc "remove [GEM [GEM ...]]", "Removes gems from the Gemfile"
- long_desc <<-D
- Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning.
- D
- method_option "install", :type => :boolean, :banner =>
- "Runs 'bundle install' after removing the gems from the Gemfile"
- def remove(*gems)
- require_relative "cli/remove"
- Remove.new(gems, options).run
- end
-
- desc "install [OPTIONS]", "Install the current environment to the system"
- long_desc <<-D
- Install will install all of the gems in the current bundle, making them available
- for use. In a freshly checked out repository, this command will give you the same
- gem versions as the last person who updated the Gemfile and ran `bundle update`.
-
- Passing [DIR] to install (e.g. vendor) will cause the unpacked gems to be installed
- into the [DIR] directory rather than into system gems.
-
- If the bundle has already been installed, bundler will tell you so and then exit.
- D
- method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
- "Generate bin stubs for bundled gems to ./bin"
- method_option "clean", :type => :boolean, :banner =>
- "Run bundle clean automatically after install"
- method_option "deployment", :type => :boolean, :banner =>
- "Install using defaults tuned for deployment environments"
- method_option "frozen", :type => :boolean, :banner =>
- "Do not allow the Gemfile.lock to be updated after this install"
- method_option "full-index", :type => :boolean, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
- "Specify the number of jobs to run in parallel"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "no-cache", :type => :boolean, :banner =>
- "Don't update the existing gem cache."
- method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
- "Force downloading every gem."
- method_option "no-prune", :type => :boolean, :banner =>
- "Don't remove stale gems from the cache."
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- method_option "shebang", :type => :string, :banner =>
- "Specify a different shebang executable name than the default (usually 'ruby')"
- method_option "standalone", :type => :array, :lazy_default => [], :banner =>
- "Make a bundle that can work without the Bundler runtime"
- method_option "system", :type => :boolean, :banner =>
- "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
- method_option "trust-policy", :alias => "P", :type => :string, :banner =>
- "Gem trust policy (like gem install -P). Must be one of " +
- Bundler.rubygems.security_policy_keys.join("|")
- method_option "without", :type => :array, :banner =>
- "Exclude gems that are part of the specified named group."
- method_option "with", :type => :array, :banner =>
- "Include gems that are part of the specified named group."
- def install
- SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
-
- %w[clean deployment frozen no-cache no-prune path shebang system without with].each do |option|
- remembered_flag_deprecation(option)
- end
-
- require_relative "cli/install"
- Bundler.settings.temporary(:no_install => false) do
- Install.new(options.dup).run
- end
- end
-
- map aliases_for("install")
-
- desc "update [OPTIONS]", "Update the current environment"
- long_desc <<-D
- Update will install the newest versions of the gems listed in the Gemfile. Use
- update when you have changed the Gemfile, or if you want to get the newest
- possible versions of the gems in the bundle.
- D
- method_option "full-index", :type => :boolean, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "group", :aliases => "-g", :type => :array, :banner =>
- "Update a specific group"
- method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
- "Specify the number of jobs to run in parallel"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- method_option "source", :type => :array, :banner =>
- "Update a specific source (and all gems associated with it)"
- method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
- "Force downloading every gem."
- method_option "ruby", :type => :boolean, :banner =>
- "Update ruby specified in Gemfile.lock"
- method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
- "Update the locked version of bundler"
- method_option "patch", :type => :boolean, :banner =>
- "Prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :banner =>
- "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner =>
- "Prefer updating to next major version (default)"
- method_option "strict", :type => :boolean, :banner =>
- "Do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "conservative", :type => :boolean, :banner =>
- "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
- method_option "all", :type => :boolean, :banner =>
- "Update everything."
- def update(*gems)
- SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
- require_relative "cli/update"
- Bundler.settings.temporary(:no_install => false) do
- Update.new(options, gems).run
- end
- end
-
- unless Bundler.feature_flag.bundler_3_mode?
- desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
- long_desc <<-D
- Show lists the names and versions of all gems that are required by your Gemfile.
- Calling show with [GEM] will list the exact location of that gem on your machine.
- D
- method_option "paths", :type => :boolean,
- :banner => "List the paths of all gems that are required by your Gemfile."
- method_option "outdated", :type => :boolean,
- :banner => "Show verbose output including whether gems are outdated."
- def show(gem_name = nil)
- if ARGV[0] == "show"
- rest = ARGV[1..-1]
-
- if flag = rest.find{|arg| ["--verbose", "--outdated"].include?(arg) }
- Bundler::SharedHelpers.major_deprecation(2, "the `#{flag}` flag to `bundle show` was undocumented and will be removed without replacement")
- else
- new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list"
-
- new_arguments = rest.map do |arg|
- next arg if arg != "--paths"
- next "--path" if new_command == "info"
- end
-
- old_argv = ARGV.join(" ")
- new_argv = [new_command, *new_arguments.compact].join(" ")
-
- Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
- end
- end
- require_relative "cli/show"
- Show.new(options, gem_name).run
- end
- end
-
- desc "list", "List all gems in the bundle"
- method_option "name-only", :type => :boolean, :banner => "print only the gem names"
- method_option "only-group", :type => :string, :banner => "print gems from a particular group"
- method_option "without-group", :type => :string, :banner => "print all gems except from a group"
- method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
- def list
- require_relative "cli/list"
- List.new(options).run
- end
-
- map aliases_for("list")
-
- desc "info GEM [OPTIONS]", "Show information for the given gem"
- method_option "path", :type => :boolean, :banner => "Print full path to gem"
- def info(gem_name)
- require_relative "cli/info"
- Info.new(options, gem_name).run
- end
-
- desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem"
- long_desc <<-D
- Generate binstubs for executables in [GEM]. Binstubs are put into bin,
- or the --binstubs directory if one has been set. Calling binstubs with [GEM [GEM]]
- will create binstubs for all given gems.
- D
- method_option "force", :type => :boolean, :default => false, :banner =>
- "Overwrite existing binstubs if they exist"
- method_option "path", :type => :string, :lazy_default => "bin", :banner =>
- "Binstub destination directory (default bin)"
- method_option "shebang", :type => :string, :banner =>
- "Specify a different shebang executable name than the default (usually 'ruby')"
- method_option "standalone", :type => :boolean, :banner =>
- "Make binstubs that can work without the Bundler runtime"
- method_option "all", :type => :boolean, :banner =>
- "Install binstubs for all gems"
- def binstubs(*gems)
- require_relative "cli/binstubs"
- Binstubs.new(options, gems).run
- end
-
- desc "add GEM VERSION", "Add gem to Gemfile and run bundle install"
- long_desc <<-D
- Adds the specified gem to Gemfile (if valid) and run 'bundle install' in one step.
- D
- method_option "version", :aliases => "-v", :type => :string
- method_option "group", :aliases => "-g", :type => :string
- method_option "source", :aliases => "-s", :type => :string
- method_option "git", :type => :string
- method_option "branch", :type => :string
- method_option "skip-install", :type => :boolean, :banner =>
- "Adds gem to the Gemfile but does not install it"
- method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
- method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
- def add(*gems)
- require_relative "cli/add"
- Add.new(options.dup, gems).run
- end
-
- desc "outdated GEM [OPTIONS]", "List installed gems with newer versions available"
- long_desc <<-D
- Outdated lists the names and versions of gems that have a newer version available
- in the given source. Calling outdated with [GEM [GEM]] will only check for newer
- versions of the given gems. Prerelease gems are ignored by default. If your gems
- are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
-
- For more information on patch level options (--major, --minor, --patch,
- --update-strict) see documentation on the same options on the update command.
- D
- method_option "group", :type => :string, :banner => "List gems from a specific group"
- method_option "groups", :type => :boolean, :banner => "List gems organized by groups"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
- method_option "source", :type => :array, :banner => "Check against a specific source"
- strict_is_update = Bundler.feature_flag.forget_cli_options?
- method_option "filter-strict", :type => :boolean, :aliases => strict_is_update ? [] : %w[--strict], :banner =>
- "Only list newer versions allowed by your Gemfile requirements"
- method_option "update-strict", :type => :boolean, :aliases => strict_is_update ? %w[--strict] : [], :banner =>
- "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
- method_option "patch", :type => :boolean, :banner => "Prefer updating only to next patch version"
- method_option "filter-major", :type => :boolean, :banner => "Only list major newer versions"
- method_option "filter-minor", :type => :boolean, :banner => "Only list minor newer versions"
- method_option "filter-patch", :type => :boolean, :banner => "Only list patch newer versions"
- method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
- "Use minimal formatting for more parseable output"
- method_option "only-explicit", :type => :boolean, :banner =>
- "Only list gems specified in your Gemfile, not their dependencies"
- def outdated(*gems)
- require_relative "cli/outdated"
- Outdated.new(options, gems).run
- end
-
- desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
- unless Bundler.feature_flag.cache_all?
- method_option "all", :type => :boolean,
- :banner => "Include all sources (including path and git)."
- end
- method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
- method_option "cache-path", :type => :string, :banner =>
- "Specify a different cache path than the default (vendor/cache)."
- method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
- method_option "no-install", :type => :boolean, :banner => "Don't install the gems, only update the cache."
- method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
- method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors."
- method_option "frozen", :type => :boolean, :banner =>
- "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install"
- long_desc <<-D
- The cache command will copy the .gem files for every gem in the bundle into the
- directory ./vendor/cache. If you then check that directory into your source
- control repository, others who check out your source will be able to install the
- bundle without having to download any additional gems.
- D
- def cache
- require_relative "cli/cache"
- Cache.new(options).run
- end
-
- map aliases_for("cache")
-
- desc "exec [OPTIONS]", "Run the command in context of the bundle"
- method_option :keep_file_descriptors, :type => :boolean, :default => false
- method_option :gemfile, :type => :string, :required => false
- long_desc <<-D
- Exec runs a command, providing it access to the gems in the bundle. While using
- bundle exec you can require and call the bundled gems as if they were installed
- into the system wide RubyGems repository.
- D
- def exec(*args)
- require_relative "cli/exec"
- Exec.new(options, args).run
- end
-
- map aliases_for("exec")
-
- desc "config NAME [VALUE]", "Retrieve or set a configuration value"
- long_desc <<-D
- Retrieves or sets a configuration value. If only one parameter is provided, retrieve the value. If two parameters are provided, replace the
- existing value with the newly provided one.
-
- By default, setting a configuration value sets it for all projects
- on the machine.
-
- If a global setting is superceded by local configuration, this command
- will show the current value, as well as any superceded values and
- where they were specified.
- D
- require_relative "cli/config"
- subcommand "config", Config
-
- desc "open GEM", "Opens the source directory of the given bundled gem"
- def open(name)
- require_relative "cli/open"
- Open.new(options, name).run
- end
-
- unless Bundler.feature_flag.bundler_3_mode?
- desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
- def console(group = nil)
- require_relative "cli/console"
- Console.new(options, group).run
- end
- end
-
- desc "version", "Prints the bundler's version information"
- def version
- cli_help = current_command.name == "cli_help"
- if cli_help || ARGV.include?("version")
- build_info = " (#{BuildMetadata.built_at} commit #{BuildMetadata.git_commit_sha})"
- end
-
- if !cli_help && Bundler.feature_flag.print_only_version_number?
- Bundler.ui.info "#{Bundler::VERSION}#{build_info}"
- else
- Bundler.ui.info "Bundler version #{Bundler::VERSION}#{build_info}"
- end
- end
-
- map aliases_for("version")
-
- desc "licenses", "Prints the license of all gems in the bundle"
- def licenses
- Bundler.load.specs.sort_by {|s| s.license.to_s }.reverse_each do |s|
- gem_name = s.name
- license = s.license || s.licenses
-
- if license.empty?
- Bundler.ui.warn "#{gem_name}: Unknown"
- else
- Bundler.ui.info "#{gem_name}: #{license}"
- end
- end
- end
-
- unless Bundler.feature_flag.bundler_3_mode?
- desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true
- long_desc <<-D
- Viz generates a PNG file of the current Gemfile as a dependency graph.
- Viz requires the ruby-graphviz gem (and its dependencies).
- The associated gems must also be installed via 'bundle install'.
- D
- method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
- method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
- method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
- method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
- method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
- def viz
- SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
- require_relative "cli/viz"
- Viz.new(options.dup).run
- end
- end
-
- old_gem = instance_method(:gem)
-
- desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
- method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library."
- method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config set gem.coc true`."
- method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
- :lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
- :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
- method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code"
- method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
- method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set gem.mit true`."
- method_option :test, :type => :string, :lazy_default => "rspec", :aliases => "-t", :banner => "rspec",
- :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config set gem.test rspec`."
- def gem(name)
- end
-
- commands["gem"].tap do |gem_command|
- def gem_command.run(instance, args = [])
- arity = 1 # name
-
- require_relative "cli/gem"
- cmd_args = args + [instance]
- cmd_args.unshift(instance.options)
-
- cmd = begin
- Gem.new(*cmd_args)
- rescue ArgumentError => e
- instance.class.handle_argument_error(self, e, args, arity)
- end
-
- cmd.run
- end
- end
-
- undef_method(:gem)
- define_method(:gem, old_gem)
- private :gem
-
- def self.source_root
- File.expand_path(File.join(File.dirname(__FILE__), "templates"))
- end
-
- desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true
- method_option "dry-run", :type => :boolean, :default => false, :banner =>
- "Only print out changes, do not clean gems"
- method_option "force", :type => :boolean, :default => false, :banner =>
- "Forces clean even if --path is not set"
- def clean
- require_relative "cli/clean"
- Clean.new(options.dup).run
- end
-
- desc "platform [OPTIONS]", "Displays platform compatibility information"
- method_option "ruby", :type => :boolean, :default => false, :banner =>
- "only display ruby related platform information"
- def platform
- require_relative "cli/platform"
- Platform.new(options).run
- end
-
- desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", :hide => true
- method_option "source", :type => :string, :banner =>
- "Install gem from the given source"
- method_option "group", :type => :string, :banner =>
- "Install gem into a bundler group"
- def inject(name, version)
- SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
- require_relative "cli/inject"
- Inject.new(options.dup, name, version).run
- end
-
- desc "lock", "Creates a lockfile without installing"
- method_option "update", :type => :array, :lazy_default => true, :banner =>
- "ignore the existing lockfile, update all gems by default, or update list of given gems"
- method_option "local", :type => :boolean, :default => false, :banner =>
- "do not attempt to fetch remote gemspecs and use the local gem cache only"
- method_option "print", :type => :boolean, :default => false, :banner =>
- "print the lockfile to STDOUT instead of writing to the file system"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "lockfile", :type => :string, :default => nil, :banner =>
- "the path the lockfile should be written to"
- method_option "full-index", :type => :boolean, :default => false, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "add-platform", :type => :array, :default => [], :banner =>
- "Add a new platform to the lockfile"
- method_option "remove-platform", :type => :array, :default => [], :banner =>
- "Remove a platform from the lockfile"
- method_option "patch", :type => :boolean, :banner =>
- "If updating, prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :banner =>
- "If updating, prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner =>
- "If updating, prefer updating to next major version (default)"
- method_option "strict", :type => :boolean, :banner =>
- "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "conservative", :type => :boolean, :banner =>
- "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
- def lock
- require_relative "cli/lock"
- Lock.new(options).run
- end
-
- desc "env", "Print information about the environment Bundler is running under"
- def env
- Env.write($stdout)
- end
-
- desc "doctor [OPTIONS]", "Checks the bundle for common problems"
- long_desc <<-D
- Doctor scans the OS dependencies of each of the gems requested in the Gemfile. If
- missing dependencies are detected, Bundler prints them and exits status 1.
- Otherwise, Bundler prints a success message and exits with a status of 0.
- D
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- def doctor
- require_relative "cli/doctor"
- Doctor.new(options).run
- end
-
- desc "issue", "Learn how to report an issue in Bundler"
- def issue
- require_relative "cli/issue"
- Issue.new.run
- end
-
- desc "pristine [GEMS...]", "Restores installed gems to pristine condition"
- long_desc <<-D
- Restores installed gems to pristine condition from files located in the
- gem cache. Gems installed from a git repository will be issued `git
- checkout --force`.
- D
- def pristine(*gems)
- require_relative "cli/pristine"
- Pristine.new(gems).run
- end
-
- if Bundler.feature_flag.plugins?
- require_relative "cli/plugin"
- desc "plugin", "Manage the bundler plugins"
- subcommand "plugin", Plugin
- end
-
- # Reformat the arguments passed to bundle that include a --help flag
- # into the corresponding `bundle help #{command}` call
- def self.reformatted_help_args(args)
- bundler_commands = (COMMAND_ALIASES.keys + COMMAND_ALIASES.values).flatten
-
- help_flags = %w[--help -h]
- exec_commands = ["exec"] + COMMAND_ALIASES["exec"]
-
- help_used = args.index {|a| help_flags.include? a }
- exec_used = args.index {|a| exec_commands.include? a }
-
- command = args.find {|a| bundler_commands.include? a }
- command = all_aliases[command] if all_aliases[command]
-
- if exec_used && help_used
- if exec_used + help_used == 1
- %w[help exec]
- else
- args
- end
- elsif help_used
- args = args.dup
- args.delete_at(help_used)
- ["help", command || args].flatten.compact
- else
- args
- end
- end
-
- private
-
- # Automatically invoke `bundle install` and resume if
- # Bundler.settings[:auto_install] exists. This is set through config cmd
- # `bundle config set auto_install 1`.
- #
- # Note that this method `nil`s out the global Definition object, so it
- # should be called first, before you instantiate anything like an
- # `Installer` that'll keep a reference to the old one instead.
- def auto_install
- return unless Bundler.settings[:auto_install]
-
- begin
- Bundler.definition.specs
- rescue GemNotFound
- Bundler.ui.info "Automatically installing missing gems."
- Bundler.reset!
- invoke :install, []
- Bundler.reset!
- end
- end
-
- def current_command
- _, _, config = @_initializer
- config[:current_command]
- end
-
- def print_command
- return unless Bundler.ui.debug?
- cmd = current_command
- command_name = cmd.name
- return if PARSEABLE_COMMANDS.include?(command_name)
- command = ["bundle", command_name] + args
- options_to_print = options.dup
- options_to_print.delete_if do |k, v|
- next unless o = cmd.options[k]
- o.default == v
- end
- command << Thor::Options.to_switches(options_to_print.sort_by(&:first)).strip
- command.reject!(&:empty?)
- Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
- end
-
- def warn_on_outdated_bundler
- return if Bundler.settings[:disable_version_check]
-
- command_name = current_command.name
- return if PARSEABLE_COMMANDS.include?(command_name)
-
- return unless SharedHelpers.md5_available?
-
- latest = Fetcher::CompactIndex.
- new(nil, Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")), nil).
- send(:compact_index_client).
- instance_variable_get(:@cache).
- dependencies("bundler").
- map {|d| Gem::Version.new(d.first) }.
- max
- return unless latest
-
- current = Gem::Version.new(VERSION)
- return if current >= latest
- latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max
-
- installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`"
- if latest_installed && latest_installed > current
- suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`"
- suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest
- else
- suggestion = installation
- end
-
- Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
- rescue RuntimeError
- nil
- end
-
- def remembered_flag_deprecation(name)
- option = current_command.options[name]
- flag_name = option.switch_name
-
- name_index = ARGV.find {|arg| flag_name == arg }
- return unless name_index
-
- value = options[name]
- value = value.join(" ").to_s if option.type == :array
-
- Bundler::SharedHelpers.major_deprecation 2,\
- "The `#{flag_name}` flag is deprecated because it relies on being " \
- "remembered across bundler invocations, which bundler will no longer " \
- "do in future versions. Instead please use `bundle config set #{name} " \
- "'#{value}'`, and stop using this flag"
- end
- end
-end
diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb
deleted file mode 100644
index 07b951f1ef..0000000000
--- a/lib/bundler/cli/add.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Add
- attr_reader :gems, :options, :version
-
- def initialize(options, gems)
- @gems = gems
- @options = options
- @options[:group] = options[:group].split(",").map(&:strip) unless options[:group].nil?
- @version = options[:version].split(",").map(&:strip) unless options[:version].nil?
- end
-
- def run
- validate_options!
- inject_dependencies
- perform_bundle_install unless options["skip-install"]
- end
-
- private
-
- def perform_bundle_install
- Installer.install(Bundler.root, Bundler.definition)
- Bundler.load.cache if Bundler.app_cache.exist?
- end
-
- def inject_dependencies
- dependencies = gems.map {|g| Bundler::Dependency.new(g, version, options) }
-
- Injector.inject(dependencies,
- :conservative_versioning => options[:version].nil?, # Perform conservative versioning only when version is not specified
- :optimistic => options[:optimistic],
- :strict => options[:strict])
- end
-
- def validate_options!
- raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic]
-
- # raise error when no gems are specified
- raise InvalidOption, "Please specify gems to add." if gems.empty?
-
- version.to_a.each do |v|
- raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
- end
- end
- end
-end
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
deleted file mode 100644
index 266396eedc..0000000000
--- a/lib/bundler/cli/binstubs.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Binstubs
- attr_reader :options, :gems
- def initialize(options, gems)
- @options = options
- @gems = gems
- end
-
- def run
- Bundler.definition.validate_runtime!
- path_option = options["path"]
- path_option = nil if path_option && path_option.empty?
- Bundler.settings.set_command_option :bin, path_option if options["path"]
- Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
- installer = Installer.new(Bundler.root, Bundler.definition)
-
- installer_opts = { :force => options[:force], :binstubs_cmd => true }
-
- if options[:all]
- raise InvalidOption, "Cannot specify --all with specific gems" unless gems.empty?
- @gems = Bundler.definition.specs.map(&:name)
- installer_opts.delete(:binstubs_cmd)
- elsif gems.empty?
- Bundler.ui.error "`bundle binstubs` needs at least one gem to run."
- exit 1
- end
-
- gems.each do |gem_name|
- spec = Bundler.definition.specs.find {|s| s.name == gem_name }
- unless spec
- raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(
- gem_name, Bundler.definition.specs
- )
- end
-
- if options[:standalone]
- next Bundler.ui.warn("Sorry, Bundler can only be run via RubyGems.") if gem_name == "bundler"
- Bundler.settings.temporary(:path => (Bundler.settings[:path] || Bundler.root)) do
- installer.generate_standalone_bundler_executable_stubs(spec)
- end
- else
- installer.generate_bundler_executable_stubs(spec, installer_opts)
- end
- end
- end
- end
-end
diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb
deleted file mode 100644
index 5e8420990f..0000000000
--- a/lib/bundler/cli/cache.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Cache
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def run
- Bundler.ui.level = "error" if options[:quiet]
- Bundler.settings.set_command_option_if_given :path, options[:path]
- Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
-
- setup_cache_all
- install
-
- # TODO: move cache contents here now that all bundles are locked
- custom_path = Bundler.settings[:path] if options[:path]
-
- Bundler.settings.temporary(:cache_all_platforms => options["all-platforms"]) do
- Bundler.load.cache(custom_path)
- end
- end
-
- private
-
- def install
- require_relative "install"
- options = self.options.dup
- options["local"] = false if Bundler.settings[:cache_all_platforms]
- Bundler::CLI::Install.new(options).run
- end
-
- def setup_cache_all
- all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil)
-
- Bundler.settings.set_command_option_if_given :cache_all, all
-
- if Bundler.definition.has_local_dependencies? && !Bundler.feature_flag.cache_all?
- Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
- "to cache them as well, please pass the --all flag. This will be the default " \
- "on Bundler 3.0."
- end
- end
- end
-end
diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb
deleted file mode 100644
index 19c0aaea06..0000000000
--- a/lib/bundler/cli/check.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Check
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def run
- Bundler.settings.set_command_option_if_given :path, options[:path]
-
- begin
- definition = Bundler.definition
- definition.validate_runtime!
- not_installed = definition.missing_specs
- rescue GemNotFound, VersionConflict
- Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
- Bundler.ui.warn "Install missing gems with `bundle install`."
- exit 1
- end
-
- if not_installed.any?
- Bundler.ui.error "The following gems are missing"
- not_installed.each {|s| Bundler.ui.error " * #{s.name} (#{s.version})" }
- Bundler.ui.warn "Install missing gems with `bundle install`"
- exit 1
- elsif !Bundler.default_lockfile.file? && Bundler.frozen_bundle?
- Bundler.ui.error "This bundle has been frozen, but there is no #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} present"
- exit 1
- else
- Bundler.load.lock(:preserve_unknown_sections => true) unless options[:"dry-run"]
- Bundler.ui.info "The Gemfile's dependencies are satisfied"
- end
- end
- end
-end
diff --git a/lib/bundler/cli/clean.rb b/lib/bundler/cli/clean.rb
deleted file mode 100644
index 4a407fbae7..0000000000
--- a/lib/bundler/cli/clean.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Clean
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def run
- require_path_or_force unless options[:"dry-run"]
- Bundler.load.clean(options[:"dry-run"])
- end
-
- protected
-
- def require_path_or_force
- return unless Bundler.use_system_gems? && !options[:force]
- raise InvalidOption, "Cleaning all the gems on your system is dangerous! " \
- "If you're sure you want to remove every system gem not in this " \
- "bundle, run `bundle clean --force`."
- end
- end
-end
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
deleted file mode 100644
index cec7bcadb4..0000000000
--- a/lib/bundler/cli/common.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module CLI::Common
- def self.output_post_install_messages(messages)
- return if Bundler.settings["ignore_messages"]
- messages.to_a.each do |name, msg|
- print_post_install_message(name, msg) unless Bundler.settings["ignore_messages.#{name}"]
- end
- end
-
- def self.print_post_install_message(name, msg)
- Bundler.ui.confirm "Post-install message from #{name}:"
- Bundler.ui.info msg
- end
-
- def self.output_without_groups_message(command)
- return if Bundler.settings[:without].empty?
- Bundler.ui.confirm without_groups_message(command)
- end
-
- def self.without_groups_message(command)
- command_in_past_tense = command == :install ? "installed" : "updated"
- groups = Bundler.settings[:without]
- group_list = [groups[0...-1].join(", "), groups[-1..-1]].
- reject {|s| s.to_s.empty? }.join(" and ")
- group_str = groups.size == 1 ? "group" : "groups"
- "Gems in the #{group_str} #{group_list} were not #{command_in_past_tense}."
- end
-
- def self.select_spec(name, regex_match = nil)
- specs = []
- regexp = Regexp.new(name) if regex_match
-
- Bundler.definition.specs.each do |spec|
- return spec if spec.name == name
- specs << spec if regexp && spec.name =~ regexp
- end
-
- case specs.count
- when 0
- raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
- when 1
- specs.first
- else
- ask_for_spec_from(specs)
- end
- rescue RegexpError
- raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
- end
-
- def self.ask_for_spec_from(specs)
- specs.each_with_index do |spec, index|
- Bundler.ui.info "#{index.succ} : #{spec.name}", true
- end
- Bundler.ui.info "0 : - exit -", true
-
- num = Bundler.ui.ask("> ").to_i
- num > 0 ? specs[num - 1] : nil
- end
-
- def self.gem_not_found_message(missing_gem_name, alternatives)
- require_relative "../similarity_detector"
- message = "Could not find gem '#{missing_gem_name}'."
- alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a }
- suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)
- message += "\nDid you mean #{suggestions}?" if suggestions
- message
- end
-
- def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
- locked_names = locked_gems.specs.map(&:name).uniq
- names.-(locked_names).each do |g|
- raise GemNotFound, gem_not_found_message(g, locked_names)
- end
- end
-
- def self.configure_gem_version_promoter(definition, options)
- patch_level = patch_level_options(options)
- patch_level << :patch if patch_level.empty? && Bundler.settings[:prefer_patch]
- raise InvalidOption, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1
-
- definition.gem_version_promoter.tap do |gvp|
- gvp.level = patch_level.first || :major
- gvp.strict = options[:strict] || options["update-strict"] || options["filter-strict"]
- end
- end
-
- def self.patch_level_options(options)
- [:major, :minor, :patch].select {|v| options.keys.include?(v.to_s) }
- end
-
- def self.clean_after_install?
- clean = Bundler.settings[:clean]
- return clean unless clean.nil?
- clean ||= Bundler.feature_flag.auto_clean_without_path? && Bundler.settings[:path].nil?
- clean &&= !Bundler.use_system_gems?
- clean
- end
- end
-end
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb
deleted file mode 100644
index 8d2aba0916..0000000000
--- a/lib/bundler/cli/config.rb
+++ /dev/null
@@ -1,194 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Config < Thor
- class_option :parseable, :type => :boolean, :banner => "Use minimal formatting for more parseable output"
-
- def self.scope_options
- method_option :global, :type => :boolean, :banner => "Only change the global config"
- method_option :local, :type => :boolean, :banner => "Only change the local config"
- end
- private_class_method :scope_options
-
- desc "base NAME [VALUE]", "The Bundler 1 config interface", :hide => true
- scope_options
- method_option :delete, :type => :boolean, :banner => "delete"
- def base(name = nil, *value)
- new_args =
- if ARGV.size == 1
- ["config", "list"]
- elsif ARGV.include?("--delete")
- ARGV.map {|arg| arg == "--delete" ? "unset" : arg }
- elsif ARGV.include?("--global") || ARGV.include?("--local") || ARGV.size == 3
- ["config", "set", *ARGV[1..-1]]
- else
- ["config", "get", ARGV[1]]
- end
-
- SharedHelpers.major_deprecation 3,
- "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
-
- Base.new(options, name, value, self).run
- end
-
- desc "list", "List out all configured settings"
- def list
- Base.new(options, nil, nil, self).run
- end
-
- desc "get NAME", "Returns the value for the given key"
- def get(name)
- Base.new(options, name, nil, self).run
- end
-
- desc "set NAME VALUE", "Sets the given value for the given key"
- scope_options
- def set(name, value, *value_)
- Base.new(options, name, value_.unshift(value), self).run
- end
-
- desc "unset NAME", "Unsets the value for the given key"
- scope_options
- def unset(name)
- options[:delete] = true
- Base.new(options, name, nil, self).run
- end
-
- default_task :base
-
- class Base
- attr_reader :name, :value, :options, :scope, :thor
-
- def initialize(options, name, value, thor)
- @options = options
- @name = name
- value = Array(value)
- @value = value.empty? ? nil : value.join(" ")
- @thor = thor
- validate_scope!
- end
-
- def run
- unless name
- warn_unused_scope "Ignoring --#{scope}"
- confirm_all
- return
- end
-
- if options[:delete]
- if !explicit_scope? || scope != "global"
- Bundler.settings.set_local(name, nil)
- end
- if !explicit_scope? || scope != "local"
- Bundler.settings.set_global(name, nil)
- end
- return
- end
-
- if value.nil?
- warn_unused_scope "Ignoring --#{scope} since no value to set was given"
-
- if options[:parseable]
- if value = Bundler.settings[name]
- Bundler.ui.info("#{name}=#{value}")
- end
- return
- end
-
- confirm(name)
- return
- end
-
- Bundler.ui.info(message) if message
- Bundler.settings.send("set_#{scope}", name, new_value)
- end
-
- def confirm_all
- if @options[:parseable]
- thor.with_padding do
- Bundler.settings.all.each do |setting|
- val = Bundler.settings[setting]
- Bundler.ui.info "#{setting}=#{val}"
- end
- end
- else
- Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
- Bundler.settings.all.each do |setting|
- Bundler.ui.confirm setting
- show_pretty_values_for(setting)
- Bundler.ui.confirm ""
- end
- end
- end
-
- def confirm(name)
- Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
- show_pretty_values_for(name)
- end
-
- def new_value
- pathname = Pathname.new(value)
- if name.start_with?("local.") && pathname.directory?
- pathname.expand_path.to_s
- else
- value
- end
- end
-
- def message
- locations = Bundler.settings.locations(name)
- if @options[:parseable]
- "#{name}=#{new_value}" if new_value
- elsif scope == "global"
- if !locations[:local].nil?
- "Your application has set #{name} to #{locations[:local].inspect}. " \
- "This will override the global value you are currently setting"
- elsif locations[:env]
- "You have a bundler environment variable for #{name} set to " \
- "#{locations[:env].inspect}. This will take precedence over the global value you are setting"
- elsif !locations[:global].nil? && locations[:global] != value
- "You are replacing the current global value of #{name}, which is currently " \
- "#{locations[:global].inspect}"
- end
- elsif scope == "local" && !locations[:local].nil? && locations[:local] != value
- "You are replacing the current local value of #{name}, which is currently " \
- "#{locations[:local].inspect}"
- end
- end
-
- def show_pretty_values_for(setting)
- thor.with_padding do
- Bundler.settings.pretty_values_for(setting).each do |line|
- Bundler.ui.info line
- end
- end
- end
-
- def explicit_scope?
- @explicit_scope
- end
-
- def warn_unused_scope(msg)
- return unless explicit_scope?
- return if options[:parseable]
-
- Bundler.ui.warn(msg)
- end
-
- def validate_scope!
- @explicit_scope = true
- scopes = %w[global local].select {|s| options[s] }
- case scopes.size
- when 0
- @scope = "global"
- @explicit_scope = false
- when 1
- @scope = scopes.first
- else
- raise InvalidOption,
- "The options #{scopes.join " and "} were specified. Please only use one of the switches at a time."
- end
- end
- end
- end
-end
diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb
deleted file mode 100644
index 6e0dfe28af..0000000000
--- a/lib/bundler/cli/console.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Console
- attr_reader :options, :group
- def initialize(options, group)
- @options = options
- @group = group
- end
-
- def run
- Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
- "by `bin/console` generated by `bundle gem <name>`"
-
- group ? Bundler.require(:default, *group.split.map!(&:to_sym)) : Bundler.require
- ARGV.clear
-
- console = get_console(Bundler.settings[:console] || "irb")
- console.start
- end
-
- def get_console(name)
- require name
- get_constant(name)
- rescue LoadError
- Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
- require "irb"
- get_constant("irb")
- end
-
- def get_constant(name)
- const_name = {
- "pry" => :Pry,
- "ripl" => :Ripl,
- "irb" => :IRB,
- }[name]
- Object.const_get(const_name)
- rescue NameError
- Bundler.ui.error "Could not find constant #{const_name}"
- exit 1
- end
- end
-end
diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb
deleted file mode 100644
index fcf139ed1e..0000000000
--- a/lib/bundler/cli/doctor.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# frozen_string_literal: true
-
-require "rbconfig"
-
-module Bundler
- class CLI::Doctor
- DARWIN_REGEX = /\s+(.+) \(compatibility /.freeze
- LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/.freeze
-
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def otool_available?
- Bundler.which("otool")
- end
-
- def ldd_available?
- Bundler.which("ldd")
- end
-
- def dylibs_darwin(path)
- output = `/usr/bin/otool -L "#{path}"`.chomp
- dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
- # ignore @rpath and friends
- dylibs.reject {|dylib| dylib.start_with? "@" }
- end
-
- def dylibs_ldd(path)
- output = `/usr/bin/ldd "#{path}"`.chomp
- output.split("\n").map do |l|
- match = l.match(LDD_REGEX)
- next if match.nil?
- match.captures[0]
- end.compact
- end
-
- def dylibs(path)
- case RbConfig::CONFIG["host_os"]
- when /darwin/
- return [] unless otool_available?
- dylibs_darwin(path)
- when /(linux|solaris|bsd)/
- return [] unless ldd_available?
- dylibs_ldd(path)
- else # Windows, etc.
- Bundler.ui.warn("Dynamic library check not supported on this platform.")
- []
- end
- end
-
- def bundles_for_gem(spec)
- Dir.glob("#{spec.full_gem_path}/**/*.bundle")
- end
-
- def check!
- require_relative "check"
- Bundler::CLI::Check.new({}).run
- end
-
- def run
- Bundler.ui.level = "error" if options[:quiet]
- Bundler.settings.validate!
- check!
-
- definition = Bundler.definition
- broken_links = {}
-
- definition.specs.each do |spec|
- bundles_for_gem(spec).each do |bundle|
- bad_paths = dylibs(bundle).select {|f| !File.exist?(f) }
- if bad_paths.any?
- broken_links[spec] ||= []
- broken_links[spec].concat(bad_paths)
- end
- end
- end
-
- permissions_valid = check_home_permissions
-
- if broken_links.any?
- message = "The following gems are missing OS dependencies:"
- broken_links.map do |spec, paths|
- paths.uniq.map do |path|
- "\n * #{spec.name}: #{path}"
- end
- end.flatten.sort.each {|m| message += m }
- raise ProductionError, message
- elsif !permissions_valid
- Bundler.ui.info "No issues found with the installed bundle"
- end
- end
-
- private
-
- def check_home_permissions
- require "find"
- files_not_readable_or_writable = []
- files_not_rw_and_owned_by_different_user = []
- files_not_owned_by_current_user_but_still_rw = []
- Find.find(Bundler.bundle_path.to_s).each do |f|
- if !File.writable?(f) || !File.readable?(f)
- if File.stat(f).uid != Process.uid
- files_not_rw_and_owned_by_different_user << f
- else
- files_not_readable_or_writable << f
- end
- elsif File.stat(f).uid != Process.uid
- files_not_owned_by_current_user_but_still_rw << f
- end
- end
-
- ok = true
- if files_not_owned_by_current_user_but_still_rw.any?
- Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
- "user, but are still readable/writable. These files are:\n - #{files_not_owned_by_current_user_but_still_rw.join("\n - ")}"
-
- ok = false
- end
-
- if files_not_rw_and_owned_by_different_user.any?
- Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
- "user, and are not readable/writable. These files are:\n - #{files_not_rw_and_owned_by_different_user.join("\n - ")}"
-
- ok = false
- end
-
- if files_not_readable_or_writable.any?
- Bundler.ui.warn "Files exist in the Bundler home that are not " \
- "readable/writable by the current user. These files are:\n - #{files_not_readable_or_writable.join("\n - ")}"
-
- ok = false
- end
-
- ok
- end
- end
-end
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb
deleted file mode 100644
index 0a1edbdbbd..0000000000
--- a/lib/bundler/cli/exec.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../current_ruby"
-
-module Bundler
- class CLI::Exec
- attr_reader :options, :args, :cmd
-
- TRAPPED_SIGNALS = %w[INT].freeze
-
- def initialize(options, args)
- @options = options
- @cmd = args.shift
- @args = args
-
- if !Bundler.current_ruby.jruby?
- @args << { :close_others => !options.keep_file_descriptors? }
- elsif options.keep_file_descriptors?
- Bundler.ui.warn "Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec."
- end
- end
-
- def run
- validate_cmd!
- SharedHelpers.set_bundle_environment
- if bin_path = Bundler.which(cmd)
- if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path)
- return kernel_load(bin_path, *args)
- end
- kernel_exec(bin_path, *args)
- else
- # exec using the given command
- kernel_exec(cmd, *args)
- end
- end
-
- private
-
- def validate_cmd!
- return unless cmd.nil?
- Bundler.ui.error "bundler: exec needs a command to run"
- exit 128
- end
-
- def kernel_exec(*args)
- Kernel.exec(*args)
- rescue Errno::EACCES, Errno::ENOEXEC
- Bundler.ui.error "bundler: not executable: #{cmd}"
- exit 126
- rescue Errno::ENOENT
- Bundler.ui.error "bundler: command not found: #{cmd}"
- Bundler.ui.warn "Install missing gem executables with `bundle install`"
- exit 127
- end
-
- def kernel_load(file, *args)
- args.pop if args.last.is_a?(Hash)
- ARGV.replace(args)
- $0 = file
- Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle)
- require_relative "../setup"
- TRAPPED_SIGNALS.each {|s| trap(s, "DEFAULT") }
- Kernel.load(file)
- rescue SystemExit, SignalException
- raise
- rescue Exception => e # rubocop:disable Lint/RescueException
- Bundler.ui.error "bundler: failed to load command: #{cmd} (#{file})"
- backtrace = e.backtrace ? e.backtrace.take_while {|bt| !bt.start_with?(__FILE__) } : []
- abort "#{e.class}: #{e.message}\n #{backtrace.join("\n ")}"
- end
-
- def process_title(file, args)
- "#{file} #{args.join(" ")}".strip
- end
-
- def ruby_shebang?(file)
- possibilities = [
- "#!/usr/bin/env ruby\n",
- "#!/usr/bin/env jruby\n",
- "#!/usr/bin/env truffleruby\n",
- "#!#{Gem.ruby}\n",
- ]
-
- if File.zero?(file)
- Bundler.ui.warn "#{file} is empty"
- return false
- end
-
- first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) }
- possibilities.any? {|shebang| first_line.start_with?(shebang) }
- end
- end
-end
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
deleted file mode 100644
index d3e5831759..0000000000
--- a/lib/bundler/cli/gem.rb
+++ /dev/null
@@ -1,252 +0,0 @@
-# frozen_string_literal: true
-
-require "pathname"
-
-module Bundler
- class CLI
- Bundler.require_thor_actions
- include Thor::Actions
- end
-
- class CLI::Gem
- TEST_FRAMEWORK_VERSIONS = {
- "rspec" => "3.0",
- "minitest" => "5.0",
- }.freeze
-
- attr_reader :options, :gem_name, :thor, :name, :target
-
- def initialize(options, gem_name, thor)
- @options = options
- @gem_name = resolve_name(gem_name)
-
- @thor = thor
- thor.behavior = :invoke
- thor.destination_root = nil
-
- @name = @gem_name
- @target = SharedHelpers.pwd.join(gem_name)
-
- validate_ext_name if options[:ext]
- end
-
- def run
- Bundler.ui.confirm "Creating gem '#{name}'..."
-
- underscored_name = name.tr("-", "_")
- namespaced_path = name.tr("-", "/")
- constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
- constant_array = constant_name.split("::")
-
- git_installed = Bundler.git_present?
-
- git_author_name = git_installed ? `git config user.name`.chomp : ""
- github_username = git_installed ? `git config github.user`.chomp : ""
- git_user_email = git_installed ? `git config user.email`.chomp : ""
-
- config = {
- :name => name,
- :underscored_name => underscored_name,
- :namespaced_path => namespaced_path,
- :makefile_path => "#{underscored_name}/#{underscored_name}",
- :constant_name => constant_name,
- :constant_array => constant_array,
- :author => git_author_name.empty? ? "TODO: Write your name" : git_author_name,
- :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
- :test => options[:test],
- :ext => options[:ext],
- :exe => options[:exe],
- :bundler_version => bundler_dependency_version,
- :github_username => github_username.empty? ? "[USERNAME]" : github_username,
- }
- ensure_safe_gem_name(name, constant_array)
-
- templates = {
- "Gemfile.tt" => "Gemfile",
- "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
- "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
- "newgem.gemspec.tt" => "#{name}.gemspec",
- "Rakefile.tt" => "Rakefile",
- "README.md.tt" => "README.md",
- "bin/console.tt" => "bin/console",
- "bin/setup.tt" => "bin/setup",
- }
-
- executables = %w[
- bin/console
- bin/setup
- ]
-
- templates.merge!("gitignore.tt" => ".gitignore") if Bundler.git_present?
-
- if test_framework = ask_and_set_test_framework
- config[:test] = test_framework
- config[:test_framework_version] = TEST_FRAMEWORK_VERSIONS[test_framework]
-
- templates.merge!("travis.yml.tt" => ".travis.yml")
-
- case test_framework
- when "rspec"
- templates.merge!(
- "rspec.tt" => ".rspec",
- "spec/spec_helper.rb.tt" => "spec/spec_helper.rb",
- "spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
- )
- when "minitest"
- templates.merge!(
- "test/test_helper.rb.tt" => "test/test_helper.rb",
- "test/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
- )
- end
- end
-
- config[:test_task] = config[:test] == "minitest" ? "test" : "spec"
-
- if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
- "This means that any other developer or company will be legally allowed to use your code " \
- "for free as long as they admit you created it. You can read more about the MIT license " \
- "at https://choosealicense.com/licenses/mit.")
- config[:mit] = true
- Bundler.ui.info "MIT License enabled in config"
- templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
- end
-
- if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
- "Codes of conduct can increase contributions to your project by contributors who " \
- "prefer collaborative, safe spaces. You can read more about the code of conduct at " \
- "contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \
- "of enforcing it, so be sure that you are prepared to do that. Be sure that your email " \
- "address is specified as a contact in the generated code of conduct so that people know " \
- "who to contact in case of a violation. For suggestions about " \
- "how to enforce codes of conduct, see https://bit.ly/coc-enforcement.")
- config[:coc] = true
- Bundler.ui.info "Code of conduct enabled in config"
- templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
- end
-
- templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
-
- if options[:ext]
- templates.merge!(
- "ext/newgem/extconf.rb.tt" => "ext/#{name}/extconf.rb",
- "ext/newgem/newgem.h.tt" => "ext/#{name}/#{underscored_name}.h",
- "ext/newgem/newgem.c.tt" => "ext/#{name}/#{underscored_name}.c"
- )
- end
-
- templates.each do |src, dst|
- destination = target.join(dst)
- SharedHelpers.filesystem_access(destination) do
- thor.template("newgem/#{src}", destination, config)
- end
- end
-
- executables.each do |file|
- SharedHelpers.filesystem_access(target.join(file)) do |path|
- executable = (path.stat.mode | 0o111)
- path.chmod(executable)
- end
- end
-
- if Bundler.git_present? && options[:git]
- Bundler.ui.info "Initializing git repo in #{target}"
- Dir.chdir(target) do
- `git init`
- `git add .`
- end
- end
-
- # Open gemspec in editor
- open_editor(options["edit"], target.join("#{name}.gemspec")) if options[:edit]
-
- Bundler.ui.info "Gem '#{name}' was successfully created. " \
- "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
- rescue Errno::EEXIST => e
- raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.")
- end
-
- private
-
- def resolve_name(name)
- SharedHelpers.pwd.join(name).basename.to_s
- end
-
- def ask_and_set(key, header, message)
- choice = options[key]
- choice = Bundler.settings["gem.#{key}"] if choice.nil?
-
- if choice.nil?
- Bundler.ui.confirm header
- choice = Bundler.ui.yes? "#{message} y/(n):"
- Bundler.settings.set_global("gem.#{key}", choice)
- end
-
- choice
- end
-
- def validate_ext_name
- return unless gem_name.index("-")
-
- Bundler.ui.error "You have specified a gem name which does not conform to the \n" \
- "naming guidelines for C extensions. For more information, \n" \
- "see the 'Extension Naming' section at the following URL:\n" \
- "https://guides.rubygems.org/gems-with-extensions/\n"
- exit 1
- end
-
- def ask_and_set_test_framework
- test_framework = options[:test] || Bundler.settings["gem.test"]
-
- if test_framework.nil?
- Bundler.ui.confirm "Do you want to generate tests with your gem?"
- result = Bundler.ui.ask "Type 'rspec' or 'minitest' to generate those test files now and " \
- "in the future. rspec/minitest/(none):"
- if result =~ /rspec|minitest/
- test_framework = result
- else
- test_framework = false
- end
- end
-
- if Bundler.settings["gem.test"].nil?
- Bundler.settings.set_global("gem.test", test_framework)
- end
-
- test_framework
- end
-
- def bundler_dependency_version
- v = Gem::Version.new(Bundler::VERSION)
- req = v.segments[0..1]
- req << "a" if v.prerelease?
- req.join(".")
- end
-
- def ensure_safe_gem_name(name, constant_array)
- if name =~ /^\d/
- Bundler.ui.error "Invalid gem name #{name} Please give a name which does not start with numbers."
- exit 1
- end
-
- constant_name = constant_array.join("::")
-
- existing_constant = constant_array.inject(Object) do |c, s|
- defined = begin
- c.const_defined?(s)
- rescue NameError
- Bundler.ui.error "Invalid gem name #{name} -- `#{constant_name}` is an invalid constant name"
- exit 1
- end
- (defined && c.const_get(s)) || break
- end
-
- return unless existing_constant
- Bundler.ui.error "Invalid gem name #{name} constant #{constant_name} is already in use. Please choose another gem name."
- exit 1
- end
-
- def open_editor(editor, file)
- thor.run(%(#{editor} "#{file}"))
- end
- end
-end
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb
deleted file mode 100644
index 4733675e8c..0000000000
--- a/lib/bundler/cli/info.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Info
- attr_reader :gem_name, :options
- def initialize(options, gem_name)
- @options = options
- @gem_name = gem_name
- end
-
- def run
- Bundler.ui.silence do
- Bundler.definition.validate_runtime!
- Bundler.load.lock
- end
-
- spec = spec_for_gem(gem_name)
-
- if spec
- return print_gem_path(spec) if @options[:path]
- print_gem_info(spec)
- end
- end
-
- private
-
- def spec_for_gem(gem_name)
- spec = Bundler.definition.specs.find {|s| s.name == gem_name }
- spec || default_gem_spec(gem_name) || Bundler::CLI::Common.select_spec(gem_name, :regex_match)
- end
-
- def default_gem_spec(gem_name)
- return unless Gem::Specification.respond_to?(:find_all_by_name)
- gem_spec = Gem::Specification.find_all_by_name(gem_name).last
- return gem_spec if gem_spec && gem_spec.respond_to?(:default_gem?) && gem_spec.default_gem?
- end
-
- def spec_not_found(gem_name)
- raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
- end
-
- def print_gem_path(spec)
- path = if spec.name == "bundler"
- File.expand_path("../../../..", __FILE__)
- else
- spec.full_gem_path
- end
-
- Bundler.ui.info path
- end
-
- def print_gem_info(spec)
- gem_info = String.new
- gem_info << " * #{spec.name} (#{spec.version}#{spec.git_version})\n"
- gem_info << "\tSummary: #{spec.summary}\n" if spec.summary
- gem_info << "\tHomepage: #{spec.homepage}\n" if spec.homepage
- gem_info << "\tPath: #{spec.full_gem_path}\n"
- gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem?
- Bundler.ui.info gem_info
- end
- end
-end
diff --git a/lib/bundler/cli/init.rb b/lib/bundler/cli/init.rb
deleted file mode 100644
index 65dd08dfe9..0000000000
--- a/lib/bundler/cli/init.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Init
- attr_reader :options
- def initialize(options)
- @options = options
- end
-
- def run
- if File.exist?(gemfile)
- Bundler.ui.error "#{gemfile} already exists at #{File.expand_path(gemfile)}"
- exit 1
- end
-
- unless File.writable?(Dir.pwd)
- Bundler.ui.error "Can not create #{gemfile} as the current directory is not writable."
- exit 1
- end
-
- if options[:gemspec]
- gemspec = File.expand_path(options[:gemspec])
- unless File.exist?(gemspec)
- Bundler.ui.error "Gem specification #{gemspec} doesn't exist"
- exit 1
- end
-
- spec = Bundler.load_gemspec_uncached(gemspec)
-
- File.open(gemfile, "wb") do |file|
- file << "# Generated from #{gemspec}\n"
- file << spec.to_gemfile
- end
- else
- FileUtils.cp(File.expand_path("../../templates/#{gemfile}", __FILE__), gemfile)
- end
-
- puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}"
- end
-
- private
-
- def gemfile
- @gemfile ||= Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
- end
- end
-end
diff --git a/lib/bundler/cli/inject.rb b/lib/bundler/cli/inject.rb
deleted file mode 100644
index b00675d348..0000000000
--- a/lib/bundler/cli/inject.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Inject
- attr_reader :options, :name, :version, :group, :source, :gems
- def initialize(options, name, version)
- @options = options
- @name = name
- @version = version || last_version_number
- @group = options[:group].split(",") unless options[:group].nil?
- @source = options[:source]
- @gems = []
- end
-
- def run
- # The required arguments allow Thor to give useful feedback when the arguments
- # are incorrect. This adds those first two arguments onto the list as a whole.
- gems.unshift(source).unshift(group).unshift(version).unshift(name)
-
- # Build an array of Dependency objects out of the arguments
- deps = []
- # when `inject` support addition of more than one gem, then this loop will
- # help. Currently this loop is running once.
- gems.each_slice(4) do |gem_name, gem_version, gem_group, gem_source|
- ops = Gem::Requirement::OPS.map {|key, _val| key }
- has_op = ops.any? {|op| gem_version.start_with? op }
- gem_version = "~> #{gem_version}" unless has_op
- deps << Bundler::Dependency.new(gem_name, gem_version, "group" => gem_group, "source" => gem_source)
- end
-
- added = Injector.inject(deps, options)
-
- if added.any?
- Bundler.ui.confirm "Added to Gemfile:"
- Bundler.ui.confirm(added.map do |d|
- name = "'#{d.name}'"
- requirement = ", '#{d.requirement}'"
- group = ", :group => #{d.groups.inspect}" if d.groups != Array(:default)
- source = ", :source => '#{d.source}'" unless d.source.nil?
- %(gem #{name}#{requirement}#{group}#{source})
- end.join("\n"))
- else
- Bundler.ui.confirm "All gems were already present in the Gemfile"
- end
- end
-
- private
-
- def last_version_number
- definition = Bundler.definition(true)
- definition.resolve_remotely!
- specs = definition.index[name].sort_by(&:version)
- unless options[:pre]
- specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
- end
- spec = specs.last
- spec.version.to_s
- end
- end
-end
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
deleted file mode 100644
index ecd474971d..0000000000
--- a/lib/bundler/cli/install.rb
+++ /dev/null
@@ -1,219 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Install
- attr_reader :options
- def initialize(options)
- @options = options
- end
-
- def run
- Bundler.ui.level = "error" if options[:quiet]
-
- warn_if_root
-
- normalize_groups
-
- Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
-
- # Disable color in deployment mode
- Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
-
- check_for_options_conflicts
-
- check_trust_policy
-
- if options[:deployment] || options[:frozen] || Bundler.frozen_bundle?
- unless Bundler.default_lockfile.exist?
- flag = "--deployment flag" if options[:deployment]
- flag ||= "--frozen flag" if options[:frozen]
- flag ||= "deployment setting"
- raise ProductionError, "The #{flag} requires a #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}. Please make " \
- "sure you have checked your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} into version control " \
- "before deploying."
- end
-
- options[:local] = true if Bundler.app_cache.exist?
-
- if Bundler.feature_flag.deployment_means_frozen?
- Bundler.settings.set_command_option :deployment, true
- else
- Bundler.settings.set_command_option :deployment, true if options[:deployment]
- Bundler.settings.set_command_option :frozen, true if options[:frozen]
- end
- end
-
- # When install is called with --no-deployment, disable deployment mode
- if options[:deployment] == false
- Bundler.settings.set_command_option :frozen, nil
- options[:system] = true
- end
-
- normalize_settings
-
- Bundler::Fetcher.disable_endpoint = options["full-index"]
-
- if options["binstubs"]
- Bundler::SharedHelpers.major_deprecation 2,
- "The --binstubs option will be removed in favor of `bundle binstubs`"
- end
-
- Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
-
- definition = Bundler.definition
- definition.validate_runtime!
-
- installer = Installer.install(Bundler.root, definition, options)
- Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
-
- Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
- Bundler::CLI::Common.output_without_groups_message(:install)
-
- if Bundler.use_system_gems?
- Bundler.ui.confirm "Use `bundle info [gemname]` to see where a bundled gem is installed."
- else
- relative_path = Bundler.configured_bundle_path.base_path_relative_to_pwd
- Bundler.ui.confirm "Bundled gems are installed into `#{relative_path}`"
- end
-
- Bundler::CLI::Common.output_post_install_messages installer.post_install_messages
-
- warn_ambiguous_gems
-
- if CLI::Common.clean_after_install?
- require_relative "clean"
- Bundler::CLI::Clean.new(options).run
- end
- rescue GemNotFound, VersionConflict => e
- if options[:local] && Bundler.app_cache.exist?
- Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
- end
-
- unless Bundler.definition.has_rubygems_remotes?
- Bundler.ui.warn <<-WARN, :wrap => true
- Your Gemfile has no gem server sources. If you need gems that are \
- not already on your machine, add a line like this to your Gemfile:
- source 'https://rubygems.org'
- WARN
- end
- raise e
- rescue Gem::InvalidSpecificationException => e
- Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed."
- raise e
- end
-
- private
-
- def warn_if_root
- return if Bundler.settings[:silence_root_warning] || Bundler::WINDOWS || !Process.uid.zero?
- Bundler.ui.warn "Don't run Bundler as root. Bundler can ask for sudo " \
- "if it is needed, and installing your bundle as root will break this " \
- "application for all non-root users on this machine.", :wrap => true
- end
-
- def dependencies_count_for(definition)
- count = definition.dependencies.count
- "#{count} Gemfile #{count == 1 ? "dependency" : "dependencies"}"
- end
-
- def gems_installed_for(definition)
- count = definition.specs.count
- "#{count} #{count == 1 ? "gem" : "gems"} now installed"
- end
-
- def check_for_group_conflicts_in_cli_options
- conflicting_groups = Array(options[:without]) & Array(options[:with])
- return if conflicting_groups.empty?
- raise InvalidOption, "You can't list a group in both with and without." \
- " The offending groups are: #{conflicting_groups.join(", ")}."
- end
-
- def check_for_options_conflicts
- if (options[:path] || options[:deployment]) && options[:system]
- error_message = String.new
- error_message << "You have specified both --path as well as --system. Please choose only one option.\n" if options[:path]
- error_message << "You have specified both --deployment as well as --system. Please choose only one option.\n" if options[:deployment]
- raise InvalidOption.new(error_message)
- end
- end
-
- def check_trust_policy
- trust_policy = options["trust-policy"]
- unless Bundler.rubygems.security_policies.keys.unshift(nil).include?(trust_policy)
- raise InvalidOption, "RubyGems doesn't know about trust policy '#{trust_policy}'. " \
- "The known policies are: #{Bundler.rubygems.security_policies.keys.join(", ")}."
- end
- Bundler.settings.set_command_option_if_given :"trust-policy", trust_policy
- end
-
- def normalize_groups
- options[:with] &&= options[:with].join(":").tr(" ", ":").split(":")
- options[:without] &&= options[:without].join(":").tr(" ", ":").split(":")
-
- check_for_group_conflicts_in_cli_options
-
- Bundler.settings.set_command_option :with, nil if options[:with] == []
- Bundler.settings.set_command_option :without, nil if options[:without] == []
-
- with = options.fetch(:with, [])
- with |= Bundler.settings[:with].map(&:to_s)
- with -= options[:without] if options[:without]
-
- without = options.fetch(:without, [])
- without |= Bundler.settings[:without].map(&:to_s)
- without -= options[:with] if options[:with]
-
- options[:with] = with
- options[:without] = without
- end
-
- def normalize_settings
- Bundler.settings.set_command_option :path, nil if options[:system]
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
- Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil?
- end
- Bundler.settings.set_command_option_if_given :path, options[:path]
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
- Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
- end
-
- bin_option = options["binstubs"]
- bin_option = nil if bin_option && bin_option.empty?
- Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]
-
- Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
-
- Bundler.settings.set_command_option_if_given :jobs, options["jobs"]
-
- Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"]
-
- Bundler.settings.set_command_option_if_given :no_install, options["no-install"]
-
- Bundler.settings.set_command_option_if_given :clean, options["clean"]
-
- unless Bundler.settings[:without] == options[:without] && Bundler.settings[:with] == options[:with]
- # need to nil them out first to get around validation for backwards compatibility
- Bundler.settings.set_command_option :without, nil
- Bundler.settings.set_command_option :with, nil
- Bundler.settings.set_command_option :without, options[:without] - options[:with]
- Bundler.settings.set_command_option :with, options[:with]
- end
-
- options[:force] = options[:redownload]
- end
-
- def warn_ambiguous_gems
- # TODO: remove this when we drop Bundler 1.x support
- Installer.ambiguous_gems.to_a.each do |name, installed_from_uri, *also_found_in_uris|
- Bundler.ui.warn "Warning: the gem '#{name}' was found in multiple sources."
- Bundler.ui.warn "Installed from: #{installed_from_uri}"
- Bundler.ui.warn "Also found in:"
- also_found_in_uris.each {|uri| Bundler.ui.warn " * #{uri}" }
- Bundler.ui.warn "You should add a source requirement to restrict this gem to your preferred source."
- Bundler.ui.warn "For example:"
- Bundler.ui.warn " gem '#{name}', :source => '#{installed_from_uri}'"
- Bundler.ui.warn "Then uninstall the gem '#{name}' (or delete all bundled gems) and then install again."
- end
- end
- end
-end
diff --git a/lib/bundler/cli/issue.rb b/lib/bundler/cli/issue.rb
deleted file mode 100644
index 054ce76315..0000000000
--- a/lib/bundler/cli/issue.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: true
-
-require "rbconfig"
-
-module Bundler
- class CLI::Issue
- def run
- Bundler.ui.info <<-EOS.gsub(/^ {8}/, "")
- Did you find an issue with Bundler? Before filing a new issue,
- be sure to check out these resources:
-
- 1. Check out our troubleshooting guide for quick fixes to common issues:
- https://github.com/bundler/bundler/blob/master/doc/TROUBLESHOOTING.md
-
- 2. Instructions for common Bundler uses can be found on the documentation
- site: https://bundler.io/
-
- 3. Information about each Bundler command can be found in the Bundler
- man pages: https://bundler.io/man/bundle.1.html
-
- Hopefully the troubleshooting steps above resolved your problem! If things
- still aren't working the way you expect them to, please let us know so
- that we can diagnose and help fix the problem you're having. Please
- view the Filing Issues guide for more information:
- https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md
-
- EOS
-
- Bundler.ui.info Bundler::Env.report
-
- Bundler.ui.info "\n## Bundle Doctor"
- doctor
- end
-
- def doctor
- require_relative "doctor"
- Bundler::CLI::Doctor.new({}).run
- end
- end
-end
diff --git a/lib/bundler/cli/list.rb b/lib/bundler/cli/list.rb
deleted file mode 100644
index d1799196e7..0000000000
--- a/lib/bundler/cli/list.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::List
- def initialize(options)
- @options = options
- end
-
- def run
- raise InvalidOption, "The `--only-group` and `--without-group` options cannot be used together" if @options["only-group"] && @options["without-group"]
-
- raise InvalidOption, "The `--name-only` and `--paths` options cannot be used together" if @options["name-only"] && @options[:paths]
-
- specs = if @options["only-group"] || @options["without-group"]
- filtered_specs_by_groups
- else
- Bundler.load.specs
- end.reject {|s| s.name == "bundler" }.sort_by(&:name)
-
- return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
-
- return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"]
- return specs.each {|s| Bundler.ui.info s.full_gem_path } if @options["paths"]
-
- Bundler.ui.info "Gems included by the bundle:"
-
- specs.each {|s| Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})" }
-
- Bundler.ui.info "Use `bundle info` to print more detailed information about a gem"
- end
-
- private
-
- def verify_group_exists(groups)
- raise InvalidOption, "`#{@options["without-group"]}` group could not be found." if @options["without-group"] && !groups.include?(@options["without-group"].to_sym)
-
- raise InvalidOption, "`#{@options["only-group"]}` group could not be found." if @options["only-group"] && !groups.include?(@options["only-group"].to_sym)
- end
-
- def filtered_specs_by_groups
- definition = Bundler.definition
- groups = definition.groups
-
- verify_group_exists(groups)
-
- show_groups =
- if @options["without-group"]
- groups.reject {|g| g == @options["without-group"].to_sym }
- elsif @options["only-group"]
- groups.select {|g| g == @options["only-group"].to_sym }
- else
- groups
- end.map(&:to_sym)
-
- definition.specs_for(show_groups)
- end
- end
-end
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
deleted file mode 100644
index 7dd078b1ef..0000000000
--- a/lib/bundler/cli/lock.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Lock
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def run
- unless Bundler.default_gemfile
- Bundler.ui.error "Unable to find a Gemfile to lock"
- exit 1
- end
-
- print = options[:print]
- ui = Bundler.ui
- Bundler.ui = UI::Silent.new if print
-
- Bundler::Fetcher.disable_endpoint = options["full-index"]
-
- update = options[:update]
- if update.is_a?(Array) # unlocking specific gems
- Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
- update = { :gems => update, :lock_shared_dependencies => options[:conservative] }
- end
- definition = Bundler.definition(update)
-
- Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update]
-
- options["remove-platform"].each do |platform|
- definition.remove_platform(platform)
- end
-
- options["add-platform"].each do |platform_string|
- platform = Gem::Platform.new(platform_string)
- if platform.to_s == "unknown"
- Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
- "and adding it will likely lead to resolution errors"
- end
- definition.add_platform(platform)
- end
-
- if definition.platforms.empty?
- raise InvalidOption, "Removing all platforms from the bundle is not allowed"
- end
-
- definition.resolve_remotely! unless options[:local]
-
- if print
- puts definition.to_lock
- else
- file = options[:lockfile]
- file = file ? File.expand_path(file) : Bundler.default_lockfile
- puts "Writing lockfile to #{file}"
- definition.lock(file)
- end
-
- Bundler.ui = ui
- end
- end
-end
diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb
deleted file mode 100644
index df32e2f38b..0000000000
--- a/lib/bundler/cli/open.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-require "shellwords"
-
-module Bundler
- class CLI::Open
- attr_reader :options, :name
- def initialize(options, name)
- @options = options
- @name = name
- end
-
- def run
- editor = [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? }
- return Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") unless editor
- return unless spec = Bundler::CLI::Common.select_spec(name, :regex_match)
- if spec.default_gem?
- Bundler.ui.info "Unable to open #{name} because it's a default gem, so the directory it would normally be installed to does not exist."
- else
- path = spec.full_gem_path
- Dir.chdir(path) do
- command = Shellwords.split(editor) + [path]
- Bundler.with_original_env do
- system(*command)
- end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
- end
- end
- end
- end
-end
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
deleted file mode 100644
index 0b710e9782..0000000000
--- a/lib/bundler/cli/outdated.rb
+++ /dev/null
@@ -1,270 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Outdated
- attr_reader :options, :gems, :options_include_groups, :filter_options_patch, :sources, :strict
- attr_accessor :outdated_gems_by_groups, :outdated_gems_list
-
- def initialize(options, gems)
- @options = options
- @gems = gems
- @sources = Array(options[:source])
-
- @filter_options_patch = options.keys &
- %w[filter-major filter-minor filter-patch]
-
- @outdated_gems_by_groups = {}
- @outdated_gems_list = []
-
- @options_include_groups = [:group, :groups].any? do |v|
- options.keys.include?(v.to_s)
- end
-
- # the patch level options imply strict is also true. It wouldn't make
- # sense otherwise.
- @strict = options["filter-strict"] ||
- Bundler::CLI::Common.patch_level_options(options).any?
- end
-
- def run
- check_for_deployment_mode!
-
- gems.each do |gem_name|
- Bundler::CLI::Common.select_spec(gem_name)
- end
-
- Bundler.definition.validate_runtime!
- current_specs = Bundler.ui.silence { Bundler.definition.resolve }
-
- current_dependencies = Bundler.ui.silence do
- Bundler.load.dependencies.map {|dep| [dep.name, dep] }.to_h
- end
-
- definition = if gems.empty? && sources.empty?
- # We're doing a full update
- Bundler.definition(true)
- else
- Bundler.definition(:gems => gems, :sources => sources)
- end
-
- Bundler::CLI::Common.configure_gem_version_promoter(
- Bundler.definition,
- options
- )
-
- definition_resolution = proc do
- options[:local] ? definition.resolve_with_cache! : definition.resolve_remotely!
- end
-
- if options[:parseable]
- Bundler.ui.silence(&definition_resolution)
- else
- definition_resolution.call
- end
-
- Bundler.ui.info ""
-
- # Loop through the current specs
- gemfile_specs, dependency_specs = current_specs.partition do |spec|
- current_dependencies.key? spec.name
- end
-
- specs = if options["only-explicit"]
- gemfile_specs
- else
- gemfile_specs + dependency_specs
- end
-
- specs.sort_by(&:name).each do |current_spec|
- next if !gems.empty? && !gems.include?(current_spec.name)
-
- dependency = current_dependencies[current_spec.name]
- active_spec = retrieve_active_spec(definition, current_spec)
-
- next if active_spec.nil?
- next if filter_options_patch.any? &&
- !update_present_via_semver_portions(current_spec, active_spec, options)
-
- gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
- next unless gem_outdated || (current_spec.git_version != active_spec.git_version)
- groups = nil
- if dependency && !options[:parseable]
- groups = dependency.groups.join(", ")
- end
-
- outdated_gems_list << { :active_spec => active_spec,
- :current_spec => current_spec,
- :dependency => dependency,
- :groups => groups }
-
- outdated_gems_by_groups[groups] ||= []
- outdated_gems_by_groups[groups] << outdated_gems_list[-1]
- end
-
- if outdated_gems_list.empty?
- display_nothing_outdated_message
- else
- unless options[:parseable]
- Bundler.ui.info(header_outdated_message)
- end
-
- if options_include_groups
- ordered_groups = outdated_gems_by_groups.keys.compact.sort
- ordered_groups.insert(0, nil).each do |groups|
- gems = outdated_gems_by_groups[groups]
- contains_group = if groups
- groups.split(", ").include?(options[:group])
- else
- options[:group] == "group"
- end
-
- next if (!options[:groups] && !contains_group) || gems.nil?
-
- unless options[:parseable]
- Bundler.ui.info(header_group_message(groups))
- end
-
- print_gems(gems)
- end
- else
- print_gems(outdated_gems_list)
- end
-
- exit 1
- end
- end
-
- private
-
- def groups_text(group_text, groups)
- "#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\""
- end
-
- def header_outdated_message
- if options[:pre]
- "Outdated gems included in the bundle (including pre-releases):"
- else
- "Outdated gems included in the bundle:"
- end
- end
-
- def header_group_message(groups)
- if groups
- "===== #{groups_text("Group", groups)} ====="
- else
- "===== Without group ====="
- end
- end
-
- def nothing_outdated_message
- if filter_options_patch.any?
- display = filter_options_patch.map do |o|
- o.sub("filter-", "")
- end.join(" or ")
-
- "No #{display} updates to display.\n"
- else
- "Bundle up to date!\n"
- end
- end
-
- def retrieve_active_spec(definition, current_spec)
- if strict
- active_spec = definition.find_resolved_spec(current_spec)
- else
- active_specs = definition.find_indexed_specs(current_spec)
- if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
- active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
- end
- active_spec = active_specs.last
- end
-
- active_spec
- end
-
- def display_nothing_outdated_message
- unless options[:parseable]
- Bundler.ui.info(nothing_outdated_message)
- end
- end
-
- def print_gems(gems_list)
- gems_list.each do |gem|
- print_gem(
- gem[:current_spec],
- gem[:active_spec],
- gem[:dependency],
- gem[:groups],
- )
- end
- end
-
- def print_gem(current_spec, active_spec, dependency, groups)
- spec_version = "#{active_spec.version}#{active_spec.git_version}"
- spec_version += " (from #{active_spec.loaded_from})" if Bundler.ui.debug? && active_spec.loaded_from
- current_version = "#{current_spec.version}#{current_spec.git_version}"
-
- if dependency && dependency.specific?
- dependency_version = %(, requested #{dependency.requirement})
- end
-
- spec_outdated_info = "#{active_spec.name} (newest #{spec_version}, " \
- "installed #{current_version}#{dependency_version})"
-
- output_message = if options[:parseable]
- spec_outdated_info.to_s
- elsif options_include_groups || !groups
- " * #{spec_outdated_info}"
- else
- " * #{spec_outdated_info} in #{groups_text("group", groups)}"
- end
-
- Bundler.ui.info output_message.rstrip
- end
-
- def check_for_deployment_mode!
- return unless Bundler.frozen_bundle?
- suggested_command = if Bundler.settings.locations("frozen")[:global]
- "bundle config unset frozen"
- elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
- "bundle config unset deployment"
- else
- "bundle install --no-deployment"
- end
- raise ProductionError, "You are trying to check outdated gems in " \
- "deployment mode. Run `bundle outdated` elsewhere.\n" \
- "\nIf this is a development machine, remove the " \
- "#{Bundler.default_gemfile} freeze" \
- "\nby running `#{suggested_command}`."
- end
-
- def update_present_via_semver_portions(current_spec, active_spec, options)
- current_major = current_spec.version.segments.first
- active_major = active_spec.version.segments.first
-
- update_present = false
- update_present = active_major > current_major if options["filter-major"]
-
- if !update_present && (options["filter-minor"] || options["filter-patch"]) && current_major == active_major
- current_minor = get_version_semver_portion_value(current_spec, 1)
- active_minor = get_version_semver_portion_value(active_spec, 1)
-
- update_present = active_minor > current_minor if options["filter-minor"]
-
- if !update_present && options["filter-patch"] && current_minor == active_minor
- current_patch = get_version_semver_portion_value(current_spec, 2)
- active_patch = get_version_semver_portion_value(active_spec, 2)
-
- update_present = active_patch > current_patch
- end
- end
-
- update_present
- end
-
- def get_version_semver_portion_value(spec, version_portion_index)
- version_section = spec.version.segments[version_portion_index, 1]
- version_section.to_a[0].to_i
- end
- end
-end
diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb
deleted file mode 100644
index b31b67776d..0000000000
--- a/lib/bundler/cli/package.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Package
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def run
- Bundler.ui.level = "error" if options[:quiet]
- Bundler.settings.set_command_option_if_given :path, options[:path]
- Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
-
- setup_cache_all
- install
-
- # TODO: move cache contents here now that all bundles are locked
- custom_path = Bundler.settings[:path] if options[:path]
-
- Bundler.settings.temporary(:cache_all_platforms => options["all-platforms"]) do
- Bundler.load.cache(custom_path)
- end
- end
-
- private
-
- def install
- require_relative "install"
- options = self.options.dup
- options["local"] = false if Bundler.settings[:cache_all_platforms]
- Bundler::CLI::Install.new(options).run
- end
-
- def setup_cache_all
- all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil)
-
- Bundler.settings.set_command_option_if_given :cache_all, all
-
- if Bundler.definition.has_local_dependencies? && !Bundler.feature_flag.cache_all?
- Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
- "to package them as well, please pass the --all flag. This will be the default " \
- "on Bundler 3.0."
- end
- end
- end
-end
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb
deleted file mode 100644
index e97cad49a4..0000000000
--- a/lib/bundler/cli/platform.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Platform
- attr_reader :options
- def initialize(options)
- @options = options
- end
-
- def run
- platforms, ruby_version = Bundler.ui.silence do
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version
- gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
- [Bundler.definition.platforms.map {|p| "* #{p}" },
- locked_ruby_version || gemfile_ruby_version]
- end
- output = []
-
- if options[:ruby]
- if ruby_version
- output << ruby_version
- else
- output << "No ruby version specified"
- end
- else
- output << "Your platform is: #{RUBY_PLATFORM}"
- output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
-
- if ruby_version
- output << "Your Gemfile specifies a Ruby version requirement:\n* #{ruby_version}"
-
- begin
- Bundler.definition.validate_runtime!
- output << "Your current platform satisfies the Ruby version requirement."
- rescue RubyVersionMismatch => e
- output << e.message
- end
- else
- output << "Your Gemfile does not specify a Ruby version requirement."
- end
- end
-
- Bundler.ui.info output.join("\n\n")
- end
- end
-end
diff --git a/lib/bundler/cli/plugin.rb b/lib/bundler/cli/plugin.rb
deleted file mode 100644
index 1155c4ec9b..0000000000
--- a/lib/bundler/cli/plugin.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../vendored_thor"
-module Bundler
- class CLI::Plugin < Thor
- desc "install PLUGINS", "Install the plugin from the source"
- long_desc <<-D
- Install plugins either from the rubygems source provided (with --source option) or from a git source provided with --git (for remote repos) or --local_git (for local repos). If no sources are provided, it uses Gem.sources
- D
- method_option "source", :type => :string, :default => nil, :banner =>
- "URL of the RubyGems source to fetch the plugin from"
- method_option "version", :type => :string, :default => nil, :banner =>
- "The version of the plugin to fetch"
- method_option "git", :type => :string, :default => nil, :banner =>
- "URL of the git repo to fetch from"
- method_option "local_git", :type => :string, :default => nil, :banner =>
- "Path of the local git repo to fetch from"
- method_option "branch", :type => :string, :default => nil, :banner =>
- "The git branch to checkout"
- method_option "ref", :type => :string, :default => nil, :banner =>
- "The git revision to check out"
- def install(*plugins)
- Bundler::Plugin.install(plugins, options)
- end
-
- desc "list", "List the installed plugins and available commands"
- def list
- Bundler::Plugin.list
- end
- end
-end
diff --git a/lib/bundler/cli/pristine.rb b/lib/bundler/cli/pristine.rb
deleted file mode 100644
index 532b3e0b5b..0000000000
--- a/lib/bundler/cli/pristine.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Pristine
- def initialize(gems)
- @gems = gems
- end
-
- def run
- CLI::Common.ensure_all_gems_in_lockfile!(@gems)
- definition = Bundler.definition
- definition.validate_runtime!
- installer = Bundler::Installer.new(Bundler.root, definition)
-
- Bundler.load.specs.each do |spec|
- next if spec.name == "bundler" # Source::Rubygems doesn't install bundler
- next if !@gems.empty? && !@gems.include?(spec.name)
-
- gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})"
- gem_name += " (#{spec.platform})" if !spec.platform.nil? && spec.platform != Gem::Platform::RUBY
-
- case source = spec.source
- when Source::Rubygems
- cached_gem = spec.cache_file
- unless File.exist?(cached_gem)
- Bundler.ui.error("Failed to pristine #{gem_name}. Cached gem #{cached_gem} does not exist.")
- next
- end
-
- FileUtils.rm_rf spec.full_gem_path
- when Source::Git
- source.remote!
- if extension_cache_path = source.extension_cache_path(spec)
- FileUtils.rm_rf extension_cache_path
- end
- FileUtils.rm_rf spec.extension_dir
- FileUtils.rm_rf spec.full_gem_path
- else
- Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
- next
- end
-
- Bundler::GemInstaller.new(spec, installer, false, 0, true).install_from_spec
- end
- end
- end
-end
diff --git a/lib/bundler/cli/remove.rb b/lib/bundler/cli/remove.rb
deleted file mode 100644
index cd6a2cec28..0000000000
--- a/lib/bundler/cli/remove.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Remove
- def initialize(gems, options)
- @gems = gems
- @options = options
- end
-
- def run
- raise InvalidOption, "Please specify gems to remove." if @gems.empty?
-
- Injector.remove(@gems, {})
-
- Installer.install(Bundler.root, Bundler.definition) if @options["install"]
- end
- end
-end
diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb
deleted file mode 100644
index 3748c25b89..0000000000
--- a/lib/bundler/cli/show.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Show
- attr_reader :options, :gem_name, :latest_specs
- def initialize(options, gem_name)
- @options = options
- @gem_name = gem_name
- @verbose = options[:verbose] || options[:outdated]
- @latest_specs = fetch_latest_specs if @verbose
- end
-
- def run
- Bundler.ui.silence do
- Bundler.definition.validate_runtime!
- Bundler.load.lock
- end
-
- if gem_name
- if gem_name == "bundler"
- path = File.expand_path("../../../..", __FILE__)
- else
- spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match)
- return unless spec
- path = spec.full_gem_path
- unless File.directory?(path)
- return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}"
- end
- end
- return Bundler.ui.info(path)
- end
-
- if options[:paths]
- Bundler.load.specs.sort_by(&:name).map do |s|
- Bundler.ui.info s.full_gem_path
- end
- else
- Bundler.ui.info "Gems included by the bundle:"
- Bundler.load.specs.sort_by(&:name).each do |s|
- desc = " * #{s.name} (#{s.version}#{s.git_version})"
- if @verbose
- latest = latest_specs.find {|l| l.name == s.name }
- Bundler.ui.info <<-END.gsub(/^ +/, "")
- #{desc}
- \tSummary: #{s.summary || "No description available."}
- \tHomepage: #{s.homepage || "No website available."}
- \tStatus: #{outdated?(s, latest) ? "Outdated - #{s.version} < #{latest.version}" : "Up to date"}
- END
- else
- Bundler.ui.info desc
- end
- end
- end
- end
-
- private
-
- def fetch_latest_specs
- definition = Bundler.definition(true)
- if options[:outdated]
- Bundler.ui.info "Fetching remote specs for outdated check...\n\n"
- Bundler.ui.silence { definition.resolve_remotely! }
- else
- definition.resolve_with_cache!
- end
- Bundler.reset!
- definition.specs
- end
-
- def outdated?(current, latest)
- return false unless latest
- Gem::Version.new(current.version) < Gem::Version.new(latest.version)
- end
- end
-end
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
deleted file mode 100644
index 529dd9c94d..0000000000
--- a/lib/bundler/cli/update.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Update
- attr_reader :options, :gems
- def initialize(options, gems)
- @options = options
- @gems = gems
- end
-
- def run
- Bundler.ui.level = "error" if options[:quiet]
-
- Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
-
- sources = Array(options[:source])
- groups = Array(options[:group]).map(&:to_sym)
-
- full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
-
- if full_update && !options[:all]
- if Bundler.feature_flag.update_requires_all_flag?
- raise InvalidOption, "To update everything, pass the `--all` flag."
- end
- SharedHelpers.major_deprecation 3, "Pass --all to `bundle update` to update everything"
- elsif !full_update && options[:all]
- raise InvalidOption, "Cannot specify --all along with specific options."
- end
-
- if full_update
- # We're doing a full update
- Bundler.definition(true)
- else
- unless Bundler.default_lockfile.exist?
- raise GemfileLockNotFound, "This Bundle hasn't been installed yet. " \
- "Run `bundle install` to update and install the bundled gems."
- end
- Bundler::CLI::Common.ensure_all_gems_in_lockfile!(gems)
-
- if groups.any?
- deps = Bundler.definition.dependencies.select {|d| (d.groups & groups).any? }
- gems.concat(deps.map(&:name))
- end
-
- Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
- :lock_shared_dependencies => options[:conservative],
- :bundler => options[:bundler])
- end
-
- Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
-
- Bundler::Fetcher.disable_endpoint = options["full-index"]
-
- opts = options.dup
- opts["update"] = true
- opts["local"] = options[:local]
-
- Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
-
- Bundler.definition.validate_runtime!
-
- if locked_gems = Bundler.definition.locked_gems
- previous_locked_info = locked_gems.specs.reduce({}) do |h, s|
- h[s.name] = { :spec => s, :version => s.version, :source => s.source.to_s }
- h
- end
- end
-
- installer = Installer.install Bundler.root, Bundler.definition, opts
- Bundler.load.cache if Bundler.app_cache.exist?
-
- if CLI::Common.clean_after_install?
- require_relative "clean"
- Bundler::CLI::Clean.new(options).run
- end
-
- if locked_gems
- gems.each do |name|
- locked_info = previous_locked_info[name]
- next unless locked_info
-
- locked_spec = locked_info[:spec]
- new_spec = Bundler.definition.specs[name].first
- unless new_spec
- if Bundler.rubygems.platforms.none? {|p| locked_spec.match_platform(p) }
- Bundler.ui.warn "Bundler attempted to update #{name} but it was not considered because it is for a different platform from the current one"
- end
-
- next
- end
-
- locked_source = locked_info[:source]
- new_source = new_spec.source.to_s
- next if locked_source != new_source
-
- new_version = new_spec.version
- locked_version = locked_info[:version]
- if new_version < locked_version
- Bundler.ui.warn "Note: #{name} version regressed from #{locked_version} to #{new_version}"
- elsif new_version == locked_version
- Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same"
- end
- end
- end
-
- Bundler.ui.confirm "Bundle updated!"
- Bundler::CLI::Common.output_without_groups_message(:update)
- Bundler::CLI::Common.output_post_install_messages installer.post_install_messages
- end
- end
-end
diff --git a/lib/bundler/cli/viz.rb b/lib/bundler/cli/viz.rb
deleted file mode 100644
index 644f9b25cf..0000000000
--- a/lib/bundler/cli/viz.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Viz
- attr_reader :options, :gem_name
- def initialize(options)
- @options = options
- end
-
- def run
- # make sure we get the right `graphviz`. There is also a `graphviz`
- # gem we're not built to support
- gem "ruby-graphviz"
- require "graphviz"
-
- options[:without] = options[:without].join(":").tr(" ", ":").split(":")
- output_file = File.expand_path(options[:file])
-
- graph = Graph.new(Bundler.load, output_file, options[:version], options[:requirements], options[:format], options[:without])
- graph.viz
- rescue LoadError => e
- Bundler.ui.error e.inspect
- Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
- Bundler.ui.warn "`gem install ruby-graphviz`"
- rescue StandardError => e
- raise unless e.message =~ /GraphViz not installed or dot not in PATH/
- Bundler.ui.error e.message
- Bundler.ui.warn "Please install GraphViz. On a Mac with Homebrew, you can run `brew install graphviz`."
- end
- end
-end
diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb
deleted file mode 100644
index a5120dbba4..0000000000
--- a/lib/bundler/compact_index_client.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-# frozen_string_literal: true
-
-require "pathname"
-require "set"
-
-module Bundler
- class CompactIndexClient
- DEBUG_MUTEX = Mutex.new
- def self.debug
- return unless ENV["DEBUG_COMPACT_INDEX"]
- DEBUG_MUTEX.synchronize { warn("[#{self}] #{yield}") }
- end
-
- class Error < StandardError; end
-
- require_relative "compact_index_client/cache"
- require_relative "compact_index_client/updater"
-
- attr_reader :directory
-
- def initialize(directory, fetcher)
- @directory = Pathname.new(directory)
- @updater = Updater.new(fetcher)
- @cache = Cache.new(@directory)
- @endpoints = Set.new
- @info_checksums_by_name = {}
- @parsed_checksums = false
- @mutex = Mutex.new
- end
-
- def execution_mode=(block)
- Bundler::CompactIndexClient.debug { "execution_mode=" }
- @endpoints = Set.new
-
- @execution_mode = block
- end
-
- # @return [Lambda] A lambda that takes an array of inputs and a block, and
- # maps the inputs with the block in parallel.
- #
- def execution_mode
- @execution_mode || sequentially
- end
-
- def sequential_execution_mode!
- self.execution_mode = sequentially
- end
-
- def sequentially
- @sequentially ||= lambda do |inputs, &blk|
- inputs.map(&blk)
- end
- end
-
- def names
- Bundler::CompactIndexClient.debug { "/names" }
- update(@cache.names_path, "names")
- @cache.names
- end
-
- def versions
- Bundler::CompactIndexClient.debug { "/versions" }
- update(@cache.versions_path, "versions")
- versions, @info_checksums_by_name = @cache.versions
- versions
- end
-
- def dependencies(names)
- Bundler::CompactIndexClient.debug { "dependencies(#{names})" }
- execution_mode.call(names) do |name|
- update_info(name)
- @cache.dependencies(name).map {|d| d.unshift(name) }
- end.flatten(1)
- end
-
- def spec(name, version, platform = nil)
- Bundler::CompactIndexClient.debug { "spec(name = #{name}, version = #{version}, platform = #{platform})" }
- update_info(name)
- @cache.specific_dependency(name, version, platform)
- end
-
- def update_and_parse_checksums!
- Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" }
- return @info_checksums_by_name if @parsed_checksums
- update(@cache.versions_path, "versions")
- @info_checksums_by_name = @cache.checksums
- @parsed_checksums = true
- end
-
- private
-
- def update(local_path, remote_path)
- Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" }
- unless synchronize { @endpoints.add?(remote_path) }
- Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
- return
- end
- @updater.update(local_path, url(remote_path))
- end
-
- def update_info(name)
- Bundler::CompactIndexClient.debug { "update_info(#{name})" }
- path = @cache.info_path(name)
- checksum = @updater.checksum_for_file(path)
- unless existing = @info_checksums_by_name[name]
- Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since it is missing from versions" }
- return
- end
- if checksum == existing
- Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since the versions checksum matches the local checksum" }
- return
- end
- Bundler::CompactIndexClient.debug { "updating info for #{name} since the versions checksum #{existing} != the local checksum #{checksum}" }
- update(path, "info/#{name}")
- end
-
- def url(path)
- path
- end
-
- def synchronize
- @mutex.synchronize { yield }
- end
- end
-end
diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb
deleted file mode 100644
index f6105d3bb3..0000000000
--- a/lib/bundler/compact_index_client/cache.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CompactIndexClient
- class Cache
- attr_reader :directory
-
- def initialize(directory)
- @directory = Pathname.new(directory).expand_path
- info_roots.each do |dir|
- SharedHelpers.filesystem_access(dir) do
- FileUtils.mkdir_p(dir)
- end
- end
- end
-
- def names
- lines(names_path)
- end
-
- def names_path
- directory.join("names")
- end
-
- def versions
- versions_by_name = Hash.new {|hash, key| hash[key] = [] }
- info_checksums_by_name = {}
-
- lines(versions_path).each do |line|
- name, versions_string, info_checksum = line.split(" ", 3)
- info_checksums_by_name[name] = info_checksum || ""
- versions_string.split(",").each do |version|
- if version.start_with?("-")
- version = version[1..-1].split("-", 2).unshift(name)
- versions_by_name[name].delete(version)
- else
- version = version.split("-", 2).unshift(name)
- versions_by_name[name] << version
- end
- end
- end
-
- [versions_by_name, info_checksums_by_name]
- end
-
- def versions_path
- directory.join("versions")
- end
-
- def checksums
- checksums = {}
-
- lines(versions_path).each do |line|
- name, _, checksum = line.split(" ", 3)
- checksums[name] = checksum
- end
-
- checksums
- end
-
- def dependencies(name)
- lines(info_path(name)).map do |line|
- parse_gem(line)
- end
- end
-
- def info_path(name)
- name = name.to_s
- if name =~ /[^a-z0-9_-]/
- name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
- info_roots.last.join(name)
- else
- info_roots.first.join(name)
- end
- end
-
- def specific_dependency(name, version, platform)
- pattern = [version, platform].compact.join("-")
- return nil if pattern.empty?
-
- gem_lines = info_path(name).read
- gem_line = gem_lines[/^#{Regexp.escape(pattern)}\b.*/, 0]
- gem_line ? parse_gem(gem_line) : nil
- end
-
- private
-
- def lines(path)
- return [] unless path.file?
- lines = SharedHelpers.filesystem_access(path, :read, &:read).split("\n")
- header = lines.index("---")
- header ? lines[header + 1..-1] : lines
- end
-
- def parse_gem(string)
- version_and_platform, rest = string.split(" ", 2)
- version, platform = version_and_platform.split("-", 2)
- dependencies, requirements = rest.split("|", 2).map {|s| s.split(",") } if rest
- dependencies = dependencies ? dependencies.map {|d| parse_dependency(d) } : []
- requirements = requirements ? requirements.map {|r| parse_dependency(r) } : []
- [version, platform, dependencies, requirements]
- end
-
- def parse_dependency(string)
- dependency = string.split(":")
- dependency[-1] = dependency[-1].split("&") if dependency.size > 1
- dependency
- end
-
- def info_roots
- [
- directory.join("info"),
- directory.join("info-special-characters"),
- ]
- end
- end
- end
-end
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb
deleted file mode 100644
index 40232019bc..0000000000
--- a/lib/bundler/compact_index_client/updater.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../vendored_fileutils"
-require "stringio"
-require "zlib"
-
-module Bundler
- class CompactIndexClient
- class Updater
- class MisMatchedChecksumError < Error
- def initialize(path, server_checksum, local_checksum)
- @path = path
- @server_checksum = server_checksum
- @local_checksum = local_checksum
- end
-
- def message
- "The checksum of /#{@path} does not match the checksum provided by the server! Something is wrong " \
- "(local checksum is #{@local_checksum.inspect}, was expecting #{@server_checksum.inspect})."
- end
- end
-
- def initialize(fetcher)
- @fetcher = fetcher
- require "tmpdir"
- end
-
- def update(local_path, remote_path, retrying = nil)
- headers = {}
-
- Dir.mktmpdir("bundler-compact-index-") do |local_temp_dir|
- local_temp_path = Pathname.new(local_temp_dir).join(local_path.basename)
-
- # first try to fetch any new bytes on the existing file
- if retrying.nil? && local_path.file?
- SharedHelpers.filesystem_access(local_temp_path) do
- FileUtils.cp local_path, local_temp_path
- end
- headers["If-None-Match"] = etag_for(local_temp_path)
- headers["Range"] =
- if local_temp_path.size.nonzero?
- # Subtract a byte to ensure the range won't be empty.
- # Avoids 416 (Range Not Satisfiable) responses.
- "bytes=#{local_temp_path.size - 1}-"
- else
- "bytes=#{local_temp_path.size}-"
- end
- else
- # Fastly ignores Range when Accept-Encoding: gzip is set
- headers["Accept-Encoding"] = "gzip"
- end
-
- response = @fetcher.call(remote_path, headers)
- return nil if response.is_a?(Net::HTTPNotModified)
-
- content = response.body
- if response["Content-Encoding"] == "gzip"
- content = Zlib::GzipReader.new(StringIO.new(content)).read
- end
-
- SharedHelpers.filesystem_access(local_temp_path) do
- if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
- local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
- else
- local_temp_path.open("w") {|f| f << content }
- end
- end
-
- response_etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
- if etag_for(local_temp_path) == response_etag
- SharedHelpers.filesystem_access(local_path) do
- FileUtils.mv(local_temp_path, local_path)
- end
- return nil
- end
-
- if retrying
- raise MisMatchedChecksumError.new(remote_path, response_etag, etag_for(local_temp_path))
- end
-
- update(local_path, remote_path, :retrying)
- end
- rescue Errno::EACCES
- raise Bundler::PermissionError,
- "Bundler does not have write access to create a temp directory " \
- "within #{Dir.tmpdir}. Bundler must have write access to your " \
- "systems temp directory to function properly. "
- rescue Zlib::GzipFile::Error
- raise Bundler::HTTPError
- end
-
- def etag_for(path)
- sum = checksum_for_file(path)
- sum ? %("#{sum}") : nil
- end
-
- def slice_body(body, range)
- body.byteslice(range)
- end
-
- def checksum_for_file(path)
- return nil unless path.file?
- # This must use IO.read instead of Digest.file().hexdigest
- # because we need to preserve \n line endings on windows when calculating
- # the checksum
- SharedHelpers.filesystem_access(path, :read) do
- SharedHelpers.digest(:MD5).hexdigest(IO.read(path))
- end
- end
- end
- end
-end
diff --git a/lib/bundler/constants.rb b/lib/bundler/constants.rb
deleted file mode 100644
index 2e4ebb37ee..0000000000
--- a/lib/bundler/constants.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
- FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
- NULL = WINDOWS ? "NUL" : "/dev/null"
-end
diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
deleted file mode 100644
index c132e8ecc0..0000000000
--- a/lib/bundler/current_ruby.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # Returns current version of Ruby
- #
- # @return [CurrentRuby] Current version of Ruby
- def self.current_ruby
- @current_ruby ||= CurrentRuby.new
- end
-
- class CurrentRuby
- KNOWN_MINOR_VERSIONS = %w[
- 1.8
- 1.9
- 2.0
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
- 2.7
- ].freeze
-
- KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
-
- KNOWN_PLATFORMS = %w[
- jruby
- maglev
- mingw
- mri
- mswin
- mswin64
- rbx
- ruby
- truffleruby
- x64_mingw
- ].freeze
-
- def ruby?
- return true if Bundler::GemHelpers.generic_local_platform == Gem::Platform::RUBY
-
- !mswin? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
- end
-
- def mri?
- !mswin? && RUBY_ENGINE == "ruby"
- end
-
- def rbx?
- ruby? && RUBY_ENGINE == "rbx"
- end
-
- def jruby?
- RUBY_ENGINE == "jruby"
- end
-
- def maglev?
- RUBY_ENGINE == "maglev"
- end
-
- def truffleruby?
- RUBY_ENGINE == "truffleruby"
- end
-
- def mswin?
- Bundler::WINDOWS
- end
-
- def mswin64?
- Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
- end
-
- def mingw?
- Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
- end
-
- def x64_mingw?
- Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
- end
-
- (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
- trimmed_version = version.tr(".", "")
- define_method(:"on_#{trimmed_version}?") do
- RUBY_VERSION.start_with?("#{version}.")
- end
-
- KNOWN_PLATFORMS.each do |platform|
- define_method(:"#{platform}_#{trimmed_version}?") do
- send(:"#{platform}?") && send(:"on_#{trimmed_version}?")
- end
- end
- end
- end
-end
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
deleted file mode 100644
index d6fbb0b5b7..0000000000
--- a/lib/bundler/definition.rb
+++ /dev/null
@@ -1,1002 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "lockfile_parser"
-require "set"
-
-module Bundler
- class Definition
- include GemHelpers
-
- attr_reader(
- :dependencies,
- :locked_deps,
- :locked_gems,
- :platforms,
- :requires,
- :ruby_version,
- :lockfile,
- :gemfiles
- )
-
- # Given a gemfile and lockfile creates a Bundler definition
- #
- # @param gemfile [Pathname] Path to Gemfile
- # @param lockfile [Pathname,nil] Path to Gemfile.lock
- # @param unlock [Hash, Boolean, nil] Gems that have been requested
- # to be updated or true if all gems should be updated
- # @return [Bundler::Definition]
- def self.build(gemfile, lockfile, unlock)
- unlock ||= {}
- gemfile = Pathname.new(gemfile).expand_path
-
- raise GemfileNotFound, "#{gemfile} not found" unless gemfile.file?
-
- Dsl.evaluate(gemfile, lockfile, unlock)
- end
-
- #
- # How does the new system work?
- #
- # * Load information from Gemfile and Lockfile
- # * Invalidate stale locked specs
- # * All specs from stale source are stale
- # * All specs that are reachable only through a stale
- # dependency are stale.
- # * If all fresh dependencies are satisfied by the locked
- # specs, then we can try to resolve locally.
- #
- # @param lockfile [Pathname] Path to Gemfile.lock
- # @param dependencies [Array(Bundler::Dependency)] array of dependencies from Gemfile
- # @param sources [Bundler::SourceList]
- # @param unlock [Hash, Boolean, nil] Gems that have been requested
- # to be updated or true if all gems should be updated
- # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
- # @param optional_groups [Array(String)] A list of optional groups
- def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
- if [true, false].include?(unlock)
- @unlocking_bundler = false
- @unlocking = unlock
- else
- unlock = unlock.dup
- @unlocking_bundler = unlock.delete(:bundler)
- unlock.delete_if {|_k, v| Array(v).empty? }
- @unlocking = !unlock.empty?
- end
-
- @dependencies = dependencies
- @sources = sources
- @unlock = unlock
- @optional_groups = optional_groups
- @remote = false
- @specs = nil
- @ruby_version = ruby_version
- @gemfiles = gemfiles
-
- @lockfile = lockfile
- @lockfile_contents = String.new
- @locked_bundler_version = nil
- @locked_ruby_version = nil
- @locked_specs_incomplete_for_platform = false
-
- if lockfile && File.exist?(lockfile)
- @lockfile_contents = Bundler.read_file(lockfile)
- @locked_gems = LockfileParser.new(@lockfile_contents)
- @locked_platforms = @locked_gems.platforms
- @platforms = @locked_platforms.dup
- @locked_bundler_version = @locked_gems.bundler_version
- @locked_ruby_version = @locked_gems.ruby_version
-
- if unlock != true
- @locked_deps = @locked_gems.dependencies
- @locked_specs = SpecSet.new(@locked_gems.specs)
- @locked_sources = @locked_gems.sources
- else
- @unlock = {}
- @locked_deps = {}
- @locked_specs = SpecSet.new([])
- @locked_sources = []
- end
- else
- @unlock = {}
- @platforms = []
- @locked_gems = nil
- @locked_deps = {}
- @locked_specs = SpecSet.new([])
- @locked_sources = []
- @locked_platforms = []
- end
-
- @unlock[:gems] ||= []
- @unlock[:sources] ||= []
- @unlock[:ruby] ||= if @ruby_version && locked_ruby_version_object
- @ruby_version.diff(locked_ruby_version_object)
- end
- @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
-
- add_current_platform unless Bundler.frozen_bundle?
-
- converge_path_sources_to_gemspec_sources
- @path_changes = converge_paths
- @source_changes = converge_sources
-
- unless @unlock[:lock_shared_dependencies]
- eager_unlock = expand_dependencies(@unlock[:gems], true)
- @unlock[:gems] = @locked_specs.for(eager_unlock, [], false, false, false).map(&:name)
- end
-
- @dependency_changes = converge_dependencies
- @local_changes = converge_locals
-
- @requires = compute_requires
- end
-
- def gem_version_promoter
- @gem_version_promoter ||= begin
- locked_specs =
- if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty?
- # Definition uses an empty set of locked_specs to indicate all gems
- # are unlocked, but GemVersionPromoter needs the locked_specs
- # for conservative comparison.
- Bundler::SpecSet.new(@locked_gems.specs)
- else
- @locked_specs
- end
- GemVersionPromoter.new(locked_specs, @unlock[:gems])
- end
- end
-
- def resolve_with_cache!
- raise "Specs already loaded" if @specs
- sources.cached!
- specs
- end
-
- def resolve_remotely!
- raise "Specs already loaded" if @specs
- @remote = true
- sources.remote!
- specs
- end
-
- # For given dependency list returns a SpecSet with Gemspec of all the required
- # dependencies.
- # 1. The method first resolves the dependencies specified in Gemfile
- # 2. After that it tries and fetches gemspec of resolved dependencies
- #
- # @return [Bundler::SpecSet]
- def specs
- @specs ||= begin
- begin
- specs = resolve.materialize(requested_dependencies)
- rescue GemNotFound => e # Handle yanked gem
- gem_name, gem_version = extract_gem_info(e)
- locked_gem = @locked_specs[gem_name].last
- raise if locked_gem.nil? || locked_gem.version.to_s != gem_version || !@remote
- raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
- "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
- "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
- "to a version other than #{locked_gem} that hasn't been removed in order to install."
- end
- unless specs["bundler"].any?
- bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
- specs["bundler"] = bundler
- end
-
- specs
- end
- end
-
- def new_specs
- specs - @locked_specs
- end
-
- def removed_specs
- @locked_specs - specs
- end
-
- def new_platform?
- @new_platform
- end
-
- def missing_specs
- missing = []
- resolve.materialize(requested_dependencies, missing)
- missing
- end
-
- def missing_specs?
- missing = missing_specs
- return false if missing.empty?
- Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
- true
- rescue BundlerError => e
- @index = nil
- @resolve = nil
- @specs = nil
- @gem_version_promoter = nil
-
- Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
- true
- end
-
- def requested_specs
- @requested_specs ||= begin
- groups = requested_groups
- groups.map!(&:to_sym)
- specs_for(groups)
- end
- end
-
- def current_dependencies
- dependencies.select(&:should_include?)
- end
-
- def specs_for(groups)
- deps = dependencies.select {|d| (d.groups & groups).any? }
- deps.delete_if {|d| !d.should_include? }
- specs.for(expand_dependencies(deps))
- end
-
- # Resolve all the dependencies specified in Gemfile. It ensures that
- # dependencies that have been already resolved via locked file and are fresh
- # are reused when resolving dependencies
- #
- # @return [SpecSet] resolved dependencies
- def resolve
- @resolve ||= begin
- last_resolve = converge_locked_specs
- resolve =
- if Bundler.frozen_bundle?
- Bundler.ui.debug "Frozen, using resolution from the lockfile"
- last_resolve
- elsif !unlocking? && nothing_changed?
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
- last_resolve
- else
- # Run a resolve against the locally available gems
- Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
- end
-
- # filter out gems that _can_ be installed on multiple platforms, but don't need
- # to be
- resolve.for(expand_dependencies(dependencies, true), [], false, false, false)
- end
- end
-
- def index
- @index ||= Index.build do |idx|
- dependency_names = @dependencies.map(&:name)
-
- sources.all_sources.each do |source|
- source.dependency_names = dependency_names - pinned_spec_names(source)
- idx.add_source source.specs
- dependency_names.concat(source.unmet_deps).uniq!
- end
-
- double_check_for_index(idx, dependency_names)
- end
- end
-
- # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
- # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
- # but will not have found any versions of Bar from source B, which is a problem if the requested version
- # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
- # each spec we found, we add all possible versions from all sources to the index.
- def double_check_for_index(idx, dependency_names)
- pinned_names = pinned_spec_names
- loop do
- idxcount = idx.size
-
- names = :names # do this so we only have to traverse to get dependency_names from the index once
- unmet_dependency_names = lambda do
- return names unless names == :names
- new_names = sources.all_sources.map(&:dependency_names_to_double_check)
- return names = nil if new_names.compact!
- names = new_names.flatten(1).concat(dependency_names)
- names.uniq!
- names -= pinned_names
- names
- end
-
- sources.all_sources.each do |source|
- source.double_check_for(unmet_dependency_names)
- end
-
- break if idxcount == idx.size
- end
- end
- private :double_check_for_index
-
- def has_rubygems_remotes?
- sources.rubygems_sources.any? {|s| s.remotes.any? }
- end
-
- def has_local_dependencies?
- !sources.path_sources.empty? || !sources.git_sources.empty?
- end
-
- def spec_git_paths
- sources.git_sources.map {|s| File.realpath(s.path) if File.exist?(s.path) }.compact
- end
-
- def groups
- dependencies.map(&:groups).flatten.uniq
- end
-
- def lock(file, preserve_unknown_sections = false)
- contents = to_lock
-
- # Convert to \r\n if the existing lock has them
- # i.e., Windows with `git config core.autocrlf=true`
- contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
-
- if @locked_bundler_version
- locked_major = @locked_bundler_version.segments.first
- current_major = Gem::Version.create(Bundler::VERSION).segments.first
-
- if updating_major = locked_major < current_major
- Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \
- "after which you will be unable to return to Bundler #{@locked_bundler_version.segments.first}."
- end
- end
-
- preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
-
- return if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
-
- if Bundler.frozen_bundle?
- Bundler.ui.error "Cannot write a changed lockfile while frozen."
- return
- end
-
- SharedHelpers.filesystem_access(file) do |p|
- File.open(p, "wb") {|f| f.puts(contents) }
- end
- end
-
- def locked_bundler_version
- if @locked_bundler_version && @locked_bundler_version < Gem::Version.new(Bundler::VERSION)
- new_version = Bundler::VERSION
- end
-
- new_version || @locked_bundler_version || Bundler::VERSION
- end
-
- def locked_ruby_version
- return unless ruby_version
- if @unlock[:ruby] || !@locked_ruby_version
- Bundler::RubyVersion.system
- else
- @locked_ruby_version
- end
- end
-
- def locked_ruby_version_object
- return unless @locked_ruby_version
- @locked_ruby_version_object ||= begin
- unless version = RubyVersion.from_string(@locked_ruby_version)
- raise LockfileError, "The Ruby version #{@locked_ruby_version} from " \
- "#{@lockfile} could not be parsed. " \
- "Try running bundle update --ruby to resolve this."
- end
- version
- end
- end
-
- def to_lock
- require_relative "lockfile_generator"
- LockfileGenerator.generate(self)
- end
-
- def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
- msg = String.new
- msg << "You are trying to install in deployment mode after changing\n" \
- "your Gemfile. Run `bundle install` elsewhere and add the\n" \
- "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
-
- unless explicit_flag
- suggested_command = if Bundler.settings.locations("frozen")[:global]
- "bundle config unset frozen"
- elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
- "bundle config unset deployment"
- else
- "bundle install --no-deployment"
- end
- msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
- "freeze \nby running `#{suggested_command}`."
- end
-
- added = []
- deleted = []
- changed = []
-
- new_platforms = @platforms - @locked_platforms
- deleted_platforms = @locked_platforms - @platforms
- added.concat new_platforms.map {|p| "* platform: #{p}" }
- deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
-
- gemfile_sources = sources.lock_sources
-
- new_sources = gemfile_sources - @locked_sources
- deleted_sources = @locked_sources - gemfile_sources
-
- new_deps = @dependencies - @locked_deps.values
- deleted_deps = @locked_deps.values - @dependencies
-
- # Check if it is possible that the source is only changed thing
- if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
- new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
- deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
- end
-
- if @locked_sources != gemfile_sources
- if new_sources.any?
- added.concat new_sources.map {|source| "* source: #{source}" }
- end
-
- if deleted_sources.any?
- deleted.concat deleted_sources.map {|source| "* source: #{source}" }
- end
- end
-
- added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
- if deleted_deps.any?
- deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" }
- end
-
- both_sources = Hash.new {|h, k| h[k] = [] }
- @dependencies.each {|d| both_sources[d.name][0] = d }
- @locked_deps.each {|name, d| both_sources[name][1] = d.source }
-
- both_sources.each do |name, (dep, lock_source)|
- next unless (dep.nil? && !lock_source.nil?) || (!dep.nil? && !lock_source.nil? && !lock_source.can_lock?(dep))
- gemfile_source_name = (dep && dep.source) || "no specified source"
- lockfile_source_name = lock_source || "no specified source"
- changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
- end
-
- reason = change_reason
- msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" unless reason.strip.empty?
- msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
- msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
- msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
- msg << "\n"
-
- raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed?
- end
-
- def validate_runtime!
- validate_ruby!
- validate_platforms!
- end
-
- def validate_ruby!
- return unless ruby_version
-
- if diff = ruby_version.diff(Bundler::RubyVersion.system)
- problem, expected, actual = diff
-
- msg = case problem
- when :engine
- "Your Ruby engine is #{actual}, but your Gemfile specified #{expected}"
- when :version
- "Your Ruby version is #{actual}, but your Gemfile specified #{expected}"
- when :engine_version
- "Your #{Bundler::RubyVersion.system.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}"
- when :patchlevel
- if !expected.is_a?(String)
- "The Ruby patchlevel in your Gemfile must be a string"
- else
- "Your Ruby patchlevel is #{actual}, but your Gemfile specified #{expected}"
- end
- end
-
- raise RubyVersionMismatch, msg
- end
- end
-
- def validate_platforms!
- return if @platforms.any? do |bundle_platform|
- Bundler.rubygems.platforms.any? do |local_platform|
- MatchPlatform.platforms_match?(bundle_platform, local_platform)
- end
- end
-
- raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
- "but your local platforms are #{Bundler.rubygems.platforms.map(&:to_s)}, and " \
- "there's no compatible match between those two lists."
- end
-
- def add_platform(platform)
- @new_platform ||= !@platforms.include?(platform)
- @platforms |= [platform]
- end
-
- def remove_platform(platform)
- return if @platforms.delete(Gem::Platform.new(platform))
- raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}"
- end
-
- def add_current_platform
- current_platforms.each {|platform| add_platform(platform) }
- end
-
- def find_resolved_spec(current_spec)
- specs.find_by_name_and_platform(current_spec.name, current_spec.platform)
- end
-
- def find_indexed_specs(current_spec)
- index[current_spec.name].select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
- end
-
- attr_reader :sources
- private :sources
-
- def nothing_changed?
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform
- end
-
- def unlocking?
- @unlocking
- end
-
- private
-
- def current_platforms
- current_platform = Bundler.local_platform
- [].tap do |platforms|
- platforms << current_platform if Bundler.feature_flag.specific_platform?
- platforms << generic(current_platform)
- end
- end
-
- def change_reason
- if unlocking?
- unlock_reason = @unlock.reject {|_k, v| Array(v).empty? }.map do |k, v|
- if v == true
- k.to_s
- else
- v = Array(v)
- "#{k}: (#{v.join(", ")})"
- end
- end.join(", ")
- return "bundler is unlocking #{unlock_reason}"
- end
- [
- [@source_changes, "the list of sources changed"],
- [@dependency_changes, "the dependencies in your gemfile changed"],
- [@new_platform, "you added a new platform to your gemfile"],
- [@path_changes, "the gemspecs for path gems changed"],
- [@local_changes, "the gemspecs for git local gems changed"],
- [@locked_specs_incomplete_for_platform, "the lockfile does not have all gems needed for the current platform"],
- ].select(&:first).map(&:last).join(", ")
- end
-
- def pretty_dep(dep, source = false)
- SharedHelpers.pretty_dependency(dep, source)
- end
-
- # Check if the specs of the given source changed
- # according to the locked source.
- def specs_changed?(source)
- locked = @locked_sources.find {|s| s == source }
-
- !locked || dependencies_for_source_changed?(source, locked) || specs_for_source_changed?(source)
- end
-
- def dependencies_for_source_changed?(source, locked_source = source)
- deps_for_source = @dependencies.select {|s| s.source == source }
- locked_deps_for_source = @locked_deps.values.select {|dep| dep.source == locked_source }
-
- Set.new(deps_for_source) != Set.new(locked_deps_for_source)
- end
-
- def specs_for_source_changed?(source)
- locked_index = Index.new
- locked_index.use(@locked_specs.select {|s| source.can_lock?(s) })
-
- # order here matters, since Index#== is checking source.specs.include?(locked_index)
- locked_index != source.specs
- rescue PathError, GitError => e
- Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
- false
- end
-
- # Get all locals and override their matching sources.
- # Return true if any of the locals changed (for example,
- # they point to a new revision) or depend on new specs.
- def converge_locals
- locals = []
-
- Bundler.settings.local_overrides.map do |k, v|
- spec = @dependencies.find {|s| s.name == k }
- source = spec && spec.source
- if source && source.respond_to?(:local_override!)
- source.unlock! if @unlock[:gems].include?(spec.name)
- locals << [source, source.local_override!(v)]
- end
- end
-
- sources_with_changes = locals.select do |source, changed|
- changed || specs_changed?(source)
- end.map(&:first)
- !sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
- end
-
- def converge_paths
- sources.path_sources.any? do |source|
- specs_changed?(source)
- end
- end
-
- def converge_path_source_to_gemspec_source(source)
- return source unless source.instance_of?(Source::Path)
- gemspec_source = sources.path_sources.find {|s| s.is_a?(Source::Gemspec) && s.as_path_source == source }
- gemspec_source || source
- end
-
- def converge_path_sources_to_gemspec_sources
- @locked_sources.map! do |source|
- converge_path_source_to_gemspec_source(source)
- end
- @locked_specs.each do |spec|
- spec.source &&= converge_path_source_to_gemspec_source(spec.source)
- end
- @locked_deps.each do |_, dep|
- dep.source &&= converge_path_source_to_gemspec_source(dep.source)
- end
- end
-
- def converge_rubygems_sources
- return false if Bundler.feature_flag.disable_multisource?
-
- changes = false
-
- # Get the RubyGems sources from the Gemfile.lock
- locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
- # Get the RubyGems remotes from the Gemfile
- actual_remotes = sources.rubygems_remotes
-
- # If there is a RubyGems source in both
- if !locked_gem_sources.empty? && !actual_remotes.empty?
- locked_gem_sources.each do |locked_gem|
- # Merge the remotes from the Gemfile into the Gemfile.lock
- changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
- end
- end
-
- changes
- end
-
- def converge_sources
- changes = false
-
- changes |= converge_rubygems_sources
-
- # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
- # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
- # source in the Gemfile.lock, use the one from the Gemfile.
- changes |= sources.replace_sources!(@locked_sources)
-
- sources.all_sources.each do |source|
- # If the source is unlockable and the current command allows an unlock of
- # the source (for example, you are doing a `bundle update <foo>` of a git-pinned
- # gem), unlock it. For git sources, this means to unlock the revision, which
- # will cause the `ref` used to be the most recent for the branch (or master) if
- # an explicit `ref` is not used.
- if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name)
- source.unlock!
- changes = true
- end
- end
-
- changes
- end
-
- def converge_dependencies
- frozen = Bundler.frozen_bundle?
- (@dependencies + @locked_deps.values).each do |dep|
- locked_source = @locked_deps[dep.name]
- # This is to make sure that if bundler is installing in deployment mode and
- # after locked_source and sources don't match, we still use locked_source.
- if frozen && !locked_source.nil? &&
- locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
- dep.source = locked_source.source
- elsif dep.source
- dep.source = sources.get(dep.source)
- end
- if dep.source.is_a?(Source::Gemspec)
- dep.platforms.concat(@platforms.map {|p| Dependency::REVERSE_PLATFORM_MAP[p] }.flatten(1)).uniq!
- end
- end
-
- changes = false
- # We want to know if all match, but don't want to check all entries
- # This means we need to return false if any dependency doesn't match
- # the lock or doesn't exist in the lock.
- @dependencies.each do |dependency|
- unless locked_dep = @locked_deps[dependency.name]
- changes = true
- next
- end
-
- # Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
- # doesn't carry a notion of the dependency type, if you use
- # add_development_dependency in a gemspec that's loaded with the gemspec
- # directive, the lockfile dependencies and resolved dependencies end up
- # with a mismatch on #type. Work around that by setting the type on the
- # dep from the lockfile.
- locked_dep.instance_variable_set(:@type, dependency.type)
-
- # We already know the name matches from the hash lookup
- # so we only need to check the requirement now
- changes ||= dependency.requirement != locked_dep.requirement
- end
-
- changes
- end
-
- # Remove elements from the locked specs that are expired. This will most
- # commonly happen if the Gemfile has changed since the lockfile was last
- # generated
- def converge_locked_specs
- deps = []
-
- # Build a list of dependencies that are the same in the Gemfile
- # and Gemfile.lock. If the Gemfile modified a dependency, but
- # the gem in the Gemfile.lock still satisfies it, this is fine
- # too.
- @dependencies.each do |dep|
- locked_dep = @locked_deps[dep.name]
-
- # If the locked_dep doesn't match the dependency we're looking for then we ignore the locked_dep
- locked_dep = nil unless locked_dep == dep
-
- if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
- deps << dep
- elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source)
- @locked_specs.each do |s|
- @unlock[:gems] << s.name if s.source == dep.source
- end
-
- dep.source.unlock! if dep.source.respond_to?(:unlock!)
- dep.source.specs.each {|s| @unlock[:gems] << s.name }
- end
- end
-
- unlock_source_unlocks_spec = Bundler.feature_flag.unlock_source_unlocks_spec?
-
- converged = []
- @locked_specs.each do |s|
- # Replace the locked dependency's source with the equivalent source from the Gemfile
- dep = @dependencies.find {|d| s.satisfies?(d) }
- s.source = (dep && dep.source) || sources.get(s.source)
-
- # Don't add a spec to the list if its source is expired. For example,
- # if you change a Git gem to RubyGems.
- next if s.source.nil?
- next if @unlock[:sources].include?(s.source.name)
-
- # XXX This is a backwards-compatibility fix to preserve the ability to
- # unlock a single gem by passing its name via `--source`. See issue #3759
- # TODO: delete in Bundler 2
- next if unlock_source_unlocks_spec && @unlock[:sources].include?(s.name)
-
- # If the spec is from a path source and it doesn't exist anymore
- # then we unlock it.
-
- # Path sources have special logic
- if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
- new_specs = begin
- s.source.specs
- rescue PathError, GitError
- # if we won't need the source (according to the lockfile),
- # don't error if the path/git source isn't available
- next if @locked_specs.
- for(requested_dependencies, [], false, true, false).
- none? {|locked_spec| locked_spec.source == s.source }
-
- raise
- end
-
- new_spec = new_specs[s].first
-
- # If the spec is no longer in the path source, unlock it. This
- # commonly happens if the version changed in the gemspec
- next unless new_spec
-
- new_runtime_deps = new_spec.dependencies.select {|d| d.type != :development }
- old_runtime_deps = s.dependencies.select {|d| d.type != :development }
- # If the dependencies of the path source have changed and locked spec can't satisfy new dependencies, unlock it
- next unless new_runtime_deps.sort == old_runtime_deps.sort || new_runtime_deps.all? {|d| satisfies_locked_spec?(d) }
-
- s.dependencies.replace(new_spec.dependencies)
- end
-
- converged << s
- end
-
- resolve = SpecSet.new(converged)
- @locked_specs_incomplete_for_platform = !resolve.for(expand_dependencies(deps), @unlock[:gems], true, true)
- resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems], false, false, false)
- diff = nil
-
- # Now, we unlock any sources that do not have anymore gems pinned to it
- sources.all_sources.each do |source|
- next unless source.respond_to?(:unlock!)
-
- unless resolve.any? {|s| s.source == source }
- diff ||= @locked_specs.to_a - resolve.to_a
- source.unlock! if diff.any? {|s| s.source == source }
- end
- end
-
- resolve
- end
-
- def in_locked_deps?(dep, locked_dep)
- # Because the lockfile can't link a dep to a specific remote, we need to
- # treat sources as equivalent anytime the locked dep has all the remotes
- # that the Gemfile dep does.
- locked_dep && locked_dep.source && dep.source && locked_dep.source.include?(dep.source)
- end
-
- def satisfies_locked_spec?(dep)
- @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
- end
-
- # This list of dependencies is only used in #resolve, so it's OK to add
- # the metadata dependencies here
- def expanded_dependencies
- @expanded_dependencies ||= begin
- expand_dependencies(dependencies + metadata_dependencies, @remote)
- end
- end
-
- def metadata_dependencies
- @metadata_dependencies ||= begin
- ruby_versions = concat_ruby_version_requirements(@ruby_version)
- if ruby_versions.empty? || !@ruby_version.exact?
- concat_ruby_version_requirements(RubyVersion.system)
- concat_ruby_version_requirements(locked_ruby_version_object) unless @unlock[:ruby]
- end
- [
- Dependency.new("Ruby\0", ruby_versions),
- Dependency.new("RubyGems\0", Gem::VERSION),
- ]
- end
- end
-
- def concat_ruby_version_requirements(ruby_version, ruby_versions = [])
- return ruby_versions unless ruby_version
- if ruby_version.patchlevel
- ruby_versions << ruby_version.to_gem_version_with_patchlevel
- else
- ruby_versions.concat(ruby_version.versions.map do |version|
- requirement = Gem::Requirement.new(version)
- if requirement.exact?
- "~> #{version}.0"
- else
- requirement
- end
- end)
- end
- end
-
- def expand_dependencies(dependencies, remote = false)
- sorted_platforms = Resolver.sort_platforms(@platforms)
- deps = []
- dependencies.each do |dep|
- dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
- next if !remote && !dep.current_platform?
- platforms = dep.gem_platforms(sorted_platforms)
- if platforms.empty? && !Bundler.settings[:disable_platform_warnings]
- mapped_platforms = dep.expanded_platforms
- Bundler.ui.warn \
- "The dependency #{dep} will be unused by any of the platforms Bundler is installing for. " \
- "Bundler is installing for #{@platforms.join ", "} but the dependency " \
- "is only for #{mapped_platforms.join ", "}. " \
- "To add those platforms to the bundle, " \
- "run `bundle lock --add-platform #{mapped_platforms.join " "}`."
- end
- platforms.each do |p|
- deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
- end
- end
- deps
- end
-
- def requested_dependencies
- groups = requested_groups
- groups.map!(&:to_sym)
- dependencies.reject {|d| !d.should_include? || (d.groups & groups).empty? }
- end
-
- def source_requirements
- # Load all specs from remote sources
- index
-
- # Record the specs available in each gem's source, so that those
- # specs will be available later when the resolver knows where to
- # look for that gemspec (or its dependencies)
- default = sources.default_source
- source_requirements = { :default => default }
- default = nil unless Bundler.feature_flag.disable_multisource?
- dependencies.each do |dep|
- next unless source = dep.source || default
- source_requirements[dep.name] = source
- end
- metadata_dependencies.each do |dep|
- source_requirements[dep.name] = sources.metadata_source
- end
- source_requirements["bundler"] = sources.metadata_source # needs to come last to override
- source_requirements
- end
-
- def pinned_spec_names(skip = nil)
- pinned_names = []
- default = Bundler.feature_flag.disable_multisource? && sources.default_source
- @dependencies.each do |dep|
- next unless dep_source = dep.source || default
- next if dep_source == skip
- pinned_names << dep.name
- end
- pinned_names
- end
-
- def requested_groups
- groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
- end
-
- def lockfiles_equal?(current, proposed, preserve_unknown_sections)
- if preserve_unknown_sections
- sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
- sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
- sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
- pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
- whitespace_cleanup = /\n{2,}/
- current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
- proposed = proposed.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
- end
- current == proposed
- end
-
- def extract_gem_info(error)
- # This method will extract the error message like "Could not find foo-1.2.3 in any of the sources"
- # to an array. The first element will be the gem name (e.g. foo), the second will be the version number.
- error.message.scan(/Could not find (\w+)-(\d+(?:\.\d+)+)/).flatten
- end
-
- def compute_requires
- dependencies.reduce({}) do |requires, dep|
- next requires unless dep.should_include?
- requires[dep.name] = Array(dep.autorequire || dep.name).map do |file|
- # Allow `require: true` as an alias for `require: <name>`
- file == true ? dep.name : file
- end
- requires
- end
- end
-
- def additional_base_requirements_for_resolve
- return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
- dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
- @locked_gems.specs.reduce({}) do |requirements, locked_spec|
- name = locked_spec.name
- dependency = dependencies_by_name[name]
- next requirements if @locked_gems.dependencies[name] != dependency
- next requirements if dependency && dependency.source.is_a?(Source::Path)
- dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
- requirements[name] = DepProxy.new(dep, locked_spec.platform)
- requirements
- end.values
- end
-
- def equivalent_rubygems_remotes?(source)
- return false unless source.is_a?(Source::Rubygems)
-
- Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
- end
- end
-end
diff --git a/lib/bundler/dep_proxy.rb b/lib/bundler/dep_proxy.rb
deleted file mode 100644
index 6c32179ac1..0000000000
--- a/lib/bundler/dep_proxy.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class DepProxy
- attr_reader :__platform, :dep
-
- def initialize(dep, platform)
- @dep = dep
- @__platform = platform
- end
-
- def hash
- @hash ||= [dep, __platform].hash
- end
-
- def ==(other)
- return false if other.class != self.class
- dep == other.dep && __platform == other.__platform
- end
-
- alias_method :eql?, :==
-
- def type
- @dep.type
- end
-
- def name
- @dep.name
- end
-
- def requirement
- @dep.requirement
- end
-
- def to_s
- s = name.dup
- s << " (#{requirement})" unless requirement == Gem::Requirement.default
- s << " #{__platform}" unless __platform == Gem::Platform::RUBY
- s
- end
-
- private
-
- def method_missing(*args, &blk)
- @dep.send(*args, &blk)
- end
- end
-end
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
deleted file mode 100644
index 6c2642163e..0000000000
--- a/lib/bundler/dependency.rb
+++ /dev/null
@@ -1,151 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems/dependency"
-require_relative "shared_helpers"
-require_relative "rubygems_ext"
-
-module Bundler
- class Dependency < Gem::Dependency
- attr_reader :autorequire
- attr_reader :groups, :platforms, :gemfile, :git, :branch
-
- PLATFORM_MAP = {
- :ruby => Gem::Platform::RUBY,
- :ruby_18 => Gem::Platform::RUBY,
- :ruby_19 => Gem::Platform::RUBY,
- :ruby_20 => Gem::Platform::RUBY,
- :ruby_21 => Gem::Platform::RUBY,
- :ruby_22 => Gem::Platform::RUBY,
- :ruby_23 => Gem::Platform::RUBY,
- :ruby_24 => Gem::Platform::RUBY,
- :ruby_25 => Gem::Platform::RUBY,
- :ruby_26 => Gem::Platform::RUBY,
- :mri => Gem::Platform::RUBY,
- :mri_18 => Gem::Platform::RUBY,
- :mri_19 => Gem::Platform::RUBY,
- :mri_20 => Gem::Platform::RUBY,
- :mri_21 => Gem::Platform::RUBY,
- :mri_22 => Gem::Platform::RUBY,
- :mri_23 => Gem::Platform::RUBY,
- :mri_24 => Gem::Platform::RUBY,
- :mri_25 => Gem::Platform::RUBY,
- :mri_26 => Gem::Platform::RUBY,
- :rbx => Gem::Platform::RUBY,
- :truffleruby => Gem::Platform::RUBY,
- :jruby => Gem::Platform::JAVA,
- :jruby_18 => Gem::Platform::JAVA,
- :jruby_19 => Gem::Platform::JAVA,
- :mswin => Gem::Platform::MSWIN,
- :mswin_18 => Gem::Platform::MSWIN,
- :mswin_19 => Gem::Platform::MSWIN,
- :mswin_20 => Gem::Platform::MSWIN,
- :mswin_21 => Gem::Platform::MSWIN,
- :mswin_22 => Gem::Platform::MSWIN,
- :mswin_23 => Gem::Platform::MSWIN,
- :mswin_24 => Gem::Platform::MSWIN,
- :mswin_25 => Gem::Platform::MSWIN,
- :mswin_26 => Gem::Platform::MSWIN,
- :mswin64 => Gem::Platform::MSWIN64,
- :mswin64_19 => Gem::Platform::MSWIN64,
- :mswin64_20 => Gem::Platform::MSWIN64,
- :mswin64_21 => Gem::Platform::MSWIN64,
- :mswin64_22 => Gem::Platform::MSWIN64,
- :mswin64_23 => Gem::Platform::MSWIN64,
- :mswin64_24 => Gem::Platform::MSWIN64,
- :mswin64_25 => Gem::Platform::MSWIN64,
- :mswin64_26 => Gem::Platform::MSWIN64,
- :mingw => Gem::Platform::MINGW,
- :mingw_18 => Gem::Platform::MINGW,
- :mingw_19 => Gem::Platform::MINGW,
- :mingw_20 => Gem::Platform::MINGW,
- :mingw_21 => Gem::Platform::MINGW,
- :mingw_22 => Gem::Platform::MINGW,
- :mingw_23 => Gem::Platform::MINGW,
- :mingw_24 => Gem::Platform::MINGW,
- :mingw_25 => Gem::Platform::MINGW,
- :mingw_26 => Gem::Platform::MINGW,
- :x64_mingw => Gem::Platform::X64_MINGW,
- :x64_mingw_20 => Gem::Platform::X64_MINGW,
- :x64_mingw_21 => Gem::Platform::X64_MINGW,
- :x64_mingw_22 => Gem::Platform::X64_MINGW,
- :x64_mingw_23 => Gem::Platform::X64_MINGW,
- :x64_mingw_24 => Gem::Platform::X64_MINGW,
- :x64_mingw_25 => Gem::Platform::X64_MINGW,
- :x64_mingw_26 => Gem::Platform::X64_MINGW,
- }.freeze
-
- REVERSE_PLATFORM_MAP = {}.tap do |reverse_platform_map|
- PLATFORM_MAP.each do |key, value|
- reverse_platform_map[value] ||= []
- reverse_platform_map[value] << key
- end
-
- reverse_platform_map.each {|_, platforms| platforms.freeze }
- end.freeze
-
- def initialize(name, version, options = {}, &blk)
- type = options["type"] || :runtime
- super(name, version, type)
-
- @autorequire = nil
- @groups = Array(options["group"] || :default).map(&:to_sym)
- @source = options["source"]
- @git = options["git"]
- @branch = options["branch"]
- @platforms = Array(options["platforms"])
- @env = options["env"]
- @should_include = options.fetch("should_include", true)
- @gemfile = options["gemfile"]
-
- @autorequire = Array(options["require"] || []) if options.key?("require")
- end
-
- # Returns the platforms this dependency is valid for, in the same order as
- # passed in the `valid_platforms` parameter
- def gem_platforms(valid_platforms)
- return valid_platforms if @platforms.empty?
-
- @gem_platforms ||= expanded_platforms.compact.uniq
-
- valid_platforms & @gem_platforms
- end
-
- def expanded_platforms
- @platforms.map {|pl| PLATFORM_MAP[pl] }
- end
-
- def should_include?
- @should_include && current_env? && current_platform?
- end
-
- def current_env?
- return true unless @env
- if @env.is_a?(Hash)
- @env.all? do |key, val|
- ENV[key.to_s] && (val.is_a?(String) ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)
- end
- else
- ENV[@env.to_s]
- end
- end
-
- def current_platform?
- return true if @platforms.empty?
- @platforms.any? do |p|
- Bundler.current_ruby.send("#{p}?")
- end
- end
-
- def to_lock
- out = super
- out << "!" if source
- out << "\n"
- end
-
- def specific?
- super
- rescue NoMethodError
- requirement != ">= 0"
- end
- end
-end
diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb
deleted file mode 100644
index b432ae6ae1..0000000000
--- a/lib/bundler/deployment.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "shared_helpers"
-Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \
- "Capistrano, but Capistrano provides its own integration with " \
- "Bundler via the capistrano-bundler gem. Use it instead."
-
-module Bundler
- class Deployment
- def self.define_task(context, task_method = :task, opts = {})
- if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
- context_name = "capistrano"
- role_default = "{:except => {:no_release => true}}"
- error_type = ::Capistrano::CommandError
- else
- context_name = "vlad"
- role_default = "[:app]"
- error_type = ::Rake::CommandFailedError
- end
-
- roles = context.fetch(:bundle_roles, false)
- opts[:roles] = roles if roles
-
- context.send :namespace, :bundle do
- send :desc, <<-DESC
- Install the current Bundler environment. By default, gems will be \
- installed to the shared/bundle path. Gems in the development and \
- test group will not be installed. The install command is executed \
- with the --deployment and --quiet flags. If the bundle cmd cannot \
- be found then you can override the bundle_cmd variable to specify \
- which one it should use. The base path to the app is fetched from \
- the :latest_release variable. Set it for custom deploy layouts.
-
- You can override any of these defaults by setting the variables shown below.
-
- N.B. bundle_roles must be defined before you require 'bundler/#{context_name}' \
- in your deploy.rb file.
-
- set :bundle_gemfile, "Gemfile"
- set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
- set :bundle_flags, "--deployment --quiet"
- set :bundle_without, [:development, :test]
- set :bundle_with, [:mysql]
- set :bundle_cmd, "bundle" # e.g. "/opt/ruby/bin/bundle"
- set :bundle_roles, #{role_default} # e.g. [:app, :batch]
- DESC
- send task_method, :install, opts do
- bundle_cmd = context.fetch(:bundle_cmd, "bundle")
- bundle_flags = context.fetch(:bundle_flags, "--deployment --quiet")
- bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), "bundle"))
- bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
- bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact
- bundle_with = [*context.fetch(:bundle_with, [])].compact
- app_path = context.fetch(:latest_release)
- if app_path.to_s.empty?
- raise error_type.new("Cannot detect current release path - make sure you have deployed at least once.")
- end
- args = ["--gemfile #{File.join(app_path, bundle_gemfile)}"]
- args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
- args << bundle_flags.to_s
- args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
- args << "--with #{bundle_with.join(" ")}" unless bundle_with.empty?
-
- run "cd #{app_path} && #{bundle_cmd} install #{args.join(" ")}"
- end
- end
- end
- end
-end
diff --git a/lib/bundler/deprecate.rb b/lib/bundler/deprecate.rb
deleted file mode 100644
index f59533630e..0000000000
--- a/lib/bundler/deprecate.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require "rubygems/deprecate"
-rescue LoadError
- # it's fine if it doesn't exist on the current RubyGems...
- nil
-end
-
-module Bundler
- # If Bundler::Deprecate is an autoload constant, we need to define it
- if defined?(Bundler::Deprecate) && !autoload?(:Deprecate)
- # nothing to do!
- elsif defined? ::Deprecate
- Deprecate = ::Deprecate
- elsif defined? Gem::Deprecate
- Deprecate = Gem::Deprecate
- else
- class Deprecate
- end
- end
-
- unless Deprecate.respond_to?(:skip_during)
- def Deprecate.skip_during
- original = skip
- self.skip = true
- yield
- ensure
- self.skip = original
- end
- end
-
- unless Deprecate.respond_to?(:skip)
- def Deprecate.skip
- @skip ||= false
- end
- end
-
- unless Deprecate.respond_to?(:skip=)
- def Deprecate.skip=(skip)
- @skip = skip
- end
- end
-end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
deleted file mode 100644
index 99a369281a..0000000000
--- a/lib/bundler/dsl.rb
+++ /dev/null
@@ -1,591 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "dependency"
-require_relative "ruby_dsl"
-
-module Bundler
- class Dsl
- include RubyDsl
-
- def self.evaluate(gemfile, lockfile, unlock)
- builder = new
- builder.eval_gemfile(gemfile)
- builder.to_definition(lockfile, unlock)
- end
-
- VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
-
- VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
- platform platforms type source install_if gemfile].freeze
-
- attr_reader :gemspecs
- attr_accessor :dependencies
-
- def initialize
- @source = nil
- @sources = SourceList.new
- @git_sources = {}
- @dependencies = []
- @groups = []
- @install_conditionals = []
- @optional_groups = []
- @platforms = []
- @env = nil
- @ruby_version = nil
- @gemspecs = []
- @gemfile = nil
- @gemfiles = []
- add_git_sources
- end
-
- def eval_gemfile(gemfile, contents = nil)
- expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile && @gemfile.parent)
- original_gemfile = @gemfile
- @gemfile = expanded_gemfile_path
- @gemfiles << expanded_gemfile_path
- contents ||= Bundler.read_file(@gemfile.to_s)
- instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
- rescue Exception => e # rubocop:disable Lint/RescueException
- message = "There was an error " \
- "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
- "`#{File.basename gemfile.to_s}`: #{e.message}"
-
- raise DSLError.new(message, gemfile, e.backtrace, contents)
- ensure
- @gemfile = original_gemfile
- end
-
- def gemspec(opts = nil)
- opts ||= {}
- path = opts[:path] || "."
- glob = opts[:glob]
- name = opts[:name]
- development_group = opts[:development_group] || :development
- expanded_path = gemfile_root.join(path)
-
- gemspecs = Dir[File.join(expanded_path, "{,*}.gemspec")].map {|g| Bundler.load_gemspec(g) }.compact
- gemspecs.reject! {|s| s.name != name } if name
- Index.sort_specs(gemspecs)
- specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
-
- case specs_by_name_and_version.size
- when 1
- specs = specs_by_name_and_version.values.first
- spec = specs.find {|s| s.match_platform(Bundler.local_platform) } || specs.first
-
- @gemspecs << spec
-
- gem_platforms = Bundler::Dependency::REVERSE_PLATFORM_MAP[Bundler::GemHelpers.generic_local_platform]
- gem spec.name, :name => spec.name, :path => path, :glob => glob, :platforms => gem_platforms
-
- group(development_group) do
- spec.development_dependencies.each do |dep|
- gem dep.name, *(dep.requirement.as_list + [:type => :development])
- end
- end
- when 0
- raise InvalidOption, "There are no gemspecs at #{expanded_path}"
- else
- raise InvalidOption, "There are multiple gemspecs at #{expanded_path}. " \
- "Please use the :name option to specify which one should be used"
- end
- end
-
- def gem(name, *args)
- options = args.last.is_a?(Hash) ? args.pop.dup : {}
- options["gemfile"] = @gemfile
- version = args || [">= 0"]
-
- normalize_options(name, version, options)
-
- dep = Dependency.new(name, version, options)
-
- # if there's already a dependency with this name we try to prefer one
- if current = @dependencies.find {|d| d.name == dep.name }
- deleted_dep = @dependencies.delete(current) if current.type == :development
-
- if current.requirement != dep.requirement
- unless deleted_dep
- return if dep.type == :development
-
- update_prompt = ""
-
- if File.basename(@gemfile) == Injector::INJECTED_GEMS
- if dep.requirements_list.include?(">= 0") && !current.requirements_list.include?(">= 0")
- update_prompt = ". Gem already added"
- else
- update_prompt = ". If you want to update the gem version, run `bundle update #{current.name}`"
-
- update_prompt += ". You may also need to change the version requirement specified in the Gemfile if it's too restrictive." unless current.requirements_list.include?(">= 0")
- end
- end
-
- raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
- "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
- "#{update_prompt}"
- end
-
- else
- Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
- "You should probably keep only one of them.\n" \
- "Remove any duplicate entries and specify the gem only once.\n" \
- "While it's not a problem now, it could cause errors if you change the version of one of them later."
- end
-
- if current.source != dep.source
- unless deleted_dep
- return if dep.type == :development
- raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
- "You specified that #{dep.name} (#{dep.requirement}) should come from " \
- "#{current.source || "an unspecified source"} and #{dep.source}\n"
- end
- end
- end
-
- @dependencies << dep
- end
-
- def source(source, *args, &blk)
- options = args.last.is_a?(Hash) ? args.pop.dup : {}
- options = normalize_hash(options)
- source = normalize_source(source)
-
- if options.key?("type")
- options["type"] = options["type"].to_s
- unless Plugin.source?(options["type"])
- raise InvalidOption, "No plugin sources available for #{options["type"]}"
- end
-
- unless block_given?
- raise InvalidOption, "You need to pass a block to #source with :type option"
- end
-
- source_opts = options.merge("uri" => source)
- with_source(@sources.add_plugin_source(options["type"], source_opts), &blk)
- elsif block_given?
- with_source(@sources.add_rubygems_source("remotes" => source), &blk)
- else
- check_primary_source_safety(@sources)
- @sources.global_rubygems_source = source
- end
- end
-
- def git_source(name, &block)
- unless block_given?
- raise InvalidOption, "You need to pass a block to #git_source"
- end
-
- if valid_keys.include?(name.to_s)
- raise InvalidOption, "You cannot use #{name} as a git source. It " \
- "is a reserved key. Reserved keys are: #{valid_keys.join(", ")}"
- end
-
- @git_sources[name.to_s] = block
- end
-
- def path(path, options = {}, &blk)
- unless block_given?
- msg = "You can no longer specify a path source by itself. Instead, \n" \
- "either use the :path option on a gem, or specify the gems that \n" \
- "bundler should find in the path source by passing a block to \n" \
- "the path method, like: \n\n" \
- " path 'dir/containing/rails' do\n" \
- " gem 'rails'\n" \
- " end\n\n"
-
- raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
- SharedHelpers.major_deprecation(2, msg.strip)
- end
-
- source_options = normalize_hash(options).merge(
- "path" => Pathname.new(path),
- "root_path" => gemfile_root,
- "gemspec" => gemspecs.find {|g| g.name == options["name"] }
- )
- source = @sources.add_path_source(source_options)
- with_source(source, &blk)
- end
-
- def git(uri, options = {}, &blk)
- unless block_given?
- msg = "You can no longer specify a git source by itself. Instead, \n" \
- "either use the :git option on a gem, or specify the gems that \n" \
- "bundler should find in the git source by passing a block to \n" \
- "the git method, like: \n\n" \
- " git 'git://github.com/rails/rails.git' do\n" \
- " gem 'rails'\n" \
- " end"
- raise DeprecatedError, msg
- end
-
- with_source(@sources.add_git_source(normalize_hash(options).merge("uri" => uri)), &blk)
- end
-
- def github(repo, options = {})
- raise ArgumentError, "GitHub sources require a block" unless block_given?
- raise DeprecatedError, "The #github method has been removed" if Bundler.feature_flag.skip_default_git_sources?
- github_uri = @git_sources["github"].call(repo)
- git_options = normalize_hash(options).merge("uri" => github_uri)
- git_source = @sources.add_git_source(git_options)
- with_source(git_source) { yield }
- end
-
- def to_definition(lockfile, unlock)
- Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version, @optional_groups, @gemfiles)
- end
-
- def group(*args, &blk)
- options = args.last.is_a?(Hash) ? args.pop.dup : {}
- normalize_group_options(options, args)
-
- @groups.concat args
-
- if options["optional"]
- optional_groups = args - @optional_groups
- @optional_groups.concat optional_groups
- end
-
- yield
- ensure
- args.each { @groups.pop }
- end
-
- def install_if(*args)
- @install_conditionals.concat args
- yield
- ensure
- args.each { @install_conditionals.pop }
- end
-
- def platforms(*platforms)
- @platforms.concat platforms
- yield
- ensure
- platforms.each { @platforms.pop }
- end
- alias_method :platform, :platforms
-
- def env(name)
- old = @env
- @env = name
- yield
- ensure
- @env = old
- end
-
- def plugin(*args)
- # Pass on
- end
-
- def method_missing(name, *args)
- raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
- end
-
- private
-
- def add_git_sources
- return if Bundler.feature_flag.skip_default_git_sources?
-
- git_source(:github) do |repo_name|
- warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".')
-"https://github.com/#{repo_name}.git"
- RUBY
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
- "https://github.com/#{repo_name}.git"
- end
-
- git_source(:gist) do |repo_name|
- warn_deprecated_git_source(:gist, '"https://gist.github.com/#{repo_name}.git"')
-
- "https://gist.github.com/#{repo_name}.git"
- end
-
- git_source(:bitbucket) do |repo_name|
- warn_deprecated_git_source(:bitbucket, <<-'RUBY'.strip)
-user_name, repo_name = repo_name.split("/")
-repo_name ||= user_name
-"https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
- RUBY
-
- user_name, repo_name = repo_name.split("/")
- repo_name ||= user_name
- "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
- end
- end
-
- def with_source(source)
- old_source = @source
- if block_given?
- @source = source
- yield
- end
- source
- ensure
- @source = old_source
- end
-
- def normalize_hash(opts)
- opts.keys.each do |k|
- opts[k.to_s] = opts.delete(k) unless k.is_a?(String)
- end
- opts
- end
-
- def valid_keys
- @valid_keys ||= VALID_KEYS
- end
-
- def normalize_options(name, version, opts)
- if name.is_a?(Symbol)
- raise GemfileError, %(You need to specify gem names as Strings. Use 'gem "#{name}"' instead)
- end
- if name =~ /\s/
- raise GemfileError, %('#{name}' is not a valid gem name because it contains whitespace)
- end
- raise GemfileError, %(an empty gem name is not valid) if name.empty?
-
- normalize_hash(opts)
-
- git_names = @git_sources.keys.map(&:to_s)
- validate_keys("gem '#{name}'", opts, valid_keys + git_names)
-
- groups = @groups.dup
- opts["group"] = opts.delete("groups") || opts["group"]
- groups.concat Array(opts.delete("group"))
- groups = [:default] if groups.empty?
-
- install_if = @install_conditionals.dup
- install_if.concat Array(opts.delete("install_if"))
- install_if = install_if.reduce(true) do |memo, val|
- memo && (val.respond_to?(:call) ? val.call : val)
- end
-
- platforms = @platforms.dup
- opts["platforms"] = opts["platform"] || opts["platforms"]
- platforms.concat Array(opts.delete("platforms"))
- platforms.map!(&:to_sym)
- platforms.each do |p|
- next if VALID_PLATFORMS.include?(p)
- raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
- end
-
- # Save sources passed in a key
- if opts.key?("source")
- source = normalize_source(opts["source"])
- opts["source"] = @sources.add_rubygems_source("remotes" => source)
- end
-
- git_name = (git_names & opts.keys).last
- if @git_sources[git_name]
- opts["git"] = @git_sources[git_name].call(opts[git_name])
- end
-
- %w[git path].each do |type|
- next unless param = opts[type]
- if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
- options = opts.merge("name" => name, "version" => $1)
- else
- options = opts.dup
- end
- source = send(type, param, options) {}
- opts["source"] = source
- end
-
- opts["source"] ||= @source
- opts["env"] ||= @env
- opts["platforms"] = platforms.dup
- opts["group"] = groups
- opts["should_include"] = install_if
- end
-
- def normalize_group_options(opts, groups)
- normalize_hash(opts)
-
- groups = groups.map {|group| ":#{group}" }.join(", ")
- validate_keys("group #{groups}", opts, %w[optional])
-
- opts["optional"] ||= false
- end
-
- def validate_keys(command, opts, valid_keys)
- invalid_keys = opts.keys - valid_keys
-
- git_source = opts.keys & @git_sources.keys.map(&:to_s)
- if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?)
- raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch)
- end
-
- return true unless invalid_keys.any?
-
- message = String.new
- message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} "
- message << if invalid_keys.size > 1
- "as options for #{command}, but they are invalid."
- else
- "as an option for #{command}, but it is invalid."
- end
-
- message << " Valid options are: #{valid_keys.join(", ")}."
- message << " You may be able to resolve this by upgrading Bundler to the newest version."
- raise InvalidOption, message
- end
-
- def normalize_source(source)
- case source
- when :gemcutter, :rubygems, :rubyforge
- Bundler::SharedHelpers.major_deprecation 2, "The source :#{source} is deprecated because HTTP " \
- "requests are insecure.\nPlease change your source to 'https://" \
- "rubygems.org' if possible, or 'http://rubygems.org' if not."
- "http://rubygems.org"
- when String
- source
- else
- raise GemfileError, "Unknown source '#{source}'"
- end
- end
-
- def check_primary_source_safety(source_list)
- return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
-
- if Bundler.feature_flag.disable_multisource?
- msg = "This Gemfile contains multiple primary sources. " \
- "Each source after the first must include a block to indicate which gems " \
- "should come from that source"
- unless Bundler.feature_flag.bundler_2_mode?
- msg += ". To downgrade this error to a warning, run " \
- "`bundle config unset disable_multisource`"
- end
- raise GemfileEvalError, msg
- else
- Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
- "Using `source` more than once without a block is a security risk, and " \
- "may result in installing unexpected gems. To resolve this warning, use " \
- "a block to indicate which gems should come from the secondary source. " \
- "To upgrade this warning to an error, run `bundle config set " \
- "disable_multisource true`."
- end
- end
-
- def warn_deprecated_git_source(name, replacement, additional_message = nil)
- additional_message &&= " #{additional_message}"
- replacement = if replacement.count("\n").zero?
- "{|repo_name| #{replacement} }"
- else
- "do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end"
- end
-
- Bundler::SharedHelpers.major_deprecation 3, <<-EOS
-The :#{name} git source is deprecated, and will be removed in the future.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work:
-
- git_source(:#{name}) #{replacement}
-
- EOS
- end
-
- class DSLError < GemfileError
- # @return [String] the description that should be presented to the user.
- #
- attr_reader :description
-
- # @return [String] the path of the dsl file that raised the exception.
- #
- attr_reader :dsl_path
-
- # @return [Exception] the backtrace of the exception raised by the
- # evaluation of the dsl file.
- #
- attr_reader :backtrace
-
- # @param [Exception] backtrace @see backtrace
- # @param [String] dsl_path @see dsl_path
- #
- def initialize(description, dsl_path, backtrace, contents = nil)
- @status_code = $!.respond_to?(:status_code) && $!.status_code
-
- @description = description
- @dsl_path = dsl_path
- @backtrace = backtrace
- @contents = contents
- end
-
- def status_code
- @status_code || super
- end
-
- # @return [String] the contents of the DSL that cause the exception to
- # be raised.
- #
- def contents
- @contents ||= begin
- dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
- end
- end
-
- # The message of the exception reports the content of podspec for the
- # line that generated the original exception.
- #
- # @example Output
- #
- # Invalid podspec at `RestKit.podspec` - undefined method
- # `exclude_header_search_paths=' for #<Pod::Specification for
- # `RestKit/Network (0.9.3)`>
- #
- # from spec-repos/master/RestKit/0.9.3/RestKit.podspec:36
- # -------------------------------------------
- # # because it would break: #import <CoreData/CoreData.h>
- # > ns.exclude_header_search_paths = 'Code/RestKit.h'
- # end
- # -------------------------------------------
- #
- # @return [String] the message of the exception.
- #
- def to_s
- @to_s ||= begin
- trace_line, description = parse_line_number_from_description
-
- m = String.new("\n[!] ")
- m << description
- m << ". Bundler cannot continue.\n"
-
- return m unless backtrace && dsl_path && contents
-
- trace_line = backtrace.find {|l| l.include?(dsl_path.to_s) } || trace_line
- return m unless trace_line
- line_numer = trace_line.split(":")[1].to_i - 1
- return m unless line_numer
-
- lines = contents.lines.to_a
- indent = " # "
- indicator = indent.tr("#", ">")
- first_line = line_numer.zero?
- last_line = (line_numer == (lines.count - 1))
-
- m << "\n"
- m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n"
- m << "#{indent}-------------------------------------------\n"
- m << "#{indent}#{lines[line_numer - 1]}" unless first_line
- m << "#{indicator}#{lines[line_numer]}"
- m << "#{indent}#{lines[line_numer + 1]}" unless last_line
- m << "\n" unless m.end_with?("\n")
- m << "#{indent}-------------------------------------------\n"
- end
- end
-
- private
-
- def parse_line_number_from_description
- description = self.description
- if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/
- trace_line = Regexp.last_match[1]
- description = description.sub(/\n.*\n(\.\.\.)? *\^~+$/, "").sub(/#{Regexp.quote trace_line}:\s*/, "").sub("\n", " - ")
- end
- [trace_line, description]
- end
- end
-
- def gemfile_root
- @gemfile ||= Bundler.default_gemfile
- @gemfile.dirname
- end
- end
-end
diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb
deleted file mode 100644
index 9a00b64e0e..0000000000
--- a/lib/bundler/endpoint_specification.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # used for Creating Specifications from the Gemcutter Endpoint
- class EndpointSpecification < Gem::Specification
- ILLFORMED_MESSAGE = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'.freeze
- include MatchPlatform
-
- attr_reader :name, :version, :platform, :required_rubygems_version, :required_ruby_version, :checksum
- attr_accessor :source, :remote, :dependencies
-
- def initialize(name, version, platform, dependencies, metadata = nil)
- super()
- @name = name
- @version = Gem::Version.create version
- @platform = platform
- @dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
-
- @loaded_from = nil
- @remote_specification = nil
-
- parse_metadata(metadata)
- end
-
- def fetch_platform
- @platform
- end
-
- # needed for standalone, load required_paths from local gemspec
- # after the gem is installed
- def require_paths
- if @remote_specification
- @remote_specification.require_paths
- elsif _local_specification
- _local_specification.require_paths
- else
- super
- end
- end
-
- # needed for inline
- def load_paths
- # remote specs aren't installed, and can't have load_paths
- if _local_specification
- _local_specification.load_paths
- else
- super
- end
- end
-
- # needed for binstubs
- def executables
- if @remote_specification
- @remote_specification.executables
- elsif _local_specification
- _local_specification.executables
- else
- super
- end
- end
-
- # needed for bundle clean
- def bindir
- if @remote_specification
- @remote_specification.bindir
- elsif _local_specification
- _local_specification.bindir
- else
- super
- end
- end
-
- # needed for post_install_messages during install
- def post_install_message
- if @remote_specification
- @remote_specification.post_install_message
- elsif _local_specification
- _local_specification.post_install_message
- else
- super
- end
- end
-
- # needed for "with native extensions" during install
- def extensions
- if @remote_specification
- @remote_specification.extensions
- elsif _local_specification
- _local_specification.extensions
- else
- super
- end
- end
-
- def _local_specification
- return unless @loaded_from && File.exist?(local_specification_path)
- eval(File.read(local_specification_path)).tap do |spec|
- spec.loaded_from = @loaded_from
- end
- end
-
- def __swap__(spec)
- SharedHelpers.ensure_same_dependencies(self, dependencies, spec.dependencies)
- @remote_specification = spec
- end
-
- private
-
- def local_specification_path
- "#{base_dir}/specifications/#{full_name}.gemspec"
- end
-
- def parse_metadata(data)
- return unless data
- data.each do |k, v|
- next unless v
- case k.to_s
- when "checksum"
- @checksum = v.last
- when "rubygems"
- @required_rubygems_version = Gem::Requirement.new(v)
- when "ruby"
- @required_ruby_version = Gem::Requirement.new(v)
- end
- end
- rescue StandardError => e
- raise GemspecError, "There was an error parsing the metadata for the gem #{name} (#{version}): #{e.class}\n#{e}\nThe metadata was #{data.inspect}"
- end
-
- def build_dependency(name, requirements)
- Gem::Dependency.new(name, requirements)
- rescue ArgumentError => e
- raise unless e.message.include?(ILLFORMED_MESSAGE)
- puts # we shouldn't print the error message on the "fetching info" status line
- raise GemspecError,
- "Unfortunately, the gem #{name} (#{version}) has an invalid " \
- "gemspec.\nPlease ask the gem author to yank the bad version to fix " \
- "this issue. For more information, see http://bit.ly/syck-defaultkey."
- end
- end
-end
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
deleted file mode 100644
index 17624b4fe9..0000000000
--- a/lib/bundler/env.rb
+++ /dev/null
@@ -1,150 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "rubygems_integration"
-require_relative "source/git/git_proxy"
-
-module Bundler
- class Env
- def self.write(io)
- io.write report
- end
-
- def self.report(options = {})
- print_gemfile = options.delete(:print_gemfile) { true }
- print_gemspecs = options.delete(:print_gemspecs) { true }
-
- out = String.new
- append_formatted_table("Environment", environment, out)
- append_formatted_table("Bundler Build Metadata", BuildMetadata.to_h, out)
-
- unless Bundler.settings.all.empty?
- out << "\n## Bundler settings\n\n```\n"
- Bundler.settings.all.each do |setting|
- out << setting << "\n"
- Bundler.settings.pretty_values_for(setting).each do |line|
- out << " " << line << "\n"
- end
- end
- out << "```\n"
- end
-
- return out unless SharedHelpers.in_bundle?
-
- if print_gemfile
- gemfiles = [Bundler.default_gemfile]
- begin
- gemfiles = Bundler.definition.gemfiles
- rescue GemfileNotFound
- nil
- end
-
- out << "\n## Gemfile\n"
- gemfiles.each do |gemfile|
- out << "\n### #{Pathname.new(gemfile).relative_path_from(SharedHelpers.pwd)}\n\n"
- out << "```ruby\n" << read_file(gemfile).chomp << "\n```\n"
- end
-
- out << "\n### #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}\n\n"
- out << "```\n" << read_file(Bundler.default_lockfile).chomp << "\n```\n"
- end
-
- if print_gemspecs
- dsl = Dsl.new.tap {|d| d.eval_gemfile(Bundler.default_gemfile) }
- out << "\n## Gemspecs\n" unless dsl.gemspecs.empty?
- dsl.gemspecs.each do |gs|
- out << "\n### #{File.basename(gs.loaded_from)}"
- out << "\n\n```ruby\n" << read_file(gs.loaded_from).chomp << "\n```\n"
- end
- end
-
- out
- end
-
- def self.read_file(filename)
- Bundler.read_file(filename.to_s).strip
- rescue Errno::ENOENT
- "<No #{filename} found>"
- rescue RuntimeError => e
- "#{e.class}: #{e.message}"
- end
-
- def self.ruby_version
- str = String.new(RUBY_VERSION)
- str << "p#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
- str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{RUBY_PLATFORM}]"
- end
-
- def self.git_version
- Bundler::Source::Git::GitProxy.new(nil, nil, nil).full_version
- rescue Bundler::Source::Git::GitNotInstalledError
- "not installed"
- end
-
- def self.version_of(script)
- return "not installed" unless Bundler.which(script)
- `#{script} --version`.chomp
- end
-
- def self.chruby_version
- return "not installed" unless Bundler.which("chruby-exec")
- `chruby-exec -- chruby --version`.
- sub(/.*^chruby: (#{Gem::Version::VERSION_PATTERN}).*/m, '\1')
- end
-
- def self.environment
- out = []
-
- out << ["Bundler", Bundler::VERSION]
- out << [" Platforms", Gem.platforms.join(", ")]
- out << ["Ruby", ruby_version]
- out << [" Full Path", Gem.ruby]
- out << [" Config Dir", Pathname.new(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE).dirname]
- out << ["RubyGems", Gem::VERSION]
- out << [" Gem Home", Gem.dir]
- out << [" Gem Path", Gem.path.join(File::PATH_SEPARATOR)]
- out << [" User Home", Gem.user_home]
- out << [" User Path", Gem.user_dir]
- out << [" Bin Dir", Gem.bindir]
- if defined?(OpenSSL)
- out << ["OpenSSL"]
- out << [" Compiled", OpenSSL::OPENSSL_VERSION] if defined?(OpenSSL::OPENSSL_VERSION)
- out << [" Loaded", OpenSSL::OPENSSL_LIBRARY_VERSION] if defined?(OpenSSL::OPENSSL_LIBRARY_VERSION)
- out << [" Cert File", OpenSSL::X509::DEFAULT_CERT_FILE] if defined?(OpenSSL::X509::DEFAULT_CERT_FILE)
- out << [" Cert Dir", OpenSSL::X509::DEFAULT_CERT_DIR] if defined?(OpenSSL::X509::DEFAULT_CERT_DIR)
- end
- out << ["Tools"]
- out << [" Git", git_version]
- out << [" RVM", ENV.fetch("rvm_version") { version_of("rvm") }]
- out << [" rbenv", version_of("rbenv")]
- out << [" chruby", chruby_version]
-
- %w[rubygems-bundler open_gem].each do |name|
- specs = Bundler.rubygems.find_name(name)
- out << [" #{name}", "(#{specs.map(&:version).join(",")})"] unless specs.empty?
- end
- if (exe = caller.last.split(":").first) && exe =~ %r{(exe|bin)/bundler?\z}
- shebang = File.read(exe).lines.first
- shebang.sub!(/^#!\s*/, "")
- unless shebang.start_with?(Gem.ruby, "/usr/bin/env ruby")
- out << ["Gem.ruby", Gem.ruby]
- out << ["bundle #!", shebang]
- end
- end
-
- out
- end
-
- def self.append_formatted_table(title, pairs, out)
- return if pairs.empty?
- out << "\n" unless out.empty?
- out << "## #{title}\n\n```\n"
- ljust = pairs.map {|k, _v| k.to_s.length }.max
- pairs.each do |k, v|
- out << "#{k.to_s.ljust(ljust)} #{v}\n"
- end
- out << "```\n"
- end
-
- private_class_method :read_file, :ruby_version, :git_version, :append_formatted_table, :version_of, :chruby_version
- end
-end
diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb
deleted file mode 100644
index c9014badad..0000000000
--- a/lib/bundler/environment_preserver.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class EnvironmentPreserver
- INTENTIONALLY_NIL = "BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL".freeze
- BUNDLER_KEYS = %w[
- BUNDLE_BIN_PATH
- BUNDLE_GEMFILE
- BUNDLER_VERSION
- GEM_HOME
- GEM_PATH
- MANPATH
- PATH
- RB_USER_INSTALL
- RUBYLIB
- RUBYOPT
- ].map(&:freeze).freeze
- BUNDLER_PREFIX = "BUNDLER_ORIG_".freeze
-
- # @param env [ENV]
- # @param keys [Array<String>]
- def initialize(env, keys)
- @original = env.to_hash
- @keys = keys
- @prefix = BUNDLER_PREFIX
- end
-
- # @return [Hash]
- def backup
- env = @original.clone
- @keys.each do |key|
- value = env[key]
- if !value.nil? && !value.empty?
- env[@prefix + key] ||= value
- elsif value.nil?
- env[@prefix + key] ||= INTENTIONALLY_NIL
- end
- end
- env
- end
-
- # @return [Hash]
- def restore
- env = @original.clone
- @keys.each do |key|
- value_original = env[@prefix + key]
- next if value_original.nil? || value_original.empty?
- if value_original == INTENTIONALLY_NIL
- env.delete(key)
- else
- env[key] = value_original
- end
- env.delete(@prefix + key)
- end
- env
- end
- end
-end
diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb
deleted file mode 100644
index e471bce0b6..0000000000
--- a/lib/bundler/errors.rb
+++ /dev/null
@@ -1,158 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class BundlerError < StandardError
- def self.status_code(code)
- define_method(:status_code) { code }
- if match = BundlerError.all_errors.find {|_k, v| v == code }
- error, _ = match
- raise ArgumentError,
- "Trying to register #{self} for status code #{code} but #{error} is already registered"
- end
- BundlerError.all_errors[self] = code
- end
-
- def self.all_errors
- @all_errors ||= {}
- end
- end
-
- class GemfileError < BundlerError; status_code(4); end
- class InstallError < BundlerError; status_code(5); end
-
- # Internal error, should be rescued
- class VersionConflict < BundlerError
- attr_reader :conflicts
-
- def initialize(conflicts, msg = nil)
- super(msg)
- @conflicts = conflicts
- end
-
- status_code(6)
- end
-
- class GemNotFound < BundlerError; status_code(7); end
- class InstallHookError < BundlerError; status_code(8); end
- class GemfileNotFound < BundlerError; status_code(10); end
- class GitError < BundlerError; status_code(11); end
- class DeprecatedError < BundlerError; status_code(12); end
- class PathError < BundlerError; status_code(13); end
- class GemspecError < BundlerError; status_code(14); end
- class InvalidOption < BundlerError; status_code(15); end
- class ProductionError < BundlerError; status_code(16); end
- class HTTPError < BundlerError
- status_code(17)
- def filter_uri(uri)
- URICredentialsFilter.credential_filtered_uri(uri)
- end
- end
- class RubyVersionMismatch < BundlerError; status_code(18); end
- class SecurityError < BundlerError; status_code(19); end
- class LockfileError < BundlerError; status_code(20); end
- class CyclicDependencyError < BundlerError; status_code(21); end
- class GemfileLockNotFound < BundlerError; status_code(22); end
- class PluginError < BundlerError; status_code(29); end
- class SudoNotPermittedError < BundlerError; status_code(30); end
- class ThreadCreationError < BundlerError; status_code(33); end
- class APIResponseMismatchError < BundlerError; status_code(34); end
- class GemfileEvalError < GemfileError; end
- class MarshalError < StandardError; end
-
- class PermissionError < BundlerError
- def initialize(path, permission_type = :write)
- @path = path
- @permission_type = permission_type
- end
-
- def action
- case @permission_type
- when :read then "read from"
- when :write then "write to"
- when :executable, :exec then "execute"
- else @permission_type.to_s
- end
- end
-
- def message
- "There was an error while trying to #{action} `#{@path}`. " \
- "It is likely that you need to grant #{@permission_type} permissions " \
- "for that path."
- end
-
- status_code(23)
- end
-
- class GemRequireError < BundlerError
- attr_reader :orig_exception
-
- def initialize(orig_exception, msg)
- full_message = msg + "\nGem Load Error is: #{orig_exception.message}\n"\
- "Backtrace for gem load error is:\n"\
- "#{orig_exception.backtrace.join("\n")}\n"\
- "Bundler Error Backtrace:\n"
- super(full_message)
- @orig_exception = orig_exception
- end
-
- status_code(24)
- end
-
- class YamlSyntaxError < BundlerError
- attr_reader :orig_exception
-
- def initialize(orig_exception, msg)
- super(msg)
- @orig_exception = orig_exception
- end
-
- status_code(25)
- end
-
- class TemporaryResourceError < PermissionError
- def message
- "There was an error while trying to #{action} `#{@path}`. " \
- "Some resource was temporarily unavailable. It's suggested that you try" \
- "the operation again."
- end
-
- status_code(26)
- end
-
- class VirtualProtocolError < BundlerError
- def message
- "There was an error relating to virtualization and file access." \
- "It is likely that you need to grant access to or mount some file system correctly."
- end
-
- status_code(27)
- end
-
- class OperationNotSupportedError < PermissionError
- def message
- "Attempting to #{action} `#{@path}` is unsupported by your OS."
- end
-
- status_code(28)
- end
-
- class NoSpaceOnDeviceError < PermissionError
- def message
- "There was an error while trying to #{action} `#{@path}`. " \
- "There was insufficient space remaining on the device."
- end
-
- status_code(31)
- end
-
- class GenericSystemCallError < BundlerError
- attr_reader :underlying_error
-
- def initialize(underlying_error, message)
- @underlying_error = underlying_error
- super("#{message}\nThe underlying system error is #{@underlying_error.class}: #{@underlying_error}")
- end
-
- status_code(32)
- end
-end
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
deleted file mode 100644
index 01739ec4aa..0000000000
--- a/lib/bundler/feature_flag.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class FeatureFlag
- def self.settings_flag(flag, &default)
- unless Bundler::Settings::BOOL_KEYS.include?(flag.to_s)
- raise "Cannot use `#{flag}` as a settings feature flag since it isn't a bool key"
- end
-
- settings_method("#{flag}?", flag, &default)
- end
- private_class_method :settings_flag
-
- def self.settings_option(key, &default)
- settings_method(key, key, &default)
- end
- private_class_method :settings_option
-
- def self.settings_method(name, key, &default)
- define_method(name) do
- value = Bundler.settings[key]
- value = instance_eval(&default) if value.nil?
- value
- end
- end
- private_class_method :settings_method
-
- (1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } }
-
- settings_flag(:allow_bundler_dependency_conflicts) { bundler_3_mode? }
- settings_flag(:allow_offline_install) { bundler_3_mode? }
- settings_flag(:auto_clean_without_path) { bundler_3_mode? }
- settings_flag(:auto_config_jobs) { bundler_3_mode? }
- settings_flag(:cache_all) { bundler_3_mode? }
- settings_flag(:default_install_uses_path) { bundler_3_mode? }
- settings_flag(:deployment_means_frozen) { bundler_3_mode? }
- settings_flag(:disable_multisource) { bundler_3_mode? }
- settings_flag(:forget_cli_options) { bundler_3_mode? }
- settings_flag(:global_gem_cache) { bundler_3_mode? }
- settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
- settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
- settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
- settings_flag(:print_only_version_number) { bundler_3_mode? }
- settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
- settings_flag(:skip_default_git_sources) { bundler_3_mode? }
- settings_flag(:specific_platform) { bundler_3_mode? }
- settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
- settings_flag(:unlock_source_unlocks_spec) { !bundler_3_mode? }
- settings_flag(:update_requires_all_flag) { bundler_4_mode? }
- settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_3_mode? }
-
- settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
-
- def initialize(bundler_version)
- @bundler_version = Gem::Version.create(bundler_version)
- end
-
- def major_version
- @bundler_version.segments.first
- end
- private :major_version
- end
-end
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
deleted file mode 100644
index caf33bcfc9..0000000000
--- a/lib/bundler/fetcher.rb
+++ /dev/null
@@ -1,315 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "vendored_persistent"
-require "cgi"
-require "securerandom"
-require "zlib"
-require "rubygems/request"
-
-module Bundler
- # Handles all the fetching with the rubygems server
- class Fetcher
- autoload :CompactIndex, File.expand_path("fetcher/compact_index", __dir__)
- autoload :Downloader, File.expand_path("fetcher/downloader", __dir__)
- autoload :Dependency, File.expand_path("fetcher/dependency", __dir__)
- autoload :Index, File.expand_path("fetcher/index", __dir__)
-
- # This error is raised when it looks like the network is down
- class NetworkDownError < HTTPError; end
- # This error is raised if we should rate limit our requests to the API
- class TooManyRequestsError < HTTPError; end
- # This error is raised if the API returns a 413 (only printed in verbose)
- class FallbackError < HTTPError; end
- # This is the error raised if OpenSSL fails the cert verification
- class CertificateFailureError < HTTPError
- def initialize(remote_uri)
- remote_uri = filter_uri(remote_uri)
- super "Could not verify the SSL certificate for #{remote_uri}.\nThere" \
- " is a chance you are experiencing a man-in-the-middle attack, but" \
- " most likely your system doesn't have the CA certificates needed" \
- " for verification. For information about OpenSSL certificates, see" \
- " http://bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile" \
- " sources and change 'https' to 'http'."
- end
- end
- # This is the error raised when a source is HTTPS and OpenSSL didn't load
- class SSLError < HTTPError
- def initialize(msg = nil)
- super msg || "Could not load OpenSSL.\n" \
- "You must recompile Ruby with OpenSSL support or change the sources in your " \
- "Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL " \
- "using RVM are available at rvm.io/packages/openssl."
- end
- end
- # This error is raised if HTTP authentication is required, but not provided.
- class AuthenticationRequiredError < HTTPError
- def initialize(remote_uri)
- remote_uri = filter_uri(remote_uri)
- super "Authentication is required for #{remote_uri}.\n" \
- "Please supply credentials for this source. You can do this by running:\n" \
- " bundle config set #{remote_uri} username:password"
- end
- end
- # This error is raised if HTTP authentication is provided, but incorrect.
- class BadAuthenticationError < HTTPError
- def initialize(remote_uri)
- remote_uri = filter_uri(remote_uri)
- super "Bad username or password for #{remote_uri}.\n" \
- "Please double-check your credentials and correct them."
- end
- end
-
- # Exceptions classes that should bypass retry attempts. If your password didn't work the
- # first time, it's not going to the third time.
- NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency,
- :HTTPForbidden, :HTTPInsufficientStorage, :HTTPMethodNotAllowed,
- :HTTPMovedPermanently, :HTTPNoContent, :HTTPNotFound,
- :HTTPNotImplemented, :HTTPPreconditionFailed, :HTTPRequestEntityTooLarge,
- :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
- :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
- FAIL_ERRORS = begin
- fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
- fail_errors << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError)
- fail_errors.concat(NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact)
- end.freeze
-
- class << self
- attr_accessor :disable_endpoint, :api_timeout, :redirect_limit, :max_retries
- end
-
- self.redirect_limit = Bundler.settings[:redirect] # How many redirects to allow in one request
- self.api_timeout = Bundler.settings[:timeout] # How long to wait for each API call
- self.max_retries = Bundler.settings[:retry] # How many retries for the API call
-
- def initialize(remote)
- @remote = remote
-
- Socket.do_not_reverse_lookup = true
- connection # create persistent connection
- end
-
- def uri
- @remote.anonymized_uri
- end
-
- # fetch a gem specification
- def fetch_spec(spec)
- spec -= [nil, "ruby", ""]
- spec_file_name = "#{spec.join "-"}.gemspec"
-
- uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
- if uri.scheme == "file"
- path = Bundler.rubygems.correct_for_windows_path(uri.path)
- Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
- elsif cached_spec_path = gemspec_cached_path(spec_file_name)
- Bundler.load_gemspec(cached_spec_path)
- else
- Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
- end
- rescue MarshalError
- raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
- "Your network or your gem server is probably having issues right now."
- end
-
- # return the specs in the bundler format as an index with retries
- def specs_with_retry(gem_names, source)
- Bundler::Retry.new("fetcher", FAIL_ERRORS).attempts do
- specs(gem_names, source)
- end
- end
-
- # return the specs in the bundler format as an index
- def specs(gem_names, source)
- old = Bundler.rubygems.sources
- index = Bundler::Index.new
-
- if Bundler::Fetcher.disable_endpoint
- @use_api = false
- specs = fetchers.last.specs(gem_names)
- else
- specs = []
- fetchers.shift until fetchers.first.available? || fetchers.empty?
- fetchers.dup.each do |f|
- break unless f.api_fetcher? && !gem_names || !specs = f.specs(gem_names)
- fetchers.delete(f)
- end
- @use_api = false if fetchers.none?(&:api_fetcher?)
- end
-
- specs.each do |name, version, platform, dependencies, metadata|
- next if name == "bundler"
- spec = if dependencies
- EndpointSpecification.new(name, version, platform, dependencies, metadata)
- else
- RemoteSpecification.new(name, version, platform, self)
- end
- spec.source = source
- spec.remote = @remote
- index << spec
- end
-
- index
- rescue CertificateFailureError
- Bundler.ui.info "" if gem_names && use_api # newline after dots
- raise
- ensure
- Bundler.rubygems.sources = old
- end
-
- def use_api
- return @use_api if defined?(@use_api)
-
- fetchers.shift until fetchers.first.available?
-
- @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
- false
- else
- fetchers.first.api_fetcher?
- end
- end
-
- def user_agent
- @user_agent ||= begin
- ruby = Bundler::RubyVersion.system
-
- agent = String.new("bundler/#{Bundler::VERSION}")
- agent << " rubygems/#{Gem::VERSION}"
- agent << " ruby/#{ruby.versions_string(ruby.versions)}"
- agent << " (#{ruby.host})"
- agent << " command/#{ARGV.first}"
-
- if ruby.engine != "ruby"
- # engine_version raises on unknown engines
- engine_version = begin
- ruby.engine_versions
- rescue RuntimeError
- "???"
- end
- agent << " #{ruby.engine}/#{ruby.versions_string(engine_version)}"
- end
-
- agent << " options/#{Bundler.settings.all.join(",")}"
-
- agent << " ci/#{cis.join(",")}" if cis.any?
-
- # add a random ID so we can consolidate runs server-side
- agent << " " << SecureRandom.hex(8)
-
- # add any user agent strings set in the config
- extra_ua = Bundler.settings[:user_agent]
- agent << " " << extra_ua if extra_ua
-
- agent
- end
- end
-
- def fetchers
- @fetchers ||= FETCHERS.map {|f| f.new(downloader, @remote, uri) }
- end
-
- def http_proxy
- return unless uri = connection.proxy_uri
- uri.to_s
- end
-
- def inspect
- "#<#{self.class}:0x#{object_id} uri=#{uri}>"
- end
-
- private
-
- FETCHERS = [CompactIndex, Dependency, Index].freeze
-
- def cis
- env_cis = {
- "TRAVIS" => "travis",
- "CIRCLECI" => "circle",
- "SEMAPHORE" => "semaphore",
- "JENKINS_URL" => "jenkins",
- "BUILDBOX" => "buildbox",
- "GO_SERVER_URL" => "go",
- "SNAP_CI" => "snap",
- "CI_NAME" => ENV["CI_NAME"],
- "CI" => "ci",
- }
- env_cis.find_all {|env, _| ENV[env] }.map {|_, ci| ci }
- end
-
- def connection
- @connection ||= begin
- needs_ssl = remote_uri.scheme == "https" ||
- Bundler.settings[:ssl_verify_mode] ||
- Bundler.settings[:ssl_client_cert]
- raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
-
- con = PersistentHTTP.new :name => "bundler", :proxy => :ENV
- if gem_proxy = Bundler.rubygems.configuration[:http_proxy]
- con.proxy = Bundler::URI.parse(gem_proxy) if gem_proxy != :no_proxy
- end
-
- if remote_uri.scheme == "https"
- con.verify_mode = (Bundler.settings[:ssl_verify_mode] ||
- OpenSSL::SSL::VERIFY_PEER)
- con.cert_store = bundler_cert_store
- end
-
- ssl_client_cert = Bundler.settings[:ssl_client_cert] ||
- (Bundler.rubygems.configuration.ssl_client_cert if
- Bundler.rubygems.configuration.respond_to?(:ssl_client_cert))
- if ssl_client_cert
- pem = File.read(ssl_client_cert)
- con.cert = OpenSSL::X509::Certificate.new(pem)
- con.key = OpenSSL::PKey::RSA.new(pem)
- end
-
- con.read_timeout = Fetcher.api_timeout
- con.open_timeout = Fetcher.api_timeout
- con.override_headers["User-Agent"] = user_agent
- con.override_headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
- con
- end
- end
-
- # cached gem specification path, if one exists
- def gemspec_cached_path(spec_file_name)
- paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
- paths = paths.select {|path| File.file? path }
- paths.first
- end
-
- HTTP_ERRORS = [
- Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
- Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
- PersistentHTTP::Error, Zlib::BufError, Errno::EHOSTUNREACH
- ].freeze
-
- def bundler_cert_store
- store = OpenSSL::X509::Store.new
- ssl_ca_cert = Bundler.settings[:ssl_ca_cert] ||
- (Bundler.rubygems.configuration.ssl_ca_cert if
- Bundler.rubygems.configuration.respond_to?(:ssl_ca_cert))
- if ssl_ca_cert
- if File.directory? ssl_ca_cert
- store.add_path ssl_ca_cert
- else
- store.add_file ssl_ca_cert
- end
- else
- store.set_default_paths
- Gem::Request.get_cert_files.each {|c| store.add_file c }
- end
- store
- end
-
- private
-
- def remote_uri
- @remote.uri
- end
-
- def downloader
- @downloader ||= Downloader.new(connection, self.class.redirect_limit)
- end
- end
-end
diff --git a/lib/bundler/fetcher/base.rb b/lib/bundler/fetcher/base.rb
deleted file mode 100644
index 27987f670a..0000000000
--- a/lib/bundler/fetcher/base.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Fetcher
- class Base
- attr_reader :downloader
- attr_reader :display_uri
- attr_reader :remote
-
- def initialize(downloader, remote, display_uri)
- raise "Abstract class" if self.class == Base
- @downloader = downloader
- @remote = remote
- @display_uri = display_uri
- end
-
- def remote_uri
- @remote.uri
- end
-
- def fetch_uri
- @fetch_uri ||= begin
- if remote_uri.host == "rubygems.org"
- uri = remote_uri.dup
- uri.host = "index.rubygems.org"
- uri
- else
- remote_uri
- end
- end
- end
-
- def available?
- true
- end
-
- def api_fetcher?
- false
- end
-
- private
-
- def log_specs(debug_msg)
- if Bundler.ui.debug?
- Bundler.ui.debug debug_msg
- else
- Bundler.ui.info ".", false
- end
- end
- end
- end
-end
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
deleted file mode 100644
index f36d76d4ae..0000000000
--- a/lib/bundler/fetcher/compact_index.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "base"
-require_relative "../worker"
-
-module Bundler
- autoload :CompactIndexClient, File.expand_path("../compact_index_client", __dir__)
-
- class Fetcher
- class CompactIndex < Base
- def self.compact_index_request(method_name)
- method = instance_method(method_name)
- undef_method(method_name)
- define_method(method_name) do |*args, &blk|
- begin
- method.bind(self).call(*args, &blk)
- rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
- raise HTTPError, e.message
- rescue AuthenticationRequiredError
- # Fail since we got a 401 from the server.
- raise
- rescue HTTPError => e
- Bundler.ui.trace(e)
- nil
- end
- end
- end
-
- def specs(gem_names)
- specs_for_names(gem_names)
- end
- compact_index_request :specs
-
- def specs_for_names(gem_names)
- gem_info = []
- complete_gems = []
- remaining_gems = gem_names.dup
-
- until remaining_gems.empty?
- log_specs "Looking up gems #{remaining_gems.inspect}"
-
- deps = begin
- parallel_compact_index_client.dependencies(remaining_gems)
- rescue TooManyRequestsError
- @bundle_worker.stop if @bundle_worker
- @bundle_worker = nil # reset it. Not sure if necessary
- serial_compact_index_client.dependencies(remaining_gems)
- end
- next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq
- deps.each {|dep| gem_info << dep }
- complete_gems.concat(deps.map(&:first)).uniq!
- remaining_gems = next_gems - complete_gems
- end
- @bundle_worker.stop if @bundle_worker
- @bundle_worker = nil # reset it. Not sure if necessary
-
- gem_info
- end
-
- def fetch_spec(spec)
- spec -= [nil, "ruby", ""]
- contents = compact_index_client.spec(*spec)
- return nil if contents.nil?
- contents.unshift(spec.first)
- contents[3].map! {|d| Gem::Dependency.new(*d) }
- EndpointSpecification.new(*contents)
- end
- compact_index_request :fetch_spec
-
- def available?
- return nil unless SharedHelpers.md5_available?
- user_home = Bundler.user_home
- return nil unless user_home.directory? && user_home.writable?
- # Read info file checksums out of /versions, so we can know if gems are up to date
- fetch_uri.scheme != "file" && compact_index_client.update_and_parse_checksums!
- rescue CompactIndexClient::Updater::MisMatchedChecksumError => e
- Bundler.ui.debug(e.message)
- nil
- end
- compact_index_request :available?
-
- def api_fetcher?
- true
- end
-
- private
-
- def compact_index_client
- @compact_index_client ||=
- SharedHelpers.filesystem_access(cache_path) do
- CompactIndexClient.new(cache_path, client_fetcher)
- end
- end
-
- def parallel_compact_index_client
- compact_index_client.execution_mode = lambda do |inputs, &blk|
- func = lambda {|object, _index| blk.call(object) }
- worker = bundle_worker(func)
- inputs.each {|input| worker.enq(input) }
- inputs.map { worker.deq }
- end
-
- compact_index_client
- end
-
- def serial_compact_index_client
- compact_index_client.sequential_execution_mode!
- compact_index_client
- end
-
- def bundle_worker(func = nil)
- @bundle_worker ||= begin
- worker_name = "Compact Index (#{display_uri.host})"
- Bundler::Worker.new(Bundler.current_ruby.rbx? ? 1 : 25, worker_name, func)
- end
- @bundle_worker.tap do |worker|
- worker.instance_variable_set(:@func, func) if func
- end
- end
-
- def cache_path
- Bundler.user_cache.join("compact_index", remote.cache_slug)
- end
-
- def client_fetcher
- ClientFetcher.new(self, Bundler.ui)
- end
-
- ClientFetcher = Struct.new(:fetcher, :ui) do
- def call(path, headers)
- fetcher.downloader.fetch(fetcher.fetch_uri + path, headers)
- rescue NetworkDownError => e
- raise unless Bundler.feature_flag.allow_offline_install? && headers["If-None-Match"]
- ui.warn "Using the cached data for the new index because of a network error: #{e}"
- Net::HTTPNotModified.new(nil, nil, nil)
- end
- end
- end
- end
-end
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
deleted file mode 100644
index c52c32fb5b..0000000000
--- a/lib/bundler/fetcher/dependency.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "base"
-require "cgi"
-
-module Bundler
- class Fetcher
- class Dependency < Base
- def available?
- @available ||= fetch_uri.scheme != "file" && downloader.fetch(dependency_api_uri)
- rescue NetworkDownError => e
- raise HTTPError, e.message
- rescue AuthenticationRequiredError
- # Fail since we got a 401 from the server.
- raise
- rescue HTTPError
- false
- end
-
- def api_fetcher?
- true
- end
-
- def specs(gem_names, full_dependency_list = [], last_spec_list = [])
- query_list = gem_names.uniq - full_dependency_list
-
- log_specs "Query List: #{query_list.inspect}"
-
- return last_spec_list if query_list.empty?
-
- spec_list, deps_list = Bundler::Retry.new("dependency api", FAIL_ERRORS).attempts do
- dependency_specs(query_list)
- end
-
- returned_gems = spec_list.map(&:first).uniq
- specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
- rescue MarshalError
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
- Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
- nil
- rescue HTTPError, GemspecError
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
- Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
- nil
- end
-
- def dependency_specs(gem_names)
- Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(",")}"
-
- gem_list = unmarshalled_dep_gems(gem_names)
- get_formatted_specs_and_deps(gem_list)
- end
-
- def unmarshalled_dep_gems(gem_names)
- gem_list = []
- gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
- marshalled_deps = downloader.fetch(dependency_api_uri(names)).body
- gem_list.concat(Bundler.load_marshal(marshalled_deps))
- end
- gem_list
- end
-
- def get_formatted_specs_and_deps(gem_list)
- deps_list = []
- spec_list = []
-
- gem_list.each do |s|
- deps_list.concat(s[:dependencies].map(&:first))
- deps = s[:dependencies].map {|n, d| [n, d.split(", ")] }
- spec_list.push([s[:name], s[:number], s[:platform], deps])
- end
- [spec_list, deps_list]
- end
-
- def dependency_api_uri(gem_names = [])
- uri = fetch_uri + "api/v1/dependencies"
- uri.query = "gems=#{CGI.escape(gem_names.sort.join(","))}" if gem_names.any?
- uri
- end
- end
- end
-end
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
deleted file mode 100644
index 498852c174..0000000000
--- a/lib/bundler/fetcher/downloader.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Fetcher
- class Downloader
- attr_reader :connection
- attr_reader :redirect_limit
-
- def initialize(connection, redirect_limit)
- @connection = connection
- @redirect_limit = redirect_limit
- end
-
- def fetch(uri, headers = {}, counter = 0)
- raise HTTPError, "Too many redirects" if counter >= redirect_limit
-
- response = request(uri, headers)
- Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}")
-
- case response
- when Net::HTTPSuccess, Net::HTTPNotModified
- response
- when Net::HTTPRedirection
- new_uri = Bundler::URI.parse(response["location"])
- if new_uri.host == uri.host
- new_uri.user = uri.user
- new_uri.password = uri.password
- end
- fetch(new_uri, headers, counter + 1)
- when Net::HTTPRequestedRangeNotSatisfiable
- new_headers = headers.dup
- new_headers.delete("Range")
- new_headers["Accept-Encoding"] = "gzip"
- fetch(uri, new_headers)
- when Net::HTTPRequestEntityTooLarge
- raise FallbackError, response.body
- when Net::HTTPTooManyRequests
- raise TooManyRequestsError, response.body
- when Net::HTTPUnauthorized
- raise BadAuthenticationError, uri.host if uri.userinfo
- raise AuthenticationRequiredError, uri.host
- when Net::HTTPNotFound
- raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}"
- else
- raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
- end
- end
-
- def request(uri, headers)
- validate_uri_scheme!(uri)
-
- Bundler.ui.debug "HTTP GET #{uri}"
- req = Net::HTTP::Get.new uri.request_uri, headers
- if uri.user
- user = CGI.unescape(uri.user)
- password = uri.password ? CGI.unescape(uri.password) : nil
- req.basic_auth(user, password)
- end
- connection.request(uri, req)
- rescue NoMethodError => e
- raise unless ["undefined method", "use_ssl="].all? {|snippet| e.message.include? snippet }
- raise LoadError.new("cannot load such file -- openssl")
- rescue OpenSSL::SSL::SSLError
- raise CertificateFailureError.new(uri)
- rescue *HTTP_ERRORS => e
- Bundler.ui.trace e
- case e.message
- when /host down:/, /getaddrinfo: nodename nor servname provided/
- raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
- "connection and try again."
- else
- raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" \
- " (#{e})"
- end
- end
-
- private
-
- def validate_uri_scheme!(uri)
- return if uri.scheme =~ /\Ahttps?\z/
- raise InvalidOption,
- "The request uri `#{uri}` has an invalid scheme (`#{uri.scheme}`). " \
- "Did you mean `http` or `https`?"
- end
- end
- end
-end
diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb
deleted file mode 100644
index 034a225198..0000000000
--- a/lib/bundler/fetcher/index.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "base"
-require "rubygems/remote_fetcher"
-
-module Bundler
- class Fetcher
- class Index < Base
- def specs(_gem_names)
- Bundler.rubygems.fetch_all_remote_specs(remote)
- rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError, Net::HTTPFatalError => e
- case e.message
- when /certificate verify failed/
- raise CertificateFailureError.new(display_uri)
- when /401/
- raise BadAuthenticationError, remote_uri if remote_uri.userinfo
- raise AuthenticationRequiredError, remote_uri
- when /403/
- raise BadAuthenticationError, remote_uri if remote_uri.userinfo
- raise AuthenticationRequiredError, remote_uri
- else
- Bundler.ui.trace e
- raise HTTPError, "Could not fetch specs from #{display_uri}"
- end
- end
-
- def fetch_spec(spec)
- spec -= [nil, "ruby", ""]
- spec_file_name = "#{spec.join "-"}.gemspec"
-
- uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
- if uri.scheme == "file"
- path = Bundler.rubygems.correct_for_windows_path(uri.path)
- Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
- elsif cached_spec_path = gemspec_cached_path(spec_file_name)
- Bundler.load_gemspec(cached_spec_path)
- else
- Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
- end
- rescue MarshalError
- raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
- "Your network or your gem server is probably having issues right now."
- end
-
- private
-
- # cached gem specification path, if one exists
- def gemspec_cached_path(spec_file_name)
- paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
- paths.find {|path| File.file? path }
- end
- end
- end
-end
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
deleted file mode 100644
index 080697b02c..0000000000
--- a/lib/bundler/friendly_errors.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "vendored_thor"
-
-module Bundler
- module FriendlyErrors
- module_function
-
- def log_error(error)
- case error
- when YamlSyntaxError
- Bundler.ui.error error.message
- Bundler.ui.trace error.orig_exception
- when Dsl::DSLError, GemspecError
- Bundler.ui.error error.message
- when GemRequireError
- Bundler.ui.error error.message
- Bundler.ui.trace error.orig_exception
- when BundlerError
- Bundler.ui.error error.message, :wrap => true
- Bundler.ui.trace error
- when Thor::Error
- Bundler.ui.error error.message
- when LoadError
- raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
- Bundler.ui.error "\nCould not load OpenSSL."
- Bundler.ui.warn <<-WARN, :wrap => true
- You must recompile Ruby with OpenSSL support or change the sources in your \
- Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \
- using RVM are available at https://rvm.io/packages/openssl.
- WARN
- Bundler.ui.trace error
- when Interrupt
- Bundler.ui.error "\nQuitting..."
- Bundler.ui.trace error
- when Gem::InvalidSpecificationException
- Bundler.ui.error error.message, :wrap => true
- when SystemExit
- when *[defined?(Java::JavaLang::OutOfMemoryError) && Java::JavaLang::OutOfMemoryError].compact
- Bundler.ui.error "\nYour JVM has run out of memory, and Bundler cannot continue. " \
- "You can decrease the amount of memory Bundler needs by removing gems from your Gemfile, " \
- "especially large gems. (Gems can be as large as hundreds of megabytes, and Bundler has to read those files!). " \
- "Alternatively, you can increase the amount of memory the JVM is able to use by running Bundler with jruby -J-Xmx1024m -S bundle (JRuby defaults to 500MB)."
- else request_issue_report_for(error)
- end
- rescue StandardError
- raise error
- end
-
- def exit_status(error)
- case error
- when BundlerError then error.status_code
- when Thor::Error then 15
- when SystemExit then error.status
- else 1
- end
- end
-
- def request_issue_report_for(e)
- Bundler.ui.info <<-EOS.gsub(/^ {8}/, "")
- --- ERROR REPORT TEMPLATE -------------------------------------------------------
- # Error Report
-
- ## Questions
-
- Please fill out answers to these questions, it'll help us figure out
- why things are going wrong.
-
- - **What did you do?**
-
- I ran the command `#{$PROGRAM_NAME} #{ARGV.join(" ")}`
-
- - **What did you expect to happen?**
-
- I expected Bundler to...
-
- - **What happened instead?**
-
- Instead, what happened was...
-
- - **Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?**
-
- I tried...
-
- - **Have you read our issues document, https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md?**
-
- ...
-
- ## Backtrace
-
- ```
- #{e.class}: #{e.message}
- #{e.backtrace && e.backtrace.join("\n ").chomp}
- ```
-
- #{Bundler::Env.report}
- --- TEMPLATE END ----------------------------------------------------------------
-
- EOS
-
- Bundler.ui.error "Unfortunately, an unexpected error occurred, and Bundler cannot continue."
-
- Bundler.ui.warn <<-EOS.gsub(/^ {8}/, "")
-
- First, try this link to see if there are any existing issue reports for this error:
- #{issues_url(e)}
-
- If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
- https://github.com/bundler/bundler/issues/new
- EOS
- end
-
- def issues_url(exception)
- message = exception.message.lines.first.tr(":", " ").chomp
- message = message.split("-").first if exception.is_a?(Errno)
- require "cgi"
- "https://github.com/bundler/bundler/search?q=" \
- "#{CGI.escape(message)}&type=Issues"
- end
- end
-
- def self.with_friendly_errors
- yield
- rescue SignalException
- raise
- rescue Exception => e # rubocop:disable Lint/RescueException
- FriendlyErrors.log_error(e)
- exit FriendlyErrors.exit_status(e)
- end
-end
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
deleted file mode 100644
index 204dd24052..0000000000
--- a/lib/bundler/gem_helper.rb
+++ /dev/null
@@ -1,216 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../bundler"
-require "shellwords"
-
-module Bundler
- class GemHelper
- include Rake::DSL if defined? Rake::DSL
-
- class << self
- # set when install'd.
- attr_accessor :instance
-
- def install_tasks(opts = {})
- new(opts[:dir], opts[:name]).install
- end
-
- def gemspec(&block)
- gemspec = instance.gemspec
- block.call(gemspec) if block
- gemspec
- end
- end
-
- attr_reader :spec_path, :base, :gemspec
-
- def initialize(base = nil, name = nil)
- @base = (base ||= SharedHelpers.pwd)
- gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "{,*}.gemspec")]
- raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1
- @spec_path = gemspecs.first
- @gemspec = Bundler.load_gemspec(@spec_path)
- end
-
- def install
- built_gem_path = nil
-
- desc "Build #{name}-#{version}.gem into the pkg directory."
- task "build" do
- built_gem_path = build_gem
- end
-
- desc "Build and install #{name}-#{version}.gem into system gems."
- task "install" => "build" do
- install_gem(built_gem_path)
- end
-
- desc "Build and install #{name}-#{version}.gem into system gems without network access."
- task "install:local" => "build" do
- install_gem(built_gem_path, :local)
- end
-
- desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to #{gem_push_host}\n" \
- "To prevent publishing in RubyGems use `gem_push=no rake release`"
- task "release", [:remote] => ["build", "release:guard_clean",
- "release:source_control_push", "release:rubygem_push"] do
- end
-
- task "release:guard_clean" do
- guard_clean
- end
-
- task "release:source_control_push", [:remote] do |_, args|
- tag_version { git_push(args[:remote]) } unless already_tagged?
- end
-
- task "release:rubygem_push" do
- rubygem_push(built_gem_path) if gem_push?
- end
-
- GemHelper.instance = self
- end
-
- def build_gem
- file_name = nil
- sh("#{gem_command} build -V #{spec_path.shellescape}".shellsplit) do
- file_name = File.basename(built_gem_path)
- SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
- FileUtils.mv(built_gem_path, "pkg")
- Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}."
- end
- File.join(base, "pkg", file_name)
- end
-
- def install_gem(built_gem_path = nil, local = false)
- built_gem_path ||= build_gem
- cmd = "#{gem_command} install #{built_gem_path}"
- cmd += " --local" if local
- _, status = sh_with_status(cmd.shellsplit)
- unless status.success?
- raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output"
- end
- Bundler.ui.confirm "#{name} (#{version}) installed."
- end
-
- protected
-
- def rubygem_push(path)
- cmd = %W[#{gem_command} push #{path}]
- cmd << "--key" << gem_key if gem_key
- cmd << "--host" << allowed_push_host if allowed_push_host
- unless allowed_push_host || Bundler.user_home.join(".gem/credentials").file?
- raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
- end
- sh_with_input(cmd)
- Bundler.ui.confirm "Pushed #{name} #{version} to #{gem_push_host}"
- end
-
- def built_gem_path
- Dir[File.join(base, "#{name}-*.gem")].sort_by {|f| File.mtime(f) }.last
- end
-
- def git_push(remote = "")
- perform_git_push remote
- perform_git_push "#{remote} --tags"
- Bundler.ui.confirm "Pushed git commits and tags."
- end
-
- def allowed_push_host
- @gemspec.metadata["allowed_push_host"] if @gemspec.respond_to?(:metadata)
- end
-
- def gem_push_host
- env_rubygems_host = ENV["RUBYGEMS_HOST"]
- env_rubygems_host = nil if
- env_rubygems_host && env_rubygems_host.empty?
-
- allowed_push_host || env_rubygems_host || "rubygems.org"
- end
-
- def perform_git_push(options = "")
- cmd = "git push #{options}"
- out, status = sh_with_status(cmd.shellsplit)
- return if status.success?
- raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n"
- end
-
- def already_tagged?
- return false unless sh(%w[git tag]).split(/\n/).include?(version_tag)
- Bundler.ui.confirm "Tag #{version_tag} has already been created."
- true
- end
-
- def guard_clean
- clean? && committed? || raise("There are files that need to be committed first.")
- end
-
- def clean?
- sh_with_status(%w[git diff --exit-code])[1].success?
- end
-
- def committed?
- sh_with_status(%w[git diff-index --quiet --cached HEAD])[1].success?
- end
-
- def tag_version
- sh %W[git tag -m Version\ #{version} #{version_tag}]
- Bundler.ui.confirm "Tagged #{version_tag}."
- yield if block_given?
- rescue RuntimeError
- Bundler.ui.error "Untagging #{version_tag} due to error."
- sh_with_status %W[git tag -d #{version_tag}]
- raise
- end
-
- def version
- gemspec.version
- end
-
- def version_tag
- "v#{version}"
- end
-
- def name
- gemspec.name
- end
-
- def sh_with_input(cmd)
- Bundler.ui.debug(cmd)
- SharedHelpers.chdir(base) do
- abort unless Kernel.system(*cmd)
- end
- end
-
- def sh(cmd, &block)
- out, status = sh_with_status(cmd, &block)
- unless status.success?
- cmd = cmd.shelljoin if cmd.respond_to?(:shelljoin)
- raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
- end
- out
- end
-
- def sh_with_status(cmd, &block)
- Bundler.ui.debug(cmd)
- SharedHelpers.chdir(base) do
- outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
- status = $?
- block.call(outbuf) if status.success? && block
- [outbuf, status]
- end
- end
-
- def gem_key
- Bundler.settings["gem.push_key"].to_s.downcase if Bundler.settings["gem.push_key"]
- end
-
- def gem_push?
- !%w[n no nil false off 0].include?(ENV["gem_push"].to_s.downcase)
- end
-
- def gem_command
- ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem"
- end
- end
-end
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
deleted file mode 100644
index be047f4397..0000000000
--- a/lib/bundler/gem_helpers.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module GemHelpers
- GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant
- GENERICS = [
- [Gem::Platform.new("java"), Gem::Platform.new("java")],
- [Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")],
- [Gem::Platform.new("mswin64"), Gem::Platform.new("mswin64")],
- [Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],
- [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
- [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
- [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")],
- ].freeze
-
- def generic(p)
- GENERIC_CACHE[p] ||= begin
- _, found = GENERICS.find do |match, _generic|
- p.os == match.os && (!match.cpu || p.cpu == match.cpu)
- end
- found || Gem::Platform::RUBY
- end
- end
- module_function :generic
-
- def generic_local_platform
- generic(Bundler.local_platform)
- end
- module_function :generic_local_platform
-
- def platform_specificity_match(spec_platform, user_platform)
- spec_platform = Gem::Platform.new(spec_platform)
- return PlatformMatch::EXACT_MATCH if spec_platform == user_platform
- return PlatformMatch::WORST_MATCH if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
-
- PlatformMatch.new(
- PlatformMatch.os_match(spec_platform, user_platform),
- PlatformMatch.cpu_match(spec_platform, user_platform),
- PlatformMatch.platform_version_match(spec_platform, user_platform)
- )
- end
- module_function :platform_specificity_match
-
- def select_best_platform_match(specs, platform)
- specs.select {|spec| spec.match_platform(platform) }.
- min_by {|spec| platform_specificity_match(spec.platform, platform) }
- end
- module_function :select_best_platform_match
-
- PlatformMatch = Struct.new(:os_match, :cpu_match, :platform_version_match)
- class PlatformMatch
- def <=>(other)
- return nil unless other.is_a?(PlatformMatch)
-
- m = os_match <=> other.os_match
- return m unless m.zero?
-
- m = cpu_match <=> other.cpu_match
- return m unless m.zero?
-
- m = platform_version_match <=> other.platform_version_match
- m
- end
-
- EXACT_MATCH = new(-1, -1, -1).freeze
- WORST_MATCH = new(1_000_000, 1_000_000, 1_000_000).freeze
-
- def self.os_match(spec_platform, user_platform)
- if spec_platform.os == user_platform.os
- 0
- else
- 1
- end
- end
-
- def self.cpu_match(spec_platform, user_platform)
- if spec_platform.cpu == user_platform.cpu
- 0
- elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")
- 0
- elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"
- 1
- else
- 2
- end
- end
-
- def self.platform_version_match(spec_platform, user_platform)
- if spec_platform.version == user_platform.version
- 0
- elsif spec_platform.version.nil?
- 1
- else
- 2
- end
- end
- end
- end
-end
diff --git a/lib/bundler/gem_remote_fetcher.rb b/lib/bundler/gem_remote_fetcher.rb
deleted file mode 100644
index 9577535d63..0000000000
--- a/lib/bundler/gem_remote_fetcher.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems/remote_fetcher"
-
-module Bundler
- # Adds support for setting custom HTTP headers when fetching gems from the
- # server.
- #
- # TODO: Get rid of this when and if gemstash only supports RubyGems versions
- # that contain https://github.com/rubygems/rubygems/commit/3db265cc20b2f813.
- class GemRemoteFetcher < Gem::RemoteFetcher
- attr_accessor :headers
-
- # Extracted from RubyGems 2.4.
- def fetch_http(uri, last_modified = nil, head = false, depth = 0)
- fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
- # beginning of change
- response = request uri, fetch_type, last_modified do |req|
- headers.each {|k, v| req.add_field(k, v) } if headers
- end
- # end of change
-
- case response
- when Net::HTTPOK, Net::HTTPNotModified then
- response.uri = uri if response.respond_to? :uri
- head ? response : response.body
- when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther,
- Net::HTTPTemporaryRedirect then
- raise FetchError.new("too many redirects", uri) if depth > 10
-
- location = URI.parse response["Location"]
-
- if https?(uri) && !https?(location)
- raise FetchError.new("redirecting to non-https resource: #{location}", uri)
- end
-
- fetch_http(location, last_modified, head, depth + 1)
- else
- raise FetchError.new("bad response #{response.message} #{response.code}", uri)
- end
- end
- end
-end
diff --git a/lib/bundler/gem_tasks.rb b/lib/bundler/gem_tasks.rb
deleted file mode 100644
index bc725d3602..0000000000
--- a/lib/bundler/gem_tasks.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-require "rake/clean"
-CLOBBER.include "pkg"
-
-require_relative "gem_helper"
-Bundler::GemHelper.install_tasks
diff --git a/lib/bundler/gem_version_promoter.rb b/lib/bundler/gem_version_promoter.rb
deleted file mode 100644
index 311b0cbbf3..0000000000
--- a/lib/bundler/gem_version_promoter.rb
+++ /dev/null
@@ -1,190 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # This class contains all of the logic for determining the next version of a
- # Gem to update to based on the requested level (patch, minor, major).
- # Primarily designed to work with Resolver which will provide it the list of
- # available dependency versions as found in its index, before returning it to
- # to the resolution engine to select the best version.
- class GemVersionPromoter
- DEBUG = ENV["DEBUG_RESOLVER"]
-
- attr_reader :level, :locked_specs, :unlock_gems
-
- # By default, strict is false, meaning every available version of a gem
- # is returned from sort_versions. The order gives preference to the
- # requested level (:patch, :minor, :major) but in complicated requirement
- # cases some gems will by necessity by promoted past the requested level,
- # or even reverted to older versions.
- #
- # If strict is set to true, the results from sort_versions will be
- # truncated, eliminating any version outside the current level scope.
- # This can lead to unexpected outcomes or even VersionConflict exceptions
- # that report a version of a gem not existing for versions that indeed do
- # existing in the referenced source.
- attr_accessor :strict
-
- attr_accessor :prerelease_specified
-
- # Given a list of locked_specs and a list of gems to unlock creates a
- # GemVersionPromoter instance.
- #
- # @param locked_specs [SpecSet] All current locked specs. Unlike Definition
- # where this list is empty if all gems are being updated, this should
- # always be populated for all gems so this class can properly function.
- # @param unlock_gems [String] List of gem names being unlocked. If empty,
- # all gems will be considered unlocked.
- # @return [GemVersionPromoter]
- def initialize(locked_specs = SpecSet.new([]), unlock_gems = [])
- @level = :major
- @strict = false
- @locked_specs = locked_specs
- @unlock_gems = unlock_gems
- @sort_versions = {}
- @prerelease_specified = {}
- end
-
- # @param value [Symbol] One of three Symbols: :major, :minor or :patch.
- def level=(value)
- v = case value
- when String, Symbol
- value.to_sym
- end
-
- raise ArgumentError, "Unexpected level #{v}. Must be :major, :minor or :patch" unless [:major, :minor, :patch].include?(v)
- @level = v
- end
-
- # Given a Dependency and an Array of SpecGroups of available versions for a
- # gem, this method will return the Array of SpecGroups sorted (and possibly
- # truncated if strict is true) in an order to give preference to the current
- # level (:major, :minor or :patch) when resolution is deciding what versions
- # best resolve all dependencies in the bundle.
- # @param dep [Dependency] The Dependency of the gem.
- # @param spec_groups [SpecGroup] An array of SpecGroups for the same gem
- # named in the @dep param.
- # @return [SpecGroup] A new instance of the SpecGroup Array sorted and
- # possibly filtered.
- def sort_versions(dep, spec_groups)
- before_result = "before sort_versions: #{debug_format_result(dep, spec_groups).inspect}" if DEBUG
-
- @sort_versions[dep] ||= begin
- gem_name = dep.name
-
- # An Array per version returned, different entries for different platforms.
- # We only need the version here so it's ok to hard code this to the first instance.
- locked_spec = locked_specs[gem_name].first
-
- if strict
- filter_dep_specs(spec_groups, locked_spec)
- else
- sort_dep_specs(spec_groups, locked_spec)
- end.tap do |specs|
- if DEBUG
- warn before_result
- warn " after sort_versions: #{debug_format_result(dep, specs).inspect}"
- end
- end
- end
- end
-
- # @return [bool] Convenience method for testing value of level variable.
- def major?
- level == :major
- end
-
- # @return [bool] Convenience method for testing value of level variable.
- def minor?
- level == :minor
- end
-
- private
-
- def filter_dep_specs(spec_groups, locked_spec)
- res = spec_groups.select do |spec_group|
- if locked_spec && !major?
- gsv = spec_group.version
- lsv = locked_spec.version
-
- must_match = minor? ? [0] : [0, 1]
-
- matches = must_match.map {|idx| gsv.segments[idx] == lsv.segments[idx] }
- matches.uniq == [true] ? (gsv >= lsv) : false
- else
- true
- end
- end
-
- sort_dep_specs(res, locked_spec)
- end
-
- def sort_dep_specs(spec_groups, locked_spec)
- return spec_groups unless locked_spec
- @gem_name = locked_spec.name
- @locked_version = locked_spec.version
-
- result = spec_groups.sort do |a, b|
- @a_ver = a.version
- @b_ver = b.version
-
- unless @prerelease_specified[@gem_name]
- a_pre = @a_ver.prerelease?
- b_pre = @b_ver.prerelease?
-
- next -1 if a_pre && !b_pre
- next 1 if b_pre && !a_pre
- end
-
- if major?
- @a_ver <=> @b_ver
- elsif either_version_older_than_locked
- @a_ver <=> @b_ver
- elsif segments_do_not_match(:major)
- @b_ver <=> @a_ver
- elsif !minor? && segments_do_not_match(:minor)
- @b_ver <=> @a_ver
- else
- @a_ver <=> @b_ver
- end
- end
- post_sort(result)
- end
-
- def either_version_older_than_locked
- @a_ver < @locked_version || @b_ver < @locked_version
- end
-
- def segments_do_not_match(level)
- index = [:major, :minor].index(level)
- @a_ver.segments[index] != @b_ver.segments[index]
- end
-
- def unlocking_gem?
- unlock_gems.empty? || unlock_gems.include?(@gem_name)
- end
-
- # Specific version moves can't always reliably be done during sorting
- # as not all elements are compared against each other.
- def post_sort(result)
- # default :major behavior in Bundler does not do this
- return result if major?
- if unlocking_gem?
- result
- else
- move_version_to_end(result, @locked_version)
- end
- end
-
- def move_version_to_end(result, version)
- move, keep = result.partition {|s| s.version.to_s == version.to_s }
- keep.concat(move)
- end
-
- def debug_format_result(dep, spec_groups)
- a = [dep.to_s,
- spec_groups.map {|sg| [sg.version, sg.dependencies_for_activated_platforms.map {|dp| [dp.name, dp.requirement.to_s] }] }]
- last_map = a.last.map {|sg_data| [sg_data.first.version, sg_data.last.map {|aa| aa.join(" ") }] }
- [a.first, last_map, level, strict ? :strict : :not_strict]
- end
- end
-end
diff --git a/lib/bundler/gemdeps.rb b/lib/bundler/gemdeps.rb
deleted file mode 100644
index cd4b25d0e6..0000000000
--- a/lib/bundler/gemdeps.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Gemdeps
- def initialize(runtime)
- @runtime = runtime
- end
-
- def requested_specs
- @runtime.requested_specs
- end
-
- def specs
- @runtime.specs
- end
-
- def dependencies
- @runtime.dependencies
- end
-
- def current_dependencies
- @runtime.current_dependencies
- end
-
- def requires
- @runtime.requires
- end
- end
-end
diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb
deleted file mode 100644
index 5644e41079..0000000000
--- a/lib/bundler/graph.rb
+++ /dev/null
@@ -1,152 +0,0 @@
-# frozen_string_literal: true
-
-require "set"
-module Bundler
- class Graph
- GRAPH_NAME = :Gemfile
-
- def initialize(env, output_file, show_version = false, show_requirements = false, output_format = "png", without = [])
- @env = env
- @output_file = output_file
- @show_version = show_version
- @show_requirements = show_requirements
- @output_format = output_format
- @without_groups = without.map(&:to_sym)
-
- @groups = []
- @relations = Hash.new {|h, k| h[k] = Set.new }
- @node_options = {}
- @edge_options = {}
-
- _populate_relations
- end
-
- attr_reader :groups, :relations, :node_options, :edge_options, :output_file, :output_format
-
- def viz
- GraphVizClient.new(self).run
- end
-
- private
-
- def _populate_relations
- parent_dependencies = _groups.values.to_set.flatten
- loop do
- break if parent_dependencies.empty?
-
- tmp = Set.new
- parent_dependencies.each do |dependency|
- child_dependencies = spec_for_dependency(dependency).runtime_dependencies.to_set
- @relations[dependency.name] += child_dependencies.map(&:name).to_set
- tmp += child_dependencies
-
- @node_options[dependency.name] = _make_label(dependency, :node)
- child_dependencies.each do |c_dependency|
- @edge_options["#{dependency.name}_#{c_dependency.name}"] = _make_label(c_dependency, :edge)
- end
- end
- parent_dependencies = tmp
- end
- end
-
- def _groups
- relations = Hash.new {|h, k| h[k] = Set.new }
- @env.current_dependencies.each do |dependency|
- dependency.groups.each do |group|
- next if @without_groups.include?(group)
-
- relations[group.to_s].add(dependency)
- @relations[group.to_s].add(dependency.name)
-
- @node_options[group.to_s] ||= _make_label(group, :node)
- @edge_options["#{group}_#{dependency.name}"] = _make_label(dependency, :edge)
- end
- end
- @groups = relations.keys
- relations
- end
-
- def _make_label(symbol_or_string_or_dependency, element_type)
- case element_type.to_sym
- when :node
- if symbol_or_string_or_dependency.is_a?(Gem::Dependency)
- label = symbol_or_string_or_dependency.name.dup
- label << "\n#{spec_for_dependency(symbol_or_string_or_dependency).version}" if @show_version
- else
- label = symbol_or_string_or_dependency.to_s
- end
- when :edge
- label = nil
- if symbol_or_string_or_dependency.respond_to?(:requirements_list) && @show_requirements
- tmp = symbol_or_string_or_dependency.requirements_list.join(", ")
- label = tmp if tmp != ">= 0"
- end
- else
- raise ArgumentError, "2nd argument is invalid"
- end
- label.nil? ? {} : { :label => label }
- end
-
- def spec_for_dependency(dependency)
- @env.requested_specs.find {|s| s.name == dependency.name }
- end
-
- class GraphVizClient
- def initialize(graph_instance)
- @graph_name = graph_instance.class::GRAPH_NAME
- @groups = graph_instance.groups
- @relations = graph_instance.relations
- @node_options = graph_instance.node_options
- @edge_options = graph_instance.edge_options
- @output_file = graph_instance.output_file
- @output_format = graph_instance.output_format
- end
-
- def g
- @g ||= ::GraphViz.digraph(@graph_name, :concentrate => true, :normalize => true, :nodesep => 0.55) do |g|
- g.edge[:weight] = 2
- g.edge[:fontname] = g.node[:fontname] = "Arial, Helvetica, SansSerif"
- g.edge[:fontsize] = 12
- end
- end
-
- def run
- @groups.each do |group|
- g.add_nodes(
- group, {
- :style => "filled",
- :fillcolor => "#B9B9D5",
- :shape => "box3d",
- :fontsize => 16,
- }.merge(@node_options[group])
- )
- end
-
- @relations.each do |parent, children|
- children.each do |child|
- if @groups.include?(parent)
- g.add_nodes(child, { :style => "filled", :fillcolor => "#B9B9D5" }.merge(@node_options[child]))
- g.add_edges(parent, child, { :constraint => false }.merge(@edge_options["#{parent}_#{child}"]))
- else
- g.add_nodes(child, @node_options[child])
- g.add_edges(parent, child, @edge_options["#{parent}_#{child}"])
- end
- end
- end
-
- if @output_format.to_s == "debug"
- $stdout.puts g.output :none => String
- Bundler.ui.info "debugging bundle viz..."
- else
- begin
- g.output @output_format.to_sym => "#{@output_file}.#{@output_format}"
- Bundler.ui.info "#{@output_file}.#{@output_format}"
- rescue ArgumentError => e
- warn "Unsupported output format. See Ruby-Graphviz/lib/graphviz/constants.rb"
- raise e
- end
- end
- end
- end
- end
-end
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
deleted file mode 100644
index 9166a92738..0000000000
--- a/lib/bundler/index.rb
+++ /dev/null
@@ -1,213 +0,0 @@
-# frozen_string_literal: true
-
-require "set"
-
-module Bundler
- class Index
- include Enumerable
-
- def self.build
- i = new
- yield i
- i
- end
-
- attr_reader :specs, :all_specs, :sources
- protected :specs, :all_specs
-
- RUBY = "ruby".freeze
- NULL = "\0".freeze
-
- def initialize
- @sources = []
- @cache = {}
- @specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
- end
-
- def initialize_copy(o)
- @sources = o.sources.dup
- @cache = {}
- @specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
-
- o.specs.each do |name, hash|
- @specs[name] = hash.dup
- end
- o.all_specs.each do |name, array|
- @all_specs[name] = array.dup
- end
- end
-
- def inspect
- "#<#{self.class}:0x#{object_id} sources=#{sources.map(&:inspect)} specs.size=#{specs.size}>"
- end
-
- def empty?
- each { return false }
- true
- end
-
- def search_all(name)
- all_matches = local_search(name) + @all_specs[name]
- @sources.each do |source|
- all_matches.concat(source.search_all(name))
- end
- all_matches
- end
-
- # Search this index's specs, and any source indexes that this index knows
- # about, returning all of the results.
- def search(query, base = nil)
- sort_specs(unsorted_search(query, base))
- end
-
- def unsorted_search(query, base)
- results = local_search(query, base)
-
- seen = results.map(&:full_name).to_set unless @sources.empty?
-
- @sources.each do |source|
- source.unsorted_search(query, base).each do |spec|
- results << spec if seen.add?(spec.full_name)
- end
- end
-
- results
- end
- protected :unsorted_search
-
- def self.sort_specs(specs)
- specs.sort_by do |s|
- platform_string = s.platform.to_s
- [s.version, platform_string == RUBY ? NULL : platform_string]
- end
- end
-
- def sort_specs(specs)
- self.class.sort_specs(specs)
- end
-
- def local_search(query, base = nil)
- case query
- when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
- when String then specs_by_name(query)
- when Gem::Dependency then search_by_dependency(query, base)
- when DepProxy then search_by_dependency(query.dep, base)
- else
- raise "You can't search for a #{query.inspect}."
- end
- end
-
- alias_method :[], :search
-
- def <<(spec)
- @specs[spec.name][spec.full_name] = spec
- spec
- end
-
- def each(&blk)
- return enum_for(:each) unless blk
- specs.values.each do |spec_sets|
- spec_sets.values.each(&blk)
- end
- sources.each {|s| s.each(&blk) }
- self
- end
-
- def spec_names
- names = specs.keys + sources.map(&:spec_names)
- names.uniq!
- names
- end
-
- # returns a list of the dependencies
- def unmet_dependency_names
- dependency_names.select do |name|
- name != "bundler" && search(name).empty?
- end
- end
-
- def dependency_names
- names = []
- each do |spec|
- spec.dependencies.each do |dep|
- next if dep.type == :development
- names << dep.name
- end
- end
- names.uniq
- end
-
- def use(other, override_dupes = false)
- return unless other
- other.each do |s|
- if (dupes = search_by_spec(s)) && !dupes.empty?
- # safe to << since it's a new array when it has contents
- @all_specs[s.name] = dupes << s
- next unless override_dupes
- end
- self << s
- end
- self
- end
-
- def size
- @sources.inject(@specs.size) do |size, source|
- size += source.size
- end
- end
-
- # Whether all the specs in self are in other
- # TODO: rename to #include?
- def ==(other)
- all? do |spec|
- other_spec = other[spec].first
- other_spec && dependencies_eql?(spec, other_spec) && spec.source == other_spec.source
- end
- end
-
- def dependencies_eql?(spec, other_spec)
- deps = spec.dependencies.select {|d| d.type != :development }
- other_deps = other_spec.dependencies.select {|d| d.type != :development }
- Set.new(deps) == Set.new(other_deps)
- end
-
- def add_source(index)
- raise ArgumentError, "Source must be an index, not #{index.class}" unless index.is_a?(Index)
- @sources << index
- @sources.uniq! # need to use uniq! here instead of checking for the item before adding
- end
-
- private
-
- def specs_by_name(name)
- @specs[name].values
- end
-
- def search_by_dependency(dependency, base = nil)
- @cache[base || false] ||= {}
- @cache[base || false][dependency] ||= begin
- specs = specs_by_name(dependency.name)
- specs += base if base
- found = specs.select do |spec|
- next true if spec.source.is_a?(Source::Gemspec)
- if base # allow all platforms when searching from a lockfile
- dependency.matches_spec?(spec)
- else
- dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform)
- end
- end
-
- found
- end
- end
-
- EMPTY_SEARCH = [].freeze
-
- def search_by_spec(spec)
- spec = @specs[spec.name][spec.full_name]
- spec ? [spec] : EMPTY_SEARCH
- end
- end
-end
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb
deleted file mode 100644
index 2cdda578e2..0000000000
--- a/lib/bundler/injector.rb
+++ /dev/null
@@ -1,255 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Injector
- INJECTED_GEMS = "injected gems".freeze
-
- def self.inject(new_deps, options = {})
- injector = new(new_deps, options)
- injector.inject(Bundler.default_gemfile, Bundler.default_lockfile)
- end
-
- def self.remove(gems, options = {})
- injector = new(gems, options)
- injector.remove(Bundler.default_gemfile, Bundler.default_lockfile)
- end
-
- def initialize(deps, options = {})
- @deps = deps
- @options = options
- end
-
- # @param [Pathname] gemfile_path The Gemfile in which to inject the new dependency.
- # @param [Pathname] lockfile_path The lockfile in which to inject the new dependency.
- # @return [Array]
- def inject(gemfile_path, lockfile_path)
- if Bundler.frozen_bundle?
- # ensure the lock and Gemfile are synced
- Bundler.definition.ensure_equivalent_gemfile_and_lockfile(true)
- end
-
- # temporarily unfreeze
- Bundler.settings.temporary(:deployment => false, :frozen => false) do
- # evaluate the Gemfile we have now
- builder = Dsl.new
- builder.eval_gemfile(gemfile_path)
-
- # don't inject any gems that are already in the Gemfile
- @deps -= builder.dependencies
-
- # add new deps to the end of the in-memory Gemfile
- # Set conservative versioning to false because
- # we want to let the resolver resolve the version first
- builder.eval_gemfile(INJECTED_GEMS, build_gem_lines(false)) if @deps.any?
-
- # resolve to see if the new deps broke anything
- @definition = builder.to_definition(lockfile_path, {})
- @definition.resolve_remotely!
-
- # since nothing broke, we can add those gems to the gemfile
- append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
-
- # since we resolved successfully, write out the lockfile
- @definition.lock(Bundler.default_lockfile)
-
- # invalidate the cached Bundler.definition
- Bundler.reset_paths!
-
- # return an array of the deps that we added
- @deps
- end
- end
-
- # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
- # @param [Pathname] lockfile_path The lockfile from which to remove dependencies.
- # @return [Array]
- def remove(gemfile_path, lockfile_path)
- # remove gems from each gemfiles we have
- Bundler.definition.gemfiles.each do |path|
- deps = remove_deps(path)
-
- show_warning("No gems were removed from the gemfile.") if deps.empty?
-
- deps.each {|dep| Bundler.ui.confirm "#{SharedHelpers.pretty_dependency(dep, false)} was removed." }
- end
- end
-
- private
-
- def conservative_version(spec)
- version = spec.version
- return ">= 0" if version.nil?
- segments = version.segments
- seg_end_index = version >= Gem::Version.new("1.0") ? 1 : 2
-
- prerelease_suffix = version.to_s.gsub(version.release.to_s, "") if version.prerelease?
- "#{version_prefix}#{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
- end
-
- def version_prefix
- if @options[:strict]
- "= "
- elsif @options[:optimistic]
- ">= "
- else
- "~> "
- end
- end
-
- def build_gem_lines(conservative_versioning)
- @deps.map do |d|
- name = d.name.dump
-
- requirement = if conservative_versioning
- ", \"#{conservative_version(@definition.specs[d.name][0])}\""
- else
- ", #{d.requirement.as_list.map(&:dump).join(", ")}"
- end
-
- if d.groups != Array(:default)
- group = d.groups.size == 1 ? ", :group => #{d.groups.first.inspect}" : ", :groups => #{d.groups.inspect}"
- end
-
- source = ", :source => \"#{d.source}\"" unless d.source.nil?
- git = ", :git => \"#{d.git}\"" unless d.git.nil?
- branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
-
- %(gem #{name}#{requirement}#{group}#{source}#{git}#{branch})
- end.join("\n")
- end
-
- def append_to(gemfile_path, new_gem_lines)
- gemfile_path.open("a") do |f|
- f.puts
- f.puts new_gem_lines
- end
- end
-
- # evaluates a gemfile to remove the specified gem
- # from it.
- def remove_deps(gemfile_path)
- initial_gemfile = IO.readlines(gemfile_path)
-
- Bundler.ui.info "Removing gems from #{gemfile_path}"
-
- # evaluate the Gemfile we have
- builder = Dsl.new
- builder.eval_gemfile(gemfile_path)
-
- removed_deps = remove_gems_from_dependencies(builder, @deps, gemfile_path)
-
- # abort the operation if no gems were removed
- # no need to operate on gemfile further
- return [] if removed_deps.empty?
-
- cleaned_gemfile = remove_gems_from_gemfile(@deps, gemfile_path)
-
- SharedHelpers.write_to_gemfile(gemfile_path, cleaned_gemfile)
-
- # check for errors
- # including extra gems being removed
- # or some gems not being removed
- # and return the actual removed deps
- cross_check_for_errors(gemfile_path, builder.dependencies, removed_deps, initial_gemfile)
- end
-
- # @param [Dsl] builder Dsl object of current Gemfile.
- # @param [Array] gems Array of names of gems to be removed.
- # @param [Pathname] gemfile_path Path of the Gemfile.
- # @return [Array] Array of removed dependencies.
- def remove_gems_from_dependencies(builder, gems, gemfile_path)
- removed_deps = []
-
- gems.each do |gem_name|
- deleted_dep = builder.dependencies.find {|d| d.name == gem_name }
-
- if deleted_dep.nil?
- raise GemfileError, "`#{gem_name}` is not specified in #{gemfile_path} so it could not be removed."
- end
-
- builder.dependencies.delete(deleted_dep)
-
- removed_deps << deleted_dep
- end
-
- removed_deps
- end
-
- # @param [Array] gems Array of names of gems to be removed.
- # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
- def remove_gems_from_gemfile(gems, gemfile_path)
- patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/
-
- # remove lines which match the regex
- new_gemfile = IO.readlines(gemfile_path).reject {|line| line.match(patterns) }
-
- # remove lone \n and append them with other strings
- new_gemfile.each_with_index do |_line, index|
- if new_gemfile[index + 1] == "\n"
- new_gemfile[index] += new_gemfile[index + 1]
- new_gemfile.delete_at(index + 1)
- end
- end
-
- %w[group source env install_if].each {|block| remove_nested_blocks(new_gemfile, block) }
-
- new_gemfile.join.chomp
- end
-
- # @param [Array] gemfile Array of gemfile contents.
- # @param [String] block_name Name of block name to look for.
- def remove_nested_blocks(gemfile, block_name)
- nested_blocks = 0
-
- # count number of nested blocks
- gemfile.each_with_index {|line, index| nested_blocks += 1 if !gemfile[index + 1].nil? && gemfile[index + 1].include?(block_name) && line.include?(block_name) }
-
- while nested_blocks >= 0
- nested_blocks -= 1
-
- gemfile.each_with_index do |line, index|
- next unless !line.nil? && line.strip.start_with?(block_name)
- if gemfile[index + 1] =~ /^\s*end\s*$/
- gemfile[index] = nil
- gemfile[index + 1] = nil
- end
- end
-
- gemfile.compact!
- end
- end
-
- # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
- # @param [Array] original_deps Array of original dependencies.
- # @param [Array] removed_deps Array of removed dependencies.
- # @param [Array] initial_gemfile Contents of original Gemfile before any operation.
- def cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile)
- # evaluate the new gemfile to look for any failure cases
- builder = Dsl.new
- builder.eval_gemfile(gemfile_path)
-
- # record gems which were removed but not requested
- extra_removed_gems = original_deps - builder.dependencies
-
- # if some extra gems were removed then raise error
- # and revert Gemfile to original
- unless extra_removed_gems.empty?
- SharedHelpers.write_to_gemfile(gemfile_path, initial_gemfile.join)
-
- raise InvalidOption, "Gems could not be removed. #{extra_removed_gems.join(", ")} would also have been removed. Bundler cannot continue."
- end
-
- # record gems which could not be removed due to some reasons
- errored_deps = builder.dependencies.select {|d| d.gemfile == gemfile_path } & removed_deps.select {|d| d.gemfile == gemfile_path }
-
- show_warning "#{errored_deps.map(&:name).join(", ")} could not be removed." unless errored_deps.empty?
-
- # return actual removed dependencies
- removed_deps - errored_deps
- end
-
- def show_warning(message)
- Bundler.ui.info Bundler.ui.add_color(message, :yellow)
- end
- end
-end
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
deleted file mode 100644
index f1f77a7a9c..0000000000
--- a/lib/bundler/inline.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-# frozen_string_literal: true
-
-# Allows for declaring a Gemfile inline in a ruby script, optionally installing
-# any gems that aren't already installed on the user's system.
-#
-# @note Every gem that is specified in this 'Gemfile' will be `require`d, as if
-# the user had manually called `Bundler.require`. To avoid a requested gem
-# being automatically required, add the `:require => false` option to the
-# `gem` dependency declaration.
-#
-# @param install [Boolean] whether gems that aren't already installed on the
-# user's system should be installed.
-# Defaults to `false`.
-#
-# @param gemfile [Proc] a block that is evaluated as a `Gemfile`.
-#
-# @example Using an inline Gemfile
-#
-# #!/usr/bin/env ruby
-#
-# require 'bundler/inline'
-#
-# gemfile do
-# source 'https://rubygems.org'
-# gem 'json', require: false
-# gem 'nap', require: 'rest'
-# gem 'cocoapods', '~> 0.34.1'
-# end
-#
-# puts Pod::VERSION # => "0.34.4"
-#
-def gemfile(install = false, options = {}, &gemfile)
- require_relative "../bundler"
-
- opts = options.dup
- ui = opts.delete(:ui) { Bundler::UI::Shell.new }
- ui.level = "silent" if opts.delete(:quiet)
- raise ArgumentError, "Unknown options: #{opts.keys.join(", ")}" unless opts.empty?
-
- begin
- old_root = Bundler.method(:root)
- bundler_module = class << Bundler; self; end
- bundler_module.send(:remove_method, :root)
- def Bundler.root
- Bundler::SharedHelpers.pwd.expand_path
- end
- old_gemfile = ENV["BUNDLE_GEMFILE"]
- Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", "Gemfile"
-
- Bundler::Plugin.gemfile_install(&gemfile) if Bundler.feature_flag.plugins?
- builder = Bundler::Dsl.new
- builder.instance_eval(&gemfile)
-
- Bundler.settings.temporary(:frozen => false) do
- definition = builder.to_definition(nil, true)
- def definition.lock(*); end
- definition.validate_runtime!
-
- Bundler.ui = install ? ui : Bundler::UI::Silent.new
- if install || definition.missing_specs?
- Bundler.settings.temporary(:inline => true, :disable_platform_warnings => true) do
- installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
- installer.post_install_messages.each do |name, message|
- Bundler.ui.info "Post-install message from #{name}:\n#{message}"
- end
- end
- end
-
- runtime = Bundler::Runtime.new(nil, definition)
- runtime.setup.require
- end
- ensure
- if bundler_module
- bundler_module.send(:remove_method, :root)
- bundler_module.send(:define_method, :root, old_root)
- end
-
- if old_gemfile
- ENV["BUNDLE_GEMFILE"] = old_gemfile
- else
- ENV["BUNDLE_GEMFILE"] = ""
- end
- end
-end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
deleted file mode 100644
index 700f0a4737..0000000000
--- a/lib/bundler/installer.rb
+++ /dev/null
@@ -1,311 +0,0 @@
-# frozen_string_literal: true
-
-require "erb"
-require "rubygems/dependency_installer"
-require_relative "worker"
-require_relative "installer/parallel_installer"
-require_relative "installer/standalone"
-require_relative "installer/gem_installer"
-
-module Bundler
- class Installer
- class << self
- attr_accessor :ambiguous_gems
-
- Installer.ambiguous_gems = []
- end
-
- attr_reader :post_install_messages
-
- # Begins the installation process for Bundler.
- # For more information see the #run method on this class.
- def self.install(root, definition, options = {})
- installer = new(root, definition)
- Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL_ALL, definition.dependencies)
- installer.run(options)
- Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL_ALL, definition.dependencies)
- installer
- end
-
- def initialize(root, definition)
- @root = root
- @definition = definition
- @post_install_messages = {}
- end
-
- # Runs the install procedures for a specific Gemfile.
- #
- # Firstly, this method will check to see if `Bundler.bundle_path` exists
- # and if not then Bundler will create the directory. This is usually the same
- # location as RubyGems which typically is the `~/.gem` directory
- # unless other specified.
- #
- # Secondly, it checks if Bundler has been configured to be "frozen".
- # Frozen ensures that the Gemfile and the Gemfile.lock file are matching.
- # This stops a situation where a developer may update the Gemfile but may not run
- # `bundle install`, which leads to the Gemfile.lock file not being correctly updated.
- # If this file is not correctly updated then any other developer running
- # `bundle install` will potentially not install the correct gems.
- #
- # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile.
- # If there are no dependencies specified then Bundler returns a warning message stating
- # so and this method returns.
- #
- # Fourthly, Bundler checks if the Gemfile.lock exists, and if so
- # then proceeds to set up a definition based on the Gemfile and the Gemfile.lock.
- # During this step Bundler will also download information about any new gems
- # that are not in the Gemfile.lock and resolve any dependencies if needed.
- #
- # Fifthly, Bundler resolves the dependencies either through a cache of gems or by remote.
- # This then leads into the gems being installed, along with stubs for their executables,
- # but only if the --binstubs option has been passed or Bundler.options[:bin] has been set
- # earlier.
- #
- # Sixthly, a new Gemfile.lock is created from the installed gems to ensure that the next time
- # that a user runs `bundle install` they will receive any updates from this process.
- #
- # Finally, if the user has specified the standalone flag, Bundler will generate the needed
- # require paths and save them in a `setup.rb` file. See `bundle standalone --help` for more
- # information.
- def run(options)
- create_bundle_path
-
- ProcessLock.lock do
- if Bundler.frozen_bundle?
- @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
- end
-
- if @definition.dependencies.empty?
- Bundler.ui.warn "The Gemfile specifies no dependencies"
- lock
- return
- end
-
- if resolve_if_needed(options)
- ensure_specs_are_compatible!
- warn_on_incompatible_bundler_deps
- load_plugins
- options.delete(:jobs)
- else
- options[:jobs] = 1 # to avoid the overhead of Bundler::Worker
- end
- install(options)
-
- lock unless Bundler.frozen_bundle?
- Standalone.new(options[:standalone], @definition).generate if options[:standalone]
- end
- end
-
- def generate_bundler_executable_stubs(spec, options = {})
- if options[:binstubs_cmd] && spec.executables.empty?
- options = {}
- spec.runtime_dependencies.each do |dep|
- bins = @definition.specs[dep].first.executables
- options[dep.name] = bins unless bins.empty?
- end
- if options.any?
- Bundler.ui.warn "#{spec.name} has no executables, but you may want " \
- "one from a gem it depends on."
- options.each {|name, bins| Bundler.ui.warn " #{name} has: #{bins.join(", ")}" }
- else
- Bundler.ui.warn "There are no executables for the gem #{spec.name}."
- end
- return
- end
-
- # double-assignment to avoid warnings about variables that will be used by ERB
- bin_path = Bundler.bin_path
- bin_path = bin_path
- relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
- relative_gemfile_path = relative_gemfile_path
- ruby_command = Thor::Util.ruby_command
- ruby_command = ruby_command
- template_path = File.expand_path("../templates/Executable", __FILE__)
- if spec.name == "bundler"
- template_path += ".bundler"
- spec.executables = %(bundle)
- end
- template = File.read(template_path)
-
- exists = []
- spec.executables.each do |executable|
- binstub_path = "#{bin_path}/#{executable}"
- if File.exist?(binstub_path) && !options[:force]
- exists << executable
- next
- end
-
- File.open(binstub_path, "w", 0o777 & ~File.umask) do |f|
- if RUBY_VERSION >= "2.6"
- f.puts ERB.new(template, :trim_mode => "-").result(binding)
- else
- f.puts ERB.new(template, nil, "-").result(binding)
- end
- end
- end
-
- if options[:binstubs_cmd] && exists.any?
- case exists.size
- when 1
- Bundler.ui.warn "Skipped #{exists[0]} since it already exists."
- when 2
- Bundler.ui.warn "Skipped #{exists.join(" and ")} since they already exist."
- else
- items = exists[0...-1].empty? ? nil : exists[0...-1].join(", ")
- skipped = [items, exists[-1]].compact.join(" and ")
- Bundler.ui.warn "Skipped #{skipped} since they already exist."
- end
- Bundler.ui.warn "If you want to overwrite skipped stubs, use --force."
- end
- end
-
- def generate_standalone_bundler_executable_stubs(spec)
- # double-assignment to avoid warnings about variables that will be used by ERB
- bin_path = Bundler.bin_path
- unless path = Bundler.settings[:path]
- raise "Can't standalone without an explicit path set"
- end
- standalone_path = Bundler.root.join(path).relative_path_from(bin_path)
- standalone_path = standalone_path
- template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__))
- ruby_command = Thor::Util.ruby_command
- ruby_command = ruby_command
-
- spec.executables.each do |executable|
- next if executable == "bundle"
- executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
- executable_path = executable_path
- File.open "#{bin_path}/#{executable}", "w", 0o755 do |f|
- if RUBY_VERSION >= "2.6"
- f.puts ERB.new(template, :trim_mode => "-").result(binding)
- else
- f.puts ERB.new(template, nil, "-").result(binding)
- end
- end
- end
- end
-
- private
-
- # the order that the resolver provides is significant, since
- # dependencies might affect the installation of a gem.
- # that said, it's a rare situation (other than rake), and parallel
- # installation is SO MUCH FASTER. so we let people opt in.
- def install(options)
- force = options["force"]
- jobs = installation_parallelization(options)
- install_in_parallel jobs, options[:standalone], force
- end
-
- def installation_parallelization(options)
- if jobs = options.delete(:jobs)
- return jobs
- end
-
- return 1 unless can_install_in_parallel?
-
- auto_config_jobs = Bundler.feature_flag.auto_config_jobs?
- if jobs = Bundler.settings[:jobs]
- if auto_config_jobs
- jobs
- else
- [jobs.pred, 1].max
- end
- elsif auto_config_jobs
- processor_count
- else
- 1
- end
- end
-
- def processor_count
- require "etc"
- Etc.nprocessors
- rescue StandardError
- 1
- end
-
- def load_plugins
- Bundler.rubygems.load_plugins
-
- requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
- path_plugin_files = requested_path_gems.map do |spec|
- begin
- Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
- rescue TypeError
- error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
- raise Gem::InvalidSpecificationException, error_message
- end
- end.flatten
- Bundler.rubygems.load_plugin_files(path_plugin_files)
- end
-
- def ensure_specs_are_compatible!
- system_ruby = Bundler::RubyVersion.system
- rubygems_version = Gem::Version.create(Gem::VERSION)
- @definition.specs.each do |spec|
- if required_ruby_version = spec.required_ruby_version
- unless required_ruby_version.satisfied_by?(system_ruby.gem_version)
- raise InstallError, "#{spec.full_name} requires ruby version #{required_ruby_version}, " \
- "which is incompatible with the current version, #{system_ruby}"
- end
- end
- next unless required_rubygems_version = spec.required_rubygems_version
- unless required_rubygems_version.satisfied_by?(rubygems_version)
- raise InstallError, "#{spec.full_name} requires rubygems version #{required_rubygems_version}, " \
- "which is incompatible with the current version, #{rubygems_version}"
- end
- end
- end
-
- def warn_on_incompatible_bundler_deps
- bundler_version = Gem::Version.create(Bundler::VERSION)
- @definition.specs.each do |spec|
- spec.dependencies.each do |dep|
- next if dep.type == :development
- next unless dep.name == "bundler".freeze
- next if dep.requirement.satisfied_by?(bundler_version)
-
- Bundler.ui.warn "#{spec.name} (#{spec.version}) has dependency" \
- " #{SharedHelpers.pretty_dependency(dep)}" \
- ", which is unsatisfied by the current bundler version #{VERSION}" \
- ", so the dependency is being ignored"
- end
- end
- end
-
- def can_install_in_parallel?
- true
- end
-
- def install_in_parallel(size, standalone, force = false)
- spec_installations = ParallelInstaller.call(self, @definition.specs, size, standalone, force)
- spec_installations.each do |installation|
- post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
- end
- end
-
- def create_bundle_path
- SharedHelpers.filesystem_access(Bundler.bundle_path.to_s) do |p|
- Bundler.mkdir_p(p)
- end unless Bundler.bundle_path.exist?
- rescue Errno::EEXIST
- raise PathError, "Could not install to path `#{Bundler.bundle_path}` " \
- "because a file already exists at that path. Either remove or rename the file so the directory can be created."
- end
-
- # returns whether or not a re-resolve was needed
- def resolve_if_needed(options)
- if !@definition.unlocking? && !options["force"] && !options["all-platforms"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
- return false if @definition.nothing_changed? && !@definition.missing_specs?
- end
-
- options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
- true
- end
-
- def lock(opts = {})
- @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
- end
- end
-end
diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb
deleted file mode 100644
index 9689911d6c..0000000000
--- a/lib/bundler/installer/gem_installer.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# frozen_string_literal: true
-
-require "shellwords"
-
-module Bundler
- class GemInstaller
- attr_reader :spec, :standalone, :worker, :force, :installer
-
- def initialize(spec, installer, standalone = false, worker = 0, force = false)
- @spec = spec
- @installer = installer
- @standalone = standalone
- @worker = worker
- @force = force
- end
-
- def install_from_spec
- post_install_message = spec_settings ? install_with_settings : install
- Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
- generate_executable_stubs
- return true, post_install_message
- rescue Bundler::InstallHookError, Bundler::SecurityError, APIResponseMismatchError
- raise
- rescue Errno::ENOSPC
- return false, out_of_space_message
- rescue StandardError => e
- return false, specific_failure_message(e)
- end
-
- private
-
- def specific_failure_message(e)
- message = "#{e.class}: #{e.message}\n"
- message += " " + e.backtrace.join("\n ") + "\n\n" if Bundler.ui.debug?
- message = message.lines.first + Bundler.ui.add_color(message.lines.drop(1).join, :clear)
- message + Bundler.ui.add_color(failure_message, :red)
- end
-
- def failure_message
- return install_error_message if spec.source.options["git"]
- "#{install_error_message}\n#{gem_install_message}"
- end
-
- def install_error_message
- "An error occurred while installing #{spec.name} (#{spec.version}), and Bundler cannot continue."
- end
-
- def gem_install_message
- source = spec.source
- return unless source.respond_to?(:remotes)
-
- if source.remotes.size == 1
- "Make sure that `gem install #{spec.name} -v '#{spec.version}' --source '#{source.remotes.first}'` succeeds before bundling."
- else
- "Make sure that `gem install #{spec.name} -v '#{spec.version}'` succeeds before bundling."
- end
- end
-
- def spec_settings
- # Fetch the build settings, if there are any
- if settings = Bundler.settings["build.#{spec.name}"]
- Shellwords.shellsplit(settings)
- end
- end
-
- def install
- spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => Array(spec_settings))
- end
-
- def install_with_settings
- # Build arguments are global, so this is mutexed
- Bundler.rubygems.install_with_build_args([spec_settings]) { install }
- end
-
- def out_of_space_message
- "#{install_error_message}\nYour disk is out of space. Free some space to be able to install your bundle."
- end
-
- def generate_executable_stubs
- return if Bundler.feature_flag.forget_cli_options?
- return if Bundler.settings[:inline]
- if Bundler.settings[:bin] && standalone
- installer.generate_standalone_bundler_executable_stubs(spec)
- elsif Bundler.settings[:bin]
- installer.generate_bundler_executable_stubs(spec, :force => true)
- end
- end
- end
-end
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
deleted file mode 100644
index 391540af0b..0000000000
--- a/lib/bundler/installer/parallel_installer.rb
+++ /dev/null
@@ -1,229 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../worker"
-require_relative "gem_installer"
-
-module Bundler
- class ParallelInstaller
- class SpecInstallation
- attr_accessor :spec, :name, :post_install_message, :state, :error
- def initialize(spec)
- @spec = spec
- @name = spec.name
- @state = :none
- @post_install_message = ""
- @error = nil
- end
-
- def installed?
- state == :installed
- end
-
- def enqueued?
- state == :enqueued
- end
-
- def failed?
- state == :failed
- end
-
- def installation_attempted?
- installed? || failed?
- end
-
- # Only true when spec in neither installed nor already enqueued
- def ready_to_enqueue?
- !enqueued? && !installation_attempted?
- end
-
- def has_post_install_message?
- !post_install_message.empty?
- end
-
- def ignorable_dependency?(dep)
- dep.type == :development || dep.name == @name
- end
-
- # Checks installed dependencies against spec's dependencies to make
- # sure needed dependencies have been installed.
- def dependencies_installed?(all_specs)
- installed_specs = all_specs.select(&:installed?).map(&:name)
- dependencies.all? {|d| installed_specs.include? d.name }
- end
-
- # Represents only the non-development dependencies, the ones that are
- # itself and are in the total list.
- def dependencies
- @dependencies ||= begin
- all_dependencies.reject {|dep| ignorable_dependency? dep }
- end
- end
-
- def missing_lockfile_dependencies(all_spec_names)
- deps = all_dependencies.reject {|dep| ignorable_dependency? dep }
- deps.reject {|dep| all_spec_names.include? dep.name }
- end
-
- # Represents all dependencies
- def all_dependencies
- @spec.dependencies
- end
-
- def to_s
- "#<#{self.class} #{@spec.full_name} (#{state})>"
- end
- end
-
- def self.call(*args)
- new(*args).call
- end
-
- attr_reader :size
-
- def initialize(installer, all_specs, size, standalone, force)
- @installer = installer
- @size = size
- @standalone = standalone
- @force = force
- @specs = all_specs.map {|s| SpecInstallation.new(s) }
- @spec_set = all_specs
- @rake = @specs.find {|s| s.name == "rake" }
- end
-
- def call
- check_for_corrupt_lockfile
-
- if @size > 1
- install_with_worker
- else
- install_serially
- end
-
- handle_error if @specs.any?(&:failed?)
- @specs
- ensure
- worker_pool && worker_pool.stop
- end
-
- def check_for_corrupt_lockfile
- missing_dependencies = @specs.map do |s|
- [
- s,
- s.missing_lockfile_dependencies(@specs.map(&:name)),
- ]
- end.reject {|a| a.last.empty? }
- return if missing_dependencies.empty?
-
- warning = []
- warning << "Your lockfile was created by an old Bundler that left some things out."
- if @size != 1
- warning << "Because of the missing DEPENDENCIES, we can only install gems one at a time, instead of installing #{@size} at a time."
- @size = 1
- end
- warning << "You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile."
- warning << "The missing gems are:"
-
- missing_dependencies.each do |spec, missing|
- warning << "* #{missing.map(&:name).join(", ")} depended upon by #{spec.name}"
- end
-
- Bundler.ui.warn(warning.join("\n"))
- end
-
- private
-
- def install_with_worker
- enqueue_specs
- process_specs until finished_installing?
- end
-
- def install_serially
- until finished_installing?
- raise "failed to find a spec to enqueue while installing serially" unless spec_install = @specs.find(&:ready_to_enqueue?)
- spec_install.state = :enqueued
- do_install(spec_install, 0)
- end
- end
-
- def worker_pool
- @worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda {|spec_install, worker_num|
- do_install(spec_install, worker_num)
- }
- end
-
- def do_install(spec_install, worker_num)
- Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL, spec_install)
- gem_installer = Bundler::GemInstaller.new(
- spec_install.spec, @installer, @standalone, worker_num, @force
- )
- success, message = begin
- gem_installer.install_from_spec
- rescue RuntimeError => e
- raise e, "#{e}\n\n#{require_tree_for_spec(spec_install.spec)}"
- end
- if success
- spec_install.state = :installed
- spec_install.post_install_message = message unless message.nil?
- else
- spec_install.state = :failed
- spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
- end
- Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL, spec_install)
- spec_install
- end
-
- # Dequeue a spec and save its post-install message and then enqueue the
- # remaining specs.
- # Some specs might've had to wait til this spec was installed to be
- # processed so the call to `enqueue_specs` is important after every
- # dequeue.
- def process_specs
- worker_pool.deq
- enqueue_specs
- end
-
- def finished_installing?
- @specs.all? do |spec|
- return true if spec.failed?
- spec.installed?
- end
- end
-
- def handle_error
- errors = @specs.select(&:failed?).map(&:error)
- if exception = errors.find {|e| e.is_a?(Bundler::BundlerError) }
- raise exception
- end
- raise Bundler::InstallError, errors.map(&:to_s).join("\n\n")
- end
-
- def require_tree_for_spec(spec)
- tree = @spec_set.what_required(spec)
- t = String.new("In #{File.basename(SharedHelpers.default_gemfile)}:\n")
- tree.each_with_index do |s, depth|
- t << " " * depth.succ << s.name
- unless tree.last == s
- t << %( was resolved to #{s.version}, which depends on)
- end
- t << %(\n)
- end
- t
- end
-
- # Keys in the remains hash represent uninstalled gems specs.
- # We enqueue all gem specs that do not have any dependencies.
- # Later we call this lambda again to install specs that depended on
- # previously installed specifications. We continue until all specs
- # are installed.
- def enqueue_specs
- @specs.select(&:ready_to_enqueue?).each do |spec|
- next if @rake && !@rake.installed? && spec.name != @rake.name
-
- if spec.dependencies_installed? @specs
- spec.state = :enqueued
- worker_pool.enq spec
- end
- end
- end
- end
-end
diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb
deleted file mode 100644
index e1beb25ad1..0000000000
--- a/lib/bundler/installer/standalone.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Standalone
- def initialize(groups, definition)
- @specs = groups.empty? ? definition.requested_specs : definition.specs_for(groups.map(&:to_sym))
- end
-
- def generate
- SharedHelpers.filesystem_access(bundler_path) do |p|
- FileUtils.mkdir_p(p)
- end
- File.open File.join(bundler_path, "setup.rb"), "w" do |file|
- file.puts "require 'rbconfig'"
- file.puts "ruby_engine = RUBY_ENGINE"
- file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]"
- file.puts "path = File.expand_path('..', __FILE__)"
- paths.each do |path|
- file.puts %($:.unshift "\#{path}/#{path}")
- end
- end
- end
-
- private
-
- def paths
- @specs.map do |spec|
- next if spec.name == "bundler"
- Array(spec.require_paths).map do |path|
- gem_path(path, spec).sub(version_dir, '#{ruby_engine}/#{ruby_version}')
- # This is a static string intentionally. It's interpolated at a later time.
- end
- end.flatten
- end
-
- def version_dir
- "#{Bundler::RubyVersion.system.engine}/#{RbConfig::CONFIG["ruby_version"]}"
- end
-
- def bundler_path
- Bundler.root.join(Bundler.settings[:path], "bundler")
- end
-
- def gem_path(path, spec)
- full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
- Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
- rescue TypeError
- error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
- raise Gem::InvalidSpecificationException.new(error_message)
- end
- end
-end
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
deleted file mode 100644
index 32c8bb9557..0000000000
--- a/lib/bundler/lazy_specification.rb
+++ /dev/null
@@ -1,122 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "match_platform"
-
-module Bundler
- class LazySpecification
- Identifier = Struct.new(:name, :version, :source, :platform, :dependencies)
- class Identifier
- include Comparable
- def <=>(other)
- return unless other.is_a?(Identifier)
- [name, version, platform_string] <=> [other.name, other.version, other.platform_string]
- end
-
- protected
-
- def platform_string
- platform_string = platform.to_s
- platform_string == Index::RUBY ? Index::NULL : platform_string
- end
- end
-
- include MatchPlatform
-
- attr_reader :name, :version, :dependencies, :platform
- attr_accessor :source, :remote
-
- def initialize(name, version, platform, source = nil)
- @name = name
- @version = version
- @dependencies = []
- @platform = platform || Gem::Platform::RUBY
- @source = source
- @specification = nil
- end
-
- def full_name
- if platform == Gem::Platform::RUBY || platform.nil?
- "#{@name}-#{@version}"
- else
- "#{@name}-#{@version}-#{platform}"
- end
- end
-
- def ==(other)
- identifier == other.identifier
- end
-
- def satisfies?(dependency)
- @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version))
- end
-
- def to_lock
- out = String.new
-
- if platform == Gem::Platform::RUBY || platform.nil?
- out << " #{name} (#{version})\n"
- else
- out << " #{name} (#{version}-#{platform})\n"
- end
-
- dependencies.sort_by(&:to_s).uniq.each do |dep|
- next if dep.type == :development
- out << " #{dep.to_lock}\n"
- end
-
- out
- end
-
- def __materialize__
- search_object = Bundler.feature_flag.specific_platform? || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
- @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
- source.gemspec.tap {|s| s.source = source }
- else
- search = source.specs.search(search_object).last
- if search && Gem::Platform.new(search.platform) != Gem::Platform.new(platform) && !search.runtime_dependencies.-(dependencies.reject {|d| d.type == :development }).empty?
- Bundler.ui.warn "Unable to use the platform-specific (#{search.platform}) version of #{name} (#{version}) " \
- "because it has different dependencies from the #{platform} version. " \
- "To use the platform-specific version of the gem, run `bundle config set specific_platform true` and install again."
- search = source.specs.search(self).last
- end
- search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
- search
- end
- end
-
- def respond_to?(*args)
- super || @specification ? @specification.respond_to?(*args) : nil
- end
-
- def to_s
- @__to_s ||= if platform == Gem::Platform::RUBY || platform.nil?
- "#{name} (#{version})"
- else
- "#{name} (#{version}-#{platform})"
- end
- end
-
- def identifier
- @__identifier ||= Identifier.new(name, version, source, platform, dependencies)
- end
-
- def git_version
- return unless source.is_a?(Bundler::Source::Git)
- " #{source.revision[0..6]}"
- end
-
- private
-
- def to_ary
- nil
- end
-
- def method_missing(method, *args, &blk)
- raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
-
- return super unless respond_to?(method)
-
- @specification.send(method, *args, &blk)
- end
- end
-end
diff --git a/lib/bundler/lockfile_generator.rb b/lib/bundler/lockfile_generator.rb
deleted file mode 100644
index 585077d18d..0000000000
--- a/lib/bundler/lockfile_generator.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class LockfileGenerator
- attr_reader :definition
- attr_reader :out
-
- # @private
- def initialize(definition)
- @definition = definition
- @out = String.new
- end
-
- def self.generate(definition)
- new(definition).generate!
- end
-
- def generate!
- add_sources
- add_platforms
- add_dependencies
- add_locked_ruby_version
- add_bundled_with
-
- out
- end
-
- private
-
- def add_sources
- definition.send(:sources).lock_sources.each_with_index do |source, idx|
- out << "\n" unless idx.zero?
-
- # Add the source header
- out << source.to_lock
-
- # Find all specs for this source
- specs = definition.resolve.select {|s| source.can_lock?(s) }
- add_specs(specs)
- end
- end
-
- def add_specs(specs)
- # This needs to be sorted by full name so that
- # gems with the same name, but different platform
- # are ordered consistently
- specs.sort_by(&:full_name).each do |spec|
- next if spec.name == "bundler".freeze
- out << spec.to_lock
- end
- end
-
- def add_platforms
- add_section("PLATFORMS", definition.platforms)
- end
-
- def add_dependencies
- out << "\nDEPENDENCIES\n"
-
- handled = []
- definition.dependencies.sort_by(&:to_s).each do |dep|
- next if handled.include?(dep.name)
- out << dep.to_lock
- handled << dep.name
- end
- end
-
- def add_locked_ruby_version
- return unless locked_ruby_version = definition.locked_ruby_version
- add_section("RUBY VERSION", locked_ruby_version.to_s)
- end
-
- def add_bundled_with
- add_section("BUNDLED WITH", definition.locked_bundler_version.to_s)
- end
-
- def add_section(name, value)
- out << "\n#{name}\n"
- case value
- when Array
- value.map(&:to_s).sort.each do |val|
- out << " #{val}\n"
- end
- when Hash
- value.to_a.sort_by {|k, _| k.to_s }.each do |key, val|
- out << " #{key}: #{val}\n"
- end
- when String
- out << " #{value}\n"
- else
- raise ArgumentError, "#{value.inspect} can't be serialized in a lockfile"
- end
- end
- end
-end
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
deleted file mode 100644
index caabd524d4..0000000000
--- a/lib/bundler/lockfile_parser.rb
+++ /dev/null
@@ -1,249 +0,0 @@
-# frozen_string_literal: true
-
-#--
-# Some versions of the Bundler 1.1 RC series introduced corrupted
-# lockfiles. There were two major problems:
-#
-# * multiple copies of the same GIT section appeared in the lockfile
-# * when this happened, those sections got multiple copies of gems
-# in those sections.
-#
-# As a result, Bundler 1.1 contains code that fixes the earlier
-# corruption. We will remove this fix-up code in Bundler 1.2.
-
-module Bundler
- class LockfileParser
- attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version
-
- BUNDLED = "BUNDLED WITH".freeze
- DEPENDENCIES = "DEPENDENCIES".freeze
- PLATFORMS = "PLATFORMS".freeze
- RUBY = "RUBY VERSION".freeze
- GIT = "GIT".freeze
- GEM = "GEM".freeze
- PATH = "PATH".freeze
- PLUGIN = "PLUGIN SOURCE".freeze
- SPECS = " specs:".freeze
- OPTIONS = /^ ([a-z]+): (.*)$/i.freeze
- SOURCE = [GIT, GEM, PATH, PLUGIN].freeze
-
- SECTIONS_BY_VERSION_INTRODUCED = {
- Gem::Version.create("1.0") => [DEPENDENCIES, PLATFORMS, GIT, GEM, PATH].freeze,
- Gem::Version.create("1.10") => [BUNDLED].freeze,
- Gem::Version.create("1.12") => [RUBY].freeze,
- Gem::Version.create("1.13") => [PLUGIN].freeze,
- }.freeze
-
- KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
-
- ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
-
- def self.sections_in_lockfile(lockfile_contents)
- lockfile_contents.scan(/^\w[\w ]*$/).uniq
- end
-
- def self.unknown_sections_in_lockfile(lockfile_contents)
- sections_in_lockfile(lockfile_contents) - KNOWN_SECTIONS
- end
-
- def self.sections_to_ignore(base_version = nil)
- base_version &&= base_version.release
- base_version ||= Gem::Version.create("1.0".dup)
- attributes = []
- SECTIONS_BY_VERSION_INTRODUCED.each do |version, introduced|
- next if version <= base_version
- attributes += introduced
- end
- attributes
- end
-
- def initialize(lockfile)
- @platforms = []
- @sources = []
- @dependencies = {}
- @state = nil
- @specs = {}
-
- @rubygems_aggregate = Source::Rubygems.new
-
- if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
- raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
- "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
- end
-
- lockfile.split(/(?:\r?\n)+/).each do |line|
- if SOURCE.include?(line)
- @state = :source
- parse_source(line)
- elsif line == DEPENDENCIES
- @state = :dependency
- elsif line == PLATFORMS
- @state = :platform
- elsif line == RUBY
- @state = :ruby
- elsif line == BUNDLED
- @state = :bundled_with
- elsif line =~ /^[^\s]/
- @state = nil
- elsif @state
- send("parse_#{@state}", line)
- end
- end
- @sources << @rubygems_aggregate unless Bundler.feature_flag.disable_multisource?
- @specs = @specs.values.sort_by(&:identifier)
- warn_for_outdated_bundler_version
- rescue ArgumentError => e
- Bundler.ui.debug(e)
- raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
- "and then `bundle install` to generate a new lockfile."
- end
-
- def warn_for_outdated_bundler_version
- return unless bundler_version
- prerelease_text = bundler_version.prerelease? ? " --pre" : ""
- current_version = Gem::Version.create(Bundler::VERSION)
- return unless current_version < bundler_version
- Bundler.ui.warn "Warning: the running version of Bundler (#{current_version}) is older " \
- "than the version that created the lockfile (#{bundler_version}). We suggest you to " \
- "upgrade to the version that created the lockfile by running `gem install " \
- "bundler:#{bundler_version}#{prerelease_text}`.\n"
- end
-
- private
-
- TYPES = {
- GIT => Bundler::Source::Git,
- GEM => Bundler::Source::Rubygems,
- PATH => Bundler::Source::Path,
- PLUGIN => Bundler::Plugin,
- }.freeze
-
- def parse_source(line)
- case line
- when SPECS
- case @type
- when PATH
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- when GIT
- @current_source = TYPES[@type].from_lock(@opts)
- # Strip out duplicate GIT sections
- if @sources.include?(@current_source)
- @current_source = @sources.find {|s| s == @current_source }
- else
- @sources << @current_source
- end
- when GEM
- if Bundler.feature_flag.disable_multisource?
- @opts["remotes"] = @opts.delete("remote")
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- else
- Array(@opts["remote"]).each do |url|
- @rubygems_aggregate.add_remote(url)
- end
- @current_source = @rubygems_aggregate
- end
- when PLUGIN
- @current_source = Plugin.source_from_lock(@opts)
- @sources << @current_source
- end
- when OPTIONS
- value = $2
- value = true if value == "true"
- value = false if value == "false"
-
- key = $1
-
- if @opts[key]
- @opts[key] = Array(@opts[key])
- @opts[key] << value
- else
- @opts[key] = value
- end
- when *SOURCE
- @current_source = nil
- @opts = {}
- @type = line
- else
- parse_spec(line)
- end
- end
-
- space = / /
- NAME_VERSION = /
- ^(#{space}{2}|#{space}{4}|#{space}{6})(?!#{space}) # Exactly 2, 4, or 6 spaces at the start of the line
- (.*?) # Name
- (?:#{space}\(([^-]*) # Space, followed by version
- (?:-(.*))?\))? # Optional platform
- (!)? # Optional pinned marker
- $ # Line end
- /xo.freeze
-
- def parse_dependency(line)
- return unless line =~ NAME_VERSION
- spaces = $1
- return unless spaces.size == 2
- name = $2
- version = $3
- pinned = $5
-
- version = version.split(",").map(&:strip) if version
-
- dep = Bundler::Dependency.new(name, version)
-
- if pinned && dep.name != "bundler"
- spec = @specs.find {|_, v| v.name == dep.name }
- dep.source = spec.last.source if spec
-
- # Path sources need to know what the default name / version
- # to use in the case that there are no gemspecs present. A fake
- # gemspec is created based on the version set on the dependency
- # TODO: Use the version from the spec instead of from the dependency
- if version && version.size == 1 && version.first =~ /^\s*= (.+)\s*$/ && dep.source.is_a?(Bundler::Source::Path)
- dep.source.name = name
- dep.source.version = $1
- end
- end
-
- @dependencies[dep.name] = dep
- end
-
- def parse_spec(line)
- return unless line =~ NAME_VERSION
- spaces = $1
- name = $2
- version = $3
- platform = $4
-
- if spaces.size == 4
- version = Gem::Version.new(version)
- platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
- @current_spec = LazySpecification.new(name, version, platform)
- @current_spec.source = @current_source
-
- # Avoid introducing multiple copies of the same spec (caused by
- # duplicate GIT sections)
- @specs[@current_spec.identifier] ||= @current_spec
- elsif spaces.size == 6
- version = version.split(",").map(&:strip) if version
- dep = Gem::Dependency.new(name, version)
- @current_spec.dependencies << dep
- end
- end
-
- def parse_platform(line)
- @platforms << Gem::Platform.new($1) if line =~ /^ (.*)$/
- end
-
- def parse_bundled_with(line)
- line = line.strip
- return unless Gem::Version.correct?(line)
- @bundler_version = Gem::Version.create(line)
- end
-
- def parse_ruby(line)
- @ruby_version = line.strip
- end
- end
-end
diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb
deleted file mode 100644
index 69074925a6..0000000000
--- a/lib/bundler/match_platform.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "gem_helpers"
-
-module Bundler
- module MatchPlatform
- include GemHelpers
-
- def match_platform(p)
- MatchPlatform.platforms_match?(platform, p)
- end
-
- def self.platforms_match?(gemspec_platform, local_platform)
- return true if gemspec_platform.nil?
- return true if Gem::Platform::RUBY == gemspec_platform
- return true if local_platform == gemspec_platform
- gemspec_platform = Gem::Platform.new(gemspec_platform)
- return true if GemHelpers.generic(gemspec_platform) === local_platform
- return true if gemspec_platform === local_platform
-
- false
- end
- end
-end
diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb
deleted file mode 100644
index 0e554bcc3f..0000000000
--- a/lib/bundler/mirror.rb
+++ /dev/null
@@ -1,223 +0,0 @@
-# frozen_string_literal: true
-
-require "socket"
-
-module Bundler
- class Settings
- # Class used to build the mirror set and then find a mirror for a given URI
- #
- # @param prober [Prober object, nil] by default a TCPSocketProbe, this object
- # will be used to probe the mirror address to validate that the mirror replies.
- class Mirrors
- def initialize(prober = nil)
- @all = Mirror.new
- @prober = prober || TCPSocketProbe.new
- @mirrors = {}
- end
-
- # Returns a mirror for the given uri.
- #
- # Depending on the uri having a valid mirror or not, it may be a
- # mirror that points to the provided uri
- def for(uri)
- if @all.validate!(@prober).valid?
- @all
- else
- fetch_valid_mirror_for(Settings.normalize_uri(uri))
- end
- end
-
- def each
- @mirrors.each do |k, v|
- yield k, v.uri.to_s
- end
- end
-
- def parse(key, value)
- config = MirrorConfig.new(key, value)
- mirror = if config.all?
- @all
- else
- @mirrors[config.uri] ||= Mirror.new
- end
- config.update_mirror(mirror)
- end
-
- private
-
- def fetch_valid_mirror_for(uri)
- downcased = uri.to_s.downcase
- mirror = @mirrors[downcased] || @mirrors[Bundler::URI(downcased).host] || Mirror.new(uri)
- mirror.validate!(@prober)
- mirror = Mirror.new(uri) unless mirror.valid?
- mirror
- end
- end
-
- # A mirror
- #
- # Contains both the uri that should be used as a mirror and the
- # fallback timeout which will be used for probing if the mirror
- # replies on time or not.
- class Mirror
- DEFAULT_FALLBACK_TIMEOUT = 0.1
-
- attr_reader :uri, :fallback_timeout
-
- def initialize(uri = nil, fallback_timeout = 0)
- self.uri = uri
- self.fallback_timeout = fallback_timeout
- @valid = nil
- end
-
- def uri=(uri)
- @uri = if uri.nil?
- nil
- else
- Bundler::URI(uri.to_s)
- end
- @valid = nil
- end
-
- def fallback_timeout=(timeout)
- case timeout
- when true, "true"
- @fallback_timeout = DEFAULT_FALLBACK_TIMEOUT
- when false, "false"
- @fallback_timeout = 0
- else
- @fallback_timeout = timeout.to_i
- end
- @valid = nil
- end
-
- def ==(other)
- !other.nil? && uri == other.uri && fallback_timeout == other.fallback_timeout
- end
-
- def valid?
- return false if @uri.nil?
- return @valid unless @valid.nil?
- false
- end
-
- def validate!(probe = nil)
- @valid = false if uri.nil?
- if @valid.nil?
- @valid = fallback_timeout == 0 || (probe || TCPSocketProbe.new).replies?(self)
- end
- self
- end
- end
-
- # Class used to parse one configuration line
- #
- # Gets the configuration line and the value.
- # This object provides a `update_mirror` method
- # used to setup the given mirror value.
- class MirrorConfig
- attr_accessor :uri, :value
-
- def initialize(config_line, value)
- uri, fallback =
- config_line.match(%r{\Amirror\.(all|.+?)(\.fallback_timeout)?\/?\z}).captures
- @fallback = !fallback.nil?
- @all = false
- if uri == "all"
- @all = true
- else
- @uri = Bundler::URI(uri).absolute? ? Settings.normalize_uri(uri) : uri
- end
- @value = value
- end
-
- def all?
- @all
- end
-
- def update_mirror(mirror)
- if @fallback
- mirror.fallback_timeout = @value
- else
- mirror.uri = Settings.normalize_uri(@value)
- end
- end
- end
-
- # Class used for probing TCP availability for a given mirror.
- class TCPSocketProbe
- def replies?(mirror)
- MirrorSockets.new(mirror).any? do |socket, address, timeout|
- begin
- socket.connect_nonblock(address)
- rescue Errno::EINPROGRESS
- wait_for_writtable_socket(socket, address, timeout)
- rescue RuntimeError # Connection failed somehow, again
- false
- end
- end
- end
-
- private
-
- def wait_for_writtable_socket(socket, address, timeout)
- if IO.select(nil, [socket], nil, timeout)
- probe_writtable_socket(socket, address)
- else # TCP Handshake timed out, or there is something dropping packets
- false
- end
- end
-
- def probe_writtable_socket(socket, address)
- socket.connect_nonblock(address)
- rescue Errno::EISCONN
- true
- rescue StandardError # Connection failed
- false
- end
- end
- end
-
- # Class used to build the list of sockets that correspond to
- # a given mirror.
- #
- # One mirror may correspond to many different addresses, both
- # because of it having many dns entries or because
- # the network interface is both ipv4 and ipv5
- class MirrorSockets
- def initialize(mirror)
- @timeout = mirror.fallback_timeout
- @addresses = Socket.getaddrinfo(mirror.uri.host, mirror.uri.port).map do |address|
- SocketAddress.new(address[0], address[3], address[1])
- end
- end
-
- def any?
- @addresses.any? do |address|
- socket = Socket.new(Socket.const_get(address.type), Socket::SOCK_STREAM, 0)
- socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
- value = yield socket, address.to_socket_address, @timeout
- socket.close unless socket.closed?
- value
- end
- end
- end
-
- # Socket address builder.
- #
- # Given a socket type, a host and a port,
- # provides a method to build sockaddr string
- class SocketAddress
- attr_reader :type, :host, :port
-
- def initialize(type, host, port)
- @type = type
- @host = host
- @port = port
- end
-
- def to_socket_address
- Socket.pack_sockaddr_in(@port, @host)
- end
- end
-end
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
deleted file mode 100644
index f4dd435df4..0000000000
--- a/lib/bundler/plugin.rb
+++ /dev/null
@@ -1,305 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "plugin/api"
-
-module Bundler
- module Plugin
- autoload :DSL, File.expand_path("plugin/dsl", __dir__)
- autoload :Events, File.expand_path("plugin/events", __dir__)
- autoload :Index, File.expand_path("plugin/index", __dir__)
- autoload :Installer, File.expand_path("plugin/installer", __dir__)
- autoload :SourceList, File.expand_path("plugin/source_list", __dir__)
-
- class MalformattedPlugin < PluginError; end
- class UndefinedCommandError < PluginError; end
- class UnknownSourceError < PluginError; end
-
- PLUGIN_FILE_NAME = "plugins.rb".freeze
-
- module_function
-
- def reset!
- instance_variables.each {|i| remove_instance_variable(i) }
-
- @sources = {}
- @commands = {}
- @hooks_by_event = Hash.new {|h, k| h[k] = [] }
- @loaded_plugin_names = []
- end
-
- reset!
-
- # Installs a new plugin by the given name
- #
- # @param [Array<String>] names the name of plugin to be installed
- # @param [Hash] options various parameters as described in description.
- # Refer to cli/plugin for available options
- def install(names, options)
- specs = Installer.new.install(names, options)
-
- save_plugins names, specs
- rescue PluginError => e
- if specs
- specs_to_delete = Hash[specs.select {|k, _v| names.include?(k) && !index.commands.values.include?(k) }]
- specs_to_delete.values.each {|spec| Bundler.rm_rf(spec.full_gem_path) }
- end
-
- Bundler.ui.error "Failed to install plugin #{name}: #{e.message}\n #{e.backtrace.join("\n ")}"
- end
-
- # List installed plugins and commands
- #
- def list
- installed_plugins = index.installed_plugins
- if installed_plugins.any?
- output = String.new
- installed_plugins.each do |plugin|
- output << "#{plugin}\n"
- output << "-----\n"
- index.plugin_commands(plugin).each do |command|
- output << " #{command}\n"
- end
- output << "\n"
- end
- else
- output = "No plugins installed"
- end
- Bundler.ui.info output
- end
-
- # Evaluates the Gemfile with a limited DSL and installs the plugins
- # specified by plugin method
- #
- # @param [Pathname] gemfile path
- # @param [Proc] block that can be evaluated for (inline) Gemfile
- def gemfile_install(gemfile = nil, &inline)
- Bundler.settings.temporary(:frozen => false, :deployment => false) do
- builder = DSL.new
- if block_given?
- builder.instance_eval(&inline)
- else
- builder.eval_gemfile(gemfile)
- end
- definition = builder.to_definition(nil, true)
-
- return if definition.dependencies.empty?
-
- plugins = definition.dependencies.map(&:name).reject {|p| index.installed? p }
- installed_specs = Installer.new.install_definition(definition)
-
- save_plugins plugins, installed_specs, builder.inferred_plugins
- end
- rescue RuntimeError => e
- unless e.is_a?(GemfileError)
- Bundler.ui.error "Failed to install plugin: #{e.message}\n #{e.backtrace[0]}"
- end
- raise
- end
-
- # The index object used to store the details about the plugin
- def index
- @index ||= Index.new
- end
-
- # The directory root for all plugin related data
- #
- # If run in an app, points to local root, in app_config_path
- # Otherwise, points to global root, in Bundler.user_bundle_path("plugin")
- def root
- @root ||= if SharedHelpers.in_bundle?
- local_root
- else
- global_root
- end
- end
-
- def local_root
- Bundler.app_config_path.join("plugin")
- end
-
- # The global directory root for all plugin related data
- def global_root
- Bundler.user_bundle_path("plugin")
- end
-
- # The cache directory for plugin stuffs
- def cache
- @cache ||= root.join("cache")
- end
-
- # To be called via the API to register to handle a command
- def add_command(command, cls)
- @commands[command] = cls
- end
-
- # Checks if any plugin handles the command
- def command?(command)
- !index.command_plugin(command).nil?
- end
-
- # To be called from Cli class to pass the command and argument to
- # approriate plugin class
- def exec_command(command, args)
- raise UndefinedCommandError, "Command `#{command}` not found" unless command? command
-
- load_plugin index.command_plugin(command) unless @commands.key? command
-
- @commands[command].new.exec(command, args)
- end
-
- # To be called via the API to register to handle a source plugin
- def add_source(source, cls)
- @sources[source] = cls
- end
-
- # Checks if any plugin declares the source
- def source?(name)
- !index.source_plugin(name.to_s).nil?
- end
-
- # @return [Class] that handles the source. The calss includes API::Source
- def source(name)
- raise UnknownSourceError, "Source #{name} not found" unless source? name
-
- load_plugin(index.source_plugin(name)) unless @sources.key? name
-
- @sources[name]
- end
-
- # @param [Hash] The options that are present in the lock file
- # @return [API::Source] the instance of the class that handles the source
- # type passed in locked_opts
- def source_from_lock(locked_opts)
- src = source(locked_opts["type"])
-
- src.new(locked_opts.merge("uri" => locked_opts["remote"]))
- end
-
- # To be called via the API to register a hooks and corresponding block that
- # will be called to handle the hook
- def add_hook(event, &block)
- unless Events.defined_event?(event)
- raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
- end
- @hooks_by_event[event.to_s] << block
- end
-
- # Runs all the hooks that are registered for the passed event
- #
- # It passes the passed arguments and block to the block registered with
- # the api.
- #
- # @param [String] event
- def hook(event, *args, &arg_blk)
- return unless Bundler.feature_flag.plugins?
- unless Events.defined_event?(event)
- raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
- end
-
- plugins = index.hook_plugins(event)
- return unless plugins.any?
-
- (plugins - @loaded_plugin_names).each {|name| load_plugin(name) }
-
- @hooks_by_event[event].each {|blk| blk.call(*args, &arg_blk) }
- end
-
- # currently only intended for specs
- #
- # @return [String, nil] installed path
- def installed?(plugin)
- Index.new.installed?(plugin)
- end
-
- # Post installation processing and registering with index
- #
- # @param [Array<String>] plugins list to be installed
- # @param [Hash] specs of plugins mapped to installation path (currently they
- # contain all the installed specs, including plugins)
- # @param [Array<String>] names of inferred source plugins that can be ignored
- def save_plugins(plugins, specs, optional_plugins = [])
- plugins.each do |name|
- spec = specs[name]
- validate_plugin! Pathname.new(spec.full_gem_path)
- installed = register_plugin(name, spec, optional_plugins.include?(name))
- Bundler.ui.info "Installed plugin #{name}" if installed
- end
- end
-
- # Checks if the gem is good to be a plugin
- #
- # At present it only checks whether it contains plugins.rb file
- #
- # @param [Pathname] plugin_path the path plugin is installed at
- # @raise [MalformattedPlugin] if plugins.rb file is not found
- def validate_plugin!(plugin_path)
- plugin_file = plugin_path.join(PLUGIN_FILE_NAME)
- raise MalformattedPlugin, "#{PLUGIN_FILE_NAME} was not found in the plugin." unless plugin_file.file?
- end
-
- # Runs the plugins.rb file in an isolated namespace, records the plugin
- # actions it registers for and then passes the data to index to be stored.
- #
- # @param [String] name the name of the plugin
- # @param [Specification] spec of installed plugin
- # @param [Boolean] optional_plugin, removed if there is conflict with any
- # other plugin (used for default source plugins)
- #
- # @raise [MalformattedPlugin] if plugins.rb raises any error
- def register_plugin(name, spec, optional_plugin = false)
- commands = @commands
- sources = @sources
- hooks = @hooks_by_event
-
- @commands = {}
- @sources = {}
- @hooks_by_event = Hash.new {|h, k| h[k] = [] }
-
- load_paths = spec.load_paths
- Bundler.rubygems.add_to_load_path(load_paths)
- path = Pathname.new spec.full_gem_path
-
- begin
- load path.join(PLUGIN_FILE_NAME), true
- rescue StandardError => e
- raise MalformattedPlugin, "#{e.class}: #{e.message}"
- end
-
- if optional_plugin && @sources.keys.any? {|s| source? s }
- Bundler.rm_rf(path)
- false
- else
- index.register_plugin(name, path.to_s, load_paths, @commands.keys,
- @sources.keys, @hooks_by_event.keys)
- true
- end
- ensure
- @commands = commands
- @sources = sources
- @hooks_by_event = hooks
- end
-
- # Executes the plugins.rb file
- #
- # @param [String] name of the plugin
- def load_plugin(name)
- # Need to ensure before this that plugin root where the rest of gems
- # are installed to be on load path to support plugin deps. Currently not
- # done to avoid conflicts
- path = index.plugin_path(name)
-
- Bundler.rubygems.add_to_load_path(index.load_paths(name))
-
- load path.join(PLUGIN_FILE_NAME)
-
- @loaded_plugin_names << name
- rescue RuntimeError => e
- Bundler.ui.error "Failed loading plugin #{name}: #{e.message}"
- raise
- end
-
- class << self
- private :load_plugin, :register_plugin, :save_plugins, :validate_plugin!
- end
- end
-end
diff --git a/lib/bundler/plugin/api.rb b/lib/bundler/plugin/api.rb
deleted file mode 100644
index ee2bffe3ab..0000000000
--- a/lib/bundler/plugin/api.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # This is the interfacing class represents the API that we intend to provide
- # the plugins to use.
- #
- # For plugins to be independent of the Bundler internals they shall limit their
- # interactions to methods of this class only. This will save them from breaking
- # when some internal change.
- #
- # Currently we are delegating the methods defined in Bundler class to
- # itself. So, this class acts as a buffer.
- #
- # If there is some change in the Bundler class that is incompatible to its
- # previous behavior or if otherwise desired, we can reimplement(or implement)
- # the method to preserve compatibility.
- #
- # To use this, either the class can inherit this class or use it directly.
- # For example of both types of use, refer the file `spec/plugins/command.rb`
- #
- # To use it without inheriting, you will have to create an object of this
- # to use the functions (except for declaration functions like command, source,
- # and hooks).
- module Plugin
- class API
- autoload :Source, File.expand_path("api/source", __dir__)
-
- # The plugins should declare that they handle a command through this helper.
- #
- # @param [String] command being handled by them
- # @param [Class] (optional) class that handles the command. If not
- # provided, the `self` class will be used.
- def self.command(command, cls = self)
- Plugin.add_command command, cls
- end
-
- # The plugins should declare that they provide a installation source
- # through this helper.
- #
- # @param [String] the source type they provide
- # @param [Class] (optional) class that handles the source. If not
- # provided, the `self` class will be used.
- def self.source(source, cls = self)
- cls.send :include, Bundler::Plugin::API::Source
- Plugin.add_source source, cls
- end
-
- def self.hook(event, &block)
- Plugin.add_hook(event, &block)
- end
-
- # The cache dir to be used by the plugins for storage
- #
- # @return [Pathname] path of the cache dir
- def cache_dir
- Plugin.cache.join("plugins")
- end
-
- # A tmp dir to be used by plugins
- # Accepts names that get concatenated as suffix
- #
- # @return [Pathname] object for the new directory created
- def tmp(*names)
- Bundler.tmp(["plugin", *names].join("-"))
- end
-
- def method_missing(name, *args, &blk)
- return Bundler.send(name, *args, &blk) if Bundler.respond_to?(name)
-
- return SharedHelpers.send(name, *args, &blk) if SharedHelpers.respond_to?(name)
-
- super
- end
-
- def respond_to_missing?(name, include_private = false)
- SharedHelpers.respond_to?(name, include_private) ||
- Bundler.respond_to?(name, include_private) || super
- end
- end
- end
-end
diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb
deleted file mode 100644
index 56e97f4aa4..0000000000
--- a/lib/bundler/plugin/api/source.rb
+++ /dev/null
@@ -1,304 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module Plugin
- class API
- # This class provides the base to build source plugins
- # All the method here are required to build a source plugin (except
- # `uri_hash`, `gem_install_dir`; they are helpers).
- #
- # Defaults for methods, where ever possible are provided which is
- # expected to work. But, all source plugins have to override
- # `fetch_gemspec_files` and `install`. Defaults are also not provided for
- # `remote!`, `cache!` and `unlock!`.
- #
- # The defaults shall work for most situations but nevertheless they can
- # be (preferably should be) overridden as per the plugins' needs safely
- # (as long as they behave as expected).
- # On overriding `initialize` you should call super first.
- #
- # If required plugin should override `hash`, `==` and `eql?` methods to be
- # able to match objects representing same sources, but may be created in
- # different situation (like form gemfile and lockfile). The default ones
- # checks only for class and uri, but elaborate source plugins may need
- # more comparisons (e.g. git checking on branch or tag).
- #
- # @!attribute [r] uri
- # @return [String] the remote specified with `source` block in Gemfile
- #
- # @!attribute [r] options
- # @return [String] options passed during initialization (either from
- # lockfile or Gemfile)
- #
- # @!attribute [r] name
- # @return [String] name that can be used to uniquely identify a source
- #
- # @!attribute [rw] dependency_names
- # @return [Array<String>] Names of dependencies that the source should
- # try to resolve. It is not necessary to use this list internally. This
- # is present to be compatible with `Definition` and is used by
- # rubygems source.
- module Source
- attr_reader :uri, :options, :name
- attr_accessor :dependency_names
-
- def initialize(opts)
- @options = opts
- @dependency_names = []
- @uri = opts["uri"]
- @type = opts["type"]
- @name = opts["name"] || "#{@type} at #{@uri}"
- end
-
- # This is used by the default `spec` method to constructs the
- # Specification objects for the gems and versions that can be installed
- # by this source plugin.
- #
- # Note: If the spec method is overridden, this function is not necessary
- #
- # @return [Array<String>] paths of the gemspec files for gems that can
- # be installed
- def fetch_gemspec_files
- []
- end
-
- # Options to be saved in the lockfile so that the source plugin is able
- # to check out same version of gem later.
- #
- # There options are passed when the source plugin is created from the
- # lock file.
- #
- # @return [Hash]
- def options_to_lock
- {}
- end
-
- # Install the gem specified by the spec at appropriate path.
- # `install_path` provides a sufficient default, if the source can only
- # satisfy one gem, but is not binding.
- #
- # @return [String] post installation message (if any)
- def install(spec, opts)
- raise MalformattedPlugin, "Source plugins need to override the install method."
- end
-
- # It builds extensions, generates bins and installs them for the spec
- # provided.
- #
- # It depends on `spec.loaded_from` to get full_gem_path. The source
- # plugins should set that.
- #
- # It should be called in `install` after the plugin is done placing the
- # gem at correct install location.
- #
- # It also runs Gem hooks `pre_install`, `post_build` and `post_install`
- #
- # Note: Do not override if you don't know what you are doing.
- def post_install(spec, disable_exts = false)
- opts = { :env_shebang => false, :disable_extensions => disable_exts }
- installer = Bundler::Source::Path::Installer.new(spec, opts)
- installer.post_install
- end
-
- # A default installation path to install a single gem. If the source
- # servers multiple gems, it's not of much use and the source should one
- # of its own.
- def install_path
- @install_path ||=
- begin
- base_name = File.basename(Bundler::URI.parse(uri).normalize.path)
-
- gem_install_dir.join("#{base_name}-#{uri_hash[0..11]}")
- end
- end
-
- # Parses the gemspec files to find the specs for the gems that can be
- # satisfied by the source.
- #
- # Few important points to keep in mind:
- # - If the gems are not installed then it shall return specs for all
- # the gems it can satisfy
- # - If gem is installed (that is to be detected by the plugin itself)
- # then it shall return at least the specs that are installed.
- # - The `loaded_from` for each of the specs shall be correct (it is
- # used to find the load path)
- #
- # @return [Bundler::Index] index containing the specs
- def specs
- files = fetch_gemspec_files
-
- Bundler::Index.build do |index|
- files.each do |file|
- next unless spec = Bundler.load_gemspec(file)
- Bundler.rubygems.set_installed_by_version(spec)
-
- spec.source = self
- Bundler.rubygems.validate(spec)
-
- index << spec
- end
- end
- end
-
- # Set internal representation to fetch the gems/specs from remote.
- #
- # When this is called, the source should try to fetch the specs and
- # install from remote path.
- def remote!
- end
-
- # Set internal representation to fetch the gems/specs from app cache.
- #
- # When this is called, the source should try to fetch the specs and
- # install from the path provided by `app_cache_path`.
- def cached!
- end
-
- # This is called to update the spec and installation.
- #
- # If the source plugin is loaded from lockfile or otherwise, it shall
- # refresh the cache/specs (e.g. git sources can make a fresh clone).
- def unlock!
- end
-
- # Name of directory where plugin the is expected to cache the gems when
- # #cache is called.
- #
- # Also this name is matched against the directories in cache for pruning
- #
- # This is used by `app_cache_path`
- def app_cache_dirname
- base_name = File.basename(Bundler::URI.parse(uri).normalize.path)
- "#{base_name}-#{uri_hash}"
- end
-
- # This method is called while caching to save copy of the gems that the
- # source can resolve to path provided by `app_cache_app`so that they can
- # be reinstalled from the cache without querying the remote (i.e. an
- # alternative to remote)
- #
- # This is stored with the app and source plugins should try to provide
- # specs and install only from this cache when `cached!` is called.
- #
- # This cache is different from the internal caching that can be done
- # at sub paths of `cache_path` (from API). This can be though as caching
- # by bundler.
- def cache(spec, custom_path = nil)
- new_cache_path = app_cache_path(custom_path)
-
- FileUtils.rm_rf(new_cache_path)
- FileUtils.cp_r(install_path, new_cache_path)
- FileUtils.touch(app_cache_path.join(".bundlecache"))
- end
-
- # This shall check if two source object represent the same source.
- #
- # The comparison shall take place only on the attribute that can be
- # inferred from the options passed from Gemfile and not on attributes
- # that are used to pin down the gem to specific version (e.g. Git
- # sources should compare on branch and tag but not on commit hash)
- #
- # The sources objects are constructed from Gemfile as well as from
- # lockfile. To converge the sources, it is necessary that they match.
- #
- # The same applies for `eql?` and `hash`
- def ==(other)
- other.is_a?(self.class) && uri == other.uri
- end
-
- # When overriding `eql?` please preserve the behaviour as mentioned in
- # docstring for `==` method.
- alias_method :eql?, :==
-
- # When overriding `hash` please preserve the behaviour as mentioned in
- # docstring for `==` method, i.e. two methods equal by above comparison
- # should have same hash.
- def hash
- [self.class, uri].hash
- end
-
- # A helper method, not necessary if not used internally.
- def installed?
- File.directory?(install_path)
- end
-
- # The full path where the plugin should cache the gem so that it can be
- # installed latter.
- #
- # Note: Do not override if you don't know what you are doing.
- def app_cache_path(custom_path = nil)
- @app_cache_path ||= Bundler.app_cache(custom_path).join(app_cache_dirname)
- end
-
- # Used by definition.
- #
- # Note: Do not override if you don't know what you are doing.
- def unmet_deps
- specs.unmet_dependency_names
- end
-
- # Note: Do not override if you don't know what you are doing.
- def can_lock?(spec)
- spec.source == self
- end
-
- # Generates the content to be entered into the lockfile.
- # Saves type and remote and also calls to `options_to_lock`.
- #
- # Plugin should use `options_to_lock` to save information in lockfile
- # and not override this.
- #
- # Note: Do not override if you don't know what you are doing.
- def to_lock
- out = String.new("#{LockfileParser::PLUGIN}\n")
- out << " remote: #{@uri}\n"
- out << " type: #{@type}\n"
- options_to_lock.each do |opt, value|
- out << " #{opt}: #{value}\n"
- end
- out << " specs:\n"
- end
-
- def to_s
- "plugin source for #{options[:type]} with uri #{uri}"
- end
-
- # Note: Do not override if you don't know what you are doing.
- def include?(other)
- other == self
- end
-
- def uri_hash
- SharedHelpers.digest(:SHA1).hexdigest(uri)
- end
-
- # Note: Do not override if you don't know what you are doing.
- def gem_install_dir
- Bundler.install_path
- end
-
- # It is used to obtain the full_gem_path.
- #
- # spec's loaded_from path is expanded against this to get full_gem_path
- #
- # Note: Do not override if you don't know what you are doing.
- def root
- Bundler.root
- end
-
- # @private
- # Returns true
- def bundler_plugin_api_source?
- true
- end
-
- # @private
- # This API on source might not be stable, and for now we expect plugins
- # to download all specs in `#specs`, so we implement the method for
- # compatibility purposes and leave it undocumented (and don't support)
- # overriding it)
- def double_check_for(*); end
- end
- end
- end
-end
diff --git a/lib/bundler/plugin/dsl.rb b/lib/bundler/plugin/dsl.rb
deleted file mode 100644
index 4bfc8437e0..0000000000
--- a/lib/bundler/plugin/dsl.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module Plugin
- # Dsl to parse the Gemfile looking for plugins to install
- class DSL < Bundler::Dsl
- class PluginGemfileError < PluginError; end
- alias_method :_gem, :gem # To use for plugin installation as gem
-
- # So that we don't have to override all there methods to dummy ones
- # explicitly.
- # They will be handled by method_missing
- [:gemspec, :gem, :path, :install_if, :platforms, :env].each {|m| undef_method m }
-
- # This lists the plugins that was added automatically and not specified by
- # the user.
- #
- # When we encounter :type attribute with a source block, we add a plugin
- # by name bundler-source-<type> to list of plugins to be installed.
- #
- # These plugins are optional and are not installed when there is conflict
- # with any other plugin.
- attr_reader :inferred_plugins
-
- def initialize
- super
- @sources = Plugin::SourceList.new
- @inferred_plugins = [] # The source plugins inferred from :type
- end
-
- def plugin(name, *args)
- _gem(name, *args)
- end
-
- def method_missing(name, *args)
- raise PluginGemfileError, "Undefined local variable or method `#{name}' for Gemfile" unless Bundler::Dsl.method_defined? name
- end
-
- def source(source, *args, &blk)
- options = args.last.is_a?(Hash) ? args.pop.dup : {}
- options = normalize_hash(options)
- return super unless options.key?("type")
-
- plugin_name = "bundler-source-#{options["type"]}"
-
- return if @dependencies.any? {|d| d.name == plugin_name }
-
- plugin(plugin_name)
- @inferred_plugins << plugin_name
- end
- end
- end
-end
diff --git a/lib/bundler/plugin/events.rb b/lib/bundler/plugin/events.rb
deleted file mode 100644
index bc037d1af5..0000000000
--- a/lib/bundler/plugin/events.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module Plugin
- module Events
- def self.define(const, event)
- const = const.to_sym.freeze
- if const_defined?(const) && const_get(const) != event
- raise ArgumentError, "Attempting to reassign #{const} to a different value"
- end
- const_set(const, event) unless const_defined?(const)
- @events ||= {}
- @events[event] = const
- end
- private_class_method :define
-
- def self.reset
- @events.each_value do |const|
- remove_const(const)
- end
- @events = nil
- end
- private_class_method :reset
-
- # Check if an event has been defined
- # @param event [String] An event to check
- # @return [Boolean] A boolean indicating if the event has been defined
- def self.defined_event?(event)
- @events ||= {}
- @events.key?(event)
- end
-
- # @!parse
- # A hook called before each individual gem is installed
- # Includes a Bundler::ParallelInstaller::SpecInstallation.
- # No state, error, post_install_message will be present as nothing has installed yet
- # GEM_BEFORE_INSTALL = "before-install"
- define :GEM_BEFORE_INSTALL, "before-install"
-
- # @!parse
- # A hook called after each individual gem is installed
- # Includes a Bundler::ParallelInstaller::SpecInstallation.
- # - If state is failed, an error will be present.
- # - If state is success, a post_install_message may be present.
- # GEM_AFTER_INSTALL = "after-install"
- define :GEM_AFTER_INSTALL, "after-install"
-
- # @!parse
- # A hook called before any gems install
- # Includes an Array of Bundler::Dependency objects
- # GEM_BEFORE_INSTALL_ALL = "before-install-all"
- define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
-
- # @!parse
- # A hook called after any gems install
- # Includes an Array of Bundler::Dependency objects
- # GEM_AFTER_INSTALL_ALL = "after-install-all"
- define :GEM_AFTER_INSTALL_ALL, "after-install-all"
- end
- end
-end
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
deleted file mode 100644
index 2d70a046bb..0000000000
--- a/lib/bundler/plugin/index.rb
+++ /dev/null
@@ -1,173 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # Manages which plugins are installed and their sources. This also is supposed to map
- # which plugin does what (currently the features are not implemented so this class is
- # now a stub class).
- module Plugin
- class Index
- class CommandConflict < PluginError
- def initialize(plugin, commands)
- msg = "Command(s) `#{commands.join("`, `")}` declared by #{plugin} are already registered."
- super msg
- end
- end
-
- class SourceConflict < PluginError
- def initialize(plugin, sources)
- msg = "Source(s) `#{sources.join("`, `")}` declared by #{plugin} are already registered."
- super msg
- end
- end
-
- attr_reader :commands
-
- def initialize
- @plugin_paths = {}
- @commands = {}
- @sources = {}
- @hooks = {}
- @load_paths = {}
-
- begin
- load_index(global_index_file, true)
- rescue GenericSystemCallError
- # no need to fail when on a read-only FS, for example
- nil
- end
- load_index(local_index_file) if SharedHelpers.in_bundle?
- end
-
- # This function is to be called when a new plugin is installed. This
- # function shall add the functions of the plugin to existing maps and also
- # the name to source location.
- #
- # @param [String] name of the plugin to be registered
- # @param [String] path where the plugin is installed
- # @param [Array<String>] load_paths for the plugin
- # @param [Array<String>] commands that are handled by the plugin
- # @param [Array<String>] sources that are handled by the plugin
- def register_plugin(name, path, load_paths, commands, sources, hooks)
- old_commands = @commands.dup
-
- common = commands & @commands.keys
- raise CommandConflict.new(name, common) unless common.empty?
- commands.each {|c| @commands[c] = name }
-
- common = sources & @sources.keys
- raise SourceConflict.new(name, common) unless common.empty?
- sources.each {|k| @sources[k] = name }
-
- hooks.each do |event|
- event_hooks = (@hooks[event] ||= []) << name
- event_hooks.uniq!
- end
-
- @plugin_paths[name] = path
- @load_paths[name] = load_paths
- save_index
- rescue StandardError
- @commands = old_commands
- raise
- end
-
- # Path of default index file
- def index_file
- Plugin.root.join("index")
- end
-
- # Path where the global index file is stored
- def global_index_file
- Plugin.global_root.join("index")
- end
-
- # Path where the local index file is stored
- def local_index_file
- Plugin.local_root.join("index")
- end
-
- def plugin_path(name)
- Pathname.new @plugin_paths[name]
- end
-
- def load_paths(name)
- @load_paths[name]
- end
-
- # Fetch the name of plugin handling the command
- def command_plugin(command)
- @commands[command]
- end
-
- def installed?(name)
- @plugin_paths[name]
- end
-
- def installed_plugins
- @plugin_paths.keys
- end
-
- def plugin_commands(plugin)
- @commands.find_all {|_, n| n == plugin }.map(&:first)
- end
-
- def source?(source)
- @sources.key? source
- end
-
- def source_plugin(name)
- @sources[name]
- end
-
- # Returns the list of plugin names handling the passed event
- def hook_plugins(event)
- @hooks[event] || []
- end
-
- private
-
- # Reads the index file from the directory and initializes the instance
- # variables.
- #
- # It skips the sources if the second param is true
- # @param [Pathname] index file path
- # @param [Boolean] is the index file global index
- def load_index(index_file, global = false)
- SharedHelpers.filesystem_access(index_file, :read) do |index_f|
- valid_file = index_f && index_f.exist? && !index_f.size.zero?
- break unless valid_file
-
- data = index_f.read
-
- require_relative "../yaml_serializer"
- index = YAMLSerializer.load(data)
-
- @commands.merge!(index["commands"])
- @hooks.merge!(index["hooks"])
- @load_paths.merge!(index["load_paths"])
- @plugin_paths.merge!(index["plugin_paths"])
- @sources.merge!(index["sources"]) unless global
- end
- end
-
- # Should be called when any of the instance variables change. Stores the
- # instance variables in YAML format. (The instance variables are supposed
- # to be only String key value pairs)
- def save_index
- index = {
- "commands" => @commands,
- "hooks" => @hooks,
- "load_paths" => @load_paths,
- "plugin_paths" => @plugin_paths,
- "sources" => @sources,
- }
-
- require_relative "../yaml_serializer"
- SharedHelpers.filesystem_access(index_file) do |index_f|
- FileUtils.mkdir_p(index_f.dirname)
- File.open(index_f, "w") {|f| f.puts YAMLSerializer.dump(index) }
- end
- end
- end
- end
-end
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
deleted file mode 100644
index bcea3f0e45..0000000000
--- a/lib/bundler/plugin/installer.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # Handles the installation of plugin in appropriate directories.
- #
- # This class is supposed to be wrapper over the existing gem installation infra
- # but currently it itself handles everything as the Source's subclasses (e.g. Source::RubyGems)
- # are heavily dependent on the Gemfile.
- module Plugin
- class Installer
- autoload :Rubygems, File.expand_path("installer/rubygems", __dir__)
- autoload :Git, File.expand_path("installer/git", __dir__)
-
- def install(names, options)
- check_sources_consistency!(options)
-
- version = options[:version] || [">= 0"]
-
- Bundler.settings.temporary(:disable_multisource => false) do
- if options[:git]
- install_git(names, version, options)
- elsif options[:local_git]
- install_local_git(names, version, options)
- else
- sources = options[:source] || Bundler.rubygems.sources
- install_rubygems(names, version, sources)
- end
- end
- end
-
- # Installs the plugin from Definition object created by limited parsing of
- # Gemfile searching for plugins to be installed
- #
- # @param [Definition] definition object
- # @return [Hash] map of names to their specs they are installed with
- def install_definition(definition)
- def definition.lock(*); end
- definition.resolve_remotely!
- specs = definition.specs
-
- install_from_specs specs
- end
-
- private
-
- def check_sources_consistency!(options)
- if options.key?(:git) && options.key?(:local_git)
- raise InvalidOption, "Remote and local plugin git sources can't be both specified"
- end
- end
-
- def install_git(names, version, options)
- uri = options.delete(:git)
- options["uri"] = uri
-
- install_all_sources(names, version, options, options[:source])
- end
-
- def install_local_git(names, version, options)
- uri = options.delete(:local_git)
- options["uri"] = uri
-
- install_all_sources(names, version, options, options[:source])
- end
-
- # Installs the plugin from rubygems source and returns the path where the
- # plugin was installed
- #
- # @param [String] name of the plugin gem to search in the source
- # @param [Array] version of the gem to install
- # @param [String, Array<String>] source(s) to resolve the gem
- #
- # @return [Hash] map of names to the specs of plugins installed
- def install_rubygems(names, version, sources)
- install_all_sources(names, version, nil, sources)
- end
-
- def install_all_sources(names, version, git_source_options, rubygems_source)
- source_list = SourceList.new
-
- source_list.add_git_source(git_source_options) if git_source_options
- source_list.add_rubygems_source("remotes" => rubygems_source) if rubygems_source
-
- deps = names.map {|name| Dependency.new name, version }
-
- definition = Definition.new(nil, deps, source_list, true)
- install_definition(definition)
- end
-
- # Installs the plugins and deps from the provided specs and returns map of
- # gems to their paths
- #
- # @param specs to install
- #
- # @return [Hash] map of names to the specs
- def install_from_specs(specs)
- paths = {}
-
- specs.each do |spec|
- spec.source.install spec
-
- paths[spec.name] = spec
- end
-
- paths
- end
- end
- end
-end
diff --git a/lib/bundler/plugin/installer/git.rb b/lib/bundler/plugin/installer/git.rb
deleted file mode 100644
index fbb6c5e40e..0000000000
--- a/lib/bundler/plugin/installer/git.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module Plugin
- class Installer
- class Git < Bundler::Source::Git
- def cache_path
- @cache_path ||= begin
- git_scope = "#{base_name}-#{uri_hash}"
-
- Plugin.cache.join("bundler", "git", git_scope)
- end
- end
-
- def install_path
- @install_path ||= begin
- git_scope = "#{base_name}-#{shortref_for_path(revision)}"
-
- Plugin.root.join("bundler", "gems", git_scope)
- end
- end
-
- def version_message(spec)
- "#{spec.name} #{spec.version}"
- end
-
- def root
- Plugin.root
- end
-
- def generate_bin(spec, disable_extensions = false)
- # Need to find a way without code duplication
- # For now, we can ignore this
- end
- end
- end
- end
-end
diff --git a/lib/bundler/plugin/installer/rubygems.rb b/lib/bundler/plugin/installer/rubygems.rb
deleted file mode 100644
index 7ae74fa93b..0000000000
--- a/lib/bundler/plugin/installer/rubygems.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module Plugin
- class Installer
- class Rubygems < Bundler::Source::Rubygems
- def version_message(spec)
- "#{spec.name} #{spec.version}"
- end
-
- private
-
- def requires_sudo?
- false # Will change on implementation of project level plugins
- end
-
- def rubygems_dir
- Plugin.root
- end
-
- def cache_path
- Plugin.cache
- end
- end
- end
- end
-end
diff --git a/lib/bundler/plugin/source_list.rb b/lib/bundler/plugin/source_list.rb
deleted file mode 100644
index f0e212205f..0000000000
--- a/lib/bundler/plugin/source_list.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # SourceList object to be used while parsing the Gemfile, setting the
- # approptiate options to be used with Source classes for plugin installation
- module Plugin
- class SourceList < Bundler::SourceList
- def add_git_source(options = {})
- add_source_to_list Plugin::Installer::Git.new(options), git_sources
- end
-
- def add_rubygems_source(options = {})
- add_source_to_list Plugin::Installer::Rubygems.new(options), @rubygems_sources
- end
-
- def all_sources
- path_sources + git_sources + rubygems_sources + [metadata_source]
- end
-
- private
-
- def rubygems_aggregate_class
- Plugin::Installer::Rubygems
- end
- end
- end
-end
diff --git a/lib/bundler/process_lock.rb b/lib/bundler/process_lock.rb
deleted file mode 100644
index cba4fcdba5..0000000000
--- a/lib/bundler/process_lock.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class ProcessLock
- def self.lock(bundle_path = Bundler.bundle_path)
- lock_file_path = File.join(bundle_path, "bundler.lock")
- has_lock = false
-
- File.open(lock_file_path, "w") do |f|
- f.flock(File::LOCK_EX)
- has_lock = true
- yield
- f.flock(File::LOCK_UN)
- end
- rescue Errno::EACCES, Errno::ENOLCK, *[SharedHelpers.const_get_safely(:ENOTSUP, Errno)].compact
- # In the case the user does not have access to
- # create the lock file or is using NFS where
- # locks are not available we skip locking.
- yield
- ensure
- FileUtils.rm_f(lock_file_path) if has_lock
- end
- end
-end
diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb
deleted file mode 100644
index c086b7651c..0000000000
--- a/lib/bundler/psyched_yaml.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-# Psych could be a gem, so try to ask for it
-begin
- gem "psych"
-rescue LoadError
-end if defined?(gem)
-
-# Psych could be in the stdlib
-# but it's too late if Syck is already loaded
-begin
- require "psych" unless defined?(Syck)
-rescue LoadError
- # Apparently Psych wasn't available. Oh well.
-end
-
-# At least load the YAML stdlib, whatever that may be
-require "yaml" unless defined?(YAML.dump)
-
-module Bundler
- # On encountering invalid YAML,
- # Psych raises Psych::SyntaxError
- if defined?(::Psych::SyntaxError)
- YamlLibrarySyntaxError = ::Psych::SyntaxError
- else # Syck raises ArgumentError
- YamlLibrarySyntaxError = ::ArgumentError
- end
-end
-
-require_relative "deprecate"
-begin
- Bundler::Deprecate.skip_during do
- require "rubygems/safe_yaml"
- end
-rescue LoadError
- # it's OK if the file isn't there
-end
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb
deleted file mode 100644
index f87a09b9a6..0000000000
--- a/lib/bundler/remote_specification.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # Represents a lazily loaded gem specification, where the full specification
- # is on the source server in rubygems' "quick" index. The proxy object is to
- # be seeded with what we're given from the source's abbreviated index - the
- # full specification will only be fetched when necessary.
- class RemoteSpecification
- include MatchPlatform
- include Comparable
-
- attr_reader :name, :version, :platform
- attr_writer :dependencies
- attr_accessor :source, :remote
-
- def initialize(name, version, platform, spec_fetcher)
- @name = name
- @version = Gem::Version.create version
- @platform = platform
- @spec_fetcher = spec_fetcher
- @dependencies = nil
- end
-
- # Needed before installs, since the arch matters then and quick
- # specs don't bother to include the arch in the platform string
- def fetch_platform
- @platform = _remote_specification.platform
- end
-
- def full_name
- if platform == Gem::Platform::RUBY || platform.nil?
- "#{@name}-#{@version}"
- else
- "#{@name}-#{@version}-#{platform}"
- end
- end
-
- # Compare this specification against another object. Using sort_obj
- # is compatible with Gem::Specification and other Bundler or RubyGems
- # objects. Otherwise, use the default Object comparison.
- def <=>(other)
- if other.respond_to?(:sort_obj)
- sort_obj <=> other.sort_obj
- else
- super
- end
- end
-
- # Because Rubyforge cannot be trusted to provide valid specifications
- # once the remote gem is downloaded, the backend specification will
- # be swapped out.
- def __swap__(spec)
- SharedHelpers.ensure_same_dependencies(self, dependencies, spec.dependencies)
- @_remote_specification = spec
- end
-
- # Create a delegate used for sorting. This strategy is copied from
- # RubyGems 2.23 and ensures that Bundler's specifications can be
- # compared and sorted with RubyGems' own specifications.
- #
- # @see #<=>
- # @see Gem::Specification#sort_obj
- #
- # @return [Array] an object you can use to compare and sort this
- # specification against other specifications
- def sort_obj
- [@name, @version, @platform == Gem::Platform::RUBY ? -1 : 1]
- end
-
- def to_s
- "#<#{self.class} name=#{name} version=#{version} platform=#{platform}>"
- end
-
- def dependencies
- @dependencies ||= begin
- deps = method_missing(:dependencies)
-
- # allow us to handle when the specs dependencies are an array of array of string
- # see https://github.com/bundler/bundler/issues/5797
- deps = deps.map {|d| d.is_a?(Gem::Dependency) ? d : Gem::Dependency.new(*d) }
-
- deps
- end
- end
-
- def git_version
- return unless loaded_from && source.is_a?(Bundler::Source::Git)
- " #{source.revision[0..6]}"
- end
-
- private
-
- def to_ary
- nil
- end
-
- def _remote_specification
- @_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform])
- @_remote_specification || raise(GemspecError, "Gemspec data for #{full_name} was" \
- " missing from the server! Try installing with `--full-index` as a workaround.")
- end
-
- def method_missing(method, *args, &blk)
- _remote_specification.send(method, *args, &blk)
- end
-
- def respond_to?(method, include_all = false)
- super || _remote_specification.respond_to?(method, include_all)
- end
- public :respond_to?
- end
-end
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
deleted file mode 100644
index c7caf01c7d..0000000000
--- a/lib/bundler/resolver.rb
+++ /dev/null
@@ -1,421 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Resolver
- require_relative "vendored_molinillo"
- require_relative "resolver/spec_group"
-
- # Figures out the best possible configuration of gems that satisfies
- # the list of passed dependencies and any child dependencies without
- # causing any gem activation errors.
- #
- # ==== Parameters
- # *dependencies<Gem::Dependency>:: The list of dependencies to resolve
- #
- # ==== Returns
- # <GemBundle>,nil:: If the list of dependencies can be resolved, a
- # collection of gemspecs is returned. Otherwise, nil is returned.
- def self.resolve(requirements, index, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
- platforms = Set.new(platforms) if platforms
- base = SpecSet.new(base) unless base.is_a?(SpecSet)
- resolver = new(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
- result = resolver.start(requirements)
- SpecSet.new(result)
- end
-
- def initialize(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
- @index = index
- @source_requirements = source_requirements
- @base = base
- @resolver = Molinillo::Resolver.new(self, self)
- @search_for = {}
- @base_dg = Molinillo::DependencyGraph.new
- @base.each do |ls|
- dep = Dependency.new(ls.name, ls.version)
- @base_dg.add_vertex(ls.name, DepProxy.new(dep, ls.platform), true)
- end
- additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) }
- @platforms = platforms
- @gem_version_promoter = gem_version_promoter
- @allow_bundler_dependency_conflicts = Bundler.feature_flag.allow_bundler_dependency_conflicts?
- @use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
- @lockfile_uses_separate_rubygems_sources = Bundler.feature_flag.disable_multisource?
- end
-
- def start(requirements)
- @gem_version_promoter.prerelease_specified = @prerelease_specified = {}
- requirements.each {|dep| @prerelease_specified[dep.name] ||= dep.prerelease? }
-
- verify_gemfile_dependencies_are_found!(requirements)
- dg = @resolver.resolve(requirements, @base_dg)
- dg.
- tap {|resolved| validate_resolved_specs!(resolved) }.
- map(&:payload).
- reject {|sg| sg.name.end_with?("\0") }.
- map(&:to_specs).
- flatten
- rescue Molinillo::VersionConflict => e
- message = version_conflict_message(e)
- raise VersionConflict.new(e.conflicts.keys.uniq, message)
- rescue Molinillo::CircularDependencyError => e
- names = e.dependencies.sort_by(&:name).map {|d| "gem '#{d.name}'" }
- raise CyclicDependencyError, "Your bundle requires gems that depend" \
- " on each other, creating an infinite loop. Please remove" \
- " #{names.count > 1 ? "either " : ""}#{names.join(" or ")}" \
- " and try again."
- end
-
- include Molinillo::UI
-
- # Conveys debug information to the user.
- #
- # @param [Integer] depth the current depth of the resolution process.
- # @return [void]
- def debug(depth = 0)
- return unless debug?
- debug_info = yield
- debug_info = debug_info.inspect unless debug_info.is_a?(String)
- warn debug_info.split("\n").map {|s| " " * depth + s }
- end
-
- def debug?
- return @debug_mode if defined?(@debug_mode)
- @debug_mode = ENV["DEBUG_RESOLVER"] || ENV["DEBUG_RESOLVER_TREE"] || false
- end
-
- def before_resolution
- Bundler.ui.info "Resolving dependencies...", debug?
- end
-
- def after_resolution
- Bundler.ui.info ""
- end
-
- def indicate_progress
- Bundler.ui.info ".", false unless debug?
- end
-
- include Molinillo::SpecificationProvider
-
- def dependencies_for(specification)
- specification.dependencies_for_activated_platforms
- end
-
- def search_for(dependency)
- platform = dependency.__platform
- dependency = dependency.dep unless dependency.is_a? Gem::Dependency
- search = @search_for[dependency] ||= begin
- index = index_for(dependency)
- results = index.search(dependency, @base[dependency.name])
-
- if vertex = @base_dg.vertex_named(dependency.name)
- locked_requirement = vertex.payload.requirement
- end
-
- if !@prerelease_specified[dependency.name] && (!@use_gvp || locked_requirement.nil?)
- # Move prereleases to the beginning of the list, so they're considered
- # last during resolution.
- pre, results = results.partition {|spec| spec.version.prerelease? }
- results = pre + results
- end
-
- spec_groups = if results.any?
- nested = []
- results.each do |spec|
- version, specs = nested.last
- if version == spec.version
- specs << spec
- else
- nested << [spec.version, [spec]]
- end
- end
- nested.reduce([]) do |groups, (version, specs)|
- next groups if locked_requirement && !locked_requirement.satisfied_by?(version)
- spec_group = SpecGroup.new(specs)
- spec_group.ignores_bundler_dependencies = @allow_bundler_dependency_conflicts
- groups << spec_group
- end
- else
- []
- end
- # GVP handles major itself, but it's still a bit risky to trust it with it
- # until we get it settled with new behavior. For 2.x it can take over all cases.
- if !@use_gvp
- spec_groups
- else
- @gem_version_promoter.sort_versions(dependency, spec_groups)
- end
- end
- search.select {|sg| sg.for?(platform) }.each {|sg| sg.activate_platform!(platform) }
- end
-
- def index_for(dependency)
- source = @source_requirements[dependency.name]
- if source
- source.specs
- elsif @lockfile_uses_separate_rubygems_sources
- Index.build do |idx|
- if dependency.all_sources
- dependency.all_sources.each {|s| idx.add_source(s.specs) if s }
- else
- idx.add_source @source_requirements[:default].specs
- end
- end
- else
- @index
- end
- end
-
- def name_for(dependency)
- dependency.name
- end
-
- def name_for_explicit_dependency_source
- Bundler.default_gemfile.basename.to_s
- rescue StandardError
- "Gemfile"
- end
-
- def name_for_locking_dependency_source
- Bundler.default_lockfile.basename.to_s
- rescue StandardError
- "Gemfile.lock"
- end
-
- def requirement_satisfied_by?(requirement, activated, spec)
- return false unless requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec)
- spec.activate_platform!(requirement.__platform) if !@platforms || @platforms.include?(requirement.__platform)
- true
- end
-
- def relevant_sources_for_vertex(vertex)
- if vertex.root?
- [@source_requirements[vertex.name]]
- elsif @lockfile_uses_separate_rubygems_sources
- vertex.recursive_predecessors.map do |v|
- @source_requirements[v.name]
- end << @source_requirements[:default]
- end
- end
-
- def sort_dependencies(dependencies, activated, conflicts)
- dependencies.sort_by do |dependency|
- dependency.all_sources = relevant_sources_for_vertex(activated.vertex_named(dependency.name))
- name = name_for(dependency)
- vertex = activated.vertex_named(name)
- [
- @base_dg.vertex_named(name) ? 0 : 1,
- vertex.payload ? 0 : 1,
- vertex.root? ? 0 : 1,
- amount_constrained(dependency),
- conflicts[name] ? 0 : 1,
- vertex.payload ? 0 : search_for(dependency).count,
- self.class.platform_sort_key(dependency.__platform),
- ]
- end
- end
-
- # Sort platforms from most general to most specific
- def self.sort_platforms(platforms)
- platforms.sort_by do |platform|
- platform_sort_key(platform)
- end
- end
-
- def self.platform_sort_key(platform)
- return ["", "", ""] if Gem::Platform::RUBY == platform
- platform.to_a.map {|part| part || "" }
- end
-
- private
-
- # returns an integer \in (-\infty, 0]
- # a number closer to 0 means the dependency is less constraining
- #
- # dependencies w/ 0 or 1 possibilities (ignoring version requirements)
- # are given very negative values, so they _always_ sort first,
- # before dependencies that are unconstrained
- def amount_constrained(dependency)
- @amount_constrained ||= {}
- @amount_constrained[dependency.name] ||= begin
- if (base = @base[dependency.name]) && !base.empty?
- dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
- else
- all = index_for(dependency).search(dependency.name).size
-
- if all <= 1
- all - 1_000_000
- else
- search = search_for(dependency)
- search = @prerelease_specified[dependency.name] ? search.count : search.count {|s| !s.version.prerelease? }
- search - all
- end
- end
- end
- end
-
- def verify_gemfile_dependencies_are_found!(requirements)
- requirements.each do |requirement|
- name = requirement.name
- next if name == "bundler"
- next unless search_for(requirement).empty?
-
- cache_message = begin
- " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
- rescue GemfileNotFound
- nil
- end
-
- if (base = @base[name]) && !base.empty?
- version = base.first.version
- message = "You have requested:\n" \
- " #{name} #{requirement.requirement}\n\n" \
- "The bundle currently has #{name} locked at #{version}.\n" \
- "Try running `bundle update #{name}`\n\n" \
- "If you are updating multiple gems in your Gemfile at once,\n" \
- "try passing them all to `bundle update`"
- elsif source = @source_requirements[name]
- specs = source.specs[name]
- versions_with_platforms = specs.map {|s| [s.version, s.platform] }
- message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
- message << if versions_with_platforms.any?
- "The source contains '#{name}' at: #{formatted_versions_with_platforms(versions_with_platforms)}"
- else
- "The source does not contain any versions of '#{name}'"
- end
- else
- message = "Could not find gem '#{requirement}' in any of the gem sources " \
- "listed in your Gemfile#{cache_message}."
- end
- raise GemNotFound, message
- end
- end
-
- def formatted_versions_with_platforms(versions_with_platforms)
- version_platform_strs = versions_with_platforms.map do |vwp|
- version = vwp.first
- platform = vwp.last
- version_platform_str = String.new(version.to_s)
- version_platform_str << " #{platform}" unless platform.nil? || platform == Gem::Platform::RUBY
- version_platform_str
- end
- version_platform_strs.join(", ")
- end
-
- def version_conflict_message(e)
- # only show essential conflicts, if possible
- conflicts = e.conflicts.dup
- conflicts.delete_if do |_name, conflict|
- deps = conflict.requirement_trees.map(&:last).flatten(1)
- !Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
- end
- e = Molinillo::VersionConflict.new(conflicts, e.specification_provider) unless conflicts.empty?
-
- solver_name = "Bundler"
- possibility_type = "gem"
- e.message_with_trees(
- :solver_name => solver_name,
- :possibility_type => possibility_type,
- :reduce_trees => lambda do |trees|
- # called first, because we want to reduce the amount of work required to find maximal empty sets
- trees = trees.uniq {|t| t.flatten.map {|dep| [dep.name, dep.requirement] } }
-
- # bail out if tree size is too big for Array#combination to make any sense
- return trees if trees.size > 15
- maximal = 1.upto(trees.size).map do |size|
- trees.map(&:last).flatten(1).combination(size).to_a
- end.flatten(1).select do |deps|
- Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
- end.min_by(&:size)
-
- trees.reject! {|t| !maximal.include?(t.last) } if maximal
-
- trees.sort_by {|t| t.reverse.map(&:name) }
- end,
- :printable_requirement => lambda {|req| SharedHelpers.pretty_dependency(req) },
- :additional_message_for_conflict => lambda do |o, name, conflict|
- if name == "bundler"
- o << %(\n Current Bundler version:\n bundler (#{Bundler::VERSION}))
- other_bundler_required = !conflict.requirement.requirement.satisfied_by?(Gem::Version.new(Bundler::VERSION))
- end
-
- if name == "bundler" && other_bundler_required
- o << "\n"
- o << "This Gemfile requires a different version of Bundler.\n"
- o << "Perhaps you need to update Bundler by running `gem install bundler`?\n"
- end
- if conflict.locked_requirement
- o << "\n"
- o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
- o << %(the gems in your Gemfile, which may resolve the conflict.\n)
- elsif !conflict.existing
- o << "\n"
-
- relevant_sources = if conflict.requirement.source
- [conflict.requirement.source]
- elsif conflict.requirement.all_sources
- conflict.requirement.all_sources
- elsif @lockfile_uses_separate_rubygems_sources
- # every conflict should have an explicit group of sources when we
- # enforce strict pinning
- raise "no source set for #{conflict}"
- else
- []
- end.compact.map(&:to_s).uniq.sort
-
- metadata_requirement = name.end_with?("\0")
-
- o << "Could not find gem '" unless metadata_requirement
- o << SharedHelpers.pretty_dependency(conflict.requirement)
- o << "'" unless metadata_requirement
- if conflict.requirement_trees.first.size > 1
- o << ", which is required by "
- o << "gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
- end
- o << " "
-
- o << if relevant_sources.empty?
- "in any of the sources.\n"
- elsif metadata_requirement
- "is not available in #{relevant_sources.join(" or ")}"
- else
- "in any of the relevant sources:\n #{relevant_sources * "\n "}\n"
- end
- end
- end,
- :version_for_spec => lambda {|spec| spec.version },
- :incompatible_version_message_for_conflict => lambda do |name, _conflict|
- if name.end_with?("\0")
- %(#{solver_name} found conflicting requirements for the #{name} version:)
- else
- %(#{solver_name} could not find compatible versions for #{possibility_type} "#{name}":)
- end
- end
- )
- end
-
- def validate_resolved_specs!(resolved_specs)
- resolved_specs.each do |v|
- name = v.name
- next unless sources = relevant_sources_for_vertex(v)
- sources.compact!
- if default_index = sources.index(@source_requirements[:default])
- sources.delete_at(default_index)
- end
- sources.reject! {|s| s.specs[name].empty? }
- sources.uniq!
- next if sources.size <= 1
-
- multisource_disabled = Bundler.feature_flag.disable_multisource?
-
- msg = ["The gem '#{name}' was found in multiple relevant sources."]
- msg.concat sources.map {|s| " * #{s}" }.sort
- msg << "You #{multisource_disabled ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
- msg = msg.join("\n")
-
- raise SecurityError, msg if multisource_disabled
- Bundler.ui.warn "Warning: #{msg}"
- end
- end
- end
-end
diff --git a/lib/bundler/resolver/spec_group.rb b/lib/bundler/resolver/spec_group.rb
deleted file mode 100644
index e5772eed81..0000000000
--- a/lib/bundler/resolver/spec_group.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Resolver
- class SpecGroup
- include GemHelpers
-
- attr_accessor :name, :version, :source
- attr_accessor :ignores_bundler_dependencies
-
- def initialize(all_specs)
- raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
- @name = exemplary_spec.name
- @version = exemplary_spec.version
- @source = exemplary_spec.source
-
- @activated_platforms = []
- @dependencies = nil
- @specs = Hash.new do |specs, platform|
- specs[platform] = select_best_platform_match(all_specs, platform)
- end
- @ignores_bundler_dependencies = true
- end
-
- def to_specs
- @activated_platforms.map do |p|
- next unless s = @specs[p]
- lazy_spec = LazySpecification.new(name, version, s.platform, source)
- lazy_spec.dependencies.replace s.dependencies
- lazy_spec
- end.compact
- end
-
- def activate_platform!(platform)
- return unless for?(platform)
- return if @activated_platforms.include?(platform)
- @activated_platforms << platform
- end
-
- def for?(platform)
- spec = @specs[platform]
- !spec.nil?
- end
-
- def to_s
- @to_s ||= "#{name} (#{version})"
- end
-
- def dependencies_for_activated_platforms
- dependencies = @activated_platforms.map {|p| __dependencies[p] }
- metadata_dependencies = @activated_platforms.map do |platform|
- metadata_dependencies(@specs[platform], platform)
- end
- dependencies.concat(metadata_dependencies).flatten
- end
-
- def ==(other)
- return unless other.is_a?(SpecGroup)
- name == other.name &&
- version == other.version &&
- source == other.source
- end
-
- def eql?(other)
- return unless other.is_a?(SpecGroup)
- name.eql?(other.name) &&
- version.eql?(other.version) &&
- source.eql?(other.source)
- end
-
- def hash
- to_s.hash ^ source.hash
- end
-
- private
-
- def __dependencies
- @dependencies = Hash.new do |dependencies, platform|
- dependencies[platform] = []
- if spec = @specs[platform]
- spec.dependencies.each do |dep|
- next if dep.type == :development
- next if @ignores_bundler_dependencies && dep.name == "bundler".freeze
- dependencies[platform] << DepProxy.new(dep, platform)
- end
- end
- dependencies[platform]
- end
- end
-
- def metadata_dependencies(spec, platform)
- return [] unless spec
- # Only allow endpoint specifications since they won't hit the network to
- # fetch the full gemspec when calling required_ruby_version
- return [] if !spec.is_a?(EndpointSpecification) && !spec.is_a?(Gem::Specification)
- dependencies = []
- if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
- dependencies << DepProxy.new(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
- end
- if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
- dependencies << DepProxy.new(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
- end
- dependencies
- end
- end
- end
-end
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
deleted file mode 100644
index d64958ba70..0000000000
--- a/lib/bundler/retry.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # General purpose class for retrying code that may fail
- class Retry
- attr_accessor :name, :total_runs, :current_run
-
- class << self
- def default_attempts
- default_retries + 1
- end
- alias_method :attempts, :default_attempts
-
- def default_retries
- Bundler.settings[:retry]
- end
- end
-
- def initialize(name, exceptions = nil, retries = self.class.default_retries)
- @name = name
- @retries = retries
- @exceptions = Array(exceptions) || []
- @total_runs = @retries + 1 # will run once, then upto attempts.times
- end
-
- def attempt(&block)
- @current_run = 0
- @failed = false
- @error = nil
- run(&block) while keep_trying?
- @result
- end
- alias_method :attempts, :attempt
-
- private
-
- def run(&block)
- @failed = false
- @current_run += 1
- @result = block.call
- rescue StandardError => e
- fail_attempt(e)
- end
-
- def fail_attempt(e)
- @failed = true
- if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
- Bundler.ui.info "" unless Bundler.ui.debug?
- raise e
- end
- return true unless name
- Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this
- Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
- end
-
- def keep_trying?
- return true if current_run.zero?
- return false if last_attempt?
- return true if @failed
- end
-
- def last_attempt?
- current_run >= total_runs
- end
- end
-end
diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb
deleted file mode 100644
index f6ba220cd5..0000000000
--- a/lib/bundler/ruby_dsl.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module RubyDsl
- def ruby(*ruby_version)
- options = ruby_version.last.is_a?(Hash) ? ruby_version.pop : {}
- ruby_version.flatten!
- raise GemfileError, "Please define :engine_version" if options[:engine] && options[:engine_version].nil?
- raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
-
- if options[:engine] == "ruby" && options[:engine_version] &&
- ruby_version != Array(options[:engine_version])
- raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
- end
- @ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
- end
- end
-end
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
deleted file mode 100644
index 7e403ce6fc..0000000000
--- a/lib/bundler/ruby_version.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class RubyVersion
- attr_reader :versions,
- :patchlevel,
- :engine,
- :engine_versions,
- :gem_version,
- :engine_gem_version
-
- def initialize(versions, patchlevel, engine, engine_version)
- # The parameters to this method must satisfy the
- # following constraints, which are verified in
- # the DSL:
- #
- # * If an engine is specified, an engine version
- # must also be specified
- # * If an engine version is specified, an engine
- # must also be specified
- # * If the engine is "ruby", the engine version
- # must not be specified, or the engine version
- # specified must match the version.
-
- @versions = Array(versions).map do |v|
- op, v = Gem::Requirement.parse(v)
- op == "=" ? v.to_s : "#{op} #{v}"
- end
-
- @gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
- @input_engine = engine && engine.to_s
- @engine = engine && engine.to_s || "ruby"
- @engine_versions = (engine_version && Array(engine_version)) || @versions
- @engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last
- @patchlevel = patchlevel
- end
-
- def to_s(versions = self.versions)
- output = String.new("ruby #{versions_string(versions)}")
- output << "p#{patchlevel}" if patchlevel
- output << " (#{engine} #{versions_string(engine_versions)})" unless engine == "ruby"
-
- output
- end
-
- # @private
- PATTERN = /
- ruby\s
- ([\d.]+) # ruby version
- (?:p(-?\d+))? # optional patchlevel
- (?:\s\((\S+)\s(.+)\))? # optional engine info
- /xo.freeze
-
- # Returns a RubyVersion from the given string.
- # @param [String] the version string to match.
- # @return [RubyVersion,Nil] The version if the string is a valid RubyVersion
- # description, and nil otherwise.
- def self.from_string(string)
- new($1, $2, $3, $4) if string =~ PATTERN
- end
-
- def single_version_string
- to_s(gem_version)
- end
-
- def ==(other)
- versions == other.versions &&
- engine == other.engine &&
- engine_versions == other.engine_versions &&
- patchlevel == other.patchlevel
- end
-
- def host
- @host ||= [
- RbConfig::CONFIG["host_cpu"],
- RbConfig::CONFIG["host_vendor"],
- RbConfig::CONFIG["host_os"],
- ].join("-")
- end
-
- # Returns a tuple of these things:
- # [diff, this, other]
- # The priority of attributes are
- # 1. engine
- # 2. ruby_version
- # 3. engine_version
- def diff(other)
- raise ArgumentError, "Can only diff with a RubyVersion, not a #{other.class}" unless other.is_a?(RubyVersion)
- if engine != other.engine && @input_engine
- [:engine, engine, other.engine]
- elsif versions.empty? || !matches?(versions, other.gem_version)
- [:version, versions_string(versions), versions_string(other.versions)]
- elsif @input_engine && !matches?(engine_versions, other.engine_gem_version)
- [:engine_version, versions_string(engine_versions), versions_string(other.engine_versions)]
- elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))
- [:patchlevel, patchlevel, other.patchlevel]
- end
- end
-
- def versions_string(versions)
- Array(versions).join(", ")
- end
-
- def self.system
- ruby_engine = RUBY_ENGINE.dup
- ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
- ruby_engine_version = RUBY_ENGINE_VERSION.dup
- patchlevel = RUBY_PATCHLEVEL.to_s
-
- @ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
- end
-
- def to_gem_version_with_patchlevel
- @gem_version_with_patch ||= begin
- Gem::Version.create("#{@gem_version}.#{@patchlevel}")
- rescue ArgumentError
- @gem_version
- end
- end
-
- def exact?
- return @exact if defined?(@exact)
- @exact = versions.all? {|v| Gem::Requirement.create(v).exact? }
- end
-
- private
-
- def matches?(requirements, version)
- # Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
- return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"
-
- Array(requirements).all? do |requirement|
- Gem::Requirement.create(requirement).satisfied_by?(Gem::Version.create(version))
- end
- end
- end
-end
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
deleted file mode 100644
index eda826422f..0000000000
--- a/lib/bundler/rubygems_ext.rb
+++ /dev/null
@@ -1,154 +0,0 @@
-# frozen_string_literal: true
-
-require "pathname"
-
-require "rubygems/specification"
-
-# Possible use in Gem::Specification#source below and require
-# shouldn't be deferred.
-require "rubygems/source"
-
-require_relative "match_platform"
-
-module Gem
- class Specification
- attr_accessor :remote, :location, :relative_loaded_from
-
- remove_method :source
- attr_writer :source
- def source
- (defined?(@source) && @source) || Gem::Source::Installed.new
- end
-
- alias_method :rg_full_gem_path, :full_gem_path
- alias_method :rg_loaded_from, :loaded_from
-
- def full_gem_path
- # this cannot check source.is_a?(Bundler::Plugin::API::Source)
- # because that _could_ trip the autoload, and if there are unresolved
- # gems at that time, this method could be called inside another require,
- # thus raising with that constant being undefined. Better to check a method
- if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?)
- Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
- else
- rg_full_gem_path
- end
- end
-
- def loaded_from
- if relative_loaded_from
- source.path.join(relative_loaded_from).to_s
- else
- rg_loaded_from
- end
- end
-
- def load_paths
- full_require_paths
- end
-
- if method_defined?(:extension_dir)
- alias_method :rg_extension_dir, :extension_dir
- def extension_dir
- @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
- File.expand_path(File.join(extensions_dir, source.extension_dir_name))
- else
- rg_extension_dir
- end
- end
- end
-
- remove_method :gem_dir if instance_methods(false).include?(:gem_dir)
- def gem_dir
- full_gem_path
- end
-
- def groups
- @groups ||= []
- end
-
- def git_version
- return unless loaded_from && source.is_a?(Bundler::Source::Git)
- " #{source.revision[0..6]}"
- end
-
- def to_gemfile(path = nil)
- gemfile = String.new("source 'https://rubygems.org'\n")
- gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
- unless development_dependencies.empty?
- gemfile << "\n"
- gemfile << dependencies_to_gemfile(development_dependencies, :development)
- end
- gemfile
- end
-
- def nondevelopment_dependencies
- dependencies - development_dependencies
- end
-
- private
-
- def dependencies_to_gemfile(dependencies, group = nil)
- gemfile = String.new
- if dependencies.any?
- gemfile << "group :#{group} do\n" if group
- dependencies.each do |dependency|
- gemfile << " " if group
- gemfile << %(gem "#{dependency.name}")
- req = dependency.requirements_list.first
- gemfile << %(, "#{req}") if req
- gemfile << "\n"
- end
- gemfile << "end\n" if group
- end
- gemfile
- end
- end
-
- class Dependency
- attr_accessor :source, :groups, :all_sources
-
- alias_method :eql?, :==
-
- def encode_with(coder)
- to_yaml_properties.each do |ivar|
- coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
- end
- end
-
- def to_yaml_properties
- instance_variables.reject {|p| ["@source", "@groups", "@all_sources"].include?(p.to_s) }
- end
-
- def to_lock
- out = String.new(" #{name}")
- unless requirement.none?
- reqs = requirement.requirements.map {|o, v| "#{o} #{v}" }.sort.reverse
- out << " (#{reqs.join(", ")})"
- end
- out
- end
- end
-
- class Platform
- JAVA = Gem::Platform.new("java") unless defined?(JAVA)
- MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
- MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64)
- MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW)
- X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW)
-
- undef_method :hash if method_defined? :hash
- def hash
- @cpu.hash ^ @os.hash ^ @version.hash
- end
-
- undef_method :eql? if method_defined? :eql?
- alias_method :eql?, :==
- end
-end
-
-module Gem
- class Specification
- include ::Bundler::MatchPlatform
- end
-end
diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb
deleted file mode 100644
index b1076b4554..0000000000
--- a/lib/bundler/rubygems_gem_installer.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems/installer"
-
-module Bundler
- class RubyGemsGemInstaller < Gem::Installer
- unless respond_to?(:at)
- def self.at(*args)
- new(*args)
- end
- end
-
- def check_executable_overwrite(filename)
- # Bundler needs to install gems regardless of binstub overwriting
- end
-
- def pre_install_checks
- super && validate_bundler_checksum(options[:bundler_expected_checksum])
- end
-
- def build_extensions
- extension_cache_path = options[:bundler_extension_cache_path]
- return super unless extension_cache_path && extension_dir = Bundler.rubygems.spec_extension_dir(spec)
-
- extension_dir = Pathname.new(extension_dir)
- build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
- if build_complete && !options[:force]
- SharedHelpers.filesystem_access(extension_dir.parent, &:mkpath)
- SharedHelpers.filesystem_access(extension_cache_path) do
- FileUtils.cp_r extension_cache_path, spec.extension_dir
- end
- else
- super
- if extension_dir.directory? # not made for gems without extensions
- SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
- SharedHelpers.filesystem_access(extension_cache_path) do
- FileUtils.cp_r extension_dir, extension_cache_path
- end
- end
- end
- end
-
- private
-
- def validate_bundler_checksum(checksum)
- return true if Bundler.settings[:disable_checksum_validation]
- return true unless checksum
- return true unless source = @package.instance_variable_get(:@gem)
- return true unless source.respond_to?(:with_read_io)
- digest = source.with_read_io do |io|
- digest = SharedHelpers.digest(:SHA256).new
- digest << io.read(16_384) until io.eof?
- io.rewind
- send(checksum_type(checksum), digest)
- end
- unless digest == checksum
- raise SecurityError, <<-MESSAGE
- Bundler cannot continue installing #{spec.name} (#{spec.version}).
- The checksum for the downloaded `#{spec.full_name}.gem` does not match \
- the checksum given by the server. This means the contents of the downloaded \
- gem is different from what was uploaded to the server, and could be a potential security issue.
-
- To resolve this issue:
- 1. delete the downloaded gem located at: `#{spec.gem_dir}/#{spec.full_name}.gem`
- 2. run `bundle install`
-
- If you wish to continue installing the downloaded gem, and are certain it does not pose a \
- security issue despite the mismatching checksum, do the following:
- 1. run `bundle config set disable_checksum_validation true` to turn off checksum verification
- 2. run `bundle install`
-
- (More info: The expected SHA256 checksum was #{checksum.inspect}, but the \
- checksum for the downloaded gem was #{digest.inspect}.)
- MESSAGE
- end
- true
- end
-
- def checksum_type(checksum)
- case checksum.length
- when 64 then :hexdigest!
- when 44 then :base64digest!
- else raise InstallError, "The given checksum for #{spec.full_name} (#{checksum.inspect}) is not a valid SHA256 hexdigest nor base64digest"
- end
- end
-
- def hexdigest!(digest)
- digest.hexdigest!
- end
-
- def base64digest!(digest)
- if digest.respond_to?(:base64digest!)
- digest.base64digest!
- else
- [digest.digest!].pack("m0")
- end
- end
- end
-end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
deleted file mode 100644
index d97621cd92..0000000000
--- a/lib/bundler/rubygems_integration.rb
+++ /dev/null
@@ -1,648 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems" unless defined?(Gem)
-
-module Bundler
- class RubygemsIntegration
- if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
- EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
- else
- require "monitor"
-
- EXT_LOCK = Monitor.new
- end
-
- def self.version
- @version ||= Gem::Version.new(Gem::VERSION)
- end
-
- def self.provides?(req_str)
- Gem::Requirement.new(req_str).satisfied_by?(version)
- end
-
- def initialize
- @replaced_methods = {}
- backport_ext_builder_monitor
- end
-
- def version
- self.class.version
- end
-
- def provides?(req_str)
- self.class.provides?(req_str)
- end
-
- def build_args
- Gem::Command.build_args
- end
-
- def build_args=(args)
- Gem::Command.build_args = args
- end
-
- def loaded_specs(name)
- Gem.loaded_specs[name]
- end
-
- def add_to_load_path(paths)
- return Gem.add_to_load_path(*paths) if Gem.respond_to?(:add_to_load_path)
-
- if insert_index = Gem.load_path_insert_index
- # Gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(insert_index, *paths)
- else
- # We are probably testing in core, -I and RUBYLIB don't apply
- $LOAD_PATH.unshift(*paths)
- end
- end
-
- def mark_loaded(spec)
- if spec.respond_to?(:activated=)
- current = Gem.loaded_specs[spec.name]
- current.activated = false if current
- spec.activated = true
- end
- Gem.loaded_specs[spec.name] = spec
- end
-
- def validate(spec)
- Bundler.ui.silence { spec.validate(false) }
- rescue Gem::InvalidSpecificationException => e
- error_message = "The gemspec at #{spec.loaded_from} is not valid. Please fix this gemspec.\n" \
- "The validation error was '#{e.message}'\n"
- raise Gem::InvalidSpecificationException.new(error_message)
- rescue Errno::ENOENT
- nil
- end
-
- def set_installed_by_version(spec, installed_by_version = Gem::VERSION)
- return unless spec.respond_to?(:installed_by_version=)
- spec.installed_by_version = Gem::Version.create(installed_by_version)
- end
-
- def spec_missing_extensions?(spec, default = true)
- return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
-
- return false if spec_default_gem?(spec)
- return false if spec.extensions.empty?
-
- default
- end
-
- def spec_default_gem?(spec)
- spec.respond_to?(:default_gem?) && spec.default_gem?
- end
-
- def spec_matches_for_glob(spec, glob)
- return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
-
- spec.load_paths.map do |lp|
- Dir["#{lp}/#{glob}#{suffix_pattern}"]
- end.flatten(1)
- end
-
- def spec_extension_dir(spec)
- return unless spec.respond_to?(:extension_dir)
- spec.extension_dir
- end
-
- def stub_set_spec(stub, spec)
- stub.instance_variable_set(:@spec, spec)
- end
-
- def path(obj)
- obj.to_s
- end
-
- def platforms
- return [Gem::Platform::RUBY] if Bundler.settings[:force_ruby_platform]
- Gem.platforms
- end
-
- def configuration
- require_relative "psyched_yaml"
- Gem.configuration
- rescue Gem::SystemExitException, LoadError => e
- Bundler.ui.error "#{e.class}: #{e.message}"
- Bundler.ui.trace e
- raise
- rescue YamlLibrarySyntaxError => e
- raise YamlSyntaxError.new(e, "Your RubyGems configuration, which is " \
- "usually located in ~/.gemrc, contains invalid YAML syntax.")
- end
-
- def ruby_engine
- Gem.ruby_engine
- end
-
- def read_binary(path)
- Gem.read_binary(path)
- end
-
- def inflate(obj)
- require "rubygems/util"
-
- Gem::Util.inflate(obj)
- end
-
- def correct_for_windows_path(path)
- require "rubygems/util"
-
- if Gem::Util.respond_to?(:correct_for_windows_path)
- Gem::Util.correct_for_windows_path(path)
- elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
- path[1..-1]
- else
- path
- end
- end
-
- def sources=(val)
- # Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
- # If that file exists, its settings (including sources) will overwrite the values we
- # are about to set here. In order to avoid that, we force memoizing the config file now.
- configuration
-
- Gem.sources = val
- end
-
- def sources
- Gem.sources
- end
-
- def gem_dir
- Gem.dir
- end
-
- def gem_bindir
- Gem.bindir
- end
-
- def user_home
- Gem.user_home
- end
-
- def gem_path
- Gem.path
- end
-
- def reset
- Gem::Specification.reset
- end
-
- def post_reset_hooks
- Gem.post_reset_hooks
- end
-
- def suffix_pattern
- Gem.suffix_pattern
- end
-
- def gem_cache
- gem_path.map {|p| File.expand_path("cache", p) }
- end
-
- def spec_cache_dirs
- @spec_cache_dirs ||= begin
- dirs = gem_path.map {|dir| File.join(dir, "specifications") }
- dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier
- dirs.uniq.select {|dir| File.directory? dir }
- end
- end
-
- def marshal_spec_dir
- Gem::MARSHAL_SPEC_DIR
- end
-
- def clear_paths
- Gem.clear_paths
- end
-
- def bin_path(gem, bin, ver)
- Gem.bin_path(gem, bin, ver)
- end
-
- def preserve_paths
- # this is a no-op outside of RubyGems 1.8
- yield
- end
-
- def loaded_gem_paths
- loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
- loaded_gem_paths.flatten
- end
-
- def load_plugins
- Gem.load_plugins if Gem.respond_to?(:load_plugins)
- end
-
- def load_plugin_files(files)
- Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
- end
-
- def ui=(obj)
- Gem::DefaultUserInteraction.ui = obj
- end
-
- def ext_lock
- EXT_LOCK
- end
-
- def with_build_args(args)
- ext_lock.synchronize do
- old_args = build_args
- begin
- self.build_args = args
- yield
- ensure
- self.build_args = old_args
- end
- end
- end
-
- def spec_from_gem(path, policy = nil)
- require "rubygems/security"
- require_relative "psyched_yaml"
- gem_from_path(path, security_policies[policy]).spec
- rescue Gem::Package::FormatError
- raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
- rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
- if e.is_a?(Gem::Security::Exception) ||
- e.message =~ /unknown trust policy|unsigned gem/i ||
- e.message =~ /couldn't verify (meta)?data signature/i
- raise SecurityError,
- "The gem #{File.basename(path, ".gem")} can't be installed because " \
- "the security policy didn't allow it, with the message: #{e.message}"
- else
- raise e
- end
- end
-
- def build_gem(gem_dir, spec)
- build(spec)
- end
-
- def security_policy_keys
- %w[High Medium Low AlmostNo No].map {|level| "#{level}Security" }
- end
-
- def security_policies
- @security_policies ||= begin
- require "rubygems/security"
- Gem::Security::Policies
- rescue LoadError, NameError
- {}
- end
- end
-
- def reverse_rubygems_kernel_mixin
- # Disable rubygems' gem activation system
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |k|
- if k.private_method_defined?(:gem_original_require)
- redefine_method(k, :require, k.instance_method(:gem_original_require))
- end
- end
- end
-
- def replace_gem(specs, specs_by_name)
- reverse_rubygems_kernel_mixin
-
- executables = nil
-
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |kernel_class|
- redefine_method(kernel_class, :gem) do |dep, *reqs|
- if executables && executables.include?(File.basename(caller.first.split(":").first))
- break
- end
-
- reqs.pop if reqs.last.is_a?(Hash)
-
- unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
- dep = Gem::Dependency.new(dep, reqs)
- end
-
- if spec = specs_by_name[dep.name]
- return true if dep.matches_spec?(spec)
- end
-
- message = if spec.nil?
- "#{dep.name} is not part of the bundle." \
- " Add it to your #{Bundler.default_gemfile.basename}."
- else
- "can't activate #{dep}, already activated #{spec.full_name}. " \
- "Make sure all dependencies are added to Gemfile."
- end
-
- e = Gem::LoadError.new(message)
- e.name = dep.name
- if e.respond_to?(:requirement=)
- e.requirement = dep.requirement
- elsif e.respond_to?(:version_requirement=)
- e.version_requirement = dep.requirement
- end
- raise e
- end
-
- # backwards compatibility shim, see https://github.com/bundler/bundler/issues/5102
- kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public?
- end
- end
-
- # Used to make bin stubs that are not created by bundler work
- # under bundler. The new Gem.bin_path only considers gems in
- # +specs+
- def replace_bin_path(specs_by_name)
- gem_class = (class << Gem; self; end)
-
- redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
- exec_name = args.first
- raise ArgumentError, "you must supply exec_name" unless exec_name
-
- spec_with_name = specs_by_name[gem_name]
- matching_specs_by_exec_name = specs_by_name.values.select {|s| s.executables.include?(exec_name) }
- spec = matching_specs_by_exec_name.delete(spec_with_name)
-
- unless spec || !matching_specs_by_exec_name.empty?
- message = "can't find executable #{exec_name} for gem #{gem_name}"
- if spec_with_name.nil?
- message += ". #{gem_name} is not currently included in the bundle, " \
- "perhaps you meant to add it to your #{Bundler.default_gemfile.basename}?"
- end
- raise Gem::Exception, message
- end
-
- unless spec
- spec = matching_specs_by_exec_name.shift
- warn \
- "Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \
- "You should run `bundle binstub #{gem_name}` " \
- "to work around a system/bundle conflict."
- end
-
- unless matching_specs_by_exec_name.empty?
- conflicting_names = matching_specs_by_exec_name.map(&:name).join(", ")
- warn \
- "The `#{exec_name}` executable in the `#{spec.name}` gem is being loaded, but it's also present in other gems (#{conflicting_names}).\n" \
- "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
- "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
- end
-
- spec
- end
-
- redefine_method(gem_class, :activate_bin_path) do |name, *args|
- exec_name = args.first
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
-
- # Copy of Rubygems activate_bin_path impl
- requirement = args.last
- spec = find_spec_for_exe name, exec_name, [requirement]
-
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
- end
-
- redefine_method(gem_class, :bin_path) do |name, *args|
- exec_name = args.first
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
-
- spec = find_spec_for_exe(name, *args)
- exec_name ||= spec.default_executable
-
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
- end
- end
-
- # Replace or hook into RubyGems to provide a bundlerized view
- # of the world.
- def replace_entrypoints(specs)
- specs_by_name = specs.reduce({}) do |h, s|
- h[s.name] = s
- h
- end
-
- Bundler.rubygems.default_stubs.each do |stub|
- default_spec = stub.to_spec
- default_spec_name = default_spec.name
- next if specs_by_name.key?(default_spec_name)
-
- specs << default_spec
- specs_by_name[default_spec_name] = default_spec
- end
-
- replace_gem(specs, specs_by_name)
- stub_rubygems(specs)
- replace_bin_path(specs_by_name)
-
- Gem.clear_paths
- end
-
- # This backports base_dir which replaces installation path
- # RubyGems 1.8+
- def backport_base_dir
- redefine_method(Gem::Specification, :base_dir) do
- return Gem.dir unless loaded_from
- File.dirname File.dirname loaded_from
- end
- end
-
- def backport_cache_file
- redefine_method(Gem::Specification, :cache_dir) do
- @cache_dir ||= File.join base_dir, "cache"
- end
-
- redefine_method(Gem::Specification, :cache_file) do
- @cache_file ||= File.join cache_dir, "#{full_name}.gem"
- end
- end
-
- def backport_spec_file
- redefine_method(Gem::Specification, :spec_dir) do
- @spec_dir ||= File.join base_dir, "specifications"
- end
-
- redefine_method(Gem::Specification, :spec_file) do
- @spec_file ||= File.join spec_dir, "#{full_name}.gemspec"
- end
- end
-
- def undo_replacements
- @replaced_methods.each do |(sym, klass), method|
- redefine_method(klass, sym, method)
- end
- if Binding.public_method_defined?(:source_location)
- post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
- else
- post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
- end
- @replaced_methods.clear
- end
-
- def redefine_method(klass, method, unbound_method = nil, &block)
- visibility = method_visibility(klass, method)
- begin
- if (instance_method = klass.instance_method(method)) && method != :initialize
- # doing this to ensure we also get private methods
- klass.send(:remove_method, method)
- end
- rescue NameError
- # method isn't defined
- nil
- end
- @replaced_methods[[method, klass]] = instance_method
- if unbound_method
- klass.send(:define_method, method, unbound_method)
- klass.send(visibility, method)
- elsif block
- klass.send(:define_method, method, &block)
- klass.send(visibility, method)
- end
- end
-
- def method_visibility(klass, method)
- if klass.private_method_defined?(method)
- :private
- elsif klass.protected_method_defined?(method)
- :protected
- else
- :public
- end
- end
-
- def stub_rubygems(specs)
- Gem::Specification.all = specs
-
- Gem.post_reset do
- Gem::Specification.all = specs
- end
-
- redefine_method((class << Gem; self; end), :finish_resolve) do |*|
- []
- end
- end
-
- def plain_specs
- Gem::Specification._all
- end
-
- def plain_specs=(specs)
- Gem::Specification.all = specs
- end
-
- def fetch_specs(remote, name)
- path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
- string = fetcher.fetch_path(path)
- Bundler.load_marshal(string)
- rescue Gem::RemoteFetcher::FetchError => e
- # it's okay for prerelease to fail
- raise e unless name == "prerelease_specs"
- end
-
- def fetch_all_remote_specs(remote)
- specs = fetch_specs(remote, "specs")
- pres = fetch_specs(remote, "prerelease_specs") || []
-
- specs.concat(pres)
- end
-
- def download_gem(spec, uri, path)
- uri = Bundler.settings.mirror_for(uri)
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
- Bundler::Retry.new("download gem from #{uri}").attempts do
- fetcher.download(spec, uri, path)
- end
- end
-
- def gem_remote_fetcher
- require "resolv"
- proxy = configuration[:http_proxy]
- dns = Resolv::DNS.new
- Gem::RemoteFetcher.new(proxy, dns)
- end
-
- def gem_from_path(path, policy = nil)
- require "rubygems/package"
- p = Gem::Package.new(path)
- p.security_policy = policy if policy
- p
- end
-
- def build(spec, skip_validation = false)
- require "rubygems/package"
- Gem::Package.build(spec, skip_validation)
- end
-
- def repository_subdirectories
- Gem::REPOSITORY_SUBDIRECTORIES
- end
-
- def install_with_build_args(args)
- yield
- end
-
- def path_separator
- Gem.path_separator
- end
-
- def all_specs
- require_relative "remote_specification"
- Gem::Specification.stubs.map do |stub|
- StubSpecification.from_stub(stub)
- end
- end
-
- def backport_ext_builder_monitor
- # So we can avoid requiring "rubygems/ext" in its entirety
- Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
- module Ext
- end
- RB
-
- require "rubygems/ext/builder"
-
- Gem::Ext::Builder.class_eval do
- unless const_defined?(:CHDIR_MONITOR)
- const_set(:CHDIR_MONITOR, EXT_LOCK)
- end
-
- remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
- const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
- end
- end
-
- def find_name(name)
- Gem::Specification.stubs_for(name).map(&:to_spec)
- end
-
- if Gem::Specification.respond_to?(:default_stubs)
- def default_stubs
- Gem::Specification.default_stubs("*.gemspec")
- end
- else
- def default_stubs
- Gem::Specification.send(:default_stubs, "*.gemspec")
- end
- end
-
- def use_gemdeps(gemfile)
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
- require_relative "gemdeps"
- runtime = Bundler.setup
- activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
- [Gemdeps.new(runtime), activated_spec_names]
- end
- end
-
- def self.rubygems
- @rubygems ||= RubygemsIntegration.new
- end
-end
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
deleted file mode 100644
index 93a801eb6c..0000000000
--- a/lib/bundler/runtime.rb
+++ /dev/null
@@ -1,315 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Runtime
- include SharedHelpers
-
- def initialize(root, definition)
- @root = root
- @definition = definition
- end
-
- def setup(*groups)
- @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
-
- groups.map!(&:to_sym)
-
- # Has to happen first
- clean_load_path
-
- specs = groups.any? ? @definition.specs_for(groups) : requested_specs
-
- SharedHelpers.set_bundle_environment
- Bundler.rubygems.replace_entrypoints(specs)
-
- # Activate the specs
- load_paths = specs.map do |spec|
- unless spec.loaded_from
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
- end
-
- check_for_activated_spec!(spec)
-
- Bundler.rubygems.mark_loaded(spec)
- spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
- end.reverse.flatten
-
- Bundler.rubygems.add_to_load_path(load_paths)
-
- setup_manpath
-
- lock(:preserve_unknown_sections => true)
-
- self
- end
-
- REQUIRE_ERRORS = [
- /^no such file to load -- (.+)$/i,
- /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
- /^Missing API definition file in (.+)$/i,
- /^cannot load such file -- (.+)$/i,
- /^dlopen\([^)]*\): Library not loaded: (.+)$/i,
- ].freeze
-
- def require(*groups)
- groups.map!(&:to_sym)
- groups = [:default] if groups.empty?
-
- @definition.dependencies.each do |dep|
- # Skip the dependency if it is not in any of the requested groups, or
- # not for the current platform, or doesn't match the gem constraints.
- next unless (dep.groups & groups).any? && dep.should_include?
-
- required_file = nil
-
- begin
- # Loop through all the specified autorequires for the
- # dependency. If there are none, use the dependency's name
- # as the autorequire.
- Array(dep.autorequire || dep.name).each do |file|
- # Allow `require: true` as an alias for `require: <name>`
- file = dep.name if file == true
- required_file = file
- begin
- Kernel.require file
- rescue RuntimeError => e
- raise e if e.is_a?(LoadError) # we handle this a little later
- raise Bundler::GemRequireError.new e,
- "There was an error while trying to load the gem '#{file}'."
- end
- end
- rescue LoadError => e
- REQUIRE_ERRORS.find {|r| r =~ e.message }
- raise if dep.autorequire || $1 != required_file
-
- if dep.autorequire.nil? && dep.name.include?("-")
- begin
- namespaced_file = dep.name.tr("-", "/")
- Kernel.require namespaced_file
- rescue LoadError => e
- REQUIRE_ERRORS.find {|r| r =~ e.message }
- raise if $1 != namespaced_file
- end
- end
- end
- end
- end
-
- def self.definition_method(meth)
- define_method(meth) do
- raise ArgumentError, "no definition when calling Runtime##{meth}" unless @definition
- @definition.send(meth)
- end
- end
- private_class_method :definition_method
-
- definition_method :requested_specs
- definition_method :specs
- definition_method :dependencies
- definition_method :current_dependencies
- definition_method :requires
-
- def lock(opts = {})
- return if @definition.nothing_changed? && !@definition.unlocking?
- @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
- end
-
- alias_method :gems, :specs
-
- def cache(custom_path = nil)
- cache_path = Bundler.app_cache(custom_path)
- SharedHelpers.filesystem_access(cache_path) do |p|
- FileUtils.mkdir_p(p)
- end unless File.exist?(cache_path)
-
- Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
-
- specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
- specs_to_cache.each do |spec|
- next if spec.name == "bundler"
- next if spec.source.is_a?(Source::Gemspec)
- spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
- spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
- end
-
- Dir[cache_path.join("*/.git")].each do |git_dir|
- FileUtils.rm_rf(git_dir)
- FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
- end
-
- prune_cache(cache_path) unless Bundler.settings[:no_prune]
- end
-
- def prune_cache(cache_path)
- SharedHelpers.filesystem_access(cache_path) do |p|
- FileUtils.mkdir_p(p)
- end unless File.exist?(cache_path)
- resolve = @definition.resolve
- prune_gem_cache(resolve, cache_path)
- prune_git_and_path_cache(resolve, cache_path)
- end
-
- def clean(dry_run = false)
- gem_bins = Dir["#{Gem.dir}/bin/*"]
- git_dirs = Dir["#{Gem.dir}/bundler/gems/*"]
- git_cache_dirs = Dir["#{Gem.dir}/cache/bundler/git/*"]
- gem_dirs = Dir["#{Gem.dir}/gems/*"]
- gem_files = Dir["#{Gem.dir}/cache/*.gem"]
- gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
- extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"] + Dir["#{Gem.dir}/bundler/gems/extensions/*/*/*"]
- spec_gem_paths = []
- # need to keep git sources around
- spec_git_paths = @definition.spec_git_paths
- spec_git_cache_dirs = []
- spec_gem_executables = []
- spec_cache_paths = []
- spec_gemspec_paths = []
- spec_extension_paths = []
- specs.each do |spec|
- spec_gem_paths << spec.full_gem_path
- # need to check here in case gems are nested like for the rails git repo
- md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
- spec_git_paths << md[1] if md
- spec_gem_executables << spec.executables.collect do |executable|
- e = "#{Bundler.rubygems.gem_bindir}/#{executable}"
- [e, "#{e}.bat"]
- end
- spec_cache_paths << spec.cache_file
- spec_gemspec_paths << spec.spec_file
- spec_extension_paths << spec.extension_dir if spec.respond_to?(:extension_dir)
- spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
- end
- spec_gem_paths.uniq!
- spec_gem_executables.flatten!
-
- stale_gem_bins = gem_bins - spec_gem_executables
- stale_git_dirs = git_dirs - spec_git_paths - ["#{Gem.dir}/bundler/gems/extensions"]
- stale_git_cache_dirs = git_cache_dirs - spec_git_cache_dirs
- stale_gem_dirs = gem_dirs - spec_gem_paths
- stale_gem_files = gem_files - spec_cache_paths
- stale_gemspec_files = gemspec_files - spec_gemspec_paths
- stale_extension_dirs = extension_dirs - spec_extension_paths
-
- removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
- removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
- output = removed_stale_gem_dirs + removed_stale_git_dirs
-
- unless dry_run
- stale_files = stale_gem_bins + stale_gem_files + stale_gemspec_files
- stale_files.each do |file|
- SharedHelpers.filesystem_access(File.dirname(file)) do |_p|
- FileUtils.rm(file) if File.exist?(file)
- end
- end
-
- stale_dirs = stale_git_cache_dirs + stale_extension_dirs
- stale_dirs.each do |stale_dir|
- SharedHelpers.filesystem_access(stale_dir) do |dir|
- FileUtils.rm_rf(dir) if File.exist?(dir)
- end
- end
- end
-
- output
- end
-
- private
-
- def prune_gem_cache(resolve, cache_path)
- cached = Dir["#{cache_path}/*.gem"]
-
- cached = cached.delete_if do |path|
- spec = Bundler.rubygems.spec_from_gem path
-
- resolve.any? do |s|
- s.name == spec.name && s.version == spec.version && !s.source.is_a?(Bundler::Source::Git)
- end
- end
-
- if cached.any?
- Bundler.ui.info "Removing outdated .gem files from #{Bundler.settings.app_cache_path}"
-
- cached.each do |path|
- Bundler.ui.info " * #{File.basename(path)}"
- File.delete(path)
- end
- end
- end
-
- def prune_git_and_path_cache(resolve, cache_path)
- cached = Dir["#{cache_path}/*/.bundlecache"]
-
- cached = cached.delete_if do |path|
- name = File.basename(File.dirname(path))
-
- resolve.any? do |s|
- source = s.source
- source.respond_to?(:app_cache_dirname) && source.app_cache_dirname == name
- end
- end
-
- if cached.any?
- Bundler.ui.info "Removing outdated git and path gems from #{Bundler.settings.app_cache_path}"
-
- cached.each do |path|
- path = File.dirname(path)
- Bundler.ui.info " * #{File.basename(path)}"
- FileUtils.rm_rf(path)
- end
- end
- end
-
- def setup_manpath
- # Add man/ subdirectories from activated bundles to MANPATH for man(1)
- manuals = $LOAD_PATH.map do |path|
- man_subdir = path.sub(/lib$/, "man")
- man_subdir unless Dir[man_subdir + "/man?/"].empty?
- end.compact
-
- return if manuals.empty?
- Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
- ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
- ).uniq.join(File::PATH_SEPARATOR)
- end
-
- def remove_dir(dir, dry_run)
- full_name = Pathname.new(dir).basename.to_s
-
- parts = full_name.split("-")
- name = parts[0..-2].join("-")
- version = parts.last
- output = "#{name} (#{version})"
-
- if dry_run
- Bundler.ui.info "Would have removed #{output}"
- else
- Bundler.ui.info "Removing #{output}"
- FileUtils.rm_rf(dir)
- end
-
- output
- end
-
- def check_for_activated_spec!(spec)
- return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
- return if activated_spec.version == spec.version
-
- suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
- "Since #{spec.name} is a default gem, you can either remove your dependency on it" \
- " or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
- else
- "Prepending `bundle exec` to your command may solve this."
- end
-
- e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
- "but your Gemfile requires #{spec.name} #{spec.version}. #{suggestion}"
- e.name = spec.name
- if e.respond_to?(:requirement=)
- e.requirement = Gem::Requirement.new(spec.version.to_s)
- else
- e.version_requirement = Gem::Requirement.new(spec.version.to_s)
- end
- raise e
- end
- end
-end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
deleted file mode 100644
index afbb02397c..0000000000
--- a/lib/bundler/settings.rb
+++ /dev/null
@@ -1,434 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Settings
- autoload :Mirror, File.expand_path("mirror", __dir__)
- autoload :Mirrors, File.expand_path("mirror", __dir__)
- autoload :Validator, File.expand_path("settings/validator", __dir__)
-
- BOOL_KEYS = %w[
- allow_bundler_dependency_conflicts
- allow_deployment_source_credential_changes
- allow_offline_install
- auto_clean_without_path
- auto_install
- auto_config_jobs
- cache_all
- cache_all_platforms
- default_install_uses_path
- deployment
- deployment_means_frozen
- disable_checksum_validation
- disable_exec_load
- disable_local_branch_check
- disable_multisource
- disable_platform_warnings
- disable_shared_gems
- disable_version_check
- force_ruby_platform
- forget_cli_options
- frozen
- gem.coc
- gem.mit
- global_gem_cache
- ignore_messages
- init_gems_rb
- no_install
- no_prune
- only_update_to_newer_versions
- path_relative_to_cwd
- path.system
- plugins
- prefer_patch
- print_only_version_number
- setup_makes_kernel_gem_public
- silence_deprecations
- silence_root_warning
- skip_default_git_sources
- specific_platform
- suppress_install_using_messages
- unlock_source_unlocks_spec
- update_requires_all_flag
- use_gem_version_promoter_for_major_updates
- ].freeze
-
- NUMBER_KEYS = %w[
- jobs
- redirect
- retry
- ssl_verify_mode
- timeout
- ].freeze
-
- ARRAY_KEYS = %w[
- with
- without
- ].freeze
-
- DEFAULT_CONFIG = {
- :silence_deprecations => false,
- :disable_version_check => true,
- :prefer_patch => false,
- :redirect => 5,
- :retry => 3,
- :timeout => 10,
- }.freeze
-
- def initialize(root = nil)
- @root = root
- @local_config = load_config(local_config_file)
- @global_config = load_config(global_config_file)
- @temporary = {}
- end
-
- def [](name)
- key = key_for(name)
- value = @temporary.fetch(key) do
- @local_config.fetch(key) do
- ENV.fetch(key) do
- @global_config.fetch(key) do
- DEFAULT_CONFIG.fetch(name) do
- nil
- end end end end end
-
- converted_value(value, name)
- end
-
- def set_command_option(key, value)
- if Bundler.feature_flag.forget_cli_options?
- temporary(key => value)
- value
- else
- set_local(key, value)
- end
- end
-
- def set_command_option_if_given(key, value)
- return if value.nil?
- set_command_option(key, value)
- end
-
- def set_local(key, value)
- local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")
-
- set_key(key, value, @local_config, local_config_file)
- end
-
- def temporary(update)
- existing = Hash[update.map {|k, _| [k, @temporary[key_for(k)]] }]
- update.each do |k, v|
- set_key(k, v, @temporary, nil)
- end
- return unless block_given?
- begin
- yield
- ensure
- existing.each {|k, v| set_key(k, v, @temporary, nil) }
- end
- end
-
- def set_global(key, value)
- set_key(key, value, @global_config, global_config_file)
- end
-
- def all
- env_keys = ENV.keys.grep(/\ABUNDLE_.+/)
-
- keys = @temporary.keys | @global_config.keys | @local_config.keys | env_keys
-
- keys.map do |key|
- key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
- end
- end
-
- def local_overrides
- repos = {}
- all.each do |k|
- repos[$'] = self[k] if k =~ /^local\./
- end
- repos
- end
-
- def mirror_for(uri)
- if uri.is_a?(String)
- require_relative "vendored_uri"
- uri = Bundler::URI(uri)
- end
-
- gem_mirrors.for(uri.to_s).uri
- end
-
- def credentials_for(uri)
- self[uri.to_s] || self[uri.host]
- end
-
- def gem_mirrors
- all.inject(Mirrors.new) do |mirrors, k|
- mirrors.parse(k, self[k]) if k.start_with?("mirror.")
- mirrors
- end
- end
-
- def locations(key)
- key = key_for(key)
- locations = {}
- locations[:temporary] = @temporary[key] if @temporary.key?(key)
- locations[:local] = @local_config[key] if @local_config.key?(key)
- locations[:env] = ENV[key] if ENV[key]
- locations[:global] = @global_config[key] if @global_config.key?(key)
- locations[:default] = DEFAULT_CONFIG[key] if DEFAULT_CONFIG.key?(key)
- locations
- end
-
- def pretty_values_for(exposed_key)
- key = key_for(exposed_key)
-
- locations = []
-
- if @temporary.key?(key)
- locations << "Set for the current command: #{converted_value(@temporary[key], exposed_key).inspect}"
- end
-
- if @local_config.key?(key)
- locations << "Set for your local app (#{local_config_file}): #{converted_value(@local_config[key], exposed_key).inspect}"
- end
-
- if value = ENV[key]
- locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}"
- end
-
- if @global_config.key?(key)
- locations << "Set for the current user (#{global_config_file}): #{converted_value(@global_config[key], exposed_key).inspect}"
- end
-
- return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
- locations
- end
-
- # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
- def path
- key = key_for(:path)
- path = ENV[key] || @global_config[key]
- if path && !@temporary.key?(key) && !@local_config.key?(key)
- return Path.new(path, false, false)
- end
-
- system_path = self["path.system"] || (self[:disable_shared_gems] == false)
- Path.new(self[:path], system_path, Bundler.feature_flag.default_install_uses_path?)
- end
-
- Path = Struct.new(:explicit_path, :system_path, :default_install_uses_path) do
- def path
- path = base_path
- path = File.join(path, Bundler.ruby_scope) unless use_system_gems?
- path
- end
-
- def use_system_gems?
- return true if system_path
- return false if explicit_path
- !default_install_uses_path
- end
-
- def base_path
- path = explicit_path
- path ||= ".bundle" unless use_system_gems?
- path ||= Bundler.rubygems.gem_dir
- path
- end
-
- def base_path_relative_to_pwd
- base_path = Pathname.new(self.base_path)
- expanded_base_path = base_path.expand_path(Bundler.root)
- relative_path = expanded_base_path.relative_path_from(Pathname.pwd)
- if relative_path.to_s.start_with?("..")
- relative_path = base_path if base_path.absolute?
- else
- relative_path = Pathname.new(File.join(".", relative_path))
- end
- relative_path
- rescue ArgumentError
- expanded_base_path
- end
-
- def validate!
- return unless explicit_path && system_path
- path = Bundler.settings.pretty_values_for(:path)
- path.unshift(nil, "path:") unless path.empty?
- system_path = Bundler.settings.pretty_values_for("path.system")
- system_path.unshift(nil, "path.system:") unless system_path.empty?
- disable_shared_gems = Bundler.settings.pretty_values_for(:disable_shared_gems)
- disable_shared_gems.unshift(nil, "disable_shared_gems:") unless disable_shared_gems.empty?
- raise InvalidOption,
- "Using a custom path while using system gems is unsupported.\n#{path.join("\n")}\n#{system_path.join("\n")}\n#{disable_shared_gems.join("\n")}"
- end
- end
-
- def allow_sudo?
- key = key_for(:path)
- path_configured = @temporary.key?(key) || @local_config.key?(key)
- !path_configured
- end
-
- def ignore_config?
- ENV["BUNDLE_IGNORE_CONFIG"]
- end
-
- def app_cache_path
- @app_cache_path ||= self[:cache_path] || "vendor/cache"
- end
-
- def validate!
- all.each do |raw_key|
- [@local_config, ENV, @global_config].each do |settings|
- value = converted_value(settings[key_for(raw_key)], raw_key)
- Validator.validate!(raw_key, value, settings.to_hash.dup)
- end
- end
- end
-
- def key_for(key)
- key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
- key = key.to_s.gsub(".", "__").upcase
- "BUNDLE_#{key}"
- end
-
- private
-
- def parent_setting_for(name)
- split_specific_setting_for(name)[0]
- end
-
- def specific_gem_for(name)
- split_specific_setting_for(name)[1]
- end
-
- def split_specific_setting_for(name)
- name.split(".")
- end
-
- def is_bool(name)
- BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s))
- end
-
- def to_bool(value)
- case value
- when nil, /\A(false|f|no|n|0|)\z/i, false
- false
- else
- true
- end
- end
-
- def is_num(key)
- NUMBER_KEYS.include?(key.to_s)
- end
-
- def is_array(key)
- ARRAY_KEYS.include?(key.to_s)
- end
-
- def to_array(value)
- return [] unless value
- value.split(":").map(&:to_sym)
- end
-
- def array_to_s(array)
- array = Array(array)
- return nil if array.empty?
- array.join(":").tr(" ", ":")
- end
-
- def set_key(raw_key, value, hash, file)
- raw_key = raw_key.to_s
- value = array_to_s(value) if is_array(raw_key)
-
- key = key_for(raw_key)
-
- return if hash[key] == value
-
- hash[key] = value
- hash.delete(key) if value.nil?
-
- Validator.validate!(raw_key, converted_value(value, raw_key), hash)
-
- return unless file
- SharedHelpers.filesystem_access(file) do |p|
- FileUtils.mkdir_p(p.dirname)
- require_relative "yaml_serializer"
- p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
- end
- end
-
- def converted_value(value, key)
- if is_array(key)
- to_array(value)
- elsif value.nil?
- nil
- elsif is_bool(key) || value == "false"
- to_bool(value)
- elsif is_num(key)
- value.to_i
- else
- value.to_s
- end
- end
-
- def global_config_file
- if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
- Pathname.new(ENV["BUNDLE_CONFIG"])
- else
- begin
- Bundler.user_bundle_path("config")
- rescue PermissionError, GenericSystemCallError
- nil
- end
- end
- end
-
- def local_config_file
- Pathname.new(@root).join("config") if @root
- end
-
- def load_config(config_file)
- return {} if !config_file || ignore_config?
- SharedHelpers.filesystem_access(config_file, :read) do |file|
- valid_file = file.exist? && !file.size.zero?
- return {} unless valid_file
- require_relative "yaml_serializer"
- YAMLSerializer.load file.read
- end
- end
-
- PER_URI_OPTIONS = %w[
- fallback_timeout
- ].freeze
-
- NORMALIZE_URI_OPTIONS_PATTERN =
- /
- \A
- (\w+\.)? # optional prefix key
- (https?.*?) # URI
- (\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key
- \z
- /ix.freeze
-
- # TODO: duplicates Rubygems#normalize_uri
- # TODO: is this the correct place to validate mirror URIs?
- def self.normalize_uri(uri)
- uri = uri.to_s
- if uri =~ NORMALIZE_URI_OPTIONS_PATTERN
- prefix = $1
- uri = $2
- suffix = $3
- end
- uri = "#{uri}/" unless uri.end_with?("/")
- require_relative "vendored_uri"
- uri = Bundler::URI(uri)
- unless uri.absolute?
- raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
- end
- "#{prefix}#{uri}#{suffix}"
- end
- end
-end
diff --git a/lib/bundler/settings/validator.rb b/lib/bundler/settings/validator.rb
deleted file mode 100644
index 0a57ea7f03..0000000000
--- a/lib/bundler/settings/validator.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Settings
- class Validator
- class Rule
- attr_reader :description
-
- def initialize(keys, description, &validate)
- @keys = keys
- @description = description
- @validate = validate
- end
-
- def validate!(key, value, settings)
- instance_exec(key, value, settings, &@validate)
- end
-
- def fail!(key, value, *reasons)
- reasons.unshift @description
- raise InvalidOption, "Setting `#{key}` to #{value.inspect} failed:\n#{reasons.map {|r| " - #{r}" }.join("\n")}"
- end
-
- def set(settings, key, value, *reasons)
- hash_key = k(key)
- return if settings[hash_key] == value
- reasons.unshift @description
- Bundler.ui.info "Setting `#{key}` to #{value.inspect}, since #{reasons.join(", ")}"
- if value.nil?
- settings.delete(hash_key)
- else
- settings[hash_key] = value
- end
- end
-
- def k(key)
- Bundler.settings.key_for(key)
- end
- end
-
- def self.rules
- @rules ||= Hash.new {|h, k| h[k] = [] }
- end
- private_class_method :rules
-
- def self.rule(keys, description, &blk)
- rule = Rule.new(keys, description, &blk)
- keys.each {|k| rules[k] << rule }
- end
- private_class_method :rule
-
- def self.validate!(key, value, settings)
- rules_to_validate = rules[key]
- rules_to_validate.each {|rule| rule.validate!(key, value, settings) }
- end
-
- rule %w[path path.system], "path and path.system are mutually exclusive" do |key, value, settings|
- if key == "path" && value
- set(settings, "path.system", nil)
- elsif key == "path.system" && value
- set(settings, :path, nil)
- end
- end
-
- rule %w[with without], "a group cannot be in both `with` & `without` simultaneously" do |key, value, settings|
- with = settings.fetch(k(:with), "").split(":").map(&:to_sym)
- without = settings.fetch(k(:without), "").split(":").map(&:to_sym)
-
- other_key = key == "with" ? :without : :with
- other_setting = key == "with" ? without : with
-
- conflicting = with & without
- if conflicting.any?
- fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
- end
- end
-
- rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
- next if value.nil?
-
- path = Pathname.new(value)
- next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
-
- path = path.expand_path
-
- root = begin
- Bundler.root
- rescue GemfileNotFound
- Pathname.pwd.expand_path
- end
-
- path = begin
- path.relative_path_from(root)
- rescue ArgumentError
- path
- end
-
- set(settings, key, path.to_s)
- end
- end
- end
-end
diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb
deleted file mode 100644
index 27911dc1ad..0000000000
--- a/lib/bundler/setup.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "shared_helpers"
-
-if Bundler::SharedHelpers.in_bundle?
- require_relative "../bundler"
-
- if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
- begin
- Bundler.ui.silence { Bundler.setup }
- rescue Bundler::BundlerError => e
- Bundler.ui.warn "\e[31m#{e.message}\e[0m"
- Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
- if e.is_a?(Bundler::GemNotFound)
- Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m"
- end
- exit e.status_code
- end
- else
- Bundler.ui.silence { Bundler.setup }
- end
-
- # We might be in the middle of shelling out to rubygems
- # (RUBYOPT=-rbundler/setup), so we need to give rubygems the opportunity of
- # not being silent.
- Gem::DefaultUserInteraction.ui = nil
-end
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
deleted file mode 100644
index 6e83bc5ff4..0000000000
--- a/lib/bundler/shared_helpers.rb
+++ /dev/null
@@ -1,358 +0,0 @@
-# frozen_string_literal: true
-
-require "pathname"
-require "rbconfig"
-
-require_relative "version"
-require_relative "constants"
-require_relative "rubygems_integration"
-require_relative "current_ruby"
-
-module Bundler
- module SharedHelpers
- def root
- gemfile = find_gemfile
- raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
- end
-
- def default_gemfile
- gemfile = find_gemfile
- raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
- end
-
- def default_lockfile
- gemfile = default_gemfile
-
- case gemfile.basename.to_s
- when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
- else Pathname.new("#{gemfile}.lock")
- end.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
- end
-
- def default_bundle_dir
- bundle_dir = find_directory(".bundle")
- return nil unless bundle_dir
-
- bundle_dir = Pathname.new(bundle_dir)
-
- global_bundle_dir = Bundler.user_home.join(".bundle")
- return nil if bundle_dir == global_bundle_dir
-
- bundle_dir
- end
-
- def in_bundle?
- find_gemfile
- end
-
- def chdir(dir, &blk)
- Bundler.rubygems.ext_lock.synchronize do
- Dir.chdir dir, &blk
- end
- end
-
- def pwd
- Bundler.rubygems.ext_lock.synchronize do
- Pathname.pwd
- end
- end
-
- def with_clean_git_env(&block)
- keys = %w[GIT_DIR GIT_WORK_TREE]
- old_env = keys.inject({}) do |h, k|
- h.update(k => ENV[k])
- end
-
- keys.each {|key| ENV.delete(key) }
-
- block.call
- ensure
- keys.each {|key| ENV[key] = old_env[key] }
- end
-
- def set_bundle_environment
- set_bundle_variables
- set_path
- set_rubyopt
- set_rubylib
- end
-
- # Rescues permissions errors raised by file system operations
- # (ie. Errno:EACCESS, Errno::EAGAIN) and raises more friendly errors instead.
- #
- # @param path [String] the path that the action will be attempted to
- # @param action [Symbol, #to_s] the type of operation that will be
- # performed. For example: :write, :read, :exec
- #
- # @yield path
- #
- # @raise [Bundler::PermissionError] if Errno:EACCES is raised in the
- # given block
- # @raise [Bundler::TemporaryResourceError] if Errno:EAGAIN is raised in the
- # given block
- #
- # @example
- # filesystem_access("vendor/cache", :write) do
- # FileUtils.mkdir_p("vendor/cache")
- # end
- #
- # @see {Bundler::PermissionError}
- def filesystem_access(path, action = :write, &block)
- yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" })
- rescue Errno::EACCES
- raise PermissionError.new(path, action)
- rescue Errno::EAGAIN
- raise TemporaryResourceError.new(path, action)
- rescue Errno::EPROTO
- raise VirtualProtocolError.new
- rescue Errno::ENOSPC
- raise NoSpaceOnDeviceError.new(path, action)
- rescue *[const_get_safely(:ENOTSUP, Errno)].compact
- raise OperationNotSupportedError.new(path, action)
- rescue Errno::EEXIST, Errno::ENOENT
- raise
- rescue SystemCallError => e
- raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
- end
-
- def const_get_safely(constant_name, namespace)
- const_in_namespace = namespace.constants.include?(constant_name.to_s) ||
- namespace.constants.include?(constant_name.to_sym)
- return nil unless const_in_namespace
- namespace.const_get(constant_name)
- end
-
- def major_deprecation(major_version, message, print_caller_location: false)
- if print_caller_location
- caller_location = caller_locations(2, 2).first
- message = "#{message} (called at #{caller_location.path}:#{caller_location.lineno})"
- end
-
- bundler_major_version = Bundler.bundler_major_version
- if bundler_major_version > major_version
- require_relative "errors"
- raise DeprecatedError, "[REMOVED] #{message}"
- end
-
- return unless bundler_major_version >= major_version && prints_major_deprecations?
- Bundler.ui.warn("[DEPRECATED] #{message}")
- end
-
- def print_major_deprecations!
- multiple_gemfiles = search_up(".") do |dir|
- gemfiles = gemfile_names.select {|gf| File.file? File.expand_path(gf, dir) }
- next if gemfiles.empty?
- break gemfiles.size != 1
- end
- return unless multiple_gemfiles
- message = "Multiple gemfiles (gems.rb and Gemfile) detected. " \
- "Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
- Bundler.ui.warn message
- end
-
- def trap(signal, override = false, &block)
- prior = Signal.trap(signal) do
- block.call
- prior.call unless override
- end
- end
-
- def ensure_same_dependencies(spec, old_deps, new_deps)
- new_deps = new_deps.reject {|d| d.type == :development }
- old_deps = old_deps.reject {|d| d.type == :development }
-
- without_type = proc {|d| Gem::Dependency.new(d.name, d.requirements_list.sort) }
- new_deps.map!(&without_type)
- old_deps.map!(&without_type)
-
- extra_deps = new_deps - old_deps
- return if extra_deps.empty?
-
- Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has either corrupted API or lockfile dependencies" \
- " (was expecting #{old_deps.map(&:to_s)}, but the real spec has #{new_deps.map(&:to_s)})"
- raise APIResponseMismatchError,
- "Downloading #{spec.full_name} revealed dependencies not in the API or the lockfile (#{extra_deps.join(", ")})." \
- "\nEither installing with `--full-index` or running `bundle update #{spec.name}` should fix the problem."
- end
-
- def pretty_dependency(dep, print_source = false)
- msg = String.new(dep.name)
- msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
-
- if dep.is_a?(Bundler::Dependency)
- platform_string = dep.platforms.join(", ")
- msg << " " << platform_string if !platform_string.empty? && platform_string != Gem::Platform::RUBY
- end
-
- msg << " from the `#{dep.source}` source" if print_source && dep.source
- msg
- end
-
- def md5_available?
- return @md5_available if defined?(@md5_available)
- @md5_available = begin
- require "openssl"
- OpenSSL::Digest::MD5.digest("")
- true
- rescue LoadError
- true
- rescue OpenSSL::Digest::DigestError
- false
- end
- end
-
- def digest(name)
- require "digest"
- Digest(name)
- end
-
- def write_to_gemfile(gemfile_path, contents)
- filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
- end
-
- private
-
- def validate_bundle_path
- path_separator = Bundler.rubygems.path_separator
- return unless Bundler.bundle_path.to_s.split(path_separator).size > 1
- message = "Your bundle path contains text matching #{path_separator.inspect}, " \
- "which is the path separator for your system. Bundler cannot " \
- "function correctly when the Bundle path contains the " \
- "system's PATH separator. Please change your " \
- "bundle path to not match #{path_separator.inspect}." \
- "\nYour current bundle path is '#{Bundler.bundle_path}'."
- raise Bundler::PathError, message
- end
-
- def find_gemfile
- given = ENV["BUNDLE_GEMFILE"]
- return given if given && !given.empty?
- find_file(*gemfile_names)
- end
-
- def gemfile_names
- ["gems.rb", "Gemfile"]
- end
-
- def find_file(*names)
- search_up(*names) do |filename|
- return filename if File.file?(filename)
- end
- end
-
- def find_directory(*names)
- search_up(*names) do |dirname|
- return dirname if File.directory?(dirname)
- end
- end
-
- def search_up(*names)
- previous = nil
- current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
-
- until !File.directory?(current) || current == previous
- if ENV["BUNDLE_SPEC_RUN"]
- # avoid stepping above the tmp directory when testing
- gemspec = if ENV["GEM_COMMAND"]
- # for Ruby Core
- "lib/bundler/bundler.gemspec"
- else
- "bundler.gemspec"
- end
-
- # avoid stepping above the tmp directory when testing
- return nil if File.file?(File.join(current, gemspec))
- end
-
- names.each do |name|
- filename = File.join(current, name)
- yield filename
- end
- previous = current
- current = File.expand_path("..", current)
- end
- end
-
- def set_env(key, value)
- raise ArgumentError, "new key #{key}" unless EnvironmentPreserver::BUNDLER_KEYS.include?(key)
- orig_key = "#{EnvironmentPreserver::BUNDLER_PREFIX}#{key}"
- orig = ENV[key]
- orig ||= EnvironmentPreserver::INTENTIONALLY_NIL
- ENV[orig_key] ||= orig
-
- ENV[key] = value
- end
- public :set_env
-
- def set_bundle_variables
- # bundler exe & lib folders have same root folder, typical gem installation
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
-
- # for Ruby core repository testing
- exe_file = File.expand_path("../../../libexec/bundle", __FILE__) unless File.exist?(exe_file)
-
- # bundler is a default gem, exe path is separate
- exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
-
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
- Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
- Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
- end
-
- def set_path
- validate_bundle_path
- paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
- paths.unshift "#{Bundler.bundle_path}/bin"
- Bundler::SharedHelpers.set_env "PATH", paths.uniq.join(File::PATH_SEPARATOR)
- end
-
- def set_rubyopt
- rubyopt = [ENV["RUBYOPT"]].compact
- setup_require = "-r#{File.expand_path("setup", __dir__)}"
- return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
- rubyopt.unshift setup_require
- Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
- end
-
- def set_rubylib
- rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
- rubylib.unshift bundler_ruby_lib unless RbConfig::CONFIG["rubylibdir"] == bundler_ruby_lib
- Bundler::SharedHelpers.set_env "RUBYLIB", rubylib.uniq.join(File::PATH_SEPARATOR)
- end
-
- def bundler_ruby_lib
- resolve_path File.expand_path("../..", __FILE__)
- end
-
- def clean_load_path
- bundler_lib = bundler_ruby_lib
-
- loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
-
- $LOAD_PATH.reject! do |p|
- next if resolve_path(p).start_with?(bundler_lib)
- loaded_gem_paths.delete(p)
- end
- $LOAD_PATH.uniq!
- end
-
- def resolve_path(path)
- expanded = File.expand_path(path)
- return expanded unless File.respond_to?(:realpath) && File.exist?(expanded)
-
- File.realpath(expanded)
- end
-
- def prints_major_deprecations?
- require_relative "../bundler"
- return false if Bundler.settings[:silence_deprecations]
- require_relative "deprecate"
- return false if Bundler::Deprecate.skip
- true
- end
-
- extend self
- end
-end
diff --git a/lib/bundler/similarity_detector.rb b/lib/bundler/similarity_detector.rb
deleted file mode 100644
index bd9971f884..0000000000
--- a/lib/bundler/similarity_detector.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class SimilarityDetector
- SimilarityScore = Struct.new(:string, :distance)
-
- # initialize with an array of words to be matched against
- def initialize(corpus)
- @corpus = corpus
- end
-
- # return an array of words similar to 'word' from the corpus
- def similar_words(word, limit = 3)
- words_by_similarity = @corpus.map {|w| SimilarityScore.new(w, levenshtein_distance(word, w)) }
- words_by_similarity.select {|s| s.distance <= limit }.sort_by(&:distance).map(&:string)
- end
-
- # return the result of 'similar_words', concatenated into a list
- # (eg "a, b, or c")
- def similar_word_list(word, limit = 3)
- words = similar_words(word, limit)
- if words.length == 1
- words[0]
- elsif words.length > 1
- [words[0..-2].join(", "), words[-1]].join(" or ")
- end
- end
-
- protected
-
- # https://www.informit.com/articles/article.aspx?p=683059&seqNum=36
- def levenshtein_distance(this, that, ins = 2, del = 2, sub = 1)
- # ins, del, sub are weighted costs
- return nil if this.nil?
- return nil if that.nil?
- dm = [] # distance matrix
-
- # Initialize first row values
- dm[0] = (0..this.length).collect {|i| i * ins }
- fill = [0] * (this.length - 1)
-
- # Initialize first column values
- (1..that.length).each do |i|
- dm[i] = [i * del, fill.flatten]
- end
-
- # populate matrix
- (1..that.length).each do |i|
- (1..this.length).each do |j|
- # critical comparison
- dm[i][j] = [
- dm[i - 1][j - 1] + (this[j - 1] == that[i - 1] ? 0 : sub),
- dm[i][j - 1] + ins,
- dm[i - 1][j] + del,
- ].min
- end
- end
-
- # The last value in matrix is the Levenshtein distance between the strings
- dm[that.length][this.length]
- end
- end
-end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
deleted file mode 100644
index 4b2e305bda..0000000000
--- a/lib/bundler/source.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Source
- autoload :Gemspec, File.expand_path("source/gemspec", __dir__)
- autoload :Git, File.expand_path("source/git", __dir__)
- autoload :Metadata, File.expand_path("source/metadata", __dir__)
- autoload :Path, File.expand_path("source/path", __dir__)
- autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
-
- attr_accessor :dependency_names
-
- def unmet_deps
- specs.unmet_dependency_names
- end
-
- def version_message(spec)
- message = "#{spec.name} #{spec.version}"
- message += " (#{spec.platform})" if spec.platform != Gem::Platform::RUBY && !spec.platform.nil?
-
- if Bundler.locked_gems
- locked_spec = Bundler.locked_gems.specs.find {|s| s.name == spec.name }
- locked_spec_version = locked_spec.version if locked_spec
- if locked_spec_version && spec.version != locked_spec_version
- message += Bundler.ui.add_color(" (was #{locked_spec_version})", version_color(spec.version, locked_spec_version))
- end
- end
-
- message
- end
-
- def can_lock?(spec)
- spec.source == self
- end
-
- # it's possible that gems from one source depend on gems from some
- # other source, so now we download gemspecs and iterate over those
- # dependencies, looking for gems we don't have info on yet.
- def double_check_for(*); end
-
- def dependency_names_to_double_check
- specs.dependency_names
- end
-
- def include?(other)
- other == self
- end
-
- def inspect
- "#<#{self.class}:0x#{object_id} #{self}>"
- end
-
- def path?
- instance_of?(Bundler::Source::Path)
- end
-
- def extension_cache_path(spec)
- return unless Bundler.feature_flag.global_gem_cache?
- return unless source_slug = extension_cache_slug(spec)
- Bundler.user_cache.join(
- "extensions", Gem::Platform.local.to_s, Bundler.ruby_scope,
- source_slug, spec.full_name
- )
- end
-
- private
-
- def version_color(spec_version, locked_spec_version)
- if Gem::Version.correct?(spec_version) && Gem::Version.correct?(locked_spec_version)
- # display yellow if there appears to be a regression
- earlier_version?(spec_version, locked_spec_version) ? :yellow : :green
- else
- # default to green if the versions cannot be directly compared
- :green
- end
- end
-
- def earlier_version?(spec_version, locked_spec_version)
- Gem::Version.new(spec_version) < Gem::Version.new(locked_spec_version)
- end
-
- def print_using_message(message)
- if !message.include?("(was ") && Bundler.feature_flag.suppress_install_using_messages?
- Bundler.ui.debug message
- else
- Bundler.ui.info message
- end
- end
-
- def extension_cache_slug(_)
- nil
- end
- end
-end
diff --git a/lib/bundler/source/gemspec.rb b/lib/bundler/source/gemspec.rb
deleted file mode 100644
index 7e3447e776..0000000000
--- a/lib/bundler/source/gemspec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Source
- class Gemspec < Path
- attr_reader :gemspec
-
- def initialize(options)
- super
- @gemspec = options["gemspec"]
- end
-
- def as_path_source
- Path.new(options)
- end
- end
- end
-end
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
deleted file mode 100644
index 7c1533ad90..0000000000
--- a/lib/bundler/source/git.rb
+++ /dev/null
@@ -1,336 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../vendored_fileutils"
-
-module Bundler
- class Source
- class Git < Path
- autoload :GitProxy, File.expand_path("git/git_proxy", __dir__)
-
- attr_reader :uri, :ref, :branch, :options, :glob, :submodules
-
- def initialize(options)
- @options = options
- @glob = options["glob"] || DEFAULT_GLOB
-
- @allow_cached = false
- @allow_remote = false
-
- # Stringify options that could be set as symbols
- %w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] }
-
- @uri = options["uri"] || ""
- @safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
- @branch = options["branch"]
- @ref = options["ref"] || options["branch"] || options["tag"] || "master"
- @submodules = options["submodules"]
- @name = options["name"]
- @version = options["version"].to_s.strip.gsub("-", ".pre.")
-
- @copied = false
- @local = false
- end
-
- def self.from_lock(options)
- new(options.merge("uri" => options.delete("remote")))
- end
-
- def to_lock
- out = String.new("GIT\n")
- out << " remote: #{@uri}\n"
- out << " revision: #{revision}\n"
- %w[ref branch tag submodules].each do |opt|
- out << " #{opt}: #{options[opt]}\n" if options[opt]
- end
- out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
- out << " specs:\n"
- end
-
- def hash
- [self.class, uri, ref, branch, name, version, glob, submodules].hash
- end
-
- def eql?(other)
- other.is_a?(Git) && uri == other.uri && ref == other.ref &&
- branch == other.branch && name == other.name &&
- version == other.version && glob == other.glob &&
- submodules == other.submodules
- end
-
- alias_method :==, :eql?
-
- def to_s
- at = if local?
- path
- elsif user_ref = options["ref"]
- if ref =~ /\A[a-z0-9]{4,}\z/i
- shortref_for_display(user_ref)
- else
- user_ref
- end
- else
- ref
- end
-
- rev = begin
- "@#{shortref_for_display(revision)}"
- rescue GitError
- nil
- end
-
- "#{@safe_uri} (at #{at}#{rev})"
- end
-
- def name
- File.basename(@uri, ".git")
- end
-
- # This is the path which is going to contain a specific
- # checkout of the git repository. When using local git
- # repos, this is set to the local repo.
- def install_path
- @install_path ||= begin
- git_scope = "#{base_name}-#{shortref_for_path(revision)}"
-
- path = Bundler.install_path.join(git_scope)
-
- if !path.exist? && Bundler.requires_sudo?
- Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
- else
- path
- end
- end
- end
-
- alias_method :path, :install_path
-
- def extension_dir_name
- "#{base_name}-#{shortref_for_path(revision)}"
- end
-
- def unlock!
- git_proxy.revision = nil
- options["revision"] = nil
-
- @unlocked = true
- end
-
- def local_override!(path)
- return false if local?
-
- original_path = path
- path = Pathname.new(path)
- path = path.expand_path(Bundler.root) unless path.relative?
-
- unless options["branch"] || Bundler.settings[:disable_local_branch_check]
- raise GitError, "Cannot use local override for #{name} at #{path} because " \
- ":branch is not specified in Gemfile. Specify a branch or run " \
- "`bundle config unset local.#{override_for(original_path)}` to remove the local override"
- end
-
- unless path.exist?
- raise GitError, "Cannot use local override for #{name} because #{path} " \
- "does not exist. Run `bundle config unset local.#{override_for(original_path)}` to remove the local override"
- end
-
- set_local!(path)
-
- # Create a new git proxy without the cached revision
- # so the Gemfile.lock always picks up the new revision.
- @git_proxy = GitProxy.new(path, uri, ref)
-
- if git_proxy.branch != options["branch"] && !Bundler.settings[:disable_local_branch_check]
- raise GitError, "Local override for #{name} at #{path} is using branch " \
- "#{git_proxy.branch} but Gemfile specifies #{options["branch"]}"
- end
-
- changed = cached_revision && cached_revision != git_proxy.revision
-
- if changed && !@unlocked && !git_proxy.contains?(cached_revision)
- raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
- "but the current branch in your local override for #{name} does not contain such commit. " \
- "Please make sure your branch is up to date."
- end
-
- changed
- end
-
- def specs(*)
- set_local!(app_cache_path) if has_app_cache? && !local?
-
- if requires_checkout? && !@copied
- fetch
- git_proxy.copy_to(install_path, submodules)
- serialize_gemspecs_in(install_path)
- @copied = true
- end
-
- local_specs
- end
-
- def install(spec, options = {})
- force = options[:force]
-
- print_using_message "Using #{version_message(spec)} from #{self}"
-
- if (requires_checkout? && !@copied) || force
- Bundler.ui.debug " * Checking out revision: #{ref}"
- git_proxy.copy_to(install_path, submodules)
- serialize_gemspecs_in(install_path)
- @copied = true
- end
-
- generate_bin_options = { :disable_extensions => !Bundler.rubygems.spec_missing_extensions?(spec), :build_args => options[:build_args] }
- generate_bin(spec, generate_bin_options)
-
- requires_checkout? ? spec.post_install_message : nil
- end
-
- def cache(spec, custom_path = nil)
- app_cache_path = app_cache_path(custom_path)
- return unless Bundler.feature_flag.cache_all?
- return if path == app_cache_path
- cached!
- FileUtils.rm_rf(app_cache_path)
- git_proxy.checkout if requires_checkout?
- git_proxy.copy_to(app_cache_path, @submodules)
- serialize_gemspecs_in(app_cache_path)
- end
-
- def load_spec_files
- super
- rescue PathError => e
- Bundler.ui.trace e
- raise GitError, "#{self} is not yet checked out. Run `bundle install` first."
- end
-
- # This is the path which is going to contain a cache
- # of the git repository. When using the same git repository
- # across different projects, this cache will be shared.
- # When using local git repos, this is set to the local repo.
- def cache_path
- @cache_path ||= begin
- if Bundler.requires_sudo? || Bundler.feature_flag.global_gem_cache?
- Bundler.user_cache
- else
- Bundler.bundle_path.join("cache", "bundler")
- end.join("git", git_scope)
- end
- end
-
- def app_cache_dirname
- "#{base_name}-#{shortref_for_path(cached_revision || revision)}"
- end
-
- def revision
- git_proxy.revision
- end
-
- def allow_git_ops?
- @allow_remote || @allow_cached
- end
-
- private
-
- def serialize_gemspecs_in(destination)
- destination = destination.expand_path(Bundler.root) if destination.relative?
- Dir["#{destination}/#{@glob}"].each do |spec_path|
- # Evaluate gemspecs and cache the result. Gemspecs
- # in git might require git or other dependencies.
- # The gemspecs we cache should already be evaluated.
- spec = Bundler.load_gemspec(spec_path)
- next unless spec
- Bundler.rubygems.set_installed_by_version(spec)
- Bundler.rubygems.validate(spec)
- File.open(spec_path, "wb") {|file| file.write(spec.to_ruby) }
- end
- end
-
- def set_local!(path)
- @local = true
- @local_specs = @git_proxy = nil
- @cache_path = @install_path = path
- end
-
- def has_app_cache?
- cached_revision && super
- end
-
- def local?
- @local
- end
-
- def requires_checkout?
- allow_git_ops? && !local? && !cached_revision_checked_out?
- end
-
- def cached_revision_checked_out?
- cached_revision && cached_revision == revision && install_path.exist?
- end
-
- def base_name
- File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)?(//\w*/)?(\w*/)*}, ""), ".git")
- end
-
- def shortref_for_display(ref)
- ref[0..6]
- end
-
- def shortref_for_path(ref)
- ref[0..11]
- end
-
- def uri_hash
- if uri =~ %r{^\w+://(\w+@)?}
- # Downcase the domain component of the URI
- # and strip off a trailing slash, if one is present
- input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
- else
- # If there is no URI scheme, assume it is an ssh/git URI
- input = uri
- end
- SharedHelpers.digest(:SHA1).hexdigest(input)
- end
-
- def cached_revision
- options["revision"]
- end
-
- def cached?
- cache_path.exist?
- end
-
- def git_proxy
- @git_proxy ||= GitProxy.new(cache_path, uri, ref, cached_revision, self)
- end
-
- def fetch
- git_proxy.checkout
- rescue GitError => e
- raise unless Bundler.feature_flag.allow_offline_install?
- Bundler.ui.warn "Using cached git data because of network errors:\n#{e}"
- end
-
- # no-op, since we validate when re-serializing the gemspec
- def validate_spec(_spec); end
-
- def load_gemspec(file)
- stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
- stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
- StubSpecification.from_stub(stub)
- end
-
- def git_scope
- "#{base_name}-#{uri_hash}"
- end
-
- def extension_cache_slug(_)
- extension_dir_name
- end
-
- def override_for(path)
- Bundler.settings.local_overrides.key(path)
- end
- end
- end
-end
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
deleted file mode 100644
index 7612eb16c6..0000000000
--- a/lib/bundler/source/git/git_proxy.rb
+++ /dev/null
@@ -1,259 +0,0 @@
-# frozen_string_literal: true
-
-require "shellwords"
-
-module Bundler
- class Source
- class Git
- class GitNotInstalledError < GitError
- def initialize
- msg = String.new
- msg << "You need to install git to be able to use gems from git repositories. "
- msg << "For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git"
- super msg
- end
- end
-
- class GitNotAllowedError < GitError
- def initialize(command)
- msg = String.new
- msg << "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, "
- msg << "this error message could probably be more useful. Please submit a ticket at https://github.com/bundler/bundler/issues "
- msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
- super msg
- end
- end
-
- class GitCommandError < GitError
- attr_reader :command
-
- def initialize(command, path = nil, extra_info = nil)
- @command = command
-
- msg = String.new
- msg << "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed."
- msg << "\n#{extra_info}" if extra_info
- msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path && path.exist?
- super msg
- end
- end
-
- class MissingGitRevisionError < GitCommandError
- def initialize(command, path, ref, repo)
- msg = "Revision #{ref} does not exist in the repository #{repo}. Maybe you misspelled it?"
- super command, path, msg
- end
- end
-
- # The GitProxy is responsible to interact with git repositories.
- # All actions required by the Git source is encapsulated in this
- # object.
- class GitProxy
- attr_accessor :path, :uri, :ref
- attr_writer :revision
-
- def initialize(path, uri, ref, revision = nil, git = nil)
- @path = path
- @uri = uri
- @ref = ref
- @revision = revision
- @git = git
- raise GitNotInstalledError.new if allow? && !Bundler.git_present?
- end
-
- def revision
- return @revision if @revision
-
- begin
- @revision ||= find_local_revision
- rescue GitCommandError => e
- raise MissingGitRevisionError.new(e.command, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
- end
-
- @revision
- end
-
- def branch
- @branch ||= allowed_in_path do
- git("rev-parse --abbrev-ref HEAD").strip
- end
- end
-
- def contains?(commit)
- allowed_in_path do
- result, status = git_null("branch --contains #{commit}")
- status.success? && result =~ /^\* (.*)$/
- end
- end
-
- def version
- git("--version").match(/(git version\s*)?((\.?\d+)+).*/)[2]
- end
-
- def full_version
- git("--version").sub("git version", "").strip
- end
-
- def checkout
- return if path.exist? && has_revision_cached?
- extra_ref = "#{Shellwords.shellescape(ref)}:#{Shellwords.shellescape(ref)}" if ref && ref.start_with?("refs/")
-
- Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
-
- unless path.exist?
- SharedHelpers.filesystem_access(path.dirname) do |p|
- FileUtils.mkdir_p(p)
- end
- git_retry %(clone #{uri_escaped_with_configured_credentials} "#{path}" --bare --no-hardlinks --quiet)
- return unless extra_ref
- end
-
- in_path do
- git_retry %(fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*" #{extra_ref})
- end
- end
-
- def copy_to(destination, submodules = false)
- # method 1
- unless File.exist?(destination.join(".git"))
- begin
- SharedHelpers.filesystem_access(destination.dirname) do |p|
- FileUtils.mkdir_p(p)
- end
- SharedHelpers.filesystem_access(destination) do |p|
- FileUtils.rm_rf(p)
- end
- git_retry %(clone --no-checkout --quiet "#{path}" "#{destination}")
- File.chmod(((File.stat(destination).mode | 0o777) & ~File.umask), destination)
- rescue Errno::EEXIST => e
- file_path = e.message[%r{.*?(/.*)}, 1]
- raise GitError, "Bundler could not install a gem because it needs to " \
- "create a directory, but a file exists - #{file_path}. Please delete " \
- "this file and try again."
- end
- end
- # method 2
- SharedHelpers.chdir(destination) do
- git_retry %(fetch --force --quiet --tags "#{path}")
-
- begin
- git "reset --hard #{@revision}"
- rescue GitCommandError => e
- raise MissingGitRevisionError.new(e.command, path, @revision, URICredentialsFilter.credential_filtered_uri(uri))
- end
-
- if submodules
- git_retry "submodule update --init --recursive"
- elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0")
- git_retry "submodule deinit --all --force"
- end
- end
- end
-
- private
-
- def git_null(command)
- command_with_no_credentials = URICredentialsFilter.credential_filtered_string(command, uri)
- raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
-
- out, status = SharedHelpers.with_clean_git_env do
- capture_and_ignore_stderr("git #{command}")
- end
-
- [URICredentialsFilter.credential_filtered_string(out, uri), status]
- end
-
- def git_retry(command)
- Bundler::Retry.new("`git #{URICredentialsFilter.credential_filtered_string(command, uri)}`", GitNotAllowedError).attempts do
- git(command)
- end
- end
-
- def git(command, check_errors = true, error_msg = nil)
- command_with_no_credentials = URICredentialsFilter.credential_filtered_string(command, uri)
- raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
-
- out, status = SharedHelpers.with_clean_git_env do
- capture_and_filter_stderr(uri, "git #{command}")
- end
-
- stdout_with_no_credentials = URICredentialsFilter.credential_filtered_string(out, uri)
- raise GitCommandError.new(command_with_no_credentials, path, error_msg) if check_errors && !status.success?
- stdout_with_no_credentials
- end
-
- def has_revision_cached?
- return unless @revision
- in_path { git("cat-file -e #{@revision}") }
- true
- rescue GitError
- false
- end
-
- def remove_cache
- FileUtils.rm_rf(path)
- end
-
- def find_local_revision
- allowed_in_path do
- git("rev-parse --verify #{Shellwords.shellescape(ref)}", true).strip
- end
- end
-
- # Escape the URI for git commands
- def uri_escaped_with_configured_credentials
- remote = configured_uri_for(uri)
- if Bundler::WINDOWS
- # Windows quoting requires double quotes only, with double quotes
- # inside the string escaped by being doubled.
- '"' + remote.gsub('"') { '""' } + '"'
- else
- # Bash requires single quoted strings, with the single quotes escaped
- # by ending the string, escaping the quote, and restarting the string.
- "'" + remote.gsub("'") { "'\\''" } + "'"
- end
- end
-
- # Adds credentials to the URI as Fetcher#configured_uri_for does
- def configured_uri_for(uri)
- if /https?:/ =~ uri
- remote = Bundler::URI(uri)
- config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
- remote.userinfo ||= config_auth
- remote.to_s
- else
- uri
- end
- end
-
- def allow?
- @git ? @git.allow_git_ops? : true
- end
-
- def in_path(&blk)
- checkout unless path.exist?
- _ = URICredentialsFilter # load it before we chdir
- SharedHelpers.chdir(path, &blk)
- end
-
- def allowed_in_path
- return in_path { yield } if allow?
- raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application"
- end
-
- def capture_and_filter_stderr(uri, cmd)
- require "open3"
- return_value, captured_err, status = Open3.capture3(cmd)
- Bundler.ui.warn URICredentialsFilter.credential_filtered_string(captured_err, uri) if uri && !captured_err.empty?
- [return_value, status]
- end
-
- def capture_and_ignore_stderr(cmd)
- require "open3"
- return_value, _, status = Open3.capture3(cmd)
- [return_value, status]
- end
- end
- end
- end
-end
diff --git a/lib/bundler/source/metadata.rb b/lib/bundler/source/metadata.rb
deleted file mode 100644
index 0867879861..0000000000
--- a/lib/bundler/source/metadata.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Source
- class Metadata < Source
- def specs
- @specs ||= Index.build do |idx|
- idx << Gem::Specification.new("Ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
- idx << Gem::Specification.new("RubyGems\0", Gem::VERSION) do |s|
- s.required_rubygems_version = Gem::Requirement.default
- end
-
- idx << Gem::Specification.new do |s|
- s.name = "bundler"
- s.version = VERSION
- s.license = "MIT"
- s.platform = Gem::Platform::RUBY
- s.source = self
- s.authors = ["bundler team"]
- s.bindir = "exe"
- s.homepage = "https://bundler.io"
- s.summary = "The best way to manage your application's dependencies"
- s.executables = %w[bundle]
- # can't point to the actual gemspec or else the require paths will be wrong
- s.loaded_from = File.expand_path("..", __FILE__)
- end
-
- if local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
- idx << local_spec
- end
-
- idx.each {|s| s.source = self }
- end
- end
-
- def cached!; end
-
- def remote!; end
-
- def options
- {}
- end
-
- def install(spec, _opts = {})
- print_using_message "Using #{version_message(spec)}"
- nil
- end
-
- def to_s
- "the local ruby installation"
- end
-
- def ==(other)
- self.class == other.class
- end
- alias_method :eql?, :==
-
- def hash
- self.class.hash
- end
-
- def version_message(spec)
- "#{spec.name} #{spec.version}"
- end
- end
- end
-end
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
deleted file mode 100644
index f98f5155fb..0000000000
--- a/lib/bundler/source/path.rb
+++ /dev/null
@@ -1,254 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Source
- class Path < Source
- autoload :Installer, File.expand_path("path/installer", __dir__)
-
- attr_reader :path, :options, :root_path, :original_path
- attr_writer :name
- attr_accessor :version
-
- protected :original_path
-
- DEFAULT_GLOB = "{,*,*/*}.gemspec".freeze
-
- def initialize(options)
- @options = options.dup
- @glob = options["glob"] || DEFAULT_GLOB
-
- @allow_cached = false
- @allow_remote = false
-
- @root_path = options["root_path"] || root
-
- if options["path"]
- @path = Pathname.new(options["path"])
- expanded_path = expand(@path)
- @path = if @path.relative?
- expanded_path.relative_path_from(root_path.expand_path)
- else
- expanded_path
- end
- end
-
- @name = options["name"]
- @version = options["version"]
-
- # Stores the original path. If at any point we move to the
- # cached directory, we still have the original path to copy from.
- @original_path = @path
- end
-
- def remote!
- @local_specs = nil
- @allow_remote = true
- end
-
- def cached!
- @local_specs = nil
- @allow_cached = true
- end
-
- def self.from_lock(options)
- new(options.merge("path" => options.delete("remote")))
- end
-
- def to_lock
- out = String.new("PATH\n")
- out << " remote: #{lockfile_path}\n"
- out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
- out << " specs:\n"
- end
-
- def to_s
- "source at `#{@path}`"
- end
-
- def hash
- [self.class, expanded_path, version].hash
- end
-
- def eql?(other)
- return unless other.class == self.class
- expanded_original_path == other.expanded_original_path &&
- version == other.version
- end
-
- alias_method :==, :eql?
-
- def name
- File.basename(expanded_path.to_s)
- end
-
- def install(spec, options = {})
- print_using_message "Using #{version_message(spec)} from #{self}"
- generate_bin(spec, :disable_extensions => true)
- nil # no post-install message
- end
-
- def cache(spec, custom_path = nil)
- app_cache_path = app_cache_path(custom_path)
- return unless Bundler.feature_flag.cache_all?
- return if expand(@original_path).to_s.index(root_path.to_s + "/") == 0
-
- unless @original_path.exist?
- raise GemNotFound, "Can't cache gem #{version_message(spec)} because #{self} is missing!"
- end
-
- FileUtils.rm_rf(app_cache_path)
- FileUtils.cp_r("#{@original_path}/.", app_cache_path)
- FileUtils.touch(app_cache_path.join(".bundlecache"))
- end
-
- def local_specs(*)
- @local_specs ||= load_spec_files
- end
-
- def specs
- if has_app_cache?
- @path = app_cache_path
- @expanded_path = nil # Invalidate
- end
- local_specs
- end
-
- def app_cache_dirname
- name
- end
-
- def root
- Bundler.root
- end
-
- def expanded_original_path
- @expanded_original_path ||= expand(original_path)
- end
-
- private
-
- def expanded_path
- @expanded_path ||= expand(path)
- end
-
- def expand(somepath)
- somepath.expand_path(root_path)
- rescue ArgumentError => e
- Bundler.ui.debug(e)
- raise PathError, "There was an error while trying to use the path " \
- "`#{somepath}`.\nThe error message was: #{e.message}."
- end
-
- def lockfile_path
- return relative_path(original_path) if original_path.absolute?
- expand(original_path).relative_path_from(root)
- end
-
- def app_cache_path(custom_path = nil)
- @app_cache_path ||= Bundler.app_cache(custom_path).join(app_cache_dirname)
- end
-
- def has_app_cache?
- SharedHelpers.in_bundle? && app_cache_path.exist?
- end
-
- def load_gemspec(file)
- return unless spec = Bundler.load_gemspec(file)
- Bundler.rubygems.set_installed_by_version(spec)
- spec
- end
-
- def validate_spec(spec)
- Bundler.rubygems.validate(spec)
- end
-
- def load_spec_files
- index = Index.new
-
- if File.directory?(expanded_path)
- # We sort depth-first since `<<` will override the earlier-found specs
- Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
- next unless spec = load_gemspec(file)
- spec.source = self
-
- # Validation causes extension_dir to be calculated, which depends
- # on #source, so we validate here instead of load_gemspec
- validate_spec(spec)
- index << spec
- end
-
- if index.empty? && @name && @version
- index << Gem::Specification.new do |s|
- s.name = @name
- s.source = self
- s.version = Gem::Version.new(@version)
- s.platform = Gem::Platform::RUBY
- s.summary = "Fake gemspec for #{@name}"
- s.relative_loaded_from = "#{@name}.gemspec"
- s.authors = ["no one"]
- if expanded_path.join("bin").exist?
- executables = expanded_path.join("bin").children
- executables.reject! {|p| File.directory?(p) }
- s.executables = executables.map {|c| c.basename.to_s }
- end
- end
- end
- else
- message = String.new("The path `#{expanded_path}` ")
- message << if File.exist?(expanded_path)
- "is not a directory."
- else
- "does not exist."
- end
- raise PathError, message
- end
-
- index
- end
-
- def relative_path(path = self.path)
- if path.to_s.start_with?(root_path.to_s)
- return path.relative_path_from(root_path)
- end
- path
- end
-
- def generate_bin(spec, options = {})
- gem_dir = Pathname.new(spec.full_gem_path)
-
- # Some gem authors put absolute paths in their gemspec
- # and we have to save them from themselves
- spec.files = spec.files.map do |p|
- next p unless p =~ /\A#{Pathname::SEPARATOR_PAT}/
- next if File.directory?(p)
- begin
- Pathname.new(p).relative_path_from(gem_dir).to_s
- rescue ArgumentError
- p
- end
- end.compact
-
- installer = Path::Installer.new(
- spec,
- :env_shebang => false,
- :disable_extensions => options[:disable_extensions],
- :build_args => options[:build_args],
- :bundler_extension_cache_path => extension_cache_path(spec)
- )
- installer.post_install
- rescue Gem::InvalidSpecificationException => e
- Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" \
- "This prevents bundler from installing bins or native extensions, but " \
- "that may not affect its functionality."
-
- if !spec.extensions.empty? && !spec.email.empty?
- Bundler.ui.warn "If you need to use this package without installing it from a gem " \
- "repository, please contact #{spec.email} and ask them " \
- "to modify their .gemspec so it can work with `gem build`."
- end
-
- Bundler.ui.warn "The validation message from RubyGems was:\n #{e.message}"
- end
- end
- end
-end
diff --git a/lib/bundler/source/path/installer.rb b/lib/bundler/source/path/installer.rb
deleted file mode 100644
index a0357ffa39..0000000000
--- a/lib/bundler/source/path/installer.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Source
- class Path
- class Installer < Bundler::RubyGemsGemInstaller
- attr_reader :spec
-
- def initialize(spec, options = {})
- @options = options
- @spec = spec
- @gem_dir = Bundler.rubygems.path(spec.full_gem_path)
- @wrappers = true
- @env_shebang = true
- @format_executable = options[:format_executable] || false
- @build_args = options[:build_args] || Bundler.rubygems.build_args
- @gem_bin_dir = "#{Bundler.rubygems.gem_dir}/bin"
- @disable_extensions = options[:disable_extensions]
-
- if Bundler.requires_sudo?
- @tmp_dir = Bundler.tmp(spec.full_name).to_s
- @bin_dir = "#{@tmp_dir}/bin"
- else
- @bin_dir = @gem_bin_dir
- end
- end
-
- def post_install
- SharedHelpers.chdir(@gem_dir) do
- run_hooks(:pre_install)
-
- unless @disable_extensions
- build_extensions
- run_hooks(:post_build)
- end
-
- generate_bin unless spec.executables.nil? || spec.executables.empty?
-
- run_hooks(:post_install)
- end
- ensure
- Bundler.rm_rf(@tmp_dir) if Bundler.requires_sudo?
- end
-
- private
-
- def generate_bin
- super
-
- if Bundler.requires_sudo?
- SharedHelpers.filesystem_access(@gem_bin_dir) do |p|
- Bundler.mkdir_p(p)
- end
- spec.executables.each do |exe|
- Bundler.sudo "cp -R #{@bin_dir}/#{exe} #{@gem_bin_dir}"
- end
- end
- end
-
- def run_hooks(type)
- hooks_meth = "#{type}_hooks"
- return unless Gem.respond_to?(hooks_meth)
- Gem.send(hooks_meth).each do |hook|
- result = hook.call(self)
- next unless result == false
- location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
- message = "#{type} hook#{location} failed for #{spec.full_name}"
- raise InstallHookError, message
- end
- end
- end
- end
- end
-end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
deleted file mode 100644
index 6c0de204e7..0000000000
--- a/lib/bundler/source/rubygems.rb
+++ /dev/null
@@ -1,545 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems/user_interaction"
-
-module Bundler
- class Source
- class Rubygems < Source
- autoload :Remote, File.expand_path("rubygems/remote", __dir__)
-
- # Use the API when installing less than X gems
- API_REQUEST_LIMIT = 500
- # Ask for X gems per API request
- API_REQUEST_SIZE = 50
-
- attr_reader :remotes, :caches
-
- def initialize(options = {})
- @options = options
- @remotes = []
- @dependency_names = []
- @allow_remote = false
- @allow_cached = false
- @caches = [cache_path, *Bundler.rubygems.gem_cache]
-
- Array(options["remotes"] || []).reverse_each {|r| add_remote(r) }
- end
-
- def remote!
- @specs = nil
- @allow_remote = true
- end
-
- def cached!
- @specs = nil
- @allow_cached = true
- end
-
- def hash
- @remotes.hash
- end
-
- def eql?(other)
- other.is_a?(Rubygems) && other.credless_remotes == credless_remotes
- end
-
- alias_method :==, :eql?
-
- def include?(o)
- o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
- end
-
- def can_lock?(spec)
- return super if Bundler.feature_flag.disable_multisource?
- spec.source.is_a?(Rubygems)
- end
-
- def options
- { "remotes" => @remotes.map(&:to_s) }
- end
-
- def self.from_lock(options)
- new(options)
- end
-
- def to_lock
- out = String.new("GEM\n")
- remotes.reverse_each do |remote|
- out << " remote: #{suppress_configured_credentials remote}\n"
- end
- out << " specs:\n"
- end
-
- def to_s
- if remotes.empty?
- "locally installed gems"
- else
- remote_names = remotes.map(&:to_s).join(", ")
- "rubygems repository #{remote_names} or installed locally"
- end
- end
- alias_method :name, :to_s
-
- def specs
- @specs ||= begin
- # remote_specs usually generates a way larger Index than the other
- # sources, and large_idx.use small_idx is way faster than
- # small_idx.use large_idx.
- idx = @allow_remote ? remote_specs.dup : Index.new
- idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
- idx.use(installed_specs, :override_dupes)
- idx
- end
- end
-
- def install(spec, opts = {})
- force = opts[:force]
- ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached]
-
- if ensure_builtin_gems_cached && builtin_gem?(spec)
- if !cached_path(spec)
- cached_built_in_gem(spec) unless spec.remote
- force = true
- else
- spec.loaded_from = loaded_from(spec)
- end
- end
-
- if (installed?(spec) || Plugin.installed?(spec.name)) && !force
- print_using_message "Using #{version_message(spec)}"
- return nil # no post-install message
- end
-
- # Download the gem to get the spec, because some specs that are returned
- # by rubygems.org are broken and wrong.
- if spec.remote
- # Check for this spec from other sources
- uris = [spec.remote.anonymized_uri]
- uris += remotes_for_spec(spec).map(&:anonymized_uri)
- uris.uniq!
- Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
-
- path = fetch_gem(spec)
- begin
- s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
- spec.__swap__(s)
- rescue StandardError
- Bundler.rm_rf(path)
- raise
- end
- end
-
- unless Bundler.settings[:no_install]
- message = "Installing #{version_message(spec)}"
- message += " with native extensions" if spec.extensions.any?
- Bundler.ui.confirm message
-
- path = cached_gem(spec)
- if requires_sudo?
- install_path = Bundler.tmp(spec.full_name)
- bin_path = install_path.join("bin")
- else
- install_path = rubygems_dir
- bin_path = Bundler.system_bindir
- end
-
- Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
-
- installed_spec = nil
- Bundler.rubygems.preserve_paths do
- installed_spec = Bundler::RubyGemsGemInstaller.at(
- path,
- :install_dir => install_path.to_s,
- :bin_dir => bin_path.to_s,
- :ignore_dependencies => true,
- :wrappers => true,
- :env_shebang => true,
- :build_args => opts[:build_args],
- :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
- :bundler_extension_cache_path => extension_cache_path(spec)
- ).install
- end
- spec.full_gem_path = installed_spec.full_gem_path
-
- # SUDO HAX
- if requires_sudo?
- Bundler.rubygems.repository_subdirectories.each do |name|
- src = File.join(install_path, name, "*")
- dst = File.join(rubygems_dir, name)
- if name == "extensions" && Dir.glob(src).any?
- src = File.join(src, "*/*")
- ext_src = Dir.glob(src).first
- ext_src.gsub!(src[0..-6], "")
- dst = File.dirname(File.join(dst, ext_src))
- end
- SharedHelpers.filesystem_access(dst) do |p|
- Bundler.mkdir_p(p)
- end
- Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
- end
-
- spec.executables.each do |exe|
- SharedHelpers.filesystem_access(Bundler.system_bindir) do |p|
- Bundler.mkdir_p(p)
- end
- Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
- end
- end
- installed_spec.loaded_from = loaded_from(spec)
- end
- spec.loaded_from = loaded_from(spec)
-
- spec.post_install_message
- ensure
- Bundler.rm_rf(install_path) if requires_sudo?
- end
-
- def cache(spec, custom_path = nil)
- if builtin_gem?(spec)
- cached_path = cached_built_in_gem(spec)
- else
- cached_path = cached_gem(spec)
- end
- raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
- return if File.dirname(cached_path) == Bundler.app_cache.to_s
- Bundler.ui.info " * #{File.basename(cached_path)}"
- FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
- rescue Errno::EACCES => e
- Bundler.ui.debug(e)
- raise InstallError, e.message
- end
-
- def cached_built_in_gem(spec)
- cached_path = cached_path(spec)
- if cached_path.nil?
- remote_spec = remote_specs.search(spec).first
- if remote_spec
- cached_path = fetch_gem(remote_spec)
- else
- Bundler.ui.warn "#{spec.full_name} is built in to Ruby, and can't be cached because your Gemfile doesn't have any sources that contain it."
- end
- end
- cached_path
- end
-
- def add_remote(source)
- uri = normalize_uri(source)
- @remotes.unshift(uri) unless @remotes.include?(uri)
- end
-
- def equivalent_remotes?(other_remotes)
- other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
- end
-
- def replace_remotes(other_remotes, allow_equivalent = false)
- return false if other_remotes == @remotes
-
- equivalent = allow_equivalent && equivalent_remotes?(other_remotes)
-
- @remotes = []
- other_remotes.reverse_each do |r|
- add_remote r.to_s
- end
-
- !equivalent
- end
-
- def unmet_deps
- if @allow_remote && api_fetchers.any?
- remote_specs.unmet_dependency_names
- else
- []
- end
- end
-
- def fetchers
- @fetchers ||= remotes.map do |uri|
- remote = Source::Rubygems::Remote.new(uri)
- Bundler::Fetcher.new(remote)
- end
- end
-
- def double_check_for(unmet_dependency_names)
- return unless @allow_remote
- return unless api_fetchers.any?
-
- unmet_dependency_names = unmet_dependency_names.call
- unless unmet_dependency_names.nil?
- if api_fetchers.size <= 1
- # can't do this when there are multiple fetchers because then we might not fetch from _all_
- # of them
- unmet_dependency_names -= remote_specs.spec_names # avoid re-fetching things we've already gotten
- end
- return if unmet_dependency_names.empty?
- end
-
- Bundler.ui.debug "Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"
-
- fetch_names(api_fetchers, unmet_dependency_names, specs, false)
- end
-
- def dependency_names_to_double_check
- names = []
- remote_specs.each do |spec|
- case spec
- when EndpointSpecification, Gem::Specification, StubSpecification, LazySpecification
- names.concat(spec.runtime_dependencies)
- when RemoteSpecification # from the full index
- return nil
- else
- raise "unhandled spec type (#{spec.inspect})"
- end
- end
- names.map!(&:name) if names
- names
- end
-
- protected
-
- def credless_remotes
- remotes.map(&method(:suppress_configured_credentials))
- end
-
- def remotes_for_spec(spec)
- specs.search_all(spec.name).inject([]) do |uris, s|
- uris << s.remote if s.remote
- uris
- end
- end
-
- def loaded_from(spec)
- "#{rubygems_dir}/specifications/#{spec.full_name}.gemspec"
- end
-
- def cached_gem(spec)
- cached_gem = cached_path(spec)
- unless cached_gem
- raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation"
- end
- cached_gem
- end
-
- def cached_path(spec)
- possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
- possibilities.find {|p| File.exist?(p) }
- end
-
- def normalize_uri(uri)
- uri = uri.to_s
- uri = "#{uri}/" unless uri =~ %r{/$}
- require_relative "../vendored_uri"
- uri = Bundler::URI(uri)
- raise ArgumentError, "The source must be an absolute URI. For example:\n" \
- "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(Bundler::URI::HTTP) && uri.host.nil?)
- uri
- end
-
- def suppress_configured_credentials(remote)
- remote_nouser = remove_auth(remote)
- if remote.userinfo && remote.userinfo == Bundler.settings[remote_nouser]
- remote_nouser
- else
- remote
- end
- end
-
- def remove_auth(remote)
- if remote.user || remote.password
- remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s
- else
- remote.to_s
- end
- end
-
- def installed_specs
- @installed_specs ||= Index.build do |idx|
- Bundler.rubygems.all_specs.reverse_each do |spec|
- next if spec.name == "bundler"
- spec.source = self
- if Bundler.rubygems.spec_missing_extensions?(spec, false)
- Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
- next
- end
- idx << spec
- end
- end
- end
-
- def cached_specs
- @cached_specs ||= begin
- idx = installed_specs.dup
-
- Dir["#{cache_path}/*.gem"].each do |gemfile|
- next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
- s ||= Bundler.rubygems.spec_from_gem(gemfile)
- s.source = self
- if Bundler.rubygems.spec_missing_extensions?(s, false)
- Bundler.ui.debug "Source #{self} is ignoring #{s} because it is missing extensions"
- next
- end
- idx << s
- end
-
- idx
- end
- end
-
- def api_fetchers
- fetchers.select {|f| f.use_api && f.fetchers.first.api_fetcher? }
- end
-
- def remote_specs
- @remote_specs ||= Index.build do |idx|
- index_fetchers = fetchers - api_fetchers
-
- # gather lists from non-api sites
- fetch_names(index_fetchers, nil, idx, false)
-
- # because ensuring we have all the gems we need involves downloading
- # the gemspecs of those gems, if the non-api sites contain more than
- # about 500 gems, we treat all sites as non-api for speed.
- allow_api = idx.size < API_REQUEST_LIMIT && dependency_names.size < API_REQUEST_LIMIT
- Bundler.ui.debug "Need to query more than #{API_REQUEST_LIMIT} gems." \
- " Downloading full index instead..." unless allow_api
-
- fetch_names(api_fetchers, allow_api && dependency_names, idx, false)
- end
- end
-
- def fetch_names(fetchers, dependency_names, index, override_dupes)
- fetchers.each do |f|
- if dependency_names
- Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug?
- index.use f.specs_with_retry(dependency_names, self), override_dupes
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
- else
- Bundler.ui.info "Fetching source index from #{f.uri}"
- index.use f.specs_with_retry(nil, self), override_dupes
- end
- end
- end
-
- def fetch_gem(spec)
- return false unless spec.remote
-
- spec.fetch_platform
-
- download_path = requires_sudo? ? Bundler.tmp(spec.full_name) : rubygems_dir
- gem_path = "#{rubygems_dir}/cache/#{spec.full_name}.gem"
-
- SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
- FileUtils.mkdir_p(p)
- end
- download_gem(spec, download_path)
-
- if requires_sudo?
- SharedHelpers.filesystem_access("#{rubygems_dir}/cache") do |p|
- Bundler.mkdir_p(p)
- end
- Bundler.sudo "mv #{download_path}/cache/#{spec.full_name}.gem #{gem_path}"
- end
-
- gem_path
- ensure
- Bundler.rm_rf(download_path) if requires_sudo?
- end
-
- def builtin_gem?(spec)
- # Ruby 2.1, where all included gems have this summary
- return true if spec.summary =~ /is bundled with Ruby/
-
- # Ruby 2.0, where gemspecs are stored in specifications/default/
- spec.loaded_from && spec.loaded_from.include?("specifications/default/")
- end
-
- def installed?(spec)
- installed_specs[spec].any?
- end
-
- def requires_sudo?
- Bundler.requires_sudo?
- end
-
- def rubygems_dir
- Bundler.rubygems.gem_dir
- end
-
- def cache_path
- Bundler.app_cache
- end
-
- private
-
- # Checks if the requested spec exists in the global cache. If it does,
- # we copy it to the download path, and if it does not, we download it.
- #
- # @param [Specification] spec
- # the spec we want to download or retrieve from the cache.
- #
- # @param [String] download_path
- # the local directory the .gem will end up in.
- #
- def download_gem(spec, download_path)
- local_path = File.join(download_path, "cache/#{spec.full_name}.gem")
-
- if (cache_path = download_cache_path(spec)) && cache_path.file?
- SharedHelpers.filesystem_access(local_path) do
- FileUtils.cp(cache_path, local_path)
- end
- else
- uri = spec.remote.uri
- Bundler.ui.confirm("Fetching #{version_message(spec)}")
- rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path)
- if rubygems_local_path != local_path
- FileUtils.mv(rubygems_local_path, local_path)
- end
- cache_globally(spec, local_path)
- end
- end
-
- # Checks if the requested spec exists in the global cache. If it does
- # not, we create the relevant global cache subdirectory if it does not
- # exist and copy the spec from the local cache to the global cache.
- #
- # @param [Specification] spec
- # the spec we want to copy to the global cache.
- #
- # @param [String] local_cache_path
- # the local directory from which we want to copy the .gem.
- #
- def cache_globally(spec, local_cache_path)
- return unless cache_path = download_cache_path(spec)
- return if cache_path.exist?
-
- SharedHelpers.filesystem_access(cache_path.dirname, &:mkpath)
- SharedHelpers.filesystem_access(cache_path) do
- FileUtils.cp(local_cache_path, cache_path)
- end
- end
-
- # Returns the global cache path of the calling Rubygems::Source object.
- #
- # Note that the Source determines the path's subdirectory. We use this
- # subdirectory in the global cache path so that gems with the same name
- # -- and possibly different versions -- from different sources are saved
- # to their respective subdirectories and do not override one another.
- #
- # @param [Gem::Specification] specification
- #
- # @return [Pathname] The global cache path.
- #
- def download_cache_path(spec)
- return unless Bundler.feature_flag.global_gem_cache?
- return unless remote = spec.remote
- return unless cache_slug = remote.cache_slug
-
- Bundler.user_cache.join("gems", cache_slug, spec.file_name)
- end
-
- def extension_cache_slug(spec)
- return unless remote = spec.remote
- remote.cache_slug
- end
- end
- end
-end
diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb
deleted file mode 100644
index 45ea61acb2..0000000000
--- a/lib/bundler/source/rubygems/remote.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Source
- class Rubygems
- class Remote
- attr_reader :uri, :anonymized_uri, :original_uri
-
- def initialize(uri)
- orig_uri = uri
- uri = Bundler.settings.mirror_for(uri)
- @original_uri = orig_uri if orig_uri != uri
- fallback_auth = Bundler.settings.credentials_for(uri)
-
- @uri = apply_auth(uri, fallback_auth).freeze
- @anonymized_uri = remove_auth(@uri).freeze
- end
-
- # @return [String] A slug suitable for use as a cache key for this
- # remote.
- #
- def cache_slug
- @cache_slug ||= begin
- return nil unless SharedHelpers.md5_available?
-
- cache_uri = original_uri || uri
-
- host = cache_uri.to_s.start_with?("file://") ? nil : cache_uri.host
-
- uri_parts = [host, cache_uri.user, cache_uri.port, cache_uri.path]
- uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join("."))
-
- uri_parts[-1] = uri_digest
- uri_parts.compact.join(".")
- end
- end
-
- def to_s
- "rubygems remote at #{anonymized_uri}"
- end
-
- private
-
- def apply_auth(uri, auth)
- if auth && uri.userinfo.nil?
- uri = uri.dup
- uri.userinfo = auth
- end
-
- uri
- rescue Bundler::URI::InvalidComponentError
- error_message = "Please CGI escape your usernames and passwords before " \
- "setting them for authentication."
- raise HTTPError.new(error_message)
- end
-
- def remove_auth(uri)
- if uri.userinfo
- uri = uri.dup
- uri.user = uri.password = nil
- end
-
- uri
- end
- end
- end
- end
-end
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
deleted file mode 100644
index d3f649a12c..0000000000
--- a/lib/bundler/source_list.rb
+++ /dev/null
@@ -1,183 +0,0 @@
-# frozen_string_literal: true
-
-require "set"
-
-module Bundler
- class SourceList
- attr_reader :path_sources,
- :git_sources,
- :plugin_sources,
- :global_rubygems_source,
- :metadata_source
-
- def initialize
- @path_sources = []
- @git_sources = []
- @plugin_sources = []
- @global_rubygems_source = nil
- @rubygems_aggregate = rubygems_aggregate_class.new
- @rubygems_sources = []
- @metadata_source = Source::Metadata.new
- end
-
- def add_path_source(options = {})
- if options["gemspec"]
- add_source_to_list Source::Gemspec.new(options), path_sources
- else
- add_source_to_list Source::Path.new(options), path_sources
- end
- end
-
- def add_git_source(options = {})
- add_source_to_list(Source::Git.new(options), git_sources).tap do |source|
- warn_on_git_protocol(source)
- end
- end
-
- def add_rubygems_source(options = {})
- add_source_to_list Source::Rubygems.new(options), @rubygems_sources
- end
-
- def add_plugin_source(source, options = {})
- add_source_to_list Plugin.source(source).new(options), @plugin_sources
- end
-
- def global_rubygems_source=(uri)
- if Bundler.feature_flag.disable_multisource?
- @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri)
- end
- add_rubygems_remote(uri)
- end
-
- def add_rubygems_remote(uri)
- return if Bundler.feature_flag.disable_multisource?
- @rubygems_aggregate.add_remote(uri)
- @rubygems_aggregate
- end
-
- def default_source
- global_rubygems_source || @rubygems_aggregate
- end
-
- def rubygems_sources
- @rubygems_sources + [default_source]
- end
-
- def rubygems_remotes
- rubygems_sources.map(&:remotes).flatten.uniq
- end
-
- def all_sources
- path_sources + git_sources + plugin_sources + rubygems_sources + [metadata_source]
- end
-
- def get(source)
- source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
- end
-
- def lock_sources
- lock_sources = (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
- if Bundler.feature_flag.disable_multisource?
- lock_sources + rubygems_sources.sort_by(&:to_s)
- else
- lock_sources << combine_rubygems_sources
- end
- end
-
- # Returns true if there are changes
- def replace_sources!(replacement_sources)
- return true if replacement_sources.empty?
-
- [path_sources, git_sources, plugin_sources].each do |source_list|
- source_list.map! do |source|
- replacement_sources.find {|s| s == source } || source
- end
- end
-
- replacement_rubygems = !Bundler.feature_flag.disable_multisource? &&
- replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
- @rubygems_aggregate = replacement_rubygems if replacement_rubygems
-
- return true if !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
- return true if replacement_rubygems && rubygems_remotes.to_set != replacement_rubygems.remotes.to_set
-
- false
- end
-
- def cached!
- all_sources.each(&:cached!)
- end
-
- def remote!
- all_sources.each(&:remote!)
- end
-
- def rubygems_primary_remotes
- @rubygems_aggregate.remotes
- end
-
- private
-
- def rubygems_aggregate_class
- Source::Rubygems
- end
-
- def add_source_to_list(source, list)
- list.unshift(source).uniq!
- source
- end
-
- def source_list_for(source)
- case source
- when Source::Git then git_sources
- when Source::Path then path_sources
- when Source::Rubygems then rubygems_sources
- when Plugin::API::Source then plugin_sources
- else raise ArgumentError, "Invalid source: #{source.inspect}"
- end
- end
-
- def combine_rubygems_sources
- Source::Rubygems.new("remotes" => rubygems_remotes)
- end
-
- def warn_on_git_protocol(source)
- return if Bundler.settings["git.allow_insecure"]
-
- if source.uri =~ /^git\:/
- Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \
- "which transmits data without encryption. Disable this warning with " \
- "`bundle config set git.allow_insecure true`, or switch to the `https` " \
- "protocol to keep your data secure."
- end
- end
-
- def equal_sources?(lock_sources, replacement_sources)
- lock_sources.to_set == replacement_sources.to_set
- end
-
- def equal_source?(source, other_source)
- source == other_source
- end
-
- def equivalent_source?(source, other_source)
- return false unless Bundler.settings[:allow_deployment_source_credential_changes] && source.is_a?(Source::Rubygems)
-
- equivalent_rubygems_sources?([source], [other_source])
- end
-
- def equivalent_sources?(lock_sources, replacement_sources)
- return false unless Bundler.settings[:allow_deployment_source_credential_changes]
-
- lock_rubygems_sources, lock_other_sources = lock_sources.partition {|s| s.is_a?(Source::Rubygems) }
- replacement_rubygems_sources, replacement_other_sources = replacement_sources.partition {|s| s.is_a?(Source::Rubygems) }
-
- equivalent_rubygems_sources?(lock_rubygems_sources, replacement_rubygems_sources) && equal_sources?(lock_other_sources, replacement_other_sources)
- end
-
- def equivalent_rubygems_sources?(lock_sources, replacement_sources)
- actual_remotes = replacement_sources.map(&:remotes).flatten.uniq
- lock_sources.all? {|s| s.equivalent_remotes?(actual_remotes) }
- end
- end
-end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
deleted file mode 100644
index 463113ef8e..0000000000
--- a/lib/bundler/spec_set.rb
+++ /dev/null
@@ -1,203 +0,0 @@
-# frozen_string_literal: true
-
-require "tsort"
-require "set"
-
-module Bundler
- class SpecSet
- include Enumerable
- include TSort
-
- def initialize(specs)
- @specs = specs
- end
-
- def for(dependencies, skip = [], check = false, match_current_platform = false, raise_on_missing = true)
- handled = Set.new
- deps = dependencies.dup
- specs = []
- skip += ["bundler"]
-
- loop do
- break unless dep = deps.shift
- next if !handled.add?(dep) || skip.include?(dep.name)
-
- if spec = spec_for_dependency(dep, match_current_platform)
- specs << spec
-
- spec.dependencies.each do |d|
- next if d.type == :development
- d = DepProxy.new(d, dep.__platform) unless match_current_platform
- deps << d
- end
- elsif check
- return false
- elsif raise_on_missing
- others = lookup[dep.name] if match_current_platform
- message = "Unable to find a spec satisfying #{dep} in the set. Perhaps the lockfile is corrupted?"
- message += " Found #{others.join(", ")} that did not match the current platform." if others && !others.empty?
- raise GemNotFound, message
- end
- end
-
- if spec = lookup["bundler"].first
- specs << spec
- end
-
- check ? true : SpecSet.new(specs)
- end
-
- def valid_for?(deps)
- self.for(deps, [], true)
- end
-
- def [](key)
- key = key.name if key.respond_to?(:name)
- lookup[key].reverse
- end
-
- def []=(key, value)
- @specs << value
- @lookup = nil
- @sorted = nil
- end
-
- def sort!
- self
- end
-
- def to_a
- sorted.dup
- end
-
- def to_hash
- lookup.dup
- end
-
- def materialize(deps, missing_specs = nil)
- materialized = self.for(deps, [], false, true, !missing_specs).to_a
- deps = materialized.map(&:name).uniq
- materialized.map! do |s|
- next s unless s.is_a?(LazySpecification)
- s.source.dependency_names = deps if s.source.respond_to?(:dependency_names=)
- spec = s.__materialize__
- unless spec
- unless missing_specs
- raise GemNotFound, "Could not find #{s.full_name} in any of the sources"
- end
- missing_specs << s
- end
- spec
- end
- SpecSet.new(missing_specs ? materialized.compact : materialized)
- end
-
- # Materialize for all the specs in the spec set, regardless of what platform they're for
- # This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform)
- # @return [Array<Gem::Specification>]
- def materialized_for_all_platforms
- names = @specs.map(&:name).uniq
- @specs.map do |s|
- next s unless s.is_a?(LazySpecification)
- s.source.dependency_names = names if s.source.respond_to?(:dependency_names=)
- spec = s.__materialize__
- raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
- spec
- end
- end
-
- def merge(set)
- arr = sorted.dup
- set.each do |set_spec|
- full_name = set_spec.full_name
- next if arr.any? {|spec| spec.full_name == full_name }
- arr << set_spec
- end
- SpecSet.new(arr)
- end
-
- def find_by_name_and_platform(name, platform)
- @specs.detect {|spec| spec.name == name && spec.match_platform(platform) }
- end
-
- def what_required(spec)
- unless req = find {|s| s.dependencies.any? {|d| d.type == :runtime && d.name == spec.name } }
- return [spec]
- end
- what_required(req) << spec
- end
-
- def <<(spec)
- @specs << spec
- end
-
- def length
- @specs.length
- end
-
- def size
- @specs.size
- end
-
- def empty?
- @specs.empty?
- end
-
- def each(&b)
- sorted.each(&b)
- end
-
- private
-
- def sorted
- rake = @specs.find {|s| s.name == "rake" }
- begin
- @sorted ||= ([rake] + tsort).compact.uniq
- rescue TSort::Cyclic => error
- cgems = extract_circular_gems(error)
- raise CyclicDependencyError, "Your bundle requires gems that depend" \
- " on each other, creating an infinite loop. Please remove either" \
- " gem '#{cgems[1]}' or gem '#{cgems[0]}' and try again."
- end
- end
-
- def extract_circular_gems(error)
- error.message.scan(/@name="(.*?)"/).flatten
- end
-
- def lookup
- @lookup ||= begin
- lookup = Hash.new {|h, k| h[k] = [] }
- Index.sort_specs(@specs).reverse_each do |s|
- lookup[s.name] << s
- end
- lookup
- end
- end
-
- def tsort_each_node
- # MUST sort by name for backwards compatibility
- @specs.sort_by(&:name).each {|s| yield s }
- end
-
- def spec_for_dependency(dep, match_current_platform)
- specs_for_platforms = lookup[dep.name]
- if match_current_platform
- Bundler.rubygems.platforms.reverse_each do |pl|
- match = GemHelpers.select_best_platform_match(specs_for_platforms, pl)
- return match if match
- end
- nil
- else
- GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
- end
- end
-
- def tsort_each_child(s)
- s.dependencies.sort_by(&:name).each do |d|
- next if d.type == :development
- lookup[d.name].each {|s2| yield s2 }
- end
- end
- end
-end
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
deleted file mode 100644
index d45f80a80a..0000000000
--- a/lib/bundler/stub_specification.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "remote_specification"
-
-module Bundler
- class StubSpecification < RemoteSpecification
- def self.from_stub(stub)
- return stub if stub.is_a?(Bundler::StubSpecification)
- spec = new(stub.name, stub.version, stub.platform, nil)
- spec.stub = stub
- spec
- end
-
- attr_accessor :stub, :ignored
-
- def source=(source)
- super
- # Stub has no concept of source, which means that extension_dir may be wrong
- # This is the case for git-based gems. So, instead manually assign the extension dir
- return unless source.respond_to?(:extension_dir_name)
- path = File.join(stub.extensions_dir, source.extension_dir_name)
- stub.extension_dir = File.expand_path(path)
- end
-
- def to_yaml
- _remote_specification.to_yaml
- end
-
- # @!group Stub Delegates
-
- # This is defined directly to avoid having to load every installed spec
- def missing_extensions?
- stub.missing_extensions?
- end
-
- def activated
- stub.activated
- end
-
- def activated=(activated)
- stub.instance_variable_set(:@activated, activated)
- end
-
- def default_gem
- stub.default_gem
- end
-
- def full_gem_path
- # deleted gems can have their stubs return nil, so in that case grab the
- # expired path from the full spec
- stub.full_gem_path || method_missing(:full_gem_path)
- end
-
- def full_require_paths
- stub.full_require_paths
- end
-
- def load_paths
- full_require_paths
- end
-
- def loaded_from
- stub.loaded_from
- end
-
- def matches_for_glob(glob)
- stub.matches_for_glob(glob)
- end
-
- def raw_require_paths
- stub.raw_require_paths
- end
-
- private
-
- def _remote_specification
- @_remote_specification ||= begin
- rs = stub.to_spec
- if rs.equal?(self) # happens when to_spec gets the spec from Gem.loaded_specs
- rs = Gem::Specification.load(loaded_from)
- Bundler.rubygems.stub_set_spec(stub, rs)
- end
-
- unless rs
- raise GemspecError, "The gemspec for #{full_name} at #{loaded_from}" \
- " was missing or broken. Try running `gem pristine #{name} -v #{version}`" \
- " to fix the cached spec."
- end
-
- rs.source = source
-
- rs
- end
- end
- end
-end
diff --git a/lib/bundler/templates/.document b/lib/bundler/templates/.document
deleted file mode 100644
index fb66f13c33..0000000000
--- a/lib/bundler/templates/.document
+++ /dev/null
@@ -1 +0,0 @@
-# Ignore all files in this directory
diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable
deleted file mode 100644
index 3e8d5b317a..0000000000
--- a/lib/bundler/templates/Executable
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
-# frozen_string_literal: true
-
-#
-# This file was generated by Bundler.
-#
-# The application '<%= executable %>' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "pathname"
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",
- Pathname.new(__FILE__).realpath)
-
-bundle_binstub = File.expand_path("../bundle", __FILE__)
-
-if File.file?(bundle_binstub)
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
- load(bundle_binstub)
- else
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
-Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
- end
-end
-
-require "rubygems"
-require "bundler/setup"
-
-load Gem.bin_path("<%= spec.name %>", "<%= executable %>")
diff --git a/lib/bundler/templates/Executable.bundler b/lib/bundler/templates/Executable.bundler
deleted file mode 100644
index 69f26bb9c0..0000000000
--- a/lib/bundler/templates/Executable.bundler
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
-# frozen_string_literal: true
-
-#
-# This file was generated by Bundler.
-#
-# The application '<%= executable %>' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "rubygems"
-
-m = Module.new do
- module_function
-
- def invoked_as_script?
- File.expand_path($0) == File.expand_path(__FILE__)
- end
-
- def env_var_version
- ENV["BUNDLER_VERSION"]
- end
-
- def cli_arg_version
- return unless invoked_as_script? # don't want to hijack other binstubs
- return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
- bundler_version = nil
- update_index = nil
- ARGV.each_with_index do |a, i|
- if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
- bundler_version = a
- end
- next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
- bundler_version = $1
- update_index = i
- end
- bundler_version
- end
-
- def gemfile
- gemfile = ENV["BUNDLE_GEMFILE"]
- return gemfile if gemfile && !gemfile.empty?
-
- File.expand_path("../<%= relative_gemfile_path %>", __FILE__)
- end
-
- def lockfile
- lockfile =
- case File.basename(gemfile)
- when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
- else "#{gemfile}.lock"
- end
- File.expand_path(lockfile)
- end
-
- def lockfile_version
- return unless File.file?(lockfile)
- lockfile_contents = File.read(lockfile)
- return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
- Regexp.last_match(1)
- end
-
- def bundler_version
- @bundler_version ||=
- env_var_version || cli_arg_version ||
- lockfile_version
- end
-
- def bundler_requirement
- return "#{Gem::Requirement.default}.a" unless bundler_version
-
- bundler_gem_version = Gem::Version.new(bundler_version)
-
- requirement = bundler_gem_version.approximate_recommendation
-
- return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
-
- requirement += ".a" if bundler_gem_version.prerelease?
-
- requirement
- end
-
- def load_bundler!
- ENV["BUNDLE_GEMFILE"] ||= gemfile
-
- activate_bundler
- end
-
- def activate_bundler
- gem_error = activation_error_handling do
- gem "bundler", bundler_requirement
- end
- return if gem_error.nil?
- require_error = activation_error_handling do
- require "bundler/version"
- end
- return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
- warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
- exit 42
- end
-
- def activation_error_handling
- yield
- nil
- rescue StandardError, LoadError => e
- e
- end
-end
-
-m.load_bundler!
-
-if m.invoked_as_script?
- load Gem.bin_path("<%= spec.name %>", "<%= executable %>")
-end
diff --git a/lib/bundler/templates/Executable.standalone b/lib/bundler/templates/Executable.standalone
deleted file mode 100644
index 4bf0753f44..0000000000
--- a/lib/bundler/templates/Executable.standalone
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
-#
-# This file was generated by Bundler.
-#
-# The application '<%= executable %>' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "pathname"
-path = Pathname.new(__FILE__)
-$:.unshift File.expand_path "../<%= standalone_path %>", path.realpath
-
-require "bundler/setup"
-load File.expand_path "../<%= executable_path %>", path.realpath
diff --git a/lib/bundler/templates/Gemfile b/lib/bundler/templates/Gemfile
deleted file mode 100644
index 1afd2cce67..0000000000
--- a/lib/bundler/templates/Gemfile
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-source "https://rubygems.org"
-
-git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
-
-# gem "rails"
diff --git a/lib/bundler/templates/gems.rb b/lib/bundler/templates/gems.rb
deleted file mode 100644
index 547cd6e8d9..0000000000
--- a/lib/bundler/templates/gems.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-# A sample gems.rb
-source "https://rubygems.org"
-
-git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
-
-# gem "rails"
diff --git a/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt b/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
deleted file mode 100644
index 7dfd14aab9..0000000000
--- a/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
+++ /dev/null
@@ -1,74 +0,0 @@
-# Contributor Covenant Code of Conduct
-
-## Our Pledge
-
-In the interest of fostering an open and welcoming environment, we as
-contributors and maintainers pledge to making participation in our project and
-our community a harassment-free experience for everyone, regardless of age, body
-size, disability, ethnicity, gender identity and expression, level of experience,
-nationality, personal appearance, race, religion, or sexual identity and
-orientation.
-
-## Our Standards
-
-Examples of behavior that contributes to creating a positive environment
-include:
-
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery and unwelcome sexual attention or
-advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
-
-## Our Responsibilities
-
-Project maintainers are responsible for clarifying the standards of acceptable
-behavior and are expected to take appropriate and fair corrective action in
-response to any instances of unacceptable behavior.
-
-Project maintainers have the right and responsibility to remove, edit, or
-reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct, or to ban temporarily or
-permanently any contributor for other behaviors that they deem inappropriate,
-threatening, offensive, or harmful.
-
-## Scope
-
-This Code of Conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community. Examples of
-representing a project or community include using an official project e-mail
-address, posting via an official social media account, or acting as an appointed
-representative at an online or offline event. Representation of a project may be
-further defined and clarified by project maintainers.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting the project team at <%= config[:email] %>. All
-complaints will be reviewed and investigated and will result in a response that
-is deemed necessary and appropriate to the circumstances. The project team is
-obligated to maintain confidentiality with regard to the reporter of an incident.
-Further details of specific enforcement policies may be posted separately.
-
-Project maintainers who do not follow or enforce the Code of Conduct in good
-faith may face temporary or permanent repercussions as determined by other
-members of the project's leadership.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
-available at [https://contributor-covenant.org/version/1/4][version]
-
-[homepage]: https://contributor-covenant.org
-[version]: https://contributor-covenant.org/version/1/4/
diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt
deleted file mode 100644
index 83878ec7f8..0000000000
--- a/lib/bundler/templates/newgem/Gemfile.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-source "https://rubygems.org"
-
-# Specify your gem's dependencies in <%= config[:name] %>.gemspec
-gemspec
-
-gem "rake", "~> 12.0"
-<%- if config[:ext] -%>
-gem "rake-compiler"
-<%- end -%>
-<%- if config[:test] -%>
-gem "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
-<%- end -%>
diff --git a/lib/bundler/templates/newgem/LICENSE.txt.tt b/lib/bundler/templates/newgem/LICENSE.txt.tt
deleted file mode 100644
index 76ef4b0191..0000000000
--- a/lib/bundler/templates/newgem/LICENSE.txt.tt
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) <%= Time.now.year %> <%= config[:author] %>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt
deleted file mode 100644
index c2f5f9dca7..0000000000
--- a/lib/bundler/templates/newgem/README.md.tt
+++ /dev/null
@@ -1,48 +0,0 @@
-# <%= config[:constant_name] %>
-
-Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/<%= config[:namespaced_path] %>`. To experiment with that code, run `bin/console` for an interactive prompt.
-
-TODO: Delete this and the text above, and describe your gem
-
-## Installation
-
-Add this line to your application's Gemfile:
-
-```ruby
-gem '<%= config[:name] %>'
-```
-
-And then execute:
-
- $ bundle install
-
-Or install it yourself as:
-
- $ gem install <%= config[:name] %>
-
-## Usage
-
-TODO: Write usage instructions here
-
-## Development
-
-After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test].sub('mini', '').sub('rspec', 'spec') %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %>
-
-To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
-
-## Contributing
-
-Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).<% end %>
-
-<% if config[:mit] -%>
-
-## License
-
-The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
-<% end -%>
-<% if config[:coc] -%>
-
-## Code of Conduct
-
-Everyone interacting in the <%= config[:constant_name] %> project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).
-<% end -%>
diff --git a/lib/bundler/templates/newgem/Rakefile.tt b/lib/bundler/templates/newgem/Rakefile.tt
deleted file mode 100644
index 099da6f3ec..0000000000
--- a/lib/bundler/templates/newgem/Rakefile.tt
+++ /dev/null
@@ -1,29 +0,0 @@
-require "bundler/gem_tasks"
-<% if config[:test] == "minitest" -%>
-require "rake/testtask"
-
-Rake::TestTask.new(:test) do |t|
- t.libs << "test"
- t.libs << "lib"
- t.test_files = FileList["test/**/*_test.rb"]
-end
-
-<% elsif config[:test] == "rspec" -%>
-require "rspec/core/rake_task"
-
-RSpec::Core::RakeTask.new(:spec)
-
-<% end -%>
-<% if config[:ext] -%>
-require "rake/extensiontask"
-
-task :build => :compile
-
-Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext|
- ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
-end
-
-task :default => [:clobber, :compile, :<%= config[:test_task] %>]
-<% else -%>
-task :default => :<%= config[:test_task] %>
-<% end -%>
diff --git a/lib/bundler/templates/newgem/bin/console.tt b/lib/bundler/templates/newgem/bin/console.tt
deleted file mode 100644
index a27f82430f..0000000000
--- a/lib/bundler/templates/newgem/bin/console.tt
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-
-require "bundler/setup"
-require "<%= config[:namespaced_path] %>"
-
-# You can add fixtures and/or initialization code here to make experimenting
-# with your gem easier. You can also use a different console, if you like.
-
-# (If you use this, don't forget to add pry to your Gemfile!)
-# require "pry"
-# Pry.start
-
-require "irb"
-IRB.start(__FILE__)
diff --git a/lib/bundler/templates/newgem/bin/setup.tt b/lib/bundler/templates/newgem/bin/setup.tt
deleted file mode 100644
index dce67d860a..0000000000
--- a/lib/bundler/templates/newgem/bin/setup.tt
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-IFS=$'\n\t'
-set -vx
-
-bundle install
-
-# Do any other automated setup that you need to do here
diff --git a/lib/bundler/templates/newgem/exe/newgem.tt b/lib/bundler/templates/newgem/exe/newgem.tt
deleted file mode 100644
index a8339bb79f..0000000000
--- a/lib/bundler/templates/newgem/exe/newgem.tt
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-
-require "<%= config[:namespaced_path] %>"
diff --git a/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt b/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt
deleted file mode 100644
index 8cfc828f94..0000000000
--- a/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt
+++ /dev/null
@@ -1,3 +0,0 @@
-require "mkmf"
-
-create_makefile(<%= config[:makefile_path].inspect %>)
diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt b/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
deleted file mode 100644
index 8177c4d202..0000000000
--- a/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "<%= config[:underscored_name] %>.h"
-
-VALUE rb_m<%= config[:constant_array].join %>;
-
-void
-Init_<%= config[:underscored_name] %>(void)
-{
- rb_m<%= config[:constant_array].join %> = rb_define_module(<%= config[:constant_name].inspect %>);
-}
diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt b/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt
deleted file mode 100644
index c6e420b66e..0000000000
--- a/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef <%= config[:underscored_name].upcase %>_H
-#define <%= config[:underscored_name].upcase %>_H 1
-
-#include "ruby.h"
-
-#endif /* <%= config[:underscored_name].upcase %>_H */
diff --git a/lib/bundler/templates/newgem/gitignore.tt b/lib/bundler/templates/newgem/gitignore.tt
deleted file mode 100644
index b1c9f9986c..0000000000
--- a/lib/bundler/templates/newgem/gitignore.tt
+++ /dev/null
@@ -1,20 +0,0 @@
-/.bundle/
-/.yardoc
-/_yardoc/
-/coverage/
-/doc/
-/pkg/
-/spec/reports/
-/tmp/
-<%- if config[:ext] -%>
-*.bundle
-*.so
-*.o
-*.a
-mkmf.log
-<%- end -%>
-<%- if config[:test] == "rspec" -%>
-
-# rspec failure tracking
-.rspec_status
-<%- end -%>
diff --git a/lib/bundler/templates/newgem/lib/newgem.rb.tt b/lib/bundler/templates/newgem/lib/newgem.rb.tt
deleted file mode 100644
index fae6337c3e..0000000000
--- a/lib/bundler/templates/newgem/lib/newgem.rb.tt
+++ /dev/null
@@ -1,13 +0,0 @@
-require "<%= config[:namespaced_path] %>/version"
-<%- if config[:ext] -%>
-require "<%= config[:namespaced_path] %>/<%= config[:underscored_name] %>"
-<%- end -%>
-
-<%- config[:constant_array].each_with_index do |c, i| -%>
-<%= " " * i %>module <%= c %>
-<%- end -%>
-<%= " " * config[:constant_array].size %>class Error < StandardError; end
-<%= " " * config[:constant_array].size %># Your code goes here...
-<%- (config[:constant_array].size-1).downto(0) do |i| -%>
-<%= " " * i %>end
-<%- end -%>
diff --git a/lib/bundler/templates/newgem/lib/newgem/version.rb.tt b/lib/bundler/templates/newgem/lib/newgem/version.rb.tt
deleted file mode 100644
index 389daf5048..0000000000
--- a/lib/bundler/templates/newgem/lib/newgem/version.rb.tt
+++ /dev/null
@@ -1,7 +0,0 @@
-<%- config[:constant_array].each_with_index do |c, i| -%>
-<%= " " * i %>module <%= c %>
-<%- end -%>
-<%= " " * config[:constant_array].size %>VERSION = "0.1.0"
-<%- (config[:constant_array].size-1).downto(0) do |i| -%>
-<%= " " * i %>end
-<%- end -%>
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
deleted file mode 100644
index 9bb3d0ff50..0000000000
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative 'lib/<%=config[:namespaced_path]%>/version'
-
-Gem::Specification.new do |spec|
- spec.name = <%= config[:name].inspect %>
- spec.version = <%= config[:constant_name] %>::VERSION
- spec.authors = [<%= config[:author].inspect %>]
- spec.email = [<%= config[:email].inspect %>]
-
- spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.}
- spec.description = %q{TODO: Write a longer description or delete this line.}
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
-<%- if config[:mit] -%>
- spec.license = "MIT"
-<%- end -%>
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
-
- spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
- spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-<%- if config[:ext] -%>
- spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
-<%- end -%>
-end
diff --git a/lib/bundler/templates/newgem/rspec.tt b/lib/bundler/templates/newgem/rspec.tt
deleted file mode 100644
index 34c5164d9b..0000000000
--- a/lib/bundler/templates/newgem/rspec.tt
+++ /dev/null
@@ -1,3 +0,0 @@
---format documentation
---color
---require spec_helper
diff --git a/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt b/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt
deleted file mode 100644
index c63b487830..0000000000
--- a/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt
+++ /dev/null
@@ -1,9 +0,0 @@
-RSpec.describe <%= config[:constant_name] %> do
- it "has a version number" do
- expect(<%= config[:constant_name] %>::VERSION).not_to be nil
- end
-
- it "does something useful" do
- expect(false).to eq(true)
- end
-end
diff --git a/lib/bundler/templates/newgem/spec/spec_helper.rb.tt b/lib/bundler/templates/newgem/spec/spec_helper.rb.tt
deleted file mode 100644
index 805cf57e01..0000000000
--- a/lib/bundler/templates/newgem/spec/spec_helper.rb.tt
+++ /dev/null
@@ -1,14 +0,0 @@
-require "bundler/setup"
-require "<%= config[:namespaced_path] %>"
-
-RSpec.configure do |config|
- # Enable flags like --only-failures and --next-failure
- config.example_status_persistence_file_path = ".rspec_status"
-
- # Disable RSpec exposing methods globally on `Module` and `main`
- config.disable_monkey_patching!
-
- config.expect_with :rspec do |c|
- c.syntax = :expect
- end
-end
diff --git a/lib/bundler/templates/newgem/test/newgem_test.rb.tt b/lib/bundler/templates/newgem/test/newgem_test.rb.tt
deleted file mode 100644
index f2af9f90e0..0000000000
--- a/lib/bundler/templates/newgem/test/newgem_test.rb.tt
+++ /dev/null
@@ -1,11 +0,0 @@
-require "test_helper"
-
-class <%= config[:constant_name] %>Test < Minitest::Test
- def test_that_it_has_a_version_number
- refute_nil ::<%= config[:constant_name] %>::VERSION
- end
-
- def test_it_does_something_useful
- assert false
- end
-end
diff --git a/lib/bundler/templates/newgem/test/test_helper.rb.tt b/lib/bundler/templates/newgem/test/test_helper.rb.tt
deleted file mode 100644
index 7d7db165ec..0000000000
--- a/lib/bundler/templates/newgem/test/test_helper.rb.tt
+++ /dev/null
@@ -1,4 +0,0 @@
-$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
-require "<%= config[:namespaced_path] %>"
-
-require "minitest/autorun"
diff --git a/lib/bundler/templates/newgem/travis.yml.tt b/lib/bundler/templates/newgem/travis.yml.tt
deleted file mode 100644
index eab16addca..0000000000
--- a/lib/bundler/templates/newgem/travis.yml.tt
+++ /dev/null
@@ -1,6 +0,0 @@
----
-language: ruby
-cache: bundler
-rvm:
- - <%= RUBY_VERSION %>
-before_install: gem install bundler -v <%= Bundler::VERSION %>
diff --git a/lib/bundler/ui.rb b/lib/bundler/ui.rb
deleted file mode 100644
index 7a4fa03669..0000000000
--- a/lib/bundler/ui.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module UI
- autoload :RGProxy, File.expand_path("ui/rg_proxy", __dir__)
- autoload :Shell, File.expand_path("ui/shell", __dir__)
- autoload :Silent, File.expand_path("ui/silent", __dir__)
- end
-end
diff --git a/lib/bundler/ui/rg_proxy.rb b/lib/bundler/ui/rg_proxy.rb
deleted file mode 100644
index ef6def225b..0000000000
--- a/lib/bundler/ui/rg_proxy.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../ui"
-require "rubygems/user_interaction"
-
-module Bundler
- module UI
- class RGProxy < ::Gem::SilentUI
- def initialize(ui)
- @ui = ui
- super()
- end
-
- def say(message)
- @ui && @ui.debug(message)
- end
- end
- end
-end
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
deleted file mode 100644
index 92476be7d2..0000000000
--- a/lib/bundler/ui/shell.rb
+++ /dev/null
@@ -1,142 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../vendored_thor"
-
-module Bundler
- module UI
- class Shell
- LEVELS = %w[silent error warn confirm info debug].freeze
-
- attr_writer :shell
-
- def initialize(options = {})
- Thor::Base.shell = options["no-color"] ? Thor::Shell::Basic : nil
- @shell = Thor::Base.shell.new
- @level = ENV["DEBUG"] ? "debug" : "info"
- @warning_history = []
- end
-
- def add_color(string, *color)
- @shell.set_color(string, *color)
- end
-
- def info(msg, newline = nil)
- tell_me(msg, nil, newline) if level("info")
- end
-
- def confirm(msg, newline = nil)
- tell_me(msg, :green, newline) if level("confirm")
- end
-
- def warn(msg, newline = nil)
- return unless level("warn")
- return if @warning_history.include? msg
- @warning_history << msg
-
- tell_err(msg, :yellow, newline)
- end
-
- def error(msg, newline = nil)
- return unless level("error")
- tell_err(msg, :red, newline)
- end
-
- def debug(msg, newline = nil)
- tell_me(msg, nil, newline) if debug?
- end
-
- def debug?
- level("debug")
- end
-
- def quiet?
- level("quiet")
- end
-
- def ask(msg)
- @shell.ask(msg)
- end
-
- def yes?(msg)
- @shell.yes?(msg)
- end
-
- def no?
- @shell.no?(msg)
- end
-
- def level=(level)
- raise ArgumentError unless LEVELS.include?(level.to_s)
- @level = level.to_s
- end
-
- def level(name = nil)
- return @level unless name
- unless index = LEVELS.index(name)
- raise "#{name.inspect} is not a valid level"
- end
- index <= LEVELS.index(@level)
- end
-
- def trace(e, newline = nil, force = false)
- return unless debug? || force
- msg = "#{e.class}: #{e.message}\n#{e.backtrace.join("\n ")}"
- tell_me(msg, nil, newline)
- end
-
- def silence(&blk)
- with_level("silent", &blk)
- end
-
- def unprinted_warnings
- []
- end
-
- private
-
- # valimism
- def tell_me(msg, color = nil, newline = nil)
- msg = word_wrap(msg) if newline.is_a?(Hash) && newline[:wrap]
- if newline.nil?
- @shell.say(msg, color)
- else
- @shell.say(msg, color, newline)
- end
- end
-
- def tell_err(message, color = nil, newline = nil)
- return if @shell.send(:stderr).closed?
-
- newline ||= message.to_s !~ /( |\t)\Z/
- message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap]
-
- color = nil if color && !$stderr.tty?
-
- buffer = @shell.send(:prepare_message, message, *color)
- buffer << "\n" if newline && !message.to_s.end_with?("\n")
-
- @shell.send(:stderr).print(buffer)
- @shell.send(:stderr).flush
- end
-
- def strip_leading_spaces(text)
- spaces = text[/\A\s+/, 0]
- spaces ? text.gsub(/#{spaces}/, "") : text
- end
-
- def word_wrap(text, line_width = @shell.terminal_width)
- strip_leading_spaces(text).split("\n").collect do |line|
- line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
- end * "\n"
- end
-
- def with_level(level)
- original = @level
- @level = level
- yield
- ensure
- @level = original
- end
- end
- end
-end
diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb
deleted file mode 100644
index dca1b2ac86..0000000000
--- a/lib/bundler/ui/silent.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module UI
- class Silent
- attr_writer :shell
-
- def initialize
- @warnings = []
- end
-
- def add_color(string, color)
- string
- end
-
- def info(message, newline = nil)
- end
-
- def confirm(message, newline = nil)
- end
-
- def warn(message, newline = nil)
- @warnings |= [message]
- end
-
- def error(message, newline = nil)
- end
-
- def debug(message, newline = nil)
- end
-
- def debug?
- false
- end
-
- def quiet?
- false
- end
-
- def ask(message)
- end
-
- def yes?(msg)
- raise "Cannot ask yes? with a silent shell"
- end
-
- def no?
- raise "Cannot ask no? with a silent shell"
- end
-
- def level=(name)
- end
-
- def level(name = nil)
- end
-
- def trace(message, newline = nil, force = false)
- end
-
- def silence
- yield
- end
-
- def unprinted_warnings
- @warnings
- end
- end
- end
-end
diff --git a/lib/bundler/uri_credentials_filter.rb b/lib/bundler/uri_credentials_filter.rb
deleted file mode 100644
index 9b9e9c2799..0000000000
--- a/lib/bundler/uri_credentials_filter.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module URICredentialsFilter
- module_function
-
- def credential_filtered_uri(uri_to_anonymize)
- return uri_to_anonymize if uri_to_anonymize.nil?
- uri = uri_to_anonymize.dup
- if uri.is_a?(String)
- require_relative "vendored_uri"
- uri = Bundler::URI(uri)
- end
-
- if uri.userinfo
- # oauth authentication
- if uri.password == "x-oauth-basic" || uri.password == "x"
- # URI as string does not display with password if no user is set
- oauth_designation = uri.password
- uri.user = oauth_designation
- end
- uri.password = nil
- end
- return uri.to_s if uri_to_anonymize.is_a?(String)
- uri
- rescue Bundler::URI::InvalidURIError # uri is not canonical uri scheme
- uri
- end
-
- def credential_filtered_string(str_to_filter, uri)
- return str_to_filter if uri.nil? || str_to_filter.nil?
- str_with_no_credentials = str_to_filter.dup
- anonymous_uri_str = credential_filtered_uri(uri).to_s
- uri_str = uri.to_s
- if anonymous_uri_str != uri_str
- str_with_no_credentials = str_with_no_credentials.gsub(uri_str, anonymous_uri_str)
- end
- str_with_no_credentials
- end
- end
-end
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
deleted file mode 100644
index fbcd26c765..0000000000
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-require_relative 'connection_pool/version'
-require_relative 'connection_pool/timed_stack'
-
-
-# Generic connection pool class for e.g. sharing a limited number of network connections
-# among many threads. Note: Connections are lazily created.
-#
-# Example usage with block (faster):
-#
-# @pool = Bundler::ConnectionPool.new { Redis.new }
-#
-# @pool.with do |redis|
-# redis.lpop('my-list') if redis.llen('my-list') > 0
-# end
-#
-# Using optional timeout override (for that single invocation)
-#
-# @pool.with(timeout: 2.0) do |redis|
-# redis.lpop('my-list') if redis.llen('my-list') > 0
-# end
-#
-# Example usage replacing an existing connection (slower):
-#
-# $redis = Bundler::ConnectionPool.wrap { Redis.new }
-#
-# def do_work
-# $redis.lpop('my-list') if $redis.llen('my-list') > 0
-# end
-#
-# Accepts the following options:
-# - :size - number of connections to pool, defaults to 5
-# - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
-#
-class Bundler::ConnectionPool
- DEFAULTS = {size: 5, timeout: 5}
-
- class Error < RuntimeError
- end
-
- def self.wrap(options, &block)
- Wrapper.new(options, &block)
- end
-
- def initialize(options = {}, &block)
- raise ArgumentError, 'Connection pool requires a block' unless block
-
- options = DEFAULTS.merge(options)
-
- @size = options.fetch(:size)
- @timeout = options.fetch(:timeout)
-
- @available = TimedStack.new(@size, &block)
- @key = :"current-#{@available.object_id}"
- @key_count = :"current-#{@available.object_id}-count"
- end
-
-if Thread.respond_to?(:handle_interrupt)
-
- # MRI
- def with(options = {})
- Thread.handle_interrupt(Exception => :never) do
- conn = checkout(options)
- begin
- Thread.handle_interrupt(Exception => :immediate) do
- yield conn
- end
- ensure
- checkin
- end
- end
- end
-
-else
-
- # jruby 1.7.x
- def with(options = {})
- conn = checkout(options)
- begin
- yield conn
- ensure
- checkin
- end
- end
-
-end
-
- def checkout(options = {})
- if ::Thread.current[@key]
- ::Thread.current[@key_count]+= 1
- ::Thread.current[@key]
- else
- ::Thread.current[@key_count]= 1
- ::Thread.current[@key]= @available.pop(options[:timeout] || @timeout)
- end
- end
-
- def checkin
- if ::Thread.current[@key]
- if ::Thread.current[@key_count] == 1
- @available.push(::Thread.current[@key])
- ::Thread.current[@key]= nil
- else
- ::Thread.current[@key_count]-= 1
- end
- else
- raise Bundler::ConnectionPool::Error, 'no connections are checked out'
- end
-
- nil
- end
-
- def shutdown(&block)
- @available.shutdown(&block)
- end
-
- # Size of this connection pool
- def size
- @size
- end
-
- # Number of pool entries available for checkout at this instant.
- def available
- @available.length
- end
-
- private
-
- class Wrapper < ::BasicObject
- METHODS = [:with, :pool_shutdown]
-
- def initialize(options = {}, &block)
- @pool = options.fetch(:pool) { ::Bundler::ConnectionPool.new(options, &block) }
- end
-
- def with(&block)
- @pool.with(&block)
- end
-
- def pool_shutdown(&block)
- @pool.shutdown(&block)
- end
-
- def pool_size
- @pool.size
- end
-
- def pool_available
- @pool.available
- end
-
- def respond_to?(id, *args)
- METHODS.include?(id) || with { |c| c.respond_to?(id, *args) }
- end
-
- def method_missing(name, *args, &block)
- with do |connection|
- connection.send(name, *args, &block)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb
deleted file mode 100644
index 5a9c4a27bb..0000000000
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# Global monotonic clock from Concurrent Ruby 1.0.
-# Copyright (c) Jerry D'Antonio -- released under the MIT license.
-# Slightly modified; used with permission.
-# https://github.com/ruby-concurrency/concurrent-ruby
-
-require 'thread'
-
-class Bundler::ConnectionPool
-
- class_definition = Class.new do
-
- if defined?(Process::CLOCK_MONOTONIC)
-
- # @!visibility private
- def get_time
- Process.clock_gettime(Process::CLOCK_MONOTONIC)
- end
-
- elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
-
- # @!visibility private
- def get_time
- java.lang.System.nanoTime() / 1_000_000_000.0
- end
-
- else
-
- # @!visibility private
- def initialize
- @mutex = Mutex.new
- @last_time = Time.now.to_f
- end
-
- # @!visibility private
- def get_time
- @mutex.synchronize do
- now = Time.now.to_f
- if @last_time < now
- @last_time = now
- else # clock has moved back in time
- @last_time += 0.000_001
- end
- end
- end
- end
- end
-
- ##
- # Clock that cannot be set and represents monotonic time since
- # some unspecified starting point.
- #
- # @!visibility private
- GLOBAL_MONOTONIC_CLOCK = class_definition.new
- private_constant :GLOBAL_MONOTONIC_CLOCK
-
- class << self
- ##
- # Returns the current time a tracked by the application monotonic clock.
- #
- # @return [Float] The current monotonic time when `since` not given else
- # the elapsed monotonic time between `since` and the current time
- def monotonic_time
- GLOBAL_MONOTONIC_CLOCK.get_time
- end
- end
-end
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb
deleted file mode 100644
index f3fe1e04ad..0000000000
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb
+++ /dev/null
@@ -1,176 +0,0 @@
-require 'thread'
-require 'timeout'
-require_relative 'monotonic_time'
-
-##
-# Raised when you attempt to retrieve a connection from a pool that has been
-# shut down.
-
-class Bundler::ConnectionPool::PoolShuttingDownError < RuntimeError; end
-
-##
-# The TimedStack manages a pool of homogeneous connections (or any resource
-# you wish to manage). Connections are created lazily up to a given maximum
-# number.
-
-# Examples:
-#
-# ts = TimedStack.new(1) { MyConnection.new }
-#
-# # fetch a connection
-# conn = ts.pop
-#
-# # return a connection
-# ts.push conn
-#
-# conn = ts.pop
-# ts.pop timeout: 5
-# #=> raises Timeout::Error after 5 seconds
-
-class Bundler::ConnectionPool::TimedStack
- attr_reader :max
-
- ##
- # Creates a new pool with +size+ connections that are created from the given
- # +block+.
-
- def initialize(size = 0, &block)
- @create_block = block
- @created = 0
- @que = []
- @max = size
- @mutex = Mutex.new
- @resource = ConditionVariable.new
- @shutdown_block = nil
- end
-
- ##
- # Returns +obj+ to the stack. +options+ is ignored in TimedStack but may be
- # used by subclasses that extend TimedStack.
-
- def push(obj, options = {})
- @mutex.synchronize do
- if @shutdown_block
- @shutdown_block.call(obj)
- else
- store_connection obj, options
- end
-
- @resource.broadcast
- end
- end
- alias_method :<<, :push
-
- ##
- # Retrieves a connection from the stack. If a connection is available it is
- # immediately returned. If no connection is available within the given
- # timeout a Timeout::Error is raised.
- #
- # +:timeout+ is the only checked entry in +options+ and is preferred over
- # the +timeout+ argument (which will be removed in a future release). Other
- # options may be used by subclasses that extend TimedStack.
-
- def pop(timeout = 0.5, options = {})
- options, timeout = timeout, 0.5 if Hash === timeout
- timeout = options.fetch :timeout, timeout
-
- deadline = Bundler::ConnectionPool.monotonic_time + timeout
- @mutex.synchronize do
- loop do
- raise Bundler::ConnectionPool::PoolShuttingDownError if @shutdown_block
- return fetch_connection(options) if connection_stored?(options)
-
- connection = try_create(options)
- return connection if connection
-
- to_wait = deadline - Bundler::ConnectionPool.monotonic_time
- raise Timeout::Error, "Waited #{timeout} sec" if to_wait <= 0
- @resource.wait(@mutex, to_wait)
- end
- end
- end
-
- ##
- # Shuts down the TimedStack which prevents connections from being checked
- # out. The +block+ is called once for each connection on the stack.
-
- def shutdown(&block)
- raise ArgumentError, "shutdown must receive a block" unless block_given?
-
- @mutex.synchronize do
- @shutdown_block = block
- @resource.broadcast
-
- shutdown_connections
- end
- end
-
- ##
- # Returns +true+ if there are no available connections.
-
- def empty?
- (@created - @que.length) >= @max
- end
-
- ##
- # The number of connections available on the stack.
-
- def length
- @max - @created + @que.length
- end
-
- private
-
- ##
- # This is an extension point for TimedStack and is called with a mutex.
- #
- # This method must returns true if a connection is available on the stack.
-
- def connection_stored?(options = nil)
- !@que.empty?
- end
-
- ##
- # This is an extension point for TimedStack and is called with a mutex.
- #
- # This method must return a connection from the stack.
-
- def fetch_connection(options = nil)
- @que.pop
- end
-
- ##
- # This is an extension point for TimedStack and is called with a mutex.
- #
- # This method must shut down all connections on the stack.
-
- def shutdown_connections(options = nil)
- while connection_stored?(options)
- conn = fetch_connection(options)
- @shutdown_block.call(conn)
- end
- end
-
- ##
- # This is an extension point for TimedStack and is called with a mutex.
- #
- # This method must return +obj+ to the stack.
-
- def store_connection(obj, options = nil)
- @que.push obj
- end
-
- ##
- # This is an extension point for TimedStack and is called with a mutex.
- #
- # This method must create a connection if and only if the total number of
- # connections allowed has not been met.
-
- def try_create(options = nil)
- unless @created == @max
- object = @create_block.call
- @created += 1
- object
- end
- end
-end
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
deleted file mode 100644
index b149c0e242..0000000000
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Bundler::ConnectionPool
- VERSION = "2.2.2"
-end
diff --git a/lib/bundler/vendor/fileutils/lib/fileutils.rb b/lib/bundler/vendor/fileutils/lib/fileutils.rb
deleted file mode 100644
index 8f8faf30c8..0000000000
--- a/lib/bundler/vendor/fileutils/lib/fileutils.rb
+++ /dev/null
@@ -1,1764 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require 'rbconfig'
-rescue LoadError
- # for make mjit-headers
-end
-
-#
-# = fileutils.rb
-#
-# Copyright (c) 2000-2007 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-#
-# == module Bundler::FileUtils
-#
-# Namespace for several file utility methods for copying, moving, removing, etc.
-#
-# === Module Functions
-#
-# require 'bundler/vendor/fileutils/lib/fileutils'
-#
-# Bundler::FileUtils.cd(dir, **options)
-# Bundler::FileUtils.cd(dir, **options) {|dir| block }
-# Bundler::FileUtils.pwd()
-# Bundler::FileUtils.mkdir(dir, **options)
-# Bundler::FileUtils.mkdir(list, **options)
-# Bundler::FileUtils.mkdir_p(dir, **options)
-# Bundler::FileUtils.mkdir_p(list, **options)
-# Bundler::FileUtils.rmdir(dir, **options)
-# Bundler::FileUtils.rmdir(list, **options)
-# Bundler::FileUtils.ln(target, link, **options)
-# Bundler::FileUtils.ln(targets, dir, **options)
-# Bundler::FileUtils.ln_s(target, link, **options)
-# Bundler::FileUtils.ln_s(targets, dir, **options)
-# Bundler::FileUtils.ln_sf(target, link, **options)
-# Bundler::FileUtils.cp(src, dest, **options)
-# Bundler::FileUtils.cp(list, dir, **options)
-# Bundler::FileUtils.cp_r(src, dest, **options)
-# Bundler::FileUtils.cp_r(list, dir, **options)
-# Bundler::FileUtils.mv(src, dest, **options)
-# Bundler::FileUtils.mv(list, dir, **options)
-# Bundler::FileUtils.rm(list, **options)
-# Bundler::FileUtils.rm_r(list, **options)
-# Bundler::FileUtils.rm_rf(list, **options)
-# Bundler::FileUtils.install(src, dest, **options)
-# Bundler::FileUtils.chmod(mode, list, **options)
-# Bundler::FileUtils.chmod_R(mode, list, **options)
-# Bundler::FileUtils.chown(user, group, list, **options)
-# Bundler::FileUtils.chown_R(user, group, list, **options)
-# Bundler::FileUtils.touch(list, **options)
-#
-# Possible <tt>options</tt> are:
-#
-# <tt>:force</tt> :: forced operation (rewrite files if exist, remove
-# directories if not empty, etc.);
-# <tt>:verbose</tt> :: print command to be run, in bash syntax, before
-# performing it;
-# <tt>:preserve</tt> :: preserve object's group, user and modification
-# time on copying;
-# <tt>:noop</tt> :: no changes are made (usable in combination with
-# <tt>:verbose</tt> which will print the command to run)
-#
-# Each method documents the options that it honours. See also ::commands,
-# ::options and ::options_of methods to introspect which command have which
-# options.
-#
-# All methods that have the concept of a "source" file or directory can take
-# either one file or a list of files in that argument. See the method
-# documentation for examples.
-#
-# There are some `low level' methods, which do not accept keyword arguments:
-#
-# Bundler::FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
-# Bundler::FileUtils.copy_file(src, dest, preserve = false, dereference = true)
-# Bundler::FileUtils.copy_stream(srcstream, deststream)
-# Bundler::FileUtils.remove_entry(path, force = false)
-# Bundler::FileUtils.remove_entry_secure(path, force = false)
-# Bundler::FileUtils.remove_file(path, force = false)
-# Bundler::FileUtils.compare_file(path_a, path_b)
-# Bundler::FileUtils.compare_stream(stream_a, stream_b)
-# Bundler::FileUtils.uptodate?(file, cmp_list)
-#
-# == module Bundler::FileUtils::Verbose
-#
-# This module has all methods of Bundler::FileUtils module, but it outputs messages
-# before acting. This equates to passing the <tt>:verbose</tt> flag to methods
-# in Bundler::FileUtils.
-#
-# == module Bundler::FileUtils::NoWrite
-#
-# This module has all methods of Bundler::FileUtils module, but never changes
-# files/directories. This equates to passing the <tt>:noop</tt> flag to methods
-# in Bundler::FileUtils.
-#
-# == module Bundler::FileUtils::DryRun
-#
-# This module has all methods of Bundler::FileUtils module, but never changes
-# files/directories. This equates to passing the <tt>:noop</tt> and
-# <tt>:verbose</tt> flags to methods in Bundler::FileUtils.
-#
-module Bundler::FileUtils
- VERSION = "1.4.1"
-
- def self.private_module_function(name) #:nodoc:
- module_function name
- private_class_method name
- end
-
- #
- # Returns the name of the current directory.
- #
- def pwd
- Dir.pwd
- end
- module_function :pwd
-
- alias getwd pwd
- module_function :getwd
-
- #
- # Changes the current directory to the directory +dir+.
- #
- # If this method is called with block, resumes to the previous
- # working directory after the block execution has finished.
- #
- # Bundler::FileUtils.cd('/') # change directory
- #
- # Bundler::FileUtils.cd('/', verbose: true) # change directory and report it
- #
- # Bundler::FileUtils.cd('/') do # change directory
- # # ... # do something
- # end # return to original directory
- #
- def cd(dir, verbose: nil, &block) # :yield: dir
- fu_output_message "cd #{dir}" if verbose
- result = Dir.chdir(dir, &block)
- fu_output_message 'cd -' if verbose and block
- result
- end
- module_function :cd
-
- alias chdir cd
- module_function :chdir
-
- #
- # Returns true if +new+ is newer than all +old_list+.
- # Non-existent files are older than any file.
- #
- # Bundler::FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
- # system 'make hello.o'
- #
- def uptodate?(new, old_list)
- return false unless File.exist?(new)
- new_time = File.mtime(new)
- old_list.each do |old|
- if File.exist?(old)
- return false unless new_time > File.mtime(old)
- end
- end
- true
- end
- module_function :uptodate?
-
- def remove_trailing_slash(dir) #:nodoc:
- dir == '/' ? dir : dir.chomp(?/)
- end
- private_module_function :remove_trailing_slash
-
- #
- # Creates one or more directories.
- #
- # Bundler::FileUtils.mkdir 'test'
- # Bundler::FileUtils.mkdir %w(tmp data)
- # Bundler::FileUtils.mkdir 'notexist', noop: true # Does not really create.
- # Bundler::FileUtils.mkdir 'tmp', mode: 0700
- #
- def mkdir(list, mode: nil, noop: nil, verbose: nil)
- list = fu_list(list)
- fu_output_message "mkdir #{mode ? ('-m %03o ' % mode) : ''}#{list.join ' '}" if verbose
- return if noop
-
- list.each do |dir|
- fu_mkdir dir, mode
- end
- end
- module_function :mkdir
-
- #
- # Creates a directory and all its parent directories.
- # For example,
- #
- # Bundler::FileUtils.mkdir_p '/usr/local/lib/ruby'
- #
- # causes to make following directories, if they do not exist.
- #
- # * /usr
- # * /usr/local
- # * /usr/local/lib
- # * /usr/local/lib/ruby
- #
- # You can pass several directories at a time in a list.
- #
- def mkdir_p(list, mode: nil, noop: nil, verbose: nil)
- list = fu_list(list)
- fu_output_message "mkdir -p #{mode ? ('-m %03o ' % mode) : ''}#{list.join ' '}" if verbose
- return *list if noop
-
- list.map {|path| remove_trailing_slash(path)}.each do |path|
- # optimize for the most common case
- begin
- fu_mkdir path, mode
- next
- rescue SystemCallError
- next if File.directory?(path)
- end
-
- stack = []
- until path == stack.last # dirname("/")=="/", dirname("C:/")=="C:/"
- stack.push path
- path = File.dirname(path)
- end
- stack.pop # root directory should exist
- stack.reverse_each do |dir|
- begin
- fu_mkdir dir, mode
- rescue SystemCallError
- raise unless File.directory?(dir)
- end
- end
- end
-
- return *list
- end
- module_function :mkdir_p
-
- alias mkpath mkdir_p
- alias makedirs mkdir_p
- module_function :mkpath
- module_function :makedirs
-
- def fu_mkdir(path, mode) #:nodoc:
- path = remove_trailing_slash(path)
- if mode
- Dir.mkdir path, mode
- File.chmod mode, path
- else
- Dir.mkdir path
- end
- end
- private_module_function :fu_mkdir
-
- #
- # Removes one or more directories.
- #
- # Bundler::FileUtils.rmdir 'somedir'
- # Bundler::FileUtils.rmdir %w(somedir anydir otherdir)
- # # Does not really remove directory; outputs message.
- # Bundler::FileUtils.rmdir 'somedir', verbose: true, noop: true
- #
- def rmdir(list, parents: nil, noop: nil, verbose: nil)
- list = fu_list(list)
- fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if verbose
- return if noop
- list.each do |dir|
- Dir.rmdir(dir = remove_trailing_slash(dir))
- if parents
- begin
- until (parent = File.dirname(dir)) == '.' or parent == dir
- dir = parent
- Dir.rmdir(dir)
- end
- rescue Errno::ENOTEMPTY, Errno::EEXIST, Errno::ENOENT
- end
- end
- end
- end
- module_function :rmdir
-
- #
- # :call-seq:
- # Bundler::FileUtils.ln(target, link, force: nil, noop: nil, verbose: nil)
- # Bundler::FileUtils.ln(target, dir, force: nil, noop: nil, verbose: nil)
- # Bundler::FileUtils.ln(targets, dir, force: nil, noop: nil, verbose: nil)
- #
- # In the first form, creates a hard link +link+ which points to +target+.
- # If +link+ already exists, raises Errno::EEXIST.
- # But if the +force+ option is set, overwrites +link+.
- #
- # Bundler::FileUtils.ln 'gcc', 'cc', verbose: true
- # Bundler::FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
- #
- # In the second form, creates a link +dir/target+ pointing to +target+.
- # In the third form, creates several hard links in the directory +dir+,
- # pointing to each item in +targets+.
- # If +dir+ is not a directory, raises Errno::ENOTDIR.
- #
- # Bundler::FileUtils.cd '/sbin'
- # Bundler::FileUtils.ln %w(cp mv mkdir), '/bin' # Now /sbin/cp and /bin/cp are linked.
- #
- def ln(src, dest, force: nil, noop: nil, verbose: nil)
- fu_output_message "ln#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
- return if noop
- fu_each_src_dest0(src, dest) do |s,d|
- remove_file d, true if force
- File.link s, d
- end
- end
- module_function :ln
-
- alias link ln
- module_function :link
-
- #
- # Hard link +src+ to +dest+. If +src+ is a directory, this method links
- # all its contents recursively. If +dest+ is a directory, links
- # +src+ to +dest/src+.
- #
- # +src+ can be a list of files.
- #
- # If +dereference_root+ is true, this method dereference tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
- # Bundler::FileUtils.rm_r site_ruby + '/mylib', force: true
- # Bundler::FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
- #
- # # Examples of linking several files to target directory.
- # Bundler::FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail'
- # Bundler::FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
- #
- # # If you want to link all contents of a directory instead of the
- # # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
- # # use the following code.
- # Bundler::FileUtils.cp_lr 'src/.', 'dest' # cp_lr('src', 'dest') makes dest/src, but this doesn't.
- #
- def cp_lr(src, dest, noop: nil, verbose: nil,
- dereference_root: true, remove_destination: false)
- fu_output_message "cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if verbose
- return if noop
- fu_each_src_dest(src, dest) do |s, d|
- link_entry s, d, dereference_root, remove_destination
- end
- end
- module_function :cp_lr
-
- #
- # :call-seq:
- # Bundler::FileUtils.ln_s(target, link, force: nil, noop: nil, verbose: nil)
- # Bundler::FileUtils.ln_s(target, dir, force: nil, noop: nil, verbose: nil)
- # Bundler::FileUtils.ln_s(targets, dir, force: nil, noop: nil, verbose: nil)
- #
- # In the first form, creates a symbolic link +link+ which points to +target+.
- # If +link+ already exists, raises Errno::EEXIST.
- # But if the <tt>force</tt> option is set, overwrites +link+.
- #
- # Bundler::FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
- # Bundler::FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
- #
- # In the second form, creates a link +dir/target+ pointing to +target+.
- # In the third form, creates several symbolic links in the directory +dir+,
- # pointing to each item in +targets+.
- # If +dir+ is not a directory, raises Errno::ENOTDIR.
- #
- # Bundler::FileUtils.ln_s Dir.glob('/bin/*.rb'), '/home/foo/bin'
- #
- def ln_s(src, dest, force: nil, noop: nil, verbose: nil)
- fu_output_message "ln -s#{force ? 'f' : ''} #{[src,dest].flatten.join ' '}" if verbose
- return if noop
- fu_each_src_dest0(src, dest) do |s,d|
- remove_file d, true if force
- File.symlink s, d
- end
- end
- module_function :ln_s
-
- alias symlink ln_s
- module_function :symlink
-
- #
- # :call-seq:
- # Bundler::FileUtils.ln_sf(*args)
- #
- # Same as
- #
- # Bundler::FileUtils.ln_s(*args, force: true)
- #
- def ln_sf(src, dest, noop: nil, verbose: nil)
- ln_s src, dest, force: true, noop: noop, verbose: verbose
- end
- module_function :ln_sf
-
- #
- # Hard links a file system entry +src+ to +dest+.
- # If +src+ is a directory, this method links its contents recursively.
- #
- # Both of +src+ and +dest+ must be a path name.
- # +src+ must exist, +dest+ must not exist.
- #
- # If +dereference_root+ is true, this method dereferences the tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
- def link_entry(src, dest, dereference_root = false, remove_destination = false)
- Entry_.new(src, nil, dereference_root).traverse do |ent|
- destent = Entry_.new(dest, ent.rel, false)
- File.unlink destent.path if remove_destination && File.file?(destent.path)
- ent.link destent.path
- end
- end
- module_function :link_entry
-
- #
- # Copies a file content +src+ to +dest+. If +dest+ is a directory,
- # copies +src+ to +dest/src+.
- #
- # If +src+ is a list of files, then +dest+ must be a directory.
- #
- # Bundler::FileUtils.cp 'eval.c', 'eval.c.org'
- # Bundler::FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
- # Bundler::FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', verbose: true
- # Bundler::FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
- #
- def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
- fu_output_message "cp#{preserve ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if verbose
- return if noop
- fu_each_src_dest(src, dest) do |s, d|
- copy_file s, d, preserve
- end
- end
- module_function :cp
-
- alias copy cp
- module_function :copy
-
- #
- # Copies +src+ to +dest+. If +src+ is a directory, this method copies
- # all its contents recursively. If +dest+ is a directory, copies
- # +src+ to +dest/src+.
- #
- # +src+ can be a list of files.
- #
- # If +dereference_root+ is true, this method dereference tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
- # # Installing Ruby library "mylib" under the site_ruby
- # Bundler::FileUtils.rm_r site_ruby + '/mylib', force: true
- # Bundler::FileUtils.cp_r 'lib/', site_ruby + '/mylib'
- #
- # # Examples of copying several files to target directory.
- # Bundler::FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
- # Bundler::FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', noop: true, verbose: true
- #
- # # If you want to copy all contents of a directory instead of the
- # # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
- # # use following code.
- # Bundler::FileUtils.cp_r 'src/.', 'dest' # cp_r('src', 'dest') makes dest/src,
- # # but this doesn't.
- #
- def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,
- dereference_root: true, remove_destination: nil)
- fu_output_message "cp -r#{preserve ? 'p' : ''}#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if verbose
- return if noop
- fu_each_src_dest(src, dest) do |s, d|
- copy_entry s, d, preserve, dereference_root, remove_destination
- end
- end
- module_function :cp_r
-
- #
- # Copies a file system entry +src+ to +dest+.
- # If +src+ is a directory, this method copies its contents recursively.
- # This method preserves file types, c.f. symlink, directory...
- # (FIFO, device files and etc. are not supported yet)
- #
- # Both of +src+ and +dest+ must be a path name.
- # +src+ must exist, +dest+ must not exist.
- #
- # If +preserve+ is true, this method preserves owner, group, and
- # modified time. Permissions are copied regardless +preserve+.
- #
- # If +dereference_root+ is true, this method dereference tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
- def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
- if dereference_root
- src = File.realpath(src)
- end
-
- Entry_.new(src, nil, false).wrap_traverse(proc do |ent|
- destent = Entry_.new(dest, ent.rel, false)
- File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path))
- ent.copy destent.path
- end, proc do |ent|
- destent = Entry_.new(dest, ent.rel, false)
- ent.copy_metadata destent.path if preserve
- end)
- end
- module_function :copy_entry
-
- #
- # Copies file contents of +src+ to +dest+.
- # Both of +src+ and +dest+ must be a path name.
- #
- def copy_file(src, dest, preserve = false, dereference = true)
- ent = Entry_.new(src, nil, dereference)
- ent.copy_file dest
- ent.copy_metadata dest if preserve
- end
- module_function :copy_file
-
- #
- # Copies stream +src+ to +dest+.
- # +src+ must respond to #read(n) and
- # +dest+ must respond to #write(str).
- #
- def copy_stream(src, dest)
- IO.copy_stream(src, dest)
- end
- module_function :copy_stream
-
- #
- # Moves file(s) +src+ to +dest+. If +file+ and +dest+ exist on the different
- # disk partition, the file is copied then the original file is removed.
- #
- # Bundler::FileUtils.mv 'badname.rb', 'goodname.rb'
- # Bundler::FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true # no error
- #
- # Bundler::FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
- # Bundler::FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
- #
- def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
- fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
- return if noop
- fu_each_src_dest(src, dest) do |s, d|
- destent = Entry_.new(d, nil, true)
- begin
- if destent.exist?
- if destent.directory?
- raise Errno::EEXIST, d
- end
- end
- begin
- File.rename s, d
- rescue Errno::EXDEV,
- Errno::EPERM # move from unencrypted to encrypted dir (ext4)
- copy_entry s, d, true
- if secure
- remove_entry_secure s, force
- else
- remove_entry s, force
- end
- end
- rescue SystemCallError
- raise unless force
- end
- end
- end
- module_function :mv
-
- alias move mv
- module_function :move
-
- #
- # Remove file(s) specified in +list+. This method cannot remove directories.
- # All StandardErrors are ignored when the :force option is set.
- #
- # Bundler::FileUtils.rm %w( junk.txt dust.txt )
- # Bundler::FileUtils.rm Dir.glob('*.so')
- # Bundler::FileUtils.rm 'NotExistFile', force: true # never raises exception
- #
- def rm(list, force: nil, noop: nil, verbose: nil)
- list = fu_list(list)
- fu_output_message "rm#{force ? ' -f' : ''} #{list.join ' '}" if verbose
- return if noop
-
- list.each do |path|
- remove_file path, force
- end
- end
- module_function :rm
-
- alias remove rm
- module_function :remove
-
- #
- # Equivalent to
- #
- # Bundler::FileUtils.rm(list, force: true)
- #
- def rm_f(list, noop: nil, verbose: nil)
- rm list, force: true, noop: noop, verbose: verbose
- end
- module_function :rm_f
-
- alias safe_unlink rm_f
- module_function :safe_unlink
-
- #
- # remove files +list+[0] +list+[1]... If +list+[n] is a directory,
- # removes its all contents recursively. This method ignores
- # StandardError when :force option is set.
- #
- # Bundler::FileUtils.rm_r Dir.glob('/tmp/*')
- # Bundler::FileUtils.rm_r 'some_dir', force: true
- #
- # WARNING: This method causes local vulnerability
- # if one of parent directories or removing directory tree are world
- # writable (including /tmp, whose permission is 1777), and the current
- # process has strong privilege such as Unix super user (root), and the
- # system has symbolic link. For secure removing, read the documentation
- # of remove_entry_secure carefully, and set :secure option to true.
- # Default is <tt>secure: false</tt>.
- #
- # NOTE: This method calls remove_entry_secure if :secure option is set.
- # See also remove_entry_secure.
- #
- def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
- list = fu_list(list)
- fu_output_message "rm -r#{force ? 'f' : ''} #{list.join ' '}" if verbose
- return if noop
- list.each do |path|
- if secure
- remove_entry_secure path, force
- else
- remove_entry path, force
- end
- end
- end
- module_function :rm_r
-
- #
- # Equivalent to
- #
- # Bundler::FileUtils.rm_r(list, force: true)
- #
- # WARNING: This method causes local vulnerability.
- # Read the documentation of rm_r first.
- #
- def rm_rf(list, noop: nil, verbose: nil, secure: nil)
- rm_r list, force: true, noop: noop, verbose: verbose, secure: secure
- end
- module_function :rm_rf
-
- alias rmtree rm_rf
- module_function :rmtree
-
- #
- # This method removes a file system entry +path+. +path+ shall be a
- # regular file, a directory, or something. If +path+ is a directory,
- # remove it recursively. This method is required to avoid TOCTTOU
- # (time-of-check-to-time-of-use) local security vulnerability of rm_r.
- # #rm_r causes security hole when:
- #
- # * Parent directory is world writable (including /tmp).
- # * Removing directory tree includes world writable directory.
- # * The system has symbolic link.
- #
- # To avoid this security hole, this method applies special preprocess.
- # If +path+ is a directory, this method chown(2) and chmod(2) all
- # removing directories. This requires the current process is the
- # owner of the removing whole directory tree, or is the super user (root).
- #
- # WARNING: You must ensure that *ALL* parent directories cannot be
- # moved by other untrusted users. For example, parent directories
- # should not be owned by untrusted users, and should not be world
- # writable except when the sticky bit set.
- #
- # WARNING: Only the owner of the removing directory tree, or Unix super
- # user (root) should invoke this method. Otherwise this method does not
- # work.
- #
- # For details of this security vulnerability, see Perl's case:
- #
- # * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
- # * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
- #
- # For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
- #
- def remove_entry_secure(path, force = false)
- unless fu_have_symlink?
- remove_entry path, force
- return
- end
- fullpath = File.expand_path(path)
- st = File.lstat(fullpath)
- unless st.directory?
- File.unlink fullpath
- return
- end
- # is a directory.
- parent_st = File.stat(File.dirname(fullpath))
- unless parent_st.world_writable?
- remove_entry path, force
- return
- end
- unless parent_st.sticky?
- raise ArgumentError, "parent directory is world writable, Bundler::FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{'%o' % parent_st.mode})"
- end
-
- # freeze tree root
- euid = Process.euid
- dot_file = fullpath + "/."
- begin
- File.open(dot_file) {|f|
- unless fu_stat_identical_entry?(st, f.stat)
- # symlink (TOC-to-TOU attack?)
- File.unlink fullpath
- return
- end
- f.chown euid, -1
- f.chmod 0700
- }
- rescue Errno::EISDIR # JRuby in non-native mode can't open files as dirs
- File.lstat(dot_file).tap {|fstat|
- unless fu_stat_identical_entry?(st, fstat)
- # symlink (TOC-to-TOU attack?)
- File.unlink fullpath
- return
- end
- File.chown euid, -1, dot_file
- File.chmod 0700, dot_file
- }
- end
-
- unless fu_stat_identical_entry?(st, File.lstat(fullpath))
- # TOC-to-TOU attack?
- File.unlink fullpath
- return
- end
-
- # ---- tree root is frozen ----
- root = Entry_.new(path)
- root.preorder_traverse do |ent|
- if ent.directory?
- ent.chown euid, -1
- ent.chmod 0700
- end
- end
- root.postorder_traverse do |ent|
- begin
- ent.remove
- rescue
- raise unless force
- end
- end
- rescue
- raise unless force
- end
- module_function :remove_entry_secure
-
- def fu_have_symlink? #:nodoc:
- File.symlink nil, nil
- rescue NotImplementedError
- return false
- rescue TypeError
- return true
- end
- private_module_function :fu_have_symlink?
-
- def fu_stat_identical_entry?(a, b) #:nodoc:
- a.dev == b.dev and a.ino == b.ino
- end
- private_module_function :fu_stat_identical_entry?
-
- #
- # This method removes a file system entry +path+.
- # +path+ might be a regular file, a directory, or something.
- # If +path+ is a directory, remove it recursively.
- #
- # See also remove_entry_secure.
- #
- def remove_entry(path, force = false)
- Entry_.new(path).postorder_traverse do |ent|
- begin
- ent.remove
- rescue
- raise unless force
- end
- end
- rescue
- raise unless force
- end
- module_function :remove_entry
-
- #
- # Removes a file +path+.
- # This method ignores StandardError if +force+ is true.
- #
- def remove_file(path, force = false)
- Entry_.new(path).remove_file
- rescue
- raise unless force
- end
- module_function :remove_file
-
- #
- # Removes a directory +dir+ and its contents recursively.
- # This method ignores StandardError if +force+ is true.
- #
- def remove_dir(path, force = false)
- remove_entry path, force # FIXME?? check if it is a directory
- end
- module_function :remove_dir
-
- #
- # Returns true if the contents of a file +a+ and a file +b+ are identical.
- #
- # Bundler::FileUtils.compare_file('somefile', 'somefile') #=> true
- # Bundler::FileUtils.compare_file('/dev/null', '/dev/urandom') #=> false
- #
- def compare_file(a, b)
- return false unless File.size(a) == File.size(b)
- File.open(a, 'rb') {|fa|
- File.open(b, 'rb') {|fb|
- return compare_stream(fa, fb)
- }
- }
- end
- module_function :compare_file
-
- alias identical? compare_file
- alias cmp compare_file
- module_function :identical?
- module_function :cmp
-
- #
- # Returns true if the contents of a stream +a+ and +b+ are identical.
- #
- def compare_stream(a, b)
- bsize = fu_stream_blksize(a, b)
-
- if RUBY_VERSION > "2.4"
- sa = String.new(capacity: bsize)
- sb = String.new(capacity: bsize)
- else
- sa = String.new
- sb = String.new
- end
-
- begin
- a.read(bsize, sa)
- b.read(bsize, sb)
- return true if sa.empty? && sb.empty?
- end while sa == sb
- false
- end
- module_function :compare_stream
-
- #
- # If +src+ is not same as +dest+, copies it and changes the permission
- # mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
- # This method removes destination before copy.
- #
- # Bundler::FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
- # Bundler::FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
- #
- def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
- noop: nil, verbose: nil)
- if verbose
- msg = +"install -c"
- msg << ' -p' if preserve
- msg << ' -m ' << mode_to_s(mode) if mode
- msg << " -o #{owner}" if owner
- msg << " -g #{group}" if group
- msg << ' ' << [src,dest].flatten.join(' ')
- fu_output_message msg
- end
- return if noop
- uid = fu_get_uid(owner)
- gid = fu_get_gid(group)
- fu_each_src_dest(src, dest) do |s, d|
- st = File.stat(s)
- unless File.exist?(d) and compare_file(s, d)
- remove_file d, true
- copy_file s, d
- File.utime st.atime, st.mtime, d if preserve
- File.chmod fu_mode(mode, st), d if mode
- File.chown uid, gid, d if uid or gid
- end
- end
- end
- module_function :install
-
- def user_mask(target) #:nodoc:
- target.each_char.inject(0) do |mask, chr|
- case chr
- when "u"
- mask | 04700
- when "g"
- mask | 02070
- when "o"
- mask | 01007
- when "a"
- mask | 07777
- else
- raise ArgumentError, "invalid `who' symbol in file mode: #{chr}"
- end
- end
- end
- private_module_function :user_mask
-
- def apply_mask(mode, user_mask, op, mode_mask) #:nodoc:
- case op
- when '='
- (mode & ~user_mask) | (user_mask & mode_mask)
- when '+'
- mode | (user_mask & mode_mask)
- when '-'
- mode & ~(user_mask & mode_mask)
- end
- end
- private_module_function :apply_mask
-
- def symbolic_modes_to_i(mode_sym, path) #:nodoc:
- mode = if File::Stat === path
- path.mode
- else
- File.stat(path).mode
- end
- mode_sym.split(/,/).inject(mode & 07777) do |current_mode, clause|
- target, *actions = clause.split(/([=+-])/)
- raise ArgumentError, "invalid file mode: #{mode_sym}" if actions.empty?
- target = 'a' if target.empty?
- user_mask = user_mask(target)
- actions.each_slice(2) do |op, perm|
- need_apply = op == '='
- mode_mask = (perm || '').each_char.inject(0) do |mask, chr|
- case chr
- when "r"
- mask | 0444
- when "w"
- mask | 0222
- when "x"
- mask | 0111
- when "X"
- if FileTest.directory? path
- mask | 0111
- else
- mask
- end
- when "s"
- mask | 06000
- when "t"
- mask | 01000
- when "u", "g", "o"
- if mask.nonzero?
- current_mode = apply_mask(current_mode, user_mask, op, mask)
- end
- need_apply = false
- copy_mask = user_mask(chr)
- (current_mode & copy_mask) / (copy_mask & 0111) * (user_mask & 0111)
- else
- raise ArgumentError, "invalid `perm' symbol in file mode: #{chr}"
- end
- end
-
- if mode_mask.nonzero? || need_apply
- current_mode = apply_mask(current_mode, user_mask, op, mode_mask)
- end
- end
- current_mode
- end
- end
- private_module_function :symbolic_modes_to_i
-
- def fu_mode(mode, path) #:nodoc:
- mode.is_a?(String) ? symbolic_modes_to_i(mode, path) : mode
- end
- private_module_function :fu_mode
-
- def mode_to_s(mode) #:nodoc:
- mode.is_a?(String) ? mode : "%o" % mode
- end
- private_module_function :mode_to_s
-
- #
- # Changes permission bits on the named files (in +list+) to the bit pattern
- # represented by +mode+.
- #
- # +mode+ is the symbolic and absolute mode can be used.
- #
- # Absolute mode is
- # Bundler::FileUtils.chmod 0755, 'somecommand'
- # Bundler::FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
- # Bundler::FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
- #
- # Symbolic mode is
- # Bundler::FileUtils.chmod "u=wrx,go=rx", 'somecommand'
- # Bundler::FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
- # Bundler::FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
- #
- # "a" :: is user, group, other mask.
- # "u" :: is user's mask.
- # "g" :: is group's mask.
- # "o" :: is other's mask.
- # "w" :: is write permission.
- # "r" :: is read permission.
- # "x" :: is execute permission.
- # "X" ::
- # is execute permission for directories only, must be used in conjunction with "+"
- # "s" :: is uid, gid.
- # "t" :: is sticky bit.
- # "+" :: is added to a class given the specified mode.
- # "-" :: Is removed from a given class given mode.
- # "=" :: Is the exact nature of the class will be given a specified mode.
-
- def chmod(mode, list, noop: nil, verbose: nil)
- list = fu_list(list)
- fu_output_message sprintf('chmod %s %s', mode_to_s(mode), list.join(' ')) if verbose
- return if noop
- list.each do |path|
- Entry_.new(path).chmod(fu_mode(mode, path))
- end
- end
- module_function :chmod
-
- #
- # Changes permission bits on the named files (in +list+)
- # to the bit pattern represented by +mode+.
- #
- # Bundler::FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
- # Bundler::FileUtils.chmod_R "u=wrx", "/tmp/app.#{$$}"
- #
- def chmod_R(mode, list, noop: nil, verbose: nil, force: nil)
- list = fu_list(list)
- fu_output_message sprintf('chmod -R%s %s %s',
- (force ? 'f' : ''),
- mode_to_s(mode), list.join(' ')) if verbose
- return if noop
- list.each do |root|
- Entry_.new(root).traverse do |ent|
- begin
- ent.chmod(fu_mode(mode, ent.path))
- rescue
- raise unless force
- end
- end
- end
- end
- module_function :chmod_R
-
- #
- # Changes owner and group on the named files (in +list+)
- # to the user +user+ and the group +group+. +user+ and +group+
- # may be an ID (Integer/String) or a name (String).
- # If +user+ or +group+ is nil, this method does not change
- # the attribute.
- #
- # Bundler::FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
- # Bundler::FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
- #
- def chown(user, group, list, noop: nil, verbose: nil)
- list = fu_list(list)
- fu_output_message sprintf('chown %s %s',
- (group ? "#{user}:#{group}" : user || ':'),
- list.join(' ')) if verbose
- return if noop
- uid = fu_get_uid(user)
- gid = fu_get_gid(group)
- list.each do |path|
- Entry_.new(path).chown uid, gid
- end
- end
- module_function :chown
-
- #
- # Changes owner and group on the named files (in +list+)
- # to the user +user+ and the group +group+ recursively.
- # +user+ and +group+ may be an ID (Integer/String) or
- # a name (String). If +user+ or +group+ is nil, this
- # method does not change the attribute.
- #
- # Bundler::FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
- # Bundler::FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
- #
- def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
- list = fu_list(list)
- fu_output_message sprintf('chown -R%s %s %s',
- (force ? 'f' : ''),
- (group ? "#{user}:#{group}" : user || ':'),
- list.join(' ')) if verbose
- return if noop
- uid = fu_get_uid(user)
- gid = fu_get_gid(group)
- list.each do |root|
- Entry_.new(root).traverse do |ent|
- begin
- ent.chown uid, gid
- rescue
- raise unless force
- end
- end
- end
- end
- module_function :chown_R
-
- def fu_get_uid(user) #:nodoc:
- return nil unless user
- case user
- when Integer
- user
- when /\A\d+\z/
- user.to_i
- else
- require 'etc'
- Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
- end
- end
- private_module_function :fu_get_uid
-
- def fu_get_gid(group) #:nodoc:
- return nil unless group
- case group
- when Integer
- group
- when /\A\d+\z/
- group.to_i
- else
- require 'etc'
- Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
- end
- end
- private_module_function :fu_get_gid
-
- #
- # Updates modification time (mtime) and access time (atime) of file(s) in
- # +list+. Files are created if they don't exist.
- #
- # Bundler::FileUtils.touch 'timestamp'
- # Bundler::FileUtils.touch Dir.glob('*.c'); system 'make'
- #
- def touch(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)
- list = fu_list(list)
- t = mtime
- if verbose
- fu_output_message "touch #{nocreate ? '-c ' : ''}#{t ? t.strftime('-t %Y%m%d%H%M.%S ') : ''}#{list.join ' '}"
- end
- return if noop
- list.each do |path|
- created = nocreate
- begin
- File.utime(t, t, path)
- rescue Errno::ENOENT
- raise if created
- File.open(path, 'a') {
- ;
- }
- created = true
- retry if t
- end
- end
- end
- module_function :touch
-
- private
-
- module StreamUtils_
- private
-
- case (defined?(::RbConfig) ? ::RbConfig::CONFIG['host_os'] : ::RUBY_PLATFORM)
- when /mswin|mingw/
- def fu_windows?; true end
- else
- def fu_windows?; false end
- end
-
- def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
- IO.copy_stream(src, dest)
- end
-
- def fu_stream_blksize(*streams)
- streams.each do |s|
- next unless s.respond_to?(:stat)
- size = fu_blksize(s.stat)
- return size if size
- end
- fu_default_blksize()
- end
-
- def fu_blksize(st)
- s = st.blksize
- return nil unless s
- return nil if s == 0
- s
- end
-
- def fu_default_blksize
- 1024
- end
- end
-
- include StreamUtils_
- extend StreamUtils_
-
- class Entry_ #:nodoc: internal use only
- include StreamUtils_
-
- def initialize(a, b = nil, deref = false)
- @prefix = @rel = @path = nil
- if b
- @prefix = a
- @rel = b
- else
- @path = a
- end
- @deref = deref
- @stat = nil
- @lstat = nil
- end
-
- def inspect
- "\#<#{self.class} #{path()}>"
- end
-
- def path
- if @path
- File.path(@path)
- else
- join(@prefix, @rel)
- end
- end
-
- def prefix
- @prefix || @path
- end
-
- def rel
- @rel
- end
-
- def dereference?
- @deref
- end
-
- def exist?
- begin
- lstat
- true
- rescue Errno::ENOENT
- false
- end
- end
-
- def file?
- s = lstat!
- s and s.file?
- end
-
- def directory?
- s = lstat!
- s and s.directory?
- end
-
- def symlink?
- s = lstat!
- s and s.symlink?
- end
-
- def chardev?
- s = lstat!
- s and s.chardev?
- end
-
- def blockdev?
- s = lstat!
- s and s.blockdev?
- end
-
- def socket?
- s = lstat!
- s and s.socket?
- end
-
- def pipe?
- s = lstat!
- s and s.pipe?
- end
-
- S_IF_DOOR = 0xD000
-
- def door?
- s = lstat!
- s and (s.mode & 0xF000 == S_IF_DOOR)
- end
-
- def entries
- opts = {}
- opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
-
- files = if Dir.respond_to?(:children)
- Dir.children(path, **opts)
- else
- Dir.entries(path(), **opts)
- .reject {|n| n == '.' or n == '..' }
- end
-
- untaint = RUBY_VERSION < '2.7'
- files.map {|n| Entry_.new(prefix(), join(rel(), untaint ? n.untaint : n)) }
- end
-
- def stat
- return @stat if @stat
- if lstat() and lstat().symlink?
- @stat = File.stat(path())
- else
- @stat = lstat()
- end
- @stat
- end
-
- def stat!
- return @stat if @stat
- if lstat! and lstat!.symlink?
- @stat = File.stat(path())
- else
- @stat = lstat!
- end
- @stat
- rescue SystemCallError
- nil
- end
-
- def lstat
- if dereference?
- @lstat ||= File.stat(path())
- else
- @lstat ||= File.lstat(path())
- end
- end
-
- def lstat!
- lstat()
- rescue SystemCallError
- nil
- end
-
- def chmod(mode)
- if symlink?
- File.lchmod mode, path() if have_lchmod?
- else
- File.chmod mode, path()
- end
- end
-
- def chown(uid, gid)
- if symlink?
- File.lchown uid, gid, path() if have_lchown?
- else
- File.chown uid, gid, path()
- end
- end
-
- def link(dest)
- case
- when directory?
- if !File.exist?(dest) and descendant_directory?(dest, path)
- raise ArgumentError, "cannot link directory %s to itself %s" % [path, dest]
- end
- begin
- Dir.mkdir dest
- rescue
- raise unless File.directory?(dest)
- end
- else
- File.link path(), dest
- end
- end
-
- def copy(dest)
- lstat
- case
- when file?
- copy_file dest
- when directory?
- if !File.exist?(dest) and descendant_directory?(dest, path)
- raise ArgumentError, "cannot copy directory %s to itself %s" % [path, dest]
- end
- begin
- Dir.mkdir dest
- rescue
- raise unless File.directory?(dest)
- end
- when symlink?
- File.symlink File.readlink(path()), dest
- when chardev?, blockdev?
- raise "cannot handle device file"
- when socket?
- begin
- require 'socket'
- rescue LoadError
- raise "cannot handle socket"
- else
- raise "cannot handle socket" unless defined?(UNIXServer)
- end
- UNIXServer.new(dest).close
- File.chmod lstat().mode, dest
- when pipe?
- raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
- File.mkfifo dest, lstat().mode
- when door?
- raise "cannot handle door: #{path()}"
- else
- raise "unknown file type: #{path()}"
- end
- end
-
- def copy_file(dest)
- File.open(path()) do |s|
- File.open(dest, 'wb', s.stat.mode) do |f|
- IO.copy_stream(s, f)
- end
- end
- end
-
- def copy_metadata(path)
- st = lstat()
- if !st.symlink?
- File.utime st.atime, st.mtime, path
- end
- mode = st.mode
- begin
- if st.symlink?
- begin
- File.lchown st.uid, st.gid, path
- rescue NotImplementedError
- end
- else
- File.chown st.uid, st.gid, path
- end
- rescue Errno::EPERM, Errno::EACCES
- # clear setuid/setgid
- mode &= 01777
- end
- if st.symlink?
- begin
- File.lchmod mode, path
- rescue NotImplementedError
- end
- else
- File.chmod mode, path
- end
- end
-
- def remove
- if directory?
- remove_dir1
- else
- remove_file
- end
- end
-
- def remove_dir1
- platform_support {
- Dir.rmdir path().chomp(?/)
- }
- end
-
- def remove_file
- platform_support {
- File.unlink path
- }
- end
-
- def platform_support
- return yield unless fu_windows?
- first_time_p = true
- begin
- yield
- rescue Errno::ENOENT
- raise
- rescue => err
- if first_time_p
- first_time_p = false
- begin
- File.chmod 0700, path() # Windows does not have symlink
- retry
- rescue SystemCallError
- end
- end
- raise err
- end
- end
-
- def preorder_traverse
- stack = [self]
- while ent = stack.pop
- yield ent
- stack.concat ent.entries.reverse if ent.directory?
- end
- end
-
- alias traverse preorder_traverse
-
- def postorder_traverse
- if directory?
- entries().each do |ent|
- ent.postorder_traverse do |e|
- yield e
- end
- end
- end
- ensure
- yield self
- end
-
- def wrap_traverse(pre, post)
- pre.call self
- if directory?
- entries.each do |ent|
- ent.wrap_traverse pre, post
- end
- end
- post.call self
- end
-
- private
-
- @@fileutils_rb_have_lchmod = nil
-
- def have_lchmod?
- # This is not MT-safe, but it does not matter.
- if @@fileutils_rb_have_lchmod == nil
- @@fileutils_rb_have_lchmod = check_have_lchmod?
- end
- @@fileutils_rb_have_lchmod
- end
-
- def check_have_lchmod?
- return false unless File.respond_to?(:lchmod)
- File.lchmod 0
- return true
- rescue NotImplementedError
- return false
- end
-
- @@fileutils_rb_have_lchown = nil
-
- def have_lchown?
- # This is not MT-safe, but it does not matter.
- if @@fileutils_rb_have_lchown == nil
- @@fileutils_rb_have_lchown = check_have_lchown?
- end
- @@fileutils_rb_have_lchown
- end
-
- def check_have_lchown?
- return false unless File.respond_to?(:lchown)
- File.lchown nil, nil
- return true
- rescue NotImplementedError
- return false
- end
-
- def join(dir, base)
- return File.path(dir) if not base or base == '.'
- return File.path(base) if not dir or dir == '.'
- File.join(dir, base)
- end
-
- if File::ALT_SEPARATOR
- DIRECTORY_TERM = "(?=[/#{Regexp.quote(File::ALT_SEPARATOR)}]|\\z)"
- else
- DIRECTORY_TERM = "(?=/|\\z)"
- end
-
- def descendant_directory?(descendant, ascendant)
- if File::FNM_SYSCASE.nonzero?
- File.expand_path(File.dirname(descendant)).casecmp(File.expand_path(ascendant)) == 0
- else
- File.expand_path(File.dirname(descendant)) == File.expand_path(ascendant)
- end
- end
- end # class Entry_
-
- def fu_list(arg) #:nodoc:
- [arg].flatten.map {|path| File.path(path) }
- end
- private_module_function :fu_list
-
- def fu_each_src_dest(src, dest) #:nodoc:
- fu_each_src_dest0(src, dest) do |s, d|
- raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
- yield s, d
- end
- end
- private_module_function :fu_each_src_dest
-
- def fu_each_src_dest0(src, dest) #:nodoc:
- if tmp = Array.try_convert(src)
- tmp.each do |s|
- s = File.path(s)
- yield s, File.join(dest, File.basename(s))
- end
- else
- src = File.path(src)
- if File.directory?(dest)
- yield src, File.join(dest, File.basename(src))
- else
- yield src, File.path(dest)
- end
- end
- end
- private_module_function :fu_each_src_dest0
-
- def fu_same?(a, b) #:nodoc:
- File.identical?(a, b)
- end
- private_module_function :fu_same?
-
- def fu_output_message(msg) #:nodoc:
- output = @fileutils_output if defined?(@fileutils_output)
- output ||= $stderr
- if defined?(@fileutils_label)
- msg = @fileutils_label + msg
- end
- output.puts msg
- end
- private_module_function :fu_output_message
-
- # This hash table holds command options.
- OPT_TABLE = {} #:nodoc: internal use only
- (private_instance_methods & methods(false)).inject(OPT_TABLE) {|tbl, name|
- (tbl[name.to_s] = instance_method(name).parameters).map! {|t, n| n if t == :key}.compact!
- tbl
- }
-
- public
-
- #
- # Returns an Array of names of high-level methods that accept any keyword
- # arguments.
- #
- # p Bundler::FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
- #
- def self.commands
- OPT_TABLE.keys
- end
-
- #
- # Returns an Array of option names.
- #
- # p Bundler::FileUtils.options #=> ["noop", "force", "verbose", "preserve", "mode"]
- #
- def self.options
- OPT_TABLE.values.flatten.uniq.map {|sym| sym.to_s }
- end
-
- #
- # Returns true if the method +mid+ have an option +opt+.
- #
- # p Bundler::FileUtils.have_option?(:cp, :noop) #=> true
- # p Bundler::FileUtils.have_option?(:rm, :force) #=> true
- # p Bundler::FileUtils.have_option?(:rm, :preserve) #=> false
- #
- def self.have_option?(mid, opt)
- li = OPT_TABLE[mid.to_s] or raise ArgumentError, "no such method: #{mid}"
- li.include?(opt)
- end
-
- #
- # Returns an Array of option names of the method +mid+.
- #
- # p Bundler::FileUtils.options_of(:rm) #=> ["noop", "verbose", "force"]
- #
- def self.options_of(mid)
- OPT_TABLE[mid.to_s].map {|sym| sym.to_s }
- end
-
- #
- # Returns an Array of methods names which have the option +opt+.
- #
- # p Bundler::FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
- #
- def self.collect_method(opt)
- OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
- end
-
- private
-
- LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern) # :nodoc:
- module LowMethods # :nodoc: internal use only
- private
- def _do_nothing(*)end
- ::Bundler::FileUtils::LOW_METHODS.map {|name| alias_method name, :_do_nothing}
- end
-
- METHODS = singleton_methods() - [:private_module_function, # :nodoc:
- :commands, :options, :have_option?, :options_of, :collect_method]
-
- #
- # This module has all methods of Bundler::FileUtils module, but it outputs messages
- # before acting. This equates to passing the <tt>:verbose</tt> flag to
- # methods in Bundler::FileUtils.
- #
- module Verbose
- include Bundler::FileUtils
- names = ::Bundler::FileUtils.collect_method(:verbose)
- names.each do |name|
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}(*args, **options)
- super(*args, **options, verbose: true)
- end
- EOS
- end
- private(*names)
- extend self
- class << self
- public(*::Bundler::FileUtils::METHODS)
- end
- end
-
- #
- # This module has all methods of Bundler::FileUtils module, but never changes
- # files/directories. This equates to passing the <tt>:noop</tt> flag
- # to methods in Bundler::FileUtils.
- #
- module NoWrite
- include Bundler::FileUtils
- include LowMethods
- names = ::Bundler::FileUtils.collect_method(:noop)
- names.each do |name|
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}(*args, **options)
- super(*args, **options, noop: true)
- end
- EOS
- end
- private(*names)
- extend self
- class << self
- public(*::Bundler::FileUtils::METHODS)
- end
- end
-
- #
- # This module has all methods of Bundler::FileUtils module, but never changes
- # files/directories, with printing message before acting.
- # This equates to passing the <tt>:noop</tt> and <tt>:verbose</tt> flag
- # to methods in Bundler::FileUtils.
- #
- module DryRun
- include Bundler::FileUtils
- include LowMethods
- names = ::Bundler::FileUtils.collect_method(:noop)
- names.each do |name|
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}(*args, **options)
- super(*args, **options, noop: true, verbose: true)
- end
- EOS
- end
- private(*names)
- extend self
- class << self
- public(*::Bundler::FileUtils::METHODS)
- end
- end
-
-end
diff --git a/lib/bundler/vendor/fileutils/lib/fileutils/version.rb b/lib/bundler/vendor/fileutils/lib/fileutils/version.rb
deleted file mode 100644
index b8f616e4fb..0000000000
--- a/lib/bundler/vendor/fileutils/lib/fileutils/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::FileUtils
- VERSION = "1.3.0"
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo.rb b/lib/bundler/vendor/molinillo/lib/molinillo.rb
deleted file mode 100644
index baedefe98b..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'molinillo/compatibility'
-require_relative 'molinillo/gem_metadata'
-require_relative 'molinillo/errors'
-require_relative 'molinillo/resolver'
-require_relative 'molinillo/modules/ui'
-require_relative 'molinillo/modules/specification_provider'
-
-# Bundler::Molinillo is a generic dependency resolution algorithm.
-module Bundler::Molinillo
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb b/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb
deleted file mode 100644
index 3eba8e4083..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- # Hacks needed for old Ruby versions.
- module Compatibility
- module_function
-
- if [].respond_to?(:flat_map)
- # Flat map
- # @param [Enumerable] enum an enumerable object
- # @block the block to flat-map with
- # @return The enum, flat-mapped
- def flat_map(enum, &blk)
- enum.flat_map(&blk)
- end
- else
- # Flat map
- # @param [Enumerable] enum an enumerable object
- # @block the block to flat-map with
- # @return The enum, flat-mapped
- def flat_map(enum, &blk)
- enum.map(&blk).flatten(1)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb b/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb
deleted file mode 100644
index bcacf35243..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- # @!visibility private
- module Delegates
- # Delegates all {Bundler::Molinillo::ResolutionState} methods to a `#state` property.
- module ResolutionState
- # (see Bundler::Molinillo::ResolutionState#name)
- def name
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.name
- end
-
- # (see Bundler::Molinillo::ResolutionState#requirements)
- def requirements
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.requirements
- end
-
- # (see Bundler::Molinillo::ResolutionState#activated)
- def activated
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.activated
- end
-
- # (see Bundler::Molinillo::ResolutionState#requirement)
- def requirement
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.requirement
- end
-
- # (see Bundler::Molinillo::ResolutionState#possibilities)
- def possibilities
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.possibilities
- end
-
- # (see Bundler::Molinillo::ResolutionState#depth)
- def depth
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.depth
- end
-
- # (see Bundler::Molinillo::ResolutionState#conflicts)
- def conflicts
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.conflicts
- end
-
- # (see Bundler::Molinillo::ResolutionState#unused_unwind_options)
- def unused_unwind_options
- current_state = state || Bundler::Molinillo::ResolutionState.empty
- current_state.unused_unwind_options
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb b/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb
deleted file mode 100644
index ec9c770a28..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- module Delegates
- # Delegates all {Bundler::Molinillo::SpecificationProvider} methods to a
- # `#specification_provider` property.
- module SpecificationProvider
- # (see Bundler::Molinillo::SpecificationProvider#search_for)
- def search_for(dependency)
- with_no_such_dependency_error_handling do
- specification_provider.search_for(dependency)
- end
- end
-
- # (see Bundler::Molinillo::SpecificationProvider#dependencies_for)
- def dependencies_for(specification)
- with_no_such_dependency_error_handling do
- specification_provider.dependencies_for(specification)
- end
- end
-
- # (see Bundler::Molinillo::SpecificationProvider#requirement_satisfied_by?)
- def requirement_satisfied_by?(requirement, activated, spec)
- with_no_such_dependency_error_handling do
- specification_provider.requirement_satisfied_by?(requirement, activated, spec)
- end
- end
-
- # (see Bundler::Molinillo::SpecificationProvider#name_for)
- def name_for(dependency)
- with_no_such_dependency_error_handling do
- specification_provider.name_for(dependency)
- end
- end
-
- # (see Bundler::Molinillo::SpecificationProvider#name_for_explicit_dependency_source)
- def name_for_explicit_dependency_source
- with_no_such_dependency_error_handling do
- specification_provider.name_for_explicit_dependency_source
- end
- end
-
- # (see Bundler::Molinillo::SpecificationProvider#name_for_locking_dependency_source)
- def name_for_locking_dependency_source
- with_no_such_dependency_error_handling do
- specification_provider.name_for_locking_dependency_source
- end
- end
-
- # (see Bundler::Molinillo::SpecificationProvider#sort_dependencies)
- def sort_dependencies(dependencies, activated, conflicts)
- with_no_such_dependency_error_handling do
- specification_provider.sort_dependencies(dependencies, activated, conflicts)
- end
- end
-
- # (see Bundler::Molinillo::SpecificationProvider#allow_missing?)
- def allow_missing?(dependency)
- with_no_such_dependency_error_handling do
- specification_provider.allow_missing?(dependency)
- end
- end
-
- private
-
- # Ensures any raised {NoSuchDependencyError} has its
- # {NoSuchDependencyError#required_by} set.
- # @yield
- def with_no_such_dependency_error_handling
- yield
- rescue NoSuchDependencyError => error
- if state
- vertex = activated.vertex_named(name_for(error.dependency))
- error.required_by += vertex.incoming_edges.map { |e| e.origin.name }
- error.required_by << name_for_explicit_dependency_source unless vertex.explicit_requirements.empty?
- end
- raise
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
deleted file mode 100644
index 31578bb5bf..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
+++ /dev/null
@@ -1,223 +0,0 @@
-# frozen_string_literal: true
-
-require 'set'
-require 'tsort'
-
-require_relative 'dependency_graph/log'
-require_relative 'dependency_graph/vertex'
-
-module Bundler::Molinillo
- # A directed acyclic graph that is tuned to hold named dependencies
- class DependencyGraph
- include Enumerable
-
- # Enumerates through the vertices of the graph.
- # @return [Array<Vertex>] The graph's vertices.
- def each
- return vertices.values.each unless block_given?
- vertices.values.each { |v| yield v }
- end
-
- include TSort
-
- # @!visibility private
- alias tsort_each_node each
-
- # @!visibility private
- def tsort_each_child(vertex, &block)
- vertex.successors.each(&block)
- end
-
- # Topologically sorts the given vertices.
- # @param [Enumerable<Vertex>] vertices the vertices to be sorted, which must
- # all belong to the same graph.
- # @return [Array<Vertex>] The sorted vertices.
- def self.tsort(vertices)
- TSort.tsort(
- lambda { |b| vertices.each(&b) },
- lambda { |v, &b| (v.successors & vertices).each(&b) }
- )
- end
-
- # A directed edge of a {DependencyGraph}
- # @attr [Vertex] origin The origin of the directed edge
- # @attr [Vertex] destination The destination of the directed edge
- # @attr [Object] requirement The requirement the directed edge represents
- Edge = Struct.new(:origin, :destination, :requirement)
-
- # @return [{String => Vertex}] the vertices of the dependency graph, keyed
- # by {Vertex#name}
- attr_reader :vertices
-
- # @return [Log] the op log for this graph
- attr_reader :log
-
- # Initializes an empty dependency graph
- def initialize
- @vertices = {}
- @log = Log.new
- end
-
- # Tags the current state of the dependency as the given tag
- # @param [Object] tag an opaque tag for the current state of the graph
- # @return [Void]
- def tag(tag)
- log.tag(self, tag)
- end
-
- # Rewinds the graph to the state tagged as `tag`
- # @param [Object] tag the tag to rewind to
- # @return [Void]
- def rewind_to(tag)
- log.rewind_to(self, tag)
- end
-
- # Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices}
- # are properly copied.
- # @param [DependencyGraph] other the graph to copy.
- def initialize_copy(other)
- super
- @vertices = {}
- @log = other.log.dup
- traverse = lambda do |new_v, old_v|
- return if new_v.outgoing_edges.size == old_v.outgoing_edges.size
- old_v.outgoing_edges.each do |edge|
- destination = add_vertex(edge.destination.name, edge.destination.payload)
- add_edge_no_circular(new_v, destination, edge.requirement)
- traverse.call(destination, edge.destination)
- end
- end
- other.vertices.each do |name, vertex|
- new_vertex = add_vertex(name, vertex.payload, vertex.root?)
- new_vertex.explicit_requirements.replace(vertex.explicit_requirements)
- traverse.call(new_vertex, vertex)
- end
- end
-
- # @return [String] a string suitable for debugging
- def inspect
- "#{self.class}:#{vertices.values.inspect}"
- end
-
- # @param [Hash] options options for dot output.
- # @return [String] Returns a dot format representation of the graph
- def to_dot(options = {})
- edge_label = options.delete(:edge_label)
- raise ArgumentError, "Unknown options: #{options.keys}" unless options.empty?
-
- dot_vertices = []
- dot_edges = []
- vertices.each do |n, v|
- dot_vertices << " #{n} [label=\"{#{n}|#{v.payload}}\"]"
- v.outgoing_edges.each do |e|
- label = edge_label ? edge_label.call(e) : e.requirement
- dot_edges << " #{e.origin.name} -> #{e.destination.name} [label=#{label.to_s.dump}]"
- end
- end
-
- dot_vertices.uniq!
- dot_vertices.sort!
- dot_edges.uniq!
- dot_edges.sort!
-
- dot = dot_vertices.unshift('digraph G {').push('') + dot_edges.push('}')
- dot.join("\n")
- end
-
- # @return [Boolean] whether the two dependency graphs are equal, determined
- # by a recursive traversal of each {#root_vertices} and its
- # {Vertex#successors}
- def ==(other)
- return false unless other
- return true if equal?(other)
- vertices.each do |name, vertex|
- other_vertex = other.vertex_named(name)
- return false unless other_vertex
- return false unless vertex.payload == other_vertex.payload
- return false unless other_vertex.successors.to_set == vertex.successors.to_set
- end
- end
-
- # @param [String] name
- # @param [Object] payload
- # @param [Array<String>] parent_names
- # @param [Object] requirement the requirement that is requiring the child
- # @return [void]
- def add_child_vertex(name, payload, parent_names, requirement)
- root = !parent_names.delete(nil) { true }
- vertex = add_vertex(name, payload, root)
- vertex.explicit_requirements << requirement if root
- parent_names.each do |parent_name|
- parent_vertex = vertex_named(parent_name)
- add_edge(parent_vertex, vertex, requirement)
- end
- vertex
- end
-
- # Adds a vertex with the given name, or updates the existing one.
- # @param [String] name
- # @param [Object] payload
- # @return [Vertex] the vertex that was added to `self`
- def add_vertex(name, payload, root = false)
- log.add_vertex(self, name, payload, root)
- end
-
- # Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively
- # removing any non-root vertices that were orphaned in the process
- # @param [String] name
- # @return [Array<Vertex>] the vertices which have been detached
- def detach_vertex_named(name)
- log.detach_vertex_named(self, name)
- end
-
- # @param [String] name
- # @return [Vertex,nil] the vertex with the given name
- def vertex_named(name)
- vertices[name]
- end
-
- # @param [String] name
- # @return [Vertex,nil] the root vertex with the given name
- def root_vertex_named(name)
- vertex = vertex_named(name)
- vertex if vertex && vertex.root?
- end
-
- # Adds a new {Edge} to the dependency graph
- # @param [Vertex] origin
- # @param [Vertex] destination
- # @param [Object] requirement the requirement that this edge represents
- # @return [Edge] the added edge
- def add_edge(origin, destination, requirement)
- if destination.path_to?(origin)
- raise CircularDependencyError.new([origin, destination])
- end
- add_edge_no_circular(origin, destination, requirement)
- end
-
- # Deletes an {Edge} from the dependency graph
- # @param [Edge] edge
- # @return [Void]
- def delete_edge(edge)
- log.delete_edge(self, edge.origin.name, edge.destination.name, edge.requirement)
- end
-
- # Sets the payload of the vertex with the given name
- # @param [String] name the name of the vertex
- # @param [Object] payload the payload
- # @return [Void]
- def set_payload(name, payload)
- log.set_payload(self, name, payload)
- end
-
- private
-
- # Adds a new {Edge} to the dependency graph without checking for
- # circularity.
- # @param (see #add_edge)
- # @return (see #add_edge)
- def add_edge_no_circular(origin, destination, requirement)
- log.add_edge_no_circular(self, origin.name, destination.name, requirement)
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb
deleted file mode 100644
index c04c7eec9c..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- class DependencyGraph
- # An action that modifies a {DependencyGraph} that is reversible.
- # @abstract
- class Action
- # rubocop:disable Lint/UnusedMethodArgument
-
- # @return [Symbol] The name of the action.
- def self.action_name
- raise 'Abstract'
- end
-
- # Performs the action on the given graph.
- # @param [DependencyGraph] graph the graph to perform the action on.
- # @return [Void]
- def up(graph)
- raise 'Abstract'
- end
-
- # Reverses the action on the given graph.
- # @param [DependencyGraph] graph the graph to reverse the action on.
- # @return [Void]
- def down(graph)
- raise 'Abstract'
- end
-
- # @return [Action,Nil] The previous action
- attr_accessor :previous
-
- # @return [Action,Nil] The next action
- attr_accessor :next
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
deleted file mode 100644
index 946a08236e..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Bundler::Molinillo
- class DependencyGraph
- # @!visibility private
- # (see DependencyGraph#add_edge_no_circular)
- class AddEdgeNoCircular < Action
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :add_vertex
- end
-
- # (see Action#up)
- def up(graph)
- edge = make_edge(graph)
- edge.origin.outgoing_edges << edge
- edge.destination.incoming_edges << edge
- edge
- end
-
- # (see Action#down)
- def down(graph)
- edge = make_edge(graph)
- delete_first(edge.origin.outgoing_edges, edge)
- delete_first(edge.destination.incoming_edges, edge)
- end
-
- # @!group AddEdgeNoCircular
-
- # @return [String] the name of the origin of the edge
- attr_reader :origin
-
- # @return [String] the name of the destination of the edge
- attr_reader :destination
-
- # @return [Object] the requirement that the edge represents
- attr_reader :requirement
-
- # @param [DependencyGraph] graph the graph to find vertices from
- # @return [Edge] The edge this action adds
- def make_edge(graph)
- Edge.new(graph.vertex_named(origin), graph.vertex_named(destination), requirement)
- end
-
- # Initialize an action to add an edge to a dependency graph
- # @param [String] origin the name of the origin of the edge
- # @param [String] destination the name of the destination of the edge
- # @param [Object] requirement the requirement that the edge represents
- def initialize(origin, destination, requirement)
- @origin = origin
- @destination = destination
- @requirement = requirement
- end
-
- private
-
- def delete_first(array, item)
- return unless index = array.index(item)
- array.delete_at(index)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
deleted file mode 100644
index 483527daf8..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Bundler::Molinillo
- class DependencyGraph
- # @!visibility private
- # (see DependencyGraph#add_vertex)
- class AddVertex < Action # :nodoc:
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :add_vertex
- end
-
- # (see Action#up)
- def up(graph)
- if existing = graph.vertices[name]
- @existing_payload = existing.payload
- @existing_root = existing.root
- end
- vertex = existing || Vertex.new(name, payload)
- graph.vertices[vertex.name] = vertex
- vertex.payload ||= payload
- vertex.root ||= root
- vertex
- end
-
- # (see Action#down)
- def down(graph)
- if defined?(@existing_payload)
- vertex = graph.vertices[name]
- vertex.payload = @existing_payload
- vertex.root = @existing_root
- else
- graph.vertices.delete(name)
- end
- end
-
- # @!group AddVertex
-
- # @return [String] the name of the vertex
- attr_reader :name
-
- # @return [Object] the payload for the vertex
- attr_reader :payload
-
- # @return [Boolean] whether the vertex is root or not
- attr_reader :root
-
- # Initialize an action to add a vertex to a dependency graph
- # @param [String] name the name of the vertex
- # @param [Object] payload the payload for the vertex
- # @param [Boolean] root whether the vertex is root or not
- def initialize(name, payload, root)
- @name = name
- @payload = payload
- @root = root
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
deleted file mode 100644
index d81940585a..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Bundler::Molinillo
- class DependencyGraph
- # @!visibility private
- # (see DependencyGraph#delete_edge)
- class DeleteEdge < Action
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :delete_edge
- end
-
- # (see Action#up)
- def up(graph)
- edge = make_edge(graph)
- edge.origin.outgoing_edges.delete(edge)
- edge.destination.incoming_edges.delete(edge)
- end
-
- # (see Action#down)
- def down(graph)
- edge = make_edge(graph)
- edge.origin.outgoing_edges << edge
- edge.destination.incoming_edges << edge
- edge
- end
-
- # @!group DeleteEdge
-
- # @return [String] the name of the origin of the edge
- attr_reader :origin_name
-
- # @return [String] the name of the destination of the edge
- attr_reader :destination_name
-
- # @return [Object] the requirement that the edge represents
- attr_reader :requirement
-
- # @param [DependencyGraph] graph the graph to find vertices from
- # @return [Edge] The edge this action adds
- def make_edge(graph)
- Edge.new(
- graph.vertex_named(origin_name),
- graph.vertex_named(destination_name),
- requirement
- )
- end
-
- # Initialize an action to add an edge to a dependency graph
- # @param [String] origin_name the name of the origin of the edge
- # @param [String] destination_name the name of the destination of the edge
- # @param [Object] requirement the requirement that the edge represents
- def initialize(origin_name, destination_name, requirement)
- @origin_name = origin_name
- @destination_name = destination_name
- @requirement = requirement
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
deleted file mode 100644
index 36fce7c526..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Bundler::Molinillo
- class DependencyGraph
- # @!visibility private
- # @see DependencyGraph#detach_vertex_named
- class DetachVertexNamed < Action
- # @!group Action
-
- # (see Action#name)
- def self.action_name
- :add_vertex
- end
-
- # (see Action#up)
- def up(graph)
- return [] unless @vertex = graph.vertices.delete(name)
-
- removed_vertices = [@vertex]
- @vertex.outgoing_edges.each do |e|
- v = e.destination
- v.incoming_edges.delete(e)
- if !v.root? && v.incoming_edges.empty?
- removed_vertices.concat graph.detach_vertex_named(v.name)
- end
- end
-
- @vertex.incoming_edges.each do |e|
- v = e.origin
- v.outgoing_edges.delete(e)
- end
-
- removed_vertices
- end
-
- # (see Action#down)
- def down(graph)
- return unless @vertex
- graph.vertices[@vertex.name] = @vertex
- @vertex.outgoing_edges.each do |e|
- e.destination.incoming_edges << e
- end
- @vertex.incoming_edges.each do |e|
- e.origin.outgoing_edges << e
- end
- end
-
- # @!group DetachVertexNamed
-
- # @return [String] the name of the vertex to detach
- attr_reader :name
-
- # Initialize an action to detach a vertex from a dependency graph
- # @param [String] name the name of the vertex to detach
- def initialize(name)
- @name = name
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
deleted file mode 100644
index 6f0de19886..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'add_edge_no_circular'
-require_relative 'add_vertex'
-require_relative 'delete_edge'
-require_relative 'detach_vertex_named'
-require_relative 'set_payload'
-require_relative 'tag'
-
-module Bundler::Molinillo
- class DependencyGraph
- # A log for dependency graph actions
- class Log
- # Initializes an empty log
- def initialize
- @current_action = @first_action = nil
- end
-
- # @!macro [new] action
- # {include:DependencyGraph#$0}
- # @param [Graph] graph the graph to perform the action on
- # @param (see DependencyGraph#$0)
- # @return (see DependencyGraph#$0)
-
- # @macro action
- def tag(graph, tag)
- push_action(graph, Tag.new(tag))
- end
-
- # @macro action
- def add_vertex(graph, name, payload, root)
- push_action(graph, AddVertex.new(name, payload, root))
- end
-
- # @macro action
- def detach_vertex_named(graph, name)
- push_action(graph, DetachVertexNamed.new(name))
- end
-
- # @macro action
- def add_edge_no_circular(graph, origin, destination, requirement)
- push_action(graph, AddEdgeNoCircular.new(origin, destination, requirement))
- end
-
- # {include:DependencyGraph#delete_edge}
- # @param [Graph] graph the graph to perform the action on
- # @param [String] origin_name
- # @param [String] destination_name
- # @param [Object] requirement
- # @return (see DependencyGraph#delete_edge)
- def delete_edge(graph, origin_name, destination_name, requirement)
- push_action(graph, DeleteEdge.new(origin_name, destination_name, requirement))
- end
-
- # @macro action
- def set_payload(graph, name, payload)
- push_action(graph, SetPayload.new(name, payload))
- end
-
- # Pops the most recent action from the log and undoes the action
- # @param [DependencyGraph] graph
- # @return [Action] the action that was popped off the log
- def pop!(graph)
- return unless action = @current_action
- unless @current_action = action.previous
- @first_action = nil
- end
- action.down(graph)
- action
- end
-
- extend Enumerable
-
- # @!visibility private
- # Enumerates each action in the log
- # @yield [Action]
- def each
- return enum_for unless block_given?
- action = @first_action
- loop do
- break unless action
- yield action
- action = action.next
- end
- self
- end
-
- # @!visibility private
- # Enumerates each action in the log in reverse order
- # @yield [Action]
- def reverse_each
- return enum_for(:reverse_each) unless block_given?
- action = @current_action
- loop do
- break unless action
- yield action
- action = action.previous
- end
- self
- end
-
- # @macro action
- def rewind_to(graph, tag)
- loop do
- action = pop!(graph)
- raise "No tag #{tag.inspect} found" unless action
- break if action.class.action_name == :tag && action.tag == tag
- end
- end
-
- private
-
- # Adds the given action to the log, running the action
- # @param [DependencyGraph] graph
- # @param [Action] action
- # @return The value returned by `action.up`
- def push_action(graph, action)
- action.previous = @current_action
- @current_action.next = action if @current_action
- @current_action = action
- @first_action ||= action
- action.up(graph)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb
deleted file mode 100644
index 2e9b90e6cd..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Bundler::Molinillo
- class DependencyGraph
- # @!visibility private
- # @see DependencyGraph#set_payload
- class SetPayload < Action # :nodoc:
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :set_payload
- end
-
- # (see Action#up)
- def up(graph)
- vertex = graph.vertex_named(name)
- @old_payload = vertex.payload
- vertex.payload = payload
- end
-
- # (see Action#down)
- def down(graph)
- graph.vertex_named(name).payload = @old_payload
- end
-
- # @!group SetPayload
-
- # @return [String] the name of the vertex
- attr_reader :name
-
- # @return [Object] the payload for the vertex
- attr_reader :payload
-
- # Initialize an action to add set the payload for a vertex in a dependency
- # graph
- # @param [String] name the name of the vertex
- # @param [Object] payload the payload for the vertex
- def initialize(name, payload)
- @name = name
- @payload = payload
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb
deleted file mode 100644
index fccfc78cc7..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Bundler::Molinillo
- class DependencyGraph
- # @!visibility private
- # @see DependencyGraph#tag
- class Tag < Action
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :tag
- end
-
- # (see Action#up)
- def up(_graph)
- end
-
- # (see Action#down)
- def down(_graph)
- end
-
- # @!group Tag
-
- # @return [Object] An opaque tag
- attr_reader :tag
-
- # Initialize an action to tag a state of a dependency graph
- # @param [Object] tag an opaque tag
- def initialize(tag)
- @tag = tag
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb
deleted file mode 100644
index 41bc013143..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb
+++ /dev/null
@@ -1,158 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- class DependencyGraph
- # A vertex in a {DependencyGraph} that encapsulates a {#name} and a
- # {#payload}
- class Vertex
- # @return [String] the name of the vertex
- attr_accessor :name
-
- # @return [Object] the payload the vertex holds
- attr_accessor :payload
-
- # @return [Array<Object>] the explicit requirements that required
- # this vertex
- attr_reader :explicit_requirements
-
- # @return [Boolean] whether the vertex is considered a root vertex
- attr_accessor :root
- alias root? root
-
- # Initializes a vertex with the given name and payload.
- # @param [String] name see {#name}
- # @param [Object] payload see {#payload}
- def initialize(name, payload)
- @name = name.frozen? ? name : name.dup.freeze
- @payload = payload
- @explicit_requirements = []
- @outgoing_edges = []
- @incoming_edges = []
- end
-
- # @return [Array<Object>] all of the requirements that required
- # this vertex
- def requirements
- (incoming_edges.map(&:requirement) + explicit_requirements).uniq
- end
-
- # @return [Array<Edge>] the edges of {#graph} that have `self` as their
- # {Edge#origin}
- attr_accessor :outgoing_edges
-
- # @return [Array<Edge>] the edges of {#graph} that have `self` as their
- # {Edge#destination}
- attr_accessor :incoming_edges
-
- # @return [Array<Vertex>] the vertices of {#graph} that have an edge with
- # `self` as their {Edge#destination}
- def predecessors
- incoming_edges.map(&:origin)
- end
-
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is a
- # {#descendent?}
- def recursive_predecessors
- _recursive_predecessors
- end
-
- # @param [Set<Vertex>] vertices the set to add the predecessors to
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is a
- # {#descendent?}
- def _recursive_predecessors(vertices = Set.new)
- incoming_edges.each do |edge|
- vertex = edge.origin
- next unless vertices.add?(vertex)
- vertex._recursive_predecessors(vertices)
- end
-
- vertices
- end
- protected :_recursive_predecessors
-
- # @return [Array<Vertex>] the vertices of {#graph} that have an edge with
- # `self` as their {Edge#origin}
- def successors
- outgoing_edges.map(&:destination)
- end
-
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is an
- # {#ancestor?}
- def recursive_successors
- _recursive_successors
- end
-
- # @param [Set<Vertex>] vertices the set to add the successors to
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is an
- # {#ancestor?}
- def _recursive_successors(vertices = Set.new)
- outgoing_edges.each do |edge|
- vertex = edge.destination
- next unless vertices.add?(vertex)
- vertex._recursive_successors(vertices)
- end
-
- vertices
- end
- protected :_recursive_successors
-
- # @return [String] a string suitable for debugging
- def inspect
- "#{self.class}:#{name}(#{payload.inspect})"
- end
-
- # @return [Boolean] whether the two vertices are equal, determined
- # by a recursive traversal of each {Vertex#successors}
- def ==(other)
- return true if equal?(other)
- shallow_eql?(other) &&
- successors.to_set == other.successors.to_set
- end
-
- # @param [Vertex] other the other vertex to compare to
- # @return [Boolean] whether the two vertices are equal, determined
- # solely by {#name} and {#payload} equality
- def shallow_eql?(other)
- return true if equal?(other)
- other &&
- name == other.name &&
- payload == other.payload
- end
-
- alias eql? ==
-
- # @return [Fixnum] a hash for the vertex based upon its {#name}
- def hash
- name.hash
- end
-
- # Is there a path from `self` to `other` following edges in the
- # dependency graph?
- # @return true iff there is a path following edges within this {#graph}
- def path_to?(other)
- _path_to?(other)
- end
-
- alias descendent? path_to?
-
- # @param [Vertex] other the vertex to check if there's a path to
- # @param [Set<Vertex>] visited the vertices of {#graph} that have been visited
- # @return [Boolean] whether there is a path to `other` from `self`
- def _path_to?(other, visited = Set.new)
- return false unless visited.add?(self)
- return true if equal?(other)
- successors.any? { |v| v._path_to?(other, visited) }
- end
- protected :_path_to?
-
- # Is there a path from `other` to `self` following edges in the
- # dependency graph?
- # @return true iff there is a path following edges within this {#graph}
- def ancestor?(other)
- other.path_to?(self)
- end
-
- alias is_reachable_from? ancestor?
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb b/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
deleted file mode 100644
index 89c7c324d5..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- # An error that occurred during the resolution process
- class ResolverError < StandardError; end
-
- # An error caused by searching for a dependency that is completely unknown,
- # i.e. has no versions available whatsoever.
- class NoSuchDependencyError < ResolverError
- # @return [Object] the dependency that could not be found
- attr_accessor :dependency
-
- # @return [Array<Object>] the specifications that depended upon {#dependency}
- attr_accessor :required_by
-
- # Initializes a new error with the given missing dependency.
- # @param [Object] dependency @see {#dependency}
- # @param [Array<Object>] required_by @see {#required_by}
- def initialize(dependency, required_by = [])
- @dependency = dependency
- @required_by = required_by.uniq
- super()
- end
-
- # The error message for the missing dependency, including the specifications
- # that had this dependency.
- def message
- sources = required_by.map { |r| "`#{r}`" }.join(' and ')
- message = "Unable to find a specification for `#{dependency}`"
- message += " depended upon by #{sources}" unless sources.empty?
- message
- end
- end
-
- # An error caused by attempting to fulfil a dependency that was circular
- #
- # @note This exception will be thrown iff a {Vertex} is added to a
- # {DependencyGraph} that has a {DependencyGraph::Vertex#path_to?} an
- # existing {DependencyGraph::Vertex}
- class CircularDependencyError < ResolverError
- # [Set<Object>] the dependencies responsible for causing the error
- attr_reader :dependencies
-
- # Initializes a new error with the given circular vertices.
- # @param [Array<DependencyGraph::Vertex>] vertices the vertices in the dependency
- # that caused the error
- def initialize(vertices)
- super "There is a circular dependency between #{vertices.map(&:name).join(' and ')}"
- @dependencies = vertices.map { |vertex| vertex.payload.possibilities.last }.to_set
- end
- end
-
- # An error caused by conflicts in version
- class VersionConflict < ResolverError
- # @return [{String => Resolution::Conflict}] the conflicts that caused
- # resolution to fail
- attr_reader :conflicts
-
- # @return [SpecificationProvider] the specification provider used during
- # resolution
- attr_reader :specification_provider
-
- # Initializes a new error with the given version conflicts.
- # @param [{String => Resolution::Conflict}] conflicts see {#conflicts}
- # @param [SpecificationProvider] specification_provider see {#specification_provider}
- def initialize(conflicts, specification_provider)
- pairs = []
- Compatibility.flat_map(conflicts.values.flatten, &:requirements).each do |conflicting|
- conflicting.each do |source, conflict_requirements|
- conflict_requirements.each do |c|
- pairs << [c, source]
- end
- end
- end
-
- super "Unable to satisfy the following requirements:\n\n" \
- "#{pairs.map { |r, d| "- `#{r}` required by `#{d}`" }.join("\n")}"
-
- @conflicts = conflicts
- @specification_provider = specification_provider
- end
-
- require_relative 'delegates/specification_provider'
- include Delegates::SpecificationProvider
-
- # @return [String] An error message that includes requirement trees,
- # which is much more detailed & customizable than the default message
- # @param [Hash] opts the options to create a message with.
- # @option opts [String] :solver_name The user-facing name of the solver
- # @option opts [String] :possibility_type The generic name of a possibility
- # @option opts [Proc] :reduce_trees A proc that reduced the list of requirement trees
- # @option opts [Proc] :printable_requirement A proc that pretty-prints requirements
- # @option opts [Proc] :additional_message_for_conflict A proc that appends additional
- # messages for each conflict
- # @option opts [Proc] :version_for_spec A proc that returns the version number for a
- # possibility
- def message_with_trees(opts = {})
- solver_name = opts.delete(:solver_name) { self.class.name.split('::').first }
- possibility_type = opts.delete(:possibility_type) { 'possibility named' }
- reduce_trees = opts.delete(:reduce_trees) { proc { |trees| trees.uniq.sort_by(&:to_s) } }
- printable_requirement = opts.delete(:printable_requirement) { proc { |req| req.to_s } }
- additional_message_for_conflict = opts.delete(:additional_message_for_conflict) { proc {} }
- version_for_spec = opts.delete(:version_for_spec) { proc(&:to_s) }
- incompatible_version_message_for_conflict = opts.delete(:incompatible_version_message_for_conflict) do
- proc do |name, _conflict|
- %(#{solver_name} could not find compatible versions for #{possibility_type} "#{name}":)
- end
- end
-
- conflicts.sort.reduce(''.dup) do |o, (name, conflict)|
- o << "\n" << incompatible_version_message_for_conflict.call(name, conflict) << "\n"
- if conflict.locked_requirement
- o << %( In snapshot (#{name_for_locking_dependency_source}):\n)
- o << %( #{printable_requirement.call(conflict.locked_requirement)}\n)
- o << %(\n)
- end
- o << %( In #{name_for_explicit_dependency_source}:\n)
- trees = reduce_trees.call(conflict.requirement_trees)
-
- o << trees.map do |tree|
- t = ''.dup
- depth = 2
- tree.each do |req|
- t << ' ' * depth << req.to_s
- unless tree.last == req
- if spec = conflict.activated_by_name[name_for(req)]
- t << %( was resolved to #{version_for_spec.call(spec)}, which)
- end
- t << %( depends on)
- end
- t << %(\n)
- depth += 1
- end
- t
- end.join("\n")
-
- additional_message_for_conflict.call(o, name, conflict)
-
- o
- end.strip
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb b/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
deleted file mode 100644
index 73f8fbf2ac..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- # The version of Bundler::Molinillo.
- VERSION = '0.6.6'.freeze
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb b/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb
deleted file mode 100644
index fa094c1981..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- # Provides information about specifcations and dependencies to the resolver,
- # allowing the {Resolver} class to remain generic while still providing power
- # and flexibility.
- #
- # This module contains the methods that users of Bundler::Molinillo must to implement,
- # using knowledge of their own model classes.
- module SpecificationProvider
- # Search for the specifications that match the given dependency.
- # The specifications in the returned array will be considered in reverse
- # order, so the latest version ought to be last.
- # @note This method should be 'pure', i.e. the return value should depend
- # only on the `dependency` parameter.
- #
- # @param [Object] dependency
- # @return [Array<Object>] the specifications that satisfy the given
- # `dependency`.
- def search_for(dependency)
- []
- end
-
- # Returns the dependencies of `specification`.
- # @note This method should be 'pure', i.e. the return value should depend
- # only on the `specification` parameter.
- #
- # @param [Object] specification
- # @return [Array<Object>] the dependencies that are required by the given
- # `specification`.
- def dependencies_for(specification)
- []
- end
-
- # Determines whether the given `requirement` is satisfied by the given
- # `spec`, in the context of the current `activated` dependency graph.
- #
- # @param [Object] requirement
- # @param [DependencyGraph] activated the current dependency graph in the
- # resolution process.
- # @param [Object] spec
- # @return [Boolean] whether `requirement` is satisfied by `spec` in the
- # context of the current `activated` dependency graph.
- def requirement_satisfied_by?(requirement, activated, spec)
- true
- end
-
- # Returns the name for the given `dependency`.
- # @note This method should be 'pure', i.e. the return value should depend
- # only on the `dependency` parameter.
- #
- # @param [Object] dependency
- # @return [String] the name for the given `dependency`.
- def name_for(dependency)
- dependency.to_s
- end
-
- # @return [String] the name of the source of explicit dependencies, i.e.
- # those passed to {Resolver#resolve} directly.
- def name_for_explicit_dependency_source
- 'user-specified dependency'
- end
-
- # @return [String] the name of the source of 'locked' dependencies, i.e.
- # those passed to {Resolver#resolve} directly as the `base`
- def name_for_locking_dependency_source
- 'Lockfile'
- end
-
- # Sort dependencies so that the ones that are easiest to resolve are first.
- # Easiest to resolve is (usually) defined by:
- # 1) Is this dependency already activated?
- # 2) How relaxed are the requirements?
- # 3) Are there any conflicts for this dependency?
- # 4) How many possibilities are there to satisfy this dependency?
- #
- # @param [Array<Object>] dependencies
- # @param [DependencyGraph] activated the current dependency graph in the
- # resolution process.
- # @param [{String => Array<Conflict>}] conflicts
- # @return [Array<Object>] a sorted copy of `dependencies`.
- def sort_dependencies(dependencies, activated, conflicts)
- dependencies.sort_by do |dependency|
- name = name_for(dependency)
- [
- activated.vertex_named(name).payload ? 0 : 1,
- conflicts[name] ? 0 : 1,
- ]
- end
- end
-
- # Returns whether this dependency, which has no possible matching
- # specifications, can safely be ignored.
- #
- # @param [Object] dependency
- # @return [Boolean] whether this dependency can safely be skipped.
- def allow_missing?(dependency)
- false
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb b/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
deleted file mode 100644
index a166bc6991..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- # Conveys information about the resolution process to a user.
- module UI
- # The {IO} object that should be used to print output. `STDOUT`, by default.
- #
- # @return [IO]
- def output
- STDOUT
- end
-
- # Called roughly every {#progress_rate}, this method should convey progress
- # to the user.
- #
- # @return [void]
- def indicate_progress
- output.print '.' unless debug?
- end
-
- # How often progress should be conveyed to the user via
- # {#indicate_progress}, in seconds. A third of a second, by default.
- #
- # @return [Float]
- def progress_rate
- 0.33
- end
-
- # Called before resolution begins.
- #
- # @return [void]
- def before_resolution
- output.print 'Resolving dependencies...'
- end
-
- # Called after resolution ends (either successfully or with an error).
- # By default, prints a newline.
- #
- # @return [void]
- def after_resolution
- output.puts
- end
-
- # Conveys debug information to the user.
- #
- # @param [Integer] depth the current depth of the resolution process.
- # @return [void]
- def debug(depth = 0)
- if debug?
- debug_info = yield
- debug_info = debug_info.inspect unless debug_info.is_a?(String)
- debug_info = debug_info.split("\n").map { |s| ":#{depth.to_s.rjust 4}: #{s}" }
- output.puts debug_info
- end
- end
-
- # Whether or not debug messages should be printed.
- # By default, whether or not the `MOLINILLO_DEBUG` environment variable is
- # set.
- #
- # @return [Boolean]
- def debug?
- return @debug_mode if defined?(@debug_mode)
- @debug_mode = ENV['MOLINILLO_DEBUG']
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
deleted file mode 100644
index acf7777414..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
+++ /dev/null
@@ -1,837 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- class Resolver
- # A specific resolution from a given {Resolver}
- class Resolution
- # A conflict that the resolution process encountered
- # @attr [Object] requirement the requirement that immediately led to the conflict
- # @attr [{String,Nil=>[Object]}] requirements the requirements that caused the conflict
- # @attr [Object, nil] existing the existing spec that was in conflict with
- # the {#possibility}
- # @attr [Object] possibility_set the set of specs that was unable to be
- # activated due to a conflict.
- # @attr [Object] locked_requirement the relevant locking requirement.
- # @attr [Array<Array<Object>>] requirement_trees the different requirement
- # trees that led to every requirement for the conflicting name.
- # @attr [{String=>Object}] activated_by_name the already-activated specs.
- # @attr [Object] underlying_error an error that has occurred during resolution, and
- # will be raised at the end of it if no resolution is found.
- Conflict = Struct.new(
- :requirement,
- :requirements,
- :existing,
- :possibility_set,
- :locked_requirement,
- :requirement_trees,
- :activated_by_name,
- :underlying_error
- )
-
- class Conflict
- # @return [Object] a spec that was unable to be activated due to a conflict
- def possibility
- possibility_set && possibility_set.latest_version
- end
- end
-
- # A collection of possibility states that share the same dependencies
- # @attr [Array] dependencies the dependencies for this set of possibilities
- # @attr [Array] possibilities the possibilities
- PossibilitySet = Struct.new(:dependencies, :possibilities)
-
- class PossibilitySet
- # String representation of the possibility set, for debugging
- def to_s
- "[#{possibilities.join(', ')}]"
- end
-
- # @return [Object] most up-to-date dependency in the possibility set
- def latest_version
- possibilities.last
- end
- end
-
- # Details of the state to unwind to when a conflict occurs, and the cause of the unwind
- # @attr [Integer] state_index the index of the state to unwind to
- # @attr [Object] state_requirement the requirement of the state we're unwinding to
- # @attr [Array] requirement_tree for the requirement we're relaxing
- # @attr [Array] conflicting_requirements the requirements that combined to cause the conflict
- # @attr [Array] requirement_trees for the conflict
- # @attr [Array] requirements_unwound_to_instead array of unwind requirements that were chosen over this unwind
- UnwindDetails = Struct.new(
- :state_index,
- :state_requirement,
- :requirement_tree,
- :conflicting_requirements,
- :requirement_trees,
- :requirements_unwound_to_instead
- )
-
- class UnwindDetails
- include Comparable
-
- # We compare UnwindDetails when choosing which state to unwind to. If
- # two options have the same state_index we prefer the one most
- # removed from a requirement that caused the conflict. Both options
- # would unwind to the same state, but a `grandparent` option will
- # filter out fewer of its possibilities after doing so - where a state
- # is both a `parent` and a `grandparent` to requirements that have
- # caused a conflict this is the correct behaviour.
- # @param [UnwindDetail] other UnwindDetail to be compared
- # @return [Integer] integer specifying ordering
- def <=>(other)
- if state_index > other.state_index
- 1
- elsif state_index == other.state_index
- reversed_requirement_tree_index <=> other.reversed_requirement_tree_index
- else
- -1
- end
- end
-
- # @return [Integer] index of state requirement in reversed requirement tree
- # (the conflicting requirement itself will be at position 0)
- def reversed_requirement_tree_index
- @reversed_requirement_tree_index ||=
- if state_requirement
- requirement_tree.reverse.index(state_requirement)
- else
- 999_999
- end
- end
-
- # @return [Boolean] where the requirement of the state we're unwinding
- # to directly caused the conflict. Note: in this case, it is
- # impossible for the state we're unwinding to to be a parent of
- # any of the other conflicting requirements (or we would have
- # circularity)
- def unwinding_to_primary_requirement?
- requirement_tree.last == state_requirement
- end
-
- # @return [Array] array of sub-dependencies to avoid when choosing a
- # new possibility for the state we've unwound to. Only relevant for
- # non-primary unwinds
- def sub_dependencies_to_avoid
- @requirements_to_avoid ||=
- requirement_trees.map do |tree|
- index = tree.index(state_requirement)
- tree[index + 1] if index
- end.compact
- end
-
- # @return [Array] array of all the requirements that led to the need for
- # this unwind
- def all_requirements
- @all_requirements ||= requirement_trees.flatten(1)
- end
- end
-
- # @return [SpecificationProvider] the provider that knows about
- # dependencies, requirements, specifications, versions, etc.
- attr_reader :specification_provider
-
- # @return [UI] the UI that knows how to communicate feedback about the
- # resolution process back to the user
- attr_reader :resolver_ui
-
- # @return [DependencyGraph] the base dependency graph to which
- # dependencies should be 'locked'
- attr_reader :base
-
- # @return [Array] the dependencies that were explicitly required
- attr_reader :original_requested
-
- # Initializes a new resolution.
- # @param [SpecificationProvider] specification_provider
- # see {#specification_provider}
- # @param [UI] resolver_ui see {#resolver_ui}
- # @param [Array] requested see {#original_requested}
- # @param [DependencyGraph] base see {#base}
- def initialize(specification_provider, resolver_ui, requested, base)
- @specification_provider = specification_provider
- @resolver_ui = resolver_ui
- @original_requested = requested
- @base = base
- @states = []
- @iteration_counter = 0
- @parents_of = Hash.new { |h, k| h[k] = [] }
- end
-
- # Resolves the {#original_requested} dependencies into a full dependency
- # graph
- # @raise [ResolverError] if successful resolution is impossible
- # @return [DependencyGraph] the dependency graph of successfully resolved
- # dependencies
- def resolve
- start_resolution
-
- while state
- break if !state.requirement && state.requirements.empty?
- indicate_progress
- if state.respond_to?(:pop_possibility_state) # DependencyState
- debug(depth) { "Creating possibility state for #{requirement} (#{possibilities.count} remaining)" }
- state.pop_possibility_state.tap do |s|
- if s
- states.push(s)
- activated.tag(s)
- end
- end
- end
- process_topmost_state
- end
-
- resolve_activated_specs
- ensure
- end_resolution
- end
-
- # @return [Integer] the number of resolver iterations in between calls to
- # {#resolver_ui}'s {UI#indicate_progress} method
- attr_accessor :iteration_rate
- private :iteration_rate
-
- # @return [Time] the time at which resolution began
- attr_accessor :started_at
- private :started_at
-
- # @return [Array<ResolutionState>] the stack of states for the resolution
- attr_accessor :states
- private :states
-
- private
-
- # Sets up the resolution process
- # @return [void]
- def start_resolution
- @started_at = Time.now
-
- handle_missing_or_push_dependency_state(initial_state)
-
- debug { "Starting resolution (#{@started_at})\nUser-requested dependencies: #{original_requested}" }
- resolver_ui.before_resolution
- end
-
- def resolve_activated_specs
- activated.vertices.each do |_, vertex|
- next unless vertex.payload
-
- latest_version = vertex.payload.possibilities.reverse_each.find do |possibility|
- vertex.requirements.all? { |req| requirement_satisfied_by?(req, activated, possibility) }
- end
-
- activated.set_payload(vertex.name, latest_version)
- end
- activated.freeze
- end
-
- # Ends the resolution process
- # @return [void]
- def end_resolution
- resolver_ui.after_resolution
- debug do
- "Finished resolution (#{@iteration_counter} steps) " \
- "(Took #{(ended_at = Time.now) - @started_at} seconds) (#{ended_at})"
- end
- debug { 'Unactivated: ' + Hash[activated.vertices.reject { |_n, v| v.payload }].keys.join(', ') } if state
- debug { 'Activated: ' + Hash[activated.vertices.select { |_n, v| v.payload }].keys.join(', ') } if state
- end
-
- require_relative 'state'
- require_relative 'modules/specification_provider'
-
- require_relative 'delegates/resolution_state'
- require_relative 'delegates/specification_provider'
-
- include Bundler::Molinillo::Delegates::ResolutionState
- include Bundler::Molinillo::Delegates::SpecificationProvider
-
- # Processes the topmost available {RequirementState} on the stack
- # @return [void]
- def process_topmost_state
- if possibility
- attempt_to_activate
- else
- create_conflict
- unwind_for_conflict
- end
- rescue CircularDependencyError => underlying_error
- create_conflict(underlying_error)
- unwind_for_conflict
- end
-
- # @return [Object] the current possibility that the resolution is trying
- # to activate
- def possibility
- possibilities.last
- end
-
- # @return [RequirementState] the current state the resolution is
- # operating upon
- def state
- states.last
- end
-
- # Creates the initial state for the resolution, based upon the
- # {#requested} dependencies
- # @return [DependencyState] the initial state for the resolution
- def initial_state
- graph = DependencyGraph.new.tap do |dg|
- original_requested.each do |requested|
- vertex = dg.add_vertex(name_for(requested), nil, true)
- vertex.explicit_requirements << requested
- end
- dg.tag(:initial_state)
- end
-
- requirements = sort_dependencies(original_requested, graph, {})
- initial_requirement = requirements.shift
- DependencyState.new(
- initial_requirement && name_for(initial_requirement),
- requirements,
- graph,
- initial_requirement,
- possibilities_for_requirement(initial_requirement, graph),
- 0,
- {},
- []
- )
- end
-
- # Unwinds the states stack because a conflict has been encountered
- # @return [void]
- def unwind_for_conflict
- details_for_unwind = build_details_for_unwind
- unwind_options = unused_unwind_options
- debug(depth) { "Unwinding for conflict: #{requirement} to #{details_for_unwind.state_index / 2}" }
- conflicts.tap do |c|
- sliced_states = states.slice!((details_for_unwind.state_index + 1)..-1)
- raise_error_unless_state(c)
- activated.rewind_to(sliced_states.first || :initial_state) if sliced_states
- state.conflicts = c
- state.unused_unwind_options = unwind_options
- filter_possibilities_after_unwind(details_for_unwind)
- index = states.size - 1
- @parents_of.each { |_, a| a.reject! { |i| i >= index } }
- state.unused_unwind_options.reject! { |uw| uw.state_index >= index }
- end
- end
-
- # Raises a VersionConflict error, or any underlying error, if there is no
- # current state
- # @return [void]
- def raise_error_unless_state(conflicts)
- return if state
-
- error = conflicts.values.map(&:underlying_error).compact.first
- raise error || VersionConflict.new(conflicts, specification_provider)
- end
-
- # @return [UnwindDetails] Details of the nearest index to which we could unwind
- def build_details_for_unwind
- # Get the possible unwinds for the current conflict
- current_conflict = conflicts[name]
- binding_requirements = binding_requirements_for_conflict(current_conflict)
- unwind_details = unwind_options_for_requirements(binding_requirements)
-
- last_detail_for_current_unwind = unwind_details.sort.last
- current_detail = last_detail_for_current_unwind
-
- # Look for past conflicts that could be unwound to affect the
- # requirement tree for the current conflict
- relevant_unused_unwinds = unused_unwind_options.select do |alternative|
- intersecting_requirements =
- last_detail_for_current_unwind.all_requirements &
- alternative.requirements_unwound_to_instead
- next if intersecting_requirements.empty?
- # Find the highest index unwind whilst looping through
- current_detail = alternative if alternative > current_detail
- alternative
- end
-
- # Add the current unwind options to the `unused_unwind_options` array.
- # The "used" option will be filtered out during `unwind_for_conflict`.
- state.unused_unwind_options += unwind_details.reject { |detail| detail.state_index == -1 }
-
- # Update the requirements_unwound_to_instead on any relevant unused unwinds
- relevant_unused_unwinds.each { |d| d.requirements_unwound_to_instead << current_detail.state_requirement }
- unwind_details.each { |d| d.requirements_unwound_to_instead << current_detail.state_requirement }
-
- current_detail
- end
-
- # @param [Array<Object>] array of requirements that combine to create a conflict
- # @return [Array<UnwindDetails>] array of UnwindDetails that have a chance
- # of resolving the passed requirements
- def unwind_options_for_requirements(binding_requirements)
- unwind_details = []
-
- trees = []
- binding_requirements.reverse_each do |r|
- partial_tree = [r]
- trees << partial_tree
- unwind_details << UnwindDetails.new(-1, nil, partial_tree, binding_requirements, trees, [])
-
- # If this requirement has alternative possibilities, check if any would
- # satisfy the other requirements that created this conflict
- requirement_state = find_state_for(r)
- if conflict_fixing_possibilities?(requirement_state, binding_requirements)
- unwind_details << UnwindDetails.new(
- states.index(requirement_state),
- r,
- partial_tree,
- binding_requirements,
- trees,
- []
- )
- end
-
- # Next, look at the parent of this requirement, and check if the requirement
- # could have been avoided if an alternative PossibilitySet had been chosen
- parent_r = parent_of(r)
- next if parent_r.nil?
- partial_tree.unshift(parent_r)
- requirement_state = find_state_for(parent_r)
- if requirement_state.possibilities.any? { |set| !set.dependencies.include?(r) }
- unwind_details << UnwindDetails.new(
- states.index(requirement_state),
- parent_r,
- partial_tree,
- binding_requirements,
- trees,
- []
- )
- end
-
- # Finally, look at the grandparent and up of this requirement, looking
- # for any possibilities that wouldn't create their parent requirement
- grandparent_r = parent_of(parent_r)
- until grandparent_r.nil?
- partial_tree.unshift(grandparent_r)
- requirement_state = find_state_for(grandparent_r)
- if requirement_state.possibilities.any? { |set| !set.dependencies.include?(parent_r) }
- unwind_details << UnwindDetails.new(
- states.index(requirement_state),
- grandparent_r,
- partial_tree,
- binding_requirements,
- trees,
- []
- )
- end
- parent_r = grandparent_r
- grandparent_r = parent_of(parent_r)
- end
- end
-
- unwind_details
- end
-
- # @param [DependencyState] state
- # @param [Array] array of requirements
- # @return [Boolean] whether or not the given state has any possibilities
- # that could satisfy the given requirements
- def conflict_fixing_possibilities?(state, binding_requirements)
- return false unless state
-
- state.possibilities.any? do |possibility_set|
- possibility_set.possibilities.any? do |poss|
- possibility_satisfies_requirements?(poss, binding_requirements)
- end
- end
- end
-
- # Filter's a state's possibilities to remove any that would not fix the
- # conflict we've just rewound from
- # @param [UnwindDetails] details of the conflict just unwound from
- # @return [void]
- def filter_possibilities_after_unwind(unwind_details)
- return unless state && !state.possibilities.empty?
-
- if unwind_details.unwinding_to_primary_requirement?
- filter_possibilities_for_primary_unwind(unwind_details)
- else
- filter_possibilities_for_parent_unwind(unwind_details)
- end
- end
-
- # Filter's a state's possibilities to remove any that would not satisfy
- # the requirements in the conflict we've just rewound from
- # @param [UnwindDetails] details of the conflict just unwound from
- # @return [void]
- def filter_possibilities_for_primary_unwind(unwind_details)
- unwinds_to_state = unused_unwind_options.select { |uw| uw.state_index == unwind_details.state_index }
- unwinds_to_state << unwind_details
- unwind_requirement_sets = unwinds_to_state.map(&:conflicting_requirements)
-
- state.possibilities.reject! do |possibility_set|
- possibility_set.possibilities.none? do |poss|
- unwind_requirement_sets.any? do |requirements|
- possibility_satisfies_requirements?(poss, requirements)
- end
- end
- end
- end
-
- # @param [Object] possibility a single possibility
- # @param [Array] requirements an array of requirements
- # @return [Boolean] whether the possibility satisfies all of the
- # given requirements
- def possibility_satisfies_requirements?(possibility, requirements)
- name = name_for(possibility)
-
- activated.tag(:swap)
- activated.set_payload(name, possibility) if activated.vertex_named(name)
- satisfied = requirements.all? { |r| requirement_satisfied_by?(r, activated, possibility) }
- activated.rewind_to(:swap)
-
- satisfied
- end
-
- # Filter's a state's possibilities to remove any that would (eventually)
- # create a requirement in the conflict we've just rewound from
- # @param [UnwindDetails] details of the conflict just unwound from
- # @return [void]
- def filter_possibilities_for_parent_unwind(unwind_details)
- unwinds_to_state = unused_unwind_options.select { |uw| uw.state_index == unwind_details.state_index }
- unwinds_to_state << unwind_details
-
- primary_unwinds = unwinds_to_state.select(&:unwinding_to_primary_requirement?).uniq
- parent_unwinds = unwinds_to_state.uniq - primary_unwinds
-
- allowed_possibility_sets = Compatibility.flat_map(primary_unwinds) do |unwind|
- states[unwind.state_index].possibilities.select do |possibility_set|
- possibility_set.possibilities.any? do |poss|
- possibility_satisfies_requirements?(poss, unwind.conflicting_requirements)
- end
- end
- end
-
- requirements_to_avoid = Compatibility.flat_map(parent_unwinds, &:sub_dependencies_to_avoid)
-
- state.possibilities.reject! do |possibility_set|
- !allowed_possibility_sets.include?(possibility_set) &&
- (requirements_to_avoid - possibility_set.dependencies).empty?
- end
- end
-
- # @param [Conflict] conflict
- # @return [Array] minimal array of requirements that would cause the passed
- # conflict to occur.
- def binding_requirements_for_conflict(conflict)
- return [conflict.requirement] if conflict.possibility.nil?
-
- possible_binding_requirements = conflict.requirements.values.flatten(1).uniq
-
- # When there’s a `CircularDependency` error the conflicting requirement
- # (the one causing the circular) won’t be `conflict.requirement`
- # (which won’t be for the right state, because we won’t have created it,
- # because it’s circular).
- # We need to make sure we have that requirement in the conflict’s list,
- # otherwise we won’t be able to unwind properly, so we just return all
- # the requirements for the conflict.
- return possible_binding_requirements if conflict.underlying_error
-
- possibilities = search_for(conflict.requirement)
-
- # If all the requirements together don't filter out all possibilities,
- # then the only two requirements we need to consider are the initial one
- # (where the dependency's version was first chosen) and the last
- if binding_requirement_in_set?(nil, possible_binding_requirements, possibilities)
- return [conflict.requirement, requirement_for_existing_name(name_for(conflict.requirement))].compact
- end
-
- # Loop through the possible binding requirements, removing each one
- # that doesn't bind. Use a `reverse_each` as we want the earliest set of
- # binding requirements, and don't use `reject!` as we wish to refine the
- # array *on each iteration*.
- binding_requirements = possible_binding_requirements.dup
- possible_binding_requirements.reverse_each do |req|
- next if req == conflict.requirement
- unless binding_requirement_in_set?(req, binding_requirements, possibilities)
- binding_requirements -= [req]
- end
- end
-
- binding_requirements
- end
-
- # @param [Object] requirement we wish to check
- # @param [Array] array of requirements
- # @param [Array] array of possibilities the requirements will be used to filter
- # @return [Boolean] whether or not the given requirement is required to filter
- # out all elements of the array of possibilities.
- def binding_requirement_in_set?(requirement, possible_binding_requirements, possibilities)
- possibilities.any? do |poss|
- possibility_satisfies_requirements?(poss, possible_binding_requirements - [requirement])
- end
- end
-
- # @return [Object] the requirement that led to `requirement` being added
- # to the list of requirements.
- def parent_of(requirement)
- return unless requirement
- return unless index = @parents_of[requirement].last
- return unless parent_state = @states[index]
- parent_state.requirement
- end
-
- # @return [Object] the requirement that led to a version of a possibility
- # with the given name being activated.
- def requirement_for_existing_name(name)
- return nil unless vertex = activated.vertex_named(name)
- return nil unless vertex.payload
- states.find { |s| s.name == name }.requirement
- end
-
- # @return [ResolutionState] the state whose `requirement` is the given
- # `requirement`.
- def find_state_for(requirement)
- return nil unless requirement
- states.find { |i| requirement == i.requirement }
- end
-
- # @return [Conflict] a {Conflict} that reflects the failure to activate
- # the {#possibility} in conjunction with the current {#state}
- def create_conflict(underlying_error = nil)
- vertex = activated.vertex_named(name)
- locked_requirement = locked_requirement_named(name)
-
- requirements = {}
- unless vertex.explicit_requirements.empty?
- requirements[name_for_explicit_dependency_source] = vertex.explicit_requirements
- end
- requirements[name_for_locking_dependency_source] = [locked_requirement] if locked_requirement
- vertex.incoming_edges.each do |edge|
- (requirements[edge.origin.payload.latest_version] ||= []).unshift(edge.requirement)
- end
-
- activated_by_name = {}
- activated.each { |v| activated_by_name[v.name] = v.payload.latest_version if v.payload }
- conflicts[name] = Conflict.new(
- requirement,
- requirements,
- vertex.payload && vertex.payload.latest_version,
- possibility,
- locked_requirement,
- requirement_trees,
- activated_by_name,
- underlying_error
- )
- end
-
- # @return [Array<Array<Object>>] The different requirement
- # trees that led to every requirement for the current spec.
- def requirement_trees
- vertex = activated.vertex_named(name)
- vertex.requirements.map { |r| requirement_tree_for(r) }
- end
-
- # @return [Array<Object>] the list of requirements that led to
- # `requirement` being required.
- def requirement_tree_for(requirement)
- tree = []
- while requirement
- tree.unshift(requirement)
- requirement = parent_of(requirement)
- end
- tree
- end
-
- # Indicates progress roughly once every second
- # @return [void]
- def indicate_progress
- @iteration_counter += 1
- @progress_rate ||= resolver_ui.progress_rate
- if iteration_rate.nil?
- if Time.now - started_at >= @progress_rate
- self.iteration_rate = @iteration_counter
- end
- end
-
- if iteration_rate && (@iteration_counter % iteration_rate) == 0
- resolver_ui.indicate_progress
- end
- end
-
- # Calls the {#resolver_ui}'s {UI#debug} method
- # @param [Integer] depth the depth of the {#states} stack
- # @param [Proc] block a block that yields a {#to_s}
- # @return [void]
- def debug(depth = 0, &block)
- resolver_ui.debug(depth, &block)
- end
-
- # Attempts to activate the current {#possibility}
- # @return [void]
- def attempt_to_activate
- debug(depth) { 'Attempting to activate ' + possibility.to_s }
- existing_vertex = activated.vertex_named(name)
- if existing_vertex.payload
- debug(depth) { "Found existing spec (#{existing_vertex.payload})" }
- attempt_to_filter_existing_spec(existing_vertex)
- else
- latest = possibility.latest_version
- # use reject!(!satisfied) for 1.8.7 compatibility
- possibility.possibilities.reject! do |possibility|
- !requirement_satisfied_by?(requirement, activated, possibility)
- end
- if possibility.latest_version.nil?
- # ensure there's a possibility for better error messages
- possibility.possibilities << latest if latest
- create_conflict
- unwind_for_conflict
- else
- activate_new_spec
- end
- end
- end
-
- # Attempts to update the existing vertex's `PossibilitySet` with a filtered version
- # @return [void]
- def attempt_to_filter_existing_spec(vertex)
- filtered_set = filtered_possibility_set(vertex)
- if !filtered_set.possibilities.empty?
- activated.set_payload(name, filtered_set)
- new_requirements = requirements.dup
- push_state_for_requirements(new_requirements, false)
- else
- create_conflict
- debug(depth) { "Unsatisfied by existing spec (#{vertex.payload})" }
- unwind_for_conflict
- end
- end
-
- # Generates a filtered version of the existing vertex's `PossibilitySet` using the
- # current state's `requirement`
- # @param [Object] existing vertex
- # @return [PossibilitySet] filtered possibility set
- def filtered_possibility_set(vertex)
- PossibilitySet.new(vertex.payload.dependencies, vertex.payload.possibilities & possibility.possibilities)
- end
-
- # @param [String] requirement_name the spec name to search for
- # @return [Object] the locked spec named `requirement_name`, if one
- # is found on {#base}
- def locked_requirement_named(requirement_name)
- vertex = base.vertex_named(requirement_name)
- vertex && vertex.payload
- end
-
- # Add the current {#possibility} to the dependency graph of the current
- # {#state}
- # @return [void]
- def activate_new_spec
- conflicts.delete(name)
- debug(depth) { "Activated #{name} at #{possibility}" }
- activated.set_payload(name, possibility)
- require_nested_dependencies_for(possibility)
- end
-
- # Requires the dependencies that the recently activated spec has
- # @param [Object] activated_possibility the PossibilitySet that has just been
- # activated
- # @return [void]
- def require_nested_dependencies_for(possibility_set)
- nested_dependencies = dependencies_for(possibility_set.latest_version)
- debug(depth) { "Requiring nested dependencies (#{nested_dependencies.join(', ')})" }
- nested_dependencies.each do |d|
- activated.add_child_vertex(name_for(d), nil, [name_for(possibility_set.latest_version)], d)
- parent_index = states.size - 1
- parents = @parents_of[d]
- parents << parent_index if parents.empty?
- end
-
- push_state_for_requirements(requirements + nested_dependencies, !nested_dependencies.empty?)
- end
-
- # Pushes a new {DependencyState} that encapsulates both existing and new
- # requirements
- # @param [Array] new_requirements
- # @return [void]
- def push_state_for_requirements(new_requirements, requires_sort = true, new_activated = activated)
- new_requirements = sort_dependencies(new_requirements.uniq, new_activated, conflicts) if requires_sort
- new_requirement = nil
- loop do
- new_requirement = new_requirements.shift
- break if new_requirement.nil? || states.none? { |s| s.requirement == new_requirement }
- end
- new_name = new_requirement ? name_for(new_requirement) : ''.freeze
- possibilities = possibilities_for_requirement(new_requirement)
- handle_missing_or_push_dependency_state DependencyState.new(
- new_name, new_requirements, new_activated,
- new_requirement, possibilities, depth, conflicts.dup, unused_unwind_options.dup
- )
- end
-
- # Checks a proposed requirement with any existing locked requirement
- # before generating an array of possibilities for it.
- # @param [Object] the proposed requirement
- # @return [Array] possibilities
- def possibilities_for_requirement(requirement, activated = self.activated)
- return [] unless requirement
- if locked_requirement_named(name_for(requirement))
- return locked_requirement_possibility_set(requirement, activated)
- end
-
- group_possibilities(search_for(requirement))
- end
-
- # @param [Object] the proposed requirement
- # @return [Array] possibility set containing only the locked requirement, if any
- def locked_requirement_possibility_set(requirement, activated = self.activated)
- all_possibilities = search_for(requirement)
- locked_requirement = locked_requirement_named(name_for(requirement))
-
- # Longwinded way to build a possibilities array with either the locked
- # requirement or nothing in it. Required, since the API for
- # locked_requirement isn't guaranteed.
- locked_possibilities = all_possibilities.select do |possibility|
- requirement_satisfied_by?(locked_requirement, activated, possibility)
- end
-
- group_possibilities(locked_possibilities)
- end
-
- # Build an array of PossibilitySets, with each element representing a group of
- # dependency versions that all have the same sub-dependency version constraints
- # and are contiguous.
- # @param [Array] an array of possibilities
- # @return [Array] an array of possibility sets
- def group_possibilities(possibilities)
- possibility_sets = []
- current_possibility_set = nil
-
- possibilities.reverse_each do |possibility|
- dependencies = dependencies_for(possibility)
- if current_possibility_set && current_possibility_set.dependencies == dependencies
- current_possibility_set.possibilities.unshift(possibility)
- else
- possibility_sets.unshift(PossibilitySet.new(dependencies, [possibility]))
- current_possibility_set = possibility_sets.first
- end
- end
-
- possibility_sets
- end
-
- # Pushes a new {DependencyState}.
- # If the {#specification_provider} says to
- # {SpecificationProvider#allow_missing?} that particular requirement, and
- # there are no possibilities for that requirement, then `state` is not
- # pushed, and the vertex in {#activated} is removed, and we continue
- # resolving the remaining requirements.
- # @param [DependencyState] state
- # @return [void]
- def handle_missing_or_push_dependency_state(state)
- if state.requirement && state.possibilities.empty? && allow_missing?(state.requirement)
- state.activated.detach_vertex_named(state.name)
- push_state_for_requirements(state.requirements.dup, false, state.activated)
- else
- states.push(state).tap { activated.tag(state) }
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
deleted file mode 100644
index 95eaab5991..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'dependency_graph'
-
-module Bundler::Molinillo
- # This class encapsulates a dependency resolver.
- # The resolver is responsible for determining which set of dependencies to
- # activate, with feedback from the {#specification_provider}
- #
- #
- class Resolver
- require_relative 'resolution'
-
- # @return [SpecificationProvider] the specification provider used
- # in the resolution process
- attr_reader :specification_provider
-
- # @return [UI] the UI module used to communicate back to the user
- # during the resolution process
- attr_reader :resolver_ui
-
- # Initializes a new resolver.
- # @param [SpecificationProvider] specification_provider
- # see {#specification_provider}
- # @param [UI] resolver_ui
- # see {#resolver_ui}
- def initialize(specification_provider, resolver_ui)
- @specification_provider = specification_provider
- @resolver_ui = resolver_ui
- end
-
- # Resolves the requested dependencies into a {DependencyGraph},
- # locking to the base dependency graph (if specified)
- # @param [Array] requested an array of 'requested' dependencies that the
- # {#specification_provider} can understand
- # @param [DependencyGraph,nil] base the base dependency graph to which
- # dependencies should be 'locked'
- def resolve(requested, base = DependencyGraph.new)
- Resolution.new(specification_provider,
- resolver_ui,
- requested,
- base).
- resolve
- end
- end
-end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/state.rb b/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
deleted file mode 100644
index 68fa1f54e3..0000000000
--- a/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler::Molinillo
- # A state that a {Resolution} can be in
- # @attr [String] name the name of the current requirement
- # @attr [Array<Object>] requirements currently unsatisfied requirements
- # @attr [DependencyGraph] activated the graph of activated dependencies
- # @attr [Object] requirement the current requirement
- # @attr [Object] possibilities the possibilities to satisfy the current requirement
- # @attr [Integer] depth the depth of the resolution
- # @attr [Hash] conflicts unresolved conflicts, indexed by dependency name
- # @attr [Array<UnwindDetails>] unused_unwind_options unwinds for previous conflicts that weren't explored
- ResolutionState = Struct.new(
- :name,
- :requirements,
- :activated,
- :requirement,
- :possibilities,
- :depth,
- :conflicts,
- :unused_unwind_options
- )
-
- class ResolutionState
- # Returns an empty resolution state
- # @return [ResolutionState] an empty state
- def self.empty
- new(nil, [], DependencyGraph.new, nil, nil, 0, {}, [])
- end
- end
-
- # A state that encapsulates a set of {#requirements} with an {Array} of
- # possibilities
- class DependencyState < ResolutionState
- # Removes a possibility from `self`
- # @return [PossibilityState] a state with a single possibility,
- # the possibility that was removed from `self`
- def pop_possibility_state
- PossibilityState.new(
- name,
- requirements.dup,
- activated,
- requirement,
- [possibilities.pop],
- depth + 1,
- conflicts.dup,
- unused_unwind_options.dup
- ).tap do |state|
- state.activated.tag(state)
- end
- end
- end
-
- # A state that encapsulates a single possibility to fulfill the given
- # {#requirement}
- class PossibilityState < ResolutionState
- end
-end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
deleted file mode 100644
index f9d1401062..0000000000
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
+++ /dev/null
@@ -1,1180 +0,0 @@
-require 'net/http'
-require_relative '../../../../uri/lib/uri'
-require 'cgi' # for escaping
-require_relative '../../../../connection_pool/lib/connection_pool'
-
-autoload :OpenSSL, 'openssl'
-
-##
-# Persistent connections for Net::HTTP
-#
-# Bundler::Persistent::Net::HTTP::Persistent maintains persistent connections across all the
-# servers you wish to talk to. For each host:port you communicate with a
-# single persistent connection is created.
-#
-# Multiple Bundler::Persistent::Net::HTTP::Persistent objects will share the same set of
-# connections.
-#
-# For each thread you start a new connection will be created. A
-# Bundler::Persistent::Net::HTTP::Persistent connection will not be shared across threads.
-#
-# You can shut down the HTTP connections when done by calling #shutdown. You
-# should name your Bundler::Persistent::Net::HTTP::Persistent object if you intend to call this
-# method.
-#
-# Example:
-#
-# require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
-#
-# uri = Bundler::URI 'http://example.com/awesome/web/service'
-#
-# http = Bundler::Persistent::Net::HTTP::Persistent.new name: 'my_app_name'
-#
-# # perform a GET
-# response = http.request uri
-#
-# # or
-#
-# get = Net::HTTP::Get.new uri.request_uri
-# response = http.request get
-#
-# # create a POST
-# post_uri = uri + 'create'
-# post = Net::HTTP::Post.new post_uri.path
-# post.set_form_data 'some' => 'cool data'
-#
-# # perform the POST, the Bundler::URI is always required
-# response http.request post_uri, post
-#
-# Note that for GET, HEAD and other requests that do not have a body you want
-# to use Bundler::URI#request_uri not Bundler::URI#path. The request_uri contains the query
-# params which are sent in the body for other requests.
-#
-# == SSL
-#
-# SSL connections are automatically created depending upon the scheme of the
-# Bundler::URI. SSL connections are automatically verified against the default
-# certificate store for your computer. You can override this by changing
-# verify_mode or by specifying an alternate cert_store.
-#
-# Here are the SSL settings, see the individual methods for documentation:
-#
-# #certificate :: This client's certificate
-# #ca_file :: The certificate-authorities
-# #ca_path :: Directory with certificate-authorities
-# #cert_store :: An SSL certificate store
-# #ciphers :: List of SSl ciphers allowed
-# #private_key :: The client's SSL private key
-# #reuse_ssl_sessions :: Reuse a previously opened SSL session for a new
-# connection
-# #ssl_timeout :: SSL session lifetime
-# #ssl_version :: Which specific SSL version to use
-# #verify_callback :: For server certificate verification
-# #verify_depth :: Depth of certificate verification
-# #verify_mode :: How connections should be verified
-#
-# == Proxies
-#
-# A proxy can be set through #proxy= or at initialization time by providing a
-# second argument to ::new. The proxy may be the Bundler::URI of the proxy server or
-# <code>:ENV</code> which will consult environment variables.
-#
-# See #proxy= and #proxy_from_env for details.
-#
-# == Headers
-#
-# Headers may be specified for use in every request. #headers are appended to
-# any headers on the request. #override_headers replace existing headers on
-# the request.
-#
-# The difference between the two can be seen in setting the User-Agent. Using
-# <code>http.headers['User-Agent'] = 'MyUserAgent'</code> will send "Ruby,
-# MyUserAgent" while <code>http.override_headers['User-Agent'] =
-# 'MyUserAgent'</code> will send "MyUserAgent".
-#
-# == Tuning
-#
-# === Segregation
-#
-# By providing an application name to ::new you can separate your connections
-# from the connections of other applications.
-#
-# === Idle Timeout
-#
-# If a connection hasn't been used for this number of seconds it will automatically be
-# reset upon the next use to avoid attempting to send to a closed connection.
-# The default value is 5 seconds. nil means no timeout. Set through #idle_timeout.
-#
-# Reducing this value may help avoid the "too many connection resets" error
-# when sending non-idempotent requests while increasing this value will cause
-# fewer round-trips.
-#
-# === Read Timeout
-#
-# The amount of time allowed between reading two chunks from the socket. Set
-# through #read_timeout
-#
-# === Max Requests
-#
-# The number of requests that should be made before opening a new connection.
-# Typically many keep-alive capable servers tune this to 100 or less, so the
-# 101st request will fail with ECONNRESET. If unset (default), this value has no
-# effect, if set, connections will be reset on the request after max_requests.
-#
-# === Open Timeout
-#
-# The amount of time to wait for a connection to be opened. Set through
-# #open_timeout.
-#
-# === Socket Options
-#
-# Socket options may be set on newly-created connections. See #socket_options
-# for details.
-#
-# === Non-Idempotent Requests
-#
-# By default non-idempotent requests will not be retried per RFC 2616. By
-# setting retry_change_requests to true requests will automatically be retried
-# once.
-#
-# Only do this when you know that retrying a POST or other non-idempotent
-# request is safe for your application and will not create duplicate
-# resources.
-#
-# The recommended way to handle non-idempotent requests is the following:
-#
-# require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
-#
-# uri = Bundler::URI 'http://example.com/awesome/web/service'
-# post_uri = uri + 'create'
-#
-# http = Bundler::Persistent::Net::HTTP::Persistent.new name: 'my_app_name'
-#
-# post = Net::HTTP::Post.new post_uri.path
-# # ... fill in POST request
-#
-# begin
-# response = http.request post_uri, post
-# rescue Bundler::Persistent::Net::HTTP::Persistent::Error
-#
-# # POST failed, make a new request to verify the server did not process
-# # the request
-# exists_uri = uri + '...'
-# response = http.get exists_uri
-#
-# # Retry if it failed
-# retry if response.code == '404'
-# end
-#
-# The method of determining if the resource was created or not is unique to
-# the particular service you are using. Of course, you will want to add
-# protection from infinite looping.
-#
-# === Connection Termination
-#
-# If you are done using the Bundler::Persistent::Net::HTTP::Persistent instance you may shut down
-# all the connections in the current thread with #shutdown. This is not
-# recommended for normal use, it should only be used when it will be several
-# minutes before you make another HTTP request.
-#
-# If you are using multiple threads, call #shutdown in each thread when the
-# thread is done making requests. If you don't call shutdown, that's OK.
-# Ruby will automatically garbage collect and shutdown your HTTP connections
-# when the thread terminates.
-
-class Bundler::Persistent::Net::HTTP::Persistent
-
- ##
- # The beginning of Time
-
- EPOCH = Time.at 0 # :nodoc:
-
- ##
- # Is OpenSSL available? This test works with autoload
-
- HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc:
-
- ##
- # The default connection pool size is 1/4 the allowed open files.
-
- if Gem.win_platform? then
- DEFAULT_POOL_SIZE = 256
- else
- DEFAULT_POOL_SIZE = Process.getrlimit(Process::RLIMIT_NOFILE).first / 4
- end
-
- ##
- # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
-
- VERSION = '3.1.0'
-
- ##
- # Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
- # the exception list for ruby 1.x.
-
- RETRIED_EXCEPTIONS = [ # :nodoc:
- (Net::ReadTimeout if Net.const_defined? :ReadTimeout),
- IOError,
- EOFError,
- Errno::ECONNRESET,
- Errno::ECONNABORTED,
- Errno::EPIPE,
- (OpenSSL::SSL::SSLError if HAVE_OPENSSL),
- Timeout::Error,
- ].compact
-
- ##
- # Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
- # SystemCallErrors are re-raised with a human-readable message under this
- # class.
-
- class Error < StandardError; end
-
- ##
- # Use this method to detect the idle timeout of the host at +uri+. The
- # value returned can be used to configure #idle_timeout. +max+ controls the
- # maximum idle timeout to detect.
- #
- # After
- #
- # Idle timeout detection is performed by creating a connection then
- # performing a HEAD request in a loop until the connection terminates
- # waiting one additional second per loop.
- #
- # NOTE: This may not work on ruby > 1.9.
-
- def self.detect_idle_timeout uri, max = 10
- uri = Bundler::URI uri unless Bundler::URI::Generic === uri
- uri += '/'
-
- req = Net::HTTP::Head.new uri.request_uri
-
- http = new 'net-http-persistent detect_idle_timeout'
-
- http.connection_for uri do |connection|
- sleep_time = 0
-
- http = connection.http
-
- loop do
- response = http.request req
-
- $stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
-
- unless Net::HTTPOK === response then
- raise Error, "bad response code #{response.code} detecting idle timeout"
- end
-
- break if sleep_time >= max
-
- sleep_time += 1
-
- $stderr.puts "sleeping #{sleep_time}" if $DEBUG
- sleep sleep_time
- end
- end
- rescue
- # ignore StandardErrors, we've probably found the idle timeout.
- ensure
- return sleep_time unless $!
- end
-
- ##
- # This client's OpenSSL::X509::Certificate
-
- attr_reader :certificate
-
- ##
- # For Net::HTTP parity
-
- alias cert certificate
-
- ##
- # An SSL certificate authority. Setting this will set verify_mode to
- # VERIFY_PEER.
-
- attr_reader :ca_file
-
- ##
- # A directory of SSL certificates to be used as certificate authorities.
- # Setting this will set verify_mode to VERIFY_PEER.
-
- attr_reader :ca_path
-
- ##
- # An SSL certificate store. Setting this will override the default
- # certificate store. See verify_mode for more information.
-
- attr_reader :cert_store
-
- ##
- # The ciphers allowed for SSL connections
-
- attr_reader :ciphers
-
- ##
- # Sends debug_output to this IO via Net::HTTP#set_debug_output.
- #
- # Never use this method in production code, it causes a serious security
- # hole.
-
- attr_accessor :debug_output
-
- ##
- # Current connection generation
-
- attr_reader :generation # :nodoc:
-
- ##
- # Headers that are added to every request using Net::HTTP#add_field
-
- attr_reader :headers
-
- ##
- # Maps host:port to an HTTP version. This allows us to enable version
- # specific features.
-
- attr_reader :http_versions
-
- ##
- # Maximum time an unused connection can remain idle before being
- # automatically closed.
-
- attr_accessor :idle_timeout
-
- ##
- # Maximum number of requests on a connection before it is considered expired
- # and automatically closed.
-
- attr_accessor :max_requests
-
- ##
- # The value sent in the Keep-Alive header. Defaults to 30. Not needed for
- # HTTP/1.1 servers.
- #
- # This may not work correctly for HTTP/1.0 servers
- #
- # This method may be removed in a future version as RFC 2616 does not
- # require this header.
-
- attr_accessor :keep_alive
-
- ##
- # A name for this connection. Allows you to keep your connections apart
- # from everybody else's.
-
- attr_reader :name
-
- ##
- # Seconds to wait until a connection is opened. See Net::HTTP#open_timeout
-
- attr_accessor :open_timeout
-
- ##
- # Headers that are added to every request using Net::HTTP#[]=
-
- attr_reader :override_headers
-
- ##
- # This client's SSL private key
-
- attr_reader :private_key
-
- ##
- # For Net::HTTP parity
-
- alias key private_key
-
- ##
- # The URL through which requests will be proxied
-
- attr_reader :proxy_uri
-
- ##
- # List of host suffixes which will not be proxied
-
- attr_reader :no_proxy
-
- ##
- # Test-only accessor for the connection pool
-
- attr_reader :pool # :nodoc:
-
- ##
- # Seconds to wait until reading one block. See Net::HTTP#read_timeout
-
- attr_accessor :read_timeout
-
- ##
- # Seconds to wait until writing one block. See Net::HTTP#write_timeout
-
- attr_accessor :write_timeout
-
- ##
- # By default SSL sessions are reused to avoid extra SSL handshakes. Set
- # this to false if you have problems communicating with an HTTPS server
- # like:
- #
- # SSL_connect [...] read finished A: unexpected message (OpenSSL::SSL::SSLError)
-
- attr_accessor :reuse_ssl_sessions
-
- ##
- # An array of options for Socket#setsockopt.
- #
- # By default the TCP_NODELAY option is set on sockets.
- #
- # To set additional options append them to this array:
- #
- # http.socket_options << [Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1]
-
- attr_reader :socket_options
-
- ##
- # Current SSL connection generation
-
- attr_reader :ssl_generation # :nodoc:
-
- ##
- # SSL session lifetime
-
- attr_reader :ssl_timeout
-
- ##
- # SSL version to use.
- #
- # By default, the version will be negotiated automatically between client
- # and server. Ruby 1.9 and newer only. Deprecated since Ruby 2.5.
-
- attr_reader :ssl_version
-
- ##
- # Minimum SSL version to use, e.g. :TLS1_1
- #
- # By default, the version will be negotiated automatically between client
- # and server. Ruby 2.5 and newer only.
-
- attr_reader :min_version
-
- ##
- # Maximum SSL version to use, e.g. :TLS1_2
- #
- # By default, the version will be negotiated automatically between client
- # and server. Ruby 2.5 and newer only.
-
- attr_reader :max_version
-
- ##
- # Where this instance's last-use times live in the thread local variables
-
- attr_reader :timeout_key # :nodoc:
-
- ##
- # SSL verification callback. Used when ca_file or ca_path is set.
-
- attr_reader :verify_callback
-
- ##
- # Sets the depth of SSL certificate verification
-
- attr_reader :verify_depth
-
- ##
- # HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER which verifies
- # the server certificate.
- #
- # If no ca_file, ca_path or cert_store is set the default system certificate
- # store is used.
- #
- # You can use +verify_mode+ to override any default values.
-
- attr_reader :verify_mode
-
- ##
- # Enable retries of non-idempotent requests that change data (e.g. POST
- # requests) when the server has disconnected.
- #
- # This will in the worst case lead to multiple requests with the same data,
- # but it may be useful for some applications. Take care when enabling
- # this option to ensure it is safe to POST or perform other non-idempotent
- # requests to the server.
-
- attr_accessor :retry_change_requests
-
- ##
- # Creates a new Bundler::Persistent::Net::HTTP::Persistent.
- #
- # Set +name+ to keep your connections apart from everybody else's. Not
- # required currently, but highly recommended. Your library name should be
- # good enough. This parameter will be required in a future version.
- #
- # +proxy+ may be set to a Bundler::URI::HTTP or :ENV to pick up proxy options from
- # the environment. See proxy_from_env for details.
- #
- # In order to use a Bundler::URI for the proxy you may need to do some extra work
- # beyond Bundler::URI parsing if the proxy requires a password:
- #
- # proxy = Bundler::URI 'http://proxy.example'
- # proxy.user = 'AzureDiamond'
- # proxy.password = 'hunter2'
- #
- # Set +pool_size+ to limit the maximum number of connections allowed.
- # Defaults to 1/4 the number of allowed file handles. You can have no more
- # than this many threads with active HTTP transactions.
-
- def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE
- @name = name
-
- @debug_output = nil
- @proxy_uri = nil
- @no_proxy = []
- @headers = {}
- @override_headers = {}
- @http_versions = {}
- @keep_alive = 30
- @open_timeout = nil
- @read_timeout = nil
- @write_timeout = nil
- @idle_timeout = 5
- @max_requests = nil
- @socket_options = []
- @ssl_generation = 0 # incremented when SSL session variables change
-
- @socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
- Socket.const_defined? :TCP_NODELAY
-
- @pool = Bundler::Persistent::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
- Bundler::Persistent::Net::HTTP::Persistent::Connection.new Net::HTTP, http_args, @ssl_generation
- end
-
- @certificate = nil
- @ca_file = nil
- @ca_path = nil
- @ciphers = nil
- @private_key = nil
- @ssl_timeout = nil
- @ssl_version = nil
- @min_version = nil
- @max_version = nil
- @verify_callback = nil
- @verify_depth = nil
- @verify_mode = nil
- @cert_store = nil
-
- @generation = 0 # incremented when proxy Bundler::URI changes
-
- if HAVE_OPENSSL then
- @verify_mode = OpenSSL::SSL::VERIFY_PEER
- @reuse_ssl_sessions = OpenSSL::SSL.const_defined? :Session
- end
-
- @retry_change_requests = false
-
- self.proxy = proxy if proxy
- end
-
- ##
- # Sets this client's OpenSSL::X509::Certificate
-
- def certificate= certificate
- @certificate = certificate
-
- reconnect_ssl
- end
-
- # For Net::HTTP parity
- alias cert= certificate=
-
- ##
- # Sets the SSL certificate authority file.
-
- def ca_file= file
- @ca_file = file
-
- reconnect_ssl
- end
-
- ##
- # Sets the SSL certificate authority path.
-
- def ca_path= path
- @ca_path = path
-
- reconnect_ssl
- end
-
- ##
- # Overrides the default SSL certificate store used for verifying
- # connections.
-
- def cert_store= store
- @cert_store = store
-
- reconnect_ssl
- end
-
- ##
- # The ciphers allowed for SSL connections
-
- def ciphers= ciphers
- @ciphers = ciphers
-
- reconnect_ssl
- end
-
- ##
- # Creates a new connection for +uri+
-
- def connection_for uri
- use_ssl = uri.scheme.downcase == 'https'
-
- net_http_args = [uri.hostname, uri.port]
-
- if @proxy_uri and not proxy_bypass? uri.hostname, uri.port then
- net_http_args.concat @proxy_args
- else
- net_http_args.concat [nil, nil, nil, nil]
- end
-
- connection = @pool.checkout net_http_args
-
- http = connection.http
-
- connection.ressl @ssl_generation if
- connection.ssl_generation != @ssl_generation
-
- if not http.started? then
- ssl http if use_ssl
- start http
- elsif expired? connection then
- reset connection
- end
-
- http.read_timeout = @read_timeout if @read_timeout
- http.write_timeout = @write_timeout if @write_timeout && http.respond_to?(:write_timeout=)
- http.keep_alive_timeout = @idle_timeout if @idle_timeout
-
- return yield connection
- rescue Errno::ECONNREFUSED
- address = http.proxy_address || http.address
- port = http.proxy_port || http.port
-
- raise Error, "connection refused: #{address}:#{port}"
- rescue Errno::EHOSTDOWN
- address = http.proxy_address || http.address
- port = http.proxy_port || http.port
-
- raise Error, "host down: #{address}:#{port}"
- ensure
- @pool.checkin net_http_args
- end
-
- ##
- # Returns an error message containing the number of requests performed on
- # this connection
-
- def error_message connection
- connection.requests -= 1 # fixup
-
- age = Time.now - connection.last_use
-
- "after #{connection.requests} requests on #{connection.http.object_id}, " \
- "last used #{age} seconds ago"
- end
-
- ##
- # Bundler::URI::escape wrapper
-
- def escape str
- CGI.escape str if str
- end
-
- ##
- # Bundler::URI::unescape wrapper
-
- def unescape str
- CGI.unescape str if str
- end
-
-
- ##
- # Returns true if the connection should be reset due to an idle timeout, or
- # maximum request count, false otherwise.
-
- def expired? connection
- return true if @max_requests && connection.requests >= @max_requests
- return false unless @idle_timeout
- return true if @idle_timeout.zero?
-
- Time.now - connection.last_use > @idle_timeout
- end
-
- ##
- # Starts the Net::HTTP +connection+
-
- def start http
- http.set_debug_output @debug_output if @debug_output
- http.open_timeout = @open_timeout if @open_timeout
-
- http.start
-
- socket = http.instance_variable_get :@socket
-
- if socket then # for fakeweb
- @socket_options.each do |option|
- socket.io.setsockopt(*option)
- end
- end
- end
-
- ##
- # Finishes the Net::HTTP +connection+
-
- def finish connection
- connection.finish
-
- connection.http.instance_variable_set :@ssl_session, nil unless
- @reuse_ssl_sessions
- end
-
- ##
- # Returns the HTTP protocol version for +uri+
-
- def http_version uri
- @http_versions["#{uri.host}:#{uri.port}"]
- end
-
- ##
- # Is +req+ idempotent according to RFC 2616?
-
- def idempotent? req
- case req.method
- when 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE' then
- true
- end
- end
-
- ##
- # Is the request +req+ idempotent or is retry_change_requests allowed.
-
- def can_retry? req
- @retry_change_requests && !idempotent?(req)
- end
-
- ##
- # Adds "http://" to the String +uri+ if it is missing.
-
- def normalize_uri uri
- (uri =~ /^https?:/) ? uri : "http://#{uri}"
- end
-
- ##
- # Sets this client's SSL private key
-
- def private_key= key
- @private_key = key
-
- reconnect_ssl
- end
-
- # For Net::HTTP parity
- alias key= private_key=
-
- ##
- # Sets the proxy server. The +proxy+ may be the Bundler::URI of the proxy server,
- # the symbol +:ENV+ which will read the proxy from the environment or nil to
- # disable use of a proxy. See #proxy_from_env for details on setting the
- # proxy from the environment.
- #
- # If the proxy Bundler::URI is set after requests have been made, the next request
- # will shut-down and re-open all connections.
- #
- # The +no_proxy+ query parameter can be used to specify hosts which shouldn't
- # be reached via proxy; if set it should be a comma separated list of
- # hostname suffixes, optionally with +:port+ appended, for example
- # <tt>example.com,some.host:8080</tt>.
-
- def proxy= proxy
- @proxy_uri = case proxy
- when :ENV then proxy_from_env
- when Bundler::URI::HTTP then proxy
- when nil then # ignore
- else raise ArgumentError, 'proxy must be :ENV or a Bundler::URI::HTTP'
- end
-
- @no_proxy.clear
-
- if @proxy_uri then
- @proxy_args = [
- @proxy_uri.host,
- @proxy_uri.port,
- unescape(@proxy_uri.user),
- unescape(@proxy_uri.password),
- ]
-
- @proxy_connection_id = [nil, *@proxy_args].join ':'
-
- if @proxy_uri.query then
- @no_proxy = CGI.parse(@proxy_uri.query)['no_proxy'].join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
- end
- end
-
- reconnect
- reconnect_ssl
- end
-
- ##
- # Creates a Bundler::URI for an HTTP proxy server from ENV variables.
- #
- # If +HTTP_PROXY+ is set a proxy will be returned.
- #
- # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Bundler::URI is given the
- # indicated user and password unless HTTP_PROXY contains either of these in
- # the Bundler::URI.
- #
- # The +NO_PROXY+ ENV variable can be used to specify hosts which shouldn't
- # be reached via proxy; if set it should be a comma separated list of
- # hostname suffixes, optionally with +:port+ appended, for example
- # <tt>example.com,some.host:8080</tt>. When set to <tt>*</tt> no proxy will
- # be returned.
- #
- # For Windows users, lowercase ENV variables are preferred over uppercase ENV
- # variables.
-
- def proxy_from_env
- env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
-
- return nil if env_proxy.nil? or env_proxy.empty?
-
- uri = Bundler::URI normalize_uri env_proxy
-
- env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
-
- # '*' is special case for always bypass
- return nil if env_no_proxy == '*'
-
- if env_no_proxy then
- uri.query = "no_proxy=#{escape(env_no_proxy)}"
- end
-
- unless uri.user or uri.password then
- uri.user = escape ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER']
- uri.password = escape ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS']
- end
-
- uri
- end
-
- ##
- # Returns true when proxy should by bypassed for host.
-
- def proxy_bypass? host, port
- host = host.downcase
- host_port = [host, port].join ':'
-
- @no_proxy.each do |name|
- return true if host[-name.length, name.length] == name or
- host_port[-name.length, name.length] == name
- end
-
- false
- end
-
- ##
- # Forces reconnection of HTTP connections.
-
- def reconnect
- @generation += 1
- end
-
- ##
- # Forces reconnection of SSL connections.
-
- def reconnect_ssl
- @ssl_generation += 1
- end
-
- ##
- # Finishes then restarts the Net::HTTP +connection+
-
- def reset connection
- http = connection.http
-
- finish connection
-
- start http
- rescue Errno::ECONNREFUSED
- e = Error.new "connection refused: #{http.address}:#{http.port}"
- e.set_backtrace $@
- raise e
- rescue Errno::EHOSTDOWN
- e = Error.new "host down: #{http.address}:#{http.port}"
- e.set_backtrace $@
- raise e
- end
-
- ##
- # Makes a request on +uri+. If +req+ is nil a Net::HTTP::Get is performed
- # against +uri+.
- #
- # If a block is passed #request behaves like Net::HTTP#request (the body of
- # the response will not have been read).
- #
- # +req+ must be a Net::HTTPGenericRequest subclass (see Net::HTTP for a list).
- #
- # If there is an error and the request is idempotent according to RFC 2616
- # it will be retried automatically.
-
- def request uri, req = nil, &block
- retried = false
- bad_response = false
-
- uri = Bundler::URI uri
- req = request_setup req || uri
- response = nil
-
- connection_for uri do |connection|
- http = connection.http
-
- begin
- connection.requests += 1
-
- response = http.request req, &block
-
- if req.connection_close? or
- (response.http_version <= '1.0' and
- not response.connection_keep_alive?) or
- response.connection_close? then
- finish connection
- end
- rescue Net::HTTPBadResponse => e
- message = error_message connection
-
- finish connection
-
- raise Error, "too many bad responses #{message}" if
- bad_response or not can_retry? req
-
- bad_response = true
- retry
- rescue *RETRIED_EXCEPTIONS => e
- request_failed e, req, connection if
- retried or not can_retry? req
-
- reset connection
-
- retried = true
- retry
- rescue Errno::EINVAL, Errno::ETIMEDOUT => e # not retried on ruby 2
- request_failed e, req, connection if retried or not can_retry? req
-
- reset connection
-
- retried = true
- retry
- rescue Exception => e
- finish connection
-
- raise
- ensure
- connection.last_use = Time.now
- end
- end
-
- @http_versions["#{uri.host}:#{uri.port}"] ||= response.http_version
-
- response
- end
-
- ##
- # Raises an Error for +exception+ which resulted from attempting the request
- # +req+ on the +connection+.
- #
- # Finishes the +connection+.
-
- def request_failed exception, req, connection # :nodoc:
- due_to = "(due to #{exception.message} - #{exception.class})"
- message = "too many connection resets #{due_to} #{error_message connection}"
-
- finish connection
-
- raise Error, message, exception.backtrace
- end
-
- ##
- # Creates a GET request if +req_or_uri+ is a Bundler::URI and adds headers to the
- # request.
- #
- # Returns the request.
-
- def request_setup req_or_uri # :nodoc:
- req = if Bundler::URI === req_or_uri then
- Net::HTTP::Get.new req_or_uri.request_uri
- else
- req_or_uri
- end
-
- @headers.each do |pair|
- req.add_field(*pair)
- end
-
- @override_headers.each do |name, value|
- req[name] = value
- end
-
- unless req['Connection'] then
- req.add_field 'Connection', 'keep-alive'
- req.add_field 'Keep-Alive', @keep_alive
- end
-
- req
- end
-
- ##
- # Shuts down all connections
- #
- # *NOTE*: Calling shutdown for can be dangerous!
- #
- # If any thread is still using a connection it may cause an error! Call
- # #shutdown when you are completely done making requests!
-
- def shutdown
- @pool.shutdown { |http| http.finish }
- end
-
- ##
- # Enables SSL on +connection+
-
- def ssl connection
- connection.use_ssl = true
-
- connection.ciphers = @ciphers if @ciphers
- connection.ssl_timeout = @ssl_timeout if @ssl_timeout
- connection.ssl_version = @ssl_version if @ssl_version
- connection.min_version = @min_version if @min_version
- connection.max_version = @max_version if @max_version
-
- connection.verify_depth = @verify_depth
- connection.verify_mode = @verify_mode
-
- if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
- not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
- warn <<-WARNING
- !!!SECURITY WARNING!!!
-
-The SSL HTTP connection to:
-
- #{connection.address}:#{connection.port}
-
- !!!MAY NOT BE VERIFIED!!!
-
-On your platform your OpenSSL implementation is broken.
-
-There is no difference between the values of VERIFY_NONE and VERIFY_PEER.
-
-This means that attempting to verify the security of SSL connections may not
-work. This exposes you to man-in-the-middle exploits, snooping on the
-contents of your connection and other dangers to the security of your data.
-
-To disable this warning define the following constant at top-level in your
-application:
-
- I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG = nil
-
- WARNING
- end
-
- connection.ca_file = @ca_file if @ca_file
- connection.ca_path = @ca_path if @ca_path
-
- if @ca_file or @ca_path then
- connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
- connection.verify_callback = @verify_callback if @verify_callback
- end
-
- if @certificate and @private_key then
- connection.cert = @certificate
- connection.key = @private_key
- end
-
- connection.cert_store = if @cert_store then
- @cert_store
- else
- store = OpenSSL::X509::Store.new
- store.set_default_paths
- store
- end
- end
-
- ##
- # SSL session lifetime
-
- def ssl_timeout= ssl_timeout
- @ssl_timeout = ssl_timeout
-
- reconnect_ssl
- end
-
- ##
- # SSL version to use
-
- def ssl_version= ssl_version
- @ssl_version = ssl_version
-
- reconnect_ssl
- end
-
- ##
- # Minimum SSL version to use
-
- def min_version= min_version
- @min_version = min_version
-
- reconnect_ssl
- end
-
- ##
- # maximum SSL version to use
-
- def max_version= max_version
- @max_version = max_version
-
- reconnect_ssl
- end
-
- ##
- # Sets the depth of SSL certificate verification
-
- def verify_depth= verify_depth
- @verify_depth = verify_depth
-
- reconnect_ssl
- end
-
- ##
- # Sets the HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER.
- #
- # Setting this to VERIFY_NONE is a VERY BAD IDEA and should NEVER be used.
- # Securely transfer the correct certificate and update the default
- # certificate store or set the ca file instead.
-
- def verify_mode= verify_mode
- @verify_mode = verify_mode
-
- reconnect_ssl
- end
-
- ##
- # SSL verification callback.
-
- def verify_callback= callback
- @verify_callback = callback
-
- reconnect_ssl
- end
-
-end
-
-require_relative 'persistent/connection'
-require_relative 'persistent/pool'
-
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
deleted file mode 100644
index a57a5d1352..0000000000
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-##
-# A Net::HTTP connection wrapper that holds extra information for managing the
-# connection's lifetime.
-
-class Bundler::Persistent::Net::HTTP::Persistent::Connection # :nodoc:
-
- attr_accessor :http
-
- attr_accessor :last_use
-
- attr_accessor :requests
-
- attr_accessor :ssl_generation
-
- def initialize http_class, http_args, ssl_generation
- @http = http_class.new(*http_args)
- @ssl_generation = ssl_generation
-
- reset
- end
-
- def finish
- @http.finish
- rescue IOError
- ensure
- reset
- end
-
- def reset
- @last_use = Bundler::Persistent::Net::HTTP::Persistent::EPOCH
- @requests = 0
- end
-
- def ressl ssl_generation
- @ssl_generation = ssl_generation
-
- finish
- end
-
-end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
deleted file mode 100644
index 9dfa6ffdb1..0000000000
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool # :nodoc:
-
- attr_reader :available # :nodoc:
- attr_reader :key # :nodoc:
-
- def initialize(options = {}, &block)
- super
-
- @available = Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti.new(@size, &block)
- @key = "current-#{@available.object_id}"
- end
-
- def checkin net_http_args
- stack = Thread.current[@key][net_http_args] ||= []
-
- raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
- stack.empty?
-
- conn = stack.pop
-
- if stack.empty?
- @available.push conn, connection_args: net_http_args
-
- Thread.current[@key].delete(net_http_args)
- Thread.current[@key] = nil if Thread.current[@key].empty?
- end
-
- nil
- end
-
- def checkout net_http_args
- stacks = Thread.current[@key] ||= {}
- stack = stacks[net_http_args] ||= []
-
- if stack.empty? then
- conn = @available.pop connection_args: net_http_args
- else
- conn = stack.last
- end
-
- stack.push conn
-
- conn
- end
-
- def shutdown
- Thread.current[@key] = nil
- super
- end
-end
-
-require_relative 'timed_stack_multi'
-
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
deleted file mode 100644
index 2da881c554..0000000000
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-class Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:
-
- ##
- # Returns a new hash that has arrays for keys
- #
- # Using a class method to limit the bindings referenced by the hash's
- # default_proc
-
- def self.hash_of_arrays # :nodoc:
- Hash.new { |h,k| h[k] = [] }
- end
-
- def initialize(size = 0, &block)
- super
-
- @enqueued = 0
- @ques = self.class.hash_of_arrays
- @lru = {}
- @key = :"connection_args-#{object_id}"
- end
-
- def empty?
- (@created - @enqueued) >= @max
- end
-
- def length
- @max - @created + @enqueued
- end
-
- private
-
- def connection_stored? options = {} # :nodoc:
- !@ques[options[:connection_args]].empty?
- end
-
- def fetch_connection options = {} # :nodoc:
- connection_args = options[:connection_args]
-
- @enqueued -= 1
- lru_update connection_args
- @ques[connection_args].pop
- end
-
- def lru_update connection_args # :nodoc:
- @lru.delete connection_args
- @lru[connection_args] = true
- end
-
- def shutdown_connections # :nodoc:
- @ques.each_key do |key|
- super connection_args: key
- end
- end
-
- def store_connection obj, options = {} # :nodoc:
- @ques[options[:connection_args]].push obj
- @enqueued += 1
- end
-
- def try_create options = {} # :nodoc:
- connection_args = options[:connection_args]
-
- if @created >= @max && @enqueued >= 1
- oldest, = @lru.first
- @lru.delete oldest
- @ques[oldest].pop
-
- @created -= 1
- end
-
- if @created < @max
- @created += 1
- lru_update connection_args
- return @create_block.call(connection_args)
- end
- end
-
-end
-
diff --git a/lib/bundler/vendor/thor/lib/thor.rb b/lib/bundler/vendor/thor/lib/thor.rb
deleted file mode 100644
index 01c0b2f83c..0000000000
--- a/lib/bundler/vendor/thor/lib/thor.rb
+++ /dev/null
@@ -1,524 +0,0 @@
-require "set"
-require_relative "thor/base"
-
-class Bundler::Thor
- class << self
- # Allows for custom "Command" package naming.
- #
- # === Parameters
- # name<String>
- # options<Hash>
- #
- def package_name(name, _ = {})
- @package_name = name.nil? || name == "" ? nil : name
- end
-
- # Sets the default command when thor is executed without an explicit command to be called.
- #
- # ==== Parameters
- # meth<Symbol>:: name of the default command
- #
- def default_command(meth = nil)
- if meth
- @default_command = meth == :none ? "help" : meth.to_s
- else
- @default_command ||= from_superclass(:default_command, "help")
- end
- end
- alias_method :default_task, :default_command
-
- # Registers another Bundler::Thor subclass as a command.
- #
- # ==== Parameters
- # klass<Class>:: Bundler::Thor subclass to register
- # command<String>:: Subcommand name to use
- # usage<String>:: Short usage for the subcommand
- # description<String>:: Description for the subcommand
- def register(klass, subcommand_name, usage, description, options = {})
- if klass <= Bundler::Thor::Group
- desc usage, description, options
- define_method(subcommand_name) { |*args| invoke(klass, args) }
- else
- desc usage, description, options
- subcommand subcommand_name, klass
- end
- end
-
- # Defines the usage and the description of the next command.
- #
- # ==== Parameters
- # usage<String>
- # description<String>
- # options<String>
- #
- def desc(usage, description, options = {})
- if options[:for]
- command = find_and_refresh_command(options[:for])
- command.usage = usage if usage
- command.description = description if description
- else
- @usage = usage
- @desc = description
- @hide = options[:hide] || false
- end
- end
-
- # Defines the long description of the next command.
- #
- # ==== Parameters
- # long description<String>
- #
- def long_desc(long_description, options = {})
- if options[:for]
- command = find_and_refresh_command(options[:for])
- command.long_description = long_description if long_description
- else
- @long_desc = long_description
- end
- end
-
- # Maps an input to a command. If you define:
- #
- # map "-T" => "list"
- #
- # Running:
- #
- # thor -T
- #
- # Will invoke the list command.
- #
- # ==== Parameters
- # Hash[String|Array => Symbol]:: Maps the string or the strings in the array to the given command.
- #
- def map(mappings = nil, **kw)
- @map ||= from_superclass(:map, {})
-
- if mappings && !kw.empty?
- mappings = kw.merge!(mappings)
- else
- mappings ||= kw
- end
- if mappings
- mappings.each do |key, value|
- if key.respond_to?(:each)
- key.each { |subkey| @map[subkey] = value }
- else
- @map[key] = value
- end
- end
- end
-
- @map
- end
-
- # Declares the options for the next command to be declared.
- #
- # ==== Parameters
- # Hash[Symbol => Object]:: The hash key is the name of the option and the value
- # is the type of the option. Can be :string, :array, :hash, :boolean, :numeric
- # or :required (string). If you give a value, the type of the value is used.
- #
- def method_options(options = nil)
- @method_options ||= {}
- build_options(options, @method_options) if options
- @method_options
- end
-
- alias_method :options, :method_options
-
- # Adds an option to the set of method options. If :for is given as option,
- # it allows you to change the options from a previous defined command.
- #
- # def previous_command
- # # magic
- # end
- #
- # method_option :foo => :bar, :for => :previous_command
- #
- # def next_command
- # # magic
- # end
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described below.
- #
- # ==== Options
- # :desc - Description for the argument.
- # :required - If the argument is required or not.
- # :default - Default value for this argument. It cannot be required and have default values.
- # :aliases - Aliases for this option.
- # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
- # :banner - String to show on usage notes.
- # :hide - If you want to hide this option from the help.
- #
- def method_option(name, options = {})
- scope = if options[:for]
- find_and_refresh_command(options[:for]).options
- else
- method_options
- end
-
- build_option(name, options, scope)
- end
- alias_method :option, :method_option
-
- # Prints help information for the given command.
- #
- # ==== Parameters
- # shell<Bundler::Thor::Shell>
- # command_name<String>
- #
- def command_help(shell, command_name)
- meth = normalize_command_name(command_name)
- command = all_commands[meth]
- handle_no_command_error(meth) unless command
-
- shell.say "Usage:"
- shell.say " #{banner(command).split("\n").join("\n ")}"
- shell.say
- class_options_help(shell, nil => command.options.values)
- if command.long_description
- shell.say "Description:"
- shell.print_wrapped(command.long_description, :indent => 2)
- else
- shell.say command.description
- end
- end
- alias_method :task_help, :command_help
-
- # Prints help information for this class.
- #
- # ==== Parameters
- # shell<Bundler::Thor::Shell>
- #
- def help(shell, subcommand = false)
- list = printable_commands(true, subcommand)
- Bundler::Thor::Util.thor_classes_in(self).each do |klass|
- list += klass.printable_commands(false)
- end
- list.sort! { |a, b| a[0] <=> b[0] }
-
- if defined?(@package_name) && @package_name
- shell.say "#{@package_name} commands:"
- else
- shell.say "Commands:"
- end
-
- shell.print_table(list, :indent => 2, :truncate => true)
- shell.say
- class_options_help(shell)
- end
-
- # Returns commands ready to be printed.
- def printable_commands(all = true, subcommand = false)
- (all ? all_commands : commands).map do |_, command|
- next if command.hidden?
- item = []
- item << banner(command, false, subcommand)
- item << (command.description ? "# #{command.description.gsub(/\s+/m, ' ')}" : "")
- item
- end.compact
- end
- alias_method :printable_tasks, :printable_commands
-
- def subcommands
- @subcommands ||= from_superclass(:subcommands, [])
- end
- alias_method :subtasks, :subcommands
-
- def subcommand_classes
- @subcommand_classes ||= {}
- end
-
- def subcommand(subcommand, subcommand_class)
- subcommands << subcommand.to_s
- subcommand_class.subcommand_help subcommand
- subcommand_classes[subcommand.to_s] = subcommand_class
-
- define_method(subcommand) do |*args|
- args, opts = Bundler::Thor::Arguments.split(args)
- invoke_args = [args, opts, {:invoked_via_subcommand => true, :class_options => options}]
- invoke_args.unshift "help" if opts.delete("--help") || opts.delete("-h")
- invoke subcommand_class, *invoke_args
- end
- subcommand_class.commands.each do |_meth, command|
- command.ancestor_name = subcommand
- end
- end
- alias_method :subtask, :subcommand
-
- # Extend check unknown options to accept a hash of conditions.
- #
- # === Parameters
- # options<Hash>: A hash containing :only and/or :except keys
- def check_unknown_options!(options = {})
- @check_unknown_options ||= {}
- options.each do |key, value|
- if value
- @check_unknown_options[key] = Array(value)
- else
- @check_unknown_options.delete(key)
- end
- end
- @check_unknown_options
- end
-
- # Overwrite check_unknown_options? to take subcommands and options into account.
- def check_unknown_options?(config) #:nodoc:
- options = check_unknown_options
- return false unless options
-
- command = config[:current_command]
- return true unless command
-
- name = command.name
-
- if subcommands.include?(name)
- false
- elsif options[:except]
- !options[:except].include?(name.to_sym)
- elsif options[:only]
- options[:only].include?(name.to_sym)
- else
- true
- end
- end
-
- # Stop parsing of options as soon as an unknown option or a regular
- # argument is encountered. All remaining arguments are passed to the command.
- # This is useful if you have a command that can receive arbitrary additional
- # options, and where those additional options should not be handled by
- # Bundler::Thor.
- #
- # ==== Example
- #
- # To better understand how this is useful, let's consider a command that calls
- # an external command. A user may want to pass arbitrary options and
- # arguments to that command. The command itself also accepts some options,
- # which should be handled by Bundler::Thor.
- #
- # class_option "verbose", :type => :boolean
- # stop_on_unknown_option! :exec
- # check_unknown_options! :except => :exec
- #
- # desc "exec", "Run a shell command"
- # def exec(*args)
- # puts "diagnostic output" if options[:verbose]
- # Kernel.exec(*args)
- # end
- #
- # Here +exec+ can be called with +--verbose+ to get diagnostic output,
- # e.g.:
- #
- # $ thor exec --verbose echo foo
- # diagnostic output
- # foo
- #
- # But if +--verbose+ is given after +echo+, it is passed to +echo+ instead:
- #
- # $ thor exec echo --verbose foo
- # --verbose foo
- #
- # ==== Parameters
- # Symbol ...:: A list of commands that should be affected.
- def stop_on_unknown_option!(*command_names)
- stop_on_unknown_option.merge(command_names)
- end
-
- def stop_on_unknown_option?(command) #:nodoc:
- command && stop_on_unknown_option.include?(command.name.to_sym)
- end
-
- # Disable the check for required options for the given commands.
- # This is useful if you have a command that does not need the required options
- # to work, like help.
- #
- # ==== Parameters
- # Symbol ...:: A list of commands that should be affected.
- def disable_required_check!(*command_names)
- disable_required_check.merge(command_names)
- end
-
- def disable_required_check?(command) #:nodoc:
- command && disable_required_check.include?(command.name.to_sym)
- end
-
- def deprecation_warning(message) #:nodoc:
- unless ENV['THOR_SILENCE_DEPRECATION']
- warn "Deprecation warning: #{message}\n" +
- 'You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.'
- end
- end
-
- protected
-
- def stop_on_unknown_option #:nodoc:
- @stop_on_unknown_option ||= Set.new
- end
-
- # help command has the required check disabled by default.
- def disable_required_check #:nodoc:
- @disable_required_check ||= Set.new([:help])
- end
-
- # The method responsible for dispatching given the args.
- def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
- meth ||= retrieve_command_name(given_args)
- command = all_commands[normalize_command_name(meth)]
-
- if !command && config[:invoked_via_subcommand]
- # We're a subcommand and our first argument didn't match any of our
- # commands. So we put it back and call our default command.
- given_args.unshift(meth)
- command = all_commands[normalize_command_name(default_command)]
- end
-
- if command
- args, opts = Bundler::Thor::Options.split(given_args)
- if stop_on_unknown_option?(command) && !args.empty?
- # given_args starts with a non-option, so we treat everything as
- # ordinary arguments
- args.concat opts
- opts.clear
- end
- else
- args = given_args
- opts = nil
- command = dynamic_command_class.new(meth)
- end
-
- opts = given_opts || opts || []
- config[:current_command] = command
- config[:command_options] = command.options
-
- instance = new(args, opts, config)
- yield instance if block_given?
- args = instance.args
- trailing = args[Range.new(arguments.size, -1)]
- instance.invoke_command(command, trailing || [])
- end
-
- # The banner for this class. You can customize it if you are invoking the
- # thor class by another ways which is not the Bundler::Thor::Runner. It receives
- # the command that is going to be invoked and a boolean which indicates if
- # the namespace should be displayed as arguments.
- #
- def banner(command, namespace = nil, subcommand = false)
- $thor_runner ||= false
- command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
- "#{basename} #{formatted_usage}"
- end.join("\n")
- end
-
- def baseclass #:nodoc:
- Bundler::Thor
- end
-
- def dynamic_command_class #:nodoc:
- Bundler::Thor::DynamicCommand
- end
-
- def create_command(meth) #:nodoc:
- @usage ||= nil
- @desc ||= nil
- @long_desc ||= nil
- @hide ||= nil
-
- if @usage && @desc
- base_class = @hide ? Bundler::Thor::HiddenCommand : Bundler::Thor::Command
- commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options)
- @usage, @desc, @long_desc, @method_options, @hide = nil
- true
- elsif all_commands[meth] || meth == "method_missing"
- true
- else
- puts "[WARNING] Attempted to create command #{meth.inspect} without usage or description. " \
- "Call desc if you want this method to be available as command or declare it inside a " \
- "no_commands{} block. Invoked from #{caller[1].inspect}."
- false
- end
- end
- alias_method :create_task, :create_command
-
- def initialize_added #:nodoc:
- class_options.merge!(method_options)
- @method_options = nil
- end
-
- # Retrieve the command name from given args.
- def retrieve_command_name(args) #:nodoc:
- meth = args.first.to_s unless args.empty?
- args.shift if meth && (map[meth] || meth !~ /^\-/)
- end
- alias_method :retrieve_task_name, :retrieve_command_name
-
- # receives a (possibly nil) command name and returns a name that is in
- # the commands hash. In addition to normalizing aliases, this logic
- # will determine if a shortened command is an unambiguous substring of
- # a command or alias.
- #
- # +normalize_command_name+ also converts names like +animal-prison+
- # into +animal_prison+.
- def normalize_command_name(meth) #:nodoc:
- return default_command.to_s.tr("-", "_") unless meth
-
- possibilities = find_command_possibilities(meth)
- raise AmbiguousTaskError, "Ambiguous command #{meth} matches [#{possibilities.join(', ')}]" if possibilities.size > 1
-
- if possibilities.empty?
- meth ||= default_command
- elsif map[meth]
- meth = map[meth]
- else
- meth = possibilities.first
- end
-
- meth.to_s.tr("-", "_") # treat foo-bar as foo_bar
- end
- alias_method :normalize_task_name, :normalize_command_name
-
- # this is the logic that takes the command name passed in by the user
- # and determines whether it is an unambiguous substrings of a command or
- # alias name.
- def find_command_possibilities(meth)
- len = meth.to_s.length
- possibilities = all_commands.merge(map).keys.select { |n| meth == n[0, len] }.sort
- unique_possibilities = possibilities.map { |k| map[k] || k }.uniq
-
- if possibilities.include?(meth)
- [meth]
- elsif unique_possibilities.size == 1
- unique_possibilities
- else
- possibilities
- end
- end
- alias_method :find_task_possibilities, :find_command_possibilities
-
- def subcommand_help(cmd)
- desc "help [COMMAND]", "Describe subcommands or one specific subcommand"
- class_eval "
- def help(command = nil, subcommand = true); super; end
-"
- end
- alias_method :subtask_help, :subcommand_help
- end
-
- include Bundler::Thor::Base
-
- map HELP_MAPPINGS => :help
-
- desc "help [COMMAND]", "Describe available commands or one specific command"
- def help(command = nil, subcommand = false)
- if command
- if self.class.subcommands.include? command
- self.class.subcommand_classes[command].help(shell, true)
- else
- self.class.command_help(shell, command)
- end
- else
- self.class.help(shell, subcommand)
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions.rb b/lib/bundler/vendor/thor/lib/thor/actions.rb
deleted file mode 100644
index a5368d07f3..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/actions.rb
+++ /dev/null
@@ -1,336 +0,0 @@
-require_relative "actions/create_file"
-require_relative "actions/create_link"
-require_relative "actions/directory"
-require_relative "actions/empty_directory"
-require_relative "actions/file_manipulation"
-require_relative "actions/inject_into_file"
-
-class Bundler::Thor
- module Actions
- attr_accessor :behavior
-
- def self.included(base) #:nodoc:
- super(base)
- base.extend ClassMethods
- end
-
- module ClassMethods
- # Hold source paths for one Bundler::Thor instance. source_paths_for_search is the
- # method responsible to gather source_paths from this current class,
- # inherited paths and the source root.
- #
- def source_paths
- @_source_paths ||= []
- end
-
- # Stores and return the source root for this class
- def source_root(path = nil)
- @_source_root = path if path
- @_source_root ||= nil
- end
-
- # Returns the source paths in the following order:
- #
- # 1) This class source paths
- # 2) Source root
- # 3) Parents source paths
- #
- def source_paths_for_search
- paths = []
- paths += source_paths
- paths << source_root if source_root
- paths += from_superclass(:source_paths, [])
- paths
- end
-
- # Add runtime options that help actions execution.
- #
- def add_runtime_options!
- class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
- :desc => "Overwrite files that already exist"
-
- class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
- :desc => "Run but do not make any changes"
-
- class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
- :desc => "Suppress status output"
-
- class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
- :desc => "Skip files that already exist"
- end
- end
-
- # Extends initializer to add more configuration options.
- #
- # ==== Configuration
- # behavior<Symbol>:: The actions default behavior. Can be :invoke or :revoke.
- # It also accepts :force, :skip and :pretend to set the behavior
- # and the respective option.
- #
- # destination_root<String>:: The root directory needed for some actions.
- #
- def initialize(args = [], options = {}, config = {})
- self.behavior = case config[:behavior].to_s
- when "force", "skip"
- _cleanup_options_and_set(options, config[:behavior])
- :invoke
- when "revoke"
- :revoke
- else
- :invoke
- end
-
- super
- self.destination_root = config[:destination_root]
- end
-
- # Wraps an action object and call it accordingly to the thor class behavior.
- #
- def action(instance) #:nodoc:
- if behavior == :revoke
- instance.revoke!
- else
- instance.invoke!
- end
- end
-
- # Returns the root for this thor class (also aliased as destination root).
- #
- def destination_root
- @destination_stack.last
- end
-
- # Sets the root for this thor class. Relatives path are added to the
- # directory where the script was invoked and expanded.
- #
- def destination_root=(root)
- @destination_stack ||= []
- @destination_stack[0] = File.expand_path(root || "")
- end
-
- # Returns the given path relative to the absolute root (ie, root where
- # the script started).
- #
- def relative_to_original_destination_root(path, remove_dot = true)
- root = @destination_stack[0]
- if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ''].include?(path[root.size..root.size])
- path = path.dup
- path[0...root.size] = '.'
- remove_dot ? (path[2..-1] || "") : path
- else
- path
- end
- end
-
- # Holds source paths in instance so they can be manipulated.
- #
- def source_paths
- @source_paths ||= self.class.source_paths_for_search
- end
-
- # Receives a file or directory and search for it in the source paths.
- #
- def find_in_source_paths(file)
- possible_files = [file, file + TEMPLATE_EXTNAME]
- relative_root = relative_to_original_destination_root(destination_root, false)
-
- source_paths.each do |source|
- possible_files.each do |f|
- source_file = File.expand_path(f, File.join(source, relative_root))
- return source_file if File.exist?(source_file)
- end
- end
-
- message = "Could not find #{file.inspect} in any of your source paths. ".dup
-
- unless self.class.source_root
- message << "Please invoke #{self.class.name}.source_root(PATH) with the PATH containing your templates. "
- end
-
- message << if source_paths.empty?
- "Currently you have no source paths."
- else
- "Your current source paths are: \n#{source_paths.join("\n")}"
- end
-
- raise Error, message
- end
-
- # Do something in the root or on a provided subfolder. If a relative path
- # is given it's referenced from the current root. The full path is yielded
- # to the block you provide. The path is set back to the previous path when
- # the method exits.
- #
- # ==== Parameters
- # dir<String>:: the directory to move to.
- # config<Hash>:: give :verbose => true to log and use padding.
- #
- def inside(dir = "", config = {}, &block)
- verbose = config.fetch(:verbose, false)
- pretend = options[:pretend]
-
- say_status :inside, dir, verbose
- shell.padding += 1 if verbose
- @destination_stack.push File.expand_path(dir, destination_root)
-
- # If the directory doesnt exist and we're not pretending
- if !File.exist?(destination_root) && !pretend
- require "fileutils"
- FileUtils.mkdir_p(destination_root)
- end
-
- if pretend
- # In pretend mode, just yield down to the block
- block.arity == 1 ? yield(destination_root) : yield
- else
- require "fileutils"
- FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
- end
-
- @destination_stack.pop
- shell.padding -= 1 if verbose
- end
-
- # Goes to the root and execute the given block.
- #
- def in_root
- inside(@destination_stack.first) { yield }
- end
-
- # Loads an external file and execute it in the instance binding.
- #
- # ==== Parameters
- # path<String>:: The path to the file to execute. Can be a web address or
- # a relative path from the source root.
- #
- # ==== Examples
- #
- # apply "http://gist.github.com/103208"
- #
- # apply "recipes/jquery.rb"
- #
- def apply(path, config = {})
- verbose = config.fetch(:verbose, true)
- is_uri = path =~ %r{^https?\://}
- path = find_in_source_paths(path) unless is_uri
-
- say_status :apply, path, verbose
- shell.padding += 1 if verbose
-
- contents = if is_uri
- require "open-uri"
- open(path, "Accept" => "application/x-thor-template", &:read)
- else
- open(path, &:read)
- end
-
- instance_eval(contents, path)
- shell.padding -= 1 if verbose
- end
-
- # Executes a command returning the contents of the command.
- #
- # ==== Parameters
- # command<String>:: the command to be executed.
- # config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output. Specify :with
- # to append an executable to command execution.
- #
- # ==== Example
- #
- # inside('vendor') do
- # run('ln -s ~/edge rails')
- # end
- #
- def run(command, config = {})
- return unless behavior == :invoke
-
- destination = relative_to_original_destination_root(destination_root, false)
- desc = "#{command} from #{destination.inspect}"
-
- if config[:with]
- desc = "#{File.basename(config[:with].to_s)} #{desc}"
- command = "#{config[:with]} #{command}"
- end
-
- say_status :run, desc, config.fetch(:verbose, true)
-
- return if options[:pretend]
-
- env_splat = [config[:env]] if config[:env]
-
- if config[:capture]
- require "open3"
- result, status = Open3.capture2e(*env_splat, command.to_s)
- success = status.success?
- else
- result = system(*env_splat, command.to_s)
- success = result
- end
-
- abort if !success && config.fetch(:abort_on_failure, self.class.exit_on_failure?)
-
- result
- end
-
- # Executes a ruby script (taking into account WIN32 platform quirks).
- #
- # ==== Parameters
- # command<String>:: the command to be executed.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- def run_ruby_script(command, config = {})
- return unless behavior == :invoke
- run command, config.merge(:with => Bundler::Thor::Util.ruby_command)
- end
-
- # Run a thor command. A hash of options can be given and it's converted to
- # switches.
- #
- # ==== Parameters
- # command<String>:: the command to be invoked
- # args<Array>:: arguments to the command
- # config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output.
- # Other options are given as parameter to Bundler::Thor.
- #
- #
- # ==== Examples
- #
- # thor :install, "http://gist.github.com/103208"
- # #=> thor install http://gist.github.com/103208
- #
- # thor :list, :all => true, :substring => 'rails'
- # #=> thor list --all --substring=rails
- #
- def thor(command, *args)
- config = args.last.is_a?(Hash) ? args.pop : {}
- verbose = config.key?(:verbose) ? config.delete(:verbose) : true
- pretend = config.key?(:pretend) ? config.delete(:pretend) : false
- capture = config.key?(:capture) ? config.delete(:capture) : false
-
- args.unshift(command)
- args.push Bundler::Thor::Options.to_switches(config)
- command = args.join(" ").strip
-
- run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
- end
-
- protected
-
- # Allow current root to be shared between invocations.
- #
- def _shared_configuration #:nodoc:
- super.merge!(:destination_root => destination_root)
- end
-
- def _cleanup_options_and_set(options, key) #:nodoc:
- case options
- when Array
- %w(--force -f --skip -s).each { |i| options.delete(i) }
- options << "--#{key}"
- when Hash
- [:force, :skip, "force", "skip"].each { |i| options.delete(i) }
- options.merge!(key => true)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
deleted file mode 100644
index 330fc08cae..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
+++ /dev/null
@@ -1,104 +0,0 @@
-require_relative "empty_directory"
-
-class Bundler::Thor
- module Actions
- # Create a new file relative to the destination root with the given data,
- # which is the return value of a block or a data string.
- #
- # ==== Parameters
- # destination<String>:: the relative path to the destination root.
- # data<String|NilClass>:: the data to append to the file.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # create_file "lib/fun_party.rb" do
- # hostname = ask("What is the virtual hostname I should use?")
- # "vhost.name = #{hostname}"
- # end
- #
- # create_file "config/apache.conf", "your apache config"
- #
- def create_file(destination, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- data = args.first
- action CreateFile.new(self, destination, block || data.to_s, config)
- end
- alias_method :add_file, :create_file
-
- # CreateFile is a subset of Template, which instead of rendering a file with
- # ERB, it gets the content from the user.
- #
- class CreateFile < EmptyDirectory #:nodoc:
- attr_reader :data
-
- def initialize(base, destination, data, config = {})
- @data = data
- super(base, destination, config)
- end
-
- # Checks if the content of the file at the destination is identical to the rendered result.
- #
- # ==== Returns
- # Boolean:: true if it is identical, false otherwise.
- #
- def identical?
- exists? && File.binread(destination) == render
- end
-
- # Holds the content to be added to the file.
- #
- def render
- @render ||= if data.is_a?(Proc)
- data.call
- else
- data
- end
- end
-
- def invoke!
- invoke_with_conflict_check do
- require "fileutils"
- FileUtils.mkdir_p(File.dirname(destination))
- File.open(destination, "wb") { |f| f.write render }
- end
- given_destination
- end
-
- protected
-
- # Now on conflict we check if the file is identical or not.
- #
- def on_conflict_behavior(&block)
- if identical?
- say_status :identical, :blue
- else
- options = base.options.merge(config)
- force_or_skip_or_conflict(options[:force], options[:skip], &block)
- end
- end
-
- # If force is true, run the action, otherwise check if it's not being
- # skipped. If both are false, show the file_collision menu, if the menu
- # returns true, force it, otherwise skip.
- #
- def force_or_skip_or_conflict(force, skip, &block)
- if force
- say_status :force, :yellow
- yield unless pretend?
- elsif skip
- say_status :skip, :yellow
- else
- say_status :conflict, :red
- force_or_skip_or_conflict(force_on_collision?, true, &block)
- end
- end
-
- # Shows the file collision menu to the user and gets the result.
- #
- def force_on_collision?
- base.shell.file_collision(destination) { render }
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb b/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb
deleted file mode 100644
index 70504a2c1f..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-require_relative "create_file"
-
-class Bundler::Thor
- module Actions
- # Create a new file relative to the destination root from the given source.
- #
- # ==== Parameters
- # destination<String>:: the relative path to the destination root.
- # source<String|NilClass>:: the relative path to the source root.
- # config<Hash>:: give :verbose => false to not log the status.
- # :: give :symbolic => false for hard link.
- #
- # ==== Examples
- #
- # create_link "config/apache.conf", "/etc/apache.conf"
- #
- def create_link(destination, *args)
- config = args.last.is_a?(Hash) ? args.pop : {}
- source = args.first
- action CreateLink.new(self, destination, source, config)
- end
- alias_method :add_link, :create_link
-
- # CreateLink is a subset of CreateFile, which instead of taking a block of
- # data, just takes a source string from the user.
- #
- class CreateLink < CreateFile #:nodoc:
- attr_reader :data
-
- # Checks if the content of the file at the destination is identical to the rendered result.
- #
- # ==== Returns
- # Boolean:: true if it is identical, false otherwise.
- #
- def identical?
- exists? && File.identical?(render, destination)
- end
-
- def invoke!
- invoke_with_conflict_check do
- require "fileutils"
- FileUtils.mkdir_p(File.dirname(destination))
- # Create a symlink by default
- config[:symbolic] = true if config[:symbolic].nil?
- File.unlink(destination) if exists?
- if config[:symbolic]
- File.symlink(render, destination)
- else
- File.link(render, destination)
- end
- end
- given_destination
- end
-
- def exists?
- super || File.symlink?(destination)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
deleted file mode 100644
index d37327a139..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-require_relative "empty_directory"
-
-class Bundler::Thor
- module Actions
- # Copies recursively the files from source directory to root directory.
- # If any of the files finishes with .tt, it's considered to be a template
- # and is placed in the destination without the extension .tt. If any
- # empty directory is found, it's copied and all .empty_directory files are
- # ignored. If any file name is wrapped within % signs, the text within
- # the % signs will be executed as a method and replaced with the returned
- # value. Let's suppose a doc directory with the following files:
- #
- # doc/
- # components/.empty_directory
- # README
- # rdoc.rb.tt
- # %app_name%.rb
- #
- # When invoked as:
- #
- # directory "doc"
- #
- # It will create a doc directory in the destination with the following
- # files (assuming that the `app_name` method returns the value "blog"):
- #
- # doc/
- # components/
- # README
- # rdoc.rb
- # blog.rb
- #
- # <b>Encoded path note:</b> Since Bundler::Thor internals use Object#respond_to? to check if it can
- # expand %something%, this `something` should be a public method in the class calling
- # #directory. If a method is private, Bundler::Thor stack raises PrivateMethodEncodedError.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- # If :recursive => false, does not look for paths recursively.
- # If :mode => :preserve, preserve the file mode from the source.
- # If :exclude_pattern => /regexp/, prevents copying files that match that regexp.
- #
- # ==== Examples
- #
- # directory "doc"
- # directory "doc", "docs", :recursive => false
- #
- def directory(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source
- action Directory.new(self, source, destination || source, config, &block)
- end
-
- class Directory < EmptyDirectory #:nodoc:
- attr_reader :source
-
- def initialize(base, source, destination = nil, config = {}, &block)
- @source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
- @block = block
- super(base, destination, {:recursive => true}.merge(config))
- end
-
- def invoke!
- base.empty_directory given_destination, config
- execute!
- end
-
- def revoke!
- execute!
- end
-
- protected
-
- def execute!
- lookup = Util.escape_globs(source)
- lookup = config[:recursive] ? File.join(lookup, "**") : lookup
- lookup = file_level_lookup(lookup)
-
- files(lookup).sort.each do |file_source|
- next if File.directory?(file_source)
- next if config[:exclude_pattern] && file_source.match(config[:exclude_pattern])
- file_destination = File.join(given_destination, file_source.gsub(source, "."))
- file_destination.gsub!("/./", "/")
-
- case file_source
- when /\.empty_directory$/
- dirname = File.dirname(file_destination).gsub(%r{/\.$}, "")
- next if dirname == given_destination
- base.empty_directory(dirname, config)
- when /#{TEMPLATE_EXTNAME}$/
- base.template(file_source, file_destination[0..-4], config, &@block)
- else
- base.copy_file(file_source, file_destination, config, &@block)
- end
- end
- end
-
- def file_level_lookup(previous_lookup)
- File.join(previous_lookup, "*")
- end
-
- def files(lookup)
- Dir.glob(lookup, File::FNM_DOTMATCH)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
deleted file mode 100644
index 284d92c19a..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-class Bundler::Thor
- module Actions
- # Creates an empty directory.
- #
- # ==== Parameters
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # empty_directory "doc"
- #
- def empty_directory(destination, config = {})
- action EmptyDirectory.new(self, destination, config)
- end
-
- # Class which holds create directory logic. This is the base class for
- # other actions like create_file and directory.
- #
- # This implementation is based in Templater actions, created by Jonas Nicklas
- # and Michael S. Klishin under MIT LICENSE.
- #
- class EmptyDirectory #:nodoc:
- attr_reader :base, :destination, :given_destination, :relative_destination, :config
-
- # Initializes given the source and destination.
- #
- # ==== Parameters
- # base<Bundler::Thor::Base>:: A Bundler::Thor::Base instance
- # source<String>:: Relative path to the source of this file
- # destination<String>:: Relative path to the destination of this file
- # config<Hash>:: give :verbose => false to not log the status.
- #
- def initialize(base, destination, config = {})
- @base = base
- @config = {:verbose => true}.merge(config)
- self.destination = destination
- end
-
- # Checks if the destination file already exists.
- #
- # ==== Returns
- # Boolean:: true if the file exists, false otherwise.
- #
- def exists?
- ::File.exist?(destination)
- end
-
- def invoke!
- invoke_with_conflict_check do
- require "fileutils"
- ::FileUtils.mkdir_p(destination)
- end
- end
-
- def revoke!
- say_status :remove, :red
- require "fileutils"
- ::FileUtils.rm_rf(destination) if !pretend? && exists?
- given_destination
- end
-
- protected
-
- # Shortcut for pretend.
- #
- def pretend?
- base.options[:pretend]
- end
-
- # Sets the absolute destination value from a relative destination value.
- # It also stores the given and relative destination. Let's suppose our
- # script is being executed on "dest", it sets the destination root to
- # "dest". The destination, given_destination and relative_destination
- # are related in the following way:
- #
- # inside "bar" do
- # empty_directory "baz"
- # end
- #
- # destination #=> dest/bar/baz
- # relative_destination #=> bar/baz
- # given_destination #=> baz
- #
- def destination=(destination)
- return unless destination
- @given_destination = convert_encoded_instructions(destination.to_s)
- @destination = ::File.expand_path(@given_destination, base.destination_root)
- @relative_destination = base.relative_to_original_destination_root(@destination)
- end
-
- # Filenames in the encoded form are converted. If you have a file:
- #
- # %file_name%.rb
- #
- # It calls #file_name from the base and replaces %-string with the
- # return value (should be String) of #file_name:
- #
- # user.rb
- #
- # The method referenced can be either public or private.
- #
- def convert_encoded_instructions(filename)
- filename.gsub(/%(.*?)%/) do |initial_string|
- method = $1.strip
- base.respond_to?(method, true) ? base.send(method) : initial_string
- end
- end
-
- # Receives a hash of options and just execute the block if some
- # conditions are met.
- #
- def invoke_with_conflict_check(&block)
- if exists?
- on_conflict_behavior(&block)
- else
- yield unless pretend?
- say_status :create, :green
- end
-
- destination
- rescue Errno::EISDIR, Errno::EEXIST
- on_file_clash_behavior
- end
-
- def on_file_clash_behavior
- say_status :file_clash, :red
- end
-
- # What to do when the destination file already exists.
- #
- def on_conflict_behavior
- say_status :exist, :blue
- end
-
- # Shortcut to say_status shell method.
- #
- def say_status(status, color)
- base.shell.say_status status, relative_destination, color if config[:verbose]
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
deleted file mode 100644
index afdbd53dd0..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
+++ /dev/null
@@ -1,373 +0,0 @@
-require "erb"
-
-class Bundler::Thor
- module Actions
- # Copies the file from the relative source to the relative destination. If
- # the destination is not given it's assumed to be equal to the source.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status, and
- # :mode => :preserve, to preserve the file mode from the source.
-
- #
- # ==== Examples
- #
- # copy_file "README", "doc/README"
- #
- # copy_file "doc/README"
- #
- def copy_file(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source
- source = File.expand_path(find_in_source_paths(source.to_s))
-
- resulting_destination = create_file destination, nil, config do
- content = File.binread(source)
- content = yield(content) if block
- content
- end
- if config[:mode] == :preserve
- mode = File.stat(source).mode
- chmod(resulting_destination, mode, config)
- end
- end
-
- # Links the file from the relative source to the relative destination. If
- # the destination is not given it's assumed to be equal to the source.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # link_file "README", "doc/README"
- #
- # link_file "doc/README"
- #
- def link_file(source, *args)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source
- source = File.expand_path(find_in_source_paths(source.to_s))
-
- create_link destination, source, config
- end
-
- # Gets the content at the given address and places it at the given relative
- # destination. If a block is given instead of destination, the content of
- # the url is yielded and used as location.
- #
- # +get+ relies on open-uri, so passing application user input would provide
- # a command injection attack vector.
- #
- # ==== Parameters
- # source<String>:: the address of the given content.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # get "http://gist.github.com/103208", "doc/README"
- #
- # get "http://gist.github.com/103208" do |content|
- # content.split("\n").first
- # end
- #
- def get(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first
-
- render = if source =~ %r{^https?\://}
- require "open-uri"
- URI.send(:open, source) { |input| input.binmode.read }
- else
- source = File.expand_path(find_in_source_paths(source.to_s))
- open(source) { |input| input.binmode.read }
- end
-
- destination ||= if block_given?
- block.arity == 1 ? yield(render) : yield
- else
- File.basename(source)
- end
-
- create_file destination, render, config
- end
-
- # Gets an ERB template at the relative source, executes it and makes a copy
- # at the relative destination. If the destination is not given it's assumed
- # to be equal to the source removing .tt from the filename.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # template "README", "doc/README"
- #
- # template "doc/README"
- #
- def template(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, "")
-
- source = File.expand_path(find_in_source_paths(source.to_s))
- context = config.delete(:context) || instance_eval("binding")
-
- create_file destination, nil, config do
- match = ERB.version.match(/(\d+\.\d+\.\d+)/)
- capturable_erb = if match && match[1] >= "2.2.0" # Ruby 2.6+
- CapturableERB.new(::File.binread(source), :trim_mode => "-", :eoutvar => "@output_buffer")
- else
- CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer")
- end
- content = capturable_erb.tap do |erb|
- erb.filename = source
- end.result(context)
- content = yield(content) if block
- content
- end
- end
-
- # Changes the mode of the given file or directory.
- #
- # ==== Parameters
- # mode<Integer>:: the file mode
- # path<String>:: the name of the file to change mode
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # chmod "script/server", 0755
- #
- def chmod(path, mode, config = {})
- return unless behavior == :invoke
- path = File.expand_path(path, destination_root)
- say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true)
- unless options[:pretend]
- require "fileutils"
- FileUtils.chmod_R(mode, path)
- end
- end
-
- # Prepend text to a file. Since it depends on insert_into_file, it's reversible.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # data<String>:: the data to prepend to the file, can be also given as a block.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # prepend_to_file 'config/environments/test.rb', 'config.gem "rspec"'
- #
- # prepend_to_file 'config/environments/test.rb' do
- # 'config.gem "rspec"'
- # end
- #
- def prepend_to_file(path, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- config[:after] = /\A/
- insert_into_file(path, *(args << config), &block)
- end
- alias_method :prepend_file, :prepend_to_file
-
- # Append text to a file. Since it depends on insert_into_file, it's reversible.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # data<String>:: the data to append to the file, can be also given as a block.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # append_to_file 'config/environments/test.rb', 'config.gem "rspec"'
- #
- # append_to_file 'config/environments/test.rb' do
- # 'config.gem "rspec"'
- # end
- #
- def append_to_file(path, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- config[:before] = /\z/
- insert_into_file(path, *(args << config), &block)
- end
- alias_method :append_file, :append_to_file
-
- # Injects text right after the class definition. Since it depends on
- # insert_into_file, it's reversible.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # klass<String|Class>:: the class to be manipulated
- # data<String>:: the data to append to the class, can be also given as a block.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # inject_into_class "app/controllers/application_controller.rb", ApplicationController, " filter_parameter :password\n"
- #
- # inject_into_class "app/controllers/application_controller.rb", ApplicationController do
- # " filter_parameter :password\n"
- # end
- #
- def inject_into_class(path, klass, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- config[:after] = /class #{klass}\n|class #{klass} .*\n/
- insert_into_file(path, *(args << config), &block)
- end
-
- # Injects text right after the module definition. Since it depends on
- # insert_into_file, it's reversible.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # module_name<String|Class>:: the module to be manipulated
- # data<String>:: the data to append to the class, can be also given as a block.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper, " def help; 'help'; end\n"
- #
- # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do
- # " def help; 'help'; end\n"
- # end
- #
- def inject_into_module(path, module_name, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- config[:after] = /module #{module_name}\n|module #{module_name} .*\n/
- insert_into_file(path, *(args << config), &block)
- end
-
- # Run a regular expression replacement on a file.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # flag<Regexp|String>:: the regexp or string to be replaced
- # replacement<String>:: the replacement, can be also given as a block
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
- #
- # gsub_file 'README', /rake/, :green do |match|
- # match << " no more. Use thor!"
- # end
- #
- def gsub_file(path, flag, *args, &block)
- return unless behavior == :invoke
- config = args.last.is_a?(Hash) ? args.pop : {}
-
- path = File.expand_path(path, destination_root)
- say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
-
- unless options[:pretend]
- content = File.binread(path)
- content.gsub!(flag, *args, &block)
- File.open(path, "wb") { |file| file.write(content) }
- end
- end
-
- # Uncomment all lines matching a given regex. It will leave the space
- # which existed before the comment hash in tact but will remove any spacing
- # between the comment hash and the beginning of the line.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # flag<Regexp|String>:: the regexp or string used to decide which lines to uncomment
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # uncomment_lines 'config/initializers/session_store.rb', /active_record/
- #
- def uncomment_lines(path, flag, *args)
- flag = flag.respond_to?(:source) ? flag.source : flag
-
- gsub_file(path, /^(\s*)#[[:blank:]]*(.*#{flag})/, '\1\2', *args)
- end
-
- # Comment all lines matching a given regex. It will leave the space
- # which existed before the beginning of the line in tact and will insert
- # a single space after the comment hash.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # flag<Regexp|String>:: the regexp or string used to decide which lines to comment
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # comment_lines 'config/initializers/session_store.rb', /cookie_store/
- #
- def comment_lines(path, flag, *args)
- flag = flag.respond_to?(:source) ? flag.source : flag
-
- gsub_file(path, /^(\s*)([^#\n]*#{flag})/, '\1# \2', *args)
- end
-
- # Removes a file at the given location.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # remove_file 'README'
- # remove_file 'app/controllers/application_controller.rb'
- #
- def remove_file(path, config = {})
- return unless behavior == :invoke
- path = File.expand_path(path, destination_root)
-
- say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
- if !options[:pretend] && File.exist?(path)
- require "fileutils"
- ::FileUtils.rm_rf(path)
- end
- end
- alias_method :remove_dir, :remove_file
-
- attr_accessor :output_buffer
- private :output_buffer, :output_buffer=
-
- private
-
- def concat(string)
- @output_buffer.concat(string)
- end
-
- def capture(*args)
- with_output_buffer { yield(*args) }
- end
-
- def with_output_buffer(buf = "".dup) #:nodoc:
- raise ArgumentError, "Buffer can not be a frozen object" if buf.frozen?
- old_buffer = output_buffer
- self.output_buffer = buf
- yield
- output_buffer
- ensure
- self.output_buffer = old_buffer
- end
-
- # Bundler::Thor::Actions#capture depends on what kind of buffer is used in ERB.
- # Thus CapturableERB fixes ERB to use String buffer.
- class CapturableERB < ERB
- def set_eoutvar(compiler, eoutvar = "_erbout")
- compiler.put_cmd = "#{eoutvar}.concat"
- compiler.insert_cmd = "#{eoutvar}.concat"
- compiler.pre_cmd = ["#{eoutvar} = ''.dup"]
- compiler.post_cmd = [eoutvar]
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
deleted file mode 100644
index 09ce0864f0..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-require_relative "empty_directory"
-
-class Bundler::Thor
- module Actions
- # Injects the given content into a file. Different from gsub_file, this
- # method is reversible.
- #
- # ==== Parameters
- # destination<String>:: Relative path to the destination root
- # data<String>:: Data to add to the file. Can be given as a block.
- # config<Hash>:: give :verbose => false to not log the status and the flag
- # for injection (:after or :before) or :force => true for
- # insert two or more times the same content.
- #
- # ==== Examples
- #
- # insert_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n"
- #
- # insert_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do
- # gems = ask "Which gems would you like to add?"
- # gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
- # end
- #
- WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }
-
- def insert_into_file(destination, *args, &block)
- data = block_given? ? block : args.shift
-
- config = args.shift || {}
- config[:after] = /\z/ unless config.key?(:before) || config.key?(:after)
-
- action InjectIntoFile.new(self, destination, data, config)
- end
- alias_method :inject_into_file, :insert_into_file
-
- class InjectIntoFile < EmptyDirectory #:nodoc:
- attr_reader :replacement, :flag, :behavior
-
- def initialize(base, destination, data, config)
- super(base, destination, {:verbose => true}.merge(config))
-
- @behavior, @flag = if @config.key?(:after)
- [:after, @config.delete(:after)]
- else
- [:before, @config.delete(:before)]
- end
-
- @replacement = data.is_a?(Proc) ? data.call : data
- @flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)
- end
-
- def invoke!
- content = if @behavior == :after
- '\0' + replacement
- else
- replacement + '\0'
- end
-
- if exists?
- if replace!(/#{flag}/, content, config[:force])
- say_status(:invoke)
- else
- say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)
- end
- else
- unless pretend?
- raise Bundler::Thor::Error, "The file #{ destination } does not appear to exist"
- end
- end
- end
-
- def revoke!
- say_status :revoke
-
- regexp = if @behavior == :after
- content = '\1\2'
- /(#{flag})(.*)(#{Regexp.escape(replacement)})/m
- else
- content = '\2\3'
- /(#{Regexp.escape(replacement)})(.*)(#{flag})/m
- end
-
- replace!(regexp, content, true)
- end
-
- protected
-
- def say_status(behavior, warning: nil, color: nil)
- status = if behavior == :invoke
- if flag == /\A/
- :prepend
- elsif flag == /\z/
- :append
- else
- :insert
- end
- elsif warning
- warning
- else
- :subtract
- end
-
- super(status, (color || config[:verbose]))
- end
-
- # Adds the content to the file.
- #
- def replace!(regexp, string, force)
- return if pretend?
- content = File.read(destination)
- if force || !content.include?(replacement)
- success = content.gsub!(regexp, string)
-
- File.open(destination, "wb") { |file| file.write(content) }
- success
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/base.rb b/lib/bundler/vendor/thor/lib/thor/base.rb
deleted file mode 100644
index 9ba5243378..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/base.rb
+++ /dev/null
@@ -1,690 +0,0 @@
-require_relative "command"
-require_relative "core_ext/hash_with_indifferent_access"
-require_relative "error"
-require_relative "invocation"
-require_relative "nested_context"
-require_relative "parser"
-require_relative "shell"
-require_relative "line_editor"
-require_relative "util"
-
-class Bundler::Thor
- autoload :Actions, File.expand_path("actions", __dir__)
- autoload :RakeCompat, File.expand_path("rake_compat", __dir__)
- autoload :Group, File.expand_path("group", __dir__)
-
- # Shortcuts for help.
- HELP_MAPPINGS = %w(-h -? --help -D)
-
- # Bundler::Thor methods that should not be overwritten by the user.
- THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
- action add_file create_file in_root inside run run_ruby_script)
-
- TEMPLATE_EXTNAME = ".tt"
-
- module Base
- attr_accessor :options, :parent_options, :args
-
- # It receives arguments in an Array and two hashes, one for options and
- # other for configuration.
- #
- # Notice that it does not check if all required arguments were supplied.
- # It should be done by the parser.
- #
- # ==== Parameters
- # args<Array[Object]>:: An array of objects. The objects are applied to their
- # respective accessors declared with <tt>argument</tt>.
- #
- # options<Hash>:: An options hash that will be available as self.options.
- # The hash given is converted to a hash with indifferent
- # access, magic predicates (options.skip?) and then frozen.
- #
- # config<Hash>:: Configuration for this Bundler::Thor class.
- #
- def initialize(args = [], local_options = {}, config = {})
- parse_options = self.class.class_options
-
- # The start method splits inbound arguments at the first argument
- # that looks like an option (starts with - or --). It then calls
- # new, passing in the two halves of the arguments Array as the
- # first two parameters.
-
- command_options = config.delete(:command_options) # hook for start
- parse_options = parse_options.merge(command_options) if command_options
- if local_options.is_a?(Array)
- array_options = local_options
- hash_options = {}
- else
- # Handle the case where the class was explicitly instantiated
- # with pre-parsed options.
- array_options = []
- hash_options = local_options
- end
-
- # Let Bundler::Thor::Options parse the options first, so it can remove
- # declared options from the array. This will leave us with
- # a list of arguments that weren't declared.
- stop_on_unknown = self.class.stop_on_unknown_option? config[:current_command]
- disable_required_check = self.class.disable_required_check? config[:current_command]
- opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check)
- self.options = opts.parse(array_options)
- self.options = config[:class_options].merge(options) if config[:class_options]
-
- # If unknown options are disallowed, make sure that none of the
- # remaining arguments looks like an option.
- opts.check_unknown! if self.class.check_unknown_options?(config)
-
- # Add the remaining arguments from the options parser to the
- # arguments passed in to initialize. Then remove any positional
- # arguments declared using #argument (this is primarily used
- # by Bundler::Thor::Group). Tis will leave us with the remaining
- # positional arguments.
- to_parse = args
- to_parse += opts.remaining unless self.class.strict_args_position?(config)
-
- thor_args = Bundler::Thor::Arguments.new(self.class.arguments)
- thor_args.parse(to_parse).each { |k, v| __send__("#{k}=", v) }
- @args = thor_args.remaining
- end
-
- class << self
- def included(base) #:nodoc:
- super(base)
- base.extend ClassMethods
- base.send :include, Invocation
- base.send :include, Shell
- end
-
- # Returns the classes that inherits from Bundler::Thor or Bundler::Thor::Group.
- #
- # ==== Returns
- # Array[Class]
- #
- def subclasses
- @subclasses ||= []
- end
-
- # Returns the files where the subclasses are kept.
- #
- # ==== Returns
- # Hash[path<String> => Class]
- #
- def subclass_files
- @subclass_files ||= Hash.new { |h, k| h[k] = [] }
- end
-
- # Whenever a class inherits from Bundler::Thor or Bundler::Thor::Group, we should track the
- # class and the file on Bundler::Thor::Base. This is the method responsible for it.
- #
- def register_klass_file(klass) #:nodoc:
- file = caller[1].match(/(.*):\d+/)[1]
- Bundler::Thor::Base.subclasses << klass unless Bundler::Thor::Base.subclasses.include?(klass)
-
- file_subclasses = Bundler::Thor::Base.subclass_files[File.expand_path(file)]
- file_subclasses << klass unless file_subclasses.include?(klass)
- end
- end
-
- module ClassMethods
- def attr_reader(*) #:nodoc:
- no_commands { super }
- end
-
- def attr_writer(*) #:nodoc:
- no_commands { super }
- end
-
- def attr_accessor(*) #:nodoc:
- no_commands { super }
- end
-
- # If you want to raise an error for unknown options, call check_unknown_options!
- # This is disabled by default to allow dynamic invocations.
- def check_unknown_options!
- @check_unknown_options = true
- end
-
- def check_unknown_options #:nodoc:
- @check_unknown_options ||= from_superclass(:check_unknown_options, false)
- end
-
- def check_unknown_options?(config) #:nodoc:
- !!check_unknown_options
- end
-
- # If you want to raise an error when the default value of an option does not match
- # the type call check_default_type!
- # This will be the default; for compatibility a deprecation warning is issued if necessary.
- def check_default_type!
- @check_default_type = true
- end
-
- # If you want to use defaults that don't match the type of an option,
- # either specify `check_default_type: false` or call `allow_incompatible_default_type!`
- def allow_incompatible_default_type!
- @check_default_type = false
- end
-
- def check_default_type #:nodoc:
- @check_default_type = from_superclass(:check_default_type, nil) unless defined?(@check_default_type)
- @check_default_type
- end
-
- # If true, option parsing is suspended as soon as an unknown option or a
- # regular argument is encountered. All remaining arguments are passed to
- # the command as regular arguments.
- def stop_on_unknown_option?(command_name) #:nodoc:
- false
- end
-
- # If true, option set will not suspend the execution of the command when
- # a required option is not provided.
- def disable_required_check?(command_name) #:nodoc:
- false
- end
-
- # If you want only strict string args (useful when cascading thor classes),
- # call strict_args_position! This is disabled by default to allow dynamic
- # invocations.
- def strict_args_position!
- @strict_args_position = true
- end
-
- def strict_args_position #:nodoc:
- @strict_args_position ||= from_superclass(:strict_args_position, false)
- end
-
- def strict_args_position?(config) #:nodoc:
- !!strict_args_position
- end
-
- # Adds an argument to the class and creates an attr_accessor for it.
- #
- # Arguments are different from options in several aspects. The first one
- # is how they are parsed from the command line, arguments are retrieved
- # from position:
- #
- # thor command NAME
- #
- # Instead of:
- #
- # thor command --name=NAME
- #
- # Besides, arguments are used inside your code as an accessor (self.argument),
- # while options are all kept in a hash (self.options).
- #
- # Finally, arguments cannot have type :default or :boolean but can be
- # optional (supplying :optional => :true or :required => false), although
- # you cannot have a required argument after a non-required argument. If you
- # try it, an error is raised.
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described below.
- #
- # ==== Options
- # :desc - Description for the argument.
- # :required - If the argument is required or not.
- # :optional - If the argument is optional or not.
- # :type - The type of the argument, can be :string, :hash, :array, :numeric.
- # :default - Default value for this argument. It cannot be required and have default values.
- # :banner - String to show on usage notes.
- #
- # ==== Errors
- # ArgumentError:: Raised if you supply a required argument after a non required one.
- #
- def argument(name, options = {})
- is_thor_reserved_word?(name, :argument)
- no_commands { attr_accessor name }
-
- required = if options.key?(:optional)
- !options[:optional]
- elsif options.key?(:required)
- options[:required]
- else
- options[:default].nil?
- end
-
- remove_argument name
-
- if required
- arguments.each do |argument|
- next if argument.required?
- raise ArgumentError, "You cannot have #{name.to_s.inspect} as required argument after " \
- "the non-required argument #{argument.human_name.inspect}."
- end
- end
-
- options[:required] = required
-
- arguments << Bundler::Thor::Argument.new(name, options)
- end
-
- # Returns this class arguments, looking up in the ancestors chain.
- #
- # ==== Returns
- # Array[Bundler::Thor::Argument]
- #
- def arguments
- @arguments ||= from_superclass(:arguments, [])
- end
-
- # Adds a bunch of options to the set of class options.
- #
- # class_options :foo => false, :bar => :required, :baz => :string
- #
- # If you prefer more detailed declaration, check class_option.
- #
- # ==== Parameters
- # Hash[Symbol => Object]
- #
- def class_options(options = nil)
- @class_options ||= from_superclass(:class_options, {})
- build_options(options, @class_options) if options
- @class_options
- end
-
- # Adds an option to the set of class options
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described below.
- #
- # ==== Options
- # :desc:: -- Description for the argument.
- # :required:: -- If the argument is required or not.
- # :default:: -- Default value for this argument.
- # :group:: -- The group for this options. Use by class options to output options in different levels.
- # :aliases:: -- Aliases for this option. <b>Note:</b> Bundler::Thor follows a convention of one-dash-one-letter options. Thus aliases like "-something" wouldn't be parsed; use either "\--something" or "-s" instead.
- # :type:: -- The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
- # :banner:: -- String to show on usage notes.
- # :hide:: -- If you want to hide this option from the help.
- #
- def class_option(name, options = {})
- build_option(name, options, class_options)
- end
-
- # Removes a previous defined argument. If :undefine is given, undefine
- # accessors as well.
- #
- # ==== Parameters
- # names<Array>:: Arguments to be removed
- #
- # ==== Examples
- #
- # remove_argument :foo
- # remove_argument :foo, :bar, :baz, :undefine => true
- #
- def remove_argument(*names)
- options = names.last.is_a?(Hash) ? names.pop : {}
-
- names.each do |name|
- arguments.delete_if { |a| a.name == name.to_s }
- undef_method name, "#{name}=" if options[:undefine]
- end
- end
-
- # Removes a previous defined class option.
- #
- # ==== Parameters
- # names<Array>:: Class options to be removed
- #
- # ==== Examples
- #
- # remove_class_option :foo
- # remove_class_option :foo, :bar, :baz
- #
- def remove_class_option(*names)
- names.each do |name|
- class_options.delete(name)
- end
- end
-
- # Defines the group. This is used when thor list is invoked so you can specify
- # that only commands from a pre-defined group will be shown. Defaults to standard.
- #
- # ==== Parameters
- # name<String|Symbol>
- #
- def group(name = nil)
- if name
- @group = name.to_s
- else
- @group ||= from_superclass(:group, "standard")
- end
- end
-
- # Returns the commands for this Bundler::Thor class.
- #
- # ==== Returns
- # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
- # objects as values.
- #
- def commands
- @commands ||= Hash.new
- end
- alias_method :tasks, :commands
-
- # Returns the commands for this Bundler::Thor class and all subclasses.
- #
- # ==== Returns
- # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
- # objects as values.
- #
- def all_commands
- @all_commands ||= from_superclass(:all_commands, Hash.new)
- @all_commands.merge!(commands)
- end
- alias_method :all_tasks, :all_commands
-
- # Removes a given command from this Bundler::Thor class. This is usually done if you
- # are inheriting from another class and don't want it to be available
- # anymore.
- #
- # By default it only remove the mapping to the command. But you can supply
- # :undefine => true to undefine the method from the class as well.
- #
- # ==== Parameters
- # name<Symbol|String>:: The name of the command to be removed
- # options<Hash>:: You can give :undefine => true if you want commands the method
- # to be undefined from the class as well.
- #
- def remove_command(*names)
- options = names.last.is_a?(Hash) ? names.pop : {}
-
- names.each do |name|
- commands.delete(name.to_s)
- all_commands.delete(name.to_s)
- undef_method name if options[:undefine]
- end
- end
- alias_method :remove_task, :remove_command
-
- # All methods defined inside the given block are not added as commands.
- #
- # So you can do:
- #
- # class MyScript < Bundler::Thor
- # no_commands do
- # def this_is_not_a_command
- # end
- # end
- # end
- #
- # You can also add the method and remove it from the command list:
- #
- # class MyScript < Bundler::Thor
- # def this_is_not_a_command
- # end
- # remove_command :this_is_not_a_command
- # end
- #
- def no_commands(&block)
- no_commands_context.enter(&block)
- end
-
- alias_method :no_tasks, :no_commands
-
- def no_commands_context
- @no_commands_context ||= NestedContext.new
- end
-
- def no_commands?
- no_commands_context.entered?
- end
-
- # Sets the namespace for the Bundler::Thor or Bundler::Thor::Group class. By default the
- # namespace is retrieved from the class name. If your Bundler::Thor class is named
- # Scripts::MyScript, the help method, for example, will be called as:
- #
- # thor scripts:my_script -h
- #
- # If you change the namespace:
- #
- # namespace :my_scripts
- #
- # You change how your commands are invoked:
- #
- # thor my_scripts -h
- #
- # Finally, if you change your namespace to default:
- #
- # namespace :default
- #
- # Your commands can be invoked with a shortcut. Instead of:
- #
- # thor :my_command
- #
- def namespace(name = nil)
- if name
- @namespace = name.to_s
- else
- @namespace ||= Bundler::Thor::Util.namespace_from_thor_class(self)
- end
- end
-
- # Parses the command and options from the given args, instantiate the class
- # and invoke the command. This method is used when the arguments must be parsed
- # from an array. If you are inside Ruby and want to use a Bundler::Thor class, you
- # can simply initialize it:
- #
- # script = MyScript.new(args, options, config)
- # script.invoke(:command, first_arg, second_arg, third_arg)
- #
- def start(given_args = ARGV, config = {})
- config[:shell] ||= Bundler::Thor::Base.shell.new
- dispatch(nil, given_args.dup, nil, config)
- rescue Bundler::Thor::Error => e
- config[:debug] || ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message)
- exit(false) if exit_on_failure?
- rescue Errno::EPIPE
- # This happens if a thor command is piped to something like `head`,
- # which closes the pipe when it's done reading. This will also
- # mean that if the pipe is closed, further unnecessary
- # computation will not occur.
- exit(true)
- end
-
- # Allows to use private methods from parent in child classes as commands.
- #
- # ==== Parameters
- # names<Array>:: Method names to be used as commands
- #
- # ==== Examples
- #
- # public_command :foo
- # public_command :foo, :bar, :baz
- #
- def public_command(*names)
- names.each do |name|
- class_eval "def #{name}(*); super end"
- end
- end
- alias_method :public_task, :public_command
-
- def handle_no_command_error(command, has_namespace = $thor_runner) #:nodoc:
- raise UndefinedCommandError.new(command, all_commands.keys, (namespace if has_namespace))
- end
- alias_method :handle_no_task_error, :handle_no_command_error
-
- def handle_argument_error(command, error, args, arity) #:nodoc:
- name = [command.ancestor_name, command.name].compact.join(" ")
- msg = "ERROR: \"#{basename} #{name}\" was called with ".dup
- msg << "no arguments" if args.empty?
- msg << "arguments " << args.inspect unless args.empty?
- msg << "\nUsage: \"#{banner(command).split("\n").join("\"\n \"")}\""
- raise InvocationError, msg
- end
-
- # A flag that makes the process exit with status 1 if any error happens.
- def exit_on_failure?
- Bundler::Thor.deprecation_warning "Bundler::Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `#{self.name}`"
- false
- end
-
- protected
-
- # Prints the class options per group. If an option does not belong to
- # any group, it's printed as Class option.
- #
- def class_options_help(shell, groups = {}) #:nodoc:
- # Group options by group
- class_options.each do |_, value|
- groups[value.group] ||= []
- groups[value.group] << value
- end
-
- # Deal with default group
- global_options = groups.delete(nil) || []
- print_options(shell, global_options)
-
- # Print all others
- groups.each do |group_name, options|
- print_options(shell, options, group_name)
- end
- end
-
- # Receives a set of options and print them.
- def print_options(shell, options, group_name = nil)
- return if options.empty?
-
- list = []
- padding = options.map { |o| o.aliases.size }.max.to_i * 4
-
- options.each do |option|
- next if option.hide
- item = [option.usage(padding)]
- item.push(option.description ? "# #{option.description}" : "")
-
- list << item
- list << ["", "# Default: #{option.default}"] if option.show_default?
- list << ["", "# Possible values: #{option.enum.join(', ')}"] if option.enum
- end
-
- shell.say(group_name ? "#{group_name} options:" : "Options:")
- shell.print_table(list, :indent => 2)
- shell.say ""
- end
-
- # Raises an error if the word given is a Bundler::Thor reserved word.
- def is_thor_reserved_word?(word, type) #:nodoc:
- return false unless THOR_RESERVED_WORDS.include?(word.to_s)
- raise "#{word.inspect} is a Bundler::Thor reserved word and cannot be defined as #{type}"
- end
-
- # Build an option and adds it to the given scope.
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described in both class_option and method_option.
- # scope<Hash>:: Options hash that is being built up
- def build_option(name, options, scope) #:nodoc:
- scope[name] = Bundler::Thor::Option.new(name, {:check_default_type => check_default_type}.merge!(options))
- end
-
- # Receives a hash of options, parse them and add to the scope. This is a
- # fast way to set a bunch of options:
- #
- # build_options :foo => true, :bar => :required, :baz => :string
- #
- # ==== Parameters
- # Hash[Symbol => Object]
- def build_options(options, scope) #:nodoc:
- options.each do |key, value|
- scope[key] = Bundler::Thor::Option.parse(key, value)
- end
- end
-
- # Finds a command with the given name. If the command belongs to the current
- # class, just return it, otherwise dup it and add the fresh copy to the
- # current command hash.
- def find_and_refresh_command(name) #:nodoc:
- if commands[name.to_s]
- commands[name.to_s]
- elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
- commands[name.to_s] = command.clone
- else
- raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
- end
- end
- alias_method :find_and_refresh_task, :find_and_refresh_command
-
- # Everytime someone inherits from a Bundler::Thor class, register the klass
- # and file into baseclass.
- def inherited(klass)
- super(klass)
- Bundler::Thor::Base.register_klass_file(klass)
- klass.instance_variable_set(:@no_commands, 0)
- end
-
- # Fire this callback whenever a method is added. Added methods are
- # tracked as commands by invoking the create_command method.
- def method_added(meth)
- super(meth)
- meth = meth.to_s
-
- if meth == "initialize"
- initialize_added
- return
- end
-
- # Return if it's not a public instance method
- return unless public_method_defined?(meth.to_sym)
-
- return if no_commands? || !create_command(meth)
-
- is_thor_reserved_word?(meth, :command)
- Bundler::Thor::Base.register_klass_file(self)
- end
-
- # Retrieves a value from superclass. If it reaches the baseclass,
- # returns default.
- def from_superclass(method, default = nil)
- if self == baseclass || !superclass.respond_to?(method, true)
- default
- else
- value = superclass.send(method)
-
- # Ruby implements `dup` on Object, but raises a `TypeError`
- # if the method is called on immediates. As a result, we
- # don't have a good way to check whether dup will succeed
- # without calling it and rescuing the TypeError.
- begin
- value.dup
- rescue TypeError
- value
- end
-
- end
- end
-
- #
- # The basename of the program invoking the thor class.
- #
- def basename
- File.basename($PROGRAM_NAME).split(" ").first
- end
-
- # SIGNATURE: Sets the baseclass. This is where the superclass lookup
- # finishes.
- def baseclass #:nodoc:
- end
-
- # SIGNATURE: Creates a new command if valid_command? is true. This method is
- # called when a new method is added to the class.
- def create_command(meth) #:nodoc:
- end
- alias_method :create_task, :create_command
-
- # SIGNATURE: Defines behavior when the initialize method is added to the
- # class.
- def initialize_added #:nodoc:
- end
-
- # SIGNATURE: The hook invoked by start.
- def dispatch(command, given_args, given_opts, config) #:nodoc:
- raise NotImplementedError
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/command.rb b/lib/bundler/vendor/thor/lib/thor/command.rb
deleted file mode 100644
index 040c971c0c..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/command.rb
+++ /dev/null
@@ -1,142 +0,0 @@
-class Bundler::Thor
- class Command < Struct.new(:name, :description, :long_description, :usage, :options, :ancestor_name)
- FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
-
- def initialize(name, description, long_description, usage, options = nil)
- super(name.to_s, description, long_description, usage, options || {})
- end
-
- def initialize_copy(other) #:nodoc:
- super(other)
- self.options = other.options.dup if other.options
- end
-
- def hidden?
- false
- end
-
- # By default, a command invokes a method in the thor class. You can change this
- # implementation to create custom commands.
- def run(instance, args = [])
- arity = nil
-
- if private_method?(instance)
- instance.class.handle_no_command_error(name)
- elsif public_method?(instance)
- arity = instance.method(name).arity
- instance.__send__(name, *args)
- elsif local_method?(instance, :method_missing)
- instance.__send__(:method_missing, name.to_sym, *args)
- else
- instance.class.handle_no_command_error(name)
- end
- rescue ArgumentError => e
- handle_argument_error?(instance, e, caller) ? instance.class.handle_argument_error(self, e, args, arity) : (raise e)
- rescue NoMethodError => e
- handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (raise e)
- end
-
- # Returns the formatted usage by injecting given required arguments
- # and required options into the given usage.
- def formatted_usage(klass, namespace = true, subcommand = false)
- if ancestor_name
- formatted = "#{ancestor_name} ".dup # add space
- elsif namespace
- namespace = klass.namespace
- formatted = "#{namespace.gsub(/^(default)/, '')}:".dup
- end
- formatted ||= "#{klass.namespace.split(':').last} ".dup if subcommand
-
- formatted ||= "".dup
-
- Array(usage).map do |specific_usage|
- formatted_specific_usage = formatted
-
- formatted_specific_usage += required_arguments_for(klass, specific_usage)
-
- # Add required options
- formatted_specific_usage += " #{required_options}"
-
- # Strip and go!
- formatted_specific_usage.strip
- end.join("\n")
- end
-
- protected
-
- # Add usage with required arguments
- def required_arguments_for(klass, usage)
- if klass && !klass.arguments.empty?
- usage.to_s.gsub(/^#{name}/) do |match|
- match << " " << klass.arguments.map(&:usage).compact.join(" ")
- end
- else
- usage.to_s
- end
- end
-
- def not_debugging?(instance)
- !(instance.class.respond_to?(:debugging) && instance.class.debugging)
- end
-
- def required_options
- @required_options ||= options.map { |_, o| o.usage if o.required? }.compact.sort.join(" ")
- end
-
- # Given a target, checks if this class name is a public method.
- def public_method?(instance) #:nodoc:
- !(instance.public_methods & [name.to_s, name.to_sym]).empty?
- end
-
- def private_method?(instance)
- !(instance.private_methods & [name.to_s, name.to_sym]).empty?
- end
-
- def local_method?(instance, name)
- methods = instance.public_methods(false) + instance.private_methods(false) + instance.protected_methods(false)
- !(methods & [name.to_s, name.to_sym]).empty?
- end
-
- def sans_backtrace(backtrace, caller) #:nodoc:
- saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) || (frame =~ %r{^kernel/} && RUBY_ENGINE =~ /rbx/) }
- saned - caller
- end
-
- def handle_argument_error?(instance, error, caller)
- not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin
- saned = sans_backtrace(error.backtrace, caller)
- saned.empty? || saned.size == 1
- end
- end
-
- def handle_no_method_error?(instance, error, caller)
- not_debugging?(instance) &&
- error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
- end
- end
- Task = Command
-
- # A command that is hidden in help messages but still invocable.
- class HiddenCommand < Command
- def hidden?
- true
- end
- end
- HiddenTask = HiddenCommand
-
- # A dynamic command that handles method missing scenarios.
- class DynamicCommand < Command
- def initialize(name, options = nil)
- super(name.to_s, "A dynamically-generated command", name.to_s, name.to_s, options)
- end
-
- def run(instance, args = [])
- if (instance.methods & [name.to_s, name.to_sym]).empty?
- super
- else
- instance.class.handle_no_command_error(name)
- end
- end
- end
- DynamicTask = DynamicCommand
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
deleted file mode 100644
index c167aa33b8..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-class Bundler::Thor
- module CoreExt #:nodoc:
- # A hash with indifferent access and magic predicates.
- #
- # hash = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true
- #
- # hash[:foo] #=> 'bar'
- # hash['foo'] #=> 'bar'
- # hash.foo? #=> true
- #
- class HashWithIndifferentAccess < ::Hash #:nodoc:
- def initialize(hash = {})
- super()
- hash.each do |key, value|
- self[convert_key(key)] = value
- end
- end
-
- def [](key)
- super(convert_key(key))
- end
-
- def []=(key, value)
- super(convert_key(key), value)
- end
-
- def delete(key)
- super(convert_key(key))
- end
-
- def fetch(key, *args)
- super(convert_key(key), *args)
- end
-
- def key?(key)
- super(convert_key(key))
- end
-
- def values_at(*indices)
- indices.map { |key| self[convert_key(key)] }
- end
-
- def merge(other)
- dup.merge!(other)
- end
-
- def merge!(other)
- other.each do |key, value|
- self[convert_key(key)] = value
- end
- self
- end
-
- def reverse_merge(other)
- self.class.new(other).merge(self)
- end
-
- def reverse_merge!(other_hash)
- replace(reverse_merge(other_hash))
- end
-
- def replace(other_hash)
- super(other_hash)
- end
-
- # Convert to a Hash with String keys.
- def to_hash
- Hash.new(default).merge!(self)
- end
-
- protected
-
- def convert_key(key)
- key.is_a?(Symbol) ? key.to_s : key
- end
-
- # Magic predicates. For instance:
- #
- # options.force? # => !!options['force']
- # options.shebang # => "/usr/lib/local/ruby"
- # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
- #
- def method_missing(method, *args)
- method = method.to_s
- if method =~ /^(\w+)\?$/
- if args.empty?
- !!self[$1]
- else
- self[$1] == args.first
- end
- else
- self[method]
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb
deleted file mode 100644
index 0f6e2e0af2..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class IO #:nodoc:
- class << self
- unless method_defined? :binread
- def binread(file, *args)
- raise ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3
- File.open(file, "rb") do |f|
- f.read(*args)
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb
deleted file mode 100644
index 76f1e43c65..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-class Bundler::Thor
- module CoreExt
- class OrderedHash < ::Hash
- if RUBY_VERSION < "1.9"
- def initialize(*args, &block)
- super
- @keys = []
- end
-
- def initialize_copy(other)
- super
- # make a deep copy of keys
- @keys = other.keys
- end
-
- def []=(key, value)
- @keys << key unless key?(key)
- super
- end
-
- def delete(key)
- if key? key
- index = @keys.index(key)
- @keys.delete_at index
- end
- super
- end
-
- def delete_if
- super
- sync_keys!
- self
- end
-
- alias_method :reject!, :delete_if
-
- def reject(&block)
- dup.reject!(&block)
- end
-
- def keys
- @keys.dup
- end
-
- def values
- @keys.map { |key| self[key] }
- end
-
- def to_hash
- self
- end
-
- def to_a
- @keys.map { |key| [key, self[key]] }
- end
-
- def each_key
- return to_enum(:each_key) unless block_given?
- @keys.each { |key| yield(key) }
- self
- end
-
- def each_value
- return to_enum(:each_value) unless block_given?
- @keys.each { |key| yield(self[key]) }
- self
- end
-
- def each
- return to_enum(:each) unless block_given?
- @keys.each { |key| yield([key, self[key]]) }
- self
- end
-
- def each_pair
- return to_enum(:each_pair) unless block_given?
- @keys.each { |key| yield(key, self[key]) }
- self
- end
-
- alias_method :select, :find_all
-
- def clear
- super
- @keys.clear
- self
- end
-
- def shift
- k = @keys.first
- v = delete(k)
- [k, v]
- end
-
- def merge!(other_hash)
- if block_given?
- other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v }
- else
- other_hash.each { |k, v| self[k] = v }
- end
- self
- end
-
- alias_method :update, :merge!
-
- def merge(other_hash, &block)
- dup.merge!(other_hash, &block)
- end
-
- # When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not.
- def replace(other)
- super
- @keys = other.keys
- self
- end
-
- def inspect
- "#<#{self.class} #{super}>"
- end
-
- private
-
- def sync_keys!
- @keys.delete_if { |k| !key?(k) }
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/error.rb b/lib/bundler/vendor/thor/lib/thor/error.rb
deleted file mode 100644
index 1553afd201..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/error.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-class Bundler::Thor
- Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
- # In order to support versions of Ruby that don't have keyword
- # arguments, we need our own spell checker class that doesn't take key
- # words. Even though this code wouldn't be hit because of the check
- # above, it's still necessary because the interpreter would otherwise be
- # unable to parse the file.
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
- def initialize(dictionary)
- @dictionary = dictionary
- end
- end
-
- DidYouMean::Correctable
- end
-
- # Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
- # errors have their backtrace suppressed and are nicely shown to the user.
- #
- # Errors that are caused by the developer, like declaring a method which
- # overwrites a thor keyword, SHOULD NOT raise a Bundler::Thor::Error. This way, we
- # ensure that developer errors are shown with full backtrace.
- class Error < StandardError
- end
-
- # Raised when a command was not found.
- class UndefinedCommandError < Error
- class SpellChecker
- attr_reader :error
-
- def initialize(error)
- @error = error
- end
-
- def corrections
- @corrections ||= spell_checker.correct(error.command).map(&:inspect)
- end
-
- def spell_checker
- NoKwargSpellChecker.new(error.all_commands)
- end
- end
-
- attr_reader :command, :all_commands
-
- def initialize(command, all_commands, namespace)
- @command = command
- @all_commands = all_commands
-
- message = "Could not find command #{command.inspect}"
- message = namespace ? "#{message} in #{namespace.inspect} namespace." : "#{message}."
-
- super(message)
- end
-
- prepend Correctable if Correctable
- end
- UndefinedTaskError = UndefinedCommandError
-
- class AmbiguousCommandError < Error
- end
- AmbiguousTaskError = AmbiguousCommandError
-
- # Raised when a command was found, but not invoked properly.
- class InvocationError < Error
- end
-
- class UnknownArgumentError < Error
- class SpellChecker
- attr_reader :error
-
- def initialize(error)
- @error = error
- end
-
- def corrections
- @corrections ||=
- error.unknown.flat_map { |unknown| spell_checker.correct(unknown) }.uniq.map(&:inspect)
- end
-
- def spell_checker
- @spell_checker ||= NoKwargSpellChecker.new(error.switches)
- end
- end
-
- attr_reader :switches, :unknown
-
- def initialize(switches, unknown)
- @switches = switches
- @unknown = unknown
-
- super("Unknown switches #{unknown.map(&:inspect).join(', ')}")
- end
-
- prepend Correctable if Correctable
- end
-
- class RequiredArgumentMissingError < InvocationError
- end
-
- class MalformattedArgumentError < InvocationError
- end
-
- if Correctable
- DidYouMean::SPELL_CHECKERS.merge!(
- 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
- 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
- )
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/group.rb b/lib/bundler/vendor/thor/lib/thor/group.rb
deleted file mode 100644
index 7861d05345..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/group.rb
+++ /dev/null
@@ -1,281 +0,0 @@
-require_relative "base"
-
-# Bundler::Thor has a special class called Bundler::Thor::Group. The main difference to Bundler::Thor class
-# is that it invokes all commands at once. It also include some methods that allows
-# invocations to be done at the class method, which are not available to Bundler::Thor
-# commands.
-class Bundler::Thor::Group
- class << self
- # The description for this Bundler::Thor::Group. If none is provided, but a source root
- # exists, tries to find the USAGE one folder above it, otherwise searches
- # in the superclass.
- #
- # ==== Parameters
- # description<String>:: The description for this Bundler::Thor::Group.
- #
- def desc(description = nil)
- if description
- @desc = description
- else
- @desc ||= from_superclass(:desc, nil)
- end
- end
-
- # Prints help information.
- #
- # ==== Options
- # short:: When true, shows only usage.
- #
- def help(shell)
- shell.say "Usage:"
- shell.say " #{banner}\n"
- shell.say
- class_options_help(shell)
- shell.say desc if desc
- end
-
- # Stores invocations for this class merging with superclass values.
- #
- def invocations #:nodoc:
- @invocations ||= from_superclass(:invocations, {})
- end
-
- # Stores invocation blocks used on invoke_from_option.
- #
- def invocation_blocks #:nodoc:
- @invocation_blocks ||= from_superclass(:invocation_blocks, {})
- end
-
- # Invoke the given namespace or class given. It adds an instance
- # method that will invoke the klass and command. You can give a block to
- # configure how it will be invoked.
- #
- # The namespace/class given will have its options showed on the help
- # usage. Check invoke_from_option for more information.
- #
- def invoke(*names, &block)
- options = names.last.is_a?(Hash) ? names.pop : {}
- verbose = options.fetch(:verbose, true)
-
- names.each do |name|
- invocations[name] = false
- invocation_blocks[name] = block if block_given?
-
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
- def _invoke_#{name.to_s.gsub(/\W/, '_')}
- klass, command = self.class.prepare_for_invocation(nil, #{name.inspect})
-
- if klass
- say_status :invoke, #{name.inspect}, #{verbose.inspect}
- block = self.class.invocation_blocks[#{name.inspect}]
- _invoke_for_class_method klass, command, &block
- else
- say_status :error, %(#{name.inspect} [not found]), :red
- end
- end
- METHOD
- end
- end
-
- # Invoke a thor class based on the value supplied by the user to the
- # given option named "name". A class option must be created before this
- # method is invoked for each name given.
- #
- # ==== Examples
- #
- # class GemGenerator < Bundler::Thor::Group
- # class_option :test_framework, :type => :string
- # invoke_from_option :test_framework
- # end
- #
- # ==== Boolean options
- #
- # In some cases, you want to invoke a thor class if some option is true or
- # false. This is automatically handled by invoke_from_option. Then the
- # option name is used to invoke the generator.
- #
- # ==== Preparing for invocation
- #
- # In some cases you want to customize how a specified hook is going to be
- # invoked. You can do that by overwriting the class method
- # prepare_for_invocation. The class method must necessarily return a klass
- # and an optional command.
- #
- # ==== Custom invocations
- #
- # You can also supply a block to customize how the option is going to be
- # invoked. The block receives two parameters, an instance of the current
- # class and the klass to be invoked.
- #
- def invoke_from_option(*names, &block)
- options = names.last.is_a?(Hash) ? names.pop : {}
- verbose = options.fetch(:verbose, :white)
-
- names.each do |name|
- unless class_options.key?(name)
- raise ArgumentError, "You have to define the option #{name.inspect} " \
- "before setting invoke_from_option."
- end
-
- invocations[name] = true
- invocation_blocks[name] = block if block_given?
-
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
- def _invoke_from_option_#{name.to_s.gsub(/\W/, '_')}
- return unless options[#{name.inspect}]
-
- value = options[#{name.inspect}]
- value = #{name.inspect} if TrueClass === value
- klass, command = self.class.prepare_for_invocation(#{name.inspect}, value)
-
- if klass
- say_status :invoke, value, #{verbose.inspect}
- block = self.class.invocation_blocks[#{name.inspect}]
- _invoke_for_class_method klass, command, &block
- else
- say_status :error, %(\#{value} [not found]), :red
- end
- end
- METHOD
- end
- end
-
- # Remove a previously added invocation.
- #
- # ==== Examples
- #
- # remove_invocation :test_framework
- #
- def remove_invocation(*names)
- names.each do |name|
- remove_command(name)
- remove_class_option(name)
- invocations.delete(name)
- invocation_blocks.delete(name)
- end
- end
-
- # Overwrite class options help to allow invoked generators options to be
- # shown recursively when invoking a generator.
- #
- def class_options_help(shell, groups = {}) #:nodoc:
- get_options_from_invocations(groups, class_options) do |klass|
- klass.send(:get_options_from_invocations, groups, class_options)
- end
- super(shell, groups)
- end
-
- # Get invocations array and merge options from invocations. Those
- # options are added to group_options hash. Options that already exists
- # in base_options are not added twice.
- #
- def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
- invocations.each do |name, from_option|
- value = if from_option
- option = class_options[name]
- option.type == :boolean ? name : option.default
- else
- name
- end
- next unless value
-
- klass, _ = prepare_for_invocation(name, value)
- next unless klass && klass.respond_to?(:class_options)
-
- value = value.to_s
- human_name = value.respond_to?(:classify) ? value.classify : value
-
- group_options[human_name] ||= []
- group_options[human_name] += klass.class_options.values.select do |class_option|
- base_options[class_option.name.to_sym].nil? && class_option.group.nil? &&
- !group_options.values.flatten.any? { |i| i.name == class_option.name }
- end
-
- yield klass if block_given?
- end
- end
-
- # Returns commands ready to be printed.
- def printable_commands(*)
- item = []
- item << banner
- item << (desc ? "# #{desc.gsub(/\s+/m, ' ')}" : "")
- [item]
- end
- alias_method :printable_tasks, :printable_commands
-
- def handle_argument_error(command, error, _args, arity) #:nodoc:
- msg = "#{basename} #{command.name} takes #{arity} argument".dup
- msg << "s" if arity > 1
- msg << ", but it should not."
- raise error, msg
- end
-
- protected
-
- # The method responsible for dispatching given the args.
- def dispatch(command, given_args, given_opts, config) #:nodoc:
- if Bundler::Thor::HELP_MAPPINGS.include?(given_args.first)
- help(config[:shell])
- return
- end
-
- args, opts = Bundler::Thor::Options.split(given_args)
- opts = given_opts || opts
-
- instance = new(args, opts, config)
- yield instance if block_given?
-
- if command
- instance.invoke_command(all_commands[command])
- else
- instance.invoke_all
- end
- end
-
- # The banner for this class. You can customize it if you are invoking the
- # thor class by another ways which is not the Bundler::Thor::Runner.
- def banner
- "#{basename} #{self_command.formatted_usage(self, false)}"
- end
-
- # Represents the whole class as a command.
- def self_command #:nodoc:
- Bundler::Thor::DynamicCommand.new(namespace, class_options)
- end
- alias_method :self_task, :self_command
-
- def baseclass #:nodoc:
- Bundler::Thor::Group
- end
-
- def create_command(meth) #:nodoc:
- commands[meth.to_s] = Bundler::Thor::Command.new(meth, nil, nil, nil, nil)
- true
- end
- alias_method :create_task, :create_command
- end
-
- include Bundler::Thor::Base
-
-protected
-
- # Shortcut to invoke with padding and block handling. Use internally by
- # invoke and invoke_from_option class methods.
- def _invoke_for_class_method(klass, command = nil, *args, &block) #:nodoc:
- with_padding do
- if block
- case block.arity
- when 3
- yield(self, klass, command)
- when 2
- yield(self, klass)
- when 1
- instance_exec(klass, &block)
- end
- else
- invoke klass, command, *args
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/invocation.rb b/lib/bundler/vendor/thor/lib/thor/invocation.rb
deleted file mode 100644
index 248a466f8e..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/invocation.rb
+++ /dev/null
@@ -1,178 +0,0 @@
-class Bundler::Thor
- module Invocation
- def self.included(base) #:nodoc:
- super(base)
- base.extend ClassMethods
- end
-
- module ClassMethods
- # This method is responsible for receiving a name and find the proper
- # class and command for it. The key is an optional parameter which is
- # available only in class methods invocations (i.e. in Bundler::Thor::Group).
- def prepare_for_invocation(key, name) #:nodoc:
- case name
- when Symbol, String
- Bundler::Thor::Util.find_class_and_command_by_namespace(name.to_s, !key)
- else
- name
- end
- end
- end
-
- # Make initializer aware of invocations and the initialization args.
- def initialize(args = [], options = {}, config = {}, &block) #:nodoc:
- @_invocations = config[:invocations] || Hash.new { |h, k| h[k] = [] }
- @_initializer = [args, options, config]
- super
- end
-
- # Make the current command chain accessible with in a Bundler::Thor-(sub)command
- def current_command_chain
- @_invocations.values.flatten.map(&:to_sym)
- end
-
- # Receives a name and invokes it. The name can be a string (either "command" or
- # "namespace:command"), a Bundler::Thor::Command, a Class or a Bundler::Thor instance. If the
- # command cannot be guessed by name, it can also be supplied as second argument.
- #
- # You can also supply the arguments, options and configuration values for
- # the command to be invoked, if none is given, the same values used to
- # initialize the invoker are used to initialize the invoked.
- #
- # When no name is given, it will invoke the default command of the current class.
- #
- # ==== Examples
- #
- # class A < Bundler::Thor
- # def foo
- # invoke :bar
- # invoke "b:hello", ["Erik"]
- # end
- #
- # def bar
- # invoke "b:hello", ["Erik"]
- # end
- # end
- #
- # class B < Bundler::Thor
- # def hello(name)
- # puts "hello #{name}"
- # end
- # end
- #
- # You can notice that the method "foo" above invokes two commands: "bar",
- # which belongs to the same class and "hello" which belongs to the class B.
- #
- # By using an invocation system you ensure that a command is invoked only once.
- # In the example above, invoking "foo" will invoke "b:hello" just once, even
- # if it's invoked later by "bar" method.
- #
- # When class A invokes class B, all arguments used on A initialization are
- # supplied to B. This allows lazy parse of options. Let's suppose you have
- # some rspec commands:
- #
- # class Rspec < Bundler::Thor::Group
- # class_option :mock_framework, :type => :string, :default => :rr
- #
- # def invoke_mock_framework
- # invoke "rspec:#{options[:mock_framework]}"
- # end
- # end
- #
- # As you noticed, it invokes the given mock framework, which might have its
- # own options:
- #
- # class Rspec::RR < Bundler::Thor::Group
- # class_option :style, :type => :string, :default => :mock
- # end
- #
- # Since it's not rspec concern to parse mock framework options, when RR
- # is invoked all options are parsed again, so RR can extract only the options
- # that it's going to use.
- #
- # If you want Rspec::RR to be initialized with its own set of options, you
- # have to do that explicitly:
- #
- # invoke "rspec:rr", [], :style => :foo
- #
- # Besides giving an instance, you can also give a class to invoke:
- #
- # invoke Rspec::RR, [], :style => :foo
- #
- def invoke(name = nil, *args)
- if name.nil?
- warn "[Bundler::Thor] Calling invoke() without argument is deprecated. Please use invoke_all instead.\n#{caller.join("\n")}"
- return invoke_all
- end
-
- args.unshift(nil) if args.first.is_a?(Array) || args.first.nil?
- command, args, opts, config = args
-
- klass, command = _retrieve_class_and_command(name, command)
- raise "Missing Bundler::Thor class for invoke #{name}" unless klass
- raise "Expected Bundler::Thor class, got #{klass}" unless klass <= Bundler::Thor::Base
-
- args, opts, config = _parse_initialization_options(args, opts, config)
- klass.send(:dispatch, command, args, opts, config) do |instance|
- instance.parent_options = options
- end
- end
-
- # Invoke the given command if the given args.
- def invoke_command(command, *args) #:nodoc:
- current = @_invocations[self.class]
-
- unless current.include?(command.name)
- current << command.name
- command.run(self, *args)
- end
- end
- alias_method :invoke_task, :invoke_command
-
- # Invoke all commands for the current instance.
- def invoke_all #:nodoc:
- self.class.all_commands.map { |_, command| invoke_command(command) }
- end
-
- # Invokes using shell padding.
- def invoke_with_padding(*args)
- with_padding { invoke(*args) }
- end
-
- protected
-
- # Configuration values that are shared between invocations.
- def _shared_configuration #:nodoc:
- {:invocations => @_invocations}
- end
-
- # This method simply retrieves the class and command to be invoked.
- # If the name is nil or the given name is a command in the current class,
- # use the given name and return self as class. Otherwise, call
- # prepare_for_invocation in the current class.
- def _retrieve_class_and_command(name, sent_command = nil) #:nodoc:
- if name.nil?
- [self.class, nil]
- elsif self.class.all_commands[name.to_s]
- [self.class, name.to_s]
- else
- klass, command = self.class.prepare_for_invocation(nil, name)
- [klass, command || sent_command]
- end
- end
- alias_method :_retrieve_class_and_task, :_retrieve_class_and_command
-
- # Initialize klass using values stored in the @_initializer.
- def _parse_initialization_options(args, opts, config) #:nodoc:
- stored_args, stored_opts, stored_config = @_initializer
-
- args ||= stored_args.dup
- opts ||= stored_opts.dup
-
- config ||= {}
- config = stored_config.merge(_shared_configuration).merge!(config)
-
- [args, opts, config]
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/line_editor.rb b/lib/bundler/vendor/thor/lib/thor/line_editor.rb
deleted file mode 100644
index 5c0c336e7a..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/line_editor.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative "line_editor/basic"
-require_relative "line_editor/readline"
-
-class Bundler::Thor
- module LineEditor
- def self.readline(prompt, options = {})
- best_available.new(prompt, options).readline
- end
-
- def self.best_available
- [
- Bundler::Thor::LineEditor::Readline,
- Bundler::Thor::LineEditor::Basic
- ].detect(&:available?)
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb b/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
deleted file mode 100644
index fe3d7c998f..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-class Bundler::Thor
- module LineEditor
- class Basic
- attr_reader :prompt, :options
-
- def self.available?
- true
- end
-
- def initialize(prompt, options)
- @prompt = prompt
- @options = options
- end
-
- def readline
- $stdout.print(prompt)
- get_input
- end
-
- private
-
- def get_input
- if echo?
- $stdin.gets
- else
- # Lazy-load io/console since it is gem-ified as of 2.3
- require "io/console"
- $stdin.noecho(&:gets)
- end
- end
-
- def echo?
- options.fetch(:echo, true)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb b/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
deleted file mode 100644
index 120eadd06a..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-class Bundler::Thor
- module LineEditor
- class Readline < Basic
- def self.available?
- begin
- require "readline"
- rescue LoadError
- end
-
- Object.const_defined?(:Readline)
- end
-
- def readline
- if echo?
- ::Readline.completion_append_character = nil
- # rb-readline does not allow Readline.completion_proc= to receive nil.
- if complete = completion_proc
- ::Readline.completion_proc = complete
- end
- ::Readline.readline(prompt, add_to_history?)
- else
- super
- end
- end
-
- private
-
- def add_to_history?
- options.fetch(:add_to_history, true)
- end
-
- def completion_proc
- if use_path_completion?
- proc { |text| PathCompletion.new(text).matches }
- elsif completion_options.any?
- proc do |text|
- completion_options.select { |option| option.start_with?(text) }
- end
- end
- end
-
- def completion_options
- options.fetch(:limited_to, [])
- end
-
- def use_path_completion?
- options.fetch(:path, false)
- end
-
- class PathCompletion
- attr_reader :text
- private :text
-
- def initialize(text)
- @text = text
- end
-
- def matches
- relative_matches
- end
-
- private
-
- def relative_matches
- absolute_matches.map { |path| path.sub(base_path, "") }
- end
-
- def absolute_matches
- Dir[glob_pattern].map do |path|
- if File.directory?(path)
- "#{path}/"
- else
- path
- end
- end
- end
-
- def glob_pattern
- "#{base_path}#{text}*"
- end
-
- def base_path
- "#{Dir.pwd}/"
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/nested_context.rb b/lib/bundler/vendor/thor/lib/thor/nested_context.rb
deleted file mode 100644
index fd36b9d43f..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/nested_context.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-class Bundler::Thor
- class NestedContext
- def initialize
- @depth = 0
- end
-
- def enter
- push
-
- yield
- ensure
- pop
- end
-
- def entered?
- @depth > 0
- end
-
- private
-
- def push
- @depth += 1
- end
-
- def pop
- @depth -= 1
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser.rb b/lib/bundler/vendor/thor/lib/thor/parser.rb
deleted file mode 100644
index 45394732ca..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/parser.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require_relative "parser/argument"
-require_relative "parser/arguments"
-require_relative "parser/option"
-require_relative "parser/options"
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
deleted file mode 100644
index dfe7398583..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-class Bundler::Thor
- class Argument #:nodoc:
- VALID_TYPES = [:numeric, :hash, :array, :string]
-
- attr_reader :name, :description, :enum, :required, :type, :default, :banner
- alias_method :human_name, :name
-
- def initialize(name, options = {})
- class_name = self.class.name.split("::").last
-
- type = options[:type]
-
- raise ArgumentError, "#{class_name} name can't be nil." if name.nil?
- raise ArgumentError, "Type :#{type} is not valid for #{class_name.downcase}s." if type && !valid_type?(type)
-
- @name = name.to_s
- @description = options[:desc]
- @required = options.key?(:required) ? options[:required] : true
- @type = (type || :string).to_sym
- @default = options[:default]
- @banner = options[:banner] || default_banner
- @enum = options[:enum]
-
- validate! # Trigger specific validations
- end
-
- def usage
- required? ? banner : "[#{banner}]"
- end
-
- def required?
- required
- end
-
- def show_default?
- case default
- when Array, String, Hash
- !default.empty?
- else
- default
- end
- end
-
- protected
-
- def validate!
- raise ArgumentError, "An argument cannot be required and have default value." if required? && !default.nil?
- raise ArgumentError, "An argument cannot have an enum other than an array." if @enum && !@enum.is_a?(Array)
- end
-
- def valid_type?(type)
- self.class::VALID_TYPES.include?(type.to_sym)
- end
-
- def default_banner
- case type
- when :boolean
- nil
- when :string, :default
- human_name.upcase
- when :numeric
- "N"
- when :hash
- "key:value"
- when :array
- "one two three"
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
deleted file mode 100644
index d0f43e2d97..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
+++ /dev/null
@@ -1,175 +0,0 @@
-class Bundler::Thor
- class Arguments #:nodoc: # rubocop:disable ClassLength
- NUMERIC = /[-+]?(\d*\.\d+|\d+)/
-
- # Receives an array of args and returns two arrays, one with arguments
- # and one with switches.
- #
- def self.split(args)
- arguments = []
-
- args.each do |item|
- break if item.is_a?(String) && item =~ /^-/
- arguments << item
- end
-
- [arguments, args[Range.new(arguments.size, -1)]]
- end
-
- def self.parse(*args)
- to_parse = args.pop
- new(*args).parse(to_parse)
- end
-
- # Takes an array of Bundler::Thor::Argument objects.
- #
- def initialize(arguments = [])
- @assigns = {}
- @non_assigned_required = []
- @switches = arguments
-
- arguments.each do |argument|
- if !argument.default.nil?
- @assigns[argument.human_name] = argument.default
- elsif argument.required?
- @non_assigned_required << argument
- end
- end
- end
-
- def parse(args)
- @pile = args.dup
-
- @switches.each do |argument|
- break unless peek
- @non_assigned_required.delete(argument)
- @assigns[argument.human_name] = send(:"parse_#{argument.type}", argument.human_name)
- end
-
- check_requirement!
- @assigns
- end
-
- def remaining
- @pile
- end
-
- private
-
- def no_or_skip?(arg)
- arg =~ /^--(no|skip)-([-\w]+)$/
- $2
- end
-
- def last?
- @pile.empty?
- end
-
- def peek
- @pile.first
- end
-
- def shift
- @pile.shift
- end
-
- def unshift(arg)
- if arg.is_a?(Array)
- @pile = arg + @pile
- else
- @pile.unshift(arg)
- end
- end
-
- def current_is_value?
- peek && peek.to_s !~ /^-{1,2}\S+/
- end
-
- # Runs through the argument array getting strings that contains ":" and
- # mark it as a hash:
- #
- # [ "name:string", "age:integer" ]
- #
- # Becomes:
- #
- # { "name" => "string", "age" => "integer" }
- #
- def parse_hash(name)
- return shift if peek.is_a?(Hash)
- hash = {}
-
- while current_is_value? && peek.include?(":")
- key, value = shift.split(":", 2)
- raise MalformattedArgumentError, "You can't specify '#{key}' more than once in option '#{name}'; got #{key}:#{hash[key]} and #{key}:#{value}" if hash.include? key
- hash[key] = value
- end
- hash
- end
-
- # Runs through the argument array getting all strings until no string is
- # found or a switch is found.
- #
- # ["a", "b", "c"]
- #
- # And returns it as an array:
- #
- # ["a", "b", "c"]
- #
- def parse_array(name)
- return shift if peek.is_a?(Array)
- array = []
- array << shift while current_is_value?
- array
- end
-
- # Check if the peek is numeric format and return a Float or Integer.
- # Check if the peek is included in enum if enum is provided.
- # Otherwise raises an error.
- #
- def parse_numeric(name)
- return shift if peek.is_a?(Numeric)
-
- unless peek =~ NUMERIC && $& == peek
- raise MalformattedArgumentError, "Expected numeric value for '#{name}'; got #{peek.inspect}"
- end
-
- value = $&.index(".") ? shift.to_f : shift.to_i
- if @switches.is_a?(Hash) && switch = @switches[name]
- if switch.enum && !switch.enum.include?(value)
- raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
- end
- end
- value
- end
-
- # Parse string:
- # for --string-arg, just return the current value in the pile
- # for --no-string-arg, nil
- # Check if the peek is included in enum if enum is provided. Otherwise raises an error.
- #
- def parse_string(name)
- if no_or_skip?(name)
- nil
- else
- value = shift
- if @switches.is_a?(Hash) && switch = @switches[name]
- if switch.enum && !switch.enum.include?(value)
- raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
- end
- end
- value
- end
- end
-
- # Raises an error if @non_assigned_required array is not empty.
- #
- def check_requirement!
- return if @non_assigned_required.empty?
- names = @non_assigned_required.map do |o|
- o.respond_to?(:switch_name) ? o.switch_name : o.human_name
- end.join("', '")
- class_name = self.class.name.split("::").last.downcase
- raise RequiredArgumentMissingError, "No value provided for required #{class_name} '#{names}'"
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/option.rb b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
deleted file mode 100644
index 5a5af6f888..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/parser/option.rb
+++ /dev/null
@@ -1,159 +0,0 @@
-class Bundler::Thor
- class Option < Argument #:nodoc:
- attr_reader :aliases, :group, :lazy_default, :hide, :repeatable
-
- VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
-
- def initialize(name, options = {})
- @check_default_type = options[:check_default_type]
- options[:required] = false unless options.key?(:required)
- @repeatable = options.fetch(:repeatable, false)
- super
- @lazy_default = options[:lazy_default]
- @group = options[:group].to_s.capitalize if options[:group]
- @aliases = Array(options[:aliases])
- @hide = options[:hide]
- end
-
- # This parse quick options given as method_options. It makes several
- # assumptions, but you can be more specific using the option method.
- #
- # parse :foo => "bar"
- # #=> Option foo with default value bar
- #
- # parse [:foo, :baz] => "bar"
- # #=> Option foo with default value bar and alias :baz
- #
- # parse :foo => :required
- # #=> Required option foo without default value
- #
- # parse :foo => 2
- # #=> Option foo with default value 2 and type numeric
- #
- # parse :foo => :numeric
- # #=> Option foo without default value and type numeric
- #
- # parse :foo => true
- # #=> Option foo with default value true and type boolean
- #
- # The valid types are :boolean, :numeric, :hash, :array and :string. If none
- # is given a default type is assumed. This default type accepts arguments as
- # string (--foo=value) or booleans (just --foo).
- #
- # By default all options are optional, unless :required is given.
- #
- def self.parse(key, value)
- if key.is_a?(Array)
- name, *aliases = key
- else
- name = key
- aliases = []
- end
-
- name = name.to_s
- default = value
-
- type = case value
- when Symbol
- default = nil
- if VALID_TYPES.include?(value)
- value
- elsif required = (value == :required) # rubocop:disable AssignmentInCondition
- :string
- end
- when TrueClass, FalseClass
- :boolean
- when Numeric
- :numeric
- when Hash, Array, String
- value.class.name.downcase.to_sym
- end
-
- new(name.to_s, :required => required, :type => type, :default => default, :aliases => aliases)
- end
-
- def switch_name
- @switch_name ||= dasherized? ? name : dasherize(name)
- end
-
- def human_name
- @human_name ||= dasherized? ? undasherize(name) : name
- end
-
- def usage(padding = 0)
- sample = if banner && !banner.to_s.empty?
- "#{switch_name}=#{banner}".dup
- else
- switch_name
- end
-
- sample = "[#{sample}]".dup unless required?
-
- if boolean?
- sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-")
- end
-
- if aliases.empty?
- (" " * padding) << sample
- else
- "#{aliases.join(', ')}, #{sample}"
- end
- end
-
- VALID_TYPES.each do |type|
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
- def #{type}?
- self.type == #{type.inspect}
- end
- RUBY
- end
-
- protected
-
- def validate!
- raise ArgumentError, "An option cannot be boolean and required." if boolean? && required?
- validate_default_type!
- end
-
- def validate_default_type!
- default_type = case @default
- when nil
- return
- when TrueClass, FalseClass
- required? ? :string : :boolean
- when Numeric
- :numeric
- when Symbol
- :string
- when Hash, Array, String
- @default.class.name.downcase.to_sym
- end
-
- expected_type = (@repeatable && @type != :hash) ? :array : @type
-
- if default_type != expected_type
- err = "Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})"
-
- if @check_default_type
- raise ArgumentError, err
- elsif @check_default_type == nil
- Bundler::Thor.deprecation_warning "#{err}.\n" +
- 'This will be rejected in the future unless you explicitly pass the options `check_default_type: false`' +
- ' or call `allow_incompatible_default_type!` in your code'
- end
- end
- end
-
- def dasherized?
- name.index("-") == 0
- end
-
- def undasherize(str)
- str.sub(/^-{1,2}/, "")
- end
-
- def dasherize(str)
- (str.length > 1 ? "--" : "-") + str.tr("_", "-")
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
deleted file mode 100644
index 6d1342ee3c..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/parser/options.rb
+++ /dev/null
@@ -1,236 +0,0 @@
-class Bundler::Thor
- class Options < Arguments #:nodoc: # rubocop:disable ClassLength
- LONG_RE = /^(--\w+(?:-\w+)*)$/
- SHORT_RE = /^(-[a-z])$/i
- EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
- SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args
- SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i
- OPTS_END = "--".freeze
-
- # Receives a hash and makes it switches.
- def self.to_switches(options)
- options.map do |key, value|
- case value
- when true
- "--#{key}"
- when Array
- "--#{key} #{value.map(&:inspect).join(' ')}"
- when Hash
- "--#{key} #{value.map { |k, v| "#{k}:#{v}" }.join(' ')}"
- when nil, false
- nil
- else
- "--#{key} #{value.inspect}"
- end
- end.compact.join(" ")
- end
-
- # Takes a hash of Bundler::Thor::Option and a hash with defaults.
- #
- # If +stop_on_unknown+ is true, #parse will stop as soon as it encounters
- # an unknown option or a regular argument.
- def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false)
- @stop_on_unknown = stop_on_unknown
- @disable_required_check = disable_required_check
- options = hash_options.values
- super(options)
-
- # Add defaults
- defaults.each do |key, value|
- @assigns[key.to_s] = value
- @non_assigned_required.delete(hash_options[key])
- end
-
- @shorts = {}
- @switches = {}
- @extra = []
- @stopped_parsing_after_extra_index = nil
-
- options.each do |option|
- @switches[option.switch_name] = option
-
- option.aliases.each do |short|
- name = short.to_s.sub(/^(?!\-)/, "-")
- @shorts[name] ||= option.switch_name
- end
- end
- end
-
- def remaining
- @extra
- end
-
- def peek
- return super unless @parsing_options
-
- result = super
- if result == OPTS_END
- shift
- @parsing_options = false
- @stopped_parsing_after_extra_index ||= @extra.size
- super
- else
- result
- end
- end
-
- def parse(args) # rubocop:disable MethodLength
- @pile = args.dup
- @parsing_options = true
-
- while peek
- if parsing_options?
- match, is_switch = current_is_switch?
- shifted = shift
-
- if is_switch
- case shifted
- when SHORT_SQ_RE
- unshift($1.split("").map { |f| "-#{f}" })
- next
- when EQ_RE, SHORT_NUM
- unshift($2)
- switch = $1
- when LONG_RE, SHORT_RE
- switch = $1
- end
-
- switch = normalize_switch(switch)
- option = switch_option(switch)
- result = parse_peek(switch, option)
- assign_result!(option, result)
- elsif @stop_on_unknown
- @parsing_options = false
- @extra << shifted
- @stopped_parsing_after_extra_index ||= @extra.size
- @extra << shift while peek
- break
- elsif match
- @extra << shifted
- @extra << shift while peek && peek !~ /^-/
- else
- @extra << shifted
- end
- else
- @extra << shift
- end
- end
-
- check_requirement! unless @disable_required_check
-
- assigns = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new(@assigns)
- assigns.freeze
- assigns
- end
-
- def check_unknown!
- to_check = @stopped_parsing_after_extra_index ? @extra[0...@stopped_parsing_after_extra_index] : @extra
-
- # an unknown option starts with - or -- and has no more --'s afterward.
- unknown = to_check.select { |str| str =~ /^--?(?:(?!--).)*$/ }
- raise UnknownArgumentError.new(@switches.keys, unknown) unless unknown.empty?
- end
-
- protected
-
- def assign_result!(option, result)
- if option.repeatable && option.type == :hash
- (@assigns[option.human_name] ||= {}).merge!(result)
- elsif option.repeatable
- (@assigns[option.human_name] ||= []) << result
- else
- @assigns[option.human_name] = result
- end
- end
- # Check if the current value in peek is a registered switch.
- #
- # Two booleans are returned. The first is true if the current value
- # starts with a hyphen; the second is true if it is a registered switch.
- def current_is_switch?
- case peek
- when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM
- [true, switch?($1)]
- when SHORT_SQ_RE
- [true, $1.split("").any? { |f| switch?("-#{f}") }]
- else
- [false, false]
- end
- end
-
- def current_is_switch_formatted?
- case peek
- when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE
- true
- else
- false
- end
- end
-
- def current_is_value?
- peek && (!parsing_options? || super)
- end
-
- def switch?(arg)
- !switch_option(normalize_switch(arg)).nil?
- end
-
- def switch_option(arg)
- if match = no_or_skip?(arg) # rubocop:disable AssignmentInCondition
- @switches[arg] || @switches["--#{match}"]
- else
- @switches[arg]
- end
- end
-
- # Check if the given argument is actually a shortcut.
- #
- def normalize_switch(arg)
- (@shorts[arg] || arg).tr("_", "-")
- end
-
- def parsing_options?
- peek
- @parsing_options
- end
-
- # Parse boolean values which can be given as --foo=true, --foo or --no-foo.
- #
- def parse_boolean(switch)
- if current_is_value?
- if ["true", "TRUE", "t", "T", true].include?(peek)
- shift
- true
- elsif ["false", "FALSE", "f", "F", false].include?(peek)
- shift
- false
- else
- @switches.key?(switch) || !no_or_skip?(switch)
- end
- else
- @switches.key?(switch) || !no_or_skip?(switch)
- end
- end
-
- # Parse the value at the peek analyzing if it requires an input or not.
- #
- def parse_peek(switch, option)
- if parsing_options? && (current_is_switch_formatted? || last?)
- if option.boolean?
- # No problem for boolean types
- elsif no_or_skip?(switch)
- return nil # User set value to nil
- elsif option.string? && !option.required?
- # Return the default if there is one, else the human name
- return option.lazy_default || option.default || option.human_name
- elsif option.lazy_default
- return option.lazy_default
- else
- raise MalformattedArgumentError, "No value provided for option '#{switch}'"
- end
- end
-
- @non_assigned_required.delete(option)
- send(:"parse_#{option.type}", switch)
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
deleted file mode 100644
index f8f86372cc..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require "rake"
-require "rake/dsl_definition"
-
-class Bundler::Thor
- # Adds a compatibility layer to your Bundler::Thor classes which allows you to use
- # rake package tasks. For example, to use rspec rake tasks, one can do:
- #
- # require 'bundler/vendor/thor/lib/thor/rake_compat'
- # require 'rspec/core/rake_task'
- #
- # class Default < Bundler::Thor
- # include Bundler::Thor::RakeCompat
- #
- # RSpec::Core::RakeTask.new(:spec) do |t|
- # t.spec_opts = ['--options', './.rspec']
- # t.spec_files = FileList['spec/**/*_spec.rb']
- # end
- # end
- #
- module RakeCompat
- include Rake::DSL if defined?(Rake::DSL)
-
- def self.rake_classes
- @rake_classes ||= []
- end
-
- def self.included(base)
- super(base)
- # Hack. Make rakefile point to invoker, so rdoc task is generated properly.
- rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
- Rake.application.instance_variable_set(:@rakefile, rakefile)
- rake_classes << base
- end
- end
-end
-
-# override task on (main), for compatibility with Rake 0.9
-instance_eval do
- alias rake_namespace namespace
-
- def task(*)
- task = super
-
- if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
- non_namespaced_name = task.name.split(":").last
-
- description = non_namespaced_name
- description << task.arg_names.map { |n| n.to_s.upcase }.join(" ")
- description.strip!
-
- klass.desc description, Rake.application.last_description || non_namespaced_name
- Rake.application.last_description = nil
- klass.send :define_method, non_namespaced_name do |*args|
- Rake::Task[task.name.to_sym].invoke(*args)
- end
- end
-
- task
- end
-
- def namespace(name)
- if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
- const_name = Bundler::Thor::Util.camel_case(name.to_s).to_sym
- klass.const_set(const_name, Class.new(Bundler::Thor))
- new_klass = klass.const_get(const_name)
- Bundler::Thor::RakeCompat.rake_classes << new_klass
- end
-
- super
- Bundler::Thor::RakeCompat.rake_classes.pop
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/runner.rb b/lib/bundler/vendor/thor/lib/thor/runner.rb
deleted file mode 100644
index 54c5525093..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/runner.rb
+++ /dev/null
@@ -1,325 +0,0 @@
-require_relative "../thor"
-require_relative "group"
-
-require "yaml"
-require "digest/md5"
-require "pathname"
-
-class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
- autoload :OpenURI, "open-uri"
-
- map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
-
- def self.banner(command, all = false, subcommand = false)
- "thor " + command.formatted_usage(self, all, subcommand)
- end
-
- def self.exit_on_failure?
- true
- end
-
- # Override Bundler::Thor#help so it can give information about any class and any method.
- #
- def help(meth = nil)
- if meth && !respond_to?(meth)
- initialize_thorfiles(meth)
- klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
- self.class.handle_no_command_error(command, false) if klass.nil?
- klass.start(["-h", command].compact, :shell => shell)
- else
- super
- end
- end
-
- # If a command is not found on Bundler::Thor::Runner, method missing is invoked and
- # Bundler::Thor::Runner is then responsible for finding the command in all classes.
- #
- def method_missing(meth, *args)
- meth = meth.to_s
- initialize_thorfiles(meth)
- klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
- self.class.handle_no_command_error(command, false) if klass.nil?
- args.unshift(command) if command
- klass.start(args, :shell => shell)
- end
-
- desc "install NAME", "Install an optionally named Bundler::Thor file into your system commands"
- method_options :as => :string, :relative => :boolean, :force => :boolean
- def install(name) # rubocop:disable MethodLength
- initialize_thorfiles
-
- # If a directory name is provided as the argument, look for a 'main.thor'
- # command in said directory.
- begin
- if File.directory?(File.expand_path(name))
- base = File.join(name, "main.thor")
- package = :directory
- contents = open(base, &:read)
- else
- base = name
- package = :file
- contents = open(name, &:read)
- end
- rescue OpenURI::HTTPError
- raise Error, "Error opening URI '#{name}'"
- rescue Errno::ENOENT
- raise Error, "Error opening file '#{name}'"
- end
-
- say "Your Thorfile contains:"
- say contents
-
- unless options["force"]
- return false if no?("Do you wish to continue [y/N]?")
- end
-
- as = options["as"] || begin
- first_line = contents.split("\n")[0]
- (match = first_line.match(/\s*#\s*module:\s*([^\n]*)/)) ? match[1].strip : nil
- end
-
- unless as
- basename = File.basename(name)
- as = ask("Please specify a name for #{name} in the system repository [#{basename}]:")
- as = basename if as.empty?
- end
-
- location = if options[:relative] || name =~ %r{^https?://}
- name
- else
- File.expand_path(name)
- end
-
- thor_yaml[as] = {
- :filename => Digest::MD5.hexdigest(name + as),
- :location => location,
- :namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
- }
-
- save_yaml(thor_yaml)
- say "Storing thor file in your system repository"
- destination = File.join(thor_root, thor_yaml[as][:filename])
-
- if package == :file
- File.open(destination, "w") { |f| f.puts contents }
- else
- require "fileutils"
- FileUtils.cp_r(name, destination)
- end
-
- thor_yaml[as][:filename] # Indicate success
- end
-
- desc "version", "Show Bundler::Thor version"
- def version
- require_relative "version"
- say "Bundler::Thor #{Bundler::Thor::VERSION}"
- end
-
- desc "uninstall NAME", "Uninstall a named Bundler::Thor module"
- def uninstall(name)
- raise Error, "Can't find module '#{name}'" unless thor_yaml[name]
- say "Uninstalling #{name}."
- require "fileutils"
- FileUtils.rm_rf(File.join(thor_root, (thor_yaml[name][:filename]).to_s))
-
- thor_yaml.delete(name)
- save_yaml(thor_yaml)
-
- puts "Done."
- end
-
- desc "update NAME", "Update a Bundler::Thor file from its original location"
- def update(name)
- raise Error, "Can't find module '#{name}'" if !thor_yaml[name] || !thor_yaml[name][:location]
-
- say "Updating '#{name}' from #{thor_yaml[name][:location]}"
-
- old_filename = thor_yaml[name][:filename]
- self.options = options.merge("as" => name)
-
- if File.directory? File.expand_path(name)
- require "fileutils"
- FileUtils.rm_rf(File.join(thor_root, old_filename))
-
- thor_yaml.delete(old_filename)
- save_yaml(thor_yaml)
-
- filename = install(name)
- else
- filename = install(thor_yaml[name][:location])
- end
-
- File.delete(File.join(thor_root, old_filename)) unless filename == old_filename
- end
-
- desc "installed", "List the installed Bundler::Thor modules and commands"
- method_options :internal => :boolean
- def installed
- initialize_thorfiles(nil, true)
- display_klasses(true, options["internal"])
- end
-
- desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)"
- method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean
- def list(search = "")
- initialize_thorfiles
-
- search = ".*#{search}" if options["substring"]
- search = /^#{search}.*/i
- group = options[:group] || "standard"
-
- klasses = Bundler::Thor::Base.subclasses.select do |k|
- (options[:all] || k.group == group) && k.namespace =~ search
- end
-
- display_klasses(false, false, klasses)
- end
-
-private
-
- def thor_root
- Bundler::Thor::Util.thor_root
- end
-
- def thor_yaml
- @thor_yaml ||= begin
- yaml_file = File.join(thor_root, "thor.yml")
- yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file)
- yaml || {}
- end
- end
-
- # Save the yaml file. If none exists in thor root, creates one.
- #
- def save_yaml(yaml)
- yaml_file = File.join(thor_root, "thor.yml")
-
- unless File.exist?(yaml_file)
- require "fileutils"
- FileUtils.mkdir_p(thor_root)
- yaml_file = File.join(thor_root, "thor.yml")
- FileUtils.touch(yaml_file)
- end
-
- File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
- end
-
- # Load the Thorfiles. If relevant_to is supplied, looks for specific files
- # in the thor_root instead of loading them all.
- #
- # By default, it also traverses the current path until find Bundler::Thor files, as
- # described in thorfiles. This look up can be skipped by supplying
- # skip_lookup true.
- #
- def initialize_thorfiles(relevant_to = nil, skip_lookup = false)
- thorfiles(relevant_to, skip_lookup).each do |f|
- Bundler::Thor::Util.load_thorfile(f, nil, options[:debug]) unless Bundler::Thor::Base.subclass_files.keys.include?(File.expand_path(f))
- end
- end
-
- # Finds Thorfiles by traversing from your current directory down to the root
- # directory of your system. If at any time we find a Bundler::Thor file, we stop.
- #
- # We also ensure that system-wide Thorfiles are loaded first, so local
- # Thorfiles can override them.
- #
- # ==== Example
- #
- # If we start at /Users/wycats/dev/thor ...
- #
- # 1. /Users/wycats/dev/thor
- # 2. /Users/wycats/dev
- # 3. /Users/wycats <-- we find a Thorfile here, so we stop
- #
- # Suppose we start at c:\Documents and Settings\james\dev\thor ...
- #
- # 1. c:\Documents and Settings\james\dev\thor
- # 2. c:\Documents and Settings\james\dev
- # 3. c:\Documents and Settings\james
- # 4. c:\Documents and Settings
- # 5. c:\ <-- no Thorfiles found!
- #
- def thorfiles(relevant_to = nil, skip_lookup = false)
- thorfiles = []
-
- unless skip_lookup
- Pathname.pwd.ascend do |path|
- thorfiles = Bundler::Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten
- break unless thorfiles.empty?
- end
- end
-
- files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Bundler::Thor::Util.thor_root_glob)
- files += thorfiles
- files -= ["#{thor_root}/thor.yml"]
-
- files.map! do |file|
- File.directory?(file) ? File.join(file, "main.thor") : file
- end
- end
-
- # Load Thorfiles relevant to the given method. If you provide "foo:bar" it
- # will load all thor files in the thor.yaml that has "foo" e "foo:bar"
- # namespaces registered.
- #
- def thorfiles_relevant_to(meth)
- lookup = [meth, meth.split(":")[0...-1].join(":")]
-
- files = thor_yaml.select do |_, v|
- v[:namespaces] && !(v[:namespaces] & lookup).empty?
- end
-
- files.map { |_, v| File.join(thor_root, (v[:filename]).to_s) }
- end
-
- # Display information about the given klasses. If with_module is given,
- # it shows a table with information extracted from the yaml file.
- #
- def display_klasses(with_modules = false, show_internal = false, klasses = Bundler::Thor::Base.subclasses)
- klasses -= [Bundler::Thor, Bundler::Thor::Runner, Bundler::Thor::Group] unless show_internal
-
- raise Error, "No Bundler::Thor commands available" if klasses.empty?
- show_modules if with_modules && !thor_yaml.empty?
-
- list = Hash.new { |h, k| h[k] = [] }
- groups = klasses.select { |k| k.ancestors.include?(Bundler::Thor::Group) }
-
- # Get classes which inherit from Bundler::Thor
- (klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_commands(false) }
-
- # Get classes which inherit from Bundler::Thor::Base
- groups.map! { |k| k.printable_commands(false).first }
- list["root"] = groups
-
- # Order namespaces with default coming first
- list = list.sort { |a, b| a[0].sub(/^default/, "") <=> b[0].sub(/^default/, "") }
- list.each { |n, commands| display_commands(n, commands) unless commands.empty? }
- end
-
- def display_commands(namespace, list) #:nodoc:
- list.sort! { |a, b| a[0] <=> b[0] }
-
- say shell.set_color(namespace, :blue, true)
- say "-" * namespace.size
-
- print_table(list, :truncate => true)
- say
- end
- alias_method :display_tasks, :display_commands
-
- def show_modules #:nodoc:
- info = []
- labels = %w(Modules Namespaces)
-
- info << labels
- info << ["-" * labels[0].size, "-" * labels[1].size]
-
- thor_yaml.each do |name, hash|
- info << [name, hash[:namespaces].join(", ")]
- end
-
- print_table info
- say ""
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell.rb b/lib/bundler/vendor/thor/lib/thor/shell.rb
deleted file mode 100644
index e36fa472d6..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/shell.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-require "rbconfig"
-
-class Bundler::Thor
- module Base
- class << self
- attr_writer :shell
-
- # Returns the shell used in all Bundler::Thor classes. If you are in a Unix platform
- # it will use a colored log, otherwise it will use a basic one without color.
- #
- def shell
- @shell ||= if ENV["THOR_SHELL"] && !ENV["THOR_SHELL"].empty?
- Bundler::Thor::Shell.const_get(ENV["THOR_SHELL"])
- elsif RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ && !ENV["ANSICON"]
- Bundler::Thor::Shell::Basic
- else
- Bundler::Thor::Shell::Color
- end
- end
- end
- end
-
- module Shell
- SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
- attr_writer :shell
-
- autoload :Basic, File.expand_path("shell/basic", __dir__)
- autoload :Color, File.expand_path("shell/color", __dir__)
- autoload :HTML, File.expand_path("shell/html", __dir__)
-
- # Add shell to initialize config values.
- #
- # ==== Configuration
- # shell<Object>:: An instance of the shell to be used.
- #
- # ==== Examples
- #
- # class MyScript < Bundler::Thor
- # argument :first, :type => :numeric
- # end
- #
- # MyScript.new [1.0], { :foo => :bar }, :shell => Bundler::Thor::Shell::Basic.new
- #
- def initialize(args = [], options = {}, config = {})
- super
- self.shell = config[:shell]
- shell.base ||= self if shell.respond_to?(:base)
- end
-
- # Holds the shell for the given Bundler::Thor instance. If no shell is given,
- # it gets a default shell from Bundler::Thor::Base.shell.
- def shell
- @shell ||= Bundler::Thor::Base.shell.new
- end
-
- # Common methods that are delegated to the shell.
- SHELL_DELEGATED_METHODS.each do |method|
- module_eval <<-METHOD, __FILE__, __LINE__ + 1
- def #{method}(*args,&block)
- shell.#{method}(*args,&block)
- end
- METHOD
- end
-
- # Yields the given block with padding.
- def with_padding
- shell.padding += 1
- yield
- ensure
- shell.padding -= 1
- end
-
- protected
-
- # Allow shell to be shared between invocations.
- #
- def _shared_configuration #:nodoc:
- super.merge!(:shell => shell)
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
deleted file mode 100644
index be48358cb1..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
+++ /dev/null
@@ -1,491 +0,0 @@
-class Bundler::Thor
- module Shell
- class Basic
- DEFAULT_TERMINAL_WIDTH = 80
-
- attr_accessor :base
- attr_reader :padding
-
- # Initialize base, mute and padding to nil.
- #
- def initialize #:nodoc:
- @base = nil
- @mute = false
- @padding = 0
- @always_force = false
- end
-
- # Mute everything that's inside given block
- #
- def mute
- @mute = true
- yield
- ensure
- @mute = false
- end
-
- # Check if base is muted
- #
- def mute?
- @mute
- end
-
- # Sets the output padding, not allowing less than zero values.
- #
- def padding=(value)
- @padding = [0, value].max
- end
-
- # Sets the output padding while executing a block and resets it.
- #
- def indent(count = 1)
- orig_padding = padding
- self.padding = padding + count
- yield
- self.padding = orig_padding
- end
-
- # Asks something to the user and receives a response.
- #
- # If a default value is specified it will be presented to the user
- # and allows them to select that value with an empty response. This
- # option is ignored when limited answers are supplied.
- #
- # If asked to limit the correct responses, you can pass in an
- # array of acceptable answers. If one of those is not supplied,
- # they will be shown a message stating that one of those answers
- # must be given and re-asked the question.
- #
- # If asking for sensitive information, the :echo option can be set
- # to false to mask user input from $stdin.
- #
- # If the required input is a path, then set the path option to
- # true. This will enable tab completion for file paths relative
- # to the current working directory on systems that support
- # Readline.
- #
- # ==== Example
- # ask("What is your name?")
- #
- # ask("What is the planet furthest from the sun?", :default => "Pluto")
- #
- # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
- #
- # ask("What is your password?", :echo => false)
- #
- # ask("Where should the file be saved?", :path => true)
- #
- def ask(statement, *args)
- options = args.last.is_a?(Hash) ? args.pop : {}
- color = args.first
-
- if options[:limited_to]
- ask_filtered(statement, color, options)
- else
- ask_simply(statement, color, options)
- end
- end
-
- # Say (print) something to the user. If the sentence ends with a whitespace
- # or tab character, a new line is not appended (print + flush). Otherwise
- # are passed straight to puts (behavior got from Highline).
- #
- # ==== Example
- # say("I know you knew that.")
- #
- def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
- buffer = prepare_message(message, *color)
- buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
-
- stdout.print(buffer)
- stdout.flush
- end
-
- # Say a status with the given color and appends the message. Since this
- # method is used frequently by actions, it allows nil or false to be given
- # in log_status, avoiding the message from being shown. If a Symbol is
- # given in log_status, it's used as the color.
- #
- def say_status(status, message, log_status = true)
- return if quiet? || log_status == false
- spaces = " " * (padding + 1)
- color = log_status.is_a?(Symbol) ? log_status : :green
-
- status = status.to_s.rjust(12)
- status = set_color status, color, true if color
-
- buffer = "#{status}#{spaces}#{message}"
- buffer = "#{buffer}\n" unless buffer.end_with?("\n")
-
- stdout.print(buffer)
- stdout.flush
- end
-
- # Make a question the to user and returns true if the user replies "y" or
- # "yes".
- #
- def yes?(statement, color = nil)
- !!(ask(statement, color, :add_to_history => false) =~ is?(:yes))
- end
-
- # Make a question the to user and returns true if the user replies "n" or
- # "no".
- #
- def no?(statement, color = nil)
- !!(ask(statement, color, :add_to_history => false) =~ is?(:no))
- end
-
- # Prints values in columns
- #
- # ==== Parameters
- # Array[String, String, ...]
- #
- def print_in_columns(array)
- return if array.empty?
- colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
- array.each_with_index do |value, index|
- # Don't output trailing spaces when printing the last column
- if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
- stdout.puts value
- else
- stdout.printf("%-#{colwidth}s", value)
- end
- end
- end
-
- # Prints a table.
- #
- # ==== Parameters
- # Array[Array[String, String, ...]]
- #
- # ==== Options
- # indent<Integer>:: Indent the first column by indent value.
- # colwidth<Integer>:: Force the first column to colwidth spaces wide.
- #
- def print_table(array, options = {}) # rubocop:disable MethodLength
- return if array.empty?
-
- formats = []
- indent = options[:indent].to_i
- colwidth = options[:colwidth]
- options[:truncate] = terminal_width if options[:truncate] == true
-
- formats << "%-#{colwidth + 2}s".dup if colwidth
- start = colwidth ? 1 : 0
-
- colcount = array.max { |a, b| a.size <=> b.size }.size
-
- maximas = []
-
- start.upto(colcount - 1) do |index|
- maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
- maximas << maxima
- formats << if index == colcount - 1
- # Don't output 2 trailing spaces when printing the last column
- "%-s".dup
- else
- "%-#{maxima + 2}s".dup
- end
- end
-
- formats[0] = formats[0].insert(0, " " * indent)
- formats << "%s"
-
- array.each do |row|
- sentence = "".dup
-
- row.each_with_index do |column, index|
- maxima = maximas[index]
-
- f = if column.is_a?(Numeric)
- if index == row.size - 1
- # Don't output 2 trailing spaces when printing the last column
- "%#{maxima}s"
- else
- "%#{maxima}s "
- end
- else
- formats[index]
- end
- sentence << f % column.to_s
- end
-
- sentence = truncate(sentence, options[:truncate]) if options[:truncate]
- stdout.puts sentence
- end
- end
-
- # Prints a long string, word-wrapping the text to the current width of the
- # terminal display. Ideal for printing heredocs.
- #
- # ==== Parameters
- # String
- #
- # ==== Options
- # indent<Integer>:: Indent each line of the printed paragraph by indent value.
- #
- def print_wrapped(message, options = {})
- indent = options[:indent] || 0
- width = terminal_width - indent
- paras = message.split("\n\n")
-
- paras.map! do |unwrapped|
- counter = 0
- unwrapped.split(" ").inject do |memo, word|
- word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
- counter = 0 if word.include? "\n"
- if (counter + word.length + 1) < width
- memo = "#{memo} #{word}"
- counter += (word.length + 1)
- else
- memo = "#{memo}\n#{word}"
- counter = word.length
- end
- memo
- end
- end.compact!
-
- paras.each do |para|
- para.split("\n").each do |line|
- stdout.puts line.insert(0, " " * indent)
- end
- stdout.puts unless para == paras.last
- end
- end
-
- # Deals with file collision and returns true if the file should be
- # overwritten and false otherwise. If a block is given, it uses the block
- # response as the content for the diff.
- #
- # ==== Parameters
- # destination<String>:: the destination file to solve conflicts
- # block<Proc>:: an optional block that returns the value to be used in diff and merge
- #
- def file_collision(destination)
- return true if @always_force
- options = block_given? ? "[Ynaqdhm]" : "[Ynaqh]"
-
- loop do
- answer = ask(
- %[Overwrite #{destination}? (enter "h" for help) #{options}],
- :add_to_history => false
- )
-
- case answer
- when nil
- say ""
- return true
- when is?(:yes), is?(:force), ""
- return true
- when is?(:no), is?(:skip)
- return false
- when is?(:always)
- return @always_force = true
- when is?(:quit)
- say "Aborting..."
- raise SystemExit
- when is?(:diff)
- show_diff(destination, yield) if block_given?
- say "Retrying..."
- when is?(:merge)
- if block_given? && !merge_tool.empty?
- merge(destination, yield)
- return nil
- end
-
- say "Please specify merge tool to `THOR_MERGE` env."
- else
- say file_collision_help
- end
- end
- end
-
- # This code was copied from Rake, available under MIT-LICENSE
- # Copyright (c) 2003, 2004 Jim Weirich
- def terminal_width
- result = if ENV["THOR_COLUMNS"]
- ENV["THOR_COLUMNS"].to_i
- else
- unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
- end
- result < 10 ? DEFAULT_TERMINAL_WIDTH : result
- rescue
- DEFAULT_TERMINAL_WIDTH
- end
-
- # Called if something goes wrong during the execution. This is used by Bundler::Thor
- # internally and should not be used inside your scripts. If something went
- # wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
- # will be rescued and wrapped in the method below.
- #
- def error(statement)
- stderr.puts statement
- end
-
- # Apply color to the given string with optional bold. Disabled in the
- # Bundler::Thor::Shell::Basic class.
- #
- def set_color(string, *) #:nodoc:
- string
- end
-
- protected
-
- def prepare_message(message, *color)
- spaces = " " * padding
- spaces + set_color(message.to_s, *color)
- end
-
- def can_display_colors?
- false
- end
-
- def lookup_color(color)
- return color unless color.is_a?(Symbol)
- self.class.const_get(color.to_s.upcase)
- end
-
- def stdout
- $stdout
- end
-
- def stderr
- $stderr
- end
-
- def is?(value) #:nodoc:
- value = value.to_s
-
- if value.size == 1
- /\A#{value}\z/i
- else
- /\A(#{value}|#{value[0, 1]})\z/i
- end
- end
-
- def file_collision_help #:nodoc:
- <<-HELP
- Y - yes, overwrite
- n - no, do not overwrite
- a - all, overwrite this and all others
- q - quit, abort
- d - diff, show the differences between the old and the new
- h - help, show this help
- m - merge, run merge tool
- HELP
- end
-
- def show_diff(destination, content) #:nodoc:
- diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
-
- require "tempfile"
- Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
- temp.write content
- temp.rewind
- system %(#{diff_cmd} "#{destination}" "#{temp.path}")
- end
- end
-
- def quiet? #:nodoc:
- mute? || (base && base.options[:quiet])
- end
-
- # Calculate the dynamic width of the terminal
- def dynamic_width
- @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
- end
-
- def dynamic_width_stty
- `stty size 2>/dev/null`.split[1].to_i
- end
-
- def dynamic_width_tput
- `tput cols 2>/dev/null`.to_i
- end
-
- def unix?
- RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
- end
-
- def truncate(string, width)
- as_unicode do
- chars = string.chars.to_a
- if chars.length <= width
- chars.join
- else
- chars[0, width - 3].join + "..."
- end
- end
- end
-
- if "".respond_to?(:encode)
- def as_unicode
- yield
- end
- else
- def as_unicode
- old = $KCODE
- $KCODE = "U"
- yield
- ensure
- $KCODE = old
- end
- end
-
- def ask_simply(statement, color, options)
- default = options[:default]
- message = [statement, ("(#{default})" if default), nil].uniq.join(" ")
- message = prepare_message(message, *color)
- result = Bundler::Thor::LineEditor.readline(message, options)
-
- return unless result
-
- result = result.strip
-
- if default && result == ""
- default
- else
- result
- end
- end
-
- def ask_filtered(statement, color, options)
- answer_set = options[:limited_to]
- case_insensitive = options.fetch(:case_insensitive, false)
- correct_answer = nil
- until correct_answer
- answers = answer_set.join(", ")
- answer = ask_simply("#{statement} [#{answers}]", color, options)
- correct_answer = answer_match(answer_set, answer, case_insensitive)
- say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
- end
- correct_answer
- end
-
- def answer_match(possibilities, answer, case_insensitive)
- if case_insensitive
- possibilities.detect{ |possibility| possibility.downcase == answer.downcase }
- else
- possibilities.detect{ |possibility| possibility == answer }
- end
- end
-
- def merge(destination, content) #:nodoc:
- require "tempfile"
- Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
- temp.write content
- temp.rewind
- system %(#{merge_tool} "#{temp.path}" "#{destination}")
- end
- end
-
- def merge_tool #:nodoc:
- @merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
- end
-
- def git_merge_tool #:nodoc:
- `git config merge.tool`.rstrip rescue ""
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/color.rb b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
deleted file mode 100644
index 29f280202d..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/shell/color.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-require_relative "basic"
-
-class Bundler::Thor
- module Shell
- # Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check
- # Bundler::Thor::Shell::Basic to see all available methods.
- #
- class Color < Basic
- # Embed in a String to clear all previous ANSI sequences.
- CLEAR = "\e[0m"
- # The start of an ANSI bold sequence.
- BOLD = "\e[1m"
-
- # Set the terminal's foreground ANSI color to black.
- BLACK = "\e[30m"
- # Set the terminal's foreground ANSI color to red.
- RED = "\e[31m"
- # Set the terminal's foreground ANSI color to green.
- GREEN = "\e[32m"
- # Set the terminal's foreground ANSI color to yellow.
- YELLOW = "\e[33m"
- # Set the terminal's foreground ANSI color to blue.
- BLUE = "\e[34m"
- # Set the terminal's foreground ANSI color to magenta.
- MAGENTA = "\e[35m"
- # Set the terminal's foreground ANSI color to cyan.
- CYAN = "\e[36m"
- # Set the terminal's foreground ANSI color to white.
- WHITE = "\e[37m"
-
- # Set the terminal's background ANSI color to black.
- ON_BLACK = "\e[40m"
- # Set the terminal's background ANSI color to red.
- ON_RED = "\e[41m"
- # Set the terminal's background ANSI color to green.
- ON_GREEN = "\e[42m"
- # Set the terminal's background ANSI color to yellow.
- ON_YELLOW = "\e[43m"
- # Set the terminal's background ANSI color to blue.
- ON_BLUE = "\e[44m"
- # Set the terminal's background ANSI color to magenta.
- ON_MAGENTA = "\e[45m"
- # Set the terminal's background ANSI color to cyan.
- ON_CYAN = "\e[46m"
- # Set the terminal's background ANSI color to white.
- ON_WHITE = "\e[47m"
-
- # Set color by using a string or one of the defined constants. If a third
- # option is set to true, it also adds bold to the string. This is based
- # on Highline implementation and it automatically appends CLEAR to the end
- # of the returned String.
- #
- # Pass foreground, background and bold options to this method as
- # symbols.
- #
- # Example:
- #
- # set_color "Hi!", :red, :on_white, :bold
- #
- # The available colors are:
- #
- # :bold
- # :black
- # :red
- # :green
- # :yellow
- # :blue
- # :magenta
- # :cyan
- # :white
- # :on_black
- # :on_red
- # :on_green
- # :on_yellow
- # :on_blue
- # :on_magenta
- # :on_cyan
- # :on_white
- def set_color(string, *colors)
- if colors.compact.empty? || !can_display_colors?
- string
- elsif colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
- ansi_colors = colors.map { |color| lookup_color(color) }
- "#{ansi_colors.join}#{string}#{CLEAR}"
- else
- # The old API was `set_color(color, bold=boolean)`. We
- # continue to support the old API because you should never
- # break old APIs unnecessarily :P
- foreground, bold = colors
- foreground = self.class.const_get(foreground.to_s.upcase) if foreground.is_a?(Symbol)
-
- bold = bold ? BOLD : ""
- "#{bold}#{foreground}#{string}#{CLEAR}"
- end
- end
-
- protected
-
- def can_display_colors?
- stdout.tty? && !are_colors_disabled?
- end
-
- def are_colors_disabled?
- !ENV['NO_COLOR'].nil?
- end
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when "-"
- say "- #{diff.old_element.chomp}", :red, true
- when "+"
- say "+ #{diff.new_element.chomp}", :green, true
- when "!"
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require "diff/lcs"
- true
- rescue LoadError
- false
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/html.rb b/lib/bundler/vendor/thor/lib/thor/shell/html.rb
deleted file mode 100644
index 77a6d13a23..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/shell/html.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-require_relative "basic"
-
-class Bundler::Thor
- module Shell
- # Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check
- # Bundler::Thor::Shell::Basic to see all available methods.
- #
- class HTML < Basic
- # The start of an HTML bold sequence.
- BOLD = "font-weight: bold"
-
- # Set the terminal's foreground HTML color to black.
- BLACK = "color: black"
- # Set the terminal's foreground HTML color to red.
- RED = "color: red"
- # Set the terminal's foreground HTML color to green.
- GREEN = "color: green"
- # Set the terminal's foreground HTML color to yellow.
- YELLOW = "color: yellow"
- # Set the terminal's foreground HTML color to blue.
- BLUE = "color: blue"
- # Set the terminal's foreground HTML color to magenta.
- MAGENTA = "color: magenta"
- # Set the terminal's foreground HTML color to cyan.
- CYAN = "color: cyan"
- # Set the terminal's foreground HTML color to white.
- WHITE = "color: white"
-
- # Set the terminal's background HTML color to black.
- ON_BLACK = "background-color: black"
- # Set the terminal's background HTML color to red.
- ON_RED = "background-color: red"
- # Set the terminal's background HTML color to green.
- ON_GREEN = "background-color: green"
- # Set the terminal's background HTML color to yellow.
- ON_YELLOW = "background-color: yellow"
- # Set the terminal's background HTML color to blue.
- ON_BLUE = "background-color: blue"
- # Set the terminal's background HTML color to magenta.
- ON_MAGENTA = "background-color: magenta"
- # Set the terminal's background HTML color to cyan.
- ON_CYAN = "background-color: cyan"
- # Set the terminal's background HTML color to white.
- ON_WHITE = "background-color: white"
-
- # Set color by using a string or one of the defined constants. If a third
- # option is set to true, it also adds bold to the string. This is based
- # on Highline implementation and it automatically appends CLEAR to the end
- # of the returned String.
- #
- def set_color(string, *colors)
- if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
- html_colors = colors.map { |color| lookup_color(color) }
- "<span style=\"#{html_colors.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>"
- else
- color, bold = colors
- html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
- styles = [html_color]
- styles << BOLD if bold
- "<span style=\"#{styles.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>"
- end
- end
-
- # Ask something to the user and receives a response.
- #
- # ==== Example
- # ask("What is your name?")
- #
- # TODO: Implement #ask for Bundler::Thor::Shell::HTML
- def ask(statement, color = nil)
- raise NotImplementedError, "Implement #ask for Bundler::Thor::Shell::HTML"
- end
-
- protected
-
- def can_display_colors?
- true
- end
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when "-"
- say "- #{diff.old_element.chomp}", :red, true
- when "+"
- say "+ #{diff.new_element.chomp}", :green, true
- when "!"
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require "diff/lcs"
- true
- rescue LoadError
- false
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/util.rb b/lib/bundler/vendor/thor/lib/thor/util.rb
deleted file mode 100644
index ddf4d21b90..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/util.rb
+++ /dev/null
@@ -1,284 +0,0 @@
-require "rbconfig"
-
-class Bundler::Thor
- module Sandbox #:nodoc:
- end
-
- # This module holds several utilities:
- #
- # 1) Methods to convert thor namespaces to constants and vice-versa.
- #
- # Bundler::Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
- #
- # 2) Loading thor files and sandboxing:
- #
- # Bundler::Thor::Util.load_thorfile("~/.thor/foo")
- #
- module Util
- class << self
- # Receives a namespace and search for it in the Bundler::Thor::Base subclasses.
- #
- # ==== Parameters
- # namespace<String>:: The namespace to search for.
- #
- def find_by_namespace(namespace)
- namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
- Bundler::Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }
- end
-
- # Receives a constant and converts it to a Bundler::Thor namespace. Since Bundler::Thor
- # commands can be added to a sandbox, this method is also responsible for
- # removing the sandbox namespace.
- #
- # This method should not be used in general because it's used to deal with
- # older versions of Bundler::Thor. On current versions, if you need to get the
- # namespace from a class, just call namespace on it.
- #
- # ==== Parameters
- # constant<Object>:: The constant to be converted to the thor path.
- #
- # ==== Returns
- # String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
- #
- def namespace_from_thor_class(constant)
- constant = constant.to_s.gsub(/^Bundler::Thor::Sandbox::/, "")
- constant = snake_case(constant).squeeze(":")
- constant
- end
-
- # Given the contents, evaluate it inside the sandbox and returns the
- # namespaces defined in the sandbox.
- #
- # ==== Parameters
- # contents<String>
- #
- # ==== Returns
- # Array[Object]
- #
- def namespaces_in_content(contents, file = __FILE__)
- old_constants = Bundler::Thor::Base.subclasses.dup
- Bundler::Thor::Base.subclasses.clear
-
- load_thorfile(file, contents)
-
- new_constants = Bundler::Thor::Base.subclasses.dup
- Bundler::Thor::Base.subclasses.replace(old_constants)
-
- new_constants.map!(&:namespace)
- new_constants.compact!
- new_constants
- end
-
- # Returns the thor classes declared inside the given class.
- #
- def thor_classes_in(klass)
- stringfied_constants = klass.constants.map(&:to_s)
- Bundler::Thor::Base.subclasses.select do |subclass|
- next unless subclass.name
- stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ""))
- end
- end
-
- # Receives a string and convert it to snake case. SnakeCase returns snake_case.
- #
- # ==== Parameters
- # String
- #
- # ==== Returns
- # String
- #
- def snake_case(str)
- return str.downcase if str =~ /^[A-Z_]+$/
- str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
- $+.downcase
- end
-
- # Receives a string and convert it to camel case. camel_case returns CamelCase.
- #
- # ==== Parameters
- # String
- #
- # ==== Returns
- # String
- #
- def camel_case(str)
- return str if str !~ /_/ && str =~ /[A-Z]+.*/
- str.split("_").map(&:capitalize).join
- end
-
- # Receives a namespace and tries to retrieve a Bundler::Thor or Bundler::Thor::Group class
- # from it. It first searches for a class using the all the given namespace,
- # if it's not found, removes the highest entry and searches for the class
- # again. If found, returns the highest entry as the class name.
- #
- # ==== Examples
- #
- # class Foo::Bar < Bundler::Thor
- # def baz
- # end
- # end
- #
- # class Baz::Foo < Bundler::Thor::Group
- # end
- #
- # Bundler::Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command
- # Bundler::Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
- # Bundler::Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
- #
- # ==== Parameters
- # namespace<String>
- #
- def find_class_and_command_by_namespace(namespace, fallback = true)
- if namespace.include?(":") # look for a namespaced command
- pieces = namespace.split(":")
- command = pieces.pop
- klass = Bundler::Thor::Util.find_by_namespace(pieces.join(":"))
- end
- unless klass # look for a Bundler::Thor::Group with the right name
- klass = Bundler::Thor::Util.find_by_namespace(namespace)
- command = nil
- end
- if !klass && fallback # try a command in the default namespace
- command = namespace
- klass = Bundler::Thor::Util.find_by_namespace("")
- end
- [klass, command]
- end
- alias_method :find_class_and_task_by_namespace, :find_class_and_command_by_namespace
-
- # Receives a path and load the thor file in the path. The file is evaluated
- # inside the sandbox to avoid namespacing conflicts.
- #
- def load_thorfile(path, content = nil, debug = false)
- content ||= File.binread(path)
-
- begin
- Bundler::Thor::Sandbox.class_eval(content, path)
- rescue StandardError => e
- $stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
- if debug
- $stderr.puts(*e.backtrace)
- else
- $stderr.puts(e.backtrace.first)
- end
- end
- end
-
- def user_home
- @@user_home ||= if ENV["HOME"]
- ENV["HOME"]
- elsif ENV["USERPROFILE"]
- ENV["USERPROFILE"]
- elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
- File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
- elsif ENV["APPDATA"]
- ENV["APPDATA"]
- else
- begin
- File.expand_path("~")
- rescue
- if File::ALT_SEPARATOR
- "C:/"
- else
- "/"
- end
- end
- end
- end
-
- # Returns the root where thor files are located, depending on the OS.
- #
- def thor_root
- File.join(user_home, ".thor").tr('\\', "/")
- end
-
- # Returns the files in the thor root. On Windows thor_root will be something
- # like this:
- #
- # C:\Documents and Settings\james\.thor
- #
- # If we don't #gsub the \ character, Dir.glob will fail.
- #
- def thor_root_glob
- files = Dir["#{escape_globs(thor_root)}/*"]
-
- files.map! do |file|
- File.directory?(file) ? File.join(file, "main.thor") : file
- end
- end
-
- # Where to look for Bundler::Thor files.
- #
- def globs_for(path)
- path = escape_globs(path)
- ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
- end
-
- # Return the path to the ruby interpreter taking into account multiple
- # installations and windows extensions.
- #
- def ruby_command
- @ruby_command ||= begin
- ruby_name = RbConfig::CONFIG["ruby_install_name"]
- ruby = File.join(RbConfig::CONFIG["bindir"], ruby_name)
- ruby << RbConfig::CONFIG["EXEEXT"]
-
- # avoid using different name than ruby (on platforms supporting links)
- if ruby_name != "ruby" && File.respond_to?(:readlink)
- begin
- alternate_ruby = File.join(RbConfig::CONFIG["bindir"], "ruby")
- alternate_ruby << RbConfig::CONFIG["EXEEXT"]
-
- # ruby is a symlink
- if File.symlink? alternate_ruby
- linked_ruby = File.readlink alternate_ruby
-
- # symlink points to 'ruby_install_name'
- ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
- end
- rescue NotImplementedError # rubocop:disable HandleExceptions
- # just ignore on windows
- end
- end
-
- # escape string in case path to ruby executable contain spaces.
- ruby.sub!(/.*\s.*/m, '"\&"')
- ruby
- end
- end
-
- # Returns a string that has had any glob characters escaped.
- # The glob characters are `* ? { } [ ]`.
- #
- # ==== Examples
- #
- # Bundler::Thor::Util.escape_globs('[apps]') # => '\[apps\]'
- #
- # ==== Parameters
- # String
- #
- # ==== Returns
- # String
- #
- def escape_globs(path)
- path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
- end
-
- # Returns a string that has had any HTML characters escaped.
- #
- # ==== Examples
- #
- # Bundler::Thor::Util.escape_html('<div>') # => "&lt;div&gt;"
- #
- # ==== Parameters
- # String
- #
- # ==== Returns
- # String
- #
- def escape_html(string)
- CGI.escapeHTML(string)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/version.rb b/lib/bundler/vendor/thor/lib/thor/version.rb
deleted file mode 100644
index 7750d27637..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Bundler::Thor
- VERSION = "1.0.0"
-end
diff --git a/lib/bundler/vendor/uri/lib/uri.rb b/lib/bundler/vendor/uri/lib/uri.rb
deleted file mode 100644
index 00c01bd07b..0000000000
--- a/lib/bundler/vendor/uri/lib/uri.rb
+++ /dev/null
@@ -1,104 +0,0 @@
-# frozen_string_literal: false
-# Bundler::URI is a module providing classes to handle Uniform Resource Identifiers
-# (RFC2396[http://tools.ietf.org/html/rfc2396]).
-#
-# == Features
-#
-# * Uniform way of handling URIs.
-# * Flexibility to introduce custom Bundler::URI schemes.
-# * Flexibility to have an alternate Bundler::URI::Parser (or just different patterns
-# and regexp's).
-#
-# == Basic example
-#
-# require 'bundler/vendor/uri/lib/uri'
-#
-# uri = Bundler::URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
-# #=> #<Bundler::URI::HTTP http://foo.com/posts?id=30&limit=5#time=1305298413>
-#
-# uri.scheme #=> "http"
-# uri.host #=> "foo.com"
-# uri.path #=> "/posts"
-# uri.query #=> "id=30&limit=5"
-# uri.fragment #=> "time=1305298413"
-#
-# uri.to_s #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
-#
-# == Adding custom URIs
-#
-# module Bundler::URI
-# class RSYNC < Generic
-# DEFAULT_PORT = 873
-# end
-# @@schemes['RSYNC'] = RSYNC
-# end
-# #=> Bundler::URI::RSYNC
-#
-# Bundler::URI.scheme_list
-# #=> {"FILE"=>Bundler::URI::File, "FTP"=>Bundler::URI::FTP, "HTTP"=>Bundler::URI::HTTP,
-# # "HTTPS"=>Bundler::URI::HTTPS, "LDAP"=>Bundler::URI::LDAP, "LDAPS"=>Bundler::URI::LDAPS,
-# # "MAILTO"=>Bundler::URI::MailTo, "RSYNC"=>Bundler::URI::RSYNC}
-#
-# uri = Bundler::URI("rsync://rsync.foo.com")
-# #=> #<Bundler::URI::RSYNC rsync://rsync.foo.com>
-#
-# == RFC References
-#
-# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
-#
-# Here is a list of all related RFC's:
-# - RFC822[http://tools.ietf.org/html/rfc822]
-# - RFC1738[http://tools.ietf.org/html/rfc1738]
-# - RFC2255[http://tools.ietf.org/html/rfc2255]
-# - RFC2368[http://tools.ietf.org/html/rfc2368]
-# - RFC2373[http://tools.ietf.org/html/rfc2373]
-# - RFC2396[http://tools.ietf.org/html/rfc2396]
-# - RFC2732[http://tools.ietf.org/html/rfc2732]
-# - RFC3986[http://tools.ietf.org/html/rfc3986]
-#
-# == Class tree
-#
-# - Bundler::URI::Generic (in uri/generic.rb)
-# - Bundler::URI::File - (in uri/file.rb)
-# - Bundler::URI::FTP - (in uri/ftp.rb)
-# - Bundler::URI::HTTP - (in uri/http.rb)
-# - Bundler::URI::HTTPS - (in uri/https.rb)
-# - Bundler::URI::LDAP - (in uri/ldap.rb)
-# - Bundler::URI::LDAPS - (in uri/ldaps.rb)
-# - Bundler::URI::MailTo - (in uri/mailto.rb)
-# - Bundler::URI::Parser - (in uri/common.rb)
-# - Bundler::URI::REGEXP - (in uri/common.rb)
-# - Bundler::URI::REGEXP::PATTERN - (in uri/common.rb)
-# - Bundler::URI::Util - (in uri/common.rb)
-# - Bundler::URI::Escape - (in uri/common.rb)
-# - Bundler::URI::Error - (in uri/common.rb)
-# - Bundler::URI::InvalidURIError - (in uri/common.rb)
-# - Bundler::URI::InvalidComponentError - (in uri/common.rb)
-# - Bundler::URI::BadURIError - (in uri/common.rb)
-#
-# == Copyright Info
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# Documentation::
-# Akira Yamada <akira@ruby-lang.org>
-# Dmitry V. Sabanin <sdmitry@lrn.ru>
-# Vincent Batts <vbatts@hashbangbash.com>
-# License::
-# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
-# You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id$
-#
-
-module Bundler::URI
-end
-
-require_relative 'uri/version'
-require_relative 'uri/common'
-require_relative 'uri/generic'
-require_relative 'uri/file'
-require_relative 'uri/ftp'
-require_relative 'uri/http'
-require_relative 'uri/https'
-require_relative 'uri/ldap'
-require_relative 'uri/ldaps'
-require_relative 'uri/mailto'
diff --git a/lib/bundler/vendor/uri/lib/uri/common.rb b/lib/bundler/vendor/uri/lib/uri/common.rb
deleted file mode 100644
index cc1ab86c2f..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/common.rb
+++ /dev/null
@@ -1,744 +0,0 @@
-# frozen_string_literal: true
-#--
-# = uri/common.rb
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# Revision:: $Id$
-# License::
-# You can redistribute it and/or modify it under the same term as Ruby.
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative "rfc2396_parser"
-require_relative "rfc3986_parser"
-
-module Bundler::URI
- REGEXP = RFC2396_REGEXP
- Parser = RFC2396_Parser
- RFC3986_PARSER = RFC3986_Parser.new
-
- # Bundler::URI::Parser.new
- DEFAULT_PARSER = Parser.new
- DEFAULT_PARSER.pattern.each_pair do |sym, str|
- unless REGEXP::PATTERN.const_defined?(sym)
- REGEXP::PATTERN.const_set(sym, str)
- end
- end
- DEFAULT_PARSER.regexp.each_pair do |sym, str|
- const_set(sym, str)
- end
-
- module Util # :nodoc:
- def make_components_hash(klass, array_hash)
- tmp = {}
- if array_hash.kind_of?(Array) &&
- array_hash.size == klass.component.size - 1
- klass.component[1..-1].each_index do |i|
- begin
- tmp[klass.component[i + 1]] = array_hash[i].clone
- rescue TypeError
- tmp[klass.component[i + 1]] = array_hash[i]
- end
- end
-
- elsif array_hash.kind_of?(Hash)
- array_hash.each do |key, value|
- begin
- tmp[key] = value.clone
- rescue TypeError
- tmp[key] = value
- end
- end
- else
- raise ArgumentError,
- "expected Array of or Hash of components of #{klass} (#{klass.component[1..-1].join(', ')})"
- end
- tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase
-
- return tmp
- end
- module_function :make_components_hash
- end
-
- # Module for escaping unsafe characters with codes.
- module Escape
- #
- # == Synopsis
- #
- # Bundler::URI.escape(str [, unsafe])
- #
- # == Args
- #
- # +str+::
- # String to replaces in.
- # +unsafe+::
- # Regexp that matches all symbols that must be replaced with codes.
- # By default uses <tt>UNSAFE</tt>.
- # When this argument is a String, it represents a character set.
- #
- # == Description
- #
- # Escapes the string, replacing all unsafe characters with codes.
- #
- # This method is obsolete and should not be used. Instead, use
- # CGI.escape, Bundler::URI.encode_www_form or Bundler::URI.encode_www_form_component
- # depending on your specific use case.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
- # # => "http://example.com/?a=%09%0D"
- #
- # Bundler::URI.unescape(enc_uri)
- # # => "http://example.com/?a=\t\r"
- #
- # Bundler::URI.escape("@?@!", "!?")
- # # => "@%3F@%21"
- #
- def escape(*arg)
- warn "Bundler::URI.escape is obsolete", uplevel: 1
- DEFAULT_PARSER.escape(*arg)
- end
- alias encode escape
- #
- # == Synopsis
- #
- # Bundler::URI.unescape(str)
- #
- # == Args
- #
- # +str+::
- # String to unescape.
- #
- # == Description
- #
- # This method is obsolete and should not be used. Instead, use
- # CGI.unescape, Bundler::URI.decode_www_form or Bundler::URI.decode_www_form_component
- # depending on your specific use case.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
- # # => "http://example.com/?a=%09%0D"
- #
- # Bundler::URI.unescape(enc_uri)
- # # => "http://example.com/?a=\t\r"
- #
- def unescape(*arg)
- warn "Bundler::URI.unescape is obsolete", uplevel: 1
- DEFAULT_PARSER.unescape(*arg)
- end
- alias decode unescape
- end # module Escape
-
- extend Escape
- include REGEXP
-
- @@schemes = {}
- # Returns a Hash of the defined schemes.
- def self.scheme_list
- @@schemes
- end
-
- #
- # Base class for all Bundler::URI exceptions.
- #
- class Error < StandardError; end
- #
- # Not a Bundler::URI.
- #
- class InvalidURIError < Error; end
- #
- # Not a Bundler::URI component.
- #
- class InvalidComponentError < Error; end
- #
- # Bundler::URI is valid, bad usage is not.
- #
- class BadURIError < Error; end
-
- #
- # == Synopsis
- #
- # Bundler::URI::split(uri)
- #
- # == Args
- #
- # +uri+::
- # String with Bundler::URI.
- #
- # == Description
- #
- # Splits the string on following parts and returns array with result:
- #
- # * Scheme
- # * Userinfo
- # * Host
- # * Port
- # * Registry
- # * Path
- # * Opaque
- # * Query
- # * Fragment
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # Bundler::URI.split("http://www.ruby-lang.org/")
- # # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
- #
- def self.split(uri)
- RFC3986_PARSER.split(uri)
- end
-
- #
- # == Synopsis
- #
- # Bundler::URI::parse(uri_str)
- #
- # == Args
- #
- # +uri_str+::
- # String with Bundler::URI.
- #
- # == Description
- #
- # Creates one of the Bundler::URI's subclasses instance from the string.
- #
- # == Raises
- #
- # Bundler::URI::InvalidURIError::
- # Raised if Bundler::URI given is not a correct one.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://www.ruby-lang.org/")
- # # => #<Bundler::URI::HTTP http://www.ruby-lang.org/>
- # uri.scheme
- # # => "http"
- # uri.host
- # # => "www.ruby-lang.org"
- #
- # It's recommended to first ::escape the provided +uri_str+ if there are any
- # invalid Bundler::URI characters.
- #
- def self.parse(uri)
- RFC3986_PARSER.parse(uri)
- end
-
- #
- # == Synopsis
- #
- # Bundler::URI::join(str[, str, ...])
- #
- # == Args
- #
- # +str+::
- # String(s) to work with, will be converted to RFC3986 URIs before merging.
- #
- # == Description
- #
- # Joins URIs.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # Bundler::URI.join("http://example.com/","main.rbx")
- # # => #<Bundler::URI::HTTP http://example.com/main.rbx>
- #
- # Bundler::URI.join('http://example.com', 'foo')
- # # => #<Bundler::URI::HTTP http://example.com/foo>
- #
- # Bundler::URI.join('http://example.com', '/foo', '/bar')
- # # => #<Bundler::URI::HTTP http://example.com/bar>
- #
- # Bundler::URI.join('http://example.com', '/foo', 'bar')
- # # => #<Bundler::URI::HTTP http://example.com/bar>
- #
- # Bundler::URI.join('http://example.com', '/foo/', 'bar')
- # # => #<Bundler::URI::HTTP http://example.com/foo/bar>
- #
- def self.join(*str)
- RFC3986_PARSER.join(*str)
- end
-
- #
- # == Synopsis
- #
- # Bundler::URI::extract(str[, schemes][,&blk])
- #
- # == Args
- #
- # +str+::
- # String to extract URIs from.
- # +schemes+::
- # Limit Bundler::URI matching to specific schemes.
- #
- # == Description
- #
- # Extracts URIs from a string. If block given, iterates through all matched URIs.
- # Returns nil if block given or array with matches.
- #
- # == Usage
- #
- # require "bundler/vendor/uri/lib/uri"
- #
- # Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
- # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
- #
- def self.extract(str, schemes = nil, &block)
- warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
- DEFAULT_PARSER.extract(str, schemes, &block)
- end
-
- #
- # == Synopsis
- #
- # Bundler::URI::regexp([match_schemes])
- #
- # == Args
- #
- # +match_schemes+::
- # Array of schemes. If given, resulting regexp matches to URIs
- # whose scheme is one of the match_schemes.
- #
- # == Description
- #
- # Returns a Regexp object which matches to Bundler::URI-like strings.
- # The Regexp object returned by this method includes arbitrary
- # number of capture group (parentheses). Never rely on it's number.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # # extract first Bundler::URI from html_string
- # html_string.slice(Bundler::URI.regexp)
- #
- # # remove ftp URIs
- # html_string.sub(Bundler::URI.regexp(['ftp']), '')
- #
- # # You should not rely on the number of parentheses
- # html_string.scan(Bundler::URI.regexp) do |*matches|
- # p $&
- # end
- #
- def self.regexp(schemes = nil)
- warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
- DEFAULT_PARSER.make_regexp(schemes)
- end
-
- TBLENCWWWCOMP_ = {} # :nodoc:
- 256.times do |i|
- TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
- end
- TBLENCWWWCOMP_[' '] = '+'
- TBLENCWWWCOMP_.freeze
- TBLDECWWWCOMP_ = {} # :nodoc:
- 256.times do |i|
- h, l = i>>4, i&15
- TBLDECWWWCOMP_[-('%%%X%X' % [h, l])] = -i.chr
- TBLDECWWWCOMP_[-('%%%x%X' % [h, l])] = -i.chr
- TBLDECWWWCOMP_[-('%%%X%x' % [h, l])] = -i.chr
- TBLDECWWWCOMP_[-('%%%x%x' % [h, l])] = -i.chr
- end
- TBLDECWWWCOMP_['+'] = ' '
- TBLDECWWWCOMP_.freeze
-
- # Encodes given +str+ to URL-encoded form data.
- #
- # This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
- # (ASCII space) to + and converts others to %XX.
- #
- # If +enc+ is given, convert +str+ to the encoding before percent encoding.
- #
- # This is an implementation of
- # http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
- #
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
- def self.encode_www_form_component(str, enc=nil)
- str = str.to_s.dup
- if str.encoding != Encoding::ASCII_8BIT
- if enc && enc != Encoding::ASCII_8BIT
- str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
- str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
- end
- str.force_encoding(Encoding::ASCII_8BIT)
- end
- str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
- str.force_encoding(Encoding::US_ASCII)
- end
-
- # Decodes given +str+ of URL-encoded form data.
- #
- # This decodes + to SP.
- #
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
- def self.decode_www_form_component(str, enc=Encoding::UTF_8)
- raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
- str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
- end
-
- # Generates URL-encoded form data from given +enum+.
- #
- # This generates application/x-www-form-urlencoded data defined in HTML5
- # from given an Enumerable object.
- #
- # This internally uses Bundler::URI.encode_www_form_component(str).
- #
- # This method doesn't convert the encoding of given items, so convert them
- # before calling this method if you want to send data as other than original
- # encoding or mixed encoding data. (Strings which are encoded in an HTML5
- # ASCII incompatible encoding are converted to UTF-8.)
- #
- # This method doesn't handle files. When you send a file, use
- # multipart/form-data.
- #
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-serializer
- #
- # Bundler::URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
- # #=> "q=ruby&lang=en"
- # Bundler::URI.encode_www_form("q" => "ruby", "lang" => "en")
- # #=> "q=ruby&lang=en"
- # Bundler::URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
- # #=> "q=ruby&q=perl&lang=en"
- # Bundler::URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
- # #=> "q=ruby&q=perl&lang=en"
- #
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
- def self.encode_www_form(enum, enc=nil)
- enum.map do |k,v|
- if v.nil?
- encode_www_form_component(k, enc)
- elsif v.respond_to?(:to_ary)
- v.to_ary.map do |w|
- str = encode_www_form_component(k, enc)
- unless w.nil?
- str << '='
- str << encode_www_form_component(w, enc)
- end
- end.join('&')
- else
- str = encode_www_form_component(k, enc)
- str << '='
- str << encode_www_form_component(v, enc)
- end
- end.join('&')
- end
-
- # Decodes URL-encoded form data from given +str+.
- #
- # This decodes application/x-www-form-urlencoded data
- # and returns an array of key-value arrays.
- #
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-parser,
- # so this supports only &-separator, and doesn't support ;-separator.
- #
- # ary = Bundler::URI.decode_www_form("a=1&a=2&b=3")
- # ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
- # ary.assoc('a').last #=> '1'
- # ary.assoc('b').last #=> '3'
- # ary.rassoc('a').last #=> '2'
- # Hash[ary] #=> {"a"=>"2", "b"=>"3"}
- #
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
- def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
- raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
- ary = []
- return ary if str.empty?
- enc = Encoding.find(enc)
- str.b.each_line(separator) do |string|
- string.chomp!(separator)
- key, sep, val = string.partition('=')
- if isindex
- if sep.empty?
- val = key
- key = +''
- end
- isindex = false
- end
-
- if use__charset_ and key == '_charset_' and e = get_encoding(val)
- enc = e
- use__charset_ = false
- end
-
- key.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
- if val
- val.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
- else
- val = +''
- end
-
- ary << [key, val]
- end
- ary.each do |k, v|
- k.force_encoding(enc)
- k.scrub!
- v.force_encoding(enc)
- v.scrub!
- end
- ary
- end
-
- private
-=begin command for WEB_ENCODINGS_
- curl https://encoding.spec.whatwg.org/encodings.json|
- ruby -rjson -e 'H={}
- h={
- "shift_jis"=>"Windows-31J",
- "euc-jp"=>"cp51932",
- "iso-2022-jp"=>"cp50221",
- "x-mac-cyrillic"=>"macCyrillic",
- }
- JSON($<.read).map{|x|x["encodings"]}.flatten.each{|x|
- Encoding.find(n=h.fetch(n=x["name"].downcase,n))rescue next
- x["labels"].each{|y|H[y]=n}
- }
- puts "{"
- H.each{|k,v|puts %[ #{k.dump}=>#{v.dump},]}
- puts "}"
-'
-=end
- WEB_ENCODINGS_ = {
- "unicode-1-1-utf-8"=>"utf-8",
- "utf-8"=>"utf-8",
- "utf8"=>"utf-8",
- "866"=>"ibm866",
- "cp866"=>"ibm866",
- "csibm866"=>"ibm866",
- "ibm866"=>"ibm866",
- "csisolatin2"=>"iso-8859-2",
- "iso-8859-2"=>"iso-8859-2",
- "iso-ir-101"=>"iso-8859-2",
- "iso8859-2"=>"iso-8859-2",
- "iso88592"=>"iso-8859-2",
- "iso_8859-2"=>"iso-8859-2",
- "iso_8859-2:1987"=>"iso-8859-2",
- "l2"=>"iso-8859-2",
- "latin2"=>"iso-8859-2",
- "csisolatin3"=>"iso-8859-3",
- "iso-8859-3"=>"iso-8859-3",
- "iso-ir-109"=>"iso-8859-3",
- "iso8859-3"=>"iso-8859-3",
- "iso88593"=>"iso-8859-3",
- "iso_8859-3"=>"iso-8859-3",
- "iso_8859-3:1988"=>"iso-8859-3",
- "l3"=>"iso-8859-3",
- "latin3"=>"iso-8859-3",
- "csisolatin4"=>"iso-8859-4",
- "iso-8859-4"=>"iso-8859-4",
- "iso-ir-110"=>"iso-8859-4",
- "iso8859-4"=>"iso-8859-4",
- "iso88594"=>"iso-8859-4",
- "iso_8859-4"=>"iso-8859-4",
- "iso_8859-4:1988"=>"iso-8859-4",
- "l4"=>"iso-8859-4",
- "latin4"=>"iso-8859-4",
- "csisolatincyrillic"=>"iso-8859-5",
- "cyrillic"=>"iso-8859-5",
- "iso-8859-5"=>"iso-8859-5",
- "iso-ir-144"=>"iso-8859-5",
- "iso8859-5"=>"iso-8859-5",
- "iso88595"=>"iso-8859-5",
- "iso_8859-5"=>"iso-8859-5",
- "iso_8859-5:1988"=>"iso-8859-5",
- "arabic"=>"iso-8859-6",
- "asmo-708"=>"iso-8859-6",
- "csiso88596e"=>"iso-8859-6",
- "csiso88596i"=>"iso-8859-6",
- "csisolatinarabic"=>"iso-8859-6",
- "ecma-114"=>"iso-8859-6",
- "iso-8859-6"=>"iso-8859-6",
- "iso-8859-6-e"=>"iso-8859-6",
- "iso-8859-6-i"=>"iso-8859-6",
- "iso-ir-127"=>"iso-8859-6",
- "iso8859-6"=>"iso-8859-6",
- "iso88596"=>"iso-8859-6",
- "iso_8859-6"=>"iso-8859-6",
- "iso_8859-6:1987"=>"iso-8859-6",
- "csisolatingreek"=>"iso-8859-7",
- "ecma-118"=>"iso-8859-7",
- "elot_928"=>"iso-8859-7",
- "greek"=>"iso-8859-7",
- "greek8"=>"iso-8859-7",
- "iso-8859-7"=>"iso-8859-7",
- "iso-ir-126"=>"iso-8859-7",
- "iso8859-7"=>"iso-8859-7",
- "iso88597"=>"iso-8859-7",
- "iso_8859-7"=>"iso-8859-7",
- "iso_8859-7:1987"=>"iso-8859-7",
- "sun_eu_greek"=>"iso-8859-7",
- "csiso88598e"=>"iso-8859-8",
- "csisolatinhebrew"=>"iso-8859-8",
- "hebrew"=>"iso-8859-8",
- "iso-8859-8"=>"iso-8859-8",
- "iso-8859-8-e"=>"iso-8859-8",
- "iso-ir-138"=>"iso-8859-8",
- "iso8859-8"=>"iso-8859-8",
- "iso88598"=>"iso-8859-8",
- "iso_8859-8"=>"iso-8859-8",
- "iso_8859-8:1988"=>"iso-8859-8",
- "visual"=>"iso-8859-8",
- "csisolatin6"=>"iso-8859-10",
- "iso-8859-10"=>"iso-8859-10",
- "iso-ir-157"=>"iso-8859-10",
- "iso8859-10"=>"iso-8859-10",
- "iso885910"=>"iso-8859-10",
- "l6"=>"iso-8859-10",
- "latin6"=>"iso-8859-10",
- "iso-8859-13"=>"iso-8859-13",
- "iso8859-13"=>"iso-8859-13",
- "iso885913"=>"iso-8859-13",
- "iso-8859-14"=>"iso-8859-14",
- "iso8859-14"=>"iso-8859-14",
- "iso885914"=>"iso-8859-14",
- "csisolatin9"=>"iso-8859-15",
- "iso-8859-15"=>"iso-8859-15",
- "iso8859-15"=>"iso-8859-15",
- "iso885915"=>"iso-8859-15",
- "iso_8859-15"=>"iso-8859-15",
- "l9"=>"iso-8859-15",
- "iso-8859-16"=>"iso-8859-16",
- "cskoi8r"=>"koi8-r",
- "koi"=>"koi8-r",
- "koi8"=>"koi8-r",
- "koi8-r"=>"koi8-r",
- "koi8_r"=>"koi8-r",
- "koi8-ru"=>"koi8-u",
- "koi8-u"=>"koi8-u",
- "dos-874"=>"windows-874",
- "iso-8859-11"=>"windows-874",
- "iso8859-11"=>"windows-874",
- "iso885911"=>"windows-874",
- "tis-620"=>"windows-874",
- "windows-874"=>"windows-874",
- "cp1250"=>"windows-1250",
- "windows-1250"=>"windows-1250",
- "x-cp1250"=>"windows-1250",
- "cp1251"=>"windows-1251",
- "windows-1251"=>"windows-1251",
- "x-cp1251"=>"windows-1251",
- "ansi_x3.4-1968"=>"windows-1252",
- "ascii"=>"windows-1252",
- "cp1252"=>"windows-1252",
- "cp819"=>"windows-1252",
- "csisolatin1"=>"windows-1252",
- "ibm819"=>"windows-1252",
- "iso-8859-1"=>"windows-1252",
- "iso-ir-100"=>"windows-1252",
- "iso8859-1"=>"windows-1252",
- "iso88591"=>"windows-1252",
- "iso_8859-1"=>"windows-1252",
- "iso_8859-1:1987"=>"windows-1252",
- "l1"=>"windows-1252",
- "latin1"=>"windows-1252",
- "us-ascii"=>"windows-1252",
- "windows-1252"=>"windows-1252",
- "x-cp1252"=>"windows-1252",
- "cp1253"=>"windows-1253",
- "windows-1253"=>"windows-1253",
- "x-cp1253"=>"windows-1253",
- "cp1254"=>"windows-1254",
- "csisolatin5"=>"windows-1254",
- "iso-8859-9"=>"windows-1254",
- "iso-ir-148"=>"windows-1254",
- "iso8859-9"=>"windows-1254",
- "iso88599"=>"windows-1254",
- "iso_8859-9"=>"windows-1254",
- "iso_8859-9:1989"=>"windows-1254",
- "l5"=>"windows-1254",
- "latin5"=>"windows-1254",
- "windows-1254"=>"windows-1254",
- "x-cp1254"=>"windows-1254",
- "cp1255"=>"windows-1255",
- "windows-1255"=>"windows-1255",
- "x-cp1255"=>"windows-1255",
- "cp1256"=>"windows-1256",
- "windows-1256"=>"windows-1256",
- "x-cp1256"=>"windows-1256",
- "cp1257"=>"windows-1257",
- "windows-1257"=>"windows-1257",
- "x-cp1257"=>"windows-1257",
- "cp1258"=>"windows-1258",
- "windows-1258"=>"windows-1258",
- "x-cp1258"=>"windows-1258",
- "x-mac-cyrillic"=>"macCyrillic",
- "x-mac-ukrainian"=>"macCyrillic",
- "chinese"=>"gbk",
- "csgb2312"=>"gbk",
- "csiso58gb231280"=>"gbk",
- "gb2312"=>"gbk",
- "gb_2312"=>"gbk",
- "gb_2312-80"=>"gbk",
- "gbk"=>"gbk",
- "iso-ir-58"=>"gbk",
- "x-gbk"=>"gbk",
- "gb18030"=>"gb18030",
- "big5"=>"big5",
- "big5-hkscs"=>"big5",
- "cn-big5"=>"big5",
- "csbig5"=>"big5",
- "x-x-big5"=>"big5",
- "cseucpkdfmtjapanese"=>"cp51932",
- "euc-jp"=>"cp51932",
- "x-euc-jp"=>"cp51932",
- "csiso2022jp"=>"cp50221",
- "iso-2022-jp"=>"cp50221",
- "csshiftjis"=>"Windows-31J",
- "ms932"=>"Windows-31J",
- "ms_kanji"=>"Windows-31J",
- "shift-jis"=>"Windows-31J",
- "shift_jis"=>"Windows-31J",
- "sjis"=>"Windows-31J",
- "windows-31j"=>"Windows-31J",
- "x-sjis"=>"Windows-31J",
- "cseuckr"=>"euc-kr",
- "csksc56011987"=>"euc-kr",
- "euc-kr"=>"euc-kr",
- "iso-ir-149"=>"euc-kr",
- "korean"=>"euc-kr",
- "ks_c_5601-1987"=>"euc-kr",
- "ks_c_5601-1989"=>"euc-kr",
- "ksc5601"=>"euc-kr",
- "ksc_5601"=>"euc-kr",
- "windows-949"=>"euc-kr",
- "utf-16be"=>"utf-16be",
- "utf-16"=>"utf-16le",
- "utf-16le"=>"utf-16le",
- } # :nodoc:
-
- # :nodoc:
- # return encoding or nil
- # http://encoding.spec.whatwg.org/#concept-encoding-get
- def self.get_encoding(label)
- Encoding.find(WEB_ENCODINGS_[label.to_str.strip.downcase]) rescue nil
- end
-end # module Bundler::URI
-
-module Bundler
-
- #
- # Returns +uri+ converted to an Bundler::URI object.
- #
- def URI(uri)
- if uri.is_a?(Bundler::URI::Generic)
- uri
- elsif uri = String.try_convert(uri)
- Bundler::URI.parse(uri)
- else
- raise ArgumentError,
- "bad argument (expected Bundler::URI object or Bundler::URI string)"
- end
- end
- module_function :URI
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/file.rb b/lib/bundler/vendor/uri/lib/uri/file.rb
deleted file mode 100644
index df42f8bcdd..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/file.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'generic'
-
-module Bundler::URI
-
- #
- # The "file" Bundler::URI is defined by RFC8089.
- #
- class File < Generic
- # A Default port of nil for Bundler::URI::File.
- DEFAULT_PORT = nil
-
- #
- # An Array of the available components for Bundler::URI::File.
- #
- COMPONENT = [
- :scheme,
- :host,
- :path
- ].freeze
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::File object from components, with syntax checking.
- #
- # The components accepted are +host+ and +path+.
- #
- # The components should be provided either as an Array, or as a Hash
- # with keys formed by preceding the component names with a colon.
- #
- # If an Array is used, the components must be passed in the
- # order <code>[host, path]</code>.
- #
- # Examples:
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri1 = Bundler::URI::File.build(['host.example.com', '/path/file.zip'])
- # uri1.to_s # => "file://host.example.com/path/file.zip"
- #
- # uri2 = Bundler::URI::File.build({:host => 'host.example.com',
- # :path => '/ruby/src'})
- # uri2.to_s # => "file://host.example.com/ruby/src"
- #
- def self.build(args)
- tmp = Util::make_components_hash(self, args)
- super(tmp)
- end
-
- # Protected setter for the host component +v+.
- #
- # See also Bundler::URI::Generic.host=.
- #
- def set_host(v)
- v = "" if v.nil? || v == "localhost"
- @host = v
- end
-
- # do nothing
- def set_port(v)
- end
-
- # raise InvalidURIError
- def check_userinfo(user)
- raise Bundler::URI::InvalidURIError, "can not set userinfo for file Bundler::URI"
- end
-
- # raise InvalidURIError
- def check_user(user)
- raise Bundler::URI::InvalidURIError, "can not set user for file Bundler::URI"
- end
-
- # raise InvalidURIError
- def check_password(user)
- raise Bundler::URI::InvalidURIError, "can not set password for file Bundler::URI"
- end
-
- # do nothing
- def set_userinfo(v)
- end
-
- # do nothing
- def set_user(v)
- end
-
- # do nothing
- def set_password(v)
- end
- end
-
- @@schemes['FILE'] = File
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/ftp.rb b/lib/bundler/vendor/uri/lib/uri/ftp.rb
deleted file mode 100644
index ad39f57d7b..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/ftp.rb
+++ /dev/null
@@ -1,267 +0,0 @@
-# frozen_string_literal: false
-# = uri/ftp.rb
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id$
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative 'generic'
-
-module Bundler::URI
-
- #
- # FTP Bundler::URI syntax is defined by RFC1738 section 3.2.
- #
- # This class will be redesigned because of difference of implementations;
- # the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
- # is a good summary about the de facto spec.
- # http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
- #
- class FTP < Generic
- # A Default port of 21 for Bundler::URI::FTP.
- DEFAULT_PORT = 21
-
- #
- # An Array of the available components for Bundler::URI::FTP.
- #
- COMPONENT = [
- :scheme,
- :userinfo, :host, :port,
- :path, :typecode
- ].freeze
-
- #
- # Typecode is "a", "i", or "d".
- #
- # * "a" indicates a text file (the FTP command was ASCII)
- # * "i" indicates a binary file (FTP command IMAGE)
- # * "d" indicates the contents of a directory should be displayed
- #
- TYPECODE = ['a', 'i', 'd'].freeze
-
- # Typecode prefix ";type=".
- TYPECODE_PREFIX = ';type='.freeze
-
- def self.new2(user, password, host, port, path,
- typecode = nil, arg_check = true) # :nodoc:
- # Do not use this method! Not tested. [Bug #7301]
- # This methods remains just for compatibility,
- # Keep it undocumented until the active maintainer is assigned.
- typecode = nil if typecode.size == 0
- if typecode && !TYPECODE.include?(typecode)
- raise ArgumentError,
- "bad typecode is specified: #{typecode}"
- end
-
- # do escape
-
- self.new('ftp',
- [user, password],
- host, port, nil,
- typecode ? path + TYPECODE_PREFIX + typecode : path,
- nil, nil, nil, arg_check)
- end
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::FTP object from components, with syntax checking.
- #
- # The components accepted are +userinfo+, +host+, +port+, +path+, and
- # +typecode+.
- #
- # The components should be provided either as an Array, or as a Hash
- # with keys formed by preceding the component names with a colon.
- #
- # If an Array is used, the components must be passed in the
- # order <code>[userinfo, host, port, path, typecode]</code>.
- #
- # If the path supplied is absolute, it will be escaped in order to
- # make it absolute in the Bundler::URI.
- #
- # Examples:
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri1 = Bundler::URI::FTP.build(['user:password', 'ftp.example.com', nil,
- # '/path/file.zip', 'i'])
- # uri1.to_s # => "ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i"
- #
- # uri2 = Bundler::URI::FTP.build({:host => 'ftp.example.com',
- # :path => 'ruby/src'})
- # uri2.to_s # => "ftp://ftp.example.com/ruby/src"
- #
- def self.build(args)
-
- # Fix the incoming path to be generic URL syntax
- # FTP path -> URL path
- # foo/bar /foo/bar
- # /foo/bar /%2Ffoo/bar
- #
- if args.kind_of?(Array)
- args[3] = '/' + args[3].sub(/^\//, '%2F')
- else
- args[:path] = '/' + args[:path].sub(/^\//, '%2F')
- end
-
- tmp = Util::make_components_hash(self, args)
-
- if tmp[:typecode]
- if tmp[:typecode].size == 1
- tmp[:typecode] = TYPECODE_PREFIX + tmp[:typecode]
- end
- tmp[:path] << tmp[:typecode]
- end
-
- return super(tmp)
- end
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::FTP object from generic URL components with no
- # syntax checking.
- #
- # Unlike build(), this method does not escape the path component as
- # required by RFC1738; instead it is treated as per RFC2396.
- #
- # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
- # +opaque+, +query+, and +fragment+, in that order.
- #
- def initialize(scheme,
- userinfo, host, port, registry,
- path, opaque,
- query,
- fragment,
- parser = nil,
- arg_check = false)
- raise InvalidURIError unless path
- path = path.sub(/^\//,'')
- path.sub!(/^%2F/,'/')
- super(scheme, userinfo, host, port, registry, path, opaque,
- query, fragment, parser, arg_check)
- @typecode = nil
- if tmp = @path.index(TYPECODE_PREFIX)
- typecode = @path[tmp + TYPECODE_PREFIX.size..-1]
- @path = @path[0..tmp - 1]
-
- if arg_check
- self.typecode = typecode
- else
- self.set_typecode(typecode)
- end
- end
- end
-
- # typecode accessor.
- #
- # See Bundler::URI::FTP::COMPONENT.
- attr_reader :typecode
-
- # Validates typecode +v+,
- # returns +true+ or +false+.
- #
- def check_typecode(v)
- if TYPECODE.include?(v)
- return true
- else
- raise InvalidComponentError,
- "bad typecode(expected #{TYPECODE.join(', ')}): #{v}"
- end
- end
- private :check_typecode
-
- # Private setter for the typecode +v+.
- #
- # See also Bundler::URI::FTP.typecode=.
- #
- def set_typecode(v)
- @typecode = v
- end
- protected :set_typecode
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the typecode +v+
- # (with validation).
- #
- # See also Bundler::URI::FTP.check_typecode.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("ftp://john@ftp.example.com/my_file.img")
- # #=> #<Bundler::URI::FTP ftp://john@ftp.example.com/my_file.img>
- # uri.typecode = "i"
- # uri
- # #=> #<Bundler::URI::FTP ftp://john@ftp.example.com/my_file.img;type=i>
- #
- def typecode=(typecode)
- check_typecode(typecode)
- set_typecode(typecode)
- typecode
- end
-
- def merge(oth) # :nodoc:
- tmp = super(oth)
- if self != tmp
- tmp.set_typecode(oth.typecode)
- end
-
- return tmp
- end
-
- # Returns the path from an FTP Bundler::URI.
- #
- # RFC 1738 specifically states that the path for an FTP Bundler::URI does not
- # include the / which separates the Bundler::URI path from the Bundler::URI host. Example:
- #
- # <code>ftp://ftp.example.com/pub/ruby</code>
- #
- # The above Bundler::URI indicates that the client should connect to
- # ftp.example.com then cd to pub/ruby from the initial login directory.
- #
- # If you want to cd to an absolute directory, you must include an
- # escaped / (%2F) in the path. Example:
- #
- # <code>ftp://ftp.example.com/%2Fpub/ruby</code>
- #
- # This method will then return "/pub/ruby".
- #
- def path
- return @path.sub(/^\//,'').sub(/^%2F/,'/')
- end
-
- # Private setter for the path of the Bundler::URI::FTP.
- def set_path(v)
- super("/" + v.sub(/^\//, "%2F"))
- end
- protected :set_path
-
- # Returns a String representation of the Bundler::URI::FTP.
- def to_s
- save_path = nil
- if @typecode
- save_path = @path
- @path = @path + TYPECODE_PREFIX + @typecode
- end
- str = super
- if @typecode
- @path = save_path
- end
-
- return str
- end
- end
- @@schemes['FTP'] = FTP
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/generic.rb b/lib/bundler/vendor/uri/lib/uri/generic.rb
deleted file mode 100644
index 56b09e1d7f..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/generic.rb
+++ /dev/null
@@ -1,1568 +0,0 @@
-# frozen_string_literal: true
-
-# = uri/generic.rb
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id$
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative 'common'
-autoload :IPSocket, 'socket'
-autoload :IPAddr, 'ipaddr'
-
-module Bundler::URI
-
- #
- # Base class for all Bundler::URI classes.
- # Implements generic Bundler::URI syntax as per RFC 2396.
- #
- class Generic
- include Bundler::URI
-
- #
- # A Default port of nil for Bundler::URI::Generic.
- #
- DEFAULT_PORT = nil
-
- #
- # Returns default port.
- #
- def self.default_port
- self::DEFAULT_PORT
- end
-
- #
- # Returns default port.
- #
- def default_port
- self.class.default_port
- end
-
- #
- # An Array of the available components for Bundler::URI::Generic.
- #
- COMPONENT = [
- :scheme,
- :userinfo, :host, :port, :registry,
- :path, :opaque,
- :query,
- :fragment
- ].freeze
-
- #
- # Components of the Bundler::URI in the order.
- #
- def self.component
- self::COMPONENT
- end
-
- USE_REGISTRY = false # :nodoc:
-
- def self.use_registry # :nodoc:
- self::USE_REGISTRY
- end
-
- #
- # == Synopsis
- #
- # See ::new.
- #
- # == Description
- #
- # At first, tries to create a new Bundler::URI::Generic instance using
- # Bundler::URI::Generic::build. But, if exception Bundler::URI::InvalidComponentError is raised,
- # then it does Bundler::URI::Escape.escape all Bundler::URI components and tries again.
- #
- def self.build2(args)
- begin
- return self.build(args)
- rescue InvalidComponentError
- if args.kind_of?(Array)
- return self.build(args.collect{|x|
- if x.is_a?(String)
- DEFAULT_PARSER.escape(x)
- else
- x
- end
- })
- elsif args.kind_of?(Hash)
- tmp = {}
- args.each do |key, value|
- tmp[key] = if value
- DEFAULT_PARSER.escape(value)
- else
- value
- end
- end
- return self.build(tmp)
- end
- end
- end
-
- #
- # == Synopsis
- #
- # See ::new.
- #
- # == Description
- #
- # Creates a new Bundler::URI::Generic instance from components of Bundler::URI::Generic
- # with check. Components are: scheme, userinfo, host, port, registry, path,
- # opaque, query, and fragment. You can provide arguments either by an Array or a Hash.
- # See ::new for hash keys to use or for order of array items.
- #
- def self.build(args)
- if args.kind_of?(Array) &&
- args.size == ::Bundler::URI::Generic::COMPONENT.size
- tmp = args.dup
- elsif args.kind_of?(Hash)
- tmp = ::Bundler::URI::Generic::COMPONENT.collect do |c|
- if args.include?(c)
- args[c]
- else
- nil
- end
- end
- else
- component = self.class.component rescue ::Bundler::URI::Generic::COMPONENT
- raise ArgumentError,
- "expected Array of or Hash of components of #{self.class} (#{component.join(', ')})"
- end
-
- tmp << nil
- tmp << true
- return self.new(*tmp)
- end
-
- #
- # == Args
- #
- # +scheme+::
- # Protocol scheme, i.e. 'http','ftp','mailto' and so on.
- # +userinfo+::
- # User name and password, i.e. 'sdmitry:bla'.
- # +host+::
- # Server host name.
- # +port+::
- # Server port.
- # +registry+::
- # Registry of naming authorities.
- # +path+::
- # Path on server.
- # +opaque+::
- # Opaque part.
- # +query+::
- # Query data.
- # +fragment+::
- # Part of the Bundler::URI after '#' character.
- # +parser+::
- # Parser for internal use [Bundler::URI::DEFAULT_PARSER by default].
- # +arg_check+::
- # Check arguments [false by default].
- #
- # == Description
- #
- # Creates a new Bundler::URI::Generic instance from ``generic'' components without check.
- #
- def initialize(scheme,
- userinfo, host, port, registry,
- path, opaque,
- query,
- fragment,
- parser = DEFAULT_PARSER,
- arg_check = false)
- @scheme = nil
- @user = nil
- @password = nil
- @host = nil
- @port = nil
- @path = nil
- @query = nil
- @opaque = nil
- @fragment = nil
- @parser = parser == DEFAULT_PARSER ? nil : parser
-
- if arg_check
- self.scheme = scheme
- self.userinfo = userinfo
- self.hostname = host
- self.port = port
- self.path = path
- self.query = query
- self.opaque = opaque
- self.fragment = fragment
- else
- self.set_scheme(scheme)
- self.set_userinfo(userinfo)
- self.set_host(host)
- self.set_port(port)
- self.set_path(path)
- self.query = query
- self.set_opaque(opaque)
- self.fragment=(fragment)
- end
- if registry
- raise InvalidURIError,
- "the scheme #{@scheme} does not accept registry part: #{registry} (or bad hostname?)"
- end
-
- @scheme&.freeze
- self.set_path('') if !@path && !@opaque # (see RFC2396 Section 5.2)
- self.set_port(self.default_port) if self.default_port && !@port
- end
-
- #
- # Returns the scheme component of the Bundler::URI.
- #
- # Bundler::URI("http://foo/bar/baz").scheme #=> "http"
- #
- attr_reader :scheme
-
- # Returns the host component of the Bundler::URI.
- #
- # Bundler::URI("http://foo/bar/baz").host #=> "foo"
- #
- # It returns nil if no host component exists.
- #
- # Bundler::URI("mailto:foo@example.org").host #=> nil
- #
- # The component does not contain the port number.
- #
- # Bundler::URI("http://foo:8080/bar/baz").host #=> "foo"
- #
- # Since IPv6 addresses are wrapped with brackets in URIs,
- # this method returns IPv6 addresses wrapped with brackets.
- # This form is not appropriate to pass to socket methods such as TCPSocket.open.
- # If unwrapped host names are required, use the #hostname method.
- #
- # Bundler::URI("http://[::1]/bar/baz").host #=> "[::1]"
- # Bundler::URI("http://[::1]/bar/baz").hostname #=> "::1"
- #
- attr_reader :host
-
- # Returns the port component of the Bundler::URI.
- #
- # Bundler::URI("http://foo/bar/baz").port #=> 80
- # Bundler::URI("http://foo:8080/bar/baz").port #=> 8080
- #
- attr_reader :port
-
- def registry # :nodoc:
- nil
- end
-
- # Returns the path component of the Bundler::URI.
- #
- # Bundler::URI("http://foo/bar/baz").path #=> "/bar/baz"
- #
- attr_reader :path
-
- # Returns the query component of the Bundler::URI.
- #
- # Bundler::URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
- #
- attr_reader :query
-
- # Returns the opaque part of the Bundler::URI.
- #
- # Bundler::URI("mailto:foo@example.org").opaque #=> "foo@example.org"
- # Bundler::URI("http://foo/bar/baz").opaque #=> nil
- #
- # The portion of the path that does not make use of the slash '/'.
- # The path typically refers to an absolute path or an opaque part.
- # (See RFC2396 Section 3 and 5.2.)
- #
- attr_reader :opaque
-
- # Returns the fragment component of the Bundler::URI.
- #
- # Bundler::URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
- #
- attr_reader :fragment
-
- # Returns the parser to be used.
- #
- # Unless a Bundler::URI::Parser is defined, DEFAULT_PARSER is used.
- #
- def parser
- if !defined?(@parser) || !@parser
- DEFAULT_PARSER
- else
- @parser || DEFAULT_PARSER
- end
- end
-
- # Replaces self by other Bundler::URI object.
- #
- def replace!(oth)
- if self.class != oth.class
- raise ArgumentError, "expected #{self.class} object"
- end
-
- component.each do |c|
- self.__send__("#{c}=", oth.__send__(c))
- end
- end
- private :replace!
-
- #
- # Components of the Bundler::URI in the order.
- #
- def component
- self.class.component
- end
-
- #
- # Checks the scheme +v+ component against the Bundler::URI::Parser Regexp for :SCHEME.
- #
- def check_scheme(v)
- if v && parser.regexp[:SCHEME] !~ v
- raise InvalidComponentError,
- "bad component(expected scheme component): #{v}"
- end
-
- return true
- end
- private :check_scheme
-
- # Protected setter for the scheme component +v+.
- #
- # See also Bundler::URI::Generic.scheme=.
- #
- def set_scheme(v)
- @scheme = v&.downcase
- end
- protected :set_scheme
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the scheme component +v+
- # (with validation).
- #
- # See also Bundler::URI::Generic.check_scheme.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com")
- # uri.scheme = "https"
- # uri.to_s #=> "https://my.example.com"
- #
- def scheme=(v)
- check_scheme(v)
- set_scheme(v)
- v
- end
-
- #
- # Checks the +user+ and +password+.
- #
- # If +password+ is not provided, then +user+ is
- # split, using Bundler::URI::Generic.split_userinfo, to
- # pull +user+ and +password.
- #
- # See also Bundler::URI::Generic.check_user, Bundler::URI::Generic.check_password.
- #
- def check_userinfo(user, password = nil)
- if !password
- user, password = split_userinfo(user)
- end
- check_user(user)
- check_password(password, user)
-
- return true
- end
- private :check_userinfo
-
- #
- # Checks the user +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :USERINFO.
- #
- # Can not have a registry or opaque component defined,
- # with a user component defined.
- #
- def check_user(v)
- if @opaque
- raise InvalidURIError,
- "can not set user with opaque"
- end
-
- return v unless v
-
- if parser.regexp[:USERINFO] !~ v
- raise InvalidComponentError,
- "bad component(expected userinfo component or user component): #{v}"
- end
-
- return true
- end
- private :check_user
-
- #
- # Checks the password +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :USERINFO.
- #
- # Can not have a registry or opaque component defined,
- # with a user component defined.
- #
- def check_password(v, user = @user)
- if @opaque
- raise InvalidURIError,
- "can not set password with opaque"
- end
- return v unless v
-
- if !user
- raise InvalidURIError,
- "password component depends user component"
- end
-
- if parser.regexp[:USERINFO] !~ v
- raise InvalidComponentError,
- "bad password component"
- end
-
- return true
- end
- private :check_password
-
- #
- # Sets userinfo, argument is string like 'name:pass'.
- #
- def userinfo=(userinfo)
- if userinfo.nil?
- return nil
- end
- check_userinfo(*userinfo)
- set_userinfo(*userinfo)
- # returns userinfo
- end
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the +user+ component
- # (with validation).
- #
- # See also Bundler::URI::Generic.check_user.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://john:S3nsit1ve@my.example.com")
- # uri.user = "sam"
- # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
- #
- def user=(user)
- check_user(user)
- set_user(user)
- # returns user
- end
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the +password+ component
- # (with validation).
- #
- # See also Bundler::URI::Generic.check_password.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://john:S3nsit1ve@my.example.com")
- # uri.password = "V3ry_S3nsit1ve"
- # uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com"
- #
- def password=(password)
- check_password(password)
- set_password(password)
- # returns password
- end
-
- # Protected setter for the +user+ component, and +password+ if available
- # (with validation).
- #
- # See also Bundler::URI::Generic.userinfo=.
- #
- def set_userinfo(user, password = nil)
- unless password
- user, password = split_userinfo(user)
- end
- @user = user
- @password = password if password
-
- [@user, @password]
- end
- protected :set_userinfo
-
- # Protected setter for the user component +v+.
- #
- # See also Bundler::URI::Generic.user=.
- #
- def set_user(v)
- set_userinfo(v, @password)
- v
- end
- protected :set_user
-
- # Protected setter for the password component +v+.
- #
- # See also Bundler::URI::Generic.password=.
- #
- def set_password(v)
- @password = v
- # returns v
- end
- protected :set_password
-
- # Returns the userinfo +ui+ as <code>[user, password]</code>
- # if properly formatted as 'user:password'.
- def split_userinfo(ui)
- return nil, nil unless ui
- user, password = ui.split(':', 2)
-
- return user, password
- end
- private :split_userinfo
-
- # Escapes 'user:password' +v+ based on RFC 1738 section 3.1.
- def escape_userpass(v)
- parser.escape(v, /[@:\/]/o) # RFC 1738 section 3.1 #/
- end
- private :escape_userpass
-
- # Returns the userinfo, either as 'user' or 'user:password'.
- def userinfo
- if @user.nil?
- nil
- elsif @password.nil?
- @user
- else
- @user + ':' + @password
- end
- end
-
- # Returns the user component.
- def user
- @user
- end
-
- # Returns the password component.
- def password
- @password
- end
-
- #
- # Checks the host +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :HOST.
- #
- # Can not have a registry or opaque component defined,
- # with a host component defined.
- #
- def check_host(v)
- return v unless v
-
- if @opaque
- raise InvalidURIError,
- "can not set host with registry or opaque"
- elsif parser.regexp[:HOST] !~ v
- raise InvalidComponentError,
- "bad component(expected host component): #{v}"
- end
-
- return true
- end
- private :check_host
-
- # Protected setter for the host component +v+.
- #
- # See also Bundler::URI::Generic.host=.
- #
- def set_host(v)
- @host = v
- end
- protected :set_host
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the host component +v+
- # (with validation).
- #
- # See also Bundler::URI::Generic.check_host.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com")
- # uri.host = "foo.com"
- # uri.to_s #=> "http://foo.com"
- #
- def host=(v)
- check_host(v)
- set_host(v)
- v
- end
-
- # Extract the host part of the Bundler::URI and unwrap brackets for IPv6 addresses.
- #
- # This method is the same as Bundler::URI::Generic#host except
- # brackets for IPv6 (and future IP) addresses are removed.
- #
- # uri = Bundler::URI("http://[::1]/bar")
- # uri.hostname #=> "::1"
- # uri.host #=> "[::1]"
- #
- def hostname
- v = self.host
- /\A\[(.*)\]\z/ =~ v ? $1 : v
- end
-
- # Sets the host part of the Bundler::URI as the argument with brackets for IPv6 addresses.
- #
- # This method is the same as Bundler::URI::Generic#host= except
- # the argument can be a bare IPv6 address.
- #
- # uri = Bundler::URI("http://foo/bar")
- # uri.hostname = "::1"
- # uri.to_s #=> "http://[::1]/bar"
- #
- # If the argument seems to be an IPv6 address,
- # it is wrapped with brackets.
- #
- def hostname=(v)
- v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
- self.host = v
- end
-
- #
- # Checks the port +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :PORT.
- #
- # Can not have a registry or opaque component defined,
- # with a port component defined.
- #
- def check_port(v)
- return v unless v
-
- if @opaque
- raise InvalidURIError,
- "can not set port with registry or opaque"
- elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
- raise InvalidComponentError,
- "bad component(expected port component): #{v.inspect}"
- end
-
- return true
- end
- private :check_port
-
- # Protected setter for the port component +v+.
- #
- # See also Bundler::URI::Generic.port=.
- #
- def set_port(v)
- v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Integer)
- @port = v
- end
- protected :set_port
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the port component +v+
- # (with validation).
- #
- # See also Bundler::URI::Generic.check_port.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com")
- # uri.port = 8080
- # uri.to_s #=> "http://my.example.com:8080"
- #
- def port=(v)
- check_port(v)
- set_port(v)
- port
- end
-
- def check_registry(v) # :nodoc:
- raise InvalidURIError, "can not set registry"
- end
- private :check_registry
-
- def set_registry(v) #:nodoc:
- raise InvalidURIError, "can not set registry"
- end
- protected :set_registry
-
- def registry=(v)
- raise InvalidURIError, "can not set registry"
- end
-
- #
- # Checks the path +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp
- # for :ABS_PATH and :REL_PATH.
- #
- # Can not have a opaque component defined,
- # with a path component defined.
- #
- def check_path(v)
- # raise if both hier and opaque are not nil, because:
- # absoluteURI = scheme ":" ( hier_part | opaque_part )
- # hier_part = ( net_path | abs_path ) [ "?" query ]
- if v && @opaque
- raise InvalidURIError,
- "path conflicts with opaque"
- end
-
- # If scheme is ftp, path may be relative.
- # See RFC 1738 section 3.2.2, and RFC 2396.
- if @scheme && @scheme != "ftp"
- if v && v != '' && parser.regexp[:ABS_PATH] !~ v
- raise InvalidComponentError,
- "bad component(expected absolute path component): #{v}"
- end
- else
- if v && v != '' && parser.regexp[:ABS_PATH] !~ v &&
- parser.regexp[:REL_PATH] !~ v
- raise InvalidComponentError,
- "bad component(expected relative path component): #{v}"
- end
- end
-
- return true
- end
- private :check_path
-
- # Protected setter for the path component +v+.
- #
- # See also Bundler::URI::Generic.path=.
- #
- def set_path(v)
- @path = v
- end
- protected :set_path
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the path component +v+
- # (with validation).
- #
- # See also Bundler::URI::Generic.check_path.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com/pub/files")
- # uri.path = "/faq/"
- # uri.to_s #=> "http://my.example.com/faq/"
- #
- def path=(v)
- check_path(v)
- set_path(v)
- v
- end
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the query component +v+.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com/?id=25")
- # uri.query = "id=1"
- # uri.to_s #=> "http://my.example.com/?id=1"
- #
- def query=(v)
- return @query = nil unless v
- raise InvalidURIError, "query conflicts with opaque" if @opaque
-
- x = v.to_str
- v = x.dup if x.equal? v
- v.encode!(Encoding::UTF_8) rescue nil
- v.delete!("\t\r\n")
- v.force_encoding(Encoding::ASCII_8BIT)
- raise InvalidURIError, "invalid percent escape: #{$1}" if /(%\H\H)/n.match(v)
- v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X' % $&.ord}
- v.force_encoding(Encoding::US_ASCII)
- @query = v
- end
-
- #
- # Checks the opaque +v+ component for RFC2396 compliance and
- # against the Bundler::URI::Parser Regexp for :OPAQUE.
- #
- # Can not have a host, port, user, or path component defined,
- # with an opaque component defined.
- #
- def check_opaque(v)
- return v unless v
-
- # raise if both hier and opaque are not nil, because:
- # absoluteURI = scheme ":" ( hier_part | opaque_part )
- # hier_part = ( net_path | abs_path ) [ "?" query ]
- if @host || @port || @user || @path # userinfo = @user + ':' + @password
- raise InvalidURIError,
- "can not set opaque with host, port, userinfo or path"
- elsif v && parser.regexp[:OPAQUE] !~ v
- raise InvalidComponentError,
- "bad component(expected opaque component): #{v}"
- end
-
- return true
- end
- private :check_opaque
-
- # Protected setter for the opaque component +v+.
- #
- # See also Bundler::URI::Generic.opaque=.
- #
- def set_opaque(v)
- @opaque = v
- end
- protected :set_opaque
-
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the opaque component +v+
- # (with validation).
- #
- # See also Bundler::URI::Generic.check_opaque.
- #
- def opaque=(v)
- check_opaque(v)
- set_opaque(v)
- v
- end
-
- #
- # Checks the fragment +v+ component against the Bundler::URI::Parser Regexp for :FRAGMENT.
- #
- #
- # == Args
- #
- # +v+::
- # String
- #
- # == Description
- #
- # Public setter for the fragment component +v+
- # (with validation).
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com/?id=25#time=1305212049")
- # uri.fragment = "time=1305212086"
- # uri.to_s #=> "http://my.example.com/?id=25#time=1305212086"
- #
- def fragment=(v)
- return @fragment = nil unless v
-
- x = v.to_str
- v = x.dup if x.equal? v
- v.encode!(Encoding::UTF_8) rescue nil
- v.delete!("\t\r\n")
- v.force_encoding(Encoding::ASCII_8BIT)
- v.gsub!(/(?!%\h\h|[!-~])./n){'%%%02X' % $&.ord}
- v.force_encoding(Encoding::US_ASCII)
- @fragment = v
- end
-
- #
- # Returns true if Bundler::URI is hierarchical.
- #
- # == Description
- #
- # Bundler::URI has components listed in order of decreasing significance from left to right,
- # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com/")
- # uri.hierarchical?
- # #=> true
- # uri = Bundler::URI.parse("mailto:joe@example.com")
- # uri.hierarchical?
- # #=> false
- #
- def hierarchical?
- if @path
- true
- else
- false
- end
- end
-
- #
- # Returns true if Bundler::URI has a scheme (e.g. http:// or https://) specified.
- #
- def absolute?
- if @scheme
- true
- else
- false
- end
- end
- alias absolute absolute?
-
- #
- # Returns true if Bundler::URI does not have a scheme (e.g. http:// or https://) specified.
- #
- def relative?
- !absolute?
- end
-
- #
- # Returns an Array of the path split on '/'.
- #
- def split_path(path)
- path.split("/", -1)
- end
- private :split_path
-
- #
- # Merges a base path +base+, with relative path +rel+,
- # returns a modified base path.
- #
- def merge_path(base, rel)
-
- # RFC2396, Section 5.2, 5)
- # RFC2396, Section 5.2, 6)
- base_path = split_path(base)
- rel_path = split_path(rel)
-
- # RFC2396, Section 5.2, 6), a)
- base_path << '' if base_path.last == '..'
- while i = base_path.index('..')
- base_path.slice!(i - 1, 2)
- end
-
- if (first = rel_path.first) and first.empty?
- base_path.clear
- rel_path.shift
- end
-
- # RFC2396, Section 5.2, 6), c)
- # RFC2396, Section 5.2, 6), d)
- rel_path.push('') if rel_path.last == '.' || rel_path.last == '..'
- rel_path.delete('.')
-
- # RFC2396, Section 5.2, 6), e)
- tmp = []
- rel_path.each do |x|
- if x == '..' &&
- !(tmp.empty? || tmp.last == '..')
- tmp.pop
- else
- tmp << x
- end
- end
-
- add_trailer_slash = !tmp.empty?
- if base_path.empty?
- base_path = [''] # keep '/' for root directory
- elsif add_trailer_slash
- base_path.pop
- end
- while x = tmp.shift
- if x == '..'
- # RFC2396, Section 4
- # a .. or . in an absolute path has no special meaning
- base_path.pop if base_path.size > 1
- else
- # if x == '..'
- # valid absolute (but abnormal) path "/../..."
- # else
- # valid absolute path
- # end
- base_path << x
- tmp.each {|t| base_path << t}
- add_trailer_slash = false
- break
- end
- end
- base_path.push('') if add_trailer_slash
-
- return base_path.join('/')
- end
- private :merge_path
-
- #
- # == Args
- #
- # +oth+::
- # Bundler::URI or String
- #
- # == Description
- #
- # Destructive form of #merge.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com")
- # uri.merge!("/main.rbx?page=1")
- # uri.to_s # => "http://my.example.com/main.rbx?page=1"
- #
- def merge!(oth)
- t = merge(oth)
- if self == t
- nil
- else
- replace!(t)
- self
- end
- end
-
- #
- # == Args
- #
- # +oth+::
- # Bundler::URI or String
- #
- # == Description
- #
- # Merges two URIs.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com")
- # uri.merge("/main.rbx?page=1")
- # # => "http://my.example.com/main.rbx?page=1"
- #
- def merge(oth)
- rel = parser.send(:convert_to_uri, oth)
-
- if rel.absolute?
- #raise BadURIError, "both Bundler::URI are absolute" if absolute?
- # hmm... should return oth for usability?
- return rel
- end
-
- unless self.absolute?
- raise BadURIError, "both Bundler::URI are relative"
- end
-
- base = self.dup
-
- authority = rel.userinfo || rel.host || rel.port
-
- # RFC2396, Section 5.2, 2)
- if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
- base.fragment=(rel.fragment) if rel.fragment
- return base
- end
-
- base.query = nil
- base.fragment=(nil)
-
- # RFC2396, Section 5.2, 4)
- if !authority
- base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
- else
- # RFC2396, Section 5.2, 4)
- base.set_path(rel.path) if rel.path
- end
-
- # RFC2396, Section 5.2, 7)
- base.set_userinfo(rel.userinfo) if rel.userinfo
- base.set_host(rel.host) if rel.host
- base.set_port(rel.port) if rel.port
- base.query = rel.query if rel.query
- base.fragment=(rel.fragment) if rel.fragment
-
- return base
- end # merge
- alias + merge
-
- # :stopdoc:
- def route_from_path(src, dst)
- case dst
- when src
- # RFC2396, Section 4.2
- return ''
- when %r{(?:\A|/)\.\.?(?:/|\z)}
- # dst has abnormal absolute path,
- # like "/./", "/../", "/x/../", ...
- return dst.dup
- end
-
- src_path = src.scan(%r{[^/]*/})
- dst_path = dst.scan(%r{[^/]*/?})
-
- # discard same parts
- while !dst_path.empty? && dst_path.first == src_path.first
- src_path.shift
- dst_path.shift
- end
-
- tmp = dst_path.join
-
- # calculate
- if src_path.empty?
- if tmp.empty?
- return './'
- elsif dst_path.first.include?(':') # (see RFC2396 Section 5)
- return './' + tmp
- else
- return tmp
- end
- end
-
- return '../' * src_path.size + tmp
- end
- private :route_from_path
- # :startdoc:
-
- # :stopdoc:
- def route_from0(oth)
- oth = parser.send(:convert_to_uri, oth)
- if self.relative?
- raise BadURIError,
- "relative Bundler::URI: #{self}"
- end
- if oth.relative?
- raise BadURIError,
- "relative Bundler::URI: #{oth}"
- end
-
- if self.scheme != oth.scheme
- return self, self.dup
- end
- rel = Bundler::URI::Generic.new(nil, # it is relative Bundler::URI
- self.userinfo, self.host, self.port,
- nil, self.path, self.opaque,
- self.query, self.fragment, parser)
-
- if rel.userinfo != oth.userinfo ||
- rel.host.to_s.downcase != oth.host.to_s.downcase ||
- rel.port != oth.port
-
- if self.userinfo.nil? && self.host.nil?
- return self, self.dup
- end
-
- rel.set_port(nil) if rel.port == oth.default_port
- return rel, rel
- end
- rel.set_userinfo(nil)
- rel.set_host(nil)
- rel.set_port(nil)
-
- if rel.path && rel.path == oth.path
- rel.set_path('')
- rel.query = nil if rel.query == oth.query
- return rel, rel
- elsif rel.opaque && rel.opaque == oth.opaque
- rel.set_opaque('')
- rel.query = nil if rel.query == oth.query
- return rel, rel
- end
-
- # you can modify `rel', but can not `oth'.
- return oth, rel
- end
- private :route_from0
- # :startdoc:
-
- #
- # == Args
- #
- # +oth+::
- # Bundler::URI or String
- #
- # == Description
- #
- # Calculates relative path from oth to self.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse('http://my.example.com/main.rbx?page=1')
- # uri.route_from('http://my.example.com')
- # #=> #<Bundler::URI::Generic /main.rbx?page=1>
- #
- def route_from(oth)
- # you can modify `rel', but can not `oth'.
- begin
- oth, rel = route_from0(oth)
- rescue
- raise $!.class, $!.message
- end
- if oth == rel
- return rel
- end
-
- rel.set_path(route_from_path(oth.path, self.path))
- if rel.path == './' && self.query
- # "./?foo" -> "?foo"
- rel.set_path('')
- end
-
- return rel
- end
-
- alias - route_from
-
- #
- # == Args
- #
- # +oth+::
- # Bundler::URI or String
- #
- # == Description
- #
- # Calculates relative path to oth from self.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse('http://my.example.com')
- # uri.route_to('http://my.example.com/main.rbx?page=1')
- # #=> #<Bundler::URI::Generic /main.rbx?page=1>
- #
- def route_to(oth)
- parser.send(:convert_to_uri, oth).route_from(self)
- end
-
- #
- # Returns normalized Bundler::URI.
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # Bundler::URI("HTTP://my.EXAMPLE.com").normalize
- # #=> #<Bundler::URI::HTTP http://my.example.com/>
- #
- # Normalization here means:
- #
- # * scheme and host are converted to lowercase,
- # * an empty path component is set to "/".
- #
- def normalize
- uri = dup
- uri.normalize!
- uri
- end
-
- #
- # Destructive version of #normalize.
- #
- def normalize!
- if path&.empty?
- set_path('/')
- end
- if scheme && scheme != scheme.downcase
- set_scheme(self.scheme.downcase)
- end
- if host && host != host.downcase
- set_host(self.host.downcase)
- end
- end
-
- #
- # Constructs String from Bundler::URI.
- #
- def to_s
- str = ''.dup
- if @scheme
- str << @scheme
- str << ':'
- end
-
- if @opaque
- str << @opaque
- else
- if @host || %w[file postgres].include?(@scheme)
- str << '//'
- end
- if self.userinfo
- str << self.userinfo
- str << '@'
- end
- if @host
- str << @host
- end
- if @port && @port != self.default_port
- str << ':'
- str << @port.to_s
- end
- str << @path
- if @query
- str << '?'
- str << @query
- end
- end
- if @fragment
- str << '#'
- str << @fragment
- end
- str
- end
-
- #
- # Compares two URIs.
- #
- def ==(oth)
- if self.class == oth.class
- self.normalize.component_ary == oth.normalize.component_ary
- else
- false
- end
- end
-
- def hash
- self.component_ary.hash
- end
-
- def eql?(oth)
- self.class == oth.class &&
- parser == oth.parser &&
- self.component_ary.eql?(oth.component_ary)
- end
-
-=begin
-
---- Bundler::URI::Generic#===(oth)
-
-=end
-# def ===(oth)
-# raise NotImplementedError
-# end
-
-=begin
-=end
-
-
- # Returns an Array of the components defined from the COMPONENT Array.
- def component_ary
- component.collect do |x|
- self.send(x)
- end
- end
- protected :component_ary
-
- # == Args
- #
- # +components+::
- # Multiple Symbol arguments defined in Bundler::URI::HTTP.
- #
- # == Description
- #
- # Selects specified components from Bundler::URI.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse('http://myuser:mypass@my.example.com/test.rbx')
- # uri.select(:userinfo, :host, :path)
- # # => ["myuser:mypass", "my.example.com", "/test.rbx"]
- #
- def select(*components)
- components.collect do |c|
- if component.include?(c)
- self.send(c)
- else
- raise ArgumentError,
- "expected of components of #{self.class} (#{self.class.component.join(', ')})"
- end
- end
- end
-
- def inspect
- "#<#{self.class} #{self}>"
- end
-
- #
- # == Args
- #
- # +v+::
- # Bundler::URI or String
- #
- # == Description
- #
- # Attempts to parse other Bundler::URI +oth+,
- # returns [parsed_oth, self].
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://my.example.com")
- # uri.coerce("http://foo.com")
- # #=> [#<Bundler::URI::HTTP http://foo.com>, #<Bundler::URI::HTTP http://my.example.com>]
- #
- def coerce(oth)
- case oth
- when String
- oth = parser.parse(oth)
- else
- super
- end
-
- return oth, self
- end
-
- # Returns a proxy Bundler::URI.
- # The proxy Bundler::URI is obtained from environment variables such as http_proxy,
- # ftp_proxy, no_proxy, etc.
- # If there is no proper proxy, nil is returned.
- #
- # If the optional parameter +env+ is specified, it is used instead of ENV.
- #
- # Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
- # are examined, too.
- #
- # But http_proxy and HTTP_PROXY is treated specially under CGI environment.
- # It's because HTTP_PROXY may be set by Proxy: header.
- # So HTTP_PROXY is not used.
- # http_proxy is not used too if the variable is case insensitive.
- # CGI_HTTP_PROXY can be used instead.
- def find_proxy(env=ENV)
- raise BadURIError, "relative Bundler::URI: #{self}" if self.relative?
- name = self.scheme.downcase + '_proxy'
- proxy_uri = nil
- if name == 'http_proxy' && env.include?('REQUEST_METHOD') # CGI?
- # HTTP_PROXY conflicts with *_proxy for proxy settings and
- # HTTP_* for header information in CGI.
- # So it should be careful to use it.
- pairs = env.reject {|k, v| /\Ahttp_proxy\z/i !~ k }
- case pairs.length
- when 0 # no proxy setting anyway.
- proxy_uri = nil
- when 1
- k, _ = pairs.shift
- if k == 'http_proxy' && env[k.upcase] == nil
- # http_proxy is safe to use because ENV is case sensitive.
- proxy_uri = env[name]
- else
- proxy_uri = nil
- end
- else # http_proxy is safe to use because ENV is case sensitive.
- proxy_uri = env.to_hash[name]
- end
- if !proxy_uri
- # Use CGI_HTTP_PROXY. cf. libwww-perl.
- proxy_uri = env["CGI_#{name.upcase}"]
- end
- elsif name == 'http_proxy'
- unless proxy_uri = env[name]
- if proxy_uri = env[name.upcase]
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
- end
- end
- else
- proxy_uri = env[name] || env[name.upcase]
- end
-
- if proxy_uri.nil? || proxy_uri.empty?
- return nil
- end
-
- if self.hostname
- begin
- addr = IPSocket.getaddress(self.hostname)
- return nil if /\A127\.|\A::1\z/ =~ addr
- rescue SocketError
- end
- end
-
- name = 'no_proxy'
- if no_proxy = env[name] || env[name.upcase]
- return nil unless Bundler::URI::Generic.use_proxy?(self.hostname, addr, self.port, no_proxy)
- end
- Bundler::URI.parse(proxy_uri)
- end
-
- def self.use_proxy?(hostname, addr, port, no_proxy) # :nodoc:
- hostname = hostname.downcase
- dothostname = ".#{hostname}"
- no_proxy.scan(/([^:,\s]+)(?::(\d+))?/) {|p_host, p_port|
- if !p_port || port == p_port.to_i
- if p_host.start_with?('.')
- return false if hostname.end_with?(p_host.downcase)
- else
- return false if dothostname.end_with?(".#{p_host.downcase}")
- end
- if addr
- begin
- return false if IPAddr.new(p_host).include?(addr)
- rescue IPAddr::InvalidAddressError
- next
- end
- end
- end
- }
- true
- end
- end
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/http.rb b/lib/bundler/vendor/uri/lib/uri/http.rb
deleted file mode 100644
index b6ca1c51de..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/http.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# frozen_string_literal: false
-# = uri/http.rb
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id$
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative 'generic'
-
-module Bundler::URI
-
- #
- # The syntax of HTTP URIs is defined in RFC1738 section 3.3.
- #
- # Note that the Ruby Bundler::URI library allows HTTP URLs containing usernames and
- # passwords. This is not legal as per the RFC, but used to be
- # supported in Internet Explorer 5 and 6, before the MS04-004 security
- # update. See <URL:http://support.microsoft.com/kb/834489>.
- #
- class HTTP < Generic
- # A Default port of 80 for Bundler::URI::HTTP.
- DEFAULT_PORT = 80
-
- # An Array of the available components for Bundler::URI::HTTP.
- COMPONENT = %i[
- scheme
- userinfo host port
- path
- query
- fragment
- ].freeze
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::HTTP object from components, with syntax checking.
- #
- # The components accepted are userinfo, host, port, path, query, and
- # fragment.
- #
- # The components should be provided either as an Array, or as a Hash
- # with keys formed by preceding the component names with a colon.
- #
- # If an Array is used, the components must be passed in the
- # order <code>[userinfo, host, port, path, query, fragment]</code>.
- #
- # Example:
- #
- # uri = Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
- #
- # uri = Bundler::URI::HTTP.build([nil, "www.example.com", nil, "/path",
- # "query", 'fragment'])
- #
- # Currently, if passed userinfo components this method generates
- # invalid HTTP URIs as per RFC 1738.
- #
- def self.build(args)
- tmp = Util.make_components_hash(self, args)
- super(tmp)
- end
-
- #
- # == Description
- #
- # Returns the full path for an HTTP request, as required by Net::HTTP::Get.
- #
- # If the Bundler::URI contains a query, the full path is Bundler::URI#path + '?' + Bundler::URI#query.
- # Otherwise, the path is simply Bundler::URI#path.
- #
- # Example:
- #
- # uri = Bundler::URI::HTTP.build(path: '/foo/bar', query: 'test=true')
- # uri.request_uri # => "/foo/bar?test=true"
- #
- def request_uri
- return unless @path
-
- url = @query ? "#@path?#@query" : @path.dup
- url.start_with?(?/.freeze) ? url : ?/ + url
- end
- end
-
- @@schemes['HTTP'] = HTTP
-
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/https.rb b/lib/bundler/vendor/uri/lib/uri/https.rb
deleted file mode 100644
index 78dc6bf532..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/https.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: false
-# = uri/https.rb
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id$
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative 'http'
-
-module Bundler::URI
-
- # The default port for HTTPS URIs is 443, and the scheme is 'https:' rather
- # than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
- # see Bundler::URI::HTTP.
- class HTTPS < HTTP
- # A Default port of 443 for Bundler::URI::HTTPS
- DEFAULT_PORT = 443
- end
- @@schemes['HTTPS'] = HTTPS
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/ldap.rb b/lib/bundler/vendor/uri/lib/uri/ldap.rb
deleted file mode 100644
index b707bedb97..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/ldap.rb
+++ /dev/null
@@ -1,261 +0,0 @@
-# frozen_string_literal: false
-# = uri/ldap.rb
-#
-# Author::
-# Takaaki Tateishi <ttate@jaist.ac.jp>
-# Akira Yamada <akira@ruby-lang.org>
-# License::
-# Bundler::URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
-# You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id$
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative 'generic'
-
-module Bundler::URI
-
- #
- # LDAP Bundler::URI SCHEMA (described in RFC2255).
- #--
- # ldap://<host>/<dn>[?<attrs>[?<scope>[?<filter>[?<extensions>]]]]
- #++
- class LDAP < Generic
-
- # A Default port of 389 for Bundler::URI::LDAP.
- DEFAULT_PORT = 389
-
- # An Array of the available components for Bundler::URI::LDAP.
- COMPONENT = [
- :scheme,
- :host, :port,
- :dn,
- :attributes,
- :scope,
- :filter,
- :extensions,
- ].freeze
-
- # Scopes available for the starting point.
- #
- # * SCOPE_BASE - the Base DN
- # * SCOPE_ONE - one level under the Base DN, not including the base DN and
- # not including any entries under this
- # * SCOPE_SUB - subtrees, all entries at all levels
- #
- SCOPE = [
- SCOPE_ONE = 'one',
- SCOPE_SUB = 'sub',
- SCOPE_BASE = 'base',
- ].freeze
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::LDAP object from components, with syntax checking.
- #
- # The components accepted are host, port, dn, attributes,
- # scope, filter, and extensions.
- #
- # The components should be provided either as an Array, or as a Hash
- # with keys formed by preceding the component names with a colon.
- #
- # If an Array is used, the components must be passed in the
- # order <code>[host, port, dn, attributes, scope, filter, extensions]</code>.
- #
- # Example:
- #
- # uri = Bundler::URI::LDAP.build({:host => 'ldap.example.com',
- # :dn => '/dc=example'})
- #
- # uri = Bundler::URI::LDAP.build(["ldap.example.com", nil,
- # "/dc=example;dc=com", "query", nil, nil, nil])
- #
- def self.build(args)
- tmp = Util::make_components_hash(self, args)
-
- if tmp[:dn]
- tmp[:path] = tmp[:dn]
- end
-
- query = []
- [:extensions, :filter, :scope, :attributes].collect do |x|
- next if !tmp[x] && query.size == 0
- query.unshift(tmp[x])
- end
-
- tmp[:query] = query.join('?')
-
- return super(tmp)
- end
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::LDAP object from generic Bundler::URI components as per
- # RFC 2396. No LDAP-specific syntax checking is performed.
- #
- # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
- # +opaque+, +query+, and +fragment+, in that order.
- #
- # Example:
- #
- # uri = Bundler::URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil,
- # "/dc=example;dc=com", nil, "query", nil)
- #
- # See also Bundler::URI::Generic.new.
- #
- def initialize(*arg)
- super(*arg)
-
- if @fragment
- raise InvalidURIError, 'bad LDAP URL'
- end
-
- parse_dn
- parse_query
- end
-
- # Private method to cleanup +dn+ from using the +path+ component attribute.
- def parse_dn
- @dn = @path[1..-1]
- end
- private :parse_dn
-
- # Private method to cleanup +attributes+, +scope+, +filter+, and +extensions+
- # from using the +query+ component attribute.
- def parse_query
- @attributes = nil
- @scope = nil
- @filter = nil
- @extensions = nil
-
- if @query
- attrs, scope, filter, extensions = @query.split('?')
-
- @attributes = attrs if attrs && attrs.size > 0
- @scope = scope if scope && scope.size > 0
- @filter = filter if filter && filter.size > 0
- @extensions = extensions if extensions && extensions.size > 0
- end
- end
- private :parse_query
-
- # Private method to assemble +query+ from +attributes+, +scope+, +filter+, and +extensions+.
- def build_path_query
- @path = '/' + @dn
-
- query = []
- [@extensions, @filter, @scope, @attributes].each do |x|
- next if !x && query.size == 0
- query.unshift(x)
- end
- @query = query.join('?')
- end
- private :build_path_query
-
- # Returns dn.
- def dn
- @dn
- end
-
- # Private setter for dn +val+.
- def set_dn(val)
- @dn = val
- build_path_query
- @dn
- end
- protected :set_dn
-
- # Setter for dn +val+.
- def dn=(val)
- set_dn(val)
- val
- end
-
- # Returns attributes.
- def attributes
- @attributes
- end
-
- # Private setter for attributes +val+.
- def set_attributes(val)
- @attributes = val
- build_path_query
- @attributes
- end
- protected :set_attributes
-
- # Setter for attributes +val+.
- def attributes=(val)
- set_attributes(val)
- val
- end
-
- # Returns scope.
- def scope
- @scope
- end
-
- # Private setter for scope +val+.
- def set_scope(val)
- @scope = val
- build_path_query
- @scope
- end
- protected :set_scope
-
- # Setter for scope +val+.
- def scope=(val)
- set_scope(val)
- val
- end
-
- # Returns filter.
- def filter
- @filter
- end
-
- # Private setter for filter +val+.
- def set_filter(val)
- @filter = val
- build_path_query
- @filter
- end
- protected :set_filter
-
- # Setter for filter +val+.
- def filter=(val)
- set_filter(val)
- val
- end
-
- # Returns extensions.
- def extensions
- @extensions
- end
-
- # Private setter for extensions +val+.
- def set_extensions(val)
- @extensions = val
- build_path_query
- @extensions
- end
- protected :set_extensions
-
- # Setter for extensions +val+.
- def extensions=(val)
- set_extensions(val)
- val
- end
-
- # Checks if Bundler::URI has a path.
- # For Bundler::URI::LDAP this will return +false+.
- def hierarchical?
- false
- end
- end
-
- @@schemes['LDAP'] = LDAP
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/ldaps.rb b/lib/bundler/vendor/uri/lib/uri/ldaps.rb
deleted file mode 100644
index 0af35bb16b..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/ldaps.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: false
-# = uri/ldap.rb
-#
-# License:: You can redistribute it and/or modify it under the same term as Ruby.
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative 'ldap'
-
-module Bundler::URI
-
- # The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather
- # than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
- # see Bundler::URI::LDAP.
- class LDAPS < LDAP
- # A Default port of 636 for Bundler::URI::LDAPS
- DEFAULT_PORT = 636
- end
- @@schemes['LDAPS'] = LDAPS
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/mailto.rb b/lib/bundler/vendor/uri/lib/uri/mailto.rb
deleted file mode 100644
index 5b2a4765c8..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/mailto.rb
+++ /dev/null
@@ -1,294 +0,0 @@
-# frozen_string_literal: false
-# = uri/mailto.rb
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id$
-#
-# See Bundler::URI for general documentation
-#
-
-require_relative 'generic'
-
-module Bundler::URI
-
- #
- # RFC6068, the mailto URL scheme.
- #
- class MailTo < Generic
- include REGEXP
-
- # A Default port of nil for Bundler::URI::MailTo.
- DEFAULT_PORT = nil
-
- # An Array of the available components for Bundler::URI::MailTo.
- COMPONENT = [ :scheme, :to, :headers ].freeze
-
- # :stopdoc:
- # "hname" and "hvalue" are encodings of an RFC 822 header name and
- # value, respectively. As with "to", all URL reserved characters must
- # be encoded.
- #
- # "#mailbox" is as specified in RFC 822 [RFC822]. This means that it
- # consists of zero or more comma-separated mail addresses, possibly
- # including "phrase" and "comment" components. Note that all URL
- # reserved characters in "to" must be encoded: in particular,
- # parentheses, commas, and the percent sign ("%"), which commonly occur
- # in the "mailbox" syntax.
- #
- # Within mailto URLs, the characters "?", "=", "&" are reserved.
-
- # ; RFC 6068
- # hfields = "?" hfield *( "&" hfield )
- # hfield = hfname "=" hfvalue
- # hfname = *qchar
- # hfvalue = *qchar
- # qchar = unreserved / pct-encoded / some-delims
- # some-delims = "!" / "$" / "'" / "(" / ")" / "*"
- # / "+" / "," / ";" / ":" / "@"
- #
- # ; RFC3986
- # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
- # pct-encoded = "%" HEXDIG HEXDIG
- HEADER_REGEXP = /\A(?<hfield>(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g<hfield>)*\z/
- # practical regexp for email address
- # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
- EMAIL_REGEXP = /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/
- # :startdoc:
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::MailTo object from components, with syntax checking.
- #
- # Components can be provided as an Array or Hash. If an Array is used,
- # the components must be supplied as <code>[to, headers]</code>.
- #
- # If a Hash is used, the keys are the component names preceded by colons.
- #
- # The headers can be supplied as a pre-encoded string, such as
- # <code>"subject=subscribe&cc=address"</code>, or as an Array of Arrays
- # like <code>[['subject', 'subscribe'], ['cc', 'address']]</code>.
- #
- # Examples:
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # m1 = Bundler::URI::MailTo.build(['joe@example.com', 'subject=Ruby'])
- # m1.to_s # => "mailto:joe@example.com?subject=Ruby"
- #
- # m2 = Bundler::URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]])
- # m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com"
- #
- # m3 = Bundler::URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]})
- # m3.to_s # => "mailto:listman@example.com?subject=subscribe"
- #
- def self.build(args)
- tmp = Util.make_components_hash(self, args)
-
- case tmp[:to]
- when Array
- tmp[:opaque] = tmp[:to].join(',')
- when String
- tmp[:opaque] = tmp[:to].dup
- else
- tmp[:opaque] = ''
- end
-
- if tmp[:headers]
- query =
- case tmp[:headers]
- when Array
- tmp[:headers].collect { |x|
- if x.kind_of?(Array)
- x[0] + '=' + x[1..-1].join
- else
- x.to_s
- end
- }.join('&')
- when Hash
- tmp[:headers].collect { |h,v|
- h + '=' + v
- }.join('&')
- else
- tmp[:headers].to_s
- end
- unless query.empty?
- tmp[:opaque] << '?' << query
- end
- end
-
- super(tmp)
- end
-
- #
- # == Description
- #
- # Creates a new Bundler::URI::MailTo object from generic URL components with
- # no syntax checking.
- #
- # This method is usually called from Bundler::URI::parse, which checks
- # the validity of each component.
- #
- def initialize(*arg)
- super(*arg)
-
- @to = nil
- @headers = []
-
- # The RFC3986 parser does not normally populate opaque
- @opaque = "?#{@query}" if @query && !@opaque
-
- unless @opaque
- raise InvalidComponentError,
- "missing opaque part for mailto URL"
- end
- to, header = @opaque.split('?', 2)
- # allow semicolon as a addr-spec separator
- # http://support.microsoft.com/kb/820868
- unless /\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/ =~ to
- raise InvalidComponentError,
- "unrecognised opaque part for mailtoURL: #{@opaque}"
- end
-
- if arg[10] # arg_check
- self.to = to
- self.headers = header
- else
- set_to(to)
- set_headers(header)
- end
- end
-
- # The primary e-mail address of the URL, as a String.
- attr_reader :to
-
- # E-mail headers set by the URL, as an Array of Arrays.
- attr_reader :headers
-
- # Checks the to +v+ component.
- def check_to(v)
- return true unless v
- return true if v.size == 0
-
- v.split(/[,;]/).each do |addr|
- # check url safety as path-rootless
- if /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*\z/ !~ addr
- raise InvalidComponentError,
- "an address in 'to' is invalid as Bundler::URI #{addr.dump}"
- end
-
- # check addr-spec
- # don't s/\+/ /g
- addr.gsub!(/%\h\h/, Bundler::URI::TBLDECWWWCOMP_)
- if EMAIL_REGEXP !~ addr
- raise InvalidComponentError,
- "an address in 'to' is invalid as uri-escaped addr-spec #{addr.dump}"
- end
- end
-
- true
- end
- private :check_to
-
- # Private setter for to +v+.
- def set_to(v)
- @to = v
- end
- protected :set_to
-
- # Setter for to +v+.
- def to=(v)
- check_to(v)
- set_to(v)
- v
- end
-
- # Checks the headers +v+ component against either
- # * HEADER_REGEXP
- def check_headers(v)
- return true unless v
- return true if v.size == 0
- if HEADER_REGEXP !~ v
- raise InvalidComponentError,
- "bad component(expected opaque component): #{v}"
- end
-
- true
- end
- private :check_headers
-
- # Private setter for headers +v+.
- def set_headers(v)
- @headers = []
- if v
- v.split('&').each do |x|
- @headers << x.split(/=/, 2)
- end
- end
- end
- protected :set_headers
-
- # Setter for headers +v+.
- def headers=(v)
- check_headers(v)
- set_headers(v)
- v
- end
-
- # Constructs String from Bundler::URI.
- def to_s
- @scheme + ':' +
- if @to
- @to
- else
- ''
- end +
- if @headers.size > 0
- '?' + @headers.collect{|x| x.join('=')}.join('&')
- else
- ''
- end +
- if @fragment
- '#' + @fragment
- else
- ''
- end
- end
-
- # Returns the RFC822 e-mail text equivalent of the URL, as a String.
- #
- # Example:
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr")
- # uri.to_mailtext
- # # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
- #
- def to_mailtext
- to = Bundler::URI.decode_www_form_component(@to)
- head = ''
- body = ''
- @headers.each do |x|
- case x[0]
- when 'body'
- body = Bundler::URI.decode_www_form_component(x[1])
- when 'to'
- to << ', ' + Bundler::URI.decode_www_form_component(x[1])
- else
- head << Bundler::URI.decode_www_form_component(x[0]).capitalize + ': ' +
- Bundler::URI.decode_www_form_component(x[1]) + "\n"
- end
- end
-
- "To: #{to}
-#{head}
-#{body}
-"
- end
- alias to_rfc822text to_mailtext
- end
-
- @@schemes['MAILTO'] = MailTo
-end
diff --git a/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb b/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
deleted file mode 100644
index a0d62ede64..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
+++ /dev/null
@@ -1,546 +0,0 @@
-# frozen_string_literal: false
-#--
-# = uri/common.rb
-#
-# Author:: Akira Yamada <akira@ruby-lang.org>
-# Revision:: $Id$
-# License::
-# You can redistribute it and/or modify it under the same term as Ruby.
-#
-# See Bundler::URI for general documentation
-#
-
-module Bundler::URI
- #
- # Includes Bundler::URI::REGEXP::PATTERN
- #
- module RFC2396_REGEXP
- #
- # Patterns used to parse Bundler::URI's
- #
- module PATTERN
- # :stopdoc:
-
- # RFC 2396 (Bundler::URI Generic Syntax)
- # RFC 2732 (IPv6 Literal Addresses in URL's)
- # RFC 2373 (IPv6 Addressing Architecture)
-
- # alpha = lowalpha | upalpha
- ALPHA = "a-zA-Z"
- # alphanum = alpha | digit
- ALNUM = "#{ALPHA}\\d"
-
- # hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
- # "a" | "b" | "c" | "d" | "e" | "f"
- HEX = "a-fA-F\\d"
- # escaped = "%" hex hex
- ESCAPED = "%[#{HEX}]{2}"
- # mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
- # "(" | ")"
- # unreserved = alphanum | mark
- UNRESERVED = "\\-_.!~*'()#{ALNUM}"
- # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
- # "$" | ","
- # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
- # "$" | "," | "[" | "]" (RFC 2732)
- RESERVED = ";/?:@&=+$,\\[\\]"
-
- # domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
- DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
- # toplabel = alpha | alpha *( alphanum | "-" ) alphanum
- TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
- # hostname = *( domainlabel "." ) toplabel [ "." ]
- HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?"
-
- # :startdoc:
- end # PATTERN
-
- # :startdoc:
- end # REGEXP
-
- # Class that parses String's into Bundler::URI's.
- #
- # It contains a Hash set of patterns and Regexp's that match and validate.
- #
- class RFC2396_Parser
- include RFC2396_REGEXP
-
- #
- # == Synopsis
- #
- # Bundler::URI::Parser.new([opts])
- #
- # == Args
- #
- # The constructor accepts a hash as options for parser.
- # Keys of options are pattern names of Bundler::URI components
- # and values of options are pattern strings.
- # The constructor generates set of regexps for parsing URIs.
- #
- # You can use the following keys:
- #
- # * :ESCAPED (Bundler::URI::PATTERN::ESCAPED in default)
- # * :UNRESERVED (Bundler::URI::PATTERN::UNRESERVED in default)
- # * :DOMLABEL (Bundler::URI::PATTERN::DOMLABEL in default)
- # * :TOPLABEL (Bundler::URI::PATTERN::TOPLABEL in default)
- # * :HOSTNAME (Bundler::URI::PATTERN::HOSTNAME in default)
- #
- # == Examples
- #
- # p = Bundler::URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
- # u = p.parse("http://example.jp/%uABCD") #=> #<Bundler::URI::HTTP http://example.jp/%uABCD>
- # Bundler::URI.parse(u.to_s) #=> raises Bundler::URI::InvalidURIError
- #
- # s = "http://example.com/ABCD"
- # u1 = p.parse(s) #=> #<Bundler::URI::HTTP http://example.com/ABCD>
- # u2 = Bundler::URI.parse(s) #=> #<Bundler::URI::HTTP http://example.com/ABCD>
- # u1 == u2 #=> true
- # u1.eql?(u2) #=> false
- #
- def initialize(opts = {})
- @pattern = initialize_pattern(opts)
- @pattern.each_value(&:freeze)
- @pattern.freeze
-
- @regexp = initialize_regexp(@pattern)
- @regexp.each_value(&:freeze)
- @regexp.freeze
- end
-
- # The Hash of patterns.
- #
- # See also Bundler::URI::Parser.initialize_pattern.
- attr_reader :pattern
-
- # The Hash of Regexp.
- #
- # See also Bundler::URI::Parser.initialize_regexp.
- attr_reader :regexp
-
- # Returns a split Bundler::URI against regexp[:ABS_URI].
- def split(uri)
- case uri
- when ''
- # null uri
-
- when @regexp[:ABS_URI]
- scheme, opaque, userinfo, host, port,
- registry, path, query, fragment = $~[1..-1]
-
- # Bundler::URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
-
- # absoluteURI = scheme ":" ( hier_part | opaque_part )
- # hier_part = ( net_path | abs_path ) [ "?" query ]
- # opaque_part = uric_no_slash *uric
-
- # abs_path = "/" path_segments
- # net_path = "//" authority [ abs_path ]
-
- # authority = server | reg_name
- # server = [ [ userinfo "@" ] hostport ]
-
- if !scheme
- raise InvalidURIError,
- "bad Bundler::URI(absolute but no scheme): #{uri}"
- end
- if !opaque && (!path && (!host && !registry))
- raise InvalidURIError,
- "bad Bundler::URI(absolute but no path): #{uri}"
- end
-
- when @regexp[:REL_URI]
- scheme = nil
- opaque = nil
-
- userinfo, host, port, registry,
- rel_segment, abs_path, query, fragment = $~[1..-1]
- if rel_segment && abs_path
- path = rel_segment + abs_path
- elsif rel_segment
- path = rel_segment
- elsif abs_path
- path = abs_path
- end
-
- # Bundler::URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
-
- # relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
-
- # net_path = "//" authority [ abs_path ]
- # abs_path = "/" path_segments
- # rel_path = rel_segment [ abs_path ]
-
- # authority = server | reg_name
- # server = [ [ userinfo "@" ] hostport ]
-
- else
- raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri}"
- end
-
- path = '' if !path && !opaque # (see RFC2396 Section 5.2)
- ret = [
- scheme,
- userinfo, host, port, # X
- registry, # X
- path, # Y
- opaque, # Y
- query,
- fragment
- ]
- return ret
- end
-
- #
- # == Args
- #
- # +uri+::
- # String
- #
- # == Description
- #
- # Parses +uri+ and constructs either matching Bundler::URI scheme object
- # (File, FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or Bundler::URI::Generic.
- #
- # == Usage
- #
- # p = Bundler::URI::Parser.new
- # p.parse("ldap://ldap.example.com/dc=example?user=john")
- # #=> #<Bundler::URI::LDAP ldap://ldap.example.com/dc=example?user=john>
- #
- def parse(uri)
- scheme, userinfo, host, port,
- registry, path, opaque, query, fragment = self.split(uri)
-
- if scheme && Bundler::URI.scheme_list.include?(scheme.upcase)
- Bundler::URI.scheme_list[scheme.upcase].new(scheme, userinfo, host, port,
- registry, path, opaque, query,
- fragment, self)
- else
- Generic.new(scheme, userinfo, host, port,
- registry, path, opaque, query,
- fragment, self)
- end
- end
-
-
- #
- # == Args
- #
- # +uris+::
- # an Array of Strings
- #
- # == Description
- #
- # Attempts to parse and merge a set of URIs.
- #
- def join(*uris)
- uris[0] = convert_to_uri(uris[0])
- uris.inject :merge
- end
-
- #
- # :call-seq:
- # extract( str )
- # extract( str, schemes )
- # extract( str, schemes ) {|item| block }
- #
- # == Args
- #
- # +str+::
- # String to search
- # +schemes+::
- # Patterns to apply to +str+
- #
- # == Description
- #
- # Attempts to parse and merge a set of URIs.
- # If no +block+ given, then returns the result,
- # else it calls +block+ for each element in result.
- #
- # See also Bundler::URI::Parser.make_regexp.
- #
- def extract(str, schemes = nil)
- if block_given?
- str.scan(make_regexp(schemes)) { yield $& }
- nil
- else
- result = []
- str.scan(make_regexp(schemes)) { result.push $& }
- result
- end
- end
-
- # Returns Regexp that is default self.regexp[:ABS_URI_REF],
- # unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI].
- def make_regexp(schemes = nil)
- unless schemes
- @regexp[:ABS_URI_REF]
- else
- /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
- end
- end
-
- #
- # :call-seq:
- # escape( str )
- # escape( str, unsafe )
- #
- # == Args
- #
- # +str+::
- # String to make safe
- # +unsafe+::
- # Regexp to apply. Defaults to self.regexp[:UNSAFE]
- #
- # == Description
- #
- # Constructs a safe String from +str+, removing unsafe characters,
- # replacing them with codes.
- #
- def escape(str, unsafe = @regexp[:UNSAFE])
- unless unsafe.kind_of?(Regexp)
- # perhaps unsafe is String object
- unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false)
- end
- str.gsub(unsafe) do
- us = $&
- tmp = ''
- us.each_byte do |uc|
- tmp << sprintf('%%%02X', uc)
- end
- tmp
- end.force_encoding(Encoding::US_ASCII)
- end
-
- #
- # :call-seq:
- # unescape( str )
- # unescape( str, escaped )
- #
- # == Args
- #
- # +str+::
- # String to remove escapes from
- # +escaped+::
- # Regexp to apply. Defaults to self.regexp[:ESCAPED]
- #
- # == Description
- #
- # Removes escapes from +str+.
- #
- def unescape(str, escaped = @regexp[:ESCAPED])
- enc = str.encoding
- enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
- str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
- end
-
- @@to_s = Kernel.instance_method(:to_s)
- def inspect
- @@to_s.bind_call(self)
- end
-
- private
-
- # Constructs the default Hash of patterns.
- def initialize_pattern(opts = {})
- ret = {}
- ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
- ret[:UNRESERVED] = unreserved = opts.delete(:UNRESERVED) || PATTERN::UNRESERVED
- ret[:RESERVED] = reserved = opts.delete(:RESERVED) || PATTERN::RESERVED
- ret[:DOMLABEL] = opts.delete(:DOMLABEL) || PATTERN::DOMLABEL
- ret[:TOPLABEL] = opts.delete(:TOPLABEL) || PATTERN::TOPLABEL
- ret[:HOSTNAME] = hostname = opts.delete(:HOSTNAME)
-
- # RFC 2396 (Bundler::URI Generic Syntax)
- # RFC 2732 (IPv6 Literal Addresses in URL's)
- # RFC 2373 (IPv6 Addressing Architecture)
-
- # uric = reserved | unreserved | escaped
- ret[:URIC] = uric = "(?:[#{unreserved}#{reserved}]|#{escaped})"
- # uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
- # "&" | "=" | "+" | "$" | ","
- ret[:URIC_NO_SLASH] = uric_no_slash = "(?:[#{unreserved};?:@&=+$,]|#{escaped})"
- # query = *uric
- ret[:QUERY] = query = "#{uric}*"
- # fragment = *uric
- ret[:FRAGMENT] = fragment = "#{uric}*"
-
- # hostname = *( domainlabel "." ) toplabel [ "." ]
- # reg-name = *( unreserved / pct-encoded / sub-delims ) # RFC3986
- unless hostname
- ret[:HOSTNAME] = hostname = "(?:[a-zA-Z0-9\\-.]|%\\h\\h)+"
- end
-
- # RFC 2373, APPENDIX B:
- # IPv6address = hexpart [ ":" IPv4address ]
- # IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
- # hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ]
- # hexseq = hex4 *( ":" hex4)
- # hex4 = 1*4HEXDIG
- #
- # XXX: This definition has a flaw. "::" + IPv4address must be
- # allowed too. Here is a replacement.
- #
- # IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
- ret[:IPV4ADDR] = ipv4addr = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
- # hex4 = 1*4HEXDIG
- hex4 = "[#{PATTERN::HEX}]{1,4}"
- # lastpart = hex4 | IPv4address
- lastpart = "(?:#{hex4}|#{ipv4addr})"
- # hexseq1 = *( hex4 ":" ) hex4
- hexseq1 = "(?:#{hex4}:)*#{hex4}"
- # hexseq2 = *( hex4 ":" ) lastpart
- hexseq2 = "(?:#{hex4}:)*#{lastpart}"
- # IPv6address = hexseq2 | [ hexseq1 ] "::" [ hexseq2 ]
- ret[:IPV6ADDR] = ipv6addr = "(?:#{hexseq2}|(?:#{hexseq1})?::(?:#{hexseq2})?)"
-
- # IPv6prefix = ( hexseq1 | [ hexseq1 ] "::" [ hexseq1 ] ) "/" 1*2DIGIT
- # unused
-
- # ipv6reference = "[" IPv6address "]" (RFC 2732)
- ret[:IPV6REF] = ipv6ref = "\\[#{ipv6addr}\\]"
-
- # host = hostname | IPv4address
- # host = hostname | IPv4address | IPv6reference (RFC 2732)
- ret[:HOST] = host = "(?:#{hostname}|#{ipv4addr}|#{ipv6ref})"
- # port = *digit
- ret[:PORT] = port = '\d*'
- # hostport = host [ ":" port ]
- ret[:HOSTPORT] = hostport = "#{host}(?::#{port})?"
-
- # userinfo = *( unreserved | escaped |
- # ";" | ":" | "&" | "=" | "+" | "$" | "," )
- ret[:USERINFO] = userinfo = "(?:[#{unreserved};:&=+$,]|#{escaped})*"
-
- # pchar = unreserved | escaped |
- # ":" | "@" | "&" | "=" | "+" | "$" | ","
- pchar = "(?:[#{unreserved}:@&=+$,]|#{escaped})"
- # param = *pchar
- param = "#{pchar}*"
- # segment = *pchar *( ";" param )
- segment = "#{pchar}*(?:;#{param})*"
- # path_segments = segment *( "/" segment )
- ret[:PATH_SEGMENTS] = path_segments = "#{segment}(?:/#{segment})*"
-
- # server = [ [ userinfo "@" ] hostport ]
- server = "(?:#{userinfo}@)?#{hostport}"
- # reg_name = 1*( unreserved | escaped | "$" | "," |
- # ";" | ":" | "@" | "&" | "=" | "+" )
- ret[:REG_NAME] = reg_name = "(?:[#{unreserved}$,;:@&=+]|#{escaped})+"
- # authority = server | reg_name
- authority = "(?:#{server}|#{reg_name})"
-
- # rel_segment = 1*( unreserved | escaped |
- # ";" | "@" | "&" | "=" | "+" | "$" | "," )
- ret[:REL_SEGMENT] = rel_segment = "(?:[#{unreserved};@&=+$,]|#{escaped})+"
-
- # scheme = alpha *( alpha | digit | "+" | "-" | "." )
- ret[:SCHEME] = scheme = "[#{PATTERN::ALPHA}][\\-+.#{PATTERN::ALPHA}\\d]*"
-
- # abs_path = "/" path_segments
- ret[:ABS_PATH] = abs_path = "/#{path_segments}"
- # rel_path = rel_segment [ abs_path ]
- ret[:REL_PATH] = rel_path = "#{rel_segment}(?:#{abs_path})?"
- # net_path = "//" authority [ abs_path ]
- ret[:NET_PATH] = net_path = "//#{authority}(?:#{abs_path})?"
-
- # hier_part = ( net_path | abs_path ) [ "?" query ]
- ret[:HIER_PART] = hier_part = "(?:#{net_path}|#{abs_path})(?:\\?(?:#{query}))?"
- # opaque_part = uric_no_slash *uric
- ret[:OPAQUE_PART] = opaque_part = "#{uric_no_slash}#{uric}*"
-
- # absoluteURI = scheme ":" ( hier_part | opaque_part )
- ret[:ABS_URI] = abs_uri = "#{scheme}:(?:#{hier_part}|#{opaque_part})"
- # relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
- ret[:REL_URI] = rel_uri = "(?:#{net_path}|#{abs_path}|#{rel_path})(?:\\?#{query})?"
-
- # Bundler::URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
- ret[:URI_REF] = "(?:#{abs_uri}|#{rel_uri})?(?:##{fragment})?"
-
- ret[:X_ABS_URI] = "
- (#{scheme}): (?# 1: scheme)
- (?:
- (#{opaque_part}) (?# 2: opaque)
- |
- (?:(?:
- //(?:
- (?:(?:(#{userinfo})@)? (?# 3: userinfo)
- (?:(#{host})(?::(\\d*))?))? (?# 4: host, 5: port)
- |
- (#{reg_name}) (?# 6: registry)
- )
- |
- (?!//)) (?# XXX: '//' is the mark for hostport)
- (#{abs_path})? (?# 7: path)
- )(?:\\?(#{query}))? (?# 8: query)
- )
- (?:\\#(#{fragment}))? (?# 9: fragment)
- "
-
- ret[:X_REL_URI] = "
- (?:
- (?:
- //
- (?:
- (?:(#{userinfo})@)? (?# 1: userinfo)
- (#{host})?(?::(\\d*))? (?# 2: host, 3: port)
- |
- (#{reg_name}) (?# 4: registry)
- )
- )
- |
- (#{rel_segment}) (?# 5: rel_segment)
- )?
- (#{abs_path})? (?# 6: abs_path)
- (?:\\?(#{query}))? (?# 7: query)
- (?:\\#(#{fragment}))? (?# 8: fragment)
- "
-
- ret
- end
-
- # Constructs the default Hash of Regexp's.
- def initialize_regexp(pattern)
- ret = {}
-
- # for Bundler::URI::split
- ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
- ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
-
- # for Bundler::URI::extract
- ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
- ret[:ABS_URI_REF] = Regexp.new(pattern[:X_ABS_URI], Regexp::EXTENDED)
- ret[:REL_URI_REF] = Regexp.new(pattern[:X_REL_URI], Regexp::EXTENDED)
-
- # for Bundler::URI::escape/unescape
- ret[:ESCAPED] = Regexp.new(pattern[:ESCAPED])
- ret[:UNSAFE] = Regexp.new("[^#{pattern[:UNRESERVED]}#{pattern[:RESERVED]}]")
-
- # for Generic#initialize
- ret[:SCHEME] = Regexp.new("\\A#{pattern[:SCHEME]}\\z")
- ret[:USERINFO] = Regexp.new("\\A#{pattern[:USERINFO]}\\z")
- ret[:HOST] = Regexp.new("\\A#{pattern[:HOST]}\\z")
- ret[:PORT] = Regexp.new("\\A#{pattern[:PORT]}\\z")
- ret[:OPAQUE] = Regexp.new("\\A#{pattern[:OPAQUE_PART]}\\z")
- ret[:REGISTRY] = Regexp.new("\\A#{pattern[:REG_NAME]}\\z")
- ret[:ABS_PATH] = Regexp.new("\\A#{pattern[:ABS_PATH]}\\z")
- ret[:REL_PATH] = Regexp.new("\\A#{pattern[:REL_PATH]}\\z")
- ret[:QUERY] = Regexp.new("\\A#{pattern[:QUERY]}\\z")
- ret[:FRAGMENT] = Regexp.new("\\A#{pattern[:FRAGMENT]}\\z")
-
- ret
- end
-
- def convert_to_uri(uri)
- if uri.is_a?(Bundler::URI::Generic)
- uri
- elsif uri = String.try_convert(uri)
- parse(uri)
- else
- raise ArgumentError,
- "bad argument (expected Bundler::URI object or Bundler::URI string)"
- end
- end
-
- end # class Parser
-end # module Bundler::URI
diff --git a/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb b/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
deleted file mode 100644
index 07ef4391c0..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-# frozen_string_literal: false
-module Bundler::URI
- class RFC3986_Parser # :nodoc:
- # Bundler::URI defined in RFC3986
- # this regexp is modified not to host is not empty string
- RFC3986_URI = /\A(?<Bundler::URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
- RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+)\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
- attr_reader :regexp
-
- def initialize
- @regexp = default_regexp.each_value(&:freeze).freeze
- end
-
- def split(uri) #:nodoc:
- begin
- uri = uri.to_str
- rescue NoMethodError
- raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
- end
- uri.ascii_only? or
- raise InvalidURIError, "Bundler::URI must be ascii only #{uri.dump}"
- if m = RFC3986_URI.match(uri)
- query = m["query".freeze]
- scheme = m["scheme".freeze]
- opaque = m["path-rootless".freeze]
- if opaque
- opaque << "?#{query}" if query
- [ scheme,
- nil, # userinfo
- nil, # host
- nil, # port
- nil, # registry
- nil, # path
- opaque,
- nil, # query
- m["fragment".freeze]
- ]
- else # normal
- [ scheme,
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
- nil, # registry
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-empty".freeze]),
- nil, # opaque
- query,
- m["fragment".freeze]
- ]
- end
- elsif m = RFC3986_relative_ref.match(uri)
- [ nil, # scheme
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
- nil, # registry,
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-noscheme".freeze] ||
- m["path-empty".freeze]),
- nil, # opaque
- m["query".freeze],
- m["fragment".freeze]
- ]
- else
- raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
- end
- end
-
- def parse(uri) # :nodoc:
- scheme, userinfo, host, port,
- registry, path, opaque, query, fragment = self.split(uri)
- scheme_list = Bundler::URI.scheme_list
- if scheme && scheme_list.include?(uc = scheme.upcase)
- scheme_list[uc].new(scheme, userinfo, host, port,
- registry, path, opaque, query,
- fragment, self)
- else
- Generic.new(scheme, userinfo, host, port,
- registry, path, opaque, query,
- fragment, self)
- end
- end
-
-
- def join(*uris) # :nodoc:
- uris[0] = convert_to_uri(uris[0])
- uris.inject :merge
- end
-
- @@to_s = Kernel.instance_method(:to_s)
- def inspect
- @@to_s.bind_call(self)
- end
-
- private
-
- def default_regexp # :nodoc:
- {
- SCHEME: /\A[A-Za-z][A-Za-z0-9+\-.]*\z/,
- USERINFO: /\A(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*\z/,
- HOST: /\A(?:(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{,4}::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))\z/,
- ABS_PATH: /\A\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- REL_PATH: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- OPAQUE: /\A(?:[^\/].*)?\z/,
- PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
- }
- end
-
- def convert_to_uri(uri)
- if uri.is_a?(Bundler::URI::Generic)
- uri
- elsif uri = String.try_convert(uri)
- parse(uri)
- else
- raise ArgumentError,
- "bad argument (expected Bundler::URI object or Bundler::URI string)"
- end
- end
-
- end # class Parser
-end # module Bundler::URI
diff --git a/lib/bundler/vendor/uri/lib/uri/version.rb b/lib/bundler/vendor/uri/lib/uri/version.rb
deleted file mode 100644
index 56177ef194..0000000000
--- a/lib/bundler/vendor/uri/lib/uri/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Bundler::URI
- # :stopdoc:
- VERSION_CODE = '001000'.freeze
- VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
- # :startdoc:
-end
diff --git a/lib/bundler/vendored_fileutils.rb b/lib/bundler/vendored_fileutils.rb
deleted file mode 100644
index 1be1138ce2..0000000000
--- a/lib/bundler/vendored_fileutils.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler; end
-require_relative "vendor/fileutils/lib/fileutils"
diff --git a/lib/bundler/vendored_molinillo.rb b/lib/bundler/vendored_molinillo.rb
deleted file mode 100644
index d1976f5cb4..0000000000
--- a/lib/bundler/vendored_molinillo.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler; end
-require_relative "vendor/molinillo/lib/molinillo"
diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb
deleted file mode 100644
index 045a761dac..0000000000
--- a/lib/bundler/vendored_persistent.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# frozen_string_literal: true
-
-# We forcibly require OpenSSL, because net/http/persistent will only autoload
-# it. On some Rubies, autoload fails but explicit require succeeds.
-begin
- require "openssl"
-rescue LoadError
- # some Ruby builds don't have OpenSSL
-end
-module Bundler
- module Persistent
- module Net
- module HTTP
- end
- end
- end
-end
-require_relative "vendor/net-http-persistent/lib/net/http/persistent"
-
-module Bundler
- class PersistentHTTP < Persistent::Net::HTTP::Persistent
- def connection_for(uri)
- super(uri) do |connection|
- result = yield connection
- warn_old_tls_version_rubygems_connection(uri, connection)
- result
- end
- end
-
- def warn_old_tls_version_rubygems_connection(uri, connection)
- return unless connection.http.use_ssl?
- return unless (uri.host || "").end_with?("rubygems.org")
-
- socket = connection.instance_variable_get(:@socket)
- return unless socket
- socket_io = socket.io
- return unless socket_io.respond_to?(:ssl_version)
- ssl_version = socket_io.ssl_version
-
- case ssl_version
- when /TLSv([\d\.]+)/
- version = Gem::Version.new($1)
- if version < Gem::Version.new("1.2")
- Bundler.ui.warn \
- "Warning: Your Ruby version is compiled against a copy of OpenSSL that is very old. " \
- "Starting in January 2018, RubyGems.org will refuse connection requests from these " \
- "very old versions of OpenSSL. If you will need to continue installing gems after " \
- "January 2018, please follow this guide to upgrade: http://ruby.to/tls-outdated.",
- :wrap => true
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendored_thor.rb b/lib/bundler/vendored_thor.rb
deleted file mode 100644
index 0666cfc9b9..0000000000
--- a/lib/bundler/vendored_thor.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- def self.require_thor_actions
- require_relative "vendor/thor/lib/thor/actions"
- end
-end
-require_relative "vendor/thor/lib/thor"
diff --git a/lib/bundler/vendored_uri.rb b/lib/bundler/vendored_uri.rb
deleted file mode 100644
index 905e8158e8..0000000000
--- a/lib/bundler/vendored_uri.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler; end
-require_relative "vendor/uri/lib/uri"
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
deleted file mode 100644
index 85704816e4..0000000000
--- a/lib/bundler/version.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: false
-
-module Bundler
- VERSION = "2.1.4".freeze
-
- def self.bundler_major_version
- @bundler_major_version ||= VERSION.split(".").first.to_i
- end
-end
diff --git a/lib/bundler/version_ranges.rb b/lib/bundler/version_ranges.rb
deleted file mode 100644
index 12a956d6a0..0000000000
--- a/lib/bundler/version_ranges.rb
+++ /dev/null
@@ -1,122 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module VersionRanges
- NEq = Struct.new(:version)
- ReqR = Struct.new(:left, :right)
- class ReqR
- Endpoint = Struct.new(:version, :inclusive) do
- def <=>(other)
- if version.equal?(INFINITY)
- return 0 if other.version.equal?(INFINITY)
- return 1
- elsif other.version.equal?(INFINITY)
- return -1
- end
-
- comp = version <=> other.version
- return comp unless comp.zero?
-
- if inclusive && !other.inclusive
- 1
- elsif !inclusive && other.inclusive
- -1
- else
- 0
- end
- end
- end
-
- def to_s
- "#{left.inclusive ? "[" : "("}#{left.version}, #{right.version}#{right.inclusive ? "]" : ")"}"
- end
- INFINITY = begin
- inf = Object.new
- def inf.to_s
- "∞"
- end
- def inf.<=>(other)
- return 0 if other.equal?(self)
- 1
- end
- inf.freeze
- end
- ZERO = Gem::Version.new("0.a")
-
- def cover?(v)
- return false if left.inclusive && left.version > v
- return false if !left.inclusive && left.version >= v
-
- if right.version != INFINITY
- return false if right.inclusive && right.version < v
- return false if !right.inclusive && right.version <= v
- end
-
- true
- end
-
- def empty?
- left.version == right.version && !(left.inclusive && right.inclusive)
- end
-
- def single?
- left.version == right.version
- end
-
- def <=>(other)
- return -1 if other.equal?(INFINITY)
-
- comp = left <=> other.left
- return comp unless comp.zero?
-
- right <=> other.right
- end
-
- UNIVERSAL = ReqR.new(ReqR::Endpoint.new(Gem::Version.new("0.a"), true), ReqR::Endpoint.new(ReqR::INFINITY, false)).freeze
- end
-
- def self.for_many(requirements)
- requirements = requirements.map(&:requirements).flatten(1).map {|r| r.join(" ") }
- requirements << ">= 0.a" if requirements.empty?
- requirement = Gem::Requirement.new(requirements)
- self.for(requirement)
- end
-
- def self.for(requirement)
- ranges = requirement.requirements.map do |op, v|
- case op
- when "=" then ReqR.new(ReqR::Endpoint.new(v, true), ReqR::Endpoint.new(v, true))
- when "!=" then NEq.new(v)
- when ">=" then ReqR.new(ReqR::Endpoint.new(v, true), ReqR::Endpoint.new(ReqR::INFINITY, false))
- when ">" then ReqR.new(ReqR::Endpoint.new(v, false), ReqR::Endpoint.new(ReqR::INFINITY, false))
- when "<" then ReqR.new(ReqR::Endpoint.new(ReqR::ZERO, true), ReqR::Endpoint.new(v, false))
- when "<=" then ReqR.new(ReqR::Endpoint.new(ReqR::ZERO, true), ReqR::Endpoint.new(v, true))
- when "~>" then ReqR.new(ReqR::Endpoint.new(v, true), ReqR::Endpoint.new(v.bump, false))
- else raise "unknown version op #{op} in requirement #{requirement}"
- end
- end.uniq
- ranges, neqs = ranges.partition {|r| !r.is_a?(NEq) }
-
- [ranges.sort, neqs.map(&:version)]
- end
-
- def self.empty?(ranges, neqs)
- !ranges.reduce(ReqR::UNIVERSAL) do |last_range, curr_range|
- next false unless last_range
- next false if curr_range.single? && neqs.include?(curr_range.left.version)
- next curr_range if last_range.right.version == ReqR::INFINITY
- case last_range.right.version <=> curr_range.left.version
- # higher
- when 1 then next ReqR.new(curr_range.left, last_range.right)
- # equal
- when 0
- if last_range.right.inclusive && curr_range.left.inclusive && !neqs.include?(curr_range.left.version)
- ReqR.new(curr_range.left, [curr_range.right, last_range.right].max)
- end
- # lower
- when -1 then next false
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb
deleted file mode 100644
index 538e8c3e74..0000000000
--- a/lib/bundler/vlad.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "shared_helpers"
-Bundler::SharedHelpers.major_deprecation 2,
- "The Bundler task for Vlad"
-
-# Vlad task for Bundler.
-#
-# Add "require 'bundler/vlad'" in your Vlad deploy.rb, and
-# include the vlad:bundle:install task in your vlad:deploy task.
-require_relative "deployment"
-
-include Rake::DSL if defined? Rake::DSL
-
-namespace :vlad do
- Bundler::Deployment.define_task(Rake::RemoteTask, :remote_task, :roles => :app)
-end
diff --git a/lib/bundler/worker.rb b/lib/bundler/worker.rb
deleted file mode 100644
index 3471654b43..0000000000
--- a/lib/bundler/worker.rb
+++ /dev/null
@@ -1,104 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class Worker
- POISON = Object.new
-
- class WrappedException < StandardError
- attr_reader :exception
- def initialize(exn)
- @exception = exn
- end
- end
-
- # @return [String] the name of the worker
- attr_reader :name
-
- # Creates a worker pool of specified size
- #
- # @param size [Integer] Size of pool
- # @param name [String] name the name of the worker
- # @param func [Proc] job to run in inside the worker pool
- def initialize(size, name, func)
- @name = name
- @request_queue = Queue.new
- @response_queue = Queue.new
- @func = func
- @size = size
- @threads = nil
- SharedHelpers.trap("INT") { abort_threads }
- end
-
- # Enqueue a request to be executed in the worker pool
- #
- # @param obj [String] mostly it is name of spec that should be downloaded
- def enq(obj)
- create_threads unless @threads
- @request_queue.enq obj
- end
-
- # Retrieves results of job function being executed in worker pool
- def deq
- result = @response_queue.deq
- raise result.exception if result.is_a?(WrappedException)
- result
- end
-
- def stop
- stop_threads
- end
-
- private
-
- def process_queue(i)
- loop do
- obj = @request_queue.deq
- break if obj.equal? POISON
- @response_queue.enq apply_func(obj, i)
- end
- end
-
- def apply_func(obj, i)
- @func.call(obj, i)
- rescue Exception => e # rubocop:disable Lint/RescueException
- WrappedException.new(e)
- end
-
- # Stop the worker threads by sending a poison object down the request queue
- # so as worker threads after retrieving it, shut themselves down
- def stop_threads
- return unless @threads
- @threads.each { @request_queue.enq POISON }
- @threads.each(&:join)
- @threads = nil
- end
-
- def abort_threads
- return unless @threads
- Bundler.ui.debug("\n#{caller.join("\n")}")
- @threads.each(&:exit)
- exit 1
- end
-
- def create_threads
- creation_errors = []
-
- @threads = Array.new(@size) do |i|
- begin
- Thread.start { process_queue(i) }.tap do |thread|
- thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=)
- end
- rescue ThreadError => e
- creation_errors << e
- nil
- end
- end.compact
-
- return if creation_errors.empty?
-
- message = "Failed to create threads for the #{name} worker: #{creation_errors.map(&:to_s).uniq.join(", ")}"
- raise ThreadCreationError, message if @threads.empty?
- Bundler.ui.info message
- end
- end
-end
diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb
deleted file mode 100644
index 374b3bb5e3..0000000000
--- a/lib/bundler/yaml_serializer.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- # A stub yaml serializer that can handle only hashes and strings (as of now).
- module YAMLSerializer
- module_function
-
- def dump(hash)
- yaml = String.new("---")
- yaml << dump_hash(hash)
- end
-
- def dump_hash(hash)
- yaml = String.new("\n")
- hash.each do |k, v|
- yaml << k << ":"
- if v.is_a?(Hash)
- yaml << dump_hash(v).gsub(/^(?!$)/, " ") # indent all non-empty lines
- elsif v.is_a?(Array) # Expected to be array of strings
- yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
- else
- yaml << " " << v.to_s.gsub(/\s+/, " ").inspect << "\n"
- end
- end
- yaml
- end
-
- ARRAY_REGEX = /
- ^
- (?:[ ]*-[ ]) # '- ' before array items
- (['"]?) # optional opening quote
- (.*) # value
- \1 # matching closing quote
- $
- /xo.freeze
-
- HASH_REGEX = /
- ^
- ([ ]*) # indentations
- (.+) # key
- (?::(?=(?:\s|$))) # : (without the lookahead the #key includes this when : is present in value)
- [ ]?
- (['"]?) # optional opening quote
- (.*) # value
- \3 # matching closing quote
- $
- /xo.freeze
-
- def load(str)
- res = {}
- stack = [res]
- last_hash = nil
- last_empty_key = nil
- str.split(/\r?\n/).each do |line|
- if match = HASH_REGEX.match(line)
- indent, key, quote, val = match.captures
- key = convert_to_backward_compatible_key(key)
- depth = indent.scan(/ /).length
- if quote.empty? && val.empty?
- new_hash = {}
- stack[depth][key] = new_hash
- stack[depth + 1] = new_hash
- last_empty_key = key
- last_hash = stack[depth]
- else
- stack[depth][key] = val
- end
- elsif match = ARRAY_REGEX.match(line)
- _, val = match.captures
- last_hash[last_empty_key] = [] unless last_hash[last_empty_key].is_a?(Array)
-
- last_hash[last_empty_key].push(val)
- end
- end
- res
- end
-
- # for settings' keys
- def convert_to_backward_compatible_key(key)
- key = "#{key}/" if key =~ /https?:/i && key !~ %r{/\Z}
- key = key.gsub(".", "__") if key.include?(".")
- key
- end
-
- class << self
- private :dump_hash, :convert_to_backward_compatible_key
- end
- end
-end
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 4f16f309da..0f44a929e4 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -253,7 +253,7 @@
# end
# end +
# cgi.pre do
-# CGI.escapeHTML(
+# CGI::escapeHTML(
# "params: #{cgi.params.inspect}\n" +
# "cookies: #{cgi.cookies.inspect}\n" +
# ENV.collect do |key, value|
diff --git a/lib/cgi/cgi.gemspec b/lib/cgi/cgi.gemspec
deleted file mode 100644
index 58bd77027d..0000000000
--- a/lib/cgi/cgi.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/cgi/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "cgi"
- spec.version = CGI::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Support for the Common Gateway Interface protocol.}
- spec.description = %q{Support for the Common Gateway Interface protocol.}
- spec.homepage = "https://github.com/ruby/cgi"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb
index 6b0d89ca3b..a2155edb77 100644
--- a/lib/cgi/cookie.rb
+++ b/lib/cgi/cookie.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'util'
+require 'cgi/util'
class CGI
# Class representing an HTTP cookie.
#
@@ -57,7 +57,7 @@ class CGI
#
# name:: the name of the cookie. Required.
# value:: the cookie's value or list of values.
- # path:: the path for which this cookie applies. Defaults to
+ # path:: the path for which this cookie applies. Defaults to the
# the value of the +SCRIPT_NAME+ environment variable.
# domain:: the domain for which this cookie applies.
# expires:: the time at which this cookie expires, as a +Time+ object.
@@ -73,7 +73,8 @@ class CGI
@expires = nil
if name.kind_of?(String)
@name = name
- @path = (%r|\A(.*/)| =~ ENV["SCRIPT_NAME"] ? $1 : "")
+ %r|^(.*/)|.match(ENV["SCRIPT_NAME"])
+ @path = ($1 or "")
@secure = false
@httponly = false
return super(value)
@@ -87,7 +88,12 @@ class CGI
@name = options["name"]
value = Array(options["value"])
# simple support for IE
- @path = options["path"] || (%r|\A(.*/)| =~ ENV["SCRIPT_NAME"] ? $1 : "")
+ if options["path"]
+ @path = options["path"]
+ else
+ %r|^(.*/)|.match(ENV["SCRIPT_NAME"])
+ @path = ($1 or "")
+ end
@domain = options["domain"]
@expires = options["expires"]
@secure = options["secure"] == true
@@ -140,7 +146,7 @@ class CGI
buf = "#{@name}=#{val}".dup
buf << "; domain=#{@domain}" if @domain
buf << "; path=#{@path}" if @path
- buf << "; expires=#{CGI.rfc1123_date(@expires)}" if @expires
+ buf << "; expires=#{CGI::rfc1123_date(@expires)}" if @expires
buf << "; secure" if @secure
buf << "; HttpOnly" if @httponly
buf
@@ -159,6 +165,7 @@ class CGI
raw_cookie.split(/;\s?/).each do |pairs|
name, values = pairs.split('=',2)
next unless name and values
+ name = CGI.unescape(name)
values ||= ""
values = values.split('&').collect{|v| CGI.unescape(v,@@accept_charset) }
if cookies.has_key?(name)
diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb
index bec76e0749..73daae3e17 100644
--- a/lib/cgi/core.rb
+++ b/lib/cgi/core.rb
@@ -261,7 +261,7 @@ class CGI
private :_header_for_hash
def nph? #:nodoc:
- return /IIS\/(\d+)/ =~ $CGI_ENV['SERVER_SOFTWARE'] && $1.to_i < 5
+ return /IIS\/(\d+)/.match($CGI_ENV['SERVER_SOFTWARE']) && $1.to_i < 5
end
def _header_for_modruby(buf) #:nodoc:
@@ -375,14 +375,14 @@ class CGI
# Parse an HTTP query string into a hash of key=>value pairs.
#
- # params = CGI.parse("query_string")
+ # params = CGI::parse("query_string")
# # {"name1" => ["value1", "value2", ...],
# # "name2" => ["value1", "value2", ...], ... }
#
- def self.parse(query)
+ def CGI::parse(query)
params = {}
query.split(/[&;]/).each do |pairs|
- key, value = pairs.split('=',2).collect{|v| CGI.unescape(v) }
+ key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
next unless key
@@ -421,7 +421,7 @@ class CGI
module QueryExtension
%w[ CONTENT_LENGTH SERVER_PORT ].each do |env|
- define_method(env.delete_prefix('HTTP_').downcase) do
+ define_method(env.sub(/^HTTP_/, '').downcase) do
(val = env_table[env]) && Integer(val)
end
end
@@ -434,7 +434,7 @@ class CGI
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM HTTP_HOST
HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ].each do |env|
- define_method(env.delete_prefix('HTTP_').downcase) do
+ define_method(env.sub(/^HTTP_/, '').downcase) do
env_table[env]
end
end
@@ -544,11 +544,11 @@ class CGI
/Content-Disposition:.* filename=(?:"(.*?)"|([^;\r\n]*))/i.match(head)
filename = $1 || $2 || ''.dup
filename = CGI.unescape(filename) if unescape_filename?()
- body.instance_variable_set(:@original_filename, filename)
+ body.instance_variable_set(:@original_filename, filename.taint)
## content type
/Content-Type: (.*)/i.match(head)
(content_type = $1 || ''.dup).chomp!
- body.instance_variable_set(:@content_type, content_type)
+ body.instance_variable_set(:@content_type, content_type.taint)
## query parameter name
/Content-Disposition:.* name=(?:"(.*?)"|([^;\r\n]*))/i.match(head)
name = $1 || $2 || ''
@@ -607,7 +607,6 @@ class CGI
end
def unescape_filename? #:nodoc:
user_agent = $CGI_ENV['HTTP_USER_AGENT']
- return false unless user_agent
return /Mac/i.match(user_agent) && /Mozilla/i.match(user_agent) && !/MSIE/i.match(user_agent)
end
@@ -649,7 +648,7 @@ class CGI
# Reads query parameters in the @params field, and cookies into @cookies.
def initialize_query()
if ("POST" == env_table['REQUEST_METHOD']) and
- %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?| =~ env_table['CONTENT_TYPE']
+ %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|.match(env_table['CONTENT_TYPE'])
current_max_multipart_length = @max_multipart_length.respond_to?(:call) ? @max_multipart_length.call : @max_multipart_length
raise StandardError.new("too large multipart data.") if env_table['CONTENT_LENGTH'].to_i > current_max_multipart_length
boundary = $1.dup
@@ -657,7 +656,7 @@ class CGI
@params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
else
@multipart = false
- @params = CGI.parse(
+ @params = CGI::parse(
case env_table['REQUEST_METHOD']
when "GET", "HEAD"
if defined?(MOD_RUBY)
@@ -687,7 +686,7 @@ class CGI
end
end
- @cookies = CGI::Cookie.parse((env_table['HTTP_COOKIE'] or env_table['COOKIE']))
+ @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] or env_table['COOKIE']))
end
private :initialize_query
@@ -863,24 +862,24 @@ class CGI
case @options[:tag_maker]
when "html3"
- require_relative 'html'
+ require 'cgi/html'
extend Html3
extend HtmlExtension
when "html4"
- require_relative 'html'
+ require 'cgi/html'
extend Html4
extend HtmlExtension
when "html4Tr"
- require_relative 'html'
+ require 'cgi/html'
extend Html4Tr
extend HtmlExtension
when "html4Fr"
- require_relative 'html'
+ require 'cgi/html'
extend Html4Tr
extend Html4Fr
extend HtmlExtension
when "html5"
- require_relative 'html'
+ require 'cgi/html'
extend Html5
extend HtmlExtension
end
diff --git a/lib/cgi/html.rb b/lib/cgi/html.rb
index 1543943320..02d847ebd3 100644
--- a/lib/cgi/html.rb
+++ b/lib/cgi/html.rb
@@ -30,10 +30,10 @@ class CGI
attributes.each do|name, value|
next unless value
s << " "
- s << CGI.escapeHTML(name.to_s)
+ s << CGI::escapeHTML(name.to_s)
if value != true
s << '="'
- s << CGI.escapeHTML(value.to_s)
+ s << CGI::escapeHTML(value.to_s)
s << '"'
end
end
@@ -423,7 +423,7 @@ class CGI
buf << super(attributes)
if pretty
- CGI.pretty(buf, pretty)
+ CGI::pretty(buf, pretty)
else
buf
end
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 29e7b3ece3..fbb42986a4 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -403,11 +403,11 @@ class CGI
for line in f
line.chomp!
k, v = line.split('=',2)
- @hash[CGI.unescape(k)] = Marshal.restore(CGI.unescape(v))
+ @hash[CGI::unescape(k)] = Marshal.restore(CGI::unescape(v))
end
ensure
- f&.close
- lockf&.close
+ f.close unless f.nil?
+ lockf.close if lockf
end
end
@hash
@@ -421,13 +421,13 @@ class CGI
lockf.flock File::LOCK_EX
f = File.open(@path+".new", File::CREAT|File::TRUNC|File::WRONLY, 0600)
for k,v in @hash
- f.printf "%s=%s\n", CGI.escape(k), CGI.escape(String(Marshal.dump(v)))
+ f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(Marshal.dump(v)))
end
f.close
File.rename @path+".new", @path
ensure
- f&.close
- lockf&.close
+ f.close if f
+ lockf.close if lockf
end
end
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
index cc3006400f..cb0370b619 100644
--- a/lib/cgi/session/pstore.rb
+++ b/lib/cgi/session/pstore.rb
@@ -10,7 +10,7 @@
# persistent of session data on top of the pstore library. See
# cgi/session.rb for more details on session storage managers.
-require_relative '../session'
+require 'cgi/session'
require 'pstore'
class CGI
@@ -50,6 +50,7 @@ class CGI
require 'digest/md5'
md5 = Digest::MD5.hexdigest(id)[0,16]
path = dir+"/"+prefix+md5
+ path.untaint
if File::exist?(path)
@hash = nil
else
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index aab8b000cb..464115262f 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -7,7 +7,7 @@ end
module CGI::Util
@@accept_charset="UTF-8" unless defined?(@@accept_charset)
# URL-encode a string.
- # url_encoded_string = CGI.escape("'Stop!' said Fred")
+ # url_encoded_string = CGI::escape("'Stop!' said Fred")
# # => "%27Stop%21%27+said+Fred"
def escape(string)
encoding = string.encoding
@@ -17,7 +17,7 @@ module CGI::Util
end
# URL-decode a string with encoding(optional).
- # string = CGI.unescape("%27Stop%21%27+said+Fred")
+ # string = CGI::unescape("%27Stop%21%27+said+Fred")
# # => "'Stop!' said Fred"
def unescape(string,encoding=@@accept_charset)
str=string.tr('+', ' ').b.gsub(/((?:%[0-9a-fA-F]{2})+)/) do |m|
@@ -36,7 +36,7 @@ module CGI::Util
}
# Escape special characters in HTML, namely '&\"<>
- # CGI.escapeHTML('Usage: foo "bar" <baz>')
+ # CGI::escapeHTML('Usage: foo "bar" <baz>')
# # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
def escapeHTML(string)
enc = string.encoding
@@ -60,7 +60,7 @@ module CGI::Util
end
# Unescape a string that has been HTML-escaped
- # CGI.unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
+ # CGI::unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
# # => "Usage: foo \"bar\" <baz>"
def unescapeHTML(string)
enc = string.encoding
@@ -118,10 +118,10 @@ module CGI::Util
end
end
- # Synonym for CGI.escapeHTML(str)
+ # Synonym for CGI::escapeHTML(str)
alias escape_html escapeHTML
- # Synonym for CGI.unescapeHTML(str)
+ # Synonym for CGI::unescapeHTML(str)
alias unescape_html unescapeHTML
# Escape only the tags of certain HTML elements in +string+.
@@ -132,30 +132,30 @@ module CGI::Util
# The attribute list of the open tag will also be escaped (for
# instance, the double-quotes surrounding attribute values).
#
- # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
+ # print CGI::escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
# # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
#
- # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
+ # print CGI::escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
# # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
def escapeElement(string, *elements)
elements = elements[0] if elements[0].kind_of?(Array)
unless elements.empty?
string.gsub(/<\/?(?:#{elements.join("|")})(?!\w)(?:.|\n)*?>/i) do
- CGI.escapeHTML($&)
+ CGI::escapeHTML($&)
end
else
string
end
end
- # Undo escaping such as that done by CGI.escapeElement()
+ # Undo escaping such as that done by CGI::escapeElement()
#
- # print CGI.unescapeElement(
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
+ # print CGI::unescapeElement(
+ # CGI::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
# # "&lt;BR&gt;<A HREF="url"></A>"
#
- # print CGI.unescapeElement(
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
+ # print CGI::unescapeElement(
+ # CGI::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
# # "&lt;BR&gt;<A HREF="url"></A>"
def unescapeElement(string, *elements)
elements = elements[0] if elements[0].kind_of?(Array)
@@ -168,10 +168,10 @@ module CGI::Util
end
end
- # Synonym for CGI.escapeElement(str)
+ # Synonym for CGI::escapeElement(str)
alias escape_element escapeElement
- # Synonym for CGI.unescapeElement(str)
+ # Synonym for CGI::unescapeElement(str)
alias unescape_element unescapeElement
# Abbreviated day-of-week names specified by RFC 822
@@ -182,7 +182,7 @@ module CGI::Util
# Format a +Time+ object as a String using the format specified by RFC 1123.
#
- # CGI.rfc1123_date(Time.now)
+ # CGI::rfc1123_date(Time.now)
# # Sat, 01 Jan 2000 00:00:00 GMT
def rfc1123_date(time)
t = time.clone.gmtime
@@ -196,13 +196,13 @@ module CGI::Util
# +string+ is the HTML string to indent. +shift+ is the indentation
# unit to use; it defaults to two spaces.
#
- # print CGI.pretty("<HTML><BODY></BODY></HTML>")
+ # print CGI::pretty("<HTML><BODY></BODY></HTML>")
# # <HTML>
# # <BODY>
# # </BODY>
# # </HTML>
#
- # print CGI.pretty("<HTML><BODY></BODY></HTML>", "\t")
+ # print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t")
# # <HTML>
# # <BODY>
# # </BODY>
diff --git a/lib/cgi/version.rb b/lib/cgi/version.rb
deleted file mode 100644
index e145a762c6..0000000000
--- a/lib/cgi/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class CGI
- VERSION = "0.1.0.1"
-end
diff --git a/lib/cmath.gemspec b/lib/cmath.gemspec
new file mode 100644
index 0000000000..90a87a8ce4
--- /dev/null
+++ b/lib/cmath.gemspec
@@ -0,0 +1,24 @@
+# coding: utf-8
+# frozen_string_literal: true
+
+Gem::Specification.new do |spec|
+ spec.name = "cmath"
+ spec.version = "1.0.0"
+ spec.date = '2017-12-11'
+ spec.authors = ["Tadayoshi Funaba"]
+ spec.email = [nil]
+
+ spec.summary = "Provides Trigonometric and Transcendental functions for complex numbers"
+ spec.description = "CMath is a library that provides trigonometric and transcendental functions for complex numbers. The functions in this module accept integers, floating-point numbers or complex numbers as arguments."
+ spec.homepage = "https://github.com/ruby/cmath"
+ spec.license = "BSD-2-Clause"
+
+ spec.files = "lib/cmath.rb"
+ spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
+ spec.required_ruby_version = ">= 2.3.0"
+
+ spec.add_development_dependency "bundler"
+ spec.add_development_dependency "rake"
+end
diff --git a/lib/cmath.rb b/lib/cmath.rb
new file mode 100644
index 0000000000..7dbd65e799
--- /dev/null
+++ b/lib/cmath.rb
@@ -0,0 +1,435 @@
+# frozen_string_literal: true
+##
+# = Trigonometric and transcendental functions for complex numbers.
+#
+# CMath is a library that provides trigonometric and transcendental
+# functions for complex numbers. The functions in this module accept
+# integers, floating-point numbers or complex numbers as arguments.
+#
+# Note that the selection of functions is similar, but not identical,
+# to that in module math. The reason for having two modules is that
+# some users aren't interested in complex numbers, and perhaps don't
+# even know what they are. They would rather have Math.sqrt(-1) raise
+# an exception than return a complex number.
+#
+# For more information you can see Complex class.
+#
+# == Usage
+#
+# To start using this library, simply require cmath library:
+#
+# require "cmath"
+
+module CMath
+
+ include Math
+
+ # Backup of Math is needed because mathn.rb replaces Math with CMath.
+ RealMath = Math # :nodoc:
+ private_constant :RealMath
+
+ %w[
+ exp
+ log
+ log2
+ log10
+ sqrt
+ cbrt
+ sin
+ cos
+ tan
+ sinh
+ cosh
+ tanh
+ asin
+ acos
+ atan
+ atan2
+ asinh
+ acosh
+ atanh
+ ].each do |meth|
+ define_method(meth + '!') do |*args, &block|
+ warn("CMath##{meth}! is deprecated; use CMath##{meth} or Math##{meth}", uplevel: 1) if $VERBOSE
+ RealMath.send(meth, *args, &block)
+ end
+ end
+
+ ##
+ # Math::E raised to the +z+ power
+ #
+ # CMath.exp(1.i * Math::PI) #=> (-1.0+1.2246467991473532e-16i)
+ def exp(z)
+ begin
+ if z.real?
+ RealMath.exp(z)
+ else
+ ere = RealMath.exp(z.real)
+ Complex(ere * RealMath.cos(z.imag),
+ ere * RealMath.sin(z.imag))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the natural logarithm of Complex. If a second argument is given,
+ # it will be the base of logarithm.
+ #
+ # CMath.log(1 + 4i) #=> (1.416606672028108+1.3258176636680326i)
+ # CMath.log(1 + 4i, 10) #=> (0.6152244606891369+0.5757952953408879i)
+ def log(z, b=::Math::E)
+ begin
+ if z.real? && z >= 0 && b >= 0
+ RealMath.log(z, b)
+ else
+ Complex(RealMath.log(z.abs), z.arg) / log(b)
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the base 2 logarithm of +z+
+ #
+ # CMath.log2(-1) => (0.0+4.532360141827194i)
+ def log2(z)
+ begin
+ if z.real? and z >= 0
+ RealMath.log2(z)
+ else
+ log(z) / RealMath.log(2)
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the base 10 logarithm of +z+
+ #
+ # CMath.log10(-1) #=> (0.0+1.3643763538418412i)
+ def log10(z)
+ begin
+ if z.real? and z >= 0
+ RealMath.log10(z)
+ else
+ log(z) / RealMath.log(10)
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the non-negative square root of Complex.
+ #
+ # CMath.sqrt(-1 + 0i) #=> 0.0+1.0i
+ def sqrt(z)
+ begin
+ if z.real?
+ if z < 0
+ Complex(0, RealMath.sqrt(-z))
+ else
+ RealMath.sqrt(z)
+ end
+ else
+ if z.imag < 0 ||
+ (z.imag == 0 && z.imag.to_s[0] == '-')
+ sqrt(z.conjugate).conjugate
+ else
+ r = z.abs
+ x = z.real
+ Complex(RealMath.sqrt((r + x) / 2.0), RealMath.sqrt((r - x) / 2.0))
+ end
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the principal value of the cube root of +z+
+ #
+ # CMath.cbrt(1 + 4i) #=> (1.449461632813119+0.6858152562177092i)
+ def cbrt(z)
+ z ** (1.0/3)
+ end
+
+ ##
+ # Returns the sine of +z+, where +z+ is given in radians
+ #
+ # CMath.sin(1 + 1i) #=> (1.2984575814159773+0.6349639147847361i)
+ def sin(z)
+ begin
+ if z.real?
+ RealMath.sin(z)
+ else
+ Complex(RealMath.sin(z.real) * RealMath.cosh(z.imag),
+ RealMath.cos(z.real) * RealMath.sinh(z.imag))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the cosine of +z+, where +z+ is given in radians
+ #
+ # CMath.cos(1 + 1i) #=> (0.8337300251311491-0.9888977057628651i)
+ def cos(z)
+ begin
+ if z.real?
+ RealMath.cos(z)
+ else
+ Complex(RealMath.cos(z.real) * RealMath.cosh(z.imag),
+ -RealMath.sin(z.real) * RealMath.sinh(z.imag))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the tangent of +z+, where +z+ is given in radians
+ #
+ # CMath.tan(1 + 1i) #=> (0.27175258531951174+1.0839233273386943i)
+ def tan(z)
+ begin
+ if z.real?
+ RealMath.tan(z)
+ else
+ sin(z) / cos(z)
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the hyperbolic sine of +z+, where +z+ is given in radians
+ #
+ # CMath.sinh(1 + 1i) #=> (0.6349639147847361+1.2984575814159773i)
+ def sinh(z)
+ begin
+ if z.real?
+ RealMath.sinh(z)
+ else
+ Complex(RealMath.sinh(z.real) * RealMath.cos(z.imag),
+ RealMath.cosh(z.real) * RealMath.sin(z.imag))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the hyperbolic cosine of +z+, where +z+ is given in radians
+ #
+ # CMath.cosh(1 + 1i) #=> (0.8337300251311491+0.9888977057628651i)
+ def cosh(z)
+ begin
+ if z.real?
+ RealMath.cosh(z)
+ else
+ Complex(RealMath.cosh(z.real) * RealMath.cos(z.imag),
+ RealMath.sinh(z.real) * RealMath.sin(z.imag))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the hyperbolic tangent of +z+, where +z+ is given in radians
+ #
+ # CMath.tanh(1 + 1i) #=> (1.0839233273386943+0.27175258531951174i)
+ def tanh(z)
+ begin
+ if z.real?
+ RealMath.tanh(z)
+ else
+ sinh(z) / cosh(z)
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the arc sine of +z+
+ #
+ # CMath.asin(1 + 1i) #=> (0.6662394324925153+1.0612750619050355i)
+ def asin(z)
+ begin
+ if z.real? and z >= -1 and z <= 1
+ RealMath.asin(z)
+ else
+ (-1.0).i * log(1.0.i * z + sqrt(1.0 - z * z))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the arc cosine of +z+
+ #
+ # CMath.acos(1 + 1i) #=> (0.9045568943023813-1.0612750619050357i)
+ def acos(z)
+ begin
+ if z.real? and z >= -1 and z <= 1
+ RealMath.acos(z)
+ else
+ (-1.0).i * log(z + 1.0.i * sqrt(1.0 - z * z))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # Returns the arc tangent of +z+
+ #
+ # CMath.atan(1 + 1i) #=> (1.0172219678978514+0.4023594781085251i)
+ def atan(z)
+ begin
+ if z.real?
+ RealMath.atan(z)
+ else
+ 1.0.i * log((1.0.i + z) / (1.0.i - z)) / 2.0
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # returns the arc tangent of +y+ divided by +x+ using the signs of +y+ and
+ # +x+ to determine the quadrant
+ #
+ # CMath.atan2(1 + 1i, 0) #=> (1.5707963267948966+0.0i)
+ def atan2(y,x)
+ begin
+ if y.real? and x.real?
+ RealMath.atan2(y,x)
+ else
+ (-1.0).i * log((x + 1.0.i * y) / sqrt(x * x + y * y))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # returns the inverse hyperbolic sine of +z+
+ #
+ # CMath.asinh(1 + 1i) #=> (1.0612750619050357+0.6662394324925153i)
+ def asinh(z)
+ begin
+ if z.real?
+ RealMath.asinh(z)
+ else
+ log(z + sqrt(1.0 + z * z))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # returns the inverse hyperbolic cosine of +z+
+ #
+ # CMath.acosh(1 + 1i) #=> (1.0612750619050357+0.9045568943023813i)
+ def acosh(z)
+ begin
+ if z.real? and z >= 1
+ RealMath.acosh(z)
+ else
+ log(z + sqrt(z * z - 1.0))
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ ##
+ # returns the inverse hyperbolic tangent of +z+
+ #
+ # CMath.atanh(1 + 1i) #=> (0.4023594781085251+1.0172219678978514i)
+ def atanh(z)
+ begin
+ if z.real? and z >= -1 and z <= 1
+ RealMath.atanh(z)
+ else
+ log((1.0 + z) / (1.0 - z)) / 2.0
+ end
+ rescue NoMethodError
+ handle_no_method_error
+ end
+ end
+
+ module_function :exp!
+ module_function :exp
+ module_function :log!
+ module_function :log
+ module_function :log2!
+ module_function :log2
+ module_function :log10!
+ module_function :log10
+ module_function :sqrt!
+ module_function :sqrt
+ module_function :cbrt!
+ module_function :cbrt
+
+ module_function :sin!
+ module_function :sin
+ module_function :cos!
+ module_function :cos
+ module_function :tan!
+ module_function :tan
+
+ module_function :sinh!
+ module_function :sinh
+ module_function :cosh!
+ module_function :cosh
+ module_function :tanh!
+ module_function :tanh
+
+ module_function :asin!
+ module_function :asin
+ module_function :acos!
+ module_function :acos
+ module_function :atan!
+ module_function :atan
+ module_function :atan2!
+ module_function :atan2
+
+ module_function :asinh!
+ module_function :asinh
+ module_function :acosh!
+ module_function :acosh
+ module_function :atanh!
+ module_function :atanh
+
+ module_function :frexp
+ module_function :ldexp
+ module_function :hypot
+ module_function :erf
+ module_function :erfc
+ module_function :gamma
+ module_function :lgamma
+
+ private
+ def handle_no_method_error # :nodoc:
+ if $!.name == :real?
+ raise TypeError, "Numeric Number required"
+ else
+ raise
+ end
+ end
+ module_function :handle_no_method_error
+
+end
diff --git a/lib/csv.gemspec b/lib/csv.gemspec
new file mode 100644
index 0000000000..2862c1fbc2
--- /dev/null
+++ b/lib/csv.gemspec
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+Gem::Specification.new do |spec|
+ spec.name = "csv"
+ spec.version = "1.0.0"
+ spec.date = "2017-12-13"
+ spec.authors = ["James Edward Gray II"]
+ spec.email = [nil]
+
+ spec.summary = "CSV Reading and Writing"
+ spec.description = "the CSV library began its life as FasterCSV."
+ spec.homepage = "https://github.com/ruby/csv"
+ spec.license = "BSD-2-Clause"
+
+ spec.files = ["lib/csv.rb"]
+ spec.require_paths = ["lib"]
+ spec.required_ruby_version = ">= 2.4.0"
+
+ spec.add_development_dependency "bundler", "~> 1.14"
+ spec.add_development_dependency "rake", "~> 12"
+end
diff --git a/lib/csv.rb b/lib/csv.rb
index 8aa65868b7..1f616803aa 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -2,7 +2,9 @@
# frozen_string_literal: true
# = csv.rb -- CSV Reading and Writing
#
-# Created by James Edward Gray II on 2005-10-31.
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
#
# See CSV for documentation.
#
@@ -10,18 +12,18 @@
#
# Welcome to the new and improved CSV.
#
-# This version of the CSV library began its life as FasterCSV. FasterCSV was
-# intended as a replacement to Ruby's then standard CSV library. It was
+# This version of the CSV library began its life as FasterCSV. FasterCSV was
+# intended as a replacement to Ruby's then standard CSV library. It was
# designed to address concerns users of that library had and it had three
# primary goals:
#
# 1. Be significantly faster than CSV while remaining a pure Ruby library.
-# 2. Use a smaller and easier to maintain code base. (FasterCSV eventually
-# grew larger, was also but considerably richer in features. The parsing
+# 2. Use a smaller and easier to maintain code base. (FasterCSV eventually
+# grew larger, was also but considerably richer in features. The parsing
# core remains quite small.)
# 3. Improve on the CSV interface.
#
-# Obviously, the last one is subjective. I did try to defer to the original
+# Obviously, the last one is subjective. I did try to defer to the original
# interface whenever I didn't have a compelling reason to change it though, so
# hopefully this won't be too radically different.
#
@@ -29,20 +31,20 @@
# the original library as of Ruby 1.9. If you are migrating code from 1.8 or
# earlier, you may have to change your code to comply with the new interface.
#
-# == What's the Different From the Old CSV?
+# == What's Different From the Old CSV?
#
# I'm sure I'll miss something, but I'll try to mention most of the major
# differences I am aware of, to help others quickly get up to speed:
#
# === CSV Parsing
#
-# * This parser is m17n aware. See CSV for full details.
+# * This parser is m17n aware. See CSV for full details.
# * This library has a stricter parser and will throw MalformedCSVErrors on
# problematic data.
-# * This library has a less liberal idea of a line ending than CSV. What you
-# set as the <tt>:row_sep</tt> is law. It can auto-detect your line endings
+# * This library has a less liberal idea of a line ending than CSV. What you
+# set as the <tt>:row_sep</tt> is law. It can auto-detect your line endings
# though.
-# * The old library returned empty lines as <tt>[nil]</tt>. This library calls
+# * The old library returned empty lines as <tt>[nil]</tt>. This library calls
# them <tt>[]</tt>.
# * This library has a much faster parser.
#
@@ -56,9 +58,9 @@
# * CSV now has a new() method used to wrap objects like String and IO for
# reading and writing.
# * CSV::generate() is different from the old method.
-# * CSV no longer supports partial reads. It works line-by-line.
+# * CSV no longer supports partial reads. It works line-by-line.
# * CSV no longer allows the instance methods to override the separators for
-# performance reasons. They must be set in the constructor.
+# performance reasons. They must be set in the constructor.
#
# If you use this library and find yourself missing any functionality I have
# trimmed, please {let me know}[mailto:james@grayproductions.net].
@@ -70,16 +72,16 @@
# == What is CSV, really?
#
# CSV maintains a pretty strict definition of CSV taken directly from
-# {the RFC}[http://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one
-# place and that is to make using this library easier. CSV will parse all valid
+# {the RFC}[http://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one
+# place and that is to make using this library easier. CSV will parse all valid
# CSV.
#
-# What you don't want to do is to feed CSV invalid data. Because of the way the
+# What you don't want to do is feed CSV invalid data. Because of the way the
# CSV format works, it's common for a parser to need to read until the end of
-# the file to be sure a field is invalid. This consumes a lot of time and memory.
+# the file to be sure a field is invalid. This eats a lot of time and memory.
#
# Luckily, when working with invalid CSV, Ruby's built-in methods will almost
-# always be superior in every way. For example, parsing non-quoted fields is as
+# always be superior in every way. For example, parsing non-quoted fields is as
# easy as:
#
# data.split(",")
@@ -94,187 +96,823 @@ require "English"
require "date"
require "stringio"
-require_relative "csv/fields_converter"
-require_relative "csv/match_p"
-require_relative "csv/parser"
-require_relative "csv/row"
-require_relative "csv/table"
-require_relative "csv/writer"
-
-using CSV::MatchP if CSV.const_defined?(:MatchP)
-
#
-# This class provides a complete interface to CSV files and data. It offers
+# This class provides a complete interface to CSV files and data. It offers
# tools to enable you to read and write to and from Strings or IO objects, as
# needed.
#
-# The most generic interface of the library is:
-#
-# csv = CSV.new(string_or_io, **options)
+# == Reading
#
-# # Reading: IO object should be open for read
-# csv.read # => array of rows
-# # or
-# csv.each do |row|
-# # ...
-# end
-# # or
-# row = csv.shift
+# === From a File
#
-# # Writing: IO object should be open for write
-# csv << row
+# ==== A Line at a Time
#
-# There are several specialized class methods for one-statement reading or writing,
-# described in the Specialized Methods section.
+# CSV.foreach("path/to/file.csv") do |row|
+# # use row here...
+# end
#
-# If a String is passed into ::new, it is internally wrapped into a StringIO object.
+# ==== All at Once
#
-# +options+ can be used for specifying the particular CSV flavor (column
-# separators, row separators, value quoting and so on), and for data conversion,
-# see Data Conversion section for the description of the latter.
+# arr_of_arrs = CSV.read("path/to/file.csv")
#
-# == Specialized Methods
+# === From a String
#
-# === Reading
+# ==== A Line at a Time
#
-# # From a file: all at once
-# arr_of_rows = CSV.read("path/to/file.csv", **options)
-# # iterator-style:
-# CSV.foreach("path/to/file.csv", **options) do |row|
-# # ...
+# CSV.parse("CSV,data,String") do |row|
+# # use row here...
# end
#
-# # From a string
-# arr_of_rows = CSV.parse("CSV,data,String", **options)
-# # or
-# CSV.parse("CSV,data,String", **options) do |row|
-# # ...
-# end
+# ==== All at Once
+#
+# arr_of_arrs = CSV.parse("CSV,data,String")
#
-# === Writing
+# == Writing
+#
+# === To a File
#
-# # To a file
# CSV.open("path/to/file.csv", "wb") do |csv|
# csv << ["row", "of", "CSV", "data"]
# csv << ["another", "row"]
# # ...
# end
#
-# # To a String
+# === To a String
+#
# csv_string = CSV.generate do |csv|
# csv << ["row", "of", "CSV", "data"]
# csv << ["another", "row"]
# # ...
# end
#
-# === Shortcuts
+# == Convert a Single Line
#
-# # Core extensions for converting one line
# csv_string = ["CSV", "data"].to_csv # to CSV
# csv_array = "CSV,String".parse_csv # from CSV
#
-# # CSV() method
+# == Shortcut Interface
+#
# CSV { |csv_out| csv_out << %w{my data here} } # to $stdout
# CSV(csv = "") { |csv_str| csv_str << %w{my data here} } # to a String
# CSV($stderr) { |csv_err| csv_err << %w{my data here} } # to $stderr
# CSV($stdin) { |csv_in| csv_in.each { |row| p row } } # from $stdin
#
-# == Data Conversion
-#
-# === CSV with headers
-#
-# CSV allows to specify column names of CSV file, whether they are in data, or
-# provided separately. If headers are specified, reading methods return an instance
-# of CSV::Table, consisting of CSV::Row.
-#
-# # Headers are part of data
-# data = CSV.parse(<<~ROWS, headers: true)
-# Name,Department,Salary
-# Bob,Engineering,1000
-# Jane,Sales,2000
-# John,Management,5000
-# ROWS
-#
-# data.class #=> CSV::Table
-# data.first #=> #<CSV::Row "Name":"Bob" "Department":"Engineering" "Salary":"1000">
-# data.first.to_h #=> {"Name"=>"Bob", "Department"=>"Engineering", "Salary"=>"1000"}
-#
-# # Headers provided by developer
-# data = CSV.parse('Bob,Engineering,1000', headers: %i[name department salary])
-# data.first #=> #<CSV::Row name:"Bob" department:"Engineering" salary:"1000">
-#
-# === Typed data reading
-#
-# CSV allows to provide a set of data _converters_ e.g. transformations to try on input
-# data. Converter could be a symbol from CSV::Converters constant's keys, or lambda.
-#
-# # Without any converters:
-# CSV.parse('Bob,2018-03-01,100')
-# #=> [["Bob", "2018-03-01", "100"]]
+# == Advanced Usage
#
-# # With built-in converters:
-# CSV.parse('Bob,2018-03-01,100', converters: %i[numeric date])
-# #=> [["Bob", #<Date: 2018-03-01>, 100]]
+# === Wrap an IO Object
#
-# # With custom converters:
-# CSV.parse('Bob,2018-03-01,100', converters: [->(v) { Time.parse(v) rescue v }])
-# #=> [["Bob", 2018-03-01 00:00:00 +0200, "100"]]
+# csv = CSV.new(io, options)
+# # ... read (with gets() or each()) from and write (with <<) to csv here ...
#
# == CSV and Character Encodings (M17n or Multilingualization)
#
# This new CSV parser is m17n savvy. The parser works in the Encoding of the IO
-# or String object being read from or written to. Your data is never transcoded
+# or String object being read from or written to. Your data is never transcoded
# (unless you ask Ruby to transcode it for you) and will literally be parsed in
-# the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the
-# Encoding of your data. This is accomplished by transcoding the parser itself
+# the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the
+# Encoding of your data. This is accomplished by transcoding the parser itself
# into your Encoding.
#
# Some transcoding must take place, of course, to accomplish this multiencoding
-# support. For example, <tt>:col_sep</tt>, <tt>:row_sep</tt>, and
+# support. For example, <tt>:col_sep</tt>, <tt>:row_sep</tt>, and
# <tt>:quote_char</tt> must be transcoded to match your data. Hopefully this
# makes the entire process feel transparent, since CSV's defaults should just
-# magically work for your data. However, you can set these values manually in
+# magically work for your data. However, you can set these values manually in
# the target Encoding to avoid the translation.
#
# It's also important to note that while all of CSV's core parser is now
-# Encoding agnostic, some features are not. For example, the built-in
+# Encoding agnostic, some features are not. For example, the built-in
# converters will try to transcode data to UTF-8 before making conversions.
# Again, you can provide custom converters that are aware of your Encodings to
-# avoid this translation. It's just too hard for me to support native
+# avoid this translation. It's just too hard for me to support native
# conversions in all of Ruby's Encodings.
#
-# Anyway, the practical side of this is simple: make sure IO and String objects
+# Anyway, the practical side of this is simple: make sure IO and String objects
# passed into CSV have the proper Encoding set and everything should just work.
# CSV methods that allow you to open IO objects (CSV::foreach(), CSV::open(),
# CSV::read(), and CSV::readlines()) do allow you to specify the Encoding.
#
# One minor exception comes when generating CSV into a String with an Encoding
-# that is not ASCII compatible. There's no existing data for CSV to use to
+# that is not ASCII compatible. There's no existing data for CSV to use to
# prepare itself and thus you will probably need to manually specify the desired
-# Encoding for most of those cases. It will try to guess using the fields in a
+# Encoding for most of those cases. It will try to guess using the fields in a
# row of output though, when using CSV::generate_line() or Array#to_csv().
#
# I try to point out any other Encoding issues in the documentation of methods
# as they come up.
#
# This has been tested to the best of my ability with all non-"dummy" Encodings
-# Ruby ships with. However, it is brave new code and may have some bugs.
+# Ruby ships with. However, it is brave new code and may have some bugs.
# Please feel free to {report}[mailto:james@grayproductions.net] any issues you
# find with it.
#
class CSV
+ # The version of the installed library.
+ VERSION = "2.4.8"
- # The error thrown when the parser encounters illegal CSV formatting.
- class MalformedCSVError < RuntimeError
- attr_reader :line_number
- alias_method :lineno, :line_number
- def initialize(message, line_number)
- @line_number = line_number
- super("#{message} in line #{line_number}.")
+ #
+ # A CSV::Row is part Array and part Hash. It retains an order for the fields
+ # and allows duplicates just as an Array would, but also allows you to access
+ # fields by name just as you could if they were in a Hash.
+ #
+ # All rows returned by CSV will be constructed from this class, if header row
+ # processing is activated.
+ #
+ class Row
+ #
+ # Construct a new CSV::Row from +headers+ and +fields+, which are expected
+ # to be Arrays. If one Array is shorter than the other, it will be padded
+ # with +nil+ objects.
+ #
+ # The optional +header_row+ parameter can be set to +true+ to indicate, via
+ # CSV::Row.header_row?() and CSV::Row.field_row?(), that this is a header
+ # row. Otherwise, the row is assumes to be a field row.
+ #
+ # A CSV::Row object supports the following Array methods through delegation:
+ #
+ # * empty?()
+ # * length()
+ # * size()
+ #
+ def initialize(headers, fields, header_row = false)
+ @header_row = header_row
+ headers.each { |h| h.freeze if h.is_a? String }
+
+ # handle extra headers or fields
+ @row = if headers.size >= fields.size
+ headers.zip(fields)
+ else
+ fields.zip(headers).each(&:reverse!)
+ end
+ end
+
+ # Internal data format used to compare equality.
+ attr_reader :row
+ protected :row
+
+ ### Array Delegation ###
+
+ extend Forwardable
+ def_delegators :@row, :empty?, :length, :size
+
+ # Returns +true+ if this is a header row.
+ def header_row?
+ @header_row
+ end
+
+ # Returns +true+ if this is a field row.
+ def field_row?
+ not header_row?
+ end
+
+ # Returns the headers of this row.
+ def headers
+ @row.map(&:first)
+ end
+
+ #
+ # :call-seq:
+ # field( header )
+ # field( header, offset )
+ # field( index )
+ #
+ # This method will return the field value by +header+ or +index+. If a field
+ # is not found, +nil+ is returned.
+ #
+ # When provided, +offset+ ensures that a header match occurs on or later
+ # than the +offset+ index. You can use this to find duplicate headers,
+ # without resorting to hard-coding exact indices.
+ #
+ def field(header_or_index, minimum_index = 0)
+ # locate the pair
+ finder = (header_or_index.is_a?(Integer) || header_or_index.is_a?(Range)) ? :[] : :assoc
+ pair = @row[minimum_index..-1].send(finder, header_or_index)
+
+ # return the field if we have a pair
+ if pair.nil?
+ nil
+ else
+ header_or_index.is_a?(Range) ? pair.map(&:last) : pair.last
+ end
+ end
+ alias_method :[], :field
+
+ #
+ # :call-seq:
+ # fetch( header )
+ # fetch( header ) { |row| ... }
+ # fetch( header, default )
+ #
+ # This method will fetch the field value by +header+. It has the same
+ # behavior as Hash#fetch: if there is a field with the given +header+, its
+ # value is returned. Otherwise, if a block is given, it is yielded the
+ # +header+ and its result is returned; if a +default+ is given as the
+ # second argument, it is returned; otherwise a KeyError is raised.
+ #
+ def fetch(header, *varargs)
+ raise ArgumentError, "Too many arguments" if varargs.length > 1
+ pair = @row.assoc(header)
+ if pair
+ pair.last
+ else
+ if block_given?
+ yield header
+ elsif varargs.empty?
+ raise KeyError, "key not found: #{header}"
+ else
+ varargs.first
+ end
+ end
+ end
+
+ # Returns +true+ if there is a field with the given +header+.
+ def has_key?(header)
+ !!@row.assoc(header)
+ end
+ alias_method :include?, :has_key?
+ alias_method :key?, :has_key?
+ alias_method :member?, :has_key?
+
+ #
+ # :call-seq:
+ # []=( header, value )
+ # []=( header, offset, value )
+ # []=( index, value )
+ #
+ # Looks up the field by the semantics described in CSV::Row.field() and
+ # assigns the +value+.
+ #
+ # Assigning past the end of the row with an index will set all pairs between
+ # to <tt>[nil, nil]</tt>. Assigning to an unused header appends the new
+ # pair.
+ #
+ def []=(*args)
+ value = args.pop
+
+ if args.first.is_a? Integer
+ if @row[args.first].nil? # extending past the end with index
+ @row[args.first] = [nil, value]
+ @row.map! { |pair| pair.nil? ? [nil, nil] : pair }
+ else # normal index assignment
+ @row[args.first][1] = value
+ end
+ else
+ index = index(*args)
+ if index.nil? # appending a field
+ self << [args.first, value]
+ else # normal header assignment
+ @row[index][1] = value
+ end
+ end
+ end
+
+ #
+ # :call-seq:
+ # <<( field )
+ # <<( header_and_field_array )
+ # <<( header_and_field_hash )
+ #
+ # If a two-element Array is provided, it is assumed to be a header and field
+ # and the pair is appended. A Hash works the same way with the key being
+ # the header and the value being the field. Anything else is assumed to be
+ # a lone field which is appended with a +nil+ header.
+ #
+ # This method returns the row for chaining.
+ #
+ def <<(arg)
+ if arg.is_a?(Array) and arg.size == 2 # appending a header and name
+ @row << arg
+ elsif arg.is_a?(Hash) # append header and name pairs
+ arg.each { |pair| @row << pair }
+ else # append field value
+ @row << [nil, arg]
+ end
+
+ self # for chaining
+ end
+
+ #
+ # A shortcut for appending multiple fields. Equivalent to:
+ #
+ # args.each { |arg| csv_row << arg }
+ #
+ # This method returns the row for chaining.
+ #
+ def push(*args)
+ args.each { |arg| self << arg }
+
+ self # for chaining
+ end
+
+ #
+ # :call-seq:
+ # delete( header )
+ # delete( header, offset )
+ # delete( index )
+ #
+ # Used to remove a pair from the row by +header+ or +index+. The pair is
+ # located as described in CSV::Row.field(). The deleted pair is returned,
+ # or +nil+ if a pair could not be found.
+ #
+ def delete(header_or_index, minimum_index = 0)
+ if header_or_index.is_a? Integer # by index
+ @row.delete_at(header_or_index)
+ elsif i = index(header_or_index, minimum_index) # by header
+ @row.delete_at(i)
+ else
+ [ ]
+ end
+ end
+
+ #
+ # The provided +block+ is passed a header and field for each pair in the row
+ # and expected to return +true+ or +false+, depending on whether the pair
+ # should be deleted.
+ #
+ # This method returns the row for chaining.
+ #
+ # If no block is given, an Enumerator is returned.
+ #
+ def delete_if(&block)
+ block or return enum_for(__method__) { size }
+
+ @row.delete_if(&block)
+
+ self # for chaining
+ end
+
+ #
+ # This method accepts any number of arguments which can be headers, indices,
+ # Ranges of either, or two-element Arrays containing a header and offset.
+ # Each argument will be replaced with a field lookup as described in
+ # CSV::Row.field().
+ #
+ # If called with no arguments, all fields are returned.
+ #
+ def fields(*headers_and_or_indices)
+ if headers_and_or_indices.empty? # return all fields--no arguments
+ @row.map(&:last)
+ else # or work like values_at()
+ all = []
+ headers_and_or_indices.each do |h_or_i|
+ if h_or_i.is_a? Range
+ index_begin = h_or_i.begin.is_a?(Integer) ? h_or_i.begin :
+ index(h_or_i.begin)
+ index_end = h_or_i.end.is_a?(Integer) ? h_or_i.end :
+ index(h_or_i.end)
+ new_range = h_or_i.exclude_end? ? (index_begin...index_end) :
+ (index_begin..index_end)
+ all.concat(fields.values_at(new_range))
+ else
+ all << field(*Array(h_or_i))
+ end
+ end
+ return all
+ end
+ end
+ alias_method :values_at, :fields
+
+ #
+ # :call-seq:
+ # index( header )
+ # index( header, offset )
+ #
+ # This method will return the index of a field with the provided +header+.
+ # The +offset+ can be used to locate duplicate header names, as described in
+ # CSV::Row.field().
+ #
+ def index(header, minimum_index = 0)
+ # find the pair
+ index = headers[minimum_index..-1].index(header)
+ # return the index at the right offset, if we found one
+ index.nil? ? nil : index + minimum_index
+ end
+
+ # Returns +true+ if +name+ is a header for this row, and +false+ otherwise.
+ def header?(name)
+ headers.include? name
+ end
+ alias_method :include?, :header?
+
+ #
+ # Returns +true+ if +data+ matches a field in this row, and +false+
+ # otherwise.
+ #
+ def field?(data)
+ fields.include? data
+ end
+
+ include Enumerable
+
+ #
+ # Yields each pair of the row as header and field tuples (much like
+ # iterating over a Hash). This method returns the row for chaining.
+ #
+ # If no block is given, an Enumerator is returned.
+ #
+ # Support for Enumerable.
+ #
+ def each(&block)
+ block or return enum_for(__method__) { size }
+
+ @row.each(&block)
+
+ self # for chaining
+ end
+
+ #
+ # Returns +true+ if this row contains the same headers and fields in the
+ # same order as +other+.
+ #
+ def ==(other)
+ return @row == other.row if other.is_a? CSV::Row
+ @row == other
+ end
+
+ #
+ # Collapses the row into a simple Hash. Be warned that this discards field
+ # order and clobbers duplicate fields.
+ #
+ def to_hash
+ @row.to_h
+ end
+
+ #
+ # Returns the row as a CSV String. Headers are not used. Equivalent to:
+ #
+ # csv_row.fields.to_csv( options )
+ #
+ def to_csv(**options)
+ fields.to_csv(options)
+ end
+ alias_method :to_s, :to_csv
+
+ # A summary of fields, by header, in an ASCII compatible String.
+ def inspect
+ str = ["#<", self.class.to_s]
+ each do |header, field|
+ str << " " << (header.is_a?(Symbol) ? header.to_s : header.inspect) <<
+ ":" << field.inspect
+ end
+ str << ">"
+ begin
+ str.join('')
+ rescue # any encoding error
+ str.map do |s|
+ e = Encoding::Converter.asciicompat_encoding(s.encoding)
+ e ? s.encode(e) : s.force_encoding("ASCII-8BIT")
+ end.join('')
+ end
end
end
#
+ # A CSV::Table is a two-dimensional data structure for representing CSV
+ # documents. Tables allow you to work with the data by row or column,
+ # manipulate the data, and even convert the results back to CSV, if needed.
+ #
+ # All tables returned by CSV will be constructed from this class, if header
+ # row processing is activated.
+ #
+ class Table
+ #
+ # Construct a new CSV::Table from +array_of_rows+, which are expected
+ # to be CSV::Row objects. All rows are assumed to have the same headers.
+ #
+ # A CSV::Table object supports the following Array methods through
+ # delegation:
+ #
+ # * empty?()
+ # * length()
+ # * size()
+ #
+ def initialize(array_of_rows)
+ @table = array_of_rows
+ @mode = :col_or_row
+ end
+
+ # The current access mode for indexing and iteration.
+ attr_reader :mode
+
+ # Internal data format used to compare equality.
+ attr_reader :table
+ protected :table
+
+ ### Array Delegation ###
+
+ extend Forwardable
+ def_delegators :@table, :empty?, :length, :size
+
+ #
+ # Returns a duplicate table object, in column mode. This is handy for
+ # chaining in a single call without changing the table mode, but be aware
+ # that this method can consume a fair amount of memory for bigger data sets.
+ #
+ # This method returns the duplicate table for chaining. Don't chain
+ # destructive methods (like []=()) this way though, since you are working
+ # with a duplicate.
+ #
+ def by_col
+ self.class.new(@table.dup).by_col!
+ end
+
+ #
+ # Switches the mode of this table to column mode. All calls to indexing and
+ # iteration methods will work with columns until the mode is changed again.
+ #
+ # This method returns the table and is safe to chain.
+ #
+ def by_col!
+ @mode = :col
+
+ self
+ end
+
+ #
+ # Returns a duplicate table object, in mixed mode. This is handy for
+ # chaining in a single call without changing the table mode, but be aware
+ # that this method can consume a fair amount of memory for bigger data sets.
+ #
+ # This method returns the duplicate table for chaining. Don't chain
+ # destructive methods (like []=()) this way though, since you are working
+ # with a duplicate.
+ #
+ def by_col_or_row
+ self.class.new(@table.dup).by_col_or_row!
+ end
+
+ #
+ # Switches the mode of this table to mixed mode. All calls to indexing and
+ # iteration methods will use the default intelligent indexing system until
+ # the mode is changed again. In mixed mode an index is assumed to be a row
+ # reference while anything else is assumed to be column access by headers.
+ #
+ # This method returns the table and is safe to chain.
+ #
+ def by_col_or_row!
+ @mode = :col_or_row
+
+ self
+ end
+
+ #
+ # Returns a duplicate table object, in row mode. This is handy for chaining
+ # in a single call without changing the table mode, but be aware that this
+ # method can consume a fair amount of memory for bigger data sets.
+ #
+ # This method returns the duplicate table for chaining. Don't chain
+ # destructive methods (like []=()) this way though, since you are working
+ # with a duplicate.
+ #
+ def by_row
+ self.class.new(@table.dup).by_row!
+ end
+
+ #
+ # Switches the mode of this table to row mode. All calls to indexing and
+ # iteration methods will work with rows until the mode is changed again.
+ #
+ # This method returns the table and is safe to chain.
+ #
+ def by_row!
+ @mode = :row
+
+ self
+ end
+
+ #
+ # Returns the headers for the first row of this table (assumed to match all
+ # other rows). An empty Array is returned for empty tables.
+ #
+ def headers
+ if @table.empty?
+ Array.new
+ else
+ @table.first.headers
+ end
+ end
+
+ #
+ # In the default mixed mode, this method returns rows for index access and
+ # columns for header access. You can force the index association by first
+ # calling by_col!() or by_row!().
+ #
+ # Columns are returned as an Array of values. Altering that Array has no
+ # effect on the table.
+ #
+ def [](index_or_header)
+ if @mode == :row or # by index
+ (@mode == :col_or_row and (index_or_header.is_a?(Integer) or index_or_header.is_a?(Range)))
+ @table[index_or_header]
+ else # by header
+ @table.map { |row| row[index_or_header] }
+ end
+ end
+
+ #
+ # In the default mixed mode, this method assigns rows for index access and
+ # columns for header access. You can force the index association by first
+ # calling by_col!() or by_row!().
+ #
+ # Rows may be set to an Array of values (which will inherit the table's
+ # headers()) or a CSV::Row.
+ #
+ # Columns may be set to a single value, which is copied to each row of the
+ # column, or an Array of values. Arrays of values are assigned to rows top
+ # to bottom in row major order. Excess values are ignored and if the Array
+ # does not have a value for each row the extra rows will receive a +nil+.
+ #
+ # Assigning to an existing column or row clobbers the data. Assigning to
+ # new columns creates them at the right end of the table.
+ #
+ def []=(index_or_header, value)
+ if @mode == :row or # by index
+ (@mode == :col_or_row and index_or_header.is_a? Integer)
+ if value.is_a? Array
+ @table[index_or_header] = Row.new(headers, value)
+ else
+ @table[index_or_header] = value
+ end
+ else # set column
+ if value.is_a? Array # multiple values
+ @table.each_with_index do |row, i|
+ if row.header_row?
+ row[index_or_header] = index_or_header
+ else
+ row[index_or_header] = value[i]
+ end
+ end
+ else # repeated value
+ @table.each do |row|
+ if row.header_row?
+ row[index_or_header] = index_or_header
+ else
+ row[index_or_header] = value
+ end
+ end
+ end
+ end
+ end
+
+ #
+ # The mixed mode default is to treat a list of indices as row access,
+ # returning the rows indicated. Anything else is considered columnar
+ # access. For columnar access, the return set has an Array for each row
+ # with the values indicated by the headers in each Array. You can force
+ # column or row mode using by_col!() or by_row!().
+ #
+ # You cannot mix column and row access.
+ #
+ def values_at(*indices_or_headers)
+ if @mode == :row or # by indices
+ ( @mode == :col_or_row and indices_or_headers.all? do |index|
+ index.is_a?(Integer) or
+ ( index.is_a?(Range) and
+ index.first.is_a?(Integer) and
+ index.last.is_a?(Integer) )
+ end )
+ @table.values_at(*indices_or_headers)
+ else # by headers
+ @table.map { |row| row.values_at(*indices_or_headers) }
+ end
+ end
+
+ #
+ # Adds a new row to the bottom end of this table. You can provide an Array,
+ # which will be converted to a CSV::Row (inheriting the table's headers()),
+ # or a CSV::Row.
+ #
+ # This method returns the table for chaining.
+ #
+ def <<(row_or_array)
+ if row_or_array.is_a? Array # append Array
+ @table << Row.new(headers, row_or_array)
+ else # append Row
+ @table << row_or_array
+ end
+
+ self # for chaining
+ end
+
+ #
+ # A shortcut for appending multiple rows. Equivalent to:
+ #
+ # rows.each { |row| self << row }
+ #
+ # This method returns the table for chaining.
+ #
+ def push(*rows)
+ rows.each { |row| self << row }
+
+ self # for chaining
+ end
+
+ #
+ # Removes and returns the indicated column or row. In the default mixed
+ # mode indices refer to rows and everything else is assumed to be a column
+ # header. Use by_col!() or by_row!() to force the lookup.
+ #
+ def delete(index_or_header)
+ if @mode == :row or # by index
+ (@mode == :col_or_row and index_or_header.is_a? Integer)
+ @table.delete_at(index_or_header)
+ else # by header
+ @table.map { |row| row.delete(index_or_header).last }
+ end
+ end
+
+ #
+ # Removes any column or row for which the block returns +true+. In the
+ # default mixed mode or row mode, iteration is the standard row major
+ # walking of rows. In column mode, iteration will +yield+ two element
+ # tuples containing the column name and an Array of values for that column.
+ #
+ # This method returns the table for chaining.
+ #
+ # If no block is given, an Enumerator is returned.
+ #
+ def delete_if(&block)
+ block or return enum_for(__method__) { @mode == :row or @mode == :col_or_row ? size : headers.size }
+
+ if @mode == :row or @mode == :col_or_row # by index
+ @table.delete_if(&block)
+ else # by header
+ deleted = []
+ headers.each do |header|
+ deleted << delete(header) if block[[header, self[header]]]
+ end
+ end
+
+ self # for chaining
+ end
+
+ include Enumerable
+
+ #
+ # In the default mixed mode or row mode, iteration is the standard row major
+ # walking of rows. In column mode, iteration will +yield+ two element
+ # tuples containing the column name and an Array of values for that column.
+ #
+ # This method returns the table for chaining.
+ #
+ # If no block is given, an Enumerator is returned.
+ #
+ def each(&block)
+ block or return enum_for(__method__) { @mode == :col ? headers.size : size }
+
+ if @mode == :col
+ headers.each { |header| block[[header, self[header]]] }
+ else
+ @table.each(&block)
+ end
+
+ self # for chaining
+ end
+
+ # Returns +true+ if all rows of this table ==() +other+'s rows.
+ def ==(other)
+ return @table == other.table if other.is_a? CSV::Table
+ @table == other
+ end
+
+ #
+ # Returns the table as an Array of Arrays. Headers will be the first row,
+ # then all of the field rows will follow.
+ #
+ def to_a
+ array = [headers]
+ @table.each do |row|
+ array.push(row.fields) unless row.header_row?
+ end
+ return array
+ end
+
+ #
+ # Returns the table as a complete CSV String. Headers will be listed first,
+ # then all of the field rows.
+ #
+ # This method assumes you want the Table.headers(), unless you explicitly
+ # pass <tt>:write_headers => false</tt>.
+ #
+ def to_csv(write_headers: true, **options)
+ array = write_headers ? [headers.to_csv(options)] : []
+ @table.each do |row|
+ array.push(row.fields.to_csv(options)) unless row.header_row?
+ end
+ return array.join('')
+ end
+ alias_method :to_s, :to_csv
+
+ # Shows the mode and size of this table in a US-ASCII String.
+ def inspect
+ "#<#{self.class} mode:#{@mode} row_count:#{to_a.size}>".encode("US-ASCII")
+ end
+ end
+
+ # The error thrown when the parser encounters illegal CSV formatting.
+ class MalformedCSVError < RuntimeError; end
+
+ #
# A FieldInfo Struct contains details about a field's position in the data
# source it was read from. CSV will pass this Struct to some blocks that make
# decisions based on field structure. See CSV.convert_fields() for an
@@ -292,11 +930,7 @@ class CSV
# A Regexp used to find and convert some common DateTime formats.
DateTimeMatcher =
/ \A(?: (\w+,?\s+)?\w+\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2},?\s+\d{2,4} |
- \d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2} |
- # ISO-8601
- \d{4}-\d{2}-\d{2}
- (?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?(?:[+-]\d{2}(?::\d{2})|Z)?)?)?
- )\z /x
+ \d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2} )\z /x
# The encoding used by all converters.
ConverterEncoding = Encoding.find("UTF-8")
@@ -336,7 +970,7 @@ class CSV
date: lambda { |f|
begin
e = f.encode(ConverterEncoding)
- e.match?(DateMatcher) ? Date.parse(e) : f
+ e =~ DateMatcher ? Date.parse(e) : f
rescue # encoding conversion or date parse errors
f
end
@@ -344,7 +978,7 @@ class CSV
date_time: lambda { |f|
begin
e = f.encode(ConverterEncoding)
- e.match?(DateTimeMatcher) ? DateTime.parse(e) : f
+ e =~ DateTimeMatcher ? DateTime.parse(e) : f
rescue # encoding conversion or date parse errors
f
end
@@ -354,7 +988,7 @@ class CSV
#
# This Hash holds the built-in header converters of CSV that can be accessed
- # by name. You can select HeaderConverters with CSV.header_convert() or
+ # by name. You can select HeaderConverters with CSV.header_convert() or
# through the +options+ Hash passed to CSV::new().
#
# <b><tt>:downcase</tt></b>:: Calls downcase() on the header String.
@@ -364,13 +998,13 @@ class CSV
# and finally to_sym() is called.
#
# All built-in header converters transcode header data to UTF-8 before
- # attempting a conversion. If your data cannot be transcoded to UTF-8 the
+ # attempting a conversion. If your data cannot be transcoded to UTF-8 the
# conversion will fail and the header will remain unchanged.
#
# This Hash is intentionally left unfrozen and users should feel free to add
# values to it that can be accessed by all CSV objects.
#
- # To add a combo field, the value should be an Array of names. Combo fields
+ # To add a combo field, the value should be an Array of names. Combo fields
# can be nested with other combo fields.
#
HeaderConverters = {
@@ -382,7 +1016,7 @@ class CSV
}
#
- # The options used when no overrides are given by calling code. They are:
+ # The options used when no overrides are given by calling code. They are:
#
# <b><tt>:col_sep</tt></b>:: <tt>","</tt>
# <b><tt>:row_sep</tt></b>:: <tt>:auto</tt>
@@ -397,7 +1031,6 @@ class CSV
# <b><tt>:force_quotes</tt></b>:: +false+
# <b><tt>:skip_lines</tt></b>:: +nil+
# <b><tt>:liberal_parsing</tt></b>:: +false+
- # <b><tt>:quote_empty</tt></b>:: +true+
#
DEFAULT_OPTIONS = {
col_sep: ",",
@@ -413,340 +1046,333 @@ class CSV
force_quotes: false,
skip_lines: nil,
liberal_parsing: false,
- quote_empty: true,
}.freeze
- class << self
- #
- # This method will return a CSV instance, just like CSV::new(), but the
- # instance will be cached and returned for all future calls to this method for
- # the same +data+ object (tested by Object#object_id()) with the same
- # +options+.
- #
- # If a block is given, the instance is passed to the block and the return
- # value becomes the return value of the block.
- #
- def instance(data = $stdout, **options)
- # create a _signature_ for this method call, data object and options
- sig = [data.object_id] +
- options.values_at(*DEFAULT_OPTIONS.keys.sort_by { |sym| sym.to_s })
+ #
+ # This method will return a CSV instance, just like CSV::new(), but the
+ # instance will be cached and returned for all future calls to this method for
+ # the same +data+ object (tested by Object#object_id()) with the same
+ # +options+.
+ #
+ # If a block is given, the instance is passed to the block and the return
+ # value becomes the return value of the block.
+ #
+ def self.instance(data = $stdout, **options)
+ # create a _signature_ for this method call, data object and options
+ sig = [data.object_id] +
+ options.values_at(*DEFAULT_OPTIONS.keys.sort_by { |sym| sym.to_s })
- # fetch or create the instance for this signature
- @@instances ||= Hash.new
- instance = (@@instances[sig] ||= new(data, **options))
+ # fetch or create the instance for this signature
+ @@instances ||= Hash.new
+ instance = (@@instances[sig] ||= new(data, options))
- if block_given?
- yield instance # run block, if given, returning result
- else
- instance # or return the instance
- end
+ if block_given?
+ yield instance # run block, if given, returning result
+ else
+ instance # or return the instance
end
+ end
- #
- # :call-seq:
- # filter( **options ) { |row| ... }
- # filter( input, **options ) { |row| ... }
- # filter( input, output, **options ) { |row| ... }
- #
- # This method is a convenience for building Unix-like filters for CSV data.
- # Each row is yielded to the provided block which can alter it as needed.
- # After the block returns, the row is appended to +output+ altered or not.
- #
- # The +input+ and +output+ arguments can be anything CSV::new() accepts
- # (generally String or IO objects). If not given, they default to
- # <tt>ARGF</tt> and <tt>$stdout</tt>.
- #
- # The +options+ parameter is also filtered down to CSV::new() after some
- # clever key parsing. Any key beginning with <tt>:in_</tt> or
- # <tt>:input_</tt> will have that leading identifier stripped and will only
- # be used in the +options+ Hash for the +input+ object. Keys starting with
- # <tt>:out_</tt> or <tt>:output_</tt> affect only +output+. All other keys
- # are assigned to both objects.
- #
- # The <tt>:output_row_sep</tt> +option+ defaults to
- # <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>).
- #
- def filter(input=nil, output=nil, **options)
- # parse options for input, output, or both
- in_options, out_options = Hash.new, {row_sep: $INPUT_RECORD_SEPARATOR}
- options.each do |key, value|
- case key.to_s
- when /\Ain(?:put)?_(.+)\Z/
- in_options[$1.to_sym] = value
- when /\Aout(?:put)?_(.+)\Z/
- out_options[$1.to_sym] = value
- else
- in_options[key] = value
- out_options[key] = value
- end
- end
- # build input and output wrappers
- input = new(input || ARGF, **in_options)
- output = new(output || $stdout, **out_options)
-
- # read, yield, write
- input.each do |row|
- yield row
- output << row
+ #
+ # :call-seq:
+ # filter( **options ) { |row| ... }
+ # filter( input, **options ) { |row| ... }
+ # filter( input, output, **options ) { |row| ... }
+ #
+ # This method is a convenience for building Unix-like filters for CSV data.
+ # Each row is yielded to the provided block which can alter it as needed.
+ # After the block returns, the row is appended to +output+ altered or not.
+ #
+ # The +input+ and +output+ arguments can be anything CSV::new() accepts
+ # (generally String or IO objects). If not given, they default to
+ # <tt>ARGF</tt> and <tt>$stdout</tt>.
+ #
+ # The +options+ parameter is also filtered down to CSV::new() after some
+ # clever key parsing. Any key beginning with <tt>:in_</tt> or
+ # <tt>:input_</tt> will have that leading identifier stripped and will only
+ # be used in the +options+ Hash for the +input+ object. Keys starting with
+ # <tt>:out_</tt> or <tt>:output_</tt> affect only +output+. All other keys
+ # are assigned to both objects.
+ #
+ # The <tt>:output_row_sep</tt> +option+ defaults to
+ # <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>).
+ #
+ def self.filter(input=nil, output=nil, **options)
+ # parse options for input, output, or both
+ in_options, out_options = Hash.new, {row_sep: $INPUT_RECORD_SEPARATOR}
+ options.each do |key, value|
+ case key.to_s
+ when /\Ain(?:put)?_(.+)\Z/
+ in_options[$1.to_sym] = value
+ when /\Aout(?:put)?_(.+)\Z/
+ out_options[$1.to_sym] = value
+ else
+ in_options[key] = value
+ out_options[key] = value
end
end
+ # build input and output wrappers
+ input = new(input || ARGF, in_options)
+ output = new(output || $stdout, out_options)
+
+ # read, yield, write
+ input.each do |row|
+ yield row
+ output << row
+ end
+ end
- #
- # This method is intended as the primary interface for reading CSV files. You
- # pass a +path+ and any +options+ you wish to set for the read. Each row of
- # file will be passed to the provided +block+ in turn.
- #
- # The +options+ parameter can be anything CSV::new() understands. This method
- # also understands an additional <tt>:encoding</tt> parameter that you can use
- # to specify the Encoding of the data in the file to be read. You must provide
- # this unless your data is in Encoding::default_external(). CSV will use this
- # to determine how to parse the data. You may provide a second Encoding to
- # have the data transcoded as it is read. For example,
- # <tt>encoding: "UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file
- # but transcode it to UTF-8 before CSV parses it.
- #
- def foreach(path, mode="r", **options, &block)
- return to_enum(__method__, path, mode, **options) unless block_given?
- open(path, mode, **options) do |csv|
- csv.each(&block)
- end
+ #
+ # This method is intended as the primary interface for reading CSV files. You
+ # pass a +path+ and any +options+ you wish to set for the read. Each row of
+ # file will be passed to the provided +block+ in turn.
+ #
+ # The +options+ parameter can be anything CSV::new() understands. This method
+ # also understands an additional <tt>:encoding</tt> parameter that you can use
+ # to specify the Encoding of the data in the file to be read. You must provide
+ # this unless your data is in Encoding::default_external(). CSV will use this
+ # to determine how to parse the data. You may provide a second Encoding to
+ # have the data transcoded as it is read. For example,
+ # <tt>encoding: "UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file
+ # but transcode it to UTF-8 before CSV parses it.
+ #
+ def self.foreach(path, **options, &block)
+ return to_enum(__method__, path, options) unless block
+ open(path, options) do |csv|
+ csv.each(&block)
end
+ end
- #
- # :call-seq:
- # generate( str, **options ) { |csv| ... }
- # generate( **options ) { |csv| ... }
- #
- # This method wraps a String you provide, or an empty default String, in a
- # CSV object which is passed to the provided block. You can use the block to
- # append CSV rows to the String and when the block exits, the final String
- # will be returned.
- #
- # Note that a passed String *is* modified by this method. Call dup() before
- # passing if you need a new String.
- #
- # The +options+ parameter can be anything CSV::new() understands. This method
- # understands an additional <tt>:encoding</tt> parameter when not passed a
- # String to set the base Encoding for the output. CSV needs this hint if you
- # plan to output non-ASCII compatible data.
- #
- def generate(str=nil, **options)
- # add a default empty String, if none was given
- if str
- str = StringIO.new(str)
- str.seek(0, IO::SEEK_END)
- else
- encoding = options[:encoding]
- str = +""
- str.force_encoding(encoding) if encoding
- end
- csv = new(str, **options) # wrap
- yield csv # yield for appending
- csv.string # return final String
+ #
+ # :call-seq:
+ # generate( str, **options ) { |csv| ... }
+ # generate( **options ) { |csv| ... }
+ #
+ # This method wraps a String you provide, or an empty default String, in a
+ # CSV object which is passed to the provided block. You can use the block to
+ # append CSV rows to the String and when the block exits, the final String
+ # will be returned.
+ #
+ # Note that a passed String *is* modified by this method. Call dup() before
+ # passing if you need a new String.
+ #
+ # The +options+ parameter can be anything CSV::new() understands. This method
+ # understands an additional <tt>:encoding</tt> parameter when not passed a
+ # String to set the base Encoding for the output. CSV needs this hint if you
+ # plan to output non-ASCII compatible data.
+ #
+ def self.generate(str=nil, **options)
+ # add a default empty String, if none was given
+ if str
+ io = StringIO.new(str)
+ io.seek(0, IO::SEEK_END)
+ else
+ encoding = options[:encoding]
+ str = String.new
+ str.force_encoding(encoding) if encoding
end
+ csv = new(str, options) # wrap
+ yield csv # yield for appending
+ csv.string # return final String
+ end
- #
- # This method is a shortcut for converting a single row (Array) into a CSV
- # String.
- #
- # The +options+ parameter can be anything CSV::new() understands. This method
- # understands an additional <tt>:encoding</tt> parameter to set the base
- # Encoding for the output. This method will try to guess your Encoding from
- # the first non-+nil+ field in +row+, if possible, but you may need to use
- # this parameter as a backup plan.
- #
- # The <tt>:row_sep</tt> +option+ defaults to <tt>$INPUT_RECORD_SEPARATOR</tt>
- # (<tt>$/</tt>) when calling this method.
- #
- def generate_line(row, **options)
- options = {row_sep: $INPUT_RECORD_SEPARATOR}.merge(options)
- str = +""
- if options[:encoding]
- str.force_encoding(options[:encoding])
- elsif field = row.find {|f| f.is_a?(String)}
- str.force_encoding(field.encoding)
- end
- (new(str, **options) << row).string
+ #
+ # This method is a shortcut for converting a single row (Array) into a CSV
+ # String.
+ #
+ # The +options+ parameter can be anything CSV::new() understands. This method
+ # understands an additional <tt>:encoding</tt> parameter to set the base
+ # Encoding for the output. This method will try to guess your Encoding from
+ # the first non-+nil+ field in +row+, if possible, but you may need to use
+ # this parameter as a backup plan.
+ #
+ # The <tt>:row_sep</tt> +option+ defaults to <tt>$INPUT_RECORD_SEPARATOR</tt>
+ # (<tt>$/</tt>) when calling this method.
+ #
+ def self.generate_line(row, **options)
+ options = {row_sep: $INPUT_RECORD_SEPARATOR}.merge(options)
+ str = String.new
+ if options[:encoding]
+ str.force_encoding(options[:encoding])
+ elsif field = row.find { |f| not f.nil? }
+ str.force_encoding(String(field).encoding)
end
+ (new(str, options) << row).string
+ end
- #
- # :call-seq:
- # open( filename, mode = "rb", **options ) { |faster_csv| ... }
- # open( filename, **options ) { |faster_csv| ... }
- # open( filename, mode = "rb", **options )
- # open( filename, **options )
- #
- # This method opens an IO object, and wraps that with CSV. This is intended
- # as the primary interface for writing a CSV file.
- #
- # You must pass a +filename+ and may optionally add a +mode+ for Ruby's
- # open(). You may also pass an optional Hash containing any +options+
- # CSV::new() understands as the final argument.
- #
- # This method works like Ruby's open() call, in that it will pass a CSV object
- # to a provided block and close it when the block terminates, or it will
- # return the CSV object when no block is provided. (*Note*: This is different
- # from the Ruby 1.8 CSV library which passed rows to the block. Use
- # CSV::foreach() for that behavior.)
- #
- # You must provide a +mode+ with an embedded Encoding designator unless your
- # data is in Encoding::default_external(). CSV will check the Encoding of the
- # underlying IO object (set by the +mode+ you pass) to determine how to parse
- # the data. You may provide a second Encoding to have the data transcoded as
- # it is read just as you can with a normal call to IO::open(). For example,
- # <tt>"rb:UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file but
- # transcode it to UTF-8 before CSV parses it.
- #
- # An opened CSV object will delegate to many IO methods for convenience. You
- # may call:
- #
- # * binmode()
- # * binmode?()
- # * close()
- # * close_read()
- # * close_write()
- # * closed?()
- # * eof()
- # * eof?()
- # * external_encoding()
- # * fcntl()
- # * fileno()
- # * flock()
- # * flush()
- # * fsync()
- # * internal_encoding()
- # * ioctl()
- # * isatty()
- # * path()
- # * pid()
- # * pos()
- # * pos=()
- # * reopen()
- # * seek()
- # * stat()
- # * sync()
- # * sync=()
- # * tell()
- # * to_i()
- # * to_io()
- # * truncate()
- # * tty?()
- #
- def open(filename, mode="r", **options)
- # wrap a File opened with the remaining +args+ with no newline
- # decorator
- file_opts = {universal_newline: false}.merge(options)
+ #
+ # :call-seq:
+ # open( filename, mode = "rb", **options ) { |faster_csv| ... }
+ # open( filename, **options ) { |faster_csv| ... }
+ # open( filename, mode = "rb", **options )
+ # open( filename, **options )
+ #
+ # This method opens an IO object, and wraps that with CSV. This is intended
+ # as the primary interface for writing a CSV file.
+ #
+ # You must pass a +filename+ and may optionally add a +mode+ for Ruby's
+ # open(). You may also pass an optional Hash containing any +options+
+ # CSV::new() understands as the final argument.
+ #
+ # This method works like Ruby's open() call, in that it will pass a CSV object
+ # to a provided block and close it when the block terminates, or it will
+ # return the CSV object when no block is provided. (*Note*: This is different
+ # from the Ruby 1.8 CSV library which passed rows to the block. Use
+ # CSV::foreach() for that behavior.)
+ #
+ # You must provide a +mode+ with an embedded Encoding designator unless your
+ # data is in Encoding::default_external(). CSV will check the Encoding of the
+ # underlying IO object (set by the +mode+ you pass) to determine how to parse
+ # the data. You may provide a second Encoding to have the data transcoded as
+ # it is read just as you can with a normal call to IO::open(). For example,
+ # <tt>"rb:UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file but
+ # transcode it to UTF-8 before CSV parses it.
+ #
+ # An opened CSV object will delegate to many IO methods for convenience. You
+ # may call:
+ #
+ # * binmode()
+ # * binmode?()
+ # * close()
+ # * close_read()
+ # * close_write()
+ # * closed?()
+ # * eof()
+ # * eof?()
+ # * external_encoding()
+ # * fcntl()
+ # * fileno()
+ # * flock()
+ # * flush()
+ # * fsync()
+ # * internal_encoding()
+ # * ioctl()
+ # * isatty()
+ # * path()
+ # * pid()
+ # * pos()
+ # * pos=()
+ # * reopen()
+ # * seek()
+ # * stat()
+ # * sync()
+ # * sync=()
+ # * tell()
+ # * to_i()
+ # * to_io()
+ # * truncate()
+ # * tty?()
+ #
+ def self.open(filename, mode="r", **options)
+ # wrap a File opened with the remaining +args+ with no newline
+ # decorator
+ file_opts = {universal_newline: false}.merge(options)
- begin
- f = File.open(filename, mode, **file_opts)
- rescue ArgumentError => e
- raise unless /needs binmode/.match?(e.message) and mode == "r"
- mode = "rb"
- file_opts = {encoding: Encoding.default_external}.merge(file_opts)
- retry
- end
- begin
- csv = new(f, **options)
- rescue Exception
- f.close
- raise
- end
+ begin
+ f = File.open(filename, mode, file_opts)
+ rescue ArgumentError => e
+ raise unless /needs binmode/ =~ e.message and mode == "r"
+ mode = "rb"
+ file_opts = {encoding: Encoding.default_external}.merge(file_opts)
+ retry
+ end
+ begin
+ csv = new(f, options)
+ rescue Exception
+ f.close
+ raise
+ end
- # handle blocks like Ruby's open(), not like the CSV library
- if block_given?
- begin
- yield csv
- ensure
- csv.close
- end
- else
- csv
+ # handle blocks like Ruby's open(), not like the CSV library
+ if block_given?
+ begin
+ yield csv
+ ensure
+ csv.close
end
+ else
+ csv
end
+ end
- #
- # :call-seq:
- # parse( str, **options ) { |row| ... }
- # parse( str, **options )
- #
- # This method can be used to easily parse CSV out of a String. You may either
- # provide a +block+ which will be called with each row of the String in turn,
- # or just use the returned Array of Arrays (when no +block+ is given).
- #
- # You pass your +str+ to read from, and an optional +options+ containing
- # anything CSV::new() understands.
- #
- def parse(str, **options, &block)
- csv = new(str, **options)
-
- return csv.each(&block) if block_given?
-
- # slurp contents, if no block is given
+ #
+ # :call-seq:
+ # parse( str, **options ) { |row| ... }
+ # parse( str, **options )
+ #
+ # This method can be used to easily parse CSV out of a String. You may either
+ # provide a +block+ which will be called with each row of the String in turn,
+ # or just use the returned Array of Arrays (when no +block+ is given).
+ #
+ # You pass your +str+ to read from, and an optional +options+ containing
+ # anything CSV::new() understands.
+ #
+ def self.parse(*args, &block)
+ csv = new(*args)
+ if block.nil? # slurp contents, if no block is given
begin
csv.read
ensure
csv.close
end
+ else # or pass each row to a provided block
+ csv.each(&block)
end
+ end
- #
- # This method is a shortcut for converting a single line of a CSV String into
- # an Array. Note that if +line+ contains multiple rows, anything beyond the
- # first row is ignored.
- #
- # The +options+ parameter can be anything CSV::new() understands.
- #
- def parse_line(line, **options)
- new(line, **options).shift
- end
+ #
+ # This method is a shortcut for converting a single line of a CSV String into
+ # an Array. Note that if +line+ contains multiple rows, anything beyond the
+ # first row is ignored.
+ #
+ # The +options+ parameter can be anything CSV::new() understands.
+ #
+ def self.parse_line(line, **options)
+ new(line, options).shift
+ end
- #
- # Use to slurp a CSV file into an Array of Arrays. Pass the +path+ to the
- # file and any +options+ CSV::new() understands. This method also understands
- # an additional <tt>:encoding</tt> parameter that you can use to specify the
- # Encoding of the data in the file to be read. You must provide this unless
- # your data is in Encoding::default_external(). CSV will use this to determine
- # how to parse the data. You may provide a second Encoding to have the data
- # transcoded as it is read. For example,
- # <tt>encoding: "UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file
- # but transcode it to UTF-8 before CSV parses it.
- #
- def read(path, **options)
- open(path, **options) { |csv| csv.read }
- end
+ #
+ # Use to slurp a CSV file into an Array of Arrays. Pass the +path+ to the
+ # file and any +options+ CSV::new() understands. This method also understands
+ # an additional <tt>:encoding</tt> parameter that you can use to specify the
+ # Encoding of the data in the file to be read. You must provide this unless
+ # your data is in Encoding::default_external(). CSV will use this to determine
+ # how to parse the data. You may provide a second Encoding to have the data
+ # transcoded as it is read. For example,
+ # <tt>encoding: "UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file
+ # but transcode it to UTF-8 before CSV parses it.
+ #
+ def self.read(path, *options)
+ open(path, *options) { |csv| csv.read }
+ end
- # Alias for CSV::read().
- def readlines(path, **options)
- read(path, **options)
- end
+ # Alias for CSV::read().
+ def self.readlines(*args)
+ read(*args)
+ end
- #
- # A shortcut for:
- #
- # CSV.read( path, { headers: true,
- # converters: :numeric,
- # header_converters: :symbol }.merge(options) )
- #
- def table(path, **options)
- default_options = {
- headers: true,
- converters: :numeric,
- header_converters: :symbol,
- }
- options = default_options.merge(options)
- read(path, **options)
- end
+ #
+ # A shortcut for:
+ #
+ # CSV.read( path, { headers: true,
+ # converters: :numeric,
+ # header_converters: :symbol }.merge(options) )
+ #
+ def self.table(path, **options)
+ read( path, { headers: true,
+ converters: :numeric,
+ header_converters: :symbol }.merge(options) )
end
#
# This constructor will wrap either a String or IO object passed in +data+ for
- # reading and/or writing. In addition to the CSV instance methods, several IO
- # methods are delegated. (See CSV::open() for a complete list.) If you pass
+ # reading and/or writing. In addition to the CSV instance methods, several IO
+ # methods are delegated. (See CSV::open() for a complete list.) If you pass
# a String for +data+, you can later retrieve it (after writing to it, for
# example) with CSV.string().
#
# Note that a wrapped String will be positioned at the beginning (for
- # reading). If you want it at the end (for writing), use CSV::generate().
+ # reading). If you want it at the end (for writing), use CSV::generate().
# If you want any other positioning, pass a preset StringIO object instead.
#
# You may set any reading and/or writing preferences in the +options+ Hash.
@@ -756,25 +1382,25 @@ class CSV
# This String will be transcoded into
# the data's Encoding before parsing.
# <b><tt>:row_sep</tt></b>:: The String appended to the end of each
- # row. This can be set to the special
+ # row. This can be set to the special
# <tt>:auto</tt> setting, which requests
# that CSV automatically discover this
- # from the data. Auto-discovery reads
+ # from the data. Auto-discovery reads
# ahead in the data looking for the next
# <tt>"\r\n"</tt>, <tt>"\n"</tt>, or
- # <tt>"\r"</tt> sequence. A sequence
+ # <tt>"\r"</tt> sequence. A sequence
# will be selected even if it occurs in
# a quoted field, assuming that you
# would have the same line endings
- # there. If none of those sequences is
+ # there. If none of those sequences is
# found, +data+ is <tt>ARGF</tt>,
# <tt>STDIN</tt>, <tt>STDOUT</tt>, or
# <tt>STDERR</tt>, or the stream is only
# available for output, the default
# <tt>$INPUT_RECORD_SEPARATOR</tt>
- # (<tt>$/</tt>) is used. Obviously,
- # discovery takes a little time. Set
- # manually if speed is important. Also
+ # (<tt>$/</tt>) is used. Obviously,
+ # discovery takes a little time. Set
+ # manually if speed is important. Also
# note that IO objects should be opened
# in binary mode on Windows if this
# feature will be used as the
@@ -786,7 +1412,7 @@ class CSV
# before parsing.
# <b><tt>:quote_char</tt></b>:: The character used to quote fields.
# This has to be a single character
- # String. This is useful for
+ # String. This is useful for
# application that incorrectly use
# <tt>'</tt> as the quote character
# instead of the correct <tt>"</tt>.
@@ -797,21 +1423,21 @@ class CSV
# before parsing.
# <b><tt>:field_size_limit</tt></b>:: This is a maximum size CSV will read
# ahead looking for the closing quote
- # for a field. (In truth, it reads to
+ # for a field. (In truth, it reads to
# the first line ending beyond this
- # size.) If a quote cannot be found
+ # size.) If a quote cannot be found
# within the limit CSV will raise a
# MalformedCSVError, assuming the data
- # is faulty. You can use this limit to
+ # is faulty. You can use this limit to
# prevent what are effectively DoS
- # attacks on the parser. However, this
+ # attacks on the parser. However, this
# limit can cause a legitimate parse to
# fail and thus is set to +nil+, or off,
# by default.
# <b><tt>:converters</tt></b>:: An Array of names from the Converters
# Hash and/or lambdas that handle custom
- # conversion. A single converter
- # doesn't have to be in an Array. All
+ # conversion. A single converter
+ # doesn't have to be in an Array. All
# built-in converters try to transcode
# fields to UTF-8 before converting.
# The conversion will fail if the data
@@ -821,7 +1447,7 @@ class CSV
# unconverted_fields() method will be
# added to all returned rows (Array or
# CSV::Row) that will return the fields
- # as they were before conversion. Note
+ # as they were before conversion. Note
# that <tt>:headers</tt> supplied by
# Array or String were not fields of the
# document and thus will have an empty
@@ -829,21 +1455,21 @@ class CSV
# <b><tt>:headers</tt></b>:: If set to <tt>:first_row</tt> or
# +true+, the initial row of the CSV
# file will be treated as a row of
- # headers. If set to an Array, the
+ # headers. If set to an Array, the
# contents will be used as the headers.
# If set to a String, the String is run
# through a call of CSV::parse_line()
# with the same <tt>:col_sep</tt>,
# <tt>:row_sep</tt>, and
# <tt>:quote_char</tt> as this instance
- # to produce an Array of headers. This
+ # to produce an Array of headers. This
# setting causes CSV#shift() to return
# rows as CSV::Row objects instead of
# Arrays and CSV#read() to return
# CSV::Table objects instead of an Array
# of Arrays.
# <b><tt>:return_headers</tt></b>:: When +false+, header rows are silently
- # swallowed. If set to +true+, header
+ # swallowed. If set to +true+, header
# rows are returned in a CSV::Row object
# with identical headers and
# fields (save that the fields do not go
@@ -854,12 +1480,12 @@ class CSV
# <b><tt>:header_converters</tt></b>:: Identical in functionality to
# <tt>:converters</tt> save that the
# conversions are only made to header
- # rows. All built-in converters try to
+ # rows. All built-in converters try to
# transcode headers to UTF-8 before
- # converting. The conversion will fail
+ # converting. The conversion will fail
# if the data cannot be transcoded,
# leaving the header unchanged.
- # <b><tt>:skip_blanks</tt></b>:: When setting a +true+ value, CSV will
+ # <b><tt>:skip_blanks</tt></b>:: When set to a +true+ value, CSV will
# skip over any empty rows. Note that
# this setting will not skip rows that
# contain column separators, even if
@@ -869,9 +1495,9 @@ class CSV
# using <tt>:skip_lines</tt>, or
# inspecting fields.compact.empty? on
# each row.
- # <b><tt>:force_quotes</tt></b>:: When setting a +true+ value, CSV will
+ # <b><tt>:force_quotes</tt></b>:: When set to a +true+ value, CSV will
# quote all CSV fields it creates.
- # <b><tt>:skip_lines</tt></b>:: When setting an object responding to
+ # <b><tt>:skip_lines</tt></b>:: When set to an object responding to
# <tt>match</tt>, every line matching
# it is considered a comment and ignored
# during parsing. When set to a String,
@@ -880,248 +1506,139 @@ class CSV
# a comment. If the passed object does
# not respond to <tt>match</tt>,
# <tt>ArgumentError</tt> is thrown.
- # <b><tt>:liberal_parsing</tt></b>:: When setting a +true+ value, CSV will
+ # <b><tt>:liberal_parsing</tt></b>:: When set to a +true+ value, CSV will
# attempt to parse input not conformant
# with RFC 4180, such as double quotes
# in unquoted fields.
- # <b><tt>:nil_value</tt></b>:: When set an object, any values of an
- # empty field is replaced by the set
- # object, not nil.
- # <b><tt>:empty_value</tt></b>:: When setting an object, any values of a
- # blank string field is replaced by
- # the set object.
- # <b><tt>:quote_empty</tt></b>:: When setting a +true+ value, CSV will
- # quote empty values with double quotes.
- # When +false+, CSV will emit an
- # empty string for an empty field value.
- # <b><tt>:write_converters</tt></b>:: Converts values on each line with the
- # specified <tt>Proc</tt> object(s),
- # which receive a <tt>String</tt> value
- # and return a <tt>String</tt> or +nil+
- # value.
- # When an array is specified, each
- # converter will be applied in order.
- # <b><tt>:write_nil_value</tt></b>:: When a <tt>String</tt> value, +nil+
- # value(s) on each line will be replaced
- # with the specified value.
- # <b><tt>:write_empty_value</tt></b>:: When a <tt>String</tt> or +nil+ value,
- # empty value(s) on each line will be
- # replaced with the specified value.
- # <b><tt>:strip</tt></b>:: When setting a +true+ value, CSV will
- # strip "\t\r\n\f\v" around the values.
- # If you specify a string instead of
- # +true+, CSV will strip string. The
- # length of the string must be 1.
#
# See CSV::DEFAULT_OPTIONS for the default settings.
#
# Options cannot be overridden in the instance methods for performance reasons,
# so be sure to set what you want here.
#
- def initialize(data,
- col_sep: ",",
- row_sep: :auto,
- quote_char: '"',
- field_size_limit: nil,
- converters: nil,
- unconverted_fields: nil,
- headers: false,
- return_headers: false,
- write_headers: nil,
- header_converters: nil,
- skip_blanks: false,
- force_quotes: false,
- skip_lines: nil,
- liberal_parsing: false,
- internal_encoding: nil,
- external_encoding: nil,
- encoding: nil,
- nil_value: nil,
- empty_value: "",
- quote_empty: true,
- write_converters: nil,
- write_nil_value: nil,
- write_empty_value: "",
- strip: false)
+ def initialize(data, col_sep: ",", row_sep: :auto, quote_char: '"', field_size_limit: nil,
+ converters: nil, unconverted_fields: nil, headers: false, return_headers: false,
+ write_headers: nil, header_converters: nil, skip_blanks: false, force_quotes: false,
+ skip_lines: nil, liberal_parsing: false, internal_encoding: nil, external_encoding: nil, encoding: nil)
raise ArgumentError.new("Cannot parse nil as CSV") if data.nil?
- if data.is_a?(String)
- @io = StringIO.new(data)
- @io.set_encoding(encoding || data.encoding)
- else
- @io = data
+ # create the IO object we will read from
+ @io = data.is_a?(String) ? StringIO.new(data) : data
+ # honor the IO encoding if we can, otherwise default to ASCII-8BIT
+ internal_encoding = Encoding.find(internal_encoding) if internal_encoding
+ external_encoding = Encoding.find(external_encoding) if external_encoding
+ if encoding
+ encoding, = encoding.split(":", 2) if encoding.is_a?(String)
+ encoding = Encoding.find(encoding)
end
- @encoding = determine_encoding(encoding, internal_encoding)
+ @encoding = raw_encoding(nil) || internal_encoding || encoding ||
+ Encoding.default_internal || Encoding.default_external
+ #
+ # prepare for building safe regular expressions in the target encoding,
+ # if we can transcode the needed characters
+ #
+ @re_esc = "\\".encode(@encoding).freeze rescue ""
+ @re_chars = /#{%"[-\\]\\[\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding)}/
+ @unconverted_fields = unconverted_fields
- @base_fields_converter_options = {
- nil_value: nil_value,
- empty_value: empty_value,
- }
- @write_fields_converter_options = {
- nil_value: write_nil_value,
- empty_value: write_empty_value,
- }
- @initial_converters = converters
- @initial_header_converters = header_converters
- @initial_write_converters = write_converters
-
- @parser_options = {
- column_separator: col_sep,
- row_separator: row_sep,
- quote_character: quote_char,
- field_size_limit: field_size_limit,
- unconverted_fields: unconverted_fields,
- headers: headers,
- return_headers: return_headers,
- skip_blanks: skip_blanks,
- skip_lines: skip_lines,
- liberal_parsing: liberal_parsing,
- encoding: @encoding,
- nil_value: nil_value,
- empty_value: empty_value,
- strip: strip,
- }
- @parser = nil
- @parser_enumerator = nil
- @eof_error = nil
-
- @writer_options = {
- encoding: @encoding,
- force_encoding: (not encoding.nil?),
- force_quotes: force_quotes,
- headers: headers,
- write_headers: write_headers,
- column_separator: col_sep,
- row_separator: row_sep,
- quote_character: quote_char,
- quote_empty: quote_empty,
- }
+ # Stores header row settings and loads header converters, if needed.
+ @use_headers = headers
+ @return_headers = return_headers
+ @write_headers = write_headers
- @writer = nil
- writer if @writer_options[:write_headers]
- end
+ # headers must be delayed until shift(), in case they need a row of content
+ @headers = nil
- #
- # The encoded <tt>:col_sep</tt> used in parsing and writing.
- # See CSV::new for details.
- #
- def col_sep
- parser.column_separator
- end
+ init_separators(col_sep, row_sep, quote_char, force_quotes)
+ init_parsers(skip_blanks, field_size_limit, liberal_parsing)
+ init_converters(converters, :@converters, :convert)
+ init_converters(header_converters, :@header_converters, :header_convert)
+ init_comments(skip_lines)
- #
- # The encoded <tt>:row_sep</tt> used in parsing and writing.
- # See CSV::new for details.
- #
- def row_sep
- parser.row_separator
+ @force_encoding = !!encoding
+
+ # track our own lineno since IO gets confused about line-ends is CSV fields
+ @lineno = 0
+
+ # make sure headers have been assigned
+ if header_row? and [Array, String].include? @use_headers.class and @write_headers
+ parse_headers # won't read data for Array or String
+ self << @headers
+ end
end
#
- # The encoded <tt>:quote_char</tt> used in parsing and writing.
- # See CSV::new for details.
+ # The encoded <tt>:col_sep</tt> used in parsing and writing. See CSV::new
+ # for details.
#
- def quote_char
- parser.quote_character
- end
-
+ attr_reader :col_sep
#
- # The limit for field size, if any.
- # See CSV::new for details.
+ # The encoded <tt>:row_sep</tt> used in parsing and writing. See CSV::new
+ # for details.
#
- def field_size_limit
- parser.field_size_limit
- end
-
+ attr_reader :row_sep
#
- # The regex marking a line as a comment.
- # See CSV::new for details.
+ # The encoded <tt>:quote_char</tt> used in parsing and writing. See CSV::new
+ # for details.
#
- def skip_lines
- parser.skip_lines
- end
+ attr_reader :quote_char
+ # The limit for field size, if any. See CSV::new for details.
+ attr_reader :field_size_limit
+
+ # The regex marking a line as a comment. See CSV::new for details
+ attr_reader :skip_lines
#
- # Returns the current list of converters in effect. See CSV::new for details.
+ # Returns the current list of converters in effect. See CSV::new for details.
# Built-in converters will be returned by name, while others will be returned
# as is.
#
def converters
- parser_fields_converter.map do |converter|
+ @converters.map do |converter|
name = Converters.rassoc(converter)
name ? name.first : converter
end
end
-
#
- # Returns +true+ if unconverted_fields() to parsed results.
- # See CSV::new for details.
+ # Returns +true+ if unconverted_fields() to parsed results. See CSV::new
+ # for details.
#
- def unconverted_fields?
- parser.unconverted_fields?
- end
-
+ def unconverted_fields?() @unconverted_fields end
#
# Returns +nil+ if headers will not be used, +true+ if they will but have not
- # yet been read, or the actual headers after they have been read.
- # See CSV::new for details.
+ # yet been read, or the actual headers after they have been read. See
+ # CSV::new for details.
#
def headers
- if @writer
- @writer.headers
- else
- parsed_headers = parser.headers
- return parsed_headers if parsed_headers
- raw_headers = @parser_options[:headers]
- raw_headers = nil if raw_headers == false
- raw_headers
- end
+ @headers || true if @use_headers
end
#
# Returns +true+ if headers will be returned as a row of results.
# See CSV::new for details.
#
- def return_headers?
- parser.return_headers?
- end
-
+ def return_headers?() @return_headers end
+ # Returns +true+ if headers are written in output. See CSV::new for details.
+ def write_headers?() @write_headers end
#
- # Returns +true+ if headers are written in output.
- # See CSV::new for details.
- #
- def write_headers?
- @writer_options[:write_headers]
- end
-
- #
- # Returns the current list of converters in effect for headers. See CSV::new
- # for details. Built-in converters will be returned by name, while others
+ # Returns the current list of converters in effect for headers. See CSV::new
+ # for details. Built-in converters will be returned by name, while others
# will be returned as is.
#
def header_converters
- header_fields_converter.map do |converter|
+ @header_converters.map do |converter|
name = HeaderConverters.rassoc(converter)
name ? name.first : converter
end
end
-
#
# Returns +true+ blank lines are skipped by the parser. See CSV::new
# for details.
#
- def skip_blanks?
- parser.skip_blanks?
- end
-
+ def skip_blanks?() @skip_blanks end
# Returns +true+ if all output fields are quoted. See CSV::new for details.
- def force_quotes?
- @writer_options[:force_quotes]
- end
-
+ def force_quotes?() @force_quotes end
# Returns +true+ if illegal input is handled. See CSV::new for details.
- def liberal_parsing?
- parser.liberal_parsing?
- end
+ def liberal_parsing?() @liberal_parsing end
#
# The Encoding CSV is parsing or writing in. This will be the Encoding you
@@ -1130,90 +1647,26 @@ class CSV
attr_reader :encoding
#
- # The line number of the last row read from this file. Fields with nested
+ # The line number of the last row read from this file. Fields with nested
# line-end characters will not affect this count.
#
- def lineno
- if @writer
- @writer.lineno
- else
- parser.lineno
- end
- end
-
- #
- # The last row read from this file.
- #
- def line
- parser.line
- end
+ attr_reader :lineno, :line
### IO and StringIO Delegation ###
extend Forwardable
- def_delegators :@io, :binmode, :close, :close_read, :close_write,
- :closed?, :external_encoding, :fcntl,
- :fileno, :flush, :fsync, :internal_encoding,
- :isatty, :pid, :pos, :pos=, :reopen,
- :seek, :string, :sync, :sync=, :tell,
- :truncate, :tty?
-
- def binmode?
- if @io.respond_to?(:binmode?)
- @io.binmode?
- else
- false
- end
- end
-
- def flock(*args)
- raise NotImplementedError unless @io.respond_to?(:flock)
- @io.flock(*args)
- end
-
- def ioctl(*args)
- raise NotImplementedError unless @io.respond_to?(:ioctl)
- @io.ioctl(*args)
- end
-
- def path
- @io.path if @io.respond_to?(:path)
- end
-
- def stat(*args)
- raise NotImplementedError unless @io.respond_to?(:stat)
- @io.stat(*args)
- end
-
- def to_i
- raise NotImplementedError unless @io.respond_to?(:to_i)
- @io.to_i
- end
-
- def to_io
- @io.respond_to?(:to_io) ? @io.to_io : @io
- end
-
- def eof?
- return false if @eof_error
- begin
- parser_enumerator.peek
- false
- rescue MalformedCSVError => error
- @eof_error = error
- false
- rescue StopIteration
- true
- end
- end
- alias_method :eof, :eof?
+ def_delegators :@io, :binmode, :binmode?, :close, :close_read, :close_write,
+ :closed?, :eof, :eof?, :external_encoding, :fcntl,
+ :fileno, :flock, :flush, :fsync, :internal_encoding,
+ :ioctl, :isatty, :path, :pid, :pos, :pos=, :reopen,
+ :seek, :stat, :string, :sync, :sync=, :tell, :to_i,
+ :to_io, :truncate, :tty?
# Rewinds the underlying IO object and resets CSV's lineno() counter.
def rewind
- @parser = nil
- @parser_enumerator = nil
- @eof_error = nil
- @writer.rewind if @writer
+ @headers = nil
+ @lineno = 0
+
@io.rewind
end
@@ -1221,14 +1674,40 @@ class CSV
#
# The primary write method for wrapped Strings and IOs, +row+ (an Array or
- # CSV::Row) is converted to CSV and appended to the data source. When a
+ # CSV::Row) is converted to CSV and appended to the data source. When a
# CSV::Row is passed, only the row's fields() are appended to the output.
#
# The data source must be open for writing.
#
def <<(row)
- writer << row
- self
+ # make sure headers have been assigned
+ if header_row? and [Array, String].include? @use_headers.class and !@write_headers
+ parse_headers # won't read data for Array or String
+ end
+
+ # handle CSV::Row objects and Hashes
+ row = case row
+ when self.class::Row then row.fields
+ when Hash then @headers.map { |header| row[header] }
+ else row
+ end
+
+ @headers = row if header_row?
+ @lineno += 1
+
+ output = row.map(&@quote).join(@col_sep) + @row_sep # quote and separate
+ if @io.is_a?(StringIO) and
+ output.encoding != (encoding = raw_encoding)
+ if @force_encoding
+ output = output.encode(encoding)
+ elsif (compatible_encoding = Encoding.compatible?(@io.string, output))
+ @io.set_encoding(compatible_encoding)
+ @io.seek(0, IO::SEEK_END)
+ end
+ end
+ @io << output
+
+ self # for chaining
end
alias_method :add_row, :<<
alias_method :puts, :<<
@@ -1243,13 +1722,13 @@ class CSV
# block that handles a custom conversion.
#
# If you provide a block that takes one argument, it will be passed the field
- # and is expected to return the converted value or the field itself. If your
+ # and is expected to return the converted value or the field itself. If your
# block takes two arguments, it will also be passed a CSV::FieldInfo Struct,
- # containing details about the field. Again, the block should return a
+ # containing details about the field. Again, the block should return a
# converted field or the field itself.
#
def convert(name = nil, &converter)
- parser_fields_converter.add_converter(name, &converter)
+ add_converter(:@converters, self.class::Converters, name, &converter)
end
#
@@ -1264,7 +1743,10 @@ class CSV
# effect.
#
def header_convert(name = nil, &converter)
- header_fields_converter.add_converter(name, &converter)
+ add_converter( :@header_converters,
+ self.class::HeaderConverters,
+ name,
+ &converter )
end
include Enumerable
@@ -1276,8 +1758,14 @@ class CSV
#
# The data source must be open for reading.
#
- def each(&block)
- parser_enumerator.each(&block)
+ def each
+ if block_given?
+ while row = shift
+ yield row
+ end
+ else
+ to_enum
+ end
end
#
@@ -1287,8 +1775,8 @@ class CSV
#
def read
rows = to_a
- if parser.use_headers?
- Table.new(rows, headers: parser.headers)
+ if @use_headers
+ Table.new(rows)
else
rows
end
@@ -1297,7 +1785,7 @@ class CSV
# Returns +true+ if the next row read will be a header row.
def header_row?
- parser.header_row?
+ @use_headers and @headers.nil?
end
#
@@ -1308,14 +1796,159 @@ class CSV
# The data source must be open for reading.
#
def shift
- if @eof_error
- eof_error, @eof_error = @eof_error, nil
- raise eof_error
+ #########################################################################
+ ### This method is purposefully kept a bit long as simple conditional ###
+ ### checks are faster than numerous (expensive) method calls. ###
+ #########################################################################
+
+ # handle headers not based on document content
+ if header_row? and @return_headers and
+ [Array, String].include? @use_headers.class
+ if @unconverted_fields
+ return add_unconverted_fields(parse_headers, Array.new)
+ else
+ return parse_headers
+ end
end
- begin
- parser_enumerator.next
- rescue StopIteration
- nil
+
+ #
+ # it can take multiple calls to <tt>@io.gets()</tt> to get a full line,
+ # because of \r and/or \n characters embedded in quoted fields
+ #
+ in_extended_col = false
+ csv = Array.new
+
+ loop do
+ # add another read to the line
+ unless parse = @io.gets(@row_sep)
+ return nil
+ end
+
+ if in_extended_col
+ @line.concat(parse)
+ else
+ @line = parse.clone
+ end
+
+ parse.sub!(@parsers[:line_end], "")
+
+ if csv.empty?
+ #
+ # I believe a blank line should be an <tt>Array.new</tt>, not Ruby 1.8
+ # CSV's <tt>[nil]</tt>
+ #
+ if parse.empty?
+ @lineno += 1
+ if @skip_blanks
+ next
+ elsif @unconverted_fields
+ return add_unconverted_fields(Array.new, Array.new)
+ elsif @use_headers
+ return self.class::Row.new(Array.new, Array.new)
+ else
+ return Array.new
+ end
+ end
+ end
+
+ next if @skip_lines and @skip_lines.match parse
+
+ parts = parse.split(@col_sep, -1)
+ if parts.empty?
+ if in_extended_col
+ csv[-1] << @col_sep # will be replaced with a @row_sep after the parts.each loop
+ else
+ csv << nil
+ end
+ end
+
+ # This loop is the hot path of csv parsing. Some things may be non-dry
+ # for a reason. Make sure to benchmark when refactoring.
+ parts.each do |part|
+ if in_extended_col
+ # If we are continuing a previous column
+ if part.end_with?(@quote_char) && part.count(@quote_char) % 2 != 0
+ # extended column ends
+ csv.last << part[0..-2]
+ if csv.last =~ @parsers[:stray_quote]
+ raise MalformedCSVError,
+ "Missing or stray quote in line #{lineno + 1}"
+ end
+ csv.last.gsub!(@double_quote_char, @quote_char)
+ in_extended_col = false
+ else
+ csv.last << part << @col_sep
+ end
+ elsif part.start_with?(@quote_char)
+ # If we are starting a new quoted column
+ if part.count(@quote_char) % 2 != 0
+ # start an extended column
+ csv << (part[1..-1] << @col_sep)
+ in_extended_col = true
+ elsif part.end_with?(@quote_char)
+ # regular quoted column
+ csv << part[1..-2]
+ if csv.last =~ @parsers[:stray_quote]
+ raise MalformedCSVError,
+ "Missing or stray quote in line #{lineno + 1}"
+ end
+ csv.last.gsub!(@double_quote_char, @quote_char)
+ elsif @liberal_parsing
+ csv << part
+ else
+ raise MalformedCSVError,
+ "Missing or stray quote in line #{lineno + 1}"
+ end
+ elsif part =~ @parsers[:quote_or_nl]
+ # Unquoted field with bad characters.
+ if part =~ @parsers[:nl_or_lf]
+ raise MalformedCSVError, "Unquoted fields do not allow " +
+ "\\r or \\n (line #{lineno + 1})."
+ else
+ if @liberal_parsing
+ csv << part
+ else
+ raise MalformedCSVError, "Illegal quoting in line #{lineno + 1}."
+ end
+ end
+ else
+ # Regular ole unquoted field.
+ csv << (part.empty? ? nil : part)
+ end
+ end
+
+ # Replace tacked on @col_sep with @row_sep if we are still in an extended
+ # column.
+ csv[-1][-1] = @row_sep if in_extended_col
+
+ if in_extended_col
+ # if we're at eof?(), a quoted field wasn't closed...
+ if @io.eof?
+ raise MalformedCSVError,
+ "Unclosed quoted field on line #{lineno + 1}."
+ elsif @field_size_limit and csv.last.size >= @field_size_limit
+ raise MalformedCSVError, "Field size exceeded on line #{lineno + 1}."
+ end
+ # otherwise, we need to loop and pull some more data to complete the row
+ else
+ @lineno += 1
+
+ # save fields unconverted fields, if needed...
+ unconverted = csv.dup if @unconverted_fields
+
+ # convert fields, if needed...
+ csv = convert_fields(csv) unless @use_headers or @converters.empty?
+ # parse out header rows and handle CSV::Row conversions...
+ csv = parse_headers(csv) if @use_headers
+
+ # inject unconverted fields and accessor, if requested...
+ if @unconverted_fields and not csv.respond_to? :unconverted_fields
+ add_unconverted_fields(csv, unconverted)
+ end
+
+ # return the results
+ break csv
+ end
end
end
alias_method :gets, :shift
@@ -1326,7 +1959,7 @@ class CSV
# ASCII compatible String.
#
def inspect
- str = ["#<", self.class.to_s, " io_type:"]
+ str = ["<#", self.class.to_s, " io_type:"]
# show type of wrapped IO
if @io == $stdout then str << "$stdout"
elsif @io == $stdin then str << "$stdin"
@@ -1340,18 +1973,15 @@ class CSV
# show encoding
str << " encoding:" << @encoding.name
# show other attributes
- ["lineno", "col_sep", "row_sep", "quote_char"].each do |attr_name|
- if a = __send__(attr_name)
+ %w[ lineno col_sep row_sep
+ quote_char skip_blanks liberal_parsing ].each do |attr_name|
+ if a = instance_variable_get("@#{attr_name}")
str << " " << attr_name << ":" << a.inspect
end
end
- ["skip_blanks", "liberal_parsing"].each do |attr_name|
- if a = __send__("#{attr_name}?")
- str << " " << attr_name << ":" << a.inspect
- end
+ if @use_headers
+ str << " headers:" << headers.inspect
end
- _headers = headers
- str << " headers:" << _headers.inspect if _headers
str << ">"
begin
str.join('')
@@ -1365,126 +1995,322 @@ class CSV
private
- def determine_encoding(encoding, internal_encoding)
- # honor the IO encoding if we can, otherwise default to ASCII-8BIT
- io_encoding = raw_encoding
- return io_encoding if io_encoding
+ #
+ # Stores the indicated separators for later use.
+ #
+ # If auto-discovery was requested for <tt>@row_sep</tt>, this method will read
+ # ahead in the <tt>@io</tt> and try to find one. +ARGF+, +STDIN+, +STDOUT+,
+ # +STDERR+ and any stream open for output only with a default
+ # <tt>@row_sep</tt> of <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>).
+ #
+ # This method also establishes the quoting rules used for CSV output.
+ #
+ def init_separators(col_sep, row_sep, quote_char, force_quotes)
+ # store the selected separators
+ @col_sep = col_sep.to_s.encode(@encoding)
+ @row_sep = row_sep # encode after resolving :auto
+ @quote_char = quote_char.to_s.encode(@encoding)
+ @double_quote_char = @quote_char * 2
- return Encoding.find(internal_encoding) if internal_encoding
+ if @quote_char.length != 1
+ raise ArgumentError, ":quote_char has to be a single character String"
+ end
- if encoding
- encoding, = encoding.split(":", 2) if encoding.is_a?(String)
- return Encoding.find(encoding)
+ #
+ # automatically discover row separator when requested
+ # (not fully encoding safe)
+ #
+ if @row_sep == :auto
+ if [ARGF, STDIN, STDOUT, STDERR].include?(@io) or
+ (defined?(Zlib) and @io.class == Zlib::GzipWriter)
+ @row_sep = $INPUT_RECORD_SEPARATOR
+ else
+ begin
+ #
+ # remember where we were (pos() will raise an exception if @io is pipe
+ # or not opened for reading)
+ #
+ saved_pos = @io.pos
+ while @row_sep == :auto
+ #
+ # if we run out of data, it's probably a single line
+ # (ensure will set default value)
+ #
+ break unless sample = @io.gets(nil, 1024)
+ # extend sample if we're unsure of the line ending
+ if sample.end_with? encode_str("\r")
+ sample << (@io.gets(nil, 1) || "")
+ end
+
+ # try to find a standard separator
+ if sample =~ encode_re("\r\n?|\n")
+ @row_sep = $&
+ break
+ end
+ end
+
+ # tricky seek() clone to work around GzipReader's lack of seek()
+ @io.rewind
+ # reset back to the remembered position
+ while saved_pos > 1024 # avoid loading a lot of data into memory
+ @io.read(1024)
+ saved_pos -= 1024
+ end
+ @io.read(saved_pos) if saved_pos.nonzero?
+ rescue IOError # not opened for reading
+ # do nothing: ensure will set default
+ rescue NoMethodError # Zlib::GzipWriter doesn't have some IO methods
+ # do nothing: ensure will set default
+ rescue SystemCallError # pipe
+ # do nothing: ensure will set default
+ ensure
+ #
+ # set default if we failed to detect
+ # (stream not opened for reading, a pipe, or a single line of data)
+ #
+ @row_sep = $INPUT_RECORD_SEPARATOR if @row_sep == :auto
+ end
+ end
+ end
+ @row_sep = @row_sep.to_s.encode(@encoding)
+
+ # establish quoting rules
+ @force_quotes = force_quotes
+ do_quote = lambda do |field|
+ field = String(field)
+ encoded_quote = @quote_char.encode(field.encoding)
+ encoded_quote + field.gsub(encoded_quote, encoded_quote * 2) + encoded_quote
+ end
+ quotable_chars = encode_str("\r\n", @col_sep, @quote_char)
+ @quote = if @force_quotes
+ do_quote
+ else
+ lambda do |field|
+ if field.nil? # represent +nil+ fields as empty unquoted fields
+ ""
+ else
+ field = String(field) # Stringify fields
+ # represent empty fields as empty quoted fields
+ if field.empty? or
+ field.count(quotable_chars).nonzero?
+ do_quote.call(field)
+ else
+ field # unquoted field
+ end
+ end
+ end
end
+ end
- Encoding.default_internal || Encoding.default_external
+ # Pre-compiles parsers and stores them by name for access during reads.
+ def init_parsers(skip_blanks, field_size_limit, liberal_parsing)
+ # store the parser behaviors
+ @skip_blanks = skip_blanks
+ @field_size_limit = field_size_limit
+ @liberal_parsing = liberal_parsing
+
+ # prebuild Regexps for faster parsing
+ esc_row_sep = escape_re(@row_sep)
+ esc_quote = escape_re(@quote_char)
+ @parsers = {
+ # for detecting parse errors
+ quote_or_nl: encode_re("[", esc_quote, "\r\n]"),
+ nl_or_lf: encode_re("[\r\n]"),
+ stray_quote: encode_re( "[^", esc_quote, "]", esc_quote,
+ "[^", esc_quote, "]" ),
+ # safer than chomp!()
+ line_end: encode_re(esc_row_sep, "\\z"),
+ # illegal unquoted characters
+ return_newline: encode_str("\r\n")
+ }
end
- def normalize_converters(converters)
- converters ||= []
- unless converters.is_a?(Array)
- converters = [converters]
- end
- converters.collect do |converter|
- case converter
- when Proc # custom code block
- [nil, converter]
- else # by name
- [converter, nil]
+ #
+ # Loads any converters requested during construction.
+ #
+ # If +field_name+ is set <tt>:converters</tt> (the default) field converters
+ # are set. When +field_name+ is <tt>:header_converters</tt> header converters
+ # are added instead.
+ #
+ # The <tt>:unconverted_fields</tt> option is also activated for
+ # <tt>:converters</tt> calls, if requested.
+ #
+ def init_converters(converters, ivar_name, convert_method)
+ converters = case converters
+ when nil then []
+ when Array then converters
+ else [converters]
+ end
+ instance_variable_set(ivar_name, [])
+ convert = method(convert_method)
+
+ # load converters
+ converters.each do |converter|
+ if converter.is_a? Proc # custom code block
+ convert.call(&converter)
+ else # by name
+ convert.call(converter)
+ end
+ end
+ end
+
+ # Stores the pattern of comments to skip from the provided options.
+ #
+ # The pattern must respond to +.match+, else ArgumentError is raised.
+ # Strings are converted to a Regexp.
+ #
+ # See also CSV.new
+ def init_comments(skip_lines)
+ @skip_lines = skip_lines
+ @skip_lines = Regexp.new(Regexp.escape(@skip_lines)) if @skip_lines.is_a? String
+ if @skip_lines and not @skip_lines.respond_to?(:match)
+ raise ArgumentError, ":skip_lines has to respond to matches"
+ end
+ end
+ #
+ # The actual work method for adding converters, used by both CSV.convert() and
+ # CSV.header_convert().
+ #
+ # This method requires the +var_name+ of the instance variable to place the
+ # converters in, the +const+ Hash to lookup named converters in, and the
+ # normal parameters of the CSV.convert() and CSV.header_convert() methods.
+ #
+ def add_converter(var_name, const, name = nil, &converter)
+ if name.nil? # custom converter
+ instance_variable_get(var_name) << converter
+ else # named converter
+ combo = const[name]
+ case combo
+ when Array # combo converter
+ combo.each do |converter_name|
+ add_converter(var_name, const, converter_name)
+ end
+ else # individual named converter
+ instance_variable_get(var_name) << combo
end
end
end
#
# Processes +fields+ with <tt>@converters</tt>, or <tt>@header_converters</tt>
- # if +headers+ is passed as +true+, returning the converted field set. Any
+ # if +headers+ is passed as +true+, returning the converted field set. Any
# converter that changes the field into something other than a String halts
- # the pipeline of conversion for that field. This is primarily an efficiency
+ # the pipeline of conversion for that field. This is primarily an efficiency
# shortcut.
#
def convert_fields(fields, headers = false)
- if headers
- header_fields_converter.convert(fields, nil, 0)
- else
- parser_fields_converter.convert(fields, @headers, lineno)
+ # see if we are converting headers or fields
+ converters = headers ? @header_converters : @converters
+
+ fields.map.with_index do |field, index|
+ converters.each do |converter|
+ break if headers && field.nil?
+ field = if converter.arity == 1 # straight field converter
+ converter[field]
+ else # FieldInfo converter
+ header = @use_headers && !headers ? @headers[index] : nil
+ converter[field, FieldInfo.new(index, lineno, header)]
+ end
+ break unless field.is_a? String # short-circuit pipeline for speed
+ end
+ field # final state of each field, converted or original
end
end
#
- # Returns the encoding of the internal IO object.
- #
- def raw_encoding
- if @io.respond_to? :internal_encoding
- @io.internal_encoding || @io.external_encoding
- elsif @io.respond_to? :encoding
- @io.encoding
- else
- nil
+ # This method is used to turn a finished +row+ into a CSV::Row. Header rows
+ # are also dealt with here, either by returning a CSV::Row with identical
+ # headers and fields (save that the fields do not go through the converters)
+ # or by reading past them to return a field row. Headers are also saved in
+ # <tt>@headers</tt> for use in future rows.
+ #
+ # When +nil+, +row+ is assumed to be a header row not based on an actual row
+ # of the stream.
+ #
+ def parse_headers(row = nil)
+ if @headers.nil? # header row
+ @headers = case @use_headers # save headers
+ # Array of headers
+ when Array then @use_headers
+ # CSV header String
+ when String
+ self.class.parse_line( @use_headers,
+ col_sep: @col_sep,
+ row_sep: @row_sep,
+ quote_char: @quote_char )
+ # first row is headers
+ else row
+ end
+
+ # prepare converted and unconverted copies
+ row = @headers if row.nil?
+ @headers = convert_fields(@headers, true)
+ @headers.each { |h| h.freeze if h.is_a? String }
+
+ if @return_headers # return headers
+ return self.class::Row.new(@headers, row, true)
+ elsif not [Array, String].include? @use_headers.class # skip to field row
+ return shift
+ end
end
- end
- def parser_fields_converter
- @parser_fields_converter ||= build_parser_fields_converter
+ self.class::Row.new(@headers, convert_fields(row)) # field row
end
- def build_parser_fields_converter
- specific_options = {
- builtin_converters: Converters,
- }
- options = @base_fields_converter_options.merge(specific_options)
- build_fields_converter(@initial_converters, options)
- end
-
- def header_fields_converter
- @header_fields_converter ||= build_header_fields_converter
- end
-
- def build_header_fields_converter
- specific_options = {
- builtin_converters: HeaderConverters,
- accept_nil: true,
- }
- options = @base_fields_converter_options.merge(specific_options)
- build_fields_converter(@initial_header_converters, options)
- end
-
- def writer_fields_converter
- @writer_fields_converter ||= build_writer_fields_converter
- end
-
- def build_writer_fields_converter
- build_fields_converter(@initial_write_converters,
- @write_fields_converter_options)
- end
-
- def build_fields_converter(initial_converters, options)
- fields_converter = FieldsConverter.new(options)
- normalize_converters(initial_converters).each do |name, converter|
- fields_converter.add_converter(name, &converter)
+ #
+ # This method injects an instance variable <tt>unconverted_fields</tt> into
+ # +row+ and an accessor method for +row+ called unconverted_fields(). The
+ # variable is set to the contents of +fields+.
+ #
+ def add_unconverted_fields(row, fields)
+ class << row
+ attr_reader :unconverted_fields
end
- fields_converter
+ row.instance_variable_set(:@unconverted_fields, fields)
+ row
end
- def parser
- @parser ||= Parser.new(@io, parser_options)
- end
-
- def parser_options
- @parser_options.merge(header_fields_converter: header_fields_converter,
- fields_converter: parser_fields_converter)
+ #
+ # This method is an encoding safe version of Regexp::escape(). It will escape
+ # any characters that would change the meaning of a regular expression in the
+ # encoding of +str+. Regular expression characters that cannot be transcoded
+ # to the target encoding will be skipped and no escaping will be performed if
+ # a backslash cannot be transcoded.
+ #
+ def escape_re(str)
+ str.gsub(@re_chars) {|c| @re_esc + c}
end
- def parser_enumerator
- @parser_enumerator ||= parser.parse
+ #
+ # Builds a regular expression in <tt>@encoding</tt>. All +chunks+ will be
+ # transcoded to that encoding.
+ #
+ def encode_re(*chunks)
+ Regexp.new(encode_str(*chunks))
end
- def writer
- @writer ||= Writer.new(@io, writer_options)
+ #
+ # Builds a String in <tt>@encoding</tt>. All +chunks+ will be transcoded to
+ # that encoding.
+ #
+ def encode_str(*chunks)
+ chunks.map { |chunk| chunk.encode(@encoding.name) }.join('')
end
- def writer_options
- @writer_options.merge(header_fields_converter: header_fields_converter,
- fields_converter: writer_fields_converter)
+ #
+ # Returns the encoding of the internal IO object or the +default+ if the
+ # encoding cannot be determined.
+ #
+ def raw_encoding(default = Encoding::ASCII_8BIT)
+ if @io.respond_to? :internal_encoding
+ @io.internal_encoding || @io.external_encoding
+ elsif @io.is_a? StringIO
+ @io.string.encoding
+ elsif @io.respond_to? :encoding
+ @io.encoding
+ else
+ default
+ end
end
end
@@ -1508,6 +2334,22 @@ def CSV(*args, &block)
CSV.instance(*args, &block)
end
-require_relative "csv/version"
-require_relative "csv/core_ext/array"
-require_relative "csv/core_ext/string"
+class Array # :nodoc:
+ # Equivalent to CSV::generate_line(self, options)
+ #
+ # ["CSV", "data"].to_csv
+ # #=> "CSV,data\n"
+ def to_csv(**options)
+ CSV.generate_line(self, options)
+ end
+end
+
+class String # :nodoc:
+ # Equivalent to CSV::parse_line(self, options)
+ #
+ # "CSV,data".parse_csv
+ # #=> ["CSV", "data"]
+ def parse_csv(**options)
+ CSV.parse_line(self, options)
+ end
+end
diff --git a/lib/csv/core_ext/array.rb b/lib/csv/core_ext/array.rb
deleted file mode 100644
index 8beb06b082..0000000000
--- a/lib/csv/core_ext/array.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Array # :nodoc:
- # Equivalent to CSV::generate_line(self, options)
- #
- # ["CSV", "data"].to_csv
- # #=> "CSV,data\n"
- def to_csv(**options)
- CSV.generate_line(self, **options)
- end
-end
diff --git a/lib/csv/core_ext/string.rb b/lib/csv/core_ext/string.rb
deleted file mode 100644
index 9b1d31c2a4..0000000000
--- a/lib/csv/core_ext/string.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class String # :nodoc:
- # Equivalent to CSV::parse_line(self, options)
- #
- # "CSV,data".parse_csv
- # #=> ["CSV", "data"]
- def parse_csv(**options)
- CSV.parse_line(self, **options)
- end
-end
diff --git a/lib/csv/csv.gemspec b/lib/csv/csv.gemspec
deleted file mode 100644
index 98110bc13c..0000000000
--- a/lib/csv/csv.gemspec
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require_relative "lib/csv/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "csv"
- spec.version = CSV::VERSION
- spec.authors = ["James Edward Gray II", "Kouhei Sutou"]
- spec.email = [nil, "kou@cozmixng.org"]
-
- spec.summary = "CSV Reading and Writing"
- spec.description = "The CSV library provides a complete interface to CSV files and data. It offers tools to enable you to read and write to and from Strings or IO objects, as needed."
- spec.homepage = "https://github.com/ruby/csv"
- spec.license = "BSD-2-Clause"
-
- spec.files = [
- "LICENSE.txt",
- "NEWS.md",
- "README.md",
- "lib/csv.rb",
- "lib/csv/core_ext/array.rb",
- "lib/csv/core_ext/string.rb",
- "lib/csv/delete_suffix.rb",
- "lib/csv/fields_converter.rb",
- "lib/csv/match_p.rb",
- "lib/csv/parser.rb",
- "lib/csv/row.rb",
- "lib/csv/table.rb",
- "lib/csv/version.rb",
- "lib/csv/writer.rb",
- ]
- spec.require_paths = ["lib"]
- spec.required_ruby_version = ">= 2.3.0"
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "benchmark_driver"
- spec.add_development_dependency "simplecov"
-end
diff --git a/lib/csv/delete_suffix.rb b/lib/csv/delete_suffix.rb
deleted file mode 100644
index d457718997..0000000000
--- a/lib/csv/delete_suffix.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-# This provides String#delete_suffix? for Ruby 2.4.
-unless String.method_defined?(:delete_suffix)
- class CSV
- module DeleteSuffix
- refine String do
- def delete_suffix(suffix)
- if end_with?(suffix)
- self[0...-suffix.size]
- else
- self
- end
- end
- end
- end
- end
-end
diff --git a/lib/csv/fields_converter.rb b/lib/csv/fields_converter.rb
deleted file mode 100644
index a751c9ea1d..0000000000
--- a/lib/csv/fields_converter.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-# frozen_string_literal: true
-
-class CSV
- # Note: Don't use this class directly. This is an internal class.
- class FieldsConverter
- include Enumerable
- #
- # A CSV::FieldsConverter is a data structure for storing the
- # fields converter properties to be passed as a parameter
- # when parsing a new file (e.g. CSV::Parser.new(@io, parser_options))
- #
-
- def initialize(options={})
- @converters = []
- @nil_value = options[:nil_value]
- @empty_value = options[:empty_value]
- @empty_value_is_empty_string = (@empty_value == "")
- @accept_nil = options[:accept_nil]
- @builtin_converters = options[:builtin_converters]
- @need_static_convert = need_static_convert?
- end
-
- def add_converter(name=nil, &converter)
- if name.nil? # custom converter
- @converters << converter
- else # named converter
- combo = @builtin_converters[name]
- case combo
- when Array # combo converter
- combo.each do |sub_name|
- add_converter(sub_name)
- end
- else # individual named converter
- @converters << combo
- end
- end
- end
-
- def each(&block)
- @converters.each(&block)
- end
-
- def empty?
- @converters.empty?
- end
-
- def convert(fields, headers, lineno)
- return fields unless need_convert?
-
- fields.collect.with_index do |field, index|
- if field.nil?
- field = @nil_value
- elsif field.empty?
- field = @empty_value unless @empty_value_is_empty_string
- end
- @converters.each do |converter|
- break if field.nil? and @accept_nil
- if converter.arity == 1 # straight field converter
- field = converter[field]
- else # FieldInfo converter
- if headers
- header = headers[index]
- else
- header = nil
- end
- field = converter[field, FieldInfo.new(index, lineno, header)]
- end
- break unless field.is_a?(String) # short-circuit pipeline for speed
- end
- field # final state of each field, converted or original
- end
- end
-
- private
- def need_static_convert?
- not (@nil_value.nil? and @empty_value_is_empty_string)
- end
-
- def need_convert?
- @need_static_convert or
- (not @converters.empty?)
- end
- end
-end
diff --git a/lib/csv/match_p.rb b/lib/csv/match_p.rb
deleted file mode 100644
index 775559a3eb..0000000000
--- a/lib/csv/match_p.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-# This provides String#match? and Regexp#match? for Ruby 2.3.
-unless String.method_defined?(:match?)
- class CSV
- module MatchP
- refine String do
- def match?(pattern)
- self =~ pattern
- end
- end
-
- refine Regexp do
- def match?(string)
- self =~ string
- end
- end
- end
- end
-end
diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb
deleted file mode 100644
index 42145f8923..0000000000
--- a/lib/csv/parser.rb
+++ /dev/null
@@ -1,1136 +0,0 @@
-# frozen_string_literal: true
-
-require "strscan"
-
-require_relative "delete_suffix"
-require_relative "match_p"
-require_relative "row"
-require_relative "table"
-
-using CSV::DeleteSuffix if CSV.const_defined?(:DeleteSuffix)
-using CSV::MatchP if CSV.const_defined?(:MatchP)
-
-class CSV
- # Note: Don't use this class directly. This is an internal class.
- class Parser
- #
- # A CSV::Parser is m17n aware. The parser works in the Encoding of the IO
- # or String object being read from or written to. Your data is never transcoded
- # (unless you ask Ruby to transcode it for you) and will literally be parsed in
- # the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the
- # Encoding of your data. This is accomplished by transcoding the parser itself
- # into your Encoding.
- #
-
- # Raised when encoding is invalid.
- class InvalidEncoding < StandardError
- end
-
- #
- # CSV::Scanner receives a CSV output, scans it and return the content.
- # It also controls the life cycle of the object with its methods +keep_start+,
- # +keep_end+, +keep_back+, +keep_drop+.
- #
- # Uses StringScanner (the official strscan gem). Strscan provides lexical
- # scanning operations on a String. We inherit its object and take advantage
- # on the methods. For more information, please visit:
- # https://ruby-doc.org/stdlib-2.6.1/libdoc/strscan/rdoc/StringScanner.html
- #
- class Scanner < StringScanner
- alias_method :scan_all, :scan
-
- def initialize(*args)
- super
- @keeps = []
- end
-
- def each_line(row_separator)
- position = pos
- rest.each_line(row_separator) do |line|
- position += line.bytesize
- self.pos = position
- yield(line)
- end
- end
-
- def keep_start
- @keeps.push(pos)
- end
-
- def keep_end
- start = @keeps.pop
- string.byteslice(start, pos - start)
- end
-
- def keep_back
- self.pos = @keeps.pop
- end
-
- def keep_drop
- @keeps.pop
- end
- end
-
- #
- # CSV::InputsScanner receives IO inputs, encoding and the chunk_size.
- # It also controls the life cycle of the object with its methods +keep_start+,
- # +keep_end+, +keep_back+, +keep_drop+.
- #
- # CSV::InputsScanner.scan() tries to match with pattern at the current position.
- # If there's a match, the scanner advances the “scan pointer†and returns the matched string.
- # Otherwise, the scanner returns nil.
- #
- # CSV::InputsScanner.rest() returns the “rest†of the string (i.e. everything after the scan pointer).
- # If there is no more data (eos? = true), it returns "".
- #
- class InputsScanner
- def initialize(inputs, encoding, chunk_size: 8192)
- @inputs = inputs.dup
- @encoding = encoding
- @chunk_size = chunk_size
- @last_scanner = @inputs.empty?
- @keeps = []
- read_chunk
- end
-
- def each_line(row_separator)
- buffer = nil
- input = @scanner.rest
- position = @scanner.pos
- offset = 0
- n_row_separator_chars = row_separator.size
- while true
- input.each_line(row_separator) do |line|
- @scanner.pos += line.bytesize
- if buffer
- if n_row_separator_chars == 2 and
- buffer.end_with?(row_separator[0]) and
- line.start_with?(row_separator[1])
- buffer << line[0]
- line = line[1..-1]
- position += buffer.bytesize + offset
- @scanner.pos = position
- offset = 0
- yield(buffer)
- buffer = nil
- next if line.empty?
- else
- buffer << line
- line = buffer
- buffer = nil
- end
- end
- if line.end_with?(row_separator)
- position += line.bytesize + offset
- @scanner.pos = position
- offset = 0
- yield(line)
- else
- buffer = line
- end
- end
- break unless read_chunk
- input = @scanner.rest
- position = @scanner.pos
- offset = -buffer.bytesize if buffer
- end
- yield(buffer) if buffer
- end
-
- def scan(pattern)
- value = @scanner.scan(pattern)
- return value if @last_scanner
-
- if value
- read_chunk if @scanner.eos?
- return value
- else
- nil
- end
- end
-
- def scan_all(pattern)
- value = @scanner.scan(pattern)
- return value if @last_scanner
-
- return nil if value.nil?
- while @scanner.eos? and read_chunk and (sub_value = @scanner.scan(pattern))
- value << sub_value
- end
- value
- end
-
- def eos?
- @scanner.eos?
- end
-
- def keep_start
- @keeps.push([@scanner.pos, nil])
- end
-
- def keep_end
- start, buffer = @keeps.pop
- keep = @scanner.string.byteslice(start, @scanner.pos - start)
- if buffer
- buffer << keep
- keep = buffer
- end
- keep
- end
-
- def keep_back
- start, buffer = @keeps.pop
- if buffer
- string = @scanner.string
- keep = string.byteslice(start, string.bytesize - start)
- if keep and not keep.empty?
- @inputs.unshift(StringIO.new(keep))
- @last_scanner = false
- end
- @scanner = StringScanner.new(buffer)
- else
- @scanner.pos = start
- end
- read_chunk if @scanner.eos?
- end
-
- def keep_drop
- @keeps.pop
- end
-
- def rest
- @scanner.rest
- end
-
- private
- def read_chunk
- return false if @last_scanner
-
- unless @keeps.empty?
- keep = @keeps.last
- keep_start = keep[0]
- string = @scanner.string
- keep_data = string.byteslice(keep_start, @scanner.pos - keep_start)
- if keep_data
- keep_buffer = keep[1]
- if keep_buffer
- keep_buffer << keep_data
- else
- keep[1] = keep_data.dup
- end
- end
- keep[0] = 0
- end
-
- input = @inputs.first
- case input
- when StringIO
- string = input.read
- raise InvalidEncoding unless string.valid_encoding?
- @scanner = StringScanner.new(string)
- @inputs.shift
- @last_scanner = @inputs.empty?
- true
- else
- chunk = input.gets(nil, @chunk_size)
- if chunk
- raise InvalidEncoding unless chunk.valid_encoding?
- @scanner = StringScanner.new(chunk)
- if input.respond_to?(:eof?) and input.eof?
- @inputs.shift
- @last_scanner = @inputs.empty?
- end
- true
- else
- @scanner = StringScanner.new("".encode(@encoding))
- @inputs.shift
- @last_scanner = @inputs.empty?
- if @last_scanner
- false
- else
- read_chunk
- end
- end
- end
- end
- end
-
- def initialize(input, options)
- @input = input
- @options = options
- @samples = []
-
- prepare
- end
-
- def column_separator
- @column_separator
- end
-
- def row_separator
- @row_separator
- end
-
- def quote_character
- @quote_character
- end
-
- def field_size_limit
- @field_size_limit
- end
-
- def skip_lines
- @skip_lines
- end
-
- def unconverted_fields?
- @unconverted_fields
- end
-
- def headers
- @headers
- end
-
- def header_row?
- @use_headers and @headers.nil?
- end
-
- def return_headers?
- @return_headers
- end
-
- def skip_blanks?
- @skip_blanks
- end
-
- def liberal_parsing?
- @liberal_parsing
- end
-
- def lineno
- @lineno
- end
-
- def line
- last_line
- end
-
- def parse(&block)
- return to_enum(__method__) unless block_given?
-
- if @return_headers and @headers and @raw_headers
- headers = Row.new(@headers, @raw_headers, true)
- if @unconverted_fields
- headers = add_unconverted_fields(headers, [])
- end
- yield headers
- end
-
- begin
- @scanner ||= build_scanner
- if quote_character.nil?
- parse_no_quote(&block)
- elsif @need_robust_parsing
- parse_quotable_robust(&block)
- else
- parse_quotable_loose(&block)
- end
- rescue InvalidEncoding
- if @scanner
- ignore_broken_line
- lineno = @lineno
- else
- lineno = @lineno + 1
- end
- message = "Invalid byte sequence in #{@encoding}"
- raise MalformedCSVError.new(message, lineno)
- end
- end
-
- def use_headers?
- @use_headers
- end
-
- private
- # A set of tasks to prepare the file in order to parse it
- def prepare
- prepare_variable
- prepare_quote_character
- prepare_backslash
- prepare_skip_lines
- prepare_strip
- prepare_separators
- prepare_quoted
- prepare_unquoted
- prepare_line
- prepare_header
- prepare_parser
- end
-
- def prepare_variable
- @need_robust_parsing = false
- @encoding = @options[:encoding]
- liberal_parsing = @options[:liberal_parsing]
- if liberal_parsing
- @liberal_parsing = true
- if liberal_parsing.is_a?(Hash)
- @double_quote_outside_quote =
- liberal_parsing[:double_quote_outside_quote]
- @backslash_quote = liberal_parsing[:backslash_quote]
- else
- @double_quote_outside_quote = false
- @backslash_quote = false
- end
- @need_robust_parsing = true
- else
- @liberal_parsing = false
- @backslash_quote = false
- end
- @unconverted_fields = @options[:unconverted_fields]
- @field_size_limit = @options[:field_size_limit]
- @skip_blanks = @options[:skip_blanks]
- @fields_converter = @options[:fields_converter]
- @header_fields_converter = @options[:header_fields_converter]
- end
-
- def prepare_quote_character
- @quote_character = @options[:quote_character]
- if @quote_character.nil?
- @escaped_quote_character = nil
- @escaped_quote = nil
- else
- @quote_character = @quote_character.to_s.encode(@encoding)
- if @quote_character.length != 1
- message = ":quote_char has to be nil or a single character String"
- raise ArgumentError, message
- end
- @double_quote_character = @quote_character * 2
- @escaped_quote_character = Regexp.escape(@quote_character)
- @escaped_quote = Regexp.new(@escaped_quote_character)
- end
- end
-
- def prepare_backslash
- return unless @backslash_quote
-
- @backslash_character = "\\".encode(@encoding)
-
- @escaped_backslash_character = Regexp.escape(@backslash_character)
- @escaped_backslash = Regexp.new(@escaped_backslash_character)
- if @quote_character.nil?
- @backslash_quote_character = nil
- else
- @backslash_quote_character =
- @backslash_character + @escaped_quote_character
- end
- end
-
- def prepare_skip_lines
- skip_lines = @options[:skip_lines]
- case skip_lines
- when String
- @skip_lines = skip_lines.encode(@encoding)
- when Regexp, nil
- @skip_lines = skip_lines
- else
- unless skip_lines.respond_to?(:match)
- message =
- ":skip_lines has to respond to \#match: #{skip_lines.inspect}"
- raise ArgumentError, message
- end
- @skip_lines = skip_lines
- end
- end
-
- def prepare_strip
- @strip = @options[:strip]
- @escaped_strip = nil
- @strip_value = nil
- if @strip.is_a?(String)
- case @strip.length
- when 0
- raise ArgumentError, ":strip must not be an empty String"
- when 1
- # ok
- else
- raise ArgumentError, ":strip doesn't support 2 or more characters yet"
- end
- @strip = @strip.encode(@encoding)
- @escaped_strip = Regexp.escape(@strip)
- if @quote_character
- @strip_value = Regexp.new(@escaped_strip +
- "+".encode(@encoding))
- end
- @need_robust_parsing = true
- elsif @strip
- strip_values = " \t\f\v"
- @escaped_strip = strip_values.encode(@encoding)
- if @quote_character
- @strip_value = Regexp.new("[#{strip_values}]+".encode(@encoding))
- end
- @need_robust_parsing = true
- end
- end
-
- begin
- StringScanner.new("x").scan("x")
- rescue TypeError
- @@string_scanner_scan_accept_string = false
- else
- @@string_scanner_scan_accept_string = true
- end
-
- def prepare_separators
- column_separator = @options[:column_separator]
- @column_separator = column_separator.to_s.encode(@encoding)
- if @column_separator.size < 1
- message = ":col_sep must be 1 or more characters: "
- message += column_separator.inspect
- raise ArgumentError, message
- end
- @row_separator =
- resolve_row_separator(@options[:row_separator]).encode(@encoding)
-
- @escaped_column_separator = Regexp.escape(@column_separator)
- @escaped_first_column_separator = Regexp.escape(@column_separator[0])
- if @column_separator.size > 1
- @column_end = Regexp.new(@escaped_column_separator)
- @column_ends = @column_separator.each_char.collect do |char|
- Regexp.new(Regexp.escape(char))
- end
- @first_column_separators = Regexp.new(@escaped_first_column_separator +
- "+".encode(@encoding))
- else
- if @@string_scanner_scan_accept_string
- @column_end = @column_separator
- else
- @column_end = Regexp.new(@escaped_column_separator)
- end
- @column_ends = nil
- @first_column_separators = nil
- end
-
- escaped_row_separator = Regexp.escape(@row_separator)
- @row_end = Regexp.new(escaped_row_separator)
- if @row_separator.size > 1
- @row_ends = @row_separator.each_char.collect do |char|
- Regexp.new(Regexp.escape(char))
- end
- else
- @row_ends = nil
- end
-
- @cr = "\r".encode(@encoding)
- @lf = "\n".encode(@encoding)
- @cr_or_lf = Regexp.new("[\r\n]".encode(@encoding))
- @not_line_end = Regexp.new("[^\r\n]+".encode(@encoding))
- end
-
- def prepare_quoted
- if @quote_character
- @quotes = Regexp.new(@escaped_quote_character +
- "+".encode(@encoding))
- no_quoted_values = @escaped_quote_character.dup
- if @backslash_quote
- no_quoted_values << @escaped_backslash_character
- end
- @quoted_value = Regexp.new("[^".encode(@encoding) +
- no_quoted_values +
- "]+".encode(@encoding))
- end
- if @escaped_strip
- @split_column_separator = Regexp.new(@escaped_strip +
- "*".encode(@encoding) +
- @escaped_column_separator +
- @escaped_strip +
- "*".encode(@encoding))
- else
- if @column_separator == " ".encode(@encoding)
- @split_column_separator = Regexp.new(@escaped_column_separator)
- else
- @split_column_separator = @column_separator
- end
- end
- end
-
- def prepare_unquoted
- return if @quote_character.nil?
-
- no_unquoted_values = "\r\n".encode(@encoding)
- no_unquoted_values << @escaped_first_column_separator
- unless @liberal_parsing
- no_unquoted_values << @escaped_quote_character
- end
- if @escaped_strip
- no_unquoted_values << @escaped_strip
- end
- @unquoted_value = Regexp.new("[^".encode(@encoding) +
- no_unquoted_values +
- "]+".encode(@encoding))
- end
-
- def resolve_row_separator(separator)
- if separator == :auto
- cr = "\r".encode(@encoding)
- lf = "\n".encode(@encoding)
- if @input.is_a?(StringIO)
- pos = @input.pos
- separator = detect_row_separator(@input.read, cr, lf)
- @input.seek(pos)
- elsif @input.respond_to?(:gets)
- if @input.is_a?(File)
- chunk_size = 32 * 1024
- else
- chunk_size = 1024
- end
- begin
- while separator == :auto
- #
- # if we run out of data, it's probably a single line
- # (ensure will set default value)
- #
- break unless sample = @input.gets(nil, chunk_size)
-
- # extend sample if we're unsure of the line ending
- if sample.end_with?(cr)
- sample << (@input.gets(nil, 1) || "")
- end
-
- @samples << sample
-
- separator = detect_row_separator(sample, cr, lf)
- end
- rescue IOError
- # do nothing: ensure will set default
- end
- end
- separator = $INPUT_RECORD_SEPARATOR if separator == :auto
- end
- separator.to_s.encode(@encoding)
- end
-
- def detect_row_separator(sample, cr, lf)
- lf_index = sample.index(lf)
- if lf_index
- cr_index = sample[0, lf_index].index(cr)
- else
- cr_index = sample.index(cr)
- end
- if cr_index and lf_index
- if cr_index + 1 == lf_index
- cr + lf
- elsif cr_index < lf_index
- cr
- else
- lf
- end
- elsif cr_index
- cr
- elsif lf_index
- lf
- else
- :auto
- end
- end
-
- def prepare_line
- @lineno = 0
- @last_line = nil
- @scanner = nil
- end
-
- def last_line
- if @scanner
- @last_line ||= @scanner.keep_end
- else
- @last_line
- end
- end
-
- def prepare_header
- @return_headers = @options[:return_headers]
-
- headers = @options[:headers]
- case headers
- when Array
- @raw_headers = headers
- @use_headers = true
- when String
- @raw_headers = parse_headers(headers)
- @use_headers = true
- when nil, false
- @raw_headers = nil
- @use_headers = false
- else
- @raw_headers = nil
- @use_headers = true
- end
- if @raw_headers
- @headers = adjust_headers(@raw_headers)
- else
- @headers = nil
- end
- end
-
- def parse_headers(row)
- CSV.parse_line(row,
- col_sep: @column_separator,
- row_sep: @row_separator,
- quote_char: @quote_character)
- end
-
- def adjust_headers(headers)
- adjusted_headers = @header_fields_converter.convert(headers, nil, @lineno)
- adjusted_headers.each {|h| h.freeze if h.is_a? String}
- adjusted_headers
- end
-
- def prepare_parser
- @may_quoted = may_quoted?
- end
-
- def may_quoted?
- return false if @quote_character.nil?
-
- if @input.is_a?(StringIO)
- pos = @input.pos
- sample = @input.read
- @input.seek(pos)
- else
- return false if @samples.empty?
- sample = @samples.first
- end
- sample[0, 128].index(@quote_character)
- end
-
- SCANNER_TEST = (ENV["CSV_PARSER_SCANNER_TEST"] == "yes")
- if SCANNER_TEST
- class UnoptimizedStringIO
- def initialize(string)
- @io = StringIO.new(string)
- end
-
- def gets(*args)
- @io.gets(*args)
- end
-
- def each_line(*args, &block)
- @io.each_line(*args, &block)
- end
-
- def eof?
- @io.eof?
- end
- end
-
- def build_scanner
- inputs = @samples.collect do |sample|
- UnoptimizedStringIO.new(sample)
- end
- if @input.is_a?(StringIO)
- inputs << UnoptimizedStringIO.new(@input.read)
- else
- inputs << @input
- end
- chunk_size = ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] || "1"
- InputsScanner.new(inputs,
- @encoding,
- chunk_size: Integer(chunk_size, 10))
- end
- else
- def build_scanner
- string = nil
- if @samples.empty? and @input.is_a?(StringIO)
- string = @input.read
- elsif @samples.size == 1 and @input.respond_to?(:eof?) and @input.eof?
- string = @samples[0]
- end
- if string
- unless string.valid_encoding?
- index = string.lines(@row_separator).index do |line|
- !line.valid_encoding?
- end
- if index
- message = "Invalid byte sequence in #{@encoding}"
- raise MalformedCSVError.new(message, @lineno + index + 1)
- end
- end
- Scanner.new(string)
- else
- inputs = @samples.collect do |sample|
- StringIO.new(sample)
- end
- inputs << @input
- InputsScanner.new(inputs, @encoding)
- end
- end
- end
-
- def skip_needless_lines
- return unless @skip_lines
-
- while true
- @scanner.keep_start
- line = @scanner.scan_all(@not_line_end) || "".encode(@encoding)
- line << @row_separator if parse_row_end
- if skip_line?(line)
- @lineno += 1
- @scanner.keep_drop
- else
- @scanner.keep_back
- return
- end
- end
- end
-
- def skip_line?(line)
- case @skip_lines
- when String
- line.include?(@skip_lines)
- when Regexp
- @skip_lines.match?(line)
- else
- @skip_lines.match(line)
- end
- end
-
- def parse_no_quote(&block)
- @scanner.each_line(@row_separator) do |line|
- next if @skip_lines and skip_line?(line)
- original_line = line
- line = line.delete_suffix(@row_separator)
-
- if line.empty?
- next if @skip_blanks
- row = []
- else
- line = strip_value(line)
- row = line.split(@split_column_separator, -1)
- n_columns = row.size
- i = 0
- while i < n_columns
- row[i] = nil if row[i].empty?
- i += 1
- end
- end
- @last_line = original_line
- emit_row(row, &block)
- end
- end
-
- def parse_quotable_loose(&block)
- @scanner.keep_start
- @scanner.each_line(@row_separator) do |line|
- if @skip_lines and skip_line?(line)
- @scanner.keep_drop
- @scanner.keep_start
- next
- end
- original_line = line
- line = line.delete_suffix(@row_separator)
-
- if line.empty?
- if @skip_blanks
- @scanner.keep_drop
- @scanner.keep_start
- next
- end
- row = []
- elsif line.include?(@cr) or line.include?(@lf)
- @scanner.keep_back
- @need_robust_parsing = true
- return parse_quotable_robust(&block)
- else
- row = line.split(@split_column_separator, -1)
- n_columns = row.size
- i = 0
- while i < n_columns
- column = row[i]
- if column.empty?
- row[i] = nil
- else
- n_quotes = column.count(@quote_character)
- if n_quotes.zero?
- # no quote
- elsif n_quotes == 2 and
- column.start_with?(@quote_character) and
- column.end_with?(@quote_character)
- row[i] = column[1..-2]
- else
- @scanner.keep_back
- @need_robust_parsing = true
- return parse_quotable_robust(&block)
- end
- end
- i += 1
- end
- end
- @scanner.keep_drop
- @scanner.keep_start
- @last_line = original_line
- emit_row(row, &block)
- end
- @scanner.keep_drop
- end
-
- def parse_quotable_robust(&block)
- row = []
- skip_needless_lines
- start_row
- while true
- @quoted_column_value = false
- @unquoted_column_value = false
- @scanner.scan_all(@strip_value) if @strip_value
- value = parse_column_value
- if value
- @scanner.scan_all(@strip_value) if @strip_value
- if @field_size_limit and value.size >= @field_size_limit
- ignore_broken_line
- raise MalformedCSVError.new("Field size exceeded", @lineno)
- end
- end
- if parse_column_end
- row << value
- elsif parse_row_end
- if row.empty? and value.nil?
- emit_row([], &block) unless @skip_blanks
- else
- row << value
- emit_row(row, &block)
- row = []
- end
- skip_needless_lines
- start_row
- elsif @scanner.eos?
- break if row.empty? and value.nil?
- row << value
- emit_row(row, &block)
- break
- else
- if @quoted_column_value
- ignore_broken_line
- message = "Any value after quoted field isn't allowed"
- raise MalformedCSVError.new(message, @lineno)
- elsif @unquoted_column_value and
- (new_line = @scanner.scan(@cr_or_lf))
- ignore_broken_line
- message = "Unquoted fields do not allow new line " +
- "<#{new_line.inspect}>"
- raise MalformedCSVError.new(message, @lineno)
- elsif @scanner.rest.start_with?(@quote_character)
- ignore_broken_line
- message = "Illegal quoting"
- raise MalformedCSVError.new(message, @lineno)
- elsif (new_line = @scanner.scan(@cr_or_lf))
- ignore_broken_line
- message = "New line must be <#{@row_separator.inspect}> " +
- "not <#{new_line.inspect}>"
- raise MalformedCSVError.new(message, @lineno)
- else
- ignore_broken_line
- raise MalformedCSVError.new("TODO: Meaningful message",
- @lineno)
- end
- end
- end
- end
-
- def parse_column_value
- if @liberal_parsing
- quoted_value = parse_quoted_column_value
- if quoted_value
- unquoted_value = parse_unquoted_column_value
- if unquoted_value
- if @double_quote_outside_quote
- unquoted_value = unquoted_value.gsub(@quote_character * 2,
- @quote_character)
- if quoted_value.empty? # %Q{""...} case
- return @quote_character + unquoted_value
- end
- end
- @quote_character + quoted_value + @quote_character + unquoted_value
- else
- quoted_value
- end
- else
- parse_unquoted_column_value
- end
- elsif @may_quoted
- parse_quoted_column_value ||
- parse_unquoted_column_value
- else
- parse_unquoted_column_value ||
- parse_quoted_column_value
- end
- end
-
- def parse_unquoted_column_value
- value = @scanner.scan_all(@unquoted_value)
- return nil unless value
-
- @unquoted_column_value = true
- if @first_column_separators
- while true
- @scanner.keep_start
- is_column_end = @column_ends.all? do |column_end|
- @scanner.scan(column_end)
- end
- @scanner.keep_back
- break if is_column_end
- sub_separator = @scanner.scan_all(@first_column_separators)
- break if sub_separator.nil?
- value << sub_separator
- sub_value = @scanner.scan_all(@unquoted_value)
- break if sub_value.nil?
- value << sub_value
- end
- end
- value.gsub!(@backslash_quote_character, @quote_character) if @backslash_quote
- value
- end
-
- def parse_quoted_column_value
- quotes = @scanner.scan_all(@quotes)
- return nil unless quotes
-
- @quoted_column_value = true
- n_quotes = quotes.size
- if (n_quotes % 2).zero?
- quotes[0, (n_quotes - 2) / 2]
- else
- value = quotes[0, (n_quotes - 1) / 2]
- while true
- quoted_value = @scanner.scan_all(@quoted_value)
- value << quoted_value if quoted_value
- if @backslash_quote
- if @scanner.scan(@escaped_backslash)
- if @scanner.scan(@escaped_quote)
- value << @quote_character
- else
- value << @backslash_character
- end
- next
- end
- end
-
- quotes = @scanner.scan_all(@quotes)
- unless quotes
- ignore_broken_line
- message = "Unclosed quoted field"
- raise MalformedCSVError.new(message, @lineno)
- end
- n_quotes = quotes.size
- if n_quotes == 1
- break
- elsif (n_quotes % 2) == 1
- value << quotes[0, (n_quotes - 1) / 2]
- break
- else
- value << quotes[0, n_quotes / 2]
- end
- end
- value
- end
- end
-
- def parse_column_end
- return true if @scanner.scan(@column_end)
- return false unless @column_ends
-
- @scanner.keep_start
- if @column_ends.all? {|column_end| @scanner.scan(column_end)}
- @scanner.keep_drop
- true
- else
- @scanner.keep_back
- false
- end
- end
-
- def parse_row_end
- return true if @scanner.scan(@row_end)
- return false unless @row_ends
- @scanner.keep_start
- if @row_ends.all? {|row_end| @scanner.scan(row_end)}
- @scanner.keep_drop
- true
- else
- @scanner.keep_back
- false
- end
- end
-
- def strip_value(value)
- return value unless @strip
- return nil if value.nil?
-
- case @strip
- when String
- size = value.size
- while value.start_with?(@strip)
- size -= 1
- value = value[1, size]
- end
- while value.end_with?(@strip)
- size -= 1
- value = value[0, size]
- end
- else
- value.strip!
- end
- value
- end
-
- def ignore_broken_line
- @scanner.scan_all(@not_line_end)
- @scanner.scan_all(@cr_or_lf)
- @lineno += 1
- end
-
- def start_row
- if @last_line
- @last_line = nil
- else
- @scanner.keep_drop
- end
- @scanner.keep_start
- end
-
- def emit_row(row, &block)
- @lineno += 1
-
- raw_row = row
- if @use_headers
- if @headers.nil?
- @headers = adjust_headers(row)
- return unless @return_headers
- row = Row.new(@headers, row, true)
- else
- row = Row.new(@headers,
- @fields_converter.convert(raw_row, @headers, @lineno))
- end
- else
- # convert fields, if needed...
- row = @fields_converter.convert(raw_row, nil, @lineno)
- end
-
- # inject unconverted fields and accessor, if requested...
- if @unconverted_fields and not row.respond_to?(:unconverted_fields)
- add_unconverted_fields(row, raw_row)
- end
-
- yield(row)
- end
-
- # This method injects an instance variable <tt>unconverted_fields</tt> into
- # +row+ and an accessor method for +row+ called unconverted_fields(). The
- # variable is set to the contents of +fields+.
- def add_unconverted_fields(row, fields)
- class << row
- attr_reader :unconverted_fields
- end
- row.instance_variable_set(:@unconverted_fields, fields)
- row
- end
- end
-end
diff --git a/lib/csv/row.rb b/lib/csv/row.rb
deleted file mode 100644
index 4aa0f30911..0000000000
--- a/lib/csv/row.rb
+++ /dev/null
@@ -1,390 +0,0 @@
-# frozen_string_literal: true
-
-require "forwardable"
-
-class CSV
- #
- # A CSV::Row is part Array and part Hash. It retains an order for the fields
- # and allows duplicates just as an Array would, but also allows you to access
- # fields by name just as you could if they were in a Hash.
- #
- # All rows returned by CSV will be constructed from this class, if header row
- # processing is activated.
- #
- class Row
- #
- # Constructs a new CSV::Row from +headers+ and +fields+, which are expected
- # to be Arrays. If one Array is shorter than the other, it will be padded
- # with +nil+ objects.
- #
- # The optional +header_row+ parameter can be set to +true+ to indicate, via
- # CSV::Row.header_row?() and CSV::Row.field_row?(), that this is a header
- # row. Otherwise, the row assumes to be a field row.
- #
- # A CSV::Row object supports the following Array methods through delegation:
- #
- # * empty?()
- # * length()
- # * size()
- #
- def initialize(headers, fields, header_row = false)
- @header_row = header_row
- headers.each { |h| h.freeze if h.is_a? String }
-
- # handle extra headers or fields
- @row = if headers.size >= fields.size
- headers.zip(fields)
- else
- fields.zip(headers).each(&:reverse!)
- end
- end
-
- # Internal data format used to compare equality.
- attr_reader :row
- protected :row
-
- ### Array Delegation ###
-
- extend Forwardable
- def_delegators :@row, :empty?, :length, :size
-
- def initialize_copy(other)
- super
- @row = @row.dup
- end
-
- # Returns +true+ if this is a header row.
- def header_row?
- @header_row
- end
-
- # Returns +true+ if this is a field row.
- def field_row?
- not header_row?
- end
-
- # Returns the headers of this row.
- def headers
- @row.map(&:first)
- end
-
- #
- # :call-seq:
- # field( header )
- # field( header, offset )
- # field( index )
- #
- # This method will return the field value by +header+ or +index+. If a field
- # is not found, +nil+ is returned.
- #
- # When provided, +offset+ ensures that a header match occurs on or later
- # than the +offset+ index. You can use this to find duplicate headers,
- # without resorting to hard-coding exact indices.
- #
- def field(header_or_index, minimum_index = 0)
- # locate the pair
- finder = (header_or_index.is_a?(Integer) || header_or_index.is_a?(Range)) ? :[] : :assoc
- pair = @row[minimum_index..-1].send(finder, header_or_index)
-
- # return the field if we have a pair
- if pair.nil?
- nil
- else
- header_or_index.is_a?(Range) ? pair.map(&:last) : pair.last
- end
- end
- alias_method :[], :field
-
- #
- # :call-seq:
- # fetch( header )
- # fetch( header ) { |row| ... }
- # fetch( header, default )
- #
- # This method will fetch the field value by +header+. It has the same
- # behavior as Hash#fetch: if there is a field with the given +header+, its
- # value is returned. Otherwise, if a block is given, it is yielded the
- # +header+ and its result is returned; if a +default+ is given as the
- # second argument, it is returned; otherwise a KeyError is raised.
- #
- def fetch(header, *varargs)
- raise ArgumentError, "Too many arguments" if varargs.length > 1
- pair = @row.assoc(header)
- if pair
- pair.last
- else
- if block_given?
- yield header
- elsif varargs.empty?
- raise KeyError, "key not found: #{header}"
- else
- varargs.first
- end
- end
- end
-
- # Returns +true+ if there is a field with the given +header+.
- def has_key?(header)
- !!@row.assoc(header)
- end
- alias_method :include?, :has_key?
- alias_method :key?, :has_key?
- alias_method :member?, :has_key?
- alias_method :header?, :has_key?
-
- #
- # :call-seq:
- # []=( header, value )
- # []=( header, offset, value )
- # []=( index, value )
- #
- # Looks up the field by the semantics described in CSV::Row.field() and
- # assigns the +value+.
- #
- # Assigning past the end of the row with an index will set all pairs between
- # to <tt>[nil, nil]</tt>. Assigning to an unused header appends the new
- # pair.
- #
- def []=(*args)
- value = args.pop
-
- if args.first.is_a? Integer
- if @row[args.first].nil? # extending past the end with index
- @row[args.first] = [nil, value]
- @row.map! { |pair| pair.nil? ? [nil, nil] : pair }
- else # normal index assignment
- @row[args.first][1] = value
- end
- else
- index = index(*args)
- if index.nil? # appending a field
- self << [args.first, value]
- else # normal header assignment
- @row[index][1] = value
- end
- end
- end
-
- #
- # :call-seq:
- # <<( field )
- # <<( header_and_field_array )
- # <<( header_and_field_hash )
- #
- # If a two-element Array is provided, it is assumed to be a header and field
- # and the pair is appended. A Hash works the same way with the key being
- # the header and the value being the field. Anything else is assumed to be
- # a lone field which is appended with a +nil+ header.
- #
- # This method returns the row for chaining.
- #
- def <<(arg)
- if arg.is_a?(Array) and arg.size == 2 # appending a header and name
- @row << arg
- elsif arg.is_a?(Hash) # append header and name pairs
- arg.each { |pair| @row << pair }
- else # append field value
- @row << [nil, arg]
- end
-
- self # for chaining
- end
-
- #
- # A shortcut for appending multiple fields. Equivalent to:
- #
- # args.each { |arg| csv_row << arg }
- #
- # This method returns the row for chaining.
- #
- def push(*args)
- args.each { |arg| self << arg }
-
- self # for chaining
- end
-
- #
- # :call-seq:
- # delete( header )
- # delete( header, offset )
- # delete( index )
- #
- # Removes a pair from the row by +header+ or +index+. The pair is
- # located as described in CSV::Row.field(). The deleted pair is returned,
- # or +nil+ if a pair could not be found.
- #
- def delete(header_or_index, minimum_index = 0)
- if header_or_index.is_a? Integer # by index
- @row.delete_at(header_or_index)
- elsif i = index(header_or_index, minimum_index) # by header
- @row.delete_at(i)
- else
- [ ]
- end
- end
-
- #
- # The provided +block+ is passed a header and field for each pair in the row
- # and expected to return +true+ or +false+, depending on whether the pair
- # should be deleted.
- #
- # This method returns the row for chaining.
- #
- # If no block is given, an Enumerator is returned.
- #
- def delete_if(&block)
- return enum_for(__method__) { size } unless block_given?
-
- @row.delete_if(&block)
-
- self # for chaining
- end
-
- #
- # This method accepts any number of arguments which can be headers, indices,
- # Ranges of either, or two-element Arrays containing a header and offset.
- # Each argument will be replaced with a field lookup as described in
- # CSV::Row.field().
- #
- # If called with no arguments, all fields are returned.
- #
- def fields(*headers_and_or_indices)
- if headers_and_or_indices.empty? # return all fields--no arguments
- @row.map(&:last)
- else # or work like values_at()
- all = []
- headers_and_or_indices.each do |h_or_i|
- if h_or_i.is_a? Range
- index_begin = h_or_i.begin.is_a?(Integer) ? h_or_i.begin :
- index(h_or_i.begin)
- index_end = h_or_i.end.is_a?(Integer) ? h_or_i.end :
- index(h_or_i.end)
- new_range = h_or_i.exclude_end? ? (index_begin...index_end) :
- (index_begin..index_end)
- all.concat(fields.values_at(new_range))
- else
- all << field(*Array(h_or_i))
- end
- end
- return all
- end
- end
- alias_method :values_at, :fields
-
- #
- # :call-seq:
- # index( header )
- # index( header, offset )
- #
- # This method will return the index of a field with the provided +header+.
- # The +offset+ can be used to locate duplicate header names, as described in
- # CSV::Row.field().
- #
- def index(header, minimum_index = 0)
- # find the pair
- index = headers[minimum_index..-1].index(header)
- # return the index at the right offset, if we found one
- index.nil? ? nil : index + minimum_index
- end
-
- #
- # Returns +true+ if +data+ matches a field in this row, and +false+
- # otherwise.
- #
- def field?(data)
- fields.include? data
- end
-
- include Enumerable
-
- #
- # Yields each pair of the row as header and field tuples (much like
- # iterating over a Hash). This method returns the row for chaining.
- #
- # If no block is given, an Enumerator is returned.
- #
- # Support for Enumerable.
- #
- def each(&block)
- return enum_for(__method__) { size } unless block_given?
-
- @row.each(&block)
-
- self # for chaining
- end
-
- alias_method :each_pair, :each
-
- #
- # Returns +true+ if this row contains the same headers and fields in the
- # same order as +other+.
- #
- def ==(other)
- return @row == other.row if other.is_a? CSV::Row
- @row == other
- end
-
- #
- # Collapses the row into a simple Hash. Be warned that this discards field
- # order and clobbers duplicate fields.
- #
- def to_h
- hash = {}
- each do |key, _value|
- hash[key] = self[key] unless hash.key?(key)
- end
- hash
- end
- alias_method :to_hash, :to_h
-
- alias_method :to_ary, :to_a
-
- #
- # Returns the row as a CSV String. Headers are not used. Equivalent to:
- #
- # csv_row.fields.to_csv( options )
- #
- def to_csv(**options)
- fields.to_csv(**options)
- end
- alias_method :to_s, :to_csv
-
- #
- # Extracts the nested value specified by the sequence of +index+ or +header+ objects by calling dig at each step,
- # returning nil if any intermediate step is nil.
- #
- def dig(index_or_header, *indexes)
- value = field(index_or_header)
- if value.nil?
- nil
- elsif indexes.empty?
- value
- else
- unless value.respond_to?(:dig)
- raise TypeError, "#{value.class} does not have \#dig method"
- end
- value.dig(*indexes)
- end
- end
-
- #
- # A summary of fields, by header, in an ASCII compatible String.
- #
- def inspect
- str = ["#<", self.class.to_s]
- each do |header, field|
- str << " " << (header.is_a?(Symbol) ? header.to_s : header.inspect) <<
- ":" << field.inspect
- end
- str << ">"
- begin
- str.join('')
- rescue # any encoding error
- str.map do |s|
- e = Encoding::Converter.asciicompat_encoding(s.encoding)
- e ? s.encode(e) : s.force_encoding("ASCII-8BIT")
- end.join('')
- end
- end
- end
-end
diff --git a/lib/csv/table.rb b/lib/csv/table.rb
deleted file mode 100644
index e6c1ee11fa..0000000000
--- a/lib/csv/table.rb
+++ /dev/null
@@ -1,402 +0,0 @@
-# frozen_string_literal: true
-
-require "forwardable"
-
-class CSV
- #
- # A CSV::Table is a two-dimensional data structure for representing CSV
- # documents. Tables allow you to work with the data by row or column,
- # manipulate the data, and even convert the results back to CSV, if needed.
- #
- # All tables returned by CSV will be constructed from this class, if header
- # row processing is activated.
- #
- class Table
- #
- # Constructs a new CSV::Table from +array_of_rows+, which are expected
- # to be CSV::Row objects. All rows are assumed to have the same headers.
- #
- # The optional +headers+ parameter can be set to Array of headers.
- # If headers aren't set, headers are fetched from CSV::Row objects.
- # Otherwise, headers() method will return headers being set in
- # headers argument.
- #
- # A CSV::Table object supports the following Array methods through
- # delegation:
- #
- # * empty?()
- # * length()
- # * size()
- #
- def initialize(array_of_rows, headers: nil)
- @table = array_of_rows
- @headers = headers
- unless @headers
- if @table.empty?
- @headers = []
- else
- @headers = @table.first.headers
- end
- end
-
- @mode = :col_or_row
- end
-
- # The current access mode for indexing and iteration.
- attr_reader :mode
-
- # Internal data format used to compare equality.
- attr_reader :table
- protected :table
-
- ### Array Delegation ###
-
- extend Forwardable
- def_delegators :@table, :empty?, :length, :size
-
- #
- # Returns a duplicate table object, in column mode. This is handy for
- # chaining in a single call without changing the table mode, but be aware
- # that this method can consume a fair amount of memory for bigger data sets.
- #
- # This method returns the duplicate table for chaining. Don't chain
- # destructive methods (like []=()) this way though, since you are working
- # with a duplicate.
- #
- def by_col
- self.class.new(@table.dup).by_col!
- end
-
- #
- # Switches the mode of this table to column mode. All calls to indexing and
- # iteration methods will work with columns until the mode is changed again.
- #
- # This method returns the table and is safe to chain.
- #
- def by_col!
- @mode = :col
-
- self
- end
-
- #
- # Returns a duplicate table object, in mixed mode. This is handy for
- # chaining in a single call without changing the table mode, but be aware
- # that this method can consume a fair amount of memory for bigger data sets.
- #
- # This method returns the duplicate table for chaining. Don't chain
- # destructive methods (like []=()) this way though, since you are working
- # with a duplicate.
- #
- def by_col_or_row
- self.class.new(@table.dup).by_col_or_row!
- end
-
- #
- # Switches the mode of this table to mixed mode. All calls to indexing and
- # iteration methods will use the default intelligent indexing system until
- # the mode is changed again. In mixed mode an index is assumed to be a row
- # reference while anything else is assumed to be column access by headers.
- #
- # This method returns the table and is safe to chain.
- #
- def by_col_or_row!
- @mode = :col_or_row
-
- self
- end
-
- #
- # Returns a duplicate table object, in row mode. This is handy for chaining
- # in a single call without changing the table mode, but be aware that this
- # method can consume a fair amount of memory for bigger data sets.
- #
- # This method returns the duplicate table for chaining. Don't chain
- # destructive methods (like []=()) this way though, since you are working
- # with a duplicate.
- #
- def by_row
- self.class.new(@table.dup).by_row!
- end
-
- #
- # Switches the mode of this table to row mode. All calls to indexing and
- # iteration methods will work with rows until the mode is changed again.
- #
- # This method returns the table and is safe to chain.
- #
- def by_row!
- @mode = :row
-
- self
- end
-
- #
- # Returns the headers for the first row of this table (assumed to match all
- # other rows). The headers Array passed to CSV::Table.new is returned for
- # empty tables.
- #
- def headers
- if @table.empty?
- @headers.dup
- else
- @table.first.headers
- end
- end
-
- #
- # In the default mixed mode, this method returns rows for index access and
- # columns for header access. You can force the index association by first
- # calling by_col!() or by_row!().
- #
- # Columns are returned as an Array of values. Altering that Array has no
- # effect on the table.
- #
- def [](index_or_header)
- if @mode == :row or # by index
- (@mode == :col_or_row and (index_or_header.is_a?(Integer) or index_or_header.is_a?(Range)))
- @table[index_or_header]
- else # by header
- @table.map { |row| row[index_or_header] }
- end
- end
-
- #
- # In the default mixed mode, this method assigns rows for index access and
- # columns for header access. You can force the index association by first
- # calling by_col!() or by_row!().
- #
- # Rows may be set to an Array of values (which will inherit the table's
- # headers()) or a CSV::Row.
- #
- # Columns may be set to a single value, which is copied to each row of the
- # column, or an Array of values. Arrays of values are assigned to rows top
- # to bottom in row major order. Excess values are ignored and if the Array
- # does not have a value for each row the extra rows will receive a +nil+.
- #
- # Assigning to an existing column or row clobbers the data. Assigning to
- # new columns creates them at the right end of the table.
- #
- def []=(index_or_header, value)
- if @mode == :row or # by index
- (@mode == :col_or_row and index_or_header.is_a? Integer)
- if value.is_a? Array
- @table[index_or_header] = Row.new(headers, value)
- else
- @table[index_or_header] = value
- end
- else # set column
- unless index_or_header.is_a? Integer
- index = @headers.index(index_or_header) || @headers.size
- @headers[index] = index_or_header
- end
- if value.is_a? Array # multiple values
- @table.each_with_index do |row, i|
- if row.header_row?
- row[index_or_header] = index_or_header
- else
- row[index_or_header] = value[i]
- end
- end
- else # repeated value
- @table.each do |row|
- if row.header_row?
- row[index_or_header] = index_or_header
- else
- row[index_or_header] = value
- end
- end
- end
- end
- end
-
- #
- # The mixed mode default is to treat a list of indices as row access,
- # returning the rows indicated. Anything else is considered columnar
- # access. For columnar access, the return set has an Array for each row
- # with the values indicated by the headers in each Array. You can force
- # column or row mode using by_col!() or by_row!().
- #
- # You cannot mix column and row access.
- #
- def values_at(*indices_or_headers)
- if @mode == :row or # by indices
- ( @mode == :col_or_row and indices_or_headers.all? do |index|
- index.is_a?(Integer) or
- ( index.is_a?(Range) and
- index.first.is_a?(Integer) and
- index.last.is_a?(Integer) )
- end )
- @table.values_at(*indices_or_headers)
- else # by headers
- @table.map { |row| row.values_at(*indices_or_headers) }
- end
- end
-
- #
- # Adds a new row to the bottom end of this table. You can provide an Array,
- # which will be converted to a CSV::Row (inheriting the table's headers()),
- # or a CSV::Row.
- #
- # This method returns the table for chaining.
- #
- def <<(row_or_array)
- if row_or_array.is_a? Array # append Array
- @table << Row.new(headers, row_or_array)
- else # append Row
- @table << row_or_array
- end
-
- self # for chaining
- end
-
- #
- # A shortcut for appending multiple rows. Equivalent to:
- #
- # rows.each { |row| self << row }
- #
- # This method returns the table for chaining.
- #
- def push(*rows)
- rows.each { |row| self << row }
-
- self # for chaining
- end
-
- #
- # Removes and returns the indicated columns or rows. In the default mixed
- # mode indices refer to rows and everything else is assumed to be a column
- # headers. Use by_col!() or by_row!() to force the lookup.
- #
- def delete(*indexes_or_headers)
- if indexes_or_headers.empty?
- raise ArgumentError, "wrong number of arguments (given 0, expected 1+)"
- end
- deleted_values = indexes_or_headers.map do |index_or_header|
- if @mode == :row or # by index
- (@mode == :col_or_row and index_or_header.is_a? Integer)
- @table.delete_at(index_or_header)
- else # by header
- if index_or_header.is_a? Integer
- @headers.delete_at(index_or_header)
- else
- @headers.delete(index_or_header)
- end
- @table.map { |row| row.delete(index_or_header).last }
- end
- end
- if indexes_or_headers.size == 1
- deleted_values[0]
- else
- deleted_values
- end
- end
-
- #
- # Removes any column or row for which the block returns +true+. In the
- # default mixed mode or row mode, iteration is the standard row major
- # walking of rows. In column mode, iteration will +yield+ two element
- # tuples containing the column name and an Array of values for that column.
- #
- # This method returns the table for chaining.
- #
- # If no block is given, an Enumerator is returned.
- #
- def delete_if(&block)
- return enum_for(__method__) { @mode == :row or @mode == :col_or_row ? size : headers.size } unless block_given?
-
- if @mode == :row or @mode == :col_or_row # by index
- @table.delete_if(&block)
- else # by header
- deleted = []
- headers.each do |header|
- deleted << delete(header) if yield([header, self[header]])
- end
- end
-
- self # for chaining
- end
-
- include Enumerable
-
- #
- # In the default mixed mode or row mode, iteration is the standard row major
- # walking of rows. In column mode, iteration will +yield+ two element
- # tuples containing the column name and an Array of values for that column.
- #
- # This method returns the table for chaining.
- #
- # If no block is given, an Enumerator is returned.
- #
- def each(&block)
- return enum_for(__method__) { @mode == :col ? headers.size : size } unless block_given?
-
- if @mode == :col
- headers.each { |header| yield([header, self[header]]) }
- else
- @table.each(&block)
- end
-
- self # for chaining
- end
-
- # Returns +true+ if all rows of this table ==() +other+'s rows.
- def ==(other)
- return @table == other.table if other.is_a? CSV::Table
- @table == other
- end
-
- #
- # Returns the table as an Array of Arrays. Headers will be the first row,
- # then all of the field rows will follow.
- #
- def to_a
- array = [headers]
- @table.each do |row|
- array.push(row.fields) unless row.header_row?
- end
-
- array
- end
-
- #
- # Returns the table as a complete CSV String. Headers will be listed first,
- # then all of the field rows.
- #
- # This method assumes you want the Table.headers(), unless you explicitly
- # pass <tt>:write_headers => false</tt>.
- #
- def to_csv(write_headers: true, **options)
- array = write_headers ? [headers.to_csv(**options)] : []
- @table.each do |row|
- array.push(row.fields.to_csv(**options)) unless row.header_row?
- end
-
- array.join("")
- end
- alias_method :to_s, :to_csv
-
- #
- # Extracts the nested value specified by the sequence of +index+ or +header+ objects by calling dig at each step,
- # returning nil if any intermediate step is nil.
- #
- def dig(index_or_header, *index_or_headers)
- value = self[index_or_header]
- if value.nil?
- nil
- elsif index_or_headers.empty?
- value
- else
- unless value.respond_to?(:dig)
- raise TypeError, "#{value.class} does not have \#dig method"
- end
- value.dig(*index_or_headers)
- end
- end
-
- # Shows the mode and size of this table in a US-ASCII String.
- def inspect
- "#<#{self.class} mode:#{@mode} row_count:#{to_a.size}>".encode("US-ASCII")
- end
- end
-end
diff --git a/lib/csv/version.rb b/lib/csv/version.rb
deleted file mode 100644
index 072400fe01..0000000000
--- a/lib/csv/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-class CSV
- # The version of the installed library.
- VERSION = "3.1.2"
-end
diff --git a/lib/csv/writer.rb b/lib/csv/writer.rb
deleted file mode 100644
index 9243d23641..0000000000
--- a/lib/csv/writer.rb
+++ /dev/null
@@ -1,168 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "match_p"
-require_relative "row"
-
-using CSV::MatchP if CSV.const_defined?(:MatchP)
-
-class CSV
- # Note: Don't use this class directly. This is an internal class.
- class Writer
- #
- # A CSV::Writer receives an output, prepares the header, format and output.
- # It allows us to write new rows in the object and rewind it.
- #
- attr_reader :lineno
- attr_reader :headers
-
- def initialize(output, options)
- @output = output
- @options = options
- @lineno = 0
- @fields_converter = nil
- prepare
- if @options[:write_headers] and @headers
- self << @headers
- end
- @fields_converter = @options[:fields_converter]
- end
-
- #
- # Adds a new row
- #
- def <<(row)
- case row
- when Row
- row = row.fields
- when Hash
- row = @headers.collect {|header| row[header]}
- end
-
- @headers ||= row if @use_headers
- @lineno += 1
-
- row = @fields_converter.convert(row, nil, lineno) if @fields_converter
-
- converted_row = row.collect do |field|
- quote(field)
- end
- line = converted_row.join(@column_separator) + @row_separator
- if @output_encoding
- line = line.encode(@output_encoding)
- end
- @output << line
-
- self
- end
-
- #
- # Winds back to the beginning
- #
- def rewind
- @lineno = 0
- @headers = nil if @options[:headers].nil?
- end
-
- private
- def prepare
- @encoding = @options[:encoding]
-
- prepare_header
- prepare_format
- prepare_output
- end
-
- def prepare_header
- headers = @options[:headers]
- case headers
- when Array
- @headers = headers
- @use_headers = true
- when String
- @headers = CSV.parse_line(headers,
- col_sep: @options[:column_separator],
- row_sep: @options[:row_separator],
- quote_char: @options[:quote_character])
- @use_headers = true
- when true
- @headers = nil
- @use_headers = true
- else
- @headers = nil
- @use_headers = false
- end
- return unless @headers
-
- converter = @options[:header_fields_converter]
- @headers = converter.convert(@headers, nil, 0)
- @headers.each do |header|
- header.freeze if header.is_a?(String)
- end
- end
-
- def prepare_format
- @column_separator = @options[:column_separator].to_s.encode(@encoding)
- row_separator = @options[:row_separator]
- if row_separator == :auto
- @row_separator = $INPUT_RECORD_SEPARATOR.encode(@encoding)
- else
- @row_separator = row_separator.to_s.encode(@encoding)
- end
- @quote_character = @options[:quote_character]
- @force_quotes = @options[:force_quotes]
- unless @force_quotes
- @quotable_pattern =
- Regexp.new("[\r\n".encode(@encoding) +
- Regexp.escape(@column_separator) +
- Regexp.escape(@quote_character.encode(@encoding)) +
- "]".encode(@encoding))
- end
- @quote_empty = @options.fetch(:quote_empty, true)
- end
-
- def prepare_output
- @output_encoding = nil
- return unless @output.is_a?(StringIO)
-
- output_encoding = @output.internal_encoding || @output.external_encoding
- if @encoding != output_encoding
- if @options[:force_encoding]
- @output_encoding = output_encoding
- else
- compatible_encoding = Encoding.compatible?(@encoding, output_encoding)
- if compatible_encoding
- @output.set_encoding(compatible_encoding)
- @output.seek(0, IO::SEEK_END)
- end
- end
- end
- end
-
- def quote_field(field)
- field = String(field)
- encoded_quote_character = @quote_character.encode(field.encoding)
- encoded_quote_character +
- field.gsub(encoded_quote_character,
- encoded_quote_character * 2) +
- encoded_quote_character
- end
-
- def quote(field)
- if @force_quotes
- quote_field(field)
- else
- if field.nil? # represent +nil+ fields as empty unquoted fields
- ""
- else
- field = String(field) # Stringify fields
- # represent empty fields as empty quoted fields
- if (@quote_empty and field.empty?) or @quotable_pattern.match?(field)
- quote_field(field)
- else
- field # unquoted field
- end
- end
- end
- end
- end
-end
diff --git a/lib/debug.rb b/lib/debug.rb
index 6f519c6c77..34d7d27406 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -5,6 +5,11 @@
require 'continuation'
+if $SAFE > 0
+ STDERR.print "-r debug.rb is not available in safe mode\n"
+ exit 1
+end
+
require 'tracer'
require 'pp'
@@ -427,7 +432,7 @@ class DEBUGGER__
pos = $2
if $1
klass = debug_silent_eval($1, binding)
- file = File.expand_path($1)
+ file = $1
end
if pos =~ /^\d+$/
pname = pos
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 1587c7e3bb..37819a28f4 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -44,7 +44,7 @@ class Delegator < BasicObject
undef_method m
end
private_instance_methods.each do |m|
- if /\Ablock_given\?\z|\Aiterator\?\z|\A__.*__\z/ =~ m
+ if /\Ablock_given\?\z|iterator\?\z|\A__.*__\z/ =~ m
next
end
undef_method m
@@ -60,8 +60,8 @@ class Delegator < BasicObject
##
# :method: raise
- # Use #__raise__ if your Delegator does not have a object to delegate the
- # #raise method call.
+ # Use __raise__ if your Delegator does not have a object to delegate the
+ # raise method call.
#
#
@@ -75,14 +75,14 @@ class Delegator < BasicObject
#
# Handles the magic of delegation through \_\_getobj\_\_.
#
- ruby2_keywords def method_missing(m, *args, &block)
+ def method_missing(m, *args, &block)
r = true
target = self.__getobj__ {r = false}
- if r && target_respond_to?(target, m, false)
+ if r && target.respond_to?(m)
target.__send__(m, *args, &block)
- elsif ::Kernel.method_defined?(m) || ::Kernel.private_method_defined?(m)
- ::Kernel.instance_method(m).bind_call(self, *args, &block)
+ elsif ::Kernel.respond_to?(m, true)
+ ::Kernel.instance_method(m).bind(self).(*args, &block)
else
super(m, *args, &block)
end
@@ -95,31 +95,14 @@ class Delegator < BasicObject
def respond_to_missing?(m, include_private)
r = true
target = self.__getobj__ {r = false}
- r &&= target_respond_to?(target, m, include_private)
- if r && include_private && !target_respond_to?(target, m, false)
+ r &&= target.respond_to?(m, include_private)
+ if r && include_private && !target.respond_to?(m, false)
warn "delegator does not forward private method \##{m}", uplevel: 3
return false
end
r
end
- KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
- private_constant :KERNEL_RESPOND_TO
-
- # Handle BasicObject instances
- private def target_respond_to?(target, m, include_private)
- case target
- when Object
- target.respond_to?(m, include_private)
- else
- if KERNEL_RESPOND_TO.bind_call(target, :respond_to?)
- target.respond_to?(m, include_private)
- else
- KERNEL_RESPOND_TO.bind_call(target, m, include_private)
- end
- end
- end
-
#
# Returns the methods available to this delegate object as the union
# of this object's and \_\_getobj\_\_ methods.
@@ -227,12 +210,35 @@ class Delegator < BasicObject
private :initialize_clone, :initialize_dup
##
+ # :method: trust
+ # Trust both the object returned by \_\_getobj\_\_ and self.
+ #
+
+ ##
+ # :method: untrust
+ # Untrust both the object returned by \_\_getobj\_\_ and self.
+ #
+
+ ##
+ # :method: taint
+ # Taint both the object returned by \_\_getobj\_\_ and self.
+ #
+
+ ##
+ # :method: untaint
+ # Untaint both the object returned by \_\_getobj\_\_ and self.
+ #
+
+ ##
# :method: freeze
# Freeze both the object returned by \_\_getobj\_\_ and self.
#
- def freeze
- __getobj__.freeze
- super()
+
+ [:trust, :untrust, :taint, :untaint, :freeze].each do |method|
+ define_method method do
+ __getobj__.send(method)
+ super()
+ end
end
@delegator_api = self.public_instance_methods
@@ -341,7 +347,7 @@ def Delegator.delegating_block(mid) # :nodoc:
lambda do |*args, &block|
target = self.__getobj__
target.__send__(mid, *args, &block)
- end.ruby2_keywords
+ end
end
#
@@ -354,14 +360,6 @@ end
# end
# end
#
-# or:
-#
-# MyClass = DelegateClass(ClassToDelegateTo) do # Step 1
-# def initialize
-# super(obj_of_ClassToDelegateTo) # Step 2
-# end
-# end
-#
# Here's a sample of use from Tempfile which is really a File object with a
# few special rules about storage location and when the File should be
# deleted. That makes for an almost textbook perfect example of how to use
@@ -385,13 +383,11 @@ end
# # ...
# end
#
-def DelegateClass(superclass, &block)
+def DelegateClass(superclass)
klass = Class.new(Delegator)
- ignores = [*::Delegator.public_api, :to_s, :inspect, :=~, :!~, :===]
- protected_instance_methods = superclass.protected_instance_methods
- protected_instance_methods -= ignores
- public_instance_methods = superclass.public_instance_methods
- public_instance_methods -= ignores
+ methods = superclass.instance_methods
+ methods -= ::Delegator.public_api
+ methods -= [:to_s, :inspect, :=~, :!~, :===]
klass.module_eval do
def __getobj__ # :nodoc:
unless defined?(@delegate_dc_obj)
@@ -404,20 +400,15 @@ def DelegateClass(superclass, &block)
__raise__ ::ArgumentError, "cannot delegate to self" if self.equal?(obj)
@delegate_dc_obj = obj
end
- protected_instance_methods.each do |method|
- define_method(method, Delegator.delegating_block(method))
- protected method
- end
- public_instance_methods.each do |method|
+ methods.each do |method|
define_method(method, Delegator.delegating_block(method))
end
end
klass.define_singleton_method :public_instance_methods do |all=true|
- super(all) | superclass.public_instance_methods
+ super(all) - superclass.protected_instance_methods
end
klass.define_singleton_method :protected_instance_methods do |all=true|
super(all) | superclass.protected_instance_methods
end
- klass.module_eval(&block) if block
return klass
end
diff --git a/lib/delegate/delegate.gemspec b/lib/delegate/delegate.gemspec
deleted file mode 100644
index 268cc5a817..0000000000
--- a/lib/delegate/delegate.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/delegate/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "delegate"
- spec.version = Delegator::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Provides three abilities to delegate method calls to an object.}
- spec.description = %q{Provides three abilities to delegate method calls to an object.}
- spec.homepage = "https://github.com/ruby/delegate"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/delegate/version.rb b/lib/delegate/version.rb
deleted file mode 100644
index 456e8f772c..0000000000
--- a/lib/delegate/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Delegator
- VERSION = "0.1.0"
-end
diff --git a/lib/did_you_mean.rb b/lib/did_you_mean.rb
deleted file mode 100644
index b8f92579ca..0000000000
--- a/lib/did_you_mean.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-require_relative "did_you_mean/version"
-require_relative "did_you_mean/core_ext/name_error"
-
-require_relative "did_you_mean/spell_checker"
-require_relative 'did_you_mean/spell_checkers/name_error_checkers'
-require_relative 'did_you_mean/spell_checkers/method_name_checker'
-require_relative 'did_you_mean/spell_checkers/key_error_checker'
-require_relative 'did_you_mean/spell_checkers/null_checker'
-require_relative 'did_you_mean/formatters/plain_formatter'
-require_relative 'did_you_mean/tree_spell_checker'
-
-# The +DidYouMean+ gem adds functionality to suggest possible method/class
-# names upon errors such as +NameError+ and +NoMethodError+. In Ruby 2.3 or
-# later, it is automatically activated during startup.
-#
-# @example
-#
-# methosd
-# # => NameError: undefined local variable or method `methosd' for main:Object
-# # Did you mean? methods
-# # method
-#
-# OBject
-# # => NameError: uninitialized constant OBject
-# # Did you mean? Object
-#
-# @full_name = "Yuki Nishijima"
-# first_name, last_name = full_name.split(" ")
-# # => NameError: undefined local variable or method `full_name' for main:Object
-# # Did you mean? @full_name
-#
-# @@full_name = "Yuki Nishijima"
-# @@full_anme
-# # => NameError: uninitialized class variable @@full_anme in Object
-# # Did you mean? @@full_name
-#
-# full_name = "Yuki Nishijima"
-# full_name.starts_with?("Y")
-# # => NoMethodError: undefined method `starts_with?' for "Yuki Nishijima":String
-# # Did you mean? start_with?
-#
-# hash = {foo: 1, bar: 2, baz: 3}
-# hash.fetch(:fooo)
-# # => KeyError: key not found: :fooo
-# # Did you mean? :foo
-#
-#
-# == Disabling +did_you_mean+
-#
-# Occasionally, you may want to disable the +did_you_mean+ gem for e.g.
-# debugging issues in the error object itself. You can disable it entirely by
-# specifying +--disable-did_you_mean+ option to the +ruby+ command:
-#
-# $ ruby --disable-did_you_mean -e "1.zeor?"
-# -e:1:in `<main>': undefined method `zeor?' for 1:Integer (NameError)
-#
-# When you do not have direct access to the +ruby+ command (e.g.
-# +rails console+, +irb+), you could applyoptions using the +RUBYOPT+
-# environment variable:
-#
-# $ RUBYOPT='--disable-did_you_mean' irb
-# irb:0> 1.zeor?
-# # => NoMethodError (undefined method `zeor?' for 1:Integer)
-#
-#
-# == Getting the original error message
-#
-# Sometimes, you do not want to disable the gem entirely, but need to get the
-# original error message without suggestions (e.g. testing). In this case, you
-# could use the +#original_message+ method on the error object:
-#
-# no_method_error = begin
-# 1.zeor?
-# rescue NoMethodError => error
-# error
-# end
-#
-# no_method_error.message
-# # => NoMethodError (undefined method `zeor?' for 1:Integer)
-# # Did you mean? zero?
-#
-# no_method_error.original_message
-# # => NoMethodError (undefined method `zeor?' for 1:Integer)
-#
-module DidYouMean
- # Map of error types and spell checker objects.
- SPELL_CHECKERS = Hash.new(NullChecker)
-
- # Adds +DidYouMean+ functionality to an error using a given spell checker
- def self.correct_error(error_class, spell_checker)
- SPELL_CHECKERS[error_class.name] = spell_checker
- error_class.prepend(Correctable) unless error_class < Correctable
- end
-
- correct_error NameError, NameErrorCheckers
- correct_error KeyError, KeyErrorChecker
- correct_error NoMethodError, MethodNameChecker
-
- # Returns the currenctly set formatter. By default, it is set to +DidYouMean::Formatter+.
- def self.formatter
- @@formatter
- end
-
- # Updates the primary formatter used to format the suggestions.
- def self.formatter=(formatter)
- @@formatter = formatter
- end
-
- self.formatter = PlainFormatter.new
-end
diff --git a/lib/did_you_mean/core_ext/name_error.rb b/lib/did_you_mean/core_ext/name_error.rb
deleted file mode 100644
index 77dcd520c0..0000000000
--- a/lib/did_you_mean/core_ext/name_error.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module DidYouMean
- module Correctable
- def original_message
- method(:to_s).super_method.call
- end
-
- def to_s
- msg = super.dup
- suggestion = DidYouMean.formatter.message_for(corrections)
-
- msg << suggestion if !msg.end_with?(suggestion)
- msg
- rescue
- super
- end
-
- def corrections
- @corrections ||= spell_checker.corrections
- end
-
- def spell_checker
- SPELL_CHECKERS[self.class.to_s].new(self)
- end
- end
-end
diff --git a/lib/did_you_mean/did_you_mean.gemspec b/lib/did_you_mean/did_you_mean.gemspec
deleted file mode 100644
index 8fe5723129..0000000000
--- a/lib/did_you_mean/did_you_mean.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-# coding: utf-8
-lib = File.expand_path('../lib', __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-begin
- require_relative "lib/did_you_mean/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "did_you_mean"
- spec.version = DidYouMean::VERSION
- spec.authors = ["Yuki Nishijima"]
- spec.email = ["mail@yukinishijima.net"]
- spec.summary = '"Did you mean?" experience in Ruby'
- spec.description = 'The gem that has been saving people from typos since 2014.'
- spec.homepage = "https://github.com/ruby/did_you_mean"
- spec.license = "MIT"
-
- spec.files = `git ls-files`.split($/).reject{|path| path.start_with?('evaluation/') }
- spec.test_files = spec.files.grep(%r{^(test)/})
- spec.require_paths = ["lib"]
-
- spec.required_ruby_version = '>= 2.5.0'
-
- spec.add_development_dependency "rake"
-end
diff --git a/lib/did_you_mean/experimental.rb b/lib/did_you_mean/experimental.rb
deleted file mode 100644
index f8e37e4532..0000000000
--- a/lib/did_you_mean/experimental.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-warn "Experimental features in the did_you_mean gem has been removed " \
- "and `require \"did_you_mean/experimental\"' has no effect."
diff --git a/lib/did_you_mean/experimental/initializer_name_correction.rb b/lib/did_you_mean/experimental/initializer_name_correction.rb
deleted file mode 100644
index b59c98e774..0000000000
--- a/lib/did_you_mean/experimental/initializer_name_correction.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen-string-literal: true
-
-require_relative '../levenshtein'
-
-module DidYouMean
- module Experimental
- module InitializerNameCorrection
- def method_added(name)
- super
-
- distance = Levenshtein.distance(name.to_s, 'initialize')
- if distance != 0 && distance <= 2
- warn "warning: #{name} might be misspelled, perhaps you meant initialize?"
- end
- end
- end
-
- ::Class.prepend(InitializerNameCorrection)
- end
-end
diff --git a/lib/did_you_mean/experimental/ivar_name_correction.rb b/lib/did_you_mean/experimental/ivar_name_correction.rb
deleted file mode 100644
index 322e422c6b..0000000000
--- a/lib/did_you_mean/experimental/ivar_name_correction.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen-string-literal: true
-
-require_relative '../../did_you_mean'
-
-module DidYouMean
- module Experimental #:nodoc:
- class IvarNameCheckerBuilder #:nodoc:
- attr_reader :original_checker
-
- def initialize(original_checker) #:nodoc:
- @original_checker = original_checker
- end
-
- def new(no_method_error) #:nodoc:
- IvarNameChecker.new(no_method_error, original_checker: @original_checker)
- end
- end
-
- class IvarNameChecker #:nodoc:
- REPLS = {
- "(irb)" => -> { Readline::HISTORY.to_a.last }
- }
-
- TRACE = TracePoint.trace(:raise) do |tp|
- e = tp.raised_exception
-
- if SPELL_CHECKERS.include?(e.class.to_s) && !e.instance_variable_defined?(:@frame_binding)
- e.instance_variable_set(:@frame_binding, tp.binding)
- end
- end
-
- attr_reader :original_checker
-
- def initialize(no_method_error, original_checker: )
- @original_checker = original_checker.new(no_method_error)
-
- @location = no_method_error.backtrace_locations.first
- @ivar_names = no_method_error.frame_binding.receiver.instance_variables
-
- no_method_error.remove_instance_variable(:@frame_binding)
- end
-
- def corrections
- original_checker.corrections + ivar_name_corrections
- end
-
- def ivar_name_corrections
- @ivar_name_corrections ||= SpellChecker.new(dictionary: @ivar_names).correct(receiver_name.to_s)
- end
-
- private
-
- def receiver_name
- return unless @original_checker.receiver.nil?
-
- abs_path = @location.absolute_path
- lineno = @location.lineno
-
- /@(\w+)*\.#{@original_checker.method_name}/ =~ line(abs_path, lineno).to_s && $1
- end
-
- def line(abs_path, lineno)
- if REPLS[abs_path]
- REPLS[abs_path].call
- elsif File.exist?(abs_path)
- File.open(abs_path) do |file|
- file.detect { file.lineno == lineno }
- end
- end
- end
- end
- end
-
- NameError.send(:attr, :frame_binding)
- SPELL_CHECKERS['NoMethodError'] = Experimental::IvarNameCheckerBuilder.new(SPELL_CHECKERS['NoMethodError'])
-end
diff --git a/lib/did_you_mean/formatters/plain_formatter.rb b/lib/did_you_mean/formatters/plain_formatter.rb
deleted file mode 100644
index e2d995f587..0000000000
--- a/lib/did_you_mean/formatters/plain_formatter.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen-string-literal: true
-
-module DidYouMean
- # The +DidYouMean::PlainFormatter+ is the basic, default formatter for the
- # gem. The formatter responds to the +message_for+ method and it returns a
- # human readable string.
- class PlainFormatter
-
- # Returns a human readable string that contains +corrections+. This
- # formatter is designed to be less verbose to not take too much screen
- # space while being helpful enough to the user.
- #
- # @example
- #
- # formatter = DidYouMean::PlainFormatter.new
- #
- # # displays suggestions in two lines with the leading empty line
- # puts formatter.message_for(["methods", "method"])
- #
- # Did you mean? methods
- # method
- # # => nil
- #
- # # displays an empty line
- # puts formatter.message_for([])
- #
- # # => nil
- #
- def message_for(corrections)
- corrections.empty? ? "" : "\nDid you mean? #{corrections.join("\n ")}"
- end
- end
-end
diff --git a/lib/did_you_mean/formatters/verbose_formatter.rb b/lib/did_you_mean/formatters/verbose_formatter.rb
deleted file mode 100644
index b8fe214d57..0000000000
--- a/lib/did_you_mean/formatters/verbose_formatter.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen-string-literal: true
-
-module DidYouMean
- # The +DidYouMean::VerboseFormatter+ uses extra empty lines to make the
- # suggestion stand out more in the error message.
- #
- # In order to activate the verbose formatter,
- #
- # @example
- #
- # OBject
- # # => NameError: uninitialized constant OBject
- # # Did you mean? Object
- #
- # require 'did_you_mean/verbose'
- #
- # OBject
- # # => NameError: uninitialized constant OBject
- # #
- # # Did you mean? Object
- # #
- #
- class VerboseFormatter
-
- # Returns a human readable string that contains +corrections+. This
- # formatter is designed to be less verbose to not take too much screen
- # space while being helpful enough to the user.
- #
- # @example
- #
- # formatter = DidYouMean::PlainFormatter.new
- #
- # puts formatter.message_for(["methods", "method"])
- #
- #
- # Did you mean? methods
- # method
- #
- # # => nil
- #
- def message_for(corrections)
- return "" if corrections.empty?
-
- output = "\n\n Did you mean? ".dup
- output << corrections.join("\n ")
- output << "\n "
- end
- end
-end
diff --git a/lib/did_you_mean/jaro_winkler.rb b/lib/did_you_mean/jaro_winkler.rb
deleted file mode 100644
index 56db130af4..0000000000
--- a/lib/did_you_mean/jaro_winkler.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-module DidYouMean
- module Jaro
- module_function
-
- def distance(str1, str2)
- str1, str2 = str2, str1 if str1.length > str2.length
- length1, length2 = str1.length, str2.length
-
- m = 0.0
- t = 0.0
- range = (length2 / 2).floor - 1
- range = 0 if range < 0
- flags1 = 0
- flags2 = 0
-
- # Avoid duplicating enumerable objects
- str1_codepoints = str1.codepoints
- str2_codepoints = str2.codepoints
-
- i = 0
- while i < length1
- last = i + range
- j = (i >= range) ? i - range : 0
-
- while j <= last
- if flags2[j] == 0 && str1_codepoints[i] == str2_codepoints[j]
- flags2 |= (1 << j)
- flags1 |= (1 << i)
- m += 1
- break
- end
-
- j += 1
- end
-
- i += 1
- end
-
- k = i = 0
- while i < length1
- if flags1[i] != 0
- j = index = k
-
- k = while j < length2
- index = j
- break(j + 1) if flags2[j] != 0
-
- j += 1
- end
-
- t += 1 if str1_codepoints[i] != str2_codepoints[index]
- end
-
- i += 1
- end
- t = (t / 2).floor
-
- m == 0 ? 0 : (m / length1 + m / length2 + (m - t) / m) / 3
- end
- end
-
- module JaroWinkler
- WEIGHT = 0.1
- THRESHOLD = 0.7
-
- module_function
-
- def distance(str1, str2)
- jaro_distance = Jaro.distance(str1, str2)
-
- if jaro_distance > THRESHOLD
- codepoints2 = str2.codepoints
- prefix_bonus = 0
-
- i = 0
- str1.each_codepoint do |char1|
- char1 == codepoints2[i] && i < 4 ? prefix_bonus += 1 : break
- i += 1
- end
-
- jaro_distance + (prefix_bonus * WEIGHT * (1 - jaro_distance))
- else
- jaro_distance
- end
- end
- end
-end
diff --git a/lib/did_you_mean/levenshtein.rb b/lib/did_you_mean/levenshtein.rb
deleted file mode 100644
index 098053470f..0000000000
--- a/lib/did_you_mean/levenshtein.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-module DidYouMean
- module Levenshtein # :nodoc:
- # This code is based directly on the Text gem implementation
- # Copyright (c) 2006-2013 Paul Battley, Michael Neumann, Tim Fletcher.
- #
- # Returns a value representing the "cost" of transforming str1 into str2
- def distance(str1, str2)
- n = str1.length
- m = str2.length
- return m if n.zero?
- return n if m.zero?
-
- d = (0..m).to_a
- x = nil
-
- # to avoid duplicating an enumerable object, create it outside of the loop
- str2_codepoints = str2.codepoints
-
- str1.each_codepoint.with_index(1) do |char1, i|
- j = 0
- while j < m
- cost = (char1 == str2_codepoints[j]) ? 0 : 1
- x = min3(
- d[j+1] + 1, # insertion
- i + 1, # deletion
- d[j] + cost # substitution
- )
- d[j] = i
- i = x
-
- j += 1
- end
- d[m] = x
- end
-
- x
- end
- module_function :distance
-
- private
-
- # detects the minimum value out of three arguments. This method is
- # faster than `[a, b, c].min` and puts less GC pressure.
- # See https://github.com/ruby/did_you_mean/pull/1 for a performance
- # benchmark.
- def min3(a, b, c)
- if a < b && a < c
- a
- elsif b < c
- b
- else
- c
- end
- end
- module_function :min3
- end
-end
diff --git a/lib/did_you_mean/spell_checker.rb b/lib/did_you_mean/spell_checker.rb
deleted file mode 100644
index e5106abba2..0000000000
--- a/lib/did_you_mean/spell_checker.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen-string-literal: true
-
-require_relative "levenshtein"
-require_relative "jaro_winkler"
-
-module DidYouMean
- class SpellChecker
- def initialize(dictionary:)
- @dictionary = dictionary
- end
-
- def correct(input)
- input = normalize(input)
- threshold = input.length > 3 ? 0.834 : 0.77
-
- words = @dictionary.select { |word| JaroWinkler.distance(normalize(word), input) >= threshold }
- words.reject! { |word| input == word.to_s }
- words.sort_by! { |word| JaroWinkler.distance(word.to_s, input) }
- words.reverse!
-
- # Correct mistypes
- threshold = (input.length * 0.25).ceil
- corrections = words.select { |c| Levenshtein.distance(normalize(c), input) <= threshold }
-
- # Correct misspells
- if corrections.empty?
- corrections = words.select do |word|
- word = normalize(word)
- length = input.length < word.length ? input.length : word.length
-
- Levenshtein.distance(word, input) < length
- end.first(1)
- end
-
- corrections
- end
-
- private
-
- def normalize(str_or_symbol) #:nodoc:
- str = str_or_symbol.to_s.downcase
- str.tr!("@", "")
- str
- end
- end
-end
diff --git a/lib/did_you_mean/spell_checkers/key_error_checker.rb b/lib/did_you_mean/spell_checkers/key_error_checker.rb
deleted file mode 100644
index be4bea7789..0000000000
--- a/lib/did_you_mean/spell_checkers/key_error_checker.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative "../spell_checker"
-
-module DidYouMean
- class KeyErrorChecker
- def initialize(key_error)
- @key = key_error.key
- @keys = key_error.receiver.keys
- end
-
- def corrections
- @corrections ||= exact_matches.empty? ? SpellChecker.new(dictionary: @keys).correct(@key).map(&:inspect) : exact_matches
- end
-
- private
-
- def exact_matches
- @exact_matches ||= @keys.select { |word| @key == word.to_s }.map(&:inspect)
- end
- end
-end
diff --git a/lib/did_you_mean/spell_checkers/method_name_checker.rb b/lib/did_you_mean/spell_checkers/method_name_checker.rb
deleted file mode 100644
index 3a38245f0c..0000000000
--- a/lib/did_you_mean/spell_checkers/method_name_checker.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require_relative "../spell_checker"
-
-module DidYouMean
- class MethodNameChecker
- attr_reader :method_name, :receiver
-
- NAMES_TO_EXCLUDE = { NilClass => nil.methods }
- NAMES_TO_EXCLUDE.default = []
-
- # +MethodNameChecker::RB_RESERVED_WORDS+ is the list of reserved words in
- # Ruby that take an argument. Unlike
- # +VariableNameChecker::RB_RESERVED_WORDS+, these reserved words require
- # an argument, and a +NoMethodError+ is raised due to the presence of the
- # argument.
- #
- # The +MethodNameChecker+ will use this list to suggest a reversed word if
- # a +NoMethodError+ is raised and found closest matches.
- #
- # Also see +VariableNameChecker::RB_RESERVED_WORDS+.
- RB_RESERVED_WORDS = %i(
- alias
- case
- def
- defined?
- elsif
- end
- ensure
- for
- rescue
- super
- undef
- unless
- until
- when
- while
- yield
- )
-
- def initialize(exception)
- @method_name = exception.name
- @receiver = exception.receiver
- @private_call = exception.respond_to?(:private_call?) ? exception.private_call? : false
- end
-
- def corrections
- @corrections ||= SpellChecker.new(dictionary: RB_RESERVED_WORDS + method_names).correct(method_name) - names_to_exclude
- end
-
- def method_names
- if Object === receiver
- method_names = receiver.methods + receiver.singleton_methods
- method_names += receiver.private_methods if @private_call
- method_names.uniq!
- method_names
- else
- []
- end
- end
-
- def names_to_exclude
- Object === receiver ? NAMES_TO_EXCLUDE[receiver.class] : []
- end
- end
-end
diff --git a/lib/did_you_mean/spell_checkers/name_error_checkers.rb b/lib/did_you_mean/spell_checkers/name_error_checkers.rb
deleted file mode 100644
index 6e2aaa4cb1..0000000000
--- a/lib/did_you_mean/spell_checkers/name_error_checkers.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative 'name_error_checkers/class_name_checker'
-require_relative 'name_error_checkers/variable_name_checker'
-
-module DidYouMean
- class << (NameErrorCheckers = Object.new)
- def new(exception)
- case exception.original_message
- when /uninitialized constant/
- ClassNameChecker
- when /undefined local variable or method/,
- /undefined method/,
- /uninitialized class variable/,
- /no member '.*' in struct/
- VariableNameChecker
- else
- NullChecker
- end.new(exception)
- end
- end
-end
diff --git a/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb b/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
deleted file mode 100644
index 924265b929..0000000000
--- a/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen-string-literal: true
-
-require_relative "../../spell_checker"
-
-module DidYouMean
- class ClassNameChecker
- attr_reader :class_name
-
- def initialize(exception)
- @class_name, @receiver, @original_message = exception.name, exception.receiver, exception.original_message
- end
-
- def corrections
- @corrections ||= SpellChecker.new(dictionary: class_names)
- .correct(class_name)
- .map(&:full_name)
- .reject {|qualified_name| @original_message.include?(qualified_name) }
- end
-
- def class_names
- scopes.flat_map do |scope|
- scope.constants.map do |c|
- ClassName.new(c, scope == Object ? "" : "#{scope}::")
- end
- end
- end
-
- def scopes
- @scopes ||= @receiver.to_s.split("::").inject([Object]) do |_scopes, scope|
- _scopes << _scopes.last.const_get(scope)
- end.uniq
- end
-
- class ClassName < String
- attr :namespace
-
- def initialize(name, namespace = '')
- super(name.to_s)
- @namespace = namespace
- end
-
- def full_name
- self.class.new("#{namespace}#{self}")
- end
- end
-
- private_constant :ClassName
- end
-end
diff --git a/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb b/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
deleted file mode 100644
index 3e51b4fa3a..0000000000
--- a/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# frozen-string-literal: true
-
-require_relative "../../spell_checker"
-
-module DidYouMean
- class VariableNameChecker
- attr_reader :name, :method_names, :lvar_names, :ivar_names, :cvar_names
-
- NAMES_TO_EXCLUDE = { 'foo' => [:fork, :for] }
- NAMES_TO_EXCLUDE.default = []
-
- # +VariableNameChecker::RB_RESERVED_WORDS+ is the list of all reserved
- # words in Ruby. They could be declared like methods are, and a typo would
- # cause Ruby to raise a +NameError+ because of the way they are declared.
- #
- # The +:VariableNameChecker+ will use this list to suggest a reversed word
- # if a +NameError+ is raised and found closest matches, excluding:
- #
- # * +do+
- # * +if+
- # * +in+
- # * +or+
- #
- # Also see +MethodNameChecker::RB_RESERVED_WORDS+.
- RB_RESERVED_WORDS = %i(
- BEGIN
- END
- alias
- and
- begin
- break
- case
- class
- def
- defined?
- else
- elsif
- end
- ensure
- false
- for
- module
- next
- nil
- not
- redo
- rescue
- retry
- return
- self
- super
- then
- true
- undef
- unless
- until
- when
- while
- yield
- __LINE__
- __FILE__
- __ENCODING__
- )
-
- def initialize(exception)
- @name = exception.name.to_s.tr("@", "")
- @lvar_names = exception.respond_to?(:local_variables) ? exception.local_variables : []
- receiver = exception.receiver
-
- @method_names = receiver.methods + receiver.private_methods
- @ivar_names = receiver.instance_variables
- @cvar_names = receiver.class.class_variables
- @cvar_names += receiver.class_variables if receiver.kind_of?(Module)
- end
-
- def corrections
- @corrections ||= SpellChecker
- .new(dictionary: (RB_RESERVED_WORDS + lvar_names + method_names + ivar_names + cvar_names))
- .correct(name) - NAMES_TO_EXCLUDE[@name]
- end
- end
-end
diff --git a/lib/did_you_mean/spell_checkers/null_checker.rb b/lib/did_you_mean/spell_checkers/null_checker.rb
deleted file mode 100644
index 1306f69d4a..0000000000
--- a/lib/did_you_mean/spell_checkers/null_checker.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module DidYouMean
- class NullChecker
- def initialize(*); end
- def corrections; [] end
- end
-end
diff --git a/lib/did_you_mean/tree_spell_checker.rb b/lib/did_you_mean/tree_spell_checker.rb
deleted file mode 100644
index 6a5b485413..0000000000
--- a/lib/did_you_mean/tree_spell_checker.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-module DidYouMean
- # spell checker for a dictionary that has a tree
- # structure, see doc/tree_spell_checker_api.md
- class TreeSpellChecker
- attr_reader :dictionary, :dimensions, :separator, :augment
-
- def initialize(dictionary:, separator: '/', augment: nil)
- @dictionary = dictionary
- @separator = separator
- @augment = augment
- @dimensions = parse_dimensions
- end
-
- def correct(input)
- plausibles = plausible_dimensions input
- return no_idea(input) if plausibles.empty?
- suggestions = find_suggestions input, plausibles
- return no_idea(input) if suggestions.empty?
- suggestions
- end
-
- private
-
- def parse_dimensions
- ParseDimensions.new(dictionary, separator).call
- end
-
- def find_suggestions(input, plausibles)
- states = plausibles[0].product(*plausibles[1..-1])
- paths = possible_paths states
- leaf = input.split(separator).last
- ideas = find_ideas(paths, leaf)
- ideas.compact.flatten
- end
-
- def no_idea(input)
- return [] unless augment
- ::DidYouMean::SpellChecker.new(dictionary: dictionary).correct(input)
- end
-
- def find_ideas(paths, leaf)
- paths.map do |path|
- names = find_leaves(path)
- ideas = CorrectElement.new.call names, leaf
- ideas_to_paths ideas, leaf, names, path
- end
- end
-
- def ideas_to_paths(ideas, leaf, names, path)
- return nil if ideas.empty?
- return [path + separator + leaf] if names.include? leaf
- ideas.map { |str| path + separator + str }
- end
-
- def find_leaves(path)
- dictionary.map do |str|
- next unless str.include? "#{path}#{separator}"
- str.gsub("#{path}#{separator}", '')
- end.compact
- end
-
- def possible_paths(states)
- states.map do |state|
- state.join separator
- end
- end
-
- def plausible_dimensions(input)
- elements = input.split(separator)[0..-2]
- elements.each_with_index.map do |element, i|
- next if dimensions[i].nil?
- CorrectElement.new.call dimensions[i], element
- end.compact
- end
- end
-
- # parses the elements in each dimension
- class ParseDimensions
- def initialize(dictionary, separator)
- @dictionary = dictionary
- @separator = separator
- end
-
- def call
- leafless = remove_leaves
- dimensions = find_elements leafless
- dimensions.map do |elements|
- elements.to_set.to_a
- end
- end
-
- private
-
- def remove_leaves
- dictionary.map do |a|
- elements = a.split(separator)
- elements[0..-2]
- end.to_set.to_a
- end
-
- def find_elements(leafless)
- max_elements = leafless.map(&:size).max
- dimensions = Array.new(max_elements) { [] }
- (0...max_elements).each do |i|
- leafless.each do |elements|
- dimensions[i] << elements[i] unless elements[i].nil?
- end
- end
- dimensions
- end
-
- attr_reader :dictionary, :separator
- end
-
- # identifies the elements close to element
- class CorrectElement
- def initialize
- end
-
- def call(names, element)
- return names if names.size == 1
- str = normalize element
- return [str] if names.include? str
- checker = ::DidYouMean::SpellChecker.new(dictionary: names)
- checker.correct(str)
- end
-
- private
-
- def normalize(leaf)
- str = leaf.dup
- str.downcase!
- return str unless str.include? '@'
- str.tr!('@', ' ')
- end
- end
-end
diff --git a/lib/did_you_mean/verbose.rb b/lib/did_you_mean/verbose.rb
deleted file mode 100644
index 4e86f167ea..0000000000
--- a/lib/did_you_mean/verbose.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require_relative '../did_you_mean'
-require_relative 'formatters/verbose_formatter'
-
-DidYouMean.formatter = DidYouMean::VerboseFormatter.new
diff --git a/lib/did_you_mean/version.rb b/lib/did_you_mean/version.rb
deleted file mode 100644
index 6d3dd3a694..0000000000
--- a/lib/did_you_mean/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module DidYouMean
- VERSION = "1.4.0"
-end
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
index 4d3ea364f1..e47b303aa4 100644
--- a/lib/drb/drb.rb
+++ b/lib/drb/drb.rb
@@ -48,8 +48,7 @@
require 'socket'
require 'io/wait'
-require 'monitor'
-require_relative 'eq'
+require 'drb/eq'
#
# == Overview
@@ -160,6 +159,8 @@ require_relative 'eq'
# # The object that handles requests on the server
# FRONT_OBJECT=TimeServer.new
#
+# $SAFE = 1 # disable eval() and friends
+#
# DRb.start_service(URI, FRONT_OBJECT)
# # Wait for the drb server thread to finish before exiting.
# DRb.thread.join
@@ -233,7 +234,7 @@ require_relative 'eq'
# def get_logger(name)
# if !@loggers.has_key? name
# # make the filename safe, then declare it to be so
-# fname = name.gsub(/[.\/\\\:]/, "_")
+# fname = name.gsub(/[.\/\\\:]/, "_").untaint
# @loggers[name] = Logger.new(name, @basedir + "/" + fname)
# end
# return @loggers[name]
@@ -243,6 +244,8 @@ require_relative 'eq'
#
# FRONT_OBJECT=LoggerFactory.new("/tmp/dlog")
#
+# $SAFE = 1 # disable eval() and friends
+#
# DRb.start_service(URI, FRONT_OBJECT)
# DRb.thread.join
#
@@ -282,7 +285,10 @@ require_relative 'eq'
# ro.instance_eval("`rm -rf *`")
#
# The dangers posed by instance_eval and friends are such that a
-# DRbServer should only be used when clients are trusted.
+# DRbServer should generally be run with $SAFE set to at least
+# level 1. This will disable eval() and related calls on strings
+# passed across the wire. The sample usage code given above follows
+# this practice.
#
# A DRbServer can be configured with an access control list to
# selectively allow or deny access from specified IP addresses. The
@@ -354,7 +360,7 @@ module DRb
# drb remains valid only while that object instance remains alive
# within the server runtime.
#
- # For alternative mechanisms, see DRb::TimerIdConv in drb/timeridconv.rb
+ # For alternative mechanisms, see DRb::TimerIdConv in rdb/timeridconv.rb
# and DRbNameIdConv in sample/name.rb in the full drb distribution.
class DRbIdConv
@@ -371,12 +377,7 @@ module DRb
# This implementation returns the object's __id__ in the local
# object space.
def to_id(obj)
- case obj
- when Object
- obj.nil? ? nil : obj.__id__
- when BasicObject
- obj.__id__
- end
+ obj.nil? ? nil : obj.__id__
end
end
@@ -559,14 +560,7 @@ module DRb
end
def dump(obj, error=false) # :nodoc:
- case obj
- when DRbUndumped
- obj = make_proxy(obj, error)
- when Object
- # nothing
- else
- obj = make_proxy(obj, error)
- end
+ obj = make_proxy(obj, error) if obj.kind_of? DRbUndumped
begin
str = Marshal::dump(obj)
rescue
@@ -594,9 +588,16 @@ module DRb
raise(DRbConnError, 'premature marshal format(can\'t read)') if str.size < sz
DRb.mutex.synchronize do
begin
+ save = Thread.current[:drb_untaint]
+ Thread.current[:drb_untaint] = []
Marshal::load(str)
rescue NameError, ArgumentError
DRbUnknown.new($!, str)
+ ensure
+ Thread.current[:drb_untaint].each do |x|
+ x.untaint
+ end
+ Thread.current[:drb_untaint] = save
end
end
end
@@ -799,7 +800,7 @@ module DRb
module_function :uri_option
def auto_load(uri) # :nodoc:
- if /\Adrb([a-z0-9]+):/ =~ uri
+ if uri =~ /^drb([a-z0-9]+):/
require("drb/#{$1}") rescue nil
end
end
@@ -815,13 +816,13 @@ module DRb
# :stopdoc:
private
def self.parse_uri(uri)
- if /\Adruby:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
+ if uri =~ /^druby:\/\/(.*?):(\d+)(\?(.*))?$/
host = $1
port = $2.to_i
option = $4
[host, port, option]
else
- raise(DRbBadScheme, uri) unless uri.start_with?('druby:')
+ raise(DRbBadScheme, uri) unless uri =~ /^druby:/
raise(DRbBadURI, 'can\'t parse uri:' + uri)
end
end
@@ -836,6 +837,8 @@ module DRb
# URI protocols.
def self.open(uri, config)
host, port, = parse_uri(uri)
+ host.untaint
+ port.untaint
soc = TCPSocket.open(host, port)
self.new(uri, soc, config)
end
@@ -844,11 +847,7 @@ module DRb
def self.getservername
host = Socket::gethostname
begin
- Socket::getaddrinfo(host, nil,
- Socket::AF_UNSPEC,
- Socket::SOCK_STREAM,
- 0,
- Socket::AI_PASSIVE)[0][3]
+ Socket::gethostbyname(host)[0]
rescue
'localhost'
end
@@ -950,7 +949,6 @@ module DRb
# returned by #open or by #accept, then it closes this particular
# client-server session.
def close
- shutdown
if @socket
@socket.close
@socket = nil
@@ -959,8 +957,14 @@ module DRb
end
def close_shutdown_pipe
- @shutdown_pipe_w.close
- @shutdown_pipe_r.close
+ if @shutdown_pipe_r && !@shutdown_pipe_r.closed?
+ @shutdown_pipe_r.close
+ @shutdown_pipe_r = nil
+ end
+ if @shutdown_pipe_w && !@shutdown_pipe_w.closed?
+ @shutdown_pipe_w.close
+ @shutdown_pipe_w = nil
+ end
end
private :close_shutdown_pipe
@@ -993,7 +997,7 @@ module DRb
# Graceful shutdown
def shutdown
- @shutdown_pipe_w.close
+ @shutdown_pipe_w.close if @shutdown_pipe_w && !@shutdown_pipe_w.closed?
end
# Check to see if this connection is alive.
@@ -1008,8 +1012,6 @@ module DRb
def set_sockopt(soc) # :nodoc:
soc.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
- rescue IOError, Errno::ECONNRESET, Errno::EINVAL
- # closed/shutdown socket, ignore error
end
end
@@ -1052,6 +1054,9 @@ module DRb
if DRb.here?(uri)
obj = DRb.to_obj(ref)
+ if ((! obj.tainted?) && Thread.current[:drb_untaint])
+ Thread.current[:drb_untaint].push(obj)
+ end
return obj
end
@@ -1088,14 +1093,7 @@ module DRb
def initialize(obj, uri=nil)
@uri = nil
@ref = nil
- case obj
- when Object
- is_nil = obj.nil?
- when BasicObject
- is_nil = false
- end
-
- if is_nil
+ if obj.nil?
return if uri.nil?
@uri, option = DRbProtocol.uri_option(uri, DRb.config)
@ref = DRbURIOption.new(option) unless option.nil?
@@ -1131,7 +1129,7 @@ module DRb
end
# Routes method calls to the referenced remote object.
- ruby2_keywords def method_missing(msg_id, *a, &b)
+ def method_missing(msg_id, *a, &b)
if DRb.here?(@uri)
obj = DRb.to_obj(@ref)
DRb.current_server.check_insecure_method(obj, msg_id)
@@ -1174,7 +1172,7 @@ module DRb
bt = []
result.backtrace.each do |x|
break if /`__send__'$/ =~ x
- if /\A\(druby:\/\// =~ x
+ if /^\(druby:\/\// =~ x
bt.push(x)
else
bt.push(prefix + x)
@@ -1195,54 +1193,6 @@ module DRb
end
end
- class ThreadObject
- include MonitorMixin
-
- def initialize(&blk)
- super()
- @wait_ev = new_cond
- @req_ev = new_cond
- @res_ev = new_cond
- @status = :wait
- @req = nil
- @res = nil
- @thread = Thread.new(self, &blk)
- end
-
- def alive?
- @thread.alive?
- end
-
- def kill
- @thread.kill
- @thread.join
- end
-
- def method_missing(msg, *arg, &blk)
- synchronize do
- @wait_ev.wait_until { @status == :wait }
- @req = [msg] + arg
- @status = :req
- @req_ev.broadcast
- @res_ev.wait_until { @status == :res }
- value = @res
- @req = @res = nil
- @status = :wait
- @wait_ev.broadcast
- return value
- end
- end
-
- def _execute()
- synchronize do
- @req_ev.wait_until { @status == :req }
- @res = yield(@req)
- @status = :res
- @res_ev.signal
- end
- end
- end
-
# Class handling the connection between a DRbObject and the
# server the real object lives on.
#
@@ -1254,50 +1204,26 @@ module DRb
# not normally need to deal with it directly.
class DRbConn
POOL_SIZE = 16 # :nodoc:
+ @mutex = Thread::Mutex.new
+ @pool = []
- def self.make_pool
- ThreadObject.new do |queue|
- pool = []
- while true
- queue._execute do |message|
- case(message[0])
- when :take then
- remote_uri = message[1]
- conn = nil
- new_pool = []
- pool.each do |c|
- if conn.nil? and c.uri == remote_uri
- conn = c if c.alive?
- else
- new_pool.push c
- end
- end
- pool = new_pool
- conn
- when :store then
- conn = message[1]
- pool.unshift(conn)
- pool.pop.close while pool.size > POOL_SIZE
- conn
+ def self.open(remote_uri) # :nodoc:
+ begin
+ conn = nil
+
+ @mutex.synchronize do
+ #FIXME
+ new_pool = []
+ @pool.each do |c|
+ if conn.nil? and c.uri == remote_uri
+ conn = c if c.alive?
else
- nil
+ new_pool.push c
end
end
+ @pool = new_pool
end
- end
- end
- @pool_proxy = nil
-
- def self.stop_pool
- @pool_proxy&.kill
- @pool_proxy = nil
- end
- def self.open(remote_uri) # :nodoc:
- begin
- @pool_proxy = make_pool unless @pool_proxy&.alive?
-
- conn = @pool_proxy.take(remote_uri)
conn = self.new(remote_uri) unless conn
succ, result = yield(conn)
return succ, result
@@ -1305,7 +1231,10 @@ module DRb
ensure
if conn
if succ
- @pool_proxy.store(conn)
+ @mutex.synchronize do
+ @pool.unshift(conn)
+ @pool.pop.close while @pool.size > POOL_SIZE
+ end
else
conn.close
end
@@ -1351,8 +1280,9 @@ module DRb
@@idconv = DRbIdConv.new
@@secondary_server = nil
@@argc_limit = 256
- @@load_limit = 0xffffffff
+ @@load_limit = 256 * 102400
@@verbose = false
+ @@safe_level = 0
# Set the default value for the :argc_limit option.
#
@@ -1382,8 +1312,11 @@ module DRb
@@idconv = idconv
end
- def self.default_safe_level(level) # :nodoc:
- # Remove in Ruby 3.0
+ # Set the default safe level to +level+. The default safe level is 0
+ #
+ # See #new for more information.
+ def self.default_safe_level(level)
+ @@safe_level = level
end
# Set the default value of the :verbose option.
@@ -1405,6 +1338,7 @@ module DRb
:tcp_acl => @@acl,
:load_limit => @@load_limit,
:argc_limit => @@argc_limit,
+ :safe_level => @@safe_level
}
default_config.update(hash)
end
@@ -1438,6 +1372,10 @@ module DRb
# :argc_limit :: the maximum number of arguments to a remote
# method accepted by the server. Defaults to
# 256.
+ # :safe_level :: The safe level of the DRbServer. The attribute
+ # sets $SAFE for methods performed in the main_loop.
+ # Defaults to 0.
+ #
# The default values of these options can be modified on
# a class-wide basis by the class methods #default_argc_limit,
# #default_load_limit, #default_acl, #default_id_conv,
@@ -1469,6 +1407,7 @@ module DRb
@front = front
@idconv = @config[:idconv]
+ @safe_level = @config[:safe_level]
@grp = ThreadGroup.new
@thread = run
@@ -1495,10 +1434,11 @@ module DRb
# The configuration of this DRbServer
attr_reader :config
- def safe_level # :nodoc:
- # Remove in Ruby 3.0
- 0
- end
+ # The safe level for this server. This is a number corresponding to
+ # $SAFE.
+ #
+ # The default safe_level is 0
+ attr_reader :safe_level
# Set whether to operate in verbose mode.
#
@@ -1586,9 +1526,9 @@ module DRb
# Coerce an object to a string, providing our own representation if
# to_s is not defined for the object.
def any_to_s(obj)
- "#{obj}:#{obj.class}"
+ obj.to_s + ":#{obj.class}"
rescue
- Kernel.instance_method(:to_s).bind_call(obj)
+ sprintf("#<%s:0x%lx>", obj.class, obj.__id__)
end
# Check that a method is callable via dRuby.
@@ -1604,27 +1544,14 @@ module DRb
raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
- case obj
- when Object
- if obj.private_methods.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
- elsif obj.protected_methods.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
- else
- true
- end
+ if obj.private_methods.include?(msg_id)
+ desc = any_to_s(obj)
+ raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
+ elsif obj.protected_methods.include?(msg_id)
+ desc = any_to_s(obj)
+ raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
else
- if Kernel.instance_method(:private_methods).bind(obj).call.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
- elsif Kernel.instance_method(:protected_methods).bind(obj).call.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
- else
- true
- end
+ true
end
end
public :check_insecure_method
@@ -1632,6 +1559,7 @@ module DRb
class InvokeMethod # :nodoc:
def initialize(drb_server, client)
@drb_server = drb_server
+ @safe_level = drb_server.safe_level
@client = client
end
@@ -1640,22 +1568,34 @@ module DRb
@succ = false
setup_message
- if @block
- @result = perform_with_block
+ if $SAFE < @safe_level
+ info = Thread.current['DRb']
+ if @block
+ @result = Thread.new {
+ Thread.current['DRb'] = info
+ $SAFE = @safe_level
+ perform_with_block
+ }.value
+ else
+ @result = Thread.new {
+ Thread.current['DRb'] = info
+ $SAFE = @safe_level
+ perform_without_block
+ }.value
+ end
else
- @result = perform_without_block
+ if @block
+ @result = perform_with_block
+ else
+ @result = perform_without_block
+ end
end
@succ = true
- case @result
- when Array
- if @msg_id == :to_ary
- @result = DRbArray.new(@result)
- end
+ if @msg_id == :to_ary && @result.class == Array
+ @result = DRbArray.new(@result)
end
return @succ, @result
- rescue NoMemoryError, SystemExit, SystemStackError, SecurityError
- raise
- rescue Exception
+ rescue StandardError, ScriptError, Interrupt
@result = $!
return @succ, @result
end
@@ -1693,7 +1633,7 @@ module DRb
end
- require_relative 'invokemethod'
+ require 'drb/invokemethod'
class InvokeMethod
include InvokeMethod18Mixin
end
@@ -1733,9 +1673,7 @@ module DRb
invoke_method = InvokeMethod.new(self, client)
succ, result = invoke_method.perform
error_print(result) if !succ && verbose
- unless DRbConnError === result && result.message == 'connection closed'
- client.send_reply(succ, result)
- end
+ client.send_reply(succ, result)
rescue Exception => e
error_print(e) if verbose
ensure
@@ -1923,11 +1861,6 @@ module DRb
# Removes +server+ from the list of registered servers.
def remove_server(server)
@server.delete(server.uri)
- mutex.synchronize do
- if @primary_server == server
- @primary_server = nil
- end
- end
end
module_function :remove_server
diff --git a/lib/drb/extserv.rb b/lib/drb/extserv.rb
index a93d5d1576..1cb1be4709 100644
--- a/lib/drb/extserv.rb
+++ b/lib/drb/extserv.rb
@@ -4,7 +4,7 @@
Copyright (c) 2000,2002 Masatoshi SEKI
=end
-require_relative 'drb'
+require 'drb/drb'
require 'monitor'
module DRb
diff --git a/lib/drb/extservm.rb b/lib/drb/extservm.rb
index 040e4e3e08..2d3c369bbf 100644
--- a/lib/drb/extservm.rb
+++ b/lib/drb/extservm.rb
@@ -4,7 +4,7 @@
Copyright (c) 2000 Masatoshi SEKI
=end
-require_relative 'drb'
+require 'drb/drb'
require 'monitor'
module DRb
@@ -61,7 +61,8 @@ module DRb
private
def invoke_thread
Thread.new do
- while name = @queue.pop
+ while true
+ name = @queue.pop
invoke_service_command(name, @@command[name])
end
end
diff --git a/lib/drb/gw.rb b/lib/drb/gw.rb
index 65a525476e..d000507644 100644
--- a/lib/drb/gw.rb
+++ b/lib/drb/gw.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'drb'
+require 'drb/drb'
require 'monitor'
module DRb
diff --git a/lib/drb/ssl.rb b/lib/drb/ssl.rb
index 3d528c6172..45fe4f1f74 100644
--- a/lib/drb/ssl.rb
+++ b/lib/drb/ssl.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
require 'socket'
require 'openssl'
-require_relative 'drb'
+require 'drb/drb'
require 'singleton'
module DRb
@@ -162,7 +162,7 @@ module DRb
return
end
- rsa = OpenSSL::PKey::RSA.new(2048){|p, n|
+ rsa = OpenSSL::PKey::RSA.new(1024){|p, n|
next unless self[:verbose]
case p
when 0; $stderr.putc "." # BN_generate_prime
@@ -196,7 +196,7 @@ module DRb
if comment = self[:SSLCertComment]
cert.add_extension(ef.create_extension("nsComment", comment))
end
- cert.sign(rsa, OpenSSL::Digest::SHA256.new)
+ cert.sign(rsa, OpenSSL::Digest::SHA1.new)
@cert = cert
@pkey = rsa
@@ -226,13 +226,13 @@ module DRb
#
# Raises DRbBadScheme or DRbBadURI if +uri+ is not matching or malformed
def self.parse_uri(uri) # :nodoc:
- if /\Adrbssl:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
+ if uri =~ /^drbssl:\/\/(.*?):(\d+)(\?(.*))?$/
host = $1
port = $2.to_i
option = $4
[host, port, option]
else
- raise(DRbBadScheme, uri) unless uri.start_with?('drbssl:')
+ raise(DRbBadScheme, uri) unless uri =~ /^drbssl:/
raise(DRbBadURI, 'can\'t parse uri:' + uri)
end
end
@@ -248,6 +248,8 @@ module DRb
# configuration. Either a Hash or DRb::DRbSSLSocket::SSLConfig
def self.open(uri, config)
host, port, = parse_uri(uri)
+ host.untaint
+ port.untaint
soc = TCPSocket.open(host, port)
ssl_conf = SSLConfig::new(config)
ssl_conf.setup_ssl_context
diff --git a/lib/drb/timeridconv.rb b/lib/drb/timeridconv.rb
index 3ead98a7f2..9ac7e1e69c 100644
--- a/lib/drb/timeridconv.rb
+++ b/lib/drb/timeridconv.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'drb'
+require 'drb/drb'
require 'monitor'
module DRb
diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb
index 1629ad3bcd..adacf6df5b 100644
--- a/lib/drb/unix.rb
+++ b/lib/drb/unix.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
require 'socket'
-require_relative 'drb'
+require 'drb/drb'
require 'tmpdir'
raise(LoadError, "UNIXServer is required") unless defined?(UNIXServer)
@@ -15,18 +15,19 @@ module DRb
class DRbUNIXSocket < DRbTCPSocket
# :stopdoc:
def self.parse_uri(uri)
- if /\Adrbunix:(.*?)(\?(.*))?\z/ =~ uri
+ if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
filename = $1
option = $3
[filename, option]
else
- raise(DRbBadScheme, uri) unless uri.start_with?('drbunix:')
+ raise(DRbBadScheme, uri) unless uri =~ /^drbunix:/
raise(DRbBadURI, 'can\'t parse uri:' + uri)
end
end
def self.open(uri, config)
filename, = parse_uri(uri)
+ filename.untaint
soc = UNIXSocket.open(filename)
self.new(uri, soc, config)
end
@@ -94,7 +95,6 @@ module DRb
public
def close
return unless @socket
- shutdown # DRbProtocol#shutdown
path = @socket.path if @server_mode
@socket.close
File.unlink(path) if @server_mode
diff --git a/lib/drb/weakidconv.rb b/lib/drb/weakidconv.rb
deleted file mode 100644
index ecf0bf515f..0000000000
--- a/lib/drb/weakidconv.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: false
-require_relative 'drb'
-require 'monitor'
-
-module DRb
-
- # To use WeakIdConv:
- #
- # DRb.start_service(nil, nil, {:idconv => DRb::WeakIdConv.new})
-
- class WeakIdConv < DRbIdConv
- class WeakSet
- include MonitorMixin
- def initialize
- super()
- @immutable = {}
- @map = ObjectSpace::WeakMap.new
- end
-
- def add(obj)
- synchronize do
- begin
- @map[obj] = self
- rescue ArgumentError
- @immutable[obj.__id__] = obj
- end
- return obj.__id__
- end
- end
-
- def fetch(ref)
- synchronize do
- @immutable.fetch(ref) {
- @map.each { |key, _|
- return key if key.__id__ == ref
- }
- raise RangeError.new("invalid reference")
- }
- end
- end
- end
-
- def initialize()
- super()
- @weak_set = WeakSet.new
- end
-
- def to_obj(ref) # :nodoc:
- return super if ref.nil?
- @weak_set.fetch(ref)
- end
-
- def to_id(obj) # :nodoc:
- return @weak_set.add(obj)
- end
- end
-end
-
-# DRb.install_id_conv(WeakIdConv.new)
diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb
new file mode 100644
index 0000000000..1c1d7148ff
--- /dev/null
+++ b/lib/e2mmap.rb
@@ -0,0 +1,177 @@
+# frozen_string_literal: true
+#
+#--
+# e2mmap.rb - for Ruby 1.1
+# $Release Version: 2.0$
+# $Revision: 1.10 $
+# by Keiju ISHITSUKA
+#
+#++
+#
+# Helper module for easily defining exceptions with predefined messages.
+#
+# == Usage
+#
+# 1.
+# class Foo
+# extend Exception2MessageMapper
+# def_e2message ExistingExceptionClass, "message..."
+# def_exception :NewExceptionClass, "message..."[, superclass]
+# ...
+# end
+#
+# 2.
+# module Error
+# extend Exception2MessageMapper
+# def_e2message ExistingExceptionClass, "message..."
+# def_exception :NewExceptionClass, "message..."[, superclass]
+# ...
+# end
+# class Foo
+# include Error
+# ...
+# end
+#
+# foo = Foo.new
+# foo.Fail ....
+#
+# 3.
+# module Error
+# extend Exception2MessageMapper
+# def_e2message ExistingExceptionClass, "message..."
+# def_exception :NewExceptionClass, "message..."[, superclass]
+# ...
+# end
+# class Foo
+# extend Exception2MessageMapper
+# include Error
+# ...
+# end
+#
+# Foo.Fail NewExceptionClass, arg...
+# Foo.Fail ExistingExceptionClass, arg...
+#
+#
+module Exception2MessageMapper
+
+ E2MM = Exception2MessageMapper # :nodoc:
+
+ def E2MM.extend_object(cl)
+ super
+ cl.bind(self) unless cl < E2MM
+ end
+
+ def bind(cl)
+ self.module_eval "#{<<-"begin;"}\n#{<<-"end;"}", __FILE__, __LINE__+1
+ begin;
+ def Raise(err = nil, *rest)
+ Exception2MessageMapper.Raise(self.class, err, *rest)
+ end
+ alias Fail Raise
+
+ class << self
+ undef included
+ end
+ def self.included(mod)
+ mod.extend Exception2MessageMapper
+ end
+ end;
+ end
+
+ # Fail(err, *rest)
+ # err: exception
+ # rest: message arguments
+ #
+ def Raise(err = nil, *rest)
+ E2MM.Raise(self, err, *rest)
+ end
+ alias Fail Raise
+ alias fail Raise
+
+ # def_e2message(c, m)
+ # c: exception
+ # m: message_form
+ # define exception c with message m.
+ #
+ def def_e2message(c, m)
+ E2MM.def_e2message(self, c, m)
+ end
+
+ # def_exception(n, m, s)
+ # n: exception_name
+ # m: message_form
+ # s: superclass(default: StandardError)
+ # define exception named ``c'' with message m.
+ #
+ def def_exception(n, m, s = StandardError)
+ E2MM.def_exception(self, n, m, s)
+ end
+
+ #
+ # Private definitions.
+ #
+ # {[class, exp] => message, ...}
+ @MessageMap = {}
+
+ # E2MM.def_e2message(k, e, m)
+ # k: class to define exception under.
+ # e: exception
+ # m: message_form
+ # define exception c with message m.
+ #
+ def E2MM.def_e2message(k, c, m)
+ E2MM.instance_eval{@MessageMap[[k, c]] = m}
+ c
+ end
+
+ # E2MM.def_exception(k, n, m, s)
+ # k: class to define exception under.
+ # n: exception_name
+ # m: message_form
+ # s: superclass(default: StandardError)
+ # define exception named ``c'' with message m.
+ #
+ def E2MM.def_exception(k, n, m, s = StandardError)
+ e = Class.new(s)
+ E2MM.instance_eval{@MessageMap[[k, e]] = m}
+ k.module_eval {remove_const(n)} if k.const_defined?(n, false)
+ k.const_set(n, e)
+ end
+
+ # Fail(klass, err, *rest)
+ # klass: class to define exception under.
+ # err: exception
+ # rest: message arguments
+ #
+ def E2MM.Raise(klass = E2MM, err = nil, *rest)
+ if form = e2mm_message(klass, err)
+ b = $@.nil? ? caller(1) : $@
+ b.shift if b[0] =~ /^#{Regexp.quote(__FILE__)}:/
+ raise err, sprintf(form, *rest), b
+ else
+ E2MM.Fail E2MM, ErrNotRegisteredException, err.inspect
+ end
+ end
+ class << E2MM
+ alias Fail Raise
+ end
+
+ def E2MM.e2mm_message(klass, exp)
+ for c in klass.ancestors
+ if mes = @MessageMap[[c,exp]]
+ m = klass.instance_eval('"' + mes + '"')
+ return m
+ end
+ end
+ nil
+ end
+ class << self
+ alias message e2mm_message
+ end
+
+ E2MM.def_exception(E2MM,
+ :ErrNotRegisteredException,
+ "not registered exception(%s)")
+end
+
+
diff --git a/lib/erb.rb b/lib/erb.rb
index d2ea64ab60..062fd496b9 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -57,6 +57,7 @@ require "cgi/util"
#
# There are several settings you can change when you use ERB:
# * the nature of the tags that are recognized;
+# * the value of <tt>$SAFE</tt> under which the template is run;
# * the binding used to resolve local variables in the template.
#
# See the ERB.new and ERB#result methods for more detail.
@@ -114,7 +115,7 @@ require "cgi/util"
# James Edward Gray II
# }.gsub(/^ /, '')
#
-# message = ERB.new(template, trim_mode: "%<>")
+# message = ERB.new(template, 0, "%<>")
#
# # Set up template data.
# to = "Community Spokesman <spokesman@ruby_community.org>"
@@ -247,20 +248,22 @@ require "cgi/util"
#
# == Notes
#
-# There are a variety of templating solutions available in various Ruby projects.
-# For example, RDoc, distributed with Ruby, uses its own template engine, which
-# can be reused elsewhere.
+# There are a variety of templating solutions available in various Ruby projects:
+# * ERB's big brother, eRuby, works the same but is written in C for speed;
+# * Amrita (smart at producing HTML/XML);
+# * cs/Template (written in C for speed);
+# * RDoc, distributed with Ruby, uses its own template engine, which can be reused elsewhere;
+# * and others; search {RubyGems.org}[https://rubygems.org/] or
+# {The Ruby Toolbox}[https://www.ruby-toolbox.com/].
#
-# Other popular engines could be found in the corresponding
-# {Category}[https://www.ruby-toolbox.com/categories/template_engines] of
-# The Ruby Toolbox.
+# Rails, the web application framework, uses ERB to create views.
#
class ERB
Revision = '$Date:: $' # :nodoc: #'
# Returns revision information for the erb.rb module.
def self.version
- "erb.rb [2.2.0 #{ERB::Revision.split[1]}]"
+ "erb.rb [2.1.0 #{ERB::Revision.split[1]}]"
end
end
@@ -512,6 +515,10 @@ class ERB
end
Scanner.register_scanner(SimpleScanner, nil, false)
+ # Deprecated. Kept for backward compatibility.
+ SimpleScanner2 = SimpleScanner # :nodoc:
+ deprecate_constant :SimpleScanner2
+
class ExplicitScanner < Scanner # :nodoc:
def scan
stag_reg = /(.*?)(^[ \t]*<%-|<%-|#{stags.join('|')}|\z)/m
@@ -662,13 +669,9 @@ class ERB
return [false, '>']
when 2
return [false, '<>']
- when 0, nil
+ when 0
return [false, nil]
when String
- unless mode.match?(/\A(%|-|>|<>){1,2}\z/)
- warn_invalid_trim_mode(mode, uplevel: 5)
- end
-
perc = mode.include?('%')
if mode.include?('-')
return [perc, '-']
@@ -680,7 +683,6 @@ class ERB
[perc, nil]
end
else
- warn_invalid_trim_mode(mode, uplevel: 5)
return [false, nil]
end
end
@@ -732,10 +734,6 @@ class ERB
end
return enc, frozen
end
-
- def warn_invalid_trim_mode(mode, uplevel:)
- warn "Invalid ERB trim mode: #{mode.inspect} (trim_mode: nil, 0, 1, 2, or String composed of '%' and/or '-', '>', '<>')", uplevel: uplevel + 1
- end
end
end
@@ -746,7 +744,9 @@ class ERB
# Constructs a new ERB object with the template specified in _str_.
#
# An ERB object works by building a chunk of Ruby code that will output
- # the completed template when run.
+ # the completed template when run. If _safe_level_ is set to a non-nil value,
+ # ERB code will be run in a separate thread with <b>$SAFE</b> set to the
+ # provided level.
#
# If _trim_mode_ is passed a String containing one or more of the following
# modifiers, ERB will adjust its code generation as listed:
@@ -781,11 +781,11 @@ class ERB
# def build
# b = binding
# # create and run templates, filling member data variables
- # ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@product").result b
+ # ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), 0, "", "@product").result b
# <%= PRODUCT[:name] %>
# <%= PRODUCT[:desc] %>
# END_PRODUCT
- # ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@price").result b
+ # ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), 0, "", "@price").result b
# <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
# <%= PRODUCT[:desc] %>
# END_PRICE
@@ -806,31 +806,14 @@ class ERB
# Chicken Fried Steak -- 9.95
# A well messages pattie, breaded and fried.
#
- def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')
- # Complex initializer for $SAFE deprecation at [Feature #14256]. Use keyword arguments to pass trim_mode or eoutvar.
- if safe_level != NOT_GIVEN
- warn 'Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.', uplevel: 1 if $VERBOSE || !ZERO_SAFE_LEVELS.include?(safe_level)
- end
- if legacy_trim_mode != NOT_GIVEN
- warn 'Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.', uplevel: 1 if $VERBOSE
- trim_mode = legacy_trim_mode
- end
- if legacy_eoutvar != NOT_GIVEN
- warn 'Passing eoutvar with the 4th argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead.', uplevel: 1 if $VERBOSE
- eoutvar = legacy_eoutvar
- end
-
+ def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
+ @safe_level = safe_level
compiler = make_compiler(trim_mode)
set_eoutvar(compiler, eoutvar)
@src, @encoding, @frozen_string = *compiler.compile(str)
@filename = nil
@lineno = 0
- @_init = self.class.singleton_class
end
- NOT_GIVEN = Object.new
- private_constant :NOT_GIVEN
- ZERO_SAFE_LEVELS = [0, nil]
- private_constant :ZERO_SAFE_LEVELS
##
# Creates a new compiler for ERB. See ERB::Compiler.new for details
@@ -853,21 +836,6 @@ class ERB
# is run
attr_accessor :lineno
- #
- # Sets optional filename and line number that will be used in ERB code
- # evaluation and error reporting. See also #filename= and #lineno=
- #
- # erb = ERB.new('<%= some_x %>')
- # erb.render
- # # undefined local variable or method `some_x'
- # # from (erb):1
- #
- # erb.location = ['file.erb', 3]
- # # All subsequent error reporting would use new location
- # erb.render
- # # undefined local variable or method `some_x'
- # # from file.erb:4
- #
def location=((filename, lineno))
@filename = filename
@lineno = lineno if lineno
@@ -899,10 +867,14 @@ class ERB
# code evaluation.
#
def result(b=new_toplevel)
- unless @_init.equal?(self.class.singleton_class)
- raise ArgumentError, "not initialized"
+ if @safe_level
+ proc {
+ $SAFE = @safe_level
+ eval(@src, b, (@filename || '(erb)'), @lineno)
+ }.call
+ else
+ eval(@src, b, (@filename || '(erb)'), @lineno)
end
- eval(@src, b, (@filename || '(erb)'), @lineno)
end
# Render a template on a new toplevel binding with local variables specified
diff --git a/lib/fileutils.gemspec b/lib/fileutils.gemspec
index cd35c09dbc..5e11587aab 100644
--- a/lib/fileutils.gemspec
+++ b/lib/fileutils.gemspec
@@ -1,31 +1,25 @@
# frozen_string_literal: true
-
-source_version = ["", "lib/"].find do |dir|
- begin
- break File.open(File.join(__dir__, "#{dir}fileutils.rb")) {|f|
- f.gets("\n VERSION = ")
- f.gets[/\s*"(.+)"/, 1]
- }
- rescue Errno::ENOENT
- end
-end
-
Gem::Specification.new do |s|
s.name = "fileutils"
- s.version = source_version
+ s.version = '1.0.2'
+ s.date = '2017-12-22'
s.summary = "Several file utility methods for copying, moving, removing, etc."
s.description = "Several file utility methods for copying, moving, removing, etc."
s.require_path = %w{lib}
- s.files = ["LICENSE.txt", "README.md", "Rakefile", "fileutils.gemspec", "lib/fileutils.rb"]
- s.required_ruby_version = ">= 2.3.0"
+ s.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "fileutils.gemspec", "lib/fileutils.rb"]
+ s.required_ruby_version = ">= 2.4.0"
s.authors = ["Minero Aoki"]
s.email = [nil]
s.homepage = "https://github.com/ruby/fileutils"
s.license = "BSD-2-Clause"
- s.metadata = {
- "source_code_uri" => "https://github.com/ruby/fileutils"
- }
+ if s.respond_to?(:metadata=)
+ s.metadata = {
+ "source_code_uri" => "https://github.com/ruby/fileutils"
+ }
+ end
+
+ s.add_development_dependency 'rake'
end
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 04788e26ca..f56d7f9cb9 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1,11 +1,4 @@
# frozen_string_literal: true
-
-begin
- require 'rbconfig'
-rescue LoadError
- # for make mjit-headers
-end
-
#
# = fileutils.rb
#
@@ -22,58 +15,48 @@ end
#
# require 'fileutils'
#
-# FileUtils.cd(dir, **options)
-# FileUtils.cd(dir, **options) {|dir| block }
+# FileUtils.cd(dir, options)
+# FileUtils.cd(dir, options) {|dir| block }
# FileUtils.pwd()
-# FileUtils.mkdir(dir, **options)
-# FileUtils.mkdir(list, **options)
-# FileUtils.mkdir_p(dir, **options)
-# FileUtils.mkdir_p(list, **options)
-# FileUtils.rmdir(dir, **options)
-# FileUtils.rmdir(list, **options)
-# FileUtils.ln(target, link, **options)
-# FileUtils.ln(targets, dir, **options)
-# FileUtils.ln_s(target, link, **options)
-# FileUtils.ln_s(targets, dir, **options)
-# FileUtils.ln_sf(target, link, **options)
-# FileUtils.cp(src, dest, **options)
-# FileUtils.cp(list, dir, **options)
-# FileUtils.cp_r(src, dest, **options)
-# FileUtils.cp_r(list, dir, **options)
-# FileUtils.mv(src, dest, **options)
-# FileUtils.mv(list, dir, **options)
-# FileUtils.rm(list, **options)
-# FileUtils.rm_r(list, **options)
-# FileUtils.rm_rf(list, **options)
-# FileUtils.install(src, dest, **options)
-# FileUtils.chmod(mode, list, **options)
-# FileUtils.chmod_R(mode, list, **options)
-# FileUtils.chown(user, group, list, **options)
-# FileUtils.chown_R(user, group, list, **options)
-# FileUtils.touch(list, **options)
+# FileUtils.mkdir(dir, options)
+# FileUtils.mkdir(list, options)
+# FileUtils.mkdir_p(dir, options)
+# FileUtils.mkdir_p(list, options)
+# FileUtils.rmdir(dir, options)
+# FileUtils.rmdir(list, options)
+# FileUtils.ln(target, link, options)
+# FileUtils.ln(targets, dir, options)
+# FileUtils.ln_s(target, link, options)
+# FileUtils.ln_s(targets, dir, options)
+# FileUtils.ln_sf(target, link, options)
+# FileUtils.cp(src, dest, options)
+# FileUtils.cp(list, dir, options)
+# FileUtils.cp_r(src, dest, options)
+# FileUtils.cp_r(list, dir, options)
+# FileUtils.mv(src, dest, options)
+# FileUtils.mv(list, dir, options)
+# FileUtils.rm(list, options)
+# FileUtils.rm_r(list, options)
+# FileUtils.rm_rf(list, options)
+# FileUtils.install(src, dest, options)
+# FileUtils.chmod(mode, list, options)
+# FileUtils.chmod_R(mode, list, options)
+# FileUtils.chown(user, group, list, options)
+# FileUtils.chown_R(user, group, list, options)
+# FileUtils.touch(list, options)
#
-# Possible <tt>options</tt> are:
-#
-# <tt>:force</tt> :: forced operation (rewrite files if exist, remove
-# directories if not empty, etc.);
-# <tt>:verbose</tt> :: print command to be run, in bash syntax, before
-# performing it;
-# <tt>:preserve</tt> :: preserve object's group, user and modification
-# time on copying;
-# <tt>:noop</tt> :: no changes are made (usable in combination with
-# <tt>:verbose</tt> which will print the command to run)
-#
-# Each method documents the options that it honours. See also ::commands,
-# ::options and ::options_of methods to introspect which command have which
-# options.
+# The <tt>options</tt> parameter is a hash of options, taken from the list
+# <tt>:force</tt>, <tt>:noop</tt>, <tt>:preserve</tt>, and <tt>:verbose</tt>.
+# <tt>:noop</tt> means that no changes are made. The other three are obvious.
+# Each method documents the options that it honours.
#
# All methods that have the concept of a "source" file or directory can take
# either one file or a list of files in that argument. See the method
# documentation for examples.
#
-# There are some `low level' methods, which do not accept keyword arguments:
+# There are some `low level' methods, which do not accept any option:
#
-# FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
+# FileUtils.copy_entry(src, dest, preserve = false, dereference = false)
# FileUtils.copy_file(src, dest, preserve = false, dereference = true)
# FileUtils.copy_stream(srcstream, deststream)
# FileUtils.remove_entry(path, force = false)
@@ -101,8 +84,10 @@ end
# files/directories. This equates to passing the <tt>:noop</tt> and
# <tt>:verbose</tt> flags to methods in FileUtils.
#
+
module FileUtils
- VERSION = "1.4.1"
+
+ VERSION = "1.0.2"
def self.private_module_function(name) #:nodoc:
module_function name
@@ -123,22 +108,19 @@ module FileUtils
#
# Changes the current directory to the directory +dir+.
#
- # If this method is called with block, resumes to the previous
- # working directory after the block execution has finished.
- #
- # FileUtils.cd('/') # change directory
+ # If this method is called with block, resumes to the old
+ # working directory after the block execution finished.
#
- # FileUtils.cd('/', verbose: true) # change directory and report it
+ # FileUtils.cd('/', :verbose => true) # chdir and report it
#
- # FileUtils.cd('/') do # change directory
+ # FileUtils.cd('/') do # chdir
# # ... # do something
# end # return to original directory
#
def cd(dir, verbose: nil, &block) # :yield: dir
fu_output_message "cd #{dir}" if verbose
- result = Dir.chdir(dir, &block)
+ Dir.chdir(dir, &block)
fu_output_message 'cd -' if verbose and block
- result
end
module_function :cd
@@ -173,9 +155,9 @@ module FileUtils
# Creates one or more directories.
#
# FileUtils.mkdir 'test'
- # FileUtils.mkdir %w(tmp data)
- # FileUtils.mkdir 'notexist', noop: true # Does not really create.
- # FileUtils.mkdir 'tmp', mode: 0700
+ # FileUtils.mkdir %w( tmp data )
+ # FileUtils.mkdir 'notexist', :noop => true # Does not really create.
+ # FileUtils.mkdir 'tmp', :mode => 0700
#
def mkdir(list, mode: nil, noop: nil, verbose: nil)
list = fu_list(list)
@@ -194,7 +176,7 @@ module FileUtils
#
# FileUtils.mkdir_p '/usr/local/lib/ruby'
#
- # causes to make following directories, if they do not exist.
+ # causes to make following directories, if it does not exist.
#
# * /usr
# * /usr/local
@@ -258,7 +240,7 @@ module FileUtils
# FileUtils.rmdir 'somedir'
# FileUtils.rmdir %w(somedir anydir otherdir)
# # Does not really remove directory; outputs message.
- # FileUtils.rmdir 'somedir', verbose: true, noop: true
+ # FileUtils.rmdir 'somedir', :verbose => true, :noop => true
#
def rmdir(list, parents: nil, noop: nil, verbose: nil)
list = fu_list(list)
@@ -287,7 +269,7 @@ module FileUtils
#
# In the first form, creates a hard link +link+ which points to +target+.
# If +link+ already exists, raises Errno::EEXIST.
- # But if the +force+ option is set, overwrites +link+.
+ # But if the :force option is set, overwrites +link+.
#
# FileUtils.ln 'gcc', 'cc', verbose: true
# FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
@@ -314,39 +296,6 @@ module FileUtils
module_function :link
#
- # Hard link +src+ to +dest+. If +src+ is a directory, this method links
- # all its contents recursively. If +dest+ is a directory, links
- # +src+ to +dest/src+.
- #
- # +src+ can be a list of files.
- #
- # If +dereference_root+ is true, this method dereference tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
- # FileUtils.rm_r site_ruby + '/mylib', force: true
- # FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
- #
- # # Examples of linking several files to target directory.
- # FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail'
- # FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
- #
- # # If you want to link all contents of a directory instead of the
- # # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
- # # use the following code.
- # FileUtils.cp_lr 'src/.', 'dest' # cp_lr('src', 'dest') makes dest/src, but this doesn't.
- #
- def cp_lr(src, dest, noop: nil, verbose: nil,
- dereference_root: true, remove_destination: false)
- fu_output_message "cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if verbose
- return if noop
- fu_each_src_dest(src, dest) do |s, d|
- link_entry s, d, dereference_root, remove_destination
- end
- end
- module_function :cp_lr
-
- #
# :call-seq:
# FileUtils.ln_s(target, link, force: nil, noop: nil, verbose: nil)
# FileUtils.ln_s(target, dir, force: nil, noop: nil, verbose: nil)
@@ -354,7 +303,7 @@ module FileUtils
#
# In the first form, creates a symbolic link +link+ which points to +target+.
# If +link+ already exists, raises Errno::EEXIST.
- # But if the <tt>force</tt> option is set, overwrites +link+.
+ # But if the :force option is set, overwrites +link+.
#
# FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
# FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
@@ -393,26 +342,6 @@ module FileUtils
module_function :ln_sf
#
- # Hard links a file system entry +src+ to +dest+.
- # If +src+ is a directory, this method links its contents recursively.
- #
- # Both of +src+ and +dest+ must be a path name.
- # +src+ must exist, +dest+ must not exist.
- #
- # If +dereference_root+ is true, this method dereferences the tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
- def link_entry(src, dest, dereference_root = false, remove_destination = false)
- Entry_.new(src, nil, dereference_root).traverse do |ent|
- destent = Entry_.new(dest, ent.rel, false)
- File.unlink destent.path if remove_destination && File.file?(destent.path)
- ent.link destent.path
- end
- end
- module_function :link_entry
-
- #
# Copies a file content +src+ to +dest+. If +dest+ is a directory,
# copies +src+ to +dest/src+.
#
@@ -420,7 +349,7 @@ module FileUtils
#
# FileUtils.cp 'eval.c', 'eval.c.org'
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
- # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', verbose: true
+ # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
# FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
#
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
@@ -442,17 +371,13 @@ module FileUtils
#
# +src+ can be a list of files.
#
- # If +dereference_root+ is true, this method dereference tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
# # Installing Ruby library "mylib" under the site_ruby
- # FileUtils.rm_r site_ruby + '/mylib', force: true
+ # FileUtils.rm_r site_ruby + '/mylib', :force
# FileUtils.cp_r 'lib/', site_ruby + '/mylib'
#
# # Examples of copying several files to target directory.
# FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
- # FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', noop: true, verbose: true
+ # FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', :noop => true, :verbose => true
#
# # If you want to copy all contents of a directory instead of the
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
@@ -487,11 +412,7 @@ module FileUtils
# If +remove_destination+ is true, this method removes each destination file before copy.
#
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
- if dereference_root
- src = File.realpath(src)
- end
-
- Entry_.new(src, nil, false).wrap_traverse(proc do |ent|
+ Entry_.new(src, nil, dereference_root).wrap_traverse(proc do |ent|
destent = Entry_.new(dest, ent.rel, false)
File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path))
ent.copy destent.path
@@ -528,10 +449,10 @@ module FileUtils
# disk partition, the file is copied then the original file is removed.
#
# FileUtils.mv 'badname.rb', 'goodname.rb'
- # FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true # no error
+ # FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true # no error
#
# FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
- # FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
+ # FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
#
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
@@ -542,12 +463,13 @@ module FileUtils
if destent.exist?
if destent.directory?
raise Errno::EEXIST, d
+ else
+ destent.remove_file if rename_cannot_overwrite_file?
end
end
begin
File.rename s, d
- rescue Errno::EXDEV,
- Errno::EPERM # move from unencrypted to encrypted dir (ext4)
+ rescue Errno::EXDEV
copy_entry s, d, true
if secure
remove_entry_secure s, force
@@ -565,13 +487,18 @@ module FileUtils
alias move mv
module_function :move
+ def rename_cannot_overwrite_file? #:nodoc:
+ /emx/ =~ RUBY_PLATFORM
+ end
+ private_module_function :rename_cannot_overwrite_file?
+
#
# Remove file(s) specified in +list+. This method cannot remove directories.
# All StandardErrors are ignored when the :force option is set.
#
# FileUtils.rm %w( junk.txt dust.txt )
# FileUtils.rm Dir.glob('*.so')
- # FileUtils.rm 'NotExistFile', force: true # never raises exception
+ # FileUtils.rm 'NotExistFile', :force => true # never raises exception
#
def rm(list, force: nil, noop: nil, verbose: nil)
list = fu_list(list)
@@ -590,7 +517,7 @@ module FileUtils
#
# Equivalent to
#
- # FileUtils.rm(list, force: true)
+ # FileUtils.rm(list, :force => true)
#
def rm_f(list, noop: nil, verbose: nil)
rm list, force: true, noop: noop, verbose: verbose
@@ -606,18 +533,18 @@ module FileUtils
# StandardError when :force option is set.
#
# FileUtils.rm_r Dir.glob('/tmp/*')
- # FileUtils.rm_r 'some_dir', force: true
+ # FileUtils.rm_r 'some_dir', :force => true
#
# WARNING: This method causes local vulnerability
# if one of parent directories or removing directory tree are world
# writable (including /tmp, whose permission is 1777), and the current
# process has strong privilege such as Unix super user (root), and the
# system has symbolic link. For secure removing, read the documentation
- # of remove_entry_secure carefully, and set :secure option to true.
- # Default is <tt>secure: false</tt>.
+ # of #remove_entry_secure carefully, and set :secure option to true.
+ # Default is :secure=>false.
#
- # NOTE: This method calls remove_entry_secure if :secure option is set.
- # See also remove_entry_secure.
+ # NOTE: This method calls #remove_entry_secure if :secure option is set.
+ # See also #remove_entry_secure.
#
def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
list = fu_list(list)
@@ -636,10 +563,10 @@ module FileUtils
#
# Equivalent to
#
- # FileUtils.rm_r(list, force: true)
+ # FileUtils.rm_r(list, :force => true)
#
# WARNING: This method causes local vulnerability.
- # Read the documentation of rm_r first.
+ # Read the documentation of #rm_r first.
#
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
rm_r list, force: true, noop: noop, verbose: verbose, secure: secure
@@ -653,7 +580,7 @@ module FileUtils
# This method removes a file system entry +path+. +path+ shall be a
# regular file, a directory, or something. If +path+ is a directory,
# remove it recursively. This method is required to avoid TOCTTOU
- # (time-of-check-to-time-of-use) local security vulnerability of rm_r.
+ # (time-of-check-to-time-of-use) local security vulnerability of #rm_r.
# #rm_r causes security hole when:
#
# * Parent directory is world writable (including /tmp).
@@ -676,8 +603,8 @@ module FileUtils
#
# For details of this security vulnerability, see Perl's case:
#
- # * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
- # * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
+ # * http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
+ # * http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
#
# For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
#
@@ -701,38 +628,22 @@ module FileUtils
unless parent_st.sticky?
raise ArgumentError, "parent directory is world writable, FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{'%o' % parent_st.mode})"
end
-
# freeze tree root
euid = Process.euid
- dot_file = fullpath + "/."
- begin
- File.open(dot_file) {|f|
- unless fu_stat_identical_entry?(st, f.stat)
- # symlink (TOC-to-TOU attack?)
- File.unlink fullpath
- return
- end
- f.chown euid, -1
- f.chmod 0700
- }
- rescue Errno::EISDIR # JRuby in non-native mode can't open files as dirs
- File.lstat(dot_file).tap {|fstat|
- unless fu_stat_identical_entry?(st, fstat)
- # symlink (TOC-to-TOU attack?)
- File.unlink fullpath
- return
- end
- File.chown euid, -1, dot_file
- File.chmod 0700, dot_file
- }
- end
-
- unless fu_stat_identical_entry?(st, File.lstat(fullpath))
- # TOC-to-TOU attack?
- File.unlink fullpath
- return
- end
-
+ File.open(fullpath + '/.') {|f|
+ unless fu_stat_identical_entry?(st, f.stat)
+ # symlink (TOC-to-TOU attack?)
+ File.unlink fullpath
+ return
+ end
+ f.chown euid, -1
+ f.chmod 0700
+ unless fu_stat_identical_entry?(st, File.lstat(fullpath))
+ # TOC-to-TOU attack?
+ File.unlink fullpath
+ return
+ end
+ }
# ---- tree root is frozen ----
root = Entry_.new(path)
root.preorder_traverse do |ent|
@@ -772,7 +683,7 @@ module FileUtils
# +path+ might be a regular file, a directory, or something.
# If +path+ is a directory, remove it recursively.
#
- # See also remove_entry_secure.
+ # See also #remove_entry_secure.
#
def remove_entry(path, force = false)
Entry_.new(path).postorder_traverse do |ent|
@@ -833,15 +744,8 @@ module FileUtils
#
def compare_stream(a, b)
bsize = fu_stream_blksize(a, b)
-
- if RUBY_VERSION > "2.4"
- sa = String.new(capacity: bsize)
- sb = String.new(capacity: bsize)
- else
- sa = String.new
- sb = String.new
- end
-
+ sa = String.new(capacity: bsize)
+ sb = String.new(capacity: bsize)
begin
a.read(bsize, sa)
b.read(bsize, sb)
@@ -856,8 +760,8 @@ module FileUtils
# mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
# This method removes destination before copy.
#
- # FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
- # FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
+ # FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
+ # FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
#
def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
noop: nil, verbose: nil)
@@ -987,12 +891,12 @@ module FileUtils
# Absolute mode is
# FileUtils.chmod 0755, 'somecommand'
# FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
- # FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
+ # FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
#
# Symbolic mode is
# FileUtils.chmod "u=wrx,go=rx", 'somecommand'
# FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
- # FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
+ # FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :verbose => true
#
# "a" :: is user, group, other mask.
# "u" :: is user's mask.
@@ -1052,7 +956,7 @@ module FileUtils
# the attribute.
#
# FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
- # FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
+ # FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :verbose => true
#
def chown(user, group, list, noop: nil, verbose: nil)
list = fu_list(list)
@@ -1076,7 +980,7 @@ module FileUtils
# method does not change the attribute.
#
# FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
- # FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
+ # FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :verbose => true
#
def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
list = fu_list(list)
@@ -1099,6 +1003,11 @@ module FileUtils
end
module_function :chown_R
+ begin
+ require 'etc'
+ rescue LoadError # rescue LoadError for miniruby
+ end
+
def fu_get_uid(user) #:nodoc:
return nil unless user
case user
@@ -1107,7 +1016,6 @@ module FileUtils
when /\A\d+\z/
user.to_i
else
- require 'etc'
Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
end
end
@@ -1121,7 +1029,6 @@ module FileUtils
when /\A\d+\z/
group.to_i
else
- require 'etc'
Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
end
end
@@ -1162,11 +1069,8 @@ module FileUtils
module StreamUtils_
private
- case (defined?(::RbConfig) ? ::RbConfig::CONFIG['host_os'] : ::RUBY_PLATFORM)
- when /mswin|mingw/
- def fu_windows?; true end
- else
- def fu_windows?; false end
+ def fu_windows?
+ /mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM
end
def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
@@ -1291,16 +1195,9 @@ module FileUtils
def entries
opts = {}
opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
-
- files = if Dir.respond_to?(:children)
- Dir.children(path, **opts)
- else
- Dir.entries(path(), **opts)
- .reject {|n| n == '.' or n == '..' }
- end
-
- untaint = RUBY_VERSION < '2.7'
- files.map {|n| Entry_.new(prefix(), join(rel(), untaint ? n.untaint : n)) }
+ Dir.entries(path(), opts)\
+ .reject {|n| n == '.' or n == '..' }\
+ .map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
end
def stat
@@ -1345,7 +1242,6 @@ module FileUtils
else
File.chmod mode, path()
end
- rescue Errno::EOPNOTSUPP
end
def chown(uid, gid)
@@ -1356,22 +1252,6 @@ module FileUtils
end
end
- def link(dest)
- case
- when directory?
- if !File.exist?(dest) and descendant_directory?(dest, path)
- raise ArgumentError, "cannot link directory %s to itself %s" % [path, dest]
- end
- begin
- Dir.mkdir dest
- rescue
- raise unless File.directory?(dest)
- end
- else
- File.link path(), dest
- end
- end
-
def copy(dest)
lstat
case
@@ -1388,21 +1268,18 @@ module FileUtils
end
when symlink?
File.symlink File.readlink(path()), dest
- when chardev?, blockdev?
- raise "cannot handle device file"
+ when chardev?
+ raise "cannot handle device file" unless File.respond_to?(:mknod)
+ mknod dest, ?c, 0666, lstat().rdev
+ when blockdev?
+ raise "cannot handle device file" unless File.respond_to?(:mknod)
+ mknod dest, ?b, 0666, lstat().rdev
when socket?
- begin
- require 'socket'
- rescue LoadError
- raise "cannot handle socket"
- else
- raise "cannot handle socket" unless defined?(UNIXServer)
- end
- UNIXServer.new(dest).close
- File.chmod lstat().mode, dest
+ raise "cannot handle socket" unless File.respond_to?(:mknod)
+ mknod dest, nil, lstat().mode, 0
when pipe?
raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
- File.mkfifo dest, lstat().mode
+ mkfifo dest, 0666
when door?
raise "cannot handle door: #{path()}"
else
@@ -1440,7 +1317,7 @@ module FileUtils
if st.symlink?
begin
File.lchmod mode, path
- rescue NotImplementedError, Errno::EOPNOTSUPP
+ rescue NotImplementedError
end
else
File.chmod mode, path
@@ -1521,14 +1398,14 @@ module FileUtils
private
- @@fileutils_rb_have_lchmod = nil
+ $fileutils_rb_have_lchmod = nil
def have_lchmod?
# This is not MT-safe, but it does not matter.
- if @@fileutils_rb_have_lchmod == nil
- @@fileutils_rb_have_lchmod = check_have_lchmod?
+ if $fileutils_rb_have_lchmod == nil
+ $fileutils_rb_have_lchmod = check_have_lchmod?
end
- @@fileutils_rb_have_lchmod
+ $fileutils_rb_have_lchmod
end
def check_have_lchmod?
@@ -1539,14 +1416,14 @@ module FileUtils
return false
end
- @@fileutils_rb_have_lchown = nil
+ $fileutils_rb_have_lchown = nil
def have_lchown?
# This is not MT-safe, but it does not matter.
- if @@fileutils_rb_have_lchown == nil
- @@fileutils_rb_have_lchown = check_have_lchown?
+ if $fileutils_rb_have_lchown == nil
+ $fileutils_rb_have_lchown = check_have_lchown?
end
- @@fileutils_rb_have_lchown
+ $fileutils_rb_have_lchown
end
def check_have_lchown?
@@ -1568,13 +1445,10 @@ module FileUtils
else
DIRECTORY_TERM = "(?=/|\\z)"
end
+ SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : ""
def descendant_directory?(descendant, ascendant)
- if File::FNM_SYSCASE.nonzero?
- File.expand_path(File.dirname(descendant)).casecmp(File.expand_path(ascendant)) == 0
- else
- File.expand_path(File.dirname(descendant)) == File.expand_path(ascendant)
- end
+ /\A(?#{SYSCASE}:#{Regexp.quote(ascendant)})#{DIRECTORY_TERM}/ =~ File.dirname(descendant)
end
end # class Entry_
@@ -1613,13 +1487,13 @@ module FileUtils
end
private_module_function :fu_same?
+ @fileutils_output = $stderr
+ @fileutils_label = ''
+
def fu_output_message(msg) #:nodoc:
- output = @fileutils_output if defined?(@fileutils_output)
- output ||= $stderr
- if defined?(@fileutils_label)
- msg = @fileutils_label + msg
- end
- output.puts msg
+ @fileutils_output ||= $stderr
+ @fileutils_label ||= ''
+ @fileutils_output.puts @fileutils_label + msg
end
private_module_function :fu_output_message
@@ -1630,11 +1504,8 @@ module FileUtils
tbl
}
- public
-
#
- # Returns an Array of names of high-level methods that accept any keyword
- # arguments.
+ # Returns an Array of method names which have any options.
#
# p FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
#
@@ -1673,7 +1544,7 @@ module FileUtils
end
#
- # Returns an Array of methods names which have the option +opt+.
+ # Returns an Array of method names which have the option +opt+.
#
# p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
#
@@ -1681,16 +1552,14 @@ module FileUtils
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
end
- private
-
- LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern) # :nodoc:
- module LowMethods # :nodoc: internal use only
+ LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern)
+ module LowMethods
private
def _do_nothing(*)end
::FileUtils::LOW_METHODS.map {|name| alias_method name, :_do_nothing}
end
- METHODS = singleton_methods() - [:private_module_function, # :nodoc:
+ METHODS = singleton_methods() - [:private_module_function,
:commands, :options, :have_option?, :options_of, :collect_method]
#
@@ -1700,6 +1569,8 @@ module FileUtils
#
module Verbose
include FileUtils
+ @fileutils_output = $stderr
+ @fileutils_label = ''
names = ::FileUtils.collect_method(:verbose)
names.each do |name|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
@@ -1723,6 +1594,8 @@ module FileUtils
module NoWrite
include FileUtils
include LowMethods
+ @fileutils_output = $stderr
+ @fileutils_label = ''
names = ::FileUtils.collect_method(:noop)
names.each do |name|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
@@ -1747,6 +1620,8 @@ module FileUtils
module DryRun
include FileUtils
include LowMethods
+ @fileutils_output = $stderr
+ @fileutils_label = ''
names = ::FileUtils.collect_method(:noop)
names.each do |name|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
diff --git a/lib/find.rb b/lib/find.rb
index 3f54cf6b93..f97cc1b836 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -15,7 +15,7 @@
#
# Find.find(ENV["HOME"]) do |path|
# if FileTest.directory?(path)
-# if File.basename(path).start_with?('.')
+# if File.basename(path)[0] == ?.
# Find.prune # Don't look any further into this directory.
# else
# next
@@ -46,7 +46,7 @@ module Find
ps = [path]
while file = ps.shift
catch(:prune) do
- yield file.dup
+ yield file.dup.taint
begin
s = File.lstat(file)
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
@@ -63,7 +63,7 @@ module Find
fs.sort!
fs.reverse_each {|f|
f = File.join(file, f)
- ps.unshift f
+ ps.unshift f.untaint
}
end
end
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 4cfade470a..a8e5aa1d5a 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -57,9 +57,10 @@
#
# == Another example
#
-# You could use Forwardable as an alternative to inheritance, when you don't want
-# to inherit all methods from the superclass. For instance, here is how you might
-# add a range of +Array+ instance methods to a new class +Queue+:
+# We want to rely on what has come before obviously, but with delegation we can
+# take just the methods we need and even rename them as appropriate. In many
+# cases this is preferable to inheritance, which gives us the entire old
+# interface, even if much of it isn't needed.
#
# class Queue
# extend Forwardable
@@ -110,7 +111,9 @@
#
module Forwardable
require 'forwardable/impl'
- require "forwardable/version"
+
+ # Version of +forwardable.rb+
+ FORWARDABLE_VERSION = "1.2.0"
@debug = nil
class << self
@@ -119,8 +122,7 @@ module Forwardable
end
# Takes a hash as its argument. The key is a symbol or an array of
- # symbols. These symbols correspond to method names, instance variable
- # names, or constant names (see def_delegator). The value is
+ # symbols. These symbols correspond to method names. The value is
# the accessor to which the methods will be delegated.
#
# :call-seq:
@@ -149,21 +151,18 @@ module Forwardable
# def_delegator :@records, :map
#
def def_instance_delegators(accessor, *methods)
- methods.each do |method|
- next if /\A__(?:send|id)__\z/ =~ method
+ methods.delete("__send__")
+ methods.delete("__id__")
+ for method in methods
def_instance_delegator(accessor, method)
end
end
# Define +method+ as delegator instance method with an optional
# alias name +ali+. Method calls to +ali+ will be delegated to
- # +accessor.method+. +accessor+ should be a method name, instance
- # variable name, or constant name. Use the full path to the
- # constant if providing the constant name.
- # Returns the name of the method defined.
+ # +accessor.method+.
#
# class MyQueue
- # CONST = 1
# extend Forwardable
# attr_reader :queue
# def initialize
@@ -171,23 +170,18 @@ module Forwardable
# end
#
# def_delegator :@queue, :push, :mypush
- # def_delegator 'MyQueue::CONST', :to_i
# end
#
# q = MyQueue.new
# q.mypush 42
# q.queue #=> [42]
# q.push 23 #=> NoMethodError
- # q.to_i #=> 1
#
def def_instance_delegator(accessor, method, ali = method)
gen = Forwardable._delegator_method(self, accessor, method, ali)
# If it's not a class or module, it's an instance
- mod = Module === self ? self : singleton_class
- ret = mod.module_eval(&gen)
- mod.send(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
- ret
+ (Module === self ? self : singleton_class).module_eval(&gen)
end
alias delegate instance_delegate
@@ -227,7 +221,7 @@ module Forwardable
#{pre}
begin
#{accessor}
- end#{method_call}
+ end#{method_call}#{FILTER_EXCEPTION}
end
end
end;
@@ -289,8 +283,9 @@ module SingleForwardable
# def_delegator :@records, :map
#
def def_single_delegators(accessor, *methods)
- methods.each do |method|
- next if /\A__(?:send|id)__\z/ =~ method
+ methods.delete("__send__")
+ methods.delete("__id__")
+ for method in methods
def_single_delegator(accessor, method)
end
end
@@ -301,13 +296,10 @@ module SingleForwardable
# Defines a method _method_ which delegates to _accessor_ (i.e. it calls
# the method of the same name in _accessor_). If _new_name_ is
# provided, it is used as the name for the delegate method.
- # Returns the name of the method defined.
def def_single_delegator(accessor, method, ali = method)
gen = Forwardable._delegator_method(self, accessor, method, ali)
- ret = instance_eval(&gen)
- singleton_class.send(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
- ret
+ instance_eval(&gen)
end
alias delegate single_delegate
diff --git a/lib/forwardable/forwardable.gemspec b/lib/forwardable/forwardable.gemspec
deleted file mode 100644
index 2a3e637e26..0000000000
--- a/lib/forwardable/forwardable.gemspec
+++ /dev/null
@@ -1,23 +0,0 @@
-begin
- require_relative "lib/forwardable/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "forwardable"
- spec.version = Forwardable::VERSION
- spec.authors = ["Keiju ISHITSUKA"]
- spec.email = ["keiju@ruby-lang.org"]
-
- spec.summary = %q{Provides delegation of specified methods to a designated object.}
- spec.description = %q{Provides delegation of specified methods to a designated object.}
- spec.homepage = "https://github.com/ruby/forwardable"
- spec.license = "BSD-2-Clause"
-
- spec.files = ["forwardable.gemspec", "lib/forwardable.rb", "lib/forwardable/impl.rb", "lib/forwardable/version.rb"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/forwardable/impl.rb b/lib/forwardable/impl.rb
index 58a9dfb69c..220d25aa95 100644
--- a/lib/forwardable/impl.rb
+++ b/lib/forwardable/impl.rb
@@ -1,5 +1,13 @@
# :stopdoc:
module Forwardable
+ FILE_REGEXP = %r"#{Regexp.quote(File.dirname(__FILE__))}"
+ FILTER_EXCEPTION = <<-'END'
+
+ rescue ::Exception
+ $@.delete_if {|s| ::Forwardable::FILE_REGEXP =~ s} unless ::Forwardable::debug
+ ::Kernel::raise
+ END
+
def self._valid_method?(method)
catch {|tag|
eval("BEGIN{throw tag}; ().#{method}", binding, __FILE__, __LINE__)
diff --git a/lib/forwardable/version.rb b/lib/forwardable/version.rb
deleted file mode 100644
index 8f3e1f510e..0000000000
--- a/lib/forwardable/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Forwardable
- # Version of +forwardable.rb+
- VERSION = "1.3.1"
- FORWARDABLE_VERSION = VERSION
-end
diff --git a/lib/getoptlong/getoptlong.gemspec b/lib/getoptlong/getoptlong.gemspec
deleted file mode 100644
index 5e218b8e93..0000000000
--- a/lib/getoptlong/getoptlong.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/getoptlong/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "getoptlong"
- spec.version = GetoptLong::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{GetoptLong for Ruby}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/getoptlong"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/getoptlong/version.rb b/lib/getoptlong/version.rb
deleted file mode 100644
index 6375fb8ad1..0000000000
--- a/lib/getoptlong/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class GetoptLong
- VERSION = "0.1.0"
-end
diff --git a/lib/ipaddr.gemspec b/lib/ipaddr.gemspec
index 2de9ef4881..16df1708b0 100644
--- a/lib/ipaddr.gemspec
+++ b/lib/ipaddr.gemspec
@@ -1,11 +1,10 @@
-# frozen_string_literal: true
# coding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "ipaddr"
- spec.version = "1.2.2"
+ spec.version = "1.2.0"
spec.authors = ["Akinori MUSHA", "Hajimu UMEMOTO"]
spec.email = ["knu@idaemons.org", "ume@mahoroba.org"]
@@ -15,7 +14,6 @@ IPAddr provides a set of methods to manipulate an IP address.
Both IPv4 and IPv6 are supported.
DESCRIPTION
spec.homepage = "https://github.com/ruby/ipaddr"
- spec.license = "BSD-2-Clause"
spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "ipaddr.gemspec", "lib/ipaddr.rb"]
spec.bindir = "exe"
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 7fff54b9d0..60f102d4e6 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: true
+# frozen_string_literal: false
#
# ipaddr.rb - A class to manipulate an IP address
#
@@ -103,13 +103,13 @@ class IPAddr
# Creates a new ipaddr containing the given network byte ordered
# string form of an IP address.
- def self.new_ntoh(addr)
- return new(ntop(addr))
+ def IPAddr::new_ntoh(addr)
+ return IPAddr.new(IPAddr::ntop(addr))
end
# Convert a network byte ordered string form of an IP address into
# human readable form.
- def self.ntop(addr)
+ def IPAddr::ntop(addr)
case addr.size
when 4
s = addr.unpack('C4').join('.')
@@ -594,8 +594,6 @@ class IPAddr
else
@mask_addr = (@family == Socket::AF_INET) ? IN4MASK : IN6MASK
end
- rescue InvalidAddressError => e
- raise e.class, "#{e.message}: #{addr}"
end
def coerce_other(other)
diff --git a/lib/irb.rb b/lib/irb.rb
index d8e1209f2c..d650e9c497 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -9,20 +9,15 @@
#
#
#
-require "ripper"
-require "reline"
+require "e2mmap"
-require_relative "irb/init"
-require_relative "irb/context"
-require_relative "irb/extend-command"
+require "irb/init"
+require "irb/context"
+require "irb/extend-command"
-require_relative "irb/ruby-lex"
-require_relative "irb/input-method"
-require_relative "irb/locale"
-require_relative "irb/color"
-
-require_relative "irb/version"
-require_relative "irb/easter-egg"
+require "irb/ruby-lex"
+require "irb/input-method"
+require "irb/locale"
# IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
# expressions read from the standard input.
@@ -46,8 +41,8 @@ require_relative "irb/easter-egg"
# irb(main):006:1> end
# #=> nil
#
-# The singleline editor module or multiline editor module can be used with irb.
-# Use of multiline editor is default if it's installed.
+# The Readline extension module can be used with irb. Use of Readline is
+# default if it's installed.
#
# == Command line options
#
@@ -62,24 +57,21 @@ require_relative "irb/easter-egg"
# -W[level=2] Same as `ruby -W`
# --inspect Use `inspect' for output (default except for bc mode)
# --noinspect Don't use inspect for output
-# --multiline Use multiline editor module
-# --nomultiline Don't use multiline editor module
-# --singleline Use singleline editor module
-# --nosingleline Don't use singleline editor module
-# --colorize Use colorization
-# --nocolorize Don't use colorization
+# --readline Use Readline extension module
+# --noreadline Don't use Readline extension module
# --prompt prompt-mode
# --prompt-mode prompt-mode
# Switch prompt mode. Pre-defined prompt modes are
# `default', `simple', `xmp' and `inf-ruby'
# --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
-# Suppresses --multiline and --singleline.
+# Suppresses --readline.
# --simple-prompt Simple prompt mode
# --noprompt No prompt mode
# --tracer Display trace for each execution of commands.
# --back-trace-limit n
# Display backtrace top n and tail n. The default
# value is 16.
+# --irb_debug n Set internal debug level to n (not for popular use)
# -v, --version Print the version of irb
#
# == Configuration
@@ -101,20 +93,19 @@ require_relative "irb/easter-egg"
# IRB.conf[:IRB_RC] = nil
# IRB.conf[:BACK_TRACE_LIMIT]=16
# IRB.conf[:USE_LOADER] = false
-# IRB.conf[:USE_MULTILINE] = nil
-# IRB.conf[:USE_SINGLELINE] = nil
-# IRB.conf[:USE_COLORIZE] = true
+# IRB.conf[:USE_READLINE] = nil
# IRB.conf[:USE_TRACER] = false
# IRB.conf[:IGNORE_SIGINT] = true
# IRB.conf[:IGNORE_EOF] = false
# IRB.conf[:PROMPT_MODE] = :DEFAULT
# IRB.conf[:PROMPT] = {...}
+# IRB.conf[:DEBUG_LEVEL]=0
#
# === Auto indentation
#
-# To disable auto-indent mode in irb, add the following to your +.irbrc+:
+# To enable auto-indent mode in irb, add the following to your +.irbrc+:
#
-# IRB.conf[:AUTO_INDENT] = false
+# IRB.conf[:AUTO_INDENT] = true
#
# === Autocompletion
#
@@ -124,22 +115,15 @@ require_relative "irb/easter-egg"
#
# === History
#
-# By default, irb will store the last 1000 commands you used in
-# <code>IRB.conf[:HISTORY_FILE]</code> (<code>~/.irb_history</code> by default).
-#
-# If you want to disable history, add the following to your +.irbrc+:
+# By default, irb disables history and will not store any commands you used.
#
-# IRB.conf[:SAVE_HISTORY] = nil
+# If you want to enable history, add the following to your +.irbrc+:
#
-# See IRB::Context#save_history= for more information.
+# IRB.conf[:SAVE_HISTORY] = 1000
#
-# The history of _results_ of commands evaluated is not stored by default,
-# but can be turned on to be stored with this +.irbrc+ setting:
+# This will now store the last 1000 commands in <code>~/.irb_history</code>.
#
-# IRB.conf[:EVAL_HISTORY] = <number>
-#
-# See IRB::Context#eval_history= and History class. The history of command
-# results is not permanently saved in any file.
+# See IRB::Context#save_history= for more information.
#
# == Customizing the IRB Prompt
#
@@ -150,7 +134,7 @@ require_relative "irb/easter-egg"
# This example can be used in your +.irbrc+
#
# IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
-# :AUTO_INDENT => false, # disables auto-indent mode
+# :AUTO_INDENT => true, # enables auto-indent mode
# :PROMPT_I => ">> ", # simple prompt
# :PROMPT_S => nil, # prompt for continuated strings
# :PROMPT_C => nil, # prompt for continuated statement
@@ -179,7 +163,6 @@ require_relative "irb/easter-egg"
#
# IRB.conf[:PROMPT_MODE][:DEFAULT] = {
# :PROMPT_I => "%N(%m):%03n:%i> ",
-# :PROMPT_N => "%N(%m):%03n:%i> ",
# :PROMPT_S => "%N(%m):%03n:%i%l ",
# :PROMPT_C => "%N(%m):%03n:%i* ",
# :RETURN => "%s\n" # used to printf
@@ -272,7 +255,7 @@ require_relative "irb/easter-egg"
# On the other hand, each conf in IRB@Command+line+options is used to
# individually configure IRB.irb.
#
-# If a proc is set for <code>IRB.conf[:IRB_RC]</code>, its will be invoked after execution
+# If a proc is set for IRB.conf[:IRB_RC], its will be invoked after execution
# of that proc with the context of the current session as its argument. Each
# session can be configured using this mechanism.
#
@@ -283,9 +266,7 @@ require_relative "irb/easter-egg"
# <code>_</code>::
# The value command executed, as a local variable
# <code>__</code>::
-# The history of evaluated commands. Available only if
-# <code>IRB.conf[:EVAL_HISTORY]</code> is not +nil+ (which is the default).
-# See also IRB::Context#eval_history= and IRB::History.
+# The history of evaluated commands
# <code>__[line_no]</code>::
# Returns the evaluation value at the given line number, +line_no+.
# If +line_no+ is a negative, the return value +line_no+ many lines before
@@ -321,7 +302,7 @@ require_relative "irb/easter-egg"
# # check if Foo#foo is available
# irb(main):005:0> Foo.instance_methods #=> [:foo, ...]
#
-# # change the active session
+# # change the active sesssion
# irb(main):006:0> fg 2
# # define Foo#bar in the context of Foo
# irb.2(Foo):005:0> def bar
@@ -373,7 +354,9 @@ module IRB
def IRB.version
if v = @CONF[:VERSION] then return v end
- @CONF[:VERSION] = format("irb %s (%s)", @RELEASE_VERSION, @LAST_UPDATE_DATE)
+ require "irb/version"
+ rv = @RELEASE_VERSION.sub(/\.0/, "")
+ @CONF[:VERSION] = format("irb %s(%s)", rv, @LAST_UPDATE_DATE)
end
# The current IRB::Context of the session, see IRB.conf
@@ -400,7 +383,7 @@ module IRB
irb.run(@CONF)
end
- # Calls each event hook of <code>IRB.conf[:TA_EXIT]</code> when the current session quits.
+ # Calls each event hook of IRB.conf[:AT_EXIT] when the current session quits.
def IRB.irb_at_exit
@CONF[:AT_EXIT].each{|hook| hook.call}
end
@@ -422,41 +405,14 @@ module IRB
end
class Irb
- ASSIGNMENT_NODE_TYPES = [
- # Local, instance, global, class, constant, instance, and index assignment:
- # "foo = bar",
- # "@foo = bar",
- # "$foo = bar",
- # "@@foo = bar",
- # "::Foo = bar",
- # "a::Foo = bar",
- # "Foo = bar"
- # "foo.bar = 1"
- # "foo[1] = bar"
- :assign,
-
- # Operation assignment:
- # "foo += bar"
- # "foo -= bar"
- # "foo ||= bar"
- # "foo &&= bar"
- :opassign,
-
- # Multiple assignment:
- # "foo, bar = 1, 2
- :massign,
- ]
- # Note: instance and index assignment expressions could also be written like:
- # "foo.bar=(1)" and "foo.[]=(1, bar)", when expressed that way, the former
- # be parsed as :assign and echo will be suppressed, but the latter is
- # parsed as a :method_add_arg and the output won't be suppressed
-
# Creates a new irb session
- def initialize(workspace = nil, input_method = nil)
- @context = Context.new(self, workspace, input_method)
+ def initialize(workspace = nil, input_method = nil, output_method = nil)
+ @context = Context.new(self, workspace, input_method, output_method)
@context.main.extend ExtendCommandBundle
@signal_status = :IN_IRB
+
@scanner = RubyLex.new
+ @scanner.exception_on_syntax_error = false
end
def run(conf = IRB.conf)
@@ -483,8 +439,6 @@ module IRB
# Evaluates input for this session.
def eval_input
- exc = nil
-
@scanner.set_prompt do
|ltype, indent, continue, line_no|
if ltype
@@ -502,16 +456,14 @@ module IRB
else
@context.io.prompt = p = ""
end
- if @context.auto_indent_mode and !@context.io.respond_to?(:auto_indent)
+ if @context.auto_indent_mode
unless ltype
- prompt_i = @context.prompt_i.nil? ? "" : @context.prompt_i
- ind = prompt(prompt_i, ltype, indent, line_no)[/.*\z/].size +
+ ind = prompt(@context.prompt_i, ltype, indent, line_no)[/.*\z/].size +
indent * 2 - p.size
ind += 2 if continue
@context.io.prompt = p + " " * ind if ind > 0
end
end
- @context.io.prompt
end
@scanner.set_input(@context.io) do
@@ -532,89 +484,56 @@ module IRB
end
end
- @scanner.set_auto_indent(@context) if @context.auto_indent_mode
-
@scanner.each_top_level_statement do |line, line_no|
signal_status(:IN_EVAL) do
begin
- line.untaint if RUBY_VERSION < '2.7'
- @context.evaluate(line, line_no, exception: exc)
- if @context.echo?
- if assignment_expression?(line)
- if @context.echo_on_assignment?
- output_value(@context.omit_on_assignment?)
- end
- else
- output_value
- end
- end
+ line.untaint
+ @context.evaluate(line, line_no)
+ output_value if @context.echo?
+ exc = nil
rescue Interrupt => exc
rescue SystemExit, SignalException
raise
rescue Exception => exc
- else
- exc = nil
- next
end
- handle_exception(exc)
- end
- end
- end
-
- def handle_exception(exc)
- if exc.backtrace && exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
- !(SyntaxError === exc) && !(EncodingError === exc)
- # The backtrace of invalid encoding hash (ex. {"\xAE": 1}) raises EncodingError without lineno.
- irb_bug = true
- else
- irb_bug = false
- end
+ if exc
+ if exc.backtrace && exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
+ !(SyntaxError === exc)
+ irb_bug = true
+ else
+ irb_bug = false
+ end
- if STDOUT.tty?
- attr = ATTR_TTY
- print "#{attr[1]}Traceback#{attr[]} (most recent call last):\n"
- else
- attr = ATTR_PLAIN
- end
- messages = []
- lasts = []
- levels = 0
- if exc.backtrace
- count = 0
- exc.backtrace.each do |m|
- m = @context.workspace.filter_backtrace(m) or next unless irb_bug
- count += 1
- if attr == ATTR_TTY
- m = sprintf("%9d: from %s", count, m)
- else
- m = "\tfrom #{m}"
- end
- if messages.size < @context.back_trace_limit
- messages.push(m)
- elsif lasts.size < @context.back_trace_limit
- lasts.push(m).shift
- levels += 1
+ messages = []
+ lasts = []
+ levels = 0
+ if exc.backtrace
+ count = 0
+ exc.backtrace.each do |m|
+ m = @context.workspace.filter_backtrace(m) or next unless irb_bug
+ m = sprintf("%9d: from %s", (count += 1), m)
+ if messages.size < @context.back_trace_limit
+ messages.push(m)
+ elsif lasts.size < @context.back_trace_limit
+ lasts.push(m).shift
+ levels += 1
+ end
+ end
+ end
+ attr = STDOUT.tty? ? ATTR_TTY : ATTR_PLAIN
+ print "#{attr[1]}Traceback#{attr[]} (most recent call last):\n"
+ unless lasts.empty?
+ puts lasts.reverse
+ printf "... %d levels...\n", levels if levels > 0
+ end
+ puts messages.reverse
+ messages = exc.to_s.split(/\n/)
+ print "#{attr[1]}#{exc.class} (#{attr[4]}#{messages.shift}#{attr[0, 1]})#{attr[]}\n"
+ puts messages.map {|s| "#{attr[1]}#{s}#{attr[]}\n"}
+ print "Maybe IRB bug!\n" if irb_bug
end
end
end
- if attr == ATTR_TTY
- unless lasts.empty?
- puts lasts.reverse
- printf "... %d levels...\n", levels if levels > 0
- end
- puts messages.reverse
- end
- m = exc.to_s.split(/\n/)
- print "#{attr[1]}#{exc.class} (#{attr[4]}#{m.shift}#{attr[0, 1]})#{attr[]}\n"
- puts m.map {|s| "#{attr[1]}#{s}#{attr[]}\n"}
- if attr == ATTR_PLAIN
- puts messages
- unless lasts.empty?
- puts lasts
- printf "... %d levels...\n", levels if levels > 0
- end
- end
- print "Maybe IRB bug!\n" if irb_bug
end
# Evaluates the given block using the given +path+ as the Context#irb_path
@@ -720,18 +639,10 @@ module IRB
when "l"
ltype
when "i"
- if indent < 0
- if $1
- "-".rjust($1.to_i)
- else
- "-"
- end
+ if $1
+ format("%" + $1 + "d", indent)
else
- if $1
- format("%" + $1 + "d", indent)
- else
- indent.to_s
- end
+ indent.to_s
end
when "n"
if $1
@@ -746,37 +657,8 @@ module IRB
p
end
- def output_value(omit = false) # :nodoc:
- str = @context.inspect_last_value
- multiline_p = str.include?("\n")
- if omit
- winwidth = @context.io.winsize.last
- if multiline_p
- first_line = str.split("\n").first
- result = @context.newline_before_multiline_output? ? (@context.return_format % first_line) : first_line
- output_width = Reline::Unicode.calculate_width(result, true)
- diff_size = output_width - Reline::Unicode.calculate_width(first_line, true)
- if diff_size.positive? and output_width > winwidth
- lines, _ = Reline::Unicode.split_by_width(first_line, winwidth - diff_size - 3)
- str = "%s...\e[0m" % lines.first
- multiline_p = false
- else
- str.gsub!(/(\A.*?\n).*/m, "\\1...")
- end
- else
- output_width = Reline::Unicode.calculate_width(@context.return_format % str, true)
- diff_size = output_width - Reline::Unicode.calculate_width(str, true)
- if diff_size.positive? and output_width > winwidth
- lines, _ = Reline::Unicode.split_by_width(str, winwidth - diff_size - 3)
- str = "%s...\e[0m" % lines.first
- end
- end
- end
- if multiline_p && @context.newline_before_multiline_output?
- printf @context.return_format, "\n#{str}"
- else
- printf @context.return_format, str
- end
+ def output_value # :nodoc:
+ printf @context.return_format, @context.inspect_last_value
end
# Outputs the local variables to this current session, including
@@ -796,21 +678,6 @@ module IRB
format("#<%s: %s>", self.class, ary.join(", "))
end
- def assignment_expression?(line)
- # Try to parse the line and check if the last of possibly multiple
- # expressions is an assignment type.
-
- # If the expression is invalid, Ripper.sexp should return nil which will
- # result in false being returned. Any valid expression should return an
- # s-expression where the second selement of the top level array is an
- # array of parsed expressions. The first element of each expression is the
- # expression's type.
- verbose, $VERBOSE = $VERBOSE, nil
- result = ASSIGNMENT_NODE_TYPES.include?(Ripper.sexp(line)&.dig(1,-1,0))
- $VERBOSE = verbose
- result
- end
-
ATTR_TTY = "\e[%sm"
def ATTR_TTY.[](*a) self % a.join(";"); end
ATTR_PLAIN = ""
@@ -841,69 +708,11 @@ module IRB
end
class Binding
- # Opens an IRB session where +binding.irb+ is called which allows for
- # interactive debugging. You can call any methods or variables available in
- # the current scope, and mutate state if you need to.
- #
- #
- # Given a Ruby file called +potato.rb+ containing the following code:
- #
- # class Potato
- # def initialize
- # @cooked = false
- # binding.irb
- # puts "Cooked potato: #{@cooked}"
- # end
- # end
- #
- # Potato.new
- #
- # Running <code>ruby potato.rb</code> will open an IRB session where
- # +binding.irb+ is called, and you will see the following:
- #
- # $ ruby potato.rb
- #
- # From: potato.rb @ line 4 :
- #
- # 1: class Potato
- # 2: def initialize
- # 3: @cooked = false
- # => 4: binding.irb
- # 5: puts "Cooked potato: #{@cooked}"
- # 6: end
- # 7: end
- # 8:
- # 9: Potato.new
- #
- # irb(#<Potato:0x00007feea1916670>):001:0>
- #
- # You can type any valid Ruby code and it will be evaluated in the current
- # context. This allows you to debug without having to run your code repeatedly:
- #
- # irb(#<Potato:0x00007feea1916670>):001:0> @cooked
- # => false
- # irb(#<Potato:0x00007feea1916670>):002:0> self.class
- # => Potato
- # irb(#<Potato:0x00007feea1916670>):003:0> caller.first
- # => ".../2.5.1/lib/ruby/2.5.0/irb/workspace.rb:85:in `eval'"
- # irb(#<Potato:0x00007feea1916670>):004:0> @cooked = true
- # => true
- #
- # You can exit the IRB session with the +exit+ command. Note that exiting will
- # resume execution where +binding.irb+ had paused it, as you can see from the
- # output printed to standard output in this example:
- #
- # irb(#<Potato:0x00007feea1916670>):005:0> exit
- # Cooked potato: true
- #
- #
- # See IRB@IRB+Usage for more information.
+ # :nodoc:
def irb
- IRB.setup(source_location[0], argv: [])
+ IRB.setup(eval("__FILE__"), argv: [])
workspace = IRB::WorkSpace.new(self)
STDOUT.print(workspace.code_around_binding)
- binding_irb = IRB::Irb.new(workspace)
- binding_irb.context.irb_path = File.expand_path(source_location[0])
- binding_irb.run(IRB.conf)
+ IRB::Irb.new(workspace).run(IRB.conf)
end
end
diff --git a/lib/irb/.document b/lib/irb/.document
deleted file mode 100644
index 3b0d6fa4ed..0000000000
--- a/lib/irb/.document
+++ /dev/null
@@ -1 +0,0 @@
-**/*.rb
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/cmd/chws.rb
index e9f257791c..e93c976f82 100644
--- a/lib/irb/cmd/chws.rb
+++ b/lib/irb/cmd/chws.rb
@@ -10,8 +10,8 @@
#
#
-require_relative "nop"
-require_relative "../ext/change-ws"
+require "irb/cmd/nop.rb"
+require "irb/ext/change-ws.rb"
# :stopdoc:
module IRB
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
index 19c78fc910..ae4d51b5d1 100644
--- a/lib/irb/cmd/fork.rb
+++ b/lib/irb/cmd/fork.rb
@@ -21,7 +21,7 @@ module IRB
class << self
alias_method :exit, ExtendCommand.irb_original_method_name('exit')
end
- if block_given?
+ if iterator?
begin
yield
ensure
@@ -35,3 +35,5 @@ module IRB
end
end
# :startdoc:
+
+
diff --git a/lib/irb/cmd/help.rb b/lib/irb/cmd/help.rb
index 0629479e92..db2bd567e5 100644
--- a/lib/irb/cmd/help.rb
+++ b/lib/irb/cmd/help.rb
@@ -9,18 +9,17 @@
#
#
-require_relative "nop"
+require 'rdoc/ri/driver'
+
+require "irb/cmd/nop.rb"
# :stopdoc:
module IRB
module ExtendCommand
class Help < Nop
- def execute(*names)
- require 'rdoc/ri/driver'
- IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new)
- rescue LoadError, SystemExit
- IRB::ExtendCommand::Help.remove_method(:execute)
- # raise NoMethodError in ensure
+ begin
+ Ri = RDoc::RI::Driver.new
+ rescue SystemExit
else
def execute(*names)
if names.empty?
@@ -36,9 +35,6 @@ module IRB
end
nil
end
- nil
- ensure
- execute(*names)
end
end
end
diff --git a/lib/irb/cmd/info.rb b/lib/irb/cmd/info.rb
deleted file mode 100644
index 53ec71d754..0000000000
--- a/lib/irb/cmd/info.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "nop"
-
-# :stopdoc:
-module IRB
- module ExtendCommand
- class Info < Nop
- def execute
- Class.new {
- def inspect
- str = "Ruby version: #{RUBY_VERSION}\n"
- str += "IRB version: #{IRB.version}\n"
- str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
- str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
- str
- end
- alias_method :to_s, :inspect
- }.new
- end
- end
- end
-end
-# :startdoc:
diff --git a/lib/irb/cmd/load.rb b/lib/irb/cmd/load.rb
index b6769a4124..f800b741eb 100644
--- a/lib/irb/cmd/load.rb
+++ b/lib/irb/cmd/load.rb
@@ -10,8 +10,8 @@
#
#
-require_relative "nop"
-require_relative "../ext/loader"
+require "irb/cmd/nop.rb"
+require "irb/ext/loader"
# :stopdoc:
module IRB
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/cmd/pushws.rb
index 612157d8a0..ffe55abed6 100644
--- a/lib/irb/cmd/pushws.rb
+++ b/lib/irb/cmd/pushws.rb
@@ -10,8 +10,8 @@
#
#
-require_relative "nop"
-require_relative "../ext/workspaces"
+require "irb/cmd/nop.rb"
+require "irb/ext/workspaces.rb"
# :stopdoc:
module IRB
@@ -38,3 +38,4 @@ module IRB
end
end
# :startdoc:
+
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/cmd/subirb.rb
index 1e18607d1a..c1602f6e45 100644
--- a/lib/irb/cmd/subirb.rb
+++ b/lib/irb/cmd/subirb.rb
@@ -9,8 +9,8 @@
#
#
-require_relative "nop"
-require_relative "../ext/multi-irb"
+require "irb/cmd/nop.rb"
+require "irb/ext/multi-irb"
# :stopdoc:
module IRB
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
deleted file mode 100644
index 0f49291d85..0000000000
--- a/lib/irb/color.rb
+++ /dev/null
@@ -1,235 +0,0 @@
-# frozen_string_literal: true
-require 'reline'
-require 'ripper'
-require 'irb/ruby-lex'
-
-module IRB # :nodoc:
- module Color
- CLEAR = 0
- BOLD = 1
- UNDERLINE = 4
- REVERSE = 7
- RED = 31
- GREEN = 32
- YELLOW = 33
- BLUE = 34
- MAGENTA = 35
- CYAN = 36
-
- TOKEN_KEYWORDS = {
- on_kw: ['nil', 'self', 'true', 'false', '__FILE__', '__LINE__'],
- on_const: ['ENV'],
- }
- private_constant :TOKEN_KEYWORDS
-
- # A constant of all-bit 1 to match any Ripper's state in #dispatch_seq
- ALL = -1
- private_constant :ALL
-
- begin
- # Following pry's colors where possible, but sometimes having a compromise like making
- # backtick and regexp as red (string's color, because they're sharing tokens).
- TOKEN_SEQ_EXPRS = {
- on_CHAR: [[BLUE, BOLD], ALL],
- on_backtick: [[RED, BOLD], ALL],
- on_comment: [[BLUE, BOLD], ALL],
- on_const: [[BLUE, BOLD, UNDERLINE], ALL],
- on_embexpr_beg: [[RED], ALL],
- on_embexpr_end: [[RED], ALL],
- on_embvar: [[RED], ALL],
- on_float: [[MAGENTA, BOLD], ALL],
- on_gvar: [[GREEN, BOLD], ALL],
- on_heredoc_beg: [[RED], ALL],
- on_heredoc_end: [[RED], ALL],
- on_ident: [[BLUE, BOLD], Ripper::EXPR_ENDFN],
- on_imaginary: [[BLUE, BOLD], ALL],
- on_int: [[BLUE, BOLD], ALL],
- on_kw: [[GREEN], ALL],
- on_label: [[MAGENTA], ALL],
- on_label_end: [[RED, BOLD], ALL],
- on_qsymbols_beg: [[RED, BOLD], ALL],
- on_qwords_beg: [[RED, BOLD], ALL],
- on_rational: [[BLUE, BOLD], ALL],
- on_regexp_beg: [[RED, BOLD], ALL],
- on_regexp_end: [[RED, BOLD], ALL],
- on_symbeg: [[YELLOW], ALL],
- on_symbols_beg: [[RED, BOLD], ALL],
- on_tstring_beg: [[RED, BOLD], ALL],
- on_tstring_content: [[RED], ALL],
- on_tstring_end: [[RED, BOLD], ALL],
- on_words_beg: [[RED, BOLD], ALL],
- on_parse_error: [[RED, REVERSE], ALL],
- compile_error: [[RED, REVERSE], ALL],
- }
- rescue NameError
- # Give up highlighting Ripper-incompatible older Ruby
- TOKEN_SEQ_EXPRS = {}
- end
- private_constant :TOKEN_SEQ_EXPRS
-
- class << self
- def colorable?
- $stdout.tty? && supported? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
- end
-
- def inspect_colorable?(obj, seen: {}.compare_by_identity)
- case obj
- when String, Symbol, Regexp, Integer, Float, FalseClass, TrueClass, NilClass
- true
- when Hash
- without_circular_ref(obj, seen: seen) do
- obj.all? { |k, v| inspect_colorable?(k, seen: seen) && inspect_colorable?(v, seen: seen) }
- end
- when Array
- without_circular_ref(obj, seen: seen) do
- obj.all? { |o| inspect_colorable?(o, seen: seen) }
- end
- when Range
- inspect_colorable?(obj.begin, seen: seen) && inspect_colorable?(obj.end, seen: seen)
- when Module
- !obj.name.nil?
- else
- false
- end
- end
-
- def clear
- return '' unless colorable?
- "\e[#{CLEAR}m"
- end
-
- def colorize(text, seq)
- return text unless colorable?
- seq = seq.map { |s| "\e[#{const_get(s)}m" }.join('')
- "#{seq}#{text}#{clear}"
- end
-
- # If `complete` is false (code is incomplete), this does not warn compile_error.
- # This option is needed to avoid warning a user when the compile_error is happening
- # because the input is not wrong but just incomplete.
- def colorize_code(code, complete: true)
- return code unless colorable?
-
- symbol_state = SymbolState.new
- colored = +''
- length = 0
-
- scan(code, allow_last_error: !complete) do |token, str, expr|
- in_symbol = symbol_state.scan_token(token)
- str.each_line do |line|
- line = Reline::Unicode.escape_for_print(line)
- if seq = dispatch_seq(token, expr, line, in_symbol: in_symbol)
- colored << seq.map { |s| "\e[#{s}m" }.join('')
- colored << line.sub(/\Z/, clear)
- else
- colored << line
- end
- end
- length += str.bytesize
- end
-
- # give up colorizing incomplete Ripper tokens
- if length != code.bytesize
- return Reline::Unicode.escape_for_print(code)
- end
-
- colored
- end
-
- private
-
- def without_circular_ref(obj, seen:, &block)
- return false if seen.key?(obj)
- seen[obj] = true
- block.call
- ensure
- seen.delete(obj)
- end
-
- def supported?
- return @supported if defined?(@supported)
- @supported = Ripper::Lexer::Elem.method_defined?(:state)
- end
-
- def scan(code, allow_last_error:)
- pos = [1, 0]
-
- verbose, $VERBOSE = $VERBOSE, nil
- RubyLex.compile_with_errors_suppressed(code) do |inner_code, line_no|
- lexer = Ripper::Lexer.new(inner_code, '(ripper)', line_no)
- if lexer.respond_to?(:scan) # Ruby 2.7+
- lexer.scan.each do |elem|
- str = elem.tok
- next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
- next if ([elem.pos[0], elem.pos[1] + str.bytesize] <=> pos) <= 0
-
- str.each_line do |line|
- if line.end_with?("\n")
- pos[0] += 1
- pos[1] = 0
- else
- pos[1] += line.bytesize
- end
- end
-
- yield(elem.event, str, elem.state)
- end
- else
- lexer.parse.each do |elem|
- yield(elem.event, elem.tok, elem.state)
- end
- end
- end
- $VERBOSE = verbose
- end
-
- def dispatch_seq(token, expr, str, in_symbol:)
- if token == :on_parse_error or token == :compile_error
- TOKEN_SEQ_EXPRS[token][0]
- elsif in_symbol
- [YELLOW]
- elsif TOKEN_KEYWORDS.fetch(token, []).include?(str)
- [CYAN, BOLD]
- elsif (seq, exprs = TOKEN_SEQ_EXPRS[token]; (expr & (exprs || 0)) != 0)
- seq
- else
- nil
- end
- end
- end
-
- # A class to manage a state to know whether the current token is for Symbol or not.
- class SymbolState
- def initialize
- # Push `true` to detect Symbol. `false` to increase the nest level for non-Symbol.
- @stack = []
- end
-
- # Return true if the token is a part of Symbol.
- def scan_token(token)
- prev_state = @stack.last
- case token
- when :on_symbeg, :on_symbols_beg, :on_qsymbols_beg
- @stack << true
- when :on_ident, :on_op, :on_const, :on_ivar, :on_cvar, :on_gvar, :on_kw
- if @stack.last # Pop only when it's Symbol
- @stack.pop
- return prev_state
- end
- when :on_tstring_beg
- @stack << false
- when :on_embexpr_beg
- @stack << false
- return prev_state
- when :on_tstring_end # :on_tstring_end may close Symbol
- @stack.pop
- return prev_state
- when :on_embexpr_end
- @stack.pop
- end
- @stack.last
- end
- end
- private_constant :SymbolState
- end
-end
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index c9328e5c5a..e7499a8e2b 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: false
#
-# irb/completion.rb -
+# irb/completor.rb -
# $Release Version: 0.9$
# $Revision$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
# From Original Idea of shugo@ruby-lang.org
#
-autoload :RDoc, "rdoc"
+require "readline"
module IRB
module InputCompletor # :nodoc:
@@ -16,12 +16,11 @@ module IRB
# Set of reserved words used by Ruby, you should not use these for
# constants or variables
ReservedWords = %w[
- __ENCODING__ __LINE__ __FILE__
BEGIN END
alias and
begin break
case class
- def defined? do
+ def defined do
else elsif end ensure
false for
if in
@@ -36,13 +35,9 @@ module IRB
yield
]
- BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
-
CompletionProc = proc { |input|
- retrieve_completion_data(input).compact.map{ |i| i.encode(Encoding.default_external) }
- }
+ bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
- def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false)
case input
when /^((["'`]).*\2)\.([^.]*)$/
# String
@@ -50,11 +45,7 @@ module IRB
message = Regexp.quote($3)
candidates = String.instance_methods.collect{|m| m.to_s}
- if doc_namespace
- "String.#{message}"
- else
- select_message(receiver, message, candidates)
- end
+ select_message(receiver, message, candidates)
when /^(\/[^\/]*\/)\.([^.]*)$/
# Regexp
@@ -62,11 +53,7 @@ module IRB
message = Regexp.quote($2)
candidates = Regexp.instance_methods.collect{|m| m.to_s}
- if doc_namespace
- "Regexp.#{message}"
- else
- select_message(receiver, message, candidates)
- end
+ select_message(receiver, message, candidates)
when /^([^\]]*\])\.([^.]*)$/
# Array
@@ -74,45 +61,32 @@ module IRB
message = Regexp.quote($2)
candidates = Array.instance_methods.collect{|m| m.to_s}
- if doc_namespace
- "Array.#{message}"
- else
- select_message(receiver, message, candidates)
- end
+ select_message(receiver, message, candidates)
when /^([^\}]*\})\.([^.]*)$/
# Proc or Hash
receiver = $1
message = Regexp.quote($2)
- proc_candidates = Proc.instance_methods.collect{|m| m.to_s}
- hash_candidates = Hash.instance_methods.collect{|m| m.to_s}
- if doc_namespace
- ["Proc.#{message}", "Hash.#{message}"]
- else
- select_message(receiver, message, proc_candidates | hash_candidates)
- end
+ candidates = Proc.instance_methods.collect{|m| m.to_s}
+ candidates |= Hash.instance_methods.collect{|m| m.to_s}
+ select_message(receiver, message, candidates)
when /^(:[^:.]*)$/
# Symbol
- return nil if doc_namespace
- sym = $1
- candidates = Symbol.all_symbols.collect do |s|
- ":" + s.id2name.encode(Encoding.default_external)
- rescue Encoding::UndefinedConversionError
- # ignore
+ if Symbol.respond_to?(:all_symbols)
+ sym = $1
+ candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
+ candidates.grep(/^#{Regexp.quote(sym)}/)
+ else
+ []
end
- candidates.grep(/^#{Regexp.quote(sym)}/)
when /^::([A-Z][^:\.\(]*)$/
# Absolute Constant or class methods
receiver = $1
candidates = Object.constants.collect{|m| m.to_s}
- if doc_namespace
- candidates.find { |i| i == receiver }
- else
- candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
- end
+ candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
when /^([A-Z].*)::([^:.]*)$/
# Constant or class methods
@@ -124,11 +98,7 @@ module IRB
rescue Exception
candidates = []
end
- if doc_namespace
- "#{receiver}::#{message}"
- else
- select_message(receiver, message, candidates, "::")
- end
+ select_message(receiver, message, candidates, "::")
when /^(:[^:.]+)(\.|::)([^.]*)$/
# Symbol
@@ -137,33 +107,20 @@ module IRB
message = Regexp.quote($3)
candidates = Symbol.instance_methods.collect{|m| m.to_s}
- if doc_namespace
- "Symbol.#{message}"
- else
- select_message(receiver, message, candidates, sep)
- end
+ select_message(receiver, message, candidates, sep)
- when /^(?<num>-?(?:0[dbo])?[0-9_]+(?:\.[0-9_]+)?(?:(?:[eE][+-]?[0-9]+)?i?|r)?)(?<sep>\.|::)(?<mes>[^.]*)$/
+ when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)(\.|::)([^.]*)$/
# Numeric
- receiver = $~[:num]
- sep = $~[:sep]
- message = Regexp.quote($~[:mes])
+ receiver = $1
+ sep = $5
+ message = Regexp.quote($6)
begin
- instance = eval(receiver, bind)
- if doc_namespace
- "#{instance.class.name}.#{message}"
- else
- candidates = instance.methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates, sep)
- end
+ candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
rescue Exception
- if doc_namespace
- nil
- else
- candidates = []
- end
+ candidates = []
end
+ select_message(receiver, message, candidates, sep)
when /^(-?0x[0-9a-fA-F_]+)(\.|::)([^.]*)$/
# Numeric(0xFFFF)
@@ -172,30 +129,16 @@ module IRB
message = Regexp.quote($3)
begin
- instance = eval(receiver, bind)
- if doc_namespace
- "#{instance.class.name}.#{message}"
- else
- candidates = instance.methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates, sep)
- end
+ candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
rescue Exception
- if doc_namespace
- nil
- else
- candidates = []
- end
+ candidates = []
end
+ select_message(receiver, message, candidates, sep)
when /^(\$[^.]*)$/
# global var
- gvar = $1
- all_gvars = global_variables.collect{|m| m.to_s}
- if doc_namespace
- all_gvars.find{ |i| i == gvar }
- else
- all_gvars.grep(Regexp.new(Regexp.quote(gvar)))
- end
+ regmessage = Regexp.new(Regexp.quote($1))
+ candidates = global_variables.collect{|m| m.to_s}.grep(regmessage)
when /^([^."].*)(\.|::)([^.]*)$/
# variable.func or func.func
@@ -203,7 +146,7 @@ module IRB
sep = $2
message = Regexp.quote($3)
- gv = eval("global_variables", bind).collect{|m| m.to_s}.push("true", "false", "nil")
+ gv = eval("global_variables", bind).collect{|m| m.to_s}
lv = eval("local_variables", bind).collect{|m| m.to_s}
iv = eval("instance_variables", bind).collect{|m| m.to_s}
cv = eval("self.class.constants", bind).collect{|m| m.to_s}
@@ -226,19 +169,24 @@ module IRB
else
# func1.func2
candidates = []
- to_ignore = ignored_modules
ObjectSpace.each_object(Module){|m|
- next if (to_ignore.include?(m) rescue true)
+ begin
+ name = m.name
+ rescue Exception
+ name = ""
+ end
+ begin
+ next if name != "IRB::Context" and
+ /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
+ rescue Exception
+ next
+ end
candidates.concat m.instance_methods(false).collect{|x| x.to_s}
}
candidates.sort!
candidates.uniq!
end
- if doc_namespace
- "#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}"
- else
- select_message(receiver, message, candidates, sep)
- end
+ select_message(receiver, message, candidates, sep)
when /^\.([^.]*)$/
# unknown(maybe String)
@@ -247,46 +195,12 @@ module IRB
message = Regexp.quote($1)
candidates = String.instance_methods(true).collect{|m| m.to_s}
- if doc_namespace
- "String.#{candidates.find{ |i| i == message }}"
- else
- select_message(receiver, message, candidates)
- end
+ select_message(receiver, message, candidates)
else
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
- candidates |= ReservedWords
-
- if doc_namespace
- candidates.find{ |i| i == input }
- else
- candidates.grep(/^#{Regexp.quote(input)}/)
- end
- end
- end
- PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
- RDocRIDriver ||= RDoc::RI::Driver.new
- if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
- IRB.send(:easter_egg)
- return
- end
- namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
- return unless namespace
- if namespace.is_a?(Array)
- out = RDoc::Markup::Document.new
- namespace.each do |m|
- begin
- RDocRIDriver.add_method(out, m)
- rescue RDoc::RI::Driver::NotFoundError
- end
- end
- RDocRIDriver.display(out)
- else
- begin
- RDocRIDriver.display_names([namespace])
- rescue RDoc::RI::Driver::NotFoundError
- end
+ (candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
end
}
@@ -304,30 +218,11 @@ module IRB
end
end
end
-
- def self.ignored_modules
- # We could cache the result, but this is very fast already.
- # By using this approach, we avoid Module#name calls, which are
- # relatively slow when there are a lot of anonymous modules defined.
- s = {}
-
- scanner = lambda do |m|
- next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
- s[m] = true
- m.constants(false).each do |c|
- value = m.const_get(c)
- scanner.call(value) if value.is_a?(Module)
- end
- end
-
- %i(IRB RubyLex).each do |sym|
- next unless Object.const_defined?(sym)
- scanner.call(Object.const_get(sym))
- end
-
- s.delete(IRB::Context) if defined?(IRB::Context)
-
- s
- end
end
end
+
+if Readline.respond_to?("basic_word_break_characters=")
+ Readline.basic_word_break_characters= " \t\n`><=;|&{("
+end
+Readline.completion_append_character = nil
+Readline.completion_proc = IRB::InputCompletor::CompletionProc
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index 4f001729e1..9ccdf744fb 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -9,10 +9,9 @@
#
#
#
-require_relative "workspace"
-require_relative "inspector"
-require_relative "input-method"
-require_relative "output-method"
+require "irb/workspace"
+require "irb/inspector"
+require "irb/output-method"
module IRB
# A class that wraps the current state of the irb session, including the
@@ -22,10 +21,10 @@ module IRB
#
# The optional +input_method+ argument:
#
- # +nil+:: uses stdin or Reidline or Readline
+ # +nil+:: uses stdin or Readline
# +String+:: uses a File
# +other+:: uses this as InputMethod
- def initialize(irb, workspace = nil, input_method = nil)
+ def initialize(irb, workspace = nil, input_method = nil, output_method = nil)
@irb = irb
if workspace
@workspace = workspace
@@ -39,21 +38,7 @@ module IRB
@rc = IRB.conf[:RC]
@load_modules = IRB.conf[:LOAD_MODULES]
- if IRB.conf.has_key?(:USE_SINGLELINE)
- @use_singleline = IRB.conf[:USE_SINGLELINE]
- elsif IRB.conf.has_key?(:USE_READLINE) # backward compatibility
- @use_singleline = IRB.conf[:USE_READLINE]
- else
- @use_singleline = nil
- end
- if IRB.conf.has_key?(:USE_MULTILINE)
- @use_multiline = IRB.conf[:USE_MULTILINE]
- elsif IRB.conf.has_key?(:USE_REIDLINE) # backward compatibility
- @use_multiline = IRB.conf[:USE_REIDLINE]
- else
- @use_multiline = nil
- end
- @use_colorize = IRB.conf[:USE_COLORIZE]
+ @use_readline = IRB.conf[:USE_READLINE]
@verbose = IRB.conf[:VERBOSE]
@io = nil
@@ -78,42 +63,23 @@ module IRB
case input_method
when nil
- @io = nil
- case use_multiline?
+ case use_readline?
when nil
- if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
- # Both of multiline mode and singleline mode aren't specified.
- @io = ReidlineInputMethod.new
+ if (defined?(ReadlineInputMethod) && STDIN.tty? &&
+ IRB.conf[:PROMPT_MODE] != :INF_RUBY)
+ @io = ReadlineInputMethod.new
else
- @io = nil
+ @io = StdioInputMethod.new
end
when false
- @io = nil
+ @io = StdioInputMethod.new
when true
- @io = ReidlineInputMethod.new
- end
- unless @io
- case use_singleline?
- when nil
- if (defined?(ReadlineInputMethod) && STDIN.tty? &&
- IRB.conf[:PROMPT_MODE] != :INF_RUBY)
- @io = ReadlineInputMethod.new
- else
- @io = nil
- end
- when false
- @io = nil
- when true
- if defined?(ReadlineInputMethod)
- @io = ReadlineInputMethod.new
- else
- @io = nil
- end
+ if defined?(ReadlineInputMethod)
+ @io = ReadlineInputMethod.new
else
- @io = nil
+ @io = StdioInputMethod.new
end
end
- @io = StdioInputMethod.new unless @io
when String
@io = FileInputMethod.new(input_method)
@@ -124,25 +90,17 @@ module IRB
end
self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
+ if output_method
+ @output_method = output_method
+ else
+ @output_method = StdioOutputMethod.new
+ end
+
@echo = IRB.conf[:ECHO]
if @echo.nil?
@echo = true
end
-
- @echo_on_assignment = IRB.conf[:ECHO_ON_ASSIGNMENT]
- if @echo_on_assignment.nil?
- @echo_on_assignment = true
- end
-
- @omit_on_assignment = IRB.conf[:OMIT_ON_ASSIGNMENT]
- if @omit_on_assignment.nil?
- @omit_on_assignment = true
- end
-
- @newline_before_multiline_output = IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]
- if @newline_before_multiline_output.nil?
- @newline_before_multiline_output = true
- end
+ self.debug_level = IRB.conf[:DEBUG_LEVEL]
end
# The top-level workspace, see WorkSpace#main
@@ -158,9 +116,9 @@ module IRB
attr_reader :thread
# The current input method
#
- # Can be either StdioInputMethod, ReadlineInputMethod,
- # ReidlineInputMethod, FileInputMethod or other specified when the
- # context is created. See ::new for more # information on +input_method+.
+ # Can be either StdioInputMethod, ReadlineInputMethod, FileInputMethod or
+ # other specified when the context is created. See ::new for more
+ # information on +input_method+.
attr_accessor :io
# Current irb session
@@ -178,18 +136,12 @@ module IRB
# +input_method+ passed to Context.new
attr_accessor :irb_path
- # Whether multiline editor mode is enabled or not.
+ # Whether +Readline+ is enabled or not.
#
- # A copy of the default <code>IRB.conf[:USE_MULTILINE]</code>
- attr_reader :use_multiline
- # Whether singleline editor mode is enabled or not.
+ # A copy of the default <code>IRB.conf[:USE_READLINE]</code>
#
- # A copy of the default <code>IRB.conf[:USE_SINGLELINE]</code>
- attr_reader :use_singleline
- # Whether colorization is enabled or not.
- #
- # A copy of the default <code>IRB.conf[:USE_COLORIZE]</code>
- attr_reader :use_colorize
+ # See #use_readline= for more information.
+ attr_reader :use_readline
# A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
attr_reader :inspect_mode
@@ -212,17 +164,17 @@ module IRB
# Can be either the default <code>IRB.conf[:AUTO_INDENT]</code>, or the
# mode set by #prompt_mode=
#
- # To disable auto-indentation in irb:
+ # To enable auto-indentation in irb:
#
- # IRB.conf[:AUTO_INDENT] = false
+ # IRB.conf[:AUTO_INDENT] = true
#
# or
#
- # irb_context.auto_indent_mode = false
+ # irb_context.auto_indent_mode = true
#
# or
#
- # IRB.CurrentContext.auto_indent_mode = false
+ # IRB.CurrentContext.auto_indent_mode = true
#
# See IRB@Configuration for more information.
attr_accessor :auto_indent_mode
@@ -245,7 +197,7 @@ module IRB
attr_accessor :ignore_eof
# Whether to echo the return value to output or not.
#
- # Uses <code>IRB.conf[:ECHO]</code> if available, or defaults to +true+.
+ # Uses IRB.conf[:ECHO] if available, or defaults to +true+.
#
# puts "hello"
# # hello
@@ -254,47 +206,14 @@ module IRB
# puts "omg"
# # omg
attr_accessor :echo
- # Whether to echo for assignment expressions
- #
- # Uses <code>IRB.conf[:ECHO_ON_ASSIGNMENT]</code> if available, or defaults to +true+.
- #
- # a = "omg"
- # #=> omg
- # IRB.CurrentContext.echo_on_assignment = false
- # a = "omg"
- attr_accessor :echo_on_assignment
- # Whether to omit echo for assignment expressions
- #
- # Uses <code>IRB.conf[:OMIT_ON_ASSIGNMENT]</code> if available, or defaults to +true+.
- #
- # a = [1] * 10
- # #=> [1, 1, 1, 1, 1, 1, 1, 1, ...
- # [1] * 10
- # #=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
- # IRB.CurrentContext.omit_on_assignment = false
- # a = [1] * 10
- # #=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
- # [1] * 10
- # #=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
- attr_accessor :omit_on_assignment
- # Whether a newline is put before multiline output.
- #
- # Uses <code>IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]</code> if available,
- # or defaults to +true+.
- #
- # "abc\ndef"
- # #=>
- # abc
- # def
- # IRB.CurrentContext.newline_before_multiline_output = false
- # "abc\ndef"
- # #=> abc
- # def
- attr_accessor :newline_before_multiline_output
# Whether verbose messages are displayed or not.
#
# A copy of the default <code>IRB.conf[:VERBOSE]</code>
attr_accessor :verbose
+ # The debug level of irb
+ #
+ # See #debug_level= for more information.
+ attr_reader :debug_level
# The limit of backtrace lines displayed as top +n+ and tail +n+.
#
@@ -305,35 +224,18 @@ module IRB
# See IRB@Command+line+options for more command line options.
attr_accessor :back_trace_limit
- # Alias for #use_multiline
- alias use_multiline? use_multiline
- # Alias for #use_singleline
- alias use_singleline? use_singleline
- # backward compatibility
- alias use_reidline use_multiline
- # backward compatibility
- alias use_reidline? use_multiline
- # backward compatibility
- alias use_readline use_singleline
- # backward compatibility
- alias use_readline? use_singleline
- # Alias for #use_colorize
- alias use_colorize? use_colorize
+ # Alias for #use_readline
+ alias use_readline? use_readline
# Alias for #rc
alias rc? rc
alias ignore_sigint? ignore_sigint
alias ignore_eof? ignore_eof
alias echo? echo
- alias echo_on_assignment? echo_on_assignment
- alias omit_on_assignment? omit_on_assignment
- alias newline_before_multiline_output? newline_before_multiline_output
# Returns whether messages are displayed or not.
def verbose?
if @verbose.nil?
- if @io.kind_of?(ReidlineInputMethod)
- false
- elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
+ if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
false
elsif !STDIN.tty? or @io.kind_of?(FileInputMethod)
true
@@ -346,11 +248,9 @@ module IRB
end
# Whether #verbose? is +true+, and +input_method+ is either
- # StdioInputMethod or ReidlineInputMethod or ReadlineInputMethod, see #io
- # for more information.
+ # StdioInputMethod or ReadlineInputMethod, see #io for more information.
def prompting?
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
- @io.kind_of?(ReidlineInputMethod) ||
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
end
@@ -361,7 +261,7 @@ module IRB
# to #last_value.
def set_last_value(value)
@last_value = value
- @workspace.local_variable_set :_, value
+ @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
end
# Sets the +mode+ of the prompt in this context.
@@ -449,13 +349,34 @@ module IRB
@inspect_mode
end
- def evaluate(line, line_no, exception: nil) # :nodoc:
+ # Obsolete method.
+ #
+ # Can be set using the +--noreadline+ and +--readline+ command line
+ # options.
+ #
+ # See IRB@Command+line+options for more command line options.
+ def use_readline=(opt)
+ print "This method is obsolete."
+ print "Do nothing."
+ end
+
+ # Sets the debug level of irb
+ #
+ # Can also be set using the +--irb_debug+ command line option.
+ #
+ # See IRB@Command+line+options for more command line options.
+ def debug_level=(value)
+ @debug_level = value
+ RubyLex.debug_level = value
+ end
+
+ # Whether or not debug mode is enabled, see #debug_level=.
+ def debug?
+ @debug_level > 0
+ end
+
+ def evaluate(line, line_no) # :nodoc:
@line_no = line_no
- if exception
- line_no -= 1
- line = "begin ::Kernel.raise _; rescue _.class\n#{line}\n""end"
- @workspace.local_variable_set(:_, exception)
- end
set_last_value(@workspace.evaluate(self, line, irb_path, line_no))
end
diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb
deleted file mode 100644
index 64869d85fa..0000000000
--- a/lib/irb/easter-egg.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-require "reline"
-
-module IRB
- class << self
- class Vec
- def initialize(x, y, z)
- @x, @y, @z = x, y, z
- end
-
- attr_reader :x, :y, :z
-
- def sub(other)
- Vec.new(@x - other.x, @y - other.y, @z - other.z)
- end
-
- def dot(other)
- @x*other.x + @y*other.y + @z*other.z
- end
-
- def cross(other)
- ox, oy, oz = other.x, other.y, other.z
- Vec.new(@y*oz-@z*oy, @z*ox-@x*oz, @x*oy-@y*ox)
- end
-
- def normalize
- r = Math.sqrt(self.dot(self))
- Vec.new(@x / r, @y / r, @z / r)
- end
- end
-
- class Canvas
- def initialize((h, w))
- @data = (0..h-2).map { [0] * w }
- @scale = [w / 2.0, h-2].min
- @center = Complex(w / 2, h-2)
- end
-
- def line((x1, y1), (x2, y2))
- p1 = Complex(x1, y1) / 2 * @scale + @center
- p2 = Complex(x2, y2) / 2 * @scale + @center
- line0(p1, p2)
- end
-
- private def line0(p1, p2)
- mid = (p1 + p2) / 2
- if (p1 - p2).abs < 1
- x, y = mid.rect
- @data[y / 2][x] |= (y % 2 > 1 ? 2 : 1)
- else
- line0(p1, mid)
- line0(p2, mid)
- end
- end
-
- def draw
- @data.each {|row| row.fill(0) }
- yield
- @data.map {|row| row.map {|n| " ',;"[n] }.join }.join("\n")
- end
- end
-
- class RubyModel
- def initialize
- @faces = init_ruby_model
- end
-
- def init_ruby_model
- cap_vertices = (0..5).map {|i| Vec.new(*Complex.polar(1, i * Math::PI / 3).rect, 1) }
- middle_vertices = (0..5).map {|i| Vec.new(*Complex.polar(2, (i + 0.5) * Math::PI / 3).rect, 0) }
- bottom_vertex = Vec.new(0, 0, -2)
-
- faces = [cap_vertices]
- 6.times do |j|
- i = j-1
- faces << [cap_vertices[i], middle_vertices[i], cap_vertices[j]]
- faces << [cap_vertices[j], middle_vertices[i], middle_vertices[j]]
- faces << [middle_vertices[i], bottom_vertex, middle_vertices[j]]
- end
-
- faces
- end
-
- def render_frame(i)
- angle = i / 10.0
- dir = Vec.new(*Complex.polar(1, angle).rect, Math.sin(angle)).normalize
- dir2 = Vec.new(*Complex.polar(1, angle - Math::PI/2).rect, 0)
- up = dir.cross(dir2)
- nm = dir.cross(up)
- @faces.each do |vertices|
- v0, v1, v2, = vertices
- if v1.sub(v0).cross(v2.sub(v0)).dot(dir) > 0
- points = vertices.map {|p| [nm.dot(p), up.dot(p)] }
- (points + [points[0]]).each_cons(2) do |p1, p2|
- yield p1, p2
- end
- end
- end
- end
- end
-
- private def easter_egg(type = nil)
- type ||= [:logo, :dancing].sample
- case type
- when :logo
- File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
- require "rdoc"
- RDoc::RI::Driver.new.page do |io|
- IO.copy_stream(f, io)
- end
- end
- when :dancing
- begin
- canvas = Canvas.new(Reline.get_screen_size)
- Reline::IOGate.set_winch_handler do
- canvas = Canvas.new(Reline.get_screen_size)
- end
- ruby_model = RubyModel.new
- print "\e[?1049h"
- 0.step do |i| # TODO (0..).each needs Ruby 2.6 or later
- buff = canvas.draw do
- ruby_model.render_frame(i) do |p1, p2|
- canvas.line(p1, p2)
- end
- end
- buff[0, 20] = "\e[0mPress Ctrl+C to stop\e[31m\e[1m"
- print "\e[H" + buff
- sleep 0.05
- end
- ensure
- print "\e[0m\e[?1049l"
- end
- end
- end
- end
-end
-
-IRB.send(:easter_egg, ARGV[0]&.to_sym) if $0 == __FILE__
diff --git a/lib/irb/ext/change-ws.rb b/lib/irb/ext/change-ws.rb
index 4c57e44eab..94bfe62bc0 100644
--- a/lib/irb/ext/change-ws.rb
+++ b/lib/irb/ext/change-ws.rb
@@ -43,3 +43,4 @@ module IRB # :nodoc:
end
end
end
+
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
index fc304c6f6c..62363b13f4 100644
--- a/lib/irb/ext/history.rb
+++ b/lib/irb/ext/history.rb
@@ -22,7 +22,7 @@ module IRB # :nodoc:
def set_last_value(value)
_set_last_value(value)
- if defined?(@eval_history) && @eval_history
+ if @eval_history
@eval_history_values.push @line_no, @last_value
@workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
end
@@ -30,13 +30,9 @@ module IRB # :nodoc:
@last_value
end
- remove_method :eval_history= if method_defined?(:eval_history=)
- # The command result history limit. This method is not available until
- # #eval_history= was called with non-nil value (directly or via
- # setting <code>IRB.conf[:EVAL_HISTORY]</code> in <code>.irbrc</code>).
+ # The command result history limit.
attr_reader :eval_history
- # Sets command result history limit. Default value is set from
- # <code>IRB.conf[:EVAL_HISTORY]</code>.
+ # Sets command result history limit.
#
# +no+ is an Integer or +nil+.
#
@@ -45,9 +41,6 @@ module IRB # :nodoc:
# If +no+ is 0, the number of history items is unlimited.
#
# If +no+ is +nil+, execution result history isn't used (default).
- #
- # History values are available via <code>__</code> variable, see
- # IRB::History.
def eval_history=(no)
if no
if defined?(@eval_history) && @eval_history
@@ -65,51 +58,20 @@ module IRB # :nodoc:
end
end
- # Represents history of results of previously evaluated commands.
- #
- # Available via <code>__</code> variable, only if <code>IRB.conf[:EVAL_HISTORY]</code>
- # or <code>IRB::CurrentContext().eval_history</code> is non-nil integer value
- # (by default it is +nil+).
- #
- # Example (in `irb`):
- #
- # # Initialize history
- # IRB::CurrentContext().eval_history = 10
- # # => 10
- #
- # # Perform some commands...
- # 1 + 2
- # # => 3
- # puts 'x'
- # # x
- # # => nil
- # raise RuntimeError
- # # ...error raised
- #
- # # Inspect history (format is "<item number> <evaluated value>":
- # __
- # # => 1 10
- # # 2 3
- # # 3 nil
- #
- # __[1]
- # # => 10
- #
- class History
-
- def initialize(size = 16) # :nodoc:
+ class History # :nodoc:
+
+ def initialize(size = 16)
@size = size
@contents = []
end
- def size(size) # :nodoc:
+ def size(size)
if size != 0 && size < @size
@contents = @contents[@size - size .. @size]
end
@size = size
end
- # Get one item of the content (both positive and negative indexes work).
def [](idx)
begin
if idx >= 0
@@ -122,14 +84,14 @@ module IRB # :nodoc:
end
end
- def push(no, val) # :nodoc:
+ def push(no, val)
@contents.push [no, val]
@contents.shift if @size != 0 && @contents.size > @size
end
alias real_inspect inspect
- def inspect # :nodoc:
+ def inspect
if @contents.empty?
return real_inspect
end
@@ -153,3 +115,5 @@ module IRB # :nodoc:
end
end
end
+
+
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
index 1b683d88e5..840226db30 100644
--- a/lib/irb/ext/loader.rb
+++ b/lib/irb/ext/loader.rb
@@ -126,3 +126,4 @@ module IRB # :nodoc:
end
end
end
+
diff --git a/lib/irb/ext/multi-irb.rb b/lib/irb/ext/multi-irb.rb
index 74de1ecde5..28d6fba832 100644
--- a/lib/irb/ext/multi-irb.rb
+++ b/lib/irb/ext/multi-irb.rb
@@ -9,7 +9,7 @@
#
#
#
-fail CantShiftToMultiIrbMode unless defined?(Thread)
+IRB.fail CantShiftToMultiIrbMode unless defined?(Thread)
module IRB
class JobManager
@@ -67,8 +67,8 @@ module IRB
# exception is raised.
def switch(key)
th, irb = search(key)
- fail IrbAlreadyDead unless th.alive?
- fail IrbSwitchedToCurrentThread if th == Thread.current
+ IRB.fail IrbAlreadyDead unless th.alive?
+ IRB.fail IrbSwitchedToCurrentThread if th == Thread.current
@current_job = irb
th.run
Thread.stop
@@ -84,7 +84,7 @@ module IRB
def kill(*keys)
for key in keys
th, _ = search(key)
- fail IrbAlreadyDead unless th.alive?
+ IRB.fail IrbAlreadyDead unless th.alive?
th.exit
end
end
@@ -114,7 +114,7 @@ module IRB
else
@jobs.find{|k, v| v.context.main.equal?(key)}
end
- fail NoSuchJob, key if job.nil?
+ IRB.fail NoSuchJob, key if job.nil?
job
end
@@ -122,7 +122,7 @@ module IRB
def delete(key)
case key
when Integer
- fail NoSuchJob, key unless @jobs[key]
+ IRB.fail NoSuchJob, key unless @jobs[key]
@jobs[key] = nil
else
catch(:EXISTS) do
@@ -135,7 +135,7 @@ module IRB
throw :EXISTS
end
end
- fail NoSuchJob, key
+ IRB.fail NoSuchJob, key
end
end
until assoc = @jobs.pop; end unless @jobs.empty?
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
index ac358c8ccb..ab64cf543d 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -9,6 +9,8 @@
#
#
+require "readline"
+
module IRB
module HistorySavingAbility # :nodoc:
end
@@ -25,7 +27,7 @@ module IRB
IRB.conf[:SAVE_HISTORY]
end
- remove_method(:save_history=) if method_defined?(:save_history=)
+ remove_method :save_history= if respond_to?(:save_history=)
# Sets <code>IRB.conf[:SAVE_HISTORY]</code> to the given +val+ and calls
# #init_save_history with this context.
#
@@ -56,6 +58,8 @@ module IRB
end
module HistorySavingAbility # :nodoc:
+ include Readline
+
def HistorySavingAbility.extended(obj)
IRB.conf[:AT_EXIT].push proc{obj.save_history}
obj.load_history
@@ -63,31 +67,19 @@ module IRB
end
def load_history
- return unless self.class.const_defined?(:HISTORY)
- history = self.class::HISTORY
if history_file = IRB.conf[:HISTORY_FILE]
history_file = File.expand_path(history_file)
end
history_file = IRB.rc_file("_history") unless history_file
if File.exist?(history_file)
- open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
- f.each { |l|
- l = l.chomp
- if self.class == ReidlineInputMethod and history.last&.end_with?("\\")
- history.last.delete_suffix!("\\")
- history.last << "\n" << l
- else
- history << l
- end
- }
+ open(history_file) do |f|
+ f.each {|l| HISTORY << l.chomp}
end
end
end
def save_history
- return unless self.class.const_defined?(:HISTORY)
- history = self.class::HISTORY
- if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) != 0
+ if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
if history_file = IRB.conf[:HISTORY_FILE]
history_file = File.expand_path(history_file)
end
@@ -99,20 +91,13 @@ module IRB
File.chmod(0600, history_file)
end
rescue Errno::ENOENT
- rescue Errno::EPERM
- return
rescue
raise
end
- open(history_file, "w:#{IRB.conf[:LC_MESSAGES].encoding}", 0600) do |f|
- hist = history.map{ |l| l.split("\n").join("\\\n") }
- begin
- hist = hist.last(num) if hist.size > num and num > 0
- rescue RangeError # bignum too big to convert into `long'
- # Do nothing because the bignum should be treated as inifinity
- end
- f.puts(hist)
+ open(history_file, 'w', 0600 ) do |f|
+ hist = HISTORY.to_a
+ f.puts(hist[-num..-1] || hist)
end
end
end
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
index 67ac4bb965..200f77e341 100644
--- a/lib/irb/ext/tracer.rb
+++ b/lib/irb/ext/tracer.rb
@@ -9,20 +9,7 @@
#
#
#
-begin
- require "tracer"
-rescue LoadError
- $stderr.puts "Tracer extension of IRB is enabled but tracer gem doesn't found."
- module IRB
- TracerLoadError = true
- class Context
- def use_tracer=(opt)
- # do nothing
- end
- end
- end
- return # This is about to disable loading below
-end
+require "tracer"
module IRB
@@ -82,3 +69,4 @@ module IRB
IRB.initialize_tracer
end
+
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
index 1897bc89e0..571dd25d17 100644
--- a/lib/irb/ext/use-loader.rb
+++ b/lib/irb/ext/use-loader.rb
@@ -10,8 +10,8 @@
#
#
-require_relative "../cmd/load"
-require_relative "loader"
+require "irb/cmd/load"
+require "irb/ext/loader"
class Object
alias __original__load__IRB_use_loader__ load
@@ -20,12 +20,10 @@ end
module IRB
module ExtendCommandBundle
- remove_method :irb_load if method_defined?(:irb_load)
# Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
def irb_load(*opts, &b)
ExtendCommand::Load.execute(irb_context, *opts, &b)
end
- remove_method :irb_require if method_defined?(:irb_require)
# Loads the given file similarly to Kernel#require
def irb_require(*opts, &b)
ExtendCommand::Require.execute(irb_context, *opts, &b)
@@ -46,8 +44,7 @@ module IRB
alias use_loader? use_loader
- remove_method :use_loader= if method_defined?(:use_loader=)
- # Sets <code>IRB.conf[:USE_LOADER]</code>
+ # Sets IRB.conf[:USE_LOADER]
#
# See #use_loader for more information.
def use_loader=(opt)
@@ -73,3 +70,5 @@ module IRB
end
end
end
+
+
diff --git a/lib/irb/ext/workspaces.rb b/lib/irb/ext/workspaces.rb
index 730b58e64d..5bd72c194f 100644
--- a/lib/irb/ext/workspaces.rb
+++ b/lib/irb/ext/workspaces.rb
@@ -64,3 +64,4 @@ module IRB # :nodoc:
end
end
end
+
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 2f4fcfb5c6..064f21ba52 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -32,7 +32,7 @@ module IRB # :nodoc:
# Displays current configuration.
#
- # Modifying the configuration is achieved by sending a message to IRB.conf.
+ # Modifing the configuration is achieved by sending a message to IRB.conf.
def irb_context
IRB.CurrentContext
end
@@ -46,84 +46,58 @@ module IRB # :nodoc:
]
@EXTEND_COMMANDS = [
- [
- :irb_current_working_workspace, :CurrentWorkingWorkspace, "irb/cmd/chws",
- [:irb_print_working_workspace, OVERRIDE_ALL],
- [:irb_cwws, OVERRIDE_ALL],
- [:irb_pwws, OVERRIDE_ALL],
- [:cwws, NO_OVERRIDE],
- [:pwws, NO_OVERRIDE],
- [:irb_current_working_binding, OVERRIDE_ALL],
- [:irb_print_working_binding, OVERRIDE_ALL],
- [:irb_cwb, OVERRIDE_ALL],
- [:irb_pwb, OVERRIDE_ALL],
- ],
- [
- :irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
- [:irb_chws, OVERRIDE_ALL],
- [:irb_cws, OVERRIDE_ALL],
- [:chws, NO_OVERRIDE],
- [:cws, NO_OVERRIDE],
- [:irb_change_binding, OVERRIDE_ALL],
- [:irb_cb, OVERRIDE_ALL],
- [:cb, NO_OVERRIDE],
- ],
+ [:irb_current_working_workspace, :CurrentWorkingWorkspace, "irb/cmd/chws",
+ [:irb_print_working_workspace, OVERRIDE_ALL],
+ [:irb_cwws, OVERRIDE_ALL],
+ [:irb_pwws, OVERRIDE_ALL],
+ [:cwws, NO_OVERRIDE],
+ [:pwws, NO_OVERRIDE],
+ [:irb_current_working_binding, OVERRIDE_ALL],
+ [:irb_print_working_binding, OVERRIDE_ALL],
+ [:irb_cwb, OVERRIDE_ALL],
+ [:irb_pwb, OVERRIDE_ALL],
+ ],
+ [:irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
+ [:irb_chws, OVERRIDE_ALL],
+ [:irb_cws, OVERRIDE_ALL],
+ [:chws, NO_OVERRIDE],
+ [:cws, NO_OVERRIDE],
+ [:irb_change_binding, OVERRIDE_ALL],
+ [:irb_cb, OVERRIDE_ALL],
+ [:cb, NO_OVERRIDE]],
- [
- :irb_workspaces, :Workspaces, "irb/cmd/pushws",
- [:workspaces, NO_OVERRIDE],
- [:irb_bindings, OVERRIDE_ALL],
- [:bindings, NO_OVERRIDE],
- ],
- [
- :irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
- [:irb_pushws, OVERRIDE_ALL],
- [:pushws, NO_OVERRIDE],
- [:irb_push_binding, OVERRIDE_ALL],
- [:irb_pushb, OVERRIDE_ALL],
- [:pushb, NO_OVERRIDE],
- ],
- [
- :irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
- [:irb_popws, OVERRIDE_ALL],
- [:popws, NO_OVERRIDE],
- [:irb_pop_binding, OVERRIDE_ALL],
- [:irb_popb, OVERRIDE_ALL],
- [:popb, NO_OVERRIDE],
- ],
+ [:irb_workspaces, :Workspaces, "irb/cmd/pushws",
+ [:workspaces, NO_OVERRIDE],
+ [:irb_bindings, OVERRIDE_ALL],
+ [:bindings, NO_OVERRIDE]],
+ [:irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
+ [:irb_pushws, OVERRIDE_ALL],
+ [:pushws, NO_OVERRIDE],
+ [:irb_push_binding, OVERRIDE_ALL],
+ [:irb_pushb, OVERRIDE_ALL],
+ [:pushb, NO_OVERRIDE]],
+ [:irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
+ [:irb_popws, OVERRIDE_ALL],
+ [:popws, NO_OVERRIDE],
+ [:irb_pop_binding, OVERRIDE_ALL],
+ [:irb_popb, OVERRIDE_ALL],
+ [:popb, NO_OVERRIDE]],
- [
- :irb_load, :Load, "irb/cmd/load"],
- [
- :irb_require, :Require, "irb/cmd/load"],
- [
- :irb_source, :Source, "irb/cmd/load",
- [:source, NO_OVERRIDE],
- ],
+ [:irb_load, :Load, "irb/cmd/load"],
+ [:irb_require, :Require, "irb/cmd/load"],
+ [:irb_source, :Source, "irb/cmd/load",
+ [:source, NO_OVERRIDE]],
- [
- :irb, :IrbCommand, "irb/cmd/subirb"],
- [
- :irb_jobs, :Jobs, "irb/cmd/subirb",
- [:jobs, NO_OVERRIDE],
- ],
- [
- :irb_fg, :Foreground, "irb/cmd/subirb",
- [:fg, NO_OVERRIDE],
- ],
- [
- :irb_kill, :Kill, "irb/cmd/subirb",
- [:kill, OVERRIDE_PRIVATE_ONLY],
- ],
+ [:irb, :IrbCommand, "irb/cmd/subirb"],
+ [:irb_jobs, :Jobs, "irb/cmd/subirb",
+ [:jobs, NO_OVERRIDE]],
+ [:irb_fg, :Foreground, "irb/cmd/subirb",
+ [:fg, NO_OVERRIDE]],
+ [:irb_kill, :Kill, "irb/cmd/subirb",
+ [:kill, OVERRIDE_PRIVATE_ONLY]],
- [
- :irb_help, :Help, "irb/cmd/help",
- [:help, NO_OVERRIDE],
- ],
-
- [
- :irb_info, :Info, "irb/cmd/info"
- ],
+ [:irb_help, :Help, "irb/cmd/help",
+ [:help, NO_OVERRIDE]],
]
@@ -173,14 +147,11 @@ module IRB # :nodoc:
args << "&block"
args = args.join(", ")
line = __LINE__; eval %[
- unless self.class.class_variable_defined?(:@@#{cmd_name}_)
- self.class.class_variable_set(:@@#{cmd_name}_, true)
- def #{cmd_name}_(\#{args})
- ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
- end
+ def #{cmd_name}(\#{args})
+ ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
end
], nil, __FILE__, line
- send :#{cmd_name}_, *opts, &b
+ send :#{cmd_name}, *opts, &b
end
], nil, __FILE__, line
else
diff --git a/lib/irb/frame.rb b/lib/irb/frame.rb
index de54a98f1b..6073809249 100644
--- a/lib/irb/frame.rb
+++ b/lib/irb/frame.rb
@@ -10,18 +10,13 @@
#
#
+require "e2mmap"
+
module IRB
class Frame
- class FrameOverflow < StandardError
- def initialize
- super("frame overflow")
- end
- end
- class FrameUnderflow < StandardError
- def initialize
- super("frame underflow")
- end
- end
+ extend Exception2MessageMapper
+ def_exception :FrameOverflow, "frame overflow"
+ def_exception :FrameUnderflow, "frame underflow"
# Default number of stack frames
INIT_STACK_TIMES = 3
@@ -49,7 +44,7 @@ module IRB
# Raises FrameUnderflow if there are no frames in the given stack range.
def top(n = 0)
bind = @frames[-(n + CALL_STACK_OFFSET)]
- fail FrameUnderflow unless bind
+ Fail FrameUnderflow unless bind
bind
end
@@ -59,7 +54,7 @@ module IRB
# Raises FrameOverflow if there are no frames in the given stack range.
def bottom(n = 0)
bind = @frames[n]
- fail FrameOverflow unless bind
+ Fail FrameOverflow unless bind
bind
end
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
index 3eeaf841b0..a4264ab4ab 100644
--- a/lib/irb/help.rb
+++ b/lib/irb/help.rb
@@ -10,7 +10,7 @@
#
#
-require_relative 'magic-file'
+require 'irb/magic-file'
module IRB
# Outputs the irb help message, see IRB@Command+line+options.
@@ -34,3 +34,4 @@ module IRB
}
end
end
+
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index 44383609bd..a971b75ac3 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -21,7 +21,7 @@ module IRB # :nodoc:
IRB.load_modules
unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
- fail UndefinedPromptMode, @CONF[:PROMPT_MODE]
+ IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE])
end
end
@@ -43,20 +43,17 @@ module IRB # :nodoc:
@CONF[:LOAD_MODULES] = []
@CONF[:IRB_RC] = nil
- @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
- @CONF[:USE_COLORIZE] = true
+ @CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod)
@CONF[:INSPECT_MODE] = true
@CONF[:USE_TRACER] = false
@CONF[:USE_LOADER] = false
@CONF[:IGNORE_SIGINT] = true
@CONF[:IGNORE_EOF] = false
@CONF[:ECHO] = nil
- @CONF[:ECHO_ON_ASSIGNMENT] = nil
- @CONF[:OMIT_ON_ASSIGNMENT] = nil
@CONF[:VERBOSE] = nil
@CONF[:EVAL_HISTORY] = nil
- @CONF[:SAVE_HISTORY] = 1000
+ @CONF[:SAVE_HISTORY] = nil
@CONF[:BACK_TRACE_LIMIT] = 16
@@ -85,7 +82,7 @@ module IRB # :nodoc:
:SIMPLE => {
:PROMPT_I => ">> ",
:PROMPT_N => ">> ",
- :PROMPT_S => "%l> ",
+ :PROMPT_S => nil,
:PROMPT_C => "?> ",
:RETURN => "=> %s\n"
},
@@ -107,7 +104,7 @@ module IRB # :nodoc:
}
@CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL)
- @CONF[:AUTO_INDENT] = true
+ @CONF[:AUTO_INDENT] = false
@CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING
@CONF[:SINGLE_IRB] = false
@@ -115,6 +112,8 @@ module IRB # :nodoc:
@CONF[:LC_MESSAGES] = Locale.new
@CONF[:AT_EXIT] = []
+
+ @CONF[:DEBUG_LEVEL] = 0
end
def IRB.init_error
@@ -162,34 +161,18 @@ module IRB # :nodoc:
end
when "--noinspect"
@CONF[:INSPECT_MODE] = false
- when "--singleline", "--readline", "--legacy"
- @CONF[:USE_SINGLELINE] = true
- when "--nosingleline", "--noreadline"
- @CONF[:USE_SINGLELINE] = false
- when "--multiline", "--reidline"
- @CONF[:USE_MULTILINE] = true
- when "--nomultiline", "--noreidline"
- @CONF[:USE_MULTILINE] = false
+ when "--readline"
+ @CONF[:USE_READLINE] = true
+ when "--noreadline"
+ @CONF[:USE_READLINE] = false
when "--echo"
@CONF[:ECHO] = true
when "--noecho"
@CONF[:ECHO] = false
- when "--echo-on-assignment"
- @CONF[:ECHO_ON_ASSIGNMENT] = true
- when "--noecho-on-assignment"
- @CONF[:ECHO_ON_ASSIGNMENT] = false
- when "--omit-on-assignment"
- @CONF[:OMIT_ON_ASSIGNMENT] = true
- when "--noomit-on-assignment"
- @CONF[:OMIT_ON_ASSIGNMENT] = false
when "--verbose"
@CONF[:VERBOSE] = true
when "--noverbose"
@CONF[:VERBOSE] = false
- when "--colorize"
- @CONF[:USE_COLORIZE] = true
- when "--nocolorize"
- @CONF[:USE_COLORIZE] = false
when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
opt = $1 || argv.shift
prompt_mode = opt.upcase.tr("-", "_").intern
@@ -208,11 +191,13 @@ module IRB # :nodoc:
@CONF[:CONTEXT_MODE] = ($1 || argv.shift).to_i
when "--single-irb"
@CONF[:SINGLE_IRB] = true
+ when /^--irb_debug(?:=(.+))?/
+ @CONF[:DEBUG_LEVEL] = ($1 || argv.shift).to_i
when "-v", "--version"
print IRB.version, "\n"
exit 0
when "-h", "--help"
- require_relative "help"
+ require "irb/help"
IRB.print_usage
exit 0
when "--"
@@ -222,7 +207,7 @@ module IRB # :nodoc:
end
break
when /^-/
- fail UnrecognizedSwitch, opt
+ IRB.fail UnrecognizedSwitch, opt
else
@CONF[:SCRIPT] = opt
$0 = opt
@@ -267,7 +252,7 @@ module IRB # :nodoc:
when String
return rc_file
else
- fail IllegalRCNameGenerator
+ IRB.fail IllegalRCNameGenerator
end
end
@@ -276,23 +261,14 @@ module IRB # :nodoc:
if irbrc = ENV["IRBRC"]
yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
end
- if xdg_config_home = ENV["XDG_CONFIG_HOME"]
- irb_home = File.join(xdg_config_home, "irb")
- unless File.exist? irb_home
- require 'fileutils'
- FileUtils.mkdir_p irb_home
- end
- yield proc{|rc| irb_home + "/irb#{rc}"}
- end
if home = ENV["HOME"]
yield proc{|rc| home+"/.irb#{rc}"}
end
- current_dir = Dir.pwd
- yield proc{|rc| current_dir+"/.config/irb/irb#{rc}"}
- yield proc{|rc| current_dir+"/.irb#{rc}"}
- yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"}
- yield proc{|rc| current_dir+"/_irb#{rc}"}
- yield proc{|rc| current_dir+"/$irb#{rc}"}
+ home = Dir.pwd
+ yield proc{|rc| home+"/.irb#{rc}"}
+ yield proc{|rc| home+"/irb#{rc.sub(/\A_?/, '.')}"}
+ yield proc{|rc| home+"/_irb#{rc}"}
+ yield proc{|rc| home+"/$irb#{rc}"}
end
# loading modules
@@ -310,18 +286,15 @@ module IRB # :nodoc:
DefaultEncodings = Struct.new(:external, :internal)
class << IRB
private
- def set_encoding(extern, intern = nil, override: true)
+ def set_encoding(extern, intern = nil)
verbose, $VERBOSE = $VERBOSE, nil
Encoding.default_external = extern unless extern.nil? || extern.empty?
Encoding.default_internal = intern unless intern.nil? || intern.empty?
+ @CONF[:ENCODINGS] = IRB::DefaultEncodings.new(extern, intern)
[$stdin, $stdout, $stderr].each do |io|
io.set_encoding(extern, intern)
end
- if override
- @CONF[:LC_MESSAGES].instance_variable_set(:@override_encoding, extern)
- else
- @CONF[:LC_MESSAGES].instance_variable_set(:@encoding, extern)
- end
+ @CONF[:LC_MESSAGES].instance_variable_set(:@encoding, extern)
ensure
$VERBOSE = verbose
end
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 6e87488753..f7b1aac3bf 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -9,11 +9,8 @@
#
#
#
-require_relative 'src_encoding'
-require_relative 'magic-file'
-require_relative 'completion'
-require 'io/console'
-require 'reline'
+require 'irb/src_encoding'
+require 'irb/magic-file'
module IRB
STDIN_FILE_NAME = "(line)" # :nodoc:
@@ -33,18 +30,10 @@ module IRB
#
# See IO#gets for more information.
def gets
- fail NotImplementedError, "gets"
+ IRB.fail NotImplementedError, "gets"
end
public :gets
- def winsize
- if instance_variable_defined?(:@stdout)
- @stdout.winsize
- else
- [24, 80]
- end
- end
-
# Whether this input method is still readable when there is no more data to
# read.
#
@@ -52,11 +41,6 @@ module IRB
def readable_after_eof?
false
end
-
- # For debug message
- def inspect
- 'Abstract InputMethod'
- end
end
class StdioInputMethod < InputMethod
@@ -107,11 +91,6 @@ module IRB
def encoding
@stdin.external_encoding
end
-
- # For debug message
- def inspect
- 'StdioInputMethod'
- end
end
# Use a File for IO with irb, see InputMethod
@@ -137,35 +116,22 @@ module IRB
# See IO#gets for more information.
def gets
print @prompt
- @io.gets
+ l = @io.gets
+ l
end
# The external encoding for standard input.
def encoding
@io.external_encoding
end
-
- # For debug message
- def inspect
- 'FileInputMethod'
- end
end
begin
+ require "readline"
class ReadlineInputMethod < InputMethod
- def self.initialize_readline
- require "readline"
- rescue LoadError
- else
- include ::Readline
- end
-
+ include Readline
# Creates a new input method object using Readline
def initialize
- self.class.initialize_readline
- if Readline.respond_to?(:encoding_system_needs)
- IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
- end
super
@line_no = 0
@@ -174,12 +140,6 @@ module IRB
@stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
@stdout = IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
-
- if Readline.respond_to?("basic_word_break_characters=")
- Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
- end
- Readline.completion_append_character = nil
- Readline.completion_proc = IRB::InputCompletor::CompletionProc
end
# Reads the next line from this input method.
@@ -226,121 +186,7 @@ module IRB
def encoding
@stdin.external_encoding
end
-
- # For debug message
- def inspect
- readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
- str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}"
- inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
- str += " and #{inputrc_path}" if File.exist?(inputrc_path)
- str
- end
- end
- end
-
- class ReidlineInputMethod < InputMethod
- include Reline
- # Creates a new input method object using Readline
- def initialize
- IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
- super
-
- @line_no = 0
- @line = []
- @eof = false
-
- @stdin = ::IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = ::IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
-
- if Reline.respond_to?("basic_word_break_characters=")
- Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
- end
- Reline.completion_append_character = nil
- Reline.completion_proc = IRB::InputCompletor::CompletionProc
- Reline.output_modifier_proc =
- if IRB.conf[:USE_COLORIZE]
- proc do |output, complete: |
- next unless IRB::Color.colorable?
- IRB::Color.colorize_code(output, complete: complete)
- end
- else
- proc do |output|
- Reline::Unicode.escape_for_print(output)
- end
- end
- Reline.dig_perfect_match_proc = IRB::InputCompletor::PerfectMatchedProc
- end
-
- def check_termination(&block)
- @check_termination_proc = block
- end
-
- def dynamic_prompt(&block)
- @prompt_proc = block
- end
-
- def auto_indent(&block)
- @auto_indent_proc = block
- end
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- Reline.input = @stdin
- Reline.output = @stdout
- Reline.prompt_proc = @prompt_proc
- Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
- if l = readmultiline(@prompt, false, &@check_termination_proc)
- HISTORY.push(l) if !l.empty?
- @line[@line_no += 1] = l + "\n"
- else
- @eof = true
- l
- end
- end
-
- # Whether the end of this input method has been reached, returns +true+
- # if there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @eof
- end
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
- end
-
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
-
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
- end
-
- # For debug message
- def inspect
- config = Reline::Config.new
- str = "ReidlineInputMethod with Reline #{Reline::VERSION}"
- if config.respond_to?(:inputrc_path)
- inputrc_path = File.expand_path(config.inputrc_path)
- else
- inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
- end
- str += " and #{inputrc_path}" if File.exist?(inputrc_path)
- str
end
+ rescue LoadError
end
end
diff --git a/lib/irb/inspector.rb b/lib/irb/inspector.rb
index 671b32b6e8..f6f76712b8 100644
--- a/lib/irb/inspector.rb
+++ b/lib/irb/inspector.rb
@@ -106,23 +106,12 @@ module IRB # :nodoc:
Inspector.def_inspector([false, :to_s, :raw]){|v| v.to_s}
Inspector.def_inspector([true, :p, :inspect]){|v|
begin
- result = v.inspect
- if IRB.conf[:MAIN_CONTEXT]&.use_colorize? && Color.inspect_colorable?(v)
- result = Color.colorize_code(result)
- end
- result
+ v.inspect
rescue NoMethodError
puts "(Object doesn't support #inspect)"
- ''
end
}
- Inspector.def_inspector([:pp, :pretty_inspect], proc{require "pp"}){|v|
- result = v.pretty_inspect.chomp
- if IRB.conf[:MAIN_CONTEXT]&.use_colorize? && Color.inspect_colorable?(v)
- result = Color.colorize_code(result)
- end
- result
- }
+ Inspector.def_inspector([:pp, :pretty_inspect], proc{require "pp"}){|v| v.pretty_inspect.chomp}
Inspector.def_inspector([:yaml, :YAML], proc{require "yaml"}){|v|
begin
YAML.dump(v)
@@ -136,3 +125,8 @@ module IRB # :nodoc:
Marshal.dump(v)
}
end
+
+
+
+
+
diff --git a/lib/irb/irb.gemspec b/lib/irb/irb.gemspec
deleted file mode 100644
index af40a32452..0000000000
--- a/lib/irb/irb.gemspec
+++ /dev/null
@@ -1,84 +0,0 @@
-begin
- require_relative "lib/irb/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "irb"
- spec.version = IRB::VERSION
- spec.authors = ["Keiju ISHITSUKA"]
- spec.email = ["keiju@ruby-lang.org"]
-
- spec.summary = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
- spec.description = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
- spec.homepage = "https://github.com/ruby/irb"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.files = [
- ".document",
- "Gemfile",
- "LICENSE.txt",
- "README.md",
- "Rakefile",
- "bin/console",
- "bin/setup",
- "doc/irb/irb-tools.rd.ja",
- "doc/irb/irb.rd.ja",
- "exe/irb",
- "irb.gemspec",
- "lib/irb.rb",
- "lib/irb/cmd/chws.rb",
- "lib/irb/cmd/fork.rb",
- "lib/irb/cmd/help.rb",
- "lib/irb/cmd/load.rb",
- "lib/irb/cmd/nop.rb",
- "lib/irb/cmd/pushws.rb",
- "lib/irb/cmd/subirb.rb",
- "lib/irb/color.rb",
- "lib/irb/completion.rb",
- "lib/irb/context.rb",
- "lib/irb/easter-egg.rb",
- "lib/irb/ext/change-ws.rb",
- "lib/irb/ext/history.rb",
- "lib/irb/ext/loader.rb",
- "lib/irb/ext/multi-irb.rb",
- "lib/irb/ext/save-history.rb",
- "lib/irb/ext/tracer.rb",
- "lib/irb/ext/use-loader.rb",
- "lib/irb/ext/workspaces.rb",
- "lib/irb/extend-command.rb",
- "lib/irb/frame.rb",
- "lib/irb/help.rb",
- "lib/irb/init.rb",
- "lib/irb/input-method.rb",
- "lib/irb/inspector.rb",
- "lib/irb/lc/error.rb",
- "lib/irb/lc/help-message",
- "lib/irb/lc/ja/encoding_aliases.rb",
- "lib/irb/lc/ja/error.rb",
- "lib/irb/lc/ja/help-message",
- "lib/irb/locale.rb",
- "lib/irb/magic-file.rb",
- "lib/irb/notifier.rb",
- "lib/irb/output-method.rb",
- "lib/irb/ruby-lex.rb",
- "lib/irb/ruby_logo.aa",
- "lib/irb/src_encoding.rb",
- "lib/irb/version.rb",
- "lib/irb/workspace.rb",
- "lib/irb/ws-for-case-2.rb",
- "lib/irb/xmp.rb",
- "man/irb.1",
- ]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
-
- spec.add_dependency "reline", ">= 0.1.5"
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
-end
diff --git a/lib/irb/lc/.document b/lib/irb/lc/.document
new file mode 100644
index 0000000000..524bb9430b
--- /dev/null
+++ b/lib/irb/lc/.document
@@ -0,0 +1,4 @@
+# hide help-message files which contain usage information
+error.rb
+ja/encoding_aliases.rb
+ja/error.rb
diff --git a/lib/irb/lc/error.rb b/lib/irb/lc/error.rb
index 798994e92c..6623f82d84 100644
--- a/lib/irb/lc/error.rb
+++ b/lib/irb/lc/error.rb
@@ -9,63 +9,24 @@
#
#
#
+require "e2mmap"
# :stopdoc:
module IRB
- class UnrecognizedSwitch < StandardError
- def initialize(val)
- super("Unrecognized switch: #{val}")
- end
- end
- class NotImplementedError < StandardError
- def initialize(val)
- super("Need to define `#{val}'")
- end
- end
- class CantReturnToNormalMode < StandardError
- def initialize
- super("Can't return to normal mode.")
- end
- end
- class IllegalParameter < StandardError
- def initialize(val)
- super("Invalid parameter(#{val}).")
- end
- end
- class IrbAlreadyDead < StandardError
- def initialize
- super("Irb is already dead.")
- end
- end
- class IrbSwitchedToCurrentThread < StandardError
- def initialize
- super("Switched to current thread.")
- end
- end
- class NoSuchJob < StandardError
- def initialize(val)
- super("No such job(#{val}).")
- end
- end
- class CantShiftToMultiIrbMode < StandardError
- def initialize
- super("Can't shift to multi irb mode.")
- end
- end
- class CantChangeBinding < StandardError
- def initialize(val)
- super("Can't change binding to (#{val}).")
- end
- end
- class UndefinedPromptMode < StandardError
- def initialize(val)
- super("Undefined prompt mode(#{val}).")
- end
- end
- class IllegalRCGenerator < StandardError
- def initialize
- super("Define illegal RC_NAME_GENERATOR.")
- end
- end
+
+ # exceptions
+ extend Exception2MessageMapper
+ def_exception :UnrecognizedSwitch, "Unrecognized switch: %s"
+ def_exception :NotImplementedError, "Need to define `%s'"
+ def_exception :CantReturnToNormalMode, "Can't return to normal mode."
+ def_exception :IllegalParameter, "Invalid parameter(%s)."
+ def_exception :IrbAlreadyDead, "Irb is already dead."
+ def_exception :IrbSwitchedToCurrentThread, "Switched to current thread."
+ def_exception :NoSuchJob, "No such job(%s)."
+ def_exception :CantShiftToMultiIrbMode, "Can't shift to multi irb mode."
+ def_exception :CantChangeBinding, "Can't change binding to (%s)."
+ def_exception :UndefinedPromptMode, "Undefined prompt mode(%s)."
+ def_exception :IllegalRCGenerator, 'Define illegal RC_NAME_GENERATOR.'
+
end
# :startdoc:
diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message
index a80facc9c5..d43c6a1695 100644
--- a/lib/irb/lc/help-message
+++ b/lib/irb/lc/help-message
@@ -22,19 +22,15 @@ Usage: irb.rb [options] [programfile] [arguments]
when new workspace was created
--echo Show result(default)
--noecho Don't show result
- --inspect Use `inspect' for output
- --noinspect Don't use inspect for output
- --multiline Use multiline editor module
- --nomultiline Don't use multiline editor module
- --singleline Use singleline editor module
- --nosingleline Don't use singleline editor module
- --colorize Use colorization
- --nocolorize Don't use colorization
+ --inspect Use `inspect' for output (default except for bc mode)
+ --noinspect Don't use inspect for output
+ --readline Use Readline extension module
+ --noreadline Don't use Readline extension module
--prompt prompt-mode/--prompt-mode prompt-mode
Switch prompt mode. Pre-defined prompt modes are
`default', `simple', `xmp' and `inf-ruby'
--inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
- Suppresses --multiline and --singleline.
+ Suppresses --readline.
--sample-book-mode/--simple-prompt
Simple prompt mode
--noprompt No prompt mode
@@ -43,6 +39,7 @@ Usage: irb.rb [options] [programfile] [arguments]
--back-trace-limit n
Display backtrace top n and tail n. The default
value is 16.
+ --irb_debug n Set internal debug level to n (not for popular use)
--verbose Show details
--noverbose Don't show details
-v, --version Print the version of irb
diff --git a/lib/irb/lc/ja/error.rb b/lib/irb/lc/ja/error.rb
index 31ebb3b5f0..919363154c 100644
--- a/lib/irb/lc/ja/error.rb
+++ b/lib/irb/lc/ja/error.rb
@@ -9,64 +9,23 @@
#
#
#
+require "e2mmap"
# :stopdoc:
module IRB
- class UnrecognizedSwitch < StandardError
- def initialize(val)
- super("スイッãƒ(#{val})ãŒåˆ†ã‚Šã¾ã›ã‚“")
- end
- end
- class NotImplementedError < StandardError
- def initialize(val)
- super("`#{val}'ã®å®šç¾©ãŒå¿…è¦ã§ã™")
- end
- end
- class CantReturnToNormalMode < StandardError
- def initialize
- super("Normalãƒ¢ãƒ¼ãƒ‰ã«æˆ»ã‚Œã¾ã›ã‚“.")
- end
- end
- class IllegalParameter < StandardError
- def initialize(val)
- super("パラメータ(#{val})ãŒé–“é•ã£ã¦ã„ã¾ã™.")
- end
- end
- class IrbAlreadyDead < StandardError
- def initialize
- super("Irbã¯æ—¢ã«æ­»ã‚“ã§ã„ã¾ã™.")
- end
- end
- class IrbSwitchedToCurrentThread < StandardError
- def initialize
- super("カレントスレッドã«åˆ‡ã‚Šæ›¿ã‚りã¾ã—ãŸ.")
- end
- end
- class NoSuchJob < StandardError
- def initialize(val)
- super("ãã®ã‚ˆã†ãªã‚¸ãƒ§ãƒ–(#{val})ã¯ã‚りã¾ã›ã‚“.")
- end
- end
- class CantShiftToMultiIrbMode < StandardError
- def initialize
- super("multi-irb modeã«ç§»ã‚Œã¾ã›ã‚“.")
- end
- end
- class CantChangeBinding < StandardError
- def initialize(val)
- super("ãƒã‚¤ãƒ³ãƒ‡ã‚£ãƒ³ã‚°(#{val})ã«å¤‰æ›´ã§ãã¾ã›ã‚“.")
- end
- end
- class UndefinedPromptMode < StandardError
- def initialize(val)
- super("プロンプトモード(#{val})ã¯å®šç¾©ã•れã¦ã„ã¾ã›ã‚“.")
- end
- end
- class IllegalRCGenerator < StandardError
- def initialize
- super("RC_NAME_GENERATORãŒæ­£ã—ã定義ã•れã¦ã„ã¾ã›ã‚“.")
- end
- end
+ # exceptions
+ extend Exception2MessageMapper
+ def_exception :UnrecognizedSwitch, 'スイッãƒ(%s)ãŒåˆ†ã‚Šã¾ã›ã‚“'
+ def_exception :NotImplementedError, '`%s\'ã®å®šç¾©ãŒå¿…è¦ã§ã™'
+ def_exception :CantReturnToNormalMode, 'Normalãƒ¢ãƒ¼ãƒ‰ã«æˆ»ã‚Œã¾ã›ã‚“.'
+ def_exception :IllegalParameter, 'パラメータ(%s)ãŒé–“é•ã£ã¦ã„ã¾ã™.'
+ def_exception :IrbAlreadyDead, 'Irbã¯æ—¢ã«æ­»ã‚“ã§ã„ã¾ã™.'
+ def_exception :IrbSwitchedToCurrentThread, 'カレントスレッドã«åˆ‡ã‚Šæ›¿ã‚りã¾ã—ãŸ.'
+ def_exception :NoSuchJob, 'ãã®ã‚ˆã†ãªã‚¸ãƒ§ãƒ–(%s)ã¯ã‚りã¾ã›ã‚“.'
+ def_exception :CantShiftToMultiIrbMode, 'multi-irb modeã«ç§»ã‚Œã¾ã›ã‚“.'
+ def_exception :CantChangeBinding, 'ãƒã‚¤ãƒ³ãƒ‡ã‚£ãƒ³ã‚°(%s)ã«å¤‰æ›´ã§ãã¾ã›ã‚“.'
+ def_exception :UndefinedPromptMode, 'プロンプトモード(%s)ã¯å®šç¾©ã•れã¦ã„ã¾ã›ã‚“.'
+ def_exception :IllegalRCNameGenerator, 'RC_NAME_GENERATORãŒæ­£ã—ã定義ã•れã¦ã„ã¾ã›ã‚“.'
end
# :startdoc:
# vim:fileencoding=utf-8
diff --git a/lib/irb/lc/ja/help-message b/lib/irb/lc/ja/help-message
index 9794a8e24e..1b24d14d28 100644
--- a/lib/irb/lc/ja/help-message
+++ b/lib/irb/lc/ja/help-message
@@ -21,21 +21,16 @@ Usage: irb.rb [options] [programfile] [arguments]
オブジェクトã®ä½œæˆæ–¹æ³•ã‚’ 0 ã‹ã‚‰ 3 ã®ã„ãšã‚Œã‹ã«è¨­å®šã™ã‚‹.
--echo å®Ÿè¡Œçµæžœã‚’表示ã™ã‚‹(デフォルト).
--noecho å®Ÿè¡Œçµæžœã‚’表示ã—ãªã„.
- --inspect çµæžœå‡ºåŠ›ã«inspectを用ã„ã‚‹.
+ --inspect çµæžœå‡ºåŠ›ã«inspectを用ã„ã‚‹(bcモード以外ã¯ãƒ‡ãƒ•ォルト).
--noinspect çµæžœå‡ºåŠ›ã«inspectを用ã„ãªã„.
- --multiline マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利用ã™ã‚‹.
- --nomultiline マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利用ã—ãªã„.
- --singleline シングルラインエディタを利用ã™ã‚‹.
- --nosingleline シングルラインエディタを利用ã—ãªã„.
- --colorize 色付ã‘を利用ã™ã‚‹.
- --nocolorize 色付ã‘を利用ã—ãªã„.
+ --readline readlineライブラリを利用ã™ã‚‹.
+ --noreadline readlineライブラリを利用ã—ãªã„.
--prompt prompt-mode/--prompt-mode prompt-mode
プロンプトモードを切替ãˆã¾ã™. ç¾åœ¨å®šç¾©ã•れã¦ã„るプ
ロンプトモードã¯, default, simple, xmp, inf-rubyãŒ
用æ„ã•れã¦ã„ã¾ã™.
--inf-ruby-mode emacsã®inf-ruby-mode用ã®ãƒ—ロンプト表示を行ãªã†. 特
- ã«æŒ‡å®šãŒãªã„é™ã‚Š, シングルラインエディタã¨ãƒžãƒ«ãƒãƒ©
- インエディタã¯ä½¿ã‚ãªããªã‚‹.
+ ã«æŒ‡å®šãŒãªã„é™ã‚Š, readlineライブラリã¯ä½¿ã‚ãªããªã‚‹.
--sample-book-mode/--simple-prompt
éžå¸¸ã«ã‚·ãƒ³ãƒ—ルãªãƒ—ロンプトを用ã„るモードã§ã™.
--noprompt プロンプト表示を行ãªã‚ãªã„.
@@ -46,6 +41,8 @@ Usage: irb.rb [options] [programfile] [arguments]
ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹è¡¨ç¤ºã‚’ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã®é ­ã‹ã‚‰ n, 後ã‚
ã‹ã‚‰nã ã‘行ãªã†. デフォルトã¯16
+ --irb_debug n irbã®ãƒ‡ãƒãƒƒã‚°ãƒ¬ãƒ™ãƒ«ã‚’nã«è¨­å®šã™ã‚‹(éžæŽ¨å¥¨).
+
--verbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã™ã‚‹.
--noverbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ãªã„(デフォルト).
-v, --version irbã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’表示ã™ã‚‹.
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index bb44b41002..b713f50e76 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -21,10 +21,8 @@ module IRB # :nodoc:
LOCALE_DIR = "/lc/"
@@legacy_encoding_alias_map = {}.freeze
- @@loaded = []
def initialize(locale = nil)
- @override_encoding = nil
@lang = @territory = @encoding_name = @modifier = nil
@locale = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
if m = LOCALE_NAME_RE.match(@locale)
@@ -41,16 +39,12 @@ module IRB # :nodoc:
@encoding ||= (Encoding.find('locale') rescue Encoding::ASCII_8BIT)
end
- attr_reader :lang, :territory, :modifier
-
- def encoding
- @override_encoding || @encoding
- end
+ attr_reader :lang, :territory, :encoding, :modifier
def String(mes)
mes = super(mes)
- if encoding
- mes.encode(encoding, undef: :replace)
+ if @encoding
+ mes.encode(@encoding, undef: :replace)
else
mes
end
@@ -113,10 +107,7 @@ module IRB # :nodoc:
def load(file, priv=nil)
found = find(file)
if found
- unless @@loaded.include?(found)
- @@loaded << found # cache
- return real_load(found, priv)
- end
+ return real_load(found, priv)
else
raise LoadError, "No such file to load -- #{file}"
end
diff --git a/lib/irb/notifier.rb b/lib/irb/notifier.rb
index d0e413dd68..a21e865f2e 100644
--- a/lib/irb/notifier.rb
+++ b/lib/irb/notifier.rb
@@ -10,21 +10,17 @@
#
#
-require_relative "output-method"
+require "e2mmap"
+require "irb/output-method"
module IRB
# An output formatter used internally by the lexer.
module Notifier
- class ErrUndefinedNotifier < StandardError
- def initialize(val)
- super("undefined notifier level: #{val} is specified")
- end
- end
- class ErrUnrecognizedLevel < StandardError
- def initialize(val)
- super("unrecognized notifier level: #{val} is specified")
- end
- end
+ extend Exception2MessageMapper
+ def_exception :ErrUndefinedNotifier,
+ "undefined notifier level: %d is specified"
+ def_exception :ErrUnrecognizedLevel,
+ "unrecognized notifier level: %s is specified"
# Define a new Notifier output source, returning a new CompositeNotifier
# with the given +prefix+ and +output_method+.
@@ -166,10 +162,10 @@ module IRB
@level_notifier = value
when Integer
l = @notifiers[value]
- raise ErrUndefinedNotifier, value unless l
+ Notifier.Raise ErrUndefinedNotifier, value unless l
@level_notifier = l
else
- raise ErrUnrecognizedLevel, value unless l
+ Notifier.Raise ErrUnrecognizedLevel, value unless l
end
end
diff --git a/lib/irb/output-method.rb b/lib/irb/output-method.rb
index 3fda708cb0..935a127d0a 100644
--- a/lib/irb/output-method.rb
+++ b/lib/irb/output-method.rb
@@ -10,21 +10,21 @@
#
#
+require "e2mmap"
+
module IRB
# An abstract output class for IO in irb. This is mainly used internally by
# IRB::Notifier. You can define your own output method to use with Irb.new,
# or Context.new
class OutputMethod
- class NotImplementedError < StandardError
- def initialize(val)
- super("Need to define `#{val}'")
- end
- end
+ extend Exception2MessageMapper
+ def_exception :NotImplementedError, "Need to define `%s'"
+
# Open this method to implement your own output method, raises a
# NotImplementedError if you don't define #print in your own class.
def print(*opts)
- raise NotImplementedError, "print"
+ OutputMethod.Raise NotImplementedError, "print"
end
# Prints the given +opts+, with a newline delimiter.
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 7be77fd12e..fb7e08099f 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -10,64 +10,74 @@
#
#
-require "ripper"
-require "jruby" if RUBY_ENGINE == "jruby"
+require "e2mmap"
+require "irb/slex"
+require "irb/ruby-token"
# :stopdoc:
class RubyLex
- class TerminateLineInput < StandardError
- def initialize
- super("Terminate Line Input")
+ extend Exception2MessageMapper
+ def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
+ def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
+ def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
+ def_exception(:TkReading2TokenDuplicateError,
+ "key duplicate(token_n='%s', key='%s')")
+ def_exception(:SyntaxError, "%s")
+
+ def_exception(:TerminateLineInput, "Terminate Line Input")
+
+ include RubyToken
+
+ class << self
+ attr_accessor :debug_level
+ def debug?
+ @debug_level > 0
end
end
+ @debug_level = 0
def initialize
+ lex_init
+ set_input(STDIN)
+
+ @seek = 0
@exp_line_no = @line_no = 1
+ @base_char_no = 0
+ @char_no = 0
+ @rests = []
+ @readed = []
+ @here_readed = []
+
@indent = 0
+ @indent_stack = []
+ @lex_state = EXPR_BEG
+ @space_seen = false
+ @here_header = false
+ @post_symbeg = false
+
@continue = false
@line = ""
+
+ @skip_space = false
+ @readed_auto_clean_up = false
+ @exception_on_syntax_error = true
+
@prompt = nil
end
- def self.compile_with_errors_suppressed(code)
- line_no = 1
- begin
- result = yield code, line_no
- rescue ArgumentError
- code = ";\n#{code}"
- line_no = 0
- result = yield code, line_no
- end
- result
- end
+ attr_accessor :skip_space
+ attr_accessor :readed_auto_clean_up
+ attr_accessor :exception_on_syntax_error
+
+ attr_reader :seek
+ attr_reader :char_no
+ attr_reader :line_no
+ attr_reader :indent
# io functions
def set_input(io, p = nil, &block)
@io = io
- if @io.respond_to?(:check_termination)
- @io.check_termination do |code|
- code.gsub!(/\s*\z/, '').concat("\n")
- ltype, indent, continue, code_block_open = check_state(code)
- if ltype or indent > 0 or continue or code_block_open
- false
- else
- true
- end
- end
- end
- if @io.respond_to?(:dynamic_prompt)
- @io.dynamic_prompt do |lines|
- lines << '' if lines.empty?
- result = []
- lines.each_index { |i|
- c = lines[0..i].map{ |l| l + "\n" }.join
- ltype, indent, continue, code_block_open = check_state(c)
- result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + i)
- }
- result
- end
- end
if p.respond_to?(:call)
@input = p
elsif block_given?
@@ -77,57 +87,119 @@ class RubyLex
end
end
- def set_prompt(p = nil, &block)
- p = block if block_given?
- if p.respond_to?(:call)
- @prompt = p
+ def get_readed
+ if idx = @readed.rindex("\n")
+ @base_char_no = @readed.size - (idx + 1)
else
- @prompt = Proc.new{print p}
+ @base_char_no += @readed.size
+ end
+
+ readed = @readed.join("")
+ @readed = []
+ readed
+ end
+
+ def getc
+ while @rests.empty?
+ @rests.push nil unless buf_input
+ end
+ c = @rests.shift
+ if @here_header
+ @here_readed.push c
+ else
+ @readed.push c
+ end
+ @seek += 1
+ if c == "\n"
+ @line_no += 1
+ @char_no = 0
+ else
+ @char_no += 1
end
+ c
end
- def ripper_lex_without_warning(code)
- verbose, $VERBOSE = $VERBOSE, nil
- tokens = nil
- self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
- tokens = Ripper.lex(inner_code, '-', line_no)
+ def gets
+ l = ""
+ while c = getc
+ l.concat(c)
+ break if c == "\n"
end
- $VERBOSE = verbose
- tokens
+ return nil if l == "" and c.nil?
+ l
end
- def set_auto_indent(context)
- if @io.respond_to?(:auto_indent) and context.auto_indent_mode
- @io.auto_indent do |lines, line_index, byte_pointer, is_newline|
- if is_newline
- md = lines[line_index - 1].match(/(\A +)/)
- prev_spaces = md.nil? ? 0 : md[1].count(' ')
- @tokens = ripper_lex_without_warning(lines[0..line_index].join("\n"))
- depth_difference = check_newline_depth_difference
- prev_spaces + depth_difference * 2
- else
- code = line_index.zero? ? '' : lines[0..(line_index - 1)].map{ |l| l + "\n" }.join
- last_line = lines[line_index]&.byteslice(0, byte_pointer)
- code += last_line if last_line
- @tokens = ripper_lex_without_warning(code)
- corresponding_token_depth = check_corresponding_token_depth
- if corresponding_token_depth
- corresponding_token_depth
- else
- nil
- end
- end
+ def eof?
+ @io.eof?
+ end
+
+ def getc_of_rests
+ if @rests.empty?
+ nil
+ else
+ getc
+ end
+ end
+
+ def ungetc(c = nil)
+ if @here_readed.empty?
+ c2 = @readed.pop
+ else
+ c2 = @here_readed.pop
+ end
+ c = c2 unless c
+ @rests.unshift c #c =
+ @seek -= 1
+ if c == "\n"
+ @line_no -= 1
+ if idx = @readed.rindex("\n")
+ @char_no = idx + 1
+ else
+ @char_no = @base_char_no + @readed.size
end
+ else
+ @char_no -= 1
+ end
+ end
+
+ def peek_equal?(str)
+ chrs = str.split(//)
+ until @rests.size >= chrs.size
+ return false unless buf_input
+ end
+ @rests[0, chrs.size] == chrs
+ end
+
+ def peek_match?(regexp)
+ while @rests.empty?
+ return false unless buf_input
+ end
+ regexp =~ @rests.join("")
+ end
+
+ def peek(i = 0)
+ while @rests.size <= i
+ return nil unless buf_input
end
+ @rests[i]
end
- def check_state(code)
- @tokens = ripper_lex_without_warning(code)
- ltype = process_literal_type
- indent = process_nesting_level
- continue = process_continue
- code_block_open = check_code_block(code)
- [ltype, indent, continue, code_block_open]
+ def buf_input
+ prompt
+ line = @input.call
+ return nil unless line
+ @rests.concat line.chars.to_a
+ true
+ end
+ private :buf_input
+
+ def set_prompt(p = nil, &block)
+ p = block if block_given?
+ if p.respond_to?(:call)
+ @prompt = p
+ else
+ @prompt = Proc.new{print p}
+ end
end
def prompt
@@ -138,11 +210,20 @@ class RubyLex
def initialize_input
@ltype = nil
+ @quoted = nil
@indent = 0
+ @indent_stack = []
+ @lex_state = EXPR_BEG
+ @space_seen = false
+ @here_header = false
+
@continue = false
+ @post_symbeg = false
+
+ prompt
+
@line = ""
@exp_line_no = @line_no
- @code_block_open = false
end
def each_top_level_statement
@@ -150,14 +231,13 @@ class RubyLex
catch(:TERM_INPUT) do
loop do
begin
+ @continue = false
prompt
unless l = lex
throw :TERM_INPUT if @line == ''
else
- @line_no += l.count("\n")
- next if l == "\n"
@line.concat l
- if @code_block_open or @ltype or @continue or @indent > 0
+ if @ltype or @continue or @indent > 0
next
end
end
@@ -165,429 +245,935 @@ class RubyLex
@line.force_encoding(@io.encoding)
yield @line, @exp_line_no
end
- break if @io.eof?
+ break unless l
@line = ''
@exp_line_no = @line_no
@indent = 0
+ @indent_stack = []
+ prompt
rescue TerminateLineInput
initialize_input
prompt
+ get_readed
end
end
end
end
def lex
- line = @input.call
- if @io.respond_to?(:check_termination)
- return line # multiline
- end
- code = @line + (line.nil? ? '' : line)
- code.gsub!(/\s*\z/, '').concat("\n")
- @tokens = ripper_lex_without_warning(code)
- @continue = process_continue
- @code_block_open = check_code_block(code)
- @indent = process_nesting_level
- @ltype = process_literal_type
- line
+ continue = @continue
+ while tk = token
+ case tk
+ when TkNL, TkEND_OF_SCRIPT
+ @continue = continue unless continue.nil?
+ break unless @continue
+ when TkSPACE, TkCOMMENT
+ when TkSEMICOLON, TkBEGIN, TkELSE
+ @continue = continue = false
+ else
+ continue = nil
+ end
+ end
+ line = get_readed
+ if line == "" and tk.kind_of?(TkEND_OF_SCRIPT) || tk.nil?
+ nil
+ else
+ line
+ end
end
- def process_continue
- # last token is always newline
- if @tokens.size >= 2 and @tokens[-2][1] == :on_regexp_end
- # end of regexp literal
- return false
- elsif @tokens.size >= 2 and @tokens[-2][1] == :on_semicolon
- return false
- elsif @tokens.size >= 2 and @tokens[-2][1] == :on_kw and ['begin', 'else', 'ensure'].include?(@tokens[-2][2])
- return false
- elsif !@tokens.empty? and @tokens.last[2] == "\\\n"
- return true
- elsif @tokens.size >= 1 and @tokens[-1][1] == :on_heredoc_end # "EOH\n"
- return false
- elsif @tokens.size >= 2 and defined?(Ripper::EXPR_BEG) and @tokens[-2][3].anybits?(Ripper::EXPR_BEG | Ripper::EXPR_FNAME)
- # end of literal except for regexp
- return true
- end
- false
+ def token
+ @prev_seek = @seek
+ @prev_line_no = @line_no
+ @prev_char_no = @char_no
+ begin
+ begin
+ tk = @OP.match(self)
+ @space_seen = tk.kind_of?(TkSPACE)
+ @lex_state = EXPR_END if @post_symbeg && tk.kind_of?(TkOp)
+ @post_symbeg = tk.kind_of?(TkSYMBEG)
+ rescue SyntaxError
+ raise if @exception_on_syntax_error
+ tk = TkError.new(@seek, @line_no, @char_no)
+ end
+ end while @skip_space and tk.kind_of?(TkSPACE)
+ if @readed_auto_clean_up
+ get_readed
+ end
+ tk
end
- def check_code_block(code)
- return true if @tokens.empty?
- if @tokens.last[1] == :on_heredoc_beg
- return true
+ ENINDENT_CLAUSE = [
+ "case", "class", "def", "do", "for", "if",
+ "module", "unless", "until", "while", "begin"
+ ]
+ DEINDENT_CLAUSE = ["end"
+ ]
+
+ PERCENT_LTYPE = {
+ "q" => "\'",
+ "Q" => "\"",
+ "x" => "\`",
+ "r" => "/",
+ "w" => "]",
+ "W" => "]",
+ "i" => "]",
+ "I" => "]",
+ "s" => ":"
+ }
+
+ PERCENT_PAREN = {
+ "{" => "}",
+ "[" => "]",
+ "<" => ">",
+ "(" => ")"
+ }
+
+ Ltype2Token = {
+ "\'" => TkSTRING,
+ "\"" => TkSTRING,
+ "\`" => TkXSTRING,
+ "/" => TkREGEXP,
+ "]" => TkDSTRING,
+ ":" => TkSYMBOL
+ }
+ DLtype2Token = {
+ "\"" => TkDSTRING,
+ "\`" => TkDXSTRING,
+ "/" => TkDREGEXP,
+ }
+
+ def lex_init()
+ @OP = IRB::SLex.new
+ @OP.def_rules("\0", "\004", "\032") do |op, io|
+ Token(TkEND_OF_SCRIPT)
end
- begin # check if parser error are available
- verbose, $VERBOSE = $VERBOSE, nil
- case RUBY_ENGINE
- when 'jruby'
- JRuby.compile_ir(code)
+ @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |op, io|
+ @space_seen = true
+ while getc =~ /[ \t\f\r\13]/; end
+ ungetc
+ Token(TkSPACE)
+ end
+
+ @OP.def_rule("#") do |op, io|
+ identify_comment
+ end
+
+ @OP.def_rule("=begin",
+ proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
+ |op, io|
+ @ltype = "="
+ until getc == "\n"; end
+ until peek_equal?("=end") && peek(4) =~ /\s/
+ until getc == "\n"; end
+ end
+ gets
+ @ltype = nil
+ Token(TkRD_COMMENT)
+ end
+
+ @OP.def_rule("\n") do |op, io|
+ print "\\n\n" if RubyLex.debug?
+ case @lex_state
+ when EXPR_BEG, EXPR_FNAME, EXPR_DOT
+ @continue = true
else
- self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
- RubyVM::InstructionSequence.compile(inner_code, nil, nil, line_no)
+ @continue = false
+ @lex_state = EXPR_BEG
+ until (@indent_stack.empty? ||
+ [TkLPAREN, TkLBRACK, TkLBRACE,
+ TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
+ @indent_stack.pop
end
end
- rescue EncodingError
- # This is for a hash with invalid encoding symbol, {"\xAE": 1}
- rescue SyntaxError => e
- case e.message
- when /unterminated (?:string|regexp) meets end of file/
- # "unterminated regexp meets end of file"
- #
- # example:
- # /
- #
- # "unterminated string meets end of file"
- #
- # example:
- # '
- return true
- when /syntax error, unexpected end-of-input/
- # "syntax error, unexpected end-of-input, expecting keyword_end"
- #
- # example:
- # if ture
- # hoge
- # if false
- # fuga
- # end
- return true
- when /syntax error, unexpected keyword_end/
- # "syntax error, unexpected keyword_end"
- #
- # example:
- # if (
- # end
- #
- # example:
- # end
- return false
- when /syntax error, unexpected '\.'/
- # "syntax error, unexpected '.'"
- #
- # example:
- # .
- return false
- when /unexpected tREGEXP_BEG/
- # "syntax error, unexpected tREGEXP_BEG, expecting keyword_do or '{' or '('"
- #
- # example:
- # method / f /
- return false
+ @here_header = false
+ @here_readed = []
+ Token(TkNL)
+ end
+
+ @OP.def_rules("*", "**",
+ "=", "==", "===",
+ "=~", "<=>",
+ "<", "<=",
+ ">", ">=", ">>",
+ "!", "!=", "!~") do
+ |op, io|
+ case @lex_state
+ when EXPR_FNAME, EXPR_DOT
+ @lex_state = EXPR_ARG
+ else
+ @lex_state = EXPR_BEG
end
- ensure
- $VERBOSE = verbose
+ Token(op)
end
- if defined?(Ripper::EXPR_BEG)
- last_lex_state = @tokens.last[3]
- if last_lex_state.allbits?(Ripper::EXPR_BEG)
- return false
- elsif last_lex_state.allbits?(Ripper::EXPR_DOT)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_CLASS)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_FNAME)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_VALUE)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_ARG)
- return false
+ @OP.def_rules("<<") do
+ |op, io|
+ tk = nil
+ if @lex_state != EXPR_END && @lex_state != EXPR_CLASS &&
+ (@lex_state != EXPR_ARG || @space_seen)
+ c = peek(0)
+ if /[-~"'`\w]/ =~ c
+ tk = identify_here_document
+ end
end
+ unless tk
+ tk = Token(op)
+ case @lex_state
+ when EXPR_FNAME, EXPR_DOT
+ @lex_state = EXPR_ARG
+ else
+ @lex_state = EXPR_BEG
+ end
+ end
+ tk
end
- false
- end
+ @OP.def_rules("'", '"') do
+ |op, io|
+ identify_string(op)
+ end
- def process_nesting_level
- indent = 0
- in_oneliner_def = nil
- @tokens.each_with_index { |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t[3].allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
+ @OP.def_rules("`") do
+ |op, io|
+ if @lex_state == EXPR_FNAME
+ @lex_state = EXPR_END
+ Token(op)
else
- if t[3].allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t[3].allbits?(Ripper::EXPR_BEG)
- if t[2] == '='
- in_oneliner_def = :BODY
- end
- elsif t[3].allbits?(Ripper::EXPR_END)
- if in_oneliner_def == :BODY
- # one-liner method definition
- indent -= 1
- end
- in_oneliner_def = nil
+ identify_string(op)
+ end
+ end
+
+ @OP.def_rules('?') do
+ |op, io|
+ if @lex_state == EXPR_END
+ @lex_state = EXPR_BEG
+ Token(TkQUESTION)
+ else
+ ch = getc
+ if @lex_state == EXPR_ARG && ch =~ /\s/
+ ungetc
+ @lex_state = EXPR_BEG;
+ Token(TkQUESTION)
else
- in_oneliner_def = nil
+ if (ch == '\\')
+ read_escape
+ end
+ @lex_state = EXPR_END
+ Token(TkINTEGER)
end
end
+ end
- case t[1]
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- indent += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- indent -= 1
- when :on_kw
- next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
- case t[2]
- when 'do'
- if index > 0 and @tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN | Ripper::EXPR_ARG)
- # method_with_block do; end
- indent += 1
+ @OP.def_rules("&", "&&", "|", "||") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op)
+ end
+
+ @OP.def_rules("+=", "-=", "*=", "**=",
+ "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ op =~ /^(.*)=$/
+ Token(TkOPASGN, $1)
+ end
+
+ @OP.def_rule("+@", proc{|op, io| @lex_state == EXPR_FNAME}) do
+ |op, io|
+ @lex_state = EXPR_ARG
+ Token(op)
+ end
+
+ @OP.def_rule("-@", proc{|op, io| @lex_state == EXPR_FNAME}) do
+ |op, io|
+ @lex_state = EXPR_ARG
+ Token(op)
+ end
+
+ @OP.def_rules("+", "-") do
+ |op, io|
+ catch(:RET) do
+ if @lex_state == EXPR_ARG
+ if @space_seen and peek(0) =~ /[0-9]/
+ throw :RET, identify_number
else
- # while cond do; end # also "until" or "for"
- # This "do" doesn't increment indent because "while" already
- # incremented.
+ @lex_state = EXPR_BEG
end
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- indent += 1
- when 'if', 'unless', 'while', 'until'
- # postfix if/unless/while/until must be Ripper::EXPR_LABEL
- indent += 1 unless t[3].allbits?(Ripper::EXPR_LABEL)
- when 'end'
- indent -= 1
+ elsif @lex_state != EXPR_END and peek(0) =~ /[0-9]/
+ throw :RET, identify_number
+ else
+ @lex_state = EXPR_BEG
end
+ Token(op)
+ end
+ end
+
+ @OP.def_rule(".") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ if peek(0) =~ /[0-9]/
+ ungetc
+ identify_number
+ else
+ # for "obj.if" etc.
+ @lex_state = EXPR_DOT
+ Token(TkDOT)
end
- # percent literals are not indented
- }
- indent
+ end
+
+ @OP.def_rules("..", "...") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op)
+ end
+
+ lex_int2
end
- def check_newline_depth_difference
- depth_difference = 0
- open_brace_on_line = 0
- in_oneliner_def = nil
- @tokens.each_with_index do |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t[3].allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
+ def lex_int2
+ @OP.def_rules("]", "}", ")") do
+ |op, io|
+ @lex_state = EXPR_END
+ @indent -= 1
+ @indent_stack.pop
+ Token(op)
+ end
+
+ @OP.def_rule(":") do
+ |op, io|
+ if @lex_state == EXPR_END || peek(0) =~ /\s/
+ @lex_state = EXPR_BEG
+ Token(TkCOLON)
else
- if t[3].allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t[3].allbits?(Ripper::EXPR_BEG)
- if t[2] == '='
- in_oneliner_def = :BODY
- end
- elsif t[3].allbits?(Ripper::EXPR_END)
- if in_oneliner_def == :BODY
- # one[-liner method definition
- depth_difference -= 1
- end
- in_oneliner_def = nil
+ @lex_state = EXPR_FNAME
+ Token(TkSYMBEG)
+ end
+ end
+
+ @OP.def_rule("::") do
+ |op, io|
+ if @lex_state == EXPR_BEG or @lex_state == EXPR_ARG && @space_seen
+ @lex_state = EXPR_BEG
+ Token(TkCOLON3)
+ else
+ @lex_state = EXPR_DOT
+ Token(TkCOLON2)
+ end
+ end
+
+ @OP.def_rule("/") do
+ |op, io|
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ identify_string(op)
+ elsif peek(0) == '='
+ getc
+ @lex_state = EXPR_BEG
+ Token(TkOPASGN, "/") #/)
+ elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
+ identify_string(op)
+ else
+ @lex_state = EXPR_BEG
+ Token("/") #/)
+ end
+ end
+
+ @OP.def_rules("^") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token("^")
+ end
+
+ @OP.def_rules(",") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op)
+ end
+
+ @OP.def_rules(";") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ until (@indent_stack.empty? ||
+ [TkLPAREN, TkLBRACK, TkLBRACE,
+ TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
+ @indent_stack.pop
+ end
+ Token(op)
+ end
+
+ @OP.def_rule("~") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token("~")
+ end
+
+ @OP.def_rule("~@", proc{|op, io| @lex_state == EXPR_FNAME}) do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token("~")
+ end
+
+ @OP.def_rule("(") do
+ |op, io|
+ @indent += 1
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ @lex_state = EXPR_BEG
+ tk_c = TkfLPAREN
+ else
+ @lex_state = EXPR_BEG
+ tk_c = TkLPAREN
+ end
+ @indent_stack.push tk_c
+ Token(tk_c)
+ end
+
+ @OP.def_rule("[]", proc{|op, io| @lex_state == EXPR_FNAME}) do
+ |op, io|
+ @lex_state = EXPR_ARG
+ Token("[]")
+ end
+
+ @OP.def_rule("[]=", proc{|op, io| @lex_state == EXPR_FNAME}) do
+ |op, io|
+ @lex_state = EXPR_ARG
+ Token("[]=")
+ end
+
+ @OP.def_rule("[") do
+ |op, io|
+ @indent += 1
+ if @lex_state == EXPR_FNAME
+ tk_c = TkfLBRACK
+ else
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ tk_c = TkLBRACK
+ elsif @lex_state == EXPR_ARG && @space_seen
+ tk_c = TkLBRACK
else
- in_oneliner_def = nil
+ tk_c = TkfLBRACK
end
+ @lex_state = EXPR_BEG
end
+ @indent_stack.push tk_c
+ Token(tk_c)
+ end
- case t[1]
- when :on_ignored_nl, :on_nl, :on_comment
- if index != (@tokens.size - 1)
- depth_difference = 0
- open_brace_on_line = 0
- end
- next
- when :on_sp
- next
- end
- case t[1]
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- depth_difference += 1
- open_brace_on_line += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- depth_difference -= 1 if open_brace_on_line > 0
- when :on_kw
- next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
- case t[2]
- when 'do'
- if index > 0 and @tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN | Ripper::EXPR_ARG)
- # method_with_block do; end
- depth_difference += 1
+ @OP.def_rule("{") do
+ |op, io|
+ @indent += 1
+ if @lex_state != EXPR_END && @lex_state != EXPR_ARG
+ tk_c = TkLBRACE
+ else
+ tk_c = TkfLBRACE
+ end
+ @lex_state = EXPR_BEG
+ @indent_stack.push tk_c
+ Token(tk_c)
+ end
+
+ @OP.def_rule('\\') do
+ |op, io|
+ if getc == "\n"
+ @space_seen = true
+ @continue = true
+ Token(TkSPACE)
+ else
+ read_escape
+ Token("\\")
+ end
+ end
+
+ @OP.def_rule('%') do
+ |op, io|
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ identify_quotation
+ elsif peek(0) == '='
+ getc
+ Token(TkOPASGN, :%)
+ elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
+ identify_quotation
+ else
+ @lex_state = EXPR_BEG
+ Token("%") #))
+ end
+ end
+
+ @OP.def_rule('$') do
+ |op, io|
+ identify_gvar
+ end
+
+ @OP.def_rule('@') do
+ |op, io|
+ if peek(0) =~ /[\w@]/
+ ungetc
+ identify_identifier
+ else
+ Token("@")
+ end
+ end
+
+ @OP.def_rule("") do
+ |op, io|
+ printf "MATCH: start %s: %s\n", op, io.inspect if RubyLex.debug?
+ if peek(0) =~ /[0-9]/
+ t = identify_number
+ elsif peek(0) =~ /[^\x00-\/:-@\[-^`{-\x7F]/
+ t = identify_identifier
+ end
+ printf "MATCH: end %s: %s\n", op, io.inspect if RubyLex.debug?
+ t
+ end
+
+ p @OP if RubyLex.debug?
+ end
+
+ def identify_gvar
+ @lex_state = EXPR_END
+
+ case ch = getc
+ when /[~_*$?!@\/\\;,=:<>".]/ #"
+ Token(TkGVAR, "$" + ch)
+ when "-"
+ Token(TkGVAR, "$-" + getc)
+ when "&", "`", "'", "+"
+ Token(TkBACK_REF, "$"+ch)
+ when /[1-9]/
+ while getc =~ /[0-9]/; end
+ ungetc
+ Token(TkNTH_REF)
+ when /\w/
+ ungetc
+ ungetc
+ identify_identifier
+ else
+ ungetc
+ Token("$")
+ end
+ end
+
+ def identify_identifier
+ token = ""
+ if peek(0) =~ /[$@]/
+ token.concat(c = getc)
+ if c == "@" and peek(0) == "@"
+ token.concat getc
+ end
+ end
+
+ while (ch = getc) =~ /[^\x00-\/:-@\[-^`{-\x7F]/
+ print ":", ch, ":" if RubyLex.debug?
+ token.concat ch
+ end
+ ungetc
+
+ if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
+ token.concat getc
+ end
+
+ # almost fix token
+
+ case token
+ when /^\$/
+ return Token(TkGVAR, token)
+ when /^\@\@/
+ @lex_state = EXPR_END
+ # p Token(TkCVAR, token)
+ return Token(TkCVAR, token)
+ when /^\@/
+ @lex_state = EXPR_END
+ return Token(TkIVAR, token)
+ end
+
+ if @lex_state != EXPR_DOT
+ print token, "\n" if RubyLex.debug?
+
+ token_c, *trans = TkReading2Token[token]
+ if token_c
+ # reserved word?
+
+ if (@lex_state != EXPR_BEG &&
+ @lex_state != EXPR_FNAME &&
+ trans[1])
+ # modifiers
+ token_c = TkSymbol2Token[trans[1]]
+ @lex_state = trans[0]
+ else
+ if @lex_state != EXPR_FNAME and peek(0) != ':'
+ if ENINDENT_CLAUSE.include?(token)
+ # check for ``class = val'' etc.
+ valid = true
+ case token
+ when "class"
+ valid = false unless peek_match?(/^\s*(<<|\w|::)/)
+ when "def"
+ valid = false if peek_match?(/^\s*(([+\-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/)
+ when "do"
+ valid = false if peek_match?(/^\s*([+\-\/*]?=|\*|<|>|\&)/)
+ when *ENINDENT_CLAUSE
+ valid = false if peek_match?(/^\s*([+\-\/*]?=|\*|<|>|\&|\|)/)
+ else
+ # no nothing
+ end
+ if valid
+ if token == "do"
+ if ![TkFOR, TkWHILE, TkUNTIL].include?(@indent_stack.last)
+ @indent += 1
+ @indent_stack.push token_c
+ end
+ else
+ @indent += 1
+ @indent_stack.push token_c
+ end
+ end
+
+ elsif DEINDENT_CLAUSE.include?(token)
+ @indent -= 1
+ @indent_stack.pop
+ end
+ @lex_state = trans[0]
else
- # while cond do; end # also "until" or "for"
- # This "do" doesn't increment indent because "while" already
- # incremented.
- end
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- depth_difference += 1
- when 'if', 'unless', 'while', 'until', 'rescue'
- # postfix if/unless/while/until/rescue must be Ripper::EXPR_LABEL
- unless t[3].allbits?(Ripper::EXPR_LABEL)
- depth_difference += 1
+ @lex_state = EXPR_END
end
- when 'else', 'elsif', 'ensure', 'when', 'in'
- depth_difference += 1
end
+ return Token(token_c, token)
+ end
+ end
+
+ if @lex_state == EXPR_FNAME
+ @lex_state = EXPR_END
+ if peek(0) == '='
+ token.concat getc
end
+ elsif @lex_state == EXPR_BEG || @lex_state == EXPR_DOT
+ @lex_state = EXPR_ARG
+ else
+ @lex_state = EXPR_END
+ end
+
+ if token[0, 1] =~ /[A-Z]/
+ return Token(TkCONSTANT, token)
+ elsif token[token.size - 1, 1] =~ /[!?]/
+ return Token(TkFID, token)
+ else
+ return Token(TkIDENTIFIER, token)
end
- depth_difference
end
- def check_corresponding_token_depth
- corresponding_token_depth = nil
- is_first_spaces_of_line = true
- is_first_printable_of_line = true
- spaces_of_nest = []
- spaces_at_line_head = 0
- open_brace_on_line = 0
- in_oneliner_def = nil
- @tokens.each_with_index do |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t[3].allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
+ def identify_here_document
+ ch = getc
+ if ch == "-" || ch == "~"
+ ch = getc
+ indent = true
+ end
+ if /['"`]/ =~ ch
+ lt = ch
+ quoted = ""
+ while (c = getc) && c != lt
+ quoted.concat c
+ end
+ else
+ lt = '"'
+ quoted = ch.dup
+ while (c = getc) && c =~ /\w/
+ quoted.concat c
+ end
+ ungetc
+ end
+
+ ltback, @ltype = @ltype, lt
+ reserve = []
+ while ch = getc
+ reserve.push ch
+ if ch == "\\"
+ reserve.push ch = getc
+ elsif ch == "\n"
+ break
+ end
+ end
+
+ @here_header = false
+
+ line = ""
+ while ch = getc
+ if ch == "\n"
+ if line == quoted
+ break
end
+ line = ""
else
- if t[3].allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t[3].allbits?(Ripper::EXPR_BEG)
- if t[2] == '='
- in_oneliner_def = :BODY
- end
- elsif t[3].allbits?(Ripper::EXPR_END)
- if in_oneliner_def == :BODY
- # one-liner method definition
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
+ line.concat ch unless indent && line == "" && /\s/ =~ ch
+ if @ltype != "'" && ch == "#" && peek(0) == "{"
+ identify_string_dvar
+ end
+ end
+ end
+
+ @here_header = true
+ @here_readed.concat reserve
+ while ch = reserve.pop
+ ungetc ch
+ end
+
+ @ltype = ltback
+ @lex_state = EXPR_END
+ Token(Ltype2Token[lt])
+ end
+
+ def identify_quotation
+ ch = getc
+ if lt = PERCENT_LTYPE[ch]
+ ch = getc
+ elsif ch =~ /\W/
+ lt = "\""
+ else
+ RubyLex.fail SyntaxError, "unknown type of %string"
+ end
+ @quoted = ch unless @quoted = PERCENT_PAREN[ch]
+ identify_string(lt, @quoted)
+ end
+
+ def identify_number
+ @lex_state = EXPR_END
+
+ if peek(0) == "0" && peek(1) !~ /[.eE]/
+ getc
+ case peek(0)
+ when /[xX]/
+ ch = getc
+ match = /[0-9a-fA-F_]/
+ when /[bB]/
+ ch = getc
+ match = /[01_]/
+ when /[oO]/
+ ch = getc
+ match = /[0-7_]/
+ when /[dD]/
+ ch = getc
+ match = /[0-9_]/
+ when /[0-7]/
+ match = /[0-7_]/
+ when /[89]/
+ RubyLex.fail SyntaxError, "Invalid octal digit"
+ else
+ return Token(TkINTEGER)
+ end
+
+ len0 = true
+ non_digit = false
+ while ch = getc
+ if match =~ ch
+ if ch == "_"
+ if non_digit
+ RubyLex.fail SyntaxError, "trailing `#{ch}' in number"
else
- spaces_of_nest.pop
- corresponding_token_depth = nil
+ non_digit = ch
end
+ else
+ non_digit = false
+ len0 = false
end
- in_oneliner_def = nil
else
- in_oneliner_def = nil
+ ungetc
+ if len0
+ RubyLex.fail SyntaxError, "numeric literal without digits"
+ end
+ if non_digit
+ RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
+ end
+ break
end
end
+ return Token(TkINTEGER)
+ end
- case t[1]
- when :on_ignored_nl, :on_nl, :on_comment
- corresponding_token_depth = nil
- spaces_at_line_head = 0
- is_first_spaces_of_line = true
- is_first_printable_of_line = true
- open_brace_on_line = 0
- next
- when :on_sp
- spaces_at_line_head = t[2].count(' ') if is_first_spaces_of_line
- is_first_spaces_of_line = false
- next
- end
- case t[1]
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- spaces_of_nest.push(spaces_at_line_head + open_brace_on_line * 2)
- open_brace_on_line += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
- else
- spaces_of_nest.pop
- corresponding_token_depth = nil
+ type = TkINTEGER
+ allow_point = true
+ allow_e = true
+ non_digit = false
+ while ch = getc
+ case ch
+ when /[0-9]/
+ non_digit = false
+ when "_"
+ non_digit = ch
+ when allow_point && "."
+ if non_digit
+ RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
end
- open_brace_on_line -= 1
- when :on_kw
- next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
- case t[2]
- when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
- spaces_of_nest.push(spaces_at_line_head)
- when 'rescue'
- unless t[3].allbits?(Ripper::EXPR_LABEL)
- corresponding_token_depth = spaces_of_nest.last
- end
- when 'if', 'unless', 'while', 'until'
- # postfix if/unless/while/until must be Ripper::EXPR_LABEL
- unless t[3].allbits?(Ripper::EXPR_LABEL)
- spaces_of_nest.push(spaces_at_line_head)
- end
- when 'else', 'elsif', 'ensure', 'when', 'in'
- corresponding_token_depth = spaces_of_nest.last
- when 'end'
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
+ type = TkFLOAT
+ if peek(0) !~ /[0-9]/
+ type = TkINTEGER
+ ungetc
+ break
+ end
+ allow_point = false
+ when allow_e && "e", allow_e && "E"
+ if non_digit
+ RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
+ end
+ type = TkFLOAT
+ if peek(0) =~ /[+-]/
+ getc
+ end
+ allow_e = false
+ allow_point = false
+ non_digit = ch
+ else
+ if non_digit
+ RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
+ end
+ ungetc
+ break
+ end
+ end
+ Token(type)
+ end
+
+ def identify_string(ltype, quoted = ltype)
+ @ltype = ltype
+ @quoted = quoted
+ subtype = nil
+ begin
+ nest = 0
+ while ch = getc
+ if @quoted == ch and nest == 0
+ break
+ elsif @ltype != "'" && ch == "#" && peek(0) == "{"
+ identify_string_dvar
+ elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
+ subtype = true
+ elsif ch == '\\' and @ltype == "'" #'
+ case ch = getc
+ when "\\", "\n", "'"
else
- spaces_of_nest.pop
- corresponding_token_depth = nil
+ ungetc
+ end
+ elsif ch == '\\' #'
+ read_escape
+ end
+ if PERCENT_PAREN.values.include?(@quoted)
+ if PERCENT_PAREN[ch] == @quoted
+ nest += 1
+ elsif ch == @quoted
+ nest -= 1
end
end
end
- is_first_spaces_of_line = false
- is_first_printable_of_line = false
+ if @ltype == "/"
+ while /[imxoesun]/ =~ peek(0)
+ getc
+ end
+ end
+ if subtype
+ Token(DLtype2Token[ltype])
+ else
+ Token(Ltype2Token[ltype])
+ end
+ ensure
+ @ltype = nil
+ @quoted = nil
+ @lex_state = EXPR_END
end
- corresponding_token_depth
end
- def check_string_literal
- i = 0
- start_token = []
- end_type = []
- while i < @tokens.size
- t = @tokens[i]
- case t[1]
- when :on_tstring_beg
- start_token << t
- end_type << [:on_tstring_end, :on_label_end]
- when :on_regexp_beg
- start_token << t
- end_type << :on_regexp_end
- when :on_symbeg
- acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw}
- if (i + 1) < @tokens.size and acceptable_single_tokens.all?{ |t| @tokens[i + 1][1] != t }
- start_token << t
- end_type << :on_tstring_end
+ def identify_string_dvar
+ begin
+ getc
+
+ reserve_continue = @continue
+ reserve_ltype = @ltype
+ reserve_indent = @indent
+ reserve_indent_stack = @indent_stack
+ reserve_state = @lex_state
+ reserve_quoted = @quoted
+
+ @ltype = nil
+ @quoted = nil
+ @indent = 0
+ @indent_stack = []
+ @lex_state = EXPR_BEG
+
+ loop do
+ @continue = false
+ prompt
+ tk = token
+ if @ltype or @continue or @indent >= 0
+ next
end
- when :on_backtick
- start_token << t
- end_type << :on_tstring_end
- when :on_qwords_beg, :on_words_beg, :on_qsymbols_beg, :on_symbols_beg
- start_token << t
- end_type << :on_tstring_end
- when :on_heredoc_beg
- start_token << t
- end_type << :on_heredoc_end
- when *end_type.last
- start_token.pop
- end_type.pop
- end
- i += 1
- end
- start_token.last.nil? ? '' : start_token.last
+ break if tk.kind_of?(TkRBRACE)
+ end
+ ensure
+ @continue = reserve_continue
+ @ltype = reserve_ltype
+ @indent = reserve_indent
+ @indent_stack = reserve_indent_stack
+ @lex_state = reserve_state
+ @quoted = reserve_quoted
+ end
end
- def process_literal_type
- start_token = check_string_literal
- case start_token[1]
- when :on_tstring_beg
- case start_token[2]
- when ?" then ?"
- when /^%.$/ then ?"
- when /^%Q.$/ then ?"
- when ?' then ?'
- when /^%q.$/ then ?'
- end
- when :on_regexp_beg then ?/
- when :on_symbeg then ?:
- when :on_backtick then ?`
- when :on_qwords_beg then ?]
- when :on_words_beg then ?]
- when :on_qsymbols_beg then ?]
- when :on_symbols_beg then ?]
- when :on_heredoc_beg
- start_token[2] =~ /<<[-~]?(['"`])[_a-zA-Z0-9]+\1/
- case $1
- when ?" then ?"
- when ?' then ?'
- when ?` then ?`
- else ?"
+ def identify_comment
+ @ltype = "#"
+
+ while ch = getc
+ if ch == "\n"
+ @ltype = nil
+ ungetc
+ break
+ end
+ end
+ return Token(TkCOMMENT)
+ end
+
+ def read_escape
+ case ch = getc
+ when "\n", "\r", "\f"
+ when "\\", "n", "t", "r", "f", "v", "a", "e", "b", "s" #"
+ when /[0-7]/
+ ungetc ch
+ 3.times do
+ case ch = getc
+ when /[0-7]/
+ when nil
+ break
+ else
+ ungetc
+ break
+ end
+ end
+
+ when "x"
+ 2.times do
+ case ch = getc
+ when /[0-9a-fA-F]/
+ when nil
+ break
+ else
+ ungetc
+ break
+ end
+ end
+
+ when "M"
+ if (ch = getc) != '-'
+ ungetc
+ else
+ if (ch = getc) == "\\" #"
+ read_escape
+ end
+ end
+
+ when "C", "c" #, "^"
+ if ch == "C" and (ch = getc) != "-"
+ ungetc
+ elsif (ch = getc) == "\\" #"
+ read_escape
end
else
- nil
+ # other characters
end
end
end
diff --git a/lib/irb/ruby-token.rb b/lib/irb/ruby-token.rb
new file mode 100644
index 0000000000..af53d3c93b
--- /dev/null
+++ b/lib/irb/ruby-token.rb
@@ -0,0 +1,267 @@
+# frozen_string_literal: false
+#
+# irb/ruby-token.rb - ruby tokens
+# $Release Version: 0.9.6$
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+# :stopdoc:
+module RubyToken
+ EXPR_BEG = :EXPR_BEG
+ EXPR_MID = :EXPR_MID
+ EXPR_END = :EXPR_END
+ EXPR_ARG = :EXPR_ARG
+ EXPR_FNAME = :EXPR_FNAME
+ EXPR_DOT = :EXPR_DOT
+ EXPR_CLASS = :EXPR_CLASS
+
+ class Token
+ def initialize(seek, line_no, char_no)
+ @seek = seek
+ @line_no = line_no
+ @char_no = char_no
+ end
+ attr_reader :seek, :line_no, :char_no
+ end
+
+ class TkNode < Token
+ def initialize(seek, line_no, char_no)
+ super
+ end
+ attr_reader :node
+ end
+
+ class TkId < Token
+ def initialize(seek, line_no, char_no, name)
+ super(seek, line_no, char_no)
+ @name = name
+ end
+ attr_reader :name
+ end
+
+ class TkVal < Token
+ def initialize(seek, line_no, char_no, value = nil)
+ super(seek, line_no, char_no)
+ @value = value
+ end
+ attr_reader :value
+ end
+
+ class TkOp < Token
+ attr_accessor :name
+ end
+
+ class TkOPASGN < TkOp
+ def initialize(seek, line_no, char_no, op)
+ super(seek, line_no, char_no)
+ op = TkReading2Token[op][0] unless op.kind_of?(Symbol)
+ @op = op
+ end
+ attr_reader :op
+ end
+
+ class TkUnknownChar < Token
+ def initialize(seek, line_no, char_no, id)
+ super(seek, line_no, char_no)
+ @name = name
+ end
+ attr_reader :name
+ end
+
+ class TkError < Token
+ end
+
+ def Token(token, value = nil)
+ case token
+ when String
+ if (tk = TkReading2Token[token]).nil?
+ IRB.fail TkReading2TokenNoKey, token
+ end
+ tk = Token(tk[0], value)
+ if tk.kind_of?(TkOp)
+ tk.name = token
+ end
+ return tk
+ when Symbol
+ if (tk = TkSymbol2Token[token]).nil?
+ IRB.fail TkSymbol2TokenNoKey, token
+ end
+ return Token(tk[0], value)
+ else
+ if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
+ token.new(@prev_seek, @prev_line_no, @prev_char_no)
+ else
+ token.new(@prev_seek, @prev_line_no, @prev_char_no, value)
+ end
+ end
+ end
+
+ TokenDefinitions = [
+ [:TkCLASS, TkId, "class", EXPR_CLASS],
+ [:TkMODULE, TkId, "module", EXPR_BEG],
+ [:TkDEF, TkId, "def", EXPR_FNAME],
+ [:TkUNDEF, TkId, "undef", EXPR_FNAME],
+ [:TkBEGIN, TkId, "begin", EXPR_BEG],
+ [:TkRESCUE, TkId, "rescue", EXPR_MID],
+ [:TkENSURE, TkId, "ensure", EXPR_BEG],
+ [:TkEND, TkId, "end", EXPR_END],
+ [:TkIF, TkId, "if", EXPR_BEG, :TkIF_MOD],
+ [:TkUNLESS, TkId, "unless", EXPR_BEG, :TkUNLESS_MOD],
+ [:TkTHEN, TkId, "then", EXPR_BEG],
+ [:TkELSIF, TkId, "elsif", EXPR_BEG],
+ [:TkELSE, TkId, "else", EXPR_BEG],
+ [:TkCASE, TkId, "case", EXPR_BEG],
+ [:TkWHEN, TkId, "when", EXPR_BEG],
+ [:TkWHILE, TkId, "while", EXPR_BEG, :TkWHILE_MOD],
+ [:TkUNTIL, TkId, "until", EXPR_BEG, :TkUNTIL_MOD],
+ [:TkFOR, TkId, "for", EXPR_BEG],
+ [:TkBREAK, TkId, "break", EXPR_END],
+ [:TkNEXT, TkId, "next", EXPR_END],
+ [:TkREDO, TkId, "redo", EXPR_END],
+ [:TkRETRY, TkId, "retry", EXPR_END],
+ [:TkIN, TkId, "in", EXPR_BEG],
+ [:TkDO, TkId, "do", EXPR_BEG],
+ [:TkRETURN, TkId, "return", EXPR_MID],
+ [:TkYIELD, TkId, "yield", EXPR_END],
+ [:TkSUPER, TkId, "super", EXPR_END],
+ [:TkSELF, TkId, "self", EXPR_END],
+ [:TkNIL, TkId, "nil", EXPR_END],
+ [:TkTRUE, TkId, "true", EXPR_END],
+ [:TkFALSE, TkId, "false", EXPR_END],
+ [:TkAND, TkId, "and", EXPR_BEG],
+ [:TkOR, TkId, "or", EXPR_BEG],
+ [:TkNOT, TkId, "not", EXPR_BEG],
+ [:TkIF_MOD, TkId],
+ [:TkUNLESS_MOD, TkId],
+ [:TkWHILE_MOD, TkId],
+ [:TkUNTIL_MOD, TkId],
+ [:TkALIAS, TkId, "alias", EXPR_FNAME],
+ [:TkDEFINED, TkId, "defined?", EXPR_END],
+ [:TklBEGIN, TkId, "BEGIN", EXPR_END],
+ [:TklEND, TkId, "END", EXPR_END],
+ [:Tk__LINE__, TkId, "__LINE__", EXPR_END],
+ [:Tk__FILE__, TkId, "__FILE__", EXPR_END],
+
+ [:TkIDENTIFIER, TkId],
+ [:TkFID, TkId],
+ [:TkGVAR, TkId],
+ [:TkCVAR, TkId],
+ [:TkIVAR, TkId],
+ [:TkCONSTANT, TkId],
+
+ [:TkINTEGER, TkVal],
+ [:TkFLOAT, TkVal],
+ [:TkSTRING, TkVal],
+ [:TkXSTRING, TkVal],
+ [:TkREGEXP, TkVal],
+ [:TkSYMBOL, TkVal],
+
+ [:TkDSTRING, TkNode],
+ [:TkDXSTRING, TkNode],
+ [:TkDREGEXP, TkNode],
+ [:TkNTH_REF, TkNode],
+ [:TkBACK_REF, TkNode],
+
+ [:TkUPLUS, TkOp, "+@"],
+ [:TkUMINUS, TkOp, "-@"],
+ [:TkPOW, TkOp, "**"],
+ [:TkCMP, TkOp, "<=>"],
+ [:TkEQ, TkOp, "=="],
+ [:TkEQQ, TkOp, "==="],
+ [:TkNEQ, TkOp, "!="],
+ [:TkGEQ, TkOp, ">="],
+ [:TkLEQ, TkOp, "<="],
+ [:TkANDOP, TkOp, "&&"],
+ [:TkOROP, TkOp, "||"],
+ [:TkMATCH, TkOp, "=~"],
+ [:TkNMATCH, TkOp, "!~"],
+ [:TkDOT2, TkOp, ".."],
+ [:TkDOT3, TkOp, "..."],
+ [:TkAREF, TkOp, "[]"],
+ [:TkASET, TkOp, "[]="],
+ [:TkLSHFT, TkOp, "<<"],
+ [:TkRSHFT, TkOp, ">>"],
+ [:TkCOLON2, TkOp],
+ [:TkCOLON3, TkOp],
+ [:TkASSOC, TkOp, "=>"],
+ [:TkQUESTION, TkOp, "?"], #?
+ [:TkCOLON, TkOp, ":"], #:
+
+ [:TkfLPAREN], # func( #
+ [:TkfLBRACK], # func[ #
+ [:TkfLBRACE], # func{ #
+ [:TkSTAR], # *arg
+ [:TkAMPER], # &arg #
+ [:TkSYMBEG], # :SYMBOL
+
+ [:TkGT, TkOp, ">"],
+ [:TkLT, TkOp, "<"],
+ [:TkPLUS, TkOp, "+"],
+ [:TkMINUS, TkOp, "-"],
+ [:TkMULT, TkOp, "*"],
+ [:TkDIV, TkOp, "/"],
+ [:TkMOD, TkOp, "%"],
+ [:TkBITOR, TkOp, "|"],
+ [:TkBITXOR, TkOp, "^"],
+ [:TkBITAND, TkOp, "&"],
+ [:TkBITNOT, TkOp, "~"],
+ [:TkNOTOP, TkOp, "!"],
+
+ [:TkBACKQUOTE, TkOp, "`"],
+
+ [:TkASSIGN, Token, "="],
+ [:TkDOT, Token, "."],
+ [:TkLPAREN, Token, "("], #(exp)
+ [:TkLBRACK, Token, "["], #[arry]
+ [:TkLBRACE, Token, "{"], #{hash}
+ [:TkRPAREN, Token, ")"],
+ [:TkRBRACK, Token, "]"],
+ [:TkRBRACE, Token, "}"],
+ [:TkCOMMA, Token, ","],
+ [:TkSEMICOLON, Token, ";"],
+
+ [:TkCOMMENT],
+ [:TkRD_COMMENT],
+ [:TkSPACE],
+ [:TkNL],
+ [:TkEND_OF_SCRIPT],
+
+ [:TkBACKSLASH, TkUnknownChar, "\\"],
+ [:TkAT, TkUnknownChar, "@"],
+ [:TkDOLLAR, TkUnknownChar, "$"],
+ ]
+
+ # {reading => token_class}
+ # {reading => [token_class, *opt]}
+ TkReading2Token = {}
+ TkSymbol2Token = {}
+
+ def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
+ token_n = token_n.id2name if token_n.kind_of?(Symbol)
+ if RubyToken.const_defined?(token_n)
+ IRB.fail AlreadyDefinedToken, token_n
+ end
+ token_c = eval("class #{token_n} < #{super_token}; end; #{token_n}")
+
+ if reading
+ if TkReading2Token[reading]
+ IRB.fail TkReading2TokenDuplicateError, token_n, reading
+ end
+ if opts.empty?
+ TkReading2Token[reading] = [token_c]
+ else
+ TkReading2Token[reading] = [token_c].concat(opts)
+ end
+ end
+ TkSymbol2Token[token_n.intern] = token_c
+ end
+
+ for defs in TokenDefinitions
+ def_token(*defs)
+ end
+end
+# :startdoc:
diff --git a/lib/irb/ruby_logo.aa b/lib/irb/ruby_logo.aa
deleted file mode 100644
index a34a3e2f28..0000000000
--- a/lib/irb/ruby_logo.aa
+++ /dev/null
@@ -1,37 +0,0 @@
-
- -+smJYYN?mm-
- HB"BBYT TQg NggT
- 9Q+g Nm,T 8g NJW
- YS+ N2NJ"Sg N?
- BQg #( gT Nggggk J
- 5j NJ NJ NNge
- #Q #JJ NgT N(
- @j bj mT J
- Bj @/d NJ (
- #q #(( NgT #J
- 5d #(t mT $d
- #q @(@J NJB;
- @( 5d ? HHH H HQmgggggggmN qD
- 5d #uN 2QdH E O
- 5 5JSd Nd NJH @d j
- Fd @J4d s NQH #d (
- #( #o6d Nd NgH #d #d
- 4 B&Od v NgT #d F
- #( 9JGd NH NgUd F
- #d #GJQ d NP $
- #J #U+#Q N Q # j
- j /W BQ+ BQ d NJ NJ
- - NjJH HBIjTQggPJQgW N W k #J
- #J b HYWgggN j s Nag d NN b #d
- #J 5- D s Ngg N d Nd F
- Fd BKH2 #+ s NNgg J Q J ]
- F H @ J N y K(d P I
- F4 E N? #d y #Q NJ E j
- F W Nd q m Bg NxW N(H-
- F d b @ m Hd gW vKJ
- NJ d K d s Bg aT FDd
- b # d N m BQ mV N>
- e5 Nd #d NggggggQWH HHHH NJ -
- m7 NW H N HSVO1z=?11-
- NgTH bB kH WBHWWHBHWmQgg&gggggNNN
- NNggggggNN
diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb
new file mode 100644
index 0000000000..039b214a8d
--- /dev/null
+++ b/lib/irb/slex.rb
@@ -0,0 +1,282 @@
+# frozen_string_literal: false
+#
+# irb/slex.rb - simple lex analyzer
+# $Release Version: 0.9.6$
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+require "e2mmap"
+require "irb/notifier"
+
+# :stopdoc:
+module IRB
+ class SLex
+
+ extend Exception2MessageMapper
+ def_exception :ErrNodeNothing, "node nothing"
+ def_exception :ErrNodeAlreadyExists, "node already exists"
+
+ DOUT = Notifier::def_notifier("SLex::")
+ D_WARN = DOUT::def_notifier(1, "Warn: ")
+ D_DEBUG = DOUT::def_notifier(2, "Debug: ")
+ D_DETAIL = DOUT::def_notifier(4, "Detail: ")
+
+ DOUT.level = Notifier::D_NOMSG
+
+ def initialize
+ @head = Node.new("")
+ end
+
+ def def_rule(token, preproc = nil, postproc = nil, &block)
+ D_DETAIL.pp token
+
+ postproc = block if block_given?
+ create(token, preproc, postproc)
+ end
+
+ def def_rules(*tokens, &block)
+ if block_given?
+ p = block
+ end
+ for token in tokens
+ def_rule(token, nil, p)
+ end
+ end
+
+ def preproc(token, proc)
+ node = search(token)
+ node.preproc=proc
+ end
+
+ # need a check?
+ def postproc(token)
+ node = search(token, proc)
+ node.postproc=proc
+ end
+
+ def search(token)
+ @head.search(token.split(//))
+ end
+
+ def create(token, preproc = nil, postproc = nil)
+ @head.create_subnode(token.split(//), preproc, postproc)
+ end
+
+ def match(token)
+ case token
+ when Array
+ when String
+ return match(token.split(//))
+ else
+ return @head.match_io(token)
+ end
+ ret = @head.match(token)
+ D_DETAIL.exec_if{D_DETAIL.printf "match end: %s:%s\n", ret, token.inspect}
+ ret
+ end
+
+ def inspect
+ format("<SLex: @head = %s>", @head.inspect)
+ end
+
+ #----------------------------------------------------------------------
+ #
+ # class Node -
+ #
+ #----------------------------------------------------------------------
+ class Node
+ # if postproc is nil, this node is an abstract node.
+ # if postproc is non-nil, this node is a real node.
+ def initialize(preproc = nil, postproc = nil)
+ @Tree = {}
+ @preproc = preproc
+ @postproc = postproc
+ end
+
+ attr_accessor :preproc
+ attr_accessor :postproc
+
+ def search(chrs, opt = nil)
+ return self if chrs.empty?
+ ch = chrs.shift
+ if node = @Tree[ch]
+ node.search(chrs, opt)
+ else
+ if opt
+ chrs.unshift ch
+ self.create_subnode(chrs)
+ else
+ SLex.fail ErrNodeNothing
+ end
+ end
+ end
+
+ def create_subnode(chrs, preproc = nil, postproc = nil)
+ if chrs.empty?
+ if @postproc
+ D_DETAIL.pp node
+ SLex.fail ErrNodeAlreadyExists
+ else
+ D_DEBUG.puts "change abstract node to real node."
+ @preproc = preproc
+ @postproc = postproc
+ end
+ return self
+ end
+
+ ch = chrs.shift
+ if node = @Tree[ch]
+ if chrs.empty?
+ if node.postproc
+ DebugLogger.pp node
+ DebugLogger.pp self
+ DebugLogger.pp ch
+ DebugLogger.pp chrs
+ SLex.fail ErrNodeAlreadyExists
+ else
+ D_WARN.puts "change abstract node to real node"
+ node.preproc = preproc
+ node.postproc = postproc
+ end
+ else
+ node.create_subnode(chrs, preproc, postproc)
+ end
+ else
+ if chrs.empty?
+ node = Node.new(preproc, postproc)
+ else
+ node = Node.new
+ node.create_subnode(chrs, preproc, postproc)
+ end
+ @Tree[ch] = node
+ end
+ node
+ end
+
+ #
+ # chrs: String
+ # character array
+ # io must have getc()/ungetc(); and ungetc() must be
+ # able to be called arbitrary number of times.
+ #
+ def match(chrs, op = "")
+ D_DETAIL.print "match>: ", chrs, "op:", op, "\n"
+ if chrs.empty?
+ if @preproc.nil? || @preproc.call(op, chrs)
+ DOUT.printf(D_DETAIL, "op1: %s\n", op)
+ @postproc.call(op, chrs)
+ else
+ nil
+ end
+ else
+ ch = chrs.shift
+ if node = @Tree[ch]
+ if ret = node.match(chrs, op+ch)
+ return ret
+ else
+ chrs.unshift ch
+ if @postproc and @preproc.nil? || @preproc.call(op, chrs)
+ DOUT.printf(D_DETAIL, "op2: %s\n", op.inspect)
+ ret = @postproc.call(op, chrs)
+ return ret
+ else
+ return nil
+ end
+ end
+ else
+ chrs.unshift ch
+ if @postproc and @preproc.nil? || @preproc.call(op, chrs)
+ DOUT.printf(D_DETAIL, "op3: %s\n", op)
+ @postproc.call(op, chrs)
+ return ""
+ else
+ return nil
+ end
+ end
+ end
+ end
+
+ def match_io(io, op = "")
+ if op == ""
+ ch = io.getc
+ if ch == nil
+ return nil
+ end
+ else
+ ch = io.getc_of_rests
+ end
+ if ch.nil?
+ if @preproc.nil? || @preproc.call(op, io)
+ D_DETAIL.printf("op1: %s\n", op)
+ @postproc.call(op, io)
+ else
+ nil
+ end
+ else
+ if node = @Tree[ch]
+ if ret = node.match_io(io, op+ch)
+ ret
+ else
+ io.ungetc ch
+ if @postproc and @preproc.nil? || @preproc.call(op, io)
+ DOUT.exec_if{D_DETAIL.printf "op2: %s\n", op.inspect}
+ @postproc.call(op, io)
+ else
+ nil
+ end
+ end
+ else
+ io.ungetc ch
+ if @postproc and @preproc.nil? || @preproc.call(op, io)
+ D_DETAIL.printf("op3: %s\n", op)
+ @postproc.call(op, io)
+ else
+ nil
+ end
+ end
+ end
+ end
+ end
+ end
+end
+# :startdoc:
+
+if $0 == __FILE__
+ case $1
+ when "1"
+ tr = SLex.new
+ print "0: ", tr.inspect, "\n"
+ tr.def_rule("=") {print "=\n"}
+ print "1: ", tr.inspect, "\n"
+ tr.def_rule("==") {print "==\n"}
+ print "2: ", tr.inspect, "\n"
+
+ print "case 1:\n"
+ print tr.match("="), "\n"
+ print "case 2:\n"
+ print tr.match("=="), "\n"
+ print "case 3:\n"
+ print tr.match("=>"), "\n"
+
+ when "2"
+ tr = SLex.new
+ print "0: ", tr.inspect, "\n"
+ tr.def_rule("=") {print "=\n"}
+ print "1: ", tr.inspect, "\n"
+ tr.def_rule("==", proc{false}) {print "==\n"}
+ print "2: ", tr.inspect, "\n"
+
+ print "case 1:\n"
+ print tr.match("="), "\n"
+ print "case 2:\n"
+ print tr.match("=="), "\n"
+ print "case 3:\n"
+ print tr.match("=>"), "\n"
+ end
+ exit
+end
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
index 8b61eb3ef9..094cb33c05 100644
--- a/lib/irb/version.rb
+++ b/lib/irb/version.rb
@@ -11,7 +11,6 @@
#
module IRB # :nodoc:
- VERSION = "1.2.6"
- @RELEASE_VERSION = VERSION
- @LAST_UPDATE_DATE = "2020-09-14"
+ @RELEASE_VERSION = "0.9.6"
+ @LAST_UPDATE_DATE = "09/06/30"
end
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index 794a511521..9ce84b60fa 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -9,9 +9,6 @@
#
#
#
-
-require "delegate"
-
module IRB # :nodoc:
class WorkSpace
# Creates a new workspace.
@@ -52,21 +49,17 @@ EOF
@binding = BINDING_QUEUE.pop
when 3 # binding in function on TOPLEVEL_BINDING(default)
- @binding = eval("self.class.send(:remove_method, :irb_binding) if defined?(irb_binding); private; def irb_binding; binding; end; irb_binding",
+ @binding = eval("def irb_binding; private; binding; end; irb_binding",
TOPLEVEL_BINDING,
__FILE__,
__LINE__ - 3)
end
end
-
if main.empty?
@main = eval("self", @binding)
else
@main = main[0]
- end
- IRB.conf[:__MAIN__] = @main
-
- unless main.empty?
+ IRB.conf[:__MAIN__] = @main
case @main
when Module
@binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
@@ -74,33 +67,11 @@ EOF
begin
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
rescue TypeError
- fail CantChangeBinding, @main.inspect
- end
- end
- end
-
- case @main
- when Object
- use_delegator = @main.frozen?
- else
- use_delegator = true
- end
-
- if use_delegator
- @main = SimpleDelegator.new(@main)
- IRB.conf[:__MAIN__] = @main
- @main.singleton_class.class_eval do
- private
- define_method(:exit) do |*a, &b|
- # Do nothing, will be overridden
+ IRB.fail CantChangeBinding, @main.inspect
end
- define_method(:binding, Kernel.instance_method(:binding))
- define_method(:local_variables, Kernel.instance_method(:local_variables))
end
- @binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, *@binding.source_location)
end
-
- @binding.local_variable_set(:_, nil)
+ eval("_=nil", @binding)
end
# The Binding of this workspace
@@ -114,65 +85,48 @@ EOF
eval(statements, @binding, file, line)
end
- def local_variable_set(name, value)
- @binding.local_variable_set(name, value)
- end
-
- def local_variable_get(name)
- @binding.local_variable_get(name)
- end
-
# error message manipulator
def filter_backtrace(bt)
- return nil if bt =~ /\/irb\/.*\.rb/
- return nil if bt =~ /\/irb\.rb/
case IRB.conf[:CONTEXT_MODE]
+ when 0
+ return nil if bt =~ /\(irb_local_binding\)/
when 1
- return nil if bt =~ %r!/tmp/irb-binding!
+ if(bt =~ %r!/tmp/irb-binding! or
+ bt =~ %r!irb/.*\.rb! or
+ bt =~ /irb\.rb/)
+ return nil
+ end
+ when 2
+ return nil if bt =~ /irb\/.*\.rb/
+ return nil if bt =~ /irb\.rb/
when 3
+ return nil if bt =~ /irb\/.*\.rb/
+ return nil if bt =~ /irb\.rb/
bt = bt.sub(/:\s*in `irb_binding'/, '')
end
bt
end
def code_around_binding
- if @binding.respond_to?(:source_location)
- file, pos = @binding.source_location
- else
- file, pos = @binding.eval('[__FILE__, __LINE__]')
- end
+ file, pos = @binding.eval('[__FILE__, __LINE__]')
- if defined?(::SCRIPT_LINES__[file]) && lines = ::SCRIPT_LINES__[file]
- code = ::SCRIPT_LINES__[file].join('')
- else
+ unless defined?(::SCRIPT_LINES__[file]) && lines = ::SCRIPT_LINES__[file]
begin
- code = File.read(file)
+ lines = File.readlines(file)
rescue SystemCallError
return
end
end
-
- # NOT using #use_colorize? of IRB.conf[:MAIN_CONTEXT] because this method may be called before IRB::Irb#run
- use_colorize = IRB.conf.fetch(:USE_COLORIZE, true)
- if use_colorize
- lines = Color.colorize_code(code).lines
- else
- lines = code.lines
- end
pos -= 1
start_pos = [pos - 5, 0].max
end_pos = [pos + 5, lines.size - 1].min
- if use_colorize
- fmt = " %2s #{Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])}: %s"
- else
- fmt = " %2s %#{end_pos.to_s.length}d: %s"
- end
+ fmt = " %2s %#{end_pos.to_s.length}d: %s"
body = (start_pos..end_pos).map do |current_pos|
sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos])
end.join("")
- "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
+ "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}\n"
end
def IRB.delete_caller
diff --git a/lib/irb/xmp.rb b/lib/irb/xmp.rb
index 88cbd88525..3234cff7f3 100644
--- a/lib/irb/xmp.rb
+++ b/lib/irb/xmp.rb
@@ -10,8 +10,8 @@
#
#
-require_relative "../irb"
-require_relative "frame"
+require "irb"
+require "irb/frame"
# An example printer for irb.
#
diff --git a/lib/logger.rb b/lib/logger.rb
index f0b99f75a2..4ccc03b614 100644
--- a/lib/logger.rb
+++ b/lib/logger.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: true
+# frozen_string_literal: false
# logger.rb - simple logging utility
# Copyright (C) 2000-2003, 2005, 2008, 2011 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
#
@@ -12,12 +12,6 @@
require 'monitor'
-require_relative 'logger/version'
-require_relative 'logger/formatter'
-require_relative 'logger/log_device'
-require_relative 'logger/severity'
-require_relative 'logger/errors'
-
# == Description
#
# The Logger class provides a simple but sophisticated logging utility that
@@ -115,7 +109,7 @@ require_relative 'logger/errors'
# 3. Create a logger for the specified file.
#
# file = File.open('foo.log', File::WRONLY | File::APPEND)
-# # To create new logfile, add File::CREAT like:
+# # To create new (and to remove old) logfile, add File::CREAT like:
# # file = File.open('foo.log', File::WRONLY | File::APPEND | File::CREAT)
# logger = Logger.new(file)
#
@@ -230,6 +224,7 @@ require_relative 'logger/errors'
# })
#
class Logger
+ VERSION = "1.2.7"
_, name, rev = %w$Id$
if name
name = name.chomp(",v")
@@ -237,8 +232,29 @@ class Logger
name = File.basename(__FILE__)
end
rev ||= "v#{VERSION}"
- ProgName = "#{name}/#{rev}"
+ ProgName = "#{name}/#{rev}".freeze
+
+ class Error < RuntimeError # :nodoc:
+ end
+ # not used after 1.2.7. just for compat.
+ class ShiftingError < Error # :nodoc:
+ end
+ # Logging severity.
+ module Severity
+ # Low-level information, mostly for developers.
+ DEBUG = 0
+ # Generic (useful) information about system operation.
+ INFO = 1
+ # A warning.
+ WARN = 2
+ # A handleable error condition.
+ ERROR = 3
+ # An unhandleable error that results in a program crash.
+ FATAL = 4
+ # An unknown message that should always be logged.
+ UNKNOWN = 5
+ end
include Severity
# Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
@@ -304,38 +320,23 @@ class Logger
# Returns +true+ iff the current severity level allows for the printing of
# +DEBUG+ messages.
- def debug?; level <= DEBUG; end
-
- # Sets the severity to DEBUG.
- def debug!; self.level = DEBUG; end
+ def debug?; @level <= DEBUG; end
# Returns +true+ iff the current severity level allows for the printing of
# +INFO+ messages.
- def info?; level <= INFO; end
-
- # Sets the severity to INFO.
- def info!; self.level = INFO; end
+ def info?; @level <= INFO; end
# Returns +true+ iff the current severity level allows for the printing of
# +WARN+ messages.
- def warn?; level <= WARN; end
-
- # Sets the severity to WARN.
- def warn!; self.level = WARN; end
+ def warn?; @level <= WARN; end
# Returns +true+ iff the current severity level allows for the printing of
# +ERROR+ messages.
- def error?; level <= ERROR; end
-
- # Sets the severity to ERROR.
- def error!; self.level = ERROR; end
+ def error?; @level <= ERROR; end
# Returns +true+ iff the current severity level allows for the printing of
# +FATAL+ messages.
- def fatal?; level <= FATAL; end
-
- # Sets the severity to FATAL.
- def fatal!; self.level = FATAL; end
+ def fatal?; @level <= FATAL; end
#
# :call-seq:
@@ -353,11 +354,10 @@ class Logger
# +STDOUT+, +STDERR+, or an open file).
# +shift_age+::
# Number of old log files to keep, *or* frequency of rotation (+daily+,
- # +weekly+ or +monthly+). Default value is 0, which disables log file
- # rotation.
+ # +weekly+ or +monthly+). Default value is 0.
# +shift_size+::
- # Maximum logfile size in bytes (only applies when +shift_age+ is a positive
- # Integer). Defaults to +1048576+ (1MB).
+ # Maximum logfile size in bytes (only applies when +shift_age+ is a number).
+ # Defaults to +1048576+ (1MB).
# +level+::
# Logging severity threshold. Default values is Logger::DEBUG.
# +progname+::
@@ -366,8 +366,6 @@ class Logger
# Logging formatter. Default values is an instance of Logger::Formatter.
# +datetime_format+::
# Date and time format. Default value is '%Y-%m-%d %H:%M:%S'.
- # +binmode+::
- # Use binary mode on the log device. Default value is false.
# +shift_period_suffix+::
# The log file suffix format for +daily+, +weekly+ or +monthly+ rotation.
# Default is '%Y%m%d'.
@@ -378,7 +376,7 @@ class Logger
#
def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG,
progname: nil, formatter: nil, datetime_format: nil,
- binmode: false, shift_period_suffix: '%Y%m%d')
+ shift_period_suffix: '%Y%m%d')
self.level = level
self.progname = progname
@default_formatter = Formatter.new
@@ -386,10 +384,9 @@ class Logger
self.formatter = formatter
@logdev = nil
if logdev
- @logdev = LogDevice.new(logdev, shift_age: shift_age,
- shift_size: shift_size,
- shift_period_suffix: shift_period_suffix,
- binmode: binmode)
+ @logdev = LogDevice.new(logdev, :shift_age => shift_age,
+ :shift_size => shift_size,
+ :shift_period_suffix => shift_period_suffix)
end
end
@@ -457,7 +454,7 @@ class Logger
#
def add(severity, message = nil, progname = nil)
severity ||= UNKNOWN
- if @logdev.nil? or severity < level
+ if @logdev.nil? or severity < @level
return true
end
if progname.nil?
@@ -482,7 +479,9 @@ class Logger
# device exists, return +nil+.
#
def <<(msg)
- @logdev&.write(msg)
+ unless @logdev.nil?
+ @logdev.write(msg)
+ end
end
#
@@ -569,13 +568,13 @@ class Logger
# Close the logging device.
#
def close
- @logdev&.close
+ @logdev.close if @logdev
end
private
# Severity label for logging (max 5 chars).
- SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY).freeze
+ SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY).each(&:freeze).freeze
def format_severity(severity)
SEV_LABEL[severity] || 'ANY'
@@ -584,4 +583,273 @@ private
def format_message(severity, datetime, progname, msg)
(@formatter || @default_formatter).call(severity, datetime, progname, msg)
end
+
+
+ # Default formatter for log messages.
+ class Formatter
+ Format = "%s, [%s#%d] %5s -- %s: %s\n".freeze
+
+ attr_accessor :datetime_format
+
+ def initialize
+ @datetime_format = nil
+ end
+
+ def call(severity, time, progname, msg)
+ Format % [severity[0..0], format_datetime(time), $$, severity, progname,
+ msg2str(msg)]
+ end
+
+ private
+
+ def format_datetime(time)
+ time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze)
+ end
+
+ def msg2str(msg)
+ case msg
+ when ::String
+ msg
+ when ::Exception
+ "#{ msg.message } (#{ msg.class })\n" <<
+ (msg.backtrace || []).join("\n")
+ else
+ msg.inspect
+ end
+ end
+ end
+
+ module Period
+ module_function
+
+ SiD = 24 * 60 * 60
+
+ def next_rotate_time(now, shift_age)
+ case shift_age
+ when 'daily'
+ t = Time.mktime(now.year, now.month, now.mday) + SiD
+ when 'weekly'
+ t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
+ when 'monthly'
+ t = Time.mktime(now.year, now.month, 1) + SiD * 32
+ return Time.mktime(t.year, t.month, 1)
+ else
+ return now
+ end
+ if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
+ hour = t.hour
+ t = Time.mktime(t.year, t.month, t.mday)
+ t += SiD if hour > 12
+ end
+ t
+ end
+
+ def previous_period_end(now, shift_age)
+ case shift_age
+ when 'daily'
+ t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
+ when 'weekly'
+ t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
+ when 'monthly'
+ t = Time.mktime(now.year, now.month, 1) - SiD / 2
+ else
+ return now
+ end
+ Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
+ end
+ end
+
+ # Device used for logging messages.
+ class LogDevice
+ include Period
+
+ attr_reader :dev
+ attr_reader :filename
+ include MonitorMixin
+
+ def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil)
+ @dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil
+ mon_initialize
+ set_dev(log)
+ if @filename
+ @shift_age = shift_age || 7
+ @shift_size = shift_size || 1048576
+ @shift_period_suffix = shift_period_suffix || '%Y%m%d'
+
+ unless @shift_age.is_a?(Integer)
+ base_time = @dev.respond_to?(:stat) ? @dev.stat.mtime : Time.now
+ @next_rotate_time = next_rotate_time(base_time, @shift_age)
+ end
+ end
+ end
+
+ def write(message)
+ begin
+ synchronize do
+ if @shift_age and @dev.respond_to?(:stat)
+ begin
+ check_shift_log
+ rescue
+ warn("log shifting failed. #{$!}")
+ end
+ end
+ begin
+ @dev.write(message)
+ rescue
+ warn("log writing failed. #{$!}")
+ end
+ end
+ rescue Exception => ignored
+ warn("log writing failed. #{ignored}")
+ end
+ end
+
+ def close
+ begin
+ synchronize do
+ @dev.close rescue nil
+ end
+ rescue Exception
+ @dev.close rescue nil
+ end
+ end
+
+ def reopen(log = nil)
+ # reopen the same filename if no argument, do nothing for IO
+ log ||= @filename if @filename
+ if log
+ synchronize do
+ if @filename and @dev
+ @dev.close rescue nil # close only file opened by Logger
+ @filename = nil
+ end
+ set_dev(log)
+ end
+ end
+ self
+ end
+
+ private
+
+ def set_dev(log)
+ if log.respond_to?(:write) and log.respond_to?(:close)
+ @dev = log
+ else
+ @dev = open_logfile(log)
+ @dev.sync = true
+ @filename = log
+ end
+ end
+
+ def open_logfile(filename)
+ begin
+ File.open(filename, (File::WRONLY | File::APPEND))
+ rescue Errno::ENOENT
+ create_logfile(filename)
+ end
+ end
+
+ def create_logfile(filename)
+ begin
+ logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL))
+ logdev.flock(File::LOCK_EX)
+ logdev.sync = true
+ add_log_header(logdev)
+ logdev.flock(File::LOCK_UN)
+ rescue Errno::EEXIST
+ # file is created by another process
+ logdev = open_logfile(filename)
+ logdev.sync = true
+ end
+ logdev
+ end
+
+ def add_log_header(file)
+ file.write(
+ "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName]
+ ) if file.size == 0
+ end
+
+ def check_shift_log
+ if @shift_age.is_a?(Integer)
+ # Note: always returns false if '0'.
+ if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)
+ lock_shift_log { shift_log_age }
+ end
+ else
+ now = Time.now
+ if now >= @next_rotate_time
+ @next_rotate_time = next_rotate_time(now, @shift_age)
+ lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) }
+ end
+ end
+ end
+
+ if /mswin|mingw/ =~ RUBY_PLATFORM
+ def lock_shift_log
+ yield
+ end
+ else
+ def lock_shift_log
+ retry_limit = 8
+ retry_sleep = 0.1
+ begin
+ File.open(@filename, File::WRONLY | File::APPEND) do |lock|
+ lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
+ if File.identical?(@filename, lock) and File.identical?(lock, @dev)
+ yield # log shifting
+ else
+ # log shifted by another process (i-node before locking and i-node after locking are different)
+ @dev.close rescue nil
+ @dev = open_logfile(@filename)
+ @dev.sync = true
+ end
+ end
+ rescue Errno::ENOENT
+ # @filename file would not exist right after #rename and before #create_logfile
+ if retry_limit <= 0
+ warn("log rotation inter-process lock failed. #{$!}")
+ else
+ sleep retry_sleep
+ retry_limit -= 1
+ retry_sleep *= 2
+ retry
+ end
+ end
+ rescue
+ warn("log rotation inter-process lock failed. #{$!}")
+ end
+ end
+
+ def shift_log_age
+ (@shift_age-3).downto(0) do |i|
+ if FileTest.exist?("#{@filename}.#{i}")
+ File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}")
+ end
+ end
+ @dev.close rescue nil
+ File.rename("#{@filename}", "#{@filename}.0")
+ @dev = create_logfile(@filename)
+ return true
+ end
+
+ def shift_log_period(period_end)
+ suffix = period_end.strftime(@shift_period_suffix)
+ age_file = "#{@filename}.#{suffix}"
+ if FileTest.exist?(age_file)
+ # try to avoid filename crash caused by Timestamp change.
+ idx = 0
+ # .99 can be overridden; avoid too much file search with 'loop do'
+ while idx < 100
+ idx += 1
+ age_file = "#{@filename}.#{suffix}.#{idx}"
+ break unless FileTest.exist?(age_file)
+ end
+ end
+ @dev.close rescue nil
+ File.rename("#{@filename}", age_file)
+ @dev = create_logfile(@filename)
+ return true
+ end
+ end
end
diff --git a/lib/logger/errors.rb b/lib/logger/errors.rb
deleted file mode 100644
index e8925e14ac..0000000000
--- a/lib/logger/errors.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-# not used after 1.2.7. just for compat.
-class Logger
- class Error < RuntimeError # :nodoc:
- end
- class ShiftingError < Error # :nodoc:
- end
-end
diff --git a/lib/logger/formatter.rb b/lib/logger/formatter.rb
deleted file mode 100644
index 852cffe033..0000000000
--- a/lib/logger/formatter.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- # Default formatter for log messages.
- class Formatter
- Format = "%s, [%s#%d] %5s -- %s: %s\n"
-
- attr_accessor :datetime_format
-
- def initialize
- @datetime_format = nil
- end
-
- def call(severity, time, progname, msg)
- Format % [severity[0..0], format_datetime(time), $$, severity, progname,
- msg2str(msg)]
- end
-
- private
-
- def format_datetime(time)
- time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ")
- end
-
- def msg2str(msg)
- case msg
- when ::String
- msg
- when ::Exception
- "#{ msg.message } (#{ msg.class })\n#{ msg.backtrace.join("\n") if msg.backtrace }"
- else
- msg.inspect
- end
- end
- end
-end
diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb
deleted file mode 100644
index fe7d54fb81..0000000000
--- a/lib/logger/log_device.rb
+++ /dev/null
@@ -1,205 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'period'
-
-class Logger
- # Device used for logging messages.
- class LogDevice
- include Period
-
- attr_reader :dev
- attr_reader :filename
- include MonitorMixin
-
- def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false)
- @dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil
- @binmode = binmode
- mon_initialize
- set_dev(log)
- if @filename
- @shift_age = shift_age || 7
- @shift_size = shift_size || 1048576
- @shift_period_suffix = shift_period_suffix || '%Y%m%d'
-
- unless @shift_age.is_a?(Integer)
- base_time = @dev.respond_to?(:stat) ? @dev.stat.mtime : Time.now
- @next_rotate_time = next_rotate_time(base_time, @shift_age)
- end
- end
- end
-
- def write(message)
- begin
- synchronize do
- if @shift_age and @dev.respond_to?(:stat)
- begin
- check_shift_log
- rescue
- warn("log shifting failed. #{$!}")
- end
- end
- begin
- @dev.write(message)
- rescue
- warn("log writing failed. #{$!}")
- end
- end
- rescue Exception => ignored
- warn("log writing failed. #{ignored}")
- end
- end
-
- def close
- begin
- synchronize do
- @dev.close rescue nil
- end
- rescue Exception
- @dev.close rescue nil
- end
- end
-
- def reopen(log = nil)
- # reopen the same filename if no argument, do nothing for IO
- log ||= @filename if @filename
- if log
- synchronize do
- if @filename and @dev
- @dev.close rescue nil # close only file opened by Logger
- @filename = nil
- end
- set_dev(log)
- end
- end
- self
- end
-
- private
-
- def set_dev(log)
- if log.respond_to?(:write) and log.respond_to?(:close)
- @dev = log
- if log.respond_to?(:path)
- @filename = log.path
- end
- else
- @dev = open_logfile(log)
- @dev.sync = true
- @dev.binmode if @binmode
- @filename = log
- end
- end
-
- def open_logfile(filename)
- begin
- File.open(filename, (File::WRONLY | File::APPEND))
- rescue Errno::ENOENT
- create_logfile(filename)
- end
- end
-
- def create_logfile(filename)
- begin
- logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL))
- logdev.flock(File::LOCK_EX)
- logdev.sync = true
- logdev.binmode if @binmode
- add_log_header(logdev)
- logdev.flock(File::LOCK_UN)
- rescue Errno::EEXIST
- # file is created by another process
- logdev = open_logfile(filename)
- logdev.sync = true
- end
- logdev
- end
-
- def add_log_header(file)
- file.write(
- "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName]
- ) if file.size == 0
- end
-
- def check_shift_log
- if @shift_age.is_a?(Integer)
- # Note: always returns false if '0'.
- if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)
- lock_shift_log { shift_log_age }
- end
- else
- now = Time.now
- if now >= @next_rotate_time
- @next_rotate_time = next_rotate_time(now, @shift_age)
- lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) }
- end
- end
- end
-
- if /mswin|mingw/ =~ RUBY_PLATFORM
- def lock_shift_log
- yield
- end
- else
- def lock_shift_log
- retry_limit = 8
- retry_sleep = 0.1
- begin
- File.open(@filename, File::WRONLY | File::APPEND) do |lock|
- lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
- if File.identical?(@filename, lock) and File.identical?(lock, @dev)
- yield # log shifting
- else
- # log shifted by another process (i-node before locking and i-node after locking are different)
- @dev.close rescue nil
- @dev = open_logfile(@filename)
- @dev.sync = true
- end
- end
- rescue Errno::ENOENT
- # @filename file would not exist right after #rename and before #create_logfile
- if retry_limit <= 0
- warn("log rotation inter-process lock failed. #{$!}")
- else
- sleep retry_sleep
- retry_limit -= 1
- retry_sleep *= 2
- retry
- end
- end
- rescue
- warn("log rotation inter-process lock failed. #{$!}")
- end
- end
-
- def shift_log_age
- (@shift_age-3).downto(0) do |i|
- if FileTest.exist?("#{@filename}.#{i}")
- File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}")
- end
- end
- @dev.close rescue nil
- File.rename("#{@filename}", "#{@filename}.0")
- @dev = create_logfile(@filename)
- return true
- end
-
- def shift_log_period(period_end)
- suffix = period_end.strftime(@shift_period_suffix)
- age_file = "#{@filename}.#{suffix}"
- if FileTest.exist?(age_file)
- # try to avoid filename crash caused by Timestamp change.
- idx = 0
- # .99 can be overridden; avoid too much file search with 'loop do'
- while idx < 100
- idx += 1
- age_file = "#{@filename}.#{suffix}.#{idx}"
- break unless FileTest.exist?(age_file)
- end
- end
- @dev.close rescue nil
- File.rename("#{@filename}", age_file)
- @dev = create_logfile(@filename)
- return true
- end
- end
-end
diff --git a/lib/logger/logger.gemspec b/lib/logger/logger.gemspec
deleted file mode 100644
index 8b3f70627a..0000000000
--- a/lib/logger/logger.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/logger/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "logger"
- spec.version = Logger::VERSION
- spec.authors = ["Naotoshi Seo", "SHIBATA Hiroshi"]
- spec.email = ["sonots@gmail.com", "hsbt@ruby-lang.org"]
-
- spec.summary = %q{Provides a simple logging utility for outputting messages.}
- spec.description = %q{Provides a simple logging utility for outputting messages.}
- spec.homepage = "https://github.com/ruby/logger"
- spec.license = "BSD-2-Clause"
-
- spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.required_ruby_version = ">= 2.3.0"
-
- spec.add_development_dependency "bundler", ">= 0"
- spec.add_development_dependency "rake", "~> 10.0"
- spec.add_development_dependency "test-unit"
- spec.add_development_dependency "rdoc"
-end
diff --git a/lib/logger/period.rb b/lib/logger/period.rb
deleted file mode 100644
index 0a291dbbbe..0000000000
--- a/lib/logger/period.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- module Period
- module_function
-
- SiD = 24 * 60 * 60
-
- def next_rotate_time(now, shift_age)
- case shift_age
- when 'daily'
- t = Time.mktime(now.year, now.month, now.mday) + SiD
- when 'weekly'
- t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
- when 'monthly'
- t = Time.mktime(now.year, now.month, 1) + SiD * 32
- return Time.mktime(t.year, t.month, 1)
- when 'now', 'everytime'
- return now
- else
- raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
- end
- if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
- hour = t.hour
- t = Time.mktime(t.year, t.month, t.mday)
- t += SiD if hour > 12
- end
- t
- end
-
- def previous_period_end(now, shift_age)
- case shift_age
- when 'daily'
- t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
- when 'weekly'
- t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
- when 'monthly'
- t = Time.mktime(now.year, now.month, 1) - SiD / 2
- when 'now', 'everytime'
- return now
- else
- raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
- end
- Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
- end
- end
-end
diff --git a/lib/logger/severity.rb b/lib/logger/severity.rb
deleted file mode 100644
index b38afb7d22..0000000000
--- a/lib/logger/severity.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- # Logging severity.
- module Severity
- # Low-level information, mostly for developers.
- DEBUG = 0
- # Generic (useful) information about system operation.
- INFO = 1
- # A warning.
- WARN = 2
- # A handleable error condition.
- ERROR = 3
- # An unhandleable error that results in a program crash.
- FATAL = 4
- # An unknown message that should always be logged.
- UNKNOWN = 5
- end
-end
diff --git a/lib/logger/version.rb b/lib/logger/version.rb
deleted file mode 100644
index f90ce94e49..0000000000
--- a/lib/logger/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- VERSION = "1.4.2"
-end
diff --git a/lib/matrix.rb b/lib/matrix.rb
index fc0e8ef2f7..923e716b35 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -12,44 +12,17 @@
# Original Documentation:: Gavin Sinclair (sourced from <i>Ruby in a Nutshell</i> (Matsumoto, O'Reilly))
##
-require_relative "matrix/version"
+require "e2mmap.rb"
module ExceptionForMatrix # :nodoc:
- class ErrDimensionMismatch < StandardError
- def initialize(val = nil)
- if val
- super(val)
- else
- super("Dimension mismatch")
- end
- end
- end
-
- class ErrNotRegular < StandardError
- def initialize(val = nil)
- if val
- super(val)
- else
- super("Not Regular Matrix")
- end
- end
- end
-
- class ErrOperationNotDefined < StandardError
- def initialize(vals)
- if vals.is_a?(Array)
- super("Operation(#{vals[0]}) can\\'t be defined: #{vals[1]} op #{vals[2]}")
- else
- super(vals)
- end
- end
- end
-
- class ErrOperationNotImplemented < StandardError
- def initialize(vals)
- super("Sorry, Operation(#{vals[0]}) not implemented: #{vals[1]} op #{vals[2]}")
- end
- end
+ extend Exception2MessageMapper
+ def_e2message(TypeError, "wrong argument type %s (expected %s)")
+ def_e2message(ArgumentError, "Wrong # of arguments(%d for %d)")
+
+ def_exception("ErrDimensionMismatch", "\#{self.name} dimension mismatch")
+ def_exception("ErrNotRegular", "Not Regular Matrix")
+ def_exception("ErrOperationNotDefined", "Operation(%s) can\\'t be defined: %s op %s")
+ def_exception("ErrOperationNotImplemented", "Sorry, Operation(%s) not implemented: %s op %s")
end
#
@@ -172,8 +145,8 @@ class Matrix
scalar(n, 1)
end
class << Matrix
- alias_method :unit, :identity
- alias_method :I, :identity
+ alias unit identity
+ alias I identity
end
#
@@ -290,7 +263,7 @@ class Matrix
matrices.map!(&CoercionHelper.method(:coerce_to_matrix))
x = matrices.first
matrices.each do |m|
- raise ErrDimensionMismatch unless x.row_count == m.row_count && x.column_count == m.column_count
+ Matrix.Raise ErrDimensionMismatch unless x.row_count == m.row_count && x.column_count == m.column_count
end
rows = Array.new(x.row_count) do |i|
@@ -316,9 +289,10 @@ class Matrix
@column_count = column_count
end
- private def new_matrix(rows, column_count = rows[0].size) # :nodoc:
+ def new_matrix(rows, column_count = rows[0].size) # :nodoc:
self.class.send(:new, rows, column_count) # bypass privacy of Matrix.new
end
+ private :new_matrix
#
# Returns element (+i+,+j+) of the matrix. That is: row +i+, column +j+.
@@ -329,107 +303,12 @@ class Matrix
alias element []
alias component []
- #
- # :call-seq:
- # matrix[range, range] = matrix/element
- # matrix[range, integer] = vector/column_matrix/element
- # matrix[integer, range] = vector/row_matrix/element
- # matrix[integer, integer] = element
- #
- # Set element or elements of matrix.
def []=(i, j, v)
- raise FrozenError, "can't modify frozen Matrix" if frozen?
- rows = check_range(i, :row) or row = check_int(i, :row)
- columns = check_range(j, :column) or column = check_int(j, :column)
- if rows && columns
- set_row_and_col_range(rows, columns, v)
- elsif rows
- set_row_range(rows, column, v)
- elsif columns
- set_col_range(row, columns, v)
- else
- set_value(row, column, v)
- end
+ @rows[i][j] = v
end
alias set_element []=
alias set_component []=
- private :set_element, :set_component
-
- # Returns range or nil
- private def check_range(val, direction)
- return unless val.is_a?(Range)
- count = direction == :row ? row_count : column_count
- CoercionHelper.check_range(val, count, direction)
- end
-
- private def check_int(val, direction)
- count = direction == :row ? row_count : column_count
- CoercionHelper.check_int(val, count, direction)
- end
-
- private def set_value(row, col, value)
- raise ErrDimensionMismatch, "Expected a a value, got a #{value.class}" if value.respond_to?(:to_matrix)
-
- @rows[row][col] = value
- end
-
- private def set_row_and_col_range(row_range, col_range, value)
- if value.is_a?(Matrix)
- if row_range.size != value.row_count || col_range.size != value.column_count
- raise ErrDimensionMismatch, [
- 'Expected a Matrix of dimensions',
- "#{row_range.size}x#{col_range.size}",
- 'got',
- "#{value.row_count}x#{value.column_count}",
- ].join(' ')
- end
- source = value.instance_variable_get :@rows
- row_range.each_with_index do |row, i|
- @rows[row][col_range] = source[i]
- end
- elsif value.is_a?(Vector)
- raise ErrDimensionMismatch, 'Expected a Matrix or a value, got a Vector'
- else
- value_to_set = Array.new(col_range.size, value)
- row_range.each do |i|
- @rows[i][col_range] = value_to_set
- end
- end
- end
-
- private def set_row_range(row_range, col, value)
- if value.is_a?(Vector)
- raise ErrDimensionMismatch unless row_range.size == value.size
- set_column_vector(row_range, col, value)
- elsif value.is_a?(Matrix)
- raise ErrDimensionMismatch unless value.column_count == 1
- value = value.column(0)
- raise ErrDimensionMismatch unless row_range.size == value.size
- set_column_vector(row_range, col, value)
- else
- @rows[row_range].each{|e| e[col] = value }
- end
- end
-
- private def set_column_vector(row_range, col, value)
- value.each_with_index do |e, index|
- r = row_range.begin + index
- @rows[r][col] = e
- end
- end
-
- private def set_col_range(row, col_range, value)
- value = if value.is_a?(Vector)
- value.to_a
- elsif value.is_a?(Matrix)
- raise ErrDimensionMismatch unless value.row_count == 1
- value.row(0).to_a
- else
- Array.new(col_range.size, value)
- end
- raise ErrDimensionMismatch unless col_range.size == value.size
- @rows[row][col_range] = value
- end
+ private :[]=, :set_element, :set_component
#
# Returns the number of rows.
@@ -482,48 +361,16 @@ class Matrix
#
# Returns a matrix that is the result of iteration of the given block over all
# elements of the matrix.
- # Elements can be restricted by passing an argument:
- # * :all (default): yields all elements
- # * :diagonal: yields only elements on the diagonal
- # * :off_diagonal: yields all elements except on the diagonal
- # * :lower: yields only elements on or below the diagonal
- # * :strict_lower: yields only elements below the diagonal
- # * :strict_upper: yields only elements above the diagonal
- # * :upper: yields only elements on or above the diagonal
# Matrix[ [1,2], [3,4] ].collect { |e| e**2 }
# => 1 4
# 9 16
#
- def collect(which = :all, &block) # :yield: e
- return to_enum(:collect, which) unless block_given?
- dup.collect!(which, &block)
- end
- alias_method :map, :collect
-
- #
- # Invokes the given block for each element of matrix, replacing the element with the value
- # returned by the block.
- # Elements can be restricted by passing an argument:
- # * :all (default): yields all elements
- # * :diagonal: yields only elements on the diagonal
- # * :off_diagonal: yields all elements except on the diagonal
- # * :lower: yields only elements on or below the diagonal
- # * :strict_lower: yields only elements below the diagonal
- # * :strict_upper: yields only elements above the diagonal
- # * :upper: yields only elements on or above the diagonal
- #
- def collect!(which = :all)
- return to_enum(:collect!, which) unless block_given?
- raise FrozenError, "can't modify frozen Matrix" if frozen?
- each_with_index(which){ |e, row_index, col_index| @rows[row_index][col_index] = yield e }
- end
-
- alias map! collect!
-
- def freeze
- @rows.freeze
- super
+ def collect(&block) # :yield: e
+ return to_enum(:collect) unless block_given?
+ rows = @rows.collect{|row| row.collect(&block)}
+ new_matrix rows, column_count
end
+ alias map collect
#
# Yields all elements of the matrix, starting with those of the first row,
@@ -541,11 +388,12 @@ class Matrix
# # => prints the numbers 1 to 4
# Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
#
- def each(which = :all, &block) # :yield: e
+ def each(which = :all) # :yield: e
return to_enum :each, which unless block_given?
last = column_count - 1
case which
when :all
+ block = Proc.new
@rows.each do |row|
row.each(&block)
end
@@ -765,7 +613,7 @@ class Matrix
#
def cofactor(row, column)
raise RuntimeError, "cofactor of empty matrix is not defined" if empty?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
det_of_minor = first_minor(row, column).determinant
det_of_minor * (-1) ** (row + column)
@@ -779,7 +627,7 @@ class Matrix
# -3 7
#
def adjugate
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
Matrix.build(row_count, column_count) do |row, column|
cofactor(column, row)
end
@@ -802,7 +650,7 @@ class Matrix
raise ArgumentError, "exactly one the row or column arguments must be specified"
end
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
raise RuntimeError, "laplace_expansion of empty matrix is not defined" if empty?
unless 0 <= num && num < row_count
@@ -825,7 +673,7 @@ class Matrix
# Raises an error if matrix is not square.
#
def diagonal?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
each(:off_diagonal).all?(&:zero?)
end
@@ -842,7 +690,7 @@ class Matrix
# Raises an error if matrix is not square.
#
def hermitian?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
each_with_index(:upper).all? do |e, row, col|
e == rows[col][row].conj
end
@@ -860,7 +708,7 @@ class Matrix
# Raises an error if matrix is not square.
#
def normal?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
rows.each_with_index do |row_i, i|
rows.each_with_index do |row_j, j|
s = 0
@@ -878,7 +726,7 @@ class Matrix
# Raises an error if matrix is not square.
#
def orthogonal?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
rows.each_with_index do |row, i|
column_count.times do |j|
s = 0
@@ -896,7 +744,7 @@ class Matrix
# Raises an error if matrix is not square.
#
def permutation?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
cols = Array.new(column_count)
rows.each_with_index do |row, i|
found = false
@@ -946,7 +794,7 @@ class Matrix
# Raises an error if matrix is not square.
#
def symmetric?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
each_with_index(:strict_upper) do |e, row, col|
return false if e != rows[col][row]
end
@@ -954,24 +802,11 @@ class Matrix
end
#
- # Returns +true+ if this is an antisymmetric matrix.
- # Raises an error if matrix is not square.
- #
- def antisymmetric?
- raise ErrDimensionMismatch unless square?
- each_with_index(:upper) do |e, row, col|
- return false unless e == -rows[col][row]
- end
- true
- end
- alias_method :skew_symmetric?, :antisymmetric?
-
- #
# Returns +true+ if this is a unitary matrix
# Raises an error if matrix is not square.
#
def unitary?
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
rows.each_with_index do |row, i|
column_count.times do |j|
s = 0
@@ -1018,11 +853,12 @@ class Matrix
end
#
- # Called for dup & clone.
+ # Returns a clone of the matrix, so that the contents of each do not reference
+ # identical objects.
+ # There should be no good reason to do this since Matrices are immutable.
#
- private def initialize_copy(m)
- super
- @rows = @rows.map(&:dup) unless frozen?
+ def clone
+ new_matrix @rows.map(&:dup), column_count
end
#
@@ -1054,7 +890,7 @@ class Matrix
r = self * m
return r.column(0)
when Matrix
- raise ErrDimensionMismatch if column_count != m.row_count
+ Matrix.Raise ErrDimensionMismatch if column_count != m.row_count
rows = Array.new(row_count) {|i|
Array.new(m.column_count) {|j|
@@ -1078,7 +914,7 @@ class Matrix
def +(m)
case m
when Numeric
- raise ErrOperationNotDefined, ["+", self.class, m.class]
+ Matrix.Raise ErrOperationNotDefined, "+", self.class, m.class
when Vector
m = self.class.column_vector(m)
when Matrix
@@ -1086,7 +922,7 @@ class Matrix
return apply_through_coercion(m, __method__)
end
- raise ErrDimensionMismatch unless row_count == m.row_count && column_count == m.column_count
+ Matrix.Raise ErrDimensionMismatch unless row_count == m.row_count && column_count == m.column_count
rows = Array.new(row_count) {|i|
Array.new(column_count) {|j|
@@ -1105,7 +941,7 @@ class Matrix
def -(m)
case m
when Numeric
- raise ErrOperationNotDefined, ["-", self.class, m.class]
+ Matrix.Raise ErrOperationNotDefined, "-", self.class, m.class
when Vector
m = self.class.column_vector(m)
when Matrix
@@ -1113,7 +949,7 @@ class Matrix
return apply_through_coercion(m, __method__)
end
- raise ErrDimensionMismatch unless row_count == m.row_count && column_count == m.column_count
+ Matrix.Raise ErrDimensionMismatch unless row_count == m.row_count && column_count == m.column_count
rows = Array.new(row_count) {|i|
Array.new(column_count) {|j|
@@ -1161,12 +997,12 @@ class Matrix
# 0 -1
#
def inverse
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
self.class.I(row_count).send(:inverse_from, self)
end
- alias_method :inv, :inverse
+ alias inv inverse
- private def inverse_from(src) # :nodoc:
+ def inverse_from(src) # :nodoc:
last = row_count - 1
a = src.to_a
@@ -1180,7 +1016,7 @@ class Matrix
akk = v
end
end
- raise ErrNotRegular if akk == 0
+ Matrix.Raise ErrNotRegular if akk == 0
if i != k
a[i], a[k] = a[k], a[i]
@rows[i], @rows[k] = @rows[k], @rows[i]
@@ -1209,6 +1045,7 @@ class Matrix
end
self
end
+ private :inverse_from
#
# Matrix exponentiation.
@@ -1238,7 +1075,7 @@ class Matrix
v, d, v_inv = eigensystem
v * self.class.diagonal(*d.each(:diagonal).map{|e| e ** other}) * v_inv
else
- raise ErrOperationNotDefined, ["**", self.class, other.class]
+ Matrix.Raise ErrOperationNotDefined, "**", self.class, other.class
end
end
@@ -1250,13 +1087,6 @@ class Matrix
collect {|e| -e }
end
- #
- # Returns the absolute value elementwise
- #
- def abs
- collect(&:abs)
- end
-
#--
# MATRIX FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
@@ -1272,7 +1102,7 @@ class Matrix
# => 45
#
def determinant
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
m = @rows
case row_count
# Up to 4x4, give result using Laplacian expansion by minors.
@@ -1322,7 +1152,7 @@ class Matrix
# with smaller bignums (if any), while a matrix of Float will usually have
# intermediate results with better precision.
#
- private def determinant_bareiss
+ def determinant_bareiss
size = row_count
last = size - 1
a = to_a
@@ -1348,6 +1178,7 @@ class Matrix
end
sign * pivot
end
+ private :determinant_bareiss
#
# deprecated; use Matrix#determinant
@@ -1356,7 +1187,7 @@ class Matrix
warn "Matrix#determinant_e is deprecated; use #determinant", uplevel: 1
determinant
end
- alias_method :det_e, :determinant_e
+ alias det_e determinant_e
#
# Returns a new matrix resulting by stacking horizontally
@@ -1428,12 +1259,12 @@ class Matrix
# => 16
#
def trace
- raise ErrDimensionMismatch unless square?
+ Matrix.Raise ErrDimensionMismatch unless square?
(0...column_count).inject(0) do |tr, i|
tr + @rows[i][i]
end
end
- alias_method :tr, :trace
+ alias tr trace
#
# Returns the transpose of the matrix.
@@ -1449,7 +1280,7 @@ class Matrix
return self.class.empty(column_count, 0) if row_count.zero?
new_matrix @rows.transpose, row_count
end
- alias_method :t, :transpose
+ alias t transpose
#
# Returns a new matrix resulting by stacking vertically
@@ -1478,7 +1309,7 @@ class Matrix
def eigensystem
EigenvalueDecomposition.new(self)
end
- alias_method :eigen, :eigensystem
+ alias eigen eigensystem
#
# Returns the LUP decomposition of the matrix; see +LUPDecomposition+.
@@ -1493,7 +1324,7 @@ class Matrix
def lup
LUPDecomposition.new(self)
end
- alias_method :lup_decomposition, :lup
+ alias lup_decomposition lup
#--
# COMPLEX ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -1511,7 +1342,7 @@ class Matrix
def conjugate
collect(&:conjugate)
end
- alias_method :conj, :conjugate
+ alias conj conjugate
#
# Returns the imaginary part of the matrix.
@@ -1525,7 +1356,7 @@ class Matrix
def imaginary
collect(&:imaginary)
end
- alias_method :imag, :imaginary
+ alias imag imaginary
#
# Returns the real part of the matrix.
@@ -1549,7 +1380,7 @@ class Matrix
def rect
[real, imag]
end
- alias_method :rectangular, :rect
+ alias rectangular rect
#--
# CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
@@ -1603,25 +1434,16 @@ class Matrix
@rows.collect(&:dup)
end
- # Deprecated.
- #
- # Use map(&:to_f)
def elements_to_f
warn "Matrix#elements_to_f is deprecated, use map(&:to_f)", uplevel: 1
map(&:to_f)
end
- # Deprecated.
- #
- # Use map(&:to_i)
def elements_to_i
warn "Matrix#elements_to_i is deprecated, use map(&:to_i)", uplevel: 1
map(&:to_i)
end
- # Deprecated.
- #
- # Use map(&:to_r)
def elements_to_r
warn "Matrix#elements_to_r is deprecated, use map(&:to_r)", uplevel: 1
map(&:to_r)
@@ -1662,7 +1484,7 @@ class Matrix
# Converts the obj to an Array. If copy is set to true
# a copy of obj will be made if necessary.
#
- private def convert_to_array(obj, copy = false) # :nodoc:
+ def convert_to_array(obj, copy = false) # :nodoc:
case obj
when Array
copy ? obj.dup : obj
@@ -1678,6 +1500,7 @@ class Matrix
converted
end
end
+ private :convert_to_array
end
extend ConversionHelper
@@ -1687,13 +1510,14 @@ class Matrix
# Applies the operator +oper+ with argument +obj+
# through coercion of +obj+
#
- private def apply_through_coercion(obj, oper)
+ def apply_through_coercion(obj, oper)
coercion = obj.coerce(self)
raise TypeError unless coercion.is_a?(Array) && coercion.length == 2
coercion[0].public_send(oper, coercion[1])
rescue
raise TypeError, "#{obj.inspect} can't be coerced into #{self.class}"
end
+ private :apply_through_coercion
#
# Helper method to coerce a value into a specific class.
@@ -1721,26 +1545,6 @@ class Matrix
def self.coerce_to_matrix(obj)
coerce_to(obj, Matrix, :to_matrix)
end
-
- # Returns `nil` for non Ranges
- # Checks range validity, return canonical range with 0 <= begin <= end < count
- def self.check_range(val, count, kind)
- canonical = (val.begin + (val.begin < 0 ? count : 0))..
- (val.end ? val.end + (val.end < 0 ? count : 0) - (val.exclude_end? ? 1 : 0)
- : count - 1)
- unless 0 <= canonical.begin && canonical.begin <= canonical.end && canonical.end < count
- raise IndexError, "given range #{val} is outside of #{kind} dimensions: 0...#{count}"
- end
- canonical
- end
-
- def self.check_int(val, count, kind)
- val = CoercionHelper.coerce_to_int(val)
- if val >= count || val < -count
- raise IndexError, "given #{kind} #{val} is outside of #{-count}...#{count}"
- end
- val
- end
end
include CoercionHelper
@@ -1761,7 +1565,7 @@ class Matrix
when Numeric
Scalar.new(@value + other)
when Vector, Matrix
- raise ErrOperationNotDefined, ["+", @value.class, other.class]
+ Scalar.Raise ErrOperationNotDefined, "+", @value.class, other.class
else
apply_through_coercion(other, __method__)
end
@@ -1772,7 +1576,7 @@ class Matrix
when Numeric
Scalar.new(@value - other)
when Vector, Matrix
- raise ErrOperationNotDefined, ["-", @value.class, other.class]
+ Scalar.Raise ErrOperationNotDefined, "-", @value.class, other.class
else
apply_through_coercion(other, __method__)
end
@@ -1794,7 +1598,7 @@ class Matrix
when Numeric
Scalar.new(@value / other)
when Vector
- raise ErrOperationNotDefined, ["/", @value.class, other.class]
+ Scalar.Raise ErrOperationNotDefined, "/", @value.class, other.class
when Matrix
self * other.inverse
else
@@ -1807,10 +1611,10 @@ class Matrix
when Numeric
Scalar.new(@value ** other)
when Vector
- raise ErrOperationNotDefined, ["**", @value.class, other.class]
+ Scalar.Raise ErrOperationNotDefined, "**", @value.class, other.class
when Matrix
#other.powered_by(self)
- raise ErrOperationNotImplemented, ["**", @value.class, other.class]
+ Scalar.Raise ErrOperationNotImplemented, "**", @value.class, other.class
else
apply_through_coercion(other, __method__)
end
@@ -1835,9 +1639,6 @@ end
# To access elements:
# * #[](i)
#
-# To set elements:
-# * #[]=(i, v)
-#
# To enumerate the elements:
# * #each2(v)
# * #collect2(v)
@@ -1860,10 +1661,8 @@ end
# * #inner_product(v), dot(v)
# * #cross_product(v), cross(v)
# * #collect
-# * #collect!
# * #magnitude
# * #map
-# * #map!
# * #map2(v)
# * #norm
# * #normalize
@@ -1942,11 +1741,7 @@ class Vector
# ACCESSING
#
- # :call-seq:
- # vector[range]
- # vector[integer]
- #
- # Returns element or elements of the vector.
+ # Returns element number +i+ (starting at zero) of the vector.
#
def [](i)
@elements[i]
@@ -1954,44 +1749,12 @@ class Vector
alias element []
alias component []
- #
- # :call-seq:
- # vector[range] = new_vector
- # vector[range] = row_matrix
- # vector[range] = new_element
- # vector[integer] = new_element
- #
- # Set element or elements of vector.
- #
def []=(i, v)
- raise FrozenError, "can't modify frozen Vector" if frozen?
- if i.is_a?(Range)
- range = Matrix::CoercionHelper.check_range(i, size, :vector)
- set_range(range, v)
- else
- index = Matrix::CoercionHelper.check_int(i, size, :index)
- set_value(index, v)
- end
+ @elements[i]= v
end
alias set_element []=
alias set_component []=
- private :set_element, :set_component
-
- private def set_value(index, value)
- @elements[index] = value
- end
-
- private def set_range(range, value)
- if value.is_a?(Vector)
- raise ArgumentError, "vector to be set has wrong size" unless range.size == value.size
- @elements[range] = value.elements
- elsif value.is_a?(Matrix)
- raise ErrDimensionMismatch unless value.row_count == 1
- @elements[range] = value.row(0).elements
- else
- @elements[range] = Array.new(range.size, value)
- end
- end
+ private :[]=, :set_element, :set_component
# Returns a vector with entries rounded to the given precision
# (see Float#round)
@@ -2025,7 +1788,7 @@ class Vector
#
def each2(v) # :yield: e1, e2
raise TypeError, "Integer is not like Vector" if v.kind_of?(Integer)
- raise ErrDimensionMismatch if size != v.size
+ Vector.Raise ErrDimensionMismatch if size != v.size
return to_enum(:each2, v) unless block_given?
size.times do |i|
yield @elements[i], v[i]
@@ -2039,7 +1802,7 @@ class Vector
#
def collect2(v) # :yield: e1, e2
raise TypeError, "Integer is not like Vector" if v.kind_of?(Integer)
- raise ErrDimensionMismatch if size != v.size
+ Vector.Raise ErrDimensionMismatch if size != v.size
return to_enum(:collect2, v) unless block_given?
Array.new(size) do |i|
yield @elements[i], v[i]
@@ -2062,7 +1825,7 @@ class Vector
def Vector.independent?(*vs)
vs.each do |v|
raise TypeError, "expected Vector, got #{v.class}" unless v.is_a?(Vector)
- raise ErrDimensionMismatch unless v.size == vs.first.size
+ Vector.Raise ErrDimensionMismatch unless v.size == vs.first.size
end
return false if vs.count > vs.first.size
Matrix[*vs].rank.eql?(vs.count)
@@ -2088,20 +1851,6 @@ class Vector
all?(&:zero?)
end
- def freeze
- @elements.freeze
- super
- end
-
- #
- # Called for dup & clone.
- #
- private def initialize_copy(v)
- super
- @elements = @elements.dup unless frozen?
- end
-
-
#--
# COMPARING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
@@ -2120,6 +1869,13 @@ class Vector
end
#
+ # Returns a copy of the vector.
+ #
+ def clone
+ self.class.elements(@elements)
+ end
+
+ #
# Returns a hash-code for the vector.
#
def hash
@@ -2141,7 +1897,7 @@ class Vector
when Matrix
Matrix.column_vector(self) * x
when Vector
- raise ErrOperationNotDefined, ["*", self.class, x.class]
+ Vector.Raise ErrOperationNotDefined, "*", self.class, x.class
else
apply_through_coercion(x, __method__)
end
@@ -2153,7 +1909,7 @@ class Vector
def +(v)
case v
when Vector
- raise ErrDimensionMismatch if size != v.size
+ Vector.Raise ErrDimensionMismatch if size != v.size
els = collect2(v) {|v1, v2|
v1 + v2
}
@@ -2171,7 +1927,7 @@ class Vector
def -(v)
case v
when Vector
- raise ErrDimensionMismatch if size != v.size
+ Vector.Raise ErrDimensionMismatch if size != v.size
els = collect2(v) {|v1, v2|
v1 - v2
}
@@ -2192,7 +1948,7 @@ class Vector
els = @elements.collect{|e| e / x}
self.class.elements(els, false)
when Matrix, Vector
- raise ErrOperationNotDefined, ["/", self.class, x.class]
+ Vector.Raise ErrOperationNotDefined, "/", self.class, x.class
else
apply_through_coercion(x, __method__)
end
@@ -2215,7 +1971,7 @@ class Vector
# Vector[4,7].inner_product Vector[10,1] => 47
#
def inner_product(v)
- raise ErrDimensionMismatch if size != v.size
+ Vector.Raise ErrDimensionMismatch if size != v.size
p = 0
each2(v) {|v1, v2|
@@ -2242,7 +1998,7 @@ class Vector
raise ArgumentError, "wrong number of arguments (#{vs.size} for #{size - 2})" unless vs.size == size - 2
vs.each do |v|
raise TypeError, "expected Vector, got #{v.class}" unless v.is_a? Vector
- raise ErrDimensionMismatch unless v.size == size
+ Vector.Raise ErrDimensionMismatch unless v.size == size
end
case size
when 2
@@ -2267,18 +2023,7 @@ class Vector
els = @elements.collect(&block)
self.class.elements(els, false)
end
- alias_method :map, :collect
-
- #
- # Like Array#collect!
- #
- def collect!(&block)
- return to_enum(:collect!) unless block_given?
- raise FrozenError, "can't modify frozen Vector" if frozen?
- @elements.collect!(&block)
- self
- end
- alias map! collect!
+ alias map collect
#
# Returns the modulus (Pythagorean distance) of the vector.
@@ -2287,8 +2032,8 @@ class Vector
def magnitude
Math.sqrt(@elements.inject(0) {|v, e| v + e.abs2})
end
- alias_method :r, :magnitude
- alias_method :norm, :magnitude
+ alias r magnitude
+ alias norm magnitude
#
# Like Vector#collect2, but returns a Vector instead of an Array.
@@ -2314,21 +2059,17 @@ class Vector
end
#
- # Returns an angle with another vector. Result is within the [0..Math::PI].
+ # Returns an angle with another vector. Result is within the [0...Math::PI].
# Vector[1,0].angle_with(Vector[0,1])
# # => Math::PI / 2
#
def angle_with(v)
raise TypeError, "Expected a Vector, got a #{v.class}" unless v.is_a?(Vector)
- raise ErrDimensionMismatch if size != v.size
+ Vector.Raise ErrDimensionMismatch if size != v.size
prod = magnitude * v.magnitude
raise ZeroVectorError, "Can't get angle of zero vector" if prod == 0
- dot = inner_product(v)
- if dot.abs >= prod
- dot.positive? ? 0 : Math::PI
- else
- Math.acos(dot / prod)
- end
+
+ Math.acos( inner_product(v) / prod )
end
#--
diff --git a/lib/matrix/eigenvalue_decomposition.rb b/lib/matrix/eigenvalue_decomposition.rb
index bf6637635a..919db9e83d 100644
--- a/lib/matrix/eigenvalue_decomposition.rb
+++ b/lib/matrix/eigenvalue_decomposition.rb
@@ -43,7 +43,7 @@ class Matrix
def eigenvector_matrix
Matrix.send(:new, build_eigenvectors.transpose)
end
- alias_method :v, :eigenvector_matrix
+ alias v eigenvector_matrix
# Returns the inverse of the eigenvector matrix +V+
#
@@ -52,7 +52,7 @@ class Matrix
r = r.transpose.inverse unless @symmetric
r
end
- alias_method :v_inv, :eigenvector_matrix_inv
+ alias v_inv eigenvector_matrix_inv
# Returns the eigenvalues in an array
#
@@ -73,7 +73,7 @@ class Matrix
def eigenvalue_matrix
Matrix.diagonal(*eigenvalues)
end
- alias_method :d, :eigenvalue_matrix
+ alias d eigenvalue_matrix
# Returns [eigenvector_matrix, eigenvalue_matrix, eigenvector_matrix_inv]
#
@@ -82,8 +82,8 @@ class Matrix
end
alias_method :to_a, :to_ary
-
- private def build_eigenvectors
+ private
+ def build_eigenvectors
# JAMA stores complex eigenvectors in a strange way
# See http://web.archive.org/web/20111016032731/http://cio.nist.gov/esd/emaildir/lists/jama/msg01021.html
@e.each_with_index.map do |imag, i|
@@ -96,10 +96,9 @@ class Matrix
end
end
end
-
# Complex scalar division.
- private def cdiv(xr, xi, yr, yi)
+ def cdiv(xr, xi, yr, yi)
if (yr.abs > yi.abs)
r = yi/yr
d = yr + r*yi
@@ -114,7 +113,7 @@ class Matrix
# Symmetric Householder reduction to tridiagonal form.
- private def tridiagonalize
+ def tridiagonalize
# This is derived from the Algol procedures tred2 by
# Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
@@ -232,7 +231,7 @@ class Matrix
# Symmetric tridiagonal QL algorithm.
- private def diagonalize
+ def diagonalize
# This is derived from the Algol procedures tql2, by
# Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
# Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
@@ -351,7 +350,7 @@ class Matrix
# Nonsymmetric reduction to Hessenberg form.
- private def reduce_to_hessenberg
+ def reduce_to_hessenberg
# This is derived from the Algol procedures orthes and ortran,
# by Martin and Wilkinson, Handbook for Auto. Comp.,
# Vol.ii-Linear Algebra, and the corresponding
@@ -441,9 +440,11 @@ class Matrix
end
end
+
+
# Nonsymmetric reduction from Hessenberg to real Schur form.
- private def hessenberg_to_real_schur
+ def hessenberg_to_real_schur
# This is derived from the Algol procedure hqr2,
# by Martin and Wilkinson, Handbook for Auto. Comp.,
diff --git a/lib/matrix/lup_decomposition.rb b/lib/matrix/lup_decomposition.rb
index e37def75f6..c001770a12 100644
--- a/lib/matrix/lup_decomposition.rb
+++ b/lib/matrix/lup_decomposition.rb
@@ -78,7 +78,7 @@ class Matrix
def det
if (@row_count != @column_count)
- raise Matrix::ErrDimensionMismatch
+ Matrix.Raise Matrix::ErrDimensionMismatch
end
d = @pivot_sign
@column_count.times do |j|
@@ -94,11 +94,11 @@ class Matrix
def solve b
if (singular?)
- raise Matrix::ErrNotRegular, "Matrix is singular."
+ Matrix.Raise Matrix::ErrNotRegular, "Matrix is singular."
end
if b.is_a? Matrix
if (b.row_count != @row_count)
- raise Matrix::ErrDimensionMismatch
+ Matrix.Raise Matrix::ErrDimensionMismatch
end
# Copy right hand side with pivoting
@@ -128,7 +128,7 @@ class Matrix
else # same algorithm, specialized for simpler case of a vector
b = convert_to_array(b)
if (b.size != @row_count)
- raise Matrix::ErrDimensionMismatch
+ Matrix.Raise Matrix::ErrDimensionMismatch
end
# Copy right hand side with pivoting
diff --git a/lib/matrix/matrix.gemspec b/lib/matrix/matrix.gemspec
deleted file mode 100644
index 75f6b69a98..0000000000
--- a/lib/matrix/matrix.gemspec
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require_relative "lib/matrix/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "matrix"
- spec.version = Matrix::VERSION
- spec.authors = ["Marc-Andre Lafortune"]
- spec.email = ["ruby-core@marc-andre.ca"]
-
- spec.summary = %q{An implementation of Matrix and Vector classes.}
- spec.description = %q{An implementation of Matrix and Vector classes.}
- spec.homepage = "https://github.com/ruby/matrix"
- spec.license = "BSD-2-Clause"
-
- spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/matrix.rb", "lib/matrix/eigenvalue_decomposition.rb", "lib/matrix/lup_decomposition.rb", "lib/matrix/version.rb", "matrix.gemspec"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
-end
diff --git a/lib/matrix/version.rb b/lib/matrix/version.rb
deleted file mode 100644
index e6f91dae3c..0000000000
--- a/lib/matrix/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class Matrix
- VERSION = "0.2.0"
-end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index eabccd48eb..74b42289b1 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -7,9 +7,8 @@ require 'rbconfig'
require 'fileutils'
require 'shellwords'
+# :stopdoc:
class String
- # :stopdoc:
-
# Wraps a string in escaped quotes if it contains whitespace.
def quote
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
@@ -32,20 +31,15 @@ class String
def sans_arguments
self[/\A[^()]+/]
end
-
- # :startdoc:
end
class Array
- # :stopdoc:
-
# Wraps all strings in escaped quotes if they contain whitespace.
def quote
map {|s| s.quote}
end
-
- # :startdoc:
end
+# :startdoc:
##
# mkmf.rb is used by Ruby C extensions to generate a Makefile which will
@@ -247,12 +241,7 @@ module MakeMakefile
$topdir ||= RbConfig::CONFIG["topdir"]
$arch_hdrdir = "$(extout)/include/$(arch)"
else
- abort <<MESSAGE
-mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h
-
-You might have to install separate package for the ruby development
-environment, ruby-dev or ruby-devel for example.
-MESSAGE
+ abort "mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h"
end
CONFTEST = "conftest".freeze
@@ -434,10 +423,6 @@ EOM
EOM
end
- def conftest_source
- CONFTEST_C
- end
-
def create_tmpsrc(src)
src = "#{COMMON_HEADERS}\n#{src}"
src = yield(src) if block_given?
@@ -446,7 +431,7 @@ EOM
src.sub!(/[^\n]\z/, "\\&\n")
count = 0
begin
- open(conftest_source, "wb") do |cfile|
+ open(CONFTEST_C, "wb") do |cfile|
cfile.print src
end
rescue Errno::EACCES
@@ -481,10 +466,10 @@ MSG
end
end
- def link_config(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
+ def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
librubyarg = $extmk ? $LIBRUBYARG_STATIC : "$(LIBRUBYARG)"
conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote,
- 'src' => "#{conftest_source}",
+ 'src' => "#{CONFTEST_C}",
'arch_hdrdir' => $arch_hdrdir.quote,
'top_srcdir' => $top_srcdir.quote,
'INCFLAGS' => "#$INCFLAGS",
@@ -495,29 +480,21 @@ MSG
'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
'LIBS' => "#{librubyarg} #{opt} #$LIBS")
conf['LIBPATH'] = libpathflag(libpath.map {|s| RbConfig::expand(s.dup, conf)})
- conf
- end
-
- def link_command(ldflags, *opts)
- conf = link_config(ldflags, *opts)
RbConfig::expand(TRY_LINK.dup, conf)
end
- def cc_config(opt="")
+ def cc_command(opt="")
conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
'arch_hdrdir' => $arch_hdrdir.quote,
'top_srcdir' => $top_srcdir.quote)
- conf
- end
-
- def cc_command(opt="")
- conf = cc_config(opt)
RbConfig::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
conf)
end
def cpp_command(outfile, opt="")
- conf = cc_config(opt)
+ conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
+ 'arch_hdrdir' => $arch_hdrdir.quote,
+ 'top_srcdir' => $top_srcdir.quote)
if $universal and (arch_flag = conf['ARCH_FLAG']) and !arch_flag.empty?
conf['ARCH_FLAG'] = arch_flag.gsub(/(?:\G|\s)-arch\s+\S+/, '')
end
@@ -1019,7 +996,6 @@ SRC
# <code>--with-FOOlib</code> configuration option.
#
def have_library(lib, func = nil, headers = nil, opt = "", &b)
- dir_config(lib)
lib = with_config(lib+'lib', lib)
checking_for checking_message(func && func.funcall_style, LIBARG%lib, opt) do
if COMMON_LIBS.include?(lib)
@@ -1045,7 +1021,6 @@ SRC
# library paths searched and linked against.
#
def find_library(lib, func, *paths, &b)
- dir_config(lib)
lib = with_config(lib+'lib', lib)
paths = paths.collect {|path| path.split(File::PATH_SEPARATOR)}.flatten
checking_for checking_message(func && func.funcall_style, LIBARG%lib) do
@@ -1119,7 +1094,6 @@ SRC
# +HAVE_FOO_H+ preprocessor macro would be passed to the compiler.
#
def have_header(header, preheaders = nil, opt = "", &b)
- dir_config(header[/.*?(?=\/)|.*?(?=\.)/])
checking_for header do
if try_header(cpp_include(preheaders)+cpp_include(header), opt, &b)
$defs.push(format("-DHAVE_%s", header.tr_cpp))
@@ -1763,10 +1737,6 @@ SRC
# application.
#
def dir_config(target, idefault=nil, ldefault=nil)
- if conf = $config_dirs[target]
- return conf
- end
-
if dir = with_config(target + "-dir", (idefault unless ldefault))
defaults = Array === dir ? dir : dir.split(File::PATH_SEPARATOR)
idefault = ldefault = nil
@@ -1797,7 +1767,7 @@ SRC
end
$LIBPATH = ldirs | $LIBPATH
- $config_dirs[target] = [idir, ldir]
+ [idir, ldir]
end
# Returns compile/link information about an installed library in a
@@ -1813,7 +1783,7 @@ SRC
#
# Where {option} is, for instance, <code>--cflags</code>.
#
- # The values obtained are appended to +$INCFLAGS+, +$CFLAGS+, +$LDFLAGS+ and
+ # The values obtained are appended to +$CFLAGS+, +$LDFLAGS+ and
# +$libs+.
#
# If an <code>option</code> argument is given, the config command is
@@ -1869,9 +1839,9 @@ SRC
$LDFLAGS = [orig_ldflags, ldflags].join(' ')
Logging::message "package configuration for %s\n", pkg
- Logging::message "incflags: %s\ncflags: %s\nldflags: %s\nlibs: %s\n\n",
- incflags, cflags, ldflags, libs
- [[incflags, cflags].join(' '), ldflags, libs]
+ Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n",
+ cflags, ldflags, libs
+ [cflags, ldflags, libs]
else
Logging::message "package configuration for %s is not found\n", pkg
nil
@@ -1990,7 +1960,6 @@ VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
headers << '$(RUBY_EXTCONF_H)' if $extconf_h
mk << %{
-CC_WRAPPER = #{CONFIG['CC_WRAPPER']}
CC = #{CONFIG['CC']}
CXX = #{CONFIG['CXX']}
LIBRUBY = #{CONFIG['LIBRUBY']}
@@ -2008,7 +1977,6 @@ cxxflags = #{CONFIG['cxxflags']}
optflags = #{CONFIG['optflags']}
debugflags = #{CONFIG['debugflags']}
warnflags = #{$warnflags}
-cppflags = #{CONFIG['cppflags']}
CCDLFLAGS = #{$static ? '' : CONFIG['CCDLFLAGS']}
CFLAGS = $(CCDLFLAGS) #$CFLAGS $(ARCH_FLAG)
INCFLAGS = -I. #$INCFLAGS
@@ -2134,6 +2102,7 @@ RULES
line.gsub!(/\.o\b/, ".#{$OBJEXT}")
line.gsub!(/\{\$\(VPATH\)\}/, "") unless $nmake
line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h)
+ line.gsub!(%r"\$\(hdrdir\)/(?!ruby(?![^:;/\s]))(?=[-\w]+\.h)", '\&ruby/')
if $nmake && /\A\s*\$\(RM|COPY\)/ =~ line
line.gsub!(%r"[-\w\./]{2,}"){$&.tr("/", "\\")}
line.gsub!(/(\$\((?!RM|COPY)[^:)]+)(?=\))/, '\1:/=\\')
@@ -2282,7 +2251,7 @@ RULES
origdef ||= ''
if $extout and $INSTALLFILES
- $cleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.delete_prefix('./'))})
+ $cleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.sub(/\A\.\//, ''))})
$distcleandirs.concat($INSTALLFILES.collect {|files, dir| dir})
end
@@ -2526,8 +2495,6 @@ site-install-rb: install-rb
$enable_shared = config['ENABLE_SHARED'] == 'yes'
$defs = []
$extconf_h = nil
- $config_dirs = {}
-
if $warnflags = CONFIG['warnflags'] and CONFIG['GCC'] == 'yes'
# turn warnings into errors only for bundled extensions.
config['warnflags'] = $warnflags.gsub(/(\A|\s)-Werror[-=]/, '\1-W')
@@ -2540,9 +2507,6 @@ site-install-rb: install-rb
end
$warnflags = config['warnflags'] unless $extmk
end
- if (w = rbconfig['CC_WRAPPER']) and !w.empty? and !File.executable?(w)
- rbconfig['CC_WRAPPER'] = config['CC_WRAPPER'] = ''
- end
$CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
$CXXFLAGS = (with_config("cxxflags", arg_config("CXXFLAGS", config["CXXFLAGS"]))||'').dup
$ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup
@@ -2586,7 +2550,6 @@ site-install-rb: install-rb
$extout_prefix ||= nil
$arg_config.clear
- $config_dirs.clear
dir_config("opt")
end
@@ -2622,8 +2585,7 @@ MESSAGE
src = src.sub(/\{/) do
$& +
"\n if (argc > 1000000) {\n" +
- refs.map {|n|" int (* volatile #{n}p)(void)=(int (*)(void))&#{n};\n"}.join("") +
- refs.map {|n|" printf(\"%d\", (*#{n}p)());\n"}.join("") +
+ refs.map {|n|" printf(\"%p\", &#{n});\n"}.join("") +
" }\n"
end
end
@@ -2747,7 +2709,7 @@ MESSAGE
##
# A C main function which does no work
- MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || "int main(int argc, char **argv)\n{\n return !!argv[argc];\n}"
+ MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || "int main(int argc, char **argv)\n{\n return 0;\n}"
UNIVERSAL_INTS = config_string('UNIVERSAL_INTS') {|s| Shellwords.shellwords(s)} ||
%w[int short long long\ long]
@@ -2775,51 +2737,6 @@ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
realclean: distclean
"
-
- @lang = Hash.new(self)
-
- def self.[](name)
- @lang.fetch(name)
- end
-
- def self.[]=(name, mod)
- @lang[name] = mod
- end
-
- self["C++"] = Module.new do
- include MakeMakefile
- extend self
-
- CONFTEST_CXX = "#{CONFTEST}.#{config_string('CXX_EXT') || CXX_EXT[0]}"
-
- TRY_LINK_CXX = config_string('TRY_LINK_CXX') ||
- ((cmd = TRY_LINK.gsub(/\$\(C(?:C|(FLAGS))\)/, '$(CXX\1)')) != TRY_LINK && cmd) ||
- "$(CXX) #{OUTFLAG}#{CONFTEST}#{$EXEEXT} $(INCFLAGS) $(CPPFLAGS) " \
- "$(CXXFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
-
- def have_devel?
- unless defined? @have_devel
- @have_devel = true
- @have_devel = try_link(MAIN_DOES_NOTHING)
- end
- @have_devel
- end
-
- def conftest_source
- CONFTEST_CXX
- end
-
- def cc_command(opt="")
- conf = cc_config(opt)
- RbConfig::expand("$(CXX) #$INCFLAGS #$CPPFLAGS #$CXXFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_CXX}",
- conf)
- end
-
- def link_command(ldflags, *opts)
- conf = link_config(ldflags, *opts)
- RbConfig::expand(TRY_LINK_CXX.dup, conf)
- end
- end
end
include MakeMakefile
diff --git a/lib/monitor.rb b/lib/monitor.rb
new file mode 100644
index 0000000000..e99cbd4baa
--- /dev/null
+++ b/lib/monitor.rb
@@ -0,0 +1,324 @@
+# frozen_string_literal: false
+# = monitor.rb
+#
+# Copyright (C) 2001 Shugo Maeda <shugo@ruby-lang.org>
+#
+# This library is distributed under the terms of the Ruby license.
+# You can freely distribute/modify this library.
+#
+
+#
+# In concurrent programming, a monitor is an object or module intended to be
+# used safely by more than one thread. The defining characteristic of a
+# monitor is that its methods are executed with mutual exclusion. That is, at
+# each point in time, at most one thread may be executing any of its methods.
+# This mutual exclusion greatly simplifies reasoning about the implementation
+# of monitors compared to reasoning about parallel code that updates a data
+# structure.
+#
+# You can read more about the general principles on the Wikipedia page for
+# Monitors[http://en.wikipedia.org/wiki/Monitor_%28synchronization%29]
+#
+# == Examples
+#
+# === Simple object.extend
+#
+# require 'monitor.rb'
+#
+# buf = []
+# buf.extend(MonitorMixin)
+# empty_cond = buf.new_cond
+#
+# # consumer
+# Thread.start do
+# loop do
+# buf.synchronize do
+# empty_cond.wait_while { buf.empty? }
+# print buf.shift
+# end
+# end
+# end
+#
+# # producer
+# while line = ARGF.gets
+# buf.synchronize do
+# buf.push(line)
+# empty_cond.signal
+# end
+# end
+#
+# The consumer thread waits for the producer thread to push a line to buf
+# while <tt>buf.empty?</tt>. The producer thread (main thread) reads a
+# line from ARGF and pushes it into buf then calls <tt>empty_cond.signal</tt>
+# to notify the consumer thread of new data.
+#
+# === Simple Class include
+#
+# require 'monitor'
+#
+# class SynchronizedArray < Array
+#
+# include MonitorMixin
+#
+# def initialize(*args)
+# super(*args)
+# end
+#
+# alias :old_shift :shift
+# alias :old_unshift :unshift
+#
+# def shift(n=1)
+# self.synchronize do
+# self.old_shift(n)
+# end
+# end
+#
+# def unshift(item)
+# self.synchronize do
+# self.old_unshift(item)
+# end
+# end
+#
+# # other methods ...
+# end
+#
+# +SynchronizedArray+ implements an Array with synchronized access to items.
+# This Class is implemented as subclass of Array which includes the
+# MonitorMixin module.
+#
+module MonitorMixin
+ EXCEPTION_NEVER = {Exception => :never}.freeze
+ EXCEPTION_IMMEDIATE = {Exception => :immediate}.freeze
+
+ #
+ # FIXME: This isn't documented in Nutshell.
+ #
+ # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
+ # above calls while_wait and signal, this class should be documented.
+ #
+ class ConditionVariable
+ class Timeout < Exception; end
+
+ #
+ # Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
+ #
+ # If +timeout+ is given, this method returns after +timeout+ seconds passed,
+ # even if no other thread doesn't signal.
+ #
+ def wait(timeout = nil)
+ Thread.handle_interrupt(EXCEPTION_NEVER) do
+ @monitor.__send__(:mon_check_owner)
+ count = @monitor.__send__(:mon_exit_for_cond)
+ begin
+ Thread.handle_interrupt(EXCEPTION_IMMEDIATE) do
+ @cond.wait(@monitor.instance_variable_get(:@mon_mutex), timeout)
+ end
+ return true
+ ensure
+ @monitor.__send__(:mon_enter_for_cond, count)
+ end
+ end
+ end
+
+ #
+ # Calls wait repeatedly while the given block yields a truthy value.
+ #
+ def wait_while
+ while yield
+ wait
+ end
+ end
+
+ #
+ # Calls wait repeatedly until the given block yields a truthy value.
+ #
+ def wait_until
+ until yield
+ wait
+ end
+ end
+
+ #
+ # Wakes up the first thread in line waiting for this lock.
+ #
+ def signal
+ @monitor.__send__(:mon_check_owner)
+ @cond.signal
+ end
+
+ #
+ # Wakes up all threads waiting for this lock.
+ #
+ def broadcast
+ @monitor.__send__(:mon_check_owner)
+ @cond.broadcast
+ end
+
+ private
+
+ def initialize(monitor)
+ @monitor = monitor
+ @cond = Thread::ConditionVariable.new
+ end
+ end
+
+ def self.extend_object(obj)
+ super(obj)
+ obj.__send__(:mon_initialize)
+ end
+
+ #
+ # Attempts to enter exclusive section. Returns +false+ if lock fails.
+ #
+ def mon_try_enter
+ if @mon_owner != Thread.current
+ unless @mon_mutex.try_lock
+ return false
+ end
+ @mon_owner = Thread.current
+ @mon_count = 0
+ end
+ @mon_count += 1
+ return true
+ end
+ # For backward compatibility
+ alias try_mon_enter mon_try_enter
+
+ #
+ # Enters exclusive section.
+ #
+ def mon_enter
+ if @mon_owner != Thread.current
+ @mon_mutex.lock
+ @mon_owner = Thread.current
+ @mon_count = 0
+ end
+ @mon_count += 1
+ end
+
+ #
+ # Leaves exclusive section.
+ #
+ def mon_exit
+ mon_check_owner
+ @mon_count -=1
+ if @mon_count == 0
+ @mon_owner = nil
+ @mon_mutex.unlock
+ end
+ end
+
+ #
+ # Returns true if this monitor is locked by any thread
+ #
+ def mon_locked?
+ @mon_mutex.locked?
+ end
+
+ #
+ # Returns true if this monitor is locked by current thread.
+ #
+ def mon_owned?
+ @mon_mutex.locked? && @mon_owner == Thread.current
+ end
+
+ #
+ # Enters exclusive section and executes the block. Leaves the exclusive
+ # section automatically when the block exits. See example under
+ # +MonitorMixin+.
+ #
+ def mon_synchronize
+ # Prevent interrupt on handling interrupts; for example timeout errors
+ # it may break locking state.
+ Thread.handle_interrupt(Exception => :never){ mon_enter }
+ begin
+ yield
+ ensure
+ Thread.handle_interrupt(EXCEPTION_NEVER){ mon_exit }
+ end
+ end
+ alias synchronize mon_synchronize
+
+ #
+ # Creates a new MonitorMixin::ConditionVariable associated with the
+ # receiver.
+ #
+ def new_cond
+ return ConditionVariable.new(self)
+ end
+
+ private
+
+ # Use <tt>extend MonitorMixin</tt> or <tt>include MonitorMixin</tt> instead
+ # of this constructor. Have look at the examples above to understand how to
+ # use this module.
+ def initialize(*args)
+ super
+ mon_initialize
+ end
+
+ # Initializes the MonitorMixin after being included in a class or when an
+ # object has been extended with the MonitorMixin
+ def mon_initialize
+ @mon_owner = nil
+ @mon_count = 0
+ @mon_mutex = Thread::Mutex.new
+ end
+
+ def mon_check_owner
+ if @mon_owner != Thread.current
+ raise ThreadError, "current thread not owner"
+ end
+ end
+
+ def mon_enter_for_cond(count)
+ @mon_owner = Thread.current
+ @mon_count = count
+ end
+
+ def mon_exit_for_cond
+ count = @mon_count
+ @mon_owner = nil
+ @mon_count = 0
+ return count
+ end
+end
+
+# Use the Monitor class when you want to have a lock object for blocks with
+# mutual exclusion.
+#
+# require 'monitor'
+#
+# lock = Monitor.new
+# lock.synchronize do
+# # exclusive access
+# end
+#
+class Monitor
+ include MonitorMixin
+ alias try_enter try_mon_enter
+ alias enter mon_enter
+ alias exit mon_exit
+end
+
+
+# Documentation comments:
+# - All documentation comes from Nutshell.
+# - MonitorMixin.new_cond appears in the example, but is not documented in
+# Nutshell.
+# - All the internals (internal modules Accessible and Initializable, class
+# ConditionVariable) appear in RDoc. It might be good to hide them, by
+# making them private, or marking them :nodoc:, etc.
+# - RDoc doesn't recognise aliases, so we have mon_synchronize documented, but
+# not synchronize.
+# - mon_owner is in Nutshell, but appears as an accessor in a separate module
+# here, so is hard/impossible to RDoc. Some other useful accessors
+# (mon_count and some queue stuff) are also in this module, and don't appear
+# directly in the RDoc output.
+# - in short, it may be worth changing the code layout in this file to make the
+# documentation easier
+
+# Local variables:
+# mode: Ruby
+# tab-width: 8
+# End:
diff --git a/lib/mutex_m.gemspec b/lib/mutex_m.gemspec
deleted file mode 100644
index 409ed5b7b2..0000000000
--- a/lib/mutex_m.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/mutex_m"
-rescue LoadError
- # for Ruby core repository
- require_relative "mutex_m"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "mutex_m"
- spec.version = Mutex_m::VERSION
- spec.authors = ["Keiju ISHITSUKA"]
- spec.email = ["keiju@ruby-lang.org"]
-
- spec.summary = %q{Mixin to extend objects to be handled like a Mutex.}
- spec.description = %q{Mixin to extend objects to be handled like a Mutex.}
- spec.homepage = "https://github.com/ruby/mutex_m"
- spec.license = "BSD-2-Clause"
-
- spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/mutex_m.rb", "mutex_m.gemspec"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "test-unit"
-end
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
index dd47934bea..592e3842c8 100644
--- a/lib/mutex_m.rb
+++ b/lib/mutex_m.rb
@@ -25,23 +25,16 @@
# obj.extend Mutex_m
#
# Or mixin Mutex_m into your module to your class inherit Mutex instance
-# methods --- remember to call super() in your class initialize method.
+# methods.
#
# class Foo
# include Mutex_m
-# def initialize
-# # ...
-# super()
-# end
# # ...
# end
# obj = Foo.new
# # this obj can be handled like Mutex
#
module Mutex_m
-
- VERSION = "0.1.0"
-
def Mutex_m.define_aliases(cl) # :nodoc:
cl.module_eval %q{
alias locked? mu_locked?
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index 1e078453a8..9902f9dc65 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -17,7 +17,7 @@
require "socket"
require "monitor"
-require_relative "protocol"
+require "net/protocol"
require "time"
begin
require "openssl"
@@ -97,10 +97,6 @@ module Net
# When +true+, the connection is in passive mode. Default: +true+.
attr_accessor :passive
- # When +true+, use the IP address in PASV responses. Otherwise, it uses
- # the same IP address for the control connection. Default: +false+.
- attr_accessor :use_pasv_ip
-
# When +true+, all traffic to and from the server is written
# to +$stdout+. Default: +false+.
attr_accessor :debug_mode
@@ -209,9 +205,6 @@ module Net
# handshake.
# See Net::FTP#ssl_handshake_timeout for
# details. Default: +nil+.
- # use_pasv_ip:: When +true+, use the IP address in PASV responses.
- # Otherwise, it uses the same IP address for the control
- # connection. Default: +false+.
# debug_mode:: When +true+, all traffic to and from the server is
# written to +$stdout+. Default: +false+.
#
@@ -272,7 +265,6 @@ module Net
@open_timeout = options[:open_timeout]
@ssl_handshake_timeout = options[:ssl_handshake_timeout]
@read_timeout = options[:read_timeout] || 60
- @use_pasv_ip = options[:use_pasv_ip] || false
if host
connect(host, options[:port] || FTP_PORT)
if options[:username]
@@ -639,12 +631,14 @@ module Net
with_binary(true) do
begin
conn = transfercmd(cmd, rest_offset)
- while data = conn.read(blocksize)
+ loop do
+ data = conn.read(blocksize)
+ break if data == nil
yield(data)
end
- conn.shutdown(Socket::SHUT_WR) rescue nil
+ conn.shutdown(Socket::SHUT_WR)
conn.read_timeout = 1
- conn.read rescue nil
+ conn.read
ensure
conn.close if conn
end
@@ -664,12 +658,14 @@ module Net
with_binary(false) do
begin
conn = transfercmd(cmd)
- while line = conn.gets
+ loop do
+ line = conn.gets
+ break if line == nil
yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?)
end
- conn.shutdown(Socket::SHUT_WR) rescue nil
+ conn.shutdown(Socket::SHUT_WR)
conn.read_timeout = 1
- conn.read rescue nil
+ conn.read
ensure
conn.close if conn
end
@@ -690,18 +686,14 @@ module Net
end
synchronize do
with_binary(true) do
- begin
- conn = transfercmd(cmd)
- while buf = file.read(blocksize)
- conn.write(buf)
- yield(buf) if block_given?
- end
- conn.shutdown(Socket::SHUT_WR) rescue nil
- conn.read_timeout = 1
- conn.read rescue nil
- ensure
- conn.close if conn
+ conn = transfercmd(cmd)
+ loop do
+ buf = file.read(blocksize)
+ break if buf == nil
+ conn.write(buf)
+ yield(buf) if block_given?
end
+ conn.close
voidresp
end
end
@@ -723,21 +715,17 @@ module Net
def storlines(cmd, file) # :yield: line
synchronize do
with_binary(false) do
- begin
- conn = transfercmd(cmd)
- while buf = file.gets
- if buf[-2, 2] != CRLF
- buf = buf.chomp + CRLF
- end
- conn.write(buf)
- yield(buf) if block_given?
+ conn = transfercmd(cmd)
+ loop do
+ buf = file.gets
+ break if buf == nil
+ if buf[-2, 2] != CRLF
+ buf = buf.chomp + CRLF
end
- conn.shutdown(Socket::SHUT_WR) rescue nil
- conn.read_timeout = 1
- conn.read rescue nil
- ensure
- conn.close if conn
+ conn.write(buf)
+ yield(buf) if block_given?
end
+ conn.close
voidresp
end
end
@@ -1248,9 +1236,8 @@ module Net
#
# Returns the status (STAT command).
- #
- # pathname:: when stat is invoked with pathname as a parameter it acts like
- # list but a lot faster and over the same tcp session.
+ # pathname - when stat is invoked with pathname as a parameter it acts like
+ # list but alot faster and over the same tcp session.
#
def status(pathname = nil)
line = pathname ? "STAT #{pathname}" : "STAT"
@@ -1311,41 +1298,6 @@ module Net
end
#
- # Issues a FEAT command
- #
- # Returns an array of supported optional features
- #
- def features
- resp = sendcmd("FEAT")
- if !resp.start_with?("211")
- raise FTPReplyError, resp
- end
-
- feats = []
- resp.split("\n").each do |line|
- next if !line.start_with?(' ') # skip status lines
-
- feats << line.strip
- end
-
- return feats
- end
-
- #
- # Issues an OPTS command
- # - name Should be the name of the option to set
- # - params is any optional parameters to supply with the option
- #
- # example: option('UTF8', 'ON') => 'OPTS UTF8 ON'
- #
- def option(name, params = nil)
- cmd = "OPTS #{name}"
- cmd += " #{params}" if params
-
- voidcmd(cmd)
- end
-
- #
# Closes the connection. Further operations are impossible until you open
# a new connection with #connect.
#
@@ -1378,12 +1330,7 @@ module Net
raise FTPReplyError, resp
end
if m = /\((?<host>\d+(,\d+){3}),(?<port>\d+,\d+)\)/.match(resp)
- if @use_pasv_ip
- host = parse_pasv_ipv4_host(m["host"])
- else
- host = @bare_sock.remote_address.ip_address
- end
- return host, parse_pasv_port(m["port"])
+ return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"])
else
raise FTPProtoError, resp
end
@@ -1509,7 +1456,7 @@ module Net
if defined?(OpenSSL::SSL::SSLSocket)
class BufferedSSLSocket < BufferedSocket
- def initialize(*args, **options)
+ def initialize(*args)
super
@is_shutdown = false
end
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 88a174a248..961ef398c3 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -35,7 +35,7 @@ module Net #:nodoc:
#
# Net::HTTP provides a rich library which can be used to build HTTP
# user-agents. For more details about HTTP see
- # [RFC2616](http://www.ietf.org/rfc/rfc2616.txt).
+ # [RFC2616](http://www.ietf.org/rfc/rfc2616.txt)
#
# Net::HTTP is designed to work closely with URI. URI::HTTP#host,
# URI::HTTP#port and URI::HTTP#request_uri are designed to work with
@@ -87,7 +87,7 @@ module Net #:nodoc:
#
# == How to use Net::HTTP
#
- # The following example code can be used as the basis of an HTTP user-agent
+ # The following example code can be used as the basis of a HTTP user-agent
# which can perform a variety of request types using persistent
# connections.
#
@@ -104,13 +104,14 @@ module Net #:nodoc:
# open for multiple requests in the block if the server indicates it
# supports persistent connections.
#
- # If you wish to re-use a connection across multiple HTTP requests without
- # automatically closing it you can use ::new and then call #start and
- # #finish manually.
- #
# The request types Net::HTTP supports are listed below in the section "HTTP
# Request Classes".
#
+ # If you wish to re-use a connection across multiple HTTP requests without
+ # automatically closing it you can use ::new instead of ::start. #request
+ # will automatically open a connection to the server if one is not currently
+ # open. You can manually close the connection with #finish.
+ #
# For all the Net::HTTP request objects and shortcut request methods you may
# supply either a String for the request path or a URI from which Net::HTTP
# will extract the request path.
@@ -169,7 +170,7 @@ module Net #:nodoc:
# === POST
#
# A POST can be made using the Net::HTTP::Post request class. This example
- # creates a URL encoded POST body:
+ # creates a urlencoded POST body:
#
# uri = URI('http://www.example.com/todo.cgi')
# req = Net::HTTP::Post.new(uri)
@@ -186,10 +187,13 @@ module Net #:nodoc:
# res.value
# end
#
- # To send multipart/form-data use Net::HTTPHeader#set_form:
+ # At this time Net::HTTP does not support multipart/form-data. To send
+ # multipart/form-data use Net::HTTPRequest#body= and
+ # Net::HTTPRequest#content_type=:
#
# req = Net::HTTP::Post.new(uri)
- # req.set_form([['upload', File.open('foo.bar')]], 'multipart/form-data')
+ # req.body = multipart_data
+ # req.content_type = 'multipart/form-data'
#
# Other requests that can contain a body such as PUT can be created in the
# same way using the corresponding request class (Net::HTTP::Put).
@@ -218,7 +222,7 @@ module Net #:nodoc:
# === Basic Authentication
#
# Basic authentication is performed according to
- # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt).
+ # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt)
#
# uri = URI('http://example.com/index.html?key=value')
#
@@ -262,7 +266,7 @@ module Net #:nodoc:
# end
#
# Or if you simply want to make a GET request, you may pass in an URI
- # object that has an HTTPS URL. Net::HTTP automatically turns on TLS
+ # object that has a HTTPS URL. Net::HTTP automatically turn on TLS
# verification if the URI object has a 'https' URI scheme.
#
# uri = URI('https://example.com/')
@@ -571,8 +575,8 @@ module Net #:nodoc:
# _opt_ :: optional hash
#
# _opt_ sets following values by its accessor.
- # The keys are ipaddr, ca_file, ca_path, cert, cert_store, ciphers,
- # close_on_empty_response, key, open_timeout, read_timeout, write_timeout, ssl_timeout,
+ # The keys are ca_file, ca_path, cert, cert_store, ciphers,
+ # close_on_empty_response, key, open_timeout, read_timeout, ssl_timeout,
# ssl_version, use_ssl, verify_callback, verify_depth and verify_mode.
# If you set :use_ssl as true, you can use https and default value of
# verify_mode is set as OpenSSL::SSL::VERIFY_PEER.
@@ -590,7 +594,6 @@ module Net #:nodoc:
p_addr = :ENV if arg.size < 2
port = https_default_port if !port && opt && opt[:use_ssl]
http = new(address, port, p_addr, p_port, p_user, p_pass)
- http.ipaddr = opt[:ipaddr] if opt && opt[:ipaddr]
if opt
if opt[:use_ssl]
@@ -661,7 +664,6 @@ module Net #:nodoc:
def initialize(address, port = nil)
@address = address
@port = (port || HTTP.default_port)
- @ipaddr = nil
@local_host = nil
@local_port = nil
@curr_http_version = HTTPVersion
@@ -672,7 +674,6 @@ module Net #:nodoc:
@started = false
@open_timeout = 60
@read_timeout = 60
- @write_timeout = 60
@continue_timeout = nil
@max_retries = 1
@debug_output = nil
@@ -729,17 +730,6 @@ module Net #:nodoc:
attr_writer :proxy_user
attr_writer :proxy_pass
- # The IP address to connect to/used to connect to
- def ipaddr
- started? ? @socket.io.peeraddr[3] : @ipaddr
- end
-
- # Set the IP address to connect to
- def ipaddr=(addr)
- raise IOError, "ipaddr value changed, but session already started" if started?
- @ipaddr = addr
- end
-
# Number of seconds to wait for the connection to open. Any number
# may be used, including Floats for fractional seconds. If the HTTP
# object cannot open a connection in this many seconds, it raises a
@@ -752,13 +742,6 @@ module Net #:nodoc:
# it raises a Net::ReadTimeout exception. The default value is 60 seconds.
attr_reader :read_timeout
- # Number of seconds to wait for one block to be written (via one write(2)
- # call). Any number may be used, including Floats for fractional
- # seconds. If the HTTP object cannot write data in this many seconds,
- # it raises a Net::WriteTimeout exception. The default value is 60 seconds.
- # Net::WriteTimeout is not raised on Windows.
- attr_reader :write_timeout
-
# Maximum number of times to retry an idempotent request in case of
# Net::ReadTimeout, IOError, EOFError, Errno::ECONNRESET,
# Errno::ECONNABORTED, Errno::EPIPE, OpenSSL::SSL::SSLError,
@@ -781,12 +764,6 @@ module Net #:nodoc:
@read_timeout = sec
end
- # Setter for the write_timeout attribute.
- def write_timeout=(sec)
- @socket.write_timeout = sec if @socket
- @write_timeout = sec
- end
-
# Seconds to wait for 100 Continue response. If the HTTP object does not
# receive a response in this many seconds it sends the request body. The
# default value is +nil+.
@@ -947,20 +924,20 @@ module Net #:nodoc:
def connect
if proxy? then
- conn_addr = proxy_address
- conn_port = proxy_port
+ conn_address = proxy_address
+ conn_port = proxy_port
else
- conn_addr = conn_address
- conn_port = port
+ conn_address = address
+ conn_port = port
end
- D "opening connection to #{conn_addr}:#{conn_port}..."
+ D "opening connection to #{conn_address}:#{conn_port}..."
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
begin
- TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
+ TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
rescue => e
raise e, "Failed to open TCP connection to " +
- "#{conn_addr}:#{conn_port} (#{e.message})"
+ "#{conn_address}:#{conn_port} (#{e.message})"
end
}
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
@@ -968,10 +945,9 @@ module Net #:nodoc:
if use_ssl?
if proxy?
plain_sock = BufferedIO.new(s, read_timeout: @read_timeout,
- write_timeout: @write_timeout,
continue_timeout: @continue_timeout,
debug_output: @debug_output)
- buf = "CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n"
+ buf = "CONNECT #{@address}:#{@port} HTTP/#{HTTPVersion}\r\n"
buf << "Host: #{@address}:#{@port}\r\n"
if proxy_user
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m0')
@@ -997,7 +973,7 @@ module Net #:nodoc:
OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE
@ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess }
- D "starting SSL for #{conn_addr}:#{conn_port}..."
+ D "starting SSL for #{conn_address}:#{conn_port}..."
s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
s.sync_close = true
# Server Name Indication (SNI) RFC 3546
@@ -1010,10 +986,9 @@ module Net #:nodoc:
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
s.post_connection_check(@address)
end
- D "SSL established, protocol: #{s.ssl_version}, cipher: #{s.cipher[0]}"
+ D "SSL established"
end
@socket = BufferedIO.new(s, read_timeout: @read_timeout,
- write_timeout: @write_timeout,
continue_timeout: @continue_timeout,
debug_output: @debug_output)
on_connect
@@ -1174,7 +1149,7 @@ module Net #:nodoc:
# without proxy, obsolete
def conn_address # :nodoc:
- @ipaddr || address()
+ address()
end
def conn_port # :nodoc:
@@ -1517,13 +1492,7 @@ module Net #:nodoc:
begin
begin_transport req
res = catch(:response) {
- begin
- req.exec @socket, @curr_http_version, edit_path(req.path)
- rescue Errno::EPIPE
- # Failure when writing full request, but we can probably
- # still read the received response.
- end
-
+ req.exec @socket, @curr_http_version, edit_path(req.path)
begin
res = HTTPResponse.read_new(@socket)
res.decode_content = req.decode_content
@@ -1539,7 +1508,7 @@ module Net #:nodoc:
rescue Net::OpenTimeout
raise
rescue Net::ReadTimeout, IOError, EOFError,
- Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE, Errno::ETIMEDOUT,
+ Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE,
# avoid a dependency on OpenSSL
defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError,
Timeout::Error => exception
diff --git a/lib/net/http/exceptions.rb b/lib/net/http/exceptions.rb
index da5f7a70fc..0d34526616 100644
--- a/lib/net/http/exceptions.rb
+++ b/lib/net/http/exceptions.rb
@@ -20,14 +20,7 @@ class Net::HTTPServerException < Net::ProtoServerError
# We cannot use the name "HTTPServerError", it is the name of the response.
include Net::HTTPExceptions
end
-
-# for compatibility
-Net::HTTPClientException = Net::HTTPServerException
-
class Net::HTTPFatalError < Net::ProtoFatalError
include Net::HTTPExceptions
end
-module Net
- deprecate_constant(:HTTPServerException)
-end
diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb
index 003f59d0ac..526cc333fc 100644
--- a/lib/net/http/generic_request.rb
+++ b/lib/net/http/generic_request.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: false
-# HTTPGenericRequest is the parent of the Net::HTTPRequest class.
-# Do not use this directly; use a subclass of Net::HTTPRequest.
+# HTTPGenericRequest is the parent of the HTTPRequest class.
+# Do not use this directly; use a subclass of HTTPRequest.
#
-# Mixes in the Net::HTTPHeader module to provide easier access to HTTP headers.
+# Mixes in the HTTPHeader module to provide easier access to HTTP headers.
#
class Net::HTTPGenericRequest
@@ -14,8 +14,6 @@ class Net::HTTPGenericRequest
@response_has_body = resbody
if URI === uri_or_path then
- raise ArgumentError, "not an HTTP URI" unless URI::HTTP === uri_or_path
- raise ArgumentError, "no host component for URI" unless uri_or_path.hostname
@uri = uri_or_path.dup
host = @uri.hostname.dup
host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port
@@ -170,8 +168,9 @@ class Net::HTTPGenericRequest
def write(buf)
# avoid memcpy() of buf, buf can huge and eat memory bandwidth
- rv = buf.bytesize
- @sock.write("#{rv.to_s(16)}\r\n", buf, "\r\n")
+ @sock.write("#{buf.bytesize.to_s(16)}\r\n")
+ rv = @sock.write(buf)
+ @sock.write("\r\n")
rv
end
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb
index 8641be4eae..96d898c89f 100644
--- a/lib/net/http/header.rb
+++ b/lib/net/http/header.rb
@@ -14,15 +14,15 @@ module Net::HTTPHeader
@header = {}
return unless initheader
initheader.each do |key, value|
- warn "net/http: duplicated HTTP header: #{key}", uplevel: 3 if key?(key) and $VERBOSE
+ warn "net/http: duplicated HTTP header: #{key}", uplevel: 1 if key?(key) and $VERBOSE
if value.nil?
- warn "net/http: nil HTTP header: #{key}", uplevel: 3 if $VERBOSE
+ warn "net/http: nil HTTP header: #{key}", uplevel: 1 if $VERBOSE
else
value = value.strip # raise error for invalid byte sequences
if value.count("\r\n") > 0
- raise ArgumentError, "header #{key} has field value #{value.inspect}, this cannot include CR/LF"
+ raise ArgumentError, 'header field value cannot include CR/LF'
end
- @header[key.downcase.to_s] = [value]
+ @header[key.downcase] = [value]
end
end
end
@@ -36,14 +36,14 @@ module Net::HTTPHeader
# Returns the header field corresponding to the case-insensitive key.
# For example, a key of "Content-Type" might return "text/html"
def [](key)
- a = @header[key.downcase.to_s] or return nil
+ a = @header[key.downcase] or return nil
a.join(', ')
end
# Sets the header field corresponding to the case-insensitive key.
def []=(key, val)
unless val
- @header.delete key.downcase.to_s
+ @header.delete key.downcase
return val
end
set_field(key, val)
@@ -65,9 +65,8 @@ module Net::HTTPHeader
# p request.get_fields('X-My-Header') #=> ["a", "b", "c"]
#
def add_field(key, val)
- stringified_downcased_key = key.downcase.to_s
- if @header.key?(stringified_downcased_key)
- append_field_value(@header[stringified_downcased_key], val)
+ if @header.key?(key.downcase)
+ append_field_value(@header[key.downcase], val)
else
set_field(key, val)
end
@@ -78,13 +77,13 @@ module Net::HTTPHeader
when Enumerable
ary = []
append_field_value(ary, val)
- @header[key.downcase.to_s] = ary
+ @header[key.downcase] = ary
else
val = val.to_s # for compatibility use to_s instead of to_str
if val.b.count("\r\n") > 0
raise ArgumentError, 'header field value cannot include CR/LF'
end
- @header[key.downcase.to_s] = [val]
+ @header[key.downcase] = [val]
end
end
@@ -113,9 +112,8 @@ module Net::HTTPHeader
# #=> "session=al98axx; expires=Fri, 31-Dec-1999 23:58:23, query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"
#
def get_fields(key)
- stringified_downcased_key = key.downcase.to_s
- return nil unless @header[stringified_downcased_key]
- @header[stringified_downcased_key].dup
+ return nil unless @header[key.downcase]
+ @header[key.downcase].dup
end
# Returns the header field corresponding to the case-insensitive key.
@@ -123,7 +121,7 @@ module Net::HTTPHeader
# raises an IndexError if there's no header field named +key+
# See Hash#fetch
def fetch(key, *args, &block) #:yield: +key+
- a = @header.fetch(key.downcase.to_s, *args, &block)
+ a = @header.fetch(key.downcase, *args, &block)
a.kind_of?(Array) ? a.join(', ') : a
end
@@ -184,12 +182,12 @@ module Net::HTTPHeader
# Removes a header field, specified by case-insensitive key.
def delete(key)
- @header.delete(key.downcase.to_s)
+ @header.delete(key.downcase)
end
# true if +key+ header exists.
def key?(key)
- @header.key?(key.downcase.to_s)
+ @header.key?(key.downcase)
end
# Returns a Hash consisting of header names and array of values.
@@ -323,7 +321,7 @@ module Net::HTTPHeader
end
# Returns "true" if the "transfer-encoding" header is present and
- # set to "chunked". This is an HTTP/1.1 feature, allowing
+ # set to "chunked". This is an HTTP/1.1 feature, allowing the
# the content to be sent in "chunks" without at the outset
# stating the entire content length.
def chunked?
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 08eaeb2cac..6a78272ac8 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -8,13 +8,11 @@
# header values both via hash-like methods and via individual readers.
#
# Note that each possible HTTP response code defines its own
-# HTTPResponse subclass. All classes are defined under the Net module.
-# Indentation indicates inheritance. For a list of the classes see Net::HTTP.
+# HTTPResponse subclass. These are listed below.
#
-# Correspondence <code>HTTP code => class</code> is stored in CODE_TO_OBJ
-# constant:
+# All classes are defined under the Net module. Indentation indicates
+# inheritance. For a list of the classes see Net::HTTP.
#
-# Net::HTTPResponse::CODE_TO_OBJ['404'] #=> Net::HTTPNotFound
#
class Net::HTTPResponse
class << self
@@ -176,10 +174,6 @@ class Net::HTTPResponse
# If a block is given, the body is passed to the block, and
# the body is provided in fragments, as it is read in from the socket.
#
- # If +dest+ argument is given, response is read into that variable,
- # with <code>dest#<<</code> method (it could be String or IO, or any
- # other object responding to <code><<</code>).
- #
# Calling this method a second or subsequent time for the same
# HTTPResponse object will return the value already read.
#
@@ -268,13 +262,12 @@ class Net::HTTPResponse
begin
yield inflate_body_io
- success = true
ensure
+ orig_err = $!
begin
inflate_body_io.finish
rescue => err
- # Ignore #finish's error if there is an exception from yield
- raise err if success
+ raise orig_err || err
end
end
when 'none', 'identity' then
@@ -387,7 +380,6 @@ class Net::HTTPResponse
end
block = proc do |compressed_chunk|
@inflate.inflate(compressed_chunk) do |chunk|
- compressed_chunk.clear
dest << chunk
end
end
diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb
index 50352032df..c4259e1a02 100644
--- a/lib/net/http/responses.rb
+++ b/lib/net/http/responses.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: true
+# frozen_string_literal: false
# :stopdoc:
# https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
class Net::HTTPUnknownResponse < Net::HTTPResponse
@@ -19,7 +19,7 @@ class Net::HTTPRedirection < Net::HTTPResponse # 3xx
end
class Net::HTTPClientError < Net::HTTPResponse # 4xx
HAS_BODY = true
- EXCEPTION_TYPE = Net::HTTPClientException # for backward compatibility
+ EXCEPTION_TYPE = Net::HTTPServerException # for backward compatibility
end
class Net::HTTPServerError < Net::HTTPResponse # 5xx
HAS_BODY = true
@@ -35,9 +35,6 @@ end
class Net::HTTPProcessing < Net::HTTPInformation # 102
HAS_BODY = false
end
-class Net::HTTPEarlyHints < Net::HTTPInformation # 103 - RFC 8297
- HAS_BODY = false
-end
class Net::HTTPOK < Net::HTTPSuccess # 200
HAS_BODY = true
@@ -122,10 +119,9 @@ end
class Net::HTTPProxyAuthenticationRequired < Net::HTTPClientError # 407
HAS_BODY = true
end
-class Net::HTTPRequestTimeout < Net::HTTPClientError # 408
+class Net::HTTPRequestTimeOut < Net::HTTPClientError # 408
HAS_BODY = true
end
-Net::HTTPRequestTimeOut = Net::HTTPRequestTimeout
class Net::HTTPConflict < Net::HTTPClientError # 409
HAS_BODY = true
end
@@ -138,22 +134,19 @@ end
class Net::HTTPPreconditionFailed < Net::HTTPClientError # 412
HAS_BODY = true
end
-class Net::HTTPPayloadTooLarge < Net::HTTPClientError # 413
+class Net::HTTPRequestEntityTooLarge < Net::HTTPClientError # 413
HAS_BODY = true
end
-Net::HTTPRequestEntityTooLarge = Net::HTTPPayloadTooLarge
-class Net::HTTPURITooLong < Net::HTTPClientError # 414
+class Net::HTTPRequestURITooLong < Net::HTTPClientError # 414
HAS_BODY = true
end
-Net::HTTPRequestURITooLong = Net::HTTPURITooLong
Net::HTTPRequestURITooLarge = Net::HTTPRequestURITooLong
class Net::HTTPUnsupportedMediaType < Net::HTTPClientError # 415
HAS_BODY = true
end
-class Net::HTTPRangeNotSatisfiable < Net::HTTPClientError # 416
+class Net::HTTPRequestedRangeNotSatisfiable < Net::HTTPClientError # 416
HAS_BODY = true
end
-Net::HTTPRequestedRangeNotSatisfiable = Net::HTTPRangeNotSatisfiable
class Net::HTTPExpectationFailed < Net::HTTPClientError # 417
HAS_BODY = true
end
@@ -204,10 +197,9 @@ end
class Net::HTTPServiceUnavailable < Net::HTTPServerError # 503
HAS_BODY = true
end
-class Net::HTTPGatewayTimeout < Net::HTTPServerError # 504
+class Net::HTTPGatewayTimeOut < Net::HTTPServerError # 504
HAS_BODY = true
end
-Net::HTTPGatewayTimeOut = Net::HTTPGatewayTimeout
class Net::HTTPVersionNotSupported < Net::HTTPServerError # 505
HAS_BODY = true
end
@@ -240,7 +232,6 @@ class Net::HTTPResponse
'100' => Net::HTTPContinue,
'101' => Net::HTTPSwitchProtocol,
'102' => Net::HTTPProcessing,
- '103' => Net::HTTPEarlyHints,
'200' => Net::HTTPOK,
'201' => Net::HTTPCreated,
@@ -270,15 +261,15 @@ class Net::HTTPResponse
'405' => Net::HTTPMethodNotAllowed,
'406' => Net::HTTPNotAcceptable,
'407' => Net::HTTPProxyAuthenticationRequired,
- '408' => Net::HTTPRequestTimeout,
+ '408' => Net::HTTPRequestTimeOut,
'409' => Net::HTTPConflict,
'410' => Net::HTTPGone,
'411' => Net::HTTPLengthRequired,
'412' => Net::HTTPPreconditionFailed,
- '413' => Net::HTTPPayloadTooLarge,
- '414' => Net::HTTPURITooLong,
+ '413' => Net::HTTPRequestEntityTooLarge,
+ '414' => Net::HTTPRequestURITooLong,
'415' => Net::HTTPUnsupportedMediaType,
- '416' => Net::HTTPRangeNotSatisfiable,
+ '416' => Net::HTTPRequestedRangeNotSatisfiable,
'417' => Net::HTTPExpectationFailed,
'421' => Net::HTTPMisdirectedRequest,
'422' => Net::HTTPUnprocessableEntity,
@@ -294,7 +285,7 @@ class Net::HTTPResponse
'501' => Net::HTTPNotImplemented,
'502' => Net::HTTPBadGateway,
'503' => Net::HTTPServiceUnavailable,
- '504' => Net::HTTPGatewayTimeout,
+ '504' => Net::HTTPGatewayTimeOut,
'505' => Net::HTTPVersionNotSupported,
'506' => Net::HTTPVariantAlsoNegotiates,
'507' => Net::HTTPInsufficientStorage,
@@ -305,3 +296,4 @@ class Net::HTTPResponse
end
# :startdoc:
+
diff --git a/lib/net/http/status.rb b/lib/net/http/status.rb
index 8db3f7d9e3..c7a4c0cee3 100644
--- a/lib/net/http/status.rb
+++ b/lib/net/http/status.rb
@@ -1,6 +1,7 @@
+#!/usr/bin/env ruby
# frozen_string_literal: true
-require_relative '../http'
+require 'net/http'
if $0 == __FILE__
require 'open-uri'
@@ -23,7 +24,6 @@ Net::HTTP::STATUS_CODES = {
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
- 103 => 'Early Hints',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
diff --git a/lib/net/https.rb b/lib/net/https.rb
index d46721c82a..58cb6ddf19 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -19,5 +19,5 @@
=end
-require_relative 'http'
+require 'net/http'
require 'openssl'
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 94ef78198f..da7d0d555c 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -18,7 +18,7 @@ require "socket"
require "monitor"
require "digest/md5"
require "strscan"
-require_relative 'protocol'
+require 'net/protocol'
begin
require "openssl"
rescue LoadError
@@ -903,9 +903,8 @@ module Net
# end
# }
#
- def add_response_handler(handler = nil, &block)
- raise ArgumentError, "two Procs are passed" if handler && block
- @response_handlers.push(block || handler)
+ def add_response_handler(handler = Proc.new)
+ @response_handlers.push(handler)
end
# Removes the response handler.
@@ -960,7 +959,7 @@ module Net
put_string("#{tag} IDLE#{CRLF}")
begin
- add_response_handler(&response_handler)
+ add_response_handler(response_handler)
@idle_done_cond = new_cond
@idle_done_cond.wait(timeout)
@idle_done_cond = nil
@@ -1000,7 +999,7 @@ module Net
def self.decode_utf7(s)
return s.gsub(/&([^-]+)?-/n) {
if $1
- ($1.tr(",", "/") + "===").unpack1("m").encode(Encoding::UTF_8, Encoding::UTF_16BE)
+ ($1.tr(",", "/") + "===").unpack("m")[0].encode(Encoding::UTF_8, Encoding::UTF_16BE)
else
"&"
end
@@ -1130,9 +1129,7 @@ module Net
end
def tcp_socket(host, port)
- s = Socket.tcp(host, port, :connect_timeout => @open_timeout)
- s.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, true)
- s
+ Socket.tcp(host, port, :connect_timeout => @open_timeout)
rescue Errno::ETIMEDOUT
raise Net::OpenTimeout, "Timeout to open TCP connection to " +
"#{host}:#{port} (exceeds #{@open_timeout} seconds)"
@@ -1216,14 +1213,12 @@ module Net
end
resp = @tagged_responses.delete(tag)
case resp.name
- when /\A(?:OK)\z/ni
- return resp
when /\A(?:NO)\z/ni
raise NoResponseError, resp
when /\A(?:BAD)\z/ni
raise BadResponseError, resp
else
- raise UnknownResponseError, resp
+ return resp
end
end
@@ -1270,7 +1265,7 @@ module Net
@logout_command_tag = tag
end
if block
- add_response_handler(&block)
+ add_response_handler(block)
end
begin
return get_tagged_response(tag, cmd)
@@ -3241,7 +3236,7 @@ module Net
if atom
atom
else
- symbol = flag.capitalize.intern
+ symbol = flag.capitalize.untaint.intern
@flag_symbols[symbol] = true
if @flag_symbols.length > IMAP.max_flag_count
raise FlagCountError, "number of flag symbols exceeded"
@@ -3719,10 +3714,6 @@ module Net
class ByeResponseError < ResponseError
end
- # Error raised upon an unknown response from the server.
- class UnknownResponseError < ResponseError
- end
-
RESPONSE_ERRORS = Hash.new(ResponseError)
RESPONSE_ERRORS["NO"] = NoResponseError
RESPONSE_ERRORS["BAD"] = BadResponseError
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 8712345301..92a4fe7303 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -549,7 +549,6 @@ module Net
context = OpenSSL::SSL::SSLContext.new
context.set_params(@ssl_params)
s = OpenSSL::SSL::SSLSocket.new(s, context)
- s.hostname = @address
s.sync_close = true
ssl_socket_connect(s, @open_timeout)
if context.verify_mode != OpenSSL::SSL::VERIFY_NONE
diff --git a/lib/net/pop/net-pop.gemspec b/lib/net/pop/net-pop.gemspec
deleted file mode 100644
index c1b0ffbd2b..0000000000
--- a/lib/net/pop/net-pop.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/net/pop/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "net-pop"
- spec.version = Net::POP3::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Ruby client library for POP3.}
- spec.description = %q{Ruby client library for POP3.}
- spec.homepage = "https://github.com/ruby/net-pop"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/net/pop/version.rb b/lib/net/pop/version.rb
deleted file mode 100644
index ef5c295cc3..0000000000
--- a/lib/net/pop/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Net
- class Protocol; end
- class POP3 < Protocol
- VERSION = "0.1.0"
- end
-end
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 07fbc6a21f..0e887d5aa9 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -75,54 +75,20 @@ module Net # :nodoc:
# ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the
# response cannot be read within the read_timeout.
- class ReadTimeout < Timeout::Error
- def initialize(io = nil)
- @io = io
- end
- attr_reader :io
-
- def message
- msg = super
- if @io
- msg = "#{msg} with #{@io.inspect}"
- end
- msg
- end
- end
-
- ##
- # WriteTimeout, a subclass of Timeout::Error, is raised if a chunk of the
- # response cannot be written within the write_timeout. Not raised on Windows.
-
- class WriteTimeout < Timeout::Error
- def initialize(io = nil)
- @io = io
- end
- attr_reader :io
-
- def message
- msg = super
- if @io
- msg = "#{msg} with #{@io.inspect}"
- end
- msg
- end
- end
+ class ReadTimeout < Timeout::Error; end
class BufferedIO #:nodoc: internal use only
- def initialize(io, read_timeout: 60, write_timeout: 60, continue_timeout: nil, debug_output: nil)
+ def initialize(io, read_timeout: 60, continue_timeout: nil, debug_output: nil)
@io = io
@read_timeout = read_timeout
- @write_timeout = write_timeout
@continue_timeout = continue_timeout
@debug_output = debug_output
- @rbuf = ''.b
+ @rbuf = ''.dup
end
attr_reader :io
attr_accessor :read_timeout
- attr_accessor :write_timeout
attr_accessor :continue_timeout
attr_accessor :debug_output
@@ -148,7 +114,7 @@ module Net # :nodoc:
public
- def read(len, dest = ''.b, ignore_eof = false)
+ def read(len, dest = ''.dup, ignore_eof = false)
LOG "reading #{len} bytes..."
read_bytes = 0
begin
@@ -168,7 +134,7 @@ module Net # :nodoc:
dest
end
- def read_all(dest = ''.b)
+ def read_all(dest = ''.dup)
LOG 'reading all...'
read_bytes = 0
begin
@@ -206,20 +172,18 @@ module Net # :nodoc:
BUFSIZE = 1024 * 16
def rbuf_fill
- tmp = @rbuf.empty? ? @rbuf : nil
- case rv = @io.read_nonblock(BUFSIZE, tmp, exception: false)
+ case rv = @io.read_nonblock(BUFSIZE, exception: false)
when String
- return if rv.equal?(tmp)
@rbuf << rv
rv.clear
return
when :wait_readable
- (io = @io.to_io).wait_readable(@read_timeout) or raise Net::ReadTimeout.new(io)
+ @io.to_io.wait_readable(@read_timeout) or raise Net::ReadTimeout
# continue looping
when :wait_writable
# OpenSSL::Buffering#read_nonblock may fail with IO::WaitWritable.
# http://www.openssl.org/support/faq.html#PROG10
- (io = @io.to_io).wait_writable(@read_timeout) or raise Net::ReadTimeout.new(io)
+ @io.to_io.wait_writable(@read_timeout) or raise Net::ReadTimeout
# continue looping
when nil
raise EOFError, 'end of file reached'
@@ -227,12 +191,7 @@ module Net # :nodoc:
end
def rbuf_consume(len)
- if len == @rbuf.size
- s = @rbuf
- @rbuf = ''.b
- else
- s = @rbuf.slice!(0, len)
- end
+ s = @rbuf.slice!(0, len)
@debug_output << %Q[-> #{s.dump}\n] if @debug_output
s
end
@@ -243,9 +202,9 @@ module Net # :nodoc:
public
- def write(*strs)
+ def write(str)
writing {
- write0(*strs)
+ write0 str
}
end
@@ -269,34 +228,11 @@ module Net # :nodoc:
bytes
end
- def write0(*strs)
- @debug_output << strs.map(&:dump).join if @debug_output
- orig_written_bytes = @written_bytes
- strs.each_with_index do |str, i|
- need_retry = true
- case len = @io.write_nonblock(str, exception: false)
- when Integer
- @written_bytes += len
- len -= str.bytesize
- if len == 0
- if strs.size == i+1
- return @written_bytes - orig_written_bytes
- else
- need_retry = false
- # next string
- end
- elsif len < 0
- str = str.byteslice(len, -len)
- else # len > 0
- need_retry = false
- # next string
- end
- # continue looping
- when :wait_writable
- (io = @io.to_io).wait_writable(@write_timeout) or raise Net::WriteTimeout.new(io)
- # continue looping
- end while need_retry
- end
+ def write0(str)
+ @debug_output << str.dump if @debug_output
+ len = @io.write(str)
+ @written_bytes += len
+ len
end
#
@@ -322,7 +258,7 @@ module Net # :nodoc:
class InternetMessageIO < BufferedIO #:nodoc: internal use only
- def initialize(*, **)
+ def initialize(*)
super
@wbuf = nil
end
@@ -337,7 +273,7 @@ module Net # :nodoc:
read_bytes = 0
while (line = readuntil("\r\n")) != ".\r\n"
read_bytes += line.size
- yield line.delete_prefix('.')
+ yield line.sub(/\A\./, '')
end
LOG_on()
LOG "read message (#{read_bytes} bytes)"
@@ -399,7 +335,7 @@ module Net # :nodoc:
end
def using_each_crlf_line
- @wbuf = ''.b
+ @wbuf = ''.dup
yield
if not @wbuf.empty? # unterminated last line
write0 dot_stuff(@wbuf.chomp) + "\r\n"
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 460ad08233..1777a7fa7e 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -38,7 +38,7 @@ module Net
include SMTPError
end
- # Represents SMTP error code 4xx, a temporary error.
+ # Represents SMTP error code 420 or 450, a temporary error.
class SMTPServerBusy < ProtoServerError
include SMTPError
end
@@ -831,6 +831,9 @@ module Net
end
def mailfrom(from_addr)
+ if $SAFE > 0
+ raise SecurityError, 'tainted from_addr' if from_addr.tainted?
+ end
getok("MAIL FROM:<#{from_addr}>")
end
@@ -856,6 +859,9 @@ module Net
end
def rcptto(to_addr)
+ if $SAFE > 0
+ raise SecurityError, 'tainted to_addr' if to_addr.tainted?
+ end
getok("RCPT TO:<#{to_addr}>")
end
diff --git a/lib/net/smtp/net-smtp.gemspec b/lib/net/smtp/net-smtp.gemspec
deleted file mode 100644
index 1dddfa7ca8..0000000000
--- a/lib/net/smtp/net-smtp.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/net/smtp/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "net-smtp"
- spec.version = Net::SMTP::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Simple Mail Transfer Protocol client library for Ruby.}
- spec.description = %q{Simple Mail Transfer Protocol client library for Ruby.}
- spec.homepage = "https://github.com/ruby/net-smtp"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/net/smtp/version.rb b/lib/net/smtp/version.rb
deleted file mode 100644
index 7f5aaaa6db..0000000000
--- a/lib/net/smtp/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Net
- class Protocol; end
- class SMTP < Protocol
- VERSION = "0.1.0"
- end
-end
diff --git a/lib/observer/observer.gemspec b/lib/observer/observer.gemspec
deleted file mode 100644
index 188c6bae76..0000000000
--- a/lib/observer/observer.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/observer/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "observer"
- spec.version = Observer::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Implementation of the Observer object-oriented design pattern.}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/observer"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/observer/version.rb b/lib/observer/version.rb
deleted file mode 100644
index 92b5098774..0000000000
--- a/lib/observer/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Observer
- VERSION = "0.1.0"
-end
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index c52f67f525..c0ef89c2ec 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -10,38 +10,23 @@ module Kernel
alias open_uri_original_open open # :nodoc:
end
- def open(name, *rest, **kw, &block) # :nodoc:
- if (name.respond_to?(:open) && !name.respond_to?(:to_path)) ||
- (name.respond_to?(:to_str) &&
- %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name &&
- (uri = URI.parse(name)).respond_to?(:open))
- warn('calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open', uplevel: 1)
- URI.open(name, *rest, **kw, &block)
- else
- open_uri_original_open(name, *rest, **kw, &block)
- end
- end
- module_function :open
-end
-
-module URI
# Allows the opening of various resources including URIs.
#
# If the first argument responds to the 'open' method, 'open' is called on
# it with the rest of the arguments.
#
- # If the first argument is a string that begins with <code>(protocol)://<code>, it is parsed by
+ # If the first argument is a string that begins with xxx://, it is parsed by
# URI.parse. If the parsed object responds to the 'open' method,
# 'open' is called on it with the rest of the arguments.
#
- # Otherwise, Kernel#open is called.
+ # Otherwise, the original Kernel#open is called.
#
# OpenURI::OpenRead#open provides URI::HTTP#open, URI::HTTPS#open and
# URI::FTP#open, Kernel#open.
#
# We can accept URIs and strings that begin with http://, https:// and
# ftp://. In these cases, the opened file object is extended by OpenURI::Meta.
- def self.open(name, *rest, &block)
+ def open(name, *rest, &block) # :doc:
if name.respond_to?(:open)
name.open(*rest, &block)
elsif name.respond_to?(:to_str) &&
@@ -50,10 +35,16 @@ module URI
uri.open(*rest, &block)
else
open_uri_original_open(name, *rest, &block)
- # After Kernel#open override is removed:
- #super
end
end
+ module_function :open
+end
+
+module URI #:nodoc:
+ # alias for Kernel.open defined in open-uri.
+ def self.open(name, *rest, &block)
+ Kernel.open(name, *rest, &block)
+ end
end
# OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
@@ -62,14 +53,14 @@ end
#
# It is possible to open an http, https or ftp URL as though it were a file:
#
-# URI.open("http://www.ruby-lang.org/") {|f|
+# open("http://www.ruby-lang.org/") {|f|
# f.each_line {|line| p line}
# }
#
# The opened file has several getter methods for its meta-information, as
# follows, since it is extended by OpenURI::Meta.
#
-# URI.open("http://www.ruby-lang.org/en") {|f|
+# open("http://www.ruby-lang.org/en") {|f|
# f.each_line {|line| p line}
# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
# p f.content_type # "text/html"
@@ -80,7 +71,7 @@ end
#
# Additional header fields can be specified by an optional hash argument.
#
-# URI.open("http://www.ruby-lang.org/en/",
+# open("http://www.ruby-lang.org/en/",
# "User-Agent" => "Ruby/#{RUBY_VERSION}",
# "From" => "foo@bar.invalid",
# "Referer" => "http://www.ruby-lang.org/") {|f|
@@ -90,11 +81,11 @@ end
# The environment variables such as http_proxy, https_proxy and ftp_proxy
# are in effect by default. Here we disable proxy:
#
-# URI.open("http://www.ruby-lang.org/en/", :proxy => nil) {|f|
+# open("http://www.ruby-lang.org/en/", :proxy => nil) {|f|
# # ...
# }
#
-# See OpenURI::OpenRead.open and URI.open for more on available options.
+# See OpenURI::OpenRead.open and Kernel#open for more on available options.
#
# URI objects can be opened in a similar way.
#
@@ -363,7 +354,6 @@ module OpenURI
if options[:progress_proc] && Net::HTTPSuccess === resp
options[:progress_proc].call(buf.size)
end
- str.clear
}
}
}
@@ -552,16 +542,17 @@ module OpenURI
# It can be used to guess charset.
#
# If charset parameter and block is not given,
- # nil is returned except text type.
- # In that case, "utf-8" is returned as defined by RFC6838 4.2.1
+ # nil is returned except text type in HTTP.
+ # In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1.
def charset
type, *parameters = content_type_parse
if pair = parameters.assoc('charset')
pair.last.downcase
elsif block_given?
yield
- elsif type && %r{\Atext/} =~ type
- "utf-8" # RFC6838 4.2.1
+ elsif type && %r{\Atext/} =~ type &&
+ @base_uri && /\Ahttp\z/i =~ @base_uri.scheme
+ "iso-8859-1" # RFC2616 3.7.1
else
nil
end
diff --git a/lib/open3.rb b/lib/open3.rb
index 5e725317a4..2bbead2951 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -81,13 +81,7 @@ module Open3
# If merged stdout and stderr output is not a problem, you can use Open3.popen2e.
# If you really need stdout and stderr output as separate strings, you can consider Open3.capture3.
#
- def popen3(*cmd, &block)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
+ def popen3(*cmd, **opts, &block)
in_r, in_w = IO.pipe
opts[:in] = in_r
in_w.sync = true
@@ -142,13 +136,7 @@ module Open3
# p o.read #=> "*"
# }
#
- def popen2(*cmd, &block)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
+ def popen2(*cmd, **opts, &block)
in_r, in_w = IO.pipe
opts[:in] = in_r
in_w.sync = true
@@ -191,13 +179,7 @@ module Open3
# }
# }
#
- def popen2e(*cmd, &block)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
+ def popen2e(*cmd, **opts, &block)
in_r, in_w = IO.pipe
opts[:in] = in_r
in_w.sync = true
@@ -210,6 +192,10 @@ module Open3
module_function :popen2e
def popen_run(cmd, opts, child_io, parent_io) # :nodoc:
+ if last = Hash.try_convert(cmd.last)
+ opts = opts.merge(last)
+ cmd.pop
+ end
pid = spawn(*cmd, opts)
wait_thr = Process.detach(pid)
child_io.each(&:close)
@@ -268,16 +254,7 @@ module Open3
# STDOUT.binmode; print thumbnail
# end
#
- def capture3(*cmd)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- stdin_data = opts.delete(:stdin_data) || ''
- binmode = opts.delete(:binmode)
-
+ def capture3(*cmd, stdin_data: '', binmode: false, **opts)
popen3(*cmd, opts) {|i, o, e, t|
if binmode
i.binmode
@@ -329,16 +306,7 @@ module Open3
# End
# image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
#
- def capture2(*cmd)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- stdin_data = opts.delete(:stdin_data)
- binmode = opts.delete(:binmode)
-
+ def capture2(*cmd, stdin_data: nil, binmode: false, **opts)
popen2(*cmd, opts) {|i, o, t|
if binmode
i.binmode
@@ -377,16 +345,7 @@ module Open3
# # capture make log
# make_log, s = Open3.capture2e("make")
#
- def capture2e(*cmd)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- stdin_data = opts.delete(:stdin_data)
- binmode = opts.delete(:binmode)
-
+ def capture2e(*cmd, stdin_data: nil, binmode: false, **opts)
popen2e(*cmd, opts) {|i, oe, t|
if binmode
i.binmode
@@ -451,13 +410,7 @@ module Open3
# stdin.close # send EOF to sort.
# p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n"
# }
- def pipeline_rw(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
+ def pipeline_rw(*cmds, **opts, &block)
in_r, in_w = IO.pipe
opts[:in] = in_r
in_w.sync = true
@@ -507,13 +460,7 @@ module Open3
# p ts[1].value #=> #<Process::Status: pid 24913 exit 0>
# }
#
- def pipeline_r(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
+ def pipeline_r(*cmds, **opts, &block)
out_r, out_w = IO.pipe
opts[:out] = out_w
@@ -549,13 +496,7 @@ module Open3
# i.puts "hello"
# }
#
- def pipeline_w(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
+ def pipeline_w(*cmds, **opts, &block)
in_r, in_w = IO.pipe
opts[:in] = in_r
in_w.sync = true
@@ -608,13 +549,7 @@ module Open3
# p err_r.read # error messages of pdftops and lpr.
# }
#
- def pipeline_start(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
+ def pipeline_start(*cmds, **opts, &block)
if block
pipeline_run(cmds, opts, [], [], &block)
else
@@ -676,13 +611,7 @@ module Open3
# # 106
# # 202
#
- def pipeline(*cmds)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
+ def pipeline(*cmds, **opts)
pipeline_run(cmds, opts, [], []) {|ts|
ts.map(&:value)
}
@@ -728,8 +657,8 @@ module Open3
end
pid = spawn(*cmd, cmd_opts)
wait_thrs << Process.detach(pid)
- r&.close
- w2&.close
+ r.close if r
+ w2.close if w2
r = r2
}
result = parent_io + [wait_thrs]
diff --git a/lib/open3/open3.gemspec b/lib/open3/open3.gemspec
deleted file mode 100644
index 543416e427..0000000000
--- a/lib/open3/open3.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/open3/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "open3"
- spec.version = Open3::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Popen, but with stderr, too}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/open3"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/open3/version.rb b/lib/open3/version.rb
deleted file mode 100644
index c670b79ebc..0000000000
--- a/lib/open3/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Open3
- VERSION = "0.1.0"
-end
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 614ebc3eae..05415901a3 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: true
+# frozen_string_literal: false
#
# optparse.rb - command-line option analysis with the OptionParser class.
#
@@ -125,7 +125,6 @@
# For options that require an argument, option specification strings may include an
# option name in all caps. If an option is used without the required argument,
# an exception will be raised.
-#
# require 'optparse'
#
# options = {}
@@ -138,9 +137,9 @@
#
# Used:
#
-# $ ruby optparse-test.rb -r
+# bash-3.2$ ruby optparse-test.rb -r
# optparse-test.rb:9:in `<main>': missing argument: -r (OptionParser::MissingArgument)
-# $ ruby optparse-test.rb -r my-library
+# bash-3.2$ ruby optparse-test.rb -r my-library
# You required my-library!
#
# === Type Coercion
@@ -169,7 +168,7 @@
# - Array -- Strings separated by ',' (e.g. 1,2,3)
# - Regexp -- Regular expressions. Also includes options.
#
-# We can also add our own coercions, which we will cover below.
+# We can also add our own coercions, which we will cover soon.
#
# ==== Using Built-in Conversions
#
@@ -188,12 +187,13 @@
# end.parse!
#
# Used:
-#
-# $ ruby optparse-test.rb -t nonsense
+# bash-3.2$ ruby optparse-test.rb -t nonsense
# ... invalid argument: -t nonsense (OptionParser::InvalidArgument)
-# $ ruby optparse-test.rb -t 10-11-12
+# from ... time.rb:5:in `block in <top (required)>'
+# from optparse-test.rb:31:in `<main>'
+# bash-3.2$ ruby optparse-test.rb -t 10-11-12
# 2010-11-12 00:00:00 -0500
-# $ ruby optparse-test.rb -t 9:30
+# bash-3.2$ ruby optparse-test.rb -t 9:30
# 2014-08-13 09:30:00 -0400
#
# ==== Creating Custom Conversions
@@ -225,39 +225,13 @@
#
# op.parse!
#
-# Used:
-#
-# $ ruby optparse-test.rb --user 1
+# output:
+# bash-3.2$ ruby optparse-test.rb --user 1
# #<struct User id=1, name="Sam">
-# $ ruby optparse-test.rb --user 2
+# bash-3.2$ ruby optparse-test.rb --user 2
# #<struct User id=2, name="Gandalf">
-# $ ruby optparse-test.rb --user 3
+# bash-3.2$ ruby optparse-test.rb --user 3
# optparse-test.rb:15:in `block in find_user': No User Found for id 3 (RuntimeError)
-#
-# === Store options to a Hash
-#
-# The +into+ option of +order+, +parse+ and so on methods stores command line options into a Hash.
-#
-# require 'optparse'
-#
-# params = {}
-# OptionParser.new do |opts|
-# opts.on('-a')
-# opts.on('-b NUM', Integer)
-# opts.on('-v', '--verbose')
-# end.parse!(into: params)
-#
-# p params
-#
-# Used:
-#
-# $ ruby optparse-test.rb -a
-# {:a=>true}
-# $ ruby optparse-test.rb -a -v
-# {:a=>true, :verbose=>true}
-# $ ruby optparse-test.rb -a -b 100
-# {:a=>true, :b=>100}
-#
# === Complete example
#
# The following example is a complete Ruby program. You can run it and see the
@@ -439,7 +413,7 @@ class OptionParser
candidates = []
block.call do |k, *v|
(if Regexp === k
- kn = ""
+ kn = "".freeze
k === key
else
kn = defined?(k.id2name) ? k.id2name : k
@@ -534,9 +508,8 @@ class OptionParser
def initialize(pattern = nil, conv = nil,
short = nil, long = nil, arg = nil,
- desc = ([] if short or long), block = nil, &_block)
+ desc = ([] if short or long), block = Proc.new)
raise if Array === pattern
- block ||= _block
@pattern, @conv, @short, @long, @arg, @desc, @block =
pattern, conv, short, long, arg, desc, block
end
@@ -592,7 +565,7 @@ class OptionParser
# +max+ columns.
# +indent+:: Prefix string indents all summarized lines.
#
- def summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "")
+ def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
sopts, lopts = [], [], nil
@short.each {|s| sdone.fetch(s) {sopts << s}; sdone[s] = true} if @short
@long.each {|s| ldone.fetch(s) {lopts << s}; ldone[s] = true} if @long
@@ -604,7 +577,7 @@ class OptionParser
while s = lopts.shift
l = left[-1].length + s.length
l += arg.length if left.size == 1 && arg
- l < max or sopts.empty? or left << +''
+ l < max or sopts.empty? or left << ''
left[-1] << (left[-1].empty? ? ' ' * 4 : ', ') << s
end
@@ -655,7 +628,7 @@ class OptionParser
return if sopts.empty? and lopts.empty? # completely hidden
(sopts+lopts).each do |opt|
- # "(-x -c -r)-l[left justify]"
+ # "(-x -c -r)-l[left justify]" \
if /^--\[no-\](.+)$/ =~ opt
o = $1
yield("--#{o}", desc.join(""))
@@ -866,10 +839,6 @@ class OptionParser
__send__(id).complete(opt, icase, *pat, &block)
end
- def get_candidates(id)
- yield __send__(id).keys
- end
-
#
# Iterates over each option, passing the option to the +block+.
#
@@ -1167,7 +1136,7 @@ XXX
#
def banner
unless @banner
- @banner = +"Usage: #{program_name} [options]"
+ @banner = "Usage: #{program_name} [options]"
visit(:add_banner, @banner)
end
@banner
@@ -1196,14 +1165,14 @@ XXX
# Version
#
def version
- (defined?(@version) && @version) || (defined?(::Version) && ::Version)
+ @version || (defined?(::Version) && ::Version)
end
#
# Release code
#
def release
- (defined?(@release) && @release) || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE)
+ @release || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE)
end
#
@@ -1211,7 +1180,7 @@ XXX
#
def ver
if v = version
- str = +"#{program_name} #{[v].join('.')}"
+ str = "#{program_name} #{[v].join('.')}"
str << " (#{v})" if v = release
str
end
@@ -1268,8 +1237,7 @@ XXX
# +indent+:: Indentation, defaults to @summary_indent.
#
def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
- nl = "\n"
- blk ||= proc {|l| to << (l.index(nl, -1) ? l : l + nl)}
+ blk ||= proc {|l| to << (l.index($/, -1) ? l : l + $/)}
visit(:summarize, {}, {}, width, max, indent, &blk)
to
end
@@ -1356,8 +1324,6 @@ XXX
# [Description:]
# Description string for the option.
# "Run verbosely"
- # If you give multiple description strings, each string will be printed
- # line by line.
#
# [Handler:]
# Handler for the parsed argument value. Either give a block or pass a
@@ -1548,10 +1514,7 @@ XXX
#
# Parses command line arguments +argv+ in order. When a block is given,
- # each non-option argument is yielded. When optional +into+ keyword
- # argument is provided, the parsed option values are stored there via
- # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
- # similar object).
+ # each non-option argument is yielded.
#
# Returns the rest of +argv+ left unparsed.
#
@@ -1602,7 +1565,7 @@ XXX
begin
sw, = complete(:short, opt)
# short option matched.
- val = arg.delete_prefix('-')
+ val = arg.sub(/\A-/, '')
has_arg = true
rescue InvalidOption
# if no short options match, try completion with long
@@ -1647,10 +1610,7 @@ XXX
#
# Parses command line arguments +argv+ in permutation mode and returns
- # list of non-option arguments. When optional +into+ keyword
- # argument is provided, the parsed option values are stored there via
- # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
- # similar object).
+ # list of non-option arguments.
#
def permute(*argv, into: nil)
argv = argv[0].dup if argv.size == 1 and Array === argv[0]
@@ -1671,9 +1631,6 @@ XXX
#
# Parses command line arguments +argv+ in order when environment variable
# POSIXLY_CORRECT is set, and in permutation mode otherwise.
- # When optional +into+ keyword argument is provided, the parsed option
- # values are stored there via <code>[]=</code> method (so it can be Hash,
- # or OpenStruct, or other similar object).
#
def parse(*argv, into: nil)
argv = argv[0].dup if argv.size == 1 and Array === argv[0]
@@ -1777,28 +1734,13 @@ XXX
if pat.empty?
search(typ, opt) {|sw| return [sw, opt]} # exact match or...
end
- ambiguous = catch(:ambiguous) {
+ raise AmbiguousOption, catch(:ambiguous) {
visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}
+ raise InvalidOption, opt
}
- exc = ambiguous ? AmbiguousOption : InvalidOption
- raise exc.new(opt, additional: self.method(:additional_message).curry[typ])
end
private :complete
- #
- # Returns additional info.
- #
- def additional_message(typ, opt)
- return unless typ and opt and defined?(DidYouMean::SpellChecker)
- all_candidates = []
- visit(:get_candidates, typ) do |candidates|
- all_candidates.concat(candidates)
- end
- all_candidates.select! {|cand| cand.is_a?(String) }
- checker = DidYouMean::SpellChecker.new(dictionary: all_candidates)
- DidYouMean.formatter.message_for(all_candidates & checker.correct(opt))
- end
-
def candidate(word)
list = []
case word
@@ -1834,26 +1776,13 @@ XXX
# is not present. Returns whether successfully loaded.
#
# +filename+ defaults to basename of the program without suffix in a
- # directory ~/.options, then the basename with '.options' suffix
- # under XDG and Haiku standard places.
+ # directory ~/.options.
#
def load(filename = nil)
- unless filename
- basename = File.basename($0, '.*')
- return true if load(File.expand_path(basename, '~/.options')) rescue nil
- basename << ".options"
- return [
- # XDG
- ENV['XDG_CONFIG_HOME'],
- '~/.config',
- *ENV['XDG_CONFIG_DIRS']&.split(File::PATH_SEPARATOR),
-
- # Haiku
- '~/config/settings',
- ].any? {|dir|
- next if !dir or dir.empty?
- load(File.expand_path(basename, dir)) rescue nil
- }
+ begin
+ filename ||= File.expand_path(File.basename($0, '.*'), '~/.options')
+ rescue
+ return false
end
begin
parse(*IO.readlines(filename).each {|s| s.chomp!})
@@ -2023,18 +1952,15 @@ XXX
#
class ParseError < RuntimeError
# Reason which caused the error.
- Reason = 'parse error'
+ Reason = 'parse error'.freeze
- def initialize(*args, additional: nil)
- @additional = additional
- @arg0, = args
+ def initialize(*args)
@args = args
@reason = nil
end
attr_reader :args
attr_writer :reason
- attr_accessor :additional
#
# Pushes back erred argument(s) to +argv+.
@@ -2079,7 +2005,7 @@ XXX
# Default stringizing method to emit standard error message.
#
def message
- "#{reason}: #{args.join(' ')}#{additional[@arg0] if additional}"
+ reason + ': ' + args.join(' ')
end
alias to_s message
@@ -2089,42 +2015,42 @@ XXX
# Raises when ambiguously completable string is encountered.
#
class AmbiguousOption < ParseError
- const_set(:Reason, 'ambiguous option')
+ const_set(:Reason, 'ambiguous option'.freeze)
end
#
# Raises when there is an argument for a switch which takes no argument.
#
class NeedlessArgument < ParseError
- const_set(:Reason, 'needless argument')
+ const_set(:Reason, 'needless argument'.freeze)
end
#
# Raises when a switch with mandatory argument has no argument.
#
class MissingArgument < ParseError
- const_set(:Reason, 'missing argument')
+ const_set(:Reason, 'missing argument'.freeze)
end
#
# Raises when switch is undefined.
#
class InvalidOption < ParseError
- const_set(:Reason, 'invalid option')
+ const_set(:Reason, 'invalid option'.freeze)
end
#
# Raises when the given argument does not match required format.
#
class InvalidArgument < ParseError
- const_set(:Reason, 'invalid argument')
+ const_set(:Reason, 'invalid argument'.freeze)
end
#
# Raises when the given argument word can't be completed uniquely.
#
class AmbiguousArgument < InvalidArgument
- const_set(:Reason, 'ambiguous argument')
+ const_set(:Reason, 'ambiguous argument'.freeze)
end
#
diff --git a/lib/optparse/ac.rb b/lib/optparse/ac.rb
index 9d520101aa..fb0883f97a 100644
--- a/lib/optparse/ac.rb
+++ b/lib/optparse/ac.rb
@@ -13,8 +13,6 @@ class OptionParser::AC < OptionParser
end
end
- ARG_CONV = proc {|val| val.nil? ? true : val}
-
def _ac_arg_enable(prefix, name, help_string, block)
_check_ac_args(name, block)
@@ -22,9 +20,8 @@ class OptionParser::AC < OptionParser
ldesc = ["--#{prefix}-#{name}"]
desc = [help_string]
q = name.downcase
- ac_block = proc {|val| block.call(ARG_CONV.call(val))}
- enable = Switch::PlacedArgument.new(nil, ARG_CONV, sdesc, ldesc, nil, desc, ac_block)
- disable = Switch::NoArgument.new(nil, proc {false}, sdesc, ldesc, nil, desc, ac_block)
+ enable = Switch::NoArgument.new(nil, proc {true}, sdesc, ldesc, nil, desc, block)
+ disable = Switch::NoArgument.new(nil, proc {false}, sdesc, ldesc, nil, desc, block)
top.append(enable, [], ["enable-" + q], disable, ['disable-' + q])
enable
end
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index c40c897ff6..28890304e4 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -72,9 +72,6 @@
# the objects that are created, as there is much more overhead in the setting
# of these properties compared to using a Hash or a Struct.
#
-
-require_relative 'ostruct/version'
-
class OpenStruct
#
@@ -108,28 +105,15 @@ class OpenStruct
end
#
- # call-seq:
- # ostruct.to_h -> hash
- # ostruct.to_h {|name, value| block } -> hash
- #
# Converts the OpenStruct to a hash with keys representing
# each attribute (as symbols) and their corresponding values.
#
- # If a block is given, the results of the block on each pair of
- # the receiver will be used as pairs.
- #
# require "ostruct"
# data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
# data.to_h # => {:country => "Australia", :capital => "Canberra" }
- # data.to_h {|name, value| [name.to_s, value.upcase] }
- # # => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
#
- def to_h(&block)
- if block_given?
- @table.to_h(&block)
- else
- @table.dup
- end
+ def to_h
+ @table.dup
end
#
@@ -172,13 +156,16 @@ class OpenStruct
begin
@modifiable = true
rescue
- exception_class = defined?(FrozenError) ? FrozenError : RuntimeError
- raise exception_class, "can't modify frozen #{self.class}", caller(3)
+ raise RuntimeError, "can't modify frozen #{self.class}", caller(3)
end
@table
end
private :modifiable?
+ # ::Kernel.warn("do not use OpenStruct#modifiable", uplevel: 1)
+ alias modifiable modifiable? # :nodoc:
+ protected :modifiable
+
#
# Used internally to defined properties on the
# OpenStruct. It does this by using the metaprogramming function
@@ -194,6 +181,10 @@ class OpenStruct
end
private :new_ostruct_member!
+ # ::Kernel.warn("do not use OpenStruct#new_ostruct_member", uplevel: 1)
+ alias new_ostruct_member new_ostruct_member! # :nodoc:
+ protected :new_ostruct_member
+
def freeze
@table.each_key {|key| new_ostruct_member!(key)}
super
@@ -201,14 +192,14 @@ class OpenStruct
def respond_to_missing?(mid, include_private = false) # :nodoc:
mname = mid.to_s.chomp("=").to_sym
- defined?(@table) && @table.key?(mname) || super
+ @table&.key?(mname) || super
end
def method_missing(mid, *args) # :nodoc:
len = args.length
if mname = mid[/.*(?==\z)/m]
if len != 1
- raise ArgumentError, "wrong number of arguments (given #{len}, expected 1)", caller(1)
+ raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
end
modifiable?[new_ostruct_member!(mname)] = args[0]
elsif len == 0 # and /\A[a-z_]\w*\z/ =~ mid #
@@ -216,8 +207,6 @@ class OpenStruct
new_ostruct_member!(mid) unless frozen?
@table[mid]
end
- elsif @table.key?(mid)
- raise ArgumentError, "wrong number of arguments (given #{len}, expected 0)"
else
begin
super
@@ -305,7 +294,7 @@ class OpenStruct
def delete_field(name)
sym = name.to_sym
begin
- singleton_class.remove_method(sym, "#{sym}=")
+ singleton_class.__send__(:remove_method, sym, "#{sym}=")
rescue NameError
end
@table.delete(sym) do
diff --git a/lib/ostruct/ostruct.gemspec b/lib/ostruct/ostruct.gemspec
deleted file mode 100644
index 4f8507045e..0000000000
--- a/lib/ostruct/ostruct.gemspec
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require_relative "lib/ostruct/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "ostruct"
- spec.version = OpenStruct::VERSION
- spec.authors = ["Marc-Andre Lafortune"]
- spec.email = ["ruby-core@marc-andre.ca"]
-
- spec.summary = %q{Class to build custom data structures, similar to a Hash.}
- spec.description = %q{Class to build custom data structures, similar to a Hash.}
- spec.homepage = "https://github.com/ruby/ostruct"
- spec.license = "BSD-2-Clause"
-
- spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/ostruct.rb", "lib/ostruct/version.rb", "ostruct.gemspec"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
-end
diff --git a/lib/ostruct/version.rb b/lib/ostruct/version.rb
deleted file mode 100644
index 91a4044094..0000000000
--- a/lib/ostruct/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class OpenStruct
- VERSION = "0.2.0"
-end
diff --git a/lib/pp.rb b/lib/pp.rb
index 012b328aad..85401c8aa6 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -89,7 +89,7 @@ class PP < PrettyPrint
# :stopdoc:
def PP.mcall(obj, mod, meth, *args, &block)
- mod.instance_method(meth).bind_call(obj, *args, &block)
+ mod.instance_method(meth).bind(obj).call(*args, &block)
end
# :startdoc:
@@ -106,17 +106,17 @@ class PP < PrettyPrint
# and preserves the previous set of objects being printed.
def guard_inspect_key
if Thread.current[:__recursive_key__] == nil
- Thread.current[:__recursive_key__] = {}.compare_by_identity
+ Thread.current[:__recursive_key__] = {}.taint
end
if Thread.current[:__recursive_key__][:inspect] == nil
- Thread.current[:__recursive_key__][:inspect] = {}.compare_by_identity
+ Thread.current[:__recursive_key__][:inspect] = {}.taint
end
save = Thread.current[:__recursive_key__][:inspect]
begin
- Thread.current[:__recursive_key__][:inspect] = {}.compare_by_identity
+ Thread.current[:__recursive_key__][:inspect] = {}.taint
yield
ensure
Thread.current[:__recursive_key__][:inspect] = save
@@ -149,20 +149,18 @@ class PP < PrettyPrint
# Object#pretty_print_cycle is used when +obj+ is already
# printed, a.k.a the object reference chain has a cycle.
def pp(obj)
- # If obj is a Delegator then use the object being delegated to for cycle
- # detection
- obj = obj.__getobj__ if defined?(::Delegator) and obj.is_a?(::Delegator)
+ id = obj.object_id
- if check_inspect_key(obj)
+ if check_inspect_key(id)
group {obj.pretty_print_cycle self}
return
end
begin
- push_inspect_key(obj)
+ push_inspect_key(id)
group {obj.pretty_print self}
ensure
- pop_inspect_key(obj) unless PP.sharing_detection
+ pop_inspect_key(id) unless PP.sharing_detection
end
end
@@ -176,7 +174,7 @@ class PP < PrettyPrint
# A convenience method, like object_group, but also reformats the Object's
# object_id.
def object_address_group(obj, &block)
- str = Kernel.instance_method(:to_s).bind_call(obj)
+ str = Kernel.instance_method(:to_s).bind(obj).call
str.chomp!('>')
group(1, str, '>', &block)
end
@@ -223,16 +221,7 @@ class PP < PrettyPrint
else
sep.call
end
- case v.last
- when Hash
- if Hash.ruby2_keywords_hash?(v.last)
- yield(*v, **{})
- else
- yield(*v)
- end
- else
- yield(*v)
- end
+ yield(*v)
}
end
@@ -290,9 +279,9 @@ class PP < PrettyPrint
# This module provides predefined #pretty_print methods for some of
# the most commonly used built-in classes for convenience.
def pretty_print(q)
- umethod_method = Object.instance_method(:method)
+ method_method = Object.instance_method(:method).bind(self)
begin
- inspect_method = umethod_method.bind_call(self, :inspect)
+ inspect_method = method_method.call(:inspect)
rescue NameError
end
if inspect_method && inspect_method.owner != Kernel
@@ -329,7 +318,7 @@ class PP < PrettyPrint
# However, doing this requires that every class that #inspect is called on
# implement #pretty_print, or a RuntimeError will be raised.
def pretty_print_inspect
- if Object.instance_method(:method).bind_call(self, :pretty_print).owner == PP::ObjectMixin
+ if Object.instance_method(:method).bind(self).call(:pretty_print).owner == PP::ObjectMixin
raise "pretty_print is not overridden for #{self.class}"
end
PP.singleline_pp(self, ''.dup)
@@ -397,7 +386,7 @@ class Range # :nodoc:
q.breakable ''
q.text(self.exclude_end? ? '...' : '..')
q.breakable ''
- q.pp self.end if self.end
+ q.pp self.end
end
end
@@ -525,40 +514,6 @@ class MatchData # :nodoc:
end
end
-class RubyVM::AbstractSyntaxTree::Node
- def pretty_print_children(q, names = [])
- children.zip(names) do |c, n|
- if n
- q.breakable
- q.text "#{n}:"
- end
- q.group(2) do
- q.breakable
- q.pp c
- end
- end
- end
-
- def pretty_print(q)
- q.group(1, "(#{type}@#{first_lineno}:#{first_column}-#{last_lineno}:#{last_column}", ")") {
- case type
- when :SCOPE
- pretty_print_children(q, %w"tbl args body")
- when :ARGS
- pretty_print_children(q, %w[pre_num pre_init opt first_post post_num post_init rest kw kwrest block])
- when :DEFN
- pretty_print_children(q, %w[mid body])
- when :ARYPTN
- pretty_print_children(q, %w[const pre rest post])
- when :HSHPTN
- pretty_print_children(q, %w[const kw kwrest])
- else
- pretty_print_children(q)
- end
- }
- end
-end
-
class Object < BasicObject # :nodoc:
include PP::ObjectMixin
end
diff --git a/lib/prime.gemspec b/lib/prime.gemspec
deleted file mode 100644
index 6a9aa683e6..0000000000
--- a/lib/prime.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/prime"
-rescue LoadError
- # for Ruby core repository
- require_relative "prime"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "prime"
- spec.version = Prime::VERSION
- spec.authors = ["Yuki Sonoda"]
- spec.email = ["yugui@yugui.jp"]
-
- spec.summary = %q{Prime numbers and factorization library.}
- spec.description = %q{Prime numbers and factorization library.}
- spec.homepage = "https://github.com/ruby/prime"
- spec.license = "BSD-2-Clause"
-
- spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/prime.rb", "lib/prime/version.rb", "prime.gemspec"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "test-unit"
-end
diff --git a/lib/prime.rb b/lib/prime.rb
index 5be12f24f5..2cd22da3a8 100644
--- a/lib/prime.rb
+++ b/lib/prime.rb
@@ -95,9 +95,6 @@ end
# has many prime factors. e.g. for Prime#prime? .
class Prime
-
- VERSION = "0.1.1"
-
include Enumerable
include Singleton
@@ -283,9 +280,9 @@ class Prime
end
# see +Enumerator+#with_index.
- def with_index(offset = 0, &block)
- return enum_for(:with_index, offset) { Float::INFINITY } unless block
- return each_with_index(&block) if offset == 0
+ def with_index(offset = 0)
+ return enum_for(:with_index, offset) { Float::INFINITY } unless block_given?
+ return each_with_index(&proc) if offset == 0
each do |prime|
yield prime, offset
@@ -391,6 +388,13 @@ class Prime
@ulticheck_next_squared = 121 # @primes[@ulticheck_index + 1] ** 2
end
+ # Returns the cached prime numbers.
+ def cache
+ @primes
+ end
+ alias primes cache
+ alias primes_so_far cache
+
# Returns the +index+th prime number.
#
# +index+ is a 0-based index.
diff --git a/lib/profile.rb b/lib/profile.rb
new file mode 100644
index 0000000000..e58c92125b
--- /dev/null
+++ b/lib/profile.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+require 'profiler'
+
+RubyVM::InstructionSequence.compile_option = {
+ :trace_instruction => true,
+ :specialized_instruction => false
+}
+END {
+ Profiler__::print_profile(STDERR)
+}
+Profiler__::start_profile
diff --git a/lib/profiler.rb b/lib/profiler.rb
new file mode 100644
index 0000000000..b3c9f7f46a
--- /dev/null
+++ b/lib/profiler.rb
@@ -0,0 +1,149 @@
+# frozen_string_literal: true
+# Profile provides a way to Profile your Ruby application.
+#
+# Profiling your program is a way of determining which methods are called and
+# how long each method takes to complete. This way you can detect which
+# methods are possible bottlenecks.
+#
+# Profiling your program will slow down your execution time considerably,
+# so activate it only when you need it. Don't confuse benchmarking with
+# profiling.
+#
+# There are two ways to activate Profiling:
+#
+# == Command line
+#
+# Run your Ruby script with <code>-rprofile</code>:
+#
+# ruby -rprofile example.rb
+#
+# If you're profiling an executable in your <code>$PATH</code> you can use
+# <code>ruby -S</code>:
+#
+# ruby -rprofile -S some_executable
+#
+# == From code
+#
+# Just require 'profile':
+#
+# require 'profile'
+#
+# def slow_method
+# 5000.times do
+# 9999999999999999*999999999
+# end
+# end
+#
+# def fast_method
+# 5000.times do
+# 9999999999999999+999999999
+# end
+# end
+#
+# slow_method
+# fast_method
+#
+# The output in both cases is a report when the execution is over:
+#
+# ruby -rprofile example.rb
+#
+# % cumulative self self total
+# time seconds seconds calls ms/call ms/call name
+# 68.42 0.13 0.13 2 65.00 95.00 Integer#times
+# 15.79 0.16 0.03 5000 0.01 0.01 Fixnum#*
+# 15.79 0.19 0.03 5000 0.01 0.01 Fixnum#+
+# 0.00 0.19 0.00 2 0.00 0.00 IO#set_encoding
+# 0.00 0.19 0.00 1 0.00 100.00 Object#slow_method
+# 0.00 0.19 0.00 2 0.00 0.00 Module#method_added
+# 0.00 0.19 0.00 1 0.00 90.00 Object#fast_method
+# 0.00 0.19 0.00 1 0.00 190.00 #toplevel
+
+module Profiler__
+ class Wrapper < Struct.new(:defined_class, :method_id, :hash) # :nodoc:
+ private :defined_class=, :method_id=, :hash=
+
+ def initialize(klass, mid)
+ super(klass, mid, nil)
+ self.hash = Struct.instance_method(:hash).bind(self).call
+ end
+
+ def to_s
+ "#{defined_class.inspect}#".sub(/\A\#<Class:(.*)>#\z/, '\1.') << method_id.to_s
+ end
+ alias inspect to_s
+ end
+
+ # internal values
+ @@start = nil # the start time that profiling began
+ @@stacks = nil # the map of stacks keyed by thread
+ @@maps = nil # the map of call data keyed by thread, class and id. Call data contains the call count, total time,
+ PROFILE_CALL_PROC = TracePoint.new(*%i[call c_call b_call]) {|tp| # :nodoc:
+ now = Process.times[0]
+ stack = (@@stacks[Thread.current] ||= [])
+ stack.push [now, 0.0]
+ }
+ PROFILE_RETURN_PROC = TracePoint.new(*%i[return c_return b_return]) {|tp| # :nodoc:
+ now = Process.times[0]
+ key = Wrapper.new(tp.defined_class, tp.method_id)
+ stack = (@@stacks[Thread.current] ||= [])
+ if tick = stack.pop
+ threadmap = (@@maps[Thread.current] ||= {})
+ data = (threadmap[key] ||= [0, 0.0, 0.0, key])
+ data[0] += 1
+ cost = now - tick[0]
+ data[1] += cost
+ data[2] += cost - tick[1]
+ stack[-1][1] += cost if stack[-1]
+ end
+ }
+module_function
+ # Starts the profiler.
+ #
+ # See Profiler__ for more information.
+ def start_profile
+ @@start = Process.times[0]
+ @@stacks = {}
+ @@maps = {}
+ PROFILE_CALL_PROC.enable
+ PROFILE_RETURN_PROC.enable
+ end
+ # Stops the profiler.
+ #
+ # See Profiler__ for more information.
+ def stop_profile
+ PROFILE_CALL_PROC.disable
+ PROFILE_RETURN_PROC.disable
+ end
+ # Outputs the results from the profiler.
+ #
+ # See Profiler__ for more information.
+ def print_profile(f)
+ stop_profile
+ total = Process.times[0] - @@start
+ if total == 0 then total = 0.01 end
+ totals = {}
+ @@maps.values.each do |threadmap|
+ threadmap.each do |key, data|
+ total_data = (totals[key] ||= [0, 0.0, 0.0, key])
+ total_data[0] += data[0]
+ total_data[1] += data[1]
+ total_data[2] += data[2]
+ end
+ end
+
+ # Maybe we should show a per thread output and a totals view?
+
+ data = totals.values
+ data = data.sort_by{|x| -x[2]}
+ sum = 0
+ f.printf " %% cumulative self self total\n"
+ f.printf " time seconds seconds calls ms/call ms/call name\n"
+ for d in data
+ sum += d[2]
+ f.printf "%6.2f %8.2f %8.2f %8d ", d[2]/total*100, sum, d[2], d[0]
+ f.printf "%8.2f %8.2f %s\n", d[2]*1000/d[0], d[1]*1000/d[0], d[3]
+ end
+ f.printf "%6.2f %8.2f %8.2f %8d ", 0.0, total, 0.0, 1 # ???
+ f.printf "%8.2f %8.2f %s\n", 0.0, total*1000, "#toplevel" # ???
+ end
+end
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 1180fd50a0..4daa2e003f 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -374,7 +374,7 @@ class PStore
def open_and_lock_file(filename, read_only)
if read_only
begin
- file = File.new(filename, **RD_ACCESS)
+ file = File.new(filename, RD_ACCESS)
begin
file.flock(File::LOCK_SH)
return file
@@ -386,7 +386,7 @@ class PStore
return nil
end
else
- file = File.new(filename, **RDWR_ACCESS)
+ file = File.new(filename, RDWR_ACCESS)
file.flock(File::LOCK_EX)
return file
end
@@ -449,7 +449,7 @@ class PStore
def save_data_with_atomic_file_rename_strategy(data, file)
temp_filename = "#{@filename}.tmp.#{Process.pid}.#{rand 1000000}"
- temp_file = File.new(temp_filename, **WR_ACCESS)
+ temp_file = File.new(temp_filename, WR_ACCESS)
begin
temp_file.flock(File::LOCK_EX)
temp_file.write(data)
diff --git a/lib/pstore/pstore.gemspec b/lib/pstore/pstore.gemspec
deleted file mode 100644
index e781c77043..0000000000
--- a/lib/pstore/pstore.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/pstore/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "pstore"
- spec.version = PStore::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Transactional File Storage for Ruby Objects}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/pstore"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = "https://github.com/ruby/pstore"
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/pstore/version.rb b/lib/pstore/version.rb
deleted file mode 100644
index 0e7a3fbd15..0000000000
--- a/lib/pstore/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class PStore
- VERSION = "0.1.0"
-end
diff --git a/lib/racc.rb b/lib/racc.rb
deleted file mode 100644
index f6e4ac03a8..0000000000
--- a/lib/racc.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require 'racc/compat'
-require 'racc/debugflags'
-require 'racc/grammar'
-require 'racc/state'
-require 'racc/exception'
-require 'racc/info'
diff --git a/lib/racc/compat.rb b/lib/racc/compat.rb
deleted file mode 100644
index ccb033e2e0..0000000000
--- a/lib/racc/compat.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# $Id: 14fa1118eb3a23e85265e4f7afe2d5a297d69f9c $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of the GNU LGPL, see the file "COPYING".
-#
-
-unless Object.method_defined?(:__send)
- class Object
- alias __send __send__
- end
-end
-
-unless Object.method_defined?(:__send!)
- class Object
- alias __send! __send__
- end
-end
-
-unless Array.method_defined?(:map!)
- class Array
- if Array.method_defined?(:collect!)
- alias map! collect!
- else
- alias map! filter
- end
- end
-end
diff --git a/lib/racc/debugflags.rb b/lib/racc/debugflags.rb
deleted file mode 100644
index 1b5d2fe54c..0000000000
--- a/lib/racc/debugflags.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# $Id: 74ff4369ce53c7f45cfc2644ce907785104ebf6e $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of LGPL, see the file "COPYING".
-#
-
-module Racc
-
- class DebugFlags
- def DebugFlags.parse_option_string(s)
- parse = rule = token = state = la = prec = conf = false
- s.split(//).each do |ch|
- case ch
- when 'p' then parse = true
- when 'r' then rule = true
- when 't' then token = true
- when 's' then state = true
- when 'l' then la = true
- when 'c' then prec = true
- when 'o' then conf = true
- else
- raise "unknown debug flag char: #{ch.inspect}"
- end
- end
- new(parse, rule, token, state, la, prec, conf)
- end
-
- def initialize(parse = false, rule = false, token = false, state = false,
- la = false, prec = false, conf = false)
- @parse = parse
- @rule = rule
- @token = token
- @state = state
- @la = la
- @prec = prec
- @any = (parse || rule || token || state || la || prec)
- @status_logging = conf
- end
-
- attr_reader :parse
- attr_reader :rule
- attr_reader :token
- attr_reader :state
- attr_reader :la
- attr_reader :prec
-
- def any?
- @any
- end
-
- attr_reader :status_logging
- end
-
-end
diff --git a/lib/racc/exception.rb b/lib/racc/exception.rb
deleted file mode 100644
index 0069ca3443..0000000000
--- a/lib/racc/exception.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# $Id: ebb9798ad0b211e031670a12a1ab154678c1c8f3 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-
-module Racc
- class Error < StandardError; end
- class CompileError < Error; end
-end
diff --git a/lib/racc/grammar.rb b/lib/racc/grammar.rb
deleted file mode 100644
index 123f1f1834..0000000000
--- a/lib/racc/grammar.rb
+++ /dev/null
@@ -1,1113 +0,0 @@
-#
-# $Id: 3fcabd58bef02540bf78e8142469681cb9f975c2 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-
-require 'racc/compat'
-require 'racc/iset'
-require 'racc/sourcetext'
-require 'racc/logfilegenerator'
-require 'racc/exception'
-require 'forwardable'
-
-module Racc
-
- class Grammar
-
- def initialize(debug_flags = DebugFlags.new)
- @symboltable = SymbolTable.new
- @debug_symbol = debug_flags.token
- @rules = [] # :: [Rule]
- @start = nil
- @n_expected_srconflicts = nil
- @prec_table = []
- @prec_table_closed = false
- @closed = false
- @states = nil
- end
-
- attr_reader :start
- attr_reader :symboltable
- attr_accessor :n_expected_srconflicts
-
- def [](x)
- @rules[x]
- end
-
- def each_rule(&block)
- @rules.each(&block)
- end
-
- alias each each_rule
-
- def each_index(&block)
- @rules.each_index(&block)
- end
-
- def each_with_index(&block)
- @rules.each_with_index(&block)
- end
-
- def size
- @rules.size
- end
-
- def to_s
- "<Racc::Grammar>"
- end
-
- extend Forwardable
-
- def_delegator "@symboltable", :each, :each_symbol
- def_delegator "@symboltable", :each_terminal
- def_delegator "@symboltable", :each_nonterminal
-
- def intern(value, dummy = false)
- @symboltable.intern(value, dummy)
- end
-
- def symbols
- @symboltable.symbols
- end
-
- def nonterminal_base
- @symboltable.nt_base
- end
-
- def useless_nonterminal_exist?
- n_useless_nonterminals() != 0
- end
-
- def n_useless_nonterminals
- @n_useless_nonterminals ||=
- begin
- n = 0
- @symboltable.each_nonterminal do |sym|
- n += 1 if sym.useless?
- end
- n
- end
- end
-
- def useless_rule_exist?
- n_useless_rules() != 0
- end
-
- def n_useless_rules
- @n_useless_rules ||=
- begin
- n = 0
- each do |r|
- n += 1 if r.useless?
- end
- n
- end
- end
-
- def nfa
- (@states ||= States.new(self)).nfa
- end
-
- def dfa
- (@states ||= States.new(self)).dfa
- end
-
- alias states dfa
-
- def state_transition_table
- states().state_transition_table
- end
-
- def parser_class
- states = states() # cache
- if $DEBUG
- srcfilename = caller(1).first.slice(/\A(.*?):/, 1)
- begin
- write_log srcfilename + ".output"
- rescue SystemCallError
- end
- report = lambda {|s| $stderr.puts "racc: #{srcfilename}: #{s}" }
- if states.should_report_srconflict?
- report["#{states.n_srconflicts} shift/reduce conflicts"]
- end
- if states.rrconflict_exist?
- report["#{states.n_rrconflicts} reduce/reduce conflicts"]
- end
- g = states.grammar
- if g.useless_nonterminal_exist?
- report["#{g.n_useless_nonterminals} useless nonterminals"]
- end
- if g.useless_rule_exist?
- report["#{g.n_useless_rules} useless rules"]
- end
- end
- states.state_transition_table.parser_class
- end
-
- def write_log(path)
- File.open(path, 'w') {|f|
- LogFileGenerator.new(states()).output f
- }
- end
-
- #
- # Grammar Definition Interface
- #
-
- def add(rule)
- raise ArgumentError, "rule added after the Grammar closed" if @closed
- @rules.push rule
- end
-
- def added?(sym)
- @rules.detect {|r| r.target == sym }
- end
-
- def start_symbol=(s)
- raise CompileError, "start symbol set twice'" if @start
- @start = s
- end
-
- def declare_precedence(assoc, syms)
- raise CompileError, "precedence table defined twice" if @prec_table_closed
- @prec_table.push [assoc, syms]
- end
-
- def end_precedence_declaration(reverse)
- @prec_table_closed = true
- return if @prec_table.empty?
- table = reverse ? @prec_table.reverse : @prec_table
- table.each_with_index do |(assoc, syms), idx|
- syms.each do |sym|
- sym.assoc = assoc
- sym.precedence = idx
- end
- end
- end
-
- #
- # Dynamic Generation Interface
- #
-
- def Grammar.define(&block)
- env = DefinitionEnv.new
- env.instance_eval(&block)
- env.grammar
- end
-
- class DefinitionEnv
- def initialize
- @grammar = Grammar.new
- @seqs = Hash.new(0)
- @delayed = []
- end
-
- def grammar
- flush_delayed
- @grammar.each do |rule|
- if rule.specified_prec
- rule.specified_prec = @grammar.intern(rule.specified_prec)
- end
- end
- @grammar.init
- @grammar
- end
-
- def precedence_table(&block)
- env = PrecedenceDefinitionEnv.new(@grammar)
- env.instance_eval(&block)
- @grammar.end_precedence_declaration env.reverse
- end
-
- def method_missing(mid, *args, &block)
- unless mid.to_s[-1,1] == '='
- super # raises NoMethodError
- end
- target = @grammar.intern(mid.to_s.chop.intern)
- unless args.size == 1
- raise ArgumentError, "too many arguments for #{mid} (#{args.size} for 1)"
- end
- _add target, args.first
- end
-
- def _add(target, x)
- case x
- when Sym
- @delayed.each do |rule|
- rule.replace x, target if rule.target == x
- end
- @grammar.symboltable.delete x
- else
- x.each_rule do |r|
- r.target = target
- @grammar.add r
- end
- end
- flush_delayed
- end
-
- def _delayed_add(rule)
- @delayed.push rule
- end
-
- def _added?(sym)
- @grammar.added?(sym) or @delayed.detect {|r| r.target == sym }
- end
-
- def flush_delayed
- return if @delayed.empty?
- @delayed.each do |rule|
- @grammar.add rule
- end
- @delayed.clear
- end
-
- def seq(*list, &block)
- Rule.new(nil, list.map {|x| _intern(x) }, UserAction.proc(block))
- end
-
- def null(&block)
- seq(&block)
- end
-
- def action(&block)
- id = "@#{@seqs["action"] += 1}".intern
- _delayed_add Rule.new(@grammar.intern(id), [], UserAction.proc(block))
- id
- end
-
- alias _ action
-
- def option(sym, default = nil, &block)
- _defmetasyntax("option", _intern(sym), block) {|target|
- seq() { default } | seq(sym)
- }
- end
-
- def many(sym, &block)
- _defmetasyntax("many", _intern(sym), block) {|target|
- seq() { [] }\
- | seq(target, sym) {|list, x| list.push x; list }
- }
- end
-
- def many1(sym, &block)
- _defmetasyntax("many1", _intern(sym), block) {|target|
- seq(sym) {|x| [x] }\
- | seq(target, sym) {|list, x| list.push x; list }
- }
- end
-
- def separated_by(sep, sym, &block)
- option(separated_by1(sep, sym), [], &block)
- end
-
- def separated_by1(sep, sym, &block)
- _defmetasyntax("separated_by1", _intern(sym), block) {|target|
- seq(sym) {|x| [x] }\
- | seq(target, sep, sym) {|list, _, x| list.push x; list }
- }
- end
-
- def _intern(x)
- case x
- when Symbol, String
- @grammar.intern(x)
- when Racc::Sym
- x
- else
- raise TypeError, "wrong type #{x.class} (expected Symbol/String/Racc::Sym)"
- end
- end
-
- private
-
- def _defmetasyntax(type, id, action, &block)
- if action
- idbase = "#{type}@#{id}-#{@seqs[type] += 1}"
- target = _wrap(idbase, "#{idbase}-core", action)
- _regist("#{idbase}-core", &block)
- else
- target = _regist("#{type}@#{id}", &block)
- end
- @grammar.intern(target)
- end
-
- def _regist(target_name)
- target = target_name.intern
- unless _added?(@grammar.intern(target))
- yield(target).each_rule do |rule|
- rule.target = @grammar.intern(target)
- _delayed_add rule
- end
- end
- target
- end
-
- def _wrap(target_name, sym, block)
- target = target_name.intern
- _delayed_add Rule.new(@grammar.intern(target),
- [@grammar.intern(sym.intern)],
- UserAction.proc(block))
- target
- end
- end
-
- class PrecedenceDefinitionEnv
- def initialize(g)
- @grammar = g
- @prechigh_seen = false
- @preclow_seen = false
- @reverse = false
- end
-
- attr_reader :reverse
-
- def higher
- if @prechigh_seen
- raise CompileError, "prechigh used twice"
- end
- @prechigh_seen = true
- end
-
- def lower
- if @preclow_seen
- raise CompileError, "preclow used twice"
- end
- if @prechigh_seen
- @reverse = true
- end
- @preclow_seen = true
- end
-
- def left(*syms)
- @grammar.declare_precedence :Left, syms.map {|s| @grammar.intern(s) }
- end
-
- def right(*syms)
- @grammar.declare_precedence :Right, syms.map {|s| @grammar.intern(s) }
- end
-
- def nonassoc(*syms)
- @grammar.declare_precedence :Nonassoc, syms.map {|s| @grammar.intern(s)}
- end
- end
-
- #
- # Computation
- #
-
- def init
- return if @closed
- @closed = true
- @start ||= @rules.map {|r| r.target }.detect {|sym| not sym.dummy? }
- raise CompileError, 'no rule in input' if @rules.empty?
- add_start_rule
- @rules.freeze
- fix_ident
- compute_hash
- compute_heads
- determine_terminals
- compute_nullable_0
- @symboltable.fix
- compute_locate
- @symboltable.each_nonterminal {|t| compute_expand t }
- compute_nullable
- compute_useless
- end
-
- private
-
- def add_start_rule
- r = Rule.new(@symboltable.dummy,
- [@start, @symboltable.anchor, @symboltable.anchor],
- UserAction.empty)
- r.ident = 0
- r.hash = 0
- r.precedence = nil
- @rules.unshift r
- end
-
- # Rule#ident
- # LocationPointer#ident
- def fix_ident
- @rules.each_with_index do |rule, idx|
- rule.ident = idx
- end
- end
-
- # Rule#hash
- def compute_hash
- hash = 4 # size of dummy rule
- @rules.each do |rule|
- rule.hash = hash
- hash += (rule.size + 1)
- end
- end
-
- # Sym#heads
- def compute_heads
- @rules.each do |rule|
- rule.target.heads.push rule.ptrs[0]
- end
- end
-
- # Sym#terminal?
- def determine_terminals
- @symboltable.each do |s|
- s.term = s.heads.empty?
- end
- end
-
- # Sym#self_null?
- def compute_nullable_0
- @symboltable.each do |s|
- if s.terminal?
- s.snull = false
- else
- s.snull = s.heads.any? {|loc| loc.reduce? }
- end
- end
- end
-
- # Sym#locate
- def compute_locate
- @rules.each do |rule|
- t = nil
- rule.ptrs.each do |ptr|
- unless ptr.reduce?
- tok = ptr.dereference
- tok.locate.push ptr
- t = tok if tok.terminal?
- end
- end
- rule.precedence = t
- end
- end
-
- # Sym#expand
- def compute_expand(t)
- puts "expand> #{t.to_s}" if @debug_symbol
- t.expand = _compute_expand(t, ISet.new, [])
- puts "expand< #{t.to_s}: #{t.expand.to_s}" if @debug_symbol
- end
-
- def _compute_expand(t, set, lock)
- if tmp = t.expand
- set.update tmp
- return set
- end
- tok = nil
- set.update_a t.heads
- t.heads.each do |ptr|
- tok = ptr.dereference
- if tok and tok.nonterminal?
- unless lock[tok.ident]
- lock[tok.ident] = true
- _compute_expand tok, set, lock
- end
- end
- end
- set
- end
-
- # Sym#nullable?, Rule#nullable?
- def compute_nullable
- @rules.each {|r| r.null = false }
- @symboltable.each {|t| t.null = false }
- r = @rules.dup
- s = @symboltable.nonterminals
- begin
- rs = r.size
- ss = s.size
- check_rules_nullable r
- check_symbols_nullable s
- end until rs == r.size and ss == s.size
- end
-
- def check_rules_nullable(rules)
- rules.delete_if do |rule|
- rule.null = true
- rule.symbols.each do |t|
- unless t.nullable?
- rule.null = false
- break
- end
- end
- rule.nullable?
- end
- end
-
- def check_symbols_nullable(symbols)
- symbols.delete_if do |sym|
- sym.heads.each do |ptr|
- if ptr.rule.nullable?
- sym.null = true
- break
- end
- end
- sym.nullable?
- end
- end
-
- # Sym#useless?, Rule#useless?
- # FIXME: what means "useless"?
- def compute_useless
- @symboltable.each_terminal {|sym| sym.useless = false }
- @symboltable.each_nonterminal {|sym| sym.useless = true }
- @rules.each {|rule| rule.useless = true }
- r = @rules.dup
- s = @symboltable.nonterminals
- begin
- rs = r.size
- ss = s.size
- check_rules_useless r
- check_symbols_useless s
- end until r.size == rs and s.size == ss
- end
-
- def check_rules_useless(rules)
- rules.delete_if do |rule|
- rule.useless = false
- rule.symbols.each do |sym|
- if sym.useless?
- rule.useless = true
- break
- end
- end
- not rule.useless?
- end
- end
-
- def check_symbols_useless(s)
- s.delete_if do |t|
- t.heads.each do |ptr|
- unless ptr.rule.useless?
- t.useless = false
- break
- end
- end
- not t.useless?
- end
- end
-
- end # class Grammar
-
-
- class Rule
-
- def initialize(target, syms, act)
- @target = target
- @symbols = syms
- @action = act
- @alternatives = []
-
- @ident = nil
- @hash = nil
- @ptrs = nil
- @precedence = nil
- @specified_prec = nil
- @null = nil
- @useless = nil
- end
-
- attr_accessor :target
- attr_reader :symbols
- attr_reader :action
-
- def |(x)
- @alternatives.push x.rule
- self
- end
-
- def rule
- self
- end
-
- def each_rule(&block)
- yield self
- @alternatives.each(&block)
- end
-
- attr_accessor :ident
-
- attr_reader :hash
- attr_reader :ptrs
-
- def hash=(n)
- @hash = n
- ptrs = []
- @symbols.each_with_index do |sym, idx|
- ptrs.push LocationPointer.new(self, idx, sym)
- end
- ptrs.push LocationPointer.new(self, @symbols.size, nil)
- @ptrs = ptrs
- end
-
- def precedence
- @specified_prec || @precedence
- end
-
- def precedence=(sym)
- @precedence ||= sym
- end
-
- def prec(sym, &block)
- @specified_prec = sym
- if block
- unless @action.empty?
- raise CompileError, 'both of rule action block and prec block given'
- end
- @action = UserAction.proc(block)
- end
- self
- end
-
- attr_accessor :specified_prec
-
- def nullable?() @null end
- def null=(n) @null = n end
-
- def useless?() @useless end
- def useless=(u) @useless = u end
-
- def inspect
- "#<Racc::Rule id=#{@ident} (#{@target})>"
- end
-
- def ==(other)
- other.kind_of?(Rule) and @ident == other.ident
- end
-
- def [](idx)
- @symbols[idx]
- end
-
- def size
- @symbols.size
- end
-
- def empty?
- @symbols.empty?
- end
-
- def to_s
- "#<rule#{@ident}>"
- end
-
- def accept?
- if tok = @symbols[-1]
- tok.anchor?
- else
- false
- end
- end
-
- def each(&block)
- @symbols.each(&block)
- end
-
- def replace(src, dest)
- @target = dest
- @symbols = @symbols.map {|s| s == src ? dest : s }
- end
-
- end # class Rule
-
-
- class UserAction
-
- def UserAction.source_text(src)
- new(src, nil)
- end
-
- def UserAction.proc(pr = nil, &block)
- if pr and block
- raise ArgumentError, "both of argument and block given"
- end
- new(nil, pr || block)
- end
-
- def UserAction.empty
- new(nil, nil)
- end
-
- private_class_method :new
-
- def initialize(src, proc)
- @source = src
- @proc = proc
- end
-
- attr_reader :source
- attr_reader :proc
-
- def source?
- not @proc
- end
-
- def proc?
- not @source
- end
-
- def empty?
- not @proc and not @source
- end
-
- def name
- "{action type=#{@source || @proc || 'nil'}}"
- end
-
- alias inspect name
-
- end
-
-
- class OrMark
- def initialize(lineno)
- @lineno = lineno
- end
-
- def name
- '|'
- end
-
- alias inspect name
-
- attr_reader :lineno
- end
-
-
- class Prec
- def initialize(symbol, lineno)
- @symbol = symbol
- @lineno = lineno
- end
-
- def name
- "=#{@symbol}"
- end
-
- alias inspect name
-
- attr_reader :symbol
- attr_reader :lineno
- end
-
-
- #
- # A set of rule and position in it's RHS.
- # Note that the number of pointers is more than rule's RHS array,
- # because pointer points right edge of the final symbol when reducing.
- #
- class LocationPointer
-
- def initialize(rule, i, sym)
- @rule = rule
- @index = i
- @symbol = sym
- @ident = @rule.hash + i
- @reduce = sym.nil?
- end
-
- attr_reader :rule
- attr_reader :index
- attr_reader :symbol
-
- alias dereference symbol
-
- attr_reader :ident
- alias hash ident
- attr_reader :reduce
- alias reduce? reduce
-
- def to_s
- sprintf('(%d,%d %s)',
- @rule.ident, @index, (reduce?() ? '#' : @symbol.to_s))
- end
-
- alias inspect to_s
-
- def eql?(ot)
- @hash == ot.hash
- end
-
- alias == eql?
-
- def head?
- @index == 0
- end
-
- def next
- @rule.ptrs[@index + 1] or ptr_bug!
- end
-
- alias increment next
-
- def before(len)
- @rule.ptrs[@index - len] or ptr_bug!
- end
-
- private
-
- def ptr_bug!
- raise "racc: fatal: pointer not exist: self: #{to_s}"
- end
-
- end # class LocationPointer
-
-
- class SymbolTable
-
- include Enumerable
-
- def initialize
- @symbols = [] # :: [Racc::Sym]
- @cache = {} # :: {(String|Symbol) => Racc::Sym}
- @dummy = intern(:$start, true)
- @anchor = intern(false, true) # Symbol ID = 0
- @error = intern(:error, false) # Symbol ID = 1
- end
-
- attr_reader :dummy
- attr_reader :anchor
- attr_reader :error
-
- def [](id)
- @symbols[id]
- end
-
- def intern(val, dummy = false)
- @cache[val] ||=
- begin
- sym = Sym.new(val, dummy)
- @symbols.push sym
- sym
- end
- end
-
- attr_reader :symbols
- alias to_a symbols
-
- def delete(sym)
- @symbols.delete sym
- @cache.delete sym.value
- end
-
- attr_reader :nt_base
-
- def nt_max
- @symbols.size
- end
-
- def each(&block)
- @symbols.each(&block)
- end
-
- def terminals(&block)
- @symbols[0, @nt_base]
- end
-
- def each_terminal(&block)
- @terms.each(&block)
- end
-
- def nonterminals
- @symbols[@nt_base, @symbols.size - @nt_base]
- end
-
- def each_nonterminal(&block)
- @nterms.each(&block)
- end
-
- def fix
- terms, nterms = @symbols.partition {|s| s.terminal? }
- @symbols = terms + nterms
- @terms = terms
- @nterms = nterms
- @nt_base = terms.size
- fix_ident
- check_terminals
- end
-
- private
-
- def fix_ident
- @symbols.each_with_index do |t, i|
- t.ident = i
- end
- end
-
- def check_terminals
- return unless @symbols.any? {|s| s.should_terminal? }
- @anchor.should_terminal
- @error.should_terminal
- each_terminal do |t|
- t.should_terminal if t.string_symbol?
- end
- each do |s|
- s.should_terminal if s.assoc
- end
- terminals().reject {|t| t.should_terminal? }.each do |t|
- raise CompileError, "terminal #{t} not declared as terminal"
- end
- nonterminals().select {|n| n.should_terminal? }.each do |n|
- raise CompileError, "symbol #{n} declared as terminal but is not terminal"
- end
- end
-
- end # class SymbolTable
-
-
- # Stands terminal and nonterminal symbols.
- class Sym
-
- def initialize(value, dummyp)
- @ident = nil
- @value = value
- @dummyp = dummyp
-
- @term = nil
- @nterm = nil
- @should_terminal = false
- @precedence = nil
- case value
- when Symbol
- @to_s = value.to_s
- @serialized = value.inspect
- @string = false
- when String
- @to_s = value.inspect
- @serialized = value.dump
- @string = true
- when false
- @to_s = '$end'
- @serialized = 'false'
- @string = false
- when ErrorSymbolValue
- @to_s = 'error'
- @serialized = 'Object.new'
- @string = false
- else
- raise ArgumentError, "unknown symbol value: #{value.class}"
- end
-
- @heads = []
- @locate = []
- @snull = nil
- @null = nil
- @expand = nil
- @useless = nil
- end
-
- class << self
- def once_writer(nm)
- nm = nm.id2name
- module_eval(<<-EOS)
- def #{nm}=(v)
- raise 'racc: fatal: @#{nm} != nil' unless @#{nm}.nil?
- @#{nm} = v
- end
- EOS
- end
- end
-
- once_writer :ident
- attr_reader :ident
-
- alias hash ident
-
- attr_reader :value
-
- def dummy?
- @dummyp
- end
-
- def terminal?
- @term
- end
-
- def nonterminal?
- @nterm
- end
-
- def term=(t)
- raise 'racc: fatal: term= called twice' unless @term.nil?
- @term = t
- @nterm = !t
- end
-
- def should_terminal
- @should_terminal = true
- end
-
- def should_terminal?
- @should_terminal
- end
-
- def string_symbol?
- @string
- end
-
- def serialize
- @serialized
- end
-
- attr_writer :serialized
-
- attr_accessor :precedence
- attr_accessor :assoc
-
- def to_s
- @to_s.dup
- end
-
- alias inspect to_s
-
- def |(x)
- rule() | x.rule
- end
-
- def rule
- Rule.new(nil, [self], UserAction.empty)
- end
-
- #
- # cache
- #
-
- attr_reader :heads
- attr_reader :locate
-
- def self_null?
- @snull
- end
-
- once_writer :snull
-
- def nullable?
- @null
- end
-
- def null=(n)
- @null = n
- end
-
- attr_reader :expand
- once_writer :expand
-
- def useless?
- @useless
- end
-
- def useless=(f)
- @useless = f
- end
-
- end # class Sym
-
-end # module Racc
diff --git a/lib/racc/grammarfileparser.rb b/lib/racc/grammarfileparser.rb
deleted file mode 100644
index 5e7081f00a..0000000000
--- a/lib/racc/grammarfileparser.rb
+++ /dev/null
@@ -1,560 +0,0 @@
-#
-# $Id: 63bd084db2dce8a2c9760318faae6104717cead7 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of the GNU LGPL, see the file "COPYING".
-#
-
-require 'racc'
-require 'racc/compat'
-require 'racc/grammar'
-require 'racc/parserfilegenerator'
-require 'racc/sourcetext'
-require 'stringio'
-
-module Racc
-
- grammar = Grammar.define {
- g = self
-
- g.class = seq(:CLASS, :cname, many(:param), :RULE, :rules, option(:END))
-
- g.cname = seq(:rubyconst) {|name|
- @result.params.classname = name
- }\
- | seq(:rubyconst, "<", :rubyconst) {|c, _, s|
- @result.params.classname = c
- @result.params.superclass = s
- }
-
- g.rubyconst = separated_by1(:colon2, :SYMBOL) {|syms|
- syms.map {|s| s.to_s }.join('::')
- }
-
- g.colon2 = seq(':', ':')
-
- g.param = seq(:CONV, many1(:convdef), :END) {|*|
- #@grammar.end_convert_block # FIXME
- }\
- | seq(:PRECHIGH, many1(:precdef), :PRECLOW) {|*|
- @grammar.end_precedence_declaration true
- }\
- | seq(:PRECLOW, many1(:precdef), :PRECHIGH) {|*|
- @grammar.end_precedence_declaration false
- }\
- | seq(:START, :symbol) {|_, sym|
- @grammar.start_symbol = sym
- }\
- | seq(:TOKEN, :symbols) {|_, syms|
- syms.each do |s|
- s.should_terminal
- end
- }\
- | seq(:OPTION, :options) {|_, syms|
- syms.each do |opt|
- case opt
- when 'result_var'
- @result.params.result_var = true
- when 'no_result_var'
- @result.params.result_var = false
- when 'omit_action_call'
- @result.params.omit_action_call = true
- when 'no_omit_action_call'
- @result.params.omit_action_call = false
- else
- raise CompileError, "unknown option: #{opt}"
- end
- end
- }\
- | seq(:EXPECT, :DIGIT) {|_, num|
- if @grammar.n_expected_srconflicts
- raise CompileError, "`expect' seen twice"
- end
- @grammar.n_expected_srconflicts = num
- }
-
- g.convdef = seq(:symbol, :STRING) {|sym, code|
- sym.serialized = code
- }
-
- g.precdef = seq(:LEFT, :symbols) {|_, syms|
- @grammar.declare_precedence :Left, syms
- }\
- | seq(:RIGHT, :symbols) {|_, syms|
- @grammar.declare_precedence :Right, syms
- }\
- | seq(:NONASSOC, :symbols) {|_, syms|
- @grammar.declare_precedence :Nonassoc, syms
- }
-
- g.symbols = seq(:symbol) {|sym|
- [sym]
- }\
- | seq(:symbols, :symbol) {|list, sym|
- list.push sym
- list
- }\
- | seq(:symbols, "|")
-
- g.symbol = seq(:SYMBOL) {|sym| @grammar.intern(sym) }\
- | seq(:STRING) {|str| @grammar.intern(str) }
-
- g.options = many(:SYMBOL) {|syms| syms.map {|s| s.to_s } }
-
- g.rules = option(:rules_core) {|list|
- add_rule_block list unless list.empty?
- nil
- }
-
- g.rules_core = seq(:symbol) {|sym|
- [sym]
- }\
- | seq(:rules_core, :rule_item) {|list, i|
- list.push i
- list
- }\
- | seq(:rules_core, ';') {|list, *|
- add_rule_block list unless list.empty?
- list.clear
- list
- }\
- | seq(:rules_core, ':') {|list, *|
- next_target = list.pop
- add_rule_block list unless list.empty?
- [next_target]
- }
-
- g.rule_item = seq(:symbol)\
- | seq("|") {|*|
- OrMark.new(@scanner.lineno)
- }\
- | seq("=", :symbol) {|_, sym|
- Prec.new(sym, @scanner.lineno)
- }\
- | seq(:ACTION) {|src|
- UserAction.source_text(src)
- }
- }
-
- GrammarFileParser = grammar.parser_class
-
- if grammar.states.srconflict_exist?
- raise 'Racc boot script fatal: S/R conflict in build'
- end
- if grammar.states.rrconflict_exist?
- raise 'Racc boot script fatal: R/R conflict in build'
- end
-
- class GrammarFileParser # reopen
-
- class Result
- def initialize(grammar)
- @grammar = grammar
- @params = ParserFileGenerator::Params.new
- end
-
- attr_reader :grammar
- attr_reader :params
- end
-
- def GrammarFileParser.parse_file(filename)
- parse(File.read(filename), filename, 1)
- end
-
- def GrammarFileParser.parse(src, filename = '-', lineno = 1)
- new().parse(src, filename, lineno)
- end
-
- def initialize(debug_flags = DebugFlags.new)
- @yydebug = debug_flags.parse
- end
-
- def parse(src, filename = '-', lineno = 1)
- @filename = filename
- @lineno = lineno
- @scanner = GrammarFileScanner.new(src, @filename)
- @scanner.debug = @yydebug
- @grammar = Grammar.new
- @result = Result.new(@grammar)
- @embedded_action_seq = 0
- yyparse @scanner, :yylex
- parse_user_code
- @result.grammar.init
- @result
- end
-
- private
-
- def next_token
- @scanner.scan
- end
-
- def on_error(tok, val, _values)
- if val.respond_to?(:id2name)
- v = val.id2name
- elsif val.kind_of?(String)
- v = val
- else
- v = val.inspect
- end
- raise CompileError, "#{location()}: unexpected token '#{v}'"
- end
-
- def location
- "#{@filename}:#{@lineno - 1 + @scanner.lineno}"
- end
-
- def add_rule_block(list)
- sprec = nil
- target = list.shift
- case target
- when OrMark, UserAction, Prec
- raise CompileError, "#{target.lineno}: unexpected symbol #{target.name}"
- end
- curr = []
- list.each do |i|
- case i
- when OrMark
- add_rule target, curr, sprec
- curr = []
- sprec = nil
- when Prec
- raise CompileError, "'=<prec>' used twice in one rule" if sprec
- sprec = i.symbol
- else
- curr.push i
- end
- end
- add_rule target, curr, sprec
- end
-
- def add_rule(target, list, sprec)
- if list.last.kind_of?(UserAction)
- act = list.pop
- else
- act = UserAction.empty
- end
- list.map! {|s| s.kind_of?(UserAction) ? embedded_action(s) : s }
- rule = Rule.new(target, list, act)
- rule.specified_prec = sprec
- @grammar.add rule
- end
-
- def embedded_action(act)
- sym = @grammar.intern("@#{@embedded_action_seq += 1}".intern, true)
- @grammar.add Rule.new(sym, [], act)
- sym
- end
-
- #
- # User Code Block
- #
-
- def parse_user_code
- line = @scanner.lineno
- _, *blocks = *@scanner.epilogue.split(/^----/)
- blocks.each do |block|
- header, *body = block.lines.to_a
- label0, pathes = *header.sub(/\A-+/, '').split('=', 2)
- label = canonical_label(label0)
- (pathes ? pathes.strip.split(' ') : []).each do |path|
- add_user_code label, SourceText.new(File.read(path), path, 1)
- end
- add_user_code label, SourceText.new(body.join(''), @filename, line + 1)
- line += (1 + body.size)
- end
- end
-
- USER_CODE_LABELS = {
- 'header' => :header,
- 'prepare' => :header, # obsolete
- 'inner' => :inner,
- 'footer' => :footer,
- 'driver' => :footer # obsolete
- }
-
- def canonical_label(src)
- label = src.to_s.strip.downcase.slice(/\w+/)
- unless USER_CODE_LABELS.key?(label)
- raise CompileError, "unknown user code type: #{label.inspect}"
- end
- label
- end
-
- def add_user_code(label, src)
- @result.params.send(USER_CODE_LABELS[label]).push src
- end
-
- end
-
-
- class GrammarFileScanner
-
- def initialize(str, filename = '-')
- @lines = str.b.split(/\n|\r\n|\r/)
- @filename = filename
- @lineno = -1
- @line_head = true
- @in_rule_blk = false
- @in_conv_blk = false
- @in_block = nil
- @epilogue = ''
- @debug = false
- next_line
- end
-
- attr_reader :epilogue
-
- def lineno
- @lineno + 1
- end
-
- attr_accessor :debug
-
- def yylex(&block)
- unless @debug
- yylex0(&block)
- else
- yylex0 do |sym, tok|
- $stderr.printf "%7d %-10s %s\n", lineno(), sym.inspect, tok.inspect
- yield [sym, tok]
- end
- end
- end
-
- private
-
- def yylex0
- begin
- until @line.empty?
- @line.sub!(/\A\s+/, '')
- if /\A\#/ =~ @line
- break
- elsif /\A\/\*/ =~ @line
- skip_comment
- elsif s = reads(/\A[a-zA-Z_]\w*/)
- yield [atom_symbol(s), s.intern]
- elsif s = reads(/\A\d+/)
- yield [:DIGIT, s.to_i]
- elsif ch = reads(/\A./)
- case ch
- when '"', "'"
- yield [:STRING, eval(scan_quoted(ch))]
- when '{'
- lineno = lineno()
- yield [:ACTION, SourceText.new(scan_action(), @filename, lineno)]
- else
- if ch == '|'
- @line_head = false
- end
- yield [ch, ch]
- end
- else
- end
- end
- end while next_line()
- yield nil
- end
-
- def next_line
- @lineno += 1
- @line = @lines[@lineno]
- if not @line or /\A----/ =~ @line
- @epilogue = @lines.join("\n")
- @lines.clear
- @line = nil
- if @in_block
- @lineno -= 1
- scan_error! sprintf('unterminated %s', @in_block)
- end
- false
- else
- @line.sub!(/(?:\n|\r\n|\r)\z/, '')
- @line_head = true
- true
- end
- end
-
- ReservedWord = {
- 'right' => :RIGHT,
- 'left' => :LEFT,
- 'nonassoc' => :NONASSOC,
- 'preclow' => :PRECLOW,
- 'prechigh' => :PRECHIGH,
- 'token' => :TOKEN,
- 'convert' => :CONV,
- 'options' => :OPTION,
- 'start' => :START,
- 'expect' => :EXPECT,
- 'class' => :CLASS,
- 'rule' => :RULE,
- 'end' => :END
- }
-
- def atom_symbol(token)
- if token == 'end'
- symbol = :END
- @in_conv_blk = false
- @in_rule_blk = false
- else
- if @line_head and not @in_conv_blk and not @in_rule_blk
- symbol = ReservedWord[token] || :SYMBOL
- else
- symbol = :SYMBOL
- end
- case symbol
- when :RULE then @in_rule_blk = true
- when :CONV then @in_conv_blk = true
- end
- end
- @line_head = false
- symbol
- end
-
- def skip_comment
- @in_block = 'comment'
- until m = /\*\//.match(@line)
- next_line
- end
- @line = m.post_match
- @in_block = nil
- end
-
- $raccs_print_type = false
-
- def scan_action
- buf = ''
- nest = 1
- pre = nil
- @in_block = 'action'
- begin
- pre = nil
- if s = reads(/\A\s+/)
- # does not set 'pre'
- buf << s
- end
- until @line.empty?
- if s = reads(/\A[^'"`{}%#\/\$]+/)
- buf << (pre = s)
- next
- end
- case ch = read(1)
- when '{'
- nest += 1
- buf << (pre = ch)
- when '}'
- nest -= 1
- if nest == 0
- @in_block = nil
- buf.sub!(/[ \t\f]+\z/, '')
- return buf
- end
- buf << (pre = ch)
- when '#' # comment
- buf << ch << @line
- break
- when "'", '"', '`'
- buf << (pre = scan_quoted(ch))
- when '%'
- if literal_head? pre, @line
- # % string, regexp, array
- buf << ch
- case ch = read(1)
- when /[qQx]/n
- buf << ch << (pre = scan_quoted(read(1), '%string'))
- when /wW/n
- buf << ch << (pre = scan_quoted(read(1), '%array'))
- when /s/n
- buf << ch << (pre = scan_quoted(read(1), '%symbol'))
- when /r/n
- buf << ch << (pre = scan_quoted(read(1), '%regexp'))
- when /[a-zA-Z0-9= ]/n # does not include "_"
- scan_error! "unknown type of % literal '%#{ch}'"
- else
- buf << (pre = scan_quoted(ch, '%string'))
- end
- else
- # operator
- buf << '||op->' if $raccs_print_type
- buf << (pre = ch)
- end
- when '/'
- if literal_head? pre, @line
- # regexp
- buf << (pre = scan_quoted(ch, 'regexp'))
- else
- # operator
- buf << '||op->' if $raccs_print_type
- buf << (pre = ch)
- end
- when '$' # gvar
- buf << ch << (pre = read(1))
- else
- raise 'racc: fatal: must not happen'
- end
- end
- buf << "\n"
- end while next_line()
- raise 'racc: fatal: scan finished before parser finished'
- end
-
- def literal_head?(pre, post)
- (!pre || /[a-zA-Z_0-9]/n !~ pre[-1,1]) &&
- !post.empty? && /\A[\s\=]/n !~ post
- end
-
- def read(len)
- s = @line[0, len]
- @line = @line[len .. -1]
- s
- end
-
- def reads(re)
- m = re.match(@line) or return nil
- @line = m.post_match
- m[0]
- end
-
- def scan_quoted(left, tag = 'string')
- buf = left.dup
- buf = "||#{tag}->" + buf if $raccs_print_type
- re = get_quoted_re(left)
- sv, @in_block = @in_block, tag
- begin
- if s = reads(re)
- buf << s
- break
- else
- buf << @line
- end
- end while next_line()
- @in_block = sv
- buf << "<-#{tag}||" if $raccs_print_type
- buf
- end
-
- LEFT_TO_RIGHT = {
- '(' => ')',
- '{' => '}',
- '[' => ']',
- '<' => '>'
- }
-
- CACHE = {}
-
- def get_quoted_re(left)
- term = Regexp.quote(LEFT_TO_RIGHT[left] || left)
- CACHE[left] ||= /\A[^#{term}\\]*(?:\\.[^\\#{term}]*)*#{term}/
- end
-
- def scan_error!(msg)
- raise CompileError, "#{lineno()}: #{msg}"
- end
-
- end
-
-end # module Racc
diff --git a/lib/racc/info.rb b/lib/racc/info.rb
deleted file mode 100644
index b7db7b6c9b..0000000000
--- a/lib/racc/info.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# $Id: 8ab2cb5341529fe5e35956bb1a1f42ec9b9c6f5a $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-
-module Racc
- VERSION = '1.4.16'
- Version = VERSION
- Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
-end
diff --git a/lib/racc/iset.rb b/lib/racc/iset.rb
deleted file mode 100644
index 245bad8b50..0000000000
--- a/lib/racc/iset.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# $Id: 31aa4331c08dfd4609c06eb5f94b7ef38dc708e1 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of the GNU LGPL, see the file "COPYING".
-#
-
-module Racc
-
- # An "indexed" set. All items must respond to :ident.
- class ISet
-
- def initialize(a = [])
- @set = a
- end
-
- attr_reader :set
-
- def add(i)
- @set[i.ident] = i
- end
-
- def [](key)
- @set[key.ident]
- end
-
- def []=(key, val)
- @set[key.ident] = val
- end
-
- alias include? []
- alias key? []
-
- def update(other)
- s = @set
- o = other.set
- o.each_index do |idx|
- if t = o[idx]
- s[idx] = t
- end
- end
- end
-
- def update_a(a)
- s = @set
- a.each {|i| s[i.ident] = i }
- end
-
- def delete(key)
- i = @set[key.ident]
- @set[key.ident] = nil
- i
- end
-
- def each(&block)
- @set.compact.each(&block)
- end
-
- def to_a
- @set.compact
- end
-
- def to_s
- "[#{@set.compact.join(' ')}]"
- end
-
- alias inspect to_s
-
- def size
- @set.nitems
- end
-
- def empty?
- @set.nitems == 0
- end
-
- def clear
- @set.clear
- end
-
- def dup
- ISet.new(@set.dup)
- end
-
- end # class ISet
-
-end # module Racc
diff --git a/lib/racc/logfilegenerator.rb b/lib/racc/logfilegenerator.rb
deleted file mode 100644
index 68593c41f6..0000000000
--- a/lib/racc/logfilegenerator.rb
+++ /dev/null
@@ -1,211 +0,0 @@
-#
-# $Id: 5e9d0a01b5d56fd9cdc3d5cb078b1a3e1bbaf779 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of the GNU LGPL, see the file "COPYING".
-#
-
-module Racc
-
- class LogFileGenerator
-
- def initialize(states, debug_flags = DebugFlags.new)
- @states = states
- @grammar = states.grammar
- @debug_flags = debug_flags
- end
-
- def output(out)
- output_conflict out; out.puts
- output_useless out; out.puts
- output_rule out; out.puts
- output_token out; out.puts
- output_state out
- end
-
- #
- # Warnings
- #
-
- def output_conflict(out)
- @states.each do |state|
- if state.srconf
- out.printf "state %d contains %d shift/reduce conflicts\n",
- state.stateid, state.srconf.size
- end
- if state.rrconf
- out.printf "state %d contains %d reduce/reduce conflicts\n",
- state.stateid, state.rrconf.size
- end
- end
- end
-
- def output_useless(out)
- @grammar.each do |rl|
- if rl.useless?
- out.printf "rule %d (%s) never reduced\n",
- rl.ident, rl.target.to_s
- end
- end
- @grammar.each_nonterminal do |t|
- if t.useless?
- out.printf "useless nonterminal %s\n", t.to_s
- end
- end
- end
-
- #
- # States
- #
-
- def output_state(out)
- out << "--------- State ---------\n"
-
- showall = @debug_flags.la || @debug_flags.state
- @states.each do |state|
- out << "\nstate #{state.ident}\n\n"
-
- (showall ? state.closure : state.core).each do |ptr|
- pointer_out(out, ptr) if ptr.rule.ident != 0 or showall
- end
- out << "\n"
-
- action_out out, state
- end
- end
-
- def pointer_out(out, ptr)
- buf = sprintf("%4d) %s :", ptr.rule.ident, ptr.rule.target.to_s)
- ptr.rule.symbols.each_with_index do |tok, idx|
- buf << ' _' if idx == ptr.index
- buf << ' ' << tok.to_s
- end
- buf << ' _' if ptr.reduce?
- out.puts buf
- end
-
- def action_out(f, state)
- sr = state.srconf && state.srconf.dup
- rr = state.rrconf && state.rrconf.dup
- acts = state.action
- keys = acts.keys
- keys.sort! {|a,b| a.ident <=> b.ident }
-
- [ Shift, Reduce, Error, Accept ].each do |klass|
- keys.delete_if do |tok|
- act = acts[tok]
- if act.kind_of?(klass)
- outact f, tok, act
- if sr and c = sr.delete(tok)
- outsrconf f, c
- end
- if rr and c = rr.delete(tok)
- outrrconf f, c
- end
-
- true
- else
- false
- end
- end
- end
- sr.each {|tok, c| outsrconf f, c } if sr
- rr.each {|tok, c| outrrconf f, c } if rr
-
- act = state.defact
- if not act.kind_of?(Error) or @debug_flags.any?
- outact f, '$default', act
- end
-
- f.puts
- state.goto_table.each do |t, st|
- if t.nonterminal?
- f.printf " %-12s go to state %d\n", t.to_s, st.ident
- end
- end
- end
-
- def outact(f, t, act)
- case act
- when Shift
- f.printf " %-12s shift, and go to state %d\n",
- t.to_s, act.goto_id
- when Reduce
- f.printf " %-12s reduce using rule %d (%s)\n",
- t.to_s, act.ruleid, act.rule.target.to_s
- when Accept
- f.printf " %-12s accept\n", t.to_s
- when Error
- f.printf " %-12s error\n", t.to_s
- else
- raise "racc: fatal: wrong act for outact: act=#{act}(#{act.class})"
- end
- end
-
- def outsrconf(f, confs)
- confs.each do |c|
- r = c.reduce
- f.printf " %-12s [reduce using rule %d (%s)]\n",
- c.shift.to_s, r.ident, r.target.to_s
- end
- end
-
- def outrrconf(f, confs)
- confs.each do |c|
- r = c.low_prec
- f.printf " %-12s [reduce using rule %d (%s)]\n",
- c.token.to_s, r.ident, r.target.to_s
- end
- end
-
- #
- # Rules
- #
-
- def output_rule(out)
- out.print "-------- Grammar --------\n\n"
- @grammar.each do |rl|
- if @debug_flags.any? or rl.ident != 0
- out.printf "rule %d %s: %s\n",
- rl.ident, rl.target.to_s, rl.symbols.join(' ')
- end
- end
- end
-
- #
- # Tokens
- #
-
- def output_token(out)
- out.print "------- Symbols -------\n\n"
-
- out.print "**Nonterminals, with rules where they appear\n\n"
- @grammar.each_nonterminal do |t|
- tmp = <<SRC
- %s (%d)
- on right: %s
- on left : %s
-SRC
- out.printf tmp, t.to_s, t.ident,
- symbol_locations(t.locate).join(' '),
- symbol_locations(t.heads).join(' ')
- end
-
- out.print "\n**Terminals, with rules where they appear\n\n"
- @grammar.each_terminal do |t|
- out.printf " %s (%d) %s\n",
- t.to_s, t.ident, symbol_locations(t.locate).join(' ')
- end
- end
-
- def symbol_locations(locs)
- locs.map {|loc| loc.rule.ident }.reject {|n| n == 0 }.uniq
- end
-
- end
-
-end # module Racc
diff --git a/lib/racc/parser-text.rb b/lib/racc/parser-text.rb
deleted file mode 100644
index 31b8e2c01f..0000000000
--- a/lib/racc/parser-text.rb
+++ /dev/null
@@ -1,643 +0,0 @@
-module Racc
- PARSER_TEXT = <<'__end_of_file__'
-# frozen_string_literal: false
-#--
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-#
-# As a special exception, when this code is copied by Racc
-# into a Racc output file, you may use that output file
-# without restriction.
-#++
-
-require 'racc/info'
-
-unless defined?(NotImplementedError)
- NotImplementedError = NotImplementError # :nodoc:
-end
-
-module Racc
- class ParseError < StandardError; end
-end
-unless defined?(::ParseError)
- ParseError = Racc::ParseError
-end
-
-# Racc is a LALR(1) parser generator.
-# It is written in Ruby itself, and generates Ruby programs.
-#
-# == Command-line Reference
-#
-# racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
-# [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
-# [-v] [--verbose]
-# [-O<var>filename</var>] [--log-file=<var>filename</var>]
-# [-g] [--debug]
-# [-E] [--embedded]
-# [-l] [--no-line-convert]
-# [-c] [--line-convert-all]
-# [-a] [--no-omit-actions]
-# [-C] [--check-only]
-# [-S] [--output-status]
-# [--version] [--copyright] [--help] <var>grammarfile</var>
-#
-# [+filename+]
-# Racc grammar file. Any extension is permitted.
-# [-o+outfile+, --output-file=+outfile+]
-# A filename for output. default is <+filename+>.tab.rb
-# [-O+filename+, --log-file=+filename+]
-# Place logging output in file +filename+.
-# Default log file name is <+filename+>.output.
-# [-e+rubypath+, --executable=+rubypath+]
-# output executable file(mode 755). where +path+ is the Ruby interpreter.
-# [-v, --verbose]
-# verbose mode. create +filename+.output file, like yacc's y.output file.
-# [-g, --debug]
-# add debug code to parser class. To display debuggin information,
-# use this '-g' option and set @yydebug true in parser class.
-# [-E, --embedded]
-# Output parser which doesn't need runtime files (racc/parser.rb).
-# [-C, --check-only]
-# Check syntax of racc grammar file and quit.
-# [-S, --output-status]
-# Print messages time to time while compiling.
-# [-l, --no-line-convert]
-# turns off line number converting.
-# [-c, --line-convert-all]
-# Convert line number of actions, inner, header and footer.
-# [-a, --no-omit-actions]
-# Call all actions, even if an action is empty.
-# [--version]
-# print Racc version and quit.
-# [--copyright]
-# Print copyright and quit.
-# [--help]
-# Print usage and quit.
-#
-# == Generating Parser Using Racc
-#
-# To compile Racc grammar file, simply type:
-#
-# $ racc parse.y
-#
-# This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
-#
-# == Writing A Racc Grammar File
-#
-# If you want your own parser, you have to write a grammar file.
-# A grammar file contains the name of your parser class, grammar for the parser,
-# user code, and anything else.
-# When writing a grammar file, yacc's knowledge is helpful.
-# If you have not used yacc before, Racc is not too difficult.
-#
-# Here's an example Racc grammar file.
-#
-# class Calcparser
-# rule
-# target: exp { print val[0] }
-#
-# exp: exp '+' exp
-# | exp '*' exp
-# | '(' exp ')'
-# | NUMBER
-# end
-#
-# Racc grammar files resemble yacc files.
-# But (of course), this is Ruby code.
-# yacc's $$ is the 'result', $0, $1... is
-# an array called 'val', and $-1, $-2... is an array called '_values'.
-#
-# See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
-# more information on grammar files.
-#
-# == Parser
-#
-# Then you must prepare the parse entry method. There are two types of
-# parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
-#
-# Racc::Parser#do_parse is simple.
-#
-# It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
-# This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
-# EOF is [false, false].
-# (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
-# If you want to change this, see the grammar reference.
-#
-# Racc::Parser#yyparse is little complicated, but useful.
-# It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
-#
-# For example, <code>yyparse(obj, :scan)</code> causes
-# calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
-#
-# == Debugging
-#
-# When debugging, "-v" or/and the "-g" option is helpful.
-#
-# "-v" creates verbose log file (.output).
-# "-g" creates a "Verbose Parser".
-# Verbose Parser prints the internal status when parsing.
-# But it's _not_ automatic.
-# You must use -g option and set +@yydebug+ to +true+ in order to get output.
-# -g option only creates the verbose parser.
-#
-# === Racc reported syntax error.
-#
-# Isn't there too many "end"?
-# grammar of racc file is changed in v0.10.
-#
-# Racc does not use '%' mark, while yacc uses huge number of '%' marks..
-#
-# === Racc reported "XXXX conflicts".
-#
-# Try "racc -v xxxx.y".
-# It causes producing racc's internal log file, xxxx.output.
-#
-# === Generated parsers does not work correctly
-#
-# Try "racc -g xxxx.y".
-# This command let racc generate "debugging parser".
-# Then set @yydebug=true in your parser.
-# It produces a working log of your parser.
-#
-# == Re-distributing Racc runtime
-#
-# A parser, which is created by Racc, requires the Racc runtime module;
-# racc/parser.rb.
-#
-# Ruby 1.8.x comes with Racc runtime module,
-# you need NOT distribute Racc runtime files.
-#
-# If you want to include the Racc runtime module with your parser.
-# This can be done by using '-E' option:
-#
-# $ racc -E -omyparser.rb myparser.y
-#
-# This command creates myparser.rb which `includes' Racc runtime.
-# Only you must do is to distribute your parser file (myparser.rb).
-#
-# Note: parser.rb is ruby license, but your parser is not.
-# Your own parser is completely yours.
-module Racc
-
- unless defined?(Racc_No_Extentions)
- Racc_No_Extentions = false # :nodoc:
- end
-
- class Parser
-
- Racc_Runtime_Version = ::Racc::VERSION
- Racc_Runtime_Revision = '$Id: 7adc21ee7a5690f10b7ff399b8af4e2717b9d94c $'
-
- Racc_Runtime_Core_Version_R = ::Racc::VERSION
- Racc_Runtime_Core_Revision_R = '$Id: 7adc21ee7a5690f10b7ff399b8af4e2717b9d94c $'.split[1]
- begin
- if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
- require 'racc/cparse-jruby.jar'
- com.headius.racc.Cparse.new.load(JRuby.runtime, false)
- else
- require 'racc/cparse'
- end
- # Racc_Runtime_Core_Version_C = (defined in extension)
- Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
- unless new.respond_to?(:_racc_do_parse_c, true)
- raise LoadError, 'old cparse.so'
- end
- if Racc_No_Extentions
- raise LoadError, 'selecting ruby version of racc runtime core'
- end
-
- Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
- Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
- Racc_Runtime_Type = 'c' # :nodoc:
- rescue LoadError
-puts $!
-puts $!.backtrace
- Racc_Main_Parsing_Routine = :_racc_do_parse_rb
- Racc_YY_Parse_Method = :_racc_yyparse_rb
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
- Racc_Runtime_Type = 'ruby'
- end
-
- def Parser.racc_runtime_type # :nodoc:
- Racc_Runtime_Type
- end
-
- def _racc_setup
- @yydebug = false unless self.class::Racc_debug_parser
- @yydebug = false unless defined?(@yydebug)
- if @yydebug
- @racc_debug_out = $stderr unless defined?(@racc_debug_out)
- @racc_debug_out ||= $stderr
- end
- arg = self.class::Racc_arg
- arg[13] = true if arg.size < 14
- arg
- end
-
- def _racc_init_sysvars
- @racc_state = [0]
- @racc_tstack = []
- @racc_vstack = []
-
- @racc_t = nil
- @racc_val = nil
-
- @racc_read_next = true
-
- @racc_user_yyerror = false
- @racc_error_status = 0
- end
-
- # The entry point of the parser. This method is used with #next_token.
- # If Racc wants to get token (and its value), calls next_token.
- #
- # Example:
- # def parse
- # @q = [[1,1],
- # [2,2],
- # [3,3],
- # [false, '$']]
- # do_parse
- # end
- #
- # def next_token
- # @q.shift
- # end
- class_eval %{
- def do_parse
- #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
- end
- }
-
- # The method to fetch next token.
- # If you use #do_parse method, you must implement #next_token.
- #
- # The format of return value is [TOKEN_SYMBOL, VALUE].
- # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
- # for 'IDENT'. ";" (String) for ';'.
- #
- # The final symbol (End of file) must be false.
- def next_token
- raise NotImplementedError, "#{self.class}\#next_token is not defined"
- end
-
- def _racc_do_parse_rb(arg, in_debug)
- action_table, action_check, action_default, action_pointer,
- _, _, _, _,
- _, _, token_table, * = arg
-
- _racc_init_sysvars
- tok = act = i = nil
-
- catch(:racc_end_parse) {
- while true
- if i = action_pointer[@racc_state[-1]]
- if @racc_read_next
- if @racc_t != 0 # not EOF
- tok, @racc_val = next_token()
- unless tok # EOF
- @racc_t = 0
- else
- @racc_t = (token_table[tok] or 1) # error token
- end
- racc_read_token(@racc_t, tok, @racc_val) if @yydebug
- @racc_read_next = false
- end
- end
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- else
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
- end
- }
- end
-
- # Another entry point for the parser.
- # If you use this method, you must implement RECEIVER#METHOD_ID method.
- #
- # RECEIVER#METHOD_ID is a method to get next token.
- # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
- class_eval %{
- def yyparse(recv, mid)
- #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), true)
- end
- }
-
- def _racc_yyparse_rb(recv, mid, arg, c_debug)
- action_table, action_check, action_default, action_pointer,
- _, _, _, _,
- _, _, token_table, * = arg
-
- _racc_init_sysvars
-
- catch(:racc_end_parse) {
- until i = action_pointer[@racc_state[-1]]
- while act = _racc_evalact(action_default[@racc_state[-1]], arg)
- ;
- end
- end
- recv.__send__(mid) do |tok, val|
- unless tok
- @racc_t = 0
- else
- @racc_t = (token_table[tok] or 1) # error token
- end
- @racc_val = val
- @racc_read_next = false
-
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
-
- while !(i = action_pointer[@racc_state[-1]]) ||
- ! @racc_read_next ||
- @racc_t == 0 # $
- unless i and i += @racc_t and
- i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
- end
- end
- }
- end
-
- ###
- ### common
- ###
-
- def _racc_evalact(act, arg)
- action_table, action_check, _, action_pointer,
- _, _, _, _,
- _, _, _, shift_n,
- reduce_n, * = arg
- nerr = 0 # tmp
-
- if act > 0 and act < shift_n
- #
- # shift
- #
- if @racc_error_status > 0
- @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
- end
- @racc_vstack.push @racc_val
- @racc_state.push act
- @racc_read_next = true
- if @yydebug
- @racc_tstack.push @racc_t
- racc_shift @racc_t, @racc_tstack, @racc_vstack
- end
-
- elsif act < 0 and act > -reduce_n
- #
- # reduce
- #
- code = catch(:racc_jump) {
- @racc_state.push _racc_do_reduce(arg, act)
- false
- }
- if code
- case code
- when 1 # yyerror
- @racc_user_yyerror = true # user_yyerror
- return -reduce_n
- when 2 # yyaccept
- return shift_n
- else
- raise '[Racc Bug] unknown jump code'
- end
- end
-
- elsif act == shift_n
- #
- # accept
- #
- racc_accept if @yydebug
- throw :racc_end_parse, @racc_vstack[0]
-
- elsif act == -reduce_n
- #
- # error
- #
- case @racc_error_status
- when 0
- unless arg[21] # user_yyerror
- nerr += 1
- on_error @racc_t, @racc_val, @racc_vstack
- end
- when 3
- if @racc_t == 0 # is $
- # We're at EOF, and another error occurred immediately after
- # attempting auto-recovery
- throw :racc_end_parse, nil
- end
- @racc_read_next = true
- end
- @racc_user_yyerror = false
- @racc_error_status = 3
- while true
- if i = action_pointer[@racc_state[-1]]
- i += 1 # error token
- if i >= 0 and
- (act = action_table[i]) and
- action_check[i] == @racc_state[-1]
- break
- end
- end
- throw :racc_end_parse, nil if @racc_state.size <= 1
- @racc_state.pop
- @racc_vstack.pop
- if @yydebug
- @racc_tstack.pop
- racc_e_pop @racc_state, @racc_tstack, @racc_vstack
- end
- end
- return act
-
- else
- raise "[Racc Bug] unknown action #{act.inspect}"
- end
-
- racc_next_state(@racc_state[-1], @racc_state) if @yydebug
-
- nil
- end
-
- def _racc_do_reduce(arg, act)
- _, _, _, _,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, _, _,
- _, use_result, * = arg
-
- state = @racc_state
- vstack = @racc_vstack
- tstack = @racc_tstack
-
- i = act * -3
- len = reduce_table[i]
- reduce_to = reduce_table[i+1]
- method_id = reduce_table[i+2]
- void_array = []
-
- tmp_t = tstack[-len, len] if @yydebug
- tmp_v = vstack[-len, len]
- tstack[-len, len] = void_array if @yydebug
- vstack[-len, len] = void_array
- state[-len, len] = void_array
-
- # tstack must be updated AFTER method call
- if use_result
- vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
- else
- vstack.push __send__(method_id, tmp_v, vstack)
- end
- tstack.push reduce_to
-
- racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
-
- k1 = reduce_to - nt_base
- if i = goto_pointer[k1]
- i += state[-1]
- if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
- return curstate
- end
- end
- goto_default[k1]
- end
-
- # This method is called when a parse error is found.
- #
- # ERROR_TOKEN_ID is an internal ID of token which caused error.
- # You can get string representation of this ID by calling
- # #token_to_str.
- #
- # ERROR_VALUE is a value of error token.
- #
- # value_stack is a stack of symbol values.
- # DO NOT MODIFY this object.
- #
- # This method raises ParseError by default.
- #
- # If this method returns, parsers enter "error recovering mode".
- def on_error(t, val, vstack)
- raise ParseError, sprintf("\nparse error on value %s (%s)",
- val.inspect, token_to_str(t) || '?')
- end
-
- # Enter error recovering mode.
- # This method does not call #on_error.
- def yyerror
- throw :racc_jump, 1
- end
-
- # Exit parser.
- # Return value is Symbol_Value_Stack[0].
- def yyaccept
- throw :racc_jump, 2
- end
-
- # Leave error recovering mode.
- def yyerrok
- @racc_error_status = 0
- end
-
- # For debugging output
- def racc_read_token(t, tok, val)
- @racc_debug_out.print 'read '
- @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
- @racc_debug_out.puts val.inspect
- @racc_debug_out.puts
- end
-
- def racc_shift(tok, tstack, vstack)
- @racc_debug_out.puts "shift #{racc_token2str tok}"
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_reduce(toks, sim, tstack, vstack)
- out = @racc_debug_out
- out.print 'reduce '
- if toks.empty?
- out.print ' <none>'
- else
- toks.each {|t| out.print ' ', racc_token2str(t) }
- end
- out.puts " --> #{racc_token2str(sim)}"
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_accept
- @racc_debug_out.puts 'accept'
- @racc_debug_out.puts
- end
-
- def racc_e_pop(state, tstack, vstack)
- @racc_debug_out.puts 'error recovering mode: pop token'
- racc_print_states state
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_next_state(curstate, state)
- @racc_debug_out.puts "goto #{curstate}"
- racc_print_states state
- @racc_debug_out.puts
- end
-
- def racc_print_stacks(t, v)
- out = @racc_debug_out
- out.print ' ['
- t.each_index do |i|
- out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
- end
- out.puts ' ]'
- end
-
- def racc_print_states(s)
- out = @racc_debug_out
- out.print ' ['
- s.each {|st| out.print ' ', st }
- out.puts ' ]'
- end
-
- def racc_token2str(tok)
- self.class::Racc_token_to_s_table[tok] or
- raise "[Racc Bug] can't convert token #{tok} to string"
- end
-
- # Convert internal ID of token symbol to the string.
- def token_to_str(t)
- self.class::Racc_token_to_s_table[t]
- end
-
- end
-
-end
-
-__end_of_file__
-end
diff --git a/lib/racc/parser.rb b/lib/racc/parser.rb
index 56b4af9dea..0cdb42e49d 100644
--- a/lib/racc/parser.rb
+++ b/lib/racc/parser.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: false
#--
+# $originalId: parser.rb,v 1.8 2006/07/06 11:42:07 aamine Exp $
+#
# Copyright (c) 1999-2006 Minero Aoki
#
# This program is free software.
@@ -10,12 +12,6 @@
# without restriction.
#++
-require 'racc/info'
-
-unless defined?(NotImplementedError)
- NotImplementedError = NotImplementError # :nodoc:
-end
-
module Racc
class ParseError < StandardError; end
end
@@ -53,7 +49,7 @@ end
# [-v, --verbose]
# verbose mode. create +filename+.output file, like yacc's y.output file.
# [-g, --debug]
-# add debug code to parser class. To display debuggin information,
+# add debug code to parser class. To display debugging information,
# use this '-g' option and set @yydebug true in parser class.
# [-E, --embedded]
# Output parser which doesn't need runtime files (racc/parser.rb).
@@ -175,34 +171,29 @@ end
# This command creates myparser.rb which `includes' Racc runtime.
# Only you must do is to distribute your parser file (myparser.rb).
#
-# Note: parser.rb is ruby license, but your parser is not.
+# Note: parser.rb is LGPL, but your parser is not.
# Your own parser is completely yours.
module Racc
- unless defined?(Racc_No_Extentions)
- Racc_No_Extentions = false # :nodoc:
+ unless defined?(Racc_No_Extensions)
+ Racc_No_Extensions = false # :nodoc:
end
class Parser
- Racc_Runtime_Version = ::Racc::VERSION
- Racc_Runtime_Revision = '$Id: e754525bd317344c4284fca6fdce0a425979ade1 $'
+ Racc_Runtime_Version = '1.4.6'
+ Racc_Runtime_Revision = %w$originalRevision: 1.8 $[1]
- Racc_Runtime_Core_Version_R = ::Racc::VERSION
- Racc_Runtime_Core_Revision_R = '$Id: e754525bd317344c4284fca6fdce0a425979ade1 $'.split[1]
+ Racc_Runtime_Core_Version_R = '1.4.6'
+ Racc_Runtime_Core_Revision_R = %w$originalRevision: 1.8 $[1]
begin
- if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
- require 'racc/cparse-jruby.jar'
- com.headius.racc.Cparse.new.load(JRuby.runtime, false)
- else
- require 'racc/cparse'
- end
+ require 'racc/cparse'
# Racc_Runtime_Core_Version_C = (defined in extension)
Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
unless new.respond_to?(:_racc_do_parse_c, true)
raise LoadError, 'old cparse.so'
end
- if Racc_No_Extentions
+ if Racc_No_Extensions
raise LoadError, 'selecting ruby version of racc runtime core'
end
@@ -212,8 +203,6 @@ module Racc
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
Racc_Runtime_Type = 'c' # :nodoc:
rescue LoadError
-puts $!
-puts $!.backtrace
Racc_Main_Parsing_Routine = :_racc_do_parse_rb
Racc_YY_Parse_Method = :_racc_yyparse_rb
Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
@@ -266,11 +255,9 @@ puts $!.backtrace
# def next_token
# @q.shift
# end
- class_eval %{
def do_parse
- #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
+ __send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
end
- }
# The method to fetch next token.
# If you use #do_parse method, you must implement #next_token.
@@ -287,7 +274,8 @@ puts $!.backtrace
def _racc_do_parse_rb(arg, in_debug)
action_table, action_check, action_default, action_pointer,
_, _, _, _,
- _, _, token_table, * = arg
+ _, _, token_table, _,
+ _, _, * = arg
_racc_init_sysvars
tok = act = i = nil
@@ -328,18 +316,19 @@ puts $!.backtrace
#
# RECEIVER#METHOD_ID is a method to get next token.
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
- class_eval %{
def yyparse(recv, mid)
- #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), true)
+ __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
end
- }
def _racc_yyparse_rb(recv, mid, arg, c_debug)
action_table, action_check, action_default, action_pointer,
- _, _, _, _,
- _, _, token_table, * = arg
+ _, _, _, _,
+ _, _, token_table, _,
+ _, _, * = arg
_racc_init_sysvars
+ act = nil
+ i = nil
catch(:racc_end_parse) {
until i = action_pointer[@racc_state[-1]]
@@ -366,9 +355,9 @@ puts $!.backtrace
;
end
- while !(i = action_pointer[@racc_state[-1]]) ||
- ! @racc_read_next ||
- @racc_t == 0 # $
+ while not(i = action_pointer[@racc_state[-1]]) or
+ not @racc_read_next or
+ @racc_t == 0 # $
unless i and i += @racc_t and
i >= 0 and
act = action_table[i] and
@@ -389,17 +378,16 @@ puts $!.backtrace
def _racc_evalact(act, arg)
action_table, action_check, _, action_pointer,
- _, _, _, _,
- _, _, _, shift_n,
- reduce_n, * = arg
- nerr = 0 # tmp
+ _, _, _, _,
+ _, _, _, shift_n, reduce_n,
+ _, _, * = arg
if act > 0 and act < shift_n
#
# shift
#
if @racc_error_status > 0
- @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
+ @racc_error_status -= 1 unless @racc_t == 1 # error token
end
@racc_vstack.push @racc_val
@racc_state.push act
@@ -443,13 +431,10 @@ puts $!.backtrace
case @racc_error_status
when 0
unless arg[21] # user_yyerror
- nerr += 1
on_error @racc_t, @racc_val, @racc_vstack
end
when 3
if @racc_t == 0 # is $
- # We're at EOF, and another error occurred immediately after
- # attempting auto-recovery
throw :racc_end_parse, nil
end
@racc_read_next = true
@@ -485,11 +470,10 @@ puts $!.backtrace
end
def _racc_do_reduce(arg, act)
- _, _, _, _,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, _, _,
- _, use_result, * = arg
-
+ _, _, _, _,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, _, _,
+ _, use_result, * = arg
state = @racc_state
vstack = @racc_vstack
tstack = @racc_tstack
@@ -585,6 +569,7 @@ puts $!.backtrace
toks.each {|t| out.print ' ', racc_token2str(t) }
end
out.puts " --> #{racc_token2str(sim)}"
+
racc_print_stacks tstack, vstack
@racc_debug_out.puts
end
diff --git a/lib/racc/parserfilegenerator.rb b/lib/racc/parserfilegenerator.rb
deleted file mode 100644
index ee1262db29..0000000000
--- a/lib/racc/parserfilegenerator.rb
+++ /dev/null
@@ -1,510 +0,0 @@
-#
-# $Id: fff07ebfd582f8dbc845e424908cb9f41f8bf42f $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-
-require 'enumerator'
-require 'racc/compat'
-require 'racc/sourcetext'
-require 'racc/parser-text'
-require 'rbconfig'
-
-module Racc
-
- class ParserFileGenerator
-
- class Params
- def self.bool_attr(name)
- module_eval(<<-End)
- def #{name}?
- @#{name}
- end
-
- def #{name}=(b)
- @#{name} = b
- end
- End
- end
-
- attr_accessor :filename
- attr_accessor :classname
- attr_accessor :superclass
- bool_attr :omit_action_call
- bool_attr :result_var
- attr_accessor :header
- attr_accessor :inner
- attr_accessor :footer
-
- bool_attr :debug_parser
- bool_attr :convert_line
- bool_attr :convert_line_all
- bool_attr :embed_runtime
- bool_attr :make_executable
- attr_accessor :interpreter
-
- def initialize
- # Parameters derived from parser
- self.filename = nil
- self.classname = nil
- self.superclass = 'Racc::Parser'
- self.omit_action_call = true
- self.result_var = true
- self.header = []
- self.inner = []
- self.footer = []
-
- # Parameters derived from command line options
- self.debug_parser = false
- self.convert_line = true
- self.convert_line_all = false
- self.embed_runtime = false
- self.make_executable = false
- self.interpreter = nil
- end
- end
-
- def initialize(states, params)
- @states = states
- @grammar = states.grammar
- @params = params
- end
-
- def generate_parser
- string_io = StringIO.new
-
- init_line_conversion_system
- @f = string_io
- parser_file
-
- string_io.rewind
- string_io.read
- end
-
- def generate_parser_file(destpath)
- init_line_conversion_system
- File.open(destpath, 'w') {|f|
- @f = f
- parser_file
- }
- File.chmod 0755, destpath if @params.make_executable?
- end
-
- private
-
- def parser_file
- shebang @params.interpreter if @params.make_executable?
- notice
- line
- if @params.embed_runtime?
- embed_library runtime_source()
- else
- require 'racc/parser.rb'
- end
- header
- parser_class(@params.classname, @params.superclass) {
- inner
- state_transition_table
- }
- footer
- end
-
- c = ::RbConfig::CONFIG
- RUBY_PATH = "#{c['bindir']}/#{c['ruby_install_name']}#{c['EXEEXT']}"
-
- def shebang(path)
- line '#!' + (path == 'ruby' ? RUBY_PATH : path)
- end
-
- def notice
- line %q[#]
- line %q[# DO NOT MODIFY!!!!]
- line %Q[# This file is automatically generated by Racc #{Racc::Version}]
- line %Q[# from Racc grammar file "#{@params.filename}".]
- line %q[#]
- end
-
- def runtime_source
- SourceText.new(::Racc::PARSER_TEXT, 'racc/parser.rb', 1)
- end
-
- def embed_library(src)
- line %[###### #{src.filename} begin]
- line %[unless $".index '#{src.filename}']
- line %[$".push '#{src.filename}']
- put src, @params.convert_line?
- line %[end]
- line %[###### #{src.filename} end]
- end
-
- def require(feature)
- line "require '#{feature}'"
- end
-
- def parser_class(classname, superclass)
- mods = classname.split('::')
- classid = mods.pop
- mods.each do |mod|
- indent; line "module #{mod}"
- cref_push mod
- end
- indent; line "class #{classid} < #{superclass}"
- cref_push classid
- yield
- cref_pop
- indent; line "end \# class #{classid}"
- mods.reverse_each do |mod|
- cref_pop
- indent; line "end \# module #{mod}"
- end
- end
-
- def header
- @params.header.each do |src|
- line
- put src, @params.convert_line_all?
- end
- end
-
- def inner
- @params.inner.each do |src|
- line
- put src, @params.convert_line?
- end
- end
-
- def footer
- @params.footer.each do |src|
- line
- put src, @params.convert_line_all?
- end
- end
-
- # Low Level Routines
-
- def put(src, convert_line = false)
- if convert_line
- replace_location(src) {
- @f.puts src.text
- }
- else
- @f.puts src.text
- end
- end
-
- def line(str = '')
- @f.puts str
- end
-
- def init_line_conversion_system
- @cref = []
- @used_separator = {}
- end
-
- def cref_push(name)
- @cref.push name
- end
-
- def cref_pop
- @cref.pop
- end
-
- def indent
- @f.print ' ' * @cref.size
- end
-
- def toplevel?
- @cref.empty?
- end
-
- def replace_location(src)
- sep = make_separator(src)
- @f.print 'self.class.' if toplevel?
- @f.puts "module_eval(<<'#{sep}', '#{src.filename}', #{src.lineno})"
- yield
- @f.puts sep
- end
-
- def make_separator(src)
- sep = unique_separator(src.filename)
- sep *= 2 while src.text.index(sep)
- sep
- end
-
- def unique_separator(id)
- sep = "...end #{id}/module_eval..."
- while @used_separator.key?(sep)
- sep.concat sprintf('%02x', rand(255))
- end
- @used_separator[sep] = true
- sep
- end
-
- #
- # State Transition Table Serialization
- #
-
- public
-
- def put_state_transition_table(f)
- @f = f
- state_transition_table
- end
-
- private
-
- def state_transition_table
- table = @states.state_transition_table
- table.use_result_var = @params.result_var?
- table.debug_parser = @params.debug_parser?
-
- line "##### State transition tables begin ###"
- line
- integer_list 'racc_action_table', table.action_table
- line
- integer_list 'racc_action_check', table.action_check
- line
- integer_list 'racc_action_pointer', table.action_pointer
- line
- integer_list 'racc_action_default', table.action_default
- line
- integer_list 'racc_goto_table', table.goto_table
- line
- integer_list 'racc_goto_check', table.goto_check
- line
- integer_list 'racc_goto_pointer', table.goto_pointer
- line
- integer_list 'racc_goto_default', table.goto_default
- line
- i_i_sym_list 'racc_reduce_table', table.reduce_table
- line
- line "racc_reduce_n = #{table.reduce_n}"
- line
- line "racc_shift_n = #{table.shift_n}"
- line
- sym_int_hash 'racc_token_table', table.token_table
- line
- line "racc_nt_base = #{table.nt_base}"
- line
- line "racc_use_result_var = #{table.use_result_var}"
- line
- @f.print(unindent_auto(<<-End))
- Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
- End
- line
- string_list 'Racc_token_to_s_table', table.token_to_s_table
- line
- line "Racc_debug_parser = #{table.debug_parser}"
- line
- line '##### State transition tables end #####'
- actions
- end
-
- def integer_list(name, table)
- if table.size > 2000
- serialize_integer_list_compressed name, table
- else
- serialize_integer_list_std name, table
- end
- end
-
- def serialize_integer_list_compressed(name, table)
- # TODO: this can be made a LOT more clean with a simple split/map
- sep = "\n"
- nsep = ",\n"
- buf = ''
- com = ''
- ncom = ','
- co = com
- @f.print 'clist = ['
- table.each do |i|
- buf << co << i.to_s; co = ncom
- if buf.size > 66
- @f.print sep; sep = nsep
- @f.print "'", buf, "'"
- buf = ''
- co = com
- end
- end
- unless buf.empty?
- @f.print sep
- @f.print "'", buf, "'"
- end
- line ' ]'
-
- @f.print(<<-End)
- #{name} = arr = ::Array.new(#{table.size}, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
- End
- end
-
- def serialize_integer_list_std(name, table)
- sep = ''
- line "#{name} = ["
- table.each_slice(10) do |ns|
- @f.print sep; sep = ",\n"
- @f.print ns.map {|n| sprintf('%6s', n ? n.to_s : 'nil') }.join(',')
- end
- line ' ]'
- end
-
- def i_i_sym_list(name, table)
- sep = ''
- line "#{name} = ["
- table.each_slice(3) do |len, target, mid|
- @f.print sep; sep = ",\n"
- @f.printf ' %d, %d, %s', len, target, mid.inspect
- end
- line " ]"
- end
-
- def sym_int_hash(name, h)
- sep = "\n"
- @f.print "#{name} = {"
- h.to_a.sort_by {|sym, i| i }.each do |sym, i|
- @f.print sep; sep = ",\n"
- @f.printf " %s => %d", sym.serialize, i
- end
- line " }"
- end
-
- def string_list(name, list)
- sep = " "
- line "#{name} = ["
- list.each do |s|
- @f.print sep; sep = ",\n "
- @f.print s.dump
- end
- line ' ]'
- end
-
- def actions
- @grammar.each do |rule|
- unless rule.action.source?
- raise "racc: fatal: cannot generate parser file when any action is a Proc"
- end
- end
-
- if @params.result_var?
- decl = ', result'
- retval = "\n result"
- default_body = ''
- else
- decl = ''
- retval = ''
- default_body = 'val[0]'
- end
- @grammar.each do |rule|
- line
- if rule.action.empty? and @params.omit_action_call?
- line "# reduce #{rule.ident} omitted"
- else
- src0 = rule.action.source || SourceText.new(default_body, __FILE__, 0)
- if @params.convert_line?
- src = remove_blank_lines(src0)
- delim = make_delimiter(src.text)
- @f.printf unindent_auto(<<-End),
- module_eval(<<'%s', '%s', %d)
- def _reduce_%d(val, _values%s)
- %s%s
- end
- %s
- End
- delim, src.filename, src.lineno - 1,
- rule.ident, decl,
- src.text, retval,
- delim
- else
- src = remove_blank_lines(src0)
- @f.printf unindent_auto(<<-End),
- def _reduce_%d(val, _values%s)
- %s%s
- end
- End
- rule.ident, decl,
- src.text, retval
- end
- end
- end
- line
- @f.printf unindent_auto(<<-'End'), decl
- def _reduce_none(val, _values%s)
- val[0]
- end
- End
- line
- end
-
- def remove_blank_lines(src)
- body = src.text.dup
- line = src.lineno
- while body.slice!(/\A[ \t\f]*(?:\n|\r\n|\r)/)
- line += 1
- end
- SourceText.new(body, src.filename, line)
- end
-
- def make_delimiter(body)
- delim = '.,.,'
- while body.index(delim)
- delim *= 2
- end
- delim
- end
-
- def unindent_auto(str)
- lines = str.lines.to_a
- n = minimum_indent(lines)
- lines.map {|line| detab(line).sub(indent_re(n), '').rstrip + "\n" }.join('')
- end
-
- def minimum_indent(lines)
- lines.map {|line| n_indent(line) }.min
- end
-
- def n_indent(line)
- line.slice(/\A\s+/).size
- end
-
- RE_CACHE = {}
-
- def indent_re(n)
- RE_CACHE[n] ||= /\A {#{n}}/
- end
-
- def detab(str, ts = 8)
- add = 0
- len = nil
- str.gsub(/\t/) {
- len = ts - ($`.size + add) % ts
- add += len - 1
- ' ' * len
- }
- end
-
- end
-
-end
diff --git a/lib/racc/pre-setup b/lib/racc/pre-setup
deleted file mode 100644
index 5027d865b7..0000000000
--- a/lib/racc/pre-setup
+++ /dev/null
@@ -1,13 +0,0 @@
-def generate_parser_text_rb(target)
- return if File.exist?(srcfile(target))
- $stderr.puts "generating #{target}..."
- File.open(target, 'w') {|f|
- f.puts "module Racc"
- f.puts " PARSER_TEXT = <<'__end_of_file__'"
- f.puts File.read(srcfile('parser.rb'))
- f.puts "__end_of_file__"
- f.puts "end"
- }
-end
-
-generate_parser_text_rb 'parser-text.rb'
diff --git a/lib/racc/racc.gemspec b/lib/racc/racc.gemspec
deleted file mode 100644
index 6beb16c5b4..0000000000
--- a/lib/racc/racc.gemspec
+++ /dev/null
@@ -1,105 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = "racc"
- s.version = "1.4.16"
- s.summary = "Racc is a LALR(1) parser generator"
- s.description = <<DESC
-Racc is a LALR(1) parser generator.
- It is written in Ruby itself, and generates Ruby program.
-
- NOTE: Ruby 1.8.x comes with Racc runtime module. You
- can run your parsers generated by racc 1.4.x out of the
- box.
-DESC
- s.authors = ["Minero Aoki", "Aaron Patterson"]
- s.email = [nil, "aaron@tenderlovemaking.com"]
- s.homepage = "http://i.loveruby.net/en/projects/racc/"
- s.licenses = ["MIT"]
- s.executables = ["racc", "racc2y", "y2racc"]
- s.files = [
- "COPYING", "ChangeLog", "DEPENDS", "Manifest.txt",
- "README.ja.rdoc", "README.rdoc", "Rakefile", "TODO", "bin/racc",
- "bin/racc2y", "bin/y2racc", "ext/racc/MANIFEST",
- "ext/racc/com/headius/racc/Cparse.java", "ext/racc/cparse.c",
- "ext/racc/depend", "ext/racc/extconf.rb", "fastcache/extconf.rb",
- "fastcache/fastcache.c", "lib/racc.rb", "lib/racc/compat.rb",
- "lib/racc/debugflags.rb", "lib/racc/exception.rb",
- "lib/racc/grammar.rb", "lib/racc/grammarfileparser.rb",
- "lib/racc/info.rb", "lib/racc/iset.rb",
- "lib/racc/logfilegenerator.rb", "lib/racc/parser-text.rb",
- "lib/racc/parser.rb", "lib/racc/parserfilegenerator.rb",
- "lib/racc/pre-setup", "lib/racc/sourcetext.rb",
- "lib/racc/state.rb", "lib/racc/statetransitiontable.rb",
- "lib/racc/static.rb", "misc/dist.sh", "rdoc/en/NEWS.en.rdoc",
- "rdoc/en/grammar.en.rdoc", "rdoc/ja/NEWS.ja.rdoc",
- "rdoc/ja/command.ja.html", "rdoc/ja/debug.ja.rdoc",
- "rdoc/ja/grammar.ja.rdoc", "rdoc/ja/index.ja.html",
- "rdoc/ja/parser.ja.rdoc", "rdoc/ja/usage.ja.html",
- "sample/array.y", "sample/array2.y", "sample/calc-ja.y",
- "sample/calc.y", "sample/conflict.y", "sample/hash.y",
- "sample/lalr.y", "sample/lists.y", "sample/syntax.y",
- "sample/yyerr.y", "setup.rb", "tasks/doc.rb", "tasks/email.rb",
- "test/assets/cadenza.y", "test/assets/cast.y",
- "test/assets/chk.y", "test/assets/conf.y",
- "test/assets/csspool.y", "test/assets/digraph.y",
- "test/assets/echk.y", "test/assets/edtf.y", "test/assets/err.y",
- "test/assets/error_recovery.y", "test/assets/expect.y",
- "test/assets/firstline.y", "test/assets/huia.y",
- "test/assets/ichk.y", "test/assets/intp.y",
- "test/assets/journey.y", "test/assets/liquor.y",
- "test/assets/machete.y", "test/assets/macruby.y",
- "test/assets/mailp.y", "test/assets/mediacloth.y",
- "test/assets/mof.y", "test/assets/namae.y", "test/assets/nasl.y",
- "test/assets/newsyn.y", "test/assets/noend.y",
- "test/assets/nokogiri-css.y", "test/assets/nonass.y",
- "test/assets/normal.y", "test/assets/norule.y",
- "test/assets/nullbug1.y", "test/assets/nullbug2.y",
- "test/assets/opal.y", "test/assets/opt.y",
- "test/assets/percent.y", "test/assets/php_serialization.y",
- "test/assets/recv.y", "test/assets/riml.y",
- "test/assets/rrconf.y", "test/assets/ruby18.y",
- "test/assets/ruby19.y", "test/assets/ruby20.y",
- "test/assets/ruby21.y", "test/assets/ruby22.y",
- "test/assets/scan.y", "test/assets/syntax.y",
- "test/assets/tp_plus.y", "test/assets/twowaysql.y",
- "test/assets/unterm.y", "test/assets/useless.y",
- "test/assets/yyerr.y", "test/bench.y", "test/helper.rb",
- "test/infini.y", "test/regress/cadenza", "test/regress/cast",
- "test/regress/csspool", "test/regress/edtf", "test/regress/huia",
- "test/regress/journey", "test/regress/liquor",
- "test/regress/machete", "test/regress/mediacloth",
- "test/regress/mof", "test/regress/namae", "test/regress/nasl",
- "test/regress/nokogiri-css", "test/regress/opal",
- "test/regress/php_serialization", "test/regress/riml",
- "test/regress/ruby18", "test/regress/ruby22",
- "test/regress/tp_plus", "test/regress/twowaysql",
- "test/scandata/brace", "test/scandata/gvar",
- "test/scandata/normal", "test/scandata/percent",
- "test/scandata/slash", "test/src.intp", "test/start.y",
- "test/test_chk_y.rb", "test/test_grammar_file_parser.rb",
- "test/test_racc_command.rb", "test/test_scan_y.rb",
- "test/testscanner.rb", "web/racc.en.rhtml", "web/racc.ja.rhtml"
- ]
- s.require_paths = ["lib"]
- s.rubygems_version = "3.1.0.pre1"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.extensions = ["ext/racc/extconf.rb"]
- s.rdoc_options = ["--main", "README.rdoc"]
- s.extra_rdoc_files = [
- "Manifest.txt", "README.ja.rdoc", "README.rdoc",
- "rdoc/en/NEWS.en.rdoc", "rdoc/en/grammar.en.rdoc",
- "rdoc/ja/NEWS.ja.rdoc", "rdoc/ja/debug.ja.rdoc",
- "rdoc/ja/grammar.ja.rdoc", "rdoc/ja/parser.ja.rdoc",
- "README.ja.rdoc", "README.rdoc"
- ]
-
- if RUBY_PLATFORM =~ /java/
- s.files << 'lib/racc/cparse-jruby.jar'
- end
-
- s.add_development_dependency("rake-compiler", [">= 0.4.1"])
- s.add_development_dependency("minitest", ["~> 4.7"])
- s.add_development_dependency("rdoc", [">= 4.0", "< 7"])
- s.add_development_dependency("hoe", ["~> 3.18"])
-end
diff --git a/lib/racc/sourcetext.rb b/lib/racc/sourcetext.rb
deleted file mode 100644
index b33ba29291..0000000000
--- a/lib/racc/sourcetext.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# $Id: 3b2d89d9ada2f5fcb043837dcc5c9631856d5b70 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of LGPL, see the file "COPYING".
-#
-
-module Racc
-
- class SourceText
- def initialize(text, filename, lineno)
- @text = text
- @filename = filename
- @lineno = lineno
- end
-
- attr_reader :text
- attr_reader :filename
- attr_reader :lineno
-
- def to_s
- "#<SourceText #{location()}>"
- end
-
- def location
- "#{@filename}:#{@lineno}"
- end
- end
-
-end
diff --git a/lib/racc/state.rb b/lib/racc/state.rb
deleted file mode 100644
index 51b1d83664..0000000000
--- a/lib/racc/state.rb
+++ /dev/null
@@ -1,969 +0,0 @@
-#
-# $Id: 6bd3136439c94cb8d928917f5e0de9c593181527 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-
-require 'racc/iset'
-require 'racc/statetransitiontable'
-require 'racc/exception'
-require 'forwardable'
-
-module Racc
-
- # A table of LALR states.
- class States
-
- include Enumerable
-
- def initialize(grammar, debug_flags = DebugFlags.new)
- @grammar = grammar
- @symboltable = grammar.symboltable
- @d_state = debug_flags.state
- @d_la = debug_flags.la
- @d_prec = debug_flags.prec
- @states = []
- @statecache = {}
- @actions = ActionTable.new(@grammar, self)
- @nfa_computed = false
- @dfa_computed = false
- end
-
- attr_reader :grammar
- attr_reader :actions
-
- def size
- @states.size
- end
-
- def inspect
- '#<state table>'
- end
-
- alias to_s inspect
-
- def [](i)
- @states[i]
- end
-
- def each_state(&block)
- @states.each(&block)
- end
-
- alias each each_state
-
- def each_index(&block)
- @states.each_index(&block)
- end
-
- extend Forwardable
-
- def_delegator "@actions", :shift_n
- def_delegator "@actions", :reduce_n
- def_delegator "@actions", :nt_base
-
- def should_report_srconflict?
- srconflict_exist? and
- (n_srconflicts() != @grammar.n_expected_srconflicts)
- end
-
- def srconflict_exist?
- n_srconflicts() != 0
- end
-
- def n_srconflicts
- @n_srconflicts ||= inject(0) {|sum, st| sum + st.n_srconflicts }
- end
-
- def rrconflict_exist?
- n_rrconflicts() != 0
- end
-
- def n_rrconflicts
- @n_rrconflicts ||= inject(0) {|sum, st| sum + st.n_rrconflicts }
- end
-
- def state_transition_table
- @state_transition_table ||= StateTransitionTable.generate(self.dfa)
- end
-
- #
- # NFA (Non-deterministic Finite Automaton) Computation
- #
-
- public
-
- def nfa
- return self if @nfa_computed
- compute_nfa
- @nfa_computed = true
- self
- end
-
- private
-
- def compute_nfa
- @grammar.init
- # add state 0
- core_to_state [ @grammar[0].ptrs[0] ]
- # generate LALR states
- cur = 0
- @gotos = []
- while cur < @states.size
- generate_states @states[cur] # state is added here
- cur += 1
- end
- @actions.init
- end
-
- def generate_states(state)
- puts "dstate: #{state}" if @d_state
-
- table = {}
- state.closure.each do |ptr|
- if sym = ptr.dereference
- addsym table, sym, ptr.next
- end
- end
- table.each do |sym, core|
- puts "dstate: sym=#{sym} ncore=#{core}" if @d_state
-
- dest = core_to_state(core.to_a)
- state.goto_table[sym] = dest
- id = sym.nonterminal?() ? @gotos.size : nil
- g = Goto.new(id, sym, state, dest)
- @gotos.push g if sym.nonterminal?
- state.gotos[sym] = g
- puts "dstate: #{state.ident} --#{sym}--> #{dest.ident}" if @d_state
-
- # check infinite recursion
- if state.ident == dest.ident and state.closure.size == 1
- raise CompileError,
- sprintf("Infinite recursion: state %d, with rule %d",
- state.ident, state.ptrs[0].rule.ident)
- end
- end
- end
-
- def addsym(table, sym, ptr)
- unless s = table[sym]
- table[sym] = s = ISet.new
- end
- s.add ptr
- end
-
- def core_to_state(core)
- #
- # convert CORE to a State object.
- # If matching state does not exist, create it and add to the table.
- #
-
- k = fingerprint(core)
- unless dest = @statecache[k]
- # not registered yet
- dest = State.new(@states.size, core)
- @states.push dest
-
- @statecache[k] = dest
-
- puts "core_to_state: create state ID #{dest.ident}" if @d_state
- else
- if @d_state
- puts "core_to_state: dest is cached ID #{dest.ident}"
- puts "core_to_state: dest core #{dest.core.join(' ')}"
- end
- end
-
- dest
- end
-
- def fingerprint(arr)
- arr.map {|i| i.ident }.pack('L*')
- end
-
- #
- # DFA (Deterministic Finite Automaton) Generation
- #
-
- public
-
- def dfa
- return self if @dfa_computed
- nfa
- compute_dfa
- @dfa_computed = true
- self
- end
-
- private
-
- def compute_dfa
- la = lookahead()
- @states.each do |state|
- state.la = la
- resolve state
- end
- set_accept
- @states.each do |state|
- pack state
- end
- check_useless
- end
-
- def lookahead
- #
- # lookahead algorithm ver.3 -- from bison 1.26
- #
-
- gotos = @gotos
- if @d_la
- puts "\n--- goto ---"
- gotos.each_with_index {|g, i| print i, ' '; p g }
- end
-
- ### initialize_LA()
- ### set_goto_map()
- la_rules = []
- @states.each do |state|
- state.check_la la_rules
- end
-
- ### initialize_F()
- f = create_tmap(gotos.size)
- reads = []
- edge = []
- gotos.each do |goto|
- goto.to_state.goto_table.each do |t, st|
- if t.terminal?
- f[goto.ident] |= (1 << t.ident)
- elsif t.nullable?
- edge.push goto.to_state.gotos[t].ident
- end
- end
- if edge.empty?
- reads.push nil
- else
- reads.push edge
- edge = []
- end
- end
- digraph f, reads
- if @d_la
- puts "\n--- F1 (reads) ---"
- print_tab gotos, reads, f
- end
-
- ### build_relations()
- ### compute_FOLLOWS
- path = nil
- edge = []
- lookback = Array.new(la_rules.size, nil)
- includes = []
- gotos.each do |goto|
- goto.symbol.heads.each do |ptr|
- path = record_path(goto.from_state, ptr.rule)
- lastgoto = path.last
- st = lastgoto ? lastgoto.to_state : goto.from_state
- if st.conflict?
- addrel lookback, st.rruleid(ptr.rule), goto
- end
- path.reverse_each do |g|
- break if g.symbol.terminal?
- edge.push g.ident
- break unless g.symbol.nullable?
- end
- end
- if edge.empty?
- includes.push nil
- else
- includes.push edge
- edge = []
- end
- end
- includes = transpose(includes)
- digraph f, includes
- if @d_la
- puts "\n--- F2 (includes) ---"
- print_tab gotos, includes, f
- end
-
- ### compute_lookaheads
- la = create_tmap(la_rules.size)
- lookback.each_with_index do |arr, i|
- if arr
- arr.each do |g|
- la[i] |= f[g.ident]
- end
- end
- end
- if @d_la
- puts "\n--- LA (lookback) ---"
- print_tab la_rules, lookback, la
- end
-
- la
- end
-
- def create_tmap(size)
- Array.new(size, 0) # use Integer as bitmap
- end
-
- def addrel(tbl, i, item)
- if a = tbl[i]
- a.push item
- else
- tbl[i] = [item]
- end
- end
-
- def record_path(begst, rule)
- st = begst
- path = []
- rule.symbols.each do |t|
- goto = st.gotos[t]
- path.push goto
- st = goto.to_state
- end
- path
- end
-
- def transpose(rel)
- new = Array.new(rel.size, nil)
- rel.each_with_index do |arr, idx|
- if arr
- arr.each do |i|
- addrel new, i, idx
- end
- end
- end
- new
- end
-
- def digraph(map, relation)
- n = relation.size
- index = Array.new(n, nil)
- vertices = []
- @infinity = n + 2
-
- index.each_index do |i|
- if not index[i] and relation[i]
- traverse i, index, vertices, map, relation
- end
- end
- end
-
- def traverse(i, index, vertices, map, relation)
- vertices.push i
- index[i] = height = vertices.size
-
- if rp = relation[i]
- rp.each do |proci|
- unless index[proci]
- traverse proci, index, vertices, map, relation
- end
- if index[i] > index[proci]
- # circulative recursion !!!
- index[i] = index[proci]
- end
- map[i] |= map[proci]
- end
- end
-
- if index[i] == height
- while true
- proci = vertices.pop
- index[proci] = @infinity
- break if i == proci
-
- map[proci] |= map[i]
- end
- end
- end
-
- # for debug
- def print_atab(idx, tab)
- tab.each_with_index do |i,ii|
- printf '%-20s', idx[ii].inspect
- p i
- end
- end
-
- def print_tab(idx, rel, tab)
- tab.each_with_index do |bin,i|
- print i, ' ', idx[i].inspect, ' << '; p rel[i]
- print ' '
- each_t(@symboltable, bin) {|t| print ' ', t }
- puts
- end
- end
-
- # for debug
- def print_tab_i(idx, rel, tab, i)
- bin = tab[i]
- print i, ' ', idx[i].inspect, ' << '; p rel[i]
- print ' '
- each_t(@symboltable, bin) {|t| print ' ', t }
- end
-
- # for debug
- def printb(i)
- each_t(@symboltable, i) do |t|
- print t, ' '
- end
- puts
- end
-
- def each_t(tbl, set)
- 0.upto( set.size ) do |i|
- (0..7).each do |ii|
- if set[idx = i * 8 + ii] == 1
- yield tbl[idx]
- end
- end
- end
- end
-
- #
- # resolve
- #
-
- def resolve(state)
- if state.conflict?
- resolve_rr state, state.ritems
- resolve_sr state, state.stokens
- else
- if state.rrules.empty?
- # shift
- state.stokens.each do |t|
- state.action[t] = @actions.shift(state.goto_table[t])
- end
- else
- # reduce
- state.defact = @actions.reduce(state.rrules[0])
- end
- end
- end
-
- def resolve_rr(state, r)
- r.each do |item|
- item.each_la(@symboltable) do |t|
- act = state.action[t]
- if act
- unless act.kind_of?(Reduce)
- raise "racc: fatal: #{act.class} in action table"
- end
- # Cannot resolve R/R conflict (on t).
- # Reduce with upper rule as default.
- state.rr_conflict act.rule, item.rule, t
- else
- # No conflict.
- state.action[t] = @actions.reduce(item.rule)
- end
- end
- end
- end
-
- def resolve_sr(state, s)
- s.each do |stok|
- goto = state.goto_table[stok]
- act = state.action[stok]
-
- unless act
- # no conflict
- state.action[stok] = @actions.shift(goto)
- else
- unless act.kind_of?(Reduce)
- puts 'DEBUG -------------------------------'
- p stok
- p act
- state.action.each do |k,v|
- print k.inspect, ' ', v.inspect, "\n"
- end
- raise "racc: fatal: #{act.class} in action table"
- end
-
- # conflict on stok
-
- rtok = act.rule.precedence
- case do_resolve_sr(stok, rtok)
- when :Reduce
- # action is already set
-
- when :Shift
- # overwrite
- act.decref
- state.action[stok] = @actions.shift(goto)
-
- when :Error
- act.decref
- state.action[stok] = @actions.error
-
- when :CantResolve
- # shift as default
- act.decref
- state.action[stok] = @actions.shift(goto)
- state.sr_conflict stok, act.rule
- end
- end
- end
- end
-
- ASSOC = {
- :Left => :Reduce,
- :Right => :Shift,
- :Nonassoc => :Error
- }
-
- def do_resolve_sr(stok, rtok)
- puts "resolve_sr: s/r conflict: rtok=#{rtok}, stok=#{stok}" if @d_prec
-
- unless rtok and rtok.precedence
- puts "resolve_sr: no prec for #{rtok}(R)" if @d_prec
- return :CantResolve
- end
- rprec = rtok.precedence
-
- unless stok and stok.precedence
- puts "resolve_sr: no prec for #{stok}(S)" if @d_prec
- return :CantResolve
- end
- sprec = stok.precedence
-
- ret = if rprec == sprec
- ASSOC[rtok.assoc] or
- raise "racc: fatal: #{rtok}.assoc is not Left/Right/Nonassoc"
- else
- (rprec > sprec) ? (:Reduce) : (:Shift)
- end
-
- puts "resolve_sr: resolved as #{ret.id2name}" if @d_prec
- ret
- end
-
- #
- # complete
- #
-
- def set_accept
- anch = @symboltable.anchor
- init_state = @states[0].goto_table[@grammar.start]
- targ_state = init_state.action[anch].goto_state
- acc_state = targ_state.action[anch].goto_state
-
- acc_state.action.clear
- acc_state.goto_table.clear
- acc_state.defact = @actions.accept
- end
-
- def pack(state)
- ### find most frequently used reduce rule
- act = state.action
- arr = Array.new(@grammar.size, 0)
- act.each do |t, a|
- arr[a.ruleid] += 1 if a.kind_of?(Reduce)
- end
- i = arr.max
- s = (i > 0) ? arr.index(i) : nil
-
- ### set & delete default action
- if s
- r = @actions.reduce(s)
- if not state.defact or state.defact == r
- act.delete_if {|t, a| a == r }
- state.defact = r
- end
- else
- state.defact ||= @actions.error
- end
- end
-
- def check_useless
- used = []
- @actions.each_reduce do |act|
- if not act or act.refn == 0
- act.rule.useless = true
- else
- t = act.rule.target
- used[t.ident] = t
- end
- end
- @symboltable.nt_base.upto(@symboltable.nt_max - 1) do |n|
- unless used[n]
- @symboltable[n].useless = true
- end
- end
- end
-
- end # class StateTable
-
-
- # A LALR state.
- class State
-
- def initialize(ident, core)
- @ident = ident
- @core = core
- @goto_table = {}
- @gotos = {}
- @stokens = nil
- @ritems = nil
- @action = {}
- @defact = nil
- @rrconf = nil
- @srconf = nil
-
- @closure = make_closure(@core)
- end
-
- attr_reader :ident
- alias stateid ident
- alias hash ident
-
- attr_reader :core
- attr_reader :closure
-
- attr_reader :goto_table
- attr_reader :gotos
-
- attr_reader :stokens
- attr_reader :ritems
- attr_reader :rrules
-
- attr_reader :action
- attr_accessor :defact # default action
-
- attr_reader :rrconf
- attr_reader :srconf
-
- def inspect
- "<state #{@ident}>"
- end
-
- alias to_s inspect
-
- def ==(oth)
- @ident == oth.ident
- end
-
- alias eql? ==
-
- def make_closure(core)
- set = ISet.new
- core.each do |ptr|
- set.add ptr
- if t = ptr.dereference and t.nonterminal?
- set.update_a t.expand
- end
- end
- set.to_a
- end
-
- def check_la(la_rules)
- @conflict = false
- s = []
- r = []
- @closure.each do |ptr|
- if t = ptr.dereference
- if t.terminal?
- s[t.ident] = t
- if t.ident == 1 # $error
- @conflict = true
- end
- end
- else
- r.push ptr.rule
- end
- end
- unless r.empty?
- if not s.empty? or r.size > 1
- @conflict = true
- end
- end
- s.compact!
- @stokens = s
- @rrules = r
-
- if @conflict
- @la_rules_i = la_rules.size
- @la_rules = r.map {|i| i.ident }
- la_rules.concat r
- else
- @la_rules_i = @la_rules = nil
- end
- end
-
- def conflict?
- @conflict
- end
-
- def rruleid(rule)
- if i = @la_rules.index(rule.ident)
- @la_rules_i + i
- else
- puts '/// rruleid'
- p self
- p rule
- p @rrules
- p @la_rules_i
- raise 'racc: fatal: cannot get reduce rule id'
- end
- end
-
- def la=(la)
- return unless @conflict
- i = @la_rules_i
- @ritems = r = []
- @rrules.each do |rule|
- r.push Item.new(rule, la[i])
- i += 1
- end
- end
-
- def rr_conflict(high, low, ctok)
- c = RRconflict.new(@ident, high, low, ctok)
-
- @rrconf ||= {}
- if a = @rrconf[ctok]
- a.push c
- else
- @rrconf[ctok] = [c]
- end
- end
-
- def sr_conflict(shift, reduce)
- c = SRconflict.new(@ident, shift, reduce)
-
- @srconf ||= {}
- if a = @srconf[shift]
- a.push c
- else
- @srconf[shift] = [c]
- end
- end
-
- def n_srconflicts
- @srconf ? @srconf.size : 0
- end
-
- def n_rrconflicts
- @rrconf ? @rrconf.size : 0
- end
-
- end # class State
-
-
- #
- # Represents a transition on the grammar.
- # "Real goto" means a transition by nonterminal,
- # but this class treats also terminal's.
- # If one is a terminal transition, .ident returns nil.
- #
- class Goto
- def initialize(ident, sym, from, to)
- @ident = ident
- @symbol = sym
- @from_state = from
- @to_state = to
- end
-
- attr_reader :ident
- attr_reader :symbol
- attr_reader :from_state
- attr_reader :to_state
-
- def inspect
- "(#{@from_state.ident}-#{@symbol}->#{@to_state.ident})"
- end
- end
-
-
- # LALR item. A set of rule and its lookahead tokens.
- class Item
- def initialize(rule, la)
- @rule = rule
- @la = la
- end
-
- attr_reader :rule
- attr_reader :la
-
- def each_la(tbl)
- la = @la
- 0.upto(la.size - 1) do |i|
- (0..7).each do |ii|
- if la[idx = i * 8 + ii] == 1
- yield tbl[idx]
- end
- end
- end
- end
- end
-
-
- # The table of LALR actions. Actions are either of
- # Shift, Reduce, Accept and Error.
- class ActionTable
-
- def initialize(rt, st)
- @grammar = rt
- @statetable = st
-
- @reduce = []
- @shift = []
- @accept = nil
- @error = nil
- end
-
- def init
- @grammar.each do |rule|
- @reduce.push Reduce.new(rule)
- end
- @statetable.each do |state|
- @shift.push Shift.new(state)
- end
- @accept = Accept.new
- @error = Error.new
- end
-
- def reduce_n
- @reduce.size
- end
-
- def reduce(i)
- case i
- when Rule then i = i.ident
- when Integer then ;
- else
- raise "racc: fatal: wrong class #{i.class} for reduce"
- end
-
- r = @reduce[i] or raise "racc: fatal: reduce action #{i.inspect} not exist"
- r.incref
- r
- end
-
- def each_reduce(&block)
- @reduce.each(&block)
- end
-
- def shift_n
- @shift.size
- end
-
- def shift(i)
- case i
- when State then i = i.ident
- when Integer then ;
- else
- raise "racc: fatal: wrong class #{i.class} for shift"
- end
-
- @shift[i] or raise "racc: fatal: shift action #{i} does not exist"
- end
-
- def each_shift(&block)
- @shift.each(&block)
- end
-
- attr_reader :accept
- attr_reader :error
-
- end
-
-
- class Shift
- def initialize(goto)
- @goto_state = goto
- end
-
- attr_reader :goto_state
-
- def goto_id
- @goto_state.ident
- end
-
- def inspect
- "<shift #{@goto_state.ident}>"
- end
- end
-
-
- class Reduce
- def initialize(rule)
- @rule = rule
- @refn = 0
- end
-
- attr_reader :rule
- attr_reader :refn
-
- def ruleid
- @rule.ident
- end
-
- def inspect
- "<reduce #{@rule.ident}>"
- end
-
- def incref
- @refn += 1
- end
-
- def decref
- @refn -= 1
- raise 'racc: fatal: act.refn < 0' if @refn < 0
- end
- end
-
- class Accept
- def inspect
- "<accept>"
- end
- end
-
- class Error
- def inspect
- "<error>"
- end
- end
-
- class SRconflict
- def initialize(sid, shift, reduce)
- @stateid = sid
- @shift = shift
- @reduce = reduce
- end
-
- attr_reader :stateid
- attr_reader :shift
- attr_reader :reduce
-
- def to_s
- sprintf('state %d: S/R conflict rule %d reduce and shift %s',
- @stateid, @reduce.ruleid, @shift.to_s)
- end
- end
-
- class RRconflict
- def initialize(sid, high, low, tok)
- @stateid = sid
- @high_prec = high
- @low_prec = low
- @token = tok
- end
-
- attr_reader :stateid
- attr_reader :high_prec
- attr_reader :low_prec
- attr_reader :token
-
- def to_s
- sprintf('state %d: R/R conflict with rule %d and %d on %s',
- @stateid, @high_prec.ident, @low_prec.ident, @token.to_s)
- end
- end
-
-end
diff --git a/lib/racc/statetransitiontable.rb b/lib/racc/statetransitiontable.rb
deleted file mode 100644
index 23df4102ec..0000000000
--- a/lib/racc/statetransitiontable.rb
+++ /dev/null
@@ -1,316 +0,0 @@
-#
-# $Id: 4c5f4311663b6d03050953d64d6a0e7905ff2216 $
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of LGPL, see the file "COPYING".
-#
-
-require 'racc/parser'
-
-unless Object.method_defined?(:funcall)
- class Object
- alias funcall __send__
- end
-end
-
-module Racc
-
- StateTransitionTable = Struct.new(:action_table,
- :action_check,
- :action_default,
- :action_pointer,
- :goto_table,
- :goto_check,
- :goto_default,
- :goto_pointer,
- :token_table,
- :reduce_table,
- :reduce_n,
- :shift_n,
- :nt_base,
- :token_to_s_table,
- :use_result_var,
- :debug_parser)
- class StateTransitionTable # reopen
- def StateTransitionTable.generate(states)
- StateTransitionTableGenerator.new(states).generate
- end
-
- def initialize(states)
- super()
- @states = states
- @grammar = states.grammar
- self.use_result_var = true
- self.debug_parser = true
- end
-
- attr_reader :states
- attr_reader :grammar
-
- def parser_class
- ParserClassGenerator.new(@states).generate
- end
-
- def token_value_table
- h = {}
- token_table().each do |sym, i|
- h[sym.value] = i
- end
- h
- end
- end
-
-
- class StateTransitionTableGenerator
-
- def initialize(states)
- @states = states
- @grammar = states.grammar
- end
-
- def generate
- t = StateTransitionTable.new(@states)
- gen_action_tables t, @states
- gen_goto_tables t, @grammar
- t.token_table = token_table(@grammar)
- t.reduce_table = reduce_table(@grammar)
- t.reduce_n = @states.reduce_n
- t.shift_n = @states.shift_n
- t.nt_base = @grammar.nonterminal_base
- t.token_to_s_table = @grammar.symbols.map {|sym| sym.to_s }
- t
- end
-
- def reduce_table(grammar)
- t = [0, 0, :racc_error]
- grammar.each_with_index do |rule, idx|
- next if idx == 0
- t.push rule.size
- t.push rule.target.ident
- t.push(if rule.action.empty? # and @params.omit_action_call?
- then :_reduce_none
- else "_reduce_#{idx}".intern
- end)
- end
- t
- end
-
- def token_table(grammar)
- h = {}
- grammar.symboltable.terminals.each do |t|
- h[t] = t.ident
- end
- h
- end
-
- def gen_action_tables(t, states)
- t.action_table = yytable = []
- t.action_check = yycheck = []
- t.action_default = yydefact = []
- t.action_pointer = yypact = []
- e1 = []
- e2 = []
- states.each do |state|
- yydefact.push act2actid(state.defact)
- if state.action.empty?
- yypact.push nil
- next
- end
- vector = []
- state.action.each do |tok, act|
- vector[tok.ident] = act2actid(act)
- end
- addent e1, vector, state.ident, yypact
- end
- set_table e1, e2, yytable, yycheck, yypact
- end
-
- def gen_goto_tables(t, grammar)
- t.goto_table = yytable2 = []
- t.goto_check = yycheck2 = []
- t.goto_pointer = yypgoto = []
- t.goto_default = yydefgoto = []
- e1 = []
- e2 = []
- grammar.each_nonterminal do |tok|
- tmp = []
-
- # decide default
- freq = Array.new(@states.size, 0)
- @states.each do |state|
- st = state.goto_table[tok]
- if st
- st = st.ident
- freq[st] += 1
- end
- tmp[state.ident] = st
- end
- max = freq.max
- if max > 1
- default = freq.index(max)
- tmp.map! {|i| default == i ? nil : i }
- else
- default = nil
- end
- yydefgoto.push default
-
- # delete default value
- tmp.pop until tmp.last or tmp.empty?
- if tmp.compact.empty?
- # only default
- yypgoto.push nil
- next
- end
-
- addent e1, tmp, (tok.ident - grammar.nonterminal_base), yypgoto
- end
- set_table e1, e2, yytable2, yycheck2, yypgoto
- end
-
- def addent(all, arr, chkval, ptr)
- max = arr.size
- min = nil
- arr.each_with_index do |item, idx|
- if item
- min ||= idx
- end
- end
- ptr.push(-7777) # mark
- arr = arr[min...max]
- all.push [arr, chkval, mkmapexp(arr), min, ptr.size - 1]
- end
-
- n = 2 ** 16
- begin
- Regexp.compile("a{#{n}}")
- RE_DUP_MAX = n
- rescue RegexpError
- n /= 2
- retry
- end
-
- def mkmapexp(arr)
- i = ii = 0
- as = arr.size
- map = ''
- maxdup = RE_DUP_MAX
- curr = nil
- while i < as
- ii = i + 1
- if arr[i]
- ii += 1 while ii < as and arr[ii]
- curr = '-'
- else
- ii += 1 while ii < as and not arr[ii]
- curr = '.'
- end
-
- offset = ii - i
- if offset == 1
- map << curr
- else
- while offset > maxdup
- map << "#{curr}{#{maxdup}}"
- offset -= maxdup
- end
- map << "#{curr}{#{offset}}" if offset > 1
- end
- i = ii
- end
- Regexp.compile(map, 'n')
- end
-
- def set_table(entries, dummy, tbl, chk, ptr)
- upper = 0
- map = '-' * 10240
-
- # sort long to short
- entries.sort! {|a,b| b[0].size <=> a[0].size }
-
- entries.each do |arr, chkval, expr, min, ptri|
- if upper + arr.size > map.size
- map << '-' * (arr.size + 1024)
- end
- idx = map.index(expr)
- ptr[ptri] = idx - min
- arr.each_with_index do |item, i|
- if item
- i += idx
- tbl[i] = item
- chk[i] = chkval
- map[i] = ?o
- end
- end
- upper = idx + arr.size
- end
- end
-
- def act2actid(act)
- case act
- when Shift then act.goto_id
- when Reduce then -act.ruleid
- when Accept then @states.shift_n
- when Error then @states.reduce_n * -1
- else
- raise "racc: fatal: wrong act type #{act.class} in action table"
- end
- end
-
- end
-
-
- class ParserClassGenerator
-
- def initialize(states)
- @states = states
- @grammar = states.grammar
- end
-
- def generate
- table = @states.state_transition_table
- c = Class.new(::Racc::Parser)
- c.const_set :Racc_arg, [table.action_table,
- table.action_check,
- table.action_default,
- table.action_pointer,
- table.goto_table,
- table.goto_check,
- table.goto_default,
- table.goto_pointer,
- table.nt_base,
- table.reduce_table,
- table.token_value_table,
- table.shift_n,
- table.reduce_n,
- false]
- c.const_set :Racc_token_to_s_table, table.token_to_s_table
- c.const_set :Racc_debug_parser, true
- define_actions c
- c
- end
-
- private
-
- def define_actions(c)
- c.module_eval "def _reduce_none(vals, vstack) vals[0] end"
- @grammar.each do |rule|
- if rule.action.empty?
- c.funcall(:alias_method, "_reduce_#{rule.ident}", :_reduce_none)
- else
- c.funcall(:define_method, "_racc_action_#{rule.ident}", &rule.action.proc)
- c.module_eval(<<-End, __FILE__, __LINE__ + 1)
- def _reduce_#{rule.ident}(vals, vstack)
- _racc_action_#{rule.ident}(*vals)
- end
- End
- end
- end
- end
-
- end
-
-end # module Racc
diff --git a/lib/racc/static.rb b/lib/racc/static.rb
deleted file mode 100644
index bebbeb5aa6..0000000000
--- a/lib/racc/static.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'racc'
-require 'racc/parser'
-require 'racc/grammarfileparser'
-require 'racc/parserfilegenerator'
-require 'racc/logfilegenerator'
diff --git a/lib/rdoc.rb b/lib/rdoc.rb
index fc8ad9e144..32c7e72f25 100644
--- a/lib/rdoc.rb
+++ b/lib/rdoc.rb
@@ -62,7 +62,10 @@ module RDoc
class Error < RuntimeError; end
- require 'rdoc/version'
+ ##
+ # RDoc version you are using
+
+ VERSION = '6.0.1.1'
##
# Method visibilities
@@ -122,6 +125,8 @@ module RDoc
autoload :RDoc, 'rdoc/rdoc'
+ autoload :TestCase, 'rdoc/test_case'
+
autoload :CrossReference, 'rdoc/cross_reference'
autoload :ERBIO, 'rdoc/erbio'
autoload :ERBPartial, 'rdoc/erb_partial'
@@ -143,11 +148,12 @@ module RDoc
autoload :KNOWN_CLASSES, 'rdoc/known_classes'
+ autoload :RipperStateLex, 'rdoc/parser/ripper_state_lex'
autoload :TokenStream, 'rdoc/token_stream'
autoload :Comment, 'rdoc/comment'
- require 'rdoc/i18n'
+ autoload :I18n, 'rdoc/i18n'
# code objects
#
diff --git a/lib/rdoc/.document b/lib/rdoc/.document
index 6b5e1b21a5..41333c6411 100644
--- a/lib/rdoc/.document
+++ b/lib/rdoc/.document
@@ -1,2 +1 @@
*.rb
-parser
diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb
index 7609080fbf..fdd56e236b 100644
--- a/lib/rdoc/class_module.rb
+++ b/lib/rdoc/class_module.rb
@@ -210,7 +210,7 @@ class RDoc::ClassModule < RDoc::Context
normalize_comment comment
end
- comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty?
+ comment = "#{@comment}\n---\n#{comment}" unless @comment.empty?
super comment
end
diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb
index 9e90999eac..134f6440a0 100644
--- a/lib/rdoc/comment.rb
+++ b/lib/rdoc/comment.rb
@@ -24,11 +24,6 @@ class RDoc::Comment
attr_accessor :location
##
- # Line where this Comment was written
-
- attr_accessor :line
-
- ##
# For duck-typing when merging classes at load time
alias file location # :nodoc:
@@ -39,11 +34,6 @@ class RDoc::Comment
attr_reader :text
##
- # Alias for text
-
- alias to_s text
-
- ##
# Overrides the content returned by #parse. Use when there is no #text
# source for this comment
@@ -53,10 +43,9 @@ class RDoc::Comment
# Creates a new comment with +text+ that is found in the RDoc::TopLevel
# +location+.
- def initialize text = nil, location = nil, language = nil
+ def initialize text = nil, location = nil
@location = location
@text = text.nil? ? nil : text.dup
- @language = language
@document = nil
@format = 'rdoc'
diff --git a/lib/rdoc/context.rb b/lib/rdoc/context.rb
index 6caf0d6712..58b1c54269 100644
--- a/lib/rdoc/context.rb
+++ b/lib/rdoc/context.rb
@@ -407,7 +407,6 @@ class RDoc::Context < RDoc::CodeObject
mod.section = current_section # TODO declaring context? something is
# wrong here...
mod.parent = self
- mod.full_name = nil
mod.store = @store
unless @done_documenting then
@@ -415,10 +414,6 @@ class RDoc::Context < RDoc::CodeObject
# this must be done AFTER adding mod to its parent, so that the full
# name is correct:
all_hash[mod.full_name] = mod
- if @store.unmatched_constant_alias[mod.full_name] then
- to, file = @store.unmatched_constant_alias[mod.full_name]
- add_module_alias mod, mod.name, to, file
- end
end
mod
@@ -516,52 +511,40 @@ class RDoc::Context < RDoc::CodeObject
end
##
- # Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
-
- def add_module_by_normal_module(mod)
- add_class_or_module mod, @modules, @store.modules_hash
- end
-
- ##
# Adds an alias from +from+ (a class or module) to +name+ which was defined
# in +file+.
- def add_module_alias from, from_name, to, file
+ def add_module_alias from, name, file
return from if @done_documenting
- to_full_name = child_name to.name
+ to_name = child_name name
# if we already know this name, don't register an alias:
# see the metaprogramming in lib/active_support/basic_object.rb,
# where we already know BasicObject is a class when we find
# BasicObject = BlankSlate
- return from if @store.find_class_or_module to_full_name
-
- unless from
- @store.unmatched_constant_alias[child_name(from_name)] = [to, file]
- return to
- end
+ return from if @store.find_class_or_module to_name
- new_to = from.dup
- new_to.name = to.name
- new_to.full_name = nil
+ to = from.dup
+ to.name = name
+ to.full_name = nil
- if new_to.module? then
- @store.modules_hash[to_full_name] = new_to
- @modules[to.name] = new_to
+ if to.module? then
+ @store.modules_hash[to_name] = to
+ @modules[name] = to
else
- @store.classes_hash[to_full_name] = new_to
- @classes[to.name] = new_to
+ @store.classes_hash[to_name] = to
+ @classes[name] = to
end
# Registers a constant for this alias. The constant value and comment
# will be updated later, when the Ruby parser adds the constant
- const = RDoc::Constant.new to.name, nil, new_to.comment
+ const = RDoc::Constant.new name, nil, to.comment
const.record_location file
const.is_alias_for = from
add_constant const
- new_to
+ to
end
##
@@ -880,13 +863,7 @@ class RDoc::Context < RDoc::CodeObject
# Finds a method named +name+ with singleton value +singleton+.
def find_method(name, singleton)
- @method_list.find { |m|
- if m.singleton
- m.name == name && m.singleton == singleton
- else
- m.name == name && !m.singleton && !singleton
- end
- }
+ @method_list.find { |m| m.name == name && m.singleton == singleton }
end
##
diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb
index 07ba14c5c3..d76ebaf2d0 100644
--- a/lib/rdoc/cross_reference.rb
+++ b/lib/rdoc/cross_reference.rb
@@ -19,16 +19,16 @@ class RDoc::CrossReference
#
# See CLASS_REGEXP_STR
- METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>)(?:\([\w.+*/=<>-]*\))?'
##
# Regular expressions matching text that should potentially have
- # cross-reference links generated are passed to add_regexp_handling. Note
- # that these expressions are meant to pick up text for which cross-references
+ # cross-reference links generated are passed to add_special. Note that
+ # these expressions are meant to pick up text for which cross-references
# have been suppressed, since the suppression characters are removed by the
# code that is triggered.
- CROSSREF_REGEXP = /(?:^|[\s()])
+ CROSSREF_REGEXP = /(?:^|\s)
(
(?:
# A::B::C.meth
@@ -76,7 +76,7 @@ class RDoc::CrossReference
# Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
ALL_CROSSREF_REGEXP = /
- (?:^|[\s()])
+ (?:^|\s)
(
(?:
# A::B::C.meth
@@ -127,41 +127,23 @@ class RDoc::CrossReference
if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
type = $2
- if '.' == type # will find either #method or ::method
- method = $3
- else
- method = "#{type}#{$3}"
- end
+ type = '' if type == '.' # will find either #method or ::method
+ method = "#{type}#{$3}"
container = @context.find_symbol_module($1)
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
type = $1
- if '.' == type
- method = $2
- else
- method = "#{type}#{$2}"
- end
+ type = '' if type == '.'
+ method = "#{type}#{$2}"
container = @context
else
- type = nil
container = nil
end
if container then
- unless RDoc::TopLevel === container then
- if '.' == type then
- if 'new' == method then # AnyClassName.new will be class method
- ref = container.find_local_symbol method
- ref = container.find_ancestor_local_symbol method unless ref
- else
- ref = container.find_local_symbol "::#{method}"
- ref = container.find_ancestor_local_symbol "::#{method}" unless ref
- ref = container.find_local_symbol "##{method}" unless ref
- ref = container.find_ancestor_local_symbol "##{method}" unless ref
- end
- else
- ref = container.find_local_symbol method
- ref = container.find_ancestor_local_symbol method unless ref
- end
+ ref = container.find_local_symbol method
+
+ unless ref || RDoc::TopLevel === container then
+ ref = container.find_ancestor_local_symbol method
end
end
diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb
index cf60badd24..54ecd89816 100644
--- a/lib/rdoc/encoding.rb
+++ b/lib/rdoc/encoding.rb
@@ -7,18 +7,6 @@
module RDoc::Encoding
- HEADER_REGEXP = /^
- (?:
- \A\#!.*\n
- |
- ^\#\s+frozen[-_]string[-_]literal[=:].+\n
- |
- ^\#[^\n]+\b(?:en)?coding[=:]\s*(?<name>[^\s;]+).*\n
- |
- <\?xml[^?]*encoding=(?<quote>["'])(?<name>.*?)\k<quote>.*\n
- )+
- /xi # :nodoc:
-
##
# Reads the contents of +filename+ and handles any encoding directives in
# the file.
@@ -30,13 +18,12 @@ module RDoc::Encoding
# unknown character in the target encoding will be replaced with '?'
def self.read_file filename, encoding, force_transcode = false
- content = File.open filename, "rb" do |f| f.read end
+ content = open filename, "rb" do |f| f.read end
content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/
utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
- enc = RDoc::Encoding.detect_encoding content
- content = RDoc::Encoding.change_encoding content, enc if enc
+ content = RDoc::Encoding.set_encoding content
begin
encoding ||= Encoding.default_external
@@ -98,22 +85,29 @@ module RDoc::Encoding
end
##
- # Detects the encoding of +string+ based on the magic comment
+ # Sets the encoding of +string+ based on the magic comment
- def self.detect_encoding string
- result = HEADER_REGEXP.match string
- name = result && result[:name]
+ def self.set_encoding string
+ string = remove_frozen_string_literal string
- name ? Encoding.find(name) : nil
- end
+ string =~ /\A(?:#!.*\n)?(.*\n)/
- ##
- # Removes magic comments and shebang
+ first_line = $1
- def self.remove_magic_comment string
- string.sub HEADER_REGEXP do |s|
- s.gsub(/[^\n]/, '')
- end
+ name = case first_line
+ when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2
+ when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1
+ else return string
+ end
+
+ string = string.sub first_line, ''
+
+ string = remove_frozen_string_literal string
+
+ enc = Encoding.find name
+ string = RDoc::Encoding.change_encoding string, enc if enc
+
+ string
end
##
diff --git a/lib/rdoc/erbio.rb b/lib/rdoc/erbio.rb
index 820a25ae01..42ce895fb3 100644
--- a/lib/rdoc/erbio.rb
+++ b/lib/rdoc/erbio.rb
@@ -9,7 +9,7 @@ require 'erb'
#
# erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil
#
-# File.open 'hello.txt', 'w' do |io|
+# open 'hello.txt', 'w' do |io|
# erbio.result binding
# end
#
@@ -21,11 +21,7 @@ class RDoc::ERBIO < ERB
# Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize
def initialize str, safe_level = nil, trim_mode = nil, eoutvar = 'io'
- if RUBY_VERSION >= '2.6'
- super(str, trim_mode: trim_mode, eoutvar: eoutvar)
- else
- super
- end
+ super
end
##
diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb
index c5d47ef355..bf4eb1f530 100644
--- a/lib/rdoc/generator/darkfish.rb
+++ b/lib/rdoc/generator/darkfish.rb
@@ -269,7 +269,7 @@ class RDoc::Generator::Darkfish
@options.static_path.each do |path|
unless File.directory? path then
- FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
+ FileUtils.install path, @outputdir, fu_options.merge(:mode => 0644)
next
end
@@ -278,9 +278,9 @@ class RDoc::Generator::Darkfish
dest_file = @outputdir + entry
if File.directory? entry then
- FileUtils.mkdir_p entry, **fu_options
+ FileUtils.mkdir_p entry, fu_options
else
- FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
+ FileUtils.install entry, dest_file, fu_options.merge(:mode => 0644)
end
end
end
@@ -585,16 +585,16 @@ class RDoc::Generator::Darkfish
return unless source.exist?
begin
- FileUtils.mkdir_p File.dirname(destination), **options
+ FileUtils.mkdir_p File.dirname(destination), options
begin
- FileUtils.ln source, destination, **options
+ FileUtils.ln source, destination, options
rescue Errno::EEXIST
FileUtils.rm destination
retry
end
rescue
- FileUtils.cp source, destination, **options
+ FileUtils.cp source, destination, options
end
end
@@ -778,11 +778,7 @@ class RDoc::Generator::Darkfish
erbout = "_erbout_#{file_var}"
end
- if RUBY_VERSION >= '2.6'
- template = klass.new template, trim_mode: '<>', eoutvar: erbout
- else
- template = klass.new template, nil, '<>', erbout
- end
+ template = klass.new template, nil, '<>', erbout
@template_cache[file] = template
template
end
diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb
index 3a1000033d..e4cfe967c6 100644
--- a/lib/rdoc/generator/json_index.rb
+++ b/lib/rdoc/generator/json_index.rb
@@ -147,15 +147,12 @@ class RDoc::Generator::JsonIndex
JSON.dump data, io, 0
end
- unless ENV['SOURCE_DATE_EPOCH'].nil?
- index_file.utime index_file.atime, Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
- end
Dir.chdir @template_dir do
Dir['**/*.js'].each do |source|
dest = File.join out_dir, source
- FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC
+ FileUtils.install source, dest, :mode => 0644, :verbose => $DEBUG_RDOC
end
end
end
diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb
index 41e132450d..fef982d378 100644
--- a/lib/rdoc/generator/markup.rb
+++ b/lib/rdoc/generator/markup.rb
@@ -65,6 +65,16 @@ end
class RDoc::MethodAttr
+ @add_line_numbers = false
+
+ class << self
+ ##
+ # Allows controlling whether <tt>#markup_code</tt> adds line numbers to
+ # the source code.
+
+ attr_accessor :add_line_numbers
+ end
+
##
# Prepend +src+ with line numbers. Relies on the first line of a source
# code listing having:
@@ -96,7 +106,7 @@ class RDoc::MethodAttr
##
# Turns the method's token stream into HTML.
#
- # Prepends line numbers if +options.line_numbers+ is true.
+ # Prepends line numbers if +add_line_numbers+ is true.
def markup_code
return '' unless @token_stream
@@ -116,7 +126,7 @@ class RDoc::MethodAttr
end
src.gsub!(/^#{' ' * indent}/, '') if indent > 0
- add_line_numbers(src) if options.line_numbers
+ add_line_numbers(src) if RDoc::MethodAttr.add_line_numbers
src
end
diff --git a/lib/rdoc/generator/pot.rb b/lib/rdoc/generator/pot.rb
index a12cba7505..8a1e0b4bd0 100644
--- a/lib/rdoc/generator/pot.rb
+++ b/lib/rdoc/generator/pot.rb
@@ -91,8 +91,8 @@ class RDoc::Generator::POT
extractor.extract
end
- require 'rdoc/generator/pot/message_extractor'
- require 'rdoc/generator/pot/po'
- require 'rdoc/generator/pot/po_entry'
+ autoload :MessageExtractor, 'rdoc/generator/pot/message_extractor'
+ autoload :PO, 'rdoc/generator/pot/po'
+ autoload :POEntry, 'rdoc/generator/pot/po_entry'
end
diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css
index a52e44ff8f..1bdb6e6223 100644
--- a/lib/rdoc/generator/template/darkfish/css/rdoc.css
+++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css
@@ -74,9 +74,6 @@ h6:target {
code,
pre {
font-family: "Source Code Pro", Monaco, monospace;
- background-color: rgba(27,31,35,0.05);
- padding: 0em 0.2em;
- border-radius: 0.2em;
}
/* @group Generic Classes */
@@ -106,7 +103,7 @@ pre {
.missing-docs {
font-size: 120%;
- background: white url(../images/wrench_orange.png) no-repeat 4px center;
+ background: white url(images/wrench_orange.png) no-repeat 4px center;
color: #ccc;
line-height: 2em;
border: 1px solid #d00;
@@ -150,11 +147,11 @@ pre {
.table-of-contents li .toc-toggle {
width: 16px;
height: 16px;
- background: url(../images/add.png) no-repeat;
+ background: url(images/add.png) no-repeat;
}
.table-of-contents li .toc-toggle.open {
- background: url(../images/delete.png) no-repeat;
+ background: url(images/delete.png) no-repeat;
}
/* @end */
@@ -276,13 +273,8 @@ ul.link-list .type {
-webkit-border-radius: 5px;
}
-dl.label-list dt {
- float: left;
- margin-right: 1em;
-}
-
.calls-super {
- background: url(../images/arrow_up.png) no-repeat right center;
+ background: url(images/arrow_up.png) no-repeat right center;
}
/* @end */
@@ -508,7 +500,7 @@ main .method-click-advice {
visibility: hidden;
padding-right: 20px;
line-height: 20px;
- background: url(../images/zoom.png) no-repeat right top;
+ background: url(images/zoom.png) no-repeat right top;
}
main .method-heading:hover .method-click-advice {
visibility: visible;
diff --git a/lib/rdoc/generator/template/json_index/js/navigation.js b/lib/rdoc/generator/template/json_index/js/navigation.js
index dfad74b1ae..4866fff819 100644
--- a/lib/rdoc/generator/template/json_index/js/navigation.js
+++ b/lib/rdoc/generator/template/json_index/js/navigation.js
@@ -41,8 +41,9 @@ Navigation = new function() {
}
break;
case 13: //Event.KEY_RETURN:
- if (this.current) e.preventDefault();
- this.select(this.current);
+ if (this.current)
+ e.preventDefault();
+ this.select(this.current);
break;
}
if (e.ctrlKey && e.shiftKey) this.select(this.current);
diff --git a/lib/rdoc/i18n.rb b/lib/rdoc/i18n.rb
index af303858b9..4cb5986155 100644
--- a/lib/rdoc/i18n.rb
+++ b/lib/rdoc/i18n.rb
@@ -5,6 +5,6 @@
module RDoc::I18n
autoload :Locale, 'rdoc/i18n/locale'
- require 'rdoc/i18n/text'
+ autoload :Text, 'rdoc/i18n/text'
end
diff --git a/lib/rdoc/markdown.rb b/lib/rdoc/markdown.rb
index 43c70c8de6..44dd50b0f7 100644
--- a/lib/rdoc/markdown.rb
+++ b/lib/rdoc/markdown.rb
@@ -1,5 +1,4 @@
# coding: UTF-8
-# frozen_string_literal: true
# :markup: markdown
##
diff --git a/lib/rdoc/markdown/literals.rb b/lib/rdoc/markdown/literals.rb
index 31cd237f12..cd4cb52335 100644
--- a/lib/rdoc/markdown/literals.rb
+++ b/lib/rdoc/markdown/literals.rb
@@ -1,5 +1,4 @@
# coding: UTF-8
-# frozen_string_literal: true
# :markup: markdown
##
diff --git a/lib/rdoc/markup.rb b/lib/rdoc/markup.rb
index fd59fca314..08ecc6f7df 100644
--- a/lib/rdoc/markup.rb
+++ b/lib/rdoc/markup.rb
@@ -65,16 +65,17 @@
# puts h.convert(input_string)
#
# You can extend the RDoc::Markup parser to recognize new markup
-# sequences, and to add regexp handling. Here we make WikiWords significant to
-# the parser, and also make the sequences {word} and \<no>text...</no> signify
+# sequences, and to add special processing for text that matches a
+# regular expression. Here we make WikiWords significant to the parser,
+# and also make the sequences {word} and \<no>text...</no> signify
# strike-through text. We then subclass the HTML output class to deal
# with these:
#
# require 'rdoc'
#
# class WikiHtml < RDoc::Markup::ToHtml
-# def handle_regexp_WIKIWORD(target)
-# "<font color=red>" + target.text + "</font>"
+# def handle_special_WIKIWORD(special)
+# "<font color=red>" + special.text + "</font>"
# end
# end
#
@@ -82,7 +83,7 @@
# markup.add_word_pair("{", "}", :STRIKE)
# markup.add_html("no", :STRIKE)
#
-# markup.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
+# markup.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
#
# wh = WikiHtml.new RDoc::Options.new, markup
# wh.add_tag(:STRIKE, "<strike>", "</strike>")
@@ -799,12 +800,13 @@ https://github.com/ruby/rdoc/issues
# Add to other inline sequences. For example, we could add WikiWords using
# something like:
#
- # parser.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
+ # parser.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
#
- # Each wiki word will be presented to the output formatter.
+ # Each wiki word will be presented to the output formatter via the
+ # accept_special method.
- def add_regexp_handling(pattern, name)
- @attribute_manager.add_regexp_handling(pattern, name)
+ def add_special(pattern, name)
+ @attribute_manager.add_special(pattern, name)
end
##
@@ -830,7 +832,7 @@ https://github.com/ruby/rdoc/issues
autoload :AttrSpan, 'rdoc/markup/attr_span'
autoload :Attributes, 'rdoc/markup/attributes'
autoload :AttributeManager, 'rdoc/markup/attribute_manager'
- autoload :RegexpHandling, 'rdoc/markup/regexp_handling'
+ autoload :Special, 'rdoc/markup/special'
# RDoc::Markup AST
autoload :BlankLine, 'rdoc/markup/blank_line'
@@ -849,6 +851,8 @@ https://github.com/ruby/rdoc/issues
# Formatters
autoload :Formatter, 'rdoc/markup/formatter'
+ autoload :FormatterTestCase, 'rdoc/markup/formatter_test_case'
+ autoload :TextFormatterTestCase, 'rdoc/markup/text_formatter_test_case'
autoload :ToAnsi, 'rdoc/markup/to_ansi'
autoload :ToBs, 'rdoc/markup/to_bs'
diff --git a/lib/rdoc/markup/attribute_manager.rb b/lib/rdoc/markup/attribute_manager.rb
index f052bc8b01..a10f731615 100644
--- a/lib/rdoc/markup/attribute_manager.rb
+++ b/lib/rdoc/markup/attribute_manager.rb
@@ -53,10 +53,10 @@ class RDoc::Markup::AttributeManager
attr_reader :protectable
##
- # And this maps _regexp handling_ sequences to a name. A regexp handling
- # sequence is something like a WikiWord
+ # And this maps _special_ sequences to a name. A special sequence is
+ # something like a WikiWord
- attr_reader :regexp_handlings
+ attr_reader :special
##
# Creates a new attribute manager that understands bold, emphasized and
@@ -66,7 +66,7 @@ class RDoc::Markup::AttributeManager
@html_tags = {}
@matching_word_pairs = {}
@protectable = %w[<]
- @regexp_handlings = []
+ @special = []
@word_pair_map = {}
@attributes = RDoc::Markup::Attributes.new
@@ -166,22 +166,22 @@ class RDoc::Markup::AttributeManager
end
##
- # Converts regexp handling sequences to RDoc attributes
+ # Converts special sequences to RDoc attributes
- def convert_regexp_handlings str, attrs
- @regexp_handlings.each do |regexp, attribute|
+ def convert_specials str, attrs
+ @special.each do |regexp, attribute|
str.scan(regexp) do
capture = $~.size == 1 ? 0 : 1
s, e = $~.offset capture
- attrs.set_attrs s, e - s, attribute | @attributes.regexp_handling
+ attrs.set_attrs s, e - s, attribute | @attributes.special
end
end
end
##
- # Escapes regexp handling sequences of text to prevent conversion to RDoc
+ # Escapes special sequences of text to prevent conversion to RDoc
def mask_protected_sequences
# protect __send__, __FILE__, etc.
@@ -193,7 +193,7 @@ class RDoc::Markup::AttributeManager
end
##
- # Unescapes regexp handling sequences of text
+ # Unescapes special sequences of text
def unmask_protected_sequences
@str.gsub!(/(.)#{PROTECT_ATTR}/, "\\1\000")
@@ -233,17 +233,17 @@ class RDoc::Markup::AttributeManager
end
##
- # Adds a regexp handling for +pattern+ with +name+. A simple URL handler
+ # Adds a special handler for +pattern+ with +name+. A simple URL handler
# would be:
#
- # @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK)
+ # @am.add_special(/((https?:)\S+\w)/, :HYPERLINK)
- def add_regexp_handling pattern, name
- @regexp_handlings << [pattern, @attributes.bitmap_for(name)]
+ def add_special pattern, name
+ @special << [pattern, @attributes.bitmap_for(name)]
end
##
- # Processes +str+ converting attributes, HTML and regexp handlings
+ # Processes +str+ converting attributes, HTML and specials
def flow str
@str = str.dup
@@ -252,9 +252,9 @@ class RDoc::Markup::AttributeManager
@attrs = RDoc::Markup::AttrSpan.new @str.length
- convert_attrs @str, @attrs
- convert_html @str, @attrs
- convert_regexp_handlings @str, @attrs
+ convert_attrs @str, @attrs
+ convert_html @str, @attrs
+ convert_specials @str, @attrs
unmask_protected_sequences
@@ -312,12 +312,12 @@ class RDoc::Markup::AttributeManager
res << change_attribute(current_attr, new_attr)
current_attr = new_attr
- if (current_attr & @attributes.regexp_handling) != 0 then
+ if (current_attr & @attributes.special) != 0 then
i += 1 while
- i < str_len and (@attrs[i] & @attributes.regexp_handling) != 0
+ i < str_len and (@attrs[i] & @attributes.special) != 0
- res << RDoc::Markup::RegexpHandling.new(current_attr,
- copy_string(start_pos, i))
+ res << RDoc::Markup::Special.new(current_attr,
+ copy_string(start_pos, i))
start_pos = i
next
end
diff --git a/lib/rdoc/markup/attributes.rb b/lib/rdoc/markup/attributes.rb
index ce014ce928..ec30160d3d 100644
--- a/lib/rdoc/markup/attributes.rb
+++ b/lib/rdoc/markup/attributes.rb
@@ -6,21 +6,21 @@
class RDoc::Markup::Attributes
##
- # The regexp handling attribute type. See RDoc::Markup#add_regexp_handling
+ # The special attribute type. See RDoc::Markup#add_special
- attr_reader :regexp_handling
+ attr_reader :special
##
# Creates a new attributes set.
def initialize
- @regexp_handling = 1
+ @special = 1
@name_to_bitmap = [
- [:_REGEXP_HANDLING_, @regexp_handling],
+ [:_SPECIAL_, @special],
]
- @next_bitmap = @regexp_handling << 1
+ @next_bitmap = @special << 1
end
##
@@ -61,7 +61,7 @@ class RDoc::Markup::Attributes
return enum_for __method__, bitmap unless block_given?
@name_to_bitmap.each do |name, bit|
- next if bit == @regexp_handling
+ next if bit == @special
yield name.to_s if (bitmap & bit) != 0
end
diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb
index 6dff96c7d0..5dc71d2242 100644
--- a/lib/rdoc/markup/formatter.rb
+++ b/lib/rdoc/markup/formatter.rb
@@ -50,7 +50,7 @@ class RDoc::Markup::Formatter
@markup = markup || RDoc::Markup.new
@am = @markup.attribute_manager
- @am.add_regexp_handling(/<br>/, :HARD_BREAK)
+ @am.add_special(/<br>/, :HARD_BREAK)
@attributes = @am.attributes
@@ -78,24 +78,23 @@ class RDoc::Markup::Formatter
end
##
- # Adds a regexp handling for links of the form rdoc-...:
+ # Adds a special for links of the form rdoc-...:
- def add_regexp_handling_RDOCLINK
- @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
+ def add_special_RDOCLINK
+ @markup.add_special(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
end
##
- # Adds a regexp handling for links of the form {<text>}[<url>] and
- # <word>[<url>]
+ # Adds a special for links of the form {<text>}[<url>] and <word>[<url>]
- def add_regexp_handling_TIDYLINK
- @markup.add_regexp_handling(/(?:
- \{.*?\} | # multi-word label
- \b[^\s{}]+? # single-word label
- )
+ def add_special_TIDYLINK
+ @markup.add_special(/(?:
+ \{.*?\} | # multi-word label
+ \b[^\s{}]+? # single-word label
+ )
- \[\S+?\] # link target
- /x, :TIDYLINK)
+ \[\S+?\] # link target
+ /x, :TIDYLINK)
end
##
@@ -134,8 +133,8 @@ class RDoc::Markup::Formatter
when RDoc::Markup::AttrChanger then
off_tags res, item
on_tags res, item
- when RDoc::Markup::RegexpHandling then
- res << convert_regexp_handling(item)
+ when RDoc::Markup::Special then
+ res << convert_special(item)
else
raise "Unknown flow element: #{item.inspect}"
end
@@ -145,29 +144,29 @@ class RDoc::Markup::Formatter
end
##
- # Converts added regexp handlings. See RDoc::Markup#add_regexp_handling
+ # Converts added specials. See RDoc::Markup#add_special
- def convert_regexp_handling target
- return target.text if in_tt?
+ def convert_special special
+ return special.text if in_tt?
handled = false
- @attributes.each_name_of target.type do |name|
- method_name = "handle_regexp_#{name}"
+ @attributes.each_name_of special.type do |name|
+ method_name = "handle_special_#{name}"
if respond_to? method_name then
- target.text = send method_name, target
+ special.text = send method_name, special
handled = true
end
end
unless handled then
- target_name = @attributes.as_string target.type
+ special_name = @attributes.as_string special.type
- raise RDoc::Error, "Unhandled regexp handling #{target_name}: #{target}"
+ raise RDoc::Error, "Unhandled special #{special_name}: #{special}"
end
- target.text
+ special.text
end
##
diff --git a/lib/rdoc/markup/formatter_test_case.rb b/lib/rdoc/markup/formatter_test_case.rb
new file mode 100644
index 0000000000..076b7c81bb
--- /dev/null
+++ b/lib/rdoc/markup/formatter_test_case.rb
@@ -0,0 +1,764 @@
+# frozen_string_literal: true
+require 'minitest/unit'
+
+##
+# Test case for creating new RDoc::Markup formatters. See
+# test/test_rdoc_markup_to_*.rb for examples.
+#
+# This test case adds a variety of tests to your subclass when
+# #add_visitor_tests is called. Most tests set up a scenario then call a
+# method you will provide to perform the assertion on the output.
+#
+# Your subclass must instantiate a visitor and assign it to <tt>@to</tt>.
+#
+# For example, test_accept_blank_line sets up a RDoc::Markup::BlockLine then
+# calls accept_blank_line on your visitor. You are responsible for asserting
+# that the output is correct.
+#
+# Example:
+#
+# class TestRDocMarkupToNewFormat < RDoc::Markup::FormatterTestCase
+#
+# add_visitor_tests
+#
+# def setup
+# super
+#
+# @to = RDoc::Markup::ToNewFormat.new
+# end
+#
+# def accept_blank_line
+# assert_equal :junk, @to.res.join
+# end
+#
+# # ...
+#
+# end
+
+class RDoc::Markup::FormatterTestCase < RDoc::TestCase
+
+ ##
+ # Call #setup when inheriting from this test case.
+ #
+ # Provides the following instance variables:
+ #
+ # +@m+:: RDoc::Markup.new
+ # +@RM+:: RDoc::Markup # to reduce typing
+ # +@bullet_list+:: @RM::List.new :BULLET, # ...
+ # +@label_list+:: @RM::List.new :LABEL, # ...
+ # +@lalpha_list+:: @RM::List.new :LALPHA, # ...
+ # +@note_list+:: @RM::List.new :NOTE, # ...
+ # +@number_list+:: @RM::List.new :NUMBER, # ...
+ # +@ualpha_list+:: @RM::List.new :UALPHA, # ...
+
+ def setup
+ super
+
+ @options = RDoc::Options.new
+
+ @m = @RM.new
+
+ @bullet_list = @RM::List.new(:BULLET,
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
+
+ @label_list = @RM::List.new(:LABEL,
+ @RM::ListItem.new('cat', @RM::Paragraph.new('cats are cool')),
+ @RM::ListItem.new('dog', @RM::Paragraph.new('dogs are cool too')))
+
+ @lalpha_list = @RM::List.new(:LALPHA,
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
+
+ @note_list = @RM::List.new(:NOTE,
+ @RM::ListItem.new('cat', @RM::Paragraph.new('cats are cool')),
+ @RM::ListItem.new('dog', @RM::Paragraph.new('dogs are cool too')))
+
+ @number_list = @RM::List.new(:NUMBER,
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
+
+ @ualpha_list = @RM::List.new(:UALPHA,
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
+ @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
+ end
+
+ ##
+ # Call to add the visitor tests to your test case
+
+ def self.add_visitor_tests
+ class_eval do
+
+ ##
+ # Calls start_accepting which needs to verify startup state
+
+ def test_start_accepting
+ @to.start_accepting
+
+ start_accepting
+ end
+
+ ##
+ # Calls end_accepting on your test case which needs to call
+ # <tt>@to.end_accepting</tt> and verify document generation
+
+ def test_end_accepting
+ @to.start_accepting
+ @to.res << 'hi'
+
+ end_accepting
+ end
+
+ ##
+ # Calls accept_blank_line
+
+ def test_accept_blank_line
+ @to.start_accepting
+
+ @to.accept_blank_line @RM::BlankLine.new
+
+ accept_blank_line
+ end
+
+ ##
+ # Calls accept_block_quote
+
+ def test_accept_block_quote
+ @to.start_accepting
+
+ @to.accept_block_quote block para 'quote'
+
+ accept_block_quote
+ end
+ ##
+ # Test case that calls <tt>@to.accept_document</tt>
+
+ def test_accept_document
+ @to.start_accepting
+ @to.accept_document @RM::Document.new @RM::Paragraph.new 'hello'
+
+ accept_document
+ end
+
+ ##
+ # Calls accept_heading with a level 5 RDoc::Markup::Heading
+
+ def test_accept_heading
+ @to.start_accepting
+
+ @to.accept_heading @RM::Heading.new(5, 'Hello')
+
+ accept_heading
+ end
+
+ ##
+ # Calls accept_heading_1 with a level 1 RDoc::Markup::Heading
+
+ def test_accept_heading_1
+ @to.start_accepting
+
+ @to.accept_heading @RM::Heading.new(1, 'Hello')
+
+ accept_heading_1
+ end
+
+ ##
+ # Calls accept_heading_2 with a level 2 RDoc::Markup::Heading
+
+ def test_accept_heading_2
+ @to.start_accepting
+
+ @to.accept_heading @RM::Heading.new(2, 'Hello')
+
+ accept_heading_2
+ end
+
+ ##
+ # Calls accept_heading_3 with a level 3 RDoc::Markup::Heading
+
+ def test_accept_heading_3
+ @to.start_accepting
+
+ @to.accept_heading @RM::Heading.new(3, 'Hello')
+
+ accept_heading_3
+ end
+
+ ##
+ # Calls accept_heading_4 with a level 4 RDoc::Markup::Heading
+
+ def test_accept_heading_4
+ @to.start_accepting
+
+ @to.accept_heading @RM::Heading.new(4, 'Hello')
+
+ accept_heading_4
+ end
+
+ ##
+ # Calls accept_heading_b with a bold level 1 RDoc::Markup::Heading
+
+ def test_accept_heading_b
+ @to.start_accepting
+
+ @to.accept_heading @RM::Heading.new(1, '*Hello*')
+
+ accept_heading_b
+ end
+
+ ##
+ # Calls accept_heading_suppressed_crossref with a level 1
+ # RDoc::Markup::Heading containing a suppressed crossref
+
+ def test_accept_heading_suppressed_crossref # HACK to_html_crossref test
+ @to.start_accepting
+
+ @to.accept_heading @RM::Heading.new(1, '\\Hello')
+
+ accept_heading_suppressed_crossref
+ end
+
+ ##
+ # Calls accept_paragraph
+
+ def test_accept_paragraph
+ @to.start_accepting
+
+ @to.accept_paragraph @RM::Paragraph.new('hi')
+
+ accept_paragraph
+ end
+
+ ##
+ # Calls accept_paragraph_b with a RDoc::Markup::Paragraph containing
+ # bold words
+
+ def test_accept_paragraph_b
+ @to.start_accepting
+
+ @to.accept_paragraph @RM::Paragraph.new('reg <b>bold words</b> reg')
+
+ accept_paragraph_b
+ end
+
+ ##
+ # Calls accept_paragraph_br with a RDoc::Markup::Paragraph containing
+ # a \<br>
+
+ def test_accept_paragraph_br
+ @to.start_accepting
+
+ @to.accept_paragraph para 'one<br>two'
+
+ accept_paragraph_br
+ end
+
+ ##
+ # Calls accept_paragraph with a Paragraph containing a hard break
+
+ def test_accept_paragraph_break
+ @to.start_accepting
+
+ @to.accept_paragraph para('hello', hard_break, 'world')
+
+ accept_paragraph_break
+ end
+
+ ##
+ # Calls accept_paragraph_i with a RDoc::Markup::Paragraph containing
+ # emphasized words
+
+ def test_accept_paragraph_i
+ @to.start_accepting
+
+ @to.accept_paragraph @RM::Paragraph.new('reg <em>italic words</em> reg')
+
+ accept_paragraph_i
+ end
+
+ ##
+ # Calls accept_paragraph_plus with a RDoc::Markup::Paragraph containing
+ # teletype words
+
+ def test_accept_paragraph_plus
+ @to.start_accepting
+
+ @to.accept_paragraph @RM::Paragraph.new('reg +teletype+ reg')
+
+ accept_paragraph_plus
+ end
+
+ ##
+ # Calls accept_paragraph_star with a RDoc::Markup::Paragraph containing
+ # bold words
+
+ def test_accept_paragraph_star
+ @to.start_accepting
+
+ @to.accept_paragraph @RM::Paragraph.new('reg *bold* reg')
+
+ accept_paragraph_star
+ end
+
+ ##
+ # Calls accept_paragraph_underscore with a RDoc::Markup::Paragraph
+ # containing emphasized words
+
+ def test_accept_paragraph_underscore
+ @to.start_accepting
+
+ @to.accept_paragraph @RM::Paragraph.new('reg _italic_ reg')
+
+ accept_paragraph_underscore
+ end
+
+ ##
+ # Calls accept_verbatim with a RDoc::Markup::Verbatim
+
+ def test_accept_verbatim
+ @to.start_accepting
+
+ @to.accept_verbatim @RM::Verbatim.new("hi\n", " world\n")
+
+ accept_verbatim
+ end
+
+ ##
+ # Calls accept_raw with a RDoc::Markup::Raw
+
+ def test_accept_raw
+ @to.start_accepting
+
+ @to.accept_raw @RM::Raw.new("<table>",
+ "<tr><th>Name<th>Count",
+ "<tr><td>a<td>1",
+ "<tr><td>b<td>2",
+ "</table>")
+
+ accept_raw
+ end
+
+ ##
+ # Calls accept_rule with a RDoc::Markup::Rule
+
+ def test_accept_rule
+ @to.start_accepting
+
+ @to.accept_rule @RM::Rule.new(4)
+
+ accept_rule
+ end
+
+ ##
+ # Calls accept_list_item_start_bullet
+
+ def test_accept_list_item_start_bullet
+ @to.start_accepting
+
+ @to.accept_list_start @bullet_list
+
+ @to.accept_list_item_start @bullet_list.items.first
+
+ accept_list_item_start_bullet
+ end
+
+ ##
+ # Calls accept_list_item_start_label
+
+ def test_accept_list_item_start_label
+ @to.start_accepting
+
+ @to.accept_list_start @label_list
+
+ @to.accept_list_item_start @label_list.items.first
+
+ accept_list_item_start_label
+ end
+
+ ##
+ # Calls accept_list_item_start_lalpha
+
+ def test_accept_list_item_start_lalpha
+ @to.start_accepting
+
+ @to.accept_list_start @lalpha_list
+
+ @to.accept_list_item_start @lalpha_list.items.first
+
+ accept_list_item_start_lalpha
+ end
+
+ ##
+ # Calls accept_list_item_start_note
+
+ def test_accept_list_item_start_note
+ @to.start_accepting
+
+ @to.accept_list_start @note_list
+
+ @to.accept_list_item_start @note_list.items.first
+
+ accept_list_item_start_note
+ end
+
+ ##
+ # Calls accept_list_item_start_note_2
+
+ def test_accept_list_item_start_note_2
+ list = list(:NOTE,
+ item('<tt>teletype</tt>',
+ para('teletype description')))
+
+ @to.start_accepting
+
+ list.accept @to
+
+ @to.end_accepting
+
+ accept_list_item_start_note_2
+ end
+
+ ##
+ # Calls accept_list_item_start_note_multi_description
+
+ def test_accept_list_item_start_note_multi_description
+ list = list(:NOTE,
+ item(%w[label],
+ para('description one')),
+ item(nil, para('description two')))
+
+ @to.start_accepting
+
+ list.accept @to
+
+ @to.end_accepting
+
+ accept_list_item_start_note_multi_description
+ end
+
+ ##
+ # Calls accept_list_item_start_note_multi_label
+
+ def test_accept_list_item_start_note_multi_label
+ list = list(:NOTE,
+ item(%w[one two],
+ para('two headers')))
+
+ @to.start_accepting
+
+ list.accept @to
+
+ @to.end_accepting
+
+ accept_list_item_start_note_multi_label
+ end
+
+ ##
+ # Calls accept_list_item_start_number
+
+ def test_accept_list_item_start_number
+ @to.start_accepting
+
+ @to.accept_list_start @number_list
+
+ @to.accept_list_item_start @number_list.items.first
+
+ accept_list_item_start_number
+ end
+
+ ##
+ # Calls accept_list_item_start_ualpha
+
+ def test_accept_list_item_start_ualpha
+ @to.start_accepting
+
+ @to.accept_list_start @ualpha_list
+
+ @to.accept_list_item_start @ualpha_list.items.first
+
+ accept_list_item_start_ualpha
+ end
+
+ ##
+ # Calls accept_list_item_end_bullet
+
+ def test_accept_list_item_end_bullet
+ @to.start_accepting
+
+ @to.accept_list_start @bullet_list
+
+ @to.accept_list_item_start @bullet_list.items.first
+
+ @to.accept_list_item_end @bullet_list.items.first
+
+ accept_list_item_end_bullet
+ end
+
+ ##
+ # Calls accept_list_item_end_label
+
+ def test_accept_list_item_end_label
+ @to.start_accepting
+
+ @to.accept_list_start @label_list
+
+ @to.accept_list_item_start @label_list.items.first
+
+ @to.accept_list_item_end @label_list.items.first
+
+ accept_list_item_end_label
+ end
+
+ ##
+ # Calls accept_list_item_end_lalpha
+
+ def test_accept_list_item_end_lalpha
+ @to.start_accepting
+
+ @to.accept_list_start @lalpha_list
+
+ @to.accept_list_item_start @lalpha_list.items.first
+
+ @to.accept_list_item_end @lalpha_list.items.first
+
+ accept_list_item_end_lalpha
+ end
+
+ ##
+ # Calls accept_list_item_end_note
+
+ def test_accept_list_item_end_note
+ @to.start_accepting
+
+ @to.accept_list_start @note_list
+
+ @to.accept_list_item_start @note_list.items.first
+
+ @to.accept_list_item_end @note_list.items.first
+
+ accept_list_item_end_note
+ end
+
+ ##
+ # Calls accept_list_item_end_number
+
+ def test_accept_list_item_end_number
+ @to.start_accepting
+
+ @to.accept_list_start @number_list
+
+ @to.accept_list_item_start @number_list.items.first
+
+ @to.accept_list_item_end @number_list.items.first
+
+ accept_list_item_end_number
+ end
+
+ ##
+ # Calls accept_list_item_end_ualpha
+
+ def test_accept_list_item_end_ualpha
+ @to.start_accepting
+
+ @to.accept_list_start @ualpha_list
+
+ @to.accept_list_item_start @ualpha_list.items.first
+
+ @to.accept_list_item_end @ualpha_list.items.first
+
+ accept_list_item_end_ualpha
+ end
+
+ ##
+ # Calls accept_list_start_bullet
+
+ def test_accept_list_start_bullet
+ @to.start_accepting
+
+ @to.accept_list_start @bullet_list
+
+ accept_list_start_bullet
+ end
+
+ ##
+ # Calls accept_list_start_label
+
+ def test_accept_list_start_label
+ @to.start_accepting
+
+ @to.accept_list_start @label_list
+
+ accept_list_start_label
+ end
+
+ ##
+ # Calls accept_list_start_lalpha
+
+ def test_accept_list_start_lalpha
+ @to.start_accepting
+
+ @to.accept_list_start @lalpha_list
+
+ accept_list_start_lalpha
+ end
+
+ ##
+ # Calls accept_list_start_note
+
+ def test_accept_list_start_note
+ @to.start_accepting
+
+ @to.accept_list_start @note_list
+
+ accept_list_start_note
+ end
+
+ ##
+ # Calls accept_list_start_number
+
+ def test_accept_list_start_number
+ @to.start_accepting
+
+ @to.accept_list_start @number_list
+
+ accept_list_start_number
+ end
+
+ ##
+ # Calls accept_list_start_ualpha
+
+ def test_accept_list_start_ualpha
+ @to.start_accepting
+
+ @to.accept_list_start @ualpha_list
+
+ accept_list_start_ualpha
+ end
+
+ ##
+ # Calls accept_list_end_bullet
+
+ def test_accept_list_end_bullet
+ @to.start_accepting
+
+ @to.accept_list_start @bullet_list
+
+ @to.accept_list_end @bullet_list
+
+ accept_list_end_bullet
+ end
+
+ ##
+ # Calls accept_list_end_label
+
+ def test_accept_list_end_label
+ @to.start_accepting
+
+ @to.accept_list_start @label_list
+
+ @to.accept_list_end @label_list
+
+ accept_list_end_label
+ end
+
+ ##
+ # Calls accept_list_end_lalpha
+
+ def test_accept_list_end_lalpha
+ @to.start_accepting
+
+ @to.accept_list_start @lalpha_list
+
+ @to.accept_list_end @lalpha_list
+
+ accept_list_end_lalpha
+ end
+
+ ##
+ # Calls accept_list_end_number
+
+ def test_accept_list_end_number
+ @to.start_accepting
+
+ @to.accept_list_start @number_list
+
+ @to.accept_list_end @number_list
+
+ accept_list_end_number
+ end
+
+ ##
+ # Calls accept_list_end_note
+
+ def test_accept_list_end_note
+ @to.start_accepting
+
+ @to.accept_list_start @note_list
+
+ @to.accept_list_end @note_list
+
+ accept_list_end_note
+ end
+
+ ##
+ # Calls accept_list_end_ualpha
+
+ def test_accept_list_end_ualpha
+ @to.start_accepting
+
+ @to.accept_list_start @ualpha_list
+
+ @to.accept_list_end @ualpha_list
+
+ accept_list_end_ualpha
+ end
+
+ ##
+ # Calls list_nested with a two-level list
+
+ def test_list_nested
+ doc = @RM::Document.new(
+ @RM::List.new(:BULLET,
+ @RM::ListItem.new(nil,
+ @RM::Paragraph.new('l1'),
+ @RM::List.new(:BULLET,
+ @RM::ListItem.new(nil,
+ @RM::Paragraph.new('l1.1')))),
+ @RM::ListItem.new(nil,
+ @RM::Paragraph.new('l2'))))
+
+ doc.accept @to
+
+ list_nested
+ end
+
+ ##
+ # Calls list_verbatim with a list containing a verbatim block
+
+ def test_list_verbatim # HACK overblown
+ doc =
+ doc(
+ list(:BULLET,
+ item(nil,
+ para('list stuff'),
+ blank_line,
+ verb("* list\n",
+ " with\n",
+ "\n",
+ " second\n",
+ "\n",
+ " 1. indented\n",
+ " 2. numbered\n",
+ "\n",
+ " third\n",
+ "\n",
+ "* second\n"))))
+
+ doc.accept @to
+
+ list_verbatim
+ end
+ end
+ end
+
+end
diff --git a/lib/rdoc/markup/heading.rb b/lib/rdoc/markup/heading.rb
index 93a3a52000..233774c5c4 100644
--- a/lib/rdoc/markup/heading.rb
+++ b/lib/rdoc/markup/heading.rb
@@ -23,12 +23,12 @@ RDoc::Markup::Heading =
return @to_html if @to_html
markup = RDoc::Markup.new
- markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
+ markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
@to_html = RDoc::Markup::ToHtml.new nil
- def @to_html.handle_regexp_CROSSREF target
- target.text.sub(/^\\/, '')
+ def @to_html.handle_special_CROSSREF special
+ special.text.sub(/^\\/, '')
end
@to_html
diff --git a/lib/rdoc/markup/inline.rb b/lib/rdoc/markup/inline.rb
new file mode 100644
index 0000000000..aba7ec21ce
--- /dev/null
+++ b/lib/rdoc/markup/inline.rb
@@ -0,0 +1,2 @@
+# frozen_string_literal: true
+warn "requiring rdoc/markup/inline is deprecated and will be removed in RDoc 4." if $-w
diff --git a/lib/rdoc/markup/parser.rb b/lib/rdoc/markup/parser.rb
index 1b54a519d1..f08587e676 100644
--- a/lib/rdoc/markup/parser.rb
+++ b/lib/rdoc/markup/parser.rb
@@ -9,9 +9,8 @@ require 'strscan'
# RDoc::Markup::ToHTML.
#
# The parser only handles the block-level constructs Paragraph, List,
-# ListItem, Heading, Verbatim, BlankLine, Rule and BlockQuote.
-# Inline markup such as <tt>\+blah\+</tt> is handled separately by
-# RDoc::Markup::AttributeManager.
+# ListItem, Heading, Verbatim, BlankLine and Rule. Inline markup such as
+# <tt>\+blah\+</tt> is handled separately by RDoc::Markup::AttributeManager.
#
# To see what markup the Parser implements read RDoc. To see how to use
# RDoc markup to format text in your program read RDoc::Markup.
@@ -80,6 +79,10 @@ class RDoc::Markup::Parser
@binary_input = nil
@current_token = nil
@debug = false
+ @input = nil
+ @input_encoding = nil
+ @line = 0
+ @line_pos = 0
@s = nil
@tokens = []
end
@@ -316,6 +319,13 @@ class RDoc::Markup::Parser
end
##
+ # The character offset for the input string at the given +byte_offset+
+
+ def char_pos byte_offset
+ @input.byteslice(0, byte_offset).length
+ end
+
+ ##
# Pulls the next token from the stream.
def get
@@ -371,17 +381,6 @@ class RDoc::Markup::Parser
when :TEXT then
unget
parse_text parent, indent
- when :BLOCKQUOTE then
- type, _, column = get
- if type == :NEWLINE
- type, _, column = get
- end
- unget if type
- bq = RDoc::Markup::BlockQuote.new
- p :blockquote_start => [data, column] if @debug
- parse bq, column
- p :blockquote_end => indent if @debug
- parent << bq
when *LIST_TOKENS then
unget
parent << build_list(indent)
@@ -414,52 +413,14 @@ class RDoc::Markup::Parser
end
##
- # A simple wrapper of StringScanner that is aware of the current column and lineno
-
- class MyStringScanner
- def initialize(input)
- @line = @column = 0
- @s = StringScanner.new input
- end
-
- def scan(re)
- ret = @s.scan(re)
- @column += ret.length if ret
- ret
- end
-
- def unscan(s)
- @s.pos -= s.bytesize
- @column -= s.length
- end
-
- def pos
- [@column, @line]
- end
-
- def newline!
- @column = 0
- @line += 1
- end
-
- def eos?
- @s.eos?
- end
-
- def matched
- @s.matched
- end
-
- def [](i)
- @s[i]
- end
- end
-
- ##
# Creates the StringScanner
def setup_scanner input
- @s = MyStringScanner.new input
+ @line = 0
+ @line_pos = 0
+ @input = input.dup
+
+ @s = StringScanner.new input
end
##
@@ -494,30 +455,31 @@ class RDoc::Markup::Parser
@tokens << case
# [CR]LF => :NEWLINE
when @s.scan(/\r?\n/) then
- token = [:NEWLINE, @s.matched, *pos]
- @s.newline!
+ token = [:NEWLINE, @s.matched, *token_pos(pos)]
+ @line_pos = char_pos @s.pos
+ @line += 1
token
# === text => :HEADER then :TEXT
when @s.scan(/(=+)(\s*)/) then
level = @s[1].length
- header = [:HEADER, level, *pos]
+ header = [:HEADER, level, *token_pos(pos)]
if @s[2] =~ /^\r?\n/ then
- @s.unscan(@s[2])
+ @s.pos -= @s[2].length
header
else
pos = @s.pos
@s.scan(/.*/)
@tokens << header
- [:TEXT, @s.matched.sub(/\r$/, ''), *pos]
+ [:TEXT, @s.matched.sub(/\r$/, ''), *token_pos(pos)]
end
# --- (at least 3) and nothing else on the line => :RULE
when @s.scan(/(-{3,}) *\r?$/) then
- [:RULE, @s[1].length - 2, *pos]
+ [:RULE, @s[1].length - 2, *token_pos(pos)]
# * or - followed by white space and text => :BULLET
when @s.scan(/([*-]) +(\S)/) then
- @s.unscan(@s[2])
- [:BULLET, @s[1], *pos]
+ @s.pos -= @s[2].bytesize # unget \S
+ [:BULLET, @s[1], *token_pos(pos)]
# A. text, a. text, 12. text => :UALPHA, :LALPHA, :NUMBER
when @s.scan(/([a-z]|\d+)\. +(\S)/i) then
# FIXME if tab(s), the column will be wrong
@@ -526,7 +488,7 @@ class RDoc::Markup::Parser
# before (and provide a check for that at least in debug
# mode)
list_label = @s[1]
- @s.unscan(@s[2])
+ @s.pos -= @s[2].bytesize # unget \S
list_type =
case list_label
when /[a-z]/ then :LALPHA
@@ -535,24 +497,20 @@ class RDoc::Markup::Parser
else
raise ParseError, "BUG token #{list_label}"
end
- [list_type, list_label, *pos]
+ [list_type, list_label, *token_pos(pos)]
# [text] followed by spaces or end of line => :LABEL
when @s.scan(/\[(.*?)\]( +|\r?$)/) then
- [:LABEL, @s[1], *pos]
+ [:LABEL, @s[1], *token_pos(pos)]
# text:: followed by spaces or end of line => :NOTE
when @s.scan(/(.*?)::( +|\r?$)/) then
- [:NOTE, @s[1], *pos]
- # >>> followed by end of line => :BLOCKQUOTE
- when @s.scan(/>>> *(\w+)?$/) then
- [:BLOCKQUOTE, @s[1], *pos]
+ [:NOTE, @s[1], *token_pos(pos)]
# anything else: :TEXT
- else
- @s.scan(/(.*?)( )?\r?$/)
- token = [:TEXT, @s[1], *pos]
+ else @s.scan(/(.*?)( )?\r?$/)
+ token = [:TEXT, @s[1], *token_pos(pos)]
if @s[2] then
@tokens << token
- [:BREAK, @s[2], pos[0] + @s[1].length, pos[1]]
+ [:BREAK, @s[2], *token_pos(pos + @s[1].length)]
else
token
end
@@ -563,6 +521,16 @@ class RDoc::Markup::Parser
end
##
+ # Calculates the column (by character) and line of the current token based
+ # on +byte_offset+.
+
+ def token_pos byte_offset
+ offset = char_pos byte_offset
+
+ [offset - @line_pos, @line]
+ end
+
+ ##
# Returns the current token to the token stream
def unget
diff --git a/lib/rdoc/markup/pre_process.rb b/lib/rdoc/markup/pre_process.rb
index d9e0dcac14..0ac7a41934 100644
--- a/lib/rdoc/markup/pre_process.rb
+++ b/lib/rdoc/markup/pre_process.rb
@@ -266,7 +266,6 @@ class RDoc::Markup::PreProcess
end
content = RDoc::Encoding.read_file full_name, encoding, true
- content = RDoc::Encoding.remove_magic_comment content
# strip magic comment
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
diff --git a/lib/rdoc/markup/regexp_handling.rb b/lib/rdoc/markup/regexp_handling.rb
deleted file mode 100644
index 6ed868c2c1..0000000000
--- a/lib/rdoc/markup/regexp_handling.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-##
-# Hold details of a regexp handling sequence
-
-class RDoc::Markup::RegexpHandling
-
- ##
- # Regexp handling type
-
- attr_reader :type
-
- ##
- # Regexp handling text
-
- attr_accessor :text
-
- ##
- # Creates a new regexp handling sequence of +type+ with +text+
-
- def initialize(type, text)
- @type, @text = type, text
- end
-
- ##
- # Regexp handlings are equal when the have the same text and type
-
- def ==(o)
- self.text == o.text && self.type == o.type
- end
-
- def inspect # :nodoc:
- "#<RDoc::Markup::RegexpHandling:0x%x @type=%p, @text=%p>" % [
- object_id, @type, text.dump]
- end
-
- def to_s # :nodoc:
- "RegexpHandling: type=#{type} text=#{text.dump}"
- end
-
-end
-
diff --git a/lib/rdoc/markup/special.rb b/lib/rdoc/markup/special.rb
new file mode 100644
index 0000000000..57261b44a7
--- /dev/null
+++ b/lib/rdoc/markup/special.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+##
+# Hold details of a special sequence
+
+class RDoc::Markup::Special
+
+ ##
+ # Special type
+
+ attr_reader :type
+
+ ##
+ # Special text
+
+ attr_accessor :text
+
+ ##
+ # Creates a new special sequence of +type+ with +text+
+
+ def initialize(type, text)
+ @type, @text = type, text
+ end
+
+ ##
+ # Specials are equal when the have the same text and type
+
+ def ==(o)
+ self.text == o.text && self.type == o.type
+ end
+
+ def inspect # :nodoc:
+ "#<RDoc::Markup::Special:0x%x @type=%p, @text=%p>" % [
+ object_id, @type, text.dump]
+ end
+
+ def to_s # :nodoc:
+ "Special: type=#{type} text=#{text.dump}"
+ end
+
+end
+
diff --git a/test/rdoc/support/text_formatter_test_case.rb b/lib/rdoc/markup/text_formatter_test_case.rb
index 22a762b5f0..22a762b5f0 100644
--- a/test/rdoc/support/text_formatter_test_case.rb
+++ b/lib/rdoc/markup/text_formatter_test_case.rb
diff --git a/lib/rdoc/markup/to_bs.rb b/lib/rdoc/markup/to_bs.rb
index f9b86487db..fea017e89d 100644
--- a/lib/rdoc/markup/to_bs.rb
+++ b/lib/rdoc/markup/to_bs.rb
@@ -41,7 +41,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
end
##
- # Turns on or off regexp handling for +convert_string+
+ # Turns on or off special handling for +convert_string+
def annotate tag
case tag
@@ -54,9 +54,9 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
end
##
- # Calls convert_string on the result of convert_regexp_handling
+ # Calls convert_string on the result of convert_special
- def convert_regexp_handling target
+ def convert_special special
convert_string super
end
diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb
index 9ae0fff8a7..c5e1f073f8 100644
--- a/lib/rdoc/markup/to_html.rb
+++ b/lib/rdoc/markup/to_html.rb
@@ -53,18 +53,18 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
@hard_break = "<br>\n"
# external links
- @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/,
- :HYPERLINK)
+ @markup.add_special(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/,
+ :HYPERLINK)
- add_regexp_handling_RDOCLINK
- add_regexp_handling_TIDYLINK
+ add_special_RDOCLINK
+ add_special_TIDYLINK
init_tags
end
- # :section: Regexp Handling
+ # :section: Special Handling
#
- # These methods are used by regexp handling markup added by RDoc::Markup#add_regexp_handling.
+ # These methods handle special markup added by RDoc::Markup#add_special.
def handle_RDOCLINK url # :nodoc:
case url
@@ -91,14 +91,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
end
##
- # +target+ is a <code><br></code>
+ # +special+ is a <code><br></code>
- def handle_regexp_HARD_BREAK target
+ def handle_special_HARD_BREAK special
'<br>'
end
##
- # +target+ is a potential link. The following schemes are handled:
+ # +special+ is a potential link. The following schemes are handled:
#
# <tt>mailto:</tt>::
# Inserted as-is.
@@ -109,14 +109,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
# <tt>link:</tt>::
# Reference to a local file relative to the output directory.
- def handle_regexp_HYPERLINK(target)
- url = target.text
+ def handle_special_HYPERLINK(special)
+ url = special.text
gen_url url, url
end
##
- # +target+ is an rdoc-schemed link that will be converted into a hyperlink.
+ # +special+ is an rdoc-schemed link that will be converted into a hyperlink.
#
# For the +rdoc-ref+ scheme the named reference will be returned without
# creating a link.
@@ -124,16 +124,16 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
# For the +rdoc-label+ scheme the footnote and label prefixes are stripped
# when creating a link. All other contents will be linked verbatim.
- def handle_regexp_RDOCLINK target
- handle_RDOCLINK target.text
+ def handle_special_RDOCLINK special
+ handle_RDOCLINK special.text
end
##
- # This +target+ is a link where the label is different from the URL
+ # This +special+ is a link where the label is different from the URL
# <tt>label[url]</tt> or <tt>{long label}[url]</tt>
- def handle_regexp_TIDYLINK(target)
- text = target.text
+ def handle_special_TIDYLINK(special)
+ text = special.text
return text unless
text =~ /^\{(.*)\}\[(.*?)\]$/ or text =~ /^(\S+)\[(.*?)\]$/
@@ -186,7 +186,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
@res << "\n<p>"
text = paragraph.text @hard_break
text = text.gsub(/\r?\n/, ' ')
- @res << to_html(text)
+ @res << wrap(to_html(text))
@res << "</p>\n"
end
@@ -200,7 +200,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
content = if verbatim.ruby? or parseable? text then
begin
- tokens = RDoc::Parser::RipperStateLex.parse text
+ tokens = RDoc::RipperStateLex.parse text
klass = ' class="ruby"'
result = RDoc::TokenStream.to_html tokens
@@ -312,7 +312,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
##
# Generate a link to +url+ with content +text+. Handles the special cases
- # for img: and link: described under handle_regexp_HYPERLINK
+ # for img: and link: described under handle_special_HYPERLINK
def gen_url url, text
scheme, url, id = parse_url url
diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb
index 9314f04fae..2911aee954 100644
--- a/lib/rdoc/markup/to_html_crossref.rb
+++ b/lib/rdoc/markup/to_html_crossref.rb
@@ -40,7 +40,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
@show_hash = @options.show_hash
crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
- @markup.add_regexp_handling crossref_re, :CROSSREF
+ @markup.add_special crossref_re, :CROSSREF
@cross_reference = RDoc::CrossReference.new @context
end
@@ -49,19 +49,16 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
# Creates a link to the reference +name+ if the name exists. If +text+ is
# given it is used as the link text, otherwise +name+ is used.
- def cross_reference name, text = nil, code = true
+ def cross_reference name, text = nil
lookup = name
name = name[1..-1] unless @show_hash if name[0, 1] == '#'
- if name =~ /(.*[^#:])@/
- text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
- code = false
- else
- text ||= name
- end
+ name = "#{CGI.unescape $'} at #{$1}" if name =~ /(.*[^#:])@/
+
+ text = name unless text
- link lookup, text, code
+ link lookup, text
end
##
@@ -71,8 +68,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
# example, ToHtml is found, even without the <tt>RDoc::Markup::</tt> prefix,
# because we look for it in module Markup first.
- def handle_regexp_CROSSREF(target)
- name = target.text
+ def handle_special_CROSSREF(special)
+ name = special.text
return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
@@ -90,22 +87,22 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
# Handles <tt>rdoc-ref:</tt> scheme links and allows RDoc::Markup::ToHtml to
# handle other schemes.
- def handle_regexp_HYPERLINK target
- return cross_reference $' if target.text =~ /\Ardoc-ref:/
+ def handle_special_HYPERLINK special
+ return cross_reference $' if special.text =~ /\Ardoc-ref:/
super
end
##
- # +target+ is an rdoc-schemed link that will be converted into a hyperlink.
+ # +special+ is an rdoc-schemed link that will be converted into a hyperlink.
# For the rdoc-ref scheme the cross-reference will be looked up and the
# given name will be used.
#
# All other contents are handled by
- # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK]
+ # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_special_RDOCLINK]
- def handle_regexp_RDOCLINK target
- url = target.text
+ def handle_special_RDOCLINK special
+ url = special.text
case url
when /\Ardoc-ref:/ then
@@ -122,14 +119,15 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
def gen_url url, text
return super unless url =~ /\Ardoc-ref:/
- name = $'
- cross_reference name, text, name == text
+ cross_reference $', text
end
##
# Creates an HTML link to +name+ with the given +text+.
- def link name, text, code = true
+ def link name, text
+ original_name = name
+
if name =~ /(.*[^#:])@/ then
name = $1
label = $'
@@ -137,27 +135,22 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
ref = @cross_reference.resolve name, text
+ text = ref.output_name @context if
+ RDoc::MethodAttr === ref and text == original_name
+
case ref
when String then
ref
else
path = ref.as_href @from_path
- if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
- text = "<code>#{text}</code>"
- end
-
if path =~ /#/ then
path << "-label-#{label}"
elsif ref.sections and
ref.sections.any? { |section| label == section.title } then
path << "##{label}"
else
- if ref.respond_to?(:aref)
- path << "##{ref.aref}-label-#{label}"
- else
- path << "#label-#{label}"
- end
+ path << "#label-#{label}"
end if label
"<a href=\"#{path}\">#{text}</a>"
diff --git a/lib/rdoc/markup/to_html_snippet.rb b/lib/rdoc/markup/to_html_snippet.rb
index 4eb36592b7..24aa1d32d9 100644
--- a/lib/rdoc/markup/to_html_snippet.rb
+++ b/lib/rdoc/markup/to_html_snippet.rb
@@ -44,7 +44,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
@mask = 0
@paragraphs = 0
- @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
+ @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
end
##
@@ -71,7 +71,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
text = paragraph.text @hard_break
- @res << "#{para}#{to_html text}\n"
+ @res << "#{para}#{wrap to_html text}\n"
add_paragraph
end
@@ -123,16 +123,16 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
end
##
- # Removes escaping from the cross-references in +target+
+ # Removes escaping from the cross-references in +special+
- def handle_regexp_CROSSREF target
- target.text.sub(/\A\\/, '')
+ def handle_special_CROSSREF special
+ special.text.sub(/\A\\/, '')
end
##
- # +target+ is a <code><br></code>
+ # +special+ is a <code><br></code>
- def handle_regexp_HARD_BREAK target
+ def handle_special_HARD_BREAK special
@characters -= 4
'<br>'
end
@@ -226,8 +226,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
when String then
text = convert_string item
res << truncate(text)
- when RDoc::Markup::RegexpHandling then
- text = convert_regexp_handling item
+ when RDoc::Markup::Special then
+ text = convert_special item
res << truncate(text)
else
raise "Unknown flow element: #{item.inspect}"
diff --git a/lib/rdoc/markup/to_label.rb b/lib/rdoc/markup/to_label.rb
index 3d95ccc2e2..9f179013f2 100644
--- a/lib/rdoc/markup/to_label.rb
+++ b/lib/rdoc/markup/to_label.rb
@@ -16,8 +16,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
def initialize markup = nil
super nil, markup
- @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
- @markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
+ @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
+ @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
add_tag :BOLD, '', ''
add_tag :TT, '', ''
@@ -36,20 +36,20 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
end
##
- # Converts the CROSSREF +target+ to plain text, removing the suppression
+ # Converts the CROSSREF +special+ to plain text, removing the suppression
# marker, if any
- def handle_regexp_CROSSREF target
- text = target.text
+ def handle_special_CROSSREF special
+ text = special.text
text.sub(/^\\/, '')
end
##
- # Converts the TIDYLINK +target+ to just the text part
+ # Converts the TIDYLINK +special+ to just the text part
- def handle_regexp_TIDYLINK target
- text = target.text
+ def handle_special_TIDYLINK special
+ text = special.text
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
@@ -68,7 +68,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
alias accept_rule ignore
alias accept_verbatim ignore
alias end_accepting ignore
- alias handle_regexp_HARD_BREAK ignore
+ alias handle_special_HARD_BREAK ignore
alias start_accepting ignore
end
diff --git a/lib/rdoc/markup/to_markdown.rb b/lib/rdoc/markup/to_markdown.rb
index 3ee48becb0..d471032f9f 100644
--- a/lib/rdoc/markup/to_markdown.rb
+++ b/lib/rdoc/markup/to_markdown.rb
@@ -19,8 +19,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
@headings[5] = ['##### ', '']
@headings[6] = ['###### ', '']
- add_regexp_handling_RDOCLINK
- add_regexp_handling_TIDYLINK
+ add_special_RDOCLINK
+ add_special_TIDYLINK
@hard_break = " \n"
end
@@ -37,7 +37,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
##
# Adds a newline to the output
- def handle_regexp_HARD_BREAK target
+ def handle_special_HARD_BREAK special
" \n"
end
@@ -131,7 +131,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
@res << part
end
- @res << "\n"
+ @res << "\n" unless @res =~ /\n\z/
end
##
@@ -166,8 +166,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
##
# Converts the RDoc markup tidylink into a Markdown.style link.
- def handle_regexp_TIDYLINK target
- text = target.text
+ def handle_special_TIDYLINK special
+ text = special.text
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
@@ -184,8 +184,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
##
# Converts the rdoc-...: links into a Markdown.style links.
- def handle_regexp_RDOCLINK target
- handle_rdoc_link target.text
+ def handle_special_RDOCLINK special
+ handle_rdoc_link special.text
end
end
diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb
index 81b16c4973..1cb4d6bab2 100644
--- a/lib/rdoc/markup/to_rdoc.rb
+++ b/lib/rdoc/markup/to_rdoc.rb
@@ -45,7 +45,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
def initialize markup = nil
super nil, markup
- @markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
+ @markup.add_special(/\\\S/, :SUPPRESSED_CROSSREF)
@width = 78
init_tags
@@ -234,7 +234,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
@res << part
end
- @res << "\n"
+ @res << "\n" unless @res =~ /\n\z/
end
##
@@ -253,10 +253,10 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
end
##
- # Removes preceding \\ from the suppressed crossref +target+
+ # Removes preceding \\ from the suppressed crossref +special+
- def handle_regexp_SUPPRESSED_CROSSREF target
- text = target.text
+ def handle_special_SUPPRESSED_CROSSREF special
+ text = special.text
text = text.sub('\\', '') unless in_tt?
text
end
@@ -264,7 +264,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
##
# Adds a newline to the output
- def handle_regexp_HARD_BREAK target
+ def handle_special_HARD_BREAK special
"\n"
end
diff --git a/lib/rdoc/markup/to_tt_only.rb b/lib/rdoc/markup/to_tt_only.rb
index 9235d33f04..4f43546e3d 100644
--- a/lib/rdoc/markup/to_tt_only.rb
+++ b/lib/rdoc/markup/to_tt_only.rb
@@ -91,8 +91,8 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
when RDoc::Markup::AttrChanger then
off_tags res, item
on_tags res, item
- when RDoc::Markup::RegexpHandling then
- @res << convert_regexp_handling(item) if in_tt? # TODO can this happen?
+ when RDoc::Markup::Special then
+ @res << convert_special(item) if in_tt? # TODO can this happen?
else
raise "Unknown flow element: #{item.inspect}"
end
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index 43494c85be..17bbca81fe 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -164,7 +164,7 @@ class RDoc::Options
##
# Files matching this pattern will be excluded
- attr_writer :exclude
+ attr_accessor :exclude
##
# The list of files to be processed
@@ -344,10 +344,7 @@ class RDoc::Options
def init_ivars # :nodoc:
@dry_run = false
- @exclude = %w[
- ~\z \.orig\z \.rej\z \.bak\z
- \.gemspec\z
- ]
+ @exclude = []
@files = nil
@force_output = false
@force_update = true
@@ -497,20 +494,6 @@ class RDoc::Options
end
##
- # Create a regexp for #exclude
-
- def exclude
- if @exclude.nil? or Regexp === @exclude then
- # done, #finish is being re-run
- @exclude
- elsif @exclude.empty? then
- nil
- else
- Regexp.new(@exclude.join("|"))
- end
- end
-
- ##
# Completes any unfinished option setup business such as filtering for
# existent files, creating a regexp for #exclude and setting a default
# #template.
@@ -522,7 +505,13 @@ class RDoc::Options
root = @root.to_s
@rdoc_include << root unless @rdoc_include.include?(root)
- @exclude = self.exclude
+ if @exclude.nil? or Regexp === @exclude then
+ # done, #finish is being re-run
+ elsif @exclude.empty? then
+ @exclude = nil
+ else
+ @exclude = Regexp.new(@exclude.join("|"))
+ end
finish_page_dir
@@ -555,13 +544,7 @@ class RDoc::Options
@files << @page_dir.to_s
- page_dir = nil
- begin
- page_dir = @page_dir.expand_path.relative_path_from @root
- rescue ArgumentError
- # On Windows, sometimes crosses different drive letters.
- page_dir = @page_dir.expand_path
- end
+ page_dir = @page_dir.expand_path.relative_path_from @root
@page_dir = page_dir
end
@@ -1160,17 +1143,8 @@ Usage: #{opt.program_name} [options] [names...]
path.reject do |item|
path = Pathname.new(item).expand_path
- is_reject = nil
- relative = nil
- begin
- relative = path.relative_path_from(dot).to_s
- rescue ArgumentError
- # On Windows, sometimes crosses different drive letters.
- is_reject = true
- else
- is_reject = relative.start_with? '..'
- end
- is_reject
+ relative = path.relative_path_from(dot).to_s
+ relative.start_with? '..'
end
end
@@ -1243,7 +1217,7 @@ Usage: #{opt.program_name} [options] [names...]
def write_options
RDoc.load_yaml
- File.open '.rdoc_options', 'w' do |io|
+ open '.rdoc_options', 'w' do |io|
io.set_encoding Encoding::UTF_8
YAML.dump self, io
diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb
index 597bcd6b9d..2b826d9284 100644
--- a/lib/rdoc/parser.rb
+++ b/lib/rdoc/parser.rb
@@ -139,7 +139,7 @@ class RDoc::Parser
# Returns the file type from the modeline in +file_name+
def self.check_modeline file_name
- line = File.open file_name do |io|
+ line = open file_name do |io|
io.gets
end
diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb
index 8265712370..183538d54b 100644
--- a/lib/rdoc/parser/c.rb
+++ b/lib/rdoc/parser/c.rb
@@ -3,15 +3,15 @@ require 'tsort'
##
# RDoc::Parser::C attempts to parse C extension files. It looks for
-# the standard patterns that you find in extensions: +rb_define_class+,
-# +rb_define_method+ and so on. It tries to find the corresponding
+# the standard patterns that you find in extensions: <tt>rb_define_class,
+# rb_define_method</tt> and so on. It tries to find the corresponding
# C source for the methods and extract comments, but if we fail
# we don't worry too much.
#
# The comments associated with a Ruby method are extracted from the C
# comment block associated with the routine that _implements_ that
# method, that is to say the method whose name is given in the
-# +rb_define_method+ call. For example, you might write:
+# <tt>rb_define_method</tt> call. For example, you might write:
#
# /*
# * Returns a new array that is a one-dimensional flattening of this
@@ -24,7 +24,8 @@ require 'tsort'
# * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# */
# static VALUE
-# rb_ary_flatten(VALUE ary)
+# rb_ary_flatten(ary)
+# VALUE ary;
# {
# ary = rb_obj_dup(ary);
# rb_ary_flatten_bang(ary);
@@ -34,16 +35,16 @@ require 'tsort'
# ...
#
# void
-# Init_Array(void)
+# Init_Array()
# {
# ...
# rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
#
-# Here RDoc will determine from the +rb_define_method+ line that there's a
+# Here RDoc will determine from the rb_define_method line that there's a
# method called "flatten" in class Array, and will look for the implementation
-# in the method +rb_ary_flatten+. It will then use the comment from that
+# in the method rb_ary_flatten. It will then use the comment from that
# method in the HTML output. This method must be in the same source file
-# as the +rb_define_method+.
+# as the rb_define_method.
#
# The comment blocks may include special directives:
#
@@ -69,15 +70,15 @@ require 'tsort'
# [Document-variable: +name+]
# Documentation for the named +rb_define_variable+
#
-# [Document-method\: +method_name+]
+# [Document-method: +method_name+]
# Documentation for the named method. Use this when the method name is
# unambiguous.
#
-# [Document-method\: <tt>ClassName::method_name</tt>]
+# [Document-method: <tt>ClassName::method_name<tt>]
# Documentation for a singleton method in the given class. Use this when
# the method name alone is ambiguous.
#
-# [Document-method\: <tt>ClassName#method_name</tt>]
+# [Document-method: <tt>ClassName#method_name<tt>]
# Documentation for a instance method in the given class. Use this when the
# method name alone is ambiguous.
#
@@ -216,7 +217,6 @@ class RDoc::Parser::C < RDoc::Parser
def deduplicate_call_seq
@methods.each do |var_name, functions|
class_name = @known_classes[var_name]
- next unless class_name
class_obj = find_class var_name, class_name
functions.each_value do |method_names|
@@ -324,100 +324,12 @@ class RDoc::Parser::C < RDoc::Parser
# Scans #content for rb_define_class, boot_defclass, rb_define_class_under
# and rb_singleton_class
- def do_classes_and_modules
- do_boot_defclass if @file_name == "class.c"
-
- @content.scan(
- %r(
- (?<var_name>[\w\.]+)\s* =
- \s*rb_(?:
- define_(?:
- class(?: # rb_define_class(class_name_1, parent_name_1)
- \s*\(
- \s*"(?<class_name_1>\w+)",
- \s*(?<parent_name_1>\w+)\s*
- \)
- |
- _under\s*\( # rb_define_class_under(class_under, class_name2, parent_name2...)
- \s* (?<class_under>\w+),
- \s* "(?<class_name_2>\w+)",
- \s*
- (?:
- (?<parent_name_2>[\w\*\s\(\)\.\->]+) |
- rb_path2class\("(?<path>[\w:]+)"\)
- )
- \s*\)
- )
- |
- module(?: # rb_define_module(module_name_1)
- \s*\(
- \s*"(?<module_name_1>\w+)"\s*
- \)
- |
- _under\s*\( # rb_define_module_under(module_under, module_name_1)
- \s*(?<module_under>\w+),
- \s*"(?<module_name_2>\w+)"
- \s*\)
- )
- )
- |
- struct_define_without_accessor\s*\( # rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
- \s*"(?<class_name_3>\w+)",
- \s*(?<parent_name_3>\w+),
- \s*\w+, # Allocation function
- (?:\s*"\w+",)* # Attributes
- \s*NULL
- \)
- |
- singleton_class\s*\( # rb_singleton_class(target_class_name)
- \s*(?<target_class_name>\w+)
- \)
- )
- )mx
- ) do
- class_name = $~[:class_name_1]
- type = :class
- if class_name
- # rb_define_class(class_name_1, parent_name_1)
- parent_name = $~[:parent_name_1]
- #under = nil
- else
- class_name = $~[:class_name_2]
- if class_name
- # rb_define_class_under(class_under, class_name2, parent_name2...)
- parent_name = $~[:parent_name_2] || $~[:path]
- under = $~[:class_under]
- else
- class_name = $~[:class_name_3]
- if class_name
- # rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
- parent_name = $~[:parent_name_3]
- #under = nil
- else
- type = :module
- class_name = $~[:module_name_1]
- #parent_name = nil
- if class_name
- # rb_define_module(module_name_1)
- #under = nil
- else
- class_name = $~[:module_name_2]
- if class_name
- # rb_define_module_under(module_under, module_name_1)
- under = $~[:module_under]
- else
- # rb_singleton_class(target_class_name)
- target_class_name = $~[:target_class_name]
- handle_singleton $~[:var_name], target_class_name
- next
- end
- end
- end
- end
- end
-
- handle_class_module($~[:var_name], type, class_name, parent_name, under)
- end
+ def do_classes
+ do_boot_defclass
+ do_define_class
+ do_define_class_under
+ do_singleton_class
+ do_struct_define_without_accessor
end
##
@@ -466,6 +378,65 @@ class RDoc::Parser::C < RDoc::Parser
end
end
+ ##
+ # Scans #content for rb_define_class
+
+ def do_define_class
+ # The '.' lets us handle SWIG-generated files
+ @content.scan(/([\w\.]+)\s* = \s*rb_define_class\s*
+ \(
+ \s*"(\w+)",
+ \s*(\w+)\s*
+ \)/mx) do |var_name, class_name, parent|
+ handle_class_module(var_name, :class, class_name, parent, nil)
+ end
+ end
+
+ ##
+ # Scans #content for rb_define_class_under
+
+ def do_define_class_under
+ @content.scan(/([\w\.]+)\s* = # var_name
+ \s*rb_define_class_under\s*
+ \(
+ \s* (\w+), # under
+ \s* "(\w+)", # class_name
+ \s*
+ (?:
+ ([\w\*\s\(\)\.\->]+) | # parent_name
+ rb_path2class\("([\w:]+)"\) # path
+ )
+ \s*
+ \)
+ /mx) do |var_name, under, class_name, parent_name, path|
+ parent = path || parent_name
+
+ handle_class_module var_name, :class, class_name, parent, under
+ end
+ end
+
+ ##
+ # Scans #content for rb_define_module
+
+ def do_define_module
+ @content.scan(/(\w+)\s* = \s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do
+ |var_name, class_name|
+ handle_class_module(var_name, :module, class_name, nil, nil)
+ end
+ end
+
+ ##
+ # Scans #content for rb_define_module_under
+
+ def do_define_module_under
+ @content.scan(/(\w+)\s* = \s*rb_define_module_under\s*
+ \(
+ \s*(\w+),
+ \s*"(\w+)"
+ \s*\)/mx) do |var_name, in_module, class_name|
+ handle_class_module(var_name, :module, class_name, nil, in_module)
+ end
+ end
##
# Scans #content for rb_include_module
@@ -475,7 +446,7 @@ class RDoc::Parser::C < RDoc::Parser
next unless cls = @classes[c]
m = @known_classes[m] || m
- comment = RDoc::Comment.new '', @top_level, :c
+ comment = RDoc::Comment.new '', @top_level
incl = cls.add_include RDoc::Include.new(m, comment)
incl.record_location @top_level
end
@@ -548,6 +519,42 @@ class RDoc::Parser::C < RDoc::Parser
end
##
+ # Scans #content for rb_define_module and rb_define_module_under
+
+ def do_modules
+ do_define_module
+ do_define_module_under
+ end
+
+ ##
+ # Scans #content for rb_singleton_class
+
+ def do_singleton_class
+ @content.scan(/([\w\.]+)\s* = \s*rb_singleton_class\s*
+ \(
+ \s*(\w+)
+ \s*\)/mx) do |sclass_var, class_var|
+ handle_singleton sclass_var, class_var
+ end
+ end
+
+ ##
+ # Scans #content for struct_define_without_accessor
+
+ def do_struct_define_without_accessor
+ @content.scan(/([\w\.]+)\s* = \s*rb_struct_define_without_accessor\s*
+ \(
+ \s*"(\w+)", # Class name
+ \s*(\w+), # Parent class
+ \s*\w+, # Allocation function
+ (\s*"\w+",)* # Attributes
+ \s*NULL
+ \)/mx) do |var_name, class_name, parent|
+ handle_class_module(var_name, :class, class_name, parent, nil)
+ end
+ end
+
+ ##
# Finds the comment for an alias on +class_name+ from +new_name+ to
# +old_name+
@@ -557,7 +564,7 @@ class RDoc::Parser::C < RDoc::Parser
\s*"#{Regexp.escape new_name}"\s*,
\s*"#{Regexp.escape old_name}"\s*\);%xm
- RDoc::Comment.new($1 || '', @top_level, :c)
+ RDoc::Comment.new($1 || '', @top_level)
end
##
@@ -596,7 +603,7 @@ class RDoc::Parser::C < RDoc::Parser
''
end
- RDoc::Comment.new comment, @top_level, :c
+ RDoc::Comment.new comment, @top_level
end
##
@@ -636,7 +643,7 @@ class RDoc::Parser::C < RDoc::Parser
case type
when :func_def
- comment = RDoc::Comment.new args[0], @top_level, :c
+ comment = RDoc::Comment.new args[0], @top_level
body = args[1]
offset, = args[2]
@@ -666,7 +673,7 @@ class RDoc::Parser::C < RDoc::Parser
body
when :macro_def
- comment = RDoc::Comment.new args[0], @top_level, :c
+ comment = RDoc::Comment.new args[0], @top_level
body = args[1]
offset, = args[2]
@@ -773,7 +780,7 @@ class RDoc::Parser::C < RDoc::Parser
comment = ''
end
- comment = RDoc::Comment.new comment, @top_level, :c
+ comment = RDoc::Comment.new comment, @top_level
comment.normalize
look_for_directives_in class_mod, comment
@@ -818,7 +825,7 @@ class RDoc::Parser::C < RDoc::Parser
table[const_name] ||
''
- RDoc::Comment.new comment, @top_level, :c
+ RDoc::Comment.new comment, @top_level
end
##
@@ -849,7 +856,7 @@ class RDoc::Parser::C < RDoc::Parser
return unless comment
- RDoc::Comment.new comment, @top_level, :c
+ RDoc::Comment.new comment, @top_level
end
##
@@ -945,7 +952,7 @@ class RDoc::Parser::C < RDoc::Parser
# can override the C value of the comment to give a friendly definition.
#
# /* 300: The perfect score in bowling */
- # rb_define_const(cFoo, "PERFECT", INT2FIX(300));
+ # rb_define_const(cFoo, "PERFECT", INT2FIX(300);
#
# Will override <tt>INT2FIX(300)</tt> with the value +300+ in the output
# RDoc. Values may include quotes and escaped colons (\:).
@@ -983,7 +990,7 @@ class RDoc::Parser::C < RDoc::Parser
new_comment = "#{$1}#{new_comment.lstrip}"
- new_comment = RDoc::Comment.new new_comment, @top_level, :c
+ new_comment = RDoc::Comment.new new_comment, @top_level
con = RDoc::Constant.new const_name, new_definition, new_comment
else
@@ -1240,7 +1247,8 @@ class RDoc::Parser::C < RDoc::Parser
def scan
remove_commented_out_lines
- do_classes_and_modules
+ do_modules
+ do_classes
do_missing
do_constants
@@ -1257,3 +1265,4 @@ class RDoc::Parser::C < RDoc::Parser
end
end
+
diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb
index 5492f08726..b7cec84bfc 100644
--- a/lib/rdoc/parser/ripper_state_lex.rb
+++ b/lib/rdoc/parser/ripper_state_lex.rb
@@ -1,12 +1,9 @@
-# frozen_string_literal: true
require 'ripper'
-class RDoc::Parser::RipperStateLex
+class RDoc::RipperStateLex
# TODO: Remove this constants after Ruby 2.4 EOL
RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
- Token = Struct.new(:line_no, :char_no, :kind, :text, :state)
-
EXPR_NONE = 0
EXPR_BEG = 1
EXPR_END = 2
@@ -50,7 +47,7 @@ class RDoc::Parser::RipperStateLex
@continue = false
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_ignored_nl(tok, data)
@@ -61,7 +58,7 @@ class RDoc::Parser::RipperStateLex
@continue = false
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_op(tok, data)
@@ -86,15 +83,6 @@ class RDoc::Parser::RipperStateLex
when '&&', '||', '+=', '-=', '*=', '**=',
'&=', '|=', '^=', '<<=', '>>=', '||=', '&&='
@lex_state = EXPR_BEG
- when '::'
- case @lex_state
- when EXPR_ARG, EXPR_CMDARG
- @lex_state = EXPR_DOT
- when EXPR_FNAME, EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_BEG
- end
else
case @lex_state
when EXPR_FNAME, EXPR_DOT
@@ -103,7 +91,7 @@ class RDoc::Parser::RipperStateLex
@lex_state = EXPR_BEG
end
end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_kw(tok, data)
@@ -116,15 +104,13 @@ class RDoc::Parser::RipperStateLex
@continue = true
@in_fname = true
when 'if', 'unless', 'while', 'until'
- if ((EXPR_MID | EXPR_END | EXPR_ENDARG | EXPR_ENDFN | EXPR_ARG | EXPR_CMDARG) & @lex_state) != 0 # postfix if
+ if ((EXPR_END | EXPR_ENDARG | EXPR_ENDFN | EXPR_ARG | EXPR_CMDARG) & @lex_state) != 0 # postfix if
@lex_state = EXPR_BEG | EXPR_LABEL
else
@lex_state = EXPR_BEG
end
- when 'begin', 'case', 'when'
+ when 'begin'
@lex_state = EXPR_BEG
- when 'return', 'break'
- @lex_state = EXPR_MID
else
if @lex_state == EXPR_FNAME
@lex_state = EXPR_END
@@ -132,54 +118,54 @@ class RDoc::Parser::RipperStateLex
@lex_state = EXPR_END
end
end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_tstring_beg(tok, data)
@lex_state = EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_tstring_end(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_CHAR(tok, data)
@lex_state = EXPR_END
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_period(tok, data)
@lex_state = EXPR_DOT
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_int(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_float(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_rational(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_imaginary(tok, data)
@lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_symbeg(tok, data)
@lex_state = EXPR_FNAME
@continue = true
@in_fname = true
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
private def on_variables(event, tok, data)
@@ -198,7 +184,7 @@ class RDoc::Parser::RipperStateLex
else
@lex_state = EXPR_CMDARG
end
- data << Token.new(lineno, column, event, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => event, :text => tok, :state => @lex_state})
end
def on_ident(tok, data)
@@ -227,80 +213,78 @@ class RDoc::Parser::RipperStateLex
def on_lparen(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_rparen(tok, data)
@lex_state = EXPR_ENDFN
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_lbrace(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_rbrace(tok, data)
@lex_state = EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_lbracket(tok, data)
@lex_state = EXPR_LABEL | EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_rbracket(tok, data)
@lex_state = EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_const(tok, data)
case @lex_state
when EXPR_FNAME
@lex_state = EXPR_ENDFN
- when EXPR_CLASS, EXPR_CMDARG, EXPR_MID
+ when EXPR_CLASS
@lex_state = EXPR_ARG
else
@lex_state = EXPR_CMDARG
end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_sp(tok, data)
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_comma(tok, data)
@lex_state = EXPR_BEG | EXPR_LABEL if (EXPR_ARG_ANY & @lex_state) != 0
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_comment(tok, data)
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_ignored_sp(tok, data)
@lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_heredoc_beg(tok, data)
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- @lex_state = EXPR_END
- data
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
end
def on_heredoc_end(tok, data)
- data << Token.new(lineno, column, __method__, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => __method__, :text => tok, :state => @lex_state})
@lex_state = EXPR_BEG
- data
end
def on_default(event, tok, data)
reset
- data << Token.new(lineno, column, event, tok, @lex_state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => event, :text => tok, :state => @lex_state})
+ end
+
+ def each(&block)
+ @callback = block
+ parse
end
end unless RIPPER_HAS_LEX_STATE
@@ -310,17 +294,21 @@ class RDoc::Parser::RipperStateLex
end
def on_default(event, tok, data)
- data << Token.new(lineno, column, event, tok, state)
+ @callback.call({ :line_no => lineno, :char_no => column, :kind => event, :text => tok, :state => state})
+ end
+
+ def each(&block)
+ @callback = block
+ parse
end
end if RIPPER_HAS_LEX_STATE
def get_squashed_tk
if @buf.empty?
- tk = @tokens.shift
+ tk = @inner_lex_enumerator.next
else
tk = @buf.shift
end
- return nil if tk.nil?
case tk[:kind]
when :on_symbeg then
tk = get_symbol_tk(tk)
@@ -342,10 +330,8 @@ class RDoc::Parser::RipperStateLex
@heredoc_queue << retrieve_heredoc_info(tk)
@inner_lex.lex_state = EXPR_END unless RIPPER_HAS_LEX_STATE
when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then
- if !@heredoc_queue.empty?
+ unless @heredoc_queue.empty?
get_heredoc_tk(*@heredoc_queue.shift)
- elsif tk[:text].nil? # :on_ignored_nl sometimes gives nil
- tk[:text] = ''
end
when :on_words_beg then
tk = get_words_tk(tk)
@@ -367,7 +353,7 @@ class RDoc::Parser::RipperStateLex
private def get_symbol_tk(tk)
is_symbol = true
- symbol_tk = Token.new(tk.line_no, tk.char_no, :on_symbol)
+ symbol_tk = { :line_no => tk[:line_no], :char_no => tk[:char_no], :kind => :on_symbol }
if ":'" == tk[:text] or ':"' == tk[:text]
tk1 = get_string_tk(tk)
symbol_tk[:text] = tk1[:text]
@@ -436,7 +422,13 @@ class RDoc::Parser::RipperStateLex
end
end
end
- Token.new(tk.line_no, tk.char_no, kind, string, state)
+ {
+ :line_no => tk[:line_no],
+ :char_no => tk[:char_no],
+ :kind => kind,
+ :text => string,
+ :state => state
+ }
end
private def get_regexp_tk(tk)
@@ -454,7 +446,13 @@ class RDoc::Parser::RipperStateLex
string = string + inner_str_tk[:text]
end
end
- Token.new(tk.line_no, tk.char_no, :on_regexp, string, state)
+ {
+ :line_no => tk[:line_no],
+ :char_no => tk[:char_no],
+ :kind => :on_regexp,
+ :text => string,
+ :state => state
+ }
end
private def get_embdoc_tk(tk)
@@ -463,14 +461,20 @@ class RDoc::Parser::RipperStateLex
string = string + embdoc_tk[:text]
end
string = string + embdoc_tk[:text]
- Token.new(tk.line_no, tk.char_no, :on_embdoc, string, embdoc_tk.state)
+ {
+ :line_no => tk[:line_no],
+ :char_no => tk[:char_no],
+ :kind => :on_embdoc,
+ :text => string,
+ :state => embdoc_tk[:state]
+ }
end
private def get_heredoc_tk(heredoc_name, indent)
string = ''
start_tk = nil
prev_tk = nil
- until heredoc_end?(heredoc_name, indent, tk = @tokens.shift) do
+ until heredoc_end?(heredoc_name, indent, tk = @inner_lex_enumerator.next) do
start_tk = tk unless start_tk
if (prev_tk.nil? or "\n" == prev_tk[:text][-1]) and 0 != tk[:char_no]
string = string + (' ' * tk[:char_no])
@@ -481,7 +485,13 @@ class RDoc::Parser::RipperStateLex
start_tk = tk unless start_tk
prev_tk = tk unless prev_tk
@buf.unshift tk # closing heredoc
- heredoc_tk = Token.new(start_tk.line_no, start_tk.char_no, :on_heredoc, string, prev_tk.state)
+ heredoc_tk = {
+ :line_no => start_tk[:line_no],
+ :char_no => start_tk[:char_no],
+ :kind => :on_heredoc,
+ :text => string,
+ :state => prev_tk[:state]
+ }
@buf.unshift heredoc_tk
end
@@ -494,8 +504,7 @@ class RDoc::Parser::RipperStateLex
private def heredoc_end?(name, indent, tk)
result = false
if :on_heredoc_end == tk[:kind] then
- tk_name = tk[:text].chomp
- tk_name.lstrip! if indent
+ tk_name = (indent ? tk[:text].gsub(/^ *(.+)\n?$/, '\1') : tk[:text].gsub(/\n\z/, ''))
if name == tk_name
result = true
end
@@ -538,7 +547,13 @@ class RDoc::Parser::RipperStateLex
end
end
text = "#{start_token}#{string}#{end_token}"
- Token.new(line_no, char_no, :on_dstring, text, state)
+ {
+ :line_no => line_no,
+ :char_no => char_no,
+ :kind => :on_dstring,
+ :text => text,
+ :state => state
+ }
end
private def get_op_tk(tk)
@@ -554,10 +569,6 @@ class RDoc::Parser::RipperStateLex
tk[:text] += tk_ahead[:text]
tk[:kind] = tk_ahead[:kind]
tk[:state] = tk_ahead[:state]
- when :on_heredoc_beg, :on_tstring, :on_dstring # frozen/non-frozen string literal
- tk[:text] += tk_ahead[:text]
- tk[:kind] = tk_ahead[:kind]
- tk[:state] = tk_ahead[:state]
else
@buf.unshift tk_ahead
end
@@ -569,7 +580,11 @@ class RDoc::Parser::RipperStateLex
@buf = []
@heredoc_queue = []
@inner_lex = InnerStateLex.new(code)
- @tokens = @inner_lex.parse([])
+ @inner_lex_enumerator = Enumerator.new do |y|
+ @inner_lex.each do |tk|
+ y << tk
+ end
+ end
end
def self.parse(code)
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index 8d021f3c6d..8599f655ad 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -8,6 +8,8 @@
# by Keiju ISHITSUKA (Nippon Rational Inc.)
#
+$TOKEN_DEBUG ||= nil
+
##
# Extracts code elements from a source file returning a TopLevel object
# containing the constituent file elements.
@@ -139,7 +141,6 @@
# standard rdocable item following it.
require 'ripper'
-require_relative 'ripper_state_lex'
class RDoc::Parser::Ruby < RDoc::Parser
@@ -176,8 +177,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
@size = 0
@token_listeners = nil
- content = RDoc::Encoding.remove_magic_comment content
- @scanner = RDoc::Parser::RipperStateLex.parse(content)
+ @scanner = RDoc::RipperStateLex.parse(content)
@content = content
@scanner_point = 0
@prev_seek = nil
@@ -244,16 +244,14 @@ class RDoc::Parser::Ruby < RDoc::Parser
comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
first_line = true
first_comment_tk_kind = nil
- line_no = nil
tk = get_tk
while tk && (:on_comment == tk[:kind] or :on_embdoc == tk[:kind])
- comment_body = retrieve_comment_body(tk)
- if first_line and comment_body =~ /\A#!/ then
+ if first_line and tk[:text] =~ /\A#!/ then
skip_tkspace
tk = get_tk
- elsif first_line and comment_body =~ /\A#\s*-\*-/ then
+ elsif first_line and tk[:text] =~ /\A#\s*-\*-/ then
first_line = false
skip_tkspace
tk = get_tk
@@ -261,13 +259,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
break if first_comment_tk_kind and not first_comment_tk_kind === tk[:kind]
first_comment_tk_kind = tk[:kind]
- line_no = tk[:line_no] if first_line
first_line = false
- comment << comment_body
+ comment << tk[:text]
tk = get_tk
if :on_nl === tk then
- skip_tkspace_without_nl
+ skip_tkspace false
tk = get_tk
end
end
@@ -275,14 +272,14 @@ class RDoc::Parser::Ruby < RDoc::Parser
unget_tk tk
- new_comment comment, line_no
+ new_comment comment
end
##
# Consumes trailing whitespace from the token stream
def consume_trailing_spaces # :nodoc:
- skip_tkspace_without_nl
+ skip_tkspace false
end
##
@@ -309,7 +306,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
container.find_module_named rhs_name
end
- container.add_module_alias mod, rhs_name, constant, @top_level
+ container.add_module_alias mod, constant.name, @top_level if mod
end
##
@@ -354,20 +351,16 @@ class RDoc::Parser::Ruby < RDoc::Parser
given_name << '::'
end
- skip_tkspace_without_nl
+ skip_tkspace false
given_name << name_t[:text]
is_self = name_t[:kind] == :on_op && name_t[:text] == '<<'
- new_modules = []
while !is_self && (tk = peek_tk) and :on_op == tk[:kind] and '::' == tk[:text] do
prev_container = container
container = container.find_module_named name_t[:text]
container ||=
if ignore_constants then
- c = RDoc::NormalModule.new name_t[:text]
- c.store = @store
- new_modules << [prev_container, c]
- c
+ RDoc::Context.new
else
c = prev_container.add_module RDoc::NormalModule, name_t[:text]
c.ignore unless prev_container.document_children
@@ -378,11 +371,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
record_location container
get_tk
- skip_tkspace
- if :on_lparen == peek_tk[:kind] # ProcObjectInConstant::()
- parse_method_or_yield_parameters
- break
- end
+ skip_tkspace false
name_t = get_tk
unless :on_const == name_t[:kind] || :on_ident == name_t[:kind]
raise RDoc::Error, "Invalid class or module definition: #{given_name}"
@@ -394,9 +383,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
end
- skip_tkspace_without_nl
+ skip_tkspace false
- return [container, name_t, given_name, new_modules]
+ return [container, name_t, given_name]
end
##
@@ -414,7 +403,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
res = get_constant
- skip_tkspace_without_nl
+ skip_tkspace false
get_tkread # empty out read buffer
@@ -437,7 +426,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def get_constant
res = ""
- skip_tkspace_without_nl
+ skip_tkspace false
tk = get_tk
while tk && ((:on_op == tk[:kind] && '::' == tk[:text]) || :on_const == tk[:kind]) do
@@ -450,83 +439,28 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
##
- # Get an included module that may be surrounded by parens
+ # Get a constant that may be surrounded by parens
- def get_included_module_with_optional_parens
- skip_tkspace_without_nl
- get_tkread
- tk = get_tk
- end_token = get_end_token tk
- return '' unless end_token
+ def get_constant_with_optional_parens
+ skip_tkspace false
nest = 0
- continue = false
- only_constant = true
- while tk != nil do
- is_element_of_constant = false
- case tk[:kind]
- when :on_semicolon then
- break if nest == 0
- when :on_lbracket then
- nest += 1
- when :on_rbracket then
- nest -= 1
- when :on_lbrace then
- nest += 1
- when :on_rbrace then
- nest -= 1
- if nest <= 0
- # we might have a.each { |i| yield i }
- unget_tk(tk) if nest < 0
- break
- end
- when :on_lparen then
- nest += 1
- when end_token[:kind] then
- if end_token[:kind] == :on_rparen
- nest -= 1
- break if nest <= 0
- else
- break if nest <= 0
- end
- when :on_rparen then
- nest -= 1
- when :on_comment, :on_embdoc then
- @read.pop
- if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
- (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
- break if !continue and nest <= 0
- end
- when :on_comma then
- continue = true
- when :on_ident then
- continue = false if continue
- when :on_kw then
- case tk[:text]
- when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
- nest += 1
- when 'if', 'unless', 'while', 'until', 'rescue'
- # postfix if/unless/while/until/rescue must be EXPR_LABEL
- nest += 1 unless (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0
- when 'end'
- nest -= 1
- break if nest == 0
- end
- when :on_const then
- is_element_of_constant = true
- when :on_op then
- is_element_of_constant = true if '::' == tk[:text]
- end
- only_constant = false unless is_element_of_constant
- tk = get_tk
+ while :on_lparen == (tk = peek_tk)[:kind] do
+ get_tk
+ skip_tkspace
+ nest += 1
end
- if only_constant
- get_tkread_clean(/\s+/, ' ')
- else
- ''
+ name = get_constant
+
+ while nest > 0
+ skip_tkspace
+ tk = get_tk
+ nest -= 1 if :on_rparen == tk[:kind]
end
+
+ name
end
##
@@ -540,17 +474,17 @@ class RDoc::Parser::Ruby < RDoc::Parser
def get_end_token tk # :nodoc:
case tk[:kind]
when :on_lparen
- token = RDoc::Parser::RipperStateLex::Token.new
- token[:kind] = :on_rparen
- token[:text] = ')'
- token
+ {
+ :kind => :on_rparen,
+ :text => ')'
+ }
when :on_rparen
nil
else
- token = RDoc::Parser::RipperStateLex::Token.new
- token[:kind] = :on_nl
- token[:text] = "\n"
- token
+ {
+ :kind => :on_nl,
+ :text => "\n"
+ }
end
end
@@ -672,9 +606,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
##
# Creates a comment with the correct format
- def new_comment comment, line_no = nil
- c = RDoc::Comment.new comment, @top_level, :ruby
- c.line = line_no
+ def new_comment comment
+ c = RDoc::Comment.new comment, @top_level
c.format = @markup
c
end
@@ -690,7 +623,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
if args.size > 0 then
name = args[0]
rw = "R"
- skip_tkspace_without_nl
+ skip_tkspace false
tk = get_tk
if :on_comma == tk[:kind] then
@@ -801,9 +734,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
when end_token
if end_token == :on_rparen
nest -= 1
- break if RDoc::Parser::RipperStateLex.end?(tk) and nest <= 0
+ break if RDoc::RipperStateLex.end?(tk) and nest <= 0
else
- break if RDoc::Parser::RipperStateLex.end?(tk)
+ break if RDoc::RipperStateLex.end?(tk)
end
when :on_comment, :on_embdoc
unget_tk(tk)
@@ -827,7 +760,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
line_no = tk[:line_no]
declaration_context = container
- container, name_t, given_name, = get_class_or_module container
+ container, name_t, given_name = get_class_or_module container
if name_t[:kind] == :on_const
cls = parse_class_regular container, declaration_context, single,
@@ -940,15 +873,14 @@ class RDoc::Parser::Ruby < RDoc::Parser
line_no = tk[:line_no]
name = tk[:text]
- skip_tkspace_without_nl
+ skip_tkspace false
return unless name =~ /^\w+$/
- new_modules = []
if :on_op == peek_tk[:kind] && '::' == peek_tk[:text] then
unget_tk tk
- container, name_t, _, new_modules = get_class_or_module container, true
+ container, name_t, = get_class_or_module container, ignore_constants
name = name_t[:text]
end
@@ -966,7 +898,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
break if nest == 0
end
end
- skip_tkspace_without_nl
+ skip_tkspace false
is_array_or_hash = true
end
@@ -975,14 +907,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
get_tk
- unless ignore_constants
- new_modules.each do |prev_c, new_module|
- prev_c.add_module_by_normal_module new_module
- new_module.ignore unless prev_c.document_children
- @top_level.add_to_classes_or_modules new_module
- end
- end
-
value = ''
con = RDoc::Constant.new name, value, comment
@@ -1021,7 +945,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
nest += 1
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
- if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
+ if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
nest += 1
end
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
@@ -1029,7 +953,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
nest -= 1
elsif (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
unget_tk tk
- if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
+ if nest <= 0 and RDoc::RipperStateLex.end?(tk) then
body = get_tkread_clean(/^[ \t]+/, '')
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
break
@@ -1045,7 +969,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
break
end
elsif :on_nl == tk[:kind] then
- if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
+ if nest <= 0 and RDoc::RipperStateLex.end?(tk) then
unget_tk tk
break
end
@@ -1065,14 +989,13 @@ class RDoc::Parser::Ruby < RDoc::Parser
def parse_comment container, tk, comment
return parse_comment_tomdoc container, tk, comment if @markup == 'tomdoc'
column = tk[:char_no]
- line_no = comment.line.nil? ? tk[:line_no] : comment.line
+ line_no = tk[:line_no]
comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3')
singleton = !!$~
co =
if (comment.text = comment.text.sub(/^# +:?method: *(\S*).*?\n/i, '')) && !!$~ then
- line_no += $`.count("\n")
parse_comment_ghost container, comment.text, $1, column, line_no, comment
elsif (comment.text = comment.text.sub(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '')) && !!$~ then
parse_comment_attr container, $1, $3, comment
@@ -1110,10 +1033,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
record_location meth
meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
+ indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
+ position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
+ newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
meth.add_tokens [position_comment, newline, indent]
meth.params =
@@ -1153,10 +1076,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
meth.line = line_no
meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
+ indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
+ position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
+ newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
meth.add_tokens [position_comment, newline, indent]
meth.call_seq = signature
@@ -1180,7 +1103,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
loop do
skip_tkspace_comment
- name = get_included_module_with_optional_parens
+ name = get_constant_with_optional_parens
unless name.empty? then
obj = container.add klass, name, comment
@@ -1304,7 +1227,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
add_token tk
add_token_listener self
- skip_tkspace_without_nl
+ skip_tkspace false
comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3')
singleton = !!$~
@@ -1321,10 +1244,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
remove_token_listener self
meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
+ indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
+ position_comment = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
+ newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
meth.add_tokens [position_comment, newline, indent]
meth.add_tokens @token_stream
@@ -1424,10 +1347,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
meth.line = line_no
meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- token = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
+ indent = { :line_no => 1, :char_no => 1, :kind => :on_sp, :text => ' ' * column }
+ token = { :line_no => line_no, :char_no => 1, :kind => :on_comment }
token[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
+ newline = { :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" }
meth.add_tokens [token, newline, indent]
meth.add_tokens @token_stream
@@ -1493,7 +1416,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def parse_method_name container # :nodoc:
skip_tkspace
name_t = get_tk
- back_tk = skip_tkspace_without_nl
+ back_tk = skip_tkspace(false)
singleton = false
dot = get_tk
@@ -1581,7 +1504,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def parse_method_or_yield_parameters(method = nil,
modifiers = RDoc::METHOD_MODIFIERS)
- skip_tkspace_without_nl
+ skip_tkspace false
tk = get_tk
end_token = get_end_token tk
return '' unless end_token
@@ -1593,10 +1516,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
case tk[:kind]
when :on_semicolon then
break if nest == 0
- when :on_lbracket then
- nest += 1
- when :on_rbracket then
- nest -= 1
when :on_lbrace then
nest += 1
when :on_rbrace then
@@ -1620,7 +1539,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
when :on_comment, :on_embdoc then
@read.pop
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
- (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
+ (!continue or (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) != 0) then
if method && method.block_params.nil? then
unget_tk tk
read_documentation_modifiers method, modifiers
@@ -1654,7 +1573,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
return if method.block_params
- skip_tkspace_without_nl
+ skip_tkspace false
read_documentation_modifiers method, RDoc::METHOD_MODIFIERS
end
@@ -1705,30 +1624,19 @@ class RDoc::Parser::Ruby < RDoc::Parser
# Parses a rescue
def parse_rescue
- skip_tkspace_without_nl
+ skip_tkspace false
while tk = get_tk
case tk[:kind]
when :on_nl, :on_semicolon, :on_comment then
break
when :on_comma then
- skip_tkspace_without_nl
+ skip_tkspace false
get_tk if :on_nl == peek_tk[:kind]
end
- skip_tkspace_without_nl
- end
- end
-
- ##
- # Retrieve comment body without =begin/=end
-
- def retrieve_comment_body(tk)
- if :on_embdoc == tk[:kind]
- tk[:text].gsub(/\A=begin.*\n/, '').gsub(/=end\n?\z/, '')
- else
- tk[:text]
+ skip_tkspace false
end
end
@@ -1784,20 +1692,17 @@ class RDoc::Parser::Ruby < RDoc::Parser
comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
end
- line_no = nil
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
- comment_body = retrieve_comment_body(tk)
- line_no = tk[:line_no] if comment.empty?
- comment += comment_body
- comment << "\n" unless comment_body =~ /\n\z/
+ comment += tk[:text]
+ comment += "\n" unless "\n" == tk[:text].chars.to_a.last
- if comment_body.size > 1 && comment_body =~ /\n\z/ then
- skip_tkspace_without_nl # leading spaces
+ if tk[:text].size > 1 && "\n" == tk[:text].chars.to_a.last then
+ skip_tkspace false # leading spaces
end
tk = get_tk
end
- comment = new_comment comment, line_no
+ comment = new_comment comment
unless comment.empty? then
look_for_directives_in container, comment
@@ -1839,7 +1744,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
when 'until', 'while' then
- if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
+ if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
nest += 1
skip_optional_do_after_expression
end
@@ -1855,7 +1760,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
skip_optional_do_after_expression
when 'case', 'do', 'if', 'unless', 'begin' then
- if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
+ if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
nest += 1
end
@@ -1976,7 +1881,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
loop do
- skip_tkspace_without_nl
+ skip_tkspace false
tk1 = get_tk
if tk1.nil? || :on_comma != tk1[:kind] then
@@ -2125,7 +2030,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
# See also RDoc::Markup::PreProcess#handle_directive
def read_documentation_modifiers context, allowed
- skip_tkspace_without_nl
+ skip_tkspace(false)
directive, value = read_directive allowed
return unless directive
@@ -2169,16 +2074,13 @@ class RDoc::Parser::Ruby < RDoc::Parser
$stderr.puts @file_name
return
end
+ bytes = ''
if @scanner_point >= @scanner.size
now_line_no = @scanner[@scanner.size - 1][:line_no]
else
now_line_no = peek_tk[:line_no]
end
- first_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no }
- last_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 }
- last_tk_index = last_tk_index ? last_tk_index - 1 : @scanner.size - 1
- code = @scanner[first_tk_index..last_tk_index].map{ |t| t[:text] }.join
$stderr.puts <<-EOF
@@ -2187,9 +2089,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
EOF
- unless code.empty? then
- $stderr.puts code
+ unless bytes.empty? then
$stderr.puts
+ now_line_no = peek_tk[:line_no]
+ start_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no }
+ end_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 } - 1
+ $stderr.puts @scanner[start_index..end_index].join
end
raise e
@@ -2203,7 +2108,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
# while, until, and for have an optional do
def skip_optional_do_after_expression
- skip_tkspace_without_nl
+ skip_tkspace false
tk = get_tk
b_nest = 0
@@ -2235,7 +2140,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
tk = get_tk
end
- skip_tkspace_without_nl
+ skip_tkspace false
get_tk if peek_tk && :on_kw == peek_tk[:kind] && 'do' == peek_tk[:text]
end
@@ -2244,9 +2149,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
# skip the var [in] part of a 'for' statement
def skip_for_variable
- skip_tkspace_without_nl
+ skip_tkspace false
get_tk
- skip_tkspace_without_nl
+ skip_tkspace false
tk = get_tk
unget_tk(tk) unless :on_kw == tk[:kind] and 'in' == tk[:text]
end
@@ -2265,7 +2170,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def skip_tkspace_comment(skip_nl = true)
loop do
- skip_nl ? skip_tkspace : skip_tkspace_without_nl
+ skip_tkspace skip_nl
next_tk = peek_tk
return if next_tk.nil? || (:on_comment != next_tk[:kind] and :on_embdoc != next_tk[:kind])
get_tk
diff --git a/lib/rdoc/parser/ruby_tools.rb b/lib/rdoc/parser/ruby_tools.rb
index 681d7166ce..1f621cd32e 100644
--- a/lib/rdoc/parser/ruby_tools.rb
+++ b/lib/rdoc/parser/ruby_tools.rb
@@ -25,10 +25,12 @@ module RDoc::Parser::RubyTools
tk = @scanner[@scanner_point]
@scanner_point += 1
@read.push tk[:text]
+ puts "get_tk1 => #{tk.inspect}" if $TOKEN_DEBUG
end
else
@read.push @unget_read.shift
tk = @tokens.shift
+ puts "get_tk2 => #{tk.inspect}" if $TOKEN_DEBUG
end
if tk == nil || :on___end__ == tk[:kind]
@@ -109,27 +111,17 @@ module RDoc::Parser::RubyTools
@scanner_point = 0
end
- ##
- # Skips whitespace tokens including newlines
-
- def skip_tkspace
- tokens = []
-
- while (tk = get_tk) and (:on_sp == tk[:kind] or :on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]) do
- tokens.push(tk)
- end
-
- unget_tk(tk)
- tokens
+ def tk_nl?(tk)
+ :on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]
end
##
- # Skips whitespace tokens excluding newlines
+ # Skips whitespace tokens including newlines if +skip_nl+ is true
- def skip_tkspace_without_nl
+ def skip_tkspace(skip_nl = true)
tokens = []
- while (tk = get_tk) and :on_sp == tk[:kind] do
+ while (tk = get_tk) and (:on_sp == tk[:kind] or (skip_nl and tk_nl?(tk))) do
tokens.push(tk)
end
diff --git a/lib/rdoc/rd/block_parser.rb b/lib/rdoc/rd/block_parser.rb
index be0b786bfc..3f4941168f 100644
--- a/lib/rdoc/rd/block_parser.rb
+++ b/lib/rdoc/rd/block_parser.rb
@@ -1,8 +1,7 @@
-# frozen_string_literal: true
#
# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
+# This file is automatically generated by Racc 1.4.14
+# from Racc grammer file "".
#
require 'racc/parser.rb'
@@ -208,7 +207,7 @@ def next_token # :nodoc:
if @in_verbatim
[:STRINGLINE, line]
else
- @indent_stack.push("\s" + newIndent)
+ @indent_stack.push("\s" << newIndent)
[:ITEMLISTLINE, rest]
end
end
@@ -220,7 +219,7 @@ def next_token # :nodoc:
if @in_verbatim
[:STRINGLINE, line]
else
- @indent_stack.push("\s" * mark.size + newIndent)
+ @indent_stack.push("\s" * mark.size << newIndent)
[:ENUMLISTLINE, rest]
end
end
@@ -420,52 +419,52 @@ end
racc_action_table = [
34, 35, 30, 33, 40, 34, 35, 30, 33, 40,
- 65, 34, 35, 30, 33, 14, 73, 36, 38, 34,
- 15, 88, 34, 35, 30, 33, 14, 9, 10, 11,
- 12, 15, 34, 35, 30, 33, 14, 9, 10, 11,
- 12, 15, 34, 35, 30, 33, 35, 47, 30, 54,
- 33, 15, 34, 35, 30, 33, 54, 47, 14, 14,
- 59, 15, 34, 35, 30, 33, 14, 73, 67, 76,
- 77, 15, 34, 35, 30, 33, 14, 73, 54, 81,
- 38, 15, 34, 35, 30, 33, 14, 73, 38, 40,
- 83, 15, 34, 35, 30, 33, 14, 73, nil, nil,
+ 65, 34, 35, 30, 33, 14, 73, 14, 54, 76,
+ 15, 88, 34, 35, 30, 33, 14, 73, 77, 33,
+ 54, 15, 34, 35, 30, 33, 14, 73, 81, 38,
+ 38, 15, 34, 35, 30, 33, 14, 73, 40, 36,
+ 83, 15, 34, 35, 30, 33, 54, 47, 30, 35,
+ 34, 15, 34, 35, 30, 33, 14, 73, 38, 67,
+ 59, 15, 34, 35, 30, 33, 14, 9, 10, 11,
+ 12, 15, 34, 35, 30, 33, 14, 73, 14, nil,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
+ nil, 15, 34, 35, 30, 33, nil, 47, nil, nil,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
- nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
- nil, 15, 34, 35, 30, 33, 14, 73, 61, 63,
+ nil, 15, 34, 35, 30, 33, 14, 9, 10, 11,
+ 12, 15, 34, 35, 30, 33, 14, 73, 61, 63,
nil, 15, 14, 62, 60, 61, 63, 79, 61, 63,
62, 87, nil, 62, 34, 35, 30, 33 ]
racc_action_check = [
41, 41, 41, 41, 41, 15, 15, 15, 15, 15,
- 41, 86, 86, 86, 86, 86, 86, 1, 13, 22,
- 86, 86, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 24, 24, 24, 24, 25, 24, 28, 30,
- 31, 24, 27, 27, 27, 27, 33, 27, 34, 35,
- 36, 27, 45, 45, 45, 45, 45, 45, 44, 49,
- 51, 45, 46, 46, 46, 46, 46, 46, 54, 56,
- 57, 46, 47, 47, 47, 47, 47, 47, 58, 62,
- 66, 47, 68, 68, 68, 68, 68, 68, nil, nil,
- nil, 68, 74, 74, 74, 74, 74, 74, nil, nil,
- nil, 74, 75, 75, 75, 75, 75, 75, nil, nil,
- nil, 75, 78, 78, 78, 78, 78, 78, nil, nil,
- nil, 78, 79, 79, 79, 79, 79, 79, nil, nil,
- nil, 79, 85, 85, 85, 85, 85, 85, 39, 39,
- nil, 85, 52, 39, 39, 82, 82, 52, 64, 64,
+ 41, 86, 86, 86, 86, 86, 86, 34, 33, 49,
+ 86, 86, 85, 85, 85, 85, 85, 85, 51, 31,
+ 54, 85, 79, 79, 79, 79, 79, 79, 56, 57,
+ 58, 79, 78, 78, 78, 78, 78, 78, 62, 1,
+ 66, 78, 24, 24, 24, 24, 30, 24, 28, 25,
+ 22, 24, 75, 75, 75, 75, 75, 75, 13, 44,
+ 36, 75, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 46, 46, 46, 46, 46, 46, 35, nil,
+ nil, 46, 45, 45, 45, 45, 45, 45, nil, nil,
+ nil, 45, 27, 27, 27, 27, nil, 27, nil, nil,
+ nil, 27, 74, 74, 74, 74, 74, 74, nil, nil,
+ nil, 74, 68, 68, 68, 68, 68, 68, nil, nil,
+ nil, 68, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 47, 47, 47, 47, 47, 47, 39, 39,
+ nil, 47, 52, 39, 39, 82, 82, 52, 64, 64,
82, 82, nil, 64, 20, 20, 20, 20 ]
racc_action_pointer = [
- 19, 17, 29, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 11, nil, 2, nil, nil, nil, nil,
- 161, nil, 16, nil, 39, 42, nil, 49, 43, nil,
- 41, 44, nil, 48, 51, 52, 60, nil, nil, 141,
- nil, -3, nil, nil, 55, 59, 69, 79, nil, 56,
- nil, 57, 145, nil, 70, nil, 66, 73, 81, nil,
- nil, nil, 82, nil, 151, nil, 77, nil, 89, nil,
- nil, nil, nil, nil, 99, 109, nil, nil, 119, 129,
- nil, nil, 148, nil, nil, 139, 8, nil, nil ]
+ 129, 49, 69, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 61, nil, 2, nil, nil, nil, nil,
+ 161, nil, 57, nil, 49, 55, nil, 99, 53, nil,
+ 48, 23, nil, 10, 10, 81, 70, nil, nil, 141,
+ nil, -3, nil, nil, 56, 89, 79, 139, nil, 6,
+ nil, 15, 145, nil, 22, nil, 25, 32, 33, nil,
+ nil, nil, 41, nil, 151, nil, 37, nil, 119, nil,
+ nil, nil, nil, nil, 109, 59, nil, nil, 39, 29,
+ nil, nil, 148, nil, nil, 19, 8, nil, nil ]
racc_action_default = [
-2, -73, -1, -4, -5, -6, -7, -8, -9, -10,
@@ -479,26 +478,26 @@ racc_action_default = [
-60, -47, -73, -29, -52, -48, -73, -20, -50 ]
racc_goto_table = [
- 4, 39, 4, 68, 74, 75, 5, 6, 5, 6,
- 44, 42, 51, 49, 3, 56, 37, 57, 58, 1,
+ 4, 39, 4, 68, 74, 75, 6, 5, 6, 5,
+ 44, 42, 51, 49, 3, 56, 37, 57, 58, 80,
2, 66, 84, 41, 43, 48, 50, 64, 84, 84,
- 45, 46, 42, 45, 46, 55, 85, 86, 80, 84,
+ 46, 45, 42, 46, 45, 55, 85, 86, 1, 84,
84, nil, nil, nil, nil, nil, nil, nil, 82, nil,
nil, nil, 78 ]
racc_goto_check = [
- 4, 10, 4, 31, 31, 31, 5, 6, 5, 6,
- 21, 12, 27, 21, 3, 27, 3, 9, 9, 1,
+ 4, 10, 4, 31, 31, 31, 6, 5, 6, 5,
+ 21, 12, 27, 21, 3, 27, 3, 9, 9, 33,
2, 11, 32, 17, 19, 23, 26, 10, 32, 32,
- 5, 6, 12, 5, 6, 29, 31, 31, 33, 32,
+ 6, 5, 12, 6, 5, 29, 31, 31, 1, 32,
32, nil, nil, nil, nil, nil, nil, nil, 10, nil,
nil, nil, 4 ]
racc_goto_pointer = [
- nil, 19, 20, 14, 0, 6, 7, nil, nil, -17,
+ nil, 38, 20, 14, 0, 7, 6, nil, nil, -17,
-14, -20, -9, nil, nil, nil, nil, 8, nil, 2,
nil, -14, nil, 0, nil, nil, -2, -18, nil, 4,
- nil, -42, -46, -16 ]
+ nil, -42, -46, -35 ]
racc_goto_default = [
nil, nil, nil, nil, 70, 71, 72, 7, 8, 13,
diff --git a/lib/rdoc/rd/inline_parser.rb b/lib/rdoc/rd/inline_parser.rb
index a64102cac7..783a5a7c7e 100644
--- a/lib/rdoc/rd/inline_parser.rb
+++ b/lib/rdoc/rd/inline_parser.rb
@@ -1,8 +1,7 @@
-# frozen_string_literal: true
#
# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
+# This file is automatically generated by Racc 1.4.14
+# from Racc grammer file "".
#
require 'racc/parser.rb'
@@ -97,7 +96,7 @@ end
def parse inline
@inline = inline
@src = StringScanner.new inline
- @pre = "".dup
+ @pre = ""
@yydebug = true
do_parse.to_s
end
@@ -244,34 +243,23 @@ end
##### State transition tables begin ###
racc_action_table = [
- 104, 103, 102, 100, 101, 99, 115, 116, 117, 29,
+ 104, 103, 102, 100, 101, 99, 115, 116, 117, 86,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
- 84, 118, 119, 63, 64, 65, 61, 81, 62, 76,
- 78, 79, 85, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 77, 80, 149, 63, 64, 65, 153,
- 81, 62, 76, 78, 79, 86, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 77, 80, 152, 104,
- 103, 102, 100, 101, 99, 115, 116, 117, 87, 105,
- 106, 107, 108, 109, 110, 111, 112, 113, 114, 88,
+ 164, 118, 119, 104, 103, 102, 100, 101, 99, 115,
+ 116, 117, 175, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 85, 118, 119, 63, 64, 65, 61,
+ 81, 62, 76, 78, 79, 84, 66, 67, 68, 69,
+ 70, 71, 72, 73, 74, 75, 77, 80, 149, 104,
+ 103, 102, 100, 101, 99, 115, 116, 117, 29, 105,
+ 106, 107, 108, 109, 110, 111, 112, 113, 114, 173,
118, 119, 104, 103, 102, 100, 101, 99, 115, 116,
- 117, 89, 105, 106, 107, 108, 109, 110, 111, 112,
- 113, 114, 96, 118, 119, 104, 103, 102, 100, 101,
- 99, 115, 116, 117, 124, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 137, 118, 119, 22, 23,
- 24, 25, 26, 21, 18, 19, 176, 177, 13, 148,
- 14, 154, 15, 137, 16, 161, 17, 164, 173, 20,
- 22, 23, 24, 25, 26, 21, 18, 19, 175, 177,
- 13, nil, 14, nil, 15, nil, 16, nil, 17, nil,
- nil, 20, 22, 23, 24, 25, 26, 21, 18, 19,
- nil, nil, 13, nil, 14, nil, 15, nil, 16, nil,
- 17, nil, nil, 20, 22, 23, 24, 25, 26, 21,
- 18, 19, nil, nil, 13, nil, 14, nil, 15, nil,
- 16, nil, 17, nil, nil, 20, 22, 23, 24, 25,
- 26, 21, 18, 19, nil, nil, 13, nil, 14, nil,
- 15, nil, 16, nil, 17, nil, nil, 20, 22, 23,
- 24, 25, 26, 21, 18, 19, nil, nil, 13, nil,
- 14, nil, 15, nil, 16, nil, 17, nil, nil, 20,
- 22, 23, 24, 25, 26, 21, 18, 19, nil, nil,
+ 117, 137, 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 177, 118, 119, 63, 64, 65, 153, 81,
+ 62, 76, 78, 79, 148, 66, 67, 68, 69, 70,
+ 71, 72, 73, 74, 75, 77, 80, 152, 22, 23,
+ 24, 25, 26, 21, 18, 19, 176, 177, 13, 124,
+ 14, 96, 15, 89, 16, 154, 17, 88, 137, 20,
+ 22, 23, 24, 25, 26, 21, 18, 19, 87, 161,
13, nil, 14, nil, 15, nil, 16, nil, 17, 42,
nil, 20, 54, 38, 53, 55, 56, 57, nil, 13,
nil, 14, nil, 15, nil, 16, nil, 17, nil, nil,
@@ -279,63 +267,63 @@ racc_action_table = [
nil, 13, nil, 14, nil, 15, nil, 16, nil, 17,
nil, nil, 20, 63, 64, 65, 61, 81, 62, 76,
78, 79, nil, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 77, 80, 122, nil, nil, 54, nil,
+ 73, 74, 75, 77, 80, 145, nil, nil, 54, 133,
+ 53, 55, 56, 57, nil, 13, nil, 14, nil, 15,
+ nil, 16, nil, 17, 145, nil, 20, 54, 133, 53,
+ 55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
+ 16, nil, 17, nil, nil, 20, 22, 23, 24, 25,
+ 26, 21, 18, 19, nil, nil, 13, nil, 14, nil,
+ 15, nil, 16, nil, 17, 145, nil, 20, 54, 133,
53, 55, 56, 57, nil, 13, nil, 14, nil, 15,
nil, 16, nil, 17, 145, nil, 20, 54, 133, 53,
55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
- 16, nil, 17, 145, nil, 20, 54, 133, 53, 55,
- 56, 57, nil, 13, nil, 14, nil, 15, nil, 16,
- nil, 17, 145, nil, 20, 54, 133, 53, 55, 56,
- 57, nil, 13, nil, 14, nil, 15, nil, 16, nil,
- 17, 145, nil, 20, 54, 133, 53, 55, 56, 57,
+ 16, nil, 17, nil, nil, 20, 22, 23, 24, 25,
+ 26, 21, 18, 19, nil, nil, 13, nil, 14, nil,
+ 15, nil, 16, nil, 17, nil, nil, 20, 22, 23,
+ 24, 25, 26, 21, 18, 19, nil, nil, 13, nil,
+ 14, nil, 15, nil, 16, nil, 17, nil, nil, 20,
+ 22, 23, 24, 25, 26, 21, 18, 19, nil, nil,
+ 13, nil, 14, nil, 15, nil, 16, nil, 17, nil,
+ nil, 20, 22, 23, 24, 25, 26, 21, 18, 19,
+ nil, nil, 13, nil, 14, nil, 15, nil, 16, 122,
+ 17, nil, 54, 20, 53, 55, 56, 57, nil, 13,
+ nil, 14, nil, 15, nil, 16, nil, 17, nil, nil,
+ 20, 135, 136, 54, 133, 53, 55, 56, 57, nil,
+ 13, nil, 14, nil, 15, nil, 16, nil, 17, nil,
+ nil, 20, 135, 136, 54, 133, 53, 55, 56, 57,
nil, 13, nil, 14, nil, 15, nil, 16, nil, 17,
nil, nil, 20, 135, 136, 54, 133, 53, 55, 56,
- 57, nil, 13, nil, 14, nil, 15, nil, 16, nil,
- 17, nil, nil, 20, 135, 136, 54, 133, 53, 55,
- 56, 57, nil, 13, nil, 14, nil, 15, nil, 16,
- nil, 17, nil, nil, 20, 135, 136, 54, 133, 53,
- 55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
- 16, nil, 17, 95, nil, 20, 54, 91, 53, 55,
- 56, 57, 145, nil, nil, 54, 133, 53, 55, 56,
- 57, 158, nil, nil, 54, nil, 53, 55, 56, 57,
- 165, 135, 136, 54, 133, 53, 55, 56, 57, 145,
- nil, nil, 54, 133, 53, 55, 56, 57, 172, 135,
- 136, 54, 133, 53, 55, 56, 57, 174, 135, 136,
- 54, 133, 53, 55, 56, 57, 178, 135, 136, 54,
- 133, 53, 55, 56, 57, 135, 136, 54, 133, 53,
- 55, 56, 57, 135, 136, 54, 133, 53, 55, 56,
- 57, 135, 136, 54, 133, 53, 55, 56, 57, 22,
- 23, 24, 25, 26, 21 ]
+ 57, nil, 13, nil, 14, nil, 15, nil, 16, 158,
+ 17, nil, 54, 20, 53, 55, 56, 57, 95, nil,
+ nil, 54, 91, 53, 55, 56, 57, 145, nil, nil,
+ 54, 133, 53, 55, 56, 57, 165, 135, 136, 54,
+ 133, 53, 55, 56, 57, 145, nil, nil, 54, 133,
+ 53, 55, 56, 57, 172, 135, 136, 54, 133, 53,
+ 55, 56, 57, 174, 135, 136, 54, 133, 53, 55,
+ 56, 57, 178, 135, 136, 54, 133, 53, 55, 56,
+ 57, 135, 136, 54, 133, 53, 55, 56, 57, 135,
+ 136, 54, 133, 53, 55, 56, 57, 135, 136, 54,
+ 133, 53, 55, 56, 57, 22, 23, 24, 25, 26,
+ 21 ]
racc_action_check = [
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 1,
+ 38, 38, 38, 38, 38, 38, 38, 38, 38, 32,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 29, 38, 38, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 31, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 59, 59, 59, 59, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 32, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 33, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 34,
- 91, 91, 97, 97, 97, 97, 97, 97, 97, 97,
- 97, 35, 97, 97, 97, 97, 97, 97, 97, 97,
- 97, 97, 37, 97, 97, 155, 155, 155, 155, 155,
- 155, 155, 155, 155, 41, 155, 155, 155, 155, 155,
- 155, 155, 155, 155, 155, 43, 155, 155, 0, 0,
- 0, 0, 0, 0, 0, 0, 165, 165, 0, 58,
- 0, 90, 0, 94, 0, 100, 0, 125, 162, 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 164, 172,
- 2, nil, 2, nil, 2, nil, 2, nil, 2, nil,
- nil, 2, 13, 13, 13, 13, 13, 13, 13, 13,
- nil, nil, 13, nil, 13, nil, 13, nil, 13, nil,
- 13, nil, nil, 13, 14, 14, 14, 14, 14, 14,
- 14, 14, nil, nil, 14, nil, 14, nil, 14, nil,
- 14, nil, 14, nil, nil, 14, 15, 15, 15, 15,
- 15, 15, 15, 15, nil, nil, 15, nil, 15, nil,
- 15, nil, 15, nil, 15, nil, nil, 15, 16, 16,
- 16, 16, 16, 16, 16, 16, nil, nil, 16, nil,
- 16, nil, 16, nil, 16, nil, 16, nil, nil, 16,
- 17, 17, 17, 17, 17, 17, 17, 17, nil, nil,
+ 125, 38, 38, 97, 97, 97, 97, 97, 97, 97,
+ 97, 97, 164, 97, 97, 97, 97, 97, 97, 97,
+ 97, 97, 97, 31, 97, 97, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 29, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 91,
+ 91, 91, 91, 91, 91, 91, 91, 91, 1, 91,
+ 91, 91, 91, 91, 91, 91, 91, 91, 91, 162,
+ 91, 91, 155, 155, 155, 155, 155, 155, 155, 155,
+ 155, 43, 155, 155, 155, 155, 155, 155, 155, 155,
+ 155, 155, 172, 155, 155, 61, 61, 61, 61, 61,
+ 61, 61, 61, 61, 58, 61, 61, 61, 61, 61,
+ 61, 61, 61, 61, 61, 61, 61, 61, 16, 16,
+ 16, 16, 16, 16, 16, 16, 165, 165, 16, 41,
+ 16, 37, 16, 35, 16, 90, 16, 34, 94, 16,
+ 17, 17, 17, 17, 17, 17, 17, 17, 33, 100,
17, nil, 17, nil, 17, nil, 17, nil, 17, 18,
nil, 17, 18, 18, 18, 18, 18, 18, nil, 18,
nil, 18, nil, 18, nil, 18, nil, 18, nil, nil,
@@ -343,53 +331,64 @@ racc_action_check = [
nil, 19, nil, 19, nil, 19, nil, 19, nil, 19,
nil, nil, 19, 20, 20, 20, 20, 20, 20, 20,
20, 20, nil, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 39, nil, nil, 39, nil,
- 39, 39, 39, 39, nil, 39, nil, 39, nil, 39,
- nil, 39, nil, 39, 44, nil, 39, 44, 44, 44,
+ 20, 20, 20, 20, 20, 146, nil, nil, 146, 146,
+ 146, 146, 146, 146, nil, 146, nil, 146, nil, 146,
+ nil, 146, nil, 146, 138, nil, 146, 138, 138, 138,
+ 138, 138, 138, nil, 138, nil, 138, nil, 138, nil,
+ 138, nil, 138, nil, nil, 138, 0, 0, 0, 0,
+ 0, 0, 0, 0, nil, nil, 0, nil, 0, nil,
+ 0, nil, 0, nil, 0, 45, nil, 0, 45, 45,
+ 45, 45, 45, 45, nil, 45, nil, 45, nil, 45,
+ nil, 45, nil, 45, 44, nil, 45, 44, 44, 44,
44, 44, 44, nil, 44, nil, 44, nil, 44, nil,
- 44, nil, 44, 45, nil, 44, 45, 45, 45, 45,
- 45, 45, nil, 45, nil, 45, nil, 45, nil, 45,
- nil, 45, 138, nil, 45, 138, 138, 138, 138, 138,
- 138, nil, 138, nil, 138, nil, 138, nil, 138, nil,
- 138, 146, nil, 138, 146, 146, 146, 146, 146, 146,
- nil, 146, nil, 146, nil, 146, nil, 146, nil, 146,
- nil, nil, 146, 42, 42, 42, 42, 42, 42, 42,
+ 44, nil, 44, nil, nil, 44, 2, 2, 2, 2,
+ 2, 2, 2, 2, nil, nil, 2, nil, 2, nil,
+ 2, nil, 2, nil, 2, nil, nil, 2, 13, 13,
+ 13, 13, 13, 13, 13, 13, nil, nil, 13, nil,
+ 13, nil, 13, nil, 13, nil, 13, nil, nil, 13,
+ 14, 14, 14, 14, 14, 14, 14, 14, nil, nil,
+ 14, nil, 14, nil, 14, nil, 14, nil, 14, nil,
+ nil, 14, 15, 15, 15, 15, 15, 15, 15, 15,
+ nil, nil, 15, nil, 15, nil, 15, nil, 15, 39,
+ 15, nil, 39, 15, 39, 39, 39, 39, nil, 39,
+ nil, 39, nil, 39, nil, 39, nil, 39, nil, nil,
+ 39, 42, 42, 42, 42, 42, 42, 42, 42, nil,
42, nil, 42, nil, 42, nil, 42, nil, 42, nil,
- 42, nil, nil, 42, 122, 122, 122, 122, 122, 122,
- 122, 122, nil, 122, nil, 122, nil, 122, nil, 122,
- nil, 122, nil, nil, 122, 127, 127, 127, 127, 127,
- 127, 127, 127, nil, 127, nil, 127, nil, 127, nil,
- 127, nil, 127, 36, nil, 127, 36, 36, 36, 36,
- 36, 36, 52, nil, nil, 52, 52, 52, 52, 52,
- 52, 92, nil, nil, 92, nil, 92, 92, 92, 92,
- 126, 126, 126, 126, 126, 126, 126, 126, 126, 142,
- nil, nil, 142, 142, 142, 142, 142, 142, 159, 159,
- 159, 159, 159, 159, 159, 159, 159, 163, 163, 163,
- 163, 163, 163, 163, 163, 163, 171, 171, 171, 171,
- 171, 171, 171, 171, 171, 95, 95, 95, 95, 95,
- 95, 95, 95, 158, 158, 158, 158, 158, 158, 158,
- 158, 168, 168, 168, 168, 168, 168, 168, 168, 27,
- 27, 27, 27, 27, 27 ]
+ nil, 42, 127, 127, 127, 127, 127, 127, 127, 127,
+ nil, 127, nil, 127, nil, 127, nil, 127, nil, 127,
+ nil, nil, 127, 122, 122, 122, 122, 122, 122, 122,
+ 122, nil, 122, nil, 122, nil, 122, nil, 122, 92,
+ 122, nil, 92, 122, 92, 92, 92, 92, 36, nil,
+ nil, 36, 36, 36, 36, 36, 36, 52, nil, nil,
+ 52, 52, 52, 52, 52, 52, 126, 126, 126, 126,
+ 126, 126, 126, 126, 126, 142, nil, nil, 142, 142,
+ 142, 142, 142, 142, 159, 159, 159, 159, 159, 159,
+ 159, 159, 159, 163, 163, 163, 163, 163, 163, 163,
+ 163, 163, 171, 171, 171, 171, 171, 171, 171, 171,
+ 171, 95, 95, 95, 95, 95, 95, 95, 95, 158,
+ 158, 158, 158, 158, 158, 158, 158, 168, 168, 168,
+ 168, 168, 168, 168, 168, 27, 27, 27, 27, 27,
+ 27 ]
racc_action_pointer = [
- 135, 9, 157, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 179, 201, 223, 245, 267, 286, 308,
- 330, nil, nil, nil, nil, nil, nil, 606, nil, 20,
- nil, 18, 39, 60, 69, 79, 510, 89, -3, 352,
- nil, 120, 449, 130, 371, 390, nil, nil, nil, nil,
- nil, nil, 519, nil, nil, nil, nil, nil, 138, 20,
- nil, 43, nil, nil, nil, nil, nil, nil, nil, nil,
+ 283, 78, 343, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 365, 387, 409, 135, 157, 176, 198,
+ 220, nil, nil, nil, nil, nil, nil, 602, nil, 55,
+ nil, 29, -7, 150, 137, 131, 515, 128, -3, 426,
+ nil, 145, 447, 96, 321, 302, nil, nil, nil, nil,
+ nil, nil, 524, nil, nil, nil, nil, nil, 113, 43,
+ nil, 112, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 128, 66, 528, nil, 148, 581, nil, 89, nil, nil,
- 149, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ 132, 66, 506, nil, 153, 577, nil, 20, nil, nil,
+ 163, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 470, nil, nil, 154, 537, 491, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 409, nil,
- nil, nil, 546, nil, nil, nil, 428, nil, nil, nil,
- nil, nil, nil, nil, nil, 112, nil, nil, 589, 555,
- nil, nil, 155, 564, 164, 142, nil, nil, 597, nil,
- nil, 573, 164, nil, nil, nil, nil, nil, nil ]
+ nil, nil, 489, nil, nil, 17, 533, 468, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, 261, nil,
+ nil, nil, 542, nil, nil, nil, 242, nil, nil, nil,
+ nil, nil, nil, nil, nil, 89, nil, nil, 585, 551,
+ nil, nil, 86, 560, 28, 142, nil, nil, 593, nil,
+ nil, 569, 107, nil, nil, nil, nil, nil, nil ]
racc_action_default = [
-138, -138, -1, -3, -4, -5, -6, -7, -8, -9,
@@ -412,15 +411,15 @@ racc_action_default = [
-60, -138, -34, -36, -37, -29, -30, -32, -34 ]
racc_goto_table = [
- 126, 44, 125, 43, 144, 144, 160, 93, 97, 52,
- 166, 82, 144, 40, 41, 39, 138, 146, 169, 30,
- 36, 94, 44, 1, 123, 129, 169, 52, 90, 37,
- 52, 167, 147, 92, 120, 121, 31, 32, 33, 34,
- 35, 170, 58, 166, 59, 83, 170, 166, 151, nil,
+ 126, 44, 125, 52, 144, 144, 160, 93, 97, 43,
+ 166, 82, 144, 41, 40, 39, 138, 146, 169, 90,
+ 36, 52, 44, 1, 52, 129, 169, 94, 59, 83,
+ 123, 30, 151, 92, 121, 120, 31, 32, 33, 34,
+ 35, 170, 58, 166, 167, 147, 170, 166, 37, nil,
150, nil, 166, 159, 4, 166, 4, nil, nil, nil,
nil, 155, nil, 156, 160, nil, nil, 4, 4, 4,
- 4, 4, nil, 4, 5, nil, 5, 157, nil, nil,
- 163, nil, 162, 52, nil, 168, nil, 5, 5, 5,
+ 4, 4, nil, 4, 5, nil, 5, 52, nil, nil,
+ 163, nil, 162, 157, nil, 168, nil, 5, 5, 5,
5, 5, nil, 5, nil, nil, nil, nil, 144, nil,
nil, nil, 144, nil, nil, 129, 144, 144, nil, 6,
129, 6, nil, nil, nil, nil, 171, 7, nil, 7,
@@ -430,15 +429,15 @@ racc_goto_table = [
11, 11, 11, nil, 11 ]
racc_goto_check = [
- 22, 24, 21, 23, 36, 36, 37, 18, 16, 34,
- 35, 41, 36, 19, 20, 17, 25, 25, 28, 3,
- 13, 23, 24, 1, 23, 24, 28, 34, 14, 15,
- 34, 29, 32, 17, 19, 20, 1, 1, 1, 1,
- 1, 33, 1, 35, 38, 39, 33, 35, 42, nil,
+ 22, 24, 21, 34, 36, 36, 37, 18, 16, 23,
+ 35, 41, 36, 20, 19, 17, 25, 25, 28, 14,
+ 13, 34, 24, 1, 34, 24, 28, 23, 38, 39,
+ 23, 3, 42, 17, 20, 19, 1, 1, 1, 1,
+ 1, 33, 1, 35, 29, 32, 33, 35, 15, nil,
41, nil, 35, 22, 4, 35, 4, nil, nil, nil,
nil, 16, nil, 18, 37, nil, nil, 4, 4, 4,
- 4, 4, nil, 4, 5, nil, 5, 23, nil, nil,
- 22, nil, 21, 34, nil, 22, nil, 5, 5, 5,
+ 4, 4, nil, 4, 5, nil, 5, 34, nil, nil,
+ 22, nil, 21, 23, nil, 22, nil, 5, 5, 5,
5, 5, nil, 5, nil, nil, nil, nil, 36, nil,
nil, nil, 36, nil, nil, 24, 36, 36, nil, 6,
24, 6, nil, nil, nil, nil, 22, 7, nil, 7,
@@ -448,11 +447,11 @@ racc_goto_check = [
11, 11, 11, nil, 11 ]
racc_goto_pointer = [
- nil, 23, nil, 17, 54, 74, 109, 117, 127, nil,
- nil, 135, nil, 2, -8, 11, -30, -3, -29, -5,
- -4, -40, -42, -15, -17, -28, nil, nil, -120, -96,
- nil, nil, -20, -101, -9, -116, -40, -91, 24, 18,
- nil, -9, -13 ]
+ nil, 23, nil, 29, 54, 74, 109, 117, 127, nil,
+ nil, 135, nil, 2, -17, 30, -30, -3, -29, -4,
+ -5, -40, -42, -9, -17, -28, nil, nil, -120, -83,
+ nil, nil, -7, -101, -15, -116, -40, -91, 8, 2,
+ nil, -9, -29 ]
racc_goto_default = [
nil, nil, 2, 3, 46, 47, 48, 49, 50, 9,
diff --git a/lib/rdoc/rdoc.gemspec b/lib/rdoc/rdoc.gemspec
index 9b274c709a..8c92908a66 100644
--- a/lib/rdoc/rdoc.gemspec
+++ b/lib/rdoc/rdoc.gemspec
@@ -1,13 +1,14 @@
begin
- require_relative "lib/rdoc/version"
+ require_relative "lib/rdoc"
rescue LoadError
# for Ruby repository
- require_relative "version"
+ require_relative "../rdoc"
end
Gem::Specification.new do |s|
s.name = "rdoc"
s.version = RDoc::VERSION
+ s.date = "2017-12-24"
s.authors = [
"Eric Hodel",
@@ -31,198 +32,8 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
s.bindir = "exe"
s.executables = ["rdoc", "ri"]
s.require_paths = ["lib"]
- # for ruby core repository. It was generated by
- # `git ls-files -z`.split("\x0").each {|f| puts " #{f.dump}," unless f.start_with?(*%W[test/ spec/ features/ .]) }
- s.files = [
- "CONTRIBUTING.rdoc",
- "CVE-2013-0256.rdoc",
- "ExampleMarkdown.md",
- "ExampleRDoc.rdoc",
- "Gemfile",
- "History.rdoc",
- "LEGAL.rdoc",
- "LICENSE.rdoc",
- "README.rdoc",
- "RI.rdoc",
- "Rakefile",
- "TODO.rdoc",
- "bin/console",
- "bin/setup",
- "exe/rdoc",
- "exe/ri",
- "lib/rdoc.rb",
- "lib/rdoc/alias.rb",
- "lib/rdoc/anon_class.rb",
- "lib/rdoc/any_method.rb",
- "lib/rdoc/attr.rb",
- "lib/rdoc/class_module.rb",
- "lib/rdoc/code_object.rb",
- "lib/rdoc/code_objects.rb",
- "lib/rdoc/comment.rb",
- "lib/rdoc/constant.rb",
- "lib/rdoc/context.rb",
- "lib/rdoc/context/section.rb",
- "lib/rdoc/cross_reference.rb",
- "lib/rdoc/encoding.rb",
- "lib/rdoc/erb_partial.rb",
- "lib/rdoc/erbio.rb",
- "lib/rdoc/extend.rb",
- "lib/rdoc/generator.rb",
- "lib/rdoc/generator/darkfish.rb",
- "lib/rdoc/generator/json_index.rb",
- "lib/rdoc/generator/markup.rb",
- "lib/rdoc/generator/pot.rb",
- "lib/rdoc/generator/pot/message_extractor.rb",
- "lib/rdoc/generator/pot/po.rb",
- "lib/rdoc/generator/pot/po_entry.rb",
- "lib/rdoc/generator/ri.rb",
- "lib/rdoc/generator/template/darkfish/.document",
- "lib/rdoc/generator/template/darkfish/_footer.rhtml",
- "lib/rdoc/generator/template/darkfish/_head.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml",
- "lib/rdoc/generator/template/darkfish/class.rhtml",
- "lib/rdoc/generator/template/darkfish/css/fonts.css",
- "lib/rdoc/generator/template/darkfish/css/rdoc.css",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf",
- "lib/rdoc/generator/template/darkfish/images/add.png",
- "lib/rdoc/generator/template/darkfish/images/arrow_up.png",
- "lib/rdoc/generator/template/darkfish/images/brick.png",
- "lib/rdoc/generator/template/darkfish/images/brick_link.png",
- "lib/rdoc/generator/template/darkfish/images/bug.png",
- "lib/rdoc/generator/template/darkfish/images/bullet_black.png",
- "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png",
- "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png",
- "lib/rdoc/generator/template/darkfish/images/date.png",
- "lib/rdoc/generator/template/darkfish/images/delete.png",
- "lib/rdoc/generator/template/darkfish/images/find.png",
- "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif",
- "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png",
- "lib/rdoc/generator/template/darkfish/images/package.png",
- "lib/rdoc/generator/template/darkfish/images/page_green.png",
- "lib/rdoc/generator/template/darkfish/images/page_white_text.png",
- "lib/rdoc/generator/template/darkfish/images/page_white_width.png",
- "lib/rdoc/generator/template/darkfish/images/plugin.png",
- "lib/rdoc/generator/template/darkfish/images/ruby.png",
- "lib/rdoc/generator/template/darkfish/images/tag_blue.png",
- "lib/rdoc/generator/template/darkfish/images/tag_green.png",
- "lib/rdoc/generator/template/darkfish/images/transparent.png",
- "lib/rdoc/generator/template/darkfish/images/wrench.png",
- "lib/rdoc/generator/template/darkfish/images/wrench_orange.png",
- "lib/rdoc/generator/template/darkfish/images/zoom.png",
- "lib/rdoc/generator/template/darkfish/index.rhtml",
- "lib/rdoc/generator/template/darkfish/js/darkfish.js",
- "lib/rdoc/generator/template/darkfish/js/search.js",
- "lib/rdoc/generator/template/darkfish/page.rhtml",
- "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml",
- "lib/rdoc/generator/template/darkfish/servlet_root.rhtml",
- "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml",
- "lib/rdoc/generator/template/json_index/.document",
- "lib/rdoc/generator/template/json_index/js/navigation.js",
- "lib/rdoc/generator/template/json_index/js/searcher.js",
- "lib/rdoc/ghost_method.rb",
- "lib/rdoc/i18n.rb",
- "lib/rdoc/i18n/locale.rb",
- "lib/rdoc/i18n/text.rb",
- "lib/rdoc/include.rb",
- "lib/rdoc/known_classes.rb",
- "lib/rdoc/markdown.kpeg",
- "lib/rdoc/markdown/entities.rb",
- "lib/rdoc/markdown/literals.kpeg",
- "lib/rdoc/markup.rb",
- "lib/rdoc/markup/attr_changer.rb",
- "lib/rdoc/markup/attr_span.rb",
- "lib/rdoc/markup/attribute_manager.rb",
- "lib/rdoc/markup/attributes.rb",
- "lib/rdoc/markup/blank_line.rb",
- "lib/rdoc/markup/block_quote.rb",
- "lib/rdoc/markup/document.rb",
- "lib/rdoc/markup/formatter.rb",
- "lib/rdoc/markup/hard_break.rb",
- "lib/rdoc/markup/heading.rb",
- "lib/rdoc/markup/include.rb",
- "lib/rdoc/markup/indented_paragraph.rb",
- "lib/rdoc/markup/list.rb",
- "lib/rdoc/markup/list_item.rb",
- "lib/rdoc/markup/paragraph.rb",
- "lib/rdoc/markup/parser.rb",
- "lib/rdoc/markup/pre_process.rb",
- "lib/rdoc/markup/raw.rb",
- "lib/rdoc/markup/regexp_handling.rb",
- "lib/rdoc/markup/rule.rb",
- "lib/rdoc/markup/to_ansi.rb",
- "lib/rdoc/markup/to_bs.rb",
- "lib/rdoc/markup/to_html.rb",
- "lib/rdoc/markup/to_html_crossref.rb",
- "lib/rdoc/markup/to_html_snippet.rb",
- "lib/rdoc/markup/to_joined_paragraph.rb",
- "lib/rdoc/markup/to_label.rb",
- "lib/rdoc/markup/to_markdown.rb",
- "lib/rdoc/markup/to_rdoc.rb",
- "lib/rdoc/markup/to_table_of_contents.rb",
- "lib/rdoc/markup/to_test.rb",
- "lib/rdoc/markup/to_tt_only.rb",
- "lib/rdoc/markup/verbatim.rb",
- "lib/rdoc/meta_method.rb",
- "lib/rdoc/method_attr.rb",
- "lib/rdoc/mixin.rb",
- "lib/rdoc/normal_class.rb",
- "lib/rdoc/normal_module.rb",
- "lib/rdoc/options.rb",
- "lib/rdoc/parser.rb",
- "lib/rdoc/parser/c.rb",
- "lib/rdoc/parser/changelog.rb",
- "lib/rdoc/parser/markdown.rb",
- "lib/rdoc/parser/rd.rb",
- "lib/rdoc/parser/ripper_state_lex.rb",
- "lib/rdoc/parser/ruby.rb",
- "lib/rdoc/parser/ruby_tools.rb",
- "lib/rdoc/parser/simple.rb",
- "lib/rdoc/parser/text.rb",
- "lib/rdoc/rd.rb",
- "lib/rdoc/rd/block_parser.ry",
- "lib/rdoc/rd/inline.rb",
- "lib/rdoc/rd/inline_parser.ry",
- "lib/rdoc/rdoc.rb",
- "lib/rdoc/require.rb",
- "lib/rdoc/ri.rb",
- "lib/rdoc/ri/driver.rb",
- "lib/rdoc/ri/formatter.rb",
- "lib/rdoc/ri/paths.rb",
- "lib/rdoc/ri/store.rb",
- "lib/rdoc/ri/task.rb",
- "lib/rdoc/rubygems_hook.rb",
- "lib/rdoc/servlet.rb",
- "lib/rdoc/single_class.rb",
- "lib/rdoc/stats.rb",
- "lib/rdoc/stats/normal.rb",
- "lib/rdoc/stats/quiet.rb",
- "lib/rdoc/stats/verbose.rb",
- "lib/rdoc/store.rb",
- "lib/rdoc/task.rb",
- "lib/rdoc/text.rb",
- "lib/rdoc/token_stream.rb",
- "lib/rdoc/tom_doc.rb",
- "lib/rdoc/top_level.rb",
- "lib/rdoc/version.rb",
- "rdoc.gemspec",
- ]
+ # for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ s.files = [".document", ".gitignore", ".travis.yml", "CONTRIBUTING.rdoc", "CVE-2013-0256.rdoc", "ExampleMarkdown.md", "ExampleRDoc.rdoc", "Gemfile", "History.rdoc", "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", "RI.rdoc", "Rakefile", "TODO.rdoc", "appveyor.yml", "bin/console", "bin/setup", "exe/rdoc", "exe/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", "lib/rdoc/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/pot.rb", "lib/rdoc/generator/pot/message_extractor.rb", "lib/rdoc/generator/pot/po.rb", "lib/rdoc/generator/pot/po_entry.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/_footer.rhtml", "lib/rdoc/generator/template/darkfish/_head.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml", "lib/rdoc/generator/template/darkfish/class.rhtml", "lib/rdoc/generator/template/darkfish/css/fonts.css", "lib/rdoc/generator/template/darkfish/css/rdoc.css", "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf", "lib/rdoc/generator/template/darkfish/images/add.png", "lib/rdoc/generator/template/darkfish/images/arrow_up.png", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/delete.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_blue.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/transparent.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/search.js", "lib/rdoc/generator/template/darkfish/page.rhtml", "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml", "lib/rdoc/generator/template/darkfish/servlet_root.rhtml", "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml", "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", "lib/rdoc/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", "lib/rdoc/markdown/literals.kpeg", "lib/rdoc/markup.rb", "lib/rdoc/markup/attr_changer.rb", "lib/rdoc/markup/attr_span.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/attributes.rb", "lib/rdoc/markup/blank_line.rb", "lib/rdoc/markup/block_quote.rb", "lib/rdoc/markup/document.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/formatter_test_case.rb", "lib/rdoc/markup/hard_break.rb", "lib/rdoc/markup/heading.rb", "lib/rdoc/markup/include.rb", "lib/rdoc/markup/indented_paragraph.rb", "lib/rdoc/markup/inline.rb", "lib/rdoc/markup/list.rb", "lib/rdoc/markup/list_item.rb", "lib/rdoc/markup/paragraph.rb", "lib/rdoc/markup/parser.rb", "lib/rdoc/markup/pre_process.rb", "lib/rdoc/markup/raw.rb", "lib/rdoc/markup/rule.rb", "lib/rdoc/markup/special.rb", "lib/rdoc/markup/text_formatter_test_case.rb", "lib/rdoc/markup/to_ansi.rb", "lib/rdoc/markup/to_bs.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_html_snippet.rb", "lib/rdoc/markup/to_joined_paragraph.rb", "lib/rdoc/markup/to_label.rb", "lib/rdoc/markup/to_markdown.rb", "lib/rdoc/markup/to_rdoc.rb", "lib/rdoc/markup/to_table_of_contents.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/changelog.rb", "lib/rdoc/parser/markdown.rb", "lib/rdoc/parser/rd.rb", "lib/rdoc/parser/ripper_state_lex.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/ruby_tools.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/parser/text.rb", "lib/rdoc/rd.rb", "lib/rdoc/rd/block_parser.ry", "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/store.rb", "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", "lib/rdoc/stats/verbose.rb", "lib/rdoc/store.rb", "lib/rdoc/task.rb", "lib/rdoc/test_case.rb", "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", "lib/rdoc/top_level.rb", "rdoc.gemspec"]
# files from .gitignore
s.files << "lib/rdoc/rd/block_parser.rb" << "lib/rdoc/rd/inline_parser.rb" << "lib/rdoc/markdown.rb" << "lib/rdoc/markdown/literals.rb"
@@ -240,7 +51,13 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
TODO.rdoc
]
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
+ s.required_ruby_version = Gem::Requirement.new(">= 2.2.2")
s.rubygems_version = "2.5.2"
s.required_rubygems_version = Gem::Requirement.new(">= 2.2")
+
+ s.add_development_dependency("rake")
+ s.add_development_dependency("racc", "> 1.4.10")
+ s.add_development_dependency("kpeg")
+ s.add_development_dependency("minitest", "~> 4")
+ s.add_development_dependency("json")
end
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index f356c368ff..68775c8be1 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -24,7 +24,7 @@ require 'time'
# rdoc.document argv
#
# Where +argv+ is an array of strings, each corresponding to an argument you'd
-# give rdoc on the command line. See <tt>rdoc --help</tt> for details.
+# give rdoc on the command line. See <tt>rdoc --help<tt> for details.
class RDoc::RDoc
@@ -36,6 +36,11 @@ class RDoc::RDoc
GENERATORS = {}
##
+ # File pattern to exclude
+
+ attr_accessor :exclude
+
+ ##
# Generator instance used for creating output
attr_accessor :generator
@@ -88,6 +93,7 @@ class RDoc::RDoc
def initialize
@current = nil
+ @exclude = nil
@generator = nil
@last_modified = {}
@old_siginfo = nil
@@ -110,7 +116,7 @@ class RDoc::RDoc
def gather_files files
files = ["."] if files.empty?
- file_list = normalized_file_list files, true, @options.exclude
+ file_list = normalized_file_list files, true, @exclude
file_list = file_list.uniq
@@ -182,7 +188,7 @@ class RDoc::RDoc
error "#{dir} exists and is not a directory" unless File.directory? dir
begin
- File.open flag_file do |io|
+ open flag_file do |io|
unless force then
Time.parse io.gets
@@ -226,11 +232,8 @@ option)
def update_output_dir(op_dir, time, last = {})
return if @options.dry_run or not @options.update_output_dir
- unless ENV['SOURCE_DATE_EPOCH'].nil?
- time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
- end
- File.open output_flag_file(op_dir), "w" do |f|
+ open output_flag_file(op_dir), "w" do |f|
f.puts time.rfc2822
last.each do |n, t|
f.puts "#{n}\t#{t.rfc2822}"
@@ -258,7 +261,7 @@ option)
patterns.split.each do |patt|
candidates = Dir.glob(File.join(in_dir, patt))
- result.concat normalized_file_list(candidates, false, @options.exclude)
+ result.concat normalized_file_list(candidates)
end
result
@@ -355,7 +358,7 @@ option)
relative_path.relative_path_from @options.page_dir
end
- top_level = @store.add_file filename, relative_name: relative_path.to_s
+ top_level = @store.add_file filename, relative_path.to_s
parser = RDoc::Parser.for top_level, filename, content, @options, @stats
@@ -430,7 +433,7 @@ The internal error was:
files.reject do |file|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
(file =~ /tags$/i and
- File.open(file, 'rb') { |io|
+ open(file, 'rb') { |io|
io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
})
end
@@ -466,6 +469,8 @@ The internal error was:
exit
end
+ @exclude = @options.exclude
+
unless @options.coverage_report then
@last_modified = setup_output_dir @options.op_dir, @options.force_update
end
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
index 46b98e99b5..fa0e040a42 100644
--- a/lib/rdoc/ri/driver.rb
+++ b/lib/rdoc/ri/driver.rb
@@ -110,7 +110,7 @@ class RDoc::RI::Driver
def self.dump data_path
require 'pp'
- File.open data_path, 'rb' do |io|
+ open data_path, 'rb' do |io|
pp Marshal.load(io.read)
end
end
@@ -425,7 +425,6 @@ or the PAGER environment variable.
@server = options[:server]
@use_stdout = options[:use_stdout]
@show_all = options[:show_all]
- @width = options[:width]
# pager process for jruby
@jruby_pager_process = nil
@@ -796,9 +795,7 @@ or the PAGER environment variable.
def display document
page do |io|
- f = formatter(io)
- f.width = @width if @width and f.respond_to?(:width)
- text = document.accept f
+ text = document.accept formatter(io)
io.write text
end
@@ -1443,13 +1440,7 @@ or the PAGER environment variable.
render_method_arguments out, method.arglists
render_method_superclass out, method
- if method.is_alias_for
- al = method.is_alias_for
- alias_for = store.load_method al.parent_name, "#{al.name_prefix}#{al.name}"
- render_method_comment out, method, alias_for
- else
- render_method_comment out, method
- end
+ render_method_comment out, method
end
def render_method_arguments out, arglists # :nodoc:
@@ -1461,22 +1452,10 @@ or the PAGER environment variable.
out << RDoc::Markup::Rule.new(1)
end
- def render_method_comment out, method, alias_for = nil# :nodoc:
- if alias_for
- unless method.comment.nil? or method.comment.empty?
- out << RDoc::Markup::BlankLine.new
- out << method.comment
- end
- out << RDoc::Markup::BlankLine.new
- out << RDoc::Markup::Paragraph.new("(This method is an alias for #{alias_for.full_name}.)")
- out << RDoc::Markup::BlankLine.new
- out << alias_for.comment
- out << RDoc::Markup::BlankLine.new
- else
- out << RDoc::Markup::BlankLine.new
- out << method.comment
- out << RDoc::Markup::BlankLine.new
- end
+ def render_method_comment out, method # :nodoc:
+ out << RDoc::Markup::BlankLine.new
+ out << method.comment
+ out << RDoc::Markup::BlankLine.new
end
def render_method_superclass out, method # :nodoc:
diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb
index f76721d318..d41e610591 100644
--- a/lib/rdoc/ri/paths.rb
+++ b/lib/rdoc/ri/paths.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require 'rdoc/rdoc'
+require 'rdoc/ri'
##
# The directories where ri data lives. Paths can be enumerated via ::each, or
diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb
index e1d0f0ce82..f2d6dd5adc 100644
--- a/lib/rdoc/servlet.rb
+++ b/lib/rdoc/servlet.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
require 'rdoc'
-require 'erb'
require 'time'
require 'json'
require 'webrick'
@@ -102,9 +101,9 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
res.body = File.read asset_path
res.content_type = case req.path
- when /\.css\z/ then 'text/css'
- when /\.js\z/ then 'application/javascript'
- else 'application/octet-stream'
+ when /css$/ then 'text/css'
+ when /js$/ then 'application/javascript'
+ else 'application/octet-stream'
end
end
@@ -112,7 +111,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
# GET request entry point. Fills in +res+ for the path, etc. in +req+.
def do_GET req, res
- req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path
+ req.path = req.path.sub(/^#{Regexp.escape @mount_path}/o, '') if @mount_path
case req.path
when '/' then
@@ -145,14 +144,11 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
# +generator+ is used to create the page.
def documentation_page store, generator, path, req, res
- text_name = path.chomp '.html'
- name = text_name.gsub '/', '::'
+ name = path.sub(/.html$/, '').gsub '/', '::'
if klass = store.find_class_or_module(name) then
res.body = generator.generate_class klass
- elsif page = store.find_text_page(name.sub(/_([^_]*)\z/, '.\1')) then
- res.body = generator.generate_page page
- elsif page = store.find_text_page(text_name.sub(/_([^_]*)\z/, '.\1')) then
+ elsif page = store.find_text_page(name.sub(/_([^_]*)$/, '.\1')) then
res.body = generator.generate_page page
else
not_found generator, req, res
@@ -419,7 +415,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
RDoc::Store.new RDoc::RI::Paths.system_dir, :system
when 'site' then
RDoc::Store.new RDoc::RI::Paths.site_dir, :site
- when /\Aextra-(\d+)\z/ then
+ when /^extra-(\d+)$/ then
index = $1.to_i - 1
ri_dir = installed_docs[index][4]
RDoc::Store.new ri_dir, :extra
@@ -431,14 +427,14 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
end
raise WEBrick::HTTPStatus::NotFound,
- "Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
+ "Could not find gem \"#{source_name}\". Are you sure you installed it?" unless ri_dir
store = RDoc::Store.new ri_dir, type
return store if File.exist? store.cache_path
raise WEBrick::HTTPStatus::NotFound,
- "Could not find documentation for \"#{ERB::Util.html_escape(source_name)}\". Please run `gem rdoc --ri gem_name`"
+ "Could not find documentation for \"#{source_name}\". Please run `gem rdoc --ri gem_name`"
end
end
diff --git a/lib/rdoc/stats/normal.rb b/lib/rdoc/stats/normal.rb
index 0a22f0582b..a3a6ff377e 100644
--- a/lib/rdoc/stats/normal.rb
+++ b/lib/rdoc/stats/normal.rb
@@ -26,28 +26,28 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
files_so_far,
@num_files)
- if $stdout.tty?
- # Print a progress bar, but make sure it fits on a single line. Filename
- # will be truncated if necessary.
- size = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
- terminal_width = size[1].to_i.nonzero? || 80
- max_filename_size = (terminal_width - progress_bar.size) - 1
-
- if filename.size > max_filename_size then
- # Turn "some_long_filename.rb" to "...ong_filename.rb"
- filename = filename[(filename.size - max_filename_size) .. -1]
- filename[0..2] = "..."
- end
+ # Print a progress bar, but make sure it fits on a single line. Filename
+ # will be truncated if necessary.
+ size = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
+ terminal_width = size[1].to_i.nonzero? || 80
+ max_filename_size = terminal_width - progress_bar.size
+
+ if filename.size > max_filename_size then
+ # Turn "some_long_filename.rb" to "...ong_filename.rb"
+ filename = filename[(filename.size - max_filename_size) .. -1]
+ filename[0..2] = "..."
+ end
+ line = "#{progress_bar}#{filename}"
+ if $stdout.tty?
# Clean the line with whitespaces so that leftover output from the
# previous line doesn't show up.
- $stdout.print("\r\e[K") if @last_width && @last_width > 0
- @last_width = progress_bar.size + filename.size
- term = "\r"
+ $stdout.print("\r" + (" " * @last_width) + ("\b" * @last_width) + "\r") if @last_width && @last_width > 0
+ @last_width = line.size
+ $stdout.print("#{line}\r")
else
- term = "\n"
+ $stdout.puts(line)
end
- $stdout.print(progress_bar, filename, term)
$stdout.flush
end
diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb
index 0f6cd06e3c..999aa76f92 100644
--- a/lib/rdoc/store.rb
+++ b/lib/rdoc/store.rb
@@ -117,11 +117,6 @@ class RDoc::Store
attr_accessor :encoding
##
- # The lazy constants alias will be discovered in passing
-
- attr_reader :unmatched_constant_alias
-
- ##
# Creates a new Store of +type+ that will load or save to +path+
def initialize path = nil, type = nil
@@ -148,7 +143,6 @@ class RDoc::Store
@classes_hash = {}
@modules_hash = {}
@files_hash = {}
- @text_files_hash = {}
@c_enclosure_classes = {}
@c_enclosure_names = {}
@@ -158,8 +152,6 @@ class RDoc::Store
@unique_classes = nil
@unique_modules = nil
-
- @unmatched_constant_alias = {}
end
##
@@ -185,24 +177,16 @@ class RDoc::Store
# Adds the file with +name+ as an RDoc::TopLevel to the store. Returns the
# created RDoc::TopLevel.
- def add_file absolute_name, relative_name: absolute_name, parser: nil
+ def add_file absolute_name, relative_name = absolute_name
unless top_level = @files_hash[relative_name] then
top_level = RDoc::TopLevel.new absolute_name, relative_name
- top_level.parser = parser if parser
top_level.store = self
@files_hash[relative_name] = top_level
- @text_files_hash[relative_name] = top_level if top_level.text?
end
top_level
end
- def update_parser_of_file(absolute_name, parser)
- if top_level = @files_hash[absolute_name] then
- @text_files_hash[absolute_name] = top_level if top_level.text?
- end
- end
-
##
# Returns all classes discovered by RDoc
@@ -437,8 +421,8 @@ class RDoc::Store
# +file_name+
def find_text_page file_name
- @text_files_hash.each_value.find do |file|
- file.full_name == file_name
+ @files_hash.each_value.find do |file|
+ file.text? and file.full_name == file_name
end
end
@@ -546,7 +530,6 @@ class RDoc::Store
@cache[:pages].each do |page_name|
page = load_page page_name
@files_hash[page_name] = page
- @text_files_hash[page_name] = page if page.text?
end
end
@@ -556,7 +539,7 @@ class RDoc::Store
def load_cache
#orig_enc = @encoding
- File.open cache_path, 'rb' do |io|
+ open cache_path, 'rb' do |io|
@cache = Marshal.load io.read
end
@@ -602,8 +585,6 @@ class RDoc::Store
case obj
when RDoc::NormalClass then
@classes_hash[klass_name] = obj
- when RDoc::SingleClass then
- @classes_hash[klass_name] = obj
when RDoc::NormalModule then
@modules_hash[klass_name] = obj
end
@@ -615,7 +596,7 @@ class RDoc::Store
def load_class_data klass_name
file = class_file klass_name
- File.open file, 'rb' do |io|
+ open file, 'rb' do |io|
Marshal.load io.read
end
rescue Errno::ENOENT => e
@@ -630,7 +611,7 @@ class RDoc::Store
def load_method klass_name, method_name
file = method_file klass_name, method_name
- File.open file, 'rb' do |io|
+ open file, 'rb' do |io|
obj = Marshal.load io.read
obj.store = self
obj.parent =
@@ -650,7 +631,7 @@ class RDoc::Store
def load_page page_name
file = page_file page_name
- File.open file, 'rb' do |io|
+ open file, 'rb' do |io|
obj = Marshal.load io.read
obj.store = self
obj
@@ -722,8 +703,8 @@ class RDoc::Store
# Returns the RDoc::TopLevel that is a text file and has the given +name+
def page name
- @text_files_hash.each_value.find do |file|
- file.page_name == name
+ @files_hash.each_value.find do |file|
+ file.text? and file.page_name == name
end
end
@@ -795,8 +776,10 @@ class RDoc::Store
return if @dry_run
- File.open cache_path, 'wb' do |io|
- Marshal.dump @cache, io
+ marshal = Marshal.dump @cache
+
+ open cache_path, 'wb' do |io|
+ io.write marshal
end
end
@@ -869,8 +852,10 @@ class RDoc::Store
FileUtils.rm_f to_delete
- File.open path, 'wb' do |io|
- Marshal.dump klass, io
+ marshal = Marshal.dump klass
+
+ open path, 'wb' do |io|
+ io.write marshal
end
end
@@ -892,8 +877,10 @@ class RDoc::Store
return if @dry_run
- File.open method_file(full_name, method.full_name), 'wb' do |io|
- Marshal.dump method, io
+ marshal = Marshal.dump method
+
+ open method_file(full_name, method.full_name), 'wb' do |io|
+ io.write marshal
end
end
@@ -912,8 +899,10 @@ class RDoc::Store
return if @dry_run
- File.open path, 'wb' do |io|
- Marshal.dump page, io
+ marshal = Marshal.dump page
+
+ open path, 'wb' do |io|
+ io.write marshal
end
end
diff --git a/lib/rdoc/task.rb b/lib/rdoc/task.rb
index 0bedaa50b0..323d00eabc 100644
--- a/lib/rdoc/task.rb
+++ b/lib/rdoc/task.rb
@@ -128,7 +128,7 @@ class RDoc::Task < Rake::TaskLib
attr_accessor :template
##
- # Name of format generator (<tt>--format</tt>) used by rdoc. (defaults to
+ # Name of format generator (<tt>--format<tt>) used by rdoc. (defaults to
# rdoc's default)
attr_accessor :generator
diff --git a/lib/rdoc/test_case.rb b/lib/rdoc/test_case.rb
new file mode 100644
index 0000000000..22d3f14219
--- /dev/null
+++ b/lib/rdoc/test_case.rb
@@ -0,0 +1,203 @@
+# frozen_string_literal: true
+begin
+ gem 'minitest', '~> 4.0' unless defined?(Test::Unit)
+rescue NoMethodError, Gem::LoadError
+ # for ruby tests
+end
+
+require 'minitest/autorun'
+require 'minitest/benchmark' unless ENV['NOBENCHMARK']
+
+require 'fileutils'
+require 'pp'
+require 'tempfile'
+require 'tmpdir'
+require 'stringio'
+
+require 'rdoc'
+
+##
+# RDoc::TestCase is an abstract TestCase to provide common setup and teardown
+# across all RDoc tests. The test case uses minitest, so all the assertions
+# of minitest may be used.
+#
+# The testcase provides the following:
+#
+# * A reset code-object tree
+# * A reset markup preprocessor (RDoc::Markup::PreProcess)
+# * The <code>@RM</code> alias of RDoc::Markup (for less typing)
+# * <code>@pwd</code> containing the current working directory
+# * FileUtils, pp, Tempfile, Dir.tmpdir and StringIO
+
+class RDoc::TestCase < MiniTest::Unit::TestCase
+
+ ##
+ # Abstract test-case setup
+
+ def setup
+ super
+
+ @top_level = nil
+
+ @RM = RDoc::Markup
+
+ RDoc::Markup::PreProcess.reset
+
+ @pwd = Dir.pwd
+
+ @store = RDoc::Store.new
+
+ @rdoc = RDoc::RDoc.new
+ @rdoc.store = @store
+ @rdoc.options = RDoc::Options.new
+
+ g = Object.new
+ def g.class_dir() end
+ def g.file_dir() end
+ @rdoc.generator = g
+ end
+
+ ##
+ # Asserts +path+ is a file
+
+ def assert_file path
+ assert File.file?(path), "#{path} is not a file"
+ end
+
+ ##
+ # Asserts +path+ is a directory
+
+ def assert_directory path
+ assert File.directory?(path), "#{path} is not a directory"
+ end
+
+ ##
+ # Refutes +path+ exists
+
+ def refute_file path
+ refute File.exist?(path), "#{path} exists"
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::BlankLine.new
+
+ def blank_line
+ @RM::BlankLine.new
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::BlockQuote.new with +contents+
+
+ def block *contents
+ @RM::BlockQuote.new(*contents)
+ end
+
+ ##
+ # Creates an RDoc::Comment with +text+ which was defined on +top_level+.
+ # By default the comment has the 'rdoc' format.
+
+ def comment text, top_level = @top_level
+ RDoc::Comment.new text, top_level
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::Document.new with +contents+
+
+ def doc *contents
+ @RM::Document.new(*contents)
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::HardBreak.new
+
+ def hard_break
+ @RM::HardBreak.new
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::Heading.new with +level+ and +text+
+
+ def head level, text
+ @RM::Heading.new level, text
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::ListItem.new with +label+ and +parts+
+
+ def item label = nil, *parts
+ @RM::ListItem.new label, *parts
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::List.new with +type+ and +items+
+
+ def list type = nil, *items
+ @RM::List.new type, *items
+ end
+
+ ##
+ # Enables pretty-print output
+
+ def mu_pp obj # :nodoc:
+ s = obj.pretty_inspect
+ s = RDoc::Encoding.change_encoding s, Encoding.default_external
+ s.chomp
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::Paragraph.new with +contents+
+
+ def para *a
+ @RM::Paragraph.new(*a)
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::Rule.new with +weight+
+
+ def rule weight
+ @RM::Rule.new weight
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::Raw.new with +contents+
+
+ def raw *contents
+ @RM::Raw.new(*contents)
+ end
+
+ ##
+ # Creates a temporary directory changes the current directory to it for the
+ # duration of the block.
+ #
+ # Depends upon Dir.mktmpdir
+
+ def temp_dir
+ Dir.mktmpdir do |temp_dir|
+ Dir.chdir temp_dir do
+ yield temp_dir
+ end
+ end
+ end
+
+ ##
+ # Shortcut for RDoc::Markup::Verbatim.new with +parts+
+
+ def verb *parts
+ @RM::Verbatim.new(*parts)
+ end
+
+ ##
+ # run capture_io with setting $VERBOSE = true
+
+ def verbose_capture_io
+ capture_io do
+ begin
+ orig_verbose = $VERBOSE
+ $VERBOSE = true
+ yield
+ ensure
+ $VERBOSE = orig_verbose
+ end
+ end
+ end
+end
diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb
index c3218fdb2f..7e714be0ad 100644
--- a/lib/rdoc/text.rb
+++ b/lib/rdoc/text.rb
@@ -10,8 +10,6 @@ require 'strscan'
module RDoc::Text
- attr_accessor :language
-
##
# Maps markup formats to classes that can parse them. If the format is
# unknown, "rdoc" format is used.
@@ -113,12 +111,8 @@ module RDoc::Text
def normalize_comment text
return text if text.empty?
- case language
- when :ruby
- text = strip_hashes text
- when :c
- text = strip_stars text
- end
+ text = strip_stars text
+ text = strip_hashes text
text = expand_tabs text
text = flush_left text
text = strip_newlines text
@@ -175,7 +169,7 @@ module RDoc::Text
encoding = text.encoding
- text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+\-/*\%@`\[\]]+%, ''
+ text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, ''
space = ' '
space = RDoc::Encoding.change_encoding space, encoding if encoding
diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb
index f428e2400c..05fb46e89a 100644
--- a/lib/rdoc/token_stream.rb
+++ b/lib/rdoc/token_stream.rb
@@ -74,16 +74,11 @@ module RDoc::TokenStream
##
# Adds +tokens+ to the collected tokens
- def add_tokens(tokens)
- @token_stream.concat(tokens)
+ def add_tokens(*tokens)
+ tokens.flatten.each { |token| @token_stream << token }
end
- ##
- # Adds one +token+ to the collected tokens
-
- def add_token(token)
- @token_stream.push(token)
- end
+ alias add_token add_tokens
##
# Starts collecting tokens
@@ -112,7 +107,7 @@ module RDoc::TokenStream
# Returns a string representation of the token stream
def tokens_to_s
- token_stream.compact.map { |token| token[:text] }.join ''
+ token_stream.compact.map { |token| token.text }.join ''
end
end
diff --git a/lib/rdoc/tom_doc.rb b/lib/rdoc/tom_doc.rb
index e161fcf42f..2b594b7d84 100644
--- a/lib/rdoc/tom_doc.rb
+++ b/lib/rdoc/tom_doc.rb
@@ -180,19 +180,12 @@ class RDoc::TomDoc < RDoc::Markup::Parser
case type
when :TEXT then
- @section = 'Returns' if data =~ /\A(Returns|Raises)/
+ @section = 'Returns' if data =~ /\AReturns/
paragraph << data
when :NEWLINE then
if :TEXT == peek_token[0] then
- # Lines beginning with 'Raises' in the Returns section should not be
- # treated as multiline text
- if 'Returns' == @section and
- peek_token[1].start_with?('Raises') then
- break
- else
- paragraph << ' '
- end
+ paragraph << ' '
else
break
end
@@ -242,18 +235,19 @@ class RDoc::TomDoc < RDoc::Markup::Parser
@tokens << case
when @s.scan(/\r?\n/) then
- token = [:NEWLINE, @s.matched, *pos]
- @s.newline!
+ token = [:NEWLINE, @s.matched, *token_pos(pos)]
+ @line_pos = char_pos @s.pos
+ @line += 1
token
when @s.scan(/(Examples|Signature)$/) then
- @tokens << [:HEADER, 3, *pos]
+ @tokens << [:HEADER, 3, *token_pos(pos)]
- [:TEXT, @s[1], *pos]
+ [:TEXT, @s[1], *token_pos(pos)]
when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
- [:NOTE, @s[1], *pos]
+ [:NOTE, @s[1], *token_pos(pos)]
else
@s.scan(/.*/)
- [:TEXT, @s.matched.sub(/\r$/, ''), *pos]
+ [:TEXT, @s.matched.sub(/\r$/, ''), *token_pos(pos)]
end
end
@@ -261,3 +255,4 @@ class RDoc::TomDoc < RDoc::Markup::Parser
end
end
+
diff --git a/lib/rdoc/top_level.rb b/lib/rdoc/top_level.rb
index b8b6110bb2..6186722772 100644
--- a/lib/rdoc/top_level.rb
+++ b/lib/rdoc/top_level.rb
@@ -33,7 +33,7 @@ class RDoc::TopLevel < RDoc::Context
##
# The parser class that processed this file
- attr_reader :parser
+ attr_accessor :parser
##
# Creates a new TopLevel for the file at +absolute_name+. If documentation
@@ -52,12 +52,6 @@ class RDoc::TopLevel < RDoc::Context
@classes_or_modules = []
end
- def parser=(val)
- @parser = val
- @store.update_parser_of_file(absolute_name, val) if @store
- @parser
- end
-
##
# An RDoc::TopLevel is equal to another with the same relative_name
@@ -278,7 +272,7 @@ class RDoc::TopLevel < RDoc::Context
# Is this TopLevel from a text file instead of a source code file?
def text?
- @parser and @parser.include? RDoc::Parser::Text
+ @parser and @parser.ancestors.include? RDoc::Parser::Text
end
def to_s # :nodoc:
diff --git a/lib/rdoc/version.rb b/lib/rdoc/version.rb
deleted file mode 100644
index 335aec3e1a..0000000000
--- a/lib/rdoc/version.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module RDoc
-
- ##
- # RDoc version you are using
-
- VERSION = '6.2.1.1'
-
-end
diff --git a/lib/readline.gemspec b/lib/readline.gemspec
deleted file mode 100644
index 5c641a88a5..0000000000
--- a/lib/readline.gemspec
+++ /dev/null
@@ -1,35 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = 'readline'
- spec.version = '0.0.2'
- spec.authors = ['aycabta']
- spec.email = ['aycabta@gmail.com']
-
- spec.summary = %q{It's a loader for "readline".}
- spec.description = <<~EOD
- This is just a loader for "readline". If Ruby has "readline-ext" gem that
- is a native extension, this gem will load it first. If Ruby doesn't have
- the "readline-ext" gem this gem will load "reline" that is a compatible
- library with "readline-ext" gem and is implemented by pure Ruby.
- EOD
- spec.homepage = 'https://github.com/ruby/readline'
- spec.license = 'Ruby license'
-
- spec.files = Dir['BSDL', 'COPYING', 'README.md', 'lib/readline.rb']
- spec.require_paths = ['lib']
-
- spec.post_install_message = <<~EOM
- +---------------------------------------------------------------------------+
- | This is just a loader for "readline". If Ruby has "readline-ext" gem that |
- | is a native extension, this gem will load it first. If Ruby doesn't have |
- | the "readline-ext" gem this gem will load "reline" that is a compatible   |
- | library with "readline-ext" gem and is implemented by pure Ruby.          |
- |                                                                           |
- | If you intend to use GNU Readline by `require 'readline'`, please install |
- | "readline-ext" gem.                                                       |
- +---------------------------------------------------------------------------+
- EOM
-
- spec.add_runtime_dependency 'reline'
- spec.add_development_dependency 'bundler'
- spec.add_development_dependency 'rake'
-end
diff --git a/lib/readline.rb b/lib/readline.rb
deleted file mode 100644
index 6cc923cb2f..0000000000
--- a/lib/readline.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-begin
- require 'readline.so'
-rescue LoadError
- require 'reline' unless defined? Reline
- Readline = Reline
-end
diff --git a/lib/reline.rb b/lib/reline.rb
deleted file mode 100644
index eb18d0d075..0000000000
--- a/lib/reline.rb
+++ /dev/null
@@ -1,441 +0,0 @@
-require 'io/console'
-require 'timeout'
-require 'forwardable'
-require 'reline/version'
-require 'reline/config'
-require 'reline/key_actor'
-require 'reline/key_stroke'
-require 'reline/line_editor'
-require 'reline/history'
-require 'rbconfig'
-
-module Reline
- FILENAME_COMPLETION_PROC = nil
- USERNAME_COMPLETION_PROC = nil
-
- Key = Struct.new('Key', :char, :combined_char, :with_meta)
- CursorPos = Struct.new(:x, :y)
-
- class Core
- ATTR_READER_NAMES = %i(
- completion_append_character
- basic_word_break_characters
- completer_word_break_characters
- basic_quote_characters
- completer_quote_characters
- filename_quote_characters
- special_prefixes
- completion_proc
- output_modifier_proc
- prompt_proc
- auto_indent_proc
- pre_input_hook
- dig_perfect_match_proc
- ).each(&method(:attr_reader))
-
- attr_accessor :config
- attr_accessor :key_stroke
- attr_accessor :line_editor
- attr_accessor :ambiguous_width
- attr_accessor :last_incremental_search
- attr_reader :output
-
- def initialize
- self.output = STDOUT
- yield self
- @completion_quote_character = nil
- end
-
- def encoding
- Reline::IOGate.encoding
- end
-
- def completion_append_character=(val)
- if val.nil?
- @completion_append_character = nil
- elsif val.size == 1
- @completion_append_character = val.encode(Reline::IOGate.encoding)
- elsif val.size > 1
- @completion_append_character = val[0].encode(Reline::IOGate.encoding)
- else
- @completion_append_character = nil
- end
- end
-
- def basic_word_break_characters=(v)
- @basic_word_break_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def completer_word_break_characters=(v)
- @completer_word_break_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def basic_quote_characters=(v)
- @basic_quote_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def completer_quote_characters=(v)
- @completer_quote_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def filename_quote_characters=(v)
- @filename_quote_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def special_prefixes=(v)
- @special_prefixes = v.encode(Reline::IOGate.encoding)
- end
-
- def completion_case_fold=(v)
- @config.completion_ignore_case = v
- end
-
- def completion_case_fold
- @config.completion_ignore_case
- end
-
- def completion_quote_character
- @completion_quote_character
- end
-
- def completion_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @completion_proc = p
- end
-
- def output_modifier_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @output_modifier_proc = p
- end
-
- def prompt_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @prompt_proc = p
- end
-
- def auto_indent_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @auto_indent_proc = p
- end
-
- def pre_input_hook=(p)
- @pre_input_hook = p
- end
-
- def dig_perfect_match_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @dig_perfect_match_proc = p
- end
-
- def input=(val)
- raise TypeError unless val.respond_to?(:getc) or val.nil?
- if val.respond_to?(:getc)
- if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
- Reline::ANSI.input = val
- elsif Reline::IOGate == Reline::GeneralIO
- Reline::GeneralIO.input = val
- end
- end
- end
-
- def output=(val)
- raise TypeError unless val.respond_to?(:write) or val.nil?
- @output = val
- if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
- Reline::ANSI.output = val
- end
- end
-
- def vi_editing_mode
- config.editing_mode = :vi_insert
- nil
- end
-
- def emacs_editing_mode
- config.editing_mode = :emacs
- nil
- end
-
- def vi_editing_mode?
- config.editing_mode_is?(:vi_insert, :vi_command)
- end
-
- def emacs_editing_mode?
- config.editing_mode_is?(:emacs)
- end
-
- def get_screen_size
- Reline::IOGate.get_screen_size
- end
-
- def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
- unless confirm_multiline_termination
- raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
- end
- inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
-
- whole_buffer = line_editor.whole_buffer.dup
- whole_buffer.taint if RUBY_VERSION < '2.7'
- if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
- Reline::HISTORY << whole_buffer
- end
-
- line_editor.reset_line if line_editor.whole_buffer.nil?
- whole_buffer
- end
-
- def readline(prompt = '', add_hist = false)
- inner_readline(prompt, add_hist, false)
-
- line = line_editor.line.dup
- line.taint if RUBY_VERSION < '2.7'
- if add_hist and line and line.chomp("\n").size > 0
- Reline::HISTORY << line.chomp("\n")
- end
-
- line_editor.reset_line if line_editor.line.nil?
- line
- end
-
- private def inner_readline(prompt, add_hist, multiline, &confirm_multiline_termination)
- if ENV['RELINE_STDERR_TTY']
- $stderr.reopen(ENV['RELINE_STDERR_TTY'], 'w')
- $stderr.sync = true
- $stderr.puts "Reline is used by #{Process.pid}"
- end
- otio = Reline::IOGate.prep
-
- may_req_ambiguous_char_width
- line_editor.reset(prompt, encoding: Reline::IOGate.encoding)
- if multiline
- line_editor.multiline_on
- if block_given?
- line_editor.confirm_multiline_termination_proc = confirm_multiline_termination
- end
- else
- line_editor.multiline_off
- end
- line_editor.output = output
- line_editor.completion_proc = completion_proc
- line_editor.completion_append_character = completion_append_character
- line_editor.output_modifier_proc = output_modifier_proc
- line_editor.prompt_proc = prompt_proc
- line_editor.auto_indent_proc = auto_indent_proc
- line_editor.dig_perfect_match_proc = dig_perfect_match_proc
- line_editor.pre_input_hook = pre_input_hook
-
- unless config.test_mode
- config.read
- config.reset_default_key_bindings
- Reline::IOGate::RAW_KEYSTROKE_CONFIG.each_pair do |key, func|
- config.add_default_key_binding(key, func)
- end
- end
-
- line_editor.rerender
-
- begin
- loop do
- read_io(config.keyseq_timeout) { |inputs|
- inputs.each { |c|
- line_editor.input_key(c)
- line_editor.rerender
- }
- }
- break if line_editor.finished?
- end
- Reline::IOGate.move_cursor_column(0)
- rescue Errno::EIO
- # Maybe the I/O has been closed.
- rescue StandardError => e
- line_editor.finalize
- Reline::IOGate.deprep(otio)
- raise e
- end
-
- line_editor.finalize
- Reline::IOGate.deprep(otio)
- end
-
- # Keystrokes of GNU Readline will timeout it with the specification of
- # "keyseq-timeout" when waiting for the 2nd character after the 1st one.
- # If the 2nd character comes after 1st ESC without timeout it has a
- # meta-property of meta-key to discriminate modified key with meta-key
- # from multibyte characters that come with 8th bit on.
- #
- # GNU Readline will wait for the 2nd character with "keyseq-timeout"
- # milli-seconds but wait forever after 3rd characters.
- private def read_io(keyseq_timeout, &block)
- buffer = []
- loop do
- c = Reline::IOGate.getc
- buffer << c
- result = key_stroke.match_status(buffer)
- case result
- when :matched
- expanded = key_stroke.expand(buffer).map{ |expanded_c|
- Reline::Key.new(expanded_c, expanded_c, false)
- }
- block.(expanded)
- break
- when :matching
- if buffer.size == 1
- begin
- succ_c = nil
- Timeout.timeout(keyseq_timeout / 1000.0) {
- succ_c = Reline::IOGate.getc
- }
- rescue Timeout::Error # cancel matching only when first byte
- block.([Reline::Key.new(c, c, false)])
- break
- else
- if key_stroke.match_status(buffer.dup.push(succ_c)) == :unmatched
- if c == "\e".ord
- block.([Reline::Key.new(succ_c, succ_c | 0b10000000, true)])
- else
- block.([Reline::Key.new(c, c, false), Reline::Key.new(succ_c, succ_c, false)])
- end
- break
- else
- Reline::IOGate.ungetc(succ_c)
- end
- end
- end
- when :unmatched
- if buffer.size == 1 and c == "\e".ord
- read_escaped_key(keyseq_timeout, c, block)
- else
- expanded = buffer.map{ |expanded_c|
- Reline::Key.new(expanded_c, expanded_c, false)
- }
- block.(expanded)
- end
- break
- end
- end
- end
-
- private def read_escaped_key(keyseq_timeout, c, block)
- begin
- escaped_c = nil
- Timeout.timeout(keyseq_timeout / 1000.0) {
- escaped_c = Reline::IOGate.getc
- }
- rescue Timeout::Error # independent ESC
- block.([Reline::Key.new(c, c, false)])
- else
- if escaped_c.nil?
- block.([Reline::Key.new(c, c, false)])
- elsif escaped_c >= 128 # maybe, first byte of multi byte
- block.([Reline::Key.new(c, c, false), Reline::Key.new(escaped_c, escaped_c, false)])
- elsif escaped_c == "\e".ord # escape twice
- block.([Reline::Key.new(c, c, false), Reline::Key.new(c, c, false)])
- else
- block.([Reline::Key.new(escaped_c, escaped_c | 0b10000000, true)])
- end
- end
- end
-
- private def may_req_ambiguous_char_width
- @ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File)
- return if ambiguous_width
- Reline::IOGate.move_cursor_column(0)
- begin
- output.write "\u{25bd}"
- rescue Encoding::UndefinedConversionError
- # LANG=C
- @ambiguous_width = 1
- else
- @ambiguous_width = Reline::IOGate.cursor_pos.x
- end
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- end
- end
-
- extend Forwardable
- extend SingleForwardable
-
- #--------------------------------------------------------
- # Documented API
- #--------------------------------------------------------
-
- (Core::ATTR_READER_NAMES).each { |name|
- def_single_delegators :core, "#{name}", "#{name}="
- }
- def_single_delegators :core, :input=, :output=
- def_single_delegators :core, :vi_editing_mode, :emacs_editing_mode
- def_single_delegators :core, :readline
- def_single_delegators :core, :completion_case_fold, :completion_case_fold=
- def_single_delegators :core, :completion_quote_character
- def_instance_delegators self, :readline
- private :readline
-
-
- #--------------------------------------------------------
- # Undocumented API
- #--------------------------------------------------------
-
- # Testable in original
- def_single_delegators :core, :get_screen_size
- def_single_delegators :line_editor, :eof?
- def_instance_delegators self, :eof?
- def_single_delegators :line_editor, :delete_text
- def_single_delegator :line_editor, :line, :line_buffer
- def_single_delegator :line_editor, :byte_pointer, :point
- def_single_delegator :line_editor, :byte_pointer=, :point=
-
- def self.insert_text(*args, &block)
- line_editor.insert_text(*args, &block)
- self
- end
-
- # Untestable in original
- def_single_delegator :line_editor, :rerender, :redisplay
- def_single_delegators :core, :vi_editing_mode?, :emacs_editing_mode?
- def_single_delegators :core, :ambiguous_width
- def_single_delegators :core, :last_incremental_search
- def_single_delegators :core, :last_incremental_search=
-
- def_single_delegators :core, :readmultiline
- def_instance_delegators self, :readmultiline
- private :readmultiline
-
- def self.encoding_system_needs
- self.core.encoding
- end
-
- def self.core
- @core ||= Core.new { |core|
- core.config = Reline::Config.new
- core.key_stroke = Reline::KeyStroke.new(core.config)
- core.line_editor = Reline::LineEditor.new(core.config, Reline::IOGate.encoding)
-
- core.basic_word_break_characters = " \t\n`><=;|&{("
- core.completer_word_break_characters = " \t\n`><=;|&{("
- core.basic_quote_characters = '"\''
- core.completer_quote_characters = '"\''
- core.filename_quote_characters = ""
- core.special_prefixes = ""
- }
- end
-
- def self.line_editor
- core.line_editor
- end
-end
-
-if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
- require 'reline/windows'
- if Reline::Windows.msys_tty?
- require 'reline/ansi'
- Reline::IOGate = Reline::ANSI
- else
- Reline::IOGate = Reline::Windows
- end
-else
- require 'reline/ansi'
- Reline::IOGate = Reline::ANSI
-end
-Reline::HISTORY = Reline::History.new(Reline.core.config)
-require 'reline/general_io'
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
deleted file mode 100644
index 80fccd74f9..0000000000
--- a/lib/reline/ansi.rb
+++ /dev/null
@@ -1,202 +0,0 @@
-require 'io/console'
-
-class Reline::ANSI
- def self.encoding
- Encoding.default_external
- end
-
- def self.win?
- false
- end
-
- RAW_KEYSTROKE_CONFIG = {
- # Console (80x25)
- [27, 91, 49, 126] => :ed_move_to_beg, # Home
- [27, 91, 52, 126] => :ed_move_to_end, # End
- [27, 91, 51, 126] => :key_delete, # Del
- [27, 91, 65] => :ed_prev_history, # ↑
- [27, 91, 66] => :ed_next_history, # ↓
- [27, 91, 67] => :ed_next_char, # →
- [27, 91, 68] => :ed_prev_char, # â†
-
- # KDE
- [27, 91, 72] => :ed_move_to_beg, # Home
- [27, 91, 70] => :ed_move_to_end, # End
- # Del is 0x08
- [27, 71, 65] => :ed_prev_history, # ↑
- [27, 71, 66] => :ed_next_history, # ↓
- [27, 71, 67] => :ed_next_char, # →
- [27, 71, 68] => :ed_prev_char, # â†
-
- # urxvt / exoterm
- [27, 91, 55, 126] => :ed_move_to_beg, # Home
- [27, 91, 56, 126] => :ed_move_to_end, # End
-
- # GNOME
- [27, 79, 72] => :ed_move_to_beg, # Home
- [27, 79, 70] => :ed_move_to_end, # End
- # Del is 0x08
- # Arrow keys are the same of KDE
-
- # iTerm2
- [27, 27, 91, 67] => :em_next_word, # Option+→
- [27, 27, 91, 68] => :ed_prev_word, # Option+â†
- [195, 166] => :em_next_word, # Option+f
- [195, 162] => :ed_prev_word, # Option+b
-
- # others
- [27, 32] => :em_set_mark, # M-<space>
- [24, 24] => :em_exchange_mark, # C-x C-x TODO also add Windows
- [27, 91, 49, 59, 53, 67] => :em_next_word, # Ctrl+→
- [27, 91, 49, 59, 53, 68] => :ed_prev_word, # Ctrl+â†
-
- [27, 79, 65] => :ed_prev_history, # ↑
- [27, 79, 66] => :ed_next_history, # ↓
- [27, 79, 67] => :ed_next_char, # →
- [27, 79, 68] => :ed_prev_char, # â†
- }
-
- @@input = STDIN
- def self.input=(val)
- @@input = val
- end
-
- @@output = STDOUT
- def self.output=(val)
- @@output = val
- end
-
- @@buf = []
- def self.getc
- unless @@buf.empty?
- return @@buf.shift
- end
- until c = @@input.raw(intr: true, &:getbyte)
- sleep 0.1
- end
- (c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
- rescue Errno::EIO
- # Maybe the I/O has been closed.
- nil
- end
-
- def self.ungetc(c)
- @@buf.unshift(c)
- end
-
- def self.retrieve_keybuffer
- begin
- result = select([@@input], [], [], 0.001)
- return if result.nil?
- str = @@input.read_nonblock(1024)
- str.bytes.each do |c|
- @@buf.push(c)
- end
- rescue EOFError
- end
- end
-
- def self.get_screen_size
- s = @@input.winsize
- return s if s[0] > 0 && s[1] > 0
- s = [ENV["LINES"].to_i, ENV["COLUMNS"].to_i]
- return s if s[0] > 0 && s[1] > 0
- [24, 80]
- rescue Errno::ENOTTY
- [24, 80]
- end
-
- def self.set_screen_size(rows, columns)
- @@input.winsize = [rows, columns]
- self
- rescue Errno::ENOTTY
- self
- end
-
- def self.cursor_pos
- begin
- res = ''
- m = nil
- @@input.raw do |stdin|
- @@output << "\e[6n"
- @@output.flush
- loop do
- c = stdin.getc
- next if c.nil?
- res << c
- m = res.match(/\e\[(?<row>\d+);(?<column>\d+)R/)
- break if m
- end
- (m.pre_match + m.post_match).chars.reverse_each do |ch|
- stdin.ungetc ch
- end
- end
- column = m[:column].to_i - 1
- row = m[:row].to_i - 1
- rescue Errno::ENOTTY
- begin
- buf = @@output.pread(@@output.pos, 0)
- row = buf.count("\n")
- column = buf.rindex("\n") ? (buf.size - buf.rindex("\n")) - 1 : 0
- rescue Errno::ESPIPE
- # Just returns column 1 for ambiguous width because this I/O is not
- # tty and can't seek.
- row = 0
- column = 1
- end
- end
- Reline::CursorPos.new(column, row)
- end
-
- def self.move_cursor_column(x)
- @@output.write "\e[#{x + 1}G"
- end
-
- def self.move_cursor_up(x)
- if x > 0
- @@output.write "\e[#{x}A" if x > 0
- elsif x < 0
- move_cursor_down(-x)
- end
- end
-
- def self.move_cursor_down(x)
- if x > 0
- @@output.write "\e[#{x}B" if x > 0
- elsif x < 0
- move_cursor_up(-x)
- end
- end
-
- def self.erase_after_cursor
- @@output.write "\e[K"
- end
-
- def self.scroll_down(x)
- return if x.zero?
- @@output.write "\e[#{x}S"
- end
-
- def self.clear_screen
- @@output.write "\e[2J"
- @@output.write "\e[1;1H"
- end
-
- @@old_winch_handler = nil
- def self.set_winch_handler(&handler)
- @@old_winch_handler = Signal.trap('WINCH', &handler)
- end
-
- def self.prep
- retrieve_keybuffer
- int_handle = Signal.trap('INT', 'IGNORE')
- Signal.trap('INT', int_handle)
- nil
- end
-
- def self.deprep(otio)
- int_handle = Signal.trap('INT', 'IGNORE')
- Signal.trap('INT', int_handle)
- Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
- end
-end
diff --git a/lib/reline/config.rb b/lib/reline/config.rb
deleted file mode 100644
index 370d100414..0000000000
--- a/lib/reline/config.rb
+++ /dev/null
@@ -1,345 +0,0 @@
-class Reline::Config
- attr_reader :test_mode
-
- KEYSEQ_PATTERN = /\\(?:C|Control)-[A-Za-z_]|\\(?:M|Meta)-[0-9A-Za-z_]|\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]|\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]|\\e|\\[\\\"\'abdfnrtv]|\\\d{1,3}|\\x\h{1,2}|./
-
- class InvalidInputrc < RuntimeError
- attr_accessor :file, :lineno
- end
-
- VARIABLE_NAMES = %w{
- bind-tty-special-chars
- blink-matching-paren
- byte-oriented
- completion-ignore-case
- convert-meta
- disable-completion
- enable-keypad
- expand-tilde
- history-preserve-point
- history-size
- horizontal-scroll-mode
- input-meta
- keyseq-timeout
- mark-directories
- mark-modified-lines
- mark-symlinked-directories
- match-hidden-files
- meta-flag
- output-meta
- page-completions
- prefer-visible-bell
- print-completions-horizontally
- show-all-if-ambiguous
- show-all-if-unmodified
- visible-stats
- show-mode-in-prompt
- vi-cmd-mode-icon
- vi-ins-mode-icon
- emacs-mode-string
- }
- VARIABLE_NAME_SYMBOLS = VARIABLE_NAMES.map { |v| :"#{v.tr(?-, ?_)}" }
- VARIABLE_NAME_SYMBOLS.each do |v|
- attr_accessor v
- end
-
- def initialize
- @additional_key_bindings = {} # from inputrc
- @default_key_bindings = {} # environment-dependent
- @skip_section = nil
- @if_stack = nil
- @editing_mode_label = :emacs
- @keymap_label = :emacs
- @key_actors = {}
- @key_actors[:emacs] = Reline::KeyActor::Emacs.new
- @key_actors[:vi_insert] = Reline::KeyActor::ViInsert.new
- @key_actors[:vi_command] = Reline::KeyActor::ViCommand.new
- @vi_cmd_mode_icon = '(cmd)'
- @vi_ins_mode_icon = '(ins)'
- @emacs_mode_string = '@'
- # https://tiswww.case.edu/php/chet/readline/readline.html#IDX25
- @history_size = -1 # unlimited
- @keyseq_timeout = 500
- @test_mode = false
- end
-
- def reset
- if editing_mode_is?(:vi_command)
- @editing_mode_label = :vi_insert
- end
- @additional_key_bindings = {}
- @default_key_bindings = {}
- end
-
- def editing_mode
- @key_actors[@editing_mode_label]
- end
-
- def editing_mode=(val)
- @editing_mode_label = val
- end
-
- def editing_mode_is?(*val)
- (val.respond_to?(:any?) ? val : [val]).any?(@editing_mode_label)
- end
-
- def keymap
- @key_actors[@keymap_label]
- end
-
- def inputrc_path
- case ENV['INPUTRC']
- when nil, ''
- else
- return File.expand_path(ENV['INPUTRC'])
- end
-
- # In the XDG Specification, if ~/.config/readline/inputrc exists, then
- # ~/.inputrc should not be read, but for compatibility with GNU Readline,
- # if ~/.inputrc exists, then it is given priority.
- home_rc_path = File.expand_path('~/.inputrc')
- return home_rc_path if File.exist?(home_rc_path)
-
- case path = ENV['XDG_CONFIG_HOME']
- when nil, ''
- else
- path = File.join(path, 'readline/inputrc')
- return path if File.exist?(path) and path == File.expand_path(path)
- end
-
- path = File.expand_path('~/.config/readline/inputrc')
- return path if File.exist?(path)
-
- return home_rc_path
- end
-
- def read(file = nil)
- file ||= inputrc_path
- begin
- if file.respond_to?(:readlines)
- lines = file.readlines
- else
- lines = File.readlines(file)
- end
- rescue Errno::ENOENT
- return nil
- end
-
- read_lines(lines, file)
- self
- rescue InvalidInputrc => e
- warn e.message
- nil
- end
-
- def key_bindings
- # override @default_key_bindings with @additional_key_bindings
- @default_key_bindings.merge(@additional_key_bindings)
- end
-
- def add_default_key_binding(keystroke, target)
- @default_key_bindings[keystroke] = target
- end
-
- def reset_default_key_bindings
- @default_key_bindings = {}
- end
-
- def read_lines(lines, file = nil)
- conditions = [@skip_section, @if_stack]
- @skip_section = nil
- @if_stack = []
-
- lines.each_with_index do |line, no|
- next if line.match(/\A\s*#/)
-
- no += 1
-
- line = line.chomp.lstrip
- if line.start_with?('$')
- handle_directive(line[1..-1], file, no)
- next
- end
-
- next if @skip_section
-
- case line
- when /^set +([^ ]+) +([^ ]+)/i
- var, value = $1.downcase, $2
- bind_variable(var, value)
- next
- when /\s*("#{KEYSEQ_PATTERN}+")\s*:\s*(.*)\s*$/o
- key, func_name = $1, $2
- keystroke, func = bind_key(key, func_name)
- next unless keystroke
- @additional_key_bindings[keystroke] = func
- end
- end
- unless @if_stack.empty?
- raise InvalidInputrc, "#{file}:#{@if_stack.last[1]}: unclosed if"
- end
- ensure
- @skip_section, @if_stack = conditions
- end
-
- def handle_directive(directive, file, no)
- directive, args = directive.split(' ')
- case directive
- when 'if'
- condition = false
- case args
- when 'mode'
- when 'term'
- when 'version'
- else # application name
- condition = true if args == 'Ruby'
- condition = true if args == 'Reline'
- end
- @if_stack << [file, no, @skip_section]
- @skip_section = !condition
- when 'else'
- if @if_stack.empty?
- raise InvalidInputrc, "#{file}:#{no}: unmatched else"
- end
- @skip_section = !@skip_section
- when 'endif'
- if @if_stack.empty?
- raise InvalidInputrc, "#{file}:#{no}: unmatched endif"
- end
- @skip_section = @if_stack.pop
- when 'include'
- read(args)
- end
- end
-
- def bind_variable(name, value)
- case name
- when 'history-size'
- begin
- @history_size = Integer(value)
- rescue ArgumentError
- @history_size = 500
- end
- when 'bell-style'
- @bell_style =
- case value
- when 'none', 'off'
- :none
- when 'audible', 'on'
- :audible
- when 'visible'
- :visible
- else
- :audible
- end
- when 'comment-begin'
- @comment_begin = value.dup
- when 'completion-query-items'
- @completion_query_items = value.to_i
- when 'isearch-terminators'
- @isearch_terminators = instance_eval(value)
- when 'editing-mode'
- case value
- when 'emacs'
- @editing_mode_label = :emacs
- @keymap_label = :emacs
- when 'vi'
- @editing_mode_label = :vi_insert
- @keymap_label = :vi_insert
- end
- when 'keymap'
- case value
- when 'emacs', 'emacs-standard', 'emacs-meta', 'emacs-ctlx'
- @keymap_label = :emacs
- when 'vi', 'vi-move', 'vi-command'
- @keymap_label = :vi_command
- when 'vi-insert'
- @keymap_label = :vi_insert
- end
- when 'keyseq-timeout'
- @keyseq_timeout = value.to_i
- when 'show-mode-in-prompt'
- case value
- when 'off'
- @show_mode_in_prompt = false
- when 'on'
- @show_mode_in_prompt = true
- else
- @show_mode_in_prompt = false
- end
- when 'vi-cmd-mode-string'
- @vi_cmd_mode_icon = retrieve_string(value)
- when 'vi-ins-mode-string'
- @vi_ins_mode_icon = retrieve_string(value)
- when 'emacs-mode-string'
- @emacs_mode_string = retrieve_string(value)
- when *VARIABLE_NAMES then
- variable_name = :"@#{name.tr(?-, ?_)}"
- instance_variable_set(variable_name, value.nil? || value == '1' || value == 'on')
- end
- end
-
- def retrieve_string(str)
- if str =~ /\A"(.*)"\z/
- parse_keyseq($1).map(&:chr).join
- else
- parse_keyseq(str).map(&:chr).join
- end
- end
-
- def bind_key(key, func_name)
- if key =~ /\A"(.*)"\z/
- keyseq = parse_keyseq($1)
- else
- keyseq = nil
- end
- if func_name =~ /"(.*)"/
- func = parse_keyseq($1)
- else
- func = func_name.tr(?-, ?_).to_sym # It must be macro.
- end
- [keyseq, func]
- end
-
- def key_notation_to_code(notation)
- case notation
- when /\\(?:C|Control)-([A-Za-z_])/
- (1 + $1.downcase.ord - ?a.ord)
- when /\\(?:M|Meta)-([0-9A-Za-z_])/
- modified_key = $1
- case $1
- when /[0-9]/
- ?\M-0.bytes.first + (modified_key.ord - ?0.ord)
- when /[A-Z]/
- ?\M-A.bytes.first + (modified_key.ord - ?A.ord)
- when /[a-z]/
- ?\M-a.bytes.first + (modified_key.ord - ?a.ord)
- end
- when /\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]/, /\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]/
- # 129 M-^A
- when /\\(\d{1,3})/ then $1.to_i(8) # octal
- when /\\x(\h{1,2})/ then $1.to_i(16) # hexadecimal
- when "\\e" then ?\e.ord
- when "\\\\" then ?\\.ord
- when "\\\"" then ?".ord
- when "\\'" then ?'.ord
- when "\\a" then ?\a.ord
- when "\\b" then ?\b.ord
- when "\\d" then ?\d.ord
- when "\\f" then ?\f.ord
- when "\\n" then ?\n.ord
- when "\\r" then ?\r.ord
- when "\\t" then ?\t.ord
- when "\\v" then ?\v.ord
- else notation.ord
- end
- end
-
- def parse_keyseq(str)
- ret = []
- str.scan(KEYSEQ_PATTERN) do
- ret << key_notation_to_code($&)
- end
- ret
- end
-end
diff --git a/lib/reline/general_io.rb b/lib/reline/general_io.rb
deleted file mode 100644
index 85f1f13eed..0000000000
--- a/lib/reline/general_io.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'timeout'
-
-class Reline::GeneralIO
- def self.encoding
- RUBY_PLATFORM =~ /mswin|mingw/ ? Encoding::UTF_8 : Encoding::default_external
- end
-
- def self.win?
- false
- end
-
- RAW_KEYSTROKE_CONFIG = {}
-
- @@buf = []
-
- def self.input=(val)
- @@input = val
- end
-
- def self.getc
- unless @@buf.empty?
- return @@buf.shift
- end
- c = nil
- loop do
- result = select([@@input], [], [], 0.1)
- next if result.nil?
- c = @@input.read(1)
- break
- end
- c&.ord
- end
-
- def self.ungetc(c)
- @@buf.unshift(c)
- end
-
- def self.get_screen_size
- [1, 1]
- end
-
- def self.cursor_pos
- Reline::CursorPos.new(1, 1)
- end
-
- def self.move_cursor_column(val)
- end
-
- def self.move_cursor_up(val)
- end
-
- def self.move_cursor_down(val)
- end
-
- def self.erase_after_cursor
- end
-
- def self.scroll_down(val)
- end
-
- def self.clear_screen
- end
-
- def self.set_screen_size(rows, columns)
- end
-
- def self.set_winch_handler(&handler)
- end
-
- def self.prep
- end
-
- def self.deprep(otio)
- end
-end
diff --git a/lib/reline/history.rb b/lib/reline/history.rb
deleted file mode 100644
index 7a1ed6b90b..0000000000
--- a/lib/reline/history.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-class Reline::History < Array
- def initialize(config)
- @config = config
- end
-
- def to_s
- 'HISTORY'
- end
-
- def delete_at(index)
- index = check_index(index)
- super(index)
- end
-
- def [](index)
- index = check_index(index) unless index.is_a?(Range)
- super(index)
- end
-
- def []=(index, val)
- index = check_index(index)
- super(index, String.new(val, encoding: Reline.encoding_system_needs))
- end
-
- def concat(*val)
- val.each do |v|
- push(*v)
- end
- end
-
- def push(*val)
- # If history_size is zero, all histories are dropped.
- return self if @config.history_size.zero?
- # If history_size is negative, history size is unlimited.
- if @config.history_size.positive?
- diff = size + val.size - @config.history_size
- if diff > 0
- if diff <= size
- shift(diff)
- else
- diff -= size
- clear
- val.shift(diff)
- end
- end
- end
- super(*(val.map{ |v|
- String.new(v, encoding: Reline.encoding_system_needs)
- }))
- end
-
- def <<(val)
- # If history_size is zero, all histories are dropped.
- return self if @config.history_size.zero?
- # If history_size is negative, history size is unlimited.
- if @config.history_size.positive?
- shift if size + 1 > @config.history_size
- end
- super(String.new(val, encoding: Reline.encoding_system_needs))
- end
-
- private def check_index(index)
- index += size if index < 0
- if index < -2147483648 or 2147483647 < index
- raise RangeError.new("integer #{index} too big to convert to `int'")
- end
- # If history_size is negative, history size is unlimited.
- if @config.history_size.positive?
- if index < -@config.history_size or @config.history_size < index
- raise RangeError.new("index=<#{index}>")
- end
- end
- raise IndexError.new("index=<#{index}>") if index < 0 or size <= index
- index
- end
-end
diff --git a/lib/reline/key_actor.rb b/lib/reline/key_actor.rb
deleted file mode 100644
index ebe09d2009..0000000000
--- a/lib/reline/key_actor.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module Reline::KeyActor
-end
-
-require 'reline/key_actor/base'
-require 'reline/key_actor/emacs'
-require 'reline/key_actor/vi_command'
-require 'reline/key_actor/vi_insert'
diff --git a/lib/reline/key_actor/base.rb b/lib/reline/key_actor/base.rb
deleted file mode 100644
index f4abac55d4..0000000000
--- a/lib/reline/key_actor/base.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class Reline::KeyActor::Base
- MAPPING = Array.new(256)
-
- def get_method(key)
- self.class::MAPPING[key]
- end
-end
diff --git a/lib/reline/key_actor/emacs.rb b/lib/reline/key_actor/emacs.rb
deleted file mode 100644
index 1e51d4fa18..0000000000
--- a/lib/reline/key_actor/emacs.rb
+++ /dev/null
@@ -1,517 +0,0 @@
-class Reline::KeyActor::Emacs < Reline::KeyActor::Base
- MAPPING = [
- # 0 ^@
- :em_set_mark,
- # 1 ^A
- :ed_move_to_beg,
- # 2 ^B
- :ed_prev_char,
- # 3 ^C
- :ed_ignore,
- # 4 ^D
- :em_delete,
- # 5 ^E
- :ed_move_to_end,
- # 6 ^F
- :ed_next_char,
- # 7 ^G
- :ed_unassigned,
- # 8 ^H
- :em_delete_prev_char,
- # 9 ^I
- :ed_unassigned,
- # 10 ^J
- :ed_newline,
- # 11 ^K
- :ed_kill_line,
- # 12 ^L
- :ed_clear_screen,
- # 13 ^M
- :ed_newline,
- # 14 ^N
- :ed_next_history,
- # 15 ^O
- :ed_ignore,
- # 16 ^P
- :ed_prev_history,
- # 17 ^Q
- :ed_quoted_insert,
- # 18 ^R
- :vi_search_prev,
- # 19 ^S
- :vi_search_next,
- # 20 ^T
- :ed_transpose_chars,
- # 21 ^U
- :em_kill_line,
- # 22 ^V
- :ed_quoted_insert,
- # 23 ^W
- :em_kill_region,
- # 24 ^X
- :ed_sequence_lead_in,
- # 25 ^Y
- :em_yank,
- # 26 ^Z
- :ed_ignore,
- # 27 ^[
- :em_meta_next,
- # 28 ^\
- :ed_ignore,
- # 29 ^]
- :ed_ignore,
- # 30 ^^
- :ed_unassigned,
- # 31 ^_
- :ed_unassigned,
- # 32 SPACE
- :ed_insert,
- # 33 !
- :ed_insert,
- # 34 "
- :ed_insert,
- # 35 #
- :ed_insert,
- # 36 $
- :ed_insert,
- # 37 %
- :ed_insert,
- # 38 &
- :ed_insert,
- # 39 '
- :ed_insert,
- # 40 (
- :ed_insert,
- # 41 )
- :ed_insert,
- # 42 *
- :ed_insert,
- # 43 +
- :ed_insert,
- # 44 ,
- :ed_insert,
- # 45 -
- :ed_insert,
- # 46 .
- :ed_insert,
- # 47 /
- :ed_insert,
- # 48 0
- :ed_digit,
- # 49 1
- :ed_digit,
- # 50 2
- :ed_digit,
- # 51 3
- :ed_digit,
- # 52 4
- :ed_digit,
- # 53 5
- :ed_digit,
- # 54 6
- :ed_digit,
- # 55 7
- :ed_digit,
- # 56 8
- :ed_digit,
- # 57 9
- :ed_digit,
- # 58 :
- :ed_insert,
- # 59 ;
- :ed_insert,
- # 60 <
- :ed_insert,
- # 61 =
- :ed_insert,
- # 62 >
- :ed_insert,
- # 63 ?
- :ed_insert,
- # 64 @
- :ed_insert,
- # 65 A
- :ed_insert,
- # 66 B
- :ed_insert,
- # 67 C
- :ed_insert,
- # 68 D
- :ed_insert,
- # 69 E
- :ed_insert,
- # 70 F
- :ed_insert,
- # 71 G
- :ed_insert,
- # 72 H
- :ed_insert,
- # 73 I
- :ed_insert,
- # 74 J
- :ed_insert,
- # 75 K
- :ed_insert,
- # 76 L
- :ed_insert,
- # 77 M
- :ed_insert,
- # 78 N
- :ed_insert,
- # 79 O
- :ed_insert,
- # 80 P
- :ed_insert,
- # 81 Q
- :ed_insert,
- # 82 R
- :ed_insert,
- # 83 S
- :ed_insert,
- # 84 T
- :ed_insert,
- # 85 U
- :ed_insert,
- # 86 V
- :ed_insert,
- # 87 W
- :ed_insert,
- # 88 X
- :ed_insert,
- # 89 Y
- :ed_insert,
- # 90 Z
- :ed_insert,
- # 91 [
- :ed_insert,
- # 92 \
- :ed_insert,
- # 93 ]
- :ed_insert,
- # 94 ^
- :ed_insert,
- # 95 _
- :ed_insert,
- # 96 `
- :ed_insert,
- # 97 a
- :ed_insert,
- # 98 b
- :ed_insert,
- # 99 c
- :ed_insert,
- # 100 d
- :ed_insert,
- # 101 e
- :ed_insert,
- # 102 f
- :ed_insert,
- # 103 g
- :ed_insert,
- # 104 h
- :ed_insert,
- # 105 i
- :ed_insert,
- # 106 j
- :ed_insert,
- # 107 k
- :ed_insert,
- # 108 l
- :ed_insert,
- # 109 m
- :ed_insert,
- # 110 n
- :ed_insert,
- # 111 o
- :ed_insert,
- # 112 p
- :ed_insert,
- # 113 q
- :ed_insert,
- # 114 r
- :ed_insert,
- # 115 s
- :ed_insert,
- # 116 t
- :ed_insert,
- # 117 u
- :ed_insert,
- # 118 v
- :ed_insert,
- # 119 w
- :ed_insert,
- # 120 x
- :ed_insert,
- # 121 y
- :ed_insert,
- # 122 z
- :ed_insert,
- # 123 {
- :ed_insert,
- # 124 |
- :ed_insert,
- # 125 }
- :ed_insert,
- # 126 ~
- :ed_insert,
- # 127 ^?
- :em_delete_prev_char,
- # 128 M-^@
- :ed_unassigned,
- # 129 M-^A
- :ed_unassigned,
- # 130 M-^B
- :ed_unassigned,
- # 131 M-^C
- :ed_unassigned,
- # 132 M-^D
- :ed_unassigned,
- # 133 M-^E
- :ed_unassigned,
- # 134 M-^F
- :ed_unassigned,
- # 135 M-^G
- :ed_unassigned,
- # 136 M-^H
- :ed_delete_prev_word,
- # 137 M-^I
- :ed_unassigned,
- # 138 M-^J
- :key_newline,
- # 139 M-^K
- :ed_unassigned,
- # 140 M-^L
- :ed_clear_screen,
- # 141 M-^M
- :key_newline,
- # 142 M-^N
- :ed_unassigned,
- # 143 M-^O
- :ed_unassigned,
- # 144 M-^P
- :ed_unassigned,
- # 145 M-^Q
- :ed_unassigned,
- # 146 M-^R
- :ed_unassigned,
- # 147 M-^S
- :ed_unassigned,
- # 148 M-^T
- :ed_unassigned,
- # 149 M-^U
- :ed_unassigned,
- # 150 M-^V
- :ed_unassigned,
- # 151 M-^W
- :ed_unassigned,
- # 152 M-^X
- :ed_unassigned,
- # 153 M-^Y
- :ed_unassigned,
- # 154 M-^Z
- :ed_unassigned,
- # 155 M-^[
- :ed_unassigned,
- # 156 M-^\
- :ed_unassigned,
- # 157 M-^]
- :ed_unassigned,
- # 158 M-^^
- :ed_unassigned,
- # 159 M-^_
- :em_copy_prev_word,
- # 160 M-SPACE
- :ed_unassigned,
- # 161 M-!
- :ed_unassigned,
- # 162 M-"
- :ed_unassigned,
- # 163 M-#
- :ed_unassigned,
- # 164 M-$
- :ed_unassigned,
- # 165 M-%
- :ed_unassigned,
- # 166 M-&
- :ed_unassigned,
- # 167 M-'
- :ed_unassigned,
- # 168 M-(
- :ed_unassigned,
- # 169 M-)
- :ed_unassigned,
- # 170 M-*
- :ed_unassigned,
- # 171 M-+
- :ed_unassigned,
- # 172 M-,
- :ed_unassigned,
- # 173 M--
- :ed_unassigned,
- # 174 M-.
- :ed_unassigned,
- # 175 M-/
- :ed_unassigned,
- # 176 M-0
- :ed_argument_digit,
- # 177 M-1
- :ed_argument_digit,
- # 178 M-2
- :ed_argument_digit,
- # 179 M-3
- :ed_argument_digit,
- # 180 M-4
- :ed_argument_digit,
- # 181 M-5
- :ed_argument_digit,
- # 182 M-6
- :ed_argument_digit,
- # 183 M-7
- :ed_argument_digit,
- # 184 M-8
- :ed_argument_digit,
- # 185 M-9
- :ed_argument_digit,
- # 186 M-:
- :ed_unassigned,
- # 187 M-;
- :ed_unassigned,
- # 188 M-<
- :ed_unassigned,
- # 189 M-=
- :ed_unassigned,
- # 190 M->
- :ed_unassigned,
- # 191 M-?
- :ed_unassigned,
- # 192 M-@
- :ed_unassigned,
- # 193 M-A
- :ed_unassigned,
- # 194 M-B
- :ed_prev_word,
- # 195 M-C
- :em_capitol_case,
- # 196 M-D
- :em_delete_next_word,
- # 197 M-E
- :ed_unassigned,
- # 198 M-F
- :em_next_word,
- # 199 M-G
- :ed_unassigned,
- # 200 M-H
- :ed_unassigned,
- # 201 M-I
- :ed_unassigned,
- # 202 M-J
- :ed_unassigned,
- # 203 M-K
- :ed_unassigned,
- # 204 M-L
- :em_lower_case,
- # 205 M-M
- :ed_unassigned,
- # 206 M-N
- :vi_search_next,
- # 207 M-O
- :ed_sequence_lead_in,
- # 208 M-P
- :vi_search_prev,
- # 209 M-Q
- :ed_unassigned,
- # 210 M-R
- :ed_unassigned,
- # 211 M-S
- :ed_unassigned,
- # 212 M-T
- :ed_unassigned,
- # 213 M-U
- :em_upper_case,
- # 214 M-V
- :ed_unassigned,
- # 215 M-W
- :em_copy_region,
- # 216 M-X
- :ed_command,
- # 217 M-Y
- :ed_unassigned,
- # 218 M-Z
- :ed_unassigned,
- # 219 M-[
- :ed_sequence_lead_in,
- # 220 M-\
- :ed_unassigned,
- # 221 M-]
- :ed_unassigned,
- # 222 M-^
- :ed_unassigned,
- # 223 M-_
- :ed_unassigned,
- # 224 M-`
- :ed_unassigned,
- # 225 M-a
- :ed_unassigned,
- # 226 M-b
- :ed_prev_word,
- # 227 M-c
- :em_capitol_case,
- # 228 M-d
- :em_delete_next_word,
- # 229 M-e
- :ed_unassigned,
- # 230 M-f
- :em_next_word,
- # 231 M-g
- :ed_unassigned,
- # 232 M-h
- :ed_unassigned,
- # 233 M-i
- :ed_unassigned,
- # 234 M-j
- :ed_unassigned,
- # 235 M-k
- :ed_unassigned,
- # 236 M-l
- :em_lower_case,
- # 237 M-m
- :ed_unassigned,
- # 238 M-n
- :vi_search_next,
- # 239 M-o
- :ed_unassigned,
- # 240 M-p
- :vi_search_prev,
- # 241 M-q
- :ed_unassigned,
- # 242 M-r
- :ed_unassigned,
- # 243 M-s
- :ed_unassigned,
- # 244 M-t
- :ed_transpose_words,
- # 245 M-u
- :em_upper_case,
- # 246 M-v
- :ed_unassigned,
- # 247 M-w
- :em_copy_region,
- # 248 M-x
- :ed_command,
- # 249 M-y
- :ed_unassigned,
- # 250 M-z
- :ed_unassigned,
- # 251 M-{
- :ed_unassigned,
- # 252 M-|
- :ed_unassigned,
- # 253 M-}
- :ed_unassigned,
- # 254 M-~
- :ed_unassigned,
- # 255 M-^?
- :ed_delete_prev_word
- # EOF
- ]
-end
diff --git a/lib/reline/key_actor/vi_command.rb b/lib/reline/key_actor/vi_command.rb
deleted file mode 100644
index 54b4a60383..0000000000
--- a/lib/reline/key_actor/vi_command.rb
+++ /dev/null
@@ -1,518 +0,0 @@
-class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
- MAPPING = [
- # 0 ^@
- :ed_unassigned,
- # 1 ^A
- :ed_move_to_beg,
- # 2 ^B
- :ed_unassigned,
- # 3 ^C
- :ed_ignore,
- # 4 ^D
- :vi_end_of_transmission,
- # 5 ^E
- :ed_move_to_end,
- # 6 ^F
- :ed_unassigned,
- # 7 ^G
- :ed_unassigned,
- # 8 ^H
- :ed_delete_prev_char,
- # 9 ^I
- :ed_unassigned,
- # 10 ^J
- :ed_newline,
- # 11 ^K
- :ed_kill_line,
- # 12 ^L
- :ed_clear_screen,
- # 13 ^M
- :ed_newline,
- # 14 ^N
- :ed_next_history,
- # 15 ^O
- :ed_ignore,
- # 16 ^P
- :ed_prev_history,
- # 17 ^Q
- :ed_ignore,
- # 18 ^R
- :vi_search_prev,
- # 19 ^S
- :ed_ignore,
- # 20 ^T
- :ed_unassigned,
- # 21 ^U
- :vi_kill_line_prev,
- # 22 ^V
- :ed_quoted_insert,
- # 23 ^W
- :ed_delete_prev_word,
- # 24 ^X
- :ed_unassigned,
- # 25 ^Y
- :ed_unassigned,
- # 26 ^Z
- :ed_unassigned,
- # 27 ^[
- :ed_unassigned,
- # 28 ^\
- :ed_ignore,
- # 29 ^]
- :ed_unassigned,
- # 30 ^^
- :ed_unassigned,
- # 31 ^_
- :ed_unassigned,
- # 32 SPACE
- :ed_next_char,
- # 33 !
- :ed_unassigned,
- # 34 "
- :ed_unassigned,
- # 35 #
- :vi_comment_out,
- # 36 $
- :ed_move_to_end,
- # 37 %
- :vi_match,
- # 38 &
- :ed_unassigned,
- # 39 '
- :ed_unassigned,
- # 40 (
- :ed_unassigned,
- # 41 )
- :ed_unassigned,
- # 42 *
- :ed_unassigned,
- # 43 +
- :ed_next_history,
- # 44 ,
- :vi_repeat_prev_char,
- # 45 -
- :ed_prev_history,
- # 46 .
- :vi_redo,
- # 47 /
- :vi_search_prev,
- # 48 0
- :vi_zero,
- # 49 1
- :ed_argument_digit,
- # 50 2
- :ed_argument_digit,
- # 51 3
- :ed_argument_digit,
- # 52 4
- :ed_argument_digit,
- # 53 5
- :ed_argument_digit,
- # 54 6
- :ed_argument_digit,
- # 55 7
- :ed_argument_digit,
- # 56 8
- :ed_argument_digit,
- # 57 9
- :ed_argument_digit,
- # 58 :
- :ed_command,
- # 59 ;
- :vi_repeat_next_char,
- # 60 <
- :ed_unassigned,
- # 61 =
- :ed_unassigned,
- # 62 >
- :ed_unassigned,
- # 63 ?
- :vi_search_next,
- # 64 @
- :vi_alias,
- # 65 A
- :vi_add_at_eol,
- # 66 B
- :vi_prev_big_word,
- # 67 C
- :vi_change_to_eol,
- # 68 D
- :ed_kill_line,
- # 69 E
- :vi_end_big_word,
- # 70 F
- :vi_prev_char,
- # 71 G
- :vi_to_history_line,
- # 72 H
- :ed_unassigned,
- # 73 I
- :vi_insert_at_bol,
- # 74 J
- :vi_join_lines,
- # 75 K
- :vi_search_prev,
- # 76 L
- :ed_unassigned,
- # 77 M
- :ed_unassigned,
- # 78 N
- :vi_repeat_search_prev,
- # 79 O
- :ed_sequence_lead_in,
- # 80 P
- :vi_paste_prev,
- # 81 Q
- :ed_unassigned,
- # 82 R
- :vi_replace_mode,
- # 83 S
- :vi_substitute_line,
- # 84 T
- :vi_to_prev_char,
- # 85 U
- :vi_undo_line,
- # 86 V
- :ed_unassigned,
- # 87 W
- :vi_next_big_word,
- # 88 X
- :ed_delete_prev_char,
- # 89 Y
- :vi_yank_end,
- # 90 Z
- :ed_unassigned,
- # 91 [
- :ed_sequence_lead_in,
- # 92 \
- :ed_unassigned,
- # 93 ]
- :ed_unassigned,
- # 94 ^
- :vi_first_print,
- # 95 _
- :vi_history_word,
- # 96 `
- :ed_unassigned,
- # 97 a
- :vi_add,
- # 98 b
- :vi_prev_word,
- # 99 c
- :vi_change_meta,
- # 100 d
- :vi_delete_meta,
- # 101 e
- :vi_end_word,
- # 102 f
- :vi_next_char,
- # 103 g
- :ed_unassigned,
- # 104 h
- :ed_prev_char,
- # 105 i
- :vi_insert,
- # 106 j
- :ed_next_history,
- # 107 k
- :ed_prev_history,
- # 108 l
- :ed_next_char,
- # 109 m
- :ed_unassigned,
- # 110 n
- :vi_repeat_search_next,
- # 111 o
- :ed_unassigned,
- # 112 p
- :vi_paste_next,
- # 113 q
- :ed_unassigned,
- # 114 r
- :vi_replace_char,
- # 115 s
- :vi_substitute_char,
- # 116 t
- :vi_to_next_char,
- # 117 u
- :vi_undo,
- # 118 v
- :vi_histedit,
- # 119 w
- :vi_next_word,
- # 120 x
- :ed_delete_next_char,
- # 121 y
- :vi_yank,
- # 122 z
- :ed_unassigned,
- # 123 {
- :ed_unassigned,
- # 124 |
- :vi_to_column,
- # 125 }
- :ed_unassigned,
- # 126 ~
- :vi_change_case,
- # 127 ^?
- :ed_delete_prev_char,
- # 128 M-^@
- :ed_unassigned,
- # 129 M-^A
- :ed_unassigned,
- # 130 M-^B
- :ed_unassigned,
- # 131 M-^C
- :ed_unassigned,
- # 132 M-^D
- :ed_unassigned,
- # 133 M-^E
- :ed_unassigned,
- # 134 M-^F
- :ed_unassigned,
- # 135 M-^G
- :ed_unassigned,
- # 136 M-^H
- :ed_unassigned,
- # 137 M-^I
- :ed_unassigned,
- # 138 M-^J
- :ed_unassigned,
- # 139 M-^K
- :ed_unassigned,
- # 140 M-^L
- :ed_unassigned,
- # 141 M-^M
- :ed_unassigned,
- # 142 M-^N
- :ed_unassigned,
- # 143 M-^O
- :ed_unassigned,
- # 144 M-^P
- :ed_unassigned,
- # 145 M-^Q
- :ed_unassigned,
- # 146 M-^R
- :ed_unassigned,
- # 147 M-^S
- :ed_unassigned,
- # 148 M-^T
- :ed_unassigned,
- # 149 M-^U
- :ed_unassigned,
- # 150 M-^V
- :ed_unassigned,
- # 151 M-^W
- :ed_unassigned,
- # 152 M-^X
- :ed_unassigned,
- # 153 M-^Y
- :ed_unassigned,
- # 154 M-^Z
- :ed_unassigned,
- # 155 M-^[
- :ed_unassigned,
- # 156 M-^\
- :ed_unassigned,
- # 157 M-^]
- :ed_unassigned,
- # 158 M-^^
- :ed_unassigned,
- # 159 M-^_
- :ed_unassigned,
- # 160 M-SPACE
- :ed_unassigned,
- # 161 M-!
- :ed_unassigned,
- # 162 M-"
- :ed_unassigned,
- # 163 M-#
- :ed_unassigned,
- # 164 M-$
- :ed_unassigned,
- # 165 M-%
- :ed_unassigned,
- # 166 M-&
- :ed_unassigned,
- # 167 M-'
- :ed_unassigned,
- # 168 M-(
- :ed_unassigned,
- # 169 M-)
- :ed_unassigned,
- # 170 M-*
- :ed_unassigned,
- # 171 M-+
- :ed_unassigned,
- # 172 M-,
- :ed_unassigned,
- # 173 M--
- :ed_unassigned,
- # 174 M-.
- :ed_unassigned,
- # 175 M-/
- :ed_unassigned,
- # 176 M-0
- :ed_unassigned,
- # 177 M-1
- :ed_unassigned,
- # 178 M-2
- :ed_unassigned,
- # 179 M-3
- :ed_unassigned,
- # 180 M-4
- :ed_unassigned,
- # 181 M-5
- :ed_unassigned,
- # 182 M-6
- :ed_unassigned,
- # 183 M-7
- :ed_unassigned,
- # 184 M-8
- :ed_unassigned,
- # 185 M-9
- :ed_unassigned,
- # 186 M-:
- :ed_unassigned,
- # 187 M-;
- :ed_unassigned,
- # 188 M-<
- :ed_unassigned,
- # 189 M-=
- :ed_unassigned,
- # 190 M->
- :ed_unassigned,
- # 191 M-?
- :ed_unassigned,
- # 192 M-@
- :ed_unassigned,
- # 193 M-A
- :ed_unassigned,
- # 194 M-B
- :ed_unassigned,
- # 195 M-C
- :ed_unassigned,
- # 196 M-D
- :ed_unassigned,
- # 197 M-E
- :ed_unassigned,
- # 198 M-F
- :ed_unassigned,
- # 199 M-G
- :ed_unassigned,
- # 200 M-H
- :ed_unassigned,
- # 201 M-I
- :ed_unassigned,
- # 202 M-J
- :ed_unassigned,
- # 203 M-K
- :ed_unassigned,
- # 204 M-L
- :ed_unassigned,
- # 205 M-M
- :ed_unassigned,
- # 206 M-N
- :ed_unassigned,
- # 207 M-O
- :ed_sequence_lead_in,
- # 208 M-P
- :ed_unassigned,
- # 209 M-Q
- :ed_unassigned,
- # 210 M-R
- :ed_unassigned,
- # 211 M-S
- :ed_unassigned,
- # 212 M-T
- :ed_unassigned,
- # 213 M-U
- :ed_unassigned,
- # 214 M-V
- :ed_unassigned,
- # 215 M-W
- :ed_unassigned,
- # 216 M-X
- :ed_unassigned,
- # 217 M-Y
- :ed_unassigned,
- # 218 M-Z
- :ed_unassigned,
- # 219 M-[
- :ed_sequence_lead_in,
- # 220 M-\
- :ed_unassigned,
- # 221 M-]
- :ed_unassigned,
- # 222 M-^
- :ed_unassigned,
- # 223 M-_
- :ed_unassigned,
- # 224 M-`
- :ed_unassigned,
- # 225 M-a
- :ed_unassigned,
- # 226 M-b
- :ed_unassigned,
- # 227 M-c
- :ed_unassigned,
- # 228 M-d
- :ed_unassigned,
- # 229 M-e
- :ed_unassigned,
- # 230 M-f
- :ed_unassigned,
- # 231 M-g
- :ed_unassigned,
- # 232 M-h
- :ed_unassigned,
- # 233 M-i
- :ed_unassigned,
- # 234 M-j
- :ed_unassigned,
- # 235 M-k
- :ed_unassigned,
- # 236 M-l
- :ed_unassigned,
- # 237 M-m
- :ed_unassigned,
- # 238 M-n
- :ed_unassigned,
- # 239 M-o
- :ed_unassigned,
- # 240 M-p
- :ed_unassigned,
- # 241 M-q
- :ed_unassigned,
- # 242 M-r
- :ed_unassigned,
- # 243 M-s
- :ed_unassigned,
- # 244 M-t
- :ed_unassigned,
- # 245 M-u
- :ed_unassigned,
- # 246 M-v
- :ed_unassigned,
- # 247 M-w
- :ed_unassigned,
- # 248 M-x
- :ed_unassigned,
- # 249 M-y
- :ed_unassigned,
- # 250 M-z
- :ed_unassigned,
- # 251 M-{
- :ed_unassigned,
- # 252 M-|
- :ed_unassigned,
- # 253 M-}
- :ed_unassigned,
- # 254 M-~
- :ed_unassigned,
- # 255 M-^?
- :ed_unassigned
- # EOF
- ]
-end
-
diff --git a/lib/reline/key_actor/vi_insert.rb b/lib/reline/key_actor/vi_insert.rb
deleted file mode 100644
index b8e89f81d8..0000000000
--- a/lib/reline/key_actor/vi_insert.rb
+++ /dev/null
@@ -1,517 +0,0 @@
-class Reline::KeyActor::ViInsert < Reline::KeyActor::Base
- MAPPING = [
- # 0 ^@
- :ed_unassigned,
- # 1 ^A
- :ed_insert,
- # 2 ^B
- :ed_insert,
- # 3 ^C
- :ed_insert,
- # 4 ^D
- :vi_list_or_eof,
- # 5 ^E
- :ed_insert,
- # 6 ^F
- :ed_insert,
- # 7 ^G
- :ed_insert,
- # 8 ^H
- :vi_delete_prev_char,
- # 9 ^I
- :ed_insert,
- # 10 ^J
- :ed_newline,
- # 11 ^K
- :ed_insert,
- # 12 ^L
- :ed_insert,
- # 13 ^M
- :ed_newline,
- # 14 ^N
- :ed_insert,
- # 15 ^O
- :ed_insert,
- # 16 ^P
- :ed_insert,
- # 17 ^Q
- :ed_ignore,
- # 18 ^R
- :vi_search_prev,
- # 19 ^S
- :vi_search_next,
- # 20 ^T
- :ed_insert,
- # 21 ^U
- :vi_kill_line_prev,
- # 22 ^V
- :ed_quoted_insert,
- # 23 ^W
- :ed_delete_prev_word,
- # 24 ^X
- :ed_insert,
- # 25 ^Y
- :ed_insert,
- # 26 ^Z
- :ed_insert,
- # 27 ^[
- :vi_command_mode,
- # 28 ^\
- :ed_ignore,
- # 29 ^]
- :ed_insert,
- # 30 ^^
- :ed_insert,
- # 31 ^_
- :ed_insert,
- # 32 SPACE
- :ed_insert,
- # 33 !
- :ed_insert,
- # 34 "
- :ed_insert,
- # 35 #
- :ed_insert,
- # 36 $
- :ed_insert,
- # 37 %
- :ed_insert,
- # 38 &
- :ed_insert,
- # 39 '
- :ed_insert,
- # 40 (
- :ed_insert,
- # 41 )
- :ed_insert,
- # 42 *
- :ed_insert,
- # 43 +
- :ed_insert,
- # 44 ,
- :ed_insert,
- # 45 -
- :ed_insert,
- # 46 .
- :ed_insert,
- # 47 /
- :ed_insert,
- # 48 0
- :ed_insert,
- # 49 1
- :ed_insert,
- # 50 2
- :ed_insert,
- # 51 3
- :ed_insert,
- # 52 4
- :ed_insert,
- # 53 5
- :ed_insert,
- # 54 6
- :ed_insert,
- # 55 7
- :ed_insert,
- # 56 8
- :ed_insert,
- # 57 9
- :ed_insert,
- # 58 :
- :ed_insert,
- # 59 ;
- :ed_insert,
- # 60 <
- :ed_insert,
- # 61 =
- :ed_insert,
- # 62 >
- :ed_insert,
- # 63 ?
- :ed_insert,
- # 64 @
- :ed_insert,
- # 65 A
- :ed_insert,
- # 66 B
- :ed_insert,
- # 67 C
- :ed_insert,
- # 68 D
- :ed_insert,
- # 69 E
- :ed_insert,
- # 70 F
- :ed_insert,
- # 71 G
- :ed_insert,
- # 72 H
- :ed_insert,
- # 73 I
- :ed_insert,
- # 74 J
- :ed_insert,
- # 75 K
- :ed_insert,
- # 76 L
- :ed_insert,
- # 77 M
- :ed_insert,
- # 78 N
- :ed_insert,
- # 79 O
- :ed_insert,
- # 80 P
- :ed_insert,
- # 81 Q
- :ed_insert,
- # 82 R
- :ed_insert,
- # 83 S
- :ed_insert,
- # 84 T
- :ed_insert,
- # 85 U
- :ed_insert,
- # 86 V
- :ed_insert,
- # 87 W
- :ed_insert,
- # 88 X
- :ed_insert,
- # 89 Y
- :ed_insert,
- # 90 Z
- :ed_insert,
- # 91 [
- :ed_insert,
- # 92 \
- :ed_insert,
- # 93 ]
- :ed_insert,
- # 94 ^
- :ed_insert,
- # 95 _
- :ed_insert,
- # 96 `
- :ed_insert,
- # 97 a
- :ed_insert,
- # 98 b
- :ed_insert,
- # 99 c
- :ed_insert,
- # 100 d
- :ed_insert,
- # 101 e
- :ed_insert,
- # 102 f
- :ed_insert,
- # 103 g
- :ed_insert,
- # 104 h
- :ed_insert,
- # 105 i
- :ed_insert,
- # 106 j
- :ed_insert,
- # 107 k
- :ed_insert,
- # 108 l
- :ed_insert,
- # 109 m
- :ed_insert,
- # 110 n
- :ed_insert,
- # 111 o
- :ed_insert,
- # 112 p
- :ed_insert,
- # 113 q
- :ed_insert,
- # 114 r
- :ed_insert,
- # 115 s
- :ed_insert,
- # 116 t
- :ed_insert,
- # 117 u
- :ed_insert,
- # 118 v
- :ed_insert,
- # 119 w
- :ed_insert,
- # 120 x
- :ed_insert,
- # 121 y
- :ed_insert,
- # 122 z
- :ed_insert,
- # 123 {
- :ed_insert,
- # 124 |
- :ed_insert,
- # 125 }
- :ed_insert,
- # 126 ~
- :ed_insert,
- # 127 ^?
- :vi_delete_prev_char,
- # 128 M-^@
- :ed_unassigned,
- # 129 M-^A
- :ed_unassigned,
- # 130 M-^B
- :ed_unassigned,
- # 131 M-^C
- :ed_unassigned,
- # 132 M-^D
- :ed_unassigned,
- # 133 M-^E
- :ed_unassigned,
- # 134 M-^F
- :ed_unassigned,
- # 135 M-^G
- :ed_unassigned,
- # 136 M-^H
- :ed_unassigned,
- # 137 M-^I
- :ed_unassigned,
- # 138 M-^J
- :key_newline,
- # 139 M-^K
- :ed_unassigned,
- # 140 M-^L
- :ed_unassigned,
- # 141 M-^M
- :key_newline,
- # 142 M-^N
- :ed_unassigned,
- # 143 M-^O
- :ed_unassigned,
- # 144 M-^P
- :ed_unassigned,
- # 145 M-^Q
- :ed_unassigned,
- # 146 M-^R
- :ed_unassigned,
- # 147 M-^S
- :ed_unassigned,
- # 148 M-^T
- :ed_unassigned,
- # 149 M-^U
- :ed_unassigned,
- # 150 M-^V
- :ed_unassigned,
- # 151 M-^W
- :ed_unassigned,
- # 152 M-^X
- :ed_unassigned,
- # 153 M-^Y
- :ed_unassigned,
- # 154 M-^Z
- :ed_unassigned,
- # 155 M-^[
- :ed_unassigned,
- # 156 M-^\
- :ed_unassigned,
- # 157 M-^]
- :ed_unassigned,
- # 158 M-^^
- :ed_unassigned,
- # 159 M-^_
- :ed_unassigned,
- # 160 M-SPACE
- :ed_unassigned,
- # 161 M-!
- :ed_unassigned,
- # 162 M-"
- :ed_unassigned,
- # 163 M-#
- :ed_unassigned,
- # 164 M-$
- :ed_unassigned,
- # 165 M-%
- :ed_unassigned,
- # 166 M-&
- :ed_unassigned,
- # 167 M-'
- :ed_unassigned,
- # 168 M-(
- :ed_unassigned,
- # 169 M-)
- :ed_unassigned,
- # 170 M-*
- :ed_unassigned,
- # 171 M-+
- :ed_unassigned,
- # 172 M-,
- :ed_unassigned,
- # 173 M--
- :ed_unassigned,
- # 174 M-.
- :ed_unassigned,
- # 175 M-/
- :ed_unassigned,
- # 176 M-0
- :ed_unassigned,
- # 177 M-1
- :ed_unassigned,
- # 178 M-2
- :ed_unassigned,
- # 179 M-3
- :ed_unassigned,
- # 180 M-4
- :ed_unassigned,
- # 181 M-5
- :ed_unassigned,
- # 182 M-6
- :ed_unassigned,
- # 183 M-7
- :ed_unassigned,
- # 184 M-8
- :ed_unassigned,
- # 185 M-9
- :ed_unassigned,
- # 186 M-:
- :ed_unassigned,
- # 187 M-;
- :ed_unassigned,
- # 188 M-<
- :ed_unassigned,
- # 189 M-=
- :ed_unassigned,
- # 190 M->
- :ed_unassigned,
- # 191 M-?
- :ed_unassigned,
- # 192 M-@
- :ed_unassigned,
- # 193 M-A
- :ed_unassigned,
- # 194 M-B
- :ed_unassigned,
- # 195 M-C
- :ed_unassigned,
- # 196 M-D
- :ed_unassigned,
- # 197 M-E
- :ed_unassigned,
- # 198 M-F
- :ed_unassigned,
- # 199 M-G
- :ed_unassigned,
- # 200 M-H
- :ed_unassigned,
- # 201 M-I
- :ed_unassigned,
- # 202 M-J
- :ed_unassigned,
- # 203 M-K
- :ed_unassigned,
- # 204 M-L
- :ed_unassigned,
- # 205 M-M
- :ed_unassigned,
- # 206 M-N
- :ed_unassigned,
- # 207 M-O
- :ed_unassigned,
- # 208 M-P
- :ed_unassigned,
- # 209 M-Q
- :ed_unassigned,
- # 210 M-R
- :ed_unassigned,
- # 211 M-S
- :ed_unassigned,
- # 212 M-T
- :ed_unassigned,
- # 213 M-U
- :ed_unassigned,
- # 214 M-V
- :ed_unassigned,
- # 215 M-W
- :ed_unassigned,
- # 216 M-X
- :ed_unassigned,
- # 217 M-Y
- :ed_unassigned,
- # 218 M-Z
- :ed_unassigned,
- # 219 M-[
- :ed_unassigned,
- # 220 M-\
- :ed_unassigned,
- # 221 M-]
- :ed_unassigned,
- # 222 M-^
- :ed_unassigned,
- # 223 M-_
- :ed_unassigned,
- # 224 M-`
- :ed_unassigned,
- # 225 M-a
- :ed_unassigned,
- # 226 M-b
- :ed_unassigned,
- # 227 M-c
- :ed_unassigned,
- # 228 M-d
- :ed_unassigned,
- # 229 M-e
- :ed_unassigned,
- # 230 M-f
- :ed_unassigned,
- # 231 M-g
- :ed_unassigned,
- # 232 M-h
- :ed_unassigned,
- # 233 M-i
- :ed_unassigned,
- # 234 M-j
- :ed_unassigned,
- # 235 M-k
- :ed_unassigned,
- # 236 M-l
- :ed_unassigned,
- # 237 M-m
- :ed_unassigned,
- # 238 M-n
- :ed_unassigned,
- # 239 M-o
- :ed_unassigned,
- # 240 M-p
- :ed_unassigned,
- # 241 M-q
- :ed_unassigned,
- # 242 M-r
- :ed_unassigned,
- # 243 M-s
- :ed_unassigned,
- # 244 M-t
- :ed_unassigned,
- # 245 M-u
- :ed_unassigned,
- # 246 M-v
- :ed_unassigned,
- # 247 M-w
- :ed_unassigned,
- # 248 M-x
- :ed_unassigned,
- # 249 M-y
- :ed_unassigned,
- # 250 M-z
- :ed_unassigned,
- # 251 M-{
- :ed_unassigned,
- # 252 M-|
- :ed_unassigned,
- # 253 M-}
- :ed_unassigned,
- # 254 M-~
- :ed_unassigned,
- # 255 M-^?
- :ed_unassigned
- # EOF
- ]
-end
diff --git a/lib/reline/key_stroke.rb b/lib/reline/key_stroke.rb
deleted file mode 100644
index 017e3db00a..0000000000
--- a/lib/reline/key_stroke.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-class Reline::KeyStroke
- using Module.new {
- refine Array do
- def start_with?(other)
- other.size <= size && other == self.take(other.size)
- end
-
- def bytes
- self
- end
- end
- }
-
- def initialize(config)
- @config = config
- end
-
- def match_status(input)
- key_mapping.keys.select { |lhs|
- lhs.start_with? input
- }.tap { |it|
- return :matched if it.size == 1 && (it.max_by(&:size)&.size&.== input.size)
- return :matching if it.size == 1 && (it.max_by(&:size)&.size&.!= input.size)
- return :matched if it.max_by(&:size)&.size&.< input.size
- return :matching if it.size > 1
- }
- key_mapping.keys.select { |lhs|
- input.start_with? lhs
- }.tap { |it|
- return it.size > 0 ? :matched : :unmatched
- }
- end
-
- def expand(input)
- lhs = key_mapping.keys.select { |item| input.start_with? item }.sort_by(&:size).reverse.first
- return input unless lhs
- rhs = key_mapping[lhs]
-
- case rhs
- when String
- rhs_bytes = rhs.bytes
- expand(expand(rhs_bytes) + expand(input.drop(lhs.size)))
- when Symbol
- [rhs] + expand(input.drop(lhs.size))
- when Array
- rhs
- end
- end
-
- private
-
- def key_mapping
- @config.key_bindings
- end
-end
diff --git a/lib/reline/kill_ring.rb b/lib/reline/kill_ring.rb
deleted file mode 100644
index 842fd04697..0000000000
--- a/lib/reline/kill_ring.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-class Reline::KillRing
- module State
- FRESH = :fresh
- CONTINUED = :continued
- PROCESSED = :processed
- YANK = :yank
- end
-
- RingPoint = Struct.new(:backward, :forward, :str) do
- def initialize(str)
- super(nil, nil, str)
- end
-
- def ==(other)
- object_id == other.object_id
- end
- end
-
- class RingBuffer
- attr_reader :size
- attr_reader :head
-
- def initialize(max = 1024)
- @max = max
- @size = 0
- @head = nil # reading head of ring-shaped tape
- end
-
- def <<(point)
- if @size.zero?
- @head = point
- @head.backward = @head
- @head.forward = @head
- @size = 1
- elsif @size >= @max
- tail = @head.forward
- new_tail = tail.forward
- @head.forward = point
- point.backward = @head
- new_tail.backward = point
- point.forward = new_tail
- @head = point
- else
- tail = @head.forward
- @head.forward = point
- point.backward = @head
- tail.backward = point
- point.forward = tail
- @head = point
- @size += 1
- end
- end
-
- def empty?
- @size.zero?
- end
- end
-
- def initialize(max = 1024)
- @ring = RingBuffer.new(max)
- @ring_pointer = nil
- @buffer = nil
- @state = State::FRESH
- end
-
- def append(string, before_p = false)
- case @state
- when State::FRESH, State::YANK
- @ring << RingPoint.new(string)
- @state = State::CONTINUED
- when State::CONTINUED, State::PROCESSED
- if before_p
- @ring.head.str.prepend(string)
- else
- @ring.head.str.concat(string)
- end
- @state = State::CONTINUED
- end
- end
-
- def process
- case @state
- when State::FRESH
- # nothing to do
- when State::CONTINUED
- @state = State::PROCESSED
- when State::PROCESSED
- @state = State::FRESH
- when State::YANK
- # nothing to do
- end
- end
-
- def yank
- unless @ring.empty?
- @state = State::YANK
- @ring_pointer = @ring.head
- @ring_pointer.str
- else
- nil
- end
- end
-
- def yank_pop
- if @state == State::YANK
- prev_yank = @ring_pointer.str
- @ring_pointer = @ring_pointer.backward
- [@ring_pointer.str, prev_yank]
- else
- nil
- end
- end
-end
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
deleted file mode 100644
index 9bdccae9c9..0000000000
--- a/lib/reline/line_editor.rb
+++ /dev/null
@@ -1,2304 +0,0 @@
-require 'reline/kill_ring'
-require 'reline/unicode'
-
-require 'tempfile'
-
-class Reline::LineEditor
- # TODO: undo
- attr_reader :line
- attr_reader :byte_pointer
- attr_accessor :confirm_multiline_termination_proc
- attr_accessor :completion_proc
- attr_accessor :completion_append_character
- attr_accessor :output_modifier_proc
- attr_accessor :prompt_proc
- attr_accessor :auto_indent_proc
- attr_accessor :pre_input_hook
- attr_accessor :dig_perfect_match_proc
- attr_writer :output
-
- VI_MOTIONS = %i{
- ed_prev_char
- ed_next_char
- vi_zero
- ed_move_to_beg
- ed_move_to_end
- vi_to_column
- vi_next_char
- vi_prev_char
- vi_next_word
- vi_prev_word
- vi_to_next_char
- vi_to_prev_char
- vi_end_word
- vi_next_big_word
- vi_prev_big_word
- vi_end_big_word
- vi_repeat_next_char
- vi_repeat_prev_char
- }
-
- module CompletionState
- NORMAL = :normal
- COMPLETION = :completion
- MENU = :menu
- JOURNEY = :journey
- MENU_WITH_PERFECT_MATCH = :menu_with_perfect_match
- PERFECT_MATCH = :perfect_match
- end
-
- CompletionJourneyData = Struct.new('CompletionJourneyData', :preposing, :postposing, :list, :pointer)
- MenuInfo = Struct.new('MenuInfo', :target, :list)
-
- def initialize(config, encoding)
- @config = config
- @completion_append_character = ''
- reset_variables(encoding: encoding)
- end
-
- private def check_multiline_prompt(buffer, prompt)
- if @vi_arg
- prompt = "(arg: #{@vi_arg}) "
- @rerender_all = true
- elsif @searching_prompt
- prompt = @searching_prompt
- @rerender_all = true
- else
- prompt = @prompt
- end
- if @prompt_proc
- prompt_list = @prompt_proc.(buffer)
- prompt_list.map!{ prompt } if @vi_arg or @searching_prompt
- if @config.show_mode_in_prompt
- if @config.editing_mode_is?(:vi_command)
- mode_icon = @config.vi_cmd_mode_icon
- elsif @config.editing_mode_is?(:vi_insert)
- mode_icon = @config.vi_ins_mode_icon
- elsif @config.editing_mode_is?(:emacs)
- mode_icon = @config.emacs_mode_string
- else
- mode_icon = '?'
- end
- prompt_list.map!{ |pr| mode_icon + pr }
- end
- prompt = prompt_list[@line_index]
- prompt_width = calculate_width(prompt, true)
- [prompt, prompt_width, prompt_list]
- else
- prompt_width = calculate_width(prompt, true)
- if @config.show_mode_in_prompt
- if @config.editing_mode_is?(:vi_command)
- mode_icon = @config.vi_cmd_mode_icon
- elsif @config.editing_mode_is?(:vi_insert)
- mode_icon = @config.vi_ins_mode_icon
- elsif @config.editing_mode_is?(:emacs)
- mode_icon = @config.emacs_mode_string
- else
- mode_icon = '?'
- end
- prompt = mode_icon + prompt
- end
- [prompt, prompt_width, nil]
- end
- end
-
- def reset(prompt = '', encoding:)
- @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
- @screen_size = Reline::IOGate.get_screen_size
- reset_variables(prompt, encoding: encoding)
- @old_trap = Signal.trap('SIGINT') {
- @old_trap.call if @old_trap.respond_to?(:call) # can also be string, ex: "DEFAULT"
- raise Interrupt
- }
- Reline::IOGate.set_winch_handler do
- @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
- old_screen_size = @screen_size
- @screen_size = Reline::IOGate.get_screen_size
- if old_screen_size.last < @screen_size.last # columns increase
- @rerender_all = true
- rerender
- else
- back = 0
- new_buffer = whole_lines
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_buffer, prompt)
- new_buffer.each_with_index do |line, index|
- prompt_width = calculate_width(prompt_list[index], true) if @prompt_proc
- width = prompt_width + calculate_width(line)
- height = calculate_height_by_width(width)
- back += height
- end
- @highest_in_all = back
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @first_line_started_from =
- if @line_index.zero?
- 0
- else
- calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt)
- end
- if @prompt_proc
- prompt = prompt_list[@line_index]
- prompt_width = calculate_width(prompt, true)
- end
- calculate_nearest_cursor
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @rerender_all = true
- end
- end
- end
-
- def finalize
- Signal.trap('SIGINT', @old_trap)
- end
-
- def eof?
- @eof
- end
-
- def reset_variables(prompt = '', encoding:)
- @prompt = prompt
- @mark_pointer = nil
- @encoding = encoding
- @is_multiline = false
- @finished = false
- @cleared = false
- @rerender_all = false
- @history_pointer = nil
- @kill_ring = Reline::KillRing.new
- @vi_clipboard = ''
- @vi_arg = nil
- @waiting_proc = nil
- @waiting_operator_proc = nil
- @completion_journey_data = nil
- @completion_state = CompletionState::NORMAL
- @perfect_matched = nil
- @menu_info = nil
- @first_prompt = true
- @searching_prompt = nil
- @first_char = true
- @eof = false
- reset_line
- end
-
- def reset_line
- @cursor = 0
- @cursor_max = 0
- @byte_pointer = 0
- @buffer_of_lines = [String.new(encoding: @encoding)]
- @line_index = 0
- @previous_line_index = nil
- @line = @buffer_of_lines[0]
- @first_line_started_from = 0
- @move_up = 0
- @started_from = 0
- @highest_in_this = 1
- @highest_in_all = 1
- @line_backup_in_history = nil
- @multibyte_buffer = String.new(encoding: 'ASCII-8BIT')
- @check_new_auto_indent = false
- end
-
- def multiline_on
- @is_multiline = true
- end
-
- def multiline_off
- @is_multiline = false
- end
-
- private def calculate_height_by_lines(lines, prompt)
- result = 0
- prompt_list = prompt.is_a?(Array) ? prompt : nil
- lines.each_with_index { |line, i|
- prompt = prompt_list[i] if prompt_list and prompt_list[i]
- result += calculate_height_by_width(calculate_width(prompt, true) + calculate_width(line))
- }
- result
- end
-
- private def insert_new_line(cursor_line, next_line)
- @line = cursor_line
- @buffer_of_lines.insert(@line_index + 1, String.new(next_line, encoding: @encoding))
- @previous_line_index = @line_index
- @line_index += 1
- end
-
- private def calculate_height_by_width(width)
- width.div(@screen_size.last) + 1
- end
-
- private def split_by_width(str, max_width)
- Reline::Unicode.split_by_width(str, max_width, @encoding)
- end
-
- private def scroll_down(val)
- if val <= @rest_height
- Reline::IOGate.move_cursor_down(val)
- @rest_height -= val
- else
- Reline::IOGate.move_cursor_down(@rest_height)
- Reline::IOGate.scroll_down(val - @rest_height)
- @rest_height = 0
- end
- end
-
- private def move_cursor_up(val)
- if val > 0
- Reline::IOGate.move_cursor_up(val)
- @rest_height += val
- elsif val < 0
- move_cursor_down(-val)
- end
- end
-
- private def move_cursor_down(val)
- if val > 0
- Reline::IOGate.move_cursor_down(val)
- @rest_height -= val
- @rest_height = 0 if @rest_height < 0
- elsif val < 0
- move_cursor_up(-val)
- end
- end
-
- private def calculate_nearest_cursor
- @cursor_max = calculate_width(line)
- new_cursor = 0
- new_byte_pointer = 0
- height = 1
- max_width = @screen_size.last
- if @config.editing_mode_is?(:vi_command)
- last_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @line.bytesize)
- if last_byte_size > 0
- last_mbchar = @line.byteslice(@line.bytesize - last_byte_size, last_byte_size)
- last_width = Reline::Unicode.get_mbchar_width(last_mbchar)
- cursor_max = @cursor_max - last_width
- else
- cursor_max = @cursor_max
- end
- else
- cursor_max = @cursor_max
- end
- @line.encode(Encoding::UTF_8).grapheme_clusters.each do |gc|
- mbchar_width = Reline::Unicode.get_mbchar_width(gc)
- now = new_cursor + mbchar_width
- if now > cursor_max or now > @cursor
- break
- end
- new_cursor += mbchar_width
- if new_cursor > max_width * height
- height += 1
- end
- new_byte_pointer += gc.bytesize
- end
- @started_from = height - 1
- @cursor = new_cursor
- @byte_pointer = new_byte_pointer
- end
-
- def rerender
- return if @line.nil?
- if @menu_info
- scroll_down(@highest_in_all - @first_line_started_from)
- @rerender_all = true
- @menu_info.list.sort!.each do |item|
- Reline::IOGate.move_cursor_column(0)
- @output.write item
- @output.flush
- scroll_down(1)
- end
- scroll_down(@highest_in_all - 1)
- move_cursor_up(@highest_in_all - 1 - @first_line_started_from)
- @menu_info = nil
- end
- prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines, prompt)
- if @cleared
- Reline::IOGate.clear_screen
- @cleared = false
- back = 0
- modify_lines(whole_lines).each_with_index do |line, index|
- if @prompt_proc
- pr = prompt_list[index]
- height = render_partial(pr, calculate_width(pr), line, false)
- else
- height = render_partial(prompt, prompt_width, line, false)
- end
- if index < (@buffer_of_lines.size - 1)
- move_cursor_down(height)
- back += height
- end
- end
- move_cursor_up(back)
- move_cursor_down(@first_line_started_from + @started_from)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- return
- end
- new_highest_in_this = calculate_height_by_width(prompt_width + calculate_width(@line.nil? ? '' : @line))
- # FIXME: end of logical line sometimes breaks
- if @previous_line_index or new_highest_in_this != @highest_in_this
- if @previous_line_index
- new_lines = whole_lines(index: @previous_line_index, line: @line)
- else
- new_lines = whole_lines
- end
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines, prompt)
- all_height = calculate_height_by_lines(new_lines, prompt_list || prompt)
- diff = all_height - @highest_in_all
- move_cursor_down(@highest_in_all - @first_line_started_from - @started_from - 1)
- if diff > 0
- scroll_down(diff)
- move_cursor_up(all_height - 1)
- elsif diff < 0
- (-diff).times do
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- move_cursor_up(1)
- end
- move_cursor_up(all_height - 1)
- else
- move_cursor_up(all_height - 1)
- end
- @highest_in_all = all_height
- back = 0
- modify_lines(new_lines).each_with_index do |line, index|
- if @prompt_proc
- prompt = prompt_list[index]
- prompt_width = calculate_width(prompt, true)
- end
- height = render_partial(prompt, prompt_width, line, false)
- if index < (new_lines.size - 1)
- scroll_down(1)
- back += height
- else
- back += height - 1
- end
- end
- move_cursor_up(back)
- if @previous_line_index
- @buffer_of_lines[@previous_line_index] = @line
- @line = @buffer_of_lines[@line_index]
- end
- @first_line_started_from =
- if @line_index.zero?
- 0
- else
- calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt)
- end
- if @prompt_proc
- prompt = prompt_list[@line_index]
- prompt_width = calculate_width(prompt, true)
- end
- move_cursor_down(@first_line_started_from)
- calculate_nearest_cursor
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- move_cursor_down(@started_from)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @previous_line_index = nil
- rendered = true
- elsif @rerender_all
- move_cursor_up(@first_line_started_from + @started_from)
- Reline::IOGate.move_cursor_column(0)
- back = 0
- new_buffer = whole_lines
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_buffer, prompt)
- new_buffer.each_with_index do |line, index|
- prompt_width = calculate_width(prompt_list[index], true) if @prompt_proc
- width = prompt_width + calculate_width(line)
- height = calculate_height_by_width(width)
- back += height
- end
- if back > @highest_in_all
- scroll_down(back - 1)
- move_cursor_up(back - 1)
- elsif back < @highest_in_all
- scroll_down(back)
- Reline::IOGate.erase_after_cursor
- (@highest_in_all - back - 1).times do
- scroll_down(1)
- Reline::IOGate.erase_after_cursor
- end
- move_cursor_up(@highest_in_all - 1)
- end
- modify_lines(new_buffer).each_with_index do |line, index|
- if @prompt_proc
- prompt = prompt_list[index]
- prompt_width = calculate_width(prompt, true)
- end
- render_partial(prompt, prompt_width, line, false)
- if index < (new_buffer.size - 1)
- move_cursor_down(1)
- end
- end
- move_cursor_up(back - 1)
- if @prompt_proc
- prompt = prompt_list[@line_index]
- prompt_width = calculate_width(prompt, true)
- end
- @highest_in_all = back
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @first_line_started_from =
- if @line_index.zero?
- 0
- else
- calculate_height_by_lines(new_buffer[0..(@line_index - 1)], prompt_list || prompt)
- end
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- move_cursor_down(@first_line_started_from + @started_from)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- @rerender_all = false
- rendered = true
- end
- line = modify_lines(whole_lines)[@line_index]
- if @is_multiline
- prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines, prompt)
- if finished?
- # Always rerender on finish because output_modifier_proc may return a different output.
- render_partial(prompt, prompt_width, line)
- scroll_down(1)
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- elsif not rendered
- render_partial(prompt, prompt_width, line)
- end
- else
- render_partial(prompt, prompt_width, line)
- if finished?
- scroll_down(1)
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- end
- end
- end
-
- private def render_partial(prompt, prompt_width, line_to_render, with_control = true)
- visual_lines, height = split_by_width(line_to_render.nil? ? prompt : prompt + line_to_render, @screen_size.last)
- if with_control
- if height > @highest_in_this
- diff = height - @highest_in_this
- scroll_down(diff)
- @highest_in_all += diff
- @highest_in_this = height
- move_cursor_up(diff)
- elsif height < @highest_in_this
- diff = @highest_in_this - height
- @highest_in_all -= diff
- @highest_in_this = height
- end
- move_cursor_up(@started_from)
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- end
- Reline::IOGate.move_cursor_column(0)
- visual_lines.each_with_index do |line, index|
- if line.nil?
- if calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last
- # reaches the end of line
- if Reline::IOGate.win?
- # A newline is automatically inserted if a character is rendered at
- # eol on command prompt.
- else
- # When the cursor is at the end of the line and erases characters
- # after the cursor, some terminals delete the character at the
- # cursor position.
- move_cursor_down(1)
- Reline::IOGate.move_cursor_column(0)
- end
- else
- Reline::IOGate.erase_after_cursor
- move_cursor_down(1)
- Reline::IOGate.move_cursor_column(0)
- end
- next
- end
- @output.write line
- if Reline::IOGate.win? and calculate_width(line, true) == Reline::IOGate.get_screen_size.last
- # A newline is automatically inserted if a character is rendered at eol on command prompt.
- @rest_height -= 1 if @rest_height > 0
- end
- @output.flush
- if @first_prompt
- @first_prompt = false
- @pre_input_hook&.call
- end
- end
- Reline::IOGate.erase_after_cursor
- if with_control
- # Just after rendring, so the cursor is on the last line.
- if finished?
- Reline::IOGate.move_cursor_column(0)
- else
- # Moves up from bottom of lines to the cursor position.
- move_cursor_up(height - 1 - @started_from)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- end
- end
- height
- end
-
- private def modify_lines(before)
- return before if before.nil? || before.empty?
-
- if after = @output_modifier_proc&.call("#{before.join("\n")}\n", complete: finished?)
- after.lines("\n").map { |l| l.chomp('') }
- else
- before
- end
- end
-
- def editing_mode
- @config.editing_mode
- end
-
- private def menu(target, list)
- @menu_info = MenuInfo.new(target, list)
- end
-
- private def complete_internal_proc(list, is_menu)
- preposing, target, postposing = retrieve_completion_block
- list = list.select { |i|
- if i and not Encoding.compatible?(target.encoding, i.encoding)
- raise Encoding::CompatibilityError, "#{target.encoding.name} is not compatible with #{i.encoding.name}"
- end
- if @config.completion_ignore_case
- i&.downcase&.start_with?(target.downcase)
- else
- i&.start_with?(target)
- end
- }
- if is_menu
- menu(target, list)
- return nil
- end
- completed = list.inject { |memo, item|
- begin
- memo_mbchars = memo.unicode_normalize.grapheme_clusters
- item_mbchars = item.unicode_normalize.grapheme_clusters
- rescue Encoding::CompatibilityError
- memo_mbchars = memo.grapheme_clusters
- item_mbchars = item.grapheme_clusters
- end
- size = [memo_mbchars.size, item_mbchars.size].min
- result = ''
- size.times do |i|
- if @config.completion_ignore_case
- if memo_mbchars[i].casecmp?(item_mbchars[i])
- result << memo_mbchars[i]
- else
- break
- end
- else
- if memo_mbchars[i] == item_mbchars[i]
- result << memo_mbchars[i]
- else
- break
- end
- end
- end
- result
- }
- [target, preposing, completed, postposing]
- end
-
- private def complete(list, just_show_list = false)
- case @completion_state
- when CompletionState::NORMAL, CompletionState::JOURNEY
- @completion_state = CompletionState::COMPLETION
- when CompletionState::PERFECT_MATCH
- @dig_perfect_match_proc&.(@perfect_matched)
- end
- if just_show_list
- is_menu = true
- elsif @completion_state == CompletionState::MENU
- is_menu = true
- elsif @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
- is_menu = true
- else
- is_menu = false
- end
- result = complete_internal_proc(list, is_menu)
- if @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
- @completion_state = CompletionState::PERFECT_MATCH
- end
- return if result.nil?
- target, preposing, completed, postposing = result
- return if completed.nil?
- if target <= completed and (@completion_state == CompletionState::COMPLETION)
- if list.include?(completed)
- if list.one?
- @completion_state = CompletionState::PERFECT_MATCH
- else
- @completion_state = CompletionState::MENU_WITH_PERFECT_MATCH
- end
- @perfect_matched = completed
- else
- @completion_state = CompletionState::MENU
- end
- if not just_show_list and target < completed
- @line = preposing + completed + completion_append_character.to_s + postposing
- line_to_pointer = preposing + completed + completion_append_character.to_s
- @cursor_max = calculate_width(@line)
- @cursor = calculate_width(line_to_pointer)
- @byte_pointer = line_to_pointer.bytesize
- end
- end
- end
-
- private def move_completed_list(list, direction)
- case @completion_state
- when CompletionState::NORMAL, CompletionState::COMPLETION,
- CompletionState::MENU, CompletionState::MENU_WITH_PERFECT_MATCH
- @completion_state = CompletionState::JOURNEY
- result = retrieve_completion_block
- return if result.nil?
- preposing, target, postposing = result
- @completion_journey_data = CompletionJourneyData.new(
- preposing, postposing,
- [target] + list.select{ |item| item.start_with?(target) }, 0)
- @completion_state = CompletionState::JOURNEY
- else
- case direction
- when :up
- @completion_journey_data.pointer -= 1
- if @completion_journey_data.pointer < 0
- @completion_journey_data.pointer = @completion_journey_data.list.size - 1
- end
- when :down
- @completion_journey_data.pointer += 1
- if @completion_journey_data.pointer >= @completion_journey_data.list.size
- @completion_journey_data.pointer = 0
- end
- end
- completed = @completion_journey_data.list[@completion_journey_data.pointer]
- @line = @completion_journey_data.preposing + completed + @completion_journey_data.postposing
- line_to_pointer = @completion_journey_data.preposing + completed
- @cursor_max = calculate_width(@line)
- @cursor = calculate_width(line_to_pointer)
- @byte_pointer = line_to_pointer.bytesize
- end
- end
-
- private def run_for_operators(key, method_symbol, &block)
- if @waiting_operator_proc
- if VI_MOTIONS.include?(method_symbol)
- old_cursor, old_byte_pointer = @cursor, @byte_pointer
- block.()
- unless @waiting_proc
- cursor_diff, byte_pointer_diff = @cursor - old_cursor, @byte_pointer - old_byte_pointer
- @cursor, @byte_pointer = old_cursor, old_byte_pointer
- @waiting_operator_proc.(cursor_diff, byte_pointer_diff)
- else
- old_waiting_proc = @waiting_proc
- old_waiting_operator_proc = @waiting_operator_proc
- @waiting_proc = proc { |k|
- old_cursor, old_byte_pointer = @cursor, @byte_pointer
- old_waiting_proc.(k)
- cursor_diff, byte_pointer_diff = @cursor - old_cursor, @byte_pointer - old_byte_pointer
- @cursor, @byte_pointer = old_cursor, old_byte_pointer
- @waiting_operator_proc.(cursor_diff, byte_pointer_diff)
- @waiting_operator_proc = old_waiting_operator_proc
- }
- end
- else
- # Ignores operator when not motion is given.
- block.()
- end
- @waiting_operator_proc = nil
- else
- block.()
- end
- end
-
- private def argumentable?(method_obj)
- method_obj and method_obj.parameters.length != 1
- end
-
- private def process_key(key, method_symbol)
- if method_symbol and respond_to?(method_symbol, true)
- method_obj = method(method_symbol)
- else
- method_obj = nil
- end
- if method_symbol and key.is_a?(Symbol)
- if @vi_arg and argumentable?(method_obj)
- run_for_operators(key, method_symbol) do
- method_obj.(key, arg: @vi_arg)
- end
- else
- method_obj&.(key)
- end
- @kill_ring.process
- @vi_arg = nil
- elsif @vi_arg
- if key.chr =~ /[0-9]/
- ed_argument_digit(key)
- else
- if argumentable?(method_obj)
- run_for_operators(key, method_symbol) do
- method_obj.(key, arg: @vi_arg)
- end
- elsif @waiting_proc
- @waiting_proc.(key)
- elsif method_obj
- method_obj.(key)
- else
- ed_insert(key)
- end
- @kill_ring.process
- @vi_arg = nil
- end
- elsif @waiting_proc
- @waiting_proc.(key)
- @kill_ring.process
- elsif method_obj
- if method_symbol == :ed_argument_digit
- method_obj.(key)
- else
- run_for_operators(key, method_symbol) do
- method_obj.(key)
- end
- end
- @kill_ring.process
- else
- ed_insert(key)
- end
- end
-
- private def normal_char(key)
- method_symbol = method_obj = nil
- if key.combined_char.is_a?(Symbol)
- process_key(key.combined_char, key.combined_char)
- return
- end
- @multibyte_buffer << key.combined_char
- if @multibyte_buffer.size > 1
- if @multibyte_buffer.dup.force_encoding(@encoding).valid_encoding?
- process_key(@multibyte_buffer.dup.force_encoding(@encoding), nil)
- @multibyte_buffer.clear
- else
- # invalid
- return
- end
- else # single byte
- return if key.char >= 128 # maybe, first byte of multi byte
- method_symbol = @config.editing_mode.get_method(key.combined_char)
- if key.with_meta and method_symbol == :ed_unassigned
- # split ESC + key
- method_symbol = @config.editing_mode.get_method("\e".ord)
- process_key("\e".ord, method_symbol)
- method_symbol = @config.editing_mode.get_method(key.char)
- process_key(key.char, method_symbol)
- else
- process_key(key.combined_char, method_symbol)
- end
- @multibyte_buffer.clear
- end
- if @config.editing_mode_is?(:vi_command) and @cursor > 0 and @cursor == @cursor_max
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- end
- end
-
- def input_key(key)
- if key.char.nil?
- if @first_char
- @line = nil
- end
- finish
- return
- end
- @first_char = false
- completion_occurs = false
- if @config.editing_mode_is?(:emacs, :vi_insert) and key.char == "\C-i".ord
- unless @config.disable_completion
- result = call_completion_proc
- if result.is_a?(Array)
- completion_occurs = true
- complete(result)
- end
- end
- elsif not @config.disable_completion and @config.editing_mode_is?(:vi_insert) and ["\C-p".ord, "\C-n".ord].include?(key.char)
- unless @config.disable_completion
- result = call_completion_proc
- if result.is_a?(Array)
- completion_occurs = true
- move_completed_list(result, "\C-p".ord == key.char ? :up : :down)
- end
- end
- elsif Symbol === key.char and respond_to?(key.char, true)
- process_key(key.char, key.char)
- else
- normal_char(key)
- end
- unless completion_occurs
- @completion_state = CompletionState::NORMAL
- end
- if @is_multiline and @auto_indent_proc
- process_auto_indent
- end
- end
-
- def call_completion_proc
- result = retrieve_completion_block(true)
- slice = result[1]
- result = @completion_proc.(slice) if @completion_proc and slice
- Reline.core.instance_variable_set(:@completion_quote_character, nil)
- result
- end
-
- private def process_auto_indent
- return if not @check_new_auto_indent and @previous_line_index # move cursor up or down
- if @check_new_auto_indent and @previous_line_index and @previous_line_index > 0 and @line_index > @previous_line_index
- # Fix indent of a line when a newline is inserted to the next
- new_lines = whole_lines(index: @previous_line_index, line: @line)
- new_indent = @auto_indent_proc.(new_lines[0..-3].push(''), @line_index - 1, 0, true)
- md = @line.match(/\A */)
- prev_indent = md[0].count(' ')
- @line = ' ' * new_indent + @line.lstrip
-
- new_indent = nil
- result = @auto_indent_proc.(new_lines[0..-2], @line_index - 1, (new_lines[-2].size + 1), false)
- if result
- new_indent = result
- end
- if new_indent&.>= 0
- @line = ' ' * new_indent + @line.lstrip
- end
- end
- if @previous_line_index
- new_lines = whole_lines(index: @previous_line_index, line: @line)
- else
- new_lines = whole_lines
- end
- new_indent = @auto_indent_proc.(new_lines, @line_index, @byte_pointer, @check_new_auto_indent)
- if new_indent&.>= 0
- md = new_lines[@line_index].match(/\A */)
- prev_indent = md[0].count(' ')
- if @check_new_auto_indent
- @buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].lstrip
- @cursor = new_indent
- @byte_pointer = new_indent
- else
- @line = ' ' * new_indent + @line.lstrip
- @cursor += new_indent - prev_indent
- @byte_pointer += new_indent - prev_indent
- end
- end
- @check_new_auto_indent = false
- end
-
- def retrieve_completion_block(set_completion_quote_character = false)
- word_break_regexp = /\A[#{Regexp.escape(Reline.completer_word_break_characters)}]/
- quote_characters_regexp = /\A[#{Regexp.escape(Reline.completer_quote_characters)}]/
- before = @line.byteslice(0, @byte_pointer)
- rest = nil
- break_pointer = nil
- quote = nil
- closing_quote = nil
- escaped_quote = nil
- i = 0
- while i < @byte_pointer do
- slice = @line.byteslice(i, @byte_pointer - i)
- unless slice.valid_encoding?
- i += 1
- next
- end
- if quote and slice.start_with?(closing_quote)
- quote = nil
- i += 1
- rest = nil
- elsif quote and slice.start_with?(escaped_quote)
- # skip
- i += 2
- elsif slice =~ quote_characters_regexp # find new "
- rest = $'
- quote = $&
- closing_quote = /(?!\\)#{Regexp.escape(quote)}/
- escaped_quote = /\\#{Regexp.escape(quote)}/
- i += 1
- break_pointer = i - 1
- elsif not quote and slice =~ word_break_regexp
- rest = $'
- i += 1
- before = @line.byteslice(i, @byte_pointer - i)
- break_pointer = i
- else
- i += 1
- end
- end
- postposing = @line.byteslice(@byte_pointer, @line.bytesize - @byte_pointer)
- if rest
- preposing = @line.byteslice(0, break_pointer)
- target = rest
- if set_completion_quote_character and quote
- Reline.core.instance_variable_set(:@completion_quote_character, quote)
- if postposing !~ /(?!\\)#{Regexp.escape(quote)}/ # closing quote
- insert_text(quote)
- end
- end
- else
- preposing = ''
- if break_pointer
- preposing = @line.byteslice(0, break_pointer)
- else
- preposing = ''
- end
- target = before
- end
- [preposing.encode(@encoding), target.encode(@encoding), postposing.encode(@encoding)]
- end
-
- def confirm_multiline_termination
- temp_buffer = @buffer_of_lines.dup
- if @previous_line_index and @line_index == (@buffer_of_lines.size - 1)
- temp_buffer[@previous_line_index] = @line
- else
- temp_buffer[@line_index] = @line
- end
- @confirm_multiline_termination_proc.(temp_buffer.join("\n") + "\n")
- end
-
- def insert_text(text)
- width = calculate_width(text)
- if @cursor == @cursor_max
- @line += text
- else
- @line = byteinsert(@line, @byte_pointer, text)
- end
- @byte_pointer += text.bytesize
- @cursor += width
- @cursor_max += width
- end
-
- def delete_text(start = nil, length = nil)
- if start.nil? and length.nil?
- @line&.clear
- @byte_pointer = 0
- @cursor = 0
- @cursor_max = 0
- elsif not start.nil? and not length.nil?
- if @line
- before = @line.byteslice(0, start)
- after = @line.byteslice(start + length, @line.bytesize)
- @line = before + after
- @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- end
- elsif start.is_a?(Range)
- range = start
- first = range.first
- last = range.last
- last = @line.bytesize - 1 if last > @line.bytesize
- last += @line.bytesize if last < 0
- first += @line.bytesize if first < 0
- range = range.exclude_end? ? first...last : first..last
- @line = @line.bytes.reject.with_index{ |c, i| range.include?(i) }.map{ |c| c.chr(Encoding::ASCII_8BIT) }.join.force_encoding(@encoding)
- @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- else
- @line = @line.byteslice(0, start)
- @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- end
- end
-
- def byte_pointer=(val)
- @byte_pointer = val
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- end
-
- def whole_lines(index: @line_index, line: @line)
- temp_lines = @buffer_of_lines.dup
- temp_lines[index] = line
- temp_lines
- end
-
- def whole_buffer
- if @buffer_of_lines.size == 1 and @line.nil?
- nil
- else
- whole_lines.join("\n")
- end
- end
-
- def finished?
- @finished
- end
-
- def finish
- @finished = true
- @config.reset
- end
-
- private def byteslice!(str, byte_pointer, size)
- new_str = str.byteslice(0, byte_pointer)
- new_str << str.byteslice(byte_pointer + size, str.bytesize)
- [new_str, str.byteslice(byte_pointer, size)]
- end
-
- private def byteinsert(str, byte_pointer, other)
- new_str = str.byteslice(0, byte_pointer)
- new_str << other
- new_str << str.byteslice(byte_pointer, str.bytesize)
- new_str
- end
-
- private def calculate_width(str, allow_escape_code = false)
- Reline::Unicode.calculate_width(str, allow_escape_code)
- end
-
- private def key_delete(key)
- if @config.editing_mode_is?(:vi_insert, :emacs)
- ed_delete_next_char(key)
- end
- end
-
- private def key_newline(key)
- if @is_multiline
- next_line = @line.byteslice(@byte_pointer, @line.bytesize - @byte_pointer)
- cursor_line = @line.byteslice(0, @byte_pointer)
- insert_new_line(cursor_line, next_line)
- @cursor = 0
- @check_new_auto_indent = true
- end
- end
-
- private def ed_unassigned(key) end # do nothing
-
- private def ed_insert(key)
- if key.instance_of?(String)
- begin
- key.encode(Encoding::UTF_8)
- rescue Encoding::UndefinedConversionError
- return
- end
- width = Reline::Unicode.get_mbchar_width(key)
- if @cursor == @cursor_max
- @line += key
- else
- @line = byteinsert(@line, @byte_pointer, key)
- end
- @byte_pointer += key.bytesize
- @cursor += width
- @cursor_max += width
- else
- begin
- key.chr.encode(Encoding::UTF_8)
- rescue Encoding::UndefinedConversionError
- return
- end
- if @cursor == @cursor_max
- @line += key.chr
- else
- @line = byteinsert(@line, @byte_pointer, key.chr)
- end
- width = Reline::Unicode.get_mbchar_width(key.chr)
- @byte_pointer += 1
- @cursor += width
- @cursor_max += width
- end
- end
- alias_method :ed_digit, :ed_insert
- alias_method :self_insert, :ed_insert
-
- private def ed_quoted_insert(str, arg: 1)
- @waiting_proc = proc { |key|
- arg.times do
- if key == "\C-j".ord or key == "\C-m".ord
- key_newline(key)
- else
- ed_insert(key)
- end
- end
- @waiting_proc = nil
- }
- end
- alias_method :quoted_insert, :ed_quoted_insert
-
- private def ed_next_char(key, arg: 1)
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- if (@byte_pointer < @line.bytesize)
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor += width if width
- @byte_pointer += byte_size
- elsif @is_multiline and @config.editing_mode_is?(:emacs) and @byte_pointer == @line.bytesize and @line_index < @buffer_of_lines.size - 1
- next_line = @buffer_of_lines[@line_index + 1]
- @cursor = 0
- @byte_pointer = 0
- @cursor_max = calculate_width(next_line)
- @previous_line_index = @line_index
- @line_index += 1
- end
- arg -= 1
- ed_next_char(key, arg: arg) if arg > 0
- end
- alias_method :forward_char, :ed_next_char
-
- private def ed_prev_char(key, arg: 1)
- if @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- elsif @is_multiline and @config.editing_mode_is?(:emacs) and @byte_pointer == 0 and @line_index > 0
- prev_line = @buffer_of_lines[@line_index - 1]
- @cursor = calculate_width(prev_line)
- @byte_pointer = prev_line.bytesize
- @cursor_max = calculate_width(prev_line)
- @previous_line_index = @line_index
- @line_index -= 1
- end
- arg -= 1
- ed_prev_char(key, arg: arg) if arg > 0
- end
-
- private def vi_first_print(key)
- @byte_pointer, @cursor = Reline::Unicode.vi_first_print(@line)
- end
-
- private def ed_move_to_beg(key)
- @byte_pointer = @cursor = 0
- end
- alias_method :beginning_of_line, :ed_move_to_beg
-
- private def ed_move_to_end(key)
- @byte_pointer = 0
- @cursor = 0
- byte_size = 0
- while @byte_pointer < @line.bytesize
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- if byte_size > 0
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- @cursor += Reline::Unicode.get_mbchar_width(mbchar)
- end
- @byte_pointer += byte_size
- end
- end
- alias_method :end_of_line, :ed_move_to_end
-
- private def generate_searcher
- Fiber.new do |first_key|
- prev_search_key = first_key
- search_word = String.new(encoding: @encoding)
- multibyte_buf = String.new(encoding: 'ASCII-8BIT')
- last_hit = nil
- case first_key
- when "\C-r".ord
- prompt_name = 'reverse-i-search'
- when "\C-s".ord
- prompt_name = 'i-search'
- end
- loop do
- key = Fiber.yield(search_word)
- search_again = false
- case key
- when -1 # determined
- Reline.last_incremental_search = search_word
- break
- when "\C-h".ord, "\C-?".ord
- grapheme_clusters = search_word.grapheme_clusters
- if grapheme_clusters.size > 0
- grapheme_clusters.pop
- search_word = grapheme_clusters.join
- end
- when "\C-r".ord, "\C-s".ord
- search_again = true if prev_search_key == key
- prev_search_key = key
- else
- multibyte_buf << key
- if multibyte_buf.dup.force_encoding(@encoding).valid_encoding?
- search_word << multibyte_buf.dup.force_encoding(@encoding)
- multibyte_buf.clear
- end
- end
- hit = nil
- if not search_word.empty? and @line_backup_in_history&.include?(search_word)
- @history_pointer = nil
- hit = @line_backup_in_history
- else
- if search_again
- if search_word.empty? and Reline.last_incremental_search
- search_word = Reline.last_incremental_search
- end
- if @history_pointer
- case prev_search_key
- when "\C-r".ord
- history_pointer_base = 0
- history = Reline::HISTORY[0..(@history_pointer - 1)]
- when "\C-s".ord
- history_pointer_base = @history_pointer + 1
- history = Reline::HISTORY[(@history_pointer + 1)..-1]
- end
- else
- history_pointer_base = 0
- history = Reline::HISTORY
- end
- elsif @history_pointer
- case prev_search_key
- when "\C-r".ord
- history_pointer_base = 0
- history = Reline::HISTORY[0..@history_pointer]
- when "\C-s".ord
- history_pointer_base = @history_pointer
- history = Reline::HISTORY[@history_pointer..-1]
- end
- else
- history_pointer_base = 0
- history = Reline::HISTORY
- end
- case prev_search_key
- when "\C-r".ord
- hit_index = history.rindex { |item|
- item.include?(search_word)
- }
- when "\C-s".ord
- hit_index = history.index { |item|
- item.include?(search_word)
- }
- end
- if hit_index
- @history_pointer = history_pointer_base + hit_index
- hit = Reline::HISTORY[@history_pointer]
- end
- end
- case prev_search_key
- when "\C-r".ord
- prompt_name = 'reverse-i-search'
- when "\C-s".ord
- prompt_name = 'i-search'
- end
- if hit
- if @is_multiline
- @buffer_of_lines = hit.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- @searching_prompt = "(%s)`%s'" % [prompt_name, search_word]
- else
- @line = hit
- @searching_prompt = "(%s)`%s': %s" % [prompt_name, search_word, hit]
- end
- last_hit = hit
- else
- if @is_multiline
- @rerender_all = true
- @searching_prompt = "(failed %s)`%s'" % [prompt_name, search_word]
- else
- @searching_prompt = "(failed %s)`%s': %s" % [prompt_name, search_word, last_hit]
- end
- end
- end
- end
- end
-
- private def incremental_search_history(key)
- unless @history_pointer
- if @is_multiline
- @line_backup_in_history = whole_buffer
- else
- @line_backup_in_history = @line
- end
- end
- searcher = generate_searcher
- searcher.resume(key)
- @searching_prompt = "(reverse-i-search)`': "
- @waiting_proc = ->(k) {
- case k
- when "\C-j".ord
- if @history_pointer
- buffer = Reline::HISTORY[@history_pointer]
- else
- buffer = @line_backup_in_history
- end
- if @is_multiline
- @buffer_of_lines = buffer.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line = buffer
- end
- @searching_prompt = nil
- @waiting_proc = nil
- @cursor_max = calculate_width(@line)
- @cursor = @byte_pointer = 0
- searcher.resume(-1)
- when "\C-g".ord
- if @is_multiline
- @buffer_of_lines = @line_backup_in_history.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line = @line_backup_in_history
- end
- @history_pointer = nil
- @searching_prompt = nil
- @waiting_proc = nil
- @line_backup_in_history = nil
- @cursor_max = calculate_width(@line)
- @cursor = @byte_pointer = 0
- @rerender_all = true
- else
- chr = k.is_a?(String) ? k : k.chr(Encoding::ASCII_8BIT)
- if chr.match?(/[[:print:]]/) or k == "\C-h".ord or k == "\C-?".ord or k == "\C-r".ord or k == "\C-s".ord
- searcher.resume(k)
- else
- if @history_pointer
- line = Reline::HISTORY[@history_pointer]
- else
- line = @line_backup_in_history
- end
- if @is_multiline
- @line_backup_in_history = whole_buffer
- @buffer_of_lines = line.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line_backup_in_history = @line
- @line = line
- end
- @searching_prompt = nil
- @waiting_proc = nil
- @cursor_max = calculate_width(@line)
- @cursor = @byte_pointer = 0
- searcher.resume(-1)
- end
- end
- }
- end
-
- private def vi_search_prev(key)
- incremental_search_history(key)
- end
- alias_method :reverse_search_history, :vi_search_prev
-
- private def vi_search_next(key)
- incremental_search_history(key)
- end
- alias_method :forward_search_history, :vi_search_next
-
- private def ed_search_prev_history(key, arg: 1)
- history = nil
- h_pointer = nil
- line_no = nil
- substr = @line.slice(0, @byte_pointer)
- if @history_pointer.nil?
- return if not @line.empty? and substr.empty?
- history = Reline::HISTORY
- elsif @history_pointer.zero?
- history = nil
- h_pointer = nil
- else
- history = Reline::HISTORY.slice(0, @history_pointer)
- end
- return if history.nil?
- if @is_multiline
- h_pointer = history.rindex { |h|
- h.split("\n").each_with_index { |l, i|
- if l.start_with?(substr)
- line_no = i
- break
- end
- }
- not line_no.nil?
- }
- else
- h_pointer = history.rindex { |l|
- l.start_with?(substr)
- }
- end
- return if h_pointer.nil?
- @history_pointer = h_pointer
- if @is_multiline
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = line_no
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line = Reline::HISTORY[@history_pointer]
- end
- @cursor_max = calculate_width(@line)
- arg -= 1
- ed_search_prev_history(key, arg: arg) if arg > 0
- end
- alias_method :history_search_backward, :ed_search_prev_history
-
- private def ed_search_next_history(key, arg: 1)
- substr = @line.slice(0, @byte_pointer)
- if @history_pointer.nil?
- return
- elsif @history_pointer == (Reline::HISTORY.size - 1) and not substr.empty?
- return
- end
- history = Reline::HISTORY.slice((@history_pointer + 1)..-1)
- h_pointer = nil
- line_no = nil
- if @is_multiline
- h_pointer = history.index { |h|
- h.split("\n").each_with_index { |l, i|
- if l.start_with?(substr)
- line_no = i
- break
- end
- }
- not line_no.nil?
- }
- else
- h_pointer = history.index { |l|
- l.start_with?(substr)
- }
- end
- h_pointer += @history_pointer + 1 if h_pointer and @history_pointer
- return if h_pointer.nil? and not substr.empty?
- @history_pointer = h_pointer
- if @is_multiline
- if @history_pointer.nil? and substr.empty?
- @buffer_of_lines = []
- @line_index = 0
- else
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @line_index = line_no
- end
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- if @history_pointer.nil? and substr.empty?
- @line = ''
- else
- @line = Reline::HISTORY[@history_pointer]
- end
- end
- @cursor_max = calculate_width(@line)
- arg -= 1
- ed_search_next_history(key, arg: arg) if arg > 0
- end
- alias_method :history_search_forward, :ed_search_next_history
-
- private def ed_prev_history(key, arg: 1)
- if @is_multiline and @line_index > 0
- @previous_line_index = @line_index
- @line_index -= 1
- return
- end
- if Reline::HISTORY.empty?
- return
- end
- if @history_pointer.nil?
- @history_pointer = Reline::HISTORY.size - 1
- if @is_multiline
- @line_backup_in_history = whole_buffer
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line_backup_in_history = @line
- @line = Reline::HISTORY[@history_pointer]
- end
- elsif @history_pointer.zero?
- return
- else
- if @is_multiline
- Reline::HISTORY[@history_pointer] = whole_buffer
- @history_pointer -= 1
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer -= 1
- @line = Reline::HISTORY[@history_pointer]
- end
- end
- if @config.editing_mode_is?(:emacs, :vi_insert)
- @cursor_max = @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- elsif @config.editing_mode_is?(:vi_command)
- @byte_pointer = @cursor = 0
- @cursor_max = calculate_width(@line)
- end
- arg -= 1
- ed_prev_history(key, arg: arg) if arg > 0
- end
-
- private def ed_next_history(key, arg: 1)
- if @is_multiline and @line_index < (@buffer_of_lines.size - 1)
- @previous_line_index = @line_index
- @line_index += 1
- return
- end
- if @history_pointer.nil?
- return
- elsif @history_pointer == (Reline::HISTORY.size - 1)
- if @is_multiline
- @history_pointer = nil
- @buffer_of_lines = @line_backup_in_history.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = 0
- @line = @buffer_of_lines.first
- @rerender_all = true
- else
- @history_pointer = nil
- @line = @line_backup_in_history
- end
- else
- if @is_multiline
- Reline::HISTORY[@history_pointer] = whole_buffer
- @history_pointer += 1
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = 0
- @line = @buffer_of_lines.first
- @rerender_all = true
- else
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer += 1
- @line = Reline::HISTORY[@history_pointer]
- end
- end
- @line = '' unless @line
- if @config.editing_mode_is?(:emacs, :vi_insert)
- @cursor_max = @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- elsif @config.editing_mode_is?(:vi_command)
- @byte_pointer = @cursor = 0
- @cursor_max = calculate_width(@line)
- end
- arg -= 1
- ed_next_history(key, arg: arg) if arg > 0
- end
-
- private def ed_newline(key)
- if @is_multiline
- if @config.editing_mode_is?(:vi_command)
- if @line_index < (@buffer_of_lines.size - 1)
- ed_next_history(key) # means cursor down
- else
- # should check confirm_multiline_termination to finish?
- finish
- end
- else
- if @line_index == (@buffer_of_lines.size - 1)
- if confirm_multiline_termination
- finish
- else
- key_newline(key)
- end
- else
- # should check confirm_multiline_termination to finish?
- @previous_line_index = @line_index
- @line_index = @buffer_of_lines.size - 1
- finish
- end
- end
- else
- if @history_pointer
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer = nil
- end
- finish
- end
- end
-
- private def em_delete_prev_char(key)
- if @is_multiline and @cursor == 0 and @line_index > 0
- @buffer_of_lines[@line_index] = @line
- @cursor = calculate_width(@buffer_of_lines[@line_index - 1])
- @byte_pointer = @buffer_of_lines[@line_index - 1].bytesize
- @buffer_of_lines[@line_index - 1] += @buffer_of_lines.delete_at(@line_index)
- @line_index -= 1
- @line = @buffer_of_lines[@line_index]
- @cursor_max = calculate_width(@line)
- @rerender_all = true
- elsif @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- @cursor_max -= width
- end
- end
- alias_method :backward_delete_char, :em_delete_prev_char
-
- private def ed_kill_line(key)
- if @line.bytesize > @byte_pointer
- @line, deleted = byteslice!(@line, @byte_pointer, @line.bytesize - @byte_pointer)
- @byte_pointer = @line.bytesize
- @cursor = @cursor_max = calculate_width(@line)
- @kill_ring.append(deleted)
- elsif @is_multiline and @byte_pointer == @line.bytesize and @buffer_of_lines.size > @line_index + 1
- @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- @line += @buffer_of_lines.delete_at(@line_index + 1)
- @cursor_max = calculate_width(@line)
- @buffer_of_lines[@line_index] = @line
- @rerender_all = true
- @rest_height += 1
- end
- end
-
- private def em_kill_line(key)
- if @byte_pointer > 0
- @line, deleted = byteslice!(@line, 0, @byte_pointer)
- @byte_pointer = 0
- @kill_ring.append(deleted, true)
- @cursor_max = calculate_width(@line)
- @cursor = 0
- end
- end
-
- private def em_delete(key)
- if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
- @line = nil
- if @buffer_of_lines.size > 1
- scroll_down(@highest_in_all - @first_line_started_from)
- end
- Reline::IOGate.move_cursor_column(0)
- @eof = true
- finish
- elsif @byte_pointer < @line.bytesize
- splitted_last = @line.byteslice(@byte_pointer, @line.bytesize)
- mbchar = splitted_last.grapheme_clusters.first
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor_max -= width
- @line, = byteslice!(@line, @byte_pointer, mbchar.bytesize)
- elsif @is_multiline and @byte_pointer == @line.bytesize and @buffer_of_lines.size > @line_index + 1
- @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- @line += @buffer_of_lines.delete_at(@line_index + 1)
- @cursor_max = calculate_width(@line)
- @buffer_of_lines[@line_index] = @line
- @rerender_all = true
- @rest_height += 1
- end
- end
- alias_method :delete_char, :em_delete
-
- private def em_delete_or_list(key)
- if @line.empty? or @byte_pointer < @line.bytesize
- em_delete(key)
- else # show completed list
- result = call_completion_proc
- if result.is_a?(Array)
- complete(result, true)
- end
- end
- end
- alias_method :delete_char_or_list, :em_delete_or_list
-
- private def em_yank(key)
- yanked = @kill_ring.yank
- if yanked
- @line = byteinsert(@line, @byte_pointer, yanked)
- yanked_width = calculate_width(yanked)
- @cursor += yanked_width
- @cursor_max += yanked_width
- @byte_pointer += yanked.bytesize
- end
- end
-
- private def em_yank_pop(key)
- yanked, prev_yank = @kill_ring.yank_pop
- if yanked
- prev_yank_width = calculate_width(prev_yank)
- @cursor -= prev_yank_width
- @cursor_max -= prev_yank_width
- @byte_pointer -= prev_yank.bytesize
- @line, = byteslice!(@line, @byte_pointer, prev_yank.bytesize)
- @line = byteinsert(@line, @byte_pointer, yanked)
- yanked_width = calculate_width(yanked)
- @cursor += yanked_width
- @cursor_max += yanked_width
- @byte_pointer += yanked.bytesize
- end
- end
-
- private def ed_clear_screen(key)
- @cleared = true
- end
- alias_method :clear_screen, :ed_clear_screen
-
- private def em_next_word(key)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- end
- alias_method :forward_word, :em_next_word
-
- private def ed_prev_word(key)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.em_backward_word(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @cursor -= width
- end
- end
- alias_method :backward_word, :ed_prev_word
-
- private def em_delete_next_word(key)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- @line, word = byteslice!(@line, @byte_pointer, byte_size)
- @kill_ring.append(word)
- @cursor_max -= width
- end
- end
-
- private def ed_delete_prev_word(key)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.em_backward_word(@line, @byte_pointer)
- @line, word = byteslice!(@line, @byte_pointer - byte_size, byte_size)
- @kill_ring.append(word, true)
- @byte_pointer -= byte_size
- @cursor -= width
- @cursor_max -= width
- end
- end
-
- private def ed_transpose_chars(key)
- if @byte_pointer > 0
- if @cursor_max > @cursor
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor += width
- @byte_pointer += byte_size
- end
- back1_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- if (@byte_pointer - back1_byte_size) > 0
- back2_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer - back1_byte_size)
- back2_pointer = @byte_pointer - back1_byte_size - back2_byte_size
- @line, back2_mbchar = byteslice!(@line, back2_pointer, back2_byte_size)
- @line = byteinsert(@line, @byte_pointer - back2_byte_size, back2_mbchar)
- end
- end
- end
- alias_method :transpose_chars, :ed_transpose_chars
-
- private def ed_transpose_words(key)
- left_word_start, middle_start, right_word_start, after_start = Reline::Unicode.ed_transpose_words(@line, @byte_pointer)
- before = @line.byteslice(0, left_word_start)
- left_word = @line.byteslice(left_word_start, middle_start - left_word_start)
- middle = @line.byteslice(middle_start, right_word_start - middle_start)
- right_word = @line.byteslice(right_word_start, after_start - right_word_start)
- after = @line.byteslice(after_start, @line.bytesize - after_start)
- return if left_word.empty? or right_word.empty?
- @line = before + right_word + middle + left_word + after
- from_head_to_left_word = before + right_word + middle + left_word
- @byte_pointer = from_head_to_left_word.bytesize
- @cursor = calculate_width(from_head_to_left_word)
- end
- alias_method :transpose_words, :ed_transpose_words
-
- private def em_capitol_case(key)
- if @line.bytesize > @byte_pointer
- byte_size, _, new_str = Reline::Unicode.em_forward_word_with_capitalization(@line, @byte_pointer)
- before = @line.byteslice(0, @byte_pointer)
- after = @line.byteslice((@byte_pointer + byte_size)..-1)
- @line = before + new_str + after
- @byte_pointer += new_str.bytesize
- @cursor += calculate_width(new_str)
- end
- end
- alias_method :capitalize_word, :em_capitol_case
-
- private def em_lower_case(key)
- if @line.bytesize > @byte_pointer
- byte_size, = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- part = @line.byteslice(@byte_pointer, byte_size).grapheme_clusters.map { |mbchar|
- mbchar =~ /[A-Z]/ ? mbchar.downcase : mbchar
- }.join
- rest = @line.byteslice((@byte_pointer + byte_size)..-1)
- @line = @line.byteslice(0, @byte_pointer) + part
- @byte_pointer = @line.bytesize
- @cursor = calculate_width(@line)
- @cursor_max = @cursor + calculate_width(rest)
- @line += rest
- end
- end
- alias_method :downcase_word, :em_lower_case
-
- private def em_upper_case(key)
- if @line.bytesize > @byte_pointer
- byte_size, = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- part = @line.byteslice(@byte_pointer, byte_size).grapheme_clusters.map { |mbchar|
- mbchar =~ /[a-z]/ ? mbchar.upcase : mbchar
- }.join
- rest = @line.byteslice((@byte_pointer + byte_size)..-1)
- @line = @line.byteslice(0, @byte_pointer) + part
- @byte_pointer = @line.bytesize
- @cursor = calculate_width(@line)
- @cursor_max = @cursor + calculate_width(rest)
- @line += rest
- end
- end
- alias_method :upcase_word, :em_upper_case
-
- private def em_kill_region(key)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.em_big_backward_word(@line, @byte_pointer)
- @line, deleted = byteslice!(@line, @byte_pointer - byte_size, byte_size)
- @byte_pointer -= byte_size
- @cursor -= width
- @cursor_max -= width
- @kill_ring.append(deleted)
- end
- end
-
- private def copy_for_vi(text)
- if @config.editing_mode_is?(:vi_insert) or @config.editing_mode_is?(:vi_command)
- @vi_clipboard = text
- end
- end
-
- private def vi_insert(key)
- @config.editing_mode = :vi_insert
- end
-
- private def vi_add(key)
- @config.editing_mode = :vi_insert
- ed_next_char(key)
- end
-
- private def vi_command_mode(key)
- ed_prev_char(key)
- @config.editing_mode = :vi_command
- end
- alias_method :backward_char, :ed_prev_char
-
- private def vi_next_word(key, arg: 1)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_forward_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- vi_next_word(key, arg: arg) if arg > 0
- end
-
- private def vi_prev_word(key, arg: 1)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.vi_backward_word(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @cursor -= width
- end
- arg -= 1
- vi_prev_word(key, arg: arg) if arg > 0
- end
-
- private def vi_end_word(key, arg: 1)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_forward_end_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- vi_end_word(key, arg: arg) if arg > 0
- end
-
- private def vi_next_big_word(key, arg: 1)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_big_forward_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- vi_next_big_word(key, arg: arg) if arg > 0
- end
-
- private def vi_prev_big_word(key, arg: 1)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.vi_big_backward_word(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @cursor -= width
- end
- arg -= 1
- vi_prev_big_word(key, arg: arg) if arg > 0
- end
-
- private def vi_end_big_word(key, arg: 1)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_big_forward_end_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- vi_end_big_word(key, arg: arg) if arg > 0
- end
-
- private def vi_delete_prev_char(key)
- if @is_multiline and @cursor == 0 and @line_index > 0
- @buffer_of_lines[@line_index] = @line
- @cursor = calculate_width(@buffer_of_lines[@line_index - 1])
- @byte_pointer = @buffer_of_lines[@line_index - 1].bytesize
- @buffer_of_lines[@line_index - 1] += @buffer_of_lines.delete_at(@line_index)
- @line_index -= 1
- @line = @buffer_of_lines[@line_index]
- @cursor_max = calculate_width(@line)
- @rerender_all = true
- elsif @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- @cursor_max -= width
- end
- end
-
- private def vi_insert_at_bol(key)
- ed_move_to_beg(key)
- @config.editing_mode = :vi_insert
- end
-
- private def vi_add_at_eol(key)
- ed_move_to_end(key)
- @config.editing_mode = :vi_insert
- end
-
- private def ed_delete_prev_char(key, arg: 1)
- deleted = ''
- arg.times do
- if @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- deleted.prepend(mbchar)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- @cursor_max -= width
- end
- end
- copy_for_vi(deleted)
- end
-
- private def vi_zero(key)
- @byte_pointer = 0
- @cursor = 0
- end
-
- private def vi_change_meta(key)
- @waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
- if byte_pointer_diff > 0
- @line, cut = byteslice!(@line, @byte_pointer, byte_pointer_diff)
- elsif byte_pointer_diff < 0
- @line, cut = byteslice!(@line, @byte_pointer + byte_pointer_diff, -byte_pointer_diff)
- end
- copy_for_vi(cut)
- @cursor += cursor_diff if cursor_diff < 0
- @cursor_max -= cursor_diff.abs
- @byte_pointer += byte_pointer_diff if byte_pointer_diff < 0
- @config.editing_mode = :vi_insert
- }
- end
-
- private def vi_delete_meta(key)
- @waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
- if byte_pointer_diff > 0
- @line, cut = byteslice!(@line, @byte_pointer, byte_pointer_diff)
- elsif byte_pointer_diff < 0
- @line, cut = byteslice!(@line, @byte_pointer + byte_pointer_diff, -byte_pointer_diff)
- end
- copy_for_vi(cut)
- @cursor += cursor_diff if cursor_diff < 0
- @cursor_max -= cursor_diff.abs
- @byte_pointer += byte_pointer_diff if byte_pointer_diff < 0
- }
- end
-
- private def vi_yank(key)
- end
-
- private def vi_list_or_eof(key)
- if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
- @line = nil
- if @buffer_of_lines.size > 1
- scroll_down(@highest_in_all - @first_line_started_from)
- end
- Reline::IOGate.move_cursor_column(0)
- @eof = true
- finish
- else
- ed_newline(key)
- end
- end
- alias_method :vi_end_of_transmission, :vi_list_or_eof
- alias_method :vi_eof_maybe, :vi_list_or_eof
-
- private def ed_delete_next_char(key, arg: 1)
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- unless @line.empty? || byte_size == 0
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- copy_for_vi(mbchar)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor_max -= width
- if @cursor > 0 and @cursor >= @cursor_max
- @byte_pointer -= byte_size
- @cursor -= width
- end
- end
- arg -= 1
- ed_delete_next_char(key, arg: arg) if arg > 0
- end
-
- private def vi_to_history_line(key)
- if Reline::HISTORY.empty?
- return
- end
- if @history_pointer.nil?
- @history_pointer = 0
- @line_backup_in_history = @line
- @line = Reline::HISTORY[@history_pointer]
- @cursor_max = calculate_width(@line)
- @cursor = 0
- @byte_pointer = 0
- elsif @history_pointer.zero?
- return
- else
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer = 0
- @line = Reline::HISTORY[@history_pointer]
- @cursor_max = calculate_width(@line)
- @cursor = 0
- @byte_pointer = 0
- end
- end
-
- private def vi_histedit(key)
- path = Tempfile.open { |fp|
- fp.write @line
- fp.path
- }
- system("#{ENV['EDITOR']} #{path}")
- @line = File.read(path)
- finish
- end
-
- private def vi_paste_prev(key, arg: 1)
- if @vi_clipboard.size > 0
- @line = byteinsert(@line, @byte_pointer, @vi_clipboard)
- @cursor_max += calculate_width(@vi_clipboard)
- cursor_point = @vi_clipboard.grapheme_clusters[0..-2].join
- @cursor += calculate_width(cursor_point)
- @byte_pointer += cursor_point.bytesize
- end
- arg -= 1
- vi_paste_prev(key, arg: arg) if arg > 0
- end
-
- private def vi_paste_next(key, arg: 1)
- if @vi_clipboard.size > 0
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- @line = byteinsert(@line, @byte_pointer + byte_size, @vi_clipboard)
- @cursor_max += calculate_width(@vi_clipboard)
- @cursor += calculate_width(@vi_clipboard)
- @byte_pointer += @vi_clipboard.bytesize
- end
- arg -= 1
- vi_paste_next(key, arg: arg) if arg > 0
- end
-
- private def ed_argument_digit(key)
- if @vi_arg.nil?
- unless key.chr.to_i.zero?
- @vi_arg = key.chr.to_i
- end
- else
- @vi_arg = @vi_arg * 10 + key.chr.to_i
- end
- end
-
- private def vi_to_column(key, arg: 0)
- @byte_pointer, @cursor = @line.grapheme_clusters.inject([0, 0]) { |total, gc|
- # total has [byte_size, cursor]
- mbchar_width = Reline::Unicode.get_mbchar_width(gc)
- if (total.last + mbchar_width) >= arg
- break total
- elsif (total.last + mbchar_width) >= @cursor_max
- break total
- else
- total = [total.first + gc.bytesize, total.last + mbchar_width]
- total
- end
- }
- end
-
- private def vi_replace_char(key, arg: 1)
- @waiting_proc = ->(k) {
- if arg == 1
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- before = @line.byteslice(0, @byte_pointer)
- remaining_point = @byte_pointer + byte_size
- after = @line.byteslice(remaining_point, @line.size - remaining_point)
- @line = before + k.chr + after
- @cursor_max = calculate_width(@line)
- @waiting_proc = nil
- elsif arg > 1
- byte_size = 0
- arg.times do
- byte_size += Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer + byte_size)
- end
- before = @line.byteslice(0, @byte_pointer)
- remaining_point = @byte_pointer + byte_size
- after = @line.byteslice(remaining_point, @line.size - remaining_point)
- replaced = k.chr * arg
- @line = before + replaced + after
- @byte_pointer += replaced.bytesize
- @cursor += calculate_width(replaced)
- @cursor_max = calculate_width(@line)
- @waiting_proc = nil
- end
- }
- end
-
- private def vi_next_char(key, arg: 1)
- @waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg) }
- end
-
- private def vi_to_next_char(key, arg: 1)
- @waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg, true) }
- end
-
- private def search_next_char(key, arg, need_prev_char = false)
- if key.instance_of?(String)
- inputed_char = key
- else
- inputed_char = key.chr
- end
- prev_total = nil
- total = nil
- found = false
- @line.byteslice(@byte_pointer..-1).grapheme_clusters.each do |mbchar|
- # total has [byte_size, cursor]
- unless total
- # skip cursor point
- width = Reline::Unicode.get_mbchar_width(mbchar)
- total = [mbchar.bytesize, width]
- else
- if inputed_char == mbchar
- arg -= 1
- if arg.zero?
- found = true
- break
- end
- end
- width = Reline::Unicode.get_mbchar_width(mbchar)
- prev_total = total
- total = [total.first + mbchar.bytesize, total.last + width]
- end
- end
- if not need_prev_char and found and total
- byte_size, width = total
- @byte_pointer += byte_size
- @cursor += width
- elsif need_prev_char and found and prev_total
- byte_size, width = prev_total
- @byte_pointer += byte_size
- @cursor += width
- end
- @waiting_proc = nil
- end
-
- private def vi_prev_char(key, arg: 1)
- @waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg) }
- end
-
- private def vi_to_prev_char(key, arg: 1)
- @waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg, true) }
- end
-
- private def search_prev_char(key, arg, need_next_char = false)
- if key.instance_of?(String)
- inputed_char = key
- else
- inputed_char = key.chr
- end
- prev_total = nil
- total = nil
- found = false
- @line.byteslice(0..@byte_pointer).grapheme_clusters.reverse_each do |mbchar|
- # total has [byte_size, cursor]
- unless total
- # skip cursor point
- width = Reline::Unicode.get_mbchar_width(mbchar)
- total = [mbchar.bytesize, width]
- else
- if inputed_char == mbchar
- arg -= 1
- if arg.zero?
- found = true
- break
- end
- end
- width = Reline::Unicode.get_mbchar_width(mbchar)
- prev_total = total
- total = [total.first + mbchar.bytesize, total.last + width]
- end
- end
- if not need_next_char and found and total
- byte_size, width = total
- @byte_pointer -= byte_size
- @cursor -= width
- elsif need_next_char and found and prev_total
- byte_size, width = prev_total
- @byte_pointer -= byte_size
- @cursor -= width
- end
- @waiting_proc = nil
- end
-
- private def vi_join_lines(key, arg: 1)
- if @is_multiline and @buffer_of_lines.size > @line_index + 1
- @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- @line += ' ' + @buffer_of_lines.delete_at(@line_index + 1).lstrip
- @cursor_max = calculate_width(@line)
- @buffer_of_lines[@line_index] = @line
- @rerender_all = true
- @rest_height += 1
- end
- arg -= 1
- vi_join_lines(key, arg: arg) if arg > 0
- end
-
- private def em_set_mark(key)
- @mark_pointer = [@byte_pointer, @line_index]
- end
- alias_method :set_mark, :em_set_mark
-
- private def em_exchange_mark(key)
- new_pointer = [@byte_pointer, @line_index]
- @previous_line_index = @line_index
- @byte_pointer, @line_index = @mark_pointer
- @cursor = calculate_width(@line.byteslice(0, @byte_pointer))
- @cursor_max = calculate_width(@line)
- @mark_pointer = new_pointer
- end
- alias_method :exchange_point_and_mark, :em_exchange_mark
-end
diff --git a/lib/reline/reline.gemspec b/lib/reline/reline.gemspec
deleted file mode 100644
index 1962f61def..0000000000
--- a/lib/reline/reline.gemspec
+++ /dev/null
@@ -1,26 +0,0 @@
-
-lib = File.expand_path('../lib', __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'reline/version'
-
-Gem::Specification.new do |spec|
- spec.name = 'reline'
- spec.version = Reline::VERSION
- spec.authors = ['aycabta']
- spec.email = ['aycabta@gmail.com']
-
- spec.summary = %q{Alternative GNU Readline or Editline implementation by pure Ruby.}
- spec.description = %q{Alternative GNU Readline or Editline implementation by pure Ruby.}
- spec.homepage = 'https://github.com/ruby/reline'
- spec.license = 'Ruby'
-
- spec.files = Dir['BSDL', 'COPYING', 'README.md', 'lib/**/*']
- spec.require_paths = ['lib']
-
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
-
- spec.add_dependency 'io-console', '~> 0.5'
- spec.add_development_dependency 'bundler'
- spec.add_development_dependency 'rake'
- spec.add_development_dependency 'test-unit'
-end
diff --git a/lib/reline/unicode.rb b/lib/reline/unicode.rb
deleted file mode 100644
index cd8c27e85b..0000000000
--- a/lib/reline/unicode.rb
+++ /dev/null
@@ -1,595 +0,0 @@
-class Reline::Unicode
- EscapedPairs = {
- 0x00 => '^@',
- 0x01 => '^A', # C-a
- 0x02 => '^B',
- 0x03 => '^C',
- 0x04 => '^D',
- 0x05 => '^E',
- 0x06 => '^F',
- 0x07 => '^G',
- 0x08 => '^H', # Backspace
- 0x09 => '^I',
- 0x0A => '^J',
- 0x0B => '^K',
- 0x0C => '^L',
- 0x0D => '^M', # Enter
- 0x0E => '^N',
- 0x0F => '^O',
- 0x10 => '^P',
- 0x11 => '^Q',
- 0x12 => '^R',
- 0x13 => '^S',
- 0x14 => '^T',
- 0x15 => '^U',
- 0x16 => '^V',
- 0x17 => '^W',
- 0x18 => '^X',
- 0x19 => '^Y',
- 0x1A => '^Z', # C-z
- 0x1B => '^[', # C-[ C-3
- 0x1D => '^]', # C-]
- 0x1E => '^^', # C-~ C-6
- 0x1F => '^_', # C-_ C-7
- 0x7F => '^?', # C-? C-8
- }
- EscapedChars = EscapedPairs.keys.map(&:chr)
-
- CSI_REGEXP = /\e\[[\d;]*[ABCDEFGHJKSTfminsuhl]/
- OSC_REGEXP = /\e\]\d+(?:;[^;]+)*\a/
- NON_PRINTING_START = "\1"
- NON_PRINTING_END = "\2"
- WIDTH_SCANNER = /\G(?:#{NON_PRINTING_START}|#{NON_PRINTING_END}|#{CSI_REGEXP}|#{OSC_REGEXP}|\X)/
-
- def self.get_mbchar_byte_size_by_first_char(c)
- # Checks UTF-8 character byte size
- case c.ord
- # 0b0xxxxxxx
- when ->(code) { (code ^ 0b10000000).allbits?(0b10000000) } then 1
- # 0b110xxxxx
- when ->(code) { (code ^ 0b00100000).allbits?(0b11100000) } then 2
- # 0b1110xxxx
- when ->(code) { (code ^ 0b00010000).allbits?(0b11110000) } then 3
- # 0b11110xxx
- when ->(code) { (code ^ 0b00001000).allbits?(0b11111000) } then 4
- # 0b111110xx
- when ->(code) { (code ^ 0b00000100).allbits?(0b11111100) } then 5
- # 0b1111110x
- when ->(code) { (code ^ 0b00000010).allbits?(0b11111110) } then 6
- # successor of mbchar
- else 0
- end
- end
-
- def self.escape_for_print(str)
- str.chars.map! { |gr|
- escaped = EscapedPairs[gr.ord]
- if escaped && gr != -"\n" && gr != -"\t"
- escaped
- else
- gr
- end
- }.join
- end
-
- def self.get_mbchar_width(mbchar)
- case mbchar.encode(Encoding::UTF_8)
- when *EscapedChars # ^ + char, such as ^M, ^H, ^[, ...
- 2
- when /^\u{2E3B}/ # THREE-EM DASH
- 3
- when /^\p{M}/
- 0
- when EastAsianWidth::TYPE_A
- Reline.ambiguous_width
- when EastAsianWidth::TYPE_F, EastAsianWidth::TYPE_W
- 2
- when EastAsianWidth::TYPE_H, EastAsianWidth::TYPE_NA, EastAsianWidth::TYPE_N
- 1
- else
- nil
- end
- end
-
- def self.calculate_width(str, allow_escape_code = false)
- if allow_escape_code
- width = 0
- rest = str.encode(Encoding::UTF_8)
- in_zero_width = false
- rest.scan(WIDTH_SCANNER) do |gc|
- case gc
- when NON_PRINTING_START
- in_zero_width = true
- when NON_PRINTING_END
- in_zero_width = false
- when CSI_REGEXP, OSC_REGEXP
- else
- unless in_zero_width
- width += get_mbchar_width(gc)
- end
- end
- end
- width
- else
- str.encode(Encoding::UTF_8).grapheme_clusters.inject(0) { |w, gc|
- w + get_mbchar_width(gc)
- }
- end
- end
-
- def self.split_by_width(str, max_width, encoding = str.encoding)
- lines = [String.new(encoding: encoding)]
- height = 1
- width = 0
- rest = str.encode(Encoding::UTF_8)
- in_zero_width = false
- rest.scan(WIDTH_SCANNER) do |gc|
- case gc
- when NON_PRINTING_START
- in_zero_width = true
- when NON_PRINTING_END
- in_zero_width = false
- when CSI_REGEXP, OSC_REGEXP
- lines.last << gc
- else
- unless in_zero_width
- mbchar_width = get_mbchar_width(gc)
- if (width += mbchar_width) > max_width
- width = mbchar_width
- lines << nil
- lines << String.new(encoding: encoding)
- height += 1
- end
- end
- lines.last << gc
- end
- end
- # The cursor moves to next line in first
- if width == max_width
- lines << nil
- lines << String.new(encoding: encoding)
- height += 1
- end
- [lines, height]
- end
-
- def self.get_next_mbchar_size(line, byte_pointer)
- grapheme = line.byteslice(byte_pointer..-1).grapheme_clusters.first
- grapheme ? grapheme.bytesize : 0
- end
-
- def self.get_prev_mbchar_size(line, byte_pointer)
- if byte_pointer.zero?
- 0
- else
- grapheme = line.byteslice(0..(byte_pointer - 1)).grapheme_clusters.last
- grapheme ? grapheme.bytesize : 0
- end
- end
-
- def self.em_forward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.em_forward_word_with_capitalization(line, byte_pointer)
- width = 0
- byte_size = 0
- new_str = String.new
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- new_str += mbchar
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- first = true
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- if first
- new_str += mbchar.upcase
- first = false
- else
- new_str += mbchar.downcase
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width, new_str]
- end
-
- def self.em_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.em_big_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\s/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.ed_transpose_words(line, byte_pointer)
- right_word_start = nil
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- if size.zero?
- # ' aaa bbb [cursor]'
- byte_size = 0
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size -= size
- end
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- right_word_start = byte_pointer + byte_size
- byte_size = 0
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size += size
- end
- after_start = byte_pointer + byte_size
- elsif mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- # ' aaa bb[cursor]b'
- byte_size = 0
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- right_word_start = byte_pointer + byte_size
- byte_size = 0
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size += size
- end
- after_start = byte_pointer + byte_size
- else
- byte_size = 0
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size += size
- end
- if (byte_pointer + byte_size) == (line.bytesize - 1)
- # ' aaa bbb [cursor] '
- after_start = line.bytesize
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size -= size
- end
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- right_word_start = byte_pointer + byte_size
- else
- # ' aaa [cursor] bbb '
- right_word_start = byte_pointer + byte_size
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size += size
- end
- after_start = byte_pointer + byte_size
- end
- end
- byte_size = right_word_start - byte_pointer
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size -= size
- end
- middle_start = byte_pointer + byte_size
- byte_size = middle_start - byte_pointer
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- left_word_start = byte_pointer + byte_size
- [left_word_start, middle_start, right_word_start, after_start]
- end
-
- def self.vi_big_forward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\s/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_big_forward_end_word(line, byte_pointer)
- if (line.bytesize - 1) > byte_pointer
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- width = get_mbchar_width(mbchar)
- byte_size = size
- else
- return [0, 0]
- end
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- prev_width = width
- prev_byte_size = byte_size
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\s/
- prev_width = width
- prev_byte_size = byte_size
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [prev_byte_size, prev_width]
- end
-
- def self.vi_big_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\s/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_forward_word(line, byte_pointer)
- if (line.bytesize - 1) > byte_pointer
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- if mbchar =~ /\w/
- started_by = :word
- elsif mbchar =~ /\s/
- started_by = :space
- else
- started_by = :non_word_printable
- end
- width = get_mbchar_width(mbchar)
- byte_size = size
- else
- return [0, 0]
- end
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- case started_by
- when :word
- break if mbchar =~ /\W/
- when :space
- break if mbchar =~ /\S/
- when :non_word_printable
- break if mbchar =~ /\w|\s/
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_forward_end_word(line, byte_pointer)
- if (line.bytesize - 1) > byte_pointer
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- if mbchar =~ /\w/
- started_by = :word
- elsif mbchar =~ /\s/
- started_by = :space
- else
- started_by = :non_word_printable
- end
- width = get_mbchar_width(mbchar)
- byte_size = size
- else
- return [0, 0]
- end
- if (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- if mbchar =~ /\w/
- second = :word
- elsif mbchar =~ /\s/
- second = :space
- else
- second = :non_word_printable
- end
- second_width = get_mbchar_width(mbchar)
- second_byte_size = size
- else
- return [byte_size, width]
- end
- if second == :space
- width += second_width
- byte_size += second_byte_size
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- if mbchar =~ /\S/
- if mbchar =~ /\w/
- started_by = :word
- else
- started_by = :non_word_printable
- end
- break
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- else
- case [started_by, second]
- when [:word, :non_word_printable], [:non_word_printable, :word]
- started_by = second
- else
- width += second_width
- byte_size += second_byte_size
- started_by = second
- end
- end
- prev_width = width
- prev_byte_size = byte_size
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- case started_by
- when :word
- break if mbchar =~ /\W/
- when :non_word_printable
- break if mbchar =~ /[\w\s]/
- end
- prev_width = width
- prev_byte_size = byte_size
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [prev_byte_size, prev_width]
- end
-
- def self.vi_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- if mbchar =~ /\S/
- if mbchar =~ /\w/
- started_by = :word
- else
- started_by = :non_word_printable
- end
- break
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- case started_by
- when :word
- break if mbchar =~ /\W/
- when :non_word_printable
- break if mbchar =~ /[\w\s]/
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_first_print(line)
- width = 0
- byte_size = 0
- while (line.bytesize - 1) > byte_size
- size = get_next_mbchar_size(line, byte_size)
- mbchar = line.byteslice(byte_size, size)
- if mbchar =~ /\S/
- break
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-end
-
-require 'reline/unicode/east_asian_width'
diff --git a/lib/reline/unicode/east_asian_width.rb b/lib/reline/unicode/east_asian_width.rb
deleted file mode 100644
index b2749ab754..0000000000
--- a/lib/reline/unicode/east_asian_width.rb
+++ /dev/null
@@ -1,1145 +0,0 @@
-class Reline::Unicode::EastAsianWidth
- # This is based on EastAsianWidth.txt
- # http://www.unicode.org/Public/12.1.0/ucd/EastAsianWidth.txt
-
- # Fullwidth
- TYPE_F = /^(
- \u{3000} |
- [\u{FF01}-\u{FF60}] |
- [\u{FFE0}-\u{FFE6}]
- )/x
-
- # Halfwidth
- TYPE_H = /^(
- \u{20A9} |
- [\u{FF61}-\u{FFBE}] |
- [\u{FFC2}-\u{FFC7}] |
- [\u{FFCA}-\u{FFCF}] |
- [\u{FFD2}-\u{FFD7}] |
- [\u{FFDA}-\u{FFDC}] |
- [\u{FFE8}-\u{FFEE}]
- )/x
-
- # Wide
- TYPE_W = /^(
- [\u{1100}-\u{115F}] |
- [\u{231A}-\u{231B}] |
- [\u{2329}-\u{232A}] |
- [\u{23E9}-\u{23EC}] |
- \u{23F0} |
- \u{23F3} |
- [\u{25FD}-\u{25FE}] |
- [\u{2614}-\u{2615}] |
- [\u{2648}-\u{2653}] |
- \u{267F} |
- \u{2693} |
- \u{26A1} |
- [\u{26AA}-\u{26AB}] |
- [\u{26BD}-\u{26BE}] |
- [\u{26C4}-\u{26C5}] |
- \u{26CE} |
- \u{26D4} |
- \u{26EA} |
- [\u{26F2}-\u{26F3}] |
- \u{26F5} |
- \u{26FA} |
- \u{26FD} |
- \u{2705} |
- [\u{270A}-\u{270B}] |
- \u{2728} |
- \u{274C} |
- \u{274E} |
- [\u{2753}-\u{2755}] |
- \u{2757} |
- [\u{2795}-\u{2797}] |
- \u{27B0} |
- \u{27BF} |
- [\u{2B1B}-\u{2B1C}] |
- \u{2B50} |
- \u{2B55} |
- [\u{2E80}-\u{2E99}] |
- [\u{2E9B}-\u{2EF3}] |
- [\u{2F00}-\u{2FD5}] |
- [\u{2FF0}-\u{2FFB}] |
- [\u{3001}-\u{303E}] |
- [\u{3041}-\u{3096}] |
- [\u{3099}-\u{30FF}] |
- [\u{3105}-\u{312F}] |
- [\u{3131}-\u{318E}] |
- [\u{3190}-\u{31BA}] |
- [\u{31C0}-\u{31E3}] |
- [\u{31F0}-\u{321E}] |
- [\u{3220}-\u{3247}] |
- [\u{3250}-\u{4DBF}] |
- [\u{4E00}-\u{A48C}] |
- [\u{A490}-\u{A4C6}] |
- [\u{A960}-\u{A97C}] |
- [\u{AC00}-\u{D7A3}] |
- [\u{F900}-\u{FAFF}] |
- [\u{FE10}-\u{FE19}] |
- [\u{FE30}-\u{FE52}] |
- [\u{FE54}-\u{FE66}] |
- [\u{FE68}-\u{FE6B}] |
- [\u{16FE0}-\u{16FE3}] |
- [\u{17000}-\u{187F7}] |
- [\u{18800}-\u{18AF2}] |
- [\u{1B000}-\u{1B11E}] |
- [\u{1B150}-\u{1B152}] |
- [\u{1B164}-\u{1B167}] |
- [\u{1B170}-\u{1B2FB}] |
- \u{1F004} |
- \u{1F0CF} |
- \u{1F18E} |
- [\u{1F191}-\u{1F19A}] |
- [\u{1F200}-\u{1F202}] |
- [\u{1F210}-\u{1F23B}] |
- [\u{1F240}-\u{1F248}] |
- [\u{1F250}-\u{1F251}] |
- [\u{1F260}-\u{1F265}] |
- [\u{1F300}-\u{1F320}] |
- [\u{1F32D}-\u{1F335}] |
- [\u{1F337}-\u{1F37C}] |
- [\u{1F37E}-\u{1F393}] |
- [\u{1F3A0}-\u{1F3CA}] |
- [\u{1F3CF}-\u{1F3D3}] |
- [\u{1F3E0}-\u{1F3F0}] |
- \u{1F3F4} |
- [\u{1F3F8}-\u{1F43E}] |
- \u{1F440} |
- [\u{1F442}-\u{1F4FC}] |
- [\u{1F4FF}-\u{1F53D}] |
- [\u{1F54B}-\u{1F54E}] |
- [\u{1F550}-\u{1F567}] |
- \u{1F57A} |
- [\u{1F595}-\u{1F596}] |
- \u{1F5A4} |
- [\u{1F5FB}-\u{1F64F}] |
- [\u{1F680}-\u{1F6C5}] |
- \u{1F6CC} |
- [\u{1F6D0}-\u{1F6D2}] |
- \u{1F6D5} |
- [\u{1F6EB}-\u{1F6EC}] |
- [\u{1F6F4}-\u{1F6FA}] |
- [\u{1F7E0}-\u{1F7EB}] |
- [\u{1F90D}-\u{1F971}] |
- [\u{1F973}-\u{1F976}] |
- [\u{1F97A}-\u{1F9A2}] |
- [\u{1F9A5}-\u{1F9AA}] |
- [\u{1F9AE}-\u{1F9CA}] |
- [\u{1F9CD}-\u{1F9FF}] |
- [\u{1FA70}-\u{1FA73}] |
- [\u{1FA78}-\u{1FA7A}] |
- [\u{1FA80}-\u{1FA82}] |
- [\u{1FA90}-\u{1FA95}] |
- [\u{20000}-\u{2FFFD}] |
- [\u{30000}-\u{3FFFD}]
- )/x
-
- # Narrow
- TYPE_NA = /^(
- [\u{0020}-\u{007E}] |
- [\u{00A2}-\u{00A3}] |
- [\u{00A5}-\u{00A6}] |
- \u{00AC} |
- \u{00AF} |
- [\u{27E6}-\u{27ED}] |
- [\u{2985}-\u{2986}]
- )/x
-
- # Ambiguous
- TYPE_A = /^(
- \u{00A1} |
- \u{00A4} |
- [\u{00A7}-\u{00A8}] |
- \u{00AA} |
- [\u{00AD}-\u{00AE}] |
- [\u{00B0}-\u{00B4}] |
- [\u{00B6}-\u{00BA}] |
- [\u{00BC}-\u{00BF}] |
- \u{00C6} |
- \u{00D0} |
- [\u{00D7}-\u{00D8}] |
- [\u{00DE}-\u{00E1}] |
- \u{00E6} |
- [\u{00E8}-\u{00EA}] |
- [\u{00EC}-\u{00ED}] |
- \u{00F0} |
- [\u{00F2}-\u{00F3}] |
- [\u{00F7}-\u{00FA}] |
- \u{00FC} |
- \u{00FE} |
- \u{0101} |
- \u{0111} |
- \u{0113} |
- \u{011B} |
- [\u{0126}-\u{0127}] |
- \u{012B} |
- [\u{0131}-\u{0133}] |
- \u{0138} |
- [\u{013F}-\u{0142}] |
- \u{0144} |
- [\u{0148}-\u{014B}] |
- \u{014D} |
- [\u{0152}-\u{0153}] |
- [\u{0166}-\u{0167}] |
- \u{016B} |
- \u{01CE} |
- \u{01D0} |
- \u{01D2} |
- \u{01D4} |
- \u{01D6} |
- \u{01D8} |
- \u{01DA} |
- \u{01DC} |
- \u{0251} |
- \u{0261} |
- \u{02C4} |
- \u{02C7} |
- [\u{02C9}-\u{02CB}] |
- \u{02CD} |
- \u{02D0} |
- [\u{02D8}-\u{02DB}] |
- \u{02DD} |
- \u{02DF} |
- [\u{0300}-\u{036F}] |
- [\u{0391}-\u{03A1}] |
- [\u{03A3}-\u{03A9}] |
- [\u{03B1}-\u{03C1}] |
- [\u{03C3}-\u{03C9}] |
- \u{0401} |
- [\u{0410}-\u{044F}] |
- \u{0451} |
- \u{2010} |
- [\u{2013}-\u{2016}] |
- [\u{2018}-\u{2019}] |
- [\u{201C}-\u{201D}] |
- [\u{2020}-\u{2022}] |
- [\u{2024}-\u{2027}] |
- \u{2030} |
- [\u{2032}-\u{2033}] |
- \u{2035} |
- \u{203B} |
- \u{203E} |
- \u{2074} |
- \u{207F} |
- [\u{2081}-\u{2084}] |
- \u{20AC} |
- \u{2103} |
- \u{2105} |
- \u{2109} |
- \u{2113} |
- \u{2116} |
- [\u{2121}-\u{2122}] |
- \u{2126} |
- \u{212B} |
- [\u{2153}-\u{2154}] |
- [\u{215B}-\u{215E}] |
- [\u{2160}-\u{216B}] |
- [\u{2170}-\u{2179}] |
- \u{2189} |
- [\u{2190}-\u{2199}] |
- [\u{21B8}-\u{21B9}] |
- \u{21D2} |
- \u{21D4} |
- \u{21E7} |
- \u{2200} |
- [\u{2202}-\u{2203}] |
- [\u{2207}-\u{2208}] |
- \u{220B} |
- \u{220F} |
- \u{2211} |
- \u{2215} |
- \u{221A} |
- [\u{221D}-\u{2220}] |
- \u{2223} |
- \u{2225} |
- [\u{2227}-\u{222C}] |
- \u{222E} |
- [\u{2234}-\u{2237}] |
- [\u{223C}-\u{223D}] |
- \u{2248} |
- \u{224C} |
- \u{2252} |
- [\u{2260}-\u{2261}] |
- [\u{2264}-\u{2267}] |
- [\u{226A}-\u{226B}] |
- [\u{226E}-\u{226F}] |
- [\u{2282}-\u{2283}] |
- [\u{2286}-\u{2287}] |
- \u{2295} |
- \u{2299} |
- \u{22A5} |
- \u{22BF} |
- \u{2312} |
- [\u{2460}-\u{24E9}] |
- [\u{24EB}-\u{254B}] |
- [\u{2550}-\u{2573}] |
- [\u{2580}-\u{258F}] |
- [\u{2592}-\u{2595}] |
- [\u{25A0}-\u{25A1}] |
- [\u{25A3}-\u{25A9}] |
- [\u{25B2}-\u{25B3}] |
- [\u{25B6}-\u{25B7}] |
- [\u{25BC}-\u{25BD}] |
- [\u{25C0}-\u{25C1}] |
- [\u{25C6}-\u{25C8}] |
- \u{25CB} |
- [\u{25CE}-\u{25D1}] |
- [\u{25E2}-\u{25E5}] |
- \u{25EF} |
- [\u{2605}-\u{2606}] |
- \u{2609} |
- [\u{260E}-\u{260F}] |
- \u{261C} |
- \u{261E} |
- \u{2640} |
- \u{2642} |
- [\u{2660}-\u{2661}] |
- [\u{2663}-\u{2665}] |
- [\u{2667}-\u{266A}] |
- [\u{266C}-\u{266D}] |
- \u{266F} |
- [\u{269E}-\u{269F}] |
- \u{26BF} |
- [\u{26C6}-\u{26CD}] |
- [\u{26CF}-\u{26D3}] |
- [\u{26D5}-\u{26E1}] |
- \u{26E3} |
- [\u{26E8}-\u{26E9}] |
- [\u{26EB}-\u{26F1}] |
- \u{26F4} |
- [\u{26F6}-\u{26F9}] |
- [\u{26FB}-\u{26FC}] |
- [\u{26FE}-\u{26FF}] |
- \u{273D} |
- [\u{2776}-\u{277F}] |
- [\u{2B56}-\u{2B59}] |
- [\u{3248}-\u{324F}] |
- [\u{E000}-\u{F8FF}] |
- [\u{FE00}-\u{FE0F}] |
- \u{FFFD} |
- [\u{1F100}-\u{1F10A}] |
- [\u{1F110}-\u{1F12D}] |
- [\u{1F130}-\u{1F169}] |
- [\u{1F170}-\u{1F18D}] |
- [\u{1F18F}-\u{1F190}] |
- [\u{1F19B}-\u{1F1AC}] |
- [\u{E0100}-\u{E01EF}] |
- [\u{F0000}-\u{FFFFD}] |
- [\u{100000}-\u{10FFFD}]
- )/x
-
- # Neutral
- TYPE_N = /^(
- [\u{0000}-\u{001F}] |
- [\u{007F}-\u{00A0}] |
- \u{00A9} |
- \u{00AB} |
- \u{00B5} |
- \u{00BB} |
- [\u{00C0}-\u{00C5}] |
- [\u{00C7}-\u{00CF}] |
- [\u{00D1}-\u{00D6}] |
- [\u{00D9}-\u{00DD}] |
- [\u{00E2}-\u{00E5}] |
- \u{00E7} |
- \u{00EB} |
- [\u{00EE}-\u{00EF}] |
- \u{00F1} |
- [\u{00F4}-\u{00F6}] |
- \u{00FB} |
- \u{00FD} |
- [\u{00FF}-\u{0100}] |
- [\u{0102}-\u{0110}] |
- \u{0112} |
- [\u{0114}-\u{011A}] |
- [\u{011C}-\u{0125}] |
- [\u{0128}-\u{012A}] |
- [\u{012C}-\u{0130}] |
- [\u{0134}-\u{0137}] |
- [\u{0139}-\u{013E}] |
- \u{0143} |
- [\u{0145}-\u{0147}] |
- \u{014C} |
- [\u{014E}-\u{0151}] |
- [\u{0154}-\u{0165}] |
- [\u{0168}-\u{016A}] |
- [\u{016C}-\u{01CD}] |
- \u{01CF} |
- \u{01D1} |
- \u{01D3} |
- \u{01D5} |
- \u{01D7} |
- \u{01D9} |
- \u{01DB} |
- [\u{01DD}-\u{0250}] |
- [\u{0252}-\u{0260}] |
- [\u{0262}-\u{02C3}] |
- [\u{02C5}-\u{02C6}] |
- \u{02C8} |
- \u{02CC} |
- [\u{02CE}-\u{02CF}] |
- [\u{02D1}-\u{02D7}] |
- \u{02DC} |
- \u{02DE} |
- [\u{02E0}-\u{02FF}] |
- [\u{0370}-\u{0377}] |
- [\u{037A}-\u{037F}] |
- [\u{0384}-\u{038A}] |
- \u{038C} |
- [\u{038E}-\u{0390}] |
- [\u{03AA}-\u{03B0}] |
- \u{03C2} |
- [\u{03CA}-\u{0400}] |
- [\u{0402}-\u{040F}] |
- \u{0450} |
- [\u{0452}-\u{052F}] |
- [\u{0531}-\u{0556}] |
- [\u{0559}-\u{058A}] |
- [\u{058D}-\u{058F}] |
- [\u{0591}-\u{05C7}] |
- [\u{05D0}-\u{05EA}] |
- [\u{05EF}-\u{05F4}] |
- [\u{0600}-\u{061C}] |
- [\u{061E}-\u{070D}] |
- [\u{070F}-\u{074A}] |
- [\u{074D}-\u{07B1}] |
- [\u{07C0}-\u{07FA}] |
- [\u{07FD}-\u{082D}] |
- [\u{0830}-\u{083E}] |
- [\u{0840}-\u{085B}] |
- \u{085E} |
- [\u{0860}-\u{086A}] |
- [\u{08A0}-\u{08B4}] |
- [\u{08B6}-\u{08BD}] |
- [\u{08D3}-\u{0983}] |
- [\u{0985}-\u{098C}] |
- [\u{098F}-\u{0990}] |
- [\u{0993}-\u{09A8}] |
- [\u{09AA}-\u{09B0}] |
- \u{09B2} |
- [\u{09B6}-\u{09B9}] |
- [\u{09BC}-\u{09C4}] |
- [\u{09C7}-\u{09C8}] |
- [\u{09CB}-\u{09CE}] |
- \u{09D7} |
- [\u{09DC}-\u{09DD}] |
- [\u{09DF}-\u{09E3}] |
- [\u{09E6}-\u{09FE}] |
- [\u{0A01}-\u{0A03}] |
- [\u{0A05}-\u{0A0A}] |
- [\u{0A0F}-\u{0A10}] |
- [\u{0A13}-\u{0A28}] |
- [\u{0A2A}-\u{0A30}] |
- [\u{0A32}-\u{0A33}] |
- [\u{0A35}-\u{0A36}] |
- [\u{0A38}-\u{0A39}] |
- \u{0A3C} |
- [\u{0A3E}-\u{0A42}] |
- [\u{0A47}-\u{0A48}] |
- [\u{0A4B}-\u{0A4D}] |
- \u{0A51} |
- [\u{0A59}-\u{0A5C}] |
- \u{0A5E} |
- [\u{0A66}-\u{0A76}] |
- [\u{0A81}-\u{0A83}] |
- [\u{0A85}-\u{0A8D}] |
- [\u{0A8F}-\u{0A91}] |
- [\u{0A93}-\u{0AA8}] |
- [\u{0AAA}-\u{0AB0}] |
- [\u{0AB2}-\u{0AB3}] |
- [\u{0AB5}-\u{0AB9}] |
- [\u{0ABC}-\u{0AC5}] |
- [\u{0AC7}-\u{0AC9}] |
- [\u{0ACB}-\u{0ACD}] |
- \u{0AD0} |
- [\u{0AE0}-\u{0AE3}] |
- [\u{0AE6}-\u{0AF1}] |
- [\u{0AF9}-\u{0AFF}] |
- [\u{0B01}-\u{0B03}] |
- [\u{0B05}-\u{0B0C}] |
- [\u{0B0F}-\u{0B10}] |
- [\u{0B13}-\u{0B28}] |
- [\u{0B2A}-\u{0B30}] |
- [\u{0B32}-\u{0B33}] |
- [\u{0B35}-\u{0B39}] |
- [\u{0B3C}-\u{0B44}] |
- [\u{0B47}-\u{0B48}] |
- [\u{0B4B}-\u{0B4D}] |
- [\u{0B56}-\u{0B57}] |
- [\u{0B5C}-\u{0B5D}] |
- [\u{0B5F}-\u{0B63}] |
- [\u{0B66}-\u{0B77}] |
- [\u{0B82}-\u{0B83}] |
- [\u{0B85}-\u{0B8A}] |
- [\u{0B8E}-\u{0B90}] |
- [\u{0B92}-\u{0B95}] |
- [\u{0B99}-\u{0B9A}] |
- \u{0B9C} |
- [\u{0B9E}-\u{0B9F}] |
- [\u{0BA3}-\u{0BA4}] |
- [\u{0BA8}-\u{0BAA}] |
- [\u{0BAE}-\u{0BB9}] |
- [\u{0BBE}-\u{0BC2}] |
- [\u{0BC6}-\u{0BC8}] |
- [\u{0BCA}-\u{0BCD}] |
- \u{0BD0} |
- \u{0BD7} |
- [\u{0BE6}-\u{0BFA}] |
- [\u{0C00}-\u{0C0C}] |
- [\u{0C0E}-\u{0C10}] |
- [\u{0C12}-\u{0C28}] |
- [\u{0C2A}-\u{0C39}] |
- [\u{0C3D}-\u{0C44}] |
- [\u{0C46}-\u{0C48}] |
- [\u{0C4A}-\u{0C4D}] |
- [\u{0C55}-\u{0C56}] |
- [\u{0C58}-\u{0C5A}] |
- [\u{0C60}-\u{0C63}] |
- [\u{0C66}-\u{0C6F}] |
- [\u{0C77}-\u{0C8C}] |
- [\u{0C8E}-\u{0C90}] |
- [\u{0C92}-\u{0CA8}] |
- [\u{0CAA}-\u{0CB3}] |
- [\u{0CB5}-\u{0CB9}] |
- [\u{0CBC}-\u{0CC4}] |
- [\u{0CC6}-\u{0CC8}] |
- [\u{0CCA}-\u{0CCD}] |
- [\u{0CD5}-\u{0CD6}] |
- \u{0CDE} |
- [\u{0CE0}-\u{0CE3}] |
- [\u{0CE6}-\u{0CEF}] |
- [\u{0CF1}-\u{0CF2}] |
- [\u{0D00}-\u{0D03}] |
- [\u{0D05}-\u{0D0C}] |
- [\u{0D0E}-\u{0D10}] |
- [\u{0D12}-\u{0D44}] |
- [\u{0D46}-\u{0D48}] |
- [\u{0D4A}-\u{0D4F}] |
- [\u{0D54}-\u{0D63}] |
- [\u{0D66}-\u{0D7F}] |
- [\u{0D82}-\u{0D83}] |
- [\u{0D85}-\u{0D96}] |
- [\u{0D9A}-\u{0DB1}] |
- [\u{0DB3}-\u{0DBB}] |
- \u{0DBD} |
- [\u{0DC0}-\u{0DC6}] |
- \u{0DCA} |
- [\u{0DCF}-\u{0DD4}] |
- \u{0DD6} |
- [\u{0DD8}-\u{0DDF}] |
- [\u{0DE6}-\u{0DEF}] |
- [\u{0DF2}-\u{0DF4}] |
- [\u{0E01}-\u{0E3A}] |
- [\u{0E3F}-\u{0E5B}] |
- [\u{0E81}-\u{0E82}] |
- \u{0E84} |
- [\u{0E86}-\u{0E8A}] |
- [\u{0E8C}-\u{0EA3}] |
- \u{0EA5} |
- [\u{0EA7}-\u{0EBD}] |
- [\u{0EC0}-\u{0EC4}] |
- \u{0EC6} |
- [\u{0EC8}-\u{0ECD}] |
- [\u{0ED0}-\u{0ED9}] |
- [\u{0EDC}-\u{0EDF}] |
- [\u{0F00}-\u{0F47}] |
- [\u{0F49}-\u{0F6C}] |
- [\u{0F71}-\u{0F97}] |
- [\u{0F99}-\u{0FBC}] |
- [\u{0FBE}-\u{0FCC}] |
- [\u{0FCE}-\u{0FDA}] |
- [\u{1000}-\u{10C5}] |
- \u{10C7} |
- \u{10CD} |
- [\u{10D0}-\u{10FF}] |
- [\u{1160}-\u{1248}] |
- [\u{124A}-\u{124D}] |
- [\u{1250}-\u{1256}] |
- \u{1258} |
- [\u{125A}-\u{125D}] |
- [\u{1260}-\u{1288}] |
- [\u{128A}-\u{128D}] |
- [\u{1290}-\u{12B0}] |
- [\u{12B2}-\u{12B5}] |
- [\u{12B8}-\u{12BE}] |
- \u{12C0} |
- [\u{12C2}-\u{12C5}] |
- [\u{12C8}-\u{12D6}] |
- [\u{12D8}-\u{1310}] |
- [\u{1312}-\u{1315}] |
- [\u{1318}-\u{135A}] |
- [\u{135D}-\u{137C}] |
- [\u{1380}-\u{1399}] |
- [\u{13A0}-\u{13F5}] |
- [\u{13F8}-\u{13FD}] |
- [\u{1400}-\u{169C}] |
- [\u{16A0}-\u{16F8}] |
- [\u{1700}-\u{170C}] |
- [\u{170E}-\u{1714}] |
- [\u{1720}-\u{1736}] |
- [\u{1740}-\u{1753}] |
- [\u{1760}-\u{176C}] |
- [\u{176E}-\u{1770}] |
- [\u{1772}-\u{1773}] |
- [\u{1780}-\u{17DD}] |
- [\u{17E0}-\u{17E9}] |
- [\u{17F0}-\u{17F9}] |
- [\u{1800}-\u{180E}] |
- [\u{1810}-\u{1819}] |
- [\u{1820}-\u{1878}] |
- [\u{1880}-\u{18AA}] |
- [\u{18B0}-\u{18F5}] |
- [\u{1900}-\u{191E}] |
- [\u{1920}-\u{192B}] |
- [\u{1930}-\u{193B}] |
- \u{1940} |
- [\u{1944}-\u{196D}] |
- [\u{1970}-\u{1974}] |
- [\u{1980}-\u{19AB}] |
- [\u{19B0}-\u{19C9}] |
- [\u{19D0}-\u{19DA}] |
- [\u{19DE}-\u{1A1B}] |
- [\u{1A1E}-\u{1A5E}] |
- [\u{1A60}-\u{1A7C}] |
- [\u{1A7F}-\u{1A89}] |
- [\u{1A90}-\u{1A99}] |
- [\u{1AA0}-\u{1AAD}] |
- [\u{1AB0}-\u{1ABE}] |
- [\u{1B00}-\u{1B4B}] |
- [\u{1B50}-\u{1B7C}] |
- [\u{1B80}-\u{1BF3}] |
- [\u{1BFC}-\u{1C37}] |
- [\u{1C3B}-\u{1C49}] |
- [\u{1C4D}-\u{1C88}] |
- [\u{1C90}-\u{1CBA}] |
- [\u{1CBD}-\u{1CC7}] |
- [\u{1CD0}-\u{1CFA}] |
- [\u{1D00}-\u{1DF9}] |
- [\u{1DFB}-\u{1F15}] |
- [\u{1F18}-\u{1F1D}] |
- [\u{1F20}-\u{1F45}] |
- [\u{1F48}-\u{1F4D}] |
- [\u{1F50}-\u{1F57}] |
- \u{1F59} |
- \u{1F5B} |
- \u{1F5D} |
- [\u{1F5F}-\u{1F7D}] |
- [\u{1F80}-\u{1FB4}] |
- [\u{1FB6}-\u{1FC4}] |
- [\u{1FC6}-\u{1FD3}] |
- [\u{1FD6}-\u{1FDB}] |
- [\u{1FDD}-\u{1FEF}] |
- [\u{1FF2}-\u{1FF4}] |
- [\u{1FF6}-\u{1FFE}] |
- [\u{2000}-\u{200F}] |
- [\u{2011}-\u{2012}] |
- \u{2017} |
- [\u{201A}-\u{201B}] |
- [\u{201E}-\u{201F}] |
- \u{2023} |
- [\u{2028}-\u{202F}] |
- \u{2031} |
- \u{2034} |
- [\u{2036}-\u{203A}] |
- [\u{203C}-\u{203D}] |
- [\u{203F}-\u{2064}] |
- [\u{2066}-\u{2071}] |
- [\u{2075}-\u{207E}] |
- \u{2080} |
- [\u{2085}-\u{208E}] |
- [\u{2090}-\u{209C}] |
- [\u{20A0}-\u{20A8}] |
- [\u{20AA}-\u{20AB}] |
- [\u{20AD}-\u{20BF}] |
- [\u{20D0}-\u{20F0}] |
- [\u{2100}-\u{2102}] |
- \u{2104} |
- [\u{2106}-\u{2108}] |
- [\u{210A}-\u{2112}] |
- [\u{2114}-\u{2115}] |
- [\u{2117}-\u{2120}] |
- [\u{2123}-\u{2125}] |
- [\u{2127}-\u{212A}] |
- [\u{212C}-\u{2152}] |
- [\u{2155}-\u{215A}] |
- \u{215F} |
- [\u{216C}-\u{216F}] |
- [\u{217A}-\u{2188}] |
- [\u{218A}-\u{218B}] |
- [\u{219A}-\u{21B7}] |
- [\u{21BA}-\u{21D1}] |
- \u{21D3} |
- [\u{21D5}-\u{21E6}] |
- [\u{21E8}-\u{21FF}] |
- \u{2201} |
- [\u{2204}-\u{2206}] |
- [\u{2209}-\u{220A}] |
- [\u{220C}-\u{220E}] |
- \u{2210} |
- [\u{2212}-\u{2214}] |
- [\u{2216}-\u{2219}] |
- [\u{221B}-\u{221C}] |
- [\u{2221}-\u{2222}] |
- \u{2224} |
- \u{2226} |
- \u{222D} |
- [\u{222F}-\u{2233}] |
- [\u{2238}-\u{223B}] |
- [\u{223E}-\u{2247}] |
- [\u{2249}-\u{224B}] |
- [\u{224D}-\u{2251}] |
- [\u{2253}-\u{225F}] |
- [\u{2262}-\u{2263}] |
- [\u{2268}-\u{2269}] |
- [\u{226C}-\u{226D}] |
- [\u{2270}-\u{2281}] |
- [\u{2284}-\u{2285}] |
- [\u{2288}-\u{2294}] |
- [\u{2296}-\u{2298}] |
- [\u{229A}-\u{22A4}] |
- [\u{22A6}-\u{22BE}] |
- [\u{22C0}-\u{2311}] |
- [\u{2313}-\u{2319}] |
- [\u{231C}-\u{2328}] |
- [\u{232B}-\u{23E8}] |
- [\u{23ED}-\u{23EF}] |
- [\u{23F1}-\u{23F2}] |
- [\u{23F4}-\u{2426}] |
- [\u{2440}-\u{244A}] |
- \u{24EA} |
- [\u{254C}-\u{254F}] |
- [\u{2574}-\u{257F}] |
- [\u{2590}-\u{2591}] |
- [\u{2596}-\u{259F}] |
- \u{25A2} |
- [\u{25AA}-\u{25B1}] |
- [\u{25B4}-\u{25B5}] |
- [\u{25B8}-\u{25BB}] |
- [\u{25BE}-\u{25BF}] |
- [\u{25C2}-\u{25C5}] |
- [\u{25C9}-\u{25CA}] |
- [\u{25CC}-\u{25CD}] |
- [\u{25D2}-\u{25E1}] |
- [\u{25E6}-\u{25EE}] |
- [\u{25F0}-\u{25FC}] |
- [\u{25FF}-\u{2604}] |
- [\u{2607}-\u{2608}] |
- [\u{260A}-\u{260D}] |
- [\u{2610}-\u{2613}] |
- [\u{2616}-\u{261B}] |
- \u{261D} |
- [\u{261F}-\u{263F}] |
- \u{2641} |
- [\u{2643}-\u{2647}] |
- [\u{2654}-\u{265F}] |
- \u{2662} |
- \u{2666} |
- \u{266B} |
- \u{266E} |
- [\u{2670}-\u{267E}] |
- [\u{2680}-\u{2692}] |
- [\u{2694}-\u{269D}] |
- \u{26A0} |
- [\u{26A2}-\u{26A9}] |
- [\u{26AC}-\u{26BC}] |
- [\u{26C0}-\u{26C3}] |
- \u{26E2} |
- [\u{26E4}-\u{26E7}] |
- [\u{2700}-\u{2704}] |
- [\u{2706}-\u{2709}] |
- [\u{270C}-\u{2727}] |
- [\u{2729}-\u{273C}] |
- [\u{273E}-\u{274B}] |
- \u{274D} |
- [\u{274F}-\u{2752}] |
- \u{2756} |
- [\u{2758}-\u{2775}] |
- [\u{2780}-\u{2794}] |
- [\u{2798}-\u{27AF}] |
- [\u{27B1}-\u{27BE}] |
- [\u{27C0}-\u{27E5}] |
- [\u{27EE}-\u{2984}] |
- [\u{2987}-\u{2B1A}] |
- [\u{2B1D}-\u{2B4F}] |
- [\u{2B51}-\u{2B54}] |
- [\u{2B5A}-\u{2B73}] |
- [\u{2B76}-\u{2B95}] |
- [\u{2B98}-\u{2C2E}] |
- [\u{2C30}-\u{2C5E}] |
- [\u{2C60}-\u{2CF3}] |
- [\u{2CF9}-\u{2D25}] |
- \u{2D27} |
- \u{2D2D} |
- [\u{2D30}-\u{2D67}] |
- [\u{2D6F}-\u{2D70}] |
- [\u{2D7F}-\u{2D96}] |
- [\u{2DA0}-\u{2DA6}] |
- [\u{2DA8}-\u{2DAE}] |
- [\u{2DB0}-\u{2DB6}] |
- [\u{2DB8}-\u{2DBE}] |
- [\u{2DC0}-\u{2DC6}] |
- [\u{2DC8}-\u{2DCE}] |
- [\u{2DD0}-\u{2DD6}] |
- [\u{2DD8}-\u{2DDE}] |
- [\u{2DE0}-\u{2E4F}] |
- \u{303F} |
- [\u{4DC0}-\u{4DFF}] |
- [\u{A4D0}-\u{A62B}] |
- [\u{A640}-\u{A6F7}] |
- [\u{A700}-\u{A7BF}] |
- [\u{A7C2}-\u{A7C6}] |
- [\u{A7F7}-\u{A82B}] |
- [\u{A830}-\u{A839}] |
- [\u{A840}-\u{A877}] |
- [\u{A880}-\u{A8C5}] |
- [\u{A8CE}-\u{A8D9}] |
- [\u{A8E0}-\u{A953}] |
- \u{A95F} |
- [\u{A980}-\u{A9CD}] |
- [\u{A9CF}-\u{A9D9}] |
- [\u{A9DE}-\u{A9FE}] |
- [\u{AA00}-\u{AA36}] |
- [\u{AA40}-\u{AA4D}] |
- [\u{AA50}-\u{AA59}] |
- [\u{AA5C}-\u{AAC2}] |
- [\u{AADB}-\u{AAF6}] |
- [\u{AB01}-\u{AB06}] |
- [\u{AB09}-\u{AB0E}] |
- [\u{AB11}-\u{AB16}] |
- [\u{AB20}-\u{AB26}] |
- [\u{AB28}-\u{AB2E}] |
- [\u{AB30}-\u{AB67}] |
- [\u{AB70}-\u{ABED}] |
- [\u{ABF0}-\u{ABF9}] |
- [\u{D7B0}-\u{D7C6}] |
- [\u{D7CB}-\u{D7FB}] |
- [\u{FB00}-\u{FB06}] |
- [\u{FB13}-\u{FB17}] |
- [\u{FB1D}-\u{FB36}] |
- [\u{FB38}-\u{FB3C}] |
- \u{FB3E} |
- [\u{FB40}-\u{FB41}] |
- [\u{FB43}-\u{FB44}] |
- [\u{FB46}-\u{FBC1}] |
- [\u{FBD3}-\u{FD3F}] |
- [\u{FD50}-\u{FD8F}] |
- [\u{FD92}-\u{FDC7}] |
- [\u{FDF0}-\u{FDFD}] |
- [\u{FE20}-\u{FE2F}] |
- [\u{FE70}-\u{FE74}] |
- [\u{FE76}-\u{FEFC}] |
- \u{FEFF} |
- [\u{FFF9}-\u{FFFC}] |
- [\u{10000}-\u{1000B}] |
- [\u{1000D}-\u{10026}] |
- [\u{10028}-\u{1003A}] |
- [\u{1003C}-\u{1003D}] |
- [\u{1003F}-\u{1004D}] |
- [\u{10050}-\u{1005D}] |
- [\u{10080}-\u{100FA}] |
- [\u{10100}-\u{10102}] |
- [\u{10107}-\u{10133}] |
- [\u{10137}-\u{1018E}] |
- [\u{10190}-\u{1019B}] |
- \u{101A0} |
- [\u{101D0}-\u{101FD}] |
- [\u{10280}-\u{1029C}] |
- [\u{102A0}-\u{102D0}] |
- [\u{102E0}-\u{102FB}] |
- [\u{10300}-\u{10323}] |
- [\u{1032D}-\u{1034A}] |
- [\u{10350}-\u{1037A}] |
- [\u{10380}-\u{1039D}] |
- [\u{1039F}-\u{103C3}] |
- [\u{103C8}-\u{103D5}] |
- [\u{10400}-\u{1049D}] |
- [\u{104A0}-\u{104A9}] |
- [\u{104B0}-\u{104D3}] |
- [\u{104D8}-\u{104FB}] |
- [\u{10500}-\u{10527}] |
- [\u{10530}-\u{10563}] |
- \u{1056F} |
- [\u{10600}-\u{10736}] |
- [\u{10740}-\u{10755}] |
- [\u{10760}-\u{10767}] |
- [\u{10800}-\u{10805}] |
- \u{10808} |
- [\u{1080A}-\u{10835}] |
- [\u{10837}-\u{10838}] |
- \u{1083C} |
- [\u{1083F}-\u{10855}] |
- [\u{10857}-\u{1089E}] |
- [\u{108A7}-\u{108AF}] |
- [\u{108E0}-\u{108F2}] |
- [\u{108F4}-\u{108F5}] |
- [\u{108FB}-\u{1091B}] |
- [\u{1091F}-\u{10939}] |
- \u{1093F} |
- [\u{10980}-\u{109B7}] |
- [\u{109BC}-\u{109CF}] |
- [\u{109D2}-\u{10A03}] |
- [\u{10A05}-\u{10A06}] |
- [\u{10A0C}-\u{10A13}] |
- [\u{10A15}-\u{10A17}] |
- [\u{10A19}-\u{10A35}] |
- [\u{10A38}-\u{10A3A}] |
- [\u{10A3F}-\u{10A48}] |
- [\u{10A50}-\u{10A58}] |
- [\u{10A60}-\u{10A9F}] |
- [\u{10AC0}-\u{10AE6}] |
- [\u{10AEB}-\u{10AF6}] |
- [\u{10B00}-\u{10B35}] |
- [\u{10B39}-\u{10B55}] |
- [\u{10B58}-\u{10B72}] |
- [\u{10B78}-\u{10B91}] |
- [\u{10B99}-\u{10B9C}] |
- [\u{10BA9}-\u{10BAF}] |
- [\u{10C00}-\u{10C48}] |
- [\u{10C80}-\u{10CB2}] |
- [\u{10CC0}-\u{10CF2}] |
- [\u{10CFA}-\u{10D27}] |
- [\u{10D30}-\u{10D39}] |
- [\u{10E60}-\u{10E7E}] |
- [\u{10F00}-\u{10F27}] |
- [\u{10F30}-\u{10F59}] |
- [\u{10FE0}-\u{10FF6}] |
- [\u{11000}-\u{1104D}] |
- [\u{11052}-\u{1106F}] |
- [\u{1107F}-\u{110C1}] |
- \u{110CD} |
- [\u{110D0}-\u{110E8}] |
- [\u{110F0}-\u{110F9}] |
- [\u{11100}-\u{11134}] |
- [\u{11136}-\u{11146}] |
- [\u{11150}-\u{11176}] |
- [\u{11180}-\u{111CD}] |
- [\u{111D0}-\u{111DF}] |
- [\u{111E1}-\u{111F4}] |
- [\u{11200}-\u{11211}] |
- [\u{11213}-\u{1123E}] |
- [\u{11280}-\u{11286}] |
- \u{11288} |
- [\u{1128A}-\u{1128D}] |
- [\u{1128F}-\u{1129D}] |
- [\u{1129F}-\u{112A9}] |
- [\u{112B0}-\u{112EA}] |
- [\u{112F0}-\u{112F9}] |
- [\u{11300}-\u{11303}] |
- [\u{11305}-\u{1130C}] |
- [\u{1130F}-\u{11310}] |
- [\u{11313}-\u{11328}] |
- [\u{1132A}-\u{11330}] |
- [\u{11332}-\u{11333}] |
- [\u{11335}-\u{11339}] |
- [\u{1133B}-\u{11344}] |
- [\u{11347}-\u{11348}] |
- [\u{1134B}-\u{1134D}] |
- \u{11350} |
- \u{11357} |
- [\u{1135D}-\u{11363}] |
- [\u{11366}-\u{1136C}] |
- [\u{11370}-\u{11374}] |
- [\u{11400}-\u{11459}] |
- \u{1145B} |
- [\u{1145D}-\u{1145F}] |
- [\u{11480}-\u{114C7}] |
- [\u{114D0}-\u{114D9}] |
- [\u{11580}-\u{115B5}] |
- [\u{115B8}-\u{115DD}] |
- [\u{11600}-\u{11644}] |
- [\u{11650}-\u{11659}] |
- [\u{11660}-\u{1166C}] |
- [\u{11680}-\u{116B8}] |
- [\u{116C0}-\u{116C9}] |
- [\u{11700}-\u{1171A}] |
- [\u{1171D}-\u{1172B}] |
- [\u{11730}-\u{1173F}] |
- [\u{11800}-\u{1183B}] |
- [\u{118A0}-\u{118F2}] |
- \u{118FF} |
- [\u{119A0}-\u{119A7}] |
- [\u{119AA}-\u{119D7}] |
- [\u{119DA}-\u{119E4}] |
- [\u{11A00}-\u{11A47}] |
- [\u{11A50}-\u{11AA2}] |
- [\u{11AC0}-\u{11AF8}] |
- [\u{11C00}-\u{11C08}] |
- [\u{11C0A}-\u{11C36}] |
- [\u{11C38}-\u{11C45}] |
- [\u{11C50}-\u{11C6C}] |
- [\u{11C70}-\u{11C8F}] |
- [\u{11C92}-\u{11CA7}] |
- [\u{11CA9}-\u{11CB6}] |
- [\u{11D00}-\u{11D06}] |
- [\u{11D08}-\u{11D09}] |
- [\u{11D0B}-\u{11D36}] |
- \u{11D3A} |
- [\u{11D3C}-\u{11D3D}] |
- [\u{11D3F}-\u{11D47}] |
- [\u{11D50}-\u{11D59}] |
- [\u{11D60}-\u{11D65}] |
- [\u{11D67}-\u{11D68}] |
- [\u{11D6A}-\u{11D8E}] |
- [\u{11D90}-\u{11D91}] |
- [\u{11D93}-\u{11D98}] |
- [\u{11DA0}-\u{11DA9}] |
- [\u{11EE0}-\u{11EF8}] |
- [\u{11FC0}-\u{11FF1}] |
- [\u{11FFF}-\u{12399}] |
- [\u{12400}-\u{1246E}] |
- [\u{12470}-\u{12474}] |
- [\u{12480}-\u{12543}] |
- [\u{13000}-\u{1342E}] |
- [\u{13430}-\u{13438}] |
- [\u{14400}-\u{14646}] |
- [\u{16800}-\u{16A38}] |
- [\u{16A40}-\u{16A5E}] |
- [\u{16A60}-\u{16A69}] |
- [\u{16A6E}-\u{16A6F}] |
- [\u{16AD0}-\u{16AED}] |
- [\u{16AF0}-\u{16AF5}] |
- [\u{16B00}-\u{16B45}] |
- [\u{16B50}-\u{16B59}] |
- [\u{16B5B}-\u{16B61}] |
- [\u{16B63}-\u{16B77}] |
- [\u{16B7D}-\u{16B8F}] |
- [\u{16E40}-\u{16E9A}] |
- [\u{16F00}-\u{16F4A}] |
- [\u{16F4F}-\u{16F87}] |
- [\u{16F8F}-\u{16F9F}] |
- [\u{1BC00}-\u{1BC6A}] |
- [\u{1BC70}-\u{1BC7C}] |
- [\u{1BC80}-\u{1BC88}] |
- [\u{1BC90}-\u{1BC99}] |
- [\u{1BC9C}-\u{1BCA3}] |
- [\u{1D000}-\u{1D0F5}] |
- [\u{1D100}-\u{1D126}] |
- [\u{1D129}-\u{1D1E8}] |
- [\u{1D200}-\u{1D245}] |
- [\u{1D2E0}-\u{1D2F3}] |
- [\u{1D300}-\u{1D356}] |
- [\u{1D360}-\u{1D378}] |
- [\u{1D400}-\u{1D454}] |
- [\u{1D456}-\u{1D49C}] |
- [\u{1D49E}-\u{1D49F}] |
- \u{1D4A2} |
- [\u{1D4A5}-\u{1D4A6}] |
- [\u{1D4A9}-\u{1D4AC}] |
- [\u{1D4AE}-\u{1D4B9}] |
- \u{1D4BB} |
- [\u{1D4BD}-\u{1D4C3}] |
- [\u{1D4C5}-\u{1D505}] |
- [\u{1D507}-\u{1D50A}] |
- [\u{1D50D}-\u{1D514}] |
- [\u{1D516}-\u{1D51C}] |
- [\u{1D51E}-\u{1D539}] |
- [\u{1D53B}-\u{1D53E}] |
- [\u{1D540}-\u{1D544}] |
- \u{1D546} |
- [\u{1D54A}-\u{1D550}] |
- [\u{1D552}-\u{1D6A5}] |
- [\u{1D6A8}-\u{1D7CB}] |
- [\u{1D7CE}-\u{1DA8B}] |
- [\u{1DA9B}-\u{1DA9F}] |
- [\u{1DAA1}-\u{1DAAF}] |
- [\u{1E000}-\u{1E006}] |
- [\u{1E008}-\u{1E018}] |
- [\u{1E01B}-\u{1E021}] |
- [\u{1E023}-\u{1E024}] |
- [\u{1E026}-\u{1E02A}] |
- [\u{1E100}-\u{1E12C}] |
- [\u{1E130}-\u{1E13D}] |
- [\u{1E140}-\u{1E149}] |
- [\u{1E14E}-\u{1E14F}] |
- [\u{1E2C0}-\u{1E2F9}] |
- \u{1E2FF} |
- [\u{1E800}-\u{1E8C4}] |
- [\u{1E8C7}-\u{1E8D6}] |
- [\u{1E900}-\u{1E94B}] |
- [\u{1E950}-\u{1E959}] |
- [\u{1E95E}-\u{1E95F}] |
- [\u{1EC71}-\u{1ECB4}] |
- [\u{1ED01}-\u{1ED3D}] |
- [\u{1EE00}-\u{1EE03}] |
- [\u{1EE05}-\u{1EE1F}] |
- [\u{1EE21}-\u{1EE22}] |
- \u{1EE24} |
- \u{1EE27} |
- [\u{1EE29}-\u{1EE32}] |
- [\u{1EE34}-\u{1EE37}] |
- \u{1EE39} |
- \u{1EE3B} |
- \u{1EE42} |
- \u{1EE47} |
- \u{1EE49} |
- \u{1EE4B} |
- [\u{1EE4D}-\u{1EE4F}] |
- [\u{1EE51}-\u{1EE52}] |
- \u{1EE54} |
- \u{1EE57} |
- \u{1EE59} |
- \u{1EE5B} |
- \u{1EE5D} |
- \u{1EE5F} |
- [\u{1EE61}-\u{1EE62}] |
- \u{1EE64} |
- [\u{1EE67}-\u{1EE6A}] |
- [\u{1EE6C}-\u{1EE72}] |
- [\u{1EE74}-\u{1EE77}] |
- [\u{1EE79}-\u{1EE7C}] |
- \u{1EE7E} |
- [\u{1EE80}-\u{1EE89}] |
- [\u{1EE8B}-\u{1EE9B}] |
- [\u{1EEA1}-\u{1EEA3}] |
- [\u{1EEA5}-\u{1EEA9}] |
- [\u{1EEAB}-\u{1EEBB}] |
- [\u{1EEF0}-\u{1EEF1}] |
- [\u{1F000}-\u{1F003}] |
- [\u{1F005}-\u{1F02B}] |
- [\u{1F030}-\u{1F093}] |
- [\u{1F0A0}-\u{1F0AE}] |
- [\u{1F0B1}-\u{1F0BF}] |
- [\u{1F0C1}-\u{1F0CE}] |
- [\u{1F0D1}-\u{1F0F5}] |
- [\u{1F10B}-\u{1F10C}] |
- [\u{1F12E}-\u{1F12F}] |
- [\u{1F16A}-\u{1F16C}] |
- [\u{1F1E6}-\u{1F1FF}] |
- [\u{1F321}-\u{1F32C}] |
- \u{1F336} |
- \u{1F37D} |
- [\u{1F394}-\u{1F39F}] |
- [\u{1F3CB}-\u{1F3CE}] |
- [\u{1F3D4}-\u{1F3DF}] |
- [\u{1F3F1}-\u{1F3F3}] |
- [\u{1F3F5}-\u{1F3F7}] |
- \u{1F43F} |
- \u{1F441} |
- [\u{1F4FD}-\u{1F4FE}] |
- [\u{1F53E}-\u{1F54A}] |
- \u{1F54F} |
- [\u{1F568}-\u{1F579}] |
- [\u{1F57B}-\u{1F594}] |
- [\u{1F597}-\u{1F5A3}] |
- [\u{1F5A5}-\u{1F5FA}] |
- [\u{1F650}-\u{1F67F}] |
- [\u{1F6C6}-\u{1F6CB}] |
- [\u{1F6CD}-\u{1F6CF}] |
- [\u{1F6D3}-\u{1F6D4}] |
- [\u{1F6E0}-\u{1F6EA}] |
- [\u{1F6F0}-\u{1F6F3}] |
- [\u{1F700}-\u{1F773}] |
- [\u{1F780}-\u{1F7D8}] |
- [\u{1F800}-\u{1F80B}] |
- [\u{1F810}-\u{1F847}] |
- [\u{1F850}-\u{1F859}] |
- [\u{1F860}-\u{1F887}] |
- [\u{1F890}-\u{1F8AD}] |
- [\u{1F900}-\u{1F90B}] |
- [\u{1FA00}-\u{1FA53}] |
- [\u{1FA60}-\u{1FA6D}] |
- \u{E0001} |
- [\u{E0020}-\u{E007F}]
- )/x
-end
diff --git a/lib/reline/version.rb b/lib/reline/version.rb
deleted file mode 100644
index aa0ef18145..0000000000
--- a/lib/reline/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Reline
- VERSION = '0.1.5'
-end
diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
deleted file mode 100644
index 2a406e39d3..0000000000
--- a/lib/reline/windows.rb
+++ /dev/null
@@ -1,282 +0,0 @@
-require 'fiddle/import'
-
-class Reline::Windows
- def self.encoding
- Encoding::UTF_8
- end
-
- def self.win?
- true
- end
-
- RAW_KEYSTROKE_CONFIG = {
- [224, 72] => :ed_prev_history, # ↑
- [224, 80] => :ed_next_history, # ↓
- [224, 77] => :ed_next_char, # →
- [224, 75] => :ed_prev_char, # â†
- [224, 83] => :key_delete, # Del
- [224, 71] => :ed_move_to_beg, # Home
- [224, 79] => :ed_move_to_end, # End
- [ 0, 41] => :ed_unassigned, # input method on/off
- [ 0, 72] => :ed_prev_history, # ↑
- [ 0, 80] => :ed_next_history, # ↓
- [ 0, 77] => :ed_next_char, # →
- [ 0, 75] => :ed_prev_char, # â†
- [ 0, 83] => :key_delete, # Del
- [ 0, 71] => :ed_move_to_beg, # Home
- [ 0, 79] => :ed_move_to_end # End
- }
-
- if defined? JRUBY_VERSION
- require 'win32api'
- else
- class Win32API
- DLL = {}
- TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG}
- POINTER_TYPE = Fiddle::SIZEOF_VOIDP == Fiddle::SIZEOF_LONG_LONG ? 'q*' : 'l!*'
-
- WIN32_TYPES = "VPpNnLlIi"
- DL_TYPES = "0SSI"
-
- def initialize(dllname, func, import, export = "0", calltype = :stdcall)
- @proto = [import].join.tr(WIN32_TYPES, DL_TYPES).sub(/^(.)0*$/, '\1')
- import = @proto.chars.map {|win_type| TYPEMAP[win_type.tr(WIN32_TYPES, DL_TYPES)]}
- export = TYPEMAP[export.tr(WIN32_TYPES, DL_TYPES)]
- calltype = Fiddle::Importer.const_get(:CALL_TYPE_TO_ABI)[calltype]
-
- handle = DLL[dllname] ||=
- begin
- Fiddle.dlopen(dllname)
- rescue Fiddle::DLError
- raise unless File.extname(dllname).empty?
- Fiddle.dlopen(dllname + ".dll")
- end
-
- @func = Fiddle::Function.new(handle[func], import, export, calltype)
- rescue Fiddle::DLError => e
- raise LoadError, e.message, e.backtrace
- end
-
- def call(*args)
- import = @proto.split("")
- args.each_with_index do |x, i|
- args[i], = [x == 0 ? nil : x].pack("p").unpack(POINTER_TYPE) if import[i] == "S"
- args[i], = [x].pack("I").unpack("i") if import[i] == "I"
- end
- ret, = @func.call(*args)
- return ret || 0
- end
- end
- end
-
- VK_MENU = 0x12
- VK_LMENU = 0xA4
- VK_CONTROL = 0x11
- VK_SHIFT = 0x10
- STD_INPUT_HANDLE = -10
- STD_OUTPUT_HANDLE = -11
- WINDOW_BUFFER_SIZE_EVENT = 0x04
- FILE_TYPE_PIPE = 0x0003
- FILE_NAME_INFO = 2
- @@getwch = Win32API.new('msvcrt', '_getwch', [], 'I')
- @@kbhit = Win32API.new('msvcrt', '_kbhit', [], 'I')
- @@GetKeyState = Win32API.new('user32', 'GetKeyState', ['L'], 'L')
- @@GetConsoleScreenBufferInfo = Win32API.new('kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L')
- @@SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', ['L', 'L'], 'L')
- @@GetStdHandle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
- @@FillConsoleOutputCharacter = Win32API.new('kernel32', 'FillConsoleOutputCharacter', ['L', 'L', 'L', 'L', 'P'], 'L')
- @@ScrollConsoleScreenBuffer = Win32API.new('kernel32', 'ScrollConsoleScreenBuffer', ['L', 'P', 'P', 'L', 'P'], 'L')
- @@hConsoleHandle = @@GetStdHandle.call(STD_OUTPUT_HANDLE)
- @@hConsoleInputHandle = @@GetStdHandle.call(STD_INPUT_HANDLE)
- @@GetNumberOfConsoleInputEvents = Win32API.new('kernel32', 'GetNumberOfConsoleInputEvents', ['L', 'P'], 'L')
- @@ReadConsoleInput = Win32API.new('kernel32', 'ReadConsoleInput', ['L', 'P', 'L', 'P'], 'L')
- @@GetFileType = Win32API.new('kernel32', 'GetFileType', ['L'], 'L')
- @@GetFileInformationByHandleEx = Win32API.new('kernel32', 'GetFileInformationByHandleEx', ['L', 'I', 'P', 'L'], 'I')
- @@FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', ['L', 'L', 'L', 'L', 'P'], 'L')
-
- @@input_buf = []
- @@output_buf = []
-
- def self.msys_tty?(io=@@hConsoleInputHandle)
- # check if fd is a pipe
- if @@GetFileType.call(io) != FILE_TYPE_PIPE
- return false
- end
-
- bufsize = 1024
- p_buffer = "\0" * bufsize
- res = @@GetFileInformationByHandleEx.call(io, FILE_NAME_INFO, p_buffer, bufsize - 2)
- return false if res == 0
-
- # get pipe name: p_buffer layout is:
- # struct _FILE_NAME_INFO {
- # DWORD FileNameLength;
- # WCHAR FileName[1];
- # } FILE_NAME_INFO
- len = p_buffer[0, 4].unpack("L")[0]
- name = p_buffer[4, len].encode(Encoding::UTF_8, Encoding::UTF_16LE, invalid: :replace)
-
- # Check if this could be a MSYS2 pty pipe ('\msys-XXXX-ptyN-XX')
- # or a cygwin pty pipe ('\cygwin-XXXX-ptyN-XX')
- name =~ /(msys-|cygwin-).*-pty/ ? true : false
- end
-
- def self.getwch
- unless @@input_buf.empty?
- return @@input_buf.shift
- end
- while @@kbhit.call == 0
- sleep(0.001)
- end
- until @@kbhit.call == 0
- ret = @@getwch.call
- if ret == 0 or ret == 0xE0
- @@input_buf << ret
- ret = @@getwch.call
- @@input_buf << ret
- return @@input_buf.shift
- end
- begin
- bytes = ret.chr(Encoding::UTF_8).bytes
- @@input_buf.push(*bytes)
- rescue Encoding::UndefinedConversionError
- @@input_buf << ret
- @@input_buf << @@getwch.call if ret == 224
- end
- end
- @@input_buf.shift
- end
-
- def self.getc
- num_of_events = 0.chr * 8
- while @@GetNumberOfConsoleInputEvents.(@@hConsoleInputHandle, num_of_events) != 0 and num_of_events.unpack('L').first > 0
- input_record = 0.chr * 18
- read_event = 0.chr * 4
- if @@ReadConsoleInput.(@@hConsoleInputHandle, input_record, 1, read_event) != 0
- event = input_record[0, 2].unpack('s*').first
- if event == WINDOW_BUFFER_SIZE_EVENT
- @@winch_handler.()
- end
- end
- end
- unless @@output_buf.empty?
- return @@output_buf.shift
- end
- input = getwch
- meta = (@@GetKeyState.call(VK_LMENU) & 0x80) != 0
- control = (@@GetKeyState.call(VK_CONTROL) & 0x80) != 0
- shift = (@@GetKeyState.call(VK_SHIFT) & 0x80) != 0
- force_enter = !input.instance_of?(Array) && (control or shift) && input == 0x0D
- if force_enter
- # It's treated as Meta+Enter on Windows
- @@output_buf.push("\e".ord)
- @@output_buf.push(input)
- else
- case input
- when 0x00
- meta = false
- @@output_buf.push(input)
- input = getwch
- @@output_buf.push(*input)
- when 0xE0
- @@output_buf.push(input)
- input = getwch
- @@output_buf.push(*input)
- when 0x03
- @@output_buf.push(input)
- else
- @@output_buf.push(input)
- end
- end
- if meta
- "\e".ord
- else
- @@output_buf.shift
- end
- end
-
- def self.ungetc(c)
- @@output_buf.unshift(c)
- end
-
- def self.get_screen_size
- csbi = 0.chr * 22
- @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi)
- csbi[0, 4].unpack('SS').reverse
- end
-
- def self.cursor_pos
- csbi = 0.chr * 22
- @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi)
- x = csbi[4, 2].unpack('s*').first
- y = csbi[6, 2].unpack('s*').first
- Reline::CursorPos.new(x, y)
- end
-
- def self.move_cursor_column(val)
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, cursor_pos.y * 65536 + val)
- end
-
- def self.move_cursor_up(val)
- if val > 0
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, (cursor_pos.y - val) * 65536 + cursor_pos.x)
- elsif val < 0
- move_cursor_down(-val)
- end
- end
-
- def self.move_cursor_down(val)
- if val > 0
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, (cursor_pos.y + val) * 65536 + cursor_pos.x)
- elsif val < 0
- move_cursor_up(-val)
- end
- end
-
- def self.erase_after_cursor
- csbi = 0.chr * 24
- @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi)
- cursor = csbi[4, 4].unpack('L').first
- written = 0.chr * 4
- @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, get_screen_size.last - cursor_pos.x, cursor, written)
- end
-
- def self.scroll_down(val)
- return if val.zero?
- scroll_rectangle = [0, val, get_screen_size.last, get_screen_size.first].pack('s4')
- destination_origin = 0 # y * 65536 + x
- fill = [' '.ord, 0].pack('SS')
- @@ScrollConsoleScreenBuffer.call(@@hConsoleHandle, scroll_rectangle, nil, destination_origin, fill)
- end
-
- def self.clear_screen
- csbi = 0.chr * 22
- return if @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi) == 0
- buffer_width = csbi[0, 2].unpack('S').first
- attributes = csbi[8, 2].unpack('S').first
- _window_left, window_top, _window_right, window_bottom = *csbi[10,8].unpack('S*')
- fill_length = buffer_width * (window_bottom - window_top + 1)
- screen_topleft = window_top * 65536
- written = 0.chr * 4
- @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, fill_length, screen_topleft, written)
- @@FillConsoleOutputAttribute.call(@@hConsoleHandle, attributes, fill_length, screen_topleft, written)
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, screen_topleft)
- end
-
- def self.set_screen_size(rows, columns)
- raise NotImplementedError
- end
-
- def self.set_winch_handler(&handler)
- @@winch_handler = handler
- end
-
- def self.prep
- # do nothing
- nil
- end
-
- def self.deprep(otio)
- # do nothing
- end
-end
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 45b2a9323b..45e1af47f4 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -166,14 +166,13 @@ class Resolv
# Resolv::Hosts is a hostname resolver that uses the system hosts file.
class Hosts
- if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM and
- begin
- require 'win32/resolv'
- DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL
- rescue LoadError
- end
+ begin
+ raise LoadError unless /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
+ require 'win32/resolv'
+ DefaultFileName = Win32::Resolv.get_hosts_path
+ rescue LoadError
+ DefaultFileName = '/etc/hosts'
end
- DefaultFileName ||= '/etc/hosts'
##
# Creates a new Resolv::Hosts, using +filename+ for its data source.
@@ -194,12 +193,15 @@ class Resolv
line.sub!(/#.*/, '')
addr, hostname, *aliases = line.split(/\s+/)
next unless addr
+ addr.untaint
+ hostname.untaint
@addr2name[addr] = [] unless @addr2name.include? addr
@addr2name[addr] << hostname
@addr2name[addr] += aliases
@name2addr[hostname] = [] unless @name2addr.include? hostname
@name2addr[hostname] << addr
aliases.each {|n|
+ n.untaint
@name2addr[n] = [] unless @name2addr.include? n
@name2addr[n] << addr
}
@@ -234,7 +236,9 @@ class Resolv
def each_address(name, &proc)
lazy_initialize
- @name2addr[name]&.each(&proc)
+ if @name2addr.include?(name)
+ @name2addr[name].each(&proc)
+ end
end
##
@@ -449,8 +453,6 @@ class Resolv
case address
when Name
ptr = address
- when IPv4, IPv6
- ptr = address.to_name
when IPv4::Regex
ptr = IPv4.create(address).to_name
when IPv6::Regex
@@ -511,15 +513,10 @@ class Resolv
def fetch_resource(name, typeclass)
lazy_initialize
- begin
- requester = make_udp_requester
- rescue Errno::EACCES
- # fall back to TCP
- end
+ requester = make_udp_requester
senders = {}
begin
@config.resolv(name) {|candidate, tout, nameserver, port|
- requester ||= make_tcp_requester(nameserver, port)
msg = Message.new
msg.rd = 1
msg.add_question(candidate, typeclass)
@@ -552,7 +549,7 @@ class Resolv
end
}
ensure
- requester&.close
+ requester.close
end
end
@@ -614,6 +611,16 @@ class Resolv
end
end
+
+ def self.rangerand(range) # :nodoc:
+ base = range.begin
+ len = range.end - range.begin
+ if !range.exclude_end?
+ len += 1
+ end
+ base + random(len)
+ end
+
RequestID = {} # :nodoc:
RequestIDMutex = Thread::Mutex.new # :nodoc:
@@ -622,7 +629,7 @@ class Resolv
RequestIDMutex.synchronize {
h = (RequestID[[host, port]] ||= {})
begin
- id = random(0x0000..0xffff)
+ id = rangerand(0x0000..0xffff)
end while h[id]
h[id] = true
}
@@ -643,7 +650,7 @@ class Resolv
def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
begin
- port = random(1024..65535)
+ port = rangerand(1024..65535)
udpsock.bind(bind_host, port)
rescue Errno::EADDRINUSE, # POSIX
Errno::EACCES, # SunOS: See PRIV_SYS_NFS in privileges(5)
@@ -696,13 +703,13 @@ class Resolv
rescue DecodeError
next # broken DNS message ignored
end
- if sender == sender_for(from, msg)
+ if s = sender_for(from, msg)
break
else
# unexpected DNS message ignored
end
end
- return msg, sender.data
+ return msg, s.data
end
def sender_for(addr, msg)
@@ -961,6 +968,7 @@ class Resolv
f.each {|line|
line.sub!(/[#;].*/, '')
keyword, *args = line.split(/\s+/)
+ args.each(&:untaint)
next unless keyword
case keyword
when 'nameserver'
@@ -2532,7 +2540,7 @@ class Resolv
attr_reader :address
def to_s # :nodoc:
- address = sprintf("%x:%x:%x:%x:%x:%x:%x:%x", *@address.unpack("nnnnnnnn"))
+ address = sprintf("%X:%X:%X:%X:%X:%X:%X:%X", *@address.unpack("nnnnnnnn"))
unless address.sub!(/(^|:)0(:0)+(:|$)/, '::')
address.sub!(/(^|:)0(:|$)/, '::')
end
@@ -2631,7 +2639,7 @@ class Resolv
def each_address(name)
name = Resolv::DNS::Name.create(name)
- return unless name[-1].to_s == 'local'
+ return unless name.to_a.last.to_s == 'local'
super(name)
end
diff --git a/lib/rexml/attlistdecl.rb b/lib/rexml/attlistdecl.rb
index 44a91d66d6..dc1d2add0b 100644
--- a/lib/rexml/attlistdecl.rb
+++ b/lib/rexml/attlistdecl.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
#vim:ts=2 sw=2 noexpandtab:
-require_relative 'child'
-require_relative 'source'
+require 'rexml/child'
+require 'rexml/source'
module REXML
# This class needs:
diff --git a/lib/rexml/attribute.rb b/lib/rexml/attribute.rb
index 8933a013a2..ca5984e178 100644
--- a/lib/rexml/attribute.rb
+++ b/lib/rexml/attribute.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative "namespace"
-require_relative 'text'
+require "rexml/namespace"
+require 'rexml/text'
module REXML
# Defines an Element Attribute; IE, a attribute=value pair, as in:
@@ -67,11 +67,15 @@ module REXML
# e.add_attribute( "nsa:a", "aval" )
# e.add_attribute( "b", "bval" )
# e.attributes.get_attribute( "a" ).prefix # -> "nsa"
- # e.attributes.get_attribute( "b" ).prefix # -> ""
+ # e.attributes.get_attribute( "b" ).prefix # -> "elns"
# a = Attribute.new( "x", "y" )
# a.prefix # -> ""
def prefix
- super
+ pf = super
+ if pf == ""
+ pf = @element.prefix if @element
+ end
+ pf
end
# Returns the namespace URL, if defined, or nil otherwise
@@ -82,26 +86,9 @@ module REXML
# e.add_attribute("nsx:a", "c")
# e.attribute("ns:a").namespace # => "http://url"
# e.attribute("nsx:a").namespace # => nil
- #
- # This method always returns "" for no namespace attribute. Because
- # the default namespace doesn't apply to attribute names.
- #
- # From https://www.w3.org/TR/xml-names/#uniqAttrs
- #
- # > the default namespace does not apply to attribute names
- #
- # e = REXML::Element.new("el")
- # e.add_namespace("", "http://example.com/")
- # e.namespace # => "http://example.com/"
- # e.add_attribute("a", "b")
- # e.attribute("a").namespace # => ""
def namespace arg=nil
arg = prefix if arg.nil?
- if arg == ""
- ""
- else
- @element.namespace(arg)
- end
+ @element.namespace arg
end
# Returns true if other is an Attribute and has the same name and value,
diff --git a/lib/rexml/cdata.rb b/lib/rexml/cdata.rb
index 997f5a08db..2238446dc4 100644
--- a/lib/rexml/cdata.rb
+++ b/lib/rexml/cdata.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "text"
+require "rexml/text"
module REXML
class CData < Text
diff --git a/lib/rexml/child.rb b/lib/rexml/child.rb
index cc6e9a4719..d23451e71e 100644
--- a/lib/rexml/child.rb
+++ b/lib/rexml/child.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "node"
+require "rexml/node"
module REXML
##
diff --git a/lib/rexml/comment.rb b/lib/rexml/comment.rb
index 52c58b46f6..822fe0d586 100644
--- a/lib/rexml/comment.rb
+++ b/lib/rexml/comment.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "child"
+require "rexml/child"
module REXML
##
diff --git a/lib/rexml/doctype.rb b/lib/rexml/doctype.rb
index a4e91529ac..1eb1f5b4e1 100644
--- a/lib/rexml/doctype.rb
+++ b/lib/rexml/doctype.rb
@@ -1,50 +1,12 @@
# frozen_string_literal: false
-require_relative "parent"
-require_relative "parseexception"
-require_relative "namespace"
-require_relative 'entity'
-require_relative 'attlistdecl'
-require_relative 'xmltokens'
+require "rexml/parent"
+require "rexml/parseexception"
+require "rexml/namespace"
+require 'rexml/entity'
+require 'rexml/attlistdecl'
+require 'rexml/xmltokens'
module REXML
- class ReferenceWriter
- def initialize(id_type,
- public_id_literal,
- system_literal,
- context=nil)
- @id_type = id_type
- @public_id_literal = public_id_literal
- @system_literal = system_literal
- if context and context[:prologue_quote] == :apostrophe
- @default_quote = "'"
- else
- @default_quote = "\""
- end
- end
-
- def write(output)
- output << " #{@id_type}"
- if @public_id_literal
- if @public_id_literal.include?("'")
- quote = "\""
- else
- quote = @default_quote
- end
- output << " #{quote}#{@public_id_literal}#{quote}"
- end
- if @system_literal
- if @system_literal.include?("'")
- quote = "\""
- elsif @system_literal.include?("\"")
- quote = "'"
- else
- quote = @default_quote
- end
- output << " #{quote}#{@system_literal}#{quote}"
- end
- end
- end
-
# Represents an XML DOCTYPE declaration; that is, the contents of <!DOCTYPE
# ... >. DOCTYPES can be used to declare the DTD of a document, as well as
# being used to declare entities used in the document.
@@ -88,8 +50,6 @@ module REXML
super( parent )
@name = first.name
@external_id = first.external_id
- @long_name = first.instance_variable_get(:@long_name)
- @uri = first.instance_variable_get(:@uri)
elsif first.kind_of? Array
super( parent )
@name = first[0]
@@ -152,13 +112,9 @@ module REXML
output << START
output << ' '
output << @name
- if @external_id
- reference_writer = ReferenceWriter.new(@external_id,
- @long_name,
- @uri,
- context)
- reference_writer.write(output)
- end
+ output << " #@external_id" if @external_id
+ output << " #{@long_name.inspect}" if @long_name
+ output << " #{@uri.inspect}" if @uri
unless @children.empty?
output << ' ['
@children.each { |child|
@@ -171,11 +127,7 @@ module REXML
end
def context
- if @parent
- @parent.context
- else
- nil
- end
+ @parent.context
end
def entity( name )
@@ -297,11 +249,9 @@ module REXML
end
def to_s
- context = nil
- context = parent.context if parent
- notation = "<!NOTATION #{@name}"
- reference_writer = ReferenceWriter.new(@middle, @public, @system, context)
- reference_writer.write(notation)
+ notation = "<!NOTATION #{@name} #{@middle}"
+ notation << " #{@public.inspect}" if @public
+ notation << " #{@system.inspect}" if @system
notation << ">"
notation
end
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
index adec293066..806bc499cd 100644
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: false
-require_relative "security"
-require_relative "element"
-require_relative "xmldecl"
-require_relative "source"
-require_relative "comment"
-require_relative "doctype"
-require_relative "instruction"
-require_relative "rexml"
-require_relative "parseexception"
-require_relative "output"
-require_relative "parsers/baseparser"
-require_relative "parsers/streamparser"
-require_relative "parsers/treeparser"
+require "rexml/security"
+require "rexml/element"
+require "rexml/xmldecl"
+require "rexml/source"
+require "rexml/comment"
+require "rexml/doctype"
+require "rexml/instruction"
+require "rexml/rexml"
+require "rexml/parseexception"
+require "rexml/output"
+require "rexml/parsers/baseparser"
+require "rexml/parsers/streamparser"
+require "rexml/parsers/treeparser"
module REXML
# Represents a full XML document, including PIs, a doctype, etc. A
@@ -226,7 +226,7 @@ module REXML
end
formatter = if indent > -1
if transitive
- require_relative "formatters/transitive"
+ require "rexml/formatters/transitive"
REXML::Formatters::Transitive.new( indent, ie_hack )
else
REXML::Formatters::Pretty.new( indent, ie_hack )
diff --git a/lib/rexml/dtd/attlistdecl.rb b/lib/rexml/dtd/attlistdecl.rb
index 1326cb21e4..32847daadb 100644
--- a/lib/rexml/dtd/attlistdecl.rb
+++ b/lib/rexml/dtd/attlistdecl.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "../child"
+require "rexml/child"
module REXML
module DTD
class AttlistDecl < Child
diff --git a/lib/rexml/dtd/dtd.rb b/lib/rexml/dtd/dtd.rb
index 8b0f2d753a..927d5d847b 100644
--- a/lib/rexml/dtd/dtd.rb
+++ b/lib/rexml/dtd/dtd.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: false
-require_relative "elementdecl"
-require_relative "entitydecl"
-require_relative "../comment"
-require_relative "notationdecl"
-require_relative "attlistdecl"
-require_relative "../parent"
+require "rexml/dtd/elementdecl"
+require "rexml/dtd/entitydecl"
+require "rexml/comment"
+require "rexml/dtd/notationdecl"
+require "rexml/dtd/attlistdecl"
+require "rexml/parent"
module REXML
module DTD
diff --git a/lib/rexml/dtd/elementdecl.rb b/lib/rexml/dtd/elementdecl.rb
index 20ed023244..119fd41a8f 100644
--- a/lib/rexml/dtd/elementdecl.rb
+++ b/lib/rexml/dtd/elementdecl.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "../child"
+require "rexml/child"
module REXML
module DTD
class ElementDecl < Child
diff --git a/lib/rexml/dtd/entitydecl.rb b/lib/rexml/dtd/entitydecl.rb
index 312df655ff..45707e2f42 100644
--- a/lib/rexml/dtd/entitydecl.rb
+++ b/lib/rexml/dtd/entitydecl.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "../child"
+require "rexml/child"
module REXML
module DTD
class EntityDecl < Child
diff --git a/lib/rexml/dtd/notationdecl.rb b/lib/rexml/dtd/notationdecl.rb
index 04a9b08aa7..cfdf0b9b74 100644
--- a/lib/rexml/dtd/notationdecl.rb
+++ b/lib/rexml/dtd/notationdecl.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "../child"
+require "rexml/child"
module REXML
module DTD
class NotationDecl < Child
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
index c706a7c245..ac9b10872c 100644
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: false
-require_relative "parent"
-require_relative "namespace"
-require_relative "attribute"
-require_relative "cdata"
-require_relative "xpath"
-require_relative "parseexception"
+require "rexml/parent"
+require "rexml/namespace"
+require "rexml/attribute"
+require "rexml/cdata"
+require "rexml/xpath"
+require "rexml/parseexception"
module REXML
# An implementation note about namespaces:
@@ -713,7 +713,7 @@ module REXML
Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters", uplevel: 1)
formatter = if indent > -1
if transitive
- require_relative "formatters/transitive"
+ require "rexml/formatters/transitive"
REXML::Formatters::Transitive.new( indent, ie_hack )
else
REXML::Formatters::Pretty.new( indent, ie_hack )
@@ -1033,7 +1033,6 @@ module REXML
# p attr.expanded_name+" => "+attr.value
# }
def each_attribute # :yields: attribute
- return to_enum(__method__) unless block_given?
each_value do |val|
if val.kind_of? Attribute
yield val
@@ -1049,7 +1048,6 @@ module REXML
# doc = Document.new '<a x="1" y="2"/>'
# doc.root.attributes.each {|name, value| p name+" => "+value }
def each
- return to_enum(__method__) unless block_given?
each_attribute do |attr|
yield [attr.expanded_name, attr.value]
end
@@ -1132,18 +1130,16 @@ module REXML
old_attr[value.prefix] = value
elsif old_attr.prefix != value.prefix
# Check for conflicting namespaces
- if value.prefix != "xmlns" and old_attr.prefix != "xmlns"
- old_namespace = old_attr.namespace
- new_namespace = value.namespace
- if old_namespace == new_namespace
- raise ParseException.new(
- "Namespace conflict in adding attribute \"#{value.name}\": "+
- "Prefix \"#{old_attr.prefix}\" = \"#{old_namespace}\" and "+
- "prefix \"#{value.prefix}\" = \"#{new_namespace}\"")
- end
- end
- store value.name, {old_attr.prefix => old_attr,
- value.prefix => value}
+ raise ParseException.new(
+ "Namespace conflict in adding attribute \"#{value.name}\": "+
+ "Prefix \"#{old_attr.prefix}\" = "+
+ "\"#{@element.namespace(old_attr.prefix)}\" and prefix "+
+ "\"#{value.prefix}\" = \"#{@element.namespace(value.prefix)}\"") if
+ value.prefix != "xmlns" and old_attr.prefix != "xmlns" and
+ @element.namespace( old_attr.prefix ) ==
+ @element.namespace( value.prefix )
+ store value.name, { old_attr.prefix => old_attr,
+ value.prefix => value }
else
store value.name, value
end
diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb
index 89a9e84c57..97c7b6b42f 100644
--- a/lib/rexml/entity.rb
+++ b/lib/rexml/entity.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative 'child'
-require_relative 'source'
-require_relative 'xmltokens'
+require 'rexml/child'
+require 'rexml/source'
+require 'rexml/xmltokens'
module REXML
class Entity < Child
@@ -90,7 +90,7 @@ module REXML
# object itself is valid.)
#
# out::
- # An object implementing <TT>&lt;&lt;</TT> to which the entity will be
+ # An object implementing <TT>&lt;&lt;<TT> to which the entity will be
# output
# indent::
# *DEPRECATED* and ignored
diff --git a/lib/rexml/formatters/default.rb b/lib/rexml/formatters/default.rb
index 811b2ff3d5..c375f1468b 100644
--- a/lib/rexml/formatters/default.rb
+++ b/lib/rexml/formatters/default.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: false
-
module REXML
module Formatters
class Default
@@ -102,14 +101,11 @@ module REXML
end
def write_instruction( node, output )
- output << Instruction::START
+ output << Instruction::START.sub(/\\/u, '')
output << node.target
- content = node.content
- if content
- output << ' '
- output << content
- end
- output << Instruction::STOP
+ output << ' '
+ output << node.content
+ output << Instruction::STOP.sub(/\\/u, '')
end
end
end
diff --git a/lib/rexml/formatters/pretty.rb b/lib/rexml/formatters/pretty.rb
index 562ef9462e..a80274bdad 100644
--- a/lib/rexml/formatters/pretty.rb
+++ b/lib/rexml/formatters/pretty.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'default'
+require 'rexml/formatters/default'
module REXML
module Formatters
diff --git a/lib/rexml/formatters/transitive.rb b/lib/rexml/formatters/transitive.rb
index 5ff51e10f3..81e67f3274 100644
--- a/lib/rexml/formatters/transitive.rb
+++ b/lib/rexml/formatters/transitive.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'pretty'
+require 'rexml/formatters/pretty'
module REXML
module Formatters
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
index 77926bf2af..cd879fdd28 100644
--- a/lib/rexml/functions.rb
+++ b/lib/rexml/functions.rb
@@ -66,11 +66,11 @@ module REXML
def Functions::id( object )
end
- def Functions::local_name(node_set=nil)
- get_namespace(node_set) do |node|
+ # UNTESTED
+ def Functions::local_name( node_set=nil )
+ get_namespace( node_set ) do |node|
return node.local_name
end
- ""
end
def Functions::namespace_uri( node_set=nil )
@@ -86,14 +86,10 @@ module REXML
# Helper method.
def Functions::get_namespace( node_set = nil )
if node_set == nil
- yield @@context[:node] if @@context[:node].respond_to?(:namespace)
+ yield @@context[:node] if defined? @@context[:node].namespace
else
if node_set.respond_to? :each
- result = []
- node_set.each do |node|
- result << yield(node) if node.respond_to?(:namespace)
- end
- result
+ node_set.each { |node| yield node if defined? node.namespace }
elsif node_set.respond_to? :namespace
yield node_set
end
@@ -135,38 +131,22 @@ module REXML
#
# An object of a type other than the four basic types is converted to a
# string in a way that is dependent on that type.
- def Functions::string( object=@@context[:node] )
- if object.respond_to?(:node_type)
- case object.node_type
- when :attribute
+ def Functions::string( object=nil )
+ #object = @context unless object
+ if object.instance_of? Array
+ string( object[0] )
+ elsif defined? object.node_type
+ if object.node_type == :attribute
object.value
- when :element
+ elsif object.node_type == :element || object.node_type == :document
string_value(object)
- when :document
- string_value(object.root)
- when :processing_instruction
- object.content
else
object.to_s
end
+ elsif object.nil?
+ return ""
else
- case object
- when Array
- string(object[0])
- when Float
- if object.nan?
- "NaN"
- else
- integer = object.to_i
- if object == integer
- "%d" % integer
- else
- object.to_s
- end
- end
- else
- object.to_s
- end
+ object.to_s
end
end
@@ -187,12 +167,9 @@ module REXML
rv
end
+ # UNTESTED
def Functions::concat( *objects )
- concatenated = ""
- objects.each do |object|
- concatenated << string(object)
- end
- concatenated
+ objects.join
end
# Fixed by Mike Stok
@@ -315,23 +292,18 @@ module REXML
end
end
- def Functions::boolean(object=@@context[:node])
- case object
- when true, false
- object
- when Float
- return false if object.zero?
- return false if object.nan?
- true
- when Numeric
- not object.zero?
- when String
- not object.empty?
- when Array
- not object.empty?
- else
- object ? true : false
+ # UNTESTED
+ def Functions::boolean( object=nil )
+ if object.kind_of? String
+ if object =~ /\d+/u
+ return object.to_f != 0
+ else
+ return object.size > 0
+ end
+ elsif object.kind_of? Array
+ object = object.find{|x| x and true}
end
+ return object ? true : false
end
# UNTESTED
@@ -385,23 +357,25 @@ module REXML
#
# an object of a type other than the four basic types is converted to a
# number in a way that is dependent on that type
- def Functions::number(object=@@context[:node])
+ def Functions::number( object=nil )
+ object = @@context[:node] unless object
case object
when true
Float(1)
when false
Float(0)
when Array
- number(string(object))
+ number(string( object ))
when Numeric
object.to_f
else
- str = string(object)
- case str.strip
- when /\A\s*(-?(?:\d+(?:\.\d*)?|\.\d+))\s*\z/
- $1.to_f
+ str = string( object )
+ # If XPath ever gets scientific notation...
+ #if str =~ /^\s*-?(\d*\.?\d+|\d+\.)([Ee]\d*)?\s*$/
+ if str =~ /^\s*-?(\d*\.?\d+|\d+\.)\s*$/
+ str.to_f
else
- Float::NAN
+ (0.0 / 0.0)
end
end
end
@@ -423,7 +397,7 @@ module REXML
number = number(number)
begin
neg = number.negative?
- number = number.abs.round
+ number = number.abs.round(half: :up)
neg ? -number : number
rescue FloatDomainError
number
diff --git a/lib/rexml/instruction.rb b/lib/rexml/instruction.rb
index 318741f03b..c4f65eefc1 100644
--- a/lib/rexml/instruction.rb
+++ b/lib/rexml/instruction.rb
@@ -1,14 +1,13 @@
# frozen_string_literal: false
-
-require_relative "child"
-require_relative "source"
+require "rexml/child"
+require "rexml/source"
module REXML
# Represents an XML Instruction; IE, <? ... ?>
# TODO: Add parent arg (3rd arg) to constructor
class Instruction < Child
- START = "<?"
- STOP = "?>"
+ START = '<\?'
+ STOP = '\?>'
# target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
# content is everything else.
@@ -18,25 +17,20 @@ module REXML
# @param target can be one of a number of things. If String, then
# the target of this instruction is set to this. If an Instruction,
# then the Instruction is shallowly cloned (target and content are
- # copied).
+ # copied). If a Source, then the source is scanned and parsed for
+ # an Instruction declaration.
# @param content Must be either a String, or a Parent. Can only
# be a Parent if the target argument is a Source. Otherwise, this
# String is set as the content of this instruction.
def initialize(target, content=nil)
- case target
- when String
+ if target.kind_of? String
super()
@target = target
@content = content
- when Instruction
+ elsif target.kind_of? Instruction
super(content)
@target = target.target
@content = target.content
- else
- message =
- "processing instruction target must be String or REXML::Instruction: "
- message << "<#{target.inspect}>"
- raise ArgumentError, message
end
@content.strip! if @content
end
@@ -51,13 +45,11 @@ module REXML
def write writer, indent=-1, transitive=false, ie_hack=false
Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1)
indent(writer, indent)
- writer << START
+ writer << START.sub(/\\/u, '')
writer << @target
- if @content
- writer << ' '
- writer << @content
- end
- writer << STOP
+ writer << ' '
+ writer << @content
+ writer << STOP.sub(/\\/u, '')
end
# @return true if other is an Instruction, and the content and target
diff --git a/lib/rexml/light/node.rb b/lib/rexml/light/node.rb
index 01177c64d2..d58119a3a4 100644
--- a/lib/rexml/light/node.rb
+++ b/lib/rexml/light/node.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative '../xmltokens'
+require 'rexml/xmltokens'
# [ :element, parent, name, attributes, children* ]
# a = Node.new
diff --git a/lib/rexml/namespace.rb b/lib/rexml/namespace.rb
index 924edf9506..90ba7cc635 100644
--- a/lib/rexml/namespace.rb
+++ b/lib/rexml/namespace.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: false
-
-require_relative 'xmltokens'
+require 'rexml/xmltokens'
module REXML
# Adds named attributes to an object.
@@ -15,24 +14,14 @@ module REXML
# Sets the name and the expanded name
def name=( name )
@expanded_name = name
- case name
- when NAMESPLIT
- if $1
- @prefix = $1
- else
- @prefix = ""
- @namespace = ""
- end
- @name = $2
- when ""
- @prefix = nil
- @namespace = nil
- @name = nil
+ name =~ NAMESPLIT
+ if $1
+ @prefix = $1
else
- message = "name must be \#{PREFIX}:\#{LOCAL_NAME} or \#{LOCAL_NAME}: "
- message += "<#{name.inspect}>"
- raise ArgumentError, message
+ @prefix = ""
+ @namespace = ""
end
+ @name = $2
end
# Compares names optionally WITH namespaces
diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb
index 081caba6cb..52337ade44 100644
--- a/lib/rexml/node.rb
+++ b/lib/rexml/node.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative "parseexception"
-require_relative "formatters/pretty"
-require_relative "formatters/default"
+require "rexml/parseexception"
+require "rexml/formatters/pretty"
+require "rexml/formatters/default"
module REXML
# Represents a node in the tree. Nodes are never encountered except as
diff --git a/lib/rexml/output.rb b/lib/rexml/output.rb
index 88a5fb378d..96dfea570e 100644
--- a/lib/rexml/output.rb
+++ b/lib/rexml/output.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'encoding'
+require 'rexml/encoding'
module REXML
class Output
diff --git a/lib/rexml/parent.rb b/lib/rexml/parent.rb
index 6a53b37a12..3bd0a96255 100644
--- a/lib/rexml/parent.rb
+++ b/lib/rexml/parent.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "child"
+require "rexml/child"
module REXML
# A parent has children, and has methods for accessing them. The Parent
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
index 305b120795..80eeb0fa79 100644
--- a/lib/rexml/parsers/baseparser.rb
+++ b/lib/rexml/parsers/baseparser.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: false
-require_relative '../parseexception'
-require_relative '../undefinednamespaceexception'
-require_relative '../source'
+require 'rexml/parseexception'
+require 'rexml/undefinednamespaceexception'
+require 'rexml/source'
require 'set'
-require "strscan"
module REXML
module Parsers
@@ -33,12 +32,8 @@ module REXML
COMBININGCHAR = '' # TODO
EXTENDER = '' # TODO
- NCNAME_STR= "[#{LETTER}_][-[:alnum:]._#{COMBININGCHAR}#{EXTENDER}]*"
- QNAME_STR= "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})"
- QNAME = /(#{QNAME_STR})/
-
- # Just for backward compatibility. For example, kramdown uses this.
- # It's not used in REXML.
+ NCNAME_STR= "[#{LETTER}_:][-[:alnum:]._:#{COMBININGCHAR}#{EXTENDER}]*"
+ NAME_STR= "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})"
UNAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}"
NAMECHAR = '[\-\w\.:]'
@@ -50,7 +45,8 @@ module REXML
DOCTYPE_START = /\A\s*<!DOCTYPE\s/um
DOCTYPE_END = /\A\s*\]\s*>/um
- ATTRIBUTE_PATTERN = /\s*(#{QNAME_STR})\s*=\s*(["'])(.*?)\4/um
+ DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/um
+ ATTRIBUTE_PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\4/um
COMMENT_START = /\A<!--/u
COMMENT_PATTERN = /<!--(.*?)-->/um
CDATA_START = /\A<!\[CDATA\[/u
@@ -59,15 +55,16 @@ module REXML
XMLDECL_START = /\A<\?xml\s/u;
XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>/um
INSTRUCTION_START = /\A<\?/u
- INSTRUCTION_PATTERN = /<\?#{NAME}(\s+.*?)?\?>/um
- TAG_MATCH = /\A<((?>#{QNAME_STR}))/um
- CLOSE_MATCH = /\A\s*<\/(#{QNAME_STR})\s*>/um
+ INSTRUCTION_PATTERN = /<\?(.*?)(\s+.*?)?\?>/um
+ TAG_MATCH = /^<((?>#{NAME_STR}))\s*((?>\s+#{UNAME_STR}\s*=\s*(["']).*?\5)*)\s*(\/)?>/um
+ CLOSE_MATCH = /^\s*<\/(#{NAME_STR})\s*>/um
VERSION = /\bversion\s*=\s*["'](.*?)['"]/um
ENCODING = /\bencoding\s*=\s*["'](.*?)['"]/um
STANDALONE = /\bstandalone\s*=\s*["'](.*?)['"]/um
ENTITY_START = /\A\s*<!ENTITY/
+ IDENTITY = /^([!\*\w\-]+)(\s+#{NCNAME_STR})?(\s+["'](.*?)['"])?(\s+['"](.*?)["'])?/u
ELEMENTDECL_START = /\A\s*<!ELEMENT/um
ELEMENTDECL_PATTERN = /\A\s*(<!ELEMENT.*?)>/um
SYSTEMENTITY = /\A\s*(%.*?;)\s*$/um
@@ -81,6 +78,9 @@ module REXML
ATTDEF_RE = /#{ATTDEF}/
ATTLISTDECL_START = /\A\s*<!ATTLIST/um
ATTLISTDECL_PATTERN = /\A\s*<!ATTLIST\s+#{NAME}(?:#{ATTDEF})*\s*>/um
+ NOTATIONDECL_START = /\A\s*<!NOTATION/um
+ PUBLIC = /\A\s*<!NOTATION\s+(\w[\-\w]*)\s+(PUBLIC)\s+(["'])(.*?)\3(?:\s+(["'])(.*?)\5)?\s*>/um
+ SYSTEM = /\A\s*<!NOTATION\s+(\w[\-\w]*)\s+(SYSTEM)\s+(["'])(.*?)\3\s*>/um
TEXT_PATTERN = /\A([^<]*)/um
@@ -98,11 +98,6 @@ module REXML
GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>"
ENTITYDECL = /\s*(?:#{GEDECL})|(?:#{PEDECL})/um
- NOTATIONDECL_START = /\A\s*<!NOTATION/um
- EXTERNAL_ID_PUBLIC = /\A\s*PUBLIC\s+#{PUBIDLITERAL}\s+#{SYSTEMLITERAL}\s*/um
- EXTERNAL_ID_SYSTEM = /\A\s*SYSTEM\s+#{SYSTEMLITERAL}\s*/um
- PUBLIC_ID = /\A\s*PUBLIC\s+#{PUBIDLITERAL}\s*/um
-
EREFERENCE = /&(?!#{NAME};)/
DEFAULT_ENTITIES = {
@@ -112,6 +107,13 @@ module REXML
"apos" => [/&apos;/, "&apos;", "'", /'/]
}
+
+ ######################################################################
+ # These are patterns to identify common markup errors, to make the
+ # error messages more informative.
+ ######################################################################
+ MISSING_ATTRIBUTE_QUOTES = /^<#{NAME_STR}\s+#{NAME_STR}\s*=\s*[^"']/um
+
def initialize( source )
self.stream = source
@listeners = []
@@ -195,9 +197,11 @@ module REXML
return [ :end_document ] if empty?
return @stack.shift if @stack.size > 0
#STDERR.puts @source.encoding
+ @source.read if @source.buffer.size<2
#STDERR.puts "BUFFER = #{@source.buffer.inspect}"
if @document_status == nil
- word = @source.match( /\A((?:\s+)|(?:<[^>]*>))/um )
+ #@source.consume( /^\s*/um )
+ word = @source.match( /^((?:\s+)|(?:<[^>]*>))/um )
word = word[1] unless word.nil?
#STDERR.puts "WORD = #{word.inspect}"
case word
@@ -220,51 +224,40 @@ module REXML
standalone = standalone[1] unless standalone.nil?
return [ :xmldecl, version, encoding, standalone ]
when INSTRUCTION_START
- return process_instruction
+ return [ :processing_instruction, *@source.match(INSTRUCTION_PATTERN, true)[1,2] ]
when DOCTYPE_START
- base_error_message = "Malformed DOCTYPE"
- @source.match(DOCTYPE_START, true)
+ md = @source.match( DOCTYPE_PATTERN, true )
@nsstack.unshift(curr_ns=Set.new)
- name = parse_name(base_error_message)
- if @source.match(/\A\s*\[/um, true)
- id = [nil, nil, nil]
- @document_status = :in_doctype
- elsif @source.match(/\A\s*>/um, true)
- id = [nil, nil, nil]
+ identity = md[1]
+ close = md[2]
+ identity =~ IDENTITY
+ name = $1
+ raise REXML::ParseException.new("DOCTYPE is missing a name") if name.nil?
+ pub_sys = $2.nil? ? nil : $2.strip
+ long_name = $4.nil? ? nil : $4.strip
+ uri = $6.nil? ? nil : $6.strip
+ args = [ :start_doctype, name, pub_sys, long_name, uri ]
+ if close == ">"
@document_status = :after_doctype
- else
- id = parse_id(base_error_message,
- accept_external_id: true,
- accept_public_id: false)
- if id[0] == "SYSTEM"
- # For backward compatibility
- id[1], id[2] = id[2], nil
- end
- if @source.match(/\A\s*\[/um, true)
- @document_status = :in_doctype
- elsif @source.match(/\A\s*>/um, true)
- @document_status = :after_doctype
- else
- message = "#{base_error_message}: garbage after external ID"
- raise REXML::ParseException.new(message, @source)
- end
- end
- args = [:start_doctype, name, *id]
- if @document_status == :after_doctype
- @source.match(/\A\s*/um, true)
+ @source.read if @source.buffer.size<2
+ md = @source.match(/^\s*/um, true)
@stack << [ :end_doctype ]
+ else
+ @document_status = :in_doctype
end
return args
- when /\A\s+/
+ when /^\s+/
else
@document_status = :after_doctype
+ @source.read if @source.buffer.size<2
+ md = @source.match(/\s*/um, true)
if @source.encoding == "UTF-8"
@source.buffer.force_encoding(::Encoding::UTF_8)
end
end
end
if @document_status == :in_doctype
- md = @source.match(/\A\s*(.*?>)/um)
+ md = @source.match(/\s*(.*?>)/um)
case md[1]
when SYSTEMENTITY
match = @source.match( SYSTEMENTITY, true )[1]
@@ -321,49 +314,33 @@ module REXML
end
return [ :attlistdecl, element, pairs, contents ]
when NOTATIONDECL_START
- base_error_message = "Malformed notation declaration"
- unless @source.match(/\A\s*<!NOTATION\s+/um, true)
- if @source.match(/\A\s*<!NOTATION\s*>/um)
- message = "#{base_error_message}: name is missing"
- else
- message = "#{base_error_message}: invalid declaration name"
- end
- raise REXML::ParseException.new(message, @source)
- end
- name = parse_name(base_error_message)
- id = parse_id(base_error_message,
- accept_external_id: true,
- accept_public_id: true)
- unless @source.match(/\A\s*>/um, true)
- message = "#{base_error_message}: garbage before end >"
- raise REXML::ParseException.new(message, @source)
+ md = nil
+ if @source.match( PUBLIC )
+ md = @source.match( PUBLIC, true )
+ vals = [md[1],md[2],md[4],md[6]]
+ elsif @source.match( SYSTEM )
+ md = @source.match( SYSTEM, true )
+ vals = [md[1],md[2],nil,md[4]]
+ else
+ raise REXML::ParseException.new( "error parsing notation: no matching pattern", @source )
end
- return [:notationdecl, name, *id]
+ return [ :notationdecl, *vals ]
when DOCTYPE_END
@document_status = :after_doctype
@source.match( DOCTYPE_END, true )
return [ :end_doctype ]
end
end
- if @document_status == :after_doctype
- @source.match(/\A\s*/um, true)
- end
begin
- @source.read if @source.buffer.size<2
if @source.buffer[0] == ?<
if @source.buffer[1] == ?/
@nsstack.shift
last_tag = @tags.pop
+ #md = @source.match_to_consume( '>', CLOSE_MATCH)
md = @source.match( CLOSE_MATCH, true )
- if md and !last_tag
- message = "Unexpected top-level end tag (got '#{md[1]}')"
- raise REXML::ParseException.new(message, @source)
- end
- if md.nil? or last_tag != md[1]
- message = "Missing end tag for '#{last_tag}'"
- message << " (got '#{md[1]}')" if md
- raise REXML::ParseException.new(message, @source)
- end
+ raise REXML::ParseException.new( "Missing end tag for "+
+ "'#{last_tag}' (got \"#{md[1]}\")",
+ @source) unless last_tag == md[1]
return [ :end_element, last_tag ]
elsif @source.buffer[1] == ?!
md = @source.match(/\A(\s*[^>]*>)/um)
@@ -385,18 +362,52 @@ module REXML
raise REXML::ParseException.new( "Declarations can only occur "+
"in the doctype declaration.", @source)
elsif @source.buffer[1] == ??
- return process_instruction
+ md = @source.match( INSTRUCTION_PATTERN, true )
+ return [ :processing_instruction, md[1], md[2] ] if md
+ raise REXML::ParseException.new( "Bad instruction declaration",
+ @source)
else
# Get the next tag
md = @source.match(TAG_MATCH, true)
unless md
+ # Check for missing attribute quotes
+ raise REXML::ParseException.new("missing attribute quote", @source) if @source.match(MISSING_ATTRIBUTE_QUOTES )
raise REXML::ParseException.new("malformed XML: missing tag start", @source)
end
- @document_status = :in_element
+ attributes = {}
prefixes = Set.new
prefixes << md[2] if md[2]
@nsstack.unshift(curr_ns=Set.new)
- attributes, closed = parse_attributes(prefixes, curr_ns)
+ if md[4].size > 0
+ attrs = md[4].scan( ATTRIBUTE_PATTERN )
+ raise REXML::ParseException.new( "error parsing attributes: [#{attrs.join ', '}], excess = \"#$'\"", @source) if $' and $'.strip.size > 0
+ attrs.each do |attr_name, prefix, local_part, quote, value|
+ if prefix == "xmlns"
+ if local_part == "xml"
+ if value != "http://www.w3.org/XML/1998/namespace"
+ msg = "The 'xml' prefix must not be bound to any other namespace "+
+ "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
+ raise REXML::ParseException.new( msg, @source, self )
+ end
+ elsif local_part == "xmlns"
+ msg = "The 'xmlns' prefix must not be declared "+
+ "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
+ raise REXML::ParseException.new( msg, @source, self)
+ end
+ curr_ns << local_part
+ elsif prefix
+ prefixes << prefix unless prefix == "xml"
+ end
+
+ if attributes.has_key?(attr_name)
+ msg = "Duplicate attribute #{attr_name.inspect}"
+ raise REXML::ParseException.new(msg, @source, self)
+ end
+
+ attributes[attr_name] = value
+ end
+ end
+
# Verify that all of the prefixes have been defined
for prefix in prefixes
unless @nsstack.find{|k| k.member?(prefix)}
@@ -404,7 +415,7 @@ module REXML
end
end
- if closed
+ if md[6]
@closed = md[1]
@nsstack.shift
else
@@ -427,7 +438,7 @@ module REXML
raise
rescue REXML::ParseException
raise
- rescue => error
+ rescue Exception, NameError => error
raise REXML::ParseException.new( "Exception parsing",
@source, self, (error ? error : $!) )
end
@@ -497,178 +508,6 @@ module REXML
return false if /\AUTF-16\z/i =~ xml_declaration_encoding
true
end
-
- def parse_name(base_error_message)
- md = @source.match(/\A\s*#{NAME}/um, true)
- unless md
- if @source.match(/\A\s*\S/um)
- message = "#{base_error_message}: invalid name"
- else
- message = "#{base_error_message}: name is missing"
- end
- raise REXML::ParseException.new(message, @source)
- end
- md[1]
- end
-
- def parse_id(base_error_message,
- accept_external_id:,
- accept_public_id:)
- if accept_external_id and (md = @source.match(EXTERNAL_ID_PUBLIC, true))
- pubid = system = nil
- pubid_literal = md[1]
- pubid = pubid_literal[1..-2] if pubid_literal # Remove quote
- system_literal = md[2]
- system = system_literal[1..-2] if system_literal # Remove quote
- ["PUBLIC", pubid, system]
- elsif accept_public_id and (md = @source.match(PUBLIC_ID, true))
- pubid = system = nil
- pubid_literal = md[1]
- pubid = pubid_literal[1..-2] if pubid_literal # Remove quote
- ["PUBLIC", pubid, nil]
- elsif accept_external_id and (md = @source.match(EXTERNAL_ID_SYSTEM, true))
- system = nil
- system_literal = md[1]
- system = system_literal[1..-2] if system_literal # Remove quote
- ["SYSTEM", nil, system]
- else
- details = parse_id_invalid_details(accept_external_id: accept_external_id,
- accept_public_id: accept_public_id)
- message = "#{base_error_message}: #{details}"
- raise REXML::ParseException.new(message, @source)
- end
- end
-
- def parse_id_invalid_details(accept_external_id:,
- accept_public_id:)
- public = /\A\s*PUBLIC/um
- system = /\A\s*SYSTEM/um
- if (accept_external_id or accept_public_id) and @source.match(/#{public}/um)
- if @source.match(/#{public}(?:\s+[^'"]|\s*[\[>])/um)
- return "public ID literal is missing"
- end
- unless @source.match(/#{public}\s+#{PUBIDLITERAL}/um)
- return "invalid public ID literal"
- end
- if accept_public_id
- if @source.match(/#{public}\s+#{PUBIDLITERAL}\s+[^'"]/um)
- return "system ID literal is missing"
- end
- unless @source.match(/#{public}\s+#{PUBIDLITERAL}\s+#{SYSTEMLITERAL}/um)
- return "invalid system literal"
- end
- "garbage after system literal"
- else
- "garbage after public ID literal"
- end
- elsif accept_external_id and @source.match(/#{system}/um)
- if @source.match(/#{system}(?:\s+[^'"]|\s*[\[>])/um)
- return "system literal is missing"
- end
- unless @source.match(/#{system}\s+#{SYSTEMLITERAL}/um)
- return "invalid system literal"
- end
- "garbage after system literal"
- else
- unless @source.match(/\A\s*(?:PUBLIC|SYSTEM)\s/um)
- return "invalid ID type"
- end
- "ID type is missing"
- end
- end
-
- def process_instruction
- match_data = @source.match(INSTRUCTION_PATTERN, true)
- unless match_data
- message = "Invalid processing instruction node"
- raise REXML::ParseException.new(message, @source)
- end
- [:processing_instruction, match_data[1], match_data[2]]
- end
-
- def parse_attributes(prefixes, curr_ns)
- attributes = {}
- closed = false
- match_data = @source.match(/^(.*?)(\/)?>/um, true)
- if match_data.nil?
- message = "Start tag isn't ended"
- raise REXML::ParseException.new(message, @source)
- end
-
- raw_attributes = match_data[1]
- closed = !match_data[2].nil?
- return attributes, closed if raw_attributes.nil?
- return attributes, closed if raw_attributes.empty?
-
- scanner = StringScanner.new(raw_attributes)
- until scanner.eos?
- if scanner.scan(/\s+/)
- break if scanner.eos?
- end
-
- pos = scanner.pos
- loop do
- break if scanner.scan(ATTRIBUTE_PATTERN)
- unless scanner.scan(QNAME)
- message = "Invalid attribute name: <#{scanner.rest}>"
- raise REXML::ParseException.new(message, @source)
- end
- name = scanner[0]
- unless scanner.scan(/\s*=\s*/um)
- message = "Missing attribute equal: <#{name}>"
- raise REXML::ParseException.new(message, @source)
- end
- quote = scanner.scan(/['"]/)
- unless quote
- message = "Missing attribute value start quote: <#{name}>"
- raise REXML::ParseException.new(message, @source)
- end
- unless scanner.scan(/.*#{Regexp.escape(quote)}/um)
- match_data = @source.match(/^(.*?)(\/)?>/um, true)
- if match_data
- scanner << "/" if closed
- scanner << ">"
- scanner << match_data[1]
- scanner.pos = pos
- closed = !match_data[2].nil?
- next
- end
- message =
- "Missing attribute value end quote: <#{name}>: <#{quote}>"
- raise REXML::ParseException.new(message, @source)
- end
- end
- name = scanner[1]
- prefix = scanner[2]
- local_part = scanner[3]
- # quote = scanner[4]
- value = scanner[5]
- if prefix == "xmlns"
- if local_part == "xml"
- if value != "http://www.w3.org/XML/1998/namespace"
- msg = "The 'xml' prefix must not be bound to any other namespace "+
- "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
- raise REXML::ParseException.new( msg, @source, self )
- end
- elsif local_part == "xmlns"
- msg = "The 'xmlns' prefix must not be declared "+
- "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
- raise REXML::ParseException.new( msg, @source, self)
- end
- curr_ns << local_part
- elsif prefix
- prefixes << prefix unless prefix == "xml"
- end
-
- if attributes.has_key?(name)
- msg = "Duplicate attribute #{name.inspect}"
- raise REXML::ParseException.new(msg, @source, self)
- end
-
- attributes[name] = value
- end
- return attributes, closed
- end
end
end
end
diff --git a/lib/rexml/parsers/lightparser.rb b/lib/rexml/parsers/lightparser.rb
index bdc08276a9..f0601ae51b 100644
--- a/lib/rexml/parsers/lightparser.rb
+++ b/lib/rexml/parsers/lightparser.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative 'streamparser'
-require_relative 'baseparser'
-require_relative '../light/node'
+require 'rexml/parsers/streamparser'
+require 'rexml/parsers/baseparser'
+require 'rexml/light/node'
module REXML
module Parsers
diff --git a/lib/rexml/parsers/pullparser.rb b/lib/rexml/parsers/pullparser.rb
index f8b232a2cd..8c49217553 100644
--- a/lib/rexml/parsers/pullparser.rb
+++ b/lib/rexml/parsers/pullparser.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: false
require 'forwardable'
-require_relative '../parseexception'
-require_relative 'baseparser'
-require_relative '../xmltokens'
+require 'rexml/parseexception'
+require 'rexml/parsers/baseparser'
+require 'rexml/xmltokens'
module REXML
module Parsers
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
index 6a24ce2227..1386f69c83 100644
--- a/lib/rexml/parsers/sax2parser.rb
+++ b/lib/rexml/parsers/sax2parser.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: false
-require_relative 'baseparser'
-require_relative '../parseexception'
-require_relative '../namespace'
-require_relative '../text'
+require 'rexml/parsers/baseparser'
+require 'rexml/parseexception'
+require 'rexml/namespace'
+require 'rexml/text'
module REXML
module Parsers
diff --git a/lib/rexml/parsers/streamparser.rb b/lib/rexml/parsers/streamparser.rb
index 9e0eb0b363..f6a8bfa802 100644
--- a/lib/rexml/parsers/streamparser.rb
+++ b/lib/rexml/parsers/streamparser.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "baseparser"
+require "rexml/parsers/baseparser"
module REXML
module Parsers
diff --git a/lib/rexml/parsers/treeparser.rb b/lib/rexml/parsers/treeparser.rb
index bf9a42545b..fc0993c72a 100644
--- a/lib/rexml/parsers/treeparser.rb
+++ b/lib/rexml/parsers/treeparser.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative '../validation/validationexception'
-require_relative '../undefinednamespaceexception'
+require 'rexml/validation/validationexception'
+require 'rexml/undefinednamespaceexception'
module REXML
module Parsers
diff --git a/lib/rexml/parsers/ultralightparser.rb b/lib/rexml/parsers/ultralightparser.rb
index e0029f43da..6571d119bd 100644
--- a/lib/rexml/parsers/ultralightparser.rb
+++ b/lib/rexml/parsers/ultralightparser.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative 'streamparser'
-require_relative 'baseparser'
+require 'rexml/parsers/streamparser'
+require 'rexml/parsers/baseparser'
module REXML
module Parsers
diff --git a/lib/rexml/parsers/xpathparser.rb b/lib/rexml/parsers/xpathparser.rb
index d01d325e04..32b70bb798 100644
--- a/lib/rexml/parsers/xpathparser.rb
+++ b/lib/rexml/parsers/xpathparser.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative '../namespace'
-require_relative '../xmltokens'
+require 'rexml/namespace'
+require 'rexml/xmltokens'
module REXML
module Parsers
@@ -185,7 +185,7 @@ module REXML
# | '/' RelativeLocationPath?
# | '//' RelativeLocationPath
def LocationPath path, parsed
- path = path.lstrip
+ path = path.strip
if path[0] == ?/
parsed << :document
if path[1] == ?/
@@ -209,12 +209,7 @@ module REXML
# | RelativeLocationPath '//' Step
AXIS = /^(ancestor|ancestor-or-self|attribute|child|descendant|descendant-or-self|following|following-sibling|namespace|parent|preceding|preceding-sibling|self)::/
def RelativeLocationPath path, parsed
- loop do
- original_path = path
- path = path.lstrip
-
- return original_path if path.empty?
-
+ while path.size > 0
# (axis or @ or <child::>) nodetest predicate >
# OR > / Step
# (. or ..) >
@@ -244,25 +239,28 @@ module REXML
n = []
path = NodeTest( path, n)
- path = Predicate( path, n )
+ if path[0] == ?[
+ path = Predicate( path, n )
+ end
parsed.concat(n)
end
- original_path = path
- path = path.lstrip
- return original_path if path.empty?
-
- return original_path if path[0] != ?/
-
- if path[1] == ?/
- parsed << :descendant_or_self
- parsed << :node
- path = path[2..-1]
- else
- path = path[1..-1]
+ if path.size > 0
+ if path[0] == ?/
+ if path[1] == ?/
+ parsed << :descendant_or_self
+ parsed << :node
+ path = path[2..-1]
+ else
+ path = path[1..-1]
+ end
+ else
+ return path
+ end
end
end
+ return path
end
# Returns a 1-1 map of the nodeset
@@ -271,26 +269,15 @@ module REXML
# String, if a name match
#NodeTest
# | ('*' | NCNAME ':' '*' | QNAME) NameTest
- # | '*' ':' NCNAME NameTest since XPath 2.0
- # | NODE_TYPE '(' ')' NodeType
+ # | NODE_TYPE '(' ')' NodeType
# | PI '(' LITERAL ')' PI
# | '[' expr ']' Predicate
- PREFIX_WILDCARD = /^\*:(#{NCNAME_STR})/u
- LOCAL_NAME_WILDCARD = /^(#{NCNAME_STR}):\*/u
+ NCNAMETEST= /^(#{NCNAME_STR}):\*/u
QNAME = Namespace::NAMESPLIT
NODE_TYPE = /^(comment|text|node)\(\s*\)/m
PI = /^processing-instruction\(/
def NodeTest path, parsed
- original_path = path
- path = path.lstrip
case path
- when PREFIX_WILDCARD
- prefix = nil
- name = $1
- path = $'
- parsed << :qname
- parsed << prefix
- parsed << name
when /^\*/
path = $'
parsed << :any
@@ -310,7 +297,7 @@ module REXML
end
parsed << :processing_instruction
parsed << (literal || '')
- when LOCAL_NAME_WILDCARD
+ when NCNAMETEST
prefix = $1
path = $'
parsed << :namespace
@@ -323,17 +310,13 @@ module REXML
parsed << :qname
parsed << prefix
parsed << name
- else
- path = original_path
end
return path
end
# Filters the supplied nodeset on the predicate(s)
def Predicate path, parsed
- original_path = path
- path = path.lstrip
- return original_path unless path[0] == ?[
+ return nil unless path[0] == ?[
predicates = []
while path[0] == ?[
path, expr = get_group(path)
@@ -438,13 +421,13 @@ module REXML
rest
end
- #| AdditiveExpr ('+' | '-') MultiplicativeExpr
+ #| AdditiveExpr ('+' | S '-') MultiplicativeExpr
#| MultiplicativeExpr
def AdditiveExpr path, parsed
n = []
rest = MultiplicativeExpr( path, n )
if rest != path
- while rest =~ /^\s*(\+|-)\s*/
+ while rest =~ /^\s*(\+| -)\s*/
if $1[0] == ?+
n = [ :plus, n, [] ]
else
@@ -526,14 +509,13 @@ module REXML
#| LocationPath
#| FilterExpr ('/' | '//') RelativeLocationPath
def PathExpr path, parsed
- path = path.lstrip
+ path =~ /^\s*/
+ path = $'
n = []
rest = FilterExpr( path, n )
if rest != path
if rest and rest[0] == ?/
- rest = RelativeLocationPath(rest, n)
- parsed.concat(n)
- return rest
+ return RelativeLocationPath(rest, n)
end
end
rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w*]/
@@ -546,7 +528,7 @@ module REXML
def FilterExpr path, parsed
n = []
path = PrimaryExpr( path, n )
- path = Predicate(path, n)
+ path = Predicate(path, n) if path and path[0] == ?[
parsed.concat(n)
path
end
diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb
index a0466b25d9..5d6c77ca38 100644
--- a/lib/rexml/quickpath.rb
+++ b/lib/rexml/quickpath.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative 'functions'
-require_relative 'xmltokens'
+require 'rexml/functions'
+require 'rexml/xmltokens'
module REXML
class QuickPath
diff --git a/lib/rexml/rexml.gemspec b/lib/rexml/rexml.gemspec
deleted file mode 100644
index 263f013aae..0000000000
--- a/lib/rexml/rexml.gemspec
+++ /dev/null
@@ -1,84 +0,0 @@
-begin
- require_relative "lib/rexml/rexml"
-rescue LoadError
- # for Ruby core repository
- require_relative "rexml"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "rexml"
- spec.version = REXML::VERSION
- spec.authors = ["Kouhei Sutou"]
- spec.email = ["kou@cozmixng.org"]
-
- spec.summary = %q{An XML toolkit for Ruby}
- spec.description = %q{An XML toolkit for Ruby}
- spec.homepage = "https://github.com/ruby/rexml"
- spec.license = "BSD-2-Clause"
-
- spec.files = [
- ".gitignore",
- ".travis.yml",
- "Gemfile",
- "LICENSE.txt",
- "NEWS.md",
- "README.md",
- "Rakefile",
- "lib/rexml/attlistdecl.rb",
- "lib/rexml/attribute.rb",
- "lib/rexml/cdata.rb",
- "lib/rexml/child.rb",
- "lib/rexml/comment.rb",
- "lib/rexml/doctype.rb",
- "lib/rexml/document.rb",
- "lib/rexml/dtd/attlistdecl.rb",
- "lib/rexml/dtd/dtd.rb",
- "lib/rexml/dtd/elementdecl.rb",
- "lib/rexml/dtd/entitydecl.rb",
- "lib/rexml/dtd/notationdecl.rb",
- "lib/rexml/element.rb",
- "lib/rexml/encoding.rb",
- "lib/rexml/entity.rb",
- "lib/rexml/formatters/default.rb",
- "lib/rexml/formatters/pretty.rb",
- "lib/rexml/formatters/transitive.rb",
- "lib/rexml/functions.rb",
- "lib/rexml/instruction.rb",
- "lib/rexml/light/node.rb",
- "lib/rexml/namespace.rb",
- "lib/rexml/node.rb",
- "lib/rexml/output.rb",
- "lib/rexml/parent.rb",
- "lib/rexml/parseexception.rb",
- "lib/rexml/parsers/baseparser.rb",
- "lib/rexml/parsers/lightparser.rb",
- "lib/rexml/parsers/pullparser.rb",
- "lib/rexml/parsers/sax2parser.rb",
- "lib/rexml/parsers/streamparser.rb",
- "lib/rexml/parsers/treeparser.rb",
- "lib/rexml/parsers/ultralightparser.rb",
- "lib/rexml/parsers/xpathparser.rb",
- "lib/rexml/quickpath.rb",
- "lib/rexml/rexml.rb",
- "lib/rexml/sax2listener.rb",
- "lib/rexml/security.rb",
- "lib/rexml/source.rb",
- "lib/rexml/streamlistener.rb",
- "lib/rexml/text.rb",
- "lib/rexml/undefinednamespaceexception.rb",
- "lib/rexml/validation/relaxng.rb",
- "lib/rexml/validation/validation.rb",
- "lib/rexml/validation/validationexception.rb",
- "lib/rexml/xmldecl.rb",
- "lib/rexml/xmltokens.rb",
- "lib/rexml/xpath.rb",
- "lib/rexml/xpath_parser.rb",
- "rexml.gemspec",
- ]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
-end
diff --git a/lib/rexml/rexml.rb b/lib/rexml/rexml.rb
index 3c991a1cfd..fbc0d339d8 100644
--- a/lib/rexml/rexml.rb
+++ b/lib/rexml/rexml.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding: utf-8 -*-
# frozen_string_literal: false
# REXML is an XML toolkit for Ruby[http://www.ruby-lang.org], in Ruby.
#
@@ -24,8 +24,8 @@
module REXML
COPYRIGHT = "Copyright © 2001-2008 Sean Russell <ser@germane-software.com>"
DATE = "2008/019"
- VERSION = "3.2.3.1"
- REVISION = ""
+ VERSION = "3.1.7.3"
+ REVISION = %w$Revision$[1] || ''
Copyright = COPYRIGHT
Version = VERSION
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
index 90b370b989..af65cf4751 100644
--- a/lib/rexml/source.rb
+++ b/lib/rexml/source.rb
@@ -1,6 +1,6 @@
# coding: US-ASCII
# frozen_string_literal: false
-require_relative 'encoding'
+require 'rexml/encoding'
module REXML
# Generates Source-s. USE THIS CLASS.
@@ -200,7 +200,7 @@ module REXML
end
rv = super
end
- rv.taint if RUBY_VERSION < '2.7'
+ rv.taint
rv
end
@@ -228,7 +228,7 @@ module REXML
@source = nil
end
end
- rv.taint if RUBY_VERSION < '2.7'
+ rv.taint
rv
end
@@ -254,7 +254,6 @@ module REXML
end
rescue
end
- @er_source.seek(pos)
rescue IOError
pos = -1
line = -1
diff --git a/lib/rexml/syncenumerator.rb b/lib/rexml/syncenumerator.rb
new file mode 100644
index 0000000000..a9d2ad7f9c
--- /dev/null
+++ b/lib/rexml/syncenumerator.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: false
+module REXML
+ class SyncEnumerator
+ include Enumerable
+
+ # Creates a new SyncEnumerator which enumerates rows of given
+ # Enumerable objects.
+ def initialize(*enums)
+ @gens = enums
+ @length = @gens.collect {|x| x.size }.max
+ end
+
+ # Returns the number of enumerated Enumerable objects, i.e. the size
+ # of each row.
+ def size
+ @gens.size
+ end
+
+ # Returns the number of enumerated Enumerable objects, i.e. the size
+ # of each row.
+ def length
+ @gens.length
+ end
+
+ # Enumerates rows of the Enumerable objects.
+ def each
+ @length.times {|i|
+ yield @gens.collect {|x| x[i]}
+ }
+ self
+ end
+ end
+end
diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb
index 050b09c97e..86269dea1e 100644
--- a/lib/rexml/text.rb
+++ b/lib/rexml/text.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: false
-require_relative 'security'
-require_relative 'entity'
-require_relative 'doctype'
-require_relative 'child'
-require_relative 'doctype'
-require_relative 'parseexception'
+require 'rexml/security'
+require 'rexml/entity'
+require 'rexml/doctype'
+require 'rexml/child'
+require 'rexml/doctype'
+require 'rexml/parseexception'
module REXML
# Represents text nodes in an XML document
@@ -96,28 +96,27 @@ module REXML
@raw = false
@parent = nil
- @entity_filter = nil
if parent
super( parent )
@raw = parent.raw
end
+ @raw = raw unless raw.nil?
+ @entity_filter = entity_filter
+ clear_cache
+
if arg.kind_of? String
@string = arg.dup
+ @string.squeeze!(" \n\t") unless respect_whitespace
elsif arg.kind_of? Text
- @string = arg.instance_variable_get(:@string).dup
+ @string = arg.to_s
@raw = arg.raw
- @entity_filter = arg.instance_variable_get(:@entity_filter)
- else
+ elsif
raise "Illegal argument of type #{arg.type} for Text constructor (#{arg})"
end
- @string.squeeze!(" \n\t") unless respect_whitespace
- @string.gsub!(/\r\n?/, "\n")
- @raw = raw unless raw.nil?
- @entity_filter = entity_filter if entity_filter
- clear_cache
+ @string.gsub!( /\r\n?/, "\n" )
Text.check(@string, illegal, doctype) if @raw
end
@@ -137,7 +136,7 @@ module REXML
case c.ord
when *VALID_CHAR
else
- raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
+ raise "Illegal character #{c.inspect} in raw string \"#{string}\""
end
end
else
@@ -145,7 +144,7 @@ module REXML
case c.unpack('U')
when *VALID_CHAR
else
- raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
+ raise "Illegal character #{c.inspect} in raw string \"#{string}\""
end
end
end
@@ -154,13 +153,13 @@ module REXML
# context sensitive
string.scan(pattern) do
if $1[-1] != ?;
- raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
+ raise "Illegal character '#{$1}' in raw string \"#{string}\""
elsif $1[0] == ?&
if $5 and $5[0] == ?#
case ($5[1] == ?x ? $5[2..-1].to_i(16) : $5[1..-1].to_i)
when *VALID_CHAR
else
- raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
+ raise "Illegal character '#{$1}' in raw string \"#{string}\""
end
# FIXME: below can't work but this needs API change.
# elsif @parent and $3 and !SUBSTITUTES.include?($1)
@@ -182,7 +181,7 @@ module REXML
def clone
- return Text.new(self, true)
+ return Text.new(self)
end
@@ -227,7 +226,9 @@ module REXML
# u.to_s #-> "sean russell"
def to_s
return @string if @raw
- @normalized ||= Text::normalize( @string, doctype, @entity_filter )
+ return @normalized if @normalized
+
+ @normalized = Text::normalize( @string, doctype, @entity_filter )
end
def inspect
@@ -248,7 +249,8 @@ module REXML
# u = Text.new( "sean russell", false, nil, true )
# u.value #-> "sean russell"
def value
- @unnormalized ||= Text::unnormalize( @string, doctype )
+ return @unnormalized if @unnormalized
+ @unnormalized = Text::unnormalize( @string, doctype )
end
# Sets the contents of this text node. This expects the text to be
@@ -264,16 +266,16 @@ module REXML
@raw = false
end
- def wrap(string, width, addnewline=false)
- # Recursively wrap string at width.
- return string if string.length <= width
- place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
- if addnewline then
- return "\n" + string[0,place] + "\n" + wrap(string[place+1..-1], width)
- else
- return string[0,place] + "\n" + wrap(string[place+1..-1], width)
- end
- end
+ def wrap(string, width, addnewline=false)
+ # Recursively wrap string at width.
+ return string if string.length <= width
+ place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
+ if addnewline then
+ return "\n" + string[0,place] + "\n" + wrap(string[place+1..-1], width)
+ else
+ return string[0,place] + "\n" + wrap(string[place+1..-1], width)
+ end
+ end
def indent_text(string, level=1, style="\t", indentfirstline=true)
return string if level < 0
diff --git a/lib/rexml/undefinednamespaceexception.rb b/lib/rexml/undefinednamespaceexception.rb
index 492a098183..e522ed57ea 100644
--- a/lib/rexml/undefinednamespaceexception.rb
+++ b/lib/rexml/undefinednamespaceexception.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'parseexception'
+require 'rexml/parseexception'
module REXML
class UndefinedNamespaceException < ParseException
def initialize( prefix, source, parser )
diff --git a/lib/rexml/validation/relaxng.rb b/lib/rexml/validation/relaxng.rb
index f29a2c05e5..fb52438290 100644
--- a/lib/rexml/validation/relaxng.rb
+++ b/lib/rexml/validation/relaxng.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative "validation"
-require_relative "../parsers/baseparser"
+require "rexml/validation/validation"
+require "rexml/parsers/baseparser"
module REXML
module Validation
diff --git a/lib/rexml/validation/validation.rb b/lib/rexml/validation/validation.rb
index 0ad6ada427..f0c76f976c 100644
--- a/lib/rexml/validation/validation.rb
+++ b/lib/rexml/validation/validation.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'validationexception'
+require 'rexml/validation/validationexception'
module REXML
module Validation
diff --git a/lib/rexml/xmldecl.rb b/lib/rexml/xmldecl.rb
index d19407cefd..a37e9f3ddc 100644
--- a/lib/rexml/xmldecl.rb
+++ b/lib/rexml/xmldecl.rb
@@ -1,18 +1,17 @@
# frozen_string_literal: false
-
-require_relative 'encoding'
-require_relative 'source'
+require 'rexml/encoding'
+require 'rexml/source'
module REXML
# NEEDS DOCUMENTATION
class XMLDecl < Child
include Encoding
- DEFAULT_VERSION = "1.0"
- DEFAULT_ENCODING = "UTF-8"
- DEFAULT_STANDALONE = "no"
- START = "<?xml"
- STOP = "?>"
+ DEFAULT_VERSION = "1.0";
+ DEFAULT_ENCODING = "UTF-8";
+ DEFAULT_STANDALONE = "no";
+ START = '<\?xml';
+ STOP = '\?>';
attr_accessor :version, :standalone
attr_reader :writeencoding, :writethis
@@ -26,7 +25,6 @@ module REXML
self.encoding = version.encoding
@writeencoding = version.writeencoding
@standalone = version.standalone
- @writethis = version.writethis
else
super()
@version = version
@@ -48,9 +46,9 @@ module REXML
# Ignored
def write(writer, indent=-1, transitive=false, ie_hack=false)
return nil unless @writethis or writer.kind_of? Output
- writer << START
+ writer << START.sub(/\\/u, '')
writer << " #{content encoding}"
- writer << STOP
+ writer << STOP.sub(/\\/u, '')
end
def ==( other )
@@ -104,26 +102,14 @@ module REXML
end
def inspect
- "#{START} ... #{STOP}"
+ START.sub(/\\/u, '') + " ... " + STOP.sub(/\\/u, '')
end
private
def content(enc)
- context = nil
- context = parent.context if parent
- if context and context[:prologue_quote] == :quote
- quote = "\""
- else
- quote = "'"
- end
-
- rv = "version=#{quote}#{@version}#{quote}"
- if @writeencoding or enc !~ /\Autf-8\z/i
- rv << " encoding=#{quote}#{enc}#{quote}"
- end
- if @standalone
- rv << " standalone=#{quote}#{@standalone}#{quote}"
- end
+ rv = "version='#@version'"
+ rv << " encoding='#{enc}'" if @writeencoding || enc !~ /\Autf-8\z/i
+ rv << " standalone='#@standalone'" if @standalone
rv
end
end
diff --git a/lib/rexml/xpath.rb b/lib/rexml/xpath.rb
index a0921bd8e1..f1cb99baea 100644
--- a/lib/rexml/xpath.rb
+++ b/lib/rexml/xpath.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative 'functions'
-require_relative 'xpath_parser'
+require 'rexml/functions'
+require 'rexml/xpath_parser'
module REXML
# Wrapper class. Use this class to access the XPath functions.
@@ -28,10 +28,10 @@ module REXML
# XPath.first( doc, "//b"} )
# XPath.first( node, "a/x:b", { "x"=>"http://doofus" } )
# XPath.first( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"})
- def XPath::first(element, path=nil, namespaces=nil, variables={}, options={})
+ def XPath::first element, path=nil, namespaces=nil, variables={}
raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
- parser = XPathParser.new(**options)
+ parser = XPathParser.new
parser.namespaces = namespaces
parser.variables = variables
path = "*" unless path
@@ -57,10 +57,10 @@ module REXML
# XPath.each( node, 'ancestor::x' ) { |el| ... }
# XPath.each( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"}) \
# {|el| ... }
- def XPath::each(element, path=nil, namespaces=nil, variables={}, options={}, &block)
+ def XPath::each element, path=nil, namespaces=nil, variables={}, &block
raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
- parser = XPathParser.new(**options)
+ parser = XPathParser.new
parser.namespaces = namespaces
parser.variables = variables
path = "*" unless path
@@ -69,8 +69,8 @@ module REXML
end
# Returns an array of nodes matching a given XPath.
- def XPath::match(element, path=nil, namespaces=nil, variables={}, options={})
- parser = XPathParser.new(**options)
+ def XPath::match element, path=nil, namespaces=nil, variables={}
+ parser = XPathParser.new
parser.namespaces = namespaces
parser.variables = variables
path = "*" unless path
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index b989725403..181b2b6e85 100644
--- a/lib/rexml/xpath_parser.rb
+++ b/lib/rexml/xpath_parser.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: false
-
-require "pp"
-
-require_relative 'namespace'
-require_relative 'xmltokens'
-require_relative 'attribute'
-require_relative 'parsers/xpathparser'
+require 'rexml/namespace'
+require 'rexml/xmltokens'
+require 'rexml/attribute'
+require 'rexml/syncenumerator'
+require 'rexml/parsers/xpathparser'
class Object
# provides a unified +clone+ operation, for REXML::XPathParser
@@ -49,15 +47,10 @@ module REXML
include XMLTokens
LITERAL = /^'([^']*)'|^"([^"]*)"/u
- DEBUG = (ENV["REXML_XPATH_PARSER_DEBUG"] == "true")
-
- def initialize(strict: false)
- @debug = DEBUG
+ def initialize( )
@parser = REXML::Parsers::XPathParser.new
@namespaces = nil
@variables = {}
- @nest = 0
- @strict = strict
end
def namespaces=( namespaces={} )
@@ -82,7 +75,7 @@ module REXML
def predicate path, nodeset
path_stack = @parser.parse( path )
- match( path_stack, nodeset )
+ expr( path_stack, nodeset )
end
def []=( variable_name, value )
@@ -130,24 +123,13 @@ module REXML
end
- def match(path_stack, nodeset)
- nodeset = nodeset.collect.with_index do |node, i|
- position = i + 1
- XPathNode.new(node, position: position)
- end
- result = expr(path_stack, nodeset)
- case result
- when Array # nodeset
- unnode(result)
- else
- [result]
- end
+ def match( path_stack, nodeset )
+ r = expr( path_stack, nodeset )
+ r
end
private
- def strict?
- @strict
- end
+
# Returns a String namespace for a node, given a prefix
# The rules are:
@@ -166,477 +148,343 @@ module REXML
# Expr takes a stack of path elements and a set of nodes (either a Parent
# or an Array and returns an Array of matching nodes
+ ALL = [ :attribute, :element, :text, :processing_instruction, :comment ]
+ ELEMENTS = [ :element ]
def expr( path_stack, nodeset, context=nil )
- enter(:expr, path_stack, nodeset) if @debug
+ node_types = ELEMENTS
return nodeset if path_stack.length == 0 || nodeset.length == 0
while path_stack.length > 0
- trace(:while, path_stack, nodeset) if @debug
if nodeset.length == 0
path_stack.clear
return []
end
- op = path_stack.shift
- case op
+ case (op = path_stack.shift)
when :document
- first_raw_node = nodeset.first.raw_node
- nodeset = [XPathNode.new(first_raw_node.root_node, position: 1)]
+ nodeset = [ nodeset[0].root_node ]
+
+ when :qname
+ prefix = path_stack.shift
+ name = path_stack.shift
+ nodeset.delete_if do |node|
+ # FIXME: This DOUBLES the time XPath searches take
+ ns = get_namespace( node, prefix )
+ if node.node_type == :element
+ if node.name == name
+ end
+ end
+ !(node.node_type == :element and
+ node.name == name and
+ node.namespace == ns )
+ end
+ node_types = ELEMENTS
+
+ when :any
+ nodeset.delete_if { |node| !node_types.include?(node.node_type) }
+
when :self
- nodeset = step(path_stack) do
- [nodeset]
+ # This space left intentionally blank
+
+ when :processing_instruction
+ target = path_stack.shift
+ nodeset.delete_if do |node|
+ (node.node_type != :processing_instruction) or
+ ( target!='' and ( node.target != target ) )
end
+
+ when :text
+ nodeset.delete_if { |node| node.node_type != :text }
+
+ when :comment
+ nodeset.delete_if { |node| node.node_type != :comment }
+
+ when :node
+ # This space left intentionally blank
+ node_types = ALL
+
when :child
- nodeset = step(path_stack) do
- child(nodeset)
+ new_nodeset = []
+ nt = nil
+ nodeset.each do |node|
+ nt = node.node_type
+ new_nodeset += node.children if nt == :element or nt == :document
end
+ nodeset = new_nodeset
+ node_types = ELEMENTS
+
when :literal
- trace(:literal, path_stack, nodeset) if @debug
return path_stack.shift
+
when :attribute
- nodeset = step(path_stack, any_type: :attribute) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.node_type == :element
- attributes = raw_node.attributes
- next if attributes.empty?
- nodesets << attributes.each_attribute.collect.with_index do |attribute, i|
- XPathNode.new(attribute, position: i + 1)
+ new_nodeset = []
+ case path_stack.shift
+ when :qname
+ prefix = path_stack.shift
+ name = path_stack.shift
+ for element in nodeset
+ if element.node_type == :element
+ attrib = element.attribute( name, get_namespace(element, prefix) )
+ new_nodeset << attrib if attrib
end
end
- nodesets
- end
- when :namespace
- pre_defined_namespaces = {
- "xml" => "http://www.w3.org/XML/1998/namespace",
- }
- nodeset = step(path_stack, any_type: :namespace) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- case raw_node.node_type
- when :element
- if @namespaces
- nodesets << pre_defined_namespaces.merge(@namespaces)
- else
- nodesets << pre_defined_namespaces.merge(raw_node.namespaces)
- end
- when :attribute
- if @namespaces
- nodesets << pre_defined_namespaces.merge(@namespaces)
- else
- nodesets << pre_defined_namespaces.merge(raw_node.element.namespaces)
- end
+ when :any
+ for element in nodeset
+ if element.node_type == :element
+ new_nodeset += element.attributes.to_a
end
end
- nodesets
end
+ nodeset = new_nodeset
+
when :parent
- nodeset = step(path_stack) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- if raw_node.node_type == :attribute
- parent = raw_node.element
- else
- parent = raw_node.parent
- end
- nodesets << [XPathNode.new(parent, position: 1)] if parent
+ nodeset = nodeset.collect{|n| n.parent}.compact
+ #nodeset = expr(path_stack.dclone, nodeset.collect{|n| n.parent}.compact)
+ node_types = ELEMENTS
+
+ when :ancestor
+ new_nodeset = []
+ nodeset.each do |node|
+ while node.parent
+ node = node.parent
+ new_nodeset << node unless new_nodeset.include? node
end
- nodesets
end
- when :ancestor
- nodeset = step(path_stack) do
- nodesets = []
- # new_nodes = {}
- nodeset.each do |node|
- raw_node = node.raw_node
- new_nodeset = []
- while raw_node.parent
- raw_node = raw_node.parent
- # next if new_nodes.key?(node)
- new_nodeset << XPathNode.new(raw_node,
- position: new_nodeset.size + 1)
- # new_nodes[node] = true
+ nodeset = new_nodeset
+ node_types = ELEMENTS
+
+ when :ancestor_or_self
+ new_nodeset = []
+ nodeset.each do |node|
+ if node.node_type == :element
+ new_nodeset << node
+ while ( node.parent )
+ node = node.parent
+ new_nodeset << node unless new_nodeset.include? node
end
- nodesets << new_nodeset unless new_nodeset.empty?
end
- nodesets
end
- when :ancestor_or_self
- nodeset = step(path_stack) do
- nodesets = []
- # new_nodes = {}
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.node_type == :element
- new_nodeset = [XPathNode.new(raw_node, position: 1)]
- # new_nodes[node] = true
- while raw_node.parent
- raw_node = raw_node.parent
- # next if new_nodes.key?(node)
- new_nodeset << XPathNode.new(raw_node,
- position: new_nodeset.size + 1)
- # new_nodes[node] = true
+ nodeset = new_nodeset
+ node_types = ELEMENTS
+
+ when :predicate
+ new_nodeset = []
+ subcontext = { :size => nodeset.size }
+ pred = path_stack.shift
+ nodeset.each_with_index { |node, index|
+ subcontext[ :node ] = node
+ subcontext[ :index ] = index+1
+ pc = pred.dclone
+ result = expr( pc, [node], subcontext )
+ result = result[0] if result.kind_of? Array and result.length == 1
+ if result.kind_of? Numeric
+ new_nodeset << node if result == (index+1)
+ elsif result.instance_of? Array
+ if result.size > 0 and result.inject(false) {|k,s| s or k}
+ new_nodeset << node if result.size > 0
end
- nodesets << new_nodeset unless new_nodeset.empty?
+ else
+ new_nodeset << node if result
end
- nodesets
+ }
+ nodeset = new_nodeset
+=begin
+ predicate = path_stack.shift
+ ns = nodeset.clone
+ result = expr( predicate, ns )
+ if result.kind_of? Array
+ nodeset = result.zip(ns).collect{|m,n| n if m}.compact
+ else
+ nodeset = result ? nodeset : []
end
+=end
+
when :descendant_or_self
- nodeset = step(path_stack) do
- descendant(nodeset, true)
- end
+ rv = descendant_or_self( path_stack, nodeset )
+ path_stack.clear
+ nodeset = rv
+ node_types = ELEMENTS
+
when :descendant
- nodeset = step(path_stack) do
- descendant(nodeset, false)
+ results = []
+ nt = nil
+ nodeset.each do |node|
+ nt = node.node_type
+ results += expr( path_stack.dclone.unshift( :descendant_or_self ),
+ node.children ) if nt == :element or nt == :document
end
+ nodeset = results
+ node_types = ELEMENTS
+
when :following_sibling
- nodeset = step(path_stack) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.respond_to?(:parent)
- next if raw_node.parent.nil?
- all_siblings = raw_node.parent.children
- current_index = all_siblings.index(raw_node)
- following_siblings = all_siblings[(current_index + 1)..-1]
- next if following_siblings.empty?
- nodesets << following_siblings.collect.with_index do |sibling, i|
- XPathNode.new(sibling, position: i + 1)
- end
- end
- nodesets
+ results = []
+ nodeset.each do |node|
+ next if node.parent.nil?
+ all_siblings = node.parent.children
+ current_index = all_siblings.index( node )
+ following_siblings = all_siblings[ current_index+1 .. -1 ]
+ results += expr( path_stack.dclone, following_siblings )
end
+ nodeset = results
+
when :preceding_sibling
- nodeset = step(path_stack, order: :reverse) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.respond_to?(:parent)
- next if raw_node.parent.nil?
- all_siblings = raw_node.parent.children
- current_index = all_siblings.index(raw_node)
- preceding_siblings = all_siblings[0, current_index].reverse
- next if preceding_siblings.empty?
- nodesets << preceding_siblings.collect.with_index do |sibling, i|
- XPathNode.new(sibling, position: i + 1)
- end
- end
- nodesets
+ results = []
+ nodeset.each do |node|
+ next if node.parent.nil?
+ all_siblings = node.parent.children
+ current_index = all_siblings.index( node )
+ preceding_siblings = all_siblings[ 0, current_index ].reverse
+ results += preceding_siblings
end
+ nodeset = results
+ node_types = ELEMENTS
+
when :preceding
- nodeset = step(path_stack, order: :reverse) do
- unnode(nodeset) do |node|
- preceding(node)
- end
+ new_nodeset = []
+ nodeset.each do |node|
+ new_nodeset += preceding( node )
end
+ nodeset = new_nodeset
+ node_types = ELEMENTS
+
when :following
- nodeset = step(path_stack) do
- unnode(nodeset) do |node|
- following(node)
+ new_nodeset = []
+ nodeset.each do |node|
+ new_nodeset += following( node )
+ end
+ nodeset = new_nodeset
+ node_types = ELEMENTS
+
+ when :namespace
+ new_nodeset = []
+ prefix = path_stack.shift
+ nodeset.each do |node|
+ if (node.node_type == :element or node.node_type == :attribute)
+ if @namespaces
+ namespaces = @namespaces
+ elsif (node.node_type == :element)
+ namespaces = node.namespaces
+ else
+ namespaces = node.element.namesapces
+ end
+ if (node.namespace == namespaces[prefix])
+ new_nodeset << node
+ end
end
end
+ nodeset = new_nodeset
+
when :variable
var_name = path_stack.shift
- return [@variables[var_name]]
+ return @variables[ var_name ]
- when :eq, :neq, :lt, :lteq, :gt, :gteq
+ # :and, :or, :eq, :neq, :lt, :lteq, :gt, :gteq
+ # TODO: Special case for :or and :and -- not evaluate the right
+ # operand if the left alone determines result (i.e. is true for
+ # :or and false for :and).
+ when :eq, :neq, :lt, :lteq, :gt, :gteq, :or
left = expr( path_stack.shift, nodeset.dup, context )
right = expr( path_stack.shift, nodeset.dup, context )
res = equality_relational_compare( left, op, right )
- trace(op, left, right, res) if @debug
return res
- when :or
- left = expr(path_stack.shift, nodeset.dup, context)
- return true if Functions.boolean(left)
- right = expr(path_stack.shift, nodeset.dup, context)
- return Functions.boolean(right)
-
when :and
- left = expr(path_stack.shift, nodeset.dup, context)
- return false unless Functions.boolean(left)
- right = expr(path_stack.shift, nodeset.dup, context)
- return Functions.boolean(right)
-
- when :div, :mod, :mult, :plus, :minus
- left = expr(path_stack.shift, nodeset, context)
- right = expr(path_stack.shift, nodeset, context)
- left = unnode(left) if left.is_a?(Array)
- right = unnode(right) if right.is_a?(Array)
- left = Functions::number(left)
- right = Functions::number(right)
- case op
- when :div
- return left / right
- when :mod
- return left % right
- when :mult
- return left * right
- when :plus
- return left + right
- when :minus
- return left - right
- else
- raise "[BUG] Unexpected operator: <#{op.inspect}>"
+ left = expr( path_stack.shift, nodeset.dup, context )
+ return [] unless left
+ if left.respond_to?(:inject) and !left.inject(false) {|a,b| a | b}
+ return []
end
+ right = expr( path_stack.shift, nodeset.dup, context )
+ res = equality_relational_compare( left, op, right )
+ return res
+
+ when :div
+ left = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
+ right = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
+ return (left / right)
+
+ when :mod
+ left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ return (left % right)
+
+ when :mult
+ left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ return (left * right)
+
+ when :plus
+ left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ return (left + right)
+
+ when :minus
+ left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
+ return (left - right)
+
when :union
left = expr( path_stack.shift, nodeset, context )
right = expr( path_stack.shift, nodeset, context )
- left = unnode(left) if left.is_a?(Array)
- right = unnode(right) if right.is_a?(Array)
return (left | right)
+
when :neg
res = expr( path_stack, nodeset, context )
- res = unnode(res) if res.is_a?(Array)
- return -Functions.number(res)
+ return -(res.to_f)
+
when :not
when :function
func_name = path_stack.shift.tr('-','_')
arguments = path_stack.shift
-
- if nodeset.size != 1
- message = "[BUG] Node set size must be 1 for function call: "
- message += "<#{func_name}>: <#{nodeset.inspect}>: "
- message += "<#{arguments.inspect}>"
- raise message
- end
-
- node = nodeset.first
- if context
- target_context = context
- else
- target_context = {:size => nodeset.size}
- if node.is_a?(XPathNode)
- target_context[:node] = node.raw_node
- target_context[:index] = node.position
- else
- target_context[:node] = node
- target_context[:index] = 1
+ subcontext = context ? nil : { :size => nodeset.size }
+
+ res = []
+ cont = context
+ nodeset.each_with_index { |n, i|
+ if subcontext
+ subcontext[:node] = n
+ subcontext[:index] = i
+ cont = subcontext
end
- end
- args = arguments.dclone.collect do |arg|
- result = expr(arg, nodeset, target_context)
- result = unnode(result) if result.is_a?(Array)
- result
- end
- Functions.context = target_context
- return Functions.send(func_name, *args)
+ arg_clone = arguments.dclone
+ args = arg_clone.collect { |arg|
+ expr( arg, [n], cont )
+ }
+ Functions.context = cont
+ res << Functions.send( func_name, *args )
+ }
+ return res
- else
- raise "[BUG] Unexpected path: <#{op.inspect}>: <#{path_stack.inspect}>"
end
end # while
return nodeset
- ensure
- leave(:expr, path_stack, nodeset) if @debug
end
- def step(path_stack, any_type: :element, order: :forward)
- nodesets = yield
- begin
- enter(:step, path_stack, nodesets) if @debug
- nodesets = node_test(path_stack, nodesets, any_type: any_type)
- while path_stack[0] == :predicate
- path_stack.shift # :predicate
- predicate_expression = path_stack.shift.dclone
- nodesets = evaluate_predicate(predicate_expression, nodesets)
- end
- if nodesets.size == 1
- ordered_nodeset = nodesets[0]
- else
- raw_nodes = []
- nodesets.each do |nodeset|
- nodeset.each do |node|
- if node.respond_to?(:raw_node)
- raw_nodes << node.raw_node
- else
- raw_nodes << node
- end
- end
- end
- ordered_nodeset = sort(raw_nodes, order)
- end
- new_nodeset = []
- ordered_nodeset.each do |node|
- # TODO: Remove duplicated
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- new_nodeset
- ensure
- leave(:step, path_stack, new_nodeset) if @debug
- end
- end
- def node_test(path_stack, nodesets, any_type: :element)
- enter(:node_test, path_stack, nodesets) if @debug
- operator = path_stack.shift
- case operator
- when :qname
- prefix = path_stack.shift
- name = path_stack.shift
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- case raw_node.node_type
- when :element
- if prefix.nil?
- raw_node.name == name
- elsif prefix.empty?
- if strict?
- raw_node.name == name and raw_node.namespace == ""
- else
- # FIXME: This DOUBLES the time XPath searches take
- ns = get_namespace(raw_node, prefix)
- raw_node.name == name and raw_node.namespace == ns
- end
- else
- # FIXME: This DOUBLES the time XPath searches take
- ns = get_namespace(raw_node, prefix)
- raw_node.name == name and raw_node.namespace == ns
- end
- when :attribute
- if prefix.nil?
- raw_node.name == name
- elsif prefix.empty?
- raw_node.name == name and raw_node.namespace == ""
- else
- # FIXME: This DOUBLES the time XPath searches take
- ns = get_namespace(raw_node.element, prefix)
- raw_node.name == name and raw_node.namespace == ns
- end
- else
- false
- end
- end
- end
- when :namespace
- prefix = path_stack.shift
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- case raw_node.node_type
- when :element
- namespaces = @namespaces || raw_node.namespaces
- raw_node.namespace == namespaces[prefix]
- when :attribute
- namespaces = @namespaces || raw_node.element.namespaces
- raw_node.namespace == namespaces[prefix]
- else
- false
- end
- end
- end
- when :any
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- raw_node.node_type == any_type
- end
- end
- when :comment
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- raw_node.node_type == :comment
- end
- end
- when :text
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- raw_node.node_type == :text
- end
- end
- when :processing_instruction
- target = path_stack.shift
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- (raw_node.node_type == :processing_instruction) and
- (target.empty? or (raw_node.target == target))
- end
- end
- when :node
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- true
- end
- end
- else
- message = "[BUG] Unexpected node test: " +
- "<#{operator.inspect}>: <#{path_stack.inspect}>"
- raise message
- end
- new_nodesets
- ensure
- leave(:node_test, path_stack, new_nodesets) if @debug
- end
+ ##########################################################
+ # FIXME
+ # The next two methods are BAD MOJO!
+ # This is my achilles heel. If anybody thinks of a better
+ # way of doing this, be my guest. This really sucks, but
+ # it is a wonder it works at all.
+ # ########################################################
- def filter_nodeset(nodeset)
- new_nodeset = []
- nodeset.each do |node|
- next unless yield(node)
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- new_nodeset
+ def descendant_or_self( path_stack, nodeset )
+ rs = []
+ d_o_s( path_stack, nodeset, rs )
+ document_order(rs.flatten.compact)
+ #rs.flatten.compact
end
- def evaluate_predicate(expression, nodesets)
- enter(:predicate, expression, nodesets) if @debug
- new_nodesets = nodesets.collect do |nodeset|
- new_nodeset = []
- subcontext = { :size => nodeset.size }
- nodeset.each_with_index do |node, index|
- if node.is_a?(XPathNode)
- subcontext[:node] = node.raw_node
- subcontext[:index] = node.position
- else
- subcontext[:node] = node
- subcontext[:index] = index + 1
- end
- result = expr(expression.dclone, [node], subcontext)
- trace(:predicate_evaluate, expression, node, subcontext, result) if @debug
- result = result[0] if result.kind_of? Array and result.length == 1
- if result.kind_of? Numeric
- if result == node.position
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- elsif result.instance_of? Array
- if result.size > 0 and result.inject(false) {|k,s| s or k}
- if result.size > 0
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- end
- else
- if result
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- end
- end
- new_nodeset
+ def d_o_s( p, ns, r )
+ nt = nil
+ ns.each_index do |i|
+ n = ns[i]
+ x = expr( p.dclone, [ n ] )
+ nt = n.node_type
+ d_o_s( p, n.children, x ) if nt == :element or nt == :document and n.children.size > 0
+ r.concat(x) if x.size > 0
end
- new_nodesets
- ensure
- leave(:predicate, new_nodesets) if @debug
end
- def trace(*args)
- indent = " " * @nest
- PP.pp(args, "").each_line do |line|
- puts("#{indent}#{line}")
- end
- end
-
- def enter(tag, *args)
- trace(:enter, tag, *args)
- @nest += 1
- end
-
- def leave(tag, *args)
- @nest -= 1
- trace(:leave, tag, *args)
- end
# Reorders an array of nodes so that they are in document order
# It tries to do this efficiently.
@@ -646,7 +494,7 @@ module REXML
# in and out of function calls. If I knew what the index of the nodes was,
# I wouldn't have to do this. Maybe add a document IDX for each node?
# Problems with mutable documents. Or, rewrite everything.
- def sort(array_of_nodes, order)
+ def document_order( array_of_nodes )
new_arry = []
array_of_nodes.each { |node|
node_idx = []
@@ -657,68 +505,42 @@ module REXML
end
new_arry << [ node_idx.reverse, node ]
}
- ordered = new_arry.sort_by do |index, node|
- if order == :forward
- index
- else
- -index
- end
- end
- ordered.collect do |_index, node|
- node
- end
+ new_arry.sort{ |s1, s2| s1[0] <=> s2[0] }.collect{ |s| s[1] }
end
- def descendant(nodeset, include_self)
- nodesets = []
- nodeset.each do |node|
- new_nodeset = []
- new_nodes = {}
- descendant_recursive(node.raw_node, new_nodeset, new_nodes, include_self)
- nodesets << new_nodeset unless new_nodeset.empty?
+
+ def recurse( nodeset, &block )
+ for node in nodeset
+ yield node
+ recurse( node, &block ) if node.node_type == :element
end
- nodesets
end
- def descendant_recursive(raw_node, new_nodeset, new_nodes, include_self)
- if include_self
- return if new_nodes.key?(raw_node)
- new_nodeset << XPathNode.new(raw_node, position: new_nodeset.size + 1)
- new_nodes[raw_node] = true
- end
- node_type = raw_node.node_type
- if node_type == :element or node_type == :document
- raw_node.children.each do |child|
- descendant_recursive(child, new_nodeset, new_nodes, true)
- end
- end
- end
# Builds a nodeset of all of the preceding nodes of the supplied node,
# in reverse document order
# preceding:: includes every element in the document that precedes this node,
# except for ancestors
- def preceding(node)
+ def preceding( node )
ancestors = []
- parent = node.parent
- while parent
- ancestors << parent
- parent = parent.parent
+ p = node.parent
+ while p
+ ancestors << p
+ p = p.parent
end
- precedings = []
- preceding_node = preceding_node_of(node)
- while preceding_node
- if ancestors.include?(preceding_node)
- ancestors.delete(preceding_node)
+ acc = []
+ p = preceding_node_of( node )
+ while p
+ if ancestors.include? p
+ ancestors.delete(p)
else
- precedings << XPathNode.new(preceding_node,
- position: precedings.size + 1)
+ acc << p
end
- preceding_node = preceding_node_of(preceding_node)
+ p = preceding_node_of( p )
end
- precedings
+ acc
end
def preceding_node_of( node )
@@ -736,15 +558,14 @@ module REXML
psn
end
- def following(node)
- followings = []
- following_node = next_sibling_node(node)
- while following_node
- followings << XPathNode.new(following_node,
- position: followings.size + 1)
- following_node = following_node_of(following_node)
+ def following( node )
+ acc = []
+ p = next_sibling_node( node )
+ while p
+ acc << p
+ p = following_node_of( p )
end
- followings
+ acc
end
def following_node_of( node )
@@ -766,68 +587,45 @@ module REXML
return psn
end
- def child(nodeset)
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- node_type = raw_node.node_type
- # trace(:child, node_type, node)
- case node_type
- when :element
- nodesets << raw_node.children.collect.with_index do |child_node, i|
- XPathNode.new(child_node, position: i + 1)
- end
- when :document
- new_nodeset = []
- raw_node.children.each do |child|
- case child
- when XMLDecl, Text
- # Ignore
- else
- new_nodeset << XPathNode.new(child, position: new_nodeset.size + 1)
- end
- end
- nodesets << new_nodeset unless new_nodeset.empty?
- end
- end
- nodesets
- end
-
def norm b
case b
when true, false
return b
when 'true', 'false'
return Functions::boolean( b )
- when /^\d+(\.\d+)?$/, Numeric
+ when /^\d+(\.\d+)?$/
return Functions::number( b )
else
return Functions::string( b )
end
end
- def equality_relational_compare(set1, op, set2)
- set1 = unnode(set1) if set1.is_a?(Array)
- set2 = unnode(set2) if set2.is_a?(Array)
-
+ def equality_relational_compare( set1, op, set2 )
if set1.kind_of? Array and set2.kind_of? Array
- # If both objects to be compared are node-sets, then the
- # comparison will be true if and only if there is a node in the
- # first node-set and a node in the second node-set such that the
- # result of performing the comparison on the string-values of
- # the two nodes is true.
- set1.product(set2).any? do |node1, node2|
- node_string1 = Functions.string(node1)
- node_string2 = Functions.string(node2)
- compare(node_string1, op, node_string2)
+ if set1.size == 1 and set2.size == 1
+ set1 = set1[0]
+ set2 = set2[0]
+ elsif set1.size == 0 or set2.size == 0
+ nd = set1.size==0 ? set2 : set1
+ rv = nd.collect { |il| compare( il, op, nil ) }
+ return rv
+ else
+ res = []
+ SyncEnumerator.new( set1, set2 ).each { |i1, i2|
+ i1 = norm( i1 )
+ i2 = norm( i2 )
+ res << compare( i1, op, i2 )
+ }
+ return res
end
- elsif set1.kind_of? Array or set2.kind_of? Array
- # If one is nodeset and other is number, compare number to each item
- # in nodeset s.t. number op number(string(item))
- # If one is nodeset and other is string, compare string to each item
- # in nodeset s.t. string op string(item)
- # If one is nodeset and other is boolean, compare boolean to each item
- # in nodeset s.t. boolean op boolean(item)
+ end
+ # If one is nodeset and other is number, compare number to each item
+ # in nodeset s.t. number op number(string(item))
+ # If one is nodeset and other is string, compare string to each item
+ # in nodeset s.t. string op string(item)
+ # If one is nodeset and other is boolean, compare boolean to each item
+ # in nodeset s.t. boolean op boolean(item)
+ if set1.kind_of? Array or set2.kind_of? Array
if set1.kind_of? Array
a = set1
b = set2
@@ -838,23 +636,15 @@ module REXML
case b
when true, false
- each_unnode(a).any? do |unnoded|
- compare(Functions.boolean(unnoded), op, b)
- end
+ return a.collect {|v| compare( Functions::boolean(v), op, b ) }
when Numeric
- each_unnode(a).any? do |unnoded|
- compare(Functions.number(unnoded), op, b)
- end
- when /\A\d+(\.\d+)?\z/
- b = Functions.number(b)
- each_unnode(a).any? do |unnoded|
- compare(Functions.number(unnoded), op, b)
- end
+ return a.collect {|v| compare( Functions::number(v), op, b )}
+ when /^\d+(\.\d+)?$/
+ b = Functions::number( b )
+ return a.collect {|v| compare( Functions::number(v), op, b )}
else
- b = Functions::string(b)
- each_unnode(a).any? do |unnoded|
- compare(Functions::string(unnoded), op, b)
- end
+ b = Functions::string( b )
+ return a.collect { |v| compare( Functions::string(v), op, b ) }
end
else
# If neither is nodeset,
@@ -864,52 +654,32 @@ module REXML
# Else, convert to string
# Else
# Convert both to numbers and compare
- compare(set1, op, set2)
- end
- end
-
- def value_type(value)
- case value
- when true, false
- :boolean
- when Numeric
- :number
- when String
- :string
- else
- raise "[BUG] Unexpected value type: <#{value.inspect}>"
- end
- end
-
- def normalize_compare_values(a, operator, b)
- a_type = value_type(a)
- b_type = value_type(b)
- case operator
- when :eq, :neq
- if a_type == :boolean or b_type == :boolean
- a = Functions.boolean(a) unless a_type == :boolean
- b = Functions.boolean(b) unless b_type == :boolean
- elsif a_type == :number or b_type == :number
- a = Functions.number(a) unless a_type == :number
- b = Functions.number(b) unless b_type == :number
+ s1 = set1.to_s
+ s2 = set2.to_s
+ if s1 == 'true' or s1 == 'false' or s2 == 'true' or s2 == 'false'
+ set1 = Functions::boolean( set1 )
+ set2 = Functions::boolean( set2 )
else
- a = Functions.string(a) unless a_type == :string
- b = Functions.string(b) unless b_type == :string
+ if op == :eq or op == :neq
+ if s1 =~ /^\d+(\.\d+)?$/ or s2 =~ /^\d+(\.\d+)?$/
+ set1 = Functions::number( s1 )
+ set2 = Functions::number( s2 )
+ else
+ set1 = Functions::string( set1 )
+ set2 = Functions::string( set2 )
+ end
+ else
+ set1 = Functions::number( set1 )
+ set2 = Functions::number( set2 )
+ end
end
- when :lt, :lteq, :gt, :gteq
- a = Functions.number(a) unless a_type == :number
- b = Functions.number(b) unless b_type == :number
- else
- message = "[BUG] Unexpected compare operator: " +
- "<#{operator.inspect}>: <#{a.inspect}>: <#{b.inspect}>"
- raise message
+ return compare( set1, op, set2 )
end
- [a, b]
+ return false
end
- def compare(a, operator, b)
- a, b = normalize_compare_values(a, operator, b)
- case operator
+ def compare a, op, b
+ case op
when :eq
a == b
when :neq
@@ -922,47 +692,13 @@ module REXML
a > b
when :gteq
a >= b
+ when :and
+ a and b
+ when :or
+ a or b
else
- message = "[BUG] Unexpected compare operator: " +
- "<#{operator.inspect}>: <#{a.inspect}>: <#{b.inspect}>"
- raise message
- end
- end
-
- def each_unnode(nodeset)
- return to_enum(__method__, nodeset) unless block_given?
- nodeset.each do |node|
- if node.is_a?(XPathNode)
- unnoded = node.raw_node
- else
- unnoded = node
- end
- yield(unnoded)
- end
- end
-
- def unnode(nodeset)
- each_unnode(nodeset).collect do |unnoded|
- unnoded = yield(unnoded) if block_given?
- unnoded
- end
- end
- end
-
- # @private
- class XPathNode
- attr_reader :raw_node, :context
- def initialize(node, context=nil)
- if node.is_a?(XPathNode)
- @raw_node = node.raw_node
- else
- @raw_node = node
+ false
end
- @context = context || {}
- end
-
- def position
- @context[:position]
end
end
end
diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb
index 948cfaf208..34dc245122 100644
--- a/lib/rinda/ring.rb
+++ b/lib/rinda/ring.rb
@@ -3,7 +3,7 @@
# Note: Rinda::Ring API is unstable.
#
require 'drb/drb'
-require_relative 'rinda'
+require 'rinda/rinda'
require 'ipaddr'
module Rinda
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
index 6a41a7ba75..47860bc8ae 100644
--- a/lib/rinda/tuplespace.rb
+++ b/lib/rinda/tuplespace.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
require 'monitor'
require 'drb/drb'
-require_relative 'rinda'
+require 'rinda/rinda'
require 'forwardable'
module Rinda
diff --git a/lib/rss.rb b/lib/rss.rb
index 1438d97bd3..1c7d72b9f7 100644
--- a/lib/rss.rb
+++ b/lib/rss.rb
@@ -77,8 +77,6 @@
module RSS
end
-require "rss/version"
-
require 'rss/1.0'
require 'rss/2.0'
require 'rss/atom'
diff --git a/lib/rss/0.9.rb b/lib/rss/0.9.rb
index 219ccefcdb..d852a6a85e 100644
--- a/lib/rss/0.9.rb
+++ b/lib/rss/0.9.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "parser"
+require "rss/parser"
module RSS
diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb
index c8f92fb54e..fb63937c5e 100644
--- a/lib/rss/1.0.rb
+++ b/lib/rss/1.0.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "parser"
+require "rss/parser"
module RSS
diff --git a/lib/rss/atom.rb b/lib/rss/atom.rb
index 48c27330d0..38e927478c 100644
--- a/lib/rss/atom.rb
+++ b/lib/rss/atom.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative 'parser'
+require 'rss/parser'
module RSS
##
diff --git a/lib/rss/content.rb b/lib/rss/content.rb
index 78c18d103c..d35311075a 100644
--- a/lib/rss/content.rb
+++ b/lib/rss/content.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "rss"
+require "rss/rss"
module RSS
# The prefix for the Content XML namespace.
diff --git a/lib/rss/converter.rb b/lib/rss/converter.rb
index d372e06725..b92e35a051 100644
--- a/lib/rss/converter.rb
+++ b/lib/rss/converter.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "utils"
+require "rss/utils"
module RSS
diff --git a/lib/rss/dublincore.rb b/lib/rss/dublincore.rb
index 85b836d3bf..8d1a551947 100644
--- a/lib/rss/dublincore.rb
+++ b/lib/rss/dublincore.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "rss"
+require "rss/rss"
module RSS
# The prefix for the Dublin Core XML namespace.
@@ -161,4 +161,4 @@ end
require 'rss/dublincore/1.0'
require 'rss/dublincore/2.0'
-require_relative 'dublincore/atom'
+require 'rss/dublincore/atom'
diff --git a/lib/rss/dublincore/atom.rb b/lib/rss/dublincore/atom.rb
index 1cfcdec677..0b8b11e440 100644
--- a/lib/rss/dublincore/atom.rb
+++ b/lib/rss/dublincore/atom.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "../atom"
+require "rss/atom"
module RSS
module Atom
diff --git a/lib/rss/image.rb b/lib/rss/image.rb
index 837f7d18f4..6b86ec0e5b 100644
--- a/lib/rss/image.rb
+++ b/lib/rss/image.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
require 'rss/1.0'
-require_relative 'dublincore'
+require 'rss/dublincore'
module RSS
diff --git a/lib/rss/itunes.rb b/lib/rss/itunes.rb
index bc3e25448a..987b090f21 100644
--- a/lib/rss/itunes.rb
+++ b/lib/rss/itunes.rb
@@ -277,46 +277,34 @@ module RSS
def parse(duration, do_validate=true)
if do_validate and /\A(?:
\d?\d:[0-5]\d:[0-5]\d|
- [0-5]?\d:[0-5]\d|
- \d+
+ [0-5]?\d:[0-5]\d
)\z/x !~ duration
raise ArgumentError,
- "must be one of HH:MM:SS, H:MM:SS, MM:SS, M:SS, S+: " +
+ "must be one of HH:MM:SS, H:MM:SS, MM::SS, M:SS: " +
duration.inspect
end
- if duration.include?(':')
- components = duration.split(':')
- components[3..-1] = nil if components.size > 3
+ components = duration.split(':')
+ components[3..-1] = nil if components.size > 3
- components.unshift("00") until components.size == 3
- components.collect do |component|
- component.to_i
- end
- else
- seconds_to_components(duration.to_i)
+ components.unshift("00") until components.size == 3
+
+ components.collect do |component|
+ component.to_i
end
end
- def construct(hours, minutes, seconds)
- components = [minutes, seconds]
+ def construct(hour, minute, second)
+ components = [minute, second]
if components.include?(nil)
nil
else
- components.unshift(hours) if hours and hours > 0
+ components.unshift(hour) if hour and hour > 0
components.collect do |component|
"%02d" % component
- end.join(':')
+ end.join(":")
end
end
-
- private
- def seconds_to_components(total_seconds)
- hours = total_seconds / (60 * 60)
- minutes = (total_seconds / 60) % 60
- seconds = total_seconds % 60
- [hours, minutes, seconds]
- end
end
content_setup
diff --git a/lib/rss/maker.rb b/lib/rss/maker.rb
index e32de81806..33d285f6af 100644
--- a/lib/rss/maker.rb
+++ b/lib/rss/maker.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "rss"
+require "rss/rss"
module RSS
##
@@ -65,15 +65,15 @@ module RSS
end
end
-require_relative "maker/1.0"
-require_relative "maker/2.0"
-require_relative "maker/feed"
-require_relative "maker/entry"
-require_relative "maker/content"
-require_relative "maker/dublincore"
-require_relative "maker/slash"
-require_relative "maker/syndication"
-require_relative "maker/taxonomy"
-require_relative "maker/trackback"
-require_relative "maker/image"
-require_relative "maker/itunes"
+require "rss/maker/1.0"
+require "rss/maker/2.0"
+require "rss/maker/feed"
+require "rss/maker/entry"
+require "rss/maker/content"
+require "rss/maker/dublincore"
+require "rss/maker/slash"
+require "rss/maker/syndication"
+require "rss/maker/taxonomy"
+require "rss/maker/trackback"
+require "rss/maker/image"
+require "rss/maker/itunes"
diff --git a/lib/rss/maker/0.9.rb b/lib/rss/maker/0.9.rb
index eb35fc14e1..622a4c30b4 100644
--- a/lib/rss/maker/0.9.rb
+++ b/lib/rss/maker/0.9.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative "../0.9"
+require "rss/0.9"
-require_relative "base"
+require "rss/maker/base"
module RSS
module Maker
@@ -278,7 +278,7 @@ module RSS
vars = super
if @maker.feed_version == "0.91"
vars << "title" unless title {|t| t.have_required_values?}
- vars << "link" unless link
+ vars << "link" unless link {|l| l.have_required_values?}
end
vars
end
diff --git a/lib/rss/maker/1.0.rb b/lib/rss/maker/1.0.rb
index 3934f9536c..3aee77e913 100644
--- a/lib/rss/maker/1.0.rb
+++ b/lib/rss/maker/1.0.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative "../1.0"
+require "rss/1.0"
-require_relative "base"
+require "rss/maker/base"
module RSS
module Maker
diff --git a/lib/rss/maker/2.0.rb b/lib/rss/maker/2.0.rb
index 43d00226b7..1f77a014d1 100644
--- a/lib/rss/maker/2.0.rb
+++ b/lib/rss/maker/2.0.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative "../2.0"
+require "rss/2.0"
-require_relative "0.9"
+require "rss/maker/0.9"
module RSS
module Maker
diff --git a/lib/rss/maker/atom.rb b/lib/rss/maker/atom.rb
index cdd1d8753e..e0cd7623c8 100644
--- a/lib/rss/maker/atom.rb
+++ b/lib/rss/maker/atom.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative "../atom"
+require "rss/atom"
-require_relative "base"
+require "rss/maker/base"
module RSS
module Maker
diff --git a/lib/rss/maker/base.rb b/lib/rss/maker/base.rb
index 17537b7006..bc4ca84141 100644
--- a/lib/rss/maker/base.rb
+++ b/lib/rss/maker/base.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
require 'forwardable'
-require_relative '../rss'
+require 'rss/rss'
module RSS
module Maker
diff --git a/lib/rss/maker/content.rb b/lib/rss/maker/content.rb
index b3f4e5036e..3559a45ad0 100644
--- a/lib/rss/maker/content.rb
+++ b/lib/rss/maker/content.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative '../content'
-require_relative '1.0'
-require_relative '2.0'
+require 'rss/content'
+require 'rss/maker/1.0'
+require 'rss/maker/2.0'
module RSS
module Maker
diff --git a/lib/rss/maker/dublincore.rb b/lib/rss/maker/dublincore.rb
index beea3134b4..988209c045 100644
--- a/lib/rss/maker/dublincore.rb
+++ b/lib/rss/maker/dublincore.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative '../dublincore'
-require_relative '1.0'
+require 'rss/dublincore'
+require 'rss/maker/1.0'
module RSS
module Maker
diff --git a/lib/rss/maker/entry.rb b/lib/rss/maker/entry.rb
index ccdf9608ae..f806cbcaae 100644
--- a/lib/rss/maker/entry.rb
+++ b/lib/rss/maker/entry.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative "atom"
-require_relative "feed"
+require "rss/maker/atom"
+require "rss/maker/feed"
module RSS
module Maker
diff --git a/lib/rss/maker/feed.rb b/lib/rss/maker/feed.rb
index 72ee704d6a..fdef7ad643 100644
--- a/lib/rss/maker/feed.rb
+++ b/lib/rss/maker/feed.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "atom"
+require "rss/maker/atom"
module RSS
module Maker
diff --git a/lib/rss/maker/image.rb b/lib/rss/maker/image.rb
index e3e62d8b9e..1957ba8689 100644
--- a/lib/rss/maker/image.rb
+++ b/lib/rss/maker/image.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative '../image'
-require_relative '1.0'
-require_relative 'dublincore'
+require 'rss/image'
+require 'rss/maker/1.0'
+require 'rss/maker/dublincore'
module RSS
module Maker
diff --git a/lib/rss/maker/itunes.rb b/lib/rss/maker/itunes.rb
index 28cca32021..d964a4d942 100644
--- a/lib/rss/maker/itunes.rb
+++ b/lib/rss/maker/itunes.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative '../itunes'
-require_relative '2.0'
+require 'rss/itunes'
+require 'rss/maker/2.0'
module RSS
module Maker
diff --git a/lib/rss/maker/slash.rb b/lib/rss/maker/slash.rb
index 473991903f..3bd82d3057 100644
--- a/lib/rss/maker/slash.rb
+++ b/lib/rss/maker/slash.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative '../slash'
-require_relative '1.0'
+require 'rss/slash'
+require 'rss/maker/1.0'
module RSS
module Maker
diff --git a/lib/rss/maker/syndication.rb b/lib/rss/maker/syndication.rb
index 9fd0efe99e..840b70229a 100644
--- a/lib/rss/maker/syndication.rb
+++ b/lib/rss/maker/syndication.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require_relative '../syndication'
-require_relative '1.0'
+require 'rss/syndication'
+require 'rss/maker/1.0'
module RSS
module Maker
diff --git a/lib/rss/maker/taxonomy.rb b/lib/rss/maker/taxonomy.rb
index f9858922da..76a2d1600d 100644
--- a/lib/rss/maker/taxonomy.rb
+++ b/lib/rss/maker/taxonomy.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative '../taxonomy'
-require_relative '1.0'
-require_relative 'dublincore'
+require 'rss/taxonomy'
+require 'rss/maker/1.0'
+require 'rss/maker/dublincore'
module RSS
module Maker
diff --git a/lib/rss/maker/trackback.rb b/lib/rss/maker/trackback.rb
index f78b4058f9..f97691c608 100644
--- a/lib/rss/maker/trackback.rb
+++ b/lib/rss/maker/trackback.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
-require_relative '../trackback'
-require_relative '1.0'
-require_relative '2.0'
+require 'rss/trackback'
+require 'rss/maker/1.0'
+require 'rss/maker/2.0'
module RSS
module Maker
diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb
index e1bcfc53e3..a9842e6d40 100644
--- a/lib/rss/parser.rb
+++ b/lib/rss/parser.rb
@@ -2,8 +2,8 @@
require "forwardable"
require "open-uri"
-require_relative "rss"
-require_relative "xml"
+require "rss/rss"
+require "rss/xml"
module RSS
@@ -72,31 +72,13 @@ module RSS
end
end
- def parse(rss, *args)
- if args.last.is_a?(Hash)
- options = args.pop
- else
- options = {}
- end
- do_validate = boolean_argument(args[0], options[:validate], true)
- ignore_unknown_element =
- boolean_argument(args[1], options[:ignore_unknown_element], true)
- parser_class = args[2] || options[:parser_class] || default_parser
+ def parse(rss, do_validate=true, ignore_unknown_element=true,
+ parser_class=default_parser)
parser = new(rss, parser_class)
parser.do_validate = do_validate
parser.ignore_unknown_element = ignore_unknown_element
parser.parse
end
-
- private
- def boolean_argument(positioned_value, option_value, default)
- value = positioned_value
- if value.nil? and not option_value.nil?
- value = option_value
- end
- value = default if value.nil?
- value
- end
end
def_delegators(:@parser, :parse, :rss,
@@ -120,7 +102,7 @@ module RSS
if uri.respond_to?(:read)
uri.read
- elsif (RUBY_VERSION >= '2.7' || !rss.tainted?) and File.readable?(rss)
+ elsif !rss.tainted? and File.readable?(rss)
File.open(rss) {|f| f.read}
else
rss
diff --git a/lib/rss/rss.gemspec b/lib/rss/rss.gemspec
deleted file mode 100644
index 04f2b2f42d..0000000000
--- a/lib/rss/rss.gemspec
+++ /dev/null
@@ -1,80 +0,0 @@
-begin
- require_relative "lib/rss/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "rss"
- spec.version = RSS::VERSION
- spec.authors = ["Kouhei Sutou"]
- spec.email = ["kou@cozmixng.org"]
-
- spec.summary = %q{Family of libraries that support various formats of XML "feeds".}
- spec.description = %q{Family of libraries that support various formats of XML "feeds".}
- spec.homepage = "https://github.com/ruby/rss"
- spec.license = "BSD-2-Clause"
-
- spec.files = [
- ".gitignore",
- ".travis.yml",
- "Gemfile",
- "LICENSE.txt",
- "NEWS.md",
- "README.md",
- "Rakefile",
- "lib/rss.rb",
- "lib/rss/0.9.rb",
- "lib/rss/1.0.rb",
- "lib/rss/2.0.rb",
- "lib/rss/atom.rb",
- "lib/rss/content.rb",
- "lib/rss/content/1.0.rb",
- "lib/rss/content/2.0.rb",
- "lib/rss/converter.rb",
- "lib/rss/dublincore.rb",
- "lib/rss/dublincore/1.0.rb",
- "lib/rss/dublincore/2.0.rb",
- "lib/rss/dublincore/atom.rb",
- "lib/rss/image.rb",
- "lib/rss/itunes.rb",
- "lib/rss/maker.rb",
- "lib/rss/maker/0.9.rb",
- "lib/rss/maker/1.0.rb",
- "lib/rss/maker/2.0.rb",
- "lib/rss/maker/atom.rb",
- "lib/rss/maker/base.rb",
- "lib/rss/maker/content.rb",
- "lib/rss/maker/dublincore.rb",
- "lib/rss/maker/entry.rb",
- "lib/rss/maker/feed.rb",
- "lib/rss/maker/image.rb",
- "lib/rss/maker/itunes.rb",
- "lib/rss/maker/slash.rb",
- "lib/rss/maker/syndication.rb",
- "lib/rss/maker/taxonomy.rb",
- "lib/rss/maker/trackback.rb",
- "lib/rss/parser.rb",
- "lib/rss/rexmlparser.rb",
- "lib/rss/rss.rb",
- "lib/rss/slash.rb",
- "lib/rss/syndication.rb",
- "lib/rss/taxonomy.rb",
- "lib/rss/trackback.rb",
- "lib/rss/utils.rb",
- "lib/rss/version.rb",
- "lib/rss/xml-stylesheet.rb",
- "lib/rss/xml.rb",
- "lib/rss/xmlparser.rb",
- "lib/rss/xmlscanner.rb",
- "rss.gemspec",
- ]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "test-unit"
-end
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb
index daa0837e9c..db87e11ad5 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -63,11 +63,15 @@ end
require "English"
-require_relative "utils"
-require_relative "converter"
-require_relative "xml-stylesheet"
+require "rss/utils"
+require "rss/converter"
+require "rss/xml-stylesheet"
module RSS
+
+ # The current version of RSS
+ VERSION = "0.2.7"
+
# The URI of the RSS 1.0 specification
URI = "http://purl.org/rss/1.0/"
diff --git a/lib/rss/taxonomy.rb b/lib/rss/taxonomy.rb
index 50688ee6c1..b7ea219e8c 100644
--- a/lib/rss/taxonomy.rb
+++ b/lib/rss/taxonomy.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
require "rss/1.0"
-require_relative "dublincore"
+require "rss/dublincore"
module RSS
# The prefix for the Taxonomy XML namespace.
diff --git a/lib/rss/version.rb b/lib/rss/version.rb
deleted file mode 100644
index f0a8894e79..0000000000
--- a/lib/rss/version.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module RSS
- # The current version of RSS
- VERSION = "0.2.8"
-end
diff --git a/lib/rss/xml-stylesheet.rb b/lib/rss/xml-stylesheet.rb
index 175c95fbcd..be9cfaaf64 100644
--- a/lib/rss/xml-stylesheet.rb
+++ b/lib/rss/xml-stylesheet.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "utils"
+require "rss/utils"
module RSS
diff --git a/lib/rss/xml.rb b/lib/rss/xml.rb
index b74630295f..cda8668044 100644
--- a/lib/rss/xml.rb
+++ b/lib/rss/xml.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: false
-require_relative "utils"
+require "rss/utils"
module RSS
module XML
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index f8ca70385e..f3671d9f2a 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -7,9 +7,10 @@
#++
require 'rbconfig'
+require 'thread'
module Gem
- VERSION = "3.1.6".freeze
+ VERSION = "2.7.6.2"
end
# Must be first since it unloads the prelude from 1.9.2
@@ -26,19 +27,19 @@ require 'rubygems/errors'
# For user documentation, see:
#
# * <tt>gem help</tt> and <tt>gem help [command]</tt>
-# * {RubyGems User Guide}[https://guides.rubygems.org/]
-# * {Frequently Asked Questions}[https://guides.rubygems.org/faqs]
+# * {RubyGems User Guide}[http://guides.rubygems.org/]
+# * {Frequently Asked Questions}[http://guides.rubygems.org/faqs]
#
# For gem developer documentation see:
#
-# * {Creating Gems}[https://guides.rubygems.org/make-your-own-gem]
+# * {Creating Gems}[http://guides.rubygems.org/make-your-own-gem]
# * Gem::Specification
# * Gem::Version for version dependency notes
#
# Further RubyGems documentation can be found at:
#
-# * {RubyGems Guides}[https://guides.rubygems.org]
-# * {RubyGems API}[https://www.rubydoc.info/github/rubygems/rubygems] (also available from
+# * {RubyGems Guides}[http://guides.rubygems.org]
+# * {RubyGems API}[http://www.rubydoc.info/github/rubygems/rubygems] (also available from
# <tt>gem server</tt>)
#
# == RubyGems Plugins
@@ -112,14 +113,10 @@ require 'rubygems/errors'
#
# -The RubyGems Team
+
module Gem
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)
- # Taint support is deprecated in Ruby 2.7.
- # This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",
- # to avoid deprecation warnings in Ruby 2.7.
- UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc{}
-
##
# An Array of Regexps that match windows Ruby platforms.
@@ -130,14 +127,14 @@ module Gem
/mingw/i,
/mswin/i,
/wince/i,
- ].freeze
+ ]
GEM_DEP_FILES = %w[
gem.deps.rb
gems.rb
Gemfile
Isolate
- ].freeze
+ ]
##
# Subdirectories in a gem repository
@@ -149,7 +146,7 @@ module Gem
extensions
gems
specifications
- ].freeze
+ ]
##
# Subdirectories in a gem repository for default gems
@@ -157,17 +154,29 @@ module Gem
REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES = %w[
gems
specifications/default
- ].freeze
+ ]
##
- # Exception classes used in a Gem.read_binary +rescue+ statement
+ # Exception classes used in a Gem.read_binary +rescue+ statement. Not all of
+ # these are defined in Ruby 1.8.7, hence the need for this convoluted setup.
- READ_BINARY_ERRORS = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS, Errno::ENOTSUP].freeze
+ READ_BINARY_ERRORS = begin
+ read_binary_errors = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS]
+ read_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP)
+ read_binary_errors
+ end.freeze
##
- # Exception classes used in Gem.write_binary +rescue+ statement
+ # Exception classes used in Gem.write_binary +rescue+ statement. Not all of
+ # these are defined in Ruby 1.8.7.
- WRITE_BINARY_ERRORS = [Errno::ENOSYS, Errno::ENOTSUP].freeze
+ WRITE_BINARY_ERRORS = begin
+ write_binary_errors = [Errno::ENOSYS]
+ write_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP)
+ write_binary_errors
+ end.freeze
+
+ USE_BUNDLER_FOR_GEMDEPS = false # :nodoc:
@@win_platform = nil
@@ -189,14 +198,12 @@ module Gem
@pre_reset_hooks ||= []
@post_reset_hooks ||= []
- @default_source_date_epoch = nil
-
##
# Try to activate a gem containing +path+. Returns true if
# activation succeeded or wasn't needed because it was already
# activated. Returns false if it can't find the path in a gem.
- def self.try_activate(path)
+ def self.try_activate path
# finds the _latest_ version... regardless of loaded specs and their deps
# if another gem had a requirement that would mean we shouldn't
# activate the latest version, then either it would already be activated
@@ -240,7 +247,7 @@ module Gem
##
# Find the full path to the executable for gem +name+. If the +exec_name+
- # is not given, an exception will be raised, otherwise the
+ # is not given, the gem's default_executable is chosen, otherwise the
# specified executable's path is returned. +requirements+ allows
# you to specify specific gem versions.
@@ -248,15 +255,15 @@ module Gem
# TODO: fails test_self_bin_path_bin_file_gone_in_latest
# Gem::Specification.find_by_name(name, *requirements).bin_file exec_name
+ raise ArgumentError, "you must supply exec_name" unless exec_name
+
requirements = Gem::Requirement.default if
requirements.empty?
find_spec_for_exe(name, exec_name, requirements).bin_file exec_name
end
- def self.find_spec_for_exe(name, exec_name, requirements)
- raise ArgumentError, "you must supply exec_name" unless exec_name
-
+ def self.find_spec_for_exe name, exec_name, requirements
dep = Gem::Dependency.new name, requirements
loaded = Gem.loaded_specs[name]
@@ -265,9 +272,9 @@ module Gem
specs = dep.matching_specs(true)
- specs = specs.find_all do |spec|
+ specs = specs.find_all { |spec|
spec.executables.include? exec_name
- end if exec_name
+ } if exec_name
unless spec = specs.first
msg = "can't find gem #{dep} with executable #{exec_name}"
@@ -283,7 +290,7 @@ module Gem
##
# Find the full path to the executable for gem +name+. If the +exec_name+
- # is not given, an exception will be raised, otherwise the
+ # is not given, the gem's default_executable is chosen, otherwise the
# specified executable's path is returned. +requirements+ allows
# you to specify specific gem versions.
#
@@ -292,8 +299,8 @@ module Gem
#
# This method should *only* be used in bin stub files.
- def self.activate_bin_path(name, exec_name = nil, *requirements) # :nodoc:
- spec = find_spec_for_exe name, exec_name, requirements
+ def self.activate_bin_path name, exec_name, requirement # :nodoc:
+ spec = find_spec_for_exe name, exec_name, [requirement]
Gem::LOADED_SPECS_MUTEX.synchronize do
spec.activate
finish_resolve
@@ -361,6 +368,11 @@ module Gem
spec.datadir
end
+ class << self
+ extend Gem::Deprecate
+ deprecate :datadir, "spec.datadir", 2016, 10
+ end
+
##
# A Zlib::Deflate.deflate wrapper
@@ -435,7 +447,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
#
# World-writable directories will never be created.
- def self.ensure_gem_subdirectories(dir = Gem.dir, mode = nil)
+ def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil
ensure_subdirectories(dir, mode, REPOSITORY_SUBDIRECTORIES)
end
@@ -448,11 +460,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
#
# World-writable directories will never be created.
- def self.ensure_default_gem_subdirectories(dir = Gem.dir, mode = nil)
+ def self.ensure_default_gem_subdirectories dir = Gem.dir, mode = nil
ensure_subdirectories(dir, mode, REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES)
end
- def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
+ def self.ensure_subdirectories dir, mode, subdirs # :nodoc:
old_umask = File.umask
File.umask old_umask | 002
@@ -465,7 +477,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
subdirs.each do |name|
subdir = File.join dir, name
next if File.exist? subdir
- FileUtils.mkdir_p subdir, **options rescue nil
+ FileUtils.mkdir_p subdir, options rescue nil
end
ensure
File.umask old_umask
@@ -476,7 +488,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# distinction as extensions cannot be shared between the two.
def self.extension_api_version # :nodoc:
- if 'no' == RbConfig::CONFIG['ENABLE_SHARED']
+ if 'no' == RbConfig::CONFIG['ENABLE_SHARED'] then
"#{ruby_api_version}-static"
else
ruby_api_version
@@ -513,11 +525,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
return files
end
- def self.find_files_from_load_path(glob) # :nodoc:
- glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
- $LOAD_PATH.map do |load_path|
- Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
- end.flatten.select { |file| File.file? file.tap(&Gem::UNTAINT) }
+ def self.find_files_from_load_path glob # :nodoc:
+ $LOAD_PATH.map { |load_path|
+ Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
+ }.flatten.select { |file| File.file? file.untaint }
end
##
@@ -561,12 +572,25 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
#++
#--
#
+ # FIXME move to pathsupport
+ #
#++
def self.find_home
- Dir.home.dup
+ windows = File::ALT_SEPARATOR
+ if not windows or RUBY_VERSION >= '1.9' then
+ File.expand_path "~"
+ else
+ ['HOME', 'USERPROFILE'].each do |key|
+ return File.expand_path ENV[key] if ENV[key]
+ end
+
+ if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
+ File.expand_path "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
+ end
+ end
rescue
- if Gem.win_platform?
+ if windows then
File.expand_path File.join(ENV['HOMEDRIVE'] || ENV['SystemDrive'], '/')
else
File.expand_path "/"
@@ -575,7 +599,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
private_class_method :find_home
- # TODO: remove in RubyGems 4.0
+ # FIXME deprecate these in 3.0
##
# Zlib::GzipReader wrapper that unzips +data+.
@@ -584,13 +608,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
Gem::Util.gunzip data
end
- class << self
-
- extend Gem::Deprecate
- deprecate :gunzip, "Gem::Util.gunzip", 2018, 12
-
- end
-
##
# Zlib::GzipWriter wrapper that zips +data+.
@@ -598,13 +615,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
Gem::Util.gzip data
end
- class << self
-
- extend Gem::Deprecate
- deprecate :gzip, "Gem::Util.gzip", 2018, 12
-
- end
-
##
# A Zlib::Inflate#inflate wrapper
@@ -612,13 +622,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
Gem::Util.inflate data
end
- class << self
-
- extend Gem::Deprecate
- deprecate :inflate, "Gem::Util.inflate", 2018, 12
-
- end
-
##
# Top level install helper method. Allows you to install gems interactively:
#
@@ -627,7 +630,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Fetching: minitest-3.0.1.gem (100%)
# => [#<Gem::Specification:0x1013b4528 @name="minitest", ...>]
- def self.install(name, version = Gem::Requirement.default, *options)
+ def self.install name, version = Gem::Requirement.default, *options
require "rubygems/dependency_installer"
inst = Gem::DependencyInstaller.new(*options)
inst.install name, version
@@ -639,12 +642,14 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# <tt>https://rubygems.org</tt>.
def self.host
+ # TODO: move to utils
@host ||= Gem::DEFAULT_HOST
end
## Set the default RubyGems API host.
- def self.host=(host)
+ def self.host= host
+ # TODO: move to utils
@host = host
end
@@ -659,25 +664,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
- index || 0
- end
-
- ##
- # The number of paths in the `$LOAD_PATH` from activated gems. Used to
- # prioritize `-I` and `ENV['RUBYLIB`]` entries during `require`.
-
- def self.activated_gem_paths
- @activated_gem_paths ||= 0
- end
-
- ##
- # Add a list of paths to the $LOAD_PATH at the proper place.
-
- def self.add_to_load_path(*paths)
- @activated_gem_paths = activated_gem_paths + paths.size
-
- # gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(Gem.load_path_insert_index, *paths)
+ index
end
@yaml_loaded = false
@@ -689,32 +676,45 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
return if @yaml_loaded
return unless defined?(gem)
- begin
- gem 'psych', '>= 2.0.0'
- rescue Gem::LoadError
- # It's OK if the user does not have the psych gem installed. We will
- # attempt to require the stdlib version
- end
+ test_syck = ENV['TEST_SYCK']
- begin
- # Try requiring the gem version *or* stdlib version of psych.
- require 'psych'
- rescue ::LoadError
- # If we can't load psych, thats fine, go on.
- else
- # If 'yaml' has already been required, then we have to
- # be sure to switch it over to the newly loaded psych.
- if defined?(YAML::ENGINE) && YAML::ENGINE.yamler != "psych"
- YAML::ENGINE.yamler = "psych"
+ # Only Ruby 1.8 and 1.9 have syck
+ test_syck = false unless /^1\./ =~ RUBY_VERSION
+
+ unless test_syck
+ begin
+ gem 'psych', '>= 2.0.0'
+ rescue Gem::LoadError
+ # It's OK if the user does not have the psych gem installed. We will
+ # attempt to require the stdlib version
end
- require 'rubygems/psych_additions'
- require 'rubygems/psych_tree'
+ begin
+ # Try requiring the gem version *or* stdlib version of psych.
+ require 'psych'
+ rescue ::LoadError
+ # If we can't load psych, thats fine, go on.
+ else
+ # If 'yaml' has already been required, then we have to
+ # be sure to switch it over to the newly loaded psych.
+ if defined?(YAML::ENGINE) && YAML::ENGINE.yamler != "psych"
+ YAML::ENGINE.yamler = "psych"
+ end
+
+ require 'rubygems/psych_additions'
+ require 'rubygems/psych_tree'
+ end
end
require 'yaml'
require 'rubygems/safe_yaml'
+ # If we're supposed to be using syck, then we may have to force
+ # activate it via the YAML::ENGINE API.
+ if test_syck and defined?(YAML::ENGINE)
+ YAML::ENGINE.yamler = "syck" unless YAML::ENGINE.syck?
+ end
+
# Now that we're sure some kind of yaml library is loaded, pull
# in our hack to deal with Syck's DefaultKey ugliness.
require 'rubygems/syck_hack'
@@ -850,7 +850,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and
prefix != File.expand_path(RbConfig::CONFIG['libdir']) and
- 'lib' == File.basename(RUBYGEMS_DIR)
+ 'lib' == File.basename(RUBYGEMS_DIR) then
prefix
end
end
@@ -908,7 +908,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# The path to the running Ruby interpreter.
def self.ruby
- if @ruby.nil?
+ if @ruby.nil? then
@ruby = File.join(RbConfig::CONFIG['bindir'],
"#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}")
@@ -937,7 +937,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# Returns the latest release-version specification for the gem +name+.
- def self.latest_spec_for(name)
+ def self.latest_spec_for name
dependency = Gem::Dependency.new name
fetcher = Gem::SpecFetcher.fetcher
spec_tuples, = fetcher.spec_for_dependency dependency
@@ -958,7 +958,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# Returns the version of the latest release-version of gem +name+
- def self.latest_version_for(name)
+ def self.latest_version_for name
spec = latest_spec_for name
spec and spec.version
end
@@ -970,15 +970,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
return @ruby_version if defined? @ruby_version
version = RUBY_VERSION.dup
- if defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1
+ if defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1 then
version << ".#{RUBY_PATCHLEVEL}"
- elsif defined?(RUBY_DESCRIPTION)
- if RUBY_ENGINE == "ruby"
- desc = RUBY_DESCRIPTION[/\Aruby #{Regexp.quote(RUBY_VERSION)}([^ ]+) /, 1]
- else
- desc = RUBY_DESCRIPTION[/\A#{RUBY_ENGINE} #{Regexp.quote(RUBY_ENGINE_VERSION)} \(#{RUBY_VERSION}([^ ]+)\) /, 1]
- end
- version << ".#{desc}" if desc
+ elsif defined?(RUBY_REVISION) then
+ version << ".dev.#{RUBY_REVISION}"
end
@ruby_version = Gem::Version.new version
@@ -1008,7 +1003,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# DOC: This comment is not documentation about the method itself, it's
# more of a code comment about the implementation.
- def self.sources=(new_sources)
+ def self.sources= new_sources
if !new_sources
@sources = nil
else
@@ -1023,21 +1018,17 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
@suffix_pattern ||= "{#{suffixes.join(',')}}"
end
- def self.suffix_regexp
- @suffix_regexp ||= /#{Regexp.union(suffixes)}\z/
- end
-
##
# Suffixes for require-able paths.
def self.suffixes
@suffixes ||= ['',
'.rb',
- *%w(DLEXT DLEXT2).map do |key|
+ *%w(DLEXT DLEXT2).map { |key|
val = RbConfig::CONFIG[key]
next unless val and not val.empty?
".#{val}"
- end
+ }
].compact.uniq
end
@@ -1082,14 +1073,14 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# The home directory for the user.
def self.user_home
- @user_home ||= find_home.tap(&Gem::UNTAINT)
+ @user_home ||= find_home.untaint
end
##
# Is this a windows platform?
def self.win_platform?
- if @@win_platform.nil?
+ if @@win_platform.nil? then
ruby_platform = RbConfig::CONFIG['host_os']
@@win_platform = !!WIN_PATTERNS.find { |r| ruby_platform =~ r }
end
@@ -1098,16 +1089,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
##
- # Is this a java platform?
-
- def self.java_platform?
- RUBY_PLATFORM == "java"
- end
-
- ##
# Load +plugins+ as Ruby files
- def self.load_plugin_files(plugins) # :nodoc:
+ def self.load_plugin_files plugins # :nodoc:
plugins.each do |plugin|
# Skip older versions of the GemCutter plugin: Its commands are in
@@ -1144,12 +1128,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
path = "rubygems_plugin"
files = []
- glob = "#{path}#{Gem.suffix_pattern}"
$LOAD_PATH.each do |load_path|
- globbed = Gem::Util.glob_files_in_dir(glob, load_path)
+ globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
globbed.each do |load_path_file|
- files << load_path_file if File.file?(load_path_file.tap(&Gem::UNTAINT))
+ files << load_path_file if File.file?(load_path_file.untaint)
end
end
@@ -1176,7 +1159,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# execution of arbitrary code when used from directories outside your
# control.
- def self.use_gemdeps(path = nil)
+ def self.use_gemdeps path = nil
raise_exception = path
path ||= ENV['RUBYGEMS_GEMDEPS']
@@ -1184,7 +1167,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
path = path.dup
- if path == "-"
+ if path == "-" then
Gem::Util.traverse_parents Dir.pwd do |directory|
dep_file = GEM_DEP_FILES.find { |f| File.file?(f) }
@@ -1195,28 +1178,35 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
end
- path.tap(&Gem::UNTAINT)
+ path.untaint
- unless File.file? path
+ unless File.file? path then
return unless raise_exception
raise ArgumentError, "Unable to find gem dependencies file at #{path}"
end
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
- require 'rubygems/user_interaction'
- Gem::DefaultUserInteraction.use_ui(ui) do
- require "bundler"
- begin
- Bundler.ui.silence do
- @gemdeps = Bundler.setup
- end
- ensure
- Gem::DefaultUserInteraction.ui.close
+ if USE_BUNDLER_FOR_GEMDEPS
+
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
+ require 'rubygems/user_interaction'
+ Gem::DefaultUserInteraction.use_ui(ui) do
+ require "bundler"
+ @gemdeps = Bundler.setup
+ Bundler.ui = nil
+ @gemdeps.requested_specs.map(&:to_spec).sort_by(&:name)
end
- @gemdeps.requested_specs.map(&:to_spec).sort_by(&:name)
- end
+ else
+
+ rs = Gem::RequestSet.new
+ @gemdeps = rs.load_gemdeps path
+
+ rs.resolve_current.map do |s|
+ s.full_spec.tap(&:activate)
+ end
+
+ end
rescue => e
case e
when Gem::LoadError, Gem::UnsatisfiableDependencyError, (defined?(Bundler::GemNotFound) ? Bundler::GemNotFound : Gem::LoadError)
@@ -1229,55 +1219,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
class << self
-
##
- # TODO remove with RubyGems 4.0
+ # TODO remove with RubyGems 3.0
alias detect_gemdeps use_gemdeps # :nodoc:
-
- extend Gem::Deprecate
- deprecate :detect_gemdeps, "Gem.use_gemdeps", 2018, 12
-
- end
-
- ##
- # If the SOURCE_DATE_EPOCH environment variable is set, returns it's value.
- # Otherwise, returns the time that `Gem.source_date_epoch_string` was
- # first called in the same format as SOURCE_DATE_EPOCH.
- #
- # NOTE(@duckinator): The implementation is a tad weird because we want to:
- # 1. Make builds reproducible by default, by having this function always
- # return the same result during a given run.
- # 2. Allow changing ENV['SOURCE_DATE_EPOCH'] at runtime, since multiple
- # tests that set this variable will be run in a single process.
- #
- # If you simplify this function and a lot of tests fail, that is likely
- # due to #2 above.
- #
- # Details on SOURCE_DATE_EPOCH:
- # https://reproducible-builds.org/specs/source-date-epoch/
-
- def self.source_date_epoch_string
- # The value used if $SOURCE_DATE_EPOCH is not set.
- @default_source_date_epoch ||= Time.now.to_i.to_s
-
- specified_epoch = ENV["SOURCE_DATE_EPOCH"]
-
- # If it's empty or just whitespace, treat it like it wasn't set at all.
- specified_epoch = nil if !specified_epoch.nil? && specified_epoch.strip.empty?
-
- epoch = specified_epoch || @default_source_date_epoch
-
- epoch.strip
- end
-
- ##
- # Returns the value of Gem.source_date_epoch_string, as a Time object.
- #
- # This is used throughout RubyGems for enabling reproducible builds.
-
- def self.source_date_epoch
- Time.at(self.source_date_epoch_string.to_i).utc.freeze
end
# FIX: Almost everywhere else we use the `def self.` way of defining class
@@ -1309,14 +1254,15 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
#
def register_default_spec(spec)
- extended_require_paths = spec.require_paths.map {|f| f + "/"}
- new_format = extended_require_paths.any? {|path| spec.files.any? {|f| f.start_with? path } }
+ new_format = Gem.default_gems_use_full_paths? || spec.require_paths.any? {|path| spec.files.any? {|f| f.start_with? path } }
if new_format
- prefix_group = extended_require_paths.join("|")
+ prefix_group = spec.require_paths.map {|f| f + "/"}.join("|")
prefix_pattern = /^(#{prefix_group})/
end
+ suffix_pattern = /#{Regexp.union(Gem.suffixes)}\z/
+
spec.files.each do |file|
if new_format
file = file.sub(prefix_pattern, "")
@@ -1324,7 +1270,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
@path_to_default_spec_map[file] = spec
- @path_to_default_spec_map[file.sub(suffix_regexp, "")] = spec
+ @path_to_default_spec_map[file.sub(suffix_pattern, "")] = spec
end
end
@@ -1332,8 +1278,17 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Find a Gem::Specification of default gem from +path+
def find_unresolved_default_spec(path)
- default_spec = @path_to_default_spec_map[path]
- return default_spec if default_spec && loaded_specs[default_spec.name] != default_spec
+ @path_to_default_spec_map[path]
+ end
+
+ ##
+ # Remove needless Gem::Specification of default gem from
+ # unresolved default gem list
+
+ def remove_unresolved_default_spec(spec)
+ spec.files.each do |file|
+ @path_to_default_spec_map.delete(file)
+ end
end
##
@@ -1387,32 +1342,31 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# work
attr_reader :pre_uninstall_hooks
-
end
##
# Location of Marshal quick gemspecs on remote repositories
- MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/".freeze
-
- autoload :BundlerVersionFinder, File.expand_path('rubygems/bundler_version_finder', __dir__)
- autoload :ConfigFile, File.expand_path('rubygems/config_file', __dir__)
- autoload :Dependency, File.expand_path('rubygems/dependency', __dir__)
- autoload :DependencyList, File.expand_path('rubygems/dependency_list', __dir__)
- autoload :Installer, File.expand_path('rubygems/installer', __dir__)
- autoload :Licenses, File.expand_path('rubygems/util/licenses', __dir__)
- autoload :NameTuple, File.expand_path('rubygems/name_tuple', __dir__)
- autoload :PathSupport, File.expand_path('rubygems/path_support', __dir__)
- autoload :Platform, File.expand_path('rubygems/platform', __dir__)
- autoload :RequestSet, File.expand_path('rubygems/request_set', __dir__)
- autoload :Requirement, File.expand_path('rubygems/requirement', __dir__)
- autoload :Resolver, File.expand_path('rubygems/resolver', __dir__)
- autoload :Source, File.expand_path('rubygems/source', __dir__)
- autoload :SourceList, File.expand_path('rubygems/source_list', __dir__)
- autoload :SpecFetcher, File.expand_path('rubygems/spec_fetcher', __dir__)
- autoload :Specification, File.expand_path('rubygems/specification', __dir__)
- autoload :Util, File.expand_path('rubygems/util', __dir__)
- autoload :Version, File.expand_path('rubygems/version', __dir__)
+ MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
+
+ autoload :BundlerVersionFinder, 'rubygems/bundler_version_finder'
+ autoload :ConfigFile, 'rubygems/config_file'
+ autoload :Dependency, 'rubygems/dependency'
+ autoload :DependencyList, 'rubygems/dependency_list'
+ autoload :DependencyResolver, 'rubygems/resolver'
+ autoload :Installer, 'rubygems/installer'
+ autoload :Licenses, 'rubygems/util/licenses'
+ autoload :PathSupport, 'rubygems/path_support'
+ autoload :Platform, 'rubygems/platform'
+ autoload :RequestSet, 'rubygems/request_set'
+ autoload :Requirement, 'rubygems/requirement'
+ autoload :Resolver, 'rubygems/resolver'
+ autoload :Source, 'rubygems/source'
+ autoload :SourceList, 'rubygems/source_list'
+ autoload :SpecFetcher, 'rubygems/spec_fetcher'
+ autoload :Specification, 'rubygems/specification'
+ autoload :Util, 'rubygems/util'
+ autoload :Version, 'rubygems/version'
require "rubygems/specification"
end
@@ -1420,20 +1374,25 @@ end
require 'rubygems/exceptions'
# REFACTOR: This should be pulled out into some kind of hacks file.
-begin
- ##
- # Defaults the operating system (or packager) wants to provide for RubyGems.
+gem_preluded = Gem::GEM_PRELUDE_SUCKAGE and defined? Gem
+unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
+ begin
+ ##
+ # Defaults the operating system (or packager) wants to provide for RubyGems.
- require 'rubygems/defaults/operating_system'
-rescue LoadError
-end
+ require 'rubygems/defaults/operating_system'
+ rescue LoadError
+ end
-begin
- ##
- # Defaults the Ruby implementation wants to provide for RubyGems
+ if defined?(RUBY_ENGINE) then
+ begin
+ ##
+ # Defaults the Ruby implementation wants to provide for RubyGems
- require "rubygems/defaults/#{RUBY_ENGINE}"
-rescue LoadError
+ require "rubygems/defaults/#{RUBY_ENGINE}"
+ rescue LoadError
+ end
+ end
end
##
@@ -1442,6 +1401,5 @@ Gem::Specification.load_defaults
require 'rubygems/core_ext/kernel_gem'
require 'rubygems/core_ext/kernel_require'
-require 'rubygems/core_ext/kernel_warn'
Gem.use_gemdeps
diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb
index 2e9d9496f6..49b5d5fd06 100644
--- a/lib/rubygems/available_set.rb
+++ b/lib/rubygems/available_set.rb
@@ -103,7 +103,7 @@ class Gem::AvailableSet
# Other options are :shallow for only direct development dependencies of the
# gems in this set or :all for all development dependencies.
- def to_request_set(development = :none)
+ def to_request_set development = :none
request_set = Gem::RequestSet.new
request_set.development = :all == development
@@ -162,5 +162,4 @@ class Gem::AvailableSet
def inject_into_list(dep_list)
@set.each { |t| dep_list.add t.spec }
end
-
end
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index 339953eb29..72954a7863 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -35,14 +35,7 @@ class Gem::BasicSpecification
end
def self.default_specifications_dir
- Gem.default_specifications_dir
- end
-
- class << self
-
- extend Gem::Deprecate
- deprecate :default_specifications_dir, "Gem.default_specifications_dir", 2020, 02
-
+ File.join(Gem.default_dir, "specifications", "default")
end
##
@@ -72,17 +65,14 @@ class Gem::BasicSpecification
##
# Return true if this spec can require +file+.
- def contains_requirable_file?(file)
- if @ignored
+ def contains_requirable_file? file
+ if @ignored then
return false
- elsif missing_extensions?
+ elsif missing_extensions? then
@ignored = true
- if Gem::Platform::RUBY == platform || Gem::Platform.local === platform
- warn "Ignoring #{full_name} because its extensions are not built. " +
- "Try: gem pristine #{name} --version #{version}"
- end
-
+ warn "Ignoring #{full_name} because its extensions are not built. " +
+ "Try: gem pristine #{name} --version #{version}"
return false
end
@@ -91,14 +81,14 @@ class Gem::BasicSpecification
def default_gem?
loaded_from &&
- File.dirname(loaded_from) == Gem.default_specifications_dir
+ File.dirname(loaded_from) == self.class.default_specifications_dir
end
##
# Returns full path to the directory where gem's extensions are installed.
def extension_dir
- @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).tap(&Gem::UNTAINT)
+ @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).untaint
end
##
@@ -113,7 +103,7 @@ class Gem::BasicSpecification
def find_full_gem_path # :nodoc:
# TODO: also, shouldn't it default to full_name if it hasn't been written?
path = File.expand_path File.join(gems_dir, full_name)
- path.tap(&Gem::UNTAINT)
+ path.untaint
path
end
@@ -134,10 +124,10 @@ class Gem::BasicSpecification
# default Ruby platform.
def full_name
- if platform == Gem::Platform::RUBY or platform.nil?
- "#{name}-#{version}".dup.tap(&Gem::UNTAINT)
+ if platform == Gem::Platform::RUBY or platform.nil? then
+ "#{name}-#{version}".dup.untaint
else
- "#{name}-#{version}-#{platform}".dup.tap(&Gem::UNTAINT)
+ "#{name}-#{version}-#{platform}".dup.untaint
end
end
@@ -149,7 +139,7 @@ class Gem::BasicSpecification
@full_require_paths ||=
begin
full_paths = raw_require_paths.map do |path|
- File.join full_gem_path, path.tap(&Gem::UNTAINT)
+ File.join full_gem_path, path.untaint
end
full_paths << extension_dir if have_extensions?
@@ -162,16 +152,16 @@ class Gem::BasicSpecification
# The path to the data directory for this gem.
def datadir
- # TODO: drop the extra ", gem_name" which is uselessly redundant
- File.expand_path(File.join(gems_dir, full_name, "data", name)).tap(&Gem::UNTAINT)
+# TODO: drop the extra ", gem_name" which is uselessly redundant
+ File.expand_path(File.join(gems_dir, full_name, "data", name)).untaint
end
##
# Full path of the target library file.
# If the file is not in this gem, return nil.
- def to_fullpath(path)
- if activated?
+ def to_fullpath path
+ if activated? then
@paths_map ||= {}
@paths_map[path] ||=
begin
@@ -206,8 +196,8 @@ class Gem::BasicSpecification
def internal_init # :nodoc:
@extension_dir = nil
- @full_gem_path = nil
- @gem_dir = nil
+ @full_gem_path = nil
+ @gem_dir = nil
@ignored = nil
end
@@ -259,7 +249,7 @@ class Gem::BasicSpecification
def source_paths
paths = raw_require_paths.dup
- if have_extensions?
+ if have_extensions? then
ext_dirs = extensions.map do |extension|
extension.split(File::SEPARATOR, 2).first
end.uniq
@@ -273,11 +263,11 @@ class Gem::BasicSpecification
##
# Return all files in this gem that match for +glob+.
- def matches_for_glob(glob) # TODO: rename?
+ def matches_for_glob glob # TODO: rename?
# TODO: do we need these?? Kill it
glob = File.join(self.lib_dirs_glob, glob)
- Dir[glob].map { |f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1
+ Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
end
##
@@ -286,16 +276,16 @@ class Gem::BasicSpecification
def lib_dirs_glob
dirs = if self.raw_require_paths
- if self.raw_require_paths.size > 1
+ if self.raw_require_paths.size > 1 then
"{#{self.raw_require_paths.join(',')}}"
else
self.raw_require_paths.first
end
else
- "lib" # default value for require_paths for bundler/inline
+ "lib" # default value for require_paths for bundler/inline
end
- "#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT)
+ "#{self.full_gem_path}/#{dirs}".dup.untaint
end
##
@@ -326,9 +316,9 @@ class Gem::BasicSpecification
def have_extensions?; !extensions.empty?; end
- def have_file?(file, suffixes)
+ def have_file? file, suffixes
return true if raw_require_paths.any? do |path|
- base = File.join(gems_dir, full_name, path.tap(&Gem::UNTAINT), file).tap(&Gem::UNTAINT)
+ base = File.join(gems_dir, full_name, path.untaint, file).untaint
suffixes.any? { |suf| File.file? base + suf }
end
@@ -339,5 +329,4 @@ class Gem::BasicSpecification
false
end
end
-
end
diff --git a/lib/rubygems/bundler_version_finder.rb b/lib/rubygems/bundler_version_finder.rb
index 38da7738a8..ba25399d1e 100644
--- a/lib/rubygems/bundler_version_finder.rb
+++ b/lib/rubygems/bundler_version_finder.rb
@@ -1,8 +1,5 @@
-# frozen_string_literal: true
-
-require "rubygems/util"
-
module Gem::BundlerVersionFinder
+
def self.bundler_version
version, _ = bundler_version_with_reason
@@ -45,11 +42,6 @@ To install the missing version, run `gem install bundler:#{vr.first}`
return unless bundler_version = self.bundler_version
specs.reject! { |spec| spec.version.segments.first != bundler_version.segments.first }
-
- exact_match_index = specs.find_index { |spec| spec.version == bundler_version }
- return unless exact_match_index
-
- specs.unshift(specs.delete_at(exact_match_index))
end
def self.bundle_update_bundler_version
@@ -83,7 +75,7 @@ To install the missing version, run `gem install bundler:#{vr.first}`
gemfile = ENV["BUNDLE_GEMFILE"]
gemfile = nil if gemfile && gemfile.empty?
Gem::Util.traverse_parents Dir.pwd do |directory|
- next unless gemfile = Gem::GEM_DEP_FILES.find { |f| File.file?(f.tap(&Gem::UNTAINT)) }
+ next unless gemfile = Gem::GEM_DEP_FILES.find { |f| File.file?(f.untaint) }
gemfile = File.join directory, gemfile
break
@@ -92,9 +84,9 @@ To install the missing version, run `gem install bundler:#{vr.first}`
return unless gemfile
lockfile = case gemfile
- when "gems.rb" then "gems.locked"
- else "#{gemfile}.lock"
- end.dup.tap(&Gem::UNTAINT)
+ when "gems.rb" then "gems.locked"
+ else "#{gemfile}.lock"
+ end.untaint
return unless File.file?(lockfile)
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index 32ec0f8ba6..a7ec212e51 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -20,10 +20,6 @@ class Gem::Command
include Gem::UserInteraction
- OptionParser.accept Symbol do |value|
- value.to_sym
- end
-
##
# The name of the command.
@@ -126,7 +122,6 @@ class Gem::Command
@defaults = defaults
@options = defaults.dup
@option_groups = Hash.new { |h,k| h[k] = [] }
- @deprecated_options = { command => {} }
@parser = nil
@when_invoked = nil
end
@@ -155,25 +150,18 @@ class Gem::Command
##
# Display to the user that a gem couldn't be found and reasons why
#--
+ # TODO: replace +domain+ with a parameter to suppress suggestions
- def show_lookup_failure(gem_name, version, errors, suppress_suggestions = false, required_by = nil)
- gem = "'#{gem_name}' (#{version})"
- msg = String.new "Could not find a valid gem #{gem}"
-
+ def show_lookup_failure(gem_name, version, errors, domain)
if errors and !errors.empty?
- msg << ", here is why:\n"
+ msg = "Could not find a valid gem '#{gem_name}' (#{version}), here is why:\n".dup
errors.each { |x| msg << " #{x.wordy}\n" }
+ alert_error msg
else
- if required_by and gem != required_by
- msg << " (required by #{required_by}) in any repository"
- else
- msg << " in any repository"
- end
+ alert_error "Could not find a valid gem '#{gem_name}' (#{version}) in any repository"
end
- alert_error msg
-
- unless suppress_suggestions
+ unless domain == :local then # HACK
suggestions = Gem::SpecFetcher.fetcher.suggest_gems_from_name gem_name
unless suggestions.empty?
@@ -188,7 +176,7 @@ class Gem::Command
def get_all_gem_names
args = options[:args]
- if args.nil? or args.empty?
+ if args.nil? or args.empty? then
raise Gem::CommandLineError,
"Please specify at least one gem name (e.g. gem build GEMNAME)"
end
@@ -218,12 +206,12 @@ class Gem::Command
def get_one_gem_name
args = options[:args]
- if args.nil? or args.empty?
+ if args.nil? or args.empty? then
raise Gem::CommandLineError,
"Please specify a gem name on the command line (e.g. gem build GEMNAME)"
end
- if args.size > 1
+ if args.size > 1 then
raise Gem::CommandLineError,
"Too many gem names (#{args.join(', ')}); please specify only one"
end
@@ -317,9 +305,9 @@ class Gem::Command
self.ui = ui = Gem::SilentUI.new
end
- if options[:help]
+ if options[:help] then
show_help
- elsif @when_invoked
+ elsif @when_invoked then
@when_invoked.call options
else
execute
@@ -365,50 +353,7 @@ class Gem::Command
def remove_option(name)
@option_groups.each do |_, option_list|
- option_list.reject! { |args, _| args.any? { |x| x.is_a?(String) && x =~ /^#{name}/ } }
- end
- end
-
- ##
- # Mark a command-line option as deprecated, and optionally specify a
- # deprecation horizon.
- #
- # Note that with the current implementation, every version of the option needs
- # to be explicitly deprecated, so to deprecate an option defined as
- #
- # add_option('-t', '--[no-]test', 'Set test mode') do |value, options|
- # # ... stuff ...
- # end
- #
- # you would need to explicitly add a call to `deprecate_option` for every
- # version of the option you want to deprecate, like
- #
- # deprecate_option('-t')
- # deprecate_option('--test')
- # deprecate_option('--no-test')
-
- def deprecate_option(name, version: nil, extra_msg: nil)
- @deprecated_options[command].merge!({ name => { "rg_version_to_expire" => version, "extra_msg" => extra_msg } })
- end
-
- def check_deprecated_options(options)
- options.each do |option|
- if option_is_deprecated?(option)
- deprecation = @deprecated_options[command][option]
- version_to_expire = deprecation["rg_version_to_expire"]
-
- deprecate_option_msg = if version_to_expire
- "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}."
- else
- "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems."
- end
-
- extra_msg = deprecation["extra_msg"]
-
- deprecate_option_msg += " #{extra_msg}" if extra_msg
-
- alert_warning(deprecate_option_msg)
- end
+ option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } }
end
end
@@ -418,7 +363,7 @@ class Gem::Command
def merge_options(new_options)
@options = @defaults.clone
- new_options.each { |k,v| @options[k] = v }
+ new_options.each do |k,v| @options[k] = v end
end
##
@@ -439,7 +384,6 @@ class Gem::Command
def handle_options(args)
args = add_extra_args(args)
- check_deprecated_options(args)
@options = Marshal.load Marshal.dump @defaults # deep copy
parser.parse!(args)
@options[:args] = args
@@ -468,10 +412,6 @@ class Gem::Command
private
- def option_is_deprecated?(option)
- @deprecated_options[command].has_key?(option)
- end
-
def add_parser_description # :nodoc:
return unless description
@@ -503,7 +443,7 @@ class Gem::Command
# Adds a section with +title+ and +content+ to the parser help view. Used
# for adding command arguments and default arguments.
- def add_parser_run_info(title, content)
+ def add_parser_run_info title, content
return if content.empty?
@parser.separator nil
@@ -556,6 +496,7 @@ class Gem::Command
@parser.separator " #{header}Options:"
option_list.each do |args, handler|
+ args.select { |arg| arg =~ /^-/ }
@parser.on(*args) do |value|
handler.call(value, @options)
end
@@ -582,7 +523,7 @@ class Gem::Command
add_common_option('-V', '--[no-]verbose',
'Set the verbose level of output') do |value, options|
# Set us to "really verbose" so the progress meter works
- if Gem.configuration.verbose and value
+ if Gem.configuration.verbose and value then
Gem.configuration.verbose = 1
else
Gem.configuration.verbose = value
@@ -618,9 +559,10 @@ class Gem::Command
'Avoid loading any .gemrc file') do
end
+
# :stopdoc:
- HELP = <<-HELP.freeze
+ HELP = <<-HELP
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
@@ -646,7 +588,7 @@ basic help message containing pointers to more information.
http://localhost:8808/
with info about installed gems
Further information:
- https://guides.rubygems.org
+ http://guides.rubygems.org
HELP
# :startdoc:
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index 8ad723be55..3bee1c30a4 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -47,7 +47,6 @@ class Gem::CommandManager
:fetch,
:generate_index,
:help,
- :info,
:install,
:list,
:lock,
@@ -71,11 +70,7 @@ class Gem::CommandManager
:update,
:which,
:yank,
- ].freeze
-
- ALIAS_COMMANDS = {
- 'i' => 'install'
- }.freeze
+ ]
##
# Return the authoritative instance of the command manager.
@@ -157,7 +152,7 @@ class Gem::CommandManager
end
def process_args(args, build_args=nil)
- if args.empty?
+ if args.empty? then
say Gem::Command::HELP
terminate_interaction 1
end
@@ -180,25 +175,18 @@ class Gem::CommandManager
end
def find_command(cmd_name)
- cmd_name = find_alias_command cmd_name
-
possibilities = find_command_possibilities cmd_name
- if possibilities.size > 1
+ if possibilities.size > 1 then
raise Gem::CommandLineError,
"Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
- elsif possibilities.empty?
+ elsif possibilities.empty? then
raise Gem::CommandLineError, "Unknown command #{cmd_name}"
end
self[possibilities.first]
end
- def find_alias_command(cmd_name)
- alias_name = ALIAS_COMMANDS[cmd_name]
- alias_name ? alias_name : cmd_name
- end
-
def find_command_possibilities(cmd_name)
len = cmd_name.length
@@ -232,3 +220,4 @@ class Gem::CommandManager
end
end
+
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index e2b5def1e8..38c45e46f0 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -10,18 +10,6 @@ class Gem::Commands::BuildCommand < Gem::Command
add_option '--force', 'skip validation of the spec' do |value, options|
options[:force] = true
end
-
- add_option '--strict', 'consider warnings as errors when validating the spec' do |value, options|
- options[:strict] = true
- end
-
- add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
- options[:output] = value
- end
-
- add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
- options[:build_path] = value
- end
end
def arguments # :nodoc:
@@ -44,11 +32,6 @@ with gem spec:
$ cd my_gem-1.0
[edit gem contents]
$ gem build my_gem-1.0.gemspec
-
-Gems can be saved to a specified filename with the output option:
-
- $ gem build my_gem-1.0.gemspec --output=release.gem
-
EOF
end
@@ -57,56 +40,26 @@ Gems can be saved to a specified filename with the output option:
end
def execute
- gem_name = get_one_optional_argument || find_gemspec
- build_gem(gem_name)
- end
-
- private
+ gemspec = get_one_gem_name
- def find_gemspec
- gemspecs = Dir.glob("*.gemspec").sort
-
- if gemspecs.size > 1
- alert_error "Multiple gemspecs found: #{gemspecs}, please specify one"
- terminate_interaction(1)
+ unless File.exist? gemspec
+ gemspec += '.gemspec' if File.exist? gemspec + '.gemspec'
end
- gemspecs.first
- end
-
- def build_gem(gem_name)
- gemspec = File.exist?(gem_name) ? gem_name : "#{gem_name}.gemspec"
+ if File.exist? gemspec then
+ spec = Gem::Specification.load gemspec
- if File.exist?(gemspec)
- spec = Gem::Specification.load(gemspec)
-
- if options[:build_path]
- Dir.chdir(File.dirname(gemspec)) do
- spec = Gem::Specification.load(File.basename(gemspec))
- build_package(spec)
- end
+ if spec then
+ Gem::Package.build spec, options[:force]
else
- build_package(spec)
+ alert_error "Error loading gemspec. Aborting."
+ terminate_interaction 1
end
-
else
alert_error "Gemspec file not found: #{gemspec}"
- terminate_interaction(1)
- end
- end
-
- def build_package(spec)
- if spec
- Gem::Package.build(
- spec,
- options[:force],
- options[:strict],
- options[:output]
- )
- else
- alert_error "Error loading gemspec. Aborting."
terminate_interaction 1
end
end
end
+
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index 72400f3edd..5542262a50 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -14,16 +14,15 @@ class Gem::Commands::CertCommand < Gem::Command
super 'cert', 'Manage RubyGems certificates and signing settings',
:add => [], :remove => [], :list => [], :build => [], :sign => []
- OptionParser.accept OpenSSL::X509::Certificate do |certificate_file|
+ OptionParser.accept OpenSSL::X509::Certificate do |certificate|
begin
- certificate = OpenSSL::X509::Certificate.new File.read certificate_file
+ OpenSSL::X509::Certificate.new File.read certificate
rescue Errno::ENOENT
- raise OptionParser::InvalidArgument, "#{certificate_file}: does not exist"
+ raise OptionParser::InvalidArgument, "#{certificate}: does not exist"
rescue OpenSSL::X509::CertificateError
raise OptionParser::InvalidArgument,
- "#{certificate_file}: invalid X509 certificate"
+ "#{certificate}: invalid X509 certificate"
end
- [certificate, certificate_file]
end
OptionParser.accept OpenSSL::PKey::RSA do |key_file|
@@ -43,7 +42,7 @@ class Gem::Commands::CertCommand < Gem::Command
end
add_option('-a', '--add CERT', OpenSSL::X509::Certificate,
- 'Add a trusted certificate.') do |(cert, _), options|
+ 'Add a trusted certificate.') do |cert, options|
options[:add] << cert
end
@@ -68,9 +67,8 @@ class Gem::Commands::CertCommand < Gem::Command
end
add_option('-C', '--certificate CERT', OpenSSL::X509::Certificate,
- 'Signing certificate for --sign') do |(cert, cert_file), options|
+ 'Signing certificate for --sign') do |cert, options|
options[:issuer_cert] = cert
- options[:issuer_cert_file] = cert_file
end
add_option('-K', '--private-key KEY', OpenSSL::PKey::RSA,
@@ -89,16 +87,11 @@ class Gem::Commands::CertCommand < Gem::Command
add_option('-d', '--days NUMBER_OF_DAYS',
'Days before the certificate expires') do |days, options|
- options[:expiration_length_days] = days.to_i
- end
-
- add_option('-R', '--re-sign',
- 'Re-signs the certificate from -C with the key from -K') do |resign, options|
- options[:resign] = resign
+ options[:expiration_length_days] = days.to_i
end
end
- def add_certificate(certificate) # :nodoc:
+ def add_certificate certificate # :nodoc:
Gem::Security.trust_dir.trust_cert certificate
say "Added '#{certificate.subject}'"
@@ -121,18 +114,10 @@ class Gem::Commands::CertCommand < Gem::Command
build email
end
- if options[:resign]
- re_sign_cert(
- options[:issuer_cert],
- options[:issuer_cert_file],
- options[:key]
- )
- end
-
sign_certificates unless options[:sign].empty?
end
- def build(email)
+ def build email
if !valid_email?(email)
raise Gem::CommandLineError, "Invalid email address #{email}"
end
@@ -148,16 +133,16 @@ class Gem::Commands::CertCommand < Gem::Command
end
end
- def build_cert(email, key) # :nodoc:
- expiration_length_days = options[:expiration_length_days] ||
- Gem.configuration.cert_expiration_length_days
-
- cert = Gem::Security.create_cert_email(
- email,
- key,
- (Gem::Security::ONE_DAY * expiration_length_days)
- )
+ def build_cert email, key # :nodoc:
+ expiration_length_days = options[:expiration_length_days]
+ age =
+ if expiration_length_days.nil? || expiration_length_days == 0
+ Gem::Security::ONE_YEAR
+ else
+ Gem::Security::ONE_DAY * expiration_length_days
+ end
+ cert = Gem::Security.create_cert_email email, key, age
Gem::Security.write cert, "gem-public_cert.pem"
end
@@ -179,7 +164,7 @@ class Gem::Commands::CertCommand < Gem::Command
return key, key_path
end
- def certificates_matching(filter)
+ def certificates_matching filter
return enum_for __method__, filter unless block_given?
Gem::Security.trusted_certificates.select do |certificate, _|
@@ -231,7 +216,7 @@ For further reading on signing gems see `ri Gem::Security`.
EOF
end
- def list_certificates_matching(filter) # :nodoc:
+ def list_certificates_matching filter # :nodoc:
certificates_matching filter do |certificate, _|
# this could probably be formatted more gracefully
say certificate.subject.to_s
@@ -276,14 +261,14 @@ For further reading on signing gems see `ri Gem::Security`.
load_default_key unless options[:key]
end
- def remove_certificates_matching(filter) # :nodoc:
+ def remove_certificates_matching filter # :nodoc:
certificates_matching filter do |certificate, path|
FileUtils.rm path
say "Removed '#{certificate.subject}'"
end
end
- def sign(cert_file)
+ def sign cert_file
cert = File.read cert_file
cert = OpenSSL::X509::Certificate.new cert
@@ -305,18 +290,13 @@ For further reading on signing gems see `ri Gem::Security`.
end
end
- def re_sign_cert(cert, cert_path, private_key)
- Gem::Security::Signer.re_sign_cert(cert, cert_path, private_key) do |expired_cert_path, new_expired_cert_path|
- alert("Your certificate #{expired_cert_path} has been re-signed")
- alert("Your expired certificate will be located at: #{new_expired_cert_path}")
- end
- end
-
private
- def valid_email?(email)
+ def valid_email? email
# It's simple, but is all we need
email =~ /\A.+@.+\z/
end
+
end if defined?(OpenSSL::SSL)
+
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
index 7905b8ab69..818cb05f55 100644
--- a/lib/rubygems/commands/check_command.rb
+++ b/lib/rubygems/commands/check_command.rb
@@ -44,7 +44,7 @@ class Gem::Commands::CheckCommand < Gem::Command
gems = get_all_gem_names rescue []
Gem::Validator.new.alien(gems).sort.each do |key, val|
- unless val.empty?
+ unless val.empty? then
say "#{key} has #{val.size} problems"
val.each do |error_entry|
say " #{error_entry.path}:"
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index fedaec8448..79c23c840d 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -22,12 +22,6 @@ class Gem::Commands::CleanupCommand < Gem::Command
options[:check_dev] = value
end
- add_option('--[no-]user-install',
- 'Cleanup in user\'s home directory instead',
- 'of GEM_HOME.') do |value, options|
- options[:user_install] = value
- end
-
@candidate_gems = nil
@default_gems = []
@full = nil
@@ -62,7 +56,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
def execute
say "Cleaning up installed gems..."
- if options[:args].empty?
+ if options[:args].empty? then
done = false
last_set = nil
@@ -99,7 +93,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
@full = Gem::DependencyList.from_specs
deplist = Gem::DependencyList.new
- @gems_to_cleanup.each { |spec| deplist.add spec }
+ @gems_to_cleanup.each do |spec| deplist.add spec end
deps = deplist.strongly_connected_components.flatten
@@ -111,7 +105,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
end
def get_candidate_gems
- @candidate_gems = unless options[:args].empty?
+ @candidate_gems = unless options[:args].empty? then
options[:args].map do |gem_name|
Gem::Specification.find_all_by_name gem_name
end.flatten
@@ -121,19 +115,18 @@ If no gems are named all gems in GEM_HOME are cleaned.
end
def get_gems_to_cleanup
- gems_to_cleanup = @candidate_gems.select do |spec|
+
+ gems_to_cleanup = @candidate_gems.select { |spec|
@primary_gems[spec.name].version != spec.version
- end
+ }
- default_gems, gems_to_cleanup = gems_to_cleanup.partition do |spec|
+ default_gems, gems_to_cleanup = gems_to_cleanup.partition { |spec|
spec.default_gem?
- end
-
- uninstall_from = options[:user_install] ? Gem.user_dir : @original_home
+ }
- gems_to_cleanup = gems_to_cleanup.select do |spec|
- spec.base_dir == uninstall_from
- end
+ gems_to_cleanup = gems_to_cleanup.select { |spec|
+ spec.base_dir == @original_home
+ }
@default_gems += default_gems
@default_gems.uniq!
@@ -145,16 +138,16 @@ If no gems are named all gems in GEM_HOME are cleaned.
Gem::Specification.each do |spec|
if @primary_gems[spec.name].nil? or
- @primary_gems[spec.name].version < spec.version
+ @primary_gems[spec.name].version < spec.version then
@primary_gems[spec.name] = spec
end
end
end
- def uninstall_dep(spec)
+ def uninstall_dep spec
return unless @full.ok_to_remove?(spec.full_name, options[:check_dev])
- if options[:dryrun]
+ if options[:dryrun] then
say "Dry Run Mode: Would uninstall #{spec.full_name}"
return
end
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 26d6828fe6..e0f2eedb5d 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -14,7 +14,7 @@ class Gem::Commands::ContentsCommand < Gem::Command
add_version_option
- add_option('--all',
+ add_option( '--all',
"Contents for all gems") do |all, options|
options[:all] = all
end
@@ -29,12 +29,12 @@ class Gem::Commands::ContentsCommand < Gem::Command
options[:lib_only] = lib_only
end
- add_option('--[no-]prefix',
+ add_option( '--[no-]prefix',
"Don't include installed path prefix") do |prefix, options|
options[:prefix] = prefix
end
- add_option('--[no-]show-install-dir',
+ add_option( '--[no-]show-install-dir',
'Show only the gem install dir') do |show, options|
options[:show_install_dir] = show
end
@@ -73,7 +73,7 @@ prefix or only the files that are requireable.
names.each do |name|
found =
- if options[:show_install_dir]
+ if options[:show_install_dir] then
gem_install_dir name
else
gem_contents name
@@ -83,15 +83,15 @@ prefix or only the files that are requireable.
end
end
- def files_in(spec)
- if spec.default_gem?
+ def files_in spec
+ if spec.default_gem? then
files_in_default_gem spec
else
files_in_gem spec
end
end
- def files_in_gem(spec)
+ def files_in_gem spec
gem_path = spec.full_gem_path
extra = "/{#{spec.require_paths.join ','}}" if options[:lib_only]
glob = "#{gem_path}#{extra}/**/*"
@@ -102,7 +102,7 @@ prefix or only the files that are requireable.
end
end
- def files_in_default_gem(spec)
+ def files_in_default_gem spec
spec.files.map do |file|
case file
when /\A#{spec.bindir}\//
@@ -115,7 +115,7 @@ prefix or only the files that are requireable.
end
end
- def gem_contents(name)
+ def gem_contents name
spec = spec_for name
return false unless spec
@@ -127,7 +127,7 @@ prefix or only the files that are requireable.
true
end
- def gem_install_dir(name)
+ def gem_install_dir name
spec = spec_for name
return false unless spec
@@ -138,27 +138,27 @@ prefix or only the files that are requireable.
end
def gem_names # :nodoc:
- if options[:all]
+ if options[:all] then
Gem::Specification.map(&:name)
else
get_all_gem_names
end
end
- def path_description(spec_dirs) # :nodoc:
- if spec_dirs.empty?
+ def path_description spec_dirs # :nodoc:
+ if spec_dirs.empty? then
"default gem paths"
else
"specified path"
end
end
- def show_files(files)
+ def show_files files
files.sort.each do |prefix, basename|
absolute_path = File.join(prefix, basename)
next if File.directory? absolute_path
- if options[:prefix]
+ if options[:prefix] then
say absolute_path
else
say basename
@@ -166,14 +166,14 @@ prefix or only the files that are requireable.
end
end
- def spec_for(name)
+ def spec_for name
spec = Gem::Specification.find_all_by_name(name, @version).last
return spec if spec
say "Unable to find gem '#{name}' in #{@path_kind}"
- if Gem.configuration.verbose
+ if Gem.configuration.verbose then
say "\nDirectories searched:"
@spec_dirs.sort.each { |dir| say dir }
end
@@ -188,3 +188,4 @@ prefix or only the files that are requireable.
end
end
+
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index 00ab19bed4..97fd812ffa 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -54,7 +54,7 @@ use with other commands.
"#{program_name} REGEXP"
end
- def fetch_remote_specs(dependency) # :nodoc:
+ def fetch_remote_specs dependency # :nodoc:
fetcher = Gem::SpecFetcher.fetcher
ss, = fetcher.spec_for_dependency dependency
@@ -62,7 +62,7 @@ use with other commands.
ss.map { |spec, _| spec }
end
- def fetch_specs(name_pattern, dependency) # :nodoc:
+ def fetch_specs name_pattern, dependency # :nodoc:
specs = []
if local?
@@ -79,19 +79,19 @@ use with other commands.
specs.uniq.sort
end
- def gem_dependency(pattern, version, prerelease) # :nodoc:
- dependency = Gem::Deprecate.skip_during do
+ def gem_dependency pattern, version, prerelease # :nodoc:
+ dependency = Gem::Deprecate.skip_during {
Gem::Dependency.new pattern, version
- end
+ }
dependency.prerelease = prerelease
dependency
end
- def display_pipe(specs) # :nodoc:
+ def display_pipe specs # :nodoc:
specs.each do |spec|
- unless spec.dependencies.empty?
+ unless spec.dependencies.empty? then
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
say "#{dep.name} --version '#{dep.requirement}'"
end
@@ -99,12 +99,12 @@ use with other commands.
end
end
- def display_readable(specs, reverse) # :nodoc:
+ def display_readable specs, reverse # :nodoc:
response = String.new
specs.each do |spec|
response << print_dependencies(spec)
- unless reverse[spec.full_name].empty?
+ unless reverse[spec.full_name].empty? then
response << " Used by\n"
reverse[spec.full_name].each do |sp, dep|
response << " #{sp} (#{dep})\n"
@@ -128,7 +128,7 @@ use with other commands.
reverse = reverse_dependencies specs
- if options[:pipe_format]
+ if options[:pipe_format] then
display_pipe specs
else
display_readable specs, reverse
@@ -136,13 +136,13 @@ use with other commands.
end
def ensure_local_only_reverse_dependencies # :nodoc:
- if options[:reverse_dependencies] and remote? and not local?
+ if options[:reverse_dependencies] and remote? and not local? then
alert_error 'Only reverse dependencies for local gems are supported.'
terminate_interaction 1
end
end
- def ensure_specs(specs) # :nodoc:
+ def ensure_specs specs # :nodoc:
return unless specs.empty?
patterns = options[:args].join ','
@@ -155,7 +155,7 @@ use with other commands.
def print_dependencies(spec, level = 0) # :nodoc:
response = String.new
response << ' ' * level + "Gem #{spec.full_name}\n"
- unless spec.dependencies.empty?
+ unless spec.dependencies.empty? then
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
response << ' ' * level + " #{dep}\n"
end
@@ -163,7 +163,7 @@ use with other commands.
response
end
- def remote_specs(dependency) # :nodoc:
+ def remote_specs dependency # :nodoc:
fetcher = Gem::SpecFetcher.fetcher
ss, _ = fetcher.spec_for_dependency dependency
@@ -171,7 +171,7 @@ use with other commands.
ss.map { |s,o| s }
end
- def reverse_dependencies(specs) # :nodoc:
+ def reverse_dependencies specs # :nodoc:
reverse = Hash.new { |h, k| h[k] = [] }
return reverse unless options[:reverse_dependencies]
@@ -186,7 +186,7 @@ use with other commands.
##
# Returns an Array of [specification, dep] that are satisfied by +spec+.
- def find_reverse_dependencies(spec) # :nodoc:
+ def find_reverse_dependencies spec # :nodoc:
result = []
Gem::Specification.each do |sp|
@@ -194,7 +194,7 @@ use with other commands.
dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
if spec.name == dep.name and
- dep.requirement.satisfied_by?(spec.version)
+ dep.requirement.satisfied_by?(spec.version) then
result << [sp.full_name, dep]
end
end
@@ -205,15 +205,14 @@ use with other commands.
private
- def name_pattern(args)
+ def name_pattern args
args << '' if args.empty?
- if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
+ if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
flags = $2 ? Regexp::IGNORECASE : nil
Regexp.new $1, flags
else
/\A#{Regexp.union(*args)}/
end
end
-
end
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index c98a77ac2e..e825c761ad 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -9,6 +9,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
def arguments # :nodoc:
args = <<-EOF
+ packageversion display the package version
gemdir display the path where gems are installed
gempath display path used to search for gems
version display the gem format version
@@ -75,6 +76,8 @@ lib/rubygems/defaults/operating_system.rb
arg = options[:args][0]
out <<
case arg
+ when /^packageversion/ then
+ Gem::RubyGemsPackageVersion
when /^version/ then
Gem::VERSION
when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
@@ -94,7 +97,7 @@ lib/rubygems/defaults/operating_system.rb
true
end
- def add_path(out, path)
+ def add_path out, path
path.each do |component|
out << " - #{component}\n"
end
@@ -117,8 +120,6 @@ lib/rubygems/defaults/operating_system.rb
out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
- out << " - GIT EXECUTABLE: #{git_path}\n"
-
out << " - EXECUTABLE DIRECTORY: #{Gem.bindir}\n"
out << " - SPEC CACHE DIRECTORY: #{Gem.spec_cache_dir}\n"
@@ -156,21 +157,4 @@ lib/rubygems/defaults/operating_system.rb
out
end
- private
-
- ##
- # Git binary path
-
- def git_path
- exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
- ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
- exts.each do |ext|
- exe = File.join(path, "git#{ext}")
- return exe if File.executable?(exe) && !File.directory?(exe)
- end
- end
-
- return nil
- end
-
end
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 66562d7fb7..19559a7774 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -56,14 +56,14 @@ then repackaging it.
specs_and_sources, errors =
Gem::SpecFetcher.fetcher.spec_for_dependency dep
- if platform
+ if platform then
filtered = specs_and_sources.select { |s,| s.platform == platform }
specs_and_sources = filtered unless filtered.empty?
end
spec, source = specs_and_sources.max_by { |s,| s.version }
- if spec.nil?
+ if spec.nil? then
show_lookup_failure gem_name, version, errors, options[:domain]
next
end
@@ -75,3 +75,4 @@ then repackaging it.
end
end
+
diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
index 6dccdcb946..0b677b73a9 100644
--- a/lib/rubygems/commands/generate_index_command.rb
+++ b/lib/rubygems/commands/generate_index_command.rb
@@ -25,9 +25,6 @@ class Gem::Commands::GenerateIndexCommand < Gem::Command
options[:build_modern] = value
end
- deprecate_option('--modern', version: '4.0', extra_msg: 'Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.')
- deprecate_option('--no-modern', version: '4.0', extra_msg: 'The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.')
-
add_option '--update',
'Update modern indexes with gems added',
'since the last update' do |value, options|
@@ -70,13 +67,13 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
options[:build_modern] = true
if not File.exist?(options[:directory]) or
- not File.directory?(options[:directory])
+ not File.directory?(options[:directory]) then
alert_error "unknown directory name #{options[:directory]}."
terminate_interaction 1
else
indexer = Gem::Indexer.new options.delete(:directory), options
- if options[:update]
+ if options[:update] then
indexer.update_index
else
indexer.generate_index
@@ -85,3 +82,4 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
end
end
+
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 259e8b5622..7d02022369 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -4,7 +4,7 @@ require 'rubygems/command'
class Gem::Commands::HelpCommand < Gem::Command
# :stopdoc:
- EXAMPLES = <<-EOF.freeze
+ EXAMPLES = <<-EOF
Some examples of 'gem' usage.
* Install 'rake', either from local directory or remote server:
@@ -38,7 +38,7 @@ Some examples of 'gem' usage.
* Create a gem:
- See https://guides.rubygems.org/make-your-own-gem/
+ See http://guides.rubygems.org/make-your-own-gem/
* See information about RubyGems:
@@ -53,7 +53,7 @@ Some examples of 'gem' usage.
gem update --system
EOF
- GEM_DEPENDENCIES = <<-EOF.freeze
+ GEM_DEPENDENCIES = <<-EOF
A gem dependencies file allows installation of a consistent set of gems across
multiple environments. The RubyGems implementation is designed to be
compatible with Bundler's Gemfile format. You can see additional
@@ -230,7 +230,7 @@ default. This may be overridden with the :development_group option:
EOF
- PLATFORMS = <<-'EOF'.freeze
+ PLATFORMS = <<-'EOF'
RubyGems platforms are composed of three parts, a CPU, an OS, and a
version. These values are taken from values in rbconfig.rb. You can view
your current platform by running `gem environment`.
@@ -277,7 +277,7 @@ platform.
["examples", EXAMPLES],
["gem_dependencies", GEM_DEPENDENCIES],
["platforms", PLATFORMS],
- ].freeze
+ ]
# :startdoc:
def initialize
@@ -297,8 +297,8 @@ platform.
begins? command, arg
end
- if help
- if Symbol === help
+ if help then
+ if Symbol === help then
send help
else
say help
@@ -306,10 +306,10 @@ platform.
return
end
- if options[:help]
+ if options[:help] then
show_help
- elsif arg
+ elsif arg then
show_command_help arg
else
@@ -334,7 +334,7 @@ platform.
command = @command_manager[cmd_name]
summary =
- if command
+ if command then
command.summary
else
"[No command found for #{cmd_name}]"
@@ -356,15 +356,15 @@ platform.
say out.join("\n")
end
- def show_command_help(command_name) # :nodoc:
+ def show_command_help command_name # :nodoc:
command_name = command_name.downcase
possibilities = @command_manager.find_command_possibilities command_name
- if possibilities.size == 1
+ if possibilities.size == 1 then
command = @command_manager[possibilities.first]
command.invoke("--help")
- elsif possibilities.size > 1
+ elsif possibilities.size > 1 then
alert_warning "Ambiguous command #{command_name} (#{possibilities.join(', ')})"
else
alert_warning "Unknown command #{command_name}. Try: gem help commands"
@@ -372,3 +372,4 @@ platform.
end
end
+
diff --git a/lib/rubygems/commands/info_command.rb b/lib/rubygems/commands/info_command.rb
deleted file mode 100644
index 6a737b178b..0000000000
--- a/lib/rubygems/commands/info_command.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-require 'rubygems/command'
-require 'rubygems/commands/query_command'
-
-class Gem::Commands::InfoCommand < Gem::Commands::QueryCommand
-
- def initialize
- super "info", "Show information for the given gem"
-
- remove_option('--name-matches')
- remove_option('-d')
-
- defaults[:details] = true
- defaults[:exact] = true
- end
-
- def description # :nodoc:
- "Info prints information about the gem such as name,"\
- " description, website, license and installed paths"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME"
- end
-
- def arguments # :nodoc:
- "GEMNAME name of the gem to print information about"
- end
-
- def defaults_str
- "--local"
- end
-
-end
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 753ff33eb5..3a7d50517f 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -117,13 +117,6 @@ to write the specification by hand. For example:
some_extension_gem (1.0)
$
-Command Alias
-==========================
-
-You can use `i` command instead of `install`.
-
- $ gem i GEMNAME
-
EOF
end
@@ -132,7 +125,7 @@ You can use `i` command instead of `install`.
end
def check_install_dir # :nodoc:
- if options[:install_dir] and options[:user_install]
+ if options[:install_dir] and options[:user_install] then
alert_error "Use --install-dir or --user-install but not both"
terminate_interaction 1
end
@@ -140,22 +133,22 @@ You can use `i` command instead of `install`.
def check_version # :nodoc:
if options[:version] != Gem::Requirement.default and
- get_all_gem_names.size > 1
- alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ get_all_gem_names.size > 1 then
+ alert_error "Can't use --version w/ multiple gems. Use name:ver instead."
terminate_interaction 1
end
end
def execute
- if options.include? :gemdeps
+
+ if options.include? :gemdeps then
install_from_gemdeps
return # not reached
end
@installed_specs = []
- ENV.delete 'GEM_PATH' if options[:install_dir].nil?
+ ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
check_install_dir
check_version
@@ -188,27 +181,68 @@ You can use `i` command instead of `install`.
terminate_interaction
end
- def install_gem(name, version) # :nodoc:
+ def install_gem name, version # :nodoc:
return if options[:conservative] and
not Gem::Dependency.new(name, version).matching_specs.empty?
req = Gem::Requirement.create(version)
- dinst = Gem::DependencyInstaller.new options
+ if options[:ignore_dependencies] then
+ install_gem_without_dependencies name, req
+ else
+ inst = Gem::DependencyInstaller.new options
+ request_set = inst.resolve_dependencies name, req
- request_set = dinst.resolve_dependencies name, req
+ if options[:explain]
+ puts "Gems to install:"
- if options[:explain]
- say "Gems to install:"
+ request_set.sorted_requests.each do |s|
+ puts " #{s.full_name}"
+ end
- request_set.sorted_requests.each do |activation_request|
- say " #{activation_request.full_name}"
+ return
+ else
+ @installed_specs.concat request_set.install options
end
- else
- @installed_specs.concat request_set.install options
+
+ show_install_errors inst.errors
+ end
+ end
+
+ def install_gem_without_dependencies name, req # :nodoc:
+ gem = nil
+
+ if local? then
+ if name =~ /\.gem$/ and File.file? name then
+ source = Gem::Source::SpecificFile.new name
+ spec = source.spec
+ else
+ source = Gem::Source::Local.new
+ spec = source.find_gem name, req
+ end
+ gem = source.download spec if spec
end
- show_install_errors dinst.errors
+ if remote? and not gem then
+ dependency = Gem::Dependency.new name, req
+ dependency.prerelease = options[:prerelease]
+
+ fetcher = Gem::RemoteFetcher.fetcher
+ gem = fetcher.download_to_cache dependency
+ end
+
+ inst = Gem::Installer.at gem, options
+ inst.install
+
+ require 'rubygems/dependency_installer'
+ dinst = Gem::DependencyInstaller.new options
+ dinst.installed_gems.replace [inst.spec]
+
+ Gem.done_installing_hooks.each do |hook|
+ hook.call dinst, [inst.spec]
+ end unless Gem.done_installing_hooks.empty?
+
+ @installed_specs.push(inst.spec)
end
def install_gems # :nodoc:
@@ -216,22 +250,16 @@ You can use `i` command instead of `install`.
get_all_gem_names_and_versions.each do |gem_name, gem_version|
gem_version ||= options[:version]
- domain = options[:domain]
- domain = :local unless options[:suggest_alternate]
- supress_suggestions = (domain == :local)
begin
install_gem gem_name, gem_version
rescue Gem::InstallError => e
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
- rescue Gem::GemNotFoundException => e
- show_lookup_failure e.name, e.version, e.errors, supress_suggestions
-
- exit_code |= 2
- rescue Gem::UnsatisfiableDependencyError => e
- show_lookup_failure e.name, e.version, e.errors, supress_suggestions,
- "'#{gem_name}' (#{gem_version})"
+ rescue Gem::GemNotFoundException, Gem::UnsatisfiableDependencyError => e
+ domain = options[:domain]
+ domain = :local unless options[:suggest_alternate]
+ show_lookup_failure e.name, e.version, e.errors, domain
exit_code |= 2
end
@@ -252,7 +280,7 @@ You can use `i` command instead of `install`.
require 'rubygems/rdoc'
end
- def show_install_errors(errors) # :nodoc:
+ def show_install_errors errors # :nodoc:
return unless errors
errors.each do |x|
@@ -272,3 +300,4 @@ You can use `i` command instead of `install`.
end
end
+
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index cd21543537..1acb49e5fb 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -38,3 +38,4 @@ To search for remote gems use the search command.
end
end
+
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
index ebb402a8bd..3eebfadc05 100644
--- a/lib/rubygems/commands/lock_command.rb
+++ b/lib/rubygems/commands/lock_command.rb
@@ -59,7 +59,7 @@ lock it down to the exact version.
end
def complain(message)
- if options[:strict]
+ if options[:strict] then
raise Gem::Exception, message
else
say "# #{message}"
@@ -78,7 +78,7 @@ lock it down to the exact version.
spec = Gem::Specification.load spec_path(full_name)
- if spec.nil?
+ if spec.nil? then
complain "Could not find gem #{full_name}, try using the full name"
next
end
@@ -90,7 +90,7 @@ lock it down to the exact version.
next if locked[dep.name]
candidates = dep.matching_specs
- if candidates.empty?
+ if candidates.empty? then
complain "Unable to satisfy '#{dep}' from currently installed gems"
else
pending << candidates.last.full_name
@@ -100,11 +100,12 @@ lock it down to the exact version.
end
def spec_path(gem_full_name)
- gemspecs = Gem.path.map do |path|
+ gemspecs = Gem.path.map { |path|
File.join path, "specifications", "#{gem_full_name}.gemspec"
- end
+ }
gemspecs.find { |path| File.exist? path }
end
end
+
diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb
index 4e2a41fa33..801c9c8927 100644
--- a/lib/rubygems/commands/mirror_command.rb
+++ b/lib/rubygems/commands/mirror_command.rb
@@ -3,7 +3,6 @@ require 'rubygems/command'
unless defined? Gem::Commands::MirrorCommand
class Gem::Commands::MirrorCommand < Gem::Command
-
def initialize
super('mirror', 'Mirror all gem files (requires rubygems-mirror)')
begin
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
index 8eaeb64ba9..059635e835 100644
--- a/lib/rubygems/commands/open_command.rb
+++ b/lib/rubygems/commands/open_command.rb
@@ -11,13 +11,13 @@ class Gem::Commands::OpenCommand < Gem::Command
def initialize
super 'open', 'Open gem sources in editor'
- add_option('-e', '--editor COMMAND', String,
- "Prepends COMMAND to gem path. Could be used to specify editor.") do |command, options|
- options[:editor] = command || get_env_editor
+ add_option('-e', '--editor EDITOR', String,
+ "Opens gem sources in EDITOR") do |editor, options|
+ options[:editor] = editor || get_env_editor
end
add_option('-v', '--version VERSION', String,
"Opens specific gem version") do |version|
- options[:version] = version
+ options[:version] = version
end
end
@@ -32,14 +32,14 @@ class Gem::Commands::OpenCommand < Gem::Command
def description # :nodoc:
<<-EOF
The open command opens gem in editor and changes current path
- to gem's source directory.
- Editor command can be specified with -e option, otherwise rubygems
- will look for editor in $EDITOR, $VISUAL and $GEM_EDITOR variables.
+ to gem's source directory. Editor can be specified with -e option,
+ otherwise rubygems will look for editor in $EDITOR, $VISUAL and
+ $GEM_EDITOR variables.
EOF
end
def usage # :nodoc:
- "#{program_name} GEMNAME [-e COMMAND]"
+ "#{program_name} GEMNAME [-e EDITOR]"
end
def get_env_editor
@@ -58,31 +58,24 @@ class Gem::Commands::OpenCommand < Gem::Command
terminate_interaction 1 unless found
end
- def open_gem(name)
+ def open_gem name
spec = spec_for name
-
return false unless spec
- if spec.default_gem?
- say "'#{name}' is a default gem and can't be opened."
- return false
- end
-
open_editor(spec.full_gem_path)
end
- def open_editor(path)
+ def open_editor path
Dir.chdir(path) do
system(*@editor.split(/\s+/) + [path])
end
end
- def spec_for(name)
+ def spec_for name
spec = Gem::Specification.find_all_by_name(name, @version).first
return spec if spec
say "Unable to find gem '#{name}'"
end
-
end
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb
index 035eaffcbc..70f6c02801 100644
--- a/lib/rubygems/commands/outdated_command.rb
+++ b/lib/rubygems/commands/outdated_command.rb
@@ -30,5 +30,4 @@ update the gems with the update or install commands.
say "#{spec.name} (#{spec.version} < #{remote_version})"
end
end
-
end
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index f8e68c48e7..cac6c5a17d 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -33,7 +33,6 @@ permission to.
super 'owner', 'Manage gem owners of a gem on the push server'
add_proxy_option
add_key_option
- add_otp_option
defaults.merge! :add => [], :remove => []
add_option '-a', '--add EMAIL', 'Add an owner' do |value, options|
@@ -62,9 +61,7 @@ permission to.
show_owners name
end
- def show_owners(name)
- Gem.load_yaml
-
+ def show_owners name
response = rubygems_api_request :get, "api/v1/gems/#{name}/owners.yaml" do |request|
request.add_field "Authorization", api_key
end
@@ -79,18 +76,22 @@ permission to.
end
end
- def add_owners(name, owners)
+ def add_owners name, owners
manage_owners :post, name, owners
end
- def remove_owners(name, owners)
+ def remove_owners name, owners
manage_owners :delete, name, owners
end
- def manage_owners(method, name, owners)
+ def manage_owners method, name, owners
owners.each do |owner|
begin
- response = send_owner_request(method, name, owner)
+ response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
+ request.set_form_data 'email' => owner
+ request.add_field "Authorization", api_key
+ end
+
action = method == :delete ? "Removing" : "Adding"
with_response response, "#{action} #{owner}"
@@ -100,14 +101,4 @@ permission to.
end
end
- private
-
- def send_owner_request(method, name, owner)
- rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
- request.set_form_data 'email' => owner
- request.add_field "Authorization", api_key
- request.add_field "OTP", options[:otp] if options[:otp]
- end
- end
-
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 2248a821c8..fafe35bec1 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -24,8 +24,7 @@ class Gem::Commands::PristineCommand < Gem::Command
add_option('--skip=gem_name',
'used on --all, skip if name == gem_name') do |value, options|
- options[:skip] ||= []
- options[:skip] << value
+ options[:skip] = value
end
add_option('--[no-]extensions',
@@ -46,12 +45,6 @@ class Gem::Commands::PristineCommand < Gem::Command
options[:env_shebang] = value
end
- add_option('-n', '--bindir DIR',
- 'Directory where executables are',
- 'located') do |value, options|
- options[:bin_dir] = File.expand_path(value)
- end
-
add_version_option('restore to', 'pristine condition')
end
@@ -88,13 +81,13 @@ extensions will be restored.
end
def execute
- specs = if options[:all]
+ specs = if options[:all] then
Gem::Specification.map
# `--extensions` must be explicitly given to pristine only gems
# with extensions.
elsif options[:extensions_set] and
- options[:extensions] and options[:args].empty?
+ options[:extensions] and options[:args].empty? then
Gem::Specification.select do |spec|
spec.extensions and not spec.extensions.empty?
end
@@ -104,13 +97,16 @@ extensions will be restored.
end.flatten
end
- specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
-
- if specs.to_a.empty?
+ if specs.to_a.empty? then
raise Gem::Exception,
"Failed to find gems #{options[:args]} #{options[:version]}"
end
+ install_dir = Gem.dir # TODO use installer option
+
+ raise Gem::FilePermissionError.new(install_dir) unless
+ File.writable?(install_dir)
+
say "Restoring gems to pristine condition..."
specs.each do |spec|
@@ -119,21 +115,24 @@ extensions will be restored.
next
end
- if options.has_key? :skip
- if options[:skip].include? spec.name
- say "Skipped #{spec.full_name}, it was given through options"
- next
- end
+ if spec.name == options[:skip]
+ say "Skipped #{spec.full_name}, it was given through options"
+ next
+ end
+
+ if spec.bundled_gem_in_old_ruby?
+ say "Skipped #{spec.full_name}, it is bundled with old Ruby"
+ next
end
- unless spec.extensions.empty? or options[:extensions] or options[:only_executables]
+ unless spec.extensions.empty? or options[:extensions] or options[:only_executables] then
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
end
gem = spec.cache_file
- unless File.exist? gem or options[:only_executables]
+ unless File.exist? gem or options[:only_executables] then
require 'rubygems/remote_fetcher'
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
@@ -151,25 +150,22 @@ extensions will be restored.
end
env_shebang =
- if options.include? :env_shebang
+ if options.include? :env_shebang then
options[:env_shebang]
else
install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install']
install_defaults.to_s['--env-shebang']
end
- bin_dir = options[:bin_dir] if options[:bin_dir]
-
installer_options = {
:wrappers => true,
:force => true,
:install_dir => spec.base_dir,
:env_shebang => env_shebang,
:build_args => spec.build_args,
- :bin_dir => bin_dir
}
- if options[:only_executables]
+ if options[:only_executables] then
installer = Gem::Installer.for_spec(spec, installer_options)
installer.generate_bin
else
@@ -180,5 +176,4 @@ extensions will be restored.
say "Restored #{spec.full_name}"
end
end
-
end
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 41e6c7ec30..d294cbc8df 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -5,7 +5,6 @@ require 'rubygems/gemcutter_utilities'
require 'rubygems/package'
class Gem::Commands::PushCommand < Gem::Command
-
include Gem::LocalRemoteOptions
include Gem::GemcutterUtilities
@@ -14,10 +13,8 @@ class Gem::Commands::PushCommand < Gem::Command
The push command uploads a gem to the push server (the default is
https://rubygems.org) and adds it to the index.
-The gem can be removed from the index and deleted from the server using the yank
+The gem can be removed from the index (but only the index) using the yank
command. For further discussion see the help for the yank command.
-
-The push command will use ~/.gem/credentials to authenticate to a server, but you can use the RubyGems environment variable GEM_HOST_API_KEY to set the api key to authenticate.
EOF
end
@@ -32,58 +29,34 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
def initialize
super 'push', 'Push a gem up to the gem server', :host => self.host
- @user_defined_host = false
-
add_proxy_option
add_key_option
- add_otp_option
add_option('--host HOST',
'Push to another gemcutter-compatible host',
' (e.g. https://rubygems.org)') do |value, options|
options[:host] = value
- @user_defined_host = true
end
@host = nil
end
def execute
- gem_name = get_one_gem_name
- default_gem_server, push_host = get_hosts_for(gem_name)
-
- default_host = nil
- user_defined_host = nil
-
- if @user_defined_host
- user_defined_host = options[:host]
- else
- default_host = options[:host]
- end
-
- @host = if user_defined_host
- user_defined_host
- elsif default_gem_server
- default_gem_server
- elsif push_host
- push_host
- else
- default_host
- end
+ @host = options[:host]
sign_in @host
- send_gem(gem_name)
+ send_gem get_one_gem_name
end
- def send_gem(name)
+ def send_gem name
args = [:post, "api/v1/gems"]
latest_rubygems_version = Gem.latest_rubygems_version
if latest_rubygems_version < Gem.rubygems_version and
Gem.rubygems_version.prerelease? and
- Gem::Version.new('2.0.0.rc.2') != Gem.rubygems_version
+ Gem::Version.new('2.0.0.rc.2') != Gem.rubygems_version then
alert_error <<-ERROR
You are using a beta release of RubyGems (#{Gem::VERSION}) which is not
allowed to push gems. Please downgrade or upgrade to a release version.
@@ -100,7 +73,7 @@ You can upgrade or downgrade to the latest release version with:
gem_data = Gem::Package.new(name)
- unless @host
+ unless @host then
@host = gem_data.spec.metadata['default_gem_server']
end
@@ -117,30 +90,15 @@ You can upgrade or downgrade to the latest release version with:
say "Pushing gem to #{@host || Gem.host}..."
- response = send_push_request(name, args)
-
- with_response response
- end
-
- private
-
- def send_push_request(name, args)
- rubygems_api_request(*args) do |request|
+ response = rubygems_api_request(*args) do |request|
request.body = Gem.read_binary name
request.add_field "Content-Length", request.body.size
request.add_field "Content-Type", "application/octet-stream"
request.add_field "Authorization", api_key
- request.add_field "OTP", options[:otp] if options[:otp]
end
- end
-
- def get_hosts_for(name)
- gem_metadata = Gem::Package.new(name).spec.metadata
- [
- gem_metadata["default_gem_server"],
- gem_metadata["allowed_push_host"]
- ]
+ with_response response
end
end
+
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index 4fb23bc6c1..4624e5a1e9 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -39,7 +39,7 @@ class Gem::Commands::QueryCommand < Gem::Command
options[:details] = value
end
- add_option('--[no-]versions',
+ add_option( '--[no-]versions',
'Display only gem names') do |value, options|
options[:versions] = value
options[:details] = false unless value
@@ -56,7 +56,7 @@ class Gem::Commands::QueryCommand < Gem::Command
options[:exact] = value
end
- add_option('--[no-]prerelease',
+ add_option( '--[no-]prerelease',
'Display prerelease versions') do |value, options|
options[:prerelease] = value
end
@@ -78,61 +78,49 @@ is too hard to use.
end
def execute
- gem_names = Array(options[:name])
-
- if !args.empty?
- gem_names = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
- end
-
- terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems?
-
- gem_names.each { |n| show_gems(n) }
- end
-
- private
-
- def check_installed_gems(gem_names)
exit_code = 0
-
- if args.empty? && !gem_name?
- alert_error "You must specify a gem name"
- exit_code = 4
- elsif gem_names.count > 1
- alert_error "You must specify only ONE gem!"
- exit_code = 4
+ if options[:args].to_a.empty? and options[:name].source.empty?
+ name = options[:name]
+ no_name = true
+ elsif !options[:name].source.empty?
+ name = Array(options[:name])
else
- installed = installed?(gem_names.first, options[:version])
- installed = !installed unless options[:installed]
-
- say(installed)
- exit_code = 1 if !installed
+ args = options[:args].to_a
+ name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
end
- exit_code
- end
+ prerelease = options[:prerelease]
- def check_installed_gems?
- !options[:installed].nil?
- end
+ unless options[:installed].nil? then
+ if no_name then
+ alert_error "You must specify a gem name"
+ exit_code |= 4
+ elsif name.count > 1
+ alert_error "You must specify only ONE gem!"
+ exit_code |= 4
+ else
+ installed = installed? name.first, options[:version]
+ installed = !installed unless options[:installed]
- def gem_name?
- !options[:name].source.empty?
- end
+ if installed then
+ say "true"
+ else
+ say "false"
+ exit_code |= 1
+ end
+ end
- def prerelease
- options[:prerelease]
- end
+ terminate_interaction exit_code
+ end
- def show_prereleases?
- prerelease.nil? || prerelease
+ names = Array(name)
+ names.each { |n| show_gems n, prerelease }
end
- def args
- options[:args].to_a
- end
+ private
- def display_header(type)
- if (ui.outs.tty? and Gem.configuration.verbose) or both?
+ def display_header type
+ if (ui.outs.tty? and Gem.configuration.verbose) or both? then
say
say "*** #{type} GEMS ***"
say
@@ -140,57 +128,56 @@ is too hard to use.
end
#Guts of original execute
- def show_gems(name)
- show_local_gems(name) if local?
- show_remote_gems(name) if remote?
- end
-
- def show_local_gems(name, req = Gem::Requirement.default)
- display_header("LOCAL")
-
- specs = Gem::Specification.find_all do |s|
- s.name =~ name and req =~ s.version
- end
-
+ def show_gems name, prerelease
+ req = Gem::Requirement.default
+ # TODO: deprecate for real
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
- specs.select! do |s|
- dep.match?(s.name, s.version, show_prereleases?)
- end
+ dep.prerelease = prerelease
- spec_tuples = specs.map do |spec|
- [spec.name_tuple, spec]
- end
-
- output_query_results(spec_tuples)
- end
+ if local? then
+ if prerelease and not both? then
+ alert_warning "prereleases are always shown locally"
+ end
- def show_remote_gems(name)
- display_header("REMOTE")
+ display_header 'LOCAL'
- fetcher = Gem::SpecFetcher.fetcher
+ specs = Gem::Specification.find_all { |s|
+ s.name =~ name and req =~ s.version
+ }
- spec_tuples = if name.respond_to?(:source) && name.source.empty?
- fetcher.detect(specs_type) { true }
- else
- fetcher.detect(specs_type) do |name_tuple|
- name === name_tuple.name
- end
- end
+ spec_tuples = specs.map do |spec|
+ [spec.name_tuple, spec]
+ end
- output_query_results(spec_tuples)
- end
+ output_query_results spec_tuples
+ end
- def specs_type
- if options[:all]
- if options[:prerelease]
- :complete
+ if remote? then
+ display_header 'REMOTE'
+
+ fetcher = Gem::SpecFetcher.fetcher
+
+ type = if options[:all]
+ if options[:prerelease]
+ :complete
+ else
+ :released
+ end
+ elsif options[:prerelease]
+ :prerelease
+ else
+ :latest
+ end
+
+ if name.respond_to?(:source) && name.source.empty?
+ spec_tuples = fetcher.detect(type) { true }
else
- :released
+ spec_tuples = fetcher.detect(type) do |name_tuple|
+ name === name_tuple.name
+ end
end
- elsif options[:prerelease]
- :prerelease
- else
- :latest
+
+ output_query_results spec_tuples
end
end
@@ -218,7 +205,7 @@ is too hard to use.
say output.join(options[:details] ? "\n\n" : "\n")
end
- def output_versions(output, versions)
+ def output_versions output, versions
versions.each do |gem_name, matching_tuples|
matching_tuples = matching_tuples.sort_by { |n,_| n.version }.reverse
@@ -231,7 +218,7 @@ is too hard to use.
seen = {}
matching_tuples.delete_if do |n,_|
- if seen[n.version]
+ if seen[n.version] then
true
else
seen[n.version] = true
@@ -243,12 +230,12 @@ is too hard to use.
end
end
- def entry_details(entry, detail_tuple, specs, platforms)
+ def entry_details entry, detail_tuple, specs, platforms
return unless options[:details]
name_tuple, spec = detail_tuple
- spec = spec.fetch_spec(name_tuple)if spec.respond_to?(:fetch_spec)
+ spec = spec.fetch_spec name_tuple if spec.respond_to? :fetch_spec
entry << "\n"
@@ -260,11 +247,11 @@ is too hard to use.
spec_summary entry, spec
end
- def entry_versions(entry, name_tuples, platforms, specs)
+ def entry_versions entry, name_tuples, platforms, specs
return unless options[:versions]
list =
- if platforms.empty? or options[:details]
+ if platforms.empty? or options[:details] then
name_tuples.map { |n| n.version }.uniq
else
platforms.sort.reverse.map do |version, pls|
@@ -277,7 +264,7 @@ is too hard to use.
out = "default: #{out}" if default
end
- if pls != [Gem::Platform::RUBY]
+ if pls != [Gem::Platform::RUBY] then
platform_list = [pls.delete(Gem::Platform::RUBY), *pls.sort].compact
out = platform_list.unshift(out).join(' ')
end
@@ -289,7 +276,7 @@ is too hard to use.
entry << " (#{list.join ', '})"
end
- def make_entry(entry_tuples, platforms)
+ def make_entry entry_tuples, platforms
detail_tuple = entry_tuples.first
name_tuples, specs = entry_tuples.flatten.partition do |item|
@@ -298,25 +285,25 @@ is too hard to use.
entry = [name_tuples.first.name]
- entry_versions(entry, name_tuples, platforms, specs)
- entry_details(entry, detail_tuple, specs, platforms)
+ entry_versions entry, name_tuples, platforms, specs
+ entry_details entry, detail_tuple, specs, platforms
entry.join
end
- def spec_authors(entry, spec)
+ def spec_authors entry, spec
authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup
authors << spec.authors.join(', ')
entry << format_text(authors, 68, 4)
end
- def spec_homepage(entry, spec)
+ def spec_homepage entry, spec
return if spec.homepage.nil? or spec.homepage.empty?
entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4)
end
- def spec_license(entry, spec)
+ def spec_license entry, spec
return if spec.license.nil? or spec.license.empty?
licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup
@@ -324,10 +311,10 @@ is too hard to use.
entry << "\n" << format_text(licenses, 68, 4)
end
- def spec_loaded_from(entry, spec, specs)
+ def spec_loaded_from entry, spec, specs
return unless spec.loaded_from
- if specs.length == 1
+ if specs.length == 1 then
default = spec.default_gem? ? ' (default)' : nil
entry << "\n" << " Installed at#{default}: #{spec.base_dir}"
else
@@ -341,22 +328,21 @@ is too hard to use.
end
end
- def spec_platforms(entry, platforms)
+ def spec_platforms entry, platforms
non_ruby = platforms.any? do |_, pls|
pls.any? { |pl| pl != Gem::Platform::RUBY }
end
return unless non_ruby
- if platforms.length == 1
+ if platforms.length == 1 then
title = platforms.values.length == 1 ? 'Platform' : 'Platforms'
- entry << " #{title}: #{platforms.values.sort.join(', ')}\n"
+ entry << " #{title}: #{platforms.values.sort.join ', '}\n"
else
entry << " Platforms:\n"
-
- sorted_platforms = platforms.sort_by { |version,| version }
-
- sorted_platforms.each do |version, pls|
+ platforms.sort_by do |version,|
+ version
+ end.each do |version, pls|
label = " #{version}: "
data = format_text pls.sort.join(', '), 68, label.length
data[0, label.length] = label
@@ -365,7 +351,7 @@ is too hard to use.
end
end
- def spec_summary(entry, spec)
+ def spec_summary entry, spec
summary = truncate_text(spec.summary, "the summary for #{spec.full_name}")
entry << "\n\n" << format_text(summary, 68, 4)
end
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index ff9e1ffcfa..6992040dca 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -5,7 +5,6 @@ require 'rubygems/rdoc'
require 'fileutils'
class Gem::Commands::RdocCommand < Gem::Command
-
include Gem::VersionOption
def initialize
@@ -61,7 +60,7 @@ Use --overwrite to force rebuilding of documentation.
end
def execute
- specs = if options[:all]
+ specs = if options[:all] then
Gem::Specification.to_a
else
get_all_gem_names.map do |name|
@@ -69,7 +68,7 @@ Use --overwrite to force rebuilding of documentation.
end.flatten.uniq
end
- if specs.empty?
+ if specs.empty? then
alert_error 'No matching gems found'
terminate_interaction 1
end
@@ -79,7 +78,7 @@ Use --overwrite to force rebuilding of documentation.
doc.force = options[:overwrite]
- if options[:overwrite]
+ if options[:overwrite] then
FileUtils.rm_rf File.join(spec.doc_dir, 'ri')
FileUtils.rm_rf File.join(spec.doc_dir, 'rdoc')
end
@@ -95,3 +94,4 @@ Use --overwrite to force rebuilding of documentation.
end
end
+
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index c9cb1f2d43..933436d84d 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -38,3 +38,4 @@ To list local gems use the list command.
end
end
+
diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb
index e91a8e5176..245156d50d 100644
--- a/lib/rubygems/commands/server_command.rb
+++ b/lib/rubygems/commands/server_command.rb
@@ -9,7 +9,7 @@ class Gem::Commands::ServerCommand < Gem::Command
:port => 8808, :gemdir => [], :daemon => false
OptionParser.accept :Port do |port|
- if port =~ /\A\d+\z/
+ if port =~ /\A\d+\z/ then
port = Integer port
raise OptionParser::InvalidArgument, "#{port}: not a port number" if
port > 65535
@@ -84,3 +84,4 @@ You can set up a shortcut to gem server documentation using the URL:
end
end
+
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 579776df7e..ee6ce88eae 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -6,18 +6,14 @@ require 'rubygems/command'
# RubyGems checkout or tarball.
class Gem::Commands::SetupCommand < Gem::Command
-
- HISTORY_HEADER = /^===\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
- VERSION_MATCHER = /^===\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
-
- ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
+ HISTORY_HEADER = /^===\s*[\d.]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
+ VERSION_MATCHER = /^===\s*([\d.]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
def initialize
require 'tmpdir'
super 'setup', 'Install RubyGems',
:format_executable => true, :document => %w[ri],
- :force => true,
:site_or_vendor => 'sitelibdir',
:destdir => '', :prefix => '', :previous_version => '',
:regenerate_binstubs => true
@@ -64,7 +60,7 @@ class Gem::Commands::SetupCommand < Gem::Command
add_option '--[no-]rdoc',
'Generate RDoc documentation for RubyGems' do |value, options|
- if value
+ if value then
options[:document] << 'rdoc'
else
options[:document].delete 'rdoc'
@@ -75,7 +71,7 @@ class Gem::Commands::SetupCommand < Gem::Command
add_option '--[no-]ri',
'Generate RI documentation for RubyGems' do |value, options|
- if value
+ if value then
options[:document] << 'ri'
else
options[:document].delete 'ri'
@@ -87,26 +83,15 @@ class Gem::Commands::SetupCommand < Gem::Command
add_option '--[no-]regenerate-binstubs',
'Regenerate gem binstubs' do |value, options|
options[:regenerate_binstubs] = value
- end
-
- add_option '-f', '--[no-]force',
- 'Forcefully overwrite binstubs' do |value, options|
- options[:force] = value
- end
-
- add_option('-E', '--[no-]env-shebang',
- 'Rewrite executables with a shebang',
- 'of /usr/bin/env') do |value, options|
- options[:env_shebang] = value
- end
+ end
@verbose = nil
end
def check_ruby_version
- required_version = Gem::Requirement.new '>= 2.3.0'
+ required_version = Gem::Requirement.new '>= 1.8.7'
- unless required_version.satisfied_by? Gem.ruby_version
+ unless required_version.satisfied_by? Gem.ruby_version then
alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
terminate_interaction 1
end
@@ -134,19 +119,12 @@ By default, this RubyGems will install gem as:
EOF
end
- module MakeDirs
- def mkdir_p(path, **opts)
- super
- (@mkdirs ||= []) << path
- end
- end
-
def execute
@verbose = Gem.configuration.really_verbose
install_destdir = options[:destdir]
- unless install_destdir.empty?
+ unless install_destdir.empty? then
ENV['GEM_HOME'] ||= File.join(install_destdir,
Gem.default_dir.gsub(/^[a-zA-Z]:/, ''))
end
@@ -154,12 +132,11 @@ By default, this RubyGems will install gem as:
check_ruby_version
require 'fileutils'
- if Gem.configuration.really_verbose
+ if Gem.configuration.really_verbose then
extend FileUtils::Verbose
else
extend FileUtils
end
- extend MakeDirs
lib_dir, bin_dir = make_destination_dirs install_destdir
@@ -171,12 +148,7 @@ By default, this RubyGems will install gem as:
remove_old_lib_files lib_dir
- install_default_bundler_gem bin_dir
-
- if mode = options[:dir_mode]
- @mkdirs.uniq!
- File.chmod(mode, @mkdirs)
- end
+ install_default_bundler_gem
say "RubyGems #{Gem::VERSION} installed"
@@ -187,7 +159,7 @@ By default, this RubyGems will install gem as:
documentation_success = install_rdoc
say
- if @verbose
+ if @verbose then
say "-" * 78
say
end
@@ -205,17 +177,17 @@ By default, this RubyGems will install gem as:
say
say "RubyGems installed the following executables:"
- say bin_file_names.map { |name| "\t#{name}\n" }
+ say @bin_file_names.map { |name| "\t#{name}\n" }
say
- unless bin_file_names.grep(/#{File::SEPARATOR}gem$/)
+ unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/) then
say "If `gem` was installed by a previous RubyGems installation, you may need"
say "to remove it by hand."
say
end
if documentation_success
- if options[:document].include? 'rdoc'
+ if options[:document].include? 'rdoc' then
say "Rdoc documentation was installed. You may now invoke:"
say " gem server"
say "and then peruse beautifully formatted documentation for your gems"
@@ -226,7 +198,7 @@ By default, this RubyGems will install gem as:
say
end
- if options[:document].include? 'ri'
+ if options[:document].include? 'ri' then
say "Ruby Interactive (ri) documentation was installed. ri is kind of like man "
say "pages for Ruby libraries. You may access it like this:"
say " ri Classname"
@@ -240,32 +212,40 @@ By default, this RubyGems will install gem as:
end
end
+
def install_executables(bin_dir)
- prog_mode = options[:prog_mode] || 0755
+ @bin_file_names = []
executables = { 'gem' => 'bin' }
+ executables['bundler'] = 'bundler/exe' if Gem::USE_BUNDLER_FOR_GEMDEPS
executables.each do |tool, path|
say "Installing #{tool} executable" if @verbose
Dir.chdir path do
bin_files = Dir['*']
- bin_files -= %w[update_rubygems]
+ bin_files -= %w[update_rubygems bundler bundle_ruby]
bin_files.each do |bin_file|
- dest_file = target_bin_path(bin_dir, bin_file)
+ bin_file_formatted = if options[:format_executable] then
+ Gem.default_exec_format % bin_file
+ else
+ bin_file
+ end
+
+ dest_file = File.join bin_dir, bin_file_formatted
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
begin
bin = File.readlines bin_file
- bin[0] = shebang
+ bin[0] = "#!#{Gem.ruby}\n"
File.open bin_tmp_file, 'w' do |fp|
fp.puts bin.join
end
- install bin_tmp_file, dest_file, :mode => prog_mode
- bin_file_names << dest_file
+ install bin_tmp_file, dest_file, :mode => 0755
+ @bin_file_names << dest_file
ensure
rm bin_tmp_file
end
@@ -286,7 +266,7 @@ By default, this RubyGems will install gem as:
TEXT
end
- install bin_cmd_file, "#{dest_file}.bat", :mode => prog_mode
+ install bin_cmd_file, "#{dest_file}.bat", :mode => 0755
ensure
rm bin_cmd_file
end
@@ -295,29 +275,17 @@ By default, this RubyGems will install gem as:
end
end
- def shebang
- if options[:env_shebang]
- ruby_name = RbConfig::CONFIG['ruby_install_name']
- @env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
- "#!#{@env_path} #{ruby_name}\n"
- else
- "#!#{Gem.ruby}\n"
- end
- end
-
- def install_file(file, dest_dir)
+ def install_file file, dest_dir
dest_file = File.join dest_dir, file
dest_dir = File.dirname dest_file
- unless File.directory? dest_dir
- mkdir_p dest_dir, :mode => 0755
- end
+ mkdir_p dest_dir unless File.directory? dest_dir
- install file, dest_file, :mode => options[:data_mode] || 0644
+ install file, dest_file, :mode => 0644
end
def install_lib(lib_dir)
libs = { 'RubyGems' => 'lib' }
- libs['Bundler'] = 'bundler/lib'
+ libs['Bundler'] = 'bundler/lib' if Gem::USE_BUNDLER_FOR_GEMDEPS
libs.each do |tool, path|
say "Installing #{tool}" if @verbose
@@ -351,7 +319,7 @@ By default, this RubyGems will install gem as:
if File.writable? gem_doc_dir and
(not File.exist? rubygems_doc_dir or
- File.writable? rubygems_doc_dir)
+ File.writable? rubygems_doc_dir) then
say "Removing old RubyGems RDoc and ri" if @verbose
Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
rm_rf dir
@@ -371,7 +339,7 @@ By default, this RubyGems will install gem as:
rdoc.generate
return true
- elsif @verbose
+ elsif @verbose then
say "Skipping RDoc generation, #{gem_doc_dir} not writable"
say "Set the GEM_HOME environment variable if you want RDoc generated"
end
@@ -379,10 +347,12 @@ By default, this RubyGems will install gem as:
return false
end
- def install_default_bundler_gem(bin_dir)
- specs_dir = Gem.default_specifications_dir
+ def install_default_bundler_gem
+ return unless Gem::USE_BUNDLER_FOR_GEMDEPS
+
+ specs_dir = Gem::Specification.default_specifications_dir
specs_dir = File.join(options[:destdir], specs_dir) unless Gem.win_platform?
- mkdir_p specs_dir, :mode => 0755
+ mkdir_p specs_dir
# Workaround for non-git environment.
gemspec = File.open('bundler/bundler.gemspec', 'rb'){|f| f.read.gsub(/`git ls-files -z`/, "''") }
@@ -415,27 +385,22 @@ By default, this RubyGems will install gem as:
each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) }
end
- bundler_bin_dir = bundler_spec.bin_dir
+ bundler_bin_dir = File.join(Gem.default_dir, 'gems', bundler_spec.full_name, bundler_spec.bindir)
bundler_bin_dir = File.join(options[:destdir], bundler_bin_dir) unless Gem.win_platform?
- mkdir_p bundler_bin_dir, :mode => 0755
+ mkdir_p bundler_bin_dir
bundler_spec.executables.each do |e|
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
end
- require 'rubygems/installer'
+ if Gem.win_platform?
+ require 'rubygems/installer'
- Dir.chdir("bundler") do
- built_gem = Gem::Package.build(bundler_spec)
- begin
- installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], format_executable: options[:format_executable], force: options[:force], install_as_default: true, bin_dir: bin_dir, wrappers: true)
- installer.install
- ensure
- FileUtils.rm_f built_gem
+ installer = Gem::Installer.for_spec bundler_spec
+ bundler_spec.executables.each do |e|
+ installer.generate_windows_script e, bundler_spec.bin_dir
end
end
- bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
-
say "Bundler #{bundler_spec.version} installed"
end
@@ -446,8 +411,8 @@ By default, this RubyGems will install gem as:
lib_dir, bin_dir = generate_default_dirs(install_destdir)
end
- mkdir_p lib_dir, :mode => 0755
- mkdir_p bin_dir, :mode => 0755
+ mkdir_p lib_dir
+ mkdir_p bin_dir
return lib_dir, bin_dir
end
@@ -456,7 +421,7 @@ By default, this RubyGems will install gem as:
prefix = options[:prefix]
site_or_vendor = options[:site_or_vendor]
- if prefix.empty?
+ if prefix.empty? then
lib_dir = RbConfig::CONFIG[site_or_vendor]
bin_dir = RbConfig::CONFIG['bindir']
else
@@ -467,16 +432,16 @@ By default, this RubyGems will install gem as:
# just in case Apple and RubyGems don't get this patched up proper.
(prefix == RbConfig::CONFIG['libdir'] or
# this one is important
- prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby'))
- lib_dir = RbConfig::CONFIG[site_or_vendor]
- bin_dir = RbConfig::CONFIG['bindir']
+ prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then
+ lib_dir = RbConfig::CONFIG[site_or_vendor]
+ bin_dir = RbConfig::CONFIG['bindir']
else
lib_dir = File.join prefix, 'lib'
bin_dir = File.join prefix, 'bin'
end
end
- unless install_destdir.empty?
+ unless install_destdir.empty? then
lib_dir = File.join install_destdir, lib_dir.gsub(/^[a-zA-Z]:/, '')
bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '')
end
@@ -484,13 +449,13 @@ By default, this RubyGems will install gem as:
[lib_dir, bin_dir]
end
- def pem_files_in(dir)
+ def pem_files_in dir
Dir.chdir dir do
Dir[File.join('**', '*pem')]
end
end
- def rb_files_in(dir)
+ def rb_files_in dir
Dir.chdir dir do
Dir[File.join('**', '*rb')]
end
@@ -505,7 +470,7 @@ By default, this RubyGems will install gem as:
end
# for cleanup old bundler files
- def template_files_in(dir)
+ def template_files_in dir
Dir.chdir dir do
(Dir[File.join('templates', '**', '{*,.*}')]).
select{|f| !File.directory?(f)}
@@ -544,9 +509,9 @@ abort "#{deprecation_message}"
end
end
- def remove_old_lib_files(lib_dir)
+ def remove_old_lib_files lib_dir
lib_dirs = { File.join(lib_dir, 'rubygems') => 'lib/rubygems' }
- lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler'
+ lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler' if Gem::USE_BUNDLER_FOR_GEMDEPS
lib_dirs.each do |old_lib_dir, new_lib_dir|
lib_files = rb_files_in(new_lib_dir)
lib_files.concat(template_files_in(new_lib_dir)) if new_lib_dir =~ /bundler/
@@ -575,10 +540,11 @@ abort "#{deprecation_message}"
release_notes = File.join Dir.pwd, 'History.txt'
release_notes =
- if File.exist? release_notes
+ if File.exist? release_notes then
history = File.read release_notes
- history.force_encoding Encoding::UTF_8
+ history.force_encoding Encoding::UTF_8 if
+ Object.const_defined? :Encoding
history = history.sub(/^# coding:.*?(?=^=)/m, '')
@@ -592,7 +558,7 @@ abort "#{deprecation_message}"
history_string = ""
until versions.length == 0 or
- versions.shift <= options[:previous_version] do
+ versions.shift < options[:previous_version] do
history_string += version_lines.shift + text.shift
end
@@ -616,29 +582,8 @@ abort "#{deprecation_message}"
def regenerate_binstubs
require "rubygems/commands/pristine_command"
say "Regenerating binstubs"
-
- args = %w[--all --only-executables --silent]
- if options[:env_shebang]
- args << "--env-shebang"
- end
-
command = Gem::Commands::PristineCommand.new
- command.invoke(*args)
- end
-
- private
-
- def target_bin_path(bin_dir, bin_file)
- bin_file_formatted = if options[:format_executable]
- Gem.default_exec_format % bin_file
- else
- bin_file
- end
- File.join bin_dir, bin_file_formatted
- end
-
- def bin_file_names
- @bin_file_names ||= []
+ command.invoke(*%w[--all --only-executables --silent])
end
end
diff --git a/lib/rubygems/commands/signin_command.rb b/lib/rubygems/commands/signin_command.rb
index 7c4b5ceb69..6556db5a89 100644
--- a/lib/rubygems/commands/signin_command.rb
+++ b/lib/rubygems/commands/signin_command.rb
@@ -3,7 +3,6 @@ require 'rubygems/command'
require 'rubygems/gemcutter_utilities'
class Gem::Commands::SigninCommand < Gem::Command
-
include Gem::GemcutterUtilities
def initialize
@@ -11,10 +10,9 @@ class Gem::Commands::SigninCommand < Gem::Command
'It defaults to https://rubygems.org'
add_option('--host HOST', 'Push to another gemcutter-compatible host') do |value, options|
- options[:host] = value
+ options[:host] = value
end
- add_otp_option
end
def description # :nodoc:
diff --git a/lib/rubygems/commands/signout_command.rb b/lib/rubygems/commands/signout_command.rb
index 2d7329c590..2452e8cae1 100644
--- a/lib/rubygems/commands/signout_command.rb
+++ b/lib/rubygems/commands/signout_command.rb
@@ -19,9 +19,9 @@ class Gem::Commands::SignoutCommand < Gem::Command
def execute
credentials_path = Gem.configuration.credentials_path
- if !File.exist?(credentials_path)
+ if !File.exist?(credentials_path) then
alert_error 'You are not currently signed in.'
- elsif !File.writable?(credentials_path)
+ elsif !File.writable?(credentials_path) then
alert_error "File '#{Gem.configuration.credentials_path}' is read-only."\
' Please make sure it is writable.'
else
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index ca9d425232..7e46963a4c 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -38,15 +38,13 @@ class Gem::Commands::SourcesCommand < Gem::Command
add_proxy_option
end
- def add_source(source_uri) # :nodoc:
+ def add_source source_uri # :nodoc:
check_rubygems_https source_uri
source = Gem::Source.new source_uri
- check_typo_squatting(source)
-
begin
- if Gem.sources.include? source
+ if Gem.sources.include? source then
say "source #{source_uri} already present in the cache"
else
source.load_specs :released
@@ -64,23 +62,11 @@ class Gem::Commands::SourcesCommand < Gem::Command
end
end
- def check_typo_squatting(source)
- if source.typo_squatting?("rubygems.org")
- question = <<-QUESTION.chomp
-#{source.uri.to_s} is too similar to https://rubygems.org
-
-Do you want to add this source?
- QUESTION
-
- terminate_interaction 1 unless ask_yes_no question
- end
- end
-
- def check_rubygems_https(source_uri) # :nodoc:
+ def check_rubygems_https source_uri # :nodoc:
uri = URI source_uri
if uri.scheme and uri.scheme.downcase == 'http' and
- uri.host.downcase == 'rubygems.org'
+ uri.host.downcase == 'rubygems.org' then
question = <<-QUESTION.chomp
https://rubygems.org is recommended for security over #{uri}
@@ -95,10 +81,10 @@ Do you want to add this insecure source?
path = Gem.spec_cache_dir
FileUtils.rm_rf path
- unless File.exist? path
+ unless File.exist? path then
say "*** Removed specs cache ***"
else
- unless File.writable? path
+ unless File.writable? path then
say "*** Unable to remove source cache (write protected) ***"
else
say "*** Unable to remove source cache ***"
@@ -136,7 +122,7 @@ RubyGems has been configured to serve gems via the following URLs through
its history:
* http://gems.rubyforge.org (RubyGems 1.3.6 and earlier)
-* https://rubygems.org/ (RubyGems 1.3.7 through 1.8.25)
+* http://rubygems.org (RubyGems 1.3.7 through 1.8.25)
* https://rubygems.org (RubyGems 2.0.1 and newer)
Since all of these sources point to the same set of gems you only need one
@@ -153,8 +139,8 @@ before it is added.
To remove a source use the --remove argument:
- $ gem sources --remove https://rubygems.org/
- https://rubygems.org/ removed from sources
+ $ gem sources --remove http://rubygems.org
+ http://rubygems.org removed from sources
EOF
end
@@ -189,8 +175,8 @@ To remove a source use the --remove argument:
list if list?
end
- def remove_source(source_uri) # :nodoc:
- unless Gem.sources.include? source_uri
+ def remove_source source_uri # :nodoc:
+ unless Gem.sources.include? source_uri then
say "source #{source_uri} not present in cache"
else
Gem.sources.delete source_uri
@@ -209,12 +195,12 @@ To remove a source use the --remove argument:
say "source cache successfully updated"
end
- def remove_cache_file(desc, path) # :nodoc:
+ def remove_cache_file desc, path # :nodoc:
FileUtils.rm_rf path
- if not File.exist?(path)
+ if not File.exist?(path) then
say "*** Removed #{desc} source cache ***"
- elsif not File.writable?(path)
+ elsif not File.writable?(path) then
say "*** Unable to remove #{desc} source cache (write protected) ***"
else
say "*** Unable to remove #{desc} source cache ***"
@@ -222,3 +208,4 @@ To remove a source use the --remove argument:
end
end
+
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 7326822ad7..ad8840adc2 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -75,7 +75,7 @@ Specific fields in the specification can be extracted in YAML format:
specs = []
gem = options[:args].shift
- unless gem
+ unless gem then
raise Gem::CommandLineError,
"Please specify a gem name or file on the command line"
end
@@ -105,29 +105,29 @@ Specific fields in the specification can be extracted in YAML format:
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
field and options[:format] == :ruby
- if local?
- if File.exist? gem
+ if local? then
+ if File.exist? gem then
specs << Gem::Package.new(gem).spec rescue nil
end
- if specs.empty?
+ if specs.empty? then
specs.push(*dep.matching_specs)
end
end
- if remote?
+ if remote? then
dep.prerelease = options[:prerelease]
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
specs.push(*found.map { |spec,| spec })
end
- if specs.empty?
+ if specs.empty? then
alert_error "No gem matching '#{dep}' found"
terminate_interaction 1
end
- unless options[:all]
+ unless options[:all] then
specs = [specs.max_by { |s| s.version }]
end
@@ -143,5 +143,4 @@ Specific fields in the specification can be extracted in YAML format:
say "\n"
end
end
-
end
diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb
index 89bafeae98..0524ee1e2b 100644
--- a/lib/rubygems/commands/stale_command.rb
+++ b/lib/rubygems/commands/stale_command.rb
@@ -2,7 +2,6 @@
require 'rubygems/command'
class Gem::Commands::StaleCommand < Gem::Command
-
def initialize
super('stale', 'List gems along with access times')
end
@@ -37,5 +36,4 @@ longer using.
say "#{name} at #{atime.strftime '%c'}"
end
end
-
end
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index c1a9dbba32..20b3a7a1e4 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -20,7 +20,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
add_option('-a', '--[no-]all',
'Uninstall all matching versions'
- ) do |value, options|
+ ) do |value, options|
options[:all] = value
end
@@ -48,7 +48,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
end
add_option('-n', '--bindir DIR',
- 'Directory to remove executables from') do |value, options|
+ 'Directory to remove binaries from') do |value, options|
options[:bin_dir] = File.expand_path(value)
end
@@ -81,7 +81,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
add_option('--vendor',
'Uninstall gem from the vendor directory.',
'Only for use by gem repackagers.') do |value, options|
- unless Gem.vendor_dir
+ unless Gem.vendor_dir then
raise OptionParser::InvalidOption.new 'your platform is not supported'
end
@@ -114,21 +114,10 @@ that is a dependency of an existing gem. You can use the
"#{program_name} GEMNAME [GEMNAME ...]"
end
- def check_version # :nodoc:
- if options[:version] != Gem::Requirement.default and
- get_all_gem_names.size > 1
- alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
- terminate_interaction 1
- end
- end
-
def execute
- check_version
-
- if options[:all] and not options[:args].empty?
+ if options[:all] and not options[:args].empty? then
uninstall_specific
- elsif options[:all]
+ elsif options[:all] then
uninstall_all
else
uninstall_specific
@@ -140,21 +129,21 @@ that is a dependency of an existing gem. You can use the
specs.each do |spec|
options[:version] = spec.version
- uninstall_gem spec.name
+
+ begin
+ Gem::Uninstaller.new(spec.name, options).uninstall
+ rescue Gem::InstallError
+ end
end
- alert "Uninstalled all gems in #{options[:install_dir] || Gem.dir}"
+ alert "Uninstalled all gems in #{options[:install_dir]}"
end
def uninstall_specific
deplist = Gem::DependencyList.new
- original_gem_version = {}
-
- get_all_gem_names_and_versions.each do |name, version|
- original_gem_version[name] = version || options[:version]
-
- gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name])
+ get_all_gem_names.uniq.each do |name|
+ gem_specs = Gem::Specification.find_all_by_name(name)
say("Gem '#{name}' is not installed") if gem_specs.empty?
gem_specs.each do |spec|
deplist.add spec
@@ -163,37 +152,15 @@ that is a dependency of an existing gem. You can use the
deps = deplist.strongly_connected_components.flatten.reverse
- gems_to_uninstall = {}
-
- deps.each do |dep|
- unless gems_to_uninstall[dep.name]
- gems_to_uninstall[dep.name] = true
-
- unless original_gem_version[dep.name] == Gem::Requirement.default
- options[:version] = dep.version
- end
-
- uninstall_gem(dep.name)
+ deps.map(&:name).uniq.each do |gem_name|
+ begin
+ Gem::Uninstaller.new(gem_name, options).uninstall
+ rescue Gem::GemNotInHomeException => e
+ spec = e.spec
+ alert("In order to remove #{spec.name}, please execute:\n" +
+ "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
end
end
end
- def uninstall_gem(gem_name)
- uninstall(gem_name)
- rescue Gem::GemNotInHomeException => e
- spec = e.spec
- alert("In order to remove #{spec.name}, please execute:\n" +
- "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
- rescue Gem::UninstallError => e
- spec = e.spec
- alert_error("Error: unable to successfully uninstall '#{spec.name}' which is " +
- "located at '#{spec.full_gem_path}'. This is most likely because" +
- "the current user does not have the appropriate permissions")
- terminate_interaction 1
- end
-
- def uninstall(gem_name)
- Gem::Uninstaller.new(gem_name, options).uninstall
- end
-
end
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index 09829d873c..b873f20d28 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
require 'rubygems/command'
+require 'rubygems/installer'
require 'rubygems/version_option'
require 'rubygems/security_option'
require 'rubygems/remote_fetcher'
-require 'rubygems/package'
# forward-declare
@@ -79,32 +79,22 @@ command help for an example.
dependency = Gem::Dependency.new name, options[:version]
path = get_path dependency
- unless path
+ unless path then
alert_error "Gem '#{name}' not installed nor fetchable."
next
end
- if @options[:spec]
- spec, metadata = Gem::Package.raw_spec(path, security_policy)
+ if @options[:spec] then
+ spec, metadata = get_metadata path, security_policy
- if metadata.nil?
+ if metadata.nil? then
alert_error "--spec is unsupported on '#{name}' (old format gem)"
next
end
spec_file = File.basename spec.spec_file
- FileUtils.mkdir_p @options[:target] if @options[:target]
-
- destination = begin
- if @options[:target]
- File.join @options[:target], spec_file
- else
- spec_file
- end
- end
-
- File.open destination, 'w' do |io|
+ File.open spec_file, 'w' do |io|
io.write metadata
end
else
@@ -152,7 +142,7 @@ command help for an example.
# TODO: It just uses Gem.dir for now. What's an easy way to get the list of
# source directories?
- def get_path(dependency)
+ def get_path dependency
return dependency.name if dependency.name =~ /\.gem$/i
specs = dependency.matching_specs
@@ -174,4 +164,32 @@ command help for an example.
path
end
+ ##
+ # Extracts the Gem::Specification and raw metadata from the .gem file at
+ # +path+.
+ #--
+ # TODO move to Gem::Package as #raw_spec or something
+
+ def get_metadata path, security_policy = nil
+ format = Gem::Package.new path, security_policy
+ spec = format.spec
+
+ metadata = nil
+
+ File.open path, Gem.binary_mode do |io|
+ tar = Gem::Package::TarReader.new io
+ tar.each_entry do |entry|
+ case entry.full_name
+ when 'metadata' then
+ metadata = entry.read
+ when 'metadata.gz' then
+ metadata = Gem.gunzip entry.read
+ end
+ end
+ end
+
+ return spec, metadata
+ end
+
end
+
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index e8031a259d..93ee60e1ab 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -68,8 +68,8 @@ command to remove old versions.
"#{program_name} GEMNAME [GEMNAME ...]"
end
- def check_latest_rubygems(version) # :nodoc:
- if Gem.rubygems_version == version
+ def check_latest_rubygems version # :nodoc:
+ if Gem.rubygems_version == version then
say "Latest version already installed. Done."
terminate_interaction
end
@@ -78,40 +78,31 @@ command to remove old versions.
end
def check_update_arguments # :nodoc:
- unless options[:args].empty?
+ unless options[:args].empty? then
alert_error "Gem names are not allowed with the --system option"
terminate_interaction 1
end
end
def execute
- if options[:system]
+
+ if options[:system] then
update_rubygems
return
end
+ say "Updating installed gems"
+
hig = highest_installed_gems
gems_to_update = which_to_update hig, options[:args].uniq
- if options[:explain]
- say "Gems to update:"
-
- gems_to_update.each do |name_tuple|
- say " #{name_tuple.full_name}"
- end
-
- return
- end
-
- say "Updating installed gems"
-
updated = update_gems gems_to_update
updated_names = updated.map { |spec| spec.name }
not_updated_names = options[:args].uniq - updated_names
- if updated.empty?
+ if updated.empty? then
say "Nothing to update"
else
say "Gems updated: #{updated_names.join(' ')}"
@@ -119,7 +110,7 @@ command to remove old versions.
end
end
- def fetch_remote_gems(spec) # :nodoc:
+ def fetch_remote_gems spec # :nodoc:
dependency = Gem::Dependency.new spec.name, "> #{spec.version}"
dependency.prerelease = options[:prerelease]
@@ -138,7 +129,7 @@ command to remove old versions.
hig = {} # highest installed gems
Gem::Specification.each do |spec|
- if hig[spec.name].nil? or hig[spec.name].version < spec.version
+ if hig[spec.name].nil? or hig[spec.name].version < spec.version then
hig[spec.name] = spec
end
end
@@ -146,21 +137,21 @@ command to remove old versions.
hig
end
- def highest_remote_name_tuple(spec) # :nodoc:
+ def highest_remote_version spec # :nodoc:
spec_tuples = fetch_remote_gems spec
matching_gems = spec_tuples.select do |g,_|
g.name == spec.name and g.match_platform?
end
- highest_remote_gem = matching_gems.max
+ highest_remote_gem = matching_gems.max_by { |g,_| g.version }
highest_remote_gem ||= [Gem::NameTuple.null]
- highest_remote_gem.first
+ highest_remote_gem.first.version
end
- def install_rubygems(version) # :nodoc:
+ def install_rubygems version # :nodoc:
args = update_rubygems_arguments
update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
@@ -168,8 +159,12 @@ command to remove old versions.
Dir.chdir update_dir do
say "Installing RubyGems #{version}"
- installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args
+ # Make sure old rubygems isn't loaded
+ old = ENV["RUBYOPT"]
+ ENV.delete("RUBYOPT") if old
+ installed = system Gem.ruby, 'setup.rb', *args
say "RubyGems system software updated" if installed
+ ENV["RUBYOPT"] = old if old
end
end
@@ -177,7 +172,7 @@ command to remove old versions.
version = options[:system]
update_latest = version == true
- if update_latest
+ if update_latest then
version = Gem::Version.new Gem::VERSION
requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
else
@@ -194,9 +189,9 @@ command to remove old versions.
}
gems_to_update = which_to_update hig, options[:args], :system
- up_ver = gems_to_update.first.version
+ _, up_ver = gems_to_update.first
- target = if update_latest
+ target = if update_latest then
up_ver
else
version
@@ -205,7 +200,7 @@ command to remove old versions.
return target, requirement
end
- def update_gem(name, version = Gem::Requirement.default)
+ def update_gem name, version = Gem::Requirement.default
return if @updated.any? { |spec| spec.name == name }
update_options = options.dup
@@ -225,9 +220,9 @@ command to remove old versions.
end
end
- def update_gems(gems_to_update)
- gems_to_update.uniq.sort.each do |name_tuple|
- update_gem name_tuple.name, name_tuple.version
+ def update_gems gems_to_update
+ gems_to_update.uniq.sort.each do |(name, version)|
+ update_gem name, version
end
@updated
@@ -254,7 +249,9 @@ command to remove old versions.
def update_rubygems_arguments # :nodoc:
args = []
args << '--prefix' << Gem.prefix if Gem.prefix
- args << '--no-document' unless options[:document].include?('rdoc') || options[:document].include?('ri')
+ # TODO use --document for >= 1.9 , --no-rdoc --no-ri < 1.9
+ args << '--no-rdoc' unless options[:document].include? 'rdoc'
+ args << '--no-ri' unless options[:document].include? 'ri'
args << '--no-format-executable' if options[:no_format_executable]
args << '--previous-version' << Gem::VERSION if
options[:system] == true or
@@ -262,19 +259,17 @@ command to remove old versions.
args
end
- def which_to_update(highest_installed_gems, gem_names, system = false)
+ def which_to_update highest_installed_gems, gem_names, system = false
result = []
highest_installed_gems.each do |l_name, l_spec|
next if not gem_names.empty? and
gem_names.none? { |name| name == l_spec.name }
- highest_remote_tup = highest_remote_name_tuple l_spec
- highest_remote_ver = highest_remote_tup.version
- highest_installed_ver = l_spec.version
+ highest_remote_ver = highest_remote_version l_spec
- if system or (highest_installed_ver < highest_remote_ver)
- result << Gem::NameTuple.new(l_spec.name, [highest_installed_ver, highest_remote_ver].max, highest_remote_tup.platform)
+ if system or (l_spec.version < highest_remote_ver) then
+ result << [l_spec.name, [l_spec.version, highest_remote_ver].max]
end
end
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index fca463a1ef..704d79fc60 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -2,7 +2,6 @@
require 'rubygems/command'
class Gem::Commands::WhichCommand < Gem::Command
-
def initialize
super 'which', 'Find the location of a library file you can require',
:search_gems_first => false, :show_all => false
@@ -45,19 +44,21 @@ requiring to see why it does not behave as you expect.
spec = Gem::Specification.find_by_path arg
- if spec
- if options[:search_gems_first]
+ if spec then
+ if options[:search_gems_first] then
dirs = spec.full_require_paths + $LOAD_PATH
else
dirs = $LOAD_PATH + spec.full_require_paths
end
end
+ # TODO: this is totally redundant and stupid
paths = find_paths arg, dirs
- if paths.empty?
+ if paths.empty? then
alert_error "Can't find Ruby library file or shared library #{arg}"
- found = false
+
+ found &&= false
else
say paths
end
@@ -72,7 +73,7 @@ requiring to see why it does not behave as you expect.
dirs.each do |dir|
Gem.suffixes.each do |ext|
full_path = File.join dir, "#{package_name}#{ext}"
- if File.exist? full_path and not File.directory? full_path
+ if File.exist? full_path and not File.directory? full_path then
result << full_path
return result unless options[:show_all]
end
@@ -87,3 +88,4 @@ requiring to see why it does not behave as you expect.
end
end
+
diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb
index 3ca05756f6..ebf24e5c77 100644
--- a/lib/rubygems/commands/yank_command.rb
+++ b/lib/rubygems/commands/yank_command.rb
@@ -5,7 +5,6 @@ require 'rubygems/version_option'
require 'rubygems/gemcutter_utilities'
class Gem::Commands::YankCommand < Gem::Command
-
include Gem::LocalRemoteOptions
include Gem::VersionOption
include Gem::GemcutterUtilities
@@ -33,7 +32,6 @@ data you will need to change them immediately and yank your gem.
add_version_option("remove")
add_platform_option("remove")
- add_otp_option
add_option('--host HOST',
'Yank from another gemcutter-compatible host',
@@ -53,7 +51,7 @@ data you will need to change them immediately and yank your gem.
version = get_version_from_requirements(options[:version])
platform = get_platform_from_requirements(options)
- if version
+ if version then
yank_gem(version, platform)
else
say "A version argument is required: #{usage}"
@@ -63,10 +61,7 @@ data you will need to change them immediately and yank your gem.
def yank_gem(version, platform)
say "Yanking gem from #{self.host}..."
- args = [:delete, version, platform, "api/v1/gems/yank"]
- response = yank_api_request(*args)
-
- say response.body
+ yank_api_request(:delete, version, platform, "api/v1/gems/yank")
end
private
@@ -75,7 +70,6 @@ data you will need to change them immediately and yank your gem.
name = get_one_gem_name
response = rubygems_api_request(method, api, host) do |request|
request.add_field("Authorization", api_key)
- request.add_field("OTP", options[:otp]) if options[:otp]
data = {
'gem_name' => name,
@@ -85,7 +79,7 @@ data you will need to change them immediately and yank your gem.
request.set_form_data data
end
- response
+ say response.body
end
def get_version_from_requirements(requirements)
@@ -99,3 +93,4 @@ data you will need to change them immediately and yank your gem.
end
end
+
diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb
index f1d452ea04..2056b5b53a 100644
--- a/lib/rubygems/compatibility.rb
+++ b/lib/rubygems/compatibility.rb
@@ -9,11 +9,31 @@
# Ruby 1.9.x has introduced some things that are awkward, and we need to
# support them, so we define some constants to use later.
#++
+module Gem
+ # Only MRI 1.9.2 has the custom prelude.
+ GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ and RUBY_ENGINE == "ruby"
+end
+
+# Gem::QuickLoader exists in the gem prelude code in ruby 1.9.2 itself.
+# We gotta get rid of it if it's there, before we do anything else.
+if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
+ Gem::QuickLoader.remove
+
+ $LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
+
+ if path = $LOADED_FEATURES.find {|n| n.end_with? '/rubygems.rb'} then
+ raise LoadError, "another rubygems is already loaded from #{path}"
+ end
+
+ class << Gem
+ remove_method :try_activate if Gem.respond_to?(:try_activate, true)
+ end
+end
-# TODO remove at RubyGems 4
module Gem
RubyGemsVersion = VERSION
- deprecate_constant(:RubyGemsVersion)
+
+ # TODO remove at RubyGems 3
RbConfigPriorities = %w[
MAJOR
@@ -22,19 +42,19 @@ module Gem
EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
rubylibdir
- ].freeze
+ ]
unless defined?(ConfigMap)
##
# Configuration settings from ::RbConfig
- ConfigMap = Hash.new do |cm, key|
+ ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3
cm[key] = RbConfig::CONFIG[key.to_s]
end
- deprecate_constant(:ConfigMap)
else
RbConfigPriorities.each do |key|
ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
end
end
+ RubyGemsPackageVersion = VERSION
end
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 54d8a9c152..c0d19dbfc2 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -27,7 +27,6 @@ require 'rbconfig'
# +:backtrace+:: See #backtrace
# +:sources+:: Sets Gem::sources
# +:verbose+:: See #verbose
-# +:concurrent_downloads+:: See #concurrent_downloads
#
# gemrc files may exist in various locations and are read and merged in
# the following order:
@@ -44,14 +43,12 @@ class Gem::ConfigFile
DEFAULT_BULK_THRESHOLD = 1000
DEFAULT_VERBOSITY = true
DEFAULT_UPDATE_SOURCES = true
- DEFAULT_CONCURRENT_DOWNLOADS = 8
- DEFAULT_CERT_EXPIRATION_LENGTH_DAYS = 365
##
# For Ruby packagers to set configuration defaults. Set in
# rubygems/defaults/operating_system.rb
- OPERATING_SYSTEM_DEFAULTS = Gem.operating_system_defaults
+ OPERATING_SYSTEM_DEFAULTS = {}
##
# For Ruby implementers to set configuration defaults. Set in
@@ -66,7 +63,26 @@ class Gem::ConfigFile
require "etc"
Etc.sysconfdir
rescue LoadError, NoMethodError
- RbConfig::CONFIG["sysconfdir"] || "/etc"
+ begin
+ # TODO: remove after we drop 1.8.7 and 1.9.1
+ require 'Win32API'
+
+ CSIDL_COMMON_APPDATA = 0x0023
+ path = 0.chr * 260
+ if RUBY_VERSION > '1.9' then
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP',
+ 'L', :stdcall
+ SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
+ else
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP',
+ 'L'
+ SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
+ end
+
+ path.strip
+ rescue LoadError
+ RbConfig::CONFIG["sysconfdir"] || "/etc"
+ end
end
# :startdoc:
@@ -108,11 +124,6 @@ class Gem::ConfigFile
attr_accessor :verbose
##
- # Number of gem downloads that should be performed concurrently.
-
- attr_accessor :concurrent_downloads
-
- ##
# True if we want to update the SourceInfoCache every time, false otherwise
attr_accessor :update_sources
@@ -137,11 +148,6 @@ class Gem::ConfigFile
attr_accessor :sources
##
- # Expiration length to sign a certificate
-
- attr_accessor :cert_expiration_length_days
-
- ##
# Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
attr_reader :ssl_client_cert
@@ -168,42 +174,53 @@ class Gem::ConfigFile
# TODO: parse options upstream, pass in options directly
def initialize(args)
- set_config_file_name(args)
+ @config_file_name = nil
+ need_config_file_name = false
+
+ arg_list = []
+
+ args.each do |arg|
+ if need_config_file_name then
+ @config_file_name = arg
+ need_config_file_name = false
+ elsif arg =~ /^--config-file=(.*)/ then
+ @config_file_name = $1
+ elsif arg =~ /^--config-file$/ then
+ need_config_file_name = true
+ else
+ arg_list << arg
+ end
+ end
@backtrace = DEFAULT_BACKTRACE
@bulk_threshold = DEFAULT_BULK_THRESHOLD
@verbose = DEFAULT_VERBOSITY
@update_sources = DEFAULT_UPDATE_SOURCES
- @concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS
- @cert_expiration_length_days = DEFAULT_CERT_EXPIRATION_LENGTH_DAYS
operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
- user_config = load_file config_file_name.dup.tap(&Gem::UNTAINT)
-
- environment_config = (ENV['GEMRC'] || '')
- .split(File::PATH_SEPARATOR).inject({}) do |result, file|
- result.merge load_file file
- end
+ user_config = load_file config_file_name.dup.untaint
+ environment_config = (ENV['GEMRC'] || '').split(/[:;]/).inject({}) do |result, file|
+ result.merge load_file file
+ end
@hash = operating_system_config.merge platform_config
- unless args.index '--norc'
+ unless arg_list.index '--norc'
@hash = @hash.merge system_config
@hash = @hash.merge user_config
@hash = @hash.merge environment_config
end
# HACK these override command-line args, which is bad
- @backtrace = @hash[:backtrace] if @hash.key? :backtrace
- @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
- @home = @hash[:gemhome] if @hash.key? :gemhome
- @path = @hash[:gempath] if @hash.key? :gempath
- @update_sources = @hash[:update_sources] if @hash.key? :update_sources
- @verbose = @hash[:verbose] if @hash.key? :verbose
- @disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
- @sources = @hash[:sources] if @hash.key? :sources
- @cert_expiration_length_days = @hash[:cert_expiration_length_days] if @hash.key? :cert_expiration_length_days
+ @backtrace = @hash[:backtrace] if @hash.key? :backtrace
+ @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
+ @home = @hash[:gemhome] if @hash.key? :gemhome
+ @path = @hash[:gempath] if @hash.key? :gempath
+ @update_sources = @hash[:update_sources] if @hash.key? :update_sources
+ @verbose = @hash[:verbose] if @hash.key? :verbose
+ @disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
+ @sources = @hash[:sources] if @hash.key? :sources
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
@@ -212,7 +229,7 @@ class Gem::ConfigFile
@api_keys = nil
@rubygems_api_key = nil
- handle_arguments args
+ handle_arguments arg_list
end
##
@@ -267,13 +284,13 @@ if you believe they were disclosed to a third party.
def load_api_keys
check_credentials_permissions
- @api_keys = if File.exist? credentials_path
+ @api_keys = if File.exist? credentials_path then
load_file(credentials_path)
else
@hash
end
- if @api_keys.key? :rubygems_api_key
+ if @api_keys.key? :rubygems_api_key then
@rubygems_api_key = @api_keys[:rubygems_api_key]
@api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless
@api_keys.key? :rubygems
@@ -292,7 +309,7 @@ if you believe they were disclosed to a third party.
##
# Sets the RubyGems.org API key to +api_key+
- def rubygems_api_key=(api_key)
+ def rubygems_api_key= api_key
set_api_key :rubygems_api_key, api_key
@rubygems_api_key = api_key
@@ -301,7 +318,7 @@ if you believe they were disclosed to a third party.
##
# Set a specific host's API key to +api_key+
- def set_api_key(host, api_key)
+ def set_api_key host, api_key
check_credentials_permissions
config = load_file(credentials_path).merge(host => api_key)
@@ -334,7 +351,7 @@ if you believe they were disclosed to a third party.
yaml_errors = [ArgumentError]
yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError)
- return {} unless filename && !filename.empty? && File.exist?(filename)
+ return {} unless filename and File.exist? filename
begin
content = Gem::SafeYAML.load(File.read(filename))
@@ -417,9 +434,6 @@ if you believe they were disclosed to a third party.
yaml_hash[:update_sources] = @hash.fetch(:update_sources, DEFAULT_UPDATE_SOURCES)
yaml_hash[:verbose] = @hash.fetch(:verbose, DEFAULT_VERBOSITY)
- yaml_hash[:concurrent_downloads] =
- @hash.fetch(:concurrent_downloads, DEFAULT_CONCURRENT_DOWNLOADS)
-
yaml_hash[:ssl_verify_mode] =
@hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
@@ -470,23 +484,4 @@ if you believe they were disclosed to a third party.
attr_reader :hash
protected :hash
-
- private
-
- def set_config_file_name(args)
- @config_file_name = ENV["GEMRC"]
- need_config_file_name = false
-
- args.each do |arg|
- if need_config_file_name
- @config_file_name = arg
- need_config_file_name = false
- elsif arg =~ /^--config-file=(.*)/
- @config_file_name = $1
- elsif arg =~ /^--config-file$/
- need_config_file_name = true
- end
- end
- end
-
end
diff --git a/lib/rubygems/core_ext/kernel_gem.rb b/lib/rubygems/core_ext/kernel_gem.rb
index e722225739..b0dd69bfcc 100644
--- a/lib/rubygems/core_ext/kernel_gem.rb
+++ b/lib/rubygems/core_ext/kernel_gem.rb
@@ -7,6 +7,9 @@
module Kernel
+ # REFACTOR: This should be pulled out into some kind of hacks file.
+ remove_method :gem if 'method' == defined? gem # from gem_prelude.rb on 1.9
+
##
# Use Kernel#gem to activate a specific version of +gem_name+.
#
@@ -61,13 +64,9 @@ module Kernel
spec = dep.to_spec
- if spec
- if Gem::LOADED_SPECS_MUTEX.owned?
- spec.activate
- else
- Gem::LOADED_SPECS_MUTEX.synchronize { spec.activate }
- end
- end
+ Gem::LOADED_SPECS_MUTEX.synchronize {
+ spec.activate
+ } if spec
end
private :gem
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 115ae0cb50..d3df9d85f9 100644..100755
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -11,8 +11,13 @@ module Kernel
RUBYGEMS_ACTIVATION_MONITOR = Monitor.new # :nodoc:
- # Make sure we have a reference to Ruby's original Kernel#require
- unless defined?(gem_original_require)
+ if defined?(gem_original_require) then
+ # Ruby ships with a custom_require, override its require
+ remove_method :require
+ else
+ ##
+ # The Kernel#require from before RubyGems was loaded.
+
alias gem_original_require require
private :gem_original_require
end
@@ -31,54 +36,25 @@ module Kernel
# The normal <tt>require</tt> functionality of returning false if
# that file has already been loaded is preserved.
- def require(path)
- if RUBYGEMS_ACTIVATION_MONITOR.respond_to?(:mon_owned?)
- monitor_owned = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?
- end
+ def require path
RUBYGEMS_ACTIVATION_MONITOR.enter
path = path.to_path if path.respond_to? :to_path
if spec = Gem.find_unresolved_default_spec(path)
- # Ensure -I beats a default gem
- resolved_path = begin
- rp = nil
- load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths
- Gem.suffixes.each do |s|
- $LOAD_PATH[0...load_path_check_index].each do |lp|
- safe_lp = lp.dup.tap(&Gem::UNTAINT)
- begin
- if File.symlink? safe_lp # for backward compatibility
- next
- end
- rescue SecurityError
- RUBYGEMS_ACTIVATION_MONITOR.exit
- raise
- end
-
- full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
- if File.file?(full_path)
- rp = full_path
- break
- end
- end
- break if rp
- end
- rp
- end
-
+ Gem.remove_unresolved_default_spec(spec)
begin
- Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease)
+ Kernel.send(:gem, spec.name)
rescue Exception
RUBYGEMS_ACTIVATION_MONITOR.exit
raise
- end unless resolved_path
+ end
end
# If there are no unresolved deps, then we can use just try
# normal require handle loading a gem from the rescue below.
- if Gem::Specification.unresolved_deps.empty?
+ if Gem::Specification.unresolved_deps.empty? then
RUBYGEMS_ACTIVATION_MONITOR.exit
return gem_original_require(path)
end
@@ -108,7 +84,7 @@ module Kernel
# requested, then find_in_unresolved_tree will find d.rb in d because
# it's a dependency of c.
#
- if found_specs.empty?
+ if found_specs.empty? then
found_specs = Gem::Specification.find_in_unresolved_tree path
found_specs.each do |found_spec|
@@ -123,7 +99,7 @@ module Kernel
# versions of the same gem
names = found_specs.map(&:name).uniq
- if names.size > 1
+ if names.size > 1 then
RUBYGEMS_ACTIVATION_MONITOR.exit
raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ', '}"
end
@@ -132,7 +108,7 @@ module Kernel
# at the highest version.
valid = found_specs.find { |s| !s.has_conflicts? }
- unless valid
+ unless valid then
le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
le.name = names.first
RUBYGEMS_ACTIVATION_MONITOR.exit
@@ -148,7 +124,8 @@ module Kernel
RUBYGEMS_ACTIVATION_MONITOR.enter
begin
- if load_error.message.end_with?(path) and Gem.try_activate(path)
+ if load_error.message.start_with?("Could not find") or
+ (load_error.message.end_with?(path) and Gem.try_activate(path)) then
require_again = true
end
ensure
@@ -158,13 +135,6 @@ module Kernel
return gem_original_require(path) if require_again
raise load_error
- ensure
- if RUBYGEMS_ACTIVATION_MONITOR.respond_to?(:mon_owned?)
- if monitor_owned != (ow = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?)
- STDERR.puts [$$, Thread.current, $!, $!.backtrace].inspect if $!
- raise "CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before #{monitor_owned} -> after #{ow}"
- end
- end
end
private :require
diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb
deleted file mode 100644
index dfc577df0b..0000000000
--- a/lib/rubygems/core_ext/kernel_warn.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-# `uplevel` keyword argument of Kernel#warn is available since ruby 2.5.
-if RUBY_VERSION >= "2.5"
-
- module Kernel
- path = "#{__dir__}/" # Frames to be skipped start with this path.
-
- original_warn = method(:warn)
-
- remove_method :warn
-
- class << self
-
- remove_method :warn
-
- end
-
- module_function define_method(:warn) {|*messages, **kw|
- unless uplevel = kw[:uplevel]
- if Gem.java_platform?
- return original_warn.call(*messages)
- else
- return original_warn.call(*messages, **kw)
- end
- end
-
- # Ensure `uplevel` fits a `long`
- uplevel, = [uplevel].pack("l!").unpack("l!")
-
- if uplevel >= 0
- start = 0
- while uplevel >= 0
- loc, = caller_locations(start, 1)
- unless loc
- # No more backtrace
- start += uplevel
- break
- end
-
- start += 1
-
- unless loc.path.start_with?(path)
- # Non-rubygems frames
- uplevel -= 1
- end
- end
- uplevel = start
- end
-
- kw[:uplevel] = uplevel
- original_warn.call(*messages, **kw)
- }
- end
-end
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index d4ff4a262c..43d57fc808 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module Gem
- DEFAULT_HOST = "https://rubygems.org".freeze
+ DEFAULT_HOST = "https://rubygems.org"
- @post_install_hooks ||= []
- @done_installing_hooks ||= []
+ @post_install_hooks ||= []
+ @done_installing_hooks ||= []
@post_uninstall_hooks ||= []
@pre_uninstall_hooks ||= []
@pre_install_hooks ||= []
@@ -28,15 +28,22 @@ module Gem
# specified in the environment
def self.default_dir
- path = if defined? RUBY_FRAMEWORK_VERSION
+ path = if defined? RUBY_FRAMEWORK_VERSION then
[
File.dirname(RbConfig::CONFIG['sitedir']),
'Gems',
RbConfig::CONFIG['ruby_version']
]
+ elsif RbConfig::CONFIG['rubylibprefix'] then
+ [
+ RbConfig::CONFIG['rubylibprefix'],
+ 'gems',
+ RbConfig::CONFIG['ruby_version']
+ ]
else
[
- RbConfig::CONFIG['rubylibprefix'],
+ RbConfig::CONFIG['libdir'],
+ ruby_engine,
'gems',
RbConfig::CONFIG['ruby_version']
]
@@ -52,7 +59,7 @@ module Gem
# By default, the binary extensions are located side by side with their
# Ruby counterparts, therefore nil is returned
- def self.default_ext_dir_for(base_dir)
+ def self.default_ext_dir_for base_dir
nil
end
@@ -64,13 +71,6 @@ module Gem
end
##
- # Path to specification files of default gems.
-
- def self.default_specifications_dir
- File.join(Gem.default_dir, "specifications", "default")
- end
-
- ##
# Path for gems in the user's home directory
def self.user_dir
@@ -103,7 +103,7 @@ module Gem
def self.default_exec_format
exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s'
- unless exec_format =~ /%s/
+ unless exec_format =~ /%s/ then
raise Gem::Exception,
"[BUG] invalid exec_format #{exec_format.inspect}, no %s"
end
@@ -115,15 +115,22 @@ module Gem
# The default directory for binaries
def self.default_bindir
- if defined? RUBY_FRAMEWORK_VERSION # mac framework support
+ if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
'/usr/bin'
else # generic install
RbConfig::CONFIG['bindir']
end
end
+ ##
+ # A wrapper around RUBY_ENGINE const that may not be defined
+
def self.ruby_engine
- RUBY_ENGINE
+ if defined? RUBY_ENGINE then
+ RUBY_ENGINE
+ else
+ 'ruby'
+ end
end
##
@@ -141,6 +148,13 @@ module Gem
end
##
+ # Whether to expect full paths in default gems - true for non-MRI
+ # ruby implementations
+ def self.default_gems_use_full_paths?
+ ruby_engine != 'ruby'
+ end
+
+ ##
# Install extensions into lib as well as into the extension directory.
def self.install_extension_in_lib # :nodoc:
@@ -151,7 +165,7 @@ module Gem
# Directory where vendor gems are installed.
def self.vendor_dir # :nodoc:
- if vendor_dir = ENV['GEM_VENDOR']
+ if vendor_dir = ENV['GEM_VENDOR'] then
return vendor_dir.dup
end
@@ -162,26 +176,7 @@ module Gem
end
##
- # Default options for gem commands for Ruby packagers.
- #
- # The options here should be structured as an array of string "gem"
- # command names as keys and a string of the default options as values.
- #
- # Example:
- #
- # def self.operating_system_defaults
- # {
- # 'install' => '--no-rdoc --no-ri --env-shebang',
- # 'update' => '--no-rdoc --no-ri --env-shebang'
- # }
- # end
-
- def self.operating_system_defaults
- {}
- end
-
- ##
- # Default options for gem commands for Ruby implementers.
+ # Default options for gem commands.
#
# The options here should be structured as an array of string "gem"
# command names as keys and a string of the default options as values.
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index 0c58815c85..55873c71e8 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -2,7 +2,6 @@
##
# The Dependency class holds a Gem name and a Gem::Requirement.
-require "rubygems/bundler_version_finder"
require "rubygems/requirement"
class Gem::Dependency
@@ -19,7 +18,7 @@ class Gem::Dependency
TYPES = [
:development,
:runtime,
- ].freeze
+ ]
##
# Dependency name or regular expression.
@@ -36,7 +35,7 @@ class Gem::Dependency
# argument can optionally be the dependency type, which defaults to
# <tt>:runtime</tt>.
- def initialize(name, *requirements)
+ def initialize name, *requirements
case name
when String then # ok
when Regexp then
@@ -76,7 +75,7 @@ class Gem::Dependency
end
def inspect # :nodoc:
- if prerelease?
+ if prerelease? then
"<%s type=%p name=%p requirements=%p prerelease=ok>" %
[self.class, self.type, self.name, requirement.to_s]
else
@@ -100,7 +99,7 @@ class Gem::Dependency
@requirement.none?
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 1, 'Gem::Dependency.new(', ')' do
q.pp name
q.text ','
@@ -140,7 +139,7 @@ class Gem::Dependency
if defined?(@version_requirement) && @version_requirement
version = @version_requirement.instance_variable_get :@version
- @version_requirement = nil
+ @version_requirement = nil
@version_requirements = Gem::Requirement.new version
end
@@ -152,7 +151,7 @@ class Gem::Dependency
end
def to_s # :nodoc:
- if type != :runtime
+ if type != :runtime then
"#{name} (#{requirement}, #{type})"
else
"#{name} (#{requirement})"
@@ -170,7 +169,7 @@ class Gem::Dependency
@type == :runtime || !@type
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
Gem::Dependency === other &&
self.name == other.name &&
self.type == other.type &&
@@ -180,7 +179,7 @@ class Gem::Dependency
##
# Dependencies are ordered by name.
- def <=>(other)
+ def <=> other
self.name <=> other.name
end
@@ -190,7 +189,7 @@ class Gem::Dependency
# other has only an equal version requirement that satisfies this
# dependency.
- def =~(other)
+ def =~ other
unless Gem::Dependency === other
return unless other.respond_to?(:name) && other.respond_to?(:version)
other = Gem::Dependency.new other.name, other.version
@@ -222,7 +221,7 @@ class Gem::Dependency
# NOTE: Unlike #matches_spec? this method does not return true when the
# version is a prerelease version unless this is a prerelease dependency.
- def match?(obj, version=nil, allow_prerelease=false)
+ def match? obj, version=nil, allow_prerelease=false
if !version
name = obj.name
version = obj.version
@@ -249,7 +248,7 @@ class Gem::Dependency
# returns true when +spec+ is a prerelease version even if this dependency
# is not a prerelease dependency.
- def matches_spec?(spec)
+ def matches_spec? spec
return false unless name === spec.name
return true if requirement.none?
@@ -259,14 +258,14 @@ class Gem::Dependency
##
# Merges the requirements of +other+ into this dependency
- def merge(other)
- unless name == other.name
+ def merge other
+ unless name == other.name then
raise ArgumentError,
"#{self} and #{other} have different names"
end
default = Gem::Requirement.default
- self_req = self.requirement
+ self_req = self.requirement
other_req = other.requirement
return self.class.new name, self_req if other_req == default
@@ -275,18 +274,18 @@ class Gem::Dependency
self.class.new name, self_req.as_list.concat(other_req.as_list)
end
- def matching_specs(platform_only = false)
+ def matching_specs platform_only = false
env_req = Gem.env_requirement(name)
- matches = Gem::Specification.stubs_for(name).find_all do |spec|
+ matches = Gem::Specification.stubs_for(name).find_all { |spec|
requirement.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
- end.map(&:to_spec)
+ }.map(&:to_spec)
- Gem::BundlerVersionFinder.filter!(matches) if name == "bundler".freeze && !requirement.specific?
+ Gem::BundlerVersionFinder.filter!(matches) if name == "bundler".freeze
if platform_only
- matches.reject! do |spec|
+ matches.reject! { |spec|
spec.nil? || !Gem::Platform.match(spec.platform)
- end
+ }
end
matches
@@ -304,7 +303,7 @@ class Gem::Dependency
# TODO: check Gem.activated_spec[self.name] in case matches falls outside
- if matches.empty?
+ if matches.empty? then
specs = Gem::Specification.stubs_for name
if specs.empty?
@@ -333,19 +332,4 @@ class Gem::Dependency
matches.first
end
-
- def identity
- if prerelease?
- if specific?
- :complete
- else
- :abs_latest
- end
- elsif latest_version?
- :latest
- else
- :released
- end
- end
-
end
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 6d45688888..5a87f50956 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -15,7 +15,6 @@ require 'rubygems/deprecate'
class Gem::DependencyInstaller
include Gem::UserInteraction
- extend Gem::Deprecate
DEFAULT_OPTIONS = { # :nodoc:
:env_shebang => false,
@@ -29,7 +28,7 @@ class Gem::DependencyInstaller
:wrappers => true,
:build_args => nil,
:build_docs_in_background => false,
- :install_as_default => false
+ :install_as_default => false
}.freeze
##
@@ -43,6 +42,15 @@ class Gem::DependencyInstaller
attr_reader :errors
##
+ #--
+ # TODO remove, no longer used
+
+ attr_reader :gems_to_install # :nodoc:
+
+ extend Gem::Deprecate
+ deprecate :gems_to_install, :none, 2016, 10
+
+ ##
# List of gems installed by #install in alphabetic order
attr_reader :installed_gems
@@ -66,7 +74,7 @@ class Gem::DependencyInstaller
# :wrappers:: See Gem::Installer::new
# :build_args:: See Gem::Installer::new
- def initialize(options = {})
+ def initialize options = {}
@only_install_dir = !!options[:install_dir]
@install_dir = options[:install_dir] || Gem.dir
@build_root = options[:build_root]
@@ -88,14 +96,11 @@ class Gem::DependencyInstaller
@wrappers = options[:wrappers]
@build_args = options[:build_args]
@build_docs_in_background = options[:build_docs_in_background]
- @install_as_default = options[:install_as_default]
- @dir_mode = options[:dir_mode]
- @data_mode = options[:data_mode]
- @prog_mode = options[:prog_mode]
+ @install_as_default = options[:install_as_default]
# Indicates that we should not try to update any deps unless
# we absolutely must.
- @minimal_deps = options[:minimal_deps]
+ @minimal_deps = options[:minimal_deps]
@available = nil
@installed_gems = []
@@ -107,25 +112,73 @@ class Gem::DependencyInstaller
end
##
+ #--
+ # TODO remove, no longer used
+
+ def add_found_dependencies to_do, dependency_list # :nodoc:
+ seen = {}
+ dependencies = Hash.new { |h, name| h[name] = Gem::Dependency.new name }
+
+ until to_do.empty? do
+ spec = to_do.shift
+
+ # HACK why is spec nil?
+ next if spec.nil? or seen[spec.name]
+ seen[spec.name] = true
+
+ deps = spec.runtime_dependencies
+
+ if @development
+ if @dev_shallow
+ if @toplevel_specs.include? spec.full_name
+ deps |= spec.development_dependencies
+ end
+ else
+ deps |= spec.development_dependencies
+ end
+ end
+
+ deps.each do |dep|
+ dependencies[dep.name] = dependencies[dep.name].merge dep
+
+ if @minimal_deps
+ next if Gem::Specification.any? do |installed_spec|
+ dep.name == installed_spec.name and
+ dep.requirement.satisfied_by? installed_spec.version
+ end
+ end
+
+ results = find_gems_with_sources(dep)
+
+ results.sorted.each do |t|
+ to_do.push t.spec
+ end
+
+ results.remove_installed! dep
+
+ @available << results
+ results.inject_into_list dependency_list
+ end
+ end
+
+ dependency_list.remove_specs_unsatisfied_by dependencies
+ end
+
+ ##
# Creates an AvailableSet to install from based on +dep_or_name+ and
# +version+
- def available_set_for(dep_or_name, version) # :nodoc:
- if String === dep_or_name
- Gem::Deprecate.skip_during do
- find_spec_by_name_and_version dep_or_name, version, @prerelease
- end
+ def available_set_for dep_or_name, version # :nodoc:
+ if String === dep_or_name then
+ find_spec_by_name_and_version dep_or_name, version, @prerelease
else
dep = dep_or_name.dup
dep.prerelease = @prerelease
- @available = Gem::Deprecate.skip_during do
- find_gems_with_sources dep
- end
+ @available = find_gems_with_sources dep
end
@available.pick_best!
end
- deprecate :available_set_for, :none, 2019, 12
##
# Indicated, based on the requested domain, if local
@@ -149,7 +202,7 @@ class Gem::DependencyInstaller
# sources. Gems are sorted with newer gems preferred over older gems, and
# local gems preferred over remote gems.
- def find_gems_with_sources(dep, best_only=false) # :nodoc:
+ def find_gems_with_sources dep, best_only=false # :nodoc:
set = Gem::AvailableSet.new
if consider_local?
@@ -164,8 +217,9 @@ class Gem::DependencyInstaller
if consider_remote?
begin
- # This is pulled from #spec_for_dependency to allow
+ # TODO this is pulled from #spec_for_dependency to allow
# us to filter tuples before fetching specs.
+ #
tuples, errors = Gem::SpecFetcher.fetcher.search_for_dependency dep
if best_only && !tuples.empty?
@@ -216,23 +270,22 @@ class Gem::DependencyInstaller
set
end
- deprecate :find_gems_with_sources, :none, 2019, 12
##
# Finds a spec and the source_uri it came from for gem +gem_name+ and
# +version+. Returns an Array of specs and sources required for
# installation of the gem.
- def find_spec_by_name_and_version(gem_name,
+ def find_spec_by_name_and_version gem_name,
version = Gem::Requirement.default,
- prerelease = false)
+ prerelease = false
set = Gem::AvailableSet.new
if consider_local?
- if gem_name =~ /\.gem$/ and File.file? gem_name
+ if gem_name =~ /\.gem$/ and File.file? gem_name then
src = Gem::Source::SpecificFile.new(gem_name)
set.add src.spec, src
- elsif gem_name =~ /\.gem$/
+ elsif gem_name =~ /\.gem$/ then
Dir[gem_name].each do |name|
begin
src = Gem::Source::SpecificFile.new name
@@ -253,10 +306,7 @@ class Gem::DependencyInstaller
dep = Gem::Dependency.new gem_name, version
dep.prerelease = true if prerelease
- set = Gem::Deprecate.skip_during do
- find_gems_with_sources(dep, true)
- end
-
+ set = find_gems_with_sources(dep, true)
set.match_platform!
end
@@ -266,9 +316,46 @@ class Gem::DependencyInstaller
@available = set
end
- deprecate :find_spec_by_name_and_version, :none, 2019, 12
- def in_background(what) # :nodoc:
+ ##
+ # Gathers all dependencies necessary for the installation from local and
+ # remote sources unless the ignore_dependencies was given.
+ #--
+ # TODO remove at RubyGems 3
+
+ def gather_dependencies # :nodoc:
+ specs = @available.all_specs
+
+ # these gems were listed by the user, always install them
+ keep_names = specs.map { |spec| spec.full_name }
+
+ if @dev_shallow
+ @toplevel_specs = keep_names
+ end
+
+ dependency_list = Gem::DependencyList.new @development
+ dependency_list.add(*specs)
+ to_do = specs.dup
+ add_found_dependencies to_do, dependency_list unless @ignore_dependencies
+
+ # REFACTOR maybe abstract away using Gem::Specification.include? so
+ # that this isn't dependent only on the currently installed gems
+ dependency_list.specs.reject! { |spec|
+ not keep_names.include?(spec.full_name) and
+ Gem::Specification.include?(spec)
+ }
+
+ unless dependency_list.ok? or @ignore_dependencies or @force then
+ reason = dependency_list.why_not_ok?.map { |k,v|
+ "#{k} requires #{v.join(", ")}"
+ }.join("; ")
+ raise Gem::DependencyError, "Unable to resolve dependencies: #{reason}"
+ end
+
+ @gems_to_install = dependency_list.dependency_order.reverse
+ end
+
+ def in_background what # :nodoc:
fork_happened = false
if @build_docs_in_background and Process.respond_to?(:fork)
begin
@@ -297,7 +384,7 @@ class Gem::DependencyInstaller
# c-1.a, b-1 and a-1.a will be installed. b-1.a will need to be installed
# separately.
- def install(dep_or_name, version = Gem::Requirement.default)
+ def install dep_or_name, version = Gem::Requirement.default
request_set = resolve_dependencies dep_or_name, version
@installed_gems = []
@@ -315,10 +402,7 @@ class Gem::DependencyInstaller
:user_install => @user_install,
:wrappers => @wrappers,
:build_root => @build_root,
- :install_as_default => @install_as_default,
- :dir_mode => @dir_mode,
- :data_mode => @data_mode,
- :prog_mode => @prog_mode,
+ :install_as_default => @install_as_default
}
options[:install_dir] = @install_dir if @only_install_dir
@@ -341,16 +425,16 @@ class Gem::DependencyInstaller
end
def install_development_deps # :nodoc:
- if @development and @dev_shallow
+ if @development and @dev_shallow then
:shallow
- elsif @development
+ elsif @development then
:all
else
:none
end
end
- def resolve_dependencies(dep_or_name, version) # :nodoc:
+ def resolve_dependencies dep_or_name, version # :nodoc:
request_set = Gem::RequestSet.new
request_set.development = @development
request_set.development_shallow = @dev_shallow
@@ -362,11 +446,11 @@ class Gem::DependencyInstaller
installer_set.ignore_installed = @only_install_dir
if consider_local?
- if dep_or_name =~ /\.gem$/ and File.file? dep_or_name
+ if dep_or_name =~ /\.gem$/ and File.file? dep_or_name then
src = Gem::Source::SpecificFile.new dep_or_name
installer_set.add_local dep_or_name, src.spec, src
version = src.spec.version if version == Gem::Requirement.default
- elsif dep_or_name =~ /\.gem$/
+ elsif dep_or_name =~ /\.gem$/ then
Dir[dep_or_name].each do |name|
begin
src = Gem::Source::SpecificFile.new name
@@ -374,14 +458,14 @@ class Gem::DependencyInstaller
rescue Gem::Package::FormatError
end
end
- # else This is a dependency. InstallerSet handles this case
+ # else This is a dependency. InstallerSet handles this case
end
end
dependency =
- if spec = installer_set.local?(dep_or_name)
+ if spec = installer_set.local?(dep_or_name) then
Gem::Dependency.new spec.name, version
- elsif String === dep_or_name
+ elsif String === dep_or_name then
Gem::Dependency.new dep_or_name, version
else
dep_or_name
@@ -395,7 +479,7 @@ class Gem::DependencyInstaller
request_set.always_install = installer_set.always_install
- if @ignore_dependencies
+ if @ignore_dependencies then
installer_set.ignore_dependencies = true
request_set.ignore_dependencies = true
request_set.soft_missing = true
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
index db7a2f5ada..d8314eaf60 100644
--- a/lib/rubygems/dependency_list.rb
+++ b/lib/rubygems/dependency_list.rb
@@ -17,7 +17,6 @@ require 'rubygems/deprecate'
# this class necessary anymore? Especially #ok?, #why_not_ok?
class Gem::DependencyList
-
attr_reader :specs
include Enumerable
@@ -41,7 +40,7 @@ class Gem::DependencyList
# Creates a new DependencyList. If +development+ is true, development
# dependencies will be included.
- def initialize(development = false)
+ def initialize development = false
@specs = []
@development = development
@@ -80,8 +79,8 @@ class Gem::DependencyList
seen = {}
sorted.each do |spec|
- if index = seen[spec.name]
- if result[index].version < spec.version
+ if index = seen[spec.name] then
+ if result[index].version < spec.version then
result[index] = spec
end
else
@@ -115,16 +114,16 @@ class Gem::DependencyList
why_not_ok?(:quick).empty?
end
- def why_not_ok?(quick = false)
+ def why_not_ok? quick = false
unsatisfied = Hash.new { |h,k| h[k] = [] }
each do |spec|
spec.runtime_dependencies.each do |dep|
- inst = Gem::Specification.any? do |installed_spec|
+ inst = Gem::Specification.any? { |installed_spec|
dep.name == installed_spec.name and
dep.requirement.satisfied_by? installed_spec.version
- end
+ }
- unless inst or @specs.find { |s| s.satisfies_requirement? dep }
+ unless inst or @specs.find { |s| s.satisfies_requirement? dep } then
unsatisfied[spec.name] << dep
return unsatisfied if quick
end
@@ -135,7 +134,7 @@ class Gem::DependencyList
end
##
- # It is ok to remove a gemspec from the dependency list?
+ # Is is ok to remove a gemspec from the dependency list?
#
# If removing the gemspec creates breaks a currently ok dependency, then it
# is NOT ok to remove the gemspec.
@@ -146,10 +145,10 @@ class Gem::DependencyList
# If the state is inconsistent, at least don't crash
return true unless gem_to_remove
- siblings = @specs.find_all do |s|
+ siblings = @specs.find_all { |s|
s.name == gem_to_remove.name &&
s.full_name != gem_to_remove.full_name
- end
+ }
deps = []
@@ -161,11 +160,11 @@ class Gem::DependencyList
end
end
- deps.all? do |dep|
- siblings.any? do |s|
+ deps.all? { |dep|
+ siblings.any? { |s|
s.satisfies_requirement? dep
- end
- end
+ }
+ }
end
##
@@ -173,11 +172,11 @@ class Gem::DependencyList
# satisfy items in +dependencies+ (a hash of gem names to arrays of
# dependencies).
- def remove_specs_unsatisfied_by(dependencies)
- specs.reject! do |spec|
+ def remove_specs_unsatisfied_by dependencies
+ specs.reject! { |spec|
dep = dependencies[spec.name]
dep and not dep.requirement.satisfied_by? spec.version
- end
+ }
end
##
@@ -201,7 +200,7 @@ class Gem::DependencyList
next if spec == other
other.dependencies.each do |dep|
- if spec.satisfies_requirement? dep
+ if spec.satisfies_requirement? dep then
result[spec] << other
end
end
@@ -223,7 +222,7 @@ class Gem::DependencyList
dependencies.each do |dep|
specs.each do |spec|
- if spec.satisfies_requirement? dep
+ if spec.satisfies_requirement? dep then
yield spec
break
end
@@ -242,3 +241,4 @@ class Gem::DependencyList
end
end
+
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
index 8accfb6174..375194c1e8 100644
--- a/lib/rubygems/deprecate.rb
+++ b/lib/rubygems/deprecate.rb
@@ -27,7 +27,7 @@ module Gem::Deprecate
@skip ||= false
end
- def self.skip=(v) # :nodoc:
+ def self.skip= v # :nodoc:
@skip = v
end
@@ -47,24 +47,25 @@ module Gem::Deprecate
# telling the user of +repl+ (unless +repl+ is :none) and the
# year/month that it is planned to go away.
- def deprecate(name, repl, year, month)
- class_eval do
+ def deprecate name, repl, year, month
+ class_eval {
old = "_deprecated_#{name}"
alias_method old, name
define_method name do |*args, &block|
klass = self.kind_of? Module
target = klass ? "#{self}." : "#{self.class}#"
msg = [ "NOTE: #{target}#{name} is deprecated",
- repl == :none ? " with no replacement" : "; use #{repl} instead",
- ". It will be removed on or after %4d-%02d-01." % [year, month],
- "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
+ repl == :none ? " with no replacement" : "; use #{repl} instead",
+ ". It will be removed on or after %4d-%02d-01." % [year, month],
+ "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
]
warn "#{msg.join}." unless Gem::Deprecate.skip
send old, *args, &block
end
- end
+ }
end
module_function :deprecate, :skip_during
end
+
diff --git a/lib/rubygems/doctor.rb b/lib/rubygems/doctor.rb
index 661ae5a4e1..ec4a16c3f8 100644
--- a/lib/rubygems/doctor.rb
+++ b/lib/rubygems/doctor.rb
@@ -26,7 +26,7 @@ class Gem::Doctor
['doc', ''],
['extensions', ''],
['gems', ''],
- ].freeze
+ ]
missing =
Gem::REPOSITORY_SUBDIRECTORIES.sort -
@@ -41,7 +41,7 @@ class Gem::Doctor
#
# If +dry_run+ is true no files or directories will be removed.
- def initialize(gem_repository, dry_run = false)
+ def initialize gem_repository, dry_run = false
@gem_repository = gem_repository
@dry_run = dry_run
@@ -73,7 +73,7 @@ class Gem::Doctor
Gem.use_paths @gem_repository.to_s
- unless gem_repository?
+ unless gem_repository? then
say 'This directory does not appear to be a RubyGems repository, ' +
'skipping'
say
@@ -99,7 +99,7 @@ class Gem::Doctor
##
# Removes files in +sub_directory+ with +extension+
- def doctor_child(sub_directory, extension) # :nodoc:
+ def doctor_child sub_directory, extension # :nodoc:
directory = File.join(@gem_repository, sub_directory)
Dir.entries(directory).sort.each do |ent|
@@ -115,7 +115,7 @@ class Gem::Doctor
type = File.directory?(child) ? 'directory' : 'file'
- action = if @dry_run
+ action = if @dry_run then
'Extra'
else
FileUtils.rm_r(child)
@@ -129,3 +129,4 @@ class Gem::Doctor
end
end
+
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index 2cd18e2e20..6f2847d548 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -13,13 +13,11 @@ module Gem
# already activated gems or that RubyGems is otherwise unable to activate.
class LoadError < ::LoadError
-
# Name of gem
attr_accessor :name
# Version requirement of gem
attr_accessor :requirement
-
end
##
@@ -27,8 +25,7 @@ module Gem
# system. Instead of rescuing from this class, make sure to rescue from the
# superclass Gem::LoadError to catch all types of load errors.
class MissingSpecError < Gem::LoadError
-
- def initialize(name, requirement)
+ def initialize name, requirement
@name = name
@requirement = requirement
end
@@ -44,7 +41,6 @@ module Gem
total = Gem::Specification.stubs.size
"Could not find '#{name}' (#{requirement}) among #{total} total gem(s)\n"
end
-
end
##
@@ -52,10 +48,9 @@ module Gem
# not the requested version. Instead of rescuing from this class, make sure to
# rescue from the superclass Gem::LoadError to catch all types of load errors.
class MissingSpecVersionError < MissingSpecError
-
attr_reader :specs
- def initialize(name, requirement, specs)
+ def initialize name, requirement, specs
super(name, requirement)
@specs = specs
end
@@ -69,7 +64,6 @@ module Gem
names = specs.map(&:full_name)
"Could not find '#{name}' (#{requirement}) - did find: [#{names.join ','}]\n"
end
-
end
# Raised when there are conflicting gem specs loaded
@@ -87,20 +81,19 @@ module Gem
attr_reader :target
- def initialize(target, conflicts)
+ def initialize target, conflicts
@target = target
@conflicts = conflicts
@name = target.name
- reason = conflicts.map do |act, dependencies|
+ reason = conflicts.map { |act, dependencies|
"#{act.full_name} conflicts with #{dependencies.join(", ")}"
- end.join ", "
+ }.join ", "
# TODO: improve message by saying who activated `con`
super("Unable to activate #{target.full_name}, because #{reason}")
end
-
end
class ErrorReason; end
@@ -150,7 +143,6 @@ module Gem
@platforms.size == 1 ? '' : 's',
@platforms.join(' ,')]
end
-
end
##
@@ -189,6 +181,5 @@ module Gem
# The "exception" alias allows you to call raise on a SourceFetchProblem.
alias exception error
-
end
end
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 3924f9dde6..b7528761fc 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
-
-require 'rubygems/deprecate'
+# TODO: the documentation in here is terrible.
+#
+# Each exception needs a brief description and the scenarios where it is
+# likely to be raised
##
# Base exception class for RubyGems. All exception raised by RubyGems are a
@@ -9,13 +11,10 @@ class Gem::Exception < RuntimeError
##
#--
- # TODO: remove in RubyGems 4, nobody sets this
+ # TODO: remove in RubyGems 3, nobody sets this
attr_accessor :source_exception # :nodoc:
- extend Gem::Deprecate
- deprecate :source_exception, :none, 2018, 12
-
end
class Gem::CommandLineError < Gem::Exception; end
@@ -33,7 +32,7 @@ class Gem::DependencyResolutionError < Gem::DependencyError
attr_reader :conflict
- def initialize(conflict)
+ def initialize conflict
@conflict = conflict
a, b = conflicting_dependencies
@@ -50,18 +49,7 @@ end
# Raised when attempting to uninstall a gem that isn't in GEM_HOME.
class Gem::GemNotInHomeException < Gem::Exception
-
- attr_accessor :spec
-
-end
-
-###
-# Raised when removing a gem with the uninstall command fails
-
-class Gem::UninstallError < Gem::Exception
-
attr_accessor :spec
-
end
class Gem::DocumentError < Gem::Exception; end
@@ -78,7 +66,7 @@ class Gem::FilePermissionError < Gem::Exception
attr_reader :directory
- def initialize(directory)
+ def initialize directory
@directory = directory
super "You don't have write permissions for the #{directory} directory."
@@ -89,9 +77,7 @@ end
##
# Used to raise parsing and loading errors
class Gem::FormatException < Gem::Exception
-
attr_accessor :file_path
-
end
class Gem::GemNotFoundException < Gem::Exception; end
@@ -140,7 +126,7 @@ class Gem::ImpossibleDependenciesError < Gem::Exception
attr_reader :conflicts
attr_reader :request
- def initialize(request, conflicts)
+ def initialize request, conflicts
@request = request
@conflicts = conflicts
@@ -169,12 +155,10 @@ end
class Gem::InstallError < Gem::Exception; end
class Gem::RuntimeRequirementNotMetError < Gem::InstallError
-
attr_accessor :suggestion
def message
[suggestion, super].compact.join("\n\t")
end
-
end
##
@@ -254,7 +238,7 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
# Creates a new UnsatisfiableDependencyError for the unsatisfiable
# Gem::Resolver::DependencyRequest +dep+
- def initialize(dep, platform_mismatch=nil)
+ def initialize dep, platform_mismatch=nil
if platform_mismatch and !platform_mismatch.empty?
plats = platform_mismatch.map { |x| x.platform.to_s }.sort.uniq
super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(', ')}"
diff --git a/lib/rubygems/ext.rb b/lib/rubygems/ext.rb
index 35a486606a..18d2bc233a 100644
--- a/lib/rubygems/ext.rb
+++ b/lib/rubygems/ext.rb
@@ -16,3 +16,4 @@ require 'rubygems/ext/configure_builder'
require 'rubygems/ext/ext_conf_builder'
require 'rubygems/ext/rake_builder'
require 'rubygems/ext/cmake_builder'
+
diff --git a/lib/rubygems/ext/build_error.rb b/lib/rubygems/ext/build_error.rb
index 6dffddb5cc..0b3c17a9a0 100644
--- a/lib/rubygems/ext/build_error.rb
+++ b/lib/rubygems/ext/build_error.rb
@@ -4,3 +4,4 @@
class Gem::Ext::BuildError < Gem::InstallError
end
+
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index a8bd4c8d1b..eb9db199d5 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -6,6 +6,7 @@
#++
require 'rubygems/user_interaction'
+require 'thread'
class Gem::Ext::Builder
@@ -27,18 +28,18 @@ class Gem::Ext::Builder
end
def self.make(dest_path, results)
- unless File.exist? 'Makefile'
+ unless File.exist? 'Makefile' then
raise Gem::InstallError, 'Makefile not found'
end
# try to find make program from Ruby configure arguments first
RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
make_program = ENV['MAKE'] || ENV['make'] || $1
- unless make_program
+ unless make_program then
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
end
- destdir = '"DESTDIR=%s"' % ENV['DESTDIR']
+ destdir = '"DESTDIR=%s"' % ENV['DESTDIR'] if RUBY_VERSION > '2.0'
['clean', '', 'install'].each do |target|
# Pass DESTDIR via command line to override what's in MAKEFLAGS
@@ -55,45 +56,37 @@ class Gem::Ext::Builder
end
end
+ def self.redirector
+ '2>&1'
+ end
+
def self.run(command, results, command_name = nil)
verbose = Gem.configuration.really_verbose
begin
+ # TODO use Process.spawn when ruby 1.8 support is dropped.
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
if verbose
puts("current directory: #{Dir.pwd}")
- p(command)
- end
- results << "current directory: #{Dir.pwd}"
- results << (command.respond_to?(:shelljoin) ? command.shelljoin : command)
-
- require "open3"
- # Set $SOURCE_DATE_EPOCH for the subprocess.
- env = {'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string}
- output, status = Open3.capture2e(env, *command)
- if verbose
- puts output
+ puts(command)
+ system(command)
else
- results << output
+ results << "current directory: #{Dir.pwd}"
+ results << command
+ results << `#{command} #{redirector}`
end
- rescue => error
- raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
ensure
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
end
- unless status.success?
+ unless $?.success? then
results << "Building has failed. See above output for more information on the failure." if verbose
- end
-
- yield(status, results) if block_given?
- unless status.success?
exit_reason =
- if status.exited?
- ", exit code #{status.exitstatus}"
- elsif status.signaled?
- ", uncaught signal #{status.termsig}"
+ if $?.exited? then
+ ", exit code #{$?.exitstatus}"
+ elsif $?.signaled? then
+ ", uncaught signal #{$?.termsig}"
end
raise Gem::InstallError, "#{command_name || class_name} failed#{exit_reason}"
@@ -105,18 +98,18 @@ class Gem::Ext::Builder
# have build arguments, saved, set +build_args+ which is an ARGV-style
# array.
- def initialize(spec, build_args = spec.build_args)
+ def initialize spec, build_args = spec.build_args
@spec = spec
@build_args = build_args
@gem_dir = spec.full_gem_path
- @ran_rake = false
+ @ran_rake = nil
end
##
# Chooses the extension builder class for +extension+
- def builder_for(extension) # :nodoc:
+ def builder_for extension # :nodoc:
case extension
when /extconf/ then
Gem::Ext::ExtConfBuilder
@@ -128,14 +121,17 @@ class Gem::Ext::Builder
when /CMakeLists.txt/ then
Gem::Ext::CmakeBuilder
else
- build_error("No builder for extension '#{extension}'")
+ extension_dir = File.join @gem_dir, File.dirname(extension)
+
+ message = "No builder for extension '#{extension}'"
+ build_error extension_dir, message
end
end
##
- # Logs the build +output+, then raises Gem::Ext::BuildError.
+ # Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError.
- def build_error(output, backtrace = nil) # :nodoc:
+ def build_error build_dir, output, backtrace = nil # :nodoc:
gem_make_out = write_gem_make_out output
message = <<-EOF
@@ -150,39 +146,32 @@ EOF
raise Gem::Ext::BuildError, message, backtrace
end
- def build_extension(extension, dest_path) # :nodoc:
+ def build_extension extension, dest_path # :nodoc:
results = []
- builder = builder_for(extension)
-
+ extension ||= '' # I wish I knew why this line existed
extension_dir =
- File.expand_path File.join(@gem_dir, File.dirname(extension))
+ File.expand_path File.join @gem_dir, File.dirname(extension)
lib_dir = File.join @spec.full_gem_path, @spec.raw_require_paths.first
+ builder = builder_for extension
+
begin
FileUtils.mkdir_p dest_path
CHDIR_MUTEX.synchronize do
- pwd = Dir.getwd
- Dir.chdir extension_dir
- begin
- results = builder.build(extension, dest_path,
+ Dir.chdir extension_dir do
+ results = builder.build(extension, @gem_dir, dest_path,
results, @build_args, lib_dir)
verbose { results.join("\n") }
- ensure
- begin
- Dir.chdir pwd
- rescue SystemCallError
- Dir.chdir dest_path
- end
end
end
write_gem_make_out results.join "\n"
rescue => e
results << e.message
- build_error(results.join("\n"), $@)
+ build_error extension_dir, results.join("\n"), $@
end
end
@@ -204,6 +193,8 @@ EOF
FileUtils.rm_f @spec.gem_build_complete_path
+ @ran_rake = false # only run rake once
+
@spec.extensions.each do |extension|
break if @ran_rake
@@ -216,16 +207,15 @@ EOF
##
# Writes +output+ to gem_make.out in the extension install directory.
- def write_gem_make_out(output) # :nodoc:
+ def write_gem_make_out output # :nodoc:
destination = File.join @spec.extension_dir, 'gem_make.out'
FileUtils.mkdir_p @spec.extension_dir
- File.open destination, 'wb' do |io|
- io.puts output
- end
+ File.open destination, 'wb' do |io| io.puts output end
destination
end
end
+
diff --git a/lib/rubygems/ext/cmake_builder.rb b/lib/rubygems/ext/cmake_builder.rb
index 829b88d1bb..efa3bd1d88 100644
--- a/lib/rubygems/ext/cmake_builder.rb
+++ b/lib/rubygems/ext/cmake_builder.rb
@@ -2,9 +2,8 @@
require 'rubygems/command'
class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
-
- def self.build(extension, dest_path, results, args=[], lib_dir=nil)
- unless File.exist?('Makefile')
+ def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
+ unless File.exist?('Makefile') then
cmd = "cmake . -DCMAKE_INSTALL_PREFIX=#{dest_path}"
cmd << " #{Gem::Command.build_args.join ' '}" unless Gem::Command.build_args.empty?
@@ -15,5 +14,4 @@ class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
results
end
-
end
diff --git a/lib/rubygems/ext/configure_builder.rb b/lib/rubygems/ext/configure_builder.rb
index 7d105c9bd3..8b42bf7ee9 100644
--- a/lib/rubygems/ext/configure_builder.rb
+++ b/lib/rubygems/ext/configure_builder.rb
@@ -7,8 +7,8 @@
class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder
- def self.build(extension, dest_path, results, args=[], lib_dir=nil)
- unless File.exist?('Makefile')
+ def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
+ unless File.exist?('Makefile') then
cmd = "sh ./configure --prefix=#{dest_path}"
cmd << " #{args.join ' '}" unless args.empty?
@@ -21,3 +21,4 @@ class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder
end
end
+
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index 88be7ecfe8..965b728278 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -7,13 +7,11 @@
require 'fileutils'
require 'tempfile'
-require 'shellwords'
class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
-
FileEntry = FileUtils::Entry_ # :nodoc:
- def self.build(extension, dest_path, results, args=[], lib_dir=nil)
+ def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
tmp_dest = Dir.mktmpdir(".gem.", ".")
# Some versions of `mktmpdir` return absolute paths, which will break make
@@ -25,7 +23,9 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
# spaces do not work.
#
# Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940
- tmp_dest = get_relative_path(tmp_dest)
+ #
+ # TODO: Make this unconditional when rubygems no longer supports Ruby 1.9.x.
+ tmp_dest = get_relative_path(tmp_dest) unless Gem.win_platform? && RUBY_VERSION <= '2.0'
Tempfile.open %w"siteconf .rb", "." do |siteconf|
siteconf.puts "require 'rbconfig'"
@@ -40,20 +40,18 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
destdir = ENV["DESTDIR"]
begin
- cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../../..", __FILE__) <<
- "-r" << get_relative_path(siteconf.path) << File.basename(extension)
- cmd.push(*args)
+ cmd = [Gem.ruby, "-r", get_relative_path(siteconf.path), File.basename(extension), *args].join ' '
begin
- run(cmd, results) do |s, r|
- if File.exist? 'mkmf.log'
- unless s.success?
- r << "To see why this extension failed to compile, please check" \
- " the mkmf.log which can be found here:\n"
- r << " " + File.join(dest_path, 'mkmf.log') + "\n"
- end
- FileUtils.mv 'mkmf.log', dest_path
+ run cmd, results
+ ensure
+ if File.exist? 'mkmf.log'
+ unless $?.success? then
+ results << "To see why this extension failed to compile, please check" \
+ " the mkmf.log which can be found here:\n"
+ results << " " + File.join(dest_path, 'mkmf.log') + "\n"
end
+ FileUtils.mv 'mkmf.log', dest_path
end
siteconf.unlink
end
@@ -64,7 +62,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
if tmp_dest
# TODO remove in RubyGems 3
- if Gem.install_extension_in_lib and lib_dir
+ if Gem.install_extension_in_lib and lib_dir then
FileUtils.mkdir_p lib_dir
entries = Dir.entries(tmp_dest) - %w[. ..]
entries = entries.map { |entry| File.join tmp_dest, entry }
@@ -88,9 +86,8 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
end
private
-
def self.get_relative_path(path)
- path[0..Dir.pwd.length - 1] = '.' if path.start_with?(Dir.pwd)
+ path[0..Dir.pwd.length-1] = '.' if path.start_with?(Dir.pwd)
path
end
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 077f080c07..4b3534bf35 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -5,31 +5,33 @@
# See LICENSE.txt for permissions.
#++
-require "shellwords"
-
class Gem::Ext::RakeBuilder < Gem::Ext::Builder
- def self.build(extension, dest_path, results, args=[], lib_dir=nil)
- if File.basename(extension) =~ /mkrf_conf/i
- run([Gem.ruby, File.basename(extension), *args], results)
+ def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
+ if File.basename(extension) =~ /mkrf_conf/i then
+ cmd = "#{Gem.ruby} #{File.basename extension}".dup
+ cmd << " #{args.join " "}" unless args.empty?
+ run cmd, results
end
+ # Deal with possible spaces in the path, e.g. C:/Program Files
+ dest_path = '"' + dest_path.to_s + '"' if dest_path.to_s.include?(' ')
+
rake = ENV['rake']
- if rake
- rake = rake.shellsplit
- else
- begin
- rake = [Gem.ruby, "-I#{File.expand_path("..", __dir__)}", "-rrubygems", Gem.bin_path('rake', 'rake')]
- rescue Gem::Exception
- rake = [Gem.default_exec_format % 'rake']
- end
- end
+ rake ||= begin
+ "#{Gem.ruby} -rrubygems #{Gem.bin_path('rake', 'rake')}"
+ rescue Gem::Exception
+ end
- rake_args = ["RUBYARCHDIR=#{dest_path}", "RUBYLIBDIR=#{dest_path}", *args]
- run(rake + rake_args, results)
+ rake ||= Gem.default_exec_format % 'rake'
+
+ cmd = "#{rake} RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
+
+ run cmd, results
results
end
end
+
diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb
index 4159d81389..349d49d66e 100644
--- a/lib/rubygems/gem_runner.rb
+++ b/lib/rubygems/gem_runner.rb
@@ -38,7 +38,7 @@ class Gem::GemRunner
##
# Run the gem command with the following arguments.
- def run(args)
+ def run args
build_args = extract_build_args args
do_configuration args
@@ -63,7 +63,7 @@ class Gem::GemRunner
# Separates the build arguments (those following <code>--</code>) from the
# other arguments in the list.
- def extract_build_args(args) # :nodoc:
+ def extract_build_args args # :nodoc:
return [] unless offset = args.index('--')
build_args = args.slice!(offset...args.length)
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 2950d94dc1..623d9301b5 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -7,10 +7,13 @@ require 'rubygems/text'
module Gem::GemcutterUtilities
- ERROR_CODE = 1
-
include Gem::Text
+ # TODO: move to Gem::Command
+ OptionParser.accept Symbol do |value|
+ value.to_sym
+ end
+
attr_writer :host
##
@@ -25,22 +28,10 @@ module Gem::GemcutterUtilities
end
##
- # Add the --otp option
-
- def add_otp_option
- add_option('--otp CODE',
- 'Digit code for multifactor authentication') do |value, options|
- options[:otp] = value
- end
- end
-
- ##
# The API key from the command options or from the user's configuration.
def api_key
- if ENV["GEM_HOST_API_KEY"]
- ENV["GEM_HOST_API_KEY"]
- elsif options[:key]
+ if options[:key] then
verify_api_key options[:key]
elsif Gem.configuration.api_keys.key?(host)
Gem.configuration.api_keys[host]
@@ -63,7 +54,7 @@ module Gem::GemcutterUtilities
env_rubygems_host = nil if
env_rubygems_host and env_rubygems_host.empty?
- env_rubygems_host || configured_host
+ env_rubygems_host|| configured_host
end
end
@@ -78,7 +69,7 @@ module Gem::GemcutterUtilities
self.host = host if host
unless self.host
alert_error "You must specify a gem server"
- terminate_interaction(ERROR_CODE)
+ terminate_interaction 1 # TODO: question this
end
if allowed_push_host
@@ -87,40 +78,26 @@ module Gem::GemcutterUtilities
unless (host_uri.scheme == allowed_host_uri.scheme) && (host_uri.host == allowed_host_uri.host)
alert_error "#{self.host.inspect} is not allowed by the gemspec, which only allows #{allowed_push_host.inspect}"
- terminate_interaction(ERROR_CODE)
+ terminate_interaction 1
end
end
uri = URI.parse "#{self.host}/#{path}"
request_method = Net::HTTP.const_get method.to_s.capitalize
- response = Gem::RemoteFetcher.fetcher.request(uri, request_method, &block)
- return response unless mfa_unauthorized?(response)
- Gem::RemoteFetcher.fetcher.request(uri, request_method) do |req|
- req.add_field "OTP", get_otp
- block.call(req)
- end
- end
-
- def mfa_unauthorized?(response)
- response.kind_of?(Net::HTTPUnauthorized) && response.body.start_with?('You have enabled multifactor authentication')
- end
-
- def get_otp
- say 'You have enabled multi-factor authentication. Please enter OTP code.'
- ask 'Code: '
+ Gem::RemoteFetcher.fetcher.request(uri, request_method, &block)
end
##
# Signs in with the RubyGems API at +sign_in_host+ and sets the rubygems API
# key.
- def sign_in(sign_in_host = nil)
+ def sign_in sign_in_host = nil
sign_in_host ||= self.host
return if api_key
- pretty_host = if Gem::DEFAULT_HOST == sign_in_host
+ pretty_host = if Gem::DEFAULT_HOST == sign_in_host then
'RubyGems.org'
else
sign_in_host
@@ -130,14 +107,13 @@ module Gem::GemcutterUtilities
say "Don't have an account yet? " +
"Create one at #{sign_in_host}/sign_up"
- email = ask " Email: "
+ email = ask " Email: "
password = ask_for_password "Password: "
say "\n"
response = rubygems_api_request(:get, "api/v1/api_key",
sign_in_host) do |request|
request.basic_auth email, password
- request.add_field "OTP", options[:otp] if options[:otp]
end
with_response response do |resp|
@@ -151,11 +127,11 @@ module Gem::GemcutterUtilities
# an error.
def verify_api_key(key)
- if Gem.configuration.api_keys.key? key
+ if Gem.configuration.api_keys.key? key then
Gem.configuration.api_keys[key]
else
alert_error "No such API key. Please add it to your configuration (done automatically on initial `gem push`)."
- terminate_interaction(ERROR_CODE)
+ terminate_interaction 1 # TODO: question this
end
end
@@ -166,10 +142,10 @@ module Gem::GemcutterUtilities
# If the response was not successful, shows an error to the user including
# the +error_prefix+ and the response body.
- def with_response(response, error_prefix = nil)
+ def with_response response, error_prefix = nil
case response
when Net::HTTPSuccess then
- if block_given?
+ if block_given? then
yield response
else
say clean_text(response.body)
@@ -179,15 +155,11 @@ module Gem::GemcutterUtilities
message = "#{error_prefix}: #{message}" if error_prefix
say clean_text(message)
- terminate_interaction(ERROR_CODE)
+ terminate_interaction 1 # TODO: question this
end
end
- ##
- # Returns true when the user has enabled multifactor authentication from
- # +response+ text and no otp provided by options.
-
- def set_api_key(host, key)
+ def set_api_key host, key
if host == Gem::DEFAULT_HOST
Gem.configuration.rubygems_api_key = key
else
@@ -196,3 +168,4 @@ module Gem::GemcutterUtilities
end
end
+
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 4d199868fb..3ea994414b 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -4,17 +4,10 @@ require 'rubygems/package'
require 'time'
require 'tmpdir'
-rescue_exceptions = [LoadError]
-begin
- require 'bundler/errors'
-rescue LoadError # this rubygems + old ruby
-else # this rubygems + ruby trunk with bundler
- rescue_exceptions << Bundler::GemfileNotFound
-end
begin
gem 'builder'
require 'builder/xchar'
-rescue *rescue_exceptions
+rescue LoadError
end
##
@@ -62,7 +55,7 @@ class Gem::Indexer
require 'tmpdir'
require 'zlib'
- unless defined?(Builder::XChar)
+ unless defined?(Builder::XChar) then
raise "Gem::Indexer requires that the XML Builder library be installed:" +
"\n\tgem install builder"
end
@@ -116,7 +109,7 @@ class Gem::Indexer
##
# Builds Marshal quick index gemspecs.
- def build_marshal_gemspecs(specs)
+ def build_marshal_gemspecs specs
count = specs.count
progress = ui.progress_reporter count,
"Generating Marshal quick index gemspecs for #{count} gems",
@@ -131,10 +124,7 @@ class Gem::Indexer
marshal_name = File.join @quick_marshal_dir, spec_file_name
marshal_zipped = Gem.deflate Marshal.dump(spec)
-
- File.open marshal_name, 'wb' do |io|
- io.write marshal_zipped
- end
+ File.open marshal_name, 'wb' do |io| io.write marshal_zipped end
files << marshal_name
@@ -164,7 +154,7 @@ class Gem::Indexer
platform = spec.original_platform
# win32-api-1.0.4-x86-mswin32-60
- unless String === platform
+ unless String === platform then
alert_warning "Skipping invalid platform in gem: #{spec.full_name}"
next
end
@@ -182,10 +172,10 @@ class Gem::Indexer
##
# Builds indices for RubyGems 1.2 and newer. Handles full, latest, prerelease
- def build_modern_indices(specs)
- prerelease, released = specs.partition do |s|
+ def build_modern_indices specs
+ prerelease, released = specs.partition { |s|
s.version.prerelease?
- end
+ }
latest_specs =
Gem::Specification._latest_specs specs
@@ -202,9 +192,9 @@ class Gem::Indexer
"#{@prerelease_specs_index}.gz"]
end
- def map_gems_to_specs(gems)
- gems.map do |gemfile|
- if File.size(gemfile) == 0
+ def map_gems_to_specs gems
+ gems.map { |gemfile|
+ if File.size(gemfile) == 0 then
alert_warning "Skipping zero-length gem: #{gemfile}"
next
end
@@ -226,7 +216,7 @@ class Gem::Indexer
"\t#{e.backtrace.join "\n\t"}"].join("\n")
alert_error msg
end
- end.compact
+ }.compact
end
##
@@ -238,7 +228,7 @@ class Gem::Indexer
say "Compressing indices"
Gem.time 'Compressed indices' do
- if @build_modern
+ if @build_modern then
gzip @specs_index
gzip @latest_specs_index
gzip @prerelease_specs_index
@@ -281,7 +271,7 @@ class Gem::Indexer
# List of gem file names to index.
def gem_file_list
- Gem::Util.glob_files_in_dir("*.gem", File.join(@dest_directory, "gems"))
+ Dir[File.join(@dest_directory, "gems", '*.gem')]
end
##
@@ -316,7 +306,7 @@ class Gem::Indexer
files = @files
files.delete @quick_marshal_dir if files.include? @quick_dir
- if files.include? @quick_marshal_dir and not files.include? @quick_dir
+ if files.include? @quick_marshal_dir and not files.include? @quick_dir then
files.delete @quick_marshal_dir
dst_name = File.join(@dest_directory, @quick_marshal_dir_base)
@@ -357,7 +347,7 @@ class Gem::Indexer
data = Gem.read_binary path
compressed_data = Gem.read_binary "#{path}.#{extension}"
- unless data == Gem::Util.inflate(compressed_data)
+ unless data == Gem.inflate(compressed_data) then
raise "Compressed file #{compressed_path} does not match uncompressed file #{path}"
end
end
@@ -377,7 +367,7 @@ class Gem::Indexer
gem_mtime >= specs_mtime
end
- if updated_gems.empty?
+ if updated_gems.empty? then
say 'No new gems'
terminate_interaction 0
end
@@ -442,5 +432,4 @@ class Gem::Indexer
Marshal.dump specs_index, io
end
end
-
end
diff --git a/lib/rubygems/install_default_message.rb b/lib/rubygems/install_default_message.rb
index f68fd2fd04..dc73fd962b 100644
--- a/lib/rubygems/install_default_message.rb
+++ b/lib/rubygems/install_default_message.rb
@@ -10,3 +10,4 @@ Gem.post_install do |installer|
ui = Gem::DefaultUserInteraction.ui
ui.say "Successfully installed #{installer.spec.full_name} as a default gem"
end
+
diff --git a/lib/rubygems/install_message.rb b/lib/rubygems/install_message.rb
index 3c13888a84..6880db583e 100644
--- a/lib/rubygems/install_message.rb
+++ b/lib/rubygems/install_message.rb
@@ -10,3 +10,4 @@ Gem.post_install do |installer|
ui = Gem::DefaultUserInteraction.ui
ui.say "Successfully installed #{installer.spec.full_name}"
end
+
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index 38a0682958..190372739b 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -25,12 +25,12 @@ module Gem::InstallUpdateOptions
end
add_option(:"Install/Update", '-n', '--bindir DIR',
- 'Directory where executables are',
+ 'Directory where binary files are',
'located') do |value, options|
options[:bin_dir] = File.expand_path(value)
end
- add_option(:"Install/Update", '--document [TYPES]', Array,
+ add_option(:"Install/Update", '--[no-]document [TYPES]', Array,
'Generate documentation for installed gems',
'List the documentation types you wish to',
'generate. For example: rdoc,ri') do |value, options|
@@ -50,7 +50,7 @@ module Gem::InstallUpdateOptions
add_option(:"Install/Update", '--vendor',
'Install gem into the vendor directory.',
'Only for use by gem repackagers.') do |value, options|
- unless Gem.vendor_dir
+ unless Gem.vendor_dir then
raise OptionParser::InvalidOption.new 'your platform is not supported'
end
@@ -63,6 +63,30 @@ module Gem::InstallUpdateOptions
options[:document] = []
end
+ add_option(:Deprecated, '--[no-]rdoc',
+ 'Generate RDoc for installed gems',
+ 'Use --document instead') do |value, options|
+ if value then
+ options[:document] << 'rdoc'
+ else
+ options[:document].delete 'rdoc'
+ end
+
+ options[:document].uniq!
+ end
+
+ add_option(:Deprecated, '--[no-]ri',
+ 'Generate ri data for installed gems.',
+ 'Use --document instead') do |value, options|
+ if value then
+ options[:document] << 'ri'
+ else
+ options[:document].delete 'ri'
+ end
+
+ options[:document].uniq!
+ end
+
add_option(:"Install/Update", '-E', '--[no-]env-shebang',
"Rewrite the shebang line on installed",
"scripts to use /usr/bin/env") do |value, options|
@@ -140,7 +164,7 @@ module Gem::InstallUpdateOptions
File.exist? file
end unless v
- unless v
+ unless v then
message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ', '})"
raise OptionParser::InvalidArgument,
@@ -178,6 +202,7 @@ module Gem::InstallUpdateOptions
'Suggest alternates when gems are not found') do |v,o|
options[:suggest_alternate] = v
end
+
end
##
@@ -188,3 +213,4 @@ module Gem::InstallUpdateOptions
end
end
+
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index ad39ec81bf..904d5a0c7c 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -7,7 +7,6 @@
require 'rubygems/command'
require 'rubygems/exceptions'
-require 'rubygems/deprecate'
require 'rubygems/package'
require 'rubygems/ext'
require 'rubygems/user_interaction'
@@ -28,13 +27,11 @@ require 'fileutils'
class Gem::Installer
- extend Gem::Deprecate
-
##
# Paths where env(1) might live. Some systems are broken and have it in
# /bin
- ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
+ ENV_PATHS = %w[/usr/bin/env /bin/env]
##
# Deprecated in favor of Gem::Ext::BuildError
@@ -65,11 +62,6 @@ class Gem::Installer
attr_reader :options
- ##
- # The gem package instance.
-
- attr_reader :package
-
@path_warning = false
@install_lock = Mutex.new
@@ -106,47 +98,39 @@ class Gem::Installer
##
# Construct an installer object for the gem file located at +path+
- def self.at(path, options = {})
+ def self.at path, options = {}
security_policy = options[:security_policy]
package = Gem::Package.new path, security_policy
new package, options
end
class FakePackage
-
attr_accessor :spec
- attr_accessor :dir_mode
- attr_accessor :prog_mode
- attr_accessor :data_mode
-
def initialize(spec)
@spec = spec
end
- def extract_files(destination_dir, pattern = '*')
+ def extract_files destination_dir, pattern = '*'
FileUtils.mkdir_p destination_dir
spec.files.each do |file|
file = File.join destination_dir, file
next if File.exist? file
FileUtils.mkdir_p File.dirname(file)
- File.open file, 'w' do |fp|
- fp.puts "# #{file}"
- end
+ File.open file, 'w' do |fp| fp.puts "# #{file}" end
end
end
- def copy_to(path)
+ def copy_to path
end
-
end
##
# Construct an installer object for an ephemeral gem (one where we don't
# actually have a .gem file, just a spec)
- def self.for_spec(spec, options = {})
+ def self.for_spec spec, options = {}
# FIXME: we should have a real Package class for this
new FakePackage.new(spec), options
end
@@ -192,11 +176,7 @@ class Gem::Installer
process_options
- @package.dir_mode = options[:dir_mode]
- @package.prog_mode = options[:prog_mode]
- @package.data_mode = options[:data_mode]
-
- if options[:user_install]
+ if options[:user_install] and not options[:unpack] then
@gem_home = Gem.user_dir
@bin_dir = Gem.bindir gem_home unless options[:bin_dir]
check_that_user_bin_dir_is_in_path
@@ -216,7 +196,7 @@ class Gem::Installer
#
# Otherwise +filename+ is overwritten.
- def check_executable_overwrite(filename) # :nodoc:
+ def check_executable_overwrite filename # :nodoc:
return if @force
generated_bin = File.join @bin_dir, formatted_program_filename(filename)
@@ -252,7 +232,7 @@ class Gem::Installer
question = "#{spec.name}'s executable \"#{filename}\" conflicts with ".dup
- if ruby_executable
+ if ruby_executable then
question << (existing || 'an unknown executable')
return if ask_yes_no "#{question}\nOverwrite the executable?", false
@@ -305,7 +285,7 @@ class Gem::Installer
run_pre_install_hooks
# Set loaded_from to ensure extension_dir is correct
- if @options[:install_as_default]
+ if @options[:install_as_default] then
spec.loaded_from = default_spec_file
else
spec.loaded_from = spec_file
@@ -315,10 +295,9 @@ class Gem::Installer
FileUtils.rm_rf gem_dir
FileUtils.rm_rf spec.extension_dir
- dir_mode = options[:dir_mode]
- FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p gem_dir
- if @options[:install_as_default]
+ if @options[:install_as_default] then
extract_bin
write_default_spec
else
@@ -327,17 +306,12 @@ class Gem::Installer
build_extensions
write_build_info_file
run_post_build_hooks
- end
- generate_bin
-
- unless @options[:install_as_default]
+ generate_bin
write_spec
write_cache_file
end
- File.chmod(dir_mode, gem_dir) if dir_mode
-
say spec.post_install_message if options[:post_install_message] && !spec.post_install_message.nil?
Gem::Installer.install_lock.synchronize { Gem::Specification.reset }
@@ -354,8 +328,8 @@ class Gem::Installer
def run_pre_install_hooks # :nodoc:
Gem.pre_install_hooks.each do |hook|
- if hook.call(self) == false
- location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
+ if hook.call(self) == false then
+ location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
message = "pre-install hook#{location} failed for #{spec.full_name}"
raise Gem::InstallError, message
@@ -365,10 +339,10 @@ class Gem::Installer
def run_post_build_hooks # :nodoc:
Gem.post_build_hooks.each do |hook|
- if hook.call(self) == false
+ if hook.call(self) == false then
FileUtils.rm_rf gem_dir
- location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
+ location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
message = "post-build hook#{location} failed for #{spec.full_name}"
raise Gem::InstallError, message
@@ -391,8 +365,8 @@ class Gem::Installer
@specs ||= begin
specs = []
- Gem::Util.glob_files_in_dir("*.gemspec", File.join(gem_home, "specifications")).each do |path|
- spec = Gem::Specification.load path.tap(&Gem::UNTAINT)
+ Dir[File.join(gem_home, "specifications", "*.gemspec")].each do |path|
+ spec = Gem::Specification.load path.untaint
specs << spec if spec
end
@@ -408,7 +382,7 @@ class Gem::Installer
# dependency :: Gem::Dependency
def ensure_dependency(spec, dependency)
- unless installation_satisfies_dependency? dependency
+ unless installation_satisfies_dependency? dependency then
raise Gem::InstallError, "#{spec.name} requires #{dependency}"
end
true
@@ -431,7 +405,6 @@ class Gem::Installer
@gem_dir = directory
extract_files
end
- deprecate :unpack, :none, 2020, 04
##
# The location of the spec file that is installed.
@@ -446,7 +419,7 @@ class Gem::Installer
#
def default_spec_file
- File.join Gem.default_specifications_dir, "#{spec.full_name}.gemspec"
+ File.join Gem::Specification.default_specifications_dir, "#{spec.full_name}.gemspec"
end
##
@@ -477,8 +450,8 @@ class Gem::Installer
# Creates windows .bat files for easy running of commands
def generate_windows_script(filename, bindir)
- if Gem.win_platform?
- script_name = formatted_program_filename(filename) + ".bat"
+ if Gem.win_platform? then
+ script_name = filename + ".bat"
script_path = File.join bindir, File.basename(script_name)
File.open script_path, 'w' do |file|
file.puts windows_stub_script(bindir, filename)
@@ -492,7 +465,7 @@ class Gem::Installer
return if spec.executables.nil? or spec.executables.empty?
begin
- Dir.mkdir @bin_dir, *[options[:dir_mode] && 0755].compact
+ Dir.mkdir @bin_dir
rescue SystemCallError
raise unless File.directory? @bin_dir
end
@@ -500,22 +473,21 @@ class Gem::Installer
raise Gem::FilePermissionError.new(@bin_dir) unless File.writable? @bin_dir
spec.executables.each do |filename|
- filename.tap(&Gem::UNTAINT)
+ filename.untaint
bin_path = File.join gem_dir, spec.bindir, filename
- unless File.exist? bin_path
+ unless File.exist? bin_path then
# TODO change this to a more useful warning
warn "`#{bin_path}` does not exist, maybe `gem pristine #{spec.name}` will fix it?"
next
end
mode = File.stat(bin_path).mode
- dir_mode = options[:prog_mode] || (mode | 0111)
- FileUtils.chmod dir_mode, bin_path unless dir_mode == mode
+ FileUtils.chmod mode | 0111, bin_path unless (mode | 0111) == mode
check_executable_overwrite filename
- if @wrappers
+ if @wrappers then
generate_bin_script filename, @bin_dir
else
generate_bin_symlink filename, @bin_dir
@@ -538,7 +510,6 @@ class Gem::Installer
File.open bin_script_path, 'wb', 0755 do |file|
file.print app_script_text(filename)
- file.chmod(options[:prog_mode] || 0755)
end
verbose bin_script_path
@@ -554,8 +525,8 @@ class Gem::Installer
src = File.join gem_dir, spec.bindir, filename
dst = File.join bindir, formatted_program_filename(filename)
- if File.exist? dst
- if File.symlink? dst
+ if File.exist? dst then
+ if File.symlink? dst then
link = File.readlink(dst).split File::SEPARATOR
cur_version = Gem::Version.create(link[-3].sub(/^.*-/, ''))
return if spec.version < cur_version
@@ -589,7 +560,7 @@ class Gem::Installer
path = File.join gem_dir, spec.bindir, bin_file_name
first_line = File.open(path, "rb") {|file| file.gets}
- if /\A#!/ =~ first_line
+ if /\A#!/ =~ first_line then
# Preserve extra words on shebang line, like "-w". Thanks RPA.
shebang = first_line.sub(/\A\#!.*?ruby\S*((\s+\S+)+)/, "#!#{Gem.ruby}")
opts = $1
@@ -614,9 +585,9 @@ class Gem::Installer
end
"#!#{which}"
- elsif not ruby_name
+ elsif not ruby_name then
"#!#{Gem.ruby}#{opts}"
- elsif opts
+ elsif opts then
"#!/bin/sh\n'exec' #{ruby_name.dump} '-x' \"$0\" \"$@\"\n#{shebang}"
else
# Create a plain shebang line.
@@ -631,7 +602,7 @@ class Gem::Installer
def ensure_loadable_spec
ruby = spec.to_ruby_for_cache
- ruby.tap(&Gem::UNTAINT)
+ ruby.untaint
begin
eval ruby
@@ -642,9 +613,9 @@ class Gem::Installer
end
def ensure_required_ruby_version_met # :nodoc:
- if rrv = spec.required_ruby_version
- ruby_version = Gem.ruby_version
- unless rrv.satisfied_by? ruby_version
+ if rrv = spec.required_ruby_version then
+ unless rrv.satisfied_by? Gem.ruby_version then
+ ruby_version = Gem.ruby_api_version
raise Gem::RuntimeRequirementNotMetError,
"#{spec.name} requires Ruby version #{rrv}. The current ruby version is #{ruby_version}."
end
@@ -652,8 +623,8 @@ class Gem::Installer
end
def ensure_required_rubygems_version_met # :nodoc:
- if rrgv = spec.required_rubygems_version
- unless rrgv.satisfied_by? Gem.rubygems_version
+ if rrgv = spec.required_rubygems_version then
+ unless rrgv.satisfied_by? Gem.rubygems_version then
rg_version = Gem::VERSION
raise Gem::RuntimeRequirementNotMetError,
"#{spec.name} requires RubyGems version #{rrgv}. The current RubyGems version is #{rg_version}. " +
@@ -696,7 +667,7 @@ class Gem::Installer
@development = options[:development]
@build_root = options[:build_root]
- @build_args = options[:build_args] || Gem::Command.build_args
+ @build_args = options[:build_args] || Gem::Command.build_args
unless @build_root.nil?
require 'pathname'
@@ -713,16 +684,16 @@ class Gem::Installer
File::ALT_SEPARATOR
path = ENV['PATH']
- if Gem.win_platform?
+ if Gem.win_platform? then
path = path.downcase
user_bin_dir = user_bin_dir.downcase
end
path = path.split(File::PATH_SEPARATOR)
- unless path.include? user_bin_dir
+ unless path.include? user_bin_dir then
unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV['HOME'], '~'))
- unless self.class.path_warning
+ unless self.class.path_warning then
alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
self.class.path_warning = true
end
@@ -730,9 +701,10 @@ class Gem::Installer
end
end
- def verify_gem_home # :nodoc:
- FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0755
- raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home)
+ def verify_gem_home(unpack = false) # :nodoc:
+ FileUtils.mkdir_p gem_home
+ raise Gem::FilePermissionError, gem_home unless
+ unpack or File.writable?(gem_home)
end
def verify_spec
@@ -740,11 +712,11 @@ class Gem::Installer
raise Gem::InstallError, "#{spec} has an invalid name"
end
- if spec.raw_require_paths.any?{|path| path =~ /\R/ }
+ if spec.raw_require_paths.any?{|path| path =~ /\r\n|\r|\n/ }
raise Gem::InstallError, "#{spec} has an invalid require_paths"
end
- if spec.extensions.any?{|ext| ext =~ /\R/ }
+ if spec.extensions.any?{|ext| ext =~ /\r\n|\r|\n/ }
raise Gem::InstallError, "#{spec} has an invalid extensions"
end
@@ -752,11 +724,7 @@ class Gem::Installer
raise Gem::InstallError, "#{spec} has an invalid specification_version"
end
- if spec.dependencies.any? {|dep| dep.type != :runtime && dep.type != :development }
- raise Gem::InstallError, "#{spec} has an invalid dependencies"
- end
-
- if spec.dependencies.any? {|dep| dep.name =~ /(?:\R|[<>])/ }
+ if spec.dependencies.any? {|dep| dep.type =~ /\r\n|\r|\n/ || dep.name =~ /\r\n|\r|\n/ }
raise Gem::InstallError, "#{spec} has an invalid dependencies"
end
end
@@ -778,13 +746,13 @@ class Gem::Installer
require 'rubygems'
-version = "#{Gem::Requirement.default_prerelease}"
+version = "#{Gem::Requirement.default}.a"
-str = ARGV.first
-if str
- str = str.b[/\\A_(.*)_\\z/, 1]
- if str and Gem::Version.correct?(str)
- version = str
+if ARGV.first
+ str = ARGV.first
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
+ if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
+ version = $1
ARGV.shift
end
end
@@ -802,38 +770,17 @@ TEXT
# return the stub script text used to launch the true Ruby script
def windows_stub_script(bindir, bin_file_name)
- rb_config = RbConfig::CONFIG
- rb_topdir = RbConfig::TOPDIR || File.dirname(rb_config["bindir"])
-
- # get ruby executable file name from RbConfig
- ruby_exe = "#{rb_config['RUBY_INSTALL_NAME']}#{rb_config['EXEEXT']}"
- ruby_exe = "ruby.exe" if ruby_exe.empty?
-
- if File.exist?(File.join bindir, ruby_exe)
- # stub & ruby.exe withing same folder. Portable
- <<-TEXT
-@ECHO OFF
-@"%~dp0#{ruby_exe}" "%~dpn0" %*
- TEXT
- elsif bindir.downcase.start_with? rb_topdir.downcase
- # stub within ruby folder, but not standard bin. Portable
- require 'pathname'
- from = Pathname.new bindir
- to = Pathname.new "#{rb_topdir}/bin"
- rel = to.relative_path_from from
- <<-TEXT
-@ECHO OFF
-@"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %*
- TEXT
- else
- # outside ruby folder, maybe -user-install or bundler. Portable, but ruby
- # is dependent on PATH
- <<-TEXT
+ ruby = Gem.ruby.gsub(/^\"|\"$/, "").tr(File::SEPARATOR, "\\")
+ return <<-TEXT
@ECHO OFF
-@#{ruby_exe} "%~dpn0" %*
- TEXT
- end
+IF NOT "%~f0" == "~f0" GOTO :WinNT
+@"#{ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
+GOTO :EOF
+:WinNT
+@"#{ruby}" "%~dpn0" %*
+TEXT
end
+
##
# Builds extensions. Valid types of extensions are extconf.rb files,
# configure scripts and rakefiles or mkrf_conf files.
@@ -847,14 +794,13 @@ TEXT
##
# Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError.
#
- # TODO: Delete this for RubyGems 4. It remains for API compatibility
+ # TODO: Delete this for RubyGems 3. It remains for API compatibility
def extension_build_error(build_dir, output, backtrace = nil) # :nodoc:
builder = Gem::Ext::Builder.new spec, @build_args
builder.build_error build_dir, output, backtrace
end
- deprecate :extension_build_error, :none, 2018, 12
##
# Reads the file index and extracts each file into the gem directory.
@@ -871,14 +817,14 @@ TEXT
# without the full gem installed.
def extract_bin
- @package.extract_files gem_dir, "#{spec.bindir}/*"
+ @package.extract_files gem_dir, "bin/*"
end
##
# Prefix and suffix the program filename the same as ruby.
def formatted_program_filename(filename)
- if @format_executable
+ if @format_executable then
self.class.exec_format % File.basename(filename)
else
filename
@@ -905,7 +851,7 @@ TEXT
# The dependent check will be skipped if the install is ignoring dependencies.
def pre_install_checks
- verify_gem_home
+ verify_gem_home options[:unpack]
# The name and require_paths must be verified first, since it could contain
# ruby code that would be eval'ed in #ensure_loadable_spec
@@ -937,8 +883,7 @@ TEXT
build_info_dir = File.join gem_home, 'build_info'
- dir_mode = options[:dir_mode]
- FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p build_info_dir
build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
@@ -947,8 +892,6 @@ TEXT
io.puts arg
end
end
-
- File.chmod(dir_mode, build_info_dir) if dir_mode
end
##
diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb
index f48466d3ea..4cec5da3f4 100644
--- a/lib/rubygems/installer_test_case.rb
+++ b/lib/rubygems/installer_test_case.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems/installer'
+require 'rubygems/deprecate'
class Gem::Installer
@@ -58,7 +59,6 @@ class Gem::Installer
# Available through requiring rubygems/installer_test_case
attr_writer :wrappers
-
end
##
@@ -66,12 +66,59 @@ end
class Gem::InstallerTestCase < Gem::TestCase
+ ##
+ # Creates the following instance variables:
+ #
+ # @spec::
+ # a spec named 'a', intended for regular installs
+ # @user_spec::
+ # a spec named 'b', intended for user installs
+ #
+ # @gem::
+ # the path to a built gem from @spec
+ # @user_spec::
+ # the path to a built gem from @user_spec
+ #
+ # @installer::
+ # a Gem::Installer for the @spec that installs into @gemhome
+ # @user_installer::
+ # a Gem::Installer for the @user_spec that installs into Gem.user_dir
+
def setup
super
+ @spec = quick_gem 'a' do |spec|
+ util_make_exec spec
+ end
+
+ @user_spec = quick_gem 'b' do |spec|
+ util_make_exec spec
+ end
+
+ util_build_gem @spec
+ util_build_gem @user_spec
+
+ @gem = @spec.cache_file
+ @user_gem = @user_spec.cache_file
+
+ @installer = util_installer @spec, @gemhome
+ @user_installer = util_installer @user_spec, Gem.user_dir, :user
+
Gem::Installer.path_warning = false
end
+ def util_gem_bindir spec = @spec # :nodoc:
+ spec.bin_dir
+ end
+
+ def util_gem_dir spec = @spec # :nodoc:
+ spec.gem_dir
+ end
+
+ extend Gem::Deprecate
+ deprecate :util_gem_bindir, "@spec.bin_dir", 2016, 10
+ deprecate :util_gem_dir, "@spec.gem_dir", 2016, 10
+
##
# The path where installed executables live
@@ -85,9 +132,9 @@ class Gem::InstallerTestCase < Gem::TestCase
# The executable is also written to the bin dir in @tmpdir and the installed
# gem directory for +spec+.
- def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby", bindir = "bin")
+ def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby")
spec.executables = %w[executable]
- spec.bindir = bindir
+ spec.files << 'bin/executable'
exec_path = spec.bin_file "executable"
write_file exec_path do |io|
@@ -101,83 +148,6 @@ class Gem::InstallerTestCase < Gem::TestCase
end
##
- # Creates the following instance variables:
- #
- # @spec::
- # a spec named 'a', intended for regular installs
- #
- # @gem::
- # the path to a built gem from @spec
- #
- # And returns a Gem::Installer for the @spec that installs into @gemhome
-
- def setup_base_installer
- @gem = setup_base_gem
- util_installer @spec, @gemhome
- end
-
- ##
- # Creates the following instance variables:
- #
- # @spec::
- # a spec named 'a', intended for regular installs
- #
- # And returns a gem built for the @spec
-
- def setup_base_gem
- @spec = setup_base_spec
- util_build_gem @spec
- @spec.cache_file
- end
-
- ##
- # Sets up a generic specification for testing the rubygems installer
- #
- # And returns it
-
- def setup_base_spec
- quick_gem 'a' do |spec|
- util_make_exec spec
- end
- end
-
- ##
- # Creates the following instance variables:
- #
- # @spec::
- # a spec named 'a', intended for regular installs
- # @user_spec::
- # a spec named 'b', intended for user installs
- #
- # @gem::
- # the path to a built gem from @spec
- # @user_gem::
- # the path to a built gem from @user_spec
- #
- # And returns a Gem::Installer for the @user_spec that installs into Gem.user_dir
-
- def setup_base_user_installer
- @user_spec = quick_gem 'b' do |spec|
- util_make_exec spec
- end
-
- util_build_gem @user_spec
-
- @user_gem = @user_spec.cache_file
-
- util_installer @user_spec, Gem.user_dir, :user
- end
-
- ##
- # Sets up the base @gem, builds it and returns an installer for it.
- #
- def util_setup_installer
- @gem = setup_base_gem
-
- util_setup_gem
- end
-
- ##
# Builds the @spec gem and returns an installer for it. The built gem
# includes:
#
@@ -185,7 +155,7 @@ class Gem::InstallerTestCase < Gem::TestCase
# lib/code.rb
# ext/a/mkrf_conf.rb
- def util_setup_gem(ui = @ui)
+ def util_setup_gem(ui = @ui) # HACK fix use_ui to make this automatic
@spec.files << File.join('lib', 'code.rb')
@spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb')
@@ -193,15 +163,10 @@ class Gem::InstallerTestCase < Gem::TestCase
FileUtils.mkdir_p 'bin'
FileUtils.mkdir_p 'lib'
FileUtils.mkdir_p File.join('ext', 'a')
-
File.open File.join('bin', 'executable'), 'w' do |f|
f.puts "raise 'ran executable'"
end
-
- File.open File.join('lib', 'code.rb'), 'w' do |f|
- f.puts '1'
- end
-
+ File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
f << <<-EOF
File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end
@@ -217,7 +182,7 @@ class Gem::InstallerTestCase < Gem::TestCase
end
end
- Gem::Installer.at @gem
+ @installer = Gem::Installer.at @gem
end
##
@@ -231,3 +196,4 @@ class Gem::InstallerTestCase < Gem::TestCase
end
end
+
diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb
index c940f50ad6..597b87ea03 100644
--- a/lib/rubygems/local_remote_options.rb
+++ b/lib/rubygems/local_remote_options.rb
@@ -24,10 +24,8 @@ module Gem::LocalRemoteOptions
raise OptionParser::InvalidArgument, value
end
- valid_uri_schemes = ["http", "https", "file", "s3"]
- unless valid_uri_schemes.include?(uri.scheme)
- msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map{|s| "#{s}://"}}"
- raise ArgumentError, msg
+ unless ['http', 'https', 'file', 's3'].include?(uri.scheme)
+ raise OptionParser::InvalidArgument, value
end
value
@@ -108,7 +106,7 @@ module Gem::LocalRemoteOptions
source << '/' if source !~ /\/\z/
- if options.delete :sources_cleared
+ if options.delete :sources_cleared then
Gem.sources = [source]
else
Gem.sources << source unless Gem.sources.include?(source)
@@ -148,3 +146,4 @@ module Gem::LocalRemoteOptions
end
end
+
diff --git a/lib/rubygems/mock_gem_ui.rb b/lib/rubygems/mock_gem_ui.rb
index 9ece75881c..0223f8c35d 100644
--- a/lib/rubygems/mock_gem_ui.rb
+++ b/lib/rubygems/mock_gem_ui.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+require 'stringio'
require 'rubygems/user_interaction'
##
@@ -6,27 +7,24 @@ require 'rubygems/user_interaction'
# retrieval during tests.
class Gem::MockGemUi < Gem::StreamUI
-
##
# Raised when you haven't provided enough input to your MockGemUi
class InputEOFError < RuntimeError
- def initialize(question)
+ def initialize question
super "Out of input for MockGemUi on #{question.inspect}"
end
end
class TermError < RuntimeError
-
attr_reader :exit_code
- def initialize(exit_code)
+ def initialize exit_code
super
@exit_code = exit_code
end
-
end
class SystemExitException < RuntimeError; end
@@ -45,7 +43,6 @@ class Gem::MockGemUi < Gem::StreamUI
end
def initialize(input = "")
- require 'stringio'
ins = StringIO.new input
outs = StringIO.new
errs = StringIO.new
@@ -59,7 +56,7 @@ class Gem::MockGemUi < Gem::StreamUI
@terminated = false
end
- def ask(question)
+ def ask question
raise InputEOFError, question if @ins.eof?
super
@@ -89,3 +86,4 @@ class Gem::MockGemUi < Gem::StreamUI
end
end
+
diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb
index dc1a1bbaa0..316329a0bd 100644
--- a/lib/rubygems/name_tuple.rb
+++ b/lib/rubygems/name_tuple.rb
@@ -7,7 +7,6 @@
require 'rubygems/platform'
class Gem::NameTuple
-
def initialize(name, version, platform="ruby")
@name = name
@version = version
@@ -25,7 +24,7 @@ class Gem::NameTuple
# Turn an array of [name, version, platform] into an array of
# NameTuple objects.
- def self.from_list(list)
+ def self.from_list list
list.map { |t| new(*t) }
end
@@ -33,7 +32,7 @@ class Gem::NameTuple
# Turn an array of NameTuple objects back into an array of
# [name, version, platform] tuples.
- def self.to_basic(list)
+ def self.to_basic list
list.map { |t| t.to_a }
end
@@ -55,7 +54,7 @@ class Gem::NameTuple
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@platform}"
- end.dup.tap(&Gem::UNTAINT)
+ end.dup.untaint
end
##
@@ -91,7 +90,7 @@ class Gem::NameTuple
alias to_s inspect # :nodoc:
- def <=>(other)
+ def <=> other
[@name, @version, @platform == Gem::Platform::RUBY ? -1 : 1] <=>
[other.name, other.version,
other.platform == Gem::Platform::RUBY ? -1 : 1]
@@ -103,7 +102,7 @@ class Gem::NameTuple
# Compare with +other+. Supports another NameTuple or an Array
# in the [name, version, platform] format.
- def ==(other)
+ def == other
case other
when self.class
@name == other.name and
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 813ab9da33..b472b97a07 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -53,10 +53,9 @@ class Gem::Package
class Error < Gem::Exception; end
class FormatError < Error
-
attr_reader :path
- def initialize(message, source = nil)
+ def initialize message, source = nil
if source
@path = source.path
@@ -69,12 +68,10 @@ class Gem::Package
end
class PathError < Error
-
- def initialize(destination, destination_dir)
+ def initialize destination, destination_dir
super "installing into parent path %s of %s is not allowed" %
[destination, destination_dir]
end
-
end
class NonSeekableIO < Error; end
@@ -86,6 +83,7 @@ class Gem::Package
class TarInvalidError < Error; end
+
attr_accessor :build_time # :nodoc:
##
@@ -100,11 +98,6 @@ class Gem::Package
attr_reader :files
##
- # Reference to the gem being packaged.
-
- attr_reader :gem
-
- ##
# The security policy used for verifying the contents of this package.
attr_accessor :security_policy
@@ -114,24 +107,12 @@ class Gem::Package
attr_writer :spec
- ##
- # Permission for directories
- attr_accessor :dir_mode
-
- ##
- # Permission for program files
- attr_accessor :prog_mode
-
- ##
- # Permission for other files
- attr_accessor :data_mode
-
- def self.build(spec, skip_validation = false, strict_validation = false, file_name = nil)
- gem_file = file_name || spec.file_name
+ def self.build spec, skip_validation=false
+ gem_file = spec.file_name
package = new gem_file
package.spec = spec
- package.build skip_validation, strict_validation
+ package.build skip_validation
gem_file
end
@@ -143,7 +124,7 @@ class Gem::Package
# If +gem+ is an existing file in the old format a Gem::Package::Old will be
# returned.
- def self.new(gem, security_policy = nil)
+ def self.new gem, security_policy = nil
gem = if gem.is_a?(Gem::Package::Source)
gem
elsif gem.respond_to? :read
@@ -162,38 +143,12 @@ class Gem::Package
end
##
- # Extracts the Gem::Specification and raw metadata from the .gem file at
- # +path+.
- #--
-
- def self.raw_spec(path, security_policy = nil)
- format = new(path, security_policy)
- spec = format.spec
-
- metadata = nil
-
- File.open path, Gem.binary_mode do |io|
- tar = Gem::Package::TarReader.new io
- tar.each_entry do |entry|
- case entry.full_name
- when 'metadata' then
- metadata = entry.read
- when 'metadata.gz' then
- metadata = Gem::Util.gunzip entry.read
- end
- end
- end
-
- return spec, metadata
- end
-
- ##
# Creates a new package that will read or write to the file +gem+.
- def initialize(gem, security_policy) # :notnew:
+ def initialize gem, security_policy # :notnew:
@gem = gem
- @build_time = Gem.source_date_epoch
+ @build_time = Time.now
@checksums = {}
@contents = nil
@digests = Hash.new { |h, algorithm| h[algorithm] = {} }
@@ -207,14 +162,14 @@ class Gem::Package
##
# Copies this package to +path+ (if possible)
- def copy_to(path)
+ def copy_to path
FileUtils.cp @gem.path, path unless File.exist? path
end
##
# Adds a checksum for each entry in the gem to checksums.yaml.gz.
- def add_checksums(tar)
+ def add_checksums tar
Gem.load_yaml
checksums_by_algorithm = Hash.new { |h, algorithm| h[algorithm] = {} }
@@ -236,7 +191,7 @@ class Gem::Package
# Adds the files listed in the packages's Gem::Specification to data.tar.gz
# and adds this file to the +tar+.
- def add_contents(tar) # :nodoc:
+ def add_contents tar # :nodoc:
digests = tar.add_file_signed 'data.tar.gz', 0444, @signer do |io|
gzip_to io do |gz_io|
Gem::Package::TarWriter.new gz_io do |data_tar|
@@ -251,18 +206,13 @@ class Gem::Package
##
# Adds files included the package's Gem::Specification to the +tar+ file
- def add_files(tar) # :nodoc:
+ def add_files tar # :nodoc:
@spec.files.each do |file|
stat = File.lstat file
if stat.symlink?
- target_path = File.readlink(file)
-
- unless target_path.start_with? '.'
- relative_dir = File.dirname(file).sub("#{Dir.pwd}/", '')
- target_path = File.join(relative_dir, target_path)
- end
-
+ relative_dir = File.dirname(file).sub("#{Dir.pwd}/", '')
+ target_path = File.join(relative_dir, File.readlink(file))
tar.add_symlink file, target_path, stat.mode
end
@@ -279,7 +229,7 @@ class Gem::Package
##
# Adds the package's Gem::Specification to the +tar+ file
- def add_metadata(tar) # :nodoc:
+ def add_metadata tar # :nodoc:
digests = tar.add_file_signed 'metadata.gz', 0444, @signer do |io|
gzip_to io do |gz_io|
gz_io.write @spec.to_yaml
@@ -292,19 +242,14 @@ class Gem::Package
##
# Builds this package based on the specification set by #spec=
- def build(skip_validation = false, strict_validation = false)
- raise ArgumentError, "skip_validation = true and strict_validation = true are incompatible" if skip_validation && strict_validation
-
+ def build skip_validation = false
Gem.load_yaml
+ require 'rubygems/security'
@spec.mark_version
- @spec.validate true, strict_validation unless skip_validation
+ @spec.validate unless skip_validation
- setup_signer(
- signer_options: {
- expiration_length_days: Gem.configuration.cert_expiration_length_days
- }
- )
+ setup_signer
@gem.with_write_io do |gem_io|
Gem::Package::TarWriter.new gem_io do |gem|
@@ -318,7 +263,7 @@ class Gem::Package
Successfully built RubyGem
Name: #{@spec.name}
Version: #{@spec.version}
- File: #{File.basename @gem.path}
+ File: #{File.basename @spec.cache_file}
EOM
ensure
@signer = nil
@@ -355,8 +300,8 @@ EOM
# Creates a digest of the TarEntry +entry+ from the digest algorithm set by
# the security policy.
- def digest(entry) # :nodoc:
- algorithms = if @checksums
+ def digest entry # :nodoc:
+ algorithms = if @checksums then
@checksums.keys
else
[Gem::Security::DIGEST_NAME].compact
@@ -364,7 +309,7 @@ EOM
algorithms.each do |algorithm|
digester =
- if defined?(OpenSSL::Digest)
+ if defined?(OpenSSL::Digest) then
OpenSSL::Digest.new algorithm
else
Digest.const_get(algorithm).new
@@ -386,10 +331,10 @@ EOM
# If +pattern+ is specified, only entries matching that glob will be
# extracted.
- def extract_files(destination_dir, pattern = "*")
+ def extract_files destination_dir, pattern = "*"
verify unless @spec
- FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p destination_dir
@gem.with_read_io do |io|
reader = Gem::Package::TarReader.new io
@@ -415,8 +360,7 @@ EOM
# If +pattern+ is specified, only entries matching that glob will be
# extracted.
- def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
- directories = [] if dir_mode
+ def extract_tar_gz io, destination_dir, pattern = "*" # :nodoc:
open_tar_gz io do |tar|
tar.each do |entry|
next unless File.fnmatch pattern, entry.full_name, File::FNM_DOTMATCH
@@ -426,20 +370,19 @@ EOM
FileUtils.rm_rf destination
mkdir_options = {}
- mkdir_options[:mode] = dir_mode ? 0755 : (entry.header.mode if entry.directory?)
+ mkdir_options[:mode] = entry.header.mode if entry.directory?
mkdir =
- if entry.directory?
+ if entry.directory? then
destination
else
File.dirname destination
end
- directories << mkdir if directories
mkdir_p_safe mkdir, mkdir_options, destination_dir, entry.full_name
File.open destination, 'wb' do |out|
out.write entry.read
- FileUtils.chmod file_mode(entry.header.mode), destination
+ FileUtils.chmod entry.header.mode, destination
end if entry.file?
File.symlink(entry.header.linkname, destination) if entry.symlink?
@@ -447,15 +390,6 @@ EOM
verbose destination
end
end
-
- if directories
- directories.uniq!
- File.chmod(dir_mode, *directories)
- end
- end
-
- def file_mode(mode) # :nodoc:
- ((mode & 0111).zero? ? data_mode : prog_mode) || mode
end
##
@@ -464,7 +398,7 @@ EOM
# Also sets the gzip modification time to the package build time to ease
# testing.
- def gzip_to(io) # :yields: gz_io
+ def gzip_to io # :yields: gz_io
gz_io = Zlib::GzipWriter.new io, Zlib::BEST_COMPRESSION
gz_io.mtime = @build_time
@@ -478,12 +412,15 @@ EOM
#
# If +filename+ is not inside +destination_dir+ an exception is raised.
- def install_location(filename, destination_dir) # :nodoc:
+ def install_location filename, destination_dir # :nodoc:
raise Gem::Package::PathError.new(filename, destination_dir) if
filename.start_with? '/'
- destination_dir = File.expand_path(File.realpath(destination_dir))
- destination = File.expand_path(File.join(destination_dir, filename))
+ destination_dir = realpath destination_dir
+ destination_dir = File.expand_path destination_dir
+
+ destination = File.join destination_dir, filename
+ destination = File.expand_path destination
raise Gem::Package::PathError.new(destination, destination_dir) unless
destination.start_with? destination_dir + '/'
@@ -498,27 +435,19 @@ EOM
real_destination.start_with? destination_dir + '/'
end
- destination.tap(&Gem::UNTAINT)
+ destination.untaint
destination
end
- def normalize_path(pathname)
- if Gem.win_platform?
- pathname.downcase
- else
- pathname
- end
- end
-
- def mkdir_p_safe(mkdir, mkdir_options, destination_dir, file_name)
- destination_dir = File.realpath(File.expand_path(destination_dir))
+ def mkdir_p_safe mkdir, mkdir_options, destination_dir, file_name
+ destination_dir = realpath File.expand_path(destination_dir)
parts = mkdir.split(File::SEPARATOR)
parts.reduce do |path, basename|
- path = File.realpath(path) unless path == ""
+ path = realpath path unless path == ""
path = File.expand_path(path + File::SEPARATOR + basename)
lstat = File.lstat path rescue nil
if !lstat || !lstat.directory?
- unless normalize_path(path).start_with? normalize_path(destination_dir) and (FileUtils.mkdir path, **mkdir_options rescue false)
+ unless path.start_with? destination_dir and (FileUtils.mkdir path, mkdir_options rescue false)
raise Gem::Package::PathError.new(file_name, destination_dir)
end
end
@@ -529,12 +458,17 @@ EOM
##
# Loads a Gem::Specification from the TarEntry +entry+
- def load_spec(entry) # :nodoc:
+ def load_spec entry # :nodoc:
case entry.full_name
when 'metadata' then
@spec = Gem::Specification.from_yaml entry.read
when 'metadata.gz' then
- Zlib::GzipReader.wrap(entry, external_encoding: Encoding::UTF_8) do |gzio|
+ args = [entry]
+ args << { :external_encoding => Encoding::UTF_8 } if
+ Object.const_defined?(:Encoding) &&
+ Zlib::GzipReader.method(:wrap).arity != 1
+
+ Zlib::GzipReader.wrap(*args) do |gzio|
@spec = Gem::Specification.from_yaml gzio.read
end
end
@@ -543,7 +477,7 @@ EOM
##
# Opens +io+ as a gzipped tar archive
- def open_tar_gz(io) # :nodoc:
+ def open_tar_gz io # :nodoc:
Zlib::GzipReader.wrap io do |gzio|
tar = Gem::Package::TarReader.new gzio
@@ -554,7 +488,7 @@ EOM
##
# Reads and loads checksums.yaml.gz from the tar file +gem+
- def read_checksums(gem)
+ def read_checksums gem
Gem.load_yaml
@checksums = gem.seek 'checksums.yaml.gz' do |entry|
@@ -568,17 +502,10 @@ EOM
# Prepares the gem for signing and checksum generation. If a signing
# certificate and key are not present only checksum generation is set up.
- def setup_signer(signer_options: {})
+ def setup_signer
passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE']
- if @spec.signing_key
- @signer =
- Gem::Security::Signer.new(
- @spec.signing_key,
- @spec.cert_chain,
- passphrase,
- signer_options
- )
-
+ if @spec.signing_key then
+ @signer = Gem::Security::Signer.new @spec.signing_key, @spec.cert_chain, passphrase
@spec.signing_key = nil
@spec.cert_chain = @signer.cert_chain.map { |cert| cert.to_s }
else
@@ -643,14 +570,14 @@ EOM
# Verifies the +checksums+ against the +digests+. This check is not
# cryptographically secure. Missing checksums are ignored.
- def verify_checksums(digests, checksums) # :nodoc:
+ def verify_checksums digests, checksums # :nodoc:
return unless checksums
checksums.sort.each do |algorithm, gem_digests|
gem_digests.sort.each do |file_name, gem_hexdigest|
computed_digest = digests[algorithm][file_name]
- unless computed_digest.hexdigest == gem_hexdigest
+ unless computed_digest.hexdigest == gem_hexdigest then
raise Gem::Package::FormatError.new \
"#{algorithm} checksum mismatch for #{file_name}", @gem
end
@@ -661,7 +588,7 @@ EOM
##
# Verifies +entry+ in a .gem file.
- def verify_entry(entry)
+ def verify_entry entry
file_name = entry.full_name
@files << file_name
@@ -674,7 +601,7 @@ EOM
end
case file_name
- when "metadata", "metadata.gz" then
+ when /^metadata(.gz)?$/ then
load_spec entry
when 'data.tar.gz' then
verify_gz entry
@@ -688,16 +615,16 @@ EOM
##
# Verifies the files of the +gem+
- def verify_files(gem)
+ def verify_files gem
gem.each do |entry|
verify_entry entry
end
- unless @spec
+ unless @spec then
raise Gem::Package::FormatError.new 'package metadata is missing', @gem
end
- unless @files.include? 'data.tar.gz'
+ unless @files.include? 'data.tar.gz' then
raise Gem::Package::FormatError.new \
'package content (data.tar.gz) is missing', @gem
end
@@ -710,7 +637,7 @@ EOM
##
# Verifies that +entry+ is a valid gzipped file.
- def verify_gz(entry) # :nodoc:
+ def verify_gz entry # :nodoc:
Zlib::GzipReader.wrap entry do |gzio|
gzio.read 16384 until gzio.eof? # gzip checksum verification
end
@@ -718,6 +645,16 @@ EOM
raise Gem::Package::FormatError.new(e.message, entry.full_name)
end
+ if File.respond_to? :realpath
+ def realpath file
+ File.realpath file
+ end
+ else
+ def realpath file
+ file
+ end
+ end
+
end
require 'rubygems/package/digest_io'
diff --git a/lib/rubygems/package/digest_io.rb b/lib/rubygems/package/digest_io.rb
index d9e6c3c021..4930c9aa7d 100644
--- a/lib/rubygems/package/digest_io.rb
+++ b/lib/rubygems/package/digest_io.rb
@@ -31,7 +31,7 @@ class Gem::Package::DigestIO
# digests['SHA1'].hexdigest #=> "aaf4c61d[...]"
# digests['SHA512'].hexdigest #=> "9b71d224[...]"
- def self.wrap(io, digests)
+ def self.wrap io, digests
digest_io = new io, digests
yield digest_io
@@ -43,7 +43,7 @@ class Gem::Package::DigestIO
# Creates a new DigestIO instance. Using ::wrap is recommended, see the
# ::wrap documentation for documentation of +io+ and +digests+.
- def initialize(io, digests)
+ def initialize io, digests
@io = io
@digests = digests
end
@@ -51,7 +51,7 @@ class Gem::Package::DigestIO
##
# Writes +data+ to the underlying IO and updates the digests
- def write(data)
+ def write data
result = @io.write data
@digests.each do |_, digest|
@@ -62,3 +62,4 @@ class Gem::Package::DigestIO
end
end
+
diff --git a/lib/rubygems/package/file_source.rb b/lib/rubygems/package/file_source.rb
index 8a4f9da6f2..ecc3a68677 100644
--- a/lib/rubygems/package/file_source.rb
+++ b/lib/rubygems/package/file_source.rb
@@ -10,7 +10,7 @@ class Gem::Package::FileSource < Gem::Package::Source # :nodoc: all
attr_reader :path
- def initialize(path)
+ def initialize path
@path = path
end
@@ -22,12 +22,13 @@ class Gem::Package::FileSource < Gem::Package::Source # :nodoc: all
File.exist? path
end
- def with_write_io(&block)
+ def with_write_io &block
File.open path, 'wb', &block
end
- def with_read_io(&block)
+ def with_read_io &block
File.open path, 'rb', &block
end
end
+
diff --git a/lib/rubygems/package/io_source.rb b/lib/rubygems/package/io_source.rb
index 669a859d0a..ee79a21083 100644
--- a/lib/rubygems/package/io_source.rb
+++ b/lib/rubygems/package/io_source.rb
@@ -11,7 +11,7 @@ class Gem::Package::IOSource < Gem::Package::Source # :nodoc: all
attr_reader :io
- def initialize(io)
+ def initialize io
@io = io
end
@@ -43,3 +43,4 @@ class Gem::Package::IOSource < Gem::Package::Source # :nodoc: all
end
end
+
diff --git a/lib/rubygems/package/old.rb b/lib/rubygems/package/old.rb
index f574b989aa..322d682ca8 100644
--- a/lib/rubygems/package/old.rb
+++ b/lib/rubygems/package/old.rb
@@ -19,7 +19,7 @@ class Gem::Package::Old < Gem::Package
# Creates a new old-format package reader for +gem+. Old-format packages
# cannot be written.
- def initialize(gem, security_policy)
+ def initialize gem, security_policy
require 'fileutils'
require 'zlib'
Gem.load_yaml
@@ -49,7 +49,7 @@ class Gem::Package::Old < Gem::Package
##
# Extracts the files in this package into +destination_dir+
- def extract_files(destination_dir)
+ def extract_files destination_dir
verify
errstr = "Error reading files from gem"
@@ -78,9 +78,9 @@ class Gem::Package::Old < Gem::Package
FileUtils.rm_rf destination
- FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755
+ FileUtils.mkdir_p File.dirname destination
- File.open destination, 'wb', file_mode(entry['mode']) do |out|
+ File.open destination, 'wb', entry['mode'] do |out|
out.write file_data
end
@@ -94,7 +94,7 @@ class Gem::Package::Old < Gem::Package
##
# Reads the file list section from the old-format gem +io+
- def file_list(io) # :nodoc:
+ def file_list io # :nodoc:
header = String.new
read_until_dashes io do |line|
@@ -107,7 +107,7 @@ class Gem::Package::Old < Gem::Package
##
# Reads lines until a "---" separator is found
- def read_until_dashes(io) # :nodoc:
+ def read_until_dashes io # :nodoc:
while (line = io.gets) && line.chomp.strip != "---" do
yield line if block_given?
end
@@ -116,7 +116,7 @@ class Gem::Package::Old < Gem::Package
##
# Skips the Ruby self-install header in +io+.
- def skip_ruby(io) # :nodoc:
+ def skip_ruby io # :nodoc:
loop do
line = io.gets
@@ -144,9 +144,17 @@ class Gem::Package::Old < Gem::Package
end
end
+ yaml_error = if RUBY_VERSION < '1.9' then
+ YAML::ParseError
+ elsif YAML.const_defined?(:ENGINE) && YAML::ENGINE.yamler == 'syck' then
+ YAML::ParseError
+ else
+ YAML::SyntaxError
+ end
+
begin
@spec = Gem::Specification.from_yaml yaml
- rescue YAML::SyntaxError
+ rescue yaml_error
raise Gem::Exception, "Failed to parse gem specification out of gem file"
end
rescue ArgumentError
diff --git a/lib/rubygems/package/source.rb b/lib/rubygems/package/source.rb
index 69701e55e9..fe19776c38 100644
--- a/lib/rubygems/package/source.rb
+++ b/lib/rubygems/package/source.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Gem::Package::Source # :nodoc:
end
+
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index c37612772a..d557357114 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -50,7 +50,7 @@ class Gem::Package::TarHeader
:uid,
:uname,
:version,
- ].freeze
+ ]
##
# Pack format for a tar header
@@ -94,21 +94,19 @@ class Gem::Package::TarHeader
attr_reader(*FIELDS)
- EMPTY_HEADER = ("\0" * 512).freeze # :nodoc:
-
##
# Creates a tar header from IO +stream+
def self.from(stream)
header = stream.read 512
- empty = (EMPTY_HEADER == header)
+ empty = (header == "\0" * 512)
fields = header.unpack UNPACK_FORMAT
new :name => fields.shift,
:mode => strict_oct(fields.shift),
- :uid => oct_or_256based(fields.shift),
- :gid => oct_or_256based(fields.shift),
+ :uid => strict_oct(fields.shift),
+ :gid => strict_oct(fields.shift),
:size => strict_oct(fields.shift),
:mtime => strict_oct(fields.shift),
:checksum => strict_oct(fields.shift),
@@ -130,20 +128,11 @@ class Gem::Package::TarHeader
raise ArgumentError, "#{str.inspect} is not an octal string"
end
- def self.oct_or_256based(str)
- # \x80 flags a positive 256-based number
- # \ff flags a negative 256-based number
- # In case we have a match, parse it as a signed binary value
- # in big-endian order, except that the high-order bit is ignored.
- return str.unpack('N2').last if str =~ /\A[\x80\xff]/n
- strict_oct(str)
- end
-
##
# Creates a new TarHeader using +vals+
def initialize(vals)
- unless vals[:name] && vals[:size] && vals[:prefix] && vals[:mode]
+ unless vals[:name] && vals[:size] && vals[:prefix] && vals[:mode] then
raise ArgumentError, ":name, :size, :prefix and :mode required"
end
diff --git a/lib/rubygems/package/tar_reader.rb b/lib/rubygems/package/tar_reader.rb
index aa31ea27d4..1098336e36 100644
--- a/lib/rubygems/package/tar_reader.rb
+++ b/lib/rubygems/package/tar_reader.rb
@@ -55,8 +55,6 @@ class Gem::Package::TarReader
def each
return enum_for __method__ unless block_given?
- use_seek = @io.respond_to?(:seek)
-
until @io.eof? do
header = Gem::Package::TarHeader.from @io
return if header.empty?
@@ -69,22 +67,18 @@ class Gem::Package::TarReader
skip = (512 - (size % 512)) % 512
pending = size - entry.bytes_read
- if use_seek
- begin
- # avoid reading if the @io supports seeking
- @io.seek pending, IO::SEEK_CUR
- pending = 0
- rescue Errno::EINVAL
+ begin
+ # avoid reading...
+ @io.seek pending, IO::SEEK_CUR
+ pending = 0
+ rescue Errno::EINVAL, NameError
+ while pending > 0 do
+ bytes_read = @io.read([pending, 4096].min).size
+ raise UnexpectedEOF if @io.eof?
+ pending -= bytes_read
end
end
- # if seeking isn't supported or failed
- while pending > 0 do
- bytes_read = @io.read([pending, 4096].min).size
- raise UnexpectedEOF if @io.eof?
- pending -= bytes_read
- end
-
@io.read skip # discard trailing zeros
# make sure nobody can use #read, #getc or #rewind anymore
@@ -98,9 +92,11 @@ class Gem::Package::TarReader
# NOTE: Do not call #rewind during #each
def rewind
- if @init_pos == 0
+ if @init_pos == 0 then
+ raise Gem::Package::NonSeekableIO unless @io.respond_to? :rewind
@io.rewind
else
+ raise Gem::Package::NonSeekableIO unless @io.respond_to? :pos=
@io.pos = @init_pos
end
end
@@ -110,7 +106,7 @@ class Gem::Package::TarReader
# yields it. Rewinds the tar file to the beginning when the block
# terminates.
- def seek(name) # :yields: entry
+ def seek name # :yields: entry
found = find do |entry|
entry.full_name == name
end
diff --git a/lib/rubygems/package/tar_reader/entry.rb b/lib/rubygems/package/tar_reader/entry.rb
index 19054c1635..5f958edc2f 100644
--- a/lib/rubygems/package/tar_reader/entry.rb
+++ b/lib/rubygems/package/tar_reader/entry.rb
@@ -64,7 +64,7 @@ class Gem::Package::TarReader::Entry
# Full name of the tar entry
def full_name
- if @header.prefix != ""
+ if @header.prefix != "" then
File.join @header.prefix, @header.name
else
@header.name
@@ -119,12 +119,6 @@ class Gem::Package::TarReader::Entry
bytes_read
end
- def size
- @header.size
- end
-
- alias length size
-
##
# Reads +len+ bytes from the tar file entry, or the rest of the entry if
# nil
@@ -143,19 +137,7 @@ class Gem::Package::TarReader::Entry
ret
end
- def readpartial(maxlen = nil, outbuf = "".b)
- check_closed
-
- raise EOFError if @read >= @header.size
-
- maxlen ||= @header.size - @read
- max_read = [maxlen, @header.size - @read].min
-
- @io.readpartial(max_read, outbuf)
- @read += outbuf.size
-
- outbuf
- end
+ alias readpartial read # :nodoc:
##
# Rewinds to the beginning of the tar file entry
@@ -163,6 +145,8 @@ class Gem::Package::TarReader::Entry
def rewind
check_closed
+ raise Gem::Package::NonSeekableIO unless @io.respond_to? :pos=
+
@io.pos = @orig_pos
@read = 0
end
diff --git a/lib/rubygems/package/tar_test_case.rb b/lib/rubygems/package/tar_test_case.rb
index 75978c8ed0..46ac949587 100644
--- a/lib/rubygems/package/tar_test_case.rb
+++ b/lib/rubygems/package/tar_test_case.rb
@@ -52,7 +52,7 @@ class Gem::Package::TarTestCase < Gem::TestCase
name = fields.shift
length = fields.shift.to_i
- if name == "checksum"
+ if name == "checksum" then
chksum_off = offset
offset += length
next
@@ -94,7 +94,13 @@ class Gem::Package::TarTestCase < Gem::TestCase
ASCIIZ(dname, 155) # char prefix[155]; ASCII + (Z unless filled)
]
- h = arr.join
+ format = "C100C8C8C8C12C12C8CC100C6C2C32C32C8C8C155"
+ h = if RUBY_VERSION >= "1.9" then
+ arr.join
+ else
+ arr = arr.join("").split(//).map{|x| x[0]}
+ arr.pack format
+ end
ret = h + "\0" * (512 - h.size)
assert_equal(512, ret.size)
ret
diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb
index 96d8184e8e..390f7851a3 100644
--- a/lib/rubygems/package/tar_writer.rb
+++ b/lib/rubygems/package/tar_writer.rb
@@ -106,10 +106,12 @@ class Gem::Package::TarWriter
def add_file(name, mode) # :yields: io
check_closed
+ raise Gem::Package::NonSeekableIO unless @io.respond_to? :pos=
+
name, prefix = split_name name
init_pos = @io.pos
- @io.write Gem::Package::TarHeader::EMPTY_HEADER # placeholder for the header
+ @io.write "\0" * 512 # placeholder for the header
yield RestrictedStream.new(@io) if block_given?
@@ -123,7 +125,7 @@ class Gem::Package::TarWriter
header = Gem::Package::TarHeader.new :name => name, :mode => mode,
:size => size, :prefix => prefix,
- :mtime => Gem.source_date_epoch
+ :mtime => Time.now
@io.write header
@io.pos = final_pos
@@ -139,11 +141,11 @@ class Gem::Package::TarWriter
#
# The created digest object is returned.
- def add_file_digest(name, mode, digest_algorithms) # :yields: io
+ def add_file_digest name, mode, digest_algorithms # :yields: io
digests = digest_algorithms.map do |digest_algorithm|
digest = digest_algorithm.new
digest_name =
- if digest.respond_to? :name
+ if digest.respond_to? :name then
digest.name
else
/::([^:]+)$/ =~ digest_algorithm.name
@@ -172,7 +174,7 @@ class Gem::Package::TarWriter
#
# Returns the digest.
- def add_file_signed(name, mode, signer)
+ def add_file_signed name, mode, signer
digest_algorithms = [
signer.digest_algorithm,
Digest::SHA512,
@@ -184,10 +186,11 @@ class Gem::Package::TarWriter
signature_digest = digests.values.compact.find do |digest|
digest_name =
- if digest.respond_to? :name
+ if digest.respond_to? :name then
digest.name
else
- digest.class.name[/::([^:]+)\z/, 1]
+ /::([^:]+)$/ =~ digest.class.name
+ $1
end
digest_name == signer.digest_name
@@ -195,7 +198,7 @@ class Gem::Package::TarWriter
raise "no #{signer.digest_name} in #{digests.values.compact}" unless signature_digest
- if signer.key
+ if signer.key then
signature = signer.sign signature_digest.digest
add_file_simple "#{name}.sig", 0444, signature.length do |io|
@@ -217,7 +220,7 @@ class Gem::Package::TarWriter
header = Gem::Package::TarHeader.new(:name => name, :mode => mode,
:size => size, :prefix => prefix,
- :mtime => Gem.source_date_epoch).to_s
+ :mtime => Time.now).to_s
@io.write header
os = BoundedStream.new @io, size
@@ -245,7 +248,7 @@ class Gem::Package::TarWriter
:size => 0, :typeflag => "2",
:linkname => target,
:prefix => prefix,
- :mtime => Gem.source_date_epoch).to_s
+ :mtime => Time.now).to_s
@io.write header
@@ -298,7 +301,7 @@ class Gem::Package::TarWriter
header = Gem::Package::TarHeader.new :name => name, :mode => mode,
:typeflag => "5", :size => 0,
:prefix => prefix,
- :mtime => Gem.source_date_epoch
+ :mtime => Time.now
@io.write header
@@ -309,12 +312,12 @@ class Gem::Package::TarWriter
# Splits +name+ into a name and prefix that can fit in the TarHeader
def split_name(name) # :nodoc:
- if name.bytesize > 256
+ if name.bytesize > 256 then
raise Gem::Package::TooLongFileName.new("File \"#{name}\" has a too long path (should be 256 or less)")
end
prefix = ''
- if name.bytesize > 100
+ if name.bytesize > 100 then
parts = name.split('/', -1) # parts are never empty here
name = parts.pop # initially empty for names with a trailing slash ("foo/.../bar/")
prefix = parts.join('/') # if empty, then it's impossible to split (parts is empty too)
@@ -323,11 +326,11 @@ class Gem::Package::TarWriter
prefix = parts.join('/')
end
- if name.bytesize > 100 or prefix.empty?
+ if name.bytesize > 100 or prefix.empty? then
raise Gem::Package::TooLongFileName.new("File \"#{prefix}/#{name}\" has a too long name (should be 100 or less)")
end
- if prefix.bytesize > 155
+ if prefix.bytesize > 155 then
raise Gem::Package::TooLongFileName.new("File \"#{prefix}/#{name}\" has a too long base path (should be 155 or less)")
end
end
diff --git a/lib/rubygems/package_task.rb b/lib/rubygems/package_task.rb
index a11d09fb21..d554e3697b 100644
--- a/lib/rubygems/package_task.rb
+++ b/lib/rubygems/package_task.rb
@@ -126,3 +126,4 @@ class Gem::PackageTask < Rake::PackageTask
end
end
+
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb
index 6a5d180a02..618bc793c4 100644
--- a/lib/rubygems/path_support.rb
+++ b/lib/rubygems/path_support.rb
@@ -5,7 +5,6 @@
# to the rest of RubyGems.
#
class Gem::PathSupport
-
##
# The default system path for managing Gems.
attr_reader :home
@@ -24,19 +23,17 @@ class Gem::PathSupport
# hashtable, or defaults to ENV, the system environment.
#
def initialize(env)
- @home = env["GEM_HOME"] || Gem.default_dir
+ @home = env["GEM_HOME"] || Gem.default_dir
- if File::ALT_SEPARATOR
- @home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
+ if File::ALT_SEPARATOR then
+ @home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
end
- @home = expand(@home)
-
@path = split_gem_path env["GEM_PATH"], @home
@spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir
- @spec_cache_dir = @spec_cache_dir.dup.tap(&Gem::UNTAINT)
+ @spec_cache_dir = @spec_cache_dir.dup.untaint
end
private
@@ -44,7 +41,7 @@ class Gem::PathSupport
##
# Split the Gem search path (as reported by Gem.path).
- def split_gem_path(gpaths, home)
+ def split_gem_path gpaths, home
# FIX: it should be [home, *path], not [*path, home]
gem_path = []
@@ -57,7 +54,7 @@ class Gem::PathSupport
gem_path += default_path
end
- if File::ALT_SEPARATOR
+ if File::ALT_SEPARATOR then
gem_path.map! do |this_path|
this_path.gsub File::ALT_SEPARATOR, File::SEPARATOR
end
@@ -68,7 +65,7 @@ class Gem::PathSupport
gem_path = default_path
end
- gem_path.map { |path| expand(path) }.uniq
+ gem_path.uniq
end
# Return the default Gem path
@@ -80,13 +77,4 @@ class Gem::PathSupport
end
gem_path
end
-
- def expand(path)
- if File.directory?(path)
- File.realpath(path)
- else
- path
- end
- end
-
end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 521c552bea..2dd9ed5782 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -56,7 +56,7 @@ class Gem::Platform
when String then
arch = arch.split '-'
- if arch.length > 2 and arch.last !~ /\d/ # reassemble x86-linux-gnu
+ if arch.length > 2 and arch.last !~ /\d/ then # reassemble x86-linux-gnu
extra = arch.pop
arch.last << "-#{extra}"
end
@@ -68,7 +68,7 @@ class Gem::Platform
else cpu
end
- if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ # for command-line
+ if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ then # for command-line
@os, @version = arch
return
end
@@ -88,7 +88,7 @@ class Gem::Platform
when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ]
when /^dotnet$/ then [ 'dotnet', nil ]
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
- when /linux-?((?!gnu)\w+)?/ then [ 'linux', $1 ]
+ when /linux/ then [ 'linux', $1 ]
when /mingw32/ then [ 'mingw32', nil ]
when /(mswin\d+)(\_(\d+))?/ then
os, version = $1, $3
@@ -195,12 +195,12 @@ class Gem::Platform
# A pure-Ruby gem that may use Gem::Specification#extensions to build
# binary files.
- RUBY = 'ruby'.freeze
+ RUBY = 'ruby'
##
# A platform-specific gem that is built for the packaging Ruby's platform.
# This will be replaced with Gem::Platform::local.
- CURRENT = 'current'.freeze
-
+ CURRENT = 'current'
end
+
diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb
index b4eebf1dcc..41a7314b53 100644
--- a/lib/rubygems/psych_tree.rb
+++ b/lib/rubygems/psych_tree.rb
@@ -2,7 +2,6 @@
module Gem
if defined? ::Psych::Visitors
class NoAliasYAMLTree < Psych::Visitors::YAMLTree
-
def self.create
new({})
end unless respond_to? :create
@@ -19,7 +18,7 @@ module Gem
end
# This is ported over from the yaml_tree in 1.9.3
- def format_time(time)
+ def format_time time
if time.utc?
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
else
@@ -28,7 +27,6 @@ module Gem
end
private :format_time
-
end
end
end
diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb
index 4e16fbb86f..7043bd2a31 100644
--- a/lib/rubygems/rdoc.rb
+++ b/lib/rubygems/rdoc.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
require 'rubygems'
+require 'rubygems/user_interaction'
+require 'fileutils'
begin
gem 'rdoc'
@@ -13,12 +15,321 @@ else
Gem.finish_resolve
end
+loaded_hook = false
+
begin
require 'rdoc/rubygems_hook'
+ loaded_hook = true
module Gem
RDoc = ::RDoc::RubygemsHook
end
-
- Gem.done_installing(&Gem::RDoc.method(:generation_hook))
rescue LoadError
end
+
+##
+# Gem::RDoc provides methods to generate RDoc and ri data for installed gems.
+# It works for RDoc 1.0.1 (in Ruby 1.8) up to RDoc 3.6.
+#
+# This implementation is considered obsolete. The RDoc project is the
+# appropriate location to find this functionality. This file provides the
+# hooks to load RDoc generation code from the "rdoc" gem and a fallback in
+# case the installed version of RDoc does not have them.
+
+class Gem::RDoc # :nodoc: all
+
+ include Gem::UserInteraction
+ extend Gem::UserInteraction
+
+ @rdoc_version = nil
+ @specs = []
+
+ ##
+ # Force installation of documentation?
+
+ attr_accessor :force
+
+ ##
+ # Generate rdoc?
+
+ attr_accessor :generate_rdoc
+
+ ##
+ # Generate ri data?
+
+ attr_accessor :generate_ri
+
+ class << self
+
+ ##
+ # Loaded version of RDoc. Set by ::load_rdoc
+
+ attr_reader :rdoc_version
+
+ end
+
+ ##
+ # Post installs hook that generates documentation for each specification in
+ # +specs+
+
+ def self.generation_hook installer, specs
+ start = Time.now
+ types = installer.document
+
+ generate_rdoc = types.include? 'rdoc'
+ generate_ri = types.include? 'ri'
+
+ specs.each do |spec|
+ new(spec, generate_rdoc, generate_ri).generate
+ end
+
+ return unless generate_rdoc or generate_ri
+
+ duration = (Time.now - start).to_i
+ names = specs.map(&:name).join ', '
+
+ say "Done installing documentation for #{names} after #{duration} seconds"
+ end
+
+ ##
+ # Loads the RDoc generator
+
+ def self.load_rdoc
+ return if @rdoc_version
+
+ require 'rdoc/rdoc'
+
+ @rdoc_version = if ::RDoc.const_defined? :VERSION then
+ Gem::Version.new ::RDoc::VERSION
+ else
+ Gem::Version.new '1.0.1'
+ end
+
+ rescue LoadError => e
+ raise Gem::DocumentError, "RDoc is not installed: #{e}"
+ end
+
+ ##
+ # Creates a new documentation generator for +spec+. RDoc and ri data
+ # generation can be enabled or disabled through +generate_rdoc+ and
+ # +generate_ri+ respectively.
+ #
+ # Only +generate_ri+ is enabled by default.
+
+ def initialize spec, generate_rdoc = true, generate_ri = true
+ @doc_dir = spec.doc_dir
+ @file_info = nil
+ @force = false
+ @rdoc = nil
+ @spec = spec
+
+ @generate_rdoc = generate_rdoc
+ @generate_ri = generate_ri
+
+ @rdoc_dir = spec.doc_dir 'rdoc'
+ @ri_dir = spec.doc_dir 'ri'
+ end
+
+ ##
+ # Removes legacy rdoc arguments from +args+
+ #--
+ # TODO move to RDoc::Options
+
+ def delete_legacy_args args
+ args.delete '--inline-source'
+ args.delete '--promiscuous'
+ args.delete '-p'
+ args.delete '--one-file'
+ end
+
+ ##
+ # Generates documentation using the named +generator+ ("darkfish" or "ri")
+ # and following the given +options+.
+ #
+ # Documentation will be generated into +destination+
+
+ def document generator, options, destination
+ generator_name = generator
+
+ options = options.dup
+ options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
+ options.setup_generator generator
+ options.op_dir = destination
+ options.finish
+
+ generator = options.generator.new @rdoc.store, options
+
+ @rdoc.options = options
+ @rdoc.generator = generator
+
+ say "Installing #{generator_name} documentation for #{@spec.full_name}"
+
+ FileUtils.mkdir_p options.op_dir
+
+ Dir.chdir options.op_dir do
+ begin
+ @rdoc.class.current = @rdoc
+ @rdoc.generator.generate @file_info
+ ensure
+ @rdoc.class.current = nil
+ end
+ end
+ end
+
+ ##
+ # Generates RDoc and ri data
+
+ def generate
+ return unless @generate_ri or @generate_rdoc
+
+ setup
+
+ options = nil
+
+ if Gem::Requirement.new('< 3').satisfied_by? self.class.rdoc_version then
+ generate_legacy
+ return
+ end
+
+ ::RDoc::TopLevel.reset # TODO ::RDoc::RDoc.reset
+ ::RDoc::Parser::C.reset
+
+ args = @spec.rdoc_options
+ args.concat @spec.source_paths
+ args.concat @spec.extra_rdoc_files
+
+ case config_args = Gem.configuration[:rdoc]
+ when String then
+ args = args.concat config_args.split
+ when Array then
+ args = args.concat config_args
+ end
+
+ delete_legacy_args args
+
+ Dir.chdir @spec.full_gem_path do
+ options = ::RDoc::Options.new
+ options.default_title = "#{@spec.full_name} Documentation"
+ options.parse args
+ end
+
+ options.quiet = !Gem.configuration.really_verbose
+
+ @rdoc = new_rdoc
+ @rdoc.options = options
+
+ say "Parsing documentation for #{@spec.full_name}"
+
+ Dir.chdir @spec.full_gem_path do
+ @file_info = @rdoc.parse_files options.files
+ end
+
+ document 'ri', options, @ri_dir if
+ @generate_ri and (@force or not File.exist? @ri_dir)
+
+ document 'darkfish', options, @rdoc_dir if
+ @generate_rdoc and (@force or not File.exist? @rdoc_dir)
+ end
+
+ ##
+ # Generates RDoc and ri data for legacy RDoc versions. This method will not
+ # exist in future versions.
+
+ def generate_legacy
+ if @generate_rdoc then
+ FileUtils.rm_rf @rdoc_dir
+ say "Installing RDoc documentation for #{@spec.full_name}"
+ legacy_rdoc '--op', @rdoc_dir
+ end
+
+ if @generate_ri then
+ FileUtils.rm_rf @ri_dir
+ say "Installing ri documentation for #{@spec.full_name}"
+ legacy_rdoc '--ri', '--op', @ri_dir
+ end
+ end
+
+ ##
+ # Generates RDoc using a legacy version of RDoc from the ARGV-like +args+.
+ # This method will not exist in future versions.
+
+ def legacy_rdoc *args
+ args << @spec.rdoc_options
+ args << '--quiet'
+ args << @spec.require_paths.clone
+ args << @spec.extra_rdoc_files
+ args << '--title' << "#{@spec.full_name} Documentation"
+ args = args.flatten.map do |arg| arg.to_s end
+
+ delete_legacy_args args if
+ Gem::Requirement.new('>= 2.4.0') =~ self.class.rdoc_version
+
+ r = new_rdoc
+ verbose { "rdoc #{args.join ' '}" }
+
+ Dir.chdir @spec.full_gem_path do
+ begin
+ r.document args
+ rescue Errno::EACCES => e
+ dirname = File.dirname e.message.split("-")[1].strip
+ raise Gem::FilePermissionError, dirname
+ rescue Interrupt => e
+ raise e
+ rescue Exception => ex
+ alert_error "While generating documentation for #{@spec.full_name}"
+ ui.errs.puts "... MESSAGE: #{ex}"
+ ui.errs.puts "... RDOC args: #{args.join(' ')}"
+ ui.backtrace ex
+ ui.errs.puts "(continuing with the rest of the installation)"
+ end
+ end
+ end
+
+ ##
+ # #new_rdoc creates a new RDoc instance. This method is provided only to
+ # make testing easier.
+
+ def new_rdoc # :nodoc:
+ ::RDoc::RDoc.new
+ end
+
+ ##
+ # Is rdoc documentation installed?
+
+ def rdoc_installed?
+ File.exist? @rdoc_dir
+ end
+
+ ##
+ # Removes generated RDoc and ri data
+
+ def remove
+ base_dir = @spec.base_dir
+
+ raise Gem::FilePermissionError, base_dir unless File.writable? base_dir
+
+ FileUtils.rm_rf @rdoc_dir
+ FileUtils.rm_rf @ri_dir
+ end
+
+ ##
+ # Is ri data installed?
+
+ def ri_installed?
+ File.exist? @ri_dir
+ end
+
+ ##
+ # Prepares the spec for documentation generation
+
+ def setup
+ self.class.load_rdoc
+
+ raise Gem::FilePermissionError, @doc_dir if
+ File.exist?(@doc_dir) and not File.writable?(@doc_dir)
+
+ FileUtils.mkdir_p @doc_dir unless File.exist? @doc_dir
+ end
+
+end unless loaded_hook
+
+Gem.done_installing(&Gem::RDoc.method(:generation_hook))
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 2ed619f1bc..8f0cf0b402 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -1,13 +1,10 @@
# frozen_string_literal: true
require 'rubygems'
require 'rubygems/request'
-require 'rubygems/request/connection_pools'
-require 'rubygems/s3_uri_signer'
require 'rubygems/uri_formatter'
-require 'rubygems/uri_parsing'
require 'rubygems/user_interaction'
+require 'rubygems/request/connection_pools'
require 'resolv'
-require 'rubygems/deprecate'
##
# RemoteFetcher handles the details of fetching gems and gem information from
@@ -16,9 +13,6 @@ require 'rubygems/deprecate'
class Gem::RemoteFetcher
include Gem::UserInteraction
- extend Gem::Deprecate
-
- include Gem::UriParsing
##
# A FetchError exception wraps up the various possible IO and HTTP failures
@@ -26,8 +20,6 @@ class Gem::RemoteFetcher
class FetchError < Gem::Exception
- include Gem::UriParsing
-
##
# The URI which was being accessed when the exception happened.
@@ -35,12 +27,13 @@ class Gem::RemoteFetcher
def initialize(message, uri)
super message
-
- uri = parse_uri(uri)
-
- uri.password = 'REDACTED' if uri.respond_to?(:password) && uri.password
-
- @uri = uri.to_s
+ begin
+ uri = URI(uri)
+ uri.password = 'REDACTED' if uri.password
+ @uri = uri.to_s
+ rescue URI::InvalidURIError, ArgumentError
+ @uri = uri
+ end
end
def to_s # :nodoc:
@@ -78,10 +71,13 @@ class Gem::RemoteFetcher
# HTTP_PROXY_PASS)
# * <tt>:no_proxy</tt>: ignore environment variables and _don't_ use a proxy
#
+ # +dns+: An object to use for DNS resolution of the API endpoint.
+ # By default, use Resolv::DNS.
+ #
# +headers+: A set of additional HTTP headers to be sent to the server when
# fetching the gem.
- def initialize(proxy=nil, dns=nil, headers={})
+ def initialize(proxy=nil, dns=Resolv::DNS.new, headers={})
require 'net/http'
require 'stringio'
require 'time'
@@ -94,24 +90,49 @@ class Gem::RemoteFetcher
@pool_lock = Mutex.new
@cert_files = Gem::Request.get_cert_files
+ @dns = dns
@headers = headers
end
##
+ # Given a source at +uri+, calculate what hostname to actually
+ # connect to query the data for it.
+
+ def api_endpoint(uri)
+ host = uri.host
+
+ begin
+ res = @dns.getresource "_rubygems._tcp.#{host}",
+ Resolv::DNS::Resource::IN::SRV
+ rescue Resolv::ResolvError => e
+ verbose "Getting SRV record failed: #{e}"
+ uri
+ else
+ target = res.target.to_s.strip
+
+ if URI("http://" + target).host.end_with?(".#{host}")
+ return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
+ end
+
+ uri
+ end
+ end
+
+ ##
# Given a name and requirement, downloads this gem into cache and returns the
# filename. Returns nil if the gem cannot be located.
#--
# Should probably be integrated with #download below, but that will be a
# larger, more encompassing effort. -erikh
- def download_to_cache(dependency)
+ def download_to_cache dependency
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dependency
return if found.empty?
spec, source = found.max_by { |(s,_)| s.version }
- download spec, source.uri
+ download spec, source.uri.to_s
end
##
@@ -121,9 +142,9 @@ class Gem::RemoteFetcher
def download(spec, source_uri, install_dir = Gem.dir)
cache_dir =
- if Dir.pwd == install_dir # see fetch_command
+ if Dir.pwd == install_dir then # see fetch_command
install_dir
- elsif File.writable? install_dir
+ elsif File.writable? install_dir then
File.join install_dir, "cache"
else
File.join Gem.user_dir, "cache"
@@ -134,7 +155,20 @@ class Gem::RemoteFetcher
FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
- source_uri = parse_uri(source_uri)
+ # Always escape URI's to deal with potential spaces and such
+ # It should also be considered that source_uri may already be
+ # a valid URI with escaped characters. e.g. "{DESede}" is encoded
+ # as "%7BDESede%7D". If this is escaped again the percentage
+ # symbols will be escaped.
+ unless source_uri.is_a?(URI::Generic)
+ begin
+ source_uri = URI.parse(source_uri)
+ rescue
+ source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
+ URI::DEFAULT_PARSER.escape(source_uri.to_s) :
+ URI.escape(source_uri.to_s))
+ end
+ end
scheme = source_uri.scheme
@@ -145,14 +179,14 @@ class Gem::RemoteFetcher
# REFACTOR: be sure to clean up fake fetcher when you do this... cleaner
case scheme
when 'http', 'https', 's3' then
- unless File.exist? local_gem_path
+ unless File.exist? local_gem_path then
begin
verbose "Downloading gem #{gem_file_name}"
remote_gem_path = source_uri + "gems/#{gem_file_name}"
self.cache_update_path remote_gem_path, local_gem_path
- rescue FetchError
+ rescue Gem::RemoteFetcher::FetchError
raise if spec.original_platform == spec.platform
alternate_name = "#{spec.original_name}.gem"
@@ -169,7 +203,7 @@ class Gem::RemoteFetcher
path = source_uri.path
path = File.dirname(path) if File.extname(path) == '.gem'
- remote_gem_path = Gem::Util.correct_for_windows_path(File.join(path, 'gems', gem_file_name))
+ remote_gem_path = correct_for_windows_path(File.join(path, 'gems', gem_file_name))
FileUtils.cp(remote_gem_path, local_gem_path)
rescue Errno::EACCES
@@ -179,7 +213,7 @@ class Gem::RemoteFetcher
verbose "Using local gem #{local_gem_path}"
when nil then # TODO test for local overriding cache
source_path = if Gem.win_platform? && source_uri.scheme &&
- !source_uri.path.include?(':')
+ !source_uri.path.include?(':') then
"#{source_uri.scheme}:#{source_uri.path}"
else
source_uri.path
@@ -205,14 +239,14 @@ class Gem::RemoteFetcher
##
# File Fetcher. Dispatched by +fetch_path+. Use it instead.
- def fetch_file(uri, *_)
- Gem.read_binary Gem::Util.correct_for_windows_path uri.path
+ def fetch_file uri, *_
+ Gem.read_binary correct_for_windows_path uri.path
end
##
# HTTP Fetcher. Dispatched by +fetch_path+. Use it instead.
- def fetch_http(uri, last_modified = nil, head = false, depth = 0)
+ def fetch_http uri, last_modified = nil, head = false, depth = 0
fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
response = request uri, fetch_type, last_modified do |req|
headers.each { |k,v| req.add_field(k,v) }
@@ -229,7 +263,7 @@ class Gem::RemoteFetcher
unless location = response['Location']
raise FetchError.new("redirecting but no redirect location was given", uri)
end
- location = parse_uri location
+ location = URI.parse response['Location']
if https?(uri) && !https?(location)
raise FetchError.new("redirecting to non-https resource: #{location}", uri)
@@ -247,7 +281,9 @@ class Gem::RemoteFetcher
# Downloads +uri+ and returns it as a String.
def fetch_path(uri, mtime = nil, head = false)
- uri = parse_uri uri
+ uri = URI.parse uri unless URI::Generic === uri
+
+ raise ArgumentError, "bad uri: #{uri}" unless uri
unless uri.scheme
raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}"
@@ -257,43 +293,35 @@ class Gem::RemoteFetcher
if data and !head and uri.to_s =~ /\.gz$/
begin
- data = Gem::Util.gunzip data
+ data = Gem.gunzip data
rescue Zlib::GzipFile::Error
- raise FetchError.new("server did not return a valid file", uri)
+ raise FetchError.new("server did not return a valid file", uri.to_s)
end
end
data
+ rescue FetchError
+ raise
rescue Timeout::Error
- raise UnknownHostError.new('timed out', uri)
- rescue IOError, SocketError, SystemCallError,
- *(OpenSSL::SSL::SSLError if defined?(OpenSSL)) => e
+ raise UnknownHostError.new('timed out', uri.to_s)
+ rescue IOError, SocketError, SystemCallError => e
if e.message =~ /getaddrinfo/
- raise UnknownHostError.new('no such name', uri)
+ raise UnknownHostError.new('no such name', uri.to_s)
else
- raise FetchError.new("#{e.class}: #{e}", uri)
+ raise FetchError.new("#{e.class}: #{e}", uri.to_s)
end
end
def fetch_s3(uri, mtime = nil, head = false)
- begin
- public_uri = s3_uri_signer(uri).sign
- rescue Gem::S3URISigner::ConfigurationError, Gem::S3URISigner::InstanceProfileError => e
- raise FetchError.new(e.message, "s3://#{uri.host}")
- end
+ public_uri = sign_s3_url(uri)
fetch_https public_uri, mtime, head
end
- # we have our own signing code here to avoid a dependency on the aws-sdk gem
- def s3_uri_signer(uri)
- Gem::S3URISigner.new(uri)
- end
-
##
# Downloads +uri+ to +path+ if necessary. If no path is given, it just
# passes the data.
- def cache_update_path(uri, path = nil, update = true)
+ def cache_update_path uri, path = nil, update = true
mtime = path && File.stat(path).mtime rescue nil
data = fetch_path(uri, mtime)
@@ -312,13 +340,19 @@ class Gem::RemoteFetcher
##
# Returns the size of +uri+ in bytes.
- def fetch_size(uri)
+ def fetch_size(uri) # TODO: phase this out
response = fetch_path(uri, nil, true)
response['content-length'].to_i
end
- deprecate :fetch_size, :none, 2019, 12
+ def correct_for_windows_path(path)
+ if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
+ path[1..-1]
+ else
+ path
+ end
+ end
##
# Performs a Net::HTTP request of type +request_class+ on +uri+ returning
@@ -344,16 +378,42 @@ class Gem::RemoteFetcher
@pools.each_value {|pool| pool.close_all}
end
+ protected
+
+ # we have our own signing code here to avoid a dependency on the aws-sdk gem
+ # fortunately, a simple GET request isn't too complex to sign properly
+ def sign_s3_url(uri, expiration = nil)
+ require 'base64'
+ require 'openssl'
+
+ unless uri.user && uri.password
+ raise FetchError.new("credentials needed in s3 source, like s3://key:secret@bucket-name/", uri.to_s)
+ end
+
+ expiration ||= s3_expiration
+ canonical_path = "/#{uri.host}#{uri.path}"
+ payload = "GET\n\n\n#{expiration}\n#{canonical_path}"
+ digest = OpenSSL::HMAC.digest('sha1', uri.password, payload)
+ # URI.escape is deprecated, and there isn't yet a replacement that does quite what we want
+ signature = Base64.encode64(digest).gsub("\n", '').gsub(/[\+\/=]/) { |c| BASE64_URI_TRANSLATE[c] }
+ URI.parse("https://#{uri.host}.s3.amazonaws.com#{uri.path}?AWSAccessKeyId=#{uri.user}&Expires=#{expiration}&Signature=#{signature}")
+ end
+
+ def s3_expiration
+ (Time.now + 3600).to_i # one hour from now
+ end
+
+ BASE64_URI_TRANSLATE = { '+' => '%2B', '/' => '%2F', '=' => '%3D' }.freeze
+
private
- def proxy_for(proxy, uri)
+ def proxy_for proxy, uri
Gem::Request.proxy_uri(proxy || Gem::Request.get_proxy_from_env(uri.scheme))
end
- def pools_for(proxy)
+ def pools_for proxy
@pool_lock.synchronize do
@pools[proxy] ||= Gem::Request::ConnectionPools.new proxy, @cert_files
end
end
-
end
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
index b5a14ec34d..81699b98fe 100644
--- a/lib/rubygems/request.rb
+++ b/lib/rubygems/request.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'net/http'
+require 'thread'
require 'time'
require 'rubygems/user_interaction'
@@ -10,16 +11,15 @@ class Gem::Request
###
# Legacy. This is used in tests.
- def self.create_with_proxy(uri, request_class, last_modified, proxy) # :nodoc:
+ def self.create_with_proxy uri, request_class, last_modified, proxy # :nodoc:
cert_files = get_cert_files
proxy ||= get_proxy_from_env(uri.scheme)
- pool = ConnectionPools.new proxy_uri(proxy), cert_files
+ pool = ConnectionPools.new proxy_uri(proxy), cert_files
new(uri, request_class, last_modified, pool.pool_for(uri))
end
- def self.proxy_uri(proxy) # :nodoc:
- require "uri"
+ def self.proxy_uri proxy # :nodoc:
case proxy
when :no_proxy then nil
when URI::HTTP then proxy
@@ -52,7 +52,7 @@ class Gem::Request
Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER
store = OpenSSL::X509::Store.new
- if Gem.configuration.ssl_client_cert
+ if Gem.configuration.ssl_client_cert then
pem = File.read Gem.configuration.ssl_client_cert
connection.cert = OpenSSL::X509::Certificate.new pem
connection.key = OpenSSL::PKey::RSA.new pem
@@ -86,7 +86,7 @@ class Gem::Request
'Unable to require openssl, install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources')
end
- def self.verify_certificate(store_context)
+ def self.verify_certificate store_context
depth = store_context.error_depth
error = store_context.error_string
number = store_context.error
@@ -99,7 +99,7 @@ class Gem::Request
ui.alert_error extra_message if extra_message
end
- def self.verify_certificate_message(error_number, cert)
+ def self.verify_certificate_message error_number, cert
return unless cert
case error_number
when OpenSSL::X509::V_ERR_CERT_HAS_EXPIRED then
@@ -118,11 +118,9 @@ class Gem::Request
"Certificate #{cert.subject} has an invalid purpose"
when OpenSSL::X509::V_ERR_SELF_SIGNED_CERT_IN_CHAIN then
"Root certificate is not trusted (#{cert.subject})"
- when OpenSSL::X509::V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY then
- "You must add #{cert.issuer} to your local trusted store"
- when
+ when OpenSSL::X509::V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
OpenSSL::X509::V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE then
- "Cannot verify certificate issued by #{cert.issuer}"
+ "You must add #{cert.issuer} to your local trusted store"
end
end
@@ -140,7 +138,7 @@ class Gem::Request
def fetch
request = @request_class.new @uri.request_uri
- unless @uri.nil? || @uri.user.nil? || @uri.user.empty?
+ unless @uri.nil? || @uri.user.nil? || @uri.user.empty? then
request.basic_auth Gem::UriFormatter.new(@uri.user).unescape,
Gem::UriFormatter.new(@uri.password).unescape
end
@@ -149,7 +147,7 @@ class Gem::Request
request.add_field 'Connection', 'keep-alive'
request.add_field 'Keep-Alive', '30'
- if @last_modified
+ if @last_modified then
request.add_field 'If-Modified-Since', @last_modified.httpdate
end
@@ -162,22 +160,19 @@ class Gem::Request
# Returns a proxy URI for the given +scheme+ if one is set in the
# environment variables.
- def self.get_proxy_from_env(scheme = 'http')
+ def self.get_proxy_from_env scheme = 'http'
_scheme = scheme.downcase
_SCHEME = scheme.upcase
env_proxy = ENV["#{_scheme}_proxy"] || ENV["#{_SCHEME}_PROXY"]
no_env_proxy = env_proxy.nil? || env_proxy.empty?
- if no_env_proxy
- return (_scheme == 'https' || _scheme == 'http') ?
- :no_proxy : get_proxy_from_env('http')
- end
+ return get_proxy_from_env 'http' if no_env_proxy and _scheme != 'http'
+ return :no_proxy if no_env_proxy
- require "uri"
uri = URI(Gem::UriFormatter.new(env_proxy).normalize)
- if uri and uri.user.nil? and uri.password.nil?
+ if uri and uri.user.nil? and uri.password.nil? then
user = ENV["#{_scheme}_proxy_user"] || ENV["#{_SCHEME}_PROXY_USER"]
password = ENV["#{_scheme}_proxy_pass"] || ENV["#{_SCHEME}_PROXY_PASS"]
@@ -188,7 +183,7 @@ class Gem::Request
uri
end
- def perform_request(request) # :nodoc:
+ def perform_request request # :nodoc:
connection = connection_for @uri
retried = false
@@ -280,14 +275,14 @@ class Gem::Request
ruby_version += 'dev' if RUBY_PATCHLEVEL == -1
ua << " Ruby/#{ruby_version} (#{RUBY_RELEASE_DATE}"
- if RUBY_PATCHLEVEL >= 0
+ if RUBY_PATCHLEVEL >= 0 then
ua << " patchlevel #{RUBY_PATCHLEVEL}"
- elsif defined?(RUBY_REVISION)
+ elsif defined?(RUBY_REVISION) then
ua << " revision #{RUBY_REVISION}"
end
ua << ")"
- ua << " #{RUBY_ENGINE}" if RUBY_ENGINE != 'ruby'
+ ua << " #{RUBY_ENGINE}" if defined?(RUBY_ENGINE) and RUBY_ENGINE != 'ruby'
ua
end
diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb
index 9444239b2c..31fc609800 100644
--- a/lib/rubygems/request/connection_pools.rb
+++ b/lib/rubygems/request/connection_pools.rb
@@ -1,28 +1,27 @@
# frozen_string_literal: true
+require 'thread'
class Gem::Request::ConnectionPools # :nodoc:
@client = Net::HTTP
class << self
-
attr_accessor :client
-
end
- def initialize(proxy_uri, cert_files)
+ def initialize proxy_uri, cert_files
@proxy_uri = proxy_uri
@cert_files = cert_files
@pools = {}
@pool_mutex = Mutex.new
end
- def pool_for(uri)
+ def pool_for uri
http_args = net_http_args(uri, @proxy_uri)
key = http_args + [https?(uri)]
@pool_mutex.synchronize do
@pools[key] ||=
- if https? uri
+ if https? uri then
Gem::Request::HTTPSPool.new(http_args, @cert_files, @proxy_uri)
else
Gem::Request::HTTPPool.new(http_args, @cert_files, @proxy_uri)
@@ -42,46 +41,35 @@ class Gem::Request::ConnectionPools # :nodoc:
def get_no_proxy_from_env
env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
- return [] if env_no_proxy.nil? or env_no_proxy.empty?
+ return [] if env_no_proxy.nil? or env_no_proxy.empty?
env_no_proxy.split(/\s*,\s*/)
end
- def https?(uri)
+ def https? uri
uri.scheme.downcase == 'https'
end
- def no_proxy?(host, env_no_proxy)
+ def no_proxy? host, env_no_proxy
host = host.downcase
env_no_proxy.any? do |pattern|
- env_no_proxy_pattern = pattern.downcase.dup
-
- # Remove dot in front of pattern for wildcard matching
- env_no_proxy_pattern[0] = "" if env_no_proxy_pattern[0] == "."
-
- host_tokens = host.split(".")
- pattern_tokens = env_no_proxy_pattern.split(".")
+ pattern = pattern.downcase
- intersection = (host_tokens - pattern_tokens) | (pattern_tokens - host_tokens)
-
- # When we do the split into tokens we miss a dot character, so add it back if we need it
- missing_dot = intersection.length > 0 ? 1 : 0
- start = intersection.join(".").size + missing_dot
-
- no_proxy_host = host[start..-1]
-
- env_no_proxy_pattern == no_proxy_host
+ host[-pattern.length, pattern.length] == pattern or
+ (pattern.start_with? '.' and pattern[1..-1] == host)
end
end
- def net_http_args(uri, proxy_uri)
- hostname = uri.hostname
+ def net_http_args uri, proxy_uri
+ # URI::Generic#hostname was added in ruby 1.9.3, use it if exists, otherwise
+ # don't support IPv6 literals and use host.
+ hostname = uri.respond_to?(:hostname) ? uri.hostname : uri.host
net_http_args = [hostname, uri.port]
no_proxy = get_no_proxy_from_env
- if proxy_uri and not no_proxy?(hostname, no_proxy)
+ if proxy_uri and not no_proxy?(hostname, no_proxy) then
proxy_hostname = proxy_uri.respond_to?(:hostname) ? proxy_uri.hostname : proxy_uri.host
net_http_args + [
proxy_hostname,
@@ -89,7 +77,7 @@ class Gem::Request::ConnectionPools # :nodoc:
Gem::UriFormatter.new(proxy_uri.user).unescape,
Gem::UriFormatter.new(proxy_uri.password).unescape,
]
- elsif no_proxy? hostname, no_proxy
+ elsif no_proxy? hostname, no_proxy then
net_http_args + [nil, nil]
else
net_http_args
@@ -97,3 +85,4 @@ class Gem::Request::ConnectionPools # :nodoc:
end
end
+
diff --git a/lib/rubygems/request/http_pool.rb b/lib/rubygems/request/http_pool.rb
index 058094a209..bfcd15399d 100644
--- a/lib/rubygems/request/http_pool.rb
+++ b/lib/rubygems/request/http_pool.rb
@@ -6,10 +6,9 @@
# use it.
class Gem::Request::HTTPPool # :nodoc:
-
attr_reader :cert_files, :proxy_uri
- def initialize(http_args, cert_files, proxy_uri)
+ def initialize http_args, cert_files, proxy_uri
@http_args = http_args
@cert_files = cert_files
@proxy_uri = proxy_uri
@@ -21,7 +20,7 @@ class Gem::Request::HTTPPool # :nodoc:
@queue.pop || make_connection
end
- def checkin(connection)
+ def checkin connection
@queue.push connection
end
@@ -40,9 +39,10 @@ class Gem::Request::HTTPPool # :nodoc:
setup_connection Gem::Request::ConnectionPools.client.new(*@http_args)
end
- def setup_connection(connection)
+ def setup_connection connection
connection.start
connection
end
end
+
diff --git a/lib/rubygems/request/https_pool.rb b/lib/rubygems/request/https_pool.rb
index 1236079b7d..e82c2440e1 100644
--- a/lib/rubygems/request/https_pool.rb
+++ b/lib/rubygems/request/https_pool.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
class Gem::Request::HTTPSPool < Gem::Request::HTTPPool # :nodoc:
-
private
- def setup_connection(connection)
+ def setup_connection connection
Gem::Request.configure_connection_for_https(connection, @cert_files)
super
end
-
end
+
+
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index d6fb41f514..95a8eed1af 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -91,7 +91,7 @@ class Gem::RequestSet
#
# set = Gem::RequestSet.new nokogiri, pg
- def initialize(*deps)
+ def initialize *deps
@dependencies = deps
@always_install = []
@@ -119,8 +119,8 @@ class Gem::RequestSet
##
# Declare that a gem of name +name+ with +reqs+ requirements is needed.
- def gem(name, *reqs)
- if dep = @dependency_names[name]
+ def gem name, *reqs
+ if dep = @dependency_names[name] then
dep.requirement.concat reqs
else
dep = Gem::Dependency.new name, *reqs
@@ -132,7 +132,7 @@ class Gem::RequestSet
##
# Add +deps+ Gem::Dependency objects to the set.
- def import(deps)
+ def import deps
@dependencies.concat deps
end
@@ -143,7 +143,7 @@ class Gem::RequestSet
# The +installer+ will be +nil+ if a gem matching the request was already
# installed.
- def install(options, &block) # :yields: request, installer
+ def install options, &block # :yields: request, installer
if dir = options[:install_dir]
requests = install_into dir, false, options, &block
return requests
@@ -152,39 +152,12 @@ class Gem::RequestSet
@prerelease = options[:prerelease]
requests = []
- download_queue = Queue.new
- # Create a thread-safe list of gems to download
sorted_requests.each do |req|
- download_queue << req
- end
-
- # Create N threads in a pool, have them download all the gems
- threads = Gem.configuration.concurrent_downloads.times.map do
- # When a thread pops this item, it knows to stop running. The symbol
- # is queued here so that there will be one symbol per thread.
- download_queue << :stop
-
- Thread.new do
- # The pop method will block waiting for items, so the only way
- # to stop a thread from running is to provide a final item that
- # means the thread should stop.
- while req = download_queue.pop
- break if req == :stop
- req.spec.download options unless req.installed?
- end
- end
- end
-
- # Wait for all the downloads to finish before continuing
- threads.each(&:value)
-
- # Install requested gems after they have been downloaded
- sorted_requests.each do |req|
- if req.installed?
+ if req.installed? then
req.spec.spec.build_extensions
- if @always_install.none? { |spec| spec == req.spec.spec }
+ if @always_install.none? { |spec| spec == req.spec.spec } then
yield req, nil if block_given?
next
end
@@ -198,9 +171,7 @@ class Gem::RequestSet
rescue Gem::RuntimeRequirementNotMetError => e
recent_match = req.spec.set.find_all(req.request).sort_by(&:version).reverse_each.find do |s|
s = s.spec
- s.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
- s.required_rubygems_version.satisfied_by?(Gem.rubygems_version) &&
- Gem::Platform.installable?(s)
+ s.required_ruby_version.satisfied_by?(Gem.ruby_version) && s.required_rubygems_version.satisfied_by?(Gem.rubygems_version)
end
if recent_match
suggestion = "The last version of #{req.request} to support your Ruby & RubyGems was #{recent_match.version}. Try installing it with `gem install #{recent_match.name} -v #{recent_match.version}`"
@@ -218,7 +189,22 @@ class Gem::RequestSet
return requests if options[:gemdeps]
- install_hooks requests, options
+ specs = requests.map do |request|
+ case request
+ when Gem::Resolver::ActivationRequest then
+ request.spec.spec
+ else
+ request
+ end
+ end
+
+ require 'rubygems/dependency_installer'
+ inst = Gem::DependencyInstaller.new options
+ inst.installed_gems.replace specs
+
+ Gem.done_installing_hooks.each do |hook|
+ hook.call inst, specs
+ end unless Gem.done_installing_hooks.empty?
requests
end
@@ -230,7 +216,7 @@ class Gem::RequestSet
# If +:without_groups+ is given in the +options+, those groups in the gem
# dependencies file are not used. See Gem::Installer for other +options+.
- def install_from_gemdeps(options, &block)
+ def install_from_gemdeps options, &block
gemdeps = options[:gemdeps]
@install_dir = options[:install_dir] || Gem.dir
@@ -255,7 +241,7 @@ class Gem::RequestSet
else
installed = install options, &block
- if options.fetch :lock, true
+ if options.fetch :lock, true then
lockfile =
Gem::RequestSet::Lockfile.build self, gemdeps, gem_deps_api.dependencies
lockfile.write
@@ -265,7 +251,7 @@ class Gem::RequestSet
end
end
- def install_into(dir, force = true, options = {})
+ def install_into dir, force = true, options = {}
gem_home, ENV['GEM_HOME'] = ENV['GEM_HOME'], dir
existing = force ? [] : specs_in(dir)
@@ -283,7 +269,7 @@ class Gem::RequestSet
sorted_requests.each do |request|
spec = request.spec
- if existing.find { |s| s.full_name == spec.full_name }
+ if existing.find { |s| s.full_name == spec.full_name } then
yield request, nil if block_given?
next
end
@@ -295,46 +281,22 @@ class Gem::RequestSet
installed << request
end
- install_hooks installed, options
-
installed
ensure
ENV['GEM_HOME'] = gem_home
end
##
- # Call hooks on installed gems
-
- def install_hooks(requests, options)
- specs = requests.map do |request|
- case request
- when Gem::Resolver::ActivationRequest then
- request.spec.spec
- else
- request
- end
- end
-
- require "rubygems/dependency_installer"
- inst = Gem::DependencyInstaller.new options
- inst.installed_gems.replace specs
-
- Gem.done_installing_hooks.each do |hook|
- hook.call inst, specs
- end unless Gem.done_installing_hooks.empty?
- end
-
- ##
# Load a dependency management file.
- def load_gemdeps(path, without_groups = [], installing = false)
+ def load_gemdeps path, without_groups = [], installing = false
@git_set = Gem::Resolver::GitSet.new
@vendor_set = Gem::Resolver::VendorSet.new
@source_set = Gem::Resolver::SourceSet.new
@git_set.root_dir = @install_dir
- lock_file = "#{File.expand_path(path)}.lock".dup.tap(&Gem::UNTAINT)
+ lock_file = "#{File.expand_path(path)}.lock".dup.untaint
begin
tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file
parser = tokenizer.make_parser self, []
@@ -348,29 +310,29 @@ class Gem::RequestSet
gf.load
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[RequestSet:', ']' do
q.breakable
- if @remote
+ if @remote then
q.text 'remote'
q.breakable
end
- if @prerelease
+ if @prerelease then
q.text 'prerelease'
q.breakable
end
- if @development_shallow
+ if @development_shallow then
q.text 'shallow development'
q.breakable
- elsif @development
+ elsif @development then
q.text 'development'
q.breakable
end
- if @soft_missing
+ if @soft_missing then
q.text 'soft missing'
end
@@ -394,7 +356,7 @@ class Gem::RequestSet
# Resolve the requested dependencies and return an Array of Specification
# objects to be activated.
- def resolve(set = Gem::Resolver::BestSet.new)
+ def resolve set = Gem::Resolver::BestSet.new
@sets << set
@sets << @git_set
@sets << @vendor_set
@@ -443,25 +405,25 @@ class Gem::RequestSet
@specs ||= @requests.map { |r| r.full_spec }
end
- def specs_in(dir)
- Gem::Util.glob_files_in_dir("*.gemspec", File.join(dir, "specifications")).map do |g|
+ def specs_in dir
+ Dir["#{dir}/specifications/*.gemspec"].map do |g|
Gem::Specification.load g
end
end
- def tsort_each_node(&block) # :nodoc:
+ def tsort_each_node &block # :nodoc:
@requests.each(&block)
end
- def tsort_each_child(node) # :nodoc:
+ def tsort_each_child node # :nodoc:
node.spec.dependencies.each do |dep|
next if dep.type == :development and not @development
- match = @requests.find do |r|
+ match = @requests.find { |r|
dep.match? r.spec.name, r.spec.version, @prerelease
- end
+ }
- unless match
+ unless match then
next if dep.type == :development and @development_shallow
next if @soft_missing
raise Gem::DependencyError,
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index ef3f302ea8..867086cc0e 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -43,13 +43,12 @@ class Gem::RequestSet::GemDependencyAPI
:mri_20 => %w[ruby],
:mri_21 => %w[ruby],
:rbx => %w[rbx],
- :truffleruby => %w[truffleruby],
- :ruby => %w[ruby rbx maglev truffleruby],
- :ruby_18 => %w[ruby rbx maglev truffleruby],
- :ruby_19 => %w[ruby rbx maglev truffleruby],
- :ruby_20 => %w[ruby rbx maglev truffleruby],
- :ruby_21 => %w[ruby rbx maglev truffleruby],
- }.freeze
+ :ruby => %w[ruby rbx maglev],
+ :ruby_18 => %w[ruby rbx maglev],
+ :ruby_19 => %w[ruby rbx maglev],
+ :ruby_20 => %w[ruby rbx maglev],
+ :ruby_21 => %w[ruby rbx maglev],
+ }
mswin = Gem::Platform.new 'x86-mswin32'
mswin64 = Gem::Platform.new 'x64-mswin64'
@@ -86,11 +85,10 @@ class Gem::RequestSet::GemDependencyAPI
:ruby_19 => Gem::Platform::RUBY,
:ruby_20 => Gem::Platform::RUBY,
:ruby_21 => Gem::Platform::RUBY,
- :truffleruby => Gem::Platform::RUBY,
:x64_mingw => x64_mingw,
:x64_mingw_20 => x64_mingw,
:x64_mingw_21 => x64_mingw
- }.freeze
+ }
gt_eq_0 = Gem::Requirement.new '>= 0'
tilde_gt_1_8_0 = Gem::Requirement.new '~> 1.8.0'
@@ -128,11 +126,10 @@ class Gem::RequestSet::GemDependencyAPI
:ruby_19 => tilde_gt_1_9_0,
:ruby_20 => tilde_gt_2_0_0,
:ruby_21 => tilde_gt_2_1_0,
- :truffleruby => gt_eq_0,
:x64_mingw => gt_eq_0,
:x64_mingw_20 => tilde_gt_2_0_0,
:x64_mingw_21 => tilde_gt_2_1_0,
- }.freeze
+ }
WINDOWS = { # :nodoc:
:mingw => :only,
@@ -163,7 +160,7 @@ class Gem::RequestSet::GemDependencyAPI
:x64_mingw => :only,
:x64_mingw_20 => :only,
:x64_mingw_21 => :only,
- }.freeze
+ }
##
# The gems required by #gem statements in the gem.deps.rb file
@@ -194,7 +191,7 @@ class Gem::RequestSet::GemDependencyAPI
# Creates a new GemDependencyAPI that will add dependencies to the
# Gem::RequestSet +set+ based on the dependency API description in +path+.
- def initialize(set, path)
+ def initialize set, path
@set = set
@path = path
@@ -231,11 +228,11 @@ class Gem::RequestSet::GemDependencyAPI
# Adds +dependencies+ to the request set if any of the +groups+ are allowed.
# This is used for gemspec dependencies.
- def add_dependencies(groups, dependencies) # :nodoc:
+ def add_dependencies groups, dependencies # :nodoc:
return unless (groups & @without_groups).empty?
dependencies.each do |dep|
- @set.gem dep.name, *dep.requirement.as_list
+ @set.gem dep.name, *dep.requirement
end
end
@@ -244,7 +241,7 @@ class Gem::RequestSet::GemDependencyAPI
##
# Finds a gemspec with the given +name+ that lives at +path+.
- def find_gemspec(name, path) # :nodoc:
+ def find_gemspec name, path # :nodoc:
glob = File.join path, "#{name}.gemspec"
spec_files = Dir[glob]
@@ -272,7 +269,7 @@ class Gem::RequestSet::GemDependencyAPI
# In installing mode certain restrictions are ignored such as ruby version
# mismatch checks.
- def installing=(installing) # :nodoc:
+ def installing= installing # :nodoc:
@installing = installing
end
@@ -280,7 +277,7 @@ class Gem::RequestSet::GemDependencyAPI
# Loads the gem dependency file and returns self.
def load
- instance_eval File.read(@path).tap(&Gem::UNTAINT), @path, 1
+ instance_eval File.read(@path).untaint, @path, 1
self
end
@@ -356,7 +353,7 @@ class Gem::RequestSet::GemDependencyAPI
# tag: ::
# Use the given tag for git:, gist: and github: dependencies.
- def gem(name, *requirements)
+ def gem name, *requirements
options = requirements.pop if requirements.last.kind_of?(Hash)
options ||= {}
@@ -372,9 +369,9 @@ class Gem::RequestSet::GemDependencyAPI
duplicate = @dependencies.include? name
@dependencies[name] =
- if requirements.empty? and not source_set
+ if requirements.empty? and not source_set then
Gem::Requirement.default
- elsif source_set
+ elsif source_set then
Gem::Requirement.source_set
else
Gem::Requirement.create requirements
@@ -390,7 +387,7 @@ class Gem::RequestSet::GemDependencyAPI
gem_requires name, options
- if duplicate
+ if duplicate then
warn <<-WARNING
Gem dependencies file #{@path} requires #{name} more than once.
WARNING
@@ -404,8 +401,8 @@ Gem dependencies file #{@path} requires #{name} more than once.
#
# Returns +true+ if the gist or git option was handled.
- def gem_git(name, options) # :nodoc:
- if gist = options.delete(:gist)
+ def gem_git name, options # :nodoc:
+ if gist = options.delete(:gist) then
options[:git] = "https://gist.github.com/#{gist}.git"
end
@@ -427,7 +424,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
#
# Returns reference for the git gem.
- def gem_git_reference(options) # :nodoc:
+ def gem_git_reference options # :nodoc:
ref = options.delete :ref
branch = options.delete :branch
tag = options.delete :tag
@@ -443,7 +440,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
Gem dependencies file #{@path} includes git reference for both ref and branch but only ref is used.
WARNING
end
- if (ref || branch) && tag
+ if (ref||branch) && tag
warn <<-WARNING
Gem dependencies file #{@path} includes git reference for both ref/branch and tag but only ref/branch is used.
WARNING
@@ -460,7 +457,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
#
# Returns +true+ if the custom source option was handled.
- def gem_git_source(name, options) # :nodoc:
+ def gem_git_source name, options # :nodoc:
return unless git_source = (@git_sources.keys & options.keys).last
source_callback = @git_sources[git_source]
@@ -481,9 +478,9 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# Handles the :group and :groups +options+ for the gem with the given
# +name+.
- def gem_group(name, options) # :nodoc:
+ def gem_group name, options # :nodoc:
g = options.delete :group
- all_groups = g ? Array(g) : []
+ all_groups = g ? Array(g) : []
groups = options.delete :groups
all_groups |= groups if groups
@@ -500,7 +497,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
#
# Returns +true+ if the path option was handled.
- def gem_path(name, options) # :nodoc:
+ def gem_path name, options # :nodoc:
return unless directory = options.delete(:path)
pin_gem_source name, :path, directory
@@ -517,7 +514,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
#
# Returns +true+ if the source option was handled.
- def gem_source(name, options) # :nodoc:
+ def gem_source name, options # :nodoc:
return unless source = options.delete(:source)
pin_gem_source name, :source, source
@@ -533,7 +530,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# Handles the platforms: option from +options+. Returns true if the
# platform matches the current platform.
- def gem_platforms(options) # :nodoc:
+ def gem_platforms options # :nodoc:
platform_names = Array(options.delete :platform)
platform_names.concat Array(options.delete :platforms)
platform_names.concat @current_platforms if @current_platforms
@@ -546,7 +543,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
next false unless Gem::Platform.match platform
- if engines = ENGINE_MAP[platform_name]
+ if engines = ENGINE_MAP[platform_name] then
next false unless engines.include? Gem.ruby_engine
end
@@ -567,9 +564,9 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# Records the require: option from +options+ and adds those files, or the
# default file to the require list for +name+.
- def gem_requires(name, options) # :nodoc:
- if options.include? :require
- if requires = options.delete(:require)
+ def gem_requires name, options # :nodoc:
+ if options.include? :require then
+ if requires = options.delete(:require) then
@requires[name].concat Array requires
end
else
@@ -590,7 +587,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# gem 'activerecord'
# end
- def git(repository)
+ def git repository
@current_repository = repository
yield
@@ -604,7 +601,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# for use in gems built from git repositories. You must provide a block
# that accepts a git repository name for expansion.
- def git_source(name, &callback)
+ def git_source name, &callback
@git_sources[name] = callback
end
@@ -637,7 +634,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# The group to add development dependencies to. By default this is
# :development. Only one group may be specified.
- def gemspec(options = {})
+ def gemspec options = {}
name = options.delete(:name) || '{,*}'
path = options.delete(:path) || '.'
development_group = options.delete(:development_group) || :development
@@ -682,7 +679,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# development`. See `gem help install` and `gem help gem_dependencies` for
# further details.
- def group(*groups)
+ def group *groups
@current_groups = groups
yield
@@ -695,7 +692,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# Pins the gem +name+ to the given +source+. Adding a gem with the same
# name from a different +source+ will raise an exception.
- def pin_gem_source(name, type = :default, source = nil)
+ def pin_gem_source name, type = :default, source = nil
source_description =
case type
when :default then '(default)'
@@ -757,7 +754,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# NOTE: There is inconsistency in what environment a platform matches. You
# may need to read the source to know the exact details.
- def platform(*platforms)
+ def platform *platforms
@current_platforms = platforms
yield
@@ -782,9 +779,9 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# You may also provide +engine:+ and +engine_version:+ options to restrict
# this gem dependencies file to a particular ruby engine and its engine
# version. This matching is performed by using the RUBY_ENGINE and
- # RUBY_ENGINE_VERSION constants.
+ # engine_specific VERSION constants. (For JRuby, JRUBY_VERSION).
- def ruby(version, options = {})
+ def ruby version, options = {}
engine = options[:engine]
engine_version = options[:engine_version]
@@ -794,24 +791,26 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
return true if @installing
- unless RUBY_VERSION == version
+ unless RUBY_VERSION == version then
message = "Your Ruby version is #{RUBY_VERSION}, " +
"but your #{gem_deps_file} requires #{version}"
raise Gem::RubyVersionMismatch, message
end
- if engine and engine != Gem.ruby_engine
+ if engine and engine != Gem.ruby_engine then
message = "Your Ruby engine is #{Gem.ruby_engine}, " +
"but your #{gem_deps_file} requires #{engine}"
raise Gem::RubyVersionMismatch, message
end
- if engine_version
- if engine_version != RUBY_ENGINE_VERSION
+ if engine_version then
+ my_engine_version = Object.const_get "#{Gem.ruby_engine.upcase}_VERSION"
+
+ if engine_version != my_engine_version then
message =
- "Your Ruby engine version is #{Gem.ruby_engine} #{RUBY_ENGINE_VERSION}, " +
+ "Your Ruby engine version is #{Gem.ruby_engine} #{my_engine_version}, " +
"but your #{gem_deps_file} requires #{engine} #{engine_version}"
raise Gem::RubyVersionMismatch, message
@@ -835,7 +834,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
# * The +prepend:+ option is not supported. If you wish to order sources
# then list them in your preferred order.
- def source(url)
+ def source url
Gem.sources.clear if @default_sources
@default_sources = false
@@ -843,4 +842,8 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
Gem.sources << url
end
+ # TODO: remove this typo name at RubyGems 3.0
+
+ Gem::RequestSet::GemDepedencyAPI = self # :nodoc:
+
end
diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
index 5423f2c14f..76ad17d486 100644
--- a/lib/rubygems/request_set/lockfile.rb
+++ b/lib/rubygems/request_set/lockfile.rb
@@ -5,7 +5,6 @@
# constructed.
class Gem::RequestSet::Lockfile
-
##
# Raised when a lockfile cannot be parsed
@@ -30,26 +29,25 @@ class Gem::RequestSet::Lockfile
# Raises a ParseError with the given +message+ which was encountered at a
# +line+ and +column+ while parsing.
- def initialize(message, column, line, path)
+ def initialize message, column, line, path
@line = line
@column = column
@path = path
super "#{message} (at line #{line} column #{column})"
end
-
end
##
# Creates a new Lockfile for the given +request_set+ and +gem_deps_file+
# location.
- def self.build(request_set, gem_deps_file, dependencies = nil)
+ def self.build request_set, gem_deps_file, dependencies = nil
request_set.resolve
dependencies ||= requests_to_deps request_set.sorted_requests
new request_set, gem_deps_file, dependencies
end
- def self.requests_to_deps(requests) # :nodoc:
+ def self.requests_to_deps requests # :nodoc:
deps = {}
requests.each do |request|
@@ -58,7 +56,7 @@ class Gem::RequestSet::Lockfile
requirement = request.request.dependency.requirement
deps[name] = if [Gem::Resolver::VendorSpecification,
- Gem::Resolver::GitSpecification].include? spec.class
+ Gem::Resolver::GitSpecification].include? spec.class then
Gem::Requirement.source_set
else
requirement
@@ -73,20 +71,18 @@ class Gem::RequestSet::Lockfile
attr_reader :platforms
- def initialize(request_set, gem_deps_file, dependencies)
+ def initialize request_set, gem_deps_file, dependencies
@set = request_set
@dependencies = dependencies
@gem_deps_file = File.expand_path(gem_deps_file)
@gem_deps_dir = File.dirname(@gem_deps_file)
- if RUBY_VERSION < '2.7'
- @gem_deps_file.untaint unless gem_deps_file.tainted?
- end
+ @gem_deps_file.untaint unless gem_deps_file.tainted?
- @platforms = []
+ @platforms = []
end
- def add_DEPENDENCIES(out) # :nodoc:
+ def add_DEPENDENCIES out # :nodoc:
out << "DEPENDENCIES"
out.concat @dependencies.sort_by { |name,| name }.map { |name, requirement|
@@ -96,7 +92,7 @@ class Gem::RequestSet::Lockfile
out << nil
end
- def add_GEM(out, spec_groups) # :nodoc:
+ def add_GEM out, spec_groups # :nodoc:
return if spec_groups.empty?
source_groups = spec_groups.values.flatten.group_by do |request|
@@ -126,7 +122,7 @@ class Gem::RequestSet::Lockfile
end
end
- def add_GIT(out, git_requests)
+ def add_GIT out, git_requests
return if git_requests.empty?
by_repository_revision = git_requests.group_by do |request|
@@ -152,12 +148,12 @@ class Gem::RequestSet::Lockfile
end
end
- def relative_path_from(dest, base) # :nodoc:
+ def relative_path_from dest, base # :nodoc:
dest = File.expand_path(dest)
base = File.expand_path(base)
- if dest.index(base) == 0
- offset = dest[base.size + 1..-1]
+ if dest.index(base) == 0 then
+ offset = dest[base.size+1..-1]
return '.' unless offset
@@ -167,7 +163,7 @@ class Gem::RequestSet::Lockfile
end
end
- def add_PATH(out, path_requests) # :nodoc:
+ def add_PATH out, path_requests # :nodoc:
return if path_requests.empty?
out << "PATH"
@@ -182,7 +178,7 @@ class Gem::RequestSet::Lockfile
out << nil
end
- def add_PLATFORMS(out) # :nodoc:
+ def add_PLATFORMS out # :nodoc:
out << "PLATFORMS"
platforms = requests.map { |request| request.spec.platform }.uniq
@@ -237,7 +233,6 @@ class Gem::RequestSet::Lockfile
def requests
@set.sorted_requests
end
-
end
require 'rubygems/request_set/lockfile/tokenizer'
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
index 1e9d2b12de..ebea940188 100644
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ b/lib/rubygems/request_set/lockfile/parser.rb
@@ -1,10 +1,9 @@
# frozen_string_literal: true
class Gem::RequestSet::Lockfile::Parser
-
###
# Parses lockfiles
- def initialize(tokenizer, set, platforms, filename = nil)
+ def initialize tokenizer, set, platforms, filename = nil
@tokens = tokenizer
@filename = filename
@set = set
@@ -42,10 +41,10 @@ class Gem::RequestSet::Lockfile::Parser
##
# Gets the next token for a Lockfile
- def get(expected_types = nil, expected_value = nil) # :nodoc:
+ def get expected_types = nil, expected_value = nil # :nodoc:
token = @tokens.shift
- if expected_types and not Array(expected_types).include? token.type
+ if expected_types and not Array(expected_types).include? token.type then
unget token
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
@@ -54,7 +53,7 @@ class Gem::RequestSet::Lockfile::Parser
raise Gem::RequestSet::Lockfile::ParseError.new message, token.column, token.line, @filename
end
- if expected_value and expected_value != token.value
+ if expected_value and expected_value != token.value then
unget token
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
@@ -94,7 +93,7 @@ class Gem::RequestSet::Lockfile::Parser
get :r_paren
- if peek[0] == :bang
+ if peek[0] == :bang then
requirements.clear
requirements << pinned_requirement(token.value)
@@ -145,7 +144,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4
+ if type == :text and column == 4 then
version, platform = data.split '-', 2
platform =
@@ -184,7 +183,7 @@ class Gem::RequestSet::Lockfile::Parser
type = peek.type
value = peek.value
- if type == :entry and %w[branch ref tag].include? value
+ if type == :entry and %w[branch ref tag].include? value then
get
get :text
@@ -215,7 +214,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4
+ if type == :text and column == 4 then
last_spec = set.add_git_spec name, data, repository, revision, true
else
dependency = parse_dependency name, data
@@ -262,7 +261,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4
+ if type == :text and column == 4 then
last_spec = set.add_vendor_gem name, directory
else
dependency = parse_dependency name, data
@@ -295,7 +294,7 @@ class Gem::RequestSet::Lockfile::Parser
# Parses the requirements following the dependency +name+ and the +op+ for
# the first token of the requirements and returns a Gem::Dependency object.
- def parse_dependency(name, op) # :nodoc:
+ def parse_dependency name, op # :nodoc:
return Gem::Dependency.new name, op unless peek[0] == :text
version = get(:text).value
@@ -315,7 +314,7 @@ class Gem::RequestSet::Lockfile::Parser
private
- def skip(type) # :nodoc:
+ def skip type # :nodoc:
@tokens.skip type
end
@@ -326,20 +325,30 @@ class Gem::RequestSet::Lockfile::Parser
@tokens.peek
end
- def pinned_requirement(name) # :nodoc:
- requirement = Gem::Dependency.new name
- specification = @set.sets.flat_map do |set|
- set.find_all(requirement)
- end.compact.first
+ if [].respond_to? :flat_map
+ def pinned_requirement name # :nodoc:
+ requirement = Gem::Dependency.new name
+ specification = @set.sets.flat_map { |set|
+ set.find_all(requirement)
+ }.compact.first
- specification && specification.version
+ specification && specification.version
+ end
+ else # FIXME: remove when 1.8 is dropped
+ def pinned_requirement name # :nodoc:
+ requirement = Gem::Dependency.new name
+ specification = @set.sets.map { |set|
+ set.find_all(requirement)
+ }.flatten(1).compact.first
+
+ specification && specification.version
+ end
end
##
# Ungets the last token retrieved by #get
- def unget(token) # :nodoc:
+ def unget token # :nodoc:
@tokens.unshift token
end
-
end
diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb
index 97396ec199..a758743dda 100644
--- a/lib/rubygems/request_set/lockfile/tokenizer.rb
+++ b/lib/rubygems/request_set/lockfile/tokenizer.rb
@@ -2,15 +2,14 @@
require 'rubygems/request_set/lockfile/parser'
class Gem::RequestSet::Lockfile::Tokenizer
-
Token = Struct.new :type, :value, :column, :line
EOF = Token.new :EOF
- def self.from_file(file)
+ def self.from_file file
new File.read(file), file
end
- def initialize(input, filename = nil, line = 0, pos = 0)
+ def initialize input, filename = nil, line = 0, pos = 0
@line = line
@line_pos = pos
@tokens = []
@@ -18,7 +17,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
tokenize input
end
- def make_parser(set, platforms)
+ def make_parser set, platforms
Gem::RequestSet::Lockfile::Parser.new self, set, platforms, @filename
end
@@ -26,7 +25,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
@tokens.map { |token| [token.type, token.value, token.column, token.line] }
end
- def skip(type)
+ def skip type
@tokens.shift while not @tokens.empty? and peek.type == type
end
@@ -34,7 +33,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
# Calculates the column (by byte) and the line of the current token based on
# +byte_offset+.
- def token_pos(byte_offset) # :nodoc:
+ def token_pos byte_offset # :nodoc:
[byte_offset - @line_pos, @line]
end
@@ -42,7 +41,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
@tokens.empty?
end
- def unshift(token)
+ def unshift token
@tokens.unshift token
end
@@ -57,7 +56,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
private
- def tokenize(input)
+ def tokenize input
require 'strscan'
s = StringScanner.new input
@@ -66,7 +65,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
pos = s.pos if leading_whitespace = s.scan(/ +/)
- if s.scan(/[<|=>]{7}/)
+ if s.scan(/[<|=>]{7}/) then
message = "your #{@filename} contains merge conflict markers"
column, line = token_pos pos
@@ -81,7 +80,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
@line += 1
token
when s.scan(/[A-Z]+/) then
- if leading_whitespace
+ if leading_whitespace then
text = s.matched
text += s.scan(/[^\s)]*/).to_s # in case of no match
Token.new(:text, text, *token_pos(pos))
@@ -110,5 +109,4 @@ class Gem::RequestSet::Lockfile::Tokenizer
@tokens
end
-
end
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index 1e17fc2dc2..2a60c86e69 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -2,6 +2,10 @@
require "rubygems/version"
require "rubygems/deprecate"
+# If we're being loaded after yaml was already required, then
+# load our yaml + workarounds now.
+Gem.load_yaml if defined? ::YAML
+
##
# A Requirement is a set of one or more version restrictions. It supports a
# few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
@@ -10,7 +14,6 @@ require "rubygems/deprecate"
# together in RubyGems.
class Gem::Requirement
-
OPS = { #:nodoc:
"=" => lambda { |v, r| v == r },
"!=" => lambda { |v, r| v != r },
@@ -19,27 +22,22 @@ class Gem::Requirement
">=" => lambda { |v, r| v >= r },
"<=" => lambda { |v, r| v <= r },
"~>" => lambda { |v, r| v >= r && v.release < r.bump }
- }.freeze
+ }
SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:
- quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
- PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*".freeze # :nodoc:
+ quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
+ PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*" # :nodoc:
##
# A regular expression that matches a requirement
- PATTERN = /\A#{PATTERN_RAW}\z/.freeze
-
- ##
- # The default requirement matches any non-prerelease version
-
- DefaultRequirement = [">=", Gem::Version.new(0)].freeze
+ PATTERN = /\A#{PATTERN_RAW}\z/
##
# The default requirement matches any version
- DefaultPrereleaseRequirement = [">=", Gem::Version.new("0.a")].freeze
+ DefaultRequirement = [">=", Gem::Version.new(0)]
##
# Raised when a bad requirement is encountered
@@ -53,7 +51,7 @@ class Gem::Requirement
# If the input is "weird", the default version requirement is
# returned.
- def self.create(*inputs)
+ def self.create *inputs
return new inputs if inputs.length > 1
input = inputs.shift
@@ -66,7 +64,7 @@ class Gem::Requirement
when '!' then
source_set
else
- if input.respond_to? :to_str
+ if input.respond_to? :to_str then
new [input.to_str]
else
default
@@ -74,14 +72,13 @@ class Gem::Requirement
end
end
+ ##
+ # A default "version requirement" can surely _only_ be '>= 0'.
+
def self.default
new '>= 0'
end
- def self.default_prerelease
- new '>= 0.a'
- end
-
###
# A source set requirement, used for Gemfiles and lockfiles
@@ -101,7 +98,7 @@ class Gem::Requirement
# parse("1.0") # => ["=", Gem::Version.new("1.0")]
# parse(Gem::Version.new("1.0")) # => ["=, Gem::Version.new("1.0")]
- def self.parse(obj)
+ def self.parse obj
return ["=", obj] if Gem::Version === obj
unless PATTERN =~ obj.to_s
@@ -110,8 +107,6 @@ class Gem::Requirement
if $1 == ">=" && $2 == "0"
DefaultRequirement
- elsif $1 == ">=" && $2 == "0.a"
- DefaultPrereleaseRequirement
else
[$1 || "=", Gem::Version.new($2)]
end
@@ -129,7 +124,7 @@ class Gem::Requirement
# requirements are ignored. An empty set of +requirements+ is the
# same as <tt>">= 0"</tt>.
- def initialize(*requirements)
+ def initialize *requirements
requirements = requirements.flatten
requirements.compact!
requirements.uniq!
@@ -144,7 +139,7 @@ class Gem::Requirement
##
# Concatenates the +new+ requirements onto this requirement.
- def concat(new)
+ def concat new
new = new.flatten
new.compact!
new.uniq!
@@ -159,11 +154,11 @@ class Gem::Requirement
def for_lockfile # :nodoc:
return if [DefaultRequirement] == @requirements
- list = requirements.sort_by do |_, version|
+ list = requirements.sort_by { |_, version|
version
- end.map do |op, version|
+ }.map { |op, version|
"#{op} #{version}"
- end.uniq
+ }.uniq
" (#{list.join ', '})"
end
@@ -188,7 +183,7 @@ class Gem::Requirement
end
def as_list # :nodoc:
- requirements.map { |op, version| "#{op} #{version}" }
+ requirements.map { |op, version| "#{op} #{version}" }.sort
end
def hash # :nodoc:
@@ -201,7 +196,7 @@ class Gem::Requirement
[@requirements]
end
- def marshal_load(array) # :nodoc:
+ def marshal_load array # :nodoc:
@requirements = array[0]
fix_syck_default_key_in_requirements
@@ -216,7 +211,7 @@ class Gem::Requirement
fix_syck_default_key_in_requirements
end
- def init_with(coder) # :nodoc:
+ def init_with coder # :nodoc:
yaml_initialize coder.tag, coder.map
end
@@ -224,7 +219,7 @@ class Gem::Requirement
["@requirements"]
end
- def encode_with(coder) # :nodoc:
+ def encode_with coder # :nodoc:
coder.add 'requirements', @requirements
end
@@ -236,7 +231,7 @@ class Gem::Requirement
requirements.any? { |r| r.last.prerelease? }
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 1, 'Gem::Requirement.new(', ')' do
q.pp as_list
end
@@ -245,7 +240,7 @@ class Gem::Requirement
##
# True if +version+ satisfies this Requirement.
- def satisfied_by?(version)
+ def satisfied_by? version
raise ArgumentError, "Need a Gem::Version: #{version.inspect}" unless
Gem::Version === version
# #28965: syck has a bug with unquoted '=' YAML.loading as YAML::DefaultKey
@@ -268,24 +263,8 @@ class Gem::Requirement
as_list.join ", "
end
- def ==(other) # :nodoc:
- return unless Gem::Requirement === other
-
- # An == check is always necessary
- return false unless requirements == other.requirements
-
- # An == check is sufficient unless any requirements use ~>
- return true unless _tilde_requirements.any?
-
- # If any requirements use ~> we use the stricter `#eql?` that also checks
- # that version precision is the same
- _tilde_requirements.eql?(other._tilde_requirements)
- end
-
- protected
-
- def _tilde_requirements
- requirements.select { |r| r.first == "~>" }
+ def == other # :nodoc:
+ Gem::Requirement === other and to_s == other.to_s
end
private
@@ -300,14 +279,11 @@ class Gem::Requirement
end
end
end
-
end
class Gem::Version
-
# This is needed for compatibility with older yaml
# gemspecs.
Requirement = Gem::Requirement # :nodoc:
-
end
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index ea9687bdbf..13ee035e4c 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -11,7 +11,6 @@ require 'rubygems/util/list'
# all the requirements.
class Gem::Resolver
-
require 'rubygems/resolver/molinillo'
##
@@ -60,7 +59,7 @@ class Gem::Resolver
# uniform manner. If one of the +sets+ is itself a ComposedSet its sets are
# flattened into the result ComposedSet.
- def self.compose_sets(*sets)
+ def self.compose_sets *sets
sets.compact!
sets = sets.map do |set|
@@ -88,7 +87,7 @@ class Gem::Resolver
# Creates a Resolver that queries only against the already installed gems
# for the +needed+ dependencies.
- def self.for_current_gems(needed)
+ def self.for_current_gems needed
new needed, Gem::Resolver::CurrentSet.new
end
@@ -100,7 +99,7 @@ class Gem::Resolver
# satisfy the Dependencies. This defaults to IndexSet, which will query
# rubygems.org.
- def initialize(needed, set = nil)
+ def initialize needed, set = nil
@set = set || Gem::Resolver::IndexSet.new
@needed = needed
@@ -113,22 +112,19 @@ class Gem::Resolver
@stats = Gem::Resolver::Stats.new
end
- def explain(stage, *data) # :nodoc:
+ def explain stage, *data # :nodoc:
return unless DEBUG_RESOLVER
d = data.map { |x| x.pretty_inspect }.join(", ")
$stderr.printf "%10s %s\n", stage.to_s.upcase, d
end
- def explain_list(stage) # :nodoc:
+ def explain_list stage # :nodoc:
return unless DEBUG_RESOLVER
data = yield
$stderr.printf "%10s (%d entries)\n", stage.to_s.upcase, data.size
- unless data.empty?
- require 'pp'
- PP.pp data, $stderr
- end
+ PP.pp data, $stderr unless data.empty?
end
##
@@ -137,7 +133,7 @@ class Gem::Resolver
#
# Returns the Specification and the ActivationRequest
- def activation_request(dep, possible) # :nodoc:
+ def activation_request dep, possible # :nodoc:
spec = possible.pop
explain :activate, [spec.full_name, possible.size]
@@ -149,7 +145,7 @@ class Gem::Resolver
return spec, activation_request
end
- def requests(s, act, reqs=[]) # :nodoc:
+ def requests s, act, reqs=[] # :nodoc:
return reqs if @ignore_dependencies
s.fetch_development_dependencies if @development
@@ -175,7 +171,7 @@ class Gem::Resolver
include Molinillo::UI
def output
- @output ||= debug? ? $stdout : File.open(IO::NULL, 'w')
+ @output ||= debug? ? $stdout : File.open(Gem::Util::NULL_DEVICE, 'w')
end
def debug?
@@ -201,7 +197,7 @@ class Gem::Resolver
# Extracts the specifications that may be able to fulfill +dependency+ and
# returns those that match the local platform and all those that match.
- def find_possible(dependency) # :nodoc:
+ def find_possible dependency # :nodoc:
all = @set.find_all dependency
if (skip_dep_gems = skip_gems[dependency.name]) && !skip_dep_gems.empty?
@@ -220,7 +216,7 @@ class Gem::Resolver
##
# Returns the gems in +specs+ that match the local platform.
- def select_local_platforms(specs) # :nodoc:
+ def select_local_platforms specs # :nodoc:
specs.select do |spec|
Gem::Platform.installable? spec
end
@@ -235,21 +231,23 @@ class Gem::Resolver
raise exc
end
+ sources = []
+
groups = Hash.new { |hash, key| hash[key] = [] }
# create groups & sources in the same loop
- sources = possibles.map do |spec|
+ sources = possibles.map { |spec|
source = spec.source
groups[source] << spec
source
- end.uniq.reverse
+ }.uniq.reverse
activation_requests = []
sources.each do |source|
groups[source].
sort_by { |spec| [spec.version, Gem::Platform.local =~ spec.platform ? 1 : 0] }.
- map { |spec| ActivationRequest.new spec, dependency }.
+ map { |spec| ActivationRequest.new spec, dependency, [] }.
each { |activation_request| activation_requests << activation_request }
end
@@ -316,6 +314,11 @@ class Gem::Resolver
end
+##
+# TODO remove in RubyGems 3
+
+Gem::DependencyResolver = Gem::Resolver # :nodoc:
+
require 'rubygems/resolver/activation_request'
require 'rubygems/resolver/conflict'
require 'rubygems/resolver/dependency_request'
diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb
index 2a8d6032f8..135d75d6bc 100644
--- a/lib/rubygems/resolver/activation_request.rb
+++ b/lib/rubygems/resolver/activation_request.rb
@@ -18,13 +18,17 @@ class Gem::Resolver::ActivationRequest
##
# Creates a new ActivationRequest that will activate +spec+. The parent
# +request+ is used to provide diagnostics in case of conflicts.
+ #
+ # +others_possible+ indicates that other specifications may also match this
+ # activation request.
- def initialize(spec, request)
+ def initialize spec, request, others_possible = true
@spec = spec
@request = request
+ @others_possible = others_possible
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
case other
when Gem::Specification
@spec == other
@@ -45,17 +49,17 @@ class Gem::Resolver::ActivationRequest
##
# Downloads a gem at +path+ and returns the file path.
- def download(path)
+ def download path
Gem.ensure_gem_subdirectories path
if @spec.respond_to? :sources
exception = nil
- path = @spec.sources.find do |source|
+ path = @spec.sources.find{ |source|
begin
source.download full_spec, path
rescue exception
end
- end
+ }
return path if path
raise exception if exception
@@ -73,7 +77,7 @@ class Gem::Resolver::ActivationRequest
# The full name of the specification to be activated.
def full_name
- name_tuple.full_name
+ @spec.full_name
end
alias_method :to_s, :full_name
@@ -86,8 +90,21 @@ class Gem::Resolver::ActivationRequest
end
def inspect # :nodoc:
- '#<%s for %p from %s>' % [
- self.class, @spec, @request
+ others =
+ case @others_possible
+ when true then # TODO remove at RubyGems 3
+ ' (others possible)'
+ when false then # TODO remove at RubyGems 3
+ nil
+ else
+ unless @others_possible.empty? then
+ others = @others_possible.map { |s| s.full_name }
+ " (others possible: #{others.join ', '})"
+ end
+ end
+
+ '#<%s for %p from %s%s>' % [
+ self.class, @spec, @request, others
]
end
@@ -115,6 +132,19 @@ class Gem::Resolver::ActivationRequest
end
##
+ # Indicate if this activation is one of a set of possible
+ # requests for the same Dependency request.
+
+ def others_possible?
+ case @others_possible
+ when true, false then
+ @others_possible
+ else
+ not @others_possible.empty?
+ end
+ end
+
+ ##
# Return the ActivationRequest that contained the dependency
# that we were activated for.
@@ -122,7 +152,7 @@ class Gem::Resolver::ActivationRequest
@request.requester
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[Activation request', ']' do
q.breakable
q.pp @spec
@@ -130,6 +160,19 @@ class Gem::Resolver::ActivationRequest
q.breakable
q.text ' for '
q.pp @request
+
+ case @others_possible
+ when false then
+ when true then
+ q.breakable
+ q.text 'others possible'
+ else
+ unless @others_possible.empty? then
+ q.breakable
+ q.text 'others '
+ q.pp @others_possible.map { |s| s.full_name }
+ end
+ end
end
end
@@ -140,17 +183,4 @@ class Gem::Resolver::ActivationRequest
@spec.version
end
- ##
- # The platform of this activation request's specification
-
- def platform
- @spec.platform
- end
-
- private
-
- def name_tuple
- @name_tuple ||= Gem::NameTuple.new(name, version, platform)
- end
-
end
diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb
index 135f1b08aa..ee3046af63 100644
--- a/lib/rubygems/resolver/api_set.rb
+++ b/lib/rubygems/resolver/api_set.rb
@@ -23,9 +23,9 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
##
# Creates a new APISet that will retrieve gems from +uri+ using the RubyGems
# API URL +dep_uri+ which is described at
- # https://guides.rubygems.org/rubygems-org-api
+ # http://guides.rubygems.org/rubygems-org-api
- def initialize(dep_uri = 'https://rubygems.org/api/v1/dependencies')
+ def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies'
super()
dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8
@@ -43,7 +43,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
# Return an array of APISpecification objects matching
# DependencyRequest +req+.
- def find_all(req)
+ def find_all req
res = []
return res unless @remote
@@ -65,7 +65,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
# A hint run by the resolver to allow the Set to fetch
# data for DependencyRequests +reqs+.
- def prefetch(reqs)
+ def prefetch reqs
return unless @remote
names = reqs.map { |r| r.dependency.name }
needed = names - @data.keys - @to_fetch
@@ -93,7 +93,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
end
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[APISet', ']' do
q.breakable
q.text "URI: #{@dep_uri}"
@@ -107,7 +107,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
##
# Return data for all versions of the gem +name+.
- def versions(name) # :nodoc:
+ def versions name # :nodoc:
if @data.key?(name)
return @data[name]
end
@@ -123,3 +123,4 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
end
end
+
diff --git a/lib/rubygems/resolver/api_specification.rb b/lib/rubygems/resolver/api_specification.rb
index 4052846e99..1e22dd0b6f 100644
--- a/lib/rubygems/resolver/api_specification.rb
+++ b/lib/rubygems/resolver/api_specification.rb
@@ -11,7 +11,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
# Creates an APISpecification for the given +set+ from the rubygems.org
# +api_data+.
#
- # See https://guides.rubygems.org/rubygems-org-api/#misc_methods for the
+ # See http://guides.rubygems.org/rubygems-org-api/#misc_methods for the
# format of the +api_data+.
def initialize(set, api_data)
@@ -21,13 +21,12 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
@name = api_data[:name]
@version = Gem::Version.new api_data[:number]
@platform = Gem::Platform.new api_data[:platform]
- @original_platform = api_data[:platform]
@dependencies = api_data[:dependencies].map do |name, ver|
Gem::Dependency.new name, ver.split(/\s*,\s*/)
end
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
self.class === other and
@set == other.set and
@name == other.name and
@@ -46,7 +45,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
Gem::Platform.match @platform
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[APISpecification', ']' do
q.breakable
q.text "name: #{name}"
@@ -74,11 +73,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
@spec ||=
begin
tuple = Gem::NameTuple.new @name, @version, @platform
- source.fetch_spec tuple
- rescue Gem::RemoteFetcher::FetchError
- raise if @original_platform == @platform
- tuple = Gem::NameTuple.new @name, @version, @original_platform
source.fetch_spec tuple
end
end
@@ -88,3 +83,4 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
end
end
+
diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb
index 8a8c15d9a4..4479535abe 100644
--- a/lib/rubygems/resolver/best_set.rb
+++ b/lib/rubygems/resolver/best_set.rb
@@ -10,7 +10,7 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
# Creates a BestSet for the given +sources+ or Gem::sources if none are
# specified. +sources+ must be a Gem::SourceList.
- def initialize(sources = Gem.sources)
+ def initialize sources = Gem.sources
super()
@sources = sources
@@ -25,7 +25,7 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
end
end
- def find_all(req) # :nodoc:
+ def find_all req # :nodoc:
pick_sets if @remote and @sets.empty?
super
@@ -35,13 +35,13 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
retry
end
- def prefetch(reqs) # :nodoc:
+ def prefetch reqs # :nodoc:
pick_sets if @remote and @sets.empty?
super
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[BestSet', ']' do
q.breakable
q.text 'sets:'
@@ -58,14 +58,14 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
#
# The calling method must retry the exception to repeat the lookup.
- def replace_failed_api_set(error) # :nodoc:
+ def replace_failed_api_set error # :nodoc:
uri = error.uri
uri = URI uri unless URI === uri
uri.query = nil
- raise error unless api_set = @sets.find do |set|
+ raise error unless api_set = @sets.find { |set|
Gem::Resolver::APISet === set and set.dep_uri == uri
- end
+ }
index_set = Gem::Resolver::IndexSet.new api_set.source
@@ -76,3 +76,4 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
end
end
+
diff --git a/lib/rubygems/resolver/composed_set.rb b/lib/rubygems/resolver/composed_set.rb
index 4baac9c75b..0b65942dca 100644
--- a/lib/rubygems/resolver/composed_set.rb
+++ b/lib/rubygems/resolver/composed_set.rb
@@ -16,7 +16,7 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
# Creates a new ComposedSet containing +sets+. Use
# Gem::Resolver::compose_sets instead.
- def initialize(*sets)
+ def initialize *sets
super()
@sets = sets
@@ -26,7 +26,7 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
# When +allow_prerelease+ is set to +true+ prereleases gems are allowed to
# match dependencies.
- def prerelease=(allow_prerelease)
+ def prerelease= allow_prerelease
super
sets.each do |set|
@@ -37,7 +37,7 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
##
# Sets the remote network access for all composed sets.
- def remote=(remote)
+ def remote= remote
super
@sets.each { |set| set.remote = remote }
@@ -50,7 +50,7 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
##
# Finds all specs matching +req+ in all sets.
- def find_all(req)
+ def find_all req
@sets.map do |s|
s.find_all req
end.flatten
@@ -59,8 +59,9 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
##
# Prefetches +reqs+ in all sets.
- def prefetch(reqs)
+ def prefetch reqs
@sets.each { |s| s.prefetch(reqs) }
end
end
+
diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb
index 2b337db339..7997f92950 100644
--- a/lib/rubygems/resolver/conflict.rb
+++ b/lib/rubygems/resolver/conflict.rb
@@ -27,7 +27,7 @@ class Gem::Resolver::Conflict
@failed_dep = failed_dep
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
self.class === other and
@dependency == other.dependency and
@activated == other.activated and
@@ -57,7 +57,7 @@ class Gem::Resolver::Conflict
requirement = dependency.requirement
alternates = dependency.matching_specs.map { |spec| spec.full_name }
- unless alternates.empty?
+ unless alternates.empty? then
matching = <<-MATCHING.chomp
Gems matching %s:
@@ -97,7 +97,7 @@ class Gem::Resolver::Conflict
@dependency.name == spec.name
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[Dependency conflict: ', ']' do
q.breakable
@@ -109,7 +109,7 @@ class Gem::Resolver::Conflict
q.pp @dependency
q.breakable
- if @dependency == @failed_dep
+ if @dependency == @failed_dep then
q.text ' failed'
else
q.text ' failed dependency '
@@ -121,7 +121,7 @@ class Gem::Resolver::Conflict
##
# Path of activations from the +current+ list.
- def request_path(current)
+ def request_path current
path = []
while current do
@@ -153,3 +153,8 @@ class Gem::Resolver::Conflict
end
end
+
+##
+# TODO: Remove in RubyGems 3
+
+Gem::Resolver::DependencyConflict = Gem::Resolver::Conflict # :nodoc:
diff --git a/lib/rubygems/resolver/current_set.rb b/lib/rubygems/resolver/current_set.rb
index d60e46389d..265c639f15 100644
--- a/lib/rubygems/resolver/current_set.rb
+++ b/lib/rubygems/resolver/current_set.rb
@@ -6,8 +6,9 @@
class Gem::Resolver::CurrentSet < Gem::Resolver::Set
- def find_all(req)
+ def find_all req
req.dependency.matching_specs
end
end
+
diff --git a/lib/rubygems/resolver/dependency_request.rb b/lib/rubygems/resolver/dependency_request.rb
index 1984aa9ddc..c2918911cd 100644
--- a/lib/rubygems/resolver/dependency_request.rb
+++ b/lib/rubygems/resolver/dependency_request.rb
@@ -19,12 +19,12 @@ class Gem::Resolver::DependencyRequest
# Creates a new DependencyRequest for +dependency+ from +requester+.
# +requester may be nil if the request came from a user.
- def initialize(dependency, requester)
+ def initialize dependency, requester
@dependency = dependency
@requester = requester
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
case other
when Gem::Dependency
@dependency == other
@@ -48,7 +48,7 @@ class Gem::Resolver::DependencyRequest
# NOTE: #match? only matches prerelease versions when #dependency is a
# prerelease dependency.
- def match?(spec, allow_prerelease = false)
+ def match? spec, allow_prerelease = false
@dependency.match? spec, nil, allow_prerelease
end
@@ -95,7 +95,7 @@ class Gem::Resolver::DependencyRequest
@requester ? @requester.request : "(unknown)"
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[Dependency request ', ']' do
q.breakable
q.text @dependency.to_s
diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb
index 6340b92fae..723a202d7a 100644
--- a/lib/rubygems/resolver/git_set.rb
+++ b/lib/rubygems/resolver/git_set.rb
@@ -43,7 +43,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
@specs = {}
end
- def add_git_gem(name, repository, reference, submodules) # :nodoc:
+ def add_git_gem name, repository, reference, submodules # :nodoc:
@repositories[name] = [repository, reference]
@need_submodules[repository] = submodules
end
@@ -56,7 +56,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
# This fills in the prefetch information as enough information about the gem
# is present in the arguments.
- def add_git_spec(name, version, repository, reference, submodules) # :nodoc:
+ def add_git_spec name, version, repository, reference, submodules # :nodoc:
add_git_gem name, repository, reference, submodules
source = Gem::Source::Git.new name, repository, reference
@@ -77,7 +77,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
##
# Finds all git gems matching +req+
- def find_all(req)
+ def find_all req
prefetch nil
specs.values.select do |spec|
@@ -88,7 +88,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
##
# Prefetches specifications from the git repositories in this set.
- def prefetch(reqs)
+ def prefetch reqs
return unless @specs.empty?
@repositories.each do |name, (repository, reference)|
@@ -104,7 +104,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
end
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[GitSet', ']' do
next if @repositories.empty?
q.breakable
@@ -120,3 +120,4 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
end
end
+
diff --git a/lib/rubygems/resolver/git_specification.rb b/lib/rubygems/resolver/git_specification.rb
index f43cfba853..2448797d3f 100644
--- a/lib/rubygems/resolver/git_specification.rb
+++ b/lib/rubygems/resolver/git_specification.rb
@@ -6,14 +6,14 @@
class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
- def ==(other) # :nodoc:
+ def == other # :nodoc:
self.class === other and
@set == other.set and
@spec == other.spec and
@source == other.source
end
- def add_dependency(dependency) # :nodoc:
+ def add_dependency dependency # :nodoc:
spec.dependencies << dependency
end
@@ -21,7 +21,7 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
# Installing a git gem only involves building the extensions and generating
# the executables.
- def install(options = {})
+ def install options = {}
require 'rubygems/installer'
installer = Gem::Installer.for_spec spec, options
@@ -35,7 +35,7 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
installer.run_post_install_hooks
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[GitSpecification', ']' do
q.breakable
q.text "name: #{name}"
@@ -56,3 +56,4 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
end
end
+
diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb
index e32e1fa5ba..2450f14b4f 100644
--- a/lib/rubygems/resolver/index_set.rb
+++ b/lib/rubygems/resolver/index_set.rb
@@ -5,11 +5,11 @@
class Gem::Resolver::IndexSet < Gem::Resolver::Set
- def initialize(source = nil) # :nodoc:
+ def initialize source = nil # :nodoc:
super()
@f =
- if source
+ if source then
sources = Gem::SourceList.from [source]
Gem::SpecFetcher.new sources
@@ -36,7 +36,7 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
# Return an array of IndexSpecification objects matching
# DependencyRequest +req+.
- def find_all(req)
+ def find_all req
res = []
return res unless @remote
@@ -44,7 +44,7 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
name = req.dependency.name
@all[name].each do |uri, n|
- if req.match? n, @prerelease
+ if req.match? n, @prerelease then
res << Gem::Resolver::IndexSpecification.new(
self, n.name, n.version, uri, n.platform)
end
@@ -53,7 +53,7 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
res
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[IndexSet', ']' do
q.breakable
q.text 'sources:'
@@ -78,3 +78,4 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
end
end
+
diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb
index ed9423791c..4340f46943 100644
--- a/lib/rubygems/resolver/index_specification.rb
+++ b/lib/rubygems/resolver/index_specification.rb
@@ -15,7 +15,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
# The +name+, +version+ and +platform+ are the name, version and platform of
# the gem.
- def initialize(set, name, version, source, platform)
+ def initialize set, name, version, source, platform
super()
@set = set
@@ -38,12 +38,12 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
'#<%s %s source %s>' % [self.class, full_name, @source]
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[Index specification', ']' do
q.breakable
q.text full_name
- unless Gem::Platform::RUBY == @platform
+ unless Gem::Platform::RUBY == @platform then
q.breakable
q.text @platform.to_s
end
@@ -67,3 +67,4 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
end
end
+
diff --git a/lib/rubygems/resolver/installed_specification.rb b/lib/rubygems/resolver/installed_specification.rb
index 9d996fc1da..d9c6a5e5cf 100644
--- a/lib/rubygems/resolver/installed_specification.rb
+++ b/lib/rubygems/resolver/installed_specification.rb
@@ -5,7 +5,7 @@
class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
- def ==(other) # :nodoc:
+ def == other # :nodoc:
self.class === other and
@set == other.set and
@spec == other.spec
@@ -15,7 +15,7 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
# This is a null install as this specification is already installed.
# +options+ are ignored.
- def install(options = {})
+ def install options = {}
yield nil
end
@@ -30,7 +30,7 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
super
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[InstalledSpecification', ']' do
q.breakable
q.text "name: #{name}"
@@ -56,3 +56,4 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
end
end
+
diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
index ba14ee945d..f24293c0a0 100644
--- a/lib/rubygems/resolver/installer_set.rb
+++ b/lib/rubygems/resolver/installer_set.rb
@@ -29,7 +29,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
##
# Creates a new InstallerSet that will look for gems in +domain+.
- def initialize(domain)
+ def initialize domain
super()
@domain = domain
@@ -50,14 +50,14 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
# Looks up the latest specification for +dependency+ and adds it to the
# always_install list.
- def add_always_install(dependency)
+ def add_always_install dependency
request = Gem::Resolver::DependencyRequest.new dependency, nil
found = find_all request
- found.delete_if do |s|
+ found.delete_if { |s|
s.version.prerelease? and not s.local?
- end unless dependency.prerelease?
+ } unless dependency.prerelease?
found = found.select do |s|
Gem::Source::SpecificFile === s.source or
@@ -65,7 +65,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
Gem::Platform.local === s.platform
end
- if found.empty?
+ if found.empty? then
exc = Gem::UnsatisfiableDependencyError.new request
exc.errors = errors
@@ -83,7 +83,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
# Adds a local gem requested using +dep_name+ with the given +spec+ that can
# be loaded and installed using the +source+.
- def add_local(dep_name, spec, source)
+ def add_local dep_name, spec, source
@local[dep_name] = [spec, source]
end
@@ -112,10 +112,10 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
# Returns an array of IndexSpecification objects matching DependencyRequest
# +req+.
- def find_all(req)
+ def find_all req
res = []
- dep = req.dependency
+ dep = req.dependency
return res if @ignore_dependencies and
@always_install.none? { |spec| dep.match? spec }
@@ -128,7 +128,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
res << Gem::Resolver::InstalledSpecification.new(self, gemspec)
end unless @ignore_installed
- if consider_local?
+ if consider_local? then
matching_local = @local.values.select do |spec, _|
req.match? spec
end.map do |spec, source|
@@ -138,7 +138,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
res.concat matching_local
begin
- if local_spec = @local_source.find_gem(name, dep.requirement)
+ if local_spec = @local_source.find_gem(name, dep.requirement) then
res << Gem::Resolver::IndexSpecification.new(
self, local_spec.name, local_spec.version,
@local_source, local_spec.platform)
@@ -161,7 +161,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
@remote_set.prefetch(reqs) if consider_remote?
end
- def prerelease=(allow_prerelease)
+ def prerelease= allow_prerelease
super
@remote_set.prerelease = allow_prerelease
@@ -179,7 +179,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
# Called from IndexSpecification to get a true Specification
# object.
- def load_spec(name, ver, platform, source) # :nodoc:
+ def load_spec name, ver, platform, source # :nodoc:
key = "#{name}-#{ver}-#{platform}"
@specs.fetch key do
@@ -192,13 +192,13 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
##
# Has a local gem for +dep_name+ been added to this set?
- def local?(dep_name) # :nodoc:
+ def local? dep_name # :nodoc:
spec, _ = @local[dep_name]
spec
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[InstallerSet', ']' do
q.breakable
q.text "domain: #{@domain}"
@@ -213,7 +213,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
end
end
- def remote=(remote) # :nodoc:
+ def remote= remote # :nodoc:
case @domain
when :local then
@domain = :both if remote
diff --git a/lib/rubygems/resolver/local_specification.rb b/lib/rubygems/resolver/local_specification.rb
index 7418cfcc86..1d9d22f0ac 100644
--- a/lib/rubygems/resolver/local_specification.rb
+++ b/lib/rubygems/resolver/local_specification.rb
@@ -17,7 +17,7 @@ class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification
true
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[LocalSpecification', ']' do
q.breakable
q.text "name: #{name}"
@@ -39,3 +39,4 @@ class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification
end
end
+
diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb
index 4134b4dcaf..7fddc93e1c 100644
--- a/lib/rubygems/resolver/lock_set.rb
+++ b/lib/rubygems/resolver/lock_set.rb
@@ -9,14 +9,14 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
##
# Creates a new LockSet from the given +sources+
- def initialize(sources)
+ def initialize sources
super()
@sources = sources.map do |source|
Gem::Source::Lock.new source
end
- @specs = []
+ @specs = []
end
##
@@ -26,7 +26,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
# The specification's set will be the current set, and the source will be
# the current set's source.
- def add(name, version, platform) # :nodoc:
+ def add name, version, platform # :nodoc:
version = Gem::Version.new version
specs = [
Gem::Resolver::LockSpecification.new(self, name, version, @sources, platform)
@@ -41,7 +41,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
# Returns an Array of IndexSpecification objects matching the
# DependencyRequest +req+.
- def find_all(req)
+ def find_all req
@specs.select do |spec|
req.match? spec
end
@@ -51,7 +51,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
# Loads a Gem::Specification with the given +name+, +version+ and
# +platform+. +source+ is ignored.
- def load_spec(name, version, platform, source) # :nodoc:
+ def load_spec name, version, platform, source # :nodoc:
dep = Gem::Dependency.new name, version
found = @specs.find do |spec|
@@ -63,7 +63,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
found.source.fetch_spec tuple
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[LockSet', ']' do
q.breakable
q.text 'source:'
@@ -80,3 +80,4 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
end
end
+
diff --git a/lib/rubygems/resolver/lock_specification.rb b/lib/rubygems/resolver/lock_specification.rb
index 5954507dba..f485675673 100644
--- a/lib/rubygems/resolver/lock_specification.rb
+++ b/lib/rubygems/resolver/lock_specification.rb
@@ -9,7 +9,7 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
attr_reader :sources
- def initialize(set, name, version, sources, platform)
+ def initialize set, name, version, sources, platform
super()
@name = name
@@ -27,10 +27,10 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
# This is a null install as a locked specification is considered installed.
# +options+ are ignored.
- def install(options = {})
+ def install options = {}
destination = options[:install_dir] || Gem.dir
- if File.exist? File.join(destination, 'specifications', spec.spec_name)
+ if File.exist? File.join(destination, 'specifications', spec.spec_name) then
yield nil
return
end
@@ -41,11 +41,11 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
##
# Adds +dependency+ from the lockfile to this specification
- def add_dependency(dependency) # :nodoc:
+ def add_dependency dependency # :nodoc:
@dependencies << dependency
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[LockSpecification', ']' do
q.breakable
q.text "name: #{@name}"
@@ -53,12 +53,12 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
q.breakable
q.text "version: #{@version}"
- unless @platform == Gem::Platform::RUBY
+ unless @platform == Gem::Platform::RUBY then
q.breakable
q.text "platform: #{@platform}"
end
- unless @dependencies.empty?
+ unless @dependencies.empty? then
q.breakable
q.text 'dependencies:'
q.breakable
@@ -71,9 +71,9 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
# A specification constructed from the lockfile is returned
def spec
- @spec ||= Gem::Specification.find do |spec|
+ @spec ||= Gem::Specification.find { |spec|
spec.name == @name and spec.version == @version
- end
+ }
@spec ||= Gem::Specification.new do |s|
s.name = @name
@@ -85,3 +85,4 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
end
end
+
diff --git a/lib/rubygems/resolver/requirement_list.rb b/lib/rubygems/resolver/requirement_list.rb
index cf0014b0bb..2768c80170 100644
--- a/lib/rubygems/resolver/requirement_list.rb
+++ b/lib/rubygems/resolver/requirement_list.rb
@@ -18,7 +18,7 @@ class Gem::Resolver::RequirementList
@list = []
end
- def initialize_copy(other) # :nodoc:
+ def initialize_copy other # :nodoc:
@exact = @exact.dup
@list = @list.dup
end
@@ -79,5 +79,4 @@ class Gem::Resolver::RequirementList
x = @exact[0,5]
x + @list[0,5 - x.size]
end
-
end
diff --git a/lib/rubygems/resolver/set.rb b/lib/rubygems/resolver/set.rb
index 242f9cd3dc..11704d5c4c 100644
--- a/lib/rubygems/resolver/set.rb
+++ b/lib/rubygems/resolver/set.rb
@@ -31,7 +31,7 @@ class Gem::Resolver::Set
# The find_all method must be implemented. It returns all Resolver
# Specification objects matching the given DependencyRequest +req+.
- def find_all(req)
+ def find_all req
raise NotImplementedError
end
@@ -43,7 +43,7 @@ class Gem::Resolver::Set
# When overridden, the #prefetch method should look up specifications
# matching +reqs+.
- def prefetch(reqs)
+ def prefetch reqs
end
##
diff --git a/lib/rubygems/resolver/source_set.rb b/lib/rubygems/resolver/source_set.rb
index 8e799514fd..66f5963e54 100644
--- a/lib/rubygems/resolver/source_set.rb
+++ b/lib/rubygems/resolver/source_set.rb
@@ -16,7 +16,7 @@ class Gem::Resolver::SourceSet < Gem::Resolver::Set
@sets = {}
end
- def find_all(req) # :nodoc:
+ def find_all req # :nodoc:
if set = get_set(req.dependency.name)
set.find_all req
else
@@ -25,7 +25,7 @@ class Gem::Resolver::SourceSet < Gem::Resolver::Set
end
# potentially no-op
- def prefetch(reqs) # :nodoc:
+ def prefetch reqs # :nodoc:
reqs.each do |req|
if set = get_set(req.dependency.name)
set.prefetch reqs
@@ -33,11 +33,11 @@ class Gem::Resolver::SourceSet < Gem::Resolver::Set
end
end
- def add_source_gem(name, source)
+ def add_source_gem name, source
@links[name] = source
end
- private
+private
def get_set(name)
link = @links[name]
@@ -45,3 +45,4 @@ class Gem::Resolver::SourceSet < Gem::Resolver::Set
end
end
+
diff --git a/lib/rubygems/resolver/spec_specification.rb b/lib/rubygems/resolver/spec_specification.rb
index d0e744f3a7..35ee8cc247 100644
--- a/lib/rubygems/resolver/spec_specification.rb
+++ b/lib/rubygems/resolver/spec_specification.rb
@@ -10,7 +10,7 @@ class Gem::Resolver::SpecSpecification < Gem::Resolver::Specification
# +spec+. The +source+ is either where the +spec+ came from, or should be
# loaded from.
- def initialize(set, spec, source = nil)
+ def initialize set, spec, source = nil
@set = set
@source = source
@spec = spec
@@ -54,3 +54,4 @@ class Gem::Resolver::SpecSpecification < Gem::Resolver::Specification
end
end
+
diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb
index e859d6659a..44989d39ae 100644
--- a/lib/rubygems/resolver/specification.rb
+++ b/lib/rubygems/resolver/specification.rb
@@ -81,10 +81,14 @@ class Gem::Resolver::Specification
# After installation #spec is updated to point to the just-installed
# specification.
- def install(options = {})
+ def install options = {}
require 'rubygems/installer'
- gem = download options
+ destination = options[:install_dir] || Gem.dir
+
+ Gem.ensure_gem_subdirectories destination
+
+ gem = source.download spec, destination
installer = Gem::Installer.at gem, options
@@ -93,14 +97,6 @@ class Gem::Resolver::Specification
@spec = installer.install
end
- def download(options)
- dir = options[:install_dir] || Gem.dir
-
- Gem.ensure_gem_subdirectories dir
-
- source.download spec, dir
- end
-
##
# Returns true if this specification is installable on this platform.
@@ -111,5 +107,5 @@ class Gem::Resolver::Specification
def local? # :nodoc:
false
end
-
end
+
diff --git a/lib/rubygems/resolver/stats.rb b/lib/rubygems/resolver/stats.rb
index 5f41940b1e..3b95efebf7 100644
--- a/lib/rubygems/resolver/stats.rb
+++ b/lib/rubygems/resolver/stats.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
class Gem::Resolver::Stats
-
def initialize
@max_depth = 0
@max_requirements = 0
@@ -33,7 +32,7 @@ class Gem::Resolver::Stats
@iterations += 1
end
- PATTERN = "%20s: %d\n".freeze
+ PATTERN = "%20s: %d\n"
def display
$stdout.puts "=== Resolver Statistics ==="
@@ -43,5 +42,4 @@ class Gem::Resolver::Stats
$stdout.printf PATTERN, "Backtracking #", @backtracking
$stdout.printf PATTERN, "Iteration #", @iterations
end
-
end
diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb
index 7e2e917d5c..f30ce534af 100644
--- a/lib/rubygems/resolver/vendor_set.rb
+++ b/lib/rubygems/resolver/vendor_set.rb
@@ -32,7 +32,7 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
# Adds a specification to the set with the given +name+ which has been
# unpacked into the given +directory+.
- def add_vendor_gem(name, directory) # :nodoc:
+ def add_vendor_gem name, directory # :nodoc:
gemspec = File.join directory, "#{name}.gemspec"
spec = Gem::Specification.load gemspec
@@ -52,7 +52,7 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
# Returns an Array of VendorSpecification objects matching the
# DependencyRequest +req+.
- def find_all(req)
+ def find_all req
@specs.values.select do |spec|
req.match? spec
end.map do |spec|
@@ -65,11 +65,11 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
# Loads a spec with the given +name+. +version+, +platform+ and +source+ are
# ignored.
- def load_spec(name, version, platform, source) # :nodoc:
+ def load_spec name, version, platform, source # :nodoc:
@specs.fetch name
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[VendorSet', ']' do
next if @directories.empty?
q.breakable
@@ -85,3 +85,4 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
end
end
+
diff --git a/lib/rubygems/resolver/vendor_specification.rb b/lib/rubygems/resolver/vendor_specification.rb
index 56f2e6eb2c..c624f3e834 100644
--- a/lib/rubygems/resolver/vendor_specification.rb
+++ b/lib/rubygems/resolver/vendor_specification.rb
@@ -6,7 +6,7 @@
class Gem::Resolver::VendorSpecification < Gem::Resolver::SpecSpecification
- def ==(other) # :nodoc:
+ def == other # :nodoc:
self.class === other and
@set == other.set and
@spec == other.spec and
@@ -17,8 +17,9 @@ class Gem::Resolver::VendorSpecification < Gem::Resolver::SpecSpecification
# This is a null install as this gem was unpacked into a directory.
# +options+ are ignored.
- def install(options = {})
+ def install options = {}
yield nil
end
end
+
diff --git a/lib/rubygems/s3_uri_signer.rb b/lib/rubygems/s3_uri_signer.rb
deleted file mode 100644
index 534b8676a0..0000000000
--- a/lib/rubygems/s3_uri_signer.rb
+++ /dev/null
@@ -1,183 +0,0 @@
-require 'base64'
-require 'digest'
-require 'openssl'
-
-##
-# S3URISigner implements AWS SigV4 for S3 Source to avoid a dependency on the aws-sdk-* gems
-# More on AWS SigV4: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
-class Gem::S3URISigner
-
- class ConfigurationError < Gem::Exception
-
- def initialize(message)
- super message
- end
-
- def to_s # :nodoc:
- "#{super}"
- end
-
- end
-
- class InstanceProfileError < Gem::Exception
-
- def initialize(message)
- super message
- end
-
- def to_s # :nodoc:
- "#{super}"
- end
-
- end
-
- attr_accessor :uri
-
- def initialize(uri)
- @uri = uri
- end
-
- ##
- # Signs S3 URI using query-params according to the reference: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
- def sign(expiration = 86400)
- s3_config = fetch_s3_config
-
- current_time = Time.now.utc
- date_time = current_time.strftime("%Y%m%dT%H%m%SZ")
- date = date_time[0,8]
-
- credential_info = "#{date}/#{s3_config.region}/s3/aws4_request"
- canonical_host = "#{uri.host}.s3.#{s3_config.region}.amazonaws.com"
-
- query_params = generate_canonical_query_params(s3_config, date_time, credential_info, expiration)
- canonical_request = generate_canonical_request(canonical_host, query_params)
- string_to_sign = generate_string_to_sign(date_time, credential_info, canonical_request)
- signature = generate_signature(s3_config, date, string_to_sign)
-
- URI.parse("https://#{canonical_host}#{uri.path}?#{query_params}&X-Amz-Signature=#{signature}")
- end
-
- private
-
- S3Config = Struct.new :access_key_id, :secret_access_key, :security_token, :region
-
- def generate_canonical_query_params(s3_config, date_time, credential_info, expiration)
- canonical_params = {}
- canonical_params["X-Amz-Algorithm"] = "AWS4-HMAC-SHA256"
- canonical_params["X-Amz-Credential"] = "#{s3_config.access_key_id}/#{credential_info}"
- canonical_params["X-Amz-Date"] = date_time
- canonical_params["X-Amz-Expires"] = expiration.to_s
- canonical_params["X-Amz-SignedHeaders"] = "host"
- canonical_params["X-Amz-Security-Token"] = s3_config.security_token if s3_config.security_token
-
- # Sorting is required to generate proper signature
- canonical_params.sort.to_h.map do |key, value|
- "#{base64_uri_escape(key)}=#{base64_uri_escape(value)}"
- end.join("&")
- end
-
- def generate_canonical_request(canonical_host, query_params)
- [
- "GET",
- uri.path,
- query_params,
- "host:#{canonical_host}",
- "", # empty params
- "host",
- "UNSIGNED-PAYLOAD",
- ].join("\n")
- end
-
- def generate_string_to_sign(date_time, credential_info, canonical_request)
- [
- "AWS4-HMAC-SHA256",
- date_time,
- credential_info,
- Digest::SHA256.hexdigest(canonical_request)
- ].join("\n")
- end
-
- def generate_signature(s3_config, date, string_to_sign)
- date_key = OpenSSL::HMAC.digest("sha256", "AWS4" + s3_config.secret_access_key, date)
- date_region_key = OpenSSL::HMAC.digest("sha256", date_key, s3_config.region)
- date_region_service_key = OpenSSL::HMAC.digest("sha256", date_region_key, "s3")
- signing_key = OpenSSL::HMAC.digest("sha256", date_region_service_key, "aws4_request")
- OpenSSL::HMAC.hexdigest("sha256", signing_key, string_to_sign)
- end
-
- ##
- # Extracts S3 configuration for S3 bucket
- def fetch_s3_config
- return S3Config.new(uri.user, uri.password, nil, "us-east-1") if uri.user && uri.password
-
- s3_source = Gem.configuration[:s3_source] || Gem.configuration["s3_source"]
- host = uri.host
- raise ConfigurationError.new("no s3_source key exists in .gemrc") unless s3_source
-
- auth = s3_source[host] || s3_source[host.to_sym]
- raise ConfigurationError.new("no key for host #{host} in s3_source in .gemrc") unless auth
-
- provider = auth[:provider] || auth["provider"]
- case provider
- when "env"
- id = ENV["AWS_ACCESS_KEY_ID"]
- secret = ENV["AWS_SECRET_ACCESS_KEY"]
- security_token = ENV["AWS_SESSION_TOKEN"]
- when "instance_profile"
- credentials = ec2_metadata_credentials_json
- id = credentials["AccessKeyId"]
- secret = credentials["SecretAccessKey"]
- security_token = credentials["Token"]
- else
- id = auth[:id] || auth["id"]
- secret = auth[:secret] || auth["secret"]
- security_token = auth[:security_token] || auth["security_token"]
- end
-
- raise ConfigurationError.new("s3_source for #{host} missing id or secret") unless id && secret
-
- region = auth[:region] || auth["region"] || "us-east-1"
- S3Config.new(id, secret, security_token, region)
- end
-
- def base64_uri_escape(str)
- str.gsub(/[\+\/=\n]/, BASE64_URI_TRANSLATE)
- end
-
- def ec2_metadata_credentials_json
- require 'net/http'
- require 'rubygems/request'
- require 'rubygems/request/connection_pools'
- require 'json'
-
- iam_info = ec2_metadata_request(EC2_IAM_INFO)
- # Expected format: arn:aws:iam::<id>:instance-profile/<role_name>
- role_name = iam_info['InstanceProfileArn'].split('/').last
- ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name)
- end
-
- def ec2_metadata_request(url)
- uri = URI(url)
- @request_pool ||= create_request_pool(uri)
- request = Gem::Request.new(uri, Net::HTTP::Get, nil, @request_pool)
- response = request.fetch
-
- case response
- when Net::HTTPOK then
- JSON.parse(response.body)
- else
- raise InstanceProfileError.new("Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}")
- end
- end
-
- def create_request_pool(uri)
- proxy_uri = Gem::Request.proxy_uri(Gem::Request.get_proxy_from_env(uri.scheme))
- certs = Gem::Request.get_cert_files
- Gem::Request::ConnectionPools.new(proxy_uri, certs).pool_for(uri)
- end
-
- BASE64_URI_TRANSLATE = { "+" => "%2B", "/" => "%2F", "=" => "%3D", "\n" => "" }.freeze
- EC2_IAM_INFO = "http://169.254.169.254/latest/meta-data/iam/info".freeze
- EC2_IAM_SECURITY_CREDENTIALS = "http://169.254.169.254/latest/meta-data/iam/security-credentials/".freeze
-
-end
diff --git a/lib/rubygems/safe_yaml.rb b/lib/rubygems/safe_yaml.rb
index 3540fd74dd..789bb5e25a 100644
--- a/lib/rubygems/safe_yaml.rb
+++ b/lib/rubygems/safe_yaml.rb
@@ -7,7 +7,7 @@ module Gem
# Psych.safe_load
module SafeYAML
- PERMITTED_CLASSES = %w(
+ WHITELISTED_CLASSES = %w(
Symbol
Time
Date
@@ -19,39 +19,31 @@ module Gem
Gem::Version::Requirement
YAML::Syck::DefaultKey
Syck::DefaultKey
- ).freeze
+ )
- PERMITTED_SYMBOLS = %w(
+ WHITELISTED_SYMBOLS = %w(
development
runtime
- ).freeze
+ )
if ::YAML.respond_to? :safe_load
- def self.safe_load(input)
- if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
- ::YAML.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true)
- else
- ::YAML.safe_load(input, PERMITTED_CLASSES, PERMITTED_SYMBOLS, true)
- end
+ def self.safe_load input
+ ::YAML.safe_load(input, WHITELISTED_CLASSES, WHITELISTED_SYMBOLS, true)
end
- def self.load(input)
- if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
- ::YAML.safe_load(input, permitted_classes: [::Symbol])
- else
- ::YAML.safe_load(input, [::Symbol])
- end
+ def self.load input
+ ::YAML.safe_load(input, [::Symbol])
end
else
unless Gem::Deprecate.skip
warn "YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0)."
end
- def self.safe_load(input, *args)
+ def self.safe_load input, *args
::YAML.load input
end
- def self.load(input)
+ def self.load input
::YAML.load input
end
end
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index 7b0a0b3c6a..236577c5a3 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -340,30 +340,25 @@ module Gem::Security
# Digest algorithm used to sign gems
DIGEST_ALGORITHM =
- if defined?(OpenSSL::Digest::SHA256)
+ if defined?(OpenSSL::Digest::SHA256) then
OpenSSL::Digest::SHA256
- elsif defined?(OpenSSL::Digest::SHA1)
+ elsif defined?(OpenSSL::Digest::SHA1) then
OpenSSL::Digest::SHA1
- else
- require 'digest'
- Digest::SHA512
end
##
# Used internally to select the signing digest from all computed digests
DIGEST_NAME = # :nodoc:
- if DIGEST_ALGORITHM.method_defined? :name
+ if DIGEST_ALGORITHM then
DIGEST_ALGORITHM.new.name
- else
- DIGEST_ALGORITHM.name[/::([^:]+)\z/, 1]
end
##
# Algorithm for creating the key pair used to sign gems
KEY_ALGORITHM =
- if defined?(OpenSSL::PKey::RSA)
+ if defined?(OpenSSL::PKey::RSA) then
OpenSSL::PKey::RSA
end
@@ -401,9 +396,9 @@ module Gem::Security
'keyUsage' =>
'keyEncipherment,dataEncipherment,digitalSignature',
'subjectKeyIdentifier' => 'hash',
- }.freeze
+ }
- def self.alt_name_or_x509_entry(certificate, x509_entry)
+ def self.alt_name_or_x509_entry certificate, x509_entry
alt_name = certificate.extensions.find do |extension|
extension.oid == "#{x509_entry}AltName"
end
@@ -419,8 +414,8 @@ module Gem::Security
#
# The +extensions+ restrict the key to the indicated uses.
- def self.create_cert(subject, key, age = ONE_YEAR, extensions = EXTENSIONS,
- serial = 1)
+ def self.create_cert subject, key, age = ONE_YEAR, extensions = EXTENSIONS,
+ serial = 1
cert = OpenSSL::X509::Certificate.new
cert.public_key = key.public_key
@@ -446,7 +441,7 @@ module Gem::Security
# a subject alternative name of +email+ and the given +extensions+ for the
# +key+.
- def self.create_cert_email(email, key, age = ONE_YEAR, extensions = EXTENSIONS)
+ def self.create_cert_email email, key, age = ONE_YEAR, extensions = EXTENSIONS
subject = email_to_name email
extensions = extensions.merge "subjectAltName" => "email:#{email}"
@@ -458,8 +453,8 @@ module Gem::Security
# Creates a self-signed certificate with an issuer and subject of +subject+
# and the given +extensions+ for the +key+.
- def self.create_cert_self_signed(subject, key, age = ONE_YEAR,
- extensions = EXTENSIONS, serial = 1)
+ def self.create_cert_self_signed subject, key, age = ONE_YEAR,
+ extensions = EXTENSIONS, serial = 1
certificate = create_cert subject, key, age, extensions
sign certificate, key, certificate, age, extensions, serial
@@ -469,14 +464,14 @@ module Gem::Security
# Creates a new key pair of the specified +length+ and +algorithm+. The
# default is a 3072 bit RSA key.
- def self.create_key(length = KEY_LENGTH, algorithm = KEY_ALGORITHM)
+ def self.create_key length = KEY_LENGTH, algorithm = KEY_ALGORITHM
algorithm.new length
end
##
# Turns +email_address+ into an OpenSSL::X509::Name
- def self.email_to_name(email_address)
+ def self.email_to_name email_address
email_address = email_address.gsub(/[^\w@.-]+/i, '_')
cn, dcs = email_address.split '@'
@@ -494,15 +489,15 @@ module Gem::Security
#--
# TODO increment serial
- def self.re_sign(expired_certificate, private_key, age = ONE_YEAR,
- extensions = EXTENSIONS)
+ def self.re_sign expired_certificate, private_key, age = ONE_YEAR,
+ extensions = EXTENSIONS
raise Gem::Security::Exception,
"incorrect signing key for re-signing " +
"#{expired_certificate.subject}" unless
expired_certificate.public_key.to_pem == private_key.public_key.to_pem
unless expired_certificate.subject.to_s ==
- expired_certificate.issuer.to_s
+ expired_certificate.issuer.to_s then
subject = alt_name_or_x509_entry expired_certificate, :subject
issuer = alt_name_or_x509_entry expired_certificate, :issuer
@@ -531,8 +526,8 @@ module Gem::Security
#
# Returns the newly signed certificate.
- def self.sign(certificate, signing_key, signing_cert,
- age = ONE_YEAR, extensions = EXTENSIONS, serial = 1)
+ def self.sign certificate, signing_key, signing_cert,
+ age = ONE_YEAR, extensions = EXTENSIONS, serial = 1
signee_subject = certificate.subject
signee_key = certificate.public_key
@@ -571,7 +566,7 @@ module Gem::Security
##
# Enumerates the trusted certificates via Gem::Security::TrustDir.
- def self.trusted_certificates(&block)
+ def self.trusted_certificates &block
trust_dir.each_certificate(&block)
end
@@ -580,7 +575,7 @@ module Gem::Security
# +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
# passed to +to_pem+.
- def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER)
+ def self.write pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER
path = File.expand_path path
File.open path, 'wb', permissions do |io|
@@ -598,10 +593,11 @@ module Gem::Security
end
-if defined?(OpenSSL::SSL)
+if defined?(OpenSSL::SSL) then
require 'rubygems/security/policy'
require 'rubygems/security/policies'
require 'rubygems/security/trust_dir'
end
require 'rubygems/security/signer'
+
diff --git a/lib/rubygems/security/policies.rb b/lib/rubygems/security/policies.rb
index 8f6ad99316..f16c46306a 100644
--- a/lib/rubygems/security/policies.rb
+++ b/lib/rubygems/security/policies.rb
@@ -110,6 +110,7 @@ module Gem::Security
'MediumSecurity' => MediumSecurity,
'HighSecurity' => HighSecurity,
# SigningPolicy is not intended for use by `gem -P` so do not list it
- }.freeze
+ }
end
+
diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb
index 1aa6eab18c..f43e6c8c96 100644
--- a/lib/rubygems/security/policy.rb
+++ b/lib/rubygems/security/policy.rb
@@ -24,7 +24,7 @@ class Gem::Security::Policy
# Create a new Gem::Security::Policy object with the given mode and
# options.
- def initialize(name, policy = {}, opt = {})
+ def initialize name, policy = {}, opt = {}
require 'openssl'
@name = name
@@ -55,7 +55,7 @@ class Gem::Security::Policy
# Verifies each certificate in +chain+ has signed the following certificate
# and is valid for the given +time+.
- def check_chain(chain, time)
+ def check_chain chain, time
raise Gem::Security::Exception, 'missing signing chain' unless chain
raise Gem::Security::Exception, 'empty signing chain' if chain.empty?
@@ -74,7 +74,7 @@ class Gem::Security::Policy
# Verifies that +data+ matches the +signature+ created by +public_key+ and
# the +digest+ algorithm.
- def check_data(public_key, digest, signature, data)
+ def check_data public_key, digest, signature, data
raise Gem::Security::Exception, "invalid signature" unless
public_key.verify digest.new, signature, data.digest
@@ -85,22 +85,22 @@ class Gem::Security::Policy
# Ensures that +signer+ is valid for +time+ and was signed by the +issuer+.
# If the +issuer+ is +nil+ no verification is performed.
- def check_cert(signer, issuer, time)
+ def check_cert signer, issuer, time
raise Gem::Security::Exception, 'missing signing certificate' unless
signer
message = "certificate #{signer.subject}"
- if not_before = signer.not_before and not_before > time
+ if not_before = signer.not_before and not_before > time then
raise Gem::Security::Exception,
"#{message} not valid before #{not_before}"
end
- if not_after = signer.not_after and not_after < time
+ if not_after = signer.not_after and not_after < time then
raise Gem::Security::Exception, "#{message} not valid after #{not_after}"
end
- if issuer and not signer.verify issuer.public_key
+ if issuer and not signer.verify issuer.public_key then
raise Gem::Security::Exception,
"#{message} was not issued by #{issuer.subject}"
end
@@ -111,8 +111,8 @@ class Gem::Security::Policy
##
# Ensures the public key of +key+ matches the public key in +signer+
- def check_key(signer, key)
- unless signer and key
+ def check_key signer, key
+ unless signer and key then
return true unless @only_signed
raise Gem::Security::Exception, 'missing key or signature'
@@ -129,7 +129,7 @@ class Gem::Security::Policy
# Ensures the root certificate in +chain+ is self-signed and valid for
# +time+.
- def check_root(chain, time)
+ def check_root chain, time
raise Gem::Security::Exception, 'missing signing chain' unless chain
root = chain.first
@@ -148,7 +148,7 @@ class Gem::Security::Policy
# Ensures the root of +chain+ has a trusted certificate in +trust_dir+ and
# the digests of the two certificates match according to +digester+
- def check_trust(chain, digester, trust_dir)
+ def check_trust chain, digester, trust_dir
raise Gem::Security::Exception, 'missing signing chain' unless chain
root = chain.first
@@ -157,7 +157,7 @@ class Gem::Security::Policy
path = Gem::Security.trust_dir.cert_path root
- unless File.exist? path
+ unless File.exist? path then
message = "root cert #{root.subject} is not trusted".dup
message << " (root of signing cert #{chain.last.subject})" if
@@ -183,7 +183,7 @@ class Gem::Security::Policy
##
# Extracts the email or subject from +certificate+
- def subject(certificate) # :nodoc:
+ def subject certificate # :nodoc:
certificate.extensions.each do |extension|
next unless extension.oid == 'subjectAltName'
@@ -196,9 +196,9 @@ class Gem::Security::Policy
def inspect # :nodoc:
("[Policy: %s - data: %p signer: %p chain: %p root: %p " +
"signed-only: %p trusted-only: %p]") % [
- @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
- @only_signed, @only_trusted,
- ]
+ @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
+ @only_signed, @only_trusted,
+ ]
end
##
@@ -208,13 +208,13 @@ class Gem::Security::Policy
#
# If +key+ is given it is used to validate the signing certificate.
- def verify(chain, key = nil, digests = {}, signatures = {},
- full_name = '(unknown)')
- if signatures.empty?
- if @only_signed
+ def verify chain, key = nil, digests = {}, signatures = {},
+ full_name = '(unknown)'
+ if signatures.empty? then
+ if @only_signed then
raise Gem::Security::Exception,
"unsigned gems are not allowed by the #{name} policy"
- elsif digests.empty?
+ elsif digests.empty? then
# lack of signatures is irrelevant if there is nothing to check
# against
else
@@ -232,7 +232,7 @@ class Gem::Security::Policy
file_digests.values.first.name == Gem::Security::DIGEST_NAME
end
- if @verify_data
+ if @verify_data then
raise Gem::Security::Exception, 'no digests provided (probable bug)' if
signer_digests.nil? or signer_digests.empty?
else
@@ -249,9 +249,9 @@ class Gem::Security::Policy
check_root chain, time if @verify_root
- if @only_trusted
+ if @only_trusted then
check_trust chain, digester, trust_dir
- elsif signatures.empty? and digests.empty?
+ elsif signatures.empty? and digests.empty? then
# trust is irrelevant if there's no signatures to verify
else
alert_warning "#{subject signer} is not trusted for #{full_name}"
@@ -280,7 +280,7 @@ class Gem::Security::Policy
# Extracts the certificate chain from the +spec+ and calls #verify to ensure
# the signatures and certificate chain is valid according to the policy..
- def verify_signatures(spec, digests, signatures)
+ def verify_signatures spec, digests, signatures
chain = spec.cert_chain.map do |cert_pem|
OpenSSL::X509::Certificate.new cert_pem
end
diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb
index 5e4ba6ebba..0c6ef60a9a 100644
--- a/lib/rubygems/security/signer.rb
+++ b/lib/rubygems/security/signer.rb
@@ -2,12 +2,8 @@
##
# Basic OpenSSL-based package signing class.
-require "rubygems/user_interaction"
-
class Gem::Security::Signer
- include Gem::UserInteraction
-
##
# The chain of certificates for signing including the signing certificate
@@ -30,53 +26,20 @@ class Gem::Security::Signer
attr_reader :digest_name # :nodoc:
##
- # Gem::Security::Signer options
-
- attr_reader :options
-
- DEFAULT_OPTIONS = {
- expiration_length_days: 365
- }.freeze
-
- ##
- # Attemps to re-sign an expired cert with a given private key
- def self.re_sign_cert(expired_cert, expired_cert_path, private_key)
- return unless expired_cert.not_after < Time.now
-
- expiry = expired_cert.not_after.strftime('%Y%m%d%H%M%S')
- expired_cert_file = "#{File.basename(expired_cert_path)}.expired.#{expiry}"
- new_expired_cert_path = File.join(Gem.user_home, ".gem", expired_cert_file)
-
- Gem::Security.write(expired_cert, new_expired_cert_path)
-
- re_signed_cert = Gem::Security.re_sign(
- expired_cert,
- private_key,
- (Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days)
- )
-
- Gem::Security.write(re_signed_cert, expired_cert_path)
-
- yield(expired_cert_path, new_expired_cert_path) if block_given?
- end
-
- ##
# Creates a new signer with an RSA +key+ or path to a key, and a certificate
# +chain+ containing X509 certificates, encoding certificates or paths to
# certificates.
- def initialize(key, cert_chain, passphrase = nil, options = {})
+ def initialize key, cert_chain, passphrase = nil
@cert_chain = cert_chain
@key = key
- @passphrase = passphrase
- @options = DEFAULT_OPTIONS.merge(options)
- unless @key
- default_key = File.join Gem.default_key_path
+ unless @key then
+ default_key = File.join Gem.default_key_path
@key = default_key if File.exist? default_key
end
- unless @cert_chain
+ unless @cert_chain then
default_cert = File.join Gem.default_cert_path
@cert_chain = [default_cert] if File.exist? default_cert
end
@@ -84,11 +47,10 @@ class Gem::Security::Signer
@digest_algorithm = Gem::Security::DIGEST_ALGORITHM
@digest_name = Gem::Security::DIGEST_NAME
- if @key && !@key.is_a?(OpenSSL::PKey::RSA)
- @key = OpenSSL::PKey::RSA.new(File.read(@key), @passphrase)
- end
+ @key = OpenSSL::PKey::RSA.new File.read(@key), passphrase if
+ @key and not OpenSSL::PKey::RSA === @key
- if @cert_chain
+ if @cert_chain then
@cert_chain = @cert_chain.compact.map do |cert|
next cert if OpenSSL::X509::Certificate === cert
@@ -105,10 +67,10 @@ class Gem::Security::Signer
# Extracts the full name of +cert+. If the certificate has a subjectAltName
# this value is preferred, otherwise the subject is used.
- def extract_name(cert) # :nodoc:
+ def extract_name cert # :nodoc:
subject_alt_name = cert.extensions.find { |e| 'subjectAltName' == e.oid }
- if subject_alt_name
+ if subject_alt_name then
/\Aemail:/ =~ subject_alt_name.value
$' || subject_alt_name.value
@@ -137,17 +99,13 @@ class Gem::Security::Signer
##
# Sign data with given digest algorithm
- def sign(data)
+ def sign data
return unless @key
raise Gem::Security::Exception, 'no certs provided' if @cert_chain.empty?
- if @cert_chain.length == 1 and @cert_chain.last.not_after < Time.now
- alert("Your certificate has expired, trying to re-sign it...")
-
- re_sign_key(
- expiration_length: (Gem::Security::ONE_DAY * options[:expiration_length_days])
- )
+ if @cert_chain.length == 1 and @cert_chain.last.not_after < Time.now then
+ re_sign_key
end
full_name = extract_name @cert_chain.last
@@ -163,7 +121,6 @@ class Gem::Security::Signer
# The key will be re-signed if:
# * The expired certificate is self-signed
# * The expired certificate is saved at ~/.gem/gem-public_cert.pem
- # and the private key is saved at ~/.gem/gem-private_key.pem
# * There is no file matching the expiry date at
# ~/.gem/gem-public_cert.pem.expired.%Y%m%d%H%M%S
#
@@ -171,32 +128,25 @@ class Gem::Security::Signer
# be saved as ~/.gem/gem-public_cert.pem.expired.%Y%m%d%H%M%S where the
# expiry time (not after) is used for the timestamp.
- def re_sign_key(expiration_length: Gem::Security::ONE_YEAR) # :nodoc:
+ def re_sign_key # :nodoc:
old_cert = @cert_chain.last
- disk_cert_path = File.join(Gem.default_cert_path)
- disk_cert = File.read(disk_cert_path) rescue nil
-
- disk_key_path = File.join(Gem.default_key_path)
- disk_key =
- OpenSSL::PKey::RSA.new(File.read(disk_key_path), @passphrase) rescue nil
-
- return unless disk_key
+ disk_cert_path = File.join Gem.default_cert_path
+ disk_cert = File.read disk_cert_path rescue nil
+ disk_key =
+ File.read File.join(Gem.default_key_path) rescue nil
- if disk_key.to_pem == @key.to_pem && disk_cert == old_cert.to_pem
- expiry = old_cert.not_after.strftime('%Y%m%d%H%M%S')
+ if disk_key == @key.to_pem and disk_cert == old_cert.to_pem then
+ expiry = old_cert.not_after.strftime '%Y%m%d%H%M%S'
old_cert_file = "gem-public_cert.pem.expired.#{expiry}"
- old_cert_path = File.join(Gem.user_home, ".gem", old_cert_file)
+ old_cert_path = File.join Gem.user_home, ".gem", old_cert_file
- unless File.exist?(old_cert_path)
- Gem::Security.write(old_cert, old_cert_path)
+ unless File.exist? old_cert_path then
+ Gem::Security.write old_cert, old_cert_path
- cert = Gem::Security.re_sign(old_cert, @key, expiration_length)
+ cert = Gem::Security.re_sign old_cert, @key
- Gem::Security.write(cert, disk_cert_path)
-
- alert("Your cert: #{disk_cert_path} has been auto re-signed with the key: #{disk_key_path}")
- alert("Your expired cert will be located at: #{old_cert_path}")
+ Gem::Security.write cert, disk_cert_path
@cert_chain = [cert]
end
@@ -204,3 +154,4 @@ class Gem::Security::Signer
end
end
+
diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb
index 98031ea22b..849cf3cd3e 100644
--- a/lib/rubygems/security/trust_dir.rb
+++ b/lib/rubygems/security/trust_dir.rb
@@ -11,7 +11,7 @@ class Gem::Security::TrustDir
DEFAULT_PERMISSIONS = {
:trust_dir => 0700,
:trusted_cert => 0600,
- }.freeze
+ }
##
# The directory where trusted certificates will be stored.
@@ -22,7 +22,7 @@ class Gem::Security::TrustDir
# Creates a new TrustDir using +dir+ where the directory and file
# permissions will be checked according to +permissions+
- def initialize(dir, permissions = DEFAULT_PERMISSIONS)
+ def initialize dir, permissions = DEFAULT_PERMISSIONS
@dir = dir
@permissions = permissions
@@ -32,7 +32,7 @@ class Gem::Security::TrustDir
##
# Returns the path to the trusted +certificate+
- def cert_path(certificate)
+ def cert_path certificate
name_path certificate.subject
end
@@ -59,7 +59,7 @@ class Gem::Security::TrustDir
# Returns the issuer certificate of the given +certificate+ if it exists in
# the trust directory.
- def issuer_of(certificate)
+ def issuer_of certificate
path = name_path certificate.issuer
return unless File.exist? path
@@ -70,7 +70,7 @@ class Gem::Security::TrustDir
##
# Returns the path to the trusted certificate with the given ASN.1 +name+
- def name_path(name)
+ def name_path name
digest = @digester.hexdigest name.to_s
File.join @dir, "cert-#{digest}.pem"
@@ -79,7 +79,7 @@ class Gem::Security::TrustDir
##
# Loads the given +certificate_file+
- def load_certificate(certificate_file)
+ def load_certificate certificate_file
pem = File.read certificate_file
OpenSSL::X509::Certificate.new pem
@@ -88,14 +88,13 @@ class Gem::Security::TrustDir
##
# Add a certificate to trusted certificate list.
- def trust_cert(certificate)
+ def trust_cert certificate
verify
destination = cert_path certificate
- File.open destination, 'wb', 0600 do |io|
+ File.open destination, 'wb', @permissions[:trusted_cert] do |io|
io.write certificate.to_pem
- io.chmod(@permissions[:trusted_cert])
end
end
@@ -105,7 +104,7 @@ class Gem::Security::TrustDir
# permissions.
def verify
- if File.exist? @dir
+ if File.exist? @dir then
raise Gem::Security::Exception,
"trust directory #{@dir} is not a directory" unless
File.directory? @dir
@@ -117,3 +116,4 @@ class Gem::Security::TrustDir
end
end
+
diff --git a/lib/rubygems/security_option.rb b/lib/rubygems/security_option.rb
index 3403aaaf05..4e3473acb4 100644
--- a/lib/rubygems/security_option.rb
+++ b/lib/rubygems/security_option.rb
@@ -19,6 +19,7 @@ end
module Gem::SecurityOption
def add_security_option
+ # TODO: use @parser.accept
OptionParser.accept Gem::Security::Policy do |value|
require 'rubygems/security'
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
index 83d7cf5abc..62c3dfe9cf 100644
--- a/lib/rubygems/server.rb
+++ b/lib/rubygems/server.rb
@@ -35,7 +35,7 @@ class Gem::Server
include ERB::Util
include Gem::UserInteraction
- SEARCH = <<-ERB.freeze
+ SEARCH = <<-ERB
<form class="headerSearch" name="headerSearchForm" method="get" action="/rdoc">
<div id="search" style="float:right">
<label for="q">Filter/Search</label>
@@ -45,7 +45,7 @@ class Gem::Server
</form>
ERB
- DOC_TEMPLATE = <<-'ERB'.freeze
+ DOC_TEMPLATE = <<-'ERB'
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -129,7 +129,7 @@ class Gem::Server
ERB
# CSS is copy & paste from rdoc-style.css, RDoc V1.0.1 - 20041108
- RDOC_CSS = <<-CSS.freeze
+ RDOC_CSS = <<-CSS
body {
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 90%;
@@ -339,7 +339,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
.ruby-value { color: #7fffd4; background: transparent; }
CSS
- RDOC_NO_DOCUMENTATION = <<-'ERB'.freeze
+ RDOC_NO_DOCUMENTATION = <<-'ERB'
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -373,7 +373,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
</html>
ERB
- RDOC_SEARCH_TEMPLATE = <<-'ERB'.freeze
+ RDOC_SEARCH_TEMPLATE = <<-'ERB'
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -450,7 +450,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
@have_rdoc_4_plus = nil
end
- def add_date(res)
+ def add_date res
res['date'] = @spec_dirs.map do |spec_dir|
File.stat(spec_dir).mtime
end.max
@@ -462,8 +462,8 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end
end
- def doc_root(gem_name)
- if have_rdoc_4_plus?
+ def doc_root gem_name
+ if have_rdoc_4_plus? then
"/doc_root/#{u gem_name}/"
else
"/doc_root/#{u gem_name}/rdoc/index.html"
@@ -491,14 +491,14 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs = Marshal.dump specs
- if req.path =~ /\.gz$/
- specs = Gem::Util.gzip specs
+ if req.path =~ /\.gz$/ then
+ specs = Gem.gzip specs
res['content-type'] = 'application/x-gzip'
else
res['content-type'] = 'application/octet-stream'
end
- if req.request_method == 'HEAD'
+ if req.request_method == 'HEAD' then
res['content-length'] = specs.length
else
res.body << specs
@@ -509,7 +509,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
# Creates server sockets based on the addresses option. If no addresses
# were given a server socket for all interfaces is created.
- def listen(addresses = @addresses)
+ def listen addresses = @addresses
addresses = [nil] unless addresses
listeners = 0
@@ -529,14 +529,14 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end
end
- if @server.listeners.empty?
+ if @server.listeners.empty? then
say "Unable to start a server."
say "Check for running servers or your --bind and --port arguments"
terminate_interaction 1
end
end
- def prerelease_specs(req, res)
+ def prerelease_specs req, res
reset_gems
res['content-type'] = 'application/x-gzip'
@@ -552,14 +552,14 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs = Marshal.dump specs
- if req.path =~ /\.gz$/
- specs = Gem::Util.gzip specs
+ if req.path =~ /\.gz$/ then
+ specs = Gem.gzip specs
res['content-type'] = 'application/x-gzip'
else
res['content-type'] = 'application/octet-stream'
end
- if req.request_method == 'HEAD'
+ if req.request_method == 'HEAD' then
res['content-length'] = specs.length
else
res.body << specs
@@ -579,13 +579,13 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
selector = full_name.inspect
- if specs.empty?
+ if specs.empty? then
res.status = 404
res.body = "No gems found matching #{selector}"
- elsif specs.length > 1
+ elsif specs.length > 1 then
res.status = 500
res.body = "Multiple gems found matching #{selector}"
- elsif marshal_format
+ elsif marshal_format then
res['content-type'] = 'application/x-deflate'
res.body << Gem.deflate(Marshal.dump(specs.first))
end
@@ -607,13 +607,13 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
Gem::Specification.each do |spec|
total_file_count += spec.files.size
- deps = spec.dependencies.map do |dep|
+ deps = spec.dependencies.map { |dep|
{
"name" => dep.name,
"type" => dep.type,
"version" => dep.requirement.to_s,
}
- end
+ }
deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }
deps.last["is_last"] = true unless deps.empty?
@@ -661,7 +661,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
"only_one_executable" => true,
"full_name" => "rubygems-#{Gem::VERSION}",
"has_deps" => false,
- "homepage" => "https://guides.rubygems.org/",
+ "homepage" => "http://guides.rubygems.org/",
"name" => 'rubygems',
"ri_installed" => true,
"summary" => "RubyGems itself",
@@ -754,9 +754,9 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
# documentation - just put it underneath the main doc folder.
def show_rdoc_for_pattern(pattern, res)
- found_gems = Dir.glob("{#{@gem_dirs.join ','}}/doc/#{pattern}").select do |path|
+ found_gems = Dir.glob("{#{@gem_dirs.join ','}}/doc/#{pattern}").select {|path|
File.exist? File.join(path, 'rdoc/index.html')
- end
+ }
case found_gems.length
when 0
return false
@@ -818,7 +818,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
'/gems' => '/cache/',
}
- if have_rdoc_4_plus?
+ if have_rdoc_4_plus? then
@server.mount '/doc_root', RDoc::Servlet, '/doc_root'
else
file_handlers['/doc_root'] = '/doc/'
@@ -851,14 +851,14 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs = Marshal.dump specs
- if req.path =~ /\.gz$/
- specs = Gem::Util.gzip specs
+ if req.path =~ /\.gz$/ then
+ specs = Gem.gzip specs
res['content-type'] = 'application/x-gzip'
else
res['content-type'] = 'application/octet-stream'
end
- if req.request_method == 'HEAD'
+ if req.request_method == 'HEAD' then
res['content-length'] = specs.length
else
res.body << specs
@@ -875,5 +875,4 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
system("#{@launch} http://#{host}:#{@port}")
end
-
end
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb
index 8572cb1806..b28b850660 100644
--- a/lib/rubygems/source.rb
+++ b/lib/rubygems/source.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
autoload :FileUtils, 'fileutils'
+autoload :URI, 'uri'
-require "rubygems/text"
##
# A Source knows how to list and fetch gems from a RubyGems marshal index.
#
@@ -11,13 +11,12 @@ require "rubygems/text"
class Gem::Source
include Comparable
- include Gem::Text
FILES = { # :nodoc:
:released => 'specs',
:latest => 'latest_specs',
:prerelease => 'prerelease_specs',
- }.freeze
+ }
##
# The URI this source will fetch gems from.
@@ -37,6 +36,15 @@ class Gem::Source
end
@uri = uri
+ @api_uri = nil
+ end
+
+ ##
+ # Use an SRV record on the host to look up the true endpoint for the index.
+
+ def api_uri # :nodoc:
+ require 'rubygems/remote_fetcher'
+ @api_uri ||= Gem::RemoteFetcher.fetcher.api_endpoint uri
end
##
@@ -69,7 +77,7 @@ class Gem::Source
end
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
self.class === other and @uri == other.uri
end
@@ -79,9 +87,9 @@ class Gem::Source
# Returns a Set that can fetch specifications from this source.
def dependency_resolver_set # :nodoc:
- return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme
+ return Gem::Resolver::IndexSet.new self if 'file' == api_uri.scheme
- bundler_api_uri = uri + './api/v1/dependencies'
+ bundler_api_uri = api_uri + './api/v1/dependencies'
begin
fetcher = Gem::RemoteFetcher.fetcher
@@ -89,7 +97,7 @@ class Gem::Source
rescue Gem::RemoteFetcher::FetchError
Gem::Resolver::IndexSet.new self
else
- if response.respond_to? :uri
+ if response.respond_to? :uri then
Gem::Resolver::APISet.new response.uri
else
Gem::Resolver::APISet.new bundler_api_uri
@@ -107,7 +115,7 @@ class Gem::Source
def cache_dir(uri)
# Correct for windows paths
escaped_path = uri.path.sub(/^\/([a-z]):\//i, '/\\1-/')
- escaped_path.tap(&Gem::UNTAINT)
+ escaped_path.untaint
File.join Gem.spec_cache_dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path)
end
@@ -127,29 +135,29 @@ class Gem::Source
##
# Fetches a specification for the given +name_tuple+.
- def fetch_spec(name_tuple)
+ def fetch_spec name_tuple
fetcher = Gem::RemoteFetcher.fetcher
spec_file_name = name_tuple.spec_name
- source_uri = uri + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
+ uri = api_uri + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
- cache_dir = cache_dir source_uri
+ cache_dir = cache_dir uri
local_spec = File.join cache_dir, spec_file_name
- if File.exist? local_spec
+ if File.exist? local_spec then
spec = Gem.read_binary local_spec
spec = Marshal.load(spec) rescue nil
return spec if spec
end
- source_uri.path << '.rz'
+ uri.path << '.rz'
- spec = fetcher.fetch_path source_uri
- spec = Gem::Util.inflate spec
+ spec = fetcher.fetch_path uri
+ spec = Gem.inflate spec
- if update_cache?
+ if update_cache? then
FileUtils.mkdir_p cache_dir
File.open local_spec, 'wb' do |io|
@@ -176,7 +184,7 @@ class Gem::Source
file = FILES[type]
fetcher = Gem::RemoteFetcher.fetcher
file_name = "#{file}.#{Gem.marshal_version}"
- spec_path = uri + "#{file_name}.gz"
+ spec_path = api_uri + "#{file_name}.gz"
cache_dir = cache_dir spec_path
local_file = File.join(cache_dir, file_name)
retried = false
@@ -204,15 +212,15 @@ class Gem::Source
def download(spec, dir=Dir.pwd)
fetcher = Gem::RemoteFetcher.fetcher
- fetcher.download spec, uri.to_s, dir
+ fetcher.download spec, api_uri.to_s, dir
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[Remote:', ']' do
q.breakable
q.text @uri.to_s
- if api = uri
+ if api = api_uri
q.breakable
q.text 'API URI: '
q.text api.to_s
@@ -220,11 +228,6 @@ class Gem::Source
end
end
- def typo_squatting?(host, distance_threshold=4)
- return if @uri.host.nil?
- levenshtein_distance(@uri.host, host) <= distance_threshold
- end
-
end
require 'rubygems/source/git'
diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb
index 0b8a4339cc..23f8928a4e 100644
--- a/lib/rubygems/source/git.rb
+++ b/lib/rubygems/source/git.rb
@@ -50,7 +50,7 @@ class Gem::Source::Git < Gem::Source
# repository may contain multiple gems. If +submodules+ is true, submodules
# will be checked out when the gem is installed.
- def initialize(name, repository, reference, submodules = false)
+ def initialize name, repository, reference, submodules = false
super repository
@name = name
@@ -63,7 +63,7 @@ class Gem::Source::Git < Gem::Source
@git = ENV['git'] || 'git'
end
- def <=>(other)
+ def <=> other
case other
when Gem::Source::Git then
0
@@ -77,7 +77,7 @@ class Gem::Source::Git < Gem::Source
end
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
super and
@name == other.name and
@repository == other.repository and
@@ -93,7 +93,7 @@ class Gem::Source::Git < Gem::Source
return false unless File.exist? repo_cache_dir
- unless File.exist? install_dir
+ unless File.exist? install_dir then
system @git, 'clone', '--quiet', '--no-checkout',
repo_cache_dir, install_dir
end
@@ -117,7 +117,7 @@ class Gem::Source::Git < Gem::Source
def cache # :nodoc:
return unless @remote
- if File.exist? repo_cache_dir
+ if File.exist? repo_cache_dir then
Dir.chdir repo_cache_dir do
system @git, 'fetch', '--quiet', '--force', '--tags',
@repository, 'refs/heads/*:refs/heads/*'
@@ -145,7 +145,7 @@ class Gem::Source::Git < Gem::Source
##
# Nothing to download for git gems
- def download(full_spec, path) # :nodoc:
+ def download full_spec, path # :nodoc:
end
##
@@ -157,7 +157,7 @@ class Gem::Source::Git < Gem::Source
File.join base_dir, 'gems', "#{@name}-#{dir_shortref}"
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[Git: ', ']' do
q.breakable
q.text @repository
@@ -206,7 +206,7 @@ class Gem::Source::Git < Gem::Source
Dir.chdir directory do
spec = Gem::Specification.load file
- if spec
+ if spec then
spec.base_dir = base_dir
spec.extension_dir =
@@ -228,7 +228,7 @@ class Gem::Source::Git < Gem::Source
require 'digest' # required here to avoid deadlocking in Gem.activate_bin_path (because digest is a gem on 2.5+)
normalized =
- if @repository =~ %r%^\w+://(\w+@)?%
+ if @repository =~ %r%^\w+://(\w+@)?% then
uri = URI(@repository).normalize.to_s.sub %r%/$%,''
uri.sub(/\A(\w+)/) { $1.downcase }
else
@@ -239,3 +239,4 @@ class Gem::Source::Git < Gem::Source
end
end
+
diff --git a/lib/rubygems/source/installed.rb b/lib/rubygems/source/installed.rb
index 8e20cbd76d..300491e467 100644
--- a/lib/rubygems/source/installed.rb
+++ b/lib/rubygems/source/installed.rb
@@ -11,7 +11,7 @@ class Gem::Source::Installed < Gem::Source
##
# Installed sources sort before all other sources
- def <=>(other)
+ def <=> other
case other
when Gem::Source::Git,
Gem::Source::Lock,
@@ -29,12 +29,13 @@ class Gem::Source::Installed < Gem::Source
##
# We don't need to download an installed gem
- def download(spec, path)
+ def download spec, path
nil
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.text '[Installed]'
end
end
+
diff --git a/lib/rubygems/source/local.rb b/lib/rubygems/source/local.rb
index 875e992d85..5ab7a467b5 100644
--- a/lib/rubygems/source/local.rb
+++ b/lib/rubygems/source/local.rb
@@ -15,7 +15,7 @@ class Gem::Source::Local < Gem::Source
##
# Local sorts before Gem::Source and after Gem::Source::Installed
- def <=>(other)
+ def <=> other
case other
when Gem::Source::Installed,
Gem::Source::Lock then
@@ -34,7 +34,7 @@ class Gem::Source::Local < Gem::Source
"#<%s specs: %p>" % [self.class, keys]
end
- def load_specs(type) # :nodoc:
+ def load_specs type # :nodoc:
@load_specs_names[type] ||= begin
names = []
@@ -78,8 +78,8 @@ class Gem::Source::Local < Gem::Source
end
end
- def find_gem(gem_name, version = Gem::Requirement.default, # :nodoc:
- prerelease = false)
+ def find_gem gem_name, version = Gem::Requirement.default, # :nodoc:
+ prerelease = false
load_specs :complete
found = []
@@ -101,7 +101,7 @@ class Gem::Source::Local < Gem::Source
found.max_by { |s| s.version }
end
- def fetch_spec(name) # :nodoc:
+ def fetch_spec name # :nodoc:
load_specs :complete
if data = @specs[name]
@@ -111,7 +111,7 @@ class Gem::Source::Local < Gem::Source
end
end
- def download(spec, cache_dir = nil) # :nodoc:
+ def download spec, cache_dir = nil # :nodoc:
load_specs :complete
@specs.each do |name, data|
@@ -121,7 +121,7 @@ class Gem::Source::Local < Gem::Source
raise Gem::Exception, "Unable to find file for '#{spec.full_name}'"
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[Local gems:', ']' do
q.breakable
q.seplist @specs.keys do |v|
diff --git a/lib/rubygems/source/lock.rb b/lib/rubygems/source/lock.rb
index 3b3f491750..59717be2c0 100644
--- a/lib/rubygems/source/lock.rb
+++ b/lib/rubygems/source/lock.rb
@@ -15,11 +15,11 @@ class Gem::Source::Lock < Gem::Source
# Creates a new Lock source that wraps +source+ and moves it earlier in the
# sort list.
- def initialize(source)
+ def initialize source
@wrapped = source
end
- def <=>(other) # :nodoc:
+ def <=> other # :nodoc:
case other
when Gem::Source::Lock then
@wrapped <=> other.wrapped
@@ -30,7 +30,7 @@ class Gem::Source::Lock < Gem::Source
end
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
0 == (self <=> other)
end
@@ -41,7 +41,7 @@ class Gem::Source::Lock < Gem::Source
##
# Delegates to the wrapped source's fetch_spec method.
- def fetch_spec(name_tuple)
+ def fetch_spec name_tuple
@wrapped.fetch_spec name_tuple
end
diff --git a/lib/rubygems/source/specific_file.rb b/lib/rubygems/source/specific_file.rb
index a22772b9c0..459c803e1a 100644
--- a/lib/rubygems/source/specific_file.rb
+++ b/lib/rubygems/source/specific_file.rb
@@ -27,22 +27,22 @@ class Gem::Source::SpecificFile < Gem::Source
attr_reader :spec
- def load_specs(*a) # :nodoc:
+ def load_specs *a # :nodoc:
[@name]
end
- def fetch_spec(name) # :nodoc:
+ def fetch_spec name # :nodoc:
return @spec if name == @name
raise Gem::Exception, "Unable to find '#{name}'"
@spec
end
- def download(spec, dir = nil) # :nodoc:
+ def download spec, dir = nil # :nodoc:
return @path if spec == @spec
raise Gem::Exception, "Unable to download '#{spec.full_name}'"
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[SpecificFile:', ']' do
q.breakable
q.text @path
@@ -59,7 +59,7 @@ class Gem::Source::SpecificFile < Gem::Source
#
# Otherwise Gem::Source#<=> is used.
- def <=>(other)
+ def <=> other
case other
when Gem::Source::SpecificFile then
return nil if @spec.name != other.spec.name
diff --git a/lib/rubygems/source/vendor.rb b/lib/rubygems/source/vendor.rb
index a87fa63331..e1b3698607 100644
--- a/lib/rubygems/source/vendor.rb
+++ b/lib/rubygems/source/vendor.rb
@@ -7,11 +7,11 @@ class Gem::Source::Vendor < Gem::Source::Installed
##
# Creates a new Vendor source for a gem that was unpacked at +path+.
- def initialize(path)
+ def initialize path
@uri = path
end
- def <=>(other)
+ def <=> other
case other
when Gem::Source::Lock then
-1
@@ -25,3 +25,4 @@ class Gem::Source::Vendor < Gem::Source::Installed
end
end
+
diff --git a/lib/rubygems/source_list.rb b/lib/rubygems/source_list.rb
index b1d1f2c362..66ce4d57ed 100644
--- a/lib/rubygems/source_list.rb
+++ b/lib/rubygems/source_list.rb
@@ -50,8 +50,6 @@ class Gem::SourceList
# String.
def <<(obj)
- require "uri"
-
src = case obj
when URI
Gem::Source.new(obj)
@@ -107,7 +105,7 @@ class Gem::SourceList
@sources.empty?
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
to_a == other
end
@@ -142,12 +140,11 @@ class Gem::SourceList
##
# Deletes +source+ from the source list which may be a Gem::Source or a URI.
- def delete(source)
+ def delete source
if source.kind_of? Gem::Source
@sources.delete source
else
@sources.delete_if { |x| x.uri.to_s == source.to_s }
end
end
-
end
diff --git a/lib/rubygems/source_local.rb b/lib/rubygems/source_local.rb
index 5107069fd0..9869158e7d 100644
--- a/lib/rubygems/source_local.rb
+++ b/lib/rubygems/source_local.rb
@@ -5,3 +5,4 @@ require 'rubygems/source_local'
unless Gem::Deprecate.skip
Kernel.warn "#{Gem.location_of_caller(3).join(':')}: Warning: Requiring rubygems/source_local is deprecated; please use rubygems/source/local instead."
end
+
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index cf86b72188..919276e113 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -54,7 +54,7 @@ class Gem::SpecFetcher
# If you need to retrieve specifications from a different +source+, you can
# send it as an argument.
- def initialize(sources = nil)
+ def initialize sources = nil
@sources = sources || Gem.sources
@update_cache =
@@ -88,8 +88,19 @@ class Gem::SpecFetcher
rejected_specs = {}
- list, errors = available_specs(dependency.identity)
+ if dependency.prerelease?
+ if dependency.specific?
+ type = :complete
+ else
+ type = :abs_latest
+ end
+ elsif dependency.latest_version?
+ type = :latest
+ else
+ type = :released
+ end
+ list, errors = available_specs(type)
list.each do |source, specs|
if dependency.name.is_a?(String) && specs.respond_to?(:bsearch)
start_index = (0 ... specs.length).bsearch{ |i| specs[i].name >= dependency.name }
@@ -127,6 +138,7 @@ class Gem::SpecFetcher
return [tuples, errors]
end
+
##
# Return all gem name tuples who's names match +obj+
@@ -145,6 +157,7 @@ class Gem::SpecFetcher
tuples
end
+
##
# Find and fetch specs that match +dependency+.
#
@@ -176,7 +189,7 @@ class Gem::SpecFetcher
max = gem_name.size / 2
names = available_specs(type).first.values.flatten(1)
- matches = names.map do |n|
+ matches = names.map { |n|
next unless n.match_platform?
distance = levenshtein_distance gem_name, n.name.downcase.tr('_-', '')
@@ -186,13 +199,13 @@ class Gem::SpecFetcher
return [n.name] if distance == 0
[n.name, distance]
- end.compact
+ }.compact
matches = if matches.empty? && type != :prerelease
- suggest_gems_from_name gem_name, :prerelease
- else
- matches.uniq.sort_by { |name, dist| dist }
- end
+ suggest_gems_from_name gem_name, :prerelease
+ else
+ matches.uniq.sort_by { |name, dist| dist }
+ end
matches.first(5).map { |name, dist| name }
end
@@ -258,3 +271,4 @@ class Gem::SpecFetcher
end
end
+
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index f925480f88..2560324b7a 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1,22 +1,24 @@
-# frozen_string_literal: true
# -*- coding: utf-8 -*-
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
+
require 'rubygems/version'
require 'rubygems/requirement'
require 'rubygems/platform'
require 'rubygems/deprecate'
require 'rubygems/basic_specification'
require 'rubygems/stub_specification'
-require 'rubygems/specification_policy'
require 'rubygems/util/list'
+require 'stringio'
+require 'uri'
##
-# The Specification class contains the information for a gem. Typically
+# The Specification class contains the information for a Gem. Typically
# defined in a .gemspec file or a Rakefile, and looks like this:
#
# Gem::Specification.new do |s|
@@ -38,8 +40,6 @@ require 'rubygems/util/list'
class Gem::Specification < Gem::BasicSpecification
- extend Gem::Deprecate
-
# REFACTOR: Consider breaking out this version stuff into a separate
# module. There's enough special stuff around it that it may justify
# a separate class.
@@ -83,17 +83,17 @@ class Gem::Specification < Gem::BasicSpecification
'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"',
'"test_file=x" is a shortcut for "test_files=[x]"'
],
- 2 => [
+ 2 => [
'Added "required_rubygems_version"',
'Now forward-compatible with future versions',
],
3 => [
- 'Added Fixnum validation to the specification_version'
+ 'Added Fixnum validation to the specification_version'
],
4 => [
'Added sandboxed freeform metadata to the specification version.'
]
- }.freeze
+ }
MARSHAL_FIELDS = { # :nodoc:
-1 => 16,
@@ -101,19 +101,16 @@ class Gem::Specification < Gem::BasicSpecification
2 => 16,
3 => 17,
4 => 18,
- }.freeze
+ }
today = Time.now.utc
TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
- # rubocop:disable Style/MutableConstant
LOAD_CACHE = {} # :nodoc:
- # rubocop:enable Style/MutableConstant
- LOAD_CACHE_MUTEX = Mutex.new
private_constant :LOAD_CACHE if defined? private_constant
- VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
+ VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:
# :startdoc:
@@ -136,7 +133,7 @@ class Gem::Specification < Gem::BasicSpecification
:autorequire => nil,
:bindir => 'bin',
:cert_chain => [],
- :date => nil,
+ :date => TODAY,
:dependencies => [],
:description => nil,
:email => nil,
@@ -155,6 +152,7 @@ class Gem::Specification < Gem::BasicSpecification
:required_ruby_version => Gem::Requirement.default,
:required_rubygems_version => Gem::Requirement.default,
:requirements => [],
+ :rubyforge_project => nil,
:rubygems_version => Gem::VERSION,
:signing_key => nil,
:specification_version => CURRENT_SPECIFICATION_VERSION,
@@ -163,41 +161,33 @@ class Gem::Specification < Gem::BasicSpecification
:version => nil,
}.freeze
- # rubocop:disable Style/MutableConstant
INITIALIZE_CODE_FOR_DEFAULTS = { } # :nodoc:
- # rubocop:enable Style/MutableConstant
@@default_value.each do |k,v|
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
- when [], {}, true, false, nil, Numeric, Symbol
- v.inspect
- when String
- v.dump
- when Numeric
- "default_value(:#{k})"
- else
- "default_value(:#{k}).dup"
- end
+ when [], {}, true, false, nil, Numeric, Symbol
+ v.inspect
+ when String
+ v.dump
+ when Numeric
+ "default_value(:#{k})"
+ else
+ "default_value(:#{k}).dup"
+ end
end
@@attributes = @@default_value.keys.sort_by { |s| s.to_s }
@@array_attributes = @@default_value.reject { |k,v| v != [] }.keys
- @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
+ @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition { |k|
@@default_value[k].nil?
- end
+ }
@@stubs_by_name = {}
# Sentinel object to represent "not found" stubs
NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc:
- @@spec_with_requirable_file = {}
- @@active_stub_with_requirable_file = {}
-
- # Tracking removed method calls to warn users during build time.
- REMOVED_METHODS = [:rubyforge_project=].freeze # :nodoc:
- def removed_method_calls
- @removed_method_calls ||= []
- end
+ @@spec_with_requirable_file = {}
+ @@active_stub_with_requirable_file = {}
######################################################################
# :section: Required gemspec attributes
@@ -268,23 +258,31 @@ class Gem::Specification < Gem::BasicSpecification
].flatten.compact.uniq.sort
end
+ ######################################################################
+ # :section: Recommended gemspec attributes
+
##
- # A list of authors for this gem.
+ # Singular writer for #authors
#
- # Alternatively, a single author can be specified by assigning a string to
- # `spec.author`
+ # Usage:
+ #
+ # spec.author = 'John Jones'
+
+ def author= o
+ self.authors = [o]
+ end
+
+ ##
+ # Sets the list of authors, ensuring it is an array.
#
# Usage:
#
# spec.authors = ['John Jones', 'Mary Smith']
- def authors=(value)
+ def authors= value
@authors = Array(value).flatten.grep(String)
end
- ######################################################################
- # :section: Recommended gemspec attributes
-
##
# A long description of this gem
#
@@ -346,7 +344,7 @@ class Gem::Specification < Gem::BasicSpecification
# Usage:
# spec.license = 'MIT'
- def license=(o)
+ def license=o
self.licenses = [o]
end
@@ -363,13 +361,14 @@ class Gem::Specification < Gem::BasicSpecification
# Usage:
# spec.licenses = ['MIT', 'GPL-2.0']
- def licenses=(licenses)
+ def licenses= licenses
@licenses = Array licenses
end
##
# The metadata holds extra data for this gem that may be useful to other
- # consumers and is settable by gem authors.
+ # consumers and is settable by gem authors without requiring an update to
+ # the rubygems software.
#
# Metadata items have the following restrictions:
#
@@ -403,17 +402,6 @@ class Gem::Specification < Gem::BasicSpecification
# :section: Optional gemspec attributes
##
- # Singular (alternative) writer for #authors
- #
- # Usage:
- #
- # spec.author = 'John Jones'
-
- def author=(o)
- self.authors = [o]
- end
-
- ##
# The path in the gem for executable scripts. Usually 'bin'
#
# Usage:
@@ -460,9 +448,9 @@ class Gem::Specification < Gem::BasicSpecification
#
# spec.platform = Gem::Platform.local
- def platform=(platform)
+ def platform= platform
if @original_platform.nil? or
- @original_platform == Gem::Platform::RUBY
+ @original_platform == Gem::Platform::RUBY then
@original_platform = platform
end
@@ -628,7 +616,7 @@ class Gem::Specification < Gem::BasicSpecification
# Sets the version of RubyGems that installed this gem. See also
# #installed_by_version.
- def installed_by_version=(version) # :nodoc:
+ def installed_by_version= version # :nodoc:
@installed_by_version = Gem::Version.new version
end
@@ -653,27 +641,29 @@ class Gem::Specification < Gem::BasicSpecification
# ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
# #<Gem::Version "2.0.0.247">
#
- # Prereleases can also be specified.
+ # Because patch-level is taken into account, be very careful specifying using
+ # `<=`: `<= 2.2.2` will not match any patch-level of 2.2.2 after the `p0`
+ # release. It is much safer to specify `< 2.2.3` instead
#
# Usage:
#
# # This gem will work with 1.8.6 or greater...
# spec.required_ruby_version = '>= 1.8.6'
#
- # # Only with final releases of major version 2 where minor version is at least 3
- # spec.required_ruby_version = '~> 2.3'
+ # # Only with ruby 2.0.x
+ # spec.required_ruby_version = '~> 2.0'
#
- # # Only prereleases or final releases after 2.6.0.preview2
- # spec.required_ruby_version = '> 2.6.0.preview2'
+ # # Only with ruby between 2.2.0 and 2.2.2
+ # spec.required_ruby_version = ['>= 2.2.0', '< 2.2.3']
- def required_ruby_version=(req)
+ def required_ruby_version= req
@required_ruby_version = Gem::Requirement.create req
end
##
# The RubyGems version required by this gem
- def required_rubygems_version=(req)
+ def required_rubygems_version= req
@required_rubygems_version = Gem::Requirement.create req
end
@@ -698,7 +688,7 @@ class Gem::Specification < Gem::BasicSpecification
# spec.test_files = Dir.glob('test/tc_*.rb')
# spec.test_files = ['tests/test-suite.rb']
- def test_files=(files) # :nodoc:
+ def test_files= files # :nodoc:
@test_files = Array files
end
@@ -725,7 +715,6 @@ class Gem::Specification < Gem::BasicSpecification
# Deprecated: You must now specify the executable name to Gem.bin_path.
attr_writer :default_executable
- deprecate :default_executable=, :none, 2018, 12
##
# Allows deinstallation of gems with legacy platforms.
@@ -733,6 +722,14 @@ class Gem::Specification < Gem::BasicSpecification
attr_writer :original_platform # :nodoc:
##
+ # The rubyforge project this gem lives under. i.e. RubyGems'
+ # rubyforge_project is "rubygems".
+ #
+ # This option is deprecated.
+
+ attr_accessor :rubyforge_project
+
+ ##
# The Gem::Specification version of this gemspec.
#
# Do not set this, it is set automatically when the gem is packaged.
@@ -740,8 +737,11 @@ class Gem::Specification < Gem::BasicSpecification
attr_accessor :specification_version
def self._all # :nodoc:
- unless defined?(@@all) && @@all
+ unless defined?(@@all) && @@all then
@@all = stubs.map(&:to_spec)
+ if @@all.any?(&:nil?) # TODO: remove once we're happy
+ raise "pid: #{$$} nil spec! included in #{stubs.inspect}"
+ end
# After a reset, make sure already loaded specs
# are still marked as activated.
@@ -753,47 +753,84 @@ class Gem::Specification < Gem::BasicSpecification
end
def self._clear_load_cache # :nodoc:
- LOAD_CACHE_MUTEX.synchronize do
- LOAD_CACHE.clear
- end
+ LOAD_CACHE.clear
end
def self.each_gemspec(dirs) # :nodoc:
dirs.each do |dir|
- Gem::Util.glob_files_in_dir("*.gemspec", dir).each do |path|
- yield path.tap(&Gem::UNTAINT)
+ Dir[File.join(dir, "*.gemspec")].each do |path|
+ yield path.untaint
end
end
end
- def self.gemspec_stubs_in(dir, pattern)
- Gem::Util.glob_files_in_dir(pattern, dir).map { |path| yield path }.select(&:valid?)
+ def self.gemspec_stubs_in dir, pattern
+ Dir[File.join(dir, pattern)].map { |path| yield path }.select(&:valid?)
end
private_class_method :gemspec_stubs_in
- def self.installed_stubs(dirs, pattern)
+ def self.default_stubs pattern
+ base_dir = Gem.default_dir
+ gems_dir = File.join base_dir, "gems"
+ gemspec_stubs_in(default_specifications_dir, pattern) do |path|
+ Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir)
+ end
+ end
+ private_class_method :default_stubs
+
+ def self.installed_stubs dirs, pattern
map_stubs(dirs, pattern) do |path, base_dir, gems_dir|
Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir)
end
end
private_class_method :installed_stubs
- def self.map_stubs(dirs, pattern) # :nodoc:
- dirs.flat_map do |dir|
- base_dir = File.dirname dir
- gems_dir = File.join base_dir, "gems"
- gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
+ if [].respond_to? :flat_map
+ def self.map_stubs(dirs, pattern) # :nodoc:
+ dirs.flat_map { |dir|
+ base_dir = File.dirname dir
+ gems_dir = File.join base_dir, "gems"
+ gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
+ }
+ end
+ else # FIXME: remove when 1.8 is dropped
+ def self.map_stubs(dirs, pattern) # :nodoc:
+ dirs.map { |dir|
+ base_dir = File.dirname dir
+ gems_dir = File.join base_dir, "gems"
+ gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
+ }.flatten 1
end
end
private_class_method :map_stubs
- def self.uniq_by(list, &block) # :nodoc:
- list.uniq(&block)
+ uniq_takes_a_block = false
+ [1,2].uniq { uniq_takes_a_block = true }
+
+ if uniq_takes_a_block
+ def self.uniq_by(list, &block) # :nodoc:
+ list.uniq(&block)
+ end
+ else # FIXME: remove when 1.8 is dropped
+ def self.uniq_by(list) # :nodoc:
+ values = {}
+ list.each { |item|
+ value = yield item
+ values[value] ||= item
+ }
+ values.values
+ end
end
private_class_method :uniq_by
- def self.sort_by!(list, &block)
- list.sort_by!(&block)
+ if [].respond_to? :sort_by!
+ def self.sort_by! list, &block
+ list.sort_by!(&block)
+ end
+ else # FIXME: remove when 1.8 is dropped
+ def self.sort_by! list, &block
+ list.replace list.sort_by(&block)
+ end
end
private_class_method :sort_by!
@@ -810,40 +847,26 @@ class Gem::Specification < Gem::BasicSpecification
def self.stubs
@@stubs ||= begin
pattern = "*.gemspec"
- stubs = Gem.loaded_specs.values + installed_stubs(dirs, pattern) + default_stubs(pattern)
+ stubs = default_stubs(pattern).concat installed_stubs(dirs, pattern)
stubs = uniq_by(stubs) { |stub| stub.full_name }
_resort!(stubs)
- @@stubs_by_name = stubs.select { |s| Gem::Platform.match s.platform }.group_by(&:name)
+ @@stubs_by_name = stubs.group_by(&:name)
stubs
end
end
- ##
- # Returns a Gem::StubSpecification for default gems
-
- def self.default_stubs(pattern = "*.gemspec")
- base_dir = Gem.default_dir
- gems_dir = File.join base_dir, "gems"
- gemspec_stubs_in(Gem.default_specifications_dir, pattern) do |path|
- Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir)
- end
- end
-
EMPTY = [].freeze # :nodoc:
##
# Returns a Gem::StubSpecification for installed gem named +name+
- # only returns stubs that match Gem.platforms
- def self.stubs_for(name)
+ def self.stubs_for name
if @@stubs
@@stubs_by_name[name] || []
else
pattern = "#{name}-*.gemspec"
- stubs = Gem.loaded_specs.values +
- installed_stubs(dirs, pattern).select { |s| Gem::Platform.match s.platform } +
- default_stubs(pattern)
+ stubs = default_stubs(pattern) + installed_stubs(dirs, pattern)
stubs = uniq_by(stubs) { |stub| stub.full_name }.group_by(&:name)
stubs.each_value { |v| _resort!(v) }
@@ -853,18 +876,18 @@ class Gem::Specification < Gem::BasicSpecification
end
def self._resort!(specs) # :nodoc:
- specs.sort! do |a, b|
+ specs.sort! { |a, b|
names = a.name <=> b.name
next names if names.nonzero?
b.version <=> a.version
- end
+ }
end
##
# Loads the default specifications. It should be called only once.
def self.load_defaults
- each_spec([Gem.default_specifications_dir]) do |spec|
+ each_spec([default_specifications_dir]) do |spec|
# #load returns nil if the spec is bad, so we just ignore
# it at this stage
Gem.register_default_spec(spec)
@@ -872,6 +895,51 @@ class Gem::Specification < Gem::BasicSpecification
end
##
+ # Adds +spec+ to the known specifications, keeping the collection
+ # properly sorted.
+
+ def self.add_spec spec
+ warn "Gem::Specification.add_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
+ # TODO: find all extraneous adds
+ # puts
+ # p :add_spec => [spec.full_name, caller.reject { |s| s =~ /minitest/ }]
+
+ # TODO: flush the rest of the crap from the tests
+ # raise "no dupes #{spec.full_name} in #{all_names.inspect}" if
+ # _all.include? spec
+
+ raise "nil spec!" unless spec # TODO: remove once we're happy with tests
+
+ return if _all.include? spec
+
+ _all << spec
+ stubs << spec
+ (@@stubs_by_name[spec.name] ||= []) << spec
+ sort_by!(@@stubs_by_name[spec.name]) { |s| s.version }
+ _resort!(_all)
+ _resort!(stubs)
+ end
+
+ ##
+ # Adds multiple specs to the known specifications.
+
+ def self.add_specs *specs
+ warn "Gem::Specification.add_specs is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
+
+ raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
+
+ # TODO: this is much more efficient, but we need the extra checks for now
+ # _all.concat specs
+ # _resort!
+
+ Gem::Deprecate.skip_during do
+ specs.each do |spec| # TODO: slow
+ add_spec spec
+ end
+ end
+ end
+
+ ##
# Returns all specifications. This method is discouraged from use.
# You probably want to use one of the Enumerable methods instead.
@@ -893,7 +961,8 @@ class Gem::Specification < Gem::BasicSpecification
#
# -- wilsonb
- def self.all=(specs)
+ def self.all= specs
+ raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
@@stubs_by_name = specs.group_by(&:name)
@@all = @@stubs = specs
end
@@ -927,16 +996,16 @@ class Gem::Specification < Gem::BasicSpecification
# Return the directories that Specification uses to find specs.
def self.dirs
- @@dirs ||= Gem.path.collect do |dir|
- File.join dir.dup.tap(&Gem::UNTAINT), "specifications"
- end
+ @@dirs ||= Gem.path.collect { |dir|
+ File.join dir.dup.untaint, "specifications"
+ }
end
##
# Set the directories that Specification uses to find specs. Setting
# this resets the list of known specs.
- def self.dirs=(dirs)
+ def self.dirs= dirs
self.reset
@@dirs = Array(dirs).map { |dir| File.join dir, "specifications" }
@@ -959,7 +1028,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# Returns every spec that matches +name+ and optional +requirements+.
- def self.find_all_by_name(name, *requirements)
+ def self.find_all_by_name name, *requirements
requirements = Gem::Requirement.default if requirements.empty?
# TODO: maybe try: find_all { |s| spec === dep }
@@ -978,7 +1047,7 @@ class Gem::Specification < Gem::BasicSpecification
# Find the best specification matching a +name+ and +requirements+. Raises
# if the dependency doesn't resolve to a valid specification.
- def self.find_by_name(name, *requirements)
+ def self.find_by_name name, *requirements
requirements = Gem::Requirement.default if requirements.empty?
# TODO: maybe try: find { |s| spec === dep }
@@ -989,12 +1058,12 @@ class Gem::Specification < Gem::BasicSpecification
##
# Return the best specification that contains the file matching +path+.
- def self.find_by_path(path)
+ def self.find_by_path path
path = path.dup.freeze
- spec = @@spec_with_requirable_file[path] ||= (stubs.find do |s|
+ spec = @@spec_with_requirable_file[path] ||= (stubs.find { |s|
next unless Gem::BundlerVersionFinder.compatible?(s)
s.contains_requirable_file? path
- end || NOT_FOUND)
+ } || NOT_FOUND)
spec.to_spec
end
@@ -1002,26 +1071,26 @@ class Gem::Specification < Gem::BasicSpecification
# Return the best specification that contains the file matching +path+
# amongst the specs that are not activated.
- def self.find_inactive_by_path(path)
- stub = stubs.find do |s|
+ def self.find_inactive_by_path path
+ stub = stubs.find { |s|
next if s.activated?
next unless Gem::BundlerVersionFinder.compatible?(s)
s.contains_requirable_file? path
- end
+ }
stub && stub.to_spec
end
- def self.find_active_stub_by_path(path)
- stub = @@active_stub_with_requirable_file[path] ||= (stubs.find do |s|
+ def self.find_active_stub_by_path path
+ stub = @@active_stub_with_requirable_file[path] ||= (stubs.find { |s|
s.activated? and s.contains_requirable_file? path
- end || NOT_FOUND)
+ } || NOT_FOUND)
stub.this
end
##
# Return currently unresolved specs that contain the file matching +path+.
- def self.find_in_unresolved(path)
+ def self.find_in_unresolved path
# TODO: do we need these?? Kill it
specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
@@ -1032,7 +1101,7 @@ class Gem::Specification < Gem::BasicSpecification
# Search through all unresolved deps and sub-dependencies and return
# specs that contain the file matching +path+.
- def self.find_in_unresolved_tree(path)
+ def self.find_in_unresolved_tree path
specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
specs.each do |spec|
@@ -1062,11 +1131,11 @@ class Gem::Specification < Gem::BasicSpecification
input = normalize_yaml_input input
spec = Gem::SafeYAML.safe_load input
- if spec && spec.class == FalseClass
+ if spec && spec.class == FalseClass then
raise Gem::EndOfYAMLException
end
- unless Gem::Specification === spec
+ unless Gem::Specification === spec then
raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
end
@@ -1080,11 +1149,11 @@ class Gem::Specification < Gem::BasicSpecification
# Return the latest specs, optionally including prerelease specs if
# +prerelease+ is true.
- def self.latest_specs(prerelease = false)
+ def self.latest_specs prerelease = false
_latest_specs Gem::Specification._all, prerelease
end
- def self._latest_specs(specs, prerelease = false) # :nodoc:
+ def self._latest_specs specs, prerelease = false # :nodoc:
result = Hash.new { |h,k| h[k] = {} }
native = {}
@@ -1095,41 +1164,38 @@ class Gem::Specification < Gem::BasicSpecification
result[spec.name][spec.platform] = spec
end
- result.map(&:last).map(&:values).flatten.reject do |spec|
+ result.map(&:last).map(&:values).flatten.reject { |spec|
minimum = native[spec.name]
minimum && spec.version < minimum
- end.sort_by{ |tup| tup.name }
+ }.sort_by{ |tup| tup.name }
end
##
# Loads Ruby format gemspec from +file+.
- def self.load(file)
+ def self.load file
return unless file
- _spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] }
+ _spec = LOAD_CACHE[file]
return _spec if _spec
- file = file.dup.tap(&Gem::UNTAINT)
+ file = file.dup.untaint
return unless File.file?(file)
- code = File.read file, :mode => 'r:UTF-8:-'
+ code = if defined? Encoding
+ File.read file, :mode => 'r:UTF-8:-'
+ else
+ File.read file
+ end
- code.tap(&Gem::UNTAINT)
+ code.untaint
begin
_spec = eval code, binding, file
if Gem::Specification === _spec
_spec.loaded_from = File.expand_path file.to_s
- LOAD_CACHE_MUTEX.synchronize do
- prev = LOAD_CACHE[file]
- if prev
- _spec = prev
- else
- LOAD_CACHE[file] = _spec
- end
- end
+ LOAD_CACHE[file] = _spec
return _spec
end
@@ -1205,6 +1271,17 @@ class Gem::Specification < Gem::BasicSpecification
end
##
+ # Removes +spec+ from the known specs.
+
+ def self.remove_spec spec
+ warn "Gem::Specification.remove_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
+ _all.delete spec
+ stubs.delete_if { |s| s.full_name == spec.full_name }
+ (@@stubs_by_name[spec.name] || []).delete_if { |s| s.full_name == spec.full_name }
+ reset
+ end
+
+ ##
# Is +name+ a required attribute?
def self.required_attribute?(name)
@@ -1228,23 +1305,17 @@ class Gem::Specification < Gem::BasicSpecification
@@all = nil
@@stubs = nil
@@stubs_by_name = {}
- @@spec_with_requirable_file = {}
- @@active_stub_with_requirable_file = {}
+ @@spec_with_requirable_file = {}
+ @@active_stub_with_requirable_file = {}
_clear_load_cache
unresolved = unresolved_deps
- unless unresolved.empty?
+ unless unresolved.empty? then
w = "W" + "ARN"
- warn "#{w}: Unresolved or ambiguous specs during Gem::Specification.reset:"
+ warn "#{w}: Unresolved specs during Gem::Specification.reset:"
unresolved.values.each do |dep|
warn " #{dep}"
-
- versions = find_all_by_name(dep.name)
- unless versions.empty?
- warn " Available/installed versions of this gem:"
- versions.each { |s| warn " - #{s.version}" }
- end
end
- warn "#{w}: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
+ warn "#{w}: Clearing out unresolved specs."
warn "Please report a bug if this causes problems."
unresolved.clear
end
@@ -1260,8 +1331,6 @@ class Gem::Specification < Gem::BasicSpecification
# Load custom marshal format, re-initializing defaults as needed
def self._load(str)
- Gem.load_yaml
-
array = Marshal.load str
spec = Gem::Specification.new
@@ -1269,7 +1338,7 @@ class Gem::Specification < Gem::BasicSpecification
current_version = CURRENT_SPECIFICATION_VERSION
- field_count = if spec.specification_version > current_version
+ field_count = if spec.specification_version > current_version then
spec.instance_variable_set :@specification_version,
current_version
MARSHAL_FIELDS[current_version]
@@ -1277,7 +1346,7 @@ class Gem::Specification < Gem::BasicSpecification
MARSHAL_FIELDS[spec.specification_version]
end
- if array.size < field_count
+ if array.size < field_count then
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
end
@@ -1296,7 +1365,7 @@ class Gem::Specification < Gem::BasicSpecification
spec.instance_variable_set :@required_rubygems_version, array[7]
spec.instance_variable_set :@original_platform, array[8]
spec.instance_variable_set :@dependencies, array[9]
- # offset due to rubyforge_project removal
+ spec.instance_variable_set :@rubyforge_project, array[10]
spec.instance_variable_set :@email, array[11]
spec.instance_variable_set :@authors, array[12]
spec.instance_variable_set :@description, array[13]
@@ -1316,7 +1385,7 @@ class Gem::Specification < Gem::BasicSpecification
sort_obj <=> other.sort_obj
end
- def ==(other) # :nodoc:
+ def == other # :nodoc:
self.class === other &&
name == other.name &&
version == other.version &&
@@ -1341,7 +1410,7 @@ class Gem::Specification < Gem::BasicSpecification
@required_rubygems_version,
@original_platform,
@dependencies,
- '', # rubyforge_project
+ @rubyforge_project,
@email,
@authors,
@description,
@@ -1361,7 +1430,7 @@ class Gem::Specification < Gem::BasicSpecification
def activate
other = Gem.loaded_specs[self.name]
- if other
+ if other then
check_version_conflict other
return false
end
@@ -1399,7 +1468,7 @@ class Gem::Specification < Gem::BasicSpecification
specs = spec_dep.to_specs
- if specs.size == 1
+ if specs.size == 1 then
specs.first.activate
else
name = spec_dep.name
@@ -1461,7 +1530,7 @@ class Gem::Specification < Gem::BasicSpecification
def add_bindir(executables)
return nil if executables.nil?
- if @bindir
+ if @bindir then
Array(executables).map { |e| File.join(@bindir, e) }
else
executables
@@ -1476,7 +1545,7 @@ class Gem::Specification < Gem::BasicSpecification
# <tt>:development</tt>.
def add_dependency_with_type(dependency, type, requirements)
- requirements = if requirements.empty?
+ requirements = if requirements.empty? then
Gem::Requirement.default
else
requirements.flatten
@@ -1502,7 +1571,16 @@ class Gem::Specification < Gem::BasicSpecification
paths = full_require_paths
- Gem.add_to_load_path(*paths)
+ # gem directories must come after -I and ENV['RUBYLIB']
+ insert_index = Gem.load_path_insert_index
+
+ if insert_index then
+ # gem directories must come after -I and ENV['RUBYLIB']
+ $LOAD_PATH.insert(insert_index, *paths)
+ else
+ # we are probably testing in core, -I and RUBYLIB don't apply
+ $LOAD_PATH.unshift(*paths)
+ end
end
##
@@ -1528,13 +1606,13 @@ class Gem::Specification < Gem::BasicSpecification
# a full path.
def bin_dir
- @bin_dir ||= File.join gem_dir, bindir
+ @bin_dir ||= File.join gem_dir, bindir # TODO: this is unfortunate
end
##
# Returns the full path to an executable named +name+ in this gem.
- def bin_file(name)
+ def bin_file name
File.join bin_dir, name
end
@@ -1601,6 +1679,16 @@ class Gem::Specification < Gem::BasicSpecification
end
##
+ # Used to detect if the gem is bundled in older version of Ruby, but not
+ # detectable as default gem (see BasicSpecification#default_gem?).
+
+ def bundled_gem_in_old_ruby?
+ !default_gem? &&
+ RUBY_VERSION < "2.0.0" &&
+ summary == "This #{name} is bundled with Ruby"
+ end
+
+ ##
# Returns the full path to the cache directory containing this
# spec's cached gem.
@@ -1620,12 +1708,12 @@ class Gem::Specification < Gem::BasicSpecification
def conflicts
conflicts = {}
- self.runtime_dependencies.each do |dep|
+ self.runtime_dependencies.each { |dep|
spec = Gem.loaded_specs[dep.name]
if spec and not spec.satisfies_requirement? dep
(conflicts[spec] ||= []) << dep
end
- end
+ }
env_req = Gem.env_requirement(name)
(conflicts[self] ||= []) << env_req unless env_req.satisfied_by? version
conflicts
@@ -1635,9 +1723,9 @@ class Gem::Specification < Gem::BasicSpecification
# return true if there will be conflict when spec if loaded together with the list of specs.
def conficts_when_loaded_with?(list_of_specs) # :nodoc:
- result = list_of_specs.any? do |spec|
+ result = list_of_specs.any? { |spec|
spec.dependencies.any? { |dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
- end
+ }
result
end
@@ -1646,26 +1734,23 @@ class Gem::Specification < Gem::BasicSpecification
def has_conflicts?
return true unless Gem.env_requirement(name).satisfied_by?(version)
- self.dependencies.any? do |dep|
- if dep.runtime?
+ self.dependencies.any? { |dep|
+ if dep.runtime? then
spec = Gem.loaded_specs[dep.name]
spec and not spec.satisfies_requirement? dep
else
false
end
- end
+ }
end
- # The date this gem was created.
- #
- # If SOURCE_DATE_EPOCH is set as an environment variable, use that to support
- # reproducible builds; otherwise, default to the current UTC date.
+ ##
+ # The date this gem was created. Lazily defaults to the current UTC date.
#
- # Details on SOURCE_DATE_EPOCH:
- # https://reproducible-builds.org/specs/source-date-epoch/
+ # There is no need to set this in your gem specification.
def date
- @date ||= Time.utc(*Gem.source_date_epoch.utc.to_a[3..5].reverse)
+ @date ||= TODAY
end
DateLike = Object.new # :nodoc:
@@ -1677,26 +1762,26 @@ class Gem::Specification < Gem::BasicSpecification
/\A
(\d{4})-(\d{2})-(\d{2})
(\s+ \d{2}:\d{2}:\d{2}\.\d+ \s* (Z | [-+]\d\d:\d\d) )?
- \Z/x.freeze
+ \Z/x
##
# The date this gem was created
#
# DO NOT set this, it is set automatically when the gem is packaged.
- def date=(date)
+ def date= date
# We want to end up with a Time object with one-day resolution.
# This is the cleanest, most-readable, faster-than-using-Date
# way to do it.
@date = case date
when String then
- if DateTimeFormat =~ date
+ if DateTimeFormat =~ date then
Time.utc($1.to_i, $2.to_i, $3.to_i)
# Workaround for where the date format output from psych isn't
# parsed as a Time object by syck and thus comes through as a
# string.
- elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date
+ elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date then
Time.utc($1.to_i, $2.to_i, $3.to_i)
else
raise(Gem::InvalidSpecificationException,
@@ -1725,12 +1810,11 @@ class Gem::Specification < Gem::BasicSpecification
end
result
end
- deprecate :default_executable, :none, 2018, 12
##
# The default value for specification attribute +name+
- def default_value(name)
+ def default_value name
@@default_value[name]
end
@@ -1754,7 +1838,7 @@ class Gem::Specification < Gem::BasicSpecification
out = []
Gem::Specification.each do |spec|
spec.dependencies.each do |dep|
- if self.satisfies_requirement?(dep)
+ if self.satisfies_requirement?(dep) then
sats = []
find_all_satisfiers(dep) do |sat|
sats << sat
@@ -1776,7 +1860,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# A detailed description of this gem. See also #summary
- def description=(str)
+ def description= str
@description = str.to_s
end
@@ -1795,17 +1879,17 @@ class Gem::Specification < Gem::BasicSpecification
#
# spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri"
- def doc_dir(type = nil)
+ def doc_dir type = nil
@doc_dir ||= File.join base_dir, 'doc', full_name
- if type
+ if type then
File.join @doc_dir, type
else
@doc_dir
end
end
- def encode_with(coder) # :nodoc:
+ def encode_with coder # :nodoc:
mark_version
coder.add 'name', @name
@@ -1826,7 +1910,7 @@ class Gem::Specification < Gem::BasicSpecification
end
end
- def eql?(other) # :nodoc:
+ def eql? other # :nodoc:
self.class === other && same_attributes?(other)
end
@@ -1840,7 +1924,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# Singular accessor for #executables
- def executable=(o)
+ def executable=o
self.executables = [o]
end
@@ -1848,7 +1932,7 @@ class Gem::Specification < Gem::BasicSpecification
# Sets executables to +value+, ensuring it is an array. Don't
# use this, push onto the array instead.
- def executables=(value)
+ def executables= value
# TODO: warn about setting instead of pushing
@executables = Array(value)
end
@@ -1857,7 +1941,7 @@ class Gem::Specification < Gem::BasicSpecification
# Sets extensions to +extensions+, ensuring it is an array. Don't
# use this, push onto the array instead.
- def extensions=(extensions)
+ def extensions= extensions
# TODO: warn about setting instead of pushing
@extensions = Array extensions
end
@@ -1866,7 +1950,7 @@ class Gem::Specification < Gem::BasicSpecification
# Sets extra_rdoc_files to +files+, ensuring it is an array. Don't
# use this, push onto the array instead.
- def extra_rdoc_files=(files)
+ def extra_rdoc_files= files
# TODO: warn about setting instead of pushing
@extra_rdoc_files = Array files
end
@@ -1883,14 +1967,14 @@ class Gem::Specification < Gem::BasicSpecification
##
# Sets files to +files+, ensuring it is an array.
- def files=(files)
+ def files= files
@files = Array files
end
##
# Finds all gems that satisfy +dep+
- def find_all_satisfiers(dep)
+ def find_all_satisfiers dep
Gem::Specification.each do |spec|
yield spec if spec.satisfies_requirement? dep
end
@@ -1922,7 +2006,8 @@ class Gem::Specification < Gem::BasicSpecification
end
def gems_dir
- @gems_dir ||= File.join(base_dir, "gems")
+ # TODO: this logic seems terribly broken, but tests fail if just base_dir
+ @gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
end
##
@@ -1933,20 +2018,17 @@ class Gem::Specification < Gem::BasicSpecification
def has_rdoc # :nodoc:
true
end
- deprecate :has_rdoc, :none, 2018, 12
##
# Deprecated and ignored.
#
# Formerly used to indicate this gem was RDoc-capable.
- def has_rdoc=(ignored) # :nodoc:
+ def has_rdoc= ignored # :nodoc:
@has_rdoc = true
end
- deprecate :has_rdoc=, :none, 2018, 12
alias :has_rdoc? :has_rdoc # :nodoc:
- deprecate :has_rdoc?, :none, 2018, 12
##
# True if this gem has files in test_files
@@ -1963,11 +2045,13 @@ class Gem::Specification < Gem::BasicSpecification
name.hash ^ version.hash
end
- def init_with(coder) # :nodoc:
+ def init_with coder # :nodoc:
@installed_by_version ||= nil
yaml_initialize coder.tag, coder.map
end
+
+
eval <<-RB, binding, __FILE__, __LINE__ + 1
def set_nil_attributes_to_nil
#{@@nil_attributes.map {|key| "@#{key} = nil" }.join "; "}
@@ -1985,7 +2069,7 @@ class Gem::Specification < Gem::BasicSpecification
# and yields itself for further initialization. Optionally takes +name+ and
# +version+.
- def initialize(name = nil, version = nil)
+ def initialize name = nil, version = nil
super()
@gems_dir = nil
@base_dir = nil
@@ -2009,14 +2093,14 @@ class Gem::Specification < Gem::BasicSpecification
##
# Duplicates array_attributes from +other_spec+ so state isn't shared.
- def initialize_copy(other_spec)
+ def initialize_copy other_spec
self.class.array_attributes.each do |name|
name = :"@#{name}"
next unless other_spec.instance_variable_defined? name
begin
val = other_spec.instance_variable_get(name)
- if val
+ if val then
instance_variable_set name, val.dup
elsif Gem.configuration.really_verbose
warn "WARNING: #{full_name} has an invalid nil value for #{name}"
@@ -2033,7 +2117,7 @@ class Gem::Specification < Gem::BasicSpecification
def base_dir
return Gem.dir unless loaded_from
- @base_dir ||= if default_gem?
+ @base_dir ||= if default_gem? then
File.dirname File.dirname File.dirname loaded_from
else
File.dirname File.dirname loaded_from
@@ -2105,17 +2189,11 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Track removed method calls to warn about during build time.
# Warn about unknown attributes while loading a spec.
def method_missing(sym, *a, &b) # :nodoc:
- if REMOVED_METHODS.include?(sym)
- removed_method_calls << sym
- return
- end
-
if @specification_version > CURRENT_SPECIFICATION_VERSION and
- sym.to_s =~ /=$/
+ sym.to_s =~ /=$/ then
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
else
super
@@ -2142,7 +2220,7 @@ class Gem::Specification < Gem::BasicSpecification
# file list.
def normalize
- if defined?(@extra_rdoc_files) and @extra_rdoc_files
+ if defined?(@extra_rdoc_files) and @extra_rdoc_files then
@extra_rdoc_files.uniq!
@files ||= []
@files.concat(@extra_rdoc_files)
@@ -2167,7 +2245,7 @@ class Gem::Specification < Gem::BasicSpecification
# platform. For use with legacy gems.
def original_name # :nodoc:
- if platform == Gem::Platform::RUBY or platform.nil?
+ if platform == Gem::Platform::RUBY or platform.nil? then
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@original_platform}"
@@ -2199,13 +2277,12 @@ class Gem::Specification < Gem::BasicSpecification
attributes.each do |attr_name|
current_value = self.send attr_name
- current_value = current_value.sort if %i(files test_files).include? attr_name
if current_value != default_value(attr_name) or
- self.class.required_attribute? attr_name
+ self.class.required_attribute? attr_name then
q.text "s.#{attr_name} = "
- if attr_name == :date
+ if attr_name == :date then
current_value = current_value.utc
q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
@@ -2223,7 +2300,7 @@ class Gem::Specification < Gem::BasicSpecification
# Raise an exception if the version of this spec conflicts with the one
# that is already loaded (+other+)
- def check_version_conflict(other) # :nodoc:
+ def check_version_conflict other # :nodoc:
return if self.version == other.version
# This gem is already loaded. If the currently loaded gem is not in the
@@ -2233,6 +2310,7 @@ class Gem::Specification < Gem::BasicSpecification
e = Gem::LoadError.new msg
e.name = self.name
+ # TODO: e.requirement = dep.requirement
raise e
end
@@ -2243,7 +2321,7 @@ class Gem::Specification < Gem::BasicSpecification
# Check the spec for possible conflicts and freak out if there are any.
def raise_if_conflicts # :nodoc:
- if has_conflicts?
+ if has_conflicts? then
raise Gem::ConflictError.new self, conflicts
end
end
@@ -2252,7 +2330,7 @@ class Gem::Specification < Gem::BasicSpecification
# Sets rdoc_options to +value+, ensuring it is an array. Don't
# use this, push onto the array instead.
- def rdoc_options=(options)
+ def rdoc_options= options
# TODO: warn about setting instead of pushing
@rdoc_options = Array options
end
@@ -2267,7 +2345,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# Singular accessor for #require_paths
- def require_path=(path)
+ def require_path= path
self.require_paths = Array(path)
end
@@ -2275,12 +2353,12 @@ class Gem::Specification < Gem::BasicSpecification
# Set requirements to +req+, ensuring it is an array. Don't
# use this, push onto the array instead.
- def requirements=(req)
+ def requirements= req
# TODO: warn about setting instead of pushing
@requirements = Array req
end
- def respond_to_missing?(m, include_private = false) # :nodoc:
+ def respond_to_missing? m, include_private = false # :nodoc:
false
end
@@ -2297,18 +2375,18 @@ class Gem::Specification < Gem::BasicSpecification
def ruby_code(obj)
case obj
- when String then obj.dump + ".freeze"
- when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
- when Hash then
+ when String then obj.dump + ".freeze"
+ when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
+ when Hash then
seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
"{ #{seg.join(', ')} }"
- when Gem::Version then obj.to_s.dump
- when DateLike then obj.strftime('%Y-%m-%d').dump
- when Time then obj.strftime('%Y-%m-%d').dump
- when Numeric then obj.inspect
- when true, false, nil then obj.inspect
- when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
- when Gem::Requirement then
+ when Gem::Version then obj.to_s.dump
+ when DateLike then obj.strftime('%Y-%m-%d').dump
+ when Time then obj.strftime('%Y-%m-%d').dump
+ when Numeric then obj.inspect
+ when true, false, nil then obj.inspect
+ when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
+ when Gem::Requirement then
list = obj.as_list
"Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
@@ -2327,7 +2405,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# True if this gem has the same attributes as +other+.
- def same_attributes?(spec)
+ def same_attributes? spec
@@attributes.all? { |name, default| self.send(name) == spec.send(name) }
end
@@ -2336,7 +2414,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# Checks if this specification meets the requirement of +dependency+.
- def satisfies_requirement?(dependency)
+ def satisfies_requirement? dependency
return @name == dependency.name &&
dependency.requirement.satisfied_by?(@version)
end
@@ -2383,7 +2461,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# A short summary of this gem's description.
- def summary=(str)
+ def summary= str
@summary = str.to_s.strip.
gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').gsub(/\n[ \t]*/, " ") # so. weird.
end
@@ -2398,7 +2476,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# Singular mutator for #test_files
- def test_file=(file) # :nodoc:
+ def test_file= file # :nodoc:
self.test_files = [file]
end
@@ -2410,11 +2488,11 @@ class Gem::Specification < Gem::BasicSpecification
# Handle the possibility that we have @test_suite_file but not
# @test_files. This will happen when an old gem is loaded via
# YAML.
- if defined? @test_suite_file
+ if defined? @test_suite_file then
@test_files = [@test_suite_file].flatten
@test_suite_file = nil
end
- if defined?(@test_files) and @test_files
+ if defined?(@test_files) and @test_files then
@test_files
else
@test_files = []
@@ -2427,7 +2505,6 @@ class Gem::Specification < Gem::BasicSpecification
# still have their default values are omitted.
def to_ruby
- require 'openssl'
mark_version
result = []
result << "# -*- encoding: utf-8 -*-"
@@ -2439,7 +2516,7 @@ class Gem::Specification < Gem::BasicSpecification
result << " s.name = #{ruby_code name}"
result << " s.version = #{ruby_code version}"
- unless platform.nil? or platform == Gem::Platform::RUBY
+ unless platform.nil? or platform == Gem::Platform::RUBY then
result << " s.platform = #{ruby_code original_platform}"
end
result << ""
@@ -2466,31 +2543,40 @@ class Gem::Specification < Gem::BasicSpecification
@@attributes.each do |attr_name|
next if handled.include? attr_name
current_value = self.send(attr_name)
- if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name)
- result << " s.#{attr_name} = #{ruby_code current_value}" unless current_value.is_a?(OpenSSL::PKey::RSA)
+ if current_value != default_value(attr_name) or
+ self.class.required_attribute? attr_name then
+ result << " s.#{attr_name} = #{ruby_code current_value}"
end
end
- if @installed_by_version
+ if @installed_by_version then
result << nil
result << " s.installed_by_version = \"#{Gem::VERSION}\" if s.respond_to? :installed_by_version"
end
- unless dependencies.empty?
+ unless dependencies.empty? then
result << nil
result << " if s.respond_to? :specification_version then"
result << " s.specification_version = #{specification_version}"
- result << " end"
result << nil
- result << " if s.respond_to? :add_runtime_dependency then"
+ result << " if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then"
dependencies.each do |dep|
req = dep.requirements_list.inspect
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
- result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
+ result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
+ end
+
+ result << " else"
+
+ dependencies.each do |dep|
+ version_reqs_param = dep.requirements_list.inspect
+ result << " s.add_dependency(%q<#{dep.name}>.freeze, #{version_reqs_param})"
end
+ result << ' end'
+
result << " else"
dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect
@@ -2527,33 +2613,39 @@ class Gem::Specification < Gem::BasicSpecification
end
def to_yaml(opts = {}) # :nodoc:
- Gem.load_yaml
-
- # Because the user can switch the YAML engine behind our
- # back, we have to check again here to make sure that our
- # psych code was properly loaded, and load it if not.
- unless Gem.const_defined?(:NoAliasYAMLTree)
- require 'rubygems/psych_tree'
- end
+ if (YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?) ||
+ (defined?(Psych) && YAML == Psych) then
+ # Because the user can switch the YAML engine behind our
+ # back, we have to check again here to make sure that our
+ # psych code was properly loaded, and load it if not.
+ unless Gem.const_defined?(:NoAliasYAMLTree)
+ require 'rubygems/psych_tree'
+ end
- builder = Gem::NoAliasYAMLTree.create
- builder << self
- ast = builder.tree
+ builder = Gem::NoAliasYAMLTree.create
+ builder << self
+ ast = builder.tree
- require 'stringio'
- io = StringIO.new
- io.set_encoding Encoding::UTF_8
+ io = StringIO.new
+ io.set_encoding Encoding::UTF_8 if Object.const_defined? :Encoding
- Psych::Visitors::Emitter.new(io).accept(ast)
+ Psych::Visitors::Emitter.new(io).accept(ast)
- io.string.gsub(/ !!null \n/, " \n")
+ io.string.gsub(/ !!null \n/, " \n")
+ else
+ YAML.quick_emit object_id, opts do |out|
+ out.map taguri, to_yaml_style do |map|
+ encode_with map
+ end
+ end
+ end
end
##
# Recursively walk dependencies of this spec, executing the +block+ for each
# hop.
- def traverse(trail = [], visited = {}, &block)
+ def traverse trail = [], visited = {}, &block
trail.push(self)
begin
dependencies.each do |dep|
@@ -2586,38 +2678,336 @@ class Gem::Specification < Gem::BasicSpecification
# Raises InvalidSpecificationException if the spec does not pass the
# checks..
- def validate(packaging = true, strict = false)
+ def validate packaging = true
+ @warnings = 0
+ require 'rubygems/user_interaction'
+ extend Gem::UserInteraction
normalize
- validation_policy = Gem::SpecificationPolicy.new(self)
- validation_policy.packaging = packaging
- validation_policy.validate(strict)
- end
+ nil_attributes = self.class.non_nil_attributes.find_all do |attrname|
+ instance_variable_get("@#{attrname}").nil?
+ end
+
+ unless nil_attributes.empty? then
+ raise Gem::InvalidSpecificationException,
+ "#{nil_attributes.join ', '} must not be nil"
+ end
+
+ if packaging and rubygems_version != Gem::VERSION then
+ raise Gem::InvalidSpecificationException,
+ "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
+ end
+
+ @@required_attributes.each do |symbol|
+ unless self.send symbol then
+ raise Gem::InvalidSpecificationException,
+ "missing value for attribute #{symbol}"
+ end
+ end
+
+ if !name.is_a?(String) then
+ raise Gem::InvalidSpecificationException,
+ "invalid value for attribute name: \"#{name.inspect}\" must be a string"
+ elsif name !~ /[a-zA-Z]/ then
+ raise Gem::InvalidSpecificationException,
+ "invalid value for attribute name: #{name.dump} must include at least one letter"
+ elsif name !~ VALID_NAME_PATTERN then
+ raise Gem::InvalidSpecificationException,
+ "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
+ end
+
+ if raw_require_paths.empty? then
+ raise Gem::InvalidSpecificationException,
+ 'specification must have at least one require_path'
+ end
- def keep_only_files_and_directories
- @executables.delete_if { |x| File.directory?(File.join(@bindir, x)) }
- @extensions.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
- @extra_rdoc_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
@files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
@test_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
+ @executables.delete_if { |x| File.directory?(File.join(@bindir, x)) }
+ @extra_rdoc_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
+ @extensions.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
+
+ non_files = files.reject { |x| File.file?(x) || File.symlink?(x) }
+
+ unless not packaging or non_files.empty? then
+ raise Gem::InvalidSpecificationException,
+ "[\"#{non_files.join "\", \""}\"] are not files"
+ end
+
+ if files.include? file_name then
+ raise Gem::InvalidSpecificationException,
+ "#{full_name} contains itself (#{file_name}), check your files list"
+ end
+
+ unless specification_version.is_a?(Integer)
+ raise Gem::InvalidSpecificationException,
+ 'specification_version must be an Integer (did you mean version?)'
+ end
+
+ case platform
+ when Gem::Platform, Gem::Platform::RUBY then # ok
+ else
+ raise Gem::InvalidSpecificationException,
+ "invalid platform #{platform.inspect}, see Gem::Platform"
+ end
+
+ self.class.array_attributes.each do |field|
+ val = self.send field
+ klass = case field
+ when :dependencies
+ Gem::Dependency
+ else
+ String
+ end
+
+ unless Array === val and val.all? { |x| x.kind_of?(klass) } then
+ raise(Gem::InvalidSpecificationException,
+ "#{field} must be an Array of #{klass}")
+ end
+ end
+
+ [:authors].each do |field|
+ val = self.send field
+ raise Gem::InvalidSpecificationException, "#{field} may not be empty" if
+ val.empty?
+ end
+
+ unless Hash === metadata
+ raise Gem::InvalidSpecificationException,
+ 'metadata must be a hash'
+ end
+
+ validate_metadata
+
+ licenses.each { |license|
+ if license.length > 64
+ raise Gem::InvalidSpecificationException,
+ "each license must be 64 characters or less"
+ end
+
+ if !Gem::Licenses.match?(license)
+ suggestions = Gem::Licenses.suggestions(license)
+ message = <<-warning
+license value '#{license}' is invalid. Use a license identifier from
+http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
+ warning
+ message += "Did you mean #{suggestions.map { |s| "'#{s}'"}.join(', ')}?\n" unless suggestions.nil?
+ warning(message)
+ end
+ }
+
+ warning <<-warning if licenses.empty?
+licenses is empty, but is recommended. Use a license identifier from
+http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
+ warning
+
+ validate_permissions
+
+ # reject lazy developers:
+
+ lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
+
+ unless authors.grep(/FI XME|TO DO/x).empty? then
+ raise Gem::InvalidSpecificationException, "#{lazy} is not an author"
+ end
+
+ unless Array(email).grep(/FI XME|TO DO/x).empty? then
+ raise Gem::InvalidSpecificationException, "#{lazy} is not an email"
+ end
+
+ if description =~ /FI XME|TO DO/x then
+ raise Gem::InvalidSpecificationException, "#{lazy} is not a description"
+ end
+
+ if summary =~ /FI XME|TO DO/x then
+ raise Gem::InvalidSpecificationException, "#{lazy} is not a summary"
+ end
+
+ # Make sure a homepage is valid HTTP/HTTPS URI
+ if homepage and not homepage.empty?
+ begin
+ homepage_uri = URI.parse(homepage)
+ unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class
+ raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI"
+ end
+ rescue URI::InvalidURIError
+ raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI"
+ end
+ end
+
+ # Warnings
+
+ %w[author homepage summary files].each do |attribute|
+ value = self.send attribute
+ warning "no #{attribute} specified" if value.nil? or value.empty?
+ end
+
+ if description == summary then
+ warning 'description and summary are identical'
+ end
+
+ # TODO: raise at some given date
+ warning "deprecated autorequire specified" if autorequire
+
+ executables.each do |executable|
+ executable_path = File.join(bindir, executable)
+ shebang = File.read(executable_path, 2) == '#!'
+
+ warning "#{executable_path} is missing #! line" unless shebang
+ end
+
+ files.each do |file|
+ next unless File.symlink?(file)
+ warning "#{file} is a symlink, which is not supported on all platforms"
+ end
+
+ validate_dependencies
+
+ true
+ ensure
+ if $! or @warnings > 0 then
+ alert_warning "See http://guides.rubygems.org/specification-reference/ for help"
+ end
end
def validate_metadata
- Gem::SpecificationPolicy.new(self).validate_metadata
+ url_validation_regex = %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z}
+ link_keys = %w(
+ bug_tracker_uri
+ changelog_uri
+ documentation_uri
+ homepage_uri
+ mailing_list_uri
+ source_code_uri
+ wiki_uri
+ )
+
+ metadata.each do|key, value|
+ if !key.kind_of?(String)
+ raise Gem::InvalidSpecificationException,
+ "metadata keys must be a String"
+ end
+
+ if key.size > 128
+ raise Gem::InvalidSpecificationException,
+ "metadata key too large (#{key.size} > 128)"
+ end
+
+ if !value.kind_of?(String)
+ raise Gem::InvalidSpecificationException,
+ "metadata values must be a String"
+ end
+
+ if value.size > 1024
+ raise Gem::InvalidSpecificationException,
+ "metadata value too large (#{value.size} > 1024)"
+ end
+
+ if link_keys.include? key
+ if value !~ url_validation_regex
+ raise Gem::InvalidSpecificationException,
+ "metadata['#{key}'] has invalid link: #{value.inspect}"
+ end
+ end
+ end
end
##
# Checks that dependencies use requirements as we recommend. Warnings are
# issued when dependencies are open-ended or overly strict for semantic
# versioning.
- def validate_dependencies
- Gem::SpecificationPolicy.new(self).validate_dependencies
+
+ def validate_dependencies # :nodoc:
+ # NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
+ seen = Gem::Dependency::TYPES.inject({}) { |types, type| types.merge({ type => {}}) }
+
+ error_messages = []
+ warning_messages = []
+ dependencies.each do |dep|
+ if prev = seen[dep.type][dep.name] then
+ error_messages << <<-MESSAGE
+duplicate dependency on #{dep}, (#{prev.requirement}) use:
+ add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
+ MESSAGE
+ end
+
+ seen[dep.type][dep.name] = dep
+
+ prerelease_dep = dep.requirements_list.any? do |req|
+ Gem::Requirement.new(req).prerelease?
+ end
+
+ warning_messages << "prerelease dependency on #{dep} is not recommended" if
+ prerelease_dep && !version.prerelease?
+
+ overly_strict = dep.requirement.requirements.length == 1 &&
+ dep.requirement.requirements.any? do |op, version|
+ op == '~>' and
+ not version.prerelease? and
+ version.segments.length > 2 and
+ version.segments.first != 0
+ end
+
+ if overly_strict then
+ _, dep_version = dep.requirement.requirements.first
+
+ base = dep_version.segments.first 2
+
+ warning_messages << <<-WARNING
+pessimistic dependency on #{dep} may be overly strict
+ if #{dep.name} is semantically versioned, use:
+ add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}', '>= #{dep_version}'
+ WARNING
+ end
+
+ open_ended = dep.requirement.requirements.all? do |op, version|
+ not version.prerelease? and (op == '>' or op == '>=')
+ end
+
+ if open_ended then
+ op, dep_version = dep.requirement.requirements.first
+
+ base = dep_version.segments.first 2
+
+ bugfix = if op == '>' then
+ ", '> #{dep_version}'"
+ elsif op == '>=' and base != dep_version.segments then
+ ", '>= #{dep_version}'"
+ end
+
+ warning_messages << <<-WARNING
+open-ended dependency on #{dep} is not recommended
+ if #{dep.name} is semantically versioned, use:
+ add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}
+ WARNING
+ end
+ end
+ if error_messages.any?
+ raise Gem::InvalidSpecificationException, error_messages.join
+ end
+ if warning_messages.any?
+ warning_messages.each { |warning_message| warning warning_message }
+ end
end
##
# Checks to see if the files to be packaged are world-readable.
+
def validate_permissions
- Gem::SpecificationPolicy.new(self).validate_permissions
+ return if Gem.win_platform?
+
+ files.each do |file|
+ next unless File.file?(file)
+ next if File.stat(file).mode & 0444 == 0444
+ warning "#{file} is not world-readable"
+ end
+
+ executables.each do |name|
+ exec = File.join @bindir, name
+ next unless File.file?(exec)
+ next if File.stat(exec).executable?
+ warning "#{exec} is not executable"
+ end
end
##
@@ -2625,13 +3015,9 @@ class Gem::Specification < Gem::BasicSpecification
# required_rubygems_version if +version+ indicates it is a
# prerelease.
- def version=(version)
+ def version= version
@version = Gem::Version.create(version)
- # skip to set required_ruby_version when pre-released rubygems.
- # It caused to raise CircularDependencyError
- if @version.prerelease? && (@name.nil? || @name.strip != "rubygems")
- self.required_rubygems_version = '> 1.3.1'
- end
+ self.required_rubygems_version = '> 1.3.1' if @version.prerelease?
invalidate_memoized_attributes
return @version
@@ -2646,9 +3032,9 @@ class Gem::Specification < Gem::BasicSpecification
case ivar
when "date"
# Force Date to go through the extra coerce logic in date=
- self.date = val.tap(&Gem::UNTAINT)
+ self.date = val.untaint
else
- instance_variable_set "@#{ivar}", val.tap(&Gem::UNTAINT)
+ instance_variable_set "@#{ivar}", val.untaint
end
end
@@ -2678,10 +3064,26 @@ class Gem::Specification < Gem::BasicSpecification
@installed_by_version ||= nil
end
+ def warning statement # :nodoc:
+ @warnings += 1
+
+ alert_warning statement
+ end
+
def raw_require_paths # :nodoc:
@require_paths
end
+ extend Gem::Deprecate
+
+ # TODO:
+ # deprecate :has_rdoc, :none, 2011, 10
+ # deprecate :has_rdoc?, :none, 2011, 10
+ # deprecate :has_rdoc=, :none, 2011, 10
+ # deprecate :default_executable, :none, 2011, 10
+ # deprecate :default_executable=, :none, 2011, 10
+ # deprecate :file_name, :cache_file, 2011, 10
+ # deprecate :full_gem_path, :cache_file, 2011, 10
end
# DOC: What is this and why is it here, randomly, at the end of this file?
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
deleted file mode 100644
index b7fb2cfa1a..0000000000
--- a/lib/rubygems/specification_policy.rb
+++ /dev/null
@@ -1,435 +0,0 @@
-require 'rubygems/user_interaction'
-
-class Gem::SpecificationPolicy
-
- include Gem::UserInteraction
-
- VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
-
- SPECIAL_CHARACTERS = /\A[#{Regexp.escape('.-_')}]+/.freeze # :nodoc:
-
- VALID_URI_PATTERN = %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z}.freeze # :nodoc:
-
- METADATA_LINK_KEYS = %w[
- bug_tracker_uri
- changelog_uri
- documentation_uri
- homepage_uri
- mailing_list_uri
- source_code_uri
- wiki_uri
- ].freeze # :nodoc:
-
- def initialize(specification)
- @warnings = 0
-
- @specification = specification
- end
-
- ##
- # If set to true, run packaging-specific checks, as well.
-
- attr_accessor :packaging
-
- ##
- # Checks that the specification contains all required fields, and does a
- # very basic sanity check.
- #
- # Raises InvalidSpecificationException if the spec does not pass the
- # checks.
-
- def validate(strict = false)
- validate_nil_attributes
-
- validate_rubygems_version
-
- validate_required_attributes
-
- validate_name
-
- validate_require_paths
-
- @specification.keep_only_files_and_directories
-
- validate_non_files
-
- validate_self_inclusion_in_files_list
-
- validate_specification_version
-
- validate_platform
-
- validate_array_attributes
-
- validate_authors_field
-
- validate_metadata
-
- validate_licenses
-
- validate_permissions
-
- validate_lazy_metadata
-
- validate_values
-
- validate_dependencies
-
- validate_removed_attributes
-
- if @warnings > 0
- if strict
- error "specification has warnings"
- else
- alert_warning help_text
- end
- end
-
- true
- end
-
- ##
- # Implementation for Specification#validate_metadata
-
- def validate_metadata
- metadata = @specification.metadata
-
- unless Hash === metadata
- error 'metadata must be a hash'
- end
-
- metadata.each do |key, value|
- if !key.kind_of?(String)
- error "metadata keys must be a String"
- end
-
- if key.size > 128
- error "metadata key too large (#{key.size} > 128)"
- end
-
- if !value.kind_of?(String)
- error "metadata values must be a String"
- end
-
- if value.size > 1024
- error "metadata value too large (#{value.size} > 1024)"
- end
-
- if METADATA_LINK_KEYS.include? key
- if value !~ VALID_URI_PATTERN
- error "metadata['#{key}'] has invalid link: #{value.inspect}"
- end
- end
- end
- end
-
- ##
- # Implementation for Specification#validate_dependencies
-
- def validate_dependencies # :nodoc:
- # NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
- seen = Gem::Dependency::TYPES.inject({}) { |types, type| types.merge({ type => {}}) }
-
- error_messages = []
- warning_messages = []
- @specification.dependencies.each do |dep|
- if prev = seen[dep.type][dep.name]
- error_messages << <<-MESSAGE
-duplicate dependency on #{dep}, (#{prev.requirement}) use:
- add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
- MESSAGE
- end
-
- seen[dep.type][dep.name] = dep
-
- prerelease_dep = dep.requirements_list.any? do |req|
- Gem::Requirement.new(req).prerelease?
- end
-
- warning_messages << "prerelease dependency on #{dep} is not recommended" if
- prerelease_dep && !@specification.version.prerelease?
-
- open_ended = dep.requirement.requirements.all? do |op, version|
- not version.prerelease? and (op == '>' or op == '>=')
- end
-
- if open_ended
- op, dep_version = dep.requirement.requirements.first
-
- segments = dep_version.segments
-
- base = segments.first 2
-
- recommendation = if (op == '>' || op == '>=') && segments == [0]
- " use a bounded requirement, such as '~> x.y'"
- else
- bugfix = if op == '>'
- ", '> #{dep_version}'"
- elsif op == '>=' and base != segments
- ", '>= #{dep_version}'"
- end
-
- " if #{dep.name} is semantically versioned, use:\n" \
- " add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
- end
-
- warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
- end
- end
- if error_messages.any?
- error error_messages.join
- end
- if warning_messages.any?
- warning_messages.each { |warning_message| warning warning_message }
- end
- end
-
- ##
- # Issues a warning for each file to be packaged which is world-readable.
- #
- # Implementation for Specification#validate_permissions
-
- def validate_permissions
- return if Gem.win_platform?
-
- @specification.files.each do |file|
- next unless File.file?(file)
- next if File.stat(file).mode & 0444 == 0444
- warning "#{file} is not world-readable"
- end
-
- @specification.executables.each do |name|
- exec = File.join @specification.bindir, name
- next unless File.file?(exec)
- next if File.stat(exec).executable?
- warning "#{exec} is not executable"
- end
- end
-
- private
-
- def validate_nil_attributes
- nil_attributes = Gem::Specification.non_nil_attributes.select do |attrname|
- @specification.instance_variable_get("@#{attrname}").nil?
- end
- return if nil_attributes.empty?
- error "#{nil_attributes.join ', '} must not be nil"
- end
-
- def validate_rubygems_version
- return unless packaging
-
- rubygems_version = @specification.rubygems_version
-
- return if rubygems_version == Gem::VERSION
-
- error "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
- end
-
- def validate_required_attributes
- Gem::Specification.required_attributes.each do |symbol|
- unless @specification.send symbol
- error "missing value for attribute #{symbol}"
- end
- end
- end
-
- def validate_name
- name = @specification.name
-
- if !name.is_a?(String)
- error "invalid value for attribute name: \"#{name.inspect}\" must be a string"
- elsif name !~ /[a-zA-Z]/
- error "invalid value for attribute name: #{name.dump} must include at least one letter"
- elsif name !~ VALID_NAME_PATTERN
- error "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
- elsif name =~ SPECIAL_CHARACTERS
- error "invalid value for attribute name: #{name.dump} can not begin with a period, dash, or underscore"
- end
- end
-
- def validate_require_paths
- return unless @specification.raw_require_paths.empty?
-
- error 'specification must have at least one require_path'
- end
-
- def validate_non_files
- return unless packaging
-
- non_files = @specification.files.reject {|x| File.file?(x) || File.symlink?(x)}
-
- unless non_files.empty?
- error "[\"#{non_files.join "\", \""}\"] are not files"
- end
- end
-
- def validate_self_inclusion_in_files_list
- file_name = @specification.file_name
-
- return unless @specification.files.include?(file_name)
-
- error "#{@specification.full_name} contains itself (#{file_name}), check your files list"
- end
-
- def validate_specification_version
- return if @specification.specification_version.is_a?(Integer)
-
- error 'specification_version must be an Integer (did you mean version?)'
- end
-
- def validate_platform
- platform = @specification.platform
-
- case platform
- when Gem::Platform, Gem::Platform::RUBY # ok
- else
- error "invalid platform #{platform.inspect}, see Gem::Platform"
- end
- end
-
- def validate_array_attributes
- Gem::Specification.array_attributes.each do |field|
- validate_array_attribute(field)
- end
- end
-
- def validate_array_attribute(field)
- val = @specification.send(field)
- klass = case field
- when :dependencies then
- Gem::Dependency
- else
- String
- end
-
- unless Array === val and val.all? {|x| x.kind_of?(klass)}
- raise(Gem::InvalidSpecificationException,
- "#{field} must be an Array of #{klass}")
- end
- end
-
- def validate_authors_field
- return unless @specification.authors.empty?
-
- error "authors may not be empty"
- end
-
- def validate_licenses
- licenses = @specification.licenses
-
- licenses.each do |license|
- if license.length > 64
- error "each license must be 64 characters or less"
- end
-
- if !Gem::Licenses.match?(license)
- suggestions = Gem::Licenses.suggestions(license)
- message = <<-warning
-license value '#{license}' is invalid. Use a license identifier from
-http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
- warning
- message += "Did you mean #{suggestions.map { |s| "'#{s}'"}.join(', ')}?\n" unless suggestions.nil?
- warning(message)
- end
- end
-
- warning <<-warning if licenses.empty?
-licenses is empty, but is recommended. Use a license identifier from
-http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
- warning
- end
-
- LAZY = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
- LAZY_PATTERN = /FI XME|TO DO/x.freeze
- HOMEPAGE_URI_PATTERN = /\A[a-z][a-z\d+.-]*:/i.freeze
-
- def validate_lazy_metadata
- unless @specification.authors.grep(LAZY_PATTERN).empty?
- error "#{LAZY} is not an author"
- end
-
- unless Array(@specification.email).grep(LAZY_PATTERN).empty?
- error "#{LAZY} is not an email"
- end
-
- if @specification.description =~ LAZY_PATTERN
- error "#{LAZY} is not a description"
- end
-
- if @specification.summary =~ LAZY_PATTERN
- error "#{LAZY} is not a summary"
- end
-
- homepage = @specification.homepage
-
- # Make sure a homepage is valid HTTP/HTTPS URI
- if homepage and not homepage.empty?
- require 'uri'
- begin
- homepage_uri = URI.parse(homepage)
- unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class
- error "\"#{homepage}\" is not a valid HTTP URI"
- end
- rescue URI::InvalidURIError
- error "\"#{homepage}\" is not a valid HTTP URI"
- end
- end
- end
-
- def validate_values
- %w[author homepage summary files].each do |attribute|
- validate_attribute_present(attribute)
- end
-
- if @specification.description == @specification.summary
- warning "description and summary are identical"
- end
-
- # TODO: raise at some given date
- warning "deprecated autorequire specified" if @specification.autorequire
-
- @specification.executables.each do |executable|
- validate_shebang_line_in(executable)
- end
-
- @specification.files.select { |f| File.symlink?(f) }.each do |file|
- warning "#{file} is a symlink, which is not supported on all platforms"
- end
- end
-
- def validate_attribute_present(attribute)
- value = @specification.send attribute
- warning("no #{attribute} specified") if value.nil? || value.empty?
- end
-
- def validate_shebang_line_in(executable)
- executable_path = File.join(@specification.bindir, executable)
- return if File.read(executable_path, 2) == '#!'
-
- warning "#{executable_path} is missing #! line"
- end
-
- def validate_removed_attributes # :nodoc:
- @specification.removed_method_calls.each do |attr|
- warning("#{attr} is deprecated and ignored. Please remove this from your gemspec to ensure that your gem continues to build in the future.")
- end
- end
-
- def warning(statement) # :nodoc:
- @warnings += 1
-
- alert_warning statement
- end
-
- def error(statement) # :nodoc:
- raise Gem::InvalidSpecificationException, statement
- ensure
- alert_warning help_text
- end
-
- def help_text # :nodoc:
- "See https://guides.rubygems.org/specification-reference/ for help"
- end
-
-end
diff --git a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem b/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem
deleted file mode 100644
index f4ce4ca43d..0000000000
--- a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
-A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
-b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
-MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
-YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
-aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
-jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
-xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
-1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
-snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
-U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
-9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
-BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
-AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
-yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
-38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
-AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
-DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
-HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
------END CERTIFICATE-----
diff --git a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem b/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem
deleted file mode 100644
index 8afb219058..0000000000
--- a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G
-A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp
-Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4
-MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG
-A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI
-hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8
-RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT
-gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm
-KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd
-QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ
-XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw
-DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o
-LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU
-RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp
-jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK
-6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX
-mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs
-Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH
-WD9f
------END CERTIFICATE-----
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 959030fd54..ae2effbc84 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -5,15 +5,17 @@
# information.
class Gem::StubSpecification < Gem::BasicSpecification
-
# :nodoc:
- PREFIX = "# stub: ".freeze
+ PREFIX = "# stub: "
- # :nodoc:
- OPEN_MODE = 'r:UTF-8:-'.freeze
+ OPEN_MODE = # :nodoc:
+ if Object.const_defined? :Encoding then
+ 'r:UTF-8:-'
+ else
+ 'r'
+ end
class StubLine # :nodoc: all
-
attr_reader :name, :version, :platform, :require_paths, :extensions,
:full_name
@@ -24,7 +26,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
'lib' => 'lib'.freeze,
'test' => 'test'.freeze,
'ext' => 'ext'.freeze,
- }.freeze
+ }
# These are common require path lists. This hash is used to optimize
# and consolidate require_path objects. Most specs just specify "lib"
@@ -32,9 +34,9 @@ class Gem::StubSpecification < Gem::BasicSpecification
# a require path list for that case.
REQUIRE_PATH_LIST = { # :nodoc:
'lib' => ['lib'].freeze
- }.freeze
+ }
- def initialize(data, extensions)
+ def initialize data, extensions
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
@name = parts[0].freeze
@version = if Gem::Version.correct?(parts[1])
@@ -52,26 +54,25 @@ class Gem::StubSpecification < Gem::BasicSpecification
end
path_list = parts.last
- @require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! do |x|
+ @require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! { |x|
REQUIRE_PATHS[x] || x
- end
+ }
end
-
end
- def self.default_gemspec_stub(filename, base_dir, gems_dir)
+ def self.default_gemspec_stub filename, base_dir, gems_dir
new filename, base_dir, gems_dir, true
end
- def self.gemspec_stub(filename, base_dir, gems_dir)
+ def self.gemspec_stub filename, base_dir, gems_dir
new filename, base_dir, gems_dir, false
end
attr_reader :base_dir, :gems_dir
- def initialize(filename, base_dir, gems_dir, default_gem)
+ def initialize filename, base_dir, gems_dir, default_gem
super()
- filename.tap(&Gem::UNTAINT)
+ filename.untaint
self.loaded_from = filename
@data = nil
@@ -113,11 +114,12 @@ class Gem::StubSpecification < Gem::BasicSpecification
begin
saved_lineno = $.
- File.open loaded_from, OPEN_MODE do |file|
+ # TODO It should be use `File.open`, but bundler-1.16.1 example expects Kernel#open.
+ open loaded_from, OPEN_MODE do |file|
begin
file.readline # discard encoding line
stubline = file.readline.chomp
- if stubline.start_with?(PREFIX)
+ if stubline.start_with?(PREFIX) then
extensions = if /\A#{PREFIX}/ =~ file.readline.chomp
$'.split "\0"
else
@@ -187,7 +189,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
# The full Gem::Specification for this gem, loaded from evalling its gemspec
def to_spec
- @spec ||= if @data
+ @spec ||= if @data then
loaded = Gem.loaded_specs[name]
loaded if loaded && loaded.version == version
end
diff --git a/lib/rubygems/syck_hack.rb b/lib/rubygems/syck_hack.rb
index 0d87c71df4..051483eac8 100644
--- a/lib/rubygems/syck_hack.rb
+++ b/lib/rubygems/syck_hack.rb
@@ -40,13 +40,11 @@ module YAML # :nodoc:
# should.
module Syck
class DefaultKey
-
remove_method :to_s rescue nil
def to_s
'='
end
-
end
end
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index c6f5f29d4e..39aa4fc9a7 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
+# TODO: $SAFE = 1
-require 'rubygems'
+begin
+ gem 'minitest', '~> 4.0'
+rescue NoMethodError, Gem::LoadError
+ # for ruby tests
+end
-# If bundler gemspec exists, add to stubs
-bundler_gemspec = File.expand_path("../../../bundler/bundler.gemspec", __FILE__)
-if File.exist?(bundler_gemspec)
- Gem::Specification.dirs.unshift File.dirname(bundler_gemspec)
- Gem::Specification.class_variable_set :@@stubs, nil
- Gem::Specification.stubs
- Gem::Specification.dirs.shift
+if defined? Gem::QuickLoader
+ Gem::QuickLoader.load_full_rubygems_library
+else
+ require 'rubygems'
end
begin
- gem 'minitest', '~> 5.0'
+ gem 'minitest'
rescue Gem::LoadError
end
-begin
- require 'simplecov'
- SimpleCov.start do
- add_filter "/test/"
- add_filter "/bundler/"
- add_filter "/lib/rubygems/resolver/molinillo"
- end
-rescue LoadError
+# We have to load these up front because otherwise we'll try to load
+# them while we're testing rubygems, and thus we can't actually load them.
+unless Gem::Dependency.new('rdoc', '>= 3.10').matching_specs.empty?
+ gem 'rdoc'
+ gem 'json'
end
-require 'bundler'
-
+if Gem::USE_BUNDLER_FOR_GEMDEPS
+ require 'bundler'
+end
require 'minitest/autorun'
require 'rubygems/deprecate'
@@ -65,7 +65,7 @@ module Gem
# Allows setting path to Ruby. This method is available when requiring
# 'rubygems/test_case'
- def self.ruby=(ruby)
+ def self.ruby= ruby
@ruby = ruby
end
@@ -83,10 +83,10 @@ end
# gem-related behavior in a sandbox. Through RubyGemTestCase you can install
# and uninstall gems, fetch remote gems through a stub fetcher and be assured
# your normal set of gems is not affected.
+#
+# Tests are always run at a safe level of 1.
-class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase)
-
- extend Gem::Deprecate
+class Gem::TestCase < MiniTest::Unit::TestCase
attr_accessor :fetcher # :nodoc:
@@ -94,11 +94,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
attr_accessor :uri # :nodoc:
- TEST_PATH = ENV.fetch('RUBYGEMS_TEST_PATH', File.expand_path('../../../test/rubygems', __FILE__))
-
- SPECIFICATIONS = File.expand_path(File.join(TEST_PATH, "specifications"), __FILE__)
-
- def assert_activate(expected, *specs)
+ def assert_activate expected, *specs
specs.each do |spec|
case spec
when String then
@@ -116,106 +112,30 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
# TODO: move to minitest
- def assert_path_exists(path, msg = nil)
+ def assert_path_exists path, msg = nil
msg = message(msg) { "Expected path '#{path}' to exist" }
assert File.exist?(path), msg
end
- def assert_directory_exists(path, msg = nil)
- msg = message(msg) { "Expected path '#{path}' to be a directory" }
- assert_path_exists path
- assert File.directory?(path), msg
- end
-
##
# Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
# the original value when the block ends
- def enable_shared(value)
+ def enable_shared value
enable_shared = RbConfig::CONFIG['ENABLE_SHARED']
RbConfig::CONFIG['ENABLE_SHARED'] = value
yield
ensure
- if enable_shared
+ if enable_shared then
RbConfig::CONFIG['enable_shared'] = enable_shared
else
RbConfig::CONFIG.delete 'enable_shared'
end
end
- ##
- # Sets the vendordir entry in RbConfig::CONFIG to +value+ and restores the
- # original value when the block ends
- #
- def vendordir(value)
- vendordir = RbConfig::CONFIG['vendordir']
-
- if value
- RbConfig::CONFIG['vendordir'] = value
- else
- RbConfig::CONFIG.delete 'vendordir'
- end
-
- yield
- ensure
- if vendordir
- RbConfig::CONFIG['vendordir'] = vendordir
- else
- RbConfig::CONFIG.delete 'vendordir'
- end
- end
-
- ##
- # Sets the bindir entry in RbConfig::CONFIG to +value+ and restores the
- # original value when the block ends
- #
- def bindir(value)
- with_clean_path_to_ruby do
- bindir = RbConfig::CONFIG['bindir']
-
- if value
- RbConfig::CONFIG['bindir'] = value
- else
- RbConfig::CONFIG.delete 'bindir'
- end
-
- begin
- yield
- ensure
- if bindir
- RbConfig::CONFIG['bindir'] = bindir
- else
- RbConfig::CONFIG.delete 'bindir'
- end
- end
- end
- end
-
- ##
- # Sets the EXEEXT entry in RbConfig::CONFIG to +value+ and restores the
- # original value when the block ends
- #
- def exeext(value)
- exeext = RbConfig::CONFIG['EXEEXT']
-
- if value
- RbConfig::CONFIG['EXEEXT'] = value
- else
- RbConfig::CONFIG.delete 'EXEEXT'
- end
-
- yield
- ensure
- if exeext
- RbConfig::CONFIG['EXEEXT'] = exeext
- else
- RbConfig::CONFIG.delete 'EXEEXT'
- end
- end
-
# TODO: move to minitest
- def refute_path_exists(path, msg = nil)
+ def refute_path_exists path, msg = nil
msg = message(msg) { "Expected path '#{path}' to not exist" }
refute File.exist?(path), msg
end
@@ -250,19 +170,19 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
def assert_contains_make_command(target, output, msg = nil)
if output.match(/\n/)
- msg = message(msg) do
+ msg = message(msg) {
'Expected output containing make command "%s": %s' % [
('%s %s' % [make_command, target]).rstrip,
output.inspect
]
- end
+ }
else
- msg = message(msg) do
+ msg = message(msg) {
'Expected make command "%s": %s' % [
('%s %s' % [make_command, target]).rstrip,
output.inspect
]
- end
+ }
end
assert scan_make_command_lines(output).any? { |line|
@@ -282,6 +202,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
undef_method :default_test if instance_methods.include? 'default_test' or
instance_methods.include? :default_test
+ @@project_dir = Dir.pwd.untaint unless defined?(@@project_dir)
+
+ @@initial_reset = false
+
##
# #setup prepares a sandboxed location to install gems. All installs are
# directed to a temporary directory. All install plugins are removed.
@@ -289,33 +213,61 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# If the +RUBY+ environment variable is set the given path is used for
# Gem::ruby. The local platform is set to <tt>i386-mswin32</tt> for Windows
# or <tt>i686-darwin8.10.1</tt> otherwise.
+ #
+ # If the +KEEP_FILES+ environment variable is set the files will not be
+ # removed from <tt>/tmp/test_rubygems_#{$$}.#{Time.now.to_i}</tt>.
def setup
super
- @orig_env = ENV.to_hash
+ @orig_gem_home = ENV['GEM_HOME']
+ @orig_gem_path = ENV['GEM_PATH']
+ @orig_gem_vendor = ENV['GEM_VENDOR']
+ @orig_gem_spec_cache = ENV['GEM_SPEC_CACHE']
+ @orig_rubygems_gemdeps = ENV['RUBYGEMS_GEMDEPS']
+ @orig_bundle_gemfile = ENV['BUNDLE_GEMFILE']
+ @orig_rubygems_host = ENV['RUBYGEMS_HOST']
+ ENV.keys.find_all { |k| k.start_with?('GEM_REQUIREMENT_') }.each do |k|
+ ENV.delete k
+ end
+ @orig_gem_env_requirements = ENV.to_hash
ENV['GEM_VENDOR'] = nil
- ENV['GEMRC'] = nil
- ENV['SOURCE_DATE_EPOCH'] = nil
@current_dir = Dir.pwd
@fetcher = nil
+ if Gem::USE_BUNDLER_FOR_GEMDEPS
+ Bundler.ui = Bundler::UI::Silent.new
+ end
@back_ui = Gem::DefaultUserInteraction.ui
@ui = Gem::MockGemUi.new
# This needs to be a new instance since we call use_ui(@ui) when we want to
# capture output
Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
- tmpdir = File.realpath Dir.tmpdir
- tmpdir.tap(&Gem::UNTAINT)
+ tmpdir = File.expand_path Dir.tmpdir
+ tmpdir.untaint
- @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
- @tempdir.tap(&Gem::UNTAINT)
+ if ENV['KEEP_FILES'] then
+ @tempdir = File.join(tmpdir, "test_rubygems_#{$$}.#{Time.now.to_i}")
+ else
+ @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
+ end
+ @tempdir.untaint
FileUtils.mkdir_p @tempdir
+ # This makes the tempdir consistent on OS X.
+ # File.expand_path Dir.tmpdir #=> "/var/..."
+ # Dir.chdir Dir.tmpdir do File.expand_path '.' end #=> "/private/var/..."
+ # TODO use File#realpath above instead of #expand_path once 1.8 support is
+ # dropped.
+ Dir.chdir @tempdir do
+ @tempdir = File.expand_path '.'
+ @tempdir.untaint
+ end
+
# This makes the tempdir consistent on Windows.
# Dir.tmpdir may return short path name, but Dir[Dir.tmpdir] returns long
# path name. https://bugs.ruby-lang.org/issues/10819
@@ -324,14 +276,14 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# Short and long path name is specific to Windows filesystem.
if win_platform?
@tempdir = Dir[@tempdir][0]
- @tempdir.tap(&Gem::UNTAINT)
+ @tempdir.untaint
end
@gemhome = File.join @tempdir, 'gemhome'
@userhome = File.join @tempdir, 'userhome'
ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache'
- @orig_ruby = if ENV['RUBY']
+ @orig_ruby = if ENV['RUBY'] then
ruby = Gem.ruby
Gem.ruby = ENV['RUBY']
ruby
@@ -342,21 +294,13 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
Gem.ensure_gem_subdirectories @gemhome
@orig_LOAD_PATH = $LOAD_PATH.dup
- $LOAD_PATH.map! do |s|
- expand_path = File.realpath(s) rescue File.expand_path(s)
- if expand_path != s
- expand_path.tap(&Gem::UNTAINT)
- if s.instance_variable_defined?(:@gem_prelude_index)
- expand_path.instance_variable_set(:@gem_prelude_index, expand_path)
- end
- expand_path.freeze if s.frozen?
- s = expand_path
- end
- s
- end
+ $LOAD_PATH.map! { |s|
+ (expand_path = File.expand_path(s)) == s ? s : expand_path.untaint
+ }
Dir.chdir @tempdir
+ @orig_ENV_HOME = ENV['HOME']
ENV['HOME'] = @userhome
Gem.instance_variable_set :@user_home, nil
Gem.instance_variable_set :@gemdeps, nil
@@ -367,27 +311,33 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
FileUtils.mkdir_p @gemhome
FileUtils.mkdir_p @userhome
+ @orig_gem_private_key_passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE']
ENV['GEM_PRIVATE_KEY_PASSPHRASE'] = PRIVATE_KEY_PASSPHRASE
@default_dir = File.join @tempdir, 'default'
@default_spec_dir = File.join @default_dir, "specifications", "default"
- if Gem.java_platform?
- @orig_default_gem_home = RbConfig::CONFIG['default_gem_home']
- RbConfig::CONFIG['default_gem_home'] = @default_dir
- else
- Gem.instance_variable_set(:@default_dir, @default_dir)
- end
+ Gem.instance_variable_set :@default_dir, @default_dir
FileUtils.mkdir_p @default_spec_dir
- Gem::Specification.unresolved_deps.clear
+ # We use Gem::Specification.reset the first time only so that if there
+ # are unresolved deps that leak into the whole test suite, they're at least
+ # reported once.
+ if @@initial_reset
+ Gem::Specification.unresolved_deps.clear # done to avoid cross-test warnings
+ else
+ @@initial_reset = true
+ Gem::Specification.reset
+ end
Gem.use_paths(@gemhome)
Gem::Security.reset
Gem.loaded_specs.clear
- Gem.instance_variable_set(:@activated_gem_paths, 0)
Gem.clear_default_specs
- Bundler.reset!
+ Gem::Specification.unresolved_deps.clear
+ if Gem::USE_BUNDLER_FOR_GEMDEPS
+ Bundler.reset!
+ end
Gem.configuration.verbose = true
Gem.configuration.update_sources = true
@@ -400,6 +350,8 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
Gem.searcher = nil
Gem::SpecFetcher.fetcher = nil
+ @orig_BASERUBY = RbConfig::CONFIG['BASERUBY']
+ RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name']
@orig_arch = RbConfig::CONFIG['arch']
@@ -409,18 +361,13 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
util_set_arch 'i686-darwin8.10.1'
end
- @orig_hooks = {}
- %w[post_install_hooks done_installing_hooks post_uninstall_hooks pre_uninstall_hooks pre_install_hooks pre_reset_hooks post_reset_hooks post_build_hooks].each do |name|
- @orig_hooks[name] = Gem.send(name).dup
- end
-
@marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
@orig_LOADED_FEATURES = $LOADED_FEATURES.dup
end
##
# #teardown restores the process to its original state and removes the
- # tempdir
+ # tempdir unless the +KEEP_FILES+ environment variable was set.
def teardown
$LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
@@ -437,34 +384,50 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
end
+ if @orig_BASERUBY
+ RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY
+ else
+ RbConfig::CONFIG.delete('BASERUBY')
+ end
RbConfig::CONFIG['arch'] = @orig_arch
- if defined? Gem::RemoteFetcher
+ if defined? Gem::RemoteFetcher then
Gem::RemoteFetcher.fetcher = nil
end
Dir.chdir @current_dir
- FileUtils.rm_rf @tempdir
+ FileUtils.rm_rf @tempdir unless ENV['KEEP_FILES']
+
+ ENV.clear
+ @orig_gem_env_requirements.each do |k,v|
+ ENV[k] = v
+ end
- ENV.replace(@orig_env)
+ ENV['GEM_HOME'] = @orig_gem_home
+ ENV['GEM_PATH'] = @orig_gem_path
+ ENV['GEM_VENDOR'] = @orig_gem_vendor
+ ENV['GEM_SPEC_CACHE'] = @orig_gem_spec_cache
+ ENV['RUBYGEMS_GEMDEPS'] = @orig_rubygems_gemdeps
+ ENV['BUNDLE_GEMFILE'] = @orig_bundle_gemfile
+ ENV['RUBYGEMS_HOST'] = @orig_rubygems_host
Gem.ruby = @orig_ruby if @orig_ruby
- if Gem.java_platform?
- RbConfig::CONFIG['default_gem_home'] = @orig_default_gem_home
+ if @orig_ENV_HOME then
+ ENV['HOME'] = @orig_ENV_HOME
else
- Gem.instance_variable_set :@default_dir, nil
+ ENV.delete 'HOME'
end
+ Gem.instance_variable_set :@default_dir, nil
+
+ ENV['GEM_PRIVATE_KEY_PASSPHRASE'] = @orig_gem_private_key_passphrase
+
Gem::Specification._clear_load_cache
Gem::Specification.unresolved_deps.clear
Gem::refresh
- @orig_hooks.each do |name, hooks|
- Gem.send(name).replace hooks
- end
-
@back_ui.close
end
@@ -511,7 +474,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
#
# Yields the +specification+ to the block, if given
- def git_gem(name = 'a', version = 1)
+ def git_gem name = 'a', version = 1
have_git?
directory = File.join 'git', name
@@ -532,7 +495,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
head = nil
Dir.chdir directory do
- unless File.exist? '.git'
+ unless File.exist? '.git' then
system @git, 'init', '--quiet'
system @git, 'config', 'user.name', 'RubyGems Tests'
system @git, 'config', 'user.email', 'rubygems@example'
@@ -555,7 +518,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
skip 'cannot find git executable, use GIT environment variable to set'
end
- def in_path?(executable) # :nodoc:
+ def in_path? executable # :nodoc:
return true if %r%\A([A-Z]:|/)% =~ executable and File.exist? executable
ENV['PATH'].split(File::PATH_SEPARATOR).any? do |directory|
@@ -566,19 +529,19 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
##
# Builds and installs the Gem::Specification +spec+
- def install_gem(spec, options = {})
+ def install_gem spec, options = {}
require 'rubygems/installer'
gem = File.join @tempdir, "gems", "#{spec.full_name}.gem"
- unless File.exist? gem
+ unless File.exist? gem then
use_ui Gem::MockGemUi.new do
Dir.chdir @tempdir do
Gem::Package.build spec
end
end
- gem = File.join(@tempdir, File.basename(spec.cache_file)).tap(&Gem::UNTAINT)
+ gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
end
Gem::Installer.at(gem, options.merge({:wrappers => true})).install
@@ -587,20 +550,32 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
##
# Builds and installs the Gem::Specification +spec+ into the user dir
- def install_gem_user(spec)
+ def install_gem_user spec
install_gem spec, :user_install => true
end
##
# Uninstalls the Gem::Specification +spec+
- def uninstall_gem(spec)
+ def uninstall_gem spec
require 'rubygems/uninstaller'
- Class.new(Gem::Uninstaller) do
- def ask_if_ok(spec)
+ Class.new(Gem::Uninstaller) {
+ def ask_if_ok spec
true
end
- end.new(spec.name, :executables => true, :user_install => true).uninstall
+ }.new(spec.name, :executables => true, :user_install => true).uninstall
+ end
+
+ ##
+ # creates a temporary directory with hax
+ # TODO: deprecate and remove
+
+ def create_tmpdir
+ tmpdir = nil
+ Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
+ tmpdir = File.join tmpdir, "test_rubygems_#{$$}"
+ FileUtils.mkdir_p tmpdir
+ return tmpdir
end
##
@@ -609,7 +584,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
def mu_pp(obj)
s = String.new
s = PP.pp obj, s
- s = s.force_encoding(Encoding.default_external)
+ s = s.force_encoding(Encoding.default_external) if defined? Encoding
s.chomp
end
@@ -617,7 +592,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# Reads a Marshal file at +path+
def read_cache(path)
- File.open path.dup.tap(&Gem::UNTAINT), 'rb' do |io|
+ File.open path.dup.untaint, 'rb' do |io|
Marshal.load io.read
end
end
@@ -680,7 +655,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
io.write spec.to_ruby_for_cache
end
- spec.loaded_from = written_path
+ spec.loaded_from = spec.loaded_from = written_path
Gem::Specification.reset
@@ -688,6 +663,13 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
##
+ # TODO: remove in RubyGems 3.0
+
+ def quick_spec name, version = '2' # :nodoc:
+ util_spec name, version
+ end
+
+ ##
# Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
# 'cache'</tt>. Automatically creates files based on +spec.files+
@@ -699,10 +681,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
spec.files.each do |file|
next if File.exist? file
FileUtils.mkdir_p File.dirname(file)
-
- File.open file, 'w' do |fp|
- fp.puts "# #{file}"
- end
+ File.open file, 'w' do |fp| fp.puts "# #{file}" end
end
use_ui Gem::MockGemUi.new do
@@ -723,7 +702,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# Removes all installed gems from +@gemhome+.
def util_clear_gems
- FileUtils.rm_rf File.join(@gemhome, "gems")
+ FileUtils.rm_rf File.join(@gemhome, "gems") # TODO: use Gem::Dirs
FileUtils.mkdir File.join(@gemhome, "gems")
FileUtils.rm_rf File.join(@gemhome, "specifications")
FileUtils.mkdir File.join(@gemhome, "specifications")
@@ -777,12 +756,54 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
old_loaded_features = $LOADED_FEATURES.dup
yield
ensure
- prefix = File.dirname(__FILE__) + "/"
- new_features = ($LOADED_FEATURES - old_loaded_features)
- old_loaded_features.concat(new_features.select {|f| f.rindex(prefix, 0)})
$LOADED_FEATURES.replace old_loaded_features
end
+ ##
+ # new_spec is deprecated as it is never used.
+ #
+ # TODO: remove in RubyGems 3.0
+
+ def new_spec name, version, deps = nil, *files # :nodoc:
+ require 'rubygems/specification'
+
+ spec = Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = name
+ s.version = version
+ s.author = 'A User'
+ s.email = 'example@example.com'
+ s.homepage = 'http://example.com'
+ s.summary = "this is a summary"
+ s.description = "This is a test description"
+
+ Array(deps).each do |n, req|
+ s.add_dependency n, (req || '>= 0')
+ end
+
+ s.files.push(*files) unless files.empty?
+
+ yield s if block_given?
+ end
+
+ spec.loaded_from = spec.spec_file
+
+ unless files.empty? then
+ write_file spec.spec_file do |io|
+ io.write spec.to_ruby_for_cache
+ end
+
+ util_build_gem spec
+
+ cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
+ FileUtils.mkdir_p File.dirname cache_file
+ FileUtils.mv spec.cache_file, cache_file
+ FileUtils.rm spec.spec_file
+ end
+
+ spec
+ end
+
def new_default_spec(name, version, deps = nil, *files)
spec = util_spec name, version, deps
@@ -790,7 +811,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
spec.files = files
lib_dir = File.join(@tempdir, "default_gems", "lib")
- lib_dir.instance_variable_set(:@gem_prelude_index, lib_dir)
$LOAD_PATH.unshift(lib_dir)
files.each do |file|
rb_path = File.join(lib_dir, file)
@@ -807,7 +827,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# Creates a spec with +name+, +version+. +deps+ can specify the dependency
# or a +block+ can be given for full customization of the specification.
- def util_spec(name, version = 2, deps = nil, *files) # :yields: specification
+ def util_spec name, version = 2, deps = nil # :yields: specification
raise "deps or block, not both" if deps and block_given?
spec = Gem::Specification.new do |s|
@@ -820,12 +840,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
s.summary = "this is a summary"
s.description = "This is a test description"
- s.files.push(*files) unless files.empty?
-
yield s if block_given?
end
- if deps
+ if deps then
# Since Hash#each is unordered in 1.8, sort the keys and iterate that
# way so the tests are deterministic on all implementations.
deps.keys.sort.each do |n|
@@ -833,18 +851,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
end
- unless files.empty?
- write_file spec.spec_file do |io|
- io.write spec.to_ruby_for_cache
- end
-
- util_build_gem spec
-
- cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
- FileUtils.mkdir_p File.dirname cache_file
- FileUtils.mv spec.cache_file, cache_file
- FileUtils.rm spec.spec_file
- end
+ Gem::Specification.reset
return spec
end
@@ -856,7 +863,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# location are returned.
def util_gem(name, version, deps = nil, &block)
- if deps
+ # TODO: deprecate
+ raise "deps or block, not both" if deps and block
+
+ if deps then
block = proc do |s|
# Since Hash#each is unordered in 1.8, sort
# the keys and iterate that way so the tests are
@@ -946,7 +956,7 @@ Also, a list:
s.add_dependency 'x', '>= 1'
end
- @pl1 = quick_gem 'pl', '1' do |s| # l for legacy
+ @pl1 = quick_gem 'pl', '1' do |s| # l for legacy
s.files = %w[lib/code.rb]
s.require_paths = %w[lib]
s.platform = Gem::Platform.new 'i386-linux'
@@ -986,12 +996,35 @@ Also, a list:
Gem.instance_variable_set :@platforms, nil
Gem::Platform.instance_variable_set :@local, nil
- yield if block_given?
-
platform
end
##
+ # Sets up a fake fetcher using the gems from #util_make_gems. Optionally
+ # additional +prerelease+ gems may be included.
+ #
+ # Gems created by this method may be fetched using Gem::RemoteFetcher.
+
+ def util_setup_fake_fetcher(prerelease = false)
+ require 'zlib'
+ require 'socket'
+ require 'rubygems/remote_fetcher'
+
+ @fetcher = Gem::FakeFetcher.new
+
+ util_make_gems(prerelease)
+ Gem::Specification.reset
+
+ @all_gems = [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2].sort
+ @all_gem_names = @all_gems.map { |gem| gem.full_name }
+
+ gem_names = [@a1.full_name, @a2.full_name, @a3a.full_name, @b2.full_name]
+ @gem_names = gem_names.sort.join("\n")
+
+ Gem::RemoteFetcher.fetcher = @fetcher
+ end
+
+ ##
# Add +spec+ to +@fetcher+ serving the data in the file +path+.
# +repo+ indicates which repo to make +spec+ appear to be in.
@@ -1002,6 +1035,7 @@ Also, a list:
##
# Sets up Gem::SpecFetcher to return information from the gems in +specs+.
+ # Best used with +@all_gems+ from #util_setup_fake_fetcher.
def util_setup_spec_fetcher(*specs)
all_specs = Gem::Specification.to_a + specs
@@ -1028,7 +1062,7 @@ Also, a list:
end
# HACK for test_download_to_cache
- unless Gem::RemoteFetcher === @fetcher
+ unless Gem::RemoteFetcher === @fetcher then
v = Gem.marshal_version
specs = all.map { |spec| spec.name_tuple }
@@ -1067,50 +1101,35 @@ Also, a list:
Zlib::Deflate.deflate data
end
- def util_set_RUBY_VERSION(version, patchlevel = nil, revision = nil, description = nil, engine = "ruby", engine_version = nil)
- if Gem.instance_variables.include? :@ruby_version
+ def util_set_RUBY_VERSION(version, patchlevel = nil, revision = nil)
+ if Gem.instance_variables.include? :@ruby_version or
+ Gem.instance_variables.include? '@ruby_version' then
Gem.send :remove_instance_variable, :@ruby_version
end
- @RUBY_VERSION = RUBY_VERSION
- @RUBY_PATCHLEVEL = RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
- @RUBY_REVISION = RUBY_REVISION if defined?(RUBY_REVISION)
- @RUBY_DESCRIPTION = RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
- @RUBY_ENGINE = RUBY_ENGINE
- @RUBY_ENGINE_VERSION = RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
+ @RUBY_VERSION = RUBY_VERSION
+ @RUBY_PATCHLEVEL = RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
+ @RUBY_REVISION = RUBY_REVISION if defined?(RUBY_REVISION)
- util_clear_RUBY_VERSION
+ Object.send :remove_const, :RUBY_VERSION
+ Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
+ Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
- Object.const_set :RUBY_VERSION, version
- Object.const_set :RUBY_PATCHLEVEL, patchlevel if patchlevel
- Object.const_set :RUBY_REVISION, revision if revision
- Object.const_set :RUBY_DESCRIPTION, description if description
- Object.const_set :RUBY_ENGINE, engine
- Object.const_set :RUBY_ENGINE_VERSION, engine_version if engine_version
+ Object.const_set :RUBY_VERSION, version
+ Object.const_set :RUBY_PATCHLEVEL, patchlevel if patchlevel
+ Object.const_set :RUBY_REVISION, revision if revision
end
def util_restore_RUBY_VERSION
- util_clear_RUBY_VERSION
+ Object.send :remove_const, :RUBY_VERSION
+ Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
+ Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
- Object.const_set :RUBY_VERSION, @RUBY_VERSION
- Object.const_set :RUBY_PATCHLEVEL, @RUBY_PATCHLEVEL if
+ Object.const_set :RUBY_VERSION, @RUBY_VERSION
+ Object.const_set :RUBY_PATCHLEVEL, @RUBY_PATCHLEVEL if
defined?(@RUBY_PATCHLEVEL)
- Object.const_set :RUBY_REVISION, @RUBY_REVISION if
+ Object.const_set :RUBY_REVISION, @RUBY_REVISION if
defined?(@RUBY_REVISION)
- Object.const_set :RUBY_DESCRIPTION, @RUBY_DESCRIPTION if
- defined?(@RUBY_DESCRIPTION)
- Object.const_set :RUBY_ENGINE, @RUBY_ENGINE
- Object.const_set :RUBY_ENGINE_VERSION, @RUBY_ENGINE_VERSION if
- defined?(@RUBY_ENGINE_VERSION)
- end
-
- def util_clear_RUBY_VERSION
- Object.send :remove_const, :RUBY_VERSION
- Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
- Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
- Object.send :remove_const, :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
- Object.send :remove_const, :RUBY_ENGINE
- Object.send :remove_const, :RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
end
##
@@ -1128,20 +1147,6 @@ Also, a list:
end
##
- # Is this test being run on a Java platform?
-
- def self.java_platform?
- Gem.java_platform?
- end
-
- ##
- # Is this test being run on a Java platform?
-
- def java_platform?
- Gem.java_platform?
- end
-
- ##
# Returns whether or not we're on a version of Ruby built with VC++ (or
# Borland) versus Cygwin, Mingw, etc.
@@ -1254,43 +1259,14 @@ Also, a list:
end
end
- def with_clean_path_to_ruby
- orig_ruby = Gem.ruby
-
- Gem.instance_variable_set :@ruby, nil
-
- yield
- ensure
- Gem.instance_variable_set :@ruby, orig_ruby
- end
-
- class << self
-
- # :nodoc:
- ##
- # Return the join path, with escaping backticks, dollars, and
- # double-quotes. Unlike `shellescape`, equal-sign is not escaped.
- private
-
- def escape_path(*path)
- path = File.join(*path)
- if %r'\A[-+:/=@,.\w]+\z' =~ path
- path
- else
- "\"#{path.gsub(/[`$"]/, '\\&')}\""
- end
- end
-
- end
-
@@ruby = rubybin
- @@good_rake = "#{rubybin} #{escape_path(TEST_PATH, 'good_rake.rb')}"
- @@bad_rake = "#{rubybin} #{escape_path(TEST_PATH, 'bad_rake.rb')}"
+ @@good_rake = "#{rubybin} \"#{File.expand_path('../../../test/rubygems/good_rake.rb', __FILE__)}\""
+ @@bad_rake = "#{rubybin} \"#{File.expand_path('../../../test/rubygems/bad_rake.rb', __FILE__)}\""
##
# Construct a new Gem::Dependency.
- def dep(name, *requirements)
+ def dep name, *requirements
Gem::Dependency.new name, *requirements
end
@@ -1299,10 +1275,10 @@ Also, a list:
# Gem::Dependency +dep+, a +from_name+ and +from_version+ requesting the
# dependency and a +parent+ DependencyRequest
- def dependency_request(dep, from_name, from_version, parent = nil)
+ def dependency_request dep, from_name, from_version, parent = nil
remote = Gem::Source.new @uri
- unless parent
+ unless parent then
parent_dep = dep from_name, from_version
parent = Gem::Resolver::DependencyRequest.new parent_dep, nil
end
@@ -1317,7 +1293,7 @@ Also, a list:
##
# Constructs a new Gem::Requirement.
- def req(*requirements)
+ def req *requirements
return requirements.first if Gem::Requirement === requirements.first
Gem::Requirement.create requirements
end
@@ -1325,7 +1301,7 @@ Also, a list:
##
# Constructs a new Gem::Specification.
- def spec(name, version, &block)
+ def spec name, version, &block
Gem::Specification.new name, v(version), &block
end
@@ -1349,7 +1325,7 @@ Also, a list:
# end
# end
- def spec_fetcher(repository = @gem_repo)
+ def spec_fetcher repository = @gem_repo
Gem::TestCase::SpecFetcherSetup.declare self, repository do |spec_fetcher_setup|
yield spec_fetcher_setup if block_given?
end
@@ -1358,7 +1334,7 @@ Also, a list:
##
# Construct a new Gem::Version.
- def v(string)
+ def v string
Gem::Version.create string
end
@@ -1368,7 +1344,7 @@ Also, a list:
#
# Yields the +specification+ to the block, if given
- def vendor_gem(name = 'a', version = 1)
+ def vendor_gem name = 'a', version = 1
directory = File.join 'vendor', name
FileUtils.mkdir_p directory
@@ -1382,7 +1358,7 @@ Also, a list:
#
# Yields the +specification+ to the block, if given
- def save_gemspec(name = 'a', version = 1, directory = '.')
+ def save_gemspec name = 'a', version = 1, directory = '.'
vendor_spec = Gem::Specification.new name, version do |specification|
yield specification if block_given?
end
@@ -1419,7 +1395,7 @@ Also, a list:
##
# Adds +spec+ to this set.
- def add(spec)
+ def add spec
@specs << spec
end
@@ -1443,7 +1419,7 @@ Also, a list:
# Loads a Gem::Specification from this set which has the given +name+,
# version +ver+, +platform+. The +source+ is ignored.
- def load_spec(name, ver, platform, source)
+ def load_spec name, ver, platform, source
dep = Gem::Dependency.new name, ver
spec = find_spec dep
@@ -1452,15 +1428,14 @@ Also, a list:
end
end
- def prefetch(reqs) # :nodoc:
+ def prefetch reqs # :nodoc:
end
-
end
##
# Loads certificate named +cert_name+ from <tt>test/rubygems/</tt>.
- def self.load_cert(cert_name)
+ def self.load_cert cert_name
cert_file = cert_path cert_name
cert = File.read cert_file
@@ -1472,20 +1447,22 @@ Also, a list:
# Returns the path to the certificate named +cert_name+ from
# <tt>test/rubygems/</tt>.
- def self.cert_path(cert_name)
- if 32 == (Time.at(2**32) rescue 32)
- cert_file = "#{TEST_PATH}/#{cert_name}_cert_32.pem"
+ def self.cert_path cert_name
+ if 32 == (Time.at(2**32) rescue 32) then
+ cert_file =
+ File.expand_path "../../../test/rubygems/#{cert_name}_cert_32.pem",
+ __FILE__
return cert_file if File.exist? cert_file
end
- "#{TEST_PATH}/#{cert_name}_cert.pem"
+ File.expand_path "../../../test/rubygems/#{cert_name}_cert.pem", __FILE__
end
##
# Loads an RSA private key named +key_name+ with +passphrase+ in <tt>test/rubygems/</tt>
- def self.load_key(key_name, passphrase = nil)
+ def self.load_key key_name, passphrase = nil
key_file = key_path key_name
key = File.read key_file
@@ -1496,14 +1473,14 @@ Also, a list:
##
# Returns the path to the key named +key_name+ from <tt>test/rubygems</tt>
- def self.key_path(key_name)
- "#{TEST_PATH}/#{key_name}_key.pem"
+ def self.key_path key_name
+ File.expand_path "../../../test/rubygems/#{key_name}_key.pem", __FILE__
end
# :stopdoc:
# only available in RubyGems tests
- PRIVATE_KEY_PASSPHRASE = 'Foo bar'.freeze
+ PRIVATE_KEY_PASSPHRASE = 'Foo bar'
begin
PRIVATE_KEY = load_key 'private'
@@ -1552,3 +1529,10 @@ rescue LoadError, Gem::LoadError
end
require 'rubygems/test_utilities'
+tmpdirs = []
+tmpdirs << (ENV['GEM_HOME'] = Dir.mktmpdir("home"))
+tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path"))
+pid = $$
+END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
+Gem.clear_paths
+Gem.loaded_specs.clear
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 69ff05370e..83c9d2d0fe 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -13,13 +13,6 @@ require 'rubygems/remote_fetcher'
# @fetcher.data['http://gems.example.com/yaml'] = source_index.to_yaml
# Gem::RemoteFetcher.fetcher = @fetcher
#
-# use nested array if multiple response is needed
-#
-# @fetcher.data['http://gems.example.com/sequence'] = [['Success', 200, 'OK'], ['Failed', 401, 'Unauthorized']]
-#
-# @fetcher.fetch_path('http://gems.example.com/sequence') # => ['Success', 200, 'OK']
-# @fetcher.fetch_path('http://gems.example.com/sequence') # => ['Failed', 401, 'Unauthorized']
-#
# # invoke RubyGems code
#
# paths = @fetcher.paths
@@ -32,17 +25,23 @@ class Gem::FakeFetcher
attr_reader :data
attr_reader :last_request
+ attr_reader :api_endpoints
attr_accessor :paths
def initialize
@data = {}
@paths = []
+ @api_endpoints = {}
end
- def find_data(path, nargs = 3)
+ def api_endpoint(uri)
+ @api_endpoints[uri] || uri
+ end
+
+ def find_data(path)
return File.read path.path if URI === path and 'file' == path.scheme
- if URI === path and "URI::#{path.scheme.upcase}" != path.class.name
+ if URI === path and "URI::#{path.scheme.upcase}" != path.class.name then
raise ArgumentError,
"mismatch for scheme #{path.scheme} and class #{path.class}"
end
@@ -51,30 +50,28 @@ class Gem::FakeFetcher
@paths << path
raise ArgumentError, 'need full URI' unless path =~ %r'^https?://'
- unless @data.key? path
+ unless @data.key? path then
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
end
- data = @data[path]
-
- data.flatten! and return data.shift(nargs) if data.respond_to?(:flatten!)
- data
+ @data[path]
end
- def fetch_path(path, mtime = nil, head = false)
+ def fetch_path path, mtime = nil, head = false
data = find_data(path)
- if data.respond_to?(:call)
+ if data.respond_to?(:call) then
data.call
else
- if path.to_s =~ /gz$/ and not data.nil? and not data.empty?
- data = Gem::Util.gunzip data
+ if path.to_s =~ /gz$/ and not data.nil? and not data.empty? then
+ data = Gem.gunzip data
end
+
data
end
end
- def cache_update_path(uri, path = nil, update = true)
+ def cache_update_path uri, path = nil, update = true
if data = fetch_path(uri)
open(path, 'wb') { |io| io.write data } if path and update
data
@@ -96,7 +93,7 @@ class Gem::FakeFetcher
def request(uri, request_class, last_modified = nil)
data = find_data(uri)
- body, code, msg = (data.respond_to?(:call) ? data.call : data)
+ body, code, msg = data
@last_request = request_class.new uri.request_uri
yield @last_request if block_given?
@@ -107,13 +104,21 @@ class Gem::FakeFetcher
response
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 2, '[FakeFetcher', ']' do
q.breakable
q.text 'URIs:'
q.breakable
q.pp @data.keys
+
+ unless @api_endpoints.empty? then
+ q.breakable
+ q.text 'API endpoints:'
+
+ q.breakable
+ q.pp @api_endpoints.keys
+ end
end
end
@@ -123,7 +128,7 @@ class Gem::FakeFetcher
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
- unless @data.key? path
+ unless @data.key? path then
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
end
@@ -132,9 +137,9 @@ class Gem::FakeFetcher
data.respond_to?(:call) ? data.call : data.length
end
- def download(spec, source_uri, install_dir = Gem.dir)
+ def download spec, source_uri, install_dir = Gem.dir
name = File.basename spec.cache_file
- path = if Dir.pwd == install_dir # see fetch_command
+ path = if Dir.pwd == install_dir then # see fetch_command
install_dir
else
File.join install_dir, "cache"
@@ -142,7 +147,7 @@ class Gem::FakeFetcher
path = File.join path, name
- if source_uri =~ /^http/
+ if source_uri =~ /^http/ then
File.open(path, "wb") do |f|
f.write fetch_path(File.join(source_uri, "gems", name))
end
@@ -153,7 +158,7 @@ class Gem::FakeFetcher
path
end
- def download_to_cache(dependency)
+ def download_to_cache dependency
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dependency
return if found.empty?
@@ -196,7 +201,7 @@ class Gem::TestCase::SpecFetcherSetup
# Executes a SpecFetcher setup block. Yields an instance then creates the
# gems and specifications defined in the instance.
- def self.declare(test, repository)
+ def self.declare test, repository
setup = new test, repository
yield setup
@@ -204,7 +209,7 @@ class Gem::TestCase::SpecFetcherSetup
setup.execute
end
- def initialize(test, repository) # :nodoc:
+ def initialize test, repository # :nodoc:
@test = test
@repository = repository
@@ -241,22 +246,21 @@ class Gem::TestCase::SpecFetcherSetup
def execute_operations # :nodoc:
@operations.each do |operation, *arguments|
- block = arguments.pop
case operation
when :gem then
- spec, gem = @test.util_gem(*arguments, &block)
+ spec, gem = @test.util_gem(*arguments, &arguments.pop)
write_spec spec
@gems[spec] = gem
@installed << spec
when :download then
- spec, gem = @test.util_gem(*arguments, &block)
+ spec, gem = @test.util_gem(*arguments, &arguments.pop)
@gems[spec] = gem
@downloaded << spec
when :spec then
- spec = @test.util_spec(*arguments, &block)
+ spec = @test.util_spec(*arguments, &arguments.pop)
write_spec spec
@@ -273,7 +277,7 @@ class Gem::TestCase::SpecFetcherSetup
# The specification will be yielded before gem creation for customization,
# but only the block or the dependencies may be set, not both.
- def gem(name, version, dependencies = nil, &block)
+ def gem name, version, dependencies = nil, &block
@operations << [:gem, name, version, dependencies, block]
end
@@ -284,7 +288,7 @@ class Gem::TestCase::SpecFetcherSetup
# The specification will be yielded before gem creation for customization,
# but only the block or the dependencies may be set, not both.
- def download(name, version, dependencies = nil, &block)
+ def download name, version, dependencies = nil, &block
@operations << [:download, name, version, dependencies, block]
end
@@ -303,7 +307,7 @@ class Gem::TestCase::SpecFetcherSetup
require 'socket'
require 'rubygems/remote_fetcher'
- unless @test.fetcher
+ unless @test.fetcher then
@test.fetcher = Gem::FakeFetcher.new
Gem::RemoteFetcher.fetcher = @test.fetcher
end
@@ -337,11 +341,11 @@ class Gem::TestCase::SpecFetcherSetup
# The specification will be yielded before creation for customization,
# but only the block or the dependencies may be set, not both.
- def spec(name, version, dependencies = nil, &block)
+ def spec name, version, dependencies = nil, &block
@operations << [:spec, name, version, dependencies, block]
end
- def write_spec(spec) # :nodoc:
+ def write_spec spec # :nodoc:
File.open spec.spec_file, 'w' do |io|
io.write spec.to_ruby_for_cache
end
@@ -376,5 +380,5 @@ class TempIO < Tempfile
flush
Gem.read_binary path
end
-
end
+
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb
index 667811192d..b944b62c27 100644
--- a/lib/rubygems/text.rb
+++ b/lib/rubygems/text.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+require 'rubygems'
##
# A collection of text-wrangling methods
@@ -27,7 +28,7 @@ module Gem::Text
work = clean_text(text)
while work.length > wrap do
- if work =~ /^(.{0,#{wrap}})[ \n]/
+ if work =~ /^(.{0,#{wrap}})[ \n]/ then
result << $1.rstrip
work.slice!(0, $&.length)
else
@@ -39,10 +40,10 @@ module Gem::Text
result.join("\n").gsub(/^/, " " * indent)
end
- def min3(a, b, c) # :nodoc:
- if a < b && a < c
+ def min3 a, b, c # :nodoc:
+ if a < b && a < c then
a
- elsif b < c
+ elsif b < c then
b
else
c
@@ -51,7 +52,7 @@ module Gem::Text
# This code is based directly on the Text gem implementation
# Returns a value representing the "cost" of transforming str1 into str2
- def levenshtein_distance(str1, str2)
+ def levenshtein_distance str1, str2
s = str1
t = str2
n = s.length
@@ -64,15 +65,15 @@ module Gem::Text
x = nil
str1.each_char.each_with_index do |char1,i|
- e = i + 1
+ e = i+1
str2.each_char.each_with_index do |char2,j|
cost = (char1 == char2) ? 0 : 1
x = min3(
- d[j + 1] + 1, # insertion
+ d[j+1] + 1, # insertion
e + 1, # deletion
d[j] + cost # substitution
- )
+ )
d[j] = e
e = x
end
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index 20b437d472..89f47a45fe 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -46,7 +46,7 @@ class Gem::Uninstaller
# TODO document the valid options
@gem = gem
@version = options[:version] || Gem::Requirement.default
- @gem_home = File.realpath(options[:install_dir] || Gem.dir)
+ @gem_home = File.expand_path(options[:install_dir] || Gem.dir)
@force_executables = options[:executables]
@force_all = options[:all]
@force_ignore = options[:ignore]
@@ -57,7 +57,7 @@ class Gem::Uninstaller
# Indicate if development dependencies should be checked when
# uninstalling. (default: false)
#
- @check_dev = options[:check_dev]
+ @check_dev = options[:check_dev]
if options[:force]
@force_all = true
@@ -80,7 +80,7 @@ class Gem::Uninstaller
dirs =
Gem::Specification.dirs +
- [Gem.default_specifications_dir]
+ [Gem::Specification.default_specifications_dir]
Gem::Specification.each_spec dirs do |spec|
next unless dependency.matches_spec? spec
@@ -88,18 +88,10 @@ class Gem::Uninstaller
list << spec
end
- if list.empty?
- raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
- end
-
default_specs, list = list.partition do |spec|
spec.default_gem?
end
- default_specs.each do |default_spec|
- say "Gem #{default_spec.full_name} cannot be uninstalled because it is a default gem"
- end
-
list, other_repo_specs = list.partition do |spec|
@gem_home == spec.base_dir or
(@user_install and spec.base_dir == Gem.user_dir)
@@ -107,8 +99,17 @@ class Gem::Uninstaller
list.sort!
- if list.empty?
- return unless other_repo_specs.any?
+ if list.empty? then
+ if other_repo_specs.empty?
+ if default_specs.empty?
+ raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
+ else
+ message =
+ "gem #{@gem.inspect} cannot be uninstalled " +
+ "because it is a default gem"
+ raise Gem::InstallError, message
+ end
+ end
other_repos = other_repo_specs.map { |spec| spec.base_dir }.uniq
@@ -118,22 +119,22 @@ class Gem::Uninstaller
}
raise Gem::InstallError, message.join("\n")
- elsif @force_all
+ elsif @force_all then
remove_all list
- elsif list.size > 1
+ elsif list.size > 1 then
gem_names = list.map { |gem| gem.full_name }
gem_names << "All versions"
say
_, index = choose_from_list "Select gem to uninstall:", gem_names
- if index == list.size
+ if index == list.size then
remove_all list
- elsif index >= 0 && index < list.size
+ elsif index >= 0 && index < list.size then
uninstall_gem list[index]
else
- say "Error: must enter a number [1-#{list.size + 1}]"
+ say "Error: must enter a number [1-#{list.size+1}]"
end
else
uninstall_gem list.first
@@ -179,9 +180,9 @@ class Gem::Uninstaller
# Leave any executables created by other installed versions
# of this gem installed.
- list = Gem::Specification.find_all do |s|
+ list = Gem::Specification.find_all { |s|
s.name == spec.name && s.version != spec.version
- end
+ }
list.each do |s|
s.executables.each do |exe_name|
@@ -193,7 +194,7 @@ class Gem::Uninstaller
executables = executables.map { |exec| formatted_program_filename exec }
- remove = if @force_executables.nil?
+ remove = if @force_executables.nil? then
ask_yes_no("Remove executables:\n" +
"\t#{executables.join ', '}\n\n" +
"in addition to the gem?",
@@ -202,7 +203,7 @@ class Gem::Uninstaller
@force_executables
end
- if remove
+ if remove then
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
raise Gem::FilePermissionError, bin_dir unless File.writable? bin_dir
@@ -212,8 +213,8 @@ class Gem::Uninstaller
exe_file = File.join bin_dir, exe_name
- safe_delete { FileUtils.rm exe_file }
- safe_delete { FileUtils.rm "#{exe_file}.bat" }
+ FileUtils.rm_f exe_file
+ FileUtils.rm_f "#{exe_file}.bat"
end
else
say "Executables and scripts will remain installed."
@@ -238,7 +239,7 @@ class Gem::Uninstaller
def remove(spec)
unless path_ok?(@gem_home, spec) or
- (@user_install and path_ok?(Gem.user_dir, spec))
+ (@user_install and path_ok?(Gem.user_dir, spec)) then
e = Gem::GemNotInHomeException.new \
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
e.spec = spec
@@ -249,26 +250,26 @@ class Gem::Uninstaller
raise Gem::FilePermissionError, spec.base_dir unless
File.writable?(spec.base_dir)
- safe_delete { FileUtils.rm_r spec.full_gem_path }
- safe_delete { FileUtils.rm_r spec.extension_dir }
+ FileUtils.rm_rf spec.full_gem_path
+ FileUtils.rm_rf spec.extension_dir
old_platform_name = spec.original_name
+ gemspec = spec.spec_file
+
+ unless File.exist? gemspec then
+ gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
+ end
+
+ FileUtils.rm_rf gemspec
gem = spec.cache_file
gem = File.join(spec.cache_dir, "#{old_platform_name}.gem") unless
File.exist? gem
- safe_delete { FileUtils.rm_r gem }
+ FileUtils.rm_rf gem
Gem::RDoc.new(spec).remove
- gemspec = spec.spec_file
-
- unless File.exist? gemspec
- gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
- end
-
- safe_delete { FileUtils.rm_r gemspec }
say "Successfully uninstalled #{spec.full_name}"
Gem::Specification.reset
@@ -288,7 +289,7 @@ class Gem::Uninstaller
# Returns true if it is OK to remove +spec+ or this is a forced
# uninstallation.
- def dependencies_ok?(spec) # :nodoc:
+ def dependencies_ok? spec # :nodoc:
return true if @force_ignore
deplist = Gem::DependencyList.from_specs
@@ -307,15 +308,15 @@ class Gem::Uninstaller
##
# Asks if it is OK to remove +spec+. Returns true if it is OK.
- def ask_if_ok(spec) # :nodoc:
+ def ask_if_ok spec # :nodoc:
msg = ['']
msg << 'You have requested to uninstall the gem:'
msg << "\t#{spec.full_name}"
msg << ''
siblings = Gem::Specification.select do |s|
- s.name == spec.name && s.full_name != spec.full_name
- end
+ s.name == spec.name && s.full_name != spec.full_name
+ end
spec.dependent_gems.each do |dep_spec, dep, satlist|
unless siblings.any? { |s| s.satisfies_requirement? dep }
@@ -331,27 +332,15 @@ class Gem::Uninstaller
##
# Returns the formatted version of the executable +filename+
- def formatted_program_filename(filename) # :nodoc:
+ def formatted_program_filename filename # :nodoc:
# TODO perhaps the installer should leave a small manifest
# of what it did for us to find rather than trying to recreate
# it again.
- if @format_executable
+ if @format_executable then
require 'rubygems/installer'
Gem::Installer.exec_format % File.basename(filename)
else
filename
end
end
-
- def safe_delete(&block)
- block.call
- rescue Errno::ENOENT
- nil
- rescue Errno::EPERM
- e = Gem::UninstallError.new
- e.spec = @spec
-
- raise e
- end
-
end
diff --git a/lib/rubygems/uri_formatter.rb b/lib/rubygems/uri_formatter.rb
index f3d510470b..bb128e4ef9 100644
--- a/lib/rubygems/uri_formatter.rb
+++ b/lib/rubygems/uri_formatter.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'cgi'
+require 'uri'
##
# The UriFormatter handles URIs from user-input and escaping.
@@ -18,7 +19,7 @@ class Gem::UriFormatter
##
# Creates a new URI formatter for +uri+.
- def initialize(uri)
+ def initialize uri
@uri = uri
end
@@ -46,3 +47,4 @@ class Gem::UriFormatter
end
end
+
diff --git a/lib/rubygems/uri_parser.rb b/lib/rubygems/uri_parser.rb
deleted file mode 100644
index 5c7cabc436..0000000000
--- a/lib/rubygems/uri_parser.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-##
-# The UriParser handles parsing URIs.
-#
-
-class Gem::UriParser
-
- ##
- # Parses the #uri, raising if it's invalid
-
- def parse!(uri)
- raise URI::InvalidURIError unless uri
-
- # Always escape URI's to deal with potential spaces and such
- # It should also be considered that source_uri may already be
- # a valid URI with escaped characters. e.g. "{DESede}" is encoded
- # as "%7BDESede%7D". If this is escaped again the percentage
- # symbols will be escaped.
- begin
- URI.parse(uri)
- rescue URI::InvalidURIError
- URI.parse(URI::DEFAULT_PARSER.escape(uri))
- end
- end
-
- ##
- # Parses the #uri, returning the original uri if it's invalid
-
- def parse(uri)
- parse!(uri)
- rescue URI::InvalidURIError
- uri
- end
-
-end
diff --git a/lib/rubygems/uri_parsing.rb b/lib/rubygems/uri_parsing.rb
deleted file mode 100644
index 941d7e023a..0000000000
--- a/lib/rubygems/uri_parsing.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems/uri_parser"
-
-module Gem::UriParsing
-
- def parse_uri(source_uri)
- return source_uri unless source_uri.is_a?(String)
-
- uri_parser.parse(source_uri)
- end
-
- private :parse_uri
-
- def uri_parser
- require "uri"
-
- Gem::UriParser.new
- end
-
- private :uri_parser
-
-end
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 93f528a763..eff8f9533c 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -6,7 +6,6 @@
#++
require 'rubygems/util'
-require 'rubygems/deprecate'
require 'rubygems/text'
##
@@ -98,7 +97,7 @@ module Gem::UserInteraction
##
# Displays an alert +statement+. Asks a +question+ if given.
- def alert(statement, question = nil)
+ def alert statement, question = nil
ui.alert statement, question
end
@@ -106,7 +105,7 @@ module Gem::UserInteraction
# Displays an error +statement+ to the error output location. Asks a
# +question+ if given.
- def alert_error(statement, question = nil)
+ def alert_error statement, question = nil
ui.alert_error statement, question
end
@@ -114,49 +113,49 @@ module Gem::UserInteraction
# Displays a warning +statement+ to the warning output location. Asks a
# +question+ if given.
- def alert_warning(statement, question = nil)
+ def alert_warning statement, question = nil
ui.alert_warning statement, question
end
##
# Asks a +question+ and returns the answer.
- def ask(question)
+ def ask question
ui.ask question
end
##
# Asks for a password with a +prompt+
- def ask_for_password(prompt)
+ def ask_for_password prompt
ui.ask_for_password prompt
end
##
# Asks a yes or no +question+. Returns true for yes, false for no.
- def ask_yes_no(question, default = nil)
+ def ask_yes_no question, default = nil
ui.ask_yes_no question, default
end
##
# Asks the user to answer +question+ with an answer from the given +list+.
- def choose_from_list(question, list)
+ def choose_from_list question, list
ui.choose_from_list question, list
end
##
# Displays the given +statement+ on the standard output (or equivalent).
- def say(statement = '')
+ def say statement = ''
ui.say statement
end
##
# Terminates the RubyGems process with the given +exit_code+
- def terminate_interaction(exit_code = 0)
+ def terminate_interaction exit_code = 0
ui.terminate_interaction exit_code
end
@@ -174,8 +173,6 @@ end
class Gem::StreamUI
- extend Gem::Deprecate
-
##
# The input stream
@@ -208,14 +205,18 @@ class Gem::StreamUI
# Returns true if TTY methods should be used on this StreamUI.
def tty?
- @usetty && @ins.tty?
+ if RUBY_VERSION < '1.9.3' and RUBY_PLATFORM =~ /mingw|mswin/ then
+ @usetty
+ else
+ @usetty && @ins.tty?
+ end
end
##
# Prints a formatted backtrace to the errors stream if backtraces are
# enabled.
- def backtrace(exception)
+ def backtrace exception
return unless Gem.configuration.backtrace
@errs.puts "\t#{exception.backtrace.join "\n\t"}"
@@ -230,7 +231,7 @@ class Gem::StreamUI
@outs.puts question
list.each_with_index do |item, index|
- @outs.puts " #{index + 1}. #{item}"
+ @outs.puts " #{index+1}. #{item}"
end
@outs.print "> "
@@ -250,8 +251,8 @@ class Gem::StreamUI
# default.
def ask_yes_no(question, default=nil)
- unless tty?
- if default.nil?
+ unless tty? then
+ if default.nil? then
raise Gem::OperationNotSupportedError,
"Not connected to a tty and no default specified"
else
@@ -323,7 +324,29 @@ class Gem::StreamUI
def _gets_noecho
require_io_console
- @ins.noecho {@ins.gets}
+ if IO.method_defined?(:noecho) then
+ @ins.noecho {@ins.gets}
+ elsif Gem.win_platform?
+ require "Win32API"
+ password = ''
+
+ while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
+ break if char == 10 || char == 13 # received carriage return or newline
+ if char == 127 || char == 8 # backspace and delete
+ password.slice!(-1, 1)
+ else
+ password << char.chr
+ end
+ end
+ password
+ else
+ system "stty -echo"
+ begin
+ @ins.gets
+ ensure
+ system "stty echo"
+ end
+ end
end
##
@@ -364,7 +387,6 @@ class Gem::StreamUI
def debug(statement)
@errs.puts statement
end
- deprecate :debug, :none, 2018, 12
##
# Terminate the application with exit code +status+, running any exit
@@ -421,7 +443,6 @@ class Gem::StreamUI
def done
end
-
end
##
@@ -510,17 +531,17 @@ class Gem::StreamUI
def done
@out.puts @terminal_message
end
-
end
##
# Return a download reporter object chosen from the current verbosity
def download_reporter(*args)
- if [nil, false].include?(Gem.configuration.verbose) || !@outs.tty?
+ case Gem.configuration.verbose
+ when nil, false
SilentDownloadReporter.new(@outs, *args)
else
- ThreadedDownloadReporter.new(@outs, *args)
+ VerboseDownloadReporter.new(@outs, *args)
end
end
@@ -554,15 +575,12 @@ class Gem::StreamUI
def done
end
-
end
##
- # A progress reporter that behaves nicely with threaded downloading.
-
- class ThreadedDownloadReporter
+ # A progress reporter that prints out messages about the current progress.
- MUTEX = Mutex.new
+ class VerboseDownloadReporter
##
# The current file name being displayed
@@ -570,49 +588,73 @@ class Gem::StreamUI
attr_reader :file_name
##
- # Creates a new threaded download reporter that will display on
+ # The total bytes in the file
+
+ attr_reader :total_bytes
+
+ ##
+ # The current progress (0 to 100)
+
+ attr_reader :progress
+
+ ##
+ # Creates a new verbose download reporter that will display on
# +out_stream+. The other arguments are ignored.
def initialize(out_stream, *args)
- @file_name = nil
@out = out_stream
+ @progress = 0
end
##
- # Tells the download reporter that the +file_name+ is being fetched.
- # The other arguments are ignored.
+ # Tells the download reporter that the +file_name+ is being fetched and
+ # contains +total_bytes+.
- def fetch(file_name, *args)
- if @file_name.nil?
- @file_name = file_name
- locked_puts "Fetching #{@file_name}"
- end
+ def fetch(file_name, total_bytes)
+ @file_name = file_name
+ @total_bytes = total_bytes.to_i
+ @units = @total_bytes.zero? ? 'B' : '%'
+
+ update_display(false)
end
##
- # Updates the threaded download reporter for the given number of +bytes+.
+ # Updates the verbose download reporter for the given number of +bytes+.
def update(bytes)
- # Do nothing.
+ new_progress = if @units == 'B' then
+ bytes
+ else
+ ((bytes.to_f * 100) / total_bytes.to_f).ceil
+ end
+
+ return if new_progress == @progress
+
+ @progress = new_progress
+ update_display
end
##
# Indicates the download is complete.
def done
- # Do nothing.
+ @progress = 100 if @units == '%'
+ update_display(true, true)
end
private
- def locked_puts(message)
- MUTEX.synchronize do
- @out.puts message
+ def update_display(show_progress = true, new_line = false) # :nodoc:
+ return unless @out.tty?
+
+ if show_progress then
+ @out.print "\rFetching: %s (%3d%s)" % [@file_name, @progress, @units]
+ else
+ @out.print "Fetching: %s" % @file_name
end
+ @out.puts if new_line
end
-
end
-
end
##
@@ -628,7 +670,6 @@ class Gem::ConsoleUI < Gem::StreamUI
def initialize
super STDIN, STDOUT, STDERR, true
end
-
end
##
@@ -642,8 +683,8 @@ class Gem::SilentUI < Gem::StreamUI
def initialize
reader, writer = nil, nil
- reader = File.open(IO::NULL, 'r')
- writer = File.open(IO::NULL, 'w')
+ reader = File.open(Gem::Util::NULL_DEVICE, 'r')
+ writer = File.open(Gem::Util::NULL_DEVICE, 'w')
super reader, writer, writer, false
end
@@ -661,5 +702,4 @@ class Gem::SilentUI < Gem::StreamUI
def progress_reporter(*args) # :nodoc:
SilentProgressReporter.new(@outs, *args)
end
-
end
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index 7fc239af9a..6c75910004 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -14,14 +14,8 @@ module Gem::Util
require 'stringio'
data = StringIO.new(data, 'r')
- gzip_reader = begin
- Zlib::GzipReader.new(data)
- rescue Zlib::GzipFile::Error => e
- raise e.class, e.inspect, e.backtrace
- end
-
- unzipped = gzip_reader.read
- unzipped.force_encoding Encoding::BINARY
+ unzipped = Zlib::GzipReader.new(data).read
+ unzipped.force_encoding Encoding::BINARY if Object.const_defined? :Encoding
unzipped
end
@@ -32,11 +26,9 @@ module Gem::Util
require 'zlib'
require 'stringio'
zipped = StringIO.new(String.new, 'w')
- zipped.set_encoding Encoding::BINARY
+ zipped.set_encoding Encoding::BINARY if Object.const_defined? :Encoding
- Zlib::GzipWriter.wrap zipped do |io|
- io.write data
- end
+ Zlib::GzipWriter.wrap zipped do |io| io.write data end
zipped.string
end
@@ -50,30 +42,74 @@ module Gem::Util
end
##
- # This calls IO.popen and reads the result
+ # This calls IO.popen where it accepts an array for a +command+ (Ruby 1.9+)
+ # and implements an IO.popen-like behavior where it does not accept an array
+ # for a command.
- def self.popen(*command)
+ def self.popen *command
IO.popen command, &:read
+ rescue TypeError # ruby 1.8 only supports string command
+ r, w = IO.pipe
+
+ pid = fork do
+ STDIN.close
+ STDOUT.reopen w
+
+ exec(*command)
+ end
+
+ w.close
+
+ begin
+ return r.read
+ ensure
+ Process.wait pid
+ end
end
+ NULL_DEVICE = defined?(IO::NULL) ? IO::NULL : Gem.win_platform? ? 'NUL' : '/dev/null'
+
##
# Invokes system, but silences all output.
- def self.silent_system(*command)
- opt = {:out => IO::NULL, :err => [:child, :out]}
+ def self.silent_system *command
+ opt = {:out => NULL_DEVICE, :err => [:child, :out]}
if Hash === command.last
opt.update(command.last)
cmds = command[0...-1]
else
cmds = command.dup
end
- system(*(cmds << opt))
+ return system(*(cmds << opt))
+ rescue TypeError
+ require 'thread'
+
+ @silent_mutex ||= Mutex.new
+
+ null_device = NULL_DEVICE
+
+ @silent_mutex.synchronize do
+ begin
+ stdout = STDOUT.dup
+ stderr = STDERR.dup
+
+ STDOUT.reopen null_device, 'w'
+ STDERR.reopen null_device, 'w'
+
+ return system(*command)
+ ensure
+ STDOUT.reopen stdout
+ STDERR.reopen stderr
+ stdout.close
+ stderr.close
+ end
+ end
end
##
# Enumerates the parents of +directory+.
- def self.traverse_parents(directory, &block)
+ def self.traverse_parents directory, &block
return enum_for __method__, directory unless block_given?
here = File.expand_path directory
@@ -86,28 +122,4 @@ module Gem::Util
end
end
- ##
- # Globs for files matching +pattern+ inside of +directory+,
- # returning absolute paths to the matching files.
-
- def self.glob_files_in_dir(glob, base_path)
- if RUBY_VERSION >= "2.5"
- Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) }
- else
- Dir.glob(File.expand_path(glob, base_path))
- end
- end
-
- ##
- # Corrects +path+ (usually returned by `URI.parse().path` on Windows), that
- # comes with a leading slash.
-
- def self.correct_for_windows_path(path)
- if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
- path[1..-1]
- else
- path
- end
- end
-
end
diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb
index f23be157b9..96fed282f1 100644
--- a/lib/rubygems/util/licenses.rb
+++ b/lib/rubygems/util/licenses.rb
@@ -2,422 +2,364 @@
require 'rubygems/text'
class Gem::Licenses
-
extend Gem::Text
NONSTANDARD = 'Nonstandard'.freeze
# Software Package Data Exchange (SPDX) standard open-source software
# license identifiers
- LICENSE_IDENTIFIERS = %w(
- 0BSD
- AAL
- ADSL
- AFL-1.1
- AFL-1.2
- AFL-2.0
- AFL-2.1
- AFL-3.0
- AGPL-1.0
- AGPL-3.0
- AGPL-3.0-only
- AGPL-3.0-or-later
- AMDPLPA
- AML
- AMPAS
- ANTLR-PD
- APAFML
- APL-1.0
- APSL-1.0
- APSL-1.1
- APSL-1.2
- APSL-2.0
- Abstyles
- Adobe-2006
- Adobe-Glyph
- Afmparse
- Aladdin
- Apache-1.0
- Apache-1.1
- Apache-2.0
- Artistic-1.0
- Artistic-1.0-Perl
- Artistic-1.0-cl8
- Artistic-2.0
- BSD-1-Clause
- BSD-2-Clause
- BSD-2-Clause-FreeBSD
- BSD-2-Clause-NetBSD
- BSD-2-Clause-Patent
- BSD-3-Clause
- BSD-3-Clause-Attribution
- BSD-3-Clause-Clear
- BSD-3-Clause-LBNL
- BSD-3-Clause-No-Nuclear-License
- BSD-3-Clause-No-Nuclear-License-2014
- BSD-3-Clause-No-Nuclear-Warranty
- BSD-4-Clause
- BSD-4-Clause-UC
- BSD-Protection
- BSD-Source-Code
- BSL-1.0
- Bahyph
- Barr
- Beerware
- BitTorrent-1.0
- BitTorrent-1.1
- Borceux
- CATOSL-1.1
- CC-BY-1.0
- CC-BY-2.0
- CC-BY-2.5
- CC-BY-3.0
- CC-BY-4.0
- CC-BY-NC-1.0
- CC-BY-NC-2.0
- CC-BY-NC-2.5
- CC-BY-NC-3.0
- CC-BY-NC-4.0
- CC-BY-NC-ND-1.0
- CC-BY-NC-ND-2.0
- CC-BY-NC-ND-2.5
- CC-BY-NC-ND-3.0
- CC-BY-NC-ND-4.0
- CC-BY-NC-SA-1.0
- CC-BY-NC-SA-2.0
- CC-BY-NC-SA-2.5
- CC-BY-NC-SA-3.0
- CC-BY-NC-SA-4.0
- CC-BY-ND-1.0
- CC-BY-ND-2.0
- CC-BY-ND-2.5
- CC-BY-ND-3.0
- CC-BY-ND-4.0
- CC-BY-SA-1.0
- CC-BY-SA-2.0
- CC-BY-SA-2.5
- CC-BY-SA-3.0
- CC-BY-SA-4.0
- CC0-1.0
- CDDL-1.0
- CDDL-1.1
- CDLA-Permissive-1.0
- CDLA-Sharing-1.0
- CECILL-1.0
- CECILL-1.1
- CECILL-2.0
- CECILL-2.1
- CECILL-B
- CECILL-C
- CNRI-Jython
- CNRI-Python
- CNRI-Python-GPL-Compatible
- CPAL-1.0
- CPL-1.0
- CPOL-1.02
- CUA-OPL-1.0
- Caldera
- ClArtistic
- Condor-1.1
- Crossword
- CrystalStacker
- Cube
- D-FSL-1.0
- DOC
- DSDP
- Dotseqn
- ECL-1.0
- ECL-2.0
- EFL-1.0
- EFL-2.0
- EPL-1.0
- EPL-2.0
- EUDatagrid
- EUPL-1.0
- EUPL-1.1
- EUPL-1.2
- Entessa
- ErlPL-1.1
- Eurosym
- FSFAP
- FSFUL
- FSFULLR
- FTL
- Fair
- Frameworx-1.0
- FreeImage
- GFDL-1.1
- GFDL-1.1-only
- GFDL-1.1-or-later
- GFDL-1.2
- GFDL-1.2-only
- GFDL-1.2-or-later
- GFDL-1.3
- GFDL-1.3-only
- GFDL-1.3-or-later
- GL2PS
- GPL-1.0
- GPL-1.0+
- GPL-1.0-only
- GPL-1.0-or-later
- GPL-2.0
- GPL-2.0+
- GPL-2.0-only
- GPL-2.0-or-later
- GPL-2.0-with-GCC-exception
- GPL-2.0-with-autoconf-exception
- GPL-2.0-with-bison-exception
- GPL-2.0-with-classpath-exception
- GPL-2.0-with-font-exception
- GPL-3.0
- GPL-3.0+
- GPL-3.0-only
- GPL-3.0-or-later
- GPL-3.0-with-GCC-exception
- GPL-3.0-with-autoconf-exception
- Giftware
- Glide
- Glulxe
- HPND
- HaskellReport
- IBM-pibs
- ICU
- IJG
- IPA
- IPL-1.0
- ISC
- ImageMagick
- Imlib2
- Info-ZIP
- Intel
- Intel-ACPI
- Interbase-1.0
- JSON
- JasPer-2.0
- LAL-1.2
- LAL-1.3
- LGPL-2.0
- LGPL-2.0+
- LGPL-2.0-only
- LGPL-2.0-or-later
- LGPL-2.1
- LGPL-2.1+
- LGPL-2.1-only
- LGPL-2.1-or-later
- LGPL-3.0
- LGPL-3.0+
- LGPL-3.0-only
- LGPL-3.0-or-later
- LGPLLR
- LPL-1.0
- LPL-1.02
- LPPL-1.0
- LPPL-1.1
- LPPL-1.2
- LPPL-1.3a
- LPPL-1.3c
- Latex2e
- Leptonica
- LiLiQ-P-1.1
- LiLiQ-R-1.1
- LiLiQ-Rplus-1.1
- Libpng
- MIT
- MIT-CMU
- MIT-advertising
- MIT-enna
- MIT-feh
- MITNFA
- MPL-1.0
- MPL-1.1
- MPL-2.0
- MPL-2.0-no-copyleft-exception
- MS-PL
- MS-RL
- MTLL
- MakeIndex
- MirOS
- Motosoto
- Multics
- Mup
- NASA-1.3
- NBPL-1.0
- NCSA
- NGPL
- NLOD-1.0
- NLPL
- NOSL
- NPL-1.0
- NPL-1.1
- NPOSL-3.0
- NRL
- NTP
- Naumen
- Net-SNMP
- NetCDF
- Newsletr
- Nokia
- Noweb
- Nunit
- OCCT-PL
- OCLC-2.0
- ODbL-1.0
- OFL-1.0
- OFL-1.1
- OGTSL
- OLDAP-1.1
- OLDAP-1.2
- OLDAP-1.3
- OLDAP-1.4
- OLDAP-2.0
- OLDAP-2.0.1
- OLDAP-2.1
- OLDAP-2.2
- OLDAP-2.2.1
- OLDAP-2.2.2
- OLDAP-2.3
- OLDAP-2.4
- OLDAP-2.5
- OLDAP-2.6
- OLDAP-2.7
- OLDAP-2.8
- OML
- OPL-1.0
- OSET-PL-2.1
- OSL-1.0
- OSL-1.1
- OSL-2.0
- OSL-2.1
- OSL-3.0
- OpenSSL
- PDDL-1.0
- PHP-3.0
- PHP-3.01
- Plexus
- PostgreSQL
- Python-2.0
- QPL-1.0
- Qhull
- RHeCos-1.1
- RPL-1.1
- RPL-1.5
- RPSL-1.0
- RSA-MD
- RSCPL
- Rdisc
- Ruby
- SAX-PD
- SCEA
- SGI-B-1.0
- SGI-B-1.1
- SGI-B-2.0
- SISSL
- SISSL-1.2
- SMLNJ
- SMPPL
- SNIA
- SPL-1.0
- SWL
- Saxpath
- Sendmail
- SimPL-2.0
- Sleepycat
- Spencer-86
- Spencer-94
- Spencer-99
- StandardML-NJ
- SugarCRM-1.1.3
- TCL
- TCP-wrappers
- TMate
- TORQUE-1.1
- TOSL
- UPL-1.0
- Unicode-DFS-2015
- Unicode-DFS-2016
- Unicode-TOU
- Unlicense
- VOSTROM
- VSL-1.0
- Vim
- W3C
- W3C-19980720
- W3C-20150513
- WTFPL
- Watcom-1.0
- Wsuipa
- X11
- XFree86-1.1
- XSkat
- Xerox
- Xnet
- YPL-1.0
- YPL-1.1
- ZPL-1.1
- ZPL-2.0
- ZPL-2.1
- Zed
- Zend-2.0
- Zimbra-1.3
- Zimbra-1.4
- Zlib
- bzip2-1.0.5
- bzip2-1.0.6
- curl
- diffmark
- dvipdfm
- eCos-2.0
- eGenix
- gSOAP-1.3b
- gnuplot
- iMatix
- libtiff
- mpich2
- psfrag
- psutils
- wxWindows
- xinetd
- xpp
- zlib-acknowledgement
- ).freeze
-
- # exception identifiers
- EXCEPTION_IDENTIFIERS = %w(
- 389-exception
- Autoconf-exception-2.0
- Autoconf-exception-3.0
- Bison-exception-2.2
- Bootloader-exception
- CLISP-exception-2.0
- Classpath-exception-2.0
- DigiRule-FOSS-exception
- FLTK-exception
- Fawkes-Runtime-exception
- Font-exception-2.0
- GCC-exception-2.0
- GCC-exception-3.1
- LZMA-exception
- Libtool-exception
- Linux-syscall-note
- Nokia-Qt-exception-1.1
- OCCT-exception-1.0
- Qwt-exception-1.0
- WxWindows-exception-3.1
- eCos-exception-2.0
- freertos-exception-2.0
- gnu-javamail-exception
- i2p-gpl-java-exception
- mif-exception
- openvpn-openssl-exception
- u-boot-exception-2.0
+ IDENTIFIERS = %w(
+ 0BSD
+ AAL
+ ADSL
+ AFL-1.1
+ AFL-1.2
+ AFL-2.0
+ AFL-2.1
+ AFL-3.0
+ AGPL-1.0
+ AGPL-3.0
+ AMDPLPA
+ AML
+ AMPAS
+ ANTLR-PD
+ APAFML
+ APL-1.0
+ APSL-1.0
+ APSL-1.1
+ APSL-1.2
+ APSL-2.0
+ Abstyles
+ Adobe-2006
+ Adobe-Glyph
+ Afmparse
+ Aladdin
+ Apache-1.0
+ Apache-1.1
+ Apache-2.0
+ Artistic-1.0
+ Artistic-1.0-Perl
+ Artistic-1.0-cl8
+ Artistic-2.0
+ BSD-2-Clause
+ BSD-2-Clause-FreeBSD
+ BSD-2-Clause-NetBSD
+ BSD-3-Clause
+ BSD-3-Clause-Attribution
+ BSD-3-Clause-Clear
+ BSD-3-Clause-LBNL
+ BSD-3-Clause-No-Nuclear-License
+ BSD-3-Clause-No-Nuclear-License-2014
+ BSD-3-Clause-No-Nuclear-Warranty
+ BSD-4-Clause
+ BSD-4-Clause-UC
+ BSD-Protection
+ BSD-Source-Code
+ BSL-1.0
+ Bahyph
+ Barr
+ Beerware
+ BitTorrent-1.0
+ BitTorrent-1.1
+ Borceux
+ CATOSL-1.1
+ CC-BY-1.0
+ CC-BY-2.0
+ CC-BY-2.5
+ CC-BY-3.0
+ CC-BY-4.0
+ CC-BY-NC-1.0
+ CC-BY-NC-2.0
+ CC-BY-NC-2.5
+ CC-BY-NC-3.0
+ CC-BY-NC-4.0
+ CC-BY-NC-ND-1.0
+ CC-BY-NC-ND-2.0
+ CC-BY-NC-ND-2.5
+ CC-BY-NC-ND-3.0
+ CC-BY-NC-ND-4.0
+ CC-BY-NC-SA-1.0
+ CC-BY-NC-SA-2.0
+ CC-BY-NC-SA-2.5
+ CC-BY-NC-SA-3.0
+ CC-BY-NC-SA-4.0
+ CC-BY-ND-1.0
+ CC-BY-ND-2.0
+ CC-BY-ND-2.5
+ CC-BY-ND-3.0
+ CC-BY-ND-4.0
+ CC-BY-SA-1.0
+ CC-BY-SA-2.0
+ CC-BY-SA-2.5
+ CC-BY-SA-3.0
+ CC-BY-SA-4.0
+ CC0-1.0
+ CDDL-1.0
+ CDDL-1.1
+ CECILL-1.0
+ CECILL-1.1
+ CECILL-2.0
+ CECILL-2.1
+ CECILL-B
+ CECILL-C
+ CNRI-Jython
+ CNRI-Python
+ CNRI-Python-GPL-Compatible
+ CPAL-1.0
+ CPL-1.0
+ CPOL-1.02
+ CUA-OPL-1.0
+ Caldera
+ ClArtistic
+ Condor-1.1
+ Crossword
+ CrystalStacker
+ Cube
+ D-FSL-1.0
+ DOC
+ DSDP
+ Dotseqn
+ ECL-1.0
+ ECL-2.0
+ EFL-1.0
+ EFL-2.0
+ EPL-1.0
+ EUDatagrid
+ EUPL-1.0
+ EUPL-1.1
+ Entessa
+ ErlPL-1.1
+ Eurosym
+ FSFAP
+ FSFUL
+ FSFULLR
+ FTL
+ Fair
+ Frameworx-1.0
+ FreeImage
+ GFDL-1.1
+ GFDL-1.2
+ GFDL-1.3
+ GL2PS
+ GPL-1.0
+ GPL-1.0+
+ GPL-2.0
+ GPL-2.0+
+ GPL-2.0-with-GCC-exception
+ GPL-2.0-with-autoconf-exception
+ GPL-2.0-with-bison-exception
+ GPL-2.0-with-classpath-exception
+ GPL-2.0-with-font-exception
+ GPL-3.0
+ GPL-3.0+
+ GPL-3.0-with-GCC-exception
+ GPL-3.0-with-autoconf-exception
+ Giftware
+ Glide
+ Glulxe
+ HPND
+ HaskellReport
+ IBM-pibs
+ ICU
+ IJG
+ IPA
+ IPL-1.0
+ ISC
+ ImageMagick
+ Imlib2
+ Info-ZIP
+ Intel
+ Intel-ACPI
+ Interbase-1.0
+ JSON
+ JasPer-2.0
+ LAL-1.2
+ LAL-1.3
+ LGPL-2.0
+ LGPL-2.0+
+ LGPL-2.1
+ LGPL-2.1+
+ LGPL-3.0
+ LGPL-3.0+
+ LGPLLR
+ LPL-1.0
+ LPL-1.02
+ LPPL-1.0
+ LPPL-1.1
+ LPPL-1.2
+ LPPL-1.3a
+ LPPL-1.3c
+ Latex2e
+ Leptonica
+ LiLiQ-P-1.1
+ LiLiQ-R-1.1
+ LiLiQ-Rplus-1.1
+ Libpng
+ MIT
+ MIT-CMU
+ MIT-advertising
+ MIT-enna
+ MIT-feh
+ MITNFA
+ MPL-1.0
+ MPL-1.1
+ MPL-2.0
+ MPL-2.0-no-copyleft-exception
+ MS-PL
+ MS-RL
+ MTLL
+ MakeIndex
+ MirOS
+ Motosoto
+ Multics
+ Mup
+ NASA-1.3
+ NBPL-1.0
+ NCSA
+ NGPL
+ NLOD-1.0
+ NLPL
+ NOSL
+ NPL-1.0
+ NPL-1.1
+ NPOSL-3.0
+ NRL
+ NTP
+ Naumen
+ Net-SNMP
+ NetCDF
+ Newsletr
+ Nokia
+ Noweb
+ Nunit
+ OCCT-PL
+ OCLC-2.0
+ ODbL-1.0
+ OFL-1.0
+ OFL-1.1
+ OGTSL
+ OLDAP-1.1
+ OLDAP-1.2
+ OLDAP-1.3
+ OLDAP-1.4
+ OLDAP-2.0
+ OLDAP-2.0.1
+ OLDAP-2.1
+ OLDAP-2.2
+ OLDAP-2.2.1
+ OLDAP-2.2.2
+ OLDAP-2.3
+ OLDAP-2.4
+ OLDAP-2.5
+ OLDAP-2.6
+ OLDAP-2.7
+ OLDAP-2.8
+ OML
+ OPL-1.0
+ OSET-PL-2.1
+ OSL-1.0
+ OSL-1.1
+ OSL-2.0
+ OSL-2.1
+ OSL-3.0
+ OpenSSL
+ PDDL-1.0
+ PHP-3.0
+ PHP-3.01
+ Plexus
+ PostgreSQL
+ Python-2.0
+ QPL-1.0
+ Qhull
+ RHeCos-1.1
+ RPL-1.1
+ RPL-1.5
+ RPSL-1.0
+ RSA-MD
+ RSCPL
+ Rdisc
+ Ruby
+ SAX-PD
+ SCEA
+ SGI-B-1.0
+ SGI-B-1.1
+ SGI-B-2.0
+ SISSL
+ SISSL-1.2
+ SMLNJ
+ SMPPL
+ SNIA
+ SPL-1.0
+ SWL
+ Saxpath
+ Sendmail
+ SimPL-2.0
+ Sleepycat
+ Spencer-86
+ Spencer-94
+ Spencer-99
+ StandardML-NJ
+ SugarCRM-1.1.3
+ TCL
+ TCP-wrappers
+ TMate
+ TORQUE-1.1
+ TOSL
+ UPL-1.0
+ Unicode-DFS-2015
+ Unicode-DFS-2016
+ Unicode-TOU
+ Unlicense
+ VOSTROM
+ VSL-1.0
+ Vim
+ W3C
+ W3C-19980720
+ W3C-20150513
+ WTFPL
+ WXwindows
+ Watcom-1.0
+ Wsuipa
+ X11
+ XFree86-1.1
+ XSkat
+ Xerox
+ Xnet
+ YPL-1.0
+ YPL-1.1
+ ZPL-1.1
+ ZPL-2.0
+ ZPL-2.1
+ Zed
+ Zend-2.0
+ Zimbra-1.3
+ Zimbra-1.4
+ Zlib
+ bzip2-1.0.5
+ bzip2-1.0.6
+ curl
+ diffmark
+ dvipdfm
+ eCos-2.0
+ eGenix
+ gSOAP-1.3b
+ gnuplot
+ iMatix
+ libtiff
+ mpich2
+ psfrag
+ psutils
+ xinetd
+ xpp
+ zlib-acknowledgement
).freeze
REGEXP = %r{
\A
(
- #{Regexp.union(LICENSE_IDENTIFIERS)}
+ #{Regexp.union(IDENTIFIERS)}
\+?
- (\s WITH \s #{Regexp.union(EXCEPTION_IDENTIFIERS)})?
+ (\s WITH \s .+)?
| #{NONSTANDARD}
)
\Z
@@ -428,12 +370,11 @@ class Gem::Licenses
end
def self.suggestions(license)
- by_distance = LICENSE_IDENTIFIERS.group_by do |identifier|
+ by_distance = IDENTIFIERS.group_by do |identifier|
levenshtein_distance(identifier, license)
end
lowest = by_distance.keys.min
return unless lowest < license.size
by_distance[lowest]
end
-
end
diff --git a/lib/rubygems/util/list.rb b/lib/rubygems/util/list.rb
index 7e4d6b5de6..9c25f6b6dc 100644
--- a/lib/rubygems/util/list.rb
+++ b/lib/rubygems/util/list.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
module Gem
class List
-
include Enumerable
attr_accessor :value, :tail
@@ -26,7 +25,7 @@ module Gem
List.new value, self
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.pp to_a
end
@@ -34,6 +33,5 @@ module Gem
return List.new(value) unless list
List.new value, list
end
-
end
end
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index 7ed0a1f80f..6842e4fa9c 100644
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -19,13 +19,36 @@ class Gem::Validator
require 'find'
end
+ ##
+ # Given a gem file's contents, validates against its own MD5 checksum
+ # gem_data:: [String] Contents of the gem file
+
+ def verify_gem(gem_data)
+ # TODO remove me? The code here only validate an MD5SUM that was
+ # in some old formatted gems, but hasn't been for a long time.
+ end
+
+ ##
+ # Given the path to a gem file, validates against its own MD5 checksum
+ #
+ # gem_path:: [String] Path to gem file
+
+ def verify_gem_file(gem_path)
+ File.open gem_path, Gem.binary_mode do |file|
+ gem_data = file.read
+ verify_gem gem_data
+ end
+ rescue Errno::ENOENT, Errno::EINVAL
+ raise Gem::VerificationError, "missing gem file #{gem_path}"
+ end
+
private
def find_files_for_gem(gem_directory)
installed_files = []
Find.find gem_directory do |file_name|
- fn = file_name[gem_directory.size..file_name.size - 1].sub(/^\//, "")
+ fn = file_name[gem_directory.size..file_name.size-1].sub(/^\//, "")
installed_files << fn unless
fn =~ /CVS/ || fn.empty? || File.directory?(file_name)
end
@@ -39,7 +62,7 @@ class Gem::Validator
# Describes a problem with a file in a gem.
ErrorData = Struct.new :path, :problem do
- def <=>(other) # :nodoc:
+ def <=> other # :nodoc:
return nil unless self.class === other
[path, problem] <=> [other.path, other.problem]
@@ -71,37 +94,35 @@ class Gem::Validator
spec_path = spec.spec_file
gem_directory = spec.full_gem_path
- unless File.directory? gem_directory
+ unless File.directory? gem_directory then
errors[gem_name][spec.full_name] =
"Gem registered but doesn't exist at #{gem_directory}"
next
end
- unless File.exist? spec_path
+ unless File.exist? spec_path then
errors[gem_name][spec_path] = "Spec file missing for installed gem"
end
begin
- unless File.readable?(gem_path)
- raise Gem::VerificationError, "missing gem file #{gem_path}"
- end
+ verify_gem_file(gem_path)
good, gone, unreadable = nil, nil, nil, nil
File.open gem_path, Gem.binary_mode do |file|
package = Gem::Package.new gem_path
- good, gone = package.contents.partition do |file_name|
+ good, gone = package.contents.partition { |file_name|
File.exist? File.join(gem_directory, file_name)
- end
+ }
gone.sort.each do |path|
errors[gem_name][path] = "Missing file"
end
- good, unreadable = good.partition do |file_name|
+ good, unreadable = good.partition { |file_name|
File.readable? File.join(gem_directory, file_name)
- end
+ }
unreadable.sort.each do |path|
errors[gem_name][path] = "Unreadable file"
@@ -114,7 +135,7 @@ class Gem::Validator
source = File.join gem_directory, entry['path']
File.open source, Gem.binary_mode do |f|
- unless f.read == data
+ unless f.read == data then
errors[gem_name][entry['path']] = "Modified from original"
end
end
@@ -141,5 +162,5 @@ class Gem::Validator
errors
end
-
end
+
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index b1faedcda2..ff5c1c1e72 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -150,13 +150,12 @@
# a zero to give a sensible result.
class Gem::Version
-
- autoload :Requirement, File.expand_path('requirement', __dir__)
+ autoload :Requirement, 'rubygems/requirement'
include Comparable
- VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?'.freeze # :nodoc:
- ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/.freeze # :nodoc:
+ VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?' # :nodoc:
+ ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/ # :nodoc:
##
# A string representation of this Version.
@@ -170,11 +169,7 @@ class Gem::Version
##
# True if the +version+ string matches RubyGems' requirements.
- def self.correct?(version)
- unless Gem::Deprecate.skip
- warn "nil versions are discouraged and will be deprecated in Rubygems 4" if version.nil?
- end
-
+ def self.correct? version
!!(version.to_s =~ ANCHORED_VERSION_PATTERN)
end
@@ -186,10 +181,10 @@ class Gem::Version
# ver2 = Version.create(ver1) # -> (ver1)
# ver3 = Version.create(nil) # -> nil
- def self.create(input)
- if self === input # check yourself before you wreck yourself
+ def self.create input
+ if self === input then # check yourself before you wreck yourself
input
- elsif input.nil?
+ elsif input.nil? then
nil
else
new input
@@ -197,10 +192,8 @@ class Gem::Version
end
@@all = {}
- @@bump = {}
- @@release = {}
- def self.new(version) # :nodoc:
+ def self.new version # :nodoc:
return super unless Gem::Version == self
@@all[version] ||= super
@@ -210,13 +203,13 @@ class Gem::Version
# Constructs a Version from the +version+ string. A version string is a
# series of digits or ASCII letters separated by dots.
- def initialize(version)
+ def initialize version
unless self.class.correct?(version)
raise ArgumentError, "Malformed version number string #{version}"
end
# If version is an empty string convert it to 0
- version = 0 if version.is_a?(String) && version =~ /\A\s*\Z/
+ version = 0 if version =~ /\A\s*\Z/
@version = version.to_s.strip.gsub("-",".pre.")
@segments = nil
@@ -229,21 +222,21 @@ class Gem::Version
# Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
def bump
- @@bump[self] ||= begin
- segments = self.segments
- segments.pop while segments.any? { |s| String === s }
- segments.pop if segments.size > 1
-
- segments[-1] = segments[-1].succ
- self.class.new segments.join(".")
- end
+ @bump ||= begin
+ segments = self.segments
+ segments.pop while segments.any? { |s| String === s }
+ segments.pop if segments.size > 1
+
+ segments[-1] = segments[-1].succ
+ self.class.new segments.join(".")
+ end
end
##
# A Version is only eql? to another version if it's specified to the
# same precision. Version "1.0" is not the same as version "1".
- def eql?(other)
+ def eql? other
self.class === other and @version == other._version
end
@@ -251,7 +244,7 @@ class Gem::Version
canonical_segments.hash
end
- def init_with(coder) # :nodoc:
+ def init_with coder # :nodoc:
yaml_initialize coder.tag, coder.map
end
@@ -271,7 +264,7 @@ class Gem::Version
# Load custom marshal format. It's a string for backwards (RubyGems
# 1.3.5 and earlier) compatibility.
- def marshal_load(array)
+ def marshal_load array
initialize array[0]
end
@@ -285,7 +278,7 @@ class Gem::Version
["@version"]
end
- def encode_with(coder) # :nodoc:
+ def encode_with coder # :nodoc:
coder.add 'version', @version
end
@@ -299,7 +292,7 @@ class Gem::Version
@prerelease
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.text "Gem::Version.new(#{version.inspect})"
end
@@ -308,13 +301,13 @@ class Gem::Version
# Non-prerelease versions return themselves.
def release
- @@release[self] ||= if prerelease?
- segments = self.segments
- segments.pop while segments.any? { |s| String === s }
- self.class.new segments.join('.')
- else
- self
- end
+ @release ||= if prerelease?
+ segments = self.segments
+ segments.pop while segments.any? { |s| String === s }
+ self.class.new segments.join('.')
+ else
+ self
+ end
end
def segments # :nodoc:
@@ -331,9 +324,7 @@ class Gem::Version
segments.pop while segments.size > 2
segments.push 0 while segments.size < 2
- recommendation = "~> #{segments.join(".")}"
- recommendation += ".a" if prerelease?
- recommendation
+ "~> #{segments.join(".")}"
end
##
@@ -342,12 +333,12 @@ class Gem::Version
# one. Attempts to compare to something that's not a
# <tt>Gem::Version</tt> return +nil+.
- def <=>(other)
+ def <=> other
return unless Gem::Version === other
return 0 if @version == other._version || canonical_segments == other.canonical_segments
- lhsegments = canonical_segments
- rhsegments = other.canonical_segments
+ lhsegments = _segments
+ rhsegments = other._segments
lhsize = lhsegments.size
rhsize = rhsegments.size
@@ -376,12 +367,6 @@ class Gem::Version
end.reduce(&:concat)
end
- def freeze
- prerelease?
- canonical_segments
- super
- end
-
protected
def _version
@@ -400,9 +385,8 @@ class Gem::Version
def _split_segments
string_start = _segments.index {|s| s.is_a?(String) }
- string_segments = segments
+ string_segments = segments
numeric_segments = string_segments.slice!(0, string_start || string_segments.size)
return numeric_segments, string_segments
end
-
end
diff --git a/lib/rubygems/version_option.rb b/lib/rubygems/version_option.rb
index 458a7a6601..c4d3306652 100644
--- a/lib/rubygems/version_option.rb
+++ b/lib/rubygems/version_option.rb
@@ -17,7 +17,7 @@ module Gem::VersionOption
def add_platform_option(task = command, *wrap)
OptionParser.accept Gem::Platform do |value|
- if value == Gem::Platform::RUBY
+ if value == Gem::Platform::RUBY then
value
else
Gem::Platform.new value
@@ -27,7 +27,7 @@ module Gem::VersionOption
add_option('--platform PLATFORM', Gem::Platform,
"Specify the platform of gem to #{task}", *wrap) do
|value, options|
- unless options[:added_platform]
+ unless options[:added_platform] then
Gem.platforms = [Gem::Platform::RUBY]
options[:added_platform] = true
end
@@ -74,3 +74,4 @@ module Gem::VersionOption
end
end
+
diff --git a/lib/scanf.gemspec b/lib/scanf.gemspec
new file mode 100644
index 0000000000..0e88535862
--- /dev/null
+++ b/lib/scanf.gemspec
@@ -0,0 +1,25 @@
+# coding: utf-8
+# frozen_string_literal: true
+
+Gem::Specification.new do |spec|
+ spec.name = "scanf"
+ spec.version = "1.0.0"
+ spec.date = '2017-12-11'
+ spec.authors = ["David Alan Black"]
+ spec.email = ['dblack@superlink.net']
+
+ spec.summary = "scanf is an implementation of the C function scanf(3)."
+ spec.description = "scanf is an implementation of the C function scanf(3)."
+ spec.homepage = "https://github.com/ruby/scanf"
+ spec.license = "BSD-2-Clause"
+
+ spec.files = ["lib/scanf.rb"]
+ spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
+ spec.required_ruby_version = ">= 2.3.0"
+
+ spec.add_development_dependency "bundler", "~> 1.14"
+ spec.add_development_dependency "rake", "~> 10.0"
+ spec.add_development_dependency "test-unit"
+end
diff --git a/lib/scanf.rb b/lib/scanf.rb
new file mode 100644
index 0000000000..27e815d494
--- /dev/null
+++ b/lib/scanf.rb
@@ -0,0 +1,776 @@
+# frozen_string_literal: false
+# scanf for Ruby
+#
+#--
+# $Release Version: 1.1.2 $
+# $Revision$
+# $Id$
+# $Author$
+#++
+#
+# == Description
+#
+# scanf is an implementation of the C function scanf(3), modified as necessary
+# for Ruby compatibility.
+#
+# the methods provided are String#scanf, IO#scanf, and
+# Kernel#scanf. Kernel#scanf is a wrapper around STDIN.scanf. IO#scanf
+# can be used on any IO stream, including file handles and sockets.
+# scanf can be called either with or without a block.
+#
+# Scanf scans an input string or stream according to a <b>format</b>, as
+# described below in Conversions, and returns an array of matches between
+# the format and the input. The format is defined in a string, and is
+# similar (though not identical) to the formats used in Kernel#printf and
+# Kernel#sprintf.
+#
+# The format may contain <b>conversion specifiers</b>, which tell scanf
+# what form (type) each particular matched substring should be converted
+# to (e.g., decimal integer, floating point number, literal string,
+# etc.) The matches and conversions take place from left to right, and
+# the conversions themselves are returned as an array.
+#
+# The format string may also contain characters other than those in the
+# conversion specifiers. White space (blanks, tabs, or newlines) in the
+# format string matches any amount of white space, including none, in
+# the input. Everything else matches only itself.
+#
+# Scanning stops, and scanf returns, when any input character fails to
+# match the specifications in the format string, or when input is
+# exhausted, or when everything in the format string has been
+# matched. All matches found up to the stopping point are returned in
+# the return array (or yielded to the block, if a block was given).
+#
+#
+# == Basic usage
+#
+# require 'scanf'
+#
+# # String#scanf and IO#scanf take a single argument, the format string
+# array = a_string.scanf("%d%s")
+# array = an_io.scanf("%d%s")
+#
+# # Kernel#scanf reads from STDIN
+# array = scanf("%d%s")
+#
+# == Block usage
+#
+# When called with a block, scanf keeps scanning the input, cycling back
+# to the beginning of the format string, and yields a new array of
+# conversions to the block every time the format string is matched
+# (including partial matches, but not including complete failures). The
+# actual return value of scanf when called with a block is an array
+# containing the results of all the executions of the block.
+#
+# str = "123 abc 456 def 789 ghi"
+# str.scanf("%d%s") { |num,str| [ num * 2, str.upcase ] }
+# # => [[246, "ABC"], [912, "DEF"], [1578, "GHI"]]
+#
+# == Conversions
+#
+# The single argument to scanf is a format string, which generally
+# includes one or more conversion specifiers. Conversion specifiers
+# begin with the percent character ('%') and include information about
+# what scanf should next scan for (string, decimal number, single
+# character, etc.).
+#
+# There may be an optional maximum field width, expressed as a decimal
+# integer, between the % and the conversion. If no width is given, a
+# default of `infinity' is used (with the exception of the %c specifier;
+# see below). Otherwise, given a field width of <em>n</em> for a given
+# conversion, at most <em>n</em> characters are scanned in processing
+# that conversion. Before conversion begins, most conversions skip
+# white space in the input string; this white space is not counted
+# against the field width.
+#
+# The following conversions are available.
+#
+# [%]
+# Matches a literal `%'. That is, `%%' in the format string matches a
+# single input `%' character. No conversion is done, and the resulting
+# '%' is not included in the return array.
+#
+# [d]
+# Matches an optionally signed decimal integer.
+#
+# [u]
+# Same as d.
+#
+# [i]
+# Matches an optionally signed integer. The integer is read in base
+# 16 if it begins with `0x' or `0X', in base 8 if it begins with `0',
+# and in base 10 other- wise. Only characters that correspond to the
+# base are recognized.
+#
+# [o]
+# Matches an optionally signed octal integer.
+#
+# [x, X]
+# Matches an optionally signed hexadecimal integer,
+#
+# [a, e, f, g, A, E, F, G]
+# Matches an optionally signed floating-point number.
+#
+# [s]
+# Matches a sequence of non-white-space character. The input string stops at
+# white space or at the maximum field width, whichever occurs first.
+#
+# [c]
+# Matches a single character, or a sequence of <em>n</em> characters if a
+# field width of <em>n</em> is specified. The usual skip of leading white
+# space is suppressed. To skip white space first, use an explicit space in
+# the format.
+#
+# [[]
+# Matches a nonempty sequence of characters from the specified set
+# of accepted characters. The usual skip of leading white space is
+# suppressed. This bracketed sub-expression is interpreted exactly like a
+# character class in a Ruby regular expression. (In fact, it is placed as-is
+# in a regular expression.) The matching against the input string ends with
+# the appearance of a character not in (or, with a circumflex, in) the set,
+# or when the field width runs out, whichever comes first.
+#
+# === Assignment suppression
+#
+# To require that a particular match occur, but without including the result
+# in the return array, place the <b>assignment suppression flag</b>, which is
+# the star character ('*'), immediately after the leading '%' of a format
+# specifier (just before the field width, if any).
+#
+# == scanf for Ruby compared with scanf in C
+#
+# scanf for Ruby is based on the C function scanf(3), but with modifications,
+# dictated mainly by the underlying differences between the languages.
+#
+# === Unimplemented flags and specifiers
+#
+# * The only flag implemented in scanf for Ruby is '<tt>*</tt>' (ignore
+# upcoming conversion). Many of the flags available in C versions of
+# scanf(3) have to do with the type of upcoming pointer arguments, and are
+# meaningless in Ruby.
+#
+# * The <tt>n</tt> specifier (store number of characters consumed so far in
+# next pointer) is not implemented.
+#
+# * The <tt>p</tt> specifier (match a pointer value) is not implemented.
+#
+# === Altered specifiers
+#
+# [o, u, x, X]
+# In scanf for Ruby, all of these specifiers scan for an optionally signed
+# integer, rather than for an unsigned integer like their C counterparts.
+#
+# === Return values
+#
+# scanf for Ruby returns an array of successful conversions, whereas
+# scanf(3) returns the number of conversions successfully
+# completed. (See below for more details on scanf for Ruby's return
+# values.)
+#
+# == Return values
+#
+# Without a block, scanf returns an array containing all the conversions
+# it has found. If none are found, scanf will return an empty array. An
+# unsuccessful match is never ignored, but rather always signals the end
+# of the scanning operation. If the first unsuccessful match takes place
+# after one or more successful matches have already taken place, the
+# returned array will contain the results of those successful matches.
+#
+# With a block scanf returns a 'map'-like array of transformations from
+# the block -- that is, an array reflecting what the block did with each
+# yielded result from the iterative scanf operation. (See "Block
+# usage", above.)
+#
+# == Current limitations and bugs
+#
+# When using IO#scanf under Windows, make sure you open your files in
+# binary mode:
+#
+# File.open("filename", "rb")
+#
+# so that scanf can keep track of characters correctly.
+#
+# Support for character classes is reasonably complete (since it
+# essentially piggy-backs on Ruby's regular expression handling of
+# character classes), but users are advised that character class testing
+# has not been exhaustive, and that they should exercise some caution
+# in using any of the more complex and/or arcane character class
+# idioms.
+#
+# == License and copyright
+#
+# Copyright:: (c) 2002-2003 David Alan Black
+# License:: Distributed on the same licensing terms as Ruby itself
+#
+# == Warranty disclaimer
+#
+# This software is provided "as is" and without any express or implied
+# warranties, including, without limitation, the implied warranties of
+# merchantability and fitness for a particular purpose.
+#
+# == Credits and acknowledgements
+#
+# scanf was developed as the major activity of the Austin Ruby Codefest
+# (Austin, Texas, August 2002).
+#
+# Principal author:: David Alan Black (mailto:dblack@superlink.net)
+# Co-author:: Hal Fulton (mailto:hal9000@hypermetrics.com)
+# Project contributors:: Nolan Darilek, Jason Johnston
+#
+# Thanks to Hal Fulton for hosting the Codefest.
+#
+# Thanks to Matz for suggestions about the class design.
+#
+# Thanks to Gavin Sinclair for some feedback on the documentation.
+#
+# The text for parts of this document, especially the Description and
+# Conversions sections, above, were adapted from the Linux Programmer's
+# Manual manpage for scanf(3), dated 1995-11-01.
+#
+# == Bugs and bug reports
+#
+# scanf for Ruby is based on something of an amalgam of C scanf
+# implementations and documentation, rather than on a single canonical
+# description. Suggestions for features and behaviors which appear in
+# other scanfs, and would be meaningful in Ruby, are welcome, as are
+# reports of suspicious behaviors and/or bugs. (Please see "Credits and
+# acknowledgements", above, for email addresses.)
+
+module Scanf
+ # :stopdoc:
+
+ # ==Technical notes
+ #
+ # ===Rationale behind scanf for Ruby
+ #
+ # The impetus for a scanf implementation in Ruby comes chiefly from the fact
+ # that existing pattern matching operations, such as Regexp#match and
+ # String#scan, return all results as strings, which have to be converted to
+ # integers or floats explicitly in cases where what's ultimately wanted are
+ # integer or float values.
+ #
+ # ===Design of scanf for Ruby
+ #
+ # scanf for Ruby is essentially a <format string>-to-<regular
+ # expression> converter.
+ #
+ # When scanf is called, a FormatString object is generated from the
+ # format string ("%d%s...") argument. The FormatString object breaks the
+ # format string down into atoms ("%d", "%5f", "blah", etc.), and from
+ # each atom it creates a FormatSpecifier object, which it
+ # saves.
+ #
+ # Each FormatSpecifier has a regular expression fragment and a "handler"
+ # associated with it. For example, the regular expression fragment
+ # associated with the format "%d" is "([-+]?\d+)", and the handler
+ # associated with it is a wrapper around String#to_i. scanf itself calls
+ # FormatString#match, passing in the input string. FormatString#match
+ # iterates through its FormatSpecifiers; for each one, it matches the
+ # corresponding regular expression fragment against the string. If
+ # there's a match, it sends the matched string to the handler associated
+ # with the FormatSpecifier.
+ #
+ # Thus, to follow up the "%d" example: if "123" occurs in the input
+ # string when a FormatSpecifier consisting of "%d" is reached, the "123"
+ # will be matched against "([-+]?\d+)", and the matched string will be
+ # rendered into an integer by a call to to_i.
+ #
+ # The rendered match is then saved to an accumulator array, and the
+ # input string is reduced to the post-match substring. Thus the string
+ # is "eaten" from the left as the FormatSpecifiers are applied in
+ # sequence. (This is done to a duplicate string; the original string is
+ # not altered.)
+ #
+ # As soon as a regular expression fragment fails to match the string, or
+ # when the FormatString object runs out of FormatSpecifiers, scanning
+ # stops and results accumulated so far are returned in an array.
+
+ class FormatSpecifier
+
+ attr_reader :re_string, :matched_string, :conversion, :matched
+
+ private
+
+ def skip; /^\s*%\*/.match(@spec_string); end
+
+ def extract_float(s)
+ return nil unless s &&! skip
+ if /\A(?<sign>[-+]?)0[xX](?<frac>\.\h+|\h+(?:\.\h*)?)[pP](?<exp>[-+]?\d+)/ =~ s
+ f1, f2 = frac.split('.')
+ f = f1.hex
+ if f2
+ len = f2.length
+ if len > 0
+ f += f2.hex / (16.0 ** len)
+ end
+ end
+ (sign == ?- ? -1 : 1) * Math.ldexp(f, exp.to_i)
+ elsif /\A([-+]?\d+)\.([eE][-+]\d+)/ =~ s
+ ($1 << $2).to_f
+ else
+ s.to_f
+ end
+ end
+ def extract_decimal(s); s.to_i if s &&! skip; end
+ def extract_hex(s); s.hex if s &&! skip; end
+ def extract_octal(s); s.oct if s &&! skip; end
+ def extract_integer(s); Integer(s) if s &&! skip; end
+ def extract_plain(s); s unless skip; end
+
+ def nil_proc(s); nil; end
+
+ public
+
+ def to_s
+ @spec_string
+ end
+
+ def count_space?
+ /(?:\A|\S)%\*?\d*c|%\d*\[/.match(@spec_string)
+ end
+
+ def initialize(str)
+ @spec_string = str
+ h = '[A-Fa-f0-9]'
+
+ @re_string, @handler =
+ case @spec_string
+
+ # %[[:...:]]
+ when /%\*?(\[\[:[a-z]+:\]\])/
+ [ "(#{$1}+)", :extract_plain ]
+
+ # %5[[:...:]]
+ when /%\*?(\d+)(\[\[:[a-z]+:\]\])/
+ [ "(#{$2}{1,#{$1}})", :extract_plain ]
+
+ # %[...]
+ when /%\*?\[([^\]]*)\]/
+ yes = $1
+ if /^\^/.match(yes) then no = yes[1..-1] else no = '^' + yes end
+ [ "([#{yes}]+)(?=[#{no}]|\\z)", :extract_plain ]
+
+ # %5[...]
+ when /%\*?(\d+)\[([^\]]*)\]/
+ yes = $2
+ w = $1
+ [ "([#{yes}]{1,#{w}})", :extract_plain ]
+
+ # %i
+ when /%\*?i/
+ [ "([-+]?(?:(?:0[0-7]+)|(?:0[Xx]#{h}+)|(?:[1-9]\\d*)))", :extract_integer ]
+
+ # %5i
+ when /%\*?(\d+)i/
+ n = $1.to_i
+ s = "("
+ if n > 1 then s += "[1-9]\\d{1,#{n-1}}|" end
+ if n > 1 then s += "0[0-7]{1,#{n-1}}|" end
+ if n > 2 then s += "[-+]0[0-7]{1,#{n-2}}|" end
+ if n > 2 then s += "[-+][1-9]\\d{1,#{n-2}}|" end
+ if n > 2 then s += "0[Xx]#{h}{1,#{n-2}}|" end
+ if n > 3 then s += "[-+]0[Xx]#{h}{1,#{n-3}}|" end
+ s += "\\d"
+ s += ")"
+ [ s, :extract_integer ]
+
+ # %d, %u
+ when /%\*?[du]/
+ [ '([-+]?\d+)', :extract_decimal ]
+
+ # %5d, %5u
+ when /%\*?(\d+)[du]/
+ n = $1.to_i
+ s = "("
+ if n > 1 then s += "[-+]\\d{1,#{n-1}}|" end
+ s += "\\d{1,#{$1}})"
+ [ s, :extract_decimal ]
+
+ # %x
+ when /%\*?[Xx]/
+ [ "([-+]?(?:0[Xx])?#{h}+)", :extract_hex ]
+
+ # %5x
+ when /%\*?(\d+)[Xx]/
+ n = $1.to_i
+ s = "("
+ if n > 3 then s += "[-+]0[Xx]#{h}{1,#{n-3}}|" end
+ if n > 2 then s += "0[Xx]#{h}{1,#{n-2}}|" end
+ if n > 1 then s += "[-+]#{h}{1,#{n-1}}|" end
+ s += "#{h}{1,#{n}}"
+ s += ")"
+ [ s, :extract_hex ]
+
+ # %o
+ when /%\*?o/
+ [ '([-+]?[0-7]+)', :extract_octal ]
+
+ # %5o
+ when /%\*?(\d+)o/
+ [ "([-+][0-7]{1,#{$1.to_i-1}}|[0-7]{1,#{$1}})", :extract_octal ]
+
+ # %f
+ when /%\*?[aefgAEFG]/
+ [ '([-+]?(?:0[xX](?:\.\h+|\h+(?:\.\h*)?)[pP][-+]?\d+|\d+(?![\d.])|\d*\.\d*(?:[eE][-+]?\d+)?))', :extract_float ]
+
+ # %5f
+ when /%\*?(\d+)[aefgAEFG]/
+ [ '(?=[-+]?(?:0[xX](?:\.\h+|\h+(?:\.\h*)?)[pP][-+]?\d+|\d+(?![\d.])|\d*\.\d*(?:[eE][-+]?\d+)?))' +
+ "(\\S{1,#{$1}})", :extract_float ]
+
+ # %5s
+ when /%\*?(\d+)s/
+ [ "(\\S{1,#{$1}})", :extract_plain ]
+
+ # %s
+ when /%\*?s/
+ [ '(\S+)', :extract_plain ]
+
+ # %c
+ when /\s%\*?c/
+ [ "\\s*(.)", :extract_plain ]
+
+ # %c
+ when /%\*?c/
+ [ "(.)", :extract_plain ]
+
+ # %5c (whitespace issues are handled by the count_*_space? methods)
+ when /%\*?(\d+)c/
+ [ "(.{1,#{$1}})", :extract_plain ]
+
+ # %%
+ when /%%/
+ [ '(\s*%)', :nil_proc ]
+
+ # literal characters
+ else
+ [ "(#{Regexp.escape(@spec_string)})", :nil_proc ]
+ end
+
+ @re_string = '\A' + @re_string
+ end
+
+ def to_re
+ Regexp.new(@re_string,Regexp::MULTILINE)
+ end
+
+ def match(str)
+ @matched = false
+ s = str.dup
+ s.sub!(/\A\s+/,'') unless count_space?
+ res = to_re.match(s)
+ if res
+ @conversion = send(@handler, res[1])
+ @matched_string = @conversion.to_s
+ @matched = true
+ end
+ res
+ end
+
+ def letter
+ @spec_string[/%\*?\d*([a-z\[])/, 1]
+ end
+
+ def width
+ @spec_string[/%\*?(\d+)/, 1]&.to_i
+ end
+
+ def mid_match?
+ return false unless @matched
+ cc_no_width = letter == '[' &&! width
+ c_or_cc_width = (letter == 'c' || letter == '[') && width
+ width_left = c_or_cc_width && (matched_string.size < width)
+
+ return width_left || cc_no_width
+ end
+
+ end
+
+ class FormatString
+
+ attr_reader :string_left, :last_spec_tried,
+ :last_match_tried, :matched_count, :space
+
+ SPECIFIERS = 'diuXxofFeEgGscaA'
+ REGEX = /
+ # possible space, followed by...
+ (?:\s*
+ # percent sign, followed by...
+ %
+ # another percent sign, or...
+ (?:%|
+ # optional assignment suppression flag
+ \*?
+ # optional maximum field width
+ \d*
+ # named character class, ...
+ (?:\[\[:\w+:\]\]|
+ # traditional character class, or...
+ \[[^\]]*\]|
+ # specifier letter.
+ [#{SPECIFIERS}])))|
+ # or miscellaneous characters
+ [^%\s]+/ix
+
+ def initialize(str)
+ @specs = []
+ @i = 1
+ s = str.to_s
+ return unless /\S/.match(s)
+ @space = true if /\s\z/.match(s)
+ @specs.replace s.scan(REGEX).map {|spec| FormatSpecifier.new(spec) }
+ end
+
+ def to_s
+ @specs.join('')
+ end
+
+ def prune(n=matched_count)
+ n.times { @specs.shift }
+ end
+
+ def spec_count
+ @specs.size
+ end
+
+ def last_spec
+ @i == spec_count - 1
+ end
+
+ def match(str)
+ accum = []
+ @string_left = str
+ @matched_count = 0
+
+ @specs.each_with_index do |spec,i|
+ @i=i
+ @last_spec_tried = spec
+ @last_match_tried = spec.match(@string_left)
+ break unless @last_match_tried
+ @matched_count += 1
+
+ accum << spec.conversion
+
+ @string_left = @last_match_tried.post_match
+ break if @string_left.empty?
+ end
+ return accum.compact
+ end
+ end
+ # :startdoc:
+end
+
+class IO
+
+ #:stopdoc:
+ # The trick here is doing a match where you grab one *line*
+ # of input at a time. The linebreak may or may not occur
+ # at the boundary where the string matches a format specifier.
+ # And if it does, some rule about whitespace may or may not
+ # be in effect...
+ #
+ # That's why this is much more elaborate than the string
+ # version.
+ #
+ # For each line:
+ #
+ # Match succeeds (non-emptily)
+ # and the last attempted spec/string sub-match succeeded:
+ #
+ # could the last spec keep matching?
+ # yes: save interim results and continue (next line)
+ #
+ # The last attempted spec/string did not match:
+ #
+ # are we on the next-to-last spec in the string?
+ # yes:
+ # is fmt_string.string_left all spaces?
+ # yes: does current spec care about input space?
+ # yes: fatal failure
+ # no: save interim results and continue
+ # no: continue [this state could be analyzed further]
+ #
+ #:startdoc:
+
+ # Scans the current string until the match is exhausted,
+ # yielding each match as it is encountered in the string.
+ # A block is not necessary though, as the results will simply
+ # be aggregated into the final array.
+ #
+ # "123 456".block_scanf("%d")
+ # # => [123, 456]
+ #
+ # If a block is given, the value from that is returned from
+ # the yield is added to an output array.
+ #
+ # "123 456".block_scanf("%d") do |digit,| # the ',' unpacks the Array
+ # digit + 100
+ # end
+ # # => [223, 556]
+ #
+ # See Scanf for details on creating a format string.
+ #
+ # You will need to require 'scanf' to use IO#scanf.
+ def scanf(str,&b) #:yield: current_match
+ return block_scanf(str,&b) if b
+ return [] unless str.size > 0
+
+ start_position = pos rescue 0
+ matched_so_far = 0
+ source_buffer = ""
+ result_buffer = []
+ final_result = []
+
+ fstr = Scanf::FormatString.new(str)
+
+ loop do
+ if eof || (tty? &&! fstr.match(source_buffer))
+ final_result.concat(result_buffer)
+ break
+ end
+
+ source_buffer << gets
+
+ current_match = fstr.match(source_buffer)
+
+ spec = fstr.last_spec_tried
+
+ if spec.matched
+ if spec.mid_match?
+ result_buffer.replace(current_match)
+ next
+ end
+
+ elsif (fstr.matched_count == fstr.spec_count - 1)
+ if /\A\s*\z/.match(fstr.string_left)
+ break if spec.count_space?
+ result_buffer.replace(current_match)
+ next
+ end
+ end
+
+ final_result.concat(current_match)
+
+ matched_so_far += source_buffer.size
+ source_buffer.replace(fstr.string_left)
+ matched_so_far -= source_buffer.size
+ break if fstr.last_spec
+ fstr.prune
+ end
+
+ begin
+ seek(start_position + matched_so_far, IO::SEEK_SET)
+ rescue Errno::ESPIPE, Errno::EINVAL
+ end
+
+ soak_up_spaces if fstr.last_spec && fstr.space
+
+ return final_result
+ end
+
+ private
+
+ def soak_up_spaces
+ c = getc
+ ungetc(c) if c
+ until eof ||! c || /\S/.match(c.chr)
+ c = getc
+ end
+ ungetc(c) if (c && /\S/.match(c.chr))
+ end
+
+ def block_scanf(str)
+ final = []
+# Sub-ideal, since another FS gets created in scanf.
+# But used here to determine the number of specifiers.
+ fstr = Scanf::FormatString.new(str)
+ last_spec = fstr.last_spec
+ begin
+ current = scanf(str)
+ break if current.empty?
+ final.push(yield(current))
+ end until eof || fstr.last_spec_tried == last_spec
+ return final
+ end
+end
+
+class String
+
+ # :section: scanf
+ #
+ # You will need to require 'scanf' to use these methods
+
+ # Scans the current string. If a block is given, it
+ # functions exactly like block_scanf.
+ #
+ # arr = "123 456".scanf("%d%d")
+ # # => [123, 456]
+ #
+ # require 'pp'
+ #
+ # "this 123 read that 456 other".scanf("%s%d%s") {|m| pp m}
+ #
+ # # ["this", 123, "read"]
+ # # ["that", 456, "other"]
+ # # => [["this", 123, "read"], ["that", 456, "other"]]
+ #
+ # See Scanf for details on creating a format string.
+ #
+ # You will need to require 'scanf' to use String#scanf
+ def scanf(fstr,&b) #:yield: current_match
+ if b
+ block_scanf(fstr,&b)
+ else
+ fs =
+ if fstr.is_a? Scanf::FormatString
+ fstr
+ else
+ Scanf::FormatString.new(fstr)
+ end
+ fs.match(self)
+ end
+ end
+
+ # Scans the current string until the match is exhausted
+ # yielding each match as it is encountered in the string.
+ # A block is not necessary as the results will simply
+ # be aggregated into the final array.
+ #
+ # "123 456".block_scanf("%d")
+ # # => [123, 456]
+ #
+ # If a block is given, the value from that is returned from
+ # the yield is added to an output array.
+ #
+ # "123 456".block_scanf("%d) do |digit,| # the ',' unpacks the Array
+ # digit + 100
+ # end
+ # # => [223, 556]
+ #
+ # See Scanf for details on creating a format string.
+ #
+ # You will need to require 'scanf' to use String#block_scanf
+ def block_scanf(fstr) #:yield: current_match
+ fs = Scanf::FormatString.new(fstr)
+ str = self.dup
+ final = []
+ begin
+ current = str.scanf(fs)
+ final.push(yield(current)) unless current.empty?
+ str = fs.string_left
+ end until current.empty? || str.empty?
+ return final
+ end
+end
+
+module Kernel
+ private
+ # Scans STDIN for data matching +format+. See IO#scanf for details.
+ #
+ # See Scanf for details on creating a format string.
+ #
+ # You will need to require 'scanf' to use Kernel#scanf.
+ def scanf(format, &b) #:doc:
+ STDIN.scanf(format ,&b)
+ end
+end
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 205cb70be5..e2632457ff 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -16,53 +16,31 @@
# * /dev/urandom
# * Win32
#
-# SecureRandom is extended by the Random::Formatter module which
-# defines the following methods:
-#
-# * alphanumeric
-# * base64
-# * choose
-# * gen_random
-# * hex
-# * rand
-# * random_bytes
-# * random_number
-# * urlsafe_base64
-# * uuid
-#
-# These methods are usable as class methods of SecureRandom such as
-# `SecureRandom.hex`.
-#
# === Examples
#
# Generate random hexadecimal strings:
#
# require 'securerandom'
#
-# SecureRandom.hex(10) #=> "52750b30ffbc7de3b362"
-# SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559"
-# SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23"
+# p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362"
+# p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559"
+# p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23"
#
# Generate random base64 strings:
#
-# SecureRandom.base64(10) #=> "EcmTPZwWRAozdA=="
-# SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg=="
-# SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8"
+# p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA=="
+# p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg=="
+# p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8"
#
# Generate random binary strings:
#
-# SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301"
-# SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337"
-#
-# Generate alphanumeric strings:
-#
-# SecureRandom.alphanumeric(10) #=> "S8baxMJnPl"
-# SecureRandom.alphanumeric(10) #=> "aOxAg8BAJe"
+# p SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301"
+# p SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337"
#
# Generate UUIDs:
#
-# SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
-# SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
+# p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
+# p SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
#
module SecureRandom
@@ -143,10 +121,8 @@ module Random::Formatter
#
# The result may contain any byte: "\x00" - "\xff".
#
- # require 'securerandom'
- #
- # SecureRandom.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
- # SecureRandom.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
+ # p SecureRandom.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
+ # p SecureRandom.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
#
# If a secure random number generator is not available,
# +NotImplementedError+ is raised.
@@ -165,10 +141,8 @@ module Random::Formatter
#
# The result may contain 0-9 and a-f.
#
- # require 'securerandom'
- #
- # SecureRandom.hex #=> "eb693ec8252cd630102fd0d0fb7c3485"
- # SecureRandom.hex #=> "91dc3bfb4de5b11d029d376634589b61"
+ # p SecureRandom.hex #=> "eb693ec8252cd630102fd0d0fb7c3485"
+ # p SecureRandom.hex #=> "91dc3bfb4de5b11d029d376634589b61"
#
# If a secure random number generator is not available,
# +NotImplementedError+ is raised.
@@ -186,10 +160,8 @@ module Random::Formatter
#
# The result may contain A-Z, a-z, 0-9, "+", "/" and "=".
#
- # require 'securerandom'
- #
- # SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
- # SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
+ # p SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
+ # p SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
#
# If a secure random number generator is not available,
# +NotImplementedError+ is raised.
@@ -215,13 +187,11 @@ module Random::Formatter
# The result may contain A-Z, a-z, 0-9, "-" and "_".
# "=" is also used if _padding_ is true.
#
- # require 'securerandom'
- #
- # SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
- # SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
+ # p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
+ # p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
#
- # SecureRandom.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ=="
- # SecureRandom.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg=="
+ # p SecureRandom.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ=="
+ # p SecureRandom.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg=="
#
# If a secure random number generator is not available,
# +NotImplementedError+ is raised.
@@ -236,11 +206,9 @@ module Random::Formatter
# SecureRandom.uuid generates a random v4 UUID (Universally Unique IDentifier).
#
- # require 'securerandom'
- #
- # SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
- # SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
- # SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
+ # p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
+ # p SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
+ # p SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
#
# The version 4 UUID is purely random (except the version).
# It doesn't contain meaningful information such as MAC addresses, timestamps, etc.
@@ -270,10 +238,8 @@ module Random::Formatter
#
# The result may contain whatever characters are in the source array.
#
- # require 'securerandom'
- #
- # SecureRandom.choose([*'l'..'r'], 16) #=> "lmrqpoonmmlqlron"
- # SecureRandom.choose([*'0'..'9'], 5) #=> "27309"
+ # p SecureRandom.choose([*'l'..'r'], 16) #=> "lmrqpoonmmlqlron"
+ # p SecureRandom.choose([*'0'..'9'], 5) #=> "27309"
#
# If a secure random number generator is not available,
# +NotImplementedError+ is raised.
@@ -317,10 +283,8 @@ module Random::Formatter
#
# The result may contain A-Z, a-z and 0-9.
#
- # require 'securerandom'
- #
- # SecureRandom.alphanumeric #=> "2BuBuLf3WfSKyQbR"
- # SecureRandom.alphanumeric(10) #=> "i6K93NdqiH"
+ # p SecureRandom.alphanumeric #=> "2BuBuLf3WfSKyQbR"
+ # p SecureRandom.alphanumeric(10) #=> "i6K93NdqiH"
#
# If a secure random number generator is not available,
# +NotImplementedError+ is raised.
diff --git a/lib/set.rb b/lib/set.rb
index 1b0e3ae6fc..9642e74af4 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -147,6 +147,16 @@ class Set
super
end
+ def taint # :nodoc:
+ @hash.taint
+ super
+ end
+
+ def untaint # :nodoc:
+ @hash.untaint
+ super
+ end
+
# Returns the number of elements.
def size
@hash.size
@@ -414,9 +424,6 @@ class Set
self if size != n
end
- # Equivalent to Set#select!
- alias filter! select!
-
# Merges the elements of the given enumerable object to the set and
# returns self.
def merge(enum)
@@ -517,7 +524,7 @@ class Set
if @hash.respond_to?(:rehash)
@hash.rehash # This should perform frozenness check.
else
- raise FrozenError, "can't modify frozen #{self.class.name}" if frozen?
+ raise "can't modify frozen #{self.class.name}" if frozen?
end
self
end
@@ -691,7 +698,6 @@ class SortedSet < Set
def setup # :nodoc:
@@setup and return
- ret = nil
@@mutex.synchronize do
# a hack to shut up warning
@@ -699,7 +705,6 @@ class SortedSet < Set
begin
require 'rbtree'
- ret = :rbtree
module_eval <<-END, __FILE__, __LINE__+1
def initialize(*args)
@@ -714,7 +719,6 @@ class SortedSet < Set
alias << add
END
rescue LoadError
- ret = true
module_eval <<-END, __FILE__, __LINE__+1
def initialize(*args)
@keys = nil
@@ -791,18 +795,13 @@ class SortedSet < Set
remove_method :old_init
@@setup = true
- ret
end
end
end
def initialize(*args, &block) # :nodoc:
- if SortedSet.setup == :rbtree
- @hash = RBTree.new
- else
- @keys = nil
- end
- super
+ SortedSet.setup
+ initialize(*args, &block)
end
end
diff --git a/lib/shell.rb b/lib/shell.rb
new file mode 100644
index 0000000000..fb63717391
--- /dev/null
+++ b/lib/shell.rb
@@ -0,0 +1,461 @@
+# frozen_string_literal: false
+#
+# shell.rb -
+# $Release Version: 0.7 $
+# $Revision: 1.9 $
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+require "e2mmap"
+
+require "forwardable"
+
+require "shell/error"
+require "shell/command-processor"
+require "shell/process-controller"
+
+# Shell implements an idiomatic Ruby interface for common UNIX shell commands.
+#
+# It provides users the ability to execute commands with filters and pipes,
+# like +sh+/+csh+ by using native facilities of Ruby.
+#
+# == Examples
+#
+# === Temp file creation
+#
+# In this example we will create three +tmpFile+'s in three different folders
+# under the +/tmp+ directory.
+#
+# sh = Shell.cd("/tmp") # Change to the /tmp directory
+# sh.mkdir "shell-test-1" unless sh.exists?("shell-test-1")
+# # make the 'shell-test-1' directory if it doesn't already exist
+# sh.cd("shell-test-1") # Change to the /tmp/shell-test-1 directory
+# for dir in ["dir1", "dir3", "dir5"]
+# if !sh.exists?(dir)
+# sh.mkdir dir # make dir if it doesn't already exist
+# sh.cd(dir) do
+# # change to the `dir` directory
+# f = sh.open("tmpFile", "w") # open a new file in write mode
+# f.print "TEST\n" # write to the file
+# f.close # close the file handler
+# end
+# print sh.pwd # output the process working directory
+# end
+# end
+#
+# === Temp file creation with self
+#
+# This example is identical to the first, except we're using
+# CommandProcessor#transact.
+#
+# CommandProcessor#transact executes the given block against self, in this case
+# +sh+; our Shell object. Within the block we can substitute +sh.cd+ to +cd+,
+# because the scope within the block uses +sh+ already.
+#
+# sh = Shell.cd("/tmp")
+# sh.transact do
+# mkdir "shell-test-1" unless exists?("shell-test-1")
+# cd("shell-test-1")
+# for dir in ["dir1", "dir3", "dir5"]
+# if !exists?(dir)
+# mkdir dir
+# cd(dir) do
+# f = open("tmpFile", "w")
+# f.print "TEST\n"
+# f.close
+# end
+# print pwd
+# end
+# end
+# end
+#
+# === Pipe /etc/printcap into a file
+#
+# In this example we will read the operating system file +/etc/printcap+,
+# generated by +cupsd+, and then output it to a new file relative to the +pwd+
+# of +sh+.
+#
+# sh = Shell.new
+# sh.cat("/etc/printcap") | sh.tee("tee1") > "tee2"
+# (sh.cat < "/etc/printcap") | sh.tee("tee11") > "tee12"
+# sh.cat("/etc/printcap") | sh.tee("tee1") >> "tee2"
+# (sh.cat < "/etc/printcap") | sh.tee("tee11") >> "tee12"
+#
+class Shell
+
+ include Error
+ extend Exception2MessageMapper
+
+ # debug: true -> normal debug
+ # debug: 1 -> eval definition debug
+ # debug: 2 -> detail inspect debug
+ @debug = false
+ @verbose = true
+
+ @debug_display_process_id = false
+ @debug_display_thread_id = true
+ @debug_output_mutex = Thread::Mutex.new
+ @default_system_path = nil
+ @default_record_separator = nil
+
+ class << Shell
+ extend Forwardable
+
+ attr_accessor :cascade, :verbose
+ attr_reader :debug
+
+ alias debug? debug
+ alias verbose? verbose
+ @verbose = true
+
+ def debug=(val)
+ @debug = val
+ @verbose = val if val
+ end
+
+
+ # call-seq:
+ # Shell.cd(path)
+ #
+ # Creates a new Shell instance with the current working directory
+ # set to +path+.
+ def cd(path)
+ new(path)
+ end
+
+ # Returns the directories in the current shell's PATH environment variable
+ # as an array of directory names. This sets the system_path for all
+ # instances of Shell.
+ #
+ # Example: If in your current shell, you did:
+ #
+ # $ echo $PATH
+ # /usr/bin:/bin:/usr/local/bin
+ #
+ # Running this method in the above shell would then return:
+ #
+ # ["/usr/bin", "/bin", "/usr/local/bin"]
+ #
+ def default_system_path
+ if @default_system_path
+ @default_system_path
+ else
+ ENV["PATH"].split(":")
+ end
+ end
+
+ # Sets the system_path that new instances of Shell should have as their
+ # initial system_path.
+ #
+ # +path+ should be an array of directory name strings.
+ def default_system_path=(path)
+ @default_system_path = path
+ end
+
+ def default_record_separator
+ if @default_record_separator
+ @default_record_separator
+ else
+ $/
+ end
+ end
+
+ def default_record_separator=(rs)
+ @default_record_separator = rs
+ end
+
+ # os resource mutex
+ mutex_methods = ["unlock", "lock", "locked?", "synchronize", "try_lock"]
+ for m in mutex_methods
+ def_delegator("@debug_output_mutex", m, "debug_output_"+m.to_s)
+ end
+
+ end
+
+ # call-seq:
+ # Shell.new(pwd, umask) -> obj
+ #
+ # Creates a Shell object which current directory is set to the process
+ # current directory, unless otherwise specified by the +pwd+ argument.
+ def initialize(pwd = Dir.pwd, umask = nil)
+ @cwd = File.expand_path(pwd)
+ @dir_stack = []
+ @umask = umask
+
+ @system_path = Shell.default_system_path
+ @record_separator = Shell.default_record_separator
+
+ @command_processor = CommandProcessor.new(self)
+ @process_controller = ProcessController.new(self)
+
+ @verbose = Shell.verbose
+ @debug = Shell.debug
+ end
+
+ # Returns the command search path in an array
+ attr_reader :system_path
+
+ # Sets the system path (the Shell instance's PATH environment variable).
+ #
+ # +path+ should be an array of directory name strings.
+ def system_path=(path)
+ @system_path = path
+ rehash
+ end
+
+
+ # Returns the umask
+ attr_accessor :umask
+ attr_accessor :record_separator
+ attr_accessor :verbose
+ attr_reader :debug
+
+ def debug=(val)
+ @debug = val
+ @verbose = val if val
+ end
+
+ alias verbose? verbose
+ alias debug? debug
+
+ attr_reader :command_processor
+ attr_reader :process_controller
+
+ def expand_path(path)
+ File.expand_path(path, @cwd)
+ end
+
+ # Most Shell commands are defined via CommandProcessor
+
+ #
+ # Dir related methods
+ #
+ # Shell#cwd/dir/getwd/pwd
+ # Shell#chdir/cd
+ # Shell#pushdir/pushd
+ # Shell#popdir/popd
+ # Shell#mkdir
+ # Shell#rmdir
+
+ # Returns the current working directory.
+ attr_reader :cwd
+ alias dir cwd
+ alias getwd cwd
+ alias pwd cwd
+
+ attr_reader :dir_stack
+ alias dirs dir_stack
+
+ # call-seq:
+ # Shell.chdir(path)
+ #
+ # Creates a Shell object which current directory is set to +path+.
+ #
+ # If a block is given, it restores the current directory when the block ends.
+ #
+ # If called as iterator, it restores the current directory when the
+ # block ends.
+ def chdir(path = nil, verbose = @verbose)
+ check_point
+
+ if iterator?
+ notify("chdir(with block) #{path}") if verbose
+ cwd_old = @cwd
+ begin
+ chdir(path, nil)
+ yield
+ ensure
+ chdir(cwd_old, nil)
+ end
+ else
+ notify("chdir #{path}") if verbose
+ path = "~" unless path
+ @cwd = expand_path(path)
+ notify "current dir: #{@cwd}"
+ rehash
+ Void.new(self)
+ end
+ end
+ alias cd chdir
+
+ # call-seq:
+ # pushdir(path)
+ # pushdir(path) { &block }
+ #
+ # Pushes the current directory to the directory stack, changing the current
+ # directory to +path+.
+ #
+ # If +path+ is omitted, it exchanges its current directory and the top of its
+ # directory stack.
+ #
+ # If a block is given, it restores the current directory when the block ends.
+ def pushdir(path = nil, verbose = @verbose)
+ check_point
+
+ if iterator?
+ notify("pushdir(with block) #{path}") if verbose
+ pushdir(path, nil)
+ begin
+ yield
+ ensure
+ popdir
+ end
+ elsif path
+ notify("pushdir #{path}") if verbose
+ @dir_stack.push @cwd
+ chdir(path, nil)
+ notify "dir stack: [#{@dir_stack.join ', '}]"
+ self
+ else
+ notify("pushdir") if verbose
+ if pop = @dir_stack.pop
+ @dir_stack.push @cwd
+ chdir pop
+ notify "dir stack: [#{@dir_stack.join ', '}]"
+ self
+ else
+ Shell.Fail DirStackEmpty
+ end
+ end
+ Void.new(self)
+ end
+ alias pushd pushdir
+
+ # Pops a directory from the directory stack, and sets the current directory
+ # to it.
+ def popdir
+ check_point
+
+ notify("popdir")
+ if pop = @dir_stack.pop
+ chdir pop
+ notify "dir stack: [#{@dir_stack.join ', '}]"
+ self
+ else
+ Shell.Fail DirStackEmpty
+ end
+ Void.new(self)
+ end
+ alias popd popdir
+
+ # Returns a list of scheduled jobs.
+ def jobs
+ @process_controller.jobs
+ end
+
+ # call-seq:
+ # kill(signal, job)
+ #
+ # Sends the given +signal+ to the given +job+
+ def kill(sig, command)
+ @process_controller.kill_job(sig, command)
+ end
+
+ # call-seq:
+ # def_system_command(command, path = command)
+ #
+ # Convenience method for Shell::CommandProcessor.def_system_command.
+ # Defines an instance method which will execute the given shell command.
+ # If the executable is not in Shell.default_system_path, you must
+ # supply the path to it.
+ #
+ # Shell.def_system_command('hostname')
+ # Shell.new.hostname # => localhost
+ #
+ # # How to use an executable that's not in the default path
+ #
+ # Shell.def_system_command('run_my_program', "~/hello")
+ # Shell.new.run_my_program # prints "Hello from a C program!"
+ #
+ def Shell.def_system_command(command, path = command)
+ CommandProcessor.def_system_command(command, path)
+ end
+
+ # Convenience method for Shell::CommandProcessor.undef_system_command
+ def Shell.undef_system_command(command)
+ CommandProcessor.undef_system_command(command)
+ end
+
+ # call-seq:
+ # alias_command(alias, command, *opts, &block)
+ #
+ # Convenience method for Shell::CommandProcessor.alias_command.
+ # Defines an instance method which will execute a command under
+ # an alternative name.
+ #
+ # Shell.def_system_command('date')
+ # Shell.alias_command('date_in_utc', 'date', '-u')
+ # Shell.new.date_in_utc # => Sat Jan 25 16:59:57 UTC 2014
+ #
+ def Shell.alias_command(ali, command, *opts, &block)
+ CommandProcessor.alias_command(ali, command, *opts, &block)
+ end
+
+ # Convenience method for Shell::CommandProcessor.unalias_command
+ def Shell.unalias_command(ali)
+ CommandProcessor.unalias_command(ali)
+ end
+
+ # call-seq:
+ # install_system_commands(pre = "sys_")
+ #
+ # Convenience method for Shell::CommandProcessor.install_system_commands.
+ # Defines instance methods representing all the executable files found in
+ # Shell.default_system_path, with the given prefix prepended to their
+ # names.
+ #
+ # Shell.install_system_commands
+ # Shell.new.sys_echo("hello") # => hello
+ #
+ def Shell.install_system_commands(pre = "sys_")
+ CommandProcessor.install_system_commands(pre)
+ end
+
+ #
+ def inspect
+ if debug.kind_of?(Integer) && debug > 2
+ super
+ else
+ to_s
+ end
+ end
+
+ def self.notify(*opts)
+ Shell::debug_output_synchronize do
+ if opts[-1].kind_of?(String)
+ yorn = verbose?
+ else
+ yorn = opts.pop
+ end
+ return unless yorn
+
+ if @debug_display_thread_id
+ if @debug_display_process_id
+ prefix = "shell(##{Process.pid}:#{Thread.current.to_s.sub("Thread", "Th")}): "
+ else
+ prefix = "shell(#{Thread.current.to_s.sub("Thread", "Th")}): "
+ end
+ else
+ prefix = "shell: "
+ end
+ _head = true
+ STDERR.print opts.collect{|mes|
+ mes = mes.dup
+ yield mes if iterator?
+ if _head
+ _head = false
+ prefix + mes
+ else
+ " "* prefix.size + mes
+ end
+ }.join("\n")+"\n"
+ end
+ end
+
+ CommandProcessor.initialize
+ CommandProcessor.run_config
+end
diff --git a/lib/shell/builtin-command.rb b/lib/shell/builtin-command.rb
new file mode 100644
index 0000000000..e419a68c33
--- /dev/null
+++ b/lib/shell/builtin-command.rb
@@ -0,0 +1,147 @@
+# frozen_string_literal: false
+#
+# shell/builtin-command.rb -
+# $Release Version: 0.7 $
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+require "shell/filter"
+
+class Shell
+ class BuiltInCommand < Filter
+ def wait?
+ false
+ end
+ def active?
+ true
+ end
+ end
+
+ class Void < BuiltInCommand
+ def initialize(sh, *opts)
+ super sh
+ end
+
+ def each(rs = nil)
+ # do nothing
+ end
+ end
+
+ class Echo < BuiltInCommand
+ def initialize(sh, *strings)
+ super sh
+ @strings = strings
+ end
+
+ def each(rs = nil)
+ rs = @shell.record_separator unless rs
+ for str in @strings
+ yield str + rs
+ end
+ end
+ end
+
+ class Cat < BuiltInCommand
+ def initialize(sh, *filenames)
+ super sh
+ @cat_files = filenames
+ end
+
+ def each(rs = nil)
+ if @cat_files.empty?
+ super
+ else
+ for src in @cat_files
+ @shell.foreach(src, rs){|l| yield l}
+ end
+ end
+ end
+ end
+
+ class Glob < BuiltInCommand
+ def initialize(sh, pattern)
+ super sh
+
+ @pattern = pattern
+ end
+
+ def each(rs = nil)
+ if @pattern[0] == ?/
+ @files = Dir[@pattern]
+ else
+ prefix = @shell.pwd+"/"
+ @files = Dir[prefix+@pattern].collect{|p| p.sub(prefix, "")}
+ end
+ rs = @shell.record_separator unless rs
+ for f in @files
+ yield f+rs
+ end
+ end
+ end
+
+ class AppendIO < BuiltInCommand
+ def initialize(sh, io, filter)
+ super sh
+ @input = filter
+ @io = io
+ end
+
+ def input=(filter)
+ @input.input=filter
+ for l in @input
+ @io << l
+ end
+ end
+
+ end
+
+ class AppendFile < AppendIO
+ def initialize(sh, to_filename, filter)
+ @file_name = to_filename
+ io = sh.open(to_filename, "a")
+ super(sh, io, filter)
+ end
+
+ def input=(filter)
+ begin
+ super
+ ensure
+ @io.close
+ end
+ end
+ end
+
+ class Tee < BuiltInCommand
+ def initialize(sh, filename)
+ super sh
+ @to_filename = filename
+ end
+
+ def each(rs = nil)
+ to = @shell.open(@to_filename, "w")
+ begin
+ super{|l| to << l; yield l}
+ ensure
+ to.close
+ end
+ end
+ end
+
+ class Concat < BuiltInCommand
+ def initialize(sh, *jobs)
+ super(sh)
+ @jobs = jobs
+ end
+
+ def each(rs = nil)
+ while job = @jobs.shift
+ job.each{|l| yield l}
+ end
+ end
+ end
+end
diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb
new file mode 100644
index 0000000000..08ea5c874c
--- /dev/null
+++ b/lib/shell/command-processor.rb
@@ -0,0 +1,671 @@
+# frozen_string_literal: false
+#
+# shell/command-controller.rb -
+# $Release Version: 0.7 $
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+require "e2mmap"
+
+require "shell/error"
+require "shell/filter"
+require "shell/system-command"
+require "shell/builtin-command"
+
+class Shell
+ # In order to execute a command on your OS, you need to define it as a
+ # Shell method.
+ #
+ # Alternatively, you can execute any command via
+ # Shell::CommandProcessor#system even if it is not defined.
+ class CommandProcessor
+
+ #
+ # initialize of Shell and related classes.
+ #
+ m = [:initialize, :expand_path]
+ if Object.methods.first.kind_of?(String)
+ NoDelegateMethods = m.collect{|x| x.id2name}
+ else
+ NoDelegateMethods = m
+ end
+
+ def self.initialize
+
+ install_builtin_commands
+
+ # define CommandProcessor#methods to Shell#methods and Filter#methods
+ for m in CommandProcessor.instance_methods(false) - NoDelegateMethods
+ add_delegate_command_to_shell(m)
+ end
+
+ def self.method_added(id)
+ add_delegate_command_to_shell(id)
+ end
+ end
+
+ #
+ # include run file.
+ #
+ def self.run_config
+ rc = "~/.rb_shell"
+ begin
+ load File.expand_path(rc) if ENV.key?("HOME")
+ rescue LoadError, Errno::ENOENT
+ rescue
+ print "load error: #{rc}\n"
+ print $!.class, ": ", $!, "\n"
+ for err in $@[0, $@.size - 2]
+ print "\t", err, "\n"
+ end
+ end
+ end
+
+ def initialize(shell)
+ @shell = shell
+ @system_commands = {}
+ end
+
+ #
+ # CommandProcessor#expand_path(path)
+ # path: String
+ # return: String
+ # returns the absolute path for <path>
+ #
+ def expand_path(path)
+ @shell.expand_path(path)
+ end
+
+ # call-seq:
+ # foreach(path, record_separator) -> Enumerator
+ # foreach(path, record_separator) { block }
+ #
+ # See IO.foreach when +path+ is a file.
+ #
+ # See Dir.foreach when +path+ is a directory.
+ #
+ def foreach(path = nil, *rs)
+ path = "." unless path
+ path = expand_path(path)
+
+ if File.directory?(path)
+ Dir.foreach(path){|fn| yield fn}
+ else
+ IO.foreach(path, *rs){|l| yield l}
+ end
+ end
+
+ # call-seq:
+ # open(path, mode, permissions) -> Enumerator
+ # open(path, mode, permissions) { block }
+ #
+ # See IO.open when +path+ is a file.
+ #
+ # See Dir.open when +path+ is a directory.
+ #
+ def open(path, mode = nil, perm = 0666, &b)
+ path = expand_path(path)
+ if File.directory?(path)
+ Dir.open(path, &b)
+ else
+ if @shell.umask
+ f = File.open(path, mode, perm)
+ File.chmod(perm & ~@shell.umask, path)
+ if block_given?
+ f.each(&b)
+ end
+ f
+ else
+ File.open(path, mode, perm, &b)
+ end
+ end
+ end
+
+ # call-seq:
+ # unlink(path)
+ #
+ # See IO.unlink when +path+ is a file.
+ #
+ # See Dir.unlink when +path+ is a directory.
+ #
+ def unlink(path)
+ @shell.check_point
+
+ path = expand_path(path)
+ if File.directory?(path)
+ Dir.unlink(path)
+ else
+ IO.unlink(path)
+ end
+ Void.new(@shell)
+ end
+
+ # See Shell::CommandProcessor#test
+ alias top_level_test test
+ # call-seq:
+ # test(command, file1, file2) -> true or false
+ # [command, file1, file2] -> true or false
+ #
+ # Tests if the given +command+ exists in +file1+, or optionally +file2+.
+ #
+ # Example:
+ # sh[?e, "foo"]
+ # sh[:e, "foo"]
+ # sh["e", "foo"]
+ # sh[:exists?, "foo"]
+ # sh["exists?", "foo"]
+ #
+ def test(command, file1, file2=nil)
+ file1 = expand_path(file1)
+ file2 = expand_path(file2) if file2
+ command = command.id2name if command.kind_of?(Symbol)
+
+ case command
+ when Integer
+ if file2
+ top_level_test(command, file1, file2)
+ else
+ top_level_test(command, file1)
+ end
+ when String
+ if command.size == 1
+ if file2
+ top_level_test(command, file1, file2)
+ else
+ top_level_test(command, file1)
+ end
+ else
+ unless FileTest.methods(false).include?(command.to_sym)
+ raise "unsupported command: #{ command }"
+ end
+ if file2
+ FileTest.send(command, file1, file2)
+ else
+ FileTest.send(command, file1)
+ end
+ end
+ end
+ end
+ # See Shell::CommandProcessor#test
+ alias [] test
+
+ # call-seq:
+ # mkdir(path)
+ #
+ # Same as Dir.mkdir, except multiple directories are allowed.
+ def mkdir(*path)
+ @shell.check_point
+ notify("mkdir #{path.join(' ')}")
+
+ perm = nil
+ if path.last.kind_of?(Integer)
+ perm = path.pop
+ end
+ for dir in path
+ d = expand_path(dir)
+ if perm
+ Dir.mkdir(d, perm)
+ else
+ Dir.mkdir(d)
+ end
+ File.chmod(d, 0666 & ~@shell.umask) if @shell.umask
+ end
+ Void.new(@shell)
+ end
+
+ # call-seq:
+ # rmdir(path)
+ #
+ # Same as Dir.rmdir, except multiple directories are allowed.
+ def rmdir(*path)
+ @shell.check_point
+ notify("rmdir #{path.join(' ')}")
+
+ for dir in path
+ Dir.rmdir(expand_path(dir))
+ end
+ Void.new(@shell)
+ end
+
+ # call-seq:
+ # system(command, *options) -> SystemCommand
+ #
+ # Executes the given +command+ with the +options+ parameter.
+ #
+ # Example:
+ # print sh.system("ls", "-l")
+ # sh.system("ls", "-l") | sh.head > STDOUT
+ #
+ def system(command, *opts)
+ if opts.empty?
+ if command =~ /\*|\?|\{|\}|\[|\]|<|>|\(|\)|~|&|\||\\|\$|;|'|`|"|\n/
+ return SystemCommand.new(@shell, find_system_command("sh"), "-c", command)
+ else
+ command, *opts = command.split(/\s+/)
+ end
+ end
+ SystemCommand.new(@shell, find_system_command(command), *opts)
+ end
+
+ # call-seq:
+ # rehash
+ #
+ # Clears the command hash table.
+ def rehash
+ @system_commands = {}
+ end
+
+ def check_point # :nodoc:
+ @shell.process_controller.wait_all_jobs_execution
+ end
+ alias finish_all_jobs check_point # :nodoc:
+
+ # call-seq:
+ # transact { block }
+ #
+ # Executes a block as self
+ #
+ # Example:
+ # sh.transact { system("ls", "-l") | head > STDOUT }
+ def transact(&block)
+ begin
+ @shell.instance_eval(&block)
+ ensure
+ check_point
+ end
+ end
+
+ # call-seq:
+ # out(device) { block }
+ #
+ # Calls <code>device.print</code> on the result passing the _block_ to
+ # #transact
+ def out(dev = STDOUT, &block)
+ dev.print transact(&block)
+ end
+
+ # call-seq:
+ # echo(*strings) -> Echo
+ #
+ # Returns a Echo object, for the given +strings+
+ def echo(*strings)
+ Echo.new(@shell, *strings)
+ end
+
+ # call-seq:
+ # cat(*filename) -> Cat
+ #
+ # Returns a Cat object, for the given +filenames+
+ def cat(*filenames)
+ Cat.new(@shell, *filenames)
+ end
+
+ # def sort(*filenames)
+ # Sort.new(self, *filenames)
+ # end
+ # call-seq:
+ # glob(pattern) -> Glob
+ #
+ # Returns a Glob filter object, with the given +pattern+ object
+ def glob(pattern)
+ Glob.new(@shell, pattern)
+ end
+
+ def append(to, filter)
+ case to
+ when String
+ AppendFile.new(@shell, to, filter)
+ when IO
+ AppendIO.new(@shell, to, filter)
+ else
+ Shell.Fail Error::CantApplyMethod, "append", to.class
+ end
+ end
+
+ # call-seq:
+ # tee(file) -> Tee
+ #
+ # Returns a Tee filter object, with the given +file+ command
+ def tee(file)
+ Tee.new(@shell, file)
+ end
+
+ # call-seq:
+ # concat(*jobs) -> Concat
+ #
+ # Returns a Concat object, for the given +jobs+
+ def concat(*jobs)
+ Concat.new(@shell, *jobs)
+ end
+
+ # %pwd, %cwd -> @pwd
+ def notify(*opts)
+ Shell.notify(*opts) {|mes|
+ yield mes if iterator?
+
+ mes.gsub!("%pwd", "#{@cwd}")
+ mes.gsub!("%cwd", "#{@cwd}")
+ }
+ end
+
+ #
+ # private functions
+ #
+ def find_system_command(command)
+ return command if /^\// =~ command
+ case path = @system_commands[command]
+ when String
+ if exists?(path)
+ return path
+ else
+ Shell.Fail Error::CommandNotFound, command
+ end
+ when false
+ Shell.Fail Error::CommandNotFound, command
+ end
+
+ for p in @shell.system_path
+ path = join(p, command)
+ begin
+ st = File.stat(path)
+ rescue SystemCallError
+ next
+ else
+ next unless st.executable? and !st.directory?
+ @system_commands[command] = path
+ return path
+ end
+ end
+ @system_commands[command] = false
+ Shell.Fail Error::CommandNotFound, command
+ end
+
+ # call-seq:
+ # def_system_command(command, path) -> Shell::SystemCommand
+ #
+ # Defines a command, registering +path+ as a Shell method for the given
+ # +command+.
+ #
+ # Shell::CommandProcessor.def_system_command "ls"
+ # #=> Defines ls.
+ #
+ # Shell::CommandProcessor.def_system_command "sys_sort", "sort"
+ # #=> Defines sys_sort as sort
+ #
+ def self.def_system_command(command, path = command)
+ begin
+ eval((d = %Q[def #{command}(*opts)
+ SystemCommand.new(@shell, '#{path}', *opts)
+ end]), nil, __FILE__, __LINE__ - 1)
+ rescue SyntaxError
+ Shell.notify "warn: Can't define #{command} path: #{path}."
+ end
+ Shell.notify "Define #{command} path: #{path}.", Shell.debug?
+ Shell.notify("Definition of #{command}: ", d,
+ Shell.debug.kind_of?(Integer) && Shell.debug > 1)
+ end
+
+ # call-seq:
+ # undef_system_command(command) -> self
+ #
+ # Undefines a command
+ def self.undef_system_command(command)
+ command = command.id2name if command.kind_of?(Symbol)
+ remove_method(command)
+ Shell.module_eval{remove_method(command)}
+ Filter.module_eval{remove_method(command)}
+ self
+ end
+
+ @alias_map = {}
+ # Returns a list of aliased commands
+ def self.alias_map
+ @alias_map
+ end
+ # call-seq:
+ # alias_command(alias, command, *options) -> self
+ #
+ # Creates a command alias at the given +alias+ for the given +command+,
+ # passing any +options+ along with it.
+ #
+ # Shell::CommandProcessor.alias_command "lsC", "ls", "-CBF", "--show-control-chars"
+ # Shell::CommandProcessor.alias_command("lsC", "ls"){|*opts| ["-CBF", "--show-control-chars", *opts]}
+ #
+ def self.alias_command(ali, command, *opts)
+ ali = ali.id2name if ali.kind_of?(Symbol)
+ command = command.id2name if command.kind_of?(Symbol)
+ begin
+ if iterator?
+ @alias_map[ali.intern] = proc
+
+ eval((d = %Q[def #{ali}(*opts)
+ @shell.__send__(:#{command},
+ *(CommandProcessor.alias_map[:#{ali}].call *opts))
+ end]), nil, __FILE__, __LINE__ - 1)
+
+ else
+ args = opts.collect{|opt| '"' + opt + '"'}.join(",")
+ eval((d = %Q[def #{ali}(*opts)
+ @shell.__send__(:#{command}, #{args}, *opts)
+ end]), nil, __FILE__, __LINE__ - 1)
+ end
+ rescue SyntaxError
+ Shell.notify "warn: Can't alias #{ali} command: #{command}."
+ Shell.notify("Definition of #{ali}: ", d)
+ raise
+ end
+ Shell.notify "Define #{ali} command: #{command}.", Shell.debug?
+ Shell.notify("Definition of #{ali}: ", d,
+ Shell.debug.kind_of?(Integer) && Shell.debug > 1)
+ self
+ end
+
+ # call-seq:
+ # unalias_command(alias) -> self
+ #
+ # Unaliases the given +alias+ command.
+ def self.unalias_command(ali)
+ ali = ali.id2name if ali.kind_of?(Symbol)
+ @alias_map.delete ali.intern
+ undef_system_command(ali)
+ end
+
+ # :nodoc:
+ #
+ # Delegates File and FileTest methods into Shell, including the following
+ # commands:
+ #
+ # * Shell#blockdev?(file)
+ # * Shell#chardev?(file)
+ # * Shell#directory?(file)
+ # * Shell#executable?(file)
+ # * Shell#executable_real?(file)
+ # * Shell#exist?(file)/Shell#exists?(file)
+ # * Shell#file?(file)
+ # * Shell#grpowned?(file)
+ # * Shell#owned?(file)
+ # * Shell#pipe?(file)
+ # * Shell#readable?(file)
+ # * Shell#readable_real?(file)
+ # * Shell#setgid?(file)
+ # * Shell#setuid?(file)
+ # * Shell#size(file)/Shell#size?(file)
+ # * Shell#socket?(file)
+ # * Shell#sticky?(file)
+ # * Shell#symlink?(file)
+ # * Shell#writable?(file)
+ # * Shell#writable_real?(file)
+ # * Shell#zero?(file)
+ # * Shell#syscopy(filename_from, filename_to)
+ # * Shell#copy(filename_from, filename_to)
+ # * Shell#move(filename_from, filename_to)
+ # * Shell#compare(filename_from, filename_to)
+ # * Shell#safe_unlink(*filenames)
+ # * Shell#makedirs(*filenames)
+ # * Shell#install(filename_from, filename_to, mode)
+ #
+ # And also, there are some aliases for convenience:
+ #
+ # * Shell#cmp <- Shell#compare
+ # * Shell#mv <- Shell#move
+ # * Shell#cp <- Shell#copy
+ # * Shell#rm_f <- Shell#safe_unlink
+ # * Shell#mkpath <- Shell#makedirs
+ #
+ def self.def_builtin_commands(delegation_class, command_specs)
+ for meth, args in command_specs
+ arg_str = args.collect{|arg| arg.downcase}.join(", ")
+ call_arg_str = args.collect{
+ |arg|
+ case arg
+ when /^(FILENAME.*)$/
+ format("expand_path(%s)", $1.downcase)
+ when /^(\*FILENAME.*)$/
+ # \*FILENAME* -> filenames.collect{|fn| expand_path(fn)}.join(", ")
+ $1.downcase + '.collect{|fn| expand_path(fn)}'
+ else
+ arg
+ end
+ }.join(", ")
+ d = %Q[def #{meth}(#{arg_str})
+ #{delegation_class}.#{meth}(#{call_arg_str})
+ end]
+ Shell.notify "Define #{meth}(#{arg_str})", Shell.debug?
+ Shell.notify("Definition of #{meth}: ", d,
+ Shell.debug.kind_of?(Integer) && Shell.debug > 1)
+ eval d
+ end
+ end
+
+ # call-seq:
+ # install_system_commands(prefix = "sys_")
+ #
+ # Defines all commands in the Shell.default_system_path as Shell method,
+ # all with given +prefix+ appended to their names.
+ #
+ # Any invalid character names are converted to +_+, and errors are passed
+ # to Shell.notify.
+ #
+ # Methods already defined are skipped.
+ def self.install_system_commands(pre = "sys_")
+ defined_meth = {}
+ for m in Shell.methods
+ defined_meth[m] = true
+ end
+ sh = Shell.new
+ for path in Shell.default_system_path
+ next unless sh.directory? path
+ sh.cd path
+ sh.foreach do
+ |cn|
+ if !defined_meth[pre + cn] && sh.file?(cn) && sh.executable?(cn)
+ command = (pre + cn).gsub(/\W/, "_").sub(/^([0-9])/, '_\1')
+ begin
+ def_system_command(command, sh.expand_path(cn))
+ rescue
+ Shell.notify "warn: Can't define #{command} path: #{cn}"
+ end
+ defined_meth[command] = command
+ end
+ end
+ end
+ end
+
+ def self.add_delegate_command_to_shell(id) # :nodoc:
+ id = id.intern if id.kind_of?(String)
+ name = id.id2name
+ if Shell.method_defined?(id)
+ Shell.notify "warn: override definition of Shell##{name}."
+ Shell.notify "warn: alias Shell##{name} to Shell##{name}_org.\n"
+ Shell.module_eval "alias #{name}_org #{name}"
+ end
+ Shell.notify "method added: Shell##{name}.", Shell.debug?
+ Shell.module_eval(%Q[def #{name}(*args, &block)
+ begin
+ @command_processor.__send__(:#{name}, *args, &block)
+ rescue Exception
+ $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #`
+ $@.delete_if{|s| /^\\(eval\\):/ =~ s}
+ raise
+ end
+ end], __FILE__, __LINE__)
+
+ if Shell::Filter.method_defined?(id)
+ Shell.notify "warn: override definition of Shell::Filter##{name}."
+ Shell.notify "warn: alias Shell##{name} to Shell::Filter##{name}_org."
+ Filter.module_eval "alias #{name}_org #{name}"
+ end
+ Shell.notify "method added: Shell::Filter##{name}.", Shell.debug?
+ Filter.module_eval(%Q[def #{name}(*args, &block)
+ begin
+ self | @shell.__send__(:#{name}, *args, &block)
+ rescue Exception
+ $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #`
+ $@.delete_if{|s| /^\\(eval\\):/ =~ s}
+ raise
+ end
+ end], __FILE__, __LINE__)
+ end
+
+ # Delegates File methods into Shell, including the following commands:
+ #
+ # * Shell#atime(file)
+ # * Shell#basename(file, *opt)
+ # * Shell#chmod(mode, *files)
+ # * Shell#chown(owner, group, *file)
+ # * Shell#ctime(file)
+ # * Shell#delete(*file)
+ # * Shell#dirname(file)
+ # * Shell#ftype(file)
+ # * Shell#join(*file)
+ # * Shell#link(file_from, file_to)
+ # * Shell#lstat(file)
+ # * Shell#mtime(file)
+ # * Shell#readlink(file)
+ # * Shell#rename(file_from, file_to)
+ # * Shell#split(file)
+ # * Shell#stat(file)
+ # * Shell#symlink(file_from, file_to)
+ # * Shell#truncate(file, length)
+ # * Shell#utime(atime, mtime, *file)
+ #
+ def self.install_builtin_commands
+ # method related File.
+ # (exclude open/foreach/unlink)
+ normal_delegation_file_methods = [
+ ["atime", ["FILENAME"]],
+ ["basename", ["fn", "*opts"]],
+ ["chmod", ["mode", "*FILENAMES"]],
+ ["chown", ["owner", "group", "*FILENAME"]],
+ ["ctime", ["FILENAMES"]],
+ ["delete", ["*FILENAMES"]],
+ ["dirname", ["FILENAME"]],
+ ["ftype", ["FILENAME"]],
+ ["join", ["*items"]],
+ ["link", ["FILENAME_O", "FILENAME_N"]],
+ ["lstat", ["FILENAME"]],
+ ["mtime", ["FILENAME"]],
+ ["readlink", ["FILENAME"]],
+ ["rename", ["FILENAME_FROM", "FILENAME_TO"]],
+ ["split", ["pathname"]],
+ ["stat", ["FILENAME"]],
+ ["symlink", ["FILENAME_O", "FILENAME_N"]],
+ ["truncate", ["FILENAME", "length"]],
+ ["utime", ["atime", "mtime", "*FILENAMES"]]]
+
+ def_builtin_commands(File, normal_delegation_file_methods)
+ alias_method :rm, :delete
+
+ # method related FileTest
+ def_builtin_commands(FileTest,
+ FileTest.singleton_methods(false).collect{|m| [m, ["FILENAME"]]})
+
+ end
+
+ end
+end
diff --git a/lib/shell/error.rb b/lib/shell/error.rb
new file mode 100644
index 0000000000..677c424baf
--- /dev/null
+++ b/lib/shell/error.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: false
+#
+# shell/error.rb -
+# $Release Version: 0.7 $
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+require "e2mmap"
+
+class Shell
+ module Error
+ extend Exception2MessageMapper
+ def_e2message TypeError, "wrong argument type %s (expected %s)"
+
+ def_exception :DirStackEmpty, "Directory stack empty."
+ def_exception :CantDefine, "Can't define method(%s, %s)."
+ def_exception :CantApplyMethod, "This method(%s) does not apply to this type(%s)."
+ def_exception :CommandNotFound, "Command not found(%s)."
+ end
+end
+
diff --git a/lib/shell/filter.rb b/lib/shell/filter.rb
new file mode 100644
index 0000000000..caa976ae3e
--- /dev/null
+++ b/lib/shell/filter.rb
@@ -0,0 +1,138 @@
+# frozen_string_literal: false
+#
+# shell/filter.rb -
+# $Release Version: 0.7 $
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+class Shell #:nodoc:
+ # Any result of command execution is a Filter.
+ #
+ # This class includes Enumerable, therefore a Filter object can use all
+ # Enumerable
+ # facilities.
+ #
+ class Filter
+ include Enumerable
+
+ def initialize(sh)
+ @shell = sh # parent shell
+ @input = nil # input filter
+ end
+
+ attr_reader :input
+
+ def input=(filter)
+ @input = filter
+ end
+
+ # call-seq:
+ # each(record_separator=nil) { block }
+ #
+ # Iterates a block for each line.
+ def each(rs = nil)
+ rs = @shell.record_separator unless rs
+ if @input
+ @input.each(rs){|l| yield l}
+ end
+ end
+
+ # call-seq:
+ # < source
+ #
+ # Inputs from +source+, which is either a string of a file name or an IO
+ # object.
+ def <(src)
+ case src
+ when String
+ cat = Cat.new(@shell, src)
+ cat | self
+ when IO
+ self.input = src
+ self
+ else
+ Shell.Fail Error::CantApplyMethod, "<", src.class
+ end
+ end
+
+ # call-seq:
+ # > source
+ #
+ # Outputs from +source+, which is either a string of a file name or an IO
+ # object.
+ def >(to)
+ case to
+ when String
+ dst = @shell.open(to, "w")
+ begin
+ each(){|l| dst << l}
+ ensure
+ dst.close
+ end
+ when IO
+ each(){|l| to << l}
+ else
+ Shell.Fail Error::CantApplyMethod, ">", to.class
+ end
+ self
+ end
+
+ # call-seq:
+ # >> source
+ #
+ # Appends the output to +source+, which is either a string of a file name
+ # or an IO object.
+ def >>(to)
+ begin
+ Shell.cd(@shell.pwd).append(to, self)
+ rescue CantApplyMethod
+ Shell.Fail Error::CantApplyMethod, ">>", to.class
+ end
+ end
+
+ # call-seq:
+ # | filter
+ #
+ # Processes a pipeline.
+ def |(filter)
+ filter.input = self
+ if active?
+ @shell.process_controller.start_job filter
+ end
+ filter
+ end
+
+ # call-seq:
+ # filter1 + filter2
+ #
+ # Outputs +filter1+, and then +filter2+ using Join.new
+ def +(filter)
+ Join.new(@shell, self, filter)
+ end
+
+ def to_a
+ ary = []
+ each(){|l| ary.push l}
+ ary
+ end
+
+ def to_s
+ str = ""
+ each(){|l| str.concat l}
+ str
+ end
+
+ def inspect
+ if @shell.debug.kind_of?(Integer) && @shell.debug > 2
+ super
+ else
+ to_s
+ end
+ end
+ end
+end
diff --git a/lib/shell/process-controller.rb b/lib/shell/process-controller.rb
new file mode 100644
index 0000000000..d54da68cb0
--- /dev/null
+++ b/lib/shell/process-controller.rb
@@ -0,0 +1,309 @@
+# frozen_string_literal: false
+#
+# shell/process-controller.rb -
+# $Release Version: 0.7 $
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+require "forwardable"
+require "sync"
+
+class Shell
+ class ProcessController
+
+ @ProcessControllers = {}
+ @ProcessControllersMonitor = Thread::Mutex.new
+ @ProcessControllersCV = Thread::ConditionVariable.new
+
+ @BlockOutputMonitor = Thread::Mutex.new
+ @BlockOutputCV = Thread::ConditionVariable.new
+
+ class << self
+ extend Forwardable
+
+ def_delegator("@ProcessControllersMonitor",
+ "synchronize", "process_controllers_exclusive")
+
+ def active_process_controllers
+ process_controllers_exclusive do
+ @ProcessControllers.dup
+ end
+ end
+
+ def activate(pc)
+ process_controllers_exclusive do
+ @ProcessControllers[pc] ||= 0
+ @ProcessControllers[pc] += 1
+ end
+ end
+
+ def inactivate(pc)
+ process_controllers_exclusive do
+ if @ProcessControllers[pc]
+ if (@ProcessControllers[pc] -= 1) == 0
+ @ProcessControllers.delete(pc)
+ @ProcessControllersCV.signal
+ end
+ end
+ end
+ end
+
+ def each_active_object
+ process_controllers_exclusive do
+ for ref in @ProcessControllers.keys
+ yield ref
+ end
+ end
+ end
+
+ def block_output_synchronize(&b)
+ @BlockOutputMonitor.synchronize(&b)
+ end
+
+ def wait_to_finish_all_process_controllers
+ process_controllers_exclusive do
+ while !@ProcessControllers.empty?
+ Shell::notify("Process finishing, but active shell exists",
+ "You can use Shell#transact or Shell#check_point for more safe execution.")
+ if Shell.debug?
+ for pc in @ProcessControllers.keys
+ Shell::notify(" Not finished jobs in "+pc.shell.to_s)
+ for com in pc.jobs
+ com.notify(" Jobs: %id")
+ end
+ end
+ end
+ @ProcessControllersCV.wait(@ProcessControllersMonitor)
+ end
+ end
+ end
+ end
+
+ # for shell-command complete finish at this process exit.
+ USING_AT_EXIT_WHEN_PROCESS_EXIT = true
+ at_exit do
+ wait_to_finish_all_process_controllers unless $@
+ end
+
+ def initialize(shell)
+ @shell = shell
+ @waiting_jobs = []
+ @active_jobs = []
+ @jobs_sync = Sync.new
+
+ @job_monitor = Thread::Mutex.new
+ @job_condition = Thread::ConditionVariable.new
+ end
+
+ attr_reader :shell
+
+ def jobs
+ jobs = []
+ @jobs_sync.synchronize(:SH) do
+ jobs.concat @waiting_jobs
+ jobs.concat @active_jobs
+ end
+ jobs
+ end
+
+ def active_jobs
+ @active_jobs
+ end
+
+ def waiting_jobs
+ @waiting_jobs
+ end
+
+ def jobs_exist?
+ @jobs_sync.synchronize(:SH) do
+ @active_jobs.empty? or @waiting_jobs.empty?
+ end
+ end
+
+ def active_jobs_exist?
+ @jobs_sync.synchronize(:SH) do
+ @active_jobs.empty?
+ end
+ end
+
+ def waiting_jobs_exist?
+ @jobs_sync.synchronize(:SH) do
+ @waiting_jobs.empty?
+ end
+ end
+
+ # schedule a command
+ def add_schedule(command)
+ @jobs_sync.synchronize(:EX) do
+ ProcessController.activate(self)
+ if @active_jobs.empty?
+ start_job command
+ else
+ @waiting_jobs.push(command)
+ end
+ end
+ end
+
+ # start a job
+ def start_job(command = nil)
+ @jobs_sync.synchronize(:EX) do
+ if command
+ return if command.active?
+ @waiting_jobs.delete command
+ else
+ command = @waiting_jobs.shift
+
+ return unless command
+ end
+ @active_jobs.push command
+ command.start
+
+ # start all jobs that input from the job
+ for job in @waiting_jobs.dup
+ start_job(job) if job.input == command
+ end
+ end
+ end
+
+ def waiting_job?(job)
+ @jobs_sync.synchronize(:SH) do
+ @waiting_jobs.include?(job)
+ end
+ end
+
+ def active_job?(job)
+ @jobs_sync.synchronize(:SH) do
+ @active_jobs.include?(job)
+ end
+ end
+
+ # terminate a job
+ def terminate_job(command)
+ @jobs_sync.synchronize(:EX) do
+ @active_jobs.delete command
+ ProcessController.inactivate(self)
+ if @active_jobs.empty?
+ command.notify("start_job in terminate_job(%id)", Shell::debug?)
+ start_job
+ end
+ end
+ end
+
+ # kill a job
+ def kill_job(sig, command)
+ @jobs_sync.synchronize(:EX) do
+ if @waiting_jobs.delete command
+ ProcessController.inactivate(self)
+ return
+ elsif @active_jobs.include?(command)
+ begin
+ r = command.kill(sig)
+ ProcessController.inactivate(self)
+ rescue
+ print "Shell: Warn: $!\n" if @shell.verbose?
+ return nil
+ end
+ @active_jobs.delete command
+ r
+ end
+ end
+ end
+
+ # wait for all jobs to terminate
+ def wait_all_jobs_execution
+ @job_monitor.synchronize do
+ begin
+ while !jobs.empty?
+ @job_condition.wait(@job_monitor)
+ for job in jobs
+ job.notify("waiting job(%id)", Shell::debug?)
+ end
+ end
+ ensure
+ redo unless jobs.empty?
+ end
+ end
+ end
+
+ # simple fork
+ def sfork(command)
+ pipe_me_in, pipe_peer_out = IO.pipe
+ pipe_peer_in, pipe_me_out = IO.pipe
+
+
+ pid = nil
+ pid_mutex = Thread::Mutex.new
+ pid_cv = Thread::ConditionVariable.new
+
+ Thread.start do
+ ProcessController.block_output_synchronize do
+ STDOUT.flush
+ ProcessController.each_active_object do |pc|
+ for jobs in pc.active_jobs
+ jobs.flush
+ end
+ end
+
+ pid = fork {
+ Thread.list.each do |th|
+ th.kill unless Thread.current == th
+ end
+
+ STDIN.reopen(pipe_peer_in)
+ STDOUT.reopen(pipe_peer_out)
+
+ ObjectSpace.each_object(IO) do |io|
+ if ![STDIN, STDOUT, STDERR].include?(io)
+ io.close
+ end
+ end
+
+ yield
+ }
+ end
+ pid_cv.signal
+
+ pipe_peer_in.close
+ pipe_peer_out.close
+ command.notify "job(%name:##{pid}) start", @shell.debug?
+
+ begin
+ _pid = nil
+ command.notify("job(%id) start to waiting finish.", @shell.debug?)
+ _pid = Process.waitpid(pid, nil)
+ rescue Errno::ECHILD
+ command.notify "warn: job(%id) was done already waitpid."
+ _pid = true
+ ensure
+ command.notify("Job(%id): Wait to finish when Process finished.", @shell.debug?)
+ # when the process ends, wait until the command terminates
+ if USING_AT_EXIT_WHEN_PROCESS_EXIT or _pid
+ else
+ command.notify("notice: Process finishing...",
+ "wait for Job[%id] to finish.",
+ "You can use Shell#transact or Shell#check_point for more safe execution.")
+ redo
+ end
+
+ @job_monitor.synchronize do
+ terminate_job(command)
+ @job_condition.signal
+ command.notify "job(%id) finish.", @shell.debug?
+ end
+ end
+ end
+
+ pid_mutex.synchronize do
+ while !pid
+ pid_cv.wait(pid_mutex)
+ end
+ end
+
+ return pid, pipe_me_in, pipe_me_out
+ end
+ end
+end
diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb
new file mode 100644
index 0000000000..af22ed90d7
--- /dev/null
+++ b/lib/shell/system-command.rb
@@ -0,0 +1,159 @@
+# frozen_string_literal: false
+#
+# shell/system-command.rb -
+# $Release Version: 0.7 $
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+require "shell/filter"
+
+class Shell
+ class SystemCommand < Filter
+ def initialize(sh, command, *opts)
+ if t = opts.find{|opt| !opt.kind_of?(String) && opt.class}
+ Shell.Fail TypeError, t.class, "String"
+ end
+ super(sh)
+ @command = command
+ @opts = opts
+
+ @input_queue = Thread::Queue.new
+ @pid = nil
+
+ sh.process_controller.add_schedule(self)
+ end
+
+ attr_reader :command
+ alias name command
+
+ def wait?
+ @shell.process_controller.waiting_job?(self)
+ end
+
+ def active?
+ @shell.process_controller.active_job?(self)
+ end
+
+ def input=(inp)
+ super
+ if active?
+ start_export
+ end
+ end
+
+ def start
+ notify([@command, *@opts].join(" "))
+
+ @pid, @pipe_in, @pipe_out = @shell.process_controller.sfork(self) {
+ Dir.chdir @shell.pwd
+ $0 = @command
+ exec(@command, *@opts)
+ }
+ if @input
+ start_export
+ end
+ start_import
+ end
+
+ def flush
+ @pipe_out.flush if @pipe_out and !@pipe_out.closed?
+ end
+
+ def terminate
+ begin
+ @pipe_in.close
+ rescue IOError
+ end
+ begin
+ @pipe_out.close
+ rescue IOError
+ end
+ end
+
+ def kill(sig)
+ if @pid
+ Process.kill(sig, @pid)
+ end
+ end
+
+ def start_import
+ notify "Job(%id) start imp-pipe.", @shell.debug?
+ _eop = true
+ Thread.start {
+ begin
+ while l = @pipe_in.gets
+ @input_queue.push l
+ end
+ _eop = false
+ rescue Errno::EPIPE
+ _eop = false
+ ensure
+ if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
+ notify("warn: Process finishing...",
+ "wait for Job[%id] to finish pipe importing.",
+ "You can use Shell#transact or Shell#check_point for more safe execution.")
+ redo
+ end
+ notify "job(%id}) close imp-pipe.", @shell.debug?
+ @input_queue.push :EOF
+ @pipe_in.close
+ end
+ }
+ end
+
+ def start_export
+ notify "job(%id) start exp-pipe.", @shell.debug?
+ _eop = true
+ Thread.start{
+ begin
+ @input.each do |l|
+ ProcessController::block_output_synchronize do
+ @pipe_out.print l
+ end
+ end
+ _eop = false
+ rescue Errno::EPIPE, Errno::EIO
+ _eop = false
+ ensure
+ if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
+ notify("shell: warn: Process finishing...",
+ "wait for Job(%id) to finish pipe exporting.",
+ "You can use Shell#transact or Shell#check_point for more safe execution.")
+ redo
+ end
+ notify "job(%id) close exp-pipe.", @shell.debug?
+ @pipe_out.close
+ end
+ }
+ end
+
+ alias super_each each
+ def each(rs = nil)
+ while (l = @input_queue.pop) != :EOF
+ yield l
+ end
+ end
+
+ # ex)
+ # if you wish to output:
+ # "shell: job(#{@command}:#{@pid}) close pipe-out."
+ # then
+ # mes: "job(%id) close pipe-out."
+ # yorn: Boolean(@shell.debug? or @shell.verbose?)
+ def notify(*opts)
+ @shell.notify(*opts) do |mes|
+ yield mes if iterator?
+
+ mes.gsub!("%id", "#{@command}:##{@pid}")
+ mes.gsub!("%name", "#{@command}")
+ mes.gsub!("%pid", "#{@pid}")
+ mes
+ end
+ end
+ end
+end
diff --git a/lib/shell/version.rb b/lib/shell/version.rb
new file mode 100644
index 0000000000..bb4e7dfb8e
--- /dev/null
+++ b/lib/shell/version.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: false
+#
+# version.rb - shell version definition file
+# $Release Version: 0.7$
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+# --
+#
+#
+#
+
+class Shell # :nodoc:
+ @RELEASE_VERSION = "0.7"
+ @LAST_UPDATE_DATE = "07/03/20"
+end
diff --git a/lib/shellwords.rb b/lib/shellwords.rb
index 1eaddce7ba..eb5fa2d226 100644
--- a/lib/shellwords.rb
+++ b/lib/shellwords.rb
@@ -147,7 +147,7 @@ module Shellwords
# Treat multibyte characters as is. It is the caller's responsibility
# to encode the string in the right encoding for the shell
# environment.
- str.gsub!(/[^A-Za-z0-9_\-.,:+\/@\n]/, "\\\\\\&")
+ str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1")
# A LF cannot be escaped with a backslash because a backslash + LF
# combo is regarded as a line continuation and simply ignored.
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 8e8a779a2e..368febc74d 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -58,9 +58,10 @@
# == Singleton and Marshal
#
# By default Singleton's #_dump(depth) returns the empty string. Marshalling by
-# default will strip state information, e.g. instance variables from the instance.
-# Classes using Singleton can provide custom _load(str) and _dump(depth) methods
-# to retain some of the previous state of the instance.
+# default will strip state information, e.g. instance variables and taint
+# state, from the instance. Classes using Singleton can provide custom
+# _load(str) and _dump(depth) methods to retain some of the previous state of
+# the instance.
#
# require 'singleton'
#
@@ -81,6 +82,7 @@
# a = Example.instance
# a.keep = "keep this"
# a.strip = "get rid of this"
+# a.taint
#
# stored_state = Marshal.dump(a)
#
@@ -118,15 +120,6 @@ module Singleton
instance
end
- def instance # :nodoc:
- return @singleton__instance__ if @singleton__instance__
- @singleton__mutex__.synchronize {
- return @singleton__instance__ if @singleton__instance__
- @singleton__instance__ = new()
- }
- @singleton__instance__
- end
-
private
def inherited(sub_klass)
@@ -141,6 +134,14 @@ module Singleton
@singleton__instance__ = nil
@singleton__mutex__ = Thread::Mutex.new
}
+ def klass.instance # :nodoc:
+ return @singleton__instance__ if @singleton__instance__
+ @singleton__mutex__.synchronize {
+ return @singleton__instance__ if @singleton__instance__
+ @singleton__instance__ = new()
+ }
+ @singleton__instance__
+ end
klass
end
@@ -168,8 +169,4 @@ module Singleton
##
# :singleton-method: _load
# By default calls instance(). Override to retain singleton state.
-
- ##
- # :singleton-method: instance
- # Returns the singleton instance.
end
diff --git a/lib/singleton/singleton.gemspec b/lib/singleton/singleton.gemspec
deleted file mode 100644
index c6a273a839..0000000000
--- a/lib/singleton/singleton.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/singleton/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "singleton"
- spec.version = Singleton::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{The Singleton module implements the Singleton pattern.}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/singleton"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/singleton/version.rb b/lib/singleton/version.rb
deleted file mode 100644
index 01ab1eb5fa..0000000000
--- a/lib/singleton/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Singleton
- VERSION = "0.1.0"
-end
diff --git a/lib/sync.rb b/lib/sync.rb
new file mode 100644
index 0000000000..40a48ac985
--- /dev/null
+++ b/lib/sync.rb
@@ -0,0 +1,329 @@
+# frozen_string_literal: false
+#
+# sync.rb - 2 phase lock with counter
+# $Release Version: 1.0$
+# $Revision$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+# Sync_m, Synchronizer_m
+# Usage:
+# obj.extend(Sync_m)
+# or
+# class Foo
+# include Sync_m
+# :
+# end
+#
+# Sync_m#sync_mode
+# Sync_m#sync_locked?, locked?
+# Sync_m#sync_shared?, shared?
+# Sync_m#sync_exclusive?, sync_exclusive?
+# Sync_m#sync_try_lock, try_lock
+# Sync_m#sync_lock, lock
+# Sync_m#sync_unlock, unlock
+#
+# Sync, Synchronizer:
+# Usage:
+# sync = Sync.new
+#
+# Sync#mode
+# Sync#locked?
+# Sync#shared?
+# Sync#exclusive?
+# Sync#try_lock(mode) -- mode = :EX, :SH, :UN
+# Sync#lock(mode) -- mode = :EX, :SH, :UN
+# Sync#unlock
+# Sync#synchronize(mode) {...}
+#
+#
+
+unless defined? Thread
+ raise "Thread not available for this ruby interpreter"
+end
+
+##
+# A module that provides a two-phase lock with a counter.
+
+module Sync_m
+ # lock mode
+ UN = :UN
+ SH = :SH
+ EX = :EX
+
+ # exceptions
+ class Err < StandardError
+ def Err.Fail(*opt)
+ fail self, sprintf(self::Message, *opt)
+ end
+
+ class UnknownLocker < Err
+ Message = "Thread(%s) not locked."
+ def UnknownLocker.Fail(th)
+ super(th.inspect)
+ end
+ end
+
+ class LockModeFailer < Err
+ Message = "Unknown lock mode(%s)"
+ def LockModeFailer.Fail(mode)
+ if mode.id2name
+ mode = mode.id2name
+ end
+ super(mode)
+ end
+ end
+ end
+
+ def Sync_m.define_aliases(cl)
+ cl.module_eval %q{
+ alias locked? sync_locked?
+ alias shared? sync_shared?
+ alias exclusive? sync_exclusive?
+ alias lock sync_lock
+ alias unlock sync_unlock
+ alias try_lock sync_try_lock
+ alias synchronize sync_synchronize
+ }
+ end
+
+ def Sync_m.append_features(cl)
+ super
+ # do nothing for Modules
+ # make aliases for Classes.
+ define_aliases(cl) unless cl.instance_of?(Module)
+ self
+ end
+
+ def Sync_m.extend_object(obj)
+ super
+ obj.sync_extend
+ end
+
+ def sync_extend
+ unless (defined? locked? and
+ defined? shared? and
+ defined? exclusive? and
+ defined? lock and
+ defined? unlock and
+ defined? try_lock and
+ defined? synchronize)
+ Sync_m.define_aliases(singleton_class)
+ end
+ sync_initialize
+ end
+
+ # accessing
+ def sync_locked?
+ sync_mode != UN
+ end
+
+ def sync_shared?
+ sync_mode == SH
+ end
+
+ def sync_exclusive?
+ sync_mode == EX
+ end
+
+ # locking methods.
+ def sync_try_lock(mode = EX)
+ return unlock if mode == UN
+ @sync_mutex.synchronize do
+ sync_try_lock_sub(mode)
+ end
+ end
+
+ def sync_lock(m = EX)
+ return unlock if m == UN
+ Thread.handle_interrupt(StandardError => :on_blocking) do
+ while true
+ @sync_mutex.synchronize do
+ begin
+ if sync_try_lock_sub(m)
+ return self
+ else
+ if sync_sh_locker[Thread.current]
+ sync_upgrade_waiting.push [Thread.current, sync_sh_locker[Thread.current]]
+ sync_sh_locker.delete(Thread.current)
+ else
+ unless sync_waiting.include?(Thread.current) || sync_upgrade_waiting.reverse_each.any?{|w| w.first == Thread.current }
+ sync_waiting.push Thread.current
+ end
+ end
+ @sync_mutex.sleep
+ end
+ ensure
+ sync_waiting.delete(Thread.current)
+ end
+ end
+ end
+ end
+ self
+ end
+
+ def sync_unlock(m = EX)
+ wakeup_threads = []
+ @sync_mutex.synchronize do
+ if sync_mode == UN
+ Err::UnknownLocker.Fail(Thread.current)
+ end
+
+ m = sync_mode if m == EX and sync_mode == SH
+
+ runnable = false
+ case m
+ when UN
+ Err::UnknownLocker.Fail(Thread.current)
+
+ when EX
+ if sync_ex_locker == Thread.current
+ if (self.sync_ex_count = sync_ex_count - 1) == 0
+ self.sync_ex_locker = nil
+ if sync_sh_locker.include?(Thread.current)
+ self.sync_mode = SH
+ else
+ self.sync_mode = UN
+ end
+ runnable = true
+ end
+ else
+ Err::UnknownLocker.Fail(Thread.current)
+ end
+
+ when SH
+ if (count = sync_sh_locker[Thread.current]).nil?
+ Err::UnknownLocker.Fail(Thread.current)
+ else
+ if (sync_sh_locker[Thread.current] = count - 1) == 0
+ sync_sh_locker.delete(Thread.current)
+ if sync_sh_locker.empty? and sync_ex_count == 0
+ self.sync_mode = UN
+ runnable = true
+ end
+ end
+ end
+ end
+
+ if runnable
+ if sync_upgrade_waiting.size > 0
+ th, count = sync_upgrade_waiting.shift
+ sync_sh_locker[th] = count
+ th.wakeup
+ wakeup_threads.push th
+ else
+ wait = sync_waiting
+ self.sync_waiting = []
+ for th in wait
+ th.wakeup
+ wakeup_threads.push th
+ end
+ end
+ end
+ end
+ for th in wakeup_threads
+ th.run
+ end
+ self
+ end
+
+ def sync_synchronize(mode = EX)
+ Thread.handle_interrupt(StandardError => :on_blocking) do
+ sync_lock(mode)
+ begin
+ yield
+ ensure
+ sync_unlock
+ end
+ end
+ end
+
+ attr_accessor :sync_mode
+
+ attr_accessor :sync_waiting
+ attr_accessor :sync_upgrade_waiting
+ attr_accessor :sync_sh_locker
+ attr_accessor :sync_ex_locker
+ attr_accessor :sync_ex_count
+
+ def sync_inspect
+ sync_iv = instance_variables.select{|iv| /^@sync_/ =~ iv.id2name}.collect{|iv| iv.id2name + '=' + instance_eval(iv.id2name).inspect}.join(",")
+ print "<#{self.class}.extend Sync_m: #{inspect}, <Sync_m: #{sync_iv}>"
+ end
+
+ private
+
+ def sync_initialize
+ @sync_mode = UN
+ @sync_waiting = []
+ @sync_upgrade_waiting = []
+ @sync_sh_locker = Hash.new
+ @sync_ex_locker = nil
+ @sync_ex_count = 0
+
+ @sync_mutex = Thread::Mutex.new
+ end
+
+ def initialize(*args)
+ super
+ sync_initialize
+ end
+
+ def sync_try_lock_sub(m)
+ case m
+ when SH
+ case sync_mode
+ when UN
+ self.sync_mode = m
+ sync_sh_locker[Thread.current] = 1
+ ret = true
+ when SH
+ count = 0 unless count = sync_sh_locker[Thread.current]
+ sync_sh_locker[Thread.current] = count + 1
+ ret = true
+ when EX
+ # in EX mode, lock will upgrade to EX lock
+ if sync_ex_locker == Thread.current
+ self.sync_ex_count = sync_ex_count + 1
+ ret = true
+ else
+ ret = false
+ end
+ end
+ when EX
+ if sync_mode == UN or
+ sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current)
+ self.sync_mode = m
+ self.sync_ex_locker = Thread.current
+ self.sync_ex_count = 1
+ ret = true
+ elsif sync_mode == EX && sync_ex_locker == Thread.current
+ self.sync_ex_count = sync_ex_count + 1
+ ret = true
+ else
+ ret = false
+ end
+ else
+ Err::LockModeFailer.Fail m
+ end
+ return ret
+ end
+end
+
+##
+# An alias for Sync_m from sync.rb
+
+Synchronizer_m = Sync_m
+
+##
+# A class that provides two-phase lock with a counter. See Sync_m for
+# details.
+
+class Sync
+ include Sync_m
+end
+
+##
+# An alias for Sync from sync.rb. See Sync_m for details.
+
+Synchronizer = Sync
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index efb0b1bcd6..671ac7b83b 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -47,7 +47,7 @@ require 'tmpdir'
#
# file = Tempfile.new('foo')
# begin
-# # ...do something with file...
+# ...do something with file...
# ensure
# file.close
# file.unlink # deletes the temp file
@@ -79,6 +79,9 @@ require 'tmpdir'
# same Tempfile object from multiple threads then you should protect it with a
# mutex.
class Tempfile < DelegateClass(File)
+ # call-seq:
+ # new(basename = "", [tmpdir = Dir.tmpdir], [options])
+ #
# Creates a temporary file with permissions 0600 (= only readable and
# writable by the owner) and opens it with mode "w+".
#
@@ -98,6 +101,10 @@ class Tempfile < DelegateClass(File)
#
# The temporary file will be placed in the directory as specified
# by the +tmpdir+ parameter. By default, this is +Dir.tmpdir+.
+ # When $SAFE > 0 and the given +tmpdir+ is tainted, it uses
+ # '/tmp' as the temporary directory. Please note that ENV values
+ # are tainted by default, and +Dir.tmpdir+'s return value might
+ # come from environment variables (e.g. <tt>$TMPDIR</tt>).
#
# file = Tempfile.new('hello', '/home/aisaka')
# file.path # => something like: "/home/aisaka/hello2843-8392-92849382--0"
@@ -107,13 +114,10 @@ class Tempfile < DelegateClass(File)
# +File.open+. This is mostly useful for specifying encoding
# options, e.g.:
#
- # Tempfile.new('hello', '/home/aisaka', encoding: 'ascii-8bit')
+ # Tempfile.new('hello', '/home/aisaka', :encoding => 'ascii-8bit')
#
# # You can also omit the 'tmpdir' parameter:
- # Tempfile.new('hello', encoding: 'ascii-8bit')
- #
- # Note: +mode+ keyword argument, as accepted by Tempfile, can only be
- # numeric, combination of the modes defined in File::Constants.
+ # Tempfile.new('hello', :encoding => 'ascii-8bit')
#
# === Exceptions
#
@@ -124,9 +128,9 @@ class Tempfile < DelegateClass(File)
@unlinked = false
@mode = mode|File::RDWR|File::CREAT|File::EXCL
- ::Dir::Tmpname.create(basename, tmpdir, **options) do |tmpname, n, opts|
+ ::Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts|
opts[:perm] = 0600
- @tmpfile = File.open(tmpname, @mode, **opts)
+ @tmpfile = File.open(tmpname, @mode, opts)
@opts = opts.freeze
end
ObjectSpace.define_finalizer(self, Remover.new(@tmpfile))
@@ -138,7 +142,7 @@ class Tempfile < DelegateClass(File)
def open
_close
mode = @mode & ~(File::CREAT|File::EXCL)
- @tmpfile = File.open(@tmpfile.path, mode, **@opts)
+ @tmpfile = File.open(@tmpfile.path, mode, @opts)
__setobj__(@tmpfile)
end
@@ -170,7 +174,7 @@ class Tempfile < DelegateClass(File)
#
# file = Tempfile.new('foo')
# begin
- # # ...do something with file...
+ # ...do something with file...
# ensure
# file.close
# file.unlink # deletes the temp file
@@ -191,7 +195,7 @@ class Tempfile < DelegateClass(File)
# file = Tempfile.new('foo')
# file.unlink # On Windows this silently fails.
# begin
- # # ... do something with file ...
+ # ... do something with file ...
# ensure
# file.close! # Closes the file handle. If the file wasn't unlinked
# # because #unlink failed, then this method will attempt
@@ -230,14 +234,14 @@ class Tempfile < DelegateClass(File)
# :stopdoc:
def inspect
- if @tmpfile.closed?
+ if closed?
"#<#{self.class}:#{path} (closed)>"
else
"#<#{self.class}:#{path}>"
end
end
- class Remover # :nodoc:
+ class Remover
def initialize(tmpfile)
@pid = Process.pid
@tmpfile = tmpfile
@@ -273,18 +277,18 @@ class Tempfile < DelegateClass(File)
# In any case, all arguments (<code>*args</code>) will be passed to Tempfile.new.
#
# Tempfile.open('foo', '/home/temp') do |f|
- # # ... do something with f ...
+ # ... do something with f ...
# end
#
# # Equivalent:
# f = Tempfile.open('foo', '/home/temp')
# begin
- # # ... do something with f ...
+ # ... do something with f ...
# ensure
# f.close
# end
- def open(*args, **kw)
- tempfile = new(*args, **kw)
+ def open(*args)
+ tempfile = new(*args)
if block_given?
begin
@@ -317,15 +321,15 @@ end
# <code>**options</code>) will be treated as Tempfile.new.
#
# Tempfile.create('foo', '/home/temp') do |f|
-# # ... do something with f ...
+# ... do something with f ...
# end
#
def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
tmpfile = nil
- Dir::Tmpname.create(basename, tmpdir, **options) do |tmpname, n, opts|
+ Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts|
mode |= File::RDWR|File::CREAT|File::EXCL
opts[:perm] = 0600
- tmpfile = File.open(tmpname, mode, **opts)
+ tmpfile = File.open(tmpname, mode, opts)
end
if block_given?
begin
diff --git a/lib/thwait.rb b/lib/thwait.rb
new file mode 100644
index 0000000000..8f9e0c2a78
--- /dev/null
+++ b/lib/thwait.rb
@@ -0,0 +1,140 @@
+# frozen_string_literal: false
+#
+# thwait.rb - thread synchronization class
+# $Release Version: 0.9 $
+# $Revision: 1.3 $
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd.)
+
+require "e2mmap.rb"
+
+#
+# This class watches for termination of multiple threads. Basic functionality
+# (wait until specified threads have terminated) can be accessed through the
+# class method ThreadsWait::all_waits. Finer control can be gained using
+# instance methods.
+#
+# Example:
+#
+# ThreadsWait.all_waits(thr1, thr2, ...) do |t|
+# STDERR.puts "Thread #{t} has terminated."
+# end
+#
+#
+# th = ThreadsWait.new(thread1,...)
+# th.next_wait # next one to be done
+#
+#
+class ThreadsWait
+ extend Exception2MessageMapper
+ def_exception("ErrNoWaitingThread", "No threads for waiting.")
+ def_exception("ErrNoFinishedThread", "No finished threads.")
+
+ #
+ # Waits until all specified threads have terminated. If a block is provided,
+ # it is executed for each thread as they terminate.
+ #
+ def ThreadsWait.all_waits(*threads) # :yield: thread
+ tw = ThreadsWait.new(*threads)
+ if block_given?
+ tw.all_waits do |th|
+ yield th
+ end
+ else
+ tw.all_waits
+ end
+ end
+
+ #
+ # Creates a ThreadsWait object, specifying the threads to wait on.
+ # Non-blocking.
+ #
+ def initialize(*threads)
+ @threads = []
+ @wait_queue = Thread::Queue.new
+ join_nowait(*threads) unless threads.empty?
+ end
+
+ # Returns the array of threads that have not terminated yet.
+ attr_reader :threads
+
+ #
+ # Returns +true+ if there are no threads in the pool still running.
+ #
+ def empty?
+ @threads.empty?
+ end
+
+ #
+ # Returns +true+ if any thread has terminated and is ready to be collected.
+ #
+ def finished?
+ !@wait_queue.empty?
+ end
+
+ #
+ # Waits for specified threads to terminate, and returns when one of
+ # the threads terminated.
+ #
+ def join(*threads)
+ join_nowait(*threads)
+ next_wait
+ end
+
+ #
+ # Specifies the threads that this object will wait for, but does not actually
+ # wait.
+ #
+ def join_nowait(*threads)
+ threads.flatten!
+ @threads.concat threads
+ for th in threads
+ Thread.start(th) do |t|
+ begin
+ t.join
+ ensure
+ @wait_queue.push t
+ end
+ end
+ end
+ end
+
+ #
+ # Waits until any of the specified threads has terminated, and returns the one
+ # that does.
+ #
+ # If there is no thread to wait, raises +ErrNoWaitingThread+. If +nonblock+
+ # is true, and there is no terminated thread, raises +ErrNoFinishedThread+.
+ #
+ def next_wait(nonblock = nil)
+ ThreadsWait.fail ErrNoWaitingThread if @threads.empty?
+ begin
+ @threads.delete(th = @wait_queue.pop(nonblock))
+ th
+ rescue ThreadError
+ ThreadsWait.fail ErrNoFinishedThread
+ end
+ end
+
+ #
+ # Waits until all of the specified threads are terminated. If a block is
+ # supplied for the method, it is executed for each thread termination.
+ #
+ # Raises exceptions in the same manner as +next_wait+.
+ #
+ def all_waits
+ until @threads.empty?
+ th = next_wait
+ yield th if block_given?
+ end
+ end
+end
+
+##
+# An alias for ThreadsWait from thwait.rb
+
+ThWait = ThreadsWait
+
+# Documentation comments:
+# - Source of documentation is evenly split between Nutshell, existing
+# comments, and my own rephrasing.
+# - I'm not particularly confident that the comments are all exactly correct.
diff --git a/lib/time.rb b/lib/time.rb
index f27bacde65..eb46a03ad3 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -2,8 +2,6 @@
require 'date'
-# :stopdoc:
-
# = time.rb
#
# When 'time' is required, Time is extended with additional methods for parsing
@@ -20,8 +18,73 @@ require 'date'
# 8601}[http://www.iso.org/iso/date_and_time_format])
# * various formats handled by Date._parse
# * custom formats handled by Date._strptime
-
-# :startdoc:
+#
+# == Examples
+#
+# All examples assume you have loaded Time with:
+#
+# require 'time'
+#
+# All of these examples were done using the EST timezone which is GMT-5.
+#
+# === Converting to a String
+#
+# t = Time.now
+# t.iso8601 # => "2011-10-05T22:26:12-04:00"
+# t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400"
+# t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT"
+#
+# === Time.parse
+#
+# #parse takes a string representation of a Time and attempts to parse it
+# using a heuristic.
+#
+# Time.parse("2010-10-31") #=> 2010-10-31 00:00:00 -0500
+#
+# Any missing pieces of the date are inferred based on the current date.
+#
+# # assuming the current date is "2011-10-31"
+# Time.parse("12:00") #=> 2011-10-31 12:00:00 -0500
+#
+# We can change the date used to infer our missing elements by passing a second
+# object that responds to #mon, #day and #year, such as Date, Time or DateTime.
+# We can also use our own object.
+#
+# class MyDate
+# attr_reader :mon, :day, :year
+#
+# def initialize(mon, day, year)
+# @mon, @day, @year = mon, day, year
+# end
+# end
+#
+# d = Date.parse("2010-10-28")
+# t = Time.parse("2010-10-29")
+# dt = DateTime.parse("2010-10-30")
+# md = MyDate.new(10,31,2010)
+#
+# Time.parse("12:00", d) #=> 2010-10-28 12:00:00 -0500
+# Time.parse("12:00", t) #=> 2010-10-29 12:00:00 -0500
+# Time.parse("12:00", dt) #=> 2010-10-30 12:00:00 -0500
+# Time.parse("12:00", md) #=> 2010-10-31 12:00:00 -0500
+#
+# #parse also accepts an optional block. You can use this block to specify how
+# to handle the year component of the date. This is specifically designed for
+# handling two digit years. For example, if you wanted to treat all two digit
+# years prior to 70 as the year 2000+ you could write this:
+#
+# Time.parse("01-10-31") {|year| year + (year < 70 ? 2000 : 1900)}
+# #=> 2001-10-31 00:00:00 -0500
+# Time.parse("70-10-31") {|year| year + (year < 70 ? 2000 : 1900)}
+# #=> 1970-10-31 00:00:00 -0500
+#
+# === Time.strptime
+#
+# #strptime works similar to +parse+ except that instead of using a heuristic
+# to detect the format of the input string, you provide a second argument that
+# describes the format of the string. For example:
+#
+# Time.strptime("2000-10-31", "%Y-%m-%d") #=> 2000-10-31 00:00:00 -0500
class Time
class << Time
@@ -68,19 +131,12 @@ class Time
#
# If +zone_offset+ is unable to determine the offset, nil will be
# returned.
- #
- # require 'time'
- #
- # Time.zone_offset("EST") #=> -18000
- #
- # You must require 'time' to use this method.
- #
def zone_offset(zone, year=self.now.year)
off = nil
zone = zone.upcase
if /\A([+-])(\d\d)(:?)(\d\d)(?:\3(\d\d))?\z/ =~ zone
off = ($1 == '-' ? -1 : 1) * (($2.to_i * 60 + $4.to_i) * 60 + $5.to_i)
- elsif zone.match?(/\A[+-]\d\d\z/)
+ elsif /\A[+-]\d\d\z/ =~ zone
off = zone.to_i * 3600
elsif ZoneOffset.include?(zone)
off = ZoneOffset[zone] * 3600
@@ -112,7 +168,11 @@ class Time
# They are not appropriate for specific time zone such as
# Europe/London because time zone neutral,
# So -00:00 and -0000 are treated as UTC.
- zone.match?(/\A(?:-00:00|-0000|-00|UTC|Z|UT)\z/i)
+ if /\A(?:-00:00|-0000|-00|UTC|Z|UT)\z/i =~ zone
+ true
+ else
+ false
+ end
end
private :zone_utc?
@@ -189,8 +249,8 @@ class Time
end
private :apply_offset
- def make_time(date, year, yday, mon, day, hour, min, sec, sec_fraction, zone, now)
- if !year && !yday && !mon && !day && !hour && !min && !sec && !sec_fraction
+ def make_time(date, year, mon, day, hour, min, sec, sec_fraction, zone, now)
+ if !year && !mon && !day && !hour && !min && !sec && !sec_fraction
raise ArgumentError, "no time information in #{date.inspect}"
end
@@ -200,27 +260,7 @@ class Time
off = zone_offset(zone, off_year) if zone
end
- if yday
- unless (1..366) === yday
- raise ArgumentError, "yday #{yday} out of range"
- end
- mon, day = (yday-1).divmod(31)
- mon += 1
- day += 1
- t = make_time(date, year, nil, mon, day, hour, min, sec, sec_fraction, zone, now)
- diff = yday - t.yday
- return t if diff.zero?
- day += diff
- if day > 28 and day > (mday = month_days(off_year, mon))
- if (mon += 1) > 12
- raise ArgumentError, "yday #{yday} out of range"
- end
- day -= mday
- end
- return make_time(date, year, nil, mon, day, hour, min, sec, sec_fraction, zone, now)
- end
-
- if now and now.respond_to?(:getlocal)
+ if now
if off
now = now.getlocal(off) if now.utc_offset != off
else
@@ -269,62 +309,17 @@ class Time
private :make_time
#
- # Takes a string representation of a Time and attempts to parse it
- # using a heuristic.
- #
- # require 'time'
+ # Parses +date+ using Date._parse and converts it to a Time object.
#
- # Time.parse("2010-10-31") #=> 2010-10-31 00:00:00 -0500
- #
- # Any missing pieces of the date are inferred based on the current date.
- #
- # require 'time'
- #
- # # assuming the current date is "2011-10-31"
- # Time.parse("12:00") #=> 2011-10-31 12:00:00 -0500
- #
- # We can change the date used to infer our missing elements by passing a second
- # object that responds to #mon, #day and #year, such as Date, Time or DateTime.
- # We can also use our own object.
- #
- # require 'time'
- #
- # class MyDate
- # attr_reader :mon, :day, :year
- #
- # def initialize(mon, day, year)
- # @mon, @day, @year = mon, day, year
- # end
- # end
- #
- # d = Date.parse("2010-10-28")
- # t = Time.parse("2010-10-29")
- # dt = DateTime.parse("2010-10-30")
- # md = MyDate.new(10,31,2010)
- #
- # Time.parse("12:00", d) #=> 2010-10-28 12:00:00 -0500
- # Time.parse("12:00", t) #=> 2010-10-29 12:00:00 -0500
- # Time.parse("12:00", dt) #=> 2010-10-30 12:00:00 -0500
- # Time.parse("12:00", md) #=> 2010-10-31 12:00:00 -0500
- #
- # If a block is given, the year described in +date+ is converted
- # by the block. This is specifically designed for handling two
- # digit years. For example, if you wanted to treat all two digit
- # years prior to 70 as the year 2000+ you could write this:
- #
- # require 'time'
+ # If a block is given, the year described in +date+ is converted by the
+ # block. For example:
#
- # Time.parse("01-10-31") {|year| year + (year < 70 ? 2000 : 1900)}
- # #=> 2001-10-31 00:00:00 -0500
- # Time.parse("70-10-31") {|year| year + (year < 70 ? 2000 : 1900)}
- # #=> 1970-10-31 00:00:00 -0500
+ # Time.parse(...) {|y| 0 <= y && y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y}
#
# If the upper components of the given time are broken or missing, they are
# supplied with those of +now+. For the lower components, the minimum
# values (1 or 0) are assumed if broken or missing. For example:
#
- # require 'time'
- #
# # Suppose it is "Thu Nov 29 14:33:20 2001" now and
# # your time zone is EST which is GMT-5.
# now = Time.parse("Thu Nov 29 14:33:20 2001")
@@ -372,13 +367,11 @@ class Time
d = Date._parse(date, comp)
year = d[:year]
year = yield(year) if year && !comp
- make_time(date, year, d[:yday], d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
+ make_time(date, year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
#
- # Works similar to +parse+ except that instead of using a
- # heuristic to detect the format of the input string, you provide
- # a second argument that describes the format of the string.
+ # Parses +date+ using Date._strptime and converts it to a Time object.
#
# If a block is given, the year described in +date+ is converted by the
# block. For example:
@@ -397,9 +390,6 @@ class Time
# %D :: Date (%m/%d/%y)
# %e :: Day of the month, blank-padded ( 1..31)
# %F :: Equivalent to %Y-%m-%d (the ISO 8601 date format)
- # %g :: The last two digits of the commercial year
- # %G :: The week-based year according to ISO-8601 (week 1 starts on Monday
- # and includes January 4)
# %h :: Equivalent to %b
# %H :: Hour of the day, 24-hour clock (00..23)
# %I :: Hour of the day, 12-hour clock (01..12)
@@ -410,7 +400,10 @@ class Time
# %m :: Month of the year (01..12)
# %M :: Minute of the hour (00..59)
# %n :: Newline (\n)
- # %N :: Fractional seconds digits
+ # %N :: Fractional seconds digits, default is 9 digits (nanosecond)
+ # %3N :: millisecond (3 digits)
+ # %6N :: microsecond (6 digits)
+ # %9N :: nanosecond (9 digits)
# %p :: Meridian indicator ("AM" or "PM")
# %P :: Meridian indicator ("am" or "pm")
# %r :: time, 12-hour (same as %I:%M:%S %p)
@@ -434,17 +427,10 @@ class Time
# %z :: Time zone as hour offset from UTC (e.g. +0900)
# %Z :: Time zone name
# %% :: Literal "%" character
- # %+ :: date(1) (%a %b %e %H:%M:%S %Z %Y)
- #
- # require 'time'
- #
- # Time.strptime("2000-10-31", "%Y-%m-%d") #=> 2000-10-31 00:00:00 -0500
- #
- # You must require 'time' to use this method.
- #
+
def strptime(date, format, now=self.now)
d = Date._strptime(date, format)
- raise ArgumentError, "invalid date or strptime format - `#{date}' `#{format}'" unless d
+ raise ArgumentError, "invalid strptime format - `#{format}'" unless d
if seconds = d[:seconds]
if sec_fraction = d[:sec_fraction]
usec = sec_fraction * 1000000
@@ -459,15 +445,7 @@ class Time
else
year = d[:year]
year = yield(year) if year && block_given?
- yday = d[:yday]
- if (d[:cwyear] && !year) || ((d[:cwday] || d[:cweek]) && !(d[:mon] && d[:mday]))
- # make_time doesn't deal with cwyear/cwday/cweek
- return Date.strptime(date, format).to_time
- end
- if (d[:wnum0] || d[:wnum1]) && !yday && !(d[:mon] && d[:mday])
- yday = Date.strptime(date, format).yday
- end
- t = make_time(date, year, yday, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
+ t = make_time(date, year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
t
end
@@ -487,11 +465,6 @@ class Time
#
# See #rfc2822 for more information on this format.
#
- # require 'time'
- #
- # Time.rfc2822("Wed, 05 Oct 2011 22:26:12 -0400")
- # #=> 2010-10-05 22:26:12 -0400
- #
# You must require 'time' to use this method.
#
def rfc2822(date)
@@ -545,22 +518,17 @@ class Time
#
# See #httpdate for more information on this format.
#
- # require 'time'
- #
- # Time.httpdate("Thu, 06 Oct 2011 02:26:12 GMT")
- # #=> 2011-10-06 02:26:12 UTC
- #
# You must require 'time' to use this method.
#
def httpdate(date)
- if date.match?(/\A\s*
+ if /\A\s*
(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\x20
(\d{2})\x20
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\x20
(\d{4})\x20
(\d{2}):(\d{2}):(\d{2})\x20
GMT
- \s*\z/ix)
+ \s*\z/ix =~ date
self.rfc2822(date).utc
elsif /\A\s*
(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday),\x20
@@ -599,11 +567,6 @@ class Time
#
# See #xmlschema for more information on this format.
#
- # require 'time'
- #
- # Time.xmlschema("2011-10-05T22:26:12-04:00")
- # #=> 2011-10-05 22:26:12-04:00
- #
# You must require 'time' to use this method.
#
def xmlschema(date)
@@ -651,11 +614,6 @@ class Time
#
# If +self+ is a UTC time, -0000 is used as zone.
#
- # require 'time'
- #
- # t = Time.now
- # t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400"
- #
# You must require 'time' to use this method.
#
def rfc2822
@@ -691,11 +649,6 @@ class Time
#
# Note that the result is always UTC (GMT).
#
- # require 'time'
- #
- # t = Time.now
- # t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT"
- #
# You must require 'time' to use this method.
#
def httpdate
@@ -720,11 +673,6 @@ class Time
# +fractional_digits+ specifies a number of digits to use for fractional
# seconds. Its default value is 0.
#
- # require 'time'
- #
- # t = Time.now
- # t.iso8601 # => "2011-10-05T22:26:12-04:00"
- #
# You must require 'time' to use this method.
#
def xmlschema(fraction_digits=0)
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 62a35169a4..a33bb4ce65 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -67,9 +67,7 @@ module Timeout
# +sec+ seconds, otherwise throws an exception, based on the value of +klass+.
#
# The exception thrown to terminate the given block cannot be rescued inside
- # the block unless +klass+ is given explicitly. However, the block can use
- # ensure to prevent the handling of the exception. For that reason, this
- # method cannot be relied on to enforce timeouts for untrusted blocks.
+ # the block unless +klass+ is given explicitly.
#
# Note that this is both a method of module Timeout, so you can <tt>include
# Timeout</tt> into your classes so they have a #timeout method, as well as
diff --git a/lib/timeout/timeout.gemspec b/lib/timeout/timeout.gemspec
deleted file mode 100644
index 7b650bdc31..0000000000
--- a/lib/timeout/timeout.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-begin
- require_relative "lib/timeout/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "timeout"
- spec.version = Timeout::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Auto-terminate potentially long-running operations in Ruby.}
- spec.description = %q{Auto-terminate potentially long-running operations in Ruby.}
- spec.homepage = "https://github.com/ruby/timeout"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/timeout/version.rb b/lib/timeout/version.rb
deleted file mode 100644
index 39fc6eec5f..0000000000
--- a/lib/timeout/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Timeout
- VERSION = "0.1.0"
-end
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 5e42e8e302..d14c446727 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -19,18 +19,22 @@ class Dir
# Returns the operating system's temporary file path.
def self.tmpdir
- tmp = nil
- [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', '.'].each do |dir|
- next if !dir
- dir = File.expand_path(dir)
- if stat = File.stat(dir) and stat.directory? and stat.writable? and
- (!stat.world_writable? or stat.sticky?)
- tmp = dir
- break
- end rescue nil
+ if $SAFE > 0
+ @@systmpdir.dup
+ else
+ tmp = nil
+ [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', '.'].each do |dir|
+ next if !dir
+ dir = File.expand_path(dir)
+ if stat = File.stat(dir) and stat.directory? and stat.writable? and
+ (!stat.world_writable? or stat.sticky?)
+ tmp = dir
+ break
+ end rescue nil
+ end
+ raise ArgumentError, "could not find a temporary directory" unless tmp
+ tmp
end
- raise ArgumentError, "could not find a temporary directory" unless tmp
- tmp
end
# Dir.mktmpdir creates a temporary directory.
@@ -78,15 +82,15 @@ class Dir
# FileUtils.remove_entry dir
# end
#
- def self.mktmpdir(prefix_suffix=nil, *rest, **options)
+ def self.mktmpdir(prefix_suffix=nil, *rest)
base = nil
- path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|path, _, _, d|
+ path = Tmpname.create(prefix_suffix || "d", *rest) {|_path, _, _, d|
base = d
- mkdir(path, 0700)
+ mkdir(_path, 0700)
}
if block_given?
begin
- yield path.dup
+ yield path
ensure
unless base
stat = File.stat(File.dirname(path))
@@ -108,19 +112,21 @@ class Dir
Dir.tmpdir
end
- UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
-
def create(basename, tmpdir=nil, max_try: nil, **opts)
- origdir = tmpdir
- tmpdir ||= tmpdir()
+ if $SAFE > 0 and tmpdir.tainted?
+ tmpdir = '/tmp'
+ else
+ origdir = tmpdir
+ tmpdir ||= tmpdir()
+ end
n = nil
prefix, suffix = basename
prefix = (String.try_convert(prefix) or
raise ArgumentError, "unexpected prefix: #{prefix.inspect}")
- prefix = prefix.delete(UNUSABLE_CHARS)
+ prefix = prefix.delete("#{File::SEPARATOR}#{File::ALT_SEPARATOR}")
suffix &&= (String.try_convert(suffix) or
raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
- suffix &&= suffix.delete(UNUSABLE_CHARS)
+ suffix &&= suffix.delete("#{File::SEPARATOR}#{File::ALT_SEPARATOR}")
begin
t = Time.now.strftime("%Y%m%d")
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"\
diff --git a/lib/tracer.rb b/lib/tracer.rb
index c1540b8d23..faafd803f4 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -60,7 +60,6 @@
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
class Tracer
-
class << self
# display additional debug information (defaults to false)
attr_accessor :verbose
@@ -142,13 +141,11 @@ class Tracer
stdout.print "Trace off\n" if Tracer.verbose?
end
- def add_filter(p = nil, &b) # :nodoc:
- p ||= b
+ def add_filter(p = proc) # :nodoc:
@filters.push p
end
- def set_get_line_procs(file, p = nil, &b) # :nodoc:
- p ||= b
+ def set_get_line_procs(file, p = proc) # :nodoc:
@get_line_procs[file] = p
end
@@ -241,7 +238,7 @@ class Tracer
end
##
- # Register an event handler <code>p</code> which is called every time a line
+ # Register an event handler <code>p</code> which is called everytime a line
# in +file_name+ is executed.
#
# Example:
@@ -250,8 +247,7 @@ class Tracer
# puts "line number executed is #{line}"
# })
- def Tracer.set_get_line_procs(file_name, p = nil, &b)
- p ||= b
+ def Tracer.set_get_line_procs(file_name, p = proc)
Single.set_get_line_procs(file_name, p)
end
@@ -264,8 +260,7 @@ class Tracer
# "Kernel" == klass.to_s
# end
- def Tracer.add_filter(p = nil, &b)
- p ||= b
+ def Tracer.add_filter(p = proc)
Single.add_filter(p)
end
end
diff --git a/lib/tracer/tracer.gemspec b/lib/tracer/tracer.gemspec
deleted file mode 100644
index 9eab333f79..0000000000
--- a/lib/tracer/tracer.gemspec
+++ /dev/null
@@ -1,23 +0,0 @@
-begin
- require_relative "lib/tracer/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "tracer"
- spec.version = Tracer::VERSION
- spec.authors = ["Keiju ISHITSUKA"]
- spec.email = ["keiju@ruby-lang.org"]
-
- spec.summary = %q{Outputs a source level execution trace of a Ruby program.}
- spec.description = %q{Outputs a source level execution trace of a Ruby program.}
- spec.homepage = "https://github.com/ruby/tracer"
- spec.license = "BSD-2-Clause"
-
- spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/tracer.rb", "lib/tracer/version.rb", "tracer.gemspec"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/tracer/version.rb b/lib/tracer/version.rb
deleted file mode 100644
index f1b6dcd094..0000000000
--- a/lib/tracer/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class Tracer
- VERSION = "0.1.0"
-end
diff --git a/lib/un.rb b/lib/un.rb
index 4a15a37394..c445dba4ec 100644
--- a/lib/un.rb
+++ b/lib/un.rb
@@ -47,7 +47,7 @@ def setup(options = "", *long_options)
end
long_options.each do |s|
opt_name, arg_name = s.split(/(?=[\s=])/, 2)
- opt_name.delete_prefix!('--')
+ opt_name.sub!(/\A--/, '')
s = "--#{opt_name.gsub(/([A-Z]+|[a-z])([A-Z])/, '\1-\2').downcase}#{arg_name}"
puts "#{opt_name}=>#{s}" if $DEBUG
opt_name = opt_name.intern
@@ -88,7 +88,7 @@ def cp
options[:preserve] = true if options.delete :p
dest = argv.pop
argv = argv[0] if argv.size == 1
- FileUtils.send cmd, argv, dest, **options
+ FileUtils.send cmd, argv, dest, options
end
end
@@ -109,7 +109,7 @@ def ln
options[:force] = true if options.delete :f
dest = argv.pop
argv = argv[0] if argv.size == 1
- FileUtils.send cmd, argv, dest, **options
+ FileUtils.send cmd, argv, dest, options
end
end
@@ -125,7 +125,7 @@ def mv
setup do |argv, options|
dest = argv.pop
argv = argv[0] if argv.size == 1
- FileUtils.mv argv, dest, **options
+ FileUtils.mv argv, dest, options
end
end
@@ -144,7 +144,7 @@ def rm
cmd = "rm"
cmd += "_r" if options.delete :r
options[:force] = true if options.delete :f
- FileUtils.send cmd, argv, **options
+ FileUtils.send cmd, argv, options
end
end
@@ -161,7 +161,7 @@ def mkdir
setup("p") do |argv, options|
cmd = "mkdir"
cmd += "_p" if options.delete :p
- FileUtils.send cmd, argv, **options
+ FileUtils.send cmd, argv, options
end
end
@@ -177,7 +177,7 @@ end
def rmdir
setup("p") do |argv, options|
options[:parents] = true if options.delete :p
- FileUtils.rmdir argv, **options
+ FileUtils.rmdir argv, options
end
end
@@ -202,7 +202,7 @@ def install
(group = options.delete :g) and options[:group] = group
dest = argv.pop
argv = argv[0] if argv.size == 1
- FileUtils.install argv, dest, **options
+ FileUtils.install argv, dest, options
end
end
@@ -218,7 +218,7 @@ def chmod
setup do |argv, options|
mode = argv.shift
mode = /\A\d/ =~ mode ? mode.oct : mode
- FileUtils.chmod mode, argv, **options
+ FileUtils.chmod mode, argv, options
end
end
@@ -232,7 +232,7 @@ end
def touch
setup do |argv, options|
- FileUtils.touch argv, **options
+ FileUtils.touch argv, options
end
end
@@ -313,8 +313,6 @@ end
# --do-not-reverse-lookup disable reverse lookup
# --request-timeout=SECOND request timeout in seconds
# --http-version=VERSION HTTP version
-# --server-name=NAME name of the server host
-# --server-software=NAME name and version of the server
# --ssl-certificate=CERT The SSL certificate file for the server
# --ssl-private-key=KEY The SSL private key file for the server certificate
# -v verbose
@@ -323,7 +321,6 @@ end
def httpd
setup("", "BindAddress=ADDR", "Port=PORT", "MaxClients=NUM", "TempDir=DIR",
"DoNotReverseLookup", "RequestTimeout=SECOND", "HTTPVersion=VERSION",
- "ServerName=NAME", "ServerSoftware=NAME",
"SSLCertificate=CERT", "SSLPrivateKey=KEY") do
|argv, options|
require 'webrick'
diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb
index b27cdadaaa..a2f7a29c88 100644
--- a/lib/unicode_normalize/normalize.rb
+++ b/lib/unicode_normalize/normalize.rb
@@ -18,7 +18,7 @@
# content are purely an implementation detail, and should not be exposed in
# any test or spec or otherwise.
-require_relative 'tables'
+require 'unicode_normalize/tables.rb'
module UnicodeNormalize # :nodoc:
@@ -70,7 +70,7 @@ module UnicodeNormalize # :nodoc:
if length>1 and 0 <= (lead =string[0].ord-LBASE) and lead < LCOUNT and
0 <= (vowel=string[1].ord-VBASE) and vowel < VCOUNT
lead_vowel = SBASE + (lead * VCOUNT + vowel) * TCOUNT
- if length>2 and 0 < (trail=string[2].ord-TBASE) and trail < TCOUNT
+ if length>2 and 0 <= (trail=string[2].ord-TBASE) and trail < TCOUNT
(lead_vowel + trail).chr(Encoding::UTF_8) + string[3..-1]
else
lead_vowel.chr(Encoding::UTF_8) + string[2..-1]
diff --git a/lib/unicode_normalize/tables.rb b/lib/unicode_normalize/tables.rb
index a36daa84e6..4984e3d329 100644
--- a/lib/unicode_normalize/tables.rb
+++ b/lib/unicode_normalize/tables.rb
@@ -5,9035 +5,1166 @@
module UnicodeNormalize # :nodoc:
accents = "" \
- "[\u0300-\u034E" \
- "\u0350-\u036F" \
- "\u0483-\u0487" \
- "\u0591-\u05BD" \
- "\u05BF" \
- "\u05C1\u05C2" \
- "\u05C4\u05C5" \
- "\u05C7" \
- "\u0610-\u061A" \
- "\u064B-\u065F" \
- "\u0670" \
- "\u06D6-\u06DC" \
- "\u06DF-\u06E4" \
- "\u06E7\u06E8" \
- "\u06EA-\u06ED" \
- "\u0711" \
- "\u0730-\u074A" \
- "\u07EB-\u07F3" \
- "\u07FD" \
- "\u0816-\u0819" \
- "\u081B-\u0823" \
- "\u0825-\u0827" \
- "\u0829-\u082D" \
- "\u0859-\u085B" \
- "\u08D3-\u08E1" \
- "\u08E3-\u08FF" \
- "\u093C" \
- "\u094D" \
- "\u0951-\u0954" \
- "\u09BC" \
- "\u09BE" \
- "\u09CD" \
- "\u09D7" \
- "\u09FE" \
- "\u0A3C" \
- "\u0A4D" \
- "\u0ABC" \
- "\u0ACD" \
- "\u0B3C" \
- "\u0B3E" \
- "\u0B4D" \
- "\u0B56\u0B57" \
- "\u0BBE" \
- "\u0BCD" \
- "\u0BD7" \
- "\u0C4D" \
- "\u0C55\u0C56" \
- "\u0CBC" \
- "\u0CC2" \
- "\u0CCD" \
- "\u0CD5\u0CD6" \
- "\u0D3B\u0D3C" \
- "\u0D3E" \
- "\u0D4D" \
- "\u0D57" \
- "\u0DCA" \
- "\u0DCF" \
- "\u0DDF" \
- "\u0E38-\u0E3A" \
- "\u0E48-\u0E4B" \
- "\u0EB8-\u0EBA" \
- "\u0EC8-\u0ECB" \
- "\u0F18\u0F19" \
- "\u0F35" \
- "\u0F37" \
- "\u0F39" \
- "\u0F71\u0F72" \
- "\u0F74" \
- "\u0F7A-\u0F7D" \
- "\u0F80" \
- "\u0F82-\u0F84" \
- "\u0F86\u0F87" \
- "\u0FC6" \
- "\u102E" \
- "\u1037" \
- "\u1039\u103A" \
- "\u108D" \
- "\u135D-\u135F" \
- "\u1714" \
- "\u1734" \
- "\u17D2" \
- "\u17DD" \
- "\u18A9" \
- "\u1939-\u193B" \
- "\u1A17\u1A18" \
- "\u1A60" \
- "\u1A75-\u1A7C" \
- "\u1A7F" \
- "\u1AB0-\u1ABD" \
- "\u1B34\u1B35" \
- "\u1B44" \
- "\u1B6B-\u1B73" \
- "\u1BAA\u1BAB" \
- "\u1BE6" \
- "\u1BF2\u1BF3" \
- "\u1C37" \
- "\u1CD0-\u1CD2" \
- "\u1CD4-\u1CE0" \
- "\u1CE2-\u1CE8" \
- "\u1CED" \
- "\u1CF4" \
- "\u1CF8\u1CF9" \
- "\u1DC0-\u1DF9" \
- "\u1DFB-\u1DFF" \
- "\u20D0-\u20DC" \
- "\u20E1" \
- "\u20E5-\u20F0" \
- "\u2CEF-\u2CF1" \
- "\u2D7F" \
- "\u2DE0-\u2DFF" \
- "\u302A-\u302F" \
- "\u3099\u309A" \
- "\uA66F" \
- "\uA674-\uA67D" \
- "\uA69E\uA69F" \
- "\uA6F0\uA6F1" \
- "\uA806" \
- "\uA8C4" \
- "\uA8E0-\uA8F1" \
- "\uA92B-\uA92D" \
- "\uA953" \
- "\uA9B3" \
- "\uA9C0" \
- "\uAAB0" \
- "\uAAB2-\uAAB4" \
- "\uAAB7\uAAB8" \
- "\uAABE\uAABF" \
- "\uAAC1" \
- "\uAAF6" \
- "\uABED" \
- "\uFB1E" \
- "\uFE20-\uFE2F" \
- "\u{101FD}" \
- "\u{102E0}" \
- "\u{10376}-\u{1037A}" \
- "\u{10A0D}" \
- "\u{10A0F}" \
- "\u{10A38}-\u{10A3A}" \
- "\u{10A3F}" \
- "\u{10AE5}\u{10AE6}" \
- "\u{10D24}-\u{10D27}" \
- "\u{10F46}-\u{10F50}" \
- "\u{11046}" \
- "\u{1107F}" \
- "\u{110B9}\u{110BA}" \
- "\u{11100}-\u{11102}" \
- "\u{11127}" \
- "\u{11133}\u{11134}" \
- "\u{11173}" \
- "\u{111C0}" \
- "\u{111CA}" \
- "\u{11235}\u{11236}" \
- "\u{112E9}\u{112EA}" \
- "\u{1133B}\u{1133C}" \
- "\u{1133E}" \
- "\u{1134D}" \
- "\u{11357}" \
- "\u{11366}-\u{1136C}" \
- "\u{11370}-\u{11374}" \
- "\u{11442}" \
- "\u{11446}" \
- "\u{1145E}" \
- "\u{114B0}" \
- "\u{114BA}" \
- "\u{114BD}" \
- "\u{114C2}\u{114C3}" \
- "\u{115AF}" \
- "\u{115BF}\u{115C0}" \
- "\u{1163F}" \
- "\u{116B6}\u{116B7}" \
- "\u{1172B}" \
- "\u{11839}\u{1183A}" \
- "\u{119E0}" \
- "\u{11A34}" \
- "\u{11A47}" \
- "\u{11A99}" \
- "\u{11C3F}" \
- "\u{11D42}" \
- "\u{11D44}\u{11D45}" \
- "\u{11D97}" \
- "\u{16AF0}-\u{16AF4}" \
- "\u{16B30}-\u{16B36}" \
- "\u{1BC9E}" \
- "\u{1D165}-\u{1D169}" \
- "\u{1D16D}-\u{1D172}" \
- "\u{1D17B}-\u{1D182}" \
- "\u{1D185}-\u{1D18B}" \
- "\u{1D1AA}-\u{1D1AD}" \
- "\u{1D242}-\u{1D244}" \
- "\u{1E000}-\u{1E006}" \
- "\u{1E008}-\u{1E018}" \
- "\u{1E01B}-\u{1E021}" \
- "\u{1E023}\u{1E024}" \
- "\u{1E026}-\u{1E02A}" \
- "\u{1E130}-\u{1E136}" \
- "\u{1E2EC}-\u{1E2EF}" \
- "\u{1E8D0}-\u{1E8D6}" \
- "\u{1E944}-\u{1E94A}" \
+ "[\u0300-\u034E\u0350-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7" \
+ "\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711" \
+ "\u0730-\u074A\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1" \
+ "\u08E3-\u08FF\u093C\u094D\u0951-\u0954\u09BC\u09BE\u09CD\u09D7" \
+ "\u0A3C\u0A4D\u0ABC\u0ACD\u0B3C\u0B3E\u0B4D\u0B56\u0B57" \
+ "\u0BBE\u0BCD\u0BD7\u0C4D\u0C55\u0C56\u0CBC\u0CC2\u0CCD" \
+ "\u0CD5\u0CD6\u0D3B\u0D3C\u0D3E\u0D4D\u0D57\u0DCA\u0DCF\u0DDF" \
+ "\u0E38-\u0E3A\u0E48-\u0E4B\u0EB8\u0EB9\u0EC8-\u0ECB\u0F18\u0F19\u0F35\u0F37\u0F39" \
+ "\u0F71\u0F72\u0F74\u0F7A-\u0F7D\u0F80\u0F82-\u0F84\u0F86\u0F87\u0FC6\u102E" \
+ "\u1037\u1039\u103A\u108D\u135D-\u135F\u1714\u1734\u17D2\u17DD" \
+ "\u18A9\u1939-\u193B\u1A17\u1A18\u1A60\u1A75-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B34\u1B35" \
+ "\u1B44\u1B6B-\u1B73\u1BAA\u1BAB\u1BE6\u1BF2\u1BF3\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0" \
+ "\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20DC\u20E1" \
+ "\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F\uA674-\uA67D" \
+ "\uA69E\uA69F\uA6F0\uA6F1\uA806\uA8C4\uA8E0-\uA8F1\uA92B-\uA92D\uA953\uA9B3" \
+ "\uA9C0\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAF6\uABED" \
+ "\uFB1E\uFE20-\uFE2F\u{101FD}\u{102E0}\u{10376}-\u{1037A}\u{10A0D}\u{10A0F}\u{10A38}-\u{10A3A}" \
+ "\u{10A3F}\u{10AE5}\u{10AE6}\u{11046}\u{1107F}\u{110B9}\u{110BA}\u{11100}-\u{11102}\u{11127}\u{11133}\u{11134}" \
+ "\u{11173}\u{111C0}\u{111CA}\u{11235}\u{11236}\u{112E9}\u{112EA}\u{1133C}\u{1133E}\u{1134D}" \
+ "\u{11357}\u{11366}-\u{1136C}\u{11370}-\u{11374}\u{11442}\u{11446}\u{114B0}\u{114BA}\u{114BD}" \
+ "\u{114C2}\u{114C3}\u{115AF}\u{115BF}\u{115C0}\u{1163F}\u{116B6}\u{116B7}\u{1172B}\u{11A34}\u{11A47}" \
+ "\u{11A99}\u{11C3F}\u{11D42}\u{11D44}\u{11D45}\u{16AF0}-\u{16AF4}\u{16B30}-\u{16B36}\u{1BC9E}\u{1D165}-\u{1D169}" \
+ "\u{1D16D}-\u{1D172}\u{1D17B}-\u{1D182}\u{1D185}-\u{1D18B}\u{1D1AA}-\u{1D1AD}\u{1D242}-\u{1D244}\u{1E000}-\u{1E006}\u{1E008}-\u{1E018}\u{1E01B}-\u{1E021}" \
+ "\u{1E023}\u{1E024}\u{1E026}-\u{1E02A}\u{1E8D0}-\u{1E8D6}\u{1E944}-\u{1E94A}" \
"]"
ACCENTS = accents
REGEXP_D_STRING = "#{'' # composition starters and composition exclusions
}" \
- "[\u00C0-\u00C5" \
- "\u00C7-\u00CF" \
- "\u00D1-\u00D6" \
- "\u00D9-\u00DD" \
- "\u00E0-\u00E5" \
- "\u00E7-\u00EF" \
- "\u00F1-\u00F6" \
- "\u00F9-\u00FD" \
- "\u00FF-\u010F" \
- "\u0112-\u0125" \
- "\u0128-\u0130" \
- "\u0134-\u0137" \
- "\u0139-\u013E" \
- "\u0143-\u0148" \
- "\u014C-\u0151" \
- "\u0154-\u0165" \
- "\u0168-\u017E" \
- "\u01A0\u01A1" \
- "\u01AF\u01B0" \
- "\u01CD-\u01DC" \
- "\u01DE-\u01E3" \
- "\u01E6-\u01F0" \
- "\u01F4\u01F5" \
- "\u01F8-\u021B" \
- "\u021E\u021F" \
- "\u0226-\u0233" \
- "\u0340\u0341" \
- "\u0343\u0344" \
- "\u0374" \
- "\u037E" \
- "\u0385-\u038A" \
- "\u038C" \
- "\u038E-\u0390" \
- "\u03AA-\u03B0" \
- "\u03CA-\u03CE" \
- "\u03D3\u03D4" \
- "\u0400\u0401" \
- "\u0403" \
- "\u0407" \
- "\u040C-\u040E" \
- "\u0419" \
- "\u0439" \
- "\u0450\u0451" \
- "\u0453" \
- "\u0457" \
- "\u045C-\u045E" \
- "\u0476\u0477" \
- "\u04C1\u04C2" \
- "\u04D0-\u04D3" \
- "\u04D6\u04D7" \
- "\u04DA-\u04DF" \
- "\u04E2-\u04E7" \
- "\u04EA-\u04F5" \
- "\u04F8\u04F9" \
- "\u0622-\u0626" \
- "\u06C0" \
- "\u06C2" \
- "\u06D3" \
- "\u0929" \
- "\u0931" \
- "\u0934" \
- "\u0958-\u095F" \
- "\u09CB\u09CC" \
- "\u09DC\u09DD" \
- "\u09DF" \
- "\u0A33" \
- "\u0A36" \
- "\u0A59-\u0A5B" \
- "\u0A5E" \
- "\u0B48" \
- "\u0B4B\u0B4C" \
- "\u0B5C\u0B5D" \
- "\u0B94" \
- "\u0BCA-\u0BCC" \
- "\u0C48" \
- "\u0CC0" \
- "\u0CC7\u0CC8" \
- "\u0CCA\u0CCB" \
- "\u0D4A-\u0D4C" \
- "\u0DDA" \
- "\u0DDC-\u0DDE" \
- "\u0F43" \
- "\u0F4D" \
- "\u0F52" \
- "\u0F57" \
- "\u0F5C" \
- "\u0F69" \
- "\u0F73" \
- "\u0F75\u0F76" \
- "\u0F78" \
- "\u0F81" \
- "\u0F93" \
- "\u0F9D" \
- "\u0FA2" \
- "\u0FA7" \
- "\u0FAC" \
- "\u0FB9" \
- "\u1026" \
- "\u1B06" \
- "\u1B08" \
- "\u1B0A" \
- "\u1B0C" \
- "\u1B0E" \
- "\u1B12" \
- "\u1B3B" \
- "\u1B3D" \
- "\u1B40\u1B41" \
- "\u1B43" \
- "\u1E00-\u1E99" \
- "\u1E9B" \
- "\u1EA0-\u1EF9" \
- "\u1F00-\u1F15" \
- "\u1F18-\u1F1D" \
- "\u1F20-\u1F45" \
- "\u1F48-\u1F4D" \
- "\u1F50-\u1F57" \
- "\u1F59" \
- "\u1F5B" \
- "\u1F5D" \
- "\u1F5F-\u1F7D" \
- "\u1F80-\u1FB4" \
- "\u1FB6-\u1FBC" \
- "\u1FBE" \
- "\u1FC1-\u1FC4" \
- "\u1FC6-\u1FD3" \
- "\u1FD6-\u1FDB" \
- "\u1FDD-\u1FEF" \
- "\u1FF2-\u1FF4" \
- "\u1FF6-\u1FFD" \
- "\u2000\u2001" \
- "\u2126" \
- "\u212A\u212B" \
- "\u219A\u219B" \
- "\u21AE" \
- "\u21CD-\u21CF" \
- "\u2204" \
- "\u2209" \
- "\u220C" \
- "\u2224" \
- "\u2226" \
- "\u2241" \
- "\u2244" \
- "\u2247" \
- "\u2249" \
- "\u2260" \
- "\u2262" \
- "\u226D-\u2271" \
- "\u2274\u2275" \
- "\u2278\u2279" \
- "\u2280\u2281" \
- "\u2284\u2285" \
- "\u2288\u2289" \
- "\u22AC-\u22AF" \
- "\u22E0-\u22E3" \
- "\u22EA-\u22ED" \
- "\u2329\u232A" \
- "\u2ADC" \
- "\u304C" \
- "\u304E" \
- "\u3050" \
- "\u3052" \
- "\u3054" \
- "\u3056" \
- "\u3058" \
- "\u305A" \
- "\u305C" \
- "\u305E" \
- "\u3060" \
- "\u3062" \
- "\u3065" \
- "\u3067" \
- "\u3069" \
- "\u3070\u3071" \
- "\u3073\u3074" \
- "\u3076\u3077" \
- "\u3079\u307A" \
- "\u307C\u307D" \
- "\u3094" \
- "\u309E" \
- "\u30AC" \
- "\u30AE" \
- "\u30B0" \
- "\u30B2" \
- "\u30B4" \
- "\u30B6" \
- "\u30B8" \
- "\u30BA" \
- "\u30BC" \
- "\u30BE" \
- "\u30C0" \
- "\u30C2" \
- "\u30C5" \
- "\u30C7" \
- "\u30C9" \
- "\u30D0\u30D1" \
- "\u30D3\u30D4" \
- "\u30D6\u30D7" \
- "\u30D9\u30DA" \
- "\u30DC\u30DD" \
- "\u30F4" \
- "\u30F7-\u30FA" \
- "\u30FE" \
- "\uF900-\uFA0D" \
- "\uFA10" \
- "\uFA12" \
- "\uFA15-\uFA1E" \
- "\uFA20" \
- "\uFA22" \
- "\uFA25\uFA26" \
- "\uFA2A-\uFA6D" \
- "\uFA70-\uFAD9" \
- "\uFB1D" \
- "\uFB1F" \
- "\uFB2A-\uFB36" \
- "\uFB38-\uFB3C" \
- "\uFB3E" \
- "\uFB40\uFB41" \
- "\uFB43\uFB44" \
- "\uFB46-\uFB4E" \
- "\u{1109A}" \
- "\u{1109C}" \
- "\u{110AB}" \
- "\u{1112E}\u{1112F}" \
- "\u{1134B}\u{1134C}" \
- "\u{114BB}\u{114BC}" \
- "\u{114BE}" \
- "\u{115BA}\u{115BB}" \
- "\u{1D15E}-\u{1D164}" \
- "\u{1D1BB}-\u{1D1C0}" \
- "\u{2F800}-\u{2FA1D}" \
+ "[\u00C0-\u00C5\u00C7-\u00CF\u00D1-\u00D6\u00D9-\u00DD\u00E0-\u00E5\u00E7-\u00EF\u00F1-\u00F6\u00F9-\u00FD" \
+ "\u00FF-\u010F\u0112-\u0125\u0128-\u0130\u0134-\u0137\u0139-\u013E\u0143-\u0148\u014C-\u0151\u0154-\u0165" \
+ "\u0168-\u017E\u01A0\u01A1\u01AF\u01B0\u01CD-\u01DC\u01DE-\u01E3\u01E6-\u01F0\u01F4\u01F5\u01F8-\u021B" \
+ "\u021E\u021F\u0226-\u0233\u0340\u0341\u0343\u0344\u0374\u037E\u0385-\u038A\u038C" \
+ "\u038E-\u0390\u03AA-\u03B0\u03CA-\u03CE\u03D3\u03D4\u0400\u0401\u0403\u0407\u040C-\u040E" \
+ "\u0419\u0439\u0450\u0451\u0453\u0457\u045C-\u045E\u0476\u0477\u04C1\u04C2" \
+ "\u04D0-\u04D3\u04D6\u04D7\u04DA-\u04DF\u04E2-\u04E7\u04EA-\u04F5\u04F8\u04F9\u0622-\u0626\u06C0" \
+ "\u06C2\u06D3\u0929\u0931\u0934\u0958-\u095F\u09CB\u09CC\u09DC\u09DD" \
+ "\u09DF\u0A33\u0A36\u0A59-\u0A5B\u0A5E\u0B48\u0B4B\u0B4C\u0B5C\u0B5D" \
+ "\u0B94\u0BCA-\u0BCC\u0C48\u0CC0\u0CC7\u0CC8\u0CCA\u0CCB\u0D4A-\u0D4C\u0DDA" \
+ "\u0DDC-\u0DDE\u0F43\u0F4D\u0F52\u0F57\u0F5C\u0F69\u0F73" \
+ "\u0F75\u0F76\u0F78\u0F81\u0F93\u0F9D\u0FA2\u0FA7\u0FAC" \
+ "\u0FB9\u1026\u1B06\u1B08\u1B0A\u1B0C\u1B0E\u1B12" \
+ "\u1B3B\u1B3D\u1B40\u1B41\u1B43\u1E00-\u1E99\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15" \
+ "\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D" \
+ "\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC1-\u1FC4\u1FC6-\u1FD3\u1FD6-\u1FDB\u1FDD-\u1FEF\u1FF2-\u1FF4" \
+ "\u1FF6-\u1FFD\u2000\u2001\u2126\u212A\u212B\u219A\u219B\u21AE\u21CD-\u21CF\u2204" \
+ "\u2209\u220C\u2224\u2226\u2241\u2244\u2247\u2249" \
+ "\u2260\u2262\u226D-\u2271\u2274\u2275\u2278\u2279\u2280\u2281\u2284\u2285\u2288\u2289" \
+ "\u22AC-\u22AF\u22E0-\u22E3\u22EA-\u22ED\u2329\u232A\u2ADC\u304C\u304E\u3050" \
+ "\u3052\u3054\u3056\u3058\u305A\u305C\u305E\u3060" \
+ "\u3062\u3065\u3067\u3069\u3070\u3071\u3073\u3074\u3076\u3077\u3079\u307A" \
+ "\u307C\u307D\u3094\u309E\u30AC\u30AE\u30B0\u30B2\u30B4" \
+ "\u30B6\u30B8\u30BA\u30BC\u30BE\u30C0\u30C2\u30C5" \
+ "\u30C7\u30C9\u30D0\u30D1\u30D3\u30D4\u30D6\u30D7\u30D9\u30DA\u30DC\u30DD\u30F4" \
+ "\u30F7-\u30FA\u30FE\uF900-\uFA0D\uFA10\uFA12\uFA15-\uFA1E\uFA20\uFA22" \
+ "\uFA25\uFA26\uFA2A-\uFA6D\uFA70-\uFAD9\uFB1D\uFB1F\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E" \
+ "\uFB40\uFB41\uFB43\uFB44\uFB46-\uFB4E\u{1109A}\u{1109C}\u{110AB}\u{1112E}\u{1112F}\u{1134B}\u{1134C}" \
+ "\u{114BB}\u{114BC}\u{114BE}\u{115BA}\u{115BB}\u{1D15E}-\u{1D164}\u{1D1BB}-\u{1D1C0}\u{2F800}-\u{2FA1D}" \
"]#{accents}*" \
"|#{'' # characters that can be the result of a composition, except composition starters
}" \
- "[<->" \
- "A-P" \
- "R-Z" \
- "a-p" \
- "r-z" \
- "\u00A8" \
- "\u00C6" \
- "\u00D8" \
- "\u00E6" \
- "\u00F8" \
- "\u017F" \
- "\u01B7" \
- "\u0292" \
- "\u0391" \
- "\u0395" \
- "\u0397" \
- "\u0399" \
- "\u039F" \
- "\u03A1" \
- "\u03A5" \
- "\u03A9" \
- "\u03B1" \
- "\u03B5" \
- "\u03B7" \
- "\u03B9" \
- "\u03BF" \
- "\u03C1" \
- "\u03C5" \
- "\u03C9" \
- "\u03D2" \
- "\u0406" \
- "\u0410" \
- "\u0413" \
- "\u0415-\u0418" \
- "\u041A" \
- "\u041E" \
- "\u0423" \
- "\u0427" \
- "\u042B" \
- "\u042D" \
- "\u0430" \
- "\u0433" \
- "\u0435-\u0438" \
- "\u043A" \
- "\u043E" \
- "\u0443" \
- "\u0447" \
- "\u044B" \
- "\u044D" \
- "\u0456" \
- "\u0474\u0475" \
- "\u04D8\u04D9" \
- "\u04E8\u04E9" \
- "\u0627" \
- "\u0648" \
- "\u064A" \
- "\u06C1" \
- "\u06D2" \
- "\u06D5" \
- "\u0928" \
- "\u0930" \
- "\u0933" \
- "\u09C7" \
- "\u0B47" \
- "\u0B92" \
- "\u0BC6\u0BC7" \
- "\u0C46" \
- "\u0CBF" \
- "\u0CC6" \
- "\u0D46\u0D47" \
- "\u0DD9" \
- "\u1025" \
- "\u1B05" \
- "\u1B07" \
- "\u1B09" \
- "\u1B0B" \
- "\u1B0D" \
- "\u1B11" \
- "\u1B3A" \
- "\u1B3C" \
- "\u1B3E\u1B3F" \
- "\u1B42" \
- "\u1FBF" \
- "\u1FFE" \
- "\u2190" \
- "\u2192" \
- "\u2194" \
- "\u21D0" \
- "\u21D2" \
- "\u21D4" \
- "\u2203" \
- "\u2208" \
- "\u220B" \
- "\u2223" \
- "\u2225" \
- "\u223C" \
- "\u2243" \
- "\u2245" \
- "\u2248" \
- "\u224D" \
- "\u2261" \
- "\u2264\u2265" \
- "\u2272\u2273" \
- "\u2276\u2277" \
- "\u227A-\u227D" \
- "\u2282\u2283" \
- "\u2286\u2287" \
- "\u2291\u2292" \
- "\u22A2" \
- "\u22A8\u22A9" \
- "\u22AB" \
- "\u22B2-\u22B5" \
- "\u3046" \
- "\u304B" \
- "\u304D" \
- "\u304F" \
- "\u3051" \
- "\u3053" \
- "\u3055" \
- "\u3057" \
- "\u3059" \
- "\u305B" \
- "\u305D" \
- "\u305F" \
- "\u3061" \
- "\u3064" \
- "\u3066" \
- "\u3068" \
- "\u306F" \
- "\u3072" \
- "\u3075" \
- "\u3078" \
- "\u307B" \
- "\u309D" \
- "\u30A6" \
- "\u30AB" \
- "\u30AD" \
- "\u30AF" \
- "\u30B1" \
- "\u30B3" \
- "\u30B5" \
- "\u30B7" \
- "\u30B9" \
- "\u30BB" \
- "\u30BD" \
- "\u30BF" \
- "\u30C1" \
- "\u30C4" \
- "\u30C6" \
- "\u30C8" \
- "\u30CF" \
- "\u30D2" \
- "\u30D5" \
- "\u30D8" \
- "\u30DB" \
- "\u30EF-\u30F2" \
- "\u30FD" \
- "\u{11099}" \
- "\u{1109B}" \
- "\u{110A5}" \
- "\u{11131}\u{11132}" \
- "\u{11347}" \
- "\u{114B9}" \
- "\u{115B8}\u{115B9}" \
+ "[<->A-PR-Za-pr-z\u00A8\u00C6\u00D8" \
+ "\u00E6\u00F8\u017F\u01B7\u0292\u0391\u0395\u0397" \
+ "\u0399\u039F\u03A1\u03A5\u03A9\u03B1\u03B5\u03B7" \
+ "\u03B9\u03BF\u03C1\u03C5\u03C9\u03D2\u0406\u0410" \
+ "\u0413\u0415-\u0418\u041A\u041E\u0423\u0427\u042B\u042D" \
+ "\u0430\u0433\u0435-\u0438\u043A\u043E\u0443\u0447\u044B" \
+ "\u044D\u0456\u0474\u0475\u04D8\u04D9\u04E8\u04E9\u0627\u0648\u064A" \
+ "\u06C1\u06D2\u06D5\u0928\u0930\u0933\u09C7\u0B47" \
+ "\u0B92\u0BC6\u0BC7\u0C46\u0CBF\u0CC6\u0D46\u0D47\u0DD9\u1025" \
+ "\u1B05\u1B07\u1B09\u1B0B\u1B0D\u1B11\u1B3A\u1B3C" \
+ "\u1B3E\u1B3F\u1B42\u1FBF\u1FFE\u2190\u2192\u2194\u21D0" \
+ "\u21D2\u21D4\u2203\u2208\u220B\u2223\u2225\u223C" \
+ "\u2243\u2245\u2248\u224D\u2261\u2264\u2265\u2272\u2273\u2276\u2277" \
+ "\u227A-\u227D\u2282\u2283\u2286\u2287\u2291\u2292\u22A2\u22A8\u22A9\u22AB\u22B2-\u22B5" \
+ "\u3046\u304B\u304D\u304F\u3051\u3053\u3055\u3057" \
+ "\u3059\u305B\u305D\u305F\u3061\u3064\u3066\u3068" \
+ "\u306F\u3072\u3075\u3078\u307B\u309D\u30A6\u30AB" \
+ "\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB" \
+ "\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CF\u30D2" \
+ "\u30D5\u30D8\u30DB\u30EF-\u30F2\u30FD\u{11099}\u{1109B}\u{110A5}" \
+ "\u{11131}\u{11132}\u{11347}\u{114B9}\u{115B8}\u{115B9}" \
"]?#{accents}+" \
"|#{'' # precomposed Hangul syllables
}" \
"[\u{AC00}-\u{D7A4}]"
REGEXP_C_STRING = "#{'' # composition exclusions
}" \
- "[\u0340\u0341" \
- "\u0343\u0344" \
- "\u0374" \
- "\u037E" \
- "\u0387" \
- "\u0958-\u095F" \
- "\u09DC\u09DD" \
- "\u09DF" \
- "\u0A33" \
- "\u0A36" \
- "\u0A59-\u0A5B" \
- "\u0A5E" \
- "\u0B5C\u0B5D" \
- "\u0F43" \
- "\u0F4D" \
- "\u0F52" \
- "\u0F57" \
- "\u0F5C" \
- "\u0F69" \
- "\u0F73" \
- "\u0F75\u0F76" \
- "\u0F78" \
- "\u0F81" \
- "\u0F93" \
- "\u0F9D" \
- "\u0FA2" \
- "\u0FA7" \
- "\u0FAC" \
- "\u0FB9" \
- "\u1F71" \
- "\u1F73" \
- "\u1F75" \
- "\u1F77" \
- "\u1F79" \
- "\u1F7B" \
- "\u1F7D" \
- "\u1FBB" \
- "\u1FBE" \
- "\u1FC9" \
- "\u1FCB" \
- "\u1FD3" \
- "\u1FDB" \
- "\u1FE3" \
- "\u1FEB" \
- "\u1FEE\u1FEF" \
- "\u1FF9" \
- "\u1FFB" \
- "\u1FFD" \
- "\u2000\u2001" \
- "\u2126" \
- "\u212A\u212B" \
- "\u2329\u232A" \
- "\u2ADC" \
- "\uF900-\uFA0D" \
- "\uFA10" \
- "\uFA12" \
- "\uFA15-\uFA1E" \
- "\uFA20" \
- "\uFA22" \
- "\uFA25\uFA26" \
- "\uFA2A-\uFA6D" \
- "\uFA70-\uFAD9" \
- "\uFB1D" \
- "\uFB1F" \
- "\uFB2A-\uFB36" \
- "\uFB38-\uFB3C" \
- "\uFB3E" \
- "\uFB40\uFB41" \
- "\uFB43\uFB44" \
- "\uFB46-\uFB4E" \
- "\u{1D15E}-\u{1D164}" \
- "\u{1D1BB}-\u{1D1C0}" \
+ "[\u0340\u0341\u0343\u0344\u0374\u037E\u0387\u0958-\u095F\u09DC\u09DD\u09DF" \
+ "\u0A33\u0A36\u0A59-\u0A5B\u0A5E\u0B5C\u0B5D\u0F43\u0F4D\u0F52" \
+ "\u0F57\u0F5C\u0F69\u0F73\u0F75\u0F76\u0F78\u0F81\u0F93" \
+ "\u0F9D\u0FA2\u0FA7\u0FAC\u0FB9\u1F71\u1F73\u1F75" \
+ "\u1F77\u1F79\u1F7B\u1F7D\u1FBB\u1FBE\u1FC9\u1FCB" \
+ "\u1FD3\u1FDB\u1FE3\u1FEB\u1FEE\u1FEF\u1FF9\u1FFB\u1FFD" \
+ "\u2000\u2001\u2126\u212A\u212B\u2329\u232A\u2ADC\uF900-\uFA0D\uFA10\uFA12" \
+ "\uFA15-\uFA1E\uFA20\uFA22\uFA25\uFA26\uFA2A-\uFA6D\uFA70-\uFAD9\uFB1D\uFB1F" \
+ "\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFB4E\u{1D15E}-\u{1D164}\u{1D1BB}-\u{1D1C0}" \
"\u{2F800}-\u{2FA1D}" \
"]#{accents}*" \
"|#{'' # composition starters and characters that can be the result of a composition
}" \
- "[<->" \
- "A-P" \
- "R-Z" \
- "a-p" \
- "r-z" \
- "\u00A8" \
- "\u00C0-\u00CF" \
- "\u00D1-\u00D6" \
- "\u00D8-\u00DD" \
- "\u00E0-\u00EF" \
- "\u00F1-\u00F6" \
- "\u00F8-\u00FD" \
- "\u00FF-\u010F" \
- "\u0112-\u0125" \
- "\u0128-\u0130" \
- "\u0134-\u0137" \
- "\u0139-\u013E" \
- "\u0143-\u0148" \
- "\u014C-\u0151" \
- "\u0154-\u0165" \
- "\u0168-\u017F" \
- "\u01A0\u01A1" \
- "\u01AF\u01B0" \
- "\u01B7" \
- "\u01CD-\u01DC" \
- "\u01DE-\u01E3" \
- "\u01E6-\u01F0" \
- "\u01F4\u01F5" \
- "\u01F8-\u021B" \
- "\u021E\u021F" \
- "\u0226-\u0233" \
- "\u0292" \
- "\u0385\u0386" \
- "\u0388-\u038A" \
- "\u038C" \
- "\u038E-\u0391" \
- "\u0395" \
- "\u0397" \
- "\u0399" \
- "\u039F" \
- "\u03A1" \
- "\u03A5" \
- "\u03A9-\u03B1" \
- "\u03B5" \
- "\u03B7" \
- "\u03B9" \
- "\u03BF" \
- "\u03C1" \
- "\u03C5" \
- "\u03C9-\u03CE" \
- "\u03D2-\u03D4" \
- "\u0400\u0401" \
- "\u0403" \
- "\u0406\u0407" \
- "\u040C-\u040E" \
- "\u0410" \
- "\u0413" \
- "\u0415-\u041A" \
- "\u041E" \
- "\u0423" \
- "\u0427" \
- "\u042B" \
- "\u042D" \
- "\u0430" \
- "\u0433" \
- "\u0435-\u043A" \
- "\u043E" \
- "\u0443" \
- "\u0447" \
- "\u044B" \
- "\u044D" \
- "\u0450\u0451" \
- "\u0453" \
- "\u0456\u0457" \
- "\u045C-\u045E" \
- "\u0474-\u0477" \
- "\u04C1\u04C2" \
- "\u04D0-\u04D3" \
- "\u04D6-\u04DF" \
- "\u04E2-\u04F5" \
- "\u04F8\u04F9" \
- "\u0622-\u0627" \
- "\u0648" \
- "\u064A" \
- "\u06C0-\u06C2" \
- "\u06D2\u06D3" \
- "\u06D5" \
- "\u0928\u0929" \
- "\u0930\u0931" \
- "\u0933\u0934" \
- "\u09C7" \
- "\u09CB\u09CC" \
- "\u0B47\u0B48" \
- "\u0B4B\u0B4C" \
- "\u0B92" \
- "\u0B94" \
- "\u0BC6\u0BC7" \
- "\u0BCA-\u0BCC" \
- "\u0C46" \
- "\u0C48" \
- "\u0CBF\u0CC0" \
- "\u0CC6-\u0CC8" \
- "\u0CCA\u0CCB" \
- "\u0D46\u0D47" \
- "\u0D4A-\u0D4C" \
- "\u0DD9\u0DDA" \
- "\u0DDC-\u0DDE" \
- "\u1025\u1026" \
- "\u1B05-\u1B0E" \
- "\u1B11\u1B12" \
- "\u1B3A-\u1B43" \
- "\u1E00-\u1E99" \
- "\u1E9B" \
- "\u1EA0-\u1EF9" \
- "\u1F00-\u1F15" \
- "\u1F18-\u1F1D" \
- "\u1F20-\u1F45" \
- "\u1F48-\u1F4D" \
- "\u1F50-\u1F57" \
- "\u1F59" \
- "\u1F5B" \
- "\u1F5D" \
- "\u1F5F-\u1F70" \
- "\u1F72" \
- "\u1F74" \
- "\u1F76" \
- "\u1F78" \
- "\u1F7A" \
- "\u1F7C" \
- "\u1F80-\u1FB4" \
- "\u1FB6-\u1FBA" \
- "\u1FBC" \
- "\u1FBF" \
- "\u1FC1-\u1FC4" \
- "\u1FC6-\u1FC8" \
- "\u1FCA" \
- "\u1FCC-\u1FD2" \
- "\u1FD6-\u1FDA" \
- "\u1FDD-\u1FE2" \
- "\u1FE4-\u1FEA" \
- "\u1FEC\u1FED" \
- "\u1FF2-\u1FF4" \
- "\u1FF6-\u1FF8" \
- "\u1FFA" \
- "\u1FFC" \
- "\u1FFE" \
- "\u2190" \
- "\u2192" \
- "\u2194" \
- "\u219A\u219B" \
- "\u21AE" \
- "\u21CD-\u21D0" \
- "\u21D2" \
- "\u21D4" \
- "\u2203\u2204" \
- "\u2208\u2209" \
- "\u220B\u220C" \
- "\u2223-\u2226" \
- "\u223C" \
- "\u2241" \
- "\u2243-\u2245" \
- "\u2247-\u2249" \
- "\u224D" \
- "\u2260-\u2262" \
- "\u2264\u2265" \
- "\u226D-\u227D" \
- "\u2280-\u2289" \
- "\u2291\u2292" \
- "\u22A2" \
- "\u22A8\u22A9" \
- "\u22AB-\u22AF" \
- "\u22B2-\u22B5" \
- "\u22E0-\u22E3" \
- "\u22EA-\u22ED" \
- "\u3046" \
- "\u304B-\u3062" \
- "\u3064-\u3069" \
- "\u306F-\u307D" \
- "\u3094" \
- "\u309D\u309E" \
- "\u30A6" \
- "\u30AB-\u30C2" \
- "\u30C4-\u30C9" \
- "\u30CF-\u30DD" \
- "\u30EF-\u30F2" \
- "\u30F4" \
- "\u30F7-\u30FA" \
- "\u30FD\u30FE" \
- "\u{11099}-\u{1109C}" \
- "\u{110A5}" \
- "\u{110AB}" \
- "\u{1112E}\u{1112F}" \
- "\u{11131}\u{11132}" \
- "\u{11347}" \
- "\u{1134B}\u{1134C}" \
- "\u{114B9}" \
- "\u{114BB}\u{114BC}" \
- "\u{114BE}" \
- "\u{115B8}-\u{115BB}" \
+ "[<->A-PR-Za-pr-z\u00A8\u00C0-\u00CF\u00D1-\u00D6" \
+ "\u00D8-\u00DD\u00E0-\u00EF\u00F1-\u00F6\u00F8-\u00FD\u00FF-\u010F\u0112-\u0125\u0128-\u0130\u0134-\u0137" \
+ "\u0139-\u013E\u0143-\u0148\u014C-\u0151\u0154-\u0165\u0168-\u017F\u01A0\u01A1\u01AF\u01B0\u01B7" \
+ "\u01CD-\u01DC\u01DE-\u01E3\u01E6-\u01F0\u01F4\u01F5\u01F8-\u021B\u021E\u021F\u0226-\u0233\u0292" \
+ "\u0385\u0386\u0388-\u038A\u038C\u038E-\u0391\u0395\u0397\u0399\u039F" \
+ "\u03A1\u03A5\u03A9-\u03B1\u03B5\u03B7\u03B9\u03BF\u03C1" \
+ "\u03C5\u03C9-\u03CE\u03D2-\u03D4\u0400\u0401\u0403\u0406\u0407\u040C-\u040E\u0410" \
+ "\u0413\u0415-\u041A\u041E\u0423\u0427\u042B\u042D\u0430" \
+ "\u0433\u0435-\u043A\u043E\u0443\u0447\u044B\u044D\u0450\u0451" \
+ "\u0453\u0456\u0457\u045C-\u045E\u0474-\u0477\u04C1\u04C2\u04D0-\u04D3\u04D6-\u04DF\u04E2-\u04F5" \
+ "\u04F8\u04F9\u0622-\u0627\u0648\u064A\u06C0-\u06C2\u06D2\u06D3\u06D5\u0928\u0929" \
+ "\u0930\u0931\u0933\u0934\u09C7\u09CB\u09CC\u0B47\u0B48\u0B4B\u0B4C\u0B92\u0B94" \
+ "\u0BC6\u0BC7\u0BCA-\u0BCC\u0C46\u0C48\u0CBF\u0CC0\u0CC6-\u0CC8\u0CCA\u0CCB\u0D46\u0D47" \
+ "\u0D4A-\u0D4C\u0DD9\u0DDA\u0DDC-\u0DDE\u1025\u1026\u1B05-\u1B0E\u1B11\u1B12\u1B3A-\u1B43\u1E00-\u1E99" \
+ "\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59" \
+ "\u1F5B\u1F5D\u1F5F-\u1F70\u1F72\u1F74\u1F76\u1F78\u1F7A" \
+ "\u1F7C\u1F80-\u1FB4\u1FB6-\u1FBA\u1FBC\u1FBF\u1FC1-\u1FC4\u1FC6-\u1FC8\u1FCA" \
+ "\u1FCC-\u1FD2\u1FD6-\u1FDA\u1FDD-\u1FE2\u1FE4-\u1FEA\u1FEC\u1FED\u1FF2-\u1FF4\u1FF6-\u1FF8\u1FFA" \
+ "\u1FFC\u1FFE\u2190\u2192\u2194\u219A\u219B\u21AE\u21CD-\u21D0" \
+ "\u21D2\u21D4\u2203\u2204\u2208\u2209\u220B\u220C\u2223-\u2226\u223C\u2241" \
+ "\u2243-\u2245\u2247-\u2249\u224D\u2260-\u2262\u2264\u2265\u226D-\u227D\u2280-\u2289\u2291\u2292" \
+ "\u22A2\u22A8\u22A9\u22AB-\u22AF\u22B2-\u22B5\u22E0-\u22E3\u22EA-\u22ED\u3046\u304B-\u3062" \
+ "\u3064-\u3069\u306F-\u307D\u3094\u309D\u309E\u30A6\u30AB-\u30C2\u30C4-\u30C9\u30CF-\u30DD" \
+ "\u30EF-\u30F2\u30F4\u30F7-\u30FA\u30FD\u30FE\u{11099}-\u{1109C}\u{110A5}\u{110AB}\u{1112E}\u{1112F}" \
+ "\u{11131}\u{11132}\u{11347}\u{1134B}\u{1134C}\u{114B9}\u{114BB}\u{114BC}\u{114BE}\u{115B8}-\u{115BB}" \
"]?#{accents}+" \
"|#{'' # Hangul syllables with separate trailer
}" \
- "[\uAC00" \
- "\uAC1C" \
- "\uAC38" \
- "\uAC54" \
- "\uAC70" \
- "\uAC8C" \
- "\uACA8" \
- "\uACC4" \
- "\uACE0" \
- "\uACFC" \
- "\uAD18" \
- "\uAD34" \
- "\uAD50" \
- "\uAD6C" \
- "\uAD88" \
- "\uADA4" \
- "\uADC0" \
- "\uADDC" \
- "\uADF8" \
- "\uAE14" \
- "\uAE30" \
- "\uAE4C" \
- "\uAE68" \
- "\uAE84" \
- "\uAEA0" \
- "\uAEBC" \
- "\uAED8" \
- "\uAEF4" \
- "\uAF10" \
- "\uAF2C" \
- "\uAF48" \
- "\uAF64" \
- "\uAF80" \
- "\uAF9C" \
- "\uAFB8" \
- "\uAFD4" \
- "\uAFF0" \
- "\uB00C" \
- "\uB028" \
- "\uB044" \
- "\uB060" \
- "\uB07C" \
- "\uB098" \
- "\uB0B4" \
- "\uB0D0" \
- "\uB0EC" \
- "\uB108" \
- "\uB124" \
- "\uB140" \
- "\uB15C" \
- "\uB178" \
- "\uB194" \
- "\uB1B0" \
- "\uB1CC" \
- "\uB1E8" \
- "\uB204" \
- "\uB220" \
- "\uB23C" \
- "\uB258" \
- "\uB274" \
- "\uB290" \
- "\uB2AC" \
- "\uB2C8" \
- "\uB2E4" \
- "\uB300" \
- "\uB31C" \
- "\uB338" \
- "\uB354" \
- "\uB370" \
- "\uB38C" \
- "\uB3A8" \
- "\uB3C4" \
- "\uB3E0" \
- "\uB3FC" \
- "\uB418" \
- "\uB434" \
- "\uB450" \
- "\uB46C" \
- "\uB488" \
- "\uB4A4" \
- "\uB4C0" \
- "\uB4DC" \
- "\uB4F8" \
- "\uB514" \
- "\uB530" \
- "\uB54C" \
- "\uB568" \
- "\uB584" \
- "\uB5A0" \
- "\uB5BC" \
- "\uB5D8" \
- "\uB5F4" \
- "\uB610" \
- "\uB62C" \
- "\uB648" \
- "\uB664" \
- "\uB680" \
- "\uB69C" \
- "\uB6B8" \
- "\uB6D4" \
- "\uB6F0" \
- "\uB70C" \
- "\uB728" \
- "\uB744" \
- "\uB760" \
- "\uB77C" \
- "\uB798" \
- "\uB7B4" \
- "\uB7D0" \
- "\uB7EC" \
- "\uB808" \
- "\uB824" \
- "\uB840" \
- "\uB85C" \
- "\uB878" \
- "\uB894" \
- "\uB8B0" \
- "\uB8CC" \
- "\uB8E8" \
- "\uB904" \
- "\uB920" \
- "\uB93C" \
- "\uB958" \
- "\uB974" \
- "\uB990" \
- "\uB9AC" \
- "\uB9C8" \
- "\uB9E4" \
- "\uBA00" \
- "\uBA1C" \
- "\uBA38" \
- "\uBA54" \
- "\uBA70" \
- "\uBA8C" \
- "\uBAA8" \
- "\uBAC4" \
- "\uBAE0" \
- "\uBAFC" \
- "\uBB18" \
- "\uBB34" \
- "\uBB50" \
- "\uBB6C" \
- "\uBB88" \
- "\uBBA4" \
- "\uBBC0" \
- "\uBBDC" \
- "\uBBF8" \
- "\uBC14" \
- "\uBC30" \
- "\uBC4C" \
- "\uBC68" \
- "\uBC84" \
- "\uBCA0" \
- "\uBCBC" \
- "\uBCD8" \
- "\uBCF4" \
- "\uBD10" \
- "\uBD2C" \
- "\uBD48" \
- "\uBD64" \
- "\uBD80" \
- "\uBD9C" \
- "\uBDB8" \
- "\uBDD4" \
- "\uBDF0" \
- "\uBE0C" \
- "\uBE28" \
- "\uBE44" \
- "\uBE60" \
- "\uBE7C" \
- "\uBE98" \
- "\uBEB4" \
- "\uBED0" \
- "\uBEEC" \
- "\uBF08" \
- "\uBF24" \
- "\uBF40" \
- "\uBF5C" \
- "\uBF78" \
- "\uBF94" \
- "\uBFB0" \
- "\uBFCC" \
- "\uBFE8" \
- "\uC004" \
- "\uC020" \
- "\uC03C" \
- "\uC058" \
- "\uC074" \
- "\uC090" \
- "\uC0AC" \
- "\uC0C8" \
- "\uC0E4" \
- "\uC100" \
- "\uC11C" \
- "\uC138" \
- "\uC154" \
- "\uC170" \
- "\uC18C" \
- "\uC1A8" \
- "\uC1C4" \
- "\uC1E0" \
- "\uC1FC" \
- "\uC218" \
- "\uC234" \
- "\uC250" \
- "\uC26C" \
- "\uC288" \
- "\uC2A4" \
- "\uC2C0" \
- "\uC2DC" \
- "\uC2F8" \
- "\uC314" \
- "\uC330" \
- "\uC34C" \
- "\uC368" \
- "\uC384" \
- "\uC3A0" \
- "\uC3BC" \
- "\uC3D8" \
- "\uC3F4" \
- "\uC410" \
- "\uC42C" \
- "\uC448" \
- "\uC464" \
- "\uC480" \
- "\uC49C" \
- "\uC4B8" \
- "\uC4D4" \
- "\uC4F0" \
- "\uC50C" \
- "\uC528" \
- "\uC544" \
- "\uC560" \
- "\uC57C" \
- "\uC598" \
- "\uC5B4" \
- "\uC5D0" \
- "\uC5EC" \
- "\uC608" \
- "\uC624" \
- "\uC640" \
- "\uC65C" \
- "\uC678" \
- "\uC694" \
- "\uC6B0" \
- "\uC6CC" \
- "\uC6E8" \
- "\uC704" \
- "\uC720" \
- "\uC73C" \
- "\uC758" \
- "\uC774" \
- "\uC790" \
- "\uC7AC" \
- "\uC7C8" \
- "\uC7E4" \
- "\uC800" \
- "\uC81C" \
- "\uC838" \
- "\uC854" \
- "\uC870" \
- "\uC88C" \
- "\uC8A8" \
- "\uC8C4" \
- "\uC8E0" \
- "\uC8FC" \
- "\uC918" \
- "\uC934" \
- "\uC950" \
- "\uC96C" \
- "\uC988" \
- "\uC9A4" \
- "\uC9C0" \
- "\uC9DC" \
- "\uC9F8" \
- "\uCA14" \
- "\uCA30" \
- "\uCA4C" \
- "\uCA68" \
- "\uCA84" \
- "\uCAA0" \
- "\uCABC" \
- "\uCAD8" \
- "\uCAF4" \
- "\uCB10" \
- "\uCB2C" \
- "\uCB48" \
- "\uCB64" \
- "\uCB80" \
- "\uCB9C" \
- "\uCBB8" \
- "\uCBD4" \
- "\uCBF0" \
- "\uCC0C" \
- "\uCC28" \
- "\uCC44" \
- "\uCC60" \
- "\uCC7C" \
- "\uCC98" \
- "\uCCB4" \
- "\uCCD0" \
- "\uCCEC" \
- "\uCD08" \
- "\uCD24" \
- "\uCD40" \
- "\uCD5C" \
- "\uCD78" \
- "\uCD94" \
- "\uCDB0" \
- "\uCDCC" \
- "\uCDE8" \
- "\uCE04" \
- "\uCE20" \
- "\uCE3C" \
- "\uCE58" \
- "\uCE74" \
- "\uCE90" \
- "\uCEAC" \
- "\uCEC8" \
- "\uCEE4" \
- "\uCF00" \
- "\uCF1C" \
- "\uCF38" \
- "\uCF54" \
- "\uCF70" \
- "\uCF8C" \
- "\uCFA8" \
- "\uCFC4" \
- "\uCFE0" \
- "\uCFFC" \
- "\uD018" \
- "\uD034" \
- "\uD050" \
- "\uD06C" \
- "\uD088" \
- "\uD0A4" \
- "\uD0C0" \
- "\uD0DC" \
- "\uD0F8" \
- "\uD114" \
- "\uD130" \
- "\uD14C" \
- "\uD168" \
- "\uD184" \
- "\uD1A0" \
- "\uD1BC" \
- "\uD1D8" \
- "\uD1F4" \
- "\uD210" \
- "\uD22C" \
- "\uD248" \
- "\uD264" \
- "\uD280" \
- "\uD29C" \
- "\uD2B8" \
- "\uD2D4" \
- "\uD2F0" \
- "\uD30C" \
- "\uD328" \
- "\uD344" \
- "\uD360" \
- "\uD37C" \
- "\uD398" \
- "\uD3B4" \
- "\uD3D0" \
- "\uD3EC" \
- "\uD408" \
- "\uD424" \
- "\uD440" \
- "\uD45C" \
- "\uD478" \
- "\uD494" \
- "\uD4B0" \
- "\uD4CC" \
- "\uD4E8" \
- "\uD504" \
- "\uD520" \
- "\uD53C" \
- "\uD558" \
- "\uD574" \
- "\uD590" \
- "\uD5AC" \
- "\uD5C8" \
- "\uD5E4" \
- "\uD600" \
- "\uD61C" \
- "\uD638" \
- "\uD654" \
- "\uD670" \
- "\uD68C" \
- "\uD6A8" \
- "\uD6C4" \
- "\uD6E0" \
- "\uD6FC" \
- "\uD718" \
- "\uD734" \
- "\uD750" \
- "\uD76C" \
- "\uD788" \
+ "[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4" \
+ "\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4" \
+ "\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84" \
+ "\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64" \
+ "\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044" \
+ "\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124" \
+ "\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204" \
+ "\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4" \
+ "\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4" \
+ "\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4" \
+ "\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584" \
+ "\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664" \
+ "\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744" \
+ "\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824" \
+ "\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904" \
+ "\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4" \
+ "\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4" \
+ "\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4" \
+ "\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84" \
+ "\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64" \
+ "\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44" \
+ "\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24" \
+ "\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004" \
+ "\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4" \
+ "\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4" \
+ "\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4" \
+ "\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384" \
+ "\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464" \
+ "\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544" \
+ "\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624" \
+ "\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704" \
+ "\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4" \
+ "\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4" \
+ "\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4" \
+ "\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84" \
+ "\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64" \
+ "\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44" \
+ "\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24" \
+ "\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04" \
+ "\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4" \
+ "\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4" \
+ "\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4" \
+ "\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184" \
+ "\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264" \
+ "\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344" \
+ "\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424" \
+ "\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504" \
+ "\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4" \
+ "\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4" \
+ "\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788" \
"][\u11A8-\u11C2]" \
"|#{'' # decomposed Hangul syllables
}" \
"[\u1100-\u1112][\u1161-\u1175][\u11A8-\u11C2]?"
REGEXP_K_STRING = "" \
- "[\u00A0" \
- "\u00A8" \
- "\u00AA" \
- "\u00AF" \
- "\u00B2-\u00B5" \
- "\u00B8-\u00BA" \
- "\u00BC-\u00BE" \
- "\u0132\u0133" \
- "\u013F\u0140" \
- "\u0149" \
- "\u017F" \
- "\u01C4-\u01CC" \
- "\u01F1-\u01F3" \
- "\u02B0-\u02B8" \
- "\u02D8-\u02DD" \
- "\u02E0-\u02E4" \
- "\u037A" \
- "\u0384\u0385" \
- "\u03D0-\u03D6" \
- "\u03F0-\u03F2" \
- "\u03F4\u03F5" \
- "\u03F9" \
- "\u0587" \
- "\u0675-\u0678" \
- "\u0E33" \
- "\u0EB3" \
- "\u0EDC\u0EDD" \
- "\u0F0C" \
- "\u0F77" \
- "\u0F79" \
- "\u10FC" \
- "\u1D2C-\u1D2E" \
- "\u1D30-\u1D3A" \
- "\u1D3C-\u1D4D" \
- "\u1D4F-\u1D6A" \
- "\u1D78" \
- "\u1D9B-\u1DBF" \
- "\u1E9A\u1E9B" \
- "\u1FBD" \
- "\u1FBF-\u1FC1" \
- "\u1FCD-\u1FCF" \
- "\u1FDD-\u1FDF" \
- "\u1FED\u1FEE" \
- "\u1FFD\u1FFE" \
- "\u2000-\u200A" \
- "\u2011" \
- "\u2017" \
- "\u2024-\u2026" \
- "\u202F" \
- "\u2033\u2034" \
- "\u2036\u2037" \
- "\u203C" \
- "\u203E" \
- "\u2047-\u2049" \
- "\u2057" \
- "\u205F" \
- "\u2070\u2071" \
- "\u2074-\u208E" \
- "\u2090-\u209C" \
- "\u20A8" \
- "\u2100-\u2103" \
- "\u2105-\u2107" \
- "\u2109-\u2113" \
- "\u2115\u2116" \
- "\u2119-\u211D" \
- "\u2120-\u2122" \
- "\u2124" \
- "\u2128" \
- "\u212C\u212D" \
- "\u212F-\u2131" \
- "\u2133-\u2139" \
- "\u213B-\u2140" \
- "\u2145-\u2149" \
- "\u2150-\u217F" \
- "\u2189" \
- "\u222C\u222D" \
- "\u222F\u2230" \
- "\u2460-\u24EA" \
- "\u2A0C" \
- "\u2A74-\u2A76" \
- "\u2C7C\u2C7D" \
- "\u2D6F" \
- "\u2E9F" \
- "\u2EF3" \
- "\u2F00-\u2FD5" \
- "\u3000" \
- "\u3036" \
- "\u3038-\u303A" \
- "\u309B\u309C" \
- "\u309F" \
- "\u30FF" \
- "\u3131-\u318E" \
- "\u3192-\u319F" \
- "\u3200-\u321E" \
- "\u3220-\u3247" \
- "\u3250-\u327E" \
- "\u3280-\u33FF" \
- "\uA69C\uA69D" \
- "\uA770" \
- "\uA7F8\uA7F9" \
- "\uAB5C-\uAB5F" \
- "\uFB00-\uFB06" \
- "\uFB13-\uFB17" \
- "\uFB20-\uFB29" \
- "\uFB4F-\uFBB1" \
- "\uFBD3-\uFD3D" \
- "\uFD50-\uFD8F" \
- "\uFD92-\uFDC7" \
- "\uFDF0-\uFDFC" \
- "\uFE10-\uFE19" \
- "\uFE30-\uFE44" \
- "\uFE47-\uFE52" \
- "\uFE54-\uFE66" \
- "\uFE68-\uFE6B" \
- "\uFE70-\uFE72" \
- "\uFE74" \
- "\uFE76-\uFEFC" \
- "\uFF01-\uFFBE" \
- "\uFFC2-\uFFC7" \
- "\uFFCA-\uFFCF" \
- "\uFFD2-\uFFD7" \
- "\uFFDA-\uFFDC" \
- "\uFFE0-\uFFE6" \
- "\uFFE8-\uFFEE" \
- "\u{1D400}-\u{1D454}" \
- "\u{1D456}-\u{1D49C}" \
- "\u{1D49E}\u{1D49F}" \
- "\u{1D4A2}" \
- "\u{1D4A5}\u{1D4A6}" \
- "\u{1D4A9}-\u{1D4AC}" \
- "\u{1D4AE}-\u{1D4B9}" \
- "\u{1D4BB}" \
- "\u{1D4BD}-\u{1D4C3}" \
- "\u{1D4C5}-\u{1D505}" \
- "\u{1D507}-\u{1D50A}" \
- "\u{1D50D}-\u{1D514}" \
- "\u{1D516}-\u{1D51C}" \
- "\u{1D51E}-\u{1D539}" \
- "\u{1D53B}-\u{1D53E}" \
- "\u{1D540}-\u{1D544}" \
- "\u{1D546}" \
- "\u{1D54A}-\u{1D550}" \
- "\u{1D552}-\u{1D6A5}" \
- "\u{1D6A8}-\u{1D7CB}" \
- "\u{1D7CE}-\u{1D7FF}" \
- "\u{1EE00}-\u{1EE03}" \
- "\u{1EE05}-\u{1EE1F}" \
- "\u{1EE21}\u{1EE22}" \
- "\u{1EE24}" \
- "\u{1EE27}" \
- "\u{1EE29}-\u{1EE32}" \
- "\u{1EE34}-\u{1EE37}" \
- "\u{1EE39}" \
- "\u{1EE3B}" \
- "\u{1EE42}" \
- "\u{1EE47}" \
- "\u{1EE49}" \
- "\u{1EE4B}" \
- "\u{1EE4D}-\u{1EE4F}" \
- "\u{1EE51}\u{1EE52}" \
- "\u{1EE54}" \
- "\u{1EE57}" \
- "\u{1EE59}" \
- "\u{1EE5B}" \
- "\u{1EE5D}" \
- "\u{1EE5F}" \
- "\u{1EE61}\u{1EE62}" \
- "\u{1EE64}" \
- "\u{1EE67}-\u{1EE6A}" \
- "\u{1EE6C}-\u{1EE72}" \
- "\u{1EE74}-\u{1EE77}" \
- "\u{1EE79}-\u{1EE7C}" \
- "\u{1EE7E}" \
- "\u{1EE80}-\u{1EE89}" \
- "\u{1EE8B}-\u{1EE9B}" \
- "\u{1EEA1}-\u{1EEA3}" \
- "\u{1EEA5}-\u{1EEA9}" \
- "\u{1EEAB}-\u{1EEBB}" \
- "\u{1F100}-\u{1F10A}" \
- "\u{1F110}-\u{1F12E}" \
- "\u{1F130}-\u{1F14F}" \
- "\u{1F16A}-\u{1F16C}" \
- "\u{1F190}" \
- "\u{1F200}-\u{1F202}" \
- "\u{1F210}-\u{1F23B}" \
- "\u{1F240}-\u{1F248}" \
- "\u{1F250}\u{1F251}" \
+ "[\u00A0\u00A8\u00AA\u00AF\u00B2-\u00B5\u00B8-\u00BA\u00BC-\u00BE\u0132\u0133" \
+ "\u013F\u0140\u0149\u017F\u01C4-\u01CC\u01F1-\u01F3\u02B0-\u02B8\u02D8-\u02DD\u02E0-\u02E4" \
+ "\u037A\u0384\u0385\u03D0-\u03D6\u03F0-\u03F2\u03F4\u03F5\u03F9\u0587\u0675-\u0678" \
+ "\u0E33\u0EB3\u0EDC\u0EDD\u0F0C\u0F77\u0F79\u10FC\u1D2C-\u1D2E" \
+ "\u1D30-\u1D3A\u1D3C-\u1D4D\u1D4F-\u1D6A\u1D78\u1D9B-\u1DBF\u1E9A\u1E9B\u1FBD\u1FBF-\u1FC1" \
+ "\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED\u1FEE\u1FFD\u1FFE\u2000-\u200A\u2011\u2017\u2024-\u2026" \
+ "\u202F\u2033\u2034\u2036\u2037\u203C\u203E\u2047-\u2049\u2057\u205F" \
+ "\u2070\u2071\u2074-\u208E\u2090-\u209C\u20A8\u2100-\u2103\u2105-\u2107\u2109-\u2113\u2115\u2116" \
+ "\u2119-\u211D\u2120-\u2122\u2124\u2128\u212C\u212D\u212F-\u2131\u2133-\u2139\u213B-\u2140" \
+ "\u2145-\u2149\u2150-\u217F\u2189\u222C\u222D\u222F\u2230\u2460-\u24EA\u2A0C\u2A74-\u2A76" \
+ "\u2C7C\u2C7D\u2D6F\u2E9F\u2EF3\u2F00-\u2FD5\u3000\u3036\u3038-\u303A" \
+ "\u309B\u309C\u309F\u30FF\u3131-\u318E\u3192-\u319F\u3200-\u321E\u3220-\u3247\u3250-\u327E" \
+ "\u3280-\u32FE\u3300-\u33FF\uA69C\uA69D\uA770\uA7F8\uA7F9\uAB5C-\uAB5F\uFB00-\uFB06\uFB13-\uFB17" \
+ "\uFB20-\uFB29\uFB4F-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFC\uFE10-\uFE19\uFE30-\uFE44" \
+ "\uFE47-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFE70-\uFE72\uFE74\uFE76-\uFEFC\uFF01-\uFFBE\uFFC2-\uFFC7" \
+ "\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\uFFE0-\uFFE6\uFFE8-\uFFEE\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}" \
+ "\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}" \
+ "\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}" \
+ "\u{1D6A8}-\u{1D7CB}\u{1D7CE}-\u{1D7FF}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}" \
+ "\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}" \
+ "\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}" \
+ "\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}" \
+ "\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}\u{1F100}-\u{1F10A}\u{1F110}-\u{1F12E}\u{1F130}-\u{1F14F}\u{1F16A}\u{1F16B}\u{1F190}" \
+ "\u{1F200}-\u{1F202}\u{1F210}-\u{1F23B}\u{1F240}-\u{1F248}\u{1F250}\u{1F251}" \
"]"
class_table = {
- "\u0300"=>230,
- "\u0301"=>230,
- "\u0302"=>230,
- "\u0303"=>230,
- "\u0304"=>230,
- "\u0305"=>230,
- "\u0306"=>230,
- "\u0307"=>230,
- "\u0308"=>230,
- "\u0309"=>230,
- "\u030A"=>230,
- "\u030B"=>230,
- "\u030C"=>230,
- "\u030D"=>230,
- "\u030E"=>230,
- "\u030F"=>230,
- "\u0310"=>230,
- "\u0311"=>230,
- "\u0312"=>230,
- "\u0313"=>230,
- "\u0314"=>230,
- "\u0315"=>232,
- "\u0316"=>220,
- "\u0317"=>220,
- "\u0318"=>220,
- "\u0319"=>220,
- "\u031A"=>232,
- "\u031B"=>216,
- "\u031C"=>220,
- "\u031D"=>220,
- "\u031E"=>220,
- "\u031F"=>220,
- "\u0320"=>220,
- "\u0321"=>202,
- "\u0322"=>202,
- "\u0323"=>220,
- "\u0324"=>220,
- "\u0325"=>220,
- "\u0326"=>220,
- "\u0327"=>202,
- "\u0328"=>202,
- "\u0329"=>220,
- "\u032A"=>220,
- "\u032B"=>220,
- "\u032C"=>220,
- "\u032D"=>220,
- "\u032E"=>220,
- "\u032F"=>220,
- "\u0330"=>220,
- "\u0331"=>220,
- "\u0332"=>220,
- "\u0333"=>220,
- "\u0334"=>1,
- "\u0335"=>1,
- "\u0336"=>1,
- "\u0337"=>1,
- "\u0338"=>1,
- "\u0339"=>220,
- "\u033A"=>220,
- "\u033B"=>220,
- "\u033C"=>220,
- "\u033D"=>230,
- "\u033E"=>230,
- "\u033F"=>230,
- "\u0340"=>230,
- "\u0341"=>230,
- "\u0342"=>230,
- "\u0343"=>230,
- "\u0344"=>230,
- "\u0345"=>240,
- "\u0346"=>230,
- "\u0347"=>220,
- "\u0348"=>220,
- "\u0349"=>220,
- "\u034A"=>230,
- "\u034B"=>230,
- "\u034C"=>230,
- "\u034D"=>220,
- "\u034E"=>220,
- "\u0350"=>230,
- "\u0351"=>230,
- "\u0352"=>230,
- "\u0353"=>220,
- "\u0354"=>220,
- "\u0355"=>220,
- "\u0356"=>220,
- "\u0357"=>230,
- "\u0358"=>232,
- "\u0359"=>220,
- "\u035A"=>220,
- "\u035B"=>230,
- "\u035C"=>233,
- "\u035D"=>234,
- "\u035E"=>234,
- "\u035F"=>233,
- "\u0360"=>234,
- "\u0361"=>234,
- "\u0362"=>233,
- "\u0363"=>230,
- "\u0364"=>230,
- "\u0365"=>230,
- "\u0366"=>230,
- "\u0367"=>230,
- "\u0368"=>230,
- "\u0369"=>230,
- "\u036A"=>230,
- "\u036B"=>230,
- "\u036C"=>230,
- "\u036D"=>230,
- "\u036E"=>230,
- "\u036F"=>230,
- "\u0483"=>230,
- "\u0484"=>230,
- "\u0485"=>230,
- "\u0486"=>230,
- "\u0487"=>230,
- "\u0591"=>220,
- "\u0592"=>230,
- "\u0593"=>230,
- "\u0594"=>230,
- "\u0595"=>230,
- "\u0596"=>220,
- "\u0597"=>230,
- "\u0598"=>230,
- "\u0599"=>230,
- "\u059A"=>222,
- "\u059B"=>220,
- "\u059C"=>230,
- "\u059D"=>230,
- "\u059E"=>230,
- "\u059F"=>230,
- "\u05A0"=>230,
- "\u05A1"=>230,
- "\u05A2"=>220,
- "\u05A3"=>220,
- "\u05A4"=>220,
- "\u05A5"=>220,
- "\u05A6"=>220,
- "\u05A7"=>220,
- "\u05A8"=>230,
- "\u05A9"=>230,
- "\u05AA"=>220,
- "\u05AB"=>230,
- "\u05AC"=>230,
- "\u05AD"=>222,
- "\u05AE"=>228,
- "\u05AF"=>230,
- "\u05B0"=>10,
- "\u05B1"=>11,
- "\u05B2"=>12,
- "\u05B3"=>13,
- "\u05B4"=>14,
- "\u05B5"=>15,
- "\u05B6"=>16,
- "\u05B7"=>17,
- "\u05B8"=>18,
- "\u05B9"=>19,
- "\u05BA"=>19,
- "\u05BB"=>20,
- "\u05BC"=>21,
- "\u05BD"=>22,
- "\u05BF"=>23,
- "\u05C1"=>24,
- "\u05C2"=>25,
- "\u05C4"=>230,
- "\u05C5"=>220,
- "\u05C7"=>18,
- "\u0610"=>230,
- "\u0611"=>230,
- "\u0612"=>230,
- "\u0613"=>230,
- "\u0614"=>230,
- "\u0615"=>230,
- "\u0616"=>230,
- "\u0617"=>230,
- "\u0618"=>30,
- "\u0619"=>31,
- "\u061A"=>32,
- "\u064B"=>27,
- "\u064C"=>28,
- "\u064D"=>29,
- "\u064E"=>30,
- "\u064F"=>31,
- "\u0650"=>32,
- "\u0651"=>33,
- "\u0652"=>34,
- "\u0653"=>230,
- "\u0654"=>230,
- "\u0655"=>220,
- "\u0656"=>220,
- "\u0657"=>230,
- "\u0658"=>230,
- "\u0659"=>230,
- "\u065A"=>230,
- "\u065B"=>230,
- "\u065C"=>220,
- "\u065D"=>230,
- "\u065E"=>230,
- "\u065F"=>220,
- "\u0670"=>35,
- "\u06D6"=>230,
- "\u06D7"=>230,
- "\u06D8"=>230,
- "\u06D9"=>230,
- "\u06DA"=>230,
- "\u06DB"=>230,
- "\u06DC"=>230,
- "\u06DF"=>230,
- "\u06E0"=>230,
- "\u06E1"=>230,
- "\u06E2"=>230,
- "\u06E3"=>220,
- "\u06E4"=>230,
- "\u06E7"=>230,
- "\u06E8"=>230,
- "\u06EA"=>220,
- "\u06EB"=>230,
- "\u06EC"=>230,
- "\u06ED"=>220,
- "\u0711"=>36,
- "\u0730"=>230,
- "\u0731"=>220,
- "\u0732"=>230,
- "\u0733"=>230,
- "\u0734"=>220,
- "\u0735"=>230,
- "\u0736"=>230,
- "\u0737"=>220,
- "\u0738"=>220,
- "\u0739"=>220,
- "\u073A"=>230,
- "\u073B"=>220,
- "\u073C"=>220,
- "\u073D"=>230,
- "\u073E"=>220,
- "\u073F"=>230,
- "\u0740"=>230,
- "\u0741"=>230,
- "\u0742"=>220,
- "\u0743"=>230,
- "\u0744"=>220,
- "\u0745"=>230,
- "\u0746"=>220,
- "\u0747"=>230,
- "\u0748"=>220,
- "\u0749"=>230,
- "\u074A"=>230,
- "\u07EB"=>230,
- "\u07EC"=>230,
- "\u07ED"=>230,
- "\u07EE"=>230,
- "\u07EF"=>230,
- "\u07F0"=>230,
- "\u07F1"=>230,
- "\u07F2"=>220,
- "\u07F3"=>230,
- "\u07FD"=>220,
- "\u0816"=>230,
- "\u0817"=>230,
- "\u0818"=>230,
- "\u0819"=>230,
- "\u081B"=>230,
- "\u081C"=>230,
- "\u081D"=>230,
- "\u081E"=>230,
- "\u081F"=>230,
- "\u0820"=>230,
- "\u0821"=>230,
- "\u0822"=>230,
- "\u0823"=>230,
- "\u0825"=>230,
- "\u0826"=>230,
- "\u0827"=>230,
- "\u0829"=>230,
- "\u082A"=>230,
- "\u082B"=>230,
- "\u082C"=>230,
- "\u082D"=>230,
- "\u0859"=>220,
- "\u085A"=>220,
- "\u085B"=>220,
- "\u08D3"=>220,
- "\u08D4"=>230,
- "\u08D5"=>230,
- "\u08D6"=>230,
- "\u08D7"=>230,
- "\u08D8"=>230,
- "\u08D9"=>230,
- "\u08DA"=>230,
- "\u08DB"=>230,
- "\u08DC"=>230,
- "\u08DD"=>230,
- "\u08DE"=>230,
- "\u08DF"=>230,
- "\u08E0"=>230,
- "\u08E1"=>230,
- "\u08E3"=>220,
- "\u08E4"=>230,
- "\u08E5"=>230,
- "\u08E6"=>220,
- "\u08E7"=>230,
- "\u08E8"=>230,
- "\u08E9"=>220,
- "\u08EA"=>230,
- "\u08EB"=>230,
- "\u08EC"=>230,
- "\u08ED"=>220,
- "\u08EE"=>220,
- "\u08EF"=>220,
- "\u08F0"=>27,
- "\u08F1"=>28,
- "\u08F2"=>29,
- "\u08F3"=>230,
- "\u08F4"=>230,
- "\u08F5"=>230,
- "\u08F6"=>220,
- "\u08F7"=>230,
- "\u08F8"=>230,
- "\u08F9"=>220,
- "\u08FA"=>220,
- "\u08FB"=>230,
- "\u08FC"=>230,
- "\u08FD"=>230,
- "\u08FE"=>230,
- "\u08FF"=>230,
- "\u093C"=>7,
- "\u094D"=>9,
- "\u0951"=>230,
- "\u0952"=>220,
- "\u0953"=>230,
- "\u0954"=>230,
- "\u09BC"=>7,
- "\u09CD"=>9,
- "\u09FE"=>230,
- "\u0A3C"=>7,
- "\u0A4D"=>9,
- "\u0ABC"=>7,
- "\u0ACD"=>9,
- "\u0B3C"=>7,
- "\u0B4D"=>9,
- "\u0BCD"=>9,
- "\u0C4D"=>9,
- "\u0C55"=>84,
- "\u0C56"=>91,
- "\u0CBC"=>7,
- "\u0CCD"=>9,
- "\u0D3B"=>9,
- "\u0D3C"=>9,
- "\u0D4D"=>9,
- "\u0DCA"=>9,
- "\u0E38"=>103,
- "\u0E39"=>103,
- "\u0E3A"=>9,
- "\u0E48"=>107,
- "\u0E49"=>107,
- "\u0E4A"=>107,
- "\u0E4B"=>107,
- "\u0EB8"=>118,
- "\u0EB9"=>118,
- "\u0EBA"=>9,
- "\u0EC8"=>122,
- "\u0EC9"=>122,
- "\u0ECA"=>122,
- "\u0ECB"=>122,
- "\u0F18"=>220,
- "\u0F19"=>220,
- "\u0F35"=>220,
- "\u0F37"=>220,
- "\u0F39"=>216,
- "\u0F71"=>129,
- "\u0F72"=>130,
- "\u0F74"=>132,
- "\u0F7A"=>130,
- "\u0F7B"=>130,
- "\u0F7C"=>130,
- "\u0F7D"=>130,
- "\u0F80"=>130,
- "\u0F82"=>230,
- "\u0F83"=>230,
- "\u0F84"=>9,
- "\u0F86"=>230,
- "\u0F87"=>230,
- "\u0FC6"=>220,
- "\u1037"=>7,
- "\u1039"=>9,
- "\u103A"=>9,
- "\u108D"=>220,
- "\u135D"=>230,
- "\u135E"=>230,
- "\u135F"=>230,
- "\u1714"=>9,
- "\u1734"=>9,
- "\u17D2"=>9,
- "\u17DD"=>230,
- "\u18A9"=>228,
- "\u1939"=>222,
- "\u193A"=>230,
- "\u193B"=>220,
- "\u1A17"=>230,
- "\u1A18"=>220,
- "\u1A60"=>9,
- "\u1A75"=>230,
- "\u1A76"=>230,
- "\u1A77"=>230,
- "\u1A78"=>230,
- "\u1A79"=>230,
- "\u1A7A"=>230,
- "\u1A7B"=>230,
- "\u1A7C"=>230,
- "\u1A7F"=>220,
- "\u1AB0"=>230,
- "\u1AB1"=>230,
- "\u1AB2"=>230,
- "\u1AB3"=>230,
- "\u1AB4"=>230,
- "\u1AB5"=>220,
- "\u1AB6"=>220,
- "\u1AB7"=>220,
- "\u1AB8"=>220,
- "\u1AB9"=>220,
- "\u1ABA"=>220,
- "\u1ABB"=>230,
- "\u1ABC"=>230,
- "\u1ABD"=>220,
- "\u1B34"=>7,
- "\u1B44"=>9,
- "\u1B6B"=>230,
- "\u1B6C"=>220,
- "\u1B6D"=>230,
- "\u1B6E"=>230,
- "\u1B6F"=>230,
- "\u1B70"=>230,
- "\u1B71"=>230,
- "\u1B72"=>230,
- "\u1B73"=>230,
- "\u1BAA"=>9,
- "\u1BAB"=>9,
- "\u1BE6"=>7,
- "\u1BF2"=>9,
- "\u1BF3"=>9,
- "\u1C37"=>7,
- "\u1CD0"=>230,
- "\u1CD1"=>230,
- "\u1CD2"=>230,
- "\u1CD4"=>1,
- "\u1CD5"=>220,
- "\u1CD6"=>220,
- "\u1CD7"=>220,
- "\u1CD8"=>220,
- "\u1CD9"=>220,
- "\u1CDA"=>230,
- "\u1CDB"=>230,
- "\u1CDC"=>220,
- "\u1CDD"=>220,
- "\u1CDE"=>220,
- "\u1CDF"=>220,
- "\u1CE0"=>230,
- "\u1CE2"=>1,
- "\u1CE3"=>1,
- "\u1CE4"=>1,
- "\u1CE5"=>1,
- "\u1CE6"=>1,
- "\u1CE7"=>1,
- "\u1CE8"=>1,
- "\u1CED"=>220,
- "\u1CF4"=>230,
- "\u1CF8"=>230,
- "\u1CF9"=>230,
- "\u1DC0"=>230,
- "\u1DC1"=>230,
- "\u1DC2"=>220,
- "\u1DC3"=>230,
- "\u1DC4"=>230,
- "\u1DC5"=>230,
- "\u1DC6"=>230,
- "\u1DC7"=>230,
- "\u1DC8"=>230,
- "\u1DC9"=>230,
- "\u1DCA"=>220,
- "\u1DCB"=>230,
- "\u1DCC"=>230,
- "\u1DCD"=>234,
- "\u1DCE"=>214,
- "\u1DCF"=>220,
- "\u1DD0"=>202,
- "\u1DD1"=>230,
- "\u1DD2"=>230,
- "\u1DD3"=>230,
- "\u1DD4"=>230,
- "\u1DD5"=>230,
- "\u1DD6"=>230,
- "\u1DD7"=>230,
- "\u1DD8"=>230,
- "\u1DD9"=>230,
- "\u1DDA"=>230,
- "\u1DDB"=>230,
- "\u1DDC"=>230,
- "\u1DDD"=>230,
- "\u1DDE"=>230,
- "\u1DDF"=>230,
- "\u1DE0"=>230,
- "\u1DE1"=>230,
- "\u1DE2"=>230,
- "\u1DE3"=>230,
- "\u1DE4"=>230,
- "\u1DE5"=>230,
- "\u1DE6"=>230,
- "\u1DE7"=>230,
- "\u1DE8"=>230,
- "\u1DE9"=>230,
- "\u1DEA"=>230,
- "\u1DEB"=>230,
- "\u1DEC"=>230,
- "\u1DED"=>230,
- "\u1DEE"=>230,
- "\u1DEF"=>230,
- "\u1DF0"=>230,
- "\u1DF1"=>230,
- "\u1DF2"=>230,
- "\u1DF3"=>230,
- "\u1DF4"=>230,
- "\u1DF5"=>230,
- "\u1DF6"=>232,
- "\u1DF7"=>228,
- "\u1DF8"=>228,
- "\u1DF9"=>220,
- "\u1DFB"=>230,
- "\u1DFC"=>233,
- "\u1DFD"=>220,
- "\u1DFE"=>230,
- "\u1DFF"=>220,
- "\u20D0"=>230,
- "\u20D1"=>230,
- "\u20D2"=>1,
- "\u20D3"=>1,
- "\u20D4"=>230,
- "\u20D5"=>230,
- "\u20D6"=>230,
- "\u20D7"=>230,
- "\u20D8"=>1,
- "\u20D9"=>1,
- "\u20DA"=>1,
- "\u20DB"=>230,
- "\u20DC"=>230,
- "\u20E1"=>230,
- "\u20E5"=>1,
- "\u20E6"=>1,
- "\u20E7"=>230,
- "\u20E8"=>220,
- "\u20E9"=>230,
- "\u20EA"=>1,
- "\u20EB"=>1,
- "\u20EC"=>220,
- "\u20ED"=>220,
- "\u20EE"=>220,
- "\u20EF"=>220,
- "\u20F0"=>230,
- "\u2CEF"=>230,
- "\u2CF0"=>230,
- "\u2CF1"=>230,
- "\u2D7F"=>9,
- "\u2DE0"=>230,
- "\u2DE1"=>230,
- "\u2DE2"=>230,
- "\u2DE3"=>230,
- "\u2DE4"=>230,
- "\u2DE5"=>230,
- "\u2DE6"=>230,
- "\u2DE7"=>230,
- "\u2DE8"=>230,
- "\u2DE9"=>230,
- "\u2DEA"=>230,
- "\u2DEB"=>230,
- "\u2DEC"=>230,
- "\u2DED"=>230,
- "\u2DEE"=>230,
- "\u2DEF"=>230,
- "\u2DF0"=>230,
- "\u2DF1"=>230,
- "\u2DF2"=>230,
- "\u2DF3"=>230,
- "\u2DF4"=>230,
- "\u2DF5"=>230,
- "\u2DF6"=>230,
- "\u2DF7"=>230,
- "\u2DF8"=>230,
- "\u2DF9"=>230,
- "\u2DFA"=>230,
- "\u2DFB"=>230,
- "\u2DFC"=>230,
- "\u2DFD"=>230,
- "\u2DFE"=>230,
- "\u2DFF"=>230,
- "\u302A"=>218,
- "\u302B"=>228,
- "\u302C"=>232,
- "\u302D"=>222,
- "\u302E"=>224,
- "\u302F"=>224,
- "\u3099"=>8,
- "\u309A"=>8,
- "\uA66F"=>230,
- "\uA674"=>230,
- "\uA675"=>230,
- "\uA676"=>230,
- "\uA677"=>230,
- "\uA678"=>230,
- "\uA679"=>230,
- "\uA67A"=>230,
- "\uA67B"=>230,
- "\uA67C"=>230,
- "\uA67D"=>230,
- "\uA69E"=>230,
- "\uA69F"=>230,
- "\uA6F0"=>230,
- "\uA6F1"=>230,
- "\uA806"=>9,
- "\uA8C4"=>9,
- "\uA8E0"=>230,
- "\uA8E1"=>230,
- "\uA8E2"=>230,
- "\uA8E3"=>230,
- "\uA8E4"=>230,
- "\uA8E5"=>230,
- "\uA8E6"=>230,
- "\uA8E7"=>230,
- "\uA8E8"=>230,
- "\uA8E9"=>230,
- "\uA8EA"=>230,
- "\uA8EB"=>230,
- "\uA8EC"=>230,
- "\uA8ED"=>230,
- "\uA8EE"=>230,
- "\uA8EF"=>230,
- "\uA8F0"=>230,
- "\uA8F1"=>230,
- "\uA92B"=>220,
- "\uA92C"=>220,
- "\uA92D"=>220,
- "\uA953"=>9,
- "\uA9B3"=>7,
- "\uA9C0"=>9,
- "\uAAB0"=>230,
- "\uAAB2"=>230,
- "\uAAB3"=>230,
- "\uAAB4"=>220,
- "\uAAB7"=>230,
- "\uAAB8"=>230,
- "\uAABE"=>230,
- "\uAABF"=>230,
- "\uAAC1"=>230,
- "\uAAF6"=>9,
- "\uABED"=>9,
- "\uFB1E"=>26,
- "\uFE20"=>230,
- "\uFE21"=>230,
- "\uFE22"=>230,
- "\uFE23"=>230,
- "\uFE24"=>230,
- "\uFE25"=>230,
- "\uFE26"=>230,
- "\uFE27"=>220,
- "\uFE28"=>220,
- "\uFE29"=>220,
- "\uFE2A"=>220,
- "\uFE2B"=>220,
- "\uFE2C"=>220,
- "\uFE2D"=>220,
- "\uFE2E"=>230,
- "\uFE2F"=>230,
- "\u{101FD}"=>220,
- "\u{102E0}"=>220,
- "\u{10376}"=>230,
- "\u{10377}"=>230,
- "\u{10378}"=>230,
- "\u{10379}"=>230,
- "\u{1037A}"=>230,
- "\u{10A0D}"=>220,
- "\u{10A0F}"=>230,
- "\u{10A38}"=>230,
- "\u{10A39}"=>1,
- "\u{10A3A}"=>220,
- "\u{10A3F}"=>9,
- "\u{10AE5}"=>230,
- "\u{10AE6}"=>220,
- "\u{10D24}"=>230,
- "\u{10D25}"=>230,
- "\u{10D26}"=>230,
- "\u{10D27}"=>230,
- "\u{10F46}"=>220,
- "\u{10F47}"=>220,
- "\u{10F48}"=>230,
- "\u{10F49}"=>230,
- "\u{10F4A}"=>230,
- "\u{10F4B}"=>220,
- "\u{10F4C}"=>230,
- "\u{10F4D}"=>220,
- "\u{10F4E}"=>220,
- "\u{10F4F}"=>220,
- "\u{10F50}"=>220,
- "\u{11046}"=>9,
- "\u{1107F}"=>9,
- "\u{110B9}"=>9,
- "\u{110BA}"=>7,
- "\u{11100}"=>230,
- "\u{11101}"=>230,
- "\u{11102}"=>230,
- "\u{11133}"=>9,
- "\u{11134}"=>9,
- "\u{11173}"=>7,
- "\u{111C0}"=>9,
- "\u{111CA}"=>7,
- "\u{11235}"=>9,
- "\u{11236}"=>7,
- "\u{112E9}"=>7,
- "\u{112EA}"=>9,
- "\u{1133B}"=>7,
- "\u{1133C}"=>7,
- "\u{1134D}"=>9,
- "\u{11366}"=>230,
- "\u{11367}"=>230,
- "\u{11368}"=>230,
- "\u{11369}"=>230,
- "\u{1136A}"=>230,
- "\u{1136B}"=>230,
- "\u{1136C}"=>230,
- "\u{11370}"=>230,
- "\u{11371}"=>230,
- "\u{11372}"=>230,
- "\u{11373}"=>230,
- "\u{11374}"=>230,
- "\u{11442}"=>9,
- "\u{11446}"=>7,
- "\u{1145E}"=>230,
- "\u{114C2}"=>9,
- "\u{114C3}"=>7,
- "\u{115BF}"=>9,
- "\u{115C0}"=>7,
- "\u{1163F}"=>9,
- "\u{116B6}"=>9,
- "\u{116B7}"=>7,
- "\u{1172B}"=>9,
- "\u{11839}"=>9,
- "\u{1183A}"=>7,
- "\u{119E0}"=>9,
- "\u{11A34}"=>9,
- "\u{11A47}"=>9,
- "\u{11A99}"=>9,
- "\u{11C3F}"=>9,
- "\u{11D42}"=>7,
- "\u{11D44}"=>9,
- "\u{11D45}"=>9,
- "\u{11D97}"=>9,
- "\u{16AF0}"=>1,
- "\u{16AF1}"=>1,
- "\u{16AF2}"=>1,
- "\u{16AF3}"=>1,
- "\u{16AF4}"=>1,
- "\u{16B30}"=>230,
- "\u{16B31}"=>230,
- "\u{16B32}"=>230,
- "\u{16B33}"=>230,
- "\u{16B34}"=>230,
- "\u{16B35}"=>230,
- "\u{16B36}"=>230,
- "\u{1BC9E}"=>1,
- "\u{1D165}"=>216,
- "\u{1D166}"=>216,
- "\u{1D167}"=>1,
- "\u{1D168}"=>1,
- "\u{1D169}"=>1,
- "\u{1D16D}"=>226,
- "\u{1D16E}"=>216,
- "\u{1D16F}"=>216,
- "\u{1D170}"=>216,
- "\u{1D171}"=>216,
- "\u{1D172}"=>216,
- "\u{1D17B}"=>220,
- "\u{1D17C}"=>220,
- "\u{1D17D}"=>220,
- "\u{1D17E}"=>220,
- "\u{1D17F}"=>220,
- "\u{1D180}"=>220,
- "\u{1D181}"=>220,
- "\u{1D182}"=>220,
- "\u{1D185}"=>230,
- "\u{1D186}"=>230,
- "\u{1D187}"=>230,
- "\u{1D188}"=>230,
- "\u{1D189}"=>230,
- "\u{1D18A}"=>220,
- "\u{1D18B}"=>220,
- "\u{1D1AA}"=>230,
- "\u{1D1AB}"=>230,
- "\u{1D1AC}"=>230,
- "\u{1D1AD}"=>230,
- "\u{1D242}"=>230,
- "\u{1D243}"=>230,
- "\u{1D244}"=>230,
- "\u{1E000}"=>230,
- "\u{1E001}"=>230,
- "\u{1E002}"=>230,
- "\u{1E003}"=>230,
- "\u{1E004}"=>230,
- "\u{1E005}"=>230,
- "\u{1E006}"=>230,
- "\u{1E008}"=>230,
- "\u{1E009}"=>230,
- "\u{1E00A}"=>230,
- "\u{1E00B}"=>230,
- "\u{1E00C}"=>230,
- "\u{1E00D}"=>230,
- "\u{1E00E}"=>230,
- "\u{1E00F}"=>230,
- "\u{1E010}"=>230,
- "\u{1E011}"=>230,
- "\u{1E012}"=>230,
- "\u{1E013}"=>230,
- "\u{1E014}"=>230,
- "\u{1E015}"=>230,
- "\u{1E016}"=>230,
- "\u{1E017}"=>230,
- "\u{1E018}"=>230,
- "\u{1E01B}"=>230,
- "\u{1E01C}"=>230,
- "\u{1E01D}"=>230,
- "\u{1E01E}"=>230,
- "\u{1E01F}"=>230,
- "\u{1E020}"=>230,
- "\u{1E021}"=>230,
- "\u{1E023}"=>230,
- "\u{1E024}"=>230,
- "\u{1E026}"=>230,
- "\u{1E027}"=>230,
- "\u{1E028}"=>230,
- "\u{1E029}"=>230,
- "\u{1E02A}"=>230,
- "\u{1E130}"=>230,
- "\u{1E131}"=>230,
- "\u{1E132}"=>230,
- "\u{1E133}"=>230,
- "\u{1E134}"=>230,
- "\u{1E135}"=>230,
- "\u{1E136}"=>230,
- "\u{1E2EC}"=>230,
- "\u{1E2ED}"=>230,
- "\u{1E2EE}"=>230,
- "\u{1E2EF}"=>230,
- "\u{1E8D0}"=>220,
- "\u{1E8D1}"=>220,
- "\u{1E8D2}"=>220,
- "\u{1E8D3}"=>220,
- "\u{1E8D4}"=>220,
- "\u{1E8D5}"=>220,
- "\u{1E8D6}"=>220,
- "\u{1E944}"=>230,
- "\u{1E945}"=>230,
- "\u{1E946}"=>230,
- "\u{1E947}"=>230,
- "\u{1E948}"=>230,
- "\u{1E949}"=>230,
- "\u{1E94A}"=>7,
+ "\u0300"=>230, "\u0301"=>230, "\u0302"=>230, "\u0303"=>230, "\u0304"=>230, "\u0305"=>230, "\u0306"=>230, "\u0307"=>230,
+ "\u0308"=>230, "\u0309"=>230, "\u030A"=>230, "\u030B"=>230, "\u030C"=>230, "\u030D"=>230, "\u030E"=>230, "\u030F"=>230,
+ "\u0310"=>230, "\u0311"=>230, "\u0312"=>230, "\u0313"=>230, "\u0314"=>230, "\u0315"=>232, "\u0316"=>220, "\u0317"=>220,
+ "\u0318"=>220, "\u0319"=>220, "\u031A"=>232, "\u031B"=>216, "\u031C"=>220, "\u031D"=>220, "\u031E"=>220, "\u031F"=>220,
+ "\u0320"=>220, "\u0321"=>202, "\u0322"=>202, "\u0323"=>220, "\u0324"=>220, "\u0325"=>220, "\u0326"=>220, "\u0327"=>202,
+ "\u0328"=>202, "\u0329"=>220, "\u032A"=>220, "\u032B"=>220, "\u032C"=>220, "\u032D"=>220, "\u032E"=>220, "\u032F"=>220,
+ "\u0330"=>220, "\u0331"=>220, "\u0332"=>220, "\u0333"=>220, "\u0334"=>1, "\u0335"=>1, "\u0336"=>1, "\u0337"=>1,
+ "\u0338"=>1, "\u0339"=>220, "\u033A"=>220, "\u033B"=>220, "\u033C"=>220, "\u033D"=>230, "\u033E"=>230, "\u033F"=>230,
+ "\u0340"=>230, "\u0341"=>230, "\u0342"=>230, "\u0343"=>230, "\u0344"=>230, "\u0345"=>240, "\u0346"=>230, "\u0347"=>220,
+ "\u0348"=>220, "\u0349"=>220, "\u034A"=>230, "\u034B"=>230, "\u034C"=>230, "\u034D"=>220, "\u034E"=>220, "\u0350"=>230,
+ "\u0351"=>230, "\u0352"=>230, "\u0353"=>220, "\u0354"=>220, "\u0355"=>220, "\u0356"=>220, "\u0357"=>230, "\u0358"=>232,
+ "\u0359"=>220, "\u035A"=>220, "\u035B"=>230, "\u035C"=>233, "\u035D"=>234, "\u035E"=>234, "\u035F"=>233, "\u0360"=>234,
+ "\u0361"=>234, "\u0362"=>233, "\u0363"=>230, "\u0364"=>230, "\u0365"=>230, "\u0366"=>230, "\u0367"=>230, "\u0368"=>230,
+ "\u0369"=>230, "\u036A"=>230, "\u036B"=>230, "\u036C"=>230, "\u036D"=>230, "\u036E"=>230, "\u036F"=>230, "\u0483"=>230,
+ "\u0484"=>230, "\u0485"=>230, "\u0486"=>230, "\u0487"=>230, "\u0591"=>220, "\u0592"=>230, "\u0593"=>230, "\u0594"=>230,
+ "\u0595"=>230, "\u0596"=>220, "\u0597"=>230, "\u0598"=>230, "\u0599"=>230, "\u059A"=>222, "\u059B"=>220, "\u059C"=>230,
+ "\u059D"=>230, "\u059E"=>230, "\u059F"=>230, "\u05A0"=>230, "\u05A1"=>230, "\u05A2"=>220, "\u05A3"=>220, "\u05A4"=>220,
+ "\u05A5"=>220, "\u05A6"=>220, "\u05A7"=>220, "\u05A8"=>230, "\u05A9"=>230, "\u05AA"=>220, "\u05AB"=>230, "\u05AC"=>230,
+ "\u05AD"=>222, "\u05AE"=>228, "\u05AF"=>230, "\u05B0"=>10, "\u05B1"=>11, "\u05B2"=>12, "\u05B3"=>13, "\u05B4"=>14,
+ "\u05B5"=>15, "\u05B6"=>16, "\u05B7"=>17, "\u05B8"=>18, "\u05B9"=>19, "\u05BA"=>19, "\u05BB"=>20, "\u05BC"=>21,
+ "\u05BD"=>22, "\u05BF"=>23, "\u05C1"=>24, "\u05C2"=>25, "\u05C4"=>230, "\u05C5"=>220, "\u05C7"=>18, "\u0610"=>230,
+ "\u0611"=>230, "\u0612"=>230, "\u0613"=>230, "\u0614"=>230, "\u0615"=>230, "\u0616"=>230, "\u0617"=>230, "\u0618"=>30,
+ "\u0619"=>31, "\u061A"=>32, "\u064B"=>27, "\u064C"=>28, "\u064D"=>29, "\u064E"=>30, "\u064F"=>31, "\u0650"=>32,
+ "\u0651"=>33, "\u0652"=>34, "\u0653"=>230, "\u0654"=>230, "\u0655"=>220, "\u0656"=>220, "\u0657"=>230, "\u0658"=>230,
+ "\u0659"=>230, "\u065A"=>230, "\u065B"=>230, "\u065C"=>220, "\u065D"=>230, "\u065E"=>230, "\u065F"=>220, "\u0670"=>35,
+ "\u06D6"=>230, "\u06D7"=>230, "\u06D8"=>230, "\u06D9"=>230, "\u06DA"=>230, "\u06DB"=>230, "\u06DC"=>230, "\u06DF"=>230,
+ "\u06E0"=>230, "\u06E1"=>230, "\u06E2"=>230, "\u06E3"=>220, "\u06E4"=>230, "\u06E7"=>230, "\u06E8"=>230, "\u06EA"=>220,
+ "\u06EB"=>230, "\u06EC"=>230, "\u06ED"=>220, "\u0711"=>36, "\u0730"=>230, "\u0731"=>220, "\u0732"=>230, "\u0733"=>230,
+ "\u0734"=>220, "\u0735"=>230, "\u0736"=>230, "\u0737"=>220, "\u0738"=>220, "\u0739"=>220, "\u073A"=>230, "\u073B"=>220,
+ "\u073C"=>220, "\u073D"=>230, "\u073E"=>220, "\u073F"=>230, "\u0740"=>230, "\u0741"=>230, "\u0742"=>220, "\u0743"=>230,
+ "\u0744"=>220, "\u0745"=>230, "\u0746"=>220, "\u0747"=>230, "\u0748"=>220, "\u0749"=>230, "\u074A"=>230, "\u07EB"=>230,
+ "\u07EC"=>230, "\u07ED"=>230, "\u07EE"=>230, "\u07EF"=>230, "\u07F0"=>230, "\u07F1"=>230, "\u07F2"=>220, "\u07F3"=>230,
+ "\u0816"=>230, "\u0817"=>230, "\u0818"=>230, "\u0819"=>230, "\u081B"=>230, "\u081C"=>230, "\u081D"=>230, "\u081E"=>230,
+ "\u081F"=>230, "\u0820"=>230, "\u0821"=>230, "\u0822"=>230, "\u0823"=>230, "\u0825"=>230, "\u0826"=>230, "\u0827"=>230,
+ "\u0829"=>230, "\u082A"=>230, "\u082B"=>230, "\u082C"=>230, "\u082D"=>230, "\u0859"=>220, "\u085A"=>220, "\u085B"=>220,
+ "\u08D4"=>230, "\u08D5"=>230, "\u08D6"=>230, "\u08D7"=>230, "\u08D8"=>230, "\u08D9"=>230, "\u08DA"=>230, "\u08DB"=>230,
+ "\u08DC"=>230, "\u08DD"=>230, "\u08DE"=>230, "\u08DF"=>230, "\u08E0"=>230, "\u08E1"=>230, "\u08E3"=>220, "\u08E4"=>230,
+ "\u08E5"=>230, "\u08E6"=>220, "\u08E7"=>230, "\u08E8"=>230, "\u08E9"=>220, "\u08EA"=>230, "\u08EB"=>230, "\u08EC"=>230,
+ "\u08ED"=>220, "\u08EE"=>220, "\u08EF"=>220, "\u08F0"=>27, "\u08F1"=>28, "\u08F2"=>29, "\u08F3"=>230, "\u08F4"=>230,
+ "\u08F5"=>230, "\u08F6"=>220, "\u08F7"=>230, "\u08F8"=>230, "\u08F9"=>220, "\u08FA"=>220, "\u08FB"=>230, "\u08FC"=>230,
+ "\u08FD"=>230, "\u08FE"=>230, "\u08FF"=>230, "\u093C"=>7, "\u094D"=>9, "\u0951"=>230, "\u0952"=>220, "\u0953"=>230,
+ "\u0954"=>230, "\u09BC"=>7, "\u09CD"=>9, "\u0A3C"=>7, "\u0A4D"=>9, "\u0ABC"=>7, "\u0ACD"=>9, "\u0B3C"=>7,
+ "\u0B4D"=>9, "\u0BCD"=>9, "\u0C4D"=>9, "\u0C55"=>84, "\u0C56"=>91, "\u0CBC"=>7, "\u0CCD"=>9, "\u0D3B"=>9,
+ "\u0D3C"=>9, "\u0D4D"=>9, "\u0DCA"=>9, "\u0E38"=>103, "\u0E39"=>103, "\u0E3A"=>9, "\u0E48"=>107, "\u0E49"=>107,
+ "\u0E4A"=>107, "\u0E4B"=>107, "\u0EB8"=>118, "\u0EB9"=>118, "\u0EC8"=>122, "\u0EC9"=>122, "\u0ECA"=>122, "\u0ECB"=>122,
+ "\u0F18"=>220, "\u0F19"=>220, "\u0F35"=>220, "\u0F37"=>220, "\u0F39"=>216, "\u0F71"=>129, "\u0F72"=>130, "\u0F74"=>132,
+ "\u0F7A"=>130, "\u0F7B"=>130, "\u0F7C"=>130, "\u0F7D"=>130, "\u0F80"=>130, "\u0F82"=>230, "\u0F83"=>230, "\u0F84"=>9,
+ "\u0F86"=>230, "\u0F87"=>230, "\u0FC6"=>220, "\u1037"=>7, "\u1039"=>9, "\u103A"=>9, "\u108D"=>220, "\u135D"=>230,
+ "\u135E"=>230, "\u135F"=>230, "\u1714"=>9, "\u1734"=>9, "\u17D2"=>9, "\u17DD"=>230, "\u18A9"=>228, "\u1939"=>222,
+ "\u193A"=>230, "\u193B"=>220, "\u1A17"=>230, "\u1A18"=>220, "\u1A60"=>9, "\u1A75"=>230, "\u1A76"=>230, "\u1A77"=>230,
+ "\u1A78"=>230, "\u1A79"=>230, "\u1A7A"=>230, "\u1A7B"=>230, "\u1A7C"=>230, "\u1A7F"=>220, "\u1AB0"=>230, "\u1AB1"=>230,
+ "\u1AB2"=>230, "\u1AB3"=>230, "\u1AB4"=>230, "\u1AB5"=>220, "\u1AB6"=>220, "\u1AB7"=>220, "\u1AB8"=>220, "\u1AB9"=>220,
+ "\u1ABA"=>220, "\u1ABB"=>230, "\u1ABC"=>230, "\u1ABD"=>220, "\u1B34"=>7, "\u1B44"=>9, "\u1B6B"=>230, "\u1B6C"=>220,
+ "\u1B6D"=>230, "\u1B6E"=>230, "\u1B6F"=>230, "\u1B70"=>230, "\u1B71"=>230, "\u1B72"=>230, "\u1B73"=>230, "\u1BAA"=>9,
+ "\u1BAB"=>9, "\u1BE6"=>7, "\u1BF2"=>9, "\u1BF3"=>9, "\u1C37"=>7, "\u1CD0"=>230, "\u1CD1"=>230, "\u1CD2"=>230,
+ "\u1CD4"=>1, "\u1CD5"=>220, "\u1CD6"=>220, "\u1CD7"=>220, "\u1CD8"=>220, "\u1CD9"=>220, "\u1CDA"=>230, "\u1CDB"=>230,
+ "\u1CDC"=>220, "\u1CDD"=>220, "\u1CDE"=>220, "\u1CDF"=>220, "\u1CE0"=>230, "\u1CE2"=>1, "\u1CE3"=>1, "\u1CE4"=>1,
+ "\u1CE5"=>1, "\u1CE6"=>1, "\u1CE7"=>1, "\u1CE8"=>1, "\u1CED"=>220, "\u1CF4"=>230, "\u1CF8"=>230, "\u1CF9"=>230,
+ "\u1DC0"=>230, "\u1DC1"=>230, "\u1DC2"=>220, "\u1DC3"=>230, "\u1DC4"=>230, "\u1DC5"=>230, "\u1DC6"=>230, "\u1DC7"=>230,
+ "\u1DC8"=>230, "\u1DC9"=>230, "\u1DCA"=>220, "\u1DCB"=>230, "\u1DCC"=>230, "\u1DCD"=>234, "\u1DCE"=>214, "\u1DCF"=>220,
+ "\u1DD0"=>202, "\u1DD1"=>230, "\u1DD2"=>230, "\u1DD3"=>230, "\u1DD4"=>230, "\u1DD5"=>230, "\u1DD6"=>230, "\u1DD7"=>230,
+ "\u1DD8"=>230, "\u1DD9"=>230, "\u1DDA"=>230, "\u1DDB"=>230, "\u1DDC"=>230, "\u1DDD"=>230, "\u1DDE"=>230, "\u1DDF"=>230,
+ "\u1DE0"=>230, "\u1DE1"=>230, "\u1DE2"=>230, "\u1DE3"=>230, "\u1DE4"=>230, "\u1DE5"=>230, "\u1DE6"=>230, "\u1DE7"=>230,
+ "\u1DE8"=>230, "\u1DE9"=>230, "\u1DEA"=>230, "\u1DEB"=>230, "\u1DEC"=>230, "\u1DED"=>230, "\u1DEE"=>230, "\u1DEF"=>230,
+ "\u1DF0"=>230, "\u1DF1"=>230, "\u1DF2"=>230, "\u1DF3"=>230, "\u1DF4"=>230, "\u1DF5"=>230, "\u1DF6"=>232, "\u1DF7"=>228,
+ "\u1DF8"=>228, "\u1DF9"=>220, "\u1DFB"=>230, "\u1DFC"=>233, "\u1DFD"=>220, "\u1DFE"=>230, "\u1DFF"=>220, "\u20D0"=>230,
+ "\u20D1"=>230, "\u20D2"=>1, "\u20D3"=>1, "\u20D4"=>230, "\u20D5"=>230, "\u20D6"=>230, "\u20D7"=>230, "\u20D8"=>1,
+ "\u20D9"=>1, "\u20DA"=>1, "\u20DB"=>230, "\u20DC"=>230, "\u20E1"=>230, "\u20E5"=>1, "\u20E6"=>1, "\u20E7"=>230,
+ "\u20E8"=>220, "\u20E9"=>230, "\u20EA"=>1, "\u20EB"=>1, "\u20EC"=>220, "\u20ED"=>220, "\u20EE"=>220, "\u20EF"=>220,
+ "\u20F0"=>230, "\u2CEF"=>230, "\u2CF0"=>230, "\u2CF1"=>230, "\u2D7F"=>9, "\u2DE0"=>230, "\u2DE1"=>230, "\u2DE2"=>230,
+ "\u2DE3"=>230, "\u2DE4"=>230, "\u2DE5"=>230, "\u2DE6"=>230, "\u2DE7"=>230, "\u2DE8"=>230, "\u2DE9"=>230, "\u2DEA"=>230,
+ "\u2DEB"=>230, "\u2DEC"=>230, "\u2DED"=>230, "\u2DEE"=>230, "\u2DEF"=>230, "\u2DF0"=>230, "\u2DF1"=>230, "\u2DF2"=>230,
+ "\u2DF3"=>230, "\u2DF4"=>230, "\u2DF5"=>230, "\u2DF6"=>230, "\u2DF7"=>230, "\u2DF8"=>230, "\u2DF9"=>230, "\u2DFA"=>230,
+ "\u2DFB"=>230, "\u2DFC"=>230, "\u2DFD"=>230, "\u2DFE"=>230, "\u2DFF"=>230, "\u302A"=>218, "\u302B"=>228, "\u302C"=>232,
+ "\u302D"=>222, "\u302E"=>224, "\u302F"=>224, "\u3099"=>8, "\u309A"=>8, "\uA66F"=>230, "\uA674"=>230, "\uA675"=>230,
+ "\uA676"=>230, "\uA677"=>230, "\uA678"=>230, "\uA679"=>230, "\uA67A"=>230, "\uA67B"=>230, "\uA67C"=>230, "\uA67D"=>230,
+ "\uA69E"=>230, "\uA69F"=>230, "\uA6F0"=>230, "\uA6F1"=>230, "\uA806"=>9, "\uA8C4"=>9, "\uA8E0"=>230, "\uA8E1"=>230,
+ "\uA8E2"=>230, "\uA8E3"=>230, "\uA8E4"=>230, "\uA8E5"=>230, "\uA8E6"=>230, "\uA8E7"=>230, "\uA8E8"=>230, "\uA8E9"=>230,
+ "\uA8EA"=>230, "\uA8EB"=>230, "\uA8EC"=>230, "\uA8ED"=>230, "\uA8EE"=>230, "\uA8EF"=>230, "\uA8F0"=>230, "\uA8F1"=>230,
+ "\uA92B"=>220, "\uA92C"=>220, "\uA92D"=>220, "\uA953"=>9, "\uA9B3"=>7, "\uA9C0"=>9, "\uAAB0"=>230, "\uAAB2"=>230,
+ "\uAAB3"=>230, "\uAAB4"=>220, "\uAAB7"=>230, "\uAAB8"=>230, "\uAABE"=>230, "\uAABF"=>230, "\uAAC1"=>230, "\uAAF6"=>9,
+ "\uABED"=>9, "\uFB1E"=>26, "\uFE20"=>230, "\uFE21"=>230, "\uFE22"=>230, "\uFE23"=>230, "\uFE24"=>230, "\uFE25"=>230,
+ "\uFE26"=>230, "\uFE27"=>220, "\uFE28"=>220, "\uFE29"=>220, "\uFE2A"=>220, "\uFE2B"=>220, "\uFE2C"=>220, "\uFE2D"=>220,
+ "\uFE2E"=>230, "\uFE2F"=>230, "\u{101FD}"=>220, "\u{102E0}"=>220, "\u{10376}"=>230, "\u{10377}"=>230, "\u{10378}"=>230, "\u{10379}"=>230,
+ "\u{1037A}"=>230, "\u{10A0D}"=>220, "\u{10A0F}"=>230, "\u{10A38}"=>230, "\u{10A39}"=>1, "\u{10A3A}"=>220, "\u{10A3F}"=>9, "\u{10AE5}"=>230,
+ "\u{10AE6}"=>220, "\u{11046}"=>9, "\u{1107F}"=>9, "\u{110B9}"=>9, "\u{110BA}"=>7, "\u{11100}"=>230, "\u{11101}"=>230, "\u{11102}"=>230,
+ "\u{11133}"=>9, "\u{11134}"=>9, "\u{11173}"=>7, "\u{111C0}"=>9, "\u{111CA}"=>7, "\u{11235}"=>9, "\u{11236}"=>7, "\u{112E9}"=>7,
+ "\u{112EA}"=>9, "\u{1133C}"=>7, "\u{1134D}"=>9, "\u{11366}"=>230, "\u{11367}"=>230, "\u{11368}"=>230, "\u{11369}"=>230, "\u{1136A}"=>230,
+ "\u{1136B}"=>230, "\u{1136C}"=>230, "\u{11370}"=>230, "\u{11371}"=>230, "\u{11372}"=>230, "\u{11373}"=>230, "\u{11374}"=>230, "\u{11442}"=>9,
+ "\u{11446}"=>7, "\u{114C2}"=>9, "\u{114C3}"=>7, "\u{115BF}"=>9, "\u{115C0}"=>7, "\u{1163F}"=>9, "\u{116B6}"=>9, "\u{116B7}"=>7,
+ "\u{1172B}"=>9, "\u{11A34}"=>9, "\u{11A47}"=>9, "\u{11A99}"=>9, "\u{11C3F}"=>9, "\u{11D42}"=>7, "\u{11D44}"=>9, "\u{11D45}"=>9,
+ "\u{16AF0}"=>1, "\u{16AF1}"=>1, "\u{16AF2}"=>1, "\u{16AF3}"=>1, "\u{16AF4}"=>1, "\u{16B30}"=>230, "\u{16B31}"=>230, "\u{16B32}"=>230,
+ "\u{16B33}"=>230, "\u{16B34}"=>230, "\u{16B35}"=>230, "\u{16B36}"=>230, "\u{1BC9E}"=>1, "\u{1D165}"=>216, "\u{1D166}"=>216, "\u{1D167}"=>1,
+ "\u{1D168}"=>1, "\u{1D169}"=>1, "\u{1D16D}"=>226, "\u{1D16E}"=>216, "\u{1D16F}"=>216, "\u{1D170}"=>216, "\u{1D171}"=>216, "\u{1D172}"=>216,
+ "\u{1D17B}"=>220, "\u{1D17C}"=>220, "\u{1D17D}"=>220, "\u{1D17E}"=>220, "\u{1D17F}"=>220, "\u{1D180}"=>220, "\u{1D181}"=>220, "\u{1D182}"=>220,
+ "\u{1D185}"=>230, "\u{1D186}"=>230, "\u{1D187}"=>230, "\u{1D188}"=>230, "\u{1D189}"=>230, "\u{1D18A}"=>220, "\u{1D18B}"=>220, "\u{1D1AA}"=>230,
+ "\u{1D1AB}"=>230, "\u{1D1AC}"=>230, "\u{1D1AD}"=>230, "\u{1D242}"=>230, "\u{1D243}"=>230, "\u{1D244}"=>230, "\u{1E000}"=>230, "\u{1E001}"=>230,
+ "\u{1E002}"=>230, "\u{1E003}"=>230, "\u{1E004}"=>230, "\u{1E005}"=>230, "\u{1E006}"=>230, "\u{1E008}"=>230, "\u{1E009}"=>230, "\u{1E00A}"=>230,
+ "\u{1E00B}"=>230, "\u{1E00C}"=>230, "\u{1E00D}"=>230, "\u{1E00E}"=>230, "\u{1E00F}"=>230, "\u{1E010}"=>230, "\u{1E011}"=>230, "\u{1E012}"=>230,
+ "\u{1E013}"=>230, "\u{1E014}"=>230, "\u{1E015}"=>230, "\u{1E016}"=>230, "\u{1E017}"=>230, "\u{1E018}"=>230, "\u{1E01B}"=>230, "\u{1E01C}"=>230,
+ "\u{1E01D}"=>230, "\u{1E01E}"=>230, "\u{1E01F}"=>230, "\u{1E020}"=>230, "\u{1E021}"=>230, "\u{1E023}"=>230, "\u{1E024}"=>230, "\u{1E026}"=>230,
+ "\u{1E027}"=>230, "\u{1E028}"=>230, "\u{1E029}"=>230, "\u{1E02A}"=>230, "\u{1E8D0}"=>220, "\u{1E8D1}"=>220, "\u{1E8D2}"=>220, "\u{1E8D3}"=>220,
+ "\u{1E8D4}"=>220, "\u{1E8D5}"=>220, "\u{1E8D6}"=>220, "\u{1E944}"=>230, "\u{1E945}"=>230, "\u{1E946}"=>230, "\u{1E947}"=>230, "\u{1E948}"=>230,
+ "\u{1E949}"=>230, "\u{1E94A}"=>7,
}
class_table.default = 0
CLASS_TABLE = class_table.freeze
DECOMPOSITION_TABLE = {
- "\u00C0"=>"A\u0300",
- "\u00C1"=>"A\u0301",
- "\u00C2"=>"A\u0302",
- "\u00C3"=>"A\u0303",
- "\u00C4"=>"A\u0308",
- "\u00C5"=>"A\u030A",
- "\u00C7"=>"C\u0327",
- "\u00C8"=>"E\u0300",
- "\u00C9"=>"E\u0301",
- "\u00CA"=>"E\u0302",
- "\u00CB"=>"E\u0308",
- "\u00CC"=>"I\u0300",
- "\u00CD"=>"I\u0301",
- "\u00CE"=>"I\u0302",
- "\u00CF"=>"I\u0308",
- "\u00D1"=>"N\u0303",
- "\u00D2"=>"O\u0300",
- "\u00D3"=>"O\u0301",
- "\u00D4"=>"O\u0302",
- "\u00D5"=>"O\u0303",
- "\u00D6"=>"O\u0308",
- "\u00D9"=>"U\u0300",
- "\u00DA"=>"U\u0301",
- "\u00DB"=>"U\u0302",
- "\u00DC"=>"U\u0308",
- "\u00DD"=>"Y\u0301",
- "\u00E0"=>"a\u0300",
- "\u00E1"=>"a\u0301",
- "\u00E2"=>"a\u0302",
- "\u00E3"=>"a\u0303",
- "\u00E4"=>"a\u0308",
- "\u00E5"=>"a\u030A",
- "\u00E7"=>"c\u0327",
- "\u00E8"=>"e\u0300",
- "\u00E9"=>"e\u0301",
- "\u00EA"=>"e\u0302",
- "\u00EB"=>"e\u0308",
- "\u00EC"=>"i\u0300",
- "\u00ED"=>"i\u0301",
- "\u00EE"=>"i\u0302",
- "\u00EF"=>"i\u0308",
- "\u00F1"=>"n\u0303",
- "\u00F2"=>"o\u0300",
- "\u00F3"=>"o\u0301",
- "\u00F4"=>"o\u0302",
- "\u00F5"=>"o\u0303",
- "\u00F6"=>"o\u0308",
- "\u00F9"=>"u\u0300",
- "\u00FA"=>"u\u0301",
- "\u00FB"=>"u\u0302",
- "\u00FC"=>"u\u0308",
- "\u00FD"=>"y\u0301",
- "\u00FF"=>"y\u0308",
- "\u0100"=>"A\u0304",
- "\u0101"=>"a\u0304",
- "\u0102"=>"A\u0306",
- "\u0103"=>"a\u0306",
- "\u0104"=>"A\u0328",
- "\u0105"=>"a\u0328",
- "\u0106"=>"C\u0301",
- "\u0107"=>"c\u0301",
- "\u0108"=>"C\u0302",
- "\u0109"=>"c\u0302",
- "\u010A"=>"C\u0307",
- "\u010B"=>"c\u0307",
- "\u010C"=>"C\u030C",
- "\u010D"=>"c\u030C",
- "\u010E"=>"D\u030C",
- "\u010F"=>"d\u030C",
- "\u0112"=>"E\u0304",
- "\u0113"=>"e\u0304",
- "\u0114"=>"E\u0306",
- "\u0115"=>"e\u0306",
- "\u0116"=>"E\u0307",
- "\u0117"=>"e\u0307",
- "\u0118"=>"E\u0328",
- "\u0119"=>"e\u0328",
- "\u011A"=>"E\u030C",
- "\u011B"=>"e\u030C",
- "\u011C"=>"G\u0302",
- "\u011D"=>"g\u0302",
- "\u011E"=>"G\u0306",
- "\u011F"=>"g\u0306",
- "\u0120"=>"G\u0307",
- "\u0121"=>"g\u0307",
- "\u0122"=>"G\u0327",
- "\u0123"=>"g\u0327",
- "\u0124"=>"H\u0302",
- "\u0125"=>"h\u0302",
- "\u0128"=>"I\u0303",
- "\u0129"=>"i\u0303",
- "\u012A"=>"I\u0304",
- "\u012B"=>"i\u0304",
- "\u012C"=>"I\u0306",
- "\u012D"=>"i\u0306",
- "\u012E"=>"I\u0328",
- "\u012F"=>"i\u0328",
- "\u0130"=>"I\u0307",
- "\u0134"=>"J\u0302",
- "\u0135"=>"j\u0302",
- "\u0136"=>"K\u0327",
- "\u0137"=>"k\u0327",
- "\u0139"=>"L\u0301",
- "\u013A"=>"l\u0301",
- "\u013B"=>"L\u0327",
- "\u013C"=>"l\u0327",
- "\u013D"=>"L\u030C",
- "\u013E"=>"l\u030C",
- "\u0143"=>"N\u0301",
- "\u0144"=>"n\u0301",
- "\u0145"=>"N\u0327",
- "\u0146"=>"n\u0327",
- "\u0147"=>"N\u030C",
- "\u0148"=>"n\u030C",
- "\u014C"=>"O\u0304",
- "\u014D"=>"o\u0304",
- "\u014E"=>"O\u0306",
- "\u014F"=>"o\u0306",
- "\u0150"=>"O\u030B",
- "\u0151"=>"o\u030B",
- "\u0154"=>"R\u0301",
- "\u0155"=>"r\u0301",
- "\u0156"=>"R\u0327",
- "\u0157"=>"r\u0327",
- "\u0158"=>"R\u030C",
- "\u0159"=>"r\u030C",
- "\u015A"=>"S\u0301",
- "\u015B"=>"s\u0301",
- "\u015C"=>"S\u0302",
- "\u015D"=>"s\u0302",
- "\u015E"=>"S\u0327",
- "\u015F"=>"s\u0327",
- "\u0160"=>"S\u030C",
- "\u0161"=>"s\u030C",
- "\u0162"=>"T\u0327",
- "\u0163"=>"t\u0327",
- "\u0164"=>"T\u030C",
- "\u0165"=>"t\u030C",
- "\u0168"=>"U\u0303",
- "\u0169"=>"u\u0303",
- "\u016A"=>"U\u0304",
- "\u016B"=>"u\u0304",
- "\u016C"=>"U\u0306",
- "\u016D"=>"u\u0306",
- "\u016E"=>"U\u030A",
- "\u016F"=>"u\u030A",
- "\u0170"=>"U\u030B",
- "\u0171"=>"u\u030B",
- "\u0172"=>"U\u0328",
- "\u0173"=>"u\u0328",
- "\u0174"=>"W\u0302",
- "\u0175"=>"w\u0302",
- "\u0176"=>"Y\u0302",
- "\u0177"=>"y\u0302",
- "\u0178"=>"Y\u0308",
- "\u0179"=>"Z\u0301",
- "\u017A"=>"z\u0301",
- "\u017B"=>"Z\u0307",
- "\u017C"=>"z\u0307",
- "\u017D"=>"Z\u030C",
- "\u017E"=>"z\u030C",
- "\u01A0"=>"O\u031B",
- "\u01A1"=>"o\u031B",
- "\u01AF"=>"U\u031B",
- "\u01B0"=>"u\u031B",
- "\u01CD"=>"A\u030C",
- "\u01CE"=>"a\u030C",
- "\u01CF"=>"I\u030C",
- "\u01D0"=>"i\u030C",
- "\u01D1"=>"O\u030C",
- "\u01D2"=>"o\u030C",
- "\u01D3"=>"U\u030C",
- "\u01D4"=>"u\u030C",
- "\u01D5"=>"U\u0308\u0304",
- "\u01D6"=>"u\u0308\u0304",
- "\u01D7"=>"U\u0308\u0301",
- "\u01D8"=>"u\u0308\u0301",
- "\u01D9"=>"U\u0308\u030C",
- "\u01DA"=>"u\u0308\u030C",
- "\u01DB"=>"U\u0308\u0300",
- "\u01DC"=>"u\u0308\u0300",
- "\u01DE"=>"A\u0308\u0304",
- "\u01DF"=>"a\u0308\u0304",
- "\u01E0"=>"A\u0307\u0304",
- "\u01E1"=>"a\u0307\u0304",
- "\u01E2"=>"\u00C6\u0304",
- "\u01E3"=>"\u00E6\u0304",
- "\u01E6"=>"G\u030C",
- "\u01E7"=>"g\u030C",
- "\u01E8"=>"K\u030C",
- "\u01E9"=>"k\u030C",
- "\u01EA"=>"O\u0328",
- "\u01EB"=>"o\u0328",
- "\u01EC"=>"O\u0328\u0304",
- "\u01ED"=>"o\u0328\u0304",
- "\u01EE"=>"\u01B7\u030C",
- "\u01EF"=>"\u0292\u030C",
- "\u01F0"=>"j\u030C",
- "\u01F4"=>"G\u0301",
- "\u01F5"=>"g\u0301",
- "\u01F8"=>"N\u0300",
- "\u01F9"=>"n\u0300",
- "\u01FA"=>"A\u030A\u0301",
- "\u01FB"=>"a\u030A\u0301",
- "\u01FC"=>"\u00C6\u0301",
- "\u01FD"=>"\u00E6\u0301",
- "\u01FE"=>"\u00D8\u0301",
- "\u01FF"=>"\u00F8\u0301",
- "\u0200"=>"A\u030F",
- "\u0201"=>"a\u030F",
- "\u0202"=>"A\u0311",
- "\u0203"=>"a\u0311",
- "\u0204"=>"E\u030F",
- "\u0205"=>"e\u030F",
- "\u0206"=>"E\u0311",
- "\u0207"=>"e\u0311",
- "\u0208"=>"I\u030F",
- "\u0209"=>"i\u030F",
- "\u020A"=>"I\u0311",
- "\u020B"=>"i\u0311",
- "\u020C"=>"O\u030F",
- "\u020D"=>"o\u030F",
- "\u020E"=>"O\u0311",
- "\u020F"=>"o\u0311",
- "\u0210"=>"R\u030F",
- "\u0211"=>"r\u030F",
- "\u0212"=>"R\u0311",
- "\u0213"=>"r\u0311",
- "\u0214"=>"U\u030F",
- "\u0215"=>"u\u030F",
- "\u0216"=>"U\u0311",
- "\u0217"=>"u\u0311",
- "\u0218"=>"S\u0326",
- "\u0219"=>"s\u0326",
- "\u021A"=>"T\u0326",
- "\u021B"=>"t\u0326",
- "\u021E"=>"H\u030C",
- "\u021F"=>"h\u030C",
- "\u0226"=>"A\u0307",
- "\u0227"=>"a\u0307",
- "\u0228"=>"E\u0327",
- "\u0229"=>"e\u0327",
- "\u022A"=>"O\u0308\u0304",
- "\u022B"=>"o\u0308\u0304",
- "\u022C"=>"O\u0303\u0304",
- "\u022D"=>"o\u0303\u0304",
- "\u022E"=>"O\u0307",
- "\u022F"=>"o\u0307",
- "\u0230"=>"O\u0307\u0304",
- "\u0231"=>"o\u0307\u0304",
- "\u0232"=>"Y\u0304",
- "\u0233"=>"y\u0304",
- "\u0340"=>"\u0300",
- "\u0341"=>"\u0301",
- "\u0343"=>"\u0313",
- "\u0344"=>"\u0308\u0301",
- "\u0374"=>"\u02B9",
- "\u037E"=>";",
- "\u0385"=>"\u00A8\u0301",
- "\u0386"=>"\u0391\u0301",
- "\u0387"=>"\u00B7",
- "\u0388"=>"\u0395\u0301",
- "\u0389"=>"\u0397\u0301",
- "\u038A"=>"\u0399\u0301",
- "\u038C"=>"\u039F\u0301",
- "\u038E"=>"\u03A5\u0301",
- "\u038F"=>"\u03A9\u0301",
- "\u0390"=>"\u03B9\u0308\u0301",
- "\u03AA"=>"\u0399\u0308",
- "\u03AB"=>"\u03A5\u0308",
- "\u03AC"=>"\u03B1\u0301",
- "\u03AD"=>"\u03B5\u0301",
- "\u03AE"=>"\u03B7\u0301",
- "\u03AF"=>"\u03B9\u0301",
- "\u03B0"=>"\u03C5\u0308\u0301",
- "\u03CA"=>"\u03B9\u0308",
- "\u03CB"=>"\u03C5\u0308",
- "\u03CC"=>"\u03BF\u0301",
- "\u03CD"=>"\u03C5\u0301",
- "\u03CE"=>"\u03C9\u0301",
- "\u03D3"=>"\u03D2\u0301",
- "\u03D4"=>"\u03D2\u0308",
- "\u0400"=>"\u0415\u0300",
- "\u0401"=>"\u0415\u0308",
- "\u0403"=>"\u0413\u0301",
- "\u0407"=>"\u0406\u0308",
- "\u040C"=>"\u041A\u0301",
- "\u040D"=>"\u0418\u0300",
- "\u040E"=>"\u0423\u0306",
- "\u0419"=>"\u0418\u0306",
- "\u0439"=>"\u0438\u0306",
- "\u0450"=>"\u0435\u0300",
- "\u0451"=>"\u0435\u0308",
- "\u0453"=>"\u0433\u0301",
- "\u0457"=>"\u0456\u0308",
- "\u045C"=>"\u043A\u0301",
- "\u045D"=>"\u0438\u0300",
- "\u045E"=>"\u0443\u0306",
- "\u0476"=>"\u0474\u030F",
- "\u0477"=>"\u0475\u030F",
- "\u04C1"=>"\u0416\u0306",
- "\u04C2"=>"\u0436\u0306",
- "\u04D0"=>"\u0410\u0306",
- "\u04D1"=>"\u0430\u0306",
- "\u04D2"=>"\u0410\u0308",
- "\u04D3"=>"\u0430\u0308",
- "\u04D6"=>"\u0415\u0306",
- "\u04D7"=>"\u0435\u0306",
- "\u04DA"=>"\u04D8\u0308",
- "\u04DB"=>"\u04D9\u0308",
- "\u04DC"=>"\u0416\u0308",
- "\u04DD"=>"\u0436\u0308",
- "\u04DE"=>"\u0417\u0308",
- "\u04DF"=>"\u0437\u0308",
- "\u04E2"=>"\u0418\u0304",
- "\u04E3"=>"\u0438\u0304",
- "\u04E4"=>"\u0418\u0308",
- "\u04E5"=>"\u0438\u0308",
- "\u04E6"=>"\u041E\u0308",
- "\u04E7"=>"\u043E\u0308",
- "\u04EA"=>"\u04E8\u0308",
- "\u04EB"=>"\u04E9\u0308",
- "\u04EC"=>"\u042D\u0308",
- "\u04ED"=>"\u044D\u0308",
- "\u04EE"=>"\u0423\u0304",
- "\u04EF"=>"\u0443\u0304",
- "\u04F0"=>"\u0423\u0308",
- "\u04F1"=>"\u0443\u0308",
- "\u04F2"=>"\u0423\u030B",
- "\u04F3"=>"\u0443\u030B",
- "\u04F4"=>"\u0427\u0308",
- "\u04F5"=>"\u0447\u0308",
- "\u04F8"=>"\u042B\u0308",
- "\u04F9"=>"\u044B\u0308",
- "\u0622"=>"\u0627\u0653",
- "\u0623"=>"\u0627\u0654",
- "\u0624"=>"\u0648\u0654",
- "\u0625"=>"\u0627\u0655",
- "\u0626"=>"\u064A\u0654",
- "\u06C0"=>"\u06D5\u0654",
- "\u06C2"=>"\u06C1\u0654",
- "\u06D3"=>"\u06D2\u0654",
- "\u0929"=>"\u0928\u093C",
- "\u0931"=>"\u0930\u093C",
- "\u0934"=>"\u0933\u093C",
- "\u0958"=>"\u0915\u093C",
- "\u0959"=>"\u0916\u093C",
- "\u095A"=>"\u0917\u093C",
- "\u095B"=>"\u091C\u093C",
- "\u095C"=>"\u0921\u093C",
- "\u095D"=>"\u0922\u093C",
- "\u095E"=>"\u092B\u093C",
- "\u095F"=>"\u092F\u093C",
- "\u09CB"=>"\u09C7\u09BE",
- "\u09CC"=>"\u09C7\u09D7",
- "\u09DC"=>"\u09A1\u09BC",
- "\u09DD"=>"\u09A2\u09BC",
- "\u09DF"=>"\u09AF\u09BC",
- "\u0A33"=>"\u0A32\u0A3C",
- "\u0A36"=>"\u0A38\u0A3C",
- "\u0A59"=>"\u0A16\u0A3C",
- "\u0A5A"=>"\u0A17\u0A3C",
- "\u0A5B"=>"\u0A1C\u0A3C",
- "\u0A5E"=>"\u0A2B\u0A3C",
- "\u0B48"=>"\u0B47\u0B56",
- "\u0B4B"=>"\u0B47\u0B3E",
- "\u0B4C"=>"\u0B47\u0B57",
- "\u0B5C"=>"\u0B21\u0B3C",
- "\u0B5D"=>"\u0B22\u0B3C",
- "\u0B94"=>"\u0B92\u0BD7",
- "\u0BCA"=>"\u0BC6\u0BBE",
- "\u0BCB"=>"\u0BC7\u0BBE",
- "\u0BCC"=>"\u0BC6\u0BD7",
- "\u0C48"=>"\u0C46\u0C56",
- "\u0CC0"=>"\u0CBF\u0CD5",
- "\u0CC7"=>"\u0CC6\u0CD5",
- "\u0CC8"=>"\u0CC6\u0CD6",
- "\u0CCA"=>"\u0CC6\u0CC2",
- "\u0CCB"=>"\u0CC6\u0CC2\u0CD5",
- "\u0D4A"=>"\u0D46\u0D3E",
- "\u0D4B"=>"\u0D47\u0D3E",
- "\u0D4C"=>"\u0D46\u0D57",
- "\u0DDA"=>"\u0DD9\u0DCA",
- "\u0DDC"=>"\u0DD9\u0DCF",
- "\u0DDD"=>"\u0DD9\u0DCF\u0DCA",
- "\u0DDE"=>"\u0DD9\u0DDF",
- "\u0F43"=>"\u0F42\u0FB7",
- "\u0F4D"=>"\u0F4C\u0FB7",
- "\u0F52"=>"\u0F51\u0FB7",
- "\u0F57"=>"\u0F56\u0FB7",
- "\u0F5C"=>"\u0F5B\u0FB7",
- "\u0F69"=>"\u0F40\u0FB5",
- "\u0F73"=>"\u0F71\u0F72",
- "\u0F75"=>"\u0F71\u0F74",
- "\u0F76"=>"\u0FB2\u0F80",
- "\u0F78"=>"\u0FB3\u0F80",
- "\u0F81"=>"\u0F71\u0F80",
- "\u0F93"=>"\u0F92\u0FB7",
- "\u0F9D"=>"\u0F9C\u0FB7",
- "\u0FA2"=>"\u0FA1\u0FB7",
- "\u0FA7"=>"\u0FA6\u0FB7",
- "\u0FAC"=>"\u0FAB\u0FB7",
- "\u0FB9"=>"\u0F90\u0FB5",
- "\u1026"=>"\u1025\u102E",
- "\u1B06"=>"\u1B05\u1B35",
- "\u1B08"=>"\u1B07\u1B35",
- "\u1B0A"=>"\u1B09\u1B35",
- "\u1B0C"=>"\u1B0B\u1B35",
- "\u1B0E"=>"\u1B0D\u1B35",
- "\u1B12"=>"\u1B11\u1B35",
- "\u1B3B"=>"\u1B3A\u1B35",
- "\u1B3D"=>"\u1B3C\u1B35",
- "\u1B40"=>"\u1B3E\u1B35",
- "\u1B41"=>"\u1B3F\u1B35",
- "\u1B43"=>"\u1B42\u1B35",
- "\u1E00"=>"A\u0325",
- "\u1E01"=>"a\u0325",
- "\u1E02"=>"B\u0307",
- "\u1E03"=>"b\u0307",
- "\u1E04"=>"B\u0323",
- "\u1E05"=>"b\u0323",
- "\u1E06"=>"B\u0331",
- "\u1E07"=>"b\u0331",
- "\u1E08"=>"C\u0327\u0301",
- "\u1E09"=>"c\u0327\u0301",
- "\u1E0A"=>"D\u0307",
- "\u1E0B"=>"d\u0307",
- "\u1E0C"=>"D\u0323",
- "\u1E0D"=>"d\u0323",
- "\u1E0E"=>"D\u0331",
- "\u1E0F"=>"d\u0331",
- "\u1E10"=>"D\u0327",
- "\u1E11"=>"d\u0327",
- "\u1E12"=>"D\u032D",
- "\u1E13"=>"d\u032D",
- "\u1E14"=>"E\u0304\u0300",
- "\u1E15"=>"e\u0304\u0300",
- "\u1E16"=>"E\u0304\u0301",
- "\u1E17"=>"e\u0304\u0301",
- "\u1E18"=>"E\u032D",
- "\u1E19"=>"e\u032D",
- "\u1E1A"=>"E\u0330",
- "\u1E1B"=>"e\u0330",
- "\u1E1C"=>"E\u0327\u0306",
- "\u1E1D"=>"e\u0327\u0306",
- "\u1E1E"=>"F\u0307",
- "\u1E1F"=>"f\u0307",
- "\u1E20"=>"G\u0304",
- "\u1E21"=>"g\u0304",
- "\u1E22"=>"H\u0307",
- "\u1E23"=>"h\u0307",
- "\u1E24"=>"H\u0323",
- "\u1E25"=>"h\u0323",
- "\u1E26"=>"H\u0308",
- "\u1E27"=>"h\u0308",
- "\u1E28"=>"H\u0327",
- "\u1E29"=>"h\u0327",
- "\u1E2A"=>"H\u032E",
- "\u1E2B"=>"h\u032E",
- "\u1E2C"=>"I\u0330",
- "\u1E2D"=>"i\u0330",
- "\u1E2E"=>"I\u0308\u0301",
- "\u1E2F"=>"i\u0308\u0301",
- "\u1E30"=>"K\u0301",
- "\u1E31"=>"k\u0301",
- "\u1E32"=>"K\u0323",
- "\u1E33"=>"k\u0323",
- "\u1E34"=>"K\u0331",
- "\u1E35"=>"k\u0331",
- "\u1E36"=>"L\u0323",
- "\u1E37"=>"l\u0323",
- "\u1E38"=>"L\u0323\u0304",
- "\u1E39"=>"l\u0323\u0304",
- "\u1E3A"=>"L\u0331",
- "\u1E3B"=>"l\u0331",
- "\u1E3C"=>"L\u032D",
- "\u1E3D"=>"l\u032D",
- "\u1E3E"=>"M\u0301",
- "\u1E3F"=>"m\u0301",
- "\u1E40"=>"M\u0307",
- "\u1E41"=>"m\u0307",
- "\u1E42"=>"M\u0323",
- "\u1E43"=>"m\u0323",
- "\u1E44"=>"N\u0307",
- "\u1E45"=>"n\u0307",
- "\u1E46"=>"N\u0323",
- "\u1E47"=>"n\u0323",
- "\u1E48"=>"N\u0331",
- "\u1E49"=>"n\u0331",
- "\u1E4A"=>"N\u032D",
- "\u1E4B"=>"n\u032D",
- "\u1E4C"=>"O\u0303\u0301",
- "\u1E4D"=>"o\u0303\u0301",
- "\u1E4E"=>"O\u0303\u0308",
- "\u1E4F"=>"o\u0303\u0308",
- "\u1E50"=>"O\u0304\u0300",
- "\u1E51"=>"o\u0304\u0300",
- "\u1E52"=>"O\u0304\u0301",
- "\u1E53"=>"o\u0304\u0301",
- "\u1E54"=>"P\u0301",
- "\u1E55"=>"p\u0301",
- "\u1E56"=>"P\u0307",
- "\u1E57"=>"p\u0307",
- "\u1E58"=>"R\u0307",
- "\u1E59"=>"r\u0307",
- "\u1E5A"=>"R\u0323",
- "\u1E5B"=>"r\u0323",
- "\u1E5C"=>"R\u0323\u0304",
- "\u1E5D"=>"r\u0323\u0304",
- "\u1E5E"=>"R\u0331",
- "\u1E5F"=>"r\u0331",
- "\u1E60"=>"S\u0307",
- "\u1E61"=>"s\u0307",
- "\u1E62"=>"S\u0323",
- "\u1E63"=>"s\u0323",
- "\u1E64"=>"S\u0301\u0307",
- "\u1E65"=>"s\u0301\u0307",
- "\u1E66"=>"S\u030C\u0307",
- "\u1E67"=>"s\u030C\u0307",
- "\u1E68"=>"S\u0323\u0307",
- "\u1E69"=>"s\u0323\u0307",
- "\u1E6A"=>"T\u0307",
- "\u1E6B"=>"t\u0307",
- "\u1E6C"=>"T\u0323",
- "\u1E6D"=>"t\u0323",
- "\u1E6E"=>"T\u0331",
- "\u1E6F"=>"t\u0331",
- "\u1E70"=>"T\u032D",
- "\u1E71"=>"t\u032D",
- "\u1E72"=>"U\u0324",
- "\u1E73"=>"u\u0324",
- "\u1E74"=>"U\u0330",
- "\u1E75"=>"u\u0330",
- "\u1E76"=>"U\u032D",
- "\u1E77"=>"u\u032D",
- "\u1E78"=>"U\u0303\u0301",
- "\u1E79"=>"u\u0303\u0301",
- "\u1E7A"=>"U\u0304\u0308",
- "\u1E7B"=>"u\u0304\u0308",
- "\u1E7C"=>"V\u0303",
- "\u1E7D"=>"v\u0303",
- "\u1E7E"=>"V\u0323",
- "\u1E7F"=>"v\u0323",
- "\u1E80"=>"W\u0300",
- "\u1E81"=>"w\u0300",
- "\u1E82"=>"W\u0301",
- "\u1E83"=>"w\u0301",
- "\u1E84"=>"W\u0308",
- "\u1E85"=>"w\u0308",
- "\u1E86"=>"W\u0307",
- "\u1E87"=>"w\u0307",
- "\u1E88"=>"W\u0323",
- "\u1E89"=>"w\u0323",
- "\u1E8A"=>"X\u0307",
- "\u1E8B"=>"x\u0307",
- "\u1E8C"=>"X\u0308",
- "\u1E8D"=>"x\u0308",
- "\u1E8E"=>"Y\u0307",
- "\u1E8F"=>"y\u0307",
- "\u1E90"=>"Z\u0302",
- "\u1E91"=>"z\u0302",
- "\u1E92"=>"Z\u0323",
- "\u1E93"=>"z\u0323",
- "\u1E94"=>"Z\u0331",
- "\u1E95"=>"z\u0331",
- "\u1E96"=>"h\u0331",
- "\u1E97"=>"t\u0308",
- "\u1E98"=>"w\u030A",
- "\u1E99"=>"y\u030A",
- "\u1E9B"=>"\u017F\u0307",
- "\u1EA0"=>"A\u0323",
- "\u1EA1"=>"a\u0323",
- "\u1EA2"=>"A\u0309",
- "\u1EA3"=>"a\u0309",
- "\u1EA4"=>"A\u0302\u0301",
- "\u1EA5"=>"a\u0302\u0301",
- "\u1EA6"=>"A\u0302\u0300",
- "\u1EA7"=>"a\u0302\u0300",
- "\u1EA8"=>"A\u0302\u0309",
- "\u1EA9"=>"a\u0302\u0309",
- "\u1EAA"=>"A\u0302\u0303",
- "\u1EAB"=>"a\u0302\u0303",
- "\u1EAC"=>"A\u0323\u0302",
- "\u1EAD"=>"a\u0323\u0302",
- "\u1EAE"=>"A\u0306\u0301",
- "\u1EAF"=>"a\u0306\u0301",
- "\u1EB0"=>"A\u0306\u0300",
- "\u1EB1"=>"a\u0306\u0300",
- "\u1EB2"=>"A\u0306\u0309",
- "\u1EB3"=>"a\u0306\u0309",
- "\u1EB4"=>"A\u0306\u0303",
- "\u1EB5"=>"a\u0306\u0303",
- "\u1EB6"=>"A\u0323\u0306",
- "\u1EB7"=>"a\u0323\u0306",
- "\u1EB8"=>"E\u0323",
- "\u1EB9"=>"e\u0323",
- "\u1EBA"=>"E\u0309",
- "\u1EBB"=>"e\u0309",
- "\u1EBC"=>"E\u0303",
- "\u1EBD"=>"e\u0303",
- "\u1EBE"=>"E\u0302\u0301",
- "\u1EBF"=>"e\u0302\u0301",
- "\u1EC0"=>"E\u0302\u0300",
- "\u1EC1"=>"e\u0302\u0300",
- "\u1EC2"=>"E\u0302\u0309",
- "\u1EC3"=>"e\u0302\u0309",
- "\u1EC4"=>"E\u0302\u0303",
- "\u1EC5"=>"e\u0302\u0303",
- "\u1EC6"=>"E\u0323\u0302",
- "\u1EC7"=>"e\u0323\u0302",
- "\u1EC8"=>"I\u0309",
- "\u1EC9"=>"i\u0309",
- "\u1ECA"=>"I\u0323",
- "\u1ECB"=>"i\u0323",
- "\u1ECC"=>"O\u0323",
- "\u1ECD"=>"o\u0323",
- "\u1ECE"=>"O\u0309",
- "\u1ECF"=>"o\u0309",
- "\u1ED0"=>"O\u0302\u0301",
- "\u1ED1"=>"o\u0302\u0301",
- "\u1ED2"=>"O\u0302\u0300",
- "\u1ED3"=>"o\u0302\u0300",
- "\u1ED4"=>"O\u0302\u0309",
- "\u1ED5"=>"o\u0302\u0309",
- "\u1ED6"=>"O\u0302\u0303",
- "\u1ED7"=>"o\u0302\u0303",
- "\u1ED8"=>"O\u0323\u0302",
- "\u1ED9"=>"o\u0323\u0302",
- "\u1EDA"=>"O\u031B\u0301",
- "\u1EDB"=>"o\u031B\u0301",
- "\u1EDC"=>"O\u031B\u0300",
- "\u1EDD"=>"o\u031B\u0300",
- "\u1EDE"=>"O\u031B\u0309",
- "\u1EDF"=>"o\u031B\u0309",
- "\u1EE0"=>"O\u031B\u0303",
- "\u1EE1"=>"o\u031B\u0303",
- "\u1EE2"=>"O\u031B\u0323",
- "\u1EE3"=>"o\u031B\u0323",
- "\u1EE4"=>"U\u0323",
- "\u1EE5"=>"u\u0323",
- "\u1EE6"=>"U\u0309",
- "\u1EE7"=>"u\u0309",
- "\u1EE8"=>"U\u031B\u0301",
- "\u1EE9"=>"u\u031B\u0301",
- "\u1EEA"=>"U\u031B\u0300",
- "\u1EEB"=>"u\u031B\u0300",
- "\u1EEC"=>"U\u031B\u0309",
- "\u1EED"=>"u\u031B\u0309",
- "\u1EEE"=>"U\u031B\u0303",
- "\u1EEF"=>"u\u031B\u0303",
- "\u1EF0"=>"U\u031B\u0323",
- "\u1EF1"=>"u\u031B\u0323",
- "\u1EF2"=>"Y\u0300",
- "\u1EF3"=>"y\u0300",
- "\u1EF4"=>"Y\u0323",
- "\u1EF5"=>"y\u0323",
- "\u1EF6"=>"Y\u0309",
- "\u1EF7"=>"y\u0309",
- "\u1EF8"=>"Y\u0303",
- "\u1EF9"=>"y\u0303",
- "\u1F00"=>"\u03B1\u0313",
- "\u1F01"=>"\u03B1\u0314",
- "\u1F02"=>"\u03B1\u0313\u0300",
- "\u1F03"=>"\u03B1\u0314\u0300",
- "\u1F04"=>"\u03B1\u0313\u0301",
- "\u1F05"=>"\u03B1\u0314\u0301",
- "\u1F06"=>"\u03B1\u0313\u0342",
- "\u1F07"=>"\u03B1\u0314\u0342",
- "\u1F08"=>"\u0391\u0313",
- "\u1F09"=>"\u0391\u0314",
- "\u1F0A"=>"\u0391\u0313\u0300",
- "\u1F0B"=>"\u0391\u0314\u0300",
- "\u1F0C"=>"\u0391\u0313\u0301",
- "\u1F0D"=>"\u0391\u0314\u0301",
- "\u1F0E"=>"\u0391\u0313\u0342",
- "\u1F0F"=>"\u0391\u0314\u0342",
- "\u1F10"=>"\u03B5\u0313",
- "\u1F11"=>"\u03B5\u0314",
- "\u1F12"=>"\u03B5\u0313\u0300",
- "\u1F13"=>"\u03B5\u0314\u0300",
- "\u1F14"=>"\u03B5\u0313\u0301",
- "\u1F15"=>"\u03B5\u0314\u0301",
- "\u1F18"=>"\u0395\u0313",
- "\u1F19"=>"\u0395\u0314",
- "\u1F1A"=>"\u0395\u0313\u0300",
- "\u1F1B"=>"\u0395\u0314\u0300",
- "\u1F1C"=>"\u0395\u0313\u0301",
- "\u1F1D"=>"\u0395\u0314\u0301",
- "\u1F20"=>"\u03B7\u0313",
- "\u1F21"=>"\u03B7\u0314",
- "\u1F22"=>"\u03B7\u0313\u0300",
- "\u1F23"=>"\u03B7\u0314\u0300",
- "\u1F24"=>"\u03B7\u0313\u0301",
- "\u1F25"=>"\u03B7\u0314\u0301",
- "\u1F26"=>"\u03B7\u0313\u0342",
- "\u1F27"=>"\u03B7\u0314\u0342",
- "\u1F28"=>"\u0397\u0313",
- "\u1F29"=>"\u0397\u0314",
- "\u1F2A"=>"\u0397\u0313\u0300",
- "\u1F2B"=>"\u0397\u0314\u0300",
- "\u1F2C"=>"\u0397\u0313\u0301",
- "\u1F2D"=>"\u0397\u0314\u0301",
- "\u1F2E"=>"\u0397\u0313\u0342",
- "\u1F2F"=>"\u0397\u0314\u0342",
- "\u1F30"=>"\u03B9\u0313",
- "\u1F31"=>"\u03B9\u0314",
- "\u1F32"=>"\u03B9\u0313\u0300",
- "\u1F33"=>"\u03B9\u0314\u0300",
- "\u1F34"=>"\u03B9\u0313\u0301",
- "\u1F35"=>"\u03B9\u0314\u0301",
- "\u1F36"=>"\u03B9\u0313\u0342",
- "\u1F37"=>"\u03B9\u0314\u0342",
- "\u1F38"=>"\u0399\u0313",
- "\u1F39"=>"\u0399\u0314",
- "\u1F3A"=>"\u0399\u0313\u0300",
- "\u1F3B"=>"\u0399\u0314\u0300",
- "\u1F3C"=>"\u0399\u0313\u0301",
- "\u1F3D"=>"\u0399\u0314\u0301",
- "\u1F3E"=>"\u0399\u0313\u0342",
- "\u1F3F"=>"\u0399\u0314\u0342",
- "\u1F40"=>"\u03BF\u0313",
- "\u1F41"=>"\u03BF\u0314",
- "\u1F42"=>"\u03BF\u0313\u0300",
- "\u1F43"=>"\u03BF\u0314\u0300",
- "\u1F44"=>"\u03BF\u0313\u0301",
- "\u1F45"=>"\u03BF\u0314\u0301",
- "\u1F48"=>"\u039F\u0313",
- "\u1F49"=>"\u039F\u0314",
- "\u1F4A"=>"\u039F\u0313\u0300",
- "\u1F4B"=>"\u039F\u0314\u0300",
- "\u1F4C"=>"\u039F\u0313\u0301",
- "\u1F4D"=>"\u039F\u0314\u0301",
- "\u1F50"=>"\u03C5\u0313",
- "\u1F51"=>"\u03C5\u0314",
- "\u1F52"=>"\u03C5\u0313\u0300",
- "\u1F53"=>"\u03C5\u0314\u0300",
- "\u1F54"=>"\u03C5\u0313\u0301",
- "\u1F55"=>"\u03C5\u0314\u0301",
- "\u1F56"=>"\u03C5\u0313\u0342",
- "\u1F57"=>"\u03C5\u0314\u0342",
- "\u1F59"=>"\u03A5\u0314",
- "\u1F5B"=>"\u03A5\u0314\u0300",
- "\u1F5D"=>"\u03A5\u0314\u0301",
- "\u1F5F"=>"\u03A5\u0314\u0342",
- "\u1F60"=>"\u03C9\u0313",
- "\u1F61"=>"\u03C9\u0314",
- "\u1F62"=>"\u03C9\u0313\u0300",
- "\u1F63"=>"\u03C9\u0314\u0300",
- "\u1F64"=>"\u03C9\u0313\u0301",
- "\u1F65"=>"\u03C9\u0314\u0301",
- "\u1F66"=>"\u03C9\u0313\u0342",
- "\u1F67"=>"\u03C9\u0314\u0342",
- "\u1F68"=>"\u03A9\u0313",
- "\u1F69"=>"\u03A9\u0314",
- "\u1F6A"=>"\u03A9\u0313\u0300",
- "\u1F6B"=>"\u03A9\u0314\u0300",
- "\u1F6C"=>"\u03A9\u0313\u0301",
- "\u1F6D"=>"\u03A9\u0314\u0301",
- "\u1F6E"=>"\u03A9\u0313\u0342",
- "\u1F6F"=>"\u03A9\u0314\u0342",
- "\u1F70"=>"\u03B1\u0300",
- "\u1F71"=>"\u03B1\u0301",
- "\u1F72"=>"\u03B5\u0300",
- "\u1F73"=>"\u03B5\u0301",
- "\u1F74"=>"\u03B7\u0300",
- "\u1F75"=>"\u03B7\u0301",
- "\u1F76"=>"\u03B9\u0300",
- "\u1F77"=>"\u03B9\u0301",
- "\u1F78"=>"\u03BF\u0300",
- "\u1F79"=>"\u03BF\u0301",
- "\u1F7A"=>"\u03C5\u0300",
- "\u1F7B"=>"\u03C5\u0301",
- "\u1F7C"=>"\u03C9\u0300",
- "\u1F7D"=>"\u03C9\u0301",
- "\u1F80"=>"\u03B1\u0313\u0345",
- "\u1F81"=>"\u03B1\u0314\u0345",
- "\u1F82"=>"\u03B1\u0313\u0300\u0345",
- "\u1F83"=>"\u03B1\u0314\u0300\u0345",
- "\u1F84"=>"\u03B1\u0313\u0301\u0345",
- "\u1F85"=>"\u03B1\u0314\u0301\u0345",
- "\u1F86"=>"\u03B1\u0313\u0342\u0345",
- "\u1F87"=>"\u03B1\u0314\u0342\u0345",
- "\u1F88"=>"\u0391\u0313\u0345",
- "\u1F89"=>"\u0391\u0314\u0345",
- "\u1F8A"=>"\u0391\u0313\u0300\u0345",
- "\u1F8B"=>"\u0391\u0314\u0300\u0345",
- "\u1F8C"=>"\u0391\u0313\u0301\u0345",
- "\u1F8D"=>"\u0391\u0314\u0301\u0345",
- "\u1F8E"=>"\u0391\u0313\u0342\u0345",
- "\u1F8F"=>"\u0391\u0314\u0342\u0345",
- "\u1F90"=>"\u03B7\u0313\u0345",
- "\u1F91"=>"\u03B7\u0314\u0345",
- "\u1F92"=>"\u03B7\u0313\u0300\u0345",
- "\u1F93"=>"\u03B7\u0314\u0300\u0345",
- "\u1F94"=>"\u03B7\u0313\u0301\u0345",
- "\u1F95"=>"\u03B7\u0314\u0301\u0345",
- "\u1F96"=>"\u03B7\u0313\u0342\u0345",
- "\u1F97"=>"\u03B7\u0314\u0342\u0345",
- "\u1F98"=>"\u0397\u0313\u0345",
- "\u1F99"=>"\u0397\u0314\u0345",
- "\u1F9A"=>"\u0397\u0313\u0300\u0345",
- "\u1F9B"=>"\u0397\u0314\u0300\u0345",
- "\u1F9C"=>"\u0397\u0313\u0301\u0345",
- "\u1F9D"=>"\u0397\u0314\u0301\u0345",
- "\u1F9E"=>"\u0397\u0313\u0342\u0345",
- "\u1F9F"=>"\u0397\u0314\u0342\u0345",
- "\u1FA0"=>"\u03C9\u0313\u0345",
- "\u1FA1"=>"\u03C9\u0314\u0345",
- "\u1FA2"=>"\u03C9\u0313\u0300\u0345",
- "\u1FA3"=>"\u03C9\u0314\u0300\u0345",
- "\u1FA4"=>"\u03C9\u0313\u0301\u0345",
- "\u1FA5"=>"\u03C9\u0314\u0301\u0345",
- "\u1FA6"=>"\u03C9\u0313\u0342\u0345",
- "\u1FA7"=>"\u03C9\u0314\u0342\u0345",
- "\u1FA8"=>"\u03A9\u0313\u0345",
- "\u1FA9"=>"\u03A9\u0314\u0345",
- "\u1FAA"=>"\u03A9\u0313\u0300\u0345",
- "\u1FAB"=>"\u03A9\u0314\u0300\u0345",
- "\u1FAC"=>"\u03A9\u0313\u0301\u0345",
- "\u1FAD"=>"\u03A9\u0314\u0301\u0345",
- "\u1FAE"=>"\u03A9\u0313\u0342\u0345",
- "\u1FAF"=>"\u03A9\u0314\u0342\u0345",
- "\u1FB0"=>"\u03B1\u0306",
- "\u1FB1"=>"\u03B1\u0304",
- "\u1FB2"=>"\u03B1\u0300\u0345",
- "\u1FB3"=>"\u03B1\u0345",
- "\u1FB4"=>"\u03B1\u0301\u0345",
- "\u1FB6"=>"\u03B1\u0342",
- "\u1FB7"=>"\u03B1\u0342\u0345",
- "\u1FB8"=>"\u0391\u0306",
- "\u1FB9"=>"\u0391\u0304",
- "\u1FBA"=>"\u0391\u0300",
- "\u1FBB"=>"\u0391\u0301",
- "\u1FBC"=>"\u0391\u0345",
- "\u1FBE"=>"\u03B9",
- "\u1FC1"=>"\u00A8\u0342",
- "\u1FC2"=>"\u03B7\u0300\u0345",
- "\u1FC3"=>"\u03B7\u0345",
- "\u1FC4"=>"\u03B7\u0301\u0345",
- "\u1FC6"=>"\u03B7\u0342",
- "\u1FC7"=>"\u03B7\u0342\u0345",
- "\u1FC8"=>"\u0395\u0300",
- "\u1FC9"=>"\u0395\u0301",
- "\u1FCA"=>"\u0397\u0300",
- "\u1FCB"=>"\u0397\u0301",
- "\u1FCC"=>"\u0397\u0345",
- "\u1FCD"=>"\u1FBF\u0300",
- "\u1FCE"=>"\u1FBF\u0301",
- "\u1FCF"=>"\u1FBF\u0342",
- "\u1FD0"=>"\u03B9\u0306",
- "\u1FD1"=>"\u03B9\u0304",
- "\u1FD2"=>"\u03B9\u0308\u0300",
- "\u1FD3"=>"\u03B9\u0308\u0301",
- "\u1FD6"=>"\u03B9\u0342",
- "\u1FD7"=>"\u03B9\u0308\u0342",
- "\u1FD8"=>"\u0399\u0306",
- "\u1FD9"=>"\u0399\u0304",
- "\u1FDA"=>"\u0399\u0300",
- "\u1FDB"=>"\u0399\u0301",
- "\u1FDD"=>"\u1FFE\u0300",
- "\u1FDE"=>"\u1FFE\u0301",
- "\u1FDF"=>"\u1FFE\u0342",
- "\u1FE0"=>"\u03C5\u0306",
- "\u1FE1"=>"\u03C5\u0304",
- "\u1FE2"=>"\u03C5\u0308\u0300",
- "\u1FE3"=>"\u03C5\u0308\u0301",
- "\u1FE4"=>"\u03C1\u0313",
- "\u1FE5"=>"\u03C1\u0314",
- "\u1FE6"=>"\u03C5\u0342",
- "\u1FE7"=>"\u03C5\u0308\u0342",
- "\u1FE8"=>"\u03A5\u0306",
- "\u1FE9"=>"\u03A5\u0304",
- "\u1FEA"=>"\u03A5\u0300",
- "\u1FEB"=>"\u03A5\u0301",
- "\u1FEC"=>"\u03A1\u0314",
- "\u1FED"=>"\u00A8\u0300",
- "\u1FEE"=>"\u00A8\u0301",
- "\u1FEF"=>"`",
- "\u1FF2"=>"\u03C9\u0300\u0345",
- "\u1FF3"=>"\u03C9\u0345",
- "\u1FF4"=>"\u03C9\u0301\u0345",
- "\u1FF6"=>"\u03C9\u0342",
- "\u1FF7"=>"\u03C9\u0342\u0345",
- "\u1FF8"=>"\u039F\u0300",
- "\u1FF9"=>"\u039F\u0301",
- "\u1FFA"=>"\u03A9\u0300",
- "\u1FFB"=>"\u03A9\u0301",
- "\u1FFC"=>"\u03A9\u0345",
- "\u1FFD"=>"\u00B4",
- "\u2000"=>"\u2002",
- "\u2001"=>"\u2003",
- "\u2126"=>"\u03A9",
- "\u212A"=>"K",
- "\u212B"=>"A\u030A",
- "\u219A"=>"\u2190\u0338",
- "\u219B"=>"\u2192\u0338",
- "\u21AE"=>"\u2194\u0338",
- "\u21CD"=>"\u21D0\u0338",
- "\u21CE"=>"\u21D4\u0338",
- "\u21CF"=>"\u21D2\u0338",
- "\u2204"=>"\u2203\u0338",
- "\u2209"=>"\u2208\u0338",
- "\u220C"=>"\u220B\u0338",
- "\u2224"=>"\u2223\u0338",
- "\u2226"=>"\u2225\u0338",
- "\u2241"=>"\u223C\u0338",
- "\u2244"=>"\u2243\u0338",
- "\u2247"=>"\u2245\u0338",
- "\u2249"=>"\u2248\u0338",
- "\u2260"=>"=\u0338",
- "\u2262"=>"\u2261\u0338",
- "\u226D"=>"\u224D\u0338",
- "\u226E"=>"<\u0338",
- "\u226F"=>">\u0338",
- "\u2270"=>"\u2264\u0338",
- "\u2271"=>"\u2265\u0338",
- "\u2274"=>"\u2272\u0338",
- "\u2275"=>"\u2273\u0338",
- "\u2278"=>"\u2276\u0338",
- "\u2279"=>"\u2277\u0338",
- "\u2280"=>"\u227A\u0338",
- "\u2281"=>"\u227B\u0338",
- "\u2284"=>"\u2282\u0338",
- "\u2285"=>"\u2283\u0338",
- "\u2288"=>"\u2286\u0338",
- "\u2289"=>"\u2287\u0338",
- "\u22AC"=>"\u22A2\u0338",
- "\u22AD"=>"\u22A8\u0338",
- "\u22AE"=>"\u22A9\u0338",
- "\u22AF"=>"\u22AB\u0338",
- "\u22E0"=>"\u227C\u0338",
- "\u22E1"=>"\u227D\u0338",
- "\u22E2"=>"\u2291\u0338",
- "\u22E3"=>"\u2292\u0338",
- "\u22EA"=>"\u22B2\u0338",
- "\u22EB"=>"\u22B3\u0338",
- "\u22EC"=>"\u22B4\u0338",
- "\u22ED"=>"\u22B5\u0338",
- "\u2329"=>"\u3008",
- "\u232A"=>"\u3009",
- "\u2ADC"=>"\u2ADD\u0338",
- "\u304C"=>"\u304B\u3099",
- "\u304E"=>"\u304D\u3099",
- "\u3050"=>"\u304F\u3099",
- "\u3052"=>"\u3051\u3099",
- "\u3054"=>"\u3053\u3099",
- "\u3056"=>"\u3055\u3099",
- "\u3058"=>"\u3057\u3099",
- "\u305A"=>"\u3059\u3099",
- "\u305C"=>"\u305B\u3099",
- "\u305E"=>"\u305D\u3099",
- "\u3060"=>"\u305F\u3099",
- "\u3062"=>"\u3061\u3099",
- "\u3065"=>"\u3064\u3099",
- "\u3067"=>"\u3066\u3099",
- "\u3069"=>"\u3068\u3099",
- "\u3070"=>"\u306F\u3099",
- "\u3071"=>"\u306F\u309A",
- "\u3073"=>"\u3072\u3099",
- "\u3074"=>"\u3072\u309A",
- "\u3076"=>"\u3075\u3099",
- "\u3077"=>"\u3075\u309A",
- "\u3079"=>"\u3078\u3099",
- "\u307A"=>"\u3078\u309A",
- "\u307C"=>"\u307B\u3099",
- "\u307D"=>"\u307B\u309A",
- "\u3094"=>"\u3046\u3099",
- "\u309E"=>"\u309D\u3099",
- "\u30AC"=>"\u30AB\u3099",
- "\u30AE"=>"\u30AD\u3099",
- "\u30B0"=>"\u30AF\u3099",
- "\u30B2"=>"\u30B1\u3099",
- "\u30B4"=>"\u30B3\u3099",
- "\u30B6"=>"\u30B5\u3099",
- "\u30B8"=>"\u30B7\u3099",
- "\u30BA"=>"\u30B9\u3099",
- "\u30BC"=>"\u30BB\u3099",
- "\u30BE"=>"\u30BD\u3099",
- "\u30C0"=>"\u30BF\u3099",
- "\u30C2"=>"\u30C1\u3099",
- "\u30C5"=>"\u30C4\u3099",
- "\u30C7"=>"\u30C6\u3099",
- "\u30C9"=>"\u30C8\u3099",
- "\u30D0"=>"\u30CF\u3099",
- "\u30D1"=>"\u30CF\u309A",
- "\u30D3"=>"\u30D2\u3099",
- "\u30D4"=>"\u30D2\u309A",
- "\u30D6"=>"\u30D5\u3099",
- "\u30D7"=>"\u30D5\u309A",
- "\u30D9"=>"\u30D8\u3099",
- "\u30DA"=>"\u30D8\u309A",
- "\u30DC"=>"\u30DB\u3099",
- "\u30DD"=>"\u30DB\u309A",
- "\u30F4"=>"\u30A6\u3099",
- "\u30F7"=>"\u30EF\u3099",
- "\u30F8"=>"\u30F0\u3099",
- "\u30F9"=>"\u30F1\u3099",
- "\u30FA"=>"\u30F2\u3099",
- "\u30FE"=>"\u30FD\u3099",
- "\uF900"=>"\u8C48",
- "\uF901"=>"\u66F4",
- "\uF902"=>"\u8ECA",
- "\uF903"=>"\u8CC8",
- "\uF904"=>"\u6ED1",
- "\uF905"=>"\u4E32",
- "\uF906"=>"\u53E5",
- "\uF907"=>"\u9F9C",
- "\uF908"=>"\u9F9C",
- "\uF909"=>"\u5951",
- "\uF90A"=>"\u91D1",
- "\uF90B"=>"\u5587",
- "\uF90C"=>"\u5948",
- "\uF90D"=>"\u61F6",
- "\uF90E"=>"\u7669",
- "\uF90F"=>"\u7F85",
- "\uF910"=>"\u863F",
- "\uF911"=>"\u87BA",
- "\uF912"=>"\u88F8",
- "\uF913"=>"\u908F",
- "\uF914"=>"\u6A02",
- "\uF915"=>"\u6D1B",
- "\uF916"=>"\u70D9",
- "\uF917"=>"\u73DE",
- "\uF918"=>"\u843D",
- "\uF919"=>"\u916A",
- "\uF91A"=>"\u99F1",
- "\uF91B"=>"\u4E82",
- "\uF91C"=>"\u5375",
- "\uF91D"=>"\u6B04",
- "\uF91E"=>"\u721B",
- "\uF91F"=>"\u862D",
- "\uF920"=>"\u9E1E",
- "\uF921"=>"\u5D50",
- "\uF922"=>"\u6FEB",
- "\uF923"=>"\u85CD",
- "\uF924"=>"\u8964",
- "\uF925"=>"\u62C9",
- "\uF926"=>"\u81D8",
- "\uF927"=>"\u881F",
- "\uF928"=>"\u5ECA",
- "\uF929"=>"\u6717",
- "\uF92A"=>"\u6D6A",
- "\uF92B"=>"\u72FC",
- "\uF92C"=>"\u90CE",
- "\uF92D"=>"\u4F86",
- "\uF92E"=>"\u51B7",
- "\uF92F"=>"\u52DE",
- "\uF930"=>"\u64C4",
- "\uF931"=>"\u6AD3",
- "\uF932"=>"\u7210",
- "\uF933"=>"\u76E7",
- "\uF934"=>"\u8001",
- "\uF935"=>"\u8606",
- "\uF936"=>"\u865C",
- "\uF937"=>"\u8DEF",
- "\uF938"=>"\u9732",
- "\uF939"=>"\u9B6F",
- "\uF93A"=>"\u9DFA",
- "\uF93B"=>"\u788C",
- "\uF93C"=>"\u797F",
- "\uF93D"=>"\u7DA0",
- "\uF93E"=>"\u83C9",
- "\uF93F"=>"\u9304",
- "\uF940"=>"\u9E7F",
- "\uF941"=>"\u8AD6",
- "\uF942"=>"\u58DF",
- "\uF943"=>"\u5F04",
- "\uF944"=>"\u7C60",
- "\uF945"=>"\u807E",
- "\uF946"=>"\u7262",
- "\uF947"=>"\u78CA",
- "\uF948"=>"\u8CC2",
- "\uF949"=>"\u96F7",
- "\uF94A"=>"\u58D8",
- "\uF94B"=>"\u5C62",
- "\uF94C"=>"\u6A13",
- "\uF94D"=>"\u6DDA",
- "\uF94E"=>"\u6F0F",
- "\uF94F"=>"\u7D2F",
- "\uF950"=>"\u7E37",
- "\uF951"=>"\u964B",
- "\uF952"=>"\u52D2",
- "\uF953"=>"\u808B",
- "\uF954"=>"\u51DC",
- "\uF955"=>"\u51CC",
- "\uF956"=>"\u7A1C",
- "\uF957"=>"\u7DBE",
- "\uF958"=>"\u83F1",
- "\uF959"=>"\u9675",
- "\uF95A"=>"\u8B80",
- "\uF95B"=>"\u62CF",
- "\uF95C"=>"\u6A02",
- "\uF95D"=>"\u8AFE",
- "\uF95E"=>"\u4E39",
- "\uF95F"=>"\u5BE7",
- "\uF960"=>"\u6012",
- "\uF961"=>"\u7387",
- "\uF962"=>"\u7570",
- "\uF963"=>"\u5317",
- "\uF964"=>"\u78FB",
- "\uF965"=>"\u4FBF",
- "\uF966"=>"\u5FA9",
- "\uF967"=>"\u4E0D",
- "\uF968"=>"\u6CCC",
- "\uF969"=>"\u6578",
- "\uF96A"=>"\u7D22",
- "\uF96B"=>"\u53C3",
- "\uF96C"=>"\u585E",
- "\uF96D"=>"\u7701",
- "\uF96E"=>"\u8449",
- "\uF96F"=>"\u8AAA",
- "\uF970"=>"\u6BBA",
- "\uF971"=>"\u8FB0",
- "\uF972"=>"\u6C88",
- "\uF973"=>"\u62FE",
- "\uF974"=>"\u82E5",
- "\uF975"=>"\u63A0",
- "\uF976"=>"\u7565",
- "\uF977"=>"\u4EAE",
- "\uF978"=>"\u5169",
- "\uF979"=>"\u51C9",
- "\uF97A"=>"\u6881",
- "\uF97B"=>"\u7CE7",
- "\uF97C"=>"\u826F",
- "\uF97D"=>"\u8AD2",
- "\uF97E"=>"\u91CF",
- "\uF97F"=>"\u52F5",
- "\uF980"=>"\u5442",
- "\uF981"=>"\u5973",
- "\uF982"=>"\u5EEC",
- "\uF983"=>"\u65C5",
- "\uF984"=>"\u6FFE",
- "\uF985"=>"\u792A",
- "\uF986"=>"\u95AD",
- "\uF987"=>"\u9A6A",
- "\uF988"=>"\u9E97",
- "\uF989"=>"\u9ECE",
- "\uF98A"=>"\u529B",
- "\uF98B"=>"\u66C6",
- "\uF98C"=>"\u6B77",
- "\uF98D"=>"\u8F62",
- "\uF98E"=>"\u5E74",
- "\uF98F"=>"\u6190",
- "\uF990"=>"\u6200",
- "\uF991"=>"\u649A",
- "\uF992"=>"\u6F23",
- "\uF993"=>"\u7149",
- "\uF994"=>"\u7489",
- "\uF995"=>"\u79CA",
- "\uF996"=>"\u7DF4",
- "\uF997"=>"\u806F",
- "\uF998"=>"\u8F26",
- "\uF999"=>"\u84EE",
- "\uF99A"=>"\u9023",
- "\uF99B"=>"\u934A",
- "\uF99C"=>"\u5217",
- "\uF99D"=>"\u52A3",
- "\uF99E"=>"\u54BD",
- "\uF99F"=>"\u70C8",
- "\uF9A0"=>"\u88C2",
- "\uF9A1"=>"\u8AAA",
- "\uF9A2"=>"\u5EC9",
- "\uF9A3"=>"\u5FF5",
- "\uF9A4"=>"\u637B",
- "\uF9A5"=>"\u6BAE",
- "\uF9A6"=>"\u7C3E",
- "\uF9A7"=>"\u7375",
- "\uF9A8"=>"\u4EE4",
- "\uF9A9"=>"\u56F9",
- "\uF9AA"=>"\u5BE7",
- "\uF9AB"=>"\u5DBA",
- "\uF9AC"=>"\u601C",
- "\uF9AD"=>"\u73B2",
- "\uF9AE"=>"\u7469",
- "\uF9AF"=>"\u7F9A",
- "\uF9B0"=>"\u8046",
- "\uF9B1"=>"\u9234",
- "\uF9B2"=>"\u96F6",
- "\uF9B3"=>"\u9748",
- "\uF9B4"=>"\u9818",
- "\uF9B5"=>"\u4F8B",
- "\uF9B6"=>"\u79AE",
- "\uF9B7"=>"\u91B4",
- "\uF9B8"=>"\u96B8",
- "\uF9B9"=>"\u60E1",
- "\uF9BA"=>"\u4E86",
- "\uF9BB"=>"\u50DA",
- "\uF9BC"=>"\u5BEE",
- "\uF9BD"=>"\u5C3F",
- "\uF9BE"=>"\u6599",
- "\uF9BF"=>"\u6A02",
- "\uF9C0"=>"\u71CE",
- "\uF9C1"=>"\u7642",
- "\uF9C2"=>"\u84FC",
- "\uF9C3"=>"\u907C",
- "\uF9C4"=>"\u9F8D",
- "\uF9C5"=>"\u6688",
- "\uF9C6"=>"\u962E",
- "\uF9C7"=>"\u5289",
- "\uF9C8"=>"\u677B",
- "\uF9C9"=>"\u67F3",
- "\uF9CA"=>"\u6D41",
- "\uF9CB"=>"\u6E9C",
- "\uF9CC"=>"\u7409",
- "\uF9CD"=>"\u7559",
- "\uF9CE"=>"\u786B",
- "\uF9CF"=>"\u7D10",
- "\uF9D0"=>"\u985E",
- "\uF9D1"=>"\u516D",
- "\uF9D2"=>"\u622E",
- "\uF9D3"=>"\u9678",
- "\uF9D4"=>"\u502B",
- "\uF9D5"=>"\u5D19",
- "\uF9D6"=>"\u6DEA",
- "\uF9D7"=>"\u8F2A",
- "\uF9D8"=>"\u5F8B",
- "\uF9D9"=>"\u6144",
- "\uF9DA"=>"\u6817",
- "\uF9DB"=>"\u7387",
- "\uF9DC"=>"\u9686",
- "\uF9DD"=>"\u5229",
- "\uF9DE"=>"\u540F",
- "\uF9DF"=>"\u5C65",
- "\uF9E0"=>"\u6613",
- "\uF9E1"=>"\u674E",
- "\uF9E2"=>"\u68A8",
- "\uF9E3"=>"\u6CE5",
- "\uF9E4"=>"\u7406",
- "\uF9E5"=>"\u75E2",
- "\uF9E6"=>"\u7F79",
- "\uF9E7"=>"\u88CF",
- "\uF9E8"=>"\u88E1",
- "\uF9E9"=>"\u91CC",
- "\uF9EA"=>"\u96E2",
- "\uF9EB"=>"\u533F",
- "\uF9EC"=>"\u6EBA",
- "\uF9ED"=>"\u541D",
- "\uF9EE"=>"\u71D0",
- "\uF9EF"=>"\u7498",
- "\uF9F0"=>"\u85FA",
- "\uF9F1"=>"\u96A3",
- "\uF9F2"=>"\u9C57",
- "\uF9F3"=>"\u9E9F",
- "\uF9F4"=>"\u6797",
- "\uF9F5"=>"\u6DCB",
- "\uF9F6"=>"\u81E8",
- "\uF9F7"=>"\u7ACB",
- "\uF9F8"=>"\u7B20",
- "\uF9F9"=>"\u7C92",
- "\uF9FA"=>"\u72C0",
- "\uF9FB"=>"\u7099",
- "\uF9FC"=>"\u8B58",
- "\uF9FD"=>"\u4EC0",
- "\uF9FE"=>"\u8336",
- "\uF9FF"=>"\u523A",
- "\uFA00"=>"\u5207",
- "\uFA01"=>"\u5EA6",
- "\uFA02"=>"\u62D3",
- "\uFA03"=>"\u7CD6",
- "\uFA04"=>"\u5B85",
- "\uFA05"=>"\u6D1E",
- "\uFA06"=>"\u66B4",
- "\uFA07"=>"\u8F3B",
- "\uFA08"=>"\u884C",
- "\uFA09"=>"\u964D",
- "\uFA0A"=>"\u898B",
- "\uFA0B"=>"\u5ED3",
- "\uFA0C"=>"\u5140",
- "\uFA0D"=>"\u55C0",
- "\uFA10"=>"\u585A",
- "\uFA12"=>"\u6674",
- "\uFA15"=>"\u51DE",
- "\uFA16"=>"\u732A",
- "\uFA17"=>"\u76CA",
- "\uFA18"=>"\u793C",
- "\uFA19"=>"\u795E",
- "\uFA1A"=>"\u7965",
- "\uFA1B"=>"\u798F",
- "\uFA1C"=>"\u9756",
- "\uFA1D"=>"\u7CBE",
- "\uFA1E"=>"\u7FBD",
- "\uFA20"=>"\u8612",
- "\uFA22"=>"\u8AF8",
- "\uFA25"=>"\u9038",
- "\uFA26"=>"\u90FD",
- "\uFA2A"=>"\u98EF",
- "\uFA2B"=>"\u98FC",
- "\uFA2C"=>"\u9928",
- "\uFA2D"=>"\u9DB4",
- "\uFA2E"=>"\u90DE",
- "\uFA2F"=>"\u96B7",
- "\uFA30"=>"\u4FAE",
- "\uFA31"=>"\u50E7",
- "\uFA32"=>"\u514D",
- "\uFA33"=>"\u52C9",
- "\uFA34"=>"\u52E4",
- "\uFA35"=>"\u5351",
- "\uFA36"=>"\u559D",
- "\uFA37"=>"\u5606",
- "\uFA38"=>"\u5668",
- "\uFA39"=>"\u5840",
- "\uFA3A"=>"\u58A8",
- "\uFA3B"=>"\u5C64",
- "\uFA3C"=>"\u5C6E",
- "\uFA3D"=>"\u6094",
- "\uFA3E"=>"\u6168",
- "\uFA3F"=>"\u618E",
- "\uFA40"=>"\u61F2",
- "\uFA41"=>"\u654F",
- "\uFA42"=>"\u65E2",
- "\uFA43"=>"\u6691",
- "\uFA44"=>"\u6885",
- "\uFA45"=>"\u6D77",
- "\uFA46"=>"\u6E1A",
- "\uFA47"=>"\u6F22",
- "\uFA48"=>"\u716E",
- "\uFA49"=>"\u722B",
- "\uFA4A"=>"\u7422",
- "\uFA4B"=>"\u7891",
- "\uFA4C"=>"\u793E",
- "\uFA4D"=>"\u7949",
- "\uFA4E"=>"\u7948",
- "\uFA4F"=>"\u7950",
- "\uFA50"=>"\u7956",
- "\uFA51"=>"\u795D",
- "\uFA52"=>"\u798D",
- "\uFA53"=>"\u798E",
- "\uFA54"=>"\u7A40",
- "\uFA55"=>"\u7A81",
- "\uFA56"=>"\u7BC0",
- "\uFA57"=>"\u7DF4",
- "\uFA58"=>"\u7E09",
- "\uFA59"=>"\u7E41",
- "\uFA5A"=>"\u7F72",
- "\uFA5B"=>"\u8005",
- "\uFA5C"=>"\u81ED",
- "\uFA5D"=>"\u8279",
- "\uFA5E"=>"\u8279",
- "\uFA5F"=>"\u8457",
- "\uFA60"=>"\u8910",
- "\uFA61"=>"\u8996",
- "\uFA62"=>"\u8B01",
- "\uFA63"=>"\u8B39",
- "\uFA64"=>"\u8CD3",
- "\uFA65"=>"\u8D08",
- "\uFA66"=>"\u8FB6",
- "\uFA67"=>"\u9038",
- "\uFA68"=>"\u96E3",
- "\uFA69"=>"\u97FF",
- "\uFA6A"=>"\u983B",
- "\uFA6B"=>"\u6075",
- "\uFA6C"=>"\u{242EE}",
- "\uFA6D"=>"\u8218",
- "\uFA70"=>"\u4E26",
- "\uFA71"=>"\u51B5",
- "\uFA72"=>"\u5168",
- "\uFA73"=>"\u4F80",
- "\uFA74"=>"\u5145",
- "\uFA75"=>"\u5180",
- "\uFA76"=>"\u52C7",
- "\uFA77"=>"\u52FA",
- "\uFA78"=>"\u559D",
- "\uFA79"=>"\u5555",
- "\uFA7A"=>"\u5599",
- "\uFA7B"=>"\u55E2",
- "\uFA7C"=>"\u585A",
- "\uFA7D"=>"\u58B3",
- "\uFA7E"=>"\u5944",
- "\uFA7F"=>"\u5954",
- "\uFA80"=>"\u5A62",
- "\uFA81"=>"\u5B28",
- "\uFA82"=>"\u5ED2",
- "\uFA83"=>"\u5ED9",
- "\uFA84"=>"\u5F69",
- "\uFA85"=>"\u5FAD",
- "\uFA86"=>"\u60D8",
- "\uFA87"=>"\u614E",
- "\uFA88"=>"\u6108",
- "\uFA89"=>"\u618E",
- "\uFA8A"=>"\u6160",
- "\uFA8B"=>"\u61F2",
- "\uFA8C"=>"\u6234",
- "\uFA8D"=>"\u63C4",
- "\uFA8E"=>"\u641C",
- "\uFA8F"=>"\u6452",
- "\uFA90"=>"\u6556",
- "\uFA91"=>"\u6674",
- "\uFA92"=>"\u6717",
- "\uFA93"=>"\u671B",
- "\uFA94"=>"\u6756",
- "\uFA95"=>"\u6B79",
- "\uFA96"=>"\u6BBA",
- "\uFA97"=>"\u6D41",
- "\uFA98"=>"\u6EDB",
- "\uFA99"=>"\u6ECB",
- "\uFA9A"=>"\u6F22",
- "\uFA9B"=>"\u701E",
- "\uFA9C"=>"\u716E",
- "\uFA9D"=>"\u77A7",
- "\uFA9E"=>"\u7235",
- "\uFA9F"=>"\u72AF",
- "\uFAA0"=>"\u732A",
- "\uFAA1"=>"\u7471",
- "\uFAA2"=>"\u7506",
- "\uFAA3"=>"\u753B",
- "\uFAA4"=>"\u761D",
- "\uFAA5"=>"\u761F",
- "\uFAA6"=>"\u76CA",
- "\uFAA7"=>"\u76DB",
- "\uFAA8"=>"\u76F4",
- "\uFAA9"=>"\u774A",
- "\uFAAA"=>"\u7740",
- "\uFAAB"=>"\u78CC",
- "\uFAAC"=>"\u7AB1",
- "\uFAAD"=>"\u7BC0",
- "\uFAAE"=>"\u7C7B",
- "\uFAAF"=>"\u7D5B",
- "\uFAB0"=>"\u7DF4",
- "\uFAB1"=>"\u7F3E",
- "\uFAB2"=>"\u8005",
- "\uFAB3"=>"\u8352",
- "\uFAB4"=>"\u83EF",
- "\uFAB5"=>"\u8779",
- "\uFAB6"=>"\u8941",
- "\uFAB7"=>"\u8986",
- "\uFAB8"=>"\u8996",
- "\uFAB9"=>"\u8ABF",
- "\uFABA"=>"\u8AF8",
- "\uFABB"=>"\u8ACB",
- "\uFABC"=>"\u8B01",
- "\uFABD"=>"\u8AFE",
- "\uFABE"=>"\u8AED",
- "\uFABF"=>"\u8B39",
- "\uFAC0"=>"\u8B8A",
- "\uFAC1"=>"\u8D08",
- "\uFAC2"=>"\u8F38",
- "\uFAC3"=>"\u9072",
- "\uFAC4"=>"\u9199",
- "\uFAC5"=>"\u9276",
- "\uFAC6"=>"\u967C",
- "\uFAC7"=>"\u96E3",
- "\uFAC8"=>"\u9756",
- "\uFAC9"=>"\u97DB",
- "\uFACA"=>"\u97FF",
- "\uFACB"=>"\u980B",
- "\uFACC"=>"\u983B",
- "\uFACD"=>"\u9B12",
- "\uFACE"=>"\u9F9C",
- "\uFACF"=>"\u{2284A}",
- "\uFAD0"=>"\u{22844}",
- "\uFAD1"=>"\u{233D5}",
- "\uFAD2"=>"\u3B9D",
- "\uFAD3"=>"\u4018",
- "\uFAD4"=>"\u4039",
- "\uFAD5"=>"\u{25249}",
- "\uFAD6"=>"\u{25CD0}",
- "\uFAD7"=>"\u{27ED3}",
- "\uFAD8"=>"\u9F43",
- "\uFAD9"=>"\u9F8E",
- "\uFB1D"=>"\u05D9\u05B4",
- "\uFB1F"=>"\u05F2\u05B7",
- "\uFB2A"=>"\u05E9\u05C1",
- "\uFB2B"=>"\u05E9\u05C2",
- "\uFB2C"=>"\u05E9\u05BC\u05C1",
- "\uFB2D"=>"\u05E9\u05BC\u05C2",
- "\uFB2E"=>"\u05D0\u05B7",
- "\uFB2F"=>"\u05D0\u05B8",
- "\uFB30"=>"\u05D0\u05BC",
- "\uFB31"=>"\u05D1\u05BC",
- "\uFB32"=>"\u05D2\u05BC",
- "\uFB33"=>"\u05D3\u05BC",
- "\uFB34"=>"\u05D4\u05BC",
- "\uFB35"=>"\u05D5\u05BC",
- "\uFB36"=>"\u05D6\u05BC",
- "\uFB38"=>"\u05D8\u05BC",
- "\uFB39"=>"\u05D9\u05BC",
- "\uFB3A"=>"\u05DA\u05BC",
- "\uFB3B"=>"\u05DB\u05BC",
- "\uFB3C"=>"\u05DC\u05BC",
- "\uFB3E"=>"\u05DE\u05BC",
- "\uFB40"=>"\u05E0\u05BC",
- "\uFB41"=>"\u05E1\u05BC",
- "\uFB43"=>"\u05E3\u05BC",
- "\uFB44"=>"\u05E4\u05BC",
- "\uFB46"=>"\u05E6\u05BC",
- "\uFB47"=>"\u05E7\u05BC",
- "\uFB48"=>"\u05E8\u05BC",
- "\uFB49"=>"\u05E9\u05BC",
- "\uFB4A"=>"\u05EA\u05BC",
- "\uFB4B"=>"\u05D5\u05B9",
- "\uFB4C"=>"\u05D1\u05BF",
- "\uFB4D"=>"\u05DB\u05BF",
- "\uFB4E"=>"\u05E4\u05BF",
- "\u{1109A}"=>"\u{11099}\u{110BA}",
- "\u{1109C}"=>"\u{1109B}\u{110BA}",
- "\u{110AB}"=>"\u{110A5}\u{110BA}",
- "\u{1112E}"=>"\u{11131}\u{11127}",
- "\u{1112F}"=>"\u{11132}\u{11127}",
- "\u{1134B}"=>"\u{11347}\u{1133E}",
- "\u{1134C}"=>"\u{11347}\u{11357}",
- "\u{114BB}"=>"\u{114B9}\u{114BA}",
- "\u{114BC}"=>"\u{114B9}\u{114B0}",
- "\u{114BE}"=>"\u{114B9}\u{114BD}",
- "\u{115BA}"=>"\u{115B8}\u{115AF}",
- "\u{115BB}"=>"\u{115B9}\u{115AF}",
- "\u{1D15E}"=>"\u{1D157}\u{1D165}",
- "\u{1D15F}"=>"\u{1D158}\u{1D165}",
- "\u{1D160}"=>"\u{1D158}\u{1D165}\u{1D16E}",
- "\u{1D161}"=>"\u{1D158}\u{1D165}\u{1D16F}",
- "\u{1D162}"=>"\u{1D158}\u{1D165}\u{1D170}",
- "\u{1D163}"=>"\u{1D158}\u{1D165}\u{1D171}",
- "\u{1D164}"=>"\u{1D158}\u{1D165}\u{1D172}",
- "\u{1D1BB}"=>"\u{1D1B9}\u{1D165}",
- "\u{1D1BC}"=>"\u{1D1BA}\u{1D165}",
- "\u{1D1BD}"=>"\u{1D1B9}\u{1D165}\u{1D16E}",
- "\u{1D1BE}"=>"\u{1D1BA}\u{1D165}\u{1D16E}",
- "\u{1D1BF}"=>"\u{1D1B9}\u{1D165}\u{1D16F}",
- "\u{1D1C0}"=>"\u{1D1BA}\u{1D165}\u{1D16F}",
- "\u{2F800}"=>"\u4E3D",
- "\u{2F801}"=>"\u4E38",
- "\u{2F802}"=>"\u4E41",
- "\u{2F803}"=>"\u{20122}",
- "\u{2F804}"=>"\u4F60",
- "\u{2F805}"=>"\u4FAE",
- "\u{2F806}"=>"\u4FBB",
- "\u{2F807}"=>"\u5002",
- "\u{2F808}"=>"\u507A",
- "\u{2F809}"=>"\u5099",
- "\u{2F80A}"=>"\u50E7",
- "\u{2F80B}"=>"\u50CF",
- "\u{2F80C}"=>"\u349E",
- "\u{2F80D}"=>"\u{2063A}",
- "\u{2F80E}"=>"\u514D",
- "\u{2F80F}"=>"\u5154",
- "\u{2F810}"=>"\u5164",
- "\u{2F811}"=>"\u5177",
- "\u{2F812}"=>"\u{2051C}",
- "\u{2F813}"=>"\u34B9",
- "\u{2F814}"=>"\u5167",
- "\u{2F815}"=>"\u518D",
- "\u{2F816}"=>"\u{2054B}",
- "\u{2F817}"=>"\u5197",
- "\u{2F818}"=>"\u51A4",
- "\u{2F819}"=>"\u4ECC",
- "\u{2F81A}"=>"\u51AC",
- "\u{2F81B}"=>"\u51B5",
- "\u{2F81C}"=>"\u{291DF}",
- "\u{2F81D}"=>"\u51F5",
- "\u{2F81E}"=>"\u5203",
- "\u{2F81F}"=>"\u34DF",
- "\u{2F820}"=>"\u523B",
- "\u{2F821}"=>"\u5246",
- "\u{2F822}"=>"\u5272",
- "\u{2F823}"=>"\u5277",
- "\u{2F824}"=>"\u3515",
- "\u{2F825}"=>"\u52C7",
- "\u{2F826}"=>"\u52C9",
- "\u{2F827}"=>"\u52E4",
- "\u{2F828}"=>"\u52FA",
- "\u{2F829}"=>"\u5305",
- "\u{2F82A}"=>"\u5306",
- "\u{2F82B}"=>"\u5317",
- "\u{2F82C}"=>"\u5349",
- "\u{2F82D}"=>"\u5351",
- "\u{2F82E}"=>"\u535A",
- "\u{2F82F}"=>"\u5373",
- "\u{2F830}"=>"\u537D",
- "\u{2F831}"=>"\u537F",
- "\u{2F832}"=>"\u537F",
- "\u{2F833}"=>"\u537F",
- "\u{2F834}"=>"\u{20A2C}",
- "\u{2F835}"=>"\u7070",
- "\u{2F836}"=>"\u53CA",
- "\u{2F837}"=>"\u53DF",
- "\u{2F838}"=>"\u{20B63}",
- "\u{2F839}"=>"\u53EB",
- "\u{2F83A}"=>"\u53F1",
- "\u{2F83B}"=>"\u5406",
- "\u{2F83C}"=>"\u549E",
- "\u{2F83D}"=>"\u5438",
- "\u{2F83E}"=>"\u5448",
- "\u{2F83F}"=>"\u5468",
- "\u{2F840}"=>"\u54A2",
- "\u{2F841}"=>"\u54F6",
- "\u{2F842}"=>"\u5510",
- "\u{2F843}"=>"\u5553",
- "\u{2F844}"=>"\u5563",
- "\u{2F845}"=>"\u5584",
- "\u{2F846}"=>"\u5584",
- "\u{2F847}"=>"\u5599",
- "\u{2F848}"=>"\u55AB",
- "\u{2F849}"=>"\u55B3",
- "\u{2F84A}"=>"\u55C2",
- "\u{2F84B}"=>"\u5716",
- "\u{2F84C}"=>"\u5606",
- "\u{2F84D}"=>"\u5717",
- "\u{2F84E}"=>"\u5651",
- "\u{2F84F}"=>"\u5674",
- "\u{2F850}"=>"\u5207",
- "\u{2F851}"=>"\u58EE",
- "\u{2F852}"=>"\u57CE",
- "\u{2F853}"=>"\u57F4",
- "\u{2F854}"=>"\u580D",
- "\u{2F855}"=>"\u578B",
- "\u{2F856}"=>"\u5832",
- "\u{2F857}"=>"\u5831",
- "\u{2F858}"=>"\u58AC",
- "\u{2F859}"=>"\u{214E4}",
- "\u{2F85A}"=>"\u58F2",
- "\u{2F85B}"=>"\u58F7",
- "\u{2F85C}"=>"\u5906",
- "\u{2F85D}"=>"\u591A",
- "\u{2F85E}"=>"\u5922",
- "\u{2F85F}"=>"\u5962",
- "\u{2F860}"=>"\u{216A8}",
- "\u{2F861}"=>"\u{216EA}",
- "\u{2F862}"=>"\u59EC",
- "\u{2F863}"=>"\u5A1B",
- "\u{2F864}"=>"\u5A27",
- "\u{2F865}"=>"\u59D8",
- "\u{2F866}"=>"\u5A66",
- "\u{2F867}"=>"\u36EE",
- "\u{2F868}"=>"\u36FC",
- "\u{2F869}"=>"\u5B08",
- "\u{2F86A}"=>"\u5B3E",
- "\u{2F86B}"=>"\u5B3E",
- "\u{2F86C}"=>"\u{219C8}",
- "\u{2F86D}"=>"\u5BC3",
- "\u{2F86E}"=>"\u5BD8",
- "\u{2F86F}"=>"\u5BE7",
- "\u{2F870}"=>"\u5BF3",
- "\u{2F871}"=>"\u{21B18}",
- "\u{2F872}"=>"\u5BFF",
- "\u{2F873}"=>"\u5C06",
- "\u{2F874}"=>"\u5F53",
- "\u{2F875}"=>"\u5C22",
- "\u{2F876}"=>"\u3781",
- "\u{2F877}"=>"\u5C60",
- "\u{2F878}"=>"\u5C6E",
- "\u{2F879}"=>"\u5CC0",
- "\u{2F87A}"=>"\u5C8D",
- "\u{2F87B}"=>"\u{21DE4}",
- "\u{2F87C}"=>"\u5D43",
- "\u{2F87D}"=>"\u{21DE6}",
- "\u{2F87E}"=>"\u5D6E",
- "\u{2F87F}"=>"\u5D6B",
- "\u{2F880}"=>"\u5D7C",
- "\u{2F881}"=>"\u5DE1",
- "\u{2F882}"=>"\u5DE2",
- "\u{2F883}"=>"\u382F",
- "\u{2F884}"=>"\u5DFD",
- "\u{2F885}"=>"\u5E28",
- "\u{2F886}"=>"\u5E3D",
- "\u{2F887}"=>"\u5E69",
- "\u{2F888}"=>"\u3862",
- "\u{2F889}"=>"\u{22183}",
- "\u{2F88A}"=>"\u387C",
- "\u{2F88B}"=>"\u5EB0",
- "\u{2F88C}"=>"\u5EB3",
- "\u{2F88D}"=>"\u5EB6",
- "\u{2F88E}"=>"\u5ECA",
- "\u{2F88F}"=>"\u{2A392}",
- "\u{2F890}"=>"\u5EFE",
- "\u{2F891}"=>"\u{22331}",
- "\u{2F892}"=>"\u{22331}",
- "\u{2F893}"=>"\u8201",
- "\u{2F894}"=>"\u5F22",
- "\u{2F895}"=>"\u5F22",
- "\u{2F896}"=>"\u38C7",
- "\u{2F897}"=>"\u{232B8}",
- "\u{2F898}"=>"\u{261DA}",
- "\u{2F899}"=>"\u5F62",
- "\u{2F89A}"=>"\u5F6B",
- "\u{2F89B}"=>"\u38E3",
- "\u{2F89C}"=>"\u5F9A",
- "\u{2F89D}"=>"\u5FCD",
- "\u{2F89E}"=>"\u5FD7",
- "\u{2F89F}"=>"\u5FF9",
- "\u{2F8A0}"=>"\u6081",
- "\u{2F8A1}"=>"\u393A",
- "\u{2F8A2}"=>"\u391C",
- "\u{2F8A3}"=>"\u6094",
- "\u{2F8A4}"=>"\u{226D4}",
- "\u{2F8A5}"=>"\u60C7",
- "\u{2F8A6}"=>"\u6148",
- "\u{2F8A7}"=>"\u614C",
- "\u{2F8A8}"=>"\u614E",
- "\u{2F8A9}"=>"\u614C",
- "\u{2F8AA}"=>"\u617A",
- "\u{2F8AB}"=>"\u618E",
- "\u{2F8AC}"=>"\u61B2",
- "\u{2F8AD}"=>"\u61A4",
- "\u{2F8AE}"=>"\u61AF",
- "\u{2F8AF}"=>"\u61DE",
- "\u{2F8B0}"=>"\u61F2",
- "\u{2F8B1}"=>"\u61F6",
- "\u{2F8B2}"=>"\u6210",
- "\u{2F8B3}"=>"\u621B",
- "\u{2F8B4}"=>"\u625D",
- "\u{2F8B5}"=>"\u62B1",
- "\u{2F8B6}"=>"\u62D4",
- "\u{2F8B7}"=>"\u6350",
- "\u{2F8B8}"=>"\u{22B0C}",
- "\u{2F8B9}"=>"\u633D",
- "\u{2F8BA}"=>"\u62FC",
- "\u{2F8BB}"=>"\u6368",
- "\u{2F8BC}"=>"\u6383",
- "\u{2F8BD}"=>"\u63E4",
- "\u{2F8BE}"=>"\u{22BF1}",
- "\u{2F8BF}"=>"\u6422",
- "\u{2F8C0}"=>"\u63C5",
- "\u{2F8C1}"=>"\u63A9",
- "\u{2F8C2}"=>"\u3A2E",
- "\u{2F8C3}"=>"\u6469",
- "\u{2F8C4}"=>"\u647E",
- "\u{2F8C5}"=>"\u649D",
- "\u{2F8C6}"=>"\u6477",
- "\u{2F8C7}"=>"\u3A6C",
- "\u{2F8C8}"=>"\u654F",
- "\u{2F8C9}"=>"\u656C",
- "\u{2F8CA}"=>"\u{2300A}",
- "\u{2F8CB}"=>"\u65E3",
- "\u{2F8CC}"=>"\u66F8",
- "\u{2F8CD}"=>"\u6649",
- "\u{2F8CE}"=>"\u3B19",
- "\u{2F8CF}"=>"\u6691",
- "\u{2F8D0}"=>"\u3B08",
- "\u{2F8D1}"=>"\u3AE4",
- "\u{2F8D2}"=>"\u5192",
- "\u{2F8D3}"=>"\u5195",
- "\u{2F8D4}"=>"\u6700",
- "\u{2F8D5}"=>"\u669C",
- "\u{2F8D6}"=>"\u80AD",
- "\u{2F8D7}"=>"\u43D9",
- "\u{2F8D8}"=>"\u6717",
- "\u{2F8D9}"=>"\u671B",
- "\u{2F8DA}"=>"\u6721",
- "\u{2F8DB}"=>"\u675E",
- "\u{2F8DC}"=>"\u6753",
- "\u{2F8DD}"=>"\u{233C3}",
- "\u{2F8DE}"=>"\u3B49",
- "\u{2F8DF}"=>"\u67FA",
- "\u{2F8E0}"=>"\u6785",
- "\u{2F8E1}"=>"\u6852",
- "\u{2F8E2}"=>"\u6885",
- "\u{2F8E3}"=>"\u{2346D}",
- "\u{2F8E4}"=>"\u688E",
- "\u{2F8E5}"=>"\u681F",
- "\u{2F8E6}"=>"\u6914",
- "\u{2F8E7}"=>"\u3B9D",
- "\u{2F8E8}"=>"\u6942",
- "\u{2F8E9}"=>"\u69A3",
- "\u{2F8EA}"=>"\u69EA",
- "\u{2F8EB}"=>"\u6AA8",
- "\u{2F8EC}"=>"\u{236A3}",
- "\u{2F8ED}"=>"\u6ADB",
- "\u{2F8EE}"=>"\u3C18",
- "\u{2F8EF}"=>"\u6B21",
- "\u{2F8F0}"=>"\u{238A7}",
- "\u{2F8F1}"=>"\u6B54",
- "\u{2F8F2}"=>"\u3C4E",
- "\u{2F8F3}"=>"\u6B72",
- "\u{2F8F4}"=>"\u6B9F",
- "\u{2F8F5}"=>"\u6BBA",
- "\u{2F8F6}"=>"\u6BBB",
- "\u{2F8F7}"=>"\u{23A8D}",
- "\u{2F8F8}"=>"\u{21D0B}",
- "\u{2F8F9}"=>"\u{23AFA}",
- "\u{2F8FA}"=>"\u6C4E",
- "\u{2F8FB}"=>"\u{23CBC}",
- "\u{2F8FC}"=>"\u6CBF",
- "\u{2F8FD}"=>"\u6CCD",
- "\u{2F8FE}"=>"\u6C67",
- "\u{2F8FF}"=>"\u6D16",
- "\u{2F900}"=>"\u6D3E",
- "\u{2F901}"=>"\u6D77",
- "\u{2F902}"=>"\u6D41",
- "\u{2F903}"=>"\u6D69",
- "\u{2F904}"=>"\u6D78",
- "\u{2F905}"=>"\u6D85",
- "\u{2F906}"=>"\u{23D1E}",
- "\u{2F907}"=>"\u6D34",
- "\u{2F908}"=>"\u6E2F",
- "\u{2F909}"=>"\u6E6E",
- "\u{2F90A}"=>"\u3D33",
- "\u{2F90B}"=>"\u6ECB",
- "\u{2F90C}"=>"\u6EC7",
- "\u{2F90D}"=>"\u{23ED1}",
- "\u{2F90E}"=>"\u6DF9",
- "\u{2F90F}"=>"\u6F6E",
- "\u{2F910}"=>"\u{23F5E}",
- "\u{2F911}"=>"\u{23F8E}",
- "\u{2F912}"=>"\u6FC6",
- "\u{2F913}"=>"\u7039",
- "\u{2F914}"=>"\u701E",
- "\u{2F915}"=>"\u701B",
- "\u{2F916}"=>"\u3D96",
- "\u{2F917}"=>"\u704A",
- "\u{2F918}"=>"\u707D",
- "\u{2F919}"=>"\u7077",
- "\u{2F91A}"=>"\u70AD",
- "\u{2F91B}"=>"\u{20525}",
- "\u{2F91C}"=>"\u7145",
- "\u{2F91D}"=>"\u{24263}",
- "\u{2F91E}"=>"\u719C",
- "\u{2F91F}"=>"\u{243AB}",
- "\u{2F920}"=>"\u7228",
- "\u{2F921}"=>"\u7235",
- "\u{2F922}"=>"\u7250",
- "\u{2F923}"=>"\u{24608}",
- "\u{2F924}"=>"\u7280",
- "\u{2F925}"=>"\u7295",
- "\u{2F926}"=>"\u{24735}",
- "\u{2F927}"=>"\u{24814}",
- "\u{2F928}"=>"\u737A",
- "\u{2F929}"=>"\u738B",
- "\u{2F92A}"=>"\u3EAC",
- "\u{2F92B}"=>"\u73A5",
- "\u{2F92C}"=>"\u3EB8",
- "\u{2F92D}"=>"\u3EB8",
- "\u{2F92E}"=>"\u7447",
- "\u{2F92F}"=>"\u745C",
- "\u{2F930}"=>"\u7471",
- "\u{2F931}"=>"\u7485",
- "\u{2F932}"=>"\u74CA",
- "\u{2F933}"=>"\u3F1B",
- "\u{2F934}"=>"\u7524",
- "\u{2F935}"=>"\u{24C36}",
- "\u{2F936}"=>"\u753E",
- "\u{2F937}"=>"\u{24C92}",
- "\u{2F938}"=>"\u7570",
- "\u{2F939}"=>"\u{2219F}",
- "\u{2F93A}"=>"\u7610",
- "\u{2F93B}"=>"\u{24FA1}",
- "\u{2F93C}"=>"\u{24FB8}",
- "\u{2F93D}"=>"\u{25044}",
- "\u{2F93E}"=>"\u3FFC",
- "\u{2F93F}"=>"\u4008",
- "\u{2F940}"=>"\u76F4",
- "\u{2F941}"=>"\u{250F3}",
- "\u{2F942}"=>"\u{250F2}",
- "\u{2F943}"=>"\u{25119}",
- "\u{2F944}"=>"\u{25133}",
- "\u{2F945}"=>"\u771E",
- "\u{2F946}"=>"\u771F",
- "\u{2F947}"=>"\u771F",
- "\u{2F948}"=>"\u774A",
- "\u{2F949}"=>"\u4039",
- "\u{2F94A}"=>"\u778B",
- "\u{2F94B}"=>"\u4046",
- "\u{2F94C}"=>"\u4096",
- "\u{2F94D}"=>"\u{2541D}",
- "\u{2F94E}"=>"\u784E",
- "\u{2F94F}"=>"\u788C",
- "\u{2F950}"=>"\u78CC",
- "\u{2F951}"=>"\u40E3",
- "\u{2F952}"=>"\u{25626}",
- "\u{2F953}"=>"\u7956",
- "\u{2F954}"=>"\u{2569A}",
- "\u{2F955}"=>"\u{256C5}",
- "\u{2F956}"=>"\u798F",
- "\u{2F957}"=>"\u79EB",
- "\u{2F958}"=>"\u412F",
- "\u{2F959}"=>"\u7A40",
- "\u{2F95A}"=>"\u7A4A",
- "\u{2F95B}"=>"\u7A4F",
- "\u{2F95C}"=>"\u{2597C}",
- "\u{2F95D}"=>"\u{25AA7}",
- "\u{2F95E}"=>"\u{25AA7}",
- "\u{2F95F}"=>"\u7AEE",
- "\u{2F960}"=>"\u4202",
- "\u{2F961}"=>"\u{25BAB}",
- "\u{2F962}"=>"\u7BC6",
- "\u{2F963}"=>"\u7BC9",
- "\u{2F964}"=>"\u4227",
- "\u{2F965}"=>"\u{25C80}",
- "\u{2F966}"=>"\u7CD2",
- "\u{2F967}"=>"\u42A0",
- "\u{2F968}"=>"\u7CE8",
- "\u{2F969}"=>"\u7CE3",
- "\u{2F96A}"=>"\u7D00",
- "\u{2F96B}"=>"\u{25F86}",
- "\u{2F96C}"=>"\u7D63",
- "\u{2F96D}"=>"\u4301",
- "\u{2F96E}"=>"\u7DC7",
- "\u{2F96F}"=>"\u7E02",
- "\u{2F970}"=>"\u7E45",
- "\u{2F971}"=>"\u4334",
- "\u{2F972}"=>"\u{26228}",
- "\u{2F973}"=>"\u{26247}",
- "\u{2F974}"=>"\u4359",
- "\u{2F975}"=>"\u{262D9}",
- "\u{2F976}"=>"\u7F7A",
- "\u{2F977}"=>"\u{2633E}",
- "\u{2F978}"=>"\u7F95",
- "\u{2F979}"=>"\u7FFA",
- "\u{2F97A}"=>"\u8005",
- "\u{2F97B}"=>"\u{264DA}",
- "\u{2F97C}"=>"\u{26523}",
- "\u{2F97D}"=>"\u8060",
- "\u{2F97E}"=>"\u{265A8}",
- "\u{2F97F}"=>"\u8070",
- "\u{2F980}"=>"\u{2335F}",
- "\u{2F981}"=>"\u43D5",
- "\u{2F982}"=>"\u80B2",
- "\u{2F983}"=>"\u8103",
- "\u{2F984}"=>"\u440B",
- "\u{2F985}"=>"\u813E",
- "\u{2F986}"=>"\u5AB5",
- "\u{2F987}"=>"\u{267A7}",
- "\u{2F988}"=>"\u{267B5}",
- "\u{2F989}"=>"\u{23393}",
- "\u{2F98A}"=>"\u{2339C}",
- "\u{2F98B}"=>"\u8201",
- "\u{2F98C}"=>"\u8204",
- "\u{2F98D}"=>"\u8F9E",
- "\u{2F98E}"=>"\u446B",
- "\u{2F98F}"=>"\u8291",
- "\u{2F990}"=>"\u828B",
- "\u{2F991}"=>"\u829D",
- "\u{2F992}"=>"\u52B3",
- "\u{2F993}"=>"\u82B1",
- "\u{2F994}"=>"\u82B3",
- "\u{2F995}"=>"\u82BD",
- "\u{2F996}"=>"\u82E6",
- "\u{2F997}"=>"\u{26B3C}",
- "\u{2F998}"=>"\u82E5",
- "\u{2F999}"=>"\u831D",
- "\u{2F99A}"=>"\u8363",
- "\u{2F99B}"=>"\u83AD",
- "\u{2F99C}"=>"\u8323",
- "\u{2F99D}"=>"\u83BD",
- "\u{2F99E}"=>"\u83E7",
- "\u{2F99F}"=>"\u8457",
- "\u{2F9A0}"=>"\u8353",
- "\u{2F9A1}"=>"\u83CA",
- "\u{2F9A2}"=>"\u83CC",
- "\u{2F9A3}"=>"\u83DC",
- "\u{2F9A4}"=>"\u{26C36}",
- "\u{2F9A5}"=>"\u{26D6B}",
- "\u{2F9A6}"=>"\u{26CD5}",
- "\u{2F9A7}"=>"\u452B",
- "\u{2F9A8}"=>"\u84F1",
- "\u{2F9A9}"=>"\u84F3",
- "\u{2F9AA}"=>"\u8516",
- "\u{2F9AB}"=>"\u{273CA}",
- "\u{2F9AC}"=>"\u8564",
- "\u{2F9AD}"=>"\u{26F2C}",
- "\u{2F9AE}"=>"\u455D",
- "\u{2F9AF}"=>"\u4561",
- "\u{2F9B0}"=>"\u{26FB1}",
- "\u{2F9B1}"=>"\u{270D2}",
- "\u{2F9B2}"=>"\u456B",
- "\u{2F9B3}"=>"\u8650",
- "\u{2F9B4}"=>"\u865C",
- "\u{2F9B5}"=>"\u8667",
- "\u{2F9B6}"=>"\u8669",
- "\u{2F9B7}"=>"\u86A9",
- "\u{2F9B8}"=>"\u8688",
- "\u{2F9B9}"=>"\u870E",
- "\u{2F9BA}"=>"\u86E2",
- "\u{2F9BB}"=>"\u8779",
- "\u{2F9BC}"=>"\u8728",
- "\u{2F9BD}"=>"\u876B",
- "\u{2F9BE}"=>"\u8786",
- "\u{2F9BF}"=>"\u45D7",
- "\u{2F9C0}"=>"\u87E1",
- "\u{2F9C1}"=>"\u8801",
- "\u{2F9C2}"=>"\u45F9",
- "\u{2F9C3}"=>"\u8860",
- "\u{2F9C4}"=>"\u8863",
- "\u{2F9C5}"=>"\u{27667}",
- "\u{2F9C6}"=>"\u88D7",
- "\u{2F9C7}"=>"\u88DE",
- "\u{2F9C8}"=>"\u4635",
- "\u{2F9C9}"=>"\u88FA",
- "\u{2F9CA}"=>"\u34BB",
- "\u{2F9CB}"=>"\u{278AE}",
- "\u{2F9CC}"=>"\u{27966}",
- "\u{2F9CD}"=>"\u46BE",
- "\u{2F9CE}"=>"\u46C7",
- "\u{2F9CF}"=>"\u8AA0",
- "\u{2F9D0}"=>"\u8AED",
- "\u{2F9D1}"=>"\u8B8A",
- "\u{2F9D2}"=>"\u8C55",
- "\u{2F9D3}"=>"\u{27CA8}",
- "\u{2F9D4}"=>"\u8CAB",
- "\u{2F9D5}"=>"\u8CC1",
- "\u{2F9D6}"=>"\u8D1B",
- "\u{2F9D7}"=>"\u8D77",
- "\u{2F9D8}"=>"\u{27F2F}",
- "\u{2F9D9}"=>"\u{20804}",
- "\u{2F9DA}"=>"\u8DCB",
- "\u{2F9DB}"=>"\u8DBC",
- "\u{2F9DC}"=>"\u8DF0",
- "\u{2F9DD}"=>"\u{208DE}",
- "\u{2F9DE}"=>"\u8ED4",
- "\u{2F9DF}"=>"\u8F38",
- "\u{2F9E0}"=>"\u{285D2}",
- "\u{2F9E1}"=>"\u{285ED}",
- "\u{2F9E2}"=>"\u9094",
- "\u{2F9E3}"=>"\u90F1",
- "\u{2F9E4}"=>"\u9111",
- "\u{2F9E5}"=>"\u{2872E}",
- "\u{2F9E6}"=>"\u911B",
- "\u{2F9E7}"=>"\u9238",
- "\u{2F9E8}"=>"\u92D7",
- "\u{2F9E9}"=>"\u92D8",
- "\u{2F9EA}"=>"\u927C",
- "\u{2F9EB}"=>"\u93F9",
- "\u{2F9EC}"=>"\u9415",
- "\u{2F9ED}"=>"\u{28BFA}",
- "\u{2F9EE}"=>"\u958B",
- "\u{2F9EF}"=>"\u4995",
- "\u{2F9F0}"=>"\u95B7",
- "\u{2F9F1}"=>"\u{28D77}",
- "\u{2F9F2}"=>"\u49E6",
- "\u{2F9F3}"=>"\u96C3",
- "\u{2F9F4}"=>"\u5DB2",
- "\u{2F9F5}"=>"\u9723",
- "\u{2F9F6}"=>"\u{29145}",
- "\u{2F9F7}"=>"\u{2921A}",
- "\u{2F9F8}"=>"\u4A6E",
- "\u{2F9F9}"=>"\u4A76",
- "\u{2F9FA}"=>"\u97E0",
- "\u{2F9FB}"=>"\u{2940A}",
- "\u{2F9FC}"=>"\u4AB2",
- "\u{2F9FD}"=>"\u{29496}",
- "\u{2F9FE}"=>"\u980B",
- "\u{2F9FF}"=>"\u980B",
- "\u{2FA00}"=>"\u9829",
- "\u{2FA01}"=>"\u{295B6}",
- "\u{2FA02}"=>"\u98E2",
- "\u{2FA03}"=>"\u4B33",
- "\u{2FA04}"=>"\u9929",
- "\u{2FA05}"=>"\u99A7",
- "\u{2FA06}"=>"\u99C2",
- "\u{2FA07}"=>"\u99FE",
- "\u{2FA08}"=>"\u4BCE",
- "\u{2FA09}"=>"\u{29B30}",
- "\u{2FA0A}"=>"\u9B12",
- "\u{2FA0B}"=>"\u9C40",
- "\u{2FA0C}"=>"\u9CFD",
- "\u{2FA0D}"=>"\u4CCE",
- "\u{2FA0E}"=>"\u4CED",
- "\u{2FA0F}"=>"\u9D67",
- "\u{2FA10}"=>"\u{2A0CE}",
- "\u{2FA11}"=>"\u4CF8",
- "\u{2FA12}"=>"\u{2A105}",
- "\u{2FA13}"=>"\u{2A20E}",
- "\u{2FA14}"=>"\u{2A291}",
- "\u{2FA15}"=>"\u9EBB",
- "\u{2FA16}"=>"\u4D56",
- "\u{2FA17}"=>"\u9EF9",
- "\u{2FA18}"=>"\u9EFE",
- "\u{2FA19}"=>"\u9F05",
- "\u{2FA1A}"=>"\u9F0F",
- "\u{2FA1B}"=>"\u9F16",
- "\u{2FA1C}"=>"\u9F3B",
- "\u{2FA1D}"=>"\u{2A600}",
+ "\u00C0"=>"A\u0300", "\u00C1"=>"A\u0301", "\u00C2"=>"A\u0302", "\u00C3"=>"A\u0303", "\u00C4"=>"A\u0308", "\u00C5"=>"A\u030A", "\u00C7"=>"C\u0327", "\u00C8"=>"E\u0300",
+ "\u00C9"=>"E\u0301", "\u00CA"=>"E\u0302", "\u00CB"=>"E\u0308", "\u00CC"=>"I\u0300", "\u00CD"=>"I\u0301", "\u00CE"=>"I\u0302", "\u00CF"=>"I\u0308", "\u00D1"=>"N\u0303",
+ "\u00D2"=>"O\u0300", "\u00D3"=>"O\u0301", "\u00D4"=>"O\u0302", "\u00D5"=>"O\u0303", "\u00D6"=>"O\u0308", "\u00D9"=>"U\u0300", "\u00DA"=>"U\u0301", "\u00DB"=>"U\u0302",
+ "\u00DC"=>"U\u0308", "\u00DD"=>"Y\u0301", "\u00E0"=>"a\u0300", "\u00E1"=>"a\u0301", "\u00E2"=>"a\u0302", "\u00E3"=>"a\u0303", "\u00E4"=>"a\u0308", "\u00E5"=>"a\u030A",
+ "\u00E7"=>"c\u0327", "\u00E8"=>"e\u0300", "\u00E9"=>"e\u0301", "\u00EA"=>"e\u0302", "\u00EB"=>"e\u0308", "\u00EC"=>"i\u0300", "\u00ED"=>"i\u0301", "\u00EE"=>"i\u0302",
+ "\u00EF"=>"i\u0308", "\u00F1"=>"n\u0303", "\u00F2"=>"o\u0300", "\u00F3"=>"o\u0301", "\u00F4"=>"o\u0302", "\u00F5"=>"o\u0303", "\u00F6"=>"o\u0308", "\u00F9"=>"u\u0300",
+ "\u00FA"=>"u\u0301", "\u00FB"=>"u\u0302", "\u00FC"=>"u\u0308", "\u00FD"=>"y\u0301", "\u00FF"=>"y\u0308", "\u0100"=>"A\u0304", "\u0101"=>"a\u0304", "\u0102"=>"A\u0306",
+ "\u0103"=>"a\u0306", "\u0104"=>"A\u0328", "\u0105"=>"a\u0328", "\u0106"=>"C\u0301", "\u0107"=>"c\u0301", "\u0108"=>"C\u0302", "\u0109"=>"c\u0302", "\u010A"=>"C\u0307",
+ "\u010B"=>"c\u0307", "\u010C"=>"C\u030C", "\u010D"=>"c\u030C", "\u010E"=>"D\u030C", "\u010F"=>"d\u030C", "\u0112"=>"E\u0304", "\u0113"=>"e\u0304", "\u0114"=>"E\u0306",
+ "\u0115"=>"e\u0306", "\u0116"=>"E\u0307", "\u0117"=>"e\u0307", "\u0118"=>"E\u0328", "\u0119"=>"e\u0328", "\u011A"=>"E\u030C", "\u011B"=>"e\u030C", "\u011C"=>"G\u0302",
+ "\u011D"=>"g\u0302", "\u011E"=>"G\u0306", "\u011F"=>"g\u0306", "\u0120"=>"G\u0307", "\u0121"=>"g\u0307", "\u0122"=>"G\u0327", "\u0123"=>"g\u0327", "\u0124"=>"H\u0302",
+ "\u0125"=>"h\u0302", "\u0128"=>"I\u0303", "\u0129"=>"i\u0303", "\u012A"=>"I\u0304", "\u012B"=>"i\u0304", "\u012C"=>"I\u0306", "\u012D"=>"i\u0306", "\u012E"=>"I\u0328",
+ "\u012F"=>"i\u0328", "\u0130"=>"I\u0307", "\u0134"=>"J\u0302", "\u0135"=>"j\u0302", "\u0136"=>"K\u0327", "\u0137"=>"k\u0327", "\u0139"=>"L\u0301", "\u013A"=>"l\u0301",
+ "\u013B"=>"L\u0327", "\u013C"=>"l\u0327", "\u013D"=>"L\u030C", "\u013E"=>"l\u030C", "\u0143"=>"N\u0301", "\u0144"=>"n\u0301", "\u0145"=>"N\u0327", "\u0146"=>"n\u0327",
+ "\u0147"=>"N\u030C", "\u0148"=>"n\u030C", "\u014C"=>"O\u0304", "\u014D"=>"o\u0304", "\u014E"=>"O\u0306", "\u014F"=>"o\u0306", "\u0150"=>"O\u030B", "\u0151"=>"o\u030B",
+ "\u0154"=>"R\u0301", "\u0155"=>"r\u0301", "\u0156"=>"R\u0327", "\u0157"=>"r\u0327", "\u0158"=>"R\u030C", "\u0159"=>"r\u030C", "\u015A"=>"S\u0301", "\u015B"=>"s\u0301",
+ "\u015C"=>"S\u0302", "\u015D"=>"s\u0302", "\u015E"=>"S\u0327", "\u015F"=>"s\u0327", "\u0160"=>"S\u030C", "\u0161"=>"s\u030C", "\u0162"=>"T\u0327", "\u0163"=>"t\u0327",
+ "\u0164"=>"T\u030C", "\u0165"=>"t\u030C", "\u0168"=>"U\u0303", "\u0169"=>"u\u0303", "\u016A"=>"U\u0304", "\u016B"=>"u\u0304", "\u016C"=>"U\u0306", "\u016D"=>"u\u0306",
+ "\u016E"=>"U\u030A", "\u016F"=>"u\u030A", "\u0170"=>"U\u030B", "\u0171"=>"u\u030B", "\u0172"=>"U\u0328", "\u0173"=>"u\u0328", "\u0174"=>"W\u0302", "\u0175"=>"w\u0302",
+ "\u0176"=>"Y\u0302", "\u0177"=>"y\u0302", "\u0178"=>"Y\u0308", "\u0179"=>"Z\u0301", "\u017A"=>"z\u0301", "\u017B"=>"Z\u0307", "\u017C"=>"z\u0307", "\u017D"=>"Z\u030C",
+ "\u017E"=>"z\u030C", "\u01A0"=>"O\u031B", "\u01A1"=>"o\u031B", "\u01AF"=>"U\u031B", "\u01B0"=>"u\u031B", "\u01CD"=>"A\u030C", "\u01CE"=>"a\u030C", "\u01CF"=>"I\u030C",
+ "\u01D0"=>"i\u030C", "\u01D1"=>"O\u030C", "\u01D2"=>"o\u030C", "\u01D3"=>"U\u030C", "\u01D4"=>"u\u030C", "\u01D5"=>"U\u0308\u0304", "\u01D6"=>"u\u0308\u0304", "\u01D7"=>"U\u0308\u0301",
+ "\u01D8"=>"u\u0308\u0301", "\u01D9"=>"U\u0308\u030C", "\u01DA"=>"u\u0308\u030C", "\u01DB"=>"U\u0308\u0300", "\u01DC"=>"u\u0308\u0300", "\u01DE"=>"A\u0308\u0304", "\u01DF"=>"a\u0308\u0304", "\u01E0"=>"A\u0307\u0304",
+ "\u01E1"=>"a\u0307\u0304", "\u01E2"=>"\u00C6\u0304", "\u01E3"=>"\u00E6\u0304", "\u01E6"=>"G\u030C", "\u01E7"=>"g\u030C", "\u01E8"=>"K\u030C", "\u01E9"=>"k\u030C", "\u01EA"=>"O\u0328",
+ "\u01EB"=>"o\u0328", "\u01EC"=>"O\u0328\u0304", "\u01ED"=>"o\u0328\u0304", "\u01EE"=>"\u01B7\u030C", "\u01EF"=>"\u0292\u030C", "\u01F0"=>"j\u030C", "\u01F4"=>"G\u0301", "\u01F5"=>"g\u0301",
+ "\u01F8"=>"N\u0300", "\u01F9"=>"n\u0300", "\u01FA"=>"A\u030A\u0301", "\u01FB"=>"a\u030A\u0301", "\u01FC"=>"\u00C6\u0301", "\u01FD"=>"\u00E6\u0301", "\u01FE"=>"\u00D8\u0301", "\u01FF"=>"\u00F8\u0301",
+ "\u0200"=>"A\u030F", "\u0201"=>"a\u030F", "\u0202"=>"A\u0311", "\u0203"=>"a\u0311", "\u0204"=>"E\u030F", "\u0205"=>"e\u030F", "\u0206"=>"E\u0311", "\u0207"=>"e\u0311",
+ "\u0208"=>"I\u030F", "\u0209"=>"i\u030F", "\u020A"=>"I\u0311", "\u020B"=>"i\u0311", "\u020C"=>"O\u030F", "\u020D"=>"o\u030F", "\u020E"=>"O\u0311", "\u020F"=>"o\u0311",
+ "\u0210"=>"R\u030F", "\u0211"=>"r\u030F", "\u0212"=>"R\u0311", "\u0213"=>"r\u0311", "\u0214"=>"U\u030F", "\u0215"=>"u\u030F", "\u0216"=>"U\u0311", "\u0217"=>"u\u0311",
+ "\u0218"=>"S\u0326", "\u0219"=>"s\u0326", "\u021A"=>"T\u0326", "\u021B"=>"t\u0326", "\u021E"=>"H\u030C", "\u021F"=>"h\u030C", "\u0226"=>"A\u0307", "\u0227"=>"a\u0307",
+ "\u0228"=>"E\u0327", "\u0229"=>"e\u0327", "\u022A"=>"O\u0308\u0304", "\u022B"=>"o\u0308\u0304", "\u022C"=>"O\u0303\u0304", "\u022D"=>"o\u0303\u0304", "\u022E"=>"O\u0307", "\u022F"=>"o\u0307",
+ "\u0230"=>"O\u0307\u0304", "\u0231"=>"o\u0307\u0304", "\u0232"=>"Y\u0304", "\u0233"=>"y\u0304", "\u0340"=>"\u0300", "\u0341"=>"\u0301", "\u0343"=>"\u0313", "\u0344"=>"\u0308\u0301",
+ "\u0374"=>"\u02B9", "\u037E"=>";", "\u0385"=>"\u00A8\u0301", "\u0386"=>"\u0391\u0301", "\u0387"=>"\u00B7", "\u0388"=>"\u0395\u0301", "\u0389"=>"\u0397\u0301", "\u038A"=>"\u0399\u0301",
+ "\u038C"=>"\u039F\u0301", "\u038E"=>"\u03A5\u0301", "\u038F"=>"\u03A9\u0301", "\u0390"=>"\u03B9\u0308\u0301", "\u03AA"=>"\u0399\u0308", "\u03AB"=>"\u03A5\u0308", "\u03AC"=>"\u03B1\u0301", "\u03AD"=>"\u03B5\u0301",
+ "\u03AE"=>"\u03B7\u0301", "\u03AF"=>"\u03B9\u0301", "\u03B0"=>"\u03C5\u0308\u0301", "\u03CA"=>"\u03B9\u0308", "\u03CB"=>"\u03C5\u0308", "\u03CC"=>"\u03BF\u0301", "\u03CD"=>"\u03C5\u0301", "\u03CE"=>"\u03C9\u0301",
+ "\u03D3"=>"\u03D2\u0301", "\u03D4"=>"\u03D2\u0308", "\u0400"=>"\u0415\u0300", "\u0401"=>"\u0415\u0308", "\u0403"=>"\u0413\u0301", "\u0407"=>"\u0406\u0308", "\u040C"=>"\u041A\u0301", "\u040D"=>"\u0418\u0300",
+ "\u040E"=>"\u0423\u0306", "\u0419"=>"\u0418\u0306", "\u0439"=>"\u0438\u0306", "\u0450"=>"\u0435\u0300", "\u0451"=>"\u0435\u0308", "\u0453"=>"\u0433\u0301", "\u0457"=>"\u0456\u0308", "\u045C"=>"\u043A\u0301",
+ "\u045D"=>"\u0438\u0300", "\u045E"=>"\u0443\u0306", "\u0476"=>"\u0474\u030F", "\u0477"=>"\u0475\u030F", "\u04C1"=>"\u0416\u0306", "\u04C2"=>"\u0436\u0306", "\u04D0"=>"\u0410\u0306", "\u04D1"=>"\u0430\u0306",
+ "\u04D2"=>"\u0410\u0308", "\u04D3"=>"\u0430\u0308", "\u04D6"=>"\u0415\u0306", "\u04D7"=>"\u0435\u0306", "\u04DA"=>"\u04D8\u0308", "\u04DB"=>"\u04D9\u0308", "\u04DC"=>"\u0416\u0308", "\u04DD"=>"\u0436\u0308",
+ "\u04DE"=>"\u0417\u0308", "\u04DF"=>"\u0437\u0308", "\u04E2"=>"\u0418\u0304", "\u04E3"=>"\u0438\u0304", "\u04E4"=>"\u0418\u0308", "\u04E5"=>"\u0438\u0308", "\u04E6"=>"\u041E\u0308", "\u04E7"=>"\u043E\u0308",
+ "\u04EA"=>"\u04E8\u0308", "\u04EB"=>"\u04E9\u0308", "\u04EC"=>"\u042D\u0308", "\u04ED"=>"\u044D\u0308", "\u04EE"=>"\u0423\u0304", "\u04EF"=>"\u0443\u0304", "\u04F0"=>"\u0423\u0308", "\u04F1"=>"\u0443\u0308",
+ "\u04F2"=>"\u0423\u030B", "\u04F3"=>"\u0443\u030B", "\u04F4"=>"\u0427\u0308", "\u04F5"=>"\u0447\u0308", "\u04F8"=>"\u042B\u0308", "\u04F9"=>"\u044B\u0308", "\u0622"=>"\u0627\u0653", "\u0623"=>"\u0627\u0654",
+ "\u0624"=>"\u0648\u0654", "\u0625"=>"\u0627\u0655", "\u0626"=>"\u064A\u0654", "\u06C0"=>"\u06D5\u0654", "\u06C2"=>"\u06C1\u0654", "\u06D3"=>"\u06D2\u0654", "\u0929"=>"\u0928\u093C", "\u0931"=>"\u0930\u093C",
+ "\u0934"=>"\u0933\u093C", "\u0958"=>"\u0915\u093C", "\u0959"=>"\u0916\u093C", "\u095A"=>"\u0917\u093C", "\u095B"=>"\u091C\u093C", "\u095C"=>"\u0921\u093C", "\u095D"=>"\u0922\u093C", "\u095E"=>"\u092B\u093C",
+ "\u095F"=>"\u092F\u093C", "\u09CB"=>"\u09C7\u09BE", "\u09CC"=>"\u09C7\u09D7", "\u09DC"=>"\u09A1\u09BC", "\u09DD"=>"\u09A2\u09BC", "\u09DF"=>"\u09AF\u09BC", "\u0A33"=>"\u0A32\u0A3C", "\u0A36"=>"\u0A38\u0A3C",
+ "\u0A59"=>"\u0A16\u0A3C", "\u0A5A"=>"\u0A17\u0A3C", "\u0A5B"=>"\u0A1C\u0A3C", "\u0A5E"=>"\u0A2B\u0A3C", "\u0B48"=>"\u0B47\u0B56", "\u0B4B"=>"\u0B47\u0B3E", "\u0B4C"=>"\u0B47\u0B57", "\u0B5C"=>"\u0B21\u0B3C",
+ "\u0B5D"=>"\u0B22\u0B3C", "\u0B94"=>"\u0B92\u0BD7", "\u0BCA"=>"\u0BC6\u0BBE", "\u0BCB"=>"\u0BC7\u0BBE", "\u0BCC"=>"\u0BC6\u0BD7", "\u0C48"=>"\u0C46\u0C56", "\u0CC0"=>"\u0CBF\u0CD5", "\u0CC7"=>"\u0CC6\u0CD5",
+ "\u0CC8"=>"\u0CC6\u0CD6", "\u0CCA"=>"\u0CC6\u0CC2", "\u0CCB"=>"\u0CC6\u0CC2\u0CD5", "\u0D4A"=>"\u0D46\u0D3E", "\u0D4B"=>"\u0D47\u0D3E", "\u0D4C"=>"\u0D46\u0D57", "\u0DDA"=>"\u0DD9\u0DCA", "\u0DDC"=>"\u0DD9\u0DCF",
+ "\u0DDD"=>"\u0DD9\u0DCF\u0DCA", "\u0DDE"=>"\u0DD9\u0DDF", "\u0F43"=>"\u0F42\u0FB7", "\u0F4D"=>"\u0F4C\u0FB7", "\u0F52"=>"\u0F51\u0FB7", "\u0F57"=>"\u0F56\u0FB7", "\u0F5C"=>"\u0F5B\u0FB7", "\u0F69"=>"\u0F40\u0FB5",
+ "\u0F73"=>"\u0F71\u0F72", "\u0F75"=>"\u0F71\u0F74", "\u0F76"=>"\u0FB2\u0F80", "\u0F78"=>"\u0FB3\u0F80", "\u0F81"=>"\u0F71\u0F80", "\u0F93"=>"\u0F92\u0FB7", "\u0F9D"=>"\u0F9C\u0FB7", "\u0FA2"=>"\u0FA1\u0FB7",
+ "\u0FA7"=>"\u0FA6\u0FB7", "\u0FAC"=>"\u0FAB\u0FB7", "\u0FB9"=>"\u0F90\u0FB5", "\u1026"=>"\u1025\u102E", "\u1B06"=>"\u1B05\u1B35", "\u1B08"=>"\u1B07\u1B35", "\u1B0A"=>"\u1B09\u1B35", "\u1B0C"=>"\u1B0B\u1B35",
+ "\u1B0E"=>"\u1B0D\u1B35", "\u1B12"=>"\u1B11\u1B35", "\u1B3B"=>"\u1B3A\u1B35", "\u1B3D"=>"\u1B3C\u1B35", "\u1B40"=>"\u1B3E\u1B35", "\u1B41"=>"\u1B3F\u1B35", "\u1B43"=>"\u1B42\u1B35", "\u1E00"=>"A\u0325",
+ "\u1E01"=>"a\u0325", "\u1E02"=>"B\u0307", "\u1E03"=>"b\u0307", "\u1E04"=>"B\u0323", "\u1E05"=>"b\u0323", "\u1E06"=>"B\u0331", "\u1E07"=>"b\u0331", "\u1E08"=>"C\u0327\u0301",
+ "\u1E09"=>"c\u0327\u0301", "\u1E0A"=>"D\u0307", "\u1E0B"=>"d\u0307", "\u1E0C"=>"D\u0323", "\u1E0D"=>"d\u0323", "\u1E0E"=>"D\u0331", "\u1E0F"=>"d\u0331", "\u1E10"=>"D\u0327",
+ "\u1E11"=>"d\u0327", "\u1E12"=>"D\u032D", "\u1E13"=>"d\u032D", "\u1E14"=>"E\u0304\u0300", "\u1E15"=>"e\u0304\u0300", "\u1E16"=>"E\u0304\u0301", "\u1E17"=>"e\u0304\u0301", "\u1E18"=>"E\u032D",
+ "\u1E19"=>"e\u032D", "\u1E1A"=>"E\u0330", "\u1E1B"=>"e\u0330", "\u1E1C"=>"E\u0327\u0306", "\u1E1D"=>"e\u0327\u0306", "\u1E1E"=>"F\u0307", "\u1E1F"=>"f\u0307", "\u1E20"=>"G\u0304",
+ "\u1E21"=>"g\u0304", "\u1E22"=>"H\u0307", "\u1E23"=>"h\u0307", "\u1E24"=>"H\u0323", "\u1E25"=>"h\u0323", "\u1E26"=>"H\u0308", "\u1E27"=>"h\u0308", "\u1E28"=>"H\u0327",
+ "\u1E29"=>"h\u0327", "\u1E2A"=>"H\u032E", "\u1E2B"=>"h\u032E", "\u1E2C"=>"I\u0330", "\u1E2D"=>"i\u0330", "\u1E2E"=>"I\u0308\u0301", "\u1E2F"=>"i\u0308\u0301", "\u1E30"=>"K\u0301",
+ "\u1E31"=>"k\u0301", "\u1E32"=>"K\u0323", "\u1E33"=>"k\u0323", "\u1E34"=>"K\u0331", "\u1E35"=>"k\u0331", "\u1E36"=>"L\u0323", "\u1E37"=>"l\u0323", "\u1E38"=>"L\u0323\u0304",
+ "\u1E39"=>"l\u0323\u0304", "\u1E3A"=>"L\u0331", "\u1E3B"=>"l\u0331", "\u1E3C"=>"L\u032D", "\u1E3D"=>"l\u032D", "\u1E3E"=>"M\u0301", "\u1E3F"=>"m\u0301", "\u1E40"=>"M\u0307",
+ "\u1E41"=>"m\u0307", "\u1E42"=>"M\u0323", "\u1E43"=>"m\u0323", "\u1E44"=>"N\u0307", "\u1E45"=>"n\u0307", "\u1E46"=>"N\u0323", "\u1E47"=>"n\u0323", "\u1E48"=>"N\u0331",
+ "\u1E49"=>"n\u0331", "\u1E4A"=>"N\u032D", "\u1E4B"=>"n\u032D", "\u1E4C"=>"O\u0303\u0301", "\u1E4D"=>"o\u0303\u0301", "\u1E4E"=>"O\u0303\u0308", "\u1E4F"=>"o\u0303\u0308", "\u1E50"=>"O\u0304\u0300",
+ "\u1E51"=>"o\u0304\u0300", "\u1E52"=>"O\u0304\u0301", "\u1E53"=>"o\u0304\u0301", "\u1E54"=>"P\u0301", "\u1E55"=>"p\u0301", "\u1E56"=>"P\u0307", "\u1E57"=>"p\u0307", "\u1E58"=>"R\u0307",
+ "\u1E59"=>"r\u0307", "\u1E5A"=>"R\u0323", "\u1E5B"=>"r\u0323", "\u1E5C"=>"R\u0323\u0304", "\u1E5D"=>"r\u0323\u0304", "\u1E5E"=>"R\u0331", "\u1E5F"=>"r\u0331", "\u1E60"=>"S\u0307",
+ "\u1E61"=>"s\u0307", "\u1E62"=>"S\u0323", "\u1E63"=>"s\u0323", "\u1E64"=>"S\u0301\u0307", "\u1E65"=>"s\u0301\u0307", "\u1E66"=>"S\u030C\u0307", "\u1E67"=>"s\u030C\u0307", "\u1E68"=>"S\u0323\u0307",
+ "\u1E69"=>"s\u0323\u0307", "\u1E6A"=>"T\u0307", "\u1E6B"=>"t\u0307", "\u1E6C"=>"T\u0323", "\u1E6D"=>"t\u0323", "\u1E6E"=>"T\u0331", "\u1E6F"=>"t\u0331", "\u1E70"=>"T\u032D",
+ "\u1E71"=>"t\u032D", "\u1E72"=>"U\u0324", "\u1E73"=>"u\u0324", "\u1E74"=>"U\u0330", "\u1E75"=>"u\u0330", "\u1E76"=>"U\u032D", "\u1E77"=>"u\u032D", "\u1E78"=>"U\u0303\u0301",
+ "\u1E79"=>"u\u0303\u0301", "\u1E7A"=>"U\u0304\u0308", "\u1E7B"=>"u\u0304\u0308", "\u1E7C"=>"V\u0303", "\u1E7D"=>"v\u0303", "\u1E7E"=>"V\u0323", "\u1E7F"=>"v\u0323", "\u1E80"=>"W\u0300",
+ "\u1E81"=>"w\u0300", "\u1E82"=>"W\u0301", "\u1E83"=>"w\u0301", "\u1E84"=>"W\u0308", "\u1E85"=>"w\u0308", "\u1E86"=>"W\u0307", "\u1E87"=>"w\u0307", "\u1E88"=>"W\u0323",
+ "\u1E89"=>"w\u0323", "\u1E8A"=>"X\u0307", "\u1E8B"=>"x\u0307", "\u1E8C"=>"X\u0308", "\u1E8D"=>"x\u0308", "\u1E8E"=>"Y\u0307", "\u1E8F"=>"y\u0307", "\u1E90"=>"Z\u0302",
+ "\u1E91"=>"z\u0302", "\u1E92"=>"Z\u0323", "\u1E93"=>"z\u0323", "\u1E94"=>"Z\u0331", "\u1E95"=>"z\u0331", "\u1E96"=>"h\u0331", "\u1E97"=>"t\u0308", "\u1E98"=>"w\u030A",
+ "\u1E99"=>"y\u030A", "\u1E9B"=>"\u017F\u0307", "\u1EA0"=>"A\u0323", "\u1EA1"=>"a\u0323", "\u1EA2"=>"A\u0309", "\u1EA3"=>"a\u0309", "\u1EA4"=>"A\u0302\u0301", "\u1EA5"=>"a\u0302\u0301",
+ "\u1EA6"=>"A\u0302\u0300", "\u1EA7"=>"a\u0302\u0300", "\u1EA8"=>"A\u0302\u0309", "\u1EA9"=>"a\u0302\u0309", "\u1EAA"=>"A\u0302\u0303", "\u1EAB"=>"a\u0302\u0303", "\u1EAC"=>"A\u0323\u0302", "\u1EAD"=>"a\u0323\u0302",
+ "\u1EAE"=>"A\u0306\u0301", "\u1EAF"=>"a\u0306\u0301", "\u1EB0"=>"A\u0306\u0300", "\u1EB1"=>"a\u0306\u0300", "\u1EB2"=>"A\u0306\u0309", "\u1EB3"=>"a\u0306\u0309", "\u1EB4"=>"A\u0306\u0303", "\u1EB5"=>"a\u0306\u0303",
+ "\u1EB6"=>"A\u0323\u0306", "\u1EB7"=>"a\u0323\u0306", "\u1EB8"=>"E\u0323", "\u1EB9"=>"e\u0323", "\u1EBA"=>"E\u0309", "\u1EBB"=>"e\u0309", "\u1EBC"=>"E\u0303", "\u1EBD"=>"e\u0303",
+ "\u1EBE"=>"E\u0302\u0301", "\u1EBF"=>"e\u0302\u0301", "\u1EC0"=>"E\u0302\u0300", "\u1EC1"=>"e\u0302\u0300", "\u1EC2"=>"E\u0302\u0309", "\u1EC3"=>"e\u0302\u0309", "\u1EC4"=>"E\u0302\u0303", "\u1EC5"=>"e\u0302\u0303",
+ "\u1EC6"=>"E\u0323\u0302", "\u1EC7"=>"e\u0323\u0302", "\u1EC8"=>"I\u0309", "\u1EC9"=>"i\u0309", "\u1ECA"=>"I\u0323", "\u1ECB"=>"i\u0323", "\u1ECC"=>"O\u0323", "\u1ECD"=>"o\u0323",
+ "\u1ECE"=>"O\u0309", "\u1ECF"=>"o\u0309", "\u1ED0"=>"O\u0302\u0301", "\u1ED1"=>"o\u0302\u0301", "\u1ED2"=>"O\u0302\u0300", "\u1ED3"=>"o\u0302\u0300", "\u1ED4"=>"O\u0302\u0309", "\u1ED5"=>"o\u0302\u0309",
+ "\u1ED6"=>"O\u0302\u0303", "\u1ED7"=>"o\u0302\u0303", "\u1ED8"=>"O\u0323\u0302", "\u1ED9"=>"o\u0323\u0302", "\u1EDA"=>"O\u031B\u0301", "\u1EDB"=>"o\u031B\u0301", "\u1EDC"=>"O\u031B\u0300", "\u1EDD"=>"o\u031B\u0300",
+ "\u1EDE"=>"O\u031B\u0309", "\u1EDF"=>"o\u031B\u0309", "\u1EE0"=>"O\u031B\u0303", "\u1EE1"=>"o\u031B\u0303", "\u1EE2"=>"O\u031B\u0323", "\u1EE3"=>"o\u031B\u0323", "\u1EE4"=>"U\u0323", "\u1EE5"=>"u\u0323",
+ "\u1EE6"=>"U\u0309", "\u1EE7"=>"u\u0309", "\u1EE8"=>"U\u031B\u0301", "\u1EE9"=>"u\u031B\u0301", "\u1EEA"=>"U\u031B\u0300", "\u1EEB"=>"u\u031B\u0300", "\u1EEC"=>"U\u031B\u0309", "\u1EED"=>"u\u031B\u0309",
+ "\u1EEE"=>"U\u031B\u0303", "\u1EEF"=>"u\u031B\u0303", "\u1EF0"=>"U\u031B\u0323", "\u1EF1"=>"u\u031B\u0323", "\u1EF2"=>"Y\u0300", "\u1EF3"=>"y\u0300", "\u1EF4"=>"Y\u0323", "\u1EF5"=>"y\u0323",
+ "\u1EF6"=>"Y\u0309", "\u1EF7"=>"y\u0309", "\u1EF8"=>"Y\u0303", "\u1EF9"=>"y\u0303", "\u1F00"=>"\u03B1\u0313", "\u1F01"=>"\u03B1\u0314", "\u1F02"=>"\u03B1\u0313\u0300", "\u1F03"=>"\u03B1\u0314\u0300",
+ "\u1F04"=>"\u03B1\u0313\u0301", "\u1F05"=>"\u03B1\u0314\u0301", "\u1F06"=>"\u03B1\u0313\u0342", "\u1F07"=>"\u03B1\u0314\u0342", "\u1F08"=>"\u0391\u0313", "\u1F09"=>"\u0391\u0314", "\u1F0A"=>"\u0391\u0313\u0300", "\u1F0B"=>"\u0391\u0314\u0300",
+ "\u1F0C"=>"\u0391\u0313\u0301", "\u1F0D"=>"\u0391\u0314\u0301", "\u1F0E"=>"\u0391\u0313\u0342", "\u1F0F"=>"\u0391\u0314\u0342", "\u1F10"=>"\u03B5\u0313", "\u1F11"=>"\u03B5\u0314", "\u1F12"=>"\u03B5\u0313\u0300", "\u1F13"=>"\u03B5\u0314\u0300",
+ "\u1F14"=>"\u03B5\u0313\u0301", "\u1F15"=>"\u03B5\u0314\u0301", "\u1F18"=>"\u0395\u0313", "\u1F19"=>"\u0395\u0314", "\u1F1A"=>"\u0395\u0313\u0300", "\u1F1B"=>"\u0395\u0314\u0300", "\u1F1C"=>"\u0395\u0313\u0301", "\u1F1D"=>"\u0395\u0314\u0301",
+ "\u1F20"=>"\u03B7\u0313", "\u1F21"=>"\u03B7\u0314", "\u1F22"=>"\u03B7\u0313\u0300", "\u1F23"=>"\u03B7\u0314\u0300", "\u1F24"=>"\u03B7\u0313\u0301", "\u1F25"=>"\u03B7\u0314\u0301", "\u1F26"=>"\u03B7\u0313\u0342", "\u1F27"=>"\u03B7\u0314\u0342",
+ "\u1F28"=>"\u0397\u0313", "\u1F29"=>"\u0397\u0314", "\u1F2A"=>"\u0397\u0313\u0300", "\u1F2B"=>"\u0397\u0314\u0300", "\u1F2C"=>"\u0397\u0313\u0301", "\u1F2D"=>"\u0397\u0314\u0301", "\u1F2E"=>"\u0397\u0313\u0342", "\u1F2F"=>"\u0397\u0314\u0342",
+ "\u1F30"=>"\u03B9\u0313", "\u1F31"=>"\u03B9\u0314", "\u1F32"=>"\u03B9\u0313\u0300", "\u1F33"=>"\u03B9\u0314\u0300", "\u1F34"=>"\u03B9\u0313\u0301", "\u1F35"=>"\u03B9\u0314\u0301", "\u1F36"=>"\u03B9\u0313\u0342", "\u1F37"=>"\u03B9\u0314\u0342",
+ "\u1F38"=>"\u0399\u0313", "\u1F39"=>"\u0399\u0314", "\u1F3A"=>"\u0399\u0313\u0300", "\u1F3B"=>"\u0399\u0314\u0300", "\u1F3C"=>"\u0399\u0313\u0301", "\u1F3D"=>"\u0399\u0314\u0301", "\u1F3E"=>"\u0399\u0313\u0342", "\u1F3F"=>"\u0399\u0314\u0342",
+ "\u1F40"=>"\u03BF\u0313", "\u1F41"=>"\u03BF\u0314", "\u1F42"=>"\u03BF\u0313\u0300", "\u1F43"=>"\u03BF\u0314\u0300", "\u1F44"=>"\u03BF\u0313\u0301", "\u1F45"=>"\u03BF\u0314\u0301", "\u1F48"=>"\u039F\u0313", "\u1F49"=>"\u039F\u0314",
+ "\u1F4A"=>"\u039F\u0313\u0300", "\u1F4B"=>"\u039F\u0314\u0300", "\u1F4C"=>"\u039F\u0313\u0301", "\u1F4D"=>"\u039F\u0314\u0301", "\u1F50"=>"\u03C5\u0313", "\u1F51"=>"\u03C5\u0314", "\u1F52"=>"\u03C5\u0313\u0300", "\u1F53"=>"\u03C5\u0314\u0300",
+ "\u1F54"=>"\u03C5\u0313\u0301", "\u1F55"=>"\u03C5\u0314\u0301", "\u1F56"=>"\u03C5\u0313\u0342", "\u1F57"=>"\u03C5\u0314\u0342", "\u1F59"=>"\u03A5\u0314", "\u1F5B"=>"\u03A5\u0314\u0300", "\u1F5D"=>"\u03A5\u0314\u0301", "\u1F5F"=>"\u03A5\u0314\u0342",
+ "\u1F60"=>"\u03C9\u0313", "\u1F61"=>"\u03C9\u0314", "\u1F62"=>"\u03C9\u0313\u0300", "\u1F63"=>"\u03C9\u0314\u0300", "\u1F64"=>"\u03C9\u0313\u0301", "\u1F65"=>"\u03C9\u0314\u0301", "\u1F66"=>"\u03C9\u0313\u0342", "\u1F67"=>"\u03C9\u0314\u0342",
+ "\u1F68"=>"\u03A9\u0313", "\u1F69"=>"\u03A9\u0314", "\u1F6A"=>"\u03A9\u0313\u0300", "\u1F6B"=>"\u03A9\u0314\u0300", "\u1F6C"=>"\u03A9\u0313\u0301", "\u1F6D"=>"\u03A9\u0314\u0301", "\u1F6E"=>"\u03A9\u0313\u0342", "\u1F6F"=>"\u03A9\u0314\u0342",
+ "\u1F70"=>"\u03B1\u0300", "\u1F71"=>"\u03B1\u0301", "\u1F72"=>"\u03B5\u0300", "\u1F73"=>"\u03B5\u0301", "\u1F74"=>"\u03B7\u0300", "\u1F75"=>"\u03B7\u0301", "\u1F76"=>"\u03B9\u0300", "\u1F77"=>"\u03B9\u0301",
+ "\u1F78"=>"\u03BF\u0300", "\u1F79"=>"\u03BF\u0301", "\u1F7A"=>"\u03C5\u0300", "\u1F7B"=>"\u03C5\u0301", "\u1F7C"=>"\u03C9\u0300", "\u1F7D"=>"\u03C9\u0301", "\u1F80"=>"\u03B1\u0313\u0345", "\u1F81"=>"\u03B1\u0314\u0345",
+ "\u1F82"=>"\u03B1\u0313\u0300\u0345", "\u1F83"=>"\u03B1\u0314\u0300\u0345", "\u1F84"=>"\u03B1\u0313\u0301\u0345", "\u1F85"=>"\u03B1\u0314\u0301\u0345", "\u1F86"=>"\u03B1\u0313\u0342\u0345", "\u1F87"=>"\u03B1\u0314\u0342\u0345", "\u1F88"=>"\u0391\u0313\u0345", "\u1F89"=>"\u0391\u0314\u0345",
+ "\u1F8A"=>"\u0391\u0313\u0300\u0345", "\u1F8B"=>"\u0391\u0314\u0300\u0345", "\u1F8C"=>"\u0391\u0313\u0301\u0345", "\u1F8D"=>"\u0391\u0314\u0301\u0345", "\u1F8E"=>"\u0391\u0313\u0342\u0345", "\u1F8F"=>"\u0391\u0314\u0342\u0345", "\u1F90"=>"\u03B7\u0313\u0345", "\u1F91"=>"\u03B7\u0314\u0345",
+ "\u1F92"=>"\u03B7\u0313\u0300\u0345", "\u1F93"=>"\u03B7\u0314\u0300\u0345", "\u1F94"=>"\u03B7\u0313\u0301\u0345", "\u1F95"=>"\u03B7\u0314\u0301\u0345", "\u1F96"=>"\u03B7\u0313\u0342\u0345", "\u1F97"=>"\u03B7\u0314\u0342\u0345", "\u1F98"=>"\u0397\u0313\u0345", "\u1F99"=>"\u0397\u0314\u0345",
+ "\u1F9A"=>"\u0397\u0313\u0300\u0345", "\u1F9B"=>"\u0397\u0314\u0300\u0345", "\u1F9C"=>"\u0397\u0313\u0301\u0345", "\u1F9D"=>"\u0397\u0314\u0301\u0345", "\u1F9E"=>"\u0397\u0313\u0342\u0345", "\u1F9F"=>"\u0397\u0314\u0342\u0345", "\u1FA0"=>"\u03C9\u0313\u0345", "\u1FA1"=>"\u03C9\u0314\u0345",
+ "\u1FA2"=>"\u03C9\u0313\u0300\u0345", "\u1FA3"=>"\u03C9\u0314\u0300\u0345", "\u1FA4"=>"\u03C9\u0313\u0301\u0345", "\u1FA5"=>"\u03C9\u0314\u0301\u0345", "\u1FA6"=>"\u03C9\u0313\u0342\u0345", "\u1FA7"=>"\u03C9\u0314\u0342\u0345", "\u1FA8"=>"\u03A9\u0313\u0345", "\u1FA9"=>"\u03A9\u0314\u0345",
+ "\u1FAA"=>"\u03A9\u0313\u0300\u0345", "\u1FAB"=>"\u03A9\u0314\u0300\u0345", "\u1FAC"=>"\u03A9\u0313\u0301\u0345", "\u1FAD"=>"\u03A9\u0314\u0301\u0345", "\u1FAE"=>"\u03A9\u0313\u0342\u0345", "\u1FAF"=>"\u03A9\u0314\u0342\u0345", "\u1FB0"=>"\u03B1\u0306", "\u1FB1"=>"\u03B1\u0304",
+ "\u1FB2"=>"\u03B1\u0300\u0345", "\u1FB3"=>"\u03B1\u0345", "\u1FB4"=>"\u03B1\u0301\u0345", "\u1FB6"=>"\u03B1\u0342", "\u1FB7"=>"\u03B1\u0342\u0345", "\u1FB8"=>"\u0391\u0306", "\u1FB9"=>"\u0391\u0304", "\u1FBA"=>"\u0391\u0300",
+ "\u1FBB"=>"\u0391\u0301", "\u1FBC"=>"\u0391\u0345", "\u1FBE"=>"\u03B9", "\u1FC1"=>"\u00A8\u0342", "\u1FC2"=>"\u03B7\u0300\u0345", "\u1FC3"=>"\u03B7\u0345", "\u1FC4"=>"\u03B7\u0301\u0345", "\u1FC6"=>"\u03B7\u0342",
+ "\u1FC7"=>"\u03B7\u0342\u0345", "\u1FC8"=>"\u0395\u0300", "\u1FC9"=>"\u0395\u0301", "\u1FCA"=>"\u0397\u0300", "\u1FCB"=>"\u0397\u0301", "\u1FCC"=>"\u0397\u0345", "\u1FCD"=>"\u1FBF\u0300", "\u1FCE"=>"\u1FBF\u0301",
+ "\u1FCF"=>"\u1FBF\u0342", "\u1FD0"=>"\u03B9\u0306", "\u1FD1"=>"\u03B9\u0304", "\u1FD2"=>"\u03B9\u0308\u0300", "\u1FD3"=>"\u03B9\u0308\u0301", "\u1FD6"=>"\u03B9\u0342", "\u1FD7"=>"\u03B9\u0308\u0342", "\u1FD8"=>"\u0399\u0306",
+ "\u1FD9"=>"\u0399\u0304", "\u1FDA"=>"\u0399\u0300", "\u1FDB"=>"\u0399\u0301", "\u1FDD"=>"\u1FFE\u0300", "\u1FDE"=>"\u1FFE\u0301", "\u1FDF"=>"\u1FFE\u0342", "\u1FE0"=>"\u03C5\u0306", "\u1FE1"=>"\u03C5\u0304",
+ "\u1FE2"=>"\u03C5\u0308\u0300", "\u1FE3"=>"\u03C5\u0308\u0301", "\u1FE4"=>"\u03C1\u0313", "\u1FE5"=>"\u03C1\u0314", "\u1FE6"=>"\u03C5\u0342", "\u1FE7"=>"\u03C5\u0308\u0342", "\u1FE8"=>"\u03A5\u0306", "\u1FE9"=>"\u03A5\u0304",
+ "\u1FEA"=>"\u03A5\u0300", "\u1FEB"=>"\u03A5\u0301", "\u1FEC"=>"\u03A1\u0314", "\u1FED"=>"\u00A8\u0300", "\u1FEE"=>"\u00A8\u0301", "\u1FEF"=>"`", "\u1FF2"=>"\u03C9\u0300\u0345", "\u1FF3"=>"\u03C9\u0345",
+ "\u1FF4"=>"\u03C9\u0301\u0345", "\u1FF6"=>"\u03C9\u0342", "\u1FF7"=>"\u03C9\u0342\u0345", "\u1FF8"=>"\u039F\u0300", "\u1FF9"=>"\u039F\u0301", "\u1FFA"=>"\u03A9\u0300", "\u1FFB"=>"\u03A9\u0301", "\u1FFC"=>"\u03A9\u0345",
+ "\u1FFD"=>"\u00B4", "\u2000"=>"\u2002", "\u2001"=>"\u2003", "\u2126"=>"\u03A9", "\u212A"=>"K", "\u212B"=>"A\u030A", "\u219A"=>"\u2190\u0338", "\u219B"=>"\u2192\u0338",
+ "\u21AE"=>"\u2194\u0338", "\u21CD"=>"\u21D0\u0338", "\u21CE"=>"\u21D4\u0338", "\u21CF"=>"\u21D2\u0338", "\u2204"=>"\u2203\u0338", "\u2209"=>"\u2208\u0338", "\u220C"=>"\u220B\u0338", "\u2224"=>"\u2223\u0338",
+ "\u2226"=>"\u2225\u0338", "\u2241"=>"\u223C\u0338", "\u2244"=>"\u2243\u0338", "\u2247"=>"\u2245\u0338", "\u2249"=>"\u2248\u0338", "\u2260"=>"=\u0338", "\u2262"=>"\u2261\u0338", "\u226D"=>"\u224D\u0338",
+ "\u226E"=>"<\u0338", "\u226F"=>">\u0338", "\u2270"=>"\u2264\u0338", "\u2271"=>"\u2265\u0338", "\u2274"=>"\u2272\u0338", "\u2275"=>"\u2273\u0338", "\u2278"=>"\u2276\u0338", "\u2279"=>"\u2277\u0338",
+ "\u2280"=>"\u227A\u0338", "\u2281"=>"\u227B\u0338", "\u2284"=>"\u2282\u0338", "\u2285"=>"\u2283\u0338", "\u2288"=>"\u2286\u0338", "\u2289"=>"\u2287\u0338", "\u22AC"=>"\u22A2\u0338", "\u22AD"=>"\u22A8\u0338",
+ "\u22AE"=>"\u22A9\u0338", "\u22AF"=>"\u22AB\u0338", "\u22E0"=>"\u227C\u0338", "\u22E1"=>"\u227D\u0338", "\u22E2"=>"\u2291\u0338", "\u22E3"=>"\u2292\u0338", "\u22EA"=>"\u22B2\u0338", "\u22EB"=>"\u22B3\u0338",
+ "\u22EC"=>"\u22B4\u0338", "\u22ED"=>"\u22B5\u0338", "\u2329"=>"\u3008", "\u232A"=>"\u3009", "\u2ADC"=>"\u2ADD\u0338", "\u304C"=>"\u304B\u3099", "\u304E"=>"\u304D\u3099", "\u3050"=>"\u304F\u3099",
+ "\u3052"=>"\u3051\u3099", "\u3054"=>"\u3053\u3099", "\u3056"=>"\u3055\u3099", "\u3058"=>"\u3057\u3099", "\u305A"=>"\u3059\u3099", "\u305C"=>"\u305B\u3099", "\u305E"=>"\u305D\u3099", "\u3060"=>"\u305F\u3099",
+ "\u3062"=>"\u3061\u3099", "\u3065"=>"\u3064\u3099", "\u3067"=>"\u3066\u3099", "\u3069"=>"\u3068\u3099", "\u3070"=>"\u306F\u3099", "\u3071"=>"\u306F\u309A", "\u3073"=>"\u3072\u3099", "\u3074"=>"\u3072\u309A",
+ "\u3076"=>"\u3075\u3099", "\u3077"=>"\u3075\u309A", "\u3079"=>"\u3078\u3099", "\u307A"=>"\u3078\u309A", "\u307C"=>"\u307B\u3099", "\u307D"=>"\u307B\u309A", "\u3094"=>"\u3046\u3099", "\u309E"=>"\u309D\u3099",
+ "\u30AC"=>"\u30AB\u3099", "\u30AE"=>"\u30AD\u3099", "\u30B0"=>"\u30AF\u3099", "\u30B2"=>"\u30B1\u3099", "\u30B4"=>"\u30B3\u3099", "\u30B6"=>"\u30B5\u3099", "\u30B8"=>"\u30B7\u3099", "\u30BA"=>"\u30B9\u3099",
+ "\u30BC"=>"\u30BB\u3099", "\u30BE"=>"\u30BD\u3099", "\u30C0"=>"\u30BF\u3099", "\u30C2"=>"\u30C1\u3099", "\u30C5"=>"\u30C4\u3099", "\u30C7"=>"\u30C6\u3099", "\u30C9"=>"\u30C8\u3099", "\u30D0"=>"\u30CF\u3099",
+ "\u30D1"=>"\u30CF\u309A", "\u30D3"=>"\u30D2\u3099", "\u30D4"=>"\u30D2\u309A", "\u30D6"=>"\u30D5\u3099", "\u30D7"=>"\u30D5\u309A", "\u30D9"=>"\u30D8\u3099", "\u30DA"=>"\u30D8\u309A", "\u30DC"=>"\u30DB\u3099",
+ "\u30DD"=>"\u30DB\u309A", "\u30F4"=>"\u30A6\u3099", "\u30F7"=>"\u30EF\u3099", "\u30F8"=>"\u30F0\u3099", "\u30F9"=>"\u30F1\u3099", "\u30FA"=>"\u30F2\u3099", "\u30FE"=>"\u30FD\u3099", "\uF900"=>"\u8C48",
+ "\uF901"=>"\u66F4", "\uF902"=>"\u8ECA", "\uF903"=>"\u8CC8", "\uF904"=>"\u6ED1", "\uF905"=>"\u4E32", "\uF906"=>"\u53E5", "\uF907"=>"\u9F9C", "\uF908"=>"\u9F9C",
+ "\uF909"=>"\u5951", "\uF90A"=>"\u91D1", "\uF90B"=>"\u5587", "\uF90C"=>"\u5948", "\uF90D"=>"\u61F6", "\uF90E"=>"\u7669", "\uF90F"=>"\u7F85", "\uF910"=>"\u863F",
+ "\uF911"=>"\u87BA", "\uF912"=>"\u88F8", "\uF913"=>"\u908F", "\uF914"=>"\u6A02", "\uF915"=>"\u6D1B", "\uF916"=>"\u70D9", "\uF917"=>"\u73DE", "\uF918"=>"\u843D",
+ "\uF919"=>"\u916A", "\uF91A"=>"\u99F1", "\uF91B"=>"\u4E82", "\uF91C"=>"\u5375", "\uF91D"=>"\u6B04", "\uF91E"=>"\u721B", "\uF91F"=>"\u862D", "\uF920"=>"\u9E1E",
+ "\uF921"=>"\u5D50", "\uF922"=>"\u6FEB", "\uF923"=>"\u85CD", "\uF924"=>"\u8964", "\uF925"=>"\u62C9", "\uF926"=>"\u81D8", "\uF927"=>"\u881F", "\uF928"=>"\u5ECA",
+ "\uF929"=>"\u6717", "\uF92A"=>"\u6D6A", "\uF92B"=>"\u72FC", "\uF92C"=>"\u90CE", "\uF92D"=>"\u4F86", "\uF92E"=>"\u51B7", "\uF92F"=>"\u52DE", "\uF930"=>"\u64C4",
+ "\uF931"=>"\u6AD3", "\uF932"=>"\u7210", "\uF933"=>"\u76E7", "\uF934"=>"\u8001", "\uF935"=>"\u8606", "\uF936"=>"\u865C", "\uF937"=>"\u8DEF", "\uF938"=>"\u9732",
+ "\uF939"=>"\u9B6F", "\uF93A"=>"\u9DFA", "\uF93B"=>"\u788C", "\uF93C"=>"\u797F", "\uF93D"=>"\u7DA0", "\uF93E"=>"\u83C9", "\uF93F"=>"\u9304", "\uF940"=>"\u9E7F",
+ "\uF941"=>"\u8AD6", "\uF942"=>"\u58DF", "\uF943"=>"\u5F04", "\uF944"=>"\u7C60", "\uF945"=>"\u807E", "\uF946"=>"\u7262", "\uF947"=>"\u78CA", "\uF948"=>"\u8CC2",
+ "\uF949"=>"\u96F7", "\uF94A"=>"\u58D8", "\uF94B"=>"\u5C62", "\uF94C"=>"\u6A13", "\uF94D"=>"\u6DDA", "\uF94E"=>"\u6F0F", "\uF94F"=>"\u7D2F", "\uF950"=>"\u7E37",
+ "\uF951"=>"\u964B", "\uF952"=>"\u52D2", "\uF953"=>"\u808B", "\uF954"=>"\u51DC", "\uF955"=>"\u51CC", "\uF956"=>"\u7A1C", "\uF957"=>"\u7DBE", "\uF958"=>"\u83F1",
+ "\uF959"=>"\u9675", "\uF95A"=>"\u8B80", "\uF95B"=>"\u62CF", "\uF95C"=>"\u6A02", "\uF95D"=>"\u8AFE", "\uF95E"=>"\u4E39", "\uF95F"=>"\u5BE7", "\uF960"=>"\u6012",
+ "\uF961"=>"\u7387", "\uF962"=>"\u7570", "\uF963"=>"\u5317", "\uF964"=>"\u78FB", "\uF965"=>"\u4FBF", "\uF966"=>"\u5FA9", "\uF967"=>"\u4E0D", "\uF968"=>"\u6CCC",
+ "\uF969"=>"\u6578", "\uF96A"=>"\u7D22", "\uF96B"=>"\u53C3", "\uF96C"=>"\u585E", "\uF96D"=>"\u7701", "\uF96E"=>"\u8449", "\uF96F"=>"\u8AAA", "\uF970"=>"\u6BBA",
+ "\uF971"=>"\u8FB0", "\uF972"=>"\u6C88", "\uF973"=>"\u62FE", "\uF974"=>"\u82E5", "\uF975"=>"\u63A0", "\uF976"=>"\u7565", "\uF977"=>"\u4EAE", "\uF978"=>"\u5169",
+ "\uF979"=>"\u51C9", "\uF97A"=>"\u6881", "\uF97B"=>"\u7CE7", "\uF97C"=>"\u826F", "\uF97D"=>"\u8AD2", "\uF97E"=>"\u91CF", "\uF97F"=>"\u52F5", "\uF980"=>"\u5442",
+ "\uF981"=>"\u5973", "\uF982"=>"\u5EEC", "\uF983"=>"\u65C5", "\uF984"=>"\u6FFE", "\uF985"=>"\u792A", "\uF986"=>"\u95AD", "\uF987"=>"\u9A6A", "\uF988"=>"\u9E97",
+ "\uF989"=>"\u9ECE", "\uF98A"=>"\u529B", "\uF98B"=>"\u66C6", "\uF98C"=>"\u6B77", "\uF98D"=>"\u8F62", "\uF98E"=>"\u5E74", "\uF98F"=>"\u6190", "\uF990"=>"\u6200",
+ "\uF991"=>"\u649A", "\uF992"=>"\u6F23", "\uF993"=>"\u7149", "\uF994"=>"\u7489", "\uF995"=>"\u79CA", "\uF996"=>"\u7DF4", "\uF997"=>"\u806F", "\uF998"=>"\u8F26",
+ "\uF999"=>"\u84EE", "\uF99A"=>"\u9023", "\uF99B"=>"\u934A", "\uF99C"=>"\u5217", "\uF99D"=>"\u52A3", "\uF99E"=>"\u54BD", "\uF99F"=>"\u70C8", "\uF9A0"=>"\u88C2",
+ "\uF9A1"=>"\u8AAA", "\uF9A2"=>"\u5EC9", "\uF9A3"=>"\u5FF5", "\uF9A4"=>"\u637B", "\uF9A5"=>"\u6BAE", "\uF9A6"=>"\u7C3E", "\uF9A7"=>"\u7375", "\uF9A8"=>"\u4EE4",
+ "\uF9A9"=>"\u56F9", "\uF9AA"=>"\u5BE7", "\uF9AB"=>"\u5DBA", "\uF9AC"=>"\u601C", "\uF9AD"=>"\u73B2", "\uF9AE"=>"\u7469", "\uF9AF"=>"\u7F9A", "\uF9B0"=>"\u8046",
+ "\uF9B1"=>"\u9234", "\uF9B2"=>"\u96F6", "\uF9B3"=>"\u9748", "\uF9B4"=>"\u9818", "\uF9B5"=>"\u4F8B", "\uF9B6"=>"\u79AE", "\uF9B7"=>"\u91B4", "\uF9B8"=>"\u96B8",
+ "\uF9B9"=>"\u60E1", "\uF9BA"=>"\u4E86", "\uF9BB"=>"\u50DA", "\uF9BC"=>"\u5BEE", "\uF9BD"=>"\u5C3F", "\uF9BE"=>"\u6599", "\uF9BF"=>"\u6A02", "\uF9C0"=>"\u71CE",
+ "\uF9C1"=>"\u7642", "\uF9C2"=>"\u84FC", "\uF9C3"=>"\u907C", "\uF9C4"=>"\u9F8D", "\uF9C5"=>"\u6688", "\uF9C6"=>"\u962E", "\uF9C7"=>"\u5289", "\uF9C8"=>"\u677B",
+ "\uF9C9"=>"\u67F3", "\uF9CA"=>"\u6D41", "\uF9CB"=>"\u6E9C", "\uF9CC"=>"\u7409", "\uF9CD"=>"\u7559", "\uF9CE"=>"\u786B", "\uF9CF"=>"\u7D10", "\uF9D0"=>"\u985E",
+ "\uF9D1"=>"\u516D", "\uF9D2"=>"\u622E", "\uF9D3"=>"\u9678", "\uF9D4"=>"\u502B", "\uF9D5"=>"\u5D19", "\uF9D6"=>"\u6DEA", "\uF9D7"=>"\u8F2A", "\uF9D8"=>"\u5F8B",
+ "\uF9D9"=>"\u6144", "\uF9DA"=>"\u6817", "\uF9DB"=>"\u7387", "\uF9DC"=>"\u9686", "\uF9DD"=>"\u5229", "\uF9DE"=>"\u540F", "\uF9DF"=>"\u5C65", "\uF9E0"=>"\u6613",
+ "\uF9E1"=>"\u674E", "\uF9E2"=>"\u68A8", "\uF9E3"=>"\u6CE5", "\uF9E4"=>"\u7406", "\uF9E5"=>"\u75E2", "\uF9E6"=>"\u7F79", "\uF9E7"=>"\u88CF", "\uF9E8"=>"\u88E1",
+ "\uF9E9"=>"\u91CC", "\uF9EA"=>"\u96E2", "\uF9EB"=>"\u533F", "\uF9EC"=>"\u6EBA", "\uF9ED"=>"\u541D", "\uF9EE"=>"\u71D0", "\uF9EF"=>"\u7498", "\uF9F0"=>"\u85FA",
+ "\uF9F1"=>"\u96A3", "\uF9F2"=>"\u9C57", "\uF9F3"=>"\u9E9F", "\uF9F4"=>"\u6797", "\uF9F5"=>"\u6DCB", "\uF9F6"=>"\u81E8", "\uF9F7"=>"\u7ACB", "\uF9F8"=>"\u7B20",
+ "\uF9F9"=>"\u7C92", "\uF9FA"=>"\u72C0", "\uF9FB"=>"\u7099", "\uF9FC"=>"\u8B58", "\uF9FD"=>"\u4EC0", "\uF9FE"=>"\u8336", "\uF9FF"=>"\u523A", "\uFA00"=>"\u5207",
+ "\uFA01"=>"\u5EA6", "\uFA02"=>"\u62D3", "\uFA03"=>"\u7CD6", "\uFA04"=>"\u5B85", "\uFA05"=>"\u6D1E", "\uFA06"=>"\u66B4", "\uFA07"=>"\u8F3B", "\uFA08"=>"\u884C",
+ "\uFA09"=>"\u964D", "\uFA0A"=>"\u898B", "\uFA0B"=>"\u5ED3", "\uFA0C"=>"\u5140", "\uFA0D"=>"\u55C0", "\uFA10"=>"\u585A", "\uFA12"=>"\u6674", "\uFA15"=>"\u51DE",
+ "\uFA16"=>"\u732A", "\uFA17"=>"\u76CA", "\uFA18"=>"\u793C", "\uFA19"=>"\u795E", "\uFA1A"=>"\u7965", "\uFA1B"=>"\u798F", "\uFA1C"=>"\u9756", "\uFA1D"=>"\u7CBE",
+ "\uFA1E"=>"\u7FBD", "\uFA20"=>"\u8612", "\uFA22"=>"\u8AF8", "\uFA25"=>"\u9038", "\uFA26"=>"\u90FD", "\uFA2A"=>"\u98EF", "\uFA2B"=>"\u98FC", "\uFA2C"=>"\u9928",
+ "\uFA2D"=>"\u9DB4", "\uFA2E"=>"\u90DE", "\uFA2F"=>"\u96B7", "\uFA30"=>"\u4FAE", "\uFA31"=>"\u50E7", "\uFA32"=>"\u514D", "\uFA33"=>"\u52C9", "\uFA34"=>"\u52E4",
+ "\uFA35"=>"\u5351", "\uFA36"=>"\u559D", "\uFA37"=>"\u5606", "\uFA38"=>"\u5668", "\uFA39"=>"\u5840", "\uFA3A"=>"\u58A8", "\uFA3B"=>"\u5C64", "\uFA3C"=>"\u5C6E",
+ "\uFA3D"=>"\u6094", "\uFA3E"=>"\u6168", "\uFA3F"=>"\u618E", "\uFA40"=>"\u61F2", "\uFA41"=>"\u654F", "\uFA42"=>"\u65E2", "\uFA43"=>"\u6691", "\uFA44"=>"\u6885",
+ "\uFA45"=>"\u6D77", "\uFA46"=>"\u6E1A", "\uFA47"=>"\u6F22", "\uFA48"=>"\u716E", "\uFA49"=>"\u722B", "\uFA4A"=>"\u7422", "\uFA4B"=>"\u7891", "\uFA4C"=>"\u793E",
+ "\uFA4D"=>"\u7949", "\uFA4E"=>"\u7948", "\uFA4F"=>"\u7950", "\uFA50"=>"\u7956", "\uFA51"=>"\u795D", "\uFA52"=>"\u798D", "\uFA53"=>"\u798E", "\uFA54"=>"\u7A40",
+ "\uFA55"=>"\u7A81", "\uFA56"=>"\u7BC0", "\uFA57"=>"\u7DF4", "\uFA58"=>"\u7E09", "\uFA59"=>"\u7E41", "\uFA5A"=>"\u7F72", "\uFA5B"=>"\u8005", "\uFA5C"=>"\u81ED",
+ "\uFA5D"=>"\u8279", "\uFA5E"=>"\u8279", "\uFA5F"=>"\u8457", "\uFA60"=>"\u8910", "\uFA61"=>"\u8996", "\uFA62"=>"\u8B01", "\uFA63"=>"\u8B39", "\uFA64"=>"\u8CD3",
+ "\uFA65"=>"\u8D08", "\uFA66"=>"\u8FB6", "\uFA67"=>"\u9038", "\uFA68"=>"\u96E3", "\uFA69"=>"\u97FF", "\uFA6A"=>"\u983B", "\uFA6B"=>"\u6075", "\uFA6C"=>"\u{242EE}",
+ "\uFA6D"=>"\u8218", "\uFA70"=>"\u4E26", "\uFA71"=>"\u51B5", "\uFA72"=>"\u5168", "\uFA73"=>"\u4F80", "\uFA74"=>"\u5145", "\uFA75"=>"\u5180", "\uFA76"=>"\u52C7",
+ "\uFA77"=>"\u52FA", "\uFA78"=>"\u559D", "\uFA79"=>"\u5555", "\uFA7A"=>"\u5599", "\uFA7B"=>"\u55E2", "\uFA7C"=>"\u585A", "\uFA7D"=>"\u58B3", "\uFA7E"=>"\u5944",
+ "\uFA7F"=>"\u5954", "\uFA80"=>"\u5A62", "\uFA81"=>"\u5B28", "\uFA82"=>"\u5ED2", "\uFA83"=>"\u5ED9", "\uFA84"=>"\u5F69", "\uFA85"=>"\u5FAD", "\uFA86"=>"\u60D8",
+ "\uFA87"=>"\u614E", "\uFA88"=>"\u6108", "\uFA89"=>"\u618E", "\uFA8A"=>"\u6160", "\uFA8B"=>"\u61F2", "\uFA8C"=>"\u6234", "\uFA8D"=>"\u63C4", "\uFA8E"=>"\u641C",
+ "\uFA8F"=>"\u6452", "\uFA90"=>"\u6556", "\uFA91"=>"\u6674", "\uFA92"=>"\u6717", "\uFA93"=>"\u671B", "\uFA94"=>"\u6756", "\uFA95"=>"\u6B79", "\uFA96"=>"\u6BBA",
+ "\uFA97"=>"\u6D41", "\uFA98"=>"\u6EDB", "\uFA99"=>"\u6ECB", "\uFA9A"=>"\u6F22", "\uFA9B"=>"\u701E", "\uFA9C"=>"\u716E", "\uFA9D"=>"\u77A7", "\uFA9E"=>"\u7235",
+ "\uFA9F"=>"\u72AF", "\uFAA0"=>"\u732A", "\uFAA1"=>"\u7471", "\uFAA2"=>"\u7506", "\uFAA3"=>"\u753B", "\uFAA4"=>"\u761D", "\uFAA5"=>"\u761F", "\uFAA6"=>"\u76CA",
+ "\uFAA7"=>"\u76DB", "\uFAA8"=>"\u76F4", "\uFAA9"=>"\u774A", "\uFAAA"=>"\u7740", "\uFAAB"=>"\u78CC", "\uFAAC"=>"\u7AB1", "\uFAAD"=>"\u7BC0", "\uFAAE"=>"\u7C7B",
+ "\uFAAF"=>"\u7D5B", "\uFAB0"=>"\u7DF4", "\uFAB1"=>"\u7F3E", "\uFAB2"=>"\u8005", "\uFAB3"=>"\u8352", "\uFAB4"=>"\u83EF", "\uFAB5"=>"\u8779", "\uFAB6"=>"\u8941",
+ "\uFAB7"=>"\u8986", "\uFAB8"=>"\u8996", "\uFAB9"=>"\u8ABF", "\uFABA"=>"\u8AF8", "\uFABB"=>"\u8ACB", "\uFABC"=>"\u8B01", "\uFABD"=>"\u8AFE", "\uFABE"=>"\u8AED",
+ "\uFABF"=>"\u8B39", "\uFAC0"=>"\u8B8A", "\uFAC1"=>"\u8D08", "\uFAC2"=>"\u8F38", "\uFAC3"=>"\u9072", "\uFAC4"=>"\u9199", "\uFAC5"=>"\u9276", "\uFAC6"=>"\u967C",
+ "\uFAC7"=>"\u96E3", "\uFAC8"=>"\u9756", "\uFAC9"=>"\u97DB", "\uFACA"=>"\u97FF", "\uFACB"=>"\u980B", "\uFACC"=>"\u983B", "\uFACD"=>"\u9B12", "\uFACE"=>"\u9F9C",
+ "\uFACF"=>"\u{2284A}", "\uFAD0"=>"\u{22844}", "\uFAD1"=>"\u{233D5}", "\uFAD2"=>"\u3B9D", "\uFAD3"=>"\u4018", "\uFAD4"=>"\u4039", "\uFAD5"=>"\u{25249}", "\uFAD6"=>"\u{25CD0}",
+ "\uFAD7"=>"\u{27ED3}", "\uFAD8"=>"\u9F43", "\uFAD9"=>"\u9F8E", "\uFB1D"=>"\u05D9\u05B4", "\uFB1F"=>"\u05F2\u05B7", "\uFB2A"=>"\u05E9\u05C1", "\uFB2B"=>"\u05E9\u05C2", "\uFB2C"=>"\u05E9\u05BC\u05C1",
+ "\uFB2D"=>"\u05E9\u05BC\u05C2", "\uFB2E"=>"\u05D0\u05B7", "\uFB2F"=>"\u05D0\u05B8", "\uFB30"=>"\u05D0\u05BC", "\uFB31"=>"\u05D1\u05BC", "\uFB32"=>"\u05D2\u05BC", "\uFB33"=>"\u05D3\u05BC", "\uFB34"=>"\u05D4\u05BC",
+ "\uFB35"=>"\u05D5\u05BC", "\uFB36"=>"\u05D6\u05BC", "\uFB38"=>"\u05D8\u05BC", "\uFB39"=>"\u05D9\u05BC", "\uFB3A"=>"\u05DA\u05BC", "\uFB3B"=>"\u05DB\u05BC", "\uFB3C"=>"\u05DC\u05BC", "\uFB3E"=>"\u05DE\u05BC",
+ "\uFB40"=>"\u05E0\u05BC", "\uFB41"=>"\u05E1\u05BC", "\uFB43"=>"\u05E3\u05BC", "\uFB44"=>"\u05E4\u05BC", "\uFB46"=>"\u05E6\u05BC", "\uFB47"=>"\u05E7\u05BC", "\uFB48"=>"\u05E8\u05BC", "\uFB49"=>"\u05E9\u05BC",
+ "\uFB4A"=>"\u05EA\u05BC", "\uFB4B"=>"\u05D5\u05B9", "\uFB4C"=>"\u05D1\u05BF", "\uFB4D"=>"\u05DB\u05BF", "\uFB4E"=>"\u05E4\u05BF", "\u{1109A}"=>"\u{11099}\u{110BA}", "\u{1109C}"=>"\u{1109B}\u{110BA}", "\u{110AB}"=>"\u{110A5}\u{110BA}",
+ "\u{1112E}"=>"\u{11131}\u{11127}", "\u{1112F}"=>"\u{11132}\u{11127}", "\u{1134B}"=>"\u{11347}\u{1133E}", "\u{1134C}"=>"\u{11347}\u{11357}", "\u{114BB}"=>"\u{114B9}\u{114BA}", "\u{114BC}"=>"\u{114B9}\u{114B0}", "\u{114BE}"=>"\u{114B9}\u{114BD}", "\u{115BA}"=>"\u{115B8}\u{115AF}",
+ "\u{115BB}"=>"\u{115B9}\u{115AF}", "\u{1D15E}"=>"\u{1D157}\u{1D165}", "\u{1D15F}"=>"\u{1D158}\u{1D165}", "\u{1D160}"=>"\u{1D158}\u{1D165}\u{1D16E}", "\u{1D161}"=>"\u{1D158}\u{1D165}\u{1D16F}", "\u{1D162}"=>"\u{1D158}\u{1D165}\u{1D170}", "\u{1D163}"=>"\u{1D158}\u{1D165}\u{1D171}", "\u{1D164}"=>"\u{1D158}\u{1D165}\u{1D172}",
+ "\u{1D1BB}"=>"\u{1D1B9}\u{1D165}", "\u{1D1BC}"=>"\u{1D1BA}\u{1D165}", "\u{1D1BD}"=>"\u{1D1B9}\u{1D165}\u{1D16E}", "\u{1D1BE}"=>"\u{1D1BA}\u{1D165}\u{1D16E}", "\u{1D1BF}"=>"\u{1D1B9}\u{1D165}\u{1D16F}", "\u{1D1C0}"=>"\u{1D1BA}\u{1D165}\u{1D16F}", "\u{2F800}"=>"\u4E3D", "\u{2F801}"=>"\u4E38",
+ "\u{2F802}"=>"\u4E41", "\u{2F803}"=>"\u{20122}", "\u{2F804}"=>"\u4F60", "\u{2F805}"=>"\u4FAE", "\u{2F806}"=>"\u4FBB", "\u{2F807}"=>"\u5002", "\u{2F808}"=>"\u507A", "\u{2F809}"=>"\u5099",
+ "\u{2F80A}"=>"\u50E7", "\u{2F80B}"=>"\u50CF", "\u{2F80C}"=>"\u349E", "\u{2F80D}"=>"\u{2063A}", "\u{2F80E}"=>"\u514D", "\u{2F80F}"=>"\u5154", "\u{2F810}"=>"\u5164", "\u{2F811}"=>"\u5177",
+ "\u{2F812}"=>"\u{2051C}", "\u{2F813}"=>"\u34B9", "\u{2F814}"=>"\u5167", "\u{2F815}"=>"\u518D", "\u{2F816}"=>"\u{2054B}", "\u{2F817}"=>"\u5197", "\u{2F818}"=>"\u51A4", "\u{2F819}"=>"\u4ECC",
+ "\u{2F81A}"=>"\u51AC", "\u{2F81B}"=>"\u51B5", "\u{2F81C}"=>"\u{291DF}", "\u{2F81D}"=>"\u51F5", "\u{2F81E}"=>"\u5203", "\u{2F81F}"=>"\u34DF", "\u{2F820}"=>"\u523B", "\u{2F821}"=>"\u5246",
+ "\u{2F822}"=>"\u5272", "\u{2F823}"=>"\u5277", "\u{2F824}"=>"\u3515", "\u{2F825}"=>"\u52C7", "\u{2F826}"=>"\u52C9", "\u{2F827}"=>"\u52E4", "\u{2F828}"=>"\u52FA", "\u{2F829}"=>"\u5305",
+ "\u{2F82A}"=>"\u5306", "\u{2F82B}"=>"\u5317", "\u{2F82C}"=>"\u5349", "\u{2F82D}"=>"\u5351", "\u{2F82E}"=>"\u535A", "\u{2F82F}"=>"\u5373", "\u{2F830}"=>"\u537D", "\u{2F831}"=>"\u537F",
+ "\u{2F832}"=>"\u537F", "\u{2F833}"=>"\u537F", "\u{2F834}"=>"\u{20A2C}", "\u{2F835}"=>"\u7070", "\u{2F836}"=>"\u53CA", "\u{2F837}"=>"\u53DF", "\u{2F838}"=>"\u{20B63}", "\u{2F839}"=>"\u53EB",
+ "\u{2F83A}"=>"\u53F1", "\u{2F83B}"=>"\u5406", "\u{2F83C}"=>"\u549E", "\u{2F83D}"=>"\u5438", "\u{2F83E}"=>"\u5448", "\u{2F83F}"=>"\u5468", "\u{2F840}"=>"\u54A2", "\u{2F841}"=>"\u54F6",
+ "\u{2F842}"=>"\u5510", "\u{2F843}"=>"\u5553", "\u{2F844}"=>"\u5563", "\u{2F845}"=>"\u5584", "\u{2F846}"=>"\u5584", "\u{2F847}"=>"\u5599", "\u{2F848}"=>"\u55AB", "\u{2F849}"=>"\u55B3",
+ "\u{2F84A}"=>"\u55C2", "\u{2F84B}"=>"\u5716", "\u{2F84C}"=>"\u5606", "\u{2F84D}"=>"\u5717", "\u{2F84E}"=>"\u5651", "\u{2F84F}"=>"\u5674", "\u{2F850}"=>"\u5207", "\u{2F851}"=>"\u58EE",
+ "\u{2F852}"=>"\u57CE", "\u{2F853}"=>"\u57F4", "\u{2F854}"=>"\u580D", "\u{2F855}"=>"\u578B", "\u{2F856}"=>"\u5832", "\u{2F857}"=>"\u5831", "\u{2F858}"=>"\u58AC", "\u{2F859}"=>"\u{214E4}",
+ "\u{2F85A}"=>"\u58F2", "\u{2F85B}"=>"\u58F7", "\u{2F85C}"=>"\u5906", "\u{2F85D}"=>"\u591A", "\u{2F85E}"=>"\u5922", "\u{2F85F}"=>"\u5962", "\u{2F860}"=>"\u{216A8}", "\u{2F861}"=>"\u{216EA}",
+ "\u{2F862}"=>"\u59EC", "\u{2F863}"=>"\u5A1B", "\u{2F864}"=>"\u5A27", "\u{2F865}"=>"\u59D8", "\u{2F866}"=>"\u5A66", "\u{2F867}"=>"\u36EE", "\u{2F868}"=>"\u36FC", "\u{2F869}"=>"\u5B08",
+ "\u{2F86A}"=>"\u5B3E", "\u{2F86B}"=>"\u5B3E", "\u{2F86C}"=>"\u{219C8}", "\u{2F86D}"=>"\u5BC3", "\u{2F86E}"=>"\u5BD8", "\u{2F86F}"=>"\u5BE7", "\u{2F870}"=>"\u5BF3", "\u{2F871}"=>"\u{21B18}",
+ "\u{2F872}"=>"\u5BFF", "\u{2F873}"=>"\u5C06", "\u{2F874}"=>"\u5F53", "\u{2F875}"=>"\u5C22", "\u{2F876}"=>"\u3781", "\u{2F877}"=>"\u5C60", "\u{2F878}"=>"\u5C6E", "\u{2F879}"=>"\u5CC0",
+ "\u{2F87A}"=>"\u5C8D", "\u{2F87B}"=>"\u{21DE4}", "\u{2F87C}"=>"\u5D43", "\u{2F87D}"=>"\u{21DE6}", "\u{2F87E}"=>"\u5D6E", "\u{2F87F}"=>"\u5D6B", "\u{2F880}"=>"\u5D7C", "\u{2F881}"=>"\u5DE1",
+ "\u{2F882}"=>"\u5DE2", "\u{2F883}"=>"\u382F", "\u{2F884}"=>"\u5DFD", "\u{2F885}"=>"\u5E28", "\u{2F886}"=>"\u5E3D", "\u{2F887}"=>"\u5E69", "\u{2F888}"=>"\u3862", "\u{2F889}"=>"\u{22183}",
+ "\u{2F88A}"=>"\u387C", "\u{2F88B}"=>"\u5EB0", "\u{2F88C}"=>"\u5EB3", "\u{2F88D}"=>"\u5EB6", "\u{2F88E}"=>"\u5ECA", "\u{2F88F}"=>"\u{2A392}", "\u{2F890}"=>"\u5EFE", "\u{2F891}"=>"\u{22331}",
+ "\u{2F892}"=>"\u{22331}", "\u{2F893}"=>"\u8201", "\u{2F894}"=>"\u5F22", "\u{2F895}"=>"\u5F22", "\u{2F896}"=>"\u38C7", "\u{2F897}"=>"\u{232B8}", "\u{2F898}"=>"\u{261DA}", "\u{2F899}"=>"\u5F62",
+ "\u{2F89A}"=>"\u5F6B", "\u{2F89B}"=>"\u38E3", "\u{2F89C}"=>"\u5F9A", "\u{2F89D}"=>"\u5FCD", "\u{2F89E}"=>"\u5FD7", "\u{2F89F}"=>"\u5FF9", "\u{2F8A0}"=>"\u6081", "\u{2F8A1}"=>"\u393A",
+ "\u{2F8A2}"=>"\u391C", "\u{2F8A3}"=>"\u6094", "\u{2F8A4}"=>"\u{226D4}", "\u{2F8A5}"=>"\u60C7", "\u{2F8A6}"=>"\u6148", "\u{2F8A7}"=>"\u614C", "\u{2F8A8}"=>"\u614E", "\u{2F8A9}"=>"\u614C",
+ "\u{2F8AA}"=>"\u617A", "\u{2F8AB}"=>"\u618E", "\u{2F8AC}"=>"\u61B2", "\u{2F8AD}"=>"\u61A4", "\u{2F8AE}"=>"\u61AF", "\u{2F8AF}"=>"\u61DE", "\u{2F8B0}"=>"\u61F2", "\u{2F8B1}"=>"\u61F6",
+ "\u{2F8B2}"=>"\u6210", "\u{2F8B3}"=>"\u621B", "\u{2F8B4}"=>"\u625D", "\u{2F8B5}"=>"\u62B1", "\u{2F8B6}"=>"\u62D4", "\u{2F8B7}"=>"\u6350", "\u{2F8B8}"=>"\u{22B0C}", "\u{2F8B9}"=>"\u633D",
+ "\u{2F8BA}"=>"\u62FC", "\u{2F8BB}"=>"\u6368", "\u{2F8BC}"=>"\u6383", "\u{2F8BD}"=>"\u63E4", "\u{2F8BE}"=>"\u{22BF1}", "\u{2F8BF}"=>"\u6422", "\u{2F8C0}"=>"\u63C5", "\u{2F8C1}"=>"\u63A9",
+ "\u{2F8C2}"=>"\u3A2E", "\u{2F8C3}"=>"\u6469", "\u{2F8C4}"=>"\u647E", "\u{2F8C5}"=>"\u649D", "\u{2F8C6}"=>"\u6477", "\u{2F8C7}"=>"\u3A6C", "\u{2F8C8}"=>"\u654F", "\u{2F8C9}"=>"\u656C",
+ "\u{2F8CA}"=>"\u{2300A}", "\u{2F8CB}"=>"\u65E3", "\u{2F8CC}"=>"\u66F8", "\u{2F8CD}"=>"\u6649", "\u{2F8CE}"=>"\u3B19", "\u{2F8CF}"=>"\u6691", "\u{2F8D0}"=>"\u3B08", "\u{2F8D1}"=>"\u3AE4",
+ "\u{2F8D2}"=>"\u5192", "\u{2F8D3}"=>"\u5195", "\u{2F8D4}"=>"\u6700", "\u{2F8D5}"=>"\u669C", "\u{2F8D6}"=>"\u80AD", "\u{2F8D7}"=>"\u43D9", "\u{2F8D8}"=>"\u6717", "\u{2F8D9}"=>"\u671B",
+ "\u{2F8DA}"=>"\u6721", "\u{2F8DB}"=>"\u675E", "\u{2F8DC}"=>"\u6753", "\u{2F8DD}"=>"\u{233C3}", "\u{2F8DE}"=>"\u3B49", "\u{2F8DF}"=>"\u67FA", "\u{2F8E0}"=>"\u6785", "\u{2F8E1}"=>"\u6852",
+ "\u{2F8E2}"=>"\u6885", "\u{2F8E3}"=>"\u{2346D}", "\u{2F8E4}"=>"\u688E", "\u{2F8E5}"=>"\u681F", "\u{2F8E6}"=>"\u6914", "\u{2F8E7}"=>"\u3B9D", "\u{2F8E8}"=>"\u6942", "\u{2F8E9}"=>"\u69A3",
+ "\u{2F8EA}"=>"\u69EA", "\u{2F8EB}"=>"\u6AA8", "\u{2F8EC}"=>"\u{236A3}", "\u{2F8ED}"=>"\u6ADB", "\u{2F8EE}"=>"\u3C18", "\u{2F8EF}"=>"\u6B21", "\u{2F8F0}"=>"\u{238A7}", "\u{2F8F1}"=>"\u6B54",
+ "\u{2F8F2}"=>"\u3C4E", "\u{2F8F3}"=>"\u6B72", "\u{2F8F4}"=>"\u6B9F", "\u{2F8F5}"=>"\u6BBA", "\u{2F8F6}"=>"\u6BBB", "\u{2F8F7}"=>"\u{23A8D}", "\u{2F8F8}"=>"\u{21D0B}", "\u{2F8F9}"=>"\u{23AFA}",
+ "\u{2F8FA}"=>"\u6C4E", "\u{2F8FB}"=>"\u{23CBC}", "\u{2F8FC}"=>"\u6CBF", "\u{2F8FD}"=>"\u6CCD", "\u{2F8FE}"=>"\u6C67", "\u{2F8FF}"=>"\u6D16", "\u{2F900}"=>"\u6D3E", "\u{2F901}"=>"\u6D77",
+ "\u{2F902}"=>"\u6D41", "\u{2F903}"=>"\u6D69", "\u{2F904}"=>"\u6D78", "\u{2F905}"=>"\u6D85", "\u{2F906}"=>"\u{23D1E}", "\u{2F907}"=>"\u6D34", "\u{2F908}"=>"\u6E2F", "\u{2F909}"=>"\u6E6E",
+ "\u{2F90A}"=>"\u3D33", "\u{2F90B}"=>"\u6ECB", "\u{2F90C}"=>"\u6EC7", "\u{2F90D}"=>"\u{23ED1}", "\u{2F90E}"=>"\u6DF9", "\u{2F90F}"=>"\u6F6E", "\u{2F910}"=>"\u{23F5E}", "\u{2F911}"=>"\u{23F8E}",
+ "\u{2F912}"=>"\u6FC6", "\u{2F913}"=>"\u7039", "\u{2F914}"=>"\u701E", "\u{2F915}"=>"\u701B", "\u{2F916}"=>"\u3D96", "\u{2F917}"=>"\u704A", "\u{2F918}"=>"\u707D", "\u{2F919}"=>"\u7077",
+ "\u{2F91A}"=>"\u70AD", "\u{2F91B}"=>"\u{20525}", "\u{2F91C}"=>"\u7145", "\u{2F91D}"=>"\u{24263}", "\u{2F91E}"=>"\u719C", "\u{2F91F}"=>"\u{243AB}", "\u{2F920}"=>"\u7228", "\u{2F921}"=>"\u7235",
+ "\u{2F922}"=>"\u7250", "\u{2F923}"=>"\u{24608}", "\u{2F924}"=>"\u7280", "\u{2F925}"=>"\u7295", "\u{2F926}"=>"\u{24735}", "\u{2F927}"=>"\u{24814}", "\u{2F928}"=>"\u737A", "\u{2F929}"=>"\u738B",
+ "\u{2F92A}"=>"\u3EAC", "\u{2F92B}"=>"\u73A5", "\u{2F92C}"=>"\u3EB8", "\u{2F92D}"=>"\u3EB8", "\u{2F92E}"=>"\u7447", "\u{2F92F}"=>"\u745C", "\u{2F930}"=>"\u7471", "\u{2F931}"=>"\u7485",
+ "\u{2F932}"=>"\u74CA", "\u{2F933}"=>"\u3F1B", "\u{2F934}"=>"\u7524", "\u{2F935}"=>"\u{24C36}", "\u{2F936}"=>"\u753E", "\u{2F937}"=>"\u{24C92}", "\u{2F938}"=>"\u7570", "\u{2F939}"=>"\u{2219F}",
+ "\u{2F93A}"=>"\u7610", "\u{2F93B}"=>"\u{24FA1}", "\u{2F93C}"=>"\u{24FB8}", "\u{2F93D}"=>"\u{25044}", "\u{2F93E}"=>"\u3FFC", "\u{2F93F}"=>"\u4008", "\u{2F940}"=>"\u76F4", "\u{2F941}"=>"\u{250F3}",
+ "\u{2F942}"=>"\u{250F2}", "\u{2F943}"=>"\u{25119}", "\u{2F944}"=>"\u{25133}", "\u{2F945}"=>"\u771E", "\u{2F946}"=>"\u771F", "\u{2F947}"=>"\u771F", "\u{2F948}"=>"\u774A", "\u{2F949}"=>"\u4039",
+ "\u{2F94A}"=>"\u778B", "\u{2F94B}"=>"\u4046", "\u{2F94C}"=>"\u4096", "\u{2F94D}"=>"\u{2541D}", "\u{2F94E}"=>"\u784E", "\u{2F94F}"=>"\u788C", "\u{2F950}"=>"\u78CC", "\u{2F951}"=>"\u40E3",
+ "\u{2F952}"=>"\u{25626}", "\u{2F953}"=>"\u7956", "\u{2F954}"=>"\u{2569A}", "\u{2F955}"=>"\u{256C5}", "\u{2F956}"=>"\u798F", "\u{2F957}"=>"\u79EB", "\u{2F958}"=>"\u412F", "\u{2F959}"=>"\u7A40",
+ "\u{2F95A}"=>"\u7A4A", "\u{2F95B}"=>"\u7A4F", "\u{2F95C}"=>"\u{2597C}", "\u{2F95D}"=>"\u{25AA7}", "\u{2F95E}"=>"\u{25AA7}", "\u{2F95F}"=>"\u7AEE", "\u{2F960}"=>"\u4202", "\u{2F961}"=>"\u{25BAB}",
+ "\u{2F962}"=>"\u7BC6", "\u{2F963}"=>"\u7BC9", "\u{2F964}"=>"\u4227", "\u{2F965}"=>"\u{25C80}", "\u{2F966}"=>"\u7CD2", "\u{2F967}"=>"\u42A0", "\u{2F968}"=>"\u7CE8", "\u{2F969}"=>"\u7CE3",
+ "\u{2F96A}"=>"\u7D00", "\u{2F96B}"=>"\u{25F86}", "\u{2F96C}"=>"\u7D63", "\u{2F96D}"=>"\u4301", "\u{2F96E}"=>"\u7DC7", "\u{2F96F}"=>"\u7E02", "\u{2F970}"=>"\u7E45", "\u{2F971}"=>"\u4334",
+ "\u{2F972}"=>"\u{26228}", "\u{2F973}"=>"\u{26247}", "\u{2F974}"=>"\u4359", "\u{2F975}"=>"\u{262D9}", "\u{2F976}"=>"\u7F7A", "\u{2F977}"=>"\u{2633E}", "\u{2F978}"=>"\u7F95", "\u{2F979}"=>"\u7FFA",
+ "\u{2F97A}"=>"\u8005", "\u{2F97B}"=>"\u{264DA}", "\u{2F97C}"=>"\u{26523}", "\u{2F97D}"=>"\u8060", "\u{2F97E}"=>"\u{265A8}", "\u{2F97F}"=>"\u8070", "\u{2F980}"=>"\u{2335F}", "\u{2F981}"=>"\u43D5",
+ "\u{2F982}"=>"\u80B2", "\u{2F983}"=>"\u8103", "\u{2F984}"=>"\u440B", "\u{2F985}"=>"\u813E", "\u{2F986}"=>"\u5AB5", "\u{2F987}"=>"\u{267A7}", "\u{2F988}"=>"\u{267B5}", "\u{2F989}"=>"\u{23393}",
+ "\u{2F98A}"=>"\u{2339C}", "\u{2F98B}"=>"\u8201", "\u{2F98C}"=>"\u8204", "\u{2F98D}"=>"\u8F9E", "\u{2F98E}"=>"\u446B", "\u{2F98F}"=>"\u8291", "\u{2F990}"=>"\u828B", "\u{2F991}"=>"\u829D",
+ "\u{2F992}"=>"\u52B3", "\u{2F993}"=>"\u82B1", "\u{2F994}"=>"\u82B3", "\u{2F995}"=>"\u82BD", "\u{2F996}"=>"\u82E6", "\u{2F997}"=>"\u{26B3C}", "\u{2F998}"=>"\u82E5", "\u{2F999}"=>"\u831D",
+ "\u{2F99A}"=>"\u8363", "\u{2F99B}"=>"\u83AD", "\u{2F99C}"=>"\u8323", "\u{2F99D}"=>"\u83BD", "\u{2F99E}"=>"\u83E7", "\u{2F99F}"=>"\u8457", "\u{2F9A0}"=>"\u8353", "\u{2F9A1}"=>"\u83CA",
+ "\u{2F9A2}"=>"\u83CC", "\u{2F9A3}"=>"\u83DC", "\u{2F9A4}"=>"\u{26C36}", "\u{2F9A5}"=>"\u{26D6B}", "\u{2F9A6}"=>"\u{26CD5}", "\u{2F9A7}"=>"\u452B", "\u{2F9A8}"=>"\u84F1", "\u{2F9A9}"=>"\u84F3",
+ "\u{2F9AA}"=>"\u8516", "\u{2F9AB}"=>"\u{273CA}", "\u{2F9AC}"=>"\u8564", "\u{2F9AD}"=>"\u{26F2C}", "\u{2F9AE}"=>"\u455D", "\u{2F9AF}"=>"\u4561", "\u{2F9B0}"=>"\u{26FB1}", "\u{2F9B1}"=>"\u{270D2}",
+ "\u{2F9B2}"=>"\u456B", "\u{2F9B3}"=>"\u8650", "\u{2F9B4}"=>"\u865C", "\u{2F9B5}"=>"\u8667", "\u{2F9B6}"=>"\u8669", "\u{2F9B7}"=>"\u86A9", "\u{2F9B8}"=>"\u8688", "\u{2F9B9}"=>"\u870E",
+ "\u{2F9BA}"=>"\u86E2", "\u{2F9BB}"=>"\u8779", "\u{2F9BC}"=>"\u8728", "\u{2F9BD}"=>"\u876B", "\u{2F9BE}"=>"\u8786", "\u{2F9BF}"=>"\u45D7", "\u{2F9C0}"=>"\u87E1", "\u{2F9C1}"=>"\u8801",
+ "\u{2F9C2}"=>"\u45F9", "\u{2F9C3}"=>"\u8860", "\u{2F9C4}"=>"\u8863", "\u{2F9C5}"=>"\u{27667}", "\u{2F9C6}"=>"\u88D7", "\u{2F9C7}"=>"\u88DE", "\u{2F9C8}"=>"\u4635", "\u{2F9C9}"=>"\u88FA",
+ "\u{2F9CA}"=>"\u34BB", "\u{2F9CB}"=>"\u{278AE}", "\u{2F9CC}"=>"\u{27966}", "\u{2F9CD}"=>"\u46BE", "\u{2F9CE}"=>"\u46C7", "\u{2F9CF}"=>"\u8AA0", "\u{2F9D0}"=>"\u8AED", "\u{2F9D1}"=>"\u8B8A",
+ "\u{2F9D2}"=>"\u8C55", "\u{2F9D3}"=>"\u{27CA8}", "\u{2F9D4}"=>"\u8CAB", "\u{2F9D5}"=>"\u8CC1", "\u{2F9D6}"=>"\u8D1B", "\u{2F9D7}"=>"\u8D77", "\u{2F9D8}"=>"\u{27F2F}", "\u{2F9D9}"=>"\u{20804}",
+ "\u{2F9DA}"=>"\u8DCB", "\u{2F9DB}"=>"\u8DBC", "\u{2F9DC}"=>"\u8DF0", "\u{2F9DD}"=>"\u{208DE}", "\u{2F9DE}"=>"\u8ED4", "\u{2F9DF}"=>"\u8F38", "\u{2F9E0}"=>"\u{285D2}", "\u{2F9E1}"=>"\u{285ED}",
+ "\u{2F9E2}"=>"\u9094", "\u{2F9E3}"=>"\u90F1", "\u{2F9E4}"=>"\u9111", "\u{2F9E5}"=>"\u{2872E}", "\u{2F9E6}"=>"\u911B", "\u{2F9E7}"=>"\u9238", "\u{2F9E8}"=>"\u92D7", "\u{2F9E9}"=>"\u92D8",
+ "\u{2F9EA}"=>"\u927C", "\u{2F9EB}"=>"\u93F9", "\u{2F9EC}"=>"\u9415", "\u{2F9ED}"=>"\u{28BFA}", "\u{2F9EE}"=>"\u958B", "\u{2F9EF}"=>"\u4995", "\u{2F9F0}"=>"\u95B7", "\u{2F9F1}"=>"\u{28D77}",
+ "\u{2F9F2}"=>"\u49E6", "\u{2F9F3}"=>"\u96C3", "\u{2F9F4}"=>"\u5DB2", "\u{2F9F5}"=>"\u9723", "\u{2F9F6}"=>"\u{29145}", "\u{2F9F7}"=>"\u{2921A}", "\u{2F9F8}"=>"\u4A6E", "\u{2F9F9}"=>"\u4A76",
+ "\u{2F9FA}"=>"\u97E0", "\u{2F9FB}"=>"\u{2940A}", "\u{2F9FC}"=>"\u4AB2", "\u{2F9FD}"=>"\u{29496}", "\u{2F9FE}"=>"\u980B", "\u{2F9FF}"=>"\u980B", "\u{2FA00}"=>"\u9829", "\u{2FA01}"=>"\u{295B6}",
+ "\u{2FA02}"=>"\u98E2", "\u{2FA03}"=>"\u4B33", "\u{2FA04}"=>"\u9929", "\u{2FA05}"=>"\u99A7", "\u{2FA06}"=>"\u99C2", "\u{2FA07}"=>"\u99FE", "\u{2FA08}"=>"\u4BCE", "\u{2FA09}"=>"\u{29B30}",
+ "\u{2FA0A}"=>"\u9B12", "\u{2FA0B}"=>"\u9C40", "\u{2FA0C}"=>"\u9CFD", "\u{2FA0D}"=>"\u4CCE", "\u{2FA0E}"=>"\u4CED", "\u{2FA0F}"=>"\u9D67", "\u{2FA10}"=>"\u{2A0CE}", "\u{2FA11}"=>"\u4CF8",
+ "\u{2FA12}"=>"\u{2A105}", "\u{2FA13}"=>"\u{2A20E}", "\u{2FA14}"=>"\u{2A291}", "\u{2FA15}"=>"\u9EBB", "\u{2FA16}"=>"\u4D56", "\u{2FA17}"=>"\u9EF9", "\u{2FA18}"=>"\u9EFE", "\u{2FA19}"=>"\u9F05",
+ "\u{2FA1A}"=>"\u9F0F", "\u{2FA1B}"=>"\u9F16", "\u{2FA1C}"=>"\u9F3B", "\u{2FA1D}"=>"\u{2A600}",
}.freeze
KOMPATIBLE_TABLE = {
- "\u00A0"=>" ",
- "\u00A8"=>" \u0308",
- "\u00AA"=>"a",
- "\u00AF"=>" \u0304",
- "\u00B2"=>"2",
- "\u00B3"=>"3",
- "\u00B4"=>" \u0301",
- "\u00B5"=>"\u03BC",
- "\u00B8"=>" \u0327",
- "\u00B9"=>"1",
- "\u00BA"=>"o",
- "\u00BC"=>"1\u20444",
- "\u00BD"=>"1\u20442",
- "\u00BE"=>"3\u20444",
- "\u0132"=>"IJ",
- "\u0133"=>"ij",
- "\u013F"=>"L\u00B7",
- "\u0140"=>"l\u00B7",
- "\u0149"=>"\u02BCn",
- "\u017F"=>"s",
- "\u01C4"=>"D\u017D",
- "\u01C5"=>"D\u017E",
- "\u01C6"=>"d\u017E",
- "\u01C7"=>"LJ",
- "\u01C8"=>"Lj",
- "\u01C9"=>"lj",
- "\u01CA"=>"NJ",
- "\u01CB"=>"Nj",
- "\u01CC"=>"nj",
- "\u01F1"=>"DZ",
- "\u01F2"=>"Dz",
- "\u01F3"=>"dz",
- "\u02B0"=>"h",
- "\u02B1"=>"\u0266",
- "\u02B2"=>"j",
- "\u02B3"=>"r",
- "\u02B4"=>"\u0279",
- "\u02B5"=>"\u027B",
- "\u02B6"=>"\u0281",
- "\u02B7"=>"w",
- "\u02B8"=>"y",
- "\u02D8"=>" \u0306",
- "\u02D9"=>" \u0307",
- "\u02DA"=>" \u030A",
- "\u02DB"=>" \u0328",
- "\u02DC"=>" \u0303",
- "\u02DD"=>" \u030B",
- "\u02E0"=>"\u0263",
- "\u02E1"=>"l",
- "\u02E2"=>"s",
- "\u02E3"=>"x",
- "\u02E4"=>"\u0295",
- "\u037A"=>" \u0345",
- "\u0384"=>" \u0301",
- "\u03D0"=>"\u03B2",
- "\u03D1"=>"\u03B8",
- "\u03D2"=>"\u03A5",
- "\u03D5"=>"\u03C6",
- "\u03D6"=>"\u03C0",
- "\u03F0"=>"\u03BA",
- "\u03F1"=>"\u03C1",
- "\u03F2"=>"\u03C2",
- "\u03F4"=>"\u0398",
- "\u03F5"=>"\u03B5",
- "\u03F9"=>"\u03A3",
- "\u0587"=>"\u0565\u0582",
- "\u0675"=>"\u0627\u0674",
- "\u0676"=>"\u0648\u0674",
- "\u0677"=>"\u06C7\u0674",
- "\u0678"=>"\u064A\u0674",
- "\u0E33"=>"\u0E4D\u0E32",
- "\u0EB3"=>"\u0ECD\u0EB2",
- "\u0EDC"=>"\u0EAB\u0E99",
- "\u0EDD"=>"\u0EAB\u0EA1",
- "\u0F0C"=>"\u0F0B",
- "\u0F77"=>"\u0FB2\u0F81",
- "\u0F79"=>"\u0FB3\u0F81",
- "\u10FC"=>"\u10DC",
- "\u1D2C"=>"A",
- "\u1D2D"=>"\u00C6",
- "\u1D2E"=>"B",
- "\u1D30"=>"D",
- "\u1D31"=>"E",
- "\u1D32"=>"\u018E",
- "\u1D33"=>"G",
- "\u1D34"=>"H",
- "\u1D35"=>"I",
- "\u1D36"=>"J",
- "\u1D37"=>"K",
- "\u1D38"=>"L",
- "\u1D39"=>"M",
- "\u1D3A"=>"N",
- "\u1D3C"=>"O",
- "\u1D3D"=>"\u0222",
- "\u1D3E"=>"P",
- "\u1D3F"=>"R",
- "\u1D40"=>"T",
- "\u1D41"=>"U",
- "\u1D42"=>"W",
- "\u1D43"=>"a",
- "\u1D44"=>"\u0250",
- "\u1D45"=>"\u0251",
- "\u1D46"=>"\u1D02",
- "\u1D47"=>"b",
- "\u1D48"=>"d",
- "\u1D49"=>"e",
- "\u1D4A"=>"\u0259",
- "\u1D4B"=>"\u025B",
- "\u1D4C"=>"\u025C",
- "\u1D4D"=>"g",
- "\u1D4F"=>"k",
- "\u1D50"=>"m",
- "\u1D51"=>"\u014B",
- "\u1D52"=>"o",
- "\u1D53"=>"\u0254",
- "\u1D54"=>"\u1D16",
- "\u1D55"=>"\u1D17",
- "\u1D56"=>"p",
- "\u1D57"=>"t",
- "\u1D58"=>"u",
- "\u1D59"=>"\u1D1D",
- "\u1D5A"=>"\u026F",
- "\u1D5B"=>"v",
- "\u1D5C"=>"\u1D25",
- "\u1D5D"=>"\u03B2",
- "\u1D5E"=>"\u03B3",
- "\u1D5F"=>"\u03B4",
- "\u1D60"=>"\u03C6",
- "\u1D61"=>"\u03C7",
- "\u1D62"=>"i",
- "\u1D63"=>"r",
- "\u1D64"=>"u",
- "\u1D65"=>"v",
- "\u1D66"=>"\u03B2",
- "\u1D67"=>"\u03B3",
- "\u1D68"=>"\u03C1",
- "\u1D69"=>"\u03C6",
- "\u1D6A"=>"\u03C7",
- "\u1D78"=>"\u043D",
- "\u1D9B"=>"\u0252",
- "\u1D9C"=>"c",
- "\u1D9D"=>"\u0255",
- "\u1D9E"=>"\u00F0",
- "\u1D9F"=>"\u025C",
- "\u1DA0"=>"f",
- "\u1DA1"=>"\u025F",
- "\u1DA2"=>"\u0261",
- "\u1DA3"=>"\u0265",
- "\u1DA4"=>"\u0268",
- "\u1DA5"=>"\u0269",
- "\u1DA6"=>"\u026A",
- "\u1DA7"=>"\u1D7B",
- "\u1DA8"=>"\u029D",
- "\u1DA9"=>"\u026D",
- "\u1DAA"=>"\u1D85",
- "\u1DAB"=>"\u029F",
- "\u1DAC"=>"\u0271",
- "\u1DAD"=>"\u0270",
- "\u1DAE"=>"\u0272",
- "\u1DAF"=>"\u0273",
- "\u1DB0"=>"\u0274",
- "\u1DB1"=>"\u0275",
- "\u1DB2"=>"\u0278",
- "\u1DB3"=>"\u0282",
- "\u1DB4"=>"\u0283",
- "\u1DB5"=>"\u01AB",
- "\u1DB6"=>"\u0289",
- "\u1DB7"=>"\u028A",
- "\u1DB8"=>"\u1D1C",
- "\u1DB9"=>"\u028B",
- "\u1DBA"=>"\u028C",
- "\u1DBB"=>"z",
- "\u1DBC"=>"\u0290",
- "\u1DBD"=>"\u0291",
- "\u1DBE"=>"\u0292",
- "\u1DBF"=>"\u03B8",
- "\u1E9A"=>"a\u02BE",
- "\u1FBD"=>" \u0313",
- "\u1FBF"=>" \u0313",
- "\u1FC0"=>" \u0342",
- "\u1FFE"=>" \u0314",
- "\u2002"=>" ",
- "\u2003"=>" ",
- "\u2004"=>" ",
- "\u2005"=>" ",
- "\u2006"=>" ",
- "\u2007"=>" ",
- "\u2008"=>" ",
- "\u2009"=>" ",
- "\u200A"=>" ",
- "\u2011"=>"\u2010",
- "\u2017"=>" \u0333",
- "\u2024"=>".",
- "\u2025"=>"..",
- "\u2026"=>"...",
- "\u202F"=>" ",
- "\u2033"=>"\u2032\u2032",
- "\u2034"=>"\u2032\u2032\u2032",
- "\u2036"=>"\u2035\u2035",
- "\u2037"=>"\u2035\u2035\u2035",
- "\u203C"=>"!!",
- "\u203E"=>" \u0305",
- "\u2047"=>"??",
- "\u2048"=>"?!",
- "\u2049"=>"!?",
- "\u2057"=>"\u2032\u2032\u2032\u2032",
- "\u205F"=>" ",
- "\u2070"=>"0",
- "\u2071"=>"i",
- "\u2074"=>"4",
- "\u2075"=>"5",
- "\u2076"=>"6",
- "\u2077"=>"7",
- "\u2078"=>"8",
- "\u2079"=>"9",
- "\u207A"=>"+",
- "\u207B"=>"\u2212",
- "\u207C"=>"=",
- "\u207D"=>"(",
- "\u207E"=>")",
- "\u207F"=>"n",
- "\u2080"=>"0",
- "\u2081"=>"1",
- "\u2082"=>"2",
- "\u2083"=>"3",
- "\u2084"=>"4",
- "\u2085"=>"5",
- "\u2086"=>"6",
- "\u2087"=>"7",
- "\u2088"=>"8",
- "\u2089"=>"9",
- "\u208A"=>"+",
- "\u208B"=>"\u2212",
- "\u208C"=>"=",
- "\u208D"=>"(",
- "\u208E"=>")",
- "\u2090"=>"a",
- "\u2091"=>"e",
- "\u2092"=>"o",
- "\u2093"=>"x",
- "\u2094"=>"\u0259",
- "\u2095"=>"h",
- "\u2096"=>"k",
- "\u2097"=>"l",
- "\u2098"=>"m",
- "\u2099"=>"n",
- "\u209A"=>"p",
- "\u209B"=>"s",
- "\u209C"=>"t",
- "\u20A8"=>"Rs",
- "\u2100"=>"a/c",
- "\u2101"=>"a/s",
- "\u2102"=>"C",
- "\u2103"=>"\u00B0C",
- "\u2105"=>"c/o",
- "\u2106"=>"c/u",
- "\u2107"=>"\u0190",
- "\u2109"=>"\u00B0F",
- "\u210A"=>"g",
- "\u210B"=>"H",
- "\u210C"=>"H",
- "\u210D"=>"H",
- "\u210E"=>"h",
- "\u210F"=>"\u0127",
- "\u2110"=>"I",
- "\u2111"=>"I",
- "\u2112"=>"L",
- "\u2113"=>"l",
- "\u2115"=>"N",
- "\u2116"=>"No",
- "\u2119"=>"P",
- "\u211A"=>"Q",
- "\u211B"=>"R",
- "\u211C"=>"R",
- "\u211D"=>"R",
- "\u2120"=>"SM",
- "\u2121"=>"TEL",
- "\u2122"=>"TM",
- "\u2124"=>"Z",
- "\u2128"=>"Z",
- "\u212C"=>"B",
- "\u212D"=>"C",
- "\u212F"=>"e",
- "\u2130"=>"E",
- "\u2131"=>"F",
- "\u2133"=>"M",
- "\u2134"=>"o",
- "\u2135"=>"\u05D0",
- "\u2136"=>"\u05D1",
- "\u2137"=>"\u05D2",
- "\u2138"=>"\u05D3",
- "\u2139"=>"i",
- "\u213B"=>"FAX",
- "\u213C"=>"\u03C0",
- "\u213D"=>"\u03B3",
- "\u213E"=>"\u0393",
- "\u213F"=>"\u03A0",
- "\u2140"=>"\u2211",
- "\u2145"=>"D",
- "\u2146"=>"d",
- "\u2147"=>"e",
- "\u2148"=>"i",
- "\u2149"=>"j",
- "\u2150"=>"1\u20447",
- "\u2151"=>"1\u20449",
- "\u2152"=>"1\u204410",
- "\u2153"=>"1\u20443",
- "\u2154"=>"2\u20443",
- "\u2155"=>"1\u20445",
- "\u2156"=>"2\u20445",
- "\u2157"=>"3\u20445",
- "\u2158"=>"4\u20445",
- "\u2159"=>"1\u20446",
- "\u215A"=>"5\u20446",
- "\u215B"=>"1\u20448",
- "\u215C"=>"3\u20448",
- "\u215D"=>"5\u20448",
- "\u215E"=>"7\u20448",
- "\u215F"=>"1\u2044",
- "\u2160"=>"I",
- "\u2161"=>"II",
- "\u2162"=>"III",
- "\u2163"=>"IV",
- "\u2164"=>"V",
- "\u2165"=>"VI",
- "\u2166"=>"VII",
- "\u2167"=>"VIII",
- "\u2168"=>"IX",
- "\u2169"=>"X",
- "\u216A"=>"XI",
- "\u216B"=>"XII",
- "\u216C"=>"L",
- "\u216D"=>"C",
- "\u216E"=>"D",
- "\u216F"=>"M",
- "\u2170"=>"i",
- "\u2171"=>"ii",
- "\u2172"=>"iii",
- "\u2173"=>"iv",
- "\u2174"=>"v",
- "\u2175"=>"vi",
- "\u2176"=>"vii",
- "\u2177"=>"viii",
- "\u2178"=>"ix",
- "\u2179"=>"x",
- "\u217A"=>"xi",
- "\u217B"=>"xii",
- "\u217C"=>"l",
- "\u217D"=>"c",
- "\u217E"=>"d",
- "\u217F"=>"m",
- "\u2189"=>"0\u20443",
- "\u222C"=>"\u222B\u222B",
- "\u222D"=>"\u222B\u222B\u222B",
- "\u222F"=>"\u222E\u222E",
- "\u2230"=>"\u222E\u222E\u222E",
- "\u2460"=>"1",
- "\u2461"=>"2",
- "\u2462"=>"3",
- "\u2463"=>"4",
- "\u2464"=>"5",
- "\u2465"=>"6",
- "\u2466"=>"7",
- "\u2467"=>"8",
- "\u2468"=>"9",
- "\u2469"=>"10",
- "\u246A"=>"11",
- "\u246B"=>"12",
- "\u246C"=>"13",
- "\u246D"=>"14",
- "\u246E"=>"15",
- "\u246F"=>"16",
- "\u2470"=>"17",
- "\u2471"=>"18",
- "\u2472"=>"19",
- "\u2473"=>"20",
- "\u2474"=>"(1)",
- "\u2475"=>"(2)",
- "\u2476"=>"(3)",
- "\u2477"=>"(4)",
- "\u2478"=>"(5)",
- "\u2479"=>"(6)",
- "\u247A"=>"(7)",
- "\u247B"=>"(8)",
- "\u247C"=>"(9)",
- "\u247D"=>"(10)",
- "\u247E"=>"(11)",
- "\u247F"=>"(12)",
- "\u2480"=>"(13)",
- "\u2481"=>"(14)",
- "\u2482"=>"(15)",
- "\u2483"=>"(16)",
- "\u2484"=>"(17)",
- "\u2485"=>"(18)",
- "\u2486"=>"(19)",
- "\u2487"=>"(20)",
- "\u2488"=>"1.",
- "\u2489"=>"2.",
- "\u248A"=>"3.",
- "\u248B"=>"4.",
- "\u248C"=>"5.",
- "\u248D"=>"6.",
- "\u248E"=>"7.",
- "\u248F"=>"8.",
- "\u2490"=>"9.",
- "\u2491"=>"10.",
- "\u2492"=>"11.",
- "\u2493"=>"12.",
- "\u2494"=>"13.",
- "\u2495"=>"14.",
- "\u2496"=>"15.",
- "\u2497"=>"16.",
- "\u2498"=>"17.",
- "\u2499"=>"18.",
- "\u249A"=>"19.",
- "\u249B"=>"20.",
- "\u249C"=>"(a)",
- "\u249D"=>"(b)",
- "\u249E"=>"(c)",
- "\u249F"=>"(d)",
- "\u24A0"=>"(e)",
- "\u24A1"=>"(f)",
- "\u24A2"=>"(g)",
- "\u24A3"=>"(h)",
- "\u24A4"=>"(i)",
- "\u24A5"=>"(j)",
- "\u24A6"=>"(k)",
- "\u24A7"=>"(l)",
- "\u24A8"=>"(m)",
- "\u24A9"=>"(n)",
- "\u24AA"=>"(o)",
- "\u24AB"=>"(p)",
- "\u24AC"=>"(q)",
- "\u24AD"=>"(r)",
- "\u24AE"=>"(s)",
- "\u24AF"=>"(t)",
- "\u24B0"=>"(u)",
- "\u24B1"=>"(v)",
- "\u24B2"=>"(w)",
- "\u24B3"=>"(x)",
- "\u24B4"=>"(y)",
- "\u24B5"=>"(z)",
- "\u24B6"=>"A",
- "\u24B7"=>"B",
- "\u24B8"=>"C",
- "\u24B9"=>"D",
- "\u24BA"=>"E",
- "\u24BB"=>"F",
- "\u24BC"=>"G",
- "\u24BD"=>"H",
- "\u24BE"=>"I",
- "\u24BF"=>"J",
- "\u24C0"=>"K",
- "\u24C1"=>"L",
- "\u24C2"=>"M",
- "\u24C3"=>"N",
- "\u24C4"=>"O",
- "\u24C5"=>"P",
- "\u24C6"=>"Q",
- "\u24C7"=>"R",
- "\u24C8"=>"S",
- "\u24C9"=>"T",
- "\u24CA"=>"U",
- "\u24CB"=>"V",
- "\u24CC"=>"W",
- "\u24CD"=>"X",
- "\u24CE"=>"Y",
- "\u24CF"=>"Z",
- "\u24D0"=>"a",
- "\u24D1"=>"b",
- "\u24D2"=>"c",
- "\u24D3"=>"d",
- "\u24D4"=>"e",
- "\u24D5"=>"f",
- "\u24D6"=>"g",
- "\u24D7"=>"h",
- "\u24D8"=>"i",
- "\u24D9"=>"j",
- "\u24DA"=>"k",
- "\u24DB"=>"l",
- "\u24DC"=>"m",
- "\u24DD"=>"n",
- "\u24DE"=>"o",
- "\u24DF"=>"p",
- "\u24E0"=>"q",
- "\u24E1"=>"r",
- "\u24E2"=>"s",
- "\u24E3"=>"t",
- "\u24E4"=>"u",
- "\u24E5"=>"v",
- "\u24E6"=>"w",
- "\u24E7"=>"x",
- "\u24E8"=>"y",
- "\u24E9"=>"z",
- "\u24EA"=>"0",
- "\u2A0C"=>"\u222B\u222B\u222B\u222B",
- "\u2A74"=>"::=",
- "\u2A75"=>"==",
- "\u2A76"=>"===",
- "\u2C7C"=>"j",
- "\u2C7D"=>"V",
- "\u2D6F"=>"\u2D61",
- "\u2E9F"=>"\u6BCD",
- "\u2EF3"=>"\u9F9F",
- "\u2F00"=>"\u4E00",
- "\u2F01"=>"\u4E28",
- "\u2F02"=>"\u4E36",
- "\u2F03"=>"\u4E3F",
- "\u2F04"=>"\u4E59",
- "\u2F05"=>"\u4E85",
- "\u2F06"=>"\u4E8C",
- "\u2F07"=>"\u4EA0",
- "\u2F08"=>"\u4EBA",
- "\u2F09"=>"\u513F",
- "\u2F0A"=>"\u5165",
- "\u2F0B"=>"\u516B",
- "\u2F0C"=>"\u5182",
- "\u2F0D"=>"\u5196",
- "\u2F0E"=>"\u51AB",
- "\u2F0F"=>"\u51E0",
- "\u2F10"=>"\u51F5",
- "\u2F11"=>"\u5200",
- "\u2F12"=>"\u529B",
- "\u2F13"=>"\u52F9",
- "\u2F14"=>"\u5315",
- "\u2F15"=>"\u531A",
- "\u2F16"=>"\u5338",
- "\u2F17"=>"\u5341",
- "\u2F18"=>"\u535C",
- "\u2F19"=>"\u5369",
- "\u2F1A"=>"\u5382",
- "\u2F1B"=>"\u53B6",
- "\u2F1C"=>"\u53C8",
- "\u2F1D"=>"\u53E3",
- "\u2F1E"=>"\u56D7",
- "\u2F1F"=>"\u571F",
- "\u2F20"=>"\u58EB",
- "\u2F21"=>"\u5902",
- "\u2F22"=>"\u590A",
- "\u2F23"=>"\u5915",
- "\u2F24"=>"\u5927",
- "\u2F25"=>"\u5973",
- "\u2F26"=>"\u5B50",
- "\u2F27"=>"\u5B80",
- "\u2F28"=>"\u5BF8",
- "\u2F29"=>"\u5C0F",
- "\u2F2A"=>"\u5C22",
- "\u2F2B"=>"\u5C38",
- "\u2F2C"=>"\u5C6E",
- "\u2F2D"=>"\u5C71",
- "\u2F2E"=>"\u5DDB",
- "\u2F2F"=>"\u5DE5",
- "\u2F30"=>"\u5DF1",
- "\u2F31"=>"\u5DFE",
- "\u2F32"=>"\u5E72",
- "\u2F33"=>"\u5E7A",
- "\u2F34"=>"\u5E7F",
- "\u2F35"=>"\u5EF4",
- "\u2F36"=>"\u5EFE",
- "\u2F37"=>"\u5F0B",
- "\u2F38"=>"\u5F13",
- "\u2F39"=>"\u5F50",
- "\u2F3A"=>"\u5F61",
- "\u2F3B"=>"\u5F73",
- "\u2F3C"=>"\u5FC3",
- "\u2F3D"=>"\u6208",
- "\u2F3E"=>"\u6236",
- "\u2F3F"=>"\u624B",
- "\u2F40"=>"\u652F",
- "\u2F41"=>"\u6534",
- "\u2F42"=>"\u6587",
- "\u2F43"=>"\u6597",
- "\u2F44"=>"\u65A4",
- "\u2F45"=>"\u65B9",
- "\u2F46"=>"\u65E0",
- "\u2F47"=>"\u65E5",
- "\u2F48"=>"\u66F0",
- "\u2F49"=>"\u6708",
- "\u2F4A"=>"\u6728",
- "\u2F4B"=>"\u6B20",
- "\u2F4C"=>"\u6B62",
- "\u2F4D"=>"\u6B79",
- "\u2F4E"=>"\u6BB3",
- "\u2F4F"=>"\u6BCB",
- "\u2F50"=>"\u6BD4",
- "\u2F51"=>"\u6BDB",
- "\u2F52"=>"\u6C0F",
- "\u2F53"=>"\u6C14",
- "\u2F54"=>"\u6C34",
- "\u2F55"=>"\u706B",
- "\u2F56"=>"\u722A",
- "\u2F57"=>"\u7236",
- "\u2F58"=>"\u723B",
- "\u2F59"=>"\u723F",
- "\u2F5A"=>"\u7247",
- "\u2F5B"=>"\u7259",
- "\u2F5C"=>"\u725B",
- "\u2F5D"=>"\u72AC",
- "\u2F5E"=>"\u7384",
- "\u2F5F"=>"\u7389",
- "\u2F60"=>"\u74DC",
- "\u2F61"=>"\u74E6",
- "\u2F62"=>"\u7518",
- "\u2F63"=>"\u751F",
- "\u2F64"=>"\u7528",
- "\u2F65"=>"\u7530",
- "\u2F66"=>"\u758B",
- "\u2F67"=>"\u7592",
- "\u2F68"=>"\u7676",
- "\u2F69"=>"\u767D",
- "\u2F6A"=>"\u76AE",
- "\u2F6B"=>"\u76BF",
- "\u2F6C"=>"\u76EE",
- "\u2F6D"=>"\u77DB",
- "\u2F6E"=>"\u77E2",
- "\u2F6F"=>"\u77F3",
- "\u2F70"=>"\u793A",
- "\u2F71"=>"\u79B8",
- "\u2F72"=>"\u79BE",
- "\u2F73"=>"\u7A74",
- "\u2F74"=>"\u7ACB",
- "\u2F75"=>"\u7AF9",
- "\u2F76"=>"\u7C73",
- "\u2F77"=>"\u7CF8",
- "\u2F78"=>"\u7F36",
- "\u2F79"=>"\u7F51",
- "\u2F7A"=>"\u7F8A",
- "\u2F7B"=>"\u7FBD",
- "\u2F7C"=>"\u8001",
- "\u2F7D"=>"\u800C",
- "\u2F7E"=>"\u8012",
- "\u2F7F"=>"\u8033",
- "\u2F80"=>"\u807F",
- "\u2F81"=>"\u8089",
- "\u2F82"=>"\u81E3",
- "\u2F83"=>"\u81EA",
- "\u2F84"=>"\u81F3",
- "\u2F85"=>"\u81FC",
- "\u2F86"=>"\u820C",
- "\u2F87"=>"\u821B",
- "\u2F88"=>"\u821F",
- "\u2F89"=>"\u826E",
- "\u2F8A"=>"\u8272",
- "\u2F8B"=>"\u8278",
- "\u2F8C"=>"\u864D",
- "\u2F8D"=>"\u866B",
- "\u2F8E"=>"\u8840",
- "\u2F8F"=>"\u884C",
- "\u2F90"=>"\u8863",
- "\u2F91"=>"\u897E",
- "\u2F92"=>"\u898B",
- "\u2F93"=>"\u89D2",
- "\u2F94"=>"\u8A00",
- "\u2F95"=>"\u8C37",
- "\u2F96"=>"\u8C46",
- "\u2F97"=>"\u8C55",
- "\u2F98"=>"\u8C78",
- "\u2F99"=>"\u8C9D",
- "\u2F9A"=>"\u8D64",
- "\u2F9B"=>"\u8D70",
- "\u2F9C"=>"\u8DB3",
- "\u2F9D"=>"\u8EAB",
- "\u2F9E"=>"\u8ECA",
- "\u2F9F"=>"\u8F9B",
- "\u2FA0"=>"\u8FB0",
- "\u2FA1"=>"\u8FB5",
- "\u2FA2"=>"\u9091",
- "\u2FA3"=>"\u9149",
- "\u2FA4"=>"\u91C6",
- "\u2FA5"=>"\u91CC",
- "\u2FA6"=>"\u91D1",
- "\u2FA7"=>"\u9577",
- "\u2FA8"=>"\u9580",
- "\u2FA9"=>"\u961C",
- "\u2FAA"=>"\u96B6",
- "\u2FAB"=>"\u96B9",
- "\u2FAC"=>"\u96E8",
- "\u2FAD"=>"\u9751",
- "\u2FAE"=>"\u975E",
- "\u2FAF"=>"\u9762",
- "\u2FB0"=>"\u9769",
- "\u2FB1"=>"\u97CB",
- "\u2FB2"=>"\u97ED",
- "\u2FB3"=>"\u97F3",
- "\u2FB4"=>"\u9801",
- "\u2FB5"=>"\u98A8",
- "\u2FB6"=>"\u98DB",
- "\u2FB7"=>"\u98DF",
- "\u2FB8"=>"\u9996",
- "\u2FB9"=>"\u9999",
- "\u2FBA"=>"\u99AC",
- "\u2FBB"=>"\u9AA8",
- "\u2FBC"=>"\u9AD8",
- "\u2FBD"=>"\u9ADF",
- "\u2FBE"=>"\u9B25",
- "\u2FBF"=>"\u9B2F",
- "\u2FC0"=>"\u9B32",
- "\u2FC1"=>"\u9B3C",
- "\u2FC2"=>"\u9B5A",
- "\u2FC3"=>"\u9CE5",
- "\u2FC4"=>"\u9E75",
- "\u2FC5"=>"\u9E7F",
- "\u2FC6"=>"\u9EA5",
- "\u2FC7"=>"\u9EBB",
- "\u2FC8"=>"\u9EC3",
- "\u2FC9"=>"\u9ECD",
- "\u2FCA"=>"\u9ED1",
- "\u2FCB"=>"\u9EF9",
- "\u2FCC"=>"\u9EFD",
- "\u2FCD"=>"\u9F0E",
- "\u2FCE"=>"\u9F13",
- "\u2FCF"=>"\u9F20",
- "\u2FD0"=>"\u9F3B",
- "\u2FD1"=>"\u9F4A",
- "\u2FD2"=>"\u9F52",
- "\u2FD3"=>"\u9F8D",
- "\u2FD4"=>"\u9F9C",
- "\u2FD5"=>"\u9FA0",
- "\u3000"=>" ",
- "\u3036"=>"\u3012",
- "\u3038"=>"\u5341",
- "\u3039"=>"\u5344",
- "\u303A"=>"\u5345",
- "\u309B"=>" \u3099",
- "\u309C"=>" \u309A",
- "\u309F"=>"\u3088\u308A",
- "\u30FF"=>"\u30B3\u30C8",
- "\u3131"=>"\u1100",
- "\u3132"=>"\u1101",
- "\u3133"=>"\u11AA",
- "\u3134"=>"\u1102",
- "\u3135"=>"\u11AC",
- "\u3136"=>"\u11AD",
- "\u3137"=>"\u1103",
- "\u3138"=>"\u1104",
- "\u3139"=>"\u1105",
- "\u313A"=>"\u11B0",
- "\u313B"=>"\u11B1",
- "\u313C"=>"\u11B2",
- "\u313D"=>"\u11B3",
- "\u313E"=>"\u11B4",
- "\u313F"=>"\u11B5",
- "\u3140"=>"\u111A",
- "\u3141"=>"\u1106",
- "\u3142"=>"\u1107",
- "\u3143"=>"\u1108",
- "\u3144"=>"\u1121",
- "\u3145"=>"\u1109",
- "\u3146"=>"\u110A",
- "\u3147"=>"\u110B",
- "\u3148"=>"\u110C",
- "\u3149"=>"\u110D",
- "\u314A"=>"\u110E",
- "\u314B"=>"\u110F",
- "\u314C"=>"\u1110",
- "\u314D"=>"\u1111",
- "\u314E"=>"\u1112",
- "\u314F"=>"\u1161",
- "\u3150"=>"\u1162",
- "\u3151"=>"\u1163",
- "\u3152"=>"\u1164",
- "\u3153"=>"\u1165",
- "\u3154"=>"\u1166",
- "\u3155"=>"\u1167",
- "\u3156"=>"\u1168",
- "\u3157"=>"\u1169",
- "\u3158"=>"\u116A",
- "\u3159"=>"\u116B",
- "\u315A"=>"\u116C",
- "\u315B"=>"\u116D",
- "\u315C"=>"\u116E",
- "\u315D"=>"\u116F",
- "\u315E"=>"\u1170",
- "\u315F"=>"\u1171",
- "\u3160"=>"\u1172",
- "\u3161"=>"\u1173",
- "\u3162"=>"\u1174",
- "\u3163"=>"\u1175",
- "\u3164"=>"\u1160",
- "\u3165"=>"\u1114",
- "\u3166"=>"\u1115",
- "\u3167"=>"\u11C7",
- "\u3168"=>"\u11C8",
- "\u3169"=>"\u11CC",
- "\u316A"=>"\u11CE",
- "\u316B"=>"\u11D3",
- "\u316C"=>"\u11D7",
- "\u316D"=>"\u11D9",
- "\u316E"=>"\u111C",
- "\u316F"=>"\u11DD",
- "\u3170"=>"\u11DF",
- "\u3171"=>"\u111D",
- "\u3172"=>"\u111E",
- "\u3173"=>"\u1120",
- "\u3174"=>"\u1122",
- "\u3175"=>"\u1123",
- "\u3176"=>"\u1127",
- "\u3177"=>"\u1129",
- "\u3178"=>"\u112B",
- "\u3179"=>"\u112C",
- "\u317A"=>"\u112D",
- "\u317B"=>"\u112E",
- "\u317C"=>"\u112F",
- "\u317D"=>"\u1132",
- "\u317E"=>"\u1136",
- "\u317F"=>"\u1140",
- "\u3180"=>"\u1147",
- "\u3181"=>"\u114C",
- "\u3182"=>"\u11F1",
- "\u3183"=>"\u11F2",
- "\u3184"=>"\u1157",
- "\u3185"=>"\u1158",
- "\u3186"=>"\u1159",
- "\u3187"=>"\u1184",
- "\u3188"=>"\u1185",
- "\u3189"=>"\u1188",
- "\u318A"=>"\u1191",
- "\u318B"=>"\u1192",
- "\u318C"=>"\u1194",
- "\u318D"=>"\u119E",
- "\u318E"=>"\u11A1",
- "\u3192"=>"\u4E00",
- "\u3193"=>"\u4E8C",
- "\u3194"=>"\u4E09",
- "\u3195"=>"\u56DB",
- "\u3196"=>"\u4E0A",
- "\u3197"=>"\u4E2D",
- "\u3198"=>"\u4E0B",
- "\u3199"=>"\u7532",
- "\u319A"=>"\u4E59",
- "\u319B"=>"\u4E19",
- "\u319C"=>"\u4E01",
- "\u319D"=>"\u5929",
- "\u319E"=>"\u5730",
- "\u319F"=>"\u4EBA",
- "\u3200"=>"(\u1100)",
- "\u3201"=>"(\u1102)",
- "\u3202"=>"(\u1103)",
- "\u3203"=>"(\u1105)",
- "\u3204"=>"(\u1106)",
- "\u3205"=>"(\u1107)",
- "\u3206"=>"(\u1109)",
- "\u3207"=>"(\u110B)",
- "\u3208"=>"(\u110C)",
- "\u3209"=>"(\u110E)",
- "\u320A"=>"(\u110F)",
- "\u320B"=>"(\u1110)",
- "\u320C"=>"(\u1111)",
- "\u320D"=>"(\u1112)",
- "\u320E"=>"(\u1100\u1161)",
- "\u320F"=>"(\u1102\u1161)",
- "\u3210"=>"(\u1103\u1161)",
- "\u3211"=>"(\u1105\u1161)",
- "\u3212"=>"(\u1106\u1161)",
- "\u3213"=>"(\u1107\u1161)",
- "\u3214"=>"(\u1109\u1161)",
- "\u3215"=>"(\u110B\u1161)",
- "\u3216"=>"(\u110C\u1161)",
- "\u3217"=>"(\u110E\u1161)",
- "\u3218"=>"(\u110F\u1161)",
- "\u3219"=>"(\u1110\u1161)",
- "\u321A"=>"(\u1111\u1161)",
- "\u321B"=>"(\u1112\u1161)",
- "\u321C"=>"(\u110C\u116E)",
- "\u321D"=>"(\u110B\u1169\u110C\u1165\u11AB)",
- "\u321E"=>"(\u110B\u1169\u1112\u116E)",
- "\u3220"=>"(\u4E00)",
- "\u3221"=>"(\u4E8C)",
- "\u3222"=>"(\u4E09)",
- "\u3223"=>"(\u56DB)",
- "\u3224"=>"(\u4E94)",
- "\u3225"=>"(\u516D)",
- "\u3226"=>"(\u4E03)",
- "\u3227"=>"(\u516B)",
- "\u3228"=>"(\u4E5D)",
- "\u3229"=>"(\u5341)",
- "\u322A"=>"(\u6708)",
- "\u322B"=>"(\u706B)",
- "\u322C"=>"(\u6C34)",
- "\u322D"=>"(\u6728)",
- "\u322E"=>"(\u91D1)",
- "\u322F"=>"(\u571F)",
- "\u3230"=>"(\u65E5)",
- "\u3231"=>"(\u682A)",
- "\u3232"=>"(\u6709)",
- "\u3233"=>"(\u793E)",
- "\u3234"=>"(\u540D)",
- "\u3235"=>"(\u7279)",
- "\u3236"=>"(\u8CA1)",
- "\u3237"=>"(\u795D)",
- "\u3238"=>"(\u52B4)",
- "\u3239"=>"(\u4EE3)",
- "\u323A"=>"(\u547C)",
- "\u323B"=>"(\u5B66)",
- "\u323C"=>"(\u76E3)",
- "\u323D"=>"(\u4F01)",
- "\u323E"=>"(\u8CC7)",
- "\u323F"=>"(\u5354)",
- "\u3240"=>"(\u796D)",
- "\u3241"=>"(\u4F11)",
- "\u3242"=>"(\u81EA)",
- "\u3243"=>"(\u81F3)",
- "\u3244"=>"\u554F",
- "\u3245"=>"\u5E7C",
- "\u3246"=>"\u6587",
- "\u3247"=>"\u7B8F",
- "\u3250"=>"PTE",
- "\u3251"=>"21",
- "\u3252"=>"22",
- "\u3253"=>"23",
- "\u3254"=>"24",
- "\u3255"=>"25",
- "\u3256"=>"26",
- "\u3257"=>"27",
- "\u3258"=>"28",
- "\u3259"=>"29",
- "\u325A"=>"30",
- "\u325B"=>"31",
- "\u325C"=>"32",
- "\u325D"=>"33",
- "\u325E"=>"34",
- "\u325F"=>"35",
- "\u3260"=>"\u1100",
- "\u3261"=>"\u1102",
- "\u3262"=>"\u1103",
- "\u3263"=>"\u1105",
- "\u3264"=>"\u1106",
- "\u3265"=>"\u1107",
- "\u3266"=>"\u1109",
- "\u3267"=>"\u110B",
- "\u3268"=>"\u110C",
- "\u3269"=>"\u110E",
- "\u326A"=>"\u110F",
- "\u326B"=>"\u1110",
- "\u326C"=>"\u1111",
- "\u326D"=>"\u1112",
- "\u326E"=>"\u1100\u1161",
- "\u326F"=>"\u1102\u1161",
- "\u3270"=>"\u1103\u1161",
- "\u3271"=>"\u1105\u1161",
- "\u3272"=>"\u1106\u1161",
- "\u3273"=>"\u1107\u1161",
- "\u3274"=>"\u1109\u1161",
- "\u3275"=>"\u110B\u1161",
- "\u3276"=>"\u110C\u1161",
- "\u3277"=>"\u110E\u1161",
- "\u3278"=>"\u110F\u1161",
- "\u3279"=>"\u1110\u1161",
- "\u327A"=>"\u1111\u1161",
- "\u327B"=>"\u1112\u1161",
- "\u327C"=>"\u110E\u1161\u11B7\u1100\u1169",
- "\u327D"=>"\u110C\u116E\u110B\u1174",
- "\u327E"=>"\u110B\u116E",
- "\u3280"=>"\u4E00",
- "\u3281"=>"\u4E8C",
- "\u3282"=>"\u4E09",
- "\u3283"=>"\u56DB",
- "\u3284"=>"\u4E94",
- "\u3285"=>"\u516D",
- "\u3286"=>"\u4E03",
- "\u3287"=>"\u516B",
- "\u3288"=>"\u4E5D",
- "\u3289"=>"\u5341",
- "\u328A"=>"\u6708",
- "\u328B"=>"\u706B",
- "\u328C"=>"\u6C34",
- "\u328D"=>"\u6728",
- "\u328E"=>"\u91D1",
- "\u328F"=>"\u571F",
- "\u3290"=>"\u65E5",
- "\u3291"=>"\u682A",
- "\u3292"=>"\u6709",
- "\u3293"=>"\u793E",
- "\u3294"=>"\u540D",
- "\u3295"=>"\u7279",
- "\u3296"=>"\u8CA1",
- "\u3297"=>"\u795D",
- "\u3298"=>"\u52B4",
- "\u3299"=>"\u79D8",
- "\u329A"=>"\u7537",
- "\u329B"=>"\u5973",
- "\u329C"=>"\u9069",
- "\u329D"=>"\u512A",
- "\u329E"=>"\u5370",
- "\u329F"=>"\u6CE8",
- "\u32A0"=>"\u9805",
- "\u32A1"=>"\u4F11",
- "\u32A2"=>"\u5199",
- "\u32A3"=>"\u6B63",
- "\u32A4"=>"\u4E0A",
- "\u32A5"=>"\u4E2D",
- "\u32A6"=>"\u4E0B",
- "\u32A7"=>"\u5DE6",
- "\u32A8"=>"\u53F3",
- "\u32A9"=>"\u533B",
- "\u32AA"=>"\u5B97",
- "\u32AB"=>"\u5B66",
- "\u32AC"=>"\u76E3",
- "\u32AD"=>"\u4F01",
- "\u32AE"=>"\u8CC7",
- "\u32AF"=>"\u5354",
- "\u32B0"=>"\u591C",
- "\u32B1"=>"36",
- "\u32B2"=>"37",
- "\u32B3"=>"38",
- "\u32B4"=>"39",
- "\u32B5"=>"40",
- "\u32B6"=>"41",
- "\u32B7"=>"42",
- "\u32B8"=>"43",
- "\u32B9"=>"44",
- "\u32BA"=>"45",
- "\u32BB"=>"46",
- "\u32BC"=>"47",
- "\u32BD"=>"48",
- "\u32BE"=>"49",
- "\u32BF"=>"50",
- "\u32C0"=>"1\u6708",
- "\u32C1"=>"2\u6708",
- "\u32C2"=>"3\u6708",
- "\u32C3"=>"4\u6708",
- "\u32C4"=>"5\u6708",
- "\u32C5"=>"6\u6708",
- "\u32C6"=>"7\u6708",
- "\u32C7"=>"8\u6708",
- "\u32C8"=>"9\u6708",
- "\u32C9"=>"10\u6708",
- "\u32CA"=>"11\u6708",
- "\u32CB"=>"12\u6708",
- "\u32CC"=>"Hg",
- "\u32CD"=>"erg",
- "\u32CE"=>"eV",
- "\u32CF"=>"LTD",
- "\u32D0"=>"\u30A2",
- "\u32D1"=>"\u30A4",
- "\u32D2"=>"\u30A6",
- "\u32D3"=>"\u30A8",
- "\u32D4"=>"\u30AA",
- "\u32D5"=>"\u30AB",
- "\u32D6"=>"\u30AD",
- "\u32D7"=>"\u30AF",
- "\u32D8"=>"\u30B1",
- "\u32D9"=>"\u30B3",
- "\u32DA"=>"\u30B5",
- "\u32DB"=>"\u30B7",
- "\u32DC"=>"\u30B9",
- "\u32DD"=>"\u30BB",
- "\u32DE"=>"\u30BD",
- "\u32DF"=>"\u30BF",
- "\u32E0"=>"\u30C1",
- "\u32E1"=>"\u30C4",
- "\u32E2"=>"\u30C6",
- "\u32E3"=>"\u30C8",
- "\u32E4"=>"\u30CA",
- "\u32E5"=>"\u30CB",
- "\u32E6"=>"\u30CC",
- "\u32E7"=>"\u30CD",
- "\u32E8"=>"\u30CE",
- "\u32E9"=>"\u30CF",
- "\u32EA"=>"\u30D2",
- "\u32EB"=>"\u30D5",
- "\u32EC"=>"\u30D8",
- "\u32ED"=>"\u30DB",
- "\u32EE"=>"\u30DE",
- "\u32EF"=>"\u30DF",
- "\u32F0"=>"\u30E0",
- "\u32F1"=>"\u30E1",
- "\u32F2"=>"\u30E2",
- "\u32F3"=>"\u30E4",
- "\u32F4"=>"\u30E6",
- "\u32F5"=>"\u30E8",
- "\u32F6"=>"\u30E9",
- "\u32F7"=>"\u30EA",
- "\u32F8"=>"\u30EB",
- "\u32F9"=>"\u30EC",
- "\u32FA"=>"\u30ED",
- "\u32FB"=>"\u30EF",
- "\u32FC"=>"\u30F0",
- "\u32FD"=>"\u30F1",
- "\u32FE"=>"\u30F2",
- "\u32FF"=>"\u4EE4\u548C",
- "\u3300"=>"\u30A2\u30D1\u30FC\u30C8",
- "\u3301"=>"\u30A2\u30EB\u30D5\u30A1",
- "\u3302"=>"\u30A2\u30F3\u30DA\u30A2",
- "\u3303"=>"\u30A2\u30FC\u30EB",
- "\u3304"=>"\u30A4\u30CB\u30F3\u30B0",
- "\u3305"=>"\u30A4\u30F3\u30C1",
- "\u3306"=>"\u30A6\u30A9\u30F3",
- "\u3307"=>"\u30A8\u30B9\u30AF\u30FC\u30C9",
- "\u3308"=>"\u30A8\u30FC\u30AB\u30FC",
- "\u3309"=>"\u30AA\u30F3\u30B9",
- "\u330A"=>"\u30AA\u30FC\u30E0",
- "\u330B"=>"\u30AB\u30A4\u30EA",
- "\u330C"=>"\u30AB\u30E9\u30C3\u30C8",
- "\u330D"=>"\u30AB\u30ED\u30EA\u30FC",
- "\u330E"=>"\u30AC\u30ED\u30F3",
- "\u330F"=>"\u30AC\u30F3\u30DE",
- "\u3310"=>"\u30AE\u30AC",
- "\u3311"=>"\u30AE\u30CB\u30FC",
- "\u3312"=>"\u30AD\u30E5\u30EA\u30FC",
- "\u3313"=>"\u30AE\u30EB\u30C0\u30FC",
- "\u3314"=>"\u30AD\u30ED",
- "\u3315"=>"\u30AD\u30ED\u30B0\u30E9\u30E0",
- "\u3316"=>"\u30AD\u30ED\u30E1\u30FC\u30C8\u30EB",
- "\u3317"=>"\u30AD\u30ED\u30EF\u30C3\u30C8",
- "\u3318"=>"\u30B0\u30E9\u30E0",
- "\u3319"=>"\u30B0\u30E9\u30E0\u30C8\u30F3",
- "\u331A"=>"\u30AF\u30EB\u30BC\u30A4\u30ED",
- "\u331B"=>"\u30AF\u30ED\u30FC\u30CD",
- "\u331C"=>"\u30B1\u30FC\u30B9",
- "\u331D"=>"\u30B3\u30EB\u30CA",
- "\u331E"=>"\u30B3\u30FC\u30DD",
- "\u331F"=>"\u30B5\u30A4\u30AF\u30EB",
- "\u3320"=>"\u30B5\u30F3\u30C1\u30FC\u30E0",
- "\u3321"=>"\u30B7\u30EA\u30F3\u30B0",
- "\u3322"=>"\u30BB\u30F3\u30C1",
- "\u3323"=>"\u30BB\u30F3\u30C8",
- "\u3324"=>"\u30C0\u30FC\u30B9",
- "\u3325"=>"\u30C7\u30B7",
- "\u3326"=>"\u30C9\u30EB",
- "\u3327"=>"\u30C8\u30F3",
- "\u3328"=>"\u30CA\u30CE",
- "\u3329"=>"\u30CE\u30C3\u30C8",
- "\u332A"=>"\u30CF\u30A4\u30C4",
- "\u332B"=>"\u30D1\u30FC\u30BB\u30F3\u30C8",
- "\u332C"=>"\u30D1\u30FC\u30C4",
- "\u332D"=>"\u30D0\u30FC\u30EC\u30EB",
- "\u332E"=>"\u30D4\u30A2\u30B9\u30C8\u30EB",
- "\u332F"=>"\u30D4\u30AF\u30EB",
- "\u3330"=>"\u30D4\u30B3",
- "\u3331"=>"\u30D3\u30EB",
- "\u3332"=>"\u30D5\u30A1\u30E9\u30C3\u30C9",
- "\u3333"=>"\u30D5\u30A3\u30FC\u30C8",
- "\u3334"=>"\u30D6\u30C3\u30B7\u30A7\u30EB",
- "\u3335"=>"\u30D5\u30E9\u30F3",
- "\u3336"=>"\u30D8\u30AF\u30BF\u30FC\u30EB",
- "\u3337"=>"\u30DA\u30BD",
- "\u3338"=>"\u30DA\u30CB\u30D2",
- "\u3339"=>"\u30D8\u30EB\u30C4",
- "\u333A"=>"\u30DA\u30F3\u30B9",
- "\u333B"=>"\u30DA\u30FC\u30B8",
- "\u333C"=>"\u30D9\u30FC\u30BF",
- "\u333D"=>"\u30DD\u30A4\u30F3\u30C8",
- "\u333E"=>"\u30DC\u30EB\u30C8",
- "\u333F"=>"\u30DB\u30F3",
- "\u3340"=>"\u30DD\u30F3\u30C9",
- "\u3341"=>"\u30DB\u30FC\u30EB",
- "\u3342"=>"\u30DB\u30FC\u30F3",
- "\u3343"=>"\u30DE\u30A4\u30AF\u30ED",
- "\u3344"=>"\u30DE\u30A4\u30EB",
- "\u3345"=>"\u30DE\u30C3\u30CF",
- "\u3346"=>"\u30DE\u30EB\u30AF",
- "\u3347"=>"\u30DE\u30F3\u30B7\u30E7\u30F3",
- "\u3348"=>"\u30DF\u30AF\u30ED\u30F3",
- "\u3349"=>"\u30DF\u30EA",
- "\u334A"=>"\u30DF\u30EA\u30D0\u30FC\u30EB",
- "\u334B"=>"\u30E1\u30AC",
- "\u334C"=>"\u30E1\u30AC\u30C8\u30F3",
- "\u334D"=>"\u30E1\u30FC\u30C8\u30EB",
- "\u334E"=>"\u30E4\u30FC\u30C9",
- "\u334F"=>"\u30E4\u30FC\u30EB",
- "\u3350"=>"\u30E6\u30A2\u30F3",
- "\u3351"=>"\u30EA\u30C3\u30C8\u30EB",
- "\u3352"=>"\u30EA\u30E9",
- "\u3353"=>"\u30EB\u30D4\u30FC",
- "\u3354"=>"\u30EB\u30FC\u30D6\u30EB",
- "\u3355"=>"\u30EC\u30E0",
- "\u3356"=>"\u30EC\u30F3\u30C8\u30B2\u30F3",
- "\u3357"=>"\u30EF\u30C3\u30C8",
- "\u3358"=>"0\u70B9",
- "\u3359"=>"1\u70B9",
- "\u335A"=>"2\u70B9",
- "\u335B"=>"3\u70B9",
- "\u335C"=>"4\u70B9",
- "\u335D"=>"5\u70B9",
- "\u335E"=>"6\u70B9",
- "\u335F"=>"7\u70B9",
- "\u3360"=>"8\u70B9",
- "\u3361"=>"9\u70B9",
- "\u3362"=>"10\u70B9",
- "\u3363"=>"11\u70B9",
- "\u3364"=>"12\u70B9",
- "\u3365"=>"13\u70B9",
- "\u3366"=>"14\u70B9",
- "\u3367"=>"15\u70B9",
- "\u3368"=>"16\u70B9",
- "\u3369"=>"17\u70B9",
- "\u336A"=>"18\u70B9",
- "\u336B"=>"19\u70B9",
- "\u336C"=>"20\u70B9",
- "\u336D"=>"21\u70B9",
- "\u336E"=>"22\u70B9",
- "\u336F"=>"23\u70B9",
- "\u3370"=>"24\u70B9",
- "\u3371"=>"hPa",
- "\u3372"=>"da",
- "\u3373"=>"AU",
- "\u3374"=>"bar",
- "\u3375"=>"oV",
- "\u3376"=>"pc",
- "\u3377"=>"dm",
- "\u3378"=>"dm2",
- "\u3379"=>"dm3",
- "\u337A"=>"IU",
- "\u337B"=>"\u5E73\u6210",
- "\u337C"=>"\u662D\u548C",
- "\u337D"=>"\u5927\u6B63",
- "\u337E"=>"\u660E\u6CBB",
- "\u337F"=>"\u682A\u5F0F\u4F1A\u793E",
- "\u3380"=>"pA",
- "\u3381"=>"nA",
- "\u3382"=>"\u03BCA",
- "\u3383"=>"mA",
- "\u3384"=>"kA",
- "\u3385"=>"KB",
- "\u3386"=>"MB",
- "\u3387"=>"GB",
- "\u3388"=>"cal",
- "\u3389"=>"kcal",
- "\u338A"=>"pF",
- "\u338B"=>"nF",
- "\u338C"=>"\u03BCF",
- "\u338D"=>"\u03BCg",
- "\u338E"=>"mg",
- "\u338F"=>"kg",
- "\u3390"=>"Hz",
- "\u3391"=>"kHz",
- "\u3392"=>"MHz",
- "\u3393"=>"GHz",
- "\u3394"=>"THz",
- "\u3395"=>"\u03BCl",
- "\u3396"=>"ml",
- "\u3397"=>"dl",
- "\u3398"=>"kl",
- "\u3399"=>"fm",
- "\u339A"=>"nm",
- "\u339B"=>"\u03BCm",
- "\u339C"=>"mm",
- "\u339D"=>"cm",
- "\u339E"=>"km",
- "\u339F"=>"mm2",
- "\u33A0"=>"cm2",
- "\u33A1"=>"m2",
- "\u33A2"=>"km2",
- "\u33A3"=>"mm3",
- "\u33A4"=>"cm3",
- "\u33A5"=>"m3",
- "\u33A6"=>"km3",
- "\u33A7"=>"m\u2215s",
- "\u33A8"=>"m\u2215s2",
- "\u33A9"=>"Pa",
- "\u33AA"=>"kPa",
- "\u33AB"=>"MPa",
- "\u33AC"=>"GPa",
- "\u33AD"=>"rad",
- "\u33AE"=>"rad\u2215s",
- "\u33AF"=>"rad\u2215s2",
- "\u33B0"=>"ps",
- "\u33B1"=>"ns",
- "\u33B2"=>"\u03BCs",
- "\u33B3"=>"ms",
- "\u33B4"=>"pV",
- "\u33B5"=>"nV",
- "\u33B6"=>"\u03BCV",
- "\u33B7"=>"mV",
- "\u33B8"=>"kV",
- "\u33B9"=>"MV",
- "\u33BA"=>"pW",
- "\u33BB"=>"nW",
- "\u33BC"=>"\u03BCW",
- "\u33BD"=>"mW",
- "\u33BE"=>"kW",
- "\u33BF"=>"MW",
- "\u33C0"=>"k\u03A9",
- "\u33C1"=>"M\u03A9",
- "\u33C2"=>"a.m.",
- "\u33C3"=>"Bq",
- "\u33C4"=>"cc",
- "\u33C5"=>"cd",
- "\u33C6"=>"C\u2215kg",
- "\u33C7"=>"Co.",
- "\u33C8"=>"dB",
- "\u33C9"=>"Gy",
- "\u33CA"=>"ha",
- "\u33CB"=>"HP",
- "\u33CC"=>"in",
- "\u33CD"=>"KK",
- "\u33CE"=>"KM",
- "\u33CF"=>"kt",
- "\u33D0"=>"lm",
- "\u33D1"=>"ln",
- "\u33D2"=>"log",
- "\u33D3"=>"lx",
- "\u33D4"=>"mb",
- "\u33D5"=>"mil",
- "\u33D6"=>"mol",
- "\u33D7"=>"PH",
- "\u33D8"=>"p.m.",
- "\u33D9"=>"PPM",
- "\u33DA"=>"PR",
- "\u33DB"=>"sr",
- "\u33DC"=>"Sv",
- "\u33DD"=>"Wb",
- "\u33DE"=>"V\u2215m",
- "\u33DF"=>"A\u2215m",
- "\u33E0"=>"1\u65E5",
- "\u33E1"=>"2\u65E5",
- "\u33E2"=>"3\u65E5",
- "\u33E3"=>"4\u65E5",
- "\u33E4"=>"5\u65E5",
- "\u33E5"=>"6\u65E5",
- "\u33E6"=>"7\u65E5",
- "\u33E7"=>"8\u65E5",
- "\u33E8"=>"9\u65E5",
- "\u33E9"=>"10\u65E5",
- "\u33EA"=>"11\u65E5",
- "\u33EB"=>"12\u65E5",
- "\u33EC"=>"13\u65E5",
- "\u33ED"=>"14\u65E5",
- "\u33EE"=>"15\u65E5",
- "\u33EF"=>"16\u65E5",
- "\u33F0"=>"17\u65E5",
- "\u33F1"=>"18\u65E5",
- "\u33F2"=>"19\u65E5",
- "\u33F3"=>"20\u65E5",
- "\u33F4"=>"21\u65E5",
- "\u33F5"=>"22\u65E5",
- "\u33F6"=>"23\u65E5",
- "\u33F7"=>"24\u65E5",
- "\u33F8"=>"25\u65E5",
- "\u33F9"=>"26\u65E5",
- "\u33FA"=>"27\u65E5",
- "\u33FB"=>"28\u65E5",
- "\u33FC"=>"29\u65E5",
- "\u33FD"=>"30\u65E5",
- "\u33FE"=>"31\u65E5",
- "\u33FF"=>"gal",
- "\uA69C"=>"\u044A",
- "\uA69D"=>"\u044C",
- "\uA770"=>"\uA76F",
- "\uA7F8"=>"\u0126",
- "\uA7F9"=>"\u0153",
- "\uAB5C"=>"\uA727",
- "\uAB5D"=>"\uAB37",
- "\uAB5E"=>"\u026B",
- "\uAB5F"=>"\uAB52",
- "\uFB00"=>"ff",
- "\uFB01"=>"fi",
- "\uFB02"=>"fl",
- "\uFB03"=>"ffi",
- "\uFB04"=>"ffl",
- "\uFB05"=>"st",
- "\uFB06"=>"st",
- "\uFB13"=>"\u0574\u0576",
- "\uFB14"=>"\u0574\u0565",
- "\uFB15"=>"\u0574\u056B",
- "\uFB16"=>"\u057E\u0576",
- "\uFB17"=>"\u0574\u056D",
- "\uFB20"=>"\u05E2",
- "\uFB21"=>"\u05D0",
- "\uFB22"=>"\u05D3",
- "\uFB23"=>"\u05D4",
- "\uFB24"=>"\u05DB",
- "\uFB25"=>"\u05DC",
- "\uFB26"=>"\u05DD",
- "\uFB27"=>"\u05E8",
- "\uFB28"=>"\u05EA",
- "\uFB29"=>"+",
- "\uFB4F"=>"\u05D0\u05DC",
- "\uFB50"=>"\u0671",
- "\uFB51"=>"\u0671",
- "\uFB52"=>"\u067B",
- "\uFB53"=>"\u067B",
- "\uFB54"=>"\u067B",
- "\uFB55"=>"\u067B",
- "\uFB56"=>"\u067E",
- "\uFB57"=>"\u067E",
- "\uFB58"=>"\u067E",
- "\uFB59"=>"\u067E",
- "\uFB5A"=>"\u0680",
- "\uFB5B"=>"\u0680",
- "\uFB5C"=>"\u0680",
- "\uFB5D"=>"\u0680",
- "\uFB5E"=>"\u067A",
- "\uFB5F"=>"\u067A",
- "\uFB60"=>"\u067A",
- "\uFB61"=>"\u067A",
- "\uFB62"=>"\u067F",
- "\uFB63"=>"\u067F",
- "\uFB64"=>"\u067F",
- "\uFB65"=>"\u067F",
- "\uFB66"=>"\u0679",
- "\uFB67"=>"\u0679",
- "\uFB68"=>"\u0679",
- "\uFB69"=>"\u0679",
- "\uFB6A"=>"\u06A4",
- "\uFB6B"=>"\u06A4",
- "\uFB6C"=>"\u06A4",
- "\uFB6D"=>"\u06A4",
- "\uFB6E"=>"\u06A6",
- "\uFB6F"=>"\u06A6",
- "\uFB70"=>"\u06A6",
- "\uFB71"=>"\u06A6",
- "\uFB72"=>"\u0684",
- "\uFB73"=>"\u0684",
- "\uFB74"=>"\u0684",
- "\uFB75"=>"\u0684",
- "\uFB76"=>"\u0683",
- "\uFB77"=>"\u0683",
- "\uFB78"=>"\u0683",
- "\uFB79"=>"\u0683",
- "\uFB7A"=>"\u0686",
- "\uFB7B"=>"\u0686",
- "\uFB7C"=>"\u0686",
- "\uFB7D"=>"\u0686",
- "\uFB7E"=>"\u0687",
- "\uFB7F"=>"\u0687",
- "\uFB80"=>"\u0687",
- "\uFB81"=>"\u0687",
- "\uFB82"=>"\u068D",
- "\uFB83"=>"\u068D",
- "\uFB84"=>"\u068C",
- "\uFB85"=>"\u068C",
- "\uFB86"=>"\u068E",
- "\uFB87"=>"\u068E",
- "\uFB88"=>"\u0688",
- "\uFB89"=>"\u0688",
- "\uFB8A"=>"\u0698",
- "\uFB8B"=>"\u0698",
- "\uFB8C"=>"\u0691",
- "\uFB8D"=>"\u0691",
- "\uFB8E"=>"\u06A9",
- "\uFB8F"=>"\u06A9",
- "\uFB90"=>"\u06A9",
- "\uFB91"=>"\u06A9",
- "\uFB92"=>"\u06AF",
- "\uFB93"=>"\u06AF",
- "\uFB94"=>"\u06AF",
- "\uFB95"=>"\u06AF",
- "\uFB96"=>"\u06B3",
- "\uFB97"=>"\u06B3",
- "\uFB98"=>"\u06B3",
- "\uFB99"=>"\u06B3",
- "\uFB9A"=>"\u06B1",
- "\uFB9B"=>"\u06B1",
- "\uFB9C"=>"\u06B1",
- "\uFB9D"=>"\u06B1",
- "\uFB9E"=>"\u06BA",
- "\uFB9F"=>"\u06BA",
- "\uFBA0"=>"\u06BB",
- "\uFBA1"=>"\u06BB",
- "\uFBA2"=>"\u06BB",
- "\uFBA3"=>"\u06BB",
- "\uFBA4"=>"\u06C0",
- "\uFBA5"=>"\u06C0",
- "\uFBA6"=>"\u06C1",
- "\uFBA7"=>"\u06C1",
- "\uFBA8"=>"\u06C1",
- "\uFBA9"=>"\u06C1",
- "\uFBAA"=>"\u06BE",
- "\uFBAB"=>"\u06BE",
- "\uFBAC"=>"\u06BE",
- "\uFBAD"=>"\u06BE",
- "\uFBAE"=>"\u06D2",
- "\uFBAF"=>"\u06D2",
- "\uFBB0"=>"\u06D3",
- "\uFBB1"=>"\u06D3",
- "\uFBD3"=>"\u06AD",
- "\uFBD4"=>"\u06AD",
- "\uFBD5"=>"\u06AD",
- "\uFBD6"=>"\u06AD",
- "\uFBD7"=>"\u06C7",
- "\uFBD8"=>"\u06C7",
- "\uFBD9"=>"\u06C6",
- "\uFBDA"=>"\u06C6",
- "\uFBDB"=>"\u06C8",
- "\uFBDC"=>"\u06C8",
- "\uFBDD"=>"\u06C7\u0674",
- "\uFBDE"=>"\u06CB",
- "\uFBDF"=>"\u06CB",
- "\uFBE0"=>"\u06C5",
- "\uFBE1"=>"\u06C5",
- "\uFBE2"=>"\u06C9",
- "\uFBE3"=>"\u06C9",
- "\uFBE4"=>"\u06D0",
- "\uFBE5"=>"\u06D0",
- "\uFBE6"=>"\u06D0",
- "\uFBE7"=>"\u06D0",
- "\uFBE8"=>"\u0649",
- "\uFBE9"=>"\u0649",
- "\uFBEA"=>"\u0626\u0627",
- "\uFBEB"=>"\u0626\u0627",
- "\uFBEC"=>"\u0626\u06D5",
- "\uFBED"=>"\u0626\u06D5",
- "\uFBEE"=>"\u0626\u0648",
- "\uFBEF"=>"\u0626\u0648",
- "\uFBF0"=>"\u0626\u06C7",
- "\uFBF1"=>"\u0626\u06C7",
- "\uFBF2"=>"\u0626\u06C6",
- "\uFBF3"=>"\u0626\u06C6",
- "\uFBF4"=>"\u0626\u06C8",
- "\uFBF5"=>"\u0626\u06C8",
- "\uFBF6"=>"\u0626\u06D0",
- "\uFBF7"=>"\u0626\u06D0",
- "\uFBF8"=>"\u0626\u06D0",
- "\uFBF9"=>"\u0626\u0649",
- "\uFBFA"=>"\u0626\u0649",
- "\uFBFB"=>"\u0626\u0649",
- "\uFBFC"=>"\u06CC",
- "\uFBFD"=>"\u06CC",
- "\uFBFE"=>"\u06CC",
- "\uFBFF"=>"\u06CC",
- "\uFC00"=>"\u0626\u062C",
- "\uFC01"=>"\u0626\u062D",
- "\uFC02"=>"\u0626\u0645",
- "\uFC03"=>"\u0626\u0649",
- "\uFC04"=>"\u0626\u064A",
- "\uFC05"=>"\u0628\u062C",
- "\uFC06"=>"\u0628\u062D",
- "\uFC07"=>"\u0628\u062E",
- "\uFC08"=>"\u0628\u0645",
- "\uFC09"=>"\u0628\u0649",
- "\uFC0A"=>"\u0628\u064A",
- "\uFC0B"=>"\u062A\u062C",
- "\uFC0C"=>"\u062A\u062D",
- "\uFC0D"=>"\u062A\u062E",
- "\uFC0E"=>"\u062A\u0645",
- "\uFC0F"=>"\u062A\u0649",
- "\uFC10"=>"\u062A\u064A",
- "\uFC11"=>"\u062B\u062C",
- "\uFC12"=>"\u062B\u0645",
- "\uFC13"=>"\u062B\u0649",
- "\uFC14"=>"\u062B\u064A",
- "\uFC15"=>"\u062C\u062D",
- "\uFC16"=>"\u062C\u0645",
- "\uFC17"=>"\u062D\u062C",
- "\uFC18"=>"\u062D\u0645",
- "\uFC19"=>"\u062E\u062C",
- "\uFC1A"=>"\u062E\u062D",
- "\uFC1B"=>"\u062E\u0645",
- "\uFC1C"=>"\u0633\u062C",
- "\uFC1D"=>"\u0633\u062D",
- "\uFC1E"=>"\u0633\u062E",
- "\uFC1F"=>"\u0633\u0645",
- "\uFC20"=>"\u0635\u062D",
- "\uFC21"=>"\u0635\u0645",
- "\uFC22"=>"\u0636\u062C",
- "\uFC23"=>"\u0636\u062D",
- "\uFC24"=>"\u0636\u062E",
- "\uFC25"=>"\u0636\u0645",
- "\uFC26"=>"\u0637\u062D",
- "\uFC27"=>"\u0637\u0645",
- "\uFC28"=>"\u0638\u0645",
- "\uFC29"=>"\u0639\u062C",
- "\uFC2A"=>"\u0639\u0645",
- "\uFC2B"=>"\u063A\u062C",
- "\uFC2C"=>"\u063A\u0645",
- "\uFC2D"=>"\u0641\u062C",
- "\uFC2E"=>"\u0641\u062D",
- "\uFC2F"=>"\u0641\u062E",
- "\uFC30"=>"\u0641\u0645",
- "\uFC31"=>"\u0641\u0649",
- "\uFC32"=>"\u0641\u064A",
- "\uFC33"=>"\u0642\u062D",
- "\uFC34"=>"\u0642\u0645",
- "\uFC35"=>"\u0642\u0649",
- "\uFC36"=>"\u0642\u064A",
- "\uFC37"=>"\u0643\u0627",
- "\uFC38"=>"\u0643\u062C",
- "\uFC39"=>"\u0643\u062D",
- "\uFC3A"=>"\u0643\u062E",
- "\uFC3B"=>"\u0643\u0644",
- "\uFC3C"=>"\u0643\u0645",
- "\uFC3D"=>"\u0643\u0649",
- "\uFC3E"=>"\u0643\u064A",
- "\uFC3F"=>"\u0644\u062C",
- "\uFC40"=>"\u0644\u062D",
- "\uFC41"=>"\u0644\u062E",
- "\uFC42"=>"\u0644\u0645",
- "\uFC43"=>"\u0644\u0649",
- "\uFC44"=>"\u0644\u064A",
- "\uFC45"=>"\u0645\u062C",
- "\uFC46"=>"\u0645\u062D",
- "\uFC47"=>"\u0645\u062E",
- "\uFC48"=>"\u0645\u0645",
- "\uFC49"=>"\u0645\u0649",
- "\uFC4A"=>"\u0645\u064A",
- "\uFC4B"=>"\u0646\u062C",
- "\uFC4C"=>"\u0646\u062D",
- "\uFC4D"=>"\u0646\u062E",
- "\uFC4E"=>"\u0646\u0645",
- "\uFC4F"=>"\u0646\u0649",
- "\uFC50"=>"\u0646\u064A",
- "\uFC51"=>"\u0647\u062C",
- "\uFC52"=>"\u0647\u0645",
- "\uFC53"=>"\u0647\u0649",
- "\uFC54"=>"\u0647\u064A",
- "\uFC55"=>"\u064A\u062C",
- "\uFC56"=>"\u064A\u062D",
- "\uFC57"=>"\u064A\u062E",
- "\uFC58"=>"\u064A\u0645",
- "\uFC59"=>"\u064A\u0649",
- "\uFC5A"=>"\u064A\u064A",
- "\uFC5B"=>"\u0630\u0670",
- "\uFC5C"=>"\u0631\u0670",
- "\uFC5D"=>"\u0649\u0670",
- "\uFC5E"=>" \u064C\u0651",
- "\uFC5F"=>" \u064D\u0651",
- "\uFC60"=>" \u064E\u0651",
- "\uFC61"=>" \u064F\u0651",
- "\uFC62"=>" \u0650\u0651",
- "\uFC63"=>" \u0651\u0670",
- "\uFC64"=>"\u0626\u0631",
- "\uFC65"=>"\u0626\u0632",
- "\uFC66"=>"\u0626\u0645",
- "\uFC67"=>"\u0626\u0646",
- "\uFC68"=>"\u0626\u0649",
- "\uFC69"=>"\u0626\u064A",
- "\uFC6A"=>"\u0628\u0631",
- "\uFC6B"=>"\u0628\u0632",
- "\uFC6C"=>"\u0628\u0645",
- "\uFC6D"=>"\u0628\u0646",
- "\uFC6E"=>"\u0628\u0649",
- "\uFC6F"=>"\u0628\u064A",
- "\uFC70"=>"\u062A\u0631",
- "\uFC71"=>"\u062A\u0632",
- "\uFC72"=>"\u062A\u0645",
- "\uFC73"=>"\u062A\u0646",
- "\uFC74"=>"\u062A\u0649",
- "\uFC75"=>"\u062A\u064A",
- "\uFC76"=>"\u062B\u0631",
- "\uFC77"=>"\u062B\u0632",
- "\uFC78"=>"\u062B\u0645",
- "\uFC79"=>"\u062B\u0646",
- "\uFC7A"=>"\u062B\u0649",
- "\uFC7B"=>"\u062B\u064A",
- "\uFC7C"=>"\u0641\u0649",
- "\uFC7D"=>"\u0641\u064A",
- "\uFC7E"=>"\u0642\u0649",
- "\uFC7F"=>"\u0642\u064A",
- "\uFC80"=>"\u0643\u0627",
- "\uFC81"=>"\u0643\u0644",
- "\uFC82"=>"\u0643\u0645",
- "\uFC83"=>"\u0643\u0649",
- "\uFC84"=>"\u0643\u064A",
- "\uFC85"=>"\u0644\u0645",
- "\uFC86"=>"\u0644\u0649",
- "\uFC87"=>"\u0644\u064A",
- "\uFC88"=>"\u0645\u0627",
- "\uFC89"=>"\u0645\u0645",
- "\uFC8A"=>"\u0646\u0631",
- "\uFC8B"=>"\u0646\u0632",
- "\uFC8C"=>"\u0646\u0645",
- "\uFC8D"=>"\u0646\u0646",
- "\uFC8E"=>"\u0646\u0649",
- "\uFC8F"=>"\u0646\u064A",
- "\uFC90"=>"\u0649\u0670",
- "\uFC91"=>"\u064A\u0631",
- "\uFC92"=>"\u064A\u0632",
- "\uFC93"=>"\u064A\u0645",
- "\uFC94"=>"\u064A\u0646",
- "\uFC95"=>"\u064A\u0649",
- "\uFC96"=>"\u064A\u064A",
- "\uFC97"=>"\u0626\u062C",
- "\uFC98"=>"\u0626\u062D",
- "\uFC99"=>"\u0626\u062E",
- "\uFC9A"=>"\u0626\u0645",
- "\uFC9B"=>"\u0626\u0647",
- "\uFC9C"=>"\u0628\u062C",
- "\uFC9D"=>"\u0628\u062D",
- "\uFC9E"=>"\u0628\u062E",
- "\uFC9F"=>"\u0628\u0645",
- "\uFCA0"=>"\u0628\u0647",
- "\uFCA1"=>"\u062A\u062C",
- "\uFCA2"=>"\u062A\u062D",
- "\uFCA3"=>"\u062A\u062E",
- "\uFCA4"=>"\u062A\u0645",
- "\uFCA5"=>"\u062A\u0647",
- "\uFCA6"=>"\u062B\u0645",
- "\uFCA7"=>"\u062C\u062D",
- "\uFCA8"=>"\u062C\u0645",
- "\uFCA9"=>"\u062D\u062C",
- "\uFCAA"=>"\u062D\u0645",
- "\uFCAB"=>"\u062E\u062C",
- "\uFCAC"=>"\u062E\u0645",
- "\uFCAD"=>"\u0633\u062C",
- "\uFCAE"=>"\u0633\u062D",
- "\uFCAF"=>"\u0633\u062E",
- "\uFCB0"=>"\u0633\u0645",
- "\uFCB1"=>"\u0635\u062D",
- "\uFCB2"=>"\u0635\u062E",
- "\uFCB3"=>"\u0635\u0645",
- "\uFCB4"=>"\u0636\u062C",
- "\uFCB5"=>"\u0636\u062D",
- "\uFCB6"=>"\u0636\u062E",
- "\uFCB7"=>"\u0636\u0645",
- "\uFCB8"=>"\u0637\u062D",
- "\uFCB9"=>"\u0638\u0645",
- "\uFCBA"=>"\u0639\u062C",
- "\uFCBB"=>"\u0639\u0645",
- "\uFCBC"=>"\u063A\u062C",
- "\uFCBD"=>"\u063A\u0645",
- "\uFCBE"=>"\u0641\u062C",
- "\uFCBF"=>"\u0641\u062D",
- "\uFCC0"=>"\u0641\u062E",
- "\uFCC1"=>"\u0641\u0645",
- "\uFCC2"=>"\u0642\u062D",
- "\uFCC3"=>"\u0642\u0645",
- "\uFCC4"=>"\u0643\u062C",
- "\uFCC5"=>"\u0643\u062D",
- "\uFCC6"=>"\u0643\u062E",
- "\uFCC7"=>"\u0643\u0644",
- "\uFCC8"=>"\u0643\u0645",
- "\uFCC9"=>"\u0644\u062C",
- "\uFCCA"=>"\u0644\u062D",
- "\uFCCB"=>"\u0644\u062E",
- "\uFCCC"=>"\u0644\u0645",
- "\uFCCD"=>"\u0644\u0647",
- "\uFCCE"=>"\u0645\u062C",
- "\uFCCF"=>"\u0645\u062D",
- "\uFCD0"=>"\u0645\u062E",
- "\uFCD1"=>"\u0645\u0645",
- "\uFCD2"=>"\u0646\u062C",
- "\uFCD3"=>"\u0646\u062D",
- "\uFCD4"=>"\u0646\u062E",
- "\uFCD5"=>"\u0646\u0645",
- "\uFCD6"=>"\u0646\u0647",
- "\uFCD7"=>"\u0647\u062C",
- "\uFCD8"=>"\u0647\u0645",
- "\uFCD9"=>"\u0647\u0670",
- "\uFCDA"=>"\u064A\u062C",
- "\uFCDB"=>"\u064A\u062D",
- "\uFCDC"=>"\u064A\u062E",
- "\uFCDD"=>"\u064A\u0645",
- "\uFCDE"=>"\u064A\u0647",
- "\uFCDF"=>"\u0626\u0645",
- "\uFCE0"=>"\u0626\u0647",
- "\uFCE1"=>"\u0628\u0645",
- "\uFCE2"=>"\u0628\u0647",
- "\uFCE3"=>"\u062A\u0645",
- "\uFCE4"=>"\u062A\u0647",
- "\uFCE5"=>"\u062B\u0645",
- "\uFCE6"=>"\u062B\u0647",
- "\uFCE7"=>"\u0633\u0645",
- "\uFCE8"=>"\u0633\u0647",
- "\uFCE9"=>"\u0634\u0645",
- "\uFCEA"=>"\u0634\u0647",
- "\uFCEB"=>"\u0643\u0644",
- "\uFCEC"=>"\u0643\u0645",
- "\uFCED"=>"\u0644\u0645",
- "\uFCEE"=>"\u0646\u0645",
- "\uFCEF"=>"\u0646\u0647",
- "\uFCF0"=>"\u064A\u0645",
- "\uFCF1"=>"\u064A\u0647",
- "\uFCF2"=>"\u0640\u064E\u0651",
- "\uFCF3"=>"\u0640\u064F\u0651",
- "\uFCF4"=>"\u0640\u0650\u0651",
- "\uFCF5"=>"\u0637\u0649",
- "\uFCF6"=>"\u0637\u064A",
- "\uFCF7"=>"\u0639\u0649",
- "\uFCF8"=>"\u0639\u064A",
- "\uFCF9"=>"\u063A\u0649",
- "\uFCFA"=>"\u063A\u064A",
- "\uFCFB"=>"\u0633\u0649",
- "\uFCFC"=>"\u0633\u064A",
- "\uFCFD"=>"\u0634\u0649",
- "\uFCFE"=>"\u0634\u064A",
- "\uFCFF"=>"\u062D\u0649",
- "\uFD00"=>"\u062D\u064A",
- "\uFD01"=>"\u062C\u0649",
- "\uFD02"=>"\u062C\u064A",
- "\uFD03"=>"\u062E\u0649",
- "\uFD04"=>"\u062E\u064A",
- "\uFD05"=>"\u0635\u0649",
- "\uFD06"=>"\u0635\u064A",
- "\uFD07"=>"\u0636\u0649",
- "\uFD08"=>"\u0636\u064A",
- "\uFD09"=>"\u0634\u062C",
- "\uFD0A"=>"\u0634\u062D",
- "\uFD0B"=>"\u0634\u062E",
- "\uFD0C"=>"\u0634\u0645",
- "\uFD0D"=>"\u0634\u0631",
- "\uFD0E"=>"\u0633\u0631",
- "\uFD0F"=>"\u0635\u0631",
- "\uFD10"=>"\u0636\u0631",
- "\uFD11"=>"\u0637\u0649",
- "\uFD12"=>"\u0637\u064A",
- "\uFD13"=>"\u0639\u0649",
- "\uFD14"=>"\u0639\u064A",
- "\uFD15"=>"\u063A\u0649",
- "\uFD16"=>"\u063A\u064A",
- "\uFD17"=>"\u0633\u0649",
- "\uFD18"=>"\u0633\u064A",
- "\uFD19"=>"\u0634\u0649",
- "\uFD1A"=>"\u0634\u064A",
- "\uFD1B"=>"\u062D\u0649",
- "\uFD1C"=>"\u062D\u064A",
- "\uFD1D"=>"\u062C\u0649",
- "\uFD1E"=>"\u062C\u064A",
- "\uFD1F"=>"\u062E\u0649",
- "\uFD20"=>"\u062E\u064A",
- "\uFD21"=>"\u0635\u0649",
- "\uFD22"=>"\u0635\u064A",
- "\uFD23"=>"\u0636\u0649",
- "\uFD24"=>"\u0636\u064A",
- "\uFD25"=>"\u0634\u062C",
- "\uFD26"=>"\u0634\u062D",
- "\uFD27"=>"\u0634\u062E",
- "\uFD28"=>"\u0634\u0645",
- "\uFD29"=>"\u0634\u0631",
- "\uFD2A"=>"\u0633\u0631",
- "\uFD2B"=>"\u0635\u0631",
- "\uFD2C"=>"\u0636\u0631",
- "\uFD2D"=>"\u0634\u062C",
- "\uFD2E"=>"\u0634\u062D",
- "\uFD2F"=>"\u0634\u062E",
- "\uFD30"=>"\u0634\u0645",
- "\uFD31"=>"\u0633\u0647",
- "\uFD32"=>"\u0634\u0647",
- "\uFD33"=>"\u0637\u0645",
- "\uFD34"=>"\u0633\u062C",
- "\uFD35"=>"\u0633\u062D",
- "\uFD36"=>"\u0633\u062E",
- "\uFD37"=>"\u0634\u062C",
- "\uFD38"=>"\u0634\u062D",
- "\uFD39"=>"\u0634\u062E",
- "\uFD3A"=>"\u0637\u0645",
- "\uFD3B"=>"\u0638\u0645",
- "\uFD3C"=>"\u0627\u064B",
- "\uFD3D"=>"\u0627\u064B",
- "\uFD50"=>"\u062A\u062C\u0645",
- "\uFD51"=>"\u062A\u062D\u062C",
- "\uFD52"=>"\u062A\u062D\u062C",
- "\uFD53"=>"\u062A\u062D\u0645",
- "\uFD54"=>"\u062A\u062E\u0645",
- "\uFD55"=>"\u062A\u0645\u062C",
- "\uFD56"=>"\u062A\u0645\u062D",
- "\uFD57"=>"\u062A\u0645\u062E",
- "\uFD58"=>"\u062C\u0645\u062D",
- "\uFD59"=>"\u062C\u0645\u062D",
- "\uFD5A"=>"\u062D\u0645\u064A",
- "\uFD5B"=>"\u062D\u0645\u0649",
- "\uFD5C"=>"\u0633\u062D\u062C",
- "\uFD5D"=>"\u0633\u062C\u062D",
- "\uFD5E"=>"\u0633\u062C\u0649",
- "\uFD5F"=>"\u0633\u0645\u062D",
- "\uFD60"=>"\u0633\u0645\u062D",
- "\uFD61"=>"\u0633\u0645\u062C",
- "\uFD62"=>"\u0633\u0645\u0645",
- "\uFD63"=>"\u0633\u0645\u0645",
- "\uFD64"=>"\u0635\u062D\u062D",
- "\uFD65"=>"\u0635\u062D\u062D",
- "\uFD66"=>"\u0635\u0645\u0645",
- "\uFD67"=>"\u0634\u062D\u0645",
- "\uFD68"=>"\u0634\u062D\u0645",
- "\uFD69"=>"\u0634\u062C\u064A",
- "\uFD6A"=>"\u0634\u0645\u062E",
- "\uFD6B"=>"\u0634\u0645\u062E",
- "\uFD6C"=>"\u0634\u0645\u0645",
- "\uFD6D"=>"\u0634\u0645\u0645",
- "\uFD6E"=>"\u0636\u062D\u0649",
- "\uFD6F"=>"\u0636\u062E\u0645",
- "\uFD70"=>"\u0636\u062E\u0645",
- "\uFD71"=>"\u0637\u0645\u062D",
- "\uFD72"=>"\u0637\u0645\u062D",
- "\uFD73"=>"\u0637\u0645\u0645",
- "\uFD74"=>"\u0637\u0645\u064A",
- "\uFD75"=>"\u0639\u062C\u0645",
- "\uFD76"=>"\u0639\u0645\u0645",
- "\uFD77"=>"\u0639\u0645\u0645",
- "\uFD78"=>"\u0639\u0645\u0649",
- "\uFD79"=>"\u063A\u0645\u0645",
- "\uFD7A"=>"\u063A\u0645\u064A",
- "\uFD7B"=>"\u063A\u0645\u0649",
- "\uFD7C"=>"\u0641\u062E\u0645",
- "\uFD7D"=>"\u0641\u062E\u0645",
- "\uFD7E"=>"\u0642\u0645\u062D",
- "\uFD7F"=>"\u0642\u0645\u0645",
- "\uFD80"=>"\u0644\u062D\u0645",
- "\uFD81"=>"\u0644\u062D\u064A",
- "\uFD82"=>"\u0644\u062D\u0649",
- "\uFD83"=>"\u0644\u062C\u062C",
- "\uFD84"=>"\u0644\u062C\u062C",
- "\uFD85"=>"\u0644\u062E\u0645",
- "\uFD86"=>"\u0644\u062E\u0645",
- "\uFD87"=>"\u0644\u0645\u062D",
- "\uFD88"=>"\u0644\u0645\u062D",
- "\uFD89"=>"\u0645\u062D\u062C",
- "\uFD8A"=>"\u0645\u062D\u0645",
- "\uFD8B"=>"\u0645\u062D\u064A",
- "\uFD8C"=>"\u0645\u062C\u062D",
- "\uFD8D"=>"\u0645\u062C\u0645",
- "\uFD8E"=>"\u0645\u062E\u062C",
- "\uFD8F"=>"\u0645\u062E\u0645",
- "\uFD92"=>"\u0645\u062C\u062E",
- "\uFD93"=>"\u0647\u0645\u062C",
- "\uFD94"=>"\u0647\u0645\u0645",
- "\uFD95"=>"\u0646\u062D\u0645",
- "\uFD96"=>"\u0646\u062D\u0649",
- "\uFD97"=>"\u0646\u062C\u0645",
- "\uFD98"=>"\u0646\u062C\u0645",
- "\uFD99"=>"\u0646\u062C\u0649",
- "\uFD9A"=>"\u0646\u0645\u064A",
- "\uFD9B"=>"\u0646\u0645\u0649",
- "\uFD9C"=>"\u064A\u0645\u0645",
- "\uFD9D"=>"\u064A\u0645\u0645",
- "\uFD9E"=>"\u0628\u062E\u064A",
- "\uFD9F"=>"\u062A\u062C\u064A",
- "\uFDA0"=>"\u062A\u062C\u0649",
- "\uFDA1"=>"\u062A\u062E\u064A",
- "\uFDA2"=>"\u062A\u062E\u0649",
- "\uFDA3"=>"\u062A\u0645\u064A",
- "\uFDA4"=>"\u062A\u0645\u0649",
- "\uFDA5"=>"\u062C\u0645\u064A",
- "\uFDA6"=>"\u062C\u062D\u0649",
- "\uFDA7"=>"\u062C\u0645\u0649",
- "\uFDA8"=>"\u0633\u062E\u0649",
- "\uFDA9"=>"\u0635\u062D\u064A",
- "\uFDAA"=>"\u0634\u062D\u064A",
- "\uFDAB"=>"\u0636\u062D\u064A",
- "\uFDAC"=>"\u0644\u062C\u064A",
- "\uFDAD"=>"\u0644\u0645\u064A",
- "\uFDAE"=>"\u064A\u062D\u064A",
- "\uFDAF"=>"\u064A\u062C\u064A",
- "\uFDB0"=>"\u064A\u0645\u064A",
- "\uFDB1"=>"\u0645\u0645\u064A",
- "\uFDB2"=>"\u0642\u0645\u064A",
- "\uFDB3"=>"\u0646\u062D\u064A",
- "\uFDB4"=>"\u0642\u0645\u062D",
- "\uFDB5"=>"\u0644\u062D\u0645",
- "\uFDB6"=>"\u0639\u0645\u064A",
- "\uFDB7"=>"\u0643\u0645\u064A",
- "\uFDB8"=>"\u0646\u062C\u062D",
- "\uFDB9"=>"\u0645\u062E\u064A",
- "\uFDBA"=>"\u0644\u062C\u0645",
- "\uFDBB"=>"\u0643\u0645\u0645",
- "\uFDBC"=>"\u0644\u062C\u0645",
- "\uFDBD"=>"\u0646\u062C\u062D",
- "\uFDBE"=>"\u062C\u062D\u064A",
- "\uFDBF"=>"\u062D\u062C\u064A",
- "\uFDC0"=>"\u0645\u062C\u064A",
- "\uFDC1"=>"\u0641\u0645\u064A",
- "\uFDC2"=>"\u0628\u062D\u064A",
- "\uFDC3"=>"\u0643\u0645\u0645",
- "\uFDC4"=>"\u0639\u062C\u0645",
- "\uFDC5"=>"\u0635\u0645\u0645",
- "\uFDC6"=>"\u0633\u062E\u064A",
- "\uFDC7"=>"\u0646\u062C\u064A",
- "\uFDF0"=>"\u0635\u0644\u06D2",
- "\uFDF1"=>"\u0642\u0644\u06D2",
- "\uFDF2"=>"\u0627\u0644\u0644\u0647",
- "\uFDF3"=>"\u0627\u0643\u0628\u0631",
- "\uFDF4"=>"\u0645\u062D\u0645\u062F",
- "\uFDF5"=>"\u0635\u0644\u0639\u0645",
- "\uFDF6"=>"\u0631\u0633\u0648\u0644",
- "\uFDF7"=>"\u0639\u0644\u064A\u0647",
- "\uFDF8"=>"\u0648\u0633\u0644\u0645",
- "\uFDF9"=>"\u0635\u0644\u0649",
- "\uFDFA"=>"\u0635\u0644\u0649 \u0627\u0644\u0644\u0647 \u0639\u0644\u064A\u0647 \u0648\u0633\u0644\u0645",
- "\uFDFB"=>"\u062C\u0644 \u062C\u0644\u0627\u0644\u0647",
- "\uFDFC"=>"\u0631\u06CC\u0627\u0644",
- "\uFE10"=>",",
- "\uFE11"=>"\u3001",
- "\uFE12"=>"\u3002",
- "\uFE13"=>":",
- "\uFE14"=>";",
- "\uFE15"=>"!",
- "\uFE16"=>"?",
- "\uFE17"=>"\u3016",
- "\uFE18"=>"\u3017",
- "\uFE19"=>"...",
- "\uFE30"=>"..",
- "\uFE31"=>"\u2014",
- "\uFE32"=>"\u2013",
- "\uFE33"=>"_",
- "\uFE34"=>"_",
- "\uFE35"=>"(",
- "\uFE36"=>")",
- "\uFE37"=>"{",
- "\uFE38"=>"}",
- "\uFE39"=>"\u3014",
- "\uFE3A"=>"\u3015",
- "\uFE3B"=>"\u3010",
- "\uFE3C"=>"\u3011",
- "\uFE3D"=>"\u300A",
- "\uFE3E"=>"\u300B",
- "\uFE3F"=>"\u3008",
- "\uFE40"=>"\u3009",
- "\uFE41"=>"\u300C",
- "\uFE42"=>"\u300D",
- "\uFE43"=>"\u300E",
- "\uFE44"=>"\u300F",
- "\uFE47"=>"[",
- "\uFE48"=>"]",
- "\uFE49"=>" \u0305",
- "\uFE4A"=>" \u0305",
- "\uFE4B"=>" \u0305",
- "\uFE4C"=>" \u0305",
- "\uFE4D"=>"_",
- "\uFE4E"=>"_",
- "\uFE4F"=>"_",
- "\uFE50"=>",",
- "\uFE51"=>"\u3001",
- "\uFE52"=>".",
- "\uFE54"=>";",
- "\uFE55"=>":",
- "\uFE56"=>"?",
- "\uFE57"=>"!",
- "\uFE58"=>"\u2014",
- "\uFE59"=>"(",
- "\uFE5A"=>")",
- "\uFE5B"=>"{",
- "\uFE5C"=>"}",
- "\uFE5D"=>"\u3014",
- "\uFE5E"=>"\u3015",
- "\uFE5F"=>"#",
- "\uFE60"=>"&",
- "\uFE61"=>"*",
- "\uFE62"=>"+",
- "\uFE63"=>"-",
- "\uFE64"=>"<",
- "\uFE65"=>">",
- "\uFE66"=>"=",
- "\uFE68"=>"\\",
- "\uFE69"=>"$",
- "\uFE6A"=>"%",
- "\uFE6B"=>"@",
- "\uFE70"=>" \u064B",
- "\uFE71"=>"\u0640\u064B",
- "\uFE72"=>" \u064C",
- "\uFE74"=>" \u064D",
- "\uFE76"=>" \u064E",
- "\uFE77"=>"\u0640\u064E",
- "\uFE78"=>" \u064F",
- "\uFE79"=>"\u0640\u064F",
- "\uFE7A"=>" \u0650",
- "\uFE7B"=>"\u0640\u0650",
- "\uFE7C"=>" \u0651",
- "\uFE7D"=>"\u0640\u0651",
- "\uFE7E"=>" \u0652",
- "\uFE7F"=>"\u0640\u0652",
- "\uFE80"=>"\u0621",
- "\uFE81"=>"\u0622",
- "\uFE82"=>"\u0622",
- "\uFE83"=>"\u0623",
- "\uFE84"=>"\u0623",
- "\uFE85"=>"\u0624",
- "\uFE86"=>"\u0624",
- "\uFE87"=>"\u0625",
- "\uFE88"=>"\u0625",
- "\uFE89"=>"\u0626",
- "\uFE8A"=>"\u0626",
- "\uFE8B"=>"\u0626",
- "\uFE8C"=>"\u0626",
- "\uFE8D"=>"\u0627",
- "\uFE8E"=>"\u0627",
- "\uFE8F"=>"\u0628",
- "\uFE90"=>"\u0628",
- "\uFE91"=>"\u0628",
- "\uFE92"=>"\u0628",
- "\uFE93"=>"\u0629",
- "\uFE94"=>"\u0629",
- "\uFE95"=>"\u062A",
- "\uFE96"=>"\u062A",
- "\uFE97"=>"\u062A",
- "\uFE98"=>"\u062A",
- "\uFE99"=>"\u062B",
- "\uFE9A"=>"\u062B",
- "\uFE9B"=>"\u062B",
- "\uFE9C"=>"\u062B",
- "\uFE9D"=>"\u062C",
- "\uFE9E"=>"\u062C",
- "\uFE9F"=>"\u062C",
- "\uFEA0"=>"\u062C",
- "\uFEA1"=>"\u062D",
- "\uFEA2"=>"\u062D",
- "\uFEA3"=>"\u062D",
- "\uFEA4"=>"\u062D",
- "\uFEA5"=>"\u062E",
- "\uFEA6"=>"\u062E",
- "\uFEA7"=>"\u062E",
- "\uFEA8"=>"\u062E",
- "\uFEA9"=>"\u062F",
- "\uFEAA"=>"\u062F",
- "\uFEAB"=>"\u0630",
- "\uFEAC"=>"\u0630",
- "\uFEAD"=>"\u0631",
- "\uFEAE"=>"\u0631",
- "\uFEAF"=>"\u0632",
- "\uFEB0"=>"\u0632",
- "\uFEB1"=>"\u0633",
- "\uFEB2"=>"\u0633",
- "\uFEB3"=>"\u0633",
- "\uFEB4"=>"\u0633",
- "\uFEB5"=>"\u0634",
- "\uFEB6"=>"\u0634",
- "\uFEB7"=>"\u0634",
- "\uFEB8"=>"\u0634",
- "\uFEB9"=>"\u0635",
- "\uFEBA"=>"\u0635",
- "\uFEBB"=>"\u0635",
- "\uFEBC"=>"\u0635",
- "\uFEBD"=>"\u0636",
- "\uFEBE"=>"\u0636",
- "\uFEBF"=>"\u0636",
- "\uFEC0"=>"\u0636",
- "\uFEC1"=>"\u0637",
- "\uFEC2"=>"\u0637",
- "\uFEC3"=>"\u0637",
- "\uFEC4"=>"\u0637",
- "\uFEC5"=>"\u0638",
- "\uFEC6"=>"\u0638",
- "\uFEC7"=>"\u0638",
- "\uFEC8"=>"\u0638",
- "\uFEC9"=>"\u0639",
- "\uFECA"=>"\u0639",
- "\uFECB"=>"\u0639",
- "\uFECC"=>"\u0639",
- "\uFECD"=>"\u063A",
- "\uFECE"=>"\u063A",
- "\uFECF"=>"\u063A",
- "\uFED0"=>"\u063A",
- "\uFED1"=>"\u0641",
- "\uFED2"=>"\u0641",
- "\uFED3"=>"\u0641",
- "\uFED4"=>"\u0641",
- "\uFED5"=>"\u0642",
- "\uFED6"=>"\u0642",
- "\uFED7"=>"\u0642",
- "\uFED8"=>"\u0642",
- "\uFED9"=>"\u0643",
- "\uFEDA"=>"\u0643",
- "\uFEDB"=>"\u0643",
- "\uFEDC"=>"\u0643",
- "\uFEDD"=>"\u0644",
- "\uFEDE"=>"\u0644",
- "\uFEDF"=>"\u0644",
- "\uFEE0"=>"\u0644",
- "\uFEE1"=>"\u0645",
- "\uFEE2"=>"\u0645",
- "\uFEE3"=>"\u0645",
- "\uFEE4"=>"\u0645",
- "\uFEE5"=>"\u0646",
- "\uFEE6"=>"\u0646",
- "\uFEE7"=>"\u0646",
- "\uFEE8"=>"\u0646",
- "\uFEE9"=>"\u0647",
- "\uFEEA"=>"\u0647",
- "\uFEEB"=>"\u0647",
- "\uFEEC"=>"\u0647",
- "\uFEED"=>"\u0648",
- "\uFEEE"=>"\u0648",
- "\uFEEF"=>"\u0649",
- "\uFEF0"=>"\u0649",
- "\uFEF1"=>"\u064A",
- "\uFEF2"=>"\u064A",
- "\uFEF3"=>"\u064A",
- "\uFEF4"=>"\u064A",
- "\uFEF5"=>"\u0644\u0622",
- "\uFEF6"=>"\u0644\u0622",
- "\uFEF7"=>"\u0644\u0623",
- "\uFEF8"=>"\u0644\u0623",
- "\uFEF9"=>"\u0644\u0625",
- "\uFEFA"=>"\u0644\u0625",
- "\uFEFB"=>"\u0644\u0627",
- "\uFEFC"=>"\u0644\u0627",
- "\uFF01"=>"!",
- "\uFF02"=>"\"",
- "\uFF03"=>"#",
- "\uFF04"=>"$",
- "\uFF05"=>"%",
- "\uFF06"=>"&",
- "\uFF07"=>"'",
- "\uFF08"=>"(",
- "\uFF09"=>")",
- "\uFF0A"=>"*",
- "\uFF0B"=>"+",
- "\uFF0C"=>",",
- "\uFF0D"=>"-",
- "\uFF0E"=>".",
- "\uFF0F"=>"/",
- "\uFF10"=>"0",
- "\uFF11"=>"1",
- "\uFF12"=>"2",
- "\uFF13"=>"3",
- "\uFF14"=>"4",
- "\uFF15"=>"5",
- "\uFF16"=>"6",
- "\uFF17"=>"7",
- "\uFF18"=>"8",
- "\uFF19"=>"9",
- "\uFF1A"=>":",
- "\uFF1B"=>";",
- "\uFF1C"=>"<",
- "\uFF1D"=>"=",
- "\uFF1E"=>">",
- "\uFF1F"=>"?",
- "\uFF20"=>"@",
- "\uFF21"=>"A",
- "\uFF22"=>"B",
- "\uFF23"=>"C",
- "\uFF24"=>"D",
- "\uFF25"=>"E",
- "\uFF26"=>"F",
- "\uFF27"=>"G",
- "\uFF28"=>"H",
- "\uFF29"=>"I",
- "\uFF2A"=>"J",
- "\uFF2B"=>"K",
- "\uFF2C"=>"L",
- "\uFF2D"=>"M",
- "\uFF2E"=>"N",
- "\uFF2F"=>"O",
- "\uFF30"=>"P",
- "\uFF31"=>"Q",
- "\uFF32"=>"R",
- "\uFF33"=>"S",
- "\uFF34"=>"T",
- "\uFF35"=>"U",
- "\uFF36"=>"V",
- "\uFF37"=>"W",
- "\uFF38"=>"X",
- "\uFF39"=>"Y",
- "\uFF3A"=>"Z",
- "\uFF3B"=>"[",
- "\uFF3C"=>"\\",
- "\uFF3D"=>"]",
- "\uFF3E"=>"^",
- "\uFF3F"=>"_",
- "\uFF40"=>"`",
- "\uFF41"=>"a",
- "\uFF42"=>"b",
- "\uFF43"=>"c",
- "\uFF44"=>"d",
- "\uFF45"=>"e",
- "\uFF46"=>"f",
- "\uFF47"=>"g",
- "\uFF48"=>"h",
- "\uFF49"=>"i",
- "\uFF4A"=>"j",
- "\uFF4B"=>"k",
- "\uFF4C"=>"l",
- "\uFF4D"=>"m",
- "\uFF4E"=>"n",
- "\uFF4F"=>"o",
- "\uFF50"=>"p",
- "\uFF51"=>"q",
- "\uFF52"=>"r",
- "\uFF53"=>"s",
- "\uFF54"=>"t",
- "\uFF55"=>"u",
- "\uFF56"=>"v",
- "\uFF57"=>"w",
- "\uFF58"=>"x",
- "\uFF59"=>"y",
- "\uFF5A"=>"z",
- "\uFF5B"=>"{",
- "\uFF5C"=>"|",
- "\uFF5D"=>"}",
- "\uFF5E"=>"~",
- "\uFF5F"=>"\u2985",
- "\uFF60"=>"\u2986",
- "\uFF61"=>"\u3002",
- "\uFF62"=>"\u300C",
- "\uFF63"=>"\u300D",
- "\uFF64"=>"\u3001",
- "\uFF65"=>"\u30FB",
- "\uFF66"=>"\u30F2",
- "\uFF67"=>"\u30A1",
- "\uFF68"=>"\u30A3",
- "\uFF69"=>"\u30A5",
- "\uFF6A"=>"\u30A7",
- "\uFF6B"=>"\u30A9",
- "\uFF6C"=>"\u30E3",
- "\uFF6D"=>"\u30E5",
- "\uFF6E"=>"\u30E7",
- "\uFF6F"=>"\u30C3",
- "\uFF70"=>"\u30FC",
- "\uFF71"=>"\u30A2",
- "\uFF72"=>"\u30A4",
- "\uFF73"=>"\u30A6",
- "\uFF74"=>"\u30A8",
- "\uFF75"=>"\u30AA",
- "\uFF76"=>"\u30AB",
- "\uFF77"=>"\u30AD",
- "\uFF78"=>"\u30AF",
- "\uFF79"=>"\u30B1",
- "\uFF7A"=>"\u30B3",
- "\uFF7B"=>"\u30B5",
- "\uFF7C"=>"\u30B7",
- "\uFF7D"=>"\u30B9",
- "\uFF7E"=>"\u30BB",
- "\uFF7F"=>"\u30BD",
- "\uFF80"=>"\u30BF",
- "\uFF81"=>"\u30C1",
- "\uFF82"=>"\u30C4",
- "\uFF83"=>"\u30C6",
- "\uFF84"=>"\u30C8",
- "\uFF85"=>"\u30CA",
- "\uFF86"=>"\u30CB",
- "\uFF87"=>"\u30CC",
- "\uFF88"=>"\u30CD",
- "\uFF89"=>"\u30CE",
- "\uFF8A"=>"\u30CF",
- "\uFF8B"=>"\u30D2",
- "\uFF8C"=>"\u30D5",
- "\uFF8D"=>"\u30D8",
- "\uFF8E"=>"\u30DB",
- "\uFF8F"=>"\u30DE",
- "\uFF90"=>"\u30DF",
- "\uFF91"=>"\u30E0",
- "\uFF92"=>"\u30E1",
- "\uFF93"=>"\u30E2",
- "\uFF94"=>"\u30E4",
- "\uFF95"=>"\u30E6",
- "\uFF96"=>"\u30E8",
- "\uFF97"=>"\u30E9",
- "\uFF98"=>"\u30EA",
- "\uFF99"=>"\u30EB",
- "\uFF9A"=>"\u30EC",
- "\uFF9B"=>"\u30ED",
- "\uFF9C"=>"\u30EF",
- "\uFF9D"=>"\u30F3",
- "\uFF9E"=>"\u3099",
- "\uFF9F"=>"\u309A",
- "\uFFA0"=>"\u1160",
- "\uFFA1"=>"\u1100",
- "\uFFA2"=>"\u1101",
- "\uFFA3"=>"\u11AA",
- "\uFFA4"=>"\u1102",
- "\uFFA5"=>"\u11AC",
- "\uFFA6"=>"\u11AD",
- "\uFFA7"=>"\u1103",
- "\uFFA8"=>"\u1104",
- "\uFFA9"=>"\u1105",
- "\uFFAA"=>"\u11B0",
- "\uFFAB"=>"\u11B1",
- "\uFFAC"=>"\u11B2",
- "\uFFAD"=>"\u11B3",
- "\uFFAE"=>"\u11B4",
- "\uFFAF"=>"\u11B5",
- "\uFFB0"=>"\u111A",
- "\uFFB1"=>"\u1106",
- "\uFFB2"=>"\u1107",
- "\uFFB3"=>"\u1108",
- "\uFFB4"=>"\u1121",
- "\uFFB5"=>"\u1109",
- "\uFFB6"=>"\u110A",
- "\uFFB7"=>"\u110B",
- "\uFFB8"=>"\u110C",
- "\uFFB9"=>"\u110D",
- "\uFFBA"=>"\u110E",
- "\uFFBB"=>"\u110F",
- "\uFFBC"=>"\u1110",
- "\uFFBD"=>"\u1111",
- "\uFFBE"=>"\u1112",
- "\uFFC2"=>"\u1161",
- "\uFFC3"=>"\u1162",
- "\uFFC4"=>"\u1163",
- "\uFFC5"=>"\u1164",
- "\uFFC6"=>"\u1165",
- "\uFFC7"=>"\u1166",
- "\uFFCA"=>"\u1167",
- "\uFFCB"=>"\u1168",
- "\uFFCC"=>"\u1169",
- "\uFFCD"=>"\u116A",
- "\uFFCE"=>"\u116B",
- "\uFFCF"=>"\u116C",
- "\uFFD2"=>"\u116D",
- "\uFFD3"=>"\u116E",
- "\uFFD4"=>"\u116F",
- "\uFFD5"=>"\u1170",
- "\uFFD6"=>"\u1171",
- "\uFFD7"=>"\u1172",
- "\uFFDA"=>"\u1173",
- "\uFFDB"=>"\u1174",
- "\uFFDC"=>"\u1175",
- "\uFFE0"=>"\u00A2",
- "\uFFE1"=>"\u00A3",
- "\uFFE2"=>"\u00AC",
- "\uFFE3"=>" \u0304",
- "\uFFE4"=>"\u00A6",
- "\uFFE5"=>"\u00A5",
- "\uFFE6"=>"\u20A9",
- "\uFFE8"=>"\u2502",
- "\uFFE9"=>"\u2190",
- "\uFFEA"=>"\u2191",
- "\uFFEB"=>"\u2192",
- "\uFFEC"=>"\u2193",
- "\uFFED"=>"\u25A0",
- "\uFFEE"=>"\u25CB",
- "\u{1D400}"=>"A",
- "\u{1D401}"=>"B",
- "\u{1D402}"=>"C",
- "\u{1D403}"=>"D",
- "\u{1D404}"=>"E",
- "\u{1D405}"=>"F",
- "\u{1D406}"=>"G",
- "\u{1D407}"=>"H",
- "\u{1D408}"=>"I",
- "\u{1D409}"=>"J",
- "\u{1D40A}"=>"K",
- "\u{1D40B}"=>"L",
- "\u{1D40C}"=>"M",
- "\u{1D40D}"=>"N",
- "\u{1D40E}"=>"O",
- "\u{1D40F}"=>"P",
- "\u{1D410}"=>"Q",
- "\u{1D411}"=>"R",
- "\u{1D412}"=>"S",
- "\u{1D413}"=>"T",
- "\u{1D414}"=>"U",
- "\u{1D415}"=>"V",
- "\u{1D416}"=>"W",
- "\u{1D417}"=>"X",
- "\u{1D418}"=>"Y",
- "\u{1D419}"=>"Z",
- "\u{1D41A}"=>"a",
- "\u{1D41B}"=>"b",
- "\u{1D41C}"=>"c",
- "\u{1D41D}"=>"d",
- "\u{1D41E}"=>"e",
- "\u{1D41F}"=>"f",
- "\u{1D420}"=>"g",
- "\u{1D421}"=>"h",
- "\u{1D422}"=>"i",
- "\u{1D423}"=>"j",
- "\u{1D424}"=>"k",
- "\u{1D425}"=>"l",
- "\u{1D426}"=>"m",
- "\u{1D427}"=>"n",
- "\u{1D428}"=>"o",
- "\u{1D429}"=>"p",
- "\u{1D42A}"=>"q",
- "\u{1D42B}"=>"r",
- "\u{1D42C}"=>"s",
- "\u{1D42D}"=>"t",
- "\u{1D42E}"=>"u",
- "\u{1D42F}"=>"v",
- "\u{1D430}"=>"w",
- "\u{1D431}"=>"x",
- "\u{1D432}"=>"y",
- "\u{1D433}"=>"z",
- "\u{1D434}"=>"A",
- "\u{1D435}"=>"B",
- "\u{1D436}"=>"C",
- "\u{1D437}"=>"D",
- "\u{1D438}"=>"E",
- "\u{1D439}"=>"F",
- "\u{1D43A}"=>"G",
- "\u{1D43B}"=>"H",
- "\u{1D43C}"=>"I",
- "\u{1D43D}"=>"J",
- "\u{1D43E}"=>"K",
- "\u{1D43F}"=>"L",
- "\u{1D440}"=>"M",
- "\u{1D441}"=>"N",
- "\u{1D442}"=>"O",
- "\u{1D443}"=>"P",
- "\u{1D444}"=>"Q",
- "\u{1D445}"=>"R",
- "\u{1D446}"=>"S",
- "\u{1D447}"=>"T",
- "\u{1D448}"=>"U",
- "\u{1D449}"=>"V",
- "\u{1D44A}"=>"W",
- "\u{1D44B}"=>"X",
- "\u{1D44C}"=>"Y",
- "\u{1D44D}"=>"Z",
- "\u{1D44E}"=>"a",
- "\u{1D44F}"=>"b",
- "\u{1D450}"=>"c",
- "\u{1D451}"=>"d",
- "\u{1D452}"=>"e",
- "\u{1D453}"=>"f",
- "\u{1D454}"=>"g",
- "\u{1D456}"=>"i",
- "\u{1D457}"=>"j",
- "\u{1D458}"=>"k",
- "\u{1D459}"=>"l",
- "\u{1D45A}"=>"m",
- "\u{1D45B}"=>"n",
- "\u{1D45C}"=>"o",
- "\u{1D45D}"=>"p",
- "\u{1D45E}"=>"q",
- "\u{1D45F}"=>"r",
- "\u{1D460}"=>"s",
- "\u{1D461}"=>"t",
- "\u{1D462}"=>"u",
- "\u{1D463}"=>"v",
- "\u{1D464}"=>"w",
- "\u{1D465}"=>"x",
- "\u{1D466}"=>"y",
- "\u{1D467}"=>"z",
- "\u{1D468}"=>"A",
- "\u{1D469}"=>"B",
- "\u{1D46A}"=>"C",
- "\u{1D46B}"=>"D",
- "\u{1D46C}"=>"E",
- "\u{1D46D}"=>"F",
- "\u{1D46E}"=>"G",
- "\u{1D46F}"=>"H",
- "\u{1D470}"=>"I",
- "\u{1D471}"=>"J",
- "\u{1D472}"=>"K",
- "\u{1D473}"=>"L",
- "\u{1D474}"=>"M",
- "\u{1D475}"=>"N",
- "\u{1D476}"=>"O",
- "\u{1D477}"=>"P",
- "\u{1D478}"=>"Q",
- "\u{1D479}"=>"R",
- "\u{1D47A}"=>"S",
- "\u{1D47B}"=>"T",
- "\u{1D47C}"=>"U",
- "\u{1D47D}"=>"V",
- "\u{1D47E}"=>"W",
- "\u{1D47F}"=>"X",
- "\u{1D480}"=>"Y",
- "\u{1D481}"=>"Z",
- "\u{1D482}"=>"a",
- "\u{1D483}"=>"b",
- "\u{1D484}"=>"c",
- "\u{1D485}"=>"d",
- "\u{1D486}"=>"e",
- "\u{1D487}"=>"f",
- "\u{1D488}"=>"g",
- "\u{1D489}"=>"h",
- "\u{1D48A}"=>"i",
- "\u{1D48B}"=>"j",
- "\u{1D48C}"=>"k",
- "\u{1D48D}"=>"l",
- "\u{1D48E}"=>"m",
- "\u{1D48F}"=>"n",
- "\u{1D490}"=>"o",
- "\u{1D491}"=>"p",
- "\u{1D492}"=>"q",
- "\u{1D493}"=>"r",
- "\u{1D494}"=>"s",
- "\u{1D495}"=>"t",
- "\u{1D496}"=>"u",
- "\u{1D497}"=>"v",
- "\u{1D498}"=>"w",
- "\u{1D499}"=>"x",
- "\u{1D49A}"=>"y",
- "\u{1D49B}"=>"z",
- "\u{1D49C}"=>"A",
- "\u{1D49E}"=>"C",
- "\u{1D49F}"=>"D",
- "\u{1D4A2}"=>"G",
- "\u{1D4A5}"=>"J",
- "\u{1D4A6}"=>"K",
- "\u{1D4A9}"=>"N",
- "\u{1D4AA}"=>"O",
- "\u{1D4AB}"=>"P",
- "\u{1D4AC}"=>"Q",
- "\u{1D4AE}"=>"S",
- "\u{1D4AF}"=>"T",
- "\u{1D4B0}"=>"U",
- "\u{1D4B1}"=>"V",
- "\u{1D4B2}"=>"W",
- "\u{1D4B3}"=>"X",
- "\u{1D4B4}"=>"Y",
- "\u{1D4B5}"=>"Z",
- "\u{1D4B6}"=>"a",
- "\u{1D4B7}"=>"b",
- "\u{1D4B8}"=>"c",
- "\u{1D4B9}"=>"d",
- "\u{1D4BB}"=>"f",
- "\u{1D4BD}"=>"h",
- "\u{1D4BE}"=>"i",
- "\u{1D4BF}"=>"j",
- "\u{1D4C0}"=>"k",
- "\u{1D4C1}"=>"l",
- "\u{1D4C2}"=>"m",
- "\u{1D4C3}"=>"n",
- "\u{1D4C5}"=>"p",
- "\u{1D4C6}"=>"q",
- "\u{1D4C7}"=>"r",
- "\u{1D4C8}"=>"s",
- "\u{1D4C9}"=>"t",
- "\u{1D4CA}"=>"u",
- "\u{1D4CB}"=>"v",
- "\u{1D4CC}"=>"w",
- "\u{1D4CD}"=>"x",
- "\u{1D4CE}"=>"y",
- "\u{1D4CF}"=>"z",
- "\u{1D4D0}"=>"A",
- "\u{1D4D1}"=>"B",
- "\u{1D4D2}"=>"C",
- "\u{1D4D3}"=>"D",
- "\u{1D4D4}"=>"E",
- "\u{1D4D5}"=>"F",
- "\u{1D4D6}"=>"G",
- "\u{1D4D7}"=>"H",
- "\u{1D4D8}"=>"I",
- "\u{1D4D9}"=>"J",
- "\u{1D4DA}"=>"K",
- "\u{1D4DB}"=>"L",
- "\u{1D4DC}"=>"M",
- "\u{1D4DD}"=>"N",
- "\u{1D4DE}"=>"O",
- "\u{1D4DF}"=>"P",
- "\u{1D4E0}"=>"Q",
- "\u{1D4E1}"=>"R",
- "\u{1D4E2}"=>"S",
- "\u{1D4E3}"=>"T",
- "\u{1D4E4}"=>"U",
- "\u{1D4E5}"=>"V",
- "\u{1D4E6}"=>"W",
- "\u{1D4E7}"=>"X",
- "\u{1D4E8}"=>"Y",
- "\u{1D4E9}"=>"Z",
- "\u{1D4EA}"=>"a",
- "\u{1D4EB}"=>"b",
- "\u{1D4EC}"=>"c",
- "\u{1D4ED}"=>"d",
- "\u{1D4EE}"=>"e",
- "\u{1D4EF}"=>"f",
- "\u{1D4F0}"=>"g",
- "\u{1D4F1}"=>"h",
- "\u{1D4F2}"=>"i",
- "\u{1D4F3}"=>"j",
- "\u{1D4F4}"=>"k",
- "\u{1D4F5}"=>"l",
- "\u{1D4F6}"=>"m",
- "\u{1D4F7}"=>"n",
- "\u{1D4F8}"=>"o",
- "\u{1D4F9}"=>"p",
- "\u{1D4FA}"=>"q",
- "\u{1D4FB}"=>"r",
- "\u{1D4FC}"=>"s",
- "\u{1D4FD}"=>"t",
- "\u{1D4FE}"=>"u",
- "\u{1D4FF}"=>"v",
- "\u{1D500}"=>"w",
- "\u{1D501}"=>"x",
- "\u{1D502}"=>"y",
- "\u{1D503}"=>"z",
- "\u{1D504}"=>"A",
- "\u{1D505}"=>"B",
- "\u{1D507}"=>"D",
- "\u{1D508}"=>"E",
- "\u{1D509}"=>"F",
- "\u{1D50A}"=>"G",
- "\u{1D50D}"=>"J",
- "\u{1D50E}"=>"K",
- "\u{1D50F}"=>"L",
- "\u{1D510}"=>"M",
- "\u{1D511}"=>"N",
- "\u{1D512}"=>"O",
- "\u{1D513}"=>"P",
- "\u{1D514}"=>"Q",
- "\u{1D516}"=>"S",
- "\u{1D517}"=>"T",
- "\u{1D518}"=>"U",
- "\u{1D519}"=>"V",
- "\u{1D51A}"=>"W",
- "\u{1D51B}"=>"X",
- "\u{1D51C}"=>"Y",
- "\u{1D51E}"=>"a",
- "\u{1D51F}"=>"b",
- "\u{1D520}"=>"c",
- "\u{1D521}"=>"d",
- "\u{1D522}"=>"e",
- "\u{1D523}"=>"f",
- "\u{1D524}"=>"g",
- "\u{1D525}"=>"h",
- "\u{1D526}"=>"i",
- "\u{1D527}"=>"j",
- "\u{1D528}"=>"k",
- "\u{1D529}"=>"l",
- "\u{1D52A}"=>"m",
- "\u{1D52B}"=>"n",
- "\u{1D52C}"=>"o",
- "\u{1D52D}"=>"p",
- "\u{1D52E}"=>"q",
- "\u{1D52F}"=>"r",
- "\u{1D530}"=>"s",
- "\u{1D531}"=>"t",
- "\u{1D532}"=>"u",
- "\u{1D533}"=>"v",
- "\u{1D534}"=>"w",
- "\u{1D535}"=>"x",
- "\u{1D536}"=>"y",
- "\u{1D537}"=>"z",
- "\u{1D538}"=>"A",
- "\u{1D539}"=>"B",
- "\u{1D53B}"=>"D",
- "\u{1D53C}"=>"E",
- "\u{1D53D}"=>"F",
- "\u{1D53E}"=>"G",
- "\u{1D540}"=>"I",
- "\u{1D541}"=>"J",
- "\u{1D542}"=>"K",
- "\u{1D543}"=>"L",
- "\u{1D544}"=>"M",
- "\u{1D546}"=>"O",
- "\u{1D54A}"=>"S",
- "\u{1D54B}"=>"T",
- "\u{1D54C}"=>"U",
- "\u{1D54D}"=>"V",
- "\u{1D54E}"=>"W",
- "\u{1D54F}"=>"X",
- "\u{1D550}"=>"Y",
- "\u{1D552}"=>"a",
- "\u{1D553}"=>"b",
- "\u{1D554}"=>"c",
- "\u{1D555}"=>"d",
- "\u{1D556}"=>"e",
- "\u{1D557}"=>"f",
- "\u{1D558}"=>"g",
- "\u{1D559}"=>"h",
- "\u{1D55A}"=>"i",
- "\u{1D55B}"=>"j",
- "\u{1D55C}"=>"k",
- "\u{1D55D}"=>"l",
- "\u{1D55E}"=>"m",
- "\u{1D55F}"=>"n",
- "\u{1D560}"=>"o",
- "\u{1D561}"=>"p",
- "\u{1D562}"=>"q",
- "\u{1D563}"=>"r",
- "\u{1D564}"=>"s",
- "\u{1D565}"=>"t",
- "\u{1D566}"=>"u",
- "\u{1D567}"=>"v",
- "\u{1D568}"=>"w",
- "\u{1D569}"=>"x",
- "\u{1D56A}"=>"y",
- "\u{1D56B}"=>"z",
- "\u{1D56C}"=>"A",
- "\u{1D56D}"=>"B",
- "\u{1D56E}"=>"C",
- "\u{1D56F}"=>"D",
- "\u{1D570}"=>"E",
- "\u{1D571}"=>"F",
- "\u{1D572}"=>"G",
- "\u{1D573}"=>"H",
- "\u{1D574}"=>"I",
- "\u{1D575}"=>"J",
- "\u{1D576}"=>"K",
- "\u{1D577}"=>"L",
- "\u{1D578}"=>"M",
- "\u{1D579}"=>"N",
- "\u{1D57A}"=>"O",
- "\u{1D57B}"=>"P",
- "\u{1D57C}"=>"Q",
- "\u{1D57D}"=>"R",
- "\u{1D57E}"=>"S",
- "\u{1D57F}"=>"T",
- "\u{1D580}"=>"U",
- "\u{1D581}"=>"V",
- "\u{1D582}"=>"W",
- "\u{1D583}"=>"X",
- "\u{1D584}"=>"Y",
- "\u{1D585}"=>"Z",
- "\u{1D586}"=>"a",
- "\u{1D587}"=>"b",
- "\u{1D588}"=>"c",
- "\u{1D589}"=>"d",
- "\u{1D58A}"=>"e",
- "\u{1D58B}"=>"f",
- "\u{1D58C}"=>"g",
- "\u{1D58D}"=>"h",
- "\u{1D58E}"=>"i",
- "\u{1D58F}"=>"j",
- "\u{1D590}"=>"k",
- "\u{1D591}"=>"l",
- "\u{1D592}"=>"m",
- "\u{1D593}"=>"n",
- "\u{1D594}"=>"o",
- "\u{1D595}"=>"p",
- "\u{1D596}"=>"q",
- "\u{1D597}"=>"r",
- "\u{1D598}"=>"s",
- "\u{1D599}"=>"t",
- "\u{1D59A}"=>"u",
- "\u{1D59B}"=>"v",
- "\u{1D59C}"=>"w",
- "\u{1D59D}"=>"x",
- "\u{1D59E}"=>"y",
- "\u{1D59F}"=>"z",
- "\u{1D5A0}"=>"A",
- "\u{1D5A1}"=>"B",
- "\u{1D5A2}"=>"C",
- "\u{1D5A3}"=>"D",
- "\u{1D5A4}"=>"E",
- "\u{1D5A5}"=>"F",
- "\u{1D5A6}"=>"G",
- "\u{1D5A7}"=>"H",
- "\u{1D5A8}"=>"I",
- "\u{1D5A9}"=>"J",
- "\u{1D5AA}"=>"K",
- "\u{1D5AB}"=>"L",
- "\u{1D5AC}"=>"M",
- "\u{1D5AD}"=>"N",
- "\u{1D5AE}"=>"O",
- "\u{1D5AF}"=>"P",
- "\u{1D5B0}"=>"Q",
- "\u{1D5B1}"=>"R",
- "\u{1D5B2}"=>"S",
- "\u{1D5B3}"=>"T",
- "\u{1D5B4}"=>"U",
- "\u{1D5B5}"=>"V",
- "\u{1D5B6}"=>"W",
- "\u{1D5B7}"=>"X",
- "\u{1D5B8}"=>"Y",
- "\u{1D5B9}"=>"Z",
- "\u{1D5BA}"=>"a",
- "\u{1D5BB}"=>"b",
- "\u{1D5BC}"=>"c",
- "\u{1D5BD}"=>"d",
- "\u{1D5BE}"=>"e",
- "\u{1D5BF}"=>"f",
- "\u{1D5C0}"=>"g",
- "\u{1D5C1}"=>"h",
- "\u{1D5C2}"=>"i",
- "\u{1D5C3}"=>"j",
- "\u{1D5C4}"=>"k",
- "\u{1D5C5}"=>"l",
- "\u{1D5C6}"=>"m",
- "\u{1D5C7}"=>"n",
- "\u{1D5C8}"=>"o",
- "\u{1D5C9}"=>"p",
- "\u{1D5CA}"=>"q",
- "\u{1D5CB}"=>"r",
- "\u{1D5CC}"=>"s",
- "\u{1D5CD}"=>"t",
- "\u{1D5CE}"=>"u",
- "\u{1D5CF}"=>"v",
- "\u{1D5D0}"=>"w",
- "\u{1D5D1}"=>"x",
- "\u{1D5D2}"=>"y",
- "\u{1D5D3}"=>"z",
- "\u{1D5D4}"=>"A",
- "\u{1D5D5}"=>"B",
- "\u{1D5D6}"=>"C",
- "\u{1D5D7}"=>"D",
- "\u{1D5D8}"=>"E",
- "\u{1D5D9}"=>"F",
- "\u{1D5DA}"=>"G",
- "\u{1D5DB}"=>"H",
- "\u{1D5DC}"=>"I",
- "\u{1D5DD}"=>"J",
- "\u{1D5DE}"=>"K",
- "\u{1D5DF}"=>"L",
- "\u{1D5E0}"=>"M",
- "\u{1D5E1}"=>"N",
- "\u{1D5E2}"=>"O",
- "\u{1D5E3}"=>"P",
- "\u{1D5E4}"=>"Q",
- "\u{1D5E5}"=>"R",
- "\u{1D5E6}"=>"S",
- "\u{1D5E7}"=>"T",
- "\u{1D5E8}"=>"U",
- "\u{1D5E9}"=>"V",
- "\u{1D5EA}"=>"W",
- "\u{1D5EB}"=>"X",
- "\u{1D5EC}"=>"Y",
- "\u{1D5ED}"=>"Z",
- "\u{1D5EE}"=>"a",
- "\u{1D5EF}"=>"b",
- "\u{1D5F0}"=>"c",
- "\u{1D5F1}"=>"d",
- "\u{1D5F2}"=>"e",
- "\u{1D5F3}"=>"f",
- "\u{1D5F4}"=>"g",
- "\u{1D5F5}"=>"h",
- "\u{1D5F6}"=>"i",
- "\u{1D5F7}"=>"j",
- "\u{1D5F8}"=>"k",
- "\u{1D5F9}"=>"l",
- "\u{1D5FA}"=>"m",
- "\u{1D5FB}"=>"n",
- "\u{1D5FC}"=>"o",
- "\u{1D5FD}"=>"p",
- "\u{1D5FE}"=>"q",
- "\u{1D5FF}"=>"r",
- "\u{1D600}"=>"s",
- "\u{1D601}"=>"t",
- "\u{1D602}"=>"u",
- "\u{1D603}"=>"v",
- "\u{1D604}"=>"w",
- "\u{1D605}"=>"x",
- "\u{1D606}"=>"y",
- "\u{1D607}"=>"z",
- "\u{1D608}"=>"A",
- "\u{1D609}"=>"B",
- "\u{1D60A}"=>"C",
- "\u{1D60B}"=>"D",
- "\u{1D60C}"=>"E",
- "\u{1D60D}"=>"F",
- "\u{1D60E}"=>"G",
- "\u{1D60F}"=>"H",
- "\u{1D610}"=>"I",
- "\u{1D611}"=>"J",
- "\u{1D612}"=>"K",
- "\u{1D613}"=>"L",
- "\u{1D614}"=>"M",
- "\u{1D615}"=>"N",
- "\u{1D616}"=>"O",
- "\u{1D617}"=>"P",
- "\u{1D618}"=>"Q",
- "\u{1D619}"=>"R",
- "\u{1D61A}"=>"S",
- "\u{1D61B}"=>"T",
- "\u{1D61C}"=>"U",
- "\u{1D61D}"=>"V",
- "\u{1D61E}"=>"W",
- "\u{1D61F}"=>"X",
- "\u{1D620}"=>"Y",
- "\u{1D621}"=>"Z",
- "\u{1D622}"=>"a",
- "\u{1D623}"=>"b",
- "\u{1D624}"=>"c",
- "\u{1D625}"=>"d",
- "\u{1D626}"=>"e",
- "\u{1D627}"=>"f",
- "\u{1D628}"=>"g",
- "\u{1D629}"=>"h",
- "\u{1D62A}"=>"i",
- "\u{1D62B}"=>"j",
- "\u{1D62C}"=>"k",
- "\u{1D62D}"=>"l",
- "\u{1D62E}"=>"m",
- "\u{1D62F}"=>"n",
- "\u{1D630}"=>"o",
- "\u{1D631}"=>"p",
- "\u{1D632}"=>"q",
- "\u{1D633}"=>"r",
- "\u{1D634}"=>"s",
- "\u{1D635}"=>"t",
- "\u{1D636}"=>"u",
- "\u{1D637}"=>"v",
- "\u{1D638}"=>"w",
- "\u{1D639}"=>"x",
- "\u{1D63A}"=>"y",
- "\u{1D63B}"=>"z",
- "\u{1D63C}"=>"A",
- "\u{1D63D}"=>"B",
- "\u{1D63E}"=>"C",
- "\u{1D63F}"=>"D",
- "\u{1D640}"=>"E",
- "\u{1D641}"=>"F",
- "\u{1D642}"=>"G",
- "\u{1D643}"=>"H",
- "\u{1D644}"=>"I",
- "\u{1D645}"=>"J",
- "\u{1D646}"=>"K",
- "\u{1D647}"=>"L",
- "\u{1D648}"=>"M",
- "\u{1D649}"=>"N",
- "\u{1D64A}"=>"O",
- "\u{1D64B}"=>"P",
- "\u{1D64C}"=>"Q",
- "\u{1D64D}"=>"R",
- "\u{1D64E}"=>"S",
- "\u{1D64F}"=>"T",
- "\u{1D650}"=>"U",
- "\u{1D651}"=>"V",
- "\u{1D652}"=>"W",
- "\u{1D653}"=>"X",
- "\u{1D654}"=>"Y",
- "\u{1D655}"=>"Z",
- "\u{1D656}"=>"a",
- "\u{1D657}"=>"b",
- "\u{1D658}"=>"c",
- "\u{1D659}"=>"d",
- "\u{1D65A}"=>"e",
- "\u{1D65B}"=>"f",
- "\u{1D65C}"=>"g",
- "\u{1D65D}"=>"h",
- "\u{1D65E}"=>"i",
- "\u{1D65F}"=>"j",
- "\u{1D660}"=>"k",
- "\u{1D661}"=>"l",
- "\u{1D662}"=>"m",
- "\u{1D663}"=>"n",
- "\u{1D664}"=>"o",
- "\u{1D665}"=>"p",
- "\u{1D666}"=>"q",
- "\u{1D667}"=>"r",
- "\u{1D668}"=>"s",
- "\u{1D669}"=>"t",
- "\u{1D66A}"=>"u",
- "\u{1D66B}"=>"v",
- "\u{1D66C}"=>"w",
- "\u{1D66D}"=>"x",
- "\u{1D66E}"=>"y",
- "\u{1D66F}"=>"z",
- "\u{1D670}"=>"A",
- "\u{1D671}"=>"B",
- "\u{1D672}"=>"C",
- "\u{1D673}"=>"D",
- "\u{1D674}"=>"E",
- "\u{1D675}"=>"F",
- "\u{1D676}"=>"G",
- "\u{1D677}"=>"H",
- "\u{1D678}"=>"I",
- "\u{1D679}"=>"J",
- "\u{1D67A}"=>"K",
- "\u{1D67B}"=>"L",
- "\u{1D67C}"=>"M",
- "\u{1D67D}"=>"N",
- "\u{1D67E}"=>"O",
- "\u{1D67F}"=>"P",
- "\u{1D680}"=>"Q",
- "\u{1D681}"=>"R",
- "\u{1D682}"=>"S",
- "\u{1D683}"=>"T",
- "\u{1D684}"=>"U",
- "\u{1D685}"=>"V",
- "\u{1D686}"=>"W",
- "\u{1D687}"=>"X",
- "\u{1D688}"=>"Y",
- "\u{1D689}"=>"Z",
- "\u{1D68A}"=>"a",
- "\u{1D68B}"=>"b",
- "\u{1D68C}"=>"c",
- "\u{1D68D}"=>"d",
- "\u{1D68E}"=>"e",
- "\u{1D68F}"=>"f",
- "\u{1D690}"=>"g",
- "\u{1D691}"=>"h",
- "\u{1D692}"=>"i",
- "\u{1D693}"=>"j",
- "\u{1D694}"=>"k",
- "\u{1D695}"=>"l",
- "\u{1D696}"=>"m",
- "\u{1D697}"=>"n",
- "\u{1D698}"=>"o",
- "\u{1D699}"=>"p",
- "\u{1D69A}"=>"q",
- "\u{1D69B}"=>"r",
- "\u{1D69C}"=>"s",
- "\u{1D69D}"=>"t",
- "\u{1D69E}"=>"u",
- "\u{1D69F}"=>"v",
- "\u{1D6A0}"=>"w",
- "\u{1D6A1}"=>"x",
- "\u{1D6A2}"=>"y",
- "\u{1D6A3}"=>"z",
- "\u{1D6A4}"=>"\u0131",
- "\u{1D6A5}"=>"\u0237",
- "\u{1D6A8}"=>"\u0391",
- "\u{1D6A9}"=>"\u0392",
- "\u{1D6AA}"=>"\u0393",
- "\u{1D6AB}"=>"\u0394",
- "\u{1D6AC}"=>"\u0395",
- "\u{1D6AD}"=>"\u0396",
- "\u{1D6AE}"=>"\u0397",
- "\u{1D6AF}"=>"\u0398",
- "\u{1D6B0}"=>"\u0399",
- "\u{1D6B1}"=>"\u039A",
- "\u{1D6B2}"=>"\u039B",
- "\u{1D6B3}"=>"\u039C",
- "\u{1D6B4}"=>"\u039D",
- "\u{1D6B5}"=>"\u039E",
- "\u{1D6B6}"=>"\u039F",
- "\u{1D6B7}"=>"\u03A0",
- "\u{1D6B8}"=>"\u03A1",
- "\u{1D6B9}"=>"\u0398",
- "\u{1D6BA}"=>"\u03A3",
- "\u{1D6BB}"=>"\u03A4",
- "\u{1D6BC}"=>"\u03A5",
- "\u{1D6BD}"=>"\u03A6",
- "\u{1D6BE}"=>"\u03A7",
- "\u{1D6BF}"=>"\u03A8",
- "\u{1D6C0}"=>"\u03A9",
- "\u{1D6C1}"=>"\u2207",
- "\u{1D6C2}"=>"\u03B1",
- "\u{1D6C3}"=>"\u03B2",
- "\u{1D6C4}"=>"\u03B3",
- "\u{1D6C5}"=>"\u03B4",
- "\u{1D6C6}"=>"\u03B5",
- "\u{1D6C7}"=>"\u03B6",
- "\u{1D6C8}"=>"\u03B7",
- "\u{1D6C9}"=>"\u03B8",
- "\u{1D6CA}"=>"\u03B9",
- "\u{1D6CB}"=>"\u03BA",
- "\u{1D6CC}"=>"\u03BB",
- "\u{1D6CD}"=>"\u03BC",
- "\u{1D6CE}"=>"\u03BD",
- "\u{1D6CF}"=>"\u03BE",
- "\u{1D6D0}"=>"\u03BF",
- "\u{1D6D1}"=>"\u03C0",
- "\u{1D6D2}"=>"\u03C1",
- "\u{1D6D3}"=>"\u03C2",
- "\u{1D6D4}"=>"\u03C3",
- "\u{1D6D5}"=>"\u03C4",
- "\u{1D6D6}"=>"\u03C5",
- "\u{1D6D7}"=>"\u03C6",
- "\u{1D6D8}"=>"\u03C7",
- "\u{1D6D9}"=>"\u03C8",
- "\u{1D6DA}"=>"\u03C9",
- "\u{1D6DB}"=>"\u2202",
- "\u{1D6DC}"=>"\u03B5",
- "\u{1D6DD}"=>"\u03B8",
- "\u{1D6DE}"=>"\u03BA",
- "\u{1D6DF}"=>"\u03C6",
- "\u{1D6E0}"=>"\u03C1",
- "\u{1D6E1}"=>"\u03C0",
- "\u{1D6E2}"=>"\u0391",
- "\u{1D6E3}"=>"\u0392",
- "\u{1D6E4}"=>"\u0393",
- "\u{1D6E5}"=>"\u0394",
- "\u{1D6E6}"=>"\u0395",
- "\u{1D6E7}"=>"\u0396",
- "\u{1D6E8}"=>"\u0397",
- "\u{1D6E9}"=>"\u0398",
- "\u{1D6EA}"=>"\u0399",
- "\u{1D6EB}"=>"\u039A",
- "\u{1D6EC}"=>"\u039B",
- "\u{1D6ED}"=>"\u039C",
- "\u{1D6EE}"=>"\u039D",
- "\u{1D6EF}"=>"\u039E",
- "\u{1D6F0}"=>"\u039F",
- "\u{1D6F1}"=>"\u03A0",
- "\u{1D6F2}"=>"\u03A1",
- "\u{1D6F3}"=>"\u0398",
- "\u{1D6F4}"=>"\u03A3",
- "\u{1D6F5}"=>"\u03A4",
- "\u{1D6F6}"=>"\u03A5",
- "\u{1D6F7}"=>"\u03A6",
- "\u{1D6F8}"=>"\u03A7",
- "\u{1D6F9}"=>"\u03A8",
- "\u{1D6FA}"=>"\u03A9",
- "\u{1D6FB}"=>"\u2207",
- "\u{1D6FC}"=>"\u03B1",
- "\u{1D6FD}"=>"\u03B2",
- "\u{1D6FE}"=>"\u03B3",
- "\u{1D6FF}"=>"\u03B4",
- "\u{1D700}"=>"\u03B5",
- "\u{1D701}"=>"\u03B6",
- "\u{1D702}"=>"\u03B7",
- "\u{1D703}"=>"\u03B8",
- "\u{1D704}"=>"\u03B9",
- "\u{1D705}"=>"\u03BA",
- "\u{1D706}"=>"\u03BB",
- "\u{1D707}"=>"\u03BC",
- "\u{1D708}"=>"\u03BD",
- "\u{1D709}"=>"\u03BE",
- "\u{1D70A}"=>"\u03BF",
- "\u{1D70B}"=>"\u03C0",
- "\u{1D70C}"=>"\u03C1",
- "\u{1D70D}"=>"\u03C2",
- "\u{1D70E}"=>"\u03C3",
- "\u{1D70F}"=>"\u03C4",
- "\u{1D710}"=>"\u03C5",
- "\u{1D711}"=>"\u03C6",
- "\u{1D712}"=>"\u03C7",
- "\u{1D713}"=>"\u03C8",
- "\u{1D714}"=>"\u03C9",
- "\u{1D715}"=>"\u2202",
- "\u{1D716}"=>"\u03B5",
- "\u{1D717}"=>"\u03B8",
- "\u{1D718}"=>"\u03BA",
- "\u{1D719}"=>"\u03C6",
- "\u{1D71A}"=>"\u03C1",
- "\u{1D71B}"=>"\u03C0",
- "\u{1D71C}"=>"\u0391",
- "\u{1D71D}"=>"\u0392",
- "\u{1D71E}"=>"\u0393",
- "\u{1D71F}"=>"\u0394",
- "\u{1D720}"=>"\u0395",
- "\u{1D721}"=>"\u0396",
- "\u{1D722}"=>"\u0397",
- "\u{1D723}"=>"\u0398",
- "\u{1D724}"=>"\u0399",
- "\u{1D725}"=>"\u039A",
- "\u{1D726}"=>"\u039B",
- "\u{1D727}"=>"\u039C",
- "\u{1D728}"=>"\u039D",
- "\u{1D729}"=>"\u039E",
- "\u{1D72A}"=>"\u039F",
- "\u{1D72B}"=>"\u03A0",
- "\u{1D72C}"=>"\u03A1",
- "\u{1D72D}"=>"\u0398",
- "\u{1D72E}"=>"\u03A3",
- "\u{1D72F}"=>"\u03A4",
- "\u{1D730}"=>"\u03A5",
- "\u{1D731}"=>"\u03A6",
- "\u{1D732}"=>"\u03A7",
- "\u{1D733}"=>"\u03A8",
- "\u{1D734}"=>"\u03A9",
- "\u{1D735}"=>"\u2207",
- "\u{1D736}"=>"\u03B1",
- "\u{1D737}"=>"\u03B2",
- "\u{1D738}"=>"\u03B3",
- "\u{1D739}"=>"\u03B4",
- "\u{1D73A}"=>"\u03B5",
- "\u{1D73B}"=>"\u03B6",
- "\u{1D73C}"=>"\u03B7",
- "\u{1D73D}"=>"\u03B8",
- "\u{1D73E}"=>"\u03B9",
- "\u{1D73F}"=>"\u03BA",
- "\u{1D740}"=>"\u03BB",
- "\u{1D741}"=>"\u03BC",
- "\u{1D742}"=>"\u03BD",
- "\u{1D743}"=>"\u03BE",
- "\u{1D744}"=>"\u03BF",
- "\u{1D745}"=>"\u03C0",
- "\u{1D746}"=>"\u03C1",
- "\u{1D747}"=>"\u03C2",
- "\u{1D748}"=>"\u03C3",
- "\u{1D749}"=>"\u03C4",
- "\u{1D74A}"=>"\u03C5",
- "\u{1D74B}"=>"\u03C6",
- "\u{1D74C}"=>"\u03C7",
- "\u{1D74D}"=>"\u03C8",
- "\u{1D74E}"=>"\u03C9",
- "\u{1D74F}"=>"\u2202",
- "\u{1D750}"=>"\u03B5",
- "\u{1D751}"=>"\u03B8",
- "\u{1D752}"=>"\u03BA",
- "\u{1D753}"=>"\u03C6",
- "\u{1D754}"=>"\u03C1",
- "\u{1D755}"=>"\u03C0",
- "\u{1D756}"=>"\u0391",
- "\u{1D757}"=>"\u0392",
- "\u{1D758}"=>"\u0393",
- "\u{1D759}"=>"\u0394",
- "\u{1D75A}"=>"\u0395",
- "\u{1D75B}"=>"\u0396",
- "\u{1D75C}"=>"\u0397",
- "\u{1D75D}"=>"\u0398",
- "\u{1D75E}"=>"\u0399",
- "\u{1D75F}"=>"\u039A",
- "\u{1D760}"=>"\u039B",
- "\u{1D761}"=>"\u039C",
- "\u{1D762}"=>"\u039D",
- "\u{1D763}"=>"\u039E",
- "\u{1D764}"=>"\u039F",
- "\u{1D765}"=>"\u03A0",
- "\u{1D766}"=>"\u03A1",
- "\u{1D767}"=>"\u0398",
- "\u{1D768}"=>"\u03A3",
- "\u{1D769}"=>"\u03A4",
- "\u{1D76A}"=>"\u03A5",
- "\u{1D76B}"=>"\u03A6",
- "\u{1D76C}"=>"\u03A7",
- "\u{1D76D}"=>"\u03A8",
- "\u{1D76E}"=>"\u03A9",
- "\u{1D76F}"=>"\u2207",
- "\u{1D770}"=>"\u03B1",
- "\u{1D771}"=>"\u03B2",
- "\u{1D772}"=>"\u03B3",
- "\u{1D773}"=>"\u03B4",
- "\u{1D774}"=>"\u03B5",
- "\u{1D775}"=>"\u03B6",
- "\u{1D776}"=>"\u03B7",
- "\u{1D777}"=>"\u03B8",
- "\u{1D778}"=>"\u03B9",
- "\u{1D779}"=>"\u03BA",
- "\u{1D77A}"=>"\u03BB",
- "\u{1D77B}"=>"\u03BC",
- "\u{1D77C}"=>"\u03BD",
- "\u{1D77D}"=>"\u03BE",
- "\u{1D77E}"=>"\u03BF",
- "\u{1D77F}"=>"\u03C0",
- "\u{1D780}"=>"\u03C1",
- "\u{1D781}"=>"\u03C2",
- "\u{1D782}"=>"\u03C3",
- "\u{1D783}"=>"\u03C4",
- "\u{1D784}"=>"\u03C5",
- "\u{1D785}"=>"\u03C6",
- "\u{1D786}"=>"\u03C7",
- "\u{1D787}"=>"\u03C8",
- "\u{1D788}"=>"\u03C9",
- "\u{1D789}"=>"\u2202",
- "\u{1D78A}"=>"\u03B5",
- "\u{1D78B}"=>"\u03B8",
- "\u{1D78C}"=>"\u03BA",
- "\u{1D78D}"=>"\u03C6",
- "\u{1D78E}"=>"\u03C1",
- "\u{1D78F}"=>"\u03C0",
- "\u{1D790}"=>"\u0391",
- "\u{1D791}"=>"\u0392",
- "\u{1D792}"=>"\u0393",
- "\u{1D793}"=>"\u0394",
- "\u{1D794}"=>"\u0395",
- "\u{1D795}"=>"\u0396",
- "\u{1D796}"=>"\u0397",
- "\u{1D797}"=>"\u0398",
- "\u{1D798}"=>"\u0399",
- "\u{1D799}"=>"\u039A",
- "\u{1D79A}"=>"\u039B",
- "\u{1D79B}"=>"\u039C",
- "\u{1D79C}"=>"\u039D",
- "\u{1D79D}"=>"\u039E",
- "\u{1D79E}"=>"\u039F",
- "\u{1D79F}"=>"\u03A0",
- "\u{1D7A0}"=>"\u03A1",
- "\u{1D7A1}"=>"\u0398",
- "\u{1D7A2}"=>"\u03A3",
- "\u{1D7A3}"=>"\u03A4",
- "\u{1D7A4}"=>"\u03A5",
- "\u{1D7A5}"=>"\u03A6",
- "\u{1D7A6}"=>"\u03A7",
- "\u{1D7A7}"=>"\u03A8",
- "\u{1D7A8}"=>"\u03A9",
- "\u{1D7A9}"=>"\u2207",
- "\u{1D7AA}"=>"\u03B1",
- "\u{1D7AB}"=>"\u03B2",
- "\u{1D7AC}"=>"\u03B3",
- "\u{1D7AD}"=>"\u03B4",
- "\u{1D7AE}"=>"\u03B5",
- "\u{1D7AF}"=>"\u03B6",
- "\u{1D7B0}"=>"\u03B7",
- "\u{1D7B1}"=>"\u03B8",
- "\u{1D7B2}"=>"\u03B9",
- "\u{1D7B3}"=>"\u03BA",
- "\u{1D7B4}"=>"\u03BB",
- "\u{1D7B5}"=>"\u03BC",
- "\u{1D7B6}"=>"\u03BD",
- "\u{1D7B7}"=>"\u03BE",
- "\u{1D7B8}"=>"\u03BF",
- "\u{1D7B9}"=>"\u03C0",
- "\u{1D7BA}"=>"\u03C1",
- "\u{1D7BB}"=>"\u03C2",
- "\u{1D7BC}"=>"\u03C3",
- "\u{1D7BD}"=>"\u03C4",
- "\u{1D7BE}"=>"\u03C5",
- "\u{1D7BF}"=>"\u03C6",
- "\u{1D7C0}"=>"\u03C7",
- "\u{1D7C1}"=>"\u03C8",
- "\u{1D7C2}"=>"\u03C9",
- "\u{1D7C3}"=>"\u2202",
- "\u{1D7C4}"=>"\u03B5",
- "\u{1D7C5}"=>"\u03B8",
- "\u{1D7C6}"=>"\u03BA",
- "\u{1D7C7}"=>"\u03C6",
- "\u{1D7C8}"=>"\u03C1",
- "\u{1D7C9}"=>"\u03C0",
- "\u{1D7CA}"=>"\u03DC",
- "\u{1D7CB}"=>"\u03DD",
- "\u{1D7CE}"=>"0",
- "\u{1D7CF}"=>"1",
- "\u{1D7D0}"=>"2",
- "\u{1D7D1}"=>"3",
- "\u{1D7D2}"=>"4",
- "\u{1D7D3}"=>"5",
- "\u{1D7D4}"=>"6",
- "\u{1D7D5}"=>"7",
- "\u{1D7D6}"=>"8",
- "\u{1D7D7}"=>"9",
- "\u{1D7D8}"=>"0",
- "\u{1D7D9}"=>"1",
- "\u{1D7DA}"=>"2",
- "\u{1D7DB}"=>"3",
- "\u{1D7DC}"=>"4",
- "\u{1D7DD}"=>"5",
- "\u{1D7DE}"=>"6",
- "\u{1D7DF}"=>"7",
- "\u{1D7E0}"=>"8",
- "\u{1D7E1}"=>"9",
- "\u{1D7E2}"=>"0",
- "\u{1D7E3}"=>"1",
- "\u{1D7E4}"=>"2",
- "\u{1D7E5}"=>"3",
- "\u{1D7E6}"=>"4",
- "\u{1D7E7}"=>"5",
- "\u{1D7E8}"=>"6",
- "\u{1D7E9}"=>"7",
- "\u{1D7EA}"=>"8",
- "\u{1D7EB}"=>"9",
- "\u{1D7EC}"=>"0",
- "\u{1D7ED}"=>"1",
- "\u{1D7EE}"=>"2",
- "\u{1D7EF}"=>"3",
- "\u{1D7F0}"=>"4",
- "\u{1D7F1}"=>"5",
- "\u{1D7F2}"=>"6",
- "\u{1D7F3}"=>"7",
- "\u{1D7F4}"=>"8",
- "\u{1D7F5}"=>"9",
- "\u{1D7F6}"=>"0",
- "\u{1D7F7}"=>"1",
- "\u{1D7F8}"=>"2",
- "\u{1D7F9}"=>"3",
- "\u{1D7FA}"=>"4",
- "\u{1D7FB}"=>"5",
- "\u{1D7FC}"=>"6",
- "\u{1D7FD}"=>"7",
- "\u{1D7FE}"=>"8",
- "\u{1D7FF}"=>"9",
- "\u{1EE00}"=>"\u0627",
- "\u{1EE01}"=>"\u0628",
- "\u{1EE02}"=>"\u062C",
- "\u{1EE03}"=>"\u062F",
- "\u{1EE05}"=>"\u0648",
- "\u{1EE06}"=>"\u0632",
- "\u{1EE07}"=>"\u062D",
- "\u{1EE08}"=>"\u0637",
- "\u{1EE09}"=>"\u064A",
- "\u{1EE0A}"=>"\u0643",
- "\u{1EE0B}"=>"\u0644",
- "\u{1EE0C}"=>"\u0645",
- "\u{1EE0D}"=>"\u0646",
- "\u{1EE0E}"=>"\u0633",
- "\u{1EE0F}"=>"\u0639",
- "\u{1EE10}"=>"\u0641",
- "\u{1EE11}"=>"\u0635",
- "\u{1EE12}"=>"\u0642",
- "\u{1EE13}"=>"\u0631",
- "\u{1EE14}"=>"\u0634",
- "\u{1EE15}"=>"\u062A",
- "\u{1EE16}"=>"\u062B",
- "\u{1EE17}"=>"\u062E",
- "\u{1EE18}"=>"\u0630",
- "\u{1EE19}"=>"\u0636",
- "\u{1EE1A}"=>"\u0638",
- "\u{1EE1B}"=>"\u063A",
- "\u{1EE1C}"=>"\u066E",
- "\u{1EE1D}"=>"\u06BA",
- "\u{1EE1E}"=>"\u06A1",
- "\u{1EE1F}"=>"\u066F",
- "\u{1EE21}"=>"\u0628",
- "\u{1EE22}"=>"\u062C",
- "\u{1EE24}"=>"\u0647",
- "\u{1EE27}"=>"\u062D",
- "\u{1EE29}"=>"\u064A",
- "\u{1EE2A}"=>"\u0643",
- "\u{1EE2B}"=>"\u0644",
- "\u{1EE2C}"=>"\u0645",
- "\u{1EE2D}"=>"\u0646",
- "\u{1EE2E}"=>"\u0633",
- "\u{1EE2F}"=>"\u0639",
- "\u{1EE30}"=>"\u0641",
- "\u{1EE31}"=>"\u0635",
- "\u{1EE32}"=>"\u0642",
- "\u{1EE34}"=>"\u0634",
- "\u{1EE35}"=>"\u062A",
- "\u{1EE36}"=>"\u062B",
- "\u{1EE37}"=>"\u062E",
- "\u{1EE39}"=>"\u0636",
- "\u{1EE3B}"=>"\u063A",
- "\u{1EE42}"=>"\u062C",
- "\u{1EE47}"=>"\u062D",
- "\u{1EE49}"=>"\u064A",
- "\u{1EE4B}"=>"\u0644",
- "\u{1EE4D}"=>"\u0646",
- "\u{1EE4E}"=>"\u0633",
- "\u{1EE4F}"=>"\u0639",
- "\u{1EE51}"=>"\u0635",
- "\u{1EE52}"=>"\u0642",
- "\u{1EE54}"=>"\u0634",
- "\u{1EE57}"=>"\u062E",
- "\u{1EE59}"=>"\u0636",
- "\u{1EE5B}"=>"\u063A",
- "\u{1EE5D}"=>"\u06BA",
- "\u{1EE5F}"=>"\u066F",
- "\u{1EE61}"=>"\u0628",
- "\u{1EE62}"=>"\u062C",
- "\u{1EE64}"=>"\u0647",
- "\u{1EE67}"=>"\u062D",
- "\u{1EE68}"=>"\u0637",
- "\u{1EE69}"=>"\u064A",
- "\u{1EE6A}"=>"\u0643",
- "\u{1EE6C}"=>"\u0645",
- "\u{1EE6D}"=>"\u0646",
- "\u{1EE6E}"=>"\u0633",
- "\u{1EE6F}"=>"\u0639",
- "\u{1EE70}"=>"\u0641",
- "\u{1EE71}"=>"\u0635",
- "\u{1EE72}"=>"\u0642",
- "\u{1EE74}"=>"\u0634",
- "\u{1EE75}"=>"\u062A",
- "\u{1EE76}"=>"\u062B",
- "\u{1EE77}"=>"\u062E",
- "\u{1EE79}"=>"\u0636",
- "\u{1EE7A}"=>"\u0638",
- "\u{1EE7B}"=>"\u063A",
- "\u{1EE7C}"=>"\u066E",
- "\u{1EE7E}"=>"\u06A1",
- "\u{1EE80}"=>"\u0627",
- "\u{1EE81}"=>"\u0628",
- "\u{1EE82}"=>"\u062C",
- "\u{1EE83}"=>"\u062F",
- "\u{1EE84}"=>"\u0647",
- "\u{1EE85}"=>"\u0648",
- "\u{1EE86}"=>"\u0632",
- "\u{1EE87}"=>"\u062D",
- "\u{1EE88}"=>"\u0637",
- "\u{1EE89}"=>"\u064A",
- "\u{1EE8B}"=>"\u0644",
- "\u{1EE8C}"=>"\u0645",
- "\u{1EE8D}"=>"\u0646",
- "\u{1EE8E}"=>"\u0633",
- "\u{1EE8F}"=>"\u0639",
- "\u{1EE90}"=>"\u0641",
- "\u{1EE91}"=>"\u0635",
- "\u{1EE92}"=>"\u0642",
- "\u{1EE93}"=>"\u0631",
- "\u{1EE94}"=>"\u0634",
- "\u{1EE95}"=>"\u062A",
- "\u{1EE96}"=>"\u062B",
- "\u{1EE97}"=>"\u062E",
- "\u{1EE98}"=>"\u0630",
- "\u{1EE99}"=>"\u0636",
- "\u{1EE9A}"=>"\u0638",
- "\u{1EE9B}"=>"\u063A",
- "\u{1EEA1}"=>"\u0628",
- "\u{1EEA2}"=>"\u062C",
- "\u{1EEA3}"=>"\u062F",
- "\u{1EEA5}"=>"\u0648",
- "\u{1EEA6}"=>"\u0632",
- "\u{1EEA7}"=>"\u062D",
- "\u{1EEA8}"=>"\u0637",
- "\u{1EEA9}"=>"\u064A",
- "\u{1EEAB}"=>"\u0644",
- "\u{1EEAC}"=>"\u0645",
- "\u{1EEAD}"=>"\u0646",
- "\u{1EEAE}"=>"\u0633",
- "\u{1EEAF}"=>"\u0639",
- "\u{1EEB0}"=>"\u0641",
- "\u{1EEB1}"=>"\u0635",
- "\u{1EEB2}"=>"\u0642",
- "\u{1EEB3}"=>"\u0631",
- "\u{1EEB4}"=>"\u0634",
- "\u{1EEB5}"=>"\u062A",
- "\u{1EEB6}"=>"\u062B",
- "\u{1EEB7}"=>"\u062E",
- "\u{1EEB8}"=>"\u0630",
- "\u{1EEB9}"=>"\u0636",
- "\u{1EEBA}"=>"\u0638",
- "\u{1EEBB}"=>"\u063A",
- "\u{1F100}"=>"0.",
- "\u{1F101}"=>"0,",
- "\u{1F102}"=>"1,",
- "\u{1F103}"=>"2,",
- "\u{1F104}"=>"3,",
- "\u{1F105}"=>"4,",
- "\u{1F106}"=>"5,",
- "\u{1F107}"=>"6,",
- "\u{1F108}"=>"7,",
- "\u{1F109}"=>"8,",
- "\u{1F10A}"=>"9,",
- "\u{1F110}"=>"(A)",
- "\u{1F111}"=>"(B)",
- "\u{1F112}"=>"(C)",
- "\u{1F113}"=>"(D)",
- "\u{1F114}"=>"(E)",
- "\u{1F115}"=>"(F)",
- "\u{1F116}"=>"(G)",
- "\u{1F117}"=>"(H)",
- "\u{1F118}"=>"(I)",
- "\u{1F119}"=>"(J)",
- "\u{1F11A}"=>"(K)",
- "\u{1F11B}"=>"(L)",
- "\u{1F11C}"=>"(M)",
- "\u{1F11D}"=>"(N)",
- "\u{1F11E}"=>"(O)",
- "\u{1F11F}"=>"(P)",
- "\u{1F120}"=>"(Q)",
- "\u{1F121}"=>"(R)",
- "\u{1F122}"=>"(S)",
- "\u{1F123}"=>"(T)",
- "\u{1F124}"=>"(U)",
- "\u{1F125}"=>"(V)",
- "\u{1F126}"=>"(W)",
- "\u{1F127}"=>"(X)",
- "\u{1F128}"=>"(Y)",
- "\u{1F129}"=>"(Z)",
- "\u{1F12A}"=>"\u3014S\u3015",
- "\u{1F12B}"=>"C",
- "\u{1F12C}"=>"R",
- "\u{1F12D}"=>"CD",
- "\u{1F12E}"=>"WZ",
- "\u{1F130}"=>"A",
- "\u{1F131}"=>"B",
- "\u{1F132}"=>"C",
- "\u{1F133}"=>"D",
- "\u{1F134}"=>"E",
- "\u{1F135}"=>"F",
- "\u{1F136}"=>"G",
- "\u{1F137}"=>"H",
- "\u{1F138}"=>"I",
- "\u{1F139}"=>"J",
- "\u{1F13A}"=>"K",
- "\u{1F13B}"=>"L",
- "\u{1F13C}"=>"M",
- "\u{1F13D}"=>"N",
- "\u{1F13E}"=>"O",
- "\u{1F13F}"=>"P",
- "\u{1F140}"=>"Q",
- "\u{1F141}"=>"R",
- "\u{1F142}"=>"S",
- "\u{1F143}"=>"T",
- "\u{1F144}"=>"U",
- "\u{1F145}"=>"V",
- "\u{1F146}"=>"W",
- "\u{1F147}"=>"X",
- "\u{1F148}"=>"Y",
- "\u{1F149}"=>"Z",
- "\u{1F14A}"=>"HV",
- "\u{1F14B}"=>"MV",
- "\u{1F14C}"=>"SD",
- "\u{1F14D}"=>"SS",
- "\u{1F14E}"=>"PPV",
- "\u{1F14F}"=>"WC",
- "\u{1F16A}"=>"MC",
- "\u{1F16B}"=>"MD",
- "\u{1F16C}"=>"MR",
- "\u{1F190}"=>"DJ",
- "\u{1F200}"=>"\u307B\u304B",
- "\u{1F201}"=>"\u30B3\u30B3",
- "\u{1F202}"=>"\u30B5",
- "\u{1F210}"=>"\u624B",
- "\u{1F211}"=>"\u5B57",
- "\u{1F212}"=>"\u53CC",
- "\u{1F213}"=>"\u30C7",
- "\u{1F214}"=>"\u4E8C",
- "\u{1F215}"=>"\u591A",
- "\u{1F216}"=>"\u89E3",
- "\u{1F217}"=>"\u5929",
- "\u{1F218}"=>"\u4EA4",
- "\u{1F219}"=>"\u6620",
- "\u{1F21A}"=>"\u7121",
- "\u{1F21B}"=>"\u6599",
- "\u{1F21C}"=>"\u524D",
- "\u{1F21D}"=>"\u5F8C",
- "\u{1F21E}"=>"\u518D",
- "\u{1F21F}"=>"\u65B0",
- "\u{1F220}"=>"\u521D",
- "\u{1F221}"=>"\u7D42",
- "\u{1F222}"=>"\u751F",
- "\u{1F223}"=>"\u8CA9",
- "\u{1F224}"=>"\u58F0",
- "\u{1F225}"=>"\u5439",
- "\u{1F226}"=>"\u6F14",
- "\u{1F227}"=>"\u6295",
- "\u{1F228}"=>"\u6355",
- "\u{1F229}"=>"\u4E00",
- "\u{1F22A}"=>"\u4E09",
- "\u{1F22B}"=>"\u904A",
- "\u{1F22C}"=>"\u5DE6",
- "\u{1F22D}"=>"\u4E2D",
- "\u{1F22E}"=>"\u53F3",
- "\u{1F22F}"=>"\u6307",
- "\u{1F230}"=>"\u8D70",
- "\u{1F231}"=>"\u6253",
- "\u{1F232}"=>"\u7981",
- "\u{1F233}"=>"\u7A7A",
- "\u{1F234}"=>"\u5408",
- "\u{1F235}"=>"\u6E80",
- "\u{1F236}"=>"\u6709",
- "\u{1F237}"=>"\u6708",
- "\u{1F238}"=>"\u7533",
- "\u{1F239}"=>"\u5272",
- "\u{1F23A}"=>"\u55B6",
- "\u{1F23B}"=>"\u914D",
- "\u{1F240}"=>"\u3014\u672C\u3015",
- "\u{1F241}"=>"\u3014\u4E09\u3015",
- "\u{1F242}"=>"\u3014\u4E8C\u3015",
- "\u{1F243}"=>"\u3014\u5B89\u3015",
- "\u{1F244}"=>"\u3014\u70B9\u3015",
- "\u{1F245}"=>"\u3014\u6253\u3015",
- "\u{1F246}"=>"\u3014\u76D7\u3015",
- "\u{1F247}"=>"\u3014\u52DD\u3015",
- "\u{1F248}"=>"\u3014\u6557\u3015",
- "\u{1F250}"=>"\u5F97",
- "\u{1F251}"=>"\u53EF",
- "\u0385"=>" \u0308\u0301",
- "\u03D3"=>"\u03A5\u0301",
- "\u03D4"=>"\u03A5\u0308",
- "\u1E9B"=>"s\u0307",
- "\u1FC1"=>" \u0308\u0342",
- "\u1FCD"=>" \u0313\u0300",
- "\u1FCE"=>" \u0313\u0301",
- "\u1FCF"=>" \u0313\u0342",
- "\u1FDD"=>" \u0314\u0300",
- "\u1FDE"=>" \u0314\u0301",
- "\u1FDF"=>" \u0314\u0342",
- "\u1FED"=>" \u0308\u0300",
- "\u1FEE"=>" \u0308\u0301",
- "\u1FFD"=>" \u0301",
- "\u2000"=>" ",
- "\u2001"=>" ",
+ "\u00A0"=>" ", "\u00A8"=>" \u0308", "\u00AA"=>"a", "\u00AF"=>" \u0304", "\u00B2"=>"2", "\u00B3"=>"3", "\u00B4"=>" \u0301", "\u00B5"=>"\u03BC",
+ "\u00B8"=>" \u0327", "\u00B9"=>"1", "\u00BA"=>"o", "\u00BC"=>"1\u20444", "\u00BD"=>"1\u20442", "\u00BE"=>"3\u20444", "\u0132"=>"IJ", "\u0133"=>"ij",
+ "\u013F"=>"L\u00B7", "\u0140"=>"l\u00B7", "\u0149"=>"\u02BCn", "\u017F"=>"s", "\u01C4"=>"D\u017D", "\u01C5"=>"D\u017E", "\u01C6"=>"d\u017E", "\u01C7"=>"LJ",
+ "\u01C8"=>"Lj", "\u01C9"=>"lj", "\u01CA"=>"NJ", "\u01CB"=>"Nj", "\u01CC"=>"nj", "\u01F1"=>"DZ", "\u01F2"=>"Dz", "\u01F3"=>"dz",
+ "\u02B0"=>"h", "\u02B1"=>"\u0266", "\u02B2"=>"j", "\u02B3"=>"r", "\u02B4"=>"\u0279", "\u02B5"=>"\u027B", "\u02B6"=>"\u0281", "\u02B7"=>"w",
+ "\u02B8"=>"y", "\u02D8"=>" \u0306", "\u02D9"=>" \u0307", "\u02DA"=>" \u030A", "\u02DB"=>" \u0328", "\u02DC"=>" \u0303", "\u02DD"=>" \u030B", "\u02E0"=>"\u0263",
+ "\u02E1"=>"l", "\u02E2"=>"s", "\u02E3"=>"x", "\u02E4"=>"\u0295", "\u037A"=>" \u0345", "\u0384"=>" \u0301", "\u03D0"=>"\u03B2", "\u03D1"=>"\u03B8",
+ "\u03D2"=>"\u03A5", "\u03D5"=>"\u03C6", "\u03D6"=>"\u03C0", "\u03F0"=>"\u03BA", "\u03F1"=>"\u03C1", "\u03F2"=>"\u03C2", "\u03F4"=>"\u0398", "\u03F5"=>"\u03B5",
+ "\u03F9"=>"\u03A3", "\u0587"=>"\u0565\u0582", "\u0675"=>"\u0627\u0674", "\u0676"=>"\u0648\u0674", "\u0677"=>"\u06C7\u0674", "\u0678"=>"\u064A\u0674", "\u0E33"=>"\u0E4D\u0E32", "\u0EB3"=>"\u0ECD\u0EB2",
+ "\u0EDC"=>"\u0EAB\u0E99", "\u0EDD"=>"\u0EAB\u0EA1", "\u0F0C"=>"\u0F0B", "\u0F77"=>"\u0FB2\u0F81", "\u0F79"=>"\u0FB3\u0F81", "\u10FC"=>"\u10DC", "\u1D2C"=>"A", "\u1D2D"=>"\u00C6",
+ "\u1D2E"=>"B", "\u1D30"=>"D", "\u1D31"=>"E", "\u1D32"=>"\u018E", "\u1D33"=>"G", "\u1D34"=>"H", "\u1D35"=>"I", "\u1D36"=>"J",
+ "\u1D37"=>"K", "\u1D38"=>"L", "\u1D39"=>"M", "\u1D3A"=>"N", "\u1D3C"=>"O", "\u1D3D"=>"\u0222", "\u1D3E"=>"P", "\u1D3F"=>"R",
+ "\u1D40"=>"T", "\u1D41"=>"U", "\u1D42"=>"W", "\u1D43"=>"a", "\u1D44"=>"\u0250", "\u1D45"=>"\u0251", "\u1D46"=>"\u1D02", "\u1D47"=>"b",
+ "\u1D48"=>"d", "\u1D49"=>"e", "\u1D4A"=>"\u0259", "\u1D4B"=>"\u025B", "\u1D4C"=>"\u025C", "\u1D4D"=>"g", "\u1D4F"=>"k", "\u1D50"=>"m",
+ "\u1D51"=>"\u014B", "\u1D52"=>"o", "\u1D53"=>"\u0254", "\u1D54"=>"\u1D16", "\u1D55"=>"\u1D17", "\u1D56"=>"p", "\u1D57"=>"t", "\u1D58"=>"u",
+ "\u1D59"=>"\u1D1D", "\u1D5A"=>"\u026F", "\u1D5B"=>"v", "\u1D5C"=>"\u1D25", "\u1D5D"=>"\u03B2", "\u1D5E"=>"\u03B3", "\u1D5F"=>"\u03B4", "\u1D60"=>"\u03C6",
+ "\u1D61"=>"\u03C7", "\u1D62"=>"i", "\u1D63"=>"r", "\u1D64"=>"u", "\u1D65"=>"v", "\u1D66"=>"\u03B2", "\u1D67"=>"\u03B3", "\u1D68"=>"\u03C1",
+ "\u1D69"=>"\u03C6", "\u1D6A"=>"\u03C7", "\u1D78"=>"\u043D", "\u1D9B"=>"\u0252", "\u1D9C"=>"c", "\u1D9D"=>"\u0255", "\u1D9E"=>"\u00F0", "\u1D9F"=>"\u025C",
+ "\u1DA0"=>"f", "\u1DA1"=>"\u025F", "\u1DA2"=>"\u0261", "\u1DA3"=>"\u0265", "\u1DA4"=>"\u0268", "\u1DA5"=>"\u0269", "\u1DA6"=>"\u026A", "\u1DA7"=>"\u1D7B",
+ "\u1DA8"=>"\u029D", "\u1DA9"=>"\u026D", "\u1DAA"=>"\u1D85", "\u1DAB"=>"\u029F", "\u1DAC"=>"\u0271", "\u1DAD"=>"\u0270", "\u1DAE"=>"\u0272", "\u1DAF"=>"\u0273",
+ "\u1DB0"=>"\u0274", "\u1DB1"=>"\u0275", "\u1DB2"=>"\u0278", "\u1DB3"=>"\u0282", "\u1DB4"=>"\u0283", "\u1DB5"=>"\u01AB", "\u1DB6"=>"\u0289", "\u1DB7"=>"\u028A",
+ "\u1DB8"=>"\u1D1C", "\u1DB9"=>"\u028B", "\u1DBA"=>"\u028C", "\u1DBB"=>"z", "\u1DBC"=>"\u0290", "\u1DBD"=>"\u0291", "\u1DBE"=>"\u0292", "\u1DBF"=>"\u03B8",
+ "\u1E9A"=>"a\u02BE", "\u1FBD"=>" \u0313", "\u1FBF"=>" \u0313", "\u1FC0"=>" \u0342", "\u1FFE"=>" \u0314", "\u2002"=>" ", "\u2003"=>" ", "\u2004"=>" ",
+ "\u2005"=>" ", "\u2006"=>" ", "\u2007"=>" ", "\u2008"=>" ", "\u2009"=>" ", "\u200A"=>" ", "\u2011"=>"\u2010", "\u2017"=>" \u0333",
+ "\u2024"=>".", "\u2025"=>"..", "\u2026"=>"...", "\u202F"=>" ", "\u2033"=>"\u2032\u2032", "\u2034"=>"\u2032\u2032\u2032", "\u2036"=>"\u2035\u2035", "\u2037"=>"\u2035\u2035\u2035",
+ "\u203C"=>"!!", "\u203E"=>" \u0305", "\u2047"=>"??", "\u2048"=>"?!", "\u2049"=>"!?", "\u2057"=>"\u2032\u2032\u2032\u2032", "\u205F"=>" ", "\u2070"=>"0",
+ "\u2071"=>"i", "\u2074"=>"4", "\u2075"=>"5", "\u2076"=>"6", "\u2077"=>"7", "\u2078"=>"8", "\u2079"=>"9", "\u207A"=>"+",
+ "\u207B"=>"\u2212", "\u207C"=>"=", "\u207D"=>"(", "\u207E"=>")", "\u207F"=>"n", "\u2080"=>"0", "\u2081"=>"1", "\u2082"=>"2",
+ "\u2083"=>"3", "\u2084"=>"4", "\u2085"=>"5", "\u2086"=>"6", "\u2087"=>"7", "\u2088"=>"8", "\u2089"=>"9", "\u208A"=>"+",
+ "\u208B"=>"\u2212", "\u208C"=>"=", "\u208D"=>"(", "\u208E"=>")", "\u2090"=>"a", "\u2091"=>"e", "\u2092"=>"o", "\u2093"=>"x",
+ "\u2094"=>"\u0259", "\u2095"=>"h", "\u2096"=>"k", "\u2097"=>"l", "\u2098"=>"m", "\u2099"=>"n", "\u209A"=>"p", "\u209B"=>"s",
+ "\u209C"=>"t", "\u20A8"=>"Rs", "\u2100"=>"a/c", "\u2101"=>"a/s", "\u2102"=>"C", "\u2103"=>"\u00B0C", "\u2105"=>"c/o", "\u2106"=>"c/u",
+ "\u2107"=>"\u0190", "\u2109"=>"\u00B0F", "\u210A"=>"g", "\u210B"=>"H", "\u210C"=>"H", "\u210D"=>"H", "\u210E"=>"h", "\u210F"=>"\u0127",
+ "\u2110"=>"I", "\u2111"=>"I", "\u2112"=>"L", "\u2113"=>"l", "\u2115"=>"N", "\u2116"=>"No", "\u2119"=>"P", "\u211A"=>"Q",
+ "\u211B"=>"R", "\u211C"=>"R", "\u211D"=>"R", "\u2120"=>"SM", "\u2121"=>"TEL", "\u2122"=>"TM", "\u2124"=>"Z", "\u2128"=>"Z",
+ "\u212C"=>"B", "\u212D"=>"C", "\u212F"=>"e", "\u2130"=>"E", "\u2131"=>"F", "\u2133"=>"M", "\u2134"=>"o", "\u2135"=>"\u05D0",
+ "\u2136"=>"\u05D1", "\u2137"=>"\u05D2", "\u2138"=>"\u05D3", "\u2139"=>"i", "\u213B"=>"FAX", "\u213C"=>"\u03C0", "\u213D"=>"\u03B3", "\u213E"=>"\u0393",
+ "\u213F"=>"\u03A0", "\u2140"=>"\u2211", "\u2145"=>"D", "\u2146"=>"d", "\u2147"=>"e", "\u2148"=>"i", "\u2149"=>"j", "\u2150"=>"1\u20447",
+ "\u2151"=>"1\u20449", "\u2152"=>"1\u204410", "\u2153"=>"1\u20443", "\u2154"=>"2\u20443", "\u2155"=>"1\u20445", "\u2156"=>"2\u20445", "\u2157"=>"3\u20445", "\u2158"=>"4\u20445",
+ "\u2159"=>"1\u20446", "\u215A"=>"5\u20446", "\u215B"=>"1\u20448", "\u215C"=>"3\u20448", "\u215D"=>"5\u20448", "\u215E"=>"7\u20448", "\u215F"=>"1\u2044", "\u2160"=>"I",
+ "\u2161"=>"II", "\u2162"=>"III", "\u2163"=>"IV", "\u2164"=>"V", "\u2165"=>"VI", "\u2166"=>"VII", "\u2167"=>"VIII", "\u2168"=>"IX",
+ "\u2169"=>"X", "\u216A"=>"XI", "\u216B"=>"XII", "\u216C"=>"L", "\u216D"=>"C", "\u216E"=>"D", "\u216F"=>"M", "\u2170"=>"i",
+ "\u2171"=>"ii", "\u2172"=>"iii", "\u2173"=>"iv", "\u2174"=>"v", "\u2175"=>"vi", "\u2176"=>"vii", "\u2177"=>"viii", "\u2178"=>"ix",
+ "\u2179"=>"x", "\u217A"=>"xi", "\u217B"=>"xii", "\u217C"=>"l", "\u217D"=>"c", "\u217E"=>"d", "\u217F"=>"m", "\u2189"=>"0\u20443",
+ "\u222C"=>"\u222B\u222B", "\u222D"=>"\u222B\u222B\u222B", "\u222F"=>"\u222E\u222E", "\u2230"=>"\u222E\u222E\u222E", "\u2460"=>"1", "\u2461"=>"2", "\u2462"=>"3", "\u2463"=>"4",
+ "\u2464"=>"5", "\u2465"=>"6", "\u2466"=>"7", "\u2467"=>"8", "\u2468"=>"9", "\u2469"=>"10", "\u246A"=>"11", "\u246B"=>"12",
+ "\u246C"=>"13", "\u246D"=>"14", "\u246E"=>"15", "\u246F"=>"16", "\u2470"=>"17", "\u2471"=>"18", "\u2472"=>"19", "\u2473"=>"20",
+ "\u2474"=>"(1)", "\u2475"=>"(2)", "\u2476"=>"(3)", "\u2477"=>"(4)", "\u2478"=>"(5)", "\u2479"=>"(6)", "\u247A"=>"(7)", "\u247B"=>"(8)",
+ "\u247C"=>"(9)", "\u247D"=>"(10)", "\u247E"=>"(11)", "\u247F"=>"(12)", "\u2480"=>"(13)", "\u2481"=>"(14)", "\u2482"=>"(15)", "\u2483"=>"(16)",
+ "\u2484"=>"(17)", "\u2485"=>"(18)", "\u2486"=>"(19)", "\u2487"=>"(20)", "\u2488"=>"1.", "\u2489"=>"2.", "\u248A"=>"3.", "\u248B"=>"4.",
+ "\u248C"=>"5.", "\u248D"=>"6.", "\u248E"=>"7.", "\u248F"=>"8.", "\u2490"=>"9.", "\u2491"=>"10.", "\u2492"=>"11.", "\u2493"=>"12.",
+ "\u2494"=>"13.", "\u2495"=>"14.", "\u2496"=>"15.", "\u2497"=>"16.", "\u2498"=>"17.", "\u2499"=>"18.", "\u249A"=>"19.", "\u249B"=>"20.",
+ "\u249C"=>"(a)", "\u249D"=>"(b)", "\u249E"=>"(c)", "\u249F"=>"(d)", "\u24A0"=>"(e)", "\u24A1"=>"(f)", "\u24A2"=>"(g)", "\u24A3"=>"(h)",
+ "\u24A4"=>"(i)", "\u24A5"=>"(j)", "\u24A6"=>"(k)", "\u24A7"=>"(l)", "\u24A8"=>"(m)", "\u24A9"=>"(n)", "\u24AA"=>"(o)", "\u24AB"=>"(p)",
+ "\u24AC"=>"(q)", "\u24AD"=>"(r)", "\u24AE"=>"(s)", "\u24AF"=>"(t)", "\u24B0"=>"(u)", "\u24B1"=>"(v)", "\u24B2"=>"(w)", "\u24B3"=>"(x)",
+ "\u24B4"=>"(y)", "\u24B5"=>"(z)", "\u24B6"=>"A", "\u24B7"=>"B", "\u24B8"=>"C", "\u24B9"=>"D", "\u24BA"=>"E", "\u24BB"=>"F",
+ "\u24BC"=>"G", "\u24BD"=>"H", "\u24BE"=>"I", "\u24BF"=>"J", "\u24C0"=>"K", "\u24C1"=>"L", "\u24C2"=>"M", "\u24C3"=>"N",
+ "\u24C4"=>"O", "\u24C5"=>"P", "\u24C6"=>"Q", "\u24C7"=>"R", "\u24C8"=>"S", "\u24C9"=>"T", "\u24CA"=>"U", "\u24CB"=>"V",
+ "\u24CC"=>"W", "\u24CD"=>"X", "\u24CE"=>"Y", "\u24CF"=>"Z", "\u24D0"=>"a", "\u24D1"=>"b", "\u24D2"=>"c", "\u24D3"=>"d",
+ "\u24D4"=>"e", "\u24D5"=>"f", "\u24D6"=>"g", "\u24D7"=>"h", "\u24D8"=>"i", "\u24D9"=>"j", "\u24DA"=>"k", "\u24DB"=>"l",
+ "\u24DC"=>"m", "\u24DD"=>"n", "\u24DE"=>"o", "\u24DF"=>"p", "\u24E0"=>"q", "\u24E1"=>"r", "\u24E2"=>"s", "\u24E3"=>"t",
+ "\u24E4"=>"u", "\u24E5"=>"v", "\u24E6"=>"w", "\u24E7"=>"x", "\u24E8"=>"y", "\u24E9"=>"z", "\u24EA"=>"0", "\u2A0C"=>"\u222B\u222B\u222B\u222B",
+ "\u2A74"=>"::=", "\u2A75"=>"==", "\u2A76"=>"===", "\u2C7C"=>"j", "\u2C7D"=>"V", "\u2D6F"=>"\u2D61", "\u2E9F"=>"\u6BCD", "\u2EF3"=>"\u9F9F",
+ "\u2F00"=>"\u4E00", "\u2F01"=>"\u4E28", "\u2F02"=>"\u4E36", "\u2F03"=>"\u4E3F", "\u2F04"=>"\u4E59", "\u2F05"=>"\u4E85", "\u2F06"=>"\u4E8C", "\u2F07"=>"\u4EA0",
+ "\u2F08"=>"\u4EBA", "\u2F09"=>"\u513F", "\u2F0A"=>"\u5165", "\u2F0B"=>"\u516B", "\u2F0C"=>"\u5182", "\u2F0D"=>"\u5196", "\u2F0E"=>"\u51AB", "\u2F0F"=>"\u51E0",
+ "\u2F10"=>"\u51F5", "\u2F11"=>"\u5200", "\u2F12"=>"\u529B", "\u2F13"=>"\u52F9", "\u2F14"=>"\u5315", "\u2F15"=>"\u531A", "\u2F16"=>"\u5338", "\u2F17"=>"\u5341",
+ "\u2F18"=>"\u535C", "\u2F19"=>"\u5369", "\u2F1A"=>"\u5382", "\u2F1B"=>"\u53B6", "\u2F1C"=>"\u53C8", "\u2F1D"=>"\u53E3", "\u2F1E"=>"\u56D7", "\u2F1F"=>"\u571F",
+ "\u2F20"=>"\u58EB", "\u2F21"=>"\u5902", "\u2F22"=>"\u590A", "\u2F23"=>"\u5915", "\u2F24"=>"\u5927", "\u2F25"=>"\u5973", "\u2F26"=>"\u5B50", "\u2F27"=>"\u5B80",
+ "\u2F28"=>"\u5BF8", "\u2F29"=>"\u5C0F", "\u2F2A"=>"\u5C22", "\u2F2B"=>"\u5C38", "\u2F2C"=>"\u5C6E", "\u2F2D"=>"\u5C71", "\u2F2E"=>"\u5DDB", "\u2F2F"=>"\u5DE5",
+ "\u2F30"=>"\u5DF1", "\u2F31"=>"\u5DFE", "\u2F32"=>"\u5E72", "\u2F33"=>"\u5E7A", "\u2F34"=>"\u5E7F", "\u2F35"=>"\u5EF4", "\u2F36"=>"\u5EFE", "\u2F37"=>"\u5F0B",
+ "\u2F38"=>"\u5F13", "\u2F39"=>"\u5F50", "\u2F3A"=>"\u5F61", "\u2F3B"=>"\u5F73", "\u2F3C"=>"\u5FC3", "\u2F3D"=>"\u6208", "\u2F3E"=>"\u6236", "\u2F3F"=>"\u624B",
+ "\u2F40"=>"\u652F", "\u2F41"=>"\u6534", "\u2F42"=>"\u6587", "\u2F43"=>"\u6597", "\u2F44"=>"\u65A4", "\u2F45"=>"\u65B9", "\u2F46"=>"\u65E0", "\u2F47"=>"\u65E5",
+ "\u2F48"=>"\u66F0", "\u2F49"=>"\u6708", "\u2F4A"=>"\u6728", "\u2F4B"=>"\u6B20", "\u2F4C"=>"\u6B62", "\u2F4D"=>"\u6B79", "\u2F4E"=>"\u6BB3", "\u2F4F"=>"\u6BCB",
+ "\u2F50"=>"\u6BD4", "\u2F51"=>"\u6BDB", "\u2F52"=>"\u6C0F", "\u2F53"=>"\u6C14", "\u2F54"=>"\u6C34", "\u2F55"=>"\u706B", "\u2F56"=>"\u722A", "\u2F57"=>"\u7236",
+ "\u2F58"=>"\u723B", "\u2F59"=>"\u723F", "\u2F5A"=>"\u7247", "\u2F5B"=>"\u7259", "\u2F5C"=>"\u725B", "\u2F5D"=>"\u72AC", "\u2F5E"=>"\u7384", "\u2F5F"=>"\u7389",
+ "\u2F60"=>"\u74DC", "\u2F61"=>"\u74E6", "\u2F62"=>"\u7518", "\u2F63"=>"\u751F", "\u2F64"=>"\u7528", "\u2F65"=>"\u7530", "\u2F66"=>"\u758B", "\u2F67"=>"\u7592",
+ "\u2F68"=>"\u7676", "\u2F69"=>"\u767D", "\u2F6A"=>"\u76AE", "\u2F6B"=>"\u76BF", "\u2F6C"=>"\u76EE", "\u2F6D"=>"\u77DB", "\u2F6E"=>"\u77E2", "\u2F6F"=>"\u77F3",
+ "\u2F70"=>"\u793A", "\u2F71"=>"\u79B8", "\u2F72"=>"\u79BE", "\u2F73"=>"\u7A74", "\u2F74"=>"\u7ACB", "\u2F75"=>"\u7AF9", "\u2F76"=>"\u7C73", "\u2F77"=>"\u7CF8",
+ "\u2F78"=>"\u7F36", "\u2F79"=>"\u7F51", "\u2F7A"=>"\u7F8A", "\u2F7B"=>"\u7FBD", "\u2F7C"=>"\u8001", "\u2F7D"=>"\u800C", "\u2F7E"=>"\u8012", "\u2F7F"=>"\u8033",
+ "\u2F80"=>"\u807F", "\u2F81"=>"\u8089", "\u2F82"=>"\u81E3", "\u2F83"=>"\u81EA", "\u2F84"=>"\u81F3", "\u2F85"=>"\u81FC", "\u2F86"=>"\u820C", "\u2F87"=>"\u821B",
+ "\u2F88"=>"\u821F", "\u2F89"=>"\u826E", "\u2F8A"=>"\u8272", "\u2F8B"=>"\u8278", "\u2F8C"=>"\u864D", "\u2F8D"=>"\u866B", "\u2F8E"=>"\u8840", "\u2F8F"=>"\u884C",
+ "\u2F90"=>"\u8863", "\u2F91"=>"\u897E", "\u2F92"=>"\u898B", "\u2F93"=>"\u89D2", "\u2F94"=>"\u8A00", "\u2F95"=>"\u8C37", "\u2F96"=>"\u8C46", "\u2F97"=>"\u8C55",
+ "\u2F98"=>"\u8C78", "\u2F99"=>"\u8C9D", "\u2F9A"=>"\u8D64", "\u2F9B"=>"\u8D70", "\u2F9C"=>"\u8DB3", "\u2F9D"=>"\u8EAB", "\u2F9E"=>"\u8ECA", "\u2F9F"=>"\u8F9B",
+ "\u2FA0"=>"\u8FB0", "\u2FA1"=>"\u8FB5", "\u2FA2"=>"\u9091", "\u2FA3"=>"\u9149", "\u2FA4"=>"\u91C6", "\u2FA5"=>"\u91CC", "\u2FA6"=>"\u91D1", "\u2FA7"=>"\u9577",
+ "\u2FA8"=>"\u9580", "\u2FA9"=>"\u961C", "\u2FAA"=>"\u96B6", "\u2FAB"=>"\u96B9", "\u2FAC"=>"\u96E8", "\u2FAD"=>"\u9751", "\u2FAE"=>"\u975E", "\u2FAF"=>"\u9762",
+ "\u2FB0"=>"\u9769", "\u2FB1"=>"\u97CB", "\u2FB2"=>"\u97ED", "\u2FB3"=>"\u97F3", "\u2FB4"=>"\u9801", "\u2FB5"=>"\u98A8", "\u2FB6"=>"\u98DB", "\u2FB7"=>"\u98DF",
+ "\u2FB8"=>"\u9996", "\u2FB9"=>"\u9999", "\u2FBA"=>"\u99AC", "\u2FBB"=>"\u9AA8", "\u2FBC"=>"\u9AD8", "\u2FBD"=>"\u9ADF", "\u2FBE"=>"\u9B25", "\u2FBF"=>"\u9B2F",
+ "\u2FC0"=>"\u9B32", "\u2FC1"=>"\u9B3C", "\u2FC2"=>"\u9B5A", "\u2FC3"=>"\u9CE5", "\u2FC4"=>"\u9E75", "\u2FC5"=>"\u9E7F", "\u2FC6"=>"\u9EA5", "\u2FC7"=>"\u9EBB",
+ "\u2FC8"=>"\u9EC3", "\u2FC9"=>"\u9ECD", "\u2FCA"=>"\u9ED1", "\u2FCB"=>"\u9EF9", "\u2FCC"=>"\u9EFD", "\u2FCD"=>"\u9F0E", "\u2FCE"=>"\u9F13", "\u2FCF"=>"\u9F20",
+ "\u2FD0"=>"\u9F3B", "\u2FD1"=>"\u9F4A", "\u2FD2"=>"\u9F52", "\u2FD3"=>"\u9F8D", "\u2FD4"=>"\u9F9C", "\u2FD5"=>"\u9FA0", "\u3000"=>" ", "\u3036"=>"\u3012",
+ "\u3038"=>"\u5341", "\u3039"=>"\u5344", "\u303A"=>"\u5345", "\u309B"=>" \u3099", "\u309C"=>" \u309A", "\u309F"=>"\u3088\u308A", "\u30FF"=>"\u30B3\u30C8", "\u3131"=>"\u1100",
+ "\u3132"=>"\u1101", "\u3133"=>"\u11AA", "\u3134"=>"\u1102", "\u3135"=>"\u11AC", "\u3136"=>"\u11AD", "\u3137"=>"\u1103", "\u3138"=>"\u1104", "\u3139"=>"\u1105",
+ "\u313A"=>"\u11B0", "\u313B"=>"\u11B1", "\u313C"=>"\u11B2", "\u313D"=>"\u11B3", "\u313E"=>"\u11B4", "\u313F"=>"\u11B5", "\u3140"=>"\u111A", "\u3141"=>"\u1106",
+ "\u3142"=>"\u1107", "\u3143"=>"\u1108", "\u3144"=>"\u1121", "\u3145"=>"\u1109", "\u3146"=>"\u110A", "\u3147"=>"\u110B", "\u3148"=>"\u110C", "\u3149"=>"\u110D",
+ "\u314A"=>"\u110E", "\u314B"=>"\u110F", "\u314C"=>"\u1110", "\u314D"=>"\u1111", "\u314E"=>"\u1112", "\u314F"=>"\u1161", "\u3150"=>"\u1162", "\u3151"=>"\u1163",
+ "\u3152"=>"\u1164", "\u3153"=>"\u1165", "\u3154"=>"\u1166", "\u3155"=>"\u1167", "\u3156"=>"\u1168", "\u3157"=>"\u1169", "\u3158"=>"\u116A", "\u3159"=>"\u116B",
+ "\u315A"=>"\u116C", "\u315B"=>"\u116D", "\u315C"=>"\u116E", "\u315D"=>"\u116F", "\u315E"=>"\u1170", "\u315F"=>"\u1171", "\u3160"=>"\u1172", "\u3161"=>"\u1173",
+ "\u3162"=>"\u1174", "\u3163"=>"\u1175", "\u3164"=>"\u1160", "\u3165"=>"\u1114", "\u3166"=>"\u1115", "\u3167"=>"\u11C7", "\u3168"=>"\u11C8", "\u3169"=>"\u11CC",
+ "\u316A"=>"\u11CE", "\u316B"=>"\u11D3", "\u316C"=>"\u11D7", "\u316D"=>"\u11D9", "\u316E"=>"\u111C", "\u316F"=>"\u11DD", "\u3170"=>"\u11DF", "\u3171"=>"\u111D",
+ "\u3172"=>"\u111E", "\u3173"=>"\u1120", "\u3174"=>"\u1122", "\u3175"=>"\u1123", "\u3176"=>"\u1127", "\u3177"=>"\u1129", "\u3178"=>"\u112B", "\u3179"=>"\u112C",
+ "\u317A"=>"\u112D", "\u317B"=>"\u112E", "\u317C"=>"\u112F", "\u317D"=>"\u1132", "\u317E"=>"\u1136", "\u317F"=>"\u1140", "\u3180"=>"\u1147", "\u3181"=>"\u114C",
+ "\u3182"=>"\u11F1", "\u3183"=>"\u11F2", "\u3184"=>"\u1157", "\u3185"=>"\u1158", "\u3186"=>"\u1159", "\u3187"=>"\u1184", "\u3188"=>"\u1185", "\u3189"=>"\u1188",
+ "\u318A"=>"\u1191", "\u318B"=>"\u1192", "\u318C"=>"\u1194", "\u318D"=>"\u119E", "\u318E"=>"\u11A1", "\u3192"=>"\u4E00", "\u3193"=>"\u4E8C", "\u3194"=>"\u4E09",
+ "\u3195"=>"\u56DB", "\u3196"=>"\u4E0A", "\u3197"=>"\u4E2D", "\u3198"=>"\u4E0B", "\u3199"=>"\u7532", "\u319A"=>"\u4E59", "\u319B"=>"\u4E19", "\u319C"=>"\u4E01",
+ "\u319D"=>"\u5929", "\u319E"=>"\u5730", "\u319F"=>"\u4EBA", "\u3200"=>"(\u1100)", "\u3201"=>"(\u1102)", "\u3202"=>"(\u1103)", "\u3203"=>"(\u1105)", "\u3204"=>"(\u1106)",
+ "\u3205"=>"(\u1107)", "\u3206"=>"(\u1109)", "\u3207"=>"(\u110B)", "\u3208"=>"(\u110C)", "\u3209"=>"(\u110E)", "\u320A"=>"(\u110F)", "\u320B"=>"(\u1110)", "\u320C"=>"(\u1111)",
+ "\u320D"=>"(\u1112)", "\u320E"=>"(\u1100\u1161)", "\u320F"=>"(\u1102\u1161)", "\u3210"=>"(\u1103\u1161)", "\u3211"=>"(\u1105\u1161)", "\u3212"=>"(\u1106\u1161)", "\u3213"=>"(\u1107\u1161)", "\u3214"=>"(\u1109\u1161)",
+ "\u3215"=>"(\u110B\u1161)", "\u3216"=>"(\u110C\u1161)", "\u3217"=>"(\u110E\u1161)", "\u3218"=>"(\u110F\u1161)", "\u3219"=>"(\u1110\u1161)", "\u321A"=>"(\u1111\u1161)", "\u321B"=>"(\u1112\u1161)", "\u321C"=>"(\u110C\u116E)",
+ "\u321D"=>"(\u110B\u1169\u110C\u1165\u11AB)", "\u321E"=>"(\u110B\u1169\u1112\u116E)", "\u3220"=>"(\u4E00)", "\u3221"=>"(\u4E8C)", "\u3222"=>"(\u4E09)", "\u3223"=>"(\u56DB)", "\u3224"=>"(\u4E94)", "\u3225"=>"(\u516D)",
+ "\u3226"=>"(\u4E03)", "\u3227"=>"(\u516B)", "\u3228"=>"(\u4E5D)", "\u3229"=>"(\u5341)", "\u322A"=>"(\u6708)", "\u322B"=>"(\u706B)", "\u322C"=>"(\u6C34)", "\u322D"=>"(\u6728)",
+ "\u322E"=>"(\u91D1)", "\u322F"=>"(\u571F)", "\u3230"=>"(\u65E5)", "\u3231"=>"(\u682A)", "\u3232"=>"(\u6709)", "\u3233"=>"(\u793E)", "\u3234"=>"(\u540D)", "\u3235"=>"(\u7279)",
+ "\u3236"=>"(\u8CA1)", "\u3237"=>"(\u795D)", "\u3238"=>"(\u52B4)", "\u3239"=>"(\u4EE3)", "\u323A"=>"(\u547C)", "\u323B"=>"(\u5B66)", "\u323C"=>"(\u76E3)", "\u323D"=>"(\u4F01)",
+ "\u323E"=>"(\u8CC7)", "\u323F"=>"(\u5354)", "\u3240"=>"(\u796D)", "\u3241"=>"(\u4F11)", "\u3242"=>"(\u81EA)", "\u3243"=>"(\u81F3)", "\u3244"=>"\u554F", "\u3245"=>"\u5E7C",
+ "\u3246"=>"\u6587", "\u3247"=>"\u7B8F", "\u3250"=>"PTE", "\u3251"=>"21", "\u3252"=>"22", "\u3253"=>"23", "\u3254"=>"24", "\u3255"=>"25",
+ "\u3256"=>"26", "\u3257"=>"27", "\u3258"=>"28", "\u3259"=>"29", "\u325A"=>"30", "\u325B"=>"31", "\u325C"=>"32", "\u325D"=>"33",
+ "\u325E"=>"34", "\u325F"=>"35", "\u3260"=>"\u1100", "\u3261"=>"\u1102", "\u3262"=>"\u1103", "\u3263"=>"\u1105", "\u3264"=>"\u1106", "\u3265"=>"\u1107",
+ "\u3266"=>"\u1109", "\u3267"=>"\u110B", "\u3268"=>"\u110C", "\u3269"=>"\u110E", "\u326A"=>"\u110F", "\u326B"=>"\u1110", "\u326C"=>"\u1111", "\u326D"=>"\u1112",
+ "\u326E"=>"\u1100\u1161", "\u326F"=>"\u1102\u1161", "\u3270"=>"\u1103\u1161", "\u3271"=>"\u1105\u1161", "\u3272"=>"\u1106\u1161", "\u3273"=>"\u1107\u1161", "\u3274"=>"\u1109\u1161", "\u3275"=>"\u110B\u1161",
+ "\u3276"=>"\u110C\u1161", "\u3277"=>"\u110E\u1161", "\u3278"=>"\u110F\u1161", "\u3279"=>"\u1110\u1161", "\u327A"=>"\u1111\u1161", "\u327B"=>"\u1112\u1161", "\u327C"=>"\u110E\u1161\u11B7\u1100\u1169", "\u327D"=>"\u110C\u116E\u110B\u1174",
+ "\u327E"=>"\u110B\u116E", "\u3280"=>"\u4E00", "\u3281"=>"\u4E8C", "\u3282"=>"\u4E09", "\u3283"=>"\u56DB", "\u3284"=>"\u4E94", "\u3285"=>"\u516D", "\u3286"=>"\u4E03",
+ "\u3287"=>"\u516B", "\u3288"=>"\u4E5D", "\u3289"=>"\u5341", "\u328A"=>"\u6708", "\u328B"=>"\u706B", "\u328C"=>"\u6C34", "\u328D"=>"\u6728", "\u328E"=>"\u91D1",
+ "\u328F"=>"\u571F", "\u3290"=>"\u65E5", "\u3291"=>"\u682A", "\u3292"=>"\u6709", "\u3293"=>"\u793E", "\u3294"=>"\u540D", "\u3295"=>"\u7279", "\u3296"=>"\u8CA1",
+ "\u3297"=>"\u795D", "\u3298"=>"\u52B4", "\u3299"=>"\u79D8", "\u329A"=>"\u7537", "\u329B"=>"\u5973", "\u329C"=>"\u9069", "\u329D"=>"\u512A", "\u329E"=>"\u5370",
+ "\u329F"=>"\u6CE8", "\u32A0"=>"\u9805", "\u32A1"=>"\u4F11", "\u32A2"=>"\u5199", "\u32A3"=>"\u6B63", "\u32A4"=>"\u4E0A", "\u32A5"=>"\u4E2D", "\u32A6"=>"\u4E0B",
+ "\u32A7"=>"\u5DE6", "\u32A8"=>"\u53F3", "\u32A9"=>"\u533B", "\u32AA"=>"\u5B97", "\u32AB"=>"\u5B66", "\u32AC"=>"\u76E3", "\u32AD"=>"\u4F01", "\u32AE"=>"\u8CC7",
+ "\u32AF"=>"\u5354", "\u32B0"=>"\u591C", "\u32B1"=>"36", "\u32B2"=>"37", "\u32B3"=>"38", "\u32B4"=>"39", "\u32B5"=>"40", "\u32B6"=>"41",
+ "\u32B7"=>"42", "\u32B8"=>"43", "\u32B9"=>"44", "\u32BA"=>"45", "\u32BB"=>"46", "\u32BC"=>"47", "\u32BD"=>"48", "\u32BE"=>"49",
+ "\u32BF"=>"50", "\u32C0"=>"1\u6708", "\u32C1"=>"2\u6708", "\u32C2"=>"3\u6708", "\u32C3"=>"4\u6708", "\u32C4"=>"5\u6708", "\u32C5"=>"6\u6708", "\u32C6"=>"7\u6708",
+ "\u32C7"=>"8\u6708", "\u32C8"=>"9\u6708", "\u32C9"=>"10\u6708", "\u32CA"=>"11\u6708", "\u32CB"=>"12\u6708", "\u32CC"=>"Hg", "\u32CD"=>"erg", "\u32CE"=>"eV",
+ "\u32CF"=>"LTD", "\u32D0"=>"\u30A2", "\u32D1"=>"\u30A4", "\u32D2"=>"\u30A6", "\u32D3"=>"\u30A8", "\u32D4"=>"\u30AA", "\u32D5"=>"\u30AB", "\u32D6"=>"\u30AD",
+ "\u32D7"=>"\u30AF", "\u32D8"=>"\u30B1", "\u32D9"=>"\u30B3", "\u32DA"=>"\u30B5", "\u32DB"=>"\u30B7", "\u32DC"=>"\u30B9", "\u32DD"=>"\u30BB", "\u32DE"=>"\u30BD",
+ "\u32DF"=>"\u30BF", "\u32E0"=>"\u30C1", "\u32E1"=>"\u30C4", "\u32E2"=>"\u30C6", "\u32E3"=>"\u30C8", "\u32E4"=>"\u30CA", "\u32E5"=>"\u30CB", "\u32E6"=>"\u30CC",
+ "\u32E7"=>"\u30CD", "\u32E8"=>"\u30CE", "\u32E9"=>"\u30CF", "\u32EA"=>"\u30D2", "\u32EB"=>"\u30D5", "\u32EC"=>"\u30D8", "\u32ED"=>"\u30DB", "\u32EE"=>"\u30DE",
+ "\u32EF"=>"\u30DF", "\u32F0"=>"\u30E0", "\u32F1"=>"\u30E1", "\u32F2"=>"\u30E2", "\u32F3"=>"\u30E4", "\u32F4"=>"\u30E6", "\u32F5"=>"\u30E8", "\u32F6"=>"\u30E9",
+ "\u32F7"=>"\u30EA", "\u32F8"=>"\u30EB", "\u32F9"=>"\u30EC", "\u32FA"=>"\u30ED", "\u32FB"=>"\u30EF", "\u32FC"=>"\u30F0", "\u32FD"=>"\u30F1", "\u32FE"=>"\u30F2",
+ "\u3300"=>"\u30A2\u30D1\u30FC\u30C8", "\u3301"=>"\u30A2\u30EB\u30D5\u30A1", "\u3302"=>"\u30A2\u30F3\u30DA\u30A2", "\u3303"=>"\u30A2\u30FC\u30EB", "\u3304"=>"\u30A4\u30CB\u30F3\u30B0", "\u3305"=>"\u30A4\u30F3\u30C1", "\u3306"=>"\u30A6\u30A9\u30F3", "\u3307"=>"\u30A8\u30B9\u30AF\u30FC\u30C9",
+ "\u3308"=>"\u30A8\u30FC\u30AB\u30FC", "\u3309"=>"\u30AA\u30F3\u30B9", "\u330A"=>"\u30AA\u30FC\u30E0", "\u330B"=>"\u30AB\u30A4\u30EA", "\u330C"=>"\u30AB\u30E9\u30C3\u30C8", "\u330D"=>"\u30AB\u30ED\u30EA\u30FC", "\u330E"=>"\u30AC\u30ED\u30F3", "\u330F"=>"\u30AC\u30F3\u30DE",
+ "\u3310"=>"\u30AE\u30AC", "\u3311"=>"\u30AE\u30CB\u30FC", "\u3312"=>"\u30AD\u30E5\u30EA\u30FC", "\u3313"=>"\u30AE\u30EB\u30C0\u30FC", "\u3314"=>"\u30AD\u30ED", "\u3315"=>"\u30AD\u30ED\u30B0\u30E9\u30E0", "\u3316"=>"\u30AD\u30ED\u30E1\u30FC\u30C8\u30EB", "\u3317"=>"\u30AD\u30ED\u30EF\u30C3\u30C8",
+ "\u3318"=>"\u30B0\u30E9\u30E0", "\u3319"=>"\u30B0\u30E9\u30E0\u30C8\u30F3", "\u331A"=>"\u30AF\u30EB\u30BC\u30A4\u30ED", "\u331B"=>"\u30AF\u30ED\u30FC\u30CD", "\u331C"=>"\u30B1\u30FC\u30B9", "\u331D"=>"\u30B3\u30EB\u30CA", "\u331E"=>"\u30B3\u30FC\u30DD", "\u331F"=>"\u30B5\u30A4\u30AF\u30EB",
+ "\u3320"=>"\u30B5\u30F3\u30C1\u30FC\u30E0", "\u3321"=>"\u30B7\u30EA\u30F3\u30B0", "\u3322"=>"\u30BB\u30F3\u30C1", "\u3323"=>"\u30BB\u30F3\u30C8", "\u3324"=>"\u30C0\u30FC\u30B9", "\u3325"=>"\u30C7\u30B7", "\u3326"=>"\u30C9\u30EB", "\u3327"=>"\u30C8\u30F3",
+ "\u3328"=>"\u30CA\u30CE", "\u3329"=>"\u30CE\u30C3\u30C8", "\u332A"=>"\u30CF\u30A4\u30C4", "\u332B"=>"\u30D1\u30FC\u30BB\u30F3\u30C8", "\u332C"=>"\u30D1\u30FC\u30C4", "\u332D"=>"\u30D0\u30FC\u30EC\u30EB", "\u332E"=>"\u30D4\u30A2\u30B9\u30C8\u30EB", "\u332F"=>"\u30D4\u30AF\u30EB",
+ "\u3330"=>"\u30D4\u30B3", "\u3331"=>"\u30D3\u30EB", "\u3332"=>"\u30D5\u30A1\u30E9\u30C3\u30C9", "\u3333"=>"\u30D5\u30A3\u30FC\u30C8", "\u3334"=>"\u30D6\u30C3\u30B7\u30A7\u30EB", "\u3335"=>"\u30D5\u30E9\u30F3", "\u3336"=>"\u30D8\u30AF\u30BF\u30FC\u30EB", "\u3337"=>"\u30DA\u30BD",
+ "\u3338"=>"\u30DA\u30CB\u30D2", "\u3339"=>"\u30D8\u30EB\u30C4", "\u333A"=>"\u30DA\u30F3\u30B9", "\u333B"=>"\u30DA\u30FC\u30B8", "\u333C"=>"\u30D9\u30FC\u30BF", "\u333D"=>"\u30DD\u30A4\u30F3\u30C8", "\u333E"=>"\u30DC\u30EB\u30C8", "\u333F"=>"\u30DB\u30F3",
+ "\u3340"=>"\u30DD\u30F3\u30C9", "\u3341"=>"\u30DB\u30FC\u30EB", "\u3342"=>"\u30DB\u30FC\u30F3", "\u3343"=>"\u30DE\u30A4\u30AF\u30ED", "\u3344"=>"\u30DE\u30A4\u30EB", "\u3345"=>"\u30DE\u30C3\u30CF", "\u3346"=>"\u30DE\u30EB\u30AF", "\u3347"=>"\u30DE\u30F3\u30B7\u30E7\u30F3",
+ "\u3348"=>"\u30DF\u30AF\u30ED\u30F3", "\u3349"=>"\u30DF\u30EA", "\u334A"=>"\u30DF\u30EA\u30D0\u30FC\u30EB", "\u334B"=>"\u30E1\u30AC", "\u334C"=>"\u30E1\u30AC\u30C8\u30F3", "\u334D"=>"\u30E1\u30FC\u30C8\u30EB", "\u334E"=>"\u30E4\u30FC\u30C9", "\u334F"=>"\u30E4\u30FC\u30EB",
+ "\u3350"=>"\u30E6\u30A2\u30F3", "\u3351"=>"\u30EA\u30C3\u30C8\u30EB", "\u3352"=>"\u30EA\u30E9", "\u3353"=>"\u30EB\u30D4\u30FC", "\u3354"=>"\u30EB\u30FC\u30D6\u30EB", "\u3355"=>"\u30EC\u30E0", "\u3356"=>"\u30EC\u30F3\u30C8\u30B2\u30F3", "\u3357"=>"\u30EF\u30C3\u30C8",
+ "\u3358"=>"0\u70B9", "\u3359"=>"1\u70B9", "\u335A"=>"2\u70B9", "\u335B"=>"3\u70B9", "\u335C"=>"4\u70B9", "\u335D"=>"5\u70B9", "\u335E"=>"6\u70B9", "\u335F"=>"7\u70B9",
+ "\u3360"=>"8\u70B9", "\u3361"=>"9\u70B9", "\u3362"=>"10\u70B9", "\u3363"=>"11\u70B9", "\u3364"=>"12\u70B9", "\u3365"=>"13\u70B9", "\u3366"=>"14\u70B9", "\u3367"=>"15\u70B9",
+ "\u3368"=>"16\u70B9", "\u3369"=>"17\u70B9", "\u336A"=>"18\u70B9", "\u336B"=>"19\u70B9", "\u336C"=>"20\u70B9", "\u336D"=>"21\u70B9", "\u336E"=>"22\u70B9", "\u336F"=>"23\u70B9",
+ "\u3370"=>"24\u70B9", "\u3371"=>"hPa", "\u3372"=>"da", "\u3373"=>"AU", "\u3374"=>"bar", "\u3375"=>"oV", "\u3376"=>"pc", "\u3377"=>"dm",
+ "\u3378"=>"dm2", "\u3379"=>"dm3", "\u337A"=>"IU", "\u337B"=>"\u5E73\u6210", "\u337C"=>"\u662D\u548C", "\u337D"=>"\u5927\u6B63", "\u337E"=>"\u660E\u6CBB", "\u337F"=>"\u682A\u5F0F\u4F1A\u793E",
+ "\u3380"=>"pA", "\u3381"=>"nA", "\u3382"=>"\u03BCA", "\u3383"=>"mA", "\u3384"=>"kA", "\u3385"=>"KB", "\u3386"=>"MB", "\u3387"=>"GB",
+ "\u3388"=>"cal", "\u3389"=>"kcal", "\u338A"=>"pF", "\u338B"=>"nF", "\u338C"=>"\u03BCF", "\u338D"=>"\u03BCg", "\u338E"=>"mg", "\u338F"=>"kg",
+ "\u3390"=>"Hz", "\u3391"=>"kHz", "\u3392"=>"MHz", "\u3393"=>"GHz", "\u3394"=>"THz", "\u3395"=>"\u03BCl", "\u3396"=>"ml", "\u3397"=>"dl",
+ "\u3398"=>"kl", "\u3399"=>"fm", "\u339A"=>"nm", "\u339B"=>"\u03BCm", "\u339C"=>"mm", "\u339D"=>"cm", "\u339E"=>"km", "\u339F"=>"mm2",
+ "\u33A0"=>"cm2", "\u33A1"=>"m2", "\u33A2"=>"km2", "\u33A3"=>"mm3", "\u33A4"=>"cm3", "\u33A5"=>"m3", "\u33A6"=>"km3", "\u33A7"=>"m\u2215s",
+ "\u33A8"=>"m\u2215s2", "\u33A9"=>"Pa", "\u33AA"=>"kPa", "\u33AB"=>"MPa", "\u33AC"=>"GPa", "\u33AD"=>"rad", "\u33AE"=>"rad\u2215s", "\u33AF"=>"rad\u2215s2",
+ "\u33B0"=>"ps", "\u33B1"=>"ns", "\u33B2"=>"\u03BCs", "\u33B3"=>"ms", "\u33B4"=>"pV", "\u33B5"=>"nV", "\u33B6"=>"\u03BCV", "\u33B7"=>"mV",
+ "\u33B8"=>"kV", "\u33B9"=>"MV", "\u33BA"=>"pW", "\u33BB"=>"nW", "\u33BC"=>"\u03BCW", "\u33BD"=>"mW", "\u33BE"=>"kW", "\u33BF"=>"MW",
+ "\u33C0"=>"k\u03A9", "\u33C1"=>"M\u03A9", "\u33C2"=>"a.m.", "\u33C3"=>"Bq", "\u33C4"=>"cc", "\u33C5"=>"cd", "\u33C6"=>"C\u2215kg", "\u33C7"=>"Co.",
+ "\u33C8"=>"dB", "\u33C9"=>"Gy", "\u33CA"=>"ha", "\u33CB"=>"HP", "\u33CC"=>"in", "\u33CD"=>"KK", "\u33CE"=>"KM", "\u33CF"=>"kt",
+ "\u33D0"=>"lm", "\u33D1"=>"ln", "\u33D2"=>"log", "\u33D3"=>"lx", "\u33D4"=>"mb", "\u33D5"=>"mil", "\u33D6"=>"mol", "\u33D7"=>"PH",
+ "\u33D8"=>"p.m.", "\u33D9"=>"PPM", "\u33DA"=>"PR", "\u33DB"=>"sr", "\u33DC"=>"Sv", "\u33DD"=>"Wb", "\u33DE"=>"V\u2215m", "\u33DF"=>"A\u2215m",
+ "\u33E0"=>"1\u65E5", "\u33E1"=>"2\u65E5", "\u33E2"=>"3\u65E5", "\u33E3"=>"4\u65E5", "\u33E4"=>"5\u65E5", "\u33E5"=>"6\u65E5", "\u33E6"=>"7\u65E5", "\u33E7"=>"8\u65E5",
+ "\u33E8"=>"9\u65E5", "\u33E9"=>"10\u65E5", "\u33EA"=>"11\u65E5", "\u33EB"=>"12\u65E5", "\u33EC"=>"13\u65E5", "\u33ED"=>"14\u65E5", "\u33EE"=>"15\u65E5", "\u33EF"=>"16\u65E5",
+ "\u33F0"=>"17\u65E5", "\u33F1"=>"18\u65E5", "\u33F2"=>"19\u65E5", "\u33F3"=>"20\u65E5", "\u33F4"=>"21\u65E5", "\u33F5"=>"22\u65E5", "\u33F6"=>"23\u65E5", "\u33F7"=>"24\u65E5",
+ "\u33F8"=>"25\u65E5", "\u33F9"=>"26\u65E5", "\u33FA"=>"27\u65E5", "\u33FB"=>"28\u65E5", "\u33FC"=>"29\u65E5", "\u33FD"=>"30\u65E5", "\u33FE"=>"31\u65E5", "\u33FF"=>"gal",
+ "\uA69C"=>"\u044A", "\uA69D"=>"\u044C", "\uA770"=>"\uA76F", "\uA7F8"=>"\u0126", "\uA7F9"=>"\u0153", "\uAB5C"=>"\uA727", "\uAB5D"=>"\uAB37", "\uAB5E"=>"\u026B",
+ "\uAB5F"=>"\uAB52", "\uFB00"=>"ff", "\uFB01"=>"fi", "\uFB02"=>"fl", "\uFB03"=>"ffi", "\uFB04"=>"ffl", "\uFB05"=>"st", "\uFB06"=>"st",
+ "\uFB13"=>"\u0574\u0576", "\uFB14"=>"\u0574\u0565", "\uFB15"=>"\u0574\u056B", "\uFB16"=>"\u057E\u0576", "\uFB17"=>"\u0574\u056D", "\uFB20"=>"\u05E2", "\uFB21"=>"\u05D0", "\uFB22"=>"\u05D3",
+ "\uFB23"=>"\u05D4", "\uFB24"=>"\u05DB", "\uFB25"=>"\u05DC", "\uFB26"=>"\u05DD", "\uFB27"=>"\u05E8", "\uFB28"=>"\u05EA", "\uFB29"=>"+", "\uFB4F"=>"\u05D0\u05DC",
+ "\uFB50"=>"\u0671", "\uFB51"=>"\u0671", "\uFB52"=>"\u067B", "\uFB53"=>"\u067B", "\uFB54"=>"\u067B", "\uFB55"=>"\u067B", "\uFB56"=>"\u067E", "\uFB57"=>"\u067E",
+ "\uFB58"=>"\u067E", "\uFB59"=>"\u067E", "\uFB5A"=>"\u0680", "\uFB5B"=>"\u0680", "\uFB5C"=>"\u0680", "\uFB5D"=>"\u0680", "\uFB5E"=>"\u067A", "\uFB5F"=>"\u067A",
+ "\uFB60"=>"\u067A", "\uFB61"=>"\u067A", "\uFB62"=>"\u067F", "\uFB63"=>"\u067F", "\uFB64"=>"\u067F", "\uFB65"=>"\u067F", "\uFB66"=>"\u0679", "\uFB67"=>"\u0679",
+ "\uFB68"=>"\u0679", "\uFB69"=>"\u0679", "\uFB6A"=>"\u06A4", "\uFB6B"=>"\u06A4", "\uFB6C"=>"\u06A4", "\uFB6D"=>"\u06A4", "\uFB6E"=>"\u06A6", "\uFB6F"=>"\u06A6",
+ "\uFB70"=>"\u06A6", "\uFB71"=>"\u06A6", "\uFB72"=>"\u0684", "\uFB73"=>"\u0684", "\uFB74"=>"\u0684", "\uFB75"=>"\u0684", "\uFB76"=>"\u0683", "\uFB77"=>"\u0683",
+ "\uFB78"=>"\u0683", "\uFB79"=>"\u0683", "\uFB7A"=>"\u0686", "\uFB7B"=>"\u0686", "\uFB7C"=>"\u0686", "\uFB7D"=>"\u0686", "\uFB7E"=>"\u0687", "\uFB7F"=>"\u0687",
+ "\uFB80"=>"\u0687", "\uFB81"=>"\u0687", "\uFB82"=>"\u068D", "\uFB83"=>"\u068D", "\uFB84"=>"\u068C", "\uFB85"=>"\u068C", "\uFB86"=>"\u068E", "\uFB87"=>"\u068E",
+ "\uFB88"=>"\u0688", "\uFB89"=>"\u0688", "\uFB8A"=>"\u0698", "\uFB8B"=>"\u0698", "\uFB8C"=>"\u0691", "\uFB8D"=>"\u0691", "\uFB8E"=>"\u06A9", "\uFB8F"=>"\u06A9",
+ "\uFB90"=>"\u06A9", "\uFB91"=>"\u06A9", "\uFB92"=>"\u06AF", "\uFB93"=>"\u06AF", "\uFB94"=>"\u06AF", "\uFB95"=>"\u06AF", "\uFB96"=>"\u06B3", "\uFB97"=>"\u06B3",
+ "\uFB98"=>"\u06B3", "\uFB99"=>"\u06B3", "\uFB9A"=>"\u06B1", "\uFB9B"=>"\u06B1", "\uFB9C"=>"\u06B1", "\uFB9D"=>"\u06B1", "\uFB9E"=>"\u06BA", "\uFB9F"=>"\u06BA",
+ "\uFBA0"=>"\u06BB", "\uFBA1"=>"\u06BB", "\uFBA2"=>"\u06BB", "\uFBA3"=>"\u06BB", "\uFBA4"=>"\u06C0", "\uFBA5"=>"\u06C0", "\uFBA6"=>"\u06C1", "\uFBA7"=>"\u06C1",
+ "\uFBA8"=>"\u06C1", "\uFBA9"=>"\u06C1", "\uFBAA"=>"\u06BE", "\uFBAB"=>"\u06BE", "\uFBAC"=>"\u06BE", "\uFBAD"=>"\u06BE", "\uFBAE"=>"\u06D2", "\uFBAF"=>"\u06D2",
+ "\uFBB0"=>"\u06D3", "\uFBB1"=>"\u06D3", "\uFBD3"=>"\u06AD", "\uFBD4"=>"\u06AD", "\uFBD5"=>"\u06AD", "\uFBD6"=>"\u06AD", "\uFBD7"=>"\u06C7", "\uFBD8"=>"\u06C7",
+ "\uFBD9"=>"\u06C6", "\uFBDA"=>"\u06C6", "\uFBDB"=>"\u06C8", "\uFBDC"=>"\u06C8", "\uFBDD"=>"\u06C7\u0674", "\uFBDE"=>"\u06CB", "\uFBDF"=>"\u06CB", "\uFBE0"=>"\u06C5",
+ "\uFBE1"=>"\u06C5", "\uFBE2"=>"\u06C9", "\uFBE3"=>"\u06C9", "\uFBE4"=>"\u06D0", "\uFBE5"=>"\u06D0", "\uFBE6"=>"\u06D0", "\uFBE7"=>"\u06D0", "\uFBE8"=>"\u0649",
+ "\uFBE9"=>"\u0649", "\uFBEA"=>"\u0626\u0627", "\uFBEB"=>"\u0626\u0627", "\uFBEC"=>"\u0626\u06D5", "\uFBED"=>"\u0626\u06D5", "\uFBEE"=>"\u0626\u0648", "\uFBEF"=>"\u0626\u0648", "\uFBF0"=>"\u0626\u06C7",
+ "\uFBF1"=>"\u0626\u06C7", "\uFBF2"=>"\u0626\u06C6", "\uFBF3"=>"\u0626\u06C6", "\uFBF4"=>"\u0626\u06C8", "\uFBF5"=>"\u0626\u06C8", "\uFBF6"=>"\u0626\u06D0", "\uFBF7"=>"\u0626\u06D0", "\uFBF8"=>"\u0626\u06D0",
+ "\uFBF9"=>"\u0626\u0649", "\uFBFA"=>"\u0626\u0649", "\uFBFB"=>"\u0626\u0649", "\uFBFC"=>"\u06CC", "\uFBFD"=>"\u06CC", "\uFBFE"=>"\u06CC", "\uFBFF"=>"\u06CC", "\uFC00"=>"\u0626\u062C",
+ "\uFC01"=>"\u0626\u062D", "\uFC02"=>"\u0626\u0645", "\uFC03"=>"\u0626\u0649", "\uFC04"=>"\u0626\u064A", "\uFC05"=>"\u0628\u062C", "\uFC06"=>"\u0628\u062D", "\uFC07"=>"\u0628\u062E", "\uFC08"=>"\u0628\u0645",
+ "\uFC09"=>"\u0628\u0649", "\uFC0A"=>"\u0628\u064A", "\uFC0B"=>"\u062A\u062C", "\uFC0C"=>"\u062A\u062D", "\uFC0D"=>"\u062A\u062E", "\uFC0E"=>"\u062A\u0645", "\uFC0F"=>"\u062A\u0649", "\uFC10"=>"\u062A\u064A",
+ "\uFC11"=>"\u062B\u062C", "\uFC12"=>"\u062B\u0645", "\uFC13"=>"\u062B\u0649", "\uFC14"=>"\u062B\u064A", "\uFC15"=>"\u062C\u062D", "\uFC16"=>"\u062C\u0645", "\uFC17"=>"\u062D\u062C", "\uFC18"=>"\u062D\u0645",
+ "\uFC19"=>"\u062E\u062C", "\uFC1A"=>"\u062E\u062D", "\uFC1B"=>"\u062E\u0645", "\uFC1C"=>"\u0633\u062C", "\uFC1D"=>"\u0633\u062D", "\uFC1E"=>"\u0633\u062E", "\uFC1F"=>"\u0633\u0645", "\uFC20"=>"\u0635\u062D",
+ "\uFC21"=>"\u0635\u0645", "\uFC22"=>"\u0636\u062C", "\uFC23"=>"\u0636\u062D", "\uFC24"=>"\u0636\u062E", "\uFC25"=>"\u0636\u0645", "\uFC26"=>"\u0637\u062D", "\uFC27"=>"\u0637\u0645", "\uFC28"=>"\u0638\u0645",
+ "\uFC29"=>"\u0639\u062C", "\uFC2A"=>"\u0639\u0645", "\uFC2B"=>"\u063A\u062C", "\uFC2C"=>"\u063A\u0645", "\uFC2D"=>"\u0641\u062C", "\uFC2E"=>"\u0641\u062D", "\uFC2F"=>"\u0641\u062E", "\uFC30"=>"\u0641\u0645",
+ "\uFC31"=>"\u0641\u0649", "\uFC32"=>"\u0641\u064A", "\uFC33"=>"\u0642\u062D", "\uFC34"=>"\u0642\u0645", "\uFC35"=>"\u0642\u0649", "\uFC36"=>"\u0642\u064A", "\uFC37"=>"\u0643\u0627", "\uFC38"=>"\u0643\u062C",
+ "\uFC39"=>"\u0643\u062D", "\uFC3A"=>"\u0643\u062E", "\uFC3B"=>"\u0643\u0644", "\uFC3C"=>"\u0643\u0645", "\uFC3D"=>"\u0643\u0649", "\uFC3E"=>"\u0643\u064A", "\uFC3F"=>"\u0644\u062C", "\uFC40"=>"\u0644\u062D",
+ "\uFC41"=>"\u0644\u062E", "\uFC42"=>"\u0644\u0645", "\uFC43"=>"\u0644\u0649", "\uFC44"=>"\u0644\u064A", "\uFC45"=>"\u0645\u062C", "\uFC46"=>"\u0645\u062D", "\uFC47"=>"\u0645\u062E", "\uFC48"=>"\u0645\u0645",
+ "\uFC49"=>"\u0645\u0649", "\uFC4A"=>"\u0645\u064A", "\uFC4B"=>"\u0646\u062C", "\uFC4C"=>"\u0646\u062D", "\uFC4D"=>"\u0646\u062E", "\uFC4E"=>"\u0646\u0645", "\uFC4F"=>"\u0646\u0649", "\uFC50"=>"\u0646\u064A",
+ "\uFC51"=>"\u0647\u062C", "\uFC52"=>"\u0647\u0645", "\uFC53"=>"\u0647\u0649", "\uFC54"=>"\u0647\u064A", "\uFC55"=>"\u064A\u062C", "\uFC56"=>"\u064A\u062D", "\uFC57"=>"\u064A\u062E", "\uFC58"=>"\u064A\u0645",
+ "\uFC59"=>"\u064A\u0649", "\uFC5A"=>"\u064A\u064A", "\uFC5B"=>"\u0630\u0670", "\uFC5C"=>"\u0631\u0670", "\uFC5D"=>"\u0649\u0670", "\uFC5E"=>" \u064C\u0651", "\uFC5F"=>" \u064D\u0651", "\uFC60"=>" \u064E\u0651",
+ "\uFC61"=>" \u064F\u0651", "\uFC62"=>" \u0650\u0651", "\uFC63"=>" \u0651\u0670", "\uFC64"=>"\u0626\u0631", "\uFC65"=>"\u0626\u0632", "\uFC66"=>"\u0626\u0645", "\uFC67"=>"\u0626\u0646", "\uFC68"=>"\u0626\u0649",
+ "\uFC69"=>"\u0626\u064A", "\uFC6A"=>"\u0628\u0631", "\uFC6B"=>"\u0628\u0632", "\uFC6C"=>"\u0628\u0645", "\uFC6D"=>"\u0628\u0646", "\uFC6E"=>"\u0628\u0649", "\uFC6F"=>"\u0628\u064A", "\uFC70"=>"\u062A\u0631",
+ "\uFC71"=>"\u062A\u0632", "\uFC72"=>"\u062A\u0645", "\uFC73"=>"\u062A\u0646", "\uFC74"=>"\u062A\u0649", "\uFC75"=>"\u062A\u064A", "\uFC76"=>"\u062B\u0631", "\uFC77"=>"\u062B\u0632", "\uFC78"=>"\u062B\u0645",
+ "\uFC79"=>"\u062B\u0646", "\uFC7A"=>"\u062B\u0649", "\uFC7B"=>"\u062B\u064A", "\uFC7C"=>"\u0641\u0649", "\uFC7D"=>"\u0641\u064A", "\uFC7E"=>"\u0642\u0649", "\uFC7F"=>"\u0642\u064A", "\uFC80"=>"\u0643\u0627",
+ "\uFC81"=>"\u0643\u0644", "\uFC82"=>"\u0643\u0645", "\uFC83"=>"\u0643\u0649", "\uFC84"=>"\u0643\u064A", "\uFC85"=>"\u0644\u0645", "\uFC86"=>"\u0644\u0649", "\uFC87"=>"\u0644\u064A", "\uFC88"=>"\u0645\u0627",
+ "\uFC89"=>"\u0645\u0645", "\uFC8A"=>"\u0646\u0631", "\uFC8B"=>"\u0646\u0632", "\uFC8C"=>"\u0646\u0645", "\uFC8D"=>"\u0646\u0646", "\uFC8E"=>"\u0646\u0649", "\uFC8F"=>"\u0646\u064A", "\uFC90"=>"\u0649\u0670",
+ "\uFC91"=>"\u064A\u0631", "\uFC92"=>"\u064A\u0632", "\uFC93"=>"\u064A\u0645", "\uFC94"=>"\u064A\u0646", "\uFC95"=>"\u064A\u0649", "\uFC96"=>"\u064A\u064A", "\uFC97"=>"\u0626\u062C", "\uFC98"=>"\u0626\u062D",
+ "\uFC99"=>"\u0626\u062E", "\uFC9A"=>"\u0626\u0645", "\uFC9B"=>"\u0626\u0647", "\uFC9C"=>"\u0628\u062C", "\uFC9D"=>"\u0628\u062D", "\uFC9E"=>"\u0628\u062E", "\uFC9F"=>"\u0628\u0645", "\uFCA0"=>"\u0628\u0647",
+ "\uFCA1"=>"\u062A\u062C", "\uFCA2"=>"\u062A\u062D", "\uFCA3"=>"\u062A\u062E", "\uFCA4"=>"\u062A\u0645", "\uFCA5"=>"\u062A\u0647", "\uFCA6"=>"\u062B\u0645", "\uFCA7"=>"\u062C\u062D", "\uFCA8"=>"\u062C\u0645",
+ "\uFCA9"=>"\u062D\u062C", "\uFCAA"=>"\u062D\u0645", "\uFCAB"=>"\u062E\u062C", "\uFCAC"=>"\u062E\u0645", "\uFCAD"=>"\u0633\u062C", "\uFCAE"=>"\u0633\u062D", "\uFCAF"=>"\u0633\u062E", "\uFCB0"=>"\u0633\u0645",
+ "\uFCB1"=>"\u0635\u062D", "\uFCB2"=>"\u0635\u062E", "\uFCB3"=>"\u0635\u0645", "\uFCB4"=>"\u0636\u062C", "\uFCB5"=>"\u0636\u062D", "\uFCB6"=>"\u0636\u062E", "\uFCB7"=>"\u0636\u0645", "\uFCB8"=>"\u0637\u062D",
+ "\uFCB9"=>"\u0638\u0645", "\uFCBA"=>"\u0639\u062C", "\uFCBB"=>"\u0639\u0645", "\uFCBC"=>"\u063A\u062C", "\uFCBD"=>"\u063A\u0645", "\uFCBE"=>"\u0641\u062C", "\uFCBF"=>"\u0641\u062D", "\uFCC0"=>"\u0641\u062E",
+ "\uFCC1"=>"\u0641\u0645", "\uFCC2"=>"\u0642\u062D", "\uFCC3"=>"\u0642\u0645", "\uFCC4"=>"\u0643\u062C", "\uFCC5"=>"\u0643\u062D", "\uFCC6"=>"\u0643\u062E", "\uFCC7"=>"\u0643\u0644", "\uFCC8"=>"\u0643\u0645",
+ "\uFCC9"=>"\u0644\u062C", "\uFCCA"=>"\u0644\u062D", "\uFCCB"=>"\u0644\u062E", "\uFCCC"=>"\u0644\u0645", "\uFCCD"=>"\u0644\u0647", "\uFCCE"=>"\u0645\u062C", "\uFCCF"=>"\u0645\u062D", "\uFCD0"=>"\u0645\u062E",
+ "\uFCD1"=>"\u0645\u0645", "\uFCD2"=>"\u0646\u062C", "\uFCD3"=>"\u0646\u062D", "\uFCD4"=>"\u0646\u062E", "\uFCD5"=>"\u0646\u0645", "\uFCD6"=>"\u0646\u0647", "\uFCD7"=>"\u0647\u062C", "\uFCD8"=>"\u0647\u0645",
+ "\uFCD9"=>"\u0647\u0670", "\uFCDA"=>"\u064A\u062C", "\uFCDB"=>"\u064A\u062D", "\uFCDC"=>"\u064A\u062E", "\uFCDD"=>"\u064A\u0645", "\uFCDE"=>"\u064A\u0647", "\uFCDF"=>"\u0626\u0645", "\uFCE0"=>"\u0626\u0647",
+ "\uFCE1"=>"\u0628\u0645", "\uFCE2"=>"\u0628\u0647", "\uFCE3"=>"\u062A\u0645", "\uFCE4"=>"\u062A\u0647", "\uFCE5"=>"\u062B\u0645", "\uFCE6"=>"\u062B\u0647", "\uFCE7"=>"\u0633\u0645", "\uFCE8"=>"\u0633\u0647",
+ "\uFCE9"=>"\u0634\u0645", "\uFCEA"=>"\u0634\u0647", "\uFCEB"=>"\u0643\u0644", "\uFCEC"=>"\u0643\u0645", "\uFCED"=>"\u0644\u0645", "\uFCEE"=>"\u0646\u0645", "\uFCEF"=>"\u0646\u0647", "\uFCF0"=>"\u064A\u0645",
+ "\uFCF1"=>"\u064A\u0647", "\uFCF2"=>"\u0640\u064E\u0651", "\uFCF3"=>"\u0640\u064F\u0651", "\uFCF4"=>"\u0640\u0650\u0651", "\uFCF5"=>"\u0637\u0649", "\uFCF6"=>"\u0637\u064A", "\uFCF7"=>"\u0639\u0649", "\uFCF8"=>"\u0639\u064A",
+ "\uFCF9"=>"\u063A\u0649", "\uFCFA"=>"\u063A\u064A", "\uFCFB"=>"\u0633\u0649", "\uFCFC"=>"\u0633\u064A", "\uFCFD"=>"\u0634\u0649", "\uFCFE"=>"\u0634\u064A", "\uFCFF"=>"\u062D\u0649", "\uFD00"=>"\u062D\u064A",
+ "\uFD01"=>"\u062C\u0649", "\uFD02"=>"\u062C\u064A", "\uFD03"=>"\u062E\u0649", "\uFD04"=>"\u062E\u064A", "\uFD05"=>"\u0635\u0649", "\uFD06"=>"\u0635\u064A", "\uFD07"=>"\u0636\u0649", "\uFD08"=>"\u0636\u064A",
+ "\uFD09"=>"\u0634\u062C", "\uFD0A"=>"\u0634\u062D", "\uFD0B"=>"\u0634\u062E", "\uFD0C"=>"\u0634\u0645", "\uFD0D"=>"\u0634\u0631", "\uFD0E"=>"\u0633\u0631", "\uFD0F"=>"\u0635\u0631", "\uFD10"=>"\u0636\u0631",
+ "\uFD11"=>"\u0637\u0649", "\uFD12"=>"\u0637\u064A", "\uFD13"=>"\u0639\u0649", "\uFD14"=>"\u0639\u064A", "\uFD15"=>"\u063A\u0649", "\uFD16"=>"\u063A\u064A", "\uFD17"=>"\u0633\u0649", "\uFD18"=>"\u0633\u064A",
+ "\uFD19"=>"\u0634\u0649", "\uFD1A"=>"\u0634\u064A", "\uFD1B"=>"\u062D\u0649", "\uFD1C"=>"\u062D\u064A", "\uFD1D"=>"\u062C\u0649", "\uFD1E"=>"\u062C\u064A", "\uFD1F"=>"\u062E\u0649", "\uFD20"=>"\u062E\u064A",
+ "\uFD21"=>"\u0635\u0649", "\uFD22"=>"\u0635\u064A", "\uFD23"=>"\u0636\u0649", "\uFD24"=>"\u0636\u064A", "\uFD25"=>"\u0634\u062C", "\uFD26"=>"\u0634\u062D", "\uFD27"=>"\u0634\u062E", "\uFD28"=>"\u0634\u0645",
+ "\uFD29"=>"\u0634\u0631", "\uFD2A"=>"\u0633\u0631", "\uFD2B"=>"\u0635\u0631", "\uFD2C"=>"\u0636\u0631", "\uFD2D"=>"\u0634\u062C", "\uFD2E"=>"\u0634\u062D", "\uFD2F"=>"\u0634\u062E", "\uFD30"=>"\u0634\u0645",
+ "\uFD31"=>"\u0633\u0647", "\uFD32"=>"\u0634\u0647", "\uFD33"=>"\u0637\u0645", "\uFD34"=>"\u0633\u062C", "\uFD35"=>"\u0633\u062D", "\uFD36"=>"\u0633\u062E", "\uFD37"=>"\u0634\u062C", "\uFD38"=>"\u0634\u062D",
+ "\uFD39"=>"\u0634\u062E", "\uFD3A"=>"\u0637\u0645", "\uFD3B"=>"\u0638\u0645", "\uFD3C"=>"\u0627\u064B", "\uFD3D"=>"\u0627\u064B", "\uFD50"=>"\u062A\u062C\u0645", "\uFD51"=>"\u062A\u062D\u062C", "\uFD52"=>"\u062A\u062D\u062C",
+ "\uFD53"=>"\u062A\u062D\u0645", "\uFD54"=>"\u062A\u062E\u0645", "\uFD55"=>"\u062A\u0645\u062C", "\uFD56"=>"\u062A\u0645\u062D", "\uFD57"=>"\u062A\u0645\u062E", "\uFD58"=>"\u062C\u0645\u062D", "\uFD59"=>"\u062C\u0645\u062D", "\uFD5A"=>"\u062D\u0645\u064A",
+ "\uFD5B"=>"\u062D\u0645\u0649", "\uFD5C"=>"\u0633\u062D\u062C", "\uFD5D"=>"\u0633\u062C\u062D", "\uFD5E"=>"\u0633\u062C\u0649", "\uFD5F"=>"\u0633\u0645\u062D", "\uFD60"=>"\u0633\u0645\u062D", "\uFD61"=>"\u0633\u0645\u062C", "\uFD62"=>"\u0633\u0645\u0645",
+ "\uFD63"=>"\u0633\u0645\u0645", "\uFD64"=>"\u0635\u062D\u062D", "\uFD65"=>"\u0635\u062D\u062D", "\uFD66"=>"\u0635\u0645\u0645", "\uFD67"=>"\u0634\u062D\u0645", "\uFD68"=>"\u0634\u062D\u0645", "\uFD69"=>"\u0634\u062C\u064A", "\uFD6A"=>"\u0634\u0645\u062E",
+ "\uFD6B"=>"\u0634\u0645\u062E", "\uFD6C"=>"\u0634\u0645\u0645", "\uFD6D"=>"\u0634\u0645\u0645", "\uFD6E"=>"\u0636\u062D\u0649", "\uFD6F"=>"\u0636\u062E\u0645", "\uFD70"=>"\u0636\u062E\u0645", "\uFD71"=>"\u0637\u0645\u062D", "\uFD72"=>"\u0637\u0645\u062D",
+ "\uFD73"=>"\u0637\u0645\u0645", "\uFD74"=>"\u0637\u0645\u064A", "\uFD75"=>"\u0639\u062C\u0645", "\uFD76"=>"\u0639\u0645\u0645", "\uFD77"=>"\u0639\u0645\u0645", "\uFD78"=>"\u0639\u0645\u0649", "\uFD79"=>"\u063A\u0645\u0645", "\uFD7A"=>"\u063A\u0645\u064A",
+ "\uFD7B"=>"\u063A\u0645\u0649", "\uFD7C"=>"\u0641\u062E\u0645", "\uFD7D"=>"\u0641\u062E\u0645", "\uFD7E"=>"\u0642\u0645\u062D", "\uFD7F"=>"\u0642\u0645\u0645", "\uFD80"=>"\u0644\u062D\u0645", "\uFD81"=>"\u0644\u062D\u064A", "\uFD82"=>"\u0644\u062D\u0649",
+ "\uFD83"=>"\u0644\u062C\u062C", "\uFD84"=>"\u0644\u062C\u062C", "\uFD85"=>"\u0644\u062E\u0645", "\uFD86"=>"\u0644\u062E\u0645", "\uFD87"=>"\u0644\u0645\u062D", "\uFD88"=>"\u0644\u0645\u062D", "\uFD89"=>"\u0645\u062D\u062C", "\uFD8A"=>"\u0645\u062D\u0645",
+ "\uFD8B"=>"\u0645\u062D\u064A", "\uFD8C"=>"\u0645\u062C\u062D", "\uFD8D"=>"\u0645\u062C\u0645", "\uFD8E"=>"\u0645\u062E\u062C", "\uFD8F"=>"\u0645\u062E\u0645", "\uFD92"=>"\u0645\u062C\u062E", "\uFD93"=>"\u0647\u0645\u062C", "\uFD94"=>"\u0647\u0645\u0645",
+ "\uFD95"=>"\u0646\u062D\u0645", "\uFD96"=>"\u0646\u062D\u0649", "\uFD97"=>"\u0646\u062C\u0645", "\uFD98"=>"\u0646\u062C\u0645", "\uFD99"=>"\u0646\u062C\u0649", "\uFD9A"=>"\u0646\u0645\u064A", "\uFD9B"=>"\u0646\u0645\u0649", "\uFD9C"=>"\u064A\u0645\u0645",
+ "\uFD9D"=>"\u064A\u0645\u0645", "\uFD9E"=>"\u0628\u062E\u064A", "\uFD9F"=>"\u062A\u062C\u064A", "\uFDA0"=>"\u062A\u062C\u0649", "\uFDA1"=>"\u062A\u062E\u064A", "\uFDA2"=>"\u062A\u062E\u0649", "\uFDA3"=>"\u062A\u0645\u064A", "\uFDA4"=>"\u062A\u0645\u0649",
+ "\uFDA5"=>"\u062C\u0645\u064A", "\uFDA6"=>"\u062C\u062D\u0649", "\uFDA7"=>"\u062C\u0645\u0649", "\uFDA8"=>"\u0633\u062E\u0649", "\uFDA9"=>"\u0635\u062D\u064A", "\uFDAA"=>"\u0634\u062D\u064A", "\uFDAB"=>"\u0636\u062D\u064A", "\uFDAC"=>"\u0644\u062C\u064A",
+ "\uFDAD"=>"\u0644\u0645\u064A", "\uFDAE"=>"\u064A\u062D\u064A", "\uFDAF"=>"\u064A\u062C\u064A", "\uFDB0"=>"\u064A\u0645\u064A", "\uFDB1"=>"\u0645\u0645\u064A", "\uFDB2"=>"\u0642\u0645\u064A", "\uFDB3"=>"\u0646\u062D\u064A", "\uFDB4"=>"\u0642\u0645\u062D",
+ "\uFDB5"=>"\u0644\u062D\u0645", "\uFDB6"=>"\u0639\u0645\u064A", "\uFDB7"=>"\u0643\u0645\u064A", "\uFDB8"=>"\u0646\u062C\u062D", "\uFDB9"=>"\u0645\u062E\u064A", "\uFDBA"=>"\u0644\u062C\u0645", "\uFDBB"=>"\u0643\u0645\u0645", "\uFDBC"=>"\u0644\u062C\u0645",
+ "\uFDBD"=>"\u0646\u062C\u062D", "\uFDBE"=>"\u062C\u062D\u064A", "\uFDBF"=>"\u062D\u062C\u064A", "\uFDC0"=>"\u0645\u062C\u064A", "\uFDC1"=>"\u0641\u0645\u064A", "\uFDC2"=>"\u0628\u062D\u064A", "\uFDC3"=>"\u0643\u0645\u0645", "\uFDC4"=>"\u0639\u062C\u0645",
+ "\uFDC5"=>"\u0635\u0645\u0645", "\uFDC6"=>"\u0633\u062E\u064A", "\uFDC7"=>"\u0646\u062C\u064A", "\uFDF0"=>"\u0635\u0644\u06D2", "\uFDF1"=>"\u0642\u0644\u06D2", "\uFDF2"=>"\u0627\u0644\u0644\u0647", "\uFDF3"=>"\u0627\u0643\u0628\u0631", "\uFDF4"=>"\u0645\u062D\u0645\u062F",
+ "\uFDF5"=>"\u0635\u0644\u0639\u0645", "\uFDF6"=>"\u0631\u0633\u0648\u0644", "\uFDF7"=>"\u0639\u0644\u064A\u0647", "\uFDF8"=>"\u0648\u0633\u0644\u0645", "\uFDF9"=>"\u0635\u0644\u0649", "\uFDFA"=>"\u0635\u0644\u0649 \u0627\u0644\u0644\u0647 \u0639\u0644\u064A\u0647 \u0648\u0633\u0644\u0645", "\uFDFB"=>"\u062C\u0644 \u062C\u0644\u0627\u0644\u0647", "\uFDFC"=>"\u0631\u06CC\u0627\u0644",
+ "\uFE10"=>",", "\uFE11"=>"\u3001", "\uFE12"=>"\u3002", "\uFE13"=>":", "\uFE14"=>";", "\uFE15"=>"!", "\uFE16"=>"?", "\uFE17"=>"\u3016",
+ "\uFE18"=>"\u3017", "\uFE19"=>"...", "\uFE30"=>"..", "\uFE31"=>"\u2014", "\uFE32"=>"\u2013", "\uFE33"=>"_", "\uFE34"=>"_", "\uFE35"=>"(",
+ "\uFE36"=>")", "\uFE37"=>"{", "\uFE38"=>"}", "\uFE39"=>"\u3014", "\uFE3A"=>"\u3015", "\uFE3B"=>"\u3010", "\uFE3C"=>"\u3011", "\uFE3D"=>"\u300A",
+ "\uFE3E"=>"\u300B", "\uFE3F"=>"\u3008", "\uFE40"=>"\u3009", "\uFE41"=>"\u300C", "\uFE42"=>"\u300D", "\uFE43"=>"\u300E", "\uFE44"=>"\u300F", "\uFE47"=>"[",
+ "\uFE48"=>"]", "\uFE49"=>" \u0305", "\uFE4A"=>" \u0305", "\uFE4B"=>" \u0305", "\uFE4C"=>" \u0305", "\uFE4D"=>"_", "\uFE4E"=>"_", "\uFE4F"=>"_",
+ "\uFE50"=>",", "\uFE51"=>"\u3001", "\uFE52"=>".", "\uFE54"=>";", "\uFE55"=>":", "\uFE56"=>"?", "\uFE57"=>"!", "\uFE58"=>"\u2014",
+ "\uFE59"=>"(", "\uFE5A"=>")", "\uFE5B"=>"{", "\uFE5C"=>"}", "\uFE5D"=>"\u3014", "\uFE5E"=>"\u3015", "\uFE5F"=>"#", "\uFE60"=>"&",
+ "\uFE61"=>"*", "\uFE62"=>"+", "\uFE63"=>"-", "\uFE64"=>"<", "\uFE65"=>">", "\uFE66"=>"=", "\uFE68"=>"\\", "\uFE69"=>"$",
+ "\uFE6A"=>"%", "\uFE6B"=>"@", "\uFE70"=>" \u064B", "\uFE71"=>"\u0640\u064B", "\uFE72"=>" \u064C", "\uFE74"=>" \u064D", "\uFE76"=>" \u064E", "\uFE77"=>"\u0640\u064E",
+ "\uFE78"=>" \u064F", "\uFE79"=>"\u0640\u064F", "\uFE7A"=>" \u0650", "\uFE7B"=>"\u0640\u0650", "\uFE7C"=>" \u0651", "\uFE7D"=>"\u0640\u0651", "\uFE7E"=>" \u0652", "\uFE7F"=>"\u0640\u0652",
+ "\uFE80"=>"\u0621", "\uFE81"=>"\u0622", "\uFE82"=>"\u0622", "\uFE83"=>"\u0623", "\uFE84"=>"\u0623", "\uFE85"=>"\u0624", "\uFE86"=>"\u0624", "\uFE87"=>"\u0625",
+ "\uFE88"=>"\u0625", "\uFE89"=>"\u0626", "\uFE8A"=>"\u0626", "\uFE8B"=>"\u0626", "\uFE8C"=>"\u0626", "\uFE8D"=>"\u0627", "\uFE8E"=>"\u0627", "\uFE8F"=>"\u0628",
+ "\uFE90"=>"\u0628", "\uFE91"=>"\u0628", "\uFE92"=>"\u0628", "\uFE93"=>"\u0629", "\uFE94"=>"\u0629", "\uFE95"=>"\u062A", "\uFE96"=>"\u062A", "\uFE97"=>"\u062A",
+ "\uFE98"=>"\u062A", "\uFE99"=>"\u062B", "\uFE9A"=>"\u062B", "\uFE9B"=>"\u062B", "\uFE9C"=>"\u062B", "\uFE9D"=>"\u062C", "\uFE9E"=>"\u062C", "\uFE9F"=>"\u062C",
+ "\uFEA0"=>"\u062C", "\uFEA1"=>"\u062D", "\uFEA2"=>"\u062D", "\uFEA3"=>"\u062D", "\uFEA4"=>"\u062D", "\uFEA5"=>"\u062E", "\uFEA6"=>"\u062E", "\uFEA7"=>"\u062E",
+ "\uFEA8"=>"\u062E", "\uFEA9"=>"\u062F", "\uFEAA"=>"\u062F", "\uFEAB"=>"\u0630", "\uFEAC"=>"\u0630", "\uFEAD"=>"\u0631", "\uFEAE"=>"\u0631", "\uFEAF"=>"\u0632",
+ "\uFEB0"=>"\u0632", "\uFEB1"=>"\u0633", "\uFEB2"=>"\u0633", "\uFEB3"=>"\u0633", "\uFEB4"=>"\u0633", "\uFEB5"=>"\u0634", "\uFEB6"=>"\u0634", "\uFEB7"=>"\u0634",
+ "\uFEB8"=>"\u0634", "\uFEB9"=>"\u0635", "\uFEBA"=>"\u0635", "\uFEBB"=>"\u0635", "\uFEBC"=>"\u0635", "\uFEBD"=>"\u0636", "\uFEBE"=>"\u0636", "\uFEBF"=>"\u0636",
+ "\uFEC0"=>"\u0636", "\uFEC1"=>"\u0637", "\uFEC2"=>"\u0637", "\uFEC3"=>"\u0637", "\uFEC4"=>"\u0637", "\uFEC5"=>"\u0638", "\uFEC6"=>"\u0638", "\uFEC7"=>"\u0638",
+ "\uFEC8"=>"\u0638", "\uFEC9"=>"\u0639", "\uFECA"=>"\u0639", "\uFECB"=>"\u0639", "\uFECC"=>"\u0639", "\uFECD"=>"\u063A", "\uFECE"=>"\u063A", "\uFECF"=>"\u063A",
+ "\uFED0"=>"\u063A", "\uFED1"=>"\u0641", "\uFED2"=>"\u0641", "\uFED3"=>"\u0641", "\uFED4"=>"\u0641", "\uFED5"=>"\u0642", "\uFED6"=>"\u0642", "\uFED7"=>"\u0642",
+ "\uFED8"=>"\u0642", "\uFED9"=>"\u0643", "\uFEDA"=>"\u0643", "\uFEDB"=>"\u0643", "\uFEDC"=>"\u0643", "\uFEDD"=>"\u0644", "\uFEDE"=>"\u0644", "\uFEDF"=>"\u0644",
+ "\uFEE0"=>"\u0644", "\uFEE1"=>"\u0645", "\uFEE2"=>"\u0645", "\uFEE3"=>"\u0645", "\uFEE4"=>"\u0645", "\uFEE5"=>"\u0646", "\uFEE6"=>"\u0646", "\uFEE7"=>"\u0646",
+ "\uFEE8"=>"\u0646", "\uFEE9"=>"\u0647", "\uFEEA"=>"\u0647", "\uFEEB"=>"\u0647", "\uFEEC"=>"\u0647", "\uFEED"=>"\u0648", "\uFEEE"=>"\u0648", "\uFEEF"=>"\u0649",
+ "\uFEF0"=>"\u0649", "\uFEF1"=>"\u064A", "\uFEF2"=>"\u064A", "\uFEF3"=>"\u064A", "\uFEF4"=>"\u064A", "\uFEF5"=>"\u0644\u0622", "\uFEF6"=>"\u0644\u0622", "\uFEF7"=>"\u0644\u0623",
+ "\uFEF8"=>"\u0644\u0623", "\uFEF9"=>"\u0644\u0625", "\uFEFA"=>"\u0644\u0625", "\uFEFB"=>"\u0644\u0627", "\uFEFC"=>"\u0644\u0627", "\uFF01"=>"!", "\uFF02"=>"\"", "\uFF03"=>"#",
+ "\uFF04"=>"$", "\uFF05"=>"%", "\uFF06"=>"&", "\uFF07"=>"'", "\uFF08"=>"(", "\uFF09"=>")", "\uFF0A"=>"*", "\uFF0B"=>"+",
+ "\uFF0C"=>",", "\uFF0D"=>"-", "\uFF0E"=>".", "\uFF0F"=>"/", "\uFF10"=>"0", "\uFF11"=>"1", "\uFF12"=>"2", "\uFF13"=>"3",
+ "\uFF14"=>"4", "\uFF15"=>"5", "\uFF16"=>"6", "\uFF17"=>"7", "\uFF18"=>"8", "\uFF19"=>"9", "\uFF1A"=>":", "\uFF1B"=>";",
+ "\uFF1C"=>"<", "\uFF1D"=>"=", "\uFF1E"=>">", "\uFF1F"=>"?", "\uFF20"=>"@", "\uFF21"=>"A", "\uFF22"=>"B", "\uFF23"=>"C",
+ "\uFF24"=>"D", "\uFF25"=>"E", "\uFF26"=>"F", "\uFF27"=>"G", "\uFF28"=>"H", "\uFF29"=>"I", "\uFF2A"=>"J", "\uFF2B"=>"K",
+ "\uFF2C"=>"L", "\uFF2D"=>"M", "\uFF2E"=>"N", "\uFF2F"=>"O", "\uFF30"=>"P", "\uFF31"=>"Q", "\uFF32"=>"R", "\uFF33"=>"S",
+ "\uFF34"=>"T", "\uFF35"=>"U", "\uFF36"=>"V", "\uFF37"=>"W", "\uFF38"=>"X", "\uFF39"=>"Y", "\uFF3A"=>"Z", "\uFF3B"=>"[",
+ "\uFF3C"=>"\\", "\uFF3D"=>"]", "\uFF3E"=>"^", "\uFF3F"=>"_", "\uFF40"=>"`", "\uFF41"=>"a", "\uFF42"=>"b", "\uFF43"=>"c",
+ "\uFF44"=>"d", "\uFF45"=>"e", "\uFF46"=>"f", "\uFF47"=>"g", "\uFF48"=>"h", "\uFF49"=>"i", "\uFF4A"=>"j", "\uFF4B"=>"k",
+ "\uFF4C"=>"l", "\uFF4D"=>"m", "\uFF4E"=>"n", "\uFF4F"=>"o", "\uFF50"=>"p", "\uFF51"=>"q", "\uFF52"=>"r", "\uFF53"=>"s",
+ "\uFF54"=>"t", "\uFF55"=>"u", "\uFF56"=>"v", "\uFF57"=>"w", "\uFF58"=>"x", "\uFF59"=>"y", "\uFF5A"=>"z", "\uFF5B"=>"{",
+ "\uFF5C"=>"|", "\uFF5D"=>"}", "\uFF5E"=>"~", "\uFF5F"=>"\u2985", "\uFF60"=>"\u2986", "\uFF61"=>"\u3002", "\uFF62"=>"\u300C", "\uFF63"=>"\u300D",
+ "\uFF64"=>"\u3001", "\uFF65"=>"\u30FB", "\uFF66"=>"\u30F2", "\uFF67"=>"\u30A1", "\uFF68"=>"\u30A3", "\uFF69"=>"\u30A5", "\uFF6A"=>"\u30A7", "\uFF6B"=>"\u30A9",
+ "\uFF6C"=>"\u30E3", "\uFF6D"=>"\u30E5", "\uFF6E"=>"\u30E7", "\uFF6F"=>"\u30C3", "\uFF70"=>"\u30FC", "\uFF71"=>"\u30A2", "\uFF72"=>"\u30A4", "\uFF73"=>"\u30A6",
+ "\uFF74"=>"\u30A8", "\uFF75"=>"\u30AA", "\uFF76"=>"\u30AB", "\uFF77"=>"\u30AD", "\uFF78"=>"\u30AF", "\uFF79"=>"\u30B1", "\uFF7A"=>"\u30B3", "\uFF7B"=>"\u30B5",
+ "\uFF7C"=>"\u30B7", "\uFF7D"=>"\u30B9", "\uFF7E"=>"\u30BB", "\uFF7F"=>"\u30BD", "\uFF80"=>"\u30BF", "\uFF81"=>"\u30C1", "\uFF82"=>"\u30C4", "\uFF83"=>"\u30C6",
+ "\uFF84"=>"\u30C8", "\uFF85"=>"\u30CA", "\uFF86"=>"\u30CB", "\uFF87"=>"\u30CC", "\uFF88"=>"\u30CD", "\uFF89"=>"\u30CE", "\uFF8A"=>"\u30CF", "\uFF8B"=>"\u30D2",
+ "\uFF8C"=>"\u30D5", "\uFF8D"=>"\u30D8", "\uFF8E"=>"\u30DB", "\uFF8F"=>"\u30DE", "\uFF90"=>"\u30DF", "\uFF91"=>"\u30E0", "\uFF92"=>"\u30E1", "\uFF93"=>"\u30E2",
+ "\uFF94"=>"\u30E4", "\uFF95"=>"\u30E6", "\uFF96"=>"\u30E8", "\uFF97"=>"\u30E9", "\uFF98"=>"\u30EA", "\uFF99"=>"\u30EB", "\uFF9A"=>"\u30EC", "\uFF9B"=>"\u30ED",
+ "\uFF9C"=>"\u30EF", "\uFF9D"=>"\u30F3", "\uFF9E"=>"\u3099", "\uFF9F"=>"\u309A", "\uFFA0"=>"\u1160", "\uFFA1"=>"\u1100", "\uFFA2"=>"\u1101", "\uFFA3"=>"\u11AA",
+ "\uFFA4"=>"\u1102", "\uFFA5"=>"\u11AC", "\uFFA6"=>"\u11AD", "\uFFA7"=>"\u1103", "\uFFA8"=>"\u1104", "\uFFA9"=>"\u1105", "\uFFAA"=>"\u11B0", "\uFFAB"=>"\u11B1",
+ "\uFFAC"=>"\u11B2", "\uFFAD"=>"\u11B3", "\uFFAE"=>"\u11B4", "\uFFAF"=>"\u11B5", "\uFFB0"=>"\u111A", "\uFFB1"=>"\u1106", "\uFFB2"=>"\u1107", "\uFFB3"=>"\u1108",
+ "\uFFB4"=>"\u1121", "\uFFB5"=>"\u1109", "\uFFB6"=>"\u110A", "\uFFB7"=>"\u110B", "\uFFB8"=>"\u110C", "\uFFB9"=>"\u110D", "\uFFBA"=>"\u110E", "\uFFBB"=>"\u110F",
+ "\uFFBC"=>"\u1110", "\uFFBD"=>"\u1111", "\uFFBE"=>"\u1112", "\uFFC2"=>"\u1161", "\uFFC3"=>"\u1162", "\uFFC4"=>"\u1163", "\uFFC5"=>"\u1164", "\uFFC6"=>"\u1165",
+ "\uFFC7"=>"\u1166", "\uFFCA"=>"\u1167", "\uFFCB"=>"\u1168", "\uFFCC"=>"\u1169", "\uFFCD"=>"\u116A", "\uFFCE"=>"\u116B", "\uFFCF"=>"\u116C", "\uFFD2"=>"\u116D",
+ "\uFFD3"=>"\u116E", "\uFFD4"=>"\u116F", "\uFFD5"=>"\u1170", "\uFFD6"=>"\u1171", "\uFFD7"=>"\u1172", "\uFFDA"=>"\u1173", "\uFFDB"=>"\u1174", "\uFFDC"=>"\u1175",
+ "\uFFE0"=>"\u00A2", "\uFFE1"=>"\u00A3", "\uFFE2"=>"\u00AC", "\uFFE3"=>" \u0304", "\uFFE4"=>"\u00A6", "\uFFE5"=>"\u00A5", "\uFFE6"=>"\u20A9", "\uFFE8"=>"\u2502",
+ "\uFFE9"=>"\u2190", "\uFFEA"=>"\u2191", "\uFFEB"=>"\u2192", "\uFFEC"=>"\u2193", "\uFFED"=>"\u25A0", "\uFFEE"=>"\u25CB", "\u{1D400}"=>"A", "\u{1D401}"=>"B",
+ "\u{1D402}"=>"C", "\u{1D403}"=>"D", "\u{1D404}"=>"E", "\u{1D405}"=>"F", "\u{1D406}"=>"G", "\u{1D407}"=>"H", "\u{1D408}"=>"I", "\u{1D409}"=>"J",
+ "\u{1D40A}"=>"K", "\u{1D40B}"=>"L", "\u{1D40C}"=>"M", "\u{1D40D}"=>"N", "\u{1D40E}"=>"O", "\u{1D40F}"=>"P", "\u{1D410}"=>"Q", "\u{1D411}"=>"R",
+ "\u{1D412}"=>"S", "\u{1D413}"=>"T", "\u{1D414}"=>"U", "\u{1D415}"=>"V", "\u{1D416}"=>"W", "\u{1D417}"=>"X", "\u{1D418}"=>"Y", "\u{1D419}"=>"Z",
+ "\u{1D41A}"=>"a", "\u{1D41B}"=>"b", "\u{1D41C}"=>"c", "\u{1D41D}"=>"d", "\u{1D41E}"=>"e", "\u{1D41F}"=>"f", "\u{1D420}"=>"g", "\u{1D421}"=>"h",
+ "\u{1D422}"=>"i", "\u{1D423}"=>"j", "\u{1D424}"=>"k", "\u{1D425}"=>"l", "\u{1D426}"=>"m", "\u{1D427}"=>"n", "\u{1D428}"=>"o", "\u{1D429}"=>"p",
+ "\u{1D42A}"=>"q", "\u{1D42B}"=>"r", "\u{1D42C}"=>"s", "\u{1D42D}"=>"t", "\u{1D42E}"=>"u", "\u{1D42F}"=>"v", "\u{1D430}"=>"w", "\u{1D431}"=>"x",
+ "\u{1D432}"=>"y", "\u{1D433}"=>"z", "\u{1D434}"=>"A", "\u{1D435}"=>"B", "\u{1D436}"=>"C", "\u{1D437}"=>"D", "\u{1D438}"=>"E", "\u{1D439}"=>"F",
+ "\u{1D43A}"=>"G", "\u{1D43B}"=>"H", "\u{1D43C}"=>"I", "\u{1D43D}"=>"J", "\u{1D43E}"=>"K", "\u{1D43F}"=>"L", "\u{1D440}"=>"M", "\u{1D441}"=>"N",
+ "\u{1D442}"=>"O", "\u{1D443}"=>"P", "\u{1D444}"=>"Q", "\u{1D445}"=>"R", "\u{1D446}"=>"S", "\u{1D447}"=>"T", "\u{1D448}"=>"U", "\u{1D449}"=>"V",
+ "\u{1D44A}"=>"W", "\u{1D44B}"=>"X", "\u{1D44C}"=>"Y", "\u{1D44D}"=>"Z", "\u{1D44E}"=>"a", "\u{1D44F}"=>"b", "\u{1D450}"=>"c", "\u{1D451}"=>"d",
+ "\u{1D452}"=>"e", "\u{1D453}"=>"f", "\u{1D454}"=>"g", "\u{1D456}"=>"i", "\u{1D457}"=>"j", "\u{1D458}"=>"k", "\u{1D459}"=>"l", "\u{1D45A}"=>"m",
+ "\u{1D45B}"=>"n", "\u{1D45C}"=>"o", "\u{1D45D}"=>"p", "\u{1D45E}"=>"q", "\u{1D45F}"=>"r", "\u{1D460}"=>"s", "\u{1D461}"=>"t", "\u{1D462}"=>"u",
+ "\u{1D463}"=>"v", "\u{1D464}"=>"w", "\u{1D465}"=>"x", "\u{1D466}"=>"y", "\u{1D467}"=>"z", "\u{1D468}"=>"A", "\u{1D469}"=>"B", "\u{1D46A}"=>"C",
+ "\u{1D46B}"=>"D", "\u{1D46C}"=>"E", "\u{1D46D}"=>"F", "\u{1D46E}"=>"G", "\u{1D46F}"=>"H", "\u{1D470}"=>"I", "\u{1D471}"=>"J", "\u{1D472}"=>"K",
+ "\u{1D473}"=>"L", "\u{1D474}"=>"M", "\u{1D475}"=>"N", "\u{1D476}"=>"O", "\u{1D477}"=>"P", "\u{1D478}"=>"Q", "\u{1D479}"=>"R", "\u{1D47A}"=>"S",
+ "\u{1D47B}"=>"T", "\u{1D47C}"=>"U", "\u{1D47D}"=>"V", "\u{1D47E}"=>"W", "\u{1D47F}"=>"X", "\u{1D480}"=>"Y", "\u{1D481}"=>"Z", "\u{1D482}"=>"a",
+ "\u{1D483}"=>"b", "\u{1D484}"=>"c", "\u{1D485}"=>"d", "\u{1D486}"=>"e", "\u{1D487}"=>"f", "\u{1D488}"=>"g", "\u{1D489}"=>"h", "\u{1D48A}"=>"i",
+ "\u{1D48B}"=>"j", "\u{1D48C}"=>"k", "\u{1D48D}"=>"l", "\u{1D48E}"=>"m", "\u{1D48F}"=>"n", "\u{1D490}"=>"o", "\u{1D491}"=>"p", "\u{1D492}"=>"q",
+ "\u{1D493}"=>"r", "\u{1D494}"=>"s", "\u{1D495}"=>"t", "\u{1D496}"=>"u", "\u{1D497}"=>"v", "\u{1D498}"=>"w", "\u{1D499}"=>"x", "\u{1D49A}"=>"y",
+ "\u{1D49B}"=>"z", "\u{1D49C}"=>"A", "\u{1D49E}"=>"C", "\u{1D49F}"=>"D", "\u{1D4A2}"=>"G", "\u{1D4A5}"=>"J", "\u{1D4A6}"=>"K", "\u{1D4A9}"=>"N",
+ "\u{1D4AA}"=>"O", "\u{1D4AB}"=>"P", "\u{1D4AC}"=>"Q", "\u{1D4AE}"=>"S", "\u{1D4AF}"=>"T", "\u{1D4B0}"=>"U", "\u{1D4B1}"=>"V", "\u{1D4B2}"=>"W",
+ "\u{1D4B3}"=>"X", "\u{1D4B4}"=>"Y", "\u{1D4B5}"=>"Z", "\u{1D4B6}"=>"a", "\u{1D4B7}"=>"b", "\u{1D4B8}"=>"c", "\u{1D4B9}"=>"d", "\u{1D4BB}"=>"f",
+ "\u{1D4BD}"=>"h", "\u{1D4BE}"=>"i", "\u{1D4BF}"=>"j", "\u{1D4C0}"=>"k", "\u{1D4C1}"=>"l", "\u{1D4C2}"=>"m", "\u{1D4C3}"=>"n", "\u{1D4C5}"=>"p",
+ "\u{1D4C6}"=>"q", "\u{1D4C7}"=>"r", "\u{1D4C8}"=>"s", "\u{1D4C9}"=>"t", "\u{1D4CA}"=>"u", "\u{1D4CB}"=>"v", "\u{1D4CC}"=>"w", "\u{1D4CD}"=>"x",
+ "\u{1D4CE}"=>"y", "\u{1D4CF}"=>"z", "\u{1D4D0}"=>"A", "\u{1D4D1}"=>"B", "\u{1D4D2}"=>"C", "\u{1D4D3}"=>"D", "\u{1D4D4}"=>"E", "\u{1D4D5}"=>"F",
+ "\u{1D4D6}"=>"G", "\u{1D4D7}"=>"H", "\u{1D4D8}"=>"I", "\u{1D4D9}"=>"J", "\u{1D4DA}"=>"K", "\u{1D4DB}"=>"L", "\u{1D4DC}"=>"M", "\u{1D4DD}"=>"N",
+ "\u{1D4DE}"=>"O", "\u{1D4DF}"=>"P", "\u{1D4E0}"=>"Q", "\u{1D4E1}"=>"R", "\u{1D4E2}"=>"S", "\u{1D4E3}"=>"T", "\u{1D4E4}"=>"U", "\u{1D4E5}"=>"V",
+ "\u{1D4E6}"=>"W", "\u{1D4E7}"=>"X", "\u{1D4E8}"=>"Y", "\u{1D4E9}"=>"Z", "\u{1D4EA}"=>"a", "\u{1D4EB}"=>"b", "\u{1D4EC}"=>"c", "\u{1D4ED}"=>"d",
+ "\u{1D4EE}"=>"e", "\u{1D4EF}"=>"f", "\u{1D4F0}"=>"g", "\u{1D4F1}"=>"h", "\u{1D4F2}"=>"i", "\u{1D4F3}"=>"j", "\u{1D4F4}"=>"k", "\u{1D4F5}"=>"l",
+ "\u{1D4F6}"=>"m", "\u{1D4F7}"=>"n", "\u{1D4F8}"=>"o", "\u{1D4F9}"=>"p", "\u{1D4FA}"=>"q", "\u{1D4FB}"=>"r", "\u{1D4FC}"=>"s", "\u{1D4FD}"=>"t",
+ "\u{1D4FE}"=>"u", "\u{1D4FF}"=>"v", "\u{1D500}"=>"w", "\u{1D501}"=>"x", "\u{1D502}"=>"y", "\u{1D503}"=>"z", "\u{1D504}"=>"A", "\u{1D505}"=>"B",
+ "\u{1D507}"=>"D", "\u{1D508}"=>"E", "\u{1D509}"=>"F", "\u{1D50A}"=>"G", "\u{1D50D}"=>"J", "\u{1D50E}"=>"K", "\u{1D50F}"=>"L", "\u{1D510}"=>"M",
+ "\u{1D511}"=>"N", "\u{1D512}"=>"O", "\u{1D513}"=>"P", "\u{1D514}"=>"Q", "\u{1D516}"=>"S", "\u{1D517}"=>"T", "\u{1D518}"=>"U", "\u{1D519}"=>"V",
+ "\u{1D51A}"=>"W", "\u{1D51B}"=>"X", "\u{1D51C}"=>"Y", "\u{1D51E}"=>"a", "\u{1D51F}"=>"b", "\u{1D520}"=>"c", "\u{1D521}"=>"d", "\u{1D522}"=>"e",
+ "\u{1D523}"=>"f", "\u{1D524}"=>"g", "\u{1D525}"=>"h", "\u{1D526}"=>"i", "\u{1D527}"=>"j", "\u{1D528}"=>"k", "\u{1D529}"=>"l", "\u{1D52A}"=>"m",
+ "\u{1D52B}"=>"n", "\u{1D52C}"=>"o", "\u{1D52D}"=>"p", "\u{1D52E}"=>"q", "\u{1D52F}"=>"r", "\u{1D530}"=>"s", "\u{1D531}"=>"t", "\u{1D532}"=>"u",
+ "\u{1D533}"=>"v", "\u{1D534}"=>"w", "\u{1D535}"=>"x", "\u{1D536}"=>"y", "\u{1D537}"=>"z", "\u{1D538}"=>"A", "\u{1D539}"=>"B", "\u{1D53B}"=>"D",
+ "\u{1D53C}"=>"E", "\u{1D53D}"=>"F", "\u{1D53E}"=>"G", "\u{1D540}"=>"I", "\u{1D541}"=>"J", "\u{1D542}"=>"K", "\u{1D543}"=>"L", "\u{1D544}"=>"M",
+ "\u{1D546}"=>"O", "\u{1D54A}"=>"S", "\u{1D54B}"=>"T", "\u{1D54C}"=>"U", "\u{1D54D}"=>"V", "\u{1D54E}"=>"W", "\u{1D54F}"=>"X", "\u{1D550}"=>"Y",
+ "\u{1D552}"=>"a", "\u{1D553}"=>"b", "\u{1D554}"=>"c", "\u{1D555}"=>"d", "\u{1D556}"=>"e", "\u{1D557}"=>"f", "\u{1D558}"=>"g", "\u{1D559}"=>"h",
+ "\u{1D55A}"=>"i", "\u{1D55B}"=>"j", "\u{1D55C}"=>"k", "\u{1D55D}"=>"l", "\u{1D55E}"=>"m", "\u{1D55F}"=>"n", "\u{1D560}"=>"o", "\u{1D561}"=>"p",
+ "\u{1D562}"=>"q", "\u{1D563}"=>"r", "\u{1D564}"=>"s", "\u{1D565}"=>"t", "\u{1D566}"=>"u", "\u{1D567}"=>"v", "\u{1D568}"=>"w", "\u{1D569}"=>"x",
+ "\u{1D56A}"=>"y", "\u{1D56B}"=>"z", "\u{1D56C}"=>"A", "\u{1D56D}"=>"B", "\u{1D56E}"=>"C", "\u{1D56F}"=>"D", "\u{1D570}"=>"E", "\u{1D571}"=>"F",
+ "\u{1D572}"=>"G", "\u{1D573}"=>"H", "\u{1D574}"=>"I", "\u{1D575}"=>"J", "\u{1D576}"=>"K", "\u{1D577}"=>"L", "\u{1D578}"=>"M", "\u{1D579}"=>"N",
+ "\u{1D57A}"=>"O", "\u{1D57B}"=>"P", "\u{1D57C}"=>"Q", "\u{1D57D}"=>"R", "\u{1D57E}"=>"S", "\u{1D57F}"=>"T", "\u{1D580}"=>"U", "\u{1D581}"=>"V",
+ "\u{1D582}"=>"W", "\u{1D583}"=>"X", "\u{1D584}"=>"Y", "\u{1D585}"=>"Z", "\u{1D586}"=>"a", "\u{1D587}"=>"b", "\u{1D588}"=>"c", "\u{1D589}"=>"d",
+ "\u{1D58A}"=>"e", "\u{1D58B}"=>"f", "\u{1D58C}"=>"g", "\u{1D58D}"=>"h", "\u{1D58E}"=>"i", "\u{1D58F}"=>"j", "\u{1D590}"=>"k", "\u{1D591}"=>"l",
+ "\u{1D592}"=>"m", "\u{1D593}"=>"n", "\u{1D594}"=>"o", "\u{1D595}"=>"p", "\u{1D596}"=>"q", "\u{1D597}"=>"r", "\u{1D598}"=>"s", "\u{1D599}"=>"t",
+ "\u{1D59A}"=>"u", "\u{1D59B}"=>"v", "\u{1D59C}"=>"w", "\u{1D59D}"=>"x", "\u{1D59E}"=>"y", "\u{1D59F}"=>"z", "\u{1D5A0}"=>"A", "\u{1D5A1}"=>"B",
+ "\u{1D5A2}"=>"C", "\u{1D5A3}"=>"D", "\u{1D5A4}"=>"E", "\u{1D5A5}"=>"F", "\u{1D5A6}"=>"G", "\u{1D5A7}"=>"H", "\u{1D5A8}"=>"I", "\u{1D5A9}"=>"J",
+ "\u{1D5AA}"=>"K", "\u{1D5AB}"=>"L", "\u{1D5AC}"=>"M", "\u{1D5AD}"=>"N", "\u{1D5AE}"=>"O", "\u{1D5AF}"=>"P", "\u{1D5B0}"=>"Q", "\u{1D5B1}"=>"R",
+ "\u{1D5B2}"=>"S", "\u{1D5B3}"=>"T", "\u{1D5B4}"=>"U", "\u{1D5B5}"=>"V", "\u{1D5B6}"=>"W", "\u{1D5B7}"=>"X", "\u{1D5B8}"=>"Y", "\u{1D5B9}"=>"Z",
+ "\u{1D5BA}"=>"a", "\u{1D5BB}"=>"b", "\u{1D5BC}"=>"c", "\u{1D5BD}"=>"d", "\u{1D5BE}"=>"e", "\u{1D5BF}"=>"f", "\u{1D5C0}"=>"g", "\u{1D5C1}"=>"h",
+ "\u{1D5C2}"=>"i", "\u{1D5C3}"=>"j", "\u{1D5C4}"=>"k", "\u{1D5C5}"=>"l", "\u{1D5C6}"=>"m", "\u{1D5C7}"=>"n", "\u{1D5C8}"=>"o", "\u{1D5C9}"=>"p",
+ "\u{1D5CA}"=>"q", "\u{1D5CB}"=>"r", "\u{1D5CC}"=>"s", "\u{1D5CD}"=>"t", "\u{1D5CE}"=>"u", "\u{1D5CF}"=>"v", "\u{1D5D0}"=>"w", "\u{1D5D1}"=>"x",
+ "\u{1D5D2}"=>"y", "\u{1D5D3}"=>"z", "\u{1D5D4}"=>"A", "\u{1D5D5}"=>"B", "\u{1D5D6}"=>"C", "\u{1D5D7}"=>"D", "\u{1D5D8}"=>"E", "\u{1D5D9}"=>"F",
+ "\u{1D5DA}"=>"G", "\u{1D5DB}"=>"H", "\u{1D5DC}"=>"I", "\u{1D5DD}"=>"J", "\u{1D5DE}"=>"K", "\u{1D5DF}"=>"L", "\u{1D5E0}"=>"M", "\u{1D5E1}"=>"N",
+ "\u{1D5E2}"=>"O", "\u{1D5E3}"=>"P", "\u{1D5E4}"=>"Q", "\u{1D5E5}"=>"R", "\u{1D5E6}"=>"S", "\u{1D5E7}"=>"T", "\u{1D5E8}"=>"U", "\u{1D5E9}"=>"V",
+ "\u{1D5EA}"=>"W", "\u{1D5EB}"=>"X", "\u{1D5EC}"=>"Y", "\u{1D5ED}"=>"Z", "\u{1D5EE}"=>"a", "\u{1D5EF}"=>"b", "\u{1D5F0}"=>"c", "\u{1D5F1}"=>"d",
+ "\u{1D5F2}"=>"e", "\u{1D5F3}"=>"f", "\u{1D5F4}"=>"g", "\u{1D5F5}"=>"h", "\u{1D5F6}"=>"i", "\u{1D5F7}"=>"j", "\u{1D5F8}"=>"k", "\u{1D5F9}"=>"l",
+ "\u{1D5FA}"=>"m", "\u{1D5FB}"=>"n", "\u{1D5FC}"=>"o", "\u{1D5FD}"=>"p", "\u{1D5FE}"=>"q", "\u{1D5FF}"=>"r", "\u{1D600}"=>"s", "\u{1D601}"=>"t",
+ "\u{1D602}"=>"u", "\u{1D603}"=>"v", "\u{1D604}"=>"w", "\u{1D605}"=>"x", "\u{1D606}"=>"y", "\u{1D607}"=>"z", "\u{1D608}"=>"A", "\u{1D609}"=>"B",
+ "\u{1D60A}"=>"C", "\u{1D60B}"=>"D", "\u{1D60C}"=>"E", "\u{1D60D}"=>"F", "\u{1D60E}"=>"G", "\u{1D60F}"=>"H", "\u{1D610}"=>"I", "\u{1D611}"=>"J",
+ "\u{1D612}"=>"K", "\u{1D613}"=>"L", "\u{1D614}"=>"M", "\u{1D615}"=>"N", "\u{1D616}"=>"O", "\u{1D617}"=>"P", "\u{1D618}"=>"Q", "\u{1D619}"=>"R",
+ "\u{1D61A}"=>"S", "\u{1D61B}"=>"T", "\u{1D61C}"=>"U", "\u{1D61D}"=>"V", "\u{1D61E}"=>"W", "\u{1D61F}"=>"X", "\u{1D620}"=>"Y", "\u{1D621}"=>"Z",
+ "\u{1D622}"=>"a", "\u{1D623}"=>"b", "\u{1D624}"=>"c", "\u{1D625}"=>"d", "\u{1D626}"=>"e", "\u{1D627}"=>"f", "\u{1D628}"=>"g", "\u{1D629}"=>"h",
+ "\u{1D62A}"=>"i", "\u{1D62B}"=>"j", "\u{1D62C}"=>"k", "\u{1D62D}"=>"l", "\u{1D62E}"=>"m", "\u{1D62F}"=>"n", "\u{1D630}"=>"o", "\u{1D631}"=>"p",
+ "\u{1D632}"=>"q", "\u{1D633}"=>"r", "\u{1D634}"=>"s", "\u{1D635}"=>"t", "\u{1D636}"=>"u", "\u{1D637}"=>"v", "\u{1D638}"=>"w", "\u{1D639}"=>"x",
+ "\u{1D63A}"=>"y", "\u{1D63B}"=>"z", "\u{1D63C}"=>"A", "\u{1D63D}"=>"B", "\u{1D63E}"=>"C", "\u{1D63F}"=>"D", "\u{1D640}"=>"E", "\u{1D641}"=>"F",
+ "\u{1D642}"=>"G", "\u{1D643}"=>"H", "\u{1D644}"=>"I", "\u{1D645}"=>"J", "\u{1D646}"=>"K", "\u{1D647}"=>"L", "\u{1D648}"=>"M", "\u{1D649}"=>"N",
+ "\u{1D64A}"=>"O", "\u{1D64B}"=>"P", "\u{1D64C}"=>"Q", "\u{1D64D}"=>"R", "\u{1D64E}"=>"S", "\u{1D64F}"=>"T", "\u{1D650}"=>"U", "\u{1D651}"=>"V",
+ "\u{1D652}"=>"W", "\u{1D653}"=>"X", "\u{1D654}"=>"Y", "\u{1D655}"=>"Z", "\u{1D656}"=>"a", "\u{1D657}"=>"b", "\u{1D658}"=>"c", "\u{1D659}"=>"d",
+ "\u{1D65A}"=>"e", "\u{1D65B}"=>"f", "\u{1D65C}"=>"g", "\u{1D65D}"=>"h", "\u{1D65E}"=>"i", "\u{1D65F}"=>"j", "\u{1D660}"=>"k", "\u{1D661}"=>"l",
+ "\u{1D662}"=>"m", "\u{1D663}"=>"n", "\u{1D664}"=>"o", "\u{1D665}"=>"p", "\u{1D666}"=>"q", "\u{1D667}"=>"r", "\u{1D668}"=>"s", "\u{1D669}"=>"t",
+ "\u{1D66A}"=>"u", "\u{1D66B}"=>"v", "\u{1D66C}"=>"w", "\u{1D66D}"=>"x", "\u{1D66E}"=>"y", "\u{1D66F}"=>"z", "\u{1D670}"=>"A", "\u{1D671}"=>"B",
+ "\u{1D672}"=>"C", "\u{1D673}"=>"D", "\u{1D674}"=>"E", "\u{1D675}"=>"F", "\u{1D676}"=>"G", "\u{1D677}"=>"H", "\u{1D678}"=>"I", "\u{1D679}"=>"J",
+ "\u{1D67A}"=>"K", "\u{1D67B}"=>"L", "\u{1D67C}"=>"M", "\u{1D67D}"=>"N", "\u{1D67E}"=>"O", "\u{1D67F}"=>"P", "\u{1D680}"=>"Q", "\u{1D681}"=>"R",
+ "\u{1D682}"=>"S", "\u{1D683}"=>"T", "\u{1D684}"=>"U", "\u{1D685}"=>"V", "\u{1D686}"=>"W", "\u{1D687}"=>"X", "\u{1D688}"=>"Y", "\u{1D689}"=>"Z",
+ "\u{1D68A}"=>"a", "\u{1D68B}"=>"b", "\u{1D68C}"=>"c", "\u{1D68D}"=>"d", "\u{1D68E}"=>"e", "\u{1D68F}"=>"f", "\u{1D690}"=>"g", "\u{1D691}"=>"h",
+ "\u{1D692}"=>"i", "\u{1D693}"=>"j", "\u{1D694}"=>"k", "\u{1D695}"=>"l", "\u{1D696}"=>"m", "\u{1D697}"=>"n", "\u{1D698}"=>"o", "\u{1D699}"=>"p",
+ "\u{1D69A}"=>"q", "\u{1D69B}"=>"r", "\u{1D69C}"=>"s", "\u{1D69D}"=>"t", "\u{1D69E}"=>"u", "\u{1D69F}"=>"v", "\u{1D6A0}"=>"w", "\u{1D6A1}"=>"x",
+ "\u{1D6A2}"=>"y", "\u{1D6A3}"=>"z", "\u{1D6A4}"=>"\u0131", "\u{1D6A5}"=>"\u0237", "\u{1D6A8}"=>"\u0391", "\u{1D6A9}"=>"\u0392", "\u{1D6AA}"=>"\u0393", "\u{1D6AB}"=>"\u0394",
+ "\u{1D6AC}"=>"\u0395", "\u{1D6AD}"=>"\u0396", "\u{1D6AE}"=>"\u0397", "\u{1D6AF}"=>"\u0398", "\u{1D6B0}"=>"\u0399", "\u{1D6B1}"=>"\u039A", "\u{1D6B2}"=>"\u039B", "\u{1D6B3}"=>"\u039C",
+ "\u{1D6B4}"=>"\u039D", "\u{1D6B5}"=>"\u039E", "\u{1D6B6}"=>"\u039F", "\u{1D6B7}"=>"\u03A0", "\u{1D6B8}"=>"\u03A1", "\u{1D6B9}"=>"\u0398", "\u{1D6BA}"=>"\u03A3", "\u{1D6BB}"=>"\u03A4",
+ "\u{1D6BC}"=>"\u03A5", "\u{1D6BD}"=>"\u03A6", "\u{1D6BE}"=>"\u03A7", "\u{1D6BF}"=>"\u03A8", "\u{1D6C0}"=>"\u03A9", "\u{1D6C1}"=>"\u2207", "\u{1D6C2}"=>"\u03B1", "\u{1D6C3}"=>"\u03B2",
+ "\u{1D6C4}"=>"\u03B3", "\u{1D6C5}"=>"\u03B4", "\u{1D6C6}"=>"\u03B5", "\u{1D6C7}"=>"\u03B6", "\u{1D6C8}"=>"\u03B7", "\u{1D6C9}"=>"\u03B8", "\u{1D6CA}"=>"\u03B9", "\u{1D6CB}"=>"\u03BA",
+ "\u{1D6CC}"=>"\u03BB", "\u{1D6CD}"=>"\u03BC", "\u{1D6CE}"=>"\u03BD", "\u{1D6CF}"=>"\u03BE", "\u{1D6D0}"=>"\u03BF", "\u{1D6D1}"=>"\u03C0", "\u{1D6D2}"=>"\u03C1", "\u{1D6D3}"=>"\u03C2",
+ "\u{1D6D4}"=>"\u03C3", "\u{1D6D5}"=>"\u03C4", "\u{1D6D6}"=>"\u03C5", "\u{1D6D7}"=>"\u03C6", "\u{1D6D8}"=>"\u03C7", "\u{1D6D9}"=>"\u03C8", "\u{1D6DA}"=>"\u03C9", "\u{1D6DB}"=>"\u2202",
+ "\u{1D6DC}"=>"\u03B5", "\u{1D6DD}"=>"\u03B8", "\u{1D6DE}"=>"\u03BA", "\u{1D6DF}"=>"\u03C6", "\u{1D6E0}"=>"\u03C1", "\u{1D6E1}"=>"\u03C0", "\u{1D6E2}"=>"\u0391", "\u{1D6E3}"=>"\u0392",
+ "\u{1D6E4}"=>"\u0393", "\u{1D6E5}"=>"\u0394", "\u{1D6E6}"=>"\u0395", "\u{1D6E7}"=>"\u0396", "\u{1D6E8}"=>"\u0397", "\u{1D6E9}"=>"\u0398", "\u{1D6EA}"=>"\u0399", "\u{1D6EB}"=>"\u039A",
+ "\u{1D6EC}"=>"\u039B", "\u{1D6ED}"=>"\u039C", "\u{1D6EE}"=>"\u039D", "\u{1D6EF}"=>"\u039E", "\u{1D6F0}"=>"\u039F", "\u{1D6F1}"=>"\u03A0", "\u{1D6F2}"=>"\u03A1", "\u{1D6F3}"=>"\u0398",
+ "\u{1D6F4}"=>"\u03A3", "\u{1D6F5}"=>"\u03A4", "\u{1D6F6}"=>"\u03A5", "\u{1D6F7}"=>"\u03A6", "\u{1D6F8}"=>"\u03A7", "\u{1D6F9}"=>"\u03A8", "\u{1D6FA}"=>"\u03A9", "\u{1D6FB}"=>"\u2207",
+ "\u{1D6FC}"=>"\u03B1", "\u{1D6FD}"=>"\u03B2", "\u{1D6FE}"=>"\u03B3", "\u{1D6FF}"=>"\u03B4", "\u{1D700}"=>"\u03B5", "\u{1D701}"=>"\u03B6", "\u{1D702}"=>"\u03B7", "\u{1D703}"=>"\u03B8",
+ "\u{1D704}"=>"\u03B9", "\u{1D705}"=>"\u03BA", "\u{1D706}"=>"\u03BB", "\u{1D707}"=>"\u03BC", "\u{1D708}"=>"\u03BD", "\u{1D709}"=>"\u03BE", "\u{1D70A}"=>"\u03BF", "\u{1D70B}"=>"\u03C0",
+ "\u{1D70C}"=>"\u03C1", "\u{1D70D}"=>"\u03C2", "\u{1D70E}"=>"\u03C3", "\u{1D70F}"=>"\u03C4", "\u{1D710}"=>"\u03C5", "\u{1D711}"=>"\u03C6", "\u{1D712}"=>"\u03C7", "\u{1D713}"=>"\u03C8",
+ "\u{1D714}"=>"\u03C9", "\u{1D715}"=>"\u2202", "\u{1D716}"=>"\u03B5", "\u{1D717}"=>"\u03B8", "\u{1D718}"=>"\u03BA", "\u{1D719}"=>"\u03C6", "\u{1D71A}"=>"\u03C1", "\u{1D71B}"=>"\u03C0",
+ "\u{1D71C}"=>"\u0391", "\u{1D71D}"=>"\u0392", "\u{1D71E}"=>"\u0393", "\u{1D71F}"=>"\u0394", "\u{1D720}"=>"\u0395", "\u{1D721}"=>"\u0396", "\u{1D722}"=>"\u0397", "\u{1D723}"=>"\u0398",
+ "\u{1D724}"=>"\u0399", "\u{1D725}"=>"\u039A", "\u{1D726}"=>"\u039B", "\u{1D727}"=>"\u039C", "\u{1D728}"=>"\u039D", "\u{1D729}"=>"\u039E", "\u{1D72A}"=>"\u039F", "\u{1D72B}"=>"\u03A0",
+ "\u{1D72C}"=>"\u03A1", "\u{1D72D}"=>"\u0398", "\u{1D72E}"=>"\u03A3", "\u{1D72F}"=>"\u03A4", "\u{1D730}"=>"\u03A5", "\u{1D731}"=>"\u03A6", "\u{1D732}"=>"\u03A7", "\u{1D733}"=>"\u03A8",
+ "\u{1D734}"=>"\u03A9", "\u{1D735}"=>"\u2207", "\u{1D736}"=>"\u03B1", "\u{1D737}"=>"\u03B2", "\u{1D738}"=>"\u03B3", "\u{1D739}"=>"\u03B4", "\u{1D73A}"=>"\u03B5", "\u{1D73B}"=>"\u03B6",
+ "\u{1D73C}"=>"\u03B7", "\u{1D73D}"=>"\u03B8", "\u{1D73E}"=>"\u03B9", "\u{1D73F}"=>"\u03BA", "\u{1D740}"=>"\u03BB", "\u{1D741}"=>"\u03BC", "\u{1D742}"=>"\u03BD", "\u{1D743}"=>"\u03BE",
+ "\u{1D744}"=>"\u03BF", "\u{1D745}"=>"\u03C0", "\u{1D746}"=>"\u03C1", "\u{1D747}"=>"\u03C2", "\u{1D748}"=>"\u03C3", "\u{1D749}"=>"\u03C4", "\u{1D74A}"=>"\u03C5", "\u{1D74B}"=>"\u03C6",
+ "\u{1D74C}"=>"\u03C7", "\u{1D74D}"=>"\u03C8", "\u{1D74E}"=>"\u03C9", "\u{1D74F}"=>"\u2202", "\u{1D750}"=>"\u03B5", "\u{1D751}"=>"\u03B8", "\u{1D752}"=>"\u03BA", "\u{1D753}"=>"\u03C6",
+ "\u{1D754}"=>"\u03C1", "\u{1D755}"=>"\u03C0", "\u{1D756}"=>"\u0391", "\u{1D757}"=>"\u0392", "\u{1D758}"=>"\u0393", "\u{1D759}"=>"\u0394", "\u{1D75A}"=>"\u0395", "\u{1D75B}"=>"\u0396",
+ "\u{1D75C}"=>"\u0397", "\u{1D75D}"=>"\u0398", "\u{1D75E}"=>"\u0399", "\u{1D75F}"=>"\u039A", "\u{1D760}"=>"\u039B", "\u{1D761}"=>"\u039C", "\u{1D762}"=>"\u039D", "\u{1D763}"=>"\u039E",
+ "\u{1D764}"=>"\u039F", "\u{1D765}"=>"\u03A0", "\u{1D766}"=>"\u03A1", "\u{1D767}"=>"\u0398", "\u{1D768}"=>"\u03A3", "\u{1D769}"=>"\u03A4", "\u{1D76A}"=>"\u03A5", "\u{1D76B}"=>"\u03A6",
+ "\u{1D76C}"=>"\u03A7", "\u{1D76D}"=>"\u03A8", "\u{1D76E}"=>"\u03A9", "\u{1D76F}"=>"\u2207", "\u{1D770}"=>"\u03B1", "\u{1D771}"=>"\u03B2", "\u{1D772}"=>"\u03B3", "\u{1D773}"=>"\u03B4",
+ "\u{1D774}"=>"\u03B5", "\u{1D775}"=>"\u03B6", "\u{1D776}"=>"\u03B7", "\u{1D777}"=>"\u03B8", "\u{1D778}"=>"\u03B9", "\u{1D779}"=>"\u03BA", "\u{1D77A}"=>"\u03BB", "\u{1D77B}"=>"\u03BC",
+ "\u{1D77C}"=>"\u03BD", "\u{1D77D}"=>"\u03BE", "\u{1D77E}"=>"\u03BF", "\u{1D77F}"=>"\u03C0", "\u{1D780}"=>"\u03C1", "\u{1D781}"=>"\u03C2", "\u{1D782}"=>"\u03C3", "\u{1D783}"=>"\u03C4",
+ "\u{1D784}"=>"\u03C5", "\u{1D785}"=>"\u03C6", "\u{1D786}"=>"\u03C7", "\u{1D787}"=>"\u03C8", "\u{1D788}"=>"\u03C9", "\u{1D789}"=>"\u2202", "\u{1D78A}"=>"\u03B5", "\u{1D78B}"=>"\u03B8",
+ "\u{1D78C}"=>"\u03BA", "\u{1D78D}"=>"\u03C6", "\u{1D78E}"=>"\u03C1", "\u{1D78F}"=>"\u03C0", "\u{1D790}"=>"\u0391", "\u{1D791}"=>"\u0392", "\u{1D792}"=>"\u0393", "\u{1D793}"=>"\u0394",
+ "\u{1D794}"=>"\u0395", "\u{1D795}"=>"\u0396", "\u{1D796}"=>"\u0397", "\u{1D797}"=>"\u0398", "\u{1D798}"=>"\u0399", "\u{1D799}"=>"\u039A", "\u{1D79A}"=>"\u039B", "\u{1D79B}"=>"\u039C",
+ "\u{1D79C}"=>"\u039D", "\u{1D79D}"=>"\u039E", "\u{1D79E}"=>"\u039F", "\u{1D79F}"=>"\u03A0", "\u{1D7A0}"=>"\u03A1", "\u{1D7A1}"=>"\u0398", "\u{1D7A2}"=>"\u03A3", "\u{1D7A3}"=>"\u03A4",
+ "\u{1D7A4}"=>"\u03A5", "\u{1D7A5}"=>"\u03A6", "\u{1D7A6}"=>"\u03A7", "\u{1D7A7}"=>"\u03A8", "\u{1D7A8}"=>"\u03A9", "\u{1D7A9}"=>"\u2207", "\u{1D7AA}"=>"\u03B1", "\u{1D7AB}"=>"\u03B2",
+ "\u{1D7AC}"=>"\u03B3", "\u{1D7AD}"=>"\u03B4", "\u{1D7AE}"=>"\u03B5", "\u{1D7AF}"=>"\u03B6", "\u{1D7B0}"=>"\u03B7", "\u{1D7B1}"=>"\u03B8", "\u{1D7B2}"=>"\u03B9", "\u{1D7B3}"=>"\u03BA",
+ "\u{1D7B4}"=>"\u03BB", "\u{1D7B5}"=>"\u03BC", "\u{1D7B6}"=>"\u03BD", "\u{1D7B7}"=>"\u03BE", "\u{1D7B8}"=>"\u03BF", "\u{1D7B9}"=>"\u03C0", "\u{1D7BA}"=>"\u03C1", "\u{1D7BB}"=>"\u03C2",
+ "\u{1D7BC}"=>"\u03C3", "\u{1D7BD}"=>"\u03C4", "\u{1D7BE}"=>"\u03C5", "\u{1D7BF}"=>"\u03C6", "\u{1D7C0}"=>"\u03C7", "\u{1D7C1}"=>"\u03C8", "\u{1D7C2}"=>"\u03C9", "\u{1D7C3}"=>"\u2202",
+ "\u{1D7C4}"=>"\u03B5", "\u{1D7C5}"=>"\u03B8", "\u{1D7C6}"=>"\u03BA", "\u{1D7C7}"=>"\u03C6", "\u{1D7C8}"=>"\u03C1", "\u{1D7C9}"=>"\u03C0", "\u{1D7CA}"=>"\u03DC", "\u{1D7CB}"=>"\u03DD",
+ "\u{1D7CE}"=>"0", "\u{1D7CF}"=>"1", "\u{1D7D0}"=>"2", "\u{1D7D1}"=>"3", "\u{1D7D2}"=>"4", "\u{1D7D3}"=>"5", "\u{1D7D4}"=>"6", "\u{1D7D5}"=>"7",
+ "\u{1D7D6}"=>"8", "\u{1D7D7}"=>"9", "\u{1D7D8}"=>"0", "\u{1D7D9}"=>"1", "\u{1D7DA}"=>"2", "\u{1D7DB}"=>"3", "\u{1D7DC}"=>"4", "\u{1D7DD}"=>"5",
+ "\u{1D7DE}"=>"6", "\u{1D7DF}"=>"7", "\u{1D7E0}"=>"8", "\u{1D7E1}"=>"9", "\u{1D7E2}"=>"0", "\u{1D7E3}"=>"1", "\u{1D7E4}"=>"2", "\u{1D7E5}"=>"3",
+ "\u{1D7E6}"=>"4", "\u{1D7E7}"=>"5", "\u{1D7E8}"=>"6", "\u{1D7E9}"=>"7", "\u{1D7EA}"=>"8", "\u{1D7EB}"=>"9", "\u{1D7EC}"=>"0", "\u{1D7ED}"=>"1",
+ "\u{1D7EE}"=>"2", "\u{1D7EF}"=>"3", "\u{1D7F0}"=>"4", "\u{1D7F1}"=>"5", "\u{1D7F2}"=>"6", "\u{1D7F3}"=>"7", "\u{1D7F4}"=>"8", "\u{1D7F5}"=>"9",
+ "\u{1D7F6}"=>"0", "\u{1D7F7}"=>"1", "\u{1D7F8}"=>"2", "\u{1D7F9}"=>"3", "\u{1D7FA}"=>"4", "\u{1D7FB}"=>"5", "\u{1D7FC}"=>"6", "\u{1D7FD}"=>"7",
+ "\u{1D7FE}"=>"8", "\u{1D7FF}"=>"9", "\u{1EE00}"=>"\u0627", "\u{1EE01}"=>"\u0628", "\u{1EE02}"=>"\u062C", "\u{1EE03}"=>"\u062F", "\u{1EE05}"=>"\u0648", "\u{1EE06}"=>"\u0632",
+ "\u{1EE07}"=>"\u062D", "\u{1EE08}"=>"\u0637", "\u{1EE09}"=>"\u064A", "\u{1EE0A}"=>"\u0643", "\u{1EE0B}"=>"\u0644", "\u{1EE0C}"=>"\u0645", "\u{1EE0D}"=>"\u0646", "\u{1EE0E}"=>"\u0633",
+ "\u{1EE0F}"=>"\u0639", "\u{1EE10}"=>"\u0641", "\u{1EE11}"=>"\u0635", "\u{1EE12}"=>"\u0642", "\u{1EE13}"=>"\u0631", "\u{1EE14}"=>"\u0634", "\u{1EE15}"=>"\u062A", "\u{1EE16}"=>"\u062B",
+ "\u{1EE17}"=>"\u062E", "\u{1EE18}"=>"\u0630", "\u{1EE19}"=>"\u0636", "\u{1EE1A}"=>"\u0638", "\u{1EE1B}"=>"\u063A", "\u{1EE1C}"=>"\u066E", "\u{1EE1D}"=>"\u06BA", "\u{1EE1E}"=>"\u06A1",
+ "\u{1EE1F}"=>"\u066F", "\u{1EE21}"=>"\u0628", "\u{1EE22}"=>"\u062C", "\u{1EE24}"=>"\u0647", "\u{1EE27}"=>"\u062D", "\u{1EE29}"=>"\u064A", "\u{1EE2A}"=>"\u0643", "\u{1EE2B}"=>"\u0644",
+ "\u{1EE2C}"=>"\u0645", "\u{1EE2D}"=>"\u0646", "\u{1EE2E}"=>"\u0633", "\u{1EE2F}"=>"\u0639", "\u{1EE30}"=>"\u0641", "\u{1EE31}"=>"\u0635", "\u{1EE32}"=>"\u0642", "\u{1EE34}"=>"\u0634",
+ "\u{1EE35}"=>"\u062A", "\u{1EE36}"=>"\u062B", "\u{1EE37}"=>"\u062E", "\u{1EE39}"=>"\u0636", "\u{1EE3B}"=>"\u063A", "\u{1EE42}"=>"\u062C", "\u{1EE47}"=>"\u062D", "\u{1EE49}"=>"\u064A",
+ "\u{1EE4B}"=>"\u0644", "\u{1EE4D}"=>"\u0646", "\u{1EE4E}"=>"\u0633", "\u{1EE4F}"=>"\u0639", "\u{1EE51}"=>"\u0635", "\u{1EE52}"=>"\u0642", "\u{1EE54}"=>"\u0634", "\u{1EE57}"=>"\u062E",
+ "\u{1EE59}"=>"\u0636", "\u{1EE5B}"=>"\u063A", "\u{1EE5D}"=>"\u06BA", "\u{1EE5F}"=>"\u066F", "\u{1EE61}"=>"\u0628", "\u{1EE62}"=>"\u062C", "\u{1EE64}"=>"\u0647", "\u{1EE67}"=>"\u062D",
+ "\u{1EE68}"=>"\u0637", "\u{1EE69}"=>"\u064A", "\u{1EE6A}"=>"\u0643", "\u{1EE6C}"=>"\u0645", "\u{1EE6D}"=>"\u0646", "\u{1EE6E}"=>"\u0633", "\u{1EE6F}"=>"\u0639", "\u{1EE70}"=>"\u0641",
+ "\u{1EE71}"=>"\u0635", "\u{1EE72}"=>"\u0642", "\u{1EE74}"=>"\u0634", "\u{1EE75}"=>"\u062A", "\u{1EE76}"=>"\u062B", "\u{1EE77}"=>"\u062E", "\u{1EE79}"=>"\u0636", "\u{1EE7A}"=>"\u0638",
+ "\u{1EE7B}"=>"\u063A", "\u{1EE7C}"=>"\u066E", "\u{1EE7E}"=>"\u06A1", "\u{1EE80}"=>"\u0627", "\u{1EE81}"=>"\u0628", "\u{1EE82}"=>"\u062C", "\u{1EE83}"=>"\u062F", "\u{1EE84}"=>"\u0647",
+ "\u{1EE85}"=>"\u0648", "\u{1EE86}"=>"\u0632", "\u{1EE87}"=>"\u062D", "\u{1EE88}"=>"\u0637", "\u{1EE89}"=>"\u064A", "\u{1EE8B}"=>"\u0644", "\u{1EE8C}"=>"\u0645", "\u{1EE8D}"=>"\u0646",
+ "\u{1EE8E}"=>"\u0633", "\u{1EE8F}"=>"\u0639", "\u{1EE90}"=>"\u0641", "\u{1EE91}"=>"\u0635", "\u{1EE92}"=>"\u0642", "\u{1EE93}"=>"\u0631", "\u{1EE94}"=>"\u0634", "\u{1EE95}"=>"\u062A",
+ "\u{1EE96}"=>"\u062B", "\u{1EE97}"=>"\u062E", "\u{1EE98}"=>"\u0630", "\u{1EE99}"=>"\u0636", "\u{1EE9A}"=>"\u0638", "\u{1EE9B}"=>"\u063A", "\u{1EEA1}"=>"\u0628", "\u{1EEA2}"=>"\u062C",
+ "\u{1EEA3}"=>"\u062F", "\u{1EEA5}"=>"\u0648", "\u{1EEA6}"=>"\u0632", "\u{1EEA7}"=>"\u062D", "\u{1EEA8}"=>"\u0637", "\u{1EEA9}"=>"\u064A", "\u{1EEAB}"=>"\u0644", "\u{1EEAC}"=>"\u0645",
+ "\u{1EEAD}"=>"\u0646", "\u{1EEAE}"=>"\u0633", "\u{1EEAF}"=>"\u0639", "\u{1EEB0}"=>"\u0641", "\u{1EEB1}"=>"\u0635", "\u{1EEB2}"=>"\u0642", "\u{1EEB3}"=>"\u0631", "\u{1EEB4}"=>"\u0634",
+ "\u{1EEB5}"=>"\u062A", "\u{1EEB6}"=>"\u062B", "\u{1EEB7}"=>"\u062E", "\u{1EEB8}"=>"\u0630", "\u{1EEB9}"=>"\u0636", "\u{1EEBA}"=>"\u0638", "\u{1EEBB}"=>"\u063A", "\u{1F100}"=>"0.",
+ "\u{1F101}"=>"0,", "\u{1F102}"=>"1,", "\u{1F103}"=>"2,", "\u{1F104}"=>"3,", "\u{1F105}"=>"4,", "\u{1F106}"=>"5,", "\u{1F107}"=>"6,", "\u{1F108}"=>"7,",
+ "\u{1F109}"=>"8,", "\u{1F10A}"=>"9,", "\u{1F110}"=>"(A)", "\u{1F111}"=>"(B)", "\u{1F112}"=>"(C)", "\u{1F113}"=>"(D)", "\u{1F114}"=>"(E)", "\u{1F115}"=>"(F)",
+ "\u{1F116}"=>"(G)", "\u{1F117}"=>"(H)", "\u{1F118}"=>"(I)", "\u{1F119}"=>"(J)", "\u{1F11A}"=>"(K)", "\u{1F11B}"=>"(L)", "\u{1F11C}"=>"(M)", "\u{1F11D}"=>"(N)",
+ "\u{1F11E}"=>"(O)", "\u{1F11F}"=>"(P)", "\u{1F120}"=>"(Q)", "\u{1F121}"=>"(R)", "\u{1F122}"=>"(S)", "\u{1F123}"=>"(T)", "\u{1F124}"=>"(U)", "\u{1F125}"=>"(V)",
+ "\u{1F126}"=>"(W)", "\u{1F127}"=>"(X)", "\u{1F128}"=>"(Y)", "\u{1F129}"=>"(Z)", "\u{1F12A}"=>"\u3014S\u3015", "\u{1F12B}"=>"C", "\u{1F12C}"=>"R", "\u{1F12D}"=>"CD",
+ "\u{1F12E}"=>"WZ", "\u{1F130}"=>"A", "\u{1F131}"=>"B", "\u{1F132}"=>"C", "\u{1F133}"=>"D", "\u{1F134}"=>"E", "\u{1F135}"=>"F", "\u{1F136}"=>"G",
+ "\u{1F137}"=>"H", "\u{1F138}"=>"I", "\u{1F139}"=>"J", "\u{1F13A}"=>"K", "\u{1F13B}"=>"L", "\u{1F13C}"=>"M", "\u{1F13D}"=>"N", "\u{1F13E}"=>"O",
+ "\u{1F13F}"=>"P", "\u{1F140}"=>"Q", "\u{1F141}"=>"R", "\u{1F142}"=>"S", "\u{1F143}"=>"T", "\u{1F144}"=>"U", "\u{1F145}"=>"V", "\u{1F146}"=>"W",
+ "\u{1F147}"=>"X", "\u{1F148}"=>"Y", "\u{1F149}"=>"Z", "\u{1F14A}"=>"HV", "\u{1F14B}"=>"MV", "\u{1F14C}"=>"SD", "\u{1F14D}"=>"SS", "\u{1F14E}"=>"PPV",
+ "\u{1F14F}"=>"WC", "\u{1F16A}"=>"MC", "\u{1F16B}"=>"MD", "\u{1F190}"=>"DJ", "\u{1F200}"=>"\u307B\u304B", "\u{1F201}"=>"\u30B3\u30B3", "\u{1F202}"=>"\u30B5", "\u{1F210}"=>"\u624B",
+ "\u{1F211}"=>"\u5B57", "\u{1F212}"=>"\u53CC", "\u{1F213}"=>"\u30C7", "\u{1F214}"=>"\u4E8C", "\u{1F215}"=>"\u591A", "\u{1F216}"=>"\u89E3", "\u{1F217}"=>"\u5929", "\u{1F218}"=>"\u4EA4",
+ "\u{1F219}"=>"\u6620", "\u{1F21A}"=>"\u7121", "\u{1F21B}"=>"\u6599", "\u{1F21C}"=>"\u524D", "\u{1F21D}"=>"\u5F8C", "\u{1F21E}"=>"\u518D", "\u{1F21F}"=>"\u65B0", "\u{1F220}"=>"\u521D",
+ "\u{1F221}"=>"\u7D42", "\u{1F222}"=>"\u751F", "\u{1F223}"=>"\u8CA9", "\u{1F224}"=>"\u58F0", "\u{1F225}"=>"\u5439", "\u{1F226}"=>"\u6F14", "\u{1F227}"=>"\u6295", "\u{1F228}"=>"\u6355",
+ "\u{1F229}"=>"\u4E00", "\u{1F22A}"=>"\u4E09", "\u{1F22B}"=>"\u904A", "\u{1F22C}"=>"\u5DE6", "\u{1F22D}"=>"\u4E2D", "\u{1F22E}"=>"\u53F3", "\u{1F22F}"=>"\u6307", "\u{1F230}"=>"\u8D70",
+ "\u{1F231}"=>"\u6253", "\u{1F232}"=>"\u7981", "\u{1F233}"=>"\u7A7A", "\u{1F234}"=>"\u5408", "\u{1F235}"=>"\u6E80", "\u{1F236}"=>"\u6709", "\u{1F237}"=>"\u6708", "\u{1F238}"=>"\u7533",
+ "\u{1F239}"=>"\u5272", "\u{1F23A}"=>"\u55B6", "\u{1F23B}"=>"\u914D", "\u{1F240}"=>"\u3014\u672C\u3015", "\u{1F241}"=>"\u3014\u4E09\u3015", "\u{1F242}"=>"\u3014\u4E8C\u3015", "\u{1F243}"=>"\u3014\u5B89\u3015", "\u{1F244}"=>"\u3014\u70B9\u3015",
+ "\u{1F245}"=>"\u3014\u6253\u3015", "\u{1F246}"=>"\u3014\u76D7\u3015", "\u{1F247}"=>"\u3014\u52DD\u3015", "\u{1F248}"=>"\u3014\u6557\u3015", "\u{1F250}"=>"\u5F97", "\u{1F251}"=>"\u53EF", "\u0385"=>" \u0308\u0301", "\u03D3"=>"\u03A5\u0301",
+ "\u03D4"=>"\u03A5\u0308", "\u1E9B"=>"s\u0307", "\u1FC1"=>" \u0308\u0342", "\u1FCD"=>" \u0313\u0300", "\u1FCE"=>" \u0313\u0301", "\u1FCF"=>" \u0313\u0342", "\u1FDD"=>" \u0314\u0300", "\u1FDE"=>" \u0314\u0301",
+ "\u1FDF"=>" \u0314\u0342", "\u1FED"=>" \u0308\u0300", "\u1FEE"=>" \u0308\u0301", "\u1FFD"=>" \u0301", "\u2000"=>" ", "\u2001"=>" ",
}.freeze
COMPOSITION_TABLE = {
- "A\u0300"=>"\u00C0",
- "A\u0301"=>"\u00C1",
- "A\u0302"=>"\u00C2",
- "A\u0303"=>"\u00C3",
- "A\u0308"=>"\u00C4",
- "A\u030A"=>"\u00C5",
- "C\u0327"=>"\u00C7",
- "E\u0300"=>"\u00C8",
- "E\u0301"=>"\u00C9",
- "E\u0302"=>"\u00CA",
- "E\u0308"=>"\u00CB",
- "I\u0300"=>"\u00CC",
- "I\u0301"=>"\u00CD",
- "I\u0302"=>"\u00CE",
- "I\u0308"=>"\u00CF",
- "N\u0303"=>"\u00D1",
- "O\u0300"=>"\u00D2",
- "O\u0301"=>"\u00D3",
- "O\u0302"=>"\u00D4",
- "O\u0303"=>"\u00D5",
- "O\u0308"=>"\u00D6",
- "U\u0300"=>"\u00D9",
- "U\u0301"=>"\u00DA",
- "U\u0302"=>"\u00DB",
- "U\u0308"=>"\u00DC",
- "Y\u0301"=>"\u00DD",
- "a\u0300"=>"\u00E0",
- "a\u0301"=>"\u00E1",
- "a\u0302"=>"\u00E2",
- "a\u0303"=>"\u00E3",
- "a\u0308"=>"\u00E4",
- "a\u030A"=>"\u00E5",
- "c\u0327"=>"\u00E7",
- "e\u0300"=>"\u00E8",
- "e\u0301"=>"\u00E9",
- "e\u0302"=>"\u00EA",
- "e\u0308"=>"\u00EB",
- "i\u0300"=>"\u00EC",
- "i\u0301"=>"\u00ED",
- "i\u0302"=>"\u00EE",
- "i\u0308"=>"\u00EF",
- "n\u0303"=>"\u00F1",
- "o\u0300"=>"\u00F2",
- "o\u0301"=>"\u00F3",
- "o\u0302"=>"\u00F4",
- "o\u0303"=>"\u00F5",
- "o\u0308"=>"\u00F6",
- "u\u0300"=>"\u00F9",
- "u\u0301"=>"\u00FA",
- "u\u0302"=>"\u00FB",
- "u\u0308"=>"\u00FC",
- "y\u0301"=>"\u00FD",
- "y\u0308"=>"\u00FF",
- "A\u0304"=>"\u0100",
- "a\u0304"=>"\u0101",
- "A\u0306"=>"\u0102",
- "a\u0306"=>"\u0103",
- "A\u0328"=>"\u0104",
- "a\u0328"=>"\u0105",
- "C\u0301"=>"\u0106",
- "c\u0301"=>"\u0107",
- "C\u0302"=>"\u0108",
- "c\u0302"=>"\u0109",
- "C\u0307"=>"\u010A",
- "c\u0307"=>"\u010B",
- "C\u030C"=>"\u010C",
- "c\u030C"=>"\u010D",
- "D\u030C"=>"\u010E",
- "d\u030C"=>"\u010F",
- "E\u0304"=>"\u0112",
- "e\u0304"=>"\u0113",
- "E\u0306"=>"\u0114",
- "e\u0306"=>"\u0115",
- "E\u0307"=>"\u0116",
- "e\u0307"=>"\u0117",
- "E\u0328"=>"\u0118",
- "e\u0328"=>"\u0119",
- "E\u030C"=>"\u011A",
- "e\u030C"=>"\u011B",
- "G\u0302"=>"\u011C",
- "g\u0302"=>"\u011D",
- "G\u0306"=>"\u011E",
- "g\u0306"=>"\u011F",
- "G\u0307"=>"\u0120",
- "g\u0307"=>"\u0121",
- "G\u0327"=>"\u0122",
- "g\u0327"=>"\u0123",
- "H\u0302"=>"\u0124",
- "h\u0302"=>"\u0125",
- "I\u0303"=>"\u0128",
- "i\u0303"=>"\u0129",
- "I\u0304"=>"\u012A",
- "i\u0304"=>"\u012B",
- "I\u0306"=>"\u012C",
- "i\u0306"=>"\u012D",
- "I\u0328"=>"\u012E",
- "i\u0328"=>"\u012F",
- "I\u0307"=>"\u0130",
- "J\u0302"=>"\u0134",
- "j\u0302"=>"\u0135",
- "K\u0327"=>"\u0136",
- "k\u0327"=>"\u0137",
- "L\u0301"=>"\u0139",
- "l\u0301"=>"\u013A",
- "L\u0327"=>"\u013B",
- "l\u0327"=>"\u013C",
- "L\u030C"=>"\u013D",
- "l\u030C"=>"\u013E",
- "N\u0301"=>"\u0143",
- "n\u0301"=>"\u0144",
- "N\u0327"=>"\u0145",
- "n\u0327"=>"\u0146",
- "N\u030C"=>"\u0147",
- "n\u030C"=>"\u0148",
- "O\u0304"=>"\u014C",
- "o\u0304"=>"\u014D",
- "O\u0306"=>"\u014E",
- "o\u0306"=>"\u014F",
- "O\u030B"=>"\u0150",
- "o\u030B"=>"\u0151",
- "R\u0301"=>"\u0154",
- "r\u0301"=>"\u0155",
- "R\u0327"=>"\u0156",
- "r\u0327"=>"\u0157",
- "R\u030C"=>"\u0158",
- "r\u030C"=>"\u0159",
- "S\u0301"=>"\u015A",
- "s\u0301"=>"\u015B",
- "S\u0302"=>"\u015C",
- "s\u0302"=>"\u015D",
- "S\u0327"=>"\u015E",
- "s\u0327"=>"\u015F",
- "S\u030C"=>"\u0160",
- "s\u030C"=>"\u0161",
- "T\u0327"=>"\u0162",
- "t\u0327"=>"\u0163",
- "T\u030C"=>"\u0164",
- "t\u030C"=>"\u0165",
- "U\u0303"=>"\u0168",
- "u\u0303"=>"\u0169",
- "U\u0304"=>"\u016A",
- "u\u0304"=>"\u016B",
- "U\u0306"=>"\u016C",
- "u\u0306"=>"\u016D",
- "U\u030A"=>"\u016E",
- "u\u030A"=>"\u016F",
- "U\u030B"=>"\u0170",
- "u\u030B"=>"\u0171",
- "U\u0328"=>"\u0172",
- "u\u0328"=>"\u0173",
- "W\u0302"=>"\u0174",
- "w\u0302"=>"\u0175",
- "Y\u0302"=>"\u0176",
- "y\u0302"=>"\u0177",
- "Y\u0308"=>"\u0178",
- "Z\u0301"=>"\u0179",
- "z\u0301"=>"\u017A",
- "Z\u0307"=>"\u017B",
- "z\u0307"=>"\u017C",
- "Z\u030C"=>"\u017D",
- "z\u030C"=>"\u017E",
- "O\u031B"=>"\u01A0",
- "o\u031B"=>"\u01A1",
- "U\u031B"=>"\u01AF",
- "u\u031B"=>"\u01B0",
- "A\u030C"=>"\u01CD",
- "a\u030C"=>"\u01CE",
- "I\u030C"=>"\u01CF",
- "i\u030C"=>"\u01D0",
- "O\u030C"=>"\u01D1",
- "o\u030C"=>"\u01D2",
- "U\u030C"=>"\u01D3",
- "u\u030C"=>"\u01D4",
- "\u00DC\u0304"=>"\u01D5",
- "\u00FC\u0304"=>"\u01D6",
- "\u00DC\u0301"=>"\u01D7",
- "\u00FC\u0301"=>"\u01D8",
- "\u00DC\u030C"=>"\u01D9",
- "\u00FC\u030C"=>"\u01DA",
- "\u00DC\u0300"=>"\u01DB",
- "\u00FC\u0300"=>"\u01DC",
- "\u00C4\u0304"=>"\u01DE",
- "\u00E4\u0304"=>"\u01DF",
- "\u0226\u0304"=>"\u01E0",
- "\u0227\u0304"=>"\u01E1",
- "\u00C6\u0304"=>"\u01E2",
- "\u00E6\u0304"=>"\u01E3",
- "G\u030C"=>"\u01E6",
- "g\u030C"=>"\u01E7",
- "K\u030C"=>"\u01E8",
- "k\u030C"=>"\u01E9",
- "O\u0328"=>"\u01EA",
- "o\u0328"=>"\u01EB",
- "\u01EA\u0304"=>"\u01EC",
- "\u01EB\u0304"=>"\u01ED",
- "\u01B7\u030C"=>"\u01EE",
- "\u0292\u030C"=>"\u01EF",
- "j\u030C"=>"\u01F0",
- "G\u0301"=>"\u01F4",
- "g\u0301"=>"\u01F5",
- "N\u0300"=>"\u01F8",
- "n\u0300"=>"\u01F9",
- "\u00C5\u0301"=>"\u01FA",
- "\u00E5\u0301"=>"\u01FB",
- "\u00C6\u0301"=>"\u01FC",
- "\u00E6\u0301"=>"\u01FD",
- "\u00D8\u0301"=>"\u01FE",
- "\u00F8\u0301"=>"\u01FF",
- "A\u030F"=>"\u0200",
- "a\u030F"=>"\u0201",
- "A\u0311"=>"\u0202",
- "a\u0311"=>"\u0203",
- "E\u030F"=>"\u0204",
- "e\u030F"=>"\u0205",
- "E\u0311"=>"\u0206",
- "e\u0311"=>"\u0207",
- "I\u030F"=>"\u0208",
- "i\u030F"=>"\u0209",
- "I\u0311"=>"\u020A",
- "i\u0311"=>"\u020B",
- "O\u030F"=>"\u020C",
- "o\u030F"=>"\u020D",
- "O\u0311"=>"\u020E",
- "o\u0311"=>"\u020F",
- "R\u030F"=>"\u0210",
- "r\u030F"=>"\u0211",
- "R\u0311"=>"\u0212",
- "r\u0311"=>"\u0213",
- "U\u030F"=>"\u0214",
- "u\u030F"=>"\u0215",
- "U\u0311"=>"\u0216",
- "u\u0311"=>"\u0217",
- "S\u0326"=>"\u0218",
- "s\u0326"=>"\u0219",
- "T\u0326"=>"\u021A",
- "t\u0326"=>"\u021B",
- "H\u030C"=>"\u021E",
- "h\u030C"=>"\u021F",
- "A\u0307"=>"\u0226",
- "a\u0307"=>"\u0227",
- "E\u0327"=>"\u0228",
- "e\u0327"=>"\u0229",
- "\u00D6\u0304"=>"\u022A",
- "\u00F6\u0304"=>"\u022B",
- "\u00D5\u0304"=>"\u022C",
- "\u00F5\u0304"=>"\u022D",
- "O\u0307"=>"\u022E",
- "o\u0307"=>"\u022F",
- "\u022E\u0304"=>"\u0230",
- "\u022F\u0304"=>"\u0231",
- "Y\u0304"=>"\u0232",
- "y\u0304"=>"\u0233",
- "\u00A8\u0301"=>"\u0385",
- "\u0391\u0301"=>"\u0386",
- "\u0395\u0301"=>"\u0388",
- "\u0397\u0301"=>"\u0389",
- "\u0399\u0301"=>"\u038A",
- "\u039F\u0301"=>"\u038C",
- "\u03A5\u0301"=>"\u038E",
- "\u03A9\u0301"=>"\u038F",
- "\u03CA\u0301"=>"\u0390",
- "\u0399\u0308"=>"\u03AA",
- "\u03A5\u0308"=>"\u03AB",
- "\u03B1\u0301"=>"\u03AC",
- "\u03B5\u0301"=>"\u03AD",
- "\u03B7\u0301"=>"\u03AE",
- "\u03B9\u0301"=>"\u03AF",
- "\u03CB\u0301"=>"\u03B0",
- "\u03B9\u0308"=>"\u03CA",
- "\u03C5\u0308"=>"\u03CB",
- "\u03BF\u0301"=>"\u03CC",
- "\u03C5\u0301"=>"\u03CD",
- "\u03C9\u0301"=>"\u03CE",
- "\u03D2\u0301"=>"\u03D3",
- "\u03D2\u0308"=>"\u03D4",
- "\u0415\u0300"=>"\u0400",
- "\u0415\u0308"=>"\u0401",
- "\u0413\u0301"=>"\u0403",
- "\u0406\u0308"=>"\u0407",
- "\u041A\u0301"=>"\u040C",
- "\u0418\u0300"=>"\u040D",
- "\u0423\u0306"=>"\u040E",
- "\u0418\u0306"=>"\u0419",
- "\u0438\u0306"=>"\u0439",
- "\u0435\u0300"=>"\u0450",
- "\u0435\u0308"=>"\u0451",
- "\u0433\u0301"=>"\u0453",
- "\u0456\u0308"=>"\u0457",
- "\u043A\u0301"=>"\u045C",
- "\u0438\u0300"=>"\u045D",
- "\u0443\u0306"=>"\u045E",
- "\u0474\u030F"=>"\u0476",
- "\u0475\u030F"=>"\u0477",
- "\u0416\u0306"=>"\u04C1",
- "\u0436\u0306"=>"\u04C2",
- "\u0410\u0306"=>"\u04D0",
- "\u0430\u0306"=>"\u04D1",
- "\u0410\u0308"=>"\u04D2",
- "\u0430\u0308"=>"\u04D3",
- "\u0415\u0306"=>"\u04D6",
- "\u0435\u0306"=>"\u04D7",
- "\u04D8\u0308"=>"\u04DA",
- "\u04D9\u0308"=>"\u04DB",
- "\u0416\u0308"=>"\u04DC",
- "\u0436\u0308"=>"\u04DD",
- "\u0417\u0308"=>"\u04DE",
- "\u0437\u0308"=>"\u04DF",
- "\u0418\u0304"=>"\u04E2",
- "\u0438\u0304"=>"\u04E3",
- "\u0418\u0308"=>"\u04E4",
- "\u0438\u0308"=>"\u04E5",
- "\u041E\u0308"=>"\u04E6",
- "\u043E\u0308"=>"\u04E7",
- "\u04E8\u0308"=>"\u04EA",
- "\u04E9\u0308"=>"\u04EB",
- "\u042D\u0308"=>"\u04EC",
- "\u044D\u0308"=>"\u04ED",
- "\u0423\u0304"=>"\u04EE",
- "\u0443\u0304"=>"\u04EF",
- "\u0423\u0308"=>"\u04F0",
- "\u0443\u0308"=>"\u04F1",
- "\u0423\u030B"=>"\u04F2",
- "\u0443\u030B"=>"\u04F3",
- "\u0427\u0308"=>"\u04F4",
- "\u0447\u0308"=>"\u04F5",
- "\u042B\u0308"=>"\u04F8",
- "\u044B\u0308"=>"\u04F9",
- "\u0627\u0653"=>"\u0622",
- "\u0627\u0654"=>"\u0623",
- "\u0648\u0654"=>"\u0624",
- "\u0627\u0655"=>"\u0625",
- "\u064A\u0654"=>"\u0626",
- "\u06D5\u0654"=>"\u06C0",
- "\u06C1\u0654"=>"\u06C2",
- "\u06D2\u0654"=>"\u06D3",
- "\u0928\u093C"=>"\u0929",
- "\u0930\u093C"=>"\u0931",
- "\u0933\u093C"=>"\u0934",
- "\u09C7\u09BE"=>"\u09CB",
- "\u09C7\u09D7"=>"\u09CC",
- "\u0B47\u0B56"=>"\u0B48",
- "\u0B47\u0B3E"=>"\u0B4B",
- "\u0B47\u0B57"=>"\u0B4C",
- "\u0B92\u0BD7"=>"\u0B94",
- "\u0BC6\u0BBE"=>"\u0BCA",
- "\u0BC7\u0BBE"=>"\u0BCB",
- "\u0BC6\u0BD7"=>"\u0BCC",
- "\u0C46\u0C56"=>"\u0C48",
- "\u0CBF\u0CD5"=>"\u0CC0",
- "\u0CC6\u0CD5"=>"\u0CC7",
- "\u0CC6\u0CD6"=>"\u0CC8",
- "\u0CC6\u0CC2"=>"\u0CCA",
- "\u0CCA\u0CD5"=>"\u0CCB",
- "\u0D46\u0D3E"=>"\u0D4A",
- "\u0D47\u0D3E"=>"\u0D4B",
- "\u0D46\u0D57"=>"\u0D4C",
- "\u0DD9\u0DCA"=>"\u0DDA",
- "\u0DD9\u0DCF"=>"\u0DDC",
- "\u0DDC\u0DCA"=>"\u0DDD",
- "\u0DD9\u0DDF"=>"\u0DDE",
- "\u1025\u102E"=>"\u1026",
- "\u1B05\u1B35"=>"\u1B06",
- "\u1B07\u1B35"=>"\u1B08",
- "\u1B09\u1B35"=>"\u1B0A",
- "\u1B0B\u1B35"=>"\u1B0C",
- "\u1B0D\u1B35"=>"\u1B0E",
- "\u1B11\u1B35"=>"\u1B12",
- "\u1B3A\u1B35"=>"\u1B3B",
- "\u1B3C\u1B35"=>"\u1B3D",
- "\u1B3E\u1B35"=>"\u1B40",
- "\u1B3F\u1B35"=>"\u1B41",
- "\u1B42\u1B35"=>"\u1B43",
- "A\u0325"=>"\u1E00",
- "a\u0325"=>"\u1E01",
- "B\u0307"=>"\u1E02",
- "b\u0307"=>"\u1E03",
- "B\u0323"=>"\u1E04",
- "b\u0323"=>"\u1E05",
- "B\u0331"=>"\u1E06",
- "b\u0331"=>"\u1E07",
- "\u00C7\u0301"=>"\u1E08",
- "\u00E7\u0301"=>"\u1E09",
- "D\u0307"=>"\u1E0A",
- "d\u0307"=>"\u1E0B",
- "D\u0323"=>"\u1E0C",
- "d\u0323"=>"\u1E0D",
- "D\u0331"=>"\u1E0E",
- "d\u0331"=>"\u1E0F",
- "D\u0327"=>"\u1E10",
- "d\u0327"=>"\u1E11",
- "D\u032D"=>"\u1E12",
- "d\u032D"=>"\u1E13",
- "\u0112\u0300"=>"\u1E14",
- "\u0113\u0300"=>"\u1E15",
- "\u0112\u0301"=>"\u1E16",
- "\u0113\u0301"=>"\u1E17",
- "E\u032D"=>"\u1E18",
- "e\u032D"=>"\u1E19",
- "E\u0330"=>"\u1E1A",
- "e\u0330"=>"\u1E1B",
- "\u0228\u0306"=>"\u1E1C",
- "\u0229\u0306"=>"\u1E1D",
- "F\u0307"=>"\u1E1E",
- "f\u0307"=>"\u1E1F",
- "G\u0304"=>"\u1E20",
- "g\u0304"=>"\u1E21",
- "H\u0307"=>"\u1E22",
- "h\u0307"=>"\u1E23",
- "H\u0323"=>"\u1E24",
- "h\u0323"=>"\u1E25",
- "H\u0308"=>"\u1E26",
- "h\u0308"=>"\u1E27",
- "H\u0327"=>"\u1E28",
- "h\u0327"=>"\u1E29",
- "H\u032E"=>"\u1E2A",
- "h\u032E"=>"\u1E2B",
- "I\u0330"=>"\u1E2C",
- "i\u0330"=>"\u1E2D",
- "\u00CF\u0301"=>"\u1E2E",
- "\u00EF\u0301"=>"\u1E2F",
- "K\u0301"=>"\u1E30",
- "k\u0301"=>"\u1E31",
- "K\u0323"=>"\u1E32",
- "k\u0323"=>"\u1E33",
- "K\u0331"=>"\u1E34",
- "k\u0331"=>"\u1E35",
- "L\u0323"=>"\u1E36",
- "l\u0323"=>"\u1E37",
- "\u1E36\u0304"=>"\u1E38",
- "\u1E37\u0304"=>"\u1E39",
- "L\u0331"=>"\u1E3A",
- "l\u0331"=>"\u1E3B",
- "L\u032D"=>"\u1E3C",
- "l\u032D"=>"\u1E3D",
- "M\u0301"=>"\u1E3E",
- "m\u0301"=>"\u1E3F",
- "M\u0307"=>"\u1E40",
- "m\u0307"=>"\u1E41",
- "M\u0323"=>"\u1E42",
- "m\u0323"=>"\u1E43",
- "N\u0307"=>"\u1E44",
- "n\u0307"=>"\u1E45",
- "N\u0323"=>"\u1E46",
- "n\u0323"=>"\u1E47",
- "N\u0331"=>"\u1E48",
- "n\u0331"=>"\u1E49",
- "N\u032D"=>"\u1E4A",
- "n\u032D"=>"\u1E4B",
- "\u00D5\u0301"=>"\u1E4C",
- "\u00F5\u0301"=>"\u1E4D",
- "\u00D5\u0308"=>"\u1E4E",
- "\u00F5\u0308"=>"\u1E4F",
- "\u014C\u0300"=>"\u1E50",
- "\u014D\u0300"=>"\u1E51",
- "\u014C\u0301"=>"\u1E52",
- "\u014D\u0301"=>"\u1E53",
- "P\u0301"=>"\u1E54",
- "p\u0301"=>"\u1E55",
- "P\u0307"=>"\u1E56",
- "p\u0307"=>"\u1E57",
- "R\u0307"=>"\u1E58",
- "r\u0307"=>"\u1E59",
- "R\u0323"=>"\u1E5A",
- "r\u0323"=>"\u1E5B",
- "\u1E5A\u0304"=>"\u1E5C",
- "\u1E5B\u0304"=>"\u1E5D",
- "R\u0331"=>"\u1E5E",
- "r\u0331"=>"\u1E5F",
- "S\u0307"=>"\u1E60",
- "s\u0307"=>"\u1E61",
- "S\u0323"=>"\u1E62",
- "s\u0323"=>"\u1E63",
- "\u015A\u0307"=>"\u1E64",
- "\u015B\u0307"=>"\u1E65",
- "\u0160\u0307"=>"\u1E66",
- "\u0161\u0307"=>"\u1E67",
- "\u1E62\u0307"=>"\u1E68",
- "\u1E63\u0307"=>"\u1E69",
- "T\u0307"=>"\u1E6A",
- "t\u0307"=>"\u1E6B",
- "T\u0323"=>"\u1E6C",
- "t\u0323"=>"\u1E6D",
- "T\u0331"=>"\u1E6E",
- "t\u0331"=>"\u1E6F",
- "T\u032D"=>"\u1E70",
- "t\u032D"=>"\u1E71",
- "U\u0324"=>"\u1E72",
- "u\u0324"=>"\u1E73",
- "U\u0330"=>"\u1E74",
- "u\u0330"=>"\u1E75",
- "U\u032D"=>"\u1E76",
- "u\u032D"=>"\u1E77",
- "\u0168\u0301"=>"\u1E78",
- "\u0169\u0301"=>"\u1E79",
- "\u016A\u0308"=>"\u1E7A",
- "\u016B\u0308"=>"\u1E7B",
- "V\u0303"=>"\u1E7C",
- "v\u0303"=>"\u1E7D",
- "V\u0323"=>"\u1E7E",
- "v\u0323"=>"\u1E7F",
- "W\u0300"=>"\u1E80",
- "w\u0300"=>"\u1E81",
- "W\u0301"=>"\u1E82",
- "w\u0301"=>"\u1E83",
- "W\u0308"=>"\u1E84",
- "w\u0308"=>"\u1E85",
- "W\u0307"=>"\u1E86",
- "w\u0307"=>"\u1E87",
- "W\u0323"=>"\u1E88",
- "w\u0323"=>"\u1E89",
- "X\u0307"=>"\u1E8A",
- "x\u0307"=>"\u1E8B",
- "X\u0308"=>"\u1E8C",
- "x\u0308"=>"\u1E8D",
- "Y\u0307"=>"\u1E8E",
- "y\u0307"=>"\u1E8F",
- "Z\u0302"=>"\u1E90",
- "z\u0302"=>"\u1E91",
- "Z\u0323"=>"\u1E92",
- "z\u0323"=>"\u1E93",
- "Z\u0331"=>"\u1E94",
- "z\u0331"=>"\u1E95",
- "h\u0331"=>"\u1E96",
- "t\u0308"=>"\u1E97",
- "w\u030A"=>"\u1E98",
- "y\u030A"=>"\u1E99",
- "\u017F\u0307"=>"\u1E9B",
- "A\u0323"=>"\u1EA0",
- "a\u0323"=>"\u1EA1",
- "A\u0309"=>"\u1EA2",
- "a\u0309"=>"\u1EA3",
- "\u00C2\u0301"=>"\u1EA4",
- "\u00E2\u0301"=>"\u1EA5",
- "\u00C2\u0300"=>"\u1EA6",
- "\u00E2\u0300"=>"\u1EA7",
- "\u00C2\u0309"=>"\u1EA8",
- "\u00E2\u0309"=>"\u1EA9",
- "\u00C2\u0303"=>"\u1EAA",
- "\u00E2\u0303"=>"\u1EAB",
- "\u1EA0\u0302"=>"\u1EAC",
- "\u1EA1\u0302"=>"\u1EAD",
- "\u0102\u0301"=>"\u1EAE",
- "\u0103\u0301"=>"\u1EAF",
- "\u0102\u0300"=>"\u1EB0",
- "\u0103\u0300"=>"\u1EB1",
- "\u0102\u0309"=>"\u1EB2",
- "\u0103\u0309"=>"\u1EB3",
- "\u0102\u0303"=>"\u1EB4",
- "\u0103\u0303"=>"\u1EB5",
- "\u1EA0\u0306"=>"\u1EB6",
- "\u1EA1\u0306"=>"\u1EB7",
- "E\u0323"=>"\u1EB8",
- "e\u0323"=>"\u1EB9",
- "E\u0309"=>"\u1EBA",
- "e\u0309"=>"\u1EBB",
- "E\u0303"=>"\u1EBC",
- "e\u0303"=>"\u1EBD",
- "\u00CA\u0301"=>"\u1EBE",
- "\u00EA\u0301"=>"\u1EBF",
- "\u00CA\u0300"=>"\u1EC0",
- "\u00EA\u0300"=>"\u1EC1",
- "\u00CA\u0309"=>"\u1EC2",
- "\u00EA\u0309"=>"\u1EC3",
- "\u00CA\u0303"=>"\u1EC4",
- "\u00EA\u0303"=>"\u1EC5",
- "\u1EB8\u0302"=>"\u1EC6",
- "\u1EB9\u0302"=>"\u1EC7",
- "I\u0309"=>"\u1EC8",
- "i\u0309"=>"\u1EC9",
- "I\u0323"=>"\u1ECA",
- "i\u0323"=>"\u1ECB",
- "O\u0323"=>"\u1ECC",
- "o\u0323"=>"\u1ECD",
- "O\u0309"=>"\u1ECE",
- "o\u0309"=>"\u1ECF",
- "\u00D4\u0301"=>"\u1ED0",
- "\u00F4\u0301"=>"\u1ED1",
- "\u00D4\u0300"=>"\u1ED2",
- "\u00F4\u0300"=>"\u1ED3",
- "\u00D4\u0309"=>"\u1ED4",
- "\u00F4\u0309"=>"\u1ED5",
- "\u00D4\u0303"=>"\u1ED6",
- "\u00F4\u0303"=>"\u1ED7",
- "\u1ECC\u0302"=>"\u1ED8",
- "\u1ECD\u0302"=>"\u1ED9",
- "\u01A0\u0301"=>"\u1EDA",
- "\u01A1\u0301"=>"\u1EDB",
- "\u01A0\u0300"=>"\u1EDC",
- "\u01A1\u0300"=>"\u1EDD",
- "\u01A0\u0309"=>"\u1EDE",
- "\u01A1\u0309"=>"\u1EDF",
- "\u01A0\u0303"=>"\u1EE0",
- "\u01A1\u0303"=>"\u1EE1",
- "\u01A0\u0323"=>"\u1EE2",
- "\u01A1\u0323"=>"\u1EE3",
- "U\u0323"=>"\u1EE4",
- "u\u0323"=>"\u1EE5",
- "U\u0309"=>"\u1EE6",
- "u\u0309"=>"\u1EE7",
- "\u01AF\u0301"=>"\u1EE8",
- "\u01B0\u0301"=>"\u1EE9",
- "\u01AF\u0300"=>"\u1EEA",
- "\u01B0\u0300"=>"\u1EEB",
- "\u01AF\u0309"=>"\u1EEC",
- "\u01B0\u0309"=>"\u1EED",
- "\u01AF\u0303"=>"\u1EEE",
- "\u01B0\u0303"=>"\u1EEF",
- "\u01AF\u0323"=>"\u1EF0",
- "\u01B0\u0323"=>"\u1EF1",
- "Y\u0300"=>"\u1EF2",
- "y\u0300"=>"\u1EF3",
- "Y\u0323"=>"\u1EF4",
- "y\u0323"=>"\u1EF5",
- "Y\u0309"=>"\u1EF6",
- "y\u0309"=>"\u1EF7",
- "Y\u0303"=>"\u1EF8",
- "y\u0303"=>"\u1EF9",
- "\u03B1\u0313"=>"\u1F00",
- "\u03B1\u0314"=>"\u1F01",
- "\u1F00\u0300"=>"\u1F02",
- "\u1F01\u0300"=>"\u1F03",
- "\u1F00\u0301"=>"\u1F04",
- "\u1F01\u0301"=>"\u1F05",
- "\u1F00\u0342"=>"\u1F06",
- "\u1F01\u0342"=>"\u1F07",
- "\u0391\u0313"=>"\u1F08",
- "\u0391\u0314"=>"\u1F09",
- "\u1F08\u0300"=>"\u1F0A",
- "\u1F09\u0300"=>"\u1F0B",
- "\u1F08\u0301"=>"\u1F0C",
- "\u1F09\u0301"=>"\u1F0D",
- "\u1F08\u0342"=>"\u1F0E",
- "\u1F09\u0342"=>"\u1F0F",
- "\u03B5\u0313"=>"\u1F10",
- "\u03B5\u0314"=>"\u1F11",
- "\u1F10\u0300"=>"\u1F12",
- "\u1F11\u0300"=>"\u1F13",
- "\u1F10\u0301"=>"\u1F14",
- "\u1F11\u0301"=>"\u1F15",
- "\u0395\u0313"=>"\u1F18",
- "\u0395\u0314"=>"\u1F19",
- "\u1F18\u0300"=>"\u1F1A",
- "\u1F19\u0300"=>"\u1F1B",
- "\u1F18\u0301"=>"\u1F1C",
- "\u1F19\u0301"=>"\u1F1D",
- "\u03B7\u0313"=>"\u1F20",
- "\u03B7\u0314"=>"\u1F21",
- "\u1F20\u0300"=>"\u1F22",
- "\u1F21\u0300"=>"\u1F23",
- "\u1F20\u0301"=>"\u1F24",
- "\u1F21\u0301"=>"\u1F25",
- "\u1F20\u0342"=>"\u1F26",
- "\u1F21\u0342"=>"\u1F27",
- "\u0397\u0313"=>"\u1F28",
- "\u0397\u0314"=>"\u1F29",
- "\u1F28\u0300"=>"\u1F2A",
- "\u1F29\u0300"=>"\u1F2B",
- "\u1F28\u0301"=>"\u1F2C",
- "\u1F29\u0301"=>"\u1F2D",
- "\u1F28\u0342"=>"\u1F2E",
- "\u1F29\u0342"=>"\u1F2F",
- "\u03B9\u0313"=>"\u1F30",
- "\u03B9\u0314"=>"\u1F31",
- "\u1F30\u0300"=>"\u1F32",
- "\u1F31\u0300"=>"\u1F33",
- "\u1F30\u0301"=>"\u1F34",
- "\u1F31\u0301"=>"\u1F35",
- "\u1F30\u0342"=>"\u1F36",
- "\u1F31\u0342"=>"\u1F37",
- "\u0399\u0313"=>"\u1F38",
- "\u0399\u0314"=>"\u1F39",
- "\u1F38\u0300"=>"\u1F3A",
- "\u1F39\u0300"=>"\u1F3B",
- "\u1F38\u0301"=>"\u1F3C",
- "\u1F39\u0301"=>"\u1F3D",
- "\u1F38\u0342"=>"\u1F3E",
- "\u1F39\u0342"=>"\u1F3F",
- "\u03BF\u0313"=>"\u1F40",
- "\u03BF\u0314"=>"\u1F41",
- "\u1F40\u0300"=>"\u1F42",
- "\u1F41\u0300"=>"\u1F43",
- "\u1F40\u0301"=>"\u1F44",
- "\u1F41\u0301"=>"\u1F45",
- "\u039F\u0313"=>"\u1F48",
- "\u039F\u0314"=>"\u1F49",
- "\u1F48\u0300"=>"\u1F4A",
- "\u1F49\u0300"=>"\u1F4B",
- "\u1F48\u0301"=>"\u1F4C",
- "\u1F49\u0301"=>"\u1F4D",
- "\u03C5\u0313"=>"\u1F50",
- "\u03C5\u0314"=>"\u1F51",
- "\u1F50\u0300"=>"\u1F52",
- "\u1F51\u0300"=>"\u1F53",
- "\u1F50\u0301"=>"\u1F54",
- "\u1F51\u0301"=>"\u1F55",
- "\u1F50\u0342"=>"\u1F56",
- "\u1F51\u0342"=>"\u1F57",
- "\u03A5\u0314"=>"\u1F59",
- "\u1F59\u0300"=>"\u1F5B",
- "\u1F59\u0301"=>"\u1F5D",
- "\u1F59\u0342"=>"\u1F5F",
- "\u03C9\u0313"=>"\u1F60",
- "\u03C9\u0314"=>"\u1F61",
- "\u1F60\u0300"=>"\u1F62",
- "\u1F61\u0300"=>"\u1F63",
- "\u1F60\u0301"=>"\u1F64",
- "\u1F61\u0301"=>"\u1F65",
- "\u1F60\u0342"=>"\u1F66",
- "\u1F61\u0342"=>"\u1F67",
- "\u03A9\u0313"=>"\u1F68",
- "\u03A9\u0314"=>"\u1F69",
- "\u1F68\u0300"=>"\u1F6A",
- "\u1F69\u0300"=>"\u1F6B",
- "\u1F68\u0301"=>"\u1F6C",
- "\u1F69\u0301"=>"\u1F6D",
- "\u1F68\u0342"=>"\u1F6E",
- "\u1F69\u0342"=>"\u1F6F",
- "\u03B1\u0300"=>"\u1F70",
- "\u03B5\u0300"=>"\u1F72",
- "\u03B7\u0300"=>"\u1F74",
- "\u03B9\u0300"=>"\u1F76",
- "\u03BF\u0300"=>"\u1F78",
- "\u03C5\u0300"=>"\u1F7A",
- "\u03C9\u0300"=>"\u1F7C",
- "\u1F00\u0345"=>"\u1F80",
- "\u1F01\u0345"=>"\u1F81",
- "\u1F02\u0345"=>"\u1F82",
- "\u1F03\u0345"=>"\u1F83",
- "\u1F04\u0345"=>"\u1F84",
- "\u1F05\u0345"=>"\u1F85",
- "\u1F06\u0345"=>"\u1F86",
- "\u1F07\u0345"=>"\u1F87",
- "\u1F08\u0345"=>"\u1F88",
- "\u1F09\u0345"=>"\u1F89",
- "\u1F0A\u0345"=>"\u1F8A",
- "\u1F0B\u0345"=>"\u1F8B",
- "\u1F0C\u0345"=>"\u1F8C",
- "\u1F0D\u0345"=>"\u1F8D",
- "\u1F0E\u0345"=>"\u1F8E",
- "\u1F0F\u0345"=>"\u1F8F",
- "\u1F20\u0345"=>"\u1F90",
- "\u1F21\u0345"=>"\u1F91",
- "\u1F22\u0345"=>"\u1F92",
- "\u1F23\u0345"=>"\u1F93",
- "\u1F24\u0345"=>"\u1F94",
- "\u1F25\u0345"=>"\u1F95",
- "\u1F26\u0345"=>"\u1F96",
- "\u1F27\u0345"=>"\u1F97",
- "\u1F28\u0345"=>"\u1F98",
- "\u1F29\u0345"=>"\u1F99",
- "\u1F2A\u0345"=>"\u1F9A",
- "\u1F2B\u0345"=>"\u1F9B",
- "\u1F2C\u0345"=>"\u1F9C",
- "\u1F2D\u0345"=>"\u1F9D",
- "\u1F2E\u0345"=>"\u1F9E",
- "\u1F2F\u0345"=>"\u1F9F",
- "\u1F60\u0345"=>"\u1FA0",
- "\u1F61\u0345"=>"\u1FA1",
- "\u1F62\u0345"=>"\u1FA2",
- "\u1F63\u0345"=>"\u1FA3",
- "\u1F64\u0345"=>"\u1FA4",
- "\u1F65\u0345"=>"\u1FA5",
- "\u1F66\u0345"=>"\u1FA6",
- "\u1F67\u0345"=>"\u1FA7",
- "\u1F68\u0345"=>"\u1FA8",
- "\u1F69\u0345"=>"\u1FA9",
- "\u1F6A\u0345"=>"\u1FAA",
- "\u1F6B\u0345"=>"\u1FAB",
- "\u1F6C\u0345"=>"\u1FAC",
- "\u1F6D\u0345"=>"\u1FAD",
- "\u1F6E\u0345"=>"\u1FAE",
- "\u1F6F\u0345"=>"\u1FAF",
- "\u03B1\u0306"=>"\u1FB0",
- "\u03B1\u0304"=>"\u1FB1",
- "\u1F70\u0345"=>"\u1FB2",
- "\u03B1\u0345"=>"\u1FB3",
- "\u03AC\u0345"=>"\u1FB4",
- "\u03B1\u0342"=>"\u1FB6",
- "\u1FB6\u0345"=>"\u1FB7",
- "\u0391\u0306"=>"\u1FB8",
- "\u0391\u0304"=>"\u1FB9",
- "\u0391\u0300"=>"\u1FBA",
- "\u0391\u0345"=>"\u1FBC",
- "\u00A8\u0342"=>"\u1FC1",
- "\u1F74\u0345"=>"\u1FC2",
- "\u03B7\u0345"=>"\u1FC3",
- "\u03AE\u0345"=>"\u1FC4",
- "\u03B7\u0342"=>"\u1FC6",
- "\u1FC6\u0345"=>"\u1FC7",
- "\u0395\u0300"=>"\u1FC8",
- "\u0397\u0300"=>"\u1FCA",
- "\u0397\u0345"=>"\u1FCC",
- "\u1FBF\u0300"=>"\u1FCD",
- "\u1FBF\u0301"=>"\u1FCE",
- "\u1FBF\u0342"=>"\u1FCF",
- "\u03B9\u0306"=>"\u1FD0",
- "\u03B9\u0304"=>"\u1FD1",
- "\u03CA\u0300"=>"\u1FD2",
- "\u03B9\u0342"=>"\u1FD6",
- "\u03CA\u0342"=>"\u1FD7",
- "\u0399\u0306"=>"\u1FD8",
- "\u0399\u0304"=>"\u1FD9",
- "\u0399\u0300"=>"\u1FDA",
- "\u1FFE\u0300"=>"\u1FDD",
- "\u1FFE\u0301"=>"\u1FDE",
- "\u1FFE\u0342"=>"\u1FDF",
- "\u03C5\u0306"=>"\u1FE0",
- "\u03C5\u0304"=>"\u1FE1",
- "\u03CB\u0300"=>"\u1FE2",
- "\u03C1\u0313"=>"\u1FE4",
- "\u03C1\u0314"=>"\u1FE5",
- "\u03C5\u0342"=>"\u1FE6",
- "\u03CB\u0342"=>"\u1FE7",
- "\u03A5\u0306"=>"\u1FE8",
- "\u03A5\u0304"=>"\u1FE9",
- "\u03A5\u0300"=>"\u1FEA",
- "\u03A1\u0314"=>"\u1FEC",
- "\u00A8\u0300"=>"\u1FED",
- "\u1F7C\u0345"=>"\u1FF2",
- "\u03C9\u0345"=>"\u1FF3",
- "\u03CE\u0345"=>"\u1FF4",
- "\u03C9\u0342"=>"\u1FF6",
- "\u1FF6\u0345"=>"\u1FF7",
- "\u039F\u0300"=>"\u1FF8",
- "\u03A9\u0300"=>"\u1FFA",
- "\u03A9\u0345"=>"\u1FFC",
- "\u2190\u0338"=>"\u219A",
- "\u2192\u0338"=>"\u219B",
- "\u2194\u0338"=>"\u21AE",
- "\u21D0\u0338"=>"\u21CD",
- "\u21D4\u0338"=>"\u21CE",
- "\u21D2\u0338"=>"\u21CF",
- "\u2203\u0338"=>"\u2204",
- "\u2208\u0338"=>"\u2209",
- "\u220B\u0338"=>"\u220C",
- "\u2223\u0338"=>"\u2224",
- "\u2225\u0338"=>"\u2226",
- "\u223C\u0338"=>"\u2241",
- "\u2243\u0338"=>"\u2244",
- "\u2245\u0338"=>"\u2247",
- "\u2248\u0338"=>"\u2249",
- "=\u0338"=>"\u2260",
- "\u2261\u0338"=>"\u2262",
- "\u224D\u0338"=>"\u226D",
- "<\u0338"=>"\u226E",
- ">\u0338"=>"\u226F",
- "\u2264\u0338"=>"\u2270",
- "\u2265\u0338"=>"\u2271",
- "\u2272\u0338"=>"\u2274",
- "\u2273\u0338"=>"\u2275",
- "\u2276\u0338"=>"\u2278",
- "\u2277\u0338"=>"\u2279",
- "\u227A\u0338"=>"\u2280",
- "\u227B\u0338"=>"\u2281",
- "\u2282\u0338"=>"\u2284",
- "\u2283\u0338"=>"\u2285",
- "\u2286\u0338"=>"\u2288",
- "\u2287\u0338"=>"\u2289",
- "\u22A2\u0338"=>"\u22AC",
- "\u22A8\u0338"=>"\u22AD",
- "\u22A9\u0338"=>"\u22AE",
- "\u22AB\u0338"=>"\u22AF",
- "\u227C\u0338"=>"\u22E0",
- "\u227D\u0338"=>"\u22E1",
- "\u2291\u0338"=>"\u22E2",
- "\u2292\u0338"=>"\u22E3",
- "\u22B2\u0338"=>"\u22EA",
- "\u22B3\u0338"=>"\u22EB",
- "\u22B4\u0338"=>"\u22EC",
- "\u22B5\u0338"=>"\u22ED",
- "\u304B\u3099"=>"\u304C",
- "\u304D\u3099"=>"\u304E",
- "\u304F\u3099"=>"\u3050",
- "\u3051\u3099"=>"\u3052",
- "\u3053\u3099"=>"\u3054",
- "\u3055\u3099"=>"\u3056",
- "\u3057\u3099"=>"\u3058",
- "\u3059\u3099"=>"\u305A",
- "\u305B\u3099"=>"\u305C",
- "\u305D\u3099"=>"\u305E",
- "\u305F\u3099"=>"\u3060",
- "\u3061\u3099"=>"\u3062",
- "\u3064\u3099"=>"\u3065",
- "\u3066\u3099"=>"\u3067",
- "\u3068\u3099"=>"\u3069",
- "\u306F\u3099"=>"\u3070",
- "\u306F\u309A"=>"\u3071",
- "\u3072\u3099"=>"\u3073",
- "\u3072\u309A"=>"\u3074",
- "\u3075\u3099"=>"\u3076",
- "\u3075\u309A"=>"\u3077",
- "\u3078\u3099"=>"\u3079",
- "\u3078\u309A"=>"\u307A",
- "\u307B\u3099"=>"\u307C",
- "\u307B\u309A"=>"\u307D",
- "\u3046\u3099"=>"\u3094",
- "\u309D\u3099"=>"\u309E",
- "\u30AB\u3099"=>"\u30AC",
- "\u30AD\u3099"=>"\u30AE",
- "\u30AF\u3099"=>"\u30B0",
- "\u30B1\u3099"=>"\u30B2",
- "\u30B3\u3099"=>"\u30B4",
- "\u30B5\u3099"=>"\u30B6",
- "\u30B7\u3099"=>"\u30B8",
- "\u30B9\u3099"=>"\u30BA",
- "\u30BB\u3099"=>"\u30BC",
- "\u30BD\u3099"=>"\u30BE",
- "\u30BF\u3099"=>"\u30C0",
- "\u30C1\u3099"=>"\u30C2",
- "\u30C4\u3099"=>"\u30C5",
- "\u30C6\u3099"=>"\u30C7",
- "\u30C8\u3099"=>"\u30C9",
- "\u30CF\u3099"=>"\u30D0",
- "\u30CF\u309A"=>"\u30D1",
- "\u30D2\u3099"=>"\u30D3",
- "\u30D2\u309A"=>"\u30D4",
- "\u30D5\u3099"=>"\u30D6",
- "\u30D5\u309A"=>"\u30D7",
- "\u30D8\u3099"=>"\u30D9",
- "\u30D8\u309A"=>"\u30DA",
- "\u30DB\u3099"=>"\u30DC",
- "\u30DB\u309A"=>"\u30DD",
- "\u30A6\u3099"=>"\u30F4",
- "\u30EF\u3099"=>"\u30F7",
- "\u30F0\u3099"=>"\u30F8",
- "\u30F1\u3099"=>"\u30F9",
- "\u30F2\u3099"=>"\u30FA",
- "\u30FD\u3099"=>"\u30FE",
- "\u{11099}\u{110BA}"=>"\u{1109A}",
- "\u{1109B}\u{110BA}"=>"\u{1109C}",
- "\u{110A5}\u{110BA}"=>"\u{110AB}",
- "\u{11131}\u{11127}"=>"\u{1112E}",
- "\u{11132}\u{11127}"=>"\u{1112F}",
- "\u{11347}\u{1133E}"=>"\u{1134B}",
- "\u{11347}\u{11357}"=>"\u{1134C}",
- "\u{114B9}\u{114BA}"=>"\u{114BB}",
- "\u{114B9}\u{114B0}"=>"\u{114BC}",
- "\u{114B9}\u{114BD}"=>"\u{114BE}",
- "\u{115B8}\u{115AF}"=>"\u{115BA}",
- "\u{115B9}\u{115AF}"=>"\u{115BB}",
+ "A\u0300"=>"\u00C0", "A\u0301"=>"\u00C1", "A\u0302"=>"\u00C2", "A\u0303"=>"\u00C3", "A\u0308"=>"\u00C4", "A\u030A"=>"\u00C5", "C\u0327"=>"\u00C7", "E\u0300"=>"\u00C8",
+ "E\u0301"=>"\u00C9", "E\u0302"=>"\u00CA", "E\u0308"=>"\u00CB", "I\u0300"=>"\u00CC", "I\u0301"=>"\u00CD", "I\u0302"=>"\u00CE", "I\u0308"=>"\u00CF", "N\u0303"=>"\u00D1",
+ "O\u0300"=>"\u00D2", "O\u0301"=>"\u00D3", "O\u0302"=>"\u00D4", "O\u0303"=>"\u00D5", "O\u0308"=>"\u00D6", "U\u0300"=>"\u00D9", "U\u0301"=>"\u00DA", "U\u0302"=>"\u00DB",
+ "U\u0308"=>"\u00DC", "Y\u0301"=>"\u00DD", "a\u0300"=>"\u00E0", "a\u0301"=>"\u00E1", "a\u0302"=>"\u00E2", "a\u0303"=>"\u00E3", "a\u0308"=>"\u00E4", "a\u030A"=>"\u00E5",
+ "c\u0327"=>"\u00E7", "e\u0300"=>"\u00E8", "e\u0301"=>"\u00E9", "e\u0302"=>"\u00EA", "e\u0308"=>"\u00EB", "i\u0300"=>"\u00EC", "i\u0301"=>"\u00ED", "i\u0302"=>"\u00EE",
+ "i\u0308"=>"\u00EF", "n\u0303"=>"\u00F1", "o\u0300"=>"\u00F2", "o\u0301"=>"\u00F3", "o\u0302"=>"\u00F4", "o\u0303"=>"\u00F5", "o\u0308"=>"\u00F6", "u\u0300"=>"\u00F9",
+ "u\u0301"=>"\u00FA", "u\u0302"=>"\u00FB", "u\u0308"=>"\u00FC", "y\u0301"=>"\u00FD", "y\u0308"=>"\u00FF", "A\u0304"=>"\u0100", "a\u0304"=>"\u0101", "A\u0306"=>"\u0102",
+ "a\u0306"=>"\u0103", "A\u0328"=>"\u0104", "a\u0328"=>"\u0105", "C\u0301"=>"\u0106", "c\u0301"=>"\u0107", "C\u0302"=>"\u0108", "c\u0302"=>"\u0109", "C\u0307"=>"\u010A",
+ "c\u0307"=>"\u010B", "C\u030C"=>"\u010C", "c\u030C"=>"\u010D", "D\u030C"=>"\u010E", "d\u030C"=>"\u010F", "E\u0304"=>"\u0112", "e\u0304"=>"\u0113", "E\u0306"=>"\u0114",
+ "e\u0306"=>"\u0115", "E\u0307"=>"\u0116", "e\u0307"=>"\u0117", "E\u0328"=>"\u0118", "e\u0328"=>"\u0119", "E\u030C"=>"\u011A", "e\u030C"=>"\u011B", "G\u0302"=>"\u011C",
+ "g\u0302"=>"\u011D", "G\u0306"=>"\u011E", "g\u0306"=>"\u011F", "G\u0307"=>"\u0120", "g\u0307"=>"\u0121", "G\u0327"=>"\u0122", "g\u0327"=>"\u0123", "H\u0302"=>"\u0124",
+ "h\u0302"=>"\u0125", "I\u0303"=>"\u0128", "i\u0303"=>"\u0129", "I\u0304"=>"\u012A", "i\u0304"=>"\u012B", "I\u0306"=>"\u012C", "i\u0306"=>"\u012D", "I\u0328"=>"\u012E",
+ "i\u0328"=>"\u012F", "I\u0307"=>"\u0130", "J\u0302"=>"\u0134", "j\u0302"=>"\u0135", "K\u0327"=>"\u0136", "k\u0327"=>"\u0137", "L\u0301"=>"\u0139", "l\u0301"=>"\u013A",
+ "L\u0327"=>"\u013B", "l\u0327"=>"\u013C", "L\u030C"=>"\u013D", "l\u030C"=>"\u013E", "N\u0301"=>"\u0143", "n\u0301"=>"\u0144", "N\u0327"=>"\u0145", "n\u0327"=>"\u0146",
+ "N\u030C"=>"\u0147", "n\u030C"=>"\u0148", "O\u0304"=>"\u014C", "o\u0304"=>"\u014D", "O\u0306"=>"\u014E", "o\u0306"=>"\u014F", "O\u030B"=>"\u0150", "o\u030B"=>"\u0151",
+ "R\u0301"=>"\u0154", "r\u0301"=>"\u0155", "R\u0327"=>"\u0156", "r\u0327"=>"\u0157", "R\u030C"=>"\u0158", "r\u030C"=>"\u0159", "S\u0301"=>"\u015A", "s\u0301"=>"\u015B",
+ "S\u0302"=>"\u015C", "s\u0302"=>"\u015D", "S\u0327"=>"\u015E", "s\u0327"=>"\u015F", "S\u030C"=>"\u0160", "s\u030C"=>"\u0161", "T\u0327"=>"\u0162", "t\u0327"=>"\u0163",
+ "T\u030C"=>"\u0164", "t\u030C"=>"\u0165", "U\u0303"=>"\u0168", "u\u0303"=>"\u0169", "U\u0304"=>"\u016A", "u\u0304"=>"\u016B", "U\u0306"=>"\u016C", "u\u0306"=>"\u016D",
+ "U\u030A"=>"\u016E", "u\u030A"=>"\u016F", "U\u030B"=>"\u0170", "u\u030B"=>"\u0171", "U\u0328"=>"\u0172", "u\u0328"=>"\u0173", "W\u0302"=>"\u0174", "w\u0302"=>"\u0175",
+ "Y\u0302"=>"\u0176", "y\u0302"=>"\u0177", "Y\u0308"=>"\u0178", "Z\u0301"=>"\u0179", "z\u0301"=>"\u017A", "Z\u0307"=>"\u017B", "z\u0307"=>"\u017C", "Z\u030C"=>"\u017D",
+ "z\u030C"=>"\u017E", "O\u031B"=>"\u01A0", "o\u031B"=>"\u01A1", "U\u031B"=>"\u01AF", "u\u031B"=>"\u01B0", "A\u030C"=>"\u01CD", "a\u030C"=>"\u01CE", "I\u030C"=>"\u01CF",
+ "i\u030C"=>"\u01D0", "O\u030C"=>"\u01D1", "o\u030C"=>"\u01D2", "U\u030C"=>"\u01D3", "u\u030C"=>"\u01D4", "\u00DC\u0304"=>"\u01D5", "\u00FC\u0304"=>"\u01D6", "\u00DC\u0301"=>"\u01D7",
+ "\u00FC\u0301"=>"\u01D8", "\u00DC\u030C"=>"\u01D9", "\u00FC\u030C"=>"\u01DA", "\u00DC\u0300"=>"\u01DB", "\u00FC\u0300"=>"\u01DC", "\u00C4\u0304"=>"\u01DE", "\u00E4\u0304"=>"\u01DF", "\u0226\u0304"=>"\u01E0",
+ "\u0227\u0304"=>"\u01E1", "\u00C6\u0304"=>"\u01E2", "\u00E6\u0304"=>"\u01E3", "G\u030C"=>"\u01E6", "g\u030C"=>"\u01E7", "K\u030C"=>"\u01E8", "k\u030C"=>"\u01E9", "O\u0328"=>"\u01EA",
+ "o\u0328"=>"\u01EB", "\u01EA\u0304"=>"\u01EC", "\u01EB\u0304"=>"\u01ED", "\u01B7\u030C"=>"\u01EE", "\u0292\u030C"=>"\u01EF", "j\u030C"=>"\u01F0", "G\u0301"=>"\u01F4", "g\u0301"=>"\u01F5",
+ "N\u0300"=>"\u01F8", "n\u0300"=>"\u01F9", "\u00C5\u0301"=>"\u01FA", "\u00E5\u0301"=>"\u01FB", "\u00C6\u0301"=>"\u01FC", "\u00E6\u0301"=>"\u01FD", "\u00D8\u0301"=>"\u01FE", "\u00F8\u0301"=>"\u01FF",
+ "A\u030F"=>"\u0200", "a\u030F"=>"\u0201", "A\u0311"=>"\u0202", "a\u0311"=>"\u0203", "E\u030F"=>"\u0204", "e\u030F"=>"\u0205", "E\u0311"=>"\u0206", "e\u0311"=>"\u0207",
+ "I\u030F"=>"\u0208", "i\u030F"=>"\u0209", "I\u0311"=>"\u020A", "i\u0311"=>"\u020B", "O\u030F"=>"\u020C", "o\u030F"=>"\u020D", "O\u0311"=>"\u020E", "o\u0311"=>"\u020F",
+ "R\u030F"=>"\u0210", "r\u030F"=>"\u0211", "R\u0311"=>"\u0212", "r\u0311"=>"\u0213", "U\u030F"=>"\u0214", "u\u030F"=>"\u0215", "U\u0311"=>"\u0216", "u\u0311"=>"\u0217",
+ "S\u0326"=>"\u0218", "s\u0326"=>"\u0219", "T\u0326"=>"\u021A", "t\u0326"=>"\u021B", "H\u030C"=>"\u021E", "h\u030C"=>"\u021F", "A\u0307"=>"\u0226", "a\u0307"=>"\u0227",
+ "E\u0327"=>"\u0228", "e\u0327"=>"\u0229", "\u00D6\u0304"=>"\u022A", "\u00F6\u0304"=>"\u022B", "\u00D5\u0304"=>"\u022C", "\u00F5\u0304"=>"\u022D", "O\u0307"=>"\u022E", "o\u0307"=>"\u022F",
+ "\u022E\u0304"=>"\u0230", "\u022F\u0304"=>"\u0231", "Y\u0304"=>"\u0232", "y\u0304"=>"\u0233", "\u00A8\u0301"=>"\u0385", "\u0391\u0301"=>"\u0386", "\u0395\u0301"=>"\u0388", "\u0397\u0301"=>"\u0389",
+ "\u0399\u0301"=>"\u038A", "\u039F\u0301"=>"\u038C", "\u03A5\u0301"=>"\u038E", "\u03A9\u0301"=>"\u038F", "\u03CA\u0301"=>"\u0390", "\u0399\u0308"=>"\u03AA", "\u03A5\u0308"=>"\u03AB", "\u03B1\u0301"=>"\u03AC",
+ "\u03B5\u0301"=>"\u03AD", "\u03B7\u0301"=>"\u03AE", "\u03B9\u0301"=>"\u03AF", "\u03CB\u0301"=>"\u03B0", "\u03B9\u0308"=>"\u03CA", "\u03C5\u0308"=>"\u03CB", "\u03BF\u0301"=>"\u03CC", "\u03C5\u0301"=>"\u03CD",
+ "\u03C9\u0301"=>"\u03CE", "\u03D2\u0301"=>"\u03D3", "\u03D2\u0308"=>"\u03D4", "\u0415\u0300"=>"\u0400", "\u0415\u0308"=>"\u0401", "\u0413\u0301"=>"\u0403", "\u0406\u0308"=>"\u0407", "\u041A\u0301"=>"\u040C",
+ "\u0418\u0300"=>"\u040D", "\u0423\u0306"=>"\u040E", "\u0418\u0306"=>"\u0419", "\u0438\u0306"=>"\u0439", "\u0435\u0300"=>"\u0450", "\u0435\u0308"=>"\u0451", "\u0433\u0301"=>"\u0453", "\u0456\u0308"=>"\u0457",
+ "\u043A\u0301"=>"\u045C", "\u0438\u0300"=>"\u045D", "\u0443\u0306"=>"\u045E", "\u0474\u030F"=>"\u0476", "\u0475\u030F"=>"\u0477", "\u0416\u0306"=>"\u04C1", "\u0436\u0306"=>"\u04C2", "\u0410\u0306"=>"\u04D0",
+ "\u0430\u0306"=>"\u04D1", "\u0410\u0308"=>"\u04D2", "\u0430\u0308"=>"\u04D3", "\u0415\u0306"=>"\u04D6", "\u0435\u0306"=>"\u04D7", "\u04D8\u0308"=>"\u04DA", "\u04D9\u0308"=>"\u04DB", "\u0416\u0308"=>"\u04DC",
+ "\u0436\u0308"=>"\u04DD", "\u0417\u0308"=>"\u04DE", "\u0437\u0308"=>"\u04DF", "\u0418\u0304"=>"\u04E2", "\u0438\u0304"=>"\u04E3", "\u0418\u0308"=>"\u04E4", "\u0438\u0308"=>"\u04E5", "\u041E\u0308"=>"\u04E6",
+ "\u043E\u0308"=>"\u04E7", "\u04E8\u0308"=>"\u04EA", "\u04E9\u0308"=>"\u04EB", "\u042D\u0308"=>"\u04EC", "\u044D\u0308"=>"\u04ED", "\u0423\u0304"=>"\u04EE", "\u0443\u0304"=>"\u04EF", "\u0423\u0308"=>"\u04F0",
+ "\u0443\u0308"=>"\u04F1", "\u0423\u030B"=>"\u04F2", "\u0443\u030B"=>"\u04F3", "\u0427\u0308"=>"\u04F4", "\u0447\u0308"=>"\u04F5", "\u042B\u0308"=>"\u04F8", "\u044B\u0308"=>"\u04F9", "\u0627\u0653"=>"\u0622",
+ "\u0627\u0654"=>"\u0623", "\u0648\u0654"=>"\u0624", "\u0627\u0655"=>"\u0625", "\u064A\u0654"=>"\u0626", "\u06D5\u0654"=>"\u06C0", "\u06C1\u0654"=>"\u06C2", "\u06D2\u0654"=>"\u06D3", "\u0928\u093C"=>"\u0929",
+ "\u0930\u093C"=>"\u0931", "\u0933\u093C"=>"\u0934", "\u09C7\u09BE"=>"\u09CB", "\u09C7\u09D7"=>"\u09CC", "\u0B47\u0B56"=>"\u0B48", "\u0B47\u0B3E"=>"\u0B4B", "\u0B47\u0B57"=>"\u0B4C", "\u0B92\u0BD7"=>"\u0B94",
+ "\u0BC6\u0BBE"=>"\u0BCA", "\u0BC7\u0BBE"=>"\u0BCB", "\u0BC6\u0BD7"=>"\u0BCC", "\u0C46\u0C56"=>"\u0C48", "\u0CBF\u0CD5"=>"\u0CC0", "\u0CC6\u0CD5"=>"\u0CC7", "\u0CC6\u0CD6"=>"\u0CC8", "\u0CC6\u0CC2"=>"\u0CCA",
+ "\u0CCA\u0CD5"=>"\u0CCB", "\u0D46\u0D3E"=>"\u0D4A", "\u0D47\u0D3E"=>"\u0D4B", "\u0D46\u0D57"=>"\u0D4C", "\u0DD9\u0DCA"=>"\u0DDA", "\u0DD9\u0DCF"=>"\u0DDC", "\u0DDC\u0DCA"=>"\u0DDD", "\u0DD9\u0DDF"=>"\u0DDE",
+ "\u1025\u102E"=>"\u1026", "\u1B05\u1B35"=>"\u1B06", "\u1B07\u1B35"=>"\u1B08", "\u1B09\u1B35"=>"\u1B0A", "\u1B0B\u1B35"=>"\u1B0C", "\u1B0D\u1B35"=>"\u1B0E", "\u1B11\u1B35"=>"\u1B12", "\u1B3A\u1B35"=>"\u1B3B",
+ "\u1B3C\u1B35"=>"\u1B3D", "\u1B3E\u1B35"=>"\u1B40", "\u1B3F\u1B35"=>"\u1B41", "\u1B42\u1B35"=>"\u1B43", "A\u0325"=>"\u1E00", "a\u0325"=>"\u1E01", "B\u0307"=>"\u1E02", "b\u0307"=>"\u1E03",
+ "B\u0323"=>"\u1E04", "b\u0323"=>"\u1E05", "B\u0331"=>"\u1E06", "b\u0331"=>"\u1E07", "\u00C7\u0301"=>"\u1E08", "\u00E7\u0301"=>"\u1E09", "D\u0307"=>"\u1E0A", "d\u0307"=>"\u1E0B",
+ "D\u0323"=>"\u1E0C", "d\u0323"=>"\u1E0D", "D\u0331"=>"\u1E0E", "d\u0331"=>"\u1E0F", "D\u0327"=>"\u1E10", "d\u0327"=>"\u1E11", "D\u032D"=>"\u1E12", "d\u032D"=>"\u1E13",
+ "\u0112\u0300"=>"\u1E14", "\u0113\u0300"=>"\u1E15", "\u0112\u0301"=>"\u1E16", "\u0113\u0301"=>"\u1E17", "E\u032D"=>"\u1E18", "e\u032D"=>"\u1E19", "E\u0330"=>"\u1E1A", "e\u0330"=>"\u1E1B",
+ "\u0228\u0306"=>"\u1E1C", "\u0229\u0306"=>"\u1E1D", "F\u0307"=>"\u1E1E", "f\u0307"=>"\u1E1F", "G\u0304"=>"\u1E20", "g\u0304"=>"\u1E21", "H\u0307"=>"\u1E22", "h\u0307"=>"\u1E23",
+ "H\u0323"=>"\u1E24", "h\u0323"=>"\u1E25", "H\u0308"=>"\u1E26", "h\u0308"=>"\u1E27", "H\u0327"=>"\u1E28", "h\u0327"=>"\u1E29", "H\u032E"=>"\u1E2A", "h\u032E"=>"\u1E2B",
+ "I\u0330"=>"\u1E2C", "i\u0330"=>"\u1E2D", "\u00CF\u0301"=>"\u1E2E", "\u00EF\u0301"=>"\u1E2F", "K\u0301"=>"\u1E30", "k\u0301"=>"\u1E31", "K\u0323"=>"\u1E32", "k\u0323"=>"\u1E33",
+ "K\u0331"=>"\u1E34", "k\u0331"=>"\u1E35", "L\u0323"=>"\u1E36", "l\u0323"=>"\u1E37", "\u1E36\u0304"=>"\u1E38", "\u1E37\u0304"=>"\u1E39", "L\u0331"=>"\u1E3A", "l\u0331"=>"\u1E3B",
+ "L\u032D"=>"\u1E3C", "l\u032D"=>"\u1E3D", "M\u0301"=>"\u1E3E", "m\u0301"=>"\u1E3F", "M\u0307"=>"\u1E40", "m\u0307"=>"\u1E41", "M\u0323"=>"\u1E42", "m\u0323"=>"\u1E43",
+ "N\u0307"=>"\u1E44", "n\u0307"=>"\u1E45", "N\u0323"=>"\u1E46", "n\u0323"=>"\u1E47", "N\u0331"=>"\u1E48", "n\u0331"=>"\u1E49", "N\u032D"=>"\u1E4A", "n\u032D"=>"\u1E4B",
+ "\u00D5\u0301"=>"\u1E4C", "\u00F5\u0301"=>"\u1E4D", "\u00D5\u0308"=>"\u1E4E", "\u00F5\u0308"=>"\u1E4F", "\u014C\u0300"=>"\u1E50", "\u014D\u0300"=>"\u1E51", "\u014C\u0301"=>"\u1E52", "\u014D\u0301"=>"\u1E53",
+ "P\u0301"=>"\u1E54", "p\u0301"=>"\u1E55", "P\u0307"=>"\u1E56", "p\u0307"=>"\u1E57", "R\u0307"=>"\u1E58", "r\u0307"=>"\u1E59", "R\u0323"=>"\u1E5A", "r\u0323"=>"\u1E5B",
+ "\u1E5A\u0304"=>"\u1E5C", "\u1E5B\u0304"=>"\u1E5D", "R\u0331"=>"\u1E5E", "r\u0331"=>"\u1E5F", "S\u0307"=>"\u1E60", "s\u0307"=>"\u1E61", "S\u0323"=>"\u1E62", "s\u0323"=>"\u1E63",
+ "\u015A\u0307"=>"\u1E64", "\u015B\u0307"=>"\u1E65", "\u0160\u0307"=>"\u1E66", "\u0161\u0307"=>"\u1E67", "\u1E62\u0307"=>"\u1E68", "\u1E63\u0307"=>"\u1E69", "T\u0307"=>"\u1E6A", "t\u0307"=>"\u1E6B",
+ "T\u0323"=>"\u1E6C", "t\u0323"=>"\u1E6D", "T\u0331"=>"\u1E6E", "t\u0331"=>"\u1E6F", "T\u032D"=>"\u1E70", "t\u032D"=>"\u1E71", "U\u0324"=>"\u1E72", "u\u0324"=>"\u1E73",
+ "U\u0330"=>"\u1E74", "u\u0330"=>"\u1E75", "U\u032D"=>"\u1E76", "u\u032D"=>"\u1E77", "\u0168\u0301"=>"\u1E78", "\u0169\u0301"=>"\u1E79", "\u016A\u0308"=>"\u1E7A", "\u016B\u0308"=>"\u1E7B",
+ "V\u0303"=>"\u1E7C", "v\u0303"=>"\u1E7D", "V\u0323"=>"\u1E7E", "v\u0323"=>"\u1E7F", "W\u0300"=>"\u1E80", "w\u0300"=>"\u1E81", "W\u0301"=>"\u1E82", "w\u0301"=>"\u1E83",
+ "W\u0308"=>"\u1E84", "w\u0308"=>"\u1E85", "W\u0307"=>"\u1E86", "w\u0307"=>"\u1E87", "W\u0323"=>"\u1E88", "w\u0323"=>"\u1E89", "X\u0307"=>"\u1E8A", "x\u0307"=>"\u1E8B",
+ "X\u0308"=>"\u1E8C", "x\u0308"=>"\u1E8D", "Y\u0307"=>"\u1E8E", "y\u0307"=>"\u1E8F", "Z\u0302"=>"\u1E90", "z\u0302"=>"\u1E91", "Z\u0323"=>"\u1E92", "z\u0323"=>"\u1E93",
+ "Z\u0331"=>"\u1E94", "z\u0331"=>"\u1E95", "h\u0331"=>"\u1E96", "t\u0308"=>"\u1E97", "w\u030A"=>"\u1E98", "y\u030A"=>"\u1E99", "\u017F\u0307"=>"\u1E9B", "A\u0323"=>"\u1EA0",
+ "a\u0323"=>"\u1EA1", "A\u0309"=>"\u1EA2", "a\u0309"=>"\u1EA3", "\u00C2\u0301"=>"\u1EA4", "\u00E2\u0301"=>"\u1EA5", "\u00C2\u0300"=>"\u1EA6", "\u00E2\u0300"=>"\u1EA7", "\u00C2\u0309"=>"\u1EA8",
+ "\u00E2\u0309"=>"\u1EA9", "\u00C2\u0303"=>"\u1EAA", "\u00E2\u0303"=>"\u1EAB", "\u1EA0\u0302"=>"\u1EAC", "\u1EA1\u0302"=>"\u1EAD", "\u0102\u0301"=>"\u1EAE", "\u0103\u0301"=>"\u1EAF", "\u0102\u0300"=>"\u1EB0",
+ "\u0103\u0300"=>"\u1EB1", "\u0102\u0309"=>"\u1EB2", "\u0103\u0309"=>"\u1EB3", "\u0102\u0303"=>"\u1EB4", "\u0103\u0303"=>"\u1EB5", "\u1EA0\u0306"=>"\u1EB6", "\u1EA1\u0306"=>"\u1EB7", "E\u0323"=>"\u1EB8",
+ "e\u0323"=>"\u1EB9", "E\u0309"=>"\u1EBA", "e\u0309"=>"\u1EBB", "E\u0303"=>"\u1EBC", "e\u0303"=>"\u1EBD", "\u00CA\u0301"=>"\u1EBE", "\u00EA\u0301"=>"\u1EBF", "\u00CA\u0300"=>"\u1EC0",
+ "\u00EA\u0300"=>"\u1EC1", "\u00CA\u0309"=>"\u1EC2", "\u00EA\u0309"=>"\u1EC3", "\u00CA\u0303"=>"\u1EC4", "\u00EA\u0303"=>"\u1EC5", "\u1EB8\u0302"=>"\u1EC6", "\u1EB9\u0302"=>"\u1EC7", "I\u0309"=>"\u1EC8",
+ "i\u0309"=>"\u1EC9", "I\u0323"=>"\u1ECA", "i\u0323"=>"\u1ECB", "O\u0323"=>"\u1ECC", "o\u0323"=>"\u1ECD", "O\u0309"=>"\u1ECE", "o\u0309"=>"\u1ECF", "\u00D4\u0301"=>"\u1ED0",
+ "\u00F4\u0301"=>"\u1ED1", "\u00D4\u0300"=>"\u1ED2", "\u00F4\u0300"=>"\u1ED3", "\u00D4\u0309"=>"\u1ED4", "\u00F4\u0309"=>"\u1ED5", "\u00D4\u0303"=>"\u1ED6", "\u00F4\u0303"=>"\u1ED7", "\u1ECC\u0302"=>"\u1ED8",
+ "\u1ECD\u0302"=>"\u1ED9", "\u01A0\u0301"=>"\u1EDA", "\u01A1\u0301"=>"\u1EDB", "\u01A0\u0300"=>"\u1EDC", "\u01A1\u0300"=>"\u1EDD", "\u01A0\u0309"=>"\u1EDE", "\u01A1\u0309"=>"\u1EDF", "\u01A0\u0303"=>"\u1EE0",
+ "\u01A1\u0303"=>"\u1EE1", "\u01A0\u0323"=>"\u1EE2", "\u01A1\u0323"=>"\u1EE3", "U\u0323"=>"\u1EE4", "u\u0323"=>"\u1EE5", "U\u0309"=>"\u1EE6", "u\u0309"=>"\u1EE7", "\u01AF\u0301"=>"\u1EE8",
+ "\u01B0\u0301"=>"\u1EE9", "\u01AF\u0300"=>"\u1EEA", "\u01B0\u0300"=>"\u1EEB", "\u01AF\u0309"=>"\u1EEC", "\u01B0\u0309"=>"\u1EED", "\u01AF\u0303"=>"\u1EEE", "\u01B0\u0303"=>"\u1EEF", "\u01AF\u0323"=>"\u1EF0",
+ "\u01B0\u0323"=>"\u1EF1", "Y\u0300"=>"\u1EF2", "y\u0300"=>"\u1EF3", "Y\u0323"=>"\u1EF4", "y\u0323"=>"\u1EF5", "Y\u0309"=>"\u1EF6", "y\u0309"=>"\u1EF7", "Y\u0303"=>"\u1EF8",
+ "y\u0303"=>"\u1EF9", "\u03B1\u0313"=>"\u1F00", "\u03B1\u0314"=>"\u1F01", "\u1F00\u0300"=>"\u1F02", "\u1F01\u0300"=>"\u1F03", "\u1F00\u0301"=>"\u1F04", "\u1F01\u0301"=>"\u1F05", "\u1F00\u0342"=>"\u1F06",
+ "\u1F01\u0342"=>"\u1F07", "\u0391\u0313"=>"\u1F08", "\u0391\u0314"=>"\u1F09", "\u1F08\u0300"=>"\u1F0A", "\u1F09\u0300"=>"\u1F0B", "\u1F08\u0301"=>"\u1F0C", "\u1F09\u0301"=>"\u1F0D", "\u1F08\u0342"=>"\u1F0E",
+ "\u1F09\u0342"=>"\u1F0F", "\u03B5\u0313"=>"\u1F10", "\u03B5\u0314"=>"\u1F11", "\u1F10\u0300"=>"\u1F12", "\u1F11\u0300"=>"\u1F13", "\u1F10\u0301"=>"\u1F14", "\u1F11\u0301"=>"\u1F15", "\u0395\u0313"=>"\u1F18",
+ "\u0395\u0314"=>"\u1F19", "\u1F18\u0300"=>"\u1F1A", "\u1F19\u0300"=>"\u1F1B", "\u1F18\u0301"=>"\u1F1C", "\u1F19\u0301"=>"\u1F1D", "\u03B7\u0313"=>"\u1F20", "\u03B7\u0314"=>"\u1F21", "\u1F20\u0300"=>"\u1F22",
+ "\u1F21\u0300"=>"\u1F23", "\u1F20\u0301"=>"\u1F24", "\u1F21\u0301"=>"\u1F25", "\u1F20\u0342"=>"\u1F26", "\u1F21\u0342"=>"\u1F27", "\u0397\u0313"=>"\u1F28", "\u0397\u0314"=>"\u1F29", "\u1F28\u0300"=>"\u1F2A",
+ "\u1F29\u0300"=>"\u1F2B", "\u1F28\u0301"=>"\u1F2C", "\u1F29\u0301"=>"\u1F2D", "\u1F28\u0342"=>"\u1F2E", "\u1F29\u0342"=>"\u1F2F", "\u03B9\u0313"=>"\u1F30", "\u03B9\u0314"=>"\u1F31", "\u1F30\u0300"=>"\u1F32",
+ "\u1F31\u0300"=>"\u1F33", "\u1F30\u0301"=>"\u1F34", "\u1F31\u0301"=>"\u1F35", "\u1F30\u0342"=>"\u1F36", "\u1F31\u0342"=>"\u1F37", "\u0399\u0313"=>"\u1F38", "\u0399\u0314"=>"\u1F39", "\u1F38\u0300"=>"\u1F3A",
+ "\u1F39\u0300"=>"\u1F3B", "\u1F38\u0301"=>"\u1F3C", "\u1F39\u0301"=>"\u1F3D", "\u1F38\u0342"=>"\u1F3E", "\u1F39\u0342"=>"\u1F3F", "\u03BF\u0313"=>"\u1F40", "\u03BF\u0314"=>"\u1F41", "\u1F40\u0300"=>"\u1F42",
+ "\u1F41\u0300"=>"\u1F43", "\u1F40\u0301"=>"\u1F44", "\u1F41\u0301"=>"\u1F45", "\u039F\u0313"=>"\u1F48", "\u039F\u0314"=>"\u1F49", "\u1F48\u0300"=>"\u1F4A", "\u1F49\u0300"=>"\u1F4B", "\u1F48\u0301"=>"\u1F4C",
+ "\u1F49\u0301"=>"\u1F4D", "\u03C5\u0313"=>"\u1F50", "\u03C5\u0314"=>"\u1F51", "\u1F50\u0300"=>"\u1F52", "\u1F51\u0300"=>"\u1F53", "\u1F50\u0301"=>"\u1F54", "\u1F51\u0301"=>"\u1F55", "\u1F50\u0342"=>"\u1F56",
+ "\u1F51\u0342"=>"\u1F57", "\u03A5\u0314"=>"\u1F59", "\u1F59\u0300"=>"\u1F5B", "\u1F59\u0301"=>"\u1F5D", "\u1F59\u0342"=>"\u1F5F", "\u03C9\u0313"=>"\u1F60", "\u03C9\u0314"=>"\u1F61", "\u1F60\u0300"=>"\u1F62",
+ "\u1F61\u0300"=>"\u1F63", "\u1F60\u0301"=>"\u1F64", "\u1F61\u0301"=>"\u1F65", "\u1F60\u0342"=>"\u1F66", "\u1F61\u0342"=>"\u1F67", "\u03A9\u0313"=>"\u1F68", "\u03A9\u0314"=>"\u1F69", "\u1F68\u0300"=>"\u1F6A",
+ "\u1F69\u0300"=>"\u1F6B", "\u1F68\u0301"=>"\u1F6C", "\u1F69\u0301"=>"\u1F6D", "\u1F68\u0342"=>"\u1F6E", "\u1F69\u0342"=>"\u1F6F", "\u03B1\u0300"=>"\u1F70", "\u03B5\u0300"=>"\u1F72", "\u03B7\u0300"=>"\u1F74",
+ "\u03B9\u0300"=>"\u1F76", "\u03BF\u0300"=>"\u1F78", "\u03C5\u0300"=>"\u1F7A", "\u03C9\u0300"=>"\u1F7C", "\u1F00\u0345"=>"\u1F80", "\u1F01\u0345"=>"\u1F81", "\u1F02\u0345"=>"\u1F82", "\u1F03\u0345"=>"\u1F83",
+ "\u1F04\u0345"=>"\u1F84", "\u1F05\u0345"=>"\u1F85", "\u1F06\u0345"=>"\u1F86", "\u1F07\u0345"=>"\u1F87", "\u1F08\u0345"=>"\u1F88", "\u1F09\u0345"=>"\u1F89", "\u1F0A\u0345"=>"\u1F8A", "\u1F0B\u0345"=>"\u1F8B",
+ "\u1F0C\u0345"=>"\u1F8C", "\u1F0D\u0345"=>"\u1F8D", "\u1F0E\u0345"=>"\u1F8E", "\u1F0F\u0345"=>"\u1F8F", "\u1F20\u0345"=>"\u1F90", "\u1F21\u0345"=>"\u1F91", "\u1F22\u0345"=>"\u1F92", "\u1F23\u0345"=>"\u1F93",
+ "\u1F24\u0345"=>"\u1F94", "\u1F25\u0345"=>"\u1F95", "\u1F26\u0345"=>"\u1F96", "\u1F27\u0345"=>"\u1F97", "\u1F28\u0345"=>"\u1F98", "\u1F29\u0345"=>"\u1F99", "\u1F2A\u0345"=>"\u1F9A", "\u1F2B\u0345"=>"\u1F9B",
+ "\u1F2C\u0345"=>"\u1F9C", "\u1F2D\u0345"=>"\u1F9D", "\u1F2E\u0345"=>"\u1F9E", "\u1F2F\u0345"=>"\u1F9F", "\u1F60\u0345"=>"\u1FA0", "\u1F61\u0345"=>"\u1FA1", "\u1F62\u0345"=>"\u1FA2", "\u1F63\u0345"=>"\u1FA3",
+ "\u1F64\u0345"=>"\u1FA4", "\u1F65\u0345"=>"\u1FA5", "\u1F66\u0345"=>"\u1FA6", "\u1F67\u0345"=>"\u1FA7", "\u1F68\u0345"=>"\u1FA8", "\u1F69\u0345"=>"\u1FA9", "\u1F6A\u0345"=>"\u1FAA", "\u1F6B\u0345"=>"\u1FAB",
+ "\u1F6C\u0345"=>"\u1FAC", "\u1F6D\u0345"=>"\u1FAD", "\u1F6E\u0345"=>"\u1FAE", "\u1F6F\u0345"=>"\u1FAF", "\u03B1\u0306"=>"\u1FB0", "\u03B1\u0304"=>"\u1FB1", "\u1F70\u0345"=>"\u1FB2", "\u03B1\u0345"=>"\u1FB3",
+ "\u03AC\u0345"=>"\u1FB4", "\u03B1\u0342"=>"\u1FB6", "\u1FB6\u0345"=>"\u1FB7", "\u0391\u0306"=>"\u1FB8", "\u0391\u0304"=>"\u1FB9", "\u0391\u0300"=>"\u1FBA", "\u0391\u0345"=>"\u1FBC", "\u00A8\u0342"=>"\u1FC1",
+ "\u1F74\u0345"=>"\u1FC2", "\u03B7\u0345"=>"\u1FC3", "\u03AE\u0345"=>"\u1FC4", "\u03B7\u0342"=>"\u1FC6", "\u1FC6\u0345"=>"\u1FC7", "\u0395\u0300"=>"\u1FC8", "\u0397\u0300"=>"\u1FCA", "\u0397\u0345"=>"\u1FCC",
+ "\u1FBF\u0300"=>"\u1FCD", "\u1FBF\u0301"=>"\u1FCE", "\u1FBF\u0342"=>"\u1FCF", "\u03B9\u0306"=>"\u1FD0", "\u03B9\u0304"=>"\u1FD1", "\u03CA\u0300"=>"\u1FD2", "\u03B9\u0342"=>"\u1FD6", "\u03CA\u0342"=>"\u1FD7",
+ "\u0399\u0306"=>"\u1FD8", "\u0399\u0304"=>"\u1FD9", "\u0399\u0300"=>"\u1FDA", "\u1FFE\u0300"=>"\u1FDD", "\u1FFE\u0301"=>"\u1FDE", "\u1FFE\u0342"=>"\u1FDF", "\u03C5\u0306"=>"\u1FE0", "\u03C5\u0304"=>"\u1FE1",
+ "\u03CB\u0300"=>"\u1FE2", "\u03C1\u0313"=>"\u1FE4", "\u03C1\u0314"=>"\u1FE5", "\u03C5\u0342"=>"\u1FE6", "\u03CB\u0342"=>"\u1FE7", "\u03A5\u0306"=>"\u1FE8", "\u03A5\u0304"=>"\u1FE9", "\u03A5\u0300"=>"\u1FEA",
+ "\u03A1\u0314"=>"\u1FEC", "\u00A8\u0300"=>"\u1FED", "\u1F7C\u0345"=>"\u1FF2", "\u03C9\u0345"=>"\u1FF3", "\u03CE\u0345"=>"\u1FF4", "\u03C9\u0342"=>"\u1FF6", "\u1FF6\u0345"=>"\u1FF7", "\u039F\u0300"=>"\u1FF8",
+ "\u03A9\u0300"=>"\u1FFA", "\u03A9\u0345"=>"\u1FFC", "\u2190\u0338"=>"\u219A", "\u2192\u0338"=>"\u219B", "\u2194\u0338"=>"\u21AE", "\u21D0\u0338"=>"\u21CD", "\u21D4\u0338"=>"\u21CE", "\u21D2\u0338"=>"\u21CF",
+ "\u2203\u0338"=>"\u2204", "\u2208\u0338"=>"\u2209", "\u220B\u0338"=>"\u220C", "\u2223\u0338"=>"\u2224", "\u2225\u0338"=>"\u2226", "\u223C\u0338"=>"\u2241", "\u2243\u0338"=>"\u2244", "\u2245\u0338"=>"\u2247",
+ "\u2248\u0338"=>"\u2249", "=\u0338"=>"\u2260", "\u2261\u0338"=>"\u2262", "\u224D\u0338"=>"\u226D", "<\u0338"=>"\u226E", ">\u0338"=>"\u226F", "\u2264\u0338"=>"\u2270", "\u2265\u0338"=>"\u2271",
+ "\u2272\u0338"=>"\u2274", "\u2273\u0338"=>"\u2275", "\u2276\u0338"=>"\u2278", "\u2277\u0338"=>"\u2279", "\u227A\u0338"=>"\u2280", "\u227B\u0338"=>"\u2281", "\u2282\u0338"=>"\u2284", "\u2283\u0338"=>"\u2285",
+ "\u2286\u0338"=>"\u2288", "\u2287\u0338"=>"\u2289", "\u22A2\u0338"=>"\u22AC", "\u22A8\u0338"=>"\u22AD", "\u22A9\u0338"=>"\u22AE", "\u22AB\u0338"=>"\u22AF", "\u227C\u0338"=>"\u22E0", "\u227D\u0338"=>"\u22E1",
+ "\u2291\u0338"=>"\u22E2", "\u2292\u0338"=>"\u22E3", "\u22B2\u0338"=>"\u22EA", "\u22B3\u0338"=>"\u22EB", "\u22B4\u0338"=>"\u22EC", "\u22B5\u0338"=>"\u22ED", "\u304B\u3099"=>"\u304C", "\u304D\u3099"=>"\u304E",
+ "\u304F\u3099"=>"\u3050", "\u3051\u3099"=>"\u3052", "\u3053\u3099"=>"\u3054", "\u3055\u3099"=>"\u3056", "\u3057\u3099"=>"\u3058", "\u3059\u3099"=>"\u305A", "\u305B\u3099"=>"\u305C", "\u305D\u3099"=>"\u305E",
+ "\u305F\u3099"=>"\u3060", "\u3061\u3099"=>"\u3062", "\u3064\u3099"=>"\u3065", "\u3066\u3099"=>"\u3067", "\u3068\u3099"=>"\u3069", "\u306F\u3099"=>"\u3070", "\u306F\u309A"=>"\u3071", "\u3072\u3099"=>"\u3073",
+ "\u3072\u309A"=>"\u3074", "\u3075\u3099"=>"\u3076", "\u3075\u309A"=>"\u3077", "\u3078\u3099"=>"\u3079", "\u3078\u309A"=>"\u307A", "\u307B\u3099"=>"\u307C", "\u307B\u309A"=>"\u307D", "\u3046\u3099"=>"\u3094",
+ "\u309D\u3099"=>"\u309E", "\u30AB\u3099"=>"\u30AC", "\u30AD\u3099"=>"\u30AE", "\u30AF\u3099"=>"\u30B0", "\u30B1\u3099"=>"\u30B2", "\u30B3\u3099"=>"\u30B4", "\u30B5\u3099"=>"\u30B6", "\u30B7\u3099"=>"\u30B8",
+ "\u30B9\u3099"=>"\u30BA", "\u30BB\u3099"=>"\u30BC", "\u30BD\u3099"=>"\u30BE", "\u30BF\u3099"=>"\u30C0", "\u30C1\u3099"=>"\u30C2", "\u30C4\u3099"=>"\u30C5", "\u30C6\u3099"=>"\u30C7", "\u30C8\u3099"=>"\u30C9",
+ "\u30CF\u3099"=>"\u30D0", "\u30CF\u309A"=>"\u30D1", "\u30D2\u3099"=>"\u30D3", "\u30D2\u309A"=>"\u30D4", "\u30D5\u3099"=>"\u30D6", "\u30D5\u309A"=>"\u30D7", "\u30D8\u3099"=>"\u30D9", "\u30D8\u309A"=>"\u30DA",
+ "\u30DB\u3099"=>"\u30DC", "\u30DB\u309A"=>"\u30DD", "\u30A6\u3099"=>"\u30F4", "\u30EF\u3099"=>"\u30F7", "\u30F0\u3099"=>"\u30F8", "\u30F1\u3099"=>"\u30F9", "\u30F2\u3099"=>"\u30FA", "\u30FD\u3099"=>"\u30FE",
+ "\u{11099}\u{110BA}"=>"\u{1109A}", "\u{1109B}\u{110BA}"=>"\u{1109C}", "\u{110A5}\u{110BA}"=>"\u{110AB}", "\u{11131}\u{11127}"=>"\u{1112E}", "\u{11132}\u{11127}"=>"\u{1112F}", "\u{11347}\u{1133E}"=>"\u{1134B}", "\u{11347}\u{11357}"=>"\u{1134C}", "\u{114B9}\u{114BA}"=>"\u{114BB}",
+ "\u{114B9}\u{114B0}"=>"\u{114BC}", "\u{114B9}\u{114BD}"=>"\u{114BE}", "\u{115B8}\u{115AF}"=>"\u{115BA}", "\u{115B9}\u{115AF}"=>"\u{115BB}",
}.freeze
end
diff --git a/lib/uri.rb b/lib/uri.rb
index ea8ea3e18c..971a97038f 100644
--- a/lib/uri.rb
+++ b/lib/uri.rb
@@ -1,28 +1,34 @@
# frozen_string_literal: false
# URI is a module providing classes to handle Uniform Resource Identifiers
-# (RFC2396[http://tools.ietf.org/html/rfc2396]).
+# (RFC2396[http://tools.ietf.org/html/rfc2396])
#
# == Features
#
-# * Uniform way of handling URIs.
-# * Flexibility to introduce custom URI schemes.
+# * Uniform handling of handling URIs
+# * Flexibility to introduce custom URI schemes
# * Flexibility to have an alternate URI::Parser (or just different patterns
-# and regexp's).
+# and regexp's)
#
# == Basic example
#
# require 'uri'
#
# uri = URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
-# #=> #<URI::HTTP http://foo.com/posts?id=30&limit=5#time=1305298413>
-#
-# uri.scheme #=> "http"
-# uri.host #=> "foo.com"
-# uri.path #=> "/posts"
-# uri.query #=> "id=30&limit=5"
-# uri.fragment #=> "time=1305298413"
-#
-# uri.to_s #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
+# #=> #<URI::HTTP:0x00000000b14880
+# URL:http://foo.com/posts?id=30&limit=5#time=1305298413>
+# uri.scheme
+# #=> "http"
+# uri.host
+# #=> "foo.com"
+# uri.path
+# #=> "/posts"
+# uri.query
+# #=> "id=30&limit=5"
+# uri.fragment
+# #=> "time=1305298413"
+#
+# uri.to_s
+# #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
#
# == Adding custom URIs
#
@@ -35,18 +41,18 @@
# #=> URI::RSYNC
#
# URI.scheme_list
-# #=> {"FILE"=>URI::File, "FTP"=>URI::FTP, "HTTP"=>URI::HTTP,
-# # "HTTPS"=>URI::HTTPS, "LDAP"=>URI::LDAP, "LDAPS"=>URI::LDAPS,
-# # "MAILTO"=>URI::MailTo, "RSYNC"=>URI::RSYNC}
+# #=> {"FTP"=>URI::FTP, "HTTP"=>URI::HTTP, "HTTPS"=>URI::HTTPS,
+# "LDAP"=>URI::LDAP, "LDAPS"=>URI::LDAPS, "MAILTO"=>URI::MailTo,
+# "RSYNC"=>URI::RSYNC}
#
# uri = URI("rsync://rsync.foo.com")
-# #=> #<URI::RSYNC rsync://rsync.foo.com>
+# #=> #<URI::RSYNC:0x00000000f648c8 URL:rsync://rsync.foo.com>
#
# == RFC References
#
-# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
+# A good place to view an RFC spec is http://www.ietf.org/rfc.html
#
-# Here is a list of all related RFC's:
+# Here is a list of all related RFC's.
# - RFC822[http://tools.ietf.org/html/rfc822]
# - RFC1738[http://tools.ietf.org/html/rfc1738]
# - RFC2255[http://tools.ietf.org/html/rfc2255]
@@ -59,7 +65,6 @@
# == Class tree
#
# - URI::Generic (in uri/generic.rb)
-# - URI::File - (in uri/file.rb)
# - URI::FTP - (in uri/ftp.rb)
# - URI::HTTP - (in uri/http.rb)
# - URI::HTTPS - (in uri/https.rb)
@@ -90,12 +95,15 @@
#
module URI
+ # :stopdoc:
+ VERSION_CODE = '001000'.freeze
+ VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
+ # :startdoc:
+
end
-require 'uri/version'
require 'uri/common'
require 'uri/generic'
-require 'uri/file'
require 'uri/ftp'
require 'uri/http'
require 'uri/https'
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index b886923c9e..764f89d810 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: true
+# frozen_string_literal: false
#--
# = uri/common.rb
#
@@ -10,8 +10,8 @@
# See URI for general documentation
#
-require_relative "rfc2396_parser"
-require_relative "rfc3986_parser"
+require "uri/rfc2396_parser"
+require "uri/rfc3986_parser"
module URI
REGEXP = RFC2396_REGEXP
@@ -61,7 +61,7 @@ module URI
module_function :make_components_hash
end
- # Module for escaping unsafe characters with codes.
+ # module for escaping unsafe characters with codes.
module Escape
#
# == Synopsis
@@ -90,16 +90,17 @@ module URI
# require 'uri'
#
# enc_uri = URI.escape("http://example.com/?a=\11\15")
+ # p enc_uri
# # => "http://example.com/?a=%09%0D"
#
- # URI.unescape(enc_uri)
+ # p URI.unescape(enc_uri)
# # => "http://example.com/?a=\t\r"
#
- # URI.escape("@?@!", "!?")
+ # p URI.escape("@?@!", "!?")
# # => "@%3F@%21"
#
def escape(*arg)
- warn "URI.escape is obsolete", uplevel: 1
+ warn "URI.escape is obsolete", uplevel: 1 if $VERBOSE
DEFAULT_PARSER.escape(*arg)
end
alias encode escape
@@ -111,7 +112,7 @@ module URI
# == Args
#
# +str+::
- # String to unescape.
+ # Unescapes the string.
#
# == Description
#
@@ -124,13 +125,14 @@ module URI
# require 'uri'
#
# enc_uri = URI.escape("http://example.com/?a=\11\15")
+ # p enc_uri
# # => "http://example.com/?a=%09%0D"
#
- # URI.unescape(enc_uri)
+ # p URI.unescape(enc_uri)
# # => "http://example.com/?a=\t\r"
#
def unescape(*arg)
- warn "URI.unescape is obsolete", uplevel: 1
+ warn "URI.unescape is obsolete", uplevel: 1 if $VERBOSE
DEFAULT_PARSER.unescape(*arg)
end
alias decode unescape
@@ -140,7 +142,7 @@ module URI
include REGEXP
@@schemes = {}
- # Returns a Hash of the defined schemes.
+ # Returns a Hash of the defined schemes
def self.scheme_list
@@schemes
end
@@ -176,21 +178,21 @@ module URI
#
# Splits the string on following parts and returns array with result:
#
- # * Scheme
- # * Userinfo
- # * Host
- # * Port
- # * Registry
- # * Path
- # * Opaque
- # * Query
- # * Fragment
+ # * Scheme
+ # * Userinfo
+ # * Host
+ # * Port
+ # * Registry
+ # * Path
+ # * Opaque
+ # * Query
+ # * Fragment
#
# == Usage
#
# require 'uri'
#
- # URI.split("http://www.ruby-lang.org/")
+ # p URI.split("http://www.ruby-lang.org/")
# # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
#
def self.split(uri)
@@ -213,7 +215,7 @@ module URI
#
# == Raises
#
- # URI::InvalidURIError::
+ # URI::InvalidURIError
# Raised if URI given is not a correct one.
#
# == Usage
@@ -221,10 +223,11 @@ module URI
# require 'uri'
#
# uri = URI.parse("http://www.ruby-lang.org/")
- # # => #<URI::HTTP http://www.ruby-lang.org/>
- # uri.scheme
+ # p uri
+ # # => #<URI::HTTP:0x202281be URL:http://www.ruby-lang.org/>
+ # p uri.scheme
# # => "http"
- # uri.host
+ # p uri.host
# # => "www.ruby-lang.org"
#
# It's recommended to first ::escape the provided +uri_str+ if there are any
@@ -252,20 +255,21 @@ module URI
#
# require 'uri'
#
- # URI.join("http://example.com/","main.rbx")
- # # => #<URI::HTTP http://example.com/main.rbx>
+ # p URI.join("http://example.com/","main.rbx")
+ # # => #<URI::HTTP:0x2022ac02 URL:http://example.com/main.rbx>
#
- # URI.join('http://example.com', 'foo')
- # # => #<URI::HTTP http://example.com/foo>
+ # p URI.join('http://example.com', 'foo')
+ # # => #<URI::HTTP:0x01ab80a0 URL:http://example.com/foo>
#
- # URI.join('http://example.com', '/foo', '/bar')
- # # => #<URI::HTTP http://example.com/bar>
+ # p URI.join('http://example.com', '/foo', '/bar')
+ # # => #<URI::HTTP:0x01aaf0b0 URL:http://example.com/bar>
#
- # URI.join('http://example.com', '/foo', 'bar')
- # # => #<URI::HTTP http://example.com/bar>
+ # p URI.join('http://example.com', '/foo', 'bar')
+ # # => #<URI::HTTP:0x801a92af0 URL:http://example.com/bar>
+ #
+ # p URI.join('http://example.com', '/foo/', 'bar')
+ # # => #<URI::HTTP:0x80135a3a0 URL:http://example.com/foo/bar>
#
- # URI.join('http://example.com', '/foo/', 'bar')
- # # => #<URI::HTTP http://example.com/foo/bar>
#
def self.join(*str)
RFC3986_PARSER.join(*str)
@@ -281,7 +285,7 @@ module URI
# +str+::
# String to extract URIs from.
# +schemes+::
- # Limit URI matching to specific schemes.
+ # Limit URI matching to a specific schemes.
#
# == Description
#
@@ -312,7 +316,6 @@ module URI
# whose scheme is one of the match_schemes.
#
# == Description
- #
# Returns a Regexp object which matches to URI-like strings.
# The Regexp object returned by this method includes arbitrary
# number of capture group (parentheses). Never rely on it's number.
@@ -325,7 +328,7 @@ module URI
# html_string.slice(URI.regexp)
#
# # remove ftp URIs
- # html_string.sub(URI.regexp(['ftp']), '')
+ # html_string.sub(URI.regexp(['ftp'])
#
# # You should not rely on the number of parentheses
# html_string.scan(URI.regexp) do |*matches|
@@ -339,22 +342,25 @@ module URI
TBLENCWWWCOMP_ = {} # :nodoc:
256.times do |i|
- TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
+ TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
end
TBLENCWWWCOMP_[' '] = '+'
TBLENCWWWCOMP_.freeze
TBLDECWWWCOMP_ = {} # :nodoc:
256.times do |i|
h, l = i>>4, i&15
- TBLDECWWWCOMP_[-('%%%X%X' % [h, l])] = -i.chr
- TBLDECWWWCOMP_[-('%%%x%X' % [h, l])] = -i.chr
- TBLDECWWWCOMP_[-('%%%X%x' % [h, l])] = -i.chr
- TBLDECWWWCOMP_[-('%%%x%x' % [h, l])] = -i.chr
+ TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr
+ TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr
+ TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr
+ TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr
end
TBLDECWWWCOMP_['+'] = ' '
TBLDECWWWCOMP_.freeze
- # Encodes given +str+ to URL-encoded form data.
+ HTML5ASCIIINCOMPAT = defined? Encoding::UTF_7 ? [Encoding::UTF_7, Encoding::UTF_16BE, Encoding::UTF_16LE,
+ Encoding::UTF_32BE, Encoding::UTF_32LE] : [] # :nodoc:
+
+ # Encode given +str+ to URL-encoded form data.
#
# This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
# (ASCII space) to + and converts others to %XX.
@@ -362,15 +368,15 @@ module URI
# If +enc+ is given, convert +str+ to the encoding before percent encoding.
#
# This is an implementation of
- # http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
+ # http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data
#
- # See URI.decode_www_form_component, URI.encode_www_form.
+ # See URI.decode_www_form_component, URI.encode_www_form
def self.encode_www_form_component(str, enc=nil)
str = str.to_s.dup
if str.encoding != Encoding::ASCII_8BIT
if enc && enc != Encoding::ASCII_8BIT
str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
- str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
+ str.encode!(enc, fallback: ->(x){"&#{x.ord};"})
end
str.force_encoding(Encoding::ASCII_8BIT)
end
@@ -378,17 +384,17 @@ module URI
str.force_encoding(Encoding::US_ASCII)
end
- # Decodes given +str+ of URL-encoded form data.
+ # Decode given +str+ of URL-encoded form data.
#
# This decodes + to SP.
#
- # See URI.encode_www_form_component, URI.decode_www_form.
+ # See URI.encode_www_form_component, URI.decode_www_form
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
end
- # Generates URL-encoded form data from given +enum+.
+ # Generate URL-encoded form data from given +enum+.
#
# This generates application/x-www-form-urlencoded data defined in HTML5
# from given an Enumerable object.
@@ -396,7 +402,7 @@ module URI
# This internally uses URI.encode_www_form_component(str).
#
# This method doesn't convert the encoding of given items, so convert them
- # before calling this method if you want to send data as other than original
+ # before call this method if you want to send data as other than original
# encoding or mixed encoding data. (Strings which are encoded in an HTML5
# ASCII incompatible encoding are converted to UTF-8.)
#
@@ -414,7 +420,7 @@ module URI
# URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
# #=> "q=ruby&q=perl&lang=en"
#
- # See URI.encode_www_form_component, URI.decode_www_form.
+ # See URI.encode_www_form_component, URI.decode_www_form
def self.encode_www_form(enum, enc=nil)
enum.map do |k,v|
if v.nil?
@@ -435,22 +441,22 @@ module URI
end.join('&')
end
- # Decodes URL-encoded form data from given +str+.
+ # Decode URL-encoded form data from given +str+.
#
# This decodes application/x-www-form-urlencoded data
- # and returns an array of key-value arrays.
+ # and returns array of key-value array.
#
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-parser,
- # so this supports only &-separator, and doesn't support ;-separator.
+ # This refers http://url.spec.whatwg.org/#concept-urlencoded-parser ,
+ # so this supports only &-separator, don't support ;-separator.
#
# ary = URI.decode_www_form("a=1&a=2&b=3")
- # ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
- # ary.assoc('a').last #=> '1'
- # ary.assoc('b').last #=> '3'
- # ary.rassoc('a').last #=> '2'
- # Hash[ary] #=> {"a"=>"2", "b"=>"3"}
+ # p ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
+ # p ary.assoc('a').last #=> '1'
+ # p ary.assoc('b').last #=> '3'
+ # p ary.rassoc('a').last #=> '2'
+ # p Hash[ary] # => {"a"=>"2", "b"=>"3"}
#
- # See URI.decode_www_form_component, URI.encode_www_form.
+ # See URI.decode_www_form_component, URI.encode_www_form
def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
ary = []
@@ -462,7 +468,7 @@ module URI
if isindex
if sep.empty?
val = key
- key = +''
+ key = ''
end
isindex = false
end
@@ -476,7 +482,7 @@ module URI
if val
val.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
else
- val = +''
+ val = ''
end
ary << [key, val]
@@ -728,7 +734,7 @@ end # module URI
module Kernel
#
- # Returns +uri+ converted to an URI object.
+ # Returns +uri+ converted to a URI object.
#
def URI(uri)
if uri.is_a?(URI::Generic)
diff --git a/lib/uri/file.rb b/lib/uri/file.rb
deleted file mode 100644
index 561ec703c4..0000000000
--- a/lib/uri/file.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'generic'
-
-module URI
-
- #
- # The "file" URI is defined by RFC8089.
- #
- class File < Generic
- # A Default port of nil for URI::File.
- DEFAULT_PORT = nil
-
- #
- # An Array of the available components for URI::File.
- #
- COMPONENT = [
- :scheme,
- :host,
- :path
- ].freeze
-
- #
- # == Description
- #
- # Creates a new URI::File object from components, with syntax checking.
- #
- # The components accepted are +host+ and +path+.
- #
- # The components should be provided either as an Array, or as a Hash
- # with keys formed by preceding the component names with a colon.
- #
- # If an Array is used, the components must be passed in the
- # order <code>[host, path]</code>.
- #
- # Examples:
- #
- # require 'uri'
- #
- # uri1 = URI::File.build(['host.example.com', '/path/file.zip'])
- # uri1.to_s # => "file://host.example.com/path/file.zip"
- #
- # uri2 = URI::File.build({:host => 'host.example.com',
- # :path => '/ruby/src'})
- # uri2.to_s # => "file://host.example.com/ruby/src"
- #
- def self.build(args)
- tmp = Util::make_components_hash(self, args)
- super(tmp)
- end
-
- # Protected setter for the host component +v+.
- #
- # See also URI::Generic.host=.
- #
- def set_host(v)
- v = "" if v.nil? || v == "localhost"
- @host = v
- end
-
- # do nothing
- def set_port(v)
- end
-
- # raise InvalidURIError
- def check_userinfo(user)
- raise URI::InvalidURIError, "can not set userinfo for file URI"
- end
-
- # raise InvalidURIError
- def check_user(user)
- raise URI::InvalidURIError, "can not set user for file URI"
- end
-
- # raise InvalidURIError
- def check_password(user)
- raise URI::InvalidURIError, "can not set password for file URI"
- end
-
- # do nothing
- def set_userinfo(v)
- end
-
- # do nothing
- def set_user(v)
- end
-
- # do nothing
- def set_password(v)
- end
- end
-
- @@schemes['FILE'] = File
-end
diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb
index f57b4b7df9..90c1403ce6 100644
--- a/lib/uri/ftp.rb
+++ b/lib/uri/ftp.rb
@@ -8,7 +8,7 @@
# See URI for general documentation
#
-require_relative 'generic'
+require 'uri/generic'
module URI
@@ -21,11 +21,11 @@ module URI
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
#
class FTP < Generic
- # A Default port of 21 for URI::FTP.
+ # A Default port of 21 for URI::FTP
DEFAULT_PORT = 21
#
- # An Array of the available components for URI::FTP.
+ # An Array of the available components for URI::FTP
#
COMPONENT = [
:scheme,
@@ -34,7 +34,7 @@ module URI
].freeze
#
- # Typecode is "a", "i", or "d".
+ # Typecode is "a", "i" or "d".
#
# * "a" indicates a text file (the FTP command was ASCII)
# * "i" indicates a binary file (FTP command IMAGE)
@@ -42,7 +42,8 @@ module URI
#
TYPECODE = ['a', 'i', 'd'].freeze
- # Typecode prefix ";type=".
+ # Typecode prefix
+ # ';type='
TYPECODE_PREFIX = ';type='.freeze
def self.new2(user, password, host, port, path,
@@ -70,29 +71,27 @@ module URI
#
# Creates a new URI::FTP object from components, with syntax checking.
#
- # The components accepted are +userinfo+, +host+, +port+, +path+, and
+ # The components accepted are +userinfo+, +host+, +port+, +path+ and
# +typecode+.
#
# The components should be provided either as an Array, or as a Hash
# with keys formed by preceding the component names with a colon.
#
- # If an Array is used, the components must be passed in the
- # order <code>[userinfo, host, port, path, typecode]</code>.
+ # If an Array is used, the components must be passed in the order
+ # [userinfo, host, port, path, typecode]
#
# If the path supplied is absolute, it will be escaped in order to
- # make it absolute in the URI.
- #
- # Examples:
+ # make it absolute in the URI. Examples:
#
# require 'uri'
#
- # uri1 = URI::FTP.build(['user:password', 'ftp.example.com', nil,
+ # uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
# '/path/file.zip', 'i'])
- # uri1.to_s # => "ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i"
+ # puts uri.to_s -> ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i
#
# uri2 = URI::FTP.build({:host => 'ftp.example.com',
# :path => 'ruby/src'})
- # uri2.to_s # => "ftp://ftp.example.com/ruby/src"
+ # puts uri2.to_s -> ftp://ftp.example.com/ruby/src
#
def self.build(args)
@@ -129,7 +128,7 @@ module URI
# required by RFC1738; instead it is treated as per RFC2396.
#
# Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
- # +opaque+, +query+, and +fragment+, in that order.
+ # +opaque+, +query+ and +fragment+, in that order.
#
def initialize(scheme,
userinfo, host, port, registry,
@@ -156,13 +155,13 @@ module URI
end
end
- # typecode accessor.
+ # typecode accessor
#
- # See URI::FTP::COMPONENT.
+ # see URI::FTP::COMPONENT
attr_reader :typecode
- # Validates typecode +v+,
- # returns +true+ or +false+.
+ # validates typecode +v+,
+ # returns a +true+ or +false+ boolean
#
def check_typecode(v)
if TYPECODE.include?(v)
@@ -174,9 +173,9 @@ module URI
end
private :check_typecode
- # Private setter for the typecode +v+.
+ # Private setter for the typecode +v+
#
- # See also URI::FTP.typecode=.
+ # see also URI::FTP.typecode=
#
def set_typecode(v)
@typecode = v
@@ -191,20 +190,21 @@ module URI
#
# == Description
#
- # Public setter for the typecode +v+
- # (with validation).
+ # public setter for the typecode +v+.
+ # (with validation)
#
- # See also URI::FTP.check_typecode.
+ # see also URI::FTP.check_typecode
#
# == Usage
#
# require 'uri'
#
# uri = URI.parse("ftp://john@ftp.example.com/my_file.img")
- # #=> #<URI::FTP ftp://john@ftp.example.com/my_file.img>
+ # #=> #<URI::FTP:0x00000000923650 URL:ftp://john@ftp.example.com/my_file.img>
# uri.typecode = "i"
+ # # => "i"
# uri
- # #=> #<URI::FTP ftp://john@ftp.example.com/my_file.img;type=i>
+ # #=> #<URI::FTP:0x00000000923650 URL:ftp://john@ftp.example.com/my_file.img;type=i>
#
def typecode=(typecode)
check_typecode(typecode)
@@ -226,29 +226,29 @@ module URI
# RFC 1738 specifically states that the path for an FTP URI does not
# include the / which separates the URI path from the URI host. Example:
#
- # <code>ftp://ftp.example.com/pub/ruby</code>
+ # +ftp://ftp.example.com/pub/ruby+
#
# The above URI indicates that the client should connect to
- # ftp.example.com then cd to pub/ruby from the initial login directory.
+ # ftp.example.com then cd pub/ruby from the initial login directory.
#
# If you want to cd to an absolute directory, you must include an
# escaped / (%2F) in the path. Example:
#
- # <code>ftp://ftp.example.com/%2Fpub/ruby</code>
+ # +ftp://ftp.example.com/%2Fpub/ruby+
#
- # This method will then return "/pub/ruby".
+ # This method will then return "/pub/ruby"
#
def path
return @path.sub(/^\//,'').sub(/^%2F/,'/')
end
- # Private setter for the path of the URI::FTP.
+ # Private setter for the path of the URI::FTP
def set_path(v)
super("/" + v.sub(/^\//, "%2F"))
end
protected :set_path
- # Returns a String representation of the URI::FTP.
+ # Returns a String representation of the URI::FTP
def to_s
save_path = nil
if @typecode
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index c672d15eb2..140fb055de 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -9,7 +9,7 @@
# See URI for general documentation
#
-require_relative 'common'
+require 'uri/common'
autoload :IPSocket, 'socket'
autoload :IPAddr, 'ipaddr'
@@ -23,26 +23,26 @@ module URI
include URI
#
- # A Default port of nil for URI::Generic.
+ # A Default port of nil for URI::Generic
#
DEFAULT_PORT = nil
#
- # Returns default port.
+ # Returns default port
#
def self.default_port
self::DEFAULT_PORT
end
#
- # Returns default port.
+ # Returns default port
#
def default_port
self.class.default_port
end
#
- # An Array of the available components for URI::Generic.
+ # An Array of the available components for URI::Generic
#
COMPONENT = [
:scheme,
@@ -68,13 +68,14 @@ module URI
#
# == Synopsis
#
- # See ::new.
+ # See #new
#
# == Description
#
# At first, tries to create a new URI::Generic instance using
# URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
- # then it does URI::Escape.escape all URI components and tries again.
+ # then it URI::Escape.escape all URI components and tries again.
+ #
#
def self.build2(args)
begin
@@ -105,14 +106,14 @@ module URI
#
# == Synopsis
#
- # See ::new.
+ # See #new
#
# == Description
#
# Creates a new URI::Generic instance from components of URI::Generic
# with check. Components are: scheme, userinfo, host, port, registry, path,
- # opaque, query, and fragment. You can provide arguments either by an Array or a Hash.
- # See ::new for hash keys to use or for order of array items.
+ # opaque, query and fragment. You can provide arguments either by an Array or a Hash.
+ # See #new for hash keys to use or for order of array items.
#
def self.build(args)
if args.kind_of?(Array) &&
@@ -136,32 +137,31 @@ module URI
tmp << true
return self.new(*tmp)
end
-
#
# == Args
#
# +scheme+::
# Protocol scheme, i.e. 'http','ftp','mailto' and so on.
# +userinfo+::
- # User name and password, i.e. 'sdmitry:bla'.
+ # User name and password, i.e. 'sdmitry:bla'
# +host+::
- # Server host name.
+ # Server host name
# +port+::
- # Server port.
+ # Server port
# +registry+::
# Registry of naming authorities.
# +path+::
- # Path on server.
+ # Path on server
# +opaque+::
- # Opaque part.
+ # Opaque part
# +query+::
- # Query data.
+ # Query data
# +fragment+::
- # Part of the URI after '#' character.
+ # A part of URI after '#' sign
# +parser+::
- # Parser for internal use [URI::DEFAULT_PARSER by default].
+ # Parser for internal use [URI::DEFAULT_PARSER by default]
# +arg_check+::
- # Check arguments [false by default].
+ # Check arguments [false by default]
#
# == Description
#
@@ -215,38 +215,39 @@ module URI
end
#
- # Returns the scheme component of the URI.
+ # returns the scheme component of the URI.
#
# URI("http://foo/bar/baz").scheme #=> "http"
#
attr_reader :scheme
- # Returns the host component of the URI.
+ # returns the host component of the URI.
#
# URI("http://foo/bar/baz").host #=> "foo"
#
- # It returns nil if no host component exists.
+ # It returns nil if no host component.
#
# URI("mailto:foo@example.org").host #=> nil
#
- # The component does not contain the port number.
+ # The component doesn't contains the port number.
#
# URI("http://foo:8080/bar/baz").host #=> "foo"
#
- # Since IPv6 addresses are wrapped with brackets in URIs,
- # this method returns IPv6 addresses wrapped with brackets.
- # This form is not appropriate to pass to socket methods such as TCPSocket.open.
- # If unwrapped host names are required, use the #hostname method.
+ # Since IPv6 addresses are wrapped by brackets in URIs,
+ # this method returns IPv6 addresses wrapped by brackets.
+ # This form is not appropriate to pass socket methods such as TCPSocket.open.
+ # If unwrapped host names are required, use "hostname" method.
#
- # URI("http://[::1]/bar/baz").host #=> "[::1]"
+ # URI("http://[::1]/bar/baz").host #=> "[::1]"
# URI("http://[::1]/bar/baz").hostname #=> "::1"
#
attr_reader :host
- # Returns the port component of the URI.
+ # returns the port component of the URI.
#
- # URI("http://foo/bar/baz").port #=> 80
- # URI("http://foo:8080/bar/baz").port #=> 8080
+ # URI("http://foo/bar/baz").port #=> "80"
+ #
+ # URI("http://foo:8080/bar/baz").port #=> "8080"
#
attr_reader :port
@@ -254,38 +255,37 @@ module URI
nil
end
- # Returns the path component of the URI.
+ # returns the path component of the URI.
#
# URI("http://foo/bar/baz").path #=> "/bar/baz"
#
attr_reader :path
- # Returns the query component of the URI.
+ # returns the query component of the URI.
#
# URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
#
attr_reader :query
- # Returns the opaque part of the URI.
+ # returns the opaque part of the URI.
#
# URI("mailto:foo@example.org").opaque #=> "foo@example.org"
- # URI("http://foo/bar/baz").opaque #=> nil
#
- # The portion of the path that does not make use of the slash '/'.
- # The path typically refers to an absolute path or an opaque part.
+ # Portion of the path that does make use of the slash '/'.
+ # The path typically refers to the absolute path and the opaque part.
# (See RFC2396 Section 3 and 5.2.)
#
attr_reader :opaque
- # Returns the fragment component of the URI.
+ # returns the fragment component of the URI.
#
# URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
#
attr_reader :fragment
- # Returns the parser to be used.
+ # returns the parser to be used.
#
- # Unless a URI::Parser is defined, DEFAULT_PARSER is used.
+ # Unless a URI::Parser is defined, then DEFAULT_PARSER is used.
#
def parser
if !defined?(@parser) || !@parser
@@ -295,8 +295,7 @@ module URI
end
end
- # Replaces self by other URI object.
- #
+ # replace self by other URI object
def replace!(oth)
if self.class != oth.class
raise ArgumentError, "expected #{self.class} object"
@@ -316,7 +315,7 @@ module URI
end
#
- # Checks the scheme +v+ component against the URI::Parser Regexp for :SCHEME.
+ # check the scheme +v+ component against the URI::Parser Regexp for :SCHEME
#
def check_scheme(v)
if v && parser.regexp[:SCHEME] !~ v
@@ -328,9 +327,9 @@ module URI
end
private :check_scheme
- # Protected setter for the scheme component +v+.
+ # protected setter for the scheme component +v+
#
- # See also URI::Generic.scheme=.
+ # see also URI::Generic.scheme=
#
def set_scheme(v)
@scheme = v&.downcase
@@ -345,10 +344,10 @@ module URI
#
# == Description
#
- # Public setter for the scheme component +v+
- # (with validation).
+ # public setter for the scheme component +v+.
+ # (with validation)
#
- # See also URI::Generic.check_scheme.
+ # see also URI::Generic.check_scheme
#
# == Usage
#
@@ -356,7 +355,9 @@ module URI
#
# uri = URI.parse("http://my.example.com")
# uri.scheme = "https"
- # uri.to_s #=> "https://my.example.com"
+ # # => "https"
+ # uri
+ # #=> #<URI::HTTP:0x000000008e89e8 URL:https://my.example.com>
#
def scheme=(v)
check_scheme(v)
@@ -365,13 +366,13 @@ module URI
end
#
- # Checks the +user+ and +password+.
+ # check the +user+ and +password+.
#
# If +password+ is not provided, then +user+ is
# split, using URI::Generic.split_userinfo, to
# pull +user+ and +password.
#
- # See also URI::Generic.check_user, URI::Generic.check_password.
+ # see also URI::Generic.check_user, URI::Generic.check_password
#
def check_userinfo(user, password = nil)
if !password
@@ -385,8 +386,8 @@ module URI
private :check_userinfo
#
- # Checks the user +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :USERINFO.
+ # check the user +v+ component for RFC2396 compliance
+ # and against the URI::Parser Regexp for :USERINFO
#
# Can not have a registry or opaque component defined,
# with a user component defined.
@@ -409,8 +410,8 @@ module URI
private :check_user
#
- # Checks the password +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :USERINFO.
+ # check the password +v+ component for RFC2396 compliance
+ # and against the URI::Parser Regexp for :USERINFO
#
# Can not have a registry or opaque component defined,
# with a user component defined.
@@ -437,7 +438,7 @@ module URI
private :check_password
#
- # Sets userinfo, argument is string like 'name:pass'.
+ # Sets userinfo, argument is string like 'name:pass'
#
def userinfo=(userinfo)
if userinfo.nil?
@@ -456,10 +457,10 @@ module URI
#
# == Description
#
- # Public setter for the +user+ component
- # (with validation).
+ # public setter for the +user+ component.
+ # (with validation)
#
- # See also URI::Generic.check_user.
+ # see also URI::Generic.check_user
#
# == Usage
#
@@ -467,7 +468,9 @@ module URI
#
# uri = URI.parse("http://john:S3nsit1ve@my.example.com")
# uri.user = "sam"
- # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
+ # # => "sam"
+ # uri
+ # #=> #<URI::HTTP:0x00000000881d90 URL:http://sam:V3ry_S3nsit1ve@my.example.com>
#
def user=(user)
check_user(user)
@@ -483,10 +486,10 @@ module URI
#
# == Description
#
- # Public setter for the +password+ component
- # (with validation).
+ # public setter for the +password+ component.
+ # (with validation)
#
- # See also URI::Generic.check_password.
+ # see also URI::Generic.check_password
#
# == Usage
#
@@ -494,7 +497,9 @@ module URI
#
# uri = URI.parse("http://john:S3nsit1ve@my.example.com")
# uri.password = "V3ry_S3nsit1ve"
- # uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com"
+ # # => "V3ry_S3nsit1ve"
+ # uri
+ # #=> #<URI::HTTP:0x00000000881d90 URL:http://john:V3ry_S3nsit1ve@my.example.com>
#
def password=(password)
check_password(password)
@@ -502,10 +507,10 @@ module URI
# returns password
end
- # Protected setter for the +user+ component, and +password+ if available
- # (with validation).
+ # protect setter for the +user+ component, and +password+ if available.
+ # (with validation)
#
- # See also URI::Generic.userinfo=.
+ # see also URI::Generic.userinfo=
#
def set_userinfo(user, password = nil)
unless password
@@ -518,9 +523,9 @@ module URI
end
protected :set_userinfo
- # Protected setter for the user component +v+.
+ # protected setter for the user component +v+
#
- # See also URI::Generic.user=.
+ # see also URI::Generic.user=
#
def set_user(v)
set_userinfo(v, @password)
@@ -528,9 +533,9 @@ module URI
end
protected :set_user
- # Protected setter for the password component +v+.
+ # protected setter for the password component +v+
#
- # See also URI::Generic.password=.
+ # see also URI::Generic.password=
#
def set_password(v)
@password = v
@@ -538,8 +543,8 @@ module URI
end
protected :set_password
- # Returns the userinfo +ui+ as <code>[user, password]</code>
- # if properly formatted as 'user:password'.
+ # returns the userinfo +ui+ as user, password
+ # if properly formatted as 'user:password'
def split_userinfo(ui)
return nil, nil unless ui
user, password = ui.split(':', 2)
@@ -548,13 +553,13 @@ module URI
end
private :split_userinfo
- # Escapes 'user:password' +v+ based on RFC 1738 section 3.1.
+ # escapes 'user:password' +v+ based on RFC 1738 section 3.1
def escape_userpass(v)
parser.escape(v, /[@:\/]/o) # RFC 1738 section 3.1 #/
end
private :escape_userpass
- # Returns the userinfo, either as 'user' or 'user:password'.
+ # returns the userinfo, either as 'user' or 'user:password'
def userinfo
if @user.nil?
nil
@@ -565,19 +570,19 @@ module URI
end
end
- # Returns the user component.
+ # returns the user component
def user
@user
end
- # Returns the password component.
+ # returns the password component
def password
@password
end
#
- # Checks the host +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :HOST.
+ # check the host +v+ component for RFC2396 compliance
+ # and against the URI::Parser Regexp for :HOST
#
# Can not have a registry or opaque component defined,
# with a host component defined.
@@ -597,9 +602,9 @@ module URI
end
private :check_host
- # Protected setter for the host component +v+.
+ # protected setter for the host component +v+
#
- # See also URI::Generic.host=.
+ # see also URI::Generic.host=
#
def set_host(v)
@host = v
@@ -614,10 +619,10 @@ module URI
#
# == Description
#
- # Public setter for the host component +v+
- # (with validation).
+ # public setter for the host component +v+.
+ # (with validation)
#
- # See also URI::Generic.check_host.
+ # see also URI::Generic.check_host
#
# == Usage
#
@@ -625,7 +630,9 @@ module URI
#
# uri = URI.parse("http://my.example.com")
# uri.host = "foo.com"
- # uri.to_s #=> "http://foo.com"
+ # # => "foo.com"
+ # uri
+ # #=> #<URI::HTTP:0x000000008e89e8 URL:http://foo.com>
#
def host=(v)
check_host(v)
@@ -633,31 +640,32 @@ module URI
v
end
- # Extract the host part of the URI and unwrap brackets for IPv6 addresses.
+ # extract the host part of the URI and unwrap brackets for IPv6 addresses.
#
- # This method is the same as URI::Generic#host except
+ # This method is same as URI::Generic#host except
# brackets for IPv6 (and future IP) addresses are removed.
#
- # uri = URI("http://[::1]/bar")
- # uri.hostname #=> "::1"
- # uri.host #=> "[::1]"
+ # u = URI("http://[::1]/bar")
+ # p u.hostname #=> "::1"
+ # p u.host #=> "[::1]"
#
def hostname
v = self.host
/\A\[(.*)\]\z/ =~ v ? $1 : v
end
- # Sets the host part of the URI as the argument with brackets for IPv6 addresses.
+ # set the host part of the URI as the argument with brackets for IPv6 addresses.
#
- # This method is the same as URI::Generic#host= except
- # the argument can be a bare IPv6 address.
+ # This method is same as URI::Generic#host= except
+ # the argument can be bare IPv6 address.
#
- # uri = URI("http://foo/bar")
- # uri.hostname = "::1"
- # uri.to_s #=> "http://[::1]/bar"
+ # u = URI("http://foo/bar")
+ # p u.to_s #=> "http://foo/bar"
+ # u.hostname = "::1"
+ # p u.to_s #=> "http://[::1]/bar"
#
- # If the argument seems to be an IPv6 address,
- # it is wrapped with brackets.
+ # If the argument seems IPv6 address,
+ # it is wrapped by brackets.
#
def hostname=(v)
v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
@@ -665,8 +673,8 @@ module URI
end
#
- # Checks the port +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :PORT.
+ # check the port +v+ component for RFC2396 compliance
+ # and against the URI::Parser Regexp for :PORT
#
# Can not have a registry or opaque component defined,
# with a port component defined.
@@ -686,9 +694,9 @@ module URI
end
private :check_port
- # Protected setter for the port component +v+.
+ # protected setter for the port component +v+
#
- # See also URI::Generic.port=.
+ # see also URI::Generic.port=
#
def set_port(v)
v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Integer)
@@ -704,10 +712,10 @@ module URI
#
# == Description
#
- # Public setter for the port component +v+
- # (with validation).
+ # public setter for the port component +v+.
+ # (with validation)
#
- # See also URI::Generic.check_port.
+ # see also URI::Generic.check_port
#
# == Usage
#
@@ -715,7 +723,9 @@ module URI
#
# uri = URI.parse("http://my.example.com")
# uri.port = 8080
- # uri.to_s #=> "http://my.example.com:8080"
+ # # => 8080
+ # uri
+ # #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com:8080>
#
def port=(v)
check_port(v)
@@ -738,9 +748,9 @@ module URI
end
#
- # Checks the path +v+ component for RFC2396 compliance
+ # check the path +v+ component for RFC2396 compliance
# and against the URI::Parser Regexp
- # for :ABS_PATH and :REL_PATH.
+ # for :ABS_PATH and :REL_PATH
#
# Can not have a opaque component defined,
# with a path component defined.
@@ -773,9 +783,9 @@ module URI
end
private :check_path
- # Protected setter for the path component +v+.
+ # protected setter for the path component +v+
#
- # See also URI::Generic.path=.
+ # see also URI::Generic.path=
#
def set_path(v)
@path = v
@@ -790,10 +800,10 @@ module URI
#
# == Description
#
- # Public setter for the path component +v+
- # (with validation).
+ # public setter for the path component +v+.
+ # (with validation)
#
- # See also URI::Generic.check_path.
+ # see also URI::Generic.check_path
#
# == Usage
#
@@ -801,7 +811,9 @@ module URI
#
# uri = URI.parse("http://my.example.com/pub/files")
# uri.path = "/faq/"
- # uri.to_s #=> "http://my.example.com/faq/"
+ # # => "/faq/"
+ # uri
+ # #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com/faq/>
#
def path=(v)
check_path(v)
@@ -817,7 +829,7 @@ module URI
#
# == Description
#
- # Public setter for the query component +v+.
+ # public setter for the query component +v+.
#
# == Usage
#
@@ -825,7 +837,9 @@ module URI
#
# uri = URI.parse("http://my.example.com/?id=25")
# uri.query = "id=1"
- # uri.to_s #=> "http://my.example.com/?id=1"
+ # # => "id=1"
+ # uri
+ # #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com/?id=1>
#
def query=(v)
return @query = nil unless v
@@ -836,17 +850,16 @@ module URI
v.encode!(Encoding::UTF_8) rescue nil
v.delete!("\t\r\n")
v.force_encoding(Encoding::ASCII_8BIT)
- raise InvalidURIError, "invalid percent escape: #{$1}" if /(%\H\H)/n.match(v)
v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X' % $&.ord}
v.force_encoding(Encoding::US_ASCII)
@query = v
end
#
- # Checks the opaque +v+ component for RFC2396 compliance and
- # against the URI::Parser Regexp for :OPAQUE.
+ # check the opaque +v+ component for RFC2396 compliance and
+ # against the URI::Parser Regexp for :OPAQUE
#
- # Can not have a host, port, user, or path component defined,
+ # Can not have a host, port, user or path component defined,
# with an opaque component defined.
#
def check_opaque(v)
@@ -867,9 +880,9 @@ module URI
end
private :check_opaque
- # Protected setter for the opaque component +v+.
+ # protected setter for the opaque component +v+
#
- # See also URI::Generic.opaque=.
+ # see also URI::Generic.opaque=
#
def set_opaque(v)
@opaque = v
@@ -884,10 +897,10 @@ module URI
#
# == Description
#
- # Public setter for the opaque component +v+
- # (with validation).
+ # public setter for the opaque component +v+.
+ # (with validation)
#
- # See also URI::Generic.check_opaque.
+ # see also URI::Generic.check_opaque
#
def opaque=(v)
check_opaque(v)
@@ -896,7 +909,7 @@ module URI
end
#
- # Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT.
+ # check the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT
#
#
# == Args
@@ -906,8 +919,8 @@ module URI
#
# == Description
#
- # Public setter for the fragment component +v+
- # (with validation).
+ # public setter for the fragment component +v+.
+ # (with validation)
#
# == Usage
#
@@ -915,7 +928,9 @@ module URI
#
# uri = URI.parse("http://my.example.com/?id=25#time=1305212049")
# uri.fragment = "time=1305212086"
- # uri.to_s #=> "http://my.example.com/?id=25#time=1305212086"
+ # # => "time=1305212086"
+ # uri
+ # #=> #<URI::HTTP:0x000000007a81f8 URL:http://my.example.com/?id=25#time=1305212086>
#
def fragment=(v)
return @fragment = nil unless v
@@ -931,23 +946,7 @@ module URI
end
#
- # Returns true if URI is hierarchical.
- #
- # == Description
- #
- # URI has components listed in order of decreasing significance from left to right,
- # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
- #
- # == Usage
- #
- # require 'uri'
- #
- # uri = URI.parse("http://my.example.com/")
- # uri.hierarchical?
- # #=> true
- # uri = URI.parse("mailto:joe@example.com")
- # uri.hierarchical?
- # #=> false
+ # Checks if URI has a path
#
def hierarchical?
if @path
@@ -958,7 +957,7 @@ module URI
end
#
- # Returns true if URI has a scheme (e.g. http:// or https://) specified.
+ # Checks if URI is an absolute one
#
def absolute?
if @scheme
@@ -970,14 +969,14 @@ module URI
alias absolute absolute?
#
- # Returns true if URI does not have a scheme (e.g. http:// or https://) specified.
+ # Checks if URI is relative
#
def relative?
!absolute?
end
#
- # Returns an Array of the path split on '/'.
+ # returns an Array of the path split on '/'
#
def split_path(path)
path.split("/", -1)
@@ -1059,7 +1058,7 @@ module URI
#
# == Description
#
- # Destructive form of #merge.
+ # Destructive form of #merge
#
# == Usage
#
@@ -1067,7 +1066,8 @@ module URI
#
# uri = URI.parse("http://my.example.com")
# uri.merge!("/main.rbx?page=1")
- # uri.to_s # => "http://my.example.com/main.rbx?page=1"
+ # p uri
+ # # => #<URI::HTTP:0x2021f3b0 URL:http://my.example.com/main.rbx?page=1>
#
def merge!(oth)
t = merge(oth)
@@ -1087,15 +1087,15 @@ module URI
#
# == Description
#
- # Merges two URIs.
+ # Merges two URI's.
#
# == Usage
#
# require 'uri'
#
# uri = URI.parse("http://my.example.com")
- # uri.merge("/main.rbx?page=1")
- # # => "http://my.example.com/main.rbx?page=1"
+ # p uri.merge("/main.rbx?page=1")
+ # # => #<URI::HTTP:0x2021f3b0 URL:http://my.example.com/main.rbx?page=1>
#
def merge(oth)
rel = parser.send(:convert_to_uri, oth)
@@ -1240,15 +1240,15 @@ module URI
#
# == Description
#
- # Calculates relative path from oth to self.
+ # Calculates relative path from oth to self
#
# == Usage
#
# require 'uri'
#
# uri = URI.parse('http://my.example.com/main.rbx?page=1')
- # uri.route_from('http://my.example.com')
- # #=> #<URI::Generic /main.rbx?page=1>
+ # p uri.route_from('http://my.example.com')
+ # #=> #<URI::Generic:0x20218858 URL:/main.rbx?page=1>
#
def route_from(oth)
# you can modify `rel', but can not `oth'.
@@ -1280,15 +1280,15 @@ module URI
#
# == Description
#
- # Calculates relative path to oth from self.
+ # Calculates relative path to oth from self
#
# == Usage
#
# require 'uri'
#
# uri = URI.parse('http://my.example.com')
- # uri.route_to('http://my.example.com/main.rbx?page=1')
- # #=> #<URI::Generic /main.rbx?page=1>
+ # p uri.route_to('http://my.example.com/main.rbx?page=1')
+ # #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1>
#
def route_to(oth)
parser.send(:convert_to_uri, oth).route_from(self)
@@ -1314,7 +1314,7 @@ module URI
end
#
- # Destructive version of #normalize.
+ # Destructive version of #normalize
#
def normalize!
if path&.empty?
@@ -1329,7 +1329,7 @@ module URI
end
#
- # Constructs String from URI.
+ # Constructs String from URI
#
def to_s
str = ''.dup
@@ -1369,7 +1369,7 @@ module URI
end
#
- # Compares two URIs.
+ # Compares two URIs
#
def ==(oth)
if self.class == oth.class
@@ -1402,7 +1402,7 @@ module URI
=end
- # Returns an Array of the components defined from the COMPONENT Array.
+ # returns an Array of the components defined from the COMPONENT Array
def component_ary
component.collect do |x|
self.send(x)
@@ -1413,18 +1413,18 @@ module URI
# == Args
#
# +components+::
- # Multiple Symbol arguments defined in URI::HTTP.
+ # Multiple Symbol arguments defined in URI::HTTP
#
# == Description
#
- # Selects specified components from URI.
+ # Selects specified components from URI
#
# == Usage
#
# require 'uri'
#
# uri = URI.parse('http://myuser:mypass@my.example.com/test.rbx')
- # uri.select(:userinfo, :host, :path)
+ # p uri.select(:userinfo, :host, :path)
# # => ["myuser:mypass", "my.example.com", "/test.rbx"]
#
def select(*components)
@@ -1450,8 +1450,8 @@ module URI
#
# == Description
#
- # Attempts to parse other URI +oth+,
- # returns [parsed_oth, self].
+ # attempts to parse other URI +oth+,
+ # returns [parsed_oth, self]
#
# == Usage
#
@@ -1459,7 +1459,7 @@ module URI
#
# uri = URI.parse("http://my.example.com")
# uri.coerce("http://foo.com")
- # #=> [#<URI::HTTP http://foo.com>, #<URI::HTTP http://my.example.com>]
+ # #=> [#<URI::HTTP:0x00000000bcb028 URL:http://foo.com/>, #<URI::HTTP:0x00000000d92178 URL:http://my.example.com>]
#
def coerce(oth)
case oth
@@ -1472,15 +1472,15 @@ module URI
return oth, self
end
- # Returns a proxy URI.
+ # returns a proxy URI.
# The proxy URI is obtained from environment variables such as http_proxy,
# ftp_proxy, no_proxy, etc.
# If there is no proper proxy, nil is returned.
#
- # If the optional parameter +env+ is specified, it is used instead of ENV.
+ # If the optional parameter, +env+, is specified, it is used instead of ENV.
#
# Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
- # are examined, too.
+ # are examined too.
#
# But http_proxy and HTTP_PROXY is treated specially under CGI environment.
# It's because HTTP_PROXY may be set by Proxy: header.
@@ -1544,16 +1544,11 @@ module URI
end
def self.use_proxy?(hostname, addr, port, no_proxy) # :nodoc:
- hostname = hostname.downcase
- dothostname = ".#{hostname}"
- no_proxy.scan(/([^:,\s]+)(?::(\d+))?/) {|p_host, p_port|
+ no_proxy.scan(/(?!\.)([^:,\s]+)(?::(\d+))?/) {|p_host, p_port|
if !p_port || port == p_port.to_i
- if p_host.start_with?('.')
- return false if hostname.end_with?(p_host.downcase)
- else
- return false if dothostname.end_with?(".#{p_host.downcase}")
- end
- if addr
+ if /(\A|\.)#{Regexp.quote p_host}\z/i =~ hostname
+ return false
+ elsif addr
begin
return false if IPAddr.new(p_host).include?(addr)
rescue IPAddr::InvalidAddressError
diff --git a/lib/uri/http.rb b/lib/uri/http.rb
index 2e2ebcc1d3..0af1858efe 100644
--- a/lib/uri/http.rb
+++ b/lib/uri/http.rb
@@ -8,7 +8,7 @@
# See URI for general documentation
#
-require_relative 'generic'
+require 'uri/generic'
module URI
@@ -21,10 +21,10 @@ module URI
# update. See <URL:http://support.microsoft.com/kb/834489>.
#
class HTTP < Generic
- # A Default port of 80 for URI::HTTP.
+ # A Default port of 80 for URI::HTTP
DEFAULT_PORT = 80
- # An Array of the available components for URI::HTTP.
+ # An Array of the available components for URI::HTTP
COMPONENT = %i[
scheme
userinfo host port
@@ -36,22 +36,22 @@ module URI
#
# == Description
#
- # Creates a new URI::HTTP object from components, with syntax checking.
+ # Create a new URI::HTTP object from components, with syntax checking.
#
- # The components accepted are userinfo, host, port, path, query, and
+ # The components accepted are userinfo, host, port, path, query and
# fragment.
#
# The components should be provided either as an Array, or as a Hash
# with keys formed by preceding the component names with a colon.
#
- # If an Array is used, the components must be passed in the
- # order <code>[userinfo, host, port, path, query, fragment]</code>.
+ # If an Array is used, the components must be passed in the order
+ # [userinfo, host, port, path, query, fragment].
#
# Example:
#
- # uri = URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
+ # newuri = URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
#
- # uri = URI::HTTP.build([nil, "www.example.com", nil, "/path",
+ # newuri = URI::HTTP.build([nil, "www.example.com", nil, "/path",
# "query", 'fragment'])
#
# Currently, if passed userinfo components this method generates
@@ -72,8 +72,8 @@ module URI
#
# Example:
#
- # uri = URI::HTTP.build(path: '/foo/bar', query: 'test=true')
- # uri.request_uri # => "/foo/bar?test=true"
+ # newuri = URI::HTTP.build(path: '/foo/bar', query: 'test=true')
+ # newuri.request_uri # => "/foo/bar?test=true"
#
def request_uri
return unless @path
diff --git a/lib/uri/https.rb b/lib/uri/https.rb
index 4780ee0a44..3c8c905cc3 100644
--- a/lib/uri/https.rb
+++ b/lib/uri/https.rb
@@ -8,7 +8,7 @@
# See URI for general documentation
#
-require_relative 'http'
+require 'uri/http'
module URI
diff --git a/lib/uri/ldap.rb b/lib/uri/ldap.rb
index 61ec3d3f12..4345875e28 100644
--- a/lib/uri/ldap.rb
+++ b/lib/uri/ldap.rb
@@ -12,21 +12,20 @@
# See URI for general documentation
#
-require_relative 'generic'
+require 'uri/generic'
module URI
#
- # LDAP URI SCHEMA (described in RFC2255).
- #--
+ # LDAP URI SCHEMA (described in RFC2255)
# ldap://<host>/<dn>[?<attrs>[?<scope>[?<filter>[?<extensions>]]]]
- #++
+ #
class LDAP < Generic
- # A Default port of 389 for URI::LDAP.
+ # A Default port of 389 for URI::LDAP
DEFAULT_PORT = 389
- # An Array of the available components for URI::LDAP.
+ # An Array of the available components for URI::LDAP
COMPONENT = [
:scheme,
:host, :port,
@@ -41,8 +40,8 @@ module URI
#
# * SCOPE_BASE - the Base DN
# * SCOPE_ONE - one level under the Base DN, not including the base DN and
- # not including any entries under this
- # * SCOPE_SUB - subtrees, all entries at all levels
+ # not including any entries under this.
+ # * SCOPE_SUB - subtress, all entries at all levels
#
SCOPE = [
SCOPE_ONE = 'one',
@@ -53,7 +52,7 @@ module URI
#
# == Description
#
- # Creates a new URI::LDAP object from components, with syntax checking.
+ # Create a new URI::LDAP object from components, with syntax checking.
#
# The components accepted are host, port, dn, attributes,
# scope, filter, and extensions.
@@ -61,15 +60,15 @@ module URI
# The components should be provided either as an Array, or as a Hash
# with keys formed by preceding the component names with a colon.
#
- # If an Array is used, the components must be passed in the
- # order <code>[host, port, dn, attributes, scope, filter, extensions]</code>.
+ # If an Array is used, the components must be passed in the order
+ # [host, port, dn, attributes, scope, filter, extensions].
#
# Example:
#
- # uri = URI::LDAP.build({:host => 'ldap.example.com',
- # :dn => '/dc=example'})
+ # newuri = URI::LDAP.build({:host => 'ldap.example.com',
+ # :dn> => '/dc=example'})
#
- # uri = URI::LDAP.build(["ldap.example.com", nil,
+ # newuri = URI::LDAP.build(["ldap.example.com", nil,
# "/dc=example;dc=com", "query", nil, nil, nil])
#
def self.build(args)
@@ -93,18 +92,19 @@ module URI
#
# == Description
#
- # Creates a new URI::LDAP object from generic URI components as per
+ # Create a new URI::LDAP object from generic URI components as per
# RFC 2396. No LDAP-specific syntax checking is performed.
#
# Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
- # +opaque+, +query+, and +fragment+, in that order.
+ # +opaque+, +query+ and +fragment+, in that order.
#
# Example:
#
- # uri = URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil,
- # "/dc=example;dc=com", nil, "query", nil)
+ # uri = URI::LDAP.new("ldap", nil, "ldap.example.com", nil,
+ # "/dc=example;dc=com", "query", nil, nil, nil, nil)
+ #
#
- # See also URI::Generic.new.
+ # See also URI::Generic.new
#
def initialize(*arg)
super(*arg)
@@ -117,15 +117,14 @@ module URI
parse_query
end
- # Private method to cleanup +dn+ from using the +path+ component attribute.
+ # private method to cleanup +dn+ from using the +path+ component attribute
def parse_dn
- raise InvalidURIError, 'bad LDAP URL' unless @path
@dn = @path[1..-1]
end
private :parse_dn
- # Private method to cleanup +attributes+, +scope+, +filter+, and +extensions+
- # from using the +query+ component attribute.
+ # private method to cleanup +attributes+, +scope+, +filter+ and +extensions+,
+ # from using the +query+ component attribute
def parse_query
@attributes = nil
@scope = nil
@@ -143,7 +142,7 @@ module URI
end
private :parse_query
- # Private method to assemble +query+ from +attributes+, +scope+, +filter+, and +extensions+.
+ # private method to assemble +query+ from +attributes+, +scope+, +filter+ and +extensions+.
def build_path_query
@path = '/' + @dn
@@ -156,12 +155,12 @@ module URI
end
private :build_path_query
- # Returns dn.
+ # returns dn.
def dn
@dn
end
- # Private setter for dn +val+.
+ # private setter for dn +val+
def set_dn(val)
@dn = val
build_path_query
@@ -169,18 +168,18 @@ module URI
end
protected :set_dn
- # Setter for dn +val+.
+ # setter for dn +val+
def dn=(val)
set_dn(val)
val
end
- # Returns attributes.
+ # returns attributes.
def attributes
@attributes
end
- # Private setter for attributes +val+.
+ # private setter for attributes +val+
def set_attributes(val)
@attributes = val
build_path_query
@@ -188,18 +187,18 @@ module URI
end
protected :set_attributes
- # Setter for attributes +val+.
+ # setter for attributes +val+
def attributes=(val)
set_attributes(val)
val
end
- # Returns scope.
+ # returns scope.
def scope
@scope
end
- # Private setter for scope +val+.
+ # private setter for scope +val+
def set_scope(val)
@scope = val
build_path_query
@@ -207,18 +206,18 @@ module URI
end
protected :set_scope
- # Setter for scope +val+.
+ # setter for scope +val+
def scope=(val)
set_scope(val)
val
end
- # Returns filter.
+ # returns filter.
def filter
@filter
end
- # Private setter for filter +val+.
+ # private setter for filter +val+
def set_filter(val)
@filter = val
build_path_query
@@ -226,18 +225,18 @@ module URI
end
protected :set_filter
- # Setter for filter +val+.
+ # setter for filter +val+
def filter=(val)
set_filter(val)
val
end
- # Returns extensions.
+ # returns extensions.
def extensions
@extensions
end
- # Private setter for extensions +val+.
+ # private setter for extensions +val+
def set_extensions(val)
@extensions = val
build_path_query
@@ -245,14 +244,14 @@ module URI
end
protected :set_extensions
- # Setter for extensions +val+.
+ # setter for extensions +val+
def extensions=(val)
set_extensions(val)
val
end
- # Checks if URI has a path.
- # For URI::LDAP this will return +false+.
+ # Checks if URI has a path
+ # For URI::LDAP this will return +false+
def hierarchical?
false
end
diff --git a/lib/uri/ldaps.rb b/lib/uri/ldaps.rb
index 227e7fab35..d03f8efa2d 100644
--- a/lib/uri/ldaps.rb
+++ b/lib/uri/ldaps.rb
@@ -6,7 +6,7 @@
# See URI for general documentation
#
-require_relative 'ldap'
+require 'uri/ldap'
module URI
diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb
index 9c06871c7a..1494c3952b 100644
--- a/lib/uri/mailto.rb
+++ b/lib/uri/mailto.rb
@@ -8,20 +8,20 @@
# See URI for general documentation
#
-require_relative 'generic'
+require 'uri/generic'
module URI
#
- # RFC6068, the mailto URL scheme.
+ # RFC6068, The mailto URL scheme
#
class MailTo < Generic
include REGEXP
- # A Default port of nil for URI::MailTo.
+ # A Default port of nil for URI::MailTo
DEFAULT_PORT = nil
- # An Array of the available components for URI::MailTo.
+ # An Array of the available components for URI::MailTo
COMPONENT = [ :scheme, :to, :headers ].freeze
# :stopdoc:
@@ -52,7 +52,7 @@ module URI
# pct-encoded = "%" HEXDIG HEXDIG
HEADER_REGEXP = /\A(?<hfield>(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g<hfield>)*\z/
# practical regexp for email address
- # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
+ # http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
EMAIL_REGEXP = /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/
# :startdoc:
@@ -62,26 +62,26 @@ module URI
# Creates a new URI::MailTo object from components, with syntax checking.
#
# Components can be provided as an Array or Hash. If an Array is used,
- # the components must be supplied as <code>[to, headers]</code>.
+ # the components must be supplied as [to, headers].
#
# If a Hash is used, the keys are the component names preceded by colons.
#
# The headers can be supplied as a pre-encoded string, such as
- # <code>"subject=subscribe&cc=address"</code>, or as an Array of Arrays
- # like <code>[['subject', 'subscribe'], ['cc', 'address']]</code>.
+ # "subject=subscribe&cc=address", or as an Array of Arrays like
+ # [['subject', 'subscribe'], ['cc', 'address']]
#
# Examples:
#
# require 'uri'
#
# m1 = URI::MailTo.build(['joe@example.com', 'subject=Ruby'])
- # m1.to_s # => "mailto:joe@example.com?subject=Ruby"
+ # puts m1.to_s -> mailto:joe@example.com?subject=Ruby
#
# m2 = URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]])
- # m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com"
+ # puts m2.to_s -> mailto:john@example.com?Subject=Ruby&Cc=jack@example.com
#
# m3 = URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]})
- # m3.to_s # => "mailto:listman@example.com?subject=subscribe"
+ # puts m3.to_s -> mailto:listman@example.com?subject=subscribe
#
def self.build(args)
tmp = Util.make_components_hash(self, args)
@@ -160,13 +160,13 @@ module URI
end
end
- # The primary e-mail address of the URL, as a String.
+ # The primary e-mail address of the URL, as a String
attr_reader :to
- # E-mail headers set by the URL, as an Array of Arrays.
+ # E-mail headers set by the URL, as an Array of Arrays
attr_reader :headers
- # Checks the to +v+ component.
+ # check the to +v+ component
def check_to(v)
return true unless v
return true if v.size == 0
@@ -191,20 +191,20 @@ module URI
end
private :check_to
- # Private setter for to +v+.
+ # private setter for to +v+
def set_to(v)
@to = v
end
protected :set_to
- # Setter for to +v+.
+ # setter for to +v+
def to=(v)
check_to(v)
set_to(v)
v
end
- # Checks the headers +v+ component against either
+ # check the headers +v+ component against either
# * HEADER_REGEXP
def check_headers(v)
return true unless v
@@ -218,7 +218,7 @@ module URI
end
private :check_headers
- # Private setter for headers +v+.
+ # private setter for headers +v+
def set_headers(v)
@headers = []
if v
@@ -229,14 +229,14 @@ module URI
end
protected :set_headers
- # Setter for headers +v+.
+ # setter for headers +v+
def headers=(v)
check_headers(v)
set_headers(v)
v
end
- # Constructs String from URI.
+ # Constructs String from URI
def to_s
@scheme + ':' +
if @to
diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb
index 556da20aa2..b9e7b2b26e 100644
--- a/lib/uri/rfc2396_parser.rb
+++ b/lib/uri/rfc2396_parser.rb
@@ -58,7 +58,7 @@ module URI
# :startdoc:
end # REGEXP
- # Class that parses String's into URI's.
+ # class that Parses String's into URI's
#
# It contains a Hash set of patterns and Regexp's that match and validate.
#
@@ -88,12 +88,12 @@ module URI
# == Examples
#
# p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
- # u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD>
+ # u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP:0xb78cf4f8 URL:http://example.jp/%uABCD>
# URI.parse(u.to_s) #=> raises URI::InvalidURIError
#
# s = "http://example.com/ABCD"
- # u1 = p.parse(s) #=> #<URI::HTTP http://example.com/ABCD>
- # u2 = URI.parse(s) #=> #<URI::HTTP http://example.com/ABCD>
+ # u1 = p.parse(s) #=> #<URI::HTTP:0xb78c3220 URL:http://example.com/ABCD>
+ # u2 = URI.parse(s) #=> #<URI::HTTP:0xb78b6d54 URL:http://example.com/ABCD>
# u1 == u2 #=> true
# u1.eql?(u2) #=> false
#
@@ -109,15 +109,15 @@ module URI
# The Hash of patterns.
#
- # See also URI::Parser.initialize_pattern.
+ # see also URI::Parser.initialize_pattern
attr_reader :pattern
- # The Hash of Regexp.
+ # The Hash of Regexp
#
- # See also URI::Parser.initialize_regexp.
+ # see also URI::Parser.initialize_regexp
attr_reader :regexp
- # Returns a split URI against regexp[:ABS_URI].
+ # Returns a split URI against regexp[:ABS_URI]
def split(uri)
case uri
when ''
@@ -198,14 +198,14 @@ module URI
#
# == Description
#
- # Parses +uri+ and constructs either matching URI scheme object
- # (File, FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or URI::Generic.
+ # parses +uri+ and constructs either matching URI scheme object
+ # (FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or URI::Generic
#
# == Usage
#
# p = URI::Parser.new
# p.parse("ldap://ldap.example.com/dc=example?user=john")
- # #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
+ # #=> #<URI::LDAP:0x00000000b9e7e8 URL:ldap://ldap.example.com/dc=example?user=john>
#
def parse(uri)
scheme, userinfo, host, port,
@@ -231,7 +231,7 @@ module URI
#
# == Description
#
- # Attempts to parse and merge a set of URIs.
+ # Attempts to parse and merge a set of URIs
#
def join(*uris)
uris[0] = convert_to_uri(uris[0])
@@ -253,11 +253,11 @@ module URI
#
# == Description
#
- # Attempts to parse and merge a set of URIs.
- # If no +block+ given, then returns the result,
+ # Attempts to parse and merge a set of URIs
+ # If no +block+ given , then returns the result,
# else it calls +block+ for each element in result.
#
- # See also URI::Parser.make_regexp.
+ # see also URI::Parser.make_regexp
#
def extract(str, schemes = nil)
if block_given?
@@ -270,8 +270,8 @@ module URI
end
end
- # Returns Regexp that is default self.regexp[:ABS_URI_REF],
- # unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI].
+ # returns Regexp that is default self.regexp[:ABS_URI_REF],
+ # unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI]
def make_regexp(schemes = nil)
unless schemes
@regexp[:ABS_URI_REF]
@@ -294,7 +294,7 @@ module URI
#
# == Description
#
- # Constructs a safe String from +str+, removing unsafe characters,
+ # constructs a safe String from +str+, removing unsafe characters,
# replacing them with codes.
#
def escape(str, unsafe = @regexp[:UNSAFE])
@@ -315,33 +315,31 @@ module URI
#
# :call-seq:
# unescape( str )
- # unescape( str, escaped )
+ # unescape( str, unsafe )
#
# == Args
#
# +str+::
# String to remove escapes from
- # +escaped+::
+ # +unsafe+::
# Regexp to apply. Defaults to self.regexp[:ESCAPED]
#
# == Description
#
- # Removes escapes from +str+.
+ # Removes escapes from +str+
#
def unescape(str, escaped = @regexp[:ESCAPED])
- enc = str.encoding
- enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
- str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
+ str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)
end
@@to_s = Kernel.instance_method(:to_s)
def inspect
- @@to_s.bind_call(self)
+ @@to_s.bind(self).call
end
private
- # Constructs the default Hash of patterns.
+ # Constructs the default Hash of patterns
def initialize_pattern(opts = {})
ret = {}
ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
@@ -499,7 +497,7 @@ module URI
ret
end
- # Constructs the default Hash of Regexp's.
+ # Constructs the default Hash of Regexp's
def initialize_regexp(pattern)
ret = {}
diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb
index 08539f069a..871280044a 100644
--- a/lib/uri/rfc3986_parser.rb
+++ b/lib/uri/rfc3986_parser.rb
@@ -15,7 +15,7 @@ module URI
begin
uri = uri.to_str
rescue NoMethodError
- raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
+ raise InvalidURIError, "bad URI(is not URI?): #{uri}"
end
uri.ascii_only? or
raise InvalidURIError, "URI must be ascii only #{uri.dump}"
@@ -64,7 +64,7 @@ module URI
m["fragment".freeze]
]
else
- raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
+ raise InvalidURIError, "bad URI(is not URI?): #{uri}"
end
end
@@ -91,7 +91,7 @@ module URI
@@to_s = Kernel.instance_method(:to_s)
def inspect
- @@to_s.bind_call(self)
+ @@to_s.bind(self).call
end
private
diff --git a/lib/uri/uri.gemspec b/lib/uri/uri.gemspec
deleted file mode 100644
index 95cb8e2d42..0000000000
--- a/lib/uri/uri.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/uri/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "uri"
- spec.version = URI::VERSION
- spec.authors = ["Akira Yamada"]
- spec.email = ["akira@ruby-lang.org"]
-
- spec.summary = %q{URI is a module providing classes to handle Uniform Resource Identifiers}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/uri"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/uri/version.rb b/lib/uri/version.rb
deleted file mode 100644
index 4f54113393..0000000000
--- a/lib/uri/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module URI
- # :stopdoc:
- VERSION_CODE = '001000'.freeze
- VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
- # :startdoc:
-end
diff --git a/lib/webrick.rb b/lib/webrick.rb
index 1c0eb81dbd..cbaf18a792 100644
--- a/lib/webrick.rb
+++ b/lib/webrick.rb
@@ -212,7 +212,7 @@ require 'webrick/version.rb'
require 'webrick/config.rb'
require 'webrick/log.rb'
require 'webrick/server.rb'
-require_relative 'webrick/utils.rb'
+require 'webrick/utils.rb'
require 'webrick/accesslog'
require 'webrick/htmlutils.rb'
diff --git a/lib/webrick/accesslog.rb b/lib/webrick/accesslog.rb
index e4849637f3..17e5b38ac9 100644
--- a/lib/webrick/accesslog.rb
+++ b/lib/webrick/accesslog.rb
@@ -149,9 +149,11 @@ module WEBrick
# Escapes control characters in +data+
def escape(data)
- data = data.gsub(/[[:cntrl:]\\]+/) {$&.dump[1...-1]}
- data.untaint if RUBY_VERSION < '2.7'
- data
+ if data.tainted?
+ data.gsub(/[[:cntrl:]\\]+/) {$&.dump[1...-1]}.untaint
+ else
+ data
+ end
end
end
end
diff --git a/lib/webrick/cgi.rb b/lib/webrick/cgi.rb
index bb0ae2fc84..33f1542731 100644
--- a/lib/webrick/cgi.rb
+++ b/lib/webrick/cgi.rb
@@ -8,9 +8,9 @@
#
# $Id$
-require_relative "httprequest"
-require_relative "httpresponse"
-require_relative "config"
+require "webrick/httprequest"
+require "webrick/httpresponse"
+require "webrick/config"
require "stringio"
module WEBrick
diff --git a/lib/webrick/config.rb b/lib/webrick/config.rb
index 9f2ab44f49..af4b561534 100644
--- a/lib/webrick/config.rb
+++ b/lib/webrick/config.rb
@@ -9,11 +9,11 @@
#
# $IPR: config.rb,v 1.52 2003/07/22 19:20:42 gotoyuzo Exp $
-require_relative 'version'
-require_relative 'httpversion'
-require_relative 'httputils'
-require_relative 'utils'
-require_relative 'log'
+require 'webrick/version'
+require 'webrick/httpversion'
+require 'webrick/httputils'
+require 'webrick/utils'
+require 'webrick/log'
module WEBrick
module Config
diff --git a/lib/webrick/cookie.rb b/lib/webrick/cookie.rb
index 5fd3bfb228..24bf92ec00 100644
--- a/lib/webrick/cookie.rb
+++ b/lib/webrick/cookie.rb
@@ -10,7 +10,7 @@
# $IPR: cookie.rb,v 1.16 2002/09/21 12:23:35 gotoyuzo Exp $
require 'time'
-require_relative 'httputils'
+require 'webrick/httputils'
module WEBrick
diff --git a/lib/webrick/httpauth.rb b/lib/webrick/httpauth.rb
index f8bf09a6f1..bbb6776528 100644
--- a/lib/webrick/httpauth.rb
+++ b/lib/webrick/httpauth.rb
@@ -9,11 +9,11 @@
#
# $IPR: httpauth.rb,v 1.14 2003/07/22 19:20:42 gotoyuzo Exp $
-require_relative 'httpauth/basicauth'
-require_relative 'httpauth/digestauth'
-require_relative 'httpauth/htpasswd'
-require_relative 'httpauth/htdigest'
-require_relative 'httpauth/htgroup'
+require 'webrick/httpauth/basicauth'
+require 'webrick/httpauth/digestauth'
+require 'webrick/httpauth/htpasswd'
+require 'webrick/httpauth/htdigest'
+require 'webrick/httpauth/htgroup'
module WEBrick
diff --git a/lib/webrick/httpauth/basicauth.rb b/lib/webrick/httpauth/basicauth.rb
index 7d0a9cfc8f..e23420fdfa 100644
--- a/lib/webrick/httpauth/basicauth.rb
+++ b/lib/webrick/httpauth/basicauth.rb
@@ -8,9 +8,9 @@
#
# $IPR: basicauth.rb,v 1.5 2003/02/20 07:15:47 gotoyuzo Exp $
-require_relative '../config'
-require_relative '../httpstatus'
-require_relative 'authenticator'
+require 'webrick/config'
+require 'webrick/httpstatus'
+require 'webrick/httpauth/authenticator'
module WEBrick
module HTTPAuth
@@ -24,7 +24,7 @@ module WEBrick
#
# config = { :Realm => 'BasicAuth example realm' }
#
- # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file', password_hash: :bcrypt
+ # htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file'
# htpasswd.set_passwd config[:Realm], 'username', 'password'
# htpasswd.flush
#
@@ -81,15 +81,7 @@ module WEBrick
error("%s: the user is not allowed.", userid)
challenge(req, res)
end
-
- case encpass
- when /\A\$2[aby]\$/
- password_matches = BCrypt::Password.new(encpass.sub(/\A\$2[aby]\$/, '$2a$')) == password
- else
- password_matches = password.crypt(encpass) == encpass
- end
-
- unless password_matches
+ if password.crypt(encpass) != encpass
error("%s: password unmatch.", userid)
challenge(req, res)
end
diff --git a/lib/webrick/httpauth/digestauth.rb b/lib/webrick/httpauth/digestauth.rb
index 3cf12899d2..c2d5c16cad 100644
--- a/lib/webrick/httpauth/digestauth.rb
+++ b/lib/webrick/httpauth/digestauth.rb
@@ -12,9 +12,9 @@
#
# $IPR: digestauth.rb,v 1.5 2003/02/20 07:15:47 gotoyuzo Exp $
-require_relative '../config'
-require_relative '../httpstatus'
-require_relative 'authenticator'
+require 'webrick/config'
+require 'webrick/httpstatus'
+require 'webrick/httpauth/authenticator'
require 'digest/md5'
require 'digest/sha1'
diff --git a/lib/webrick/httpauth/htdigest.rb b/lib/webrick/httpauth/htdigest.rb
index 93b18e2c75..c35b38433b 100644
--- a/lib/webrick/httpauth/htdigest.rb
+++ b/lib/webrick/httpauth/htdigest.rb
@@ -8,8 +8,8 @@
#
# $IPR: htdigest.rb,v 1.4 2003/07/22 19:20:45 gotoyuzo Exp $
-require_relative 'userdb'
-require_relative 'digestauth'
+require 'webrick/httpauth/userdb'
+require 'webrick/httpauth/digestauth'
require 'tempfile'
module WEBrick
diff --git a/lib/webrick/httpauth/htgroup.rb b/lib/webrick/httpauth/htgroup.rb
index e06c441b18..399a62c37f 100644
--- a/lib/webrick/httpauth/htgroup.rb
+++ b/lib/webrick/httpauth/htgroup.rb
@@ -63,18 +63,15 @@ module WEBrick
def flush(output=nil)
output ||= @path
- tmp = Tempfile.create("htgroup", File::dirname(output))
+ tmp = Tempfile.new("htgroup", File::dirname(output))
begin
@group.keys.sort.each{|group|
tmp.puts(format("%s: %s", group, self.members(group).join(" ")))
}
- ensure
tmp.close
- if $!
- File.unlink(tmp.path)
- else
- return File.rename(tmp.path, output)
- end
+ File::rename(tmp.path, output)
+ rescue
+ tmp.close(true)
end
end
diff --git a/lib/webrick/httpauth/htpasswd.rb b/lib/webrick/httpauth/htpasswd.rb
index abca30532e..976eeeb13e 100644
--- a/lib/webrick/httpauth/htpasswd.rb
+++ b/lib/webrick/httpauth/htpasswd.rb
@@ -8,8 +8,8 @@
#
# $IPR: htpasswd.rb,v 1.4 2003/07/22 19:20:45 gotoyuzo Exp $
-require_relative 'userdb'
-require_relative 'basicauth'
+require 'webrick/httpauth/userdb'
+require 'webrick/httpauth/basicauth'
require 'tempfile'
module WEBrick
@@ -35,29 +35,11 @@ module WEBrick
##
# Open a password database at +path+
- def initialize(path, password_hash: nil)
+ def initialize(path)
@path = path
@mtime = Time.at(0)
@passwd = Hash.new
@auth_type = BasicAuth
- @password_hash = password_hash
-
- case @password_hash
- when nil
- # begin
- # require "string/crypt"
- # rescue LoadError
- # warn("Unable to load string/crypt, proceeding with deprecated use of String#crypt, consider using password_hash: :bcrypt")
- # end
- @password_hash = :crypt
- when :crypt
- # require "string/crypt"
- when :bcrypt
- require "bcrypt"
- else
- raise ArgumentError, "only :crypt and :bcrypt are supported for password_hash keyword argument"
- end
-
File.open(@path,"a").close unless File.exist?(@path)
reload
end
@@ -74,14 +56,6 @@ module WEBrick
line.chomp!
case line
when %r!\A[^:]+:[a-zA-Z0-9./]{13}\z!
- if @password_hash == :bcrypt
- raise StandardError, ".htpasswd file contains crypt password, only bcrypt passwords supported"
- end
- user, pass = line.split(":")
- when %r!\A[^:]+:\$2[aby]\$\d{2}\$.{53}\z!
- if @password_hash == :crypt
- raise StandardError, ".htpasswd file contains bcrypt password, only crypt passwords supported"
- end
user, pass = line.split(":")
when /:\$/, /:{SHA}/
raise NotImplementedError,
@@ -128,14 +102,7 @@ module WEBrick
# Sets a password in the database for +user+ in +realm+ to +pass+.
def set_passwd(realm, user, pass)
- if @password_hash == :bcrypt
- # Cost of 5 to match Apache default, and because the
- # bcrypt default of 10 will introduce significant delays
- # for every request.
- @passwd[user] = BCrypt::Password.create(pass, :cost=>5)
- else
- @passwd[user] = make_passwd(realm, user, pass)
- end
+ @passwd[user] = make_passwd(realm, user, pass)
end
##
diff --git a/lib/webrick/httpproxy.rb b/lib/webrick/httpproxy.rb
index d05d59514c..be5531fec0 100644
--- a/lib/webrick/httpproxy.rb
+++ b/lib/webrick/httpproxy.rb
@@ -10,7 +10,7 @@
# $IPR: httpproxy.rb,v 1.18 2003/03/08 18:58:10 gotoyuzo Exp $
# $kNotwork: straw.rb,v 1.3 2002/02/12 15:13:07 gotoken Exp $
-require_relative "httpserver"
+require "webrick/httpserver"
require "net/http"
module WEBrick
@@ -211,15 +211,21 @@ module WEBrick
end
def do_GET(req, res)
- perform_proxy_request(req, res, Net::HTTP::Get)
+ perform_proxy_request(req, res) do |http, path, header|
+ http.get(path, header)
+ end
end
def do_HEAD(req, res)
- perform_proxy_request(req, res, Net::HTTP::Head)
+ perform_proxy_request(req, res) do |http, path, header|
+ http.head(path, header)
+ end
end
def do_POST(req, res)
- perform_proxy_request(req, res, Net::HTTP::Post, req.body_reader)
+ perform_proxy_request(req, res) do |http, path, header|
+ http.post(path, req.body || "", header)
+ end
end
def do_OPTIONS(req, res)
@@ -295,56 +301,38 @@ module WEBrick
return FakeProxyURI
end
- def perform_proxy_request(req, res, req_class, body_stream = nil)
+ def perform_proxy_request(req, res)
uri = req.request_uri
path = uri.path.dup
path << "?" << uri.query if uri.query
header = setup_proxy_header(req, res)
upstream = setup_upstream_proxy_authentication(req, res, header)
+ response = nil
- body_tmp = []
http = Net::HTTP.new(uri.host, uri.port, upstream.host, upstream.port)
- req_fib = Fiber.new do
- http.start do
- if @config[:ProxyTimeout]
- ################################## these issues are
- http.open_timeout = 30 # secs # necessary (maybe because
- http.read_timeout = 60 # secs # Ruby's bug, but why?)
- ##################################
- end
- if body_stream && req['transfer-encoding'] =~ /\bchunked\b/i
- header['Transfer-Encoding'] = 'chunked'
- end
- http_req = req_class.new(path, header)
- http_req.body_stream = body_stream if body_stream
- http.request(http_req) do |response|
- # Persistent connection requirements are mysterious for me.
- # So I will close the connection in every response.
- res['proxy-connection'] = "close"
- res['connection'] = "close"
-
- # stream Net::HTTP::HTTPResponse to WEBrick::HTTPResponse
- res.status = response.code.to_i
- res.chunked = response.chunked?
- choose_header(response, res)
- set_cookie(response, res)
- set_via(res)
- response.read_body do |buf|
- body_tmp << buf
- Fiber.yield # wait for res.body Proc#call
- end
- end # http.request
- end
- end
- req_fib.resume # read HTTP response headers and first chunk of the body
- res.body = ->(socket) do
- while buf = body_tmp.shift
- socket.write(buf)
- buf.clear
- req_fib.resume # continue response.read_body
+ http.start do
+ if @config[:ProxyTimeout]
+ ################################## these issues are
+ http.open_timeout = 30 # secs # necessary (maybe because
+ http.read_timeout = 60 # secs # Ruby's bug, but why?)
+ ##################################
end
+ response = yield(http, path, header)
end
+
+ # Persistent connection requirements are mysterious for me.
+ # So I will close the connection in every response.
+ res['proxy-connection'] = "close"
+ res['connection'] = "close"
+
+ # Convert Net::HTTP::HTTPResponse to WEBrick::HTTPResponse
+ res.status = response.code.to_i
+ choose_header(response, res)
+ set_cookie(response, res)
+ set_via(res)
+ res.body = response.body
end
+
# :stopdoc:
end
end
diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb
index 6af0cee97d..b40bcb0d57 100644
--- a/lib/webrick/httprequest.rb
+++ b/lib/webrick/httprequest.rb
@@ -10,10 +10,10 @@
# $IPR: httprequest.rb,v 1.64 2003/07/13 17:18:22 gotoyuzo Exp $
require 'uri'
-require_relative 'httpversion'
-require_relative 'httpstatus'
-require_relative 'httputils'
-require_relative 'cookie'
+require 'webrick/httpversion'
+require 'webrick/httpstatus'
+require 'webrick/httputils'
+require 'webrick/cookie'
module WEBrick
@@ -226,9 +226,9 @@ module WEBrick
raise HTTPStatus::BadRequest, "bad URI `#{@unparsed_uri}'."
end
- if /\Aclose\z/io =~ self["connection"]
+ if /close/io =~ self["connection"]
@keep_alive = false
- elsif /\Akeep-alive\z/io =~ self["connection"]
+ elsif /keep-alive/io =~ self["connection"]
@keep_alive = true
elsif @http_version < "1.1"
@keep_alive = false
@@ -258,32 +258,6 @@ module WEBrick
end
##
- # Prepares the HTTPRequest object for use as the
- # source for IO.copy_stream
-
- def body_reader
- @body_tmp = []
- @body_rd = Fiber.new do
- body do |buf|
- @body_tmp << buf
- Fiber.yield
- end
- end
- @body_rd.resume # grab the first chunk and yield
- self
- end
-
- # for IO.copy_stream. Note: we may return a larger string than +size+
- # here; but IO.copy_stream does not care.
- def readpartial(size, buf = ''.b) # :nodoc
- res = @body_tmp.shift or raise EOFError, 'end of file reached'
- buf.replace(res)
- res.clear
- @body_rd.resume # get more chunks
- buf
- end
-
- ##
# Request query as a Hash
def query
@@ -445,14 +419,12 @@ module WEBrick
def read_request_line(socket)
@request_line = read_line(socket, MAX_URI_LENGTH) if socket
- raise HTTPStatus::EOFError unless @request_line
-
@request_bytes = @request_line.bytesize
if @request_bytes >= MAX_URI_LENGTH and @request_line[-1, 1] != LF
raise HTTPStatus::RequestURITooLarge
end
-
@request_time = Time.now
+ raise HTTPStatus::EOFError unless @request_line
if /^(\S+)\s+(\S++)(?:\s+HTTP\/(\d+\.\d+))?\r?\n/mo =~ @request_line
@request_method = $1
@unparsed_uri = $2
@@ -503,7 +475,7 @@ module WEBrick
return unless socket
if tc = self['transfer-encoding']
case tc
- when /\Achunked\z/io then read_chunked(socket, block)
+ when /chunked/io then read_chunked(socket, block)
else raise HTTPStatus::NotImplemented, "Transfer-Encoding: #{tc}."
end
elsif self['content-length'] || @remaining_size
@@ -611,12 +583,7 @@ module WEBrick
end
if host_port = self["x-forwarded-host"]
host_port = host_port.split(",", 2).first
- if host_port =~ /\A(\[[0-9a-fA-F:]+\])(?::(\d+))?\z/
- @forwarded_host = $1
- tmp = $2
- else
- @forwarded_host, tmp = host_port.split(":", 2)
- end
+ @forwarded_host, tmp = host_port.split(":", 2)
@forwarded_port = (tmp || (@forwarded_proto == "https" ? 443 : 80)).to_i
end
if addrs = self["x-forwarded-for"]
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index ba4494ab74..d26324c54a 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -10,11 +10,10 @@
# $IPR: httpresponse.rb,v 1.45 2003/07/11 11:02:25 gotoyuzo Exp $
require 'time'
-require 'uri'
-require_relative 'httpversion'
-require_relative 'htmlutils'
-require_relative 'httputils'
-require_relative 'httpstatus'
+require 'webrick/httpversion'
+require 'webrick/htmlutils'
+require 'webrick/httputils'
+require 'webrick/httpstatus'
module WEBrick
##
@@ -51,21 +50,8 @@ module WEBrick
attr_accessor :reason_phrase
##
- # Body may be:
- # * a String;
- # * an IO-like object that responds to +#read+ and +#readpartial+;
- # * a Proc-like object that responds to +#call+.
- #
- # In the latter case, either #chunked= should be set to +true+,
- # or <code>header['content-length']</code> explicitly provided.
- # Example:
- #
- # server.mount_proc '/' do |req, res|
- # res.chunked = true
- # # or
- # # res.header['content-length'] = 10
- # res.body = proc { |out| out.write(Time.now.to_s) }
- # end
+ # Body may be a String or IO-like object that responds to #read and
+ # #readpartial.
attr_accessor :body
@@ -126,14 +112,13 @@ module WEBrick
@chunked = false
@filename = nil
@sent_size = 0
- @bodytempfile = nil
end
##
# The response's HTTP status line
def status_line
- "HTTP/#@http_version #@status #@reason_phrase".rstrip << CRLF
+ "HTTP/#@http_version #@status #@reason_phrase #{CRLF}"
end
##
@@ -155,7 +140,6 @@ module WEBrick
# Sets the response header +field+ to +value+
def []=(field, value)
- @chunked = value.to_s.downcase == 'chunked' if field.downcase == 'transfer-encoding'
@header[field.downcase] = value.to_s
end
@@ -268,11 +252,8 @@ module WEBrick
elsif %r{^multipart/byteranges} =~ @header['content-type']
@header.delete('content-length')
elsif @header['content-length'].nil?
- if @body.respond_to? :readpartial
- elsif @body.respond_to? :call
- make_body_tempfile
- else
- @header['content-length'] = (@body ? @body.bytesize : 0).to_s
+ unless @body.is_a?(IO)
+ @header['content-length'] = @body ? @body.bytesize : 0
end
end
@@ -295,38 +276,11 @@ module WEBrick
# Location is a single absoluteURI.
if location = @header['location']
if @request_uri
- @header['location'] = @request_uri.merge(location).to_s
+ @header['location'] = @request_uri.merge(location)
end
end
end
- def make_body_tempfile # :nodoc:
- return if @bodytempfile
- bodytempfile = Tempfile.create("webrick")
- if @body.nil?
- # nothing
- elsif @body.respond_to? :readpartial
- IO.copy_stream(@body, bodytempfile)
- @body.close
- elsif @body.respond_to? :call
- @body.call(bodytempfile)
- else
- bodytempfile.write @body
- end
- bodytempfile.rewind
- @body = @bodytempfile = bodytempfile
- @header['content-length'] = bodytempfile.stat.size.to_s
- end
-
- def remove_body_tempfile # :nodoc:
- if @bodytempfile
- @bodytempfile.close
- File.unlink @bodytempfile.path
- @bodytempfile = nil
- end
- end
-
-
##
# Sends the headers on +socket+
@@ -363,6 +317,12 @@ module WEBrick
end
end
+ def to_s # :nodoc:
+ ret = ""
+ send_response(ret)
+ ret
+ end
+
##
# Redirects to +url+ with a WEBrick::HTTPStatus::Redirect +status+.
#
@@ -371,9 +331,8 @@ module WEBrick
# res.set_redirect WEBrick::HTTPStatus::TemporaryRedirect
def set_redirect(status, url)
- url = URI(url).to_s
@body = "<HTML><A HREF=\"#{url}\">#{url}</A>.</HTML>\n"
- @header['location'] = url
+ @header['location'] = url.to_s
raise status
end
@@ -485,7 +444,6 @@ module WEBrick
ensure
@body.close
end
- remove_body_tempfile
end
def send_body_string(socket)
@@ -518,12 +476,7 @@ module WEBrick
socket.write("0#{CRLF}#{CRLF}")
else
size = @header['content-length'].to_i
- if @bodytempfile
- @bodytempfile.rewind
- IO.copy_stream(@bodytempfile, socket)
- else
- @body.call(socket)
- end
+ @body.call(socket)
@sent_size = size
end
end
diff --git a/lib/webrick/https.rb b/lib/webrick/https.rb
index b0a49bc40b..4826654d3a 100644
--- a/lib/webrick/https.rb
+++ b/lib/webrick/https.rb
@@ -9,8 +9,8 @@
#
# $IPR: https.rb,v 1.15 2003/07/22 19:20:42 gotoyuzo Exp $
-require_relative 'ssl'
-require_relative 'httpserver'
+require 'webrick/ssl'
+require 'webrick/httpserver'
module WEBrick
module Config
diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb
index e85d059319..e46b3bd1ad 100644
--- a/lib/webrick/httpserver.rb
+++ b/lib/webrick/httpserver.rb
@@ -10,13 +10,13 @@
# $IPR: httpserver.rb,v 1.63 2002/10/01 17:16:32 gotoyuzo Exp $
require 'io/wait'
-require_relative 'server'
-require_relative 'httputils'
-require_relative 'httpstatus'
-require_relative 'httprequest'
-require_relative 'httpresponse'
-require_relative 'httpservlet'
-require_relative 'accesslog'
+require 'webrick/server'
+require 'webrick/httputils'
+require 'webrick/httpstatus'
+require 'webrick/httprequest'
+require 'webrick/httpresponse'
+require 'webrick/httpservlet'
+require 'webrick/accesslog'
module WEBrick
class HTTPServerError < ServerError; end
@@ -68,8 +68,8 @@ module WEBrick
def run(sock)
while true
- req = create_request(@config)
- res = create_response(@config)
+ res = HTTPResponse.new(@config)
+ req = HTTPRequest.new(@config)
server = self
begin
timeout = @config[:RequestTimeout]
@@ -225,20 +225,6 @@ module WEBrick
end
##
- # Creates the HTTPRequest used when handling the HTTP
- # request. Can be overridden by subclasses.
- def create_request(with_webrick_config)
- HTTPRequest.new(with_webrick_config)
- end
-
- ##
- # Creates the HTTPResponse used when handling the HTTP
- # request. Can be overridden by subclasses.
- def create_response(with_webrick_config)
- HTTPResponse.new(with_webrick_config)
- end
-
- ##
# Mount table for the path a servlet is mounted on in the directory space
# of the server. Users of WEBrick can only access this indirectly via
# WEBrick::HTTPServer#mount, WEBrick::HTTPServer#unmount and
diff --git a/lib/webrick/httpservlet.rb b/lib/webrick/httpservlet.rb
index da49a1405b..1ee04ec86f 100644
--- a/lib/webrick/httpservlet.rb
+++ b/lib/webrick/httpservlet.rb
@@ -9,11 +9,11 @@
#
# $IPR: httpservlet.rb,v 1.21 2003/02/23 12:24:46 gotoyuzo Exp $
-require_relative 'httpservlet/abstract'
-require_relative 'httpservlet/filehandler'
-require_relative 'httpservlet/cgihandler'
-require_relative 'httpservlet/erbhandler'
-require_relative 'httpservlet/prochandler'
+require 'webrick/httpservlet/abstract'
+require 'webrick/httpservlet/filehandler'
+require 'webrick/httpservlet/cgihandler'
+require 'webrick/httpservlet/erbhandler'
+require 'webrick/httpservlet/prochandler'
module WEBrick
module HTTPServlet
diff --git a/lib/webrick/httpservlet/abstract.rb b/lib/webrick/httpservlet/abstract.rb
index bccb091861..fc4cd2275a 100644
--- a/lib/webrick/httpservlet/abstract.rb
+++ b/lib/webrick/httpservlet/abstract.rb
@@ -9,9 +9,9 @@
#
# $IPR: abstract.rb,v 1.24 2003/07/11 11:16:46 gotoyuzo Exp $
-require_relative '../htmlutils'
-require_relative '../httputils'
-require_relative '../httpstatus'
+require 'webrick/htmlutils'
+require 'webrick/httputils'
+require 'webrick/httpstatus'
module WEBrick
module HTTPServlet
diff --git a/lib/webrick/httpservlet/cgihandler.rb b/lib/webrick/httpservlet/cgihandler.rb
index 4457770b7a..b1fb471c54 100644
--- a/lib/webrick/httpservlet/cgihandler.rb
+++ b/lib/webrick/httpservlet/cgihandler.rb
@@ -11,8 +11,8 @@
require 'rbconfig'
require 'tempfile'
-require_relative '../config'
-require_relative 'abstract'
+require 'webrick/config'
+require 'webrick/httpservlet/abstract'
module WEBrick
module HTTPServlet
@@ -28,7 +28,6 @@ module WEBrick
class CGIHandler < AbstractServlet
Ruby = RbConfig.ruby # :nodoc:
CGIRunner = "\"#{Ruby}\" \"#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb\"" # :nodoc:
- CGIRunnerArray = [Ruby, "#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb".freeze].freeze # :nodoc:
##
# Creates a new CGI script servlet for the script at +name+
@@ -37,12 +36,7 @@ module WEBrick
super(server, name)
@script_filename = name
@tempdir = server[:TempDir]
- interpreter = server[:CGIInterpreter]
- if interpreter.is_a?(Array)
- @cgicmd = CGIRunnerArray + interpreter
- else
- @cgicmd = "#{CGIRunner} #{interpreter}"
- end
+ @cgicmd = "#{CGIRunner} #{server[:CGIInterpreter]}"
end
# :stopdoc:
diff --git a/lib/webrick/httpservlet/erbhandler.rb b/lib/webrick/httpservlet/erbhandler.rb
index cd09e5f216..aa02ce8a1d 100644
--- a/lib/webrick/httpservlet/erbhandler.rb
+++ b/lib/webrick/httpservlet/erbhandler.rb
@@ -9,7 +9,7 @@
#
# $IPR: erbhandler.rb,v 1.25 2003/02/24 19:25:31 gotoyuzo Exp $
-require_relative 'abstract'
+require 'webrick/httpservlet/abstract.rb'
require 'erb'
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 601882ef4c..0072e81ac6 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -11,9 +11,9 @@
require 'time'
-require_relative '../htmlutils'
-require_relative '../httputils'
-require_relative '../httpstatus'
+require 'webrick/htmlutils'
+require 'webrick/httputils'
+require 'webrick/httpstatus'
module WEBrick
module HTTPServlet
@@ -55,7 +55,7 @@ module WEBrick
else
mtype = HTTPUtils::mime_type(@local_path, @config[:MimeTypes])
res['content-type'] = mtype
- res['content-length'] = st.size.to_s
+ res['content-length'] = st.size
res['last-modified'] = mtime.httpdate
res.body = File.open(@local_path, "rb")
end
@@ -144,7 +144,7 @@ module WEBrick
raise HTTPStatus::RequestRangeNotSatisfiable if first < 0
res['content-type'] = mtype
res['content-range'] = "bytes #{first}-#{last}/#{filesize}"
- res['content-length'] = (last - first + 1).to_s
+ res['content-length'] = last - first + 1
res.body = io.dup
else
raise HTTPStatus::BadRequest
diff --git a/lib/webrick/httpservlet/prochandler.rb b/lib/webrick/httpservlet/prochandler.rb
index 599ffc4340..c1f454e2f6 100644
--- a/lib/webrick/httpservlet/prochandler.rb
+++ b/lib/webrick/httpservlet/prochandler.rb
@@ -9,7 +9,7 @@
#
# $IPR: prochandler.rb,v 1.7 2002/09/21 12:23:42 gotoyuzo Exp $
-require_relative 'abstract'
+require 'webrick/httpservlet/abstract.rb'
module WEBrick
module HTTPServlet
diff --git a/lib/webrick/httpstatus.rb b/lib/webrick/httpstatus.rb
index c811f21964..0630219ada 100644
--- a/lib/webrick/httpstatus.rb
+++ b/lib/webrick/httpstatus.rb
@@ -9,7 +9,7 @@
#
# $IPR: httpstatus.rb,v 1.11 2003/03/24 20:18:55 gotoyuzo Exp $
-require_relative 'accesslog'
+require 'webrick/accesslog'
module WEBrick
diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb
index 76d4bd0dc7..a4cd3b48ee 100644
--- a/lib/webrick/httputils.rb
+++ b/lib/webrick/httputils.rb
@@ -95,7 +95,6 @@ module WEBrick
"tif" => "image/tiff",
"tiff" => "image/tiff",
"txt" => "text/plain",
- "wasm" => "application/wasm",
"xbm" => "image/x-xbitmap",
"xhtml" => "text/html",
"xls" => "application/vnd.ms-excel",
@@ -162,7 +161,10 @@ module WEBrick
end
}
header.each{|key, values|
- values.each(&:strip!)
+ values.each{|value|
+ value.strip!
+ value.gsub!(/\s+/, " ")
+ }
}
header
end
diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb
index 4a6e74c4f9..88e160d981 100644
--- a/lib/webrick/server.rb
+++ b/lib/webrick/server.rb
@@ -10,8 +10,8 @@
# $IPR: server.rb,v 1.62 2003/07/22 19:20:43 gotoyuzo Exp $
require 'socket'
-require_relative 'config'
-require_relative 'log'
+require 'webrick/config'
+require 'webrick/log'
module WEBrick
diff --git a/lib/webrick/ssl.rb b/lib/webrick/ssl.rb
index d125083528..8a334eaff1 100644
--- a/lib/webrick/ssl.rb
+++ b/lib/webrick/ssl.rb
@@ -130,7 +130,7 @@ module WEBrick
aki = ef.create_extension("authorityKeyIdentifier",
"keyid:always,issuer:always")
cert.add_extension(aki)
- cert.sign(rsa, OpenSSL::Digest::SHA256.new)
+ cert.sign(rsa, OpenSSL::Digest::SHA1.new)
return [ cert, rsa ]
end
@@ -181,7 +181,7 @@ module WEBrick
unless config[:SSLCertificate]
cn = config[:SSLCertName]
comment = config[:SSLCertComment]
- cert, key = Utils::create_self_signed_cert(2048, cn, comment)
+ cert, key = Utils::create_self_signed_cert(1024, cn, comment)
config[:SSLCertificate] = cert
config[:SSLPrivateKey] = key
end
diff --git a/lib/webrick/version.rb b/lib/webrick/version.rb
index 7bcdd5b943..ee6b415eef 100644
--- a/lib/webrick/version.rb
+++ b/lib/webrick/version.rb
@@ -14,5 +14,5 @@ module WEBrick
##
# The WEBrick version
- VERSION = "1.6.1"
+ VERSION = "1.4.2"
end
diff --git a/lib/webrick/webrick.gemspec b/lib/webrick/webrick.gemspec
index 5490502539..3f859c410b 100644
--- a/lib/webrick/webrick.gemspec
+++ b/lib/webrick/webrick.gemspec
@@ -1,62 +1,15 @@
# frozen_string_literal: true
-begin
- require_relative 'lib/webrick/version'
-rescue LoadError
- # for Ruby core repository
- require_relative 'version'
-end
+require_relative 'version'
Gem::Specification.new do |s|
s.name = "webrick"
s.version = WEBrick::VERSION
+ s.date = '2017-12-24'
s.summary = "HTTP server toolkit"
s.description = "WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server."
s.require_path = %w{lib}
- s.files = [
- "Gemfile",
- "LICENSE.txt",
- "README.md",
- "Rakefile",
- "bin/console",
- "bin/setup",
- "lib/webrick.rb",
- "lib/webrick/accesslog.rb",
- "lib/webrick/cgi.rb",
- "lib/webrick/compat.rb",
- "lib/webrick/config.rb",
- "lib/webrick/cookie.rb",
- "lib/webrick/htmlutils.rb",
- "lib/webrick/httpauth.rb",
- "lib/webrick/httpauth/authenticator.rb",
- "lib/webrick/httpauth/basicauth.rb",
- "lib/webrick/httpauth/digestauth.rb",
- "lib/webrick/httpauth/htdigest.rb",
- "lib/webrick/httpauth/htgroup.rb",
- "lib/webrick/httpauth/htpasswd.rb",
- "lib/webrick/httpauth/userdb.rb",
- "lib/webrick/httpproxy.rb",
- "lib/webrick/httprequest.rb",
- "lib/webrick/httpresponse.rb",
- "lib/webrick/https.rb",
- "lib/webrick/httpserver.rb",
- "lib/webrick/httpservlet.rb",
- "lib/webrick/httpservlet/abstract.rb",
- "lib/webrick/httpservlet/cgi_runner.rb",
- "lib/webrick/httpservlet/cgihandler.rb",
- "lib/webrick/httpservlet/erbhandler.rb",
- "lib/webrick/httpservlet/filehandler.rb",
- "lib/webrick/httpservlet/prochandler.rb",
- "lib/webrick/httpstatus.rb",
- "lib/webrick/httputils.rb",
- "lib/webrick/httpversion.rb",
- "lib/webrick/log.rb",
- "lib/webrick/server.rb",
- "lib/webrick/ssl.rb",
- "lib/webrick/utils.rb",
- "lib/webrick/version.rb",
- "webrick.gemspec",
- ]
+ s.files = ["lib/webrick.rb", "lib/webrick/accesslog.rb", "lib/webrick/cgi.rb", "lib/webrick/compat.rb", "lib/webrick/config.rb", "lib/webrick/cookie.rb", "lib/webrick/htmlutils.rb", "lib/webrick/httpauth.rb", "lib/webrick/httpauth/authenticator.rb", "lib/webrick/httpauth/basicauth.rb", "lib/webrick/httpauth/digestauth.rb", "lib/webrick/httpauth/htdigest.rb", "lib/webrick/httpauth/htgroup.rb", "lib/webrick/httpauth/htpasswd.rb", "lib/webrick/httpauth/userdb.rb", "lib/webrick/httpauth.rb", "lib/webrick/httpproxy.rb", "lib/webrick/httprequest.rb", "lib/webrick/httpresponse.rb", "lib/webrick/https.rb", "lib/webrick/httpserver.rb", "lib/webrick/httpservlet.rb", "lib/webrick/httpservlet/abstract.rb", "lib/webrick/httpservlet/cgi_runner.rb", "lib/webrick/httpservlet/cgihandler.rb", "lib/webrick/httpservlet/erbhandler.rb", "lib/webrick/httpservlet/filehandler.rb", "lib/webrick/httpservlet/prochandler.rb", "lib/webrick/httpservlet.rb", "lib/webrick/httpstatus.rb", "lib/webrick/httputils.rb", "lib/webrick/httpversion.rb", "lib/webrick/log.rb", "lib/webrick/server.rb", "lib/webrick/ssl.rb", "lib/webrick/utils.rb", "lib/webrick/version.rb"]
s.required_ruby_version = ">= 2.3.0"
s.authors = ["TAKAHASHI Masayoshi", "GOTOU YUUZOU", "Eric Wong"]
@@ -68,7 +21,7 @@ Gem::Specification.new do |s|
s.metadata = {
"bug_tracker_uri" => "https://bugs.ruby-lang.org/projects/ruby-trunk/issues",
"homepage_uri" => "https://www.ruby-lang.org",
- "source_code_uri" => "https://git.ruby-lang.org/ruby.git/"
+ "source_code_uri" => "https://svn.ruby-lang.org/repos/ruby"
}
end
diff --git a/lib/yaml.rb b/lib/yaml.rb
index cec7808f05..aa0a1eb470 100644
--- a/lib/yaml.rb
+++ b/lib/yaml.rb
@@ -1,4 +1,6 @@
# frozen_string_literal: false
+##
+# The YAML module is an alias of Psych, the YAML engine for Ruby.
begin
require 'psych'
@@ -15,7 +17,7 @@ YAML = Psych # :nodoc:
#
# This module provides a Ruby interface for data serialization in YAML format.
#
-# The YAML module is an alias of Psych, the YAML engine for Ruby.
+# The underlying implementation is the libyaml wrapper Psych.
#
# == Usage
#
@@ -29,9 +31,6 @@ YAML = Psych # :nodoc:
# YAML.dump("foo") # => "--- foo\n...\n"
# { :a => 'b'}.to_yaml # => "---\n:a: b\n"
#
-# As the implementation is provided by the Psych library, detailed documentation
-# can be found in that library's docs (also part of standard library).
-#
# == Security
#
# Do not use YAML to load untrusted data. Doing so is unsafe and could allow
@@ -54,8 +53,8 @@ YAML = Psych # :nodoc:
# For more advanced details on the implementation see Psych, and also check out
# http://yaml.org for spec details and other helpful information.
#
-# Psych is maintained by Aaron Patterson on github: https://github.com/ruby/psych
+# Psych is maintained by Aaron Patterson on github: https://github.com/tenderlove/psych
#
-# Syck can also be found on github: https://github.com/ruby/syck
+# Syck can also be found on github: https://github.com/tenderlove/syck
module YAML
end
diff --git a/lib/yaml/yaml.gemspec b/lib/yaml/yaml.gemspec
deleted file mode 100644
index ba5027a9b6..0000000000
--- a/lib/yaml/yaml.gemspec
+++ /dev/null
@@ -1,23 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "yaml"
- spec.version = "0.1.0"
- spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
- spec.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"]
-
- spec.summary = "YAML Ain't Markup Language"
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/yaml"
- spec.license = "BSD-2-Clause"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/libexec/bundle b/libexec/bundle
deleted file mode 100755
index b3b1b691d8..0000000000
--- a/libexec/bundle
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-# Exit cleanly from an early interrupt
-Signal.trap("INT") do
- Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
- exit 1
-end
-
-base_path = File.expand_path("../lib", __dir__)
-
-if File.exist?(base_path)
- require_relative "../lib/bundler"
-else
- require "bundler"
-end
-
-# Check if an older version of bundler is installed
-$LOAD_PATH.each do |path|
- next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
- err = String.new
- err << "Looks like you have a version of bundler that's older than 0.9.\n"
- err << "Please remove your old versions.\n"
- err << "An easy way to do this is by running `gem cleanup bundler`."
- abort(err)
-end
-
-if File.exist?(base_path)
- require_relative "../lib/bundler/friendly_errors"
-else
- require "bundler/friendly_errors"
-end
-
-Bundler.with_friendly_errors do
- if File.exist?(base_path)
- require_relative "../lib/bundler/cli"
- else
- require "bundler/cli"
- end
-
- # Allow any command to use --help flag to show help for that command
- help_flags = %w[--help -h]
- help_flag_used = ARGV.any? {|a| help_flags.include? a }
- args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
-
- Bundler::CLI.start(args, :debug => true)
-end
diff --git a/libexec/bundler b/libexec/bundler
deleted file mode 100755
index d9131fe834..0000000000
--- a/libexec/bundler
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-load File.expand_path("../bundle", __FILE__)
diff --git a/libexec/irb b/libexec/irb
deleted file mode 100755
index c64ee85fbd..0000000000
--- a/libexec/irb
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env ruby
-#
-# irb.rb - interactive ruby
-# $Release Version: 0.9.6 $
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require "irb"
-
-IRB.start(__FILE__)
diff --git a/libexec/racc b/libexec/racc
deleted file mode 100755
index 5656b25e42..0000000000
--- a/libexec/racc
+++ /dev/null
@@ -1,306 +0,0 @@
-#!/usr/bin/env ruby
-#
-# $Id$
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-
-require 'racc/static'
-require 'optparse'
-
-def main
- output = nil
- debug_parser = false
- make_logfile = false
- logfilename = nil
- make_executable = false
- rubypath = nil
- embed_runtime = false
- debug_flags = Racc::DebugFlags.new
- line_convert = true
- line_convert_all = false
- omit_action_call = true
- superclass = nil
- check_only = false
- verbose = false
- profiler = RaccProfiler.new(false)
-
- parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [options] <input>"
- parser.on('-o', '--output-file=PATH',
- 'output file name [<input>.tab.rb]') {|name|
- output = name
- }
- parser.on('-t', '--debug', 'Outputs debugging parser.') {|fl|
- debug_parser = fl
- }
- parser.on('-g', 'Equivalent to -t (obsolete).') {|fl|
- $stderr.puts "racc -g is obsolete. Use racc -t instead." if $VERBOSE
- debug_parser = fl
- }
- parser.on('-v', '--verbose',
- 'Creates <filename>.output log file.') {|fl|
- make_logfile = fl
- }
- parser.on('-O', '--log-file=PATH',
- 'Log file name [<input>.output]') {|path|
- make_logfile = true
- logfilename = path
- }
- parser.on('-e', '--executable [RUBYPATH]', 'Makes executable parser.') {|path|
- executable = true
- rubypath = (path == 'ruby' ? nil : path)
- }
- parser.on('-E', '--embedded', "Embeds Racc runtime in output.") {
- embed_runtime = true
- }
- parser.on('--line-convert-all', 'Converts line numbers of user codes.') {
- line_convert_all = true
- }
- parser.on('-l', '--no-line-convert', 'Never convert line numbers.') {
- line_convert = false
- line_convert_all = false
- }
- parser.on('-a', '--no-omit-actions', 'Never omit actions.') {
- omit_action_call = false
- }
- parser.on('--superclass=CLASSNAME',
- 'Uses CLASSNAME instead of Racc::Parser.') {|name|
- superclass = name
- }
- parser.on('--runtime=FEATURE',
- "Uses FEATURE instead of 'racc/parser'") {|feat|
- runtime = feature
- }
- parser.on('-C', '--check-only', 'Checks syntax and quit immediately.') {|fl|
- check_only = fl
- }
- parser.on('-S', '--output-status', 'Outputs internal status time to time.') {
- verbose = true
- }
- parser.on('-P', 'Enables generator profile') {
- profiler = RaccProfiler.new(true)
- }
- parser.on('-D flags', "Flags for Racc debugging (do not use).") {|flags|
- debug_flags = Racc::DebugFlags.parse_option_string(flags)
- }
- #parser.on('--no-extensions', 'Run Racc without any Ruby extension.') {
- # Racc.const_set :Racc_No_Extentions, true
- #}
- parser.on('--version', 'Prints version and quit.') {
- puts "racc version #{Racc::Version}"
- exit 0
- }
- parser.on('--runtime-version', 'Prints runtime version and quit.') {
- printf "racc runtime version %s (rev. %s); %s\n",
- Racc::Parser::Racc_Runtime_Version,
- Racc::Parser::Racc_Runtime_Revision,
- if Racc::Parser.racc_runtime_type == 'ruby'
- sprintf('ruby core version %s (rev. %s)',
- Racc::Parser::Racc_Runtime_Core_Version_R,
- Racc::Parser::Racc_Runtime_Core_Revision_R)
- else
- sprintf('c core version %s (rev. %s)',
- Racc::Parser::Racc_Runtime_Core_Version_C,
- Racc::Parser::Racc_Runtime_Core_Revision_C)
- end
- exit 0
- }
- parser.on('--copyright', 'Prints copyright and quit.') {
- puts Racc::Copyright
- exit 0
- }
- parser.on('--help', 'Prints this message and quit.') {
- puts parser.help
- exit 1
- }
- begin
- parser.parse!
- rescue OptionParser::ParseError => err
- $stderr.puts err.message
- $stderr.puts parser.help
- exit 1
- end
- if ARGV.empty?
- $stderr.puts 'no input'
- exit 1
- end
- if ARGV.size > 1
- $stderr.puts 'too many input'
- exit 1
- end
- input = ARGV[0]
-
- begin
- $stderr.puts 'Parsing grammar file...' if verbose
- result = profiler.section('parse') {
- parser = Racc::GrammarFileParser.new(debug_flags)
- parser.parse(File.read(input), File.basename(input))
- }
- if check_only
- $stderr.puts 'syntax ok'
- exit 0
- end
-
- $stderr.puts 'Generating LALR states...' if verbose
- states = profiler.section('nfa') {
- Racc::States.new(result.grammar).nfa
- }
-
- $stderr.puts "Resolving #{states.size} states..." if verbose
- profiler.section('dfa') {
- states.dfa
- }
-
- $stderr.puts 'Creating parser file...' if verbose
- params = result.params.dup
- # Overwrites parameters given by a grammar file with command line options.
- params.superclass = superclass if superclass
- params.omit_action_call = true if omit_action_call
- # From command line option
- if make_executable
- params.make_executable = true
- params.interpreter = rubypath
- end
- params.debug_parser = debug_parser
- params.convert_line = line_convert
- params.convert_line_all = line_convert_all
- params.embed_runtime = embed_runtime
- profiler.section('generation') {
- generator = Racc::ParserFileGenerator.new(states, params)
- generator.generate_parser_file(output || make_filename(input, '.tab.rb'))
- }
-
- if make_logfile
- profiler.section('logging') {
- $stderr.puts 'Creating log file...' if verbose
- logfilename ||= make_filename(output || File.basename(input), '.output')
- File.open(logfilename, 'w') {|f|
- Racc::LogFileGenerator.new(states, debug_flags).output f
- }
- }
- end
- if debug_flags.status_logging
- log_useless states.grammar
- log_conflict states
- else
- report_useless states.grammar
- report_conflict states
- end
-
- profiler.report
- rescue Racc::Error, Errno::ENOENT, Errno::EPERM => err
- raise if $DEBUG or debug_flags.any?
- lineno = err.message.slice(/\A\d+:/).to_s
- $stderr.puts "#{File.basename $0}: #{input}:#{lineno} #{err.message.strip}"
- exit 1
- end
-end
-
-def make_filename(path, suffix)
- path.sub(/(?:\..*?)?\z/, suffix)
-end
-
-def report_conflict(states)
- if states.should_report_srconflict?
- $stderr.puts "#{states.n_srconflicts} shift/reduce conflicts"
- end
- if states.rrconflict_exist?
- $stderr.puts "#{states.n_rrconflicts} reduce/reduce conflicts"
- end
-end
-
-def log_conflict(states)
- logging('w') {|f|
- f.puts "ex#{states.grammar.n_expected_srconflicts}"
- if states.should_report_srconflict?
- f.puts "sr#{states.n_srconflicts}"
- end
- if states.rrconflict_exist?
- f.puts "rr#{states.n_rrconflicts}"
- end
- }
-end
-
-def report_useless(grammar)
- if grammar.useless_nonterminal_exist?
- $stderr.puts "#{grammar.n_useless_nonterminals} useless nonterminals"
- end
- if grammar.useless_rule_exist?
- $stderr.puts "#{grammar.n_useless_rules} useless rules"
- end
- if grammar.start.useless?
- $stderr.puts 'fatal: start symbol does not derive any sentence'
- end
-end
-
-def log_useless(grammar)
- logging('a') {|f|
- if grammar.useless_nonterminal_exist?
- f.puts "un#{grammar.n_useless_nonterminals}"
- end
- if grammar.useless_rule_exist?
- f.puts "ur#{grammar.n_useless_rules}"
- end
- }
-end
-
-def logging(mode, &block)
- File.open("log/#{File.basename(ARGV[0])}", mode, &block)
-end
-
-class RaccProfiler
- def initialize(really)
- @really = really
- @log = []
- unless ::Process.respond_to?(:times)
- # Ruby 1.6
- @class = ::Time
- else
- @class = ::Process
- end
- end
-
- def section(name)
- if @really
- t1 = @class.times.utime
- result = yield
- t2 = @class.times.utime
- @log.push [name, t2 - t1]
- result
- else
- yield
- end
- end
-
- def report
- return unless @really
- f = $stderr
- total = cumulative_time()
- f.puts '--task-----------+--sec------+---%-'
- @log.each do |name, time|
- f.printf "%-19s %s %3d%%\n", name, pjust(time,4,4), (time/total*100).to_i
- end
- f.puts '-----------------+-----------+-----'
- f.printf "%-20s%s\n", 'total', pjust(total,4,4)
- end
-
- private
-
- def cumulative_time
- t = @log.inject(0) {|sum, (name, time)| sum + time }
- t == 0 ? 0.01 : t
- end
-
- def pjust(num, i, j)
- m = /(\d+)(\.\d+)?/.match(num.to_s)
- str = m[1].rjust(i)
- str.concat m[2].ljust(j+1)[0,j+1] if m[2]
- str
- end
-end
-
-main
diff --git a/libexec/racc2y b/libexec/racc2y
deleted file mode 100755
index f88d73ed2c..0000000000
--- a/libexec/racc2y
+++ /dev/null
@@ -1,195 +0,0 @@
-#!/usr/local/bin/ruby
-#
-# $Id$
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is feee software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of the LGPL, see the file "COPYING".
-#
-
-require 'racc/grammarfileparser'
-require 'racc/info'
-require 'optparse'
-
-def main
- @with_action = true
- with_header = false
- with_inner = false
- with_footer = false
- output = nil
- parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [-AHIF] [-oFILENAME] GRAMMARFILE"
- parser.on('-o', '--output=FILENAME', 'output file name [<input>.yacc]') {|name|
- output = name
- }
- parser.on('-A', '--without-action', 'Does not include actions.') {
- @with_action = false
- }
- parser.on('-H', '--with-header', 'Includes header part.') {
- with_header = true
- }
- parser.on('-I', '--with-inner', 'Includes inner part.') {
- with_inner = true
- }
- parser.on('-F', '--with-footer', 'Includes footer part.') {
- with_footer = true
- }
- parser.on('--version', 'Prints version and quit.') {
- puts "racc2y version #{Racc::Version}"
- exit 0
- }
- parser.on('--copyright', 'Prints copyright and quit.') {
- puts Racc::Copyright
- exit 0
- }
- parser.on('--help', 'Prints this message and quit.') {
- puts parser.help
- exit 1
- }
- begin
- parser.parse!
- rescue OptionParser::ParseError => err
- $stderr.puts err.message
- $stderr.puts parser.help
- exit 1
- end
- if ARGV.empty?
- $stderr.puts "no input file"
- exit 1
- end
- unless ARGV.size == 1
- $stderr.puts "too many inputs"
- exit 1
- end
- input = ARGV[0]
-
- begin
- result = Racc::GrammarFileParser.parse_file(input)
- result.grammar.init
- File.open(output || "#{input}.yacc", 'w') {|f|
- f.puts "/* generated from #{input} */"
- if with_header
- f.puts
- f.puts '%{'
- print_user_codes f, result.params.header
- f.puts '%}'
- end
- f.puts
- print_terminals f, result.grammar
- f.puts
- print_precedence_table f, precedence_table(result.grammar)
- f.puts
- f.puts '%%'
- print_grammar f, result.grammar
- f.puts '%%'
- if with_inner
- f.puts '/*---- inner ----*/'
- print_user_codes f, result.params.inner
- end
- if with_footer
- f.puts '/*---- footer ----*/'
- print_user_codes f, result.params.footer
- end
- }
- rescue SystemCallError => err
- $stderr.puts err.message
- exit 1
- end
-end
-
-def print_terminals(f, grammar)
- init_indent = '%token'.size
- f.print '%token'
- columns = init_indent
- grammar.symboltable.each_terminal do |t|
- next unless t.terminal?
- next if t.dummy?
- next if t == grammar.symboltable.anchor
- next if t == grammar.symboltable.error
- unless t.value.kind_of?(String)
- if columns > 60
- f.puts
- f.print ' ' * init_indent
- columns = init_indent
- end
- columns += f.write(" #{yacc_symbol(t)}")
- end
- end
- f.puts
-end
-
-def precedence_table(grammar)
- table = []
- grammar.symboltable.select {|sym| sym.precedence }.each do |sym|
- (table[sym.prec] ||= [sym.assoc]).push sym
- end
- table.compact
-end
-
-def print_precedence_table(f, table)
- return if table.empty?
- f.puts '/* precedance table */'
- table.each do |syms|
- assoc = syms.shift
- f.printf '%%%-8s ', assoc.to_s.downcase
- f.puts syms.map {|s| yacc_symbol(s) }.join(' ')
- end
- f.puts
-end
-
-def print_grammar(f, grammar)
- prev_target = nil
- indent = 10
- embactions = []
- grammar.each do |rule|
- if rule.target.dummy?
- embactions.push rule.action unless rule.action.empty?
- next
- end
- if rule.target == prev_target
- f.print ' ' * indent, '|'
- else
- prev_target = rule.target
- f.printf "\n%-10s:", yacc_symbol(prev_target)
- end
- rule.symbols.each do |s|
- if s.dummy? # target of dummy rule for embedded action
- f.puts
- print_action f, embactions.shift, indent
- f.print ' ' * (indent + 1)
- else
- f.print ' ', yacc_symbol(s)
- end
- end
- if rule.specified_prec
- f.print ' %prec ', yacc_symbol(rule.specified_prec)
- end
- f.puts
- unless rule.action.empty?
- print_action f, rule.action, indent
- end
- end
-end
-
-def print_action(f, action, indent)
- return unless @with_action
- f.print ' ' * (indent + 4), "{\n"
- f.print ' ' * (indent + 6), action.source.text.strip, "\n"
- f.print ' ' * (indent + 4) , "}\n"
-end
-
-def print_user_codes(f, srcs)
- return if srcs.empty?
- srcs.each do |src|
- f.puts src.text
- end
-end
-
-def yacc_symbol(s)
- s.to_s.gsub('"', "'")
-end
-
-main
diff --git a/libexec/rdoc b/libexec/rdoc
deleted file mode 100755
index aaa23292df..0000000000
--- a/libexec/rdoc
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env ruby
-#
-# RDoc: Documentation tool for source code
-# (see lib/rdoc/rdoc.rb for more information)
-#
-# Copyright (c) 2003 Dave Thomas
-# Released under the same terms as Ruby
-
-begin
- gem 'rdoc'
-rescue NameError => e # --disable-gems
- raise unless e.name == :gem
-rescue Gem::LoadError
-end
-
-require 'rdoc/rdoc'
-
-begin
- r = RDoc::RDoc.new
- r.document ARGV
-rescue Errno::ENOSPC
- $stderr.puts 'Ran out of space creating documentation'
- $stderr.puts
- $stderr.puts 'Please free up some space and try again'
-rescue SystemExit
- raise
-rescue Exception => e
- if $DEBUG_RDOC then
- $stderr.puts e.message
- $stderr.puts "#{e.backtrace.join "\n\t"}"
- $stderr.puts
- elsif Interrupt === e then
- $stderr.puts
- $stderr.puts 'Interrupted'
- else
- $stderr.puts "uh-oh! RDoc had a problem:"
- $stderr.puts e.message
- $stderr.puts
- $stderr.puts "run with --debug for full backtrace"
- end
-
- exit 1
-end
-
diff --git a/libexec/ri b/libexec/ri
deleted file mode 100755
index 7fbed0c099..0000000000
--- a/libexec/ri
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env ruby
-
-begin
- gem 'rdoc'
-rescue NameError => e # --disable-gems
- raise unless e.name == :gem
-rescue Gem::LoadError
-end
-
-require 'rdoc/ri/driver'
-
-RDoc::RI::Driver.run ARGV
diff --git a/libexec/y2racc b/libexec/y2racc
deleted file mode 100755
index 7933f94153..0000000000
--- a/libexec/y2racc
+++ /dev/null
@@ -1,339 +0,0 @@
-#!/usr/local/bin/ruby
-#
-# $Id$
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU LGPL, Lesser General Public License version 2.1.
-# For details of the GNU LGPL, see the file "COPYING".
-#
-
-require 'racc/info'
-require 'strscan'
-require 'forwardable'
-require 'optparse'
-
-def main
- @with_action = true
- @with_header = false
- @with_usercode = false
- cname = 'MyParser'
- input = nil
- output = nil
- parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [-Ahu] [-c <classname>] [-o <filename>] <input>"
- parser.on('-o', '--output=FILENAME', 'output file name [<input>.racc]') {|name|
- output = name
- }
- parser.on('-c', '--classname=NAME', "Name of the parser class. [#{cname}]") {|name|
- cname = name
- }
- parser.on('-A', '--without-action', 'Does not include actions.') {
- @with_action = false
- }
- parser.on('-h', '--with-header', 'Includes header (%{...%}).') {
- @with_header = true
- }
- parser.on('-u', '--with-user-code', 'Includes user code.') {
- @with_usercode = true
- }
- parser.on('--version', 'Prints version and quit.') {
- puts "y2racc version #{Racc::Version}"
- exit 0
- }
- parser.on('--copyright', 'Prints copyright and quit.') {
- puts Racc::Copyright
- exit 0
- }
- parser.on('--help', 'Prints this message and quit.') {
- puts parser.help
- exit 1
- }
- begin
- parser.parse!
- rescue OptionParser::ParseError => err
- $stderr.puts err.message
- $stderr.puts parser.help
- exit 1
- end
- if ARGV.empty?
- $stderr.puts 'no input'
- exit 1
- end
- if ARGV.size > 1
- $stderr.puts 'too many input'
- exit 1
- end
- input = ARGV[0]
-
- begin
- result = YaccFileParser.parse_file(input)
- File.open(output || "#{input}.racc", 'w') {|f|
- convert cname, result, f
- }
- rescue SystemCallError => err
- $stderr.puts err.message
- exit 1
- end
-end
-
-def convert(classname, result, f)
- init_indent = 'token'.size
- f.puts %<# Converted from "#{result.filename}" by y2racc version #{Racc::Version}>
- f.puts
- f.puts "class #{classname}"
- unless result.terminals.empty?
- f.puts
- f.print 'token'
- columns = init_indent
- result.terminals.each do |t|
- if columns > 60
- f.puts
- f.print ' ' * init_indent
- columns = init_indent
- end
- columns += f.write(" #{t}")
- end
- f.puts
- end
- unless result.precedence_table.empty?
- f.puts
- f.puts 'preclow'
- result.precedence_table.each do |assoc, toks|
- f.printf " %-8s %s\n", assoc, toks.join(' ') unless toks.empty?
- end
- f.puts 'prechigh'
- end
- if result.start
- f.puts
- f.puts "start #{@start}"
- end
-
- f.puts
- f.puts 'rule'
- texts = @with_action ? result.grammar : result.grammar_without_actions
- texts.each do |text|
- f.print text
- end
-
- if @with_header and result.header
- f.puts
- f.puts '---- header'
- f.puts result.header
- end
- if @with_usercode and result.usercode
- f.puts
- f.puts '---- footer'
- f.puts result.usercode
- end
-end
-
-class ParseError < StandardError; end
-
-class StringScanner_withlineno
- def initialize(src)
- @s = StringScanner.new(src)
- @lineno = 1
- end
-
- extend Forwardable
- def_delegator "@s", :eos?
- def_delegator "@s", :rest
-
- attr_reader :lineno
-
- def scan(re)
- advance_lineno(@s.scan(re))
- end
-
- def scan_until(re)
- advance_lineno(@s.scan_until(re))
- end
-
- def skip(re)
- str = advance_lineno(@s.scan(re))
- str ? str.size : nil
- end
-
- def getch
- advance_lineno(@s.getch)
- end
-
- private
-
- def advance_lineno(str)
- @lineno += str.count("\n") if str
- str
- end
-end
-
-class YaccFileParser
-
- Result = Struct.new(:terminals, :precedence_table, :start,
- :header, :grammar, :usercode, :filename)
- class Result # reopen
- def initialize
- super
- self.terminals = []
- self.precedence_table = []
- self.start = nil
- self.grammar = []
- self.header = nil
- self.usercode = nil
- self.filename = nil
- end
-
- def grammar_without_actions
- grammar().map {|text| text[0,1] == '{' ? '{}' : text }
- end
- end
-
- def YaccFileParser.parse_file(filename)
- new().parse(File.read(filename), filename)
- end
-
- def parse(src, filename = '-')
- @result = Result.new
- @filename = filename
- @result.filename = filename
- s = StringScanner_withlineno.new(src)
- parse_header s
- parse_grammar s
- @result
- end
-
- private
-
- COMMENT = %r</\*[^*]*\*+(?:[^/*][^*]*\*+)*/>
- CHAR = /'((?:[^'\\]+|\\.)*)'/
- STRING = /"((?:[^"\\]+|\\.)*)"/
-
- def parse_header(s)
- skip_until_percent s
- until s.eos?
- case
- when t = s.scan(/left/)
- @result.precedence_table.push ['left', scan_symbols(s)]
- when t = s.scan(/right/)
- @result.precedence_table.push ['right', scan_symbols(s)]
- when t = s.scan(/nonassoc/)
- @result.precedence_table.push ['nonassoc', scan_symbols(s)]
- when t = s.scan(/token/)
- list = scan_symbols(s)
- list.shift if /\A<(.*)>\z/ =~ list[0]
- @result.terminals.concat list
- when t = s.scan(/start/)
- @result.start = scan_symbols(s)[0]
- when s.skip(%r<(?:
- type | union | expect | thong | binary |
- semantic_parser | pure_parser | no_lines |
- raw | token_table
- )\b>x)
- skip_until_percent s
- when s.skip(/\{/) # header (%{...%})
- str = s.scan_until(/\%\}/)
- str.chop!
- str.chop!
- @result.header = str
- skip_until_percent s
- when s.skip(/\%/) # grammar (%%...)
- return
- else
- raise ParseError, "#{@filename}:#{s.lineno}: scan error"
- end
- end
- end
-
- def skip_until_percent(s)
- until s.eos?
- s.skip /[^\%\/]+/
- next if s.skip(COMMENT)
- return if s.getch == '%'
- end
- end
-
- def scan_symbols(s)
- list = []
- until s.eos?
- s.skip /\s+/
- if s.skip(COMMENT)
- ;
- elsif t = s.scan(CHAR)
- list.push t
- elsif t = s.scan(STRING)
- list.push t
- elsif s.skip(/\%/)
- break
- elsif t = s.scan(/\S+/)
- list.push t
- else
- raise ParseError, "#{@filename}:#{@lineno}: scan error"
- end
- end
- list
- end
-
- def parse_grammar(s)
- buf = []
- until s.eos?
- if t = s.scan(/[^%'"{\/]+/)
- buf.push t
- break if s.eos?
- end
- if s.skip(/\{/)
- buf.push scan_action(s)
- elsif t = s.scan(/'(?:[^'\\]+|\\.)*'/) then buf.push t
- elsif t = s.scan(/"(?:[^"\\]+|\\.)*"/) then buf.push t
- elsif t = s.scan(COMMENT) then buf.push t
- elsif s.skip(/%prec\b/) then buf.push '='
- elsif s.skip(/%%/)
- @result.usercode = s.rest
- break
- else
- buf.push s.getch
- end
- end
- @result.grammar = buf
- end
-
- def scan_action(s)
- buf = '{'
- nest = 1
- until s.eos?
- if t = s.scan(%r<[^/{}'"]+>)
- buf << t
- break if s.eos?
- elsif t = s.scan(COMMENT)
- buf << t
- elsif t = s.scan(CHAR)
- buf << t
- elsif t = s.scan(STRING)
- buf << t
- else
- c = s.getch
- buf << c
- case c
- when '{'
- nest += 1
- when '}'
- nest -= 1
- return buf if nest == 0
- end
- end
- end
- $stderr.puts "warning: unterminated action in #{@filename}"
- buf
- end
-
-end
-
-unless Object.method_defined?(:funcall)
- class Object
- alias funcall __send__
- end
-end
-
-
-main
diff --git a/load.c b/load.c
index 51c21ee4f2..cfc8b1f032 100644
--- a/load.c
+++ b/load.c
@@ -2,13 +2,11 @@
* load methods from eval.c
*/
-#include "ruby/encoding.h"
-#include "ruby/util.h"
#include "internal.h"
+#include "ruby/util.h"
#include "dln.h"
#include "eval_intern.h"
#include "probes.h"
-#include "iseq.h"
static VALUE ruby_dln_librefs;
@@ -28,10 +26,12 @@ static const char *const loadable_ext[] = {
0
};
-static const char *const ruby_ext[] = {
- ".rb",
- 0
-};
+VALUE
+rb_get_load_path(void)
+{
+ VALUE load_path = GET_VM()->load_path;
+ return load_path;
+}
enum expand_type {
EXPAND_ALL,
@@ -53,6 +53,7 @@ rb_construct_expanded_load_path(enum expand_type type, int *has_relative, int *h
VALUE expanded_load_path = vm->expanded_load_path;
VALUE ary;
long i;
+ int level = rb_safe_level();
ary = rb_ary_tmp_new(RARRAY_LEN(load_path));
for (i = 0; i < RARRAY_LEN(load_path); ++i) {
@@ -62,7 +63,7 @@ rb_construct_expanded_load_path(enum expand_type type, int *has_relative, int *h
as_str = path = RARRAY_AREF(load_path, i);
is_string = RB_TYPE_P(path, T_STRING) ? 1 : 0;
non_cache = !is_string ? 1 : 0;
- as_str = rb_get_path_check_to_string(path);
+ as_str = rb_get_path_check_to_string(path, level);
as_cstr = RSTRING_PTR(as_str);
if (!non_cache) {
@@ -83,8 +84,8 @@ rb_construct_expanded_load_path(enum expand_type type, int *has_relative, int *h
/* Freeze only string object. We expand other objects every time. */
if (is_string)
rb_str_freeze(path);
- as_str = rb_get_path_check_convert(as_str);
- expanded_path = rb_check_realpath(Qnil, as_str, NULL);
+ as_str = rb_get_path_check_convert(path, as_str, level);
+ expanded_path = rb_check_realpath(Qnil, as_str);
if (NIL_P(expanded_path)) expanded_path = as_str;
rb_ary_push(ary, rb_fstring(expanded_path));
}
@@ -140,9 +141,8 @@ rb_get_expanded_load_path(void)
}
static VALUE
-load_path_getter(ID id, VALUE * p)
+load_path_getter(ID id, rb_vm_t *vm)
{
- rb_vm_t *vm = (void *)p;
return vm->load_path;
}
@@ -152,12 +152,6 @@ get_loaded_features(void)
return GET_VM()->loaded_features;
}
-static VALUE
-get_LOADED_FEATURES(ID _x, VALUE *_y)
-{
- return get_loaded_features();
-}
-
static void
reset_loaded_features_snapshot(void)
{
@@ -177,75 +171,35 @@ get_loading_table(void)
return GET_VM()->loading_table;
}
-static st_data_t
-feature_key(const char *str, size_t len)
-{
- return st_hash(str, len, 0xfea7009e);
-}
-
-static bool
-is_rbext_path(VALUE feature_path)
-{
- long len = RSTRING_LEN(feature_path);
- long rbext_len = rb_strlen_lit(".rb");
- if (len <= rbext_len) return false;
- return IS_RBEXT(RSTRING_PTR(feature_path) + len - rbext_len);
-}
-
static void
-features_index_add_single(const char* str, size_t len, VALUE offset, bool rb)
+features_index_add_single(VALUE short_feature, VALUE offset)
{
struct st_table *features_index;
VALUE this_feature_index = Qnil;
- st_data_t short_feature_key;
+ char *short_feature_cstr;
Check_Type(offset, T_FIXNUM);
- short_feature_key = feature_key(str, len);
+ Check_Type(short_feature, T_STRING);
+ short_feature_cstr = StringValueCStr(short_feature);
features_index = get_loaded_features_index_raw();
- st_lookup(features_index, short_feature_key, (st_data_t *)&this_feature_index);
+ st_lookup(features_index, (st_data_t)short_feature_cstr, (st_data_t *)&this_feature_index);
if (NIL_P(this_feature_index)) {
- st_insert(features_index, short_feature_key, (st_data_t)offset);
+ st_insert(features_index, (st_data_t)ruby_strdup(short_feature_cstr), (st_data_t)offset);
}
else if (RB_TYPE_P(this_feature_index, T_FIXNUM)) {
- VALUE loaded_features = get_loaded_features();
- VALUE this_feature_path = RARRAY_AREF(loaded_features, FIX2LONG(this_feature_index));
VALUE feature_indexes[2];
- int top = (rb && !is_rbext_path(this_feature_path)) ? 1 : 0;
- feature_indexes[top^0] = this_feature_index;
- feature_indexes[top^1] = offset;
+ feature_indexes[0] = this_feature_index;
+ feature_indexes[1] = offset;
this_feature_index = (VALUE)xcalloc(1, sizeof(struct RArray));
RBASIC(this_feature_index)->flags = T_ARRAY; /* fake VALUE, do not mark/sweep */
rb_ary_cat(this_feature_index, feature_indexes, numberof(feature_indexes));
- st_insert(features_index, short_feature_key, (st_data_t)this_feature_index);
+ st_insert(features_index, (st_data_t)short_feature_cstr, (st_data_t)this_feature_index);
}
else {
- long pos = -1;
-
Check_Type(this_feature_index, T_ARRAY);
- if (rb) {
- VALUE loaded_features = get_loaded_features();
- for (long i = 0; i < RARRAY_LEN(this_feature_index); ++i) {
- VALUE idx = RARRAY_AREF(this_feature_index, i);
- VALUE this_feature_path = RARRAY_AREF(loaded_features, FIX2LONG(idx));
- Check_Type(this_feature_path, T_STRING);
- if (!is_rbext_path(this_feature_path)) {
- /* as this_feature_index is a fake VALUE, `push` (which
- * doesn't wb_unprotect like as rb_ary_splice) first,
- * then rotate partially. */
- pos = i;
- break;
- }
- }
- }
rb_ary_push(this_feature_index, offset);
- if (pos >= 0) {
- VALUE *ptr = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(this_feature_index);
- long len = RARRAY_LEN(this_feature_index);
- MEMMOVE(ptr + pos, ptr + pos + 1, VALUE, len - pos - 1);
- ptr[pos] = offset;
- }
}
}
@@ -260,8 +214,8 @@ features_index_add_single(const char* str, size_t len, VALUE offset, bool rb)
static void
features_index_add(VALUE feature, VALUE offset)
{
+ VALUE short_feature;
const char *feature_str, *feature_end, *ext, *p;
- bool rb = false;
feature_str = StringValuePtr(feature);
feature_end = feature_str + RSTRING_LEN(feature);
@@ -271,27 +225,31 @@ features_index_add(VALUE feature, VALUE offset)
break;
if (*ext != '.')
ext = NULL;
- else
- rb = IS_RBEXT(ext);
/* Now `ext` points to the only string matching %r{^\.[^./]*$} that is
at the end of `feature`, or is NULL if there is no such string. */
p = ext ? ext : feature_end;
while (1) {
+ long beg;
+
p--;
while (p >= feature_str && *p != '/')
p--;
if (p < feature_str)
break;
/* Now *p == '/'. We reach this point for every '/' in `feature`. */
- features_index_add_single(p + 1, feature_end - p - 1, offset, false);
+ beg = p + 1 - feature_str;
+ short_feature = rb_str_subseq(feature, beg, feature_end - p - 1);
+ features_index_add_single(short_feature, offset);
if (ext) {
- features_index_add_single(p + 1, ext - p - 1, offset, rb);
+ short_feature = rb_str_subseq(feature, beg, ext - p - 1);
+ features_index_add_single(short_feature, offset);
}
}
- features_index_add_single(feature_str, feature_end - feature_str, offset, false);
+ features_index_add_single(feature, offset);
if (ext) {
- features_index_add_single(feature_str, ext - feature_str, offset, rb);
+ short_feature = rb_str_subseq(feature, 0, ext - feature_str);
+ features_index_add_single(short_feature, offset);
}
}
@@ -301,8 +259,9 @@ loaded_features_index_clear_i(st_data_t key, st_data_t val, st_data_t arg)
VALUE obj = (VALUE)val;
if (!SPECIAL_CONST_P(obj)) {
rb_ary_free(obj);
- ruby_sized_xfree((void *)obj, sizeof(struct RArray));
+ xfree((void *)obj);
}
+ xfree((char *)key);
return ST_DELETE;
}
@@ -415,7 +374,6 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
long i, len, elen, n;
st_table *loading_tbl, *features_index;
st_data_t data;
- st_data_t key;
int type;
if (fn) *fn = 0;
@@ -432,8 +390,7 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
features = get_loaded_features();
features_index = get_loaded_features_index();
- key = feature_key(feature, strlen(feature));
- st_lookup(features_index, key, (st_data_t *)&this_feature_index);
+ st_lookup(features_index, (st_data_t)feature, (st_data_t *)&this_feature_index);
/* We search `features` for an entry such that either
"#{features[i]}" == "#{load_path[j]}/#{feature}#{e}"
for some j, or
@@ -597,7 +554,6 @@ rb_provide_feature(VALUE feature)
}
rb_str_freeze(feature);
- get_loaded_features_index();
rb_ary_push(features, rb_fstring(feature));
features_index_add(feature, INT2FIX(RARRAY_LEN(features)-1));
reset_loaded_features_snapshot();
@@ -610,27 +566,10 @@ rb_provide(const char *feature)
}
NORETURN(static void load_failed(VALUE));
+const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
-static inline void
-load_iseq_eval(rb_execution_context_t *ec, VALUE fname)
-{
- const rb_iseq_t *iseq = rb_iseq_load_iseq(fname);
-
- if (!iseq) {
- rb_ast_t *ast;
- VALUE parser = rb_parser_new();
- rb_parser_set_context(parser, NULL, FALSE);
- ast = (rb_ast_t *)rb_parser_load_file(parser, fname);
- iseq = rb_iseq_new_top(&ast->body, rb_fstring_lit("<top (required)>"),
- fname, rb_realpath_internal(Qnil, fname, 1), NULL);
- rb_ast_dispose(ast);
- }
- rb_exec_event_hook_script_compiled(ec, iseq, Qnil);
- rb_iseq_eval(iseq);
-}
-
-static inline enum ruby_tag_type
-load_wrapping(rb_execution_context_t *ec, VALUE fname)
+static int
+rb_load_internal0(rb_execution_context_t *ec, VALUE fname, int wrap)
{
enum ruby_tag_type state;
rb_thread_t *th = rb_ec_thread_ptr(ec);
@@ -640,17 +579,36 @@ load_wrapping(rb_execution_context_t *ec, VALUE fname)
rb_thread_t *volatile th0 = th;
#endif
- ec->errinfo = Qnil; /* ensure */
+ th->ec->errinfo = Qnil; /* ensure */
- /* load in anonymous module as toplevel */
- th->top_self = rb_obj_clone(rb_vm_top_self());
- th->top_wrapper = rb_module_new();
- rb_extend_object(th->top_self, th->top_wrapper);
+ if (!wrap) {
+ th->top_wrapper = 0;
+ }
+ else {
+ /* load in anonymous module as toplevel */
+ th->top_self = rb_obj_clone(rb_vm_top_self());
+ th->top_wrapper = rb_module_new();
+ rb_extend_object(th->top_self, th->top_wrapper);
+ }
- EC_PUSH_TAG(ec);
+ EC_PUSH_TAG(th->ec);
state = EC_EXEC_TAG();
if (state == TAG_NONE) {
- load_iseq_eval(ec, fname);
+ rb_ast_t *ast;
+ const rb_iseq_t *iseq;
+
+ if ((iseq = rb_iseq_load_iseq(fname)) != NULL) {
+ /* OK */
+ }
+ else {
+ VALUE parser = rb_parser_new();
+ rb_parser_set_context(parser, NULL, FALSE);
+ ast = (rb_ast_t *)rb_parser_load_file(parser, fname);
+ iseq = rb_iseq_new_top(ast->root, rb_fstring_cstr("<top (required)>"),
+ fname, rb_realpath_internal(Qnil, fname, 1), NULL);
+ rb_ast_dispose(ast);
+ }
+ rb_iseq_eval(iseq);
}
EC_POP_TAG();
@@ -660,54 +618,61 @@ load_wrapping(rb_execution_context_t *ec, VALUE fname)
#endif
th->top_self = self;
th->top_wrapper = wrapper;
- return state;
-}
-static inline void
-raise_load_if_failed(rb_execution_context_t *ec, enum ruby_tag_type state)
-{
if (state) {
- rb_vm_jump_tag_but_local_jump(state);
+ /* usually state == TAG_RAISE only, except for
+ * rb_iseq_load_iseq case */
+ VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
+ if (NIL_P(exc)) return state;
+ th->ec->errinfo = exc;
+ return TAG_RAISE;
}
- if (!NIL_P(ec->errinfo)) {
- rb_exc_raise(ec->errinfo);
+ if (!NIL_P(th->ec->errinfo)) {
+ /* exception during load */
+ return TAG_RAISE;
}
+ return state;
}
static void
rb_load_internal(VALUE fname, int wrap)
{
rb_execution_context_t *ec = GET_EC();
- enum ruby_tag_type state = TAG_NONE;
- if (wrap) {
- state = load_wrapping(ec, fname);
- }
- else {
- load_iseq_eval(ec, fname);
+ int state = rb_load_internal0(ec, fname, wrap);
+ if (state) {
+ if (state == TAG_RAISE) rb_exc_raise(ec->errinfo);
+ EC_JUMP_TAG(ec, state);
}
- raise_load_if_failed(ec, state);
}
-void
-rb_load(VALUE fname, int wrap)
+static VALUE
+file_to_load(VALUE fname)
{
VALUE tmp = rb_find_file(FilePathValue(fname));
if (!tmp) load_failed(fname);
- rb_load_internal(tmp, wrap);
+ return tmp;
+}
+
+void
+rb_load(VALUE fname, int wrap)
+{
+ rb_load_internal(file_to_load(fname), wrap);
}
void
rb_load_protect(VALUE fname, int wrap, int *pstate)
{
enum ruby_tag_type state;
+ volatile VALUE path = 0;
EC_PUSH_TAG(GET_EC());
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- rb_load(fname, wrap);
+ path = file_to_load(fname);
}
EC_POP_TAG();
+ if (state == TAG_NONE) state = rb_load_internal0(GET_EC(), path, wrap);
if (state != TAG_NONE) *pstate = state;
}
@@ -726,13 +691,13 @@ rb_load_protect(VALUE fname, int wrap, int *pstate)
*/
static VALUE
-rb_f_load(int argc, VALUE *argv, VALUE _)
+rb_f_load(int argc, VALUE *argv)
{
VALUE fname, wrap, path, orig_fname;
rb_scan_args(argc, argv, "11", &fname, &wrap);
- orig_fname = rb_get_path_check_to_string(fname);
+ orig_fname = rb_get_path_check_to_string(fname, rb_safe_level());
fname = rb_str_encode_ospath(orig_fname);
RUBY_DTRACE_HOOK(LOAD_ENTRY, RSTRING_PTR(orig_fname));
@@ -749,6 +714,8 @@ rb_f_load(int argc, VALUE *argv, VALUE _)
return Qtrue;
}
+extern VALUE rb_mWarning;
+
static char *
load_lock(const char *ftptr)
{
@@ -764,7 +731,7 @@ load_lock(const char *ftptr)
}
else if (imemo_type_p(data, imemo_memo)) {
struct MEMO *memo = MEMO_CAST(data);
- void (*init)(void) = memo->u3.func;
+ void (*init)(void) = (void (*)(void))memo->u3.func;
data = (st_data_t)rb_thread_shield_new();
st_insert(loading_tbl, (st_data_t)ftptr, data);
(*init)();
@@ -773,7 +740,7 @@ load_lock(const char *ftptr)
if (RTEST(ruby_verbose)) {
VALUE warning = rb_warning_string("loading in progress, circular require considered harmful - %s", ftptr);
rb_backtrace_each(rb_str_append, warning);
- rb_warning("%"PRIsVALUE, warning);
+ rb_warning_warn(rb_mWarning, warning);
}
switch (rb_thread_shield_wait((VALUE)data)) {
case Qfalse:
@@ -852,7 +819,7 @@ load_unlock(const char *ftptr, int done)
VALUE
rb_f_require(VALUE obj, VALUE fname)
{
- return rb_require_string(fname);
+ return rb_require_safe(fname, rb_safe_level());
}
/*
@@ -871,13 +838,11 @@ rb_f_require_relative(VALUE obj, VALUE fname)
rb_loaderror("cannot infer basepath");
}
base = rb_file_dirname(base);
- return rb_require_string(rb_file_absolute_path(fname, base));
+ return rb_require_safe(rb_file_absolute_path(fname, base), rb_safe_level());
}
-typedef int (*feature_func)(const char *feature, const char *ext, int rb, int expanded, const char **fn);
-
static int
-search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
+search_required(VALUE fname, volatile VALUE *path, int safe_level)
{
VALUE tmp;
char *ext, *ftptr;
@@ -892,7 +857,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return 'r';
}
- if ((tmp = rb_find_file(fname)) != 0) {
+ if ((tmp = rb_find_file_safe(fname, safe_level)) != 0) {
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, TRUE, TRUE, &loading) || loading)
*path = tmp;
@@ -908,7 +873,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
tmp = rb_str_subseq(fname, 0, ext - RSTRING_PTR(fname));
#ifdef DLEXT2
OBJ_FREEZE(tmp);
- if (rb_find_file_ext(&tmp, loadable_ext + 1)) {
+ if (rb_find_file_ext_safe(&tmp, loadable_ext + 1, safe_level)) {
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, FALSE, TRUE, &loading) || loading)
*path = tmp;
@@ -917,7 +882,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
#else
rb_str_cat2(tmp, DLEXT);
OBJ_FREEZE(tmp);
- if ((tmp = rb_find_file(tmp)) != 0) {
+ if ((tmp = rb_find_file_safe(tmp, safe_level)) != 0) {
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, FALSE, TRUE, &loading) || loading)
*path = tmp;
@@ -930,7 +895,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return 's';
}
- if ((tmp = rb_find_file(fname)) != 0) {
+ if ((tmp = rb_find_file_safe(fname, safe_level)) != 0) {
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, FALSE, TRUE, &loading) || loading)
*path = tmp;
@@ -943,7 +908,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
return 'r';
}
tmp = fname;
- type = rb_find_file_ext(&tmp, ft == 's' ? ruby_ext : loadable_ext);
+ type = rb_find_file_ext_safe(&tmp, loadable_ext, safe_level);
switch (type) {
case 0:
if (ft)
@@ -957,7 +922,6 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return ft;
}
- /* fall through */
case 1:
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (rb_feature_p(ftptr, ext, !--type, TRUE, &loading) && !loading)
@@ -980,38 +944,6 @@ load_ext(VALUE path)
return (VALUE)dln_load(RSTRING_PTR(path));
}
-static int
-no_feature_p(const char *feature, const char *ext, int rb, int expanded, const char **fn)
-{
- return 0;
-}
-
-// Documented in doc/globals.rdoc
-VALUE
-rb_resolve_feature_path(VALUE klass, VALUE fname)
-{
- VALUE path;
- int found;
- VALUE sym;
-
- fname = rb_get_path(fname);
- path = rb_str_encode_ospath(fname);
- found = search_required(path, &path, no_feature_p);
-
- switch (found) {
- case 'r':
- sym = ID2SYM(rb_intern("rb"));
- break;
- case 's':
- sym = ID2SYM(rb_intern("so"));
- break;
- default:
- load_failed(fname);
- }
-
- return rb_ary_new_from_args(2, sym, path);
-}
-
/*
* returns
* 0: if already loaded (false)
@@ -1019,44 +951,47 @@ rb_resolve_feature_path(VALUE klass, VALUE fname)
* <0: not found (LoadError)
* >1: exception
*/
-static int
-require_internal(rb_execution_context_t *ec, VALUE fname, int exception)
+int
+rb_require_internal(VALUE fname, int safe)
{
volatile int result = -1;
- rb_thread_t *th = rb_ec_thread_ptr(ec);
- volatile VALUE wrapper = th->top_wrapper;
- volatile VALUE self = th->top_self;
+ rb_execution_context_t *ec = GET_EC();
volatile VALUE errinfo = ec->errinfo;
enum ruby_tag_type state;
+ struct {
+ int safe;
+ } volatile saved;
char *volatile ftptr = 0;
VALUE path;
- fname = rb_get_path(fname);
+ fname = rb_get_path_check(fname, safe);
path = rb_str_encode_ospath(fname);
RUBY_DTRACE_HOOK(REQUIRE_ENTRY, RSTRING_PTR(fname));
EC_PUSH_TAG(ec);
- ec->errinfo = Qnil; /* ensure */
- th->top_wrapper = 0;
+ saved.safe = rb_safe_level();
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
long handle;
int found;
+ rb_set_safe_level_force(0);
+
RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, RSTRING_PTR(fname));
- found = search_required(path, &path, rb_feature_p);
+ found = search_required(path, &path, safe);
RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, RSTRING_PTR(fname));
if (found) {
- if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
+ if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
result = 0;
}
else if (!*ftptr) {
+ rb_provide_feature(path);
result = TAG_RETURN;
}
else {
switch (found) {
case 'r':
- load_iseq_eval(ec, path);
+ state = rb_load_internal0(ec, path, 0);
break;
case 's':
@@ -1065,40 +1000,23 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception)
rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
break;
}
- result = TAG_RETURN;
+ if (!state) {
+ rb_provide_feature(path);
+ result = TAG_RETURN;
+ }
}
}
}
EC_POP_TAG();
- th = rb_ec_thread_ptr(ec);
- th->top_self = self;
- th->top_wrapper = wrapper;
- if (ftptr) load_unlock(RSTRING_PTR(path), !state);
+ load_unlock(ftptr, !state);
+ rb_set_safe_level_force(saved.safe);
if (state) {
- if (state == TAG_FATAL || state == TAG_THROW) {
- EC_JUMP_TAG(ec, state);
- }
- else if (exception) {
- /* usually state == TAG_RAISE only, except for
- * rb_iseq_load_iseq in load_iseq_eval case */
- VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
- if (!NIL_P(exc)) ec->errinfo = exc;
- return TAG_RAISE;
- }
- else if (state == TAG_RETURN) {
- return TAG_RAISE;
- }
RB_GC_GUARD(fname);
/* never TAG_RETURN */
return state;
}
- if (!NIL_P(ec->errinfo)) {
- if (!exception) return TAG_RAISE;
- rb_exc_raise(ec->errinfo);
- }
- if (result == TAG_RETURN) rb_provide_feature(path);
ec->errinfo = errinfo;
RUBY_DTRACE_HOOK(REQUIRE_RETURN, RSTRING_PTR(fname));
@@ -1107,19 +1025,11 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception)
}
int
-rb_require_internal(VALUE fname)
-{
- rb_execution_context_t *ec = GET_EC();
- return require_internal(ec, fname, 1);
-}
-
-int
ruby_require_internal(const char *fname, unsigned int len)
{
struct RString fake;
VALUE str = rb_setup_fake_str(&fake, fname, len, 0);
- rb_execution_context_t *ec = GET_EC();
- int result = require_internal(ec, str, 0);
+ int result = rb_require_internal(str, 0);
rb_set_errinfo(Qnil);
return result == TAG_RETURN ? 1 : result ? -1 : 0;
}
@@ -1127,28 +1037,11 @@ ruby_require_internal(const char *fname, unsigned int len)
VALUE
rb_require_safe(VALUE fname, int safe)
{
- rb_warn("rb_require_safe will be removed in Ruby 3.0");
- rb_execution_context_t *ec = GET_EC();
- int result = require_internal(ec, fname, 1);
+ int result = rb_require_internal(fname, safe);
if (result > TAG_RETURN) {
- EC_JUMP_TAG(ec, result);
- }
- if (result < 0) {
- load_failed(fname);
- }
-
- return result ? Qtrue : Qfalse;
-}
-
-VALUE
-rb_require_string(VALUE fname)
-{
- rb_execution_context_t *ec = GET_EC();
- int result = require_internal(ec, fname, 1);
-
- if (result > TAG_RETURN) {
- EC_JUMP_TAG(ec, result);
+ if (result == TAG_RAISE) rb_exc_raise(rb_errinfo());
+ EC_JUMP_TAG(GET_EC(), result);
}
if (result < 0) {
load_failed(fname);
@@ -1160,7 +1053,8 @@ rb_require_string(VALUE fname)
VALUE
rb_require(const char *fname)
{
- return rb_require_string(rb_str_new_cstr(fname));
+ VALUE fn = rb_str_new_cstr(fname);
+ return rb_require_safe(fn, rb_safe_level());
}
static int
@@ -1192,8 +1086,8 @@ ruby_init_ext(const char *name, void (*init)(void))
* call-seq:
* mod.autoload(module, filename) -> nil
*
- * Registers _filename_ to be loaded (using Kernel::require)
- * the first time that _module_ (which may be a String or
+ * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
+ * the first time that _module_ (which may be a <code>String</code> or
* a symbol) is accessed in the namespace of _mod_.
*
* module A
@@ -1214,49 +1108,33 @@ rb_mod_autoload(VALUE mod, VALUE sym, VALUE file)
/*
* call-seq:
- * mod.autoload?(name, inherit=true) -> String or nil
+ * mod.autoload?(name) -> String or nil
*
* Returns _filename_ to be loaded if _name_ is registered as
- * +autoload+ in the namespace of _mod_ or one of its ancestors.
+ * +autoload+ in the namespace of _mod_.
*
* module A
* end
* A.autoload(:B, "b")
* A.autoload?(:B) #=> "b"
- *
- * If +inherit+ is false, the lookup only checks the autoloads in the receiver:
- *
- * class A
- * autoload :CONST, "const.rb"
- * end
- *
- * class B < A
- * end
- *
- * B.autoload?(:CONST) #=> "const.rb", found in A (ancestor)
- * B.autoload?(:CONST, false) #=> nil, not found in B itself
- *
*/
static VALUE
-rb_mod_autoload_p(int argc, VALUE *argv, VALUE mod)
+rb_mod_autoload_p(VALUE mod, VALUE sym)
{
- int recur = (rb_check_arity(argc, 1, 2) == 1) ? TRUE : RTEST(argv[1]);
- VALUE sym = argv[0];
-
ID id = rb_check_id(&sym);
if (!id) {
return Qnil;
}
- return rb_autoload_at_p(mod, id, recur);
+ return rb_autoload_p(mod, id);
}
/*
* call-seq:
* autoload(module, filename) -> nil
*
- * Registers _filename_ to be loaded (using Kernel::require)
- * the first time that _module_ (which may be a String or
+ * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
+ * the first time that _module_ (which may be a <code>String</code> or
* a symbol) is accessed.
*
* autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
@@ -1274,7 +1152,7 @@ rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
/*
* call-seq:
- * autoload?(name, inherit=true) -> String or nil
+ * autoload?(name) -> String or nil
*
* Returns _filename_ to be loaded if _name_ is registered as
* +autoload+.
@@ -1284,14 +1162,14 @@ rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
*/
static VALUE
-rb_f_autoload_p(int argc, VALUE *argv, VALUE obj)
+rb_f_autoload_p(VALUE obj, VALUE sym)
{
/* use rb_vm_cbase() as same as rb_f_autoload. */
VALUE klass = rb_vm_cbase();
if (NIL_P(klass)) {
return Qnil;
}
- return rb_mod_autoload_p(argc, argv, klass);
+ return rb_mod_autoload_p(klass, sym);
}
void
@@ -1310,21 +1188,20 @@ Init_load(void)
vm->expanded_load_path = rb_ary_tmp_new(0);
vm->load_path_snapshot = rb_ary_tmp_new(0);
vm->load_path_check_cache = 0;
- rb_define_singleton_method(vm->load_path, "resolve_feature_path", rb_resolve_feature_path, 1);
- rb_define_virtual_variable("$\"", get_LOADED_FEATURES, 0);
- rb_define_virtual_variable("$LOADED_FEATURES", get_LOADED_FEATURES, 0);
+ rb_define_virtual_variable("$\"", get_loaded_features, 0);
+ rb_define_virtual_variable("$LOADED_FEATURES", get_loaded_features, 0);
vm->loaded_features = rb_ary_new();
vm->loaded_features_snapshot = rb_ary_tmp_new(0);
- vm->loaded_features_index = st_init_numtable();
+ vm->loaded_features_index = st_init_strtable();
rb_define_global_function("load", rb_f_load, -1);
rb_define_global_function("require", rb_f_require, 1);
rb_define_global_function("require_relative", rb_f_require_relative, 1);
rb_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
- rb_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, -1);
+ rb_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, 1);
rb_define_global_function("autoload", rb_f_autoload, 2);
- rb_define_global_function("autoload?", rb_f_autoload_p, -1);
+ rb_define_global_function("autoload?", rb_f_autoload_p, 1);
ruby_dln_librefs = rb_ary_tmp_new(0);
rb_gc_register_mark_object(ruby_dln_librefs);
diff --git a/loadpath.c b/loadpath.c
index b8969e6998..9160031971 100644
--- a/loadpath.c
+++ b/loadpath.c
@@ -89,3 +89,4 @@ const char ruby_initial_load_paths[] =
RUBY_ARCH_LIB_FOR(RUBY_ARCH) "\0"
#endif
"";
+
diff --git a/localeinit.c b/localeinit.c
index bec29a6d46..dc48d42561 100644
--- a/localeinit.c
+++ b/localeinit.c
@@ -9,7 +9,6 @@
**********************************************************************/
-#include "ruby/encoding.h"
#include "internal.h"
#include "encindex.h"
#ifdef __CYGWIN__
diff --git a/main.c b/main.c
index 313aaedd42..6e8ab7b9fe 100644
--- a/main.c
+++ b/main.c
@@ -9,14 +9,6 @@
**********************************************************************/
-/*!
- * \mainpage Developers' documentation for Ruby
- *
- * This documentation is produced by applying Doxygen to
- * <a href="https://github.com/ruby/ruby">Ruby's source code</a>.
- * It is still under construction (and even not well-maintained).
- * If you are familiar with Ruby's source code, please improve the doc.
- */
#undef RUBY_EXPORT
#include "ruby.h"
#include "vm_debug.h"
diff --git a/man/bundle-add.1 b/man/bundle-add.1
deleted file mode 100644
index 8b75859104..0000000000
--- a/man/bundle-add.1
+++ /dev/null
@@ -1,66 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-ADD" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
-.
-.SH "SYNOPSIS"
-\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-git=GIT] [\-\-branch=BRANCH] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
-.
-.SH "DESCRIPTION"
-Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
-.
-.P
-Example:
-.
-.P
-bundle add rails
-.
-.P
-bundle add rails \-\-version "< 3\.0, > 1\.1"
-.
-.P
-bundle add rails \-\-version "~> 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"
-.
-.P
-bundle add rails \-\-skip\-install
-.
-.P
-bundle add rails \-\-group "development, test"
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-version\fR, \fB\-v\fR
-Specify version requirements(s) for the added gem\.
-.
-.TP
-\fB\-\-group\fR, \fB\-g\fR
-Specify the group(s) for the added gem\. Multiple groups should be separated by commas\.
-.
-.TP
-\fB\-\-source\fR, , \fB\-s\fR
-Specify the source for the added gem\.
-.
-.TP
-\fB\-\-git\fR
-Specify the git source for the added gem\.
-.
-.TP
-\fB\-\-branch\fR
-Specify the git branch for the added gem\.
-.
-.TP
-\fB\-\-skip\-install\fR
-Adds the gem to the Gemfile but does not install it\.
-.
-.TP
-\fB\-\-optimistic\fR
-Adds optimistic declaration of version
-.
-.TP
-\fB\-\-strict\fR
-Adds strict declaration of version
-
diff --git a/man/bundle-add.1.txt b/man/bundle-add.1.txt
deleted file mode 100644
index dcd76df4ae..0000000000
--- a/man/bundle-add.1.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-BUNDLE-ADD(1) BUNDLE-ADD(1)
-
-
-
-NAME
- bundle-add - Add gem to the Gemfile and run bundle install
-
-SYNOPSIS
- bundle add GEM_NAME [--group=GROUP] [--version=VERSION]
- [--source=SOURCE] [--git=GIT] [--branch=BRANCH] [--skip-install]
- [--strict] [--optimistic]
-
-DESCRIPTION
- Adds the named gem to the Gemfile and run bundle install. bundle
- install can be avoided by using the flag --skip-install.
-
- Example:
-
- bundle add rails
-
- bundle add rails --version "< 3.0, > 1.1"
-
- bundle add rails --version "~> 5.0.0" --source "https://gems.exam-
- ple.com" --group "development"
-
- bundle add rails --skip-install
-
- bundle add rails --group "development, test"
-
-OPTIONS
- --version, -v
- Specify version requirements(s) for the added gem.
-
- --group, -g
- Specify the group(s) for the added gem. Multiple groups should
- be separated by commas.
-
- --source, , -s
- Specify the source for the added gem.
-
- --git Specify the git source for the added gem.
-
- --branch
- Specify the git branch for the added gem.
-
- --skip-install
- Adds the gem to the Gemfile but does not install it.
-
- --optimistic
- Adds optimistic declaration of version
-
- --strict
- Adds strict declaration of version
-
-
-
-
- January 2020 BUNDLE-ADD(1)
diff --git a/man/bundle-add.ronn b/man/bundle-add.ronn
deleted file mode 100644
index 26cbe55647..0000000000
--- a/man/bundle-add.ronn
+++ /dev/null
@@ -1,46 +0,0 @@
-bundle-add(1) -- Add gem to the Gemfile and run bundle install
-================================================================
-
-## SYNOPSIS
-
-`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--git=GIT] [--branch=BRANCH] [--skip-install] [--strict] [--optimistic]
-
-## DESCRIPTION
-Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.
-
-Example:
-
-bundle add rails
-
-bundle add rails --version "< 3.0, > 1.1"
-
-bundle add rails --version "~> 5.0.0" --source "https://gems.example.com" --group "development"
-
-bundle add rails --skip-install
-
-bundle add rails --group "development, test"
-
-## OPTIONS
-* `--version`, `-v`:
- Specify version requirements(s) for the added gem.
-
-* `--group`, `-g`:
- Specify the group(s) for the added gem. Multiple groups should be separated by commas.
-
-* `--source`, , `-s`:
- Specify the source for the added gem.
-
-* `--git`:
- Specify the git source for the added gem.
-
-* `--branch`:
- Specify the git branch for the added gem.
-
-* `--skip-install`:
- Adds the gem to the Gemfile but does not install it.
-
-* `--optimistic`:
- Adds optimistic declaration of version
-
-* `--strict`:
- Adds strict declaration of version
diff --git a/man/bundle-binstubs.1 b/man/bundle-binstubs.1
deleted file mode 100644
index 4f9e5c0e31..0000000000
--- a/man/bundle-binstubs.1
+++ /dev/null
@@ -1,40 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-BINSTUBS" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
-.
-.SH "SYNOPSIS"
-\fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-path PATH] [\-\-standalone]
-.
-.SH "DESCRIPTION"
-Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it into \fBbin/\fR\. Binstubs are a shortcut\-or alternative\- to always using \fBbundle exec\fR\. This gives you a file that can be run directly, and one that will always run the correct gem version used by the application\.
-.
-.P
-For example, if you run \fBbundle binstubs rspec\-core\fR, Bundler will create the file \fBbin/rspec\fR\. That file will contain enough code to load Bundler, tell it to load the bundled gems, and then run rspec\.
-.
-.P
-This command generates binstubs for executables in \fBGEM_NAME\fR\. Binstubs are put into \fBbin\fR, or the \fB\-\-path\fR directory if one has been set\. Calling binstubs with [GEM [GEM]] will create binstubs for all given gems\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-force\fR
-Overwrite existing binstubs if they exist\.
-.
-.TP
-\fB\-\-path\fR
-The location to install the specified binstubs to\. This defaults to \fBbin\fR\.
-.
-.TP
-\fB\-\-standalone\fR
-Makes binstubs that can work without depending on Rubygems or Bundler at runtime\.
-.
-.TP
-\fB\-\-shebang\fR
-Specify a different shebang executable name than the default (default \'ruby\')
-.
-.SH "BUNDLE INSTALL \-\-BINSTUBS"
-To create binstubs for all the gems in the bundle you can use the \fB\-\-binstubs\fR flag in bundle install(1) \fIbundle\-install\.1\.html\fR\.
diff --git a/man/bundle-binstubs.1.txt b/man/bundle-binstubs.1.txt
deleted file mode 100644
index cbd2b12da0..0000000000
--- a/man/bundle-binstubs.1.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-BUNDLE-BINSTUBS(1) BUNDLE-BINSTUBS(1)
-
-
-
-NAME
- bundle-binstubs - Install the binstubs of the listed gems
-
-SYNOPSIS
- bundle binstubs GEM_NAME [--force] [--path PATH] [--standalone]
-
-DESCRIPTION
- Binstubs are scripts that wrap around executables. Bundler creates a
- small Ruby file (a binstub) that loads Bundler, runs the command, and
- puts it into bin/. Binstubs are a shortcut-or alternative- to always
- using bundle exec. This gives you a file that can be run directly, and
- one that will always run the correct gem version used by the applica-
- tion.
-
- For example, if you run bundle binstubs rspec-core, Bundler will create
- the file bin/rspec. That file will contain enough code to load Bundler,
- tell it to load the bundled gems, and then run rspec.
-
- This command generates binstubs for executables in GEM_NAME. Binstubs
- are put into bin, or the --path directory if one has been set. Calling
- binstubs with [GEM [GEM]] will create binstubs for all given gems.
-
-OPTIONS
- --force
- Overwrite existing binstubs if they exist.
-
- --path The location to install the specified binstubs to. This defaults
- to bin.
-
- --standalone
- Makes binstubs that can work without depending on Rubygems or
- Bundler at runtime.
-
- --shebang
- Specify a different shebang executable name than the default
- (default 'ruby')
-
-BUNDLE INSTALL --BINSTUBS
- To create binstubs for all the gems in the bundle you can use the
- --binstubs flag in bundle install(1) bundle-install.1.html.
-
-
-
- January 2020 BUNDLE-BINSTUBS(1)
diff --git a/man/bundle-binstubs.ronn b/man/bundle-binstubs.ronn
deleted file mode 100644
index 8909fdc3da..0000000000
--- a/man/bundle-binstubs.ronn
+++ /dev/null
@@ -1,43 +0,0 @@
-bundle-binstubs(1) -- Install the binstubs of the listed gems
-=============================================================
-
-## SYNOPSIS
-
-`bundle binstubs` <GEM_NAME> [--force] [--path PATH] [--standalone]
-
-## DESCRIPTION
-
-Binstubs are scripts that wrap around executables. Bundler creates a
-small Ruby file (a binstub) that loads Bundler, runs the command,
-and puts it into `bin/`. Binstubs are a shortcut-or alternative-
-to always using `bundle exec`. This gives you a file that can be run
-directly, and one that will always run the correct gem version
-used by the application.
-
-For example, if you run `bundle binstubs rspec-core`, Bundler will create
-the file `bin/rspec`. That file will contain enough code to load Bundler,
-tell it to load the bundled gems, and then run rspec.
-
-This command generates binstubs for executables in `GEM_NAME`.
-Binstubs are put into `bin`, or the `--path` directory if one has been set.
-Calling binstubs with [GEM [GEM]] will create binstubs for all given gems.
-
-## OPTIONS
-
-* `--force`:
- Overwrite existing binstubs if they exist.
-
-* `--path`:
- The location to install the specified binstubs to. This defaults to `bin`.
-
-* `--standalone`:
- Makes binstubs that can work without depending on Rubygems or Bundler at
- runtime.
-
-* `--shebang`:
- Specify a different shebang executable name than the default (default 'ruby')
-
-## BUNDLE INSTALL --BINSTUBS
-
-To create binstubs for all the gems in the bundle you can use the `--binstubs`
-flag in [bundle install(1)](bundle-install.1.html).
diff --git a/man/bundle-cache.1 b/man/bundle-cache.1
deleted file mode 100644
index cb376777ff..0000000000
--- a/man/bundle-cache.1
+++ /dev/null
@@ -1,55 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CACHE" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
-.
-.SH "SYNOPSIS"
-\fBbundle cache\fR
-.
-.SH "DESCRIPTION"
-Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running [bundle install(1)][bundle\-install], use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
-.
-.SH "GIT AND PATH GEMS"
-The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR dependencies besides \.gem files\. This needs to be explicitly enabled via the \fB\-\-all\fR option\. Once used, the \fB\-\-all\fR option will be remembered\.
-.
-.SH "SUPPORT FOR MULTIPLE PLATFORMS"
-When using gems that have different packages for different platforms, Bundler supports caching of gems for other platforms where the Gemfile has been resolved (i\.e\. present in the lockfile) in \fBvendor/cache\fR\. This needs to be enabled via the \fB\-\-all\-platforms\fR option\. This setting will be remembered in your local bundler configuration\.
-.
-.SH "REMOTE FETCHING"
-By default, if you run \fBbundle install(1)\fR](bundle\-install\.1\.html) after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
-.
-.P
-For instance, consider this Gemfile(5):
-.
-.IP "" 4
-.
-.nf
-
-source "https://rubygems\.org"
-
-gem "nokogiri"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-If you run \fBbundle cache\fR under C Ruby, bundler will retrieve the version of \fBnokogiri\fR for the \fB"ruby"\fR platform\. If you deploy to JRuby and run \fBbundle install\fR, bundler is forced to check to see whether a \fB"java"\fR platformed \fBnokogiri\fR exists\.
-.
-.P
-Even though the \fBnokogiri\fR gem for the Ruby platform is \fItechnically\fR acceptable on JRuby, it has a C extension that does not run on JRuby\. As a result, bundler will, by default, still connect to \fBrubygems\.org\fR to check whether it has a version of one of your gems more specific to your platform\.
-.
-.P
-This problem is also not limited to the \fB"java"\fR platform\. A similar (common) problem can happen when developing on Windows and deploying to Linux, or even when developing on OSX and deploying to Linux\.
-.
-.P
-If you know for sure that the gems packaged in \fBvendor/cache\fR are appropriate for the platform you are on, you can run \fBbundle install \-\-local\fR to skip checking for more appropriate gems, and use the ones in \fBvendor/cache\fR\.
-.
-.P
-One way to be sure that you have the right platformed versions of all your gems is to run \fBbundle cache\fR on an identical machine and check in the gems\. For instance, you can run \fBbundle cache\fR on an identical staging box during your staging process, and check in the \fBvendor/cache\fR before deploying to production\.
-.
-.P
-By default, bundle cache(1) \fIbundle\-cache\.1\.html\fR fetches and also installs the gems to the default location\. To package the dependencies to \fBvendor/cache\fR without installing them to the local install location, you can run \fBbundle cache \-\-no\-install\fR\.
diff --git a/man/bundle-cache.1.txt b/man/bundle-cache.1.txt
deleted file mode 100644
index c0b8b5bf07..0000000000
--- a/man/bundle-cache.1.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-BUNDLE-CACHE(1) BUNDLE-CACHE(1)
-
-
-
-NAME
- bundle-cache - Package your needed .gem files into your application
-
-SYNOPSIS
- bundle cache
-
-DESCRIPTION
- Copy all of the .gem files needed to run the application into the ven-
- dor/cache directory. In the future, when running [bundle
- install(1)][bundle-install], use the gems in the cache in preference to
- the ones on rubygems.org.
-
-GIT AND PATH GEMS
- The bundle cache command can also package :git and :path dependencies
- besides .gem files. This needs to be explicitly enabled via the --all
- option. Once used, the --all option will be remembered.
-
-SUPPORT FOR MULTIPLE PLATFORMS
- When using gems that have different packages for different platforms,
- Bundler supports caching of gems for other platforms where the Gemfile
- has been resolved (i.e. present in the lockfile) in vendor/cache. This
- needs to be enabled via the --all-platforms option. This setting will
- be remembered in your local bundler configuration.
-
-REMOTE FETCHING
- By default, if you run bundle install(1)](bundle-install.1.html) after
- running bundle cache(1) bundle-cache.1.html, bundler will still connect
- to rubygems.org to check whether a platform-specific gem exists for any
- of the gems in vendor/cache.
-
- For instance, consider this Gemfile(5):
-
-
-
- source "https://rubygems.org"
-
- gem "nokogiri"
-
-
-
- If you run bundle cache under C Ruby, bundler will retrieve the version
- of nokogiri for the "ruby" platform. If you deploy to JRuby and run
- bundle install, bundler is forced to check to see whether a "java"
- platformed nokogiri exists.
-
- Even though the nokogiri gem for the Ruby platform is technically
- acceptable on JRuby, it has a C extension that does not run on JRuby.
- As a result, bundler will, by default, still connect to rubygems.org to
- check whether it has a version of one of your gems more specific to
- your platform.
-
- This problem is also not limited to the "java" platform. A similar
- (common) problem can happen when developing on Windows and deploying to
- Linux, or even when developing on OSX and deploying to Linux.
-
- If you know for sure that the gems packaged in vendor/cache are appro-
- priate for the platform you are on, you can run bundle install --local
- to skip checking for more appropriate gems, and use the ones in ven-
- dor/cache.
-
- One way to be sure that you have the right platformed versions of all
- your gems is to run bundle cache on an identical machine and check in
- the gems. For instance, you can run bundle cache on an identical stag-
- ing box during your staging process, and check in the vendor/cache
- before deploying to production.
-
- By default, bundle cache(1) bundle-cache.1.html fetches and also
- installs the gems to the default location. To package the dependencies
- to vendor/cache without installing them to the local install location,
- you can run bundle cache --no-install.
-
-
-
- January 2020 BUNDLE-CACHE(1)
diff --git a/man/bundle-cache.ronn b/man/bundle-cache.ronn
deleted file mode 100644
index 383adb2ba3..0000000000
--- a/man/bundle-cache.ronn
+++ /dev/null
@@ -1,72 +0,0 @@
-bundle-cache(1) -- Package your needed `.gem` files into your application
-===========================================================================
-
-## SYNOPSIS
-
-`bundle cache`
-
-## DESCRIPTION
-
-Copy all of the `.gem` files needed to run the application into the
-`vendor/cache` directory. In the future, when running [bundle install(1)][bundle-install],
-use the gems in the cache in preference to the ones on `rubygems.org`.
-
-## GIT AND PATH GEMS
-
-The `bundle cache` command can also package `:git` and `:path` dependencies
-besides .gem files. This needs to be explicitly enabled via the `--all` option.
-Once used, the `--all` option will be remembered.
-
-## SUPPORT FOR MULTIPLE PLATFORMS
-
-When using gems that have different packages for different platforms, Bundler
-supports caching of gems for other platforms where the Gemfile has been resolved
-(i.e. present in the lockfile) in `vendor/cache`. This needs to be enabled via
-the `--all-platforms` option. This setting will be remembered in your local
-bundler configuration.
-
-## REMOTE FETCHING
-
-By default, if you run `bundle install(1)`](bundle-install.1.html) after running
-[bundle cache(1)](bundle-cache.1.html), bundler will still connect to `rubygems.org`
-to check whether a platform-specific gem exists for any of the gems
-in `vendor/cache`.
-
-For instance, consider this Gemfile(5):
-
- source "https://rubygems.org"
-
- gem "nokogiri"
-
-If you run `bundle cache` under C Ruby, bundler will retrieve
-the version of `nokogiri` for the `"ruby"` platform. If you deploy
-to JRuby and run `bundle install`, bundler is forced to check to
-see whether a `"java"` platformed `nokogiri` exists.
-
-Even though the `nokogiri` gem for the Ruby platform is
-_technically_ acceptable on JRuby, it has a C extension
-that does not run on JRuby. As a result, bundler will, by default,
-still connect to `rubygems.org` to check whether it has a version
-of one of your gems more specific to your platform.
-
-This problem is also not limited to the `"java"` platform.
-A similar (common) problem can happen when developing on Windows
-and deploying to Linux, or even when developing on OSX and
-deploying to Linux.
-
-If you know for sure that the gems packaged in `vendor/cache`
-are appropriate for the platform you are on, you can run
-`bundle install --local` to skip checking for more appropriate
-gems, and use the ones in `vendor/cache`.
-
-One way to be sure that you have the right platformed versions
-of all your gems is to run `bundle cache` on an identical
-machine and check in the gems. For instance, you can run
-`bundle cache` on an identical staging box during your
-staging process, and check in the `vendor/cache` before
-deploying to production.
-
-By default, [bundle cache(1)](bundle-cache.1.html) fetches and also
-installs the gems to the default location. To package the
-dependencies to `vendor/cache` without installing them to the
-local install location, you can run `bundle cache --no-install`.
diff --git a/man/bundle-check.1 b/man/bundle-check.1
deleted file mode 100644
index aba5b66348..0000000000
--- a/man/bundle-check.1
+++ /dev/null
@@ -1,31 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CHECK" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems
-.
-.SH "SYNOPSIS"
-\fBbundle check\fR [\-\-dry\-run] [\-\-gemfile=FILE] [\-\-path=PATH]
-.
-.SH "DESCRIPTION"
-\fBcheck\fR searches the local machine for each of the gems requested in the Gemfile\. If all gems are found, Bundler prints a success message and exits with a status of 0\.
-.
-.P
-If not, the first missing gem is listed and Bundler exits status 1\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-dry\-run\fR
-Locks the [\fBGemfile(5)\fR][Gemfile(5)] before running the command\.
-.
-.TP
-\fB\-\-gemfile\fR
-Use the specified gemfile instead of the [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
-.TP
-\fB\-\-path\fR
-Specify a different path than the system default (\fB$BUNDLE_PATH\fR or \fB$GEM_HOME\fR)\. Bundler will remember this value for future installs on this machine\.
-
diff --git a/man/bundle-check.1.txt b/man/bundle-check.1.txt
deleted file mode 100644
index cca5fae9e1..0000000000
--- a/man/bundle-check.1.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-BUNDLE-CHECK(1) BUNDLE-CHECK(1)
-
-
-
-NAME
- bundle-check - Verifies if dependencies are satisfied by installed gems
-
-SYNOPSIS
- bundle check [--dry-run] [--gemfile=FILE] [--path=PATH]
-
-DESCRIPTION
- check searches the local machine for each of the gems requested in the
- Gemfile. If all gems are found, Bundler prints a success message and
- exits with a status of 0.
-
- If not, the first missing gem is listed and Bundler exits status 1.
-
-OPTIONS
- --dry-run
- Locks the [Gemfile(5)][Gemfile(5)] before running the command.
-
- --gemfile
- Use the specified gemfile instead of the [Gemfile(5)][Gem-
- file(5)].
-
- --path Specify a different path than the system default ($BUNDLE_PATH
- or $GEM_HOME). Bundler will remember this value for future
- installs on this machine.
-
-
-
-
- January 2020 BUNDLE-CHECK(1)
diff --git a/man/bundle-check.ronn b/man/bundle-check.ronn
deleted file mode 100644
index f2846b8ff2..0000000000
--- a/man/bundle-check.ronn
+++ /dev/null
@@ -1,26 +0,0 @@
-bundle-check(1) -- Verifies if dependencies are satisfied by installed gems
-===========================================================================
-
-## SYNOPSIS
-
-`bundle check` [--dry-run]
- [--gemfile=FILE]
- [--path=PATH]
-
-## DESCRIPTION
-
-`check` searches the local machine for each of the gems requested in the
-Gemfile. If all gems are found, Bundler prints a success message and exits with
-a status of 0.
-
-If not, the first missing gem is listed and Bundler exits status 1.
-
-## OPTIONS
-
-* `--dry-run`:
- Locks the [`Gemfile(5)`][Gemfile(5)] before running the command.
-* `--gemfile`:
- Use the specified gemfile instead of the [`Gemfile(5)`][Gemfile(5)].
-* `--path`:
- Specify a different path than the system default (`$BUNDLE_PATH` or `$GEM_HOME`).
- Bundler will remember this value for future installs on this machine.
diff --git a/man/bundle-clean.1 b/man/bundle-clean.1
deleted file mode 100644
index cc5c8e86d7..0000000000
--- a/man/bundle-clean.1
+++ /dev/null
@@ -1,24 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CLEAN" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory
-.
-.SH "SYNOPSIS"
-\fBbundle clean\fR [\-\-dry\-run] [\-\-force]
-.
-.SH "DESCRIPTION"
-This command will remove all unused gems in your bundler directory\. This is useful when you have made many changes to your gem dependencies\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-dry\-run\fR
-Print the changes, but do not clean the unused gems\.
-.
-.TP
-\fB\-\-force\fR
-Force a clean even if \fB\-\-path\fR is not set\.
-
diff --git a/man/bundle-clean.1.txt b/man/bundle-clean.1.txt
deleted file mode 100644
index 300d0c0b51..0000000000
--- a/man/bundle-clean.1.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-BUNDLE-CLEAN(1) BUNDLE-CLEAN(1)
-
-
-
-NAME
- bundle-clean - Cleans up unused gems in your bundler directory
-
-SYNOPSIS
- bundle clean [--dry-run] [--force]
-
-DESCRIPTION
- This command will remove all unused gems in your bundler directory.
- This is useful when you have made many changes to your gem dependen-
- cies.
-
-OPTIONS
- --dry-run
- Print the changes, but do not clean the unused gems.
-
- --force
- Force a clean even if --path is not set.
-
-
-
-
- January 2020 BUNDLE-CLEAN(1)
diff --git a/man/bundle-clean.ronn b/man/bundle-clean.ronn
deleted file mode 100644
index de23991782..0000000000
--- a/man/bundle-clean.ronn
+++ /dev/null
@@ -1,18 +0,0 @@
-bundle-clean(1) -- Cleans up unused gems in your bundler directory
-==================================================================
-
-## SYNOPSIS
-
-`bundle clean` [--dry-run] [--force]
-
-## DESCRIPTION
-
-This command will remove all unused gems in your bundler directory. This is
-useful when you have made many changes to your gem dependencies.
-
-## OPTIONS
-
-* `--dry-run`:
- Print the changes, but do not clean the unused gems.
-* `--force`:
- Force a clean even if `--path` is not set.
diff --git a/man/bundle-config.1 b/man/bundle-config.1
deleted file mode 100644
index c3464fb2ec..0000000000
--- a/man/bundle-config.1
+++ /dev/null
@@ -1,497 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CONFIG" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-config\fR \- Set bundler configuration options
-.
-.SH "SYNOPSIS"
-\fBbundle config\fR [list|get|set|unset] [\fIname\fR [\fIvalue\fR]]
-.
-.SH "DESCRIPTION"
-This command allows you to interact with Bundler\'s configuration system\.
-.
-.P
-Bundler loads configuration settings in this order:
-.
-.IP "1." 4
-Local config (\fBapp/\.bundle/config\fR)
-.
-.IP "2." 4
-Environmental variables (\fBENV\fR)
-.
-.IP "3." 4
-Global config (\fB~/\.bundle/config\fR)
-.
-.IP "4." 4
-Bundler default config
-.
-.IP "" 0
-.
-.P
-Executing \fBbundle config list\fR with will print a list of all bundler configuration for the current bundle, and where that configuration was set\.
-.
-.P
-Executing \fBbundle config get <name>\fR will print the value of that configuration setting, and where it was set\.
-.
-.P
-Executing \fBbundle config set <name> <value>\fR will set that configuration to the value specified for all bundles executed as the current user\. The configuration will be stored in \fB~/\.bundle/config\fR\. If \fIname\fR already is set, \fIname\fR will be overridden and user will be warned\.
-.
-.P
-Executing \fBbundle config set \-\-global <name> <value>\fR works the same as above\.
-.
-.P
-Executing \fBbundle config set \-\-local <name> <value>\fR will set that configuration to the local application\. The configuration will be stored in \fBapp/\.bundle/config\fR\.
-.
-.P
-Executing \fBbundle config unset <name>\fR will delete the configuration in both local and global sources\.
-.
-.P
-Executing \fBbundle config unset \-\-global <name>\fR will delete the configuration only from the user configuration\.
-.
-.P
-Executing \fBbundle config unset \-\-local <name> <value>\fR will delete the configuration only from the local application\.
-.
-.P
-Executing bundle with the \fBBUNDLE_IGNORE_CONFIG\fR environment variable set will cause it to ignore all configuration\.
-.
-.P
-Executing \fBbundle config set disable_multisource true\fR upgrades the warning about the Gemfile containing multiple primary sources to an error\. Executing \fBbundle config unset disable_multisource\fR downgrades this error to a warning\.
-.
-.SH "REMEMBERING OPTIONS"
-Flags passed to \fBbundle install\fR or the Bundler runtime, such as \fB\-\-path foo\fR or \fB\-\-without production\fR, are remembered between commands and saved to your local application\'s configuration (normally, \fB\./\.bundle/config\fR)\.
-.
-.P
-However, this will be changed in bundler 3, so it\'s better not to rely on this behavior\. If these options must be remembered, it\'s better to set them using \fBbundle config\fR (e\.g\., \fBbundle config set path foo\fR)\.
-.
-.P
-The options that can be configured are:
-.
-.TP
-\fBbin\fR
-Creates a directory (defaults to \fB~/bin\fR) and place any executables from the gem there\. These executables run in Bundler\'s context\. If used, you might add this directory to your environment\'s \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
-.
-.TP
-\fBdeployment\fR
-In deployment mode, Bundler will \'roll\-out\' the bundle for \fBproduction\fR use\. Please check carefully if you want to have this option enabled in \fBdevelopment\fR or \fBtest\fR environments\.
-.
-.TP
-\fBpath\fR
-The location to install the specified gems to\. This defaults to Rubygems\' setting\. Bundler shares this location with Rubygems, \fBgem install \.\.\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \.\.\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
-.
-.TP
-\fBwithout\fR
-A space\-separated list of groups referencing gems to skip during installation\.
-.
-.TP
-\fBwith\fR
-A space\-separated list of groups referencing gems to include during installation\.
-.
-.SH "BUILD OPTIONS"
-You can use \fBbundle config\fR to give Bundler the flags to pass to the gem installer every time bundler tries to install a particular gem\.
-.
-.P
-A very common example, the \fBmysql\fR gem, requires Snow Leopard users to pass configuration flags to \fBgem install\fR to specify where to find the \fBmysql_config\fR executable\.
-.
-.IP "" 4
-.
-.nf
-
-gem install mysql \-\- \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Since the specific location of that executable can change from machine to machine, you can specify these flags on a per\-machine basis\.
-.
-.IP "" 4
-.
-.nf
-
-bundle config set build\.mysql \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
-.
-.fi
-.
-.IP "" 0
-.
-.P
-After running this command, every time bundler needs to install the \fBmysql\fR gem, it will pass along the flags you specified\.
-.
-.SH "CONFIGURATION KEYS"
-Configuration keys in bundler have two forms: the canonical form and the environment variable form\.
-.
-.P
-For instance, passing the \fB\-\-without\fR flag to bundle install(1) \fIbundle\-install\.1\.html\fR prevents Bundler from installing certain groups specified in the Gemfile(5)\. Bundler persists this value in \fBapp/\.bundle/config\fR so that calls to \fBBundler\.setup\fR do not try to find gems from the \fBGemfile\fR that you didn\'t install\. Additionally, subsequent calls to bundle install(1) \fIbundle\-install\.1\.html\fR remember this setting and skip those groups\.
-.
-.P
-The canonical form of this configuration is \fB"without"\fR\. To convert the canonical form to the environment variable form, capitalize it, and prepend \fBBUNDLE_\fR\. The environment variable form of \fB"without"\fR is \fBBUNDLE_WITHOUT\fR\.
-.
-.P
-Any periods in the configuration keys must be replaced with two underscores when setting it via environment variables\. The configuration key \fBlocal\.rack\fR becomes the environment variable \fBBUNDLE_LOCAL__RACK\fR\.
-.
-.SH "LIST OF AVAILABLE KEYS"
-The following is a list of all configuration keys and their purpose\. You can learn more about their operation in bundle install(1) \fIbundle\-install\.1\.html\fR\.
-.
-.IP "\(bu" 4
-\fBallow_bundler_dependency_conflicts\fR (\fBBUNDLE_ALLOW_BUNDLER_DEPENDENCY_CONFLICTS\fR): Allow resolving to specifications that have dependencies on \fBbundler\fR that are incompatible with the running Bundler version\.
-.
-.IP "\(bu" 4
-\fBallow_deployment_source_credential_changes\fR (\fBBUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES\fR): When in deployment mode, allow changing the credentials to a gem\'s source\. Ex: \fBhttps://some\.host\.com/gems/path/\fR \-> \fBhttps://user_name:password@some\.host\.com/gems/path\fR
-.
-.IP "\(bu" 4
-\fBallow_offline_install\fR (\fBBUNDLE_ALLOW_OFFLINE_INSTALL\fR): Allow Bundler to use cached data when installing without network access\.
-.
-.IP "\(bu" 4
-\fBauto_clean_without_path\fR (\fBBUNDLE_AUTO_CLEAN_WITHOUT_PATH\fR): Automatically run \fBbundle clean\fR after installing when an explicit \fBpath\fR has not been set and Bundler is not installing into the system gems\.
-.
-.IP "\(bu" 4
-\fBauto_install\fR (\fBBUNDLE_AUTO_INSTALL\fR): Automatically run \fBbundle install\fR when gems are missing\.
-.
-.IP "\(bu" 4
-\fBbin\fR (\fBBUNDLE_BIN\fR): Install executables from gems in the bundle to the specified directory\. Defaults to \fBfalse\fR\.
-.
-.IP "\(bu" 4
-\fBcache_all\fR (\fBBUNDLE_CACHE_ALL\fR): Cache all gems, including path and git gems\.
-.
-.IP "\(bu" 4
-\fBcache_all_platforms\fR (\fBBUNDLE_CACHE_ALL_PLATFORMS\fR): Cache gems for all platforms\.
-.
-.IP "\(bu" 4
-\fBcache_path\fR (\fBBUNDLE_CACHE_PATH\fR): The directory that bundler will place cached gems in when running \fBbundle package\fR, and that bundler will look in when installing gems\. Defaults to \fBvendor/cache\fR\.
-.
-.IP "\(bu" 4
-\fBclean\fR (\fBBUNDLE_CLEAN\fR): Whether Bundler should run \fBbundle clean\fR automatically after \fBbundle install\fR\.
-.
-.IP "\(bu" 4
-\fBconsole\fR (\fBBUNDLE_CONSOLE\fR): The console that \fBbundle console\fR starts\. Defaults to \fBirb\fR\.
-.
-.IP "\(bu" 4
-\fBdefault_install_uses_path\fR (\fBBUNDLE_DEFAULT_INSTALL_USES_PATH\fR): Whether a \fBbundle install\fR without an explicit \fB\-\-path\fR argument defaults to installing gems in \fB\.bundle\fR\.
-.
-.IP "\(bu" 4
-\fBdeployment\fR (\fBBUNDLE_DEPLOYMENT\fR): Disallow changes to the \fBGemfile\fR\. When the \fBGemfile\fR is changed and the lockfile has not been updated, running Bundler commands will be blocked\.
-.
-.IP "\(bu" 4
-\fBdisable_checksum_validation\fR (\fBBUNDLE_DISABLE_CHECKSUM_VALIDATION\fR): Allow installing gems even if they do not match the checksum provided by RubyGems\.
-.
-.IP "\(bu" 4
-\fBdisable_exec_load\fR (\fBBUNDLE_DISABLE_EXEC_LOAD\fR): Stop Bundler from using \fBload\fR to launch an executable in\-process in \fBbundle exec\fR\.
-.
-.IP "\(bu" 4
-\fBdisable_local_branch_check\fR (\fBBUNDLE_DISABLE_LOCAL_BRANCH_CHECK\fR): Allow Bundler to use a local git override without a branch specified in the Gemfile\.
-.
-.IP "\(bu" 4
-\fBdisable_multisource\fR (\fBBUNDLE_DISABLE_MULTISOURCE\fR): When set, Gemfiles containing multiple sources will produce errors instead of warnings\. Use \fBbundle config unset disable_multisource\fR to unset\.
-.
-.IP "\(bu" 4
-\fBdisable_platform_warnings\fR (\fBBUNDLE_DISABLE_PLATFORM_WARNINGS\fR): Disable warnings during bundle install when a dependency is unused on the current platform\.
-.
-.IP "\(bu" 4
-\fBdisable_shared_gems\fR (\fBBUNDLE_DISABLE_SHARED_GEMS\fR): Stop Bundler from accessing gems installed to RubyGems\' normal location\.
-.
-.IP "\(bu" 4
-\fBdisable_version_check\fR (\fBBUNDLE_DISABLE_VERSION_CHECK\fR): Stop Bundler from checking if a newer Bundler version is available on rubygems\.org\.
-.
-.IP "\(bu" 4
-\fBforce_ruby_platform\fR (\fBBUNDLE_FORCE_RUBY_PLATFORM\fR): Ignore the current machine\'s platform and install only \fBruby\fR platform gems\. As a result, gems with native extensions will be compiled from source\.
-.
-.IP "\(bu" 4
-\fBfrozen\fR (\fBBUNDLE_FROZEN\fR): Disallow changes to the \fBGemfile\fR\. When the \fBGemfile\fR is changed and the lockfile has not been updated, running Bundler commands will be blocked\. Defaults to \fBtrue\fR when \fB\-\-deployment\fR is used\.
-.
-.IP "\(bu" 4
-\fBgem\.push_key\fR (\fBBUNDLE_GEM__PUSH_KEY\fR): Sets the \fB\-\-key\fR parameter for \fBgem push\fR when using the \fBrake release\fR command with a private gemstash server\.
-.
-.IP "\(bu" 4
-\fBgemfile\fR (\fBBUNDLE_GEMFILE\fR): The name of the file that bundler should use as the \fBGemfile\fR\. This location of this file also sets the root of the project, which is used to resolve relative paths in the \fBGemfile\fR, among other things\. By default, bundler will search up from the current working directory until it finds a \fBGemfile\fR\.
-.
-.IP "\(bu" 4
-\fBglobal_gem_cache\fR (\fBBUNDLE_GLOBAL_GEM_CACHE\fR): Whether Bundler should cache all gems globally, rather than locally to the installing Ruby installation\.
-.
-.IP "\(bu" 4
-\fBignore_messages\fR (\fBBUNDLE_IGNORE_MESSAGES\fR): When set, no post install messages will be printed\. To silence a single gem, use dot notation like \fBignore_messages\.httparty true\fR\.
-.
-.IP "\(bu" 4
-\fBinit_gems_rb\fR (\fBBUNDLE_INIT_GEMS_RB\fR) Generate a \fBgems\.rb\fR instead of a \fBGemfile\fR when running \fBbundle init\fR\.
-.
-.IP "\(bu" 4
-\fBjobs\fR (\fBBUNDLE_JOBS\fR): The number of gems Bundler can install in parallel\. Defaults to 1\.
-.
-.IP "\(bu" 4
-\fBno_install\fR (\fBBUNDLE_NO_INSTALL\fR): Whether \fBbundle package\fR should skip installing gems\.
-.
-.IP "\(bu" 4
-\fBno_prune\fR (\fBBUNDLE_NO_PRUNE\fR): Whether Bundler should leave outdated gems unpruned when caching\.
-.
-.IP "\(bu" 4
-\fBonly_update_to_newer_versions\fR (\fBBUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS\fR): During \fBbundle update\fR, only resolve to newer versions of the gems in the lockfile\.
-.
-.IP "\(bu" 4
-\fBpath\fR (\fBBUNDLE_PATH\fR): The location on disk where all gems in your bundle will be located regardless of \fB$GEM_HOME\fR or \fB$GEM_PATH\fR values\. Bundle gems not found in this location will be installed by \fBbundle install\fR\. Defaults to \fBGem\.dir\fR\. When \-\-deployment is used, defaults to vendor/bundle\.
-.
-.IP "\(bu" 4
-\fBpath\.system\fR (\fBBUNDLE_PATH__SYSTEM\fR): Whether Bundler will install gems into the default system path (\fBGem\.dir\fR)\.
-.
-.IP "\(bu" 4
-\fBpath_relative_to_cwd\fR (\fBBUNDLE_PATH_RELATIVE_TO_CWD\fR) Makes \fB\-\-path\fR relative to the CWD instead of the \fBGemfile\fR\.
-.
-.IP "\(bu" 4
-\fBplugins\fR (\fBBUNDLE_PLUGINS\fR): Enable Bundler\'s experimental plugin system\.
-.
-.IP "\(bu" 4
-\fBprefer_patch\fR (BUNDLE_PREFER_PATCH): Prefer updating only to next patch version during updates\. Makes \fBbundle update\fR calls equivalent to \fBbundler update \-\-patch\fR\.
-.
-.IP "\(bu" 4
-\fBprint_only_version_number\fR (\fBBUNDLE_PRINT_ONLY_VERSION_NUMBER\fR) Print only version number from \fBbundler \-\-version\fR\.
-.
-.IP "\(bu" 4
-\fBredirect\fR (\fBBUNDLE_REDIRECT\fR): The number of redirects allowed for network requests\. Defaults to \fB5\fR\.
-.
-.IP "\(bu" 4
-\fBretry\fR (\fBBUNDLE_RETRY\fR): The number of times to retry failed network requests\. Defaults to \fB3\fR\.
-.
-.IP "\(bu" 4
-\fBsetup_makes_kernel_gem_public\fR (\fBBUNDLE_SETUP_MAKES_KERNEL_GEM_PUBLIC\fR): Have \fBBundler\.setup\fR make the \fBKernel#gem\fR method public, even though RubyGems declares it as private\.
-.
-.IP "\(bu" 4
-\fBshebang\fR (\fBBUNDLE_SHEBANG\fR): The program name that should be invoked for generated binstubs\. Defaults to the ruby install name used to generate the binstub\.
-.
-.IP "\(bu" 4
-\fBsilence_deprecations\fR (\fBBUNDLE_SILENCE_DEPRECATIONS\fR): Whether Bundler should silence deprecation warnings for behavior that will be changed in the next major version\.
-.
-.IP "\(bu" 4
-\fBsilence_root_warning\fR (\fBBUNDLE_SILENCE_ROOT_WARNING\fR): Silence the warning Bundler prints when installing gems as root\.
-.
-.IP "\(bu" 4
-\fBskip_default_git_sources\fR (\fBBUNDLE_SKIP_DEFAULT_GIT_SOURCES\fR): Whether Bundler should skip adding default git source shortcuts to the Gemfile DSL\.
-.
-.IP "\(bu" 4
-\fBspecific_platform\fR (\fBBUNDLE_SPECIFIC_PLATFORM\fR): Allow bundler to resolve for the specific running platform and store it in the lockfile, instead of only using a generic platform\. A specific platform is the exact platform triple reported by \fBGem::Platform\.local\fR, such as \fBx86_64\-darwin\-16\fR or \fBuniversal\-java\-1\.8\fR\. On the other hand, generic platforms are those such as \fBruby\fR, \fBmswin\fR, or \fBjava\fR\. In this example, \fBx86_64\-darwin\-16\fR would map to \fBruby\fR and \fBuniversal\-java\-1\.8\fR to \fBjava\fR\.
-.
-.IP "\(bu" 4
-\fBssl_ca_cert\fR (\fBBUNDLE_SSL_CA_CERT\fR): Path to a designated CA certificate file or folder containing multiple certificates for trusted CAs in PEM format\.
-.
-.IP "\(bu" 4
-\fBssl_client_cert\fR (\fBBUNDLE_SSL_CLIENT_CERT\fR): Path to a designated file containing a X\.509 client certificate and key in PEM format\.
-.
-.IP "\(bu" 4
-\fBssl_verify_mode\fR (\fBBUNDLE_SSL_VERIFY_MODE\fR): The SSL verification mode Bundler uses when making HTTPS requests\. Defaults to verify peer\.
-.
-.IP "\(bu" 4
-\fBsuppress_install_using_messages\fR (\fBBUNDLE_SUPPRESS_INSTALL_USING_MESSAGES\fR): Avoid printing \fBUsing \.\.\.\fR messages during installation when the version of a gem has not changed\.
-.
-.IP "\(bu" 4
-\fBsystem_bindir\fR (\fBBUNDLE_SYSTEM_BINDIR\fR): The location where RubyGems installs binstubs\. Defaults to \fBGem\.bindir\fR\.
-.
-.IP "\(bu" 4
-\fBtimeout\fR (\fBBUNDLE_TIMEOUT\fR): The seconds allowed before timing out for network requests\. Defaults to \fB10\fR\.
-.
-.IP "\(bu" 4
-\fBunlock_source_unlocks_spec\fR (\fBBUNDLE_UNLOCK_SOURCE_UNLOCKS_SPEC\fR): Whether running \fBbundle update \-\-source NAME\fR unlocks a gem with the given name\. Defaults to \fBtrue\fR\.
-.
-.IP "\(bu" 4
-\fBupdate_requires_all_flag\fR (\fBBUNDLE_UPDATE_REQUIRES_ALL_FLAG\fR) Require passing \fB\-\-all\fR to \fBbundle update\fR when everything should be updated, and disallow passing no options to \fBbundle update\fR\.
-.
-.IP "\(bu" 4
-\fBuser_agent\fR (\fBBUNDLE_USER_AGENT\fR): The custom user agent fragment Bundler includes in API requests\.
-.
-.IP "\(bu" 4
-\fBwith\fR (\fBBUNDLE_WITH\fR): A \fB:\fR\-separated list of groups whose gems bundler should install\.
-.
-.IP "\(bu" 4
-\fBwithout\fR (\fBBUNDLE_WITHOUT\fR): A \fB:\fR\-separated list of groups whose gems bundler should not install\.
-.
-.IP "" 0
-.
-.P
-In general, you should set these settings per\-application by using the applicable flag to the bundle install(1) \fIbundle\-install\.1\.html\fR or bundle package(1) \fIbundle\-package\.1\.html\fR command\.
-.
-.P
-You can set them globally either via environment variables or \fBbundle config\fR, whichever is preferable for your setup\. If you use both, environment variables will take preference over global settings\.
-.
-.SH "LOCAL GIT REPOS"
-Bundler also allows you to work against a git repository locally instead of using the remote version\. This can be achieved by setting up a local override:
-.
-.IP "" 4
-.
-.nf
-
-bundle config set local\.GEM_NAME /path/to/local/git/repository
-.
-.fi
-.
-.IP "" 0
-.
-.P
-For example, in order to use a local Rack repository, a developer could call:
-.
-.IP "" 4
-.
-.nf
-
-bundle config set local\.rack ~/Work/git/rack
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Now instead of checking out the remote git repository, the local override will be used\. Similar to a path source, every time the local git repository change, changes will be automatically picked up by Bundler\. This means a commit in the local git repo will update the revision in the \fBGemfile\.lock\fR to the local git repo revision\. This requires the same attention as git submodules\. Before pushing to the remote, you need to ensure the local override was pushed, otherwise you may point to a commit that only exists in your local machine\. You\'ll also need to CGI escape your usernames and passwords as well\.
-.
-.P
-Bundler does many checks to ensure a developer won\'t work with invalid references\. Particularly, we force a developer to specify a branch in the \fBGemfile\fR in order to use this feature\. If the branch specified in the \fBGemfile\fR and the current branch in the local git repository do not match, Bundler will abort\. This ensures that a developer is always working against the correct branches, and prevents accidental locking to a different branch\.
-.
-.P
-Finally, Bundler also ensures that the current revision in the \fBGemfile\.lock\fR exists in the local git repository\. By doing this, Bundler forces you to fetch the latest changes in the remotes\.
-.
-.SH "MIRRORS OF GEM SOURCES"
-Bundler supports overriding gem sources with mirrors\. This allows you to configure rubygems\.org as the gem source in your Gemfile while still using your mirror to fetch gems\.
-.
-.IP "" 4
-.
-.nf
-
-bundle config set mirror\.SOURCE_URL MIRROR_URL
-.
-.fi
-.
-.IP "" 0
-.
-.P
-For example, to use a mirror of rubygems\.org hosted at rubygems\-mirror\.org:
-.
-.IP "" 4
-.
-.nf
-
-bundle config set mirror\.http://rubygems\.org http://rubygems\-mirror\.org
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Each mirror also provides a fallback timeout setting\. If the mirror does not respond within the fallback timeout, Bundler will try to use the original server instead of the mirror\.
-.
-.IP "" 4
-.
-.nf
-
-bundle config set mirror\.SOURCE_URL\.fallback_timeout TIMEOUT
-.
-.fi
-.
-.IP "" 0
-.
-.P
-For example, to fall back to rubygems\.org after 3 seconds:
-.
-.IP "" 4
-.
-.nf
-
-bundle config set mirror\.https://rubygems\.org\.fallback_timeout 3
-.
-.fi
-.
-.IP "" 0
-.
-.P
-The default fallback timeout is 0\.1 seconds, but the setting can currently only accept whole seconds (for example, 1, 15, or 30)\.
-.
-.SH "CREDENTIALS FOR GEM SOURCES"
-Bundler allows you to configure credentials for any gem source, which allows you to avoid putting secrets into your Gemfile\.
-.
-.IP "" 4
-.
-.nf
-
-bundle config set SOURCE_HOSTNAME USERNAME:PASSWORD
-.
-.fi
-.
-.IP "" 0
-.
-.P
-For example, to save the credentials of user \fBclaudette\fR for the gem source at \fBgems\.longerous\.com\fR, you would run:
-.
-.IP "" 4
-.
-.nf
-
-bundle config set gems\.longerous\.com claudette:s00pers3krit
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Or you can set the credentials as an environment variable like this:
-.
-.IP "" 4
-.
-.nf
-
-export BUNDLE_GEMS__LONGEROUS__COM="claudette:s00pers3krit"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-For gems with a git source with HTTP(S) URL you can specify credentials like so:
-.
-.IP "" 4
-.
-.nf
-
-bundle config set https://github\.com/bundler/bundler\.git username:password
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Or you can set the credentials as an environment variable like so:
-.
-.IP "" 4
-.
-.nf
-
-export BUNDLE_GITHUB__COM=username:password
-.
-.fi
-.
-.IP "" 0
-.
-.P
-This is especially useful for private repositories on hosts such as Github, where you can use personal OAuth tokens:
-.
-.IP "" 4
-.
-.nf
-
-export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x\-oauth\-basic
-.
-.fi
-.
-.IP "" 0
-.
-.SH "CONFIGURE BUNDLER DIRECTORIES"
-Bundler\'s home, config, cache and plugin directories are able to be configured through environment variables\. The default location for Bundler\'s home directory is \fB~/\.bundle\fR, which all directories inherit from by default\. The following outlines the available environment variables and their default values
-.
-.IP "" 4
-.
-.nf
-
-BUNDLE_USER_HOME : $HOME/\.bundle
-BUNDLE_USER_CACHE : $BUNDLE_USER_HOME/cache
-BUNDLE_USER_CONFIG : $BUNDLE_USER_HOME/config
-BUNDLE_USER_PLUGIN : $BUNDLE_USER_HOME/plugin
-.
-.fi
-.
-.IP "" 0
-
diff --git a/man/bundle-config.1.txt b/man/bundle-config.1.txt
deleted file mode 100644
index f5fc0ce12a..0000000000
--- a/man/bundle-config.1.txt
+++ /dev/null
@@ -1,528 +0,0 @@
-BUNDLE-CONFIG(1) BUNDLE-CONFIG(1)
-
-
-
-NAME
- bundle-config - Set bundler configuration options
-
-SYNOPSIS
- bundle config [list|get|set|unset] [name [value]]
-
-DESCRIPTION
- This command allows you to interact with Bundler's configuration sys-
- tem.
-
- Bundler loads configuration settings in this order:
-
- 1. Local config (app/.bundle/config)
-
- 2. Environmental variables (ENV)
-
- 3. Global config (~/.bundle/config)
-
- 4. Bundler default config
-
-
-
- Executing bundle config list with will print a list of all bundler con-
- figuration for the current bundle, and where that configuration was
- set.
-
- Executing bundle config get <name> will print the value of that config-
- uration setting, and where it was set.
-
- Executing bundle config set <name> <value> will set that configuration
- to the value specified for all bundles executed as the current user.
- The configuration will be stored in ~/.bundle/config. If name already
- is set, name will be overridden and user will be warned.
-
- Executing bundle config set --global <name> <value> works the same as
- above.
-
- Executing bundle config set --local <name> <value> will set that con-
- figuration to the local application. The configuration will be stored
- in app/.bundle/config.
-
- Executing bundle config unset <name> will delete the configuration in
- both local and global sources.
-
- Executing bundle config unset --global <name> will delete the configu-
- ration only from the user configuration.
-
- Executing bundle config unset --local <name> <value> will delete the
- configuration only from the local application.
-
- Executing bundle with the BUNDLE_IGNORE_CONFIG environment variable set
- will cause it to ignore all configuration.
-
- Executing bundle config set disable_multisource true upgrades the warn-
- ing about the Gemfile containing multiple primary sources to an error.
- Executing bundle config unset disable_multisource downgrades this error
- to a warning.
-
-REMEMBERING OPTIONS
- Flags passed to bundle install or the Bundler runtime, such as --path
- foo or --without production, are remembered between commands and saved
- to your local application's configuration (normally, ./.bundle/config).
-
- However, this will be changed in bundler 3, so it's better not to rely
- on this behavior. If these options must be remembered, it's better to
- set them using bundle config (e.g., bundle config set path foo).
-
- The options that can be configured are:
-
- bin Creates a directory (defaults to ~/bin) and place any executa-
- bles from the gem there. These executables run in Bundler's con-
- text. If used, you might add this directory to your environ-
- ment's PATH variable. For instance, if the rails gem comes with
- a rails executable, this flag will create a bin/rails executable
- that ensures that all referred dependencies will be resolved
- using the bundled gems.
-
- deployment
- In deployment mode, Bundler will 'roll-out' the bundle for pro-
- duction use. Please check carefully if you want to have this
- option enabled in development or test environments.
-
- path The location to install the specified gems to. This defaults to
- Rubygems' setting. Bundler shares this location with Rubygems,
- gem install ... will have gem installed there, too. Therefore,
- gems installed without a --path ... setting will show up by
- calling gem list. Accordingly, gems installed to other locations
- will not get listed.
-
- without
- A space-separated list of groups referencing gems to skip during
- installation.
-
- with A space-separated list of groups referencing gems to include
- during installation.
-
-BUILD OPTIONS
- You can use bundle config to give Bundler the flags to pass to the gem
- installer every time bundler tries to install a particular gem.
-
- A very common example, the mysql gem, requires Snow Leopard users to
- pass configuration flags to gem install to specify where to find the
- mysql_config executable.
-
-
-
- gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
-
-
-
- Since the specific location of that executable can change from machine
- to machine, you can specify these flags on a per-machine basis.
-
-
-
- bundle config set build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
-
-
-
- After running this command, every time bundler needs to install the
- mysql gem, it will pass along the flags you specified.
-
-CONFIGURATION KEYS
- Configuration keys in bundler have two forms: the canonical form and
- the environment variable form.
-
- For instance, passing the --without flag to bundle install(1) bun-
- dle-install.1.html prevents Bundler from installing certain groups
- specified in the Gemfile(5). Bundler persists this value in app/.bun-
- dle/config so that calls to Bundler.setup do not try to find gems from
- the Gemfile that you didn't install. Additionally, subsequent calls to
- bundle install(1) bundle-install.1.html remember this setting and skip
- those groups.
-
- The canonical form of this configuration is "without". To convert the
- canonical form to the environment variable form, capitalize it, and
- prepend BUNDLE_. The environment variable form of "without" is BUN-
- DLE_WITHOUT.
-
- Any periods in the configuration keys must be replaced with two under-
- scores when setting it via environment variables. The configuration key
- local.rack becomes the environment variable BUNDLE_LOCAL__RACK.
-
-LIST OF AVAILABLE KEYS
- The following is a list of all configuration keys and their purpose.
- You can learn more about their operation in bundle install(1) bun-
- dle-install.1.html.
-
- o allow_bundler_dependency_conflicts (BUNDLE_ALLOW_BUNDLER_DEPEN-
- DENCY_CONFLICTS): Allow resolving to specifications that have
- dependencies on bundler that are incompatible with the running
- Bundler version.
-
- o allow_deployment_source_credential_changes (BUNDLE_ALLOW_DEPLOY-
- MENT_SOURCE_CREDENTIAL_CHANGES): When in deployment mode, allow
- changing the credentials to a gem's source. Ex:
- https://some.host.com/gems/path/ -> https://user_name:pass-
- word@some.host.com/gems/path
-
- o allow_offline_install (BUNDLE_ALLOW_OFFLINE_INSTALL): Allow Bundler
- to use cached data when installing without network access.
-
- o auto_clean_without_path (BUNDLE_AUTO_CLEAN_WITHOUT_PATH): Automati-
- cally run bundle clean after installing when an explicit path has
- not been set and Bundler is not installing into the system gems.
-
- o auto_install (BUNDLE_AUTO_INSTALL): Automatically run bundle
- install when gems are missing.
-
- o bin (BUNDLE_BIN): Install executables from gems in the bundle to
- the specified directory. Defaults to false.
-
- o cache_all (BUNDLE_CACHE_ALL): Cache all gems, including path and
- git gems.
-
- o cache_all_platforms (BUNDLE_CACHE_ALL_PLATFORMS): Cache gems for
- all platforms.
-
- o cache_path (BUNDLE_CACHE_PATH): The directory that bundler will
- place cached gems in when running bundle package, and that bundler
- will look in when installing gems. Defaults to vendor/cache.
-
- o clean (BUNDLE_CLEAN): Whether Bundler should run bundle clean auto-
- matically after bundle install.
-
- o console (BUNDLE_CONSOLE): The console that bundle console starts.
- Defaults to irb.
-
- o default_install_uses_path (BUNDLE_DEFAULT_INSTALL_USES_PATH):
- Whether a bundle install without an explicit --path argument
- defaults to installing gems in .bundle.
-
- o deployment (BUNDLE_DEPLOYMENT): Disallow changes to the Gemfile.
- When the Gemfile is changed and the lockfile has not been updated,
- running Bundler commands will be blocked.
-
- o disable_checksum_validation (BUNDLE_DISABLE_CHECKSUM_VALIDATION):
- Allow installing gems even if they do not match the checksum pro-
- vided by RubyGems.
-
- o disable_exec_load (BUNDLE_DISABLE_EXEC_LOAD): Stop Bundler from
- using load to launch an executable in-process in bundle exec.
-
- o disable_local_branch_check (BUNDLE_DISABLE_LOCAL_BRANCH_CHECK):
- Allow Bundler to use a local git override without a branch speci-
- fied in the Gemfile.
-
- o disable_multisource (BUNDLE_DISABLE_MULTISOURCE): When set, Gem-
- files containing multiple sources will produce errors instead of
- warnings. Use bundle config unset disable_multisource to unset.
-
- o disable_platform_warnings (BUNDLE_DISABLE_PLATFORM_WARNINGS): Dis-
- able warnings during bundle install when a dependency is unused on
- the current platform.
-
- o disable_shared_gems (BUNDLE_DISABLE_SHARED_GEMS): Stop Bundler from
- accessing gems installed to RubyGems' normal location.
-
- o disable_version_check (BUNDLE_DISABLE_VERSION_CHECK): Stop Bundler
- from checking if a newer Bundler version is available on
- rubygems.org.
-
- o force_ruby_platform (BUNDLE_FORCE_RUBY_PLATFORM): Ignore the cur-
- rent machine's platform and install only ruby platform gems. As a
- result, gems with native extensions will be compiled from source.
-
- o frozen (BUNDLE_FROZEN): Disallow changes to the Gemfile. When the
- Gemfile is changed and the lockfile has not been updated, running
- Bundler commands will be blocked. Defaults to true when --deploy-
- ment is used.
-
- o gem.push_key (BUNDLE_GEM__PUSH_KEY): Sets the --key parameter for
- gem push when using the rake release command with a private gem-
- stash server.
-
- o gemfile (BUNDLE_GEMFILE): The name of the file that bundler should
- use as the Gemfile. This location of this file also sets the root
- of the project, which is used to resolve relative paths in the Gem-
- file, among other things. By default, bundler will search up from
- the current working directory until it finds a Gemfile.
-
- o global_gem_cache (BUNDLE_GLOBAL_GEM_CACHE): Whether Bundler should
- cache all gems globally, rather than locally to the installing Ruby
- installation.
-
- o ignore_messages (BUNDLE_IGNORE_MESSAGES): When set, no post install
- messages will be printed. To silence a single gem, use dot notation
- like ignore_messages.httparty true.
-
- o init_gems_rb (BUNDLE_INIT_GEMS_RB) Generate a gems.rb instead of a
- Gemfile when running bundle init.
-
- o jobs (BUNDLE_JOBS): The number of gems Bundler can install in par-
- allel. Defaults to 1.
-
- o no_install (BUNDLE_NO_INSTALL): Whether bundle package should skip
- installing gems.
-
- o no_prune (BUNDLE_NO_PRUNE): Whether Bundler should leave outdated
- gems unpruned when caching.
-
- o only_update_to_newer_versions (BUNDLE_ONLY_UPDATE_TO_NEWER_VER-
- SIONS): During bundle update, only resolve to newer versions of the
- gems in the lockfile.
-
- o path (BUNDLE_PATH): The location on disk where all gems in your
- bundle will be located regardless of $GEM_HOME or $GEM_PATH values.
- Bundle gems not found in this location will be installed by bundle
- install. Defaults to Gem.dir. When --deployment is used, defaults
- to vendor/bundle.
-
- o path.system (BUNDLE_PATH__SYSTEM): Whether Bundler will install
- gems into the default system path (Gem.dir).
-
- o path_relative_to_cwd (BUNDLE_PATH_RELATIVE_TO_CWD) Makes --path
- relative to the CWD instead of the Gemfile.
-
- o plugins (BUNDLE_PLUGINS): Enable Bundler's experimental plugin sys-
- tem.
-
- o prefer_patch (BUNDLE_PREFER_PATCH): Prefer updating only to next
- patch version during updates. Makes bundle update calls equivalent
- to bundler update --patch.
-
- o print_only_version_number (BUNDLE_PRINT_ONLY_VERSION_NUMBER) Print
- only version number from bundler --version.
-
- o redirect (BUNDLE_REDIRECT): The number of redirects allowed for
- network requests. Defaults to 5.
-
- o retry (BUNDLE_RETRY): The number of times to retry failed network
- requests. Defaults to 3.
-
- o setup_makes_kernel_gem_public (BUNDLE_SETUP_MAKES_KERNEL_GEM_PUB-
- LIC): Have Bundler.setup make the Kernel#gem method public, even
- though RubyGems declares it as private.
-
- o shebang (BUNDLE_SHEBANG): The program name that should be invoked
- for generated binstubs. Defaults to the ruby install name used to
- generate the binstub.
-
- o silence_deprecations (BUNDLE_SILENCE_DEPRECATIONS): Whether Bundler
- should silence deprecation warnings for behavior that will be
- changed in the next major version.
-
- o silence_root_warning (BUNDLE_SILENCE_ROOT_WARNING): Silence the
- warning Bundler prints when installing gems as root.
-
- o skip_default_git_sources (BUNDLE_SKIP_DEFAULT_GIT_SOURCES): Whether
- Bundler should skip adding default git source shortcuts to the Gem-
- file DSL.
-
- o specific_platform (BUNDLE_SPECIFIC_PLATFORM): Allow bundler to
- resolve for the specific running platform and store it in the lock-
- file, instead of only using a generic platform. A specific platform
- is the exact platform triple reported by Gem::Platform.local, such
- as x86_64-darwin-16 or universal-java-1.8. On the other hand,
- generic platforms are those such as ruby, mswin, or java. In this
- example, x86_64-darwin-16 would map to ruby and universal-java-1.8
- to java.
-
- o ssl_ca_cert (BUNDLE_SSL_CA_CERT): Path to a designated CA certifi-
- cate file or folder containing multiple certificates for trusted
- CAs in PEM format.
-
- o ssl_client_cert (BUNDLE_SSL_CLIENT_CERT): Path to a designated file
- containing a X.509 client certificate and key in PEM format.
-
- o ssl_verify_mode (BUNDLE_SSL_VERIFY_MODE): The SSL verification mode
- Bundler uses when making HTTPS requests. Defaults to verify peer.
-
- o suppress_install_using_messages (BUNDLE_SUPPRESS_INSTALL_USING_MES-
- SAGES): Avoid printing Using ... messages during installation when
- the version of a gem has not changed.
-
- o system_bindir (BUNDLE_SYSTEM_BINDIR): The location where RubyGems
- installs binstubs. Defaults to Gem.bindir.
-
- o timeout (BUNDLE_TIMEOUT): The seconds allowed before timing out for
- network requests. Defaults to 10.
-
- o unlock_source_unlocks_spec (BUNDLE_UNLOCK_SOURCE_UNLOCKS_SPEC):
- Whether running bundle update --source NAME unlocks a gem with the
- given name. Defaults to true.
-
- o update_requires_all_flag (BUNDLE_UPDATE_REQUIRES_ALL_FLAG) Require
- passing --all to bundle update when everything should be updated,
- and disallow passing no options to bundle update.
-
- o user_agent (BUNDLE_USER_AGENT): The custom user agent fragment
- Bundler includes in API requests.
-
- o with (BUNDLE_WITH): A :-separated list of groups whose gems bundler
- should install.
-
- o without (BUNDLE_WITHOUT): A :-separated list of groups whose gems
- bundler should not install.
-
-
-
- In general, you should set these settings per-application by using the
- applicable flag to the bundle install(1) bundle-install.1.html or bun-
- dle package(1) bundle-package.1.html command.
-
- You can set them globally either via environment variables or bundle
- config, whichever is preferable for your setup. If you use both, envi-
- ronment variables will take preference over global settings.
-
-LOCAL GIT REPOS
- Bundler also allows you to work against a git repository locally
- instead of using the remote version. This can be achieved by setting up
- a local override:
-
-
-
- bundle config set local.GEM_NAME /path/to/local/git/repository
-
-
-
- For example, in order to use a local Rack repository, a developer could
- call:
-
-
-
- bundle config set local.rack ~/Work/git/rack
-
-
-
- Now instead of checking out the remote git repository, the local over-
- ride will be used. Similar to a path source, every time the local git
- repository change, changes will be automatically picked up by Bundler.
- This means a commit in the local git repo will update the revision in
- the Gemfile.lock to the local git repo revision. This requires the same
- attention as git submodules. Before pushing to the remote, you need to
- ensure the local override was pushed, otherwise you may point to a com-
- mit that only exists in your local machine. You'll also need to CGI
- escape your usernames and passwords as well.
-
- Bundler does many checks to ensure a developer won't work with invalid
- references. Particularly, we force a developer to specify a branch in
- the Gemfile in order to use this feature. If the branch specified in
- the Gemfile and the current branch in the local git repository do not
- match, Bundler will abort. This ensures that a developer is always
- working against the correct branches, and prevents accidental locking
- to a different branch.
-
- Finally, Bundler also ensures that the current revision in the Gem-
- file.lock exists in the local git repository. By doing this, Bundler
- forces you to fetch the latest changes in the remotes.
-
-MIRRORS OF GEM SOURCES
- Bundler supports overriding gem sources with mirrors. This allows you
- to configure rubygems.org as the gem source in your Gemfile while still
- using your mirror to fetch gems.
-
-
-
- bundle config set mirror.SOURCE_URL MIRROR_URL
-
-
-
- For example, to use a mirror of rubygems.org hosted at rubygems-mir-
- ror.org:
-
-
-
- bundle config set mirror.http://rubygems.org http://rubygems-mirror.org
-
-
-
- Each mirror also provides a fallback timeout setting. If the mirror
- does not respond within the fallback timeout, Bundler will try to use
- the original server instead of the mirror.
-
-
-
- bundle config set mirror.SOURCE_URL.fallback_timeout TIMEOUT
-
-
-
- For example, to fall back to rubygems.org after 3 seconds:
-
-
-
- bundle config set mirror.https://rubygems.org.fallback_timeout 3
-
-
-
- The default fallback timeout is 0.1 seconds, but the setting can cur-
- rently only accept whole seconds (for example, 1, 15, or 30).
-
-CREDENTIALS FOR GEM SOURCES
- Bundler allows you to configure credentials for any gem source, which
- allows you to avoid putting secrets into your Gemfile.
-
-
-
- bundle config set SOURCE_HOSTNAME USERNAME:PASSWORD
-
-
-
- For example, to save the credentials of user claudette for the gem
- source at gems.longerous.com, you would run:
-
-
-
- bundle config set gems.longerous.com claudette:s00pers3krit
-
-
-
- Or you can set the credentials as an environment variable like this:
-
-
-
- export BUNDLE_GEMS__LONGEROUS__COM="claudette:s00pers3krit"
-
-
-
- For gems with a git source with HTTP(S) URL you can specify credentials
- like so:
-
-
-
- bundle config set https://github.com/bundler/bundler.git username:password
-
-
-
- Or you can set the credentials as an environment variable like so:
-
-
-
- export BUNDLE_GITHUB__COM=username:password
-
-
-
- This is especially useful for private repositories on hosts such as
- Github, where you can use personal OAuth tokens:
-
-
-
- export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x-oauth-basic
-
-
-
-CONFIGURE BUNDLER DIRECTORIES
- Bundler's home, config, cache and plugin directories are able to be
- configured through environment variables. The default location for
- Bundler's home directory is ~/.bundle, which all directories inherit
- from by default. The following outlines the available environment vari-
- ables and their default values
-
-
-
- BUNDLE_USER_HOME : $HOME/.bundle
- BUNDLE_USER_CACHE : $BUNDLE_USER_HOME/cache
- BUNDLE_USER_CONFIG : $BUNDLE_USER_HOME/config
- BUNDLE_USER_PLUGIN : $BUNDLE_USER_HOME/plugin
-
-
-
-
-
-
- January 2020 BUNDLE-CONFIG(1)
diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn
deleted file mode 100644
index 75b389e7e3..0000000000
--- a/man/bundle-config.ronn
+++ /dev/null
@@ -1,399 +0,0 @@
-bundle-config(1) -- Set bundler configuration options
-=====================================================
-
-## SYNOPSIS
-
-`bundle config` [list|get|set|unset] [<name> [<value>]]
-
-## DESCRIPTION
-
-This command allows you to interact with Bundler's configuration system.
-
-Bundler loads configuration settings in this order:
-
-1. Local config (`app/.bundle/config`)
-2. Environmental variables (`ENV`)
-3. Global config (`~/.bundle/config`)
-4. Bundler default config
-
-Executing `bundle config list` with will print a list of all bundler
-configuration for the current bundle, and where that configuration
-was set.
-
-Executing `bundle config get <name>` will print the value of that configuration
-setting, and where it was set.
-
-Executing `bundle config set <name> <value>` will set that configuration to the
-value specified for all bundles executed as the current user. The configuration
-will be stored in `~/.bundle/config`. If <name> already is set, <name> will be
-overridden and user will be warned.
-
-Executing `bundle config set --global <name> <value>` works the same as above.
-
-Executing `bundle config set --local <name> <value>` will set that configuration to
-the local application. The configuration will be stored in `app/.bundle/config`.
-
-Executing `bundle config unset <name>` will delete the configuration in both
-local and global sources.
-
-Executing `bundle config unset --global <name>` will delete the configuration
-only from the user configuration.
-
-Executing `bundle config unset --local <name> <value>` will delete the
-configuration only from the local application.
-
-Executing bundle with the `BUNDLE_IGNORE_CONFIG` environment variable set will
-cause it to ignore all configuration.
-
-Executing `bundle config set disable_multisource true` upgrades the warning about
-the Gemfile containing multiple primary sources to an error. Executing `bundle
-config unset disable_multisource` downgrades this error to a warning.
-
-## REMEMBERING OPTIONS
-
-Flags passed to `bundle install` or the Bundler runtime, such as `--path foo` or
-`--without production`, are remembered between commands and saved to your local
-application's configuration (normally, `./.bundle/config`).
-
-However, this will be changed in bundler 3, so it's better not to rely on this
-behavior. If these options must be remembered, it's better to set them using
-`bundle config` (e.g., `bundle config set path foo`).
-
-The options that can be configured are:
-
-* `bin`:
- Creates a directory (defaults to `~/bin`) and place any executables from the
- gem there. These executables run in Bundler's context. If used, you might add
- this directory to your environment's `PATH` variable. For instance, if the
- `rails` gem comes with a `rails` executable, this flag will create a
- `bin/rails` executable that ensures that all referred dependencies will be
- resolved using the bundled gems.
-
-* `deployment`:
- In deployment mode, Bundler will 'roll-out' the bundle for
- `production` use. Please check carefully if you want to have this option
- enabled in `development` or `test` environments.
-
-* `path`:
- The location to install the specified gems to. This defaults to Rubygems'
- setting. Bundler shares this location with Rubygems, `gem install ...` will
- have gem installed there, too. Therefore, gems installed without a
- `--path ...` setting will show up by calling `gem list`. Accordingly, gems
- installed to other locations will not get listed.
-
-* `without`:
- A space-separated list of groups referencing gems to skip during installation.
-
-* `with`:
- A space-separated list of groups referencing gems to include during installation.
-
-## BUILD OPTIONS
-
-You can use `bundle config` to give Bundler the flags to pass to the gem
-installer every time bundler tries to install a particular gem.
-
-A very common example, the `mysql` gem, requires Snow Leopard users to
-pass configuration flags to `gem install` to specify where to find the
-`mysql_config` executable.
-
- gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
-
-Since the specific location of that executable can change from machine
-to machine, you can specify these flags on a per-machine basis.
-
- bundle config set build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
-
-After running this command, every time bundler needs to install the
-`mysql` gem, it will pass along the flags you specified.
-
-## CONFIGURATION KEYS
-
-Configuration keys in bundler have two forms: the canonical form and the
-environment variable form.
-
-For instance, passing the `--without` flag to [bundle install(1)](bundle-install.1.html)
-prevents Bundler from installing certain groups specified in the Gemfile(5). Bundler
-persists this value in `app/.bundle/config` so that calls to `Bundler.setup`
-do not try to find gems from the `Gemfile` that you didn't install. Additionally,
-subsequent calls to [bundle install(1)](bundle-install.1.html) remember this setting
-and skip those groups.
-
-The canonical form of this configuration is `"without"`. To convert the canonical
-form to the environment variable form, capitalize it, and prepend `BUNDLE_`. The
-environment variable form of `"without"` is `BUNDLE_WITHOUT`.
-
-Any periods in the configuration keys must be replaced with two underscores when
-setting it via environment variables. The configuration key `local.rack` becomes
-the environment variable `BUNDLE_LOCAL__RACK`.
-
-## LIST OF AVAILABLE KEYS
-
-The following is a list of all configuration keys and their purpose. You can
-learn more about their operation in [bundle install(1)](bundle-install.1.html).
-
-* `allow_bundler_dependency_conflicts` (`BUNDLE_ALLOW_BUNDLER_DEPENDENCY_CONFLICTS`):
- Allow resolving to specifications that have dependencies on `bundler` that
- are incompatible with the running Bundler version.
-* `allow_deployment_source_credential_changes` (`BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES`):
- When in deployment mode, allow changing the credentials to a gem's source.
- Ex: `https://some.host.com/gems/path/` -> `https://user_name:password@some.host.com/gems/path`
-* `allow_offline_install` (`BUNDLE_ALLOW_OFFLINE_INSTALL`):
- Allow Bundler to use cached data when installing without network access.
-* `auto_clean_without_path` (`BUNDLE_AUTO_CLEAN_WITHOUT_PATH`):
- Automatically run `bundle clean` after installing when an explicit `path`
- has not been set and Bundler is not installing into the system gems.
-* `auto_install` (`BUNDLE_AUTO_INSTALL`):
- Automatically run `bundle install` when gems are missing.
-* `bin` (`BUNDLE_BIN`):
- Install executables from gems in the bundle to the specified directory.
- Defaults to `false`.
-* `cache_all` (`BUNDLE_CACHE_ALL`):
- Cache all gems, including path and git gems.
-* `cache_all_platforms` (`BUNDLE_CACHE_ALL_PLATFORMS`):
- Cache gems for all platforms.
-* `cache_path` (`BUNDLE_CACHE_PATH`):
- The directory that bundler will place cached gems in when running
- <code>bundle package</code>, and that bundler will look in when installing gems.
- Defaults to `vendor/cache`.
-* `clean` (`BUNDLE_CLEAN`):
- Whether Bundler should run `bundle clean` automatically after
- `bundle install`.
-* `console` (`BUNDLE_CONSOLE`):
- The console that `bundle console` starts. Defaults to `irb`.
-* `default_install_uses_path` (`BUNDLE_DEFAULT_INSTALL_USES_PATH`):
- Whether a `bundle install` without an explicit `--path` argument defaults
- to installing gems in `.bundle`.
-* `deployment` (`BUNDLE_DEPLOYMENT`):
- Disallow changes to the `Gemfile`. When the `Gemfile` is changed and the
- lockfile has not been updated, running Bundler commands will be blocked.
-* `disable_checksum_validation` (`BUNDLE_DISABLE_CHECKSUM_VALIDATION`):
- Allow installing gems even if they do not match the checksum provided by
- RubyGems.
-* `disable_exec_load` (`BUNDLE_DISABLE_EXEC_LOAD`):
- Stop Bundler from using `load` to launch an executable in-process in
- `bundle exec`.
-* `disable_local_branch_check` (`BUNDLE_DISABLE_LOCAL_BRANCH_CHECK`):
- Allow Bundler to use a local git override without a branch specified in the
- Gemfile.
-* `disable_multisource` (`BUNDLE_DISABLE_MULTISOURCE`):
- When set, Gemfiles containing multiple sources will produce errors
- instead of warnings.
- Use `bundle config unset disable_multisource` to unset.
-* `disable_platform_warnings` (`BUNDLE_DISABLE_PLATFORM_WARNINGS`):
- Disable warnings during bundle install when a dependency is unused on the current platform.
-* `disable_shared_gems` (`BUNDLE_DISABLE_SHARED_GEMS`):
- Stop Bundler from accessing gems installed to RubyGems' normal location.
-* `disable_version_check` (`BUNDLE_DISABLE_VERSION_CHECK`):
- Stop Bundler from checking if a newer Bundler version is available on
- rubygems.org.
-* `force_ruby_platform` (`BUNDLE_FORCE_RUBY_PLATFORM`):
- Ignore the current machine's platform and install only `ruby` platform gems.
- As a result, gems with native extensions will be compiled from source.
-* `frozen` (`BUNDLE_FROZEN`):
- Disallow changes to the `Gemfile`. When the `Gemfile` is changed and the
- lockfile has not been updated, running Bundler commands will be blocked.
- Defaults to `true` when `--deployment` is used.
-* `gem.push_key` (`BUNDLE_GEM__PUSH_KEY`):
- Sets the `--key` parameter for `gem push` when using the `rake release`
- command with a private gemstash server.
-* `gemfile` (`BUNDLE_GEMFILE`):
- The name of the file that bundler should use as the `Gemfile`. This location
- of this file also sets the root of the project, which is used to resolve
- relative paths in the `Gemfile`, among other things. By default, bundler
- will search up from the current working directory until it finds a
- `Gemfile`.
-* `global_gem_cache` (`BUNDLE_GLOBAL_GEM_CACHE`):
- Whether Bundler should cache all gems globally, rather than locally to the
- installing Ruby installation.
-* `ignore_messages` (`BUNDLE_IGNORE_MESSAGES`): When set, no post install
- messages will be printed. To silence a single gem, use dot notation like
- `ignore_messages.httparty true`.
-* `init_gems_rb` (`BUNDLE_INIT_GEMS_RB`)
- Generate a `gems.rb` instead of a `Gemfile` when running `bundle init`.
-* `jobs` (`BUNDLE_JOBS`):
- The number of gems Bundler can install in parallel. Defaults to 1.
-* `no_install` (`BUNDLE_NO_INSTALL`):
- Whether `bundle package` should skip installing gems.
-* `no_prune` (`BUNDLE_NO_PRUNE`):
- Whether Bundler should leave outdated gems unpruned when caching.
-* `only_update_to_newer_versions` (`BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS`):
- During `bundle update`, only resolve to newer versions of the gems in the
- lockfile.
-* `path` (`BUNDLE_PATH`):
- The location on disk where all gems in your bundle will be located regardless
- of `$GEM_HOME` or `$GEM_PATH` values. Bundle gems not found in this location
- will be installed by `bundle install`. Defaults to `Gem.dir`. When --deployment
- is used, defaults to vendor/bundle.
-* `path.system` (`BUNDLE_PATH__SYSTEM`):
- Whether Bundler will install gems into the default system path (`Gem.dir`).
-* `path_relative_to_cwd` (`BUNDLE_PATH_RELATIVE_TO_CWD`)
- Makes `--path` relative to the CWD instead of the `Gemfile`.
-* `plugins` (`BUNDLE_PLUGINS`):
- Enable Bundler's experimental plugin system.
-* `prefer_patch` (BUNDLE_PREFER_PATCH):
- Prefer updating only to next patch version during updates. Makes `bundle update` calls equivalent to `bundler update --patch`.
-* `print_only_version_number` (`BUNDLE_PRINT_ONLY_VERSION_NUMBER`)
- Print only version number from `bundler --version`.
-* `redirect` (`BUNDLE_REDIRECT`):
- The number of redirects allowed for network requests. Defaults to `5`.
-* `retry` (`BUNDLE_RETRY`):
- The number of times to retry failed network requests. Defaults to `3`.
-* `setup_makes_kernel_gem_public` (`BUNDLE_SETUP_MAKES_KERNEL_GEM_PUBLIC`):
- Have `Bundler.setup` make the `Kernel#gem` method public, even though
- RubyGems declares it as private.
-* `shebang` (`BUNDLE_SHEBANG`):
- The program name that should be invoked for generated binstubs. Defaults to
- the ruby install name used to generate the binstub.
-* `silence_deprecations` (`BUNDLE_SILENCE_DEPRECATIONS`):
- Whether Bundler should silence deprecation warnings for behavior that will
- be changed in the next major version.
-* `silence_root_warning` (`BUNDLE_SILENCE_ROOT_WARNING`):
- Silence the warning Bundler prints when installing gems as root.
-* `skip_default_git_sources` (`BUNDLE_SKIP_DEFAULT_GIT_SOURCES`):
- Whether Bundler should skip adding default git source shortcuts to the
- Gemfile DSL.
-* `specific_platform` (`BUNDLE_SPECIFIC_PLATFORM`):
- Allow bundler to resolve for the specific running platform and store it in
- the lockfile, instead of only using a generic platform.
- A specific platform is the exact platform triple reported by
- `Gem::Platform.local`, such as `x86_64-darwin-16` or `universal-java-1.8`.
- On the other hand, generic platforms are those such as `ruby`, `mswin`, or
- `java`. In this example, `x86_64-darwin-16` would map to `ruby` and
- `universal-java-1.8` to `java`.
-* `ssl_ca_cert` (`BUNDLE_SSL_CA_CERT`):
- Path to a designated CA certificate file or folder containing multiple
- certificates for trusted CAs in PEM format.
-* `ssl_client_cert` (`BUNDLE_SSL_CLIENT_CERT`):
- Path to a designated file containing a X.509 client certificate
- and key in PEM format.
-* `ssl_verify_mode` (`BUNDLE_SSL_VERIFY_MODE`):
- The SSL verification mode Bundler uses when making HTTPS requests.
- Defaults to verify peer.
-* `suppress_install_using_messages` (`BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES`):
- Avoid printing `Using ...` messages during installation when the version of
- a gem has not changed.
-* `system_bindir` (`BUNDLE_SYSTEM_BINDIR`):
- The location where RubyGems installs binstubs. Defaults to `Gem.bindir`.
-* `timeout` (`BUNDLE_TIMEOUT`):
- The seconds allowed before timing out for network requests. Defaults to `10`.
-* `unlock_source_unlocks_spec` (`BUNDLE_UNLOCK_SOURCE_UNLOCKS_SPEC`):
- Whether running `bundle update --source NAME` unlocks a gem with the given
- name. Defaults to `true`.
-* `update_requires_all_flag` (`BUNDLE_UPDATE_REQUIRES_ALL_FLAG`)
- Require passing `--all` to `bundle update` when everything should be updated,
- and disallow passing no options to `bundle update`.
-* `user_agent` (`BUNDLE_USER_AGENT`):
- The custom user agent fragment Bundler includes in API requests.
-* `with` (`BUNDLE_WITH`):
- A `:`-separated list of groups whose gems bundler should install.
-* `without` (`BUNDLE_WITHOUT`):
- A `:`-separated list of groups whose gems bundler should not install.
-
-In general, you should set these settings per-application by using the applicable
-flag to the [bundle install(1)](bundle-install.1.html) or [bundle package(1)](bundle-package.1.html) command.
-
-You can set them globally either via environment variables or `bundle config`,
-whichever is preferable for your setup. If you use both, environment variables
-will take preference over global settings.
-
-## LOCAL GIT REPOS
-
-Bundler also allows you to work against a git repository locally
-instead of using the remote version. This can be achieved by setting
-up a local override:
-
- bundle config set local.GEM_NAME /path/to/local/git/repository
-
-For example, in order to use a local Rack repository, a developer could call:
-
- bundle config set local.rack ~/Work/git/rack
-
-Now instead of checking out the remote git repository, the local
-override will be used. Similar to a path source, every time the local
-git repository change, changes will be automatically picked up by
-Bundler. This means a commit in the local git repo will update the
-revision in the `Gemfile.lock` to the local git repo revision. This
-requires the same attention as git submodules. Before pushing to
-the remote, you need to ensure the local override was pushed, otherwise
-you may point to a commit that only exists in your local machine.
-You'll also need to CGI escape your usernames and passwords as well.
-
-Bundler does many checks to ensure a developer won't work with
-invalid references. Particularly, we force a developer to specify
-a branch in the `Gemfile` in order to use this feature. If the branch
-specified in the `Gemfile` and the current branch in the local git
-repository do not match, Bundler will abort. This ensures that
-a developer is always working against the correct branches, and prevents
-accidental locking to a different branch.
-
-Finally, Bundler also ensures that the current revision in the
-`Gemfile.lock` exists in the local git repository. By doing this, Bundler
-forces you to fetch the latest changes in the remotes.
-
-## MIRRORS OF GEM SOURCES
-
-Bundler supports overriding gem sources with mirrors. This allows you to
-configure rubygems.org as the gem source in your Gemfile while still using your
-mirror to fetch gems.
-
- bundle config set mirror.SOURCE_URL MIRROR_URL
-
-For example, to use a mirror of rubygems.org hosted at rubygems-mirror.org:
-
- bundle config set mirror.http://rubygems.org http://rubygems-mirror.org
-
-Each mirror also provides a fallback timeout setting. If the mirror does not
-respond within the fallback timeout, Bundler will try to use the original
-server instead of the mirror.
-
- bundle config set mirror.SOURCE_URL.fallback_timeout TIMEOUT
-
-For example, to fall back to rubygems.org after 3 seconds:
-
- bundle config set mirror.https://rubygems.org.fallback_timeout 3
-
-The default fallback timeout is 0.1 seconds, but the setting can currently
-only accept whole seconds (for example, 1, 15, or 30).
-
-## CREDENTIALS FOR GEM SOURCES
-
-Bundler allows you to configure credentials for any gem source, which allows
-you to avoid putting secrets into your Gemfile.
-
- bundle config set SOURCE_HOSTNAME USERNAME:PASSWORD
-
-For example, to save the credentials of user `claudette` for the gem source at
-`gems.longerous.com`, you would run:
-
- bundle config set gems.longerous.com claudette:s00pers3krit
-
-Or you can set the credentials as an environment variable like this:
-
- export BUNDLE_GEMS__LONGEROUS__COM="claudette:s00pers3krit"
-
-For gems with a git source with HTTP(S) URL you can specify credentials like so:
-
- bundle config set https://github.com/bundler/bundler.git username:password
-
-Or you can set the credentials as an environment variable like so:
-
- export BUNDLE_GITHUB__COM=username:password
-
-This is especially useful for private repositories on hosts such as Github,
-where you can use personal OAuth tokens:
-
- export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x-oauth-basic
-
-
-## CONFIGURE BUNDLER DIRECTORIES
-
-Bundler's home, config, cache and plugin directories are able to be configured
-through environment variables. The default location for Bundler's home directory is
-`~/.bundle`, which all directories inherit from by default. The following
-outlines the available environment variables and their default values
-
- BUNDLE_USER_HOME : $HOME/.bundle
- BUNDLE_USER_CACHE : $BUNDLE_USER_HOME/cache
- BUNDLE_USER_CONFIG : $BUNDLE_USER_HOME/config
- BUNDLE_USER_PLUGIN : $BUNDLE_USER_HOME/plugin
-
diff --git a/man/bundle-doctor.1 b/man/bundle-doctor.1
deleted file mode 100644
index 344c40066b..0000000000
--- a/man/bundle-doctor.1
+++ /dev/null
@@ -1,44 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-DOCTOR" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-doctor\fR \- Checks the bundle for common problems
-.
-.SH "SYNOPSIS"
-\fBbundle doctor\fR [\-\-quiet] [\-\-gemfile=GEMFILE]
-.
-.SH "DESCRIPTION"
-Checks your Gemfile and gem environment for common problems\. If issues are detected, Bundler prints them and exits status 1\. Otherwise, Bundler prints a success message and exits status 0\.
-.
-.P
-Examples of common problems caught by bundle\-doctor include:
-.
-.IP "\(bu" 4
-Invalid Bundler settings
-.
-.IP "\(bu" 4
-Mismatched Ruby versions
-.
-.IP "\(bu" 4
-Mismatched platforms
-.
-.IP "\(bu" 4
-Uninstalled gems
-.
-.IP "\(bu" 4
-Missing dependencies
-.
-.IP "" 0
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-quiet\fR
-Only output warnings and errors\.
-.
-.TP
-\fB\-\-gemfile=<gemfile>\fR
-The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project\'s root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
-
diff --git a/man/bundle-doctor.1.txt b/man/bundle-doctor.1.txt
deleted file mode 100644
index 595ba99633..0000000000
--- a/man/bundle-doctor.1.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-BUNDLE-DOCTOR(1) BUNDLE-DOCTOR(1)
-
-
-
-NAME
- bundle-doctor - Checks the bundle for common problems
-
-SYNOPSIS
- bundle doctor [--quiet] [--gemfile=GEMFILE]
-
-DESCRIPTION
- Checks your Gemfile and gem environment for common problems. If issues
- are detected, Bundler prints them and exits status 1. Otherwise,
- Bundler prints a success message and exits status 0.
-
- Examples of common problems caught by bundle-doctor include:
-
- o Invalid Bundler settings
-
- o Mismatched Ruby versions
-
- o Mismatched platforms
-
- o Uninstalled gems
-
- o Missing dependencies
-
-
-
-OPTIONS
- --quiet
- Only output warnings and errors.
-
- --gemfile=<gemfile>
- The location of the Gemfile(5) which Bundler should use. This
- defaults to a Gemfile(5) in the current working directory. In
- general, Bundler will assume that the location of the Gemfile(5)
- is also the project's root and will try to find Gemfile.lock and
- vendor/cache relative to this location.
-
-
-
-
- January 2020 BUNDLE-DOCTOR(1)
diff --git a/man/bundle-doctor.ronn b/man/bundle-doctor.ronn
deleted file mode 100644
index 271ee800ad..0000000000
--- a/man/bundle-doctor.ronn
+++ /dev/null
@@ -1,33 +0,0 @@
-bundle-doctor(1) -- Checks the bundle for common problems
-=========================================================
-
-## SYNOPSIS
-
-`bundle doctor` [--quiet]
- [--gemfile=GEMFILE]
-
-## DESCRIPTION
-
-Checks your Gemfile and gem environment for common problems. If issues
-are detected, Bundler prints them and exits status 1. Otherwise,
-Bundler prints a success message and exits status 0.
-
-Examples of common problems caught by bundle-doctor include:
-
-* Invalid Bundler settings
-* Mismatched Ruby versions
-* Mismatched platforms
-* Uninstalled gems
-* Missing dependencies
-
-## OPTIONS
-
-* `--quiet`:
- Only output warnings and errors.
-
-* `--gemfile=<gemfile>`:
- The location of the Gemfile(5) which Bundler should use. This defaults
- to a Gemfile(5) in the current working directory. In general, Bundler
- will assume that the location of the Gemfile(5) is also the project's
- root and will try to find `Gemfile.lock` and `vendor/cache` relative
- to this location.
diff --git a/man/bundle-exec.1 b/man/bundle-exec.1
deleted file mode 100644
index 555819a5b4..0000000000
--- a/man/bundle-exec.1
+++ /dev/null
@@ -1,165 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-EXEC" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-exec\fR \- Execute a command in the context of the bundle
-.
-.SH "SYNOPSIS"
-\fBbundle exec\fR [\-\-keep\-file\-descriptors] \fIcommand\fR
-.
-.SH "DESCRIPTION"
-This command executes the command, making all gems specified in the [\fBGemfile(5)\fR][Gemfile(5)] available to \fBrequire\fR in Ruby programs\.
-.
-.P
-Essentially, if you would normally have run something like \fBrspec spec/my_spec\.rb\fR, and you want to use the gems specified in the [\fBGemfile(5)\fR][Gemfile(5)] and installed via bundle install(1) \fIbundle\-install\.1\.html\fR, you should run \fBbundle exec rspec spec/my_spec\.rb\fR\.
-.
-.P
-Note that \fBbundle exec\fR does not require that an executable is available on your shell\'s \fB$PATH\fR\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-keep\-file\-descriptors\fR
-Exec in Ruby 2\.0 began discarding non\-standard file descriptors\. When this flag is passed, exec will revert to the 1\.9 behaviour of passing all file descriptors to the new process\.
-.
-.SH "BUNDLE INSTALL \-\-BINSTUBS"
-If you use the \fB\-\-binstubs\fR flag in bundle install(1) \fIbundle\-install\.1\.html\fR, Bundler will automatically create a directory (which defaults to \fBapp_root/bin\fR) containing all of the executables available from gems in the bundle\.
-.
-.P
-After using \fB\-\-binstubs\fR, \fBbin/rspec spec/my_spec\.rb\fR is identical to \fBbundle exec rspec spec/my_spec\.rb\fR\.
-.
-.SH "ENVIRONMENT MODIFICATIONS"
-\fBbundle exec\fR makes a number of changes to the shell environment, then executes the command you specify in full\.
-.
-.IP "\(bu" 4
-make sure that it\'s still possible to shell out to \fBbundle\fR from inside a command invoked by \fBbundle exec\fR (using \fB$BUNDLE_BIN_PATH\fR)
-.
-.IP "\(bu" 4
-put the directory containing executables (like \fBrails\fR, \fBrspec\fR, \fBrackup\fR) for your bundle on \fB$PATH\fR
-.
-.IP "\(bu" 4
-make sure that if bundler is invoked in the subshell, it uses the same \fBGemfile\fR (by setting \fBBUNDLE_GEMFILE\fR)
-.
-.IP "\(bu" 4
-add \fB\-rbundler/setup\fR to \fB$RUBYOPT\fR, which makes sure that Ruby programs invoked in the subshell can see the gems in the bundle
-.
-.IP "" 0
-.
-.P
-It also modifies Rubygems:
-.
-.IP "\(bu" 4
-disallow loading additional gems not in the bundle
-.
-.IP "\(bu" 4
-modify the \fBgem\fR method to be a no\-op if a gem matching the requirements is in the bundle, and to raise a \fBGem::LoadError\fR if it\'s not
-.
-.IP "\(bu" 4
-Define \fBGem\.refresh\fR to be a no\-op, since the source index is always frozen when using bundler, and to prevent gems from the system leaking into the environment
-.
-.IP "\(bu" 4
-Override \fBGem\.bin_path\fR to use the gems in the bundle, making system executables work
-.
-.IP "\(bu" 4
-Add all gems in the bundle into Gem\.loaded_specs
-.
-.IP "" 0
-.
-.P
-Finally, \fBbundle exec\fR also implicitly modifies \fBGemfile\.lock\fR if the lockfile and the Gemfile do not match\. Bundler needs the Gemfile to determine things such as a gem\'s groups, \fBautorequire\fR, and platforms, etc\., and that information isn\'t stored in the lockfile\. The Gemfile and lockfile must be synced in order to \fBbundle exec\fR successfully, so \fBbundle exec\fR updates the lockfile beforehand\.
-.
-.SS "Loading"
-By default, when attempting to \fBbundle exec\fR to a file with a ruby shebang, Bundler will \fBKernel\.load\fR that file instead of using \fBKernel\.exec\fR\. For the vast majority of cases, this is a performance improvement\. In a rare few cases, this could cause some subtle side\-effects (such as dependence on the exact contents of \fB$0\fR or \fB__FILE__\fR) and the optimization can be disabled by enabling the \fBdisable_exec_load\fR setting\.
-.
-.SS "Shelling out"
-Any Ruby code that opens a subshell (like \fBsystem\fR, backticks, or \fB%x{}\fR) will automatically use the current Bundler environment\. If you need to shell out to a Ruby command that is not part of your current bundle, use the \fBwith_clean_env\fR method with a block\. Any subshells created inside the block will be given the environment present before Bundler was activated\. For example, Homebrew commands run Ruby, but don\'t work inside a bundle:
-.
-.IP "" 4
-.
-.nf
-
-Bundler\.with_clean_env do
- `brew install wget`
-end
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Using \fBwith_clean_env\fR is also necessary if you are shelling out to a different bundle\. Any Bundler commands run in a subshell will inherit the current Gemfile, so commands that need to run in the context of a different bundle also need to use \fBwith_clean_env\fR\.
-.
-.IP "" 4
-.
-.nf
-
-Bundler\.with_clean_env do
- Dir\.chdir "/other/bundler/project" do
- `bundle exec \./script`
- end
-end
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Bundler provides convenience helpers that wrap \fBsystem\fR and \fBexec\fR, and they can be used like this:
-.
-.IP "" 4
-.
-.nf
-
-Bundler\.clean_system(\'brew install wget\')
-Bundler\.clean_exec(\'brew install wget\')
-.
-.fi
-.
-.IP "" 0
-.
-.SH "RUBYGEMS PLUGINS"
-At present, the Rubygems plugin system requires all files named \fBrubygems_plugin\.rb\fR on the load path of \fIany\fR installed gem when any Ruby code requires \fBrubygems\.rb\fR\. This includes executables installed into the system, like \fBrails\fR, \fBrackup\fR, and \fBrspec\fR\.
-.
-.P
-Since Rubygems plugins can contain arbitrary Ruby code, they commonly end up activating themselves or their dependencies\.
-.
-.P
-For instance, the \fBgemcutter 0\.5\fR gem depended on \fBjson_pure\fR\. If you had that version of gemcutter installed (even if you \fIalso\fR had a newer version without this problem), Rubygems would activate \fBgemcutter 0\.5\fR and \fBjson_pure <latest>\fR\.
-.
-.P
-If your Gemfile(5) also contained \fBjson_pure\fR (or a gem with a dependency on \fBjson_pure\fR), the latest version on your system might conflict with the version in your Gemfile(5), or the snapshot version in your \fBGemfile\.lock\fR\.
-.
-.P
-If this happens, bundler will say:
-.
-.IP "" 4
-.
-.nf
-
-You have already activated json_pure 1\.4\.6 but your Gemfile
-requires json_pure 1\.4\.3\. Consider using bundle exec\.
-.
-.fi
-.
-.IP "" 0
-.
-.P
-In this situation, you almost certainly want to remove the underlying gem with the problematic gem plugin\. In general, the authors of these plugins (in this case, the \fBgemcutter\fR gem) have released newer versions that are more careful in their plugins\.
-.
-.P
-You can find a list of all the gems containing gem plugins by running
-.
-.IP "" 4
-.
-.nf
-
-ruby \-rrubygems \-e "puts Gem\.find_files(\'rubygems_plugin\.rb\')"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-At the very least, you should remove all but the newest version of each gem plugin, and also remove all gem plugins that you aren\'t using (\fBgem uninstall gem_name\fR)\.
diff --git a/man/bundle-exec.1.txt b/man/bundle-exec.1.txt
deleted file mode 100644
index ebdc2fda71..0000000000
--- a/man/bundle-exec.1.txt
+++ /dev/null
@@ -1,178 +0,0 @@
-BUNDLE-EXEC(1) BUNDLE-EXEC(1)
-
-
-
-NAME
- bundle-exec - Execute a command in the context of the bundle
-
-SYNOPSIS
- bundle exec [--keep-file-descriptors] command
-
-DESCRIPTION
- This command executes the command, making all gems specified in the
- [Gemfile(5)][Gemfile(5)] available to require in Ruby programs.
-
- Essentially, if you would normally have run something like rspec
- spec/my_spec.rb, and you want to use the gems specified in the [Gem-
- file(5)][Gemfile(5)] and installed via bundle install(1) bun-
- dle-install.1.html, you should run bundle exec rspec spec/my_spec.rb.
-
- Note that bundle exec does not require that an executable is available
- on your shell's $PATH.
-
-OPTIONS
- --keep-file-descriptors
- Exec in Ruby 2.0 began discarding non-standard file descriptors.
- When this flag is passed, exec will revert to the 1.9 behaviour
- of passing all file descriptors to the new process.
-
-BUNDLE INSTALL --BINSTUBS
- If you use the --binstubs flag in bundle install(1) bun-
- dle-install.1.html, Bundler will automatically create a directory
- (which defaults to app_root/bin) containing all of the executables
- available from gems in the bundle.
-
- After using --binstubs, bin/rspec spec/my_spec.rb is identical to bun-
- dle exec rspec spec/my_spec.rb.
-
-ENVIRONMENT MODIFICATIONS
- bundle exec makes a number of changes to the shell environment, then
- executes the command you specify in full.
-
- o make sure that it's still possible to shell out to bundle from
- inside a command invoked by bundle exec (using $BUNDLE_BIN_PATH)
-
- o put the directory containing executables (like rails, rspec,
- rackup) for your bundle on $PATH
-
- o make sure that if bundler is invoked in the subshell, it uses the
- same Gemfile (by setting BUNDLE_GEMFILE)
-
- o add -rbundler/setup to $RUBYOPT, which makes sure that Ruby pro-
- grams invoked in the subshell can see the gems in the bundle
-
-
-
- It also modifies Rubygems:
-
- o disallow loading additional gems not in the bundle
-
- o modify the gem method to be a no-op if a gem matching the require-
- ments is in the bundle, and to raise a Gem::LoadError if it's not
-
- o Define Gem.refresh to be a no-op, since the source index is always
- frozen when using bundler, and to prevent gems from the system
- leaking into the environment
-
- o Override Gem.bin_path to use the gems in the bundle, making system
- executables work
-
- o Add all gems in the bundle into Gem.loaded_specs
-
-
-
- Finally, bundle exec also implicitly modifies Gemfile.lock if the lock-
- file and the Gemfile do not match. Bundler needs the Gemfile to deter-
- mine things such as a gem's groups, autorequire, and platforms, etc.,
- and that information isn't stored in the lockfile. The Gemfile and
- lockfile must be synced in order to bundle exec successfully, so bundle
- exec updates the lockfile beforehand.
-
- Loading
- By default, when attempting to bundle exec to a file with a ruby she-
- bang, Bundler will Kernel.load that file instead of using Kernel.exec.
- For the vast majority of cases, this is a performance improvement. In a
- rare few cases, this could cause some subtle side-effects (such as
- dependence on the exact contents of $0 or __FILE__) and the optimiza-
- tion can be disabled by enabling the disable_exec_load setting.
-
- Shelling out
- Any Ruby code that opens a subshell (like system, backticks, or %x{})
- will automatically use the current Bundler environment. If you need to
- shell out to a Ruby command that is not part of your current bundle,
- use the with_clean_env method with a block. Any subshells created
- inside the block will be given the environment present before Bundler
- was activated. For example, Homebrew commands run Ruby, but don't work
- inside a bundle:
-
-
-
- Bundler.with_clean_env do
- `brew install wget`
- end
-
-
-
- Using with_clean_env is also necessary if you are shelling out to a
- different bundle. Any Bundler commands run in a subshell will inherit
- the current Gemfile, so commands that need to run in the context of a
- different bundle also need to use with_clean_env.
-
-
-
- Bundler.with_clean_env do
- Dir.chdir "/other/bundler/project" do
- `bundle exec ./script`
- end
- end
-
-
-
- Bundler provides convenience helpers that wrap system and exec, and
- they can be used like this:
-
-
-
- Bundler.clean_system('brew install wget')
- Bundler.clean_exec('brew install wget')
-
-
-
-RUBYGEMS PLUGINS
- At present, the Rubygems plugin system requires all files named
- rubygems_plugin.rb on the load path of any installed gem when any Ruby
- code requires rubygems.rb. This includes executables installed into the
- system, like rails, rackup, and rspec.
-
- Since Rubygems plugins can contain arbitrary Ruby code, they commonly
- end up activating themselves or their dependencies.
-
- For instance, the gemcutter 0.5 gem depended on json_pure. If you had
- that version of gemcutter installed (even if you also had a newer ver-
- sion without this problem), Rubygems would activate gemcutter 0.5 and
- json_pure <latest>.
-
- If your Gemfile(5) also contained json_pure (or a gem with a dependency
- on json_pure), the latest version on your system might conflict with
- the version in your Gemfile(5), or the snapshot version in your Gem-
- file.lock.
-
- If this happens, bundler will say:
-
-
-
- You have already activated json_pure 1.4.6 but your Gemfile
- requires json_pure 1.4.3. Consider using bundle exec.
-
-
-
- In this situation, you almost certainly want to remove the underlying
- gem with the problematic gem plugin. In general, the authors of these
- plugins (in this case, the gemcutter gem) have released newer versions
- that are more careful in their plugins.
-
- You can find a list of all the gems containing gem plugins by running
-
-
-
- ruby -rrubygems -e "puts Gem.find_files('rubygems_plugin.rb')"
-
-
-
- At the very least, you should remove all but the newest version of each
- gem plugin, and also remove all gem plugins that you aren't using (gem
- uninstall gem_name).
-
-
-
- January 2020 BUNDLE-EXEC(1)
diff --git a/man/bundle-exec.ronn b/man/bundle-exec.ronn
deleted file mode 100644
index dec3c7cb82..0000000000
--- a/man/bundle-exec.ronn
+++ /dev/null
@@ -1,152 +0,0 @@
-bundle-exec(1) -- Execute a command in the context of the bundle
-================================================================
-
-## SYNOPSIS
-
-`bundle exec` [--keep-file-descriptors] <command>
-
-## DESCRIPTION
-
-This command executes the command, making all gems specified in the
-[`Gemfile(5)`][Gemfile(5)] available to `require` in Ruby programs.
-
-Essentially, if you would normally have run something like
-`rspec spec/my_spec.rb`, and you want to use the gems specified
-in the [`Gemfile(5)`][Gemfile(5)] and installed via [bundle install(1)](bundle-install.1.html), you
-should run `bundle exec rspec spec/my_spec.rb`.
-
-Note that `bundle exec` does not require that an executable is
-available on your shell's `$PATH`.
-
-## OPTIONS
-
-* `--keep-file-descriptors`:
- Exec in Ruby 2.0 began discarding non-standard file descriptors. When this
- flag is passed, exec will revert to the 1.9 behaviour of passing all file
- descriptors to the new process.
-
-## BUNDLE INSTALL --BINSTUBS
-
-If you use the `--binstubs` flag in [bundle install(1)](bundle-install.1.html), Bundler will
-automatically create a directory (which defaults to `app_root/bin`)
-containing all of the executables available from gems in the bundle.
-
-After using `--binstubs`, `bin/rspec spec/my_spec.rb` is identical
-to `bundle exec rspec spec/my_spec.rb`.
-
-## ENVIRONMENT MODIFICATIONS
-
-`bundle exec` makes a number of changes to the shell environment,
-then executes the command you specify in full.
-
-* make sure that it's still possible to shell out to `bundle`
- from inside a command invoked by `bundle exec` (using
- `$BUNDLE_BIN_PATH`)
-* put the directory containing executables (like `rails`, `rspec`,
- `rackup`) for your bundle on `$PATH`
-* make sure that if bundler is invoked in the subshell, it uses
- the same `Gemfile` (by setting `BUNDLE_GEMFILE`)
-* add `-rbundler/setup` to `$RUBYOPT`, which makes sure that
- Ruby programs invoked in the subshell can see the gems in
- the bundle
-
-It also modifies Rubygems:
-
-* disallow loading additional gems not in the bundle
-* modify the `gem` method to be a no-op if a gem matching
- the requirements is in the bundle, and to raise a
- `Gem::LoadError` if it's not
-* Define `Gem.refresh` to be a no-op, since the source
- index is always frozen when using bundler, and to
- prevent gems from the system leaking into the environment
-* Override `Gem.bin_path` to use the gems in the bundle,
- making system executables work
-* Add all gems in the bundle into Gem.loaded_specs
-
-Finally, `bundle exec` also implicitly modifies `Gemfile.lock` if the lockfile
-and the Gemfile do not match. Bundler needs the Gemfile to determine things
-such as a gem's groups, `autorequire`, and platforms, etc., and that
-information isn't stored in the lockfile. The Gemfile and lockfile must be
-synced in order to `bundle exec` successfully, so `bundle exec`
-updates the lockfile beforehand.
-
-### Loading
-
-By default, when attempting to `bundle exec` to a file with a ruby shebang,
-Bundler will `Kernel.load` that file instead of using `Kernel.exec`. For the
-vast majority of cases, this is a performance improvement. In a rare few cases,
-this could cause some subtle side-effects (such as dependence on the exact
-contents of `$0` or `__FILE__`) and the optimization can be disabled by enabling
-the `disable_exec_load` setting.
-
-### Shelling out
-
-Any Ruby code that opens a subshell (like `system`, backticks, or `%x{}`) will
-automatically use the current Bundler environment. If you need to shell out to
-a Ruby command that is not part of your current bundle, use the
-`with_clean_env` method with a block. Any subshells created inside the block
-will be given the environment present before Bundler was activated. For
-example, Homebrew commands run Ruby, but don't work inside a bundle:
-
- Bundler.with_clean_env do
- `brew install wget`
- end
-
-Using `with_clean_env` is also necessary if you are shelling out to a different
-bundle. Any Bundler commands run in a subshell will inherit the current
-Gemfile, so commands that need to run in the context of a different bundle also
-need to use `with_clean_env`.
-
- Bundler.with_clean_env do
- Dir.chdir "/other/bundler/project" do
- `bundle exec ./script`
- end
- end
-
-Bundler provides convenience helpers that wrap `system` and `exec`, and they
-can be used like this:
-
- Bundler.clean_system('brew install wget')
- Bundler.clean_exec('brew install wget')
-
-
-## RUBYGEMS PLUGINS
-
-At present, the Rubygems plugin system requires all files
-named `rubygems_plugin.rb` on the load path of _any_ installed
-gem when any Ruby code requires `rubygems.rb`. This includes
-executables installed into the system, like `rails`, `rackup`,
-and `rspec`.
-
-Since Rubygems plugins can contain arbitrary Ruby code, they
-commonly end up activating themselves or their dependencies.
-
-For instance, the `gemcutter 0.5` gem depended on `json_pure`.
-If you had that version of gemcutter installed (even if
-you _also_ had a newer version without this problem), Rubygems
-would activate `gemcutter 0.5` and `json_pure <latest>`.
-
-If your Gemfile(5) also contained `json_pure` (or a gem
-with a dependency on `json_pure`), the latest version on
-your system might conflict with the version in your
-Gemfile(5), or the snapshot version in your `Gemfile.lock`.
-
-If this happens, bundler will say:
-
- You have already activated json_pure 1.4.6 but your Gemfile
- requires json_pure 1.4.3. Consider using bundle exec.
-
-In this situation, you almost certainly want to remove the
-underlying gem with the problematic gem plugin. In general,
-the authors of these plugins (in this case, the `gemcutter`
-gem) have released newer versions that are more careful in
-their plugins.
-
-You can find a list of all the gems containing gem plugins
-by running
-
- ruby -rrubygems -e "puts Gem.find_files('rubygems_plugin.rb')"
-
-At the very least, you should remove all but the newest
-version of each gem plugin, and also remove all gem plugins
-that you aren't using (`gem uninstall gem_name`).
diff --git a/man/bundle-gem.1 b/man/bundle-gem.1
deleted file mode 100644
index baed185e70..0000000000
--- a/man/bundle-gem.1
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-GEM" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem
-.
-.SH "SYNOPSIS"
-\fBbundle gem\fR \fIGEM_NAME\fR \fIOPTIONS\fR
-.
-.SH "DESCRIPTION"
-Generates a directory named \fBGEM_NAME\fR with a \fBRakefile\fR, \fBGEM_NAME\.gemspec\fR, and other supporting files and directories that can be used to develop a rubygem with that name\.
-.
-.P
-Run \fBrake \-T\fR in the resulting project for a list of Rake tasks that can be used to test and publish the gem to rubygems\.org\.
-.
-.P
-The generated project skeleton can be customized with OPTIONS, as explained below\. Note that these options can also be specified via Bundler\'s global configuration file using the following names:
-.
-.IP "\(bu" 4
-\fBgem\.coc\fR
-.
-.IP "\(bu" 4
-\fBgem\.mit\fR
-.
-.IP "\(bu" 4
-\fBgem\.test\fR
-.
-.IP "" 0
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-exe\fR or \fB\-b\fR or \fB\-\-bin\fR
-Specify that Bundler should create a binary executable (as \fBexe/GEM_NAME\fR) in the generated rubygem project\. This binary will also be added to the \fBGEM_NAME\.gemspec\fR manifest\. This behavior is disabled by default\.
-.
-.TP
-\fB\-\-no\-exe\fR
-Do not create a binary (overrides \fB\-\-exe\fR specified in the global config)\.
-.
-.TP
-\fB\-\-coc\fR
-Add a \fBCODE_OF_CONDUCT\.md\fR file to the root of the generated project\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
-.TP
-\fB\-\-no\-coc\fR
-Do not create a \fBCODE_OF_CONDUCT\.md\fR (overrides \fB\-\-coc\fR specified in the global config)\.
-.
-.TP
-\fB\-\-ext\fR
-Add boilerplate for C extension code to the generated project\. This behavior is disabled by default\.
-.
-.TP
-\fB\-\-no\-ext\fR
-Do not add C extension code (overrides \fB\-\-ext\fR specified in the global config)\.
-.
-.TP
-\fB\-\-mit\fR
-Add an MIT license to a \fBLICENSE\.txt\fR file in the root of the generated project\. Your name from the global git config is used for the copyright statement\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
-.TP
-\fB\-\-no\-mit\fR
-Do not create a \fBLICENSE\.txt\fR (overrides \fB\-\-mit\fR specified in the global config)\.
-.
-.TP
-\fB\-t\fR, \fB\-\-test=minitest\fR, \fB\-\-test=rspec\fR
-Specify the test framework that Bundler should use when generating the project\. Acceptable values are \fBminitest\fR and \fBrspec\fR\. The \fBGEM_NAME\.gemspec\fR will be configured and a skeleton test/spec directory will be created based on this option\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\. If no option is specified, the default testing framework is RSpec\.
-.
-.TP
-\fB\-e\fR, \fB\-\-edit[=EDITOR]\fR
-Open the resulting GEM_NAME\.gemspec in EDITOR, or the default editor if not specified\. The default is \fB$BUNDLER_EDITOR\fR, \fB$VISUAL\fR, or \fB$EDITOR\fR\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-bundle config(1) \fIbundle\-config\.1\.html\fR
-.
-.IP "" 0
-
diff --git a/man/bundle-gem.1.txt b/man/bundle-gem.1.txt
deleted file mode 100644
index 554bb1a41b..0000000000
--- a/man/bundle-gem.1.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-BUNDLE-GEM(1) BUNDLE-GEM(1)
-
-
-
-NAME
- bundle-gem - Generate a project skeleton for creating a rubygem
-
-SYNOPSIS
- bundle gem GEM_NAME OPTIONS
-
-DESCRIPTION
- Generates a directory named GEM_NAME with a Rakefile, GEM_NAME.gemspec,
- and other supporting files and directories that can be used to develop
- a rubygem with that name.
-
- Run rake -T in the resulting project for a list of Rake tasks that can
- be used to test and publish the gem to rubygems.org.
-
- The generated project skeleton can be customized with OPTIONS, as
- explained below. Note that these options can also be specified via
- Bundler's global configuration file using the following names:
-
- o gem.coc
-
- o gem.mit
-
- o gem.test
-
-
-
-OPTIONS
- --exe or -b or --bin
- Specify that Bundler should create a binary executable (as
- exe/GEM_NAME) in the generated rubygem project. This binary will
- also be added to the GEM_NAME.gemspec manifest. This behavior is
- disabled by default.
-
- --no-exe
- Do not create a binary (overrides --exe specified in the global
- config).
-
- --coc Add a CODE_OF_CONDUCT.md file to the root of the generated
- project. If this option is unspecified, an interactive prompt
- will be displayed and the answer will be saved in Bundler's
- global config for future bundle gem use.
-
- --no-coc
- Do not create a CODE_OF_CONDUCT.md (overrides --coc specified in
- the global config).
-
- --ext Add boilerplate for C extension code to the generated project.
- This behavior is disabled by default.
-
- --no-ext
- Do not add C extension code (overrides --ext specified in the
- global config).
-
- --mit Add an MIT license to a LICENSE.txt file in the root of the gen-
- erated project. Your name from the global git config is used for
- the copyright statement. If this option is unspecified, an
- interactive prompt will be displayed and the answer will be
- saved in Bundler's global config for future bundle gem use.
-
- --no-mit
- Do not create a LICENSE.txt (overrides --mit specified in the
- global config).
-
- -t, --test=minitest, --test=rspec
- Specify the test framework that Bundler should use when generat-
- ing the project. Acceptable values are minitest and rspec. The
- GEM_NAME.gemspec will be configured and a skeleton test/spec
- directory will be created based on this option. If this option
- is unspecified, an interactive prompt will be displayed and the
- answer will be saved in Bundler's global config for future bun-
- dle gem use. If no option is specified, the default testing
- framework is RSpec.
-
- -e, --edit[=EDITOR]
- Open the resulting GEM_NAME.gemspec in EDITOR, or the default
- editor if not specified. The default is $BUNDLER_EDITOR, $VIS-
- UAL, or $EDITOR.
-
-SEE ALSO
- o bundle config(1) bundle-config.1.html
-
-
-
-
-
-
- January 2020 BUNDLE-GEM(1)
diff --git a/man/bundle-gem.ronn b/man/bundle-gem.ronn
deleted file mode 100644
index cf3d037df2..0000000000
--- a/man/bundle-gem.ronn
+++ /dev/null
@@ -1,78 +0,0 @@
-bundle-gem(1) -- Generate a project skeleton for creating a rubygem
-====================================================================
-
-## SYNOPSIS
-
-`bundle gem` <GEM_NAME> [OPTIONS]
-
-## DESCRIPTION
-
-Generates a directory named `GEM_NAME` with a `Rakefile`, `GEM_NAME.gemspec`,
-and other supporting files and directories that can be used to develop a
-rubygem with that name.
-
-Run `rake -T` in the resulting project for a list of Rake tasks that can be used
-to test and publish the gem to rubygems.org.
-
-The generated project skeleton can be customized with OPTIONS, as explained
-below. Note that these options can also be specified via Bundler's global
-configuration file using the following names:
-
-* `gem.coc`
-* `gem.mit`
-* `gem.test`
-
-## OPTIONS
-
-* `--exe` or `-b` or `--bin`:
- Specify that Bundler should create a binary executable (as `exe/GEM_NAME`)
- in the generated rubygem project. This binary will also be added to the
- `GEM_NAME.gemspec` manifest. This behavior is disabled by default.
-
-* `--no-exe`:
- Do not create a binary (overrides `--exe` specified in the global config).
-
-* `--coc`:
- Add a `CODE_OF_CONDUCT.md` file to the root of the generated project. If
- this option is unspecified, an interactive prompt will be displayed and the
- answer will be saved in Bundler's global config for future `bundle gem` use.
-
-* `--no-coc`:
- Do not create a `CODE_OF_CONDUCT.md` (overrides `--coc` specified in the
- global config).
-
-* `--ext`:
- Add boilerplate for C extension code to the generated project. This behavior
- is disabled by default.
-
-* `--no-ext`:
- Do not add C extension code (overrides `--ext` specified in the global
- config).
-
-* `--mit`:
- Add an MIT license to a `LICENSE.txt` file in the root of the generated
- project. Your name from the global git config is used for the copyright
- statement. If this option is unspecified, an interactive prompt will be
- displayed and the answer will be saved in Bundler's global config for future
- `bundle gem` use.
-
-* `--no-mit`:
- Do not create a `LICENSE.txt` (overrides `--mit` specified in the global
- config).
-
-* `-t`, `--test=minitest`, `--test=rspec`:
- Specify the test framework that Bundler should use when generating the
- project. Acceptable values are `minitest` and `rspec`. The `GEM_NAME.gemspec`
- will be configured and a skeleton test/spec directory will be created based
- on this option. If this option is unspecified, an interactive prompt will be
- displayed and the answer will be saved in Bundler's global config for future
- `bundle gem` use.
- If no option is specified, the default testing framework is RSpec.
-
-* `-e`, `--edit[=EDITOR]`:
- Open the resulting GEM_NAME.gemspec in EDITOR, or the default editor if not
- specified. The default is `$BUNDLER_EDITOR`, `$VISUAL`, or `$EDITOR`.
-
-## SEE ALSO
-
-* [bundle config(1)](bundle-config.1.html)
diff --git a/man/bundle-info.1 b/man/bundle-info.1
deleted file mode 100644
index d7c73e9bb7..0000000000
--- a/man/bundle-info.1
+++ /dev/null
@@ -1,20 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INFO" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-info\fR \- Show information for the given gem in your bundle
-.
-.SH "SYNOPSIS"
-\fBbundle info\fR [GEM] [\-\-path]
-.
-.SH "DESCRIPTION"
-Print the basic information about the provided GEM such as homepage, version, path and summary\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-path\fR
-Print the path of the given gem
-
diff --git a/man/bundle-info.1.txt b/man/bundle-info.1.txt
deleted file mode 100644
index 67563aa191..0000000000
--- a/man/bundle-info.1.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-BUNDLE-INFO(1) BUNDLE-INFO(1)
-
-
-
-NAME
- bundle-info - Show information for the given gem in your bundle
-
-SYNOPSIS
- bundle info [GEM] [--path]
-
-DESCRIPTION
- Print the basic information about the provided GEM such as homepage,
- version, path and summary.
-
-OPTIONS
- --path Print the path of the given gem
-
-
-
-
- January 2020 BUNDLE-INFO(1)
diff --git a/man/bundle-info.ronn b/man/bundle-info.ronn
deleted file mode 100644
index 47e457aa3c..0000000000
--- a/man/bundle-info.ronn
+++ /dev/null
@@ -1,17 +0,0 @@
-bundle-info(1) -- Show information for the given gem in your bundle
-=========================================================================
-
-## SYNOPSIS
-
-`bundle info` [GEM]
- [--path]
-
-## DESCRIPTION
-
-Print the basic information about the provided GEM such as homepage, version,
-path and summary.
-
-## OPTIONS
-
-* `--path`:
-Print the path of the given gem
diff --git a/man/bundle-init.1 b/man/bundle-init.1
deleted file mode 100644
index 803d4b9be8..0000000000
--- a/man/bundle-init.1
+++ /dev/null
@@ -1,25 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INIT" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-init\fR \- Generates a Gemfile into the current working directory
-.
-.SH "SYNOPSIS"
-\fBbundle init\fR [\-\-gemspec=FILE]
-.
-.SH "DESCRIPTION"
-Init generates a default [\fBGemfile(5)\fR][Gemfile(5)] in the current working directory\. When adding a [\fBGemfile(5)\fR][Gemfile(5)] to a gem with a gemspec, the \fB\-\-gemspec\fR option will automatically add each dependency listed in the gemspec file to the newly created [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-gemspec\fR
-Use the specified \.gemspec to create the [\fBGemfile(5)\fR][Gemfile(5)]
-.
-.SH "FILES"
-Included in the default [\fBGemfile(5)\fR][Gemfile(5)] generated is the line \fB# frozen_string_literal: true\fR\. This is a magic comment supported for the first time in Ruby 2\.3\. The presence of this line results in all string literals in the file being implicitly frozen\.
-.
-.SH "SEE ALSO"
-Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR
diff --git a/man/bundle-init.1.txt b/man/bundle-init.1.txt
deleted file mode 100644
index 2565edbece..0000000000
--- a/man/bundle-init.1.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-BUNDLE-INIT(1) BUNDLE-INIT(1)
-
-
-
-NAME
- bundle-init - Generates a Gemfile into the current working directory
-
-SYNOPSIS
- bundle init [--gemspec=FILE]
-
-DESCRIPTION
- Init generates a default [Gemfile(5)][Gemfile(5)] in the current work-
- ing directory. When adding a [Gemfile(5)][Gemfile(5)] to a gem with a
- gemspec, the --gemspec option will automatically add each dependency
- listed in the gemspec file to the newly created [Gemfile(5)][Gem-
- file(5)].
-
-OPTIONS
- --gemspec
- Use the specified .gemspec to create the [Gemfile(5)][Gem-
- file(5)]
-
-FILES
- Included in the default [Gemfile(5)][Gemfile(5)] generated is the line
- # frozen_string_literal: true. This is a magic comment supported for
- the first time in Ruby 2.3. The presence of this line results in all
- string literals in the file being implicitly frozen.
-
-SEE ALSO
- Gemfile(5) https://bundler.io/man/gemfile.5.html
-
-
-
- January 2020 BUNDLE-INIT(1)
diff --git a/man/bundle-init.ronn b/man/bundle-init.ronn
deleted file mode 100644
index 9d3d97deea..0000000000
--- a/man/bundle-init.ronn
+++ /dev/null
@@ -1,29 +0,0 @@
-bundle-init(1) -- Generates a Gemfile into the current working directory
-========================================================================
-
-## SYNOPSIS
-
-`bundle init` [--gemspec=FILE]
-
-## DESCRIPTION
-
-Init generates a default [`Gemfile(5)`][Gemfile(5)] in the current working directory. When
-adding a [`Gemfile(5)`][Gemfile(5)] to a gem with a gemspec, the `--gemspec` option will
-automatically add each dependency listed in the gemspec file to the newly
-created [`Gemfile(5)`][Gemfile(5)].
-
-## OPTIONS
-
-* `--gemspec`:
- Use the specified .gemspec to create the [`Gemfile(5)`][Gemfile(5)]
-
-## FILES
-
-Included in the default [`Gemfile(5)`][Gemfile(5)]
-generated is the line `# frozen_string_literal: true`. This is a magic comment
-supported for the first time in Ruby 2.3. The presence of this line
-results in all string literals in the file being implicitly frozen.
-
-## SEE ALSO
-
-[Gemfile(5)](https://bundler.io/man/gemfile.5.html)
diff --git a/man/bundle-inject.1 b/man/bundle-inject.1
deleted file mode 100644
index 3370a91573..0000000000
--- a/man/bundle-inject.1
+++ /dev/null
@@ -1,33 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INJECT" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
-.
-.SH "SYNOPSIS"
-\fBbundle inject\fR [GEM] [VERSION]
-.
-.SH "DESCRIPTION"
-Adds the named gem(s) with their version requirements to the resolved [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
-.P
-This command will add the gem to both your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock if it isn\'t listed yet\.
-.
-.P
-Example:
-.
-.IP "" 4
-.
-.nf
-
-bundle install
-bundle inject \'rack\' \'> 0\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-This will inject the \'rack\' gem with a version greater than 0 in your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock
diff --git a/man/bundle-inject.1.txt b/man/bundle-inject.1.txt
deleted file mode 100644
index 4707b99e5f..0000000000
--- a/man/bundle-inject.1.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-BUNDLE-INJECT(1) BUNDLE-INJECT(1)
-
-
-
-NAME
- bundle-inject - Add named gem(s) with version requirements to Gemfile
-
-SYNOPSIS
- bundle inject [GEM] [VERSION]
-
-DESCRIPTION
- Adds the named gem(s) with their version requirements to the resolved
- [Gemfile(5)][Gemfile(5)].
-
- This command will add the gem to both your [Gemfile(5)][Gemfile(5)] and
- Gemfile.lock if it isn't listed yet.
-
- Example:
-
-
-
- bundle install
- bundle inject 'rack' '> 0'
-
-
-
- This will inject the 'rack' gem with a version greater than 0 in your
- [Gemfile(5)][Gemfile(5)] and Gemfile.lock
-
-
-
- January 2020 BUNDLE-INJECT(1)
diff --git a/man/bundle-inject.ronn b/man/bundle-inject.ronn
deleted file mode 100644
index f454341896..0000000000
--- a/man/bundle-inject.ronn
+++ /dev/null
@@ -1,22 +0,0 @@
-bundle-inject(1) -- Add named gem(s) with version requirements to Gemfile
-=========================================================================
-
-## SYNOPSIS
-
-`bundle inject` [GEM] [VERSION]
-
-## DESCRIPTION
-
-Adds the named gem(s) with their version requirements to the resolved
-[`Gemfile(5)`][Gemfile(5)].
-
-This command will add the gem to both your [`Gemfile(5)`][Gemfile(5)] and Gemfile.lock if it
-isn't listed yet.
-
-Example:
-
- bundle install
- bundle inject 'rack' '> 0'
-
-This will inject the 'rack' gem with a version greater than 0 in your
-[`Gemfile(5)`][Gemfile(5)] and Gemfile.lock
diff --git a/man/bundle-install.1 b/man/bundle-install.1
deleted file mode 100644
index 4a289f5c2e..0000000000
--- a/man/bundle-install.1
+++ /dev/null
@@ -1,311 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INSTALL" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-install\fR \- Install the dependencies specified in your Gemfile
-.
-.SH "SYNOPSIS"
-\fBbundle install\fR [\-\-binstubs[=DIRECTORY]] [\-\-clean] [\-\-deployment] [\-\-frozen] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-local] [\-\-no\-cache] [\-\-no\-prune] [\-\-path PATH] [\-\-quiet] [\-\-redownload] [\-\-retry=NUMBER] [\-\-shebang] [\-\-standalone[=GROUP[ GROUP\.\.\.]]] [\-\-system] [\-\-trust\-policy=POLICY] [\-\-with=GROUP[ GROUP\.\.\.]] [\-\-without=GROUP[ GROUP\.\.\.]]
-.
-.SH "DESCRIPTION"
-Install the gems specified in your Gemfile(5)\. If this is the first time you run bundle install (and a \fBGemfile\.lock\fR does not exist), Bundler will fetch all remote sources, resolve dependencies and install all needed gems\.
-.
-.P
-If a \fBGemfile\.lock\fR does exist, and you have not updated your Gemfile(5), Bundler will fetch all remote sources, but use the dependencies specified in the \fBGemfile\.lock\fR instead of resolving dependencies\.
-.
-.P
-If a \fBGemfile\.lock\fR does exist, and you have updated your Gemfile(5), Bundler will use the dependencies in the \fBGemfile\.lock\fR for all gems that you did not update, but will re\-resolve the dependencies of gems that you did update\. You can find more information about this update process below under \fICONSERVATIVE UPDATING\fR\.
-.
-.SH "OPTIONS"
-To apply any of \fB\-\-binstubs\fR, \fB\-\-deployment\fR, \fB\-\-path\fR, or \fB\-\-without\fR every time \fBbundle install\fR is run, use \fBbundle config\fR (see bundle\-config(1))\.
-.
-.TP
-\fB\-\-binstubs[=<directory>]\fR
-Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it in \fBbin/\fR\. This lets you link the binstub inside of an application to the exact gem version the application needs\.
-.
-.IP
-Creates a directory (defaults to \fB~/bin\fR) and places any executables from the gem there\. These executables run in Bundler\'s context\. If used, you might add this directory to your environment\'s \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
-.
-.TP
-\fB\-\-clean\fR
-On finishing the installation Bundler is going to remove any gems not present in the current Gemfile(5)\. Don\'t worry, gems currently in use will not be removed\.
-.
-.TP
-\fB\-\-deployment\fR
-In \fIdeployment mode\fR, Bundler will \'roll\-out\' the bundle for production or CI use\. Please check carefully if you want to have this option enabled in your development environment\.
-.
-.TP
-\fB\-\-redownload\fR
-Force download every gem, even if the required versions are already available locally\.
-.
-.TP
-\fB\-\-frozen\fR
-Do not allow the Gemfile\.lock to be updated after this install\. Exits non\-zero if there are going to be changes to the Gemfile\.lock\.
-.
-.TP
-\fB\-\-full\-index\fR
-Bundler will not call Rubygems\' API endpoint (default) but download and cache a (currently big) index file of all gems\. Performance can be improved for large bundles that seldom change by enabling this option\.
-.
-.TP
-\fB\-\-gemfile=<gemfile>\fR
-The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project\'s root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
-.
-.TP
-\fB\-\-jobs=[<number>]\fR, \fB\-j[<number>]\fR
-The maximum number of parallel download and install jobs\. The default is \fB1\fR\.
-.
-.TP
-\fB\-\-local\fR
-Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems\' cache or in \fBvendor/cache\fR\. Note that if a appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
-.
-.TP
-\fB\-\-no\-cache\fR
-Do not update the cache in \fBvendor/cache\fR with the newly bundled gems\. This does not remove any gems in the cache but keeps the newly bundled gems from being cached during the install\.
-.
-.TP
-\fB\-\-no\-prune\fR
-Don\'t remove stale gems from the cache when the installation finishes\.
-.
-.TP
-\fB\-\-path=<path>\fR
-The location to install the specified gems to\. This defaults to Rubygems\' setting\. Bundler shares this location with Rubygems, \fBgem install \.\.\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \.\.\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
-.
-.TP
-\fB\-\-quiet\fR
-Do not print progress information to the standard output\. Instead, Bundler will exit using a status code (\fB$?\fR)\.
-.
-.TP
-\fB\-\-retry=[<number>]\fR
-Retry failed network or git requests for \fInumber\fR times\.
-.
-.TP
-\fB\-\-shebang=<ruby\-executable>\fR
-Uses the specified ruby executable (usually \fBruby\fR) to execute the scripts created with \fB\-\-binstubs\fR\. In addition, if you use \fB\-\-binstubs\fR together with \fB\-\-shebang jruby\fR these executables will be changed to execute \fBjruby\fR instead\.
-.
-.TP
-\fB\-\-standalone[=<list>]\fR
-Makes a bundle that can work without depending on Rubygems or Bundler at runtime\. A space separated list of groups to install has to be specified\. Bundler creates a directory named \fBbundle\fR and installs the bundle there\. It also generates a \fBbundle/bundler/setup\.rb\fR file to replace Bundler\'s own setup in the manner required\. Using this option implicitly sets \fBpath\fR, which is a [remembered option][REMEMBERED OPTIONS]\.
-.
-.TP
-\fB\-\-system\fR
-Installs the gems specified in the bundle to the system\'s Rubygems location\. This overrides any previous configuration of \fB\-\-path\fR\.
-.
-.TP
-\fB\-\-trust\-policy=[<policy>]\fR
-Apply the Rubygems security policy \fIpolicy\fR, where policy is one of \fBHighSecurity\fR, \fBMediumSecurity\fR, \fBLowSecurity\fR, \fBAlmostNoSecurity\fR, or \fBNoSecurity\fR\. For more details, please see the Rubygems signing documentation linked below in \fISEE ALSO\fR\.
-.
-.TP
-\fB\-\-with=<list>\fR
-A space\-separated list of groups referencing gems to install\. If an optional group is given it is installed\. If a group is given that is in the remembered list of groups given to \-\-without, it is removed from that list\.
-.
-.TP
-\fB\-\-without=<list>\fR
-A space\-separated list of groups referencing gems to skip during installation\. If a group is given that is in the remembered list of groups given to \-\-with, it is removed from that list\.
-.
-.SH "DEPLOYMENT MODE"
-Bundler\'s defaults are optimized for development\. To switch to defaults optimized for deployment and for CI, use the \fB\-\-deployment\fR flag\. Do not activate deployment mode on development machines, as it will cause an error when the Gemfile(5) is modified\.
-.
-.IP "1." 4
-A \fBGemfile\.lock\fR is required\.
-.
-.IP
-To ensure that the same versions of the gems you developed with and tested with are also used in deployments, a \fBGemfile\.lock\fR is required\.
-.
-.IP
-This is mainly to ensure that you remember to check your \fBGemfile\.lock\fR into version control\.
-.
-.IP "2." 4
-The \fBGemfile\.lock\fR must be up to date
-.
-.IP
-In development, you can modify your Gemfile(5) and re\-run \fBbundle install\fR to \fIconservatively update\fR your \fBGemfile\.lock\fR snapshot\.
-.
-.IP
-In deployment, your \fBGemfile\.lock\fR should be up\-to\-date with changes made in your Gemfile(5)\.
-.
-.IP "3." 4
-Gems are installed to \fBvendor/bundle\fR not your default system location
-.
-.IP
-In development, it\'s convenient to share the gems used in your application with other applications and other scripts that run on the system\.
-.
-.IP
-In deployment, isolation is a more important default\. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them\.
-.
-.IP
-As a result, \fBbundle install \-\-deployment\fR installs gems to the \fBvendor/bundle\fR directory in the application\. This may be overridden using the \fB\-\-path\fR option\.
-.
-.IP "" 0
-.
-.SH "SUDO USAGE"
-By default, Bundler installs gems to the same location as \fBgem install\fR\.
-.
-.P
-In some cases, that location may not be writable by your Unix user\. In that case, Bundler will stage everything in a temporary directory, then ask you for your \fBsudo\fR password in order to copy the gems into their system location\.
-.
-.P
-From your perspective, this is identical to installing the gems directly into the system\.
-.
-.P
-You should never use \fBsudo bundle install\fR\. This is because several other steps in \fBbundle install\fR must be performed as the current user:
-.
-.IP "\(bu" 4
-Updating your \fBGemfile\.lock\fR
-.
-.IP "\(bu" 4
-Updating your \fBvendor/cache\fR, if necessary
-.
-.IP "\(bu" 4
-Checking out private git repositories using your user\'s SSH keys
-.
-.IP "" 0
-.
-.P
-Of these three, the first two could theoretically be performed by \fBchown\fRing the resulting files to \fB$SUDO_USER\fR\. The third, however, can only be performed by invoking the \fBgit\fR command as the current user\. Therefore, git gems are downloaded and installed into \fB~/\.bundle\fR rather than $GEM_HOME or $BUNDLE_PATH\.
-.
-.P
-As a result, you should run \fBbundle install\fR as the current user, and Bundler will ask for your password if it is needed to put the gems into their final location\.
-.
-.SH "INSTALLING GROUPS"
-By default, \fBbundle install\fR will install all gems in all groups in your Gemfile(5), except those declared for a different platform\.
-.
-.P
-However, you can explicitly tell Bundler to skip installing certain groups with the \fB\-\-without\fR option\. This option takes a space\-separated list of groups\.
-.
-.P
-While the \fB\-\-without\fR option will skip \fIinstalling\fR the gems in the specified groups, it will still \fIdownload\fR those gems and use them to resolve the dependencies of every gem in your Gemfile(5)\.
-.
-.P
-This is so that installing a different set of groups on another machine (such as a production server) will not change the gems and versions that you have already developed and tested against\.
-.
-.P
-\fBBundler offers a rock\-solid guarantee that the third\-party code you are running in development and testing is also the third\-party code you are running in production\. You can choose to exclude some of that code in different environments, but you will never be caught flat\-footed by different versions of third\-party code being used in different environments\.\fR
-.
-.P
-For a simple illustration, consider the following Gemfile(5):
-.
-.IP "" 4
-.
-.nf
-
-source \'https://rubygems\.org\'
-
-gem \'sinatra\'
-
-group :production do
- gem \'rack\-perftools\-profiler\'
-end
-.
-.fi
-.
-.IP "" 0
-.
-.P
-In this case, \fBsinatra\fR depends on any version of Rack (\fB>= 1\.0\fR), while \fBrack\-perftools\-profiler\fR depends on 1\.x (\fB~> 1\.0\fR)\.
-.
-.P
-When you run \fBbundle install \-\-without production\fR in development, we look at the dependencies of \fBrack\-perftools\-profiler\fR as well\. That way, you do not spend all your time developing against Rack 2\.0, using new APIs unavailable in Rack 1\.x, only to have Bundler switch to Rack 1\.2 when the \fBproduction\fR group \fIis\fR used\.
-.
-.P
-This should not cause any problems in practice, because we do not attempt to \fBinstall\fR the gems in the excluded groups, and only evaluate as part of the dependency resolution process\.
-.
-.P
-This also means that you cannot include different versions of the same gem in different groups, because doing so would result in different sets of dependencies used in development and production\. Because of the vagaries of the dependency resolution process, this usually affects more than the gems you list in your Gemfile(5), and can (surprisingly) radically change the gems you are using\.
-.
-.SH "THE GEMFILE\.LOCK"
-When you run \fBbundle install\fR, Bundler will persist the full names and versions of all gems that you used (including dependencies of the gems specified in the Gemfile(5)) into a file called \fBGemfile\.lock\fR\.
-.
-.P
-Bundler uses this file in all subsequent calls to \fBbundle install\fR, which guarantees that you always use the same exact code, even as your application moves across machines\.
-.
-.P
-Because of the way dependency resolution works, even a seemingly small change (for instance, an update to a point\-release of a dependency of a gem in your Gemfile(5)) can result in radically different gems being needed to satisfy all dependencies\.
-.
-.P
-As a result, you \fBSHOULD\fR check your \fBGemfile\.lock\fR into version control, in both applications and gems\. If you do not, every machine that checks out your repository (including your production server) will resolve all dependencies again, which will result in different versions of third\-party code being used if \fBany\fR of the gems in the Gemfile(5) or any of their dependencies have been updated\.
-.
-.P
-When Bundler first shipped, the \fBGemfile\.lock\fR was included in the \fB\.gitignore\fR file included with generated gems\. Over time, however, it became clear that this practice forces the pain of broken dependencies onto new contributors, while leaving existing contributors potentially unaware of the problem\. Since \fBbundle install\fR is usually the first step towards a contribution, the pain of broken dependencies would discourage new contributors from contributing\. As a result, we have revised our guidance for gem authors to now recommend checking in the lock for gems\.
-.
-.SH "CONSERVATIVE UPDATING"
-When you make a change to the Gemfile(5) and then run \fBbundle install\fR, Bundler will update only the gems that you modified\.
-.
-.P
-In other words, if a gem that you \fBdid not modify\fR worked before you called \fBbundle install\fR, it will continue to use the exact same versions of all dependencies as it used before the update\.
-.
-.P
-Let\'s take a look at an example\. Here\'s your original Gemfile(5):
-.
-.IP "" 4
-.
-.nf
-
-source \'https://rubygems\.org\'
-
-gem \'actionpack\', \'2\.3\.8\'
-gem \'activemerchant\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-In this case, both \fBactionpack\fR and \fBactivemerchant\fR depend on \fBactivesupport\fR\. The \fBactionpack\fR gem depends on \fBactivesupport 2\.3\.8\fR and \fBrack ~> 1\.1\.0\fR, while the \fBactivemerchant\fR gem depends on \fBactivesupport >= 2\.3\.2\fR, \fBbraintree >= 2\.0\.0\fR, and \fBbuilder >= 2\.0\.0\fR\.
-.
-.P
-When the dependencies are first resolved, Bundler will select \fBactivesupport 2\.3\.8\fR, which satisfies the requirements of both gems in your Gemfile(5)\.
-.
-.P
-Next, you modify your Gemfile(5) to:
-.
-.IP "" 4
-.
-.nf
-
-source \'https://rubygems\.org\'
-
-gem \'actionpack\', \'3\.0\.0\.rc\'
-gem \'activemerchant\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-The \fBactionpack 3\.0\.0\.rc\fR gem has a number of new dependencies, and updates the \fBactivesupport\fR dependency to \fB= 3\.0\.0\.rc\fR and the \fBrack\fR dependency to \fB~> 1\.2\.1\fR\.
-.
-.P
-When you run \fBbundle install\fR, Bundler notices that you changed the \fBactionpack\fR gem, but not the \fBactivemerchant\fR gem\. It evaluates the gems currently being used to satisfy its requirements:
-.
-.TP
-\fBactivesupport 2\.3\.8\fR
-also used to satisfy a dependency in \fBactivemerchant\fR, which is not being updated
-.
-.TP
-\fBrack ~> 1\.1\.0\fR
-not currently being used to satisfy another dependency
-.
-.P
-Because you did not explicitly ask to update \fBactivemerchant\fR, you would not expect it to suddenly stop working after updating \fBactionpack\fR\. However, satisfying the new \fBactivesupport 3\.0\.0\.rc\fR dependency of actionpack requires updating one of its dependencies\.
-.
-.P
-Even though \fBactivemerchant\fR declares a very loose dependency that theoretically matches \fBactivesupport 3\.0\.0\.rc\fR, Bundler treats gems in your Gemfile(5) that have not changed as an atomic unit together with their dependencies\. In this case, the \fBactivemerchant\fR dependency is treated as \fBactivemerchant 1\.7\.1 + activesupport 2\.3\.8\fR, so \fBbundle install\fR will report that it cannot update \fBactionpack\fR\.
-.
-.P
-To explicitly update \fBactionpack\fR, including its dependencies which other gems in the Gemfile(5) still depend on, run \fBbundle update actionpack\fR (see \fBbundle update(1)\fR)\.
-.
-.P
-\fBSummary\fR: In general, after making a change to the Gemfile(5) , you should first try to run \fBbundle install\fR, which will guarantee that no other gem in the Gemfile(5) is impacted by the change\. If that does not work, run bundle update(1) \fIbundle\-update\.1\.html\fR\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-Gem install docs \fIhttp://guides\.rubygems\.org/rubygems\-basics/#installing\-gems\fR
-.
-.IP "\(bu" 4
-Rubygems signing docs \fIhttp://guides\.rubygems\.org/security/\fR
-.
-.IP "" 0
-
diff --git a/man/bundle-install.1.txt b/man/bundle-install.1.txt
deleted file mode 100644
index b1a9ad1eb3..0000000000
--- a/man/bundle-install.1.txt
+++ /dev/null
@@ -1,401 +0,0 @@
-BUNDLE-INSTALL(1) BUNDLE-INSTALL(1)
-
-
-
-NAME
- bundle-install - Install the dependencies specified in your Gemfile
-
-SYNOPSIS
- bundle install [--binstubs[=DIRECTORY]] [--clean] [--deployment]
- [--frozen] [--full-index] [--gemfile=GEMFILE] [--jobs=NUMBER] [--local]
- [--no-cache] [--no-prune] [--path PATH] [--quiet] [--redownload]
- [--retry=NUMBER] [--shebang] [--standalone[=GROUP[ GROUP...]]] [--sys-
- tem] [--trust-policy=POLICY] [--with=GROUP[ GROUP...]] [--with-
- out=GROUP[ GROUP...]]
-
-DESCRIPTION
- Install the gems specified in your Gemfile(5). If this is the first
- time you run bundle install (and a Gemfile.lock does not exist),
- Bundler will fetch all remote sources, resolve dependencies and install
- all needed gems.
-
- If a Gemfile.lock does exist, and you have not updated your Gemfile(5),
- Bundler will fetch all remote sources, but use the dependencies speci-
- fied in the Gemfile.lock instead of resolving dependencies.
-
- If a Gemfile.lock does exist, and you have updated your Gemfile(5),
- Bundler will use the dependencies in the Gemfile.lock for all gems that
- you did not update, but will re-resolve the dependencies of gems that
- you did update. You can find more information about this update process
- below under CONSERVATIVE UPDATING.
-
-OPTIONS
- To apply any of --binstubs, --deployment, --path, or --without every
- time bundle install is run, use bundle config (see bundle-config(1)).
-
- --binstubs[=<directory>]
- Binstubs are scripts that wrap around executables. Bundler cre-
- ates a small Ruby file (a binstub) that loads Bundler, runs the
- command, and puts it in bin/. This lets you link the binstub
- inside of an application to the exact gem version the applica-
- tion needs.
-
- Creates a directory (defaults to ~/bin) and places any executa-
- bles from the gem there. These executables run in Bundler's con-
- text. If used, you might add this directory to your environ-
- ment's PATH variable. For instance, if the rails gem comes with
- a rails executable, this flag will create a bin/rails executable
- that ensures that all referred dependencies will be resolved
- using the bundled gems.
-
- --clean
- On finishing the installation Bundler is going to remove any
- gems not present in the current Gemfile(5). Don't worry, gems
- currently in use will not be removed.
-
- --deployment
- In deployment mode, Bundler will 'roll-out' the bundle for pro-
- duction or CI use. Please check carefully if you want to have
- this option enabled in your development environment.
-
- --redownload
- Force download every gem, even if the required versions are
- already available locally.
-
- --frozen
- Do not allow the Gemfile.lock to be updated after this install.
- Exits non-zero if there are going to be changes to the Gem-
- file.lock.
-
- --full-index
- Bundler will not call Rubygems' API endpoint (default) but down-
- load and cache a (currently big) index file of all gems. Perfor-
- mance can be improved for large bundles that seldom change by
- enabling this option.
-
- --gemfile=<gemfile>
- The location of the Gemfile(5) which Bundler should use. This
- defaults to a Gemfile(5) in the current working directory. In
- general, Bundler will assume that the location of the Gemfile(5)
- is also the project's root and will try to find Gemfile.lock and
- vendor/cache relative to this location.
-
- --jobs=[<number>], -j[<number>]
- The maximum number of parallel download and install jobs. The
- default is 1.
-
- --local
- Do not attempt to connect to rubygems.org. Instead, Bundler will
- use the gems already present in Rubygems' cache or in ven-
- dor/cache. Note that if a appropriate platform-specific gem
- exists on rubygems.org it will not be found.
-
- --no-cache
- Do not update the cache in vendor/cache with the newly bundled
- gems. This does not remove any gems in the cache but keeps the
- newly bundled gems from being cached during the install.
-
- --no-prune
- Don't remove stale gems from the cache when the installation
- finishes.
-
- --path=<path>
- The location to install the specified gems to. This defaults to
- Rubygems' setting. Bundler shares this location with Rubygems,
- gem install ... will have gem installed there, too. Therefore,
- gems installed without a --path ... setting will show up by
- calling gem list. Accordingly, gems installed to other locations
- will not get listed.
-
- --quiet
- Do not print progress information to the standard output.
- Instead, Bundler will exit using a status code ($?).
-
- --retry=[<number>]
- Retry failed network or git requests for number times.
-
- --shebang=<ruby-executable>
- Uses the specified ruby executable (usually ruby) to execute the
- scripts created with --binstubs. In addition, if you use --bin-
- stubs together with --shebang jruby these executables will be
- changed to execute jruby instead.
-
- --standalone[=<list>]
- Makes a bundle that can work without depending on Rubygems or
- Bundler at runtime. A space separated list of groups to install
- has to be specified. Bundler creates a directory named bundle
- and installs the bundle there. It also generates a bun-
- dle/bundler/setup.rb file to replace Bundler's own setup in the
- manner required. Using this option implicitly sets path, which
- is a [remembered option][REMEMBERED OPTIONS].
-
- --system
- Installs the gems specified in the bundle to the system's
- Rubygems location. This overrides any previous configuration of
- --path.
-
- --trust-policy=[<policy>]
- Apply the Rubygems security policy policy, where policy is one
- of HighSecurity, MediumSecurity, LowSecurity, AlmostNoSecurity,
- or NoSecurity. For more details, please see the Rubygems signing
- documentation linked below in SEE ALSO.
-
- --with=<list>
- A space-separated list of groups referencing gems to install. If
- an optional group is given it is installed. If a group is given
- that is in the remembered list of groups given to --without, it
- is removed from that list.
-
- --without=<list>
- A space-separated list of groups referencing gems to skip during
- installation. If a group is given that is in the remembered list
- of groups given to --with, it is removed from that list.
-
-DEPLOYMENT MODE
- Bundler's defaults are optimized for development. To switch to defaults
- optimized for deployment and for CI, use the --deployment flag. Do not
- activate deployment mode on development machines, as it will cause an
- error when the Gemfile(5) is modified.
-
- 1. A Gemfile.lock is required.
-
- To ensure that the same versions of the gems you developed with and
- tested with are also used in deployments, a Gemfile.lock is
- required.
-
- This is mainly to ensure that you remember to check your Gem-
- file.lock into version control.
-
- 2. The Gemfile.lock must be up to date
-
- In development, you can modify your Gemfile(5) and re-run bundle
- install to conservatively update your Gemfile.lock snapshot.
-
- In deployment, your Gemfile.lock should be up-to-date with changes
- made in your Gemfile(5).
-
- 3. Gems are installed to vendor/bundle not your default system loca-
- tion
-
- In development, it's convenient to share the gems used in your
- application with other applications and other scripts that run on
- the system.
-
- In deployment, isolation is a more important default. In addition,
- the user deploying the application may not have permission to
- install gems to the system, or the web server may not have permis-
- sion to read them.
-
- As a result, bundle install --deployment installs gems to the ven-
- dor/bundle directory in the application. This may be overridden
- using the --path option.
-
-
-
-SUDO USAGE
- By default, Bundler installs gems to the same location as gem install.
-
- In some cases, that location may not be writable by your Unix user. In
- that case, Bundler will stage everything in a temporary directory, then
- ask you for your sudo password in order to copy the gems into their
- system location.
-
- From your perspective, this is identical to installing the gems
- directly into the system.
-
- You should never use sudo bundle install. This is because several other
- steps in bundle install must be performed as the current user:
-
- o Updating your Gemfile.lock
-
- o Updating your vendor/cache, if necessary
-
- o Checking out private git repositories using your user's SSH keys
-
-
-
- Of these three, the first two could theoretically be performed by
- chowning the resulting files to $SUDO_USER. The third, however, can
- only be performed by invoking the git command as the current user.
- Therefore, git gems are downloaded and installed into ~/.bundle rather
- than $GEM_HOME or $BUNDLE_PATH.
-
- As a result, you should run bundle install as the current user, and
- Bundler will ask for your password if it is needed to put the gems into
- their final location.
-
-INSTALLING GROUPS
- By default, bundle install will install all gems in all groups in your
- Gemfile(5), except those declared for a different platform.
-
- However, you can explicitly tell Bundler to skip installing certain
- groups with the --without option. This option takes a space-separated
- list of groups.
-
- While the --without option will skip installing the gems in the speci-
- fied groups, it will still download those gems and use them to resolve
- the dependencies of every gem in your Gemfile(5).
-
- This is so that installing a different set of groups on another machine
- (such as a production server) will not change the gems and versions
- that you have already developed and tested against.
-
- Bundler offers a rock-solid guarantee that the third-party code you are
- running in development and testing is also the third-party code you are
- running in production. You can choose to exclude some of that code in
- different environments, but you will never be caught flat-footed by
- different versions of third-party code being used in different environ-
- ments.
-
- For a simple illustration, consider the following Gemfile(5):
-
-
-
- source 'https://rubygems.org'
-
- gem 'sinatra'
-
- group :production do
- gem 'rack-perftools-profiler'
- end
-
-
-
- In this case, sinatra depends on any version of Rack (>= 1.0), while
- rack-perftools-profiler depends on 1.x (~> 1.0).
-
- When you run bundle install --without production in development, we
- look at the dependencies of rack-perftools-profiler as well. That way,
- you do not spend all your time developing against Rack 2.0, using new
- APIs unavailable in Rack 1.x, only to have Bundler switch to Rack 1.2
- when the production group is used.
-
- This should not cause any problems in practice, because we do not
- attempt to install the gems in the excluded groups, and only evaluate
- as part of the dependency resolution process.
-
- This also means that you cannot include different versions of the same
- gem in different groups, because doing so would result in different
- sets of dependencies used in development and production. Because of the
- vagaries of the dependency resolution process, this usually affects
- more than the gems you list in your Gemfile(5), and can (surprisingly)
- radically change the gems you are using.
-
-THE GEMFILE.LOCK
- When you run bundle install, Bundler will persist the full names and
- versions of all gems that you used (including dependencies of the gems
- specified in the Gemfile(5)) into a file called Gemfile.lock.
-
- Bundler uses this file in all subsequent calls to bundle install, which
- guarantees that you always use the same exact code, even as your appli-
- cation moves across machines.
-
- Because of the way dependency resolution works, even a seemingly small
- change (for instance, an update to a point-release of a dependency of a
- gem in your Gemfile(5)) can result in radically different gems being
- needed to satisfy all dependencies.
-
- As a result, you SHOULD check your Gemfile.lock into version control,
- in both applications and gems. If you do not, every machine that checks
- out your repository (including your production server) will resolve all
- dependencies again, which will result in different versions of
- third-party code being used if any of the gems in the Gemfile(5) or any
- of their dependencies have been updated.
-
- When Bundler first shipped, the Gemfile.lock was included in the .git-
- ignore file included with generated gems. Over time, however, it became
- clear that this practice forces the pain of broken dependencies onto
- new contributors, while leaving existing contributors potentially
- unaware of the problem. Since bundle install is usually the first step
- towards a contribution, the pain of broken dependencies would discour-
- age new contributors from contributing. As a result, we have revised
- our guidance for gem authors to now recommend checking in the lock for
- gems.
-
-CONSERVATIVE UPDATING
- When you make a change to the Gemfile(5) and then run bundle install,
- Bundler will update only the gems that you modified.
-
- In other words, if a gem that you did not modify worked before you
- called bundle install, it will continue to use the exact same versions
- of all dependencies as it used before the update.
-
- Let's take a look at an example. Here's your original Gemfile(5):
-
-
-
- source 'https://rubygems.org'
-
- gem 'actionpack', '2.3.8'
- gem 'activemerchant'
-
-
-
- In this case, both actionpack and activemerchant depend on activesup-
- port. The actionpack gem depends on activesupport 2.3.8 and rack ~>
- 1.1.0, while the activemerchant gem depends on activesupport >= 2.3.2,
- braintree >= 2.0.0, and builder >= 2.0.0.
-
- When the dependencies are first resolved, Bundler will select
- activesupport 2.3.8, which satisfies the requirements of both gems in
- your Gemfile(5).
-
- Next, you modify your Gemfile(5) to:
-
-
-
- source 'https://rubygems.org'
-
- gem 'actionpack', '3.0.0.rc'
- gem 'activemerchant'
-
-
-
- The actionpack 3.0.0.rc gem has a number of new dependencies, and
- updates the activesupport dependency to = 3.0.0.rc and the rack depen-
- dency to ~> 1.2.1.
-
- When you run bundle install, Bundler notices that you changed the
- actionpack gem, but not the activemerchant gem. It evaluates the gems
- currently being used to satisfy its requirements:
-
- activesupport 2.3.8
- also used to satisfy a dependency in activemerchant, which is
- not being updated
-
- rack ~> 1.1.0
- not currently being used to satisfy another dependency
-
- Because you did not explicitly ask to update activemerchant, you would
- not expect it to suddenly stop working after updating actionpack. How-
- ever, satisfying the new activesupport 3.0.0.rc dependency of action-
- pack requires updating one of its dependencies.
-
- Even though activemerchant declares a very loose dependency that theo-
- retically matches activesupport 3.0.0.rc, Bundler treats gems in your
- Gemfile(5) that have not changed as an atomic unit together with their
- dependencies. In this case, the activemerchant dependency is treated as
- activemerchant 1.7.1 + activesupport 2.3.8, so bundle install will
- report that it cannot update actionpack.
-
- To explicitly update actionpack, including its dependencies which other
- gems in the Gemfile(5) still depend on, run bundle update actionpack
- (see bundle update(1)).
-
- Summary: In general, after making a change to the Gemfile(5) , you
- should first try to run bundle install, which will guarantee that no
- other gem in the Gemfile(5) is impacted by the change. If that does not
- work, run bundle update(1) bundle-update.1.html.
-
-SEE ALSO
- o Gem install docs
- http://guides.rubygems.org/rubygems-basics/#installing-gems
-
- o Rubygems signing docs http://guides.rubygems.org/security/
-
-
-
-
-
-
- January 2020 BUNDLE-INSTALL(1)
diff --git a/man/bundle-install.ronn b/man/bundle-install.ronn
deleted file mode 100644
index 2ba82f27a5..0000000000
--- a/man/bundle-install.ronn
+++ /dev/null
@@ -1,383 +0,0 @@
-bundle-install(1) -- Install the dependencies specified in your Gemfile
-=======================================================================
-
-## SYNOPSIS
-
-`bundle install` [--binstubs[=DIRECTORY]]
- [--clean]
- [--deployment]
- [--frozen]
- [--full-index]
- [--gemfile=GEMFILE]
- [--jobs=NUMBER]
- [--local]
- [--no-cache]
- [--no-prune]
- [--path PATH]
- [--quiet]
- [--redownload]
- [--retry=NUMBER]
- [--shebang]
- [--standalone[=GROUP[ GROUP...]]]
- [--system]
- [--trust-policy=POLICY]
- [--with=GROUP[ GROUP...]]
- [--without=GROUP[ GROUP...]]
-
-## DESCRIPTION
-
-Install the gems specified in your Gemfile(5). If this is the first
-time you run bundle install (and a `Gemfile.lock` does not exist),
-Bundler will fetch all remote sources, resolve dependencies and
-install all needed gems.
-
-If a `Gemfile.lock` does exist, and you have not updated your Gemfile(5),
-Bundler will fetch all remote sources, but use the dependencies
-specified in the `Gemfile.lock` instead of resolving dependencies.
-
-If a `Gemfile.lock` does exist, and you have updated your Gemfile(5),
-Bundler will use the dependencies in the `Gemfile.lock` for all gems
-that you did not update, but will re-resolve the dependencies of
-gems that you did update. You can find more information about this
-update process below under [CONSERVATIVE UPDATING][].
-
-## OPTIONS
-
-To apply any of `--binstubs`, `--deployment`, `--path`, or `--without` every
-time `bundle install` is run, use `bundle config` (see bundle-config(1)).
-
-* `--binstubs[=<directory>]`:
- Binstubs are scripts that wrap around executables. Bundler creates a small Ruby
- file (a binstub) that loads Bundler, runs the command, and puts it in `bin/`.
- This lets you link the binstub inside of an application to the exact gem
- version the application needs.
-
- Creates a directory (defaults to `~/bin`) and places any executables from the
- gem there. These executables run in Bundler's context. If used, you might add
- this directory to your environment's `PATH` variable. For instance, if the
- `rails` gem comes with a `rails` executable, this flag will create a
- `bin/rails` executable that ensures that all referred dependencies will be
- resolved using the bundled gems.
-
-* `--clean`:
- On finishing the installation Bundler is going to remove any gems not present
- in the current Gemfile(5). Don't worry, gems currently in use will not be
- removed.
-
-* `--deployment`:
- In [deployment mode][DEPLOYMENT MODE], Bundler will 'roll-out' the bundle for
- production or CI use. Please check carefully if you want to have this option
- enabled in your development environment.
-
-* `--redownload`:
- Force download every gem, even if the required versions are already available
- locally.
-
-* `--frozen`:
- Do not allow the Gemfile.lock to be updated after this install. Exits
- non-zero if there are going to be changes to the Gemfile.lock.
-
-* `--full-index`:
- Bundler will not call Rubygems' API endpoint (default) but download and cache
- a (currently big) index file of all gems. Performance can be improved for
- large bundles that seldom change by enabling this option.
-
-* `--gemfile=<gemfile>`:
- The location of the Gemfile(5) which Bundler should use. This defaults
- to a Gemfile(5) in the current working directory. In general, Bundler
- will assume that the location of the Gemfile(5) is also the project's
- root and will try to find `Gemfile.lock` and `vendor/cache` relative
- to this location.
-
-* `--jobs=[<number>]`, `-j[<number>]`:
- The maximum number of parallel download and install jobs. The default
- is `1`.
-
-* `--local`:
- Do not attempt to connect to `rubygems.org`. Instead, Bundler will use the
- gems already present in Rubygems' cache or in `vendor/cache`. Note that if a
- appropriate platform-specific gem exists on `rubygems.org` it will not be
- found.
-
-* `--no-cache`:
- Do not update the cache in `vendor/cache` with the newly bundled gems. This
- does not remove any gems in the cache but keeps the newly bundled gems from
- being cached during the install.
-
-* `--no-prune`:
- Don't remove stale gems from the cache when the installation finishes.
-
-* `--path=<path>`:
- The location to install the specified gems to. This defaults to Rubygems'
- setting. Bundler shares this location with Rubygems, `gem install ...` will
- have gem installed there, too. Therefore, gems installed without a
- `--path ...` setting will show up by calling `gem list`. Accordingly, gems
- installed to other locations will not get listed.
-
-* `--quiet`:
- Do not print progress information to the standard output. Instead, Bundler
- will exit using a status code (`$?`).
-
-* `--retry=[<number>]`:
- Retry failed network or git requests for <number> times.
-
-* `--shebang=<ruby-executable>`:
- Uses the specified ruby executable (usually `ruby`) to execute the scripts
- created with `--binstubs`. In addition, if you use `--binstubs` together with
- `--shebang jruby` these executables will be changed to execute `jruby`
- instead.
-
-* `--standalone[=<list>]`:
- Makes a bundle that can work without depending on Rubygems or Bundler at
- runtime. A space separated list of groups to install has to be specified.
- Bundler creates a directory named `bundle` and installs the bundle there. It
- also generates a `bundle/bundler/setup.rb` file to replace Bundler's own setup
- in the manner required. Using this option implicitly sets `path`, which is a
- [remembered option][REMEMBERED OPTIONS].
-
-* `--system`:
- Installs the gems specified in the bundle to the system's Rubygems location.
- This overrides any previous configuration of `--path`.
-
-* `--trust-policy=[<policy>]`:
- Apply the Rubygems security policy <policy>, where policy is one of
- `HighSecurity`, `MediumSecurity`, `LowSecurity`, `AlmostNoSecurity`, or
- `NoSecurity`. For more details, please see the Rubygems signing documentation
- linked below in [SEE ALSO][].
-
-* `--with=<list>`:
- A space-separated list of groups referencing gems to install. If an
- optional group is given it is installed. If a group is given that is
- in the remembered list of groups given to --without, it is removed
- from that list.
-
-* `--without=<list>`:
- A space-separated list of groups referencing gems to skip during installation.
- If a group is given that is in the remembered list of groups given
- to --with, it is removed from that list.
-
-## DEPLOYMENT MODE
-
-Bundler's defaults are optimized for development. To switch to
-defaults optimized for deployment and for CI, use the `--deployment`
-flag. Do not activate deployment mode on development machines, as it
-will cause an error when the Gemfile(5) is modified.
-
-1. A `Gemfile.lock` is required.
-
- To ensure that the same versions of the gems you developed with
- and tested with are also used in deployments, a `Gemfile.lock`
- is required.
-
- This is mainly to ensure that you remember to check your
- `Gemfile.lock` into version control.
-
-2. The `Gemfile.lock` must be up to date
-
- In development, you can modify your Gemfile(5) and re-run
- `bundle install` to [conservatively update][CONSERVATIVE UPDATING]
- your `Gemfile.lock` snapshot.
-
- In deployment, your `Gemfile.lock` should be up-to-date with
- changes made in your Gemfile(5).
-
-3. Gems are installed to `vendor/bundle` not your default system location
-
- In development, it's convenient to share the gems used in your
- application with other applications and other scripts that run on
- the system.
-
- In deployment, isolation is a more important default. In addition,
- the user deploying the application may not have permission to install
- gems to the system, or the web server may not have permission to
- read them.
-
- As a result, `bundle install --deployment` installs gems to
- the `vendor/bundle` directory in the application. This may be
- overridden using the `--path` option.
-
-## SUDO USAGE
-
-By default, Bundler installs gems to the same location as `gem install`.
-
-In some cases, that location may not be writable by your Unix user. In
-that case, Bundler will stage everything in a temporary directory,
-then ask you for your `sudo` password in order to copy the gems into
-their system location.
-
-From your perspective, this is identical to installing the gems
-directly into the system.
-
-You should never use `sudo bundle install`. This is because several
-other steps in `bundle install` must be performed as the current user:
-
-* Updating your `Gemfile.lock`
-* Updating your `vendor/cache`, if necessary
-* Checking out private git repositories using your user's SSH keys
-
-Of these three, the first two could theoretically be performed by
-`chown`ing the resulting files to `$SUDO_USER`. The third, however,
-can only be performed by invoking the `git` command as
-the current user. Therefore, git gems are downloaded and installed
-into `~/.bundle` rather than $GEM_HOME or $BUNDLE_PATH.
-
-As a result, you should run `bundle install` as the current user,
-and Bundler will ask for your password if it is needed to put the
-gems into their final location.
-
-## INSTALLING GROUPS
-
-By default, `bundle install` will install all gems in all groups
-in your Gemfile(5), except those declared for a different platform.
-
-However, you can explicitly tell Bundler to skip installing
-certain groups with the `--without` option. This option takes
-a space-separated list of groups.
-
-While the `--without` option will skip _installing_ the gems in the
-specified groups, it will still _download_ those gems and use them to
-resolve the dependencies of every gem in your Gemfile(5).
-
-This is so that installing a different set of groups on another
- machine (such as a production server) will not change the
-gems and versions that you have already developed and tested against.
-
-`Bundler offers a rock-solid guarantee that the third-party
-code you are running in development and testing is also the
-third-party code you are running in production. You can choose
-to exclude some of that code in different environments, but you
-will never be caught flat-footed by different versions of
-third-party code being used in different environments.`
-
-For a simple illustration, consider the following Gemfile(5):
-
- source 'https://rubygems.org'
-
- gem 'sinatra'
-
- group :production do
- gem 'rack-perftools-profiler'
- end
-
-In this case, `sinatra` depends on any version of Rack (`>= 1.0`), while
-`rack-perftools-profiler` depends on 1.x (`~> 1.0`).
-
-When you run `bundle install --without production` in development, we
-look at the dependencies of `rack-perftools-profiler` as well. That way,
-you do not spend all your time developing against Rack 2.0, using new
-APIs unavailable in Rack 1.x, only to have Bundler switch to Rack 1.2
-when the `production` group _is_ used.
-
-This should not cause any problems in practice, because we do not
-attempt to `install` the gems in the excluded groups, and only evaluate
-as part of the dependency resolution process.
-
-This also means that you cannot include different versions of the same
-gem in different groups, because doing so would result in different
-sets of dependencies used in development and production. Because of
-the vagaries of the dependency resolution process, this usually
-affects more than the gems you list in your Gemfile(5), and can
-(surprisingly) radically change the gems you are using.
-
-## THE GEMFILE.LOCK
-
-When you run `bundle install`, Bundler will persist the full names
-and versions of all gems that you used (including dependencies of
-the gems specified in the Gemfile(5)) into a file called `Gemfile.lock`.
-
-Bundler uses this file in all subsequent calls to `bundle install`,
-which guarantees that you always use the same exact code, even
-as your application moves across machines.
-
-Because of the way dependency resolution works, even a
-seemingly small change (for instance, an update to a point-release
-of a dependency of a gem in your Gemfile(5)) can result in radically
-different gems being needed to satisfy all dependencies.
-
-As a result, you `SHOULD` check your `Gemfile.lock` into version
-control, in both applications and gems. If you do not, every machine that
-checks out your repository (including your production server) will resolve all
-dependencies again, which will result in different versions of
-third-party code being used if `any` of the gems in the Gemfile(5)
-or any of their dependencies have been updated.
-
-When Bundler first shipped, the `Gemfile.lock` was included in the `.gitignore`
-file included with generated gems. Over time, however, it became clear that
-this practice forces the pain of broken dependencies onto new contributors,
-while leaving existing contributors potentially unaware of the problem. Since
-`bundle install` is usually the first step towards a contribution, the pain of
-broken dependencies would discourage new contributors from contributing. As a
-result, we have revised our guidance for gem authors to now recommend checking
-in the lock for gems.
-
-## CONSERVATIVE UPDATING
-
-When you make a change to the Gemfile(5) and then run `bundle install`,
-Bundler will update only the gems that you modified.
-
-In other words, if a gem that you `did not modify` worked before
-you called `bundle install`, it will continue to use the exact
-same versions of all dependencies as it used before the update.
-
-Let's take a look at an example. Here's your original Gemfile(5):
-
- source 'https://rubygems.org'
-
- gem 'actionpack', '2.3.8'
- gem 'activemerchant'
-
-In this case, both `actionpack` and `activemerchant` depend on
-`activesupport`. The `actionpack` gem depends on `activesupport 2.3.8`
-and `rack ~> 1.1.0`, while the `activemerchant` gem depends on
-`activesupport >= 2.3.2`, `braintree >= 2.0.0`, and `builder >= 2.0.0`.
-
-When the dependencies are first resolved, Bundler will select
-`activesupport 2.3.8`, which satisfies the requirements of both
-gems in your Gemfile(5).
-
-Next, you modify your Gemfile(5) to:
-
- source 'https://rubygems.org'
-
- gem 'actionpack', '3.0.0.rc'
- gem 'activemerchant'
-
-The `actionpack 3.0.0.rc` gem has a number of new dependencies,
-and updates the `activesupport` dependency to `= 3.0.0.rc` and
-the `rack` dependency to `~> 1.2.1`.
-
-When you run `bundle install`, Bundler notices that you changed
-the `actionpack` gem, but not the `activemerchant` gem. It
-evaluates the gems currently being used to satisfy its requirements:
-
- * `activesupport 2.3.8`:
- also used to satisfy a dependency in `activemerchant`,
- which is not being updated
- * `rack ~> 1.1.0`:
- not currently being used to satisfy another dependency
-
-Because you did not explicitly ask to update `activemerchant`,
-you would not expect it to suddenly stop working after updating
-`actionpack`. However, satisfying the new `activesupport 3.0.0.rc`
-dependency of actionpack requires updating one of its dependencies.
-
-Even though `activemerchant` declares a very loose dependency
-that theoretically matches `activesupport 3.0.0.rc`, Bundler treats
-gems in your Gemfile(5) that have not changed as an atomic unit
-together with their dependencies. In this case, the `activemerchant`
-dependency is treated as `activemerchant 1.7.1 + activesupport 2.3.8`,
-so `bundle install` will report that it cannot update `actionpack`.
-
-To explicitly update `actionpack`, including its dependencies
-which other gems in the Gemfile(5) still depend on, run
-`bundle update actionpack` (see `bundle update(1)`).
-
-`Summary`: In general, after making a change to the Gemfile(5) , you
-should first try to run `bundle install`, which will guarantee that no
-other gem in the Gemfile(5) is impacted by the change. If that
-does not work, run [bundle update(1)](bundle-update.1.html).
-
-## SEE ALSO
-
-* [Gem install docs](http://guides.rubygems.org/rubygems-basics/#installing-gems)
-* [Rubygems signing docs](http://guides.rubygems.org/security/)
diff --git a/man/bundle-list.1 b/man/bundle-list.1
deleted file mode 100644
index 72bc391ac2..0000000000
--- a/man/bundle-list.1
+++ /dev/null
@@ -1,50 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-LIST" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-list\fR \- List all the gems in the bundle
-.
-.SH "SYNOPSIS"
-\fBbundle list\fR [\-\-name\-only] [\-\-paths] [\-\-without\-group=GROUP] [\-\-only\-group=GROUP]
-.
-.SH "DESCRIPTION"
-Prints a list of all the gems in the bundle including their version\.
-.
-.P
-Example:
-.
-.P
-bundle list \-\-name\-only
-.
-.P
-bundle list \-\-paths
-.
-.P
-bundle list \-\-without\-group test
-.
-.P
-bundle list \-\-only\-group dev
-.
-.P
-bundle list \-\-only\-group dev \-\-paths
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-name\-only\fR
-Print only the name of each gem\.
-.
-.TP
-\fB\-\-paths\fR
-Print the path to each gem in the bundle\.
-.
-.TP
-\fB\-\-without\-group\fR
-Print all gems expect from a group\.
-.
-.TP
-\fB\-\-only\-group\fR
-Print gems from a particular group\.
-
diff --git a/man/bundle-list.1.txt b/man/bundle-list.1.txt
deleted file mode 100644
index 645e62e452..0000000000
--- a/man/bundle-list.1.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-BUNDLE-LIST(1) BUNDLE-LIST(1)
-
-
-
-NAME
- bundle-list - List all the gems in the bundle
-
-SYNOPSIS
- bundle list [--name-only] [--paths] [--without-group=GROUP]
- [--only-group=GROUP]
-
-DESCRIPTION
- Prints a list of all the gems in the bundle including their version.
-
- Example:
-
- bundle list --name-only
-
- bundle list --paths
-
- bundle list --without-group test
-
- bundle list --only-group dev
-
- bundle list --only-group dev --paths
-
-OPTIONS
- --name-only
- Print only the name of each gem.
-
- --paths
- Print the path to each gem in the bundle.
-
- --without-group
- Print all gems expect from a group.
-
- --only-group
- Print gems from a particular group.
-
-
-
-
- January 2020 BUNDLE-LIST(1)
diff --git a/man/bundle-list.ronn b/man/bundle-list.ronn
deleted file mode 100644
index 120cf5e307..0000000000
--- a/man/bundle-list.ronn
+++ /dev/null
@@ -1,33 +0,0 @@
-bundle-list(1) -- List all the gems in the bundle
-=========================================================================
-
-## SYNOPSIS
-
-`bundle list` [--name-only] [--paths] [--without-group=GROUP] [--only-group=GROUP]
-
-## DESCRIPTION
-
-Prints a list of all the gems in the bundle including their version.
-
-Example:
-
-bundle list --name-only
-
-bundle list --paths
-
-bundle list --without-group test
-
-bundle list --only-group dev
-
-bundle list --only-group dev --paths
-
-## OPTIONS
-
-* `--name-only`:
- Print only the name of each gem.
-* `--paths`:
- Print the path to each gem in the bundle.
-* `--without-group`:
- Print all gems expect from a group.
-* `--only-group`:
- Print gems from a particular group.
diff --git a/man/bundle-lock.1 b/man/bundle-lock.1
deleted file mode 100644
index 89f6e35179..0000000000
--- a/man/bundle-lock.1
+++ /dev/null
@@ -1,84 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-LOCK" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
-.
-.SH "SYNOPSIS"
-\fBbundle lock\fR [\-\-update] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-add\-platform] [\-\-remove\-platform] [\-\-patch] [\-\-minor] [\-\-major] [\-\-strict] [\-\-conservative]
-.
-.SH "DESCRIPTION"
-Lock the gems specified in Gemfile\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-update=<*gems>\fR
-Ignores the existing lockfile\. Resolve then updates lockfile\. Taking a list of gems or updating all gems if no list is given\.
-.
-.TP
-\fB\-\-local\fR
-Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems\' cache or in \fBvendor/cache\fR\. Note that if a appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
-.
-.TP
-\fB\-\-print\fR
-Prints the lockfile to STDOUT instead of writing to the file system\.
-.
-.TP
-\fB\-\-lockfile=<path>\fR
-The path where the lockfile should be written to\.
-.
-.TP
-\fB\-\-full\-index\fR
-Fall back to using the single\-file index of all gems\.
-.
-.TP
-\fB\-\-add\-platform\fR
-Add a new platform to the lockfile, re\-resolving for the addition of that platform\.
-.
-.TP
-\fB\-\-remove\-platform\fR
-Remove a platform from the lockfile\.
-.
-.TP
-\fB\-\-patch\fR
-If updating, prefer updating only to next patch version\.
-.
-.TP
-\fB\-\-minor\fR
-If updating, prefer updating only to next minor version\.
-.
-.TP
-\fB\-\-major\fR
-If updating, prefer updating to next major version (default)\.
-.
-.TP
-\fB\-\-strict\fR
-If updating, do not allow any gem to be updated past latest \-\-patch | \-\-minor | \-\-major\.
-.
-.TP
-\fB\-\-conservative\fR
-If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated\.
-.
-.SH "UPDATING ALL GEMS"
-If you run \fBbundle lock\fR with \fB\-\-update\fR option without list of gems, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources\.
-.
-.SH "UPDATING A LIST OF GEMS"
-Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
-.P
-For instance, you only want to update \fBnokogiri\fR, run \fBbundle lock \-\-update nokogiri\fR\.
-.
-.P
-Bundler will update \fBnokogiri\fR and any of its dependencies, but leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
-.SH "SUPPORTING OTHER PLATFORMS"
-If you want your bundle to support platforms other than the one you\'re running locally, you can run \fBbundle lock \-\-add\-platform PLATFORM\fR to add PLATFORM to the lockfile, force bundler to re\-resolve and consider the new platform when picking gems, all without needing to have a machine that matches PLATFORM handy to install those platform\-specific gems on\.
-.
-.P
-For a full explanation of gem platforms, see \fBgem help platform\fR\.
-.
-.SH "PATCH LEVEL OPTIONS"
-See bundle update(1) \fIbundle\-update\.1\.html\fR for details\.
diff --git a/man/bundle-lock.1.txt b/man/bundle-lock.1.txt
deleted file mode 100644
index 80dcada5b3..0000000000
--- a/man/bundle-lock.1.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-BUNDLE-LOCK(1) BUNDLE-LOCK(1)
-
-
-
-NAME
- bundle-lock - Creates / Updates a lockfile without installing
-
-SYNOPSIS
- bundle lock [--update] [--local] [--print] [--lockfile=PATH]
- [--full-index] [--add-platform] [--remove-platform] [--patch] [--minor]
- [--major] [--strict] [--conservative]
-
-DESCRIPTION
- Lock the gems specified in Gemfile.
-
-OPTIONS
- --update=<*gems>
- Ignores the existing lockfile. Resolve then updates lockfile.
- Taking a list of gems or updating all gems if no list is given.
-
- --local
- Do not attempt to connect to rubygems.org. Instead, Bundler will
- use the gems already present in Rubygems' cache or in ven-
- dor/cache. Note that if a appropriate platform-specific gem
- exists on rubygems.org it will not be found.
-
- --print
- Prints the lockfile to STDOUT instead of writing to the file
- system.
-
- --lockfile=<path>
- The path where the lockfile should be written to.
-
- --full-index
- Fall back to using the single-file index of all gems.
-
- --add-platform
- Add a new platform to the lockfile, re-resolving for the addi-
- tion of that platform.
-
- --remove-platform
- Remove a platform from the lockfile.
-
- --patch
- If updating, prefer updating only to next patch version.
-
- --minor
- If updating, prefer updating only to next minor version.
-
- --major
- If updating, prefer updating to next major version (default).
-
- --strict
- If updating, do not allow any gem to be updated past latest
- --patch | --minor | --major.
-
- --conservative
- If updating, use bundle install conservative update behavior and
- do not allow shared dependencies to be updated.
-
-UPDATING ALL GEMS
- If you run bundle lock with --update option without list of gems,
- bundler will ignore any previously installed gems and resolve all
- dependencies again based on the latest versions of all gems available
- in the sources.
-
-UPDATING A LIST OF GEMS
- Sometimes, you want to update a single gem in the Gemfile(5), and leave
- the rest of the gems that you specified locked to the versions in the
- Gemfile.lock.
-
- For instance, you only want to update nokogiri, run bundle lock
- --update nokogiri.
-
- Bundler will update nokogiri and any of its dependencies, but leave the
- rest of the gems that you specified locked to the versions in the Gem-
- file.lock.
-
-SUPPORTING OTHER PLATFORMS
- If you want your bundle to support platforms other than the one you're
- running locally, you can run bundle lock --add-platform PLATFORM to add
- PLATFORM to the lockfile, force bundler to re-resolve and consider the
- new platform when picking gems, all without needing to have a machine
- that matches PLATFORM handy to install those platform-specific gems on.
-
- For a full explanation of gem platforms, see gem help platform.
-
-PATCH LEVEL OPTIONS
- See bundle update(1) bundle-update.1.html for details.
-
-
-
- January 2020 BUNDLE-LOCK(1)
diff --git a/man/bundle-lock.ronn b/man/bundle-lock.ronn
deleted file mode 100644
index 3aa5920f5a..0000000000
--- a/man/bundle-lock.ronn
+++ /dev/null
@@ -1,94 +0,0 @@
-bundle-lock(1) -- Creates / Updates a lockfile without installing
-=================================================================
-
-## SYNOPSIS
-
-`bundle lock` [--update]
- [--local]
- [--print]
- [--lockfile=PATH]
- [--full-index]
- [--add-platform]
- [--remove-platform]
- [--patch]
- [--minor]
- [--major]
- [--strict]
- [--conservative]
-
-## DESCRIPTION
-
-Lock the gems specified in Gemfile.
-
-## OPTIONS
-
-* `--update=<*gems>`:
- Ignores the existing lockfile. Resolve then updates lockfile. Taking a list
- of gems or updating all gems if no list is given.
-
-* `--local`:
- Do not attempt to connect to `rubygems.org`. Instead, Bundler will use the
- gems already present in Rubygems' cache or in `vendor/cache`. Note that if a
- appropriate platform-specific gem exists on `rubygems.org` it will not be
- found.
-
-* `--print`:
- Prints the lockfile to STDOUT instead of writing to the file system.
-
-* `--lockfile=<path>`:
- The path where the lockfile should be written to.
-
-* `--full-index`:
- Fall back to using the single-file index of all gems.
-
-* `--add-platform`:
- Add a new platform to the lockfile, re-resolving for the addition of that
- platform.
-
-* `--remove-platform`:
- Remove a platform from the lockfile.
-
-* `--patch`:
- If updating, prefer updating only to next patch version.
-
-* `--minor`:
- If updating, prefer updating only to next minor version.
-
-* `--major`:
- If updating, prefer updating to next major version (default).
-
-* `--strict`:
- If updating, do not allow any gem to be updated past latest --patch | --minor | --major.
-
-* `--conservative`:
- If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated.
-
-## UPDATING ALL GEMS
-
-If you run `bundle lock` with `--update` option without list of gems, bundler will
-ignore any previously installed gems and resolve all dependencies again based
-on the latest versions of all gems available in the sources.
-
-## UPDATING A LIST OF GEMS
-
-Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of
-the gems that you specified locked to the versions in the `Gemfile.lock`.
-
-For instance, you only want to update `nokogiri`, run `bundle lock --update nokogiri`.
-
-Bundler will update `nokogiri` and any of its dependencies, but leave the rest of the
-gems that you specified locked to the versions in the `Gemfile.lock`.
-
-## SUPPORTING OTHER PLATFORMS
-
-If you want your bundle to support platforms other than the one you're running
-locally, you can run `bundle lock --add-platform PLATFORM` to add PLATFORM to
-the lockfile, force bundler to re-resolve and consider the new platform when
-picking gems, all without needing to have a machine that matches PLATFORM handy
-to install those platform-specific gems on.
-
-For a full explanation of gem platforms, see `gem help platform`.
-
-## PATCH LEVEL OPTIONS
-
-See [bundle update(1)](bundle-update.1.html) for details.
diff --git a/man/bundle-open.1 b/man/bundle-open.1
deleted file mode 100644
index 5a11eeeb64..0000000000
--- a/man/bundle-open.1
+++ /dev/null
@@ -1,32 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-OPEN" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-open\fR \- Opens the source directory for a gem in your bundle
-.
-.SH "SYNOPSIS"
-\fBbundle open\fR [GEM]
-.
-.SH "DESCRIPTION"
-Opens the source directory of the provided GEM in your editor\.
-.
-.P
-For this to work the \fBEDITOR\fR or \fBBUNDLER_EDITOR\fR environment variable has to be set\.
-.
-.P
-Example:
-.
-.IP "" 4
-.
-.nf
-
-bundle open \'rack\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Will open the source directory for the \'rack\' gem in your bundle\.
diff --git a/man/bundle-open.1.txt b/man/bundle-open.1.txt
deleted file mode 100644
index 288bbce0e3..0000000000
--- a/man/bundle-open.1.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-BUNDLE-OPEN(1) BUNDLE-OPEN(1)
-
-
-
-NAME
- bundle-open - Opens the source directory for a gem in your bundle
-
-SYNOPSIS
- bundle open [GEM]
-
-DESCRIPTION
- Opens the source directory of the provided GEM in your editor.
-
- For this to work the EDITOR or BUNDLER_EDITOR environment variable has
- to be set.
-
- Example:
-
-
-
- bundle open 'rack'
-
-
-
- Will open the source directory for the 'rack' gem in your bundle.
-
-
-
- January 2020 BUNDLE-OPEN(1)
diff --git a/man/bundle-open.ronn b/man/bundle-open.ronn
deleted file mode 100644
index 497beac93f..0000000000
--- a/man/bundle-open.ronn
+++ /dev/null
@@ -1,19 +0,0 @@
-bundle-open(1) -- Opens the source directory for a gem in your bundle
-=====================================================================
-
-## SYNOPSIS
-
-`bundle open` [GEM]
-
-## DESCRIPTION
-
-Opens the source directory of the provided GEM in your editor.
-
-For this to work the `EDITOR` or `BUNDLER_EDITOR` environment variable has to
-be set.
-
-Example:
-
- bundle open 'rack'
-
-Will open the source directory for the 'rack' gem in your bundle.
diff --git a/man/bundle-outdated.1 b/man/bundle-outdated.1
deleted file mode 100644
index 408e568034..0000000000
--- a/man/bundle-outdated.1
+++ /dev/null
@@ -1,155 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-OUTDATED" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-outdated\fR \- List installed gems with newer versions available
-.
-.SH "SYNOPSIS"
-\fBbundle outdated\fR [GEM] [\-\-local] [\-\-pre] [\-\-source] [\-\-strict] [\-\-parseable | \-\-porcelain] [\-\-group=GROUP] [\-\-groups] [\-\-update\-strict] [\-\-patch|\-\-minor|\-\-major] [\-\-filter\-major] [\-\-filter\-minor] [\-\-filter\-patch] [\-\-only\-explicit]
-.
-.SH "DESCRIPTION"
-Outdated lists the names and versions of gems that have a newer version available in the given source\. Calling outdated with [GEM [GEM]] will only check for newer versions of the given gems\. Prerelease gems are ignored by default\. If your gems are up to date, Bundler will exit with a status of 0\. Otherwise, it will exit 1\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-local\fR
-Do not attempt to fetch gems remotely and use the gem cache instead\.
-.
-.TP
-\fB\-\-pre\fR
-Check for newer pre\-release gems\.
-.
-.TP
-\fB\-\-source\fR
-Check against a specific source\.
-.
-.TP
-\fB\-\-strict\fR
-Only list newer versions allowed by your Gemfile requirements\.
-.
-.TP
-\fB\-\-parseable\fR, \fB\-\-porcelain\fR
-Use minimal formatting for more parseable output\.
-.
-.TP
-\fB\-\-group\fR
-List gems from a specific group\.
-.
-.TP
-\fB\-\-groups\fR
-List gems organized by groups\.
-.
-.TP
-\fB\-\-update\-strict\fR
-Strict conservative resolution, do not allow any gem to be updated past latest \-\-patch | \-\-minor| \-\-major\.
-.
-.TP
-\fB\-\-minor\fR
-Prefer updating only to next minor version\.
-.
-.TP
-\fB\-\-major\fR
-Prefer updating to next major version (default)\.
-.
-.TP
-\fB\-\-patch\fR
-Prefer updating only to next patch version\.
-.
-.TP
-\fB\-\-filter\-major\fR
-Only list major newer versions\.
-.
-.TP
-\fB\-\-filter\-minor\fR
-Only list minor newer versions\.
-.
-.TP
-\fB\-\-filter\-patch\fR
-Only list patch newer versions\.
-.
-.TP
-\fB\-\-only\-explicit\fR
-Only list gems specified in your Gemfile, not their dependencies\.
-.
-.SH "PATCH LEVEL OPTIONS"
-See bundle update(1) \fIbundle\-update\.1\.html\fR for details\.
-.
-.P
-One difference between the patch level options in \fBbundle update\fR and here is the \fB\-\-strict\fR option\. \fB\-\-strict\fR was already an option on outdated before the patch level options were added\. \fB\-\-strict\fR wasn\'t altered, and the \fB\-\-update\-strict\fR option on \fBoutdated\fR reflects what \fB\-\-strict\fR does on \fBbundle update\fR\.
-.
-.SH "FILTERING OUTPUT"
-The 3 filtering options do not affect the resolution of versions, merely what versions are shown in the output\.
-.
-.P
-If the regular output shows the following:
-.
-.IP "" 4
-.
-.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-* hashie (newest 3\.4\.6, installed 1\.2\.0, requested = 1\.2\.0) in groups "default"
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-\fB\-\-filter\-major\fR would only show:
-.
-.IP "" 4
-.
-.nf
-
-* hashie (newest 3\.4\.6, installed 1\.2\.0, requested = 1\.2\.0) in groups "default"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-\fB\-\-filter\-minor\fR would only show:
-.
-.IP "" 4
-.
-.nf
-
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-\fB\-\-filter\-patch\fR would only show:
-.
-.IP "" 4
-.
-.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Filter options can be combined\. \fB\-\-filter\-minor\fR and \fB\-\-filter\-patch\fR would show:
-.
-.IP "" 4
-.
-.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Combining all three \fBfilter\fR options would be the same result as providing none of them\.
diff --git a/man/bundle-outdated.1.txt b/man/bundle-outdated.1.txt
deleted file mode 100644
index c938e0a4ab..0000000000
--- a/man/bundle-outdated.1.txt
+++ /dev/null
@@ -1,131 +0,0 @@
-BUNDLE-OUTDATED(1) BUNDLE-OUTDATED(1)
-
-
-
-NAME
- bundle-outdated - List installed gems with newer versions available
-
-SYNOPSIS
- bundle outdated [GEM] [--local] [--pre] [--source] [--strict]
- [--parseable | --porcelain] [--group=GROUP] [--groups]
- [--update-strict] [--patch|--minor|--major] [--filter-major] [--fil-
- ter-minor] [--filter-patch] [--only-explicit]
-
-DESCRIPTION
- Outdated lists the names and versions of gems that have a newer version
- available in the given source. Calling outdated with [GEM [GEM]] will
- only check for newer versions of the given gems. Prerelease gems are
- ignored by default. If your gems are up to date, Bundler will exit with
- a status of 0. Otherwise, it will exit 1.
-
-OPTIONS
- --local
- Do not attempt to fetch gems remotely and use the gem cache
- instead.
-
- --pre Check for newer pre-release gems.
-
- --source
- Check against a specific source.
-
- --strict
- Only list newer versions allowed by your Gemfile requirements.
-
- --parseable, --porcelain
- Use minimal formatting for more parseable output.
-
- --group
- List gems from a specific group.
-
- --groups
- List gems organized by groups.
-
- --update-strict
- Strict conservative resolution, do not allow any gem to be
- updated past latest --patch | --minor| --major.
-
- --minor
- Prefer updating only to next minor version.
-
- --major
- Prefer updating to next major version (default).
-
- --patch
- Prefer updating only to next patch version.
-
- --filter-major
- Only list major newer versions.
-
- --filter-minor
- Only list minor newer versions.
-
- --filter-patch
- Only list patch newer versions.
-
- --only-explicit
- Only list gems specified in your Gemfile, not their dependen-
- cies.
-
-PATCH LEVEL OPTIONS
- See bundle update(1) bundle-update.1.html for details.
-
- One difference between the patch level options in bundle update and
- here is the --strict option. --strict was already an option on outdated
- before the patch level options were added. --strict wasn't altered, and
- the --update-strict option on outdated reflects what --strict does on
- bundle update.
-
-FILTERING OUTPUT
- The 3 filtering options do not affect the resolution of versions,
- merely what versions are shown in the output.
-
- If the regular output shows the following:
-
-
-
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
-
-
-
- --filter-major would only show:
-
-
-
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
-
-
-
- --filter-minor would only show:
-
-
-
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
-
-
-
- --filter-patch would only show:
-
-
-
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
-
-
-
- Filter options can be combined. --filter-minor and --filter-patch would
- show:
-
-
-
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
-
-
-
- Combining all three filter options would be the same result as provid-
- ing none of them.
-
-
-
- January 2020 BUNDLE-OUTDATED(1)
diff --git a/man/bundle-outdated.ronn b/man/bundle-outdated.ronn
deleted file mode 100644
index a991d23789..0000000000
--- a/man/bundle-outdated.ronn
+++ /dev/null
@@ -1,111 +0,0 @@
-bundle-outdated(1) -- List installed gems with newer versions available
-=======================================================================
-
-## SYNOPSIS
-
-`bundle outdated` [GEM] [--local]
- [--pre]
- [--source]
- [--strict]
- [--parseable | --porcelain]
- [--group=GROUP]
- [--groups]
- [--update-strict]
- [--patch|--minor|--major]
- [--filter-major]
- [--filter-minor]
- [--filter-patch]
- [--only-explicit]
-
-## DESCRIPTION
-
-Outdated lists the names and versions of gems that have a newer version available
-in the given source. Calling outdated with [GEM [GEM]] will only check for newer
-versions of the given gems. Prerelease gems are ignored by default. If your gems
-are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
-
-## OPTIONS
-
-* `--local`:
- Do not attempt to fetch gems remotely and use the gem cache instead.
-
-* `--pre`:
- Check for newer pre-release gems.
-
-* `--source`:
- Check against a specific source.
-
-* `--strict`:
- Only list newer versions allowed by your Gemfile requirements.
-
-* `--parseable`, `--porcelain`:
- Use minimal formatting for more parseable output.
-
-* `--group`:
- List gems from a specific group.
-
-* `--groups`:
- List gems organized by groups.
-
-* `--update-strict`:
- Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor| --major.
-
-* `--minor`:
- Prefer updating only to next minor version.
-
-* `--major`:
- Prefer updating to next major version (default).
-
-* `--patch`:
- Prefer updating only to next patch version.
-
-* `--filter-major`:
- Only list major newer versions.
-
-* `--filter-minor`:
- Only list minor newer versions.
-
-* `--filter-patch`:
- Only list patch newer versions.
-
-* `--only-explicit`:
- Only list gems specified in your Gemfile, not their dependencies.
-
-## PATCH LEVEL OPTIONS
-
-See [bundle update(1)](bundle-update.1.html) for details.
-
-One difference between the patch level options in `bundle update` and here is the `--strict` option.
-`--strict` was already an option on outdated before the patch level options were added. `--strict`
-wasn't altered, and the `--update-strict` option on `outdated` reflects what `--strict` does on
-`bundle update`.
-
-## FILTERING OUTPUT
-
-The 3 filtering options do not affect the resolution of versions, merely what versions are shown
-in the output.
-
-If the regular output shows the following:
-
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
-
-`--filter-major` would only show:
-
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
-
-`--filter-minor` would only show:
-
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
-
-`--filter-patch` would only show:
-
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
-
-Filter options can be combined. `--filter-minor` and `--filter-patch` would show:
-
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
-
-Combining all three `filter` options would be the same result as providing none of them.
diff --git a/man/bundle-package.1 b/man/bundle-package.1
deleted file mode 100644
index 142f298cf4..0000000000
--- a/man/bundle-package.1
+++ /dev/null
@@ -1,55 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PACKAGE" "1" "September 2019" "" ""
-.
-.SH "NAME"
-\fBbundle\-package\fR \- Package your needed \fB\.gem\fR files into your application
-.
-.SH "SYNOPSIS"
-\fBbundle package\fR
-.
-.SH "DESCRIPTION"
-Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running [bundle install(1)][bundle\-install], use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
-.
-.SH "GIT AND PATH GEMS"
-Since Bundler 1\.2, the \fBbundle package\fR command can also package \fB:git\fR and \fB:path\fR dependencies besides \.gem files\. This needs to be explicitly enabled via the \fB\-\-all\fR option\. Once used, the \fB\-\-all\fR option will be remembered\.
-.
-.SH "SUPPORT FOR MULTIPLE PLATFORMS"
-When using gems that have different packages for different platforms, Bundler 1\.8 and newer support caching of gems for other platforms where the Gemfile has been resolved (i\.e\. present in the lockfile) in \fBvendor/cache\fR\. This needs to be enabled via the \fB\-\-all\-platforms\fR option\. This setting will be remembered in your local bundler configuration\.
-.
-.SH "REMOTE FETCHING"
-By default, if you run \fBbundle install(1)\fR](bundle\-install\.1\.html) after running bundle package(1) \fIbundle\-package\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
-.
-.P
-For instance, consider this Gemfile(5):
-.
-.IP "" 4
-.
-.nf
-
-source "https://rubygems\.org"
-
-gem "nokogiri"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-If you run \fBbundle package\fR under C Ruby, bundler will retrieve the version of \fBnokogiri\fR for the \fB"ruby"\fR platform\. If you deploy to JRuby and run \fBbundle install\fR, bundler is forced to check to see whether a \fB"java"\fR platformed \fBnokogiri\fR exists\.
-.
-.P
-Even though the \fBnokogiri\fR gem for the Ruby platform is \fItechnically\fR acceptable on JRuby, it has a C extension that does not run on JRuby\. As a result, bundler will, by default, still connect to \fBrubygems\.org\fR to check whether it has a version of one of your gems more specific to your platform\.
-.
-.P
-This problem is also not limited to the \fB"java"\fR platform\. A similar (common) problem can happen when developing on Windows and deploying to Linux, or even when developing on OSX and deploying to Linux\.
-.
-.P
-If you know for sure that the gems packaged in \fBvendor/cache\fR are appropriate for the platform you are on, you can run \fBbundle install \-\-local\fR to skip checking for more appropriate gems, and use the ones in \fBvendor/cache\fR\.
-.
-.P
-One way to be sure that you have the right platformed versions of all your gems is to run \fBbundle package\fR on an identical machine and check in the gems\. For instance, you can run \fBbundle package\fR on an identical staging box during your staging process, and check in the \fBvendor/cache\fR before deploying to production\.
-.
-.P
-By default, bundle package(1) \fIbundle\-package\.1\.html\fR fetches and also installs the gems to the default location\. To package the dependencies to \fBvendor/cache\fR without installing them to the local install location, you can run \fBbundle package \-\-no\-install\fR\.
diff --git a/man/bundle-package.1.txt b/man/bundle-package.1.txt
deleted file mode 100644
index ff4068b3bd..0000000000
--- a/man/bundle-package.1.txt
+++ /dev/null
@@ -1,79 +0,0 @@
-BUNDLE-PACKAGE(1) BUNDLE-PACKAGE(1)
-
-
-
-NAME
- bundle-package - Package your needed .gem files into your application
-
-SYNOPSIS
- bundle package
-
-DESCRIPTION
- Copy all of the .gem files needed to run the application into the ven-
- dor/cache directory. In the future, when running [bundle
- install(1)][bundle-install], use the gems in the cache in preference to
- the ones on rubygems.org.
-
-GIT AND PATH GEMS
- Since Bundler 1.2, the bundle package command can also package :git and
- :path dependencies besides .gem files. This needs to be explicitly
- enabled via the --all option. Once used, the --all option will be
- remembered.
-
-SUPPORT FOR MULTIPLE PLATFORMS
- When using gems that have different packages for different platforms,
- Bundler 1.8 and newer support caching of gems for other platforms where
- the Gemfile has been resolved (i.e. present in the lockfile) in ven-
- dor/cache. This needs to be enabled via the --all-platforms option.
- This setting will be remembered in your local bundler configuration.
-
-REMOTE FETCHING
- By default, if you run bundle install(1)](bundle-install.1.html) after
- running bundle package(1) bundle-package.1.html, bundler will still
- connect to rubygems.org to check whether a platform-specific gem exists
- for any of the gems in vendor/cache.
-
- For instance, consider this Gemfile(5):
-
-
-
- source "https://rubygems.org"
-
- gem "nokogiri"
-
-
-
- If you run bundle package under C Ruby, bundler will retrieve the ver-
- sion of nokogiri for the "ruby" platform. If you deploy to JRuby and
- run bundle install, bundler is forced to check to see whether a "java"
- platformed nokogiri exists.
-
- Even though the nokogiri gem for the Ruby platform is technically
- acceptable on JRuby, it has a C extension that does not run on JRuby.
- As a result, bundler will, by default, still connect to rubygems.org to
- check whether it has a version of one of your gems more specific to
- your platform.
-
- This problem is also not limited to the "java" platform. A similar
- (common) problem can happen when developing on Windows and deploying to
- Linux, or even when developing on OSX and deploying to Linux.
-
- If you know for sure that the gems packaged in vendor/cache are appro-
- priate for the platform you are on, you can run bundle install --local
- to skip checking for more appropriate gems, and use the ones in ven-
- dor/cache.
-
- One way to be sure that you have the right platformed versions of all
- your gems is to run bundle package on an identical machine and check in
- the gems. For instance, you can run bundle package on an identical
- staging box during your staging process, and check in the vendor/cache
- before deploying to production.
-
- By default, bundle package(1) bundle-package.1.html fetches and also
- installs the gems to the default location. To package the dependencies
- to vendor/cache without installing them to the local install location,
- you can run bundle package --no-install.
-
-
-
- September 2019 BUNDLE-PACKAGE(1)
diff --git a/man/bundle-package.ronn b/man/bundle-package.ronn
deleted file mode 100644
index bc137374da..0000000000
--- a/man/bundle-package.ronn
+++ /dev/null
@@ -1,72 +0,0 @@
-bundle-package(1) -- Package your needed `.gem` files into your application
-===========================================================================
-
-## SYNOPSIS
-
-`bundle package`
-
-## DESCRIPTION
-
-Copy all of the `.gem` files needed to run the application into the
-`vendor/cache` directory. In the future, when running [bundle install(1)][bundle-install],
-use the gems in the cache in preference to the ones on `rubygems.org`.
-
-## GIT AND PATH GEMS
-
-Since Bundler 1.2, the `bundle package` command can also package `:git` and
-`:path` dependencies besides .gem files. This needs to be explicitly enabled
-via the `--all` option. Once used, the `--all` option will be remembered.
-
-## SUPPORT FOR MULTIPLE PLATFORMS
-
-When using gems that have different packages for different platforms, Bundler
-1.8 and newer support caching of gems for other platforms where the Gemfile
-has been resolved (i.e. present in the lockfile) in `vendor/cache`. This needs
-to be enabled via the `--all-platforms` option. This setting will be remembered
-in your local bundler configuration.
-
-## REMOTE FETCHING
-
-By default, if you run `bundle install(1)`](bundle-install.1.html) after running
-[bundle package(1)](bundle-package.1.html), bundler will still connect to `rubygems.org`
-to check whether a platform-specific gem exists for any of the gems
-in `vendor/cache`.
-
-For instance, consider this Gemfile(5):
-
- source "https://rubygems.org"
-
- gem "nokogiri"
-
-If you run `bundle package` under C Ruby, bundler will retrieve
-the version of `nokogiri` for the `"ruby"` platform. If you deploy
-to JRuby and run `bundle install`, bundler is forced to check to
-see whether a `"java"` platformed `nokogiri` exists.
-
-Even though the `nokogiri` gem for the Ruby platform is
-_technically_ acceptable on JRuby, it has a C extension
-that does not run on JRuby. As a result, bundler will, by default,
-still connect to `rubygems.org` to check whether it has a version
-of one of your gems more specific to your platform.
-
-This problem is also not limited to the `"java"` platform.
-A similar (common) problem can happen when developing on Windows
-and deploying to Linux, or even when developing on OSX and
-deploying to Linux.
-
-If you know for sure that the gems packaged in `vendor/cache`
-are appropriate for the platform you are on, you can run
-`bundle install --local` to skip checking for more appropriate
-gems, and use the ones in `vendor/cache`.
-
-One way to be sure that you have the right platformed versions
-of all your gems is to run `bundle package` on an identical
-machine and check in the gems. For instance, you can run
-`bundle package` on an identical staging box during your
-staging process, and check in the `vendor/cache` before
-deploying to production.
-
-By default, [bundle package(1)](bundle-package.1.html) fetches and also
-installs the gems to the default location. To package the
-dependencies to `vendor/cache` without installing them to the
-local install location, you can run `bundle package --no-install`.
diff --git a/man/bundle-platform.1 b/man/bundle-platform.1
deleted file mode 100644
index c83aa3c5d4..0000000000
--- a/man/bundle-platform.1
+++ /dev/null
@@ -1,61 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PLATFORM" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-platform\fR \- Displays platform compatibility information
-.
-.SH "SYNOPSIS"
-\fBbundle platform\fR [\-\-ruby]
-.
-.SH "DESCRIPTION"
-\fBplatform\fR will display information from your Gemfile, Gemfile\.lock, and Ruby VM about your platform\.
-.
-.P
-For instance, using this Gemfile(5):
-.
-.IP "" 4
-.
-.nf
-
-source "https://rubygems\.org"
-
-ruby "1\.9\.3"
-
-gem "rack"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-If you run \fBbundle platform\fR on Ruby 1\.9\.3, it will display the following output:
-.
-.IP "" 4
-.
-.nf
-
-Your platform is: x86_64\-linux
-
-Your app has gems that work on these platforms:
-* ruby
-
-Your Gemfile specifies a Ruby version requirement:
-* ruby 1\.9\.3
-
-Your current platform satisfies the Ruby version requirement\.
-.
-.fi
-.
-.IP "" 0
-.
-.P
-\fBplatform\fR will list all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It will also let you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn\'t match the running Ruby VM, it will tell you what part does not\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-ruby\fR
-It will display the ruby directive information, so you don\'t have to parse it from the Gemfile(5)\.
-
diff --git a/man/bundle-platform.1.txt b/man/bundle-platform.1.txt
deleted file mode 100644
index f9dc8ccc1f..0000000000
--- a/man/bundle-platform.1.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-BUNDLE-PLATFORM(1) BUNDLE-PLATFORM(1)
-
-
-
-NAME
- bundle-platform - Displays platform compatibility information
-
-SYNOPSIS
- bundle platform [--ruby]
-
-DESCRIPTION
- platform will display information from your Gemfile, Gemfile.lock, and
- Ruby VM about your platform.
-
- For instance, using this Gemfile(5):
-
-
-
- source "https://rubygems.org"
-
- ruby "1.9.3"
-
- gem "rack"
-
-
-
- If you run bundle platform on Ruby 1.9.3, it will display the following
- output:
-
-
-
- Your platform is: x86_64-linux
-
- Your app has gems that work on these platforms:
- * ruby
-
- Your Gemfile specifies a Ruby version requirement:
- * ruby 1.9.3
-
- Your current platform satisfies the Ruby version requirement.
-
-
-
- platform will list all the platforms in your Gemfile.lock as well as
- the ruby directive if applicable from your Gemfile(5). It will also let
- you know if the ruby directive requirement has been met. If ruby direc-
- tive doesn't match the running Ruby VM, it will tell you what part does
- not.
-
-OPTIONS
- --ruby It will display the ruby directive information, so you don't
- have to parse it from the Gemfile(5).
-
-
-
-
- January 2020 BUNDLE-PLATFORM(1)
diff --git a/man/bundle-platform.ronn b/man/bundle-platform.ronn
deleted file mode 100644
index b5d3283fb6..0000000000
--- a/man/bundle-platform.ronn
+++ /dev/null
@@ -1,42 +0,0 @@
-bundle-platform(1) -- Displays platform compatibility information
-=================================================================
-
-## SYNOPSIS
-
-`bundle platform` [--ruby]
-
-## DESCRIPTION
-
-`platform` will display information from your Gemfile, Gemfile.lock, and Ruby
-VM about your platform.
-
-For instance, using this Gemfile(5):
-
- source "https://rubygems.org"
-
- ruby "1.9.3"
-
- gem "rack"
-
-If you run `bundle platform` on Ruby 1.9.3, it will display the following output:
-
- Your platform is: x86_64-linux
-
- Your app has gems that work on these platforms:
- * ruby
-
- Your Gemfile specifies a Ruby version requirement:
- * ruby 1.9.3
-
- Your current platform satisfies the Ruby version requirement.
-
-`platform` will list all the platforms in your `Gemfile.lock` as well as the
-`ruby` directive if applicable from your Gemfile(5). It will also let you know
-if the `ruby` directive requirement has been met. If `ruby` directive doesn't
-match the running Ruby VM, it will tell you what part does not.
-
-## OPTIONS
-
-* `--ruby`:
- It will display the ruby directive information, so you don't have to
- parse it from the Gemfile(5).
diff --git a/man/bundle-pristine.1 b/man/bundle-pristine.1
deleted file mode 100644
index 460e3d4e5a..0000000000
--- a/man/bundle-pristine.1
+++ /dev/null
@@ -1,34 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PRISTINE" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
-.
-.SH "SYNOPSIS"
-\fBbundle pristine\fR
-.
-.SH "DESCRIPTION"
-\fBpristine\fR restores the installed gems in the bundle to their pristine condition using the local gem cache from RubyGems\. For git gems, a forced checkout will be performed\.
-.
-.P
-For further explanation, \fBbundle pristine\fR ignores unpacked files on disk\. In other words, this command utilizes the local \fB\.gem\fR cache or the gem\'s git repository as if one were installing from scratch\.
-.
-.P
-Note: the Bundler gem cannot be restored to its original state with \fBpristine\fR\. One also cannot use \fBbundle pristine\fR on gems with a \'path\' option in the Gemfile, because bundler has no original copy it can restore from\.
-.
-.P
-When is it practical to use \fBbundle pristine\fR?
-.
-.P
-It comes in handy when a developer is debugging a gem\. \fBbundle pristine\fR is a great way to get rid of experimental changes to a gem that one may not want\.
-.
-.P
-Why use \fBbundle pristine\fR over \fBgem pristine \-\-all\fR?
-.
-.P
-Both commands are very similar\. For context: \fBbundle pristine\fR, without arguments, cleans all gems from the lockfile\. Meanwhile, \fBgem pristine \-\-all\fR cleans all installed gems for that Ruby version\.
-.
-.P
-If a developer forgets which gems in their project they might have been debugging, the Rubygems \fBgem pristine [GEMNAME]\fR command may be inconvenient\. One can avoid waiting for \fBgem pristine \-\-all\fR, and instead run \fBbundle pristine\fR\.
diff --git a/man/bundle-pristine.1.txt b/man/bundle-pristine.1.txt
deleted file mode 100644
index 8d474fe497..0000000000
--- a/man/bundle-pristine.1.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-BUNDLE-PRISTINE(1) BUNDLE-PRISTINE(1)
-
-
-
-NAME
- bundle-pristine - Restores installed gems to their pristine condition
-
-SYNOPSIS
- bundle pristine
-
-DESCRIPTION
- pristine restores the installed gems in the bundle to their pristine
- condition using the local gem cache from RubyGems. For git gems, a
- forced checkout will be performed.
-
- For further explanation, bundle pristine ignores unpacked files on
- disk. In other words, this command utilizes the local .gem cache or the
- gem's git repository as if one were installing from scratch.
-
- Note: the Bundler gem cannot be restored to its original state with
- pristine. One also cannot use bundle pristine on gems with a 'path'
- option in the Gemfile, because bundler has no original copy it can
- restore from.
-
- When is it practical to use bundle pristine?
-
- It comes in handy when a developer is debugging a gem. bundle pristine
- is a great way to get rid of experimental changes to a gem that one may
- not want.
-
- Why use bundle pristine over gem pristine --all?
-
- Both commands are very similar. For context: bundle pristine, without
- arguments, cleans all gems from the lockfile. Meanwhile, gem pristine
- --all cleans all installed gems for that Ruby version.
-
- If a developer forgets which gems in their project they might have been
- debugging, the Rubygems gem pristine [GEMNAME] command may be inconve-
- nient. One can avoid waiting for gem pristine --all, and instead run
- bundle pristine.
-
-
-
- January 2020 BUNDLE-PRISTINE(1)
diff --git a/man/bundle-pristine.ronn b/man/bundle-pristine.ronn
deleted file mode 100644
index e2d6b6a348..0000000000
--- a/man/bundle-pristine.ronn
+++ /dev/null
@@ -1,34 +0,0 @@
-bundle-pristine(1) -- Restores installed gems to their pristine condition
-===========================================================================
-
-## SYNOPSIS
-
-`bundle pristine`
-
-## DESCRIPTION
-
-`pristine` restores the installed gems in the bundle to their pristine condition
-using the local gem cache from RubyGems. For git gems, a forced checkout will be performed.
-
-For further explanation, `bundle pristine` ignores unpacked files on disk. In other
-words, this command utilizes the local `.gem` cache or the gem's git repository
-as if one were installing from scratch.
-
-Note: the Bundler gem cannot be restored to its original state with `pristine`.
-One also cannot use `bundle pristine` on gems with a 'path' option in the Gemfile,
-because bundler has no original copy it can restore from.
-
-When is it practical to use `bundle pristine`?
-
-It comes in handy when a developer is debugging a gem. `bundle pristine` is a
-great way to get rid of experimental changes to a gem that one may not want.
-
-Why use `bundle pristine` over `gem pristine --all`?
-
-Both commands are very similar.
-For context: `bundle pristine`, without arguments, cleans all gems from the lockfile.
-Meanwhile, `gem pristine --all` cleans all installed gems for that Ruby version.
-
-If a developer forgets which gems in their project they might
-have been debugging, the Rubygems `gem pristine [GEMNAME]` command may be inconvenient.
-One can avoid waiting for `gem pristine --all`, and instead run `bundle pristine`.
diff --git a/man/bundle-remove.1 b/man/bundle-remove.1
deleted file mode 100644
index cb4ad8d384..0000000000
--- a/man/bundle-remove.1
+++ /dev/null
@@ -1,31 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-REMOVE" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-remove\fR \- Removes gems from the Gemfile
-.
-.SH "SYNOPSIS"
-\fBbundle remove [GEM [GEM \.\.\.]] [\-\-install]\fR
-.
-.SH "DESCRIPTION"
-Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid\. If a gem cannot be removed, a warning is printed\. If a gem is already absent from the Gemfile, and error is raised\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-install\fR
-Runs \fBbundle install\fR after the given gems have been removed from the Gemfile, which ensures that both the lockfile and the installed gems on disk are also updated to remove the given gem(s)\.
-.
-.P
-Example:
-.
-.P
-bundle remove rails
-.
-.P
-bundle remove rails rack
-.
-.P
-bundle remove rails rack \-\-install
diff --git a/man/bundle-remove.1.txt b/man/bundle-remove.1.txt
deleted file mode 100644
index 7203422f39..0000000000
--- a/man/bundle-remove.1.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-BUNDLE-REMOVE(1) BUNDLE-REMOVE(1)
-
-
-
-NAME
- bundle-remove - Removes gems from the Gemfile
-
-SYNOPSIS
- bundle remove [GEM [GEM ...]] [--install]
-
-DESCRIPTION
- Removes the given gems from the Gemfile while ensuring that the result-
- ing Gemfile is still valid. If a gem cannot be removed, a warning is
- printed. If a gem is already absent from the Gemfile, and error is
- raised.
-
-OPTIONS
- --install
- Runs bundle install after the given gems have been removed from
- the Gemfile, which ensures that both the lockfile and the
- installed gems on disk are also updated to remove the given
- gem(s).
-
- Example:
-
- bundle remove rails
-
- bundle remove rails rack
-
- bundle remove rails rack --install
-
-
-
- January 2020 BUNDLE-REMOVE(1)
diff --git a/man/bundle-remove.ronn b/man/bundle-remove.ronn
deleted file mode 100644
index 40a239b4a2..0000000000
--- a/man/bundle-remove.ronn
+++ /dev/null
@@ -1,23 +0,0 @@
-bundle-remove(1) -- Removes gems from the Gemfile
-===========================================================================
-
-## SYNOPSIS
-
-`bundle remove [GEM [GEM ...]] [--install]`
-
-## DESCRIPTION
-
-Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If a gem cannot be removed, a warning is printed. If a gem is already absent from the Gemfile, and error is raised.
-
-## OPTIONS
-
-* `--install`:
- Runs `bundle install` after the given gems have been removed from the Gemfile, which ensures that both the lockfile and the installed gems on disk are also updated to remove the given gem(s).
-
-Example:
-
-bundle remove rails
-
-bundle remove rails rack
-
-bundle remove rails rack --install
diff --git a/man/bundle-show.1 b/man/bundle-show.1
deleted file mode 100644
index 2922a33467..0000000000
--- a/man/bundle-show.1
+++ /dev/null
@@ -1,23 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-SHOW" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem
-.
-.SH "SYNOPSIS"
-\fBbundle show\fR [GEM] [\-\-paths]
-.
-.SH "DESCRIPTION"
-Without the [GEM] option, \fBshow\fR will print a list of the names and versions of all gems that are required by your [\fBGemfile(5)\fR][Gemfile(5)], sorted by name\.
-.
-.P
-Calling show with [GEM] will list the exact location of that gem on your machine\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-paths\fR
-List the paths of all gems that are required by your [\fBGemfile(5)\fR][Gemfile(5)], sorted by gem name\.
-
diff --git a/man/bundle-show.1.txt b/man/bundle-show.1.txt
deleted file mode 100644
index 58f1620168..0000000000
--- a/man/bundle-show.1.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-BUNDLE-SHOW(1) BUNDLE-SHOW(1)
-
-
-
-NAME
- bundle-show - Shows all the gems in your bundle, or the path to a gem
-
-SYNOPSIS
- bundle show [GEM] [--paths]
-
-DESCRIPTION
- Without the [GEM] option, show will print a list of the names and ver-
- sions of all gems that are required by your [Gemfile(5)][Gemfile(5)],
- sorted by name.
-
- Calling show with [GEM] will list the exact location of that gem on
- your machine.
-
-OPTIONS
- --paths
- List the paths of all gems that are required by your [Gem-
- file(5)][Gemfile(5)], sorted by gem name.
-
-
-
-
- January 2020 BUNDLE-SHOW(1)
diff --git a/man/bundle-show.ronn b/man/bundle-show.ronn
deleted file mode 100644
index a6a59a1445..0000000000
--- a/man/bundle-show.ronn
+++ /dev/null
@@ -1,21 +0,0 @@
-bundle-show(1) -- Shows all the gems in your bundle, or the path to a gem
-=========================================================================
-
-## SYNOPSIS
-
-`bundle show` [GEM]
- [--paths]
-
-## DESCRIPTION
-
-Without the [GEM] option, `show` will print a list of the names and versions of
-all gems that are required by your [`Gemfile(5)`][Gemfile(5)], sorted by name.
-
-Calling show with [GEM] will list the exact location of that gem on your
-machine.
-
-## OPTIONS
-
-* `--paths`:
- List the paths of all gems that are required by your [`Gemfile(5)`][Gemfile(5)],
- sorted by gem name.
diff --git a/man/bundle-update.1 b/man/bundle-update.1
deleted file mode 100644
index f315532bb9..0000000000
--- a/man/bundle-update.1
+++ /dev/null
@@ -1,394 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-UPDATE" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-update\fR \- Update your gems to the latest available versions
-.
-.SH "SYNOPSIS"
-\fBbundle update\fR \fI*gems\fR [\-\-all] [\-\-group=NAME] [\-\-source=NAME] [\-\-local] [\-\-ruby] [\-\-bundler[=VERSION]] [\-\-full\-index] [\-\-jobs=JOBS] [\-\-quiet] [\-\-patch|\-\-minor|\-\-major] [\-\-redownload] [\-\-strict] [\-\-conservative]
-.
-.SH "DESCRIPTION"
-Update the gems specified (all gems, if \fB\-\-all\fR flag is used), ignoring the previously installed gems specified in the \fBGemfile\.lock\fR\. In general, you should use bundle install(1) \fIbundle\-install\.1\.html\fR to install the same exact gems and versions across machines\.
-.
-.P
-You would use \fBbundle update\fR to explicitly update the version of a gem\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-all\fR
-Update all gems specified in Gemfile\.
-.
-.TP
-\fB\-\-group=<name>\fR, \fB\-g=[<name>]\fR
-Only update the gems in the specified group\. For instance, you can update all gems in the development group with \fBbundle update \-\-group development\fR\. You can also call \fBbundle update rails \-\-group test\fR to update the rails gem and all gems in the test group, for example\.
-.
-.TP
-\fB\-\-source=<name>\fR
-The name of a \fB:git\fR or \fB:path\fR source used in the Gemfile(5)\. For instance, with a \fB:git\fR source of \fBhttp://github\.com/rails/rails\.git\fR, you would call \fBbundle update \-\-source rails\fR
-.
-.TP
-\fB\-\-local\fR
-Do not attempt to fetch gems remotely and use the gem cache instead\.
-.
-.TP
-\fB\-\-ruby\fR
-Update the locked version of Ruby to the current version of Ruby\.
-.
-.TP
-\fB\-\-bundler\fR
-Update the locked version of bundler to the invoked bundler version\.
-.
-.TP
-\fB\-\-full\-index\fR
-Fall back to using the single\-file index of all gems\.
-.
-.TP
-\fB\-\-jobs=[<number>]\fR, \fB\-j[<number>]\fR
-Specify the number of jobs to run in parallel\. The default is \fB1\fR\.
-.
-.TP
-\fB\-\-retry=[<number>]\fR
-Retry failed network or git requests for \fInumber\fR times\.
-.
-.TP
-\fB\-\-quiet\fR
-Only output warnings and errors\.
-.
-.TP
-\fB\-\-redownload\fR
-Force downloading every gem\.
-.
-.TP
-\fB\-\-patch\fR
-Prefer updating only to next patch version\.
-.
-.TP
-\fB\-\-minor\fR
-Prefer updating only to next minor version\.
-.
-.TP
-\fB\-\-major\fR
-Prefer updating to next major version (default)\.
-.
-.TP
-\fB\-\-strict\fR
-Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
-.
-.TP
-\fB\-\-conservative\fR
-Use bundle install conservative update behavior and do not allow shared dependencies to be updated\.
-.
-.SH "UPDATING ALL GEMS"
-If you run \fBbundle update \-\-all\fR, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources\.
-.
-.P
-Consider the following Gemfile(5):
-.
-.IP "" 4
-.
-.nf
-
-source "https://rubygems\.org"
-
-gem "rails", "3\.0\.0\.rc"
-gem "nokogiri"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-When you run bundle install(1) \fIbundle\-install\.1\.html\fR the first time, bundler will resolve all of the dependencies, all the way down, and install what you need:
-.
-.IP "" 4
-.
-.nf
-
-Fetching gem metadata from https://rubygems\.org/\.\.\.\.\.\.\.\.\.
-Resolving dependencies\.\.\.
-Installing builder 2\.1\.2
-Installing abstract 1\.0\.0
-Installing rack 1\.2\.8
-Using bundler 1\.7\.6
-Installing rake 10\.4\.0
-Installing polyglot 0\.3\.5
-Installing mime\-types 1\.25\.1
-Installing i18n 0\.4\.2
-Installing mini_portile 0\.6\.1
-Installing tzinfo 0\.3\.42
-Installing rack\-mount 0\.6\.14
-Installing rack\-test 0\.5\.7
-Installing treetop 1\.4\.15
-Installing thor 0\.14\.6
-Installing activesupport 3\.0\.0\.rc
-Installing erubis 2\.6\.6
-Installing activemodel 3\.0\.0\.rc
-Installing arel 0\.4\.0
-Installing mail 2\.2\.20
-Installing activeresource 3\.0\.0\.rc
-Installing actionpack 3\.0\.0\.rc
-Installing activerecord 3\.0\.0\.rc
-Installing actionmailer 3\.0\.0\.rc
-Installing railties 3\.0\.0\.rc
-Installing rails 3\.0\.0\.rc
-Installing nokogiri 1\.6\.5
-
-Bundle complete! 2 Gemfile dependencies, 26 gems total\.
-Use `bundle show [gemname]` to see where a bundled gem is installed\.
-.
-.fi
-.
-.IP "" 0
-.
-.P
-As you can see, even though you have two gems in the Gemfile(5), your application needs 26 different gems in order to run\. Bundler remembers the exact versions it installed in \fBGemfile\.lock\fR\. The next time you run bundle install(1) \fIbundle\-install\.1\.html\fR, bundler skips the dependency resolution and installs the same gems as it installed last time\.
-.
-.P
-After checking in the \fBGemfile\.lock\fR into version control and cloning it on another machine, running bundle install(1) \fIbundle\-install\.1\.html\fR will \fIstill\fR install the gems that you installed last time\. You don\'t need to worry that a new release of \fBerubis\fR or \fBmail\fR changes the gems you use\.
-.
-.P
-However, from time to time, you might want to update the gems you are using to the newest versions that still match the gems in your Gemfile(5)\.
-.
-.P
-To do this, run \fBbundle update \-\-all\fR, which will ignore the \fBGemfile\.lock\fR, and resolve all the dependencies again\. Keep in mind that this process can result in a significantly different set of the 25 gems, based on the requirements of new gems that the gem authors released since the last time you ran \fBbundle update \-\-all\fR\.
-.
-.SH "UPDATING A LIST OF GEMS"
-Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
-.P
-For instance, in the scenario above, imagine that \fBnokogiri\fR releases version \fB1\.4\.4\fR, and you want to update it \fIwithout\fR updating Rails and all of its dependencies\. To do this, run \fBbundle update nokogiri\fR\.
-.
-.P
-Bundler will update \fBnokogiri\fR and any of its dependencies, but leave alone Rails and its dependencies\.
-.
-.SH "OVERLAPPING DEPENDENCIES"
-Sometimes, multiple gems declared in your Gemfile(5) are satisfied by the same second\-level dependency\. For instance, consider the case of \fBthin\fR and \fBrack\-perftools\-profiler\fR\.
-.
-.IP "" 4
-.
-.nf
-
-source "https://rubygems\.org"
-
-gem "thin"
-gem "rack\-perftools\-profiler"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-The \fBthin\fR gem depends on \fBrack >= 1\.0\fR, while \fBrack\-perftools\-profiler\fR depends on \fBrack ~> 1\.0\fR\. If you run bundle install, you get:
-.
-.IP "" 4
-.
-.nf
-
-Fetching source index for https://rubygems\.org/
-Installing daemons (1\.1\.0)
-Installing eventmachine (0\.12\.10) with native extensions
-Installing open4 (1\.0\.1)
-Installing perftools\.rb (0\.4\.7) with native extensions
-Installing rack (1\.2\.1)
-Installing rack\-perftools_profiler (0\.0\.2)
-Installing thin (1\.2\.7) with native extensions
-Using bundler (1\.0\.0\.rc\.3)
-.
-.fi
-.
-.IP "" 0
-.
-.P
-In this case, the two gems have their own set of dependencies, but they share \fBrack\fR in common\. If you run \fBbundle update thin\fR, bundler will update \fBdaemons\fR, \fBeventmachine\fR and \fBrack\fR, which are dependencies of \fBthin\fR, but not \fBopen4\fR or \fBperftools\.rb\fR, which are dependencies of \fBrack\-perftools_profiler\fR\. Note that \fBbundle update thin\fR will update \fBrack\fR even though it\'s \fIalso\fR a dependency of \fBrack\-perftools_profiler\fR\.
-.
-.P
-In short, by default, when you update a gem using \fBbundle update\fR, bundler will update all dependencies of that gem, including those that are also dependencies of another gem\.
-.
-.P
-To prevent updating shared dependencies, prior to version 1\.14 the only option was the \fBCONSERVATIVE UPDATING\fR behavior in bundle install(1) \fIbundle\-install\.1\.html\fR:
-.
-.P
-In this scenario, updating the \fBthin\fR version manually in the Gemfile(5), and then running bundle install(1) \fIbundle\-install\.1\.html\fR will only update \fBdaemons\fR and \fBeventmachine\fR, but not \fBrack\fR\. For more information, see the \fBCONSERVATIVE UPDATING\fR section of bundle install(1) \fIbundle\-install\.1\.html\fR\.
-.
-.P
-Starting with 1\.14, specifying the \fB\-\-conservative\fR option will also prevent shared dependencies from being updated\.
-.
-.SH "PATCH LEVEL OPTIONS"
-Version 1\.14 introduced 4 patch\-level options that will influence how gem versions are resolved\. One of the following options can be used: \fB\-\-patch\fR, \fB\-\-minor\fR or \fB\-\-major\fR\. \fB\-\-strict\fR can be added to further influence resolution\.
-.
-.TP
-\fB\-\-patch\fR
-Prefer updating only to next patch version\.
-.
-.TP
-\fB\-\-minor\fR
-Prefer updating only to next minor version\.
-.
-.TP
-\fB\-\-major\fR
-Prefer updating to next major version (default)\.
-.
-.TP
-\fB\-\-strict\fR
-Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
-.
-.P
-When Bundler is resolving what versions to use to satisfy declared requirements in the Gemfile or in parent gems, it looks up all available versions, filters out any versions that don\'t satisfy the requirement, and then, by default, sorts them from newest to oldest, considering them in that order\.
-.
-.P
-Providing one of the patch level options (e\.g\. \fB\-\-patch\fR) changes the sort order of the satisfying versions, causing Bundler to consider the latest \fB\-\-patch\fR or \fB\-\-minor\fR version available before other versions\. Note that versions outside the stated patch level could still be resolved to if necessary to find a suitable dependency graph\.
-.
-.P
-For example, if gem \'foo\' is locked at 1\.0\.2, with no gem requirement defined in the Gemfile, and versions 1\.0\.3, 1\.0\.4, 1\.1\.0, 1\.1\.1, 2\.0\.0 all exist, the default order of preference by default (\fB\-\-major\fR) will be "2\.0\.0, 1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
-.
-.P
-If the \fB\-\-patch\fR option is used, the order of preference will change to "1\.0\.4, 1\.0\.3, 1\.0\.2, 1\.1\.1, 1\.1\.0, 2\.0\.0"\.
-.
-.P
-If the \fB\-\-minor\fR option is used, the order of preference will change to "1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2, 2\.0\.0"\.
-.
-.P
-Combining the \fB\-\-strict\fR option with any of the patch level options will remove any versions beyond the scope of the patch level option, to ensure that no gem is updated that far\.
-.
-.P
-To continue the previous example, if both \fB\-\-patch\fR and \fB\-\-strict\fR options are used, the available versions for resolution would be "1\.0\.4, 1\.0\.3, 1\.0\.2"\. If \fB\-\-minor\fR and \fB\-\-strict\fR are used, it would be "1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
-.
-.P
-Gem requirements as defined in the Gemfile will still be the first determining factor for what versions are available\. If the gem requirement for \fBfoo\fR in the Gemfile is \'~> 1\.0\', that will accomplish the same thing as providing the \fB\-\-minor\fR and \fB\-\-strict\fR options\.
-.
-.SH "PATCH LEVEL EXAMPLES"
-Given the following gem specifications:
-.
-.IP "" 4
-.
-.nf
-
-foo 1\.4\.3, requires: ~> bar 2\.0
-foo 1\.4\.4, requires: ~> bar 2\.0
-foo 1\.4\.5, requires: ~> bar 2\.1
-foo 1\.5\.0, requires: ~> bar 2\.1
-foo 1\.5\.1, requires: ~> bar 3\.0
-bar with versions 2\.0\.3, 2\.0\.4, 2\.1\.0, 2\.1\.1, 3\.0\.0
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Gemfile:
-.
-.IP "" 4
-.
-.nf
-
-gem \'foo\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Gemfile\.lock:
-.
-.IP "" 4
-.
-.nf
-
-foo (1\.4\.3)
- bar (~> 2\.0)
-bar (2\.0\.3)
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Cases:
-.
-.IP "" 4
-.
-.nf
-
-# Command Line Result
-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
-1 bundle update \-\-patch \'foo 1\.4\.5\', \'bar 2\.1\.1\'
-2 bundle update \-\-patch foo \'foo 1\.4\.5\', \'bar 2\.1\.1\'
-3 bundle update \-\-minor \'foo 1\.5\.1\', \'bar 3\.0\.0\'
-4 bundle update \-\-minor \-\-strict \'foo 1\.5\.0\', \'bar 2\.1\.1\'
-5 bundle update \-\-patch \-\-strict \'foo 1\.4\.4\', \'bar 2\.0\.4\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-In case 1, bar is upgraded to 2\.1\.1, a minor version increase, because the dependency from foo 1\.4\.5 required it\.
-.
-.P
-In case 2, only foo is requested to be unlocked, but bar is also allowed to move because it\'s not a declared dependency in the Gemfile\.
-.
-.P
-In case 3, bar goes up a whole major release, because a minor increase is preferred now for foo, and when it goes to 1\.5\.1, it requires 3\.0\.0 of bar\.
-.
-.P
-In case 4, foo is preferred up to a minor version, but 1\.5\.1 won\'t work because the \-\-strict flag removes bar 3\.0\.0 from consideration since it\'s a major increment\.
-.
-.P
-In case 5, both foo and bar have any minor or major increments removed from consideration because of the \-\-strict flag, so the most they can move is up to 1\.4\.4 and 2\.0\.4\.
-.
-.SH "RECOMMENDED WORKFLOW"
-In general, when working with an application managed with bundler, you should use the following workflow:
-.
-.IP "\(bu" 4
-After you create your Gemfile(5) for the first time, run
-.
-.IP
-$ bundle install
-.
-.IP "\(bu" 4
-Check the resulting \fBGemfile\.lock\fR into version control
-.
-.IP
-$ git add Gemfile\.lock
-.
-.IP "\(bu" 4
-When checking out this repository on another development machine, run
-.
-.IP
-$ bundle install
-.
-.IP "\(bu" 4
-When checking out this repository on a deployment machine, run
-.
-.IP
-$ bundle install \-\-deployment
-.
-.IP "\(bu" 4
-After changing the Gemfile(5) to reflect a new or update dependency, run
-.
-.IP
-$ bundle install
-.
-.IP "\(bu" 4
-Make sure to check the updated \fBGemfile\.lock\fR into version control
-.
-.IP
-$ git add Gemfile\.lock
-.
-.IP "\(bu" 4
-If bundle install(1) \fIbundle\-install\.1\.html\fR reports a conflict, manually update the specific gems that you changed in the Gemfile(5)
-.
-.IP
-$ bundle update rails thin
-.
-.IP "\(bu" 4
-If you want to update all the gems to the latest possible versions that still match the gems listed in the Gemfile(5), run
-.
-.IP
-$ bundle update \-\-all
-.
-.IP "" 0
-
diff --git a/man/bundle-update.1.txt b/man/bundle-update.1.txt
deleted file mode 100644
index b8208c75d3..0000000000
--- a/man/bundle-update.1.txt
+++ /dev/null
@@ -1,390 +0,0 @@
-BUNDLE-UPDATE(1) BUNDLE-UPDATE(1)
-
-
-
-NAME
- bundle-update - Update your gems to the latest available versions
-
-SYNOPSIS
- bundle update *gems [--all] [--group=NAME] [--source=NAME] [--local]
- [--ruby] [--bundler[=VERSION]] [--full-index] [--jobs=JOBS] [--quiet]
- [--patch|--minor|--major] [--redownload] [--strict] [--conservative]
-
-DESCRIPTION
- Update the gems specified (all gems, if --all flag is used), ignoring
- the previously installed gems specified in the Gemfile.lock. In gen-
- eral, you should use bundle install(1) bundle-install.1.html to install
- the same exact gems and versions across machines.
-
- You would use bundle update to explicitly update the version of a gem.
-
-OPTIONS
- --all Update all gems specified in Gemfile.
-
- --group=<name>, -g=[<name>]
- Only update the gems in the specified group. For instance, you
- can update all gems in the development group with bundle update
- --group development. You can also call bundle update rails
- --group test to update the rails gem and all gems in the test
- group, for example.
-
- --source=<name>
- The name of a :git or :path source used in the Gemfile(5). For
- instance, with a :git source of
- http://github.com/rails/rails.git, you would call bundle update
- --source rails
-
- --local
- Do not attempt to fetch gems remotely and use the gem cache
- instead.
-
- --ruby Update the locked version of Ruby to the current version of
- Ruby.
-
- --bundler
- Update the locked version of bundler to the invoked bundler ver-
- sion.
-
- --full-index
- Fall back to using the single-file index of all gems.
-
- --jobs=[<number>], -j[<number>]
- Specify the number of jobs to run in parallel. The default is 1.
-
- --retry=[<number>]
- Retry failed network or git requests for number times.
-
- --quiet
- Only output warnings and errors.
-
- --redownload
- Force downloading every gem.
-
- --patch
- Prefer updating only to next patch version.
-
- --minor
- Prefer updating only to next minor version.
-
- --major
- Prefer updating to next major version (default).
-
- --strict
- Do not allow any gem to be updated past latest --patch | --minor
- | --major.
-
- --conservative
- Use bundle install conservative update behavior and do not allow
- shared dependencies to be updated.
-
-UPDATING ALL GEMS
- If you run bundle update --all, bundler will ignore any previously
- installed gems and resolve all dependencies again based on the latest
- versions of all gems available in the sources.
-
- Consider the following Gemfile(5):
-
-
-
- source "https://rubygems.org"
-
- gem "rails", "3.0.0.rc"
- gem "nokogiri"
-
-
-
- When you run bundle install(1) bundle-install.1.html the first time,
- bundler will resolve all of the dependencies, all the way down, and
- install what you need:
-
-
-
- Fetching gem metadata from https://rubygems.org/.........
- Resolving dependencies...
- Installing builder 2.1.2
- Installing abstract 1.0.0
- Installing rack 1.2.8
- Using bundler 1.7.6
- Installing rake 10.4.0
- Installing polyglot 0.3.5
- Installing mime-types 1.25.1
- Installing i18n 0.4.2
- Installing mini_portile 0.6.1
- Installing tzinfo 0.3.42
- Installing rack-mount 0.6.14
- Installing rack-test 0.5.7
- Installing treetop 1.4.15
- Installing thor 0.14.6
- Installing activesupport 3.0.0.rc
- Installing erubis 2.6.6
- Installing activemodel 3.0.0.rc
- Installing arel 0.4.0
- Installing mail 2.2.20
- Installing activeresource 3.0.0.rc
- Installing actionpack 3.0.0.rc
- Installing activerecord 3.0.0.rc
- Installing actionmailer 3.0.0.rc
- Installing railties 3.0.0.rc
- Installing rails 3.0.0.rc
- Installing nokogiri 1.6.5
-
- Bundle complete! 2 Gemfile dependencies, 26 gems total.
- Use `bundle show [gemname]` to see where a bundled gem is installed.
-
-
-
- As you can see, even though you have two gems in the Gemfile(5), your
- application needs 26 different gems in order to run. Bundler remembers
- the exact versions it installed in Gemfile.lock. The next time you run
- bundle install(1) bundle-install.1.html, bundler skips the dependency
- resolution and installs the same gems as it installed last time.
-
- After checking in the Gemfile.lock into version control and cloning it
- on another machine, running bundle install(1) bundle-install.1.html
- will still install the gems that you installed last time. You don't
- need to worry that a new release of erubis or mail changes the gems you
- use.
-
- However, from time to time, you might want to update the gems you are
- using to the newest versions that still match the gems in your Gem-
- file(5).
-
- To do this, run bundle update --all, which will ignore the Gem-
- file.lock, and resolve all the dependencies again. Keep in mind that
- this process can result in a significantly different set of the 25
- gems, based on the requirements of new gems that the gem authors
- released since the last time you ran bundle update --all.
-
-UPDATING A LIST OF GEMS
- Sometimes, you want to update a single gem in the Gemfile(5), and leave
- the rest of the gems that you specified locked to the versions in the
- Gemfile.lock.
-
- For instance, in the scenario above, imagine that nokogiri releases
- version 1.4.4, and you want to update it without updating Rails and all
- of its dependencies. To do this, run bundle update nokogiri.
-
- Bundler will update nokogiri and any of its dependencies, but leave
- alone Rails and its dependencies.
-
-OVERLAPPING DEPENDENCIES
- Sometimes, multiple gems declared in your Gemfile(5) are satisfied by
- the same second-level dependency. For instance, consider the case of
- thin and rack-perftools-profiler.
-
-
-
- source "https://rubygems.org"
-
- gem "thin"
- gem "rack-perftools-profiler"
-
-
-
- The thin gem depends on rack >= 1.0, while rack-perftools-profiler
- depends on rack ~> 1.0. If you run bundle install, you get:
-
-
-
- Fetching source index for https://rubygems.org/
- Installing daemons (1.1.0)
- Installing eventmachine (0.12.10) with native extensions
- Installing open4 (1.0.1)
- Installing perftools.rb (0.4.7) with native extensions
- Installing rack (1.2.1)
- Installing rack-perftools_profiler (0.0.2)
- Installing thin (1.2.7) with native extensions
- Using bundler (1.0.0.rc.3)
-
-
-
- In this case, the two gems have their own set of dependencies, but they
- share rack in common. If you run bundle update thin, bundler will
- update daemons, eventmachine and rack, which are dependencies of thin,
- but not open4 or perftools.rb, which are dependencies of
- rack-perftools_profiler. Note that bundle update thin will update rack
- even though it's also a dependency of rack-perftools_profiler.
-
- In short, by default, when you update a gem using bundle update,
- bundler will update all dependencies of that gem, including those that
- are also dependencies of another gem.
-
- To prevent updating shared dependencies, prior to version 1.14 the only
- option was the CONSERVATIVE UPDATING behavior in bundle install(1) bun-
- dle-install.1.html:
-
- In this scenario, updating the thin version manually in the Gemfile(5),
- and then running bundle install(1) bundle-install.1.html will only
- update daemons and eventmachine, but not rack. For more information,
- see the CONSERVATIVE UPDATING section of bundle install(1) bun-
- dle-install.1.html.
-
- Starting with 1.14, specifying the --conservative option will also pre-
- vent shared dependencies from being updated.
-
-PATCH LEVEL OPTIONS
- Version 1.14 introduced 4 patch-level options that will influence how
- gem versions are resolved. One of the following options can be used:
- --patch, --minor or --major. --strict can be added to further influence
- resolution.
-
- --patch
- Prefer updating only to next patch version.
-
- --minor
- Prefer updating only to next minor version.
-
- --major
- Prefer updating to next major version (default).
-
- --strict
- Do not allow any gem to be updated past latest --patch | --minor
- | --major.
-
- When Bundler is resolving what versions to use to satisfy declared
- requirements in the Gemfile or in parent gems, it looks up all avail-
- able versions, filters out any versions that don't satisfy the require-
- ment, and then, by default, sorts them from newest to oldest, consider-
- ing them in that order.
-
- Providing one of the patch level options (e.g. --patch) changes the
- sort order of the satisfying versions, causing Bundler to consider the
- latest --patch or --minor version available before other versions. Note
- that versions outside the stated patch level could still be resolved to
- if necessary to find a suitable dependency graph.
-
- For example, if gem 'foo' is locked at 1.0.2, with no gem requirement
- defined in the Gemfile, and versions 1.0.3, 1.0.4, 1.1.0, 1.1.1, 2.0.0
- all exist, the default order of preference by default (--major) will be
- "2.0.0, 1.1.1, 1.1.0, 1.0.4, 1.0.3, 1.0.2".
-
- If the --patch option is used, the order of preference will change to
- "1.0.4, 1.0.3, 1.0.2, 1.1.1, 1.1.0, 2.0.0".
-
- If the --minor option is used, the order of preference will change to
- "1.1.1, 1.1.0, 1.0.4, 1.0.3, 1.0.2, 2.0.0".
-
- Combining the --strict option with any of the patch level options will
- remove any versions beyond the scope of the patch level option, to
- ensure that no gem is updated that far.
-
- To continue the previous example, if both --patch and --strict options
- are used, the available versions for resolution would be "1.0.4, 1.0.3,
- 1.0.2". If --minor and --strict are used, it would be "1.1.1, 1.1.0,
- 1.0.4, 1.0.3, 1.0.2".
-
- Gem requirements as defined in the Gemfile will still be the first
- determining factor for what versions are available. If the gem require-
- ment for foo in the Gemfile is '~> 1.0', that will accomplish the same
- thing as providing the --minor and --strict options.
-
-PATCH LEVEL EXAMPLES
- Given the following gem specifications:
-
-
-
- foo 1.4.3, requires: ~> bar 2.0
- foo 1.4.4, requires: ~> bar 2.0
- foo 1.4.5, requires: ~> bar 2.1
- foo 1.5.0, requires: ~> bar 2.1
- foo 1.5.1, requires: ~> bar 3.0
- bar with versions 2.0.3, 2.0.4, 2.1.0, 2.1.1, 3.0.0
-
-
-
- Gemfile:
-
-
-
- gem 'foo'
-
-
-
- Gemfile.lock:
-
-
-
- foo (1.4.3)
- bar (~> 2.0)
- bar (2.0.3)
-
-
-
- Cases:
-
-
-
- # Command Line Result
- ------------------------------------------------------------
- 1 bundle update --patch 'foo 1.4.5', 'bar 2.1.1'
- 2 bundle update --patch foo 'foo 1.4.5', 'bar 2.1.1'
- 3 bundle update --minor 'foo 1.5.1', 'bar 3.0.0'
- 4 bundle update --minor --strict 'foo 1.5.0', 'bar 2.1.1'
- 5 bundle update --patch --strict 'foo 1.4.4', 'bar 2.0.4'
-
-
-
- In case 1, bar is upgraded to 2.1.1, a minor version increase, because
- the dependency from foo 1.4.5 required it.
-
- In case 2, only foo is requested to be unlocked, but bar is also
- allowed to move because it's not a declared dependency in the Gemfile.
-
- In case 3, bar goes up a whole major release, because a minor increase
- is preferred now for foo, and when it goes to 1.5.1, it requires 3.0.0
- of bar.
-
- In case 4, foo is preferred up to a minor version, but 1.5.1 won't work
- because the --strict flag removes bar 3.0.0 from consideration since
- it's a major increment.
-
- In case 5, both foo and bar have any minor or major increments removed
- from consideration because of the --strict flag, so the most they can
- move is up to 1.4.4 and 2.0.4.
-
-RECOMMENDED WORKFLOW
- In general, when working with an application managed with bundler, you
- should use the following workflow:
-
- o After you create your Gemfile(5) for the first time, run
-
- $ bundle install
-
- o Check the resulting Gemfile.lock into version control
-
- $ git add Gemfile.lock
-
- o When checking out this repository on another development machine,
- run
-
- $ bundle install
-
- o When checking out this repository on a deployment machine, run
-
- $ bundle install --deployment
-
- o After changing the Gemfile(5) to reflect a new or update depen-
- dency, run
-
- $ bundle install
-
- o Make sure to check the updated Gemfile.lock into version control
-
- $ git add Gemfile.lock
-
- o If bundle install(1) bundle-install.1.html reports a conflict, man-
- ually update the specific gems that you changed in the Gemfile(5)
-
- $ bundle update rails thin
-
- o If you want to update all the gems to the latest possible versions
- that still match the gems listed in the Gemfile(5), run
-
- $ bundle update --all
-
-
-
-
-
-
- January 2020 BUNDLE-UPDATE(1)
diff --git a/man/bundle-update.ronn b/man/bundle-update.ronn
deleted file mode 100644
index 397fecadcb..0000000000
--- a/man/bundle-update.ronn
+++ /dev/null
@@ -1,350 +0,0 @@
-bundle-update(1) -- Update your gems to the latest available versions
-=====================================================================
-
-## SYNOPSIS
-
-`bundle update` <*gems> [--all]
- [--group=NAME]
- [--source=NAME]
- [--local]
- [--ruby]
- [--bundler[=VERSION]]
- [--full-index]
- [--jobs=JOBS]
- [--quiet]
- [--patch|--minor|--major]
- [--redownload]
- [--strict]
- [--conservative]
-
-## DESCRIPTION
-
-Update the gems specified (all gems, if `--all` flag is used), ignoring
-the previously installed gems specified in the `Gemfile.lock`. In
-general, you should use [bundle install(1)](bundle-install.1.html) to install the same exact
-gems and versions across machines.
-
-You would use `bundle update` to explicitly update the version of a
-gem.
-
-## OPTIONS
-
-* `--all`:
- Update all gems specified in Gemfile.
-
-* `--group=<name>`, `-g=[<name>]`:
- Only update the gems in the specified group. For instance, you can update all gems
- in the development group with `bundle update --group development`. You can also
- call `bundle update rails --group test` to update the rails gem and all gems in
- the test group, for example.
-
-* `--source=<name>`:
- The name of a `:git` or `:path` source used in the Gemfile(5). For
- instance, with a `:git` source of `http://github.com/rails/rails.git`,
- you would call `bundle update --source rails`
-
-* `--local`:
- Do not attempt to fetch gems remotely and use the gem cache instead.
-
-* `--ruby`:
- Update the locked version of Ruby to the current version of Ruby.
-
-* `--bundler`:
- Update the locked version of bundler to the invoked bundler version.
-
-* `--full-index`:
- Fall back to using the single-file index of all gems.
-
-* `--jobs=[<number>]`, `-j[<number>]`:
- Specify the number of jobs to run in parallel. The default is `1`.
-
-* `--retry=[<number>]`:
- Retry failed network or git requests for <number> times.
-
-* `--quiet`:
- Only output warnings and errors.
-
-* `--redownload`:
- Force downloading every gem.
-
-* `--patch`:
- Prefer updating only to next patch version.
-
-* `--minor`:
- Prefer updating only to next minor version.
-
-* `--major`:
- Prefer updating to next major version (default).
-
-* `--strict`:
- Do not allow any gem to be updated past latest `--patch` | `--minor` | `--major`.
-
-* `--conservative`:
- Use bundle install conservative update behavior and do not allow shared dependencies to be updated.
-
-## UPDATING ALL GEMS
-
-If you run `bundle update --all`, bundler will ignore
-any previously installed gems and resolve all dependencies again
-based on the latest versions of all gems available in the sources.
-
-Consider the following Gemfile(5):
-
- source "https://rubygems.org"
-
- gem "rails", "3.0.0.rc"
- gem "nokogiri"
-
-When you run [bundle install(1)](bundle-install.1.html) the first time, bundler will resolve
-all of the dependencies, all the way down, and install what you need:
-
- Fetching gem metadata from https://rubygems.org/.........
- Resolving dependencies...
- Installing builder 2.1.2
- Installing abstract 1.0.0
- Installing rack 1.2.8
- Using bundler 1.7.6
- Installing rake 10.4.0
- Installing polyglot 0.3.5
- Installing mime-types 1.25.1
- Installing i18n 0.4.2
- Installing mini_portile 0.6.1
- Installing tzinfo 0.3.42
- Installing rack-mount 0.6.14
- Installing rack-test 0.5.7
- Installing treetop 1.4.15
- Installing thor 0.14.6
- Installing activesupport 3.0.0.rc
- Installing erubis 2.6.6
- Installing activemodel 3.0.0.rc
- Installing arel 0.4.0
- Installing mail 2.2.20
- Installing activeresource 3.0.0.rc
- Installing actionpack 3.0.0.rc
- Installing activerecord 3.0.0.rc
- Installing actionmailer 3.0.0.rc
- Installing railties 3.0.0.rc
- Installing rails 3.0.0.rc
- Installing nokogiri 1.6.5
-
- Bundle complete! 2 Gemfile dependencies, 26 gems total.
- Use `bundle show [gemname]` to see where a bundled gem is installed.
-
-As you can see, even though you have two gems in the Gemfile(5), your application
-needs 26 different gems in order to run. Bundler remembers the exact versions
-it installed in `Gemfile.lock`. The next time you run [bundle install(1)](bundle-install.1.html), bundler skips
-the dependency resolution and installs the same gems as it installed last time.
-
-After checking in the `Gemfile.lock` into version control and cloning it on another
-machine, running [bundle install(1)](bundle-install.1.html) will _still_ install the gems that you installed
-last time. You don't need to worry that a new release of `erubis` or `mail` changes
-the gems you use.
-
-However, from time to time, you might want to update the gems you are using to the
-newest versions that still match the gems in your Gemfile(5).
-
-To do this, run `bundle update --all`, which will ignore the `Gemfile.lock`, and resolve
-all the dependencies again. Keep in mind that this process can result in a significantly
-different set of the 25 gems, based on the requirements of new gems that the gem
-authors released since the last time you ran `bundle update --all`.
-
-## UPDATING A LIST OF GEMS
-
-Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of the
-gems that you specified locked to the versions in the `Gemfile.lock`.
-
-For instance, in the scenario above, imagine that `nokogiri` releases version `1.4.4`, and
-you want to update it _without_ updating Rails and all of its dependencies. To do this,
-run `bundle update nokogiri`.
-
-Bundler will update `nokogiri` and any of its dependencies, but leave alone Rails and
-its dependencies.
-
-## OVERLAPPING DEPENDENCIES
-
-Sometimes, multiple gems declared in your Gemfile(5) are satisfied by the same
-second-level dependency. For instance, consider the case of `thin` and
-`rack-perftools-profiler`.
-
- source "https://rubygems.org"
-
- gem "thin"
- gem "rack-perftools-profiler"
-
-The `thin` gem depends on `rack >= 1.0`, while `rack-perftools-profiler` depends
-on `rack ~> 1.0`. If you run bundle install, you get:
-
- Fetching source index for https://rubygems.org/
- Installing daemons (1.1.0)
- Installing eventmachine (0.12.10) with native extensions
- Installing open4 (1.0.1)
- Installing perftools.rb (0.4.7) with native extensions
- Installing rack (1.2.1)
- Installing rack-perftools_profiler (0.0.2)
- Installing thin (1.2.7) with native extensions
- Using bundler (1.0.0.rc.3)
-
-In this case, the two gems have their own set of dependencies, but they share
-`rack` in common. If you run `bundle update thin`, bundler will update `daemons`,
-`eventmachine` and `rack`, which are dependencies of `thin`, but not `open4` or
-`perftools.rb`, which are dependencies of `rack-perftools_profiler`. Note that
-`bundle update thin` will update `rack` even though it's _also_ a dependency of
-`rack-perftools_profiler`.
-
-In short, by default, when you update a gem using `bundle update`, bundler will
-update all dependencies of that gem, including those that are also dependencies
-of another gem.
-
-To prevent updating shared dependencies, prior to version 1.14 the only option
-was the `CONSERVATIVE UPDATING` behavior in [bundle install(1)](bundle-install.1.html):
-
-In this scenario, updating the `thin` version manually in the Gemfile(5),
-and then running [bundle install(1)](bundle-install.1.html) will only update `daemons` and `eventmachine`,
-but not `rack`. For more information, see the `CONSERVATIVE UPDATING` section
-of [bundle install(1)](bundle-install.1.html).
-
-Starting with 1.14, specifying the `--conservative` option will also prevent shared
-dependencies from being updated.
-
-## PATCH LEVEL OPTIONS
-
-Version 1.14 introduced 4 patch-level options that will influence how gem
-versions are resolved. One of the following options can be used: `--patch`,
-`--minor` or `--major`. `--strict` can be added to further influence resolution.
-
-* `--patch`:
- Prefer updating only to next patch version.
-
-* `--minor`:
- Prefer updating only to next minor version.
-
-* `--major`:
- Prefer updating to next major version (default).
-
-* `--strict`:
- Do not allow any gem to be updated past latest `--patch` | `--minor` | `--major`.
-
-When Bundler is resolving what versions to use to satisfy declared
-requirements in the Gemfile or in parent gems, it looks up all
-available versions, filters out any versions that don't satisfy
-the requirement, and then, by default, sorts them from newest to
-oldest, considering them in that order.
-
-Providing one of the patch level options (e.g. `--patch`) changes the
-sort order of the satisfying versions, causing Bundler to consider the
-latest `--patch` or `--minor` version available before other versions.
-Note that versions outside the stated patch level could still be
-resolved to if necessary to find a suitable dependency graph.
-
-For example, if gem 'foo' is locked at 1.0.2, with no gem requirement
-defined in the Gemfile, and versions 1.0.3, 1.0.4, 1.1.0, 1.1.1, 2.0.0
-all exist, the default order of preference by default (`--major`) will
-be "2.0.0, 1.1.1, 1.1.0, 1.0.4, 1.0.3, 1.0.2".
-
-If the `--patch` option is used, the order of preference will change to
-"1.0.4, 1.0.3, 1.0.2, 1.1.1, 1.1.0, 2.0.0".
-
-If the `--minor` option is used, the order of preference will change to
-"1.1.1, 1.1.0, 1.0.4, 1.0.3, 1.0.2, 2.0.0".
-
-Combining the `--strict` option with any of the patch level options
-will remove any versions beyond the scope of the patch level option,
-to ensure that no gem is updated that far.
-
-To continue the previous example, if both `--patch` and `--strict`
-options are used, the available versions for resolution would be
-"1.0.4, 1.0.3, 1.0.2". If `--minor` and `--strict` are used, it would
-be "1.1.1, 1.1.0, 1.0.4, 1.0.3, 1.0.2".
-
-Gem requirements as defined in the Gemfile will still be the first
-determining factor for what versions are available. If the gem
-requirement for `foo` in the Gemfile is '~> 1.0', that will accomplish
-the same thing as providing the `--minor` and `--strict` options.
-
-## PATCH LEVEL EXAMPLES
-
-Given the following gem specifications:
-
- foo 1.4.3, requires: ~> bar 2.0
- foo 1.4.4, requires: ~> bar 2.0
- foo 1.4.5, requires: ~> bar 2.1
- foo 1.5.0, requires: ~> bar 2.1
- foo 1.5.1, requires: ~> bar 3.0
- bar with versions 2.0.3, 2.0.4, 2.1.0, 2.1.1, 3.0.0
-
-Gemfile:
-
- gem 'foo'
-
-Gemfile.lock:
-
- foo (1.4.3)
- bar (~> 2.0)
- bar (2.0.3)
-
-Cases:
-
- # Command Line Result
- ------------------------------------------------------------
- 1 bundle update --patch 'foo 1.4.5', 'bar 2.1.1'
- 2 bundle update --patch foo 'foo 1.4.5', 'bar 2.1.1'
- 3 bundle update --minor 'foo 1.5.1', 'bar 3.0.0'
- 4 bundle update --minor --strict 'foo 1.5.0', 'bar 2.1.1'
- 5 bundle update --patch --strict 'foo 1.4.4', 'bar 2.0.4'
-
-In case 1, bar is upgraded to 2.1.1, a minor version increase, because
-the dependency from foo 1.4.5 required it.
-
-In case 2, only foo is requested to be unlocked, but bar is also
-allowed to move because it's not a declared dependency in the Gemfile.
-
-In case 3, bar goes up a whole major release, because a minor increase
-is preferred now for foo, and when it goes to 1.5.1, it requires 3.0.0
-of bar.
-
-In case 4, foo is preferred up to a minor version, but 1.5.1 won't work
-because the --strict flag removes bar 3.0.0 from consideration since
-it's a major increment.
-
-In case 5, both foo and bar have any minor or major increments removed
-from consideration because of the --strict flag, so the most they can
-move is up to 1.4.4 and 2.0.4.
-
-## RECOMMENDED WORKFLOW
-
-In general, when working with an application managed with bundler, you should
-use the following workflow:
-
-* After you create your Gemfile(5) for the first time, run
-
- $ bundle install
-
-* Check the resulting `Gemfile.lock` into version control
-
- $ git add Gemfile.lock
-
-* When checking out this repository on another development machine, run
-
- $ bundle install
-
-* When checking out this repository on a deployment machine, run
-
- $ bundle install --deployment
-
-* After changing the Gemfile(5) to reflect a new or update dependency, run
-
- $ bundle install
-
-* Make sure to check the updated `Gemfile.lock` into version control
-
- $ git add Gemfile.lock
-
-* If [bundle install(1)](bundle-install.1.html) reports a conflict, manually update the specific
- gems that you changed in the Gemfile(5)
-
- $ bundle update rails thin
-
-* If you want to update all the gems to the latest possible versions that
- still match the gems listed in the Gemfile(5), run
-
- $ bundle update --all
diff --git a/man/bundle-viz.1 b/man/bundle-viz.1
deleted file mode 100644
index a2153da28d..0000000000
--- a/man/bundle-viz.1
+++ /dev/null
@@ -1,39 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-VIZ" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile
-.
-.SH "SYNOPSIS"
-\fBbundle viz\fR [\-\-file=FILE] [\-\-format=FORMAT] [\-\-requirements] [\-\-version] [\-\-without=GROUP GROUP]
-.
-.SH "DESCRIPTION"
-\fBviz\fR generates a PNG file of the current \fBGemfile(5)\fR as a dependency graph\. \fBviz\fR requires the ruby\-graphviz gem (and its dependencies)\.
-.
-.P
-The associated gems must also be installed via \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-file\fR, \fB\-f\fR
-The name to use for the generated file\. See \fB\-\-format\fR option
-.
-.TP
-\fB\-\-format\fR, \fB\-F\fR
-This is output format option\. Supported format is png, jpg, svg, dot \.\.\.
-.
-.TP
-\fB\-\-requirements\fR, \fB\-R\fR
-Set to show the version of each required dependency\.
-.
-.TP
-\fB\-\-version\fR, \fB\-v\fR
-Set to show each gem version\.
-.
-.TP
-\fB\-\-without\fR, \fB\-W\fR
-Exclude gems that are part of the specified named group\.
-
diff --git a/man/bundle-viz.1.txt b/man/bundle-viz.1.txt
deleted file mode 100644
index c934b4cf5b..0000000000
--- a/man/bundle-viz.1.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-BUNDLE-VIZ(1) BUNDLE-VIZ(1)
-
-
-
-NAME
- bundle-viz - Generates a visual dependency graph for your Gemfile
-
-SYNOPSIS
- bundle viz [--file=FILE] [--format=FORMAT] [--requirements] [--version]
- [--without=GROUP GROUP]
-
-DESCRIPTION
- viz generates a PNG file of the current Gemfile(5) as a dependency
- graph. viz requires the ruby-graphviz gem (and its dependencies).
-
- The associated gems must also be installed via bundle install(1) bun-
- dle-install.1.html.
-
-OPTIONS
- --file, -f
- The name to use for the generated file. See --format option
-
- --format, -F
- This is output format option. Supported format is png, jpg, svg,
- dot ...
-
- --requirements, -R
- Set to show the version of each required dependency.
-
- --version, -v
- Set to show each gem version.
-
- --without, -W
- Exclude gems that are part of the specified named group.
-
-
-
-
- January 2020 BUNDLE-VIZ(1)
diff --git a/man/bundle-viz.ronn b/man/bundle-viz.ronn
deleted file mode 100644
index 701df5415e..0000000000
--- a/man/bundle-viz.ronn
+++ /dev/null
@@ -1,30 +0,0 @@
-bundle-viz(1) -- Generates a visual dependency graph for your Gemfile
-=====================================================================
-
-## SYNOPSIS
-
-`bundle viz` [--file=FILE]
- [--format=FORMAT]
- [--requirements]
- [--version]
- [--without=GROUP GROUP]
-
-## DESCRIPTION
-
-`viz` generates a PNG file of the current `Gemfile(5)` as a dependency graph.
-`viz` requires the ruby-graphviz gem (and its dependencies).
-
-The associated gems must also be installed via [`bundle install(1)`](bundle-install.1.html).
-
-## OPTIONS
-
-* `--file`, `-f`:
- The name to use for the generated file. See `--format` option
-* `--format`, `-F`:
- This is output format option. Supported format is png, jpg, svg, dot ...
-* `--requirements`, `-R`:
- Set to show the version of each required dependency.
-* `--version`, `-v`:
- Set to show each gem version.
-* `--without`, `-W`:
- Exclude gems that are part of the specified named group.
diff --git a/man/bundle.1 b/man/bundle.1
deleted file mode 100644
index 4a9a9bec4d..0000000000
--- a/man/bundle.1
+++ /dev/null
@@ -1,136 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE" "1" "January 2020" "" ""
-.
-.SH "NAME"
-\fBbundle\fR \- Ruby Dependency Management
-.
-.SH "SYNOPSIS"
-\fBbundle\fR COMMAND [\-\-no\-color] [\-\-verbose] [ARGS]
-.
-.SH "DESCRIPTION"
-Bundler manages an \fBapplication\'s dependencies\fR through its entire life across many machines systematically and repeatably\.
-.
-.P
-See the bundler website \fIhttps://bundler\.io\fR for information on getting started, and Gemfile(5) for more information on the \fBGemfile\fR format\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-no\-color\fR
-Print all output without color
-.
-.TP
-\fB\-\-retry\fR, \fB\-r\fR
-Specify the number of times you wish to attempt network commands
-.
-.TP
-\fB\-\-verbose\fR, \fB\-V\fR
-Print out additional logging information
-.
-.SH "BUNDLE COMMANDS"
-We divide \fBbundle\fR subcommands into primary commands and utilities:
-.
-.SH "PRIMARY COMMANDS"
-.
-.TP
-\fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR
-Install the gems specified by the \fBGemfile\fR or \fBGemfile\.lock\fR
-.
-.TP
-\fBbundle update(1)\fR \fIbundle\-update\.1\.html\fR
-Update dependencies to their latest versions
-.
-.TP
-\fBbundle package(1)\fR \fIbundle\-package\.1\.html\fR
-Package the \.gem files required by your application into the \fBvendor/cache\fR directory
-.
-.TP
-\fBbundle exec(1)\fR \fIbundle\-exec\.1\.html\fR
-Execute a script in the current bundle
-.
-.TP
-\fBbundle config(1)\fR \fIbundle\-config\.1\.html\fR
-Specify and read configuration options for Bundler
-.
-.TP
-\fBbundle help(1)\fR
-Display detailed help for each subcommand
-.
-.SH "UTILITIES"
-.
-.TP
-\fBbundle add(1)\fR \fIbundle\-add\.1\.html\fR
-Add the named gem to the Gemfile and run \fBbundle install\fR
-.
-.TP
-\fBbundle binstubs(1)\fR \fIbundle\-binstubs\.1\.html\fR
-Generate binstubs for executables in a gem
-.
-.TP
-\fBbundle check(1)\fR \fIbundle\-check\.1\.html\fR
-Determine whether the requirements for your application are installed and available to Bundler
-.
-.TP
-\fBbundle show(1)\fR \fIbundle\-show\.1\.html\fR
-Show the source location of a particular gem in the bundle
-.
-.TP
-\fBbundle outdated(1)\fR \fIbundle\-outdated\.1\.html\fR
-Show all of the outdated gems in the current bundle
-.
-.TP
-\fBbundle console(1)\fR
-Start an IRB session in the current bundle
-.
-.TP
-\fBbundle open(1)\fR \fIbundle\-open\.1\.html\fR
-Open an installed gem in the editor
-.
-.TP
-\fBbundle lock(1)\fR \fIbundle\-lock\.1\.html\fR
-Generate a lockfile for your dependencies
-.
-.TP
-\fBbundle viz(1)\fR \fIbundle\-viz\.1\.html\fR
-Generate a visual representation of your dependencies
-.
-.TP
-\fBbundle init(1)\fR \fIbundle\-init\.1\.html\fR
-Generate a simple \fBGemfile\fR, placed in the current directory
-.
-.TP
-\fBbundle gem(1)\fR \fIbundle\-gem\.1\.html\fR
-Create a simple gem, suitable for development with Bundler
-.
-.TP
-\fBbundle platform(1)\fR \fIbundle\-platform\.1\.html\fR
-Display platform compatibility information
-.
-.TP
-\fBbundle clean(1)\fR \fIbundle\-clean\.1\.html\fR
-Clean up unused gems in your Bundler directory
-.
-.TP
-\fBbundle doctor(1)\fR \fIbundle\-doctor\.1\.html\fR
-Display warnings about common problems
-.
-.TP
-\fBbundle remove(1)\fR \fIbundle\-remove\.1\.html\fR
-Removes gems from the Gemfile
-.
-.SH "PLUGINS"
-When running a command that isn\'t listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named \fBbundler\-<command>\fR and execute it, passing down any extra arguments to it\.
-.
-.SH "OBSOLETE"
-These commands are obsolete and should no longer be used:
-.
-.IP "\(bu" 4
-\fBbundle cache(1)\fR
-.
-.IP "\(bu" 4
-\fBbundle show(1)\fR
-.
-.IP "" 0
-
diff --git a/man/bundle.1.txt b/man/bundle.1.txt
deleted file mode 100644
index e7eb35aa14..0000000000
--- a/man/bundle.1.txt
+++ /dev/null
@@ -1,116 +0,0 @@
-BUNDLE(1) BUNDLE(1)
-
-
-
-NAME
- bundle - Ruby Dependency Management
-
-SYNOPSIS
- bundle COMMAND [--no-color] [--verbose] [ARGS]
-
-DESCRIPTION
- Bundler manages an application's dependencies through its entire life
- across many machines systematically and repeatably.
-
- See the bundler website https://bundler.io for information on getting
- started, and Gemfile(5) for more information on the Gemfile format.
-
-OPTIONS
- --no-color
- Print all output without color
-
- --retry, -r
- Specify the number of times you wish to attempt network commands
-
- --verbose, -V
- Print out additional logging information
-
-BUNDLE COMMANDS
- We divide bundle subcommands into primary commands and utilities:
-
-PRIMARY COMMANDS
- bundle install(1) bundle-install.1.html
- Install the gems specified by the Gemfile or Gemfile.lock
-
- bundle update(1) bundle-update.1.html
- Update dependencies to their latest versions
-
- bundle package(1) bundle-package.1.html
- Package the .gem files required by your application into the
- vendor/cache directory
-
- bundle exec(1) bundle-exec.1.html
- Execute a script in the current bundle
-
- bundle config(1) bundle-config.1.html
- Specify and read configuration options for Bundler
-
- bundle help(1)
- Display detailed help for each subcommand
-
-UTILITIES
- bundle add(1) bundle-add.1.html
- Add the named gem to the Gemfile and run bundle install
-
- bundle binstubs(1) bundle-binstubs.1.html
- Generate binstubs for executables in a gem
-
- bundle check(1) bundle-check.1.html
- Determine whether the requirements for your application are
- installed and available to Bundler
-
- bundle show(1) bundle-show.1.html
- Show the source location of a particular gem in the bundle
-
- bundle outdated(1) bundle-outdated.1.html
- Show all of the outdated gems in the current bundle
-
- bundle console(1)
- Start an IRB session in the current bundle
-
- bundle open(1) bundle-open.1.html
- Open an installed gem in the editor
-
- bundle lock(1) bundle-lock.1.html
- Generate a lockfile for your dependencies
-
- bundle viz(1) bundle-viz.1.html
- Generate a visual representation of your dependencies
-
- bundle init(1) bundle-init.1.html
- Generate a simple Gemfile, placed in the current directory
-
- bundle gem(1) bundle-gem.1.html
- Create a simple gem, suitable for development with Bundler
-
- bundle platform(1) bundle-platform.1.html
- Display platform compatibility information
-
- bundle clean(1) bundle-clean.1.html
- Clean up unused gems in your Bundler directory
-
- bundle doctor(1) bundle-doctor.1.html
- Display warnings about common problems
-
- bundle remove(1) bundle-remove.1.html
- Removes gems from the Gemfile
-
-PLUGINS
- When running a command that isn't listed in PRIMARY COMMANDS or UTILI-
- TIES, Bundler will try to find an executable on your path named
- bundler-<command> and execute it, passing down any extra arguments to
- it.
-
-OBSOLETE
- These commands are obsolete and should no longer be used:
-
- o bundle cache(1)
-
- o bundle show(1)
-
-
-
-
-
-
- January 2020 BUNDLE(1)
diff --git a/man/bundle.ronn b/man/bundle.ronn
deleted file mode 100644
index 5b1712394a..0000000000
--- a/man/bundle.ronn
+++ /dev/null
@@ -1,111 +0,0 @@
-bundle(1) -- Ruby Dependency Management
-=======================================
-
-## SYNOPSIS
-
-`bundle` COMMAND [--no-color] [--verbose] [ARGS]
-
-## DESCRIPTION
-
-Bundler manages an `application's dependencies` through its entire life
-across many machines systematically and repeatably.
-
-See [the bundler website](https://bundler.io) for information on getting
-started, and Gemfile(5) for more information on the `Gemfile` format.
-
-## OPTIONS
-
-* `--no-color`:
- Print all output without color
-
-* `--retry`, `-r`:
- Specify the number of times you wish to attempt network commands
-
-* `--verbose`, `-V`:
- Print out additional logging information
-
-## BUNDLE COMMANDS
-
-We divide `bundle` subcommands into primary commands and utilities:
-
-## PRIMARY COMMANDS
-
-* [`bundle install(1)`](bundle-install.1.html):
- Install the gems specified by the `Gemfile` or `Gemfile.lock`
-
-* [`bundle update(1)`](bundle-update.1.html):
- Update dependencies to their latest versions
-
-* [`bundle package(1)`](bundle-package.1.html):
- Package the .gem files required by your application into the
- `vendor/cache` directory
-
-* [`bundle exec(1)`](bundle-exec.1.html):
- Execute a script in the current bundle
-
-* [`bundle config(1)`](bundle-config.1.html):
- Specify and read configuration options for Bundler
-
-* `bundle help(1)`:
- Display detailed help for each subcommand
-
-## UTILITIES
-
-* [`bundle add(1)`](bundle-add.1.html):
- Add the named gem to the Gemfile and run `bundle install`
-
-* [`bundle binstubs(1)`](bundle-binstubs.1.html):
- Generate binstubs for executables in a gem
-
-* [`bundle check(1)`](bundle-check.1.html):
- Determine whether the requirements for your application are installed
- and available to Bundler
-
-* [`bundle show(1)`](bundle-show.1.html):
- Show the source location of a particular gem in the bundle
-
-* [`bundle outdated(1)`](bundle-outdated.1.html):
- Show all of the outdated gems in the current bundle
-
-* `bundle console(1)`:
- Start an IRB session in the current bundle
-
-* [`bundle open(1)`](bundle-open.1.html):
- Open an installed gem in the editor
-
-* [`bundle lock(1)`](bundle-lock.1.html):
- Generate a lockfile for your dependencies
-
-* [`bundle viz(1)`](bundle-viz.1.html):
- Generate a visual representation of your dependencies
-
-* [`bundle init(1)`](bundle-init.1.html):
- Generate a simple `Gemfile`, placed in the current directory
-
-* [`bundle gem(1)`](bundle-gem.1.html):
- Create a simple gem, suitable for development with Bundler
-
-* [`bundle platform(1)`](bundle-platform.1.html):
- Display platform compatibility information
-
-* [`bundle clean(1)`](bundle-clean.1.html):
- Clean up unused gems in your Bundler directory
-
-* [`bundle doctor(1)`](bundle-doctor.1.html):
- Display warnings about common problems
-
-* [`bundle remove(1)`](bundle-remove.1.html):
- Removes gems from the Gemfile
-
-## PLUGINS
-
-When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES,
-Bundler will try to find an executable on your path named `bundler-<command>`
-and execute it, passing down any extra arguments to it.
-
-## OBSOLETE
-
-These commands are obsolete and should no longer be used:
-
-* `bundle cache(1)`
-* `bundle show(1)`
diff --git a/man/erb.1 b/man/erb.1
index d8739a7639..3b350e0064 100644
--- a/man/erb.1
+++ b/man/erb.1
@@ -1,5 +1,5 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd December 16, 2018
+.Dd November 15, 2012
.Dt ERB \&1 "Ruby Programmer's Reference Guide"
.Os UNIX
.Sh NAME
@@ -45,8 +45,9 @@ You can omit the one for internal encodings, then the value
.Pf ( Li "Encoding.default_internal" ) will be nil.
.Pp
.It Fl P
-Disables ruby code evaluation for lines beginning with
-.Li "%" .
+Evaluates lines starting with
+.Li "%"
+as Ruby code and removes the tailing EOLs.
.Pp
.It Fl S Ar level
Specifies the safe level in which eRuby script will run.
diff --git a/man/gemfile.5 b/man/gemfile.5
deleted file mode 100644
index a9d2cee7c7..0000000000
--- a/man/gemfile.5
+++ /dev/null
@@ -1,686 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "GEMFILE" "5" "January 2020" "" ""
-.
-.SH "NAME"
-\fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
-.
-.SH "SYNOPSIS"
-A \fBGemfile\fR describes the gem dependencies required to execute associated Ruby code\.
-.
-.P
-Place the \fBGemfile\fR in the root of the directory containing the associated code\. For instance, in a Rails application, place the \fBGemfile\fR in the same directory as the \fBRakefile\fR\.
-.
-.SH "SYNTAX"
-A \fBGemfile\fR is evaluated as Ruby code, in a context which makes available a number of methods used to describe the gem requirements\.
-.
-.SH "GLOBAL SOURCES"
-At the top of the \fBGemfile\fR, add a line for the \fBRubygems\fR source that contains the gems listed in the \fBGemfile\fR\.
-.
-.IP "" 4
-.
-.nf
-
-source "https://rubygems\.org"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-It is possible, but not recommended as of Bundler 1\.7, to add multiple global \fBsource\fR lines\. Each of these \fBsource\fRs \fBMUST\fR be a valid Rubygems repository\.
-.
-.P
-Sources are checked for gems following the heuristics described in \fISOURCE PRIORITY\fR\. If a gem is found in more than one global source, Bundler will print a warning after installing the gem indicating which source was used, and listing the other sources where the gem is available\. A specific source can be selected for gems that need to use a non\-standard repository, suppressing this warning, by using the \fI\fB:source\fR option\fR or a \fI\fBsource\fR block\fR\.
-.
-.SS "CREDENTIALS"
-Some gem sources require a username and password\. Use bundle config(1) \fIbundle\-config\.1\.html\fR to set the username and password for any of the sources that need it\. The command must be run once on each computer that will install the Gemfile, but this keeps the credentials from being stored in plain text in version control\.
-.
-.IP "" 4
-.
-.nf
-
-bundle config gems\.example\.com user:password
-.
-.fi
-.
-.IP "" 0
-.
-.P
-For some sources, like a company Gemfury account, it may be easier to include the credentials in the Gemfile as part of the source URL\.
-.
-.IP "" 4
-.
-.nf
-
-source "https://user:password@gems\.example\.com"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Credentials in the source URL will take precedence over credentials set using \fBconfig\fR\.
-.
-.SH "RUBY"
-If your application requires a specific Ruby version or engine, specify your requirements using the \fBruby\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
-.
-.SS "VERSION (required)"
-The version of Ruby that your application requires\. If your application requires an alternate Ruby engine, such as JRuby, Rubinius or TruffleRuby, this should be the Ruby version that the engine is compatible with\.
-.
-.IP "" 4
-.
-.nf
-
-ruby "1\.9\.3"
-.
-.fi
-.
-.IP "" 0
-.
-.SS "ENGINE"
-Each application \fImay\fR specify a Ruby engine\. If an engine is specified, an engine version \fImust\fR also be specified\.
-.
-.P
-What exactly is an Engine? \- A Ruby engine is an implementation of the Ruby language\.
-.
-.IP "\(bu" 4
-For background: the reference or original implementation of the Ruby programming language is called Matz\'s Ruby Interpreter \fIhttps://en\.wikipedia\.org/wiki/Ruby_MRI\fR, or MRI for short\. This is named after Ruby creator Yukihiro Matsumoto, also known as Matz\. MRI is also known as CRuby, because it is written in C\. MRI is the most widely used Ruby engine\.
-.
-.IP "\(bu" 4
-Other implementations \fIhttps://www\.ruby\-lang\.org/en/about/\fR of Ruby exist\. Some of the more well\-known implementations include Rubinius \fIhttps://rubinius\.com/\fR, and JRuby \fIhttp://jruby\.org/\fR\. Rubinius is an alternative implementation of Ruby written in Ruby\. JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine\.
-.
-.IP "" 0
-.
-.SS "ENGINE VERSION"
-Each application \fImay\fR specify a Ruby engine version\. If an engine version is specified, an engine \fImust\fR also be specified\. If the engine is "ruby" the engine version specified \fImust\fR match the Ruby version\.
-.
-.IP "" 4
-.
-.nf
-
-ruby "1\.8\.7", :engine => "jruby", :engine_version => "1\.6\.7"
-.
-.fi
-.
-.IP "" 0
-.
-.SS "PATCHLEVEL"
-Each application \fImay\fR specify a Ruby patchlevel\.
-.
-.IP "" 4
-.
-.nf
-
-ruby "2\.0\.0", :patchlevel => "247"
-.
-.fi
-.
-.IP "" 0
-.
-.SH "GEMS"
-Specify gem requirements using the \fBgem\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
-.
-.SS "NAME (required)"
-For each gem requirement, list a single \fIgem\fR line\.
-.
-.IP "" 4
-.
-.nf
-
-gem "nokogiri"
-.
-.fi
-.
-.IP "" 0
-.
-.SS "VERSION"
-Each \fIgem\fR \fBMAY\fR have one or more version specifiers\.
-.
-.IP "" 4
-.
-.nf
-
-gem "nokogiri", ">= 1\.4\.2"
-gem "RedCloth", ">= 4\.1\.0", "< 4\.2\.0"
-.
-.fi
-.
-.IP "" 0
-.
-.SS "REQUIRE AS"
-Each \fIgem\fR \fBMAY\fR specify files that should be used when autorequiring via \fBBundler\.require\fR\. You may pass an array with multiple files or \fBtrue\fR if file you want \fBrequired\fR has same name as \fIgem\fR or \fBfalse\fR to prevent any file from being autorequired\.
-.
-.IP "" 4
-.
-.nf
-
-gem "redis", :require => ["redis/connection/hiredis", "redis"]
-gem "webmock", :require => false
-gem "byebug", :require => true
-.
-.fi
-.
-.IP "" 0
-.
-.P
-The argument defaults to the name of the gem\. For example, these are identical:
-.
-.IP "" 4
-.
-.nf
-
-gem "nokogiri"
-gem "nokogiri", :require => "nokogiri"
-gem "nokogiri", :require => true
-.
-.fi
-.
-.IP "" 0
-.
-.SS "GROUPS"
-Each \fIgem\fR \fBMAY\fR specify membership in one or more groups\. Any \fIgem\fR that does not specify membership in any group is placed in the \fBdefault\fR group\.
-.
-.IP "" 4
-.
-.nf
-
-gem "rspec", :group => :test
-gem "wirble", :groups => [:development, :test]
-.
-.fi
-.
-.IP "" 0
-.
-.P
-The Bundler runtime allows its two main methods, \fBBundler\.setup\fR and \fBBundler\.require\fR, to limit their impact to particular groups\.
-.
-.IP "" 4
-.
-.nf
-
-# setup adds gems to Ruby\'s load path
-Bundler\.setup # defaults to all groups
-require "bundler/setup" # same as Bundler\.setup
-Bundler\.setup(:default) # only set up the _default_ group
-Bundler\.setup(:test) # only set up the _test_ group (but `not` _default_)
-Bundler\.setup(:default, :test) # set up the _default_ and _test_ groups, but no others
-
-# require requires all of the gems in the specified groups
-Bundler\.require # defaults to the _default_ group
-Bundler\.require(:default) # identical
-Bundler\.require(:default, :test) # requires the _default_ and _test_ groups
-Bundler\.require(:test) # requires the _test_ group
-.
-.fi
-.
-.IP "" 0
-.
-.P
-The Bundler CLI allows you to specify a list of groups whose gems \fBbundle install\fR should not install with the \fBwithout\fR configuration\.
-.
-.P
-To specify multiple groups to ignore, specify a list of groups separated by spaces\.
-.
-.IP "" 4
-.
-.nf
-
-bundle config set without test
-bundle config set without development test
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Also, calling \fBBundler\.setup\fR with no parameters, or calling \fBrequire "bundler/setup"\fR will setup all groups except for the ones you excluded via \fB\-\-without\fR (since they are not available)\.
-.
-.P
-Note that on \fBbundle install\fR, bundler downloads and evaluates all gems, in order to create a single canonical list of all of the required gems and their dependencies\. This means that you cannot list different versions of the same gems in different groups\. For more details, see Understanding Bundler \fIhttps://bundler\.io/rationale\.html\fR\.
-.
-.SS "PLATFORMS"
-If a gem should only be used in a particular platform or set of platforms, you can specify them\. Platforms are essentially identical to groups, except that you do not need to use the \fB\-\-without\fR install\-time flag to exclude groups of gems for other platforms\.
-.
-.P
-There are a number of \fBGemfile\fR platforms:
-.
-.TP
-\fBruby\fR
-C Ruby (MRI), Rubinius or TruffleRuby, but \fBNOT\fR Windows
-.
-.TP
-\fBmri\fR
-Same as \fIruby\fR, but only C Ruby (MRI)
-.
-.TP
-\fBmingw\fR
-Windows 32 bit \'mingw32\' platform (aka RubyInstaller)
-.
-.TP
-\fBx64_mingw\fR
-Windows 64 bit \'mingw32\' platform (aka RubyInstaller x64)
-.
-.TP
-\fBrbx\fR
-Rubinius
-.
-.TP
-\fBjruby\fR
-JRuby
-.
-.TP
-\fBtruffleruby\fR
-TruffleRuby
-.
-.TP
-\fBmswin\fR
-Windows
-.
-.P
-You can restrict further by platform and version for all platforms \fIexcept\fR for \fBrbx\fR, \fBjruby\fR, \fBtruffleruby\fR and \fBmswin\fR\.
-.
-.P
-To specify a version in addition to a platform, append the version number without the delimiter to the platform\. For example, to specify that a gem should only be used on platforms with Ruby 2\.3, use:
-.
-.IP "" 4
-.
-.nf
-
-ruby_23
-.
-.fi
-.
-.IP "" 0
-.
-.P
-The full list of platforms and supported versions includes:
-.
-.TP
-\fBruby\fR
-1\.8, 1\.9, 2\.0, 2\.1, 2\.2, 2\.3, 2\.4, 2\.5, 2\.6
-.
-.TP
-\fBmri\fR
-1\.8, 1\.9, 2\.0, 2\.1, 2\.2, 2\.3, 2\.4, 2\.5, 2\.6
-.
-.TP
-\fBmingw\fR
-1\.8, 1\.9, 2\.0, 2\.1, 2\.2, 2\.3, 2\.4, 2\.5, 2\.6
-.
-.TP
-\fBx64_mingw\fR
-2\.0, 2\.1, 2\.2, 2\.3, 2\.4, 2\.5, 2\.6
-.
-.P
-As with groups, you can specify one or more platforms:
-.
-.IP "" 4
-.
-.nf
-
-gem "weakling", :platforms => :jruby
-gem "ruby\-debug", :platforms => :mri_18
-gem "nokogiri", :platforms => [:mri_18, :jruby]
-.
-.fi
-.
-.IP "" 0
-.
-.P
-All operations involving groups (\fBbundle install\fR \fIbundle\-install\.1\.html\fR, \fBBundler\.setup\fR, \fBBundler\.require\fR) behave exactly the same as if any groups not matching the current platform were explicitly excluded\.
-.
-.SS "SOURCE"
-You can select an alternate Rubygems repository for a gem using the \':source\' option\.
-.
-.IP "" 4
-.
-.nf
-
-gem "some_internal_gem", :source => "https://gems\.example\.com"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-This forces the gem to be loaded from this source and ignores any global sources declared at the top level of the file\. If the gem does not exist in this source, it will not be installed\.
-.
-.P
-Bundler will search for child dependencies of this gem by first looking in the source selected for the parent, but if they are not found there, it will fall back on global sources using the ordering described in \fISOURCE PRIORITY\fR\.
-.
-.P
-Selecting a specific source repository this way also suppresses the ambiguous gem warning described above in \fIGLOBAL SOURCES (#source)\fR\.
-.
-.P
-Using the \fB:source\fR option for an individual gem will also make that source available as a possible global source for any other gems which do not specify explicit sources\. Thus, when adding gems with explicit sources, it is recommended that you also ensure all other gems in the Gemfile are using explicit sources\.
-.
-.SS "GIT"
-If necessary, you can specify that a gem is located at a particular git repository using the \fB:git\fR parameter\. The repository can be accessed via several protocols:
-.
-.TP
-\fBHTTP(S)\fR
-gem "rails", :git => "https://github\.com/rails/rails\.git"
-.
-.TP
-\fBSSH\fR
-gem "rails", :git => "git@github\.com:rails/rails\.git"
-.
-.TP
-\fBgit\fR
-gem "rails", :git => "git://github\.com/rails/rails\.git"
-.
-.P
-If using SSH, the user that you use to run \fBbundle install\fR \fBMUST\fR have the appropriate keys available in their \fB$HOME/\.ssh\fR\.
-.
-.P
-\fBNOTE\fR: \fBhttp://\fR and \fBgit://\fR URLs should be avoided if at all possible\. These protocols are unauthenticated, so a man\-in\-the\-middle attacker can deliver malicious code and compromise your system\. HTTPS and SSH are strongly preferred\.
-.
-.P
-The \fBgroup\fR, \fBplatforms\fR, and \fBrequire\fR options are available and behave exactly the same as they would for a normal gem\.
-.
-.P
-A git repository \fBSHOULD\fR have at least one file, at the root of the directory containing the gem, with the extension \fB\.gemspec\fR\. This file \fBMUST\fR contain a valid gem specification, as expected by the \fBgem build\fR command\.
-.
-.P
-If a git repository does not have a \fB\.gemspec\fR, bundler will attempt to create one, but it will not contain any dependencies, executables, or C extension compilation instructions\. As a result, it may fail to properly integrate into your application\.
-.
-.P
-If a git repository does have a \fB\.gemspec\fR for the gem you attached it to, a version specifier, if provided, means that the git repository is only valid if the \fB\.gemspec\fR specifies a version matching the version specifier\. If not, bundler will print a warning\.
-.
-.IP "" 4
-.
-.nf
-
-gem "rails", "2\.3\.8", :git => "https://github\.com/rails/rails\.git"
-# bundle install will fail, because the \.gemspec in the rails
-# repository\'s master branch specifies version 3\.0\.0
-.
-.fi
-.
-.IP "" 0
-.
-.P
-If a git repository does \fBnot\fR have a \fB\.gemspec\fR for the gem you attached it to, a version specifier \fBMUST\fR be provided\. Bundler will use this version in the simple \fB\.gemspec\fR it creates\.
-.
-.P
-Git repositories support a number of additional options\.
-.
-.TP
-\fBbranch\fR, \fBtag\fR, and \fBref\fR
-You \fBMUST\fR only specify at most one of these options\. The default is \fB:branch => "master"\fR\. For example:
-.
-.IP
-gem "rails", :git => "https://github\.com/rails/rails\.git", :branch => "5\-0\-stable"
-.
-.IP
-gem "rails", :git => "https://github\.com/rails/rails\.git", :tag => "v5\.0\.0"
-.
-.IP
-gem "rails", :git => "https://github\.com/rails/rails\.git", :ref => "4aded"
-.
-.TP
-\fBsubmodules\fR
-For reference, a git submodule \fIhttps://git\-scm\.com/book/en/v2/Git\-Tools\-Submodules\fR lets you have another git repository within a subfolder of your repository\. Specify \fB:submodules => true\fR to cause bundler to expand any submodules included in the git repository
-.
-.P
-If a git repository contains multiple \fB\.gemspecs\fR, each \fB\.gemspec\fR represents a gem located at the same place in the file system as the \fB\.gemspec\fR\.
-.
-.IP "" 4
-.
-.nf
-
-|~rails [git root]
-| |\-rails\.gemspec [rails gem located here]
-|~actionpack
-| |\-actionpack\.gemspec [actionpack gem located here]
-|~activesupport
-| |\-activesupport\.gemspec [activesupport gem located here]
-|\.\.\.
-.
-.fi
-.
-.IP "" 0
-.
-.P
-To install a gem located in a git repository, bundler changes to the directory containing the gemspec, runs \fBgem build name\.gemspec\fR and then installs the resulting gem\. The \fBgem build\fR command, which comes standard with Rubygems, evaluates the \fB\.gemspec\fR in the context of the directory in which it is located\.
-.
-.SS "GIT SOURCE"
-A custom git source can be defined via the \fBgit_source\fR method\. Provide the source\'s name as an argument, and a block which receives a single argument and interpolates it into a string to return the full repo address:
-.
-.IP "" 4
-.
-.nf
-
-git_source(:stash){ |repo_name| "https://stash\.corp\.acme\.pl/#{repo_name}\.git" }
-gem \'rails\', :stash => \'forks/rails\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-In addition, if you wish to choose a specific branch:
-.
-.IP "" 4
-.
-.nf
-
-gem "rails", :stash => "forks/rails", :branch => "branch_name"
-.
-.fi
-.
-.IP "" 0
-.
-.SS "GITHUB"
-\fBNOTE\fR: This shorthand should be avoided until Bundler 2\.0, since it currently expands to an insecure \fBgit://\fR URL\. This allows a man\-in\-the\-middle attacker to compromise your system\.
-.
-.P
-If the git repository you want to use is hosted on GitHub and is public, you can use the :github shorthand to specify the github username and repository name (without the trailing "\.git"), separated by a slash\. If both the username and repository name are the same, you can omit one\.
-.
-.IP "" 4
-.
-.nf
-
-gem "rails", :github => "rails/rails"
-gem "rails", :github => "rails"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Are both equivalent to
-.
-.IP "" 4
-.
-.nf
-
-gem "rails", :git => "git://github\.com/rails/rails\.git"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Since the \fBgithub\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
-.SS "GIST"
-If the git repository you want to use is hosted as a Github Gist and is public, you can use the :gist shorthand to specify the gist identifier (without the trailing "\.git")\.
-.
-.IP "" 4
-.
-.nf
-
-gem "the_hatch", :gist => "4815162342"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Is equivalent to:
-.
-.IP "" 4
-.
-.nf
-
-gem "the_hatch", :git => "https://gist\.github\.com/4815162342\.git"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Since the \fBgist\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
-.SS "BITBUCKET"
-If the git repository you want to use is hosted on Bitbucket and is public, you can use the :bitbucket shorthand to specify the bitbucket username and repository name (without the trailing "\.git"), separated by a slash\. If both the username and repository name are the same, you can omit one\.
-.
-.IP "" 4
-.
-.nf
-
-gem "rails", :bitbucket => "rails/rails"
-gem "rails", :bitbucket => "rails"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Are both equivalent to
-.
-.IP "" 4
-.
-.nf
-
-gem "rails", :git => "https://rails@bitbucket\.org/rails/rails\.git"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Since the \fBbitbucket\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
-.SS "PATH"
-You can specify that a gem is located in a particular location on the file system\. Relative paths are resolved relative to the directory containing the \fBGemfile\fR\.
-.
-.P
-Similar to the semantics of the \fB:git\fR option, the \fB:path\fR option requires that the directory in question either contains a \fB\.gemspec\fR for the gem, or that you specify an explicit version that bundler should use\.
-.
-.P
-Unlike \fB:git\fR, bundler does not compile C extensions for gems specified as paths\.
-.
-.IP "" 4
-.
-.nf
-
-gem "rails", :path => "vendor/rails"
-.
-.fi
-.
-.IP "" 0
-.
-.P
-If you would like to use multiple local gems directly from the filesystem, you can set a global \fBpath\fR option to the path containing the gem\'s files\. This will automatically load gemspec files from subdirectories\.
-.
-.IP "" 4
-.
-.nf
-
-path \'components\' do
- gem \'admin_ui\'
- gem \'public_ui\'
-end
-.
-.fi
-.
-.IP "" 0
-.
-.SH "BLOCK FORM OF SOURCE, GIT, PATH, GROUP and PLATFORMS"
-The \fB:source\fR, \fB:git\fR, \fB:path\fR, \fB:group\fR, and \fB:platforms\fR options may be applied to a group of gems by using block form\.
-.
-.IP "" 4
-.
-.nf
-
-source "https://gems\.example\.com" do
- gem "some_internal_gem"
- gem "another_internal_gem"
-end
-
-git "https://github\.com/rails/rails\.git" do
- gem "activesupport"
- gem "actionpack"
-end
-
-platforms :ruby do
- gem "ruby\-debug"
- gem "sqlite3"
-end
-
-group :development, :optional => true do
- gem "wirble"
- gem "faker"
-end
-.
-.fi
-.
-.IP "" 0
-.
-.P
-In the case of the group block form the :optional option can be given to prevent a group from being installed unless listed in the \fB\-\-with\fR option given to the \fBbundle install\fR command\.
-.
-.P
-In the case of the \fBgit\fR block form, the \fB:ref\fR, \fB:branch\fR, \fB:tag\fR, and \fB:submodules\fR options may be passed to the \fBgit\fR method, and all gems in the block will inherit those options\.
-.
-.P
-The presence of a \fBsource\fR block in a Gemfile also makes that source available as a possible global source for any other gems which do not specify explicit sources\. Thus, when defining source blocks, it is recommended that you also ensure all other gems in the Gemfile are using explicit sources, either via source blocks or \fB:source\fR directives on individual gems\.
-.
-.SH "INSTALL_IF"
-The \fBinstall_if\fR method allows gems to be installed based on a proc or lambda\. This is especially useful for optional gems that can only be used if certain software is installed or some other conditions are met\.
-.
-.IP "" 4
-.
-.nf
-
-install_if \-> { RUBY_PLATFORM =~ /darwin/ } do
- gem "pasteboard"
-end
-.
-.fi
-.
-.IP "" 0
-.
-.SH "GEMSPEC"
-The \fB\.gemspec\fR \fIhttp://guides\.rubygems\.org/specification\-reference/\fR file is where you provide metadata about your gem to Rubygems\. Some required Gemspec attributes include the name, description, and homepage of your gem\. This is also where you specify the dependencies your gem needs to run\.
-.
-.P
-If you wish to use Bundler to help install dependencies for a gem while it is being developed, use the \fBgemspec\fR method to pull in the dependencies listed in the \fB\.gemspec\fR file\.
-.
-.P
-The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fB:path => \'\.\'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
-.
-.P
-The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, the glob it uses to look for the gemspec (defaults to: "{,\fI,\fR/*}\.gemspec"), what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
-.
-.P
-When a \fBgemspec\fR dependency encounters version conflicts during resolution, the local version under development will always be selected \-\- even if there are remote versions that better match other requirements for the \fBgemspec\fR gem\.
-.
-.SH "SOURCE PRIORITY"
-When attempting to locate a gem to satisfy a gem requirement, bundler uses the following priority order:
-.
-.IP "1." 4
-The source explicitly attached to the gem (using \fB:source\fR, \fB:path\fR, or \fB:git\fR)
-.
-.IP "2." 4
-For implicit gems (dependencies of explicit gems), any source, git, or path repository declared on the parent\. This results in bundler prioritizing the ActiveSupport gem from the Rails git repository over ones from \fBrubygems\.org\fR
-.
-.IP "3." 4
-The sources specified via global \fBsource\fR lines, searching each source in your \fBGemfile\fR from last added to first added\.
-.
-.IP "" 0
-
diff --git a/man/gemfile.5.ronn b/man/gemfile.5.ronn
deleted file mode 100644
index 832577130c..0000000000
--- a/man/gemfile.5.ronn
+++ /dev/null
@@ -1,517 +0,0 @@
-Gemfile(5) -- A format for describing gem dependencies for Ruby programs
-========================================================================
-
-## SYNOPSIS
-
-A `Gemfile` describes the gem dependencies required to execute associated
-Ruby code.
-
-Place the `Gemfile` in the root of the directory containing the associated
-code. For instance, in a Rails application, place the `Gemfile` in the same
-directory as the `Rakefile`.
-
-## SYNTAX
-
-A `Gemfile` is evaluated as Ruby code, in a context which makes available
-a number of methods used to describe the gem requirements.
-
-## GLOBAL SOURCES
-
-At the top of the `Gemfile`, add a line for the `Rubygems` source that contains
-the gems listed in the `Gemfile`.
-
- source "https://rubygems.org"
-
-It is possible, but not recommended as of Bundler 1.7, to add multiple global
-`source` lines. Each of these `source`s `MUST` be a valid Rubygems repository.
-
-Sources are checked for gems following the heuristics described in
-[SOURCE PRIORITY][]. If a gem is found in more than one global source, Bundler
-will print a warning after installing the gem indicating which source was used,
-and listing the other sources where the gem is available. A specific source can
-be selected for gems that need to use a non-standard repository, suppressing
-this warning, by using the [`:source` option](#SOURCE) or a
-[`source` block](#BLOCK-FORM-OF-SOURCE-GIT-PATH-GROUP-and-PLATFORMS).
-
-### CREDENTIALS
-
-Some gem sources require a username and password. Use [bundle config(1)](bundle-config.1.html) to set
-the username and password for any of the sources that need it. The command must
-be run once on each computer that will install the Gemfile, but this keeps the
-credentials from being stored in plain text in version control.
-
- bundle config gems.example.com user:password
-
-For some sources, like a company Gemfury account, it may be easier to
-include the credentials in the Gemfile as part of the source URL.
-
- source "https://user:password@gems.example.com"
-
-Credentials in the source URL will take precedence over credentials set using
-`config`.
-
-## RUBY
-
-If your application requires a specific Ruby version or engine, specify your
-requirements using the `ruby` method, with the following arguments.
-All parameters are `OPTIONAL` unless otherwise specified.
-
-### VERSION (required)
-
-The version of Ruby that your application requires. If your application
-requires an alternate Ruby engine, such as JRuby, Rubinius or TruffleRuby, this
-should be the Ruby version that the engine is compatible with.
-
- ruby "1.9.3"
-
-### ENGINE
-
-Each application _may_ specify a Ruby engine. If an engine is specified, an
-engine version _must_ also be specified.
-
-What exactly is an Engine?
- - A Ruby engine is an implementation of the Ruby language.
-
- - For background: the reference or original implementation of the Ruby
- programming language is called
- [Matz's Ruby Interpreter](https://en.wikipedia.org/wiki/Ruby_MRI), or MRI
- for short. This is named after Ruby creator Yukihiro Matsumoto,
- also known as Matz. MRI is also known as CRuby, because it is written in C.
- MRI is the most widely used Ruby engine.
-
- - [Other implementations](https://www.ruby-lang.org/en/about/) of Ruby exist.
- Some of the more well-known implementations include
- [Rubinius](https://rubinius.com/), and [JRuby](http://jruby.org/).
- Rubinius is an alternative implementation of Ruby written in Ruby.
- JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine.
-
-### ENGINE VERSION
-
-Each application _may_ specify a Ruby engine version. If an engine version is
-specified, an engine _must_ also be specified. If the engine is "ruby" the
-engine version specified _must_ match the Ruby version.
-
- ruby "1.8.7", :engine => "jruby", :engine_version => "1.6.7"
-
-### PATCHLEVEL
-
-Each application _may_ specify a Ruby patchlevel.
-
- ruby "2.0.0", :patchlevel => "247"
-
-## GEMS
-
-Specify gem requirements using the `gem` method, with the following arguments.
-All parameters are `OPTIONAL` unless otherwise specified.
-
-### NAME (required)
-
-For each gem requirement, list a single _gem_ line.
-
- gem "nokogiri"
-
-### VERSION
-
-Each _gem_ `MAY` have one or more version specifiers.
-
- gem "nokogiri", ">= 1.4.2"
- gem "RedCloth", ">= 4.1.0", "< 4.2.0"
-
-### REQUIRE AS
-
-Each _gem_ `MAY` specify files that should be used when autorequiring via
-`Bundler.require`. You may pass an array with multiple files or `true` if file
-you want `required` has same name as _gem_ or `false` to
-prevent any file from being autorequired.
-
- gem "redis", :require => ["redis/connection/hiredis", "redis"]
- gem "webmock", :require => false
- gem "byebug", :require => true
-
-The argument defaults to the name of the gem. For example, these are identical:
-
- gem "nokogiri"
- gem "nokogiri", :require => "nokogiri"
- gem "nokogiri", :require => true
-
-### GROUPS
-
-Each _gem_ `MAY` specify membership in one or more groups. Any _gem_ that does
-not specify membership in any group is placed in the `default` group.
-
- gem "rspec", :group => :test
- gem "wirble", :groups => [:development, :test]
-
-The Bundler runtime allows its two main methods, `Bundler.setup` and
-`Bundler.require`, to limit their impact to particular groups.
-
- # setup adds gems to Ruby's load path
- Bundler.setup # defaults to all groups
- require "bundler/setup" # same as Bundler.setup
- Bundler.setup(:default) # only set up the _default_ group
- Bundler.setup(:test) # only set up the _test_ group (but `not` _default_)
- Bundler.setup(:default, :test) # set up the _default_ and _test_ groups, but no others
-
- # require requires all of the gems in the specified groups
- Bundler.require # defaults to the _default_ group
- Bundler.require(:default) # identical
- Bundler.require(:default, :test) # requires the _default_ and _test_ groups
- Bundler.require(:test) # requires the _test_ group
-
-The Bundler CLI allows you to specify a list of groups whose gems `bundle install` should
-not install with the `without` configuration.
-
-To specify multiple groups to ignore, specify a list of groups separated by spaces.
-
- bundle config set without test
- bundle config set without development test
-
-Also, calling `Bundler.setup` with no parameters, or calling `require "bundler/setup"`
-will setup all groups except for the ones you excluded via `--without` (since they
-are not available).
-
-Note that on `bundle install`, bundler downloads and evaluates all gems, in order to
-create a single canonical list of all of the required gems and their dependencies.
-This means that you cannot list different versions of the same gems in different
-groups. For more details, see [Understanding Bundler](https://bundler.io/rationale.html).
-
-### PLATFORMS
-
-If a gem should only be used in a particular platform or set of platforms, you can
-specify them. Platforms are essentially identical to groups, except that you do not
-need to use the `--without` install-time flag to exclude groups of gems for other
-platforms.
-
-There are a number of `Gemfile` platforms:
-
- * `ruby`:
- C Ruby (MRI), Rubinius or TruffleRuby, but `NOT` Windows
- * `mri`:
- Same as _ruby_, but only C Ruby (MRI)
- * `mingw`:
- Windows 32 bit 'mingw32' platform (aka RubyInstaller)
- * `x64_mingw`:
- Windows 64 bit 'mingw32' platform (aka RubyInstaller x64)
- * `rbx`:
- Rubinius
- * `jruby`:
- JRuby
- * `truffleruby`:
- TruffleRuby
- * `mswin`:
- Windows
-
-You can restrict further by platform and version for all platforms *except* for
-`rbx`, `jruby`, `truffleruby` and `mswin`.
-
-To specify a version in addition to a platform, append the version number without
-the delimiter to the platform. For example, to specify that a gem should only be
-used on platforms with Ruby 2.3, use:
-
- ruby_23
-
-The full list of platforms and supported versions includes:
-
- * `ruby`:
- 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
- * `mri`:
- 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
- * `mingw`:
- 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
- * `x64_mingw`:
- 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
-
-As with groups, you can specify one or more platforms:
-
- gem "weakling", :platforms => :jruby
- gem "ruby-debug", :platforms => :mri_18
- gem "nokogiri", :platforms => [:mri_18, :jruby]
-
-All operations involving groups ([`bundle install`](bundle-install.1.html), `Bundler.setup`,
-`Bundler.require`) behave exactly the same as if any groups not
-matching the current platform were explicitly excluded.
-
-### SOURCE
-
-You can select an alternate Rubygems repository for a gem using the ':source'
-option.
-
- gem "some_internal_gem", :source => "https://gems.example.com"
-
-This forces the gem to be loaded from this source and ignores any global sources
-declared at the top level of the file. If the gem does not exist in this source,
-it will not be installed.
-
-Bundler will search for child dependencies of this gem by first looking in the
-source selected for the parent, but if they are not found there, it will fall
-back on global sources using the ordering described in [SOURCE PRIORITY][].
-
-Selecting a specific source repository this way also suppresses the ambiguous
-gem warning described above in
-[GLOBAL SOURCES (#source)](#GLOBAL-SOURCES).
-
-Using the `:source` option for an individual gem will also make that source
-available as a possible global source for any other gems which do not specify
-explicit sources. Thus, when adding gems with explicit sources, it is
-recommended that you also ensure all other gems in the Gemfile are using
-explicit sources.
-
-### GIT
-
-If necessary, you can specify that a gem is located at a particular
-git repository using the `:git` parameter. The repository can be accessed via
-several protocols:
-
- * `HTTP(S)`:
- gem "rails", :git => "https://github.com/rails/rails.git"
- * `SSH`:
- gem "rails", :git => "git@github.com:rails/rails.git"
- * `git`:
- gem "rails", :git => "git://github.com/rails/rails.git"
-
-If using SSH, the user that you use to run `bundle install` `MUST` have the
-appropriate keys available in their `$HOME/.ssh`.
-
-`NOTE`: `http://` and `git://` URLs should be avoided if at all possible. These
-protocols are unauthenticated, so a man-in-the-middle attacker can deliver
-malicious code and compromise your system. HTTPS and SSH are strongly
-preferred.
-
-The `group`, `platforms`, and `require` options are available and behave
-exactly the same as they would for a normal gem.
-
-A git repository `SHOULD` have at least one file, at the root of the
-directory containing the gem, with the extension `.gemspec`. This file
-`MUST` contain a valid gem specification, as expected by the `gem build`
-command.
-
-If a git repository does not have a `.gemspec`, bundler will attempt to
-create one, but it will not contain any dependencies, executables, or
-C extension compilation instructions. As a result, it may fail to properly
-integrate into your application.
-
-If a git repository does have a `.gemspec` for the gem you attached it
-to, a version specifier, if provided, means that the git repository is
-only valid if the `.gemspec` specifies a version matching the version
-specifier. If not, bundler will print a warning.
-
- gem "rails", "2.3.8", :git => "https://github.com/rails/rails.git"
- # bundle install will fail, because the .gemspec in the rails
- # repository's master branch specifies version 3.0.0
-
-If a git repository does `not` have a `.gemspec` for the gem you attached
-it to, a version specifier `MUST` be provided. Bundler will use this
-version in the simple `.gemspec` it creates.
-
-Git repositories support a number of additional options.
-
- * `branch`, `tag`, and `ref`:
- You `MUST` only specify at most one of these options. The default
- is `:branch => "master"`. For example:
-
- gem "rails", :git => "https://github.com/rails/rails.git", :branch => "5-0-stable"
-
- gem "rails", :git => "https://github.com/rails/rails.git", :tag => "v5.0.0"
-
- gem "rails", :git => "https://github.com/rails/rails.git", :ref => "4aded"
-
- * `submodules`:
- For reference, a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
- lets you have another git repository within a subfolder of your repository.
- Specify `:submodules => true` to cause bundler to expand any
- submodules included in the git repository
-
-If a git repository contains multiple `.gemspecs`, each `.gemspec`
-represents a gem located at the same place in the file system as
-the `.gemspec`.
-
- |~rails [git root]
- | |-rails.gemspec [rails gem located here]
- |~actionpack
- | |-actionpack.gemspec [actionpack gem located here]
- |~activesupport
- | |-activesupport.gemspec [activesupport gem located here]
- |...
-
-To install a gem located in a git repository, bundler changes to
-the directory containing the gemspec, runs `gem build name.gemspec`
-and then installs the resulting gem. The `gem build` command,
-which comes standard with Rubygems, evaluates the `.gemspec` in
-the context of the directory in which it is located.
-
-### GIT SOURCE
-
-A custom git source can be defined via the `git_source` method. Provide the source's name
-as an argument, and a block which receives a single argument and interpolates it into a
-string to return the full repo address:
-
- git_source(:stash){ |repo_name| "https://stash.corp.acme.pl/#{repo_name}.git" }
- gem 'rails', :stash => 'forks/rails'
-
-In addition, if you wish to choose a specific branch:
-
- gem "rails", :stash => "forks/rails", :branch => "branch_name"
-
-### GITHUB
-
-`NOTE`: This shorthand should be avoided until Bundler 2.0, since it
-currently expands to an insecure `git://` URL. This allows a
-man-in-the-middle attacker to compromise your system.
-
-If the git repository you want to use is hosted on GitHub and is public, you can use the
-:github shorthand to specify the github username and repository name (without the
-trailing ".git"), separated by a slash. If both the username and repository name are the
-same, you can omit one.
-
- gem "rails", :github => "rails/rails"
- gem "rails", :github => "rails"
-
-Are both equivalent to
-
- gem "rails", :git => "git://github.com/rails/rails.git"
-
-Since the `github` method is a specialization of `git_source`, it accepts a `:branch` named argument.
-
-### GIST
-
-If the git repository you want to use is hosted as a Github Gist and is public, you can use
-the :gist shorthand to specify the gist identifier (without the trailing ".git").
-
- gem "the_hatch", :gist => "4815162342"
-
-Is equivalent to:
-
- gem "the_hatch", :git => "https://gist.github.com/4815162342.git"
-
-Since the `gist` method is a specialization of `git_source`, it accepts a `:branch` named argument.
-
-### BITBUCKET
-
-If the git repository you want to use is hosted on Bitbucket and is public, you can use the
-:bitbucket shorthand to specify the bitbucket username and repository name (without the
-trailing ".git"), separated by a slash. If both the username and repository name are the
-same, you can omit one.
-
- gem "rails", :bitbucket => "rails/rails"
- gem "rails", :bitbucket => "rails"
-
-Are both equivalent to
-
- gem "rails", :git => "https://rails@bitbucket.org/rails/rails.git"
-
-Since the `bitbucket` method is a specialization of `git_source`, it accepts a `:branch` named argument.
-
-### PATH
-
-You can specify that a gem is located in a particular location
-on the file system. Relative paths are resolved relative to the
-directory containing the `Gemfile`.
-
-Similar to the semantics of the `:git` option, the `:path`
-option requires that the directory in question either contains
-a `.gemspec` for the gem, or that you specify an explicit
-version that bundler should use.
-
-Unlike `:git`, bundler does not compile C extensions for
-gems specified as paths.
-
- gem "rails", :path => "vendor/rails"
-
-If you would like to use multiple local gems directly from the filesystem, you can set a global `path` option to the path containing the gem's files. This will automatically load gemspec files from subdirectories.
-
- path 'components' do
- gem 'admin_ui'
- gem 'public_ui'
- end
-
-## BLOCK FORM OF SOURCE, GIT, PATH, GROUP and PLATFORMS
-
-The `:source`, `:git`, `:path`, `:group`, and `:platforms` options may be
-applied to a group of gems by using block form.
-
- source "https://gems.example.com" do
- gem "some_internal_gem"
- gem "another_internal_gem"
- end
-
- git "https://github.com/rails/rails.git" do
- gem "activesupport"
- gem "actionpack"
- end
-
- platforms :ruby do
- gem "ruby-debug"
- gem "sqlite3"
- end
-
- group :development, :optional => true do
- gem "wirble"
- gem "faker"
- end
-
-In the case of the group block form the :optional option can be given
-to prevent a group from being installed unless listed in the `--with`
-option given to the `bundle install` command.
-
-In the case of the `git` block form, the `:ref`, `:branch`, `:tag`,
-and `:submodules` options may be passed to the `git` method, and
-all gems in the block will inherit those options.
-
-The presence of a `source` block in a Gemfile also makes that source
-available as a possible global source for any other gems which do not specify
-explicit sources. Thus, when defining source blocks, it is
-recommended that you also ensure all other gems in the Gemfile are using
-explicit sources, either via source blocks or `:source` directives on
-individual gems.
-
-## INSTALL_IF
-
-The `install_if` method allows gems to be installed based on a proc or lambda.
-This is especially useful for optional gems that can only be used if certain
-software is installed or some other conditions are met.
-
- install_if -> { RUBY_PLATFORM =~ /darwin/ } do
- gem "pasteboard"
- end
-
-## GEMSPEC
-
-The [`.gemspec`](http://guides.rubygems.org/specification-reference/) file is where
- you provide metadata about your gem to Rubygems. Some required Gemspec
- attributes include the name, description, and homepage of your gem. This is
- also where you specify the dependencies your gem needs to run.
-
-If you wish to use Bundler to help install dependencies for a gem while it is
-being developed, use the `gemspec` method to pull in the dependencies listed in
-the `.gemspec` file.
-
-The `gemspec` method adds any runtime dependencies as gem requirements in the
-default group. It also adds development dependencies as gem requirements in the
-`development` group. Finally, it adds a gem requirement on your project (`:path
-=> '.'`). In conjunction with `Bundler.setup`, this allows you to require project
-files in your test code as you would if the project were installed as a gem; you
-need not manipulate the load path manually or require project files via relative
-paths.
-
-The `gemspec` method supports optional `:path`, `:glob`, `:name`, and `:development_group`
-options, which control where bundler looks for the `.gemspec`, the glob it uses to look
-for the gemspec (defaults to: "{,*,*/*}.gemspec"), what named `.gemspec` it uses
-(if more than one is present), and which group development dependencies are included in.
-
-When a `gemspec` dependency encounters version conflicts during resolution, the
-local version under development will always be selected -- even if there are
-remote versions that better match other requirements for the `gemspec` gem.
-
-## SOURCE PRIORITY
-
-When attempting to locate a gem to satisfy a gem requirement,
-bundler uses the following priority order:
-
- 1. The source explicitly attached to the gem (using `:source`, `:path`, or
- `:git`)
- 2. For implicit gems (dependencies of explicit gems), any source, git, or path
- repository declared on the parent. This results in bundler prioritizing the
- ActiveSupport gem from the Rails git repository over ones from
- `rubygems.org`
- 3. The sources specified via global `source` lines, searching each source in
- your `Gemfile` from last added to first added.
diff --git a/man/gemfile.5.txt b/man/gemfile.5.txt
deleted file mode 100644
index 71d2513271..0000000000
--- a/man/gemfile.5.txt
+++ /dev/null
@@ -1,649 +0,0 @@
-GEMFILE(5) GEMFILE(5)
-
-
-
-NAME
- Gemfile - A format for describing gem dependencies for Ruby programs
-
-SYNOPSIS
- A Gemfile describes the gem dependencies required to execute associated
- Ruby code.
-
- Place the Gemfile in the root of the directory containing the associ-
- ated code. For instance, in a Rails application, place the Gemfile in
- the same directory as the Rakefile.
-
-SYNTAX
- A Gemfile is evaluated as Ruby code, in a context which makes available
- a number of methods used to describe the gem requirements.
-
-GLOBAL SOURCES
- At the top of the Gemfile, add a line for the Rubygems source that con-
- tains the gems listed in the Gemfile.
-
-
-
- source "https://rubygems.org"
-
-
-
- It is possible, but not recommended as of Bundler 1.7, to add multiple
- global source lines. Each of these sources MUST be a valid Rubygems
- repository.
-
- Sources are checked for gems following the heuristics described in
- SOURCE PRIORITY. If a gem is found in more than one global source,
- Bundler will print a warning after installing the gem indicating which
- source was used, and listing the other sources where the gem is avail-
- able. A specific source can be selected for gems that need to use a
- non-standard repository, suppressing this warning, by using the :source
- option or a source block.
-
- CREDENTIALS
- Some gem sources require a username and password. Use bundle config(1)
- bundle-config.1.html to set the username and password for any of the
- sources that need it. The command must be run once on each computer
- that will install the Gemfile, but this keeps the credentials from
- being stored in plain text in version control.
-
-
-
- bundle config gems.example.com user:password
-
-
-
- For some sources, like a company Gemfury account, it may be easier to
- include the credentials in the Gemfile as part of the source URL.
-
-
-
- source "https://user:password@gems.example.com"
-
-
-
- Credentials in the source URL will take precedence over credentials set
- using config.
-
-RUBY
- If your application requires a specific Ruby version or engine, specify
- your requirements using the ruby method, with the following arguments.
- All parameters are OPTIONAL unless otherwise specified.
-
- VERSION (required)
- The version of Ruby that your application requires. If your application
- requires an alternate Ruby engine, such as JRuby, Rubinius or Truf-
- fleRuby, this should be the Ruby version that the engine is compatible
- with.
-
-
-
- ruby "1.9.3"
-
-
-
- ENGINE
- Each application may specify a Ruby engine. If an engine is specified,
- an engine version must also be specified.
-
- What exactly is an Engine? - A Ruby engine is an implementation of the
- Ruby language.
-
- o For background: the reference or original implementation of the
- Ruby programming language is called Matz's Ruby Interpreter
- https://en.wikipedia.org/wiki/Ruby_MRI, or MRI for short. This is
- named after Ruby creator Yukihiro Matsumoto, also known as Matz.
- MRI is also known as CRuby, because it is written in C. MRI is the
- most widely used Ruby engine.
-
- o Other implementations https://www.ruby-lang.org/en/about/ of Ruby
- exist. Some of the more well-known implementations include Rubinius
- https://rubinius.com/, and JRuby http://jruby.org/. Rubinius is an
- alternative implementation of Ruby written in Ruby. JRuby is an
- implementation of Ruby on the JVM, short for Java Virtual Machine.
-
-
-
- ENGINE VERSION
- Each application may specify a Ruby engine version. If an engine ver-
- sion is specified, an engine must also be specified. If the engine is
- "ruby" the engine version specified must match the Ruby version.
-
-
-
- ruby "1.8.7", :engine => "jruby", :engine_version => "1.6.7"
-
-
-
- PATCHLEVEL
- Each application may specify a Ruby patchlevel.
-
-
-
- ruby "2.0.0", :patchlevel => "247"
-
-
-
-GEMS
- Specify gem requirements using the gem method, with the following argu-
- ments. All parameters are OPTIONAL unless otherwise specified.
-
- NAME (required)
- For each gem requirement, list a single gem line.
-
-
-
- gem "nokogiri"
-
-
-
- VERSION
- Each gem MAY have one or more version specifiers.
-
-
-
- gem "nokogiri", ">= 1.4.2"
- gem "RedCloth", ">= 4.1.0", "< 4.2.0"
-
-
-
- REQUIRE AS
- Each gem MAY specify files that should be used when autorequiring via
- Bundler.require. You may pass an array with multiple files or true if
- file you want required has same name as gem or false to prevent any
- file from being autorequired.
-
-
-
- gem "redis", :require => ["redis/connection/hiredis", "redis"]
- gem "webmock", :require => false
- gem "byebug", :require => true
-
-
-
- The argument defaults to the name of the gem. For example, these are
- identical:
-
-
-
- gem "nokogiri"
- gem "nokogiri", :require => "nokogiri"
- gem "nokogiri", :require => true
-
-
-
- GROUPS
- Each gem MAY specify membership in one or more groups. Any gem that
- does not specify membership in any group is placed in the default
- group.
-
-
-
- gem "rspec", :group => :test
- gem "wirble", :groups => [:development, :test]
-
-
-
- The Bundler runtime allows its two main methods, Bundler.setup and
- Bundler.require, to limit their impact to particular groups.
-
-
-
- # setup adds gems to Ruby's load path
- Bundler.setup # defaults to all groups
- require "bundler/setup" # same as Bundler.setup
- Bundler.setup(:default) # only set up the _default_ group
- Bundler.setup(:test) # only set up the _test_ group (but `not` _default_)
- Bundler.setup(:default, :test) # set up the _default_ and _test_ groups, but no others
-
- # require requires all of the gems in the specified groups
- Bundler.require # defaults to the _default_ group
- Bundler.require(:default) # identical
- Bundler.require(:default, :test) # requires the _default_ and _test_ groups
- Bundler.require(:test) # requires the _test_ group
-
-
-
- The Bundler CLI allows you to specify a list of groups whose gems bun-
- dle install should not install with the without configuration.
-
- To specify multiple groups to ignore, specify a list of groups sepa-
- rated by spaces.
-
-
-
- bundle config set without test
- bundle config set without development test
-
-
-
- Also, calling Bundler.setup with no parameters, or calling require
- "bundler/setup" will setup all groups except for the ones you excluded
- via --without (since they are not available).
-
- Note that on bundle install, bundler downloads and evaluates all gems,
- in order to create a single canonical list of all of the required gems
- and their dependencies. This means that you cannot list different ver-
- sions of the same gems in different groups. For more details, see
- Understanding Bundler https://bundler.io/rationale.html.
-
- PLATFORMS
- If a gem should only be used in a particular platform or set of plat-
- forms, you can specify them. Platforms are essentially identical to
- groups, except that you do not need to use the --without install-time
- flag to exclude groups of gems for other platforms.
-
- There are a number of Gemfile platforms:
-
- ruby C Ruby (MRI), Rubinius or TruffleRuby, but NOT Windows
-
- mri Same as ruby, but only C Ruby (MRI)
-
- mingw Windows 32 bit 'mingw32' platform (aka RubyInstaller)
-
- x64_mingw
- Windows 64 bit 'mingw32' platform (aka RubyInstaller x64)
-
- rbx Rubinius
-
- jruby JRuby
-
- truffleruby
- TruffleRuby
-
- mswin Windows
-
- You can restrict further by platform and version for all platforms
- except for rbx, jruby, truffleruby and mswin.
-
- To specify a version in addition to a platform, append the version num-
- ber without the delimiter to the platform. For example, to specify that
- a gem should only be used on platforms with Ruby 2.3, use:
-
-
-
- ruby_23
-
-
-
- The full list of platforms and supported versions includes:
-
- ruby 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
-
- mri 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
-
- mingw 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
-
- x64_mingw
- 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
-
- As with groups, you can specify one or more platforms:
-
-
-
- gem "weakling", :platforms => :jruby
- gem "ruby-debug", :platforms => :mri_18
- gem "nokogiri", :platforms => [:mri_18, :jruby]
-
-
-
- All operations involving groups (bundle install bundle-install.1.html,
- Bundler.setup, Bundler.require) behave exactly the same as if any
- groups not matching the current platform were explicitly excluded.
-
- SOURCE
- You can select an alternate Rubygems repository for a gem using the
- ':source' option.
-
-
-
- gem "some_internal_gem", :source => "https://gems.example.com"
-
-
-
- This forces the gem to be loaded from this source and ignores any
- global sources declared at the top level of the file. If the gem does
- not exist in this source, it will not be installed.
-
- Bundler will search for child dependencies of this gem by first looking
- in the source selected for the parent, but if they are not found there,
- it will fall back on global sources using the ordering described in
- SOURCE PRIORITY.
-
- Selecting a specific source repository this way also suppresses the
- ambiguous gem warning described above in GLOBAL SOURCES (#source).
-
- Using the :source option for an individual gem will also make that
- source available as a possible global source for any other gems which
- do not specify explicit sources. Thus, when adding gems with explicit
- sources, it is recommended that you also ensure all other gems in the
- Gemfile are using explicit sources.
-
- GIT
- If necessary, you can specify that a gem is located at a particular git
- repository using the :git parameter. The repository can be accessed via
- several protocols:
-
- HTTP(S)
- gem "rails", :git => "https://github.com/rails/rails.git"
-
- SSH gem "rails", :git => "git@github.com:rails/rails.git"
-
- git gem "rails", :git => "git://github.com/rails/rails.git"
-
- If using SSH, the user that you use to run bundle install MUST have the
- appropriate keys available in their $HOME/.ssh.
-
- NOTE: http:// and git:// URLs should be avoided if at all possible.
- These protocols are unauthenticated, so a man-in-the-middle attacker
- can deliver malicious code and compromise your system. HTTPS and SSH
- are strongly preferred.
-
- The group, platforms, and require options are available and behave
- exactly the same as they would for a normal gem.
-
- A git repository SHOULD have at least one file, at the root of the
- directory containing the gem, with the extension .gemspec. This file
- MUST contain a valid gem specification, as expected by the gem build
- command.
-
- If a git repository does not have a .gemspec, bundler will attempt to
- create one, but it will not contain any dependencies, executables, or C
- extension compilation instructions. As a result, it may fail to prop-
- erly integrate into your application.
-
- If a git repository does have a .gemspec for the gem you attached it
- to, a version specifier, if provided, means that the git repository is
- only valid if the .gemspec specifies a version matching the version
- specifier. If not, bundler will print a warning.
-
-
-
- gem "rails", "2.3.8", :git => "https://github.com/rails/rails.git"
- # bundle install will fail, because the .gemspec in the rails
- # repository's master branch specifies version 3.0.0
-
-
-
- If a git repository does not have a .gemspec for the gem you attached
- it to, a version specifier MUST be provided. Bundler will use this ver-
- sion in the simple .gemspec it creates.
-
- Git repositories support a number of additional options.
-
- branch, tag, and ref
- You MUST only specify at most one of these options. The default
- is :branch => "master". For example:
-
- gem "rails", :git => "https://github.com/rails/rails.git",
- :branch => "5-0-stable"
-
- gem "rails", :git => "https://github.com/rails/rails.git", :tag
- => "v5.0.0"
-
- gem "rails", :git => "https://github.com/rails/rails.git", :ref
- => "4aded"
-
- submodules
- For reference, a git submodule
- https://git-scm.com/book/en/v2/Git-Tools-Submodules lets you
- have another git repository within a subfolder of your reposi-
- tory. Specify :submodules => true to cause bundler to expand any
- submodules included in the git repository
-
- If a git repository contains multiple .gemspecs, each .gemspec repre-
- sents a gem located at the same place in the file system as the .gem-
- spec.
-
-
-
- |~rails [git root]
- | |-rails.gemspec [rails gem located here]
- |~actionpack
- | |-actionpack.gemspec [actionpack gem located here]
- |~activesupport
- | |-activesupport.gemspec [activesupport gem located here]
- |...
-
-
-
- To install a gem located in a git repository, bundler changes to the
- directory containing the gemspec, runs gem build name.gemspec and then
- installs the resulting gem. The gem build command, which comes standard
- with Rubygems, evaluates the .gemspec in the context of the directory
- in which it is located.
-
- GIT SOURCE
- A custom git source can be defined via the git_source method. Provide
- the source's name as an argument, and a block which receives a single
- argument and interpolates it into a string to return the full repo
- address:
-
-
-
- git_source(:stash){ |repo_name| "https://stash.corp.acme.pl/#{repo_name}.git" }
- gem 'rails', :stash => 'forks/rails'
-
-
-
- In addition, if you wish to choose a specific branch:
-
-
-
- gem "rails", :stash => "forks/rails", :branch => "branch_name"
-
-
-
- GITHUB
- NOTE: This shorthand should be avoided until Bundler 2.0, since it cur-
- rently expands to an insecure git:// URL. This allows a man-in-the-mid-
- dle attacker to compromise your system.
-
- If the git repository you want to use is hosted on GitHub and is pub-
- lic, you can use the :github shorthand to specify the github username
- and repository name (without the trailing ".git"), separated by a
- slash. If both the username and repository name are the same, you can
- omit one.
-
-
-
- gem "rails", :github => "rails/rails"
- gem "rails", :github => "rails"
-
-
-
- Are both equivalent to
-
-
-
- gem "rails", :git => "git://github.com/rails/rails.git"
-
-
-
- Since the github method is a specialization of git_source, it accepts a
- :branch named argument.
-
- GIST
- If the git repository you want to use is hosted as a Github Gist and is
- public, you can use the :gist shorthand to specify the gist identifier
- (without the trailing ".git").
-
-
-
- gem "the_hatch", :gist => "4815162342"
-
-
-
- Is equivalent to:
-
-
-
- gem "the_hatch", :git => "https://gist.github.com/4815162342.git"
-
-
-
- Since the gist method is a specialization of git_source, it accepts a
- :branch named argument.
-
- BITBUCKET
- If the git repository you want to use is hosted on Bitbucket and is
- public, you can use the :bitbucket shorthand to specify the bitbucket
- username and repository name (without the trailing ".git"), separated
- by a slash. If both the username and repository name are the same, you
- can omit one.
-
-
-
- gem "rails", :bitbucket => "rails/rails"
- gem "rails", :bitbucket => "rails"
-
-
-
- Are both equivalent to
-
-
-
- gem "rails", :git => "https://rails@bitbucket.org/rails/rails.git"
-
-
-
- Since the bitbucket method is a specialization of git_source, it
- accepts a :branch named argument.
-
- PATH
- You can specify that a gem is located in a particular location on the
- file system. Relative paths are resolved relative to the directory con-
- taining the Gemfile.
-
- Similar to the semantics of the :git option, the :path option requires
- that the directory in question either contains a .gemspec for the gem,
- or that you specify an explicit version that bundler should use.
-
- Unlike :git, bundler does not compile C extensions for gems specified
- as paths.
-
-
-
- gem "rails", :path => "vendor/rails"
-
-
-
- If you would like to use multiple local gems directly from the filesys-
- tem, you can set a global path option to the path containing the gem's
- files. This will automatically load gemspec files from subdirectories.
-
-
-
- path 'components' do
- gem 'admin_ui'
- gem 'public_ui'
- end
-
-
-
-BLOCK FORM OF SOURCE, GIT, PATH, GROUP and PLATFORMS
- The :source, :git, :path, :group, and :platforms options may be applied
- to a group of gems by using block form.
-
-
-
- source "https://gems.example.com" do
- gem "some_internal_gem"
- gem "another_internal_gem"
- end
-
- git "https://github.com/rails/rails.git" do
- gem "activesupport"
- gem "actionpack"
- end
-
- platforms :ruby do
- gem "ruby-debug"
- gem "sqlite3"
- end
-
- group :development, :optional => true do
- gem "wirble"
- gem "faker"
- end
-
-
-
- In the case of the group block form the :optional option can be given
- to prevent a group from being installed unless listed in the --with
- option given to the bundle install command.
-
- In the case of the git block form, the :ref, :branch, :tag, and :sub-
- modules options may be passed to the git method, and all gems in the
- block will inherit those options.
-
- The presence of a source block in a Gemfile also makes that source
- available as a possible global source for any other gems which do not
- specify explicit sources. Thus, when defining source blocks, it is rec-
- ommended that you also ensure all other gems in the Gemfile are using
- explicit sources, either via source blocks or :source directives on
- individual gems.
-
-INSTALL_IF
- The install_if method allows gems to be installed based on a proc or
- lambda. This is especially useful for optional gems that can only be
- used if certain software is installed or some other conditions are met.
-
-
-
- install_if -> { RUBY_PLATFORM =~ /darwin/ } do
- gem "pasteboard"
- end
-
-
-
-GEMSPEC
- The .gemspec http://guides.rubygems.org/specification-reference/ file
- is where you provide metadata about your gem to Rubygems. Some required
- Gemspec attributes include the name, description, and homepage of your
- gem. This is also where you specify the dependencies your gem needs to
- run.
-
- If you wish to use Bundler to help install dependencies for a gem while
- it is being developed, use the gemspec method to pull in the dependen-
- cies listed in the .gemspec file.
-
- The gemspec method adds any runtime dependencies as gem requirements in
- the default group. It also adds development dependencies as gem
- requirements in the development group. Finally, it adds a gem require-
- ment on your project (:path => '.'). In conjunction with Bundler.setup,
- this allows you to require project files in your test code as you would
- if the project were installed as a gem; you need not manipulate the
- load path manually or require project files via relative paths.
-
- The gemspec method supports optional :path, :glob, :name, and :develop-
- ment_group options, which control where bundler looks for the .gemspec,
- the glob it uses to look for the gemspec (defaults to: "{,,/*}.gem-
- spec"), what named .gemspec it uses (if more than one is present), and
- which group development dependencies are included in.
-
- When a gemspec dependency encounters version conflicts during resolu-
- tion, the local version under development will always be selected --
- even if there are remote versions that better match other requirements
- for the gemspec gem.
-
-SOURCE PRIORITY
- When attempting to locate a gem to satisfy a gem requirement, bundler
- uses the following priority order:
-
- 1. The source explicitly attached to the gem (using :source, :path, or
- :git)
-
- 2. For implicit gems (dependencies of explicit gems), any source, git,
- or path repository declared on the parent. This results in bundler
- prioritizing the ActiveSupport gem from the Rails git repository
- over ones from rubygems.org
-
- 3. The sources specified via global source lines, searching each
- source in your Gemfile from last added to first added.
-
-
-
-
-
-
- January 2020 GEMFILE(5)
diff --git a/man/goruby.1 b/man/goruby.1
index a305a5afce..47a015f34d 100644
--- a/man/goruby.1
+++ b/man/goruby.1
@@ -1,5 +1,5 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd April 20, 2017
+.Dd November 15, 2012
.Dt GORUBY \&1 "Ruby Programmer's Reference Guide"
.Os UNIX
.Sh NAME
diff --git a/man/index.txt b/man/index.txt
deleted file mode 100644
index 400eb02267..0000000000
--- a/man/index.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-Gemfile(5) gemfile.5
-bundle(1) bundle.1
-bundle-add(1) bundle-add.1
-bundle-binstubs(1) bundle-binstubs.1
-bundle-check(1) bundle-check.1
-bundle-clean(1) bundle-clean.1
-bundle-config(1) bundle-config.1
-bundle-doctor(1) bundle-doctor.1
-bundle-exec(1) bundle-exec.1
-bundle-gem(1) bundle-gem.1
-bundle-info(1) bundle-info.1
-bundle-init(1) bundle-init.1
-bundle-inject(1) bundle-inject.1
-bundle-install(1) bundle-install.1
-bundle-list(1) bundle-list.1
-bundle-lock(1) bundle-lock.1
-bundle-open(1) bundle-open.1
-bundle-outdated(1) bundle-outdated.1
-bundle-package(1) bundle-package.1
-bundle-platform(1) bundle-platform.1
-bundle-pristine(1) bundle-pristine.1
-bundle-remove(1) bundle-remove.1
-bundle-show(1) bundle-show.1
-bundle-update(1) bundle-update.1
-bundle-viz(1) bundle-viz.1
diff --git a/man/irb.1 b/man/irb.1
index f0a720fbd3..e980a2ebfd 100644
--- a/man/irb.1
+++ b/man/irb.1
@@ -1,5 +1,5 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd August 11, 2019
+.Dd November 15, 2012
.Dt IRB \&1 "Ruby Programmer's Reference Guide"
.Os UNIX
.Sh NAME
@@ -8,17 +8,11 @@
.Sh SYNOPSIS
.Nm
.Op Fl -version
-.Op Fl dfUw
+.Op Fl dfm
.Op Fl I Ar directory
.Op Fl r Ar library
-.Op Fl E Ar external Ns Op : Ns Ar internal
-.Op Fl W Ns Op Ar level
.Op Fl - Ns Oo no Oc Ns inspect
-.Op Fl - Ns Oo no Oc Ns multiline
-.Op Fl - Ns Oo no Oc Ns singleline
-.Op Fl - Ns Oo no Oc Ns echo
-.Op Fl - Ns Oo no Oc Ns colorize
-.Op Fl - Ns Oo no Oc Ns verbose
+.Op Fl - Ns Oo no Oc Ns readline
.Op Fl -prompt Ar mode
.Op Fl -prompt-mode Ar mode
.Op Fl -inf-ruby-mode
@@ -26,6 +20,7 @@
.Op Fl -noprompt
.Op Fl -tracer
.Op Fl -back-trace-limit Ar n
+.Op Fl -irb_debug Ar n
.Op Fl -
.Op program_file
.Op argument ...
@@ -70,13 +65,6 @@ to true.
Suppresses read of
.Pa ~/.irbrc .
.Pp
-.It Fl w
-Same as `ruby -w' .
-.Pp
-.Pp
-.It Fl W
-Same as `ruby -W' .
-.Pp
.It Fl h
.It Fl -help
Prints a summary of the options.
@@ -91,38 +79,11 @@ Uses `inspect' for output (default except for bc mode)
.It Fl -noinspect
Doesn't use inspect for output
.Pp
-.It Fl -multiline
-Uses multiline editor module.
-.Pp
-.It Fl -nomultiline
-Doesn't use multiline editor module.
-.Pp
-.It Fl -singleline
-Uses singleline editor module.
-.Pp
-.It Fl -nosingleline
-Doesn't use singleline editor module.
-.Pp
-.Pp
-.It Fl -echo
-Show result(default).
+.It Fl -readline
+Uses Readline extension module.
.Pp
-.It Fl -noecho
-Don't show result.
-.Pp
-.Pp
-.It Fl -colorize
-Use colorization.
-.Pp
-.It Fl -nocolorize
-Don't use colorization.
-.Pp
-.Pp
-.It Fl -verbose
-Show details.
-.Pp
-.It Fl -noverbose
-Don't show details.
+.It Fl -noreadline
+Doesn't use Readline extension module.
.Pp
.It Fl -prompt Ar mode
.It Fl -prompt-mode Ar mode
@@ -131,7 +92,7 @@ Switch prompt mode. Pre-defined prompt modes are
.Pp
.It Fl -inf-ruby-mode
Uses prompt appropriate for inf-ruby-mode on emacs.
-Suppresses --multiline and --singleline.
+Suppresses --readline.
.Pp
.It Fl -simple-prompt
Makes prompts simple.
@@ -148,6 +109,10 @@ Displays backtrace top
and tail
.Ar n Ns .
The default value is 16.
+.Pp
+.It Fl -irb_debug Ar n
+Sets internal debug level to n (not for popular use)
+.Pp
.El
.Pp
.Sh ENVIRONMENT
@@ -173,7 +138,7 @@ Personal irb initialization.
.Dl irb(main):001:0> Ic 1 + 1
.Dl 2
.Dl irb(main):002:0> Ic def t(x)
-.Dl irb(main):003:1> Ic x + 1
+.Dl irb(main):003:1> Ic x+1
.Dl irb(main):004:1> Ic end
.Dl => :t
.Dl irb(main):005:0> Ic t(3)
diff --git a/man/ruby.1 b/man/ruby.1
index 1888312d26..88cef8d480 100644
--- a/man/ruby.1
+++ b/man/ruby.1
@@ -1,5 +1,5 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd April 14, 2018
+.Dd October 31, 2015
.Dt RUBY \&1 "Ruby Programmer's Reference Guide"
.Os UNIX
.Sh NAME
@@ -137,18 +137,16 @@ to see how they are being developed and used.
.El
.Pp
.Sh OPTIONS
-The Ruby interpreter accepts the following command-line options (switches).
+Ruby interpreter accepts following command-line options (switches).
They are quite similar to those of
.Xr perl 1 .
.Bl -tag -width "1234567890123" -compact
.Pp
.It Fl -copyright
-Prints the copyright notice, and quits immediately without running any
-script.
+Prints the copyright notice.
.Pp
.It Fl -version
-Prints the version of the Ruby interpreter, and quits immediately without
-running any script.
+Prints the version of Ruby interpreter.
.Pp
.It Fl 0 Ns Op Ar octal
(The digit
@@ -419,7 +417,7 @@ Disables (or enables) all features.
.El
.Pp
.It Fl -dump Ns = Ns Ar target
-Dump some information.
+Dump some informations.
.Pp
Prints the specified target.
.Ar target
@@ -459,9 +457,8 @@ Enables verbose mode without printing version message at the
beginning. It sets the
.Li "$VERBOSE"
variable to true.
-If this switch is given, and no script arguments (script file or
-.Fl e
-options) are present, Ruby quits immediately.
+If this switch is given, and no other switches are present, Ruby quits
+after printing its version.
.El
.Pp
.Sh ENVIRONMENT
diff --git a/marshal.c b/marshal.c
index d05b4b9336..d89ccf51cf 100644
--- a/marshal.c
+++ b/marshal.c
@@ -9,9 +9,12 @@
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/io.h"
+#if defined __GNUC__ && __GNUC__ < 3
+# error too old GCC
+#endif
+
#include "internal.h"
+#include "ruby/io.h"
#include "ruby/st.h"
#include "ruby/util.h"
#include "encindex.h"
@@ -83,7 +86,6 @@ shortlen(size_t len, BDIGIT *ds)
static ID s_dump, s_load, s_mdump, s_mload;
static ID s_dump_data, s_load_data, s_alloc, s_call;
static ID s_getbyte, s_read, s_write, s_binmode;
-static ID s_encoding_short, s_ruby2_keywords_flag;
#define name_s_dump "_dump"
#define name_s_load "_load"
@@ -97,8 +99,6 @@ static ID s_encoding_short, s_ruby2_keywords_flag;
#define name_s_read "read"
#define name_s_write "write"
#define name_s_binmode "binmode"
-#define name_s_encoding_short "E"
-#define name_s_ruby2_keywords_flag "K"
typedef struct {
VALUE newclass;
@@ -113,7 +113,7 @@ static VALUE rb_marshal_dump_limited(VALUE obj, VALUE port, int limit);
static VALUE rb_marshal_load_with_proc(VALUE port, VALUE proc);
static int
-mark_marshal_compat_i(st_data_t key, st_data_t value, st_data_t _)
+mark_marshal_compat_i(st_data_t key, st_data_t value)
{
marshal_compat_t *p = (marshal_compat_t *)value;
rb_gc_mark(p->newclass);
@@ -151,12 +151,16 @@ rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE),
st_insert(compat_allocator_table(), (st_data_t)allocator, (st_data_t)compat);
}
+#define MARSHAL_INFECTION FL_TAINT
+STATIC_ASSERT(marshal_infection_is_int, MARSHAL_INFECTION == (int)MARSHAL_INFECTION);
+
struct dump_arg {
VALUE str, dest;
st_table *symbols;
st_table *data;
st_table *compat_tbl;
st_table *encodings;
+ int infection;
};
struct dump_call_arg {
@@ -255,9 +259,8 @@ class2path(VALUE klass)
return path;
}
-int ruby_marshal_write_long(long x, char *buf);
static void w_long(long, struct dump_arg*);
-static int w_encoding(VALUE encname, struct dump_call_arg *arg);
+static void w_encoding(VALUE encname, struct dump_call_arg *arg);
static VALUE encoding_name(VALUE obj, struct dump_arg *arg);
static void
@@ -265,6 +268,7 @@ w_nbyte(const char *s, long n, struct dump_arg *arg)
{
VALUE buf = arg->str;
rb_str_buf_cat(buf, s, n);
+ RBASIC(buf)->flags |= arg->infection;
if (arg->dest && RSTRING_LEN(buf) >= BUFSIZ) {
rb_io_write(arg->dest, buf);
rb_str_resize(buf, 0);
@@ -297,36 +301,26 @@ static void
w_long(long x, struct dump_arg *arg)
{
char buf[sizeof(long)+1];
- int i = ruby_marshal_write_long(x, buf);
- if (i < 0) {
- rb_raise(rb_eTypeError, "long too big to dump");
- }
- w_nbyte(buf, i, arg);
-}
-
-int
-ruby_marshal_write_long(long x, char *buf)
-{
int i;
#if SIZEOF_LONG > 4
if (!(RSHIFT(x, 31) == 0 || RSHIFT(x, 31) == -1)) {
/* big long does not fit in 4 bytes */
- return -1;
+ rb_raise(rb_eTypeError, "long too big to dump");
}
#endif
if (x == 0) {
- buf[0] = 0;
- return 1;
+ w_byte(0, arg);
+ return;
}
if (0 < x && x < 123) {
- buf[0] = (char)(x + 5);
- return 1;
+ w_byte((char)(x + 5), arg);
+ return;
}
if (-124 < x && x < 0) {
- buf[0] = (char)((x - 5)&0xff);
- return 1;
+ w_byte((char)((x - 5)&0xff), arg);
+ return;
}
for (i=1;i<(int)sizeof(long)+1;i++) {
buf[i] = (char)(x & 0xff);
@@ -340,7 +334,7 @@ ruby_marshal_write_long(long x, char *buf)
break;
}
}
- return i+1;
+ w_nbyte(buf, i+1, arg);
}
#ifdef DBL_MANT_DIG
@@ -368,12 +362,12 @@ load_mantissa(double d, const char *buf, long len)
do {
m = 0;
switch (len) {
- default: m = *buf++ & 0xff; /* fall through */
+ default: m = *buf++ & 0xff;
#if MANT_BITS > 24
- case 3: m = (m << 8) | (*buf++ & 0xff); /* fall through */
+ case 3: m = (m << 8) | (*buf++ & 0xff);
#endif
#if MANT_BITS > 16
- case 2: m = (m << 8) | (*buf++ & 0xff); /* fall through */
+ case 2: m = (m << 8) | (*buf++ & 0xff);
#endif
#if MANT_BITS > 8
case 1: m = (m << 8) | (*buf++ & 0xff);
@@ -410,8 +404,8 @@ w_float(double d, struct dump_arg *arg)
w_cstr("nan", arg);
}
else if (d == 0.0) {
- if (signbit(d)) w_cstr("-0", arg);
- else w_cstr("0", arg);
+ if (1.0/d < 0) w_cstr("-0", arg);
+ else w_cstr("0", arg);
}
else {
int decpt, sign, digs, len = 0;
@@ -496,9 +490,8 @@ w_unique(VALUE s, struct dump_arg *arg)
static void w_object(VALUE,struct dump_arg*,int);
static int
-hash_each(VALUE key, VALUE value, VALUE v)
+hash_each(VALUE key, VALUE value, struct dump_call_arg *arg)
{
- struct dump_call_arg *arg = (void *)v;
w_object(key, arg->arg, arg->limit);
w_object(value, arg->arg, arg->limit);
return ST_CONTINUE;
@@ -558,7 +551,7 @@ w_uclass(VALUE obj, VALUE super, struct dump_arg *arg)
}
}
-#define to_be_skipped_id(id) (id == rb_id_encoding() || id == s_encoding_short || id == s_ruby2_keywords_flag || !rb_id2str(id))
+#define to_be_skipped_id(id) (id == rb_id_encoding() || id == rb_intern("E") || !rb_id2str(id))
struct w_ivar_arg {
struct dump_call_arg *dump;
@@ -573,17 +566,7 @@ w_obj_each(st_data_t key, st_data_t val, st_data_t a)
struct w_ivar_arg *ivarg = (struct w_ivar_arg *)a;
struct dump_call_arg *arg = ivarg->dump;
- if (to_be_skipped_id(id)) {
- if (id == s_encoding_short) {
- rb_warn("instance variable `"name_s_encoding_short"' on class %"PRIsVALUE" is not dumped",
- CLASS_OF(arg->obj));
- }
- if (id == s_ruby2_keywords_flag) {
- rb_warn("instance variable `"name_s_ruby2_keywords_flag"' on class %"PRIsVALUE" is not dumped",
- CLASS_OF(arg->obj));
- }
- return ST_CONTINUE;
- }
+ if (to_be_skipped_id(id)) return ST_CONTINUE;
if (!ivarg->num_ivar) {
rb_raise(rb_eRuntimeError, "instance variable added to %"PRIsVALUE" instance",
CLASS_OF(arg->obj));
@@ -605,37 +588,32 @@ obj_count_ivars(st_data_t key, st_data_t val, st_data_t a)
static VALUE
encoding_name(VALUE obj, struct dump_arg *arg)
{
- if (rb_enc_capable(obj)) {
- int encidx = rb_enc_get_index(obj);
- rb_encoding *enc = 0;
- st_data_t name;
-
- if (encidx <= 0 || !(enc = rb_enc_from_index(encidx))) {
- return Qnil;
- }
+ int encidx = rb_enc_get_index(obj);
+ rb_encoding *enc = 0;
+ st_data_t name;
- /* special treatment for US-ASCII and UTF-8 */
- if (encidx == rb_usascii_encindex()) {
- return Qfalse;
- }
- else if (encidx == rb_utf8_encindex()) {
- return Qtrue;
- }
+ if (encidx <= 0 || !(enc = rb_enc_from_index(encidx))) {
+ return Qnil;
+ }
- if (arg->encodings ?
- !st_lookup(arg->encodings, (st_data_t)rb_enc_name(enc), &name) :
- (arg->encodings = st_init_strcasetable(), 1)) {
- name = (st_data_t)rb_str_new_cstr(rb_enc_name(enc));
- st_insert(arg->encodings, (st_data_t)rb_enc_name(enc), name);
- }
- return (VALUE)name;
+ /* special treatment for US-ASCII and UTF-8 */
+ if (encidx == rb_usascii_encindex()) {
+ return Qfalse;
}
- else {
- return Qnil;
+ else if (encidx == rb_utf8_encindex()) {
+ return Qtrue;
+ }
+
+ if (arg->encodings ?
+ !st_lookup(arg->encodings, (st_data_t)rb_enc_name(enc), &name) :
+ (arg->encodings = st_init_strcasetable(), 1)) {
+ name = (st_data_t)rb_str_new_cstr(rb_enc_name(enc));
+ st_insert(arg->encodings, (st_data_t)rb_enc_name(enc), name);
}
+ return (VALUE)name;
}
-static int
+static void
w_encoding(VALUE encname, struct dump_call_arg *arg)
{
int limit = arg->limit;
@@ -643,15 +621,13 @@ w_encoding(VALUE encname, struct dump_call_arg *arg)
switch (encname) {
case Qfalse:
case Qtrue:
- w_symbol(ID2SYM(s_encoding_short), arg->arg);
+ w_symbol(ID2SYM(rb_intern("E")), arg->arg);
w_object(encname, arg->arg, limit);
- return 1;
case Qnil:
- return 0;
+ return;
}
w_symbol(ID2SYM(rb_id_encoding()), arg->arg);
w_object(encname, arg->arg, limit);
- return 1;
}
static st_index_t
@@ -659,7 +635,6 @@ has_ivars(VALUE obj, VALUE encname, VALUE *ivobj)
{
st_index_t enc = !NIL_P(encname);
st_index_t num = 0;
- st_index_t ruby2_keywords_flag = 0;
if (SPECIAL_CONST_P(obj)) goto generic;
switch (BUILTIN_TYPE(obj)) {
@@ -667,16 +642,13 @@ has_ivars(VALUE obj, VALUE encname, VALUE *ivobj)
case T_CLASS:
case T_MODULE:
break; /* counted elsewhere */
- case T_HASH:
- ruby2_keywords_flag = RHASH(obj)->basic.flags & RHASH_PASS_AS_KEYWORDS ? 1 : 0;
- /* fall through */
default:
generic:
rb_ivar_foreach(obj, obj_count_ivars, (st_data_t)&num);
- if (ruby2_keywords_flag || num) *ivobj = obj;
+ if (num) *ivobj = obj;
}
- return num + enc + ruby2_keywords_flag;
+ return num + enc;
}
static void
@@ -685,25 +657,14 @@ w_ivar_each(VALUE obj, st_index_t num, struct dump_call_arg *arg)
struct w_ivar_arg ivarg = {arg, num};
if (!num) return;
rb_ivar_foreach(obj, w_obj_each, (st_data_t)&ivarg);
- if (ivarg.num_ivar) {
- rb_raise(rb_eRuntimeError, "instance variable removed from %"PRIsVALUE" instance",
- CLASS_OF(arg->obj));
- }
}
static void
w_ivar(st_index_t num, VALUE ivobj, VALUE encname, struct dump_call_arg *arg)
{
w_long(num, arg->arg);
- num -= w_encoding(encname, arg);
- if (RB_TYPE_P(ivobj, T_HASH) && (RHASH(ivobj)->basic.flags & RHASH_PASS_AS_KEYWORDS)) {
- int limit = arg->limit;
- if (limit >= 0) ++limit;
- w_symbol(ID2SYM(s_ruby2_keywords_flag), arg->arg);
- w_object(Qtrue, arg->arg, limit);
- num--;
- }
- if (ivobj != Qundef && num) {
+ w_encoding(encname, arg);
+ if (ivobj != Qundef) {
w_ivar_each(ivobj, num, arg);
}
}
@@ -781,6 +742,8 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
rb_builtin_type_name(BUILTIN_TYPE(obj)));
}
+ arg->infection |= (int)FL_TEST(obj, MARSHAL_INFECTION);
+
if (rb_obj_respond_to(obj, s_mdump, TRUE)) {
st_add_direct(arg->data, obj, arg->data->num_entries);
@@ -870,7 +833,6 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
char sign = BIGNUM_SIGN(obj) ? '+' : '-';
size_t len = BIGNUM_LEN(obj);
size_t slen;
- size_t j;
BDIGIT *d = BIGNUM_DIGITS(obj);
slen = SHORTLEN(len);
@@ -880,7 +842,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
w_byte(sign, arg);
w_long((long)slen, arg);
- for (j = 0; j < len; j++) {
+ while (len--) {
#if SIZEOF_BDIGIT > SIZEOF_SHORT
BDIGIT num = *d;
int i;
@@ -888,7 +850,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
for (i=0; i<SIZEOF_BDIGIT; i+=SIZEOF_SHORT) {
w_short(num & SHORTMASK, arg);
num = SHORTDN(num);
- if (j == len - 1 && num == 0) break;
+ if (len == 0 && num == 0) break;
}
#else
w_short(*d, arg);
@@ -935,13 +897,13 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
if (NIL_P(RHASH_IFNONE(obj))) {
w_byte(TYPE_HASH, arg);
}
- else if (FL_TEST(obj, RHASH_PROC_DEFAULT)) {
+ else if (FL_TEST(obj, HASH_PROC_DEFAULT)) {
rb_raise(rb_eTypeError, "can't dump hash with default proc");
}
else {
w_byte(TYPE_HASH_DEF, arg);
}
- w_long(rb_hash_size_num(obj), arg);
+ w_long(RHASH_SIZE(obj), arg);
rb_hash_foreach(obj, hash_each, (st_data_t)&c_arg);
if (!NIL_P(RHASH_IFNONE(obj))) {
w_object(RHASH_IFNONE(obj), arg, limit);
@@ -1056,7 +1018,7 @@ io_needed(void)
* * objects which define singleton methods
*/
static VALUE
-marshal_dump(int argc, VALUE *argv, VALUE _)
+marshal_dump(int argc, VALUE *argv)
{
VALUE obj, port, a1, a2;
int limit = -1;
@@ -1086,6 +1048,7 @@ rb_marshal_dump_limited(VALUE obj, VALUE port, int limit)
arg->dest = 0;
arg->symbols = st_init_numtable();
arg->data = rb_init_identtable();
+ arg->infection = 0;
arg->compat_tbl = 0;
arg->encodings = 0;
arg->str = rb_str_buf_new(0);
@@ -1124,6 +1087,7 @@ struct load_arg {
st_table *data;
VALUE proc;
st_table *compat_tbl;
+ int infection;
};
static VALUE
@@ -1202,6 +1166,7 @@ r_byte1_buffered(struct load_arg *arg)
str = load_funcall(arg, arg->src, s_read, 1, &n);
if (NIL_P(str)) too_short();
StringValue(str);
+ arg->infection |= (int)FL_TEST(str, MARSHAL_INFECTION);
memcpy(arg->buf, RSTRING_PTR(str), RSTRING_LEN(str));
arg->offset = 0;
arg->buflen = RSTRING_LEN(str);
@@ -1236,8 +1201,6 @@ r_byte(struct load_arg *arg)
return c;
}
-NORETURN(static void long_toobig(int size));
-
static void
long_toobig(int size)
{
@@ -1278,19 +1241,6 @@ r_long(struct load_arg *arg)
return x;
}
-long
-ruby_marshal_read_long(const char **buf, long len)
-{
- long x;
- struct RString src;
- struct load_arg arg;
- memset(&arg, 0, sizeof(arg));
- arg.src = rb_setup_fake_str(&src, *buf, len, 0);
- x = r_long(&arg);
- *buf += arg.offset;
- return x;
-}
-
static VALUE
r_bytes1(long len, struct load_arg *arg)
{
@@ -1300,6 +1250,7 @@ r_bytes1(long len, struct load_arg *arg)
if (NIL_P(str)) too_short();
StringValue(str);
if (RSTRING_LEN(str) != len) too_short();
+ arg->infection |= (int)FL_TEST(str, MARSHAL_INFECTION);
return str;
}
@@ -1330,6 +1281,7 @@ r_bytes1_buffered(long len, struct load_arg *arg)
tmp_len = RSTRING_LEN(tmp);
if (tmp_len < need_len) too_short();
+ arg->infection |= (int)FL_TEST(tmp, MARSHAL_INFECTION);
str = rb_str_new(arg->buf+arg->offset, buflen);
rb_str_cat(str, RSTRING_PTR(tmp), need_len);
@@ -1376,13 +1328,6 @@ r_bytes0(long len, struct load_arg *arg)
return str;
}
-static inline int
-name_equal(const char *name, size_t nlen, const char *p, long l)
-{
- if ((size_t)l != nlen || *p != *name) return 0;
- return nlen == 1 || memcmp(p+1, name+1, nlen-1) == 0;
-}
-
static int
sym2encidx(VALUE sym, VALUE val)
{
@@ -1392,11 +1337,12 @@ sym2encidx(VALUE sym, VALUE val)
if (rb_enc_get_index(sym) != ENCINDEX_US_ASCII) return -1;
RSTRING_GETMEM(sym, p, l);
if (l <= 0) return -1;
- if (name_equal(name_encoding, sizeof(name_encoding), p, l)) {
+ if (l == sizeof(name_encoding) &&
+ memcmp(p, name_encoding, sizeof(name_encoding)) == 0) {
int idx = rb_enc_find_index(StringValueCStr(val));
return idx;
}
- if (name_equal(name_s_encoding_short, rb_strlen_lit(name_s_encoding_short), p, l)) {
+ else if (l == 1 && *p == 'E') {
if (val == Qfalse) return rb_usascii_encindex();
else if (val == Qtrue) return rb_utf8_encindex();
/* bogus ignore */
@@ -1404,19 +1350,6 @@ sym2encidx(VALUE sym, VALUE val)
return -1;
}
-static int
-ruby2_keywords_flag_check(VALUE sym)
-{
- const char *p;
- long l;
- RSTRING_GETMEM(sym, p, l);
- if (l <= 0) return 0;
- if (name_equal(name_s_ruby2_keywords_flag, rb_strlen_lit(name_s_ruby2_keywords_flag), p, 1)) {
- return 1;
- }
- return 0;
-}
-
static VALUE
r_symlink(struct load_arg *arg)
{
@@ -1495,6 +1428,12 @@ r_entry0(VALUE v, st_index_t num, struct load_arg *arg)
else {
st_insert(arg->data, num, (st_data_t)v);
}
+ if (arg->infection &&
+ !RB_TYPE_P(v, T_CLASS) && !RB_TYPE_P(v, T_MODULE)) {
+ OBJ_TAINT(v);
+ if ((VALUE)real_obj != Qundef)
+ OBJ_TAINT((VALUE)real_obj);
+ }
return v;
}
@@ -1562,24 +1501,11 @@ r_ivar(VALUE obj, int *has_encoding, struct load_arg *arg)
VALUE val = r_object(arg);
int idx = sym2encidx(sym, val);
if (idx >= 0) {
- if (rb_enc_capable(obj)) {
- rb_enc_associate_index(obj, idx);
- }
- else {
- rb_raise(rb_eArgError, "%"PRIsVALUE" is not enc_capable", obj);
- }
+ rb_enc_associate_index(obj, idx);
if (has_encoding) *has_encoding = TRUE;
}
- else if (ruby2_keywords_flag_check(sym)) {
- if (RB_TYPE_P(obj, T_HASH)) {
- RHASH(obj)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
- }
- else {
- rb_raise(rb_eArgError, "ruby2_keywords flag is given but %"PRIsVALUE" is not a Hash", obj);
- }
- }
- else {
- rb_ivar_set(obj, rb_intern_str(sym), val);
+ else {
+ rb_ivar_set(obj, rb_intern_str(sym), val);
}
} while (--len > 0);
}
@@ -1678,9 +1604,6 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
v = r_object0(arg, &ivar, extmod);
if (ivar) r_ivar(v, NULL, arg);
- if (RB_TYPE_P(v, T_STRING)) {
- v = r_leave(v, arg);
- }
}
break;
@@ -1770,13 +1693,13 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
const char *ptr = RSTRING_PTR(str);
if (strcmp(ptr, "nan") == 0) {
- d = nan("");
+ d = NAN;
}
else if (strcmp(ptr, "inf") == 0) {
- d = HUGE_VAL;
+ d = INFINITY;
}
else if (strcmp(ptr, "-inf") == 0) {
- d = -HUGE_VAL;
+ d = -INFINITY;
}
else {
char *e;
@@ -1808,9 +1731,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
case TYPE_STRING:
v = r_entry(r_string(arg), arg);
- if (!ivp) {
- v = r_leave(v, arg);
- }
+ v = r_leave(v, arg);
break;
case TYPE_REGEXP:
@@ -1838,7 +1759,6 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
case 'L': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'X': case 'Y':
if (bs & 1) --dst;
- /* fall through */
default: bs = 0; break;
}
}
@@ -1910,8 +1830,9 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
v = r_entry0(v, idx, arg);
values = rb_ary_new2(len);
{
- VALUE keywords = Qfalse;
- if (RTEST(rb_struct_s_keyword_init(klass))) {
+ VALUE keywords;
+ int keyword_init = RTEST(rb_struct_s_keyword_init(klass));
+ if (keyword_init) {
keywords = rb_hash_new();
rb_ary_push(values, keywords);
}
@@ -1925,7 +1846,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
rb_class_name(klass),
slot, n);
}
- if (keywords) {
+ if (keyword_init) {
rb_hash_aset(keywords, RARRAY_AREF(mem, i), r_object(arg));
}
else {
@@ -2134,7 +2055,7 @@ clear_load_arg(struct load_arg *arg)
* Please see the overview for further details.
*/
static VALUE
-marshal_load(int argc, VALUE *argv, VALUE _)
+marshal_load(int argc, VALUE *argv)
{
VALUE port, proc;
@@ -2147,22 +2068,25 @@ marshal_load(int argc, VALUE *argv, VALUE _)
VALUE
rb_marshal_load_with_proc(VALUE port, VALUE proc)
{
- int major, minor;
+ int major, minor, infection = 0;
VALUE v;
VALUE wrapper; /* used to avoid memory leak in case of exception */
struct load_arg *arg;
v = rb_check_string_type(port);
if (!NIL_P(v)) {
+ infection = (int)FL_TEST(port, MARSHAL_INFECTION); /* original taintedness */
port = v;
}
else if (rb_respond_to(port, s_getbyte) && rb_respond_to(port, s_read)) {
rb_check_funcall(port, s_binmode, 0, 0);
+ infection = (int)FL_TAINT;
}
else {
io_needed();
}
wrapper = TypedData_Make_Struct(0, struct load_arg, &load_arg_data, arg);
+ arg->infection = infection;
arg->src = port;
arg->offset = 0;
arg->symbols = st_init_numtable();
@@ -2329,8 +2253,6 @@ Init_marshal(void)
set_id(s_read);
set_id(s_write);
set_id(s_binmode);
- set_id(s_encoding_short);
- set_id(s_ruby2_keywords_flag);
rb_define_module_function(rb_mMarshal, "dump", marshal_dump, -1);
rb_define_module_function(rb_mMarshal, "load", marshal_load, -1);
diff --git a/math.c b/math.c
index d98467ca0a..ce49879305 100644
--- a/math.c
+++ b/math.c
@@ -382,8 +382,8 @@ math_atanh(VALUE unused_obj, VALUE x)
/* check for domain error */
if (d < -1.0 || +1.0 < d) domain_error("atanh");
/* check for pole error */
- if (d == -1.0) return DBL2NUM(-HUGE_VAL);
- if (d == +1.0) return DBL2NUM(+HUGE_VAL);
+ if (d == -1.0) return DBL2NUM(-INFINITY);
+ if (d == +1.0) return DBL2NUM(+INFINITY);
return DBL2NUM(atanh(d));
}
@@ -426,7 +426,6 @@ math_exp(VALUE unused_obj, VALUE x)
#endif
static double math_log1(VALUE x);
-FUNC_MINIMIZED(static VALUE math_log(int, const VALUE *, VALUE));
/*
* call-seq:
@@ -452,12 +451,6 @@ FUNC_MINIMIZED(static VALUE math_log(int, const VALUE *, VALUE));
static VALUE
math_log(int argc, const VALUE *argv, VALUE unused_obj)
{
- return rb_math_log(argc, argv);
-}
-
-VALUE
-rb_math_log(int argc, const VALUE *argv)
-{
VALUE x, base;
double d;
@@ -495,7 +488,7 @@ math_log1(VALUE x)
/* check for domain error */
if (d < 0.0) domain_error("log");
/* check for pole error */
- if (d == 0.0) return -HUGE_VAL;
+ if (d == 0.0) return -INFINITY;
return log(d) + numbits * M_LN2; /* log(d * 2 ** numbits) */
}
@@ -538,7 +531,7 @@ math_log2(VALUE unused_obj, VALUE x)
/* check for domain error */
if (d < 0.0) domain_error("log2");
/* check for pole error */
- if (d == 0.0) return DBL2NUM(-HUGE_VAL);
+ if (d == 0.0) return DBL2NUM(-INFINITY);
return DBL2NUM(log2(d) + numbits); /* log2(d * 2 ** numbits) */
}
@@ -568,13 +561,11 @@ math_log10(VALUE unused_obj, VALUE x)
/* check for domain error */
if (d < 0.0) domain_error("log10");
/* check for pole error */
- if (d == 0.0) return DBL2NUM(-HUGE_VAL);
+ if (d == 0.0) return DBL2NUM(-INFINITY);
return DBL2NUM(log10(d) + numbits * log10(2)); /* log10(d * 2 ** numbits) */
}
-static VALUE rb_math_sqrt(VALUE x);
-
/*
* call-seq:
* Math.sqrt(x) -> Float
@@ -632,7 +623,7 @@ f_signbit(VALUE x)
return f_negative_p(x);
}
-static VALUE
+VALUE
rb_math_sqrt(VALUE x)
{
double d;
@@ -691,14 +682,7 @@ rb_math_sqrt(VALUE x)
static VALUE
math_cbrt(VALUE unused_obj, VALUE x)
{
- double f = Get_Double(x);
- double r = cbrt(f);
-#if defined __GLIBC__
- if (isfinite(r)) {
- r = (2.0 * r + (f / r / r)) / 3.0;
- }
-#endif
- return DBL2NUM(r);
+ return DBL2NUM(cbrt(Get_Double(x)));
}
/*
@@ -871,10 +855,10 @@ math_gamma(VALUE unused_obj, VALUE x)
/* check for domain error */
if (isinf(d)) {
if (signbit(d)) domain_error("gamma");
- return DBL2NUM(HUGE_VAL);
+ return DBL2NUM(INFINITY);
}
if (d == 0.0) {
- return signbit(d) ? DBL2NUM(-HUGE_VAL) : DBL2NUM(HUGE_VAL);
+ return signbit(d) ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY);
}
if (d == floor(d)) {
if (d < 0.0) domain_error("gamma");
@@ -909,11 +893,11 @@ math_lgamma(VALUE unused_obj, VALUE x)
/* check for domain error */
if (isinf(d)) {
if (signbit(d)) domain_error("lgamma");
- return rb_assoc_new(DBL2NUM(HUGE_VAL), INT2FIX(1));
+ return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1));
}
if (d == 0.0) {
VALUE vsign = signbit(d) ? INT2FIX(-1) : INT2FIX(+1);
- return rb_assoc_new(DBL2NUM(HUGE_VAL), vsign);
+ return rb_assoc_new(DBL2NUM(INFINITY), vsign);
}
v = DBL2NUM(lgamma_r(d, &sign));
return rb_assoc_new(v, INT2FIX(sign));
@@ -939,6 +923,13 @@ exp1(cos)
exp1(cosh)
exp1(exp)
exp2(hypot)
+
+VALUE
+rb_math_log(int argc, const VALUE *argv)
+{
+ return math_log(argc, argv, 0);
+}
+
exp1(sin)
exp1(sinh)
#if 0
@@ -984,7 +975,7 @@ InitVM_Math(void)
rb_define_const(rb_mMath, "PI", DBL2NUM(M_PI));
#ifdef M_E
- /* Definition of the mathematical constant E for Euler's number (e) as a Float number. */
+ /* Definition of the mathematical constant E (e) as a Float number. */
rb_define_const(rb_mMath, "E", DBL2NUM(M_E));
#else
rb_define_const(rb_mMath, "E", DBL2NUM(exp(1.0)));
diff --git a/method.h b/method.h
index 18deea7b03..dc430401a7 100644
--- a/method.h
+++ b/method.h
@@ -33,16 +33,16 @@ typedef enum {
} rb_method_visibility_t;
typedef struct rb_scope_visi_struct {
- BITFIELD(rb_method_visibility_t, method_visi, 3);
+ rb_method_visibility_t method_visi : 3;
unsigned int module_func : 1;
} rb_scope_visibility_t;
/*! CREF (Class REFerence) */
typedef struct rb_cref_struct {
VALUE flags;
- VALUE refinements;
- VALUE klass;
- struct rb_cref_struct * next;
+ const VALUE refinements;
+ const VALUE klass;
+ struct rb_cref_struct * const next;
const rb_scope_visibility_t scope_visi;
} rb_cref_t;
@@ -50,10 +50,10 @@ typedef struct rb_cref_struct {
typedef struct rb_method_entry_struct {
VALUE flags;
- VALUE defined_class;
+ const VALUE defined_class;
struct rb_method_definition_struct * const def;
ID called_id;
- VALUE owner;
+ const VALUE owner;
} rb_method_entry_t;
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
@@ -88,14 +88,14 @@ METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsig
VM_ASSERT(basic <= 1);
me->flags =
(me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
- ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
+ ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
}
static inline void
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
{
dst->flags =
(dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
- (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
+ (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
}
typedef enum {
@@ -114,9 +114,6 @@ typedef enum {
END_OF_ENUMERATION(VM_METHOD_TYPE)
} rb_method_type_t;
-#define VM_METHOD_TYPE_MINIMUM_BITS 4
-STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
- VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
#ifndef rb_iseq_t
typedef struct rb_iseq_struct rb_iseq_t;
@@ -124,65 +121,56 @@ typedef struct rb_iseq_struct rb_iseq_t;
#endif
typedef struct rb_method_iseq_struct {
- rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
- rb_cref_t * cref; /*!< class reference, should be marked */
+ const rb_iseq_t * const iseqptr; /*!< iseq pointer, should be separated from iseqval */
+ rb_cref_t * const cref; /*!< class reference, should be marked */
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
typedef struct rb_method_cfunc_struct {
VALUE (*func)(ANYARGS);
- VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
+ VALUE (*invoker)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *argv);
int argc;
} rb_method_cfunc_t;
typedef struct rb_method_attr_struct {
ID id;
- VALUE location; /* should be marked */
+ const VALUE location; /* should be marked */
} rb_method_attr_t;
typedef struct rb_method_alias_struct {
- struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
+ const struct rb_method_entry_struct * const original_me; /* original_me->klass is original owner */
} rb_method_alias_t;
typedef struct rb_method_refined_struct {
- struct rb_method_entry_struct * orig_me;
- VALUE owner;
+ const struct rb_method_entry_struct * const orig_me;
+ const VALUE owner;
} rb_method_refined_t;
-typedef struct rb_method_bmethod_struct {
- VALUE proc; /* should be marked */
- struct rb_hook_list_struct *hooks;
-} rb_method_bmethod_t;
-
enum method_optimized_type {
OPTIMIZED_METHOD_TYPE_SEND,
OPTIMIZED_METHOD_TYPE_CALL,
- OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
OPTIMIZED_METHOD_TYPE__MAX
};
-struct rb_method_definition_struct {
- BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
+PACKED_STRUCT_UNALIGNED(struct rb_method_definition_struct {
+ unsigned int type : 4; /* method type */
int alias_count : 28;
int complemented_count : 28;
- unsigned int no_redef_warning: 1;
union {
- rb_method_iseq_t iseq;
- rb_method_cfunc_t cfunc;
- rb_method_attr_t attr;
- rb_method_alias_t alias;
- rb_method_refined_t refined;
- rb_method_bmethod_t bmethod;
-
- enum method_optimized_type optimize_type;
+ rb_method_iseq_t iseq;
+ rb_method_cfunc_t cfunc;
+ rb_method_attr_t attr;
+ rb_method_alias_t alias;
+ rb_method_refined_t refined;
+
+ const VALUE proc; /* should be marked */
+ enum method_optimized_type optimize_type;
} body;
ID original_id;
- uintptr_t method_serial;
-};
+});
typedef struct rb_method_definition_struct rb_method_definition_t;
-STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8);
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
#define UNDEFINED_REFINED_METHOD_P(def) \
@@ -192,15 +180,14 @@ STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8);
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
-void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
+rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
-const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
RUBY_SYMBOL_EXPORT_BEGIN
@@ -216,8 +203,11 @@ int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2)
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
VALUE rb_method_entry_location(const rb_method_entry_t *me);
+VALUE rb_mod_method_location(VALUE mod, ID id);
+VALUE rb_obj_method_location(VALUE obj, ID id);
void rb_free_method_entry(const rb_method_entry_t *me);
+void rb_sweep_method_entry(void *vm);
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
@@ -225,6 +215,4 @@ void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
void rb_scope_visibility_set(rb_method_visibility_t);
-VALUE rb_unnamed_parameters(int arity);
-
#endif /* RUBY_METHOD_H */
diff --git a/mini_builtin.c b/mini_builtin.c
deleted file mode 100644
index ad289bf896..0000000000
--- a/mini_builtin.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "internal.h"
-#include "vm_core.h"
-#include "iseq.h"
-#include "builtin.h"
-
-#include "miniprelude.c"
-
-// included from miniinit.c
-
-#ifndef INCLUDED_BY_BUILTIN_C
-static struct st_table *loaded_builtin_table;
-#endif
-
-rb_ast_t *rb_builtin_ast(const char *feature_name, VALUE *name_str);
-
-static const rb_iseq_t *
-builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *table)
-{
- VALUE name_str = 0;
- rb_ast_t *ast = rb_builtin_ast(feature_name, &name_str);
- rb_vm_t *vm = GET_VM();
-
- vm->builtin_function_table = table;
- vm->builtin_inline_index = 0;
- const rb_iseq_t *iseq = rb_iseq_new(&ast->body, name_str, name_str, Qnil, NULL, ISEQ_TYPE_TOP);
- GET_VM()->builtin_function_table = NULL;
-
- rb_ast_dispose(ast);
-
- // for debug
- if (0 && strcmp("prelude", feature_name) == 0) {
- rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
- }
-
-#ifndef INCLUDED_BY_BUILTIN_C
- st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
- rb_gc_register_mark_object((VALUE)iseq);
-#endif
-
- return iseq;
-}
-
-void
-rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
-{
- const rb_iseq_t *iseq = builtin_iseq_load(feature_name, table);
- rb_iseq_eval(iseq);
-}
-
-#ifndef INCLUDED_BY_BUILTIN_C
-
-static int
-each_builtin_i(st_data_t key, st_data_t val, st_data_t dmy)
-{
- const char *feature = (const char *)key;
- const rb_iseq_t *iseq = (const rb_iseq_t *)val;
-
- rb_yield_values(2, rb_str_new2(feature), rb_iseqw_new(iseq));
-
- return ST_CONTINUE;
-}
-
-static VALUE
-each_builtin(VALUE self)
-{
- st_foreach(loaded_builtin_table, each_builtin_i, 0);
- return Qnil;
-}
-
-void
-Init_builtin(void)
-{
- rb_define_singleton_method(rb_cRubyVM, "each_builtin", each_builtin, 0);
- loaded_builtin_table = st_init_strtable();
-}
-
-void
-Init_builtin_features(void)
-{
- // register for ruby
- builtin_iseq_load("gem_prelude", NULL);
-}
-#endif
diff --git a/miniinit.c b/miniinit.c
index 2a14a0d1c5..7284e2e62d 100644
--- a/miniinit.c
+++ b/miniinit.c
@@ -47,5 +47,3 @@ Init_enc(void)
rb_encdb_alias("BINARY", "ASCII-8BIT");
rb_encdb_alias("ASCII", "US-ASCII");
}
-
-#include "mini_builtin.c"
diff --git a/misc/README b/misc/README
index 1728b42700..08a9010f58 100644
--- a/misc/README
+++ b/misc/README
@@ -1,6 +1,12 @@
-README this file
-rb_optparse.bash bash completion script
-rb_optparse.zsh zsh completion script
-ruby-style.el Ruby's C/C++ mode style for emacs
-lldb_cruby.py LLDB port of debug utility
-test_lldb_cruby.rb test file for LLDB port
+README this file
+inf-ruby.el program to run ruby under emacs
+rb_optparse.bash bash completion script
+rb_optparse.zsh zsh completion script
+rdoc-mode.el RDoc mode for emacs
+ruby-mode.el ruby mode for emacs
+ruby-style.el Ruby's C/C++ mode style for emacs
+rubydb2x.el ruby debugger support for emacs 19.2x or before
+rubydb3x.el ruby debugger support for emacs 19.3x or later
+ruby-electric.el emacs minor mode providing electric commands
+
+Check out https://github.com/ruby-debug/ also.
diff --git a/misc/expand_tabs.rb b/misc/expand_tabs.rb
deleted file mode 100755
index 7b3bff78ff..0000000000
--- a/misc/expand_tabs.rb
+++ /dev/null
@@ -1,169 +0,0 @@
-#!/usr/bin/env ruby --disable-gems
-# Add the following line to your `.git/hooks/pre-commit`:
-#
-# $ ruby --disable-gems misc/expand_tabs.rb
-#
-
-require 'shellwords'
-require 'tmpdir'
-ENV['LC_ALL'] = 'C'
-
-class Git
- def initialize(oldrev, newrev)
- @oldrev = oldrev
- @newrev = newrev
- end
-
- # ["foo/bar.c", "baz.h", ...]
- def updated_paths
- with_clean_env do
- IO.popen(['git', 'diff', '--cached', '--name-only', @newrev], &:readlines).each(&:chomp!)
- end
- end
-
- # [0, 1, 4, ...]
- def updated_lines(file)
- lines = []
- revs_pattern = ("0"*40) + " "
- with_clean_env { IO.popen(['git', 'blame', '-l', '--', file], &:readlines) }.each_with_index do |line, index|
- if line.b.start_with?(revs_pattern)
- lines << index
- end
- end
- lines
- end
-
- def add(file)
- git('add', file)
- end
-
- def toplevel
- IO.popen(['git', 'rev-parse', '--show-toplevel'], &:read).chomp
- end
-
- private
-
- def git(*args)
- cmd = ['git', *args].shelljoin
- unless with_clean_env { system(cmd) }
- abort "Failed to run: #{cmd}"
- end
- end
-
- def with_clean_env
- git_dir = ENV.delete('GIT_DIR') # this overcomes '-C' or pwd
- yield
- ensure
- ENV['GIT_DIR'] = git_dir if git_dir
- end
-end
-
-DEFAULT_GEM_LIBS = %w[
- bundler
- cmath
- csv
- e2mmap
- fileutils
- forwardable
- ipaddr
- irb
- logger
- matrix
- mutex_m
- ostruct
- prime
- racc
- rdoc
- rexml
- rss
- scanf
- shell
- sync
- thwait
- tracer
- webrick
-]
-
-DEFAULT_GEM_EXTS = %w[
- bigdecimal
- date
- dbm
- etc
- fcntl
- fiddle
- gdbm
- io/console
- json
- openssl
- psych
- sdbm
- stringio
- strscan
- zlib
-]
-
-EXPANDTAB_IGNORED_FILES = [
- # default gems whose master is GitHub
- %r{\Abin/(?!erb)\w+\z},
- *DEFAULT_GEM_LIBS.flat_map { |lib|
- [
- %r{\Alib/#{lib}/},
- %r{\Alib/#{lib}\.gemspec\z},
- %r{\Alib/#{lib}\.rb\z},
- %r{\Atest/#{lib}/},
- ]
- },
- *DEFAULT_GEM_EXTS.flat_map { |ext|
- [
- %r{\Aext/#{ext}/},
- %r{\Atest/#{ext}/},
- ]
- },
-
- # vendoring (ccan)
- %r{\Accan/},
-
- # vendoring (onigmo)
- %r{\Aenc/},
- %r{\Ainclude/ruby/onigmo\.h\z},
- %r{\Areg.+\.(c|h)\z},
-
- # explicit or implicit `c-file-style: "linux"`
- %r{\Aaddr2line\.c\z},
- %r{\Amissing/},
- %r{\Astrftime\.c\z},
- %r{\Avsnprintf\.c\z},
-]
-
-git = Git.new('HEAD^', 'HEAD')
-
-Dir.chdir(git.toplevel) do
- paths = git.updated_paths
- paths.select! {|f|
- (f.end_with?('.c') || f.end_with?('.h') || f == 'insns.def') && EXPANDTAB_IGNORED_FILES.all? { |re| !f.match(re) }
- }
- files = paths.select {|n| File.file?(n)}
- exit if files.empty?
-
- files.each do |f|
- src = File.binread(f) rescue next
-
- expanded = false
- updated_lines = git.updated_lines(f)
- unless updated_lines.empty?
- src.gsub!(/^.*$/).with_index do |line, lineno|
- if updated_lines.include?(lineno) && line.start_with?("\t") # last-committed line with hard tabs
- expanded = true
- line.sub(/\A\t+/) { |tabs| ' ' * (8 * tabs.length) }
- else
- line
- end
- end
- end
-
- if expanded
- File.binwrite(f, src)
- git.add(f)
- end
- end
-end
diff --git a/misc/inf-ruby.el b/misc/inf-ruby.el
new file mode 100644
index 0000000000..b3f4f10267
--- /dev/null
+++ b/misc/inf-ruby.el
@@ -0,0 +1,418 @@
+;;; -*-Emacs-Lisp-*-
+;;;
+;;; $Id$
+;;; $Author$
+;;;
+;;; Inferior Ruby Mode - ruby process in a buffer.
+;;; adapted from cmuscheme.el
+;;;
+;;; Usage:
+;;;
+;;; (0) check ruby-program-name variable that can run your environment.
+;;;
+;;; (1) modify .emacs to use ruby-mode
+;;; for example :
+;;;
+;;; (autoload 'ruby-mode "ruby-mode"
+;;; "Mode for editing ruby source files" t)
+;;; (setq auto-mode-alist
+;;; (append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
+;;; (setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
+;;; interpreter-mode-alist))
+;;;
+;;; (2) set to load inf-ruby and set inf-ruby key definition in ruby-mode.
+;;;
+;;; (autoload 'run-ruby "inf-ruby"
+;;; "Run an inferior Ruby process")
+;;; (autoload 'inf-ruby-keys "inf-ruby"
+;;; "Set local key defs for inf-ruby in ruby-mode")
+;;; (add-hook 'ruby-mode-hook
+;;; '(lambda ()
+;;; (inf-ruby-keys)
+;;; ))
+;;;
+;;; HISTORY
+;;; senda - 8 Apr 1998: Created.
+;;; $Log$
+;;; Revision 1.7 2004/07/27 08:11:36 matz
+;;; * eval.c (rb_eval): copy on write for argument local variable
+;;; assignment.
+;;;
+;;; * eval.c (assign): ditto.
+;;;
+;;; * eval.c (rb_call0): update ruby_frame->argv with the default
+;;; value used for the optional arguments.
+;;;
+;;; * object.c (Init_Object): "===" calls rb_obj_equal() directly.
+;;; [ruby-list:39937]
+;;;
+;;; Revision 1.6 2002/09/07 14:35:46 nobu
+;;; * misc/inf-ruby.el (inferior-ruby-error-regexp-alist): regexp
+;;; alist for error message from ruby.
+;;;
+;;; * misc/inf-ruby.el (inferior-ruby-mode): fixed for Emacs.
+;;;
+;;; * misc/inf-ruby.el (ruby-send-region): compilation-parse-errors
+;;; doesn't parse first line, so insert separators before each
+;;; evaluations.
+;;;
+;;; Revision 1.5 2002/08/19 10:05:47 nobu
+;;; * misc/inf-ruby.el (inf-ruby-keys): ruby-send-definition
+;;; conflicted with ruby-insert-end.
+;;;
+;;; * misc/inf-ruby.el (inferior-ruby-mode): compilation-minor-mode.
+;;;
+;;; * misc/inf-ruby.el (ruby-send-region): send as here document to
+;;; adjust source file/line. [ruby-talk:47113], [ruby-dev:17965]
+;;;
+;;; * misc/inf-ruby.el (ruby-send-terminator): added to make unique
+;;; terminator.
+;;;
+;;; Revision 1.4 2002/01/29 07:16:09 matz
+;;; * file.c (rb_stat_rdev_major): added. [new]
+;;;
+;;; * file.c (rb_stat_rdev_minor): added. [new]
+;;;
+;;; * file.c (rb_stat_inspect): print mode in octal.
+;;;
+;;; Revision 1.3 1999/12/01 09:24:18 matz
+;;; 19991201
+;;;
+;;; Revision 1.2 1999/08/13 05:45:18 matz
+;;; 1.4.0
+;;;
+;;; Revision 1.1.1.1.2.1 1999/07/15 07:59:59 matz
+;;; 990715
+;;;
+;;; Revision 1.1.1.1 1999/01/20 04:59:36 matz
+;;; ruby 1.3 cycle
+;;;
+;;; Revision 1.1.2.1 1998/12/16 07:30:36 matz
+;;; first public release of 1.1d (pre1.2) series
+;;;
+;;; Revision 1.4 1998/05/20 02:45:58 senda
+;;; default program to irb
+;;;
+;;; Revision 1.3 1998/04/10 04:11:30 senda
+;;; modification by Matsumoto san (1.1b9_09)
+;;; remove-in-string defined
+;;; global variable :
+;;; inferior-ruby-first-prompt-pattern
+;;; inferior-ruby-prompt-pattern
+;;; defined
+;;;
+;;; Revision 1.2 1998/04/09 07:53:42 senda
+;;; remove M-C-x in inferior-ruby-mode
+;;;
+;;; Revision 1.1 1998/04/09 07:28:36 senda
+;;; Initial revision
+;;;
+;;;
+
+(require 'comint)
+(require 'compile)
+(require 'ruby-mode)
+
+;;
+;; you may change these variables
+;;
+;(defvar ruby-program-name "rbc --noreadline"
+; "*Program invoked by the run-ruby command")
+;
+;(defvar inferior-ruby-first-prompt-pattern "^rbc0> *"
+; "first prompt regex pattern of ruby interpreter.")
+;
+;(defvar inferior-ruby-prompt-pattern "^\\(rbc.[>*\"'] *\\)+"
+; "prompt regex pattern of ruby interpreter.")
+
+;;;; for irb
+(defvar ruby-program-name "irb --inf-ruby-mode"
+ "*Program invoked by the run-ruby command")
+
+(defvar inferior-ruby-first-prompt-pattern "^irb(.*)[0-9:]+0> *"
+ "first prompt regex pattern of ruby interpreter.")
+
+(defvar inferior-ruby-prompt-pattern "^\\(irb(.*)[0-9:]+[>*\"'] *\\)+"
+ "prompt regex pattern of ruby interpreter.")
+
+;;
+;; mode variables
+;;
+(defvar inferior-ruby-mode-hook nil
+ "*Hook for customising inferior-ruby mode.")
+(defvar inferior-ruby-mode-map nil
+ "*Mode map for inferior-ruby-mode")
+
+(defconst inferior-ruby-error-regexp-alist
+ '(("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2)
+ ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
+
+(cond ((not inferior-ruby-mode-map)
+ (setq inferior-ruby-mode-map
+ (copy-keymap comint-mode-map))
+; (define-key inferior-ruby-mode-map "\M-\C-x" ;gnu convention
+; 'ruby-send-definition)
+; (define-key inferior-ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
+ (define-key inferior-ruby-mode-map "\C-c\C-l" 'ruby-load-file)
+))
+
+;;;###autoload
+(defun inf-ruby-keys ()
+ "Set local key defs for inf-ruby in ruby-mode"
+ (define-key ruby-mode-map "\M-\C-x" 'ruby-send-definition)
+; (define-key ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
+ (define-key ruby-mode-map "\C-c\C-b" 'ruby-send-block)
+ (define-key ruby-mode-map "\C-c\M-b" 'ruby-send-block-and-go)
+ (define-key ruby-mode-map "\C-c\C-x" 'ruby-send-definition)
+ (define-key ruby-mode-map "\C-c\M-x" 'ruby-send-definition-and-go)
+ (define-key ruby-mode-map "\C-c\C-r" 'ruby-send-region)
+ (define-key ruby-mode-map "\C-c\M-r" 'ruby-send-region-and-go)
+ (define-key ruby-mode-map "\C-c\C-z" 'switch-to-ruby)
+ (define-key ruby-mode-map "\C-c\C-l" 'ruby-load-file)
+ (define-key ruby-mode-map "\C-c\C-s" 'run-ruby)
+)
+
+(defvar ruby-buffer nil "current ruby (actually irb) process buffer.")
+
+(defun inferior-ruby-mode ()
+ "Major mode for interacting with an inferior ruby (irb) process.
+
+The following commands are available:
+\\{inferior-ruby-mode-map}
+
+A ruby process can be fired up with M-x run-ruby.
+
+Customisation: Entry to this mode runs the hooks on comint-mode-hook and
+inferior-ruby-mode-hook (in that order).
+
+You can send text to the inferior ruby process from other buffers containing
+Ruby source.
+ switch-to-ruby switches the current buffer to the ruby process buffer.
+ ruby-send-definition sends the current definition to the ruby process.
+ ruby-send-region sends the current region to the ruby process.
+
+ ruby-send-definition-and-go, ruby-send-region-and-go,
+ switch to the ruby process buffer after sending their text.
+For information on running multiple processes in multiple buffers, see
+documentation for variable ruby-buffer.
+
+Commands:
+Return after the end of the process' output sends the text from the
+ end of process to point.
+Return before the end of the process' output copies the sexp ending at point
+ to the end of the process' output, and sends it.
+Delete converts tabs to spaces as it moves back.
+Tab indents for ruby; with argument, shifts rest
+ of expression rigidly with the current line.
+C-M-q does Tab on each line starting within following expression.
+Paragraphs are separated only by blank lines. # start comments.
+If you accidentally suspend your process, use \\[comint-continue-subjob]
+to continue it."
+ (interactive)
+ (comint-mode)
+ ;; Customise in inferior-ruby-mode-hook
+ ;(setq comint-prompt-regexp "^[^>\n]*>+ *")
+ (setq comint-prompt-regexp inferior-ruby-prompt-pattern)
+ ;;(scheme-mode-variables)
+ (ruby-mode-variables)
+ (setq major-mode 'inferior-ruby-mode)
+ (setq mode-name "Inferior Ruby")
+ (setq mode-line-process '(":%s"))
+ (use-local-map inferior-ruby-mode-map)
+ (setq comint-input-filter (function ruby-input-filter))
+ (setq comint-get-old-input (function ruby-get-old-input))
+ (make-local-variable 'compilation-error-regexp-alist)
+ (setq compilation-error-regexp-alist inferior-ruby-error-regexp-alist)
+ (compilation-shell-minor-mode t)
+ (run-hooks 'inferior-ruby-mode-hook))
+
+(defvar inferior-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
+ "*Input matching this regexp are not saved on the history list.
+Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters.")
+
+(defun ruby-input-filter (str)
+ "Don't save anything matching inferior-ruby-filter-regexp"
+ (not (string-match inferior-ruby-filter-regexp str)))
+
+;; adapted from replace-in-string in XEmacs (subr.el)
+(defun remove-in-string (str regexp)
+ "Remove all matches in STR for REGEXP and returns the new string."
+ (let ((rtn-str "") (start 0) match prev-start)
+ (while (setq match (string-match regexp str start))
+ (setq prev-start start
+ start (match-end 0)
+ rtn-str (concat rtn-str (substring str prev-start match))))
+ (concat rtn-str (substring str start))))
+
+(defun ruby-get-old-input ()
+ "Snarf the sexp ending at point"
+ (save-excursion
+ (let ((end (point)))
+ (re-search-backward inferior-ruby-first-prompt-pattern)
+ (remove-in-string (buffer-substring (point) end)
+ inferior-ruby-prompt-pattern)
+ )))
+
+(defun ruby-args-to-list (string)
+ (let ((where (string-match "[ \t]" string)))
+ (cond ((null where) (list string))
+ ((not (= where 0))
+ (cons (substring string 0 where)
+ (ruby-args-to-list (substring string (+ 1 where)
+ (length string)))))
+ (t (let ((pos (string-match "[^ \t]" string)))
+ (if (null pos)
+ nil
+ (ruby-args-to-list (substring string pos
+ (length string)))))))))
+
+;;;###autoload
+(defun run-ruby (cmd)
+ "Run an inferior Ruby process, input and output via buffer *ruby*.
+If there is a process already running in `*ruby*', switch to that buffer.
+With argument, allows you to edit the command line (default is value
+of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
+\(after the `comint-mode-hook' is run).
+\(Type \\[describe-mode] in the process buffer for a list of commands.)"
+
+ (interactive (list (if current-prefix-arg
+ (read-string "Run Ruby: " ruby-program-name)
+ ruby-program-name)))
+ (if (not (comint-check-proc "*ruby*"))
+ (let ((cmdlist (ruby-args-to-list cmd)))
+ (set-buffer (apply 'make-comint "ruby" (car cmdlist)
+ nil (cdr cmdlist)))
+ (inferior-ruby-mode)))
+ (setq ruby-program-name cmd)
+ (setq ruby-buffer "*ruby*")
+ (pop-to-buffer "*ruby*"))
+
+(defconst ruby-send-terminator "--inf-ruby-%x-%d-%d-%d--"
+ "Template for irb here document terminator.
+Must not contain ruby meta characters.")
+
+(defconst ruby-eval-separator "")
+
+(defun ruby-send-region (start end)
+ "Send the current region to the inferior Ruby process."
+ (interactive "r")
+ (let (term (file (buffer-file-name)) line)
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char start)
+ (setq line (+ start (forward-line (- start)) 1))
+ (goto-char start)
+ (while (progn
+ (setq term (apply 'format ruby-send-terminator (random) (current-time)))
+ (re-search-forward (concat "^" (regexp-quote term) "$") end t)))))
+ ;; compilation-parse-errors parses from second line.
+ (save-excursion
+ (let ((m (process-mark (ruby-proc))))
+ (set-buffer (marker-buffer m))
+ (goto-char m)
+ (insert ruby-eval-separator "\n")
+ (set-marker m (point))))
+ (comint-send-string (ruby-proc) (format "eval <<'%s', nil, %S, %d\n" term file line))
+ (comint-send-region (ruby-proc) start end)
+ (comint-send-string (ruby-proc) (concat "\n" term "\n"))))
+
+(defun ruby-send-definition ()
+ "Send the current definition to the inferior Ruby process."
+ (interactive)
+ (save-excursion
+ (ruby-end-of-defun)
+ (let ((end (point)))
+ (ruby-beginning-of-defun)
+ (ruby-send-region (point) end))))
+
+;(defun ruby-send-last-sexp ()
+; "Send the previous sexp to the inferior Ruby process."
+; (interactive)
+; (ruby-send-region (save-excursion (backward-sexp) (point)) (point)))
+
+(defun ruby-send-block ()
+ "Send the current block to the inferior Ruby process."
+ (interactive)
+ (save-excursion
+ (ruby-end-of-block)
+ (end-of-line)
+ (let ((end (point)))
+ (ruby-beginning-of-block)
+ (ruby-send-region (point) end))))
+
+(defun switch-to-ruby (eob-p)
+ "Switch to the ruby process buffer.
+With argument, positions cursor at end of buffer."
+ (interactive "P")
+ (if (get-buffer ruby-buffer)
+ (pop-to-buffer ruby-buffer)
+ (error "No current process buffer. See variable ruby-buffer."))
+ (cond (eob-p
+ (push-mark)
+ (goto-char (point-max)))))
+
+(defun ruby-send-region-and-go (start end)
+ "Send the current region to the inferior Ruby process.
+Then switch to the process buffer."
+ (interactive "r")
+ (ruby-send-region start end)
+ (switch-to-ruby t))
+
+(defun ruby-send-definition-and-go ()
+ "Send the current definition to the inferior Ruby.
+Then switch to the process buffer."
+ (interactive)
+ (ruby-send-definition)
+ (switch-to-ruby t))
+
+(defun ruby-send-block-and-go ()
+ "Send the current block to the inferior Ruby.
+Then switch to the process buffer."
+ (interactive)
+ (ruby-send-block)
+ (switch-to-ruby t))
+
+(defvar ruby-source-modes '(ruby-mode)
+ "*Used to determine if a buffer contains Ruby source code.
+If it's loaded into a buffer that is in one of these major modes, it's
+considered a ruby source file by ruby-load-file.
+Used by these commands to determine defaults.")
+
+(defvar ruby-prev-l/c-dir/file nil
+ "Caches the last (directory . file) pair.
+Caches the last pair used in the last ruby-load-file command.
+Used for determining the default in the
+next one.")
+
+(defun ruby-load-file (file-name)
+ "Load a Ruby file into the inferior Ruby process."
+ (interactive (comint-get-source "Load Ruby file: " ruby-prev-l/c-dir/file
+ ruby-source-modes t)) ; T because LOAD
+ ; needs an exact name
+ (comint-check-source file-name) ; Check to see if buffer needs saved.
+ (setq ruby-prev-l/c-dir/file (cons (file-name-directory file-name)
+ (file-name-nondirectory file-name)))
+ (comint-send-string (ruby-proc) (concat "(load \""
+ file-name
+ "\"\)\n")))
+
+(defun ruby-proc ()
+ "Returns the current ruby process. See variable ruby-buffer."
+ (let ((proc (get-buffer-process (if (eq major-mode 'inferior-ruby-mode)
+ (current-buffer)
+ ruby-buffer))))
+ (or proc
+ (error "No current process. See variable ruby-buffer"))))
+
+;;; Do the user's customisation...
+
+(defvar inf-ruby-load-hook nil
+ "This hook is run when inf-ruby is loaded in.
+This is a good place to put keybindings.")
+
+(run-hooks 'inf-ruby-load-hook)
+
+(provide 'inf-ruby)
+
+;;; inf-ruby.el ends here
diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py
index a582b7dde0..e954d1be00 100755
--- a/misc/lldb_cruby.py
+++ b/misc/lldb_cruby.py
@@ -6,8 +6,8 @@
# Test: misc/test_lldb_cruby.rb
#
-from __future__ import print_function
import lldb
+import commands
import os
import shlex
@@ -21,7 +21,7 @@ def lldb_init(debugger):
for enum in target.FindFirstGlobalVariable('ruby_dummy_gdb_enums'):
enum = enum.GetType()
members = enum.GetEnumMembers()
- for i in range(0, members.GetSize()):
+ for i in xrange(0, members.GetSize()):
member = members.GetTypeEnumMemberAtIndex(i)
name = member.GetName()
value = member.GetValueAsUnsigned()
@@ -33,8 +33,6 @@ def lldb_init(debugger):
def string2cstr(rstring):
"""Returns the pointer to the C-string in the given String object"""
- if rstring.TypeIsPointerType():
- rstring = rstring.Dereference()
flags = rstring.GetValueForExpressionPath(".basic->flags").unsigned
if flags & RUBY_T_MASK != RUBY_T_STRING:
raise TypeError("not a string")
@@ -42,14 +40,14 @@ def string2cstr(rstring):
cptr = int(rstring.GetValueForExpressionPath(".as.heap.ptr").value, 0)
clen = int(rstring.GetValueForExpressionPath(".as.heap.len").value, 0)
else:
- cptr = int(rstring.GetValueForExpressionPath(".as.ary").location, 0)
+ cptr = int(rstring.GetValueForExpressionPath(".as.ary").value, 0)
clen = (flags & RSTRING_EMBED_LEN_MASK) >> RSTRING_EMBED_LEN_SHIFT
return cptr, clen
-def output_string(debugger, result, rstring):
+def output_string(ctx, rstring):
cptr, clen = string2cstr(rstring)
- expr = "print *(const char (*)[%d])%0#x" % (clen, cptr)
- append_command_output(debugger, expr, result)
+ expr = 'printf("%%.*s", (size_t)%d, (const char*)%d)' % (clen, cptr)
+ ctx.frame.EvaluateExpression(expr)
def fixnum_p(x):
return x & RUBY_FIXNUM_FLAG != 0
@@ -57,21 +55,7 @@ def fixnum_p(x):
def flonum_p(x):
return (x&RUBY_FLONUM_MASK) == RUBY_FLONUM_FLAG
-def static_sym_p(x):
- return (x&~(~0<<RUBY_SPECIAL_SHIFT)) == RUBY_SYMBOL_FLAG
-
-def append_command_output(debugger, command, result):
- output1 = result.GetOutput()
- debugger.GetCommandInterpreter().HandleCommand(command, result)
- output2 = result.GetOutput()
- result.Clear()
- result.write(output1)
- result.write(output2)
-
def lldb_rp(debugger, command, result, internal_dict):
- if not ('RUBY_Qfalse' in globals()):
- lldb_init(debugger)
-
target = debugger.GetSelectedTarget()
process = target.GetProcess()
thread = process.GetSelectedThread()
@@ -82,156 +66,70 @@ def lldb_rp(debugger, command, result, internal_dict):
val = target.EvaluateExpression(command)
error = val.GetError()
if error.Fail():
- print(error, file=result)
+ print >> result, error
return
- lldb_inspect(debugger, target, result, val)
-
-def lldb_inspect(debugger, target, result, val):
num = val.GetValueAsSigned()
if num == RUBY_Qfalse:
- print('false', file=result)
+ print >> result, 'false'
elif num == RUBY_Qtrue:
- print('true', file=result)
+ print >> result, 'true'
elif num == RUBY_Qnil:
- print('nil', file=result)
+ print >> result, 'nil'
elif num == RUBY_Qundef:
- print('undef', file=result)
+ print >> result, 'undef'
elif fixnum_p(num):
- print(num >> 1, file=result)
+ print >> result, num >> 1
elif flonum_p(num):
- append_command_output(debugger, "print rb_float_value(%0#x)" % val.GetValueAsUnsigned(), result)
- elif static_sym_p(num):
- if num < 128:
- print("T_SYMBOL: %c" % num, file=result)
- else:
- print("T_SYMBOL: (%x)" % num, file=result)
- append_command_output(debugger, "p rb_id2name(%0#x)" % (num >> 8), result)
+ debugger.HandleCommand("print rb_float_value(%0#x)" % val.GetValueAsUnsigned())
elif num & RUBY_IMMEDIATE_MASK:
- print('immediate(%x)' % num, file=result)
+ print >> result, 'immediate(%x)' % num
else:
tRBasic = target.FindFirstType("struct RBasic").GetPointerType()
val = val.Cast(tRBasic)
flags = val.GetValueForExpressionPath("->flags").GetValueAsUnsigned()
- flaginfo = ""
if (flags & RUBY_FL_PROMOTED) == RUBY_FL_PROMOTED:
- flaginfo += "[PROMOTED] "
- if (flags & RUBY_FL_FREEZE) == RUBY_FL_FREEZE:
- flaginfo += "[FROZEN] "
+ print >> result, "[PROMOTED] "
flType = flags & RUBY_T_MASK
if flType == RUBY_T_NONE:
- print('T_NONE: %s%s' % (flaginfo, val.Dereference()), file=result)
+ print >> result, 'T_NONE: %s' % val.Dereference()
elif flType == RUBY_T_NIL:
- print('T_NIL: %s%s' % (flaginfo, val.Dereference()), file=result)
+ print >> result, 'T_NIL: %s' % val.Dereference()
elif flType == RUBY_T_OBJECT:
- result.write('T_OBJECT: %s' % flaginfo)
- append_command_output(debugger, "print *(struct RObject*)%0#x" % val.GetValueAsUnsigned(), result)
- elif flType == RUBY_T_CLASS or flType == RUBY_T_MODULE or flType == RUBY_T_ICLASS:
- result.write('T_%s: %s' % ('CLASS' if flType == RUBY_T_CLASS else 'MODULE' if flType == RUBY_T_MODULE else 'ICLASS', flaginfo))
- append_command_output(debugger, "print *(struct RClass*)%0#x" % val.GetValueAsUnsigned(), result)
+ tRObject = target.FindFirstType("struct RObject").GetPointerType()
+ val = val.Cast(tRObject)
+ print >> result, 'T_OBJECT: %s' % val.Dereference()
elif flType == RUBY_T_STRING:
- result.write('T_STRING: %s' % flaginfo)
tRString = target.FindFirstType("struct RString").GetPointerType()
- ptr, len = string2cstr(val.Cast(tRString))
- append_command_output(debugger, "print *(const char (*)[%d])%0#x" % (len, ptr), result)
- elif flType == RUBY_T_SYMBOL:
- result.write('T_SYMBOL: %s' % flaginfo)
- tRSymbol = target.FindFirstType("struct RSymbol").GetPointerType()
- val = val.Cast(tRSymbol)
- append_command_output(debugger, 'print (ID)%0#x ' % val.GetValueForExpressionPath("->id").GetValueAsUnsigned(), result)
- tRString = target.FindFirstType("struct RString").GetPointerType()
- output_string(debugger, result, val.GetValueForExpressionPath("->fstr").Cast(tRString))
+ val = val.Cast(tRString)
+ if flags & RSTRING_NOEMBED:
+ print >> result, val.GetValueForExpressionPath("->as.heap")
+ else:
+ print >> result, val.GetValueForExpressionPath("->as.ary")
elif flType == RUBY_T_ARRAY:
tRArray = target.FindFirstType("struct RArray").GetPointerType()
val = val.Cast(tRArray)
if flags & RUBY_FL_USER1:
len = ((flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
- ptr = val.GetValueForExpressionPath("->as.ary")
- else:
- len = val.GetValueForExpressionPath("->as.heap.len").GetValueAsSigned()
- ptr = val.GetValueForExpressionPath("->as.heap.ptr")
- #print(val.GetValueForExpressionPath("->as.heap"), file=result)
- result.write("T_ARRAY: %slen=%d" % (flaginfo, len))
- if flags & RUBY_FL_USER1:
- result.write(" (embed)")
- elif flags & RUBY_FL_USER2:
- shared = val.GetValueForExpressionPath("->as.heap.aux.shared").GetValueAsUnsigned()
- result.write(" (shared) shared=%016x" % shared)
- else:
- capa = val.GetValueForExpressionPath("->as.heap.aux.capa").GetValueAsSigned()
- result.write(" (ownership) capa=%d" % capa)
- if len == 0:
- result.write(" {(empty)}\n")
- else:
- result.write("\n")
- if ptr.GetValueAsSigned() == 0:
- append_command_output(debugger, "expression -fx -- ((struct RArray*)%0#x)->as.ary" % val.GetValueAsUnsigned(), result)
+ print >> result, "T_ARRAY: len=%d (embed)" % len
+ if len == 0:
+ print >> result, "{(empty)}"
else:
- append_command_output(debugger, "expression -Z %d -fx -- (const VALUE*)%0#x" % (len, ptr.GetValueAsUnsigned()), result)
- elif flType == RUBY_T_HASH:
- result.write("T_HASH: %s" % flaginfo)
- append_command_output(debugger, "p *(struct RHash *) %0#x" % val.GetValueAsUnsigned(), result)
- elif flType == RUBY_T_BIGNUM:
- tRBignum = target.FindFirstType("struct RBignum").GetPointerType()
- val = val.Cast(tRBignum)
- if flags & RUBY_FL_USER2:
- len = ((flags & (RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5)) >> (RUBY_FL_USHIFT+3))
- print("T_BIGNUM: len=%d (embed)" % len, file=result)
- append_command_output(debugger, "print ((struct RBignum *) %0#x)->as.ary" % val.GetValueAsUnsigned(), result)
+ print >> result, val.GetValueForExpressionPath("->as.ary")
else:
len = val.GetValueForExpressionPath("->as.heap.len").GetValueAsSigned()
- print("T_BIGNUM: len=%d" % len, file=result)
- print(val.Dereference(), file=result)
- append_command_output(debugger, "expression -Z %x -fx -- (const BDIGIT*)((struct RBignum*)%d)->as.heap.digits" % (len, val.GetValueAsUnsigned()), result)
- # append_command_output(debugger, "x ((struct RBignum *) %0#x)->as.heap.digits / %d" % (val.GetValueAsUnsigned(), len), result)
- elif flType == RUBY_T_FLOAT:
- tRFloat = target.FindFirstType("struct RFloat").GetPointerType()
- val = val.Cast(tRFloat)
- append_command_output(debugger, "p *(double *)%0#x" % val.GetValueForExpressionPath("->float_value").GetAddress(), result)
- elif flType == RUBY_T_RATIONAL:
- tRRational = target.FindFirstType("struct RRational").GetPointerType()
- val = val.Cast(tRRational)
- lldb_inspect(debugger, target, result, val.GetValueForExpressionPath("->num"))
- output = result.GetOutput()
- result.Clear()
- result.write("(Rational) " + output.rstrip() + " / ")
- lldb_inspect(debugger, target, result, val.GetValueForExpressionPath("->den"))
- elif flType == RUBY_T_COMPLEX:
- tRComplex = target.FindFirstType("struct RComplex").GetPointerType()
- val = val.Cast(tRComplex)
- lldb_inspect(debugger, target, result, val.GetValueForExpressionPath("->real"))
- real = result.GetOutput().rstrip()
- result.Clear()
- lldb_inspect(debugger, target, result, val.GetValueForExpressionPath("->imag"))
- imag = result.GetOutput().rstrip()
- result.Clear()
- if not imag.startswith("-"):
- imag = "+" + imag
- print("(Complex) " + real + imag + "i", file=result)
- elif flType == RUBY_T_REGEXP:
- tRRegex = target.FindFirstType("struct RRegexp").GetPointerType()
- val = val.Cast(tRRegex)
- print("(Regex) ->src {", file=result)
- lldb_inspect(debugger, target, result, val.GetValueForExpressionPath("->src"))
- print("}", file=result)
- elif flType == RUBY_T_DATA:
- tRTypedData = target.FindFirstType("struct RTypedData").GetPointerType()
- val = val.Cast(tRTypedData)
- flag = val.GetValueForExpressionPath("->typed_flag")
- if flag.GetValueAsUnsigned() == 1:
- print("T_DATA: %s" % val.GetValueForExpressionPath("->type->wrap_struct_name"), file=result)
- append_command_output(debugger, "p *(struct RTypedData *) %0#x" % val.GetValueAsUnsigned(), result)
- else:
- print("T_DATA:", file=result)
- append_command_output(debugger, "p *(struct RData *) %0#x" % val.GetValueAsUnsigned(), result)
- elif flType == RUBY_T_NODE:
- tRTypedData = target.FindFirstType("struct RNode").GetPointerType()
- nd_type = (flags & RUBY_NODE_TYPEMASK) >> RUBY_NODE_TYPESHIFT
- append_command_output(debugger, "p (node_type) %d" % nd_type, result)
- val = val.Cast(tRTypedData)
- append_command_output(debugger, "p *(struct RNode *) %0#x" % val.GetValueAsUnsigned(), result)
- else:
- print("Not-handled type %0#x" % flType, file=result)
- print(val, file=result)
+ print >> result, "T_ARRAY: len=%d " % len
+ #print >> result, val.GetValueForExpressionPath("->as.heap")
+ if flags & RUBY_FL_USER2:
+ shared = val.GetValueForExpressionPath("->as.heap.aux.shared").GetValueAsUnsigned()
+ print >> result, "(shared) shared=%016x " % shared
+ else:
+ capa = val.GetValueForExpressionPath("->as.heap.aux.capa").GetValueAsSigned()
+ print >> result, "(ownership) capa=%d " % capa
+ if len == 0:
+ print >> result, "{(empty)}"
+ else:
+ debugger.HandleCommand("expression -Z %d -fx -- (const VALUE*)((struct RArray*)%d)->as.heap.ptr" % (len, val.GetValueAsUnsigned()))
+ debugger.HandleCommand("p (struct RArray *) %0#x" % val.GetValueAsUnsigned())
def count_objects(debugger, command, ctx, result, internal_dict):
objspace = ctx.frame.EvaluateExpression("ruby_current_vm->objspace")
@@ -243,7 +141,7 @@ def count_objects(debugger, command, ctx, result, internal_dict):
counts[t] = 0
for i in range(0, num_pages):
- print("\rcounting... %d/%d" % (i, num_pages), end="")
+ print "\rcounting... %d/%d" % (i, num_pages),
page = objspace.GetValueForExpressionPath('.heap_pages.sorted[%d]' % i)
p = page.GetChildMemberWithName('start')
num_slots = page.GetChildMemberWithName('total_slots').unsigned
@@ -254,9 +152,9 @@ def count_objects(debugger, command, ctx, result, internal_dict):
counts[obj_type] += 1
total += num_slots
- print("\rTOTAL: %d, FREE: %d" % (total, counts[0x00]))
+ print "\rTOTAL: %d, FREE: %d" % (total, counts[0x00])
for sym in value_types:
- print("%s: %d" % (sym, counts[globals()[sym]]))
+ print "%s: %d" % (sym, counts[globals()[sym]])
def stack_dump_raw(debugger, command, ctx, result, internal_dict):
ctx.frame.EvaluateExpression("rb_vmdebug_stack_dump_raw_current()")
@@ -268,7 +166,7 @@ def dump_node(debugger, command, ctx, result, internal_dict):
node = args[0]
dump = ctx.frame.EvaluateExpression("(struct RString*)rb_parser_dump_tree((NODE*)(%s), 0)" % node)
- output_string(ctx, result, dump)
+ output_string(ctx, dump)
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("command script add -f lldb_cruby.lldb_rp rp")
@@ -276,4 +174,4 @@ def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("command script add -f lldb_cruby.stack_dump_raw SDR")
debugger.HandleCommand("command script add -f lldb_cruby.dump_node dump_node")
lldb_init(debugger)
- print("lldb scripts for ruby has been installed.")
+ print "lldb scripts for ruby has been installed."
diff --git a/misc/rb_optparse.zsh b/misc/rb_optparse.zsh
index 7407e87c03..d53170c5f7 100755
--- a/misc/rb_optparse.zsh
+++ b/misc/rb_optparse.zsh
@@ -13,7 +13,7 @@
#
# (3) restart zsh.
#
-# (4) generate completion files once.
+# (4) geneate completion files once.
# generate-complete-function/ruby/optparse COMMAND1
# generate-complete-function/ruby/optparse COMMAND2
#
diff --git a/misc/rdoc-mode.el b/misc/rdoc-mode.el
new file mode 100644
index 0000000000..c26c2ee564
--- /dev/null
+++ b/misc/rdoc-mode.el
@@ -0,0 +1,166 @@
+;;
+;; rdoc-mode.el
+;; Major mode for RDoc editing
+;;
+
+;; Created: Fri Sep 18 09:04:49 JST 2009
+
+;; License: Ruby's
+
+(require 'derived)
+
+;;;###autoload
+(define-derived-mode rdoc-mode text-mode "RDoc"
+ "Major mode for RD editing.
+\\{rdoc-mode-map}"
+ (make-local-variable 'paragraph-separate)
+ (setq paragraph-separate "^\\(=+\\|\\*+\\)[ \t\v\f]*\\|^\\s *$")
+ (make-local-variable 'paragraph-start)
+ (setq paragraph-start paragraph-separate)
+ (make-local-variable 'require-final-newline)
+ (setq require-final-newline t)
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults '((rdoc-font-lock-keywords) t nil))
+ (make-local-variable 'font-lock-keywords)
+ (setq font-lock-keywords rdoc-font-lock-keywords)
+ (make-local-variable 'outline-regexp)
+ (setq outline-regexp "^\\(=+\\)[ \t\v\f]*")
+ (outline-minor-mode t)
+ (setq show-trailing-whitespace t)
+ (rdoc-setup-keys)
+ (setq indent-tabs-mode nil)
+ (run-hooks 'rdoc-mode-hook)
+ )
+
+(defun rdoc-fill-paragraph (&optional justify region)
+ "Fills paragraph, except for cited region"
+ (interactive (progn
+ (barf-if-buffer-read-only)
+ (list (if current-prefix-arg 'full))))
+ (save-excursion
+ (beginning-of-line)
+ (save-restriction
+ (let ((pos (point)) beg end indent hanging)
+ (cond
+ ((looking-at "^ +\\(\\*\\s *\\)")
+ (setq indent (- (match-end 0) (match-beginning 0))
+ hanging (- (match-end 1) (match-beginning 1))))
+ ((looking-at "^ +")
+ (setq indent (- (match-end 0) (match-beginning 0)))
+ (when (and (re-search-backward "^[^ ]\\|^\\( *\\(\\* *\\)\\)" nil t)
+ (match-beginning 1)
+ (= indent (- (match-end 1) (match-beginning 1))))
+ (setq hanging (- (match-end 2) (match-beginning 2)))
+ (setq beg (match-beginning 1))))
+ ((setq beg t)))
+ (when beg
+ (when indent
+ (goto-char pos)
+ (while (progn (beginning-of-line 2)
+ (and (looking-at "^\\( +\\)\\S ")
+ (= indent (- (match-end 1) (match-beginning 1))))))
+ (setq end (point))
+ (when (and beg (not region))
+ (setq region (list beg end))
+ (narrow-to-region beg end)
+ ))
+ (goto-char pos)
+ (fill-paragraph justify region)
+ (when (and indent
+ (or (goto-char beg) t)
+ (or (beginning-of-line 2) t)
+ (looking-at "^\\( +\\)")
+ (= (- indent hanging) (- (match-end 0) (match-beginning 0))))
+ (insert-char ?\s hanging)
+ (beginning-of-line)
+ (narrow-to-region (point) end)
+ (fill-paragraph justify (list (point) end))))))))
+
+(defun rdoc-setup-keys ()
+ (interactive)
+ (define-key rdoc-mode-map "\M-q" 'rdoc-fill-paragraph)
+ )
+
+(defvar rdoc-heading1-face 'font-lock-keywordoc-face)
+(defvar rdoc-heading2-face 'font-lock-type-face)
+(defvar rdoc-heading3-face 'font-lock-variable-name-face)
+(defvar rdoc-heading4-face 'font-lock-comment-face)
+(defvar rdoc-bold-face 'font-lock-function-name-face)
+(defvar rdoc-emphasis-face 'font-lock-function-name-face)
+(defvar rdoc-code-face 'font-lock-keyword-face)
+(defvar rdoc-description-face 'font-lock-constant-face)
+
+(defvar rdoc-font-lock-keywords
+ (list
+ (list "^=([^=\r\n].*)?$"
+ 0 rdoc-heading1-face)
+ (list "^==([^=\r\n].*)?$"
+ 0 rdoc-heading2-face)
+ (list "^===([^=\r\n].*)?$"
+ 0 rdoc-heading3-face)
+ (list "^====+.*$"
+ 0 rdoc-heading4-face)
+ (list "\\(^\\|[ \t\v\f]\\)\\(\\*\\(\\sw\\|[-_:]\\)+\\*\\)\\($\\|[ \t\v\f]\\)"
+ 2 rdoc-bold-face) ; *bold*
+ (list "\\(^\\|[ \t\v\f]\\)\\(_\\(\\sw\\|[-_:]\\)+_\\)\\($\\|[ \t\v\f]\\)"
+ 2 rdoc-emphasis-face) ; _emphasis_
+ (list "\\(^\\|[ \t\v\f]\\)\\(\\+\\(\\sw\\|[-_:]\\)+\\+\\)\\($\\|[ \t\v\f]\\)"
+ 2 rdoc-code-face) ; +code+
+ (list "<em>[^<>]*</em>" 0 rdoc-emphasis-face)
+ (list "<i>[^<>]*</i>" 0 rdoc-emphasis-face)
+ (list "<b>[^<>]*</b>" 0 rdoc-bold-face)
+ (list "<tt>[^<>]*</tt>" 0 rdoc-code-face)
+ (list "<code>[^<>]*</code>" 0 rdoc-code-face)
+ (list "^\\([-*]\\|[0-9]+\\.\\|[A-Za-z]\\.\\)\\s "
+ 1 rdoc-description-face) ; bullet | numbered | alphabetically numbered
+ (list "^\\[[^\]]*\\]\\|\\S .*::\\)\\([ \t\v\f]\\|$\\)"
+ 1 rdoc-description-face) ; labeled | node
+ ;(list "^[ \t\v\f]+\\(.*\\)" 1 rdoc-verbatim-face)
+ ))
+
+(defun rdoc-imenu-create-index ()
+ (let ((root '(nil . nil))
+ cur-alist
+ (cur-level 0)
+ (pattern (concat outline-regexp "\\(.*?\\)[ \t\v\f]*$"))
+ (empty-heading "-")
+ (self-heading ".")
+ pos level heading alist)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward pattern (point-max) t)
+ (setq heading (match-string-no-properties 2)
+ level (min 6 (length (match-string-no-properties 1)))
+ pos (match-beginning 1))
+ (if (= (length heading) 0)
+ (setq heading empty-heading))
+ (setq alist (list (cons heading pos)))
+ (cond
+ ((= cur-level level) ; new sibling
+ (setcdr cur-alist alist)
+ (setq cur-alist alist))
+ ((< cur-level level) ; first child
+ (dotimes (i (- level cur-level 1))
+ (setq alist (list (cons empty-heading alist))))
+ (if cur-alist
+ (let* ((parent (car cur-alist))
+ (self-pos (cdr parent)))
+ (setcdr parent (cons (cons self-heading self-pos) alist)))
+ (setcdr root alist)) ; primogenitor
+ (setq cur-alist alist
+ cur-level level))
+ (t ; new sibling of an ancestor
+ (let ((sibling-alist (last (cdr root))))
+ (dotimes (i (1- level))
+ (setq sibling-alist (last (cdar sibling-alist))))
+ (setcdr sibling-alist alist)
+ (setq cur-alist alist
+ cur-level level))))))
+ (cdr root)))
+
+(defun rdoc-set-imenu-create-index-function ()
+ (setq imenu-create-index-function 'rdoc-imenu-create-index))
+
+(add-hook 'rdoc-mode-hook 'rdoc-set-imenu-create-index-function)
+
+(provide 'rdoc-mode)
diff --git a/misc/ruby-additional.el b/misc/ruby-additional.el
new file mode 100644
index 0000000000..432adfedb6
--- /dev/null
+++ b/misc/ruby-additional.el
@@ -0,0 +1,181 @@
+;;; ruby-additional.el --- ruby-mode extensions yet to be merged into Emacs
+
+;; Authors: Yukihiro Matsumoto, Nobuyoshi Nakada, Akinori MUSHA
+;; URL: https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/misc/
+;; Created: 3 Sep 2012
+;; Package-Requires: ((emacs "24.3") (ruby-mode "1.2"))
+;; Keywords: ruby, languages
+
+;;; Commentary:
+;;
+;; This package contains ruby-mode extensions yet to be merged into
+;; the latest released version of Emacs distribution. For older
+;; versions of Emacs, use ruby-mode.el bundled with CRuby.
+
+;;; Code:
+
+(eval-when-compile
+ (require 'ruby-mode))
+
+(eval-after-load 'ruby-mode
+ '(progn
+ (define-key ruby-mode-map "\C-c\C-e" 'ruby-insert-end)
+
+ (defun ruby-insert-end ()
+ (interactive)
+ (if (eq (char-syntax (preceding-char)) ?w)
+ (insert " "))
+ (insert "end")
+ (save-excursion
+ (if (eq (char-syntax (following-char)) ?w)
+ (insert " "))
+ (ruby-indent-line t)
+ (end-of-line)))
+
+ (defconst ruby-default-encoding-map
+ '((us-ascii . nil) ;; Do not put coding: us-ascii
+ (utf-8 . nil) ;; Do not put coding: utf-8
+ (shift-jis . cp932) ;; Emacs charset name of Shift_JIS
+ (shift_jis . cp932) ;; MIME charset name of Shift_JIS
+ (japanese-cp932 . cp932)) ;; Emacs charset name of CP932
+ )
+
+ (custom-set-default 'ruby-encoding-map ruby-default-encoding-map)
+
+ (defcustom ruby-encoding-map ruby-default-encoding-map
+ "Alist to map encoding name from Emacs to Ruby.
+Associating an encoding name with nil means it needs not be
+explicitly declared in magic comment."
+ :type '(repeat (cons (symbol :tag "From") (symbol :tag "To")))
+ :group 'ruby)
+
+ (defun ruby-mode-set-encoding ()
+ "Insert or update a magic comment header with the proper encoding.
+`ruby-encoding-map' is looked up to convert an encoding name from
+Emacs to Ruby."
+ (let* ((nonascii
+ (save-excursion
+ (widen)
+ (goto-char (point-min))
+ (re-search-forward "[^\0-\177]" nil t)))
+ (coding-system
+ (or coding-system-for-write
+ buffer-file-coding-system))
+ (coding-system
+ (and coding-system
+ (coding-system-change-eol-conversion coding-system nil)))
+ (coding-system
+ (and coding-system
+ (or
+ (coding-system-get coding-system :mime-charset)
+ (let ((coding-type (coding-system-get coding-system :coding-type)))
+ (cond ((eq coding-type 'undecided)
+ (if nonascii
+ (or (and (coding-system-get coding-system :prefer-utf-8)
+ 'utf-8)
+ (coding-system-get default-buffer-file-coding-system :coding-type)
+ 'ascii-8bit)))
+ ((memq coding-type '(utf-8 shift-jis))
+ coding-type)
+ (t coding-system))))))
+ (coding-system
+ (or coding-system
+ 'us-ascii))
+ (coding-system
+ (let ((cons (assq coding-system ruby-encoding-map)))
+ (if cons (cdr cons) coding-system)))
+ (coding-system
+ (and coding-system
+ (symbol-name coding-system))))
+ (if coding-system
+ (save-excursion
+ (widen)
+ (goto-char (point-min))
+ (if (looking-at "^#!") (beginning-of-line 2))
+ (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
+ (unless (string= (match-string 2) coding-system)
+ (goto-char (match-beginning 2))
+ (delete-region (point) (match-end 2))
+ (and (looking-at "-\*-")
+ (let ((n (skip-chars-backward " ")))
+ (cond ((= n 0) (insert " ") (backward-char))
+ ((= n -1) (insert " "))
+ ((forward-char)))))
+ (insert coding-system)))
+ ((looking-at "\\s *#.*coding\\s *[:=]"))
+ (t (when ruby-insert-encoding-magic-comment
+ (insert "# -*- coding: " coding-system " -*-\n"))))))))
+
+ (define-key ruby-mode-map "\C-cU" 'ruby-encode-decode-unicode)
+
+ (defun ruby-encode-unicode (beg end)
+ "Convert non-ascii string in the given region to \\u{} form."
+ (interactive "r")
+ (setq end (set-marker (make-marker) end))
+ (goto-char beg)
+ (while (and (< (point) end)
+ (re-search-forward "\\([\C-@-\C-I\C-K\C-_\C-?]+\\)\\|[^\C-@-\C-?]+" end t))
+ (let ((str (match-string-no-properties 0)) sep b e f)
+ (if (match-beginning 1)
+ (setq b "" e "" sep ""
+ f (lambda (c)
+ (cond ((= c ?\t) "\\t")
+ ((= c ?\r) "\\r")
+ ((= c ?\e) "\\e")
+ ((= c ?\f) "\\f")
+ ((= c ?\b) "\\b")
+ ((= c ?\v) "\\v")
+ ((= c ?\C-?) "\\c?")
+ ((concat "\\c" (char-to-string (logior c #x40)))))))
+ (setq b "\\u{" e "}" sep " " f (lambda (c) (format "%x" c))))
+ (setq str (mapconcat f str sep))
+ (delete-region (match-beginning 0) (match-end 0))
+ (insert b str e))))
+
+ (defun ruby-decode-unicode (beg end)
+ "Convert escaped Unicode in the given region to raw string."
+ (interactive "r")
+ (setq end (set-marker (make-marker) end))
+ (goto-char beg)
+ (while (and (< (point) end)
+ (re-search-forward "\\\\u\\([0-9a-fA-F]\\{4\\}\\)\\|\\\\u{\\([0-9a-fA-F \t]+\\)}" end t))
+ (let ((b (match-beginning 0)) (e (match-end 0))
+ (s (match-string-no-properties 1)))
+ (if s
+ (setq s (cons s nil))
+ (goto-char (match-beginning 2))
+ (while (looking-at "[ \t]*\\([0-9a-fA-F]+\\)")
+ (setq s (cons (match-string-no-properties 1) s))
+ (goto-char (match-end 0))))
+ (setq s (mapconcat (lambda (c) (format "%c" (string-to-int c 16)))
+ (nreverse s) ""))
+ (delete-region b e)
+ (insert s))
+ ))
+
+ (defun ruby-encode-decode-unicode (dec beg end)
+ "Convert Unicode <-> \\u{} in the given region."
+ (interactive "P\nr")
+ (if dec (ruby-decode-unicode beg end) (ruby-encode-unicode beg end)))
+
+ (defun ruby-insert-heredoc-code-block (arg)
+ "Insert indented here document code block"
+ (interactive "P")
+ (let ((c (if arg "~" "-")))
+ (insert "\"#{<<" c "\"{#\"}\\n#{<<" c "'};'}\""))
+ (end-of-line)
+ (if (eobp) (insert "\n") (forward-char))
+ (indent-region (point)
+ (progn (insert "{#\n" "};\n") (point)))
+ (beginning-of-line 0))
+ (define-key ruby-mode-map "\C-cH" 'ruby-insert-heredoc-code-block)
+ ))
+
+;; monkey-patching ruby-mode.el in Emacs 24, as r49872.
+(when (and (boundp 'ruby-syntax-before-regexp-re)
+ (not (string-match ruby-syntax-before-regexp-re "foo {|" 1)))
+ (replace-regexp-in-string "\\[\\[" "\\&{|" ruby-syntax-before-regexp-re))
+
+(provide 'ruby-additional)
+
+;;; ruby-additional.el ends here
diff --git a/misc/ruby-electric.el b/misc/ruby-electric.el
new file mode 100644
index 0000000000..61e84d2adb
--- /dev/null
+++ b/misc/ruby-electric.el
@@ -0,0 +1,583 @@
+;;; ruby-electric.el --- Minor mode for electrically editing ruby code
+;;
+;; Authors: Dee Zsombor <dee dot zsombor at gmail dot com>
+;; Yukihiro Matsumoto
+;; Nobuyoshi Nakada
+;; Akinori MUSHA <knu@iDaemons.org>
+;; Jakub Kuźma <qoobaa@gmail.com>
+;; Maintainer: Akinori MUSHA <knu@iDaemons.org>
+;; Created: 6 Mar 2005
+;; URL: https://github.com/knu/ruby-electric.el
+;; Keywords: languages ruby
+;; License: The same license terms as Ruby
+;; Version: 2.3.1
+
+;;; Commentary:
+;;
+;; `ruby-electric-mode' accelerates code writing in ruby by making
+;; some keys "electric" and automatically supplying with closing
+;; parentheses and "end" as appropriate.
+;;
+;; This work was originally inspired by a code snippet posted by
+;; [Frederick Ros](https://github.com/sleeper).
+;;
+;; Add the following line to enable ruby-electric-mode under
+;; ruby-mode.
+;;
+;; (eval-after-load "ruby-mode"
+;; '(add-hook 'ruby-mode-hook 'ruby-electric-mode))
+;;
+;; Type M-x customize-group ruby-electric for configuration.
+
+;;; Code:
+
+(require 'ruby-mode)
+
+(eval-when-compile
+ (require 'cl))
+
+(defgroup ruby-electric nil
+ "Minor mode providing electric editing commands for ruby files"
+ :group 'ruby)
+
+(defconst ruby-electric-expandable-bar-re
+ "\\s-\\(do\\|{\\)\\s-*|")
+
+(defconst ruby-electric-delimiters-alist
+ '((?\{ :name "Curly brace" :handler ruby-electric-curlies :closing ?\})
+ (?\[ :name "Square brace" :handler ruby-electric-matching-char :closing ?\])
+ (?\( :name "Round brace" :handler ruby-electric-matching-char :closing ?\))
+ (?\' :name "Quote" :handler ruby-electric-matching-char)
+ (?\" :name "Double quote" :handler ruby-electric-matching-char)
+ (?\` :name "Back quote" :handler ruby-electric-matching-char)
+ (?\| :name "Vertical bar" :handler ruby-electric-bar)
+ (?\# :name "Hash" :handler ruby-electric-hash)))
+
+(defvar ruby-electric-matching-delimeter-alist
+ (apply 'nconc
+ (mapcar #'(lambda (x)
+ (let ((delim (car x))
+ (plist (cdr x)))
+ (if (eq (plist-get plist :handler) 'ruby-electric-matching-char)
+ (list (cons delim (or (plist-get plist :closing)
+ delim))))))
+ ruby-electric-delimiters-alist)))
+
+(defvar ruby-electric-expandable-keyword-re)
+
+(defmacro ruby-electric--try-insert-and-do (string &rest body)
+ (declare (indent 1))
+ `(let ((before (point))
+ (after (progn
+ (insert ,string)
+ (point))))
+ (unwind-protect
+ (progn ,@body)
+ (delete-region before after)
+ (goto-char before))))
+
+(defconst ruby-modifier-beg-symbol-re
+ (regexp-opt ruby-modifier-beg-keywords 'symbols))
+
+(defun ruby-electric--modifier-keyword-at-point-p ()
+ "Test if there is a modifier keyword at point."
+ (and (looking-at ruby-modifier-beg-symbol-re)
+ (let ((end (match-end 1)))
+ (not (looking-back "\\."))
+ (save-excursion
+ (let ((indent1 (ruby-electric--try-insert-and-do "\n"
+ (ruby-calculate-indent)))
+ (indent2 (save-excursion
+ (goto-char end)
+ (ruby-electric--try-insert-and-do " x\n"
+ (ruby-calculate-indent)))))
+ (= indent1 indent2))))))
+
+(defconst ruby-block-mid-symbol-re
+ (regexp-opt ruby-block-mid-keywords 'symbols))
+
+(defun ruby-electric--block-mid-keyword-at-point-p ()
+ "Test if there is a block mid keyword at point."
+ (and (looking-at ruby-block-mid-symbol-re)
+ (looking-back "^\\s-*")))
+
+(defconst ruby-block-beg-symbol-re
+ (regexp-opt ruby-block-beg-keywords 'symbols))
+
+(defun ruby-electric--block-beg-keyword-at-point-p ()
+ "Test if there is a block beginning keyword at point."
+ (and (looking-at ruby-block-beg-symbol-re)
+ (if (string= (match-string 1) "do")
+ (looking-back "\\s-")
+ (not (looking-back "\\.")))
+ ;; (not (ruby-electric--modifier-keyword-at-point-p)) ;; implicit assumption
+ ))
+
+(defcustom ruby-electric-keywords-alist
+ '(("begin" . end)
+ ("case" . end)
+ ("class" . end)
+ ("def" . end)
+ ("do" . end)
+ ("else" . reindent)
+ ("elsif" . reindent)
+ ("end" . reindent)
+ ("ensure" . reindent)
+ ("for" . end)
+ ("if" . end)
+ ("module" . end)
+ ("rescue" . reindent)
+ ("unless" . end)
+ ("until" . end)
+ ("when" . reindent)
+ ("while" . end))
+ "Alist of keywords and actions to define how to react to space
+or return right after each keyword. In each (KEYWORD . ACTION)
+cons, ACTION can be set to one of the following values:
+
+ `reindent' Reindent the line.
+
+ `end' Reindent the line and auto-close the keyword with
+ end if applicable.
+
+ `nil' Do nothing.
+"
+ :type '(repeat (cons (string :tag "Keyword")
+ (choice :tag "Action"
+ :menu-tag "Action"
+ (const :tag "Auto-close with end"
+ :value end)
+ (const :tag "Auto-reindent"
+ :value reindent)
+ (const :tag "None"
+ :value nil))))
+ :set (lambda (sym val)
+ (set sym val)
+ (let (keywords)
+ (dolist (x val)
+ (let ((keyword (car x))
+ (action (cdr x)))
+ (if action
+ (setq keywords (cons keyword keywords)))))
+ (setq ruby-electric-expandable-keyword-re
+ (concat (regexp-opt keywords 'symbols)
+ "$"))))
+ :group 'ruby-electric)
+
+(defvar ruby-electric-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map " " 'ruby-electric-space/return)
+ (define-key map [remap delete-backward-char] 'ruby-electric-delete-backward-char)
+ (define-key map [remap newline] 'ruby-electric-space/return)
+ (define-key map [remap newline-and-indent] 'ruby-electric-space/return)
+ (define-key map [remap electric-newline-and-maybe-indent] 'ruby-electric-space/return)
+ (define-key map [remap reindent-then-newline-and-indent] 'ruby-electric-space/return)
+ (dolist (x ruby-electric-delimiters-alist)
+ (let* ((delim (car x))
+ (plist (cdr x))
+ (name (plist-get plist :name))
+ (func (plist-get plist :handler))
+ (closing (plist-get plist :closing)))
+ (define-key map (char-to-string delim) func)
+ (if closing
+ (define-key map (char-to-string closing) 'ruby-electric-closing-char))))
+ map)
+ "Keymap used in ruby-electric-mode")
+
+(defcustom ruby-electric-expand-delimiters-list '(all)
+ "*List of contexts where matching delimiter should be inserted.
+The word 'all' will do all insertions."
+ :type `(set :extra-offset 8
+ (const :tag "Everything" all)
+ ,@(apply 'list
+ (mapcar #'(lambda (x)
+ `(const :tag ,(plist-get (cdr x) :name)
+ ,(car x)))
+ ruby-electric-delimiters-alist)))
+ :group 'ruby-electric)
+
+(defcustom ruby-electric-newline-before-closing-bracket nil
+ "*Non-nil means a newline should be inserted before an
+automatically inserted closing bracket."
+ :type 'boolean :group 'ruby-electric)
+
+(defcustom ruby-electric-autoindent-on-closing-char nil
+ "*Non-nil means the current line should be automatically
+indented when a closing character is manually typed in."
+ :type 'boolean :group 'ruby-electric)
+
+(defvar ruby-electric-mode-hook nil
+ "Called after `ruby-electric-mode' is turned on.")
+
+;;;###autoload
+(define-minor-mode ruby-electric-mode
+ "Toggle Ruby Electric minor mode.
+With no argument, this command toggles the mode. Non-null prefix
+argument turns on the mode. Null prefix argument turns off the
+mode.
+
+When Ruby Electric mode is enabled, an indented 'end' is
+heuristicaly inserted whenever typing a word like 'module',
+'class', 'def', 'if', 'unless', 'case', 'until', 'for', 'begin',
+'do' followed by a space. Single, double and back quotes as well
+as braces are paired auto-magically. Expansion does not occur
+inside comments and strings. Note that you must have Font Lock
+enabled."
+ ;; initial value.
+ nil
+ ;;indicator for the mode line.
+ " REl"
+ ;;keymap
+ ruby-electric-mode-map
+ (if ruby-electric-mode
+ (run-hooks 'ruby-electric-mode-hook)))
+
+(defun ruby-electric-space/return-fallback ()
+ (if (or (eq this-original-command 'ruby-electric-space/return)
+ (null (ignore-errors
+ ;; ac-complete may fail if there is nothing left to complete
+ (call-interactively this-original-command)
+ (setq this-command this-original-command))))
+ ;; fall back to a globally bound command
+ (let ((command (global-key-binding (char-to-string last-command-event) t)))
+ (and command
+ (call-interactively (setq this-command command))))))
+
+(defun ruby-electric-space/return (arg)
+ (interactive "*P")
+ (and (boundp 'sp-last-operation)
+ (setq sp-delayed-pair nil))
+ (cond ((or arg
+ (region-active-p))
+ (or (= last-command-event ?\s)
+ (setq last-command-event ?\n))
+ (ruby-electric-replace-region-or-insert))
+ ((ruby-electric-space/return-can-be-expanded-p)
+ (let (action)
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (let* ((keyword (match-string 1))
+ (allowed-actions
+ (cond ((ruby-electric--modifier-keyword-at-point-p)
+ '(reindent)) ;; no end necessary
+ ((ruby-electric--block-mid-keyword-at-point-p)
+ '(reindent)) ;; ditto
+ ((ruby-electric--block-beg-keyword-at-point-p)
+ '(end reindent)))))
+ (if allowed-actions
+ (setq action
+ (let ((action (cdr (assoc keyword ruby-electric-keywords-alist))))
+ (and (memq action allowed-actions)
+ action))))))
+ (cond ((eq action 'end)
+ (ruby-indent-line)
+ (save-excursion
+ (newline)
+ (ruby-electric-end)))
+ ((eq action 'reindent)
+ (ruby-indent-line)))
+ (ruby-electric-space/return-fallback)))
+ ((and (eq this-original-command 'newline-and-indent)
+ (ruby-electric-comment-at-point-p))
+ (call-interactively (setq this-command 'comment-indent-new-line)))
+ (t
+ (ruby-electric-space/return-fallback))))
+
+(defun ruby-electric--get-faces-at-point ()
+ (let* ((point (point))
+ (value (or
+ (get-text-property point 'read-face-name)
+ (get-text-property point 'face))))
+ (if (listp value) value (list value))))
+
+(defun ruby-electric--faces-include-p (pfaces &rest faces)
+ (and ruby-electric-mode
+ (loop for face in faces
+ thereis (memq face pfaces))))
+
+(defun ruby-electric--faces-at-point-include-p (&rest faces)
+ (apply 'ruby-electric--faces-include-p
+ (ruby-electric--get-faces-at-point)
+ faces))
+
+(defun ruby-electric-code-face-p (faces)
+ (not (ruby-electric--faces-include-p
+ faces
+ 'font-lock-string-face
+ 'font-lock-comment-face
+ 'enh-ruby-string-delimiter-face
+ 'enh-ruby-heredoc-delimiter-face
+ 'enh-ruby-regexp-delimiter-face
+ 'enh-ruby-regexp-face)))
+
+(defun ruby-electric-code-at-point-p ()
+ (ruby-electric-code-face-p
+ (ruby-electric--get-faces-at-point)))
+
+(defun ruby-electric-string-face-p (faces)
+ (ruby-electric--faces-include-p
+ faces
+ 'font-lock-string-face
+ 'enh-ruby-string-delimiter-face
+ 'enh-ruby-heredoc-delimiter-face
+ 'enh-ruby-regexp-delimiter-face
+ 'enh-ruby-regexp-face))
+
+(defun ruby-electric-string-at-point-p ()
+ (ruby-electric-string-face-p
+ (ruby-electric--get-faces-at-point)))
+
+(defun ruby-electric-comment-at-point-p ()
+ (ruby-electric--faces-at-point-include-p
+ 'font-lock-comment-face))
+
+(defun ruby-electric-escaped-p()
+ (let ((f nil))
+ (save-excursion
+ (while (char-equal ?\\ (preceding-char))
+ (backward-char 1)
+ (setq f (not f))))
+ f))
+
+(defun ruby-electric-command-char-expandable-punct-p(char)
+ (or (memq 'all ruby-electric-expand-delimiters-list)
+ (memq char ruby-electric-expand-delimiters-list)))
+
+(defun ruby-electric-space/return-can-be-expanded-p()
+ (and (ruby-electric-code-at-point-p)
+ (looking-back ruby-electric-expandable-keyword-re)))
+
+(defun ruby-electric-replace-region-or-insert ()
+ (and (region-active-p)
+ (bound-and-true-p delete-selection-mode)
+ (fboundp 'delete-selection-helper)
+ (delete-selection-helper (get 'self-insert-command 'delete-selection)))
+ (insert (make-string (prefix-numeric-value current-prefix-arg)
+ last-command-event))
+ (setq this-command 'self-insert-command))
+
+(defmacro ruby-electric-insert (arg &rest body)
+ `(cond ((and
+ (null ,arg)
+ (ruby-electric-command-char-expandable-punct-p last-command-event))
+ (let ((region-beginning
+ (cond ((region-active-p)
+ (prog1
+ (save-excursion
+ (goto-char (region-beginning))
+ (insert last-command-event)
+ (point))
+ (goto-char (region-end))))
+ (t
+ (insert last-command-event)
+ nil)))
+ (faces-at-point
+ (ruby-electric--get-faces-at-point)))
+ ,@body
+ (and region-beginning
+ ;; If no extra character is inserted, go back to the
+ ;; region beginning.
+ (eq this-command 'self-insert-command)
+ (goto-char region-beginning))))
+ ((ruby-electric-replace-region-or-insert))))
+
+(defun ruby-electric-curlies (arg)
+ (interactive "*P")
+ (ruby-electric-insert
+ arg
+ (cond
+ ((or (ruby-electric-code-at-point-p)
+ (ruby-electric--faces-include-p
+ faces-at-point
+ 'enh-ruby-string-delimiter-face
+ 'enh-ruby-regexp-delimiter-face))
+ (save-excursion
+ (insert "}")
+ (font-lock-fontify-region (line-beginning-position) (point)))
+ (cond
+ ((or (ruby-electric-string-at-point-p) ;; %w{}, %r{}, etc.
+ (looking-back "%[QqWwRrxIis]{"))
+ (if region-beginning
+ (forward-char 1)))
+ (ruby-electric-newline-before-closing-bracket
+ (cond (region-beginning
+ (save-excursion
+ (goto-char region-beginning)
+ (newline))
+ (newline)
+ (forward-char 1)
+ (indent-region region-beginning (line-end-position)))
+ (t
+ (insert " ")
+ (save-excursion
+ (newline)
+ (ruby-indent-line t)))))
+ (t
+ (if region-beginning
+ (save-excursion
+ (goto-char region-beginning)
+ (insert " "))
+ (insert " "))
+ (insert " ")
+ (backward-char 1)
+ (and region-beginning
+ (forward-char 1)))))
+ ((ruby-electric-string-at-point-p)
+ (let ((start-position (1- (or region-beginning (point)))))
+ (cond
+ ((char-equal ?\# (char-before start-position))
+ (unless (save-excursion
+ (goto-char (1- start-position))
+ (ruby-electric-escaped-p))
+ (insert "}")
+ (or region-beginning
+ (backward-char 1))))
+ ((or
+ (ruby-electric-command-char-expandable-punct-p ?\#)
+ (save-excursion
+ (goto-char start-position)
+ (ruby-electric-escaped-p)))
+ (if region-beginning
+ (goto-char region-beginning))
+ (setq this-command 'self-insert-command))
+ (t
+ (save-excursion
+ (goto-char start-position)
+ (insert "#"))
+ (insert "}")
+ (or region-beginning
+ (backward-char 1))))))
+ (t
+ (delete-char -1)
+ (ruby-electric-replace-region-or-insert)))))
+
+(defun ruby-electric-hash (arg)
+ (interactive "*P")
+ (ruby-electric-insert
+ arg
+ (if (ruby-electric-string-at-point-p)
+ (let ((start-position (1- (or region-beginning (point)))))
+ (cond
+ ((char-equal (following-char) ?')) ;; likely to be in ''
+ ((save-excursion
+ (goto-char start-position)
+ (ruby-electric-escaped-p)))
+ (region-beginning
+ (save-excursion
+ (goto-char (1+ start-position))
+ (insert "{"))
+ (insert "}"))
+ (t
+ (insert "{")
+ (save-excursion
+ (insert "}")))))
+ (delete-char -1)
+ (ruby-electric-replace-region-or-insert))))
+
+(defun ruby-electric-matching-char (arg)
+ (interactive "*P")
+ (ruby-electric-insert
+ arg
+ (let ((closing (cdr (assoc last-command-event
+ ruby-electric-matching-delimeter-alist))))
+ (cond
+ ;; quotes
+ ((char-equal closing last-command-event)
+ (cond ((not (ruby-electric-string-face-p faces-at-point))
+ (if region-beginning
+ ;; escape quotes of the same kind, backslash and hash
+ (let ((re (format "[%c\\%s]"
+ last-command-event
+ (if (char-equal last-command-event ?\")
+ "#" "")))
+ (bound (point)))
+ (save-excursion
+ (goto-char region-beginning)
+ (while (re-search-forward re bound t)
+ (let ((end (point)))
+ (replace-match "\\\\\\&")
+ (setq bound (+ bound (- (point) end))))))))
+ (insert closing)
+ (or region-beginning
+ (backward-char 1)))
+ (t
+ (and (eq last-command 'ruby-electric-matching-char)
+ (char-equal (following-char) closing) ;; repeated quotes
+ (delete-char 1))
+ (setq this-command 'self-insert-command))))
+ ((ruby-electric-code-at-point-p)
+ (insert closing)
+ (or region-beginning
+ (backward-char 1)))))))
+
+(defun ruby-electric-closing-char(arg)
+ (interactive "*P")
+ (cond
+ (arg
+ (ruby-electric-replace-region-or-insert))
+ ((and
+ (eq last-command 'ruby-electric-curlies)
+ (= last-command-event ?})
+ (not (char-equal (preceding-char) last-command-event))) ;; {}
+ (if (char-equal (following-char) ?\n) (delete-char 1))
+ (delete-horizontal-space)
+ (forward-char))
+ ((and
+ (= last-command-event (following-char))
+ (not (char-equal (preceding-char) last-command-event))
+ (memq last-command '(ruby-electric-matching-char
+ ruby-electric-closing-char))) ;; ()/[] and (())/[[]]
+ (forward-char))
+ (t
+ (ruby-electric-replace-region-or-insert)
+ (if ruby-electric-autoindent-on-closing-char
+ (ruby-indent-line)))))
+
+(defun ruby-electric-bar(arg)
+ (interactive "*P")
+ (ruby-electric-insert
+ arg
+ (cond ((and (ruby-electric-code-at-point-p)
+ (looking-back ruby-electric-expandable-bar-re))
+ (save-excursion (insert "|")))
+ (t
+ (delete-char -1)
+ (ruby-electric-replace-region-or-insert)))))
+
+(defun ruby-electric-delete-backward-char(arg)
+ (interactive "*p")
+ (cond ((memq last-command '(ruby-electric-matching-char
+ ruby-electric-bar))
+ (delete-char 1))
+ ((eq last-command 'ruby-electric-curlies)
+ (cond ((eolp)
+ (cond ((char-equal (preceding-char) ?\s)
+ (setq this-command last-command))
+ ((char-equal (preceding-char) ?{)
+ (and (looking-at "[ \t\n]*}")
+ (delete-char (- (match-end 0) (match-beginning 0)))))))
+ ((char-equal (following-char) ?\s)
+ (setq this-command last-command)
+ (delete-char 1))
+ ((char-equal (following-char) ?})
+ (delete-char 1))))
+ ((eq last-command 'ruby-electric-hash)
+ (and (char-equal (preceding-char) ?{)
+ (delete-char 1))))
+ (delete-char (- arg)))
+
+(put 'ruby-electric-delete-backward-char 'delete-selection 'supersede)
+
+(defun ruby-electric-end ()
+ (interactive)
+ (if (eq (char-syntax (preceding-char)) ?w)
+ (insert " "))
+ (insert "end")
+ (save-excursion
+ (if (eq (char-syntax (following-char)) ?w)
+ (insert " "))
+ (ruby-indent-line t)))
+
+(provide 'ruby-electric)
+
+;;; ruby-electric.el ends here
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
new file mode 100644
index 0000000000..b1abd18a9e
--- /dev/null
+++ b/misc/ruby-mode.el
@@ -0,0 +1,1584 @@
+;;; ruby-mode.el --- Major mode for editing Ruby files
+
+;; Copyright (C) 1994, 1995, 1996 1997, 1998, 1999, 2000, 2001,
+;; 2002,2003, 2004, 2005, 2006, 2007, 2008
+;; Free Software Foundation, Inc.
+
+;; Authors: Yukihiro Matsumoto, Nobuyoshi Nakada
+;; URL: http://www.emacswiki.org/cgi-bin/wiki/RubyMode
+;; Created: Fri Feb 4 14:49:13 JST 1994
+;; Keywords: languages ruby
+;; Version: 0.9
+
+;; This file is not part of GNU Emacs. However, a newer version of
+;; ruby-mode is included in recent releases of GNU Emacs (version 23
+;; and up), but the new version is not guaranteed to be compatible
+;; with older versions of Emacs or XEmacs. This file is the last
+;; version that aims to keep this compatibility.
+
+;; You can also get the latest version from the Emacs Lisp Package
+;; Archive: http://tromey.com/elpa
+
+;; This file is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; It is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+;; License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with it. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Provides font-locking, indentation support, and navigation for Ruby code.
+;;
+;; If you're installing manually, you should add this to your .emacs
+;; file after putting it on your load path:
+;;
+;; (autoload 'ruby-mode "ruby-mode" "Major mode for ruby files" t)
+;; (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
+;; (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
+;;
+
+;;; Code:
+
+(defconst ruby-mode-revision "$Revision$"
+ "Ruby mode revision string.")
+
+(defconst ruby-mode-version
+ (and (string-match "[0-9.]+" ruby-mode-revision)
+ (substring ruby-mode-revision (match-beginning 0) (match-end 0)))
+ "Ruby mode version number.")
+
+(defconst ruby-keyword-end-re
+ (if (string-match "\\_>" "ruby")
+ "\\_>"
+ "\\>"))
+
+(defconst ruby-block-beg-keywords
+ '("class" "module" "def" "if" "unless" "case" "while" "until" "for" "begin" "do")
+ "Keywords at the beginning of blocks.")
+
+(defconst ruby-block-beg-re
+ (regexp-opt ruby-block-beg-keywords)
+ "Regexp to match the beginning of blocks.")
+
+(defconst ruby-non-block-do-re
+ (concat (regexp-opt '("while" "until" "for" "rescue") t) ruby-keyword-end-re)
+ "Regexp to match")
+
+(defconst ruby-indent-beg-re
+ (concat "\\(\\s *" (regexp-opt '("class" "module" "def") t) "\\)\\|"
+ (regexp-opt '("if" "unless" "case" "while" "until" "for" "begin")))
+ "Regexp to match where the indentation gets deeper.")
+
+(defconst ruby-modifier-beg-keywords
+ '("if" "unless" "while" "until")
+ "Modifiers that are the same as the beginning of blocks.")
+
+(defconst ruby-modifier-beg-re
+ (regexp-opt ruby-modifier-beg-keywords)
+ "Regexp to match modifiers same as the beginning of blocks.")
+
+(defconst ruby-modifier-re
+ (regexp-opt (cons "rescue" ruby-modifier-beg-keywords))
+ "Regexp to match modifiers.")
+
+(defconst ruby-block-mid-keywords
+ '("then" "else" "elsif" "when" "rescue" "ensure")
+ "Keywords where the indentation gets shallower in middle of block statements.")
+
+(defconst ruby-block-mid-re
+ (regexp-opt ruby-block-mid-keywords)
+ "Regexp to match where the indentation gets shallower in middle of block statements.")
+
+(defconst ruby-block-op-keywords
+ '("and" "or" "not")
+ "Block operators.")
+
+(defconst ruby-block-hanging-re
+ (regexp-opt (append ruby-modifier-beg-keywords ruby-block-op-keywords))
+ "Regexp to match hanging block modifiers.")
+
+(defconst ruby-block-end-re "\\_<end\\_>")
+
+(defconst ruby-here-doc-beg-re
+ "\\(<\\)<\\([-~]\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)")
+
+(defconst ruby-here-doc-end-re
+ "^\\([ \t]+\\)?\\(.*\\)\\(.\\)$")
+
+(defun ruby-here-doc-end-match ()
+ (concat "^"
+ (if (match-string 2) "[ \t]*" nil)
+ (regexp-quote
+ (or (match-string 4)
+ (match-string 5)
+ (match-string 6)))))
+
+(defun ruby-here-doc-beg-match ()
+ (let ((contents (concat
+ (regexp-quote (concat (match-string 2) (match-string 3)))
+ (if (string= (match-string 3) "_") "\\B" "\\b"))))
+ (concat "<<"
+ (let ((match (match-string 1)))
+ (if (and match (> (length match) 0))
+ (concat "\\(?:[-~]\\([\"']?\\)\\|\\([\"']\\)" (match-string 1) "\\)"
+ contents "\\(\\1\\|\\2\\)")
+ (concat "[-~]?\\([\"']\\|\\)" contents "\\1"))))))
+
+(defconst ruby-delimiter
+ (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\_<\\("
+ ruby-block-beg-re
+ "\\)\\_>\\|" ruby-block-end-re
+ "\\|^=begin\\|" ruby-here-doc-beg-re)
+ )
+
+(defconst ruby-negative
+ (concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\>\\|"
+ ruby-block-end-re "\\|}\\|\\]\\)")
+ "Regexp to match where the indentation gets shallower.")
+
+(defconst ruby-operator-chars "-,.+*/%&|^~=<>:")
+(defconst ruby-operator-re (concat "[" ruby-operator-chars "]"))
+
+(defconst ruby-symbol-chars "a-zA-Z0-9_")
+(defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]"))
+
+(defvar ruby-mode-abbrev-table nil
+ "Abbrev table in use in ruby-mode buffers.")
+
+(define-abbrev-table 'ruby-mode-abbrev-table ())
+
+(defvar ruby-mode-map nil "Keymap used in ruby mode.")
+
+(if ruby-mode-map
+ nil
+ (setq ruby-mode-map (make-sparse-keymap))
+ (define-key ruby-mode-map "{" 'ruby-electric-brace)
+ (define-key ruby-mode-map "}" 'ruby-electric-brace)
+ (define-key ruby-mode-map "\e\C-a" 'ruby-beginning-of-defun)
+ (define-key ruby-mode-map "\e\C-e" 'ruby-end-of-defun)
+ (define-key ruby-mode-map "\e\C-b" 'ruby-backward-sexp)
+ (define-key ruby-mode-map "\e\C-f" 'ruby-forward-sexp)
+ (define-key ruby-mode-map "\e\C-p" 'ruby-beginning-of-block)
+ (define-key ruby-mode-map "\e\C-n" 'ruby-end-of-block)
+ (define-key ruby-mode-map "\e\C-h" 'ruby-mark-defun)
+ (define-key ruby-mode-map "\e\C-q" 'ruby-indent-exp)
+ (define-key ruby-mode-map "\t" 'ruby-indent-command)
+ (define-key ruby-mode-map "\C-c\C-e" 'ruby-insert-end)
+ (define-key ruby-mode-map "\C-j" 'ruby-reindent-then-newline-and-indent)
+ (define-key ruby-mode-map "\C-c{" 'ruby-toggle-block)
+ (define-key ruby-mode-map "\C-c\C-u" 'uncomment-region))
+
+(defvar ruby-mode-syntax-table nil
+ "Syntax table in use in ruby-mode buffers.")
+
+(if ruby-mode-syntax-table
+ ()
+ (setq ruby-mode-syntax-table (make-syntax-table))
+ (modify-syntax-entry ?\' "\"" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\" "\"" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\` "\"" ruby-mode-syntax-table)
+ (modify-syntax-entry ?# "<" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\n ">" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\\ "\\" ruby-mode-syntax-table)
+ (modify-syntax-entry ?$ "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?? "_" ruby-mode-syntax-table)
+ (modify-syntax-entry ?_ "_" ruby-mode-syntax-table)
+ (modify-syntax-entry ?: "_" ruby-mode-syntax-table)
+ (modify-syntax-entry ?< "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?> "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?& "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?| "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?% "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?= "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?/ "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?+ "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?* "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?- "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?\; "." ruby-mode-syntax-table)
+ (modify-syntax-entry ?\( "()" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\) ")(" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\{ "(}" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\} "){" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\[ "(]" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\] ")[" ruby-mode-syntax-table)
+ )
+
+(defcustom ruby-indent-tabs-mode nil
+ "*Indentation can insert tabs in ruby mode if this is non-nil."
+ :type 'boolean :group 'ruby)
+(put 'ruby-indent-tabs-mode 'safe-local-variable 'booleanp)
+
+(defcustom ruby-indent-level 2
+ "*Indentation of ruby statements."
+ :type 'integer :group 'ruby)
+(put 'ruby-indent-level 'safe-local-variable 'integerp)
+
+(defcustom ruby-comment-column 32
+ "*Indentation column of comments."
+ :type 'integer :group 'ruby)
+(put 'ruby-comment-column 'safe-local-variable 'integerp)
+
+(defcustom ruby-deep-arglist t
+ "*Deep indent lists in parenthesis when non-nil.
+Also ignores spaces after parenthesis when 'space."
+ :group 'ruby)
+(put 'ruby-deep-arglist 'safe-local-variable 'booleanp)
+
+(defcustom ruby-deep-indent-paren '(?\( ?\[ ?\] t)
+ "*Deep indent lists in parenthesis when non-nil. t means continuous line.
+Also ignores spaces after parenthesis when 'space."
+ :group 'ruby)
+
+(defcustom ruby-deep-indent-paren-style 'space
+ "Default deep indent style."
+ :options '(t nil space) :group 'ruby)
+
+(defcustom ruby-encoding-map
+ '((us-ascii . nil) ;; Do not put coding: us-ascii
+ (utf-8 . nil) ;; Do not put coding: utf-8
+ (shift-jis . cp932) ;; Emacs charset name of Shift_JIS
+ (shift_jis . cp932) ;; MIME charset name of Shift_JIS
+ (japanese-cp932 . cp932)) ;; Emacs charset name of CP932
+ "Alist to map encoding name from Emacs to Ruby.
+Associating an encoding name with nil means it needs not be
+explicitly declared in magic comment."
+ :type '(repeat (cons (symbol :tag "From") (symbol :tag "To")))
+ :group 'ruby)
+
+(defcustom ruby-use-encoding-map t
+ "*Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
+ :type 'boolean :group 'ruby)
+
+(defvar ruby-indent-point nil "internal variable")
+
+(eval-when-compile (require 'cl))
+(defun ruby-imenu-create-index-in-block (prefix beg end)
+ (let ((index-alist '()) (case-fold-search nil)
+ name next pos decl sing)
+ (goto-char beg)
+ (while (re-search-forward "^\\s *\\(\\(class\\s +\\|\\(class\\s *<<\\s *\\)\\|module\\s +\\)\\([^\(<\n ]+\\)\\|\\(def\\|alias\\)\\s +\\([^\(\n ]+\\)\\)" end t)
+ (setq sing (match-beginning 3))
+ (setq decl (match-string 5))
+ (setq next (match-end 0))
+ (setq name (or (match-string 4) (match-string 6)))
+ (setq pos (match-beginning 0))
+ (cond
+ ((string= "alias" decl)
+ (if prefix (setq name (concat prefix name)))
+ (push (cons name pos) index-alist))
+ ((string= "def" decl)
+ (if prefix
+ (setq name
+ (cond
+ ((string-match "^self\." name)
+ (concat (substring prefix 0 -1) (substring name 4)))
+ (t (concat prefix name)))))
+ (push (cons name pos) index-alist)
+ (ruby-accurate-end-of-block end))
+ (t
+ (if (string= "self" name)
+ (if prefix (setq name (substring prefix 0 -1)))
+ (if prefix (setq name (concat (substring prefix 0 -1) "::" name)))
+ (push (cons name pos) index-alist))
+ (ruby-accurate-end-of-block end)
+ (setq beg (point))
+ (setq index-alist
+ (nconc (ruby-imenu-create-index-in-block
+ (concat name (if sing "." "#"))
+ next beg) index-alist))
+ (goto-char beg))))
+ index-alist))
+
+(defun ruby-imenu-create-index ()
+ (nreverse (ruby-imenu-create-index-in-block nil (point-min) nil)))
+
+(defun ruby-accurate-end-of-block (&optional end)
+ (let (state)
+ (or end (setq end (point-max)))
+ (while (and (setq state (apply 'ruby-parse-partial end state))
+ (>= (nth 2 state) 0) (< (point) end)))))
+
+(defun ruby-mode-variables ()
+ (set-syntax-table ruby-mode-syntax-table)
+ (setq show-trailing-whitespace t)
+ (setq local-abbrev-table ruby-mode-abbrev-table)
+ (make-local-variable 'indent-line-function)
+ (setq indent-line-function 'ruby-indent-line)
+ (make-local-variable 'require-final-newline)
+ (setq require-final-newline t)
+ (make-local-variable 'comment-start)
+ (setq comment-start "# ")
+ (make-local-variable 'comment-end)
+ (setq comment-end "")
+ (make-local-variable 'comment-column)
+ (setq comment-column ruby-comment-column)
+ (make-local-variable 'comment-start-skip)
+ (setq comment-start-skip "#+ *")
+ (setq indent-tabs-mode ruby-indent-tabs-mode)
+ (make-local-variable 'parse-sexp-ignore-comments)
+ (setq parse-sexp-ignore-comments t)
+ (make-local-variable 'parse-sexp-lookup-properties)
+ (setq parse-sexp-lookup-properties t)
+ (make-local-variable 'paragraph-start)
+ (setq paragraph-start (concat "$\\|" page-delimiter))
+ (make-local-variable 'paragraph-separate)
+ (setq paragraph-separate paragraph-start)
+ (make-local-variable 'paragraph-ignore-fill-prefix)
+ (setq paragraph-ignore-fill-prefix t))
+
+(defun ruby-mode-set-encoding ()
+ "Insert or update a magic comment header with the proper encoding.
+`ruby-encoding-map' is looked up to convert an encoding name from
+Emacs to Ruby."
+ (let* ((nonascii
+ (save-excursion
+ (widen)
+ (goto-char (point-min))
+ (re-search-forward "[^\0-\177]" nil t)))
+ (coding-system
+ (or coding-system-for-write
+ buffer-file-coding-system))
+ (coding-system
+ (and coding-system
+ (coding-system-change-eol-conversion coding-system nil)))
+ (coding-system
+ (and coding-system
+ (or
+ (coding-system-get coding-system :mime-charset)
+ (let ((coding-type (coding-system-get coding-system :coding-type)))
+ (cond ((eq coding-type 'undecided)
+ (if nonascii
+ (or (and (coding-system-get coding-system :prefer-utf-8)
+ 'utf-8)
+ (coding-system-get default-buffer-file-coding-system :coding-type)
+ 'ascii-8bit)))
+ ((memq coding-type '(utf-8 shift-jis))
+ coding-type)
+ (t coding-system))))))
+ (coding-system
+ (or coding-system
+ 'us-ascii))
+ (coding-system
+ (let ((cons (assq coding-system ruby-encoding-map)))
+ (if cons (cdr cons) coding-system)))
+ (coding-system
+ (and coding-system
+ (symbol-name coding-system))))
+ (if coding-system
+ (save-excursion
+ (widen)
+ (goto-char (point-min))
+ (if (looking-at "^#!") (beginning-of-line 2))
+ (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
+ (unless (string= (match-string 2) coding-system)
+ (goto-char (match-beginning 2))
+ (delete-region (point) (match-end 2))
+ (and (looking-at "-\*-")
+ (let ((n (skip-chars-backward " ")))
+ (cond ((= n 0) (insert " ") (backward-char))
+ ((= n -1) (insert " "))
+ ((forward-char)))))
+ (insert coding-system)))
+ ((looking-at "\\s *#.*coding\\s *[:=]"))
+ (t (when ruby-insert-encoding-magic-comment
+ (insert "# -*- coding: " coding-system " -*-\n"))))))))
+
+(defun ruby-current-indentation ()
+ (save-excursion
+ (beginning-of-line)
+ (back-to-indentation)
+ (current-column)))
+
+(defun ruby-indent-line (&optional flag)
+ "Correct indentation of the current ruby line."
+ (ruby-indent-to (ruby-calculate-indent)))
+
+(defun ruby-indent-command ()
+ (interactive)
+ (ruby-indent-line t))
+
+(defun ruby-indent-to (x)
+ (if x
+ (let (shift top beg)
+ (and (< x 0) (error "invalid nest"))
+ (setq shift (current-column))
+ (beginning-of-line)
+ (setq beg (point))
+ (back-to-indentation)
+ (setq top (current-column))
+ (skip-chars-backward " \t")
+ (if (>= shift top) (setq shift (- shift top))
+ (setq shift 0))
+ (if (and (bolp)
+ (= x top))
+ (move-to-column (+ x shift))
+ (move-to-column top)
+ (delete-region beg (point))
+ (beginning-of-line)
+ (indent-to x)
+ (move-to-column (+ x shift))))))
+
+(defun ruby-special-char-p (&optional pnt)
+ (setq pnt (or pnt (point)))
+ (let ((c (char-before pnt)) (b (and (< (point-min) pnt) (char-before (1- pnt)))))
+ (cond ((or (eq c ??) (eq c ?$)))
+ ((and (eq c ?:) (or (not b) (eq (char-syntax b) ? ))))
+ ((eq c ?\\) (eq b ??)))))
+
+(defun ruby-singleton-class-p ()
+ (save-excursion
+ (forward-word -1)
+ (and (or (bolp) (not (eq (char-before (point)) ?_)))
+ (looking-at "class\\s *<<"))))
+
+(defun ruby-expr-beg (&optional option)
+ (save-excursion
+ (store-match-data nil)
+ (let ((space (skip-chars-backward " \t"))
+ (start (point)))
+ (cond
+ ((bolp) t)
+ ((progn
+ (forward-char -1)
+ (and (looking-at "\\?")
+ (or (eq (char-syntax (preceding-char)) ?w)
+ (ruby-special-char-p))))
+ nil)
+ ((and (eq option 'heredoc) (< space 0))
+ (not (progn (goto-char start) (ruby-singleton-class-p))))
+ ((or (looking-at ruby-operator-re)
+ (looking-at "[\\[({,;]")
+ (and (looking-at "[!?]")
+ (or (not (eq option 'modifier))
+ (bolp)
+ (save-excursion (forward-char -1) (looking-at "\\Sw$"))))
+ (and (looking-at ruby-symbol-re)
+ (skip-chars-backward ruby-symbol-chars)
+ (cond
+ ((looking-at (regexp-opt
+ (append ruby-block-beg-keywords
+ ruby-block-op-keywords
+ ruby-block-mid-keywords)
+ 'words))
+ (goto-char (match-end 0))
+ (not (looking-at "\\s_\\|[!?:]")))
+ ((eq option 'expr-qstr)
+ (looking-at "[a-zA-Z][a-zA-z0-9_]* +%[^ \t]"))
+ ((eq option 'expr-re)
+ (looking-at "[a-zA-Z][a-zA-z0-9_]* +/[^ \t]"))
+ (t nil)))))))))
+
+(defun ruby-forward-string (term &optional end no-error expand)
+ (let ((n 1) (c (string-to-char term))
+ (re (if expand
+ (concat "[^\\]\\(\\\\\\\\\\)*\\([" term "]\\|\\(#{\\)\\)")
+ (concat "[^\\]\\(\\\\\\\\\\)*[" term "]"))))
+ (while (and (re-search-forward re end no-error)
+ (if (match-beginning 3)
+ (ruby-forward-string "}{" end no-error nil)
+ (> (setq n (if (eq (char-before (point)) c)
+ (1- n) (1+ n))) 0)))
+ (forward-char -1))
+ (cond ((zerop n))
+ (no-error nil)
+ ((error "unterminated string")))))
+
+(defun ruby-deep-indent-paren-p (c &optional pos)
+ (cond ((save-excursion
+ (if pos (goto-char pos))
+ (ruby-expr-beg))
+ nil)
+ ((listp ruby-deep-indent-paren)
+ (let ((deep (assoc c ruby-deep-indent-paren)))
+ (cond (deep
+ (or (cdr deep) ruby-deep-indent-paren-style))
+ ((memq c ruby-deep-indent-paren)
+ ruby-deep-indent-paren-style))))
+ ((eq c ruby-deep-indent-paren) ruby-deep-indent-paren-style)
+ ((eq c ?\( ) ruby-deep-arglist)))
+
+(defun ruby-parse-partial (&optional end in-string nest depth pcol indent)
+ (or depth (setq depth 0))
+ (or indent (setq indent 0))
+ (when (re-search-forward ruby-delimiter end 'move)
+ (let ((pnt (point)) w re expand)
+ (goto-char (match-beginning 0))
+ (cond
+ ((and (memq (char-before) '(?@ ?$)) (looking-at "\\sw"))
+ (goto-char pnt))
+ ((looking-at "[\"`]") ;skip string
+ (cond
+ ((and (not (eobp))
+ (ruby-forward-string (buffer-substring (point) (1+ (point))) end t t))
+ nil)
+ (t
+ (setq in-string (point))
+ (goto-char end))))
+ ((looking-at "'")
+ (cond
+ ((and (not (eobp))
+ (re-search-forward "[^\\]\\(\\\\\\\\\\)*'" end t))
+ nil)
+ (t
+ (setq in-string (point))
+ (goto-char end))))
+ ((looking-at "/=")
+ (goto-char pnt))
+ ((looking-at "/")
+ (cond
+ ((and (not (eobp)) (ruby-expr-beg 'expr-re))
+ (if (ruby-forward-string "/" end t t)
+ nil
+ (setq in-string (point))
+ (goto-char end)))
+ (t
+ (goto-char pnt))))
+ ((looking-at "%")
+ (cond
+ ((and (not (eobp))
+ (ruby-expr-beg 'expr-qstr)
+ (not (looking-at "%="))
+ (looking-at "%[QqrxWw]?\\([^a-zA-Z0-9 \t\n]\\)"))
+ (goto-char (match-beginning 1))
+ (setq expand (not (memq (char-before) '(?q ?w))))
+ (setq w (match-string 1))
+ (cond
+ ((string= w "[") (setq re "]["))
+ ((string= w "{") (setq re "}{"))
+ ((string= w "(") (setq re ")("))
+ ((string= w "<") (setq re "><"))
+ ((and expand (string= w "\\"))
+ (setq w (concat "\\" w))))
+ (unless (cond (re (ruby-forward-string re end t expand))
+ (expand (ruby-forward-string w end t t))
+ (t (re-search-forward
+ (if (string= w "\\")
+ "\\\\[^\\]*\\\\"
+ (concat "[^\\]\\(\\\\\\\\\\)*" w))
+ end t)))
+ (setq in-string (point))
+ (goto-char end)))
+ (t
+ (goto-char pnt))))
+ ((looking-at "\\?") ;skip ?char
+ (cond
+ ((and (ruby-expr-beg)
+ (looking-at "?\\(\\\\C-\\|\\\\M-\\)*\\\\?."))
+ (goto-char (match-end 0)))
+ (t
+ (goto-char pnt))))
+ ((looking-at "\\$") ;skip $char
+ (goto-char pnt)
+ (forward-char 1))
+ ((looking-at "#") ;skip comment
+ (forward-line 1)
+ (goto-char (point))
+ )
+ ((looking-at "[\\[{(]")
+ (let ((deep (ruby-deep-indent-paren-p (char-after))))
+ (if (and deep (or (not (eq (char-after) ?\{)) (ruby-expr-beg)))
+ (progn
+ (and (eq deep 'space) (looking-at ".\\s +[^# \t\n]")
+ (setq pnt (1- (match-end 0))))
+ (setq nest (cons (cons (char-after (point)) (point)) nest))
+ (setq pcol (cons (cons pnt depth) pcol))
+ (setq depth 0))
+ (setq nest (cons (cons (char-after (point)) pnt) nest))
+ (setq depth (1+ depth))))
+ (goto-char pnt)
+ )
+ ((looking-at "[])}]")
+ (if (ruby-deep-indent-paren-p (matching-paren (char-after))
+ (if nest
+ (cdr (nth 0 nest))
+ (save-excursion
+ (forward-char)
+ (ruby-backward-sexp)
+ (point))))
+ (setq depth (cdr (car pcol)) pcol (cdr pcol))
+ (setq depth (1- depth)))
+ (setq nest (cdr nest))
+ (goto-char pnt))
+ ((looking-at ruby-block-end-re)
+ (if (or (and (not (bolp))
+ (progn
+ (forward-char -1)
+ (setq w (char-after (point)))
+ (or (eq ?_ w)
+ (eq ?. w))))
+ (progn
+ (goto-char pnt)
+ (setq w (char-after (point)))
+ (or (eq ?_ w)
+ (eq ?! w)
+ (eq ?? w))))
+ nil
+ (setq nest (cdr nest))
+ (setq depth (1- depth)))
+ (goto-char pnt))
+ ((looking-at "def\\s +[^(\n;]*")
+ (if (or (bolp)
+ (progn
+ (forward-char -1)
+ (not (eq ?_ (char-after (point))))))
+ (progn
+ (setq nest (cons (cons nil pnt) nest))
+ (setq depth (1+ depth))))
+ (goto-char (match-end 0)))
+ ((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>"))
+ (and
+ (save-match-data
+ (or (not (looking-at (concat "do" ruby-keyword-end-re)))
+ (save-excursion
+ (back-to-indentation)
+ (not (looking-at ruby-non-block-do-re)))))
+ (or (bolp)
+ (progn
+ (forward-char -1)
+ (setq w (char-after (point)))
+ (not (or (eq ?_ w)
+ (eq ?. w)))))
+ (goto-char pnt)
+ (setq w (char-after (point)))
+ (not (eq ?_ w))
+ (not (eq ?! w))
+ (not (eq ?? w))
+ (not (eq ?: w))
+ (skip-chars-forward " \t")
+ (goto-char (match-beginning 0))
+ (or (not (looking-at ruby-modifier-re))
+ (ruby-expr-beg 'modifier))
+ (goto-char pnt)
+ (setq nest (cons (cons nil pnt) nest))
+ (setq depth (1+ depth)))
+ (goto-char pnt))
+ ((looking-at ":\\(['\"]\\)")
+ (goto-char (match-beginning 1))
+ (ruby-forward-string (buffer-substring (match-beginning 1) (match-end 1)) end))
+ ((looking-at ":\\([-,.+*/%&|^~<>]=?\\|===?\\|<=>\\|![~=]?\\)")
+ (goto-char (match-end 0)))
+ ((looking-at ":\\([a-zA-Z_][a-zA-Z_0-9]*[!?=]?\\)?")
+ (goto-char (match-end 0)))
+ ((or (looking-at "\\.\\.\\.?")
+ (looking-at "\\.[0-9]+")
+ (looking-at "\\.[a-zA-Z_0-9]+")
+ (looking-at "\\."))
+ (goto-char (match-end 0)))
+ ((looking-at "^=begin")
+ (if (re-search-forward "^=end" end t)
+ (forward-line 1)
+ (setq in-string (match-end 0))
+ (goto-char end)))
+ ((looking-at "<<")
+ (cond
+ ((and (ruby-expr-beg 'heredoc)
+ (looking-at "<<\\([-~]\\)?\\(\\([\"'`]\\)\\([^\n]+?\\)\\3\\|\\(?:\\sw\\|\\s_\\)+\\)"))
+ (setq re (regexp-quote (or (match-string 4) (match-string 2))))
+ (if (match-beginning 1) (setq re (concat "\\s *" re)))
+ (let* ((id-end (goto-char (match-end 0)))
+ (line-end-position (save-excursion (end-of-line) (point)))
+ (state (list in-string nest depth pcol indent)))
+ ;; parse the rest of the line
+ (while (and (> line-end-position (point))
+ (setq state (apply 'ruby-parse-partial
+ line-end-position state))))
+ (setq in-string (car state)
+ nest (nth 1 state)
+ depth (nth 2 state)
+ pcol (nth 3 state)
+ indent (nth 4 state))
+ ;; skip heredoc section
+ (if (re-search-forward (concat "^" re "$") end 'move)
+ (forward-line 1)
+ (setq in-string id-end)
+ (goto-char end))))
+ (t
+ (goto-char pnt))))
+ ((looking-at "^__END__$")
+ (goto-char pnt))
+ ((looking-at ruby-here-doc-beg-re)
+ (if (re-search-forward (ruby-here-doc-end-match)
+ ruby-indent-point t)
+ (forward-line 1)
+ (setq in-string (match-end 0))
+ (goto-char ruby-indent-point)))
+ (t
+ (error (format "bad string %s"
+ (buffer-substring (point) pnt)
+ ))))))
+ (list in-string nest depth pcol))
+
+(defun ruby-parse-region (start end)
+ (let (state)
+ (save-excursion
+ (if start
+ (goto-char start)
+ (ruby-beginning-of-indent))
+ (save-restriction
+ (narrow-to-region (point) end)
+ (while (and (> end (point))
+ (setq state (apply 'ruby-parse-partial end state))))))
+ (list (nth 0 state) ; in-string
+ (car (nth 1 state)) ; nest
+ (nth 2 state) ; depth
+ (car (car (nth 3 state))) ; pcol
+ ;(car (nth 5 state)) ; indent
+ )))
+
+(defun ruby-indent-size (pos nest)
+ (+ pos (* (or nest 1) ruby-indent-level)))
+
+(defun ruby-calculate-indent (&optional parse-start)
+ (save-excursion
+ (beginning-of-line)
+ (let ((ruby-indent-point (point))
+ (case-fold-search nil)
+ state bol eol begin op-end
+ (paren (progn (skip-syntax-forward " ")
+ (and (char-after) (matching-paren (char-after)))))
+ (indent 0))
+ (if parse-start
+ (goto-char parse-start)
+ (ruby-beginning-of-indent)
+ (setq parse-start (point)))
+ (back-to-indentation)
+ (setq indent (current-column))
+ (setq state (ruby-parse-region parse-start ruby-indent-point))
+ (cond
+ ((nth 0 state) ; within string
+ (setq indent nil)) ; do nothing
+ ((car (nth 1 state)) ; in paren
+ (goto-char (setq begin (cdr (nth 1 state))))
+ (let ((deep (ruby-deep-indent-paren-p (car (nth 1 state))
+ (1- (cdr (nth 1 state))))))
+ (if deep
+ (cond ((and (eq deep t) (eq (car (nth 1 state)) paren))
+ (skip-syntax-backward " ")
+ (setq indent (1- (current-column))))
+ ((eq deep 'space)
+ (goto-char (cdr (nth 1 state)))
+ (setq indent (1+ (current-column))))
+ ((let ((s (ruby-parse-region (point) ruby-indent-point)))
+ (and (nth 2 s) (> (nth 2 s) 0)
+ (or (goto-char (cdr (nth 1 s))) t)))
+ (forward-word -1)
+ (setq indent (ruby-indent-size (current-column) (nth 2 state))))
+ (t
+ (setq indent (current-column))
+ (cond ((eq deep 'space))
+ (paren (setq indent (1- indent)))
+ (t (setq indent (ruby-indent-size (1- indent) 1))))))
+ (if (nth 3 state) (goto-char (nth 3 state))
+ (goto-char parse-start) (back-to-indentation))
+ (setq indent (ruby-indent-size (current-column) (nth 2 state))))
+ (and (eq (car (nth 1 state)) paren)
+ (ruby-deep-indent-paren-p (matching-paren paren)
+ (1- (cdr (nth 1 state))))
+ (search-backward (char-to-string paren))
+ (setq indent (current-column)))))
+ ((and (nth 2 state) (> (nth 2 state) 0)) ; in nest
+ (if (null (cdr (nth 1 state)))
+ (error "invalid nest"))
+ (goto-char (cdr (nth 1 state)))
+ (forward-word -1) ; skip back a keyword
+ (setq begin (point))
+ (cond
+ ((looking-at "do\\>[^_]") ; iter block is a special case
+ (if (nth 3 state) (goto-char (nth 3 state))
+ (goto-char parse-start) (back-to-indentation))
+ (setq indent (ruby-indent-size (current-column) (nth 2 state))))
+ (t
+ (setq indent (+ (current-column) ruby-indent-level)))))
+
+ ((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest
+ (setq indent (ruby-indent-size (current-column) (nth 2 state)))))
+ (when indent
+ (goto-char ruby-indent-point)
+ (end-of-line)
+ (setq eol (point))
+ (beginning-of-line)
+ (cond
+ ((and (not (ruby-deep-indent-paren-p paren
+ (and (cdr (nth 1 state))
+ (1- (cdr (nth 1 state))))))
+ (re-search-forward ruby-negative eol t))
+ (and (not (eq ?_ (char-after (match-end 0))))
+ (setq indent (- indent ruby-indent-level))))
+ ((and
+ (save-excursion
+ (beginning-of-line)
+ (not (bobp)))
+ (or (ruby-deep-indent-paren-p t)
+ (null (car (nth 1 state)))))
+ ;; goto beginning of non-empty no-comment line
+ (let (end done)
+ (while (not done)
+ (skip-chars-backward " \t\n")
+ (setq end (point))
+ (beginning-of-line)
+ (if (re-search-forward "^\\s *#" end t)
+ (beginning-of-line)
+ (setq done t))))
+ (setq bol (point))
+ (end-of-line)
+ ;; skip the comment at the end
+ (skip-chars-backward " \t")
+ (let (end (pos (point)))
+ (beginning-of-line)
+ (while (and (re-search-forward "#" pos t)
+ (setq end (1- (point)))
+ (or (ruby-special-char-p end)
+ (and (setq state (ruby-parse-region parse-start end))
+ (nth 0 state))))
+ (setq end nil))
+ (goto-char (or end pos))
+ (skip-chars-backward " \t")
+ (setq begin (if (and end (nth 0 state)) pos (cdr (nth 1 state))))
+ (setq state (ruby-parse-region parse-start (point))))
+ (or (bobp) (forward-char -1))
+ (and
+ (or (and (looking-at ruby-symbol-re)
+ (skip-chars-backward ruby-symbol-chars)
+ (looking-at (concat "\\<\\(" ruby-block-hanging-re "\\)\\>"))
+ (not (eq (point) (nth 3 state)))
+ (save-excursion
+ (goto-char (match-end 0))
+ (not (looking-at "[a-z_]"))))
+ (and (looking-at ruby-operator-re)
+ (not (ruby-special-char-p))
+ ;; operator at the end of line
+ (let ((c (char-after (point))))
+ (and
+;; (or (null begin)
+;; (save-excursion
+;; (goto-char begin)
+;; (skip-chars-forward " \t")
+;; (not (or (eolp) (looking-at "#")
+;; (and (eq (car (nth 1 state)) ?{)
+;; (looking-at "|"))))))
+ (or (not (eq ?/ c))
+ (null (nth 0 (ruby-parse-region (or begin parse-start) (point)))))
+ (or (not (eq ?| (char-after (point))))
+ (save-excursion
+ (or (eolp) (forward-char -1))
+ (cond
+ ((search-backward "|" nil t)
+ (skip-chars-backward " \t\n")
+ (and (not (eolp))
+ (progn
+ (forward-char -1)
+ (not (looking-at "{")))
+ (progn
+ (forward-word -1)
+ (not (looking-at "do\\>[^_]")))))
+ (t t))))
+ (not (eq ?, c))
+ (setq op-end t)))))
+ (setq indent
+ (cond
+ ((and
+ (null op-end)
+ (not (looking-at (concat "\\<\\(" ruby-block-hanging-re "\\)\\>")))
+ (eq (ruby-deep-indent-paren-p t) 'space)
+ (not (bobp)))
+ (widen)
+ (goto-char (or begin parse-start))
+ (skip-syntax-forward " ")
+ (current-column))
+ ((car (nth 1 state)) indent)
+ (t
+ (+ indent ruby-indent-level))))))))
+ (goto-char ruby-indent-point)
+ (beginning-of-line)
+ (skip-syntax-forward " ")
+ (if (looking-at "\\.[^.]\\|&\\.")
+ (+ indent ruby-indent-level)
+ indent))))
+
+(defun ruby-electric-brace (arg)
+ (interactive "P")
+ (insert-char last-command-event 1)
+ (ruby-indent-line t)
+ (delete-char -1)
+ (self-insert-command (prefix-numeric-value arg)))
+
+(eval-when-compile
+ (defmacro defun-region-command (func args &rest body)
+ (let ((intr (car body)))
+ (when (featurep 'xemacs)
+ (if (stringp intr) (setq intr (cadr body)))
+ (and (eq (car intr) 'interactive)
+ (setq intr (cdr intr))
+ (setcar intr (concat "_" (car intr)))))
+ (cons 'defun (cons func (cons args body))))))
+
+(defun-region-command ruby-beginning-of-defun (&optional arg)
+ "Move backward to next beginning-of-defun.
+With argument, do this that many times.
+Returns t unless search stops due to end of buffer."
+ (interactive "p")
+ (and (re-search-backward (concat "^\\(" ruby-block-beg-re "\\)\\_>")
+ nil 'move (or arg 1))
+ (progn (beginning-of-line) t)))
+
+(defun ruby-beginning-of-indent ()
+ (and (re-search-backward (concat "^\\(" ruby-indent-beg-re "\\)\\_>")
+ nil 'move)
+ (progn
+ (beginning-of-line)
+ t)))
+
+(defun-region-command ruby-end-of-defun (&optional arg)
+ "Move forward to next end of defun.
+An end of a defun is found by moving forward from the beginning of one."
+ (interactive "p")
+ (and (re-search-forward (concat "^\\(" ruby-block-end-re "\\)\\($\\|\\b[^_]\\)")
+ nil 'move (or arg 1))
+ (progn (beginning-of-line) t))
+ (forward-line 1))
+
+(defun ruby-move-to-block (n)
+ (let (start pos done down (orig (point)))
+ (setq start (ruby-calculate-indent))
+ (setq down (looking-at (if (< n 0) ruby-block-end-re
+ (concat "\\<\\(" ruby-block-beg-re "\\)\\>"))))
+ (while (and (not done) (not (if (< n 0) (bobp) (eobp))))
+ (forward-line n)
+ (cond
+ ((looking-at "^\\s *$"))
+ ((looking-at "^\\s *#"))
+ ((and (> n 0) (looking-at "^=begin\\>"))
+ (re-search-forward "^=end\\>"))
+ ((and (< n 0) (looking-at "^=end\\>"))
+ (re-search-backward "^=begin\\>"))
+ (t
+ (setq pos (current-indentation))
+ (cond
+ ((< start pos)
+ (setq down t))
+ ((and down (= pos start))
+ (setq done t))
+ ((> start pos)
+ (setq done t)))))
+ (if done
+ (save-excursion
+ (back-to-indentation)
+ (if (looking-at (concat "\\<\\(" ruby-block-mid-re "\\)\\>"))
+ (setq done nil)))))
+ (back-to-indentation)
+ (when (< n 0)
+ (let ((eol (point-at-eol)) state next)
+ (if (< orig eol) (setq eol orig))
+ (setq orig (point))
+ (while (and (setq next (apply 'ruby-parse-partial eol state))
+ (< (point) eol))
+ (setq state next))
+ (when (cdaadr state)
+ (goto-char (cdaadr state)))
+ (backward-word)))))
+
+(defun-region-command ruby-beginning-of-block (&optional arg)
+ "Move backward to next beginning-of-block"
+ (interactive "p")
+ (ruby-move-to-block (- (or arg 1))))
+
+(defun-region-command ruby-end-of-block (&optional arg)
+ "Move forward to next beginning-of-block"
+ (interactive "p")
+ (ruby-move-to-block (or arg 1)))
+
+(defun-region-command ruby-forward-sexp (&optional cnt)
+ (interactive "p")
+ (if (and (numberp cnt) (< cnt 0))
+ (ruby-backward-sexp (- cnt))
+ (let ((i (or cnt 1)))
+ (condition-case nil
+ (while (> i 0)
+ (skip-syntax-forward " ")
+ (if (looking-at ",\\s *") (goto-char (match-end 0)))
+ (cond ((looking-at "\\?\\(\\\\[CM]-\\)*\\\\?\\S ")
+ (goto-char (match-end 0)))
+ ((progn
+ (skip-chars-forward ",.:;|&^~=!?\\+\\-\\*")
+ (looking-at "\\s("))
+ (goto-char (scan-sexps (point) 1)))
+ ((and (looking-at (concat "\\<\\(" ruby-block-beg-re "\\)\\>"))
+ (not (eq (char-before (point)) ?.))
+ (not (eq (char-before (point)) ?:)))
+ (ruby-end-of-block)
+ (forward-word 1))
+ ((looking-at "\\(\\$\\|@@?\\)?\\sw")
+ (while (progn
+ (while (progn (forward-word 1) (looking-at "_")))
+ (cond ((looking-at "::") (forward-char 2) t)
+ ((> (skip-chars-forward ".") 0))
+ ((looking-at "\\?\\|!\\(=[~=>]\\|[^~=]\\)")
+ (forward-char 1) nil)))))
+ ((let (state expr)
+ (while
+ (progn
+ (setq expr (or expr (ruby-expr-beg)
+ (looking-at "%\\sw?\\Sw\\|[\"'`/]")))
+ (nth 1 (setq state (apply 'ruby-parse-partial nil state))))
+ (setq expr t)
+ (skip-chars-forward "<"))
+ (not expr))))
+ (setq i (1- i)))
+ ((error) (forward-word 1)))
+ i)))
+
+(defun-region-command ruby-backward-sexp (&optional cnt)
+ (interactive "p")
+ (if (and (numberp cnt) (< cnt 0))
+ (ruby-forward-sexp (- cnt))
+ (let ((i (or cnt 1)))
+ (condition-case nil
+ (while (> i 0)
+ (skip-chars-backward " \t\n,.:;|&^~=!?\\+\\-\\*")
+ (forward-char -1)
+ (cond ((looking-at "\\s)")
+ (goto-char (scan-sexps (1+ (point)) -1))
+ (case (char-before)
+ (?% (forward-char -1))
+ ('(?q ?Q ?w ?W ?r ?x)
+ (if (eq (char-before (1- (point))) ?%) (forward-char -2))))
+ nil)
+ ((looking-at "\\s\"\\|\\\\\\S_")
+ (let ((c (char-to-string (char-before (match-end 0)))))
+ (while (and (search-backward c)
+ (oddp (skip-chars-backward "\\")))))
+ nil)
+ ((looking-at "\\s.\\|\\s\\")
+ (if (ruby-special-char-p) (forward-char -1)))
+ ((looking-at "\\s(") nil)
+ (t
+ (forward-char 1)
+ (while (progn (forward-word -1)
+ (case (char-before)
+ (?_ t)
+ (?. (forward-char -1) t)
+ ((?$ ?@)
+ (forward-char -1)
+ (and (eq (char-before) (char-after)) (forward-char -1)))
+ (?:
+ (forward-char -1)
+ (eq (char-before) :)))))
+ (if (looking-at ruby-block-end-re)
+ (ruby-beginning-of-block))
+ nil))
+ (setq i (1- i)))
+ ((error)))
+ i)))
+
+(defun ruby-reindent-then-newline-and-indent ()
+ (interactive "*")
+ (newline)
+ (save-excursion
+ (end-of-line 0)
+ (indent-according-to-mode)
+ (delete-region (point) (progn (skip-chars-backward " \t") (point))))
+ (indent-according-to-mode))
+
+(fset 'ruby-encomment-region (symbol-function 'comment-region))
+
+(defun ruby-decomment-region (beg end)
+ (interactive "r")
+ (save-excursion
+ (goto-char beg)
+ (while (re-search-forward "^\\([ \t]*\\)#" end t)
+ (replace-match "\\1" nil nil)
+ (save-excursion
+ (ruby-indent-line)))))
+
+(defun ruby-insert-end ()
+ (interactive)
+ (insert "end")
+ (ruby-indent-line t)
+ (end-of-line))
+
+(defun ruby-mark-defun ()
+ "Put mark at end of this Ruby function, point at beginning."
+ (interactive)
+ (push-mark (point))
+ (ruby-end-of-defun)
+ (push-mark (point) nil t)
+ (ruby-beginning-of-defun)
+ (re-search-backward "^\n" (- (point) 1) t))
+
+(defun ruby-indent-exp (&optional shutup-p)
+ "Indent each line in the balanced expression following point syntactically.
+If optional SHUTUP-P is non-nil, no errors are signalled if no
+balanced expression is found."
+ (interactive "*P")
+ (let ((here (point-marker)) start top column (nest t))
+ (set-marker-insertion-type here t)
+ (unwind-protect
+ (progn
+ (beginning-of-line)
+ (setq start (point) top (current-indentation))
+ (while (and (not (eobp))
+ (progn
+ (setq column (ruby-calculate-indent start))
+ (cond ((> column top)
+ (setq nest t))
+ ((and (= column top) nest)
+ (setq nest nil) t))))
+ (ruby-indent-to column)
+ (beginning-of-line 2)))
+ (goto-char here)
+ (set-marker here nil))))
+
+(defun ruby-add-log-current-method ()
+ "Return current method string."
+ (condition-case nil
+ (save-excursion
+ (let (mname mlist (indent 0))
+ ;; get current method (or class/module)
+ (if (re-search-backward
+ (concat "^[ \t]*\\(def\\|class\\|module\\)[ \t]+"
+ "\\("
+ ;; \\. and :: for class method
+ "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)"
+ "+\\)")
+ nil t)
+ (progn
+ (setq mname (match-string 2))
+ (unless (string-equal "def" (match-string 1))
+ (setq mlist (list mname) mname nil))
+ (goto-char (match-beginning 1))
+ (setq indent (current-column))
+ (beginning-of-line)))
+ ;; nest class/module
+ (while (and (> indent 0)
+ (re-search-backward
+ (concat
+ "^[ \t]*\\(class\\|module\\)[ \t]+"
+ "\\([A-Z]" ruby-symbol-re "*\\)")
+ nil t))
+ (goto-char (match-beginning 1))
+ (if (< (current-column) indent)
+ (progn
+ (setq mlist (cons (match-string 2) mlist))
+ (setq indent (current-column))
+ (beginning-of-line))))
+ (when mname
+ (let ((mn (split-string mname "\\.\\|::")))
+ (if (cdr mn)
+ (progn
+ (cond
+ ((string-equal "" (car mn))
+ (setq mn (cdr mn) mlist nil))
+ ((string-equal "self" (car mn))
+ (setq mn (cdr mn)))
+ ((let ((ml (nreverse mlist)))
+ (while ml
+ (if (string-equal (car ml) (car mn))
+ (setq mlist (nreverse (cdr ml)) ml nil))
+ (or (setq ml (cdr ml)) (nreverse mlist))))))
+ (if mlist
+ (setcdr (last mlist) mn)
+ (setq mlist mn))
+ (setq mn (last mn 2))
+ (setq mname (concat "." (cadr mn)))
+ (setcdr mn nil))
+ (setq mname (concat "#" mname)))))
+ ;; generate string
+ (if (consp mlist)
+ (setq mlist (mapconcat (function identity) mlist "::")))
+ (if mname
+ (if mlist (concat mlist mname) mname)
+ mlist)))))
+
+(defun ruby-brace-to-do-end ()
+ (when (looking-at "{")
+ (let ((orig (point)) (end (progn (ruby-forward-sexp) (point)))
+ oneline (end (make-marker)))
+ (setq oneline (and (eolp) (<= (point-at-bol) orig)))
+ (when (eq (char-before) ?\})
+ (delete-char -1)
+ (cond
+ (oneline
+ (insert "\n")
+ (set-marker end (point)))
+ ((eq (char-syntax (preceding-char)) ?w)
+ (insert " ")))
+ (insert "end")
+ (if (eq (char-syntax (following-char)) ?w)
+ (insert " "))
+ (goto-char orig)
+ (delete-char 1)
+ (if (eq (char-syntax (preceding-char)) ?w)
+ (insert " "))
+ (insert "do")
+ (when (looking-at "\\sw\\||")
+ (insert " ")
+ (backward-char))
+ (when oneline
+ (setq orig (point))
+ (when (cond
+ ((looking-at "\\s *|")
+ (goto-char (match-end 0))
+ (and (search-forward "|" (point-at-eol) 'move)
+ (not (eolp))))
+ (t))
+ (while (progn
+ (insert "\n")
+ (ruby-forward-sexp)
+ (looking-at "\\s *;\\s *"))
+ (delete-char (- (match-end 0) (match-beginning 0))))
+ (goto-char orig)
+ (beginning-of-line 2)
+ (indent-region (point) end))
+ (goto-char orig))
+ t))))
+
+(defun ruby-do-end-to-brace ()
+ (when (and (or (bolp)
+ (not (memq (char-syntax (preceding-char)) '(?w ?_))))
+ (looking-at "\\<do\\(\\s \\|$\\)"))
+ (let ((orig (point)) (end (progn (ruby-forward-sexp) (point)))
+ first last)
+ (backward-char 3)
+ (when (looking-at ruby-block-end-re)
+ (delete-char 3)
+ (insert "}")
+ (setq last (and (eolp)
+ (progn (backward-char 1)
+ (skip-syntax-backward " ")
+ (bolp))
+ (1- (point-at-eol -1))))
+ (goto-char orig)
+ (delete-char 2)
+ (insert "{")
+ (setq orig (point))
+ (when (and last (<= last (point))
+ (not (search-forward "#" (setq first (point-at-eol)) t)))
+ (goto-char (- end 4))
+ (end-of-line 0)
+ (if (looking-at "\n\\s *")
+ (delete-char (- (match-end 0) (match-beginning 0))) t)
+ (goto-char first)
+ (if (looking-at "\n\\s *")
+ (delete-char (- (match-end 0) (match-beginning 0))) t))
+ (goto-char orig)
+ (if (looking-at "\\s +|")
+ (delete-char (- (match-end 0) (match-beginning 0) 1)))
+ t))))
+
+(defun ruby-toggle-block ()
+ (interactive)
+ (or (ruby-brace-to-do-end)
+ (ruby-do-end-to-brace)))
+
+(eval-when-compile
+ (if (featurep 'font-lock)
+ (defmacro eval-when-font-lock-available (&rest args) (cons 'progn args))
+ (defmacro eval-when-font-lock-available (&rest args))))
+
+(eval-when-compile
+ (if (featurep 'hilit19)
+ (defmacro eval-when-hilit19-available (&rest args) (cons 'progn args))
+ (defmacro eval-when-hilit19-available (&rest args))))
+
+(eval-when-font-lock-available
+ (or (boundp 'font-lock-variable-name-face)
+ (setq font-lock-variable-name-face font-lock-type-face))
+
+ (defconst ruby-font-lock-syntactic-keywords
+ `(
+ ;; #{ }, #$hoge, #@foo are not comments
+ ("\\(#\\)[{$@]" 1 (1 . nil))
+ ;; the last $', $", $` in the respective string is not variable
+ ;; the last ?', ?", ?` in the respective string is not ascii code
+ ("\\(^\\|[\[ \t\n<+\(,=]\\)\\(['\"`]\\)\\(\\\\.\\|\\2\\|[^'\"`\n\\\\]\\)*?\\\\?[?$]\\(\\2\\)"
+ (2 (7 . nil))
+ (4 (7 . nil)))
+ ;; $' $" $` .... are variables
+ ;; ?' ?" ?` are ascii codes
+ ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
+ ;; regexps
+ ("\\(^\\|[[{|=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
+ (4 (7 . ?/))
+ (6 (7 . ?/)))
+ ("^\\(=\\)begin\\(\\s \\|$\\)" 1 (7 . nil))
+ ("^\\(=\\)end\\(\\s \\|$\\)" 1 (7 . nil))
+ (,(concat ruby-here-doc-beg-re ".*\\(\n\\)")
+ ,(+ 1 (regexp-opt-depth ruby-here-doc-beg-re))
+ (ruby-here-doc-beg-syntax))
+ (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax))))
+
+ (unless (functionp 'syntax-ppss)
+ (defun syntax-ppss (&optional pos)
+ (parse-partial-sexp (point-min) (or pos (point)))))
+
+ (defun ruby-in-ppss-context-p (context &optional ppss)
+ (let ((ppss (or ppss (syntax-ppss (point)))))
+ (if (cond
+ ((eq context 'anything)
+ (or (nth 3 ppss)
+ (nth 4 ppss)))
+ ((eq context 'string)
+ (nth 3 ppss))
+ ((eq context 'heredoc)
+ (and (nth 3 ppss)
+ ;; If it's generic string, it's a heredoc and we don't care
+ ;; See `parse-partial-sexp'
+ (not (numberp (nth 3 ppss)))))
+ ((eq context 'non-heredoc)
+ (and (ruby-in-ppss-context-p 'anything)
+ (not (ruby-in-ppss-context-p 'heredoc))))
+ ((eq context 'comment)
+ (nth 4 ppss))
+ (t
+ (error (concat
+ "Internal error on `ruby-in-ppss-context-p': "
+ "context name `" (symbol-name context) "' is unknown"))))
+ t)))
+
+ (defun ruby-in-here-doc-p ()
+ (save-excursion
+ (let ((old-point (point)) (case-fold-search nil))
+ (beginning-of-line)
+ (catch 'found-beg
+ (while (and (re-search-backward ruby-here-doc-beg-re nil t)
+ (not (ruby-singleton-class-p)))
+ (if (not (or (ruby-in-ppss-context-p 'anything)
+ (ruby-here-doc-find-end old-point)))
+ (throw 'found-beg t)))))))
+
+ (defun ruby-here-doc-find-end (&optional limit)
+ "Expects the point to be on a line with one or more heredoc
+openers. Returns the buffer position at which all heredocs on the
+line are terminated, or nil if they aren't terminated before the
+buffer position `limit' or the end of the buffer."
+ (save-excursion
+ (beginning-of-line)
+ (catch 'done
+ (let ((eol (save-excursion (end-of-line) (point)))
+ (case-fold-search nil)
+ ;; Fake match data such that (match-end 0) is at eol
+ (end-match-data (progn (looking-at ".*$") (match-data)))
+ beg-match-data end-re)
+ (while (re-search-forward ruby-here-doc-beg-re eol t)
+ (setq beg-match-data (match-data))
+ (setq end-re (ruby-here-doc-end-match))
+
+ (set-match-data end-match-data)
+ (goto-char (match-end 0))
+ (unless (re-search-forward end-re limit t) (throw 'done nil))
+ (setq end-match-data (match-data))
+
+ (set-match-data beg-match-data)
+ (goto-char (match-end 0)))
+ (set-match-data end-match-data)
+ (goto-char (match-end 0))
+ (point)))))
+
+ (defun ruby-here-doc-beg-syntax ()
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (unless (or (ruby-in-ppss-context-p 'non-heredoc)
+ (ruby-in-here-doc-p))
+ (string-to-syntax "|"))))
+
+ (defun ruby-here-doc-end-syntax ()
+ (let ((pss (syntax-ppss)) (case-fold-search nil))
+ (when (ruby-in-ppss-context-p 'heredoc pss)
+ (save-excursion
+ (goto-char (nth 8 pss)) ; Go to the beginning of heredoc.
+ (let ((eol (point)))
+ (beginning-of-line)
+ (if (and (re-search-forward (ruby-here-doc-beg-match) eol t) ; If there is a heredoc that matches this line...
+ (not (ruby-in-ppss-context-p 'anything)) ; And that's not inside a heredoc/string/comment...
+ (progn (goto-char (match-end 0)) ; And it's the last heredoc on its line...
+ (not (re-search-forward ruby-here-doc-beg-re eol t))))
+ (string-to-syntax "|")))))))
+
+ (eval-when-compile
+ (put 'ruby-mode 'font-lock-defaults
+ '((ruby-font-lock-keywords)
+ nil nil nil
+ beginning-of-line
+ (font-lock-syntactic-keywords
+ . ruby-font-lock-syntactic-keywords))))
+
+ (defun ruby-font-lock-docs (limit)
+ (if (re-search-forward "^=begin\\(\\s \\|$\\)" limit t)
+ (let (beg)
+ (beginning-of-line)
+ (setq beg (point))
+ (forward-line 1)
+ (if (re-search-forward "^=end\\(\\s \\|$\\)" limit t)
+ (progn
+ (set-match-data (list beg (point)))
+ t)))))
+
+ (defun ruby-font-lock-maybe-docs (limit)
+ (let (beg)
+ (save-excursion
+ (if (and (re-search-backward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
+ (string= (match-string 1) "begin"))
+ (progn
+ (beginning-of-line)
+ (setq beg (point)))))
+ (if (and beg (and (re-search-forward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
+ (string= (match-string 1) "end")))
+ (progn
+ (set-match-data (list beg (point)))
+ t)
+ nil)))
+
+ (defvar ruby-font-lock-syntax-table
+ (let* ((tbl (copy-syntax-table ruby-mode-syntax-table)))
+ (modify-syntax-entry ?_ "w" tbl)
+ tbl))
+
+ (defconst ruby-font-lock-keywords
+ (list
+ ;; functions
+ '("^\\s *def\\s +\\([^( \t\n]+\\)"
+ 1 font-lock-function-name-face)
+ ;; keywords
+ (cons (concat
+ "\\(^\\|[^_:.@$]\\|\\.\\.\\)\\_<\\(defined\\?\\|"
+ (regexp-opt
+ '("alias"
+ "and"
+ "begin"
+ "break"
+ "case"
+ "catch"
+ "class"
+ "def"
+ "do"
+ "elsif"
+ "else"
+ "fail"
+ "ensure"
+ "for"
+ "end"
+ "if"
+ "in"
+ "module"
+ "next"
+ "not"
+ "or"
+ "raise"
+ "redo"
+ "rescue"
+ "retry"
+ "return"
+ "then"
+ "throw"
+ "super"
+ "unless"
+ "undef"
+ "until"
+ "when"
+ "while"
+ "yield"
+ )
+ t)
+ "\\)"
+ ruby-keyword-end-re)
+ 2)
+ ;; here-doc beginnings
+ (list ruby-here-doc-beg-re 0 'font-lock-string-face)
+ ;; variables
+ '("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>"
+ 2 font-lock-variable-name-face)
+ ;; variables
+ '("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
+ 1 font-lock-variable-name-face)
+ '("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+"
+ 0 font-lock-variable-name-face)
+ ;; embedded document
+ '(ruby-font-lock-docs
+ 0 font-lock-comment-face t)
+ '(ruby-font-lock-maybe-docs
+ 0 font-lock-comment-face t)
+ ;; general delimited string
+ '("\\(^\\|[[ \t\n<+(,=]\\)\\(%[xrqQwW]?\\([^<[{(a-zA-Z0-9 \n]\\)[^\n\\\\]*\\(\\\\.[^\n\\\\]*\\)*\\(\\3\\)\\)"
+ (2 font-lock-string-face))
+ ;; constants
+ '("\\(^\\|[^_]\\)\\_<\\([A-Z]+\\(\\w\\|_\\)*\\)"
+ 2 font-lock-type-face)
+ ;; symbols
+ '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
+ 2 font-lock-reference-face)
+ '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-reference-face)
+ ;; expression expansion
+ '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)"
+ 0 font-lock-variable-name-face t)
+ ;; warn lower camel case
+ ;'("\\<[a-z]+[a-z0-9]*[A-Z][A-Za-z0-9]*\\([!?]?\\|\\>\\)"
+ ; 0 font-lock-warning-face)
+ )
+ "*Additional expressions to highlight in ruby mode."))
+
+(eval-when-hilit19-available
+ (hilit-set-mode-patterns
+ 'ruby-mode
+ '(("[^$\\?]\\(\"[^\\\"]*\\(\\\\\\(.\\|\n\\)[^\\\"]*\\)*\"\\)" 1 string)
+ ("[^$\\?]\\('[^\\']*\\(\\\\\\(.\\|\n\\)[^\\']*\\)*'\\)" 1 string)
+ ("[^$\\?]\\(`[^\\`]*\\(\\\\\\(.\\|\n\\)[^\\`]*\\)*`\\)" 1 string)
+ ("^\\s *#.*$" nil comment)
+ ("[^$@?\\]\\(#[^$@{\n].*$\\)" 1 comment)
+ ("[^a-zA-Z_]\\(\\?\\(\\\\[CM]-\\)*.\\)" 1 string)
+ ("^\\s *\\(require\\|load\\).*$" nil include)
+ ("^\\s *\\(include\\|alias\\|undef\\).*$" nil decl)
+ ("^\\s *\\<\\(class\\|def\\|module\\)\\>" "[)\n;]" defun)
+ ("[^_]\\<\\(begin\\|case\\|else\\|elsif\\|end\\|ensure\\|for\\|if\\|unless\\|rescue\\|then\\|when\\|while\\|until\\|do\\|yield\\)\\>\\([^_]\\|$\\)" 1 defun)
+ ("[^_]\\<\\(and\\|break\\|next\\|raise\\|fail\\|in\\|not\\|or\\|redo\\|retry\\|return\\|super\\|yield\\|catch\\|throw\\|self\\|nil\\)\\>\\([^_]\\|$\\)" 1 keyword)
+ ("\\$\\(.\\|\\sw+\\)" nil type)
+ ("[$@].[a-zA-Z_0-9]*" nil struct)
+ ("^__END__" nil label))))
+
+
+;;;###autoload
+(defun ruby-mode ()
+ "Major mode for editing ruby scripts.
+\\[ruby-indent-command] properly indents subexpressions of multi-line
+class, module, def, if, while, for, do, and case statements, taking
+nesting into account.
+
+The variable ruby-indent-level controls the amount of indentation.
+\\{ruby-mode-map}"
+ (interactive)
+ (kill-all-local-variables)
+ (use-local-map ruby-mode-map)
+ (setq mode-name "Ruby")
+ (setq major-mode 'ruby-mode)
+ (ruby-mode-variables)
+
+ (make-local-variable 'imenu-create-index-function)
+ (setq imenu-create-index-function 'ruby-imenu-create-index)
+
+ (make-local-variable 'add-log-current-defun-function)
+ (setq add-log-current-defun-function 'ruby-add-log-current-method)
+
+ (add-hook
+ (cond ((boundp 'before-save-hook)
+ (make-local-variable 'before-save-hook)
+ 'before-save-hook)
+ ((boundp 'write-contents-functions) 'write-contents-functions)
+ ((boundp 'write-contents-hooks) 'write-contents-hooks))
+ 'ruby-mode-set-encoding)
+
+ (set (make-local-variable 'font-lock-defaults) '((ruby-font-lock-keywords) nil nil))
+ (set (make-local-variable 'font-lock-keywords) ruby-font-lock-keywords)
+ (set (make-local-variable 'font-lock-syntax-table) ruby-font-lock-syntax-table)
+ (set (make-local-variable 'font-lock-syntactic-keywords) ruby-font-lock-syntactic-keywords)
+
+ (if (fboundp 'run-mode-hooks)
+ (run-mode-hooks 'ruby-mode-hook)
+ (run-hooks 'ruby-mode-hook)))
+
+(provide 'ruby-mode)
diff --git a/misc/ruby-style.el b/misc/ruby-style.el
index 13aad77b3d..b8593b202a 100644
--- a/misc/ruby-style.el
+++ b/misc/ruby-style.el
@@ -55,7 +55,7 @@
'("bsd"
(c-basic-offset . 4)
(tab-width . 8)
- (indent-tabs-mode . nil)
+ (indent-tabs-mode . t)
(setq show-trailing-whitespace t)
(c-offsets-alist
(case-label . *)
@@ -75,20 +75,7 @@
(let ((head (progn (forward-line 100) (point)))
(case-fold-search nil))
(goto-char (point-min))
- (re-search-forward "Copyright (C) .* Yukihiro Matsumoto" head t)))
- (condition-case ()
- (with-temp-buffer
- (when (= 0 (call-process "git" nil t nil "remote" "get-url" "origin"))
- (goto-char (point-min))
- (looking-at ".*/ruby\\(\\.git\\)?$")))
- (error))
- (condition-case ()
- (with-temp-buffer
- (when (= 0 (call-process "svn" nil t nil "info" "--xml"))
- (goto-char (point-min))
- (search-forward-regexp "<root>.*/ruby</root>" nil)))
- (error))
- nil)
+ (re-search-forward "Copyright (C) .* Yukihiro Matsumoto" head t))))
(c-set-style "ruby")))
(provide 'ruby-style)
diff --git a/misc/rubydb2x.el b/misc/rubydb2x.el
new file mode 100644
index 0000000000..a74265fb0e
--- /dev/null
+++ b/misc/rubydb2x.el
@@ -0,0 +1,104 @@
+(require 'gud)
+(provide 'rubydb)
+
+;; ======================================================================
+;; rubydb functions
+
+;;; History of argument lists passed to rubydb.
+(defvar gud-rubydb-history nil)
+
+(defun gud-rubydb-massage-args (file args)
+ (cons "-I" (cons "." (cons "-r" (cons "debug" (cons file args))))))
+
+;; There's no guarantee that Emacs will hand the filter the entire
+;; marker at once; it could be broken up across several strings. We
+;; might even receive a big chunk with several markers in it. If we
+;; receive a chunk of text which looks like it might contain the
+;; beginning of a marker, we save it here between calls to the
+;; filter.
+(defvar gud-rubydb-marker-acc "")
+
+(defun gud-rubydb-marker-filter (string)
+ (save-match-data
+ (setq gud-marker-acc (concat gud-marker-acc string))
+ (let ((output ""))
+
+ ;; Process all the complete markers in this chunk.
+ (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
+ gud-marker-acc)
+ (setq
+
+ ;; Extract the frame position from the marker.
+ gud-last-frame
+ (cons (substring gud-marker-acc (match-beginning 1) (match-end 1))
+ (string-to-int (substring gud-marker-acc
+ (match-beginning 2)
+ (match-end 2))))
+
+ ;; Append any text before the marker to the output we're going
+ ;; to return - we don't include the marker in this text.
+ output (concat output
+ (substring gud-marker-acc 0 (match-beginning 0)))
+
+ ;; Set the accumulator to the remaining text.
+ gud-marker-acc (substring gud-marker-acc (match-end 0))))
+
+ ;; Does the remaining text look like it might end with the
+ ;; beginning of another marker? If it does, then keep it in
+ ;; gud-marker-acc until we receive the rest of it. Since we
+ ;; know the full marker regexp above failed, it's pretty simple to
+ ;; test for marker starts.
+ (if (string-match "\032.*\\'" gud-marker-acc)
+ (progn
+ ;; Everything before the potential marker start can be output.
+ (setq output (concat output (substring gud-marker-acc
+ 0 (match-beginning 0))))
+
+ ;; Everything after, we save, to combine with later input.
+ (setq gud-marker-acc
+ (substring gud-marker-acc (match-beginning 0))))
+
+ (setq output (concat output gud-marker-acc)
+ gud-marker-acc ""))
+
+ output)))
+
+(defun gud-rubydb-find-file (f)
+ (find-file-noselect f))
+
+(defvar rubydb-command-name "ruby"
+ "File name for executing ruby.")
+
+;;;###autoload
+(defun rubydb (command-line)
+ "Run rubydb on program FILE in buffer *gud-FILE*.
+The directory containing FILE becomes the initial working directory
+and source-file directory for your debugger."
+ (interactive
+ (list (read-from-minibuffer "Run rubydb (like this): "
+ (if (consp gud-rubydb-history)
+ (car gud-rubydb-history)
+ (concat rubydb-command-name " "))
+ nil nil
+ '(gud-rubydb-history . 1))))
+
+ (gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
+ (gud-marker-filter . gud-rubydb-marker-filter)
+ (gud-find-file . gud-rubydb-find-file)
+ ))
+ (gud-common-init command-line)
+
+ (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.")
+; (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
+ (gud-def gud-step "s" "\C-s" "Step one source line with display.")
+ (gud-def gud-next "n" "\C-n" "Step one line (skip functions).")
+ (gud-def gud-cont "c" "\C-r" "Continue with display.")
+ (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
+ (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
+ (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
+ (gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
+
+ (setq comint-prompt-regexp "^(rdb:-) ")
+ (setq paragraph-start comint-prompt-regexp)
+ (run-hooks 'rubydb-mode-hook)
+ )
diff --git a/misc/rubydb3x.el b/misc/rubydb3x.el
new file mode 100644
index 0000000000..9d6bc57d5a
--- /dev/null
+++ b/misc/rubydb3x.el
@@ -0,0 +1,115 @@
+(require 'gud)
+(provide 'rubydb)
+
+;; ======================================================================
+;; rubydb functions
+
+;;; History of argument lists passed to rubydb.
+(defvar gud-rubydb-history nil)
+
+(if (fboundp 'gud-overload-functions)
+ (defun gud-rubydb-massage-args (file args)
+ (cons "-r" (cons "debug" (cons file args))))
+ (defun gud-rubydb-massage-args (file args)
+ (cons "-r" (cons "debug" args))))
+
+;; There's no guarantee that Emacs will hand the filter the entire
+;; marker at once; it could be broken up across several strings. We
+;; might even receive a big chunk with several markers in it. If we
+;; receive a chunk of text which looks like it might contain the
+;; beginning of a marker, we save it here between calls to the
+;; filter.
+(defvar gud-rubydb-marker-acc "")
+(make-variable-buffer-local 'gud-rubydb-marker-acc)
+
+(defun gud-rubydb-marker-filter (string)
+ (setq gud-rubydb-marker-acc (concat gud-rubydb-marker-acc string))
+ (let ((output ""))
+
+ ;; Process all the complete markers in this chunk.
+ (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
+ gud-rubydb-marker-acc)
+ (setq
+
+ ;; Extract the frame position from the marker.
+ gud-last-frame
+ (cons (substring gud-rubydb-marker-acc (match-beginning 1) (match-end 1))
+ (string-to-int (substring gud-rubydb-marker-acc
+ (match-beginning 2)
+ (match-end 2))))
+
+ ;; Append any text before the marker to the output we're going
+ ;; to return - we don't include the marker in this text.
+ output (concat output
+ (substring gud-rubydb-marker-acc 0 (match-beginning 0)))
+
+ ;; Set the accumulator to the remaining text.
+ gud-rubydb-marker-acc (substring gud-rubydb-marker-acc (match-end 0))))
+
+ ;; Does the remaining text look like it might end with the
+ ;; beginning of another marker? If it does, then keep it in
+ ;; gud-rubydb-marker-acc until we receive the rest of it. Since we
+ ;; know the full marker regexp above failed, it's pretty simple to
+ ;; test for marker starts.
+ (if (string-match "\032.*\\'" gud-rubydb-marker-acc)
+ (progn
+ ;; Everything before the potential marker start can be output.
+ (setq output (concat output (substring gud-rubydb-marker-acc
+ 0 (match-beginning 0))))
+
+ ;; Everything after, we save, to combine with later input.
+ (setq gud-rubydb-marker-acc
+ (substring gud-rubydb-marker-acc (match-beginning 0))))
+
+ (setq output (concat output gud-rubydb-marker-acc)
+ gud-rubydb-marker-acc ""))
+
+ output))
+
+(defun gud-rubydb-find-file (f)
+ (save-excursion
+ (let ((buf (find-file-noselect f)))
+ (set-buffer buf)
+;; (gud-make-debug-menu)
+ buf)))
+
+(defvar rubydb-command-name "ruby"
+ "File name for executing ruby.")
+
+;;;###autoload
+(defun rubydb (command-line)
+ "Run rubydb on program FILE in buffer *gud-FILE*.
+The directory containing FILE becomes the initial working directory
+and source-file directory for your debugger."
+ (interactive
+ (list (read-from-minibuffer "Run rubydb (like this): "
+ (if (consp gud-rubydb-history)
+ (car gud-rubydb-history)
+ (concat rubydb-command-name " "))
+ nil nil
+ '(gud-rubydb-history . 1))))
+
+ (if (not (fboundp 'gud-overload-functions))
+ (gud-common-init command-line 'gud-rubydb-massage-args
+ 'gud-rubydb-marker-filter 'gud-rubydb-find-file)
+ (gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
+ (gud-marker-filter . gud-rubydb-marker-filter)
+ (gud-find-file . gud-rubydb-find-file)))
+ (gud-common-init command-line rubydb-command-name))
+
+ (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.")
+; (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
+ (gud-def gud-step "s" "\C-s" "Step one source line with display.")
+ (gud-def gud-next "n" "\C-n" "Step one line (skip functions).")
+ (gud-def gud-cont "c" "\C-r" "Continue with display.")
+ (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
+ (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
+ (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
+ (gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
+
+ (setq comint-prompt-regexp "^(rdb:-) ")
+ (if (boundp 'comint-last-output-start)
+ (set-marker comint-last-output-start (point)))
+ (set (make-local-variable 'paragraph-start) comint-prompt-regexp)
+ (run-hooks 'rubydb-mode-hook)
+ )
diff --git a/misc/test_lldb_cruby.rb b/misc/test_lldb_cruby.rb
index bd58619ac2..4d1cc499f5 100644
--- a/misc/test_lldb_cruby.rb
+++ b/misc/test_lldb_cruby.rb
@@ -9,7 +9,7 @@ class TestLLDBInit < Test::Unit::TestCase
tf.puts <<eom
target create ./miniruby
command script import -r misc/lldb_cruby.py
-b rb_inspect
+b rb_p
run -e'p #{expr}'
rp obj
eom
@@ -24,12 +24,8 @@ eom
assert_rp 'Object.new', 'T_OBJECT'
end
- def test_rp_regex
- assert_rp '/foo/', '[(]Regex'
- end
-
def test_rp_symbol
- assert_rp ':abcde', /T_SYMBOL: \(\h+\)/
+ assert_rp ':abcde', /immediate\(\h+\)/
end
def test_rp_string
diff --git a/missing/dtoa.c b/missing/dtoa.c
deleted file mode 100644
index cbee13ee81..0000000000
--- a/missing/dtoa.c
+++ /dev/null
@@ -1,3417 +0,0 @@
-/****************************************************************
- *
- * The author of this software is David M. Gay.
- *
- * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software and in all copies of the supporting
- * documentation for such software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- ***************************************************************/
-
-/* Please send bug reports to David M. Gay (dmg at acm dot org,
- * with " at " changed at "@" and " dot " changed to "."). */
-
-/* On a machine with IEEE extended-precision registers, it is
- * necessary to specify double-precision (53-bit) rounding precision
- * before invoking strtod or dtoa. If the machine uses (the equivalent
- * of) Intel 80x87 arithmetic, the call
- * _control87(PC_53, MCW_PC);
- * does this with many compilers. Whether this or another call is
- * appropriate depends on the compiler; for this to work, it may be
- * necessary to #include "float.h" or another system-dependent header
- * file.
- */
-
-/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
- *
- * This strtod returns a nearest machine number to the input decimal
- * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
- * broken by the IEEE round-even rule. Otherwise ties are broken by
- * biased rounding (add half and chop).
- *
- * Inspired loosely by William D. Clinger's paper "How to Read Floating
- * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
- *
- * Modifications:
- *
- * 1. We only require IEEE, IBM, or VAX double-precision
- * arithmetic (not IEEE double-extended).
- * 2. We get by with floating-point arithmetic in a case that
- * Clinger missed -- when we're computing d * 10^n
- * for a small integer d and the integer n is not too
- * much larger than 22 (the maximum integer k for which
- * we can represent 10^k exactly), we may be able to
- * compute (d*10^k) * 10^(e-k) with just one roundoff.
- * 3. Rather than a bit-at-a-time adjustment of the binary
- * result in the hard case, we use floating-point
- * arithmetic to determine the adjustment to within
- * one bit; only in really hard cases do we need to
- * compute a second residual.
- * 4. Because of 3., we don't need a large table of powers of 10
- * for ten-to-e (just some small tables, e.g. of 10^k
- * for 0 <= k <= 22).
- */
-
-/*
- * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least
- * significant byte has the lowest address.
- * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most
- * significant byte has the lowest address.
- * #define Long int on machines with 32-bit ints and 64-bit longs.
- * #define IBM for IBM mainframe-style floating-point arithmetic.
- * #define VAX for VAX-style floating-point arithmetic (D_floating).
- * #define No_leftright to omit left-right logic in fast floating-point
- * computation of dtoa.
- * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
- * and strtod and dtoa should round accordingly.
- * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
- * and Honor_FLT_ROUNDS is not #defined.
- * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
- * that use extended-precision instructions to compute rounded
- * products and quotients) with IBM.
- * #define ROUND_BIASED for IEEE-format with biased rounding.
- * #define Inaccurate_Divide for IEEE-format with correctly rounded
- * products but inaccurate quotients, e.g., for Intel i860.
- * #define NO_LONG_LONG on machines that do not have a "long long"
- * integer type (of >= 64 bits). On such machines, you can
- * #define Just_16 to store 16 bits per 32-bit Long when doing
- * high-precision integer arithmetic. Whether this speeds things
- * up or slows things down depends on the machine and the number
- * being converted. If long long is available and the name is
- * something other than "long long", #define Llong to be the name,
- * and if "unsigned Llong" does not work as an unsigned version of
- * Llong, #define #ULLong to be the corresponding unsigned type.
- * #define KR_headers for old-style C function headers.
- * #define Bad_float_h if your system lacks a float.h or if it does not
- * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
- * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
- * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
- * if memory is available and otherwise does something you deem
- * appropriate. If MALLOC is undefined, malloc will be invoked
- * directly -- and assumed always to succeed.
- * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
- * memory allocations from a private pool of memory when possible.
- * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
- * unless #defined to be a different length. This default length
- * suffices to get rid of MALLOC calls except for unusual cases,
- * such as decimal-to-binary conversion of a very long string of
- * digits. The longest string dtoa can return is about 751 bytes
- * long. For conversions by strtod of strings of 800 digits and
- * all dtoa conversions in single-threaded executions with 8-byte
- * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte
- * pointers, PRIVATE_MEM >= 7112 appears adequate.
- * #define INFNAN_CHECK on IEEE systems to cause strtod to check for
- * Infinity and NaN (case insensitively). On some systems (e.g.,
- * some HP systems), it may be necessary to #define NAN_WORD0
- * appropriately -- to the most significant word of a quiet NaN.
- * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
- * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
- * strtod also accepts (case insensitively) strings of the form
- * NaN(x), where x is a string of hexadecimal digits and spaces;
- * if there is only one string of hexadecimal digits, it is taken
- * for the 52 fraction bits of the resulting NaN; if there are two
- * or more strings of hex digits, the first is for the high 20 bits,
- * the second and subsequent for the low 32 bits, with intervening
- * white space ignored; but if this results in none of the 52
- * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0
- * and NAN_WORD1 are used instead.
- * #define MULTIPLE_THREADS if the system offers preemptively scheduled
- * multiple threads. In this case, you must provide (or suitably
- * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
- * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed
- * in pow5mult, ensures lazy evaluation of only one copy of high
- * powers of 5; omitting this lock would introduce a small
- * probability of wasting memory, but would otherwise be harmless.)
- * You must also invoke freedtoa(s) to free the value s returned by
- * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined.
- * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that
- * avoids underflows on inputs whose result does not underflow.
- * If you #define NO_IEEE_Scale on a machine that uses IEEE-format
- * floating-point numbers and flushes underflows to zero rather
- * than implementing gradual underflow, then you must also #define
- * Sudden_Underflow.
- * #define YES_ALIAS to permit aliasing certain double values with
- * arrays of ULongs. This leads to slightly better code with
- * some compilers and was always used prior to 19990916, but it
- * is not strictly legal and can cause trouble with aggressively
- * optimizing compilers (e.g., gcc 2.95.1 under -O2).
- * #define USE_LOCALE to use the current locale's decimal_point value.
- * #define SET_INEXACT if IEEE arithmetic is being used and extra
- * computation should be done to set the inexact flag when the
- * result is inexact and avoid setting inexact when the result
- * is exact. In this case, dtoa.c must be compiled in
- * an environment, perhaps provided by #include "dtoa.c" in a
- * suitable wrapper, that defines two functions,
- * int get_inexact(void);
- * void clear_inexact(void);
- * such that get_inexact() returns a nonzero value if the
- * inexact bit is already set, and clear_inexact() sets the
- * inexact bit to 0. When SET_INEXACT is #defined, strtod
- * also does extra computations to set the underflow and overflow
- * flags when appropriate (i.e., when the result is tiny and
- * inexact or when it is a numeric value rounded to +-infinity).
- * #define NO_ERRNO if strtod should not assign errno = ERANGE when
- * the result overflows to +-Infinity or underflows to 0.
- */
-
-#ifdef WORDS_BIGENDIAN
-#define IEEE_BIG_ENDIAN
-#else
-#define IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __vax__
-#define VAX
-#undef IEEE_BIG_ENDIAN
-#undef IEEE_LITTLE_ENDIAN
-#endif
-
-#if defined(__arm__) && !defined(__VFP_FP__)
-#define IEEE_BIG_ENDIAN
-#undef IEEE_LITTLE_ENDIAN
-#endif
-
-#undef Long
-#undef ULong
-
-#if SIZEOF_INT == 4
-#define Long int
-#define ULong unsigned int
-#elif SIZEOF_LONG == 4
-#define Long long int
-#define ULong unsigned long int
-#endif
-
-#if HAVE_LONG_LONG
-#define Llong LONG_LONG
-#else
-#define NO_LONG_LONG
-#endif
-
-#ifdef DEBUG
-#include <stdio.h>
-#define Bug(x) {fprintf(stderr, "%s\n", (x)); exit(EXIT_FAILURE);}
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef USE_LOCALE
-#include <locale.h>
-#endif
-
-#ifdef MALLOC
-extern void *MALLOC(size_t);
-#else
-#define MALLOC xmalloc
-#endif
-#ifdef FREE
-extern void FREE(void*);
-#else
-#define FREE xfree
-#endif
-
-#ifndef Omit_Private_Memory
-#ifndef PRIVATE_MEM
-#define PRIVATE_MEM 2304
-#endif
-#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
-static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
-#endif
-
-#undef IEEE_Arith
-#undef Avoid_Underflow
-#ifdef IEEE_BIG_ENDIAN
-#define IEEE_Arith
-#endif
-#ifdef IEEE_LITTLE_ENDIAN
-#define IEEE_Arith
-#endif
-
-#ifdef Bad_float_h
-
-#ifdef IEEE_Arith
-#define DBL_DIG 15
-#define DBL_MAX_10_EXP 308
-#define DBL_MAX_EXP 1024
-#define FLT_RADIX 2
-#endif /*IEEE_Arith*/
-
-#ifdef IBM
-#define DBL_DIG 16
-#define DBL_MAX_10_EXP 75
-#define DBL_MAX_EXP 63
-#define FLT_RADIX 16
-#define DBL_MAX 7.2370055773322621e+75
-#endif
-
-#ifdef VAX
-#define DBL_DIG 16
-#define DBL_MAX_10_EXP 38
-#define DBL_MAX_EXP 127
-#define FLT_RADIX 2
-#define DBL_MAX 1.7014118346046923e+38
-#endif
-
-#ifndef LONG_MAX
-#define LONG_MAX 2147483647
-#endif
-
-#else /* ifndef Bad_float_h */
-#include <float.h>
-#endif /* Bad_float_h */
-
-#include <math.h>
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#ifndef hexdigit
-static const char hexdigits[] = "0123456789abcdef0123456789ABCDEF";
-#endif
-
-#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1
-Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined.
-#endif
-
-typedef union { double d; ULong L[2]; } U;
-
-#ifdef YES_ALIAS
-typedef double double_u;
-# define dval(x) (x)
-# ifdef IEEE_LITTLE_ENDIAN
-# define word0(x) (((ULong *)&(x))[1])
-# define word1(x) (((ULong *)&(x))[0])
-# else
-# define word0(x) (((ULong *)&(x))[0])
-# define word1(x) (((ULong *)&(x))[1])
-# endif
-#else
-typedef U double_u;
-# ifdef IEEE_LITTLE_ENDIAN
-# define word0(x) ((x).L[1])
-# define word1(x) ((x).L[0])
-# else
-# define word0(x) ((x).L[0])
-# define word1(x) ((x).L[1])
-# endif
-# define dval(x) ((x).d)
-#endif
-
-/* The following definition of Storeinc is appropriate for MIPS processors.
- * An alternative that might be better on some machines is
- * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
- */
-#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) + defined(__arm__)
-#define Storeinc(a,b,c) (((unsigned short *)(a))[1] = (unsigned short)(b), \
-((unsigned short *)(a))[0] = (unsigned short)(c), (a)++)
-#else
-#define Storeinc(a,b,c) (((unsigned short *)(a))[0] = (unsigned short)(b), \
-((unsigned short *)(a))[1] = (unsigned short)(c), (a)++)
-#endif
-
-/* #define P DBL_MANT_DIG */
-/* Ten_pmax = floor(P*log(2)/log(5)) */
-/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
-/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
-/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
-
-#ifdef IEEE_Arith
-#define Exp_shift 20
-#define Exp_shift1 20
-#define Exp_msk1 0x100000
-#define Exp_msk11 0x100000
-#define Exp_mask 0x7ff00000
-#define P 53
-#define Bias 1023
-#define Emin (-1022)
-#define Exp_1 0x3ff00000
-#define Exp_11 0x3ff00000
-#define Ebits 11
-#define Frac_mask 0xfffff
-#define Frac_mask1 0xfffff
-#define Ten_pmax 22
-#define Bletch 0x10
-#define Bndry_mask 0xfffff
-#define Bndry_mask1 0xfffff
-#define LSB 1
-#define Sign_bit 0x80000000
-#define Log2P 1
-#define Tiny0 0
-#define Tiny1 1
-#define Quick_max 14
-#define Int_max 14
-#ifndef NO_IEEE_Scale
-#define Avoid_Underflow
-#ifdef Flush_Denorm /* debugging option */
-#undef Sudden_Underflow
-#endif
-#endif
-
-#ifndef Flt_Rounds
-#ifdef FLT_ROUNDS
-#define Flt_Rounds FLT_ROUNDS
-#else
-#define Flt_Rounds 1
-#endif
-#endif /*Flt_Rounds*/
-
-#ifdef Honor_FLT_ROUNDS
-#define Rounding rounding
-#undef Check_FLT_ROUNDS
-#define Check_FLT_ROUNDS
-#else
-#define Rounding Flt_Rounds
-#endif
-
-#else /* ifndef IEEE_Arith */
-#undef Check_FLT_ROUNDS
-#undef Honor_FLT_ROUNDS
-#undef SET_INEXACT
-#undef Sudden_Underflow
-#define Sudden_Underflow
-#ifdef IBM
-#undef Flt_Rounds
-#define Flt_Rounds 0
-#define Exp_shift 24
-#define Exp_shift1 24
-#define Exp_msk1 0x1000000
-#define Exp_msk11 0x1000000
-#define Exp_mask 0x7f000000
-#define P 14
-#define Bias 65
-#define Exp_1 0x41000000
-#define Exp_11 0x41000000
-#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
-#define Frac_mask 0xffffff
-#define Frac_mask1 0xffffff
-#define Bletch 4
-#define Ten_pmax 22
-#define Bndry_mask 0xefffff
-#define Bndry_mask1 0xffffff
-#define LSB 1
-#define Sign_bit 0x80000000
-#define Log2P 4
-#define Tiny0 0x100000
-#define Tiny1 0
-#define Quick_max 14
-#define Int_max 15
-#else /* VAX */
-#undef Flt_Rounds
-#define Flt_Rounds 1
-#define Exp_shift 23
-#define Exp_shift1 7
-#define Exp_msk1 0x80
-#define Exp_msk11 0x800000
-#define Exp_mask 0x7f80
-#define P 56
-#define Bias 129
-#define Exp_1 0x40800000
-#define Exp_11 0x4080
-#define Ebits 8
-#define Frac_mask 0x7fffff
-#define Frac_mask1 0xffff007f
-#define Ten_pmax 24
-#define Bletch 2
-#define Bndry_mask 0xffff007f
-#define Bndry_mask1 0xffff007f
-#define LSB 0x10000
-#define Sign_bit 0x8000
-#define Log2P 1
-#define Tiny0 0x80
-#define Tiny1 0
-#define Quick_max 15
-#define Int_max 15
-#endif /* IBM, VAX */
-#endif /* IEEE_Arith */
-
-#ifndef IEEE_Arith
-#define ROUND_BIASED
-#endif
-
-#ifdef RND_PRODQUOT
-#define rounded_product(a,b) ((a) = rnd_prod((a), (b)))
-#define rounded_quotient(a,b) ((a) = rnd_quot((a), (b)))
-extern double rnd_prod(double, double), rnd_quot(double, double);
-#else
-#define rounded_product(a,b) ((a) *= (b))
-#define rounded_quotient(a,b) ((a) /= (b))
-#endif
-
-#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
-#define Big1 0xffffffff
-
-#ifndef Pack_32
-#define Pack_32
-#endif
-
-#define FFFFFFFF 0xffffffffUL
-
-#ifdef NO_LONG_LONG
-#undef ULLong
-#ifdef Just_16
-#undef Pack_32
-/* When Pack_32 is not defined, we store 16 bits per 32-bit Long.
- * This makes some inner loops simpler and sometimes saves work
- * during multiplications, but it often seems to make things slightly
- * slower. Hence the default is now to store 32 bits per Long.
- */
-#endif
-#else /* long long available */
-#ifndef Llong
-#define Llong long long
-#endif
-#ifndef ULLong
-#define ULLong unsigned Llong
-#endif
-#endif /* NO_LONG_LONG */
-
-#define MULTIPLE_THREADS 1
-
-#ifndef MULTIPLE_THREADS
-#define ACQUIRE_DTOA_LOCK(n) /*nothing*/
-#define FREE_DTOA_LOCK(n) /*nothing*/
-#else
-#define ACQUIRE_DTOA_LOCK(n) /*unused right now*/
-#define FREE_DTOA_LOCK(n) /*unused right now*/
-#endif
-
-#define Kmax 15
-
-struct Bigint {
- struct Bigint *next;
- int k, maxwds, sign, wds;
- ULong x[1];
-};
-
-typedef struct Bigint Bigint;
-
-static Bigint *freelist[Kmax+1];
-
-static Bigint *
-Balloc(int k)
-{
- int x;
- Bigint *rv;
-#ifndef Omit_Private_Memory
- size_t len;
-#endif
-
- ACQUIRE_DTOA_LOCK(0);
- if (k <= Kmax && (rv = freelist[k]) != 0) {
- freelist[k] = rv->next;
- }
- else {
- x = 1 << k;
-#ifdef Omit_Private_Memory
- rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
-#else
- len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
- /sizeof(double);
- if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {
- rv = (Bigint*)pmem_next;
- pmem_next += len;
- }
- else
- rv = (Bigint*)MALLOC(len*sizeof(double));
-#endif
- rv->k = k;
- rv->maxwds = x;
- }
- FREE_DTOA_LOCK(0);
- rv->sign = rv->wds = 0;
- return rv;
-}
-
-static void
-Bfree(Bigint *v)
-{
- if (v) {
- if (v->k > Kmax) {
- FREE(v);
- return;
- }
- ACQUIRE_DTOA_LOCK(0);
- v->next = freelist[v->k];
- freelist[v->k] = v;
- FREE_DTOA_LOCK(0);
- }
-}
-
-#define Bcopy(x,y) memcpy((char *)&(x)->sign, (char *)&(y)->sign, \
-(y)->wds*sizeof(Long) + 2*sizeof(int))
-
-static Bigint *
-multadd(Bigint *b, int m, int a) /* multiply by m and add a */
-{
- int i, wds;
- ULong *x;
-#ifdef ULLong
- ULLong carry, y;
-#else
- ULong carry, y;
-#ifdef Pack_32
- ULong xi, z;
-#endif
-#endif
- Bigint *b1;
-
- wds = b->wds;
- x = b->x;
- i = 0;
- carry = a;
- do {
-#ifdef ULLong
- y = *x * (ULLong)m + carry;
- carry = y >> 32;
- *x++ = (ULong)(y & FFFFFFFF);
-#else
-#ifdef Pack_32
- xi = *x;
- y = (xi & 0xffff) * m + carry;
- z = (xi >> 16) * m + (y >> 16);
- carry = z >> 16;
- *x++ = (z << 16) + (y & 0xffff);
-#else
- y = *x * m + carry;
- carry = y >> 16;
- *x++ = y & 0xffff;
-#endif
-#endif
- } while (++i < wds);
- if (carry) {
- if (wds >= b->maxwds) {
- b1 = Balloc(b->k+1);
- Bcopy(b1, b);
- Bfree(b);
- b = b1;
- }
- b->x[wds++] = (ULong)carry;
- b->wds = wds;
- }
- return b;
-}
-
-static Bigint *
-s2b(const char *s, int nd0, int nd, ULong y9)
-{
- Bigint *b;
- int i, k;
- Long x, y;
-
- x = (nd + 8) / 9;
- for (k = 0, y = 1; x > y; y <<= 1, k++) ;
-#ifdef Pack_32
- b = Balloc(k);
- b->x[0] = y9;
- b->wds = 1;
-#else
- b = Balloc(k+1);
- b->x[0] = y9 & 0xffff;
- b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
-#endif
-
- i = 9;
- if (9 < nd0) {
- s += 9;
- do {
- b = multadd(b, 10, *s++ - '0');
- } while (++i < nd0);
- s++;
- }
- else
- s += 10;
- for (; i < nd; i++)
- b = multadd(b, 10, *s++ - '0');
- return b;
-}
-
-static int
-hi0bits(register ULong x)
-{
- register int k = 0;
-
- if (!(x & 0xffff0000)) {
- k = 16;
- x <<= 16;
- }
- if (!(x & 0xff000000)) {
- k += 8;
- x <<= 8;
- }
- if (!(x & 0xf0000000)) {
- k += 4;
- x <<= 4;
- }
- if (!(x & 0xc0000000)) {
- k += 2;
- x <<= 2;
- }
- if (!(x & 0x80000000)) {
- k++;
- if (!(x & 0x40000000))
- return 32;
- }
- return k;
-}
-
-static int
-lo0bits(ULong *y)
-{
- register int k;
- register ULong x = *y;
-
- if (x & 7) {
- if (x & 1)
- return 0;
- if (x & 2) {
- *y = x >> 1;
- return 1;
- }
- *y = x >> 2;
- return 2;
- }
- k = 0;
- if (!(x & 0xffff)) {
- k = 16;
- x >>= 16;
- }
- if (!(x & 0xff)) {
- k += 8;
- x >>= 8;
- }
- if (!(x & 0xf)) {
- k += 4;
- x >>= 4;
- }
- if (!(x & 0x3)) {
- k += 2;
- x >>= 2;
- }
- if (!(x & 1)) {
- k++;
- x >>= 1;
- if (!x)
- return 32;
- }
- *y = x;
- return k;
-}
-
-static Bigint *
-i2b(int i)
-{
- Bigint *b;
-
- b = Balloc(1);
- b->x[0] = i;
- b->wds = 1;
- return b;
-}
-
-static Bigint *
-mult(Bigint *a, Bigint *b)
-{
- Bigint *c;
- int k, wa, wb, wc;
- ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
- ULong y;
-#ifdef ULLong
- ULLong carry, z;
-#else
- ULong carry, z;
-#ifdef Pack_32
- ULong z2;
-#endif
-#endif
-
- if (a->wds < b->wds) {
- c = a;
- a = b;
- b = c;
- }
- k = a->k;
- wa = a->wds;
- wb = b->wds;
- wc = wa + wb;
- if (wc > a->maxwds)
- k++;
- c = Balloc(k);
- for (x = c->x, xa = x + wc; x < xa; x++)
- *x = 0;
- xa = a->x;
- xae = xa + wa;
- xb = b->x;
- xbe = xb + wb;
- xc0 = c->x;
-#ifdef ULLong
- for (; xb < xbe; xc0++) {
- if ((y = *xb++) != 0) {
- x = xa;
- xc = xc0;
- carry = 0;
- do {
- z = *x++ * (ULLong)y + *xc + carry;
- carry = z >> 32;
- *xc++ = (ULong)(z & FFFFFFFF);
- } while (x < xae);
- *xc = (ULong)carry;
- }
- }
-#else
-#ifdef Pack_32
- for (; xb < xbe; xb++, xc0++) {
- if ((y = *xb & 0xffff) != 0) {
- x = xa;
- xc = xc0;
- carry = 0;
- do {
- z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
- carry = z >> 16;
- z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
- carry = z2 >> 16;
- Storeinc(xc, z2, z);
- } while (x < xae);
- *xc = (ULong)carry;
- }
- if ((y = *xb >> 16) != 0) {
- x = xa;
- xc = xc0;
- carry = 0;
- z2 = *xc;
- do {
- z = (*x & 0xffff) * y + (*xc >> 16) + carry;
- carry = z >> 16;
- Storeinc(xc, z, z2);
- z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
- carry = z2 >> 16;
- } while (x < xae);
- *xc = z2;
- }
- }
-#else
- for (; xb < xbe; xc0++) {
- if (y = *xb++) {
- x = xa;
- xc = xc0;
- carry = 0;
- do {
- z = *x++ * y + *xc + carry;
- carry = z >> 16;
- *xc++ = z & 0xffff;
- } while (x < xae);
- *xc = (ULong)carry;
- }
- }
-#endif
-#endif
- for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
- c->wds = wc;
- return c;
-}
-
-static Bigint *p5s;
-
-static Bigint *
-pow5mult(Bigint *b, int k)
-{
- Bigint *b1, *p5, *p51;
- int i;
- static int p05[3] = { 5, 25, 125 };
-
- if ((i = k & 3) != 0)
- b = multadd(b, p05[i-1], 0);
-
- if (!(k >>= 2))
- return b;
- if (!(p5 = p5s)) {
- /* first time */
-#ifdef MULTIPLE_THREADS
- ACQUIRE_DTOA_LOCK(1);
- if (!(p5 = p5s)) {
- p5 = p5s = i2b(625);
- p5->next = 0;
- }
- FREE_DTOA_LOCK(1);
-#else
- p5 = p5s = i2b(625);
- p5->next = 0;
-#endif
- }
- for (;;) {
- if (k & 1) {
- b1 = mult(b, p5);
- Bfree(b);
- b = b1;
- }
- if (!(k >>= 1))
- break;
- if (!(p51 = p5->next)) {
-#ifdef MULTIPLE_THREADS
- ACQUIRE_DTOA_LOCK(1);
- if (!(p51 = p5->next)) {
- p51 = p5->next = mult(p5,p5);
- p51->next = 0;
- }
- FREE_DTOA_LOCK(1);
-#else
- p51 = p5->next = mult(p5,p5);
- p51->next = 0;
-#endif
- }
- p5 = p51;
- }
- return b;
-}
-
-static Bigint *
-lshift(Bigint *b, int k)
-{
- int i, k1, n, n1;
- Bigint *b1;
- ULong *x, *x1, *xe, z;
-
-#ifdef Pack_32
- n = k >> 5;
-#else
- n = k >> 4;
-#endif
- k1 = b->k;
- n1 = n + b->wds + 1;
- for (i = b->maxwds; n1 > i; i <<= 1)
- k1++;
- b1 = Balloc(k1);
- x1 = b1->x;
- for (i = 0; i < n; i++)
- *x1++ = 0;
- x = b->x;
- xe = x + b->wds;
-#ifdef Pack_32
- if (k &= 0x1f) {
- k1 = 32 - k;
- z = 0;
- do {
- *x1++ = *x << k | z;
- z = *x++ >> k1;
- } while (x < xe);
- if ((*x1 = z) != 0)
- ++n1;
- }
-#else
- if (k &= 0xf) {
- k1 = 16 - k;
- z = 0;
- do {
- *x1++ = *x << k & 0xffff | z;
- z = *x++ >> k1;
- } while (x < xe);
- if (*x1 = z)
- ++n1;
- }
-#endif
- else
- do {
- *x1++ = *x++;
- } while (x < xe);
- b1->wds = n1 - 1;
- Bfree(b);
- return b1;
-}
-
-static int
-cmp(Bigint *a, Bigint *b)
-{
- ULong *xa, *xa0, *xb, *xb0;
- int i, j;
-
- i = a->wds;
- j = b->wds;
-#ifdef DEBUG
- if (i > 1 && !a->x[i-1])
- Bug("cmp called with a->x[a->wds-1] == 0");
- if (j > 1 && !b->x[j-1])
- Bug("cmp called with b->x[b->wds-1] == 0");
-#endif
- if (i -= j)
- return i;
- xa0 = a->x;
- xa = xa0 + j;
- xb0 = b->x;
- xb = xb0 + j;
- for (;;) {
- if (*--xa != *--xb)
- return *xa < *xb ? -1 : 1;
- if (xa <= xa0)
- break;
- }
- return 0;
-}
-
-NO_SANITIZE("unsigned-integer-overflow", static Bigint * diff(Bigint *a, Bigint *b));
-static Bigint *
-diff(Bigint *a, Bigint *b)
-{
- Bigint *c;
- int i, wa, wb;
- ULong *xa, *xae, *xb, *xbe, *xc;
-#ifdef ULLong
- ULLong borrow, y;
-#else
- ULong borrow, y;
-#ifdef Pack_32
- ULong z;
-#endif
-#endif
-
- i = cmp(a,b);
- if (!i) {
- c = Balloc(0);
- c->wds = 1;
- c->x[0] = 0;
- return c;
- }
- if (i < 0) {
- c = a;
- a = b;
- b = c;
- i = 1;
- }
- else
- i = 0;
- c = Balloc(a->k);
- c->sign = i;
- wa = a->wds;
- xa = a->x;
- xae = xa + wa;
- wb = b->wds;
- xb = b->x;
- xbe = xb + wb;
- xc = c->x;
- borrow = 0;
-#ifdef ULLong
- do {
- y = (ULLong)*xa++ - *xb++ - borrow;
- borrow = y >> 32 & (ULong)1;
- *xc++ = (ULong)(y & FFFFFFFF);
- } while (xb < xbe);
- while (xa < xae) {
- y = *xa++ - borrow;
- borrow = y >> 32 & (ULong)1;
- *xc++ = (ULong)(y & FFFFFFFF);
- }
-#else
-#ifdef Pack_32
- do {
- y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(xc, z, y);
- } while (xb < xbe);
- while (xa < xae) {
- y = (*xa & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*xa++ >> 16) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(xc, z, y);
- }
-#else
- do {
- y = *xa++ - *xb++ - borrow;
- borrow = (y & 0x10000) >> 16;
- *xc++ = y & 0xffff;
- } while (xb < xbe);
- while (xa < xae) {
- y = *xa++ - borrow;
- borrow = (y & 0x10000) >> 16;
- *xc++ = y & 0xffff;
- }
-#endif
-#endif
- while (!*--xc)
- wa--;
- c->wds = wa;
- return c;
-}
-
-static double
-ulp(double x_)
-{
- register Long L;
- double_u x, a;
- dval(x) = x_;
-
- L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
-#ifndef Avoid_Underflow
-#ifndef Sudden_Underflow
- if (L > 0) {
-#endif
-#endif
-#ifdef IBM
- L |= Exp_msk1 >> 4;
-#endif
- word0(a) = L;
- word1(a) = 0;
-#ifndef Avoid_Underflow
-#ifndef Sudden_Underflow
- }
- else {
- L = -L >> Exp_shift;
- if (L < Exp_shift) {
- word0(a) = 0x80000 >> L;
- word1(a) = 0;
- }
- else {
- word0(a) = 0;
- L -= Exp_shift;
- word1(a) = L >= 31 ? 1 : 1 << 31 - L;
- }
- }
-#endif
-#endif
- return dval(a);
-}
-
-static double
-b2d(Bigint *a, int *e)
-{
- ULong *xa, *xa0, w, y, z;
- int k;
- double_u d;
-#ifdef VAX
- ULong d0, d1;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
-#endif
-
- xa0 = a->x;
- xa = xa0 + a->wds;
- y = *--xa;
-#ifdef DEBUG
- if (!y) Bug("zero y in b2d");
-#endif
- k = hi0bits(y);
- *e = 32 - k;
-#ifdef Pack_32
- if (k < Ebits) {
- d0 = Exp_1 | y >> (Ebits - k);
- w = xa > xa0 ? *--xa : 0;
- d1 = y << ((32-Ebits) + k) | w >> (Ebits - k);
- goto ret_d;
- }
- z = xa > xa0 ? *--xa : 0;
- if (k -= Ebits) {
- d0 = Exp_1 | y << k | z >> (32 - k);
- y = xa > xa0 ? *--xa : 0;
- d1 = z << k | y >> (32 - k);
- }
- else {
- d0 = Exp_1 | y;
- d1 = z;
- }
-#else
- if (k < Ebits + 16) {
- z = xa > xa0 ? *--xa : 0;
- d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
- w = xa > xa0 ? *--xa : 0;
- y = xa > xa0 ? *--xa : 0;
- d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
- goto ret_d;
- }
- z = xa > xa0 ? *--xa : 0;
- w = xa > xa0 ? *--xa : 0;
- k -= Ebits + 16;
- d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
- y = xa > xa0 ? *--xa : 0;
- d1 = w << k + 16 | y << k;
-#endif
-ret_d:
-#ifdef VAX
- word0(d) = d0 >> 16 | d0 << 16;
- word1(d) = d1 >> 16 | d1 << 16;
-#else
-#undef d0
-#undef d1
-#endif
- return dval(d);
-}
-
-static Bigint *
-d2b(double d_, int *e, int *bits)
-{
- double_u d;
- Bigint *b;
- int de, k;
- ULong *x, y, z;
-#ifndef Sudden_Underflow
- int i;
-#endif
-#ifdef VAX
- ULong d0, d1;
-#endif
- dval(d) = d_;
-#ifdef VAX
- d0 = word0(d) >> 16 | word0(d) << 16;
- d1 = word1(d) >> 16 | word1(d) << 16;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
-#endif
-
-#ifdef Pack_32
- b = Balloc(1);
-#else
- b = Balloc(2);
-#endif
- x = b->x;
-
- z = d0 & Frac_mask;
- d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
-#ifdef Sudden_Underflow
- de = (int)(d0 >> Exp_shift);
-#ifndef IBM
- z |= Exp_msk11;
-#endif
-#else
- if ((de = (int)(d0 >> Exp_shift)) != 0)
- z |= Exp_msk1;
-#endif
-#ifdef Pack_32
- if ((y = d1) != 0) {
- if ((k = lo0bits(&y)) != 0) {
- x[0] = y | z << (32 - k);
- z >>= k;
- }
- else
- x[0] = y;
-#ifndef Sudden_Underflow
- i =
-#endif
- b->wds = (x[1] = z) ? 2 : 1;
- }
- else {
-#ifdef DEBUG
- if (!z)
- Bug("Zero passed to d2b");
-#endif
- k = lo0bits(&z);
- x[0] = z;
-#ifndef Sudden_Underflow
- i =
-#endif
- b->wds = 1;
- k += 32;
- }
-#else
- if (y = d1) {
- if (k = lo0bits(&y))
- if (k >= 16) {
- x[0] = y | z << 32 - k & 0xffff;
- x[1] = z >> k - 16 & 0xffff;
- x[2] = z >> k;
- i = 2;
- }
- else {
- x[0] = y & 0xffff;
- x[1] = y >> 16 | z << 16 - k & 0xffff;
- x[2] = z >> k & 0xffff;
- x[3] = z >> k+16;
- i = 3;
- }
- else {
- x[0] = y & 0xffff;
- x[1] = y >> 16;
- x[2] = z & 0xffff;
- x[3] = z >> 16;
- i = 3;
- }
- }
- else {
-#ifdef DEBUG
- if (!z)
- Bug("Zero passed to d2b");
-#endif
- k = lo0bits(&z);
- if (k >= 16) {
- x[0] = z;
- i = 0;
- }
- else {
- x[0] = z & 0xffff;
- x[1] = z >> 16;
- i = 1;
- }
- k += 32;
- }
- while (!x[i])
- --i;
- b->wds = i + 1;
-#endif
-#ifndef Sudden_Underflow
- if (de) {
-#endif
-#ifdef IBM
- *e = (de - Bias - (P-1) << 2) + k;
- *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
-#else
- *e = de - Bias - (P-1) + k;
- *bits = P - k;
-#endif
-#ifndef Sudden_Underflow
- }
- else {
- *e = de - Bias - (P-1) + 1 + k;
-#ifdef Pack_32
- *bits = 32*i - hi0bits(x[i-1]);
-#else
- *bits = (i+2)*16 - hi0bits(x[i]);
-#endif
- }
-#endif
- return b;
-}
-#undef d0
-#undef d1
-
-static double
-ratio(Bigint *a, Bigint *b)
-{
- double_u da, db;
- int k, ka, kb;
-
- dval(da) = b2d(a, &ka);
- dval(db) = b2d(b, &kb);
-#ifdef Pack_32
- k = ka - kb + 32*(a->wds - b->wds);
-#else
- k = ka - kb + 16*(a->wds - b->wds);
-#endif
-#ifdef IBM
- if (k > 0) {
- word0(da) += (k >> 2)*Exp_msk1;
- if (k &= 3)
- dval(da) *= 1 << k;
- }
- else {
- k = -k;
- word0(db) += (k >> 2)*Exp_msk1;
- if (k &= 3)
- dval(db) *= 1 << k;
- }
-#else
- if (k > 0)
- word0(da) += k*Exp_msk1;
- else {
- k = -k;
- word0(db) += k*Exp_msk1;
- }
-#endif
- return dval(da) / dval(db);
-}
-
-static const double
-tens[] = {
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
- 1e20, 1e21, 1e22
-#ifdef VAX
- , 1e23, 1e24
-#endif
-};
-
-static const double
-#ifdef IEEE_Arith
-bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
-static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
-#ifdef Avoid_Underflow
- 9007199254740992.*9007199254740992.e-256
- /* = 2^106 * 1e-53 */
-#else
- 1e-256
-#endif
-};
-/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
-/* flag unnecessarily. It leads to a song and dance at the end of strtod. */
-#define Scale_Bit 0x10
-#define n_bigtens 5
-#else
-#ifdef IBM
-bigtens[] = { 1e16, 1e32, 1e64 };
-static const double tinytens[] = { 1e-16, 1e-32, 1e-64 };
-#define n_bigtens 3
-#else
-bigtens[] = { 1e16, 1e32 };
-static const double tinytens[] = { 1e-16, 1e-32 };
-#define n_bigtens 2
-#endif
-#endif
-
-#ifndef IEEE_Arith
-#undef INFNAN_CHECK
-#endif
-
-#ifdef INFNAN_CHECK
-
-#ifndef NAN_WORD0
-#define NAN_WORD0 0x7ff80000
-#endif
-
-#ifndef NAN_WORD1
-#define NAN_WORD1 0
-#endif
-
-static int
-match(const char **sp, char *t)
-{
- int c, d;
- const char *s = *sp;
-
- while (d = *t++) {
- if ((c = *++s) >= 'A' && c <= 'Z')
- c += 'a' - 'A';
- if (c != d)
- return 0;
- }
- *sp = s + 1;
- return 1;
-}
-
-#ifndef No_Hex_NaN
-static void
-hexnan(double *rvp, const char **sp)
-{
- ULong c, x[2];
- const char *s;
- int havedig, udx0, xshift;
-
- x[0] = x[1] = 0;
- havedig = xshift = 0;
- udx0 = 1;
- s = *sp;
- while (c = *(const unsigned char*)++s) {
- if (c >= '0' && c <= '9')
- c -= '0';
- else if (c >= 'a' && c <= 'f')
- c += 10 - 'a';
- else if (c >= 'A' && c <= 'F')
- c += 10 - 'A';
- else if (c <= ' ') {
- if (udx0 && havedig) {
- udx0 = 0;
- xshift = 1;
- }
- continue;
- }
- else if (/*(*/ c == ')' && havedig) {
- *sp = s + 1;
- break;
- }
- else
- return; /* invalid form: don't change *sp */
- havedig = 1;
- if (xshift) {
- xshift = 0;
- x[0] = x[1];
- x[1] = 0;
- }
- if (udx0)
- x[0] = (x[0] << 4) | (x[1] >> 28);
- x[1] = (x[1] << 4) | c;
- }
- if ((x[0] &= 0xfffff) || x[1]) {
- word0(*rvp) = Exp_mask | x[0];
- word1(*rvp) = x[1];
- }
-}
-#endif /*No_Hex_NaN*/
-#endif /* INFNAN_CHECK */
-
-NO_SANITIZE("unsigned-integer-overflow", double strtod(const char *s00, char **se));
-double
-strtod(const char *s00, char **se)
-{
-#ifdef Avoid_Underflow
- int scale;
-#endif
- int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
- e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
- const char *s, *s0, *s1;
- double aadj, adj;
- double_u aadj1, rv, rv0;
- Long L;
- ULong y, z;
- Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
-#ifdef SET_INEXACT
- int inexact, oldinexact;
-#endif
-#ifdef Honor_FLT_ROUNDS
- int rounding;
-#endif
-#ifdef USE_LOCALE
- const char *s2;
-#endif
-
- errno = 0;
- sign = nz0 = nz = 0;
- dval(rv) = 0.;
- for (s = s00;;s++)
- switch (*s) {
- case '-':
- sign = 1;
- /* no break */
- case '+':
- if (*++s)
- goto break2;
- /* no break */
- case 0:
- goto ret0;
- case '\t':
- case '\n':
- case '\v':
- case '\f':
- case '\r':
- case ' ':
- continue;
- default:
- goto break2;
- }
-break2:
- if (*s == '0') {
- if (s[1] == 'x' || s[1] == 'X') {
- s0 = ++s;
- adj = 0;
- aadj = 1.0;
- nd0 = -4;
-
- if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
- if (*s == '0') {
- while (*++s == '0');
- s1 = strchr(hexdigit, *s);
- }
- if (s1 != NULL) {
- do {
- adj += aadj * ((s1 - hexdigit) & 15);
- nd0 += 4;
- aadj /= 16;
- } while (*++s && (s1 = strchr(hexdigit, *s)));
- }
-
- if (*s == '.') {
- dsign = 1;
- if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
- if (nd0 < 0) {
- while (*s == '0') {
- s++;
- nd0 -= 4;
- }
- }
- for (; *s && (s1 = strchr(hexdigit, *s)); ++s) {
- adj += aadj * ((s1 - hexdigit) & 15);
- if ((aadj /= 16) == 0.0) {
- while (strchr(hexdigit, *++s));
- break;
- }
- }
- }
- else {
- dsign = 0;
- }
-
- if (*s == 'P' || *s == 'p') {
- dsign = 0x2C - *++s; /* +: 2B, -: 2D */
- if (abs(dsign) == 1) s++;
- else dsign = 1;
-
- nd = 0;
- c = *s;
- if (c < '0' || '9' < c) goto ret0;
- do {
- nd *= 10;
- nd += c;
- nd -= '0';
- c = *++s;
- /* Float("0x0."+("0"*267)+"1fp2095") */
- if (nd + dsign * nd0 > 2095) {
- while ('0' <= c && c <= '9') c = *++s;
- break;
- }
- } while ('0' <= c && c <= '9');
- nd0 += nd * dsign;
- }
- else {
- if (dsign) goto ret0;
- }
- dval(rv) = ldexp(adj, nd0);
- goto ret;
- }
- nz0 = 1;
- while (*++s == '0') ;
- if (!*s)
- goto ret;
- }
- s0 = s;
- y = z = 0;
- for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
- if (nd < 9)
- y = 10*y + c - '0';
- else if (nd < DBL_DIG + 2)
- z = 10*z + c - '0';
- nd0 = nd;
-#ifdef USE_LOCALE
- s1 = localeconv()->decimal_point;
- if (c == *s1) {
- c = '.';
- if (*++s1) {
- s2 = s;
- for (;;) {
- if (*++s2 != *s1) {
- c = 0;
- break;
- }
- if (!*++s1) {
- s = s2;
- break;
- }
- }
- }
- }
-#endif
- if (c == '.') {
- if (!ISDIGIT(s[1]))
- goto dig_done;
- c = *++s;
- if (!nd) {
- for (; c == '0'; c = *++s)
- nz++;
- if (c > '0' && c <= '9') {
- s0 = s;
- nf += nz;
- nz = 0;
- goto have_dig;
- }
- goto dig_done;
- }
- for (; c >= '0' && c <= '9'; c = *++s) {
-have_dig:
- nz++;
- if (nd > DBL_DIG * 4) {
- continue;
- }
- if (c -= '0') {
- nf += nz;
- for (i = 1; i < nz; i++)
- if (nd++ < 9)
- y *= 10;
- else if (nd <= DBL_DIG + 2)
- z *= 10;
- if (nd++ < 9)
- y = 10*y + c;
- else if (nd <= DBL_DIG + 2)
- z = 10*z + c;
- nz = 0;
- }
- }
- }
-dig_done:
- e = 0;
- if (c == 'e' || c == 'E') {
- if (!nd && !nz && !nz0) {
- goto ret0;
- }
- s00 = s;
- esign = 0;
- switch (c = *++s) {
- case '-':
- esign = 1;
- case '+':
- c = *++s;
- }
- if (c >= '0' && c <= '9') {
- while (c == '0')
- c = *++s;
- if (c > '0' && c <= '9') {
- L = c - '0';
- s1 = s;
- while ((c = *++s) >= '0' && c <= '9')
- L = 10*L + c - '0';
- if (s - s1 > 8 || L > 19999)
- /* Avoid confusion from exponents
- * so large that e might overflow.
- */
- e = 19999; /* safe for 16 bit ints */
- else
- e = (int)L;
- if (esign)
- e = -e;
- }
- else
- e = 0;
- }
- else
- s = s00;
- }
- if (!nd) {
- if (!nz && !nz0) {
-#ifdef INFNAN_CHECK
- /* Check for Nan and Infinity */
- switch (c) {
- case 'i':
- case 'I':
- if (match(&s,"nf")) {
- --s;
- if (!match(&s,"inity"))
- ++s;
- word0(rv) = 0x7ff00000;
- word1(rv) = 0;
- goto ret;
- }
- break;
- case 'n':
- case 'N':
- if (match(&s, "an")) {
- word0(rv) = NAN_WORD0;
- word1(rv) = NAN_WORD1;
-#ifndef No_Hex_NaN
- if (*s == '(') /*)*/
- hexnan(&rv, &s);
-#endif
- goto ret;
- }
- }
-#endif /* INFNAN_CHECK */
-ret0:
- s = s00;
- sign = 0;
- }
- goto ret;
- }
- e1 = e -= nf;
-
- /* Now we have nd0 digits, starting at s0, followed by a
- * decimal point, followed by nd-nd0 digits. The number we're
- * after is the integer represented by those digits times
- * 10**e */
-
- if (!nd0)
- nd0 = nd;
- k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2;
- dval(rv) = y;
- if (k > 9) {
-#ifdef SET_INEXACT
- if (k > DBL_DIG)
- oldinexact = get_inexact();
-#endif
- dval(rv) = tens[k - 9] * dval(rv) + z;
- }
- bd0 = bb = bd = bs = delta = 0;
- if (nd <= DBL_DIG
-#ifndef RND_PRODQUOT
-#ifndef Honor_FLT_ROUNDS
- && Flt_Rounds == 1
-#endif
-#endif
- ) {
- if (!e)
- goto ret;
- if (e > 0) {
- if (e <= Ten_pmax) {
-#ifdef VAX
- goto vax_ovfl_check;
-#else
-#ifdef Honor_FLT_ROUNDS
- /* round correctly FLT_ROUNDS = 2 or 3 */
- if (sign) {
- dval(rv) = -dval(rv);
- sign = 0;
- }
-#endif
- /* rv = */ rounded_product(dval(rv), tens[e]);
- goto ret;
-#endif
- }
- i = DBL_DIG - nd;
- if (e <= Ten_pmax + i) {
- /* A fancier test would sometimes let us do
- * this for larger i values.
- */
-#ifdef Honor_FLT_ROUNDS
- /* round correctly FLT_ROUNDS = 2 or 3 */
- if (sign) {
- dval(rv) = -dval(rv);
- sign = 0;
- }
-#endif
- e -= i;
- dval(rv) *= tens[i];
-#ifdef VAX
- /* VAX exponent range is so narrow we must
- * worry about overflow here...
- */
-vax_ovfl_check:
- word0(rv) -= P*Exp_msk1;
- /* rv = */ rounded_product(dval(rv), tens[e]);
- if ((word0(rv) & Exp_mask)
- > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
- goto ovfl;
- word0(rv) += P*Exp_msk1;
-#else
- /* rv = */ rounded_product(dval(rv), tens[e]);
-#endif
- goto ret;
- }
- }
-#ifndef Inaccurate_Divide
- else if (e >= -Ten_pmax) {
-#ifdef Honor_FLT_ROUNDS
- /* round correctly FLT_ROUNDS = 2 or 3 */
- if (sign) {
- dval(rv) = -dval(rv);
- sign = 0;
- }
-#endif
- /* rv = */ rounded_quotient(dval(rv), tens[-e]);
- goto ret;
- }
-#endif
- }
- e1 += nd - k;
-
-#ifdef IEEE_Arith
-#ifdef SET_INEXACT
- inexact = 1;
- if (k <= DBL_DIG)
- oldinexact = get_inexact();
-#endif
-#ifdef Avoid_Underflow
- scale = 0;
-#endif
-#ifdef Honor_FLT_ROUNDS
- if ((rounding = Flt_Rounds) >= 2) {
- if (sign)
- rounding = rounding == 2 ? 0 : 2;
- else
- if (rounding != 2)
- rounding = 0;
- }
-#endif
-#endif /*IEEE_Arith*/
-
- /* Get starting approximation = rv * 10**e1 */
-
- if (e1 > 0) {
- if ((i = e1 & 15) != 0)
- dval(rv) *= tens[i];
- if (e1 &= ~15) {
- if (e1 > DBL_MAX_10_EXP) {
-ovfl:
-#ifndef NO_ERRNO
- errno = ERANGE;
-#endif
- /* Can't trust HUGE_VAL */
-#ifdef IEEE_Arith
-#ifdef Honor_FLT_ROUNDS
- switch (rounding) {
- case 0: /* toward 0 */
- case 3: /* toward -infinity */
- word0(rv) = Big0;
- word1(rv) = Big1;
- break;
- default:
- word0(rv) = Exp_mask;
- word1(rv) = 0;
- }
-#else /*Honor_FLT_ROUNDS*/
- word0(rv) = Exp_mask;
- word1(rv) = 0;
-#endif /*Honor_FLT_ROUNDS*/
-#ifdef SET_INEXACT
- /* set overflow bit */
- dval(rv0) = 1e300;
- dval(rv0) *= dval(rv0);
-#endif
-#else /*IEEE_Arith*/
- word0(rv) = Big0;
- word1(rv) = Big1;
-#endif /*IEEE_Arith*/
- if (bd0)
- goto retfree;
- goto ret;
- }
- e1 >>= 4;
- for (j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- dval(rv) *= bigtens[j];
- /* The last multiplication could overflow. */
- word0(rv) -= P*Exp_msk1;
- dval(rv) *= bigtens[j];
- if ((z = word0(rv) & Exp_mask)
- > Exp_msk1*(DBL_MAX_EXP+Bias-P))
- goto ovfl;
- if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
- /* set to largest number */
- /* (Can't trust DBL_MAX) */
- word0(rv) = Big0;
- word1(rv) = Big1;
- }
- else
- word0(rv) += P*Exp_msk1;
- }
- }
- else if (e1 < 0) {
- e1 = -e1;
- if ((i = e1 & 15) != 0)
- dval(rv) /= tens[i];
- if (e1 >>= 4) {
- if (e1 >= 1 << n_bigtens)
- goto undfl;
-#ifdef Avoid_Underflow
- if (e1 & Scale_Bit)
- scale = 2*P;
- for (j = 0; e1 > 0; j++, e1 >>= 1)
- if (e1 & 1)
- dval(rv) *= tinytens[j];
- if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask)
- >> Exp_shift)) > 0) {
- /* scaled rv is denormal; zap j low bits */
- if (j >= 32) {
- word1(rv) = 0;
- if (j >= 53)
- word0(rv) = (P+2)*Exp_msk1;
- else
- word0(rv) &= 0xffffffff << (j-32);
- }
- else
- word1(rv) &= 0xffffffff << j;
- }
-#else
- for (j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- dval(rv) *= tinytens[j];
- /* The last multiplication could underflow. */
- dval(rv0) = dval(rv);
- dval(rv) *= tinytens[j];
- if (!dval(rv)) {
- dval(rv) = 2.*dval(rv0);
- dval(rv) *= tinytens[j];
-#endif
- if (!dval(rv)) {
-undfl:
- dval(rv) = 0.;
-#ifndef NO_ERRNO
- errno = ERANGE;
-#endif
- if (bd0)
- goto retfree;
- goto ret;
- }
-#ifndef Avoid_Underflow
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
- /* The refinement below will clean
- * this approximation up.
- */
- }
-#endif
- }
- }
-
- /* Now the hard part -- adjusting rv to the correct value.*/
-
- /* Put digits into bd: true value = bd * 10^e */
-
- bd0 = s2b(s0, nd0, nd, y);
-
- for (;;) {
- bd = Balloc(bd0->k);
- Bcopy(bd, bd0);
- bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
- bs = i2b(1);
-
- if (e >= 0) {
- bb2 = bb5 = 0;
- bd2 = bd5 = e;
- }
- else {
- bb2 = bb5 = -e;
- bd2 = bd5 = 0;
- }
- if (bbe >= 0)
- bb2 += bbe;
- else
- bd2 -= bbe;
- bs2 = bb2;
-#ifdef Honor_FLT_ROUNDS
- if (rounding != 1)
- bs2++;
-#endif
-#ifdef Avoid_Underflow
- j = bbe - scale;
- i = j + bbbits - 1; /* logb(rv) */
- if (i < Emin) /* denormal */
- j += P - Emin;
- else
- j = P + 1 - bbbits;
-#else /*Avoid_Underflow*/
-#ifdef Sudden_Underflow
-#ifdef IBM
- j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
-#else
- j = P + 1 - bbbits;
-#endif
-#else /*Sudden_Underflow*/
- j = bbe;
- i = j + bbbits - 1; /* logb(rv) */
- if (i < Emin) /* denormal */
- j += P - Emin;
- else
- j = P + 1 - bbbits;
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- bb2 += j;
- bd2 += j;
-#ifdef Avoid_Underflow
- bd2 += scale;
-#endif
- i = bb2 < bd2 ? bb2 : bd2;
- if (i > bs2)
- i = bs2;
- if (i > 0) {
- bb2 -= i;
- bd2 -= i;
- bs2 -= i;
- }
- if (bb5 > 0) {
- bs = pow5mult(bs, bb5);
- bb1 = mult(bs, bb);
- Bfree(bb);
- bb = bb1;
- }
- if (bb2 > 0)
- bb = lshift(bb, bb2);
- if (bd5 > 0)
- bd = pow5mult(bd, bd5);
- if (bd2 > 0)
- bd = lshift(bd, bd2);
- if (bs2 > 0)
- bs = lshift(bs, bs2);
- delta = diff(bb, bd);
- dsign = delta->sign;
- delta->sign = 0;
- i = cmp(delta, bs);
-#ifdef Honor_FLT_ROUNDS
- if (rounding != 1) {
- if (i < 0) {
- /* Error is less than an ulp */
- if (!delta->x[0] && delta->wds <= 1) {
- /* exact */
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- break;
- }
- if (rounding) {
- if (dsign) {
- adj = 1.;
- goto apply_adj;
- }
- }
- else if (!dsign) {
- adj = -1.;
- if (!word1(rv)
- && !(word0(rv) & Frac_mask)) {
- y = word0(rv) & Exp_mask;
-#ifdef Avoid_Underflow
- if (!scale || y > 2*P*Exp_msk1)
-#else
- if (y)
-#endif
- {
- delta = lshift(delta,Log2P);
- if (cmp(delta, bs) <= 0)
- adj = -0.5;
- }
- }
-apply_adj:
-#ifdef Avoid_Underflow
- if (scale && (y = word0(rv) & Exp_mask)
- <= 2*P*Exp_msk1)
- word0(adj) += (2*P+1)*Exp_msk1 - y;
-#else
-#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <=
- P*Exp_msk1) {
- word0(rv) += P*Exp_msk1;
- dval(rv) += adj*ulp(dval(rv));
- word0(rv) -= P*Exp_msk1;
- }
- else
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- dval(rv) += adj*ulp(dval(rv));
- }
- break;
- }
- adj = ratio(delta, bs);
- if (adj < 1.)
- adj = 1.;
- if (adj <= 0x7ffffffe) {
- /* adj = rounding ? ceil(adj) : floor(adj); */
- y = adj;
- if (y != adj) {
- if (!((rounding>>1) ^ dsign))
- y++;
- adj = y;
- }
- }
-#ifdef Avoid_Underflow
- if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
- word0(adj) += (2*P+1)*Exp_msk1 - y;
-#else
-#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
- word0(rv) += P*Exp_msk1;
- adj *= ulp(dval(rv));
- if (dsign)
- dval(rv) += adj;
- else
- dval(rv) -= adj;
- word0(rv) -= P*Exp_msk1;
- goto cont;
- }
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- adj *= ulp(dval(rv));
- if (dsign)
- dval(rv) += adj;
- else
- dval(rv) -= adj;
- goto cont;
- }
-#endif /*Honor_FLT_ROUNDS*/
-
- if (i < 0) {
- /* Error is less than half an ulp -- check for
- * special case of mantissa a power of two.
- */
- if (dsign || word1(rv) || word0(rv) & Bndry_mask
-#ifdef IEEE_Arith
-#ifdef Avoid_Underflow
- || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1
-#else
- || (word0(rv) & Exp_mask) <= Exp_msk1
-#endif
-#endif
- ) {
-#ifdef SET_INEXACT
- if (!delta->x[0] && delta->wds <= 1)
- inexact = 0;
-#endif
- break;
- }
- if (!delta->x[0] && delta->wds <= 1) {
- /* exact result */
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- break;
- }
- delta = lshift(delta,Log2P);
- if (cmp(delta, bs) > 0)
- goto drop_down;
- break;
- }
- if (i == 0) {
- /* exactly half-way between */
- if (dsign) {
- if ((word0(rv) & Bndry_mask1) == Bndry_mask1
- && word1(rv) == (
-#ifdef Avoid_Underflow
- (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
- ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
-#endif
- 0xffffffff)) {
- /*boundary case -- increment exponent*/
- word0(rv) = (word0(rv) & Exp_mask)
- + Exp_msk1
-#ifdef IBM
- | Exp_msk1 >> 4
-#endif
- ;
- word1(rv) = 0;
-#ifdef Avoid_Underflow
- dsign = 0;
-#endif
- break;
- }
- }
- else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
-drop_down:
- /* boundary case -- decrement exponent */
-#ifdef Sudden_Underflow /*{{*/
- L = word0(rv) & Exp_mask;
-#ifdef IBM
- if (L < Exp_msk1)
-#else
-#ifdef Avoid_Underflow
- if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1))
-#else
- if (L <= Exp_msk1)
-#endif /*Avoid_Underflow*/
-#endif /*IBM*/
- goto undfl;
- L -= Exp_msk1;
-#else /*Sudden_Underflow}{*/
-#ifdef Avoid_Underflow
- if (scale) {
- L = word0(rv) & Exp_mask;
- if (L <= (2*P+1)*Exp_msk1) {
- if (L > (P+2)*Exp_msk1)
- /* round even ==> */
- /* accept rv */
- break;
- /* rv = smallest denormal */
- goto undfl;
- }
- }
-#endif /*Avoid_Underflow*/
- L = (word0(rv) & Exp_mask) - Exp_msk1;
-#endif /*Sudden_Underflow}}*/
- word0(rv) = L | Bndry_mask1;
- word1(rv) = 0xffffffff;
-#ifdef IBM
- goto cont;
-#else
- break;
-#endif
- }
-#ifndef ROUND_BIASED
- if (!(word1(rv) & LSB))
- break;
-#endif
- if (dsign)
- dval(rv) += ulp(dval(rv));
-#ifndef ROUND_BIASED
- else {
- dval(rv) -= ulp(dval(rv));
-#ifndef Sudden_Underflow
- if (!dval(rv))
- goto undfl;
-#endif
- }
-#ifdef Avoid_Underflow
- dsign = 1 - dsign;
-#endif
-#endif
- break;
- }
- if ((aadj = ratio(delta, bs)) <= 2.) {
- if (dsign)
- aadj = dval(aadj1) = 1.;
- else if (word1(rv) || word0(rv) & Bndry_mask) {
-#ifndef Sudden_Underflow
- if (word1(rv) == Tiny1 && !word0(rv))
- goto undfl;
-#endif
- aadj = 1.;
- dval(aadj1) = -1.;
- }
- else {
- /* special case -- power of FLT_RADIX to be */
- /* rounded down... */
-
- if (aadj < 2./FLT_RADIX)
- aadj = 1./FLT_RADIX;
- else
- aadj *= 0.5;
- dval(aadj1) = -aadj;
- }
- }
- else {
- aadj *= 0.5;
- dval(aadj1) = dsign ? aadj : -aadj;
-#ifdef Check_FLT_ROUNDS
- switch (Rounding) {
- case 2: /* towards +infinity */
- dval(aadj1) -= 0.5;
- break;
- case 0: /* towards 0 */
- case 3: /* towards -infinity */
- dval(aadj1) += 0.5;
- }
-#else
- if (Flt_Rounds == 0)
- dval(aadj1) += 0.5;
-#endif /*Check_FLT_ROUNDS*/
- }
- y = word0(rv) & Exp_mask;
-
- /* Check for overflow */
-
- if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
- dval(rv0) = dval(rv);
- word0(rv) -= P*Exp_msk1;
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
- if ((word0(rv) & Exp_mask) >=
- Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
- if (word0(rv0) == Big0 && word1(rv0) == Big1)
- goto ovfl;
- word0(rv) = Big0;
- word1(rv) = Big1;
- goto cont;
- }
- else
- word0(rv) += P*Exp_msk1;
- }
- else {
-#ifdef Avoid_Underflow
- if (scale && y <= 2*P*Exp_msk1) {
- if (aadj <= 0x7fffffff) {
- if ((z = (int)aadj) <= 0)
- z = 1;
- aadj = z;
- dval(aadj1) = dsign ? aadj : -aadj;
- }
- word0(aadj1) += (2*P+1)*Exp_msk1 - y;
- }
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
-#else
-#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
- dval(rv0) = dval(rv);
- word0(rv) += P*Exp_msk1;
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
-#ifdef IBM
- if ((word0(rv) & Exp_mask) < P*Exp_msk1)
-#else
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
-#endif
- {
- if (word0(rv0) == Tiny0 && word1(rv0) == Tiny1)
- goto undfl;
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
- goto cont;
- }
- else
- word0(rv) -= P*Exp_msk1;
- }
- else {
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
- }
-#else /*Sudden_Underflow*/
- /* Compute adj so that the IEEE rounding rules will
- * correctly round rv + adj in some half-way cases.
- * If rv * ulp(rv) is denormalized (i.e.,
- * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
- * trouble from bits lost to denormalization;
- * example: 1.2e-307 .
- */
- if (y <= (P-1)*Exp_msk1 && aadj > 1.) {
- dval(aadj1) = (double)(int)(aadj + 0.5);
- if (!dsign)
- dval(aadj1) = -dval(aadj1);
- }
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- }
- z = word0(rv) & Exp_mask;
-#ifndef SET_INEXACT
-#ifdef Avoid_Underflow
- if (!scale)
-#endif
- if (y == z) {
- /* Can we stop now? */
- L = (Long)aadj;
- aadj -= L;
- /* The tolerances below are conservative. */
- if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
- if (aadj < .4999999 || aadj > .5000001)
- break;
- }
- else if (aadj < .4999999/FLT_RADIX)
- break;
- }
-#endif
-cont:
- Bfree(bb);
- Bfree(bd);
- Bfree(bs);
- Bfree(delta);
- }
-#ifdef SET_INEXACT
- if (inexact) {
- if (!oldinexact) {
- word0(rv0) = Exp_1 + (70 << Exp_shift);
- word1(rv0) = 0;
- dval(rv0) += 1.;
- }
- }
- else if (!oldinexact)
- clear_inexact();
-#endif
-#ifdef Avoid_Underflow
- if (scale) {
- word0(rv0) = Exp_1 - 2*P*Exp_msk1;
- word1(rv0) = 0;
- dval(rv) *= dval(rv0);
-#ifndef NO_ERRNO
- /* try to avoid the bug of testing an 8087 register value */
- if (word0(rv) == 0 && word1(rv) == 0)
- errno = ERANGE;
-#endif
- }
-#endif /* Avoid_Underflow */
-#ifdef SET_INEXACT
- if (inexact && !(word0(rv) & Exp_mask)) {
- /* set underflow bit */
- dval(rv0) = 1e-300;
- dval(rv0) *= dval(rv0);
- }
-#endif
-retfree:
- Bfree(bb);
- Bfree(bd);
- Bfree(bs);
- Bfree(bd0);
- Bfree(delta);
-ret:
- if (se)
- *se = (char *)s;
- return sign ? -dval(rv) : dval(rv);
-}
-
-NO_SANITIZE("unsigned-integer-overflow", static int quorem(Bigint *b, Bigint *S));
-static int
-quorem(Bigint *b, Bigint *S)
-{
- int n;
- ULong *bx, *bxe, q, *sx, *sxe;
-#ifdef ULLong
- ULLong borrow, carry, y, ys;
-#else
- ULong borrow, carry, y, ys;
-#ifdef Pack_32
- ULong si, z, zs;
-#endif
-#endif
-
- n = S->wds;
-#ifdef DEBUG
- /*debug*/ if (b->wds > n)
- /*debug*/ Bug("oversize b in quorem");
-#endif
- if (b->wds < n)
- return 0;
- sx = S->x;
- sxe = sx + --n;
- bx = b->x;
- bxe = bx + n;
- q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
-#ifdef DEBUG
- /*debug*/ if (q > 9)
- /*debug*/ Bug("oversized quotient in quorem");
-#endif
- if (q) {
- borrow = 0;
- carry = 0;
- do {
-#ifdef ULLong
- ys = *sx++ * (ULLong)q + carry;
- carry = ys >> 32;
- y = *bx - (ys & FFFFFFFF) - borrow;
- borrow = y >> 32 & (ULong)1;
- *bx++ = (ULong)(y & FFFFFFFF);
-#else
-#ifdef Pack_32
- si = *sx++;
- ys = (si & 0xffff) * q + carry;
- zs = (si >> 16) * q + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*bx >> 16) - (zs & 0xffff) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(bx, z, y);
-#else
- ys = *sx++ * q + carry;
- carry = ys >> 16;
- y = *bx - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- *bx++ = y & 0xffff;
-#endif
-#endif
- } while (sx <= sxe);
- if (!*bxe) {
- bx = b->x;
- while (--bxe > bx && !*bxe)
- --n;
- b->wds = n;
- }
- }
- if (cmp(b, S) >= 0) {
- q++;
- borrow = 0;
- carry = 0;
- bx = b->x;
- sx = S->x;
- do {
-#ifdef ULLong
- ys = *sx++ + carry;
- carry = ys >> 32;
- y = *bx - (ys & FFFFFFFF) - borrow;
- borrow = y >> 32 & (ULong)1;
- *bx++ = (ULong)(y & FFFFFFFF);
-#else
-#ifdef Pack_32
- si = *sx++;
- ys = (si & 0xffff) + carry;
- zs = (si >> 16) + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*bx >> 16) - (zs & 0xffff) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(bx, z, y);
-#else
- ys = *sx++ + carry;
- carry = ys >> 16;
- y = *bx - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- *bx++ = y & 0xffff;
-#endif
-#endif
- } while (sx <= sxe);
- bx = b->x;
- bxe = bx + n;
- if (!*bxe) {
- while (--bxe > bx && !*bxe)
- --n;
- b->wds = n;
- }
- }
- return q;
-}
-
-#ifndef MULTIPLE_THREADS
-static char *dtoa_result;
-#endif
-
-#ifndef MULTIPLE_THREADS
-static char *
-rv_alloc(int i)
-{
- return dtoa_result = xmalloc(i);
-}
-#else
-#define rv_alloc(i) xmalloc(i)
-#endif
-
-static char *
-nrv_alloc(const char *s, char **rve, size_t n)
-{
- char *rv, *t;
-
- t = rv = rv_alloc(n);
- while ((*t = *s++) != 0) t++;
- if (rve)
- *rve = t;
- return rv;
-}
-
-#define rv_strdup(s, rve) nrv_alloc((s), (rve), strlen(s)+1)
-
-#ifndef MULTIPLE_THREADS
-/* freedtoa(s) must be used to free values s returned by dtoa
- * when MULTIPLE_THREADS is #defined. It should be used in all cases,
- * but for consistency with earlier versions of dtoa, it is optional
- * when MULTIPLE_THREADS is not defined.
- */
-
-static void
-freedtoa(char *s)
-{
- xfree(s);
-}
-#endif
-
-static const char INFSTR[] = "Infinity";
-static const char NANSTR[] = "NaN";
-static const char ZEROSTR[] = "0";
-
-/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
- *
- * Inspired by "How to Print Floating-Point Numbers Accurately" by
- * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].
- *
- * Modifications:
- * 1. Rather than iterating, we use a simple numeric overestimate
- * to determine k = floor(log10(d)). We scale relevant
- * quantities using O(log2(k)) rather than O(k) multiplications.
- * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
- * try to generate digits strictly left to right. Instead, we
- * compute with fewer bits and propagate the carry if necessary
- * when rounding the final digit up. This is often faster.
- * 3. Under the assumption that input will be rounded nearest,
- * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
- * That is, we allow equality in stopping tests when the
- * round-nearest rule will give the same floating-point value
- * as would satisfaction of the stopping test with strict
- * inequality.
- * 4. We remove common factors of powers of 2 from relevant
- * quantities.
- * 5. When converting floating-point integers less than 1e16,
- * we use floating-point arithmetic rather than resorting
- * to multiple-precision integers.
- * 6. When asked to produce fewer than 15 digits, we first try
- * to get by with floating-point arithmetic; we resort to
- * multiple-precision integer arithmetic only if we cannot
- * guarantee that the floating-point calculation has given
- * the correctly rounded result. For k requested digits and
- * "uniformly" distributed input, the probability is
- * something like 10^(k-15) that we must resort to the Long
- * calculation.
- */
-
-char *
-dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
-{
- /* Arguments ndigits, decpt, sign are similar to those
- of ecvt and fcvt; trailing zeros are suppressed from
- the returned string. If not null, *rve is set to point
- to the end of the return value. If d is +-Infinity or NaN,
- then *decpt is set to 9999.
-
- mode:
- 0 ==> shortest string that yields d when read in
- and rounded to nearest.
- 1 ==> like 0, but with Steele & White stopping rule;
- e.g. with IEEE P754 arithmetic , mode 0 gives
- 1e23 whereas mode 1 gives 9.999999999999999e22.
- 2 ==> max(1,ndigits) significant digits. This gives a
- return value similar to that of ecvt, except
- that trailing zeros are suppressed.
- 3 ==> through ndigits past the decimal point. This
- gives a return value similar to that from fcvt,
- except that trailing zeros are suppressed, and
- ndigits can be negative.
- 4,5 ==> similar to 2 and 3, respectively, but (in
- round-nearest mode) with the tests of mode 0 to
- possibly return a shorter string that rounds to d.
- With IEEE arithmetic and compilation with
- -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same
- as modes 2 and 3 when FLT_ROUNDS != 1.
- 6-9 ==> Debugging modes similar to mode - 4: don't try
- fast floating-point estimate (if applicable).
-
- Values of mode other than 0-9 are treated as mode 0.
-
- Sufficient space is allocated to the return value
- to hold the suppressed trailing zeros.
- */
-
- int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
- j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
- spec_case, try_quick, half = 0;
- Long L;
-#ifndef Sudden_Underflow
- int denorm;
- ULong x;
-#endif
- Bigint *b, *b1, *delta, *mlo = 0, *mhi = 0, *S;
- double ds;
- double_u d, d2, eps;
- char *s, *s0;
-#ifdef Honor_FLT_ROUNDS
- int rounding;
-#endif
-#ifdef SET_INEXACT
- int inexact, oldinexact;
-#endif
-
- dval(d) = d_;
-
-#ifndef MULTIPLE_THREADS
- if (dtoa_result) {
- freedtoa(dtoa_result);
- dtoa_result = 0;
- }
-#endif
-
- if (word0(d) & Sign_bit) {
- /* set sign for everything, including 0's and NaNs */
- *sign = 1;
- word0(d) &= ~Sign_bit; /* clear sign bit */
- }
- else
- *sign = 0;
-
-#if defined(IEEE_Arith) + defined(VAX)
-#ifdef IEEE_Arith
- if ((word0(d) & Exp_mask) == Exp_mask)
-#else
- if (word0(d) == 0x8000)
-#endif
- {
- /* Infinity or NaN */
- *decpt = 9999;
-#ifdef IEEE_Arith
- if (!word1(d) && !(word0(d) & 0xfffff))
- return rv_strdup(INFSTR, rve);
-#endif
- return rv_strdup(NANSTR, rve);
- }
-#endif
-#ifdef IBM
- dval(d) += 0; /* normalize */
-#endif
- if (!dval(d)) {
- *decpt = 1;
- return rv_strdup(ZEROSTR, rve);
- }
-
-#ifdef SET_INEXACT
- try_quick = oldinexact = get_inexact();
- inexact = 1;
-#endif
-#ifdef Honor_FLT_ROUNDS
- if ((rounding = Flt_Rounds) >= 2) {
- if (*sign)
- rounding = rounding == 2 ? 0 : 2;
- else
- if (rounding != 2)
- rounding = 0;
- }
-#endif
-
- b = d2b(dval(d), &be, &bbits);
-#ifdef Sudden_Underflow
- i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
-#else
- if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) {
-#endif
- dval(d2) = dval(d);
- word0(d2) &= Frac_mask1;
- word0(d2) |= Exp_11;
-#ifdef IBM
- if (j = 11 - hi0bits(word0(d2) & Frac_mask))
- dval(d2) /= 1 << j;
-#endif
-
- /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
- * log10(x) = log(x) / log(10)
- * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
- * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
- *
- * This suggests computing an approximation k to log10(d) by
- *
- * k = (i - Bias)*0.301029995663981
- * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
- *
- * We want k to be too large rather than too small.
- * The error in the first-order Taylor series approximation
- * is in our favor, so we just round up the constant enough
- * to compensate for any error in the multiplication of
- * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
- * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
- * adding 1e-13 to the constant term more than suffices.
- * Hence we adjust the constant term to 0.1760912590558.
- * (We could get a more accurate k by invoking log10,
- * but this is probably not worthwhile.)
- */
-
- i -= Bias;
-#ifdef IBM
- i <<= 2;
- i += j;
-#endif
-#ifndef Sudden_Underflow
- denorm = 0;
- }
- else {
- /* d is denormalized */
-
- i = bbits + be + (Bias + (P-1) - 1);
- x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32)
- : word1(d) << (32 - i);
- dval(d2) = x;
- word0(d2) -= 31*Exp_msk1; /* adjust exponent */
- i -= (Bias + (P-1) - 1) + 1;
- denorm = 1;
- }
-#endif
- ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
- k = (int)ds;
- if (ds < 0. && ds != k)
- k--; /* want k = floor(ds) */
- k_check = 1;
- if (k >= 0 && k <= Ten_pmax) {
- if (dval(d) < tens[k])
- k--;
- k_check = 0;
- }
- j = bbits - i - 1;
- if (j >= 0) {
- b2 = 0;
- s2 = j;
- }
- else {
- b2 = -j;
- s2 = 0;
- }
- if (k >= 0) {
- b5 = 0;
- s5 = k;
- s2 += k;
- }
- else {
- b2 -= k;
- b5 = -k;
- s5 = 0;
- }
- if (mode < 0 || mode > 9)
- mode = 0;
-
-#ifndef SET_INEXACT
-#ifdef Check_FLT_ROUNDS
- try_quick = Rounding == 1;
-#else
- try_quick = 1;
-#endif
-#endif /*SET_INEXACT*/
-
- if (mode > 5) {
- mode -= 4;
- try_quick = 0;
- }
- leftright = 1;
- ilim = ilim1 = -1;
- switch (mode) {
- case 0:
- case 1:
- i = 18;
- ndigits = 0;
- break;
- case 2:
- leftright = 0;
- /* no break */
- case 4:
- if (ndigits <= 0)
- ndigits = 1;
- ilim = ilim1 = i = ndigits;
- break;
- case 3:
- leftright = 0;
- /* no break */
- case 5:
- i = ndigits + k + 1;
- ilim = i;
- ilim1 = i - 1;
- if (i <= 0)
- i = 1;
- }
- s = s0 = rv_alloc(i+1);
-
-#ifdef Honor_FLT_ROUNDS
- if (mode > 1 && rounding != 1)
- leftright = 0;
-#endif
-
- if (ilim >= 0 && ilim <= Quick_max && try_quick) {
-
- /* Try to get by with floating-point arithmetic. */
-
- i = 0;
- dval(d2) = dval(d);
- k0 = k;
- ilim0 = ilim;
- ieps = 2; /* conservative */
- if (k > 0) {
- ds = tens[k&0xf];
- j = k >> 4;
- if (j & Bletch) {
- /* prevent overflows */
- j &= Bletch - 1;
- dval(d) /= bigtens[n_bigtens-1];
- ieps++;
- }
- for (; j; j >>= 1, i++)
- if (j & 1) {
- ieps++;
- ds *= bigtens[i];
- }
- dval(d) /= ds;
- }
- else if ((j1 = -k) != 0) {
- dval(d) *= tens[j1 & 0xf];
- for (j = j1 >> 4; j; j >>= 1, i++)
- if (j & 1) {
- ieps++;
- dval(d) *= bigtens[i];
- }
- }
- if (k_check && dval(d) < 1. && ilim > 0) {
- if (ilim1 <= 0)
- goto fast_failed;
- ilim = ilim1;
- k--;
- dval(d) *= 10.;
- ieps++;
- }
- dval(eps) = ieps*dval(d) + 7.;
- word0(eps) -= (P-1)*Exp_msk1;
- if (ilim == 0) {
- S = mhi = 0;
- dval(d) -= 5.;
- if (dval(d) > dval(eps))
- goto one_digit;
- if (dval(d) < -dval(eps))
- goto no_digits;
- goto fast_failed;
- }
-#ifndef No_leftright
- if (leftright) {
- /* Use Steele & White method of only
- * generating digits needed.
- */
- dval(eps) = 0.5/tens[ilim-1] - dval(eps);
- for (i = 0;;) {
- L = (int)dval(d);
- dval(d) -= L;
- *s++ = '0' + (int)L;
- if (dval(d) < dval(eps))
- goto ret1;
- if (1. - dval(d) < dval(eps))
- goto bump_up;
- if (++i >= ilim)
- break;
- dval(eps) *= 10.;
- dval(d) *= 10.;
- }
- }
- else {
-#endif
- /* Generate ilim digits, then fix them up. */
- dval(eps) *= tens[ilim-1];
- for (i = 1;; i++, dval(d) *= 10.) {
- L = (Long)(dval(d));
- if (!(dval(d) -= L))
- ilim = i;
- *s++ = '0' + (int)L;
- if (i == ilim) {
- if (dval(d) > 0.5 + dval(eps))
- goto bump_up;
- else if (dval(d) < 0.5 - dval(eps)) {
- while (*--s == '0') ;
- s++;
- goto ret1;
- }
- half = 1;
- if ((*(s-1) - '0') & 1) {
- goto bump_up;
- }
- break;
- }
- }
-#ifndef No_leftright
- }
-#endif
-fast_failed:
- s = s0;
- dval(d) = dval(d2);
- k = k0;
- ilim = ilim0;
- }
-
- /* Do we have a "small" integer? */
-
- if (be >= 0 && k <= Int_max) {
- /* Yes. */
- ds = tens[k];
- if (ndigits < 0 && ilim <= 0) {
- S = mhi = 0;
- if (ilim < 0 || dval(d) <= 5*ds)
- goto no_digits;
- goto one_digit;
- }
- for (i = 1;; i++, dval(d) *= 10.) {
- L = (Long)(dval(d) / ds);
- dval(d) -= L*ds;
-#ifdef Check_FLT_ROUNDS
- /* If FLT_ROUNDS == 2, L will usually be high by 1 */
- if (dval(d) < 0) {
- L--;
- dval(d) += ds;
- }
-#endif
- *s++ = '0' + (int)L;
- if (!dval(d)) {
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- break;
- }
- if (i == ilim) {
-#ifdef Honor_FLT_ROUNDS
- if (mode > 1)
- switch (rounding) {
- case 0: goto ret1;
- case 2: goto bump_up;
- }
-#endif
- dval(d) += dval(d);
- if (dval(d) > ds || (dval(d) == ds && (L & 1))) {
-bump_up:
- while (*--s == '9')
- if (s == s0) {
- k++;
- *s = '0';
- break;
- }
- ++*s++;
- }
- break;
- }
- }
- goto ret1;
- }
-
- m2 = b2;
- m5 = b5;
- if (leftright) {
- i =
-#ifndef Sudden_Underflow
- denorm ? be + (Bias + (P-1) - 1 + 1) :
-#endif
-#ifdef IBM
- 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
-#else
- 1 + P - bbits;
-#endif
- b2 += i;
- s2 += i;
- mhi = i2b(1);
- }
- if (m2 > 0 && s2 > 0) {
- i = m2 < s2 ? m2 : s2;
- b2 -= i;
- m2 -= i;
- s2 -= i;
- }
- if (b5 > 0) {
- if (leftright) {
- if (m5 > 0) {
- mhi = pow5mult(mhi, m5);
- b1 = mult(mhi, b);
- Bfree(b);
- b = b1;
- }
- if ((j = b5 - m5) != 0)
- b = pow5mult(b, j);
- }
- else
- b = pow5mult(b, b5);
- }
- S = i2b(1);
- if (s5 > 0)
- S = pow5mult(S, s5);
-
- /* Check for special case that d is a normalized power of 2. */
-
- spec_case = 0;
- if ((mode < 2 || leftright)
-#ifdef Honor_FLT_ROUNDS
- && rounding == 1
-#endif
- ) {
- if (!word1(d) && !(word0(d) & Bndry_mask)
-#ifndef Sudden_Underflow
- && word0(d) & (Exp_mask & ~Exp_msk1)
-#endif
- ) {
- /* The special case */
- b2 += Log2P;
- s2 += Log2P;
- spec_case = 1;
- }
- }
-
- /* Arrange for convenient computation of quotients:
- * shift left if necessary so divisor has 4 leading 0 bits.
- *
- * Perhaps we should just compute leading 28 bits of S once
- * and for all and pass them and a shift to quorem, so it
- * can do shifts and ors to compute the numerator for q.
- */
-#ifdef Pack_32
- if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) != 0)
- i = 32 - i;
-#else
- if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) != 0)
- i = 16 - i;
-#endif
- if (i > 4) {
- i -= 4;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- else if (i < 4) {
- i += 28;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- if (b2 > 0)
- b = lshift(b, b2);
- if (s2 > 0)
- S = lshift(S, s2);
- if (k_check) {
- if (cmp(b,S) < 0) {
- k--;
- b = multadd(b, 10, 0); /* we botched the k estimate */
- if (leftright)
- mhi = multadd(mhi, 10, 0);
- ilim = ilim1;
- }
- }
- if (ilim <= 0 && (mode == 3 || mode == 5)) {
- if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
- /* no digits, fcvt style */
-no_digits:
- k = -1 - ndigits;
- goto ret;
- }
-one_digit:
- *s++ = '1';
- k++;
- goto ret;
- }
- if (leftright) {
- if (m2 > 0)
- mhi = lshift(mhi, m2);
-
- /* Compute mlo -- check for special case
- * that d is a normalized power of 2.
- */
-
- mlo = mhi;
- if (spec_case) {
- mhi = Balloc(mhi->k);
- Bcopy(mhi, mlo);
- mhi = lshift(mhi, Log2P);
- }
-
- for (i = 1;;i++) {
- dig = quorem(b,S) + '0';
- /* Do we yet have the shortest decimal string
- * that will round to d?
- */
- j = cmp(b, mlo);
- delta = diff(S, mhi);
- j1 = delta->sign ? 1 : cmp(b, delta);
- Bfree(delta);
-#ifndef ROUND_BIASED
- if (j1 == 0 && mode != 1 && !(word1(d) & 1)
-#ifdef Honor_FLT_ROUNDS
- && rounding >= 1
-#endif
- ) {
- if (dig == '9')
- goto round_9_up;
- if (j > 0)
- dig++;
-#ifdef SET_INEXACT
- else if (!b->x[0] && b->wds <= 1)
- inexact = 0;
-#endif
- *s++ = dig;
- goto ret;
- }
-#endif
- if (j < 0 || (j == 0 && mode != 1
-#ifndef ROUND_BIASED
- && !(word1(d) & 1)
-#endif
- )) {
- if (!b->x[0] && b->wds <= 1) {
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- goto accept_dig;
- }
-#ifdef Honor_FLT_ROUNDS
- if (mode > 1)
- switch (rounding) {
- case 0: goto accept_dig;
- case 2: goto keep_dig;
- }
-#endif /*Honor_FLT_ROUNDS*/
- if (j1 > 0) {
- b = lshift(b, 1);
- j1 = cmp(b, S);
- if ((j1 > 0 || (j1 == 0 && (dig & 1))) && dig++ == '9')
- goto round_9_up;
- }
-accept_dig:
- *s++ = dig;
- goto ret;
- }
- if (j1 > 0) {
-#ifdef Honor_FLT_ROUNDS
- if (!rounding)
- goto accept_dig;
-#endif
- if (dig == '9') { /* possible if i == 1 */
-round_9_up:
- *s++ = '9';
- goto roundoff;
- }
- *s++ = dig + 1;
- goto ret;
- }
-#ifdef Honor_FLT_ROUNDS
-keep_dig:
-#endif
- *s++ = dig;
- if (i == ilim)
- break;
- b = multadd(b, 10, 0);
- if (mlo == mhi)
- mlo = mhi = multadd(mhi, 10, 0);
- else {
- mlo = multadd(mlo, 10, 0);
- mhi = multadd(mhi, 10, 0);
- }
- }
- }
- else
- for (i = 1;; i++) {
- *s++ = dig = quorem(b,S) + '0';
- if (!b->x[0] && b->wds <= 1) {
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- goto ret;
- }
- if (i >= ilim)
- break;
- b = multadd(b, 10, 0);
- }
-
- /* Round off last digit */
-
-#ifdef Honor_FLT_ROUNDS
- switch (rounding) {
- case 0: goto trimzeros;
- case 2: goto roundoff;
- }
-#endif
- b = lshift(b, 1);
- j = cmp(b, S);
- if (j > 0 || (j == 0 && (dig & 1))) {
- roundoff:
- while (*--s == '9')
- if (s == s0) {
- k++;
- *s++ = '1';
- goto ret;
- }
- if (!half || (*s - '0') & 1)
- ++*s;
- }
- else {
- while (*--s == '0') ;
- }
- s++;
-ret:
- Bfree(S);
- if (mhi) {
- if (mlo && mlo != mhi)
- Bfree(mlo);
- Bfree(mhi);
- }
-ret1:
-#ifdef SET_INEXACT
- if (inexact) {
- if (!oldinexact) {
- word0(d) = Exp_1 + (70 << Exp_shift);
- word1(d) = 0;
- dval(d) += 1.;
- }
- }
- else if (!oldinexact)
- clear_inexact();
-#endif
- Bfree(b);
- *s = 0;
- *decpt = k + 1;
- if (rve)
- *rve = s;
- return s0;
-}
-
-/*-
- * Copyright (c) 2004-2008 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define DBL_MANH_SIZE 20
-#define DBL_MANL_SIZE 32
-#define DBL_ADJ (DBL_MAX_EXP - 2)
-#define SIGFIGS ((DBL_MANT_DIG + 3) / 4 + 1)
-#define dexp_get(u) ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)
-#define dexp_set(u,v) (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift)))
-#define dmanh_get(u) ((uint32_t)(word0(u) & Frac_mask))
-#define dmanl_get(u) ((uint32_t)word1(u))
-
-
-/*
- * This procedure converts a double-precision number in IEEE format
- * into a string of hexadecimal digits and an exponent of 2. Its
- * behavior is bug-for-bug compatible with dtoa() in mode 2, with the
- * following exceptions:
- *
- * - An ndigits < 0 causes it to use as many digits as necessary to
- * represent the number exactly.
- * - The additional xdigs argument should point to either the string
- * "0123456789ABCDEF" or the string "0123456789abcdef", depending on
- * which case is desired.
- * - This routine does not repeat dtoa's mistake of setting decpt
- * to 9999 in the case of an infinity or NaN. INT_MAX is used
- * for this purpose instead.
- *
- * Note that the C99 standard does not specify what the leading digit
- * should be for non-zero numbers. For instance, 0x1.3p3 is the same
- * as 0x2.6p2 is the same as 0x4.cp3. This implementation always makes
- * the leading digit a 1. This ensures that the exponent printed is the
- * actual base-2 exponent, i.e., ilogb(d).
- *
- * Inputs: d, xdigs, ndigits
- * Outputs: decpt, sign, rve
- */
-char *
-hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve)
-{
- U u;
- char *s, *s0;
- int bufsize;
- uint32_t manh, manl;
-
- u.d = d;
- if (word0(u) & Sign_bit) {
- /* set sign for everything, including 0's and NaNs */
- *sign = 1;
- word0(u) &= ~Sign_bit; /* clear sign bit */
- }
- else
- *sign = 0;
-
- if (isinf(d)) { /* FP_INFINITE */
- *decpt = INT_MAX;
- return rv_strdup(INFSTR, rve);
- }
- else if (isnan(d)) { /* FP_NAN */
- *decpt = INT_MAX;
- return rv_strdup(NANSTR, rve);
- }
- else if (d == 0.0) { /* FP_ZERO */
- *decpt = 1;
- return rv_strdup(ZEROSTR, rve);
- }
- else if (dexp_get(u)) { /* FP_NORMAL */
- *decpt = dexp_get(u) - DBL_ADJ;
- }
- else { /* FP_SUBNORMAL */
- u.d *= 5.363123171977039e+154 /* 0x1p514 */;
- *decpt = dexp_get(u) - (514 + DBL_ADJ);
- }
-
- if (ndigits == 0) /* dtoa() compatibility */
- ndigits = 1;
-
- /*
- * If ndigits < 0, we are expected to auto-size, so we allocate
- * enough space for all the digits.
- */
- bufsize = (ndigits > 0) ? ndigits : SIGFIGS;
- s0 = rv_alloc(bufsize+1);
-
- /* Round to the desired number of digits. */
- if (SIGFIGS > ndigits && ndigits > 0) {
- float redux = 1.0f;
- int offset = 4 * ndigits + DBL_MAX_EXP - 4 - DBL_MANT_DIG;
- dexp_set(u, offset);
- u.d += redux;
- u.d -= redux;
- *decpt += dexp_get(u) - offset;
- }
-
- manh = dmanh_get(u);
- manl = dmanl_get(u);
- *s0 = '1';
- for (s = s0 + 1; s < s0 + bufsize; s++) {
- *s = xdigs[(manh >> (DBL_MANH_SIZE - 4)) & 0xf];
- manh = (manh << 4) | (manl >> (DBL_MANL_SIZE - 4));
- manl <<= 4;
- }
-
- /* If ndigits < 0, we are expected to auto-size the precision. */
- if (ndigits < 0) {
- for (ndigits = SIGFIGS; s0[ndigits - 1] == '0'; ndigits--)
- ;
- }
-
- s = s0 + ndigits;
- *s = '\0';
- if (rve != NULL)
- *rve = s;
- return (s0);
-}
-
-#ifdef __cplusplus
-#if 0
-{ /* satisfy cc-mode */
-#endif
-}
-#endif
diff --git a/missing/explicit_bzero.c b/missing/explicit_bzero.c
index 1804cdd42e..a7ff9cb517 100644
--- a/missing/explicit_bzero.c
+++ b/missing/explicit_bzero.c
@@ -33,13 +33,7 @@
#undef explicit_bzero
#ifndef HAVE_EXPLICIT_BZERO
- #ifdef HAVE_EXPLICIT_MEMSET
-void
-explicit_bzero(void *b, size_t len)
-{
- (void)explicit_memset(b, 0, len);
-}
- #elif defined HAVE_MEMSET_S
+ #ifdef HAVE_MEMSET_S
void
explicit_bzero(void *b, size_t len)
{
diff --git a/missing/fileblocks.c b/missing/fileblocks.c
new file mode 100644
index 0000000000..ccb8d667b4
--- /dev/null
+++ b/missing/fileblocks.c
@@ -0,0 +1 @@
+/* dummy for autoconf */
diff --git a/missing/memcmp.c b/missing/memcmp.c
index 9657e6c372..a81eec4244 100644
--- a/missing/memcmp.c
+++ b/missing/memcmp.c
@@ -11,8 +11,7 @@ memcmp(const void *s1, const void *s2, size_t len)
register int tmp;
for (; len; --len) {
- tmp = *a++ - *b++;
- if (tmp)
+ if (tmp = *a++ - *b++)
return tmp;
}
return 0;
diff --git a/missing/mt19937.c b/missing/mt19937.c
deleted file mode 100644
index cf1da349fb..0000000000
--- a/missing/mt19937.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
-This is based on trimmed version of MT19937. To get the original version,
-contact <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html>.
-
-The original copyright notice follows.
-
- A C-program for MT19937, with initialization improved 2002/2/10.
- Coded by Takuji Nishimura and Makoto Matsumoto.
- This is a faster version by taking Shawn Cokus's optimization,
- Matthe Bellew's simplification, Isaku Wada's real version.
-
- Before using, initialize the state by using init_genrand(mt, seed)
- or init_by_array(mt, init_key, key_length).
-
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. The names of its contributors may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
- Any feedback is very welcome.
- http://www.math.keio.ac.jp/matumoto/emt.html
- email: matumoto@math.keio.ac.jp
-*/
-
-/* Period parameters */
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0dfU /* constant vector a */
-#define UMASK 0x80000000U /* most significant w-r bits */
-#define LMASK 0x7fffffffU /* least significant r bits */
-#define MIXBITS(u,v) ( ((u) & UMASK) | ((v) & LMASK) )
-#define TWIST(u,v) ((MIXBITS((u),(v)) >> 1) ^ ((v)&1U ? MATRIX_A : 0U))
-
-enum {MT_MAX_STATE = N};
-
-struct MT {
- /* assume int is enough to store 32bits */
- uint32_t state[N]; /* the array for the state vector */
- uint32_t *next;
- int left;
-};
-
-#define genrand_initialized(mt) ((mt)->next != 0)
-#define uninit_genrand(mt) ((mt)->next = 0)
-
-NO_SANITIZE("unsigned-integer-overflow", static void init_genrand(struct MT *mt, unsigned int s));
-NO_SANITIZE("unsigned-integer-overflow", static void init_by_array(struct MT *mt, const uint32_t init_key[], int key_length));
-
-/* initializes state[N] with a seed */
-static void
-init_genrand(struct MT *mt, unsigned int s)
-{
- int j;
- mt->state[0] = s & 0xffffffffU;
- for (j=1; j<N; j++) {
- mt->state[j] = (1812433253U * (mt->state[j-1] ^ (mt->state[j-1] >> 30)) + j);
- /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
- /* In the previous versions, MSBs of the seed affect */
- /* only MSBs of the array state[]. */
- /* 2002/01/09 modified by Makoto Matsumoto */
- mt->state[j] &= 0xffffffff; /* for >32 bit machines */
- }
- mt->left = 1;
- mt->next = mt->state + N;
-}
-
-/* initialize by an array with array-length */
-/* init_key is the array for initializing keys */
-/* key_length is its length */
-/* slight change for C++, 2004/2/26 */
-static void
-init_by_array(struct MT *mt, const uint32_t init_key[], int key_length)
-{
- int i, j, k;
- init_genrand(mt, 19650218U);
- i=1; j=0;
- k = (N>key_length ? N : key_length);
- for (; k; k--) {
- mt->state[i] = (mt->state[i] ^ ((mt->state[i-1] ^ (mt->state[i-1] >> 30)) * 1664525U))
- + init_key[j] + j; /* non linear */
- mt->state[i] &= 0xffffffffU; /* for WORDSIZE > 32 machines */
- i++; j++;
- if (i>=N) { mt->state[0] = mt->state[N-1]; i=1; }
- if (j>=key_length) j=0;
- }
- for (k=N-1; k; k--) {
- mt->state[i] = (mt->state[i] ^ ((mt->state[i-1] ^ (mt->state[i-1] >> 30)) * 1566083941U))
- - i; /* non linear */
- mt->state[i] &= 0xffffffffU; /* for WORDSIZE > 32 machines */
- i++;
- if (i>=N) { mt->state[0] = mt->state[N-1]; i=1; }
- }
-
- mt->state[0] = 0x80000000U; /* MSB is 1; assuring non-zero initial array */
-}
-
-static void
-next_state(struct MT *mt)
-{
- uint32_t *p = mt->state;
- int j;
-
- mt->left = N;
- mt->next = mt->state;
-
- for (j=N-M+1; --j; p++)
- *p = p[M] ^ TWIST(p[0], p[1]);
-
- for (j=M; --j; p++)
- *p = p[M-N] ^ TWIST(p[0], p[1]);
-
- *p = p[M-N] ^ TWIST(p[0], mt->state[0]);
-}
-
-/* generates a random number on [0,0xffffffff]-interval */
-static unsigned int
-genrand_int32(struct MT *mt)
-{
- /* mt must be initialized */
- unsigned int y;
-
- if (--mt->left <= 0) next_state(mt);
- y = *mt->next++;
-
- /* Tempering */
- y ^= (y >> 11);
- y ^= (y << 7) & 0x9d2c5680;
- y ^= (y << 15) & 0xefc60000;
- y ^= (y >> 18);
-
- return y;
-}
diff --git a/missing/nan.c b/missing/nan.c
deleted file mode 100644
index 686c48a336..0000000000
--- a/missing/nan.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "ruby/missing.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-double
-nan(const char *spec)
-{
-#if 0
- /* FIXME: we have not yet seen any situation this is
- * necessary. Please write a proper implementation that
- * covers this branch. */
- if (spec && spec[0]) {
- double generated_nan;
- int len = snprintf(NULL, 0, "NAN(%s)", spec);
- char *buf = malloc(len + 1); /* +1 for NUL */
- sprintf(buf, "NAN(%s)", spec);
- generated_nan = strtod(buf, NULL);
- free(buf);
- return generated_nan;
- }
- else
-#endif
- {
- assert(!spec || !spec[0]);
- return (double)NAN;
- }
-}
diff --git a/missing/procstat_vm.c b/missing/procstat_vm.c
deleted file mode 100644
index 76fd8f61ba..0000000000
--- a/missing/procstat_vm.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <sys/user.h>
-#include <sys/sysctl.h>
-#include <sys/param.h>
-#include <libprocstat.h>
-# ifndef KVME_TYPE_MGTDEVICE
-# define KVME_TYPE_MGTDEVICE 8
-# endif
-void
-procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
-{
- struct kinfo_vmentry *freep, *kve;
- int ptrwidth;
- unsigned int i, cnt;
- const char *str;
-#ifdef __x86_64__
- ptrwidth = 14;
-#else
- ptrwidth = 2*sizeof(void *) + 2;
-#endif
- fprintf(stderr, "%*s %*s %3s %4s %4s %3s %3s %4s %-2s %-s\n",
- ptrwidth, "START", ptrwidth, "END", "PRT", "RES",
- "P""RES", "REF", "SHD", "FL", "TP", "PATH");
-
-#ifdef HAVE_PROCSTAT_GETVMMAP
- freep = procstat_getvmmap(procstat, kipp, &cnt);
-#else
- freep = kinfo_getvmmap(kipp->ki_pid, &cnt);
-#endif
- if (freep == NULL)
- return;
- for (i = 0; i < cnt; i++) {
- kve = &freep[i];
- fprintf(stderr, "%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
- fprintf(stderr, "%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
- fprintf(stderr, "%s", kve->kve_protection & KVME_PROT_READ ? "r" : "-");
- fprintf(stderr, "%s", kve->kve_protection & KVME_PROT_WRITE ? "w" : "-");
- fprintf(stderr, "%s ", kve->kve_protection & KVME_PROT_EXEC ? "x" : "-");
- fprintf(stderr, "%4d ", kve->kve_resident);
- fprintf(stderr, "%4d ", kve->kve_private_resident);
- fprintf(stderr, "%3d ", kve->kve_ref_count);
- fprintf(stderr, "%3d ", kve->kve_shadow_count);
- fprintf(stderr, "%-1s", kve->kve_flags & KVME_FLAG_COW ? "C" : "-");
- fprintf(stderr, "%-1s", kve->kve_flags & KVME_FLAG_NEEDS_COPY ? "N" :
- "-");
- fprintf(stderr, "%-1s", kve->kve_flags & KVME_FLAG_SUPER ? "S" : "-");
- fprintf(stderr, "%-1s ", kve->kve_flags & KVME_FLAG_GROWS_UP ? "U" :
- kve->kve_flags & KVME_FLAG_GROWS_DOWN ? "D" : "-");
- switch (kve->kve_type) {
- case KVME_TYPE_NONE:
- str = "--";
- break;
- case KVME_TYPE_DEFAULT:
- str = "df";
- break;
- case KVME_TYPE_VNODE:
- str = "vn";
- break;
- case KVME_TYPE_SWAP:
- str = "sw";
- break;
- case KVME_TYPE_DEVICE:
- str = "dv";
- break;
- case KVME_TYPE_PHYS:
- str = "ph";
- break;
- case KVME_TYPE_DEAD:
- str = "dd";
- break;
- case KVME_TYPE_SG:
- str = "sg";
- break;
- case KVME_TYPE_MGTDEVICE:
- str = "md";
- break;
- case KVME_TYPE_UNKNOWN:
- default:
- str = "??";
- break;
- }
- fprintf(stderr, "%-2s ", str);
- fprintf(stderr, "%-s\n", kve->kve_path);
- }
- free(freep);
-}
diff --git a/missing/setproctitle.c b/missing/setproctitle.c
index 811829c060..9fceeee52b 100644
--- a/missing/setproctitle.c
+++ b/missing/setproctitle.c
@@ -152,9 +152,10 @@ setproctitle(const char *fmt, ...)
return;
#endif
- /* fmt must be non-NULL */
va_start(ap, fmt);
- vsnprintf(ptitle, sizeof(ptitle), fmt, ap);
+ if (fmt != NULL) {
+ vsnprintf(ptitle, sizeof(ptitle) , fmt, ap);
+ }
va_end(ap);
#if SPT_TYPE == SPT_PSTAT
diff --git a/missing/stdbool.h b/missing/stdbool.h
index f370e01e92..68c2f3d254 100644
--- a/missing/stdbool.h
+++ b/missing/stdbool.h
@@ -5,16 +5,16 @@
#ifndef _MISSING_STDBOOL_H_
#define _MISSING_STDBOOL_H_
-#ifndef __bool_true_false_are_defined
-# ifndef __cplusplus
-# undef bool
-# undef false
-# undef true
-# define bool signed char
-# define false 0
-# define true 1
-# define __bool_true_false_are_defined 1
-# endif
-#endif
+#ifndef __cplusplus
+
+#define bool _Bool
+#define true 1
+#define false 0
+
+#ifndef HAVE__BOOL /* AC_HEADER_STDBOOL in configure.ac */
+typedef int _Bool;
+#endif /* HAVE__BOOL */
+
+#endif /* __cplusplus */
#endif /* _MISSING_STDBOOL_H_ */
diff --git a/missing/x86_64-chkstk.S b/missing/x86_64-chkstk.s
index 6d1227b6d2..6d1227b6d2 100644
--- a/missing/x86_64-chkstk.S
+++ b/missing/x86_64-chkstk.s
diff --git a/mjit.c b/mjit.c
deleted file mode 100644
index 4dc6ad80b4..0000000000
--- a/mjit.c
+++ /dev/null
@@ -1,1046 +0,0 @@
-/**********************************************************************
-
- mjit.c - MRI method JIT compiler functions for Ruby's main thread
-
- Copyright (C) 2017 Vladimir Makarov <vmakarov@redhat.com>.
-
-**********************************************************************/
-
-// Functions in this file are never executed on MJIT worker thread.
-// So you can safely use Ruby methods and GC in this file.
-
-// To share variables privately, include mjit_worker.c instead of linking.
-
-#include "internal.h"
-
-#if USE_MJIT
-
-#include "mjit_worker.c"
-
-#include "constant.h"
-#include "id_table.h"
-
-// Copy ISeq's states so that race condition does not happen on compilation.
-static void
-mjit_copy_job_handler(void *data)
-{
- mjit_copy_job_t *job = data;
- if (stop_worker_p) { // check if mutex is still alive, before calling CRITICAL_SECTION_START.
- return;
- }
-
- CRITICAL_SECTION_START(3, "in mjit_copy_job_handler");
- // Make sure that this job is never executed when:
- // 1. job is being modified
- // 2. alloca memory inside job is expired
- // 3. ISeq is GC-ed
- if (job->finish_p) {
- CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");
- return;
- }
- else if (job->iseq == NULL) { // ISeq GC notified in mjit_mark_iseq
- job->finish_p = true;
- CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");
- return;
- }
-
- const struct rb_iseq_constant_body *body = job->iseq->body;
- if (job->cc_entries) {
- unsigned int i;
- struct rb_call_cache *sink = job->cc_entries;
- const struct rb_call_data *calls = body->call_data;
- const struct rb_kwarg_call_data *kw_calls = (struct rb_kwarg_call_data *)&body->call_data[body->ci_size];
- for (i = 0; i < body->ci_size; i++) {
- *sink++ = calls[i].cc;
- }
- for (i = 0; i < body->ci_kw_size; i++) {
- *sink++ = kw_calls[i].cc;
- }
- }
- if (job->is_entries) {
- memcpy(job->is_entries, body->is_entries, sizeof(union iseq_inline_storage_entry) * body->is_size);
- }
-
- job->finish_p = true;
- rb_native_cond_broadcast(&mjit_worker_wakeup);
- CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");
-}
-
-extern int rb_thread_create_mjit_thread(void (*worker_func)(void));
-
-// Return an unique file name in /tmp with PREFIX and SUFFIX and
-// number ID. Use getpid if ID == 0. The return file name exists
-// until the next function call.
-static char *
-get_uniq_filename(unsigned long id, const char *prefix, const char *suffix)
-{
- char buff[70], *str = buff;
- int size = sprint_uniq_filename(buff, sizeof(buff), id, prefix, suffix);
- str = 0;
- ++size;
- str = xmalloc(size);
- if (size <= (int)sizeof(buff)) {
- memcpy(str, buff, size);
- }
- else {
- sprint_uniq_filename(str, size, id, prefix, suffix);
- }
- return str;
-}
-
-// Wait until workers don't compile any iseq. It is called at the
-// start of GC.
-void
-mjit_gc_start_hook(void)
-{
- if (!mjit_enabled)
- return;
- CRITICAL_SECTION_START(4, "mjit_gc_start_hook");
- while (in_jit) {
- verbose(4, "Waiting wakeup from a worker for GC");
- rb_native_cond_wait(&mjit_client_wakeup, &mjit_engine_mutex);
- verbose(4, "Getting wakeup from a worker for GC");
- }
- in_gc = true;
- CRITICAL_SECTION_FINISH(4, "mjit_gc_start_hook");
-}
-
-// Send a signal to workers to continue iseq compilations. It is
-// called at the end of GC.
-void
-mjit_gc_exit_hook(void)
-{
- if (!mjit_enabled)
- return;
- CRITICAL_SECTION_START(4, "mjit_gc_exit_hook");
- in_gc = false;
- verbose(4, "Sending wakeup signal to workers after GC");
- rb_native_cond_broadcast(&mjit_gc_wakeup);
- CRITICAL_SECTION_FINISH(4, "mjit_gc_exit_hook");
-}
-
-// Deal with ISeq movement from compactor
-void
-mjit_update_references(const rb_iseq_t *iseq)
-{
- if (!mjit_enabled)
- return;
-
- CRITICAL_SECTION_START(4, "mjit_update_references");
- if (iseq->body->jit_unit) {
- iseq->body->jit_unit->iseq = (rb_iseq_t *)rb_gc_location((VALUE)iseq->body->jit_unit->iseq);
- // We need to invalidate JIT-ed code for the ISeq because it embeds pointer addresses.
- // To efficiently do that, we use the same thing as TracePoint and thus everything is cancelled for now.
- // See mjit.h and tool/ruby_vm/views/_mjit_compile_insn.erb for how `mjit_call_p` is used.
- mjit_call_p = false; // TODO: instead of cancelling all, invalidate only this one and recompile it with some threshold.
- }
-
- // Units in stale_units (list of over-speculated and invalidated code) are not referenced from
- // `iseq->body->jit_unit` anymore (because new one replaces that). So we need to check them too.
- // TODO: we should be able to reduce the number of units checked here.
- struct rb_mjit_unit *unit = NULL;
- list_for_each(&stale_units.head, unit, unode) {
- if (unit->iseq == iseq) {
- unit->iseq = (rb_iseq_t *)rb_gc_location((VALUE)unit->iseq);
- }
- }
- CRITICAL_SECTION_FINISH(4, "mjit_update_references");
-}
-
-// Iseqs can be garbage collected. This function should call when it
-// happens. It removes iseq from the unit.
-void
-mjit_free_iseq(const rb_iseq_t *iseq)
-{
- if (!mjit_enabled)
- return;
-
- CRITICAL_SECTION_START(4, "mjit_free_iseq");
- if (mjit_copy_job.iseq == iseq) {
- mjit_copy_job.iseq = NULL;
- }
- if (iseq->body->jit_unit) {
- // jit_unit is not freed here because it may be referred by multiple
- // lists of units. `get_from_list` and `mjit_finish` do the job.
- iseq->body->jit_unit->iseq = NULL;
- }
- // Units in stale_units (list of over-speculated and invalidated code) are not referenced from
- // `iseq->body->jit_unit` anymore (because new one replaces that). So we need to check them too.
- // TODO: we should be able to reduce the number of units checked here.
- struct rb_mjit_unit *unit = NULL;
- list_for_each(&stale_units.head, unit, unode) {
- if (unit->iseq == iseq) {
- unit->iseq = NULL;
- }
- }
- CRITICAL_SECTION_FINISH(4, "mjit_free_iseq");
-}
-
-// Free unit list. This should be called only when worker is finished
-// because node of unit_queue and one of active_units may have the same unit
-// during proceeding unit.
-static void
-free_list(struct rb_mjit_unit_list *list, bool close_handle_p)
-{
- struct rb_mjit_unit *unit = 0, *next;
-
- list_for_each_safe(&list->head, unit, next, unode) {
- list_del(&unit->unode);
- if (!close_handle_p) unit->handle = NULL; /* Skip dlclose in free_unit() */
-
- if (list == &stale_units) { // `free_unit(unit)` crashes after GC.compact on `stale_units`
- /*
- * TODO: REVERT THIS BRANCH
- * Debug the crash on stale_units w/ GC.compact and just use `free_unit(unit)`!!
- */
- if (unit->handle && dlclose(unit->handle)) {
- mjit_warning("failed to close handle for u%d: %s", unit->id, dlerror());
- }
- clean_object_files(unit);
- free(unit);
- }
- else {
- free_unit(unit);
- }
- }
- list->length = 0;
-}
-
-// MJIT info related to an existing continutaion.
-struct mjit_cont {
- rb_execution_context_t *ec; // continuation ec
- struct mjit_cont *prev, *next; // used to form lists
-};
-
-// Double linked list of registered continuations. This is used to detect
-// units which are in use in unload_units.
-static struct mjit_cont *first_cont;
-
-// Register a new continuation with execution context `ec`. Return MJIT info about
-// the continuation.
-struct mjit_cont *
-mjit_cont_new(rb_execution_context_t *ec)
-{
- struct mjit_cont *cont;
-
- cont = ZALLOC(struct mjit_cont);
- cont->ec = ec;
-
- CRITICAL_SECTION_START(3, "in mjit_cont_new");
- if (first_cont == NULL) {
- cont->next = cont->prev = NULL;
- }
- else {
- cont->prev = NULL;
- cont->next = first_cont;
- first_cont->prev = cont;
- }
- first_cont = cont;
- CRITICAL_SECTION_FINISH(3, "in mjit_cont_new");
-
- return cont;
-}
-
-// Unregister continuation `cont`.
-void
-mjit_cont_free(struct mjit_cont *cont)
-{
- CRITICAL_SECTION_START(3, "in mjit_cont_new");
- if (cont == first_cont) {
- first_cont = cont->next;
- if (first_cont != NULL)
- first_cont->prev = NULL;
- }
- else {
- cont->prev->next = cont->next;
- if (cont->next != NULL)
- cont->next->prev = cont->prev;
- }
- CRITICAL_SECTION_FINISH(3, "in mjit_cont_new");
-
- xfree(cont);
-}
-
-// Finish work with continuation info.
-static void
-finish_conts(void)
-{
- struct mjit_cont *cont, *next;
-
- for (cont = first_cont; cont != NULL; cont = next) {
- next = cont->next;
- xfree(cont);
- }
-}
-
-// Create unit for `iseq`.
-static void
-create_unit(const rb_iseq_t *iseq)
-{
- struct rb_mjit_unit *unit;
-
- unit = ZALLOC(struct rb_mjit_unit);
- if (unit == NULL)
- return;
-
- unit->id = current_unit_num++;
- unit->iseq = (rb_iseq_t *)iseq;
- iseq->body->jit_unit = unit;
-}
-
-// Set up field `used_code_p` for unit iseqs whose iseq on the stack of ec.
-static void
-mark_ec_units(rb_execution_context_t *ec)
-{
- const rb_control_frame_t *cfp;
-
- if (ec->vm_stack == NULL)
- return;
- for (cfp = RUBY_VM_END_CONTROL_FRAME(ec) - 1; ; cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp)) {
- const rb_iseq_t *iseq;
- if (cfp->pc && (iseq = cfp->iseq) != NULL
- && imemo_type((VALUE) iseq) == imemo_iseq
- && (iseq->body->jit_unit) != NULL) {
- iseq->body->jit_unit->used_code_p = TRUE;
- }
-
- if (cfp == ec->cfp)
- break; // reached the most recent cfp
- }
-}
-
-// Unload JIT code of some units to satisfy the maximum permitted
-// number of units with a loaded code.
-static void
-unload_units(void)
-{
- rb_vm_t *vm = GET_THREAD()->vm;
- rb_thread_t *th = NULL;
- struct rb_mjit_unit *unit = 0, *next, *worst;
- struct mjit_cont *cont;
- int delete_num, units_num = active_units.length;
-
- // For now, we don't unload units when ISeq is GCed. We should
- // unload such ISeqs first here.
- list_for_each_safe(&active_units.head, unit, next, unode) {
- if (unit->iseq == NULL) { // ISeq is GCed.
- remove_from_list(unit, &active_units);
- free_unit(unit);
- }
- }
-
- // Detect units which are in use and can't be unloaded.
- list_for_each(&active_units.head, unit, unode) {
- assert(unit->iseq != NULL && unit->handle != NULL);
- unit->used_code_p = FALSE;
- }
- list_for_each(&vm->living_threads, th, vmlt_node) {
- mark_ec_units(th->ec);
- }
- for (cont = first_cont; cont != NULL; cont = cont->next) {
- mark_ec_units(cont->ec);
- }
- // TODO: check slale_units and unload unused ones! (note that the unit is not associated to ISeq anymore)
-
- // Remove 1/10 units more to decrease unloading calls.
- // TODO: Calculate max total_calls in unit_queue and don't unload units
- // whose total_calls are larger than the max.
- delete_num = active_units.length / 10;
- for (; active_units.length > mjit_opts.max_cache_size - delete_num;) {
- // Find one unit that has the minimum total_calls.
- worst = NULL;
- list_for_each(&active_units.head, unit, unode) {
- if (unit->used_code_p) // We can't unload code on stack.
- continue;
-
- if (worst == NULL || worst->iseq->body->total_calls > unit->iseq->body->total_calls) {
- worst = unit;
- }
- }
- if (worst == NULL)
- break;
-
- // Unload the worst node.
- verbose(2, "Unloading unit %d (calls=%lu)", worst->id, worst->iseq->body->total_calls);
- assert(worst->handle != NULL);
- remove_from_list(worst, &active_units);
- free_unit(worst);
- }
-
- if (units_num == active_units.length && mjit_opts.wait) {
- mjit_opts.max_cache_size++; // avoid infinite loop on `rb_mjit_wait_call`. Note that --jit-wait is just for testing.
- verbose(1, "No units can be unloaded -- incremented max-cache-size to %d for --jit-wait", mjit_opts.max_cache_size);
- }
- else {
- verbose(1, "Too many JIT code -- %d units unloaded", units_num - active_units.length);
- }
-}
-
-static void
-mjit_add_iseq_to_process(const rb_iseq_t *iseq, const struct rb_mjit_compile_info *compile_info)
-{
- if (!mjit_enabled || pch_status == PCH_FAILED)
- return;
-
- iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
- create_unit(iseq);
- if (iseq->body->jit_unit == NULL)
- // Failure in creating the unit.
- return;
- if (compile_info != NULL)
- iseq->body->jit_unit->compile_info = *compile_info;
-
- CRITICAL_SECTION_START(3, "in add_iseq_to_process");
- add_to_list(iseq->body->jit_unit, &unit_queue);
- if (active_units.length >= mjit_opts.max_cache_size) {
- unload_units();
- }
- verbose(3, "Sending wakeup signal to workers in mjit_add_iseq_to_process");
- rb_native_cond_broadcast(&mjit_worker_wakeup);
- CRITICAL_SECTION_FINISH(3, "in add_iseq_to_process");
-}
-
-// Add ISEQ to be JITed in parallel with the current thread.
-// Unload some JIT codes if there are too many of them.
-void
-rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq)
-{
- mjit_add_iseq_to_process(iseq, NULL);
-}
-
-// For this timeout seconds, --jit-wait will wait for JIT compilation finish.
-#define MJIT_WAIT_TIMEOUT_SECONDS 60
-
-static void
-mjit_wait(struct rb_iseq_constant_body *body)
-{
- struct timeval tv;
- int tries = 0;
- tv.tv_sec = 0;
- tv.tv_usec = 1000;
- while (body->jit_func == (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC) {
- tries++;
- if (tries / 1000 > MJIT_WAIT_TIMEOUT_SECONDS || pch_status == PCH_FAILED) {
- CRITICAL_SECTION_START(3, "in rb_mjit_wait_call to set jit_func");
- body->jit_func = (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; // JIT worker seems dead. Give up.
- CRITICAL_SECTION_FINISH(3, "in rb_mjit_wait_call to set jit_func");
- mjit_warning("timed out to wait for JIT finish");
- break;
- }
-
- CRITICAL_SECTION_START(3, "in rb_mjit_wait_call for a client wakeup");
- rb_native_cond_broadcast(&mjit_worker_wakeup);
- CRITICAL_SECTION_FINISH(3, "in rb_mjit_wait_call for a client wakeup");
- rb_thread_wait_for(tv);
- }
-}
-
-// Wait for JIT compilation finish for --jit-wait, and call the function pointer
-// if the compiled result is not NOT_COMPILED_JIT_ISEQ_FUNC.
-VALUE
-rb_mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body)
-{
- mjit_wait(body);
- if ((uintptr_t)body->jit_func <= (uintptr_t)LAST_JIT_ISEQ_FUNC) {
- return Qundef;
- }
- return body->jit_func(ec, ec->cfp);
-}
-
-struct rb_mjit_compile_info*
-rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body)
-{
- assert(body->jit_unit != NULL);
- return &body->jit_unit->compile_info;
-}
-
-void
-rb_mjit_recompile_iseq(const rb_iseq_t *iseq)
-{
- if ((uintptr_t)iseq->body->jit_func <= (uintptr_t)LAST_JIT_ISEQ_FUNC)
- return;
-
- verbose(1, "JIT recompile: %s@%s:%d", RSTRING_PTR(iseq->body->location.label),
- RSTRING_PTR(rb_iseq_path(iseq)), FIX2INT(iseq->body->location.first_lineno));
-
- CRITICAL_SECTION_START(3, "in rb_mjit_recompile_iseq");
- remove_from_list(iseq->body->jit_unit, &active_units);
- iseq->body->jit_func = (void *)NOT_ADDED_JIT_ISEQ_FUNC;
- add_to_list(iseq->body->jit_unit, &stale_units);
- CRITICAL_SECTION_FINISH(3, "in rb_mjit_recompile_iseq");
-
- mjit_add_iseq_to_process(iseq, &iseq->body->jit_unit->compile_info);
- if (UNLIKELY(mjit_opts.wait)) {
- mjit_wait(iseq->body);
- }
-}
-
-extern VALUE ruby_archlibdir_path, ruby_prefix_path;
-
-// Initialize header_file, pch_file, libruby_pathflag. Return true on success.
-static bool
-init_header_filename(void)
-{
- int fd;
-#ifdef LOAD_RELATIVE
- // Root path of the running ruby process. Equal to RbConfig::TOPDIR.
- VALUE basedir_val;
-#endif
- const char *basedir = "";
- size_t baselen = 0;
- char *p;
-#ifdef _WIN32
- static const char libpathflag[] =
-# ifdef _MSC_VER
- "-LIBPATH:"
-# else
- "-L"
-# endif
- ;
- const size_t libpathflag_len = sizeof(libpathflag) - 1;
-#endif
-
-#ifdef LOAD_RELATIVE
- basedir_val = ruby_prefix_path;
- basedir = StringValuePtr(basedir_val);
- baselen = RSTRING_LEN(basedir_val);
-#else
- if (getenv("MJIT_SEARCH_BUILD_DIR")) {
- // This path is not intended to be used on production, but using build directory's
- // header file here because people want to run `make test-all` without running
- // `make install`. Don't use $MJIT_SEARCH_BUILD_DIR except for test-all.
-
- struct stat st;
- const char *hdr = dlsym(RTLD_DEFAULT, "MJIT_HEADER");
- if (!hdr) {
- verbose(1, "No MJIT_HEADER");
- }
- else if (hdr[0] != '/') {
- verbose(1, "Non-absolute header file path: %s", hdr);
- }
- else if (stat(hdr, &st) || !S_ISREG(st.st_mode)) {
- verbose(1, "Non-file header file path: %s", hdr);
- }
- else if ((st.st_uid != getuid()) || (st.st_mode & 022) ||
- !rb_path_check(hdr)) {
- verbose(1, "Unsafe header file: uid=%ld mode=%#o %s",
- (long)st.st_uid, (unsigned)st.st_mode, hdr);
- return FALSE;
- }
- else {
- // Do not pass PRELOADENV to child processes, on
- // multi-arch environment
- verbose(3, "PRELOADENV("PRELOADENV")=%s", getenv(PRELOADENV));
- // assume no other PRELOADENV in test-all
- unsetenv(PRELOADENV);
- verbose(3, "MJIT_HEADER: %s", hdr);
- header_file = ruby_strdup(hdr);
- if (!header_file) return false;
- }
- }
- else
-#endif
-#ifndef _MSC_VER
- {
- // A name of the header file included in any C file generated by MJIT for iseqs.
- static const char header_name[] = MJIT_HEADER_INSTALL_DIR "/" MJIT_MIN_HEADER_NAME;
- const size_t header_name_len = sizeof(header_name) - 1;
-
- header_file = xmalloc(baselen + header_name_len + 1);
- p = append_str2(header_file, basedir, baselen);
- p = append_str2(p, header_name, header_name_len + 1);
-
- if ((fd = rb_cloexec_open(header_file, O_RDONLY, 0)) < 0) {
- verbose(1, "Cannot access header file: %s", header_file);
- xfree(header_file);
- header_file = NULL;
- return false;
- }
- (void)close(fd);
- }
-
- pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
-#else
- {
- static const char pch_name[] = MJIT_HEADER_INSTALL_DIR "/" MJIT_PRECOMPILED_HEADER_NAME;
- const size_t pch_name_len = sizeof(pch_name) - 1;
-
- pch_file = xmalloc(baselen + pch_name_len + 1);
- p = append_str2(pch_file, basedir, baselen);
- p = append_str2(p, pch_name, pch_name_len + 1);
- if ((fd = rb_cloexec_open(pch_file, O_RDONLY, 0)) < 0) {
- verbose(1, "Cannot access precompiled header file: %s", pch_file);
- xfree(pch_file);
- pch_file = NULL;
- return false;
- }
- (void)close(fd);
- }
-#endif
-
-#ifdef _WIN32
- basedir_val = ruby_archlibdir_path;
- basedir = StringValuePtr(basedir_val);
- baselen = RSTRING_LEN(basedir_val);
- libruby_pathflag = p = xmalloc(libpathflag_len + baselen + 1);
- p = append_str(p, libpathflag);
- p = append_str2(p, basedir, baselen);
- *p = '\0';
-#endif
-
- return true;
-}
-
-static enum rb_id_table_iterator_result
-valid_class_serials_add_i(ID key, VALUE v, void *unused)
-{
- rb_const_entry_t *ce = (rb_const_entry_t *)v;
- VALUE value = ce->value;
-
- if (!rb_is_const_id(key)) return ID_TABLE_CONTINUE;
- if (RB_TYPE_P(value, T_MODULE) || RB_TYPE_P(value, T_CLASS)) {
- mjit_add_class_serial(RCLASS_SERIAL(value));
- }
- return ID_TABLE_CONTINUE;
-}
-
-#ifdef _WIN32
-UINT rb_w32_system_tmpdir(WCHAR *path, UINT len);
-#endif
-
-static char *
-system_default_tmpdir(void)
-{
- // c.f. ext/etc/etc.c:etc_systmpdir()
-#ifdef _WIN32
- WCHAR tmppath[_MAX_PATH];
- UINT len = rb_w32_system_tmpdir(tmppath, numberof(tmppath));
- if (len) {
- int blen = WideCharToMultiByte(CP_UTF8, 0, tmppath, len, NULL, 0, NULL, NULL);
- char *tmpdir = xmalloc(blen + 1);
- WideCharToMultiByte(CP_UTF8, 0, tmppath, len, tmpdir, blen, NULL, NULL);
- tmpdir[blen] = '\0';
- return tmpdir;
- }
-#elif defined _CS_DARWIN_USER_TEMP_DIR
- char path[MAXPATHLEN];
- size_t len = confstr(_CS_DARWIN_USER_TEMP_DIR, path, sizeof(path));
- if (len > 0) {
- char *tmpdir = xmalloc(len);
- if (len > sizeof(path)) {
- confstr(_CS_DARWIN_USER_TEMP_DIR, tmpdir, len);
- }
- else {
- memcpy(tmpdir, path, len);
- }
- return tmpdir;
- }
-#endif
- return 0;
-}
-
-static int
-check_tmpdir(const char *dir)
-{
- struct stat st;
-
- if (!dir) return FALSE;
- if (stat(dir, &st)) return FALSE;
-#ifndef S_ISDIR
-# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
- if (!S_ISDIR(st.st_mode)) return FALSE;
-#ifndef _WIN32
-# ifndef S_IWOTH
-# define S_IWOTH 002
-# endif
- if (st.st_mode & S_IWOTH) {
-# ifdef S_ISVTX
- if (!(st.st_mode & S_ISVTX)) return FALSE;
-# else
- return FALSE;
-# endif
- }
- if (access(dir, W_OK)) return FALSE;
-#endif
- return TRUE;
-}
-
-static char *
-system_tmpdir(void)
-{
- char *tmpdir;
-# define RETURN_ENV(name) \
- if (check_tmpdir(tmpdir = getenv(name))) return ruby_strdup(tmpdir)
- RETURN_ENV("TMPDIR");
- RETURN_ENV("TMP");
- tmpdir = system_default_tmpdir();
- if (check_tmpdir(tmpdir)) return tmpdir;
- return ruby_strdup("/tmp");
-# undef RETURN_ENV
-}
-
-// Minimum value for JIT cache size.
-#define MIN_CACHE_SIZE 10
-// Default permitted number of units with a JIT code kept in memory.
-#define DEFAULT_MAX_CACHE_SIZE 100
-// A default threshold used to add iseq to JIT.
-#define DEFAULT_MIN_CALLS_TO_ADD 10000
-
-// Start MJIT worker. Return TRUE if worker is successfully started.
-static bool
-start_worker(void)
-{
- stop_worker_p = false;
- worker_stopped = false;
-
- if (!rb_thread_create_mjit_thread(mjit_worker)) {
- mjit_enabled = false;
- rb_native_mutex_destroy(&mjit_engine_mutex);
- rb_native_cond_destroy(&mjit_pch_wakeup);
- rb_native_cond_destroy(&mjit_client_wakeup);
- rb_native_cond_destroy(&mjit_worker_wakeup);
- rb_native_cond_destroy(&mjit_gc_wakeup);
- verbose(1, "Failure in MJIT thread initialization\n");
- return false;
- }
- return true;
-}
-
-// There's no strndup on Windows
-static char*
-ruby_strndup(const char *str, size_t n)
-{
- char *ret = xmalloc(n + 1);
- memcpy(ret, str, n);
- ret[n] = '\0';
- return ret;
-}
-
-// Convert "foo bar" to {"foo", "bar", NULL} array. Caller is responsible for
-// freeing a returned buffer and its elements.
-static char **
-split_flags(const char *flags)
-{
- char *buf[MAXPATHLEN];
- int i = 0;
- char *next;
- for (; flags != NULL; flags = next) {
- next = strchr(flags, ' ');
- if (next == NULL) {
- if (strlen(flags) > 0)
- buf[i++] = strdup(flags);
- }
- else {
- if (next > flags)
- buf[i++] = ruby_strndup(flags, next - flags);
- next++; // skip space
- }
- }
-
- char **ret = xmalloc(sizeof(char *) * (i + 1));
- memcpy(ret, buf, sizeof(char *) * i);
- ret[i] = NULL;
- return ret;
-}
-
-// Initialize MJIT. Start a thread creating the precompiled header and
-// processing ISeqs. The function should be called first for using MJIT.
-// If everything is successful, MJIT_INIT_P will be TRUE.
-void
-mjit_init(const struct mjit_options *opts)
-{
- mjit_opts = *opts;
- mjit_enabled = true;
- mjit_call_p = true;
-
- // Normalize options
- if (mjit_opts.min_calls == 0)
- mjit_opts.min_calls = DEFAULT_MIN_CALLS_TO_ADD;
- if (mjit_opts.max_cache_size <= 0)
- mjit_opts.max_cache_size = DEFAULT_MAX_CACHE_SIZE;
- if (mjit_opts.max_cache_size < MIN_CACHE_SIZE)
- mjit_opts.max_cache_size = MIN_CACHE_SIZE;
-
- // Initialize variables for compilation
-#ifdef _MSC_VER
- pch_status = PCH_SUCCESS; // has prebuilt precompiled header
-#else
- pch_status = PCH_NOT_READY;
-#endif
- cc_path = CC_COMMON_ARGS[0];
- verbose(2, "MJIT: CC defaults to %s", cc_path);
- cc_common_args = xmalloc(sizeof(CC_COMMON_ARGS));
- memcpy((void *)cc_common_args, CC_COMMON_ARGS, sizeof(CC_COMMON_ARGS));
- cc_added_args = split_flags(opts->debug_flags);
- xfree(opts->debug_flags);
-#if MJIT_CFLAGS_PIPE
- // eliminate a flag incompatible with `-pipe`
- for (size_t i = 0, j = 0; i < sizeof(CC_COMMON_ARGS) / sizeof(char *); i++) {
- if (CC_COMMON_ARGS[i] && strncmp("-save-temps", CC_COMMON_ARGS[i], strlen("-save-temps")) == 0)
- continue; // skip -save-temps flag
- cc_common_args[j] = CC_COMMON_ARGS[i];
- j++;
- }
-#endif
-
- tmp_dir = system_tmpdir();
- verbose(2, "MJIT: tmp_dir is %s", tmp_dir);
-
- if (!init_header_filename()) {
- mjit_enabled = false;
- verbose(1, "Failure in MJIT header file name initialization\n");
- return;
- }
- pch_owner_pid = getpid();
-
- // Initialize mutex
- rb_native_mutex_initialize(&mjit_engine_mutex);
- rb_native_cond_initialize(&mjit_pch_wakeup);
- rb_native_cond_initialize(&mjit_client_wakeup);
- rb_native_cond_initialize(&mjit_worker_wakeup);
- rb_native_cond_initialize(&mjit_gc_wakeup);
-
- // Make sure root_fiber's saved_ec is scanned by mark_ec_units
- rb_fiber_init_mjit_cont(GET_EC()->fiber_ptr);
-
- // Initialize class_serials cache for compilation
- valid_class_serials = rb_hash_new();
- rb_obj_hide(valid_class_serials);
- rb_gc_register_mark_object(valid_class_serials);
- mjit_add_class_serial(RCLASS_SERIAL(rb_cObject));
- mjit_add_class_serial(RCLASS_SERIAL(CLASS_OF(rb_vm_top_self())));
- if (RCLASS_CONST_TBL(rb_cObject)) {
- rb_id_table_foreach(RCLASS_CONST_TBL(rb_cObject), valid_class_serials_add_i, NULL);
- }
-
- // Initialize worker thread
- start_worker();
-}
-
-static void
-stop_worker(void)
-{
- rb_execution_context_t *ec = GET_EC();
-
- while (!worker_stopped) {
- verbose(3, "Sending cancel signal to worker");
- CRITICAL_SECTION_START(3, "in stop_worker");
- stop_worker_p = true; // Setting this inside loop because RUBY_VM_CHECK_INTS may make this false.
- rb_native_cond_broadcast(&mjit_worker_wakeup);
- CRITICAL_SECTION_FINISH(3, "in stop_worker");
- RUBY_VM_CHECK_INTS(ec);
- }
-}
-
-// Stop JIT-compiling methods but compiled code is kept available.
-VALUE
-mjit_pause(bool wait_p)
-{
- if (!mjit_enabled) {
- rb_raise(rb_eRuntimeError, "MJIT is not enabled");
- }
- if (worker_stopped) {
- return Qfalse;
- }
-
- // Flush all queued units with no option or `wait: true`
- if (wait_p) {
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 1000;
-
- while (unit_queue.length > 0 && active_units.length < mjit_opts.max_cache_size) { // inverse of condition that waits for mjit_worker_wakeup
- CRITICAL_SECTION_START(3, "in mjit_pause for a worker wakeup");
- rb_native_cond_broadcast(&mjit_worker_wakeup);
- CRITICAL_SECTION_FINISH(3, "in mjit_pause for a worker wakeup");
- rb_thread_wait_for(tv);
- }
- }
-
- stop_worker();
- return Qtrue;
-}
-
-// Restart JIT-compiling methods after mjit_pause.
-VALUE
-mjit_resume(void)
-{
- if (!mjit_enabled) {
- rb_raise(rb_eRuntimeError, "MJIT is not enabled");
- }
- if (!worker_stopped) {
- return Qfalse;
- }
-
- if (!start_worker()) {
- rb_raise(rb_eRuntimeError, "Failed to resume MJIT worker");
- }
- return Qtrue;
-}
-
-// Skip calling `clean_object_files` for units which currently exist in the list.
-static void
-skip_cleaning_object_files(struct rb_mjit_unit_list *list)
-{
- struct rb_mjit_unit *unit = NULL, *next;
-
- // No mutex for list, assuming MJIT worker does not exist yet since it's immediately after fork.
- list_for_each_safe(&list->head, unit, next, unode) {
-#ifndef _MSC_VER // Actually mswin does not reach here since it doesn't have fork
- if (unit->o_file) unit->o_file_inherited_p = true;
-#endif
-
-#if defined(_WIN32) // mswin doesn't reach here either. This is for MinGW.
- if (unit->so_file) unit->so_file = NULL;
-#endif
- }
-}
-
-// This is called after fork initiated by Ruby's method to launch MJIT worker thread
-// for child Ruby process.
-//
-// In multi-process Ruby applications, child Ruby processes do most of the jobs.
-// Thus we want child Ruby processes to enqueue ISeqs to MJIT worker's queue and
-// call the JIT-ed code.
-//
-// But unfortunately current MJIT-generated code is process-specific. After the fork,
-// JIT-ed code created by parent Ruby process cannot be used in child Ruby process
-// because the code could rely on inline cache values (ivar's IC, send's CC) which
-// may vary between processes after fork or embed some process-specific addresses.
-//
-// So child Ruby process can't request parent process to JIT an ISeq and use the code.
-// Instead of that, MJIT worker thread is created for all child Ruby processes, even
-// while child processes would end up with compiling the same ISeqs.
-void
-mjit_child_after_fork(void)
-{
- if (!mjit_enabled)
- return;
-
- /* Let parent process delete the already-compiled object files.
- This must be done before starting MJIT worker on child process. */
- skip_cleaning_object_files(&active_units);
-
- /* MJIT worker thread is not inherited on fork. Start it for this child process. */
- start_worker();
-}
-
-// Finish the threads processing units and creating PCH, finalize
-// and free MJIT data. It should be called last during MJIT
-// life.
-//
-// If close_handle_p is true, it calls dlclose() for JIT-ed code. So it should be false
-// if the code can still be on stack. ...But it means to leak JIT-ed handle forever (FIXME).
-void
-mjit_finish(bool close_handle_p)
-{
- if (!mjit_enabled)
- return;
-
- // Wait for pch finish
- verbose(2, "Stopping worker thread");
- CRITICAL_SECTION_START(3, "in mjit_finish to wakeup from pch");
- // As our threads are detached, we could just cancel them. But it
- // is a bad idea because OS processes (C compiler) started by
- // threads can produce temp files. And even if the temp files are
- // removed, the used C compiler still complaint about their
- // absence. So wait for a clean finish of the threads.
- while (pch_status == PCH_NOT_READY) {
- verbose(3, "Waiting wakeup from make_pch");
- rb_native_cond_wait(&mjit_pch_wakeup, &mjit_engine_mutex);
- }
- CRITICAL_SECTION_FINISH(3, "in mjit_finish to wakeup from pch");
-
- // Stop worker
- stop_worker();
-
- rb_native_mutex_destroy(&mjit_engine_mutex);
- rb_native_cond_destroy(&mjit_pch_wakeup);
- rb_native_cond_destroy(&mjit_client_wakeup);
- rb_native_cond_destroy(&mjit_worker_wakeup);
- rb_native_cond_destroy(&mjit_gc_wakeup);
-
-#ifndef _MSC_VER // mswin has prebuilt precompiled header
- if (!mjit_opts.save_temps && getpid() == pch_owner_pid)
- remove_file(pch_file);
-
- xfree(header_file); header_file = NULL;
-#endif
- xfree((void *)cc_common_args); cc_common_args = NULL;
- for (char **flag = cc_added_args; *flag != NULL; flag++)
- xfree(*flag);
- xfree((void *)cc_added_args); cc_added_args = NULL;
- xfree(tmp_dir); tmp_dir = NULL;
- xfree(pch_file); pch_file = NULL;
-
- mjit_call_p = false;
- free_list(&unit_queue, close_handle_p);
- free_list(&active_units, close_handle_p);
- free_list(&compact_units, close_handle_p);
- free_list(&stale_units, close_handle_p);
- finish_conts();
-
- mjit_enabled = false;
- verbose(1, "Successful MJIT finish");
-}
-
-void
-mjit_mark(void)
-{
- if (!mjit_enabled)
- return;
- RUBY_MARK_ENTER("mjit");
-
- CRITICAL_SECTION_START(4, "mjit_mark");
- VALUE iseq = (VALUE)mjit_copy_job.iseq;
- CRITICAL_SECTION_FINISH(4, "mjit_mark");
-
- // Don't wrap critical section with this. This may trigger GC,
- // and in that case mjit_gc_start_hook causes deadlock.
- if (iseq) rb_gc_mark(iseq);
-
- struct rb_mjit_unit *unit = NULL;
- CRITICAL_SECTION_START(4, "mjit_mark");
- list_for_each(&unit_queue.head, unit, unode) {
- if (unit->iseq) { // ISeq is still not GCed
- iseq = (VALUE)unit->iseq;
- CRITICAL_SECTION_FINISH(4, "mjit_mark rb_gc_mark");
-
- // Don't wrap critical section with this. This may trigger GC,
- // and in that case mjit_gc_start_hook causes deadlock.
- rb_gc_mark(iseq);
-
- CRITICAL_SECTION_START(4, "mjit_mark rb_gc_mark");
- }
- }
- CRITICAL_SECTION_FINISH(4, "mjit_mark");
-
- RUBY_MARK_LEAVE("mjit");
-}
-
-// A hook to update valid_class_serials.
-void
-mjit_add_class_serial(rb_serial_t class_serial)
-{
- if (!mjit_enabled)
- return;
-
- // Do not wrap CRITICAL_SECTION here. This function is only called in main thread
- // and guarded by GVL, and `rb_hash_aset` may cause GC and deadlock in it.
- rb_hash_aset(valid_class_serials, LONG2FIX(class_serial), Qtrue);
-}
-
-// A hook to update valid_class_serials.
-void
-mjit_remove_class_serial(rb_serial_t class_serial)
-{
- if (!mjit_enabled)
- return;
-
- CRITICAL_SECTION_START(3, "in mjit_remove_class_serial");
- rb_hash_delete_entry(valid_class_serials, LONG2FIX(class_serial));
- CRITICAL_SECTION_FINISH(3, "in mjit_remove_class_serial");
-}
-
-#endif
diff --git a/mjit.h b/mjit.h
deleted file mode 100644
index 256bf65a29..0000000000
--- a/mjit.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/**********************************************************************
-
- mjit.h - Interface to MRI method JIT compiler for Ruby's main thread
-
- Copyright (C) 2017 Vladimir Makarov <vmakarov@redhat.com>.
-
-**********************************************************************/
-
-#ifndef RUBY_MJIT_H
-#define RUBY_MJIT_H 1
-
-#include "ruby.h"
-#include "debug_counter.h"
-
-#if USE_MJIT
-
-// Special address values of a function generated from the
-// corresponding iseq by MJIT:
-enum rb_mjit_iseq_func {
- // ISEQ was not queued yet for the machine code generation
- NOT_ADDED_JIT_ISEQ_FUNC = 0,
- // ISEQ is already queued for the machine code generation but the
- // code is not ready yet for the execution
- NOT_READY_JIT_ISEQ_FUNC = 1,
- // ISEQ included not compilable insn, some internal assertion failed
- // or the unit is unloaded
- NOT_COMPILED_JIT_ISEQ_FUNC = 2,
- // End mark
- LAST_JIT_ISEQ_FUNC = 3
-};
-
-// MJIT options which can be defined on the MRI command line.
-struct mjit_options {
- // Converted from "jit" feature flag to tell the enablement
- // information to ruby_show_version().
- char on;
- // Save temporary files after MRI finish. The temporary files
- // include the pre-compiled header, C code file generated for ISEQ,
- // and the corresponding object file.
- char save_temps;
- // Print MJIT warnings to stderr.
- char warnings;
- // Disable compiler optimization and add debug symbols. It can be
- // very slow.
- char debug;
- // Add arbitrary cflags.
- char* debug_flags;
- // If not 0, all ISeqs are synchronously compiled. For testing.
- unsigned int wait;
- // Number of calls to trigger JIT compilation. For testing.
- unsigned int min_calls;
- // Force printing info about MJIT work of level VERBOSE or
- // less. 0=silence, 1=medium, 2=verbose.
- int verbose;
- // Maximal permitted number of iseq JIT codes in a MJIT memory
- // cache.
- int max_cache_size;
-};
-
-// State of optimization switches
-struct rb_mjit_compile_info {
- // Disable getinstancevariable/setinstancevariable optimizations based on inline cache
- bool disable_ivar_cache;
- // Disable send/opt_send_without_block optimizations based on inline cache
- bool disable_send_cache;
- // Disable method inlining
- bool disable_inlining;
-};
-
-typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
-
-RUBY_SYMBOL_EXPORT_BEGIN
-RUBY_EXTERN struct mjit_options mjit_opts;
-RUBY_EXTERN bool mjit_call_p;
-
-extern void rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq);
-extern VALUE rb_mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body);
-extern struct rb_mjit_compile_info* rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body);
-extern void rb_mjit_recompile_iseq(const rb_iseq_t *iseq);
-RUBY_SYMBOL_EXPORT_END
-
-extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname);
-extern void mjit_init(const struct mjit_options *opts);
-extern void mjit_gc_start_hook(void);
-extern void mjit_gc_exit_hook(void);
-extern void mjit_free_iseq(const rb_iseq_t *iseq);
-extern void mjit_update_references(const rb_iseq_t *iseq);
-extern void mjit_mark(void);
-extern struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec);
-extern void mjit_cont_free(struct mjit_cont *cont);
-extern void mjit_add_class_serial(rb_serial_t class_serial);
-extern void mjit_remove_class_serial(rb_serial_t class_serial);
-
-// A threshold used to reject long iseqs from JITting as such iseqs
-// takes too much time to be compiled.
-#define JIT_ISEQ_SIZE_THRESHOLD 1000
-
-// Return TRUE if given ISeq body should be compiled by MJIT
-static inline int
-mjit_target_iseq_p(struct rb_iseq_constant_body *body)
-{
- return (body->type == ISEQ_TYPE_METHOD || body->type == ISEQ_TYPE_BLOCK)
- && body->iseq_size < JIT_ISEQ_SIZE_THRESHOLD;
-}
-
-// Try to execute the current iseq in ec. Use JIT code if it is ready.
-// If it is not, add ISEQ to the compilation queue and return Qundef.
-static inline VALUE
-mjit_exec(rb_execution_context_t *ec)
-{
- const rb_iseq_t *iseq;
- struct rb_iseq_constant_body *body;
- long unsigned total_calls;
- mjit_func_t func;
-
- if (!mjit_call_p)
- return Qundef;
- RB_DEBUG_COUNTER_INC(mjit_exec);
-
- iseq = ec->cfp->iseq;
- body = iseq->body;
- total_calls = ++body->total_calls;
-
- func = body->jit_func;
- if (UNLIKELY((uintptr_t)func <= (uintptr_t)LAST_JIT_ISEQ_FUNC)) {
-# ifdef MJIT_HEADER
- RB_DEBUG_COUNTER_INC(mjit_frame_JT2VM);
-# else
- RB_DEBUG_COUNTER_INC(mjit_frame_VM2VM);
-# endif
- switch ((enum rb_mjit_iseq_func)func) {
- case NOT_ADDED_JIT_ISEQ_FUNC:
- RB_DEBUG_COUNTER_INC(mjit_exec_not_added);
- if (total_calls == mjit_opts.min_calls && mjit_target_iseq_p(body)) {
- RB_DEBUG_COUNTER_INC(mjit_exec_not_added_add_iseq);
- rb_mjit_add_iseq_to_process(iseq);
- if (UNLIKELY(mjit_opts.wait)) {
- return rb_mjit_wait_call(ec, body);
- }
- }
- return Qundef;
- case NOT_READY_JIT_ISEQ_FUNC:
- RB_DEBUG_COUNTER_INC(mjit_exec_not_ready);
- return Qundef;
- case NOT_COMPILED_JIT_ISEQ_FUNC:
- RB_DEBUG_COUNTER_INC(mjit_exec_not_compiled);
- return Qundef;
- default: // to avoid warning with LAST_JIT_ISEQ_FUNC
- break;
- }
- }
-
-# ifdef MJIT_HEADER
- RB_DEBUG_COUNTER_INC(mjit_frame_JT2JT);
-# else
- RB_DEBUG_COUNTER_INC(mjit_frame_VM2JT);
-# endif
- RB_DEBUG_COUNTER_INC(mjit_exec_call_func);
- return func(ec, ec->cfp);
-}
-
-void mjit_child_after_fork(void);
-
-#else // USE_MJIT
-static inline struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec){return NULL;}
-static inline void mjit_cont_free(struct mjit_cont *cont){}
-static inline void mjit_gc_start_hook(void){}
-static inline void mjit_gc_exit_hook(void){}
-static inline void mjit_free_iseq(const rb_iseq_t *iseq){}
-static inline void mjit_mark(void){}
-static inline void mjit_add_class_serial(rb_serial_t class_serial){}
-static inline void mjit_remove_class_serial(rb_serial_t class_serial){}
-static inline VALUE mjit_exec(rb_execution_context_t *ec) { return Qundef; /* unreachable */ }
-static inline void mjit_child_after_fork(void){}
-
-#endif // USE_MJIT
-#endif // RUBY_MJIT_H
diff --git a/mjit_compile.c b/mjit_compile.c
deleted file mode 100644
index f379a896a8..0000000000
--- a/mjit_compile.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/**********************************************************************
-
- mjit_compile.c - MRI method JIT compiler
-
- Copyright (C) 2017 Takashi Kokubun <takashikkbn@gmail.com>.
-
-**********************************************************************/
-
-// NOTE: All functions in this file are executed on MJIT worker. So don't
-// call Ruby methods (C functions that may call rb_funcall) or trigger
-// GC (using ZALLOC, xmalloc, xfree, etc.) in this file.
-
-#include "internal.h"
-
-#if USE_MJIT
-
-#include "vm_core.h"
-#include "vm_exec.h"
-#include "mjit.h"
-#include "builtin.h"
-#include "insns.inc"
-#include "insns_info.inc"
-#include "vm_insnhelper.h"
-
-// Macros to check if a position is already compiled using compile_status.stack_size_for_pos
-#define NOT_COMPILED_STACK_SIZE -1
-#define ALREADY_COMPILED_P(status, pos) (status->stack_size_for_pos[pos] != NOT_COMPILED_STACK_SIZE)
-
-static size_t
-call_data_index(CALL_DATA cd, const struct rb_iseq_constant_body *body)
-{
- const struct rb_kwarg_call_data *kw_calls = (const struct rb_kwarg_call_data *)&body->call_data[body->ci_size];
- const struct rb_kwarg_call_data *kw_cd = (const struct rb_kwarg_call_data *)cd;
-
- VM_ASSERT(cd >= body->call_data && kw_cd < (kw_calls + body->ci_kw_size));
- if (kw_cd < kw_calls) {
- return cd - body->call_data;
- }
- else {
- return kw_cd - kw_calls + body->ci_size;
- }
-}
-
-// For propagating information needed for lazily pushing a frame.
-struct inlined_call_context {
- int orig_argc; // ci->orig_argc
- VALUE me; // cc->me
- int param_size; // def_iseq_ptr(cc->me->def)->body->param.size
- int local_size; // def_iseq_ptr(cc->me->def)->body->local_table_size
-};
-
-// Storage to keep compiler's status. This should have information
-// which is global during one `mjit_compile` call. Ones conditional
-// in each branch should be stored in `compile_branch`.
-struct compile_status {
- bool success; // has true if compilation has had no issue
- int *stack_size_for_pos; // stack_size_for_pos[pos] has stack size for the position (otherwise -1)
- // If true, JIT-ed code will use local variables to store pushed values instead of
- // using VM's stack and moving stack pointer.
- bool local_stack_p;
- // Safely-accessible cache entries copied from main thread.
- union iseq_inline_storage_entry *is_entries;
- struct rb_call_cache *cc_entries;
- // Mutated optimization levels
- struct rb_mjit_compile_info *compile_info;
- // If `inlined_iseqs[pos]` is not NULL, `mjit_compile_body` tries to inline ISeq there.
- const struct rb_iseq_constant_body **inlined_iseqs;
- struct inlined_call_context inline_context;
-};
-
-// Storage to keep data which is consistent in each conditional branch.
-// This is created and used for one `compile_insns` call and its values
-// should be copied for extra `compile_insns` call.
-struct compile_branch {
- unsigned int stack_size; // this simulates sp (stack pointer) of YARV
- bool finish_p; // if true, compilation in this branch should stop and let another branch to be compiled
-};
-
-struct case_dispatch_var {
- FILE *f;
- unsigned int base_pos;
- VALUE last_value;
-};
-
-// Returns true if call cache is still not obsoleted and cc->me->def->type is available.
-static bool
-has_valid_method_type(CALL_CACHE cc)
-{
- extern bool mjit_valid_class_serial_p(rb_serial_t class_serial);
- return GET_GLOBAL_METHOD_STATE() == cc->method_state
- && mjit_valid_class_serial_p(cc->class_serial[0]) && cc->me;
-}
-
-// Returns true if iseq can use fastpath for setup, otherwise NULL. This becomes true in the same condition
-// as CC_SET_FASTPATH (in vm_callee_setup_arg) is called from vm_call_iseq_setup.
-static bool
-fastpath_applied_iseq_p(const CALL_INFO ci, const CALL_CACHE cc, const rb_iseq_t *iseq)
-{
- extern bool rb_simple_iseq_p(const rb_iseq_t *iseq);
- return iseq != NULL
- && !(ci->flag & VM_CALL_KW_SPLAT) && rb_simple_iseq_p(iseq) // Top of vm_callee_setup_arg. In this case, opt_pc is 0.
- && ci->orig_argc == iseq->body->param.lead_num // exclude argument_arity_error (assumption: `calling->argc == ci->orig_argc` in send insns)
- && vm_call_iseq_optimizable_p(ci, cc); // CC_SET_FASTPATH condition
-}
-
-static int
-compile_case_dispatch_each(VALUE key, VALUE value, VALUE arg)
-{
- struct case_dispatch_var *var = (struct case_dispatch_var *)arg;
- unsigned int offset;
-
- if (var->last_value != value) {
- offset = FIX2INT(value);
- var->last_value = value;
- fprintf(var->f, " case %d:\n", offset);
- fprintf(var->f, " goto label_%d;\n", var->base_pos + offset);
- fprintf(var->f, " break;\n");
- }
- return ST_CONTINUE;
-}
-
-// Calling rb_id2str in MJIT worker causes random SEGV. So this is disabled by default.
-static void
-comment_id(FILE *f, ID id)
-{
-#ifdef MJIT_COMMENT_ID
- VALUE name = rb_id2str(id);
- const char *p, *e;
- char c, prev = '\0';
-
- if (!name) return;
- p = RSTRING_PTR(name);
- e = RSTRING_END(name);
- fputs("/* :\"", f);
- for (; p < e; ++p) {
- switch (c = *p) {
- case '*': case '/': if (prev != (c ^ ('/' ^ '*'))) break;
- case '\\': case '"': fputc('\\', f);
- }
- fputc(c, f);
- prev = c;
- }
- fputs("\" */", f);
-#endif
-}
-
-static void compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int stack_size,
- unsigned int pos, struct compile_status *status);
-
-// Main function of JIT compilation, vm_exec_core counterpart for JIT. Compile one insn to `f`, may modify
-// b->stack_size and return next position.
-//
-// When you add a new instruction to insns.def, it would be nice to have JIT compilation support here but
-// it's optional. This JIT compiler just ignores ISeq which includes unknown instruction, and ISeq which
-// does not have it can be compiled as usual.
-static unsigned int
-compile_insn(FILE *f, const struct rb_iseq_constant_body *body, const int insn, const VALUE *operands,
- const unsigned int pos, struct compile_status *status, struct compile_branch *b)
-{
- unsigned int next_pos = pos + insn_len(insn);
-
-/*****************/
- #include "mjit_compile.inc"
-/*****************/
-
- // If next_pos is already compiled and this branch is not finished yet,
- // next instruction won't be compiled in C code next and will need `goto`.
- if (!b->finish_p && next_pos < body->iseq_size && ALREADY_COMPILED_P(status, next_pos)) {
- fprintf(f, "goto label_%d;\n", next_pos);
-
- // Verify stack size assumption is the same among multiple branches
- if ((unsigned int)status->stack_size_for_pos[next_pos] != b->stack_size) {
- if (mjit_opts.warnings || mjit_opts.verbose)
- fprintf(stderr, "MJIT warning: JIT stack assumption is not the same between branches (%d != %u)\n",
- status->stack_size_for_pos[next_pos], b->stack_size);
- status->success = false;
- }
- }
-
- return next_pos;
-}
-
-// Compile one conditional branch. If it has branchXXX insn, this should be
-// called multiple times for each branch.
-static void
-compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int stack_size,
- unsigned int pos, struct compile_status *status)
-{
- int insn;
- struct compile_branch branch;
-
- branch.stack_size = stack_size;
- branch.finish_p = false;
-
- while (pos < body->iseq_size && !ALREADY_COMPILED_P(status, pos) && !branch.finish_p) {
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
- insn = rb_vm_insn_addr2insn((void *)body->iseq_encoded[pos]);
-#else
- insn = (int)body->iseq_encoded[pos];
-#endif
- status->stack_size_for_pos[pos] = (int)branch.stack_size;
-
- fprintf(f, "\nlabel_%d: /* %s */\n", pos, insn_name(insn));
- pos = compile_insn(f, body, insn, body->iseq_encoded + (pos+1), pos, status, &branch);
- if (status->success && branch.stack_size > body->stack_max) {
- if (mjit_opts.warnings || mjit_opts.verbose)
- fprintf(stderr, "MJIT warning: JIT stack size (%d) exceeded its max size (%d)\n", branch.stack_size, body->stack_max);
- status->success = false;
- }
- if (!status->success)
- break;
- }
-}
-
-// Print the block to cancel inlined method call. It's supporting only `opt_send_without_block` for now.
-static void
-compile_inlined_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct inlined_call_context *inline_context)
-{
- fprintf(f, "\ncancel:\n");
- fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel);\n");
- fprintf(f, " rb_mjit_iseq_compile_info(original_iseq->body)->disable_inlining = true;\n");
- fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n");
-
- // Swap pc/sp set on cancel with original pc/sp.
- fprintf(f, " const VALUE current_pc = reg_cfp->pc;\n");
- fprintf(f, " const VALUE current_sp = reg_cfp->sp;\n");
- fprintf(f, " reg_cfp->pc = orig_pc;\n");
- fprintf(f, " reg_cfp->sp = orig_sp;\n\n");
-
- // Lazily push the current call frame.
- fprintf(f, " struct rb_calling_info calling;\n");
- fprintf(f, " calling.block_handler = VM_BLOCK_HANDLER_NONE;\n"); // assumes `opt_send_without_block`
- fprintf(f, " calling.argc = %d;\n", inline_context->orig_argc);
- fprintf(f, " calling.recv = reg_cfp->self;\n");
- fprintf(f, " reg_cfp->self = orig_self;\n");
- fprintf(f, " vm_call_iseq_setup_normal(ec, reg_cfp, &calling, (const rb_callable_method_entry_t *)0x%"PRIxVALUE", 0, %d, %d);\n\n",
- inline_context->me, inline_context->param_size, inline_context->local_size); // fastpath_applied_iseq_p checks rb_simple_iseq_p, which ensures has_opt == FALSE
-
- // Start usual cancel from here.
- fprintf(f, " reg_cfp = ec->cfp;\n"); // work on the new frame
- fprintf(f, " reg_cfp->pc = current_pc;\n");
- fprintf(f, " reg_cfp->sp = current_sp;\n");
- for (unsigned int i = 0; i < body->stack_max; i++) { // should be always `status->local_stack_p`
- fprintf(f, " *(vm_base_ptr(reg_cfp) + %d) = stack[%d];\n", i, i);
- }
- // We're not just returning Qundef here so that caller's normal cancel handler can
- // push back `stack` to `cfp->sp`.
- fprintf(f, " return vm_exec(ec, ec->cfp);\n");
-}
-
-// Print the block to cancel JIT execution.
-static void
-compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct compile_status *status)
-{
- if (status->inlined_iseqs == NULL) { // the current ISeq is being inlined
- compile_inlined_cancel_handler(f, body, &status->inline_context);
- return;
- }
-
- fprintf(f, "\nsend_cancel:\n");
- fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_send_inline);\n");
- fprintf(f, " rb_mjit_iseq_compile_info(original_iseq->body)->disable_send_cache = true;\n");
- fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n");
- fprintf(f, " goto cancel;\n");
-
- fprintf(f, "\nivar_cancel:\n");
- fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_ivar_inline);\n");
- fprintf(f, " rb_mjit_iseq_compile_info(original_iseq->body)->disable_ivar_cache = true;\n");
- fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n");
- fprintf(f, " goto cancel;\n");
-
- fprintf(f, "\ncancel:\n");
- fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel);\n");
- if (status->local_stack_p) {
- for (unsigned int i = 0; i < body->stack_max; i++) {
- fprintf(f, " *(vm_base_ptr(reg_cfp) + %d) = stack[%d];\n", i, i);
- }
- }
- fprintf(f, " return Qundef;\n");
-}
-
-extern bool mjit_copy_cache_from_main_thread(const rb_iseq_t *iseq, struct rb_call_cache *cc_entries, union iseq_inline_storage_entry *is_entries);
-
-static bool
-mjit_compile_body(FILE *f, const rb_iseq_t *iseq, struct compile_status *status)
-{
- const struct rb_iseq_constant_body *body = iseq->body;
- status->success = true;
- status->local_stack_p = !body->catch_except_p;
-
- if (status->local_stack_p) {
- fprintf(f, " VALUE stack[%d];\n", body->stack_max);
- }
- else {
- fprintf(f, " VALUE *stack = reg_cfp->sp;\n");
- }
- if (status->inlined_iseqs != NULL) // i.e. compile root
- fprintf(f, " static const rb_iseq_t *original_iseq = (const rb_iseq_t *)0x%"PRIxVALUE";\n", (VALUE)iseq);
- fprintf(f, " static const VALUE *const original_body_iseq = (VALUE *)0x%"PRIxVALUE";\n",
- (VALUE)body->iseq_encoded);
-
- // Simulate `opt_pc` in setup_parameters_complex. Other PCs which may be passed by catch tables
- // are not considered since vm_exec doesn't call mjit_exec for catch tables.
- if (body->param.flags.has_opt) {
- int i;
- fprintf(f, "\n");
- fprintf(f, " switch (reg_cfp->pc - reg_cfp->iseq->body->iseq_encoded) {\n");
- for (i = 0; i <= body->param.opt_num; i++) {
- VALUE pc_offset = body->param.opt_table[i];
- fprintf(f, " case %"PRIdVALUE":\n", pc_offset);
- fprintf(f, " goto label_%"PRIdVALUE";\n", pc_offset);
- }
- fprintf(f, " }\n");
- }
-
- compile_insns(f, body, 0, 0, status);
- compile_cancel_handler(f, body, status);
- return status->success;
-}
-
-// Return true if the ISeq can be inlined without pushing a new control frame.
-static bool
-inlinable_iseq_p(const struct rb_iseq_constant_body *body)
-{
- // 1) If catch_except_p, caller frame should be preserved when callee catches an exception.
- // Then we need to wrap `vm_exec()` but then we can't inline the call inside it.
- //
- // 2) If `body->catch_except_p` is false and `handles_sp?` of an insn is false,
- // sp is not moved as we assume `status->local_stack_p = !body->catch_except_p`.
- //
- // 3) If `body->catch_except_p` is false and `always_leaf?` of an insn is true,
- // pc is not moved.
- if (body->catch_except_p)
- return false;
-
- unsigned int pos = 0;
- while (pos < body->iseq_size) {
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
- int insn = rb_vm_insn_addr2insn((void *)body->iseq_encoded[pos]);
-#else
- int insn = (int)body->iseq_encoded[pos];
-#endif
- // All insns in the ISeq except `leave` (to be overridden in the inlined code)
- // should meet following strong assumptions:
- // * Do not require `cfp->sp` motion
- // * Do not move `cfp->pc`
- // * Do not read any `cfp->pc`
- if (insn != BIN(leave) && insn_may_depend_on_sp_or_pc(insn, body->iseq_encoded + (pos + 1)))
- return false;
- // At this moment, `cfp->ep` in an inlined method is not working.
- switch (insn) {
- case BIN(getlocal):
- case BIN(getlocal_WC_0):
- case BIN(getlocal_WC_1):
- case BIN(setlocal):
- case BIN(setlocal_WC_0):
- case BIN(setlocal_WC_1):
- case BIN(getblockparam):
- case BIN(getblockparamproxy):
- case BIN(setblockparam):
- return false;
- }
- pos += insn_len(insn);
- }
- return true;
-}
-
-// This needs to be macro instead of a function because it's using `alloca`.
-#define INIT_COMPILE_STATUS(status, body, compile_root_p) do { \
- status = (struct compile_status){ \
- .stack_size_for_pos = (int *)alloca(sizeof(int) * body->iseq_size), \
- .inlined_iseqs = compile_root_p ? \
- alloca(sizeof(const struct rb_iseq_constant_body *) * body->iseq_size) : NULL, \
- .cc_entries = (body->ci_size + body->ci_kw_size) > 0 ? \
- alloca(sizeof(struct rb_call_cache) * (body->ci_size + body->ci_kw_size)) : NULL, \
- .is_entries = (body->is_size > 0) ? \
- alloca(sizeof(union iseq_inline_storage_entry) * body->is_size) : NULL, \
- .compile_info = compile_root_p ? \
- rb_mjit_iseq_compile_info(body) : alloca(sizeof(struct rb_mjit_compile_info)) \
- }; \
- memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size); \
- if (compile_root_p) \
- memset((void *)status.inlined_iseqs, 0, sizeof(const struct rb_iseq_constant_body *) * body->iseq_size); \
- else \
- memset(status.compile_info, 0, sizeof(struct rb_mjit_compile_info)); \
-} while (0)
-
-// Compile inlinable ISeqs to C code in `f`. It returns true if it succeeds to compile them.
-static bool
-precompile_inlinable_iseqs(FILE *f, const rb_iseq_t *iseq, struct compile_status *status)
-{
- const struct rb_iseq_constant_body *body = iseq->body;
- unsigned int pos = 0;
- while (pos < body->iseq_size) {
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
- int insn = rb_vm_insn_addr2insn((void *)body->iseq_encoded[pos]);
-#else
- int insn = (int)body->iseq_encoded[pos];
-#endif
-
- if (insn == BIN(opt_send_without_block)) { // `compile_inlined_cancel_handler` supports only `opt_send_without_block`
- CALL_DATA cd = (CALL_DATA)body->iseq_encoded[pos + 1];
- CALL_INFO ci = &cd->ci;
- CALL_CACHE cc_copy = status->cc_entries + call_data_index(cd, body); // use copy to avoid race condition
-
- const rb_iseq_t *child_iseq;
- if (has_valid_method_type(cc_copy) &&
- !(ci->flag & VM_CALL_TAILCALL) && // inlining only non-tailcall path
- cc_copy->me->def->type == VM_METHOD_TYPE_ISEQ && fastpath_applied_iseq_p(ci, cc_copy, child_iseq = def_iseq_ptr(cc_copy->me->def)) && // CC_SET_FASTPATH in vm_callee_setup_arg
- inlinable_iseq_p(child_iseq->body)) {
- status->inlined_iseqs[pos] = child_iseq->body;
-
- if (mjit_opts.verbose >= 1) // print beforehand because ISeq may be GCed during copy job.
- fprintf(stderr, "JIT inline: %s@%s:%d => %s@%s:%d\n",
- RSTRING_PTR(iseq->body->location.label),
- RSTRING_PTR(rb_iseq_path(iseq)), FIX2INT(iseq->body->location.first_lineno),
- RSTRING_PTR(child_iseq->body->location.label),
- RSTRING_PTR(rb_iseq_path(child_iseq)), FIX2INT(child_iseq->body->location.first_lineno));
-
- struct compile_status child_status;
- INIT_COMPILE_STATUS(child_status, child_iseq->body, false);
- child_status.inline_context = (struct inlined_call_context){
- .orig_argc = ci->orig_argc,
- .me = (VALUE)cc_copy->me,
- .param_size = child_iseq->body->param.size,
- .local_size = child_iseq->body->local_table_size
- };
- if ((child_status.cc_entries != NULL || child_status.is_entries != NULL)
- && !mjit_copy_cache_from_main_thread(child_iseq, child_status.cc_entries, child_status.is_entries))
- return false;
-
- fprintf(f, "ALWAYS_INLINE(static VALUE _mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq));\n", pos);
- fprintf(f, "static inline VALUE\n_mjit_inlined_%d(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE orig_self, const rb_iseq_t *original_iseq)\n{\n", pos);
- fprintf(f, " const VALUE *orig_pc = reg_cfp->pc;\n");
- fprintf(f, " const VALUE *orig_sp = reg_cfp->sp;\n");
- bool success = mjit_compile_body(f, child_iseq, &child_status);
- fprintf(f, "\n} /* end of _mjit_inlined_%d */\n\n", pos);
-
- if (!success)
- return false;
- }
- }
- pos += insn_len(insn);
- }
- return true;
-}
-
-// Compile ISeq to C code in `f`. It returns true if it succeeds to compile.
-bool
-mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname)
-{
- // For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug
- if (!mjit_opts.debug) {
- fprintf(f, "#undef OPT_CHECKED_RUN\n");
- fprintf(f, "#define OPT_CHECKED_RUN 0\n\n");
- }
-
- struct compile_status status;
- INIT_COMPILE_STATUS(status, iseq->body, true);
- if ((status.cc_entries != NULL || status.is_entries != NULL)
- && !mjit_copy_cache_from_main_thread(iseq, status.cc_entries, status.is_entries))
- return false;
-
- if (!status.compile_info->disable_send_cache && !status.compile_info->disable_inlining) {
- if (!precompile_inlinable_iseqs(f, iseq, &status))
- return false;
- }
-
-#ifdef _WIN32
- fprintf(f, "__declspec(dllexport)\n");
-#endif
- fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname);
- bool success = mjit_compile_body(f, iseq, &status);
- fprintf(f, "\n} // end of %s\n", funcname);
- return success;
-}
-
-#endif // USE_MJIT
diff --git a/mjit_worker.c b/mjit_worker.c
deleted file mode 100644
index 95518883c6..0000000000
--- a/mjit_worker.c
+++ /dev/null
@@ -1,1259 +0,0 @@
-/**********************************************************************
-
- mjit_worker.c - Worker for MRI method JIT compiler
-
- Copyright (C) 2017 Vladimir Makarov <vmakarov@redhat.com>.
-
-**********************************************************************/
-
-// NOTE: All functions in this file are executed on MJIT worker. So don't
-// call Ruby methods (C functions that may call rb_funcall) or trigger
-// GC (using ZALLOC, xmalloc, xfree, etc.) in this file.
-
-/* We utilize widely used C compilers (GCC and LLVM Clang) to
- implement MJIT. We feed them a C code generated from ISEQ. The
- industrial C compilers are slower than regular JIT engines.
- Generated code performance of the used C compilers has a higher
- priority over the compilation speed.
-
- So our major goal is to minimize the ISEQ compilation time when we
- use widely optimization level (-O2). It is achieved by
-
- o Using a precompiled version of the header
- o Keeping all files in `/tmp`. On modern Linux `/tmp` is a file
- system in memory. So it is pretty fast
- o Implementing MJIT as a multi-threaded code because we want to
- compile ISEQs in parallel with iseq execution to speed up Ruby
- code execution. MJIT has one thread (*worker*) to do
- parallel compilations:
- o It prepares a precompiled code of the minimized header.
- It starts at the MRI execution start
- o It generates PIC object files of ISEQs
- o It takes one JIT unit from a priority queue unless it is empty.
- o It translates the JIT unit ISEQ into C-code using the precompiled
- header, calls CC and load PIC code when it is ready
- o Currently MJIT put ISEQ in the queue when ISEQ is called
- o MJIT can reorder ISEQs in the queue if some ISEQ has been called
- many times and its compilation did not start yet
- o MRI reuses the machine code if it already exists for ISEQ
- o The machine code we generate can stop and switch to the ISEQ
- interpretation if some condition is not satisfied as the machine
- code can be speculative or some exception raises
- o Speculative machine code can be canceled.
-
- Here is a diagram showing the MJIT organization:
-
- _______
- |header |
- |_______|
- | MRI building
- --------------|----------------------------------------
- | MRI execution
- |
- _____________|_____
- | | |
- | ___V__ | CC ____________________
- | | |----------->| precompiled header |
- | | | | |____________________|
- | | | | |
- | | MJIT | | |
- | | | | |
- | | | | ____V___ CC __________
- | |______|----------->| C code |--->| .so file |
- | | |________| |__________|
- | | |
- | | |
- | MRI machine code |<-----------------------------
- |___________________| loading
-
-*/
-
-#ifdef __sun
-#define __EXTENSIONS__ 1
-#endif
-
-#include "vm_core.h"
-#include "mjit.h"
-#include "gc.h"
-#include "ruby_assert.h"
-#include "ruby/debug.h"
-#include "ruby/thread.h"
-
-#ifdef _WIN32
-#include <winsock2.h>
-#include <windows.h>
-#else
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <dlfcn.h>
-#endif
-#include <errno.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-#include "dln.h"
-
-#include "ruby/util.h"
-#undef strdup // ruby_strdup may trigger GC
-
-#ifndef MAXPATHLEN
-# define MAXPATHLEN 1024
-#endif
-
-#ifdef _WIN32
-#define dlopen(name,flag) ((void*)LoadLibrary(name))
-#define dlerror() strerror(rb_w32_map_errno(GetLastError()))
-#define dlsym(handle,name) ((void*)GetProcAddress((handle),(name)))
-#define dlclose(handle) (!FreeLibrary(handle))
-#define RTLD_NOW -1
-
-#define waitpid(pid,stat_loc,options) (WaitForSingleObject((HANDLE)(pid), INFINITE), GetExitCodeProcess((HANDLE)(pid), (LPDWORD)(stat_loc)), CloseHandle((HANDLE)pid), (pid))
-#define WIFEXITED(S) ((S) != STILL_ACTIVE)
-#define WEXITSTATUS(S) (S)
-#define WIFSIGNALED(S) (0)
-typedef intptr_t pid_t;
-#endif
-
-// Atomically set function pointer if possible.
-#define MJIT_ATOMIC_SET(var, val) (void)ATOMIC_PTR_EXCHANGE(var, val)
-
-#define MJIT_TMP_PREFIX "_ruby_mjit_"
-
-// The unit structure that holds metadata of ISeq for MJIT.
-struct rb_mjit_unit {
- // Unique order number of unit.
- int id;
- // Dlopen handle of the loaded object file.
- void *handle;
- rb_iseq_t *iseq;
-#ifndef _MSC_VER
- // This value is always set for `compact_all_jit_code`. Also used for lazy deletion.
- char *o_file;
- // true if it's inherited from parent Ruby process and lazy deletion should be skipped.
- // `o_file = NULL` can't be used to skip lazy deletion because `o_file` could be used
- // by child for `compact_all_jit_code`.
- bool o_file_inherited_p;
-#endif
-#if defined(_WIN32)
- // DLL cannot be removed while loaded on Windows. If this is set, it'll be lazily deleted.
- char *so_file;
-#endif
- // Only used by unload_units. Flag to check this unit is currently on stack or not.
- char used_code_p;
- struct list_node unode;
- // mjit_compile's optimization switches
- struct rb_mjit_compile_info compile_info;
-};
-
-// Linked list of struct rb_mjit_unit.
-struct rb_mjit_unit_list {
- struct list_head head;
- int length; // the list length
-};
-
-extern void rb_native_mutex_lock(rb_nativethread_lock_t *lock);
-extern void rb_native_mutex_unlock(rb_nativethread_lock_t *lock);
-extern void rb_native_mutex_initialize(rb_nativethread_lock_t *lock);
-extern void rb_native_mutex_destroy(rb_nativethread_lock_t *lock);
-
-extern void rb_native_cond_initialize(rb_nativethread_cond_t *cond);
-extern void rb_native_cond_destroy(rb_nativethread_cond_t *cond);
-extern void rb_native_cond_signal(rb_nativethread_cond_t *cond);
-extern void rb_native_cond_broadcast(rb_nativethread_cond_t *cond);
-extern void rb_native_cond_wait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex);
-
-// process.c
-extern rb_pid_t ruby_waitpid_locked(rb_vm_t *, rb_pid_t, int *status, int options, rb_nativethread_cond_t *cond);
-
-// A copy of MJIT portion of MRI options since MJIT initialization. We
-// need them as MJIT threads still can work when the most MRI data were
-// freed.
-struct mjit_options mjit_opts;
-
-// true if MJIT is enabled.
-bool mjit_enabled = false;
-// true if JIT-ed code should be called. When `ruby_vm_event_enabled_global_flags & ISEQ_TRACE_EVENTS`
-// and `mjit_call_p == false`, any JIT-ed code execution is cancelled as soon as possible.
-bool mjit_call_p = false;
-
-// Priority queue of iseqs waiting for JIT compilation.
-// This variable is a pointer to head unit of the queue.
-static struct rb_mjit_unit_list unit_queue = { LIST_HEAD_INIT(unit_queue.head) };
-// List of units which are successfully compiled.
-static struct rb_mjit_unit_list active_units = { LIST_HEAD_INIT(active_units.head) };
-// List of compacted so files which will be cleaned up by `free_list()` in `mjit_finish()`.
-static struct rb_mjit_unit_list compact_units = { LIST_HEAD_INIT(compact_units.head) };
-// List of units before recompilation and just waiting for dlclose().
-static struct rb_mjit_unit_list stale_units = { LIST_HEAD_INIT(stale_units.head) };
-// The number of so far processed ISEQs, used to generate unique id.
-static int current_unit_num;
-// A mutex for conitionals and critical sections.
-static rb_nativethread_lock_t mjit_engine_mutex;
-// A thread conditional to wake up `mjit_finish` at the end of PCH thread.
-static rb_nativethread_cond_t mjit_pch_wakeup;
-// A thread conditional to wake up the client if there is a change in
-// executed unit status.
-static rb_nativethread_cond_t mjit_client_wakeup;
-// A thread conditional to wake up a worker if there we have something
-// to add or we need to stop MJIT engine.
-static rb_nativethread_cond_t mjit_worker_wakeup;
-// A thread conditional to wake up workers if at the end of GC.
-static rb_nativethread_cond_t mjit_gc_wakeup;
-// True when GC is working.
-static bool in_gc;
-// True when JIT is working.
-static bool in_jit;
-// Set to true to stop worker.
-static bool stop_worker_p;
-// Set to true if worker is stopped.
-static bool worker_stopped;
-
-// Path of "/tmp", which can be changed to $TMP in MinGW.
-static char *tmp_dir;
-// Hash like { 1 => true, 2 => true, ... } whose keys are valid `class_serial`s.
-// This is used to invalidate obsoleted CALL_CACHE.
-static VALUE valid_class_serials;
-
-// Used C compiler path.
-static const char *cc_path;
-// Used C compiler flags.
-static const char **cc_common_args;
-// Used C compiler flags added by --jit-debug=...
-static char **cc_added_args;
-// Name of the precompiled header file.
-static char *pch_file;
-// The process id which should delete the pch_file on mjit_finish.
-static rb_pid_t pch_owner_pid;
-// Status of the precompiled header creation. The status is
-// shared by the workers and the pch thread.
-static enum {PCH_NOT_READY, PCH_FAILED, PCH_SUCCESS} pch_status;
-
-#ifndef _MSC_VER
-// Name of the header file.
-static char *header_file;
-#endif
-
-#ifdef _WIN32
-// Linker option to enable libruby.
-static char *libruby_pathflag;
-#endif
-
-#include "mjit_config.h"
-
-#if defined(__GNUC__) && \
- (!defined(__clang__) || \
- (defined(__clang__) && (defined(__FreeBSD__) || defined(__GLIBC__))))
-# define GCC_PIC_FLAGS "-Wfatal-errors", "-fPIC", "-shared", "-w", "-pipe",
-# define MJIT_CFLAGS_PIPE 1
-#else
-# define GCC_PIC_FLAGS /* empty */
-# define MJIT_CFLAGS_PIPE 0
-#endif
-
-// Use `-nodefaultlibs -nostdlib` for GCC where possible, which does not work on mingw, cygwin, AIX, and OpenBSD.
-// This seems to improve MJIT performance on GCC.
-#if defined __GNUC__ && !defined __clang__ && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(_AIX) && !defined(__OpenBSD__)
-# define GCC_NOSTDLIB_FLAGS "-nodefaultlibs", "-nostdlib",
-#else
-# define GCC_NOSTDLIB_FLAGS // empty
-#endif
-
-static const char *const CC_COMMON_ARGS[] = {
- MJIT_CC_COMMON MJIT_CFLAGS GCC_PIC_FLAGS
- NULL
-};
-
-static const char *const CC_DEBUG_ARGS[] = {MJIT_DEBUGFLAGS NULL};
-static const char *const CC_OPTIMIZE_ARGS[] = {MJIT_OPTFLAGS NULL};
-
-static const char *const CC_LDSHARED_ARGS[] = {MJIT_LDSHARED GCC_PIC_FLAGS NULL};
-static const char *const CC_DLDFLAGS_ARGS[] = {MJIT_DLDFLAGS NULL};
-// `CC_LINKER_ARGS` are linker flags which must be passed to `-c` as well.
-static const char *const CC_LINKER_ARGS[] = {
-#if defined __GNUC__ && !defined __clang__ && !defined(__OpenBSD__)
- "-nostartfiles",
-#endif
- GCC_NOSTDLIB_FLAGS NULL
-};
-
-static const char *const CC_LIBS[] = {
-#if defined(_WIN32) || defined(__CYGWIN__)
- MJIT_LIBS // mswin, mingw, cygwin
-#endif
-#if defined __GNUC__ && !defined __clang__
-# if defined(_WIN32)
- "-lmsvcrt", // mingw
-# endif
- "-lgcc", // mingw, cygwin, and GCC platforms using `-nodefaultlibs -nostdlib`
-#endif
-#if defined __ANDROID__
- "-lm", // to avoid 'cannot locate symbol "modf" referenced by .../_ruby_mjit_XXX.so"'
-#endif
- NULL
-};
-
-#define CC_CODEFLAG_ARGS (mjit_opts.debug ? CC_DEBUG_ARGS : CC_OPTIMIZE_ARGS)
-
-// Print the arguments according to FORMAT to stderr only if MJIT
-// verbose option value is more or equal to LEVEL.
-PRINTF_ARGS(static void, 2, 3)
-verbose(int level, const char *format, ...)
-{
- if (mjit_opts.verbose >= level) {
- va_list args;
- size_t len = strlen(format);
- char *full_format = alloca(sizeof(char) * (len + 2));
-
- // Creating `format + '\n'` to atomically print format and '\n'.
- memcpy(full_format, format, len);
- full_format[len] = '\n';
- full_format[len+1] = '\0';
-
- va_start(args, format);
- vfprintf(stderr, full_format, args);
- va_end(args);
- }
-}
-
-PRINTF_ARGS(static void, 1, 2)
-mjit_warning(const char *format, ...)
-{
- if (mjit_opts.warnings || mjit_opts.verbose) {
- va_list args;
-
- fprintf(stderr, "MJIT warning: ");
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fprintf(stderr, "\n");
- }
-}
-
-// Add unit node to the tail of doubly linked `list`. It should be not in
-// the list before.
-static void
-add_to_list(struct rb_mjit_unit *unit, struct rb_mjit_unit_list *list)
-{
- (void)RB_DEBUG_COUNTER_INC_IF(mjit_length_unit_queue, list == &unit_queue);
- (void)RB_DEBUG_COUNTER_INC_IF(mjit_length_active_units, list == &active_units);
- (void)RB_DEBUG_COUNTER_INC_IF(mjit_length_compact_units, list == &compact_units);
- (void)RB_DEBUG_COUNTER_INC_IF(mjit_length_stale_units, list == &stale_units);
-
- list_add_tail(&list->head, &unit->unode);
- list->length++;
-}
-
-static void
-remove_from_list(struct rb_mjit_unit *unit, struct rb_mjit_unit_list *list)
-{
-#if USE_DEBUG_COUNTER
- rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_unit_queue, -1, list == &unit_queue);
- rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_active_units, -1, list == &active_units);
- rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_compact_units, -1, list == &compact_units);
- rb_debug_counter_add(RB_DEBUG_COUNTER_mjit_length_stale_units, -1, list == &stale_units);
-#endif
-
- list_del(&unit->unode);
- list->length--;
-}
-
-static void
-remove_file(const char *filename)
-{
- if (remove(filename)) {
- mjit_warning("failed to remove \"%s\": %s", filename, strerror(errno));
- }
-}
-
-// Lazily delete .o and/or .so files.
-static void
-clean_object_files(struct rb_mjit_unit *unit)
-{
-#ifndef _MSC_VER
- if (unit->o_file) {
- char *o_file = unit->o_file;
-
- unit->o_file = NULL;
- // For compaction, unit->o_file is always set when compilation succeeds.
- // So save_temps needs to be checked here.
- if (!mjit_opts.save_temps && !unit->o_file_inherited_p)
- remove_file(o_file);
- free(o_file);
- }
-#endif
-
-#if defined(_WIN32)
- if (unit->so_file) {
- char *so_file = unit->so_file;
-
- unit->so_file = NULL;
- // unit->so_file is set only when mjit_opts.save_temps is false.
- remove_file(so_file);
- free(so_file);
- }
-#endif
-}
-
-// This is called in the following situations:
-// 1) On dequeue or `unload_units()`, associated ISeq is already GCed.
-// 2) The unit is not called often and unloaded by `unload_units()`.
-// 3) Freeing lists on `mjit_finish()`.
-//
-// `jit_func` value does not matter for 1 and 3 since the unit won't be used anymore.
-// For the situation 2, this sets the ISeq's JIT state to NOT_COMPILED_JIT_ISEQ_FUNC
-// to prevent the situation that the same methods are continuously compiled.
-static void
-free_unit(struct rb_mjit_unit *unit)
-{
- if (unit->iseq) { // ISeq is not GCed
- unit->iseq->body->jit_func = (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC;
- unit->iseq->body->jit_unit = NULL;
- }
- if (unit->handle && dlclose(unit->handle)) { // handle is NULL if it's in queue
- mjit_warning("failed to close handle for u%d: %s", unit->id, dlerror());
- }
- clean_object_files(unit);
- free(unit);
-}
-
-// Start a critical section. Use message `msg` to print debug info at `level`.
-static inline void
-CRITICAL_SECTION_START(int level, const char *msg)
-{
- verbose(level, "Locking %s", msg);
- rb_native_mutex_lock(&mjit_engine_mutex);
- verbose(level, "Locked %s", msg);
-}
-
-// Finish the current critical section. Use message `msg` to print
-// debug info at `level`.
-static inline void
-CRITICAL_SECTION_FINISH(int level, const char *msg)
-{
- verbose(level, "Unlocked %s", msg);
- rb_native_mutex_unlock(&mjit_engine_mutex);
-}
-
-static int
-sprint_uniq_filename(char *str, size_t size, unsigned long id, const char *prefix, const char *suffix)
-{
- return snprintf(str, size, "%s/%sp%"PRI_PIDT_PREFIX"uu%lu%s", tmp_dir, prefix, getpid(), id, suffix);
-}
-
-// Return time in milliseconds as a double.
-#ifdef __APPLE__
-double ruby_real_ms_time(void);
-# define real_ms_time() ruby_real_ms_time()
-#else
-static double
-real_ms_time(void)
-{
-# ifdef HAVE_CLOCK_GETTIME
- struct timespec tv;
-# ifdef CLOCK_MONOTONIC
- const clockid_t c = CLOCK_MONOTONIC;
-# else
- const clockid_t c = CLOCK_REALTIME;
-# endif
-
- clock_gettime(c, &tv);
- return tv.tv_nsec / 1000000.0 + tv.tv_sec * 1000.0;
-# else
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
- return tv.tv_usec / 1000.0 + tv.tv_sec * 1000.0;
-# endif
-}
-#endif
-
-// Return true if class_serial is not obsoleted. This is used by mjit_compile.c.
-bool
-mjit_valid_class_serial_p(rb_serial_t class_serial)
-{
- CRITICAL_SECTION_START(3, "in valid_class_serial_p");
- bool found_p = rb_hash_stlike_lookup(valid_class_serials, LONG2FIX(class_serial), NULL);
- CRITICAL_SECTION_FINISH(3, "in valid_class_serial_p");
- return found_p;
-}
-
-// Return the best unit from list. The best is the first
-// high priority unit or the unit whose iseq has the biggest number
-// of calls so far.
-static struct rb_mjit_unit *
-get_from_list(struct rb_mjit_unit_list *list)
-{
- struct rb_mjit_unit *unit = NULL, *next, *best = NULL;
-
- // Find iseq with max total_calls
- list_for_each_safe(&list->head, unit, next, unode) {
- if (unit->iseq == NULL) { // ISeq is GCed.
- remove_from_list(unit, list);
- free_unit(unit);
- continue;
- }
-
- if (best == NULL || best->iseq->body->total_calls < unit->iseq->body->total_calls) {
- best = unit;
- }
- }
- if (best) {
- remove_from_list(best, list);
- }
- return best;
-}
-
-// Return length of NULL-terminated array `args` excluding the NULL marker.
-static size_t
-args_len(char *const *args)
-{
- size_t i;
-
- for (i = 0; (args[i]) != NULL;i++)
- ;
- return i;
-}
-
-// Concatenate `num` passed NULL-terminated arrays of strings, put the
-// result (with NULL end marker) into the heap, and return the result.
-static char **
-form_args(int num, ...)
-{
- va_list argp;
- size_t len, n;
- int i;
- char **args, **res, **tmp;
-
- va_start(argp, num);
- res = NULL;
- for (i = len = 0; i < num; i++) {
- args = va_arg(argp, char **);
- n = args_len(args);
- if ((tmp = (char **)realloc(res, sizeof(char *) * (len + n + 1))) == NULL) {
- free(res);
- res = NULL;
- break;
- }
- res = tmp;
- MEMCPY(res + len, args, char *, n + 1);
- len += n;
- }
- va_end(argp);
- return res;
-}
-
-COMPILER_WARNING_PUSH
-#ifdef __GNUC__
-COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
-#endif
-// Start an OS process of absolute executable path with arguments `argv`.
-// Return PID of the process.
-static pid_t
-start_process(const char *abspath, char *const *argv)
-{
- // Not calling non-async-signal-safe functions between vfork
- // and execv for safety
- int dev_null = rb_cloexec_open(ruby_null_device, O_WRONLY, 0);
- if (dev_null < 0) {
- verbose(1, "MJIT: Failed to open a null device: %s", strerror(errno));
- return -1;
- }
- if (mjit_opts.verbose >= 2) {
- const char *arg;
- fprintf(stderr, "Starting process: %s", abspath);
- for (int i = 0; (arg = argv[i]) != NULL; i++)
- fprintf(stderr, " %s", arg);
- fprintf(stderr, "\n");
- }
-
- pid_t pid;
-#ifdef _WIN32
- extern HANDLE rb_w32_start_process(const char *abspath, char *const *argv, int out_fd);
- int out_fd = 0;
- if (mjit_opts.verbose <= 1) {
- // Discard cl.exe's outputs like:
- // _ruby_mjit_p12u3.c
- // Creating library C:.../_ruby_mjit_p12u3.lib and object C:.../_ruby_mjit_p12u3.exp
- out_fd = dev_null;
- }
-
- pid = (pid_t)rb_w32_start_process(abspath, argv, out_fd);
- if (pid == 0) {
- verbose(1, "MJIT: Failed to create process: %s", dlerror());
- return -1;
- }
-#else
- if ((pid = vfork()) == 0) { /* TODO: reuse some function in process.c */
- umask(0077);
- if (mjit_opts.verbose == 0) {
- // CC can be started in a thread using a file which has been
- // already removed while MJIT is finishing. Discard the
- // messages about missing files.
- dup2(dev_null, STDERR_FILENO);
- dup2(dev_null, STDOUT_FILENO);
- }
- (void)close(dev_null);
- pid = execv(abspath, argv); // Pid will be negative on an error
- // Even if we successfully found CC to compile PCH we still can
- // fail with loading the CC in very rare cases for some reasons.
- // Stop the forked process in this case.
- verbose(1, "MJIT: Error in execv: %s", abspath);
- _exit(1);
- }
-#endif
- (void)close(dev_null);
- return pid;
-}
-COMPILER_WARNING_POP
-
-// Execute an OS process of executable PATH with arguments ARGV.
-// Return -1 or -2 if failed to execute, otherwise exit code of the process.
-// TODO: Use a similar function in process.c
-static int
-exec_process(const char *path, char *const argv[])
-{
- int stat, exit_code = -2;
- rb_vm_t *vm = WAITPID_USE_SIGCHLD ? GET_VM() : 0;
- rb_nativethread_cond_t cond;
-
- if (vm) {
- rb_native_cond_initialize(&cond);
- rb_native_mutex_lock(&vm->waitpid_lock);
- }
-
- pid_t pid = start_process(path, argv);
- for (;pid > 0;) {
- pid_t r = vm ? ruby_waitpid_locked(vm, pid, &stat, 0, &cond)
- : waitpid(pid, &stat, 0);
- if (r == -1) {
- if (errno == EINTR) continue;
- fprintf(stderr, "[%"PRI_PIDT_PREFIX"d] waitpid(%lu): %s (SIGCHLD=%d,%u)\n",
- getpid(), (unsigned long)pid, strerror(errno),
- RUBY_SIGCHLD, SIGCHLD_LOSSY);
- break;
- }
- else if (r == pid) {
- if (WIFEXITED(stat)) {
- exit_code = WEXITSTATUS(stat);
- break;
- }
- else if (WIFSIGNALED(stat)) {
- exit_code = -1;
- break;
- }
- }
- }
-
- if (vm) {
- rb_native_mutex_unlock(&vm->waitpid_lock);
- rb_native_cond_destroy(&cond);
- }
- return exit_code;
-}
-
-static void
-remove_so_file(const char *so_file, struct rb_mjit_unit *unit)
-{
-#if defined(_WIN32)
- // Windows can't remove files while it's used.
- unit->so_file = strdup(so_file); // lazily delete on `clean_object_files()`
- if (unit->so_file == NULL)
- mjit_warning("failed to allocate memory to lazily remove '%s': %s", so_file, strerror(errno));
-#else
- remove_file(so_file);
-#endif
-}
-
-#define append_str2(p, str, len) ((char *)memcpy((p), str, (len))+(len))
-#define append_str(p, str) append_str2(p, str, sizeof(str)-1)
-#define append_lit(p, str) append_str2(p, str, rb_strlen_lit(str))
-
-#ifdef _MSC_VER
-// Compile C file to so. It returns true if it succeeds. (mswin)
-static bool
-compile_c_to_so(const char *c_file, const char *so_file)
-{
- const char *files[] = { NULL, NULL, NULL, NULL, NULL, NULL, "-link", libruby_pathflag, NULL };
- char *p;
-
- // files[0] = "-Fe*.dll"
- files[0] = p = alloca(sizeof(char) * (rb_strlen_lit("-Fe") + strlen(so_file) + 1));
- p = append_lit(p, "-Fe");
- p = append_str2(p, so_file, strlen(so_file));
- *p = '\0';
-
- // files[1] = "-Fo*.obj"
- // We don't need .obj file, but it's somehow created to cwd without -Fo and we want to control the output directory.
- files[1] = p = alloca(sizeof(char) * (rb_strlen_lit("-Fo") + strlen(so_file) - rb_strlen_lit(DLEXT) + rb_strlen_lit(".obj") + 1));
- char *obj_file = p = append_lit(p, "-Fo");
- p = append_str2(p, so_file, strlen(so_file) - rb_strlen_lit(DLEXT));
- p = append_lit(p, ".obj");
- *p = '\0';
-
- // files[2] = "-Yu*.pch"
- files[2] = p = alloca(sizeof(char) * (rb_strlen_lit("-Yu") + strlen(pch_file) + 1));
- p = append_lit(p, "-Yu");
- p = append_str2(p, pch_file, strlen(pch_file));
- *p = '\0';
-
- // files[3] = "C:/.../rb_mjit_header-*.obj"
- files[3] = p = alloca(sizeof(char) * (strlen(pch_file) + 1));
- p = append_str2(p, pch_file, strlen(pch_file) - strlen(".pch"));
- p = append_lit(p, ".obj");
- *p = '\0';
-
- // files[4] = "-Tc*.c"
- files[4] = p = alloca(sizeof(char) * (rb_strlen_lit("-Tc") + strlen(c_file) + 1));
- p = append_lit(p, "-Tc");
- p = append_str2(p, c_file, strlen(c_file));
- *p = '\0';
-
- // files[5] = "-Fd*.pdb"
- files[5] = p = alloca(sizeof(char) * (rb_strlen_lit("-Fd") + strlen(pch_file) + 1));
- p = append_lit(p, "-Fd");
- p = append_str2(p, pch_file, strlen(pch_file) - rb_strlen_lit(".pch"));
- p = append_lit(p, ".pdb");
- *p = '\0';
-
- char **args = form_args(5, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS,
- files, CC_LIBS, CC_DLDFLAGS_ARGS);
- if (args == NULL)
- return false;
-
- int exit_code = exec_process(cc_path, args);
- free(args);
-
- if (exit_code == 0) {
- // remove never-used files (.obj, .lib, .exp, .pdb). XXX: Is there any way not to generate this?
- if (!mjit_opts.save_temps) {
- char *before_dot;
- remove_file(obj_file);
-
- before_dot = obj_file + strlen(obj_file) - rb_strlen_lit(".obj");
- append_lit(before_dot, ".lib"); remove_file(obj_file);
- append_lit(before_dot, ".exp"); remove_file(obj_file);
- append_lit(before_dot, ".pdb"); remove_file(obj_file);
- }
- }
- else {
- verbose(2, "compile_c_to_so: compile error: %d", exit_code);
- }
- return exit_code == 0;
-}
-#else // _MSC_VER
-
-// The function producing the pre-compiled header.
-static void
-make_pch(void)
-{
- const char *rest_args[] = {
-# ifdef __clang__
- "-emit-pch",
- "-c",
-# endif
- // -nodefaultlibs is a linker flag, but it may affect cc1 behavior on Gentoo, which should NOT be changed on pch:
- // https://gitweb.gentoo.org/proj/gcc-patches.git/tree/7.3.0/gentoo/13_all_default-ssp-fix.patch
- GCC_NOSTDLIB_FLAGS
- "-o", pch_file, header_file,
- NULL,
- };
-
- verbose(2, "Creating precompiled header");
- char **args = form_args(4, cc_common_args, CC_CODEFLAG_ARGS, cc_added_args, rest_args);
- if (args == NULL) {
- mjit_warning("making precompiled header failed on forming args");
- CRITICAL_SECTION_START(3, "in make_pch");
- pch_status = PCH_FAILED;
- CRITICAL_SECTION_FINISH(3, "in make_pch");
- return;
- }
-
- int exit_code = exec_process(cc_path, args);
- free(args);
-
- CRITICAL_SECTION_START(3, "in make_pch");
- if (exit_code == 0) {
- pch_status = PCH_SUCCESS;
- }
- else {
- mjit_warning("Making precompiled header failed on compilation. Stopping MJIT worker...");
- pch_status = PCH_FAILED;
- }
- /* wakeup `mjit_finish` */
- rb_native_cond_broadcast(&mjit_pch_wakeup);
- CRITICAL_SECTION_FINISH(3, "in make_pch");
-}
-
-// Compile .c file to .o file. It returns true if it succeeds. (non-mswin)
-static bool
-compile_c_to_o(const char *c_file, const char *o_file)
-{
- const char *files[] = {
- "-o", o_file, c_file,
-# ifdef __clang__
- "-include-pch", pch_file,
-# endif
- "-c", NULL
- };
-
- char **args = form_args(5, cc_common_args, CC_CODEFLAG_ARGS, cc_added_args, files, CC_LINKER_ARGS);
- if (args == NULL)
- return false;
-
- int exit_code = exec_process(cc_path, args);
- free(args);
-
- if (exit_code != 0)
- verbose(2, "compile_c_to_o: compile error: %d", exit_code);
- return exit_code == 0;
-}
-
-// Link .o files to .so file. It returns true if it succeeds. (non-mswin)
-static bool
-link_o_to_so(const char **o_files, const char *so_file)
-{
- const char *options[] = {
- "-o", so_file,
-# ifdef _WIN32
- libruby_pathflag,
-# endif
- NULL
- };
-
- char **args = form_args(7, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS,
- options, o_files, CC_LIBS, CC_DLDFLAGS_ARGS, CC_LINKER_ARGS);
- if (args == NULL)
- return false;
-
- int exit_code = exec_process(cc_path, args);
- free(args);
-
- if (exit_code != 0)
- verbose(2, "link_o_to_so: link error: %d", exit_code);
- return exit_code == 0;
-}
-
-// Link all cached .o files and build a .so file. Reload all JIT func from it. This
-// allows to avoid JIT code fragmentation and improve performance to call JIT-ed code.
-static void
-compact_all_jit_code(void)
-{
-# ifndef _WIN32 // This requires header transformation but we don't transform header on Windows for now
- struct rb_mjit_unit *unit, *cur = 0;
- double start_time, end_time;
- static const char so_ext[] = DLEXT;
- char so_file[MAXPATHLEN];
- const char **o_files;
- int i = 0;
-
- // Abnormal use case of rb_mjit_unit that doesn't have ISeq
- unit = calloc(1, sizeof(struct rb_mjit_unit)); // To prevent GC, don't use ZALLOC
- if (unit == NULL) return;
- unit->id = current_unit_num++;
- sprint_uniq_filename(so_file, (int)sizeof(so_file), unit->id, MJIT_TMP_PREFIX, so_ext);
-
- // NULL-ending for form_args
- o_files = alloca(sizeof(char *) * (active_units.length + 1));
- o_files[active_units.length] = NULL;
- CRITICAL_SECTION_START(3, "in compact_all_jit_code to keep .o files");
- list_for_each(&active_units.head, cur, unode) {
- o_files[i] = cur->o_file;
- i++;
- }
-
- start_time = real_ms_time();
- bool success = link_o_to_so(o_files, so_file);
- end_time = real_ms_time();
-
- // TODO: Shrink this big critical section. For now, this is needed to prevent failure by missing .o files.
- // This assumes that o -> so link doesn't take long time because the bottleneck, which is compiler optimization,
- // is already done. But actually it takes about 500ms for 5,000 methods on my Linux machine, so it's better to
- // finish this critical section before link_o_to_so by disabling unload_units.
- CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to keep .o files");
-
- if (success) {
- void *handle = dlopen(so_file, RTLD_NOW);
- if (handle == NULL) {
- mjit_warning("failure in loading code from compacted '%s': %s", so_file, dlerror());
- free(unit);
- return;
- }
- unit->handle = handle;
-
- // lazily dlclose handle (and .so file for win32) on `mjit_finish()`.
- add_to_list(unit, &compact_units);
-
- if (!mjit_opts.save_temps)
- remove_so_file(so_file, unit);
-
- CRITICAL_SECTION_START(3, "in compact_all_jit_code to read list");
- list_for_each(&active_units.head, cur, unode) {
- void *func;
- char funcname[35]; // TODO: reconsider `35`
- sprintf(funcname, "_mjit%d", cur->id);
-
- if ((func = dlsym(handle, funcname)) == NULL) {
- mjit_warning("skipping to reload '%s' from '%s': %s", funcname, so_file, dlerror());
- continue;
- }
-
- if (cur->iseq) { // Check whether GCed or not
- // Usage of jit_code might be not in a critical section.
- MJIT_ATOMIC_SET(cur->iseq->body->jit_func, (mjit_func_t)func);
- }
- }
- CRITICAL_SECTION_FINISH(3, "in compact_all_jit_code to read list");
- verbose(1, "JIT compaction (%.1fms): Compacted %d methods -> %s", end_time - start_time, active_units.length, so_file);
- }
- else {
- free(unit);
- verbose(1, "JIT compaction failure (%.1fms): Failed to compact methods", end_time - start_time);
- }
-# endif // _WIN32
-}
-
-#endif // _MSC_VER
-
-static void *
-load_func_from_so(const char *so_file, const char *funcname, struct rb_mjit_unit *unit)
-{
- void *handle, *func;
-
- handle = dlopen(so_file, RTLD_NOW);
- if (handle == NULL) {
- mjit_warning("failure in loading code from '%s': %s", so_file, dlerror());
- return (void *)NOT_ADDED_JIT_ISEQ_FUNC;
- }
-
- func = dlsym(handle, funcname);
- unit->handle = handle;
- return func;
-}
-
-#ifndef __clang__
-static const char *
-header_name_end(const char *s)
-{
- const char *e = s + strlen(s);
-# ifdef __GNUC__ // don't chomp .pch for mswin
- static const char suffix[] = ".gch";
-
- // chomp .gch suffix
- if (e > s+sizeof(suffix)-1 && strcmp(e-sizeof(suffix)+1, suffix) == 0) {
- e -= sizeof(suffix)-1;
- }
-# endif
- return e;
-}
-#endif
-
-// Print platform-specific prerequisites in generated code.
-static void
-compile_prelude(FILE *f)
-{
-#ifndef __clang__ // -include-pch is used for Clang
- const char *s = pch_file;
- const char *e = header_name_end(s);
-
- fprintf(f, "#include \"");
- // print pch_file except .gch for gcc, but keep .pch for mswin
- for (; s < e; s++) {
- switch(*s) {
- case '\\': case '"':
- fputc('\\', f);
- }
- fputc(*s, f);
- }
- fprintf(f, "\"\n");
-#endif
-
-#ifdef _WIN32
- fprintf(f, "void _pei386_runtime_relocator(void){}\n");
- fprintf(f, "int __stdcall DllMainCRTStartup(void* hinstDLL, unsigned int fdwReason, void* lpvReserved) { return 1; }\n");
-#endif
-}
-
-// Compile ISeq in UNIT and return function pointer of JIT-ed code.
-// It may return NOT_COMPILED_JIT_ISEQ_FUNC if something went wrong.
-static mjit_func_t
-convert_unit_to_func(struct rb_mjit_unit *unit)
-{
- char c_file_buff[MAXPATHLEN], *c_file = c_file_buff, *so_file, funcname[35]; // TODO: reconsider `35`
- int fd;
- FILE *f;
- void *func;
- double start_time, end_time;
- int c_file_len = (int)sizeof(c_file_buff);
- static const char c_ext[] = ".c";
- static const char so_ext[] = DLEXT;
- const int access_mode =
-#ifdef O_BINARY
- O_BINARY|
-#endif
- O_WRONLY|O_EXCL|O_CREAT;
-#ifndef _MSC_VER
- static const char o_ext[] = ".o";
- char *o_file;
-#endif
-
- c_file_len = sprint_uniq_filename(c_file_buff, c_file_len, unit->id, MJIT_TMP_PREFIX, c_ext);
- if (c_file_len >= (int)sizeof(c_file_buff)) {
- ++c_file_len;
- c_file = alloca(c_file_len);
- c_file_len = sprint_uniq_filename(c_file, c_file_len, unit->id, MJIT_TMP_PREFIX, c_ext);
- }
- ++c_file_len;
-
-#ifndef _MSC_VER
- o_file = alloca(c_file_len - sizeof(c_ext) + sizeof(o_ext));
- memcpy(o_file, c_file, c_file_len - sizeof(c_ext));
- memcpy(&o_file[c_file_len - sizeof(c_ext)], o_ext, sizeof(o_ext));
-#endif
- so_file = alloca(c_file_len - sizeof(c_ext) + sizeof(so_ext));
- memcpy(so_file, c_file, c_file_len - sizeof(c_ext));
- memcpy(&so_file[c_file_len - sizeof(c_ext)], so_ext, sizeof(so_ext));
-
- sprintf(funcname, "_mjit%d", unit->id);
-
- fd = rb_cloexec_open(c_file, access_mode, 0600);
- if (fd < 0 || (f = fdopen(fd, "w")) == NULL) {
- int e = errno;
- if (fd >= 0) (void)close(fd);
- verbose(1, "Failed to fopen '%s', giving up JIT for it (%s)", c_file, strerror(e));
- return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC;
- }
-
- // print #include of MJIT header, etc.
- compile_prelude(f);
-
- // wait until mjit_gc_exit_hook is called
- CRITICAL_SECTION_START(3, "before mjit_compile to wait GC finish");
- while (in_gc) {
- verbose(3, "Waiting wakeup from GC");
- rb_native_cond_wait(&mjit_gc_wakeup, &mjit_engine_mutex);
- }
-
- // We need to check again here because we could've waited on GC above
- if (unit->iseq == NULL) {
- fclose(f);
- if (!mjit_opts.save_temps)
- remove_file(c_file);
- in_jit = false; // just being explicit for return
- }
- else {
- in_jit = true;
- }
- CRITICAL_SECTION_FINISH(3, "before mjit_compile to wait GC finish");
- if (!in_jit) {
- return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC;
- }
-
- // To make MJIT worker thread-safe against GC.compact, copy ISeq values while `in_jit` is true.
- long iseq_lineno = 0;
- if (FIXNUM_P(unit->iseq->body->location.first_lineno))
- // FIX2INT may fallback to rb_num2long(), which is a method call and dangerous in MJIT worker. So using only FIX2LONG.
- iseq_lineno = FIX2LONG(unit->iseq->body->location.first_lineno);
- char *iseq_label = alloca(RSTRING_LEN(unit->iseq->body->location.label) + 1);
- char *iseq_path = alloca(RSTRING_LEN(rb_iseq_path(unit->iseq)) + 1);
- strcpy(iseq_label, RSTRING_PTR(unit->iseq->body->location.label));
- strcpy(iseq_path, RSTRING_PTR(rb_iseq_path(unit->iseq)));
-
- verbose(2, "start compilation: %s@%s:%ld -> %s", iseq_label, iseq_path, iseq_lineno, c_file);
- fprintf(f, "/* %s@%s:%ld */\n\n", iseq_label, iseq_path, iseq_lineno);
- bool success = mjit_compile(f, unit->iseq, funcname);
-
- // release blocking mjit_gc_start_hook
- CRITICAL_SECTION_START(3, "after mjit_compile to wakeup client for GC");
- in_jit = false;
- verbose(3, "Sending wakeup signal to client in a mjit-worker for GC");
- rb_native_cond_signal(&mjit_client_wakeup);
- CRITICAL_SECTION_FINISH(3, "in worker to wakeup client for GC");
-
- fclose(f);
- if (!success) {
- if (!mjit_opts.save_temps)
- remove_file(c_file);
- verbose(1, "JIT failure: %s@%s:%ld -> %s", iseq_label, iseq_path, iseq_lineno, c_file);
- return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC;
- }
-
- start_time = real_ms_time();
-#ifdef _MSC_VER
- success = compile_c_to_so(c_file, so_file);
-#else
- // splitting .c -> .o step and .o -> .so step, to cache .o files in the future
- if ((success = compile_c_to_o(c_file, o_file)) != false) {
- success = link_o_to_so((const char *[]){ o_file, NULL }, so_file);
-
- // Always set o_file for compaction. The value is also used for lazy deletion.
- unit->o_file = strdup(o_file);
- if (unit->o_file == NULL) {
- mjit_warning("failed to allocate memory to remember '%s' (%s), removing it...", o_file, strerror(errno));
- remove_file(o_file);
- }
- }
-#endif
- end_time = real_ms_time();
-
- if (!mjit_opts.save_temps)
- remove_file(c_file);
- if (!success) {
- verbose(2, "Failed to generate so: %s", so_file);
- return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC;
- }
-
- func = load_func_from_so(so_file, funcname, unit);
- if (!mjit_opts.save_temps)
- remove_so_file(so_file, unit);
-
- if ((uintptr_t)func > (uintptr_t)LAST_JIT_ISEQ_FUNC) {
- verbose(1, "JIT success (%.1fms): %s@%s:%ld -> %s",
- end_time - start_time, iseq_label, iseq_path, iseq_lineno, c_file);
- }
- return (mjit_func_t)func;
-}
-
-typedef struct {
- const rb_iseq_t *iseq;
- struct rb_call_cache *cc_entries;
- union iseq_inline_storage_entry *is_entries;
- bool finish_p;
-} mjit_copy_job_t;
-
-// Singleton MJIT copy job. This is made global since it needs to be durable even when MJIT worker thread is stopped.
-// (ex: register job -> MJIT pause -> MJIT resume -> dispatch job. Actually this should be just cancelled by finish_p check)
-static mjit_copy_job_t mjit_copy_job = { .iseq = NULL, .finish_p = true };
-
-static void mjit_copy_job_handler(void *data);
-
-// vm_trace.c
-int rb_workqueue_register(unsigned flags, rb_postponed_job_func_t , void *);
-
-// Copy inline cache values of `iseq` to `cc_entries` and `is_entries`.
-// These buffers should be pre-allocated properly prior to calling this function.
-// Return true if copy succeeds or is not needed.
-//
-// We're lazily copying cache values from main thread because these cache values
-// could be different between ones on enqueue timing and ones on dequeue timing.
-bool
-mjit_copy_cache_from_main_thread(const rb_iseq_t *iseq, struct rb_call_cache *cc_entries, union iseq_inline_storage_entry *is_entries)
-{
- mjit_copy_job_t *job = &mjit_copy_job; // just a short hand
-
- CRITICAL_SECTION_START(3, "in mjit_copy_cache_from_main_thread");
- job->finish_p = true; // disable dispatching this job in mjit_copy_job_handler while it's being modified
- CRITICAL_SECTION_FINISH(3, "in mjit_copy_cache_from_main_thread");
-
- job->cc_entries = cc_entries;
- job->is_entries = is_entries;
-
- CRITICAL_SECTION_START(3, "in mjit_copy_cache_from_main_thread");
- job->iseq = iseq; // Prevernt GC of this ISeq from here
- VM_ASSERT(in_jit);
- in_jit = false; // To avoid deadlock, allow running GC while waiting for copy job
- rb_native_cond_signal(&mjit_client_wakeup); // Unblock main thread waiting in `mjit_gc_start_hook`
-
- job->finish_p = false; // allow dispatching this job in mjit_copy_job_handler
- CRITICAL_SECTION_FINISH(3, "in mjit_copy_cache_from_main_thread");
-
- if (UNLIKELY(mjit_opts.wait)) {
- mjit_copy_job_handler((void *)job);
- }
- else if (rb_workqueue_register(0, mjit_copy_job_handler, (void *)job)) {
- CRITICAL_SECTION_START(3, "in MJIT copy job wait");
- // checking `stop_worker_p` too because `RUBY_VM_CHECK_INTS(ec)` may not
- // lush mjit_copy_job_handler when EC_EXEC_TAG() is not TAG_NONE, and then
- // `stop_worker()` could dead lock with this function.
- while (!job->finish_p && !stop_worker_p) {
- rb_native_cond_wait(&mjit_worker_wakeup, &mjit_engine_mutex);
- verbose(3, "Getting wakeup from client");
- }
- CRITICAL_SECTION_FINISH(3, "in MJIT copy job wait");
- }
-
- CRITICAL_SECTION_START(3, "in mjit_copy_cache_from_main_thread");
- bool success_p = job->finish_p;
- // Disable dispatching this job in mjit_copy_job_handler while memory allocated by alloca
- // could be expired after finishing this function.
- job->finish_p = true;
-
- in_jit = true; // Prohibit GC during JIT compilation
- if (job->iseq == NULL) // ISeq GC is notified in mjit_mark_iseq
- success_p = false;
- job->iseq = NULL; // Allow future GC of this ISeq from here
- CRITICAL_SECTION_FINISH(3, "in mjit_copy_cache_from_main_thread");
- return success_p;
-}
-
-// The function implementing a worker. It is executed in a separate
-// thread by rb_thread_create_mjit_thread. It compiles precompiled header
-// and then compiles requested ISeqs.
-void
-mjit_worker(void)
-{
-#ifndef _MSC_VER
- if (pch_status == PCH_NOT_READY) {
- make_pch();
- }
-#endif
- if (pch_status == PCH_FAILED) {
- mjit_enabled = false;
- CRITICAL_SECTION_START(3, "in worker to update worker_stopped");
- worker_stopped = true;
- verbose(3, "Sending wakeup signal to client in a mjit-worker");
- rb_native_cond_signal(&mjit_client_wakeup);
- CRITICAL_SECTION_FINISH(3, "in worker to update worker_stopped");
- return; // TODO: do the same thing in the latter half of mjit_finish
- }
-
- // main worker loop
- while (!stop_worker_p) {
- struct rb_mjit_unit *unit;
-
- // wait until unit is available
- CRITICAL_SECTION_START(3, "in worker dequeue");
- while ((list_empty(&unit_queue.head) || active_units.length >= mjit_opts.max_cache_size) && !stop_worker_p) {
- rb_native_cond_wait(&mjit_worker_wakeup, &mjit_engine_mutex);
- verbose(3, "Getting wakeup from client");
- }
- unit = get_from_list(&unit_queue);
- CRITICAL_SECTION_FINISH(3, "in worker dequeue");
-
- if (unit) {
- // JIT compile
- mjit_func_t func = convert_unit_to_func(unit);
- (void)RB_DEBUG_COUNTER_INC_IF(mjit_compile_failures, func == (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC);
-
- CRITICAL_SECTION_START(3, "in jit func replace");
- while (in_gc) { // Make sure we're not GC-ing when touching ISeq
- verbose(3, "Waiting wakeup from GC");
- rb_native_cond_wait(&mjit_gc_wakeup, &mjit_engine_mutex);
- }
- if (unit->iseq) { // Check whether GCed or not
- if ((uintptr_t)func > (uintptr_t)LAST_JIT_ISEQ_FUNC) {
- add_to_list(unit, &active_units);
- }
- // Usage of jit_code might be not in a critical section.
- MJIT_ATOMIC_SET(unit->iseq->body->jit_func, func);
- }
- else {
- free_unit(unit);
- }
- CRITICAL_SECTION_FINISH(3, "in jit func replace");
-
-#ifndef _MSC_VER
- // Combine .o files to one .so and reload all jit_func to improve memory locality
- if ((!mjit_opts.wait && unit_queue.length == 0 && active_units.length > 1)
- || active_units.length == mjit_opts.max_cache_size) {
- compact_all_jit_code();
- }
-#endif
- }
- }
-
- // To keep mutex unlocked when it is destroyed by mjit_finish, don't wrap CRITICAL_SECTION here.
- worker_stopped = true;
-}
diff --git a/node.c b/node.c
index 2cdf4c9dda..23b15c2dbc 100644
--- a/node.c
+++ b/node.c
@@ -12,8 +12,6 @@
#include "ruby/ruby.h"
#include "vm_core.h"
-#define NODE_BUF_DEFAULT_LEN 16
-
#define A(str) rb_str_cat2(buf, (str))
#define AR(str) rb_str_concat(buf, (str))
@@ -25,11 +23,8 @@
#define A_LONG(val) rb_str_catf(buf, "%ld", (val))
#define A_LIT(lit) AR(rb_inspect(lit))
#define A_NODE_HEADER(node, term) \
- rb_str_catf(buf, "@ %s (line: %d, location: (%d,%d)-(%d,%d))%s"term, \
- ruby_node_name(nd_type(node)), nd_line(node), \
- nd_first_lineno(node), nd_first_column(node), \
- nd_last_lineno(node), nd_last_column(node), \
- (node->flags & NODE_FL_NEWLINE ? "*" : ""))
+ rb_str_catf(buf, "@ %s (line: %d, code_range: (%d,%d)-(%d,%d))"term, \
+ ruby_node_name(nd_type(node)), nd_line(node), nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node))
#define A_FIELD_HEADER(len, name, term) \
rb_str_catf(buf, "+- %.*s:"term, (len), (name))
#define D_FIELD_HEADER(len, name, term) (A_INDENT, A_FIELD_HEADER(len, name, term))
@@ -68,6 +63,8 @@
#define F_NODE(name, ann) \
COMPOUND_FIELD1(#name, ann) {dump_node(buf, indent, comment, node->name);}
+#define F_OPTION(name, ann) \
+ COMPOUND_FIELD1(#name, ann) {dump_option(buf, indent, node->name);}
#define ANN(ann) \
if (comment) { \
@@ -94,7 +91,7 @@ add_id(VALUE buf, ID id)
A(":"); AR(str);
}
else {
- rb_str_catf(buf, "(internal variable: 0x%"PRIsVALUE")", id);
+ A("(internal variable)");
}
}
}
@@ -104,17 +101,48 @@ struct add_option_arg {
st_index_t count;
};
-static void dump_node(VALUE, VALUE, int, const NODE *);
+static int
+add_option_i(VALUE key, VALUE val, VALUE args)
+{
+ struct add_option_arg *argp = (void *)args;
+ VALUE buf = argp->buf;
+ VALUE indent = argp->indent;
+
+ A_INDENT;
+ A("+- ");
+ AR(rb_sym2str(key));
+ A(": ");
+ A_LIT(val);
+ A("\n");
+ return ST_CONTINUE;
+}
+
+static void
+dump_option(VALUE buf, VALUE indent, VALUE opt)
+{
+ struct add_option_arg arg;
+
+ if (!RB_TYPE_P(opt, T_HASH)) {
+ A_LIT(opt);
+ return;
+ }
+ arg.buf = buf;
+ arg.indent = indent;
+ arg.count = 0;
+ rb_hash_foreach(opt, add_option_i, (VALUE)&arg);
+}
+
+static void dump_node(VALUE, VALUE, int, NODE *);
static const char default_indent[] = "| ";
static void
-dump_array(VALUE buf, VALUE indent, int comment, const NODE *node)
+dump_array(VALUE buf, VALUE indent, int comment, NODE *node)
{
int field_flag;
const char *next_indent = default_indent;
F_LONG(nd_alen, "length");
F_NODE(nd_head, "element");
- while (node->nd_next && nd_type(node->nd_next) == NODE_LIST) {
+ while (node->nd_next && nd_type(node->nd_next) == NODE_ARRAY) {
node = node->nd_next;
F_NODE(nd_head, "element");
}
@@ -123,7 +151,7 @@ dump_array(VALUE buf, VALUE indent, int comment, const NODE *node)
}
static void
-dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
+dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
{
int field_flag;
int i;
@@ -197,14 +225,6 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
LAST_NODE;
F_NODE(nd_body, "when clauses");
return;
- case NODE_CASE3:
- ANN("case statement (pattern matching)");
- ANN("format: case [nd_head]; [nd_body]; end");
- ANN("example: case x; in 1; foo; in 2; bar; else baz; end");
- F_NODE(nd_head, "case expr");
- LAST_NODE;
- F_NODE(nd_body, "in clauses");
- return;
case NODE_WHEN:
ANN("when clause");
@@ -216,16 +236,6 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_NODE(nd_next, "next when clause");
return;
- case NODE_IN:
- ANN("in clause");
- ANN("format: in [nd_head]; [nd_body]; (in or else) [nd_next]");
- ANN("example: case x; in 1; foo; in 2; bar; else baz; end");
- F_NODE(nd_head, "in pattern");
- F_NODE(nd_body, "in body");
- LAST_NODE;
- F_NODE(nd_next, "next in clause");
- return;
-
case NODE_WHILE:
ANN("while statement");
ANN("format: while [nd_cond]; [nd_body]; end");
@@ -260,14 +270,6 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_NODE(nd_body, "body");
return;
- case NODE_FOR_MASGN:
- ANN("vars of for statement with masgn");
- ANN("format: for [nd_var] in ... do ... end");
- ANN("example: for x, y in 1..3 do foo end");
- LAST_NODE;
- F_NODE(nd_var, "var");
- return;
-
case NODE_BREAK:
ANN("break statement");
ANN("format: break [nd_stts]");
@@ -362,7 +364,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("example: a, b = foo");
F_NODE(nd_value, "rhsn");
F_NODE(nd_head, "lhsn");
- if (NODE_NAMED_REST_P(node->nd_args)) {
+ if (node->nd_args != NODE_SPECIAL_NO_NAME_REST) {
LAST_NODE;
F_NODE(nd_args, "splatn");
}
@@ -376,7 +378,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("format: [nd_vid](lvar) = [nd_value]");
ANN("example: x = foo");
F_ID(nd_vid, "local variable");
- if (NODE_REQUIRED_KEYWORD_P(node)) {
+ if (node->nd_value == NODE_SPECIAL_REQUIRED_KEYWORD) {
F_MSG(nd_value, "rvalue", "NODE_SPECIAL_REQUIRED_KEYWORD (required keyword argument)");
}
else {
@@ -397,13 +399,8 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("format: [nd_vid](current dvar) = [nd_value]");
ANN("example: 1.times { x = foo }");
F_ID(nd_vid, "local variable");
- if (NODE_REQUIRED_KEYWORD_P(node)) {
- F_MSG(nd_value, "rvalue", "NODE_SPECIAL_REQUIRED_KEYWORD (required keyword argument)");
- }
- else {
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- }
+ LAST_NODE;
+ F_NODE(nd_value, "rvalue");
return;
case NODE_IASGN:
ANN("instance variable assignment");
@@ -448,10 +445,16 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
case NODE_OP_ASGN1:
ANN("array assignment with operator");
- ANN("format: [nd_recv] [ [nd_args->nd_head] ] [nd_mid]= [nd_args->nd_body]");
+ ANN("format: [nd_value] [ [nd_args->nd_body] ] [nd_vid]= [nd_args->nd_head]");
ANN("example: ary[1] += foo");
F_NODE(nd_recv, "receiver");
- F_ID(nd_mid, "operator");
+ F_CUSTOM1(nd_mid, "operator") {
+ switch (node->nd_mid) {
+ case 0: A("0 (||)"); break;
+ case 1: A("1 (&&)"); break;
+ default: A_ID(node->nd_mid);
+ }
+ }
F_NODE(nd_args->nd_head, "index");
LAST_NODE;
F_NODE(nd_args->nd_body, "rvalue");
@@ -459,7 +462,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
case NODE_OP_ASGN2:
ANN("attr assignment with operator");
- ANN("format: [nd_recv].[attr] [nd_next->nd_mid]= [nd_value]");
+ ANN("format: [nd_value].[attr] [nd_next->nd_mid]= [nd_value]");
ANN(" where [attr]: [nd_next->nd_vid]");
ANN("example: struct.field += foo");
F_NODE(nd_recv, "receiver");
@@ -467,7 +470,13 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
if (node->nd_next->nd_aid) A("? ");
A_ID(node->nd_next->nd_vid);
}
- F_ID(nd_next->nd_mid, "operator");
+ F_CUSTOM1(nd_next->nd_mid, "operator") {
+ switch (node->nd_next->nd_mid) {
+ case 0: A("0 (||)"); break;
+ case 1: A("1 (&&)"); break;
+ default: A_ID(node->nd_next->nd_mid);
+ }
+ }
LAST_NODE;
F_NODE(nd_value, "rvalue");
return;
@@ -492,12 +501,19 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("format: [nd_head](constant) [nd_aid]= [nd_value]");
ANN("example: A::B ||= 1");
F_NODE(nd_head, "constant");
- F_ID(nd_aid, "operator");
+ F_CUSTOM1(nd_aid, "operator") {
+ switch (node->nd_aid) {
+ case 0: A("0 (||)"); break;
+ case 1: A("1 (&&)"); break;
+ default: A_ID(node->nd_mid);
+ }
+ }
LAST_NODE;
F_NODE(nd_value, "rvalue");
return;
case NODE_CALL:
+ case NODE_OPCALL:
ANN("method invocation");
ANN("format: [nd_recv].[nd_mid]([nd_args])");
ANN("example: obj.foo(1)");
@@ -507,16 +523,6 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_NODE(nd_args, "arguments");
return;
- case NODE_OPCALL:
- ANN("method invocation");
- ANN("format: [nd_recv] [nd_mid] [nd_args]");
- ANN("example: foo + bar");
- F_ID(nd_mid, "method id");
- F_NODE(nd_recv, "receiver");
- LAST_NODE;
- F_NODE(nd_args, "arguments");
- return;
-
case NODE_FCALL:
ANN("function call");
ANN("format: [nd_mid]([nd_args])");
@@ -557,8 +563,8 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("example: super");
return;
- case NODE_LIST:
- ANN("list constructor");
+ case NODE_ARRAY:
+ ANN("array constructor");
ANN("format: [ [nd_head], [nd_next].. ] (length: [nd_alen])");
ANN("example: [1, 2, 3]");
goto ary;
@@ -570,14 +576,14 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
dump_array(buf, indent, comment, node);
return;
- case NODE_ZLIST:
- ANN("empty list constructor");
+ case NODE_ZARRAY:
+ ANN("empty array constructor");
ANN("format: []");
ANN("example: []");
return;
case NODE_HASH:
- if (!node->nd_brace) {
+ if (!node->nd_alen) {
ANN("keyword arguments");
ANN("format: nd_head");
ANN("example: a: 1, b: 2");
@@ -587,8 +593,8 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("format: { [nd_head] }");
ANN("example: { 1 => 2, 3 => 4 }");
}
- F_CUSTOM1(nd_brace, "keyword arguments or hash literal") {
- switch (node->nd_brace) {
+ F_CUSTOM1(nd_alen, "keyword arguments or hash literal") {
+ switch (node->nd_alen) {
case 0: A("0 (keyword argument)"); break;
case 1: A("1 (hash literal)"); break;
}
@@ -710,13 +716,6 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_LIT(nd_lit, "literal");
return;
- case NODE_ONCE:
- ANN("once evaluation");
- ANN("format: [nd_body]");
- ANN("example: /foo#{ bar }baz/o");
- LAST_NODE;
- F_NODE(nd_body, "body");
- return;
case NODE_DSTR:
ANN("string literal with interpolation");
ANN("format: [nd_lit]");
@@ -789,7 +788,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
case NODE_DEFN:
ANN("method definition");
ANN("format: def [nd_mid] [nd_defn]; end");
- ANN("example: def foo; bar; end");
+ ANN("example; def foo; bar; end");
F_ID(nd_mid, "method name");
LAST_NODE;
F_NODE(nd_defn, "method definition");
@@ -798,7 +797,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
case NODE_DEFS:
ANN("singleton method definition");
ANN("format: def [nd_recv].[nd_mid] [nd_defn]; end");
- ANN("example: def obj.foo; bar; end");
+ ANN("example; def obj.foo; bar; end");
F_NODE(nd_recv, "receiver");
F_ID(nd_mid, "method name");
LAST_NODE;
@@ -807,7 +806,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
case NODE_ALIAS:
ANN("method alias statement");
- ANN("format: alias [nd_1st] [nd_2nd]");
+ ANN("format: alias [u1.node] [u2.node]");
ANN("example: alias bar foo");
F_NODE(nd_1st, "new name");
LAST_NODE;
@@ -816,15 +815,15 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
case NODE_VALIAS:
ANN("global variable alias statement");
- ANN("format: alias [nd_alias](gvar) [nd_orig](gvar)");
+ ANN("format: alias [u1.id](gvar) [u2.id](gvar)");
ANN("example: alias $y $x");
F_ID(nd_alias, "new name");
F_ID(nd_orig, "old name");
return;
case NODE_UNDEF:
- ANN("method undef statement");
- ANN("format: undef [nd_undef]");
+ ANN("method alias statement");
+ ANN("format: undef [u2.node]");
ANN("example: undef foo");
LAST_NODE;
F_NODE(nd_undef, "old name");
@@ -954,6 +953,19 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_NODE(nd_args, "arguments");
return;
+ case NODE_PRELUDE:
+ ANN("pre-execution");
+ ANN("format: BEGIN { [nd_head] }; [nd_body]");
+ ANN("example: bar; BEGIN { foo }");
+ F_NODE(nd_head, "prelude");
+ if (!node->nd_compile_option) LAST_NODE;
+ F_NODE(nd_body, "body");
+ if (node->nd_compile_option) {
+ LAST_NODE;
+ F_OPTION(nd_compile_option, "compile_option");
+ }
+ return;
+
case NODE_LAMBDA:
ANN("lambda expression");
ANN("format: -> [nd_body]");
@@ -984,7 +996,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
ANN("post arguments");
ANN("format: *[nd_1st], [nd_2nd..] = ..");
ANN("example: a, *rest, z = foo");
- if (NODE_NAMED_REST_P(node->nd_1st)) {
+ if (node->nd_1st != NODE_SPECIAL_NO_NAME_REST) {
F_NODE(nd_1st, "rest argument");
}
else {
@@ -1003,14 +1015,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_INT(nd_ainfo->post_args_num, "count of mandatory post-arguments");
F_NODE(nd_ainfo->post_init, "initialization of post-arguments");
F_ID(nd_ainfo->first_post_arg, "first post argument");
- F_CUSTOM1(nd_ainfo->rest_arg, "rest argument") {
- if (node->nd_ainfo->rest_arg == NODE_SPECIAL_EXCESSIVE_COMMA) {
- A("1 (excessed comma)");
- }
- else {
- A_ID(node->nd_ainfo->rest_arg);
- }
- }
+ F_ID(nd_ainfo->rest_arg, "rest argument");
F_ID(nd_ainfo->block_arg, "block argument");
F_NODE(nd_ainfo->opt_args, "optional arguments");
F_NODE(nd_ainfo->kw_args, "keyword arguments");
@@ -1035,35 +1040,6 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
F_NODE(nd_body, "body");
return;
- case NODE_ARYPTN:
- ANN("array pattern");
- ANN("format: [nd_pconst]([pre_args], ..., *[rest_arg], [post_args], ...)");
- F_NODE(nd_pconst, "constant");
- F_NODE(nd_apinfo->pre_args, "pre arguments");
- if (NODE_NAMED_REST_P(node->nd_apinfo->rest_arg)) {
- F_NODE(nd_apinfo->rest_arg, "rest argument");
- }
- else {
- F_MSG(nd_apinfo->rest_arg, "rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
- }
- LAST_NODE;
- F_NODE(nd_apinfo->post_args, "post arguments");
- return;
-
- case NODE_HSHPTN:
- ANN("hash pattern");
- ANN("format: [nd_pconst]([nd_pkwargs], ..., **[nd_pkwrestarg])");
- F_NODE(nd_pconst, "constant");
- F_NODE(nd_pkwargs, "keyword arguments");
- LAST_NODE;
- if (node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
- F_MSG(nd_pkwrestarg, "keyword rest argument", "NODE_SPECIAL_NO_REST_KEYWORD (**nil)");
- }
- else {
- F_NODE(nd_pkwrestarg, "keyword rest argument");
- }
- return;
-
case NODE_ARGS_AUX:
case NODE_LAST:
break;
@@ -1073,7 +1049,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
}
VALUE
-rb_parser_dump_tree(const NODE *node, int comment)
+rb_parser_dump_tree(NODE *node, int comment)
{
VALUE buf = rb_str_new_cstr(
"###########################################################\n"
@@ -1085,7 +1061,7 @@ rb_parser_dump_tree(const NODE *node, int comment)
return buf;
}
-/* Setup NODE structure.
+/* Setup NODE strucutre.
* NODE is not an object managed by GC, but it imitates an object
* so that it can work with `RB_TYPE_P(obj, T_NODE)`.
* This dirty hack is needed because Ripper jumbles NODEs and other type
@@ -1099,93 +1075,55 @@ rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
n->u1.value = a0;
n->u2.value = a1;
n->u3.value = a2;
- n->nd_loc.beg_pos.lineno = 0;
- n->nd_loc.beg_pos.column = 0;
- n->nd_loc.end_pos.lineno = 0;
- n->nd_loc.end_pos.column = 0;
+ n->nd_loc.first_loc.lineno = 0;
+ n->nd_loc.first_loc.column = 0;
+ n->nd_loc.last_loc.lineno = 0;
+ n->nd_loc.last_loc.column = 0;
}
typedef struct node_buffer_elem_struct {
struct node_buffer_elem_struct *next;
- long len;
- NODE buf[FLEX_ARY_LEN];
+ NODE buf[1]; /* flexible array */
} node_buffer_elem_t;
-typedef struct {
+struct node_buffer_struct {
long idx, len;
node_buffer_elem_t *head;
- node_buffer_elem_t *last;
-} node_buffer_list_t;
-
-struct node_buffer_struct {
- node_buffer_list_t unmarkable;
- node_buffer_list_t markable;
- ID *local_tables;
- VALUE mark_hash;
+ node_buffer_elem_t body; /* this should be a last, because body has flexible array */
};
-static void
-init_node_buffer_list(node_buffer_list_t * nb, node_buffer_elem_t *head)
-{
- nb->idx = 0;
- nb->len = NODE_BUF_DEFAULT_LEN;
- nb->head = nb->last = head;
- nb->head->len = nb->len;
- nb->head->next = NULL;
-}
-
static node_buffer_t *
rb_node_buffer_new(void)
{
- const size_t bucket_size = offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE);
- const size_t alloc_size = sizeof(node_buffer_t) + (bucket_size * 2);
- STATIC_ASSERT(
- integer_overflow,
- offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE)
- > sizeof(node_buffer_t) + 2 * sizeof(node_buffer_elem_t));
- node_buffer_t *nb = ruby_xmalloc(alloc_size);
- init_node_buffer_list(&nb->unmarkable, (node_buffer_elem_t*)&nb[1]);
- init_node_buffer_list(&nb->markable, (node_buffer_elem_t*)((size_t)nb->unmarkable.head + bucket_size));
- nb->local_tables = 0;
- nb->mark_hash = Qnil;
+ node_buffer_t *nb = xmalloc(offsetof(node_buffer_t, body) + offsetof(node_buffer_elem_t, buf) + 16 * sizeof(NODE));
+ nb->idx = 0;
+ nb->len = 16;
+ nb->head = &nb->body;
+ nb->head->next = NULL;
return nb;
}
static void
-node_buffer_list_free(node_buffer_list_t * nb)
+rb_node_buffer_free(node_buffer_t *nb)
{
node_buffer_elem_t *nbe = nb->head;
- while (nbe != nb->last) {
+ while (nbe != &nb->body) {
void *buf = nbe;
nbe = nbe->next;
xfree(buf);
}
-}
-
-static void
-rb_node_buffer_free(node_buffer_t *nb)
-{
- node_buffer_list_free(&nb->unmarkable);
- node_buffer_list_free(&nb->markable);
- ID * local_table = nb->local_tables;
- while (local_table) {
- unsigned int size = (unsigned int)*local_table;
- ID * next_table = (ID *)local_table[size + 1];
- xfree(local_table);
- local_table = next_table;
- }
xfree(nb);
}
-static NODE *
-ast_newnode_in_bucket(node_buffer_list_t *nb)
+NODE *
+rb_ast_newnode(rb_ast_t *ast)
{
+ node_buffer_t *nb = ast->node_buffer;
if (nb->idx >= nb->len) {
long n = nb->len * 2;
node_buffer_elem_t *nbe;
- nbe = rb_xmalloc_mul_add(n, sizeof(NODE), offsetof(node_buffer_elem_t, buf));
- nbe->len = n;
+ nbe = xmalloc(offsetof(node_buffer_elem_t, buf) + n * sizeof(NODE));
nb->idx = 0;
nb->len = n;
nbe->next = nb->head;
@@ -1194,35 +1132,6 @@ ast_newnode_in_bucket(node_buffer_list_t *nb)
return &nb->head->buf[nb->idx++];
}
-NODE *
-rb_ast_newnode(rb_ast_t *ast, enum node_type type)
-{
- node_buffer_t *nb = ast->node_buffer;
- switch (type) {
- case NODE_MATCH:
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_DSYM:
- case NODE_ARGS:
- case NODE_ARYPTN:
- return ast_newnode_in_bucket(&nb->markable);
- default:
- return ast_newnode_in_bucket(&nb->unmarkable);
- }
-}
-
-void
-rb_ast_add_local_table(rb_ast_t *ast, ID *buf)
-{
- unsigned int size = (unsigned int)*buf;
- buf[size + 1] = (ID)ast->node_buffer->local_tables;
- ast->node_buffer->local_tables = buf;
-}
-
void
rb_ast_delete_node(rb_ast_t *ast, NODE *n)
{
@@ -1234,118 +1143,13 @@ rb_ast_delete_node(rb_ast_t *ast, NODE *n)
rb_ast_t *
rb_ast_new(void)
{
- node_buffer_t *nb = rb_node_buffer_new();
- rb_ast_t *ast = (rb_ast_t *)rb_imemo_new(imemo_ast, 0, 0, 0, (VALUE)nb);
- return ast;
-}
-
-typedef void node_itr_t(void *ctx, NODE * node);
-
-static void
-iterate_buffer_elements(node_buffer_elem_t *nbe, long len, node_itr_t *func, void *ctx)
-{
- long cursor;
- for (cursor = 0; cursor < len; cursor++) {
- func(ctx, &nbe->buf[cursor]);
- }
-}
-
-static void
-iterate_node_values(node_buffer_list_t *nb, node_itr_t * func, void *ctx)
-{
- node_buffer_elem_t *nbe = nb->head;
-
- /* iterate over the head first because it's not full */
- iterate_buffer_elements(nbe, nb->idx, func, ctx);
-
- nbe = nbe->next;
- while (nbe) {
- iterate_buffer_elements(nbe, nbe->len, func, ctx);
- nbe = nbe->next;
- }
-}
-
-static void
-mark_ast_value(void *ctx, NODE * node)
-{
- switch (nd_type(node)) {
- case NODE_ARYPTN:
- {
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- rb_gc_mark_movable(apinfo->imemo);
- break;
- }
- case NODE_ARGS:
- {
- struct rb_args_info *args = node->nd_ainfo;
- rb_gc_mark_movable(args->imemo);
- break;
- }
- case NODE_MATCH:
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_DSYM:
- rb_gc_mark_movable(node->nd_lit);
- break;
- default:
- rb_bug("unreachable node %s", ruby_node_name(nd_type(node)));
- }
-}
-
-static void
-update_ast_value(void *ctx, NODE * node)
-{
- switch (nd_type(node)) {
- case NODE_ARYPTN:
- {
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- apinfo->imemo = rb_gc_location(apinfo->imemo);
- break;
- }
- case NODE_ARGS:
- {
- struct rb_args_info *args = node->nd_ainfo;
- args->imemo = rb_gc_location(args->imemo);
- break;
- }
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_DSYM:
- node->nd_lit = rb_gc_location(node->nd_lit);
- break;
- default:
- rb_bug("unreachable");
- }
-}
-
-void
-rb_ast_update_references(rb_ast_t *ast)
-{
- if (ast->node_buffer) {
- node_buffer_t *nb = ast->node_buffer;
-
- iterate_node_values(&nb->markable, update_ast_value, NULL);
- }
+ return (rb_ast_t *)rb_imemo_new(imemo_ast, 0, (VALUE)rb_node_buffer_new(), rb_ary_tmp_new(0), 0);
}
void
rb_ast_mark(rb_ast_t *ast)
{
- if (ast->node_buffer) rb_gc_mark(ast->node_buffer->mark_hash);
- if (ast->body.compile_option) rb_gc_mark(ast->body.compile_option);
- if (ast->node_buffer) {
- node_buffer_t *nb = ast->node_buffer;
-
- iterate_node_values(&nb->markable, mark_ast_value, NULL);
- }
+ if (ast->node_buffer) rb_gc_mark(ast->mark_ary);
}
void
@@ -1357,43 +1161,26 @@ rb_ast_free(rb_ast_t *ast)
}
}
-static size_t
-buffer_list_size(node_buffer_list_t *nb)
-{
- size_t size = 0;
- node_buffer_elem_t *nbe = nb->head;
- while (nbe != nb->last) {
- nbe = nbe->next;
- size += offsetof(node_buffer_elem_t, buf) + nb->len * sizeof(NODE);
- }
- return size;
-}
-
-size_t
-rb_ast_memsize(const rb_ast_t *ast)
-{
- size_t size = 0;
- node_buffer_t *nb = ast->node_buffer;
-
- if (nb) {
- size += sizeof(node_buffer_t) + offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE);
- size += buffer_list_size(&nb->unmarkable);
- size += buffer_list_size(&nb->markable);
- }
- return size;
-}
-
void
rb_ast_dispose(rb_ast_t *ast)
{
rb_ast_free(ast);
+ RB_OBJ_WRITE(ast, &ast->mark_ary, Qnil);
}
void
rb_ast_add_mark_object(rb_ast_t *ast, VALUE obj)
{
- if (NIL_P(ast->node_buffer->mark_hash)) {
- RB_OBJ_WRITE(ast, &ast->node_buffer->mark_hash, rb_ident_hash_new());
+ rb_ary_push(ast->mark_ary, obj);
+}
+
+void
+rb_ast_delete_mark_object(rb_ast_t *ast, VALUE obj)
+{
+ long i;
+ for (i = 0; i < RARRAY_LEN(ast->mark_ary); i++) {
+ if (obj == RARRAY_AREF(ast->mark_ary, i)) {
+ RARRAY_ASET(ast->mark_ary, i, Qnil);
+ }
}
- rb_hash_aset(ast->node_buffer->mark_hash, obj, Qtrue);
}
diff --git a/node.h b/node.h
index f688f238de..9730edeea2 100644
--- a/node.h
+++ b/node.h
@@ -21,130 +21,216 @@ extern "C" {
enum node_type {
NODE_SCOPE,
+#define NODE_SCOPE NODE_SCOPE
NODE_BLOCK,
+#define NODE_BLOCK NODE_BLOCK
NODE_IF,
+#define NODE_IF NODE_IF
NODE_UNLESS,
+#define NODE_UNLESS NODE_UNLESS
NODE_CASE,
+#define NODE_CASE NODE_CASE
NODE_CASE2,
- NODE_CASE3,
+#define NODE_CASE2 NODE_CASE2
NODE_WHEN,
- NODE_IN,
+#define NODE_WHEN NODE_WHEN
NODE_WHILE,
+#define NODE_WHILE NODE_WHILE
NODE_UNTIL,
+#define NODE_UNTIL NODE_UNTIL
NODE_ITER,
+#define NODE_ITER NODE_ITER
NODE_FOR,
- NODE_FOR_MASGN,
+#define NODE_FOR NODE_FOR
NODE_BREAK,
+#define NODE_BREAK NODE_BREAK
NODE_NEXT,
+#define NODE_NEXT NODE_NEXT
NODE_REDO,
+#define NODE_REDO NODE_REDO
NODE_RETRY,
+#define NODE_RETRY NODE_RETRY
NODE_BEGIN,
+#define NODE_BEGIN NODE_BEGIN
NODE_RESCUE,
+#define NODE_RESCUE NODE_RESCUE
NODE_RESBODY,
+#define NODE_RESBODY NODE_RESBODY
NODE_ENSURE,
+#define NODE_ENSURE NODE_ENSURE
NODE_AND,
+#define NODE_AND NODE_AND
NODE_OR,
+#define NODE_OR NODE_OR
NODE_MASGN,
+#define NODE_MASGN NODE_MASGN
NODE_LASGN,
+#define NODE_LASGN NODE_LASGN
NODE_DASGN,
+#define NODE_DASGN NODE_DASGN
NODE_DASGN_CURR,
+#define NODE_DASGN_CURR NODE_DASGN_CURR
NODE_GASGN,
+#define NODE_GASGN NODE_GASGN
NODE_IASGN,
+#define NODE_IASGN NODE_IASGN
NODE_CDECL,
+#define NODE_CDECL NODE_CDECL
NODE_CVASGN,
+#define NODE_CVASGN NODE_CVASGN
NODE_OP_ASGN1,
+#define NODE_OP_ASGN1 NODE_OP_ASGN1
NODE_OP_ASGN2,
+#define NODE_OP_ASGN2 NODE_OP_ASGN2
NODE_OP_ASGN_AND,
+#define NODE_OP_ASGN_AND NODE_OP_ASGN_AND
NODE_OP_ASGN_OR,
+#define NODE_OP_ASGN_OR NODE_OP_ASGN_OR
NODE_OP_CDECL,
+#define NODE_OP_CDECL NODE_OP_CDECL
NODE_CALL,
+#define NODE_CALL NODE_CALL
NODE_OPCALL,
+#define NODE_OPCALL NODE_OPCALL
NODE_FCALL,
+#define NODE_FCALL NODE_FCALL
NODE_VCALL,
+#define NODE_VCALL NODE_VCALL
NODE_QCALL,
+#define NODE_QCALL NODE_QCALL
NODE_SUPER,
+#define NODE_SUPER NODE_SUPER
NODE_ZSUPER,
- NODE_LIST,
- NODE_ZLIST,
+#define NODE_ZSUPER NODE_ZSUPER
+ NODE_ARRAY,
+#define NODE_ARRAY NODE_ARRAY
+ NODE_ZARRAY,
+#define NODE_ZARRAY NODE_ZARRAY
NODE_VALUES,
+#define NODE_VALUES NODE_VALUES
NODE_HASH,
+#define NODE_HASH NODE_HASH
NODE_RETURN,
+#define NODE_RETURN NODE_RETURN
NODE_YIELD,
+#define NODE_YIELD NODE_YIELD
NODE_LVAR,
+#define NODE_LVAR NODE_LVAR
NODE_DVAR,
+#define NODE_DVAR NODE_DVAR
NODE_GVAR,
+#define NODE_GVAR NODE_GVAR
NODE_IVAR,
+#define NODE_IVAR NODE_IVAR
NODE_CONST,
+#define NODE_CONST NODE_CONST
NODE_CVAR,
+#define NODE_CVAR NODE_CVAR
NODE_NTH_REF,
+#define NODE_NTH_REF NODE_NTH_REF
NODE_BACK_REF,
+#define NODE_BACK_REF NODE_BACK_REF
NODE_MATCH,
+#define NODE_MATCH NODE_MATCH
NODE_MATCH2,
+#define NODE_MATCH2 NODE_MATCH2
NODE_MATCH3,
+#define NODE_MATCH3 NODE_MATCH3
NODE_LIT,
+#define NODE_LIT NODE_LIT
NODE_STR,
+#define NODE_STR NODE_STR
NODE_DSTR,
+#define NODE_DSTR NODE_DSTR
NODE_XSTR,
+#define NODE_XSTR NODE_XSTR
NODE_DXSTR,
+#define NODE_DXSTR NODE_DXSTR
NODE_EVSTR,
+#define NODE_EVSTR NODE_EVSTR
NODE_DREGX,
- NODE_ONCE,
+#define NODE_DREGX NODE_DREGX
NODE_ARGS,
+#define NODE_ARGS NODE_ARGS
NODE_ARGS_AUX,
+#define NODE_ARGS_AUX NODE_ARGS_AUX
NODE_OPT_ARG,
+#define NODE_OPT_ARG NODE_OPT_ARG
NODE_KW_ARG,
+#define NODE_KW_ARG NODE_KW_ARG
NODE_POSTARG,
+#define NODE_POSTARG NODE_POSTARG
NODE_ARGSCAT,
+#define NODE_ARGSCAT NODE_ARGSCAT
NODE_ARGSPUSH,
+#define NODE_ARGSPUSH NODE_ARGSPUSH
NODE_SPLAT,
+#define NODE_SPLAT NODE_SPLAT
NODE_BLOCK_PASS,
+#define NODE_BLOCK_PASS NODE_BLOCK_PASS
NODE_DEFN,
+#define NODE_DEFN NODE_DEFN
NODE_DEFS,
+#define NODE_DEFS NODE_DEFS
NODE_ALIAS,
+#define NODE_ALIAS NODE_ALIAS
NODE_VALIAS,
+#define NODE_VALIAS NODE_VALIAS
NODE_UNDEF,
+#define NODE_UNDEF NODE_UNDEF
NODE_CLASS,
+#define NODE_CLASS NODE_CLASS
NODE_MODULE,
+#define NODE_MODULE NODE_MODULE
NODE_SCLASS,
+#define NODE_SCLASS NODE_SCLASS
NODE_COLON2,
+#define NODE_COLON2 NODE_COLON2
NODE_COLON3,
+#define NODE_COLON3 NODE_COLON3
NODE_DOT2,
+#define NODE_DOT2 NODE_DOT2
NODE_DOT3,
+#define NODE_DOT3 NODE_DOT3
NODE_FLIP2,
+#define NODE_FLIP2 NODE_FLIP2
NODE_FLIP3,
+#define NODE_FLIP3 NODE_FLIP3
NODE_SELF,
+#define NODE_SELF NODE_SELF
NODE_NIL,
+#define NODE_NIL NODE_NIL
NODE_TRUE,
+#define NODE_TRUE NODE_TRUE
NODE_FALSE,
+#define NODE_FALSE NODE_FALSE
NODE_ERRINFO,
+#define NODE_ERRINFO NODE_ERRINFO
NODE_DEFINED,
+#define NODE_DEFINED NODE_DEFINED
NODE_POSTEXE,
+#define NODE_POSTEXE NODE_POSTEXE
NODE_DSYM,
+#define NODE_DSYM NODE_DSYM
NODE_ATTRASGN,
+#define NODE_ATTRASGN NODE_ATTRASGN
+ NODE_PRELUDE,
+#define NODE_PRELUDE NODE_PRELUDE
NODE_LAMBDA,
- NODE_ARYPTN,
- NODE_HSHPTN,
+#define NODE_LAMBDA NODE_LAMBDA
NODE_LAST
+#define NODE_LAST NODE_LAST
};
-typedef struct rb_code_position_struct {
+typedef struct rb_code_location_struct {
int lineno;
int column;
-} rb_code_position_t;
-
-typedef struct rb_code_location_struct {
- rb_code_position_t beg_pos;
- rb_code_position_t end_pos;
} rb_code_location_t;
-static inline rb_code_location_t
-code_loc_gen(rb_code_location_t *loc1, rb_code_location_t *loc2)
-{
- rb_code_location_t loc;
- loc.beg_pos = loc1->beg_pos;
- loc.end_pos = loc2->end_pos;
- return loc;
-}
+typedef struct rb_code_range_struct {
+ rb_code_location_t first_loc;
+ rb_code_location_t last_loc;
+} rb_code_range_t;
typedef struct RNode {
VALUE flags;
@@ -152,6 +238,7 @@ typedef struct RNode {
struct RNode *node;
ID id;
VALUE value;
+ VALUE (*cfunc)(ANYARGS);
ID *tbl;
} u1;
union {
@@ -166,16 +253,15 @@ typedef struct RNode {
long state;
struct rb_global_entry *entry;
struct rb_args_info *args;
- struct rb_ary_pattern_info *apinfo;
+ long cnt;
VALUE value;
} u3;
- rb_code_location_t nd_loc;
- int node_id;
+ rb_code_range_t nd_loc;
} NODE;
#define RNODE(obj) (R_CAST(RNode)(obj))
-/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
+/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: TAINT, 9: UNTRUSTED, 10: EXIVAR, 11: FREEZE */
/* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE,
* 8..14: nd_type,
* 15..: nd_line
@@ -195,21 +281,17 @@ typedef struct RNode {
#define nd_set_line(n,l) \
(n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
-#define nd_first_column(n) ((int)((n)->nd_loc.beg_pos.column))
-#define nd_set_first_column(n, v) ((n)->nd_loc.beg_pos.column = (v))
-#define nd_first_lineno(n) ((int)((n)->nd_loc.beg_pos.lineno))
-#define nd_set_first_lineno(n, v) ((n)->nd_loc.beg_pos.lineno = (v))
-#define nd_first_loc(n) ((n)->nd_loc.beg_pos)
-#define nd_set_first_loc(n, v) (nd_first_loc(n) = (v))
-
-#define nd_last_column(n) ((int)((n)->nd_loc.end_pos.column))
-#define nd_set_last_column(n, v) ((n)->nd_loc.end_pos.column = (v))
-#define nd_last_lineno(n) ((int)((n)->nd_loc.end_pos.lineno))
-#define nd_set_last_lineno(n, v) ((n)->nd_loc.end_pos.lineno = (v))
-#define nd_last_loc(n) ((n)->nd_loc.end_pos)
+#define nd_first_column(n) ((int)((n)->nd_loc.first_loc.column))
+#define nd_set_first_column(n, v) ((n)->nd_loc.first_loc.column = (v))
+#define nd_first_lineno(n) ((int)((n)->nd_loc.first_loc.lineno))
+#define nd_set_first_lineno(n, v) ((n)->nd_loc.first_loc.lineno = (v))
+
+#define nd_last_column(n) ((int)((n)->nd_loc.last_loc.column))
+#define nd_set_last_column(n, v) ((n)->nd_loc.last_loc.column = (v))
+#define nd_last_lineno(n) ((int)((n)->nd_loc.last_loc.lineno))
+#define nd_set_last_lineno(n, v) ((n)->nd_loc.last_loc.lineno = (v))
+#define nd_last_loc(n) ((n)->nd_loc.last_loc)
#define nd_set_last_loc(n, v) (nd_last_loc(n) = (v))
-#define nd_node_id(n) ((n)->node_id)
-#define nd_set_node_id(n,id) ((n)->node_id = (id))
#define nd_head u1.node
#define nd_alen u2.argc
@@ -233,6 +315,7 @@ typedef struct RNode {
#define nd_cval u3.value
#define nd_oid u1.id
+#define nd_cnt u3.cnt
#define nd_tbl u1.tbl
#define nd_var u1.node
@@ -243,6 +326,7 @@ typedef struct RNode {
#define nd_lit u1.value
+#define nd_frml u2.argc
#define nd_rest u1.id
#define nd_opt u1.node
#define nd_pid u1.id
@@ -253,8 +337,12 @@ typedef struct RNode {
#define nd_args u3.node
#define nd_ainfo u3.args
+#define nd_noex u3.id
#define nd_defn u3.node
+#define nd_cfnc u1.cfunc
+#define nd_argc u2.argc
+
#define nd_cpath u1.node
#define nd_super u3.node
@@ -271,161 +359,147 @@ typedef struct RNode {
#define nd_orig u2.id
#define nd_undef u2.node
-#define nd_brace u2.argc
-
-#define nd_pconst u1.node
-#define nd_pkwargs u2.node
-#define nd_pkwrestarg u3.node
-
-#define nd_apinfo u3.apinfo
-
-#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
-#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc)
-
-#define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc)
-#define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc)
-#define NEW_SCOPE(a,b,loc) NEW_NODE_WITH_LOCALS(NODE_SCOPE,b,a,loc)
-#define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc)
-#define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc)
-#define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc)
-#define NEW_CASE(h,b,loc) NEW_NODE(NODE_CASE,h,b,0,loc)
-#define NEW_CASE2(b,loc) NEW_NODE(NODE_CASE2,0,b,0,loc)
-#define NEW_CASE3(h,b,loc) NEW_NODE(NODE_CASE3,h,b,0,loc)
-#define NEW_WHEN(c,t,e,loc) NEW_NODE(NODE_WHEN,c,t,e,loc)
-#define NEW_IN(c,t,e,loc) NEW_NODE(NODE_IN,c,t,e,loc)
-#define NEW_WHILE(c,b,n,loc) NEW_NODE(NODE_WHILE,c,b,n,loc)
-#define NEW_UNTIL(c,b,n,loc) NEW_NODE(NODE_UNTIL,c,b,n,loc)
-#define NEW_FOR(i,b,loc) NEW_NODE(NODE_FOR,0,b,i,loc)
-#define NEW_FOR_MASGN(v,loc) NEW_NODE(NODE_FOR_MASGN,v,0,0,loc)
-#define NEW_ITER(a,b,loc) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b,loc),0,loc)
-#define NEW_LAMBDA(a,b,loc) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b,loc),0,loc)
-#define NEW_BREAK(s,loc) NEW_NODE(NODE_BREAK,s,0,0,loc)
-#define NEW_NEXT(s,loc) NEW_NODE(NODE_NEXT,s,0,0,loc)
-#define NEW_REDO(loc) NEW_NODE(NODE_REDO,0,0,0,loc)
-#define NEW_RETRY(loc) NEW_NODE(NODE_RETRY,0,0,0,loc)
-#define NEW_BEGIN(b,loc) NEW_NODE(NODE_BEGIN,0,b,0,loc)
-#define NEW_RESCUE(b,res,e,loc) NEW_NODE(NODE_RESCUE,b,res,e,loc)
-#define NEW_RESBODY(a,ex,n,loc) NEW_NODE(NODE_RESBODY,n,ex,a,loc)
-#define NEW_ENSURE(b,en,loc) NEW_NODE(NODE_ENSURE,b,0,en,loc)
-#define NEW_RETURN(s,loc) NEW_NODE(NODE_RETURN,s,0,0,loc)
-#define NEW_YIELD(a,loc) NEW_NODE(NODE_YIELD,a,0,0,loc)
-#define NEW_LIST(a,loc) NEW_NODE(NODE_LIST,a,1,0,loc)
-#define NEW_ZLIST(loc) NEW_NODE(NODE_ZLIST,0,0,0,loc)
-#define NEW_HASH(a,loc) NEW_NODE(NODE_HASH,a,0,0,loc)
-#define NEW_MASGN(l,r,loc) NEW_NODE(NODE_MASGN,l,0,r,loc)
-#define NEW_GASGN(v,val,loc) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v),loc)
-#define NEW_LASGN(v,val,loc) NEW_NODE(NODE_LASGN,v,val,0,loc)
-#define NEW_DASGN(v,val,loc) NEW_NODE(NODE_DASGN,v,val,0,loc)
-#define NEW_DASGN_CURR(v,val,loc) NEW_NODE(NODE_DASGN_CURR,v,val,0,loc)
-#define NEW_IASGN(v,val,loc) NEW_NODE(NODE_IASGN,v,val,0,loc)
-#define NEW_CDECL(v,val,path,loc) NEW_NODE(NODE_CDECL,v,val,path,loc)
-#define NEW_CVASGN(v,val,loc) NEW_NODE(NODE_CVASGN,v,val,0,loc)
-#define NEW_OP_ASGN1(p,id,a,loc) NEW_NODE(NODE_OP_ASGN1,p,id,a,loc)
-#define NEW_OP_ASGN2(r,t,i,o,val,loc) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t,loc),loc)
-#define NEW_OP_ASGN22(i,o,t,loc) NEW_NODE(NODE_OP_ASGN2,i,o,t,loc)
-#define NEW_OP_ASGN_OR(i,val,loc) NEW_NODE(NODE_OP_ASGN_OR,i,val,0,loc)
-#define NEW_OP_ASGN_AND(i,val,loc) NEW_NODE(NODE_OP_ASGN_AND,i,val,0,loc)
-#define NEW_OP_CDECL(v,op,val,loc) NEW_NODE(NODE_OP_CDECL,v,val,op,loc)
-#define NEW_GVAR(v,loc) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v),loc)
-#define NEW_LVAR(v,loc) NEW_NODE(NODE_LVAR,v,0,0,loc)
-#define NEW_DVAR(v,loc) NEW_NODE(NODE_DVAR,v,0,0,loc)
-#define NEW_IVAR(v,loc) NEW_NODE(NODE_IVAR,v,0,0,loc)
-#define NEW_CONST(v,loc) NEW_NODE(NODE_CONST,v,0,0,loc)
-#define NEW_CVAR(v,loc) NEW_NODE(NODE_CVAR,v,0,0,loc)
-#define NEW_NTH_REF(n,loc) NEW_NODE(NODE_NTH_REF,0,n,0,loc)
-#define NEW_BACK_REF(n,loc) NEW_NODE(NODE_BACK_REF,0,n,0,loc)
-#define NEW_MATCH(c,loc) NEW_NODE(NODE_MATCH,c,0,0,loc)
-#define NEW_MATCH2(n1,n2,loc) NEW_NODE(NODE_MATCH2,n1,n2,0,loc)
-#define NEW_MATCH3(r,n2,loc) NEW_NODE(NODE_MATCH3,r,n2,0,loc)
-#define NEW_LIT(l,loc) NEW_NODE(NODE_LIT,l,0,0,loc)
-#define NEW_STR(s,loc) NEW_NODE(NODE_STR,s,0,0,loc)
-#define NEW_DSTR(s,loc) NEW_NODE(NODE_DSTR,s,1,0,loc)
-#define NEW_XSTR(s,loc) NEW_NODE(NODE_XSTR,s,0,0,loc)
-#define NEW_DXSTR(s,loc) NEW_NODE(NODE_DXSTR,s,0,0,loc)
-#define NEW_DSYM(s,loc) NEW_NODE(NODE_DSYM,s,0,0,loc)
-#define NEW_EVSTR(n,loc) NEW_NODE(NODE_EVSTR,0,(n),0,loc)
-#define NEW_CALL(r,m,a,loc) NEW_NODE(NODE_CALL,r,m,a,loc)
-#define NEW_OPCALL(r,m,a,loc) NEW_NODE(NODE_OPCALL,r,m,a,loc)
-#define NEW_FCALL(m,a,loc) NEW_NODE(NODE_FCALL,0,m,a,loc)
-#define NEW_VCALL(m,loc) NEW_NODE(NODE_VCALL,0,m,0,loc)
-#define NEW_SUPER(a,loc) NEW_NODE(NODE_SUPER,0,0,a,loc)
-#define NEW_ZSUPER(loc) NEW_NODE(NODE_ZSUPER,0,0,0,loc)
-#define NEW_ARGS_AUX(r,b,loc) NEW_NODE(NODE_ARGS_AUX,r,b,0,loc)
-#define NEW_OPT_ARG(i,v,loc) NEW_NODE(NODE_OPT_ARG,i,v,0,loc)
-#define NEW_KW_ARG(i,v,loc) NEW_NODE(NODE_KW_ARG,i,v,0,loc)
-#define NEW_POSTARG(i,v,loc) NEW_NODE(NODE_POSTARG,i,v,0,loc)
-#define NEW_ARGSCAT(a,b,loc) NEW_NODE(NODE_ARGSCAT,a,b,0,loc)
-#define NEW_ARGSPUSH(a,b,loc) NEW_NODE(NODE_ARGSPUSH,a,b,0,loc)
-#define NEW_SPLAT(a,loc) NEW_NODE(NODE_SPLAT,a,0,0,loc)
-#define NEW_BLOCK_PASS(b,loc) NEW_NODE(NODE_BLOCK_PASS,0,b,0,loc)
-#define NEW_ALIAS(n,o,loc) NEW_NODE(NODE_ALIAS,n,o,0,loc)
-#define NEW_VALIAS(n,o,loc) NEW_NODE(NODE_VALIAS,n,o,0,loc)
-#define NEW_UNDEF(i,loc) NEW_NODE(NODE_UNDEF,0,i,0,loc)
-#define NEW_CLASS(n,b,s,loc) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b,loc),(s),loc)
-#define NEW_SCLASS(r,b,loc) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b,loc),0,loc)
-#define NEW_MODULE(n,b,loc) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b,loc),0,loc)
-#define NEW_COLON2(c,i,loc) NEW_NODE(NODE_COLON2,c,i,0,loc)
-#define NEW_COLON3(i,loc) NEW_NODE(NODE_COLON3,0,i,0,loc)
-#define NEW_DOT2(b,e,loc) NEW_NODE(NODE_DOT2,b,e,0,loc)
-#define NEW_DOT3(b,e,loc) NEW_NODE(NODE_DOT3,b,e,0,loc)
-#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,1,loc)
-#define NEW_NIL(loc) NEW_NODE(NODE_NIL,0,0,0,loc)
-#define NEW_TRUE(loc) NEW_NODE(NODE_TRUE,0,0,0,loc)
-#define NEW_FALSE(loc) NEW_NODE(NODE_FALSE,0,0,0,loc)
-#define NEW_ERRINFO(loc) NEW_NODE(NODE_ERRINFO,0,0,0,loc)
-#define NEW_DEFINED(e,loc) NEW_NODE(NODE_DEFINED,e,0,0,loc)
-#define NEW_PREEXE(b,loc) NEW_SCOPE(b,loc)
-#define NEW_POSTEXE(b,loc) NEW_NODE(NODE_POSTEXE,0,b,0,loc)
-#define NEW_ATTRASGN(r,m,a,loc) NEW_NODE(NODE_ATTRASGN,r,m,a,loc)
+#define nd_compile_option u3.value
+
+#define NEW_NODE(t,a0,a1,a2) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
+
+#define NEW_DEFN(i,a,d,p) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d))
+#define NEW_DEFS(r,i,a,d) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d))
+#define NEW_SCOPE(a,b) NEW_NODE(NODE_SCOPE,local_tbl(),b,a)
+#define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
+#define NEW_IF(c,t,e) NEW_NODE(NODE_IF,c,t,e)
+#define NEW_UNLESS(c,t,e) NEW_NODE(NODE_UNLESS,c,t,e)
+#define NEW_CASE(h,b) NEW_NODE(NODE_CASE,h,b,0)
+#define NEW_CASE2(b) NEW_NODE(NODE_CASE2,0,b,0)
+#define NEW_WHEN(c,t,e) NEW_NODE(NODE_WHEN,c,t,e)
+#define NEW_WHILE(c,b,n) NEW_NODE(NODE_WHILE,c,b,n)
+#define NEW_UNTIL(c,b,n) NEW_NODE(NODE_UNTIL,c,b,n)
+#define NEW_FOR(v,i,b) NEW_NODE(NODE_FOR,v,b,i)
+#define NEW_ITER(a,b) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b),0)
+#define NEW_LAMBDA(a,b) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b),0)
+#define NEW_BREAK(s) NEW_NODE(NODE_BREAK,s,0,0)
+#define NEW_NEXT(s) NEW_NODE(NODE_NEXT,s,0,0)
+#define NEW_REDO() NEW_NODE(NODE_REDO,0,0,0)
+#define NEW_RETRY() NEW_NODE(NODE_RETRY,0,0,0)
+#define NEW_BEGIN(b) NEW_NODE(NODE_BEGIN,0,b,0)
+#define NEW_RESCUE(b,res,e) NEW_NODE(NODE_RESCUE,b,res,e)
+#define NEW_RESBODY(a,ex,n) NEW_NODE(NODE_RESBODY,n,ex,a)
+#define NEW_ENSURE(b,en) NEW_NODE(NODE_ENSURE,b,0,en)
+#define NEW_RETURN(s) NEW_NODE(NODE_RETURN,s,0,0)
+#define NEW_YIELD(a) NEW_NODE(NODE_YIELD,a,0,0)
+#define NEW_LIST(a) NEW_ARRAY(a)
+#define NEW_ARRAY(a) NEW_NODE(NODE_ARRAY,a,1,0)
+#define NEW_ZARRAY() NEW_NODE(NODE_ZARRAY,0,0,0)
+#define NEW_HASH(a) NEW_NODE(NODE_HASH,a,0,0)
+#define NEW_MASGN(l,r) NEW_NODE(NODE_MASGN,l,0,r)
+#define NEW_GASGN(v,val) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v))
+#define NEW_LASGN(v,val) NEW_NODE(NODE_LASGN,v,val,0)
+#define NEW_DASGN(v,val) NEW_NODE(NODE_DASGN,v,val,0)
+#define NEW_DASGN_CURR(v,val) NEW_NODE(NODE_DASGN_CURR,v,val,0)
+#define NEW_IASGN(v,val) NEW_NODE(NODE_IASGN,v,val,0)
+#define NEW_CDECL(v,val,path) NEW_NODE(NODE_CDECL,v,val,path)
+#define NEW_CVASGN(v,val) NEW_NODE(NODE_CVASGN,v,val,0)
+#define NEW_OP_ASGN1(p,id,a) NEW_NODE(NODE_OP_ASGN1,p,id,a)
+#define NEW_OP_ASGN2(r,t,i,o,val) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t))
+#define NEW_OP_ASGN22(i,o,t) NEW_NODE(NODE_OP_ASGN2,i,o,t)
+#define NEW_OP_ASGN_OR(i,val) NEW_NODE(NODE_OP_ASGN_OR,i,val,0)
+#define NEW_OP_ASGN_AND(i,val) NEW_NODE(NODE_OP_ASGN_AND,i,val,0)
+#define NEW_OP_CDECL(v,op,val) NEW_NODE(NODE_OP_CDECL,v,val,op)
+#define NEW_GVAR(v) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v))
+#define NEW_LVAR(v) NEW_NODE(NODE_LVAR,v,0,0)
+#define NEW_DVAR(v) NEW_NODE(NODE_DVAR,v,0,0)
+#define NEW_IVAR(v) NEW_NODE(NODE_IVAR,v,0,0)
+#define NEW_CONST(v) NEW_NODE(NODE_CONST,v,0,0)
+#define NEW_CVAR(v) NEW_NODE(NODE_CVAR,v,0,0)
+#define NEW_NTH_REF(n) NEW_NODE(NODE_NTH_REF,0,n,0)
+#define NEW_BACK_REF(n) NEW_NODE(NODE_BACK_REF,0,n,0)
+#define NEW_MATCH(c) NEW_NODE(NODE_MATCH,c,0,0)
+#define NEW_MATCH2(n1,n2) NEW_NODE(NODE_MATCH2,n1,n2,0)
+#define NEW_MATCH3(r,n2) NEW_NODE(NODE_MATCH3,r,n2,0)
+#define NEW_LIT(l) NEW_NODE(NODE_LIT,l,0,0)
+#define NEW_STR(s) NEW_NODE(NODE_STR,s,0,0)
+#define NEW_DSTR(s) NEW_NODE(NODE_DSTR,s,1,0)
+#define NEW_XSTR(s) NEW_NODE(NODE_XSTR,s,0,0)
+#define NEW_DXSTR(s) NEW_NODE(NODE_DXSTR,s,0,0)
+#define NEW_DSYM(s) NEW_NODE(NODE_DSYM,s,0,0)
+#define NEW_EVSTR(n) NEW_NODE(NODE_EVSTR,0,(n),0)
+#define NEW_CALL(r,m,a) NEW_NODE(NODE_CALL,r,m,a)
+#define NEW_OPCALL(r,m,a) NEW_NODE(NODE_OPCALL,r,m,a)
+#define NEW_FCALL(m,a) NEW_NODE(NODE_FCALL,0,m,a)
+#define NEW_VCALL(m) NEW_NODE(NODE_VCALL,0,m,0)
+#define NEW_SUPER(a) NEW_NODE(NODE_SUPER,0,0,a)
+#define NEW_ZSUPER() NEW_NODE(NODE_ZSUPER,0,0,0)
+#define NEW_ARGS_AUX(r,b) NEW_NODE(NODE_ARGS_AUX,r,b,0)
+#define NEW_OPT_ARG(i,v) NEW_NODE(NODE_OPT_ARG,i,v,0)
+#define NEW_KW_ARG(i,v) NEW_NODE(NODE_KW_ARG,i,v,0)
+#define NEW_POSTARG(i,v) NEW_NODE(NODE_POSTARG,i,v,0)
+#define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
+#define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
+#define NEW_SPLAT(a) NEW_NODE(NODE_SPLAT,a,0,0)
+#define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
+#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0)
+#define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,n,o,0)
+#define NEW_UNDEF(i) NEW_NODE(NODE_UNDEF,0,i,0)
+#define NEW_CLASS(n,b,s) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b),(s))
+#define NEW_SCLASS(r,b) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b),0)
+#define NEW_MODULE(n,b) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b),0)
+#define NEW_COLON2(c,i) NEW_NODE(NODE_COLON2,c,i,0)
+#define NEW_COLON3(i) NEW_NODE(NODE_COLON3,0,i,0)
+#define NEW_DOT2(b,e) NEW_NODE(NODE_DOT2,b,e,0)
+#define NEW_DOT3(b,e) NEW_NODE(NODE_DOT3,b,e,0)
+#define NEW_SELF() NEW_NODE(NODE_SELF,0,0,0)
+#define NEW_NIL() NEW_NODE(NODE_NIL,0,0,0)
+#define NEW_TRUE() NEW_NODE(NODE_TRUE,0,0,0)
+#define NEW_FALSE() NEW_NODE(NODE_FALSE,0,0,0)
+#define NEW_ERRINFO() NEW_NODE(NODE_ERRINFO,0,0,0)
+#define NEW_DEFINED(e) NEW_NODE(NODE_DEFINED,e,0,0)
+#define NEW_PREEXE(b) NEW_SCOPE(b)
+#define NEW_POSTEXE(b) NEW_NODE(NODE_POSTEXE,0,b,0)
+#define NEW_ATTRASGN(r,m,a) NEW_NODE(NODE_ATTRASGN,r,m,a)
+#define NEW_PRELUDE(p,b,o) NEW_NODE(NODE_PRELUDE,p,b,o)
#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
-#define NODE_REQUIRED_KEYWORD_P(node) ((node)->nd_value == NODE_SPECIAL_REQUIRED_KEYWORD)
#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
-#define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
-#define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
-#define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
-
-VALUE rb_node_case_when_optimizable_literal(const NODE *const node);
RUBY_SYMBOL_EXPORT_BEGIN
typedef struct node_buffer_struct node_buffer_t;
/* T_IMEMO/ast */
-typedef struct rb_ast_body_struct {
- const NODE *root;
- VALUE compile_option;
- int line_count;
-} rb_ast_body_t;
typedef struct rb_ast_struct {
VALUE flags;
+ VALUE reserved1;
+ NODE *root;
node_buffer_t *node_buffer;
- rb_ast_body_t body;
+ VALUE mark_ary;
} rb_ast_t;
-rb_ast_t *rb_ast_new(void);
+rb_ast_t *rb_ast_new();
void rb_ast_mark(rb_ast_t*);
-void rb_ast_update_references(rb_ast_t*);
-void rb_ast_add_local_table(rb_ast_t*, ID *buf);
void rb_ast_dispose(rb_ast_t*);
void rb_ast_free(rb_ast_t*);
-size_t rb_ast_memsize(const rb_ast_t*);
void rb_ast_add_mark_object(rb_ast_t*, VALUE);
-NODE *rb_ast_newnode(rb_ast_t*, enum node_type type);
+void rb_ast_delete_mark_object(rb_ast_t*, VALUE);
+NODE *rb_ast_newnode(rb_ast_t*);
void rb_ast_delete_node(rb_ast_t*, NODE *n);
VALUE rb_parser_new(void);
VALUE rb_parser_end_seen_p(VALUE);
VALUE rb_parser_encoding(VALUE);
+VALUE rb_parser_get_yydebug(VALUE);
VALUE rb_parser_set_yydebug(VALUE, VALUE);
-VALUE rb_parser_dump_tree(const NODE *node, int comment);
+VALUE rb_parser_dump_tree(NODE *node, int comment);
void rb_parser_set_options(VALUE, int, int, int, int);
+rb_ast_t *rb_parser_compile_cstr(VALUE, const char*, const char*, int, int);
rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
+rb_ast_t *rb_parser_compile_file(VALUE, const char*, VALUE, int);
rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
-rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
+
+rb_ast_t *rb_compile_cstr(const char*, const char*, int, int);
+rb_ast_t *rb_compile_string(const char*, VALUE, int);
+rb_ast_t *rb_compile_file(const char*, VALUE, int);
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
-const char *ruby_node_name(int node);
const struct kwtable *rb_reserved_word(const char *, unsigned int);
@@ -445,17 +519,6 @@ struct rb_args_info {
NODE *kw_rest_arg;
NODE *opt_args;
- unsigned int no_kwarg: 1;
- unsigned int ruby2_keywords: 1;
-
- VALUE imemo;
-};
-
-struct rb_ary_pattern_info {
- NODE *pre_args;
- NODE *rest_arg;
- NODE *post_args;
- VALUE imemo;
};
struct parser_params;
@@ -463,7 +526,7 @@ void *rb_parser_malloc(struct parser_params *, size_t);
void *rb_parser_realloc(struct parser_params *, void *, size_t);
void *rb_parser_calloc(struct parser_params *, size_t, size_t);
void rb_parser_free(struct parser_params *, void *);
-PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
+void rb_parser_printf(struct parser_params *parser, const char *fmt, ...);
RUBY_SYMBOL_EXPORT_END
diff --git a/numeric.c b/numeric.c
index ea15625697..d0531fa69c 100644
--- a/numeric.c
+++ b/numeric.c
@@ -9,9 +9,8 @@
**********************************************************************/
-#include "ruby/encoding.h"
-#include "ruby/util.h"
#include "internal.h"
+#include "ruby/util.h"
#include "id.h"
#include <assert.h>
#include <ctype.h>
@@ -61,14 +60,14 @@
#define DBL_EPSILON 2.2204460492503131e-16
#endif
-#ifndef USE_RB_INFINITY
+#ifdef HAVE_INFINITY
#elif !defined(WORDS_BIGENDIAN) /* BYTE_ORDER == LITTLE_ENDIAN */
const union bytesequence4_or_float rb_infinity = {{0x00, 0x00, 0x80, 0x7f}};
#else
const union bytesequence4_or_float rb_infinity = {{0x7f, 0x80, 0x00, 0x00}};
#endif
-#ifndef USE_RB_NAN
+#ifdef HAVE_NAN
#elif !defined(WORDS_BIGENDIAN) /* BYTE_ORDER == LITTLE_ENDIAN */
const union bytesequence4_or_float rb_nan = {{0x00, 0x00, 0xc0, 0x7f}};
#else
@@ -171,9 +170,7 @@ static VALUE flo_to_i(VALUE num);
static int float_round_overflow(int ndigits, int binexp);
static int float_round_underflow(int ndigits, int binexp);
-static ID id_coerce;
-#define id_div idDiv
-#define id_divmod idDivmod
+static ID id_coerce, id_div, id_divmod;
#define id_to_i idTo_i
#define id_eq idEq
#define id_cmp idCmp
@@ -298,18 +295,6 @@ int_neg_p(VALUE num)
}
int
-rb_int_positive_p(VALUE num)
-{
- return int_pos_p(num);
-}
-
-int
-rb_int_negative_p(VALUE num)
-{
- return int_neg_p(num);
-}
-
-int
rb_num_negative_p(VALUE num)
{
return rb_num_negative_int_p(num);
@@ -343,8 +328,6 @@ num_funcall0(VALUE x, ID func)
return rb_exec_recursive(num_funcall_op_0, x, (VALUE)func);
}
-NORETURN(static void num_funcall_op_1_recursion(VALUE x, ID func, VALUE y));
-
static void
num_funcall_op_1_recursion(VALUE x, ID func, VALUE y)
{
@@ -410,7 +393,7 @@ NORETURN(static void coerce_failed(VALUE x, VALUE y));
static void
coerce_failed(VALUE x, VALUE y)
{
- if (SPECIAL_CONST_P(y) || SYMBOL_P(y) || RB_FLOAT_TYPE_P(y)) {
+ if (SPECIAL_CONST_P(y) || BUILTIN_TYPE(y) == T_FLOAT) {
y = rb_inspect(y);
}
else {
@@ -489,7 +472,7 @@ num_sadded(VALUE x, VALUE name)
rb_id2str(mid),
rb_obj_class(x));
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
#if 0
@@ -1020,8 +1003,8 @@ rb_float_uminus(VALUE flt)
* Returns a new Float which is the sum of +float+ and +other+.
*/
-VALUE
-rb_float_plus(VALUE x, VALUE y)
+static VALUE
+flo_plus(VALUE x, VALUE y)
{
if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y));
@@ -1044,8 +1027,8 @@ rb_float_plus(VALUE x, VALUE y)
* Returns a new Float which is the difference of +float+ and +other+.
*/
-VALUE
-rb_float_minus(VALUE x, VALUE y)
+static VALUE
+flo_minus(VALUE x, VALUE y)
{
if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y));
@@ -1068,8 +1051,8 @@ rb_float_minus(VALUE x, VALUE y)
* Returns a new Float which is the product of +float+ and +other+.
*/
-VALUE
-rb_float_mul(VALUE x, VALUE y)
+static VALUE
+flo_mul(VALUE x, VALUE y)
{
if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y));
@@ -1085,36 +1068,6 @@ rb_float_mul(VALUE x, VALUE y)
}
}
-static bool
-flo_iszero(VALUE f)
-{
- return FLOAT_ZERO_P(f);
-}
-
-static double
-double_div_double(double x, double y)
-{
- if (LIKELY(y != 0.0)) {
- return x / y;
- }
- else if (x == 0.0) {
- return nan("");
- }
- else {
- double z = signbit(y) ? -1.0 : 1.0;
- return x * z * HUGE_VAL;
- }
-}
-
-MJIT_FUNC_EXPORTED VALUE
-rb_flo_div_flo(VALUE x, VALUE y)
-{
- double num = RFLOAT_VALUE(x);
- double den = RFLOAT_VALUE(y);
- double ret = double_div_double(num, den);
- return DBL2NUM(ret);
-}
-
/*
* call-seq:
* float / other -> float
@@ -1122,28 +1075,26 @@ rb_flo_div_flo(VALUE x, VALUE y)
* Returns a new Float which is the result of dividing +float+ by +other+.
*/
-VALUE
-rb_float_div(VALUE x, VALUE y)
+static VALUE
+flo_div(VALUE x, VALUE y)
{
- double num = RFLOAT_VALUE(x);
- double den;
- double ret;
+ long f_y;
+ double d;
if (RB_TYPE_P(y, T_FIXNUM)) {
- den = FIX2LONG(y);
+ f_y = FIX2LONG(y);
+ return DBL2NUM(RFLOAT_VALUE(x) / (double)f_y);
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
- den = rb_big2dbl(y);
+ d = rb_big2dbl(y);
+ return DBL2NUM(RFLOAT_VALUE(x) / d);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
- den = RFLOAT_VALUE(y);
+ return DBL2NUM(RFLOAT_VALUE(x) / RFLOAT_VALUE(y));
}
else {
return rb_num_coerce_bin(x, y, '/');
}
-
- ret = double_div_double(num, den);
- return DBL2NUM(ret);
}
/*
@@ -1203,7 +1154,7 @@ flodivmod(double x, double y, double *divp, double *modp)
* An error will be raised if y == 0.
*/
-MJIT_FUNC_EXPORTED double
+double
ruby_float_mod(double x, double y)
{
double mod;
@@ -1310,7 +1261,7 @@ rb_float_pow(VALUE x, VALUE y)
dx = RFLOAT_VALUE(x);
dy = RFLOAT_VALUE(y);
if (dx < 0 && dy != round(dy))
- return rb_dbl_complex_new_polar_pi(pow(-dx, dy), dy);
+ return num_funcall1(rb_complex_raw1(x), idPow, y);
}
else {
return rb_num_coerce_bin(x, y, idPow);
@@ -1379,7 +1330,7 @@ num_equal(VALUE x, VALUE y)
* so an implementation-dependent value is returned.
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_float_equal(VALUE x, VALUE y)
{
volatile double a, b;
@@ -1404,7 +1355,6 @@ rb_float_equal(VALUE x, VALUE y)
}
#define flo_eq rb_float_equal
-static VALUE rb_dbl_hash(double d);
/*
* call-seq:
@@ -1421,7 +1371,7 @@ flo_hash(VALUE num)
return rb_dbl_hash(RFLOAT_VALUE(num));
}
-static VALUE
+VALUE
rb_dbl_hash(double d)
{
return LONG2FIX(rb_dbl_long_hash(d));
@@ -1462,7 +1412,7 @@ flo_cmp(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return LONG2FIX(-FIX2LONG(rel));
+ return INT2FIX(-FIX2INT(rel));
return rel;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1483,7 +1433,7 @@ flo_cmp(VALUE x, VALUE y)
return rb_dbl_cmp(a, b);
}
-MJIT_FUNC_EXPORTED int
+int
rb_float_cmp(VALUE x, VALUE y)
{
return NUM2INT(flo_cmp(x, y));
@@ -1508,7 +1458,7 @@ rb_float_gt(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) > 0 ? Qtrue : Qfalse;
+ return -FIX2INT(rel) > 0 ? Qtrue : Qfalse;
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1545,7 +1495,7 @@ flo_ge(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) >= 0 ? Qtrue : Qfalse;
+ return -FIX2INT(rel) >= 0 ? Qtrue : Qfalse;
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1582,7 +1532,7 @@ flo_lt(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) < 0 ? Qtrue : Qfalse;
+ return -FIX2INT(rel) < 0 ? Qtrue : Qfalse;
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1619,7 +1569,7 @@ flo_le(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) <= 0 ? Qtrue : Qfalse;
+ return -FIX2INT(rel) <= 0 ? Qtrue : Qfalse;
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1650,7 +1600,7 @@ flo_le(VALUE x, VALUE y)
* so an implementation-dependent value is returned.
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_float_eql(VALUE x, VALUE y)
{
if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1711,7 +1661,10 @@ rb_float_abs(VALUE flt)
static VALUE
flo_zero_p(VALUE num)
{
- return flo_iszero(num) ? Qtrue : Qfalse;
+ if (RFLOAT_VALUE(num) == 0.0) {
+ return Qtrue;
+ }
+ return Qfalse;
}
/*
@@ -1839,7 +1792,7 @@ flo_next_float(VALUE vx)
{
double x, y;
x = NUM2DBL(vx);
- y = nextafter(x, HUGE_VAL);
+ y = nextafter(x, INFINITY);
return DBL2NUM(y);
}
@@ -1890,35 +1843,10 @@ flo_prev_float(VALUE vx)
{
double x, y;
x = NUM2DBL(vx);
- y = nextafter(x, -HUGE_VAL);
+ y = nextafter(x, -INFINITY);
return DBL2NUM(y);
}
-VALUE
-rb_float_floor(VALUE num, int ndigits)
-{
- double number, f;
- number = RFLOAT_VALUE(num);
- if (number == 0.0) {
- return ndigits > 0 ? DBL2NUM(number) : INT2FIX(0);
- }
- if (ndigits > 0) {
- int binexp;
- frexp(number, &binexp);
- if (float_round_overflow(ndigits, binexp)) return num;
- if (number > 0.0 && float_round_underflow(ndigits, binexp))
- return DBL2NUM(0.0);
- f = pow(10, ndigits);
- f = floor(number * f) / f;
- return DBL2NUM(f);
- }
- else {
- num = dbl2ival(floor(number));
- if (ndigits < 0) num = rb_int_floor(num, ndigits);
- return num;
- }
-}
-
/*
* call-seq:
* float.floor([ndigits]) -> integer or float
@@ -1961,11 +1889,31 @@ rb_float_floor(VALUE num, int ndigits)
static VALUE
flo_floor(int argc, VALUE *argv, VALUE num)
{
+ double number, f;
int ndigits = 0;
+
if (rb_check_arity(argc, 0, 1)) {
ndigits = NUM2INT(argv[0]);
}
- return rb_float_floor(num, ndigits);
+ number = RFLOAT_VALUE(num);
+ if (number == 0.0) {
+ return ndigits > 0 ? DBL2NUM(number) : INT2FIX(0);
+ }
+ if (ndigits > 0) {
+ int binexp;
+ frexp(number, &binexp);
+ if (float_round_overflow(ndigits, binexp)) return num;
+ if (number > 0.0 && float_round_underflow(ndigits, binexp))
+ return DBL2NUM(0.0);
+ f = pow(10, ndigits);
+ f = floor(number * f) / f;
+ return DBL2NUM(f);
+ }
+ else {
+ num = dbl2ival(floor(number));
+ if (ndigits < 0) num = rb_int_floor(num, ndigits);
+ return num;
+ }
}
/*
@@ -2010,19 +1958,12 @@ flo_floor(int argc, VALUE *argv, VALUE num)
static VALUE
flo_ceil(int argc, VALUE *argv, VALUE num)
{
+ double number, f;
int ndigits = 0;
if (rb_check_arity(argc, 0, 1)) {
ndigits = NUM2INT(argv[0]);
}
- return rb_float_ceil(num, ndigits);
-}
-
-VALUE
-rb_float_ceil(VALUE num, int ndigits)
-{
- double number, f;
-
number = RFLOAT_VALUE(num);
if (number == 0.0) {
return ndigits > 0 ? DBL2NUM(number) : INT2FIX(0);
@@ -2105,7 +2046,7 @@ int_half_p_half_down(VALUE num, VALUE n, VALUE f)
/*
* Assumes num is an Integer, ndigits <= 0
*/
-static VALUE
+VALUE
rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode)
{
VALUE n, f, h, r;
@@ -2496,20 +2437,19 @@ num_truncate(int argc, VALUE *argv, VALUE num)
return flo_truncate(argc, argv, rb_Float(num));
}
-double
+static double
ruby_float_step_size(double beg, double end, double unit, int excl)
{
const double epsilon = DBL_EPSILON;
- double n, err;
+ double n = (end - beg)/unit;
+ double err = (fabs(beg) + fabs(end) + fabs(end-beg)) / fabs(unit) * epsilon;
- if (unit == 0) {
- return HUGE_VAL;
- }
- n= (end - beg)/unit;
- err = (fabs(beg) + fabs(end) + fabs(end-beg)) / fabs(unit) * epsilon;
if (isinf(unit)) {
return unit > 0 ? beg <= end : beg >= end;
}
+ if (unit == 0) {
+ return INFINITY;
+ }
if (err>0.5) err=0.5;
if (excl) {
if (n<=0) return 0;
@@ -2526,12 +2466,12 @@ ruby_float_step_size(double beg, double end, double unit, int excl)
}
int
-ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless)
+ruby_float_step(VALUE from, VALUE to, VALUE step, int excl)
{
if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) {
- double unit = NUM2DBL(step);
double beg = NUM2DBL(from);
- double end = (allow_endless && NIL_P(to)) ? (unit < 0 ? -1 : 1)*HUGE_VAL : NUM2DBL(to);
+ double end = NUM2DBL(to);
+ double unit = NUM2DBL(step);
double n = ruby_float_step_size(beg, end, unit, excl);
long i;
@@ -2564,7 +2504,7 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
diff = FIX2LONG(step);
if (diff == 0) {
- return DBL2NUM(HUGE_VAL);
+ return DBL2NUM(INFINITY);
}
delta = FIX2LONG(to) - FIX2LONG(from);
if (diff < 0) {
@@ -2590,7 +2530,7 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
VALUE result;
ID cmp = '>';
switch (rb_cmpint(rb_num_coerce_cmp(step, INT2FIX(0), id_cmp), step, INT2FIX(0))) {
- case 0: return DBL2NUM(HUGE_VAL);
+ case 0: return DBL2NUM(INFINITY);
case -1: cmp = '<'; break;
}
if (RTEST(rb_funcall(from, cmp, 1, to))) return INT2FIX(0);
@@ -2626,9 +2566,10 @@ num_step_negative_p(VALUE num)
}
static int
-num_step_extract_args(int argc, const VALUE *argv, VALUE *to, VALUE *step, VALUE *by)
+num_step_scan_args(int argc, const VALUE *argv, VALUE *to, VALUE *step)
{
VALUE hash;
+ int desc;
argc = rb_scan_args(argc, argv, "02:", to, step, &hash);
if (!NIL_P(hash)) {
@@ -2643,47 +2584,28 @@ num_step_extract_args(int argc, const VALUE *argv, VALUE *to, VALUE *step, VALUE
}
if (values[1] != Qundef) {
if (argc > 1) rb_raise(rb_eArgError, "step is given twice");
- *by = values[1];
+ *step = values[1];
}
}
-
- return argc;
-}
-
-static int
-num_step_check_fix_args(int argc, VALUE *to, VALUE *step, VALUE by, int fix_nil, int allow_zero_step)
-{
- int desc;
- if (by != Qundef) {
- *step = by;
- }
else {
- /* compatibility */
- if (argc > 1 && NIL_P(*step)) {
- rb_raise(rb_eTypeError, "step must be numeric");
- }
- if (!allow_zero_step && rb_equal(*step, INT2FIX(0))) {
- rb_raise(rb_eArgError, "step can't be 0");
- }
+ /* compatibility */
+ if (argc > 1 && NIL_P(*step)) {
+ rb_raise(rb_eTypeError, "step must be numeric");
+ }
+ if (rb_equal(*step, INT2FIX(0))) {
+ rb_raise(rb_eArgError, "step can't be 0");
+ }
}
if (NIL_P(*step)) {
*step = INT2FIX(1);
}
desc = num_step_negative_p(*step);
- if (fix_nil && NIL_P(*to)) {
- *to = desc ? DBL2NUM(-HUGE_VAL) : DBL2NUM(HUGE_VAL);
+ if (NIL_P(*to)) {
+ *to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY);
}
return desc;
}
-static int
-num_step_scan_args(int argc, const VALUE *argv, VALUE *to, VALUE *step, int fix_nil, int allow_zero_step)
-{
- VALUE by = Qundef;
- argc = num_step_extract_args(argc, argv, to, step, &by);
- return num_step_check_fix_args(argc, to, step, by, fix_nil, allow_zero_step);
-}
-
static VALUE
num_step_size(VALUE from, VALUE args, VALUE eobj)
{
@@ -2691,7 +2613,7 @@ num_step_size(VALUE from, VALUE args, VALUE eobj)
int argc = args ? RARRAY_LENINT(args) : 0;
const VALUE *argv = args ? RARRAY_CONST_PTR(args) : 0;
- num_step_scan_args(argc, argv, &to, &step, TRUE, FALSE);
+ num_step_scan_args(argc, argv, &to, &step);
return ruby_num_interval_step_size(from, to, step, FALSE);
}
@@ -2699,11 +2621,9 @@ num_step_size(VALUE from, VALUE args, VALUE eobj)
/*
* call-seq:
* num.step(by: step, to: limit) {|i| block } -> self
- * num.step(by: step, to: limit) -> an_enumerator
- * num.step(by: step, to: limit) -> an_arithmetic_sequence
+ * num.step(by: step, to: limit) -> an_enumerator
* num.step(limit=nil, step=1) {|i| block } -> self
* num.step(limit=nil, step=1) -> an_enumerator
- * num.step(limit=nil, step=1) -> an_arithmetic_sequence
*
* Invokes the given block with the sequence of numbers starting at +num+,
* incremented by +step+ (defaulted to +1+) on each call.
@@ -2732,8 +2652,6 @@ num_step_size(VALUE from, VALUE args, VALUE eobj)
* and increments itself using the <code>+</code> operator.
*
* If no block is given, an Enumerator is returned instead.
- * Especially, the enumerator is an Enumerator::ArithmeticSequence
- * if both +limit+ and +step+ are kind of Numeric or <code>nil</code>.
*
* For example:
*
@@ -2758,26 +2676,9 @@ num_step(int argc, VALUE *argv, VALUE from)
VALUE to, step;
int desc, inf;
- if (!rb_block_given_p()) {
- VALUE by = Qundef;
+ RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size);
- num_step_extract_args(argc, argv, &to, &step, &by);
- if (by != Qundef) {
- step = by;
- }
- if (NIL_P(step)) {
- step = INT2FIX(1);
- }
- if ((NIL_P(to) || rb_obj_is_kind_of(to, rb_cNumeric)) &&
- rb_obj_is_kind_of(step, rb_cNumeric)) {
- return rb_arith_seq_new(from, ID2SYM(rb_frame_this_func()), argc, argv,
- num_step_size, from, to, step, FALSE);
- }
-
- return SIZED_ENUMERATOR(from, 2, ((VALUE [2]){to, step}), num_step_size);
- }
-
- desc = num_step_scan_args(argc, argv, &to, &step, TRUE, FALSE);
+ desc = num_step_scan_args(argc, argv, &to, &step);
if (rb_equal(step, INT2FIX(0))) {
inf = 1;
}
@@ -2808,7 +2709,7 @@ num_step(int argc, VALUE *argv, VALUE from)
}
}
}
- else if (!ruby_float_step(from, to, step, FALSE, FALSE)) {
+ else if (!ruby_float_step(from, to, step, FALSE)) {
VALUE i = from;
if (inf) {
@@ -3348,7 +3249,7 @@ rb_int_succ(VALUE num)
* (-1).pred #=> -2
*/
-static VALUE
+VALUE
rb_int_pred(VALUE num)
{
if (FIXNUM_P(num)) {
@@ -3433,7 +3334,8 @@ int_chr(int argc, VALUE *argv, VALUE num)
case 1:
break;
default:
- rb_error_arity(argc, 0, 1);
+ rb_check_arity(argc, 0, 1);
+ break;
}
enc = rb_to_encoding(argv[0]);
if (!enc) enc = rb_ascii8bit_encoding();
@@ -3716,16 +3618,16 @@ static double
fix_fdiv_double(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
- return double_div_double(FIX2LONG(x), FIX2LONG(y));
+ return (double)FIX2LONG(x) / (double)FIX2LONG(y);
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
return rb_big_fdiv_double(rb_int2big(FIX2LONG(x)), y);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
- return double_div_double(FIX2LONG(x), RFLOAT_VALUE(y));
+ return (double)FIX2LONG(x) / RFLOAT_VALUE(y);
}
else {
- return NUM2DBL(rb_num_coerce_bin(x, y, idFdiv));
+ return NUM2DBL(rb_num_coerce_bin(x, y, rb_intern("fdiv")));
}
}
@@ -3745,9 +3647,7 @@ rb_int_fdiv_double(VALUE x, VALUE y)
else if (RB_TYPE_P(x, T_BIGNUM)) {
return rb_big_fdiv_double(x, y);
}
- else {
- return nan("");
- }
+ return NAN;
}
/*
@@ -3792,16 +3692,19 @@ fix_divide(VALUE x, VALUE y, ID op)
return rb_big_div(x, y);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
+ {
+ double div;
+
if (op == '/') {
- double d = FIX2LONG(x);
- return rb_flo_div_flo(DBL2NUM(d), y);
+ div = (double)FIX2LONG(x) / RFLOAT_VALUE(y);
+ return DBL2NUM(div);
}
else {
- VALUE v;
if (RFLOAT_VALUE(y) == 0) rb_num_zerodiv();
- v = fix_divide(x, y, '/');
- return flo_floor(0, 0, v);
+ div = (double)FIX2LONG(x) / RFLOAT_VALUE(y);
+ return rb_dbl2big(floor(div));
}
+ }
}
else {
if (RB_TYPE_P(y, T_RATIONAL) &&
@@ -3916,7 +3819,7 @@ rb_int_modulo(VALUE x, VALUE y)
* See Numeric#divmod.
*/
-static VALUE
+VALUE
int_remainder(VALUE x, VALUE y)
{
if (FIXNUM_P(x)) {
@@ -4055,17 +3958,14 @@ fix_pow(VALUE x, VALUE y)
else
return INT2FIX(-1);
}
- if (b < 0) {
- if (a == 0) rb_num_zerodiv();
- y = rb_int_pow(x, LONG2NUM(-b));
- goto inverted;
- }
+ if (b < 0)
+ return num_funcall1(rb_rational_raw1(x), idPow, y);
if (b == 0) return INT2FIX(1);
if (b == 1) return x;
if (a == 0) {
if (b > 0) return INT2FIX(0);
- return DBL2NUM(HUGE_VAL);
+ return DBL2NUM(INFINITY);
}
return int_pow(a, b);
}
@@ -4075,16 +3975,8 @@ fix_pow(VALUE x, VALUE y)
if (int_even_p(y)) return INT2FIX(1);
else return INT2FIX(-1);
}
- if (BIGNUM_NEGATIVE_P(y)) {
- if (a == 0) rb_num_zerodiv();
- y = rb_int_pow(x, rb_big_uminus(y));
- inverted:
- if (RB_FLOAT_TYPE_P(y)) {
- double d = pow((double)a, RFLOAT_VALUE(y));
- return DBL2NUM(1.0 / d);
- }
- return rb_rational_raw(INT2FIX(1), y);
- }
+ if (rb_num_negative_int_p(y))
+ return num_funcall1(rb_rational_raw1(x), idPow, y);
if (a == 0) return INT2FIX(0);
x = rb_int2big(FIX2LONG(x));
return rb_big_pow(x, y);
@@ -4093,12 +3985,12 @@ fix_pow(VALUE x, VALUE y)
double dy = RFLOAT_VALUE(y);
if (dy == 0.0) return DBL2NUM(1.0);
if (a == 0) {
- return DBL2NUM(dy < 0 ? HUGE_VAL : 0.0);
+ return DBL2NUM(dy < 0 ? INFINITY : 0.0);
}
if (a == 1) return DBL2NUM(1.0);
{
if (a < 0 && dy != round(dy))
- return rb_dbl_complex_new_polar_pi(pow(-(double)a, dy), dy);
+ return num_funcall1(rb_complex_raw1(x), idPow, y);
return DBL2NUM(pow((double)a, dy));
}
}
@@ -4119,22 +4011,6 @@ rb_int_pow(VALUE x, VALUE y)
return Qnil;
}
-VALUE
-rb_num_pow(VALUE x, VALUE y)
-{
- VALUE z = rb_int_pow(x, y);
- if (!NIL_P(z)) return z;
- if (RB_FLOAT_TYPE_P(x)) return rb_float_pow(x, y);
- if (SPECIAL_CONST_P(x)) return Qnil;
- switch (BUILTIN_TYPE(x)) {
- case T_COMPLEX:
- return rb_complex_pow(x, y);
- case T_RATIONAL:
- return rb_rational_pow(x, y);
- }
- return Qnil;
-}
-
/*
* Document-method: Integer#==
* Document-method: Integer#===
@@ -4211,6 +4087,7 @@ fix_cmp(VALUE x, VALUE y)
else {
return rb_num_coerce_cmp(x, y, id_cmp);
}
+ return rb_num_coerce_cmp(x, y, id_cmp);
}
VALUE
@@ -4565,7 +4442,6 @@ rb_fix_lshift(VALUE x, VALUE y)
long val, width;
val = NUM2LONG(x);
- if (!val) return (rb_to_int(y), INT2FIX(0));
if (!FIXNUM_P(y))
return rb_big_lshift(rb_int2big(val), y);
width = FIX2LONG(y);
@@ -4612,7 +4488,6 @@ rb_fix_rshift(VALUE x, VALUE y)
long i, val;
val = FIX2LONG(x);
- if (!val) return (rb_to_int(y), INT2FIX(0));
if (!FIXNUM_P(y))
return rb_big_rshift(rb_int2big(val), y);
i = FIX2LONG(y);
@@ -4645,8 +4520,26 @@ rb_int_rshift(VALUE x, VALUE y)
return Qnil;
}
-MJIT_FUNC_EXPORTED VALUE
-rb_fix_aref(VALUE fix, VALUE idx)
+/*
+ * Document-method: Integer#[]
+ * call-seq:
+ * int[n] -> 0, 1
+ *
+ * Bit Reference---Returns the <code>n</code>th bit in the
+ * binary representation of +int+, where <code>int[0]</code>
+ * is the least significant bit.
+ *
+ * a = 0b11001100101010
+ * 30.downto(0) {|n| print a[n] }
+ * #=> 0000000000000000011001100101010
+ *
+ * a = 9**15
+ * 50.downto(0) {|n| print a[n] }
+ * #=> 000101110110100000111000011110010100111100010111001
+ */
+
+static VALUE
+fix_aref(VALUE fix, VALUE idx)
{
long val = FIX2LONG(fix);
long i;
@@ -4672,136 +4565,15 @@ rb_fix_aref(VALUE fix, VALUE idx)
return INT2FIX(0);
}
-
-/* copied from "r_less" in range.c */
-/* compares _a_ and _b_ and returns:
- * < 0: a < b
- * = 0: a = b
- * > 0: a > b or non-comparable
- */
-static int
-compare_indexes(VALUE a, VALUE b)
-{
- VALUE r = rb_funcall(a, id_cmp, 1, b);
-
- if (NIL_P(r))
- return INT_MAX;
- return rb_cmpint(r, a, b);
-}
-
static VALUE
-generate_mask(VALUE len)
+int_aref(VALUE num, VALUE idx)
{
- return rb_int_minus(rb_int_lshift(INT2FIX(1), len), INT2FIX(1));
-}
-
-static VALUE
-int_aref1(VALUE num, VALUE arg)
-{
- VALUE orig_num = num, beg, end;
- int excl;
-
- if (rb_range_values(arg, &beg, &end, &excl)) {
- if (NIL_P(beg)) {
- /* beginless range */
- if (!RTEST(num_negative_p(end))) {
- if (!excl) end = rb_int_plus(end, INT2FIX(1));
- VALUE mask = generate_mask(end);
- if (RTEST(num_zero_p(rb_int_and(num, mask)))) {
- return INT2FIX(0);
- }
- else {
- rb_raise(rb_eArgError, "The beginless range for Integer#[] results in infinity");
- }
- }
- else {
- return INT2FIX(0);
- }
- }
- num = rb_int_rshift(num, beg);
-
- int cmp = compare_indexes(beg, end);
- if (!NIL_P(end) && cmp < 0) {
- VALUE len = rb_int_minus(end, beg);
- if (!excl) len = rb_int_plus(len, INT2FIX(1));
- VALUE mask = generate_mask(len);
- num = rb_int_and(num, mask);
- }
- else if (cmp == 0) {
- if (excl) return INT2FIX(0);
- num = orig_num;
- arg = beg;
- goto one_bit;
- }
- return num;
- }
-
-one_bit:
if (FIXNUM_P(num)) {
- return rb_fix_aref(num, arg);
+ return fix_aref(num, idx);
}
else if (RB_TYPE_P(num, T_BIGNUM)) {
- return rb_big_aref(num, arg);
- }
- return Qnil;
-}
-
-static VALUE
-int_aref2(VALUE num, VALUE beg, VALUE len)
-{
- num = rb_int_rshift(num, beg);
- VALUE mask = generate_mask(len);
- num = rb_int_and(num, mask);
- return num;
-}
-
-/*
- * Document-method: Integer#[]
- * call-seq:
- * int[n] -> 0, 1
- * int[n, m] -> num
- * int[range] -> num
- *
- * Bit Reference---Returns the <code>n</code>th bit in the
- * binary representation of +int+, where <code>int[0]</code>
- * is the least significant bit.
- *
- * a = 0b11001100101010
- * 30.downto(0) {|n| print a[n] }
- * #=> 0000000000000000011001100101010
- *
- * a = 9**15
- * 50.downto(0) {|n| print a[n] }
- * #=> 000101110110100000111000011110010100111100010111001
- *
- * In principle, <code>n[i]</code> is equivalent to <code>(n >> i) & 1</code>.
- * Thus, any negative index always returns zero:
- *
- * p 255[-1] #=> 0
- *
- * Range operations <code>n[i, len]</code> and <code>n[i..j]</code>
- * are naturally extended.
- *
- * * <code>n[i, len]</code> equals to <code>(n >> i) & ((1 << len) - 1)</code>.
- * * <code>n[i..j]</code> equals to <code>(n >> i) & ((1 << (j - i + 1)) - 1)</code>.
- * * <code>n[i...j]</code> equals to <code>(n >> i) & ((1 << (j - i)) - 1)</code>.
- * * <code>n[i..]</code> equals to <code>(n >> i)</code>.
- * * <code>n[..j]</code> is zero if <code>n & ((1 << (j + 1)) - 1)</code> is zero. Otherwise, raises an ArgumentError.
- * * <code>n[...j]</code> is zero if <code>n & ((1 << j) - 1)</code> is zero. Otherwise, raises an ArgumentError.
- *
- * Note that range operation may exhaust memory.
- * For example, <code>-1[0, 1000000000000]</code> will raise NoMemoryError.
- */
-
-static VALUE
-int_aref(int const argc, VALUE * const argv, VALUE const num)
-{
- rb_check_arity(argc, 1, 2);
- if (argc == 2) {
- return int_aref2(num, argv[0], argv[1]);
+ return rb_big_aref(num, idx);
}
- return int_aref1(num, argv[0]);
-
return Qnil;
}
@@ -5571,8 +5343,8 @@ Init_Numeric(void)
_set_Creg(0, 0);
#endif
id_coerce = rb_intern("coerce");
- id_to = rb_intern("to");
- id_by = rb_intern("by");
+ id_div = rb_intern("div");
+ id_divmod = rb_intern("divmod");
rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError);
rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError);
@@ -5673,7 +5445,7 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "&", rb_int_and, 1);
rb_define_method(rb_cInteger, "|", int_or, 1);
rb_define_method(rb_cInteger, "^", int_xor, 1);
- rb_define_method(rb_cInteger, "[]", int_aref, -1);
+ rb_define_method(rb_cInteger, "[]", int_aref, 1);
rb_define_method(rb_cInteger, "<<", rb_int_lshift, 1);
rb_define_method(rb_cInteger, ">>", rb_int_rshift, 1);
@@ -5685,7 +5457,6 @@ Init_Numeric(void)
#ifndef RUBY_INTEGER_UNIFICATION
rb_cFixnum = rb_cInteger;
#endif
- /* An obsolete class, use Integer */
rb_define_const(rb_cObject, "Fixnum", rb_cInteger);
rb_deprecate_constant(rb_cObject, "Fixnum");
@@ -5695,9 +5466,7 @@ Init_Numeric(void)
rb_undef_method(CLASS_OF(rb_cFloat), "new");
/*
- * Deprecated, do not use.
- *
- * Represents the rounding mode for floating point addition at the start time.
+ * Represents the rounding mode for floating point addition.
*
* Usually defaults to 1, rounding to the nearest number.
*
@@ -5710,7 +5479,6 @@ Init_Numeric(void)
* 3:: Rounding towards negative infinity
*/
rb_define_const(rb_cFloat, "ROUNDS", INT2FIX(FLT_ROUNDS));
- rb_deprecate_constant(rb_cFloat, "ROUNDS");
/*
* The base of the floating point, or number of unique digits used to
* represent the number.
@@ -5786,20 +5554,20 @@ Init_Numeric(void)
/*
* An expression representing positive infinity.
*/
- rb_define_const(rb_cFloat, "INFINITY", DBL2NUM(HUGE_VAL));
+ rb_define_const(rb_cFloat, "INFINITY", DBL2NUM(INFINITY));
/*
* An expression representing a value which is "not a number".
*/
- rb_define_const(rb_cFloat, "NAN", DBL2NUM(nan("")));
+ rb_define_const(rb_cFloat, "NAN", DBL2NUM(NAN));
rb_define_method(rb_cFloat, "to_s", flo_to_s, 0);
rb_define_alias(rb_cFloat, "inspect", "to_s");
rb_define_method(rb_cFloat, "coerce", flo_coerce, 1);
rb_define_method(rb_cFloat, "-@", rb_float_uminus, 0);
- rb_define_method(rb_cFloat, "+", rb_float_plus, 1);
- rb_define_method(rb_cFloat, "-", rb_float_minus, 1);
- rb_define_method(rb_cFloat, "*", rb_float_mul, 1);
- rb_define_method(rb_cFloat, "/", rb_float_div, 1);
+ rb_define_method(rb_cFloat, "+", flo_plus, 1);
+ rb_define_method(rb_cFloat, "-", flo_minus, 1);
+ rb_define_method(rb_cFloat, "*", flo_mul, 1);
+ rb_define_method(rb_cFloat, "/", flo_div, 1);
rb_define_method(rb_cFloat, "quo", flo_quo, 1);
rb_define_method(rb_cFloat, "fdiv", flo_quo, 1);
rb_define_method(rb_cFloat, "%", flo_mod, 1);
@@ -5834,6 +5602,9 @@ Init_Numeric(void)
rb_define_method(rb_cFloat, "prev_float", flo_prev_float, 0);
rb_define_method(rb_cFloat, "positive?", flo_positive_p, 0);
rb_define_method(rb_cFloat, "negative?", flo_negative_p, 0);
+
+ id_to = rb_intern("to");
+ id_by = rb_intern("by");
}
#undef rb_float_value
diff --git a/object.c b/object.c
index 61be0d3862..463be7bfb1 100644
--- a/object.c
+++ b/object.c
@@ -11,10 +11,9 @@
**********************************************************************/
-#include "ruby/encoding.h"
+#include "internal.h"
#include "ruby/st.h"
#include "ruby/util.h"
-#include "internal.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
@@ -40,10 +39,6 @@ VALUE rb_cNilClass; /*!< NilClass class */
VALUE rb_cTrueClass; /*!< TrueClass class */
VALUE rb_cFalseClass; /*!< FalseClass class */
-static VALUE rb_cNilClass_to_s;
-static VALUE rb_cTrueClass_to_s;
-static VALUE rb_cFalseClass_to_s;
-
/*! \cond INTERNAL_MACRO */
#define id_eq idEq
@@ -54,7 +49,6 @@ static VALUE rb_cFalseClass_to_s;
#define id_init_clone idInitialize_clone
#define id_init_dup idInitialize_dup
#define id_const_missing idConst_missing
-#define id_to_f idTo_f
#define CLASS_OR_MODULE_P(obj) \
(!SPECIAL_CONST_P(obj) && \
@@ -171,15 +165,15 @@ rb_eql(VALUE obj1, VALUE obj2)
* obj.equal?(other) -> true or false
* obj.eql?(other) -> true or false
*
- * Equality --- At the Object level, #== returns <code>true</code>
- * only if +obj+ and +other+ are the same object. Typically, this
- * method is overridden in descendant classes to provide
+ * Equality --- At the <code>Object</code> level, <code>==</code> returns
+ * <code>true</code> only if +obj+ and +other+ are the same object.
+ * Typically, this method is overridden in descendant classes to provide
* class-specific meaning.
*
- * Unlike #==, the #equal? method should never be overridden by
- * subclasses as it is used to determine object identity (that is,
- * <code>a.equal?(b)</code> if and only if <code>a</code> is the same
- * object as <code>b</code>):
+ * Unlike <code>==</code>, the <code>equal?</code> method should never be
+ * overridden by subclasses as it is used to determine object identity
+ * (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
+ * same object as <code>b</code>):
*
* obj = "a"
* other = obj.dup
@@ -188,17 +182,14 @@ rb_eql(VALUE obj1, VALUE obj2)
* obj.equal? other #=> false
* obj.equal? obj #=> true
*
- * The #eql? method returns <code>true</code> if +obj+ and +other+
- * refer to the same hash key. This is used by Hash to test members
- * for equality. For any pair of objects where #eql? returns +true+,
- * the #hash value of both objects must be equal. So any subclass
- * that overrides #eql? should also override #hash appropriately.
- *
- * For objects of class Object, #eql? is synonymous
- * with #==. Subclasses normally continue this tradition by aliasing
- * #eql? to their overridden #== method, but there are exceptions.
- * Numeric types, for example, perform type conversion across #==,
- * but not across #eql?, so:
+ * The <code>eql?</code> method returns <code>true</code> if +obj+ and
+ * +other+ refer to the same hash key. This is used by Hash to test members
+ * for equality. For objects of class <code>Object</code>, <code>eql?</code>
+ * is synonymous with <code>==</code>. Subclasses normally continue this
+ * tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
+ * method, but there are exceptions. <code>Numeric</code> types, for
+ * example, perform type conversion across <code>==</code>, but not across
+ * <code>eql?</code>, so:
*
* 1 == 1.0 #=> true
* 1.eql? 1.0 #=> false
@@ -206,7 +197,7 @@ rb_eql(VALUE obj1, VALUE obj2)
* \private
*++
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_obj_equal(VALUE obj1, VALUE obj2)
{
if (obj1 == obj2) return Qtrue;
@@ -225,7 +216,7 @@ VALUE rb_obj_hash(VALUE obj);
*++
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_obj_not(VALUE obj)
{
return RTEST(obj) ? Qfalse : Qtrue;
@@ -241,7 +232,7 @@ rb_obj_not(VALUE obj)
*++
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_obj_not_equal(VALUE obj1, VALUE obj2)
{
VALUE result = rb_funcall(obj1, id_eq, 1, obj2);
@@ -270,9 +261,9 @@ rb_class_real(VALUE cl)
* call-seq:
* obj.class -> class
*
- * Returns the class of <i>obj</i>. This method must always be called
- * with an explicit receiver, as #class is also a reserved word in
- * Ruby.
+ * Returns the class of <i>obj</i>. This method must always be
+ * called with an explicit receiver, as <code>class</code> is also a
+ * reserved word in Ruby.
*
* 1.class #=> Integer
* self.class #=> Object
@@ -312,7 +303,7 @@ rb_obj_singleton_class(VALUE obj)
}
/*! \private */
-MJIT_FUNC_EXPORTED void
+void
rb_obj_copy_ivar(VALUE dest, VALUE obj)
{
if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_IVPTR(dest)) {
@@ -346,7 +337,7 @@ init_copy(VALUE dest, VALUE obj)
rb_raise(rb_eTypeError, "[bug] frozen object (%s) allocated", rb_obj_classname(dest));
}
RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR);
- RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR);
+ RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR|FL_TAINT);
rb_copy_wb_protected_attribute(dest, obj);
rb_copy_generic_ivar(dest, obj);
rb_gc_copy_finalizer(dest, obj);
@@ -382,9 +373,9 @@ special_object_p(VALUE obj)
*
* Produces a shallow copy of <i>obj</i>---the instance variables of
* <i>obj</i> are copied, but not the objects they reference.
- * #clone copies the frozen (unless +:freeze+ keyword argument is
- * given with a false value) state of <i>obj</i>. See
- * also the discussion under Object#dup.
+ * <code>clone</code> copies the frozen (unless :freeze keyword argument
+ * is given with a false value) and tainted state of <i>obj</i>.
+ * See also the discussion under <code>Object#dup</code>.
*
* class Klass
* attr_accessor :str
@@ -455,6 +446,8 @@ mutable_obj_clone(VALUE obj, int kwfreeze)
VALUE clone, singleton;
clone = rb_obj_alloc(rb_obj_class(obj));
+ RBASIC(clone)->flags &= (FL_TAINT|FL_PROMOTED0|FL_PROMOTED1);
+ RBASIC(clone)->flags |= RBASIC(obj)->flags & ~(FL_PROMOTED0|FL_PROMOTED1|FL_FREEZE|FL_FINALIZE);
singleton = rb_singleton_class_clone_and_attach(obj, clone);
RBASIC_SET_CLASS(clone, singleton);
@@ -491,6 +484,7 @@ rb_obj_clone(VALUE obj)
*
* Produces a shallow copy of <i>obj</i>---the instance variables of
* <i>obj</i> are copied, but not the objects they reference.
+ * <code>dup</code> copies the tainted state of <i>obj</i>.
*
* This method may have class-specific behavior. If so, that
* behavior will be documented under the #+initialize_copy+ method of
@@ -498,10 +492,11 @@ rb_obj_clone(VALUE obj)
*
* === on dup vs clone
*
- * In general, #clone and #dup may have different semantics in
- * descendant classes. While #clone is used to duplicate an object,
- * including its internal state, #dup typically uses the class of the
- * descendant object to create the new instance.
+ * In general, <code>clone</code> and <code>dup</code> may have different
+ * semantics in descendant classes. While <code>clone</code> is used to
+ * duplicate an object, including its internal state, <code>dup</code>
+ * typically uses the class of the descendant object to create the new
+ * instance.
*
* When using #dup, any modules that the object has been extended with will not
* be copied.
@@ -567,31 +562,12 @@ rb_obj_size(VALUE self, VALUE args, VALUE obj)
/*
* call-seq:
- * obj.then {|x| block } -> an_object
* obj.yield_self {|x| block } -> an_object
*
* Yields self to the block and returns the result of the block.
*
- * 3.next.then {|x| x**x }.to_s #=> "256"
* "my string".yield_self {|s| s.upcase } #=> "MY STRING"
- *
- * Good usage for +then+ is value piping in method chains:
- *
- * require 'open-uri'
- * require 'json'
- *
- * construct_url(arguments).
- * then {|url| open(url).read }.
- * then {|response| JSON.parse(response) }
- *
- * When called without block, the method returns +Enumerator+,
- * which can be used, for example, for conditional
- * circuit-breaking:
- *
- * # meets condition, no-op
- * 1.then.detect(&:odd?) # => 1
- * # does not meet condition, drop value
- * 2.then.detect(&:odd?) # => nil
+ * 3.next.yield_self {|x| x**x }.to_s #=> "256"
*
*/
@@ -615,6 +591,7 @@ rb_obj_init_copy(VALUE obj, VALUE orig)
{
if (obj == orig) return obj;
rb_check_frozen(obj);
+ rb_check_trusted(obj);
if (TYPE(obj) != TYPE(orig) || rb_obj_class(obj) != rb_obj_class(orig)) {
rb_raise(rb_eTypeError, "initialize_copy should take same class object");
}
@@ -641,10 +618,10 @@ rb_obj_init_dup_clone(VALUE obj, VALUE orig)
* call-seq:
* obj.to_s -> string
*
- * Returns a string representing <i>obj</i>. The default #to_s prints
- * the object's class and an encoding of the object id. As a special
- * case, the top-level object that is the initial execution context
- * of Ruby programs returns ``main''.
+ * Returns a string representing <i>obj</i>. The default
+ * <code>to_s</code> prints the object's class and an encoding of the
+ * object id. As a special case, the top-level object that is the
+ * initial execution context of Ruby programs returns ``main''.
*
*--
* Default implementation of \c #to_s.
@@ -657,6 +634,7 @@ rb_any_to_s(VALUE obj)
VALUE cname = rb_class_name(CLASS_OF(obj));
str = rb_sprintf("#<%"PRIsVALUE":%p>", cname, (void*)obj);
+ OBJ_INFECT(str, obj);
return str;
}
@@ -725,6 +703,7 @@ inspect_obj(VALUE obj, VALUE str, int recur)
}
rb_str_cat2(str, ">");
RSTRING_PTR(str)[0] = '#';
+ OBJ_INFECT(str, obj);
return str;
}
@@ -734,12 +713,13 @@ inspect_obj(VALUE obj, VALUE str, int recur)
* obj.inspect -> string
*
* Returns a string containing a human-readable representation of <i>obj</i>.
- * The default #inspect shows the object's class name, an encoding of
- * the object id, and a list of the instance variables and their
- * values (by calling #inspect on each of them). User defined classes
- * should override this method to provide a better representation of
- * <i>obj</i>. When overriding this method, it should return a string
- * whose encoding is compatible with the default external encoding.
+ * The default <code>inspect</code> shows the object's class name,
+ * an encoding of the object id, and a list of the instance variables and
+ * their values (by calling #inspect on each of them).
+ * User defined classes should override this method to provide a better
+ * representation of <i>obj</i>. When overriding this method, it should
+ * return a string whose encoding is compatible with the default external
+ * encoding.
*
* [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
* Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
@@ -795,7 +775,7 @@ static VALUE class_search_ancestor(VALUE cl, VALUE c);
* obj.instance_of?(class) -> true or false
*
* Returns <code>true</code> if <i>obj</i> is an instance of the given
- * class. See also Object#kind_of?.
+ * class. See also <code>Object#kind_of?</code>.
*
* class A; end
* class B < A; end
@@ -1141,34 +1121,33 @@ rb_obj_tap(VALUE obj)
*/
static VALUE
-rb_obj_dummy()
+rb_obj_dummy(void)
{
return Qnil;
}
-static VALUE
-rb_obj_dummy0(VALUE _)
-{
- return rb_obj_dummy();
-}
-
-static VALUE
-rb_obj_dummy1(VALUE _x, VALUE _y)
-{
- return rb_obj_dummy();
-}
-
/**
* call-seq:
- * obj.tainted? -> false
+ * obj.tainted? -> true or false
+ *
+ * Returns true if the object is tainted.
*
- * Returns false. This method is deprecated and will be removed in Ruby 3.2.
+ * See #taint for more information.
+ *--
+ * Determines if \a obj is tainted. Equivalent to \c Object\#tainted? in Ruby.
+ * \param[in] obj the object to be determined
+ * \retval Qtrue if the object is tainted
+ * \retval Qfalse if the object is not tainted
+ * \sa rb_obj_taint
+ * \sa rb_obj_untaint
+ *++
*/
VALUE
rb_obj_tainted(VALUE obj)
{
- rb_warning("Object#tainted? is deprecated and will be removed in Ruby 3.2.");
+ if (OBJ_TAINTED(obj))
+ return Qtrue;
return Qfalse;
}
@@ -1176,13 +1155,33 @@ rb_obj_tainted(VALUE obj)
* call-seq:
* obj.taint -> obj
*
- * Returns object. This method is deprecated and will be removed in Ruby 3.2.
+ * Mark the object as tainted.
+ *
+ * Objects that are marked as tainted will be restricted from various built-in
+ * methods. This is to prevent insecure data, such as command-line arguments
+ * or strings read from Kernel#gets, from inadvertently compromising the user's
+ * system.
+ *
+ * To check whether an object is tainted, use #tainted?.
+ *
+ * You should only untaint a tainted object if your code has inspected it and
+ * determined that it is safe. To do so use #untaint.
+ *--
+ * Marks the object as tainted. Equivalent to \c Object\#taint in Ruby
+ * \param[in] obj the object to be tainted
+ * \return the object itself
+ * \sa rb_obj_untaint
+ * \sa rb_obj_tainted
+ *++
*/
VALUE
rb_obj_taint(VALUE obj)
{
- rb_warning("Object#taint is deprecated and will be removed in Ruby 3.2.");
+ if (!OBJ_TAINTED(obj) && OBJ_TAINTABLE(obj)) {
+ rb_check_frozen(obj);
+ OBJ_TAINT(obj);
+ }
return obj;
}
@@ -1191,42 +1190,74 @@ rb_obj_taint(VALUE obj)
* call-seq:
* obj.untaint -> obj
*
- * Returns object. This method is deprecated and will be removed in Ruby 3.2.
+ * Removes the tainted mark from the object.
+ *
+ * See #taint for more information.
+ *--
+ * Removes the tainted mark from the object.
+ * Equivalent to \c Object\#untaint in Ruby.
+ *
+ * \param[in] obj the object to be tainted
+ * \return the object itself
+ * \sa rb_obj_taint
+ * \sa rb_obj_tainted
+ *++
*/
VALUE
rb_obj_untaint(VALUE obj)
{
- rb_warning("Object#untaint is deprecated and will be removed in Ruby 3.2.");
+ if (OBJ_TAINTED(obj)) {
+ rb_check_frozen(obj);
+ FL_UNSET(obj, FL_TAINT);
+ }
return obj;
}
/**
* call-seq:
- * obj.untrusted? -> false
+ * obj.untrusted? -> true or false
+ *
+ * Deprecated method that is equivalent to #tainted?.
+ *--
+ * \deprecated Use rb_obj_tainted.
*
- * Returns false. This method is deprecated and will be removed in Ruby 3.2.
+ * Trustiness used to have independent semantics from taintedness.
+ * But now trustiness of objects is obsolete and this function behaves
+ * the same as rb_obj_tainted.
+ *
+ * \sa rb_obj_tainted
+ *++
*/
VALUE
rb_obj_untrusted(VALUE obj)
{
- rb_warning("Object#untrusted? is deprecated and will be removed in Ruby 3.2.");
- return Qfalse;
+ rb_warning("untrusted? is deprecated and its behavior is same as tainted?");
+ return rb_obj_tainted(obj);
}
/**
* call-seq:
* obj.untrust -> obj
*
- * Returns object. This method is deprecated and will be removed in Ruby 3.2.
+ * Deprecated method that is equivalent to #taint.
+ *--
+ * \deprecated Use rb_obj_taint(obj)
+ *
+ * Trustiness used to have independent semantics from taintedness.
+ * But now trustiness of objects is obsolete and this function behaves
+ * the same as rb_obj_taint.
+ *
+ * \sa rb_obj_taint
+ *++
*/
VALUE
rb_obj_untrust(VALUE obj)
{
- rb_warning("Object#untrust is deprecated and will be removed in Ruby 3.2.");
- return obj;
+ rb_warning("untrust is deprecated and its behavior is same as taint");
+ return rb_obj_taint(obj);
}
@@ -1234,24 +1265,37 @@ rb_obj_untrust(VALUE obj)
* call-seq:
* obj.trust -> obj
*
- * Returns object. This method is deprecated and will be removed in Ruby 3.2.
+ * Deprecated method that is equivalent to #untaint.
+ *--
+ * \deprecated Use rb_obj_untaint(obj)
+ *
+ * Trustiness used to have independent semantics from taintedness.
+ * But now trustiness of objects is obsolete and this function behaves
+ * the same as rb_obj_untaint.
+ *
+ * \sa rb_obj_untaint
+ *++
*/
VALUE
rb_obj_trust(VALUE obj)
{
- rb_warning("Object#trust is deprecated and will be removed in Ruby 3.2.");
- return obj;
+ rb_warning("trust is deprecated and its behavior is same as untaint");
+ return rb_obj_untaint(obj);
}
/**
- * Does nothing. This method is deprecated and will be removed in Ruby 3.2.
+ * Convenient function to infect \a victim with the taintedness of \a carrier.
+ *
+ * It just keeps the taintedness of \a victim if \a carrier is not tainted.
+ * \param[in,out] victim the object being infected with the taintness of \a carrier
+ * \param[in] carrier a possibly tainted object
*/
void
rb_obj_infect(VALUE victim, VALUE carrier)
{
- rb_warning("rb_obj_infect is deprecated and will be removed in Ruby 3.2.");
+ OBJ_INFECT(victim, carrier);
}
/**
@@ -1259,9 +1303,9 @@ rb_obj_infect(VALUE victim, VALUE carrier)
* obj.freeze -> obj
*
* Prevents further modifications to <i>obj</i>. A
- * RuntimeError will be raised if modification is attempted.
+ * <code>RuntimeError</code> will be raised if modification is attempted.
* There is no way to unfreeze a frozen object. See also
- * Object#frozen?.
+ * <code>Object#frozen?</code>.
*
* This method returns self.
*
@@ -1366,7 +1410,7 @@ nil_to_f(VALUE obj)
static VALUE
nil_to_s(VALUE obj)
{
- return rb_cNilClass_to_s;
+ return rb_usascii_str_new(0, 0);
}
/*
@@ -1416,24 +1460,11 @@ nil_inspect(VALUE obj)
return rb_usascii_str_new2("nil");
}
-/*
- * call-seq:
- * nil =~ other -> nil
- *
- * Dummy pattern matching -- always returns nil.
- */
-
-static VALUE
-nil_match(VALUE obj1, VALUE obj2)
-{
- return Qnil;
-}
-
/***********************************************************************
* Document-class: TrueClass
*
* The global value <code>true</code> is the only instance of class
- * TrueClass and represents a logically true value in
+ * <code>TrueClass</code> and represents a logically true value in
* boolean expressions. The class provides operators allowing
* <code>true</code> to be used in logical expressions.
*/
@@ -1449,7 +1480,7 @@ nil_match(VALUE obj1, VALUE obj2)
static VALUE
true_to_s(VALUE obj)
{
- return rb_cTrueClass_to_s;
+ return rb_usascii_str_new2("true");
}
@@ -1510,7 +1541,7 @@ true_xor(VALUE obj, VALUE obj2)
* Document-class: FalseClass
*
* The global value <code>false</code> is the only instance of class
- * FalseClass and represents a logically false value in
+ * <code>FalseClass</code> and represents a logically false value in
* boolean expressions. The class provides operators allowing
* <code>false</code> to participate correctly in logical expressions.
*
@@ -1526,7 +1557,7 @@ true_xor(VALUE obj, VALUE obj2)
static VALUE
false_to_s(VALUE obj)
{
- return rb_cFalseClass_to_s;
+ return rb_usascii_str_new2("false");
}
/*
@@ -1604,7 +1635,7 @@ rb_true(VALUE obj)
*/
-MJIT_FUNC_EXPORTED VALUE
+static VALUE
rb_false(VALUE obj)
{
return Qfalse;
@@ -1615,19 +1646,14 @@ rb_false(VALUE obj)
* call-seq:
* obj =~ other -> nil
*
- * This method is deprecated.
- *
- * This is not only unuseful but also troublesome because it
- * may hide a type error.
+ * Pattern Match---Overridden by descendants (notably
+ * <code>Regexp</code> and <code>String</code>) to provide meaningful
+ * pattern-match semantics.
*/
static VALUE
rb_obj_match(VALUE obj1, VALUE obj2)
{
- if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) {
- rb_warn("deprecated Object#=~ is called on %"PRIsVALUE
- "; it always returns nil", rb_obj_class(obj1));
- }
return Qnil;
}
@@ -1654,16 +1680,16 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
* Returns 0 if +obj+ and +other+ are the same object
* or <code>obj == other</code>, otherwise nil.
*
- * The #<=> is used by various methods to compare objects, for example
+ * The <code><=></code> is used by various methods to compare objects, for example
* Enumerable#sort, Enumerable#max etc.
*
- * Your implementation of #<=> should return one of the following values: -1, 0,
+ * Your implementation of <code><=></code> should return one of the following values: -1, 0,
* 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
* 1 means self is bigger than other. Nil means the two values could not be
* compared.
*
- * When you define #<=>, you can include Comparable to gain the
- * methods #<=, #<, #==, #>=, #> and #between?.
+ * When you define <code><=></code>, you can include Comparable to gain the methods
+ * <code><=</code>, <code><</code>, <code>==</code>, <code>>=</code>, <code>></code> and <code>between?</code>.
*/
static VALUE
rb_obj_cmp(VALUE obj1, VALUE obj2)
@@ -1677,16 +1703,16 @@ rb_obj_cmp(VALUE obj1, VALUE obj2)
*
* Document-class: Module
*
- * A Module is a collection of methods and constants. The
+ * A <code>Module</code> is a collection of methods and constants. The
* methods in a module may be instance methods or module methods.
* Instance methods appear as methods in a class when the module is
* included, module methods do not. Conversely, module methods may be
* called without creating an encapsulating object, while instance
- * methods may not. (See Module#module_function.)
+ * methods may not. (See <code>Module#module_function</code>.)
*
* In the descriptions that follow, the parameter <i>sym</i> refers
* to a symbol, which is either a quoted string or a
- * Symbol (such as <code>:name</code>).
+ * <code>Symbol</code> (such as <code>:name</code>).
*
* module Mod
* include Math
@@ -1742,7 +1768,7 @@ rb_mod_to_s(VALUE klass)
rb_str_cat2(s, ">");
return s;
}
- return rb_class_name(klass);
+ return rb_str_dup(rb_class_name(klass));
}
/*
@@ -1925,7 +1951,7 @@ rb_class_s_alloc(VALUE klass)
*
* Creates a new anonymous module. If a block is given, it is passed
* the module object, and the block is evaluated in the context of this
- * module like #module_eval.
+ * module like <code>module_eval</code>.
*
* fred = Module.new do
* def meth1
@@ -1970,12 +1996,12 @@ rb_mod_initialize_clone(VALUE clone, VALUE orig)
* Class.new(super_class=Object) { |mod| ... } -> a_class
*
* Creates a new anonymous (unnamed) class with the given superclass
- * (or Object if no parameter is given). You can give a
+ * (or <code>Object</code> if no parameter is given). You can give a
* class a name by assigning the class object to a constant.
*
* If a block is given, it is passed the class object, and the block
* is evaluated in the context of this class like
- * #class_eval.
+ * <code>class_eval</code>.
*
* fred = Class.new do
* def meth1
@@ -2002,11 +2028,11 @@ rb_class_initialize(int argc, VALUE *argv, VALUE klass)
if (RCLASS_SUPER(klass) != 0 || klass == rb_cBasicObject) {
rb_raise(rb_eTypeError, "already initialized class");
}
- if (rb_check_arity(argc, 0, 1) == 0) {
+ if (argc == 0) {
super = rb_cObject;
}
else {
- super = argv[0];
+ rb_scan_args(argc, argv, "01", &super);
rb_check_inheritable(super);
if (super != rb_cBasicObject && !RCLASS_SUPER(super)) {
rb_raise(rb_eTypeError, "can't inherit uninitialized class");
@@ -2028,9 +2054,6 @@ rb_undefined_alloc(VALUE klass)
klass);
}
-static rb_alloc_func_t class_get_alloc_func(VALUE klass);
-static VALUE class_call_alloc_func(rb_alloc_func_t allocator, VALUE klass);
-
/*
* call-seq:
* class.allocate() -> obj
@@ -2054,26 +2077,9 @@ static VALUE class_call_alloc_func(rb_alloc_func_t allocator, VALUE klass);
*/
static VALUE
-rb_class_alloc_m(VALUE klass)
-{
- rb_alloc_func_t allocator = class_get_alloc_func(klass);
- if (!rb_obj_respond_to(klass, rb_intern("allocate"), 1)) {
- rb_raise(rb_eTypeError, "calling %"PRIsVALUE".allocate is prohibited",
- klass);
- }
- return class_call_alloc_func(allocator, klass);
-}
-
-static VALUE
rb_class_alloc(VALUE klass)
{
- rb_alloc_func_t allocator = class_get_alloc_func(klass);
- return class_call_alloc_func(allocator, klass);
-}
-
-static rb_alloc_func_t
-class_get_alloc_func(VALUE klass)
-{
+ VALUE obj;
rb_alloc_func_t allocator;
if (RCLASS_SUPER(klass) == 0 && klass != rb_cBasicObject) {
@@ -2086,13 +2092,6 @@ class_get_alloc_func(VALUE klass)
if (!allocator) {
rb_undefined_alloc(klass);
}
- return allocator;
-}
-
-static VALUE
-class_call_alloc_func(rb_alloc_func_t allocator, VALUE klass)
-{
- VALUE obj;
RUBY_DTRACE_CREATE_HOOK(OBJECT, rb_class2name(klass));
@@ -2136,10 +2135,11 @@ rb_class_allocate_instance(VALUE klass)
* call-seq:
* class.new(args, ...) -> obj
*
- * Calls #allocate to create a new object of <i>class</i>'s class,
- * then invokes that object's #initialize method, passing it
- * <i>args</i>. This is the method that ends up getting called
- * whenever an object is constructed using <code>.new</code>.
+ * Calls <code>allocate</code> to create a new object of
+ * <i>class</i>'s class, then invokes that object's
+ * <code>initialize</code> method, passing it <i>args</i>.
+ * This is the method that ends up getting called whenever
+ * an object is constructed using .new.
*
*/
@@ -2149,19 +2149,7 @@ rb_class_s_new(int argc, const VALUE *argv, VALUE klass)
VALUE obj;
obj = rb_class_alloc(klass);
- rb_obj_call_init_kw(obj, argc, argv, RB_PASS_CALLED_KEYWORDS);
-
- return obj;
-}
-
-VALUE
-rb_class_new_instance_kw(int argc, const VALUE *argv, VALUE klass, int kw_splat)
-{
- VALUE obj;
- Check_Type(klass, T_CLASS);
-
- obj = rb_class_alloc(klass);
- rb_obj_call_init_kw(obj, argc, argv, kw_splat);
+ rb_obj_call_init(obj, argc, argv);
return obj;
}
@@ -2181,13 +2169,8 @@ rb_class_new_instance_kw(int argc, const VALUE *argv, VALUE klass, int kw_splat)
VALUE
rb_class_new_instance(int argc, const VALUE *argv, VALUE klass)
{
- VALUE obj;
Check_Type(klass, T_CLASS);
-
- obj = rb_class_alloc(klass);
- rb_obj_call_init_kw(obj, argc, argv, RB_NO_KEYWORDS);
-
- return obj;
+ return rb_class_s_new(argc, argv, klass);
}
/**
@@ -2248,14 +2231,9 @@ rb_class_get_superclass(VALUE klass)
return RCLASS(klass)->super;
}
-static const char bad_instance_name[] = "`%1$s' is not allowed as an instance variable name";
-static const char bad_class_name[] = "`%1$s' is not allowed as a class variable name";
-static const char bad_const_name[] = "wrong constant name %1$s";
-static const char bad_attr_name[] = "invalid attribute name `%1$s'";
-#define wrong_constant_name bad_const_name
-
/*! \private */
-#define id_for_var(obj, name, type) id_for_setter(obj, name, type, bad_##type##_name)
+#define id_for_var(obj, name, part, type) \
+ id_for_setter(obj, name, type, "`%1$s' is not allowed as "#part" "#type" variable name")
/*! \private */
#define id_for_setter(obj, name, type, message) \
check_setter_id(obj, &(name), rb_is_##type##_id, rb_is_##type##_name, message, strlen(message))
@@ -2286,10 +2264,13 @@ rb_is_attr_id(ID id)
return rb_is_local_id(id) || rb_is_const_id(id);
}
+static const char wrong_constant_name[] = "wrong constant name %1$s";
+static const char invalid_attribute_name[] = "invalid attribute name `%1$s'";
+
static ID
id_for_attr(VALUE obj, VALUE name)
{
- ID id = id_for_var(obj, name, attr);
+ ID id = id_for_setter(obj, name, attr, invalid_attribute_name);
if (!id) id = rb_intern_str(name);
return id;
}
@@ -2324,7 +2305,7 @@ rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
* attr(name, true) -> nil
* attr(name, false) -> nil
*
- * The first form is equivalent to #attr_reader.
+ * The first form is equivalent to <code>attr_reader</code>.
* The second form is equivalent to <code>attr_accessor(name)</code> but deprecated.
* The last form is equivalent to <code>attr_reader(name)</code> but deprecated.
*--
@@ -2497,7 +2478,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
if (!id) {
part = rb_str_subseq(name, beglen, len);
OBJ_FREEZE(part);
- if (!rb_is_const_name(part)) {
+ if (!ISUPPER(*pbeg) || !rb_is_const_name(part)) {
name = part;
goto wrong_name;
}
@@ -2514,19 +2495,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
name = ID2SYM(id);
goto wrong_name;
}
-#if 0
- mod = rb_const_get_0(mod, id, beglen > 0 || !RTEST(recur), RTEST(recur), FALSE);
-#else
- if (!RTEST(recur)) {
- mod = rb_const_get_at(mod, id);
- }
- else if (beglen == 0) {
- mod = rb_const_get(mod, id);
- }
- else {
- mod = rb_const_get_from(mod, id);
- }
-#endif
+ mod = RTEST(recur) ? rb_const_get(mod, id) : rb_const_get_at(mod, id);
}
return mod;
@@ -2554,7 +2523,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
static VALUE
rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
{
- ID id = id_for_var(mod, name, const);
+ ID id = id_for_setter(mod, name, const, wrong_constant_name);
if (!id) id = rb_intern_str(name);
rb_const_set(mod, id, value);
@@ -2662,7 +2631,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
if (!id) {
part = rb_str_subseq(name, beglen, len);
OBJ_FREEZE(part);
- if (!rb_is_const_name(part)) {
+ if (!ISUPPER(*pbeg) || !rb_is_const_name(part)) {
name = part;
goto wrong_name;
}
@@ -2674,30 +2643,17 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
name = ID2SYM(id);
goto wrong_name;
}
-
-#if 0
- mod = rb_const_search(mod, id, beglen > 0 || !RTEST(recur), RTEST(recur), FALSE);
- if (mod == Qundef) return Qfalse;
-#else
- if (!RTEST(recur)) {
+ if (RTEST(recur)) {
+ if (!rb_const_defined(mod, id))
+ return Qfalse;
+ mod = rb_const_get(mod, id);
+ }
+ else {
if (!rb_const_defined_at(mod, id))
return Qfalse;
- if (p == pend) return Qtrue;
mod = rb_const_get_at(mod, id);
}
- else if (beglen == 0) {
- if (!rb_const_defined(mod, id))
- return Qfalse;
- if (p == pend) return Qtrue;
- mod = rb_const_get(mod, id);
- }
- else {
- if (!rb_const_defined_from(mod, id))
- return Qfalse;
- if (p == pend) return Qtrue;
- mod = rb_const_get_from(mod, id);
- }
-#endif
+ recur = Qfalse;
if (p < pend && !RB_TYPE_P(mod, T_MODULE) && !RB_TYPE_P(mod, T_CLASS)) {
rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module",
@@ -2710,159 +2666,13 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
/*
* call-seq:
- * mod.const_source_location(sym, inherit=true) -> [String, Integer]
- * mod.const_source_location(str, inherit=true) -> [String, Integer]
- *
- * Returns the Ruby source filename and line number containing first definition
- * of constant specified. If the named constant is not found, +nil+ is returned.
- * If the constant is found, but its source location can not be extracted
- * (constant is defined in C code), empty array is returned.
- *
- * _inherit_ specifies whether to lookup in <code>mod.ancestors</code> (+true+
- * by default).
- *
- * # test.rb:
- * class A
- * C1 = 1
- * end
- *
- * module M
- * C2 = 2
- * end
- *
- * class B < A
- * include M
- * C3 = 3
- * end
- *
- * class A # continuation of A definition
- * end
- *
- * p B.const_source_location('C3') # => ["test.rb", 11]
- * p B.const_source_location('C2') # => ["test.rb", 6]
- * p B.const_source_location('C1') # => ["test.rb", 2]
- *
- * p B.const_source_location('C2', false) # => nil -- don't lookup in ancestors
- *
- * p Object.const_source_location('B') # => ["test.rb", 9]
- * p Object.const_source_location('A') # => ["test.rb", 1] -- note it is first entry, not "continuation"
- *
- * p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors
- * p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules
- *
- * p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported
- * p Object.const_source_location('String') # => [] -- constant is defined in C code
- *
- *
- */
-static VALUE
-rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod)
-{
- VALUE name, recur, loc = Qnil;
- rb_encoding *enc;
- const char *pbeg, *p, *path, *pend;
- ID id;
-
- rb_check_arity(argc, 1, 2);
- name = argv[0];
- recur = (argc == 1) ? Qtrue : argv[1];
-
- if (SYMBOL_P(name)) {
- if (!rb_is_const_sym(name)) goto wrong_name;
- id = rb_check_id(&name);
- if (!id) return Qnil;
- return RTEST(recur) ? rb_const_source_location(mod, id) : rb_const_source_location_at(mod, id);
- }
-
- path = StringValuePtr(name);
- enc = rb_enc_get(name);
-
- if (!rb_enc_asciicompat(enc)) {
- rb_raise(rb_eArgError, "invalid class path encoding (non ASCII)");
- }
-
- pbeg = p = path;
- pend = path + RSTRING_LEN(name);
-
- if (p >= pend || !*p) {
- wrong_name:
- rb_name_err_raise(wrong_constant_name, mod, name);
- }
-
- if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
- mod = rb_cObject;
- p += 2;
- pbeg = p;
- }
-
- while (p < pend) {
- VALUE part;
- long len, beglen;
-
- while (p < pend && *p != ':') p++;
-
- if (pbeg == p) goto wrong_name;
-
- id = rb_check_id_cstr(pbeg, len = p-pbeg, enc);
- beglen = pbeg-path;
-
- if (p < pend && p[0] == ':') {
- if (p + 2 >= pend || p[1] != ':') goto wrong_name;
- p += 2;
- pbeg = p;
- }
-
- if (!id) {
- part = rb_str_subseq(name, beglen, len);
- OBJ_FREEZE(part);
- if (!rb_is_const_name(part)) {
- name = part;
- goto wrong_name;
- }
- else {
- return Qnil;
- }
- }
- if (!rb_is_const_id(id)) {
- name = ID2SYM(id);
- goto wrong_name;
- }
- if (p < pend) {
- if (RTEST(recur)) {
- mod = rb_const_get(mod, id);
- }
- else {
- mod = rb_const_get_at(mod, id);
- }
- if (!RB_TYPE_P(mod, T_MODULE) && !RB_TYPE_P(mod, T_CLASS)) {
- rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module",
- QUOTE(name));
- }
- }
- else {
- if (RTEST(recur)) {
- loc = rb_const_source_location(mod, id);
- }
- else {
- loc = rb_const_source_location_at(mod, id);
- }
- break;
- }
- recur = Qfalse;
- }
-
- return loc;
-}
-
-/*
- * call-seq:
* obj.instance_variable_get(symbol) -> obj
* obj.instance_variable_get(string) -> obj
*
* Returns the value of the given instance variable, or nil if the
* instance variable is not set. The <code>@</code> part of the
* variable name should be included for regular instance
- * variables. Throws a NameError exception if the
+ * variables. Throws a <code>NameError</code> exception if the
* supplied symbol is not valid as an instance variable name.
* String arguments are converted to symbols.
*
@@ -2879,7 +2689,7 @@ rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod)
static VALUE
rb_obj_ivar_get(VALUE obj, VALUE iv)
{
- ID id = id_for_var(obj, iv, instance);
+ ID id = id_for_var(obj, iv, an, instance);
if (!id) {
return Qnil;
@@ -2913,7 +2723,7 @@ rb_obj_ivar_get(VALUE obj, VALUE iv)
static VALUE
rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
{
- ID id = id_for_var(obj, iv, instance);
+ ID id = id_for_var(obj, iv, an, instance);
if (!id) id = rb_intern_str(iv);
return rb_ivar_set(obj, id, val);
}
@@ -2941,7 +2751,7 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
static VALUE
rb_obj_ivar_defined(VALUE obj, VALUE iv)
{
- ID id = id_for_var(obj, iv, instance);
+ ID id = id_for_var(obj, iv, an, instance);
if (!id) {
return Qfalse;
@@ -2955,7 +2765,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
* mod.class_variable_get(string) -> obj
*
* Returns the value of the given class variable (or throws a
- * NameError exception). The <code>@@</code> part of the
+ * <code>NameError</code> exception). The <code>@@</code> part of the
* variable name should be included for regular class variables.
* String arguments are converted to symbols.
*
@@ -2968,7 +2778,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
static VALUE
rb_mod_cvar_get(VALUE obj, VALUE iv)
{
- ID id = id_for_var(obj, iv, class);
+ ID id = id_for_var(obj, iv, a, class);
if (!id) {
rb_name_err_raise("uninitialized class variable %1$s in %2$s",
@@ -3000,7 +2810,7 @@ rb_mod_cvar_get(VALUE obj, VALUE iv)
static VALUE
rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
{
- ID id = id_for_var(obj, iv, class);
+ ID id = id_for_var(obj, iv, a, class);
if (!id) id = rb_intern_str(iv);
rb_cvar_set(obj, id, val);
return val;
@@ -3025,7 +2835,7 @@ rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
static VALUE
rb_mod_cvar_defined(VALUE obj, VALUE iv)
{
- ID id = id_for_var(obj, iv, class);
+ ID id = id_for_var(obj, iv, a, class);
if (!id) {
return Qfalse;
@@ -3208,7 +3018,7 @@ rb_check_convert_type(VALUE val, int type, const char *tname, const char *method
}
/*! \private */
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_check_convert_type_with_id(VALUE val, int type, const char *tname, ID method)
{
VALUE v;
@@ -3223,19 +3033,17 @@ rb_check_convert_type_with_id(VALUE val, int type, const char *tname, ID method)
return v;
}
-#define try_to_int(val, mid, raise) \
- convert_type_with_id(val, "Integer", mid, raise, -1)
-ALWAYS_INLINE(static VALUE rb_to_integer(VALUE val, const char *method, ID mid));
-static inline VALUE
-rb_to_integer(VALUE val, const char *method, ID mid)
+static VALUE
+rb_to_integer(VALUE val, const char *method)
{
VALUE v;
- if (RB_INTEGER_TYPE_P(val)) return val;
- v = try_to_int(val, mid, TRUE);
- if (!RB_INTEGER_TYPE_P(v)) {
- conversion_mismatch(val, "Integer", method, v);
+ if (FIXNUM_P(val)) return val;
+ if (RB_TYPE_P(val, T_BIGNUM)) return val;
+ v = convert_type(val, "Integer", method, TRUE);
+ if (!rb_obj_is_kind_of(v, rb_cInteger)) {
+ conversion_mismatch(val, "Integer", method, v);
}
return v;
}
@@ -3258,8 +3066,8 @@ rb_check_to_integer(VALUE val, const char *method)
if (FIXNUM_P(val)) return val;
if (RB_TYPE_P(val, T_BIGNUM)) return val;
v = convert_type(val, "Integer", method, FALSE);
- if (!RB_INTEGER_TYPE_P(v)) {
- return Qnil;
+ if (!rb_obj_is_kind_of(v, rb_cInteger)) {
+ return Qnil;
}
return v;
}
@@ -3275,7 +3083,7 @@ rb_check_to_integer(VALUE val, const char *method)
VALUE
rb_to_int(VALUE val)
{
- return rb_to_integer(val, "to_int", idTo_int);
+ return rb_to_integer(val, "to_int");
}
/**
@@ -3290,65 +3098,44 @@ rb_to_int(VALUE val)
VALUE
rb_check_to_int(VALUE val)
{
- if (RB_INTEGER_TYPE_P(val)) return val;
- val = try_to_int(val, idTo_int, FALSE);
- if (RB_INTEGER_TYPE_P(val)) return val;
- return Qnil;
+ return rb_check_to_integer(val, "to_int");
}
static VALUE
-rb_check_to_i(VALUE val)
-{
- if (RB_INTEGER_TYPE_P(val)) return val;
- val = try_to_int(val, idTo_i, FALSE);
- if (RB_INTEGER_TYPE_P(val)) return val;
- return Qnil;
-}
-
-static VALUE
-rb_convert_to_integer(VALUE val, int base, int raise_exception)
+rb_convert_to_integer(VALUE val, int base)
{
VALUE tmp;
if (RB_FLOAT_TYPE_P(val)) {
- double f;
- if (base != 0) goto arg_error;
- f = RFLOAT_VALUE(val);
- if (!raise_exception && !isfinite(f)) return Qnil;
- if (FIXABLE(f)) return LONG2FIX((long)f);
- return rb_dbl2big(f);
+ double f;
+ if (base != 0) goto arg_error;
+ f = RFLOAT_VALUE(val);
+ if (FIXABLE(f)) return LONG2FIX((long)f);
+ return rb_dbl2big(f);
}
else if (RB_INTEGER_TYPE_P(val)) {
- if (base != 0) goto arg_error;
- return val;
+ if (base != 0) goto arg_error;
+ return val;
}
else if (RB_TYPE_P(val, T_STRING)) {
- return rb_str_convert_to_inum(val, base, TRUE, raise_exception);
+ return rb_str_to_inum(val, base, TRUE);
}
else if (NIL_P(val)) {
- if (base != 0) goto arg_error;
- if (!raise_exception) return Qnil;
- rb_raise(rb_eTypeError, "can't convert nil into Integer");
+ if (base != 0) goto arg_error;
+ rb_raise(rb_eTypeError, "can't convert nil into Integer");
}
if (base != 0) {
- tmp = rb_check_string_type(val);
- if (!NIL_P(tmp)) return rb_str_convert_to_inum(tmp, base, TRUE, raise_exception);
+ tmp = rb_check_string_type(val);
+ if (!NIL_P(tmp)) return rb_str_to_inum(tmp, base, TRUE);
arg_error:
- if (!raise_exception) return Qnil;
- rb_raise(rb_eArgError, "base specified for non string value");
+ rb_raise(rb_eArgError, "base specified for non string value");
}
-
- tmp = rb_protect(rb_check_to_int, val, NULL);
- if (RB_INTEGER_TYPE_P(tmp)) return tmp;
- rb_set_errinfo(Qnil);
-
- if (!raise_exception) {
- VALUE result = rb_protect(rb_check_to_i, val, NULL);
- rb_set_errinfo(Qnil);
- return result;
+ tmp = convert_type(val, "Integer", "to_int", FALSE);
+ if (NIL_P(tmp)) {
+ return rb_to_integer(val, "to_i");
}
+ return tmp;
- return rb_to_integer(val, "to_i", idTo_i);
}
/**
@@ -3360,95 +3147,65 @@ rb_convert_to_integer(VALUE val, int base, int raise_exception)
VALUE
rb_Integer(VALUE val)
{
- return rb_convert_to_integer(val, 0, TRUE);
-}
-
-int
-rb_bool_expected(VALUE obj, const char *flagname)
-{
- switch (obj) {
- case Qtrue: case Qfalse:
- break;
- default:
- rb_raise(rb_eArgError, "true or false is expected as %s: %+"PRIsVALUE,
- flagname, obj);
- }
- return obj != Qfalse;
-}
-
-int
-rb_opts_exception_p(VALUE opts, int default_value)
-{
- static ID kwds[1] = {idException};
- VALUE exception;
- if (rb_get_kwargs(opts, kwds, 0, 1, &exception))
- return rb_bool_expected(exception, "exception");
- return default_value;
+ return rb_convert_to_integer(val, 0);
}
-#define opts_exception_p(opts) rb_opts_exception_p((opts), TRUE)
-
/*
* call-seq:
- * Integer(arg, base=0, exception: true) -> integer or nil
+ * Integer(arg, base=0) -> integer
*
- * Converts <i>arg</i> to an Integer.
+ * Converts <i>arg</i> to an <code>Integer</code>.
* Numeric types are converted directly (with floating point numbers
* being truncated). <i>base</i> (0, or between 2 and 36) is a base for
- * integer string representation. If <i>arg</i> is a String,
+ * integer string representation. If <i>arg</i> is a <code>String</code>,
* when <i>base</i> is omitted or equals zero, radix indicators
* (<code>0</code>, <code>0b</code>, and <code>0x</code>) are honored.
* In any case, strings should be strictly conformed to numeric
* representation. This behavior is different from that of
- * String#to_i. Non string values will be converted by first
- * trying <code>to_int</code>, then <code>to_i</code>.
- *
- * Passing <code>nil</code> raises a TypeError, while passing a String that
- * does not conform with numeric representation raises an ArgumentError.
- * This behavior can be altered by passing <code>exception: false</code>,
- * in this case a not convertible value will return <code>nil</code>.
+ * <code>String#to_i</code>. Non string values will be converted by first
+ * trying <code>to_int</code>, then <code>to_i</code>. Passing <code>nil</code>
+ * raises a TypeError.
*
* Integer(123.999) #=> 123
* Integer("0x1a") #=> 26
* Integer(Time.new) #=> 1204973019
* Integer("0930", 10) #=> 930
* Integer("111", 2) #=> 7
- * Integer(nil) #=> TypeError: can't convert nil into Integer
- * Integer("x") #=> ArgumentError: invalid value for Integer(): "x"
- *
- * Integer("x", exception: false) #=> nil
- *
+ * Integer(nil) #=> TypeError
*/
static VALUE
rb_f_integer(int argc, VALUE *argv, VALUE obj)
{
- VALUE arg = Qnil, opts = Qnil;
+ VALUE arg = Qnil;
int base = 0;
- if (argc > 1) {
- int narg = 1;
- VALUE vbase = rb_check_to_int(argv[1]);
- if (!NIL_P(vbase)) {
- base = NUM2INT(vbase);
- narg = 2;
- }
- if (argc > narg) {
- VALUE hash = rb_check_hash_type(argv[argc-1]);
- if (!NIL_P(hash)) {
- opts = rb_extract_keywords(&hash);
- if (!hash) --argc;
- }
- }
+ switch (argc) {
+ case 2:
+ base = NUM2INT(argv[1]);
+ case 1:
+ arg = argv[0];
+ break;
+ default:
+ /* should cause ArgumentError */
+ rb_scan_args(argc, argv, "11", NULL, NULL);
}
- rb_check_arity(argc, 1, 2);
- arg = argv[0];
-
- return rb_convert_to_integer(arg, base, opts_exception_p(opts));
+ return rb_convert_to_integer(arg, base);
}
-static double
-rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
+/*!
+ * Parses a string representation of a floating point number.
+ *
+ * \param[in] p a string representation of a floating number
+ * \param[in] badcheck raises an exception on parse error if \a badcheck is non-zero.
+ * \return the floating point number in the string on success,
+ * 0.0 on parse error and \a badcheck is zero.
+ * \note it always fails to parse a hexadecimal representation like "0xAB.CDp+1" when
+ * \a badcheck is zero, even though it would success if \a badcheck was non-zero.
+ * This inconsistency is coming from a historical compatibility reason. [ruby-dev:40822]
+ */
+double
+rb_cstr_to_dbl(const char *p, int badcheck)
{
const char *q;
char *end;
@@ -3457,34 +3214,29 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
int w;
enum {max_width = 20};
#define OutOfRange() ((end - p > max_width) ? \
- (w = max_width, ellipsis = "...") : \
- (w = (int)(end - p), ellipsis = ""))
+ (w = max_width, ellipsis = "...") : \
+ (w = (int)(end - p), ellipsis = ""))
if (!p) return 0.0;
q = p;
while (ISSPACE(*p)) p++;
if (!badcheck && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
- return 0.0;
+ return 0.0;
}
d = strtod(p, &end);
if (errno == ERANGE) {
- OutOfRange();
- rb_warning("Float %.*s%s out of range", w, p, ellipsis);
- errno = 0;
+ OutOfRange();
+ rb_warning("Float %.*s%s out of range", w, p, ellipsis);
+ errno = 0;
}
if (p == end) {
- if (badcheck) {
- bad:
- if (raise)
- rb_invalid_str(q, "Float()");
- else {
- if (error) *error = 1;
- return 0.0;
- }
- }
- return d;
+ if (badcheck) {
+ bad:
+ rb_invalid_str(q, "Float()");
+ }
+ return d;
}
if (*end) {
char buf[DBL_DIG * 4 + 10];
@@ -3535,26 +3287,26 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
*n = '\0';
p = buf;
- if (!badcheck && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
- return 0.0;
- }
+ if (!badcheck && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
+ return 0.0;
+ }
- d = strtod(p, &end);
- if (errno == ERANGE) {
- OutOfRange();
- rb_warning("Float %.*s%s out of range", w, p, ellipsis);
- errno = 0;
- }
- if (badcheck) {
- if (!end || p == end) goto bad;
- while (*end && ISSPACE(*end)) end++;
- if (*end) goto bad;
- }
+ d = strtod(p, &end);
+ if (errno == ERANGE) {
+ OutOfRange();
+ rb_warning("Float %.*s%s out of range", w, p, ellipsis);
+ errno = 0;
+ }
+ if (badcheck) {
+ if (!end || p == end) goto bad;
+ while (*end && ISSPACE(*end)) end++;
+ if (*end) goto bad;
+ }
}
if (errno == ERANGE) {
- errno = 0;
- OutOfRange();
- rb_raise(rb_eArgError, "Float %.*s%s out of range", w, q, ellipsis);
+ errno = 0;
+ OutOfRange();
+ rb_raise(rb_eArgError, "Float %.*s%s out of range", w, q, ellipsis);
}
return d;
}
@@ -3562,7 +3314,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
/*!
* Parses a string representation of a floating point number.
*
- * \param[in] p a string representation of a floating number
+ * \param[in] str a \c String object representation of a floating number
* \param[in] badcheck raises an exception on parse error if \a badcheck is non-zero.
* \return the floating point number in the string on success,
* 0.0 on parse error and \a badcheck is zero.
@@ -3571,13 +3323,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
* This inconsistency is coming from a historical compatibility reason. [ruby-dev:40822]
*/
double
-rb_cstr_to_dbl(const char *p, int badcheck)
-{
- return rb_cstr_to_dbl_raise(p, badcheck, TRUE, NULL);
-}
-
-static double
-rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
+rb_str_to_dbl(VALUE str, int badcheck)
{
char *s;
long len;
@@ -3589,12 +3335,7 @@ rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
len = RSTRING_LEN(str);
if (s) {
if (badcheck && memchr(s, '\0', len)) {
- if (raise)
- rb_raise(rb_eArgError, "string for Float contains null byte");
- else {
- if (error) *error = 1;
- return 0.0;
- }
+ rb_raise(rb_eArgError, "string for Float contains null byte");
}
if (s[len]) { /* no sentinel somehow */
char *p = ALLOCV(v, (size_t)len + 1);
@@ -3603,47 +3344,20 @@ rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
s = p;
}
}
- ret = rb_cstr_to_dbl_raise(s, badcheck, raise, error);
+ ret = rb_cstr_to_dbl(s, badcheck);
if (v)
ALLOCV_END(v);
return ret;
}
-FUNC_MINIMIZED(double rb_str_to_dbl(VALUE str, int badcheck));
-
-/*!
- * Parses a string representation of a floating point number.
- *
- * \param[in] str a \c String object representation of a floating number
- * \param[in] badcheck raises an exception on parse error if \a badcheck is non-zero.
- * \return the floating point number in the string on success,
- * 0.0 on parse error and \a badcheck is zero.
- * \note it always fails to parse a hexadecimal representation like "0xAB.CDp+1" when
- * \a badcheck is zero, even though it would success if \a badcheck was non-zero.
- * This inconsistency is coming from a historical compatibility reason. [ruby-dev:40822]
- */
-double
-rb_str_to_dbl(VALUE str, int badcheck)
-{
- return rb_str_to_dbl_raise(str, badcheck, TRUE, NULL);
-}
-
/*! \cond INTERNAL_MACRO */
#define fix2dbl_without_to_f(x) (double)FIX2LONG(x)
#define big2dbl_without_to_f(x) rb_big2dbl(x)
#define int2dbl_without_to_f(x) \
(FIXNUM_P(x) ? fix2dbl_without_to_f(x) : big2dbl_without_to_f(x))
-#define num2dbl_without_to_f(x) \
- (FIXNUM_P(x) ? fix2dbl_without_to_f(x) : \
- RB_TYPE_P(x, T_BIGNUM) ? big2dbl_without_to_f(x) : \
- (Check_Type(x, T_FLOAT), RFLOAT_VALUE(x)))
-static inline double
-rat2dbl_without_to_f(VALUE x)
-{
- VALUE num = rb_rational_num(x);
- VALUE den = rb_rational_den(x);
- return num2dbl_without_to_f(num) / num2dbl_without_to_f(den);
-}
+#define rat2dbl_without_to_f(x) \
+ (int2dbl_without_to_f(rb_rational_num(x)) / \
+ int2dbl_without_to_f(rb_rational_den(x)))
#define special_const_to_float(val, pre, post) \
switch (val) { \
@@ -3669,7 +3383,7 @@ implicit_conversion_to_float(VALUE val)
}
static int
-to_float(VALUE *valp, int raise_exception)
+to_float(VALUE *valp)
{
VALUE val = *valp;
if (SPECIAL_CONST_P(val)) {
@@ -3680,7 +3394,7 @@ to_float(VALUE *valp, int raise_exception)
else if (FLONUM_P(val)) {
return T_FLOAT;
}
- else if (raise_exception) {
+ else {
conversion_to_float(val);
}
}
@@ -3702,42 +3416,6 @@ to_float(VALUE *valp, int raise_exception)
return T_NONE;
}
-static VALUE
-convert_type_to_float_protected(VALUE val)
-{
- return rb_convert_type_with_id(val, T_FLOAT, "Float", id_to_f);
-}
-
-static VALUE
-rb_convert_to_float(VALUE val, int raise_exception)
-{
- switch (to_float(&val, raise_exception)) {
- case T_FLOAT:
- return val;
- case T_STRING:
- if (!raise_exception) {
- int e = 0;
- double x = rb_str_to_dbl_raise(val, TRUE, raise_exception, &e);
- return e ? Qnil : DBL2NUM(x);
- }
- return DBL2NUM(rb_str_to_dbl(val, TRUE));
- case T_NONE:
- if (SPECIAL_CONST_P(val) && !raise_exception)
- return Qnil;
- }
-
- if (!raise_exception) {
- int state;
- VALUE result = rb_protect(convert_type_to_float_protected, val, &state);
- if (state) rb_set_errinfo(Qnil);
- return result;
- }
-
- return rb_convert_type_with_id(val, T_FLOAT, "Float", id_to_f);
-}
-
-FUNC_MINIMIZED(VALUE rb_Float(VALUE val));
-
/*!
* Equivalent to \c Kernel\#Float in Ruby.
*
@@ -3747,35 +3425,36 @@ FUNC_MINIMIZED(VALUE rb_Float(VALUE val));
VALUE
rb_Float(VALUE val)
{
- return rb_convert_to_float(val, TRUE);
+ switch (to_float(&val)) {
+ case T_FLOAT:
+ return val;
+ case T_STRING:
+ return DBL2NUM(rb_str_to_dbl(val, TRUE));
+ }
+ return rb_convert_type(val, T_FLOAT, "Float", "to_f");
}
+FUNC_MINIMIZED(static VALUE rb_f_float(VALUE obj, VALUE arg)); /*!< \private */
+
/*
* call-seq:
- * Float(arg, exception: true) -> float or nil
+ * Float(arg) -> float
*
- * Returns <i>arg</i> converted to a float. Numeric types are
- * converted directly, and with exception to String and
- * <code>nil</code> the rest are converted using
- * <i>arg</i><code>.to_f</code>. Converting a String with invalid
- * characters will result in a ArgumentError. Converting
- * <code>nil</code> generates a TypeError. Exceptions can be
- * suppressed by passing <code>exception: false</code>.
+ * Returns <i>arg</i> converted to a float. Numeric types are converted
+ * directly, and with exception to string and nil the rest are converted using <i>arg</i>.to_f.
+ * Converting a <code>string</code> with invalid characters will result in a <code>ArgumentError</code>.
+ * Converting <code>nil</code> generates a <code>TypeError</code>.
*
* Float(1) #=> 1.0
* Float("123.456") #=> 123.456
* Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring"
* Float(nil) #=> TypeError: can't convert nil into Float
- * Float("123.0_badstring", exception: false) #=> nil
*/
static VALUE
-rb_f_float(int argc, VALUE *argv, VALUE obj)
+rb_f_float(VALUE obj, VALUE arg)
{
- VALUE arg = Qnil, opts = Qnil;
-
- rb_scan_args(argc, argv, "1:", &arg, &opts);
- return rb_convert_to_float(arg, opts_exception_p(opts));
+ return rb_Float(arg);
}
static VALUE
@@ -3785,7 +3464,7 @@ numeric_to_float(VALUE val)
rb_raise(rb_eTypeError, "can't convert %"PRIsVALUE" into Float",
rb_obj_class(val));
}
- return rb_convert_type_with_id(val, T_FLOAT, "Float", id_to_f);
+ return rb_convert_type(val, T_FLOAT, "Float", "to_f");
}
/*!
@@ -3796,7 +3475,7 @@ numeric_to_float(VALUE val)
VALUE
rb_to_float(VALUE val)
{
- switch (to_float(&val, TRUE)) {
+ switch (to_float(&val)) {
case T_FLOAT:
return val;
}
@@ -3817,9 +3496,11 @@ rb_check_to_float(VALUE val)
if (!rb_obj_is_kind_of(val, rb_cNumeric)) {
return Qnil;
}
- return rb_check_convert_type_with_id(val, T_FLOAT, "Float", id_to_f);
+ return rb_check_convert_type(val, T_FLOAT, "Float", "to_f");
}
+static ID id_to_f;
+
static inline int
basic_to_f_p(VALUE klass)
{
@@ -3893,7 +3574,7 @@ rb_num2dbl(VALUE val)
rb_raise(rb_eTypeError, "no implicit conversion to float from string");
}
}
- val = rb_convert_type_with_id(val, T_FLOAT, "Float", id_to_f);
+ val = rb_convert_type(val, T_FLOAT, "Float", "to_f");
return RFLOAT_VALUE(val);
}
@@ -3917,7 +3598,7 @@ rb_String(VALUE val)
* call-seq:
* String(arg) -> string
*
- * Returns <i>arg</i> as a String.
+ * Returns <i>arg</i> as a <code>String</code>.
*
* First tries to call its <code>to_str</code> method, then its <code>to_s</code> method.
*
@@ -3941,7 +3622,7 @@ rb_Array(VALUE val)
VALUE tmp = rb_check_array_type(val);
if (NIL_P(tmp)) {
- tmp = rb_check_to_array(val);
+ tmp = rb_check_convert_type_with_id(val, T_ARRAY, "Array", idTo_a);
if (NIL_P(tmp)) {
return rb_ary_new3(1, val);
}
@@ -3960,7 +3641,7 @@ rb_Array(VALUE val)
* returns an Array of length 1 containing +arg+.
*
* If <code>to_ary</code> or <code>to_a</code> returns something other than
- * an Array, raises a TypeError.
+ * an Array, raises a <code>TypeError</code>.
*
* Array(["a", "b"]) #=> ["a", "b"]
* Array(1..5) #=> [1, 2, 3, 4, 5]
@@ -3997,8 +3678,8 @@ rb_Hash(VALUE val)
* call-seq:
* Hash(arg) -> hash
*
- * Converts <i>arg</i> to a Hash by calling
- * <i>arg</i><code>.to_hash</code>. Returns an empty Hash when
+ * Converts <i>arg</i> to a <code>Hash</code> by calling
+ * <i>arg</i><code>.to_hash</code>. Returns an empty <code>Hash</code> when
* <i>arg</i> is <tt>nil</tt> or <tt>[]</tt>.
*
* Hash([]) #=> {}
@@ -4071,287 +3752,17 @@ rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
break;
}
}
- return rb_check_funcall_with_hook_kw(obj, id_dig, argc, argv,
- no_dig_method, obj,
- rb_empty_keyword_given_p() ?
- RB_PASS_EMPTY_KEYWORDS :
- RB_NO_KEYWORDS);
+ return rb_check_funcall_with_hook(obj, id_dig, argc, argv,
+ no_dig_method, obj);
}
return obj;
}
/*
- * call-seq:
- * format(format_string [, arguments...] ) -> string
- * sprintf(format_string [, arguments...] ) -> string
- *
- * Returns the string resulting from applying <i>format_string</i> to
- * any additional arguments. Within the format string, any characters
- * other than format sequences are copied to the result.
- *
- * The syntax of a format sequence is as follows.
- *
- * %[flags][width][.precision]type
- *
- * A format
- * sequence consists of a percent sign, followed by optional flags,
- * width, and precision indicators, then terminated with a field type
- * character. The field type controls how the corresponding
- * <code>sprintf</code> argument is to be interpreted, while the flags
- * modify that interpretation.
- *
- * The field type characters are:
- *
- * Field | Integer Format
- * ------+--------------------------------------------------------------
- * b | Convert argument as a binary number.
- * | Negative numbers will be displayed as a two's complement
- * | prefixed with `..1'.
- * B | Equivalent to `b', but uses an uppercase 0B for prefix
- * | in the alternative format by #.
- * d | Convert argument as a decimal number.
- * i | Identical to `d'.
- * o | Convert argument as an octal number.
- * | Negative numbers will be displayed as a two's complement
- * | prefixed with `..7'.
- * u | Identical to `d'.
- * x | Convert argument as a hexadecimal number.
- * | Negative numbers will be displayed as a two's complement
- * | prefixed with `..f' (representing an infinite string of
- * | leading 'ff's).
- * X | Equivalent to `x', but uses uppercase letters.
- *
- * Field | Float Format
- * ------+--------------------------------------------------------------
- * e | Convert floating point argument into exponential notation
- * | with one digit before the decimal point as [-]d.dddddde[+-]dd.
- * | The precision specifies the number of digits after the decimal
- * | point (defaulting to six).
- * E | Equivalent to `e', but uses an uppercase E to indicate
- * | the exponent.
- * f | Convert floating point argument as [-]ddd.dddddd,
- * | where the precision specifies the number of digits after
- * | the decimal point.
- * g | Convert a floating point number using exponential form
- * | if the exponent is less than -4 or greater than or
- * | equal to the precision, or in dd.dddd form otherwise.
- * | The precision specifies the number of significant digits.
- * G | Equivalent to `g', but use an uppercase `E' in exponent form.
- * a | Convert floating point argument as [-]0xh.hhhhp[+-]dd,
- * | which is consisted from optional sign, "0x", fraction part
- * | as hexadecimal, "p", and exponential part as decimal.
- * A | Equivalent to `a', but use uppercase `X' and `P'.
- *
- * Field | Other Format
- * ------+--------------------------------------------------------------
- * c | Argument is the numeric code for a single character or
- * | a single character string itself.
- * p | The valuing of argument.inspect.
- * s | Argument is a string to be substituted. If the format
- * | sequence contains a precision, at most that many characters
- * | will be copied.
- * % | A percent sign itself will be displayed. No argument taken.
- *
- * The flags modifies the behavior of the formats.
- * The flag characters are:
- *
- * Flag | Applies to | Meaning
- * ---------+---------------+-----------------------------------------
- * space | bBdiouxX | Leave a space at the start of
- * | aAeEfgG | non-negative numbers.
- * | (numeric fmt) | For `o', `x', `X', `b' and `B', use
- * | | a minus sign with absolute value for
- * | | negative values.
- * ---------+---------------+-----------------------------------------
- * (digit)$ | all | Specifies the absolute argument number
- * | | for this field. Absolute and relative
- * | | argument numbers cannot be mixed in a
- * | | sprintf string.
- * ---------+---------------+-----------------------------------------
- * # | bBoxX | Use an alternative format.
- * | aAeEfgG | For the conversions `o', increase the precision
- * | | until the first digit will be `0' if
- * | | it is not formatted as complements.
- * | | For the conversions `x', `X', `b' and `B'
- * | | on non-zero, prefix the result with ``0x'',
- * | | ``0X'', ``0b'' and ``0B'', respectively.
- * | | For `a', `A', `e', `E', `f', `g', and 'G',
- * | | force a decimal point to be added,
- * | | even if no digits follow.
- * | | For `g' and 'G', do not remove trailing zeros.
- * ---------+---------------+-----------------------------------------
- * + | bBdiouxX | Add a leading plus sign to non-negative
- * | aAeEfgG | numbers.
- * | (numeric fmt) | For `o', `x', `X', `b' and `B', use
- * | | a minus sign with absolute value for
- * | | negative values.
- * ---------+---------------+-----------------------------------------
- * - | all | Left-justify the result of this conversion.
- * ---------+---------------+-----------------------------------------
- * 0 (zero) | bBdiouxX | Pad with zeros, not spaces.
- * | aAeEfgG | For `o', `x', `X', `b' and `B', radix-1
- * | (numeric fmt) | is used for negative numbers formatted as
- * | | complements.
- * ---------+---------------+-----------------------------------------
- * * | all | Use the next argument as the field width.
- * | | If negative, left-justify the result. If the
- * | | asterisk is followed by a number and a dollar
- * | | sign, use the indicated argument as the width.
- *
- * Examples of flags:
- *
- * # `+' and space flag specifies the sign of non-negative numbers.
- * sprintf("%d", 123) #=> "123"
- * sprintf("%+d", 123) #=> "+123"
- * sprintf("% d", 123) #=> " 123"
- *
- * # `#' flag for `o' increases number of digits to show `0'.
- * # `+' and space flag changes format of negative numbers.
- * sprintf("%o", 123) #=> "173"
- * sprintf("%#o", 123) #=> "0173"
- * sprintf("%+o", -123) #=> "-173"
- * sprintf("%o", -123) #=> "..7605"
- * sprintf("%#o", -123) #=> "..7605"
- *
- * # `#' flag for `x' add a prefix `0x' for non-zero numbers.
- * # `+' and space flag disables complements for negative numbers.
- * sprintf("%x", 123) #=> "7b"
- * sprintf("%#x", 123) #=> "0x7b"
- * sprintf("%+x", -123) #=> "-7b"
- * sprintf("%x", -123) #=> "..f85"
- * sprintf("%#x", -123) #=> "0x..f85"
- * sprintf("%#x", 0) #=> "0"
- *
- * # `#' for `X' uses the prefix `0X'.
- * sprintf("%X", 123) #=> "7B"
- * sprintf("%#X", 123) #=> "0X7B"
- *
- * # `#' flag for `b' add a prefix `0b' for non-zero numbers.
- * # `+' and space flag disables complements for negative numbers.
- * sprintf("%b", 123) #=> "1111011"
- * sprintf("%#b", 123) #=> "0b1111011"
- * sprintf("%+b", -123) #=> "-1111011"
- * sprintf("%b", -123) #=> "..10000101"
- * sprintf("%#b", -123) #=> "0b..10000101"
- * sprintf("%#b", 0) #=> "0"
- *
- * # `#' for `B' uses the prefix `0B'.
- * sprintf("%B", 123) #=> "1111011"
- * sprintf("%#B", 123) #=> "0B1111011"
- *
- * # `#' for `e' forces to show the decimal point.
- * sprintf("%.0e", 1) #=> "1e+00"
- * sprintf("%#.0e", 1) #=> "1.e+00"
- *
- * # `#' for `f' forces to show the decimal point.
- * sprintf("%.0f", 1234) #=> "1234"
- * sprintf("%#.0f", 1234) #=> "1234."
- *
- * # `#' for `g' forces to show the decimal point.
- * # It also disables stripping lowest zeros.
- * sprintf("%g", 123.4) #=> "123.4"
- * sprintf("%#g", 123.4) #=> "123.400"
- * sprintf("%g", 123456) #=> "123456"
- * sprintf("%#g", 123456) #=> "123456."
- *
- * The field width is an optional integer, followed optionally by a
- * period and a precision. The width specifies the minimum number of
- * characters that will be written to the result for this field.
- *
- * Examples of width:
- *
- * # padding is done by spaces, width=20
- * # 0 or radix-1. <------------------>
- * sprintf("%20d", 123) #=> " 123"
- * sprintf("%+20d", 123) #=> " +123"
- * sprintf("%020d", 123) #=> "00000000000000000123"
- * sprintf("%+020d", 123) #=> "+0000000000000000123"
- * sprintf("% 020d", 123) #=> " 0000000000000000123"
- * sprintf("%-20d", 123) #=> "123 "
- * sprintf("%-+20d", 123) #=> "+123 "
- * sprintf("%- 20d", 123) #=> " 123 "
- * sprintf("%020x", -123) #=> "..ffffffffffffffff85"
- *
- * For
- * numeric fields, the precision controls the number of decimal places
- * displayed. For string fields, the precision determines the maximum
- * number of characters to be copied from the string. (Thus, the format
- * sequence <code>%10.10s</code> will always contribute exactly ten
- * characters to the result.)
- *
- * Examples of precisions:
- *
- * # precision for `d', 'o', 'x' and 'b' is
- * # minimum number of digits <------>
- * sprintf("%20.8d", 123) #=> " 00000123"
- * sprintf("%20.8o", 123) #=> " 00000173"
- * sprintf("%20.8x", 123) #=> " 0000007b"
- * sprintf("%20.8b", 123) #=> " 01111011"
- * sprintf("%20.8d", -123) #=> " -00000123"
- * sprintf("%20.8o", -123) #=> " ..777605"
- * sprintf("%20.8x", -123) #=> " ..ffff85"
- * sprintf("%20.8b", -11) #=> " ..110101"
- *
- * # "0x" and "0b" for `#x' and `#b' is not counted for
- * # precision but "0" for `#o' is counted. <------>
- * sprintf("%#20.8d", 123) #=> " 00000123"
- * sprintf("%#20.8o", 123) #=> " 00000173"
- * sprintf("%#20.8x", 123) #=> " 0x0000007b"
- * sprintf("%#20.8b", 123) #=> " 0b01111011"
- * sprintf("%#20.8d", -123) #=> " -00000123"
- * sprintf("%#20.8o", -123) #=> " ..777605"
- * sprintf("%#20.8x", -123) #=> " 0x..ffff85"
- * sprintf("%#20.8b", -11) #=> " 0b..110101"
- *
- * # precision for `e' is number of
- * # digits after the decimal point <------>
- * sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03"
- *
- * # precision for `f' is number of
- * # digits after the decimal point <------>
- * sprintf("%20.8f", 1234.56789) #=> " 1234.56789000"
- *
- * # precision for `g' is number of
- * # significant digits <------->
- * sprintf("%20.8g", 1234.56789) #=> " 1234.5679"
- *
- * # <------->
- * sprintf("%20.8g", 123456789) #=> " 1.2345679e+08"
- *
- * # precision for `s' is
- * # maximum number of characters <------>
- * sprintf("%20.8s", "string test") #=> " string t"
- *
- * Examples:
- *
- * sprintf("%d %04x", 123, 123) #=> "123 007b"
- * sprintf("%08b '%4s'", 123, 123) #=> "01111011 ' 123'"
- * sprintf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello"
- * sprintf("%1$*2$s %2$d", "hello", -8) #=> "hello -8"
- * sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23"
- * sprintf("%u", -123) #=> "-123"
- *
- * For more complex formatting, Ruby supports a reference by name.
- * %<name>s style uses format style, but %{name} style doesn't.
- *
- * Examples:
- * sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 })
- * #=> 1 : 2.000000
- * sprintf("%{foo}f", { :foo => 1 })
- * # => "1f"
- */
-
-static VALUE
-f_sprintf(int c, const VALUE *v, VALUE _)
-{
- return rb_f_sprintf(c, v);
-}
-
-/*
* Document-class: Class
*
* Classes in Ruby are first-class objects---each is an instance of
- * class Class.
+ * class <code>Class</code>.
*
* Typically, you create a new class by using:
*
@@ -4360,11 +3771,12 @@ f_sprintf(int c, const VALUE *v, VALUE _)
* end
*
* When a new class is created, an object of type Class is initialized and
- * assigned to a global constant (Name in this case).
+ * assigned to a global constant (<code>Name</code> in this case).
*
* When <code>Name.new</code> is called to create a new object, the
- * #new method in Class is run by default.
- * This can be demonstrated by overriding #new in Class:
+ * <code>new</code> method in <code>Class</code> is run by default.
+ * This can be demonstrated by overriding <code>new</code> in
+ * <code>Class</code>:
*
* class Class
* alias old_new new
@@ -4440,7 +3852,7 @@ f_sprintf(int c, const VALUE *v, VALUE _)
* DELEGATE = [:puts, :p]
*
* def method_missing(name, *args, &block)
- * return super unless DELEGATE.include? name
+ * super unless DELEGATE.include? name
* ::Kernel.send(name, *args, &block)
* end
*
@@ -4518,16 +3930,16 @@ InitVM_Object(void)
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
- rb_define_private_method(rb_cBasicObject, "initialize", rb_obj_dummy0, 0);
+ rb_define_private_method(rb_cBasicObject, "initialize", rb_obj_dummy, 0);
rb_define_alloc_func(rb_cBasicObject, rb_class_allocate_instance);
rb_define_method(rb_cBasicObject, "==", rb_obj_equal, 1);
rb_define_method(rb_cBasicObject, "equal?", rb_obj_equal, 1);
rb_define_method(rb_cBasicObject, "!", rb_obj_not, 0);
rb_define_method(rb_cBasicObject, "!=", rb_obj_not_equal, 1);
- rb_define_private_method(rb_cBasicObject, "singleton_method_added", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cBasicObject, "singleton_method_removed", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cBasicObject, "singleton_method_undefined", rb_obj_dummy1, 1);
+ rb_define_private_method(rb_cBasicObject, "singleton_method_added", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cBasicObject, "singleton_method_removed", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cBasicObject, "singleton_method_undefined", rb_obj_dummy, 1);
/* Document-module: Kernel
*
@@ -4543,20 +3955,20 @@ InitVM_Object(void)
*/
rb_mKernel = rb_define_module("Kernel");
rb_include_module(rb_cObject, rb_mKernel);
- rb_define_private_method(rb_cClass, "inherited", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cModule, "included", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cModule, "extended", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cModule, "prepended", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy1, 1);
- rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy1, 1);
+ rb_define_private_method(rb_cClass, "inherited", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cModule, "included", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cModule, "extended", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cModule, "prepended", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy, 1);
+ rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
rb_define_method(rb_mKernel, "nil?", rb_false, 0);
rb_define_method(rb_mKernel, "===", rb_equal, 1);
rb_define_method(rb_mKernel, "=~", rb_obj_match, 1);
rb_define_method(rb_mKernel, "!~", rb_obj_not_match, 1);
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
- rb_define_method(rb_mKernel, "hash", rb_obj_hash, 0); /* in hash.c */
+ rb_define_method(rb_mKernel, "hash", rb_obj_hash, 0);
rb_define_method(rb_mKernel, "<=>", rb_obj_cmp, 1);
rb_define_method(rb_mKernel, "class", rb_obj_class, 0);
@@ -4565,7 +3977,6 @@ InitVM_Object(void)
rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0);
rb_define_method(rb_mKernel, "itself", rb_obj_itself, 0);
rb_define_method(rb_mKernel, "yield_self", rb_obj_yield_self, 0);
- rb_define_method(rb_mKernel, "then", rb_obj_yield_self, 0);
rb_define_method(rb_mKernel, "initialize_copy", rb_obj_init_copy, 1);
rb_define_method(rb_mKernel, "initialize_dup", rb_obj_init_dup_clone, 1);
rb_define_method(rb_mKernel, "initialize_clone", rb_obj_init_dup_clone, 1);
@@ -4598,26 +4009,23 @@ InitVM_Object(void)
rb_define_method(rb_mKernel, "is_a?", rb_obj_is_kind_of, 1);
rb_define_method(rb_mKernel, "tap", rb_obj_tap, 0);
- rb_define_global_function("sprintf", f_sprintf, -1);
- rb_define_global_function("format", f_sprintf, -1);
+ rb_define_global_function("sprintf", rb_f_sprintf, -1); /* in sprintf.c */
+ rb_define_global_function("format", rb_f_sprintf, -1); /* in sprintf.c */
rb_define_global_function("Integer", rb_f_integer, -1);
- rb_define_global_function("Float", rb_f_float, -1);
+ rb_define_global_function("Float", rb_f_float, 1);
rb_define_global_function("String", rb_f_string, 1);
rb_define_global_function("Array", rb_f_array, 1);
rb_define_global_function("Hash", rb_f_hash, 1);
rb_cNilClass = rb_define_class("NilClass", rb_cObject);
- rb_cNilClass_to_s = rb_fstring_enc_lit("", rb_usascii_encoding());
- rb_gc_register_mark_object(rb_cNilClass_to_s);
rb_define_method(rb_cNilClass, "to_i", nil_to_i, 0);
rb_define_method(rb_cNilClass, "to_f", nil_to_f, 0);
rb_define_method(rb_cNilClass, "to_s", nil_to_s, 0);
rb_define_method(rb_cNilClass, "to_a", nil_to_a, 0);
rb_define_method(rb_cNilClass, "to_h", nil_to_h, 0);
rb_define_method(rb_cNilClass, "inspect", nil_inspect, 0);
- rb_define_method(rb_cNilClass, "=~", nil_match, 1);
rb_define_method(rb_cNilClass, "&", false_and, 1);
rb_define_method(rb_cNilClass, "|", false_or, 1);
rb_define_method(rb_cNilClass, "^", false_xor, 1);
@@ -4668,7 +4076,6 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "const_get", rb_mod_const_get, -1);
rb_define_method(rb_cModule, "const_set", rb_mod_const_set, 2);
rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, -1);
- rb_define_method(rb_cModule, "const_source_location", rb_mod_const_source_location, -1);
rb_define_private_method(rb_cModule, "remove_const",
rb_mod_remove_const, 1); /* in variable.c */
rb_define_method(rb_cModule, "const_missing",
@@ -4685,7 +4092,7 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "deprecate_constant", rb_mod_deprecate_constant, -1); /* in variable.c */
rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0);
- rb_define_method(rb_cClass, "allocate", rb_class_alloc_m, 0);
+ rb_define_method(rb_cClass, "allocate", rb_class_alloc, 0);
rb_define_method(rb_cClass, "new", rb_class_s_new, -1);
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0);
@@ -4705,8 +4112,6 @@ InitVM_Object(void)
rb_deprecate_constant(rb_cObject, "Data");
rb_cTrueClass = rb_define_class("TrueClass", rb_cObject);
- rb_cTrueClass_to_s = rb_fstring_enc_lit("true", rb_usascii_encoding());
- rb_gc_register_mark_object(rb_cTrueClass_to_s);
rb_define_method(rb_cTrueClass, "to_s", true_to_s, 0);
rb_define_alias(rb_cTrueClass, "inspect", "to_s");
rb_define_method(rb_cTrueClass, "&", true_and, 1);
@@ -4722,8 +4127,6 @@ InitVM_Object(void)
rb_deprecate_constant(rb_cObject, "TRUE");
rb_cFalseClass = rb_define_class("FalseClass", rb_cObject);
- rb_cFalseClass_to_s = rb_fstring_enc_lit("false", rb_usascii_encoding());
- rb_gc_register_mark_object(rb_cFalseClass_to_s);
rb_define_method(rb_cFalseClass, "to_s", false_to_s, 0);
rb_define_alias(rb_cFalseClass, "inspect", "to_s");
rb_define_method(rb_cFalseClass, "&", false_and, 1);
@@ -4742,6 +4145,7 @@ InitVM_Object(void)
void
Init_Object(void)
{
+ id_to_f = rb_intern_const("to_f");
id_dig = rb_intern_const("dig");
InitVM(Object);
}
diff --git a/pack.c b/pack.c
index ae5a9a18e2..6197c85233 100644
--- a/pack.c
+++ b/pack.c
@@ -9,13 +9,10 @@
**********************************************************************/
-#include "ruby/encoding.h"
#include "internal.h"
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
-#include <float.h>
-#include "builtin.h"
/*
* It is intentional that the condition for natstr is HAVE_TRUE_LONG_LONG
@@ -44,20 +41,20 @@ static const char endstr[] = "sSiIlLqQjJ";
#endif
#ifdef DYNAMIC_ENDIAN
-/* for universal binary of NEXTSTEP and MacOS X */
-/* useless since autoconf 2.63? */
-static int
-is_bigendian(void)
-{
- static int init = 0;
- static int endian_value;
- char *p;
-
- if (init) return endian_value;
- init = 1;
- p = (char*)&init;
- return endian_value = p[0]?0:1;
-}
+ /* for universal binary of NEXTSTEP and MacOS X */
+ /* useless since autoconf 2.63? */
+ static int
+ is_bigendian(void)
+ {
+ static int init = 0;
+ static int endian_value;
+ char *p;
+
+ if (init) return endian_value;
+ init = 1;
+ p = (char*)&init;
+ return endian_value = p[0]?0:1;
+ }
# define BIGENDIAN_P() (is_bigendian())
#elif defined(WORDS_BIGENDIAN)
# define BIGENDIAN_P() 1
@@ -129,54 +126,142 @@ str_associated(VALUE str)
return rb_ivar_lookup(str, id_associated, Qfalse);
}
-static void
-unknown_directive(const char *mode, char type, VALUE fmt)
-{
- VALUE f;
- char unknown[5];
-
- if (ISPRINT(type)) {
- unknown[0] = type;
- unknown[1] = '\0';
- }
- else {
- snprintf(unknown, sizeof(unknown), "\\x%.2x", type & 0xff);
- }
- f = rb_str_quote_unprintable(fmt);
- if (f != fmt) {
- fmt = rb_str_subseq(f, 1, RSTRING_LEN(f) - 2);
- }
- rb_warning("unknown %s directive '%s' in '%"PRIsVALUE"'",
- mode, unknown, fmt);
-}
-
-static float
-VALUE_to_float(VALUE obj)
-{
- VALUE v = rb_to_float(obj);
- double d = RFLOAT_VALUE(v);
-
- if (isnan(d)) {
- return NAN;
- }
- else if (d < -FLT_MAX) {
- return -INFINITY;
- }
- else if (d <= FLT_MAX) {
- return d;
- }
- else {
- return INFINITY;
- }
-}
+/*
+ * call-seq:
+ * arr.pack( aTemplateString ) -> aBinaryString
+ * arr.pack( aTemplateString, buffer: aBufferString ) -> aBufferString
+ *
+ * Packs the contents of <i>arr</i> into a binary sequence according to
+ * the directives in <i>aTemplateString</i> (see the table below)
+ * Directives ``A,'' ``a,'' and ``Z'' may be followed by a count,
+ * which gives the width of the resulting field. The remaining
+ * directives also may take a count, indicating the number of array
+ * elements to convert. If the count is an asterisk
+ * (``<code>*</code>''), all remaining array elements will be
+ * converted. Any of the directives ``<code>sSiIlL</code>'' may be
+ * followed by an underscore (``<code>_</code>'') or
+ * exclamation mark (``<code>!</code>'') to use the underlying
+ * platform's native size for the specified type; otherwise, they use a
+ * platform-independent size. Spaces are ignored in the template
+ * string. See also <code>String#unpack</code>.
+ *
+ * a = [ "a", "b", "c" ]
+ * n = [ 65, 66, 67 ]
+ * a.pack("A3A3A3") #=> "a b c "
+ * a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000"
+ * n.pack("ccc") #=> "ABC"
+ *
+ * If <i>aBufferString</i> is specified and its capacity is enough,
+ * +pack+ uses it as the buffer and returns it.
+ * When the offset is specified by the beginning of <i>aTemplateString</i>,
+ * the result is filled after the offset.
+ * If original contents of <i>aBufferString</i> exists and it's longer than
+ * the offset, the rest of <i>offsetOfBuffer</i> are overwritten by the result.
+ * If it's shorter, the gap is filled with ``<code>\0</code>''.
+ *
+ * Note that ``buffer:'' option does not guarantee not to allocate memory
+ * in +pack+. If the capacity of <i>aBufferString</i> is not enough,
+ * +pack+ allocates memory.
+ *
+ * Directives for +pack+.
+ *
+ * Integer | Array |
+ * Directive | Element | Meaning
+ * ----------------------------------------------------------------------------
+ * C | Integer | 8-bit unsigned (unsigned char)
+ * S | Integer | 16-bit unsigned, native endian (uint16_t)
+ * L | Integer | 32-bit unsigned, native endian (uint32_t)
+ * Q | Integer | 64-bit unsigned, native endian (uint64_t)
+ * J | Integer | pointer width unsigned, native endian (uintptr_t)
+ * | | (J is available since Ruby 2.3.)
+ * | |
+ * c | Integer | 8-bit signed (signed char)
+ * s | Integer | 16-bit signed, native endian (int16_t)
+ * l | Integer | 32-bit signed, native endian (int32_t)
+ * q | Integer | 64-bit signed, native endian (int64_t)
+ * j | Integer | pointer width signed, native endian (intptr_t)
+ * | | (j is available since Ruby 2.3.)
+ * | |
+ * S_ S! | Integer | unsigned short, native endian
+ * I I_ I! | Integer | unsigned int, native endian
+ * L_ L! | Integer | unsigned long, native endian
+ * Q_ Q! | Integer | unsigned long long, native endian (ArgumentError
+ * | | if the platform has no long long type.)
+ * | | (Q_ and Q! is available since Ruby 2.1.)
+ * J! | Integer | uintptr_t, native endian (same with J)
+ * | | (J! is available since Ruby 2.3.)
+ * | |
+ * s_ s! | Integer | signed short, native endian
+ * i i_ i! | Integer | signed int, native endian
+ * l_ l! | Integer | signed long, native endian
+ * q_ q! | Integer | signed long long, native endian (ArgumentError
+ * | | if the platform has no long long type.)
+ * | | (q_ and q! is available since Ruby 2.1.)
+ * j! | Integer | intptr_t, native endian (same with j)
+ * | | (j! is available since Ruby 2.3.)
+ * | |
+ * S> s> S!> s!> | Integer | same as the directives without ">" except
+ * L> l> L!> l!> | | big endian
+ * I!> i!> | | (available since Ruby 1.9.3)
+ * Q> q> Q!> q!> | | "S>" is same as "n"
+ * J> j> J!> j!> | | "L>" is same as "N"
+ * | |
+ * S< s< S!< s!< | Integer | same as the directives without "<" except
+ * L< l< L!< l!< | | little endian
+ * I!< i!< | | (available since Ruby 1.9.3)
+ * Q< q< Q!< q!< | | "S<" is same as "v"
+ * J< j< J!< j!< | | "L<" is same as "V"
+ * | |
+ * n | Integer | 16-bit unsigned, network (big-endian) byte order
+ * N | Integer | 32-bit unsigned, network (big-endian) byte order
+ * v | Integer | 16-bit unsigned, VAX (little-endian) byte order
+ * V | Integer | 32-bit unsigned, VAX (little-endian) byte order
+ * | |
+ * U | Integer | UTF-8 character
+ * w | Integer | BER-compressed integer
+ *
+ * Float | Array |
+ * Directive | Element | Meaning
+ * ---------------------------------------------------------------------------
+ * D d | Float | double-precision, native format
+ * F f | Float | single-precision, native format
+ * E | Float | double-precision, little-endian byte order
+ * e | Float | single-precision, little-endian byte order
+ * G | Float | double-precision, network (big-endian) byte order
+ * g | Float | single-precision, network (big-endian) byte order
+ *
+ * String | Array |
+ * Directive | Element | Meaning
+ * ---------------------------------------------------------------------------
+ * A | String | arbitrary binary string (space padded, count is width)
+ * a | String | arbitrary binary string (null padded, count is width)
+ * Z | String | same as ``a'', except that null is added with *
+ * B | String | bit string (MSB first)
+ * b | String | bit string (LSB first)
+ * H | String | hex string (high nibble first)
+ * h | String | hex string (low nibble first)
+ * u | String | UU-encoded string
+ * M | String | quoted printable, MIME encoding (see RFC2045)
+ * m | String | base64 encoded string (see RFC 2045, count is width)
+ * | | (if count is 0, no line feed are added, see RFC 4648)
+ * P | String | pointer to a structure (fixed-length string)
+ * p | String | pointer to a null-terminated string
+ *
+ * Misc. | Array |
+ * Directive | Element | Meaning
+ * ---------------------------------------------------------------------------
+ * @ | --- | moves to absolute position
+ * X | --- | back up a byte
+ * x | --- | null byte
+ */
static VALUE
-pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
+pack_pack(int argc, VALUE *argv, VALUE ary)
{
static const char nul10[] = "\0\0\0\0\0\0\0\0\0\0";
static const char spc10[] = " ";
const char *p, *pend;
- VALUE res, from, associates = 0;
+ VALUE fmt, opt = Qnil, res, from, associates = 0, buffer = 0;
char type;
long len, idx, plen;
const char *ptr;
@@ -186,18 +271,25 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
#endif
int integer_size, bigendian_p;
+ rb_scan_args(argc, argv, "10:", &fmt, &opt);
+
StringValue(fmt);
p = RSTRING_PTR(fmt);
pend = p + RSTRING_LEN(fmt);
+ if (!NIL_P(opt)) {
+ static ID keyword_ids[1];
+ if (!keyword_ids[0])
+ CONST_ID(keyword_ids[0], "buffer");
- if (NIL_P(buffer)) {
- res = rb_str_buf_new(0);
+ rb_get_kwargs(opt, keyword_ids, 0, 1, &buffer);
+
+ if (buffer != Qundef && !RB_TYPE_P(buffer, T_STRING))
+ rb_raise(rb_eTypeError, "buffer must be String, not %s", rb_obj_classname(buffer));
}
- else {
- if (!RB_TYPE_P(buffer, T_STRING))
- rb_raise(rb_eTypeError, "buffer must be String, not %s", rb_obj_classname(buffer));
+ if (buffer)
res = buffer;
- }
+ else
+ res = rb_str_buf_new(0);
idx = 0;
@@ -296,6 +388,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
StringValue(from);
ptr = RSTRING_PTR(from);
plen = RSTRING_LEN(from);
+ OBJ_INFECT(res, from);
}
if (p[-1] == '*')
@@ -547,7 +640,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
float f;
from = NEXTFROM;
- f = VALUE_to_float(from);
+ f = (float)RFLOAT_VALUE(rb_to_float(from));
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
break;
@@ -557,7 +650,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
FLOAT_CONVWITH(tmp);
from = NEXTFROM;
- tmp.f = VALUE_to_float(from);
+ tmp.f = (float)RFLOAT_VALUE(rb_to_float(from));
HTOVF(tmp);
rb_str_buf_cat(res, tmp.buf, sizeof(float));
}
@@ -588,7 +681,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
while (len-- > 0) {
FLOAT_CONVWITH(tmp);
from = NEXTFROM;
- tmp.f = VALUE_to_float(from);
+ tmp.f = (float)RFLOAT_VALUE(rb_to_float(from));
HTONF(tmp);
rb_str_buf_cat(res, tmp.buf, sizeof(float));
}
@@ -656,6 +749,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
StringValue(from);
ptr = RSTRING_PTR(from);
plen = RSTRING_LEN(from);
+ OBJ_INFECT(res, from);
if (len == 0 && type == 'm') {
encodes(res, ptr, plen, type, 0);
@@ -683,6 +777,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
case 'M': /* quoted-printable encoded string */
from = rb_obj_as_string(NEXTFROM);
+ OBJ_INFECT(res, from);
if (len <= 1)
len = 72;
qpencode(res, from, len);
@@ -708,6 +803,8 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
}
else {
t = StringValuePtr(from);
+ OBJ_INFECT(res, from);
+ rb_obj_taint(from);
}
if (!associates) {
associates = rb_ary_new();
@@ -740,9 +837,9 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
cp = RSTRING_PTR(buf);
while (1 < numbytes) {
- *cp |= 0x80;
- cp++;
- numbytes--;
+ *cp |= 0x80;
+ cp++;
+ numbytes--;
}
rb_str_buf_cat(res, RSTRING_PTR(buf), RSTRING_LEN(buf));
@@ -750,7 +847,16 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
break;
default: {
- unknown_directive("pack", type, fmt);
+ char unknown[5];
+ if (ISPRINT(type)) {
+ unknown[0] = type;
+ unknown[1] = '\0';
+ }
+ else {
+ snprintf(unknown, sizeof(unknown), "\\x%.2x", type & 0xff);
+ }
+ rb_warning("unknown pack directive '%s' in '% "PRIsVALUE"'",
+ unknown, fmt);
break;
}
}
@@ -759,6 +865,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
if (associates) {
str_associate(res, associates);
}
+ OBJ_INFECT(res, fmt);
switch (enc_info) {
case 1:
ENCODING_CODERANGE_SET(res, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
@@ -896,7 +1003,7 @@ hex2num(char c)
tmp_len = 0; \
if (len > (long)((send-s)/(sz))) { \
if (!star) { \
- tmp_len = len-(send-s)/(sz); \
+ tmp_len = len-(send-s)/(sz); \
} \
len = (send-s)/(sz); \
} \
@@ -917,6 +1024,15 @@ hex2num(char c)
# define AVOID_CC_BUG
#endif
+static VALUE
+infected_str_new(const char *ptr, long len, VALUE str)
+{
+ VALUE s = rb_str_new(ptr, len);
+
+ OBJ_INFECT(s, str);
+ return s;
+}
+
/* unpack mode */
#define UNPACK_ARRAY 0
#define UNPACK_BLOCK 1
@@ -1037,7 +1153,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
if (*t != ' ' && *t != '\0') break;
t--; len--;
}
- UNPACK_PUSH(rb_str_new(s, len));
+ UNPACK_PUSH(infected_str_new(s, len, str));
s += end;
}
break;
@@ -1048,7 +1164,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
if (len > send-s) len = send-s;
while (t < s+len && *t) t++;
- UNPACK_PUSH(rb_str_new(s, t-s));
+ UNPACK_PUSH(infected_str_new(s, t-s, str));
if (t < send) t++;
s = star ? t : s+len;
}
@@ -1056,7 +1172,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
case 'a':
if (len > send - s) len = send - s;
- UNPACK_PUSH(rb_str_new(s, len));
+ UNPACK_PUSH(infected_str_new(s, len, str));
s += len;
break;
@@ -1071,6 +1187,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
len = (send - s) * 8;
bits = 0;
bitstr = rb_usascii_str_new(0, len);
+ OBJ_INFECT(bitstr, str);
t = RSTRING_PTR(bitstr);
for (i=0; i<len; i++) {
if (i & 7) bits >>= 1;
@@ -1092,6 +1209,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
len = (send - s) * 8;
bits = 0;
bitstr = rb_usascii_str_new(0, len);
+ OBJ_INFECT(bitstr, str);
t = RSTRING_PTR(bitstr);
for (i=0; i<len; i++) {
if (i & 7) bits <<= 1;
@@ -1113,6 +1231,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
len = (send - s) * 2;
bits = 0;
bitstr = rb_usascii_str_new(0, len);
+ OBJ_INFECT(bitstr, str);
t = RSTRING_PTR(bitstr);
for (i=0; i<len; i++) {
if (i & 1)
@@ -1136,6 +1255,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
len = (send - s) * 2;
bits = 0;
bitstr = rb_usascii_str_new(0, len);
+ OBJ_INFECT(bitstr, str);
t = RSTRING_PTR(bitstr);
for (i=0; i<len; i++) {
if (i & 1)
@@ -1347,7 +1467,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
case 'u':
{
- VALUE buf = rb_str_new(0, (send - s)*3/4);
+ VALUE buf = infected_str_new(0, (send - s)*3/4, str);
char *ptr = RSTRING_PTR(buf);
long total = 0;
@@ -1402,7 +1522,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
case 'm':
{
- VALUE buf = rb_str_new(0, (send - s + 3)*3/4); /* +3 is for skipping paddings */
+ VALUE buf = infected_str_new(0, (send - s + 3)*3/4, str); /* +3 is for skipping paddings */
char *ptr = RSTRING_PTR(buf);
int a = -1,b = -1,c = 0,d = 0;
static signed char b64_xtable[256];
@@ -1483,7 +1603,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
case 'M':
{
- VALUE buf = rb_str_new(0, send - s);
+ VALUE buf = infected_str_new(0, send - s, str);
char *ptr = RSTRING_PTR(buf), *ss = s;
int csum = 0;
int c1, c2;
@@ -1552,7 +1672,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
while (p < pend) {
if (RB_TYPE_P(*p, T_STRING) && RSTRING_PTR(*p) == t) {
if (len < RSTRING_LEN(*p)) {
- tmp = rb_str_new(t, len);
+ tmp = rb_tainted_str_new(t, len);
str_associate(tmp, a);
}
else {
@@ -1626,7 +1746,8 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
break;
default:
- unknown_directive("unpack", type, fmt);
+ rb_warning("unknown unpack directive '%c' in '%s'",
+ type, RSTRING_PTR(fmt));
break;
}
}
@@ -1634,15 +1755,144 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
return ary;
}
+/*
+ * call-seq:
+ * str.unpack(format) -> anArray
+ *
+ * Decodes <i>str</i> (which may contain binary data) according to the
+ * format string, returning an array of each value extracted. The
+ * format string consists of a sequence of single-character directives,
+ * summarized in the table at the end of this entry.
+ * Each directive may be followed
+ * by a number, indicating the number of times to repeat with this
+ * directive. An asterisk (``<code>*</code>'') will use up all
+ * remaining elements. The directives <code>sSiIlL</code> may each be
+ * followed by an underscore (``<code>_</code>'') or
+ * exclamation mark (``<code>!</code>'') to use the underlying
+ * platform's native size for the specified type; otherwise, it uses a
+ * platform-independent consistent size. Spaces are ignored in the
+ * format string. See also <code>String#unpack1</code>, <code>Array#pack</code>.
+ *
+ * "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "]
+ * "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"]
+ * "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "]
+ * "aa".unpack('b8B8') #=> ["10000110", "01100001"]
+ * "aaa".unpack('h2H2c') #=> ["16", "61", 97]
+ * "\xfe\xff\xfe\xff".unpack('sS') #=> [-2, 65534]
+ * "now=20is".unpack('M*') #=> ["now is"]
+ * "whole".unpack('xax2aX2aX1aX2a') #=> ["h", "e", "l", "l", "o"]
+ *
+ * This table summarizes the various formats and the Ruby classes
+ * returned by each.
+ *
+ * Integer | |
+ * Directive | Returns | Meaning
+ * ------------------------------------------------------------------
+ * C | Integer | 8-bit unsigned (unsigned char)
+ * S | Integer | 16-bit unsigned, native endian (uint16_t)
+ * L | Integer | 32-bit unsigned, native endian (uint32_t)
+ * Q | Integer | 64-bit unsigned, native endian (uint64_t)
+ * J | Integer | pointer width unsigned, native endian (uintptr_t)
+ * | |
+ * c | Integer | 8-bit signed (signed char)
+ * s | Integer | 16-bit signed, native endian (int16_t)
+ * l | Integer | 32-bit signed, native endian (int32_t)
+ * q | Integer | 64-bit signed, native endian (int64_t)
+ * j | Integer | pointer width signed, native endian (intptr_t)
+ * | |
+ * S_ S! | Integer | unsigned short, native endian
+ * I I_ I! | Integer | unsigned int, native endian
+ * L_ L! | Integer | unsigned long, native endian
+ * Q_ Q! | Integer | unsigned long long, native endian (ArgumentError
+ * | | if the platform has no long long type.)
+ * J! | Integer | uintptr_t, native endian (same with J)
+ * | |
+ * s_ s! | Integer | signed short, native endian
+ * i i_ i! | Integer | signed int, native endian
+ * l_ l! | Integer | signed long, native endian
+ * q_ q! | Integer | signed long long, native endian (ArgumentError
+ * | | if the platform has no long long type.)
+ * j! | Integer | intptr_t, native endian (same with j)
+ * | |
+ * S> s> S!> s!> | Integer | same as the directives without ">" except
+ * L> l> L!> l!> | | big endian
+ * I!> i!> | |
+ * Q> q> Q!> q!> | | "S>" is same as "n"
+ * J> j> J!> j!> | | "L>" is same as "N"
+ * | |
+ * S< s< S!< s!< | Integer | same as the directives without "<" except
+ * L< l< L!< l!< | | little endian
+ * I!< i!< | |
+ * Q< q< Q!< q!< | | "S<" is same as "v"
+ * J< j< J!< j!< | | "L<" is same as "V"
+ * | |
+ * n | Integer | 16-bit unsigned, network (big-endian) byte order
+ * N | Integer | 32-bit unsigned, network (big-endian) byte order
+ * v | Integer | 16-bit unsigned, VAX (little-endian) byte order
+ * V | Integer | 32-bit unsigned, VAX (little-endian) byte order
+ * | |
+ * U | Integer | UTF-8 character
+ * w | Integer | BER-compressed integer (see Array.pack)
+ *
+ * Float | |
+ * Directive | Returns | Meaning
+ * -----------------------------------------------------------------
+ * D d | Float | double-precision, native format
+ * F f | Float | single-precision, native format
+ * E | Float | double-precision, little-endian byte order
+ * e | Float | single-precision, little-endian byte order
+ * G | Float | double-precision, network (big-endian) byte order
+ * g | Float | single-precision, network (big-endian) byte order
+ *
+ * String | |
+ * Directive | Returns | Meaning
+ * -----------------------------------------------------------------
+ * A | String | arbitrary binary string (remove trailing nulls and ASCII spaces)
+ * a | String | arbitrary binary string
+ * Z | String | null-terminated string
+ * B | String | bit string (MSB first)
+ * b | String | bit string (LSB first)
+ * H | String | hex string (high nibble first)
+ * h | String | hex string (low nibble first)
+ * u | String | UU-encoded string
+ * M | String | quoted-printable, MIME encoding (see RFC2045)
+ * m | String | base64 encoded string (RFC 2045) (default)
+ * | | base64 encoded string (RFC 4648) if followed by 0
+ * P | String | pointer to a structure (fixed-length string)
+ * p | String | pointer to a null-terminated string
+ *
+ * Misc. | |
+ * Directive | Returns | Meaning
+ * -----------------------------------------------------------------
+ * @ | --- | skip to the offset given by the length argument
+ * X | --- | skip backward one byte
+ * x | --- | skip forward one byte
+ *
+ * HISTORY
+ *
+ * * J, J! j, and j! are available since Ruby 2.3.
+ * * Q_, Q!, q_, and q! are available since Ruby 2.1.
+ * * I!<, i!<, I!>, and i!> are available since Ruby 1.9.3.
+ */
+
static VALUE
-pack_unpack(rb_execution_context_t *ec, VALUE str, VALUE fmt)
+pack_unpack(VALUE str, VALUE fmt)
{
int mode = rb_block_given_p() ? UNPACK_BLOCK : UNPACK_ARRAY;
return pack_unpack_internal(str, fmt, mode);
}
+/*
+ * call-seq:
+ * str.unpack1(format) -> obj
+ *
+ * Decodes <i>str</i> (which may contain binary data) according to the
+ * format string, returning the first value extracted.
+ * See also <code>String#unpack</code>, <code>Array#pack</code>.
+ */
+
static VALUE
-pack_unpack1(rb_execution_context_t *ec, VALUE str, VALUE fmt)
+pack_unpack1(VALUE str, VALUE fmt)
{
return pack_unpack_internal(str, fmt, UNPACK_1);
}
@@ -1691,7 +1941,7 @@ rb_uv_to_utf8(char buf[6], unsigned long uv)
}
rb_raise(rb_eRangeError, "pack(U): value out of range");
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
static const unsigned long utf8_limits[] = {
@@ -1754,12 +2004,12 @@ utf8_to_uv(const char *p, long *lenp)
return uv;
}
-#include "pack.rbinc"
-
void
Init_pack(void)
{
- load_pack();
+ rb_define_method(rb_cArray, "pack", pack_pack, -1);
+ rb_define_method(rb_cString, "unpack", pack_unpack, 1);
+ rb_define_method(rb_cString, "unpack1", pack_unpack1, 1);
id_associated = rb_make_internal_id();
}
diff --git a/pack.rb b/pack.rb
deleted file mode 100644
index 3f921a93dd..0000000000
--- a/pack.rb
+++ /dev/null
@@ -1,283 +0,0 @@
-# for pack.c
-
-class Array
- # call-seq:
- # arr.pack( aTemplateString ) -> aBinaryString
- # arr.pack( aTemplateString, buffer: aBufferString ) -> aBufferString
- #
- # Packs the contents of <i>arr</i> into a binary sequence according to
- # the directives in <i>aTemplateString</i> (see the table below)
- # Directives ``A,'' ``a,'' and ``Z'' may be followed by a count,
- # which gives the width of the resulting field. The remaining
- # directives also may take a count, indicating the number of array
- # elements to convert. If the count is an asterisk
- # (``<code>*</code>''), all remaining array elements will be
- # converted. Any of the directives ``<code>sSiIlL</code>'' may be
- # followed by an underscore (``<code>_</code>'') or
- # exclamation mark (``<code>!</code>'') to use the underlying
- # platform's native size for the specified type; otherwise, they use a
- # platform-independent size. Spaces are ignored in the template
- # string. See also String#unpack.
- #
- # a = [ "a", "b", "c" ]
- # n = [ 65, 66, 67 ]
- # a.pack("A3A3A3") #=> "a b c "
- # a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000"
- # n.pack("ccc") #=> "ABC"
- #
- # If <i>aBufferString</i> is specified and its capacity is enough,
- # +pack+ uses it as the buffer and returns it.
- # When the offset is specified by the beginning of <i>aTemplateString</i>,
- # the result is filled after the offset.
- # If original contents of <i>aBufferString</i> exists and it's longer than
- # the offset, the rest of <i>offsetOfBuffer</i> are overwritten by the result.
- # If it's shorter, the gap is filled with ``<code>\0</code>''.
- #
- # Note that ``buffer:'' option does not guarantee not to allocate memory
- # in +pack+. If the capacity of <i>aBufferString</i> is not enough,
- # +pack+ allocates memory.
- #
- # Directives for +pack+.
- #
- # Integer | Array |
- # Directive | Element | Meaning
- # ----------------------------------------------------------------------------
- # C | Integer | 8-bit unsigned (unsigned char)
- # S | Integer | 16-bit unsigned, native endian (uint16_t)
- # L | Integer | 32-bit unsigned, native endian (uint32_t)
- # Q | Integer | 64-bit unsigned, native endian (uint64_t)
- # J | Integer | pointer width unsigned, native endian (uintptr_t)
- # | | (J is available since Ruby 2.3.)
- # | |
- # c | Integer | 8-bit signed (signed char)
- # s | Integer | 16-bit signed, native endian (int16_t)
- # l | Integer | 32-bit signed, native endian (int32_t)
- # q | Integer | 64-bit signed, native endian (int64_t)
- # j | Integer | pointer width signed, native endian (intptr_t)
- # | | (j is available since Ruby 2.3.)
- # | |
- # S_ S! | Integer | unsigned short, native endian
- # I I_ I! | Integer | unsigned int, native endian
- # L_ L! | Integer | unsigned long, native endian
- # Q_ Q! | Integer | unsigned long long, native endian (ArgumentError
- # | | if the platform has no long long type.)
- # | | (Q_ and Q! is available since Ruby 2.1.)
- # J! | Integer | uintptr_t, native endian (same with J)
- # | | (J! is available since Ruby 2.3.)
- # | |
- # s_ s! | Integer | signed short, native endian
- # i i_ i! | Integer | signed int, native endian
- # l_ l! | Integer | signed long, native endian
- # q_ q! | Integer | signed long long, native endian (ArgumentError
- # | | if the platform has no long long type.)
- # | | (q_ and q! is available since Ruby 2.1.)
- # j! | Integer | intptr_t, native endian (same with j)
- # | | (j! is available since Ruby 2.3.)
- # | |
- # S> s> S!> s!> | Integer | same as the directives without ">" except
- # L> l> L!> l!> | | big endian
- # I!> i!> | | (available since Ruby 1.9.3)
- # Q> q> Q!> q!> | | "S>" is same as "n"
- # J> j> J!> j!> | | "L>" is same as "N"
- # | |
- # S< s< S!< s!< | Integer | same as the directives without "<" except
- # L< l< L!< l!< | | little endian
- # I!< i!< | | (available since Ruby 1.9.3)
- # Q< q< Q!< q!< | | "S<" is same as "v"
- # J< j< J!< j!< | | "L<" is same as "V"
- # | |
- # n | Integer | 16-bit unsigned, network (big-endian) byte order
- # N | Integer | 32-bit unsigned, network (big-endian) byte order
- # v | Integer | 16-bit unsigned, VAX (little-endian) byte order
- # V | Integer | 32-bit unsigned, VAX (little-endian) byte order
- # | |
- # U | Integer | UTF-8 character
- # w | Integer | BER-compressed integer
- #
- # Float | Array |
- # Directive | Element | Meaning
- # ---------------------------------------------------------------------------
- # D d | Float | double-precision, native format
- # F f | Float | single-precision, native format
- # E | Float | double-precision, little-endian byte order
- # e | Float | single-precision, little-endian byte order
- # G | Float | double-precision, network (big-endian) byte order
- # g | Float | single-precision, network (big-endian) byte order
- #
- # String | Array |
- # Directive | Element | Meaning
- # ---------------------------------------------------------------------------
- # A | String | arbitrary binary string (space padded, count is width)
- # a | String | arbitrary binary string (null padded, count is width)
- # Z | String | same as ``a'', except that null is added with *
- # B | String | bit string (MSB first)
- # b | String | bit string (LSB first)
- # H | String | hex string (high nibble first)
- # h | String | hex string (low nibble first)
- # u | String | UU-encoded string
- # M | String | quoted printable, MIME encoding (see also RFC2045)
- # | | (text mode but input must use LF and output LF)
- # m | String | base64 encoded string (see RFC 2045)
- # | | (if count is 0, no line feed are added, see RFC 4648)
- # | | (count specifies input bytes between each LF,
- # | | rounded down to nearest multiple of 3)
- # P | String | pointer to a structure (fixed-length string)
- # p | String | pointer to a null-terminated string
- #
- # Misc. | Array |
- # Directive | Element | Meaning
- # ---------------------------------------------------------------------------
- # @ | --- | moves to absolute position
- # X | --- | back up a byte
- # x | --- | null byte
- def pack(fmt, buffer: nil)
- __builtin_pack_pack(fmt, buffer)
- end
-end
-
-class String
- # call-seq:
- # str.unpack(format) -> anArray
- #
- # Decodes <i>str</i> (which may contain binary data) according to the
- # format string, returning an array of each value extracted. The
- # format string consists of a sequence of single-character directives,
- # summarized in the table at the end of this entry.
- # Each directive may be followed
- # by a number, indicating the number of times to repeat with this
- # directive. An asterisk (``<code>*</code>'') will use up all
- # remaining elements. The directives <code>sSiIlL</code> may each be
- # followed by an underscore (``<code>_</code>'') or
- # exclamation mark (``<code>!</code>'') to use the underlying
- # platform's native size for the specified type; otherwise, it uses a
- # platform-independent consistent size. Spaces are ignored in the
- # format string. See also String#unpack1, Array#pack.
- #
- # "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "]
- # "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"]
- # "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "]
- # "aa".unpack('b8B8') #=> ["10000110", "01100001"]
- # "aaa".unpack('h2H2c') #=> ["16", "61", 97]
- # "\xfe\xff\xfe\xff".unpack('sS') #=> [-2, 65534]
- # "now=20is".unpack('M*') #=> ["now is"]
- # "whole".unpack('xax2aX2aX1aX2a') #=> ["h", "e", "l", "l", "o"]
- #
- # This table summarizes the various formats and the Ruby classes
- # returned by each.
- #
- # Integer | |
- # Directive | Returns | Meaning
- # ------------------------------------------------------------------
- # C | Integer | 8-bit unsigned (unsigned char)
- # S | Integer | 16-bit unsigned, native endian (uint16_t)
- # L | Integer | 32-bit unsigned, native endian (uint32_t)
- # Q | Integer | 64-bit unsigned, native endian (uint64_t)
- # J | Integer | pointer width unsigned, native endian (uintptr_t)
- # | |
- # c | Integer | 8-bit signed (signed char)
- # s | Integer | 16-bit signed, native endian (int16_t)
- # l | Integer | 32-bit signed, native endian (int32_t)
- # q | Integer | 64-bit signed, native endian (int64_t)
- # j | Integer | pointer width signed, native endian (intptr_t)
- # | |
- # S_ S! | Integer | unsigned short, native endian
- # I I_ I! | Integer | unsigned int, native endian
- # L_ L! | Integer | unsigned long, native endian
- # Q_ Q! | Integer | unsigned long long, native endian (ArgumentError
- # | | if the platform has no long long type.)
- # J! | Integer | uintptr_t, native endian (same with J)
- # | |
- # s_ s! | Integer | signed short, native endian
- # i i_ i! | Integer | signed int, native endian
- # l_ l! | Integer | signed long, native endian
- # q_ q! | Integer | signed long long, native endian (ArgumentError
- # | | if the platform has no long long type.)
- # j! | Integer | intptr_t, native endian (same with j)
- # | |
- # S> s> S!> s!> | Integer | same as the directives without ">" except
- # L> l> L!> l!> | | big endian
- # I!> i!> | |
- # Q> q> Q!> q!> | | "S>" is same as "n"
- # J> j> J!> j!> | | "L>" is same as "N"
- # | |
- # S< s< S!< s!< | Integer | same as the directives without "<" except
- # L< l< L!< l!< | | little endian
- # I!< i!< | |
- # Q< q< Q!< q!< | | "S<" is same as "v"
- # J< j< J!< j!< | | "L<" is same as "V"
- # | |
- # n | Integer | 16-bit unsigned, network (big-endian) byte order
- # N | Integer | 32-bit unsigned, network (big-endian) byte order
- # v | Integer | 16-bit unsigned, VAX (little-endian) byte order
- # V | Integer | 32-bit unsigned, VAX (little-endian) byte order
- # | |
- # U | Integer | UTF-8 character
- # w | Integer | BER-compressed integer (see Array.pack)
- #
- # Float | |
- # Directive | Returns | Meaning
- # -----------------------------------------------------------------
- # D d | Float | double-precision, native format
- # F f | Float | single-precision, native format
- # E | Float | double-precision, little-endian byte order
- # e | Float | single-precision, little-endian byte order
- # G | Float | double-precision, network (big-endian) byte order
- # g | Float | single-precision, network (big-endian) byte order
- #
- # String | |
- # Directive | Returns | Meaning
- # -----------------------------------------------------------------
- # A | String | arbitrary binary string (remove trailing nulls and ASCII spaces)
- # a | String | arbitrary binary string
- # Z | String | null-terminated string
- # B | String | bit string (MSB first)
- # b | String | bit string (LSB first)
- # H | String | hex string (high nibble first)
- # h | String | hex string (low nibble first)
- # u | String | UU-encoded string
- # M | String | quoted-printable, MIME encoding (see RFC2045)
- # m | String | base64 encoded string (RFC 2045) (default)
- # | | base64 encoded string (RFC 4648) if followed by 0
- # P | String | pointer to a structure (fixed-length string)
- # p | String | pointer to a null-terminated string
- #
- # Misc. | |
- # Directive | Returns | Meaning
- # -----------------------------------------------------------------
- # @ | --- | skip to the offset given by the length argument
- # X | --- | skip backward one byte
- # x | --- | skip forward one byte
- #
- # HISTORY
- #
- # * J, J! j, and j! are available since Ruby 2.3.
- # * Q_, Q!, q_, and q! are available since Ruby 2.1.
- # * I!<, i!<, I!>, and i!> are available since Ruby 1.9.3.
- def unpack(fmt)
- __builtin_pack_unpack(fmt)
- end
-
- # call-seq:
- # str.unpack1(format) -> obj
- #
- # Decodes <i>str</i> (which may contain binary data) according to the
- # format string, returning the first value extracted.
- # See also String#unpack, Array#pack.
- #
- # Contrast with String#unpack:
- #
- # "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "]
- # "abc \0\0abc \0\0".unpack1('A6Z6') #=> "abc"
- #
- # In that case data would be lost but often it's the case that the array
- # only holds one value, especially when unpacking binary data. For instance:
- #
- # "\xff\x00\x00\x00".unpack("l") #=> [255]
- # "\xff\x00\x00\x00".unpack1("l") #=> 255
- #
- # Thus unpack1 is convenient, makes clear the intention and signals
- # the expected return value to those reading the code.
- def unpack1(fmt)
- __builtin_pack_unpack1(fmt)
- end
-end
diff --git a/parse.y b/parse.y
index 2bf825a052..383e76f991 100644
--- a/parse.y
+++ b/parse.y
@@ -14,10 +14,13 @@
#if !YYPURE
# error needs pure parser
#endif
+#ifndef PARSER_DEBUG
+#define PARSER_DEBUG 0
+#endif
#define YYDEBUG 1
#define YYERROR_VERBOSE 1
#define YYSTACK_USE_ALLOCA 0
-#define YYLTYPE rb_code_location_t
+#define YYLTYPE rb_code_range_t
#define YYLTYPE_IS_DECLARED 1
#include "ruby/ruby.h"
@@ -39,43 +42,41 @@
#define TAB_WIDTH 8
-#define yydebug (p->debug) /* disable the global variable definition */
-
-#define YYMALLOC(size) rb_parser_malloc(p, (size))
-#define YYREALLOC(ptr, size) rb_parser_realloc(p, (ptr), (size))
-#define YYCALLOC(nelem, size) rb_parser_calloc(p, (nelem), (size))
-#define YYFREE(ptr) rb_parser_free(p, (ptr))
+#define YYMALLOC(size) rb_parser_malloc(parser, (size))
+#define YYREALLOC(ptr, size) rb_parser_realloc(parser, (ptr), (size))
+#define YYCALLOC(nelem, size) rb_parser_calloc(parser, (nelem), (size))
+#define YYFREE(ptr) rb_parser_free(parser, (ptr))
#define YYFPRINTF rb_parser_printf
-#define YYPRINT(out, tok, val) parser_token_value_print(p, (tok), &(val))
-#define YY_LOCATION_PRINT(File, loc) \
- rb_parser_printf(p, "%d.%d-%d.%d", \
- (loc).beg_pos.lineno, (loc).beg_pos.column,\
- (loc).end_pos.lineno, (loc).end_pos.column)
+#define YY_LOCATION_PRINT(File, Loc) \
+ rb_parser_printf(parser, "%d.%d-%d.%d", \
+ (Loc).first_loc.lineno, (Loc).first_loc.column,\
+ (Loc).last_loc.lineno, (Loc).last_loc.column)
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
- (Current).beg_pos = YYRHSLOC(Rhs, 1).beg_pos; \
- (Current).end_pos = YYRHSLOC(Rhs, N).end_pos; \
+ (Current).first_loc = YYRHSLOC(Rhs, 1).first_loc; \
+ (Current).last_loc = YYRHSLOC(Rhs, N).last_loc; \
} \
else \
- { \
- (Current).beg_pos = YYRHSLOC(Rhs, 0).end_pos; \
- (Current).end_pos = YYRHSLOC(Rhs, 0).end_pos; \
- } \
+ RUBY_SET_YYLLOC_OF_NONE(Current); \
while (0)
#define RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(Current) \
- rb_parser_set_location_from_strterm_heredoc(p, &p->lex.strterm->u.heredoc, &(Current))
+ rb_parser_set_location_from_strterm_heredoc(parser, &lex_strterm->u.heredoc, &(Current))
#define RUBY_SET_YYLLOC_OF_NONE(Current) \
- rb_parser_set_location_of_none(p, &(Current))
+ rb_parser_set_location_of_none(parser, &(Current))
#define RUBY_SET_YYLLOC(Current) \
- rb_parser_set_location(p, &(Current))
-#define RUBY_INIT_YYLLOC() \
- { \
- {p->ruby_sourceline, (int)(p->lex.ptok - p->lex.pbeg)}, \
- {p->ruby_sourceline, (int)(p->lex.pcur - p->lex.pbeg)}, \
- }
+ rb_parser_set_location(parser, &(Current))
+
+#undef malloc
+#undef realloc
+#undef calloc
+#undef free
+#define malloc YYMALLOC
+#define realloc YYREALLOC
+#define calloc YYCALLOC
+#define free YYFREE
enum lex_state_bits {
EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
@@ -112,41 +113,37 @@ enum lex_state_e {
EXPR_VALUE = EXPR_BEG,
EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
- EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
- EXPR_NONE = 0
+ EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN)
};
#define IS_lex_state_for(x, ls) ((x) & (ls))
#define IS_lex_state_all_for(x, ls) (((x) & (ls)) == (ls))
-#define IS_lex_state(ls) IS_lex_state_for(p->lex.state, (ls))
-#define IS_lex_state_all(ls) IS_lex_state_all_for(p->lex.state, (ls))
+#define IS_lex_state(ls) IS_lex_state_for(lex_state, (ls))
+#define IS_lex_state_all(ls) IS_lex_state_all_for(lex_state, (ls))
# define SET_LEX_STATE(ls) \
- (p->lex.state = \
- (p->debug ? \
- rb_parser_trace_lex_state(p, p->lex.state, (ls), __LINE__) : \
+ (lex_state = \
+ (yydebug ? \
+ rb_parser_trace_lex_state(parser, lex_state, (ls), __LINE__) : \
(enum lex_state_e)(ls)))
typedef VALUE stack_type;
-static const rb_code_location_t NULL_LOC = { {0, -1}, {0, -1} };
-
-# define SHOW_BITSTACK(stack, name) (p->debug ? rb_parser_show_bitstack(p, stack, name, __LINE__) : (void)0)
-# define BITSTACK_PUSH(stack, n) (((p->stack) = ((p->stack)<<1)|((n)&1)), SHOW_BITSTACK(p->stack, #stack"(push)"))
-# define BITSTACK_POP(stack) (((p->stack) = (p->stack) >> 1), SHOW_BITSTACK(p->stack, #stack"(pop)"))
-# define BITSTACK_SET_P(stack) (SHOW_BITSTACK(p->stack, #stack), (p->stack)&1)
-# define BITSTACK_SET(stack, n) ((p->stack)=(n), SHOW_BITSTACK(p->stack, #stack"(set)"))
+# define SHOW_BITSTACK(stack, name) (yydebug ? rb_parser_show_bitstack(parser, stack, name, __LINE__) : (void)0)
+# define BITSTACK_PUSH(stack, n) (((stack) = ((stack)<<1)|((n)&1)), SHOW_BITSTACK(stack, #stack"(push)"))
+# define BITSTACK_POP(stack) (((stack) = (stack) >> 1), SHOW_BITSTACK(stack, #stack"(pop)"))
+# define BITSTACK_LEXPOP(stack) (((stack) = ((stack) >> 1) | ((stack) & 1)), SHOW_BITSTACK(stack, #stack"(lexpop)"))
+# define BITSTACK_SET_P(stack) (SHOW_BITSTACK(stack, #stack), (stack)&1)
+# define BITSTACK_SET(stack, n) ((stack)=(n), SHOW_BITSTACK(stack, #stack"(set)"))
-/* A flag to identify keyword_do_cond, "do" keyword after condition expression.
- Examples: `while ... do`, `until ... do`, and `for ... in ... do` */
#define COND_PUSH(n) BITSTACK_PUSH(cond_stack, (n))
#define COND_POP() BITSTACK_POP(cond_stack)
+#define COND_LEXPOP() BITSTACK_LEXPOP(cond_stack)
#define COND_P() BITSTACK_SET_P(cond_stack)
#define COND_SET(n) BITSTACK_SET(cond_stack, (n))
-/* A flag to identify keyword_do_block; "do" keyword after command_call.
- Example: `foo 1, 2 do`. */
#define CMDARG_PUSH(n) BITSTACK_PUSH(cmdarg_stack, (n))
#define CMDARG_POP() BITSTACK_POP(cmdarg_stack)
+#define CMDARG_LEXPOP() BITSTACK_LEXPOP(cmdarg_stack)
#define CMDARG_P() BITSTACK_SET_P(cmdarg_stack)
#define CMDARG_SET(n) BITSTACK_SET(cmdarg_stack, (n))
@@ -165,39 +162,18 @@ struct local_vars {
struct vtable *past;
# endif
struct local_vars *prev;
-# ifndef RIPPER
- struct {
- NODE *outer, *inner, *current;
- } numparam;
-# endif
+ stack_type cmdargs;
};
-enum {
- ORDINAL_PARAM = -1,
- NO_PARAM = 0,
- NUMPARAM_MAX = 9,
-};
-
-#define NUMPARAM_ID_P(id) numparam_id_p(id)
-#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - tNUMPARAM_1 + 1)
-#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_1 + (idx) - 1))
-static int
-numparam_id_p(ID id)
-{
- if (!is_local_id(id)) return 0;
- unsigned int idx = NUMPARAM_ID_TO_IDX(id);
- return idx > 0 && idx <= NUMPARAM_MAX;
-}
-static void numparam_name(struct parser_params *p, ID id);
-
#define DVARS_INHERIT ((void*)1)
#define DVARS_TOPSCOPE NULL
-#define DVARS_TERMINAL_P(tbl) ((tbl) == DVARS_INHERIT || (tbl) == DVARS_TOPSCOPE)
+#define DVARS_SPECIAL_P(tbl) (!POINTER_P(tbl))
+#define POINTER_P(val) ((VALUE)(val) & ~(VALUE)3)
typedef struct token_info {
const char *token;
- rb_code_position_t beg;
- int indent;
+ int linenum;
+ int column;
int nonspc;
struct token_info *next;
} token_info;
@@ -207,14 +183,14 @@ typedef struct rb_strterm_struct rb_strterm_t;
/*
Structure of Lexer Buffer:
- lex.pbeg lex.ptok lex.pcur lex.pend
- | | | |
- |------------+------------+------------|
- |<---------->|
+ lex_pbeg tokp lex_p lex_pend
+ | | | |
+ |-----------+--------------+------------|
+ |<------------>|
token
*/
struct parser_params {
- rb_imemo_tmpbuf_t *heap;
+ rb_imemo_alloc_t *heap;
YYSTYPE *lval;
@@ -229,16 +205,10 @@ struct parser_params {
const char *pcur;
const char *pend;
const char *ptok;
- union {
- long ptr;
- VALUE (*call)(VALUE, int);
- } gets_;
+ long gets_ptr;
enum lex_state_e state;
- /* track the nest level of any parens "()[]{}" */
int paren_nest;
- /* keep p->lex.paren_nest at the beginning of lambda "->" to detect tLAMBEG and keyword_do_LAMBDA */
int lpar_beg;
- /* track the nest level of only braces "{}" */
int brace_nest;
} lex;
stack_type cond_stack;
@@ -251,15 +221,12 @@ struct parser_params {
int heredoc_line_indent;
char *tokenbuf;
struct local_vars *lvtbl;
- st_table *pvtbl;
- st_table *pktbl;
int line_count;
int ruby_sourceline; /* current line no. */
- const char *ruby_sourcefile; /* current source file */
+ char *ruby_sourcefile; /* current source file */
VALUE ruby_sourcefile_string;
rb_encoding *enc;
token_info *token_info;
- VALUE case_labels;
VALUE compile_option;
VALUE debug_buffer;
@@ -268,16 +235,14 @@ struct parser_params {
ID cur_arg;
rb_ast_t *ast;
- int node_id;
-
- int max_numparam;
unsigned int command_start:1;
unsigned int eofp: 1;
unsigned int ruby__end__seen: 1;
- unsigned int debug: 1;
+ unsigned int yydebug: 1;
unsigned int has_shebang: 1;
unsigned int in_defined: 1;
+ unsigned int in_main: 1;
unsigned int in_kwarg: 1;
unsigned int in_def: 1;
unsigned int in_class: 1;
@@ -296,21 +261,19 @@ struct parser_params {
unsigned int do_loop: 1;
unsigned int do_chomp: 1;
unsigned int do_split: 1;
- unsigned int warn_location: 1;
NODE *eval_tree_begin;
NODE *eval_tree;
VALUE error_buffer;
VALUE debug_lines;
- const struct rb_iseq_struct *parent_iseq;
+ VALUE coverage;
+ const struct rb_block *base_block;
#else
/* Ripper only */
- struct {
- VALUE token;
- int line;
- int col;
- } delayed;
+ VALUE delayed;
+ int delayed_line;
+ int delayed_col;
VALUE value;
VALUE result;
@@ -320,99 +283,98 @@ struct parser_params {
#define intern_cstr(n,l,en) rb_intern3(n,l,en)
-#define STR_NEW(ptr,len) rb_enc_str_new((ptr),(len),p->enc)
-#define STR_NEW0() rb_enc_str_new(0,0,p->enc)
-#define STR_NEW2(ptr) rb_enc_str_new((ptr),strlen(ptr),p->enc)
-#define STR_NEW3(ptr,len,e,func) parser_str_new((ptr),(len),(e),(func),p->enc)
-#define TOK_INTERN() intern_cstr(tok(p), toklen(p), p->enc)
-
-static st_table *
-push_pvtbl(struct parser_params *p)
-{
- st_table *tbl = p->pvtbl;
- p->pvtbl = st_init_numtable();
- return tbl;
-}
-
-static void
-pop_pvtbl(struct parser_params *p, st_table *tbl)
-{
- st_free_table(p->pvtbl);
- p->pvtbl = tbl;
-}
-
-static st_table *
-push_pktbl(struct parser_params *p)
-{
- st_table *tbl = p->pktbl;
- p->pktbl = 0;
- return tbl;
-}
-
-static void
-pop_pktbl(struct parser_params *p, st_table *tbl)
-{
- if (p->pktbl) st_free_table(p->pktbl);
- p->pktbl = tbl;
-}
-
-static int parser_yyerror(struct parser_params*, const YYLTYPE *yylloc, const char*);
-#define yyerror0(msg) parser_yyerror(p, NULL, (msg))
-#define yyerror1(loc, msg) parser_yyerror(p, (loc), (msg))
-#define yyerror(yylloc, p, msg) parser_yyerror(p, yylloc, msg)
-#define token_flush(ptr) ((ptr)->lex.ptok = (ptr)->lex.pcur)
-
+#define STR_NEW(p,n) rb_enc_str_new((p),(n),current_enc)
+#define STR_NEW0() rb_enc_str_new(0,0,current_enc)
+#define STR_NEW2(p) rb_enc_str_new((p),strlen(p),current_enc)
+#define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),current_enc)
+#define TOK_INTERN() intern_cstr(tok(), toklen(), current_enc)
+
+static int parser_yyerror(struct parser_params*, const char*);
+#define yyerror0(msg) parser_yyerror(parser, (msg))
+#define yyerror(yylloc, parser, msg) yyerror0(msg)
+#define token_flush(p) ((p)->lex.ptok = (p)->lex.pcur)
+
+#define lex_strterm (parser->lex.strterm)
+#define lex_state (parser->lex.state)
+#define cond_stack (parser->cond_stack)
+#define cmdarg_stack (parser->cmdarg_stack)
+#define paren_nest (parser->lex.paren_nest)
+#define lpar_beg (parser->lex.lpar_beg)
+#define brace_nest (parser->lex.brace_nest)
+#define in_def (parser->in_def)
+#define in_class (parser->in_class)
+#define in_main (parser->in_main)
+#define in_defined (parser->in_defined)
+#define tokenbuf (parser->tokenbuf)
+#define tokidx (parser->tokidx)
+#define toksiz (parser->toksiz)
+#define tokline (parser->tokline)
+#define lex_input (parser->lex.input)
+#define lex_prevline (parser->lex.prevline)
+#define lex_lastline (parser->lex.lastline)
+#define lex_nextline (parser->lex.nextline)
+#define lex_pbeg (parser->lex.pbeg)
+#define lex_p (parser->lex.pcur)
+#define lex_pend (parser->lex.pend)
+#define heredoc_end (parser->heredoc_end)
+#define heredoc_indent (parser->heredoc_indent)
+#define heredoc_line_indent (parser->heredoc_line_indent)
+#define command_start (parser->command_start)
+#define lex_gets_ptr (parser->lex.gets_ptr)
+#define lex_gets (parser->lex.gets)
+#define lvtbl (parser->lvtbl)
+#define ruby__end__seen (parser->ruby__end__seen)
+#define ruby_sourceline (parser->ruby_sourceline)
+#define ruby_sourcefile (parser->ruby_sourcefile)
+#define ruby_sourcefile_string (parser->ruby_sourcefile_string)
+#define current_enc (parser->enc)
+#define current_arg (parser->cur_arg)
+#define yydebug (parser->yydebug)
#ifdef RIPPER
#define compile_for_eval (0)
#else
-#define compile_for_eval (p->parent_iseq != 0)
+#define compile_for_eval (parser->base_block != 0 && !in_main)
+#define ruby_eval_tree (parser->eval_tree)
+#define ruby_eval_tree_begin (parser->eval_tree_begin)
+#define ruby_debug_lines (parser->debug_lines)
+#define ruby_coverage (parser->coverage)
#endif
+#define tokp lex.ptok
-#define token_column ((int)(p->lex.ptok - p->lex.pbeg))
+#define token_column ((int)(parser->tokp - lex_pbeg))
#define CALL_Q_P(q) ((q) == TOKEN2VAL(tANDDOT))
#define NODE_CALL_Q(q) (CALL_Q_P(q) ? NODE_QCALL : NODE_CALL)
-#define NEW_QCALL(q,r,m,a,loc) NEW_NODE(NODE_CALL_Q(q),r,m,a,loc)
+#define NEW_QCALL(q,r,m,a) NEW_NODE(NODE_CALL_Q(q),r,m,a)
-#define lambda_beginning_p() (p->lex.lpar_beg == p->lex.paren_nest)
+#define lambda_beginning_p() (lpar_beg && lpar_beg == paren_nest)
static enum yytokentype yylex(YYSTYPE*, YYLTYPE*, struct parser_params*);
#ifndef RIPPER
static inline void
-rb_discard_node(struct parser_params *p, NODE *n)
+rb_discard_node_gen(struct parser_params *parser, NODE *n)
{
- rb_ast_delete_node(p->ast, n);
+ rb_ast_delete_node(parser->ast, n);
}
+#define rb_discard_node(n) rb_discard_node_gen(parser, (n))
#endif
-#ifdef RIPPER
-static inline VALUE
-add_mark_object(struct parser_params *p, VALUE obj)
+static inline void
+add_mark_object_gen(struct parser_params *parser, VALUE obj)
{
if (!SPECIAL_CONST_P(obj)
+#ifdef RIPPER
&& !RB_TYPE_P(obj, T_NODE) /* Ripper jumbles NODE objects and other objects... */
+#endif
) {
- rb_ast_add_mark_object(p->ast, obj);
+ rb_ast_add_mark_object(parser->ast, obj);
}
- return obj;
}
-#else
-static NODE* node_newnode_with_locals(struct parser_params *, enum node_type, VALUE, VALUE, const rb_code_location_t*);
-#endif
+#define add_mark_object(obj) add_mark_object_gen(parser, (obj))
-static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_location_t*);
-#define rb_node_newnode(type, a1, a2, a3, loc) node_newnode(p, (type), (a1), (a2), (a3), (loc))
-
-static NODE *nd_set_loc(NODE *nd, const YYLTYPE *loc);
-
-static int
-parser_get_node_id(struct parser_params *p)
-{
- int node_id = p->node_id;
- p->node_id++;
- return node_id;
-}
+static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE);
+#define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3))
#ifndef RIPPER
static inline void
@@ -428,124 +390,231 @@ set_line_body(NODE *body, int line)
#define yyparse ruby_yyparse
-static NODE* cond(struct parser_params *p, NODE *node, const YYLTYPE *loc);
-static NODE* method_cond(struct parser_params *p, NODE *node, const YYLTYPE *loc);
-#define new_nil(loc) NEW_NIL(loc)
-static NODE *new_if(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
-static NODE *new_unless(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
-static NODE *logop(struct parser_params*,ID,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*);
+static NODE *cond_gen(struct parser_params*,NODE*,int,const YYLTYPE*);
+#define cond(node,location) cond_gen(parser, (node), FALSE, location)
+#define method_cond(node,location) cond_gen(parser, (node), TRUE, location)
+static NODE *new_nil_gen(struct parser_params*,const YYLTYPE*);
+#define new_nil(location) new_nil_gen(parser,location)
+static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
+#define new_if(cc,left,right,location) new_if_gen(parser, (cc), (left), (right), (location))
+static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
+#define new_unless(cc,left,right,location) new_unless_gen(parser, (cc), (left), (right), (location))
+static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*);
+#define logop(id,node1,node2,op_loc,location) \
+ logop_gen(parser, ((id)==idAND||(id)==idANDOP)?NODE_AND:NODE_OR, \
+ (node1), (node2), (op_loc), (location))
static NODE *newline_node(NODE*);
static void fixpos(NODE*,NODE*);
static int value_expr_gen(struct parser_params*,NODE*);
-static void void_expr(struct parser_params*,NODE*);
+static void void_expr_gen(struct parser_params*,NODE*);
static NODE *remove_begin(NODE*);
static NODE *remove_begin_all(NODE*);
-#define value_expr(node) value_expr_gen(p, (node) = remove_begin(node))
-static NODE *void_stmts(struct parser_params*,NODE*);
-static void reduce_nodes(struct parser_params*,NODE**);
-static void block_dup_check(struct parser_params*,NODE*,NODE*);
-
-static NODE *block_append(struct parser_params*,NODE*,NODE*);
-static NODE *list_append(struct parser_params*,NODE*,NODE*);
+#define value_expr(node) value_expr_gen(parser, (node) = remove_begin(node))
+#define void_expr0(node) void_expr_gen(parser, (node))
+#define void_expr(node) void_expr0((node) = remove_begin(node))
+static void void_stmts_gen(struct parser_params*,NODE*);
+#define void_stmts(node) void_stmts_gen(parser, (node))
+static void reduce_nodes_gen(struct parser_params*,NODE**);
+#define reduce_nodes(n) reduce_nodes_gen(parser,(n))
+static void block_dup_check_gen(struct parser_params*,NODE*,NODE*);
+#define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2))
+
+static NODE *block_append_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
+#define block_append(h,t,location) block_append_gen(parser,(h),(t),(location))
+static NODE *list_append_gen(struct parser_params*,NODE*,NODE*);
+#define list_append(l,i) list_append_gen(parser,(l),(i))
static NODE *list_concat(NODE*,NODE*);
-static NODE *arg_append(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-static NODE *last_arg_append(struct parser_params *p, NODE *args, NODE *last_arg, const YYLTYPE *loc);
-static NODE *rest_arg_append(struct parser_params *p, NODE *args, NODE *rest_arg, const YYLTYPE *loc);
-static NODE *literal_concat(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-static NODE *new_evstr(struct parser_params*,NODE*,const YYLTYPE*);
-static NODE *evstr2dstr(struct parser_params*,NODE*);
+static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
+#define arg_append(h,t,location) arg_append_gen(parser,(h),(t),(location))
+static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
+#define arg_concat(h,t,location) arg_concat_gen(parser,(h),(t),(location))
+static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
+#define literal_concat(h,t,location) literal_concat_gen(parser,(h),(t),(location))
+static int literal_concat0(struct parser_params *, VALUE, VALUE);
+static NODE *new_evstr_gen(struct parser_params*,NODE*,const YYLTYPE*);
+#define new_evstr(n, location) new_evstr_gen(parser,(n),(location))
+static NODE *evstr2dstr_gen(struct parser_params*,NODE*);
+#define evstr2dstr(n) evstr2dstr_gen(parser,(n))
static NODE *splat_array(NODE*);
-static void mark_lvar_used(struct parser_params *p, NODE *rhs);
-
-static NODE *call_bin_op(struct parser_params*,NODE*,ID,NODE*,const YYLTYPE*,const YYLTYPE*);
-static NODE *call_uni_op(struct parser_params*,NODE*,ID,const YYLTYPE*,const YYLTYPE*);
-static NODE *new_qcall(struct parser_params* p, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_loc, const YYLTYPE *loc);
-static NODE *new_command_qcall(struct parser_params* p, ID atype, NODE *recv, ID mid, NODE *args, NODE *block, const YYLTYPE *op_loc, const YYLTYPE *loc);
-static NODE *method_add_block(struct parser_params*p, NODE *m, NODE *b, const YYLTYPE *loc) {b->nd_iter = m; b->nd_loc = *loc; return b;}
-
-static bool args_info_empty_p(struct rb_args_info *args);
-static NODE *new_args(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*,const YYLTYPE*);
-static NODE *new_args_tail(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
-static NODE *new_array_pattern(struct parser_params *p, NODE *constant, NODE *pre_arg, NODE *aryptn, const YYLTYPE *loc);
-static NODE *new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID rest_arg, NODE *post_args, const YYLTYPE *loc);
-static NODE *new_hash_pattern(struct parser_params *p, NODE *constant, NODE *hshptn, const YYLTYPE *loc);
-static NODE *new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, const YYLTYPE *loc);
-static NODE *new_case3(struct parser_params *p, NODE *val, NODE *pat, const YYLTYPE *loc);
-
-static NODE *new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc);
-static NODE *args_with_numbered(struct parser_params*,NODE*,int);
-
-static VALUE negate_lit(struct parser_params*, VALUE);
-static NODE *ret_args(struct parser_params*,NODE*);
+
+static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*,const YYLTYPE*,const YYLTYPE*);
+#define call_bin_op(recv,id,arg1,op_loc,location) call_bin_op_gen(parser, (recv),(id),(arg1),(op_loc),(location))
+static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID,const YYLTYPE*,const YYLTYPE*);
+#define call_uni_op(recv,id,op_loc,location) call_uni_op_gen(parser, (recv),(id),(op_loc),(location))
+static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *location);
+#define new_qcall(q,r,m,a,location) new_qcall_gen(parser,q,r,m,a,location)
+#define new_command_qcall(q,r,m,a,location) new_qcall_gen(parser,q,r,m,a,location)
+static NODE *new_command_gen(struct parser_params*parser, NODE *m, NODE *a) {m->nd_args = a; return m;}
+#define new_command(m,a) new_command_gen(parser, m, a)
+static NODE *method_add_block_gen(struct parser_params*parser, NODE *m, NODE *b) {b->nd_iter = m; return b;}
+#define method_add_block(m,b) method_add_block_gen(parser, m, b)
+
+static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*,const YYLTYPE*);
+#define new_args(f,o,r,p,t,location) new_args_gen(parser, (f),(o),(r),(p),(t),(location))
+static NODE *new_args_tail_gen(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
+#define new_args_tail(k,kr,b,location) new_args_tail_gen(parser, (k),(kr),(b),(location))
+static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *location);
+#define new_kw_arg(k,location) new_kw_arg_gen(parser, k, location)
+
+static VALUE negate_lit_gen(struct parser_params*, VALUE);
+#define negate_lit(lit) negate_lit_gen(parser, lit)
+static NODE *ret_args_gen(struct parser_params*,NODE*);
+#define ret_args(node) ret_args_gen(parser, (node))
static NODE *arg_blk_pass(NODE*,NODE*);
-static NODE *new_yield(struct parser_params*,NODE*,const YYLTYPE*);
-static NODE *dsym_node(struct parser_params*,NODE*,const YYLTYPE*);
+static NODE *new_yield_gen(struct parser_params*,NODE*,const YYLTYPE*);
+#define new_yield(node,location) new_yield_gen(parser, (node), (location))
+static NODE *dsym_node_gen(struct parser_params*,NODE*,const YYLTYPE*);
+#define dsym_node(node,location) dsym_node_gen(parser, (node), (location))
+
+static NODE *gettable_gen(struct parser_params*,ID,const YYLTYPE*);
+#define gettable(id,location) gettable_gen(parser,(id),(location))
+static NODE *assignable_gen(struct parser_params*,ID,NODE*,const YYLTYPE*);
+#define assignable(id,node,location) assignable_gen(parser, (id), (node), (location))
+
+static NODE *aryset_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
+#define aryset(node1,node2,location) aryset_gen(parser, (node1), (node2), (location))
+static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
+#define attrset(node,q,id,location) attrset_gen(parser, (node), (q), (id), (location))
+
+static void rb_backref_error_gen(struct parser_params*,NODE*);
+#define rb_backref_error(n) rb_backref_error_gen(parser,(n))
+static NODE *node_assign_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
+#define node_assign(node1, node2, location) node_assign_gen(parser, (node1), (node2), (location))
+
+static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *location);
+#define new_op_assign(lhs, op, rhs, location) new_op_assign_gen(parser, (lhs), (op), (rhs), (location))
+static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *location);
+#define new_attr_op_assign(lhs, type, attr, op, rhs, location) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (location))
+static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *location);
+#define new_const_op_assign(lhs, op, rhs, location) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (location))
+
+static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *location);
+#define const_path_field(w, n, location) const_path_field_gen(parser, w, n, location)
+#define top_const_field(n) NEW_COLON3(n)
+static NODE *const_decl_gen(struct parser_params *parser, NODE* path, const YYLTYPE *location);
+#define const_decl(path, location) const_decl_gen(parser, path, location)
+
+#define var_field(n) (n)
+#define backref_assign_error(n, a, location) (rb_backref_error(n), new_begin(0, location))
-static NODE *gettable(struct parser_params*,ID,const YYLTYPE*);
-static NODE *assignable(struct parser_params*,ID,NODE*,const YYLTYPE*);
+static NODE *opt_arg_append(NODE*, NODE*);
+static NODE *kwd_append(NODE*, NODE*);
-static NODE *aryset(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-static NODE *attrset(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
+static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *location);
+#define new_hash(hash, location) new_hash_gen(parser, (hash), location)
-static void rb_backref_error(struct parser_params*,NODE*);
-static NODE *node_assign(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
+static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *location);
+#define new_defined(expr, location) new_defined_gen(parser, expr, location)
-static NODE *new_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc);
-static NODE *new_ary_op_assign(struct parser_params *p, NODE *ary, NODE *args, ID op, NODE *rhs, const YYLTYPE *args_loc, const YYLTYPE *loc);
-static NODE *new_attr_op_assign(struct parser_params *p, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc);
-static NODE *new_const_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc);
-static NODE *new_bodystmt(struct parser_params *p, NODE *head, NODE *rescue, NODE *rescue_else, NODE *ensure, const YYLTYPE *loc);
+static NODE *new_regexp_gen(struct parser_params *, NODE *, int, const YYLTYPE *);
+#define new_regexp(node, opt, location) new_regexp_gen(parser, node, opt, location)
-static NODE *const_decl(struct parser_params *p, NODE* path, const YYLTYPE *loc);
+static NODE *new_lit_gen(struct parser_params *parser, VALUE sym, const YYLTYPE *location);
+#define new_lit(sym, location) new_lit_gen(parser, sym, location)
-static NODE *opt_arg_append(NODE*, NODE*);
-static NODE *kwd_append(NODE*, NODE*);
+static NODE *new_list_gen(struct parser_params *parser, NODE *item, const YYLTYPE *location);
+#define new_list(item, location) new_list_gen(parser, item, location)
+
+static NODE *new_str_gen(struct parser_params *parser, VALUE str, const YYLTYPE *location);
+#define new_str(s,location) new_str_gen(parser, s, location)
+
+static NODE *new_dvar_gen(struct parser_params *parser, ID id, const YYLTYPE *location);
+#define new_dvar(id, location) new_dvar_gen(parser, id, location)
+
+static NODE *new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, const YYLTYPE *location);
+#define new_resbody(e,s,r,location) new_resbody_gen(parser, (e),(s),(r),(location))
+
+static NODE *new_errinfo_gen(struct parser_params *parser, const YYLTYPE *location);
+#define new_errinfo(location) new_errinfo_gen(parser, location)
+
+static NODE *new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, const YYLTYPE *location);
+#define new_call(recv,mid,args,location) new_call_gen(parser, recv,mid,args,location)
+
+static NODE *new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, const YYLTYPE *location);
+#define new_fcall(mid,args,location) new_fcall_gen(parser, mid, args, location)
+
+static NODE *new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, const YYLTYPE *location);
+#define new_for(var,iter,body,location) new_for_gen(parser, var, iter, body, location)
+
+static NODE *new_gvar_gen(struct parser_params *parser, ID id, const YYLTYPE *location);
+#define new_gvar(id, location) new_gvar_gen(parser, id, location)
+
+static NODE *new_lvar_gen(struct parser_params *parser, ID id, const YYLTYPE *location);
+#define new_lvar(id, location) new_lvar_gen(parser, id, location)
-static NODE *new_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc);
-static NODE *new_unique_key_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc);
+static NODE *new_dstr_gen(struct parser_params *parser, VALUE str, const YYLTYPE *location);
+#define new_dstr(s, location) new_dstr_gen(parser, s, location)
-static NODE *new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc);
+static NODE *new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, const YYLTYPE *location);
+#define new_rescue(b,res,e,location) new_rescue_gen(parser,b,res,e,location)
-static NODE *new_regexp(struct parser_params *, NODE *, int, const YYLTYPE *);
+static NODE *new_undef_gen(struct parser_params *parser, NODE *i, const YYLTYPE *location);
+#define new_undef(i, location) new_undef_gen(parser, i, location)
-#define make_list(list, loc) ((list) ? (nd_set_loc(list, loc), list) : NEW_ZLIST(loc))
+static NODE *nd_set_loc(NODE *nd, const YYLTYPE *location);
+static NODE *new_zarray_gen(struct parser_params *parser, const YYLTYPE *location);
+#define new_zarray(location) new_zarray_gen(parser, location)
+#define make_array(ary, location) ((ary) ? (nd_set_loc(ary, location), ary) : new_zarray(location))
-static NODE *new_xstring(struct parser_params *, NODE *, const YYLTYPE *loc);
+static NODE *new_ivar_gen(struct parser_params *parser, ID id, const YYLTYPE *location);
+#define new_ivar(id, location) new_ivar_gen(parser,id,location)
-static NODE *symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol);
+static NODE *new_postarg_gen(struct parser_params *parser, NODE *i, NODE *v, const YYLTYPE *location);
+#define new_postarg(i,v,location) new_postarg_gen(parser,i,v,location)
-static NODE *match_op(struct parser_params*,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*);
+static NODE *new_cdecl_gen(struct parser_params *parser, ID v, NODE *val, NODE *path, const YYLTYPE *location);
+#define new_cdecl(v,val,path,location) new_cdecl_gen(parser,v,val,path,location)
-static ID *local_tbl(struct parser_params*);
+static NODE *new_scope_gen(struct parser_params *parser, NODE *a, NODE *b, const YYLTYPE *location);
+#define new_scope(a,b,location) new_scope_gen(parser,a,b,location)
-static VALUE reg_compile(struct parser_params*, VALUE, int);
-static void reg_fragment_setenc(struct parser_params*, VALUE, int);
-static int reg_fragment_check(struct parser_params*, VALUE, int);
-static NODE *reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *loc);
+static NODE *new_begin_gen(struct parser_params *parser, NODE *b, const YYLTYPE *location);
+#define new_begin(b,location) new_begin_gen(parser,b,location)
-static int literal_concat0(struct parser_params *p, VALUE head, VALUE tail);
-static NODE *heredoc_dedent(struct parser_params*,NODE*);
+static NODE *new_masgn_gen(struct parser_params *parser, NODE *l, NODE *r, const YYLTYPE *location);
+#define new_masgn(l,r,location) new_masgn_gen(parser,l,r,location)
-static void check_literal_when(struct parser_params *p, NODE *args, const YYLTYPE *loc);
+static NODE *new_xstring_gen(struct parser_params *, NODE *, const YYLTYPE *location);
+#define new_xstring(node, location) new_xstring_gen(parser, node, location)
+#define new_string1(str) (str)
+
+static NODE *new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *location);
+#define new_brace_body(param, stmt, location) new_body_gen(parser, param, stmt, location)
+#define new_do_body(param, stmt, location) new_body_gen(parser, param, stmt, location)
+
+static NODE *match_op_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*);
+#define match_op(node1,node2,op_loc,location) match_op_gen(parser, (node1), (node2), (op_loc), (location))
+
+static ID *local_tbl_gen(struct parser_params*);
+#define local_tbl() local_tbl_gen(parser)
+
+static VALUE reg_compile_gen(struct parser_params*, VALUE, int);
+#define reg_compile(str,options) reg_compile_gen(parser, (str), (options))
+static void reg_fragment_setenc_gen(struct parser_params*, VALUE, int);
+#define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options))
+static int reg_fragment_check_gen(struct parser_params*, VALUE, int);
+#define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options))
+static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *location);
+#define reg_named_capture_assign(regexp,location) reg_named_capture_assign_gen(parser,(regexp),location)
+
+static NODE *parser_heredoc_dedent(struct parser_params*,NODE*);
+# define heredoc_dedent(str) parser_heredoc_dedent(parser, (str))
#define get_id(id) (id)
#define get_value(val) (val)
-#define get_num(num) (num)
#else /* RIPPER */
#define NODE_RIPPER NODE_CDECL
-static inline int ripper_is_node_yylval(VALUE n);
-
static inline VALUE
-ripper_new_yylval(struct parser_params *p, ID a, VALUE b, VALUE c)
+ripper_new_yylval_gen(struct parser_params *parser, ID a, VALUE b, VALUE c)
{
- if (ripper_is_node_yylval(c)) c = RNODE(c)->nd_cval;
- add_mark_object(p, b);
- add_mark_object(p, c);
- return (VALUE)NEW_CDECL(a, b, c, &NULL_LOC);
+ add_mark_object(b);
+ add_mark_object(c);
+ return (VALUE)NEW_CDECL(a, b, c);
}
+#define ripper_new_yylval(a, b, c) ripper_new_yylval_gen(parser, a, b, c)
static inline int
ripper_is_node_yylval(VALUE n)
@@ -555,31 +624,61 @@ ripper_is_node_yylval(VALUE n)
#define value_expr(node) ((void)(node))
#define remove_begin(node) (node)
-#define void_stmts(p,x) (x)
#define rb_dvar_defined(id, base) 0
#define rb_local_defined(id, base) 0
static ID ripper_get_id(VALUE);
#define get_id(id) ripper_get_id(id)
static VALUE ripper_get_value(VALUE);
#define get_value(val) ripper_get_value(val)
-#define get_num(num) (int)get_id(num)
-static VALUE assignable(struct parser_params*,VALUE);
-static int id_is_var(struct parser_params *p, ID id);
-
-#define method_cond(p,node,loc) (node)
-#define call_bin_op(p, recv,id,arg1,op_loc,loc) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1))
-#define match_op(p,node1,node2,op_loc,loc) call_bin_op(0, (node1), idEqTilde, (node2), op_loc, loc)
-#define call_uni_op(p, recv,id,op_loc,loc) dispatch2(unary, STATIC_ID2SYM(id), (recv))
-#define logop(p,id,node1,node2,op_loc,loc) call_bin_op(0, (node1), (id), (node2), op_loc, loc)
-
-#define new_nil(loc) Qnil
-
-static VALUE new_regexp(struct parser_params *, VALUE, VALUE, const YYLTYPE *);
-
-static VALUE const_decl(struct parser_params *p, VALUE path);
-
-static VALUE var_field(struct parser_params *p, VALUE a);
-static VALUE assign_error(struct parser_params *p, VALUE a);
+static VALUE assignable_gen(struct parser_params*,VALUE);
+#define assignable(lhs,node,location) assignable_gen(parser, (lhs))
+static int id_is_var_gen(struct parser_params *parser, ID id);
+#define id_is_var(id) id_is_var_gen(parser, (id))
+
+#define method_cond(node,location) (node)
+#define call_bin_op(recv,id,arg1,op_loc,location) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1))
+#define match_op(node1,node2,op_loc,location) call_bin_op((node1), idEqTilde, (node2), op_loc, location)
+#define call_uni_op(recv,id,op_loc,location) dispatch2(unary, STATIC_ID2SYM(id), (recv))
+#define logop(id,node1,node2,op_loc,location) call_bin_op((node1), (id), (node2), op_loc, location)
+#define node_assign(node1, node2, location) dispatch2(assign, (node1), (node2))
+static VALUE new_qcall_gen(struct parser_params *parser, VALUE q, VALUE r, VALUE m, VALUE a);
+#define new_qcall(q,r,m,a,location) new_qcall_gen(parser, (r), (q), (m), (a))
+#define new_command_qcall(q,r,m,a,location) dispatch4(command_call, (r), (q), (m), (a))
+#define new_command_call(q,r,m,a) dispatch4(command_call, (r), (q), (m), (a))
+#define new_command(m,a) dispatch2(command, (m), (a));
+
+#define new_nil(location) Qnil
+static VALUE new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs);
+#define new_op_assign(lhs, op, rhs, location) new_op_assign_gen(parser, (lhs), (op), (rhs))
+static VALUE new_attr_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE type, VALUE attr, VALUE op, VALUE rhs);
+#define new_attr_op_assign(lhs, type, attr, op, rhs, location) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
+#define new_const_op_assign(lhs, op, rhs, location) new_op_assign(lhs, op, rhs, location)
+
+static VALUE new_regexp_gen(struct parser_params *, VALUE, VALUE);
+#define new_regexp(node, opt, location) new_regexp_gen(parser, node, opt)
+
+static VALUE new_xstring_gen(struct parser_params *, VALUE);
+#define new_xstring(str, location) new_xstring_gen(parser, str)
+#define new_string1(str) dispatch1(string_literal, str)
+
+#define new_brace_body(param, stmt, location) dispatch2(brace_block, escape_Qundef(param), stmt)
+#define new_do_body(param, stmt, location) dispatch2(do_block, escape_Qundef(param), stmt)
+
+#define const_path_field(w, n, location) dispatch2(const_path_field, (w), (n))
+#define top_const_field(n) dispatch1(top_const_field, (n))
+static VALUE const_decl_gen(struct parser_params *parser, VALUE path);
+#define const_decl(path, location) const_decl_gen(parser, path)
+
+static VALUE var_field_gen(struct parser_params *parser, VALUE a);
+#define var_field(a) var_field_gen(parser, (a))
+static VALUE assign_error_gen(struct parser_params *parser, VALUE a);
+#define assign_error(a) assign_error_gen(parser, (a))
+#define backref_assign_error(n, a, location) assign_error(a)
+
+#define block_dup_check(n1,n2) ((void)(n1), (void)(n2))
+#define fixpos(n1,n2) ((void)(n1), (void)(n2))
+#undef nd_set_line
+#define nd_set_line(n,l) ((void)(n))
static VALUE parser_reg_compile(struct parser_params*, VALUE, int, VALUE *);
@@ -589,46 +688,53 @@ static VALUE parser_reg_compile(struct parser_params*, VALUE, int, VALUE *);
typedef struct rb_strterm_heredoc_struct rb_strterm_heredoc_t;
RUBY_SYMBOL_EXPORT_BEGIN
-VALUE rb_parser_reg_compile(struct parser_params* p, VALUE str, int options);
+VALUE rb_parser_reg_compile(struct parser_params* parser, VALUE str, int options);
int rb_reg_fragment_setenc(struct parser_params*, VALUE, int);
enum lex_state_e rb_parser_trace_lex_state(struct parser_params *, enum lex_state_e, enum lex_state_e, int);
VALUE rb_parser_lex_state_name(enum lex_state_e state);
void rb_parser_show_bitstack(struct parser_params *, stack_type, const char *, int);
-PRINTF_ARGS(void rb_parser_fatal(struct parser_params *p, const char *fmt, ...), 2, 3);
-YYLTYPE *rb_parser_set_location_from_strterm_heredoc(struct parser_params *p, rb_strterm_heredoc_t *here, YYLTYPE *yylloc);
-YYLTYPE *rb_parser_set_location_of_none(struct parser_params *p, YYLTYPE *yylloc);
-YYLTYPE *rb_parser_set_location(struct parser_params *p, YYLTYPE *yylloc);
+PRINTF_ARGS(void rb_parser_fatal(struct parser_params *parser, const char *fmt, ...), 2, 3);
+void rb_parser_set_location_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc);
+void rb_parser_set_location_of_none(struct parser_params *parser, YYLTYPE *yylloc);
+void rb_parser_set_location(struct parser_params *parser, YYLTYPE *yylloc);
RUBY_SYMBOL_EXPORT_END
-static void error_duplicate_pattern_variable(struct parser_params *p, ID id, const YYLTYPE *loc);
-static void error_duplicate_pattern_key(struct parser_params *p, ID id, const YYLTYPE *loc);
-static void parser_token_value_print(struct parser_params *p, enum yytokentype type, const YYSTYPE *valp);
-static ID formal_argument(struct parser_params*, ID);
-static ID shadowing_lvar(struct parser_params*,ID);
-static void new_bv(struct parser_params*,ID);
-
-static void local_push(struct parser_params*,int);
-static void local_pop(struct parser_params*);
-static void local_var(struct parser_params*, ID);
-static void arg_var(struct parser_params*, ID);
-static int local_id(struct parser_params *p, ID id);
-static int local_id_ref(struct parser_params*, ID, ID **);
-#ifndef RIPPER
-static ID internal_id(struct parser_params*);
-#endif
-
-static const struct vtable *dyna_push(struct parser_params *);
-static void dyna_pop(struct parser_params*, const struct vtable *);
-static int dyna_in_block(struct parser_params*);
-#define dyna_var(p, id) local_var(p, id)
-static int dvar_defined(struct parser_params*, ID);
-static int dvar_defined_ref(struct parser_params*, ID, ID**);
-static int dvar_curr(struct parser_params*,ID);
-
-static int lvar_defined(struct parser_params*, ID);
-
-static NODE *numparam_push(struct parser_params *p);
-static void numparam_pop(struct parser_params *p, NODE *prev_inner);
+static ID formal_argument_gen(struct parser_params*, ID);
+#define formal_argument(id) formal_argument_gen(parser, (id))
+static ID shadowing_lvar_gen(struct parser_params*,ID);
+#define shadowing_lvar(name) shadowing_lvar_gen(parser, (name))
+static void new_bv_gen(struct parser_params*,ID);
+#define new_bv(id) new_bv_gen(parser, (id))
+
+static void local_push_gen(struct parser_params*,int);
+#define local_push(top) local_push_gen(parser,(top))
+static void local_pop_gen(struct parser_params*);
+#define local_pop() local_pop_gen(parser)
+static void local_var_gen(struct parser_params*, ID);
+#define local_var(id) local_var_gen(parser, (id))
+static void arg_var_gen(struct parser_params*, ID);
+#define arg_var(id) arg_var_gen(parser, (id))
+static int local_id_gen(struct parser_params*, ID, ID **);
+#define local_id_ref(id, vidp) local_id_gen(parser, (id), &(vidp))
+#define local_id(id) local_id_gen(parser, (id), NULL)
+static ID internal_id_gen(struct parser_params*);
+#define internal_id() internal_id_gen(parser)
+
+static const struct vtable *dyna_push_gen(struct parser_params *);
+#define dyna_push() dyna_push_gen(parser)
+static void dyna_pop_gen(struct parser_params*, const struct vtable *);
+#define dyna_pop(node) dyna_pop_gen(parser, (node))
+static int dyna_in_block_gen(struct parser_params*);
+#define dyna_in_block() dyna_in_block_gen(parser)
+#define dyna_var(id) local_var(id)
+static int dvar_defined_gen(struct parser_params*, ID, ID**);
+#define dvar_defined_ref(id, vidp) dvar_defined_gen(parser, (id), &(vidp))
+#define dvar_defined(id) dvar_defined_gen(parser, (id), NULL)
+static int dvar_curr_gen(struct parser_params*,ID);
+#define dvar_curr(id) dvar_curr_gen(parser, (id))
+
+static int lvar_defined_gen(struct parser_params*, ID);
+#define lvar_defined(id) lvar_defined_gen(parser, (id))
#ifdef RIPPER
# define METHOD_NOT idNOT
@@ -636,14 +742,6 @@ static void numparam_pop(struct parser_params *p, NODE *prev_inner);
# define METHOD_NOT '!'
#endif
-#define idFWD_REST '*'
-#ifdef RUBY3_KEYWORDS
-#define idFWD_KWREST idPow /* Use simple "**", as tDSTAR is "**arg" */
-#else
-#define idFWD_KWREST 0
-#endif
-#define idFWD_BLOCK '&'
-
#define RE_OPTION_ONCE (1<<16)
#define RE_OPTION_ENCODING_SHIFT 8
#define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
@@ -672,29 +770,15 @@ typedef struct rb_strterm_literal_struct {
} u3;
} rb_strterm_literal_t;
-#define HERETERM_LENGTH_BITS ((SIZEOF_VALUE - 1) * CHAR_BIT - 1)
-
struct rb_strterm_heredoc_struct {
+ SIGNED_VALUE sourceline;
+ VALUE term; /* `"END"` of `<<"END"` */
VALUE lastline; /* the string of line that contains `<<"END"` */
- long offset; /* the column of END in `<<"END"` */
- int sourceline; /* lineno of the line that contains `<<"END"` */
- unsigned length /* the length of END in `<<"END"` */
-#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
- : HERETERM_LENGTH_BITS
-# define HERETERM_LENGTH_MAX ((1U << HERETERM_LENGTH_BITS) - 1)
-#else
-# define HERETERM_LENGTH_MAX UINT_MAX
-#endif
- ;
-#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
- unsigned quote: 1;
- unsigned func: 8;
-#else
- uint8_t quote;
- uint8_t func;
-#endif
+ union {
+ VALUE dummy;
+ long lastidx; /* the column of `<<"END"` */
+ } u3;
};
-STATIC_ASSERT(rb_strterm_heredoc_t, sizeof(rb_strterm_heredoc_t) <= 4 * SIZEOF_VALUE);
#define STRTERM_HEREDOC IMEMO_FL_USER0
@@ -713,14 +797,12 @@ rb_strterm_mark(VALUE obj)
rb_strterm_t *strterm = (rb_strterm_t*)obj;
if (RBASIC(obj)->flags & STRTERM_HEREDOC) {
rb_strterm_heredoc_t *heredoc = &strterm->u.heredoc;
+ rb_gc_mark(heredoc->term);
rb_gc_mark(heredoc->lastline);
}
}
#endif
-#define yytnamerr(yyres, yystr) (YYSIZE_T)rb_yytnamerr(p, yyres, yystr)
-size_t rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr);
-
#define TOKEN2ID(tok) ( \
tTOKEN_LOCAL_BEGIN<(tok)&&(tok)<tTOKEN_LOCAL_END ? TOKEN2LOCALID(tok) : \
tTOKEN_INSTANCE_BEGIN<(tok)&&(tok)<tTOKEN_INSTANCE_END ? TOKEN2INSTANCEID(tok) : \
@@ -747,138 +829,81 @@ static VALUE ripper_dispatch3(struct parser_params*,ID,VALUE,VALUE,VALUE);
static VALUE ripper_dispatch4(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE);
static VALUE ripper_dispatch5(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE,VALUE);
static VALUE ripper_dispatch7(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE);
-static void ripper_error(struct parser_params *p);
+static void ripper_error_gen(struct parser_params *parser);
+#define ripper_error() ripper_error_gen(parser)
-#define dispatch0(n) ripper_dispatch0(p, TOKEN_PASTE(ripper_id_, n))
-#define dispatch1(n,a) ripper_dispatch1(p, TOKEN_PASTE(ripper_id_, n), (a))
-#define dispatch2(n,a,b) ripper_dispatch2(p, TOKEN_PASTE(ripper_id_, n), (a), (b))
-#define dispatch3(n,a,b,c) ripper_dispatch3(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
-#define dispatch4(n,a,b,c,d) ripper_dispatch4(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
-#define dispatch5(n,a,b,c,d,e) ripper_dispatch5(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
-#define dispatch7(n,a,b,c,d,e,f,g) ripper_dispatch7(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e), (f), (g))
+#define dispatch0(n) ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
+#define dispatch1(n,a) ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), (a))
+#define dispatch2(n,a,b) ripper_dispatch2(parser, TOKEN_PASTE(ripper_id_, n), (a), (b))
+#define dispatch3(n,a,b,c) ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
+#define dispatch4(n,a,b,c,d) ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
+#define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
+#define dispatch7(n,a,b,c,d,e,f,g) ripper_dispatch7(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e), (f), (g))
#define yyparse ripper_yyparse
#define ID2VAL(id) STATIC_ID2SYM(id)
#define TOKEN2VAL(t) ID2VAL(TOKEN2ID(t))
-#define KWD2EID(t, v) ripper_new_yylval(p, keyword_##t, get_value(v), 0)
+#define KWD2EID(t, v) ripper_new_yylval(keyword_##t, get_value(v), 0)
+
+#define arg_new() dispatch0(args_new)
+#define arg_add(l,a) dispatch2(args_add, (l), (a))
+#define arg_add_star(l,a) dispatch2(args_add_star, (l), (a))
+#define arg_add_block(l,b) dispatch2(args_add_block, (l), (b))
+#define arg_add_optblock(l,b) ((b)==Qundef? (l) : dispatch2(args_add_block, (l), (b)))
+#define bare_assoc(v) dispatch1(bare_assoc_hash, (v))
+#define arg_add_assocs(l,b) arg_add((l), bare_assoc(b))
+
+#define args2mrhs(a) dispatch1(mrhs_new_from_args, (a))
+#define mrhs_new() dispatch0(mrhs_new)
+#define mrhs_add(l,a) dispatch2(mrhs_add, (l), (a))
+#define mrhs_add_star(l,a) dispatch2(mrhs_add_star, (l), (a))
+
+#define mlhs_new() dispatch0(mlhs_new)
+#define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
+#define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
+#define mlhs_add_post(l,a) dispatch2(mlhs_add_post, (l), (a))
#define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
+#define blockvar_new(p,v) dispatch2(block_var, (p), (v))
+
+#define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
+#define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
+#define method_add_block(m,b) dispatch2(method_add_block, (m), (b))
+
#define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
static inline VALUE
-new_args(struct parser_params *p, VALUE pre_args, VALUE opt_args, VALUE rest_arg, VALUE post_args, VALUE tail, YYLTYPE *loc)
+new_args_gen(struct parser_params *parser, VALUE f, VALUE o, VALUE r, VALUE p, VALUE tail)
{
NODE *t = (NODE *)tail;
- VALUE kw_args = t->u1.value, kw_rest_arg = t->u2.value, block = t->u3.value;
- return params_new(pre_args, opt_args, rest_arg, post_args, kw_args, kw_rest_arg, escape_Qundef(block));
+ VALUE k = t->u1.value, kr = t->u2.value, b = t->u3.value;
+ return params_new(f, o, r, p, k, kr, escape_Qundef(b));
}
+#define new_args(f,o,r,p,t,location) new_args_gen(parser, (f),(o),(r),(p),(t))
static inline VALUE
-new_args_tail(struct parser_params *p, VALUE kw_args, VALUE kw_rest_arg, VALUE block, YYLTYPE *loc)
+new_args_tail_gen(struct parser_params *parser, VALUE k, VALUE kr, VALUE b)
{
- NODE *t = rb_node_newnode(NODE_ARGS_AUX, kw_args, kw_rest_arg, block, &NULL_LOC);
- add_mark_object(p, kw_args);
- add_mark_object(p, kw_rest_arg);
- add_mark_object(p, block);
+ NODE *t = rb_node_newnode(NODE_ARGS_AUX, k, kr, b);
+ add_mark_object(k);
+ add_mark_object(kr);
+ add_mark_object(b);
return (VALUE)t;
}
+#define new_args_tail(k,kr,b,location) new_args_tail_gen(parser, (k),(kr),(b))
-static inline VALUE
-args_with_numbered(struct parser_params *p, VALUE args, int max_numparam)
-{
- return args;
-}
-
-static VALUE
-new_array_pattern(struct parser_params *p, VALUE constant, VALUE pre_arg, VALUE aryptn, const YYLTYPE *loc)
-{
- NODE *t = (NODE *)aryptn;
- struct rb_ary_pattern_info *apinfo = t->nd_apinfo;
- VALUE pre_args = Qnil, rest_arg = Qnil, post_args = Qnil;
-
- if (apinfo) {
- pre_args = rb_ary_entry(apinfo->imemo, 0);
- rest_arg = rb_ary_entry(apinfo->imemo, 1);
- post_args = rb_ary_entry(apinfo->imemo, 2);
- }
-
- if (!NIL_P(pre_arg)) {
- if (!NIL_P(pre_args)) {
- rb_ary_unshift(pre_args, pre_arg);
- }
- else {
- pre_args = rb_ary_new_from_args(1, pre_arg);
- }
- }
- return dispatch4(aryptn, constant, pre_args, rest_arg, post_args);
-}
-
-static VALUE
-new_array_pattern_tail(struct parser_params *p, VALUE pre_args, VALUE has_rest, VALUE rest_arg, VALUE post_args, const YYLTYPE *loc)
-{
- NODE *t;
- struct rb_ary_pattern_info *apinfo;
-
- if (has_rest) {
- rest_arg = dispatch1(var_field, rest_arg ? rest_arg : Qnil);
- }
- else {
- rest_arg = Qnil;
- }
-
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- apinfo = ZALLOC(struct rb_ary_pattern_info);
- rb_imemo_tmpbuf_set_ptr(tmpbuf, apinfo);
- apinfo->imemo = rb_ary_new_from_args(4, pre_args, rest_arg, post_args, tmpbuf);
-
- t = rb_node_newnode(NODE_ARYPTN, Qnil, Qnil, (VALUE)apinfo, &NULL_LOC);
- RB_OBJ_WRITTEN(p->ast, Qnil, apinfo->imemo);
-
- return (VALUE)t;
-}
-
-#define new_hash(p,h,l) rb_ary_new_from_args(0)
-
-static VALUE
-new_unique_key_hash(struct parser_params *p, VALUE ary, const YYLTYPE *loc)
-{
- return ary;
-}
-
-static VALUE
-new_hash_pattern(struct parser_params *p, VALUE constant, VALUE hshptn, const YYLTYPE *loc)
-{
- NODE *t = (NODE *)hshptn;
- VALUE kw_args = t->u1.value, kw_rest_arg = t->u2.value;
- return dispatch3(hshptn, constant, kw_args, kw_rest_arg);
-}
-
-static VALUE
-new_hash_pattern_tail(struct parser_params *p, VALUE kw_args, VALUE kw_rest_arg, const YYLTYPE *loc)
-{
- NODE *t;
- if (kw_rest_arg) {
- kw_rest_arg = dispatch1(var_field, kw_rest_arg);
- }
- else {
- kw_rest_arg = Qnil;
- }
- t = rb_node_newnode(NODE_HSHPTN, kw_args, kw_rest_arg, 0, &NULL_LOC);
-
- add_mark_object(p, kw_args);
- add_mark_object(p, kw_rest_arg);
- return (VALUE)t;
-}
+#define new_defined(expr,location) dispatch1(defined, (expr))
-#define new_defined(p,expr,loc) dispatch1(defined, (expr))
+static VALUE parser_heredoc_dedent(struct parser_params*,VALUE);
+# define heredoc_dedent(str) parser_heredoc_dedent(parser, (str))
-static VALUE heredoc_dedent(struct parser_params*,VALUE);
+#define FIXME 0
#else
-#define ID2VAL(id) (id)
+#define ID2VAL(id) ((VALUE)(id))
#define TOKEN2VAL(t) ID2VAL(t)
#define KWD2EID(t, v) keyword_##t
#endif /* RIPPER */
@@ -914,21 +939,20 @@ static VALUE heredoc_dedent(struct parser_params*,VALUE);
# define rb_warning3L(l,fmt,a,b,c) WARNING_CALL(WARNING_ARGS_L(l, fmt, 4), (a), (b), (c))
# define rb_warning4L(l,fmt,a,b,c,d) WARNING_CALL(WARNING_ARGS_L(l, fmt, 5), (a), (b), (c), (d))
#ifdef RIPPER
-static ID id_warn, id_warning, id_gets, id_assoc;
+static ID id_warn, id_warning, id_gets;
# define WARN_S_L(s,l) STR_NEW(s,l)
# define WARN_S(s) STR_NEW2(s)
# define WARN_I(i) INT2NUM(i)
# define WARN_ID(i) rb_id2str(i)
-# define WARN_IVAL(i) i
# define PRIsWARN "s"
-# define WARN_ARGS(fmt,n) p->value, id_warn, n, rb_usascii_str_new_lit(fmt)
+# define WARN_ARGS(fmt,n) parser->value, id_warn, n, rb_usascii_str_new_lit(fmt)
# define WARN_ARGS_L(l,fmt,n) WARN_ARGS(fmt,n)
# ifdef HAVE_VA_ARGS_MACRO
# define WARN_CALL(...) rb_funcall(__VA_ARGS__)
# else
# define WARN_CALL rb_funcall
# endif
-# define WARNING_ARGS(fmt,n) p->value, id_warning, n, rb_usascii_str_new_lit(fmt)
+# define WARNING_ARGS(fmt,n) parser->value, id_warning, n, rb_usascii_str_new_lit(fmt)
# define WARNING_ARGS_L(l, fmt,n) WARNING_ARGS(fmt,n)
# ifdef HAVE_VA_ARGS_MACRO
# define WARNING_CALL(...) rb_funcall(__VA_ARGS__)
@@ -937,138 +961,123 @@ static ID id_warn, id_warning, id_gets, id_assoc;
# endif
PRINTF_ARGS(static void ripper_compile_error(struct parser_params*, const char *fmt, ...), 2, 3);
# define compile_error ripper_compile_error
+# define PARSER_ARG parser,
#else
# define WARN_S_L(s,l) s
# define WARN_S(s) s
# define WARN_I(i) i
# define WARN_ID(i) rb_id2name(i)
-# define WARN_IVAL(i) NUM2INT(i)
# define PRIsWARN PRIsVALUE
-# define WARN_ARGS(fmt,n) WARN_ARGS_L(p->ruby_sourceline,fmt,n)
-# define WARN_ARGS_L(l,fmt,n) p->ruby_sourcefile, (l), (fmt)
+# define WARN_ARGS(fmt,n) WARN_ARGS_L(ruby_sourceline,fmt,n)
+# define WARN_ARGS_L(l,fmt,n) ruby_sourcefile, (l), (fmt)
# define WARN_CALL rb_compile_warn
# define WARNING_ARGS(fmt,n) WARN_ARGS(fmt,n)
# define WARNING_ARGS_L(l,fmt,n) WARN_ARGS_L(l,fmt,n)
# define WARNING_CALL rb_compile_warning
PRINTF_ARGS(static void parser_compile_error(struct parser_params*, const char *fmt, ...), 2, 3);
# define compile_error parser_compile_error
+# define PARSER_ARG parser,
#endif
-static void token_info_setup(token_info *ptinfo, const char *ptr, const rb_code_location_t *loc);
-static void token_info_push(struct parser_params*, const char *token, const rb_code_location_t *loc);
-static void token_info_pop(struct parser_params*, const char *token, const rb_code_location_t *loc);
-static void token_info_warn(struct parser_params *p, const char *token, token_info *ptinfo_beg, int same, const rb_code_location_t *loc);
+/* Older versions of Yacc set YYMAXDEPTH to a very low value by default (150,
+ for instance). This is too low for Ruby to parse some files, such as
+ date/format.rb, therefore bump the value up to at least Bison's default. */
+#ifdef OLD_YACC
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 10000
+#endif
+#endif
-#define WARN_EOL(tok) \
- (looking_at_eol_p(p) ? \
- (void)rb_warning0("`" tok "' at the end of line without an expression") : \
- (void)0)
-static int looking_at_eol_p(struct parser_params *p);
+static void token_info_push_gen(struct parser_params*, const char *token, size_t len);
+static void token_info_pop_gen(struct parser_params*, const char *token, size_t len);
+#define token_info_push(token) token_info_push_gen(parser, (token), rb_strlen_lit(token))
+#define token_info_pop(token) token_info_pop_gen(parser, (token), rb_strlen_lit(token))
%}
-%expect 0
-%define api.pure
-%define parse.error verbose
-%lex-param {struct parser_params *p}
-%parse-param {struct parser_params *p}
-%initial-action
-{
- RUBY_SET_YYLLOC_OF_NONE(@$);
-};
+%pure-parser
+%lex-param {struct parser_params *parser}
+%parse-param {struct parser_params *parser}
%union {
VALUE val;
NODE *node;
ID id;
int num;
- st_table *tbl;
const struct vtable *vars;
struct rb_strterm_struct *strterm;
}
%token <id>
- keyword_class "`class'"
- keyword_module "`module'"
- keyword_def "`def'"
- keyword_undef "`undef'"
- keyword_begin "`begin'"
- keyword_rescue "`rescue'"
- keyword_ensure "`ensure'"
- keyword_end "`end'"
- keyword_if "`if'"
- keyword_unless "`unless'"
- keyword_then "`then'"
- keyword_elsif "`elsif'"
- keyword_else "`else'"
- keyword_case "`case'"
- keyword_when "`when'"
- keyword_while "`while'"
- keyword_until "`until'"
- keyword_for "`for'"
- keyword_break "`break'"
- keyword_next "`next'"
- keyword_redo "`redo'"
- keyword_retry "`retry'"
- keyword_in "`in'"
- keyword_do "`do'"
- keyword_do_cond "`do' for condition"
- keyword_do_block "`do' for block"
- keyword_do_LAMBDA "`do' for lambda"
- keyword_return "`return'"
- keyword_yield "`yield'"
- keyword_super "`super'"
- keyword_self "`self'"
- keyword_nil "`nil'"
- keyword_true "`true'"
- keyword_false "`false'"
- keyword_and "`and'"
- keyword_or "`or'"
- keyword_not "`not'"
- modifier_if "`if' modifier"
- modifier_unless "`unless' modifier"
- modifier_while "`while' modifier"
- modifier_until "`until' modifier"
- modifier_rescue "`rescue' modifier"
- keyword_alias "`alias'"
- keyword_defined "`defined?'"
- keyword_BEGIN "`BEGIN'"
- keyword_END "`END'"
- keyword__LINE__ "`__LINE__'"
- keyword__FILE__ "`__FILE__'"
- keyword__ENCODING__ "`__ENCODING__'"
-
-%token <id> tIDENTIFIER "local variable or method"
-%token <id> tFID "method"
-%token <id> tGVAR "global variable"
-%token <id> tIVAR "instance variable"
-%token <id> tCONSTANT "constant"
-%token <id> tCVAR "class variable"
-%token <id> tLABEL
-%token <node> tINTEGER "integer literal"
-%token <node> tFLOAT "float literal"
-%token <node> tRATIONAL "rational literal"
-%token <node> tIMAGINARY "imaginary literal"
-%token <node> tCHAR "char literal"
-%token <node> tNTH_REF "numbered reference"
-%token <node> tBACK_REF "back reference"
-%token <node> tSTRING_CONTENT "literal content"
+ keyword_class
+ keyword_module
+ keyword_def
+ keyword_undef
+ keyword_begin
+ keyword_rescue
+ keyword_ensure
+ keyword_end
+ keyword_if
+ keyword_unless
+ keyword_then
+ keyword_elsif
+ keyword_else
+ keyword_case
+ keyword_when
+ keyword_while
+ keyword_until
+ keyword_for
+ keyword_break
+ keyword_next
+ keyword_redo
+ keyword_retry
+ keyword_in
+ keyword_do
+ keyword_do_cond
+ keyword_do_block
+ keyword_do_LAMBDA
+ keyword_return
+ keyword_yield
+ keyword_super
+ keyword_self
+ keyword_nil
+ keyword_true
+ keyword_false
+ keyword_and
+ keyword_or
+ keyword_not
+ modifier_if
+ modifier_unless
+ modifier_while
+ modifier_until
+ modifier_rescue
+ keyword_alias
+ keyword_defined
+ keyword_BEGIN
+ keyword_END
+ keyword__LINE__
+ keyword__FILE__
+ keyword__ENCODING__
+
+%token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
+%token <node> tINTEGER tFLOAT tRATIONAL tIMAGINARY tSTRING_CONTENT tCHAR
+%token <node> tNTH_REF tBACK_REF
%token <num> tREGEXP_END
%type <node> singleton strings string string1 xstring regexp
%type <node> string_contents xstring_contents regexp_contents string_content
%type <node> words symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
-%type <node> literal numeric simple_numeric ssym dsym symbol cpath
-%type <node> top_compstmt top_stmts top_stmt begin_block
+%type <node> literal numeric simple_numeric dsym cpath
+%type <node> top_compstmt top_stmts top_stmt
%type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
-%type <node> expr_value expr_value_do arg_value primary_value fcall rel_expr
-%type <node> if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure
+%type <node> expr_value arg_value primary_value fcall rel_expr
+%type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
%type <node> args call_args opt_call_args
%type <node> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
%type <node> command_rhs arg_rhs
%type <node> command_asgn mrhs mrhs_arg superclass block_call block_command
%type <node> f_block_optarg f_block_opt
-%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs f_rest_marg
+%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
%type <node> block_param opt_block_param block_param_def f_opt
%type <node> f_kwarg f_kw f_block_kwarg f_block_kw
@@ -1076,25 +1085,14 @@ static int looking_at_eol_p(struct parser_params *p);
%type <node> lambda f_larglist lambda_body brace_body do_body
%type <node> brace_block cmd_brace_block do_block lhs none fitem
%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
-%type <node> p_case_body p_cases p_top_expr p_top_expr_body
-%type <node> p_expr p_as p_alt p_expr_basic
-%type <node> p_args p_args_head p_args_tail p_args_post p_arg
-%type <node> p_value p_primitive p_variable p_var_ref p_const
-%type <node> p_kwargs p_kwarg p_kw
-%type <id> keyword_variable user_variable sym operation operation2 operation3
+%type <id> fsym keyword_variable user_variable sym symbol operation operation2 operation3
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
-%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
-%type <id> p_kwrest p_kwnorest p_kw_label
-%type <id> f_no_kwarg args_forward
+%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop
+/*%%%*/
+/*%
+%type <val> program then do
+%*/
%token END_OF_INPUT 0 "end-of-input"
-%token <id> '.'
-/* escaped chars, should be ignored otherwise */
-%token <id> '\\' "backslash"
-%token tSP "escaped space"
-%token <id> '\t' "escaped horizontal tab"
-%token <id> '\f' "escaped form feed"
-%token <id> '\r' "escaped carriage return"
-%token <id> '\13' "escaped vertical tab"
%token tUPLUS RUBY_TOKEN(UPLUS) "unary+"
%token tUMINUS RUBY_TOKEN(UMINUS) "unary-"
%token tPOW RUBY_TOKEN(POW) "**"
@@ -1110,16 +1108,14 @@ static int looking_at_eol_p(struct parser_params *p);
%token tNMATCH RUBY_TOKEN(NMATCH) "!~"
%token tDOT2 RUBY_TOKEN(DOT2) ".."
%token tDOT3 RUBY_TOKEN(DOT3) "..."
-%token tBDOT2 RUBY_TOKEN(BDOT2) "(.."
-%token tBDOT3 RUBY_TOKEN(BDOT3) "(..."
%token tAREF RUBY_TOKEN(AREF) "[]"
%token tASET RUBY_TOKEN(ASET) "[]="
%token tLSHFT RUBY_TOKEN(LSHFT) "<<"
%token tRSHFT RUBY_TOKEN(RSHFT) ">>"
-%token <id> tANDDOT RUBY_TOKEN(ANDDOT) "&."
-%token <id> tCOLON2 RUBY_TOKEN(COLON2) "::"
+%token tANDDOT RUBY_TOKEN(ANDDOT) "&."
+%token tCOLON2 RUBY_TOKEN(COLON2) "::"
%token tCOLON3 ":: at EXPR_BEG"
-%token <id> tOP_ASGN "operator-assignment" /* +=, -= etc. */
+%token <id> tOP_ASGN /* +=, -= etc. */
%token tASSOC "=>"
%token tLPAREN "("
%token tLPAREN_ARG "( arg"
@@ -1131,17 +1127,8 @@ static int looking_at_eol_p(struct parser_params *p);
%token tDSTAR "**arg"
%token tAMPER "&"
%token tLAMBDA "->"
-%token tSYMBEG "symbol literal"
-%token tSTRING_BEG "string literal"
-%token tXSTRING_BEG "backtick literal"
-%token tREGEXP_BEG "regexp literal"
-%token tWORDS_BEG "word list"
-%token tQWORDS_BEG "verbatim word list"
-%token tSYMBOLS_BEG "symbol list"
-%token tQSYMBOLS_BEG "verbatim symbol list"
-%token tSTRING_END "terminator"
-%token tSTRING_DEND "'}'"
-%token tSTRING_DBEG tSTRING_DVAR tLAMBEG tLABEL_END
+%token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG
+%token tSTRING_DBEG tSTRING_DEND tSTRING_DVAR tSTRING_END tLAMBEG tLABEL_END
/*
* precedence table
@@ -1150,14 +1137,14 @@ static int looking_at_eol_p(struct parser_params *p);
%nonassoc tLOWEST
%nonassoc tLBRACE_ARG
-%nonassoc modifier_if modifier_unless modifier_while modifier_until keyword_in
+%nonassoc modifier_if modifier_unless modifier_while modifier_until
%left keyword_or keyword_and
%right keyword_not
%nonassoc keyword_defined
%right '=' tOP_ASGN
%left modifier_rescue
%right '?' ':'
-%nonassoc tDOT2 tDOT3 tBDOT2 tBDOT3
+%nonassoc tDOT2 tDOT3
%left tOROP
%left tANDOP
%nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
@@ -1176,56 +1163,69 @@ static int looking_at_eol_p(struct parser_params *p);
%%
program : {
SET_LEX_STATE(EXPR_BEG);
- local_push(p, ifndef_ripper(1)+0);
+ /*%%%*/
+ local_push(compile_for_eval || in_main);
+ /*%
+ local_push(0);
+ %*/
}
top_compstmt
{
/*%%%*/
if ($2 && !compile_for_eval) {
- NODE *node = $2;
/* last expression should not be void */
- if (nd_type(node) == NODE_BLOCK) {
+ if (nd_type($2) != NODE_BLOCK) void_expr($2);
+ else {
+ NODE *node = $2;
while (node->nd_next) {
node = node->nd_next;
}
- node = node->nd_head;
+ void_expr(node->nd_head);
}
- node = remove_begin(node);
- void_expr(p, node);
}
- p->eval_tree = NEW_SCOPE(0, block_append(p, p->eval_tree, $2), &@$);
- /*% %*/
- /*% ripper[final]: program!($2) %*/
- local_pop(p);
+ ruby_eval_tree = new_scope(0, block_append(ruby_eval_tree, $2, &@$), &@$);
+ /*%
+ $$ = $2;
+ parser->result = dispatch1(program, $$);
+ %*/
+ local_pop();
}
;
top_compstmt : top_stmts opt_terms
{
- $$ = void_stmts(p, $1);
+ /*%%%*/
+ void_stmts($1);
+ /*%
+ %*/
+ $$ = $1;
}
;
top_stmts : none
{
/*%%%*/
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: stmts_add!(stmts_new!, void_stmt!) %*/
+ $$ = new_begin(0, &@$);
+ /*%
+ $$ = dispatch2(stmts_add, dispatch0(stmts_new),
+ dispatch0(void_stmt));
+ %*/
}
| top_stmt
{
/*%%%*/
$$ = newline_node($1);
- /*% %*/
- /*% ripper: stmts_add!(stmts_new!, $1) %*/
+ /*%
+ $$ = dispatch2(stmts_add, dispatch0(stmts_new), $1);
+ %*/
}
| top_stmts terms top_stmt
{
/*%%%*/
- $$ = block_append(p, $1, newline_node($3));
- /*% %*/
- /*% ripper: stmts_add!($1, $3) %*/
+ $$ = block_append($1, newline_node($3), &@$);
+ /*%
+ $$ = dispatch2(stmts_add, $1, $3);
+ %*/
}
| error top_stmt
{
@@ -1234,71 +1234,97 @@ top_stmts : none
;
top_stmt : stmt
- | keyword_BEGIN begin_block
+ | keyword_BEGIN
{
- $$ = $2;
+ /*%%%*/
+ /* local_push(0); */
+ /*%
+ %*/
}
- ;
-
-begin_block : '{' top_compstmt '}'
+ '{' top_compstmt '}'
{
/*%%%*/
- p->eval_tree_begin = block_append(p, p->eval_tree_begin,
- NEW_BEGIN($2, &@$));
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: BEGIN!($2) %*/
+ ruby_eval_tree_begin = block_append(ruby_eval_tree_begin,
+ new_begin($4, &@$), &@$);
+ /* NEW_PREEXE($4)); */
+ /* local_pop(); */
+ $$ = new_begin(0, &@$);
+ /*%
+ $$ = dispatch1(BEGIN, $4);
+ %*/
}
;
bodystmt : compstmt
opt_rescue
- k_else {if (!$2) {yyerror1(&@3, "else without rescue is useless");}}
- compstmt
- opt_ensure
- {
- /*%%%*/
- $$ = new_bodystmt(p, $1, $2, $5, $6, &@$);
- /*% %*/
- /*% ripper: bodystmt!(escape_Qundef($1), escape_Qundef($2), escape_Qundef($5), escape_Qundef($6)) %*/
- }
- | compstmt
- opt_rescue
+ opt_else
opt_ensure
{
/*%%%*/
- $$ = new_bodystmt(p, $1, $2, 0, $3, &@$);
- /*% %*/
- /*% ripper: bodystmt!(escape_Qundef($1), escape_Qundef($2), Qnil, escape_Qundef($3)) %*/
+ $$ = $1;
+ if ($2) {
+ $$ = new_rescue($1, $2, $3, &@$);
+ }
+ else if ($3) {
+ rb_warn0("else without rescue is useless");
+ $$ = block_append($$, $3, &@$);
+ }
+ if ($4) {
+ if ($$) {
+ $$ = NEW_ENSURE($$, $4);
+ $$->nd_loc = @$;
+ }
+ else {
+ NODE *nil = NEW_NIL();
+ nil->nd_loc = @$;
+ $$ = block_append($4, nil, &@$);
+ }
+ }
+ fixpos($$, $1);
+ /*%
+ $$ = dispatch4(bodystmt,
+ escape_Qundef($1),
+ escape_Qundef($2),
+ escape_Qundef($3),
+ escape_Qundef($4));
+ %*/
}
;
compstmt : stmts opt_terms
{
- $$ = void_stmts(p, $1);
+ /*%%%*/
+ void_stmts($1);
+ /*%
+ %*/
+ $$ = $1;
}
;
stmts : none
{
/*%%%*/
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: stmts_add!(stmts_new!, void_stmt!) %*/
+ $$ = new_begin(0, &@$);
+ /*%
+ $$ = dispatch2(stmts_add, dispatch0(stmts_new),
+ dispatch0(void_stmt));
+ %*/
}
| stmt_or_begin
{
/*%%%*/
$$ = newline_node($1);
- /*% %*/
- /*% ripper: stmts_add!(stmts_new!, $1) %*/
+ /*%
+ $$ = dispatch2(stmts_add, dispatch0(stmts_new), $1);
+ %*/
}
| stmts terms stmt_or_begin
{
/*%%%*/
- $$ = block_append(p, $1, newline_node($3));
- /*% %*/
- /*% ripper: stmts_add!($1, $3) %*/
+ $$ = block_append($1, newline_node($3), &@$);
+ /*%
+ $$ = dispatch2(stmts_add, $1, $3);
+ %*/
}
| error stmt
{
@@ -1312,27 +1338,43 @@ stmt_or_begin : stmt
}
| keyword_BEGIN
{
- yyerror1(&@1, "BEGIN is permitted only at toplevel");
+ yyerror0("BEGIN is permitted only at toplevel");
+ /*%%%*/
+ /* local_push(0); */
+ /*%
+ %*/
}
- begin_block
+ '{' top_compstmt '}'
{
- $$ = $3;
+ /*%%%*/
+ ruby_eval_tree_begin = block_append(ruby_eval_tree_begin,
+ $4, &@$);
+ /* NEW_PREEXE($4)); */
+ /* local_pop(); */
+ $$ = new_begin(0, &@$);
+ /*%
+ $$ = dispatch1(BEGIN, $4);
+ %*/
}
;
stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
/*%%%*/
- $$ = NEW_ALIAS($2, $4, &@$);
- /*% %*/
- /*% ripper: alias!($2, $4) %*/
+ $$ = NEW_ALIAS($2, $4);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(alias, $2, $4);
+ %*/
}
| keyword_alias tGVAR tGVAR
{
/*%%%*/
- $$ = NEW_VALIAS($2, $3, &@$);
- /*% %*/
- /*% ripper: var_alias!($2, $3) %*/
+ $$ = NEW_VALIAS($2, $3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(var_alias, $2, $3);
+ %*/
}
| keyword_alias tGVAR tBACK_REF
{
@@ -1340,199 +1382,211 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
char buf[2];
buf[0] = '$';
buf[1] = (char)$3->nd_nth;
- $$ = NEW_VALIAS($2, rb_intern2(buf, 2), &@$);
- /*% %*/
- /*% ripper: var_alias!($2, $3) %*/
+ $$ = NEW_VALIAS($2, rb_intern2(buf, 2));
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(var_alias, $2, $3);
+ %*/
}
| keyword_alias tGVAR tNTH_REF
{
/*%%%*/
- yyerror1(&@3, "can't make alias for the number variables");
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: alias_error!(var_alias!($2, $3)) %*/
+ yyerror0("can't make alias for the number variables");
+ $$ = new_begin(0, &@$);
+ /*%
+ $$ = dispatch2(var_alias, $2, $3);
+ $$ = dispatch1(alias_error, $$);
+ ripper_error();
+ %*/
}
| keyword_undef undef_list
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: undef!($2) %*/
+ /*%
+ $$ = dispatch1(undef, $2);
+ %*/
}
| stmt modifier_if expr_value
{
/*%%%*/
- $$ = new_if(p, $3, remove_begin($1), 0, &@$);
+ $$ = new_if($3, remove_begin($1), 0, &@$);
fixpos($$, $3);
- /*% %*/
- /*% ripper: if_mod!($3, $1) %*/
+ /*%
+ $$ = dispatch2(if_mod, $3, $1);
+ %*/
}
| stmt modifier_unless expr_value
{
/*%%%*/
- $$ = new_unless(p, $3, remove_begin($1), 0, &@$);
+ $$ = new_unless($3, remove_begin($1), 0, &@$);
fixpos($$, $3);
- /*% %*/
- /*% ripper: unless_mod!($3, $1) %*/
+ /*%
+ $$ = dispatch2(unless_mod, $3, $1);
+ %*/
}
| stmt modifier_while expr_value
{
/*%%%*/
if ($1 && nd_type($1) == NODE_BEGIN) {
- $$ = NEW_WHILE(cond(p, $3, &@3), $1->nd_body, 0, &@$);
+ $$ = NEW_WHILE(cond($3, &@3), $1->nd_body, 0);
}
else {
- $$ = NEW_WHILE(cond(p, $3, &@3), $1, 1, &@$);
+ $$ = NEW_WHILE(cond($3, &@3), $1, 1);
}
- /*% %*/
- /*% ripper: while_mod!($3, $1) %*/
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(while_mod, $3, $1);
+ %*/
}
| stmt modifier_until expr_value
{
/*%%%*/
if ($1 && nd_type($1) == NODE_BEGIN) {
- $$ = NEW_UNTIL(cond(p, $3, &@3), $1->nd_body, 0, &@$);
+ $$ = NEW_UNTIL(cond($3, &@3), $1->nd_body, 0);
}
else {
- $$ = NEW_UNTIL(cond(p, $3, &@3), $1, 1, &@$);
+ $$ = NEW_UNTIL(cond($3, &@3), $1, 1);
}
- /*% %*/
- /*% ripper: until_mod!($3, $1) %*/
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(until_mod, $3, $1);
+ %*/
}
| stmt modifier_rescue stmt
{
/*%%%*/
NODE *resq;
- YYLTYPE loc = code_loc_gen(&@2, &@3);
- resq = NEW_RESBODY(0, remove_begin($3), 0, &loc);
- $$ = NEW_RESCUE(remove_begin($1), resq, 0, &@$);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ YYLTYPE location;
+ location.first_loc = @2.first_loc;
+ location.last_loc = @3.last_loc;
+ resq = new_resbody(0, remove_begin($3), 0, &location);
+ $$ = new_rescue(remove_begin($1), resq, 0, &@$);
+ /*%
+ $$ = dispatch2(rescue_mod, $1, $3);
+ %*/
}
| keyword_END '{' compstmt '}'
{
- if (p->in_def) {
+ if (in_def) {
rb_warn0("END in method; use at_exit");
}
/*%%%*/
{
NODE *scope = NEW_NODE(
- NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */, &@$);
- $$ = NEW_POSTEXE(scope, &@$);
+ NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */);
+ $$ = NEW_POSTEXE(scope);
+ scope->nd_loc = @$;
+ $$->nd_loc = @$;
}
- /*% %*/
- /*% ripper: END!($3) %*/
+ /*%
+ $$ = dispatch1(END, $3);
+ %*/
}
| command_asgn
| mlhs '=' command_call
{
/*%%%*/
value_expr($3);
- $$ = node_assign(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: massign!($1, $3) %*/
+ $$ = node_assign($1, $3, &@$);
+ /*%
+ $$ = dispatch2(massign, $1, $3);
+ %*/
}
| lhs '=' mrhs
{
- /*%%%*/
value_expr($3);
- $$ = node_assign(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: assign!($1, $3) %*/
+ $$ = node_assign($1, $3, &@$);
}
- | mlhs '=' mrhs_arg modifier_rescue stmt
- {
- /*%%%*/
- YYLTYPE loc = code_loc_gen(&@4, &@5);
- value_expr($3);
- $$ = node_assign(p, $1, NEW_RESCUE($3, NEW_RESBODY(0, remove_begin($5), 0, &loc), 0, &@$), &@$);
- /*% %*/
- /*% ripper: massign!($1, rescue_mod!($3, $5)) %*/
- }
| mlhs '=' mrhs_arg
{
/*%%%*/
- $$ = node_assign(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: massign!($1, $3) %*/
+ $$ = node_assign($1, $3, &@$);
+ /*%
+ $$ = dispatch2(massign, $1, $3);
+ %*/
}
| expr
;
command_asgn : lhs '=' command_rhs
{
- /*%%%*/
- $$ = node_assign(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: assign!($1, $3) %*/
+ $$ = node_assign($1, $3, &@$);
}
| var_lhs tOP_ASGN command_rhs
{
- /*%%%*/
- $$ = new_op_assign(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: opassign!($1, $2, $3) %*/
+ $$ = new_op_assign($1, $2, $3, &@$);
}
| primary_value '[' opt_call_args rbracket tOP_ASGN command_rhs
{
/*%%%*/
- $$ = new_ary_op_assign(p, $1, $3, $5, $6, &@3, &@$);
- /*% %*/
- /*% ripper: opassign!(aref_field!($1, escape_Qundef($3)), $5, $6) %*/
+ NODE *args;
+ $3 = make_array($3, &@3);
+ args = arg_concat($3, $6, &@$);
+ if ($5 == tOROP) {
+ $5 = 0;
+ }
+ else if ($5 == tANDOP) {
+ $5 = 1;
+ }
+ $$ = NEW_OP_ASGN1($1, $5, args);
+ fixpos($$, $1);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(aref_field, $1, escape_Qundef($3));
+ $$ = dispatch3(opassign, $$, $5, $6);
+ %*/
}
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
{
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $5) %*/
+ $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@$);
}
| primary_value call_op tCONSTANT tOP_ASGN command_rhs
{
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $5) %*/
+ $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@$);
}
| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
{
/*%%%*/
- YYLTYPE loc = code_loc_gen(&@1, &@3);
- $$ = new_const_op_assign(p, NEW_COLON2($1, $3, &loc), $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(const_path_field!($1, $3), $4, $5) %*/
+ YYLTYPE location;
+ location.first_loc = @1.first_loc;
+ location.last_loc = @3.last_loc;
+ /*%
+ %*/
+ $$ = const_path_field($1, $3, &location);
+ $$ = new_const_op_assign($$, $4, $5, &@$);
}
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
{
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, ID2VAL(idCOLON2), $3, $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $5) %*/
+ $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, &@$);
}
| backref tOP_ASGN command_rhs
{
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: assign_error!(assign!(var_field(p, $1), $3)) %*/
+ $1 = var_field($1);
+ $$ = backref_assign_error($1, node_assign($1, $3, &@$), &@$);
}
;
command_rhs : command_call %prec tOP_ASGN
{
+ /*%%%*/
value_expr($1);
$$ = $1;
+ /*%
+ %*/
}
| command_call modifier_rescue stmt
{
/*%%%*/
- YYLTYPE loc = code_loc_gen(&@2, &@3);
+ YYLTYPE location;
+ location.first_loc = @2.first_loc;
+ location.last_loc = @3.last_loc;
value_expr($1);
- $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &loc), 0, &@$);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &location), 0, &@$);
+ /*%
+ $$ = dispatch2(rescue_mod, $1, $3);
+ %*/
}
| command_asgn
;
@@ -1540,54 +1594,35 @@ command_rhs : command_call %prec tOP_ASGN
expr : command_call
| expr keyword_and expr
{
- $$ = logop(p, idAND, $1, $3, &@2, &@$);
+ $$ = logop(idAND, $1, $3, &@2, &@$);
}
| expr keyword_or expr
{
- $$ = logop(p, idOR, $1, $3, &@2, &@$);
+ $$ = logop(idOR, $1, $3, &@2, &@$);
}
| keyword_not opt_nl expr
{
- $$ = call_uni_op(p, method_cond(p, $3, &@3), METHOD_NOT, &@1, &@$);
+ $$ = call_uni_op(method_cond($3, &@3), METHOD_NOT, &@1, &@$);
}
| '!' command_call
{
- $$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
+ $$ = call_uni_op(method_cond($2, &@2), '!', &@1, &@$);
}
- | arg keyword_in
- {
- value_expr($1);
- SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
- p->command_start = FALSE;
- $<num>$ = p->in_kwarg;
- p->in_kwarg = 1;
- }
- {$<tbl>$ = push_pvtbl(p);}
- p_expr
- {pop_pvtbl(p, $<tbl>4);}
- {
- p->in_kwarg = !!$<num>3;
- /*%%%*/
- $$ = new_case3(p, $1, NEW_IN($5, 0, 0, &@5), &@$);
- /*% %*/
- /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
- }
- | arg %prec tLBRACE_ARG
+ | arg
;
expr_value : expr
{
+ /*%%%*/
value_expr($1);
$$ = $1;
+ if (!$$) $$ = NEW_NIL();
+ /*%
+ $$ = $1;
+ %*/
}
;
-expr_value_do : {COND_PUSH(1);} expr_value do {COND_POP();}
- {
- $$ = $2;
- }
-
-
command_call : command
| block_command
;
@@ -1595,19 +1630,24 @@ command_call : command
block_command : block_call
| block_call call_op2 operation2 command_args
{
- /*%%%*/
- $$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, $2, $3), $4) %*/
+ $$ = new_qcall($2, $1, $3, $4, &@$);
}
;
-cmd_brace_block : tLBRACE_ARG brace_body '}'
+cmd_brace_block : tLBRACE_ARG
{
- $$ = $2;
/*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
+ $<num>$ = ruby_sourceline;
+ /*%
+ %*/
+ }
+ brace_body '}'
+ {
+ $$ = $3;
+ /*%%%*/
+ $3->nd_body->nd_loc.first_loc = @1.first_loc;
+ $3->nd_body->nd_loc.last_loc = @4.last_loc;
+ nd_set_line($$, $<num>2);
/*% %*/
}
;
@@ -1615,97 +1655,112 @@ cmd_brace_block : tLBRACE_ARG brace_body '}'
fcall : operation
{
/*%%%*/
- $$ = NEW_FCALL($1, 0, &@$);
- nd_set_line($$, p->tokline);
- /*% %*/
- /*% ripper: $1 %*/
+ $$ = new_fcall($1, 0, &@$);
+ nd_set_line($$, tokline);
+ /*%
+ %*/
}
;
command : fcall command_args %prec tLOWEST
{
/*%%%*/
- $1->nd_args = $2;
- nd_set_last_loc($1, @2.end_pos);
$$ = $1;
- /*% %*/
- /*% ripper: command!($1, $2) %*/
+ $$->nd_args = $2;
+ nd_set_last_loc($1, @2.last_loc);
+ /*%
+ $$ = dispatch2(command, $1, $2);
+ %*/
}
| fcall command_args cmd_brace_block
{
- /*%%%*/
- block_dup_check(p, $2, $3);
- $1->nd_args = $2;
- $$ = method_add_block(p, $1, $3, &@$);
+ block_dup_check($2,$3);
+ $$ = new_command($1, $2);
+ $$ = method_add_block($$, $3);
fixpos($$, $1);
- nd_set_last_loc($1, @2.end_pos);
- /*% %*/
- /*% ripper: method_add_block!(command!($1, $2), $3) %*/
+ /*%%%*/
+ $$->nd_loc = @$;
+ nd_set_last_loc($1, @2.last_loc);
+ /*%
+ %*/
}
| primary_value call_op operation2 command_args %prec tLOWEST
{
- /*%%%*/
- $$ = new_command_qcall(p, $2, $1, $3, $4, Qnull, &@3, &@$);
- /*% %*/
- /*% ripper: command_call!($1, $2, $3, $4) %*/
+ $$ = new_command_qcall($2, $1, $3, $4, &@$);
+ fixpos($$, $1);
}
| primary_value call_op operation2 command_args cmd_brace_block
{
+ block_dup_check($4,$5);
+ $$ = new_command_qcall($2, $1, $3, $4, &@$);
+ $$ = method_add_block($$, $5);
+ fixpos($$, $1);
/*%%%*/
- $$ = new_command_qcall(p, $2, $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_block!(command_call!($1, $2, $3, $4), $5) %*/
- }
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
| primary_value tCOLON2 operation2 command_args %prec tLOWEST
{
- /*%%%*/
- $$ = new_command_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, Qnull, &@3, &@$);
- /*% %*/
- /*% ripper: command_call!($1, ID2VAL(idCOLON2), $3, $4) %*/
+ $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@$);
+ fixpos($$, $1);
}
| primary_value tCOLON2 operation2 command_args cmd_brace_block
{
+ block_dup_check($4,$5);
+ $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@$);
+ $$ = method_add_block($$, $5);
+ fixpos($$, $1);
/*%%%*/
- $$ = new_command_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_block!(command_call!($1, ID2VAL(idCOLON2), $3, $4), $5) %*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
}
| keyword_super command_args
{
/*%%%*/
- $$ = NEW_SUPER($2, &@$);
+ $$ = NEW_SUPER($2);
fixpos($$, $2);
- /*% %*/
- /*% ripper: super!($2) %*/
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(super, $2);
+ %*/
}
| keyword_yield command_args
{
/*%%%*/
- $$ = new_yield(p, $2, &@$);
+ $$ = new_yield($2, &@$);
fixpos($$, $2);
- /*% %*/
- /*% ripper: yield!($2) %*/
+ /*%
+ $$ = dispatch1(yield, $2);
+ %*/
}
| k_return call_args
{
/*%%%*/
- $$ = NEW_RETURN(ret_args(p, $2), &@$);
- /*% %*/
- /*% ripper: return!($2) %*/
+ $$ = NEW_RETURN(ret_args($2));
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(return, $2);
+ %*/
}
| keyword_break call_args
{
/*%%%*/
- $$ = NEW_BREAK(ret_args(p, $2), &@$);
- /*% %*/
- /*% ripper: break!($2) %*/
+ $$ = NEW_BREAK(ret_args($2));
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(break, $2);
+ %*/
}
| keyword_next call_args
{
/*%%%*/
- $$ = NEW_NEXT(ret_args(p, $2), &@$);
- /*% %*/
- /*% ripper: next!($2) %*/
+ $$ = NEW_NEXT(ret_args($2));
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(next, $2);
+ %*/
}
;
@@ -1714,8 +1769,9 @@ mlhs : mlhs_basic
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ /*%
+ $$ = dispatch1(mlhs_paren, $2);
+ %*/
}
;
@@ -1723,81 +1779,96 @@ mlhs_inner : mlhs_basic
| tLPAREN mlhs_inner rparen
{
/*%%%*/
- $$ = NEW_MASGN(NEW_LIST($2, &@$), 0, &@$);
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ $$ = new_masgn(new_list($2, &@$), 0, &@$);
+ /*%
+ $$ = dispatch1(mlhs_paren, $2);
+ %*/
}
;
mlhs_basic : mlhs_head
{
/*%%%*/
- $$ = NEW_MASGN($1, 0, &@$);
- /*% %*/
- /*% ripper: $1 %*/
+ $$ = new_masgn($1, 0, &@$);
+ /*%
+ $$ = $1;
+ %*/
}
| mlhs_head mlhs_item
{
/*%%%*/
- $$ = NEW_MASGN(list_append(p, $1,$2), 0, &@$);
- /*% %*/
- /*% ripper: mlhs_add!($1, $2) %*/
+ $$ = new_masgn(list_append($1,$2), 0, &@$);
+ /*%
+ $$ = mlhs_add($1, $2);
+ %*/
}
| mlhs_head tSTAR mlhs_node
{
/*%%%*/
- $$ = NEW_MASGN($1, $3, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!($1, $3) %*/
+ $$ = new_masgn($1, $3, &@$);
+ /*%
+ $$ = mlhs_add_star($1, $3);
+ %*/
}
| mlhs_head tSTAR mlhs_node ',' mlhs_post
{
/*%%%*/
- $$ = NEW_MASGN($1, NEW_POSTARG($3,$5,&@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!($1, $3), $5) %*/
+ $$ = new_masgn($1, new_postarg($3,$5,&@$), &@$);
+ /*%
+ $1 = mlhs_add_star($1, $3);
+ $$ = mlhs_add_post($1, $5);
+ %*/
}
| mlhs_head tSTAR
{
/*%%%*/
- $$ = NEW_MASGN($1, NODE_SPECIAL_NO_NAME_REST, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!($1, Qnil) %*/
+ $$ = new_masgn($1, NODE_SPECIAL_NO_NAME_REST, &@$);
+ /*%
+ $$ = mlhs_add_star($1, Qnil);
+ %*/
}
| mlhs_head tSTAR ',' mlhs_post
{
/*%%%*/
- $$ = NEW_MASGN($1, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $4, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!($1, Qnil), $4) %*/
+ $$ = new_masgn($1, new_postarg(NODE_SPECIAL_NO_NAME_REST, $4, &@$), &@$);
+ /*%
+ $1 = mlhs_add_star($1, Qnil);
+ $$ = mlhs_add_post($1, $4);
+ %*/
}
| tSTAR mlhs_node
{
/*%%%*/
- $$ = NEW_MASGN(0, $2, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!(mlhs_new!, $2) %*/
+ $$ = new_masgn(0, $2, &@$);
+ /*%
+ $$ = mlhs_add_star(mlhs_new(), $2);
+ %*/
}
| tSTAR mlhs_node ',' mlhs_post
{
/*%%%*/
- $$ = NEW_MASGN(0, NEW_POSTARG($2,$4,&@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $2), $4) %*/
+ $$ = new_masgn(0, new_postarg($2,$4,&@$), &@$);
+ /*%
+ $2 = mlhs_add_star(mlhs_new(), $2);
+ $$ = mlhs_add_post($2, $4);
+ %*/
}
| tSTAR
{
/*%%%*/
- $$ = NEW_MASGN(0, NODE_SPECIAL_NO_NAME_REST, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!(mlhs_new!, Qnil) %*/
+ $$ = new_masgn(0, NODE_SPECIAL_NO_NAME_REST, &@$);
+ /*%
+ $$ = mlhs_add_star(mlhs_new(), Qnil);
+ %*/
}
| tSTAR ',' mlhs_post
{
/*%%%*/
- $$ = NEW_MASGN(0, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, Qnil), $3) %*/
+ $$ = new_masgn(0, new_postarg(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$);
+ /*%
+ $$ = mlhs_add_star(mlhs_new(), Qnil);
+ $$ = mlhs_add_post($$, $3);
+ %*/
}
;
@@ -1806,187 +1877,166 @@ mlhs_item : mlhs_node
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ /*%
+ $$ = dispatch1(mlhs_paren, $2);
+ %*/
}
;
mlhs_head : mlhs_item ','
{
/*%%%*/
- $$ = NEW_LIST($1, &@1);
- /*% %*/
- /*% ripper: mlhs_add!(mlhs_new!, $1) %*/
+ $$ = new_list($1, &@1);
+ /*%
+ $$ = mlhs_add(mlhs_new(), $1);
+ %*/
}
| mlhs_head mlhs_item ','
{
/*%%%*/
- $$ = list_append(p, $1, $2);
- /*% %*/
- /*% ripper: mlhs_add!($1, $2) %*/
+ $$ = list_append($1, $2);
+ /*%
+ $$ = mlhs_add($1, $2);
+ %*/
}
;
mlhs_post : mlhs_item
{
/*%%%*/
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: mlhs_add!(mlhs_new!, $1) %*/
+ $$ = new_list($1, &@$);
+ /*%
+ $$ = mlhs_add(mlhs_new(), $1);
+ %*/
}
| mlhs_post ',' mlhs_item
{
/*%%%*/
- $$ = list_append(p, $1, $3);
- /*% %*/
- /*% ripper: mlhs_add!($1, $3) %*/
+ $$ = list_append($1, $3);
+ /*%
+ $$ = mlhs_add($1, $3);
+ %*/
}
;
mlhs_node : user_variable
{
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
+ $$ = assignable(var_field($1), 0, &@$);
}
| keyword_variable
{
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
+ $$ = assignable(var_field($1), 0, &@$);
}
| primary_value '[' opt_call_args rbracket
{
/*%%%*/
- $$ = aryset(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: aref_field!($1, escape_Qundef($3)) %*/
+ $$ = aryset($1, $3, &@$);
+ /*%
+ $$ = dispatch2(aref_field, $1, escape_Qundef($3));
+ %*/
}
| primary_value call_op tIDENTIFIER
{
- if ($2 == tANDDOT) {
- yyerror1(&@2, "&. inside multiple assignment destination");
- }
/*%%%*/
- $$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ $$ = attrset($1, $2, $3, &@$);
+ /*%
+ $$ = dispatch3(field, $1, $2, $3);
+ %*/
}
| primary_value tCOLON2 tIDENTIFIER
{
/*%%%*/
- $$ = attrset(p, $1, idCOLON2, $3, &@$);
- /*% %*/
- /*% ripper: const_path_field!($1, $3) %*/
+ $$ = attrset($1, idCOLON2, $3, &@$);
+ /*%
+ $$ = dispatch2(const_path_field, $1, $3);
+ %*/
}
| primary_value call_op tCONSTANT
{
- if ($2 == tANDDOT) {
- yyerror1(&@2, "&. inside multiple assignment destination");
- }
/*%%%*/
- $$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ $$ = attrset($1, $2, $3, &@$);
+ /*%
+ $$ = dispatch3(field, $1, $2, $3);
+ %*/
}
| primary_value tCOLON2 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON2($1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, const_path_field!($1, $3)) %*/
+ $$ = const_decl(const_path_field($1, $3, &@$), &@$);
}
| tCOLON3 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON3($2, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, top_const_field!($2)) %*/
+ $$ = const_decl(top_const_field($2), &@$);
}
| backref
{
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: assign_error!(var_field(p, $1)) %*/
+ $1 = var_field($1);
+ $$ = backref_assign_error($1, $1, &@$);
}
;
lhs : user_variable
{
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
+ $$ = assignable(var_field($1), 0, &@$);
}
| keyword_variable
{
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
+ $$ = assignable(var_field($1), 0, &@$);
}
| primary_value '[' opt_call_args rbracket
{
/*%%%*/
- $$ = aryset(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: aref_field!($1, escape_Qundef($3)) %*/
+ $$ = aryset($1, $3, &@$);
+ /*%
+ $$ = dispatch2(aref_field, $1, escape_Qundef($3));
+ %*/
}
| primary_value call_op tIDENTIFIER
{
/*%%%*/
- $$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ $$ = attrset($1, $2, $3, &@$);
+ /*%
+ $$ = dispatch3(field, $1, $2, $3);
+ %*/
}
| primary_value tCOLON2 tIDENTIFIER
{
/*%%%*/
- $$ = attrset(p, $1, idCOLON2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, ID2VAL(idCOLON2), $3) %*/
+ $$ = attrset($1, idCOLON2, $3, &@$);
+ /*%
+ $$ = dispatch3(field, $1, ID2VAL(idCOLON2), $3);
+ %*/
}
| primary_value call_op tCONSTANT
{
/*%%%*/
- $$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ $$ = attrset($1, $2, $3, &@$);
+ /*%
+ $$ = dispatch3(field, $1, $2, $3);
+ %*/
}
| primary_value tCOLON2 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON2($1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, const_path_field!($1, $3)) %*/
+ $$ = const_decl(const_path_field($1, $3, &@$), &@$);
}
| tCOLON3 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON3($2, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, top_const_field!($2)) %*/
+ $$ = const_decl(top_const_field($2), &@$);
}
| backref
{
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: assign_error!(var_field(p, $1)) %*/
+ $1 = var_field($1);
+ $$ = backref_assign_error($1, $1, &@$);
}
;
cname : tIDENTIFIER
{
/*%%%*/
- yyerror1(&@1, "class/module name must be CONSTANT");
- /*% %*/
- /*% ripper[error]: class_name_error!($1) %*/
+ yyerror0("class/module name must be CONSTANT");
+ /*%
+ $$ = dispatch1(class_name_error, $1);
+ ripper_error();
+ %*/
}
| tCONSTANT
;
@@ -1994,23 +2044,29 @@ cname : tIDENTIFIER
cpath : tCOLON3 cname
{
/*%%%*/
- $$ = NEW_COLON3($2, &@$);
- /*% %*/
- /*% ripper: top_const_ref!($2) %*/
+ $$ = NEW_COLON3($2);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(top_const_ref, $2);
+ %*/
}
| cname
{
/*%%%*/
- $$ = NEW_COLON2(0, $$, &@$);
- /*% %*/
- /*% ripper: const_ref!($1) %*/
+ $$ = NEW_COLON2(0, $$);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(const_ref, $1);
+ %*/
}
| primary_value tCOLON2 cname
{
/*%%%*/
- $$ = NEW_COLON2($1, $3, &@$);
- /*% %*/
- /*% ripper: const_path_ref!($1, $3) %*/
+ $$ = NEW_COLON2($1, $3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(const_path_ref, $1, $3);
+ %*/
}
;
@@ -2023,32 +2079,43 @@ fname : tIDENTIFIER
$$ = $1;
}
| reswords
+ {
+ SET_LEX_STATE(EXPR_ENDFN);
+ $$ = $1;
+ }
;
-fitem : fname
+fsym : fname
+ | symbol
+ ;
+
+fitem : fsym
{
/*%%%*/
- $$ = NEW_LIT(ID2SYM($1), &@$);
- /*% %*/
- /*% ripper: symbol_literal!($1) %*/
+ $$ = new_lit(ID2SYM($1), &@$);
+ /*%
+ $$ = dispatch1(symbol_literal, $1);
+ %*/
}
- | symbol
+ | dsym
;
undef_list : fitem
{
/*%%%*/
- $$ = NEW_UNDEF($1, &@$);
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ $$ = new_undef($1, &@$);
+ /*%
+ $$ = rb_ary_new3(1, get_value($1));
+ %*/
}
| undef_list ',' {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
/*%%%*/
- NODE *undef = NEW_UNDEF($4, &@4);
- $$ = block_append(p, $1, undef);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($4)) %*/
+ NODE *undef = new_undef($4, &@$);
+ $$ = block_append($1, undef, &@$);
+ /*%
+ rb_ary_push($1, get_value($4));
+ %*/
}
;
@@ -2100,249 +2167,209 @@ reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
arg : lhs '=' arg_rhs
{
- /*%%%*/
- $$ = node_assign(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: assign!($1, $3) %*/
+ $$ = node_assign($1, $3, &@$);
}
| var_lhs tOP_ASGN arg_rhs
{
- /*%%%*/
- $$ = new_op_assign(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: opassign!($1, $2, $3) %*/
+ $$ = new_op_assign($1, $2, $3, &@$);
}
| primary_value '[' opt_call_args rbracket tOP_ASGN arg_rhs
{
/*%%%*/
+ NODE *args;
+
value_expr($6);
- $$ = new_ary_op_assign(p, $1, $3, $5, $6, &@3, &@$);
- /*% %*/
- /*% ripper: opassign!(aref_field!($1, escape_Qundef($3)), $5, $6) %*/
+ $3 = make_array($3, &@3);
+ if (nd_type($3) == NODE_BLOCK_PASS) {
+ args = NEW_ARGSCAT($3, $6);
+ args->nd_loc = @$;
+ }
+ else {
+ args = arg_concat($3, $6, &@$);
+ }
+ if ($5 == tOROP) {
+ $5 = 0;
+ }
+ else if ($5 == tANDOP) {
+ $5 = 1;
+ }
+ $$ = NEW_OP_ASGN1($1, $5, args);
+ fixpos($$, $1);
+ $$->nd_loc = @$;
+ /*%
+ $1 = dispatch2(aref_field, $1, escape_Qundef($3));
+ $$ = dispatch3(opassign, $1, $5, $6);
+ %*/
}
| primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
{
- /*%%%*/
value_expr($5);
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $5) %*/
+ $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@$);
}
| primary_value call_op tCONSTANT tOP_ASGN arg_rhs
{
- /*%%%*/
value_expr($5);
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $5) %*/
+ $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@$);
}
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
{
- /*%%%*/
value_expr($5);
- $$ = new_attr_op_assign(p, $1, ID2VAL(idCOLON2), $3, $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $5) %*/
+ $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, &@$);
}
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
{
/*%%%*/
- YYLTYPE loc = code_loc_gen(&@1, &@3);
- $$ = new_const_op_assign(p, NEW_COLON2($1, $3, &loc), $4, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(const_path_field!($1, $3), $4, $5) %*/
+ YYLTYPE location;
+ location.first_loc = @1.first_loc;
+ location.last_loc = @3.last_loc;
+ /*%
+ %*/
+ $$ = const_path_field($1, $3, &location);
+ $$ = new_const_op_assign($$, $4, $5, &@$);
}
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
{
- /*%%%*/
- $$ = new_const_op_assign(p, NEW_COLON3($2, &@$), $3, $4, &@$);
- /*% %*/
- /*% ripper: opassign!(top_const_field!($2), $3, $4) %*/
+ $$ = top_const_field($2);
+ $$ = new_const_op_assign($$, $3, $4, &@$);
}
| backref tOP_ASGN arg_rhs
{
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: assign_error!(opassign!(var_field(p, $1), $2, $3)) %*/
+ $1 = var_field($1);
+ $$ = backref_assign_error($1, new_op_assign($1, $2, $3, &@$), &@$);
}
| arg tDOT2 arg
{
/*%%%*/
value_expr($1);
value_expr($3);
- $$ = NEW_DOT2($1, $3, &@$);
- /*% %*/
- /*% ripper: dot2!($1, $3) %*/
+ $$ = NEW_DOT2($1, $3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(dot2, $1, $3);
+ %*/
}
| arg tDOT3 arg
{
/*%%%*/
value_expr($1);
value_expr($3);
- $$ = NEW_DOT3($1, $3, &@$);
- /*% %*/
- /*% ripper: dot3!($1, $3) %*/
- }
- | arg tDOT2
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @2.end_pos;
- loc.end_pos = @2.end_pos;
-
- value_expr($1);
- $$ = NEW_DOT2($1, new_nil(&loc), &@$);
- /*% %*/
- /*% ripper: dot2!($1, Qnil) %*/
- }
- | arg tDOT3
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @2.end_pos;
- loc.end_pos = @2.end_pos;
-
- value_expr($1);
- $$ = NEW_DOT3($1, new_nil(&loc), &@$);
- /*% %*/
- /*% ripper: dot3!($1, Qnil) %*/
- }
- | tBDOT2 arg
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @1.beg_pos;
- loc.end_pos = @1.beg_pos;
-
- value_expr($2);
- $$ = NEW_DOT2(new_nil(&loc), $2, &@$);
- /*% %*/
- /*% ripper: dot2!(Qnil, $2) %*/
- }
- | tBDOT3 arg
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @1.beg_pos;
- loc.end_pos = @1.beg_pos;
-
- value_expr($2);
- $$ = NEW_DOT3(new_nil(&loc), $2, &@$);
- /*% %*/
- /*% ripper: dot3!(Qnil, $2) %*/
+ $$ = NEW_DOT3($1, $3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(dot3, $1, $3);
+ %*/
}
| arg '+' arg
{
- $$ = call_bin_op(p, $1, '+', $3, &@2, &@$);
+ $$ = call_bin_op($1, '+', $3, &@2, &@$);
}
| arg '-' arg
{
- $$ = call_bin_op(p, $1, '-', $3, &@2, &@$);
+ $$ = call_bin_op($1, '-', $3, &@2, &@$);
}
| arg '*' arg
{
- $$ = call_bin_op(p, $1, '*', $3, &@2, &@$);
+ $$ = call_bin_op($1, '*', $3, &@2, &@$);
}
| arg '/' arg
{
- $$ = call_bin_op(p, $1, '/', $3, &@2, &@$);
+ $$ = call_bin_op($1, '/', $3, &@2, &@$);
}
| arg '%' arg
{
- $$ = call_bin_op(p, $1, '%', $3, &@2, &@$);
+ $$ = call_bin_op($1, '%', $3, &@2, &@$);
}
| arg tPOW arg
{
- $$ = call_bin_op(p, $1, idPow, $3, &@2, &@$);
+ $$ = call_bin_op($1, idPow, $3, &@2, &@$);
}
| tUMINUS_NUM simple_numeric tPOW arg
{
- $$ = call_uni_op(p, call_bin_op(p, $2, idPow, $4, &@2, &@$), idUMinus, &@1, &@$);
+ $$ = call_uni_op(call_bin_op($2, idPow, $4, &@2, &@$), idUMinus, &@1, &@$);
}
| tUPLUS arg
{
- $$ = call_uni_op(p, $2, idUPlus, &@1, &@$);
+ $$ = call_uni_op($2, idUPlus, &@1, &@$);
}
| tUMINUS arg
{
- $$ = call_uni_op(p, $2, idUMinus, &@1, &@$);
+ $$ = call_uni_op($2, idUMinus, &@1, &@$);
}
| arg '|' arg
{
- $$ = call_bin_op(p, $1, '|', $3, &@2, &@$);
+ $$ = call_bin_op($1, '|', $3, &@2, &@$);
}
| arg '^' arg
{
- $$ = call_bin_op(p, $1, '^', $3, &@2, &@$);
+ $$ = call_bin_op($1, '^', $3, &@2, &@$);
}
| arg '&' arg
{
- $$ = call_bin_op(p, $1, '&', $3, &@2, &@$);
+ $$ = call_bin_op($1, '&', $3, &@2, &@$);
}
| arg tCMP arg
{
- $$ = call_bin_op(p, $1, idCmp, $3, &@2, &@$);
+ $$ = call_bin_op($1, idCmp, $3, &@2, &@$);
}
| rel_expr %prec tCMP
| arg tEQ arg
{
- $$ = call_bin_op(p, $1, idEq, $3, &@2, &@$);
+ $$ = call_bin_op($1, idEq, $3, &@2, &@$);
}
| arg tEQQ arg
{
- $$ = call_bin_op(p, $1, idEqq, $3, &@2, &@$);
+ $$ = call_bin_op($1, idEqq, $3, &@2, &@$);
}
| arg tNEQ arg
{
- $$ = call_bin_op(p, $1, idNeq, $3, &@2, &@$);
+ $$ = call_bin_op($1, idNeq, $3, &@2, &@$);
}
| arg tMATCH arg
{
- $$ = match_op(p, $1, $3, &@2, &@$);
+ $$ = match_op($1, $3, &@2, &@$);
}
| arg tNMATCH arg
{
- $$ = call_bin_op(p, $1, idNeqTilde, $3, &@2, &@$);
+ $$ = call_bin_op($1, idNeqTilde, $3, &@2, &@$);
}
| '!' arg
{
- $$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
+ $$ = call_uni_op(method_cond($2, &@2), '!', &@1, &@$);
}
| '~' arg
{
- $$ = call_uni_op(p, $2, '~', &@1, &@$);
+ $$ = call_uni_op($2, '~', &@1, &@$);
}
| arg tLSHFT arg
{
- $$ = call_bin_op(p, $1, idLTLT, $3, &@2, &@$);
+ $$ = call_bin_op($1, idLTLT, $3, &@2, &@$);
}
| arg tRSHFT arg
{
- $$ = call_bin_op(p, $1, idGTGT, $3, &@2, &@$);
+ $$ = call_bin_op($1, idGTGT, $3, &@2, &@$);
}
| arg tANDOP arg
{
- $$ = logop(p, idANDOP, $1, $3, &@2, &@$);
+ $$ = logop(idANDOP, $1, $3, &@2, &@$);
}
| arg tOROP arg
{
- $$ = logop(p, idOROP, $1, $3, &@2, &@$);
+ $$ = logop(idOROP, $1, $3, &@2, &@$);
}
- | keyword_defined opt_nl {p->in_defined = 1;} arg
+ | keyword_defined opt_nl {in_defined = 1;} arg
{
- p->in_defined = 0;
- $$ = new_defined(p, $4, &@$);
+ in_defined = 0;
+ $$ = new_defined($4, &@$);
}
| arg '?' arg opt_nl ':' arg
{
/*%%%*/
value_expr($1);
- $$ = new_if(p, $1, $3, $6, &@$);
+ $$ = new_if($1, $3, $6, &@$);
fixpos($$, $1);
- /*% %*/
- /*% ripper: ifop!($1, $3, $6) %*/
+ /*%
+ $$ = dispatch3(ifop, $1, $3, $6);
+ %*/
}
| primary
{
@@ -2358,19 +2385,24 @@ relop : '>' {$$ = '>';}
rel_expr : arg relop arg %prec '>'
{
- $$ = call_bin_op(p, $1, $2, $3, &@2, &@$);
+ $$ = call_bin_op($1, $2, $3, &@2, &@$);
}
| rel_expr relop arg %prec '>'
{
rb_warning1("comparison '%s' after comparison", WARN_ID($2));
- $$ = call_bin_op(p, $1, $2, $3, &@2, &@$);
+ $$ = call_bin_op($1, $2, $3, &@2, &@$);
}
;
arg_value : arg
{
+ /*%%%*/
value_expr($1);
$$ = $1;
+ if (!$$) $$ = NEW_NIL();
+ /*%
+ $$ = $1;
+ %*/
}
;
@@ -2382,32 +2414,40 @@ aref_args : none
| args ',' assocs trailer
{
/*%%%*/
- $$ = $3 ? arg_append(p, $1, new_hash(p, $3, &@3), &@$) : $1;
- /*% %*/
- /*% ripper: args_add!($1, bare_assoc_hash!($3)) %*/
+ $$ = $3 ? arg_append($1, new_hash($3, &@3), &@$) : $1;
+ /*%
+ $$ = arg_add_assocs($1, $3);
+ %*/
}
| assocs trailer
{
/*%%%*/
- $$ = $1 ? NEW_LIST(new_hash(p, $1, &@1), &@$) : 0;
- /*% %*/
- /*% ripper: args_add!(args_new!, bare_assoc_hash!($1)) %*/
+ $$ = $1 ? new_list(new_hash($1, &@1), &@$) : 0;
+ /*%
+ $$ = arg_add_assocs(arg_new(), $1);
+ %*/
}
;
arg_rhs : arg %prec tOP_ASGN
{
+ /*%%%*/
value_expr($1);
$$ = $1;
+ /*%
+ %*/
}
| arg modifier_rescue arg
{
/*%%%*/
- YYLTYPE loc = code_loc_gen(&@2, &@3);
+ YYLTYPE location;
+ location.first_loc = @2.first_loc;
+ location.last_loc = @3.last_loc;
value_expr($1);
- $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &loc), 0, &@$);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &location), 0, &@$);
+ /*%
+ $$ = dispatch2(rescue_mod, $1, $3);
+ %*/
}
;
@@ -2415,61 +2455,9 @@ paren_args : '(' opt_call_args rparen
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: arg_paren!(escape_Qundef($2)) %*/
- }
- | '(' args ',' args_forward rparen
- {
- if (!local_id(p, idFWD_REST) ||
-#if idFWD_KWREST
- !local_id(p, idFWD_KWREST) ||
-#endif
- !local_id(p, idFWD_BLOCK)) {
- compile_error(p, "unexpected ...");
- $$ = Qnone;
- }
- else {
- /*%%%*/
- NODE *splat = NEW_SPLAT(NEW_LVAR(idFWD_REST, &@4), &@4);
-#if idFWD_KWREST
- NODE *kwrest = list_append(p, NEW_LIST(0, &@4), NEW_LVAR(idFWD_KWREST, &@4));
-#endif
- NODE *block = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, &@4), &@4);
- $$ = rest_arg_append(p, $2, splat, &@$);
-#if idFWD_KWREST
- $$ = arg_append(p, $$, new_hash(p, kwrest, &@4), &@4);
-#endif
- $$ = arg_blk_pass($$, block);
- /*% %*/
- /*% ripper: arg_paren!(args_add!($2, $4)) %*/
- }
- }
- | '(' args_forward rparen
- {
- if (!local_id(p, idFWD_REST) ||
-#if idFWD_KWREST
- !local_id(p, idFWD_KWREST) ||
-#endif
- !local_id(p, idFWD_BLOCK)) {
- compile_error(p, "unexpected ...");
- $$ = Qnone;
- }
- else {
- /*%%%*/
- NODE *splat = NEW_SPLAT(NEW_LVAR(idFWD_REST, &@2), &@2);
-#if idFWD_KWREST
- NODE *kwrest = list_append(p, NEW_LIST(0, &@2), NEW_LVAR(idFWD_KWREST, &@2));
-#endif
- NODE *block = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, &@2), &@2);
-#if idFWD_KWREST
- $$ = arg_append(p, splat, new_hash(p, kwrest, &@2), &@2);
-#else
- $$ = splat;
-#endif
- $$ = arg_blk_pass($$, block);
- /*% %*/
- /*% ripper: arg_paren!($2) %*/
- }
+ /*%
+ $$ = dispatch1(arg_paren, escape_Qundef($2));
+ %*/
}
;
@@ -2486,16 +2474,18 @@ opt_call_args : none
| args ',' assocs ','
{
/*%%%*/
- $$ = $3 ? arg_append(p, $1, new_hash(p, $3, &@3), &@$) : $1;
- /*% %*/
- /*% ripper: args_add!($1, bare_assoc_hash!($3)) %*/
+ $$ = $3 ? arg_append($1, new_hash($3, &@3), &@$) : $1;
+ /*%
+ $$ = arg_add_assocs($1, $3);
+ %*/
}
| assocs ','
{
/*%%%*/
- $$ = $1 ? NEW_LIST(new_hash(p, $1, &@1), &@1) : 0;
- /*% %*/
- /*% ripper: args_add!(args_new!, bare_assoc_hash!($1)) %*/
+ $$ = $1 ? new_list(new_hash($1, &@1), &@1) : 0;
+ /*%
+ $$ = arg_add_assocs(arg_new(), $1);
+ %*/
}
;
@@ -2503,70 +2493,55 @@ call_args : command
{
/*%%%*/
value_expr($1);
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: args_add!(args_new!, $1) %*/
+ $$ = new_list($1, &@$);
+ /*%
+ $$ = arg_add(arg_new(), $1);
+ %*/
}
| args opt_block_arg
{
/*%%%*/
$$ = arg_blk_pass($1, $2);
- /*% %*/
- /*% ripper: args_add_block!($1, $2) %*/
+ /*%
+ $$ = arg_add_optblock($1, $2);
+ %*/
}
| assocs opt_block_arg
{
/*%%%*/
- $$ = $1 ? NEW_LIST(new_hash(p, $1, &@1), &@1) : 0;
+ $$ = $1 ? new_list(new_hash($1, &@1), &@1) : 0;
$$ = arg_blk_pass($$, $2);
- /*% %*/
- /*% ripper: args_add_block!(args_add!(args_new!, bare_assoc_hash!($1)), $2) %*/
+ /*%
+ $$ = arg_add_assocs(arg_new(), $1);
+ $$ = arg_add_optblock($$, $2);
+ %*/
}
| args ',' assocs opt_block_arg
{
/*%%%*/
- $$ = $3 ? arg_append(p, $1, new_hash(p, $3, &@3), &@$) : $1;
+ $$ = $3 ? arg_append($1, new_hash($3, &@3), &@$) : $1;
$$ = arg_blk_pass($$, $4);
- /*% %*/
- /*% ripper: args_add_block!(args_add!($1, bare_assoc_hash!($3)), $4) %*/
+ /*%
+ $$ = arg_add_optblock(arg_add_assocs($1, $3), $4);
+ %*/
}
| block_arg
- /*% ripper[brace]: args_add_block!(args_new!, $1) %*/
+ /*%c%*/
+ /*%c
+ {
+ $$ = arg_add_block(arg_new(), $1);
+ }
+ %*/
;
command_args : {
- /* If call_args starts with a open paren '(' or '[',
- * look-ahead reading of the letters calls CMDARG_PUSH(0),
- * but the push must be done after CMDARG_PUSH(1).
- * So this code makes them consistent by first cancelling
- * the premature CMDARG_PUSH(0), doing CMDARG_PUSH(1),
- * and finally redoing CMDARG_PUSH(0).
- */
- int lookahead = 0;
- switch (yychar) {
- case '(': case tLPAREN: case tLPAREN_ARG: case '[': case tLBRACK:
- lookahead = 1;
- }
- if (lookahead) CMDARG_POP();
+ $<val>$ = cmdarg_stack;
CMDARG_PUSH(1);
- if (lookahead) CMDARG_PUSH(0);
}
call_args
{
- /* call_args can be followed by tLBRACE_ARG (that does CMDARG_PUSH(0) in the lexer)
- * but the push must be done after CMDARG_POP() in the parser.
- * So this code does CMDARG_POP() to pop 0 pushed by tLBRACE_ARG,
- * CMDARG_POP() to pop 1 pushed by command_args,
- * and CMDARG_PUSH(0) to restore back the flag set by tLBRACE_ARG.
- */
- int lookahead = 0;
- switch (yychar) {
- case tLBRACE_ARG:
- lookahead = 1;
- }
- if (lookahead) CMDARG_POP();
- CMDARG_POP();
- if (lookahead) CMDARG_PUSH(0);
+ /* CMDARG_POP() */
+ CMDARG_SET($<val>1);
$$ = $2;
}
;
@@ -2574,9 +2549,11 @@ command_args : {
block_arg : tAMPER arg_value
{
/*%%%*/
- $$ = NEW_BLOCK_PASS($2, &@$);
- /*% %*/
- /*% ripper: $2 %*/
+ $$ = NEW_BLOCK_PASS($2);
+ $$->nd_loc = @$;
+ /*%
+ $$ = $2;
+ %*/
}
;
@@ -2593,30 +2570,47 @@ opt_block_arg : ',' block_arg
args : arg_value
{
/*%%%*/
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: args_add!(args_new!, $1) %*/
+ $$ = new_list($1, &@$);
+ /*%
+ $$ = arg_add(arg_new(), $1);
+ %*/
}
| tSTAR arg_value
{
/*%%%*/
- $$ = NEW_SPLAT($2, &@$);
- /*% %*/
- /*% ripper: args_add_star!(args_new!, $2) %*/
+ $$ = NEW_SPLAT($2);
+ $$->nd_loc = @$;
+ /*%
+ $$ = arg_add_star(arg_new(), $2);
+ %*/
}
| args ',' arg_value
{
/*%%%*/
- $$ = last_arg_append(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: args_add!($1, $3) %*/
+ NODE *n1;
+ if ((n1 = splat_array($1)) != 0) {
+ $$ = list_append(n1, $3);
+ }
+ else {
+ $$ = arg_append($1, $3, &@$);
+ }
+ /*%
+ $$ = arg_add($1, $3);
+ %*/
}
| args ',' tSTAR arg_value
{
/*%%%*/
- $$ = rest_arg_append(p, $1, $4, &@$);
- /*% %*/
- /*% ripper: args_add_star!($1, $4) %*/
+ NODE *n1;
+ if ((nd_type($4) == NODE_ARRAY) && (n1 = splat_array($1)) != 0) {
+ $$ = list_concat(n1, $4);
+ }
+ else {
+ $$ = arg_concat($1, $4, &@$);
+ }
+ /*%
+ $$ = arg_add_star($1, $4);
+ %*/
}
;
@@ -2627,23 +2621,40 @@ mrhs_arg : mrhs
mrhs : args ',' arg_value
{
/*%%%*/
- $$ = last_arg_append(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: mrhs_add!(mrhs_new_from_args!($1), $3) %*/
+ NODE *n1;
+ if ((n1 = splat_array($1)) != 0) {
+ $$ = list_append(n1, $3);
+ }
+ else {
+ $$ = arg_append($1, $3, &@$);
+ }
+ /*%
+ $$ = mrhs_add(args2mrhs($1), $3);
+ %*/
}
| args ',' tSTAR arg_value
{
/*%%%*/
- $$ = rest_arg_append(p, $1, $4, &@$);
- /*% %*/
- /*% ripper: mrhs_add_star!(mrhs_new_from_args!($1), $4) %*/
+ NODE *n1;
+ if (nd_type($4) == NODE_ARRAY &&
+ (n1 = splat_array($1)) != 0) {
+ $$ = list_concat(n1, $4);
+ }
+ else {
+ $$ = arg_concat($1, $4, &@$);
+ }
+ /*%
+ $$ = mrhs_add_star(args2mrhs($1), $4);
+ %*/
}
| tSTAR arg_value
{
/*%%%*/
- $$ = NEW_SPLAT($2, &@$);
- /*% %*/
- /*% ripper: mrhs_add_star!(mrhs_new!, $2) %*/
+ $$ = NEW_SPLAT($2);
+ $$->nd_loc = @$;
+ /*%
+ $$ = mrhs_add_star(mrhs_new(), $2);
+ %*/
}
;
@@ -2660,144 +2671,177 @@ primary : literal
| tFID
{
/*%%%*/
- $$ = NEW_FCALL($1, 0, &@$);
- /*% %*/
- /*% ripper: method_add_arg!(fcall!($1), args_new!) %*/
+ $$ = new_fcall($1, 0, &@$);
+ /*%
+ $$ = method_arg(dispatch1(fcall, $1), arg_new());
+ %*/
}
| k_begin
{
- CMDARG_PUSH(0);
+ $<val>1 = cmdarg_stack;
+ CMDARG_SET(0);
+ /*%%%*/
+ $<num>$ = ruby_sourceline;
+ /*%
+ %*/
}
bodystmt
k_end
{
- CMDARG_POP();
+ CMDARG_SET($<val>1);
/*%%%*/
- set_line_body($3, @1.end_pos.lineno);
- $$ = NEW_BEGIN($3, &@$);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
- /*% ripper: begin!($3) %*/
+ if ($3 == NULL) {
+ $$ = NEW_NIL();
+ $$->nd_loc = @$;
+ }
+ else {
+ set_line_body($3, $<num>2);
+ $$ = new_begin($3, &@$);
+ }
+ nd_set_line($$, $<num>2);
+ /*%
+ $$ = dispatch1(begin, $3);
+ %*/
}
| tLPAREN_ARG {SET_LEX_STATE(EXPR_ENDARG);} rparen
{
/*%%%*/
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: paren!(0) %*/
+ $$ = new_begin(0, &@$);
+ /*%
+ $$ = dispatch1(paren, 0);
+ %*/
+ }
+ | tLPAREN_ARG
+ {
+ $<val>1 = cmdarg_stack;
+ CMDARG_SET(0);
}
- | tLPAREN_ARG stmt {SET_LEX_STATE(EXPR_ENDARG);} rparen
+ stmt {SET_LEX_STATE(EXPR_ENDARG);} rparen
{
+ CMDARG_SET($<val>1);
/*%%%*/
- if (nd_type($2) == NODE_SELF) $2->nd_state = 0;
- $$ = $2;
- /*% %*/
- /*% ripper: paren!($2) %*/
+ $$ = $3;
+ /*%
+ $$ = dispatch1(paren, $3);
+ %*/
}
| tLPAREN compstmt ')'
{
/*%%%*/
- if (nd_type($2) == NODE_SELF) $2->nd_state = 0;
$$ = $2;
- /*% %*/
- /*% ripper: paren!($2) %*/
+ /*%
+ $$ = dispatch1(paren, $2);
+ %*/
}
| primary_value tCOLON2 tCONSTANT
{
/*%%%*/
- $$ = NEW_COLON2($1, $3, &@$);
- /*% %*/
- /*% ripper: const_path_ref!($1, $3) %*/
+ $$ = NEW_COLON2($1, $3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(const_path_ref, $1, $3);
+ %*/
}
| tCOLON3 tCONSTANT
{
/*%%%*/
- $$ = NEW_COLON3($2, &@$);
- /*% %*/
- /*% ripper: top_const_ref!($2) %*/
+ $$ = NEW_COLON3($2);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(top_const_ref, $2);
+ %*/
}
| tLBRACK aref_args ']'
{
/*%%%*/
- $$ = make_list($2, &@$);
- /*% %*/
- /*% ripper: array!(escape_Qundef($2)) %*/
+ $$ = make_array($2, &@$);
+ /*%
+ $$ = dispatch1(array, escape_Qundef($2));
+ %*/
}
| tLBRACE assoc_list '}'
{
/*%%%*/
- $$ = new_hash(p, $2, &@$);
- $$->nd_brace = TRUE;
- /*% %*/
- /*% ripper: hash!(escape_Qundef($2)) %*/
+ $$ = new_hash($2, &@$);
+ $$->nd_alen = TRUE;
+ /*%
+ $$ = dispatch1(hash, escape_Qundef($2));
+ %*/
}
| k_return
{
/*%%%*/
- $$ = NEW_RETURN(0, &@$);
- /*% %*/
- /*% ripper: return0! %*/
+ $$ = NEW_RETURN(0);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch0(return0);
+ %*/
}
| keyword_yield '(' call_args rparen
{
/*%%%*/
- $$ = new_yield(p, $3, &@$);
- /*% %*/
- /*% ripper: yield!(paren!($3)) %*/
+ $$ = new_yield($3, &@$);
+ /*%
+ $$ = dispatch1(yield, dispatch1(paren, $3));
+ %*/
}
| keyword_yield '(' rparen
{
/*%%%*/
- $$ = NEW_YIELD(0, &@$);
- /*% %*/
- /*% ripper: yield!(paren!(args_new!)) %*/
+ $$ = NEW_YIELD(0);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(yield, dispatch1(paren, arg_new()));
+ %*/
}
| keyword_yield
{
/*%%%*/
- $$ = NEW_YIELD(0, &@$);
- /*% %*/
- /*% ripper: yield0! %*/
+ $$ = NEW_YIELD(0);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch0(yield0);
+ %*/
}
- | keyword_defined opt_nl '(' {p->in_defined = 1;} expr rparen
+ | keyword_defined opt_nl '(' {in_defined = 1;} expr rparen
{
- p->in_defined = 0;
- $$ = new_defined(p, $5, &@$);
+ in_defined = 0;
+ $$ = new_defined($5, &@$);
}
| keyword_not '(' expr rparen
{
- $$ = call_uni_op(p, method_cond(p, $3, &@3), METHOD_NOT, &@1, &@$);
+ $$ = call_uni_op(method_cond($3, &@3), METHOD_NOT, &@1, &@$);
}
| keyword_not '(' rparen
{
- $$ = call_uni_op(p, method_cond(p, new_nil(&@2), &@2), METHOD_NOT, &@1, &@$);
+ $$ = call_uni_op(method_cond(new_nil(&@2), &@2), METHOD_NOT, &@1, &@$);
}
| fcall brace_block
{
/*%%%*/
- $$ = method_add_block(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: method_add_block!(method_add_arg!(fcall!($1), args_new!), $2) %*/
+ $2->nd_iter = $1;
+ $2->nd_loc = @$;
+ $$ = $2;
+ /*%
+ $$ = method_arg(dispatch1(fcall, $1), arg_new());
+ $$ = method_add_block($$, $2);
+ %*/
}
| method_call
| method_call brace_block
{
/*%%%*/
- block_dup_check(p, $1->nd_args, $2);
- $$ = method_add_block(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: method_add_block!($1, $2) %*/
- }
- | tLAMBDA
- {
- token_info_push(p, "->", &@1);
+ block_dup_check($1->nd_args, $2);
+ $2->nd_iter = $1;
+ $2->nd_loc = @$;
+ $$ = $2;
+ /*%
+ $$ = method_add_block($1, $2);
+ %*/
}
- lambda
+ | tLAMBDA lambda
{
- $$ = $3;
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*% %*/
+ $$ = $2;
}
| k_if expr_value then
compstmt
@@ -2805,10 +2849,11 @@ primary : literal
k_end
{
/*%%%*/
- $$ = new_if(p, $2, $4, $5, &@$);
+ $$ = new_if($2, $4, $5, &@$);
fixpos($$, $2);
- /*% %*/
- /*% ripper: if!($2, $4, escape_Qundef($5)) %*/
+ /*%
+ $$ = dispatch3(if, $2, $4, escape_Qundef($5));
+ %*/
}
| k_unless expr_value then
compstmt
@@ -2816,72 +2861,62 @@ primary : literal
k_end
{
/*%%%*/
- $$ = new_unless(p, $2, $4, $5, &@$);
+ $$ = new_unless($2, $4, $5, &@$);
fixpos($$, $2);
- /*% %*/
- /*% ripper: unless!($2, $4, escape_Qundef($5)) %*/
+ /*%
+ $$ = dispatch3(unless, $2, $4, escape_Qundef($5));
+ %*/
}
- | k_while expr_value_do
+ | k_while {COND_PUSH(1);} expr_value do {COND_POP();}
compstmt
k_end
{
/*%%%*/
- $$ = NEW_WHILE(cond(p, $2, &@2), $3, 1, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: while!($2, $3) %*/
+ $$ = NEW_WHILE(cond($3, &@3), $6, 1);
+ fixpos($$, $3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(while, $3, $6);
+ %*/
}
- | k_until expr_value_do
+ | k_until {COND_PUSH(1);} expr_value do {COND_POP();}
compstmt
k_end
{
/*%%%*/
- $$ = NEW_UNTIL(cond(p, $2, &@2), $3, 1, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: until!($2, $3) %*/
+ $$ = NEW_UNTIL(cond($3, &@3), $6, 1);
+ fixpos($$, $3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(until, $3, $6);
+ %*/
}
| k_case expr_value opt_terms
- {
- $<val>$ = p->case_labels;
- p->case_labels = Qnil;
- }
case_body
k_end
{
- if (RTEST(p->case_labels)) rb_hash_clear(p->case_labels);
- p->case_labels = $<val>4;
/*%%%*/
- $$ = NEW_CASE($2, $5, &@$);
+ $$ = NEW_CASE($2, $4);
fixpos($$, $2);
- /*% %*/
- /*% ripper: case!($2, $5) %*/
- }
- | k_case opt_terms
- {
- $<val>$ = p->case_labels;
- p->case_labels = 0;
- }
- case_body
- k_end
- {
- if (RTEST(p->case_labels)) rb_hash_clear(p->case_labels);
- p->case_labels = $<val>3;
- /*%%%*/
- $$ = NEW_CASE2($4, &@$);
- /*% %*/
- /*% ripper: case!(Qnil, $4) %*/
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(case, $2, $4);
+ %*/
}
- | k_case expr_value opt_terms
- p_case_body
- k_end
+ | k_case opt_terms case_body k_end
{
/*%%%*/
- $$ = new_case3(p, $2, $4, &@$);
- /*% %*/
- /*% ripper: case!($2, $4) %*/
+ $$ = NEW_CASE2($3);
+ nd_set_line($3, $<num>1);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(case, Qnil, $3);
+ %*/
}
- | k_for for_var keyword_in expr_value_do
+ | k_for for_var keyword_in
+ {COND_PUSH(1);}
+ expr_value do
+ {COND_POP();}
compstmt
k_end
{
@@ -2895,114 +2930,129 @@ primary : literal
* #=>
* e.each{|x| a, = x}
*/
- ID id = internal_id(p);
- NODE *m = NEW_ARGS_AUX(0, 0, &NULL_LOC);
- NODE *args, *scope, *internal_var = NEW_DVAR(id, &@2);
- ID *tbl = ALLOC_N(ID, 3);
- tbl[0] = 1 /* length of local var table */; tbl[1] = id /* internal id */;
- rb_ast_add_local_table(p->ast, tbl);
+ ID id = internal_id();
+ ID *tbl = ALLOC_N(ID, 2);
+ NODE *m = NEW_ARGS_AUX(0, 0);
+ NODE *args, *scope;
switch (nd_type($2)) {
+ case NODE_MASGN:
+ m->nd_next = node_assign($2, new_for(new_dvar(id, &@2), 0, 0, &@2), &@2);
+ args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@2), &@2);
+ break;
case NODE_LASGN:
case NODE_DASGN:
- case NODE_DASGN_CURR: /* e.each {|internal_var| a = internal_var; ... } */
- $2->nd_value = internal_var;
- id = 0;
+ case NODE_DASGN_CURR:
+ $2->nd_value = new_dvar(id, &@2);
m->nd_plen = 1;
m->nd_next = $2;
+ args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0, &@2), &@2);
break;
- case NODE_MASGN: /* e.each {|*internal_var| a, b, c = (internal_var.length == 1 && Array === (tmp = internal_var[0]) ? tmp : internal_var); ... } */
- m->nd_next = node_assign(p, $2, NEW_FOR_MASGN(internal_var, &@2), &@2);
- break;
- default: /* e.each {|*internal_var| @a, B, c[1], d.attr = internal_val; ... } */
- m->nd_next = node_assign(p, NEW_MASGN(NEW_LIST($2, &@2), 0, &@2), internal_var, &@2);
+ default:
+ {
+ NODE *masgn = new_masgn(new_list($2, &@2), 0, &@2);
+ m->nd_next = node_assign(masgn, new_dvar(id, &@2), &@2);
+ args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@2), &@2);
+ break;
+ }
}
- /* {|*internal_id| <m> = internal_id; ... } */
- args = new_args(p, m, 0, id, 0, new_args_tail(p, 0, 0, 0, &@2), &@2);
- scope = NEW_NODE(NODE_SCOPE, tbl, $5, args, &@$);
- $$ = NEW_FOR($4, scope, &@$);
+ add_mark_object((VALUE)rb_imemo_alloc_new((VALUE)tbl, 0, 0, 0));
+ scope = NEW_NODE(NODE_SCOPE, tbl, $8, args);
+ scope->nd_loc = @$;
+ tbl[0] = 1; tbl[1] = id;
+ $$ = new_for(0, $5, scope, &@$);
fixpos($$, $2);
- /*% %*/
- /*% ripper: for!($2, $4, $5) %*/
+ /*%
+ $$ = dispatch3(for, $2, $5, $8);
+ %*/
}
| k_class cpath superclass
{
- if (p->in_def) {
- YYLTYPE loc = code_loc_gen(&@1, &@2);
- yyerror1(&loc, "class definition in method body");
- }
- $<num>1 = p->in_class;
- p->in_class = 1;
- local_push(p, 0);
+ if (in_def)
+ yyerror0("class definition in method body");
+ $<num>1 = in_class;
+ in_class = 1;
+ local_push(0);
+ /*%%%*/
+ $<num>$ = ruby_sourceline;
+ /*%
+ %*/
}
bodystmt
k_end
{
/*%%%*/
- $$ = NEW_CLASS($2, $5, $3, &@$);
- nd_set_line($$->nd_body, @6.end_pos.lineno);
- set_line_body($5, @3.end_pos.lineno);
- nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: class!($2, $3, $5) %*/
- local_pop(p);
- p->in_class = $<num>1 & 1;
+ $$ = NEW_CLASS($2, $5, $3);
+ $$->nd_body->nd_loc = @$;
+ set_line_body($5, $<num>4);
+ nd_set_line($$, $<num>4);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch3(class, $2, $3, $5);
+ %*/
+ local_pop();
+ in_class = $<num>1 & 1;
}
| k_class tLSHFT expr
{
- $<num>$ = (p->in_class << 1) | p->in_def;
- p->in_def = 0;
- p->in_class = 0;
- local_push(p, 0);
+ $<num>$ = (in_class << 1) | in_def;
+ in_def = 0;
+ in_class = 0;
+ local_push(0);
}
term
bodystmt
k_end
{
/*%%%*/
- $$ = NEW_SCLASS($3, $6, &@$);
- nd_set_line($$->nd_body, @7.end_pos.lineno);
+ $$ = NEW_SCLASS($3, $6);
+ $$->nd_body->nd_loc = @$;
set_line_body($6, nd_line($3));
fixpos($$, $3);
- /*% %*/
- /*% ripper: sclass!($3, $6) %*/
- local_pop(p);
- p->in_def = $<num>4 & 1;
- p->in_class = ($<num>4 >> 1) & 1;
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(sclass, $3, $6);
+ %*/
+ local_pop();
+ in_def = $<num>4 & 1;
+ in_class = ($<num>4 >> 1) & 1;
}
| k_module cpath
{
- if (p->in_def) {
- YYLTYPE loc = code_loc_gen(&@1, &@2);
- yyerror1(&loc, "module definition in method body");
- }
- $<num>1 = p->in_class;
- p->in_class = 1;
- local_push(p, 0);
+ if (in_def)
+ yyerror0("module definition in method body");
+ $<num>1 = in_class;
+ in_class = 1;
+ local_push(0);
+ /*%%%*/
+ $<num>$ = ruby_sourceline;
+ /*%
+ %*/
}
bodystmt
k_end
{
/*%%%*/
- $$ = NEW_MODULE($2, $4, &@$);
- nd_set_line($$->nd_body, @5.end_pos.lineno);
- set_line_body($4, @2.end_pos.lineno);
- nd_set_line($$, @2.end_pos.lineno);
- /*% %*/
- /*% ripper: module!($2, $4) %*/
- local_pop(p);
- p->in_class = $<num>1 & 1;
+ $$ = NEW_MODULE($2, $4);
+ $$->nd_body->nd_loc = @$;
+ set_line_body($4, $<num>3);
+ nd_set_line($$, $<num>3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch2(module, $2, $4);
+ %*/
+ local_pop();
+ in_class = $<num>1 & 1;
}
| k_def fname
{
- numparam_name(p, get_id($2));
- local_push(p, 0);
- $<id>$ = p->cur_arg;
- p->cur_arg = 0;
+ local_push(0);
+ $<id>$ = current_arg;
+ current_arg = 0;
}
{
- $<num>$ = p->in_def;
- p->in_def = 1;
+ $<num>$ = in_def;
+ in_def = 1;
}
f_arglist
bodystmt
@@ -3010,25 +3060,27 @@ primary : literal
{
/*%%%*/
NODE *body = remove_begin($6);
- reduce_nodes(p, &body);
- $$ = NEW_DEFN($2, $5, body, &@$);
- nd_set_line($$->nd_defn, @7.end_pos.lineno);
- set_line_body(body, @1.beg_pos.lineno);
- /*% %*/
- /*% ripper: def!($2, $5, $6) %*/
- local_pop(p);
- p->in_def = $<num>4 & 1;
- p->cur_arg = $<id>3;
+ reduce_nodes(&body);
+ $$ = NEW_DEFN($2, $5, body, METHOD_VISI_PRIVATE);
+ $$->nd_defn->nd_loc = @$;
+ set_line_body(body, $<num>1);
+ nd_set_line($$, $<num>1);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch3(def, $2, $5, $6);
+ %*/
+ local_pop();
+ in_def = $<num>4 & 1;
+ current_arg = $<id>3;
}
| k_def singleton dot_or_colon {SET_LEX_STATE(EXPR_FNAME);} fname
{
- numparam_name(p, get_id($5));
- $<num>4 = p->in_def;
- p->in_def = 1;
+ $<num>4 = in_def;
+ in_def = 1;
SET_LEX_STATE(EXPR_ENDFN|EXPR_LABEL); /* force for args */
- local_push(p, 0);
- $<id>$ = p->cur_arg;
- p->cur_arg = 0;
+ local_push(0);
+ $<id>$ = current_arg;
+ current_arg = 0;
}
f_arglist
bodystmt
@@ -3036,218 +3088,193 @@ primary : literal
{
/*%%%*/
NODE *body = remove_begin($8);
- reduce_nodes(p, &body);
- $$ = NEW_DEFS($2, $5, $7, body, &@$);
- nd_set_line($$->nd_defn, @9.end_pos.lineno);
- set_line_body(body, @1.beg_pos.lineno);
- /*% %*/
- /*% ripper: defs!($2, $3, $5, $7, $8) %*/
- local_pop(p);
- p->in_def = $<num>4 & 1;
- p->cur_arg = $<id>6;
+ reduce_nodes(&body);
+ $$ = NEW_DEFS($2, $5, $7, body);
+ $$->nd_defn->nd_loc = @$;
+ set_line_body(body, $<num>1);
+ nd_set_line($$, $<num>1);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch5(defs, $2, $<val>3, $5, $7, $8);
+ %*/
+ local_pop();
+ in_def = $<num>4 & 1;
+ current_arg = $<id>6;
}
| keyword_break
{
/*%%%*/
- $$ = NEW_BREAK(0, &@$);
- /*% %*/
- /*% ripper: break!(args_new!) %*/
+ $$ = NEW_BREAK(0);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(break, arg_new());
+ %*/
}
| keyword_next
{
/*%%%*/
- $$ = NEW_NEXT(0, &@$);
- /*% %*/
- /*% ripper: next!(args_new!) %*/
+ $$ = NEW_NEXT(0);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(next, arg_new());
+ %*/
}
| keyword_redo
{
/*%%%*/
- $$ = NEW_REDO(&@$);
- /*% %*/
- /*% ripper: redo! %*/
+ $$ = NEW_REDO();
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch0(redo);
+ %*/
}
| keyword_retry
{
/*%%%*/
- $$ = NEW_RETRY(&@$);
- /*% %*/
- /*% ripper: retry! %*/
+ $$ = NEW_RETRY();
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch0(retry);
+ %*/
}
;
primary_value : primary
{
+ /*%%%*/
value_expr($1);
$$ = $1;
+ if (!$$) $$ = NEW_NIL();
+ /*%
+ $$ = $1;
+ %*/
}
;
k_begin : keyword_begin
{
- token_info_push(p, "begin", &@$);
+ token_info_push("begin");
}
;
k_if : keyword_if
{
- WARN_EOL("if");
- token_info_push(p, "if", &@$);
- if (p->token_info && p->token_info->nonspc &&
- p->token_info->next && !strcmp(p->token_info->next->token, "else")) {
- const char *tok = p->lex.ptok;
- const char *beg = p->lex.pbeg + p->token_info->next->beg.column;
- beg += rb_strlen_lit("else");
- while (beg < tok && ISSPACE(*beg)) beg++;
- if (beg == tok) {
- p->token_info->nonspc = 0;
- }
- }
+ token_info_push("if");
}
;
k_unless : keyword_unless
{
- token_info_push(p, "unless", &@$);
+ token_info_push("unless");
}
;
k_while : keyword_while
{
- token_info_push(p, "while", &@$);
+ token_info_push("while");
}
;
k_until : keyword_until
{
- token_info_push(p, "until", &@$);
+ token_info_push("until");
}
;
k_case : keyword_case
{
- token_info_push(p, "case", &@$);
+ token_info_push("case");
+ /*%%%*/
+ $<num>$ = ruby_sourceline;
+ /*%
+ %*/
}
;
k_for : keyword_for
{
- token_info_push(p, "for", &@$);
+ token_info_push("for");
}
;
k_class : keyword_class
{
- token_info_push(p, "class", &@$);
+ token_info_push("class");
}
;
k_module : keyword_module
{
- token_info_push(p, "module", &@$);
+ token_info_push("module");
}
;
k_def : keyword_def
{
- token_info_push(p, "def", &@$);
- }
- ;
-
-k_do : keyword_do
- {
- token_info_push(p, "do", &@$);
- }
- ;
-
-k_do_block : keyword_do_block
- {
- token_info_push(p, "do", &@$);
- }
- ;
-
-k_rescue : keyword_rescue
- {
- token_info_warn(p, "rescue", p->token_info, 1, &@$);
- }
- ;
-
-k_ensure : keyword_ensure
- {
- token_info_warn(p, "ensure", p->token_info, 1, &@$);
- }
- ;
-
-k_when : keyword_when
- {
- token_info_warn(p, "when", p->token_info, 0, &@$);
- }
- ;
-
-k_else : keyword_else
- {
- token_info *ptinfo_beg = p->token_info;
- int same = ptinfo_beg && strcmp(ptinfo_beg->token, "case") != 0;
- token_info_warn(p, "else", p->token_info, same, &@$);
- if (same) {
- token_info e;
- e.next = ptinfo_beg->next;
- e.token = "else";
- token_info_setup(&e, p->lex.pbeg, &@$);
- if (!e.nonspc) *ptinfo_beg = e;
- }
- }
- ;
-
-k_elsif : keyword_elsif
- {
- WARN_EOL("elsif");
- token_info_warn(p, "elsif", p->token_info, 1, &@$);
+ token_info_push("def");
+ /*%%%*/
+ $<num>$ = ruby_sourceline;
+ /*%
+ %*/
}
;
k_end : keyword_end
{
- token_info_pop(p, "end", &@$);
+ token_info_pop("end");
}
;
k_return : keyword_return
{
- if (p->in_class && !p->in_def && !dyna_in_block(p))
- yyerror1(&@1, "Invalid return in class/module body");
+ if (in_class && !in_def && !dyna_in_block())
+ yyerror0("Invalid return in class/module body");
}
;
then : term
+ /*%c%*/
+ /*%c
+ { $$ = Qnil; }
+ %*/
| keyword_then
| term keyword_then
+ /*%c%*/
+ /*%c
+ { $$ = $2; }
+ %*/
;
do : term
+ /*%c%*/
+ /*%c
+ { $$ = Qnil; }
+ %*/
| keyword_do_cond
;
if_tail : opt_else
- | k_elsif expr_value then
+ | keyword_elsif expr_value then
compstmt
if_tail
{
/*%%%*/
- $$ = new_if(p, $2, $4, $5, &@$);
+ $$ = new_if($2, $4, $5, &@$);
fixpos($$, $2);
- /*% %*/
- /*% ripper: elsif!($2, $4, escape_Qundef($5)) %*/
+ /*%
+ $$ = dispatch3(elsif, $2, $4, escape_Qundef($5));
+ %*/
}
;
opt_else : none
- | k_else compstmt
+ | keyword_else compstmt
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: else!($2) %*/
+ /*%
+ $$ = dispatch1(else, $2);
+ %*/
}
;
@@ -3257,110 +3284,137 @@ for_var : lhs
f_marg : f_norm_arg
{
+ $$ = assignable($1, 0, &@$);
/*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- mark_lvar_used(p, $$);
- /*% %*/
- /*% ripper: assignable(p, $1) %*/
+ /*%
+ %*/
}
| tLPAREN f_margs rparen
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ /*%
+ $$ = dispatch1(mlhs_paren, $2);
+ %*/
}
;
f_marg_list : f_marg
{
/*%%%*/
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: mlhs_add!(mlhs_new!, $1) %*/
+ $$ = new_list($1, &@$);
+ /*%
+ $$ = mlhs_add(mlhs_new(), $1);
+ %*/
}
| f_marg_list ',' f_marg
{
/*%%%*/
- $$ = list_append(p, $1, $3);
- /*% %*/
- /*% ripper: mlhs_add!($1, $3) %*/
+ $$ = list_append($1, $3);
+ /*%
+ $$ = mlhs_add($1, $3);
+ %*/
}
;
f_margs : f_marg_list
{
/*%%%*/
- $$ = NEW_MASGN($1, 0, &@$);
- /*% %*/
- /*% ripper: $1 %*/
+ $$ = new_masgn($1, 0, &@$);
+ /*%
+ $$ = $1;
+ %*/
}
- | f_marg_list ',' f_rest_marg
+ | f_marg_list ',' tSTAR f_norm_arg
{
+ $$ = assignable($4, 0, &@$);
/*%%%*/
- $$ = NEW_MASGN($1, $3, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!($1, $3) %*/
+ $$ = new_masgn($1, $$, &@$);
+ /*%
+ $$ = mlhs_add_star($1, $$);
+ %*/
}
- | f_marg_list ',' f_rest_marg ',' f_marg_list
+ | f_marg_list ',' tSTAR f_norm_arg ',' f_marg_list
{
+ $$ = assignable($4, 0, &@$);
/*%%%*/
- $$ = NEW_MASGN($1, NEW_POSTARG($3, $5, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!($1, $3), $5) %*/
+ $$ = new_masgn($1, new_postarg($$, $6, &@$), &@$);
+ /*%
+ $$ = mlhs_add_star($1, $$);
+ $$ = mlhs_add_post($$, $6);
+ %*/
}
- | f_rest_marg
+ | f_marg_list ',' tSTAR
{
/*%%%*/
- $$ = NEW_MASGN(0, $1, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!(mlhs_new!, $1) %*/
+ $$ = new_masgn($1, NODE_SPECIAL_NO_NAME_REST, &@$);
+ /*%
+ $$ = mlhs_add_star($1, Qnil);
+ %*/
}
- | f_rest_marg ',' f_marg_list
+ | f_marg_list ',' tSTAR ',' f_marg_list
{
/*%%%*/
- $$ = NEW_MASGN(0, NEW_POSTARG($1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $1), $3) %*/
+ $$ = new_masgn($1, new_postarg(NODE_SPECIAL_NO_NAME_REST, $5, &@$), &@$);
+ /*%
+ $$ = mlhs_add_star($1, Qnil);
+ $$ = mlhs_add_post($$, $5);
+ %*/
}
- ;
-
-f_rest_marg : tSTAR f_norm_arg
+ | tSTAR f_norm_arg
{
+ $$ = assignable($2, 0, &@$);
/*%%%*/
- $$ = assignable(p, $2, 0, &@$);
- mark_lvar_used(p, $$);
- /*% %*/
- /*% ripper: assignable(p, $2) %*/
+ $$ = new_masgn(0, $$, &@$);
+ /*%
+ $$ = mlhs_add_star(mlhs_new(), $$);
+ %*/
+ }
+ | tSTAR f_norm_arg ',' f_marg_list
+ {
+ $$ = assignable($2, 0, &@$);
+ /*%%%*/
+ $$ = new_masgn(0, new_postarg($$, $4, &@$), &@$);
+ /*%
+ $$ = mlhs_add_star(mlhs_new(), $$);
+ $$ = mlhs_add_post($$, $4);
+ %*/
}
| tSTAR
{
/*%%%*/
- $$ = NODE_SPECIAL_NO_NAME_REST;
- /*% %*/
- /*% ripper: Qnil %*/
+ $$ = new_masgn(0, NODE_SPECIAL_NO_NAME_REST, &@$);
+ /*%
+ $$ = mlhs_add_star(mlhs_new(), Qnil);
+ %*/
+ }
+ | tSTAR ',' f_marg_list
+ {
+ /*%%%*/
+ $$ = new_masgn(0, new_postarg(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$);
+ /*%
+ $$ = mlhs_add_star(mlhs_new(), Qnil);
+ $$ = mlhs_add_post($$, $3);
+ %*/
}
;
+
block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg
{
- $$ = new_args_tail(p, $1, $3, $4, &@3);
+ $$ = new_args_tail($1, $3, $4, &@3);
}
| f_block_kwarg opt_f_block_arg
{
- $$ = new_args_tail(p, $1, Qnone, $2, &@1);
+ $$ = new_args_tail($1, Qnone, $2, &@1);
}
| f_kwrest opt_f_block_arg
{
- $$ = new_args_tail(p, Qnone, $1, $2, &@1);
- }
- | f_no_kwarg opt_f_block_arg
- {
- $$ = new_args_tail(p, Qnone, ID2VAL(idNil), $2, &@1);
+ $$ = new_args_tail(Qnone, $1, $2, &@1);
}
| f_block_arg
{
- $$ = new_args_tail(p, Qnone, Qnone, $1, &@1);
+ $$ = new_args_tail(Qnone, Qnone, $1, &@1);
}
;
@@ -3370,100 +3424,110 @@ opt_block_args_tail : ',' block_args_tail
}
| /* none */
{
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
+ $$ = new_args_tail(Qnone, Qnone, Qnone, &@0);
}
;
block_param : f_arg ',' f_block_optarg ',' f_rest_arg opt_block_args_tail
{
- $$ = new_args(p, $1, $3, $5, Qnone, $6, &@$);
+ $$ = new_args($1, $3, $5, Qnone, $6, &@$);
}
| f_arg ',' f_block_optarg ',' f_rest_arg ',' f_arg opt_block_args_tail
{
- $$ = new_args(p, $1, $3, $5, $7, $8, &@$);
+ $$ = new_args($1, $3, $5, $7, $8, &@$);
}
| f_arg ',' f_block_optarg opt_block_args_tail
{
- $$ = new_args(p, $1, $3, Qnone, Qnone, $4, &@$);
+ $$ = new_args($1, $3, Qnone, Qnone, $4, &@$);
}
| f_arg ',' f_block_optarg ',' f_arg opt_block_args_tail
{
- $$ = new_args(p, $1, $3, Qnone, $5, $6, &@$);
+ $$ = new_args($1, $3, Qnone, $5, $6, &@$);
}
| f_arg ',' f_rest_arg opt_block_args_tail
{
- $$ = new_args(p, $1, Qnone, $3, Qnone, $4, &@$);
+ $$ = new_args($1, Qnone, $3, Qnone, $4, &@$);
}
| f_arg ','
{
+ $$ = new_args($1, Qnone, 1, Qnone, new_args_tail(Qnone, Qnone, Qnone, &@1), &@$);
/*%%%*/
- /* magic number for rest_id in iseq_set_arguments() */
- $$ = new_args(p, $1, Qnone, NODE_SPECIAL_EXCESSIVE_COMMA, Qnone, new_args_tail(p, Qnone, Qnone, Qnone, &@1), &@$);
- /*% %*/
- /*% ripper: new_args(p, $1, Qnone, excessed_comma!, Qnone, new_args_tail(p, Qnone, Qnone, Qnone, NULL), NULL) %*/
+ /*%
+ dispatch1(excessed_comma, $$);
+ %*/
}
| f_arg ',' f_rest_arg ',' f_arg opt_block_args_tail
{
- $$ = new_args(p, $1, Qnone, $3, $5, $6, &@$);
+ $$ = new_args($1, Qnone, $3, $5, $6, &@$);
}
| f_arg opt_block_args_tail
{
- $$ = new_args(p, $1, Qnone, Qnone, Qnone, $2, &@$);
+ $$ = new_args($1, Qnone, Qnone, Qnone, $2, &@$);
}
| f_block_optarg ',' f_rest_arg opt_block_args_tail
{
- $$ = new_args(p, Qnone, $1, $3, Qnone, $4, &@$);
+ $$ = new_args(Qnone, $1, $3, Qnone, $4, &@$);
}
| f_block_optarg ',' f_rest_arg ',' f_arg opt_block_args_tail
{
- $$ = new_args(p, Qnone, $1, $3, $5, $6, &@$);
+ $$ = new_args(Qnone, $1, $3, $5, $6, &@$);
}
| f_block_optarg opt_block_args_tail
{
- $$ = new_args(p, Qnone, $1, Qnone, Qnone, $2, &@$);
+ $$ = new_args(Qnone, $1, Qnone, Qnone, $2, &@$);
}
| f_block_optarg ',' f_arg opt_block_args_tail
{
- $$ = new_args(p, Qnone, $1, Qnone, $3, $4, &@$);
+ $$ = new_args(Qnone, $1, Qnone, $3, $4, &@$);
}
| f_rest_arg opt_block_args_tail
{
- $$ = new_args(p, Qnone, Qnone, $1, Qnone, $2, &@$);
+ $$ = new_args(Qnone, Qnone, $1, Qnone, $2, &@$);
}
| f_rest_arg ',' f_arg opt_block_args_tail
{
- $$ = new_args(p, Qnone, Qnone, $1, $3, $4, &@$);
+ $$ = new_args(Qnone, Qnone, $1, $3, $4, &@$);
}
| block_args_tail
{
- $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $1, &@$);
+ $$ = new_args(Qnone, Qnone, Qnone, Qnone, $1, &@$);
}
;
opt_block_param : none
| block_param_def
{
- p->command_start = TRUE;
+ command_start = TRUE;
}
;
block_param_def : '|' opt_bv_decl '|'
{
- p->cur_arg = 0;
- p->max_numparam = ORDINAL_PARAM;
+ current_arg = 0;
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: block_var!(params!(Qnil,Qnil,Qnil,Qnil,Qnil,Qnil,Qnil), escape_Qundef($2)) %*/
+ /*%
+ $$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil,Qnil,Qnil),
+ escape_Qundef($2));
+ %*/
+ }
+ | tOROP
+ {
+ /*%%%*/
+ $$ = 0;
+ /*%
+ $$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil,Qnil,Qnil),
+ Qnil);
+ %*/
}
| '|' block_param opt_bv_decl '|'
{
- p->cur_arg = 0;
- p->max_numparam = ORDINAL_PARAM;
+ current_arg = 0;
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: block_var!(escape_Qundef($2), escape_Qundef($3)) %*/
+ /*%
+ $$ = blockvar_new(escape_Qundef($2), escape_Qundef($3));
+ %*/
}
;
@@ -3476,21 +3540,35 @@ opt_bv_decl : opt_nl
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: $3 %*/
+ /*%
+ $$ = $3;
+ %*/
}
;
bv_decls : bvar
- /*% ripper[brace]: rb_ary_new3(1, get_value($1)) %*/
+ /*%c%*/
+ /*%c
+ {
+ $$ = rb_ary_new3(1, get_value($1));
+ }
+ %*/
| bv_decls ',' bvar
- /*% ripper[brace]: rb_ary_push($1, get_value($3)) %*/
+ /*%c%*/
+ /*%c
+ {
+ rb_ary_push($1, get_value($3));
+ }
+ %*/
;
bvar : tIDENTIFIER
{
- new_bv(p, get_id($1));
- /*% ripper: get_value($1) %*/
+ new_bv(get_id($1));
+ /*%%%*/
+ /*%
+ $$ = get_value($1);
+ %*/
}
| f_bad_arg
{
@@ -3499,41 +3577,34 @@ bvar : tIDENTIFIER
;
lambda : {
- $<vars>$ = dyna_push(p);
+ $<vars>$ = dyna_push();
}
{
- $<num>$ = p->lex.lpar_beg;
- p->lex.lpar_beg = p->lex.paren_nest;
+ $<num>$ = lpar_beg;
+ lpar_beg = ++paren_nest;
}
+ f_larglist
{
- $<num>$ = p->max_numparam;
- p->max_numparam = 0;
+ $<num>$ = ruby_sourceline;
}
{
- $<node>$ = numparam_push(p);
- }
- f_larglist
- {
- CMDARG_PUSH(0);
+ $<val>$ = cmdarg_stack;
+ CMDARG_SET(0);
}
lambda_body
{
- int max_numparam = p->max_numparam;
- p->lex.lpar_beg = $<num>2;
- p->max_numparam = $<num>3;
- CMDARG_POP();
- $5 = args_with_numbered(p, $5, max_numparam);
- /*%%%*/
- {
- YYLTYPE loc = code_loc_gen(&@5, &@7);
- $$ = NEW_LAMBDA($5, $7, &loc);
- nd_set_line($$->nd_body, @7.end_pos.lineno);
- nd_set_line($$, @5.end_pos.lineno);
- }
- /*% %*/
- /*% ripper: lambda!($5, $7) %*/
- numparam_pop(p, $<node>4);
- dyna_pop(p, $<vars>1);
+ lpar_beg = $<num>2;
+ CMDARG_SET($<val>5);
+ CMDARG_LEXPOP();
+ /*%%%*/
+ $$ = NEW_LAMBDA($3, $6);
+ nd_set_line($$, $<num>4);
+ $$->nd_loc = @$;
+ $$->nd_body->nd_loc = @$;
+ /*%
+ $$ = dispatch2(lambda, $3, $6);
+ %*/
+ dyna_pop($<vars>1);
}
;
@@ -3541,37 +3612,40 @@ f_larglist : '(' f_args opt_bv_decl ')'
{
/*%%%*/
$$ = $2;
- p->max_numparam = ORDINAL_PARAM;
- /*% %*/
- /*% ripper: paren!($2) %*/
+ /*%
+ $$ = dispatch1(paren, $2);
+ %*/
}
| f_args
{
- /*%%%*/
- if (!args_info_empty_p($1->nd_ainfo))
- p->max_numparam = ORDINAL_PARAM;
- /*% %*/
$$ = $1;
}
;
lambda_body : tLAMBEG compstmt '}'
{
- token_info_pop(p, "}", &@3);
+ token_info_pop("}");
$$ = $2;
}
- | keyword_do_LAMBDA bodystmt k_end
+ | keyword_do_LAMBDA compstmt k_end
{
$$ = $2;
}
;
-do_block : k_do_block do_body k_end
+do_block : keyword_do_block
{
- $$ = $2;
/*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
+ $<num>$ = ruby_sourceline;
+ /*% %*/
+ }
+ do_body keyword_end
+ {
+ $$ = $3;
+ /*%%%*/
+ $3->nd_body->nd_loc.first_loc = @1.first_loc;
+ $3->nd_body->nd_loc.last_loc = @4.last_loc;
+ nd_set_line($$, $<num>2);
/*% %*/
}
;
@@ -3580,36 +3654,48 @@ block_call : command do_block
{
/*%%%*/
if (nd_type($1) == NODE_YIELD) {
- compile_error(p, "block given to yield");
+ compile_error(PARSER_ARG "block given to yield");
}
else {
- block_dup_check(p, $1->nd_args, $2);
+ block_dup_check($1->nd_args, $2);
}
- $$ = method_add_block(p, $1, $2, &@$);
+ $2->nd_iter = $1;
+ $2->nd_loc = @$;
+ $$ = $2;
fixpos($$, $1);
- /*% %*/
- /*% ripper: method_add_block!($1, $2) %*/
+ /*%
+ $$ = method_add_block($1, $2);
+ %*/
}
| block_call call_op2 operation2 opt_paren_args
{
- /*%%%*/
- $$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$);
- /*% %*/
- /*% ripper: opt_event(:method_add_arg!, call!($1, $2, $3), $4) %*/
+ $$ = new_qcall($2, $1, $3, $4, &@$);
}
| block_call call_op2 operation2 opt_paren_args brace_block
{
/*%%%*/
- $$ = new_command_qcall(p, $2, $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: opt_event(:method_add_block!, command_call!($1, $2, $3, $4), $5) %*/
+ block_dup_check($4, $5);
+ $5->nd_iter = new_command_qcall($2, $1, $3, $4, &@$);
+ $5->nd_loc = @$;
+ $$ = $5;
+ fixpos($$, $1);
+ /*%
+ $$ = dispatch4(command_call, $1, $2, $3, $4);
+ $$ = method_add_block($$, $5);
+ %*/
}
| block_call call_op2 operation2 command_args do_block
{
/*%%%*/
- $$ = new_command_qcall(p, $2, $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_block!(command_call!($1, $2, $3, $4), $5) %*/
+ block_dup_check($4, $5);
+ $5->nd_iter = new_command_qcall($2, $1, $3, $4, &@$);
+ $5->nd_loc = @$;
+ $$ = $5;
+ fixpos($$, $1);
+ /*%
+ $$ = dispatch4(command_call, $1, $2, $3, $4);
+ $$ = method_add_block($$, $5);
+ %*/
}
;
@@ -3618,716 +3704,181 @@ method_call : fcall paren_args
/*%%%*/
$$ = $1;
$$->nd_args = $2;
- nd_set_last_loc($1, @2.end_pos);
- /*% %*/
- /*% ripper: method_add_arg!(fcall!($1), $2) %*/
- }
- | primary_value call_op operation2 opt_paren_args
- {
- /*%%%*/
- $$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$);
- nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: opt_event(:method_add_arg!, call!($1, $2, $3), $4) %*/
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- /*%%%*/
- $$ = new_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, &@3, &@$);
- nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, ID2VAL(idCOLON2), $3), $4) %*/
- }
- | primary_value tCOLON2 operation3
- {
- /*%%%*/
- $$ = new_qcall(p, ID2VAL(idCOLON2), $1, $3, Qnull, &@3, &@$);
- /*% %*/
- /*% ripper: call!($1, ID2VAL(idCOLON2), $3) %*/
- }
- | primary_value call_op paren_args
- {
- /*%%%*/
- $$ = new_qcall(p, $2, $1, ID2VAL(idCall), $3, &@2, &@$);
- nd_set_line($$, @2.end_pos.lineno);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, $2, ID2VAL(idCall)), $3) %*/
- }
- | primary_value tCOLON2 paren_args
- {
- /*%%%*/
- $$ = new_qcall(p, ID2VAL(idCOLON2), $1, ID2VAL(idCall), $3, &@2, &@$);
- nd_set_line($$, @2.end_pos.lineno);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, ID2VAL(idCOLON2), ID2VAL(idCall)), $3) %*/
- }
- | keyword_super paren_args
- {
- /*%%%*/
- $$ = NEW_SUPER($2, &@$);
- /*% %*/
- /*% ripper: super!($2) %*/
- }
- | keyword_super
- {
- /*%%%*/
- $$ = NEW_ZSUPER(&@$);
- /*% %*/
- /*% ripper: zsuper! %*/
- }
- | primary_value '[' opt_call_args rbracket
- {
- /*%%%*/
- if ($1 && nd_type($1) == NODE_SELF)
- $$ = NEW_FCALL(tAREF, $3, &@$);
- else
- $$ = NEW_CALL($1, tAREF, $3, &@$);
- fixpos($$, $1);
- /*% %*/
- /*% ripper: aref!($1, escape_Qundef($3)) %*/
- }
- ;
-
-brace_block : '{' brace_body '}'
- {
- $$ = $2;
- /*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
- }
- | k_do do_body k_end
- {
- $$ = $2;
- /*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
- }
- ;
-
-brace_body : {$<vars>$ = dyna_push(p);}
- {
- $<num>$ = p->max_numparam;
- p->max_numparam = 0;
- }
- {
- $<node>$ = numparam_push(p);
- }
- opt_block_param compstmt
- {
- int max_numparam = p->max_numparam;
- p->max_numparam = $<num>2;
- $4 = args_with_numbered(p, $4, max_numparam);
- /*%%%*/
- $$ = NEW_ITER($4, $5, &@$);
- /*% %*/
- /*% ripper: brace_block!(escape_Qundef($4), $5) %*/
- numparam_pop(p, $<node>3);
- dyna_pop(p, $<vars>1);
- }
- ;
-
-do_body : {$<vars>$ = dyna_push(p);}
- {
- $<num>$ = p->max_numparam;
- p->max_numparam = 0;
- }
- {
- $<node>$ = numparam_push(p);
- CMDARG_PUSH(0);
- }
- opt_block_param bodystmt
- {
- int max_numparam = p->max_numparam;
- p->max_numparam = $<num>2;
- $4 = args_with_numbered(p, $4, max_numparam);
- /*%%%*/
- $$ = NEW_ITER($4, $5, &@$);
- /*% %*/
- /*% ripper: do_block!(escape_Qundef($4), $5) %*/
- CMDARG_POP();
- numparam_pop(p, $<node>3);
- dyna_pop(p, $<vars>1);
- }
- ;
-
-case_args : arg_value
- {
- /*%%%*/
- check_literal_when(p, $1, &@1);
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: args_add!(args_new!, $1) %*/
- }
- | tSTAR arg_value
- {
- /*%%%*/
- $$ = NEW_SPLAT($2, &@$);
- /*% %*/
- /*% ripper: args_add_star!(args_new!, $2) %*/
+ nd_set_last_loc($1, @2.last_loc);
+ /*%
+ $$ = method_arg(dispatch1(fcall, $1), $2);
+ %*/
}
- | case_args ',' arg_value
+ | primary_value call_op operation2
{
/*%%%*/
- check_literal_when(p, $3, &@3);
- $$ = last_arg_append(p, $1, $3, &@$);
+ $<num>$ = ruby_sourceline;
/*% %*/
- /*% ripper: args_add!($1, $3) %*/
}
- | case_args ',' tSTAR arg_value
+ opt_paren_args
{
- /*%%%*/
- $$ = rest_arg_append(p, $1, $4, &@$);
- /*% %*/
- /*% ripper: args_add_star!($1, $4) %*/
+ $$ = new_qcall($2, $1, $3, $5, &@$);
+ nd_set_line($$, $<num>4);
}
- ;
-
-case_body : k_when case_args then
- compstmt
- cases
+ | primary_value tCOLON2 operation2
{
/*%%%*/
- $$ = NEW_WHEN($2, $4, $5, &@$);
- fixpos($$, $2);
+ $<num>$ = ruby_sourceline;
/*% %*/
- /*% ripper: when!($2, $4, escape_Qundef($5)) %*/
- }
- ;
-
-cases : opt_else
- | case_body
- ;
-
-p_case_body : keyword_in
- {
- SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
- p->command_start = FALSE;
- $<num>$ = p->in_kwarg;
- p->in_kwarg = 1;
}
- {$<tbl>$ = push_pvtbl(p);}
- {$<tbl>$ = push_pktbl(p);}
- p_top_expr then
- {pop_pktbl(p, $<tbl>4);}
- {pop_pvtbl(p, $<tbl>3);}
+ paren_args
{
- p->in_kwarg = !!$<num>2;
- }
- compstmt
- p_cases
- {
- /*%%%*/
- $$ = NEW_IN($5, $10, $11, &@$);
- /*% %*/
- /*% ripper: in!($5, $10, escape_Qundef($11)) %*/
+ $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, $5, &@$);
+ nd_set_line($$, $<num>4);
}
- ;
-
-p_cases : opt_else
- | p_case_body
- ;
-
-p_top_expr : p_top_expr_body
- | p_top_expr_body modifier_if expr_value
+ | primary_value tCOLON2 operation3
{
- /*%%%*/
- $$ = new_if(p, $3, remove_begin($1), 0, &@$);
- fixpos($$, $3);
- /*% %*/
- /*% ripper: if_mod!($3, $1) %*/
+ $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, Qnull, &@$);
}
- | p_top_expr_body modifier_unless expr_value
+ | primary_value call_op
{
/*%%%*/
- $$ = new_unless(p, $3, remove_begin($1), 0, &@$);
- fixpos($$, $3);
+ $<num>$ = ruby_sourceline;
/*% %*/
- /*% ripper: unless_mod!($3, $1) %*/
}
- ;
-
-p_top_expr_body : p_expr
- | p_expr ','
- {
- $$ = new_array_pattern_tail(p, Qnone, 1, 0, Qnone, &@$);
- $$ = new_array_pattern(p, Qnone, get_value($1), $$, &@$);
- }
- | p_expr ',' p_args
- {
- $$ = new_array_pattern(p, Qnone, get_value($1), $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
- }
- | p_args_tail
- {
- $$ = new_array_pattern(p, Qnone, Qnone, $1, &@$);
- }
- | p_kwargs
- {
- $$ = new_hash_pattern(p, Qnone, $1, &@$);
- }
- ;
-
-p_expr : p_as
- ;
-
-p_as : p_expr tASSOC p_variable
+ paren_args
{
- /*%%%*/
- NODE *n = NEW_LIST($1, &@$);
- n = list_append(p, n, $3);
- $$ = new_hash(p, n, &@$);
- /*% %*/
- /*% ripper: binary!($1, STATIC_ID2SYM((id_assoc)), $3) %*/
+ $$ = new_qcall($2, $1, ID2VAL(idCall), $4, &@$);
+ nd_set_line($$, $<num>3);
}
- | p_alt
- ;
-
-p_alt : p_alt '|' p_expr_basic
+ | primary_value tCOLON2
{
/*%%%*/
- $$ = NEW_NODE(NODE_OR, $1, $3, 0, &@$);
+ $<num>$ = ruby_sourceline;
/*% %*/
- /*% ripper: binary!($1, STATIC_ID2SYM(idOr), $3) %*/
}
- | p_expr_basic
- ;
-
-p_lparen : '(' {$<tbl>$ = push_pktbl(p);};
-p_lbracket : '[' {$<tbl>$ = push_pktbl(p);};
-
-p_expr_basic : p_value
- | p_const p_lparen p_args rparen
+ paren_args
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_array_pattern(p, $1, Qnone, $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ $$ = new_qcall(ID2VAL(idCOLON2), $1, ID2VAL(idCall), $4, &@$);
+ nd_set_line($$, $<num>3);
}
- | p_const p_lparen p_kwargs rparen
+ | keyword_super paren_args
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_hash_pattern(p, $1, $3, &@$);
/*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
+ $$ = NEW_SUPER($2);
+ $$->nd_loc = @$;
/*%
+ $$ = dispatch1(super, $2);
%*/
}
- | p_const '(' rparen
- {
- $$ = new_array_pattern_tail(p, Qnone, 0, 0, Qnone, &@$);
- $$ = new_array_pattern(p, $1, Qnone, $$, &@$);
- }
- | p_const p_lbracket p_args rbracket
+ | keyword_super
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_array_pattern(p, $1, Qnone, $3, &@$);
/*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
+ $$ = NEW_ZSUPER();
+ $$->nd_loc = @$;
/*%
+ $$ = dispatch0(zsuper);
%*/
}
- | p_const p_lbracket p_kwargs rbracket
+ | primary_value '[' opt_call_args rbracket
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_hash_pattern(p, $1, $3, &@$);
/*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
+ if ($1 && nd_type($1) == NODE_SELF)
+ $$ = new_fcall(tAREF, $3, &@$);
+ else
+ $$ = new_call($1, tAREF, $3, &@$);
+ fixpos($$, $1);
/*%
+ $$ = dispatch2(aref, $1, escape_Qundef($3));
%*/
}
- | p_const '[' rbracket
- {
- $$ = new_array_pattern_tail(p, Qnone, 0, 0, Qnone, &@$);
- $$ = new_array_pattern(p, $1, Qnone, $$, &@$);
- }
- | tLBRACK {$<tbl>$ = push_pktbl(p);} p_args rbracket
- {
- pop_pktbl(p, $<tbl>2);
- $$ = new_array_pattern(p, Qnone, Qnone, $3, &@$);
- }
- | tLBRACK rbracket
- {
- $$ = new_array_pattern_tail(p, Qnone, 0, 0, Qnone, &@$);
- $$ = new_array_pattern(p, Qnone, Qnone, $$, &@$);
- }
- | tLBRACE
- {
- $<tbl>$ = push_pktbl(p);
- $<num>1 = p->in_kwarg;
- p->in_kwarg = 0;
- }
- p_kwargs rbrace
- {
- pop_pktbl(p, $<tbl>2);
- p->in_kwarg = $<num>1;
- $$ = new_hash_pattern(p, Qnone, $3, &@$);
- }
- | tLBRACE rbrace
- {
- $$ = new_hash_pattern_tail(p, Qnone, 0, &@$);
- $$ = new_hash_pattern(p, Qnone, $$, &@$);
- }
- | tLPAREN {$<tbl>$ = push_pktbl(p);} p_expr rparen
- {
- pop_pktbl(p, $<tbl>2);
- $$ = $3;
- }
;
-p_args : p_expr
- {
- /*%%%*/
- NODE *pre_args = NEW_LIST($1, &@$);
- $$ = new_array_pattern_tail(p, pre_args, 0, 0, Qnone, &@$);
- /*%
- $$ = new_array_pattern_tail(p, rb_ary_new_from_args(1, get_value($1)), 0, 0, Qnone, &@$);
- %*/
- }
- | p_args_head
- {
- $$ = new_array_pattern_tail(p, $1, 1, 0, Qnone, &@$);
- }
- | p_args_head p_arg
+brace_block : '{'
{
/*%%%*/
- $$ = new_array_pattern_tail(p, list_concat($1, $2), 0, 0, Qnone, &@$);
- /*%
- VALUE pre_args = rb_ary_concat($1, get_value($2));
- $$ = new_array_pattern_tail(p, pre_args, 0, 0, Qnone, &@$);
- %*/
- }
- | p_args_head tSTAR tIDENTIFIER
- {
- $$ = new_array_pattern_tail(p, $1, 1, $3, Qnone, &@$);
- }
- | p_args_head tSTAR tIDENTIFIER ',' p_args_post
- {
- $$ = new_array_pattern_tail(p, $1, 1, $3, $5, &@$);
- }
- | p_args_head tSTAR
- {
- $$ = new_array_pattern_tail(p, $1, 1, 0, Qnone, &@$);
- }
- | p_args_head tSTAR ',' p_args_post
- {
- $$ = new_array_pattern_tail(p, $1, 1, 0, $4, &@$);
- }
- | p_args_tail
- ;
-
-p_args_head : p_arg ','
- {
- $$ = $1;
+ $<num>$ = ruby_sourceline;
+ /*% %*/
}
- | p_args_head p_arg ','
+ brace_body '}'
{
+ $$ = $3;
/*%%%*/
- $$ = list_concat($1, $2);
+ $3->nd_body->nd_loc.first_loc = @1.first_loc;
+ $3->nd_body->nd_loc.last_loc = @4.last_loc;
+ nd_set_line($$, $<num>2);
/*% %*/
- /*% ripper: rb_ary_concat($1, get_value($2)) %*/
- }
- ;
-
-p_args_tail : tSTAR tIDENTIFIER
- {
- $$ = new_array_pattern_tail(p, Qnone, 1, $2, Qnone, &@$);
- }
- | tSTAR tIDENTIFIER ',' p_args_post
- {
- $$ = new_array_pattern_tail(p, Qnone, 1, $2, $4, &@$);
- }
- | tSTAR
- {
- $$ = new_array_pattern_tail(p, Qnone, 1, 0, Qnone, &@$);
}
- | tSTAR ',' p_args_post
- {
- $$ = new_array_pattern_tail(p, Qnone, 1, 0, $3, &@$);
- }
- ;
-
-p_args_post : p_arg
- | p_args_post ',' p_arg
+ | keyword_do
{
/*%%%*/
- $$ = list_concat($1, $3);
+ $<num>$ = ruby_sourceline;
/*% %*/
- /*% ripper: rb_ary_concat($1, get_value($3)) %*/
}
- ;
-
-p_arg : p_expr
+ do_body keyword_end
{
+ $$ = $3;
/*%%%*/
- $$ = NEW_LIST($1, &@$);
+ $3->nd_body->nd_loc.first_loc = @1.first_loc;
+ $3->nd_body->nd_loc.last_loc = @4.last_loc;
+ nd_set_line($$, $<num>2);
/*% %*/
- /*% ripper: rb_ary_new_from_args(1, get_value($1)) %*/
- }
- ;
-
-p_kwargs : p_kwarg ',' p_kwrest
- {
- $$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), $3, &@$);
- }
- | p_kwarg
- {
- $$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), 0, &@$);
- }
- | p_kwarg ','
- {
- $$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), 0, &@$);
- }
- | p_kwrest
- {
- $$ = new_hash_pattern_tail(p, new_hash(p, Qnone, &@$), $1, &@$);
- }
- | p_kwarg ',' p_kwnorest
- {
- $$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), ID2VAL(idNil), &@$);
- }
- | p_kwnorest
- {
- $$ = new_hash_pattern_tail(p, new_hash(p, Qnone, &@$), ID2VAL(idNil), &@$);
}
;
-p_kwarg : p_kw
- /*% ripper[brace]: rb_ary_new_from_args(1, $1) %*/
- | p_kwarg ',' p_kw
+brace_body : {$<vars>$ = dyna_push();}
+ {$<val>$ = cmdarg_stack >> 1; CMDARG_SET(0);}
+ opt_block_param compstmt
{
- /*%%%*/
- $$ = list_concat($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, $3) %*/
+ $$ = new_brace_body($3, $4, &@$);
+ dyna_pop($<vars>1);
+ CMDARG_SET($<val>2);
}
;
-p_kw : p_kw_label p_expr
+do_body : {$<vars>$ = dyna_push();}
+ {$<val>$ = cmdarg_stack; CMDARG_SET(0);}
+ opt_block_param bodystmt
{
- error_duplicate_pattern_key(p, get_id($1), &@1);
- /*%%%*/
- $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@$), &@$), $2);
- /*% %*/
- /*% ripper: rb_ary_new_from_args(2, get_value($1), get_value($2)) %*/
- }
- | p_kw_label
- {
- error_duplicate_pattern_key(p, get_id($1), &@1);
- if ($1 && !is_local_id(get_id($1))) {
- yyerror1(&@1, "key must be valid as local variables");
- }
- error_duplicate_pattern_variable(p, get_id($1), &@1);
- /*%%%*/
- $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@$), &@$), assignable(p, $1, 0, &@$));
- /*% %*/
- /*% ripper: rb_ary_new_from_args(2, get_value($1), Qnil) %*/
+ $$ = new_do_body($3, $4, &@$);
+ dyna_pop($<vars>1);
+ CMDARG_SET($<val>2);
}
;
-p_kw_label : tLABEL
- | tSTRING_BEG string_contents tLABEL_END
+case_body : keyword_when args then
+ compstmt
+ cases
{
- YYLTYPE loc = code_loc_gen(&@1, &@3);
/*%%%*/
- if (!$2 || nd_type($2) == NODE_STR) {
- NODE *node = dsym_node(p, $2, &loc);
- $$ = SYM2ID(node->nd_lit);
- }
+ $$ = NEW_WHEN($2, $4, $5);
+ $$->nd_loc = @$;
/*%
- if (ripper_is_node_yylval($2) && RNODE($2)->nd_cval) {
- VALUE label = RNODE($2)->nd_cval;
- VALUE rval = RNODE($2)->nd_rval;
- $$ = ripper_new_yylval(p, rb_intern_str(label), rval, label);
- RNODE($$)->nd_loc = loc;
- }
+ $$ = dispatch3(when, $2, $4, escape_Qundef($5));
%*/
- else {
- yyerror1(&loc, "symbol literal with interpolation is not allowed");
- $$ = 0;
- }
- }
- ;
-
-p_kwrest : kwrest_mark tIDENTIFIER
- {
- $$ = $2;
- }
- | kwrest_mark
- {
- $$ = 0;
- }
- ;
-
-p_kwnorest : kwrest_mark keyword_nil
- {
- $$ = 0;
- }
- ;
-
-p_value : p_primitive
- | p_primitive tDOT2 p_primitive
- {
- /*%%%*/
- value_expr($1);
- value_expr($3);
- $$ = NEW_DOT2($1, $3, &@$);
- /*% %*/
- /*% ripper: dot2!($1, $3) %*/
- }
- | p_primitive tDOT3 p_primitive
- {
- /*%%%*/
- value_expr($1);
- value_expr($3);
- $$ = NEW_DOT3($1, $3, &@$);
- /*% %*/
- /*% ripper: dot3!($1, $3) %*/
- }
- | p_primitive tDOT2
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @2.end_pos;
- loc.end_pos = @2.end_pos;
-
- value_expr($1);
- $$ = NEW_DOT2($1, new_nil(&loc), &@$);
- /*% %*/
- /*% ripper: dot2!($1, Qnil) %*/
- }
- | p_primitive tDOT3
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @2.end_pos;
- loc.end_pos = @2.end_pos;
-
- value_expr($1);
- $$ = NEW_DOT3($1, new_nil(&loc), &@$);
- /*% %*/
- /*% ripper: dot3!($1, Qnil) %*/
- }
- | p_variable
- | p_var_ref
- | p_const
- | tBDOT2 p_primitive
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @1.beg_pos;
- loc.end_pos = @1.beg_pos;
-
- value_expr($2);
- $$ = NEW_DOT2(new_nil(&loc), $2, &@$);
- /*% %*/
- /*% ripper: dot2!(Qnil, $2) %*/
- }
- | tBDOT3 p_primitive
- {
- /*%%%*/
- YYLTYPE loc;
- loc.beg_pos = @1.beg_pos;
- loc.end_pos = @1.beg_pos;
-
- value_expr($2);
- $$ = NEW_DOT3(new_nil(&loc), $2, &@$);
- /*% %*/
- /*% ripper: dot3!(Qnil, $2) %*/
- }
- ;
-
-p_primitive : literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | symbols
- | qsymbols
- | keyword_variable
- {
- /*%%%*/
- if (!($$ = gettable(p, $1, &@$))) $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
- }
- | tLAMBDA
- {
- token_info_push(p, "->", &@1);
- }
- lambda
- {
- $$ = $3;
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*% %*/
}
;
-p_variable : tIDENTIFIER
- {
- /*%%%*/
- error_duplicate_pattern_variable(p, $1, &@1);
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
- }
- ;
-
-p_var_ref : '^' tIDENTIFIER
- {
- /*%%%*/
- NODE *n = gettable(p, $2, &@$);
- if (!(nd_type(n) == NODE_LVAR || nd_type(n) == NODE_DVAR)) {
- compile_error(p, "%"PRIsVALUE": no such local variable", rb_id2str($2));
- }
- $$ = n;
- /*% %*/
- /*% ripper: var_ref!($2) %*/
- }
- ;
-
-p_const : tCOLON3 cname
- {
- /*%%%*/
- $$ = NEW_COLON3($2, &@$);
- /*% %*/
- /*% ripper: top_const_ref!($2) %*/
- }
- | p_const tCOLON2 cname
- {
- /*%%%*/
- $$ = NEW_COLON2($1, $3, &@$);
- /*% %*/
- /*% ripper: const_path_ref!($1, $3) %*/
- }
- | tCONSTANT
- {
- /*%%%*/
- $$ = gettable(p, $1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
- }
+cases : opt_else
+ | case_body
;
-opt_rescue : k_rescue exc_list exc_var then
+opt_rescue : keyword_rescue exc_list exc_var then
compstmt
opt_rescue
{
/*%%%*/
- $$ = NEW_RESBODY($2,
- $3 ? block_append(p, node_assign(p, $3, NEW_ERRINFO(&@3), &@3), $5) : $5,
- $6, &@$);
+ if ($3) {
+ YYLTYPE location;
+ location.first_loc = @3.first_loc;
+ location.last_loc = @5.last_loc;
+ $3 = node_assign($3, new_errinfo(&@3), &@3);
+ $5 = block_append($3, $5, &location);
+ }
+ $$ = new_resbody($2, $5, $6, &@$);
fixpos($$, $2?$2:$5);
- /*% %*/
- /*% ripper: rescue!(escape_Qundef($2), escape_Qundef($3), escape_Qundef($5), escape_Qundef($6)) %*/
+ /*%
+ $$ = dispatch4(rescue,
+ escape_Qundef($2),
+ escape_Qundef($3),
+ escape_Qundef($5),
+ escape_Qundef($6));
+ %*/
}
| none
;
@@ -4335,16 +3886,18 @@ opt_rescue : k_rescue exc_list exc_var then
exc_list : arg_value
{
/*%%%*/
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ $$ = new_list($1, &@$);
+ /*%
+ $$ = rb_ary_new3(1, get_value($1));
+ %*/
}
| mrhs
{
/*%%%*/
if (!($$ = splat_array($1))) $$ = $1;
- /*% %*/
- /*% ripper: $1 %*/
+ /*%
+ $$ = $1;
+ %*/
}
| none
;
@@ -4356,18 +3909,27 @@ exc_var : tASSOC lhs
| none
;
-opt_ensure : k_ensure compstmt
+opt_ensure : keyword_ensure compstmt
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: ensure!($2) %*/
+ /*%
+ $$ = dispatch1(ensure, $2);
+ %*/
}
| none
;
literal : numeric
| symbol
+ {
+ /*%%%*/
+ $$ = new_lit(ID2SYM($1), &@$);
+ /*%
+ $$ = dispatch1(symbol_literal, $1);
+ %*/
+ }
+ | dsym
;
strings : string
@@ -4375,60 +3937,65 @@ strings : string
/*%%%*/
NODE *node = $1;
if (!node) {
- node = NEW_STR(STR_NEW0(), &@$);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
+ node = new_str(STR_NEW0(), &@$);
}
else {
- node = evstr2dstr(p, node);
+ node = evstr2dstr(node);
}
$$ = node;
- /*% %*/
- /*% ripper: $1 %*/
+ /*%
+ $$ = $1;
+ %*/
}
;
string : tCHAR
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
| string1
| string string1
{
/*%%%*/
- $$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: string_concat!($1, $2) %*/
+ $$ = literal_concat($1, $2, &@$);
+ /*%
+ $$ = dispatch2(string_concat, $1, $2);
+ %*/
}
;
string1 : tSTRING_BEG string_contents tSTRING_END
{
+ $$ = new_string1(heredoc_dedent($2));
/*%%%*/
- $$ = heredoc_dedent(p, $2);
if ($$) nd_set_loc($$, &@$);
- /*% %*/
- /*% ripper: string_literal!(heredoc_dedent(p, $2)) %*/
+ /*%
+ %*/
}
;
xstring : tXSTRING_BEG xstring_contents tSTRING_END
{
- /*%%%*/
- $$ = new_xstring(p, heredoc_dedent(p, $2), &@$);
- /*% %*/
- /*% ripper: xstring_literal!(heredoc_dedent(p, $2)) %*/
+ $$ = new_xstring(heredoc_dedent($2), &@$);
}
;
regexp : tREGEXP_BEG regexp_contents tREGEXP_END
{
- $$ = new_regexp(p, $2, $3, &@$);
+ $$ = new_regexp($2, $3, &@$);
}
;
words : tWORDS_BEG ' ' word_list tSTRING_END
{
/*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
+ $$ = make_array($3, &@$);
+ /*%
+ $$ = dispatch1(array, $3);
+ %*/
}
;
@@ -4436,35 +4003,45 @@ word_list : /* none */
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: words_new! %*/
+ /*%
+ $$ = dispatch0(words_new);
+ %*/
}
| word_list word ' '
{
/*%%%*/
- $$ = list_append(p, $1, evstr2dstr(p, $2));
- /*% %*/
- /*% ripper: words_add!($1, $2) %*/
+ $$ = list_append($1, evstr2dstr($2));
+ /*%
+ $$ = dispatch2(words_add, $1, $2);
+ %*/
}
;
word : string_content
- /*% ripper[brace]: word_add!(word_new!, $1) %*/
+ /*%c%*/
+ /*%c
+ {
+ $$ = dispatch0(word_new);
+ $$ = dispatch2(word_add, $$, $1);
+ }
+ %*/
| word string_content
{
/*%%%*/
- $$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: word_add!($1, $2) %*/
+ $$ = literal_concat($1, $2, &@$);
+ /*%
+ $$ = dispatch2(word_add, $1, $2);
+ %*/
}
;
symbols : tSYMBOLS_BEG ' ' symbol_list tSTRING_END
{
/*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
+ $$ = make_array($3, &@$);
+ /*%
+ $$ = dispatch1(array, $3);
+ %*/
}
;
@@ -4472,33 +4049,45 @@ symbol_list : /* none */
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: symbols_new! %*/
+ /*%
+ $$ = dispatch0(symbols_new);
+ %*/
}
| symbol_list word ' '
{
/*%%%*/
- $$ = symbol_append(p, $1, evstr2dstr(p, $2));
- /*% %*/
- /*% ripper: symbols_add!($1, $2) %*/
+ $2 = evstr2dstr($2);
+ if (nd_type($2) == NODE_DSTR) {
+ nd_set_type($2, NODE_DSYM);
+ }
+ else {
+ nd_set_type($2, NODE_LIT);
+ add_mark_object($2->nd_lit = rb_str_intern($2->nd_lit));
+ }
+ $$ = list_append($1, $2);
+ /*%
+ $$ = dispatch2(symbols_add, $1, $2);
+ %*/
}
;
qwords : tQWORDS_BEG ' ' qword_list tSTRING_END
{
/*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
+ $$ = make_array($3, &@$);
+ /*%
+ $$ = dispatch1(array, $3);
+ %*/
}
;
qsymbols : tQSYMBOLS_BEG ' ' qsym_list tSTRING_END
{
/*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
+ $$ = make_array($3, &@$);
+ /*%
+ $$ = dispatch1(array, $3);
+ %*/
}
;
@@ -4506,15 +4095,18 @@ qword_list : /* none */
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: qwords_new! %*/
+ /*%
+ $$ = dispatch0(qwords_new);
+ %*/
}
| qword_list tSTRING_CONTENT ' '
{
/*%%%*/
- $$ = list_append(p, $1, $2);
- /*% %*/
- /*% ripper: qwords_add!($1, $2) %*/
+ $2->nd_loc = @2;
+ $$ = list_append($1, $2);
+ /*%
+ $$ = dispatch2(qwords_add, $1, $2);
+ %*/
}
;
@@ -4522,15 +4114,22 @@ qsym_list : /* none */
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: qsymbols_new! %*/
+ /*%
+ $$ = dispatch0(qsymbols_new);
+ %*/
}
| qsym_list tSTRING_CONTENT ' '
{
/*%%%*/
- $$ = symbol_append(p, $1, $2);
- /*% %*/
- /*% ripper: qsymbols_add!($1, $2) %*/
+ VALUE lit;
+ lit = $2->nd_lit;
+ nd_set_type($2, NODE_LIT);
+ add_mark_object($2->nd_lit = ID2SYM(rb_intern_str(lit)));
+ $2->nd_loc = @2;
+ $$ = list_append($1, $2);
+ /*%
+ $$ = dispatch2(qsymbols_add, $1, $2);
+ %*/
}
;
@@ -4538,27 +4137,16 @@ string_contents : /* none */
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: string_content! %*/
- /*%%%*/
/*%
- $$ = ripper_new_yylval(p, 0, $$, 0);
+ $$ = dispatch0(string_content);
%*/
}
| string_contents string_content
{
/*%%%*/
- $$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: string_add!($1, $2) %*/
- /*%%%*/
+ $$ = literal_concat($1, $2, &@$);
/*%
- if (ripper_is_node_yylval($1) && ripper_is_node_yylval($2) &&
- !RNODE($1)->nd_cval) {
- RNODE($1)->nd_cval = RNODE($2)->nd_cval;
- RNODE($1)->nd_rval = add_mark_object(p, $$);
- $$ = $1;
- }
+ $$ = dispatch2(string_add, $1, $2);
%*/
}
;
@@ -4567,15 +4155,17 @@ xstring_contents: /* none */
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: xstring_new! %*/
+ /*%
+ $$ = dispatch0(xstring_new);
+ %*/
}
| xstring_contents string_content
{
/*%%%*/
- $$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: xstring_add!($1, $2) %*/
+ $$ = literal_concat($1, $2, &@$);
+ /*%
+ $$ = dispatch2(xstring_add, $1, $2);
+ %*/
}
;
@@ -4583,11 +4173,8 @@ regexp_contents: /* none */
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: regexp_new! %*/
- /*%%%*/
/*%
- $$ = ripper_new_yylval(p, 0, $$, 0);
+ $$ = ripper_new_yylval(0, dispatch0(regexp_new), 0);
%*/
}
| regexp_contents string_content
@@ -4608,10 +4195,10 @@ regexp_contents: /* none */
case NODE_DSTR:
break;
default:
- head = list_append(p, NEW_DSTR(Qnil, &@$), head);
+ head = list_append(new_dstr(Qnil, &@$), head);
break;
}
- $$ = list_append(p, head, tail);
+ $$ = list_append(head, tail);
}
/*%
VALUE s1 = 1, s2 = 0, n1 = $1, n2 = $2;
@@ -4625,104 +4212,114 @@ regexp_contents: /* none */
}
$$ = dispatch2(regexp_add, n1, n2);
if (!s1 && s2) {
- $$ = ripper_new_yylval(p, 0, $$, s2);
+ $$ = ripper_new_yylval(0, $$, s2);
}
%*/
}
;
string_content : tSTRING_CONTENT
- /*% ripper[brace]: ripper_new_yylval(p, 0, get_value($1), $1) %*/
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
| tSTRING_DVAR
{
- /* need to backup p->lex.strterm so that a string literal `%&foo,#$&,bar&` can be parsed */
- $<strterm>$ = p->lex.strterm;
- p->lex.strterm = 0;
+ /* need to backup lex_strterm so that a string literal `%&foo,#$&,bar&` can be parsed */
+ $<strterm>$ = lex_strterm;
+ lex_strterm = 0;
SET_LEX_STATE(EXPR_BEG);
}
string_dvar
{
- p->lex.strterm = $<strterm>2;
+ lex_strterm = $<strterm>2;
/*%%%*/
- $$ = NEW_EVSTR($3, &@$);
- nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: string_dvar!($3) %*/
+ $$ = NEW_EVSTR($3);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(string_dvar, $3);
+ %*/
}
| tSTRING_DBEG
{
- CMDARG_PUSH(0);
- COND_PUSH(0);
+ $<val>1 = cond_stack;
+ $<val>$ = cmdarg_stack;
+ COND_SET(0);
+ CMDARG_SET(0);
}
{
- /* need to backup p->lex.strterm so that a string literal `%!foo,#{ !0 },bar!` can be parsed */
- $<strterm>$ = p->lex.strterm;
- p->lex.strterm = 0;
+ /* need to backup lex_strterm so that a string literal `%!foo,#{ !0 },bar!` can be parsed */
+ $<strterm>$ = lex_strterm;
+ lex_strterm = 0;
}
{
- $<num>$ = p->lex.state;
+ $<num>$ = lex_state;
SET_LEX_STATE(EXPR_BEG);
}
{
- $<num>$ = p->lex.brace_nest;
- p->lex.brace_nest = 0;
+ $<num>$ = brace_nest;
+ brace_nest = 0;
}
{
- $<num>$ = p->heredoc_indent;
- p->heredoc_indent = 0;
+ $<num>$ = heredoc_indent;
+ heredoc_indent = 0;
}
compstmt tSTRING_DEND
{
- COND_POP();
- CMDARG_POP();
- p->lex.strterm = $<strterm>3;
+ COND_SET($<val>1);
+ CMDARG_SET($<val>2);
+ lex_strterm = $<strterm>3;
SET_LEX_STATE($<num>4);
- p->lex.brace_nest = $<num>5;
- p->heredoc_indent = $<num>6;
- p->heredoc_line_indent = -1;
+ brace_nest = $<num>5;
+ heredoc_indent = $<num>6;
+ heredoc_line_indent = -1;
/*%%%*/
if ($7) $7->flags &= ~NODE_FL_NEWLINE;
- $$ = new_evstr(p, $7, &@$);
- /*% %*/
- /*% ripper: string_embexpr!($7) %*/
+ $$ = new_evstr($7, &@$);
+ /*%
+ $$ = dispatch1(string_embexpr, $7);
+ %*/
}
;
string_dvar : tGVAR
{
/*%%%*/
- $$ = NEW_GVAR($1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ $$ = new_gvar($1, &@$);
+ /*%
+ $$ = dispatch1(var_ref, $1);
+ %*/
}
| tIVAR
{
/*%%%*/
- $$ = NEW_IVAR($1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ $$ = new_ivar($1, &@$);
+ /*%
+ $$ = dispatch1(var_ref, $1);
+ %*/
}
| tCVAR
{
/*%%%*/
- $$ = NEW_CVAR($1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ $$ = NEW_CVAR($1);
+ $$->nd_loc = @$;
+ /*%
+ $$ = dispatch1(var_ref, $1);
+ %*/
}
| backref
;
-symbol : ssym
- | dsym
- ;
-
-ssym : tSYMBEG sym
+symbol : tSYMBEG sym
{
- SET_LEX_STATE(EXPR_END);
+ SET_LEX_STATE(EXPR_END|EXPR_ENDARG);
/*%%%*/
- $$ = NEW_LIT(ID2SYM($2), &@$);
- /*% %*/
- /*% ripper: symbol_literal!(symbol!($2)) %*/
+ $$ = $2;
+ /*%
+ $$ = dispatch1(symbol, $2);
+ %*/
}
;
@@ -4734,11 +4331,12 @@ sym : fname
dsym : tSYMBEG string_contents tSTRING_END
{
- SET_LEX_STATE(EXPR_END);
+ SET_LEX_STATE(EXPR_END|EXPR_ENDARG);
/*%%%*/
- $$ = dsym_node(p, $2, &@$);
- /*% %*/
- /*% ripper: dyna_symbol!($2) %*/
+ $$ = dsym_node($2, &@$);
+ /*%
+ $$ = dispatch1(dyna_symbol, $2);
+ %*/
}
;
@@ -4747,16 +4345,41 @@ numeric : simple_numeric
{
/*%%%*/
$$ = $2;
- RB_OBJ_WRITE(p->ast, &$$->nd_lit, negate_lit(p, $$->nd_lit));
- /*% %*/
- /*% ripper: unary!(ID2VAL(idUMinus), $2) %*/
+ add_mark_object($$->nd_lit = negate_lit($$->nd_lit));
+ /*%
+ $$ = dispatch2(unary, ID2VAL(idUMinus), $2);
+ %*/
}
;
simple_numeric : tINTEGER
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
| tFLOAT
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
| tRATIONAL
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
| tIMAGINARY
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
;
user_variable : tIDENTIFIER
@@ -4778,9 +4401,9 @@ keyword_variable: keyword_nil {$$ = KWD2EID(nil, $1);}
var_ref : user_variable
{
/*%%%*/
- if (!($$ = gettable(p, $1, &@$))) $$ = NEW_BEGIN(0, &@$);
+ if (!($$ = gettable($1, &@$))) $$ = new_begin(0, &@$);
/*%
- if (id_is_var(p, get_id($1))) {
+ if (id_is_var(get_id($1))) {
$$ = dispatch1(var_ref, $1);
}
else {
@@ -4791,36 +4414,43 @@ var_ref : user_variable
| keyword_variable
{
/*%%%*/
- if (!($$ = gettable(p, $1, &@$))) $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ if (!($$ = gettable($1, &@$))) $$ = new_begin(0, &@$);
+ /*%
+ $$ = dispatch1(var_ref, $1);
+ %*/
}
;
var_lhs : user_variable
{
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
+ $$ = assignable(var_field($1), 0, &@$);
}
| keyword_variable
{
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
+ $$ = assignable(var_field($1), 0, &@$);
}
;
backref : tNTH_REF
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
| tBACK_REF
+ {
+ /*%%%*/
+ $$->nd_loc = @$;
+ /*%
+ %*/
+ }
;
superclass : '<'
{
SET_LEX_STATE(EXPR_BEG);
- p->command_start = TRUE;
+ command_start = TRUE;
}
expr_value term
{
@@ -4830,8 +4460,9 @@ superclass : '<'
{
/*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: Qnil %*/
+ /*%
+ $$ = Qnil;
+ %*/
}
;
@@ -4839,74 +4470,41 @@ f_arglist : '(' f_args rparen
{
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: paren!($2) %*/
- SET_LEX_STATE(EXPR_BEG);
- p->command_start = TRUE;
- }
- | '(' f_arg ',' args_forward rparen
- {
- arg_var(p, idFWD_REST);
-#if idFWD_KWREST
- arg_var(p, idFWD_KWREST);
-#endif
- arg_var(p, idFWD_BLOCK);
- /*%%%*/
- $$ = new_args_tail(p, Qnone, idFWD_KWREST, idFWD_BLOCK, &@4);
- $$ = new_args(p, $2, Qnone, idFWD_REST, Qnone, $$, &@4);
- /*% %*/
- /*% ripper: paren!(params_new($2, Qnone, $4, Qnone, Qnone, Qnone, Qnone)) %*/
- SET_LEX_STATE(EXPR_BEG);
- p->command_start = TRUE;
- }
- | '(' args_forward rparen
- {
- arg_var(p, idFWD_REST);
-#if idFWD_KWREST
- arg_var(p, idFWD_KWREST);
-#endif
- arg_var(p, idFWD_BLOCK);
- /*%%%*/
- $$ = new_args_tail(p, Qnone, idFWD_KWREST, idFWD_BLOCK, &@2);
- $$ = new_args(p, Qnone, Qnone, idFWD_REST, Qnone, $$, &@2);
- /*% %*/
- /*% ripper: paren!(params_new(Qnone, Qnone, $2, Qnone, Qnone, Qnone, Qnone)) %*/
+ /*%
+ $$ = dispatch1(paren, $2);
+ %*/
SET_LEX_STATE(EXPR_BEG);
- p->command_start = TRUE;
+ command_start = TRUE;
}
| {
- $<num>$ = p->in_kwarg;
- p->in_kwarg = 1;
- SET_LEX_STATE(p->lex.state|EXPR_LABEL); /* force for args */
+ $<num>$ = parser->in_kwarg;
+ parser->in_kwarg = 1;
+ SET_LEX_STATE(lex_state|EXPR_LABEL); /* force for args */
}
f_args term
{
- p->in_kwarg = !!$<num>1;
+ parser->in_kwarg = !!$<num>1;
$$ = $2;
SET_LEX_STATE(EXPR_BEG);
- p->command_start = TRUE;
+ command_start = TRUE;
}
;
args_tail : f_kwarg ',' f_kwrest opt_f_block_arg
{
- $$ = new_args_tail(p, $1, $3, $4, &@3);
+ $$ = new_args_tail($1, $3, $4, &@3);
}
| f_kwarg opt_f_block_arg
{
- $$ = new_args_tail(p, $1, Qnone, $2, &@1);
+ $$ = new_args_tail($1, Qnone, $2, &@1);
}
| f_kwrest opt_f_block_arg
{
- $$ = new_args_tail(p, Qnone, $1, $2, &@1);
- }
- | f_no_kwarg opt_f_block_arg
- {
- $$ = new_args_tail(p, Qnone, ID2VAL(idNil), $2, &@1);
+ $$ = new_args_tail(Qnone, $1, $2, &@1);
}
| f_block_arg
{
- $$ = new_args_tail(p, Qnone, Qnone, $1, &@1);
+ $$ = new_args_tail(Qnone, Qnone, $1, &@1);
}
;
@@ -4916,121 +4514,119 @@ opt_args_tail : ',' args_tail
}
| /* none */
{
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
+ $$ = new_args_tail(Qnone, Qnone, Qnone, &@0);
}
;
f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail
{
- $$ = new_args(p, $1, $3, $5, Qnone, $6, &@$);
+ $$ = new_args($1, $3, $5, Qnone, $6, &@$);
}
| f_arg ',' f_optarg ',' f_rest_arg ',' f_arg opt_args_tail
{
- $$ = new_args(p, $1, $3, $5, $7, $8, &@$);
+ $$ = new_args($1, $3, $5, $7, $8, &@$);
}
| f_arg ',' f_optarg opt_args_tail
{
- $$ = new_args(p, $1, $3, Qnone, Qnone, $4, &@$);
+ $$ = new_args($1, $3, Qnone, Qnone, $4, &@$);
}
| f_arg ',' f_optarg ',' f_arg opt_args_tail
{
- $$ = new_args(p, $1, $3, Qnone, $5, $6, &@$);
+ $$ = new_args($1, $3, Qnone, $5, $6, &@$);
}
| f_arg ',' f_rest_arg opt_args_tail
{
- $$ = new_args(p, $1, Qnone, $3, Qnone, $4, &@$);
+ $$ = new_args($1, Qnone, $3, Qnone, $4, &@$);
}
| f_arg ',' f_rest_arg ',' f_arg opt_args_tail
{
- $$ = new_args(p, $1, Qnone, $3, $5, $6, &@$);
+ $$ = new_args($1, Qnone, $3, $5, $6, &@$);
}
| f_arg opt_args_tail
{
- $$ = new_args(p, $1, Qnone, Qnone, Qnone, $2, &@$);
+ $$ = new_args($1, Qnone, Qnone, Qnone, $2, &@$);
}
| f_optarg ',' f_rest_arg opt_args_tail
{
- $$ = new_args(p, Qnone, $1, $3, Qnone, $4, &@$);
+ $$ = new_args(Qnone, $1, $3, Qnone, $4, &@$);
}
| f_optarg ',' f_rest_arg ',' f_arg opt_args_tail
{
- $$ = new_args(p, Qnone, $1, $3, $5, $6, &@$);
+ $$ = new_args(Qnone, $1, $3, $5, $6, &@$);
}
| f_optarg opt_args_tail
{
- $$ = new_args(p, Qnone, $1, Qnone, Qnone, $2, &@$);
+ $$ = new_args(Qnone, $1, Qnone, Qnone, $2, &@$);
}
| f_optarg ',' f_arg opt_args_tail
{
- $$ = new_args(p, Qnone, $1, Qnone, $3, $4, &@$);
+ $$ = new_args(Qnone, $1, Qnone, $3, $4, &@$);
}
| f_rest_arg opt_args_tail
{
- $$ = new_args(p, Qnone, Qnone, $1, Qnone, $2, &@$);
+ $$ = new_args(Qnone, Qnone, $1, Qnone, $2, &@$);
}
| f_rest_arg ',' f_arg opt_args_tail
{
- $$ = new_args(p, Qnone, Qnone, $1, $3, $4, &@$);
+ $$ = new_args(Qnone, Qnone, $1, $3, $4, &@$);
}
| args_tail
{
- $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $1, &@$);
+ $$ = new_args(Qnone, Qnone, Qnone, Qnone, $1, &@$);
}
| /* none */
{
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
- $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $$, &@0);
- }
- ;
-
-args_forward : tBDOT3
- {
- /*%%%*/
- $$ = idDot3;
- /*% %*/
- /*% ripper: args_forward! %*/
+ $$ = new_args_tail(Qnone, Qnone, Qnone, &@0);
+ $$ = new_args(Qnone, Qnone, Qnone, Qnone, $$, &@0);
}
;
f_bad_arg : tCONSTANT
{
/*%%%*/
- yyerror1(&@1, "formal argument cannot be a constant");
+ yyerror0("formal argument cannot be a constant");
$$ = 0;
- /*% %*/
- /*% ripper[error]: param_error!($1) %*/
+ /*%
+ $$ = dispatch1(param_error, $1);
+ ripper_error();
+ %*/
}
| tIVAR
{
/*%%%*/
- yyerror1(&@1, "formal argument cannot be an instance variable");
+ yyerror0("formal argument cannot be an instance variable");
$$ = 0;
- /*% %*/
- /*% ripper[error]: param_error!($1) %*/
+ /*%
+ $$ = dispatch1(param_error, $1);
+ ripper_error();
+ %*/
}
| tGVAR
{
/*%%%*/
- yyerror1(&@1, "formal argument cannot be a global variable");
+ yyerror0("formal argument cannot be a global variable");
$$ = 0;
- /*% %*/
- /*% ripper[error]: param_error!($1) %*/
+ /*%
+ $$ = dispatch1(param_error, $1);
+ ripper_error();
+ %*/
}
| tCVAR
{
/*%%%*/
- yyerror1(&@1, "formal argument cannot be a class variable");
+ yyerror0("formal argument cannot be a class variable");
$$ = 0;
- /*% %*/
- /*% ripper[error]: param_error!($1) %*/
+ /*%
+ $$ = dispatch1(param_error, $1);
+ ripper_error();
+ %*/
}
;
f_norm_arg : f_bad_arg
| tIDENTIFIER
{
- formal_argument(p, get_id($1));
- p->max_numparam = ORDINAL_PARAM;
+ formal_argument(get_id($1));
$$ = $1;
}
;
@@ -5038,52 +4634,63 @@ f_norm_arg : f_bad_arg
f_arg_asgn : f_norm_arg
{
ID id = get_id($1);
- arg_var(p, id);
- p->cur_arg = id;
+ arg_var(id);
+ current_arg = id;
$$ = $1;
}
;
f_arg_item : f_arg_asgn
{
- p->cur_arg = 0;
+ current_arg = 0;
/*%%%*/
- $$ = NEW_ARGS_AUX($1, 1, &NULL_LOC);
- /*% %*/
- /*% ripper: get_value($1) %*/
+ $$ = NEW_ARGS_AUX($1, 1);
+ /*%
+ $$ = get_value($1);
+ %*/
}
| tLPAREN f_margs rparen
{
+ ID tid = internal_id();
+ /*%%%*/
+ YYLTYPE location;
+ location.first_loc = @2.first_loc;
+ location.last_loc = @2.first_loc;
+ /*%
+ %*/
+ arg_var(tid);
/*%%%*/
- ID tid = internal_id(p);
- YYLTYPE loc;
- loc.beg_pos = @2.beg_pos;
- loc.end_pos = @2.beg_pos;
- arg_var(p, tid);
- if (dyna_in_block(p)) {
- $2->nd_value = NEW_DVAR(tid, &loc);
+ if (dyna_in_block()) {
+ $2->nd_value = new_dvar(tid, &location);
}
else {
- $2->nd_value = NEW_LVAR(tid, &loc);
+ $2->nd_value = new_lvar(tid, &location);
}
- $$ = NEW_ARGS_AUX(tid, 1, &NULL_LOC);
+ $$ = NEW_ARGS_AUX(tid, 1);
$$->nd_next = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ /*%
+ $$ = dispatch1(mlhs_paren, $2);
+ %*/
}
;
f_arg : f_arg_item
- /*% ripper[brace]: rb_ary_new3(1, get_value($1)) %*/
+ /*%c%*/
+ /*%c
+ {
+ $$ = rb_ary_new3(1, get_value($1));
+ }
+ c%*/
| f_arg ',' f_arg_item
{
/*%%%*/
$$ = $1;
$$->nd_plen++;
- $$->nd_next = block_append(p, $$->nd_next, $3->nd_next);
- rb_discard_node(p, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ $$->nd_next = block_append($$->nd_next, $3->nd_next, &@$);
+ rb_discard_node($3);
+ /*%
+ $$ = rb_ary_push($1, get_value($3));
+ %*/
}
;
@@ -5091,44 +4698,51 @@ f_arg : f_arg_item
f_label : tLABEL
{
ID id = get_id($1);
- arg_var(p, formal_argument(p, id));
- p->cur_arg = id;
- p->max_numparam = ORDINAL_PARAM;
+ arg_var(formal_argument(id));
+ current_arg = id;
$$ = $1;
}
;
f_kw : f_label arg_value
{
- p->cur_arg = 0;
+ current_arg = 0;
+ $$ = assignable($1, $2, &@$);
/*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, $2, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($2)) %*/
+ $$ = new_kw_arg($$, &@$);
+ /*%
+ $$ = rb_assoc_new(get_value($$), get_value($2));
+ %*/
}
| f_label
{
- p->cur_arg = 0;
+ current_arg = 0;
+ $$ = assignable($1, NODE_SPECIAL_REQUIRED_KEYWORD, &@$);
/*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, NODE_SPECIAL_REQUIRED_KEYWORD, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), 0) %*/
+ $$ = new_kw_arg($$, &@$);
+ /*%
+ $$ = rb_assoc_new(get_value($$), 0);
+ %*/
}
;
f_block_kw : f_label primary_value
{
+ $$ = assignable($1, $2, &@$);
/*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, $2, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($2)) %*/
+ $$ = new_kw_arg($$, &@$);
+ /*%
+ $$ = rb_assoc_new(get_value($$), get_value($2));
+ %*/
}
| f_label
{
+ $$ = assignable($1, NODE_SPECIAL_REQUIRED_KEYWORD, &@$);
/*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, NODE_SPECIAL_REQUIRED_KEYWORD, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), 0) %*/
+ $$ = new_kw_arg($$, &@$);
+ /*%
+ $$ = rb_assoc_new(get_value($$), 0);
+ %*/
}
;
@@ -5136,15 +4750,17 @@ f_block_kwarg : f_block_kw
{
/*%%%*/
$$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ /*%
+ $$ = rb_ary_new3(1, get_value($1));
+ %*/
}
| f_block_kwarg ',' f_block_kw
{
/*%%%*/
$$ = kwd_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ /*%
+ $$ = rb_ary_push($1, get_value($3));
+ %*/
}
;
@@ -5153,15 +4769,17 @@ f_kwarg : f_kw
{
/*%%%*/
$$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ /*%
+ $$ = rb_ary_new3(1, get_value($1));
+ %*/
}
| f_kwarg ',' f_kw
{
/*%%%*/
$$ = kwd_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ /*%
+ $$ = rb_ary_push($1, get_value($3));
+ %*/
}
;
@@ -5169,49 +4787,49 @@ kwrest_mark : tPOW
| tDSTAR
;
-f_no_kwarg : kwrest_mark keyword_nil
- {
- /*%%%*/
- /*% %*/
- /*% ripper: nokw_param!(Qnil) %*/
- }
- ;
-
f_kwrest : kwrest_mark tIDENTIFIER
{
- arg_var(p, shadowing_lvar(p, get_id($2)));
+ shadowing_lvar(get_id($2));
/*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: kwrest_param!($2) %*/
+ /*%
+ $$ = dispatch1(kwrest_param, $2);
+ %*/
}
| kwrest_mark
{
/*%%%*/
- $$ = internal_id(p);
- arg_var(p, $$);
- /*% %*/
- /*% ripper: kwrest_param!(Qnil) %*/
+ $$ = internal_id();
+ arg_var($$);
+ /*%
+ $$ = dispatch1(kwrest_param, Qnil);
+ %*/
}
;
f_opt : f_arg_asgn '=' arg_value
{
- p->cur_arg = 0;
+ current_arg = 0;
+ $$ = assignable($1, $3, &@$);
/*%%%*/
- $$ = NEW_OPT_ARG(0, assignable(p, $1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($3)) %*/
+ $$ = NEW_OPT_ARG(0, $$);
+ $$->nd_loc = @$;
+ /*%
+ $$ = rb_assoc_new(get_value($$), get_value($3));
+ %*/
}
;
f_block_opt : f_arg_asgn '=' primary_value
{
- p->cur_arg = 0;
+ current_arg = 0;
+ $$ = assignable($1, $3, &@$);
/*%%%*/
- $$ = NEW_OPT_ARG(0, assignable(p, $1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($3)) %*/
+ $$ = NEW_OPT_ARG(0, $$);
+ $$->nd_loc = @$;
+ /*%
+ $$ = rb_assoc_new(get_value($$), get_value($3));
+ %*/
}
;
@@ -5219,15 +4837,17 @@ f_block_optarg : f_block_opt
{
/*%%%*/
$$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ /*%
+ $$ = rb_ary_new3(1, get_value($1));
+ %*/
}
| f_block_optarg ',' f_block_opt
{
/*%%%*/
$$ = opt_arg_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ /*%
+ $$ = rb_ary_push($1, get_value($3));
+ %*/
}
;
@@ -5235,15 +4855,17 @@ f_optarg : f_opt
{
/*%%%*/
$$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ /*%
+ $$ = rb_ary_new3(1, get_value($1));
+ %*/
}
| f_optarg ',' f_opt
{
/*%%%*/
$$ = opt_arg_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ /*%
+ $$ = rb_ary_push($1, get_value($3));
+ %*/
}
;
@@ -5253,19 +4875,25 @@ restarg_mark : '*'
f_rest_arg : restarg_mark tIDENTIFIER
{
- arg_var(p, shadowing_lvar(p, get_id($2)));
/*%%%*/
- $$ = $2;
+ if (!is_local_id($2))
+ yyerror0("rest argument must be local variable");
/*% %*/
- /*% ripper: rest_param!($2) %*/
+ arg_var(shadowing_lvar(get_id($2)));
+ /*%%%*/
+ $$ = $2;
+ /*%
+ $$ = dispatch1(rest_param, $2);
+ %*/
}
| restarg_mark
{
/*%%%*/
- $$ = internal_id(p);
- arg_var(p, $$);
- /*% %*/
- /*% ripper: rest_param!(Qnil) %*/
+ $$ = internal_id();
+ arg_var($$);
+ /*%
+ $$ = dispatch1(rest_param, Qnil);
+ %*/
}
;
@@ -5275,11 +4903,18 @@ blkarg_mark : '&'
f_block_arg : blkarg_mark tIDENTIFIER
{
- arg_var(p, shadowing_lvar(p, get_id($2)));
/*%%%*/
- $$ = $2;
+ if (!is_local_id($2))
+ yyerror0("block argument must be local variable");
+ else if (!dyna_in_block() && local_id($2))
+ yyerror0("duplicated block argument name");
/*% %*/
- /*% ripper: blockarg!($2) %*/
+ arg_var(shadowing_lvar(get_id($2)));
+ /*%%%*/
+ $$ = $2;
+ /*%
+ $$ = dispatch1(blockarg, $2);
+ %*/
}
;
@@ -5289,36 +4924,51 @@ opt_f_block_arg : ',' f_block_arg
}
| none
{
- $$ = Qnull;
+ /*%%%*/
+ $$ = 0;
+ /*%
+ $$ = Qundef;
+ %*/
}
;
singleton : var_ref
{
+ /*%%%*/
value_expr($1);
$$ = $1;
+ if (!$$) $$ = NEW_NIL();
+ /*%
+ $$ = $1;
+ %*/
}
| '(' {SET_LEX_STATE(EXPR_BEG);} expr rparen
{
/*%%%*/
- switch (nd_type($3)) {
- case NODE_STR:
- case NODE_DSTR:
- case NODE_XSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_LIT:
- case NODE_LIST:
- case NODE_ZLIST:
- yyerror1(&@3, "can't define singleton method for literals");
- break;
- default:
- value_expr($3);
- break;
+ if ($3 == 0) {
+ yyerror0("can't define singleton method for ().");
+ }
+ else {
+ switch (nd_type($3)) {
+ case NODE_STR:
+ case NODE_DSTR:
+ case NODE_XSTR:
+ case NODE_DXSTR:
+ case NODE_DREGX:
+ case NODE_LIT:
+ case NODE_ARRAY:
+ case NODE_ZARRAY:
+ yyerror0("can't define singleton method for literals");
+ break;
+ default:
+ value_expr($3);
+ break;
+ }
}
$$ = $3;
- /*% %*/
- /*% ripper: paren!($3) %*/
+ /*%
+ $$ = dispatch1(paren, $3);
+ %*/
}
;
@@ -5327,13 +4977,19 @@ assoc_list : none
{
/*%%%*/
$$ = $1;
- /*% %*/
- /*% ripper: assoclist_from_args!($1) %*/
+ /*%
+ $$ = dispatch1(assoclist_from_args, $1);
+ %*/
}
;
assocs : assoc
- /*% ripper[brace]: rb_ary_new3(1, get_value($1)) %*/
+ /*%c%*/
+ /*%c
+ {
+ $$ = rb_ary_new3(1, get_value($1));
+ }
+ %*/
| assocs ',' assoc
{
/*%%%*/
@@ -5343,17 +4999,18 @@ assocs : assoc
assocs = tail;
}
else if (tail) {
- if (assocs->nd_head &&
- !tail->nd_head && nd_type(tail->nd_next) == NODE_LIST &&
- nd_type(tail->nd_next->nd_head) == NODE_HASH) {
- /* DSTAR */
- tail = tail->nd_next->nd_head->nd_head;
- }
+ if (assocs->nd_head &&
+ !tail->nd_head && nd_type(tail->nd_next) == NODE_ARRAY &&
+ nd_type(tail->nd_next->nd_head) == NODE_HASH) {
+ /* DSTAR */
+ tail = tail->nd_next->nd_head->nd_head;
+ }
assocs = list_concat(assocs, tail);
}
$$ = assocs;
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ /*%
+ $$ = rb_ary_push($1, get_value($3));
+ %*/
}
;
@@ -5362,43 +5019,43 @@ assoc : arg_value tASSOC arg_value
/*%%%*/
if (nd_type($1) == NODE_STR) {
nd_set_type($1, NODE_LIT);
- RB_OBJ_WRITE(p->ast, &$1->nd_lit, rb_fstring($1->nd_lit));
+ add_mark_object($1->nd_lit = rb_fstring($1->nd_lit));
}
- $$ = list_append(p, NEW_LIST($1, &@$), $3);
- /*% %*/
- /*% ripper: assoc_new!($1, $3) %*/
+ $$ = list_append(new_list($1, &@$), $3);
+ /*%
+ $$ = dispatch2(assoc_new, $1, $3);
+ %*/
}
| tLABEL arg_value
{
/*%%%*/
- $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@1), &@$), $2);
- /*% %*/
- /*% ripper: assoc_new!($1, $2) %*/
+ $$ = list_append(new_list(new_lit(ID2SYM($1), &@1), &@$), $2);
+ /*%
+ $$ = dispatch2(assoc_new, $1, $2);
+ %*/
}
| tSTRING_BEG string_contents tLABEL_END arg_value
{
/*%%%*/
- YYLTYPE loc = code_loc_gen(&@1, &@3);
- $$ = list_append(p, NEW_LIST(dsym_node(p, $2, &loc), &loc), $4);
- /*% %*/
- /*% ripper: assoc_new!(dyna_symbol!($2), $4) %*/
+ YYLTYPE location;
+ location.first_loc = @1.first_loc;
+ location.last_loc = @3.last_loc;
+ $$ = list_append(new_list(dsym_node($2, &location), &location), $4);
+ /*%
+ $$ = dispatch2(assoc_new, dispatch1(dyna_symbol, $2), $4);
+ %*/
}
| tDSTAR arg_value
{
/*%%%*/
- if (nd_type($2) == NODE_HASH &&
- !($2->nd_head && $2->nd_head->nd_alen)) {
- static VALUE empty_hash;
- if (!empty_hash) {
- empty_hash = rb_obj_freeze(rb_hash_new());
- rb_gc_register_mark_object(empty_hash);
- }
- $$ = list_append(p, NEW_LIST(0, &@$), NEW_LIT(empty_hash, &@$));
- }
- else
- $$ = list_append(p, NEW_LIST(0, &@$), $2);
- /*% %*/
- /*% ripper: assoc_splat!($2) %*/
+ if (nd_type($2) == NODE_HASH &&
+ !($2->nd_head && $2->nd_head->nd_alen))
+ $$ = 0;
+ else
+ $$ = list_append(new_list(0, &@$), $2);
+ /*%
+ $$ = dispatch1(assoc_splat, $2);
+ %*/
}
;
@@ -5423,11 +5080,20 @@ dot_or_colon : '.'
;
call_op : '.'
+ {
+ $$ = TOKEN2VAL('.');
+ }
| tANDDOT
+ {
+ $$ = ID2VAL(idANDDOT);
+ }
;
call_op2 : call_op
| tCOLON2
+ {
+ $$ = ID2VAL(idCOLON2);
+ }
;
opt_terms : /* none */
@@ -5444,16 +5110,13 @@ rparen : opt_nl ')'
rbracket : opt_nl ']'
;
-rbrace : opt_nl '}'
- ;
-
trailer : /* none */
| '\n'
| ','
;
-term : ';' {yyerrok;token_flush(p);}
- | '\n' {token_flush(p);}
+term : ';' {yyerrok;token_flush(parser);}
+ | '\n' {token_flush(parser);}
;
terms : term
@@ -5466,62 +5129,69 @@ none : /* none */
}
;
%%
-# undef p
+# undef parser
# undef yylex
# undef yylval
-# define yylval (*p->lval)
-
-static int regx_options(struct parser_params*);
-static int tokadd_string(struct parser_params*,int,int,int,long*,rb_encoding**,rb_encoding**);
-static void tokaddmbc(struct parser_params *p, int c, rb_encoding *enc);
-static enum yytokentype parse_string(struct parser_params*,rb_strterm_literal_t*);
-static enum yytokentype here_document(struct parser_params*,rb_strterm_heredoc_t*);
+# define yylval (*parser->lval)
+
+static int parser_regx_options(struct parser_params*);
+static int parser_tokadd_string(struct parser_params*,int,int,int,long*,rb_encoding**,rb_encoding**);
+static void parser_tokaddmbc(struct parser_params *parser, int c, rb_encoding *enc);
+static enum yytokentype parser_parse_string(struct parser_params*,rb_strterm_literal_t*);
+static enum yytokentype parser_here_document(struct parser_params*,rb_strterm_heredoc_t*);
+
+
+# define nextc() parser_nextc(parser)
+# define pushback(c) parser_pushback(parser, (c))
+# define newtok() parser_newtok(parser)
+# define tokspace(n) parser_tokspace(parser, (n))
+# define tokadd(c) parser_tokadd(parser, (c))
+# define tok_hex(numlen) parser_tok_hex(parser, (numlen))
+# define read_escape(flags,e) parser_read_escape(parser, (flags), (e))
+# define tokadd_escape(e) parser_tokadd_escape(parser, (e))
+# define regx_options() parser_regx_options(parser)
+# define tokadd_string(f,t,p,n,e,e2) parser_tokadd_string(parser,(f),(t),(p),(n),(e),(e2))
+# define parse_string(n) parser_parse_string(parser,(n))
+# define tokaddmbc(c, enc) parser_tokaddmbc(parser, (c), (enc))
+# define here_document(n) parser_here_document(parser,(n))
+# define heredoc_identifier() parser_heredoc_identifier(parser)
+# define heredoc_restore(n) parser_heredoc_restore(parser,(n))
+# define whole_match_p(e,l,i) parser_whole_match_p(parser,(e),(l),(i))
+# define number_literal_suffix(f) parser_number_literal_suffix(parser, (f))
+# define set_number_literal(v, t, f) parser_set_number_literal(parser, (v), (t), (f))
+# define set_integer_literal(v, f) parser_set_integer_literal(parser, (v), (f))
#ifndef RIPPER
-# define set_yylval_node(x) { \
- YYLTYPE _cur_loc; \
- rb_parser_set_location(p, &_cur_loc); \
- yylval.node = (x); \
-}
-# define set_yylval_str(x) \
-do { \
- set_yylval_node(NEW_STR(x, &_cur_loc)); \
- RB_OBJ_WRITTEN(p->ast, Qnil, x); \
-} while(0)
-# define set_yylval_literal(x) \
-do { \
- set_yylval_node(NEW_LIT(x, &_cur_loc)); \
- RB_OBJ_WRITTEN(p->ast, Qnil, x); \
-} while(0)
+# define set_yylval_str(x) (yylval.node = NEW_STR(x))
# define set_yylval_num(x) (yylval.num = (x))
# define set_yylval_id(x) (yylval.id = (x))
# define set_yylval_name(x) (yylval.id = (x))
+# define set_yylval_literal(x) (yylval.node = NEW_LIT(x))
+# define set_yylval_node(x) (yylval.node = (x))
# define yylval_id() (yylval.id)
#else
static inline VALUE
-ripper_yylval_id(struct parser_params *p, ID x)
+ripper_yylval_id_gen(struct parser_params *parser, ID x)
{
- return ripper_new_yylval(p, x, ID2SYM(x), 0);
+ return ripper_new_yylval(x, ID2SYM(x), 0);
}
-# define set_yylval_str(x) (yylval.val = add_mark_object(p, (x)))
-# define set_yylval_num(x) (yylval.val = ripper_new_yylval(p, (x), 0, 0))
+#define ripper_yylval_id(x) ripper_yylval_id_gen(parser, x)
+# define set_yylval_str(x) (yylval.val = (x))
+# define set_yylval_num(x) (yylval.val = ripper_new_yylval((x), 0, 0))
# define set_yylval_id(x) (void)(x)
-# define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(p, x))
-# define set_yylval_literal(x) add_mark_object(p, (x))
+# define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(x))
+# define set_yylval_literal(x) (void)(x)
# define set_yylval_node(x) (void)(x)
# define yylval_id() yylval.id
-# define _cur_loc NULL_LOC /* dummy */
#endif
-#define set_yylval_noname() set_yylval_id(keyword_nil)
-
#ifndef RIPPER
-#define literal_flush(p, ptr) ((p)->lex.ptok = (ptr))
-#define dispatch_scan_event(p, t) ((void)0)
-#define dispatch_delayed_token(p, t) ((void)0)
-#define has_delayed_token(p) (0)
+#define literal_flush(p) (parser->tokp = (p))
+#define dispatch_scan_event(t) ((void)0)
+#define dispatch_delayed_token(t) ((void)0)
+#define has_delayed_token() (0)
#else
-#define literal_flush(p, ptr) ((void)(ptr))
+#define literal_flush(p) ((void)0)
#define yylval_rval (*(RB_TYPE_P(yylval.val, T_NODE) ? &yylval.node->nd_rval : &yylval.val))
@@ -5533,327 +5203,218 @@ intern_sym(const char *name)
}
static int
-ripper_has_scan_event(struct parser_params *p)
+ripper_has_scan_event(struct parser_params *parser)
{
- if (p->lex.pcur < p->lex.ptok) rb_raise(rb_eRuntimeError, "lex.pcur < lex.ptok");
- return p->lex.pcur > p->lex.ptok;
+
+ if (lex_p < parser->tokp) rb_raise(rb_eRuntimeError, "lex_p < tokp");
+ return lex_p > parser->tokp;
}
static VALUE
-ripper_scan_event_val(struct parser_params *p, enum yytokentype t)
+ripper_scan_event_val(struct parser_params *parser, int t)
{
- VALUE str = STR_NEW(p->lex.ptok, p->lex.pcur - p->lex.ptok);
- VALUE rval = ripper_dispatch1(p, ripper_token2eventid(t), str);
- token_flush(p);
+ VALUE str = STR_NEW(parser->tokp, lex_p - parser->tokp);
+ VALUE rval = ripper_dispatch1(parser, ripper_token2eventid(t), str);
+ token_flush(parser);
return rval;
}
static void
-ripper_dispatch_scan_event(struct parser_params *p, enum yytokentype t)
+ripper_dispatch_scan_event(struct parser_params *parser, int t)
{
- if (!ripper_has_scan_event(p)) return;
- add_mark_object(p, yylval_rval = ripper_scan_event_val(p, t));
+ if (!ripper_has_scan_event(parser)) return;
+ add_mark_object(yylval_rval = ripper_scan_event_val(parser, t));
}
-#define dispatch_scan_event(p, t) ripper_dispatch_scan_event(p, t)
+#define dispatch_scan_event(t) ripper_dispatch_scan_event(parser, t)
static void
-ripper_dispatch_delayed_token(struct parser_params *p, enum yytokentype t)
+ripper_dispatch_delayed_token(struct parser_params *parser, int t)
{
- int saved_line = p->ruby_sourceline;
- const char *saved_tokp = p->lex.ptok;
+ int saved_line = ruby_sourceline;
+ const char *saved_tokp = parser->tokp;
- if (NIL_P(p->delayed.token)) return;
- p->ruby_sourceline = p->delayed.line;
- p->lex.ptok = p->lex.pbeg + p->delayed.col;
- add_mark_object(p, yylval_rval = ripper_dispatch1(p, ripper_token2eventid(t), p->delayed.token));
- p->delayed.token = Qnil;
- p->ruby_sourceline = saved_line;
- p->lex.ptok = saved_tokp;
+ ruby_sourceline = parser->delayed_line;
+ parser->tokp = lex_pbeg + parser->delayed_col;
+ add_mark_object(yylval_rval = ripper_dispatch1(parser, ripper_token2eventid(t), parser->delayed));
+ parser->delayed = Qnil;
+ ruby_sourceline = saved_line;
+ parser->tokp = saved_tokp;
}
-#define dispatch_delayed_token(p, t) ripper_dispatch_delayed_token(p, t)
-#define has_delayed_token(p) (!NIL_P(p->delayed.token))
+#define dispatch_delayed_token(t) ripper_dispatch_delayed_token(parser, t)
+#define has_delayed_token() (!NIL_P(parser->delayed))
#endif /* RIPPER */
#include "ruby/regex.h"
#include "ruby/util.h"
-static inline int
-is_identchar(const char *ptr, const char *MAYBE_UNUSED(ptr_end), rb_encoding *enc)
-{
- return rb_enc_isalnum((unsigned char)*ptr, enc) || *ptr == '_' || !ISASCII(*ptr);
-}
-
-static inline int
-parser_is_identchar(struct parser_params *p)
-{
- return !(p)->eofp && is_identchar(p->lex.pcur-1, p->lex.pend, p->enc);
-}
+#define parser_encoding_name() (current_enc->name)
+#define parser_mbclen() mbclen((lex_p-1),lex_pend,current_enc)
+#define is_identchar(p,e,enc) (rb_enc_isalnum((unsigned char)(*(p)),(enc)) || (*(p)) == '_' || !ISASCII(*(p)))
+#define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,current_enc))
-static inline int
-parser_isascii(struct parser_params *p)
-{
- return ISASCII(*(p->lex.pcur-1));
-}
+#define parser_isascii() ISASCII(*(lex_p-1))
-static void
-token_info_setup(token_info *ptinfo, const char *ptr, const rb_code_location_t *loc)
+static int
+token_info_get_column(struct parser_params *parser, const char *pend)
{
- int column = 1, nonspc = 0, i;
- for (i = 0; i < loc->beg_pos.column; i++, ptr++) {
- if (*ptr == '\t') {
+ int column = 1;
+ const char *p;
+ for (p = lex_pbeg; p < pend; p++) {
+ if (*p == '\t') {
column = (((column - 1) / TAB_WIDTH) + 1) * TAB_WIDTH;
}
column++;
- if (*ptr != ' ' && *ptr != '\t') {
- nonspc = 1;
- }
}
+ return column;
+}
- ptinfo->beg = loc->beg_pos;
- ptinfo->indent = column;
- ptinfo->nonspc = nonspc;
+static int
+token_info_has_nonspaces(struct parser_params *parser, const char *pend)
+{
+ const char *p;
+ for (p = lex_pbeg; p < pend; p++) {
+ if (*p != ' ' && *p != '\t') {
+ return 1;
+ }
+ }
+ return 0;
}
static void
-token_info_push(struct parser_params *p, const char *token, const rb_code_location_t *loc)
+token_info_push_gen(struct parser_params *parser, const char *token, size_t len)
{
token_info *ptinfo;
+ const char *t = lex_p - len;
- if (!p->token_info_enabled) return;
+ if (!parser->token_info_enabled) return;
ptinfo = ALLOC(token_info);
ptinfo->token = token;
- ptinfo->next = p->token_info;
- token_info_setup(ptinfo, p->lex.pbeg, loc);
+ ptinfo->linenum = ruby_sourceline;
+ ptinfo->column = token_info_get_column(parser, t);
+ ptinfo->nonspc = token_info_has_nonspaces(parser, t);
+ ptinfo->next = parser->token_info;
- p->token_info = ptinfo;
+ parser->token_info = ptinfo;
}
static void
-token_info_pop(struct parser_params *p, const char *token, const rb_code_location_t *loc)
+token_info_pop_gen(struct parser_params *parser, const char *token, size_t len)
{
- token_info *ptinfo_beg = p->token_info;
+ int linenum;
+ token_info *ptinfo = parser->token_info;
+ const char *t = lex_p - len;
- if (!ptinfo_beg) return;
- p->token_info = ptinfo_beg->next;
+ if (!ptinfo) return;
+ parser->token_info = ptinfo->next;
+ linenum = ruby_sourceline;
+ if (parser->token_info_enabled &&
+ linenum != ptinfo->linenum && !ptinfo->nonspc &&
+ !token_info_has_nonspaces(parser, t) &&
+ token_info_get_column(parser, t) != ptinfo->column) {
+ rb_warn3L(linenum,
+ "mismatched indentations at '%s' with '%s' at %d",
+ WARN_S(token), WARN_S(ptinfo->token), WARN_I(ptinfo->linenum));
+ }
- /* indentation check of matched keywords (begin..end, if..end, etc.) */
- token_info_warn(p, token, ptinfo_beg, 1, loc);
- ruby_sized_xfree(ptinfo_beg, sizeof(*ptinfo_beg));
-}
-
-static void
-token_info_warn(struct parser_params *p, const char *token, token_info *ptinfo_beg, int same, const rb_code_location_t *loc)
-{
- token_info ptinfo_end_body, *ptinfo_end = &ptinfo_end_body;
- if (!p->token_info_enabled) return;
- if (!ptinfo_beg) return;
- token_info_setup(ptinfo_end, p->lex.pbeg, loc);
- if (ptinfo_beg->beg.lineno == ptinfo_end->beg.lineno) return; /* ignore one-line block */
- if (ptinfo_beg->nonspc || ptinfo_end->nonspc) return; /* ignore keyword in the middle of a line */
- if (ptinfo_beg->indent == ptinfo_end->indent) return; /* the indents are matched */
- if (!same && ptinfo_beg->indent < ptinfo_end->indent) return;
- rb_warn3L(ptinfo_end->beg.lineno,
- "mismatched indentations at '%s' with '%s' at %d",
- WARN_S(token), WARN_S(ptinfo_beg->token), WARN_I(ptinfo_beg->beg.lineno));
+ xfree(ptinfo);
}
static int
-parser_precise_mbclen(struct parser_params *p, const char *ptr)
+parser_precise_mbclen(struct parser_params *parser, const char *p)
{
- int len = rb_enc_precise_mbclen(ptr, p->lex.pend, p->enc);
+ int len = rb_enc_precise_mbclen(p, lex_pend, current_enc);
if (!MBCLEN_CHARFOUND_P(len)) {
- compile_error(p, "invalid multibyte char (%s)", rb_enc_name(p->enc));
+ compile_error(PARSER_ARG "invalid multibyte char (%s)", parser_encoding_name());
return -1;
}
return len;
}
-#ifndef RIPPER
-static void ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str);
-
-static inline void
-parser_show_error_line(struct parser_params *p, const YYLTYPE *yylloc)
-{
- VALUE str;
- int lineno = p->ruby_sourceline;
- if (!yylloc) {
- return;
- }
- else if (yylloc->beg_pos.lineno == lineno) {
- str = p->lex.lastline;
- }
- else {
- return;
- }
- ruby_show_error_line(p->error_buffer, yylloc, lineno, str);
-}
-
static int
-parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg)
-{
- YYLTYPE current;
-
- if (!yylloc) {
- yylloc = RUBY_SET_YYLLOC(current);
- }
- else if ((p->ruby_sourceline != yylloc->beg_pos.lineno &&
- p->ruby_sourceline != yylloc->end_pos.lineno) ||
- (yylloc->beg_pos.lineno == yylloc->end_pos.lineno &&
- yylloc->beg_pos.column == yylloc->end_pos.column)) {
- yylloc = 0;
- }
- compile_error(p, "%s", msg);
- parser_show_error_line(p, yylloc);
- return 0;
-}
-
-static void
-ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str)
+parser_yyerror(struct parser_params *parser, const char *msg)
{
- VALUE mesg;
+#ifndef RIPPER
const int max_line_margin = 30;
- const char *ptr, *ptr_end, *pt, *pb;
+ const char *p, *pe;
const char *pre = "", *post = "", *pend;
- const char *code = "", *caret = "";
+ const char *code = "", *caret = "", *newline = "";
const char *lim;
- const char *const pbeg = RSTRING_PTR(str);
char *buf;
long len;
int i;
- if (!yylloc) return;
- pend = RSTRING_END(str);
- if (pend > pbeg && pend[-1] == '\n') {
- if (--pend > pbeg && pend[-1] == '\r') --pend;
- }
-
- pt = pend;
- if (lineno == yylloc->end_pos.lineno &&
- (pend - pbeg) > yylloc->end_pos.column) {
- pt = pbeg + yylloc->end_pos.column;
+ pend = lex_pend;
+ if (pend > lex_pbeg && pend[-1] == '\n') {
+ if (--pend > lex_pbeg && pend[-1] == '\r') --pend;
}
- ptr = ptr_end = pt;
- lim = ptr - pbeg > max_line_margin ? ptr - max_line_margin : pbeg;
- while ((lim < ptr) && (*(ptr-1) != '\n')) ptr--;
+ p = pe = lex_p < pend ? lex_p : pend;
+ lim = p - lex_pbeg > max_line_margin ? p - max_line_margin : lex_pbeg;
+ while ((lim < p) && (*(p-1) != '\n')) p--;
- lim = pend - ptr_end > max_line_margin ? ptr_end + max_line_margin : pend;
- while ((ptr_end < lim) && (*ptr_end != '\n') && (*ptr_end != '\r')) ptr_end++;
+ lim = pend - pe > max_line_margin ? pe + max_line_margin : pend;
+ while ((pe < lim) && (*pe != '\n')) pe++;
- len = ptr_end - ptr;
+ len = pe - p;
if (len > 4) {
- if (ptr > pbeg) {
- ptr = rb_enc_prev_char(pbeg, ptr, pt, rb_enc_get(str));
- if (ptr > pbeg) pre = "...";
- }
- if (ptr_end < pend) {
- ptr_end = rb_enc_prev_char(pt, ptr_end, pend, rb_enc_get(str));
- if (ptr_end < pend) post = "...";
- }
- }
- pb = pbeg;
- if (lineno == yylloc->beg_pos.lineno) {
- pb += yylloc->beg_pos.column;
- if (pb > pt) pb = pt;
- }
- if (pb < ptr) pb = ptr;
- if (len <= 4 && yylloc->beg_pos.lineno == yylloc->end_pos.lineno) {
- return;
- }
- if (RTEST(errbuf)) {
- mesg = rb_attr_get(errbuf, idMesg);
- if (RSTRING_LEN(mesg) > 0 && *(RSTRING_END(mesg)-1) != '\n')
- rb_str_cat_cstr(mesg, "\n");
- }
- else {
- mesg = rb_enc_str_new(0, 0, rb_enc_get(str));
- }
- if (!errbuf && rb_stderr_tty_p()) {
-#define CSI_BEGIN "\033["
-#define CSI_SGR "m"
- rb_str_catf(mesg,
- CSI_BEGIN""CSI_SGR"%s" /* pre */
- CSI_BEGIN"1"CSI_SGR"%.*s"
- CSI_BEGIN"1;4"CSI_SGR"%.*s"
- CSI_BEGIN";1"CSI_SGR"%.*s"
- CSI_BEGIN""CSI_SGR"%s" /* post */
- "\n",
- pre,
- (int)(pb - ptr), ptr,
- (int)(pt - pb), pb,
- (int)(ptr_end - pt), pt,
- post);
- }
- else {
char *p2;
- len = ptr_end - ptr;
- lim = pt < pend ? pt : pend;
- i = (int)(lim - ptr);
+ if (p > lex_pbeg) {
+ p = rb_enc_prev_char(lex_pbeg, p, lex_p, rb_enc_get(lex_lastline));
+ if (p > lex_pbeg) pre = "...";
+ }
+ if (pe < pend) {
+ pe = rb_enc_prev_char(lex_p, pe, pend, rb_enc_get(lex_lastline));
+ if (pe < pend) post = "...";
+ }
+ len = pe - p;
+ lim = lex_p < pend ? lex_p : pend;
+ i = (int)(lim - p);
buf = ALLOCA_N(char, i+2);
- code = ptr;
+ code = p;
caret = p2 = buf;
- if (ptr <= pb) {
- while (ptr < pb) {
- *p2++ = *ptr++ == '\t' ? '\t' : ' ';
+ pe = (parser->tokp < lim ? parser->tokp : lim);
+ if (p <= pe) {
+ while (p < pe) {
+ *p2++ = *p++ == '\t' ? '\t' : ' ';
}
*p2++ = '^';
- ptr++;
+ p++;
}
- if (lim > ptr) {
- memset(p2, '~', (lim - ptr));
- p2 += (lim - ptr);
+ if (lim > p) {
+ memset(p2, '~', (lim - p));
+ p2 += (lim - p);
}
*p2 = '\0';
- rb_str_catf(mesg, "%s%.*s%s\n""%s%s\n",
- pre, (int)len, code, post,
- pre, caret);
+ newline = "\n";
}
- if (!errbuf) rb_write_error_str(mesg);
-}
-#else
-static int
-parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg)
-{
- const char *pcur = 0, *ptok = 0;
- if (yylloc &&
- p->ruby_sourceline == yylloc->beg_pos.lineno &&
- p->ruby_sourceline == yylloc->end_pos.lineno) {
- pcur = p->lex.pcur;
- ptok = p->lex.ptok;
- p->lex.ptok = p->lex.pbeg + yylloc->beg_pos.column;
- p->lex.pcur = p->lex.pbeg + yylloc->end_pos.column;
+ else {
+ len = 0;
}
+ compile_error(PARSER_ARG "%s%s""%s%.*s%s%s""%s%s",
+ msg, newline,
+ pre, (int)len, code, post, newline,
+ pre, caret);
+#else
dispatch1(parse_error, STR_NEW2(msg));
- ripper_error(p);
- if (pcur) {
- p->lex.ptok = ptok;
- p->lex.pcur = pcur;
- }
+ ripper_error();
+#endif /* !RIPPER */
return 0;
}
-static inline void
-parser_show_error_line(struct parser_params *p, const YYLTYPE *yylloc)
-{
-}
-#endif /* !RIPPER */
-
-#ifndef RIPPER
static int
vtable_size(const struct vtable *tbl)
{
- if (!DVARS_TERMINAL_P(tbl)) {
+ if (POINTER_P(tbl)) {
return tbl->pos;
}
else {
return 0;
}
}
-#endif
static struct vtable *
-vtable_alloc_gen(struct parser_params *p, int line, struct vtable *prev)
+vtable_alloc_gen(struct parser_params *parser, int line, struct vtable *prev)
{
struct vtable *tbl = ALLOC(struct vtable);
tbl->pos = 0;
@@ -5861,70 +5422,70 @@ vtable_alloc_gen(struct parser_params *p, int line, struct vtable *prev)
tbl->tbl = ALLOC_N(ID, tbl->capa);
tbl->prev = prev;
#ifndef RIPPER
- if (p->debug) {
- rb_parser_printf(p, "vtable_alloc:%d: %p\n", line, (void *)tbl);
+ if (yydebug) {
+ rb_parser_printf(parser, "vtable_alloc:%d: %p\n", line, tbl);
}
#endif
return tbl;
}
-#define vtable_alloc(prev) vtable_alloc_gen(p, __LINE__, prev)
+#define vtable_alloc(prev) vtable_alloc_gen(parser, __LINE__, prev)
static void
-vtable_free_gen(struct parser_params *p, int line, const char *name,
+vtable_free_gen(struct parser_params *parser, int line, const char *name,
struct vtable *tbl)
{
#ifndef RIPPER
- if (p->debug) {
- rb_parser_printf(p, "vtable_free:%d: %s(%p)\n", line, name, (void *)tbl);
+ if (yydebug) {
+ rb_parser_printf(parser, "vtable_free:%d: %s(%p)\n", line, name, tbl);
}
#endif
- if (!DVARS_TERMINAL_P(tbl)) {
+ if (POINTER_P(tbl)) {
if (tbl->tbl) {
- ruby_sized_xfree(tbl->tbl, tbl->capa * sizeof(ID));
+ xfree(tbl->tbl);
}
- ruby_sized_xfree(tbl, sizeof(tbl));
+ xfree(tbl);
}
}
-#define vtable_free(tbl) vtable_free_gen(p, __LINE__, #tbl, tbl)
+#define vtable_free(tbl) vtable_free_gen(parser, __LINE__, #tbl, tbl)
static void
-vtable_add_gen(struct parser_params *p, int line, const char *name,
+vtable_add_gen(struct parser_params *parser, int line, const char *name,
struct vtable *tbl, ID id)
{
#ifndef RIPPER
- if (p->debug) {
- rb_parser_printf(p, "vtable_add:%d: %s(%p), %s\n",
- line, name, (void *)tbl, rb_id2name(id));
+ if (yydebug) {
+ rb_parser_printf(parser, "vtable_add:%d: %s(%p), %s\n",
+ line, name, tbl, rb_id2name(id));
}
#endif
- if (DVARS_TERMINAL_P(tbl)) {
- rb_parser_fatal(p, "vtable_add: vtable is not allocated (%p)", (void *)tbl);
+ if (!POINTER_P(tbl)) {
+ rb_parser_fatal(parser, "vtable_add: vtable is not allocated (%p)", (void *)tbl);
return;
}
if (tbl->pos == tbl->capa) {
tbl->capa = tbl->capa * 2;
- SIZED_REALLOC_N(tbl->tbl, ID, tbl->capa, tbl->pos);
+ REALLOC_N(tbl->tbl, ID, tbl->capa);
}
tbl->tbl[tbl->pos++] = id;
}
-#define vtable_add(tbl, id) vtable_add_gen(p, __LINE__, #tbl, tbl, id)
+#define vtable_add(tbl, id) vtable_add_gen(parser, __LINE__, #tbl, tbl, id)
#ifndef RIPPER
static void
-vtable_pop_gen(struct parser_params *p, int line, const char *name,
+vtable_pop_gen(struct parser_params *parser, int line, const char *name,
struct vtable *tbl, int n)
{
- if (p->debug) {
- rb_parser_printf(p, "vtable_pop:%d: %s(%p), %d\n",
- line, name, (void *)tbl, n);
+ if (yydebug) {
+ rb_parser_printf(parser, "vtable_pop:%d: %s(%p), %d\n",
+ line, name, tbl, n);
}
if (tbl->pos < n) {
- rb_parser_fatal(p, "vtable_pop: unreachable (%d < %d)", tbl->pos, n);
+ rb_parser_fatal(parser, "vtable_pop: unreachable (%d < %d)", tbl->pos, n);
return;
}
tbl->pos -= n;
}
-#define vtable_pop(tbl, n) vtable_pop_gen(p, __LINE__, #tbl, tbl, n)
+#define vtable_pop(tbl, n) vtable_pop_gen(parser, __LINE__, #tbl, tbl, n)
#endif
static int
@@ -5932,7 +5493,7 @@ vtable_included(const struct vtable * tbl, ID id)
{
int i;
- if (!DVARS_TERMINAL_P(tbl)) {
+ if (POINTER_P(tbl)) {
for (i = 0; i < tbl->pos; i++) {
if (tbl->tbl[i] == id) {
return i+1;
@@ -5942,10 +5503,10 @@ vtable_included(const struct vtable * tbl, ID id)
return 0;
}
-static void parser_prepare(struct parser_params *p);
+static void parser_prepare(struct parser_params *parser);
#ifndef RIPPER
-static NODE *parser_append_options(struct parser_params *p, NODE *node);
+static NODE *parser_append_options(struct parser_params *parser, NODE *node);
static VALUE
debug_lines(VALUE fname)
@@ -5963,10 +5524,25 @@ debug_lines(VALUE fname)
return 0;
}
+static VALUE
+coverage(VALUE fname, int n)
+{
+ VALUE coverages = rb_get_coverages();
+ if (RTEST(coverages) && RBASIC(coverages)->klass == 0) {
+ VALUE coverage = rb_default_coverage(n);
+ VALUE lines = RARRAY_AREF(coverage, COVERAGE_INDEX_LINES);
+
+ rb_hash_aset(coverages, fname, coverage);
+
+ return lines == Qnil ? Qfalse : lines;
+ }
+ return 0;
+}
+
static int
-e_option_supplied(struct parser_params *p)
+e_option_supplied(struct parser_params *parser)
{
- return strcmp(p->ruby_sourcefile, "-e") == 0;
+ return strcmp(ruby_sourcefile, "-e") == 0;
}
static VALUE
@@ -5974,84 +5550,76 @@ yycompile0(VALUE arg)
{
int n;
NODE *tree;
- struct parser_params *p = (struct parser_params *)arg;
+ struct parser_params *parser = (struct parser_params *)arg;
VALUE cov = Qfalse;
- if (!compile_for_eval && !NIL_P(p->ruby_sourcefile_string)) {
- p->debug_lines = debug_lines(p->ruby_sourcefile_string);
- if (p->debug_lines && p->ruby_sourceline > 0) {
+ if (!compile_for_eval && rb_safe_level() == 0) {
+ ruby_debug_lines = debug_lines(ruby_sourcefile_string);
+ if (ruby_debug_lines && ruby_sourceline > 0) {
VALUE str = STR_NEW0();
- n = p->ruby_sourceline;
+ n = ruby_sourceline;
do {
- rb_ary_push(p->debug_lines, str);
+ rb_ary_push(ruby_debug_lines, str);
} while (--n);
}
- if (!e_option_supplied(p)) {
+ if (!e_option_supplied(parser)) {
+ ruby_coverage = coverage(ruby_sourcefile_string, ruby_sourceline);
cov = Qtrue;
}
}
- parser_prepare(p);
+ parser_prepare(parser);
+#ifndef RIPPER
#define RUBY_DTRACE_PARSE_HOOK(name) \
if (RUBY_DTRACE_PARSE_##name##_ENABLED()) { \
- RUBY_DTRACE_PARSE_##name(p->ruby_sourcefile, p->ruby_sourceline); \
+ RUBY_DTRACE_PARSE_##name(ruby_sourcefile, ruby_sourceline); \
}
RUBY_DTRACE_PARSE_HOOK(BEGIN);
- n = yyparse(p);
+#endif
+ n = yyparse((void*)parser);
+#ifndef RIPPER
RUBY_DTRACE_PARSE_HOOK(END);
- p->debug_lines = 0;
-
- p->lex.strterm = 0;
- p->lex.pcur = p->lex.pbeg = p->lex.pend = 0;
- p->lex.prevline = p->lex.lastline = p->lex.nextline = 0;
- if (n || p->error_p) {
- VALUE mesg = p->error_buffer;
+#endif
+ ruby_debug_lines = 0;
+ ruby_coverage = 0;
+
+ lex_strterm = 0;
+ lex_p = lex_pbeg = lex_pend = 0;
+ lex_prevline = lex_lastline = lex_nextline = 0;
+ if (parser->error_p) {
+ VALUE mesg = parser->error_buffer;
if (!mesg) {
mesg = rb_class_new_instance(0, 0, rb_eSyntaxError);
}
rb_set_errinfo(mesg);
- return FALSE;
+ return 0;
}
- tree = p->eval_tree;
+ tree = ruby_eval_tree;
if (!tree) {
- tree = NEW_NIL(&NULL_LOC);
+ tree = NEW_NIL();
}
else {
- VALUE opt = p->compile_option;
+ VALUE opt = parser->compile_option;
NODE *prelude;
- NODE *body = parser_append_options(p, tree->nd_body);
+ NODE *body = parser_append_options(parser, tree->nd_body);
if (!opt) opt = rb_obj_hide(rb_ident_hash_new());
rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov);
- prelude = block_append(p, p->eval_tree_begin, body);
+ prelude = NEW_PRELUDE(ruby_eval_tree_begin, body, opt);
+ add_mark_object(opt);
+ prelude->nd_loc = body->nd_loc;
tree->nd_body = prelude;
- RB_OBJ_WRITE(p->ast, &p->ast->body.compile_option, opt);
}
- p->ast->body.root = tree;
- p->ast->body.line_count = p->line_count;
- return TRUE;
+ return (VALUE)tree;
}
-static rb_ast_t *
-yycompile(VALUE vparser, struct parser_params *p, VALUE fname, int line)
+static NODE*
+yycompile(struct parser_params *parser, VALUE fname, int line)
{
- rb_ast_t *ast;
- if (NIL_P(fname)) {
- p->ruby_sourcefile_string = Qnil;
- p->ruby_sourcefile = "(none)";
- }
- else {
- p->ruby_sourcefile_string = rb_fstring(fname);
- p->ruby_sourcefile = StringValueCStr(fname);
- }
- p->ruby_sourceline = line - 1;
-
- p->ast = ast = rb_ast_new();
- rb_suppress_tracing(yycompile0, (VALUE)p);
- p->ast = 0;
- RB_GC_GUARD(vparser); /* prohibit tail call optimization */
-
- return ast;
+ ruby_sourcefile_string = rb_str_new_frozen(fname);
+ ruby_sourcefile = RSTRING_PTR(fname);
+ ruby_sourceline = line - 1;
+ return (NODE *)rb_suppress_tracing(yycompile0, (VALUE)parser);
}
#endif /* !RIPPER */
@@ -6066,7 +5634,7 @@ must_be_ascii_compatible(VALUE s)
}
static VALUE
-lex_get_str(struct parser_params *p, VALUE s)
+lex_get_str(struct parser_params *parser, VALUE s)
{
char *beg, *end, *start;
long len;
@@ -6074,30 +5642,32 @@ lex_get_str(struct parser_params *p, VALUE s)
beg = RSTRING_PTR(s);
len = RSTRING_LEN(s);
start = beg;
- if (p->lex.gets_.ptr) {
- if (len == p->lex.gets_.ptr) return Qnil;
- beg += p->lex.gets_.ptr;
- len -= p->lex.gets_.ptr;
+ if (lex_gets_ptr) {
+ if (len == lex_gets_ptr) return Qnil;
+ beg += lex_gets_ptr;
+ len -= lex_gets_ptr;
}
end = memchr(beg, '\n', len);
if (end) len = ++end - beg;
- p->lex.gets_.ptr += len;
+ lex_gets_ptr += len;
return rb_str_subseq(s, beg - start, len);
}
static VALUE
-lex_getline(struct parser_params *p)
+lex_getline(struct parser_params *parser)
{
- VALUE line = (*p->lex.gets)(p, p->lex.input);
+ VALUE line = (*lex_gets)(parser, lex_input);
if (NIL_P(line)) return line;
must_be_ascii_compatible(line);
#ifndef RIPPER
- if (p->debug_lines) {
- rb_enc_associate(line, p->enc);
- rb_ary_push(p->debug_lines, line);
+ if (ruby_debug_lines) {
+ rb_enc_associate(line, current_enc);
+ rb_ary_push(ruby_debug_lines, line);
+ }
+ if (ruby_coverage) {
+ rb_ary_push(ruby_coverage, Qnil);
}
#endif
- p->line_count++;
return line;
}
@@ -6107,16 +5677,29 @@ static const rb_data_type_t parser_data_type;
static rb_ast_t*
parser_compile_string(VALUE vparser, VALUE fname, VALUE s, int line)
{
- struct parser_params *p;
+ struct parser_params *parser;
+ rb_ast_t *ast;
+
+ TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
+ parser->ast = ast = rb_ast_new();
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
+ lex_gets = lex_get_str;
+ lex_gets_ptr = 0;
+ lex_input = rb_str_new_frozen(s);
+ lex_pbeg = lex_p = lex_pend = 0;
- p->lex.gets = lex_get_str;
- p->lex.gets_.ptr = 0;
- p->lex.input = rb_str_new_frozen(s);
- p->lex.pbeg = p->lex.pcur = p->lex.pend = 0;
+ ast->root = yycompile(parser, fname, line);
+ parser->ast = 0;
+ RB_GC_GUARD(vparser); /* prohibit tail call optimization */
- return yycompile(vparser, p, fname, line);
+ return ast;
+}
+
+rb_ast_t*
+rb_compile_string(const char *f, VALUE s, int line)
+{
+ must_be_ascii_compatible(s);
+ return parser_compile_string(rb_parser_new(), rb_filesystem_str_new_cstr(f), s, line);
}
rb_ast_t*
@@ -6132,47 +5715,60 @@ rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
return parser_compile_string(vparser, f, s, line);
}
+rb_ast_t*
+rb_compile_cstr(const char *f, const char *s, int len, int line)
+{
+ VALUE str = rb_str_new(s, len);
+ return parser_compile_string(rb_parser_new(), rb_filesystem_str_new_cstr(f), str, line);
+}
+
+rb_ast_t*
+rb_parser_compile_cstr(VALUE vparser, const char *f, const char *s, int len, int line)
+{
+ VALUE str = rb_str_new(s, len);
+ return parser_compile_string(vparser, rb_filesystem_str_new_cstr(f), str, line);
+}
+
VALUE rb_io_gets_internal(VALUE io);
static VALUE
-lex_io_gets(struct parser_params *p, VALUE io)
+lex_io_gets(struct parser_params *parser, VALUE io)
{
return rb_io_gets_internal(io);
}
rb_ast_t*
-rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
+rb_compile_file(const char *f, VALUE file, int start)
{
- struct parser_params *p;
+ VALUE vparser = rb_parser_new();
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
-
- p->lex.gets = lex_io_gets;
- p->lex.input = file;
- p->lex.pbeg = p->lex.pcur = p->lex.pend = 0;
-
- return yycompile(vparser, p, fname, start);
+ return rb_parser_compile_file(vparser, f, file, start);
}
-static VALUE
-lex_generic_gets(struct parser_params *p, VALUE input)
+rb_ast_t*
+rb_parser_compile_file(VALUE vparser, const char *f, VALUE file, int start)
{
- return (*p->lex.gets_.call)(input, p->line_count);
+ return rb_parser_compile_file_path(vparser, rb_filesystem_str_new_cstr(f), file, start);
}
rb_ast_t*
-rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start)
+rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
{
- struct parser_params *p;
+ struct parser_params *parser;
+ rb_ast_t *ast;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
+ TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
+ parser->ast = ast = rb_ast_new();
- p->lex.gets = lex_generic_gets;
- p->lex.gets_.call = lex_gets;
- p->lex.input = input;
- p->lex.pbeg = p->lex.pcur = p->lex.pend = 0;
+ lex_gets = lex_io_gets;
+ lex_input = file;
+ lex_pbeg = lex_p = lex_pend = 0;
- return yycompile(vparser, p, fname, start);
+ ast->root = yycompile(parser, fname, start);
+ parser->ast = 0;
+ RB_GC_GUARD(vparser); /* prohibit tail call optimization */
+
+ return ast;
}
#endif /* !RIPPER */
@@ -6199,11 +5795,11 @@ enum string_type {
};
static VALUE
-parser_str_new(const char *ptr, long len, rb_encoding *enc, int func, rb_encoding *enc0)
+parser_str_new(const char *p, long n, rb_encoding *enc, int func, rb_encoding *enc0)
{
VALUE str;
- str = rb_enc_str_new(ptr, len, enc);
+ str = rb_enc_str_new(p, n, enc);
if (!(func & STR_FUNC_REGEXP) && rb_enc_asciicompat(enc)) {
if (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) {
}
@@ -6215,226 +5811,175 @@ parser_str_new(const char *ptr, long len, rb_encoding *enc, int func, rb_encodin
return str;
}
-#define lex_goto_eol(p) ((p)->lex.pcur = (p)->lex.pend)
-#define lex_eol_p(p) ((p)->lex.pcur >= (p)->lex.pend)
-#define lex_eol_n_p(p,n) ((p)->lex.pcur+(n) >= (p)->lex.pend)
-#define peek(p,c) peek_n(p, (c), 0)
-#define peek_n(p,c,n) (!lex_eol_n_p(p, n) && (c) == (unsigned char)(p)->lex.pcur[n])
-#define peekc(p) peekc_n(p, 0)
-#define peekc_n(p,n) (lex_eol_n_p(p, n) ? -1 : (unsigned char)(p)->lex.pcur[n])
+#define lex_goto_eol(parser) ((parser)->lex.pcur = (parser)->lex.pend)
+#define lex_eol_p() (lex_p >= lex_pend)
+#define peek(c) peek_n((c), 0)
+#define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
+#define peekc() peekc_n(0)
+#define peekc_n(n) (lex_p+(n) < lex_pend ? (unsigned char)lex_p[n] : -1)
#ifdef RIPPER
static void
-add_delayed_token(struct parser_params *p, const char *tok, const char *end)
+parser_add_delayed_token(struct parser_params *parser, const char *tok, const char *end)
{
if (tok < end) {
- if (!has_delayed_token(p)) {
- p->delayed.token = rb_str_buf_new(end - tok);
- rb_enc_associate(p->delayed.token, p->enc);
- p->delayed.line = p->ruby_sourceline;
- p->delayed.col = rb_long2int(tok - p->lex.pbeg);
+ if (!has_delayed_token()) {
+ parser->delayed = rb_str_buf_new(1024);
+ rb_enc_associate(parser->delayed, current_enc);
+ parser->delayed_line = ruby_sourceline;
+ parser->delayed_col = (int)(tok - lex_pbeg);
}
- rb_str_buf_cat(p->delayed.token, tok, end - tok);
- p->lex.ptok = end;
+ rb_str_buf_cat(parser->delayed, tok, end - tok);
+ parser->tokp = end;
}
}
+#define add_delayed_token(tok, end) parser_add_delayed_token(parser, (tok), (end))
#else
-#define add_delayed_token(p, tok, end) ((void)(tok), (void)(end))
+#define add_delayed_token(tok, end) ((void)(tok), (void)(end))
#endif
static int
-nextline(struct parser_params *p)
+parser_nextline(struct parser_params *parser)
{
- VALUE v = p->lex.nextline;
- p->lex.nextline = 0;
+ VALUE v = lex_nextline;
+ lex_nextline = 0;
if (!v) {
- if (p->eofp)
+ if (parser->eofp)
return -1;
- if (p->lex.pend > p->lex.pbeg && *(p->lex.pend-1) != '\n') {
- goto end_of_input;
- }
-
- if (!p->lex.input || NIL_P(v = lex_getline(p))) {
- end_of_input:
- p->eofp = 1;
- lex_goto_eol(p);
+ if (!lex_input || NIL_P(v = lex_getline(parser))) {
+ parser->eofp = 1;
+ lex_goto_eol(parser);
return -1;
}
- p->cr_seen = FALSE;
- }
- else if (NIL_P(v)) {
- /* after here-document without terminator */
- goto end_of_input;
+ parser->cr_seen = FALSE;
}
- add_delayed_token(p, p->lex.ptok, p->lex.pend);
- if (p->heredoc_end > 0) {
- p->ruby_sourceline = p->heredoc_end;
- p->heredoc_end = 0;
+ add_delayed_token(parser->tokp, lex_pend);
+ if (heredoc_end > 0) {
+ ruby_sourceline = heredoc_end;
+ heredoc_end = 0;
}
- p->ruby_sourceline++;
- p->lex.pbeg = p->lex.pcur = RSTRING_PTR(v);
- p->lex.pend = p->lex.pcur + RSTRING_LEN(v);
- token_flush(p);
- p->lex.prevline = p->lex.lastline;
- p->lex.lastline = v;
+ ruby_sourceline++;
+ parser->line_count++;
+ lex_pbeg = lex_p = RSTRING_PTR(v);
+ lex_pend = lex_p + RSTRING_LEN(v);
+ token_flush(parser);
+ lex_prevline = lex_lastline;
+ lex_lastline = v;
return 0;
}
static int
-parser_cr(struct parser_params *p, int c)
+parser_cr(struct parser_params *parser, int c)
{
- if (peek(p, '\n')) {
- p->lex.pcur++;
+ if (peek('\n')) {
+ lex_p++;
c = '\n';
}
- else if (!p->cr_seen) {
- p->cr_seen = TRUE;
- /* carried over with p->lex.nextline for nextc() */
+ else if (!parser->cr_seen) {
+ parser->cr_seen = TRUE;
+ /* carried over with lex_nextline for nextc() */
rb_warn0("encountered \\r in middle of line, treated as a mere space");
}
return c;
}
static inline int
-nextc(struct parser_params *p)
+parser_nextc(struct parser_params *parser)
{
int c;
- if (UNLIKELY((p->lex.pcur == p->lex.pend) || p->eofp || RTEST(p->lex.nextline))) {
- if (nextline(p)) return -1;
+ if (UNLIKELY((lex_p == lex_pend) || parser->eofp || lex_nextline)) {
+ if (parser_nextline(parser)) return -1;
}
- c = (unsigned char)*p->lex.pcur++;
+ c = (unsigned char)*lex_p++;
if (UNLIKELY(c == '\r')) {
- c = parser_cr(p, c);
+ c = parser_cr(parser, c);
}
return c;
}
static void
-pushback(struct parser_params *p, int c)
+parser_pushback(struct parser_params *parser, int c)
{
if (c == -1) return;
- p->lex.pcur--;
- if (p->lex.pcur > p->lex.pbeg && p->lex.pcur[0] == '\n' && p->lex.pcur[-1] == '\r') {
- p->lex.pcur--;
+ lex_p--;
+ if (lex_p > lex_pbeg && lex_p[0] == '\n' && lex_p[-1] == '\r') {
+ lex_p--;
}
}
-#define was_bol(p) ((p)->lex.pcur == (p)->lex.pbeg + 1)
+#define was_bol() (lex_p == lex_pbeg + 1)
-#define tokfix(p) ((p)->tokenbuf[(p)->tokidx]='\0')
-#define tok(p) (p)->tokenbuf
-#define toklen(p) (p)->tokidx
-
-static int
-looking_at_eol_p(struct parser_params *p)
-{
- const char *ptr = p->lex.pcur;
- while (ptr < p->lex.pend) {
- int c = (unsigned char)*ptr++;
- int eol = (c == '\n' || c == '#');
- if (eol || !ISSPACE(c)) {
- return eol;
- }
- }
- return TRUE;
-}
+#define tokfix() (tokenbuf[tokidx]='\0')
+#define tok() tokenbuf
+#define toklen() tokidx
+#define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
static char*
-newtok(struct parser_params *p)
+parser_newtok(struct parser_params *parser)
{
- p->tokidx = 0;
- p->tokline = p->ruby_sourceline;
- if (!p->tokenbuf) {
- p->toksiz = 60;
- p->tokenbuf = ALLOC_N(char, 60);
+ tokidx = 0;
+ tokline = ruby_sourceline;
+ if (!tokenbuf) {
+ toksiz = 60;
+ tokenbuf = ALLOC_N(char, 60);
}
- if (p->toksiz > 4096) {
- p->toksiz = 60;
- REALLOC_N(p->tokenbuf, char, 60);
+ if (toksiz > 4096) {
+ toksiz = 60;
+ REALLOC_N(tokenbuf, char, 60);
}
- return p->tokenbuf;
+ return tokenbuf;
}
static char *
-tokspace(struct parser_params *p, int n)
+parser_tokspace(struct parser_params *parser, int n)
{
- p->tokidx += n;
+ tokidx += n;
- if (p->tokidx >= p->toksiz) {
- do {p->toksiz *= 2;} while (p->toksiz < p->tokidx);
- REALLOC_N(p->tokenbuf, char, p->toksiz);
+ if (tokidx >= toksiz) {
+ do {toksiz *= 2;} while (toksiz < tokidx);
+ REALLOC_N(tokenbuf, char, toksiz);
}
- return &p->tokenbuf[p->tokidx-n];
+ return &tokenbuf[tokidx-n];
}
static void
-tokadd(struct parser_params *p, int c)
+parser_tokadd(struct parser_params *parser, int c)
{
- p->tokenbuf[p->tokidx++] = (char)c;
- if (p->tokidx >= p->toksiz) {
- p->toksiz *= 2;
- REALLOC_N(p->tokenbuf, char, p->toksiz);
+ tokenbuf[tokidx++] = (char)c;
+ if (tokidx >= toksiz) {
+ toksiz *= 2;
+ REALLOC_N(tokenbuf, char, toksiz);
}
}
static int
-tok_hex(struct parser_params *p, size_t *numlen)
+parser_tok_hex(struct parser_params *parser, size_t *numlen)
{
int c;
- c = scan_hex(p->lex.pcur, 2, numlen);
+ c = scan_hex(lex_p, 2, numlen);
if (!*numlen) {
+ parser->tokp = lex_p;
yyerror0("invalid hex escape");
- token_flush(p);
return 0;
}
- p->lex.pcur += *numlen;
+ lex_p += *numlen;
return c;
}
-#define tokcopy(p, n) memcpy(tokspace(p, n), (p)->lex.pcur - (n), (n))
-
-static int
-escaped_control_code(int c)
-{
- int c2 = 0;
- switch (c) {
- case ' ':
- c2 = 's';
- break;
- case '\n':
- c2 = 'n';
- break;
- case '\t':
- c2 = 't';
- break;
- case '\v':
- c2 = 'v';
- break;
- case '\r':
- c2 = 'r';
- break;
- case '\f':
- c2 = 'f';
- break;
- }
- return c2;
-}
-
-#define WARN_SPACE_CHAR(c, prefix) \
- rb_warn1("invalid character syntax; use "prefix"\\%c", WARN_I(c2))
+#define tokcopy(n) memcpy(tokspace(n), lex_p - (n), (n))
static int
-tokadd_codepoint(struct parser_params *p, rb_encoding **encp,
- int regexp_literal, int wide)
+parser_tokadd_codepoint(struct parser_params *parser, rb_encoding **encp,
+ int regexp_literal, int wide)
{
size_t numlen;
- int codepoint = scan_hex(p->lex.pcur, wide ? p->lex.pend - p->lex.pcur : 4, &numlen);
- literal_flush(p, p->lex.pcur);
- p->lex.pcur += numlen;
+ int codepoint = scan_hex(lex_p, wide ? lex_pend - lex_p : 4, &numlen);
+ literal_flush(lex_p);
+ lex_p += numlen;
if (wide ? (numlen == 0 || numlen > 6) : (numlen < 4)) {
yyerror0("invalid Unicode escape");
return wide && numlen > 0;
@@ -6448,99 +5993,88 @@ tokadd_codepoint(struct parser_params *p, rb_encoding **encp,
return wide;
}
if (regexp_literal) {
- tokcopy(p, (int)numlen);
+ tokcopy((int)numlen);
}
else if (codepoint >= 0x80) {
rb_encoding *utf8 = rb_utf8_encoding();
if (*encp && utf8 != *encp) {
- YYLTYPE loc = RUBY_INIT_YYLLOC();
- compile_error(p, "UTF-8 mixed within %s source", rb_enc_name(*encp));
- parser_show_error_line(p, &loc);
+ static const char mixed_utf8[] = "UTF-8 mixed within %s source";
+ size_t len = sizeof(mixed_utf8) - 2 + strlen(rb_enc_name(*encp));
+ char *mesg = alloca(len);
+ snprintf(mesg, len, mixed_utf8, rb_enc_name(*encp));
+ yyerror0(mesg);
return wide;
}
*encp = utf8;
- tokaddmbc(p, codepoint, *encp);
+ tokaddmbc(codepoint, *encp);
}
else {
- tokadd(p, codepoint);
+ tokadd(codepoint);
}
return TRUE;
}
/* return value is for ?\u3042 */
-static void
-tokadd_utf8(struct parser_params *p, rb_encoding **encp,
- int term, int symbol_literal, int regexp_literal)
+static int
+parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp,
+ int string_literal, int symbol_literal, int regexp_literal)
{
/*
- * If `term` is not -1, then we allow multiple codepoints in \u{}
- * upto `term` byte, otherwise we're parsing a character literal.
- * And then add the codepoints to the current token.
+ * If string_literal is true, then we allow multiple codepoints
+ * in \u{}, and add the codepoints to the current token.
+ * Otherwise we're parsing a character literal and return a single
+ * codepoint without adding it
*/
- static const char multiple_codepoints[] = "Multiple codepoints at single character literal";
const int open_brace = '{', close_brace = '}';
- if (regexp_literal) { tokadd(p, '\\'); tokadd(p, 'u'); }
+ if (regexp_literal) { tokadd('\\'); tokadd('u'); }
- if (peek(p, open_brace)) { /* handle \u{...} form */
- const char *second = NULL;
- int c, last = nextc(p);
- if (p->lex.pcur >= p->lex.pend) goto unterminated;
- while (ISSPACE(c = *p->lex.pcur) && ++p->lex.pcur < p->lex.pend);
+ if (peek(open_brace)) { /* handle \u{...} form */
+ int c, last = nextc();
+ if (lex_p >= lex_pend) goto unterminated;
+ while (ISSPACE(c = *lex_p) && ++lex_p < lex_pend);
while (c != close_brace) {
- if (c == term) goto unterminated;
- if (second == multiple_codepoints)
- second = p->lex.pcur;
- if (regexp_literal) tokadd(p, last);
- if (!tokadd_codepoint(p, encp, regexp_literal, TRUE)) {
+ if (regexp_literal) tokadd(last);
+ if (!parser_tokadd_codepoint(parser, encp, regexp_literal, TRUE)) {
break;
}
- while (ISSPACE(c = *p->lex.pcur)) {
- if (++p->lex.pcur >= p->lex.pend) goto unterminated;
+ while (ISSPACE(c = *lex_p)) {
+ if (++lex_p >= lex_pend) goto unterminated;
last = c;
}
- if (term == -1 && !second)
- second = multiple_codepoints;
}
if (c != close_brace) {
unterminated:
- token_flush(p);
+ literal_flush(lex_p);
yyerror0("unterminated Unicode escape");
- return;
- }
- if (second && second != multiple_codepoints) {
- const char *pcur = p->lex.pcur;
- p->lex.pcur = second;
- dispatch_scan_event(p, tSTRING_CONTENT);
- token_flush(p);
- p->lex.pcur = pcur;
- yyerror0(multiple_codepoints);
- token_flush(p);
+ return 0;
}
- if (regexp_literal) tokadd(p, close_brace);
- nextc(p);
+ if (regexp_literal) tokadd(close_brace);
+ nextc();
}
else { /* handle \uxxxx form */
- if (!tokadd_codepoint(p, encp, regexp_literal, FALSE)) {
- token_flush(p);
- return;
+ if (!parser_tokadd_codepoint(parser, encp, regexp_literal, FALSE)) {
+ return 0;
}
}
+
+ return TRUE;
}
#define ESCAPE_CONTROL 1
#define ESCAPE_META 2
static int
-read_escape(struct parser_params *p, int flags, rb_encoding **encp)
+parser_read_escape(struct parser_params *parser, int flags,
+ rb_encoding **encp)
{
int c;
size_t numlen;
- switch (c = nextc(p)) {
+ switch (c = nextc()) {
case '\\': /* Backslash */
return c;
@@ -6567,13 +6101,13 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
case '0': case '1': case '2': case '3': /* octal constant */
case '4': case '5': case '6': case '7':
- pushback(p, c);
- c = scan_oct(p->lex.pcur, 3, &numlen);
- p->lex.pcur += numlen;
+ pushback(c);
+ c = scan_oct(lex_p, 3, &numlen);
+ lex_p += numlen;
return c;
case 'x': /* hex constant */
- c = tok_hex(p, &numlen);
+ c = tok_hex(&numlen);
if (numlen == 0) return 0;
return c;
@@ -6585,69 +6119,37 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
case 'M':
if (flags & ESCAPE_META) goto eof;
- if ((c = nextc(p)) != '-') {
+ if ((c = nextc()) != '-') {
goto eof;
}
- if ((c = nextc(p)) == '\\') {
- if (peek(p, 'u')) goto eof;
- return read_escape(p, flags|ESCAPE_META, encp) | 0x80;
+ if ((c = nextc()) == '\\') {
+ if (peek('u')) goto eof;
+ return read_escape(flags|ESCAPE_META, encp) | 0x80;
}
else if (c == -1 || !ISASCII(c)) goto eof;
else {
- int c2 = escaped_control_code(c);
- if (c2) {
- if (ISCNTRL(c) || !(flags & ESCAPE_CONTROL)) {
- WARN_SPACE_CHAR(c2, "\\M-");
- }
- else {
- WARN_SPACE_CHAR(c2, "\\C-\\M-");
- }
- }
- else if (ISCNTRL(c)) goto eof;
return ((c & 0xff) | 0x80);
}
case 'C':
- if ((c = nextc(p)) != '-') {
+ if ((c = nextc()) != '-') {
goto eof;
}
case 'c':
if (flags & ESCAPE_CONTROL) goto eof;
- if ((c = nextc(p))== '\\') {
- if (peek(p, 'u')) goto eof;
- c = read_escape(p, flags|ESCAPE_CONTROL, encp);
+ if ((c = nextc())== '\\') {
+ if (peek('u')) goto eof;
+ c = read_escape(flags|ESCAPE_CONTROL, encp);
}
else if (c == '?')
return 0177;
else if (c == -1 || !ISASCII(c)) goto eof;
- else {
- int c2 = escaped_control_code(c);
- if (c2) {
- if (ISCNTRL(c)) {
- if (flags & ESCAPE_META) {
- WARN_SPACE_CHAR(c2, "\\M-");
- }
- else {
- WARN_SPACE_CHAR(c2, "");
- }
- }
- else {
- if (flags & ESCAPE_META) {
- WARN_SPACE_CHAR(c2, "\\M-\\C-");
- }
- else {
- WARN_SPACE_CHAR(c2, "\\C-");
- }
- }
- }
- else if (ISCNTRL(c)) goto eof;
- }
return c & 0x9f;
eof:
case -1:
yyerror0("Invalid escape character syntax");
- token_flush(p);
+ pushback(c);
return '\0';
default:
@@ -6656,96 +6158,95 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
}
static void
-tokaddmbc(struct parser_params *p, int c, rb_encoding *enc)
+parser_tokaddmbc(struct parser_params *parser, int c, rb_encoding *enc)
{
int len = rb_enc_codelen(c, enc);
- rb_enc_mbcput(c, tokspace(p, len), enc);
+ rb_enc_mbcput(c, tokspace(len), enc);
}
static int
-tokadd_escape(struct parser_params *p, rb_encoding **encp)
+parser_tokadd_escape(struct parser_params *parser, rb_encoding **encp)
{
int c;
int flags = 0;
size_t numlen;
first:
- switch (c = nextc(p)) {
+ switch (c = nextc()) {
case '\n':
return 0; /* just ignore */
case '0': case '1': case '2': case '3': /* octal constant */
case '4': case '5': case '6': case '7':
{
- ruby_scan_oct(--p->lex.pcur, 3, &numlen);
+ ruby_scan_oct(--lex_p, 3, &numlen);
if (numlen == 0) goto eof;
- p->lex.pcur += numlen;
- tokcopy(p, (int)numlen + 1);
+ lex_p += numlen;
+ tokcopy((int)numlen + 1);
}
return 0;
case 'x': /* hex constant */
{
- tok_hex(p, &numlen);
+ tok_hex(&numlen);
if (numlen == 0) return -1;
- tokcopy(p, (int)numlen + 2);
+ tokcopy((int)numlen + 2);
}
return 0;
case 'M':
if (flags & ESCAPE_META) goto eof;
- if ((c = nextc(p)) != '-') {
- pushback(p, c);
+ if ((c = nextc()) != '-') {
+ pushback(c);
goto eof;
}
- tokcopy(p, 3);
+ tokcopy(3);
flags |= ESCAPE_META;
goto escaped;
case 'C':
if (flags & ESCAPE_CONTROL) goto eof;
- if ((c = nextc(p)) != '-') {
- pushback(p, c);
+ if ((c = nextc()) != '-') {
+ pushback(c);
goto eof;
}
- tokcopy(p, 3);
+ tokcopy(3);
goto escaped;
case 'c':
if (flags & ESCAPE_CONTROL) goto eof;
- tokcopy(p, 2);
+ tokcopy(2);
flags |= ESCAPE_CONTROL;
escaped:
- if ((c = nextc(p)) == '\\') {
+ if ((c = nextc()) == '\\') {
goto first;
}
else if (c == -1) goto eof;
- tokadd(p, c);
+ tokadd(c);
return 0;
eof:
case -1:
yyerror0("Invalid escape character syntax");
- token_flush(p);
return -1;
default:
- tokadd(p, '\\');
- tokadd(p, c);
+ tokadd('\\');
+ tokadd(c);
}
return 0;
}
static int
-regx_options(struct parser_params *p)
+parser_regx_options(struct parser_params *parser)
{
int kcode = 0;
int kopt = 0;
int options = 0;
int c, opt, kc;
- newtok(p);
- while (c = nextc(p), ISALPHA(c)) {
+ newtok();
+ while (c = nextc(), ISALPHA(c)) {
if (c == 'o') {
options |= RE_OPTION_ONCE;
}
@@ -6759,32 +6260,40 @@ regx_options(struct parser_params *p)
}
}
else {
- tokadd(p, c);
+ tokadd(c);
}
}
options |= kopt;
- pushback(p, c);
- if (toklen(p)) {
- YYLTYPE loc = RUBY_INIT_YYLLOC();
- tokfix(p);
- compile_error(p, "unknown regexp option%s - %*s",
- toklen(p) > 1 ? "s" : "", toklen(p), tok(p));
- parser_show_error_line(p, &loc);
+ pushback(c);
+ if (toklen()) {
+ tokfix();
+ compile_error(PARSER_ARG "unknown regexp option%s - %s",
+ toklen() > 1 ? "s" : "", tok());
}
return options | RE_OPTION_ENCODING(kcode);
}
+static void
+dispose_string(struct parser_params *parser, VALUE str)
+{
+ rb_ast_delete_mark_object(parser->ast, str);
+ rb_str_free(str);
+ rb_gc_force_recycle(str);
+}
+
static int
-tokadd_mbchar(struct parser_params *p, int c)
+parser_tokadd_mbchar(struct parser_params *parser, int c)
{
- int len = parser_precise_mbclen(p, p->lex.pcur-1);
+ int len = parser_precise_mbclen(parser, lex_p-1);
if (len < 0) return -1;
- tokadd(p, c);
- p->lex.pcur += --len;
- if (len > 0) tokcopy(p, len);
+ tokadd(c);
+ lex_p += --len;
+ if (len > 0) tokcopy(len);
return c;
}
+#define tokadd_mbchar(c) parser_tokadd_mbchar(parser, (c))
+
static inline int
simple_re_meta(int c)
{
@@ -6799,38 +6308,40 @@ simple_re_meta(int c)
}
static int
-parser_update_heredoc_indent(struct parser_params *p, int c)
+parser_update_heredoc_indent(struct parser_params *parser, int c)
{
- if (p->heredoc_line_indent == -1) {
- if (c == '\n') p->heredoc_line_indent = 0;
+ if (heredoc_line_indent == -1) {
+ if (c == '\n') heredoc_line_indent = 0;
}
else {
if (c == ' ') {
- p->heredoc_line_indent++;
+ heredoc_line_indent++;
return TRUE;
}
else if (c == '\t') {
- int w = (p->heredoc_line_indent / TAB_WIDTH) + 1;
- p->heredoc_line_indent = w * TAB_WIDTH;
+ int w = (heredoc_line_indent / TAB_WIDTH) + 1;
+ heredoc_line_indent = w * TAB_WIDTH;
return TRUE;
}
else if (c != '\n') {
- if (p->heredoc_indent > p->heredoc_line_indent) {
- p->heredoc_indent = p->heredoc_line_indent;
+ if (heredoc_indent > heredoc_line_indent) {
+ heredoc_indent = heredoc_line_indent;
}
- p->heredoc_line_indent = -1;
+ heredoc_line_indent = -1;
}
}
return FALSE;
}
static void
-parser_mixed_error(struct parser_params *p, rb_encoding *enc1, rb_encoding *enc2)
+parser_mixed_error(struct parser_params *parser, rb_encoding *enc1, rb_encoding *enc2)
{
- YYLTYPE loc = RUBY_INIT_YYLLOC();
+ static const char mixed_msg[] = "%s mixed within %s source";
const char *n1 = rb_enc_name(enc1), *n2 = rb_enc_name(enc2);
- compile_error(p, "%s mixed within %s source", n1, n2);
- parser_show_error_line(p, &loc);
+ const size_t len = sizeof(mixed_msg) - 4 + strlen(n1) + strlen(n2);
+ char *errbuf = ALLOCA_N(char, len);
+ snprintf(errbuf, len, mixed_msg, n1, n2);
+ yyerror0(errbuf);
}
static void
@@ -6843,21 +6354,21 @@ parser_mixed_escape(struct parser_params *p, const char *beg, rb_encoding *enc1,
}
static int
-tokadd_string(struct parser_params *p,
- int func, int term, int paren, long *nest,
- rb_encoding **encp, rb_encoding **enc)
+parser_tokadd_string(struct parser_params *parser,
+ int func, int term, int paren, long *nest,
+ rb_encoding **encp, rb_encoding **enc)
{
int c;
bool erred = false;
#define mixed_error(enc1, enc2) \
- (void)(erred || (parser_mixed_error(p, enc1, enc2), erred = true))
+ (void)(erred || (parser_mixed_error(parser, enc1, enc2), erred = true))
#define mixed_escape(beg, enc1, enc2) \
- (void)(erred || (parser_mixed_escape(p, beg, enc1, enc2), erred = true))
+ (void)(erred || (parser_mixed_escape(parser, beg, enc1, enc2), erred = true))
- while ((c = nextc(p)) != -1) {
- if (p->heredoc_indent > 0) {
- parser_update_heredoc_indent(p, c);
+ while ((c = nextc()) != -1) {
+ if (heredoc_indent > 0) {
+ parser_update_heredoc_indent(parser, c);
}
if (paren && c == paren) {
@@ -6865,84 +6376,86 @@ tokadd_string(struct parser_params *p,
}
else if (c == term) {
if (!nest || !*nest) {
- pushback(p, c);
+ pushback(c);
break;
}
--*nest;
}
- else if ((func & STR_FUNC_EXPAND) && c == '#' && p->lex.pcur < p->lex.pend) {
- int c2 = *p->lex.pcur;
+ else if ((func & STR_FUNC_EXPAND) && c == '#' && lex_p < lex_pend) {
+ int c2 = *lex_p;
if (c2 == '$' || c2 == '@' || c2 == '{') {
- pushback(p, c);
+ pushback(c);
break;
}
}
else if (c == '\\') {
- literal_flush(p, p->lex.pcur - 1);
- c = nextc(p);
+ literal_flush(lex_p - 1);
+ c = nextc();
switch (c) {
case '\n':
if (func & STR_FUNC_QWORDS) break;
if (func & STR_FUNC_EXPAND) {
- if (!(func & STR_FUNC_INDENT) || (p->heredoc_indent < 0))
+ if (!(func & STR_FUNC_INDENT) || (heredoc_indent < 0))
continue;
if (c == term) {
c = '\\';
goto terminate;
}
}
- tokadd(p, '\\');
+ tokadd('\\');
break;
case '\\':
- if (func & STR_FUNC_ESCAPE) tokadd(p, c);
+ if (func & STR_FUNC_ESCAPE) tokadd(c);
break;
case 'u':
if ((func & STR_FUNC_EXPAND) == 0) {
- tokadd(p, '\\');
+ tokadd('\\');
break;
}
- tokadd_utf8(p, enc, term,
- func & STR_FUNC_SYMBOL,
- func & STR_FUNC_REGEXP);
+ if (!parser_tokadd_utf8(parser, enc, term,
+ func & STR_FUNC_SYMBOL,
+ func & STR_FUNC_REGEXP)) {
+ return -1;
+ }
continue;
default:
if (c == -1) return -1;
if (!ISASCII(c)) {
- if ((func & STR_FUNC_EXPAND) == 0) tokadd(p, '\\');
+ if ((func & STR_FUNC_EXPAND) == 0) tokadd('\\');
goto non_ascii;
}
if (func & STR_FUNC_REGEXP) {
if (c == term && !simple_re_meta(c)) {
- tokadd(p, c);
+ tokadd(c);
continue;
}
- pushback(p, c);
- if ((c = tokadd_escape(p, enc)) < 0)
+ pushback(c);
+ if ((c = tokadd_escape(enc)) < 0)
return -1;
if (*enc && *enc != *encp) {
- mixed_escape(p->lex.ptok+2, *enc, *encp);
+ mixed_escape(parser->tokp+2, *enc, *encp);
}
continue;
}
else if (func & STR_FUNC_EXPAND) {
- pushback(p, c);
- if (func & STR_FUNC_ESCAPE) tokadd(p, '\\');
- c = read_escape(p, 0, enc);
+ pushback(c);
+ if (func & STR_FUNC_ESCAPE) tokadd('\\');
+ c = read_escape(0, enc);
}
else if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
/* ignore backslashed spaces in %w */
}
else if (c != term && !(paren && c == paren)) {
- tokadd(p, '\\');
- pushback(p, c);
+ tokadd('\\');
+ pushback(c);
continue;
}
}
}
- else if (!parser_isascii(p)) {
+ else if (!parser_isascii()) {
non_ascii:
if (!*enc) {
*enc = *encp;
@@ -6951,11 +6464,11 @@ tokadd_string(struct parser_params *p,
mixed_error(*enc, *encp);
continue;
}
- if (tokadd_mbchar(p, c) == -1) return -1;
+ if (tokadd_mbchar(c) == -1) return -1;
continue;
}
else if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
- pushback(p, c);
+ pushback(c);
break;
}
if (c & 0x80) {
@@ -6967,46 +6480,42 @@ tokadd_string(struct parser_params *p,
continue;
}
}
- tokadd(p, c);
+ tokadd(c);
}
terminate:
if (*enc) *encp = *enc;
return c;
}
-static inline rb_strterm_t *
-new_strterm(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
-{
- return (rb_strterm_t*)rb_imemo_new(imemo_parser_strterm, v1, v2, v3, v0);
-}
-
/* imemo_parser_strterm for literal */
#define NEW_STRTERM(func, term, paren) \
- new_strterm((VALUE)(func), (VALUE)(paren), (VALUE)(term), 0)
+ (rb_strterm_t*)rb_imemo_new(imemo_parser_strterm, (VALUE)(func), (VALUE)(paren), (VALUE)(term), 0)
#ifdef RIPPER
static void
-flush_string_content(struct parser_params *p, rb_encoding *enc)
+token_flush_string_content(struct parser_params *parser, rb_encoding *enc)
{
VALUE content = yylval.val;
if (!ripper_is_node_yylval(content))
- content = ripper_new_yylval(p, 0, 0, content);
- if (has_delayed_token(p)) {
- ptrdiff_t len = p->lex.pcur - p->lex.ptok;
+ content = ripper_new_yylval(0, 0, content);
+ if (has_delayed_token()) {
+ ptrdiff_t len = lex_p - parser->tokp;
if (len > 0) {
- rb_enc_str_buf_cat(p->delayed.token, p->lex.ptok, len, enc);
+ rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc);
}
- dispatch_delayed_token(p, tSTRING_CONTENT);
- p->lex.ptok = p->lex.pcur;
+ dispatch_delayed_token(tSTRING_CONTENT);
+ parser->tokp = lex_p;
RNODE(content)->nd_rval = yylval.val;
}
- dispatch_scan_event(p, tSTRING_CONTENT);
+ dispatch_scan_event(tSTRING_CONTENT);
if (yylval.val != content)
RNODE(content)->nd_rval = yylval.val;
yylval.val = content;
}
+
+#define flush_string_content(enc) token_flush_string_content(parser, (enc))
#else
-#define flush_string_content(p, enc) ((void)(enc))
+#define flush_string_content(enc) ((void)(enc))
#endif
RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e - 0x20 + 31) / 32];
@@ -7031,32 +6540,32 @@ const unsigned int ruby_global_name_punct_bits[] = {
#endif
static enum yytokentype
-parser_peek_variable_name(struct parser_params *p)
+parser_peek_variable_name(struct parser_params *parser)
{
int c;
- const char *ptr = p->lex.pcur;
+ const char *p = lex_p;
- if (ptr + 1 >= p->lex.pend) return 0;
- c = *ptr++;
+ if (p + 1 >= lex_pend) return 0;
+ c = *p++;
switch (c) {
case '$':
- if ((c = *ptr) == '-') {
- if (++ptr >= p->lex.pend) return 0;
- c = *ptr;
+ if ((c = *p) == '-') {
+ if (++p >= lex_pend) return 0;
+ c = *p;
}
else if (is_global_name_punct(c) || ISDIGIT(c)) {
return tSTRING_DVAR;
}
break;
case '@':
- if ((c = *ptr) == '@') {
- if (++ptr >= p->lex.pend) return 0;
- c = *ptr;
+ if ((c = *p) == '@') {
+ if (++p >= lex_pend) return 0;
+ c = *p;
}
break;
case '{':
- p->lex.pcur = ptr;
- p->command_start = TRUE;
+ lex_p = p;
+ command_start = TRUE;
return tSTRING_DBEG;
default:
return 0;
@@ -7073,48 +6582,48 @@ parser_peek_variable_name(struct parser_params *p)
#define IS_LABEL_POSSIBLE() (\
(IS_lex_state(EXPR_LABEL|EXPR_ENDFN) && !cmd_state) || \
IS_ARG())
-#define IS_LABEL_SUFFIX(n) (peek_n(p, ':',(n)) && !peek_n(p, ':', (n)+1))
+#define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1))
#define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT)
static inline enum yytokentype
-parser_string_term(struct parser_params *p, int func)
+parser_string_term(struct parser_params *parser, int func)
{
- p->lex.strterm = 0;
+ lex_strterm = 0;
if (func & STR_FUNC_REGEXP) {
- set_yylval_num(regx_options(p));
- dispatch_scan_event(p, tREGEXP_END);
- SET_LEX_STATE(EXPR_END);
+ set_yylval_num(regx_options());
+ dispatch_scan_event(tREGEXP_END);
+ SET_LEX_STATE(EXPR_END|EXPR_ENDARG);
return tREGEXP_END;
}
if ((func & STR_FUNC_LABEL) && IS_LABEL_SUFFIX(0)) {
- nextc(p);
+ nextc();
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
return tLABEL_END;
}
- SET_LEX_STATE(EXPR_END);
+ SET_LEX_STATE(EXPR_END|EXPR_ENDARG);
return tSTRING_END;
}
static enum yytokentype
-parse_string(struct parser_params *p, rb_strterm_literal_t *quote)
+parser_parse_string(struct parser_params *parser, rb_strterm_literal_t *quote)
{
int func = (int)quote->u1.func;
int term = (int)quote->u3.term;
int paren = (int)quote->u2.paren;
int c, space = 0;
- rb_encoding *enc = p->enc;
+ rb_encoding *enc = current_enc;
rb_encoding *base_enc = 0;
VALUE lit;
if (func & STR_FUNC_TERM) {
- if (func & STR_FUNC_QWORDS) nextc(p); /* delayed term */
- SET_LEX_STATE(EXPR_END);
- p->lex.strterm = 0;
+ if (func & STR_FUNC_QWORDS) nextc(); /* delayed term */
+ SET_LEX_STATE(EXPR_END|EXPR_ENDARG);
+ lex_strterm = 0;
return func & STR_FUNC_REGEXP ? tREGEXP_END : tSTRING_END;
}
- c = nextc(p);
+ c = nextc();
if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
- do {c = nextc(p);} while (ISSPACE(c));
+ do {c = nextc();} while (ISSPACE(c));
space = 1;
}
if (func & STR_FUNC_LIST) {
@@ -7124,40 +6633,34 @@ parse_string(struct parser_params *p, rb_strterm_literal_t *quote)
if (c == term && !quote->u0.nest) {
if (func & STR_FUNC_QWORDS) {
quote->u1.func |= STR_FUNC_TERM;
- pushback(p, c); /* dispatch the term at tSTRING_END */
- add_delayed_token(p, p->lex.ptok, p->lex.pcur);
+ pushback(c); /* dispatch the term at tSTRING_END */
+ add_delayed_token(parser->tokp, lex_p);
return ' ';
}
- return parser_string_term(p, func);
+ return parser_string_term(parser, func);
}
if (space) {
- pushback(p, c);
- add_delayed_token(p, p->lex.ptok, p->lex.pcur);
+ pushback(c);
+ add_delayed_token(parser->tokp, lex_p);
return ' ';
}
- newtok(p);
+ newtok();
if ((func & STR_FUNC_EXPAND) && c == '#') {
- int t = parser_peek_variable_name(p);
+ int t = parser_peek_variable_name(parser);
if (t) return t;
- tokadd(p, '#');
- c = nextc(p);
+ tokadd('#');
+ c = nextc();
}
- pushback(p, c);
- if (tokadd_string(p, func, term, paren, &quote->u0.nest,
+ pushback(c);
+ if (tokadd_string(func, term, paren, &quote->u0.nest,
&enc, &base_enc) == -1) {
- if (p->eofp) {
+ if (parser->eofp) {
#ifndef RIPPER
# define unterminated_literal(mesg) yyerror0(mesg)
#else
-# define unterminated_literal(mesg) compile_error(p, mesg)
+# define unterminated_literal(mesg) compile_error(PARSER_ARG mesg)
#endif
- literal_flush(p, p->lex.pcur);
- if (func & STR_FUNC_QWORDS) {
- /* no content to add, bailing out here */
- unterminated_literal("unterminated list meets end of file");
- p->lex.strterm = 0;
- return tSTRING_END;
- }
+ literal_flush(lex_p);
if (func & STR_FUNC_REGEXP) {
unterminated_literal("unterminated regexp meets end of file");
}
@@ -7168,114 +6671,123 @@ parse_string(struct parser_params *p, rb_strterm_literal_t *quote)
}
}
- tokfix(p);
- lit = STR_NEW3(tok(p), toklen(p), enc, func);
+ tokfix();
+ add_mark_object(lit = STR_NEW3(tok(), toklen(), enc, func));
set_yylval_str(lit);
- flush_string_content(p, enc);
+ flush_string_content(enc);
return tSTRING_CONTENT;
}
static enum yytokentype
-heredoc_identifier(struct parser_params *p)
+parser_heredoc_identifier(struct parser_params *parser)
{
- /*
- * term_len is length of `<<"END"` except `END`,
- * in this case term_len is 4 (<, <, " and ").
- */
- long len, offset = p->lex.pcur - p->lex.pbeg;
- int c = nextc(p), term, func = 0, quote = 0;
+ int c = nextc(), term, func = 0, term_len = 2; /* length of "<<" */
enum yytokentype token = tSTRING_BEG;
+ long len;
+ int newline = 0;
int indent = 0;
if (c == '-') {
- c = nextc(p);
+ c = nextc();
+ term_len++;
func = STR_FUNC_INDENT;
- offset++;
}
else if (c == '~') {
- c = nextc(p);
+ c = nextc();
+ term_len++;
func = STR_FUNC_INDENT;
- offset++;
indent = INT_MAX;
}
switch (c) {
case '\'':
+ term_len++;
func |= str_squote; goto quoted;
case '"':
+ term_len++;
func |= str_dquote; goto quoted;
case '`':
+ term_len++;
token = tXSTRING_BEG;
func |= str_xquote; goto quoted;
quoted:
- quote++;
- offset++;
+ term_len++;
+ newtok();
+ tokadd(term_len);
+ tokadd(func);
term = c;
- len = 0;
- while ((c = nextc(p)) != term) {
- if (c == -1 || c == '\r' || c == '\n') {
- yyerror(NULL, p, "unterminated here document identifier");
- return -1;
- }
+ while ((c = nextc()) != -1 && c != term) {
+ if (tokadd_mbchar(c) == -1) return 0;
+ if (!newline && c == '\n') newline = 1;
+ else if (newline) newline = 2;
+ }
+ if (c == -1) {
+ compile_error(PARSER_ARG "unterminated here document identifier");
+ return 0;
+ }
+ switch (newline) {
+ case 1:
+ rb_warn0("here document identifier ends with a newline");
+ if (--tokidx > 0 && tokenbuf[tokidx] == '\r') --tokidx;
+ break;
+ case 2:
+ compile_error(PARSER_ARG "here document identifier across newlines, never match");
+ return -1;
}
break;
default:
- if (!parser_is_identchar(p)) {
- pushback(p, c);
+ if (!parser_is_identchar()) {
+ pushback(c);
if (func & STR_FUNC_INDENT) {
- pushback(p, indent > 0 ? '~' : '-');
+ pushback(indent > 0 ? '~' : '-');
}
return 0;
}
- func |= str_dquote;
+ newtok();
+ tokadd(term_len);
+ tokadd(func |= str_dquote);
do {
- int n = parser_precise_mbclen(p, p->lex.pcur-1);
- if (n < 0) return 0;
- p->lex.pcur += --n;
- } while ((c = nextc(p)) != -1 && parser_is_identchar(p));
- pushback(p, c);
+ if (tokadd_mbchar(c) == -1) return 0;
+ } while ((c = nextc()) != -1 && parser_is_identchar());
+ pushback(c);
break;
}
- len = p->lex.pcur - (p->lex.pbeg + offset) - quote;
- if ((unsigned long)len >= HERETERM_LENGTH_MAX)
- yyerror(NULL, p, "too long here document identifier");
- dispatch_scan_event(p, tHEREDOC_BEG);
- lex_goto_eol(p);
-
- p->lex.strterm = new_strterm(0, 0, 0, p->lex.lastline);
- p->lex.strterm->flags |= STRTERM_HEREDOC;
- rb_strterm_heredoc_t *here = &p->lex.strterm->u.heredoc;
- here->offset = offset;
- here->sourceline = p->ruby_sourceline;
- here->length = (int)len;
- here->quote = quote;
- here->func = func;
-
- token_flush(p);
- p->heredoc_indent = indent;
- p->heredoc_line_indent = 0;
+ tokenbuf[0] = tokenbuf[0] + toklen() - 2;
+ tokfix();
+ dispatch_scan_event(tHEREDOC_BEG);
+ len = lex_p - lex_pbeg;
+ lex_goto_eol(parser);
+
+ lex_strterm = (rb_strterm_t*)rb_imemo_new(imemo_parser_strterm,
+ STR_NEW(tok(), toklen()), /* term */
+ lex_lastline, /* lastline */
+ len, /* lastidx */
+ ruby_sourceline);
+ lex_strterm->flags |= STRTERM_HEREDOC;
+
+ token_flush(parser);
+ heredoc_indent = indent;
+ heredoc_line_indent = 0;
return token;
}
static void
-heredoc_restore(struct parser_params *p, rb_strterm_heredoc_t *here)
+parser_heredoc_restore(struct parser_params *parser, rb_strterm_heredoc_t *here)
{
VALUE line;
- p->lex.strterm = 0;
+ lex_strterm = 0;
line = here->lastline;
- p->lex.lastline = line;
- p->lex.pbeg = RSTRING_PTR(line);
- p->lex.pend = p->lex.pbeg + RSTRING_LEN(line);
- p->lex.pcur = p->lex.pbeg + here->offset + here->length + here->quote;
- p->lex.ptok = p->lex.pbeg + here->offset - here->quote;
- p->heredoc_end = p->ruby_sourceline;
- p->ruby_sourceline = (int)here->sourceline;
- if (p->eofp) p->lex.nextline = Qnil;
- p->eofp = 0;
+ lex_lastline = line;
+ lex_pbeg = RSTRING_PTR(line);
+ lex_pend = lex_pbeg + RSTRING_LEN(line);
+ lex_p = lex_pbeg + here->u3.lastidx;
+ heredoc_end = ruby_sourceline;
+ ruby_sourceline = (int)here->sourceline;
+ token_flush(parser);
}
static int
@@ -7311,50 +6823,29 @@ dedent_string(VALUE string, int width)
#ifndef RIPPER
static NODE *
-heredoc_dedent(struct parser_params *p, NODE *root)
+parser_heredoc_dedent(struct parser_params *parser, NODE *root)
{
- NODE *node, *str_node, *prev_node;
- int indent = p->heredoc_indent;
- VALUE prev_lit = 0;
+ NODE *node, *str_node;
+ int indent = heredoc_indent;
if (indent <= 0) return root;
- p->heredoc_indent = 0;
+ heredoc_indent = 0;
if (!root) return root;
- prev_node = node = str_node = root;
- if (nd_type(root) == NODE_LIST) str_node = root->nd_head;
+ node = str_node = root;
+ if (nd_type(root) == NODE_ARRAY) str_node = root->nd_head;
while (str_node) {
VALUE lit = str_node->nd_lit;
if (str_node->flags & NODE_FL_NEWLINE) {
dedent_string(lit, indent);
}
- if (!prev_lit) {
- prev_lit = lit;
- }
- else if (!literal_concat0(p, prev_lit, lit)) {
- return 0;
- }
- else {
- NODE *end = node->nd_end;
- node = prev_node->nd_next = node->nd_next;
- if (!node) {
- if (nd_type(prev_node) == NODE_DSTR)
- nd_set_type(prev_node, NODE_STR);
- break;
- }
- node->nd_end = end;
- goto next_str;
- }
str_node = 0;
- while ((node = (prev_node = node)->nd_next) != 0) {
- next_str:
- if (nd_type(node) != NODE_LIST) break;
+ while ((node = node->nd_next) != 0 && nd_type(node) == NODE_ARRAY) {
if ((str_node = node->nd_head) != 0) {
enum node_type type = nd_type(str_node);
if (type == NODE_STR || type == NODE_DSTR) break;
- prev_lit = 0;
str_node = 0;
}
}
@@ -7363,25 +6854,16 @@ heredoc_dedent(struct parser_params *p, NODE *root)
}
#else /* RIPPER */
static VALUE
-heredoc_dedent(struct parser_params *p, VALUE array)
+parser_heredoc_dedent(struct parser_params *parser, VALUE array)
{
- int indent = p->heredoc_indent;
+ int indent = heredoc_indent;
if (indent <= 0) return array;
- p->heredoc_indent = 0;
+ heredoc_indent = 0;
dispatch2(heredoc_dedent, array, INT2NUM(indent));
return array;
}
-/*
- * call-seq:
- * Ripper.dedent_string(input, width) -> Integer
- *
- * USE OF RIPPER LIBRARY ONLY.
- *
- * Strips up to +width+ leading whitespaces from +input+,
- * and returns the stripped column width.
- */
static VALUE
parser_dedent_string(VALUE self, VALUE input, VALUE width)
{
@@ -7395,34 +6877,22 @@ parser_dedent_string(VALUE self, VALUE input, VALUE width)
#endif
static int
-whole_match_p(struct parser_params *p, const char *eos, long len, int indent)
+parser_whole_match_p(struct parser_params *parser,
+ const char *eos, long len, int indent)
{
- const char *ptr = p->lex.pbeg;
+ const char *p = lex_pbeg;
long n;
if (indent) {
- while (*ptr && ISSPACE(*ptr)) ptr++;
+ while (*p && ISSPACE(*p)) p++;
}
- n = p->lex.pend - (ptr + len);
+ n = lex_pend - (p + len);
if (n < 0) return FALSE;
- if (n > 0 && ptr[len] != '\n') {
- if (ptr[len] != '\r') return FALSE;
- if (n <= 1 || ptr[len+1] != '\n') return FALSE;
+ if (n > 0 && p[len] != '\n') {
+ if (p[len] != '\r') return FALSE;
+ if (n <= 1 || p[len+1] != '\n') return FALSE;
}
- return strncmp(eos, ptr, len) == 0;
-}
-
-static int
-word_match_p(struct parser_params *p, const char *word, long len)
-{
- if (strncmp(p->lex.pcur, word, len)) return 0;
- if (p->lex.pcur + len == p->lex.pend) return 1;
- int c = (unsigned char)p->lex.pcur[len];
- if (ISSPACE(c)) return 1;
- switch (c) {
- case '\0': case '\004': case '\032': return 1;
- }
- return 0;
+ return strncmp(eos, p, len) == 0;
}
#define NUM_SUFFIX_R (1<<0)
@@ -7430,12 +6900,12 @@ word_match_p(struct parser_params *p, const char *word, long len)
#define NUM_SUFFIX_ALL 3
static int
-number_literal_suffix(struct parser_params *p, int mask)
+parser_number_literal_suffix(struct parser_params *parser, int mask)
{
int c, result = 0;
- const char *lastp = p->lex.pcur;
+ const char *lastp = lex_p;
- while ((c = nextc(p)) != -1) {
+ while ((c = nextc()) != -1) {
if ((mask & NUM_SUFFIX_I) && c == 'i') {
result |= (mask & NUM_SUFFIX_I);
mask &= ~NUM_SUFFIX_I;
@@ -7449,217 +6919,225 @@ number_literal_suffix(struct parser_params *p, int mask)
continue;
}
if (!ISASCII(c) || ISALPHA(c) || c == '_') {
- p->lex.pcur = lastp;
- literal_flush(p, p->lex.pcur);
+ lex_p = lastp;
+ literal_flush(lex_p);
return 0;
}
- pushback(p, c);
+ pushback(c);
+ if (c == '.') {
+ c = peekc_n(1);
+ if (ISDIGIT(c)) {
+ yyerror0("unexpected fraction part after numeric literal");
+ lex_p += 2;
+ while (parser_is_identchar()) nextc();
+ }
+ }
break;
}
return result;
}
static enum yytokentype
-set_number_literal(struct parser_params *p, VALUE v,
- enum yytokentype type, int suffix)
+parser_set_number_literal(struct parser_params *parser, VALUE v,
+ enum yytokentype type, int suffix)
{
if (suffix & NUM_SUFFIX_I) {
v = rb_complex_raw(INT2FIX(0), v);
type = tIMAGINARY;
}
set_yylval_literal(v);
- SET_LEX_STATE(EXPR_END);
+ add_mark_object(v);
+ SET_LEX_STATE(EXPR_END|EXPR_ENDARG);
return type;
}
-static enum yytokentype
-set_integer_literal(struct parser_params *p, VALUE v, int suffix)
+static int
+parser_set_integer_literal(struct parser_params *parser, VALUE v, int suffix)
{
enum yytokentype type = tINTEGER;
if (suffix & NUM_SUFFIX_R) {
v = rb_rational_raw1(v);
type = tRATIONAL;
}
- return set_number_literal(p, v, type, suffix);
+ return set_number_literal(v, type, suffix);
}
#ifdef RIPPER
static void
-dispatch_heredoc_end(struct parser_params *p)
+ripper_dispatch_heredoc_end(struct parser_params *parser)
{
VALUE str;
- if (has_delayed_token(p))
- dispatch_delayed_token(p, tSTRING_CONTENT);
- str = STR_NEW(p->lex.ptok, p->lex.pend - p->lex.ptok);
- ripper_dispatch1(p, ripper_token2eventid(tHEREDOC_END), str);
- lex_goto_eol(p);
- token_flush(p);
+ if (has_delayed_token())
+ dispatch_delayed_token(tSTRING_CONTENT);
+ str = STR_NEW(parser->tokp, lex_pend - parser->tokp);
+ ripper_dispatch1(parser, ripper_token2eventid(tHEREDOC_END), str);
+ lex_goto_eol(parser);
+ token_flush(parser);
}
+#define dispatch_heredoc_end() ripper_dispatch_heredoc_end(parser)
#else
-#define dispatch_heredoc_end(p) ((void)0)
+#define dispatch_heredoc_end() ((void)0)
#endif
static enum yytokentype
-here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
+parser_here_document(struct parser_params *parser, rb_strterm_heredoc_t *here)
{
int c, func, indent = 0;
- const char *eos, *ptr, *ptr_end;
+ const char *eos, *p, *pend;
long len;
VALUE str = 0;
- rb_encoding *enc = p->enc;
+ rb_encoding *enc = current_enc;
rb_encoding *base_enc = 0;
int bol;
- eos = RSTRING_PTR(here->lastline) + here->offset;
- len = here->length;
- indent = (func = here->func) & STR_FUNC_INDENT;
+ eos = RSTRING_PTR(here->term);
+ len = RSTRING_LEN(here->term) - 2; /* here->term includes term_len and func */
+ eos++; /* skip term_len */
+ indent = (func = *eos++) & STR_FUNC_INDENT;
- if ((c = nextc(p)) == -1) {
+ if ((c = nextc()) == -1) {
error:
+ compile_error(PARSER_ARG "can't find string \"%s\" anywhere before EOF", eos);
#ifdef RIPPER
- if (!has_delayed_token(p)) {
- dispatch_scan_event(p, tSTRING_CONTENT);
+ if (!has_delayed_token()) {
+ dispatch_scan_event(tSTRING_CONTENT);
}
else {
- if ((len = p->lex.pcur - p->lex.ptok) > 0) {
+ if (str) {
+ rb_str_append(parser->delayed, str);
+ }
+ else if ((len = lex_p - parser->tokp) > 0) {
if (!(func & STR_FUNC_REGEXP) && rb_enc_asciicompat(enc)) {
int cr = ENC_CODERANGE_UNKNOWN;
- rb_str_coderange_scan_restartable(p->lex.ptok, p->lex.pcur, enc, &cr);
+ rb_str_coderange_scan_restartable(parser->tokp, lex_p, enc, &cr);
if (cr != ENC_CODERANGE_7BIT &&
- p->enc == rb_usascii_encoding() &&
+ current_enc == rb_usascii_encoding() &&
enc != rb_utf8_encoding()) {
enc = rb_ascii8bit_encoding();
}
}
- rb_enc_str_buf_cat(p->delayed.token, p->lex.ptok, len, enc);
+ rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc);
}
- dispatch_delayed_token(p, tSTRING_CONTENT);
+ dispatch_delayed_token(tSTRING_CONTENT);
}
- lex_goto_eol(p);
+ lex_goto_eol(parser);
#endif
- heredoc_restore(p, &p->lex.strterm->u.heredoc);
- compile_error(p, "can't find string \"%.*s\" anywhere before EOF",
- (int)len, eos);
- token_flush(p);
- p->lex.strterm = 0;
- SET_LEX_STATE(EXPR_END);
- return tSTRING_END;
- }
- bol = was_bol(p);
- if (!bol) {
- /* not beginning of line, cannot be the terminator */
- }
- else if (p->heredoc_line_indent == -1) {
- /* `heredoc_line_indent == -1` means
- * - "after an interpolation in the same line", or
- * - "in a continuing line"
- */
- p->heredoc_line_indent = 0;
- }
- else if (whole_match_p(p, eos, len, indent)) {
- dispatch_heredoc_end(p);
restore:
- heredoc_restore(p, &p->lex.strterm->u.heredoc);
- token_flush(p);
- p->lex.strterm = 0;
+ heredoc_restore(&lex_strterm->u.heredoc);
+ lex_strterm = 0;
+ return 0;
+ }
+ bol = was_bol();
+ /* `heredoc_line_indent == -1` means
+ * - "after an interpolation in the same line", or
+ * - "in a continuing line"
+ */
+ if (bol &&
+ (heredoc_line_indent != -1 || (heredoc_line_indent = 0)) &&
+ whole_match_p(eos, len, indent)) {
+ dispatch_heredoc_end();
+ heredoc_restore(&lex_strterm->u.heredoc);
+ lex_strterm = 0;
SET_LEX_STATE(EXPR_END);
return tSTRING_END;
}
if (!(func & STR_FUNC_EXPAND)) {
do {
- ptr = RSTRING_PTR(p->lex.lastline);
- ptr_end = p->lex.pend;
- if (ptr_end > ptr) {
- switch (ptr_end[-1]) {
+ p = RSTRING_PTR(lex_lastline);
+ pend = lex_pend;
+ if (pend > p) {
+ switch (pend[-1]) {
case '\n':
- if (--ptr_end == ptr || ptr_end[-1] != '\r') {
- ptr_end++;
+ if (--pend == p || pend[-1] != '\r') {
+ pend++;
break;
}
case '\r':
- --ptr_end;
+ --pend;
}
}
- if (p->heredoc_indent > 0) {
+ if (heredoc_indent > 0) {
long i = 0;
- while (ptr + i < ptr_end && parser_update_heredoc_indent(p, ptr[i]))
+ while (p + i < pend && parser_update_heredoc_indent(parser, p[i]))
i++;
- p->heredoc_line_indent = 0;
+ heredoc_line_indent = 0;
}
if (str)
- rb_str_cat(str, ptr, ptr_end - ptr);
+ rb_str_cat(str, p, pend - p);
else
- str = STR_NEW(ptr, ptr_end - ptr);
- if (ptr_end < p->lex.pend) rb_str_cat(str, "\n", 1);
- lex_goto_eol(p);
- if (p->heredoc_indent > 0) {
+ str = STR_NEW(p, pend - p);
+ if (pend < lex_pend) rb_str_cat(str, "\n", 1);
+ lex_goto_eol(parser);
+ if (heredoc_indent > 0) {
goto flush_str;
}
- if (nextc(p) == -1) {
+ if (nextc() == -1) {
if (str) {
+ dispose_string(parser, str);
str = 0;
}
goto error;
}
- } while (!whole_match_p(p, eos, len, indent));
+ } while (!whole_match_p(eos, len, indent));
}
else {
/* int mb = ENC_CODERANGE_7BIT, *mbp = &mb;*/
- newtok(p);
+ newtok();
if (c == '#') {
- int t = parser_peek_variable_name(p);
- if (p->heredoc_line_indent != -1) {
- if (p->heredoc_indent > p->heredoc_line_indent) {
- p->heredoc_indent = p->heredoc_line_indent;
+ int t = parser_peek_variable_name(parser);
+ if (heredoc_line_indent != -1) {
+ if (heredoc_indent > heredoc_line_indent) {
+ heredoc_indent = heredoc_line_indent;
}
- p->heredoc_line_indent = -1;
+ heredoc_line_indent = -1;
}
if (t) return t;
- tokadd(p, '#');
- c = nextc(p);
+ tokadd('#');
+ c = nextc();
}
do {
- pushback(p, c);
- enc = p->enc;
- if ((c = tokadd_string(p, func, '\n', 0, NULL, &enc, &base_enc)) == -1) {
- if (p->eofp) goto error;
+ pushback(c);
+ enc = current_enc;
+ if ((c = tokadd_string(func, '\n', 0, NULL, &enc, &base_enc)) == -1) {
+ if (parser->eofp) goto error;
goto restore;
}
if (c != '\n') {
- if (c == '\\') p->heredoc_line_indent = -1;
+ if (c == '\\') heredoc_line_indent = -1;
flush:
- str = STR_NEW3(tok(p), toklen(p), enc, func);
+ str = STR_NEW3(tok(), toklen(), enc, func);
flush_str:
set_yylval_str(str);
+ add_mark_object(str);
#ifndef RIPPER
if (bol) yylval.node->flags |= NODE_FL_NEWLINE;
#endif
- flush_string_content(p, enc);
+ flush_string_content(enc);
return tSTRING_CONTENT;
}
- tokadd(p, nextc(p));
- if (p->heredoc_indent > 0) {
- lex_goto_eol(p);
+ tokadd(nextc());
+ if (heredoc_indent > 0) {
+ lex_goto_eol(parser);
goto flush;
}
/* if (mbp && mb == ENC_CODERANGE_UNKNOWN) mbp = 0;*/
- if ((c = nextc(p)) == -1) goto error;
- } while (!whole_match_p(p, eos, len, indent));
- str = STR_NEW3(tok(p), toklen(p), enc, func);
+ if ((c = nextc()) == -1) goto error;
+ } while (!whole_match_p(eos, len, indent));
+ str = STR_NEW3(tok(), toklen(), enc, func);
}
- dispatch_heredoc_end(p);
+ dispatch_heredoc_end();
#ifdef RIPPER
- str = ripper_new_yylval(p, ripper_token2eventid(tSTRING_CONTENT),
+ str = ripper_new_yylval(ripper_token2eventid(tSTRING_CONTENT),
yylval.val, str);
#endif
- heredoc_restore(p, &p->lex.strterm->u.heredoc);
- token_flush(p);
- p->lex.strterm = NEW_STRTERM(func | STR_FUNC_TERM, 0, 0);
+ heredoc_restore(&lex_strterm->u.heredoc);
+ lex_strterm = NEW_STRTERM(func | STR_FUNC_TERM, 0, 0);
set_yylval_str(str);
+ add_mark_object(str);
#ifndef RIPPER
if (bol) yylval.node->flags |= NODE_FL_NEWLINE;
#endif
@@ -7668,19 +7146,19 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
#include "lex.c"
-static int
-arg_ambiguous(struct parser_params *p, char c)
+static void
+arg_ambiguous_gen(struct parser_params *parser, char c)
{
#ifndef RIPPER
rb_warning1("ambiguous first argument; put parentheses or a space even after `%c' operator", WARN_I(c));
#else
dispatch1(arg_ambiguous, rb_usascii_str_new(&c, 1));
#endif
- return TRUE;
}
+#define arg_ambiguous(c) (arg_ambiguous_gen(parser, (c)), 1)
static ID
-formal_argument(struct parser_params *p, ID lhs)
+formal_argument_gen(struct parser_params *parser, ID lhs)
{
switch (id_type(lhs)) {
case ID_LOCAL:
@@ -7704,23 +7182,23 @@ formal_argument(struct parser_params *p, ID lhs)
#else
default:
lhs = dispatch1(param_error, lhs);
- ripper_error(p);
+ ripper_error();
return 0;
#endif
}
- shadowing_lvar(p, lhs);
+ shadowing_lvar(lhs);
return lhs;
}
static int
-lvar_defined(struct parser_params *p, ID id)
+lvar_defined_gen(struct parser_params *parser, ID id)
{
- return (dyna_in_block(p) && dvar_defined(p, id)) || local_id(p, id);
+ return (dyna_in_block() && dvar_defined(id)) || local_id(id);
}
/* emacsen -*- hack */
static long
-parser_encode_length(struct parser_params *p, const char *name, long len)
+parser_encode_length(struct parser_params *parser, const char *name, long len)
{
long nlen;
@@ -7740,7 +7218,7 @@ parser_encode_length(struct parser_params *p, const char *name, long len)
}
static void
-parser_set_encode(struct parser_params *p, const char *name)
+parser_set_encode(struct parser_params *parser, const char *name)
{
int idx = rb_enc_find_index(name);
rb_encoding *enc;
@@ -7751,7 +7229,7 @@ parser_set_encode(struct parser_params *p, const char *name)
error:
excargs[0] = rb_eArgError;
excargs[2] = rb_make_backtrace();
- rb_ary_unshift(excargs[2], rb_sprintf("%"PRIsVALUE":%d", p->ruby_sourcefile_string, p->ruby_sourceline));
+ rb_ary_unshift(excargs[2], rb_sprintf("%"PRIsVALUE":%d", ruby_sourcefile_string, ruby_sourceline));
rb_exc_raise(rb_make_exception(3, excargs));
}
enc = rb_enc_from_index(idx);
@@ -7759,10 +7237,10 @@ parser_set_encode(struct parser_params *p, const char *name)
excargs[1] = rb_sprintf("%s is not ASCII compatible", rb_enc_name(enc));
goto error;
}
- p->enc = enc;
+ parser->enc = enc;
#ifndef RIPPER
- if (p->debug_lines) {
- VALUE lines = p->debug_lines;
+ if (ruby_debug_lines) {
+ VALUE lines = ruby_debug_lines;
long i, n = RARRAY_LEN(lines);
for (i = 0; i < n; ++i) {
rb_enc_associate_index(RARRAY_AREF(lines, i), idx);
@@ -7772,31 +7250,31 @@ parser_set_encode(struct parser_params *p, const char *name)
}
static int
-comment_at_top(struct parser_params *p)
+comment_at_top(struct parser_params *parser)
{
- const char *ptr = p->lex.pbeg, *ptr_end = p->lex.pcur - 1;
- if (p->line_count != (p->has_shebang ? 2 : 1)) return 0;
- while (ptr < ptr_end) {
- if (!ISSPACE(*ptr)) return 0;
- ptr++;
+ const char *p = lex_pbeg, *pend = lex_p - 1;
+ if (parser->line_count != (parser->has_shebang ? 2 : 1)) return 0;
+ while (p < pend) {
+ if (!ISSPACE(*p)) return 0;
+ p++;
}
return 1;
}
-typedef long (*rb_magic_comment_length_t)(struct parser_params *p, const char *name, long len);
-typedef void (*rb_magic_comment_setter_t)(struct parser_params *p, const char *name, const char *val);
+typedef long (*rb_magic_comment_length_t)(struct parser_params *parser, const char *name, long len);
+typedef void (*rb_magic_comment_setter_t)(struct parser_params *parser, const char *name, const char *val);
static void
-magic_comment_encoding(struct parser_params *p, const char *name, const char *val)
+magic_comment_encoding(struct parser_params *parser, const char *name, const char *val)
{
- if (!comment_at_top(p)) {
+ if (!comment_at_top(parser)) {
return;
}
- parser_set_encode(p, val);
+ parser_set_encode(parser, val);
}
static int
-parser_get_bool(struct parser_params *p, const char *name, const char *val)
+parser_get_bool(struct parser_params *parser, const char *name, const char *val)
{
switch (*val) {
case 't': case 'T':
@@ -7810,42 +7288,42 @@ parser_get_bool(struct parser_params *p, const char *name, const char *val)
}
break;
}
- rb_compile_warning(p->ruby_sourcefile, p->ruby_sourceline, "invalid value for %s: %s", name, val);
+ rb_compile_warning(ruby_sourcefile, ruby_sourceline, "invalid value for %s: %s", name, val);
return -1;
}
static void
-parser_set_token_info(struct parser_params *p, const char *name, const char *val)
+parser_set_token_info(struct parser_params *parser, const char *name, const char *val)
{
- int b = parser_get_bool(p, name, val);
- if (b >= 0) p->token_info_enabled = b;
+ int b = parser_get_bool(parser, name, val);
+ if (b >= 0) parser->token_info_enabled = b;
}
static void
-parser_set_compile_option_flag(struct parser_params *p, const char *name, const char *val)
+parser_set_compile_option_flag(struct parser_params *parser, const char *name, const char *val)
{
int b;
- if (p->token_seen) {
+ if (parser->token_seen) {
rb_warning1("`%s' is ignored after any tokens", WARN_S(name));
return;
}
- b = parser_get_bool(p, name, val);
+ b = parser_get_bool(parser, name, val);
if (b < 0) return;
- if (!p->compile_option)
- p->compile_option = rb_obj_hide(rb_ident_hash_new());
- rb_hash_aset(p->compile_option, ID2SYM(rb_intern(name)),
+ if (!parser->compile_option)
+ parser->compile_option = rb_obj_hide(rb_ident_hash_new());
+ rb_hash_aset(parser->compile_option, ID2SYM(rb_intern(name)),
(b ? Qtrue : Qfalse));
}
# if WARN_PAST_SCOPE
static void
-parser_set_past_scope(struct parser_params *p, const char *name, const char *val)
+parser_set_past_scope(struct parser_params *parser, const char *name, const char *val)
{
- int b = parser_get_bool(p, name, val);
- if (b >= 0) p->past_scope_enabled = b;
+ int b = parser_get_bool(parser, name, val);
+ if (b >= 0) parser->past_scope_enabled = b;
}
# endif
@@ -7899,7 +7377,7 @@ magic_comment_marker(const char *str, long len)
}
static int
-parser_magic_comment(struct parser_params *p, const char *str, long len)
+parser_magic_comment(struct parser_params *parser, const char *str, long len)
{
int indicator = 0;
VALUE name = 0, val = 0;
@@ -7920,7 +7398,7 @@ parser_magic_comment(struct parser_params *p, const char *str, long len)
/* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */
while (len > 0) {
- const struct magic_comment *mc = magic_comments;
+ const struct magic_comment *p = magic_comments;
char *s;
int i;
long n = 0;
@@ -7983,16 +7461,16 @@ parser_magic_comment(struct parser_params *p, const char *str, long len)
if (s[i] == '-') s[i] = '_';
}
do {
- if (STRNCASECMP(mc->name, s, n) == 0 && !mc->name[n]) {
+ if (STRNCASECMP(p->name, s, n) == 0 && !p->name[n]) {
n = vend - vbeg;
- if (mc->length) {
- n = (*mc->length)(p, vbeg, n);
+ if (p->length) {
+ n = (*p->length)(parser, vbeg, n);
}
str_copy(val, vbeg, n);
- (*mc->func)(p, mc->name, RSTRING_PTR(val));
+ (*p->func)(parser, p->name, RSTRING_PTR(val));
break;
}
- } while (++mc < magic_comments + numberof(magic_comments));
+ } while (++p < magic_comments + numberof(magic_comments));
#ifdef RIPPER
str_copy(val, vbeg, vend - vbeg);
dispatch2(magic_comment, name, val);
@@ -8003,7 +7481,7 @@ parser_magic_comment(struct parser_params *p, const char *str, long len)
}
static void
-set_file_encoding(struct parser_params *p, const char *str, const char *send)
+set_file_encoding(struct parser_params *parser, const char *str, const char *send)
{
int sep = 0;
const char *beg = str;
@@ -8040,35 +7518,35 @@ set_file_encoding(struct parser_params *p, const char *str, const char *send)
}
beg = str;
while ((*str == '-' || *str == '_' || ISALNUM(*str)) && ++str < send);
- s = rb_str_new(beg, parser_encode_length(p, beg, str - beg));
- parser_set_encode(p, RSTRING_PTR(s));
+ s = rb_str_new(beg, parser_encode_length(parser, beg, str - beg));
+ parser_set_encode(parser, RSTRING_PTR(s));
rb_str_resize(s, 0);
}
static void
-parser_prepare(struct parser_params *p)
+parser_prepare(struct parser_params *parser)
{
- int c = nextc(p);
- p->token_info_enabled = !compile_for_eval && RTEST(ruby_verbose);
+ int c = nextc();
+ parser->token_info_enabled = !compile_for_eval && RTEST(ruby_verbose);
switch (c) {
case '#':
- if (peek(p, '!')) p->has_shebang = 1;
+ if (peek('!')) parser->has_shebang = 1;
break;
case 0xef: /* UTF-8 BOM marker */
- if (p->lex.pend - p->lex.pcur >= 2 &&
- (unsigned char)p->lex.pcur[0] == 0xbb &&
- (unsigned char)p->lex.pcur[1] == 0xbf) {
- p->enc = rb_utf8_encoding();
- p->lex.pcur += 2;
- p->lex.pbeg = p->lex.pcur;
+ if (lex_pend - lex_p >= 2 &&
+ (unsigned char)lex_p[0] == 0xbb &&
+ (unsigned char)lex_p[1] == 0xbf) {
+ parser->enc = rb_utf8_encoding();
+ lex_p += 2;
+ lex_pbeg = lex_p;
return;
}
break;
case EOF:
return;
}
- pushback(p, c);
- p->enc = rb_enc_get(p->lex.lastline);
+ pushback(c);
+ parser->enc = rb_enc_get(lex_lastline);
}
#ifndef RIPPER
@@ -8086,7 +7564,7 @@ parser_prepare(struct parser_params *p)
(enum yytokentype)(tok))
static VALUE
-parse_rational(struct parser_params *p, char *str, int len, int seen_point)
+parse_rational(struct parser_params *parser, char *str, int len, int seen_point)
{
VALUE v;
char *point = &str[seen_point];
@@ -8096,34 +7574,26 @@ parse_rational(struct parser_params *p, char *str, int len, int seen_point)
return rb_rational_new(v, rb_int_positive_pow(10, fraclen));
}
-static enum yytokentype
-no_digits(struct parser_params *p)
-{
- yyerror0("numeric literal without digits");
- if (peek(p, '_')) nextc(p);
- /* dummy 0, for tUMINUS_NUM at numeric */
- return set_integer_literal(p, INT2FIX(0), 0);
-}
-
-static enum yytokentype
-parse_numeric(struct parser_params *p, int c)
+static int
+parse_numeric(struct parser_params *parser, int c)
{
int is_float, seen_point, seen_e, nondigit;
int suffix;
is_float = seen_point = seen_e = nondigit = 0;
SET_LEX_STATE(EXPR_END);
- newtok(p);
+ newtok();
if (c == '-' || c == '+') {
- tokadd(p, c);
- c = nextc(p);
+ tokadd(c);
+ c = nextc();
}
if (c == '0') {
- int start = toklen(p);
- c = nextc(p);
+#define no_digits() do {yyerror0("numeric literal without digits"); return 0;} while (0)
+ int start = toklen();
+ c = nextc();
if (c == 'x' || c == 'X') {
/* hexadecimal */
- c = nextc(p);
+ c = nextc();
if (c != -1 && ISXDIGIT(c)) {
do {
if (c == '_') {
@@ -8133,21 +7603,21 @@ parse_numeric(struct parser_params *p, int c)
}
if (!ISXDIGIT(c)) break;
nondigit = 0;
- tokadd(p, c);
- } while ((c = nextc(p)) != -1);
+ tokadd(c);
+ } while ((c = nextc()) != -1);
}
- pushback(p, c);
- tokfix(p);
- if (toklen(p) == start) {
- return no_digits(p);
+ pushback(c);
+ tokfix();
+ if (toklen() == start) {
+ no_digits();
}
else if (nondigit) goto trailing_uc;
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 16, FALSE), suffix);
+ suffix = number_literal_suffix(NUM_SUFFIX_ALL);
+ return set_integer_literal(rb_cstr_to_inum(tok(), 16, FALSE), suffix);
}
if (c == 'b' || c == 'B') {
/* binary */
- c = nextc(p);
+ c = nextc();
if (c == '0' || c == '1') {
do {
if (c == '_') {
@@ -8157,21 +7627,21 @@ parse_numeric(struct parser_params *p, int c)
}
if (c != '0' && c != '1') break;
nondigit = 0;
- tokadd(p, c);
- } while ((c = nextc(p)) != -1);
+ tokadd(c);
+ } while ((c = nextc()) != -1);
}
- pushback(p, c);
- tokfix(p);
- if (toklen(p) == start) {
- return no_digits(p);
+ pushback(c);
+ tokfix();
+ if (toklen() == start) {
+ no_digits();
}
else if (nondigit) goto trailing_uc;
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 2, FALSE), suffix);
+ suffix = number_literal_suffix(NUM_SUFFIX_ALL);
+ return set_integer_literal(rb_cstr_to_inum(tok(), 2, FALSE), suffix);
}
if (c == 'd' || c == 'D') {
/* decimal */
- c = nextc(p);
+ c = nextc();
if (c != -1 && ISDIGIT(c)) {
do {
if (c == '_') {
@@ -8181,17 +7651,17 @@ parse_numeric(struct parser_params *p, int c)
}
if (!ISDIGIT(c)) break;
nondigit = 0;
- tokadd(p, c);
- } while ((c = nextc(p)) != -1);
+ tokadd(c);
+ } while ((c = nextc()) != -1);
}
- pushback(p, c);
- tokfix(p);
- if (toklen(p) == start) {
- return no_digits(p);
+ pushback(c);
+ tokfix();
+ if (toklen() == start) {
+ no_digits();
}
else if (nondigit) goto trailing_uc;
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 10, FALSE), suffix);
+ suffix = number_literal_suffix(NUM_SUFFIX_ALL);
+ return set_integer_literal(rb_cstr_to_inum(tok(), 10, FALSE), suffix);
}
if (c == '_') {
/* 0_0 */
@@ -8199,9 +7669,9 @@ parse_numeric(struct parser_params *p, int c)
}
if (c == 'o' || c == 'O') {
/* prefixed octal */
- c = nextc(p);
+ c = nextc();
if (c == -1 || c == '_' || !ISDIGIT(c)) {
- return no_digits(p);
+ no_digits();
}
}
if (c >= '0' && c <= '7') {
@@ -8216,17 +7686,17 @@ parse_numeric(struct parser_params *p, int c)
if (c < '0' || c > '9') break;
if (c > '7') goto invalid_octal;
nondigit = 0;
- tokadd(p, c);
- } while ((c = nextc(p)) != -1);
- if (toklen(p) > start) {
- pushback(p, c);
- tokfix(p);
+ tokadd(c);
+ } while ((c = nextc()) != -1);
+ if (toklen() > start) {
+ pushback(c);
+ tokfix();
if (nondigit) goto trailing_uc;
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 8, FALSE), suffix);
+ suffix = number_literal_suffix(NUM_SUFFIX_ALL);
+ return set_integer_literal(rb_cstr_to_inum(tok(), 8, FALSE), suffix);
}
if (nondigit) {
- pushback(p, c);
+ pushback(c);
goto trailing_uc;
}
}
@@ -8235,12 +7705,12 @@ parse_numeric(struct parser_params *p, int c)
yyerror0("Invalid octal digit");
}
else if (c == '.' || c == 'e' || c == 'E') {
- tokadd(p, '0');
+ tokadd('0');
}
else {
- pushback(p, c);
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, INT2FIX(0), suffix);
+ pushback(c);
+ suffix = number_literal_suffix(NUM_SUFFIX_ALL);
+ return set_integer_literal(INT2FIX(0), suffix);
}
}
@@ -8249,7 +7719,7 @@ parse_numeric(struct parser_params *p, int c)
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
nondigit = 0;
- tokadd(p, c);
+ tokadd(c);
break;
case '.':
@@ -8258,16 +7728,16 @@ parse_numeric(struct parser_params *p, int c)
goto decode_num;
}
else {
- int c0 = nextc(p);
+ int c0 = nextc();
if (c0 == -1 || !ISDIGIT(c0)) {
- pushback(p, c0);
+ pushback(c0);
goto decode_num;
}
c = c0;
}
- seen_point = toklen(p);
- tokadd(p, '.');
- tokadd(p, c);
+ seen_point = toklen();
+ tokadd('.');
+ tokadd(c);
is_float++;
nondigit = 0;
break;
@@ -8275,7 +7745,7 @@ parse_numeric(struct parser_params *p, int c)
case 'e':
case 'E':
if (nondigit) {
- pushback(p, c);
+ pushback(c);
c = nondigit;
goto decode_num;
}
@@ -8283,16 +7753,16 @@ parse_numeric(struct parser_params *p, int c)
goto decode_num;
}
nondigit = c;
- c = nextc(p);
+ c = nextc();
if (c != '-' && c != '+' && !ISDIGIT(c)) {
- pushback(p, c);
+ pushback(c);
nondigit = 0;
goto decode_num;
}
- tokadd(p, nondigit);
+ tokadd(nondigit);
seen_e++;
is_float++;
- tokadd(p, c);
+ tokadd(c);
nondigit = (c == '-' || c == '+') ? c : 0;
break;
@@ -8304,44 +7774,44 @@ parse_numeric(struct parser_params *p, int c)
default:
goto decode_num;
}
- c = nextc(p);
+ c = nextc();
}
decode_num:
- pushback(p, c);
+ pushback(c);
if (nondigit) {
+ char tmp[30];
trailing_uc:
- literal_flush(p, p->lex.pcur - 1);
- YYLTYPE loc = RUBY_INIT_YYLLOC();
- compile_error(p, "trailing `%c' in number", nondigit);
- parser_show_error_line(p, &loc);
+ literal_flush(lex_p - 1);
+ snprintf(tmp, sizeof(tmp), "trailing `%c' in number", nondigit);
+ yyerror0(tmp);
}
- tokfix(p);
+ tokfix();
if (is_float) {
- enum yytokentype type = tFLOAT;
+ int type = tFLOAT;
VALUE v;
- suffix = number_literal_suffix(p, seen_e ? NUM_SUFFIX_I : NUM_SUFFIX_ALL);
+ suffix = number_literal_suffix(seen_e ? NUM_SUFFIX_I : NUM_SUFFIX_ALL);
if (suffix & NUM_SUFFIX_R) {
type = tRATIONAL;
- v = parse_rational(p, tok(p), toklen(p), seen_point);
+ v = parse_rational(parser, tok(), toklen(), seen_point);
}
else {
- double d = strtod(tok(p), 0);
+ double d = strtod(tok(), 0);
if (errno == ERANGE) {
- rb_warning1("Float %s out of range", WARN_S(tok(p)));
+ rb_warning1("Float %s out of range", WARN_S(tok()));
errno = 0;
}
v = DBL2NUM(d);
}
- return set_number_literal(p, v, type, suffix);
+ return set_number_literal(v, type, suffix);
}
- suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 10, FALSE), suffix);
+ suffix = number_literal_suffix(NUM_SUFFIX_ALL);
+ return set_integer_literal(rb_cstr_to_inum(tok(), 10, FALSE), suffix);
}
static enum yytokentype
-parse_qmark(struct parser_params *p, int space_seen)
+parse_qmark(struct parser_params *parser, int space_seen)
{
rb_encoding *enc;
register int c;
@@ -8351,93 +7821,113 @@ parse_qmark(struct parser_params *p, int space_seen)
SET_LEX_STATE(EXPR_VALUE);
return '?';
}
- c = nextc(p);
+ c = nextc();
if (c == -1) {
- compile_error(p, "incomplete character syntax");
+ compile_error(PARSER_ARG "incomplete character syntax");
return 0;
}
- if (rb_enc_isspace(c, p->enc)) {
+ if (rb_enc_isspace(c, current_enc)) {
if (!IS_ARG()) {
- int c2 = escaped_control_code(c);
+ int c2 = 0;
+ switch (c) {
+ case ' ':
+ c2 = 's';
+ break;
+ case '\n':
+ c2 = 'n';
+ break;
+ case '\t':
+ c2 = 't';
+ break;
+ case '\v':
+ c2 = 'v';
+ break;
+ case '\r':
+ c2 = 'r';
+ break;
+ case '\f':
+ c2 = 'f';
+ break;
+ }
if (c2) {
- WARN_SPACE_CHAR(c2, "?");
+ rb_warn1("invalid character syntax; use ?\\%c", WARN_I(c2));
}
}
ternary:
- pushback(p, c);
+ pushback(c);
SET_LEX_STATE(EXPR_VALUE);
return '?';
}
- newtok(p);
- enc = p->enc;
- if (!parser_isascii(p)) {
- if (tokadd_mbchar(p, c) == -1) return 0;
+ newtok();
+ enc = current_enc;
+ if (!parser_isascii()) {
+ if (tokadd_mbchar(c) == -1) return 0;
}
- else if ((rb_enc_isalnum(c, p->enc) || c == '_') &&
- p->lex.pcur < p->lex.pend && is_identchar(p->lex.pcur, p->lex.pend, p->enc)) {
+ else if ((rb_enc_isalnum(c, current_enc) || c == '_') &&
+ lex_p < lex_pend && is_identchar(lex_p, lex_pend, current_enc)) {
if (space_seen) {
- const char *start = p->lex.pcur - 1, *ptr = start;
+ const char *start = lex_p - 1, *p = start;
do {
- int n = parser_precise_mbclen(p, ptr);
+ int n = parser_precise_mbclen(parser, p);
if (n < 0) return -1;
- ptr += n;
- } while (ptr < p->lex.pend && is_identchar(ptr, p->lex.pend, p->enc));
+ p += n;
+ } while (p < lex_pend && is_identchar(p, lex_pend, current_enc));
rb_warn2("`?' just followed by `%.*s' is interpreted as" \
" a conditional operator, put a space after `?'",
- WARN_I((int)(ptr - start)), WARN_S_L(start, (ptr - start)));
+ WARN_I((int)(p - start)), WARN_S_L(start, (p - start)));
}
goto ternary;
}
else if (c == '\\') {
- if (peek(p, 'u')) {
- nextc(p);
+ if (peek('u')) {
+ nextc();
enc = rb_utf8_encoding();
- tokadd_utf8(p, &enc, -1, 0, 0);
+ if (!parser_tokadd_utf8(parser, &enc, -1, 0, 0))
+ return 0;
}
- else if (!lex_eol_p(p) && !(c = *p->lex.pcur, ISASCII(c))) {
- nextc(p);
- if (tokadd_mbchar(p, c) == -1) return 0;
+ else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) {
+ nextc();
+ if (tokadd_mbchar(c) == -1) return 0;
}
else {
- c = read_escape(p, 0, &enc);
- tokadd(p, c);
+ c = read_escape(0, &enc);
+ tokadd(c);
}
}
else {
- tokadd(p, c);
+ tokadd(c);
}
- tokfix(p);
- lit = STR_NEW3(tok(p), toklen(p), enc, 0);
+ tokfix();
+ add_mark_object(lit = STR_NEW3(tok(), toklen(), enc, 0));
set_yylval_str(lit);
SET_LEX_STATE(EXPR_END);
return tCHAR;
}
static enum yytokentype
-parse_percent(struct parser_params *p, const int space_seen, const enum lex_state_e last_state)
+parse_percent(struct parser_params *parser, const int space_seen, const enum lex_state_e last_state)
{
register int c;
- const char *ptok = p->lex.pcur;
if (IS_BEG()) {
int term;
int paren;
- c = nextc(p);
+ c = nextc();
quotation:
if (c == -1 || !ISALNUM(c)) {
term = c;
c = 'Q';
}
else {
- term = nextc(p);
- if (rb_enc_isalnum(term, p->enc) || !parser_isascii(p)) {
+ term = nextc();
+ if (rb_enc_isalnum(term, current_enc) || !parser_isascii()) {
yyerror0("unknown type of %string");
return 0;
}
}
if (c == -1 || term == -1) {
- compile_error(p, "unterminated quoted string meets end of file");
+ compile_error(PARSER_ARG "unterminated quoted string meets end of file");
return 0;
}
paren = term;
@@ -8447,42 +7937,41 @@ parse_percent(struct parser_params *p, const int space_seen, const enum lex_stat
else if (term == '<') term = '>';
else paren = 0;
- p->lex.ptok = ptok-1;
switch (c) {
case 'Q':
- p->lex.strterm = NEW_STRTERM(str_dquote, term, paren);
+ lex_strterm = NEW_STRTERM(str_dquote, term, paren);
return tSTRING_BEG;
case 'q':
- p->lex.strterm = NEW_STRTERM(str_squote, term, paren);
+ lex_strterm = NEW_STRTERM(str_squote, term, paren);
return tSTRING_BEG;
case 'W':
- p->lex.strterm = NEW_STRTERM(str_dword, term, paren);
+ lex_strterm = NEW_STRTERM(str_dword, term, paren);
return tWORDS_BEG;
case 'w':
- p->lex.strterm = NEW_STRTERM(str_sword, term, paren);
+ lex_strterm = NEW_STRTERM(str_sword, term, paren);
return tQWORDS_BEG;
case 'I':
- p->lex.strterm = NEW_STRTERM(str_dword, term, paren);
+ lex_strterm = NEW_STRTERM(str_dword, term, paren);
return tSYMBOLS_BEG;
case 'i':
- p->lex.strterm = NEW_STRTERM(str_sword, term, paren);
+ lex_strterm = NEW_STRTERM(str_sword, term, paren);
return tQSYMBOLS_BEG;
case 'x':
- p->lex.strterm = NEW_STRTERM(str_xquote, term, paren);
+ lex_strterm = NEW_STRTERM(str_xquote, term, paren);
return tXSTRING_BEG;
case 'r':
- p->lex.strterm = NEW_STRTERM(str_regexp, term, paren);
+ lex_strterm = NEW_STRTERM(str_regexp, term, paren);
return tREGEXP_BEG;
case 's':
- p->lex.strterm = NEW_STRTERM(str_ssym, term, paren);
+ lex_strterm = NEW_STRTERM(str_ssym, term, paren);
SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);
return tSYMBEG;
@@ -8491,7 +7980,7 @@ parse_percent(struct parser_params *p, const int space_seen, const enum lex_stat
return 0;
}
}
- if ((c = nextc(p)) == '=') {
+ if ((c = nextc()) == '=') {
set_yylval_id('%');
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
@@ -8500,23 +7989,23 @@ parse_percent(struct parser_params *p, const int space_seen, const enum lex_stat
goto quotation;
}
SET_LEX_STATE(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
- pushback(p, c);
+ pushback(c);
return warn_balanced('%', "%%", "string literal");
}
static int
-tokadd_ident(struct parser_params *p, int c)
+tokadd_ident(struct parser_params *parser, int c)
{
do {
- if (tokadd_mbchar(p, c) == -1) return -1;
- c = nextc(p);
- } while (parser_is_identchar(p));
- pushback(p, c);
+ if (tokadd_mbchar(c) == -1) return -1;
+ c = nextc();
+ } while (parser_is_identchar());
+ pushback(c);
return 0;
}
static ID
-tokenize_ident(struct parser_params *p, const enum lex_state_e last_state)
+tokenize_ident(struct parser_params *parser, const enum lex_state_e last_state)
{
ID ident = TOK_INTERN();
@@ -8526,11 +8015,11 @@ tokenize_ident(struct parser_params *p, const enum lex_state_e last_state)
}
static int
-parse_numvar(struct parser_params *p)
+parse_numvar(struct parser_params *parser)
{
size_t len;
int overflow;
- unsigned long n = ruby_scan_digits(tok(p)+1, toklen(p)-1, 10, &len, &overflow);
+ unsigned long n = ruby_scan_digits(tok()+1, toklen()-1, 10, &len, &overflow);
const unsigned long nth_ref_max =
((FIXNUM_MAX < INT_MAX) ? FIXNUM_MAX : INT_MAX) >> 1;
/* NTH_REF is left-shifted to be ORed with back-ref flag and
@@ -8538,7 +8027,7 @@ parse_numvar(struct parser_params *p)
if (overflow || n > nth_ref_max) {
/* compile_error()? */
- rb_warn1("`%s' is too big for a number variable, always nil", WARN_S(tok(p)));
+ rb_warn1("`%s' is too big for a number variable, always nil", WARN_S(tok()));
return 0; /* $0 is $PROGRAM_NAME, not NTH_REF */
}
else {
@@ -8547,24 +8036,22 @@ parse_numvar(struct parser_params *p)
}
static enum yytokentype
-parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
+parse_gvar(struct parser_params *parser, const enum lex_state_e last_state)
{
- const char *ptr = p->lex.pcur;
register int c;
SET_LEX_STATE(EXPR_END);
- p->lex.ptok = ptr - 1; /* from '$' */
- newtok(p);
- c = nextc(p);
+ newtok();
+ c = nextc();
switch (c) {
case '_': /* $_: last read line string */
- c = nextc(p);
- if (parser_is_identchar(p)) {
- tokadd(p, '$');
- tokadd(p, '_');
+ c = nextc();
+ if (parser_is_identchar()) {
+ tokadd('$');
+ tokadd('_');
break;
}
- pushback(p, c);
+ pushback(c);
c = '_';
/* fall through */
case '~': /* $~: match-data */
@@ -8583,20 +8070,20 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
case '<': /* $<: reading filename */
case '>': /* $>: default output handle */
case '\"': /* $": already loaded files */
- tokadd(p, '$');
- tokadd(p, c);
+ tokadd('$');
+ tokadd(c);
goto gvar;
case '-':
- tokadd(p, '$');
- tokadd(p, c);
- c = nextc(p);
- if (parser_is_identchar(p)) {
- if (tokadd_mbchar(p, c) == -1) return 0;
+ tokadd('$');
+ tokadd(c);
+ c = nextc();
+ if (parser_is_identchar()) {
+ if (tokadd_mbchar(c) == -1) return 0;
}
else {
- pushback(p, c);
- pushback(p, '-');
+ pushback(c);
+ pushback('-');
return '$';
}
gvar:
@@ -8608,159 +8095,119 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
case '\'': /* $': string after last match */
case '+': /* $+: string matches last paren. */
if (IS_lex_state_for(last_state, EXPR_FNAME)) {
- tokadd(p, '$');
- tokadd(p, c);
+ tokadd('$');
+ tokadd(c);
goto gvar;
}
- set_yylval_node(NEW_BACK_REF(c, &_cur_loc));
+ set_yylval_node(NEW_BACK_REF(c));
return tBACK_REF;
case '1': case '2': case '3':
case '4': case '5': case '6':
case '7': case '8': case '9':
- tokadd(p, '$');
+ tokadd('$');
do {
- tokadd(p, c);
- c = nextc(p);
+ tokadd(c);
+ c = nextc();
} while (c != -1 && ISDIGIT(c));
- pushback(p, c);
+ pushback(c);
if (IS_lex_state_for(last_state, EXPR_FNAME)) goto gvar;
- tokfix(p);
- set_yylval_node(NEW_NTH_REF(parse_numvar(p), &_cur_loc));
+ tokfix();
+ set_yylval_node(NEW_NTH_REF(parse_numvar(parser)));
return tNTH_REF;
default:
- if (!parser_is_identchar(p)) {
- YYLTYPE loc = RUBY_INIT_YYLLOC();
+ if (!parser_is_identchar()) {
if (c == -1 || ISSPACE(c)) {
- compile_error(p, "`$' without identifiers is not allowed as a global variable name");
+ compile_error(PARSER_ARG "`$' without identifiers is not allowed as a global variable name");
}
else {
- pushback(p, c);
- compile_error(p, "`$%c' is not allowed as a global variable name", c);
+ pushback(c);
+ compile_error(PARSER_ARG "`$%c' is not allowed as a global variable name", c);
}
- parser_show_error_line(p, &loc);
- set_yylval_noname();
- return tGVAR;
+ return 0;
}
- /* fall through */
case '0':
- tokadd(p, '$');
+ tokadd('$');
}
- if (tokadd_ident(p, c)) return 0;
+ if (tokadd_ident(parser, c)) return 0;
SET_LEX_STATE(EXPR_END);
- tokenize_ident(p, last_state);
+ tokenize_ident(parser, last_state);
return tGVAR;
}
-#ifndef RIPPER
-static bool
-parser_numbered_param(struct parser_params *p, int n)
-{
- if (n < 0) return false;
-
- if (DVARS_TERMINAL_P(p->lvtbl->args) || DVARS_TERMINAL_P(p->lvtbl->args->prev)) {
- return false;
- }
- if (p->max_numparam == ORDINAL_PARAM) {
- compile_error(p, "ordinary parameter is defined");
- return false;
- }
- struct vtable *args = p->lvtbl->args;
- if (p->max_numparam < n) {
- p->max_numparam = n;
- }
- while (n > args->pos) {
- vtable_add(args, NUMPARAM_IDX_TO_ID(args->pos+1));
- }
- return true;
-}
-#endif
-
static enum yytokentype
-parse_atmark(struct parser_params *p, const enum lex_state_e last_state)
+parse_atmark(struct parser_params *parser, const enum lex_state_e last_state)
{
- const char *ptr = p->lex.pcur;
enum yytokentype result = tIVAR;
- register int c = nextc(p);
- YYLTYPE loc;
+ register int c = nextc();
- p->lex.ptok = ptr - 1; /* from '@' */
- newtok(p);
- tokadd(p, '@');
+ newtok();
+ tokadd('@');
if (c == '@') {
result = tCVAR;
- tokadd(p, '@');
- c = nextc(p);
+ tokadd('@');
+ c = nextc();
}
- SET_LEX_STATE(IS_lex_state_for(last_state, EXPR_FNAME) ? EXPR_ENDFN : EXPR_END);
- if (c == -1 || !parser_is_identchar(p)) {
- pushback(p, c);
- RUBY_SET_YYLLOC(loc);
+ if (c == -1 || ISSPACE(c)) {
if (result == tIVAR) {
- compile_error(p, "`@' without identifiers is not allowed as an instance variable name");
+ compile_error(PARSER_ARG "`@' without identifiers is not allowed as an instance variable name");
}
else {
- compile_error(p, "`@@' without identifiers is not allowed as a class variable name");
+ compile_error(PARSER_ARG "`@@' without identifiers is not allowed as a class variable name");
}
- parser_show_error_line(p, &loc);
- set_yylval_noname();
- SET_LEX_STATE(EXPR_END);
- return result;
+ return 0;
}
- else if (ISDIGIT(c)) {
- pushback(p, c);
- RUBY_SET_YYLLOC(loc);
+ else if (ISDIGIT(c) || !parser_is_identchar()) {
+ pushback(c);
if (result == tIVAR) {
- compile_error(p, "`@%c' is not allowed as an instance variable name", c);
+ compile_error(PARSER_ARG "`@%c' is not allowed as an instance variable name", c);
}
else {
- compile_error(p, "`@@%c' is not allowed as a class variable name", c);
+ compile_error(PARSER_ARG "`@@%c' is not allowed as a class variable name", c);
}
- parser_show_error_line(p, &loc);
- set_yylval_noname();
- SET_LEX_STATE(EXPR_END);
- return result;
+ return 0;
}
- if (tokadd_ident(p, c)) return 0;
- tokenize_ident(p, last_state);
+ if (tokadd_ident(parser, c)) return 0;
+ SET_LEX_STATE(EXPR_END);
+ tokenize_ident(parser, last_state);
return result;
}
static enum yytokentype
-parse_ident(struct parser_params *p, int c, int cmd_state)
+parse_ident(struct parser_params *parser, int c, int cmd_state)
{
enum yytokentype result;
int mb = ENC_CODERANGE_7BIT;
- const enum lex_state_e last_state = p->lex.state;
+ const enum lex_state_e last_state = lex_state;
ID ident;
do {
if (!ISASCII(c)) mb = ENC_CODERANGE_UNKNOWN;
- if (tokadd_mbchar(p, c) == -1) return 0;
- c = nextc(p);
- } while (parser_is_identchar(p));
- if ((c == '!' || c == '?') && !peek(p, '=')) {
+ if (tokadd_mbchar(c) == -1) return 0;
+ c = nextc();
+ } while (parser_is_identchar());
+ if ((c == '!' || c == '?') && !peek('=')) {
result = tFID;
- tokadd(p, c);
+ tokadd(c);
}
else if (c == '=' && IS_lex_state(EXPR_FNAME) &&
- (!peek(p, '~') && !peek(p, '>') && (!peek(p, '=') || (peek_n(p, '>', 1))))) {
+ (!peek('~') && !peek('>') && (!peek('=') || (peek_n('>', 1))))) {
result = tIDENTIFIER;
- tokadd(p, c);
+ tokadd(c);
}
else {
result = tCONSTANT; /* assume provisionally */
- pushback(p, c);
+ pushback(c);
}
- tokfix(p);
+ tokfix();
if (IS_LABEL_POSSIBLE()) {
if (IS_LABEL_SUFFIX(0)) {
SET_LEX_STATE(EXPR_ARG|EXPR_LABELED);
- nextc(p);
+ nextc();
set_yylval_name(TOK_INTERN());
return tLABEL;
}
@@ -8769,26 +8216,28 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
const struct kwtable *kw;
/* See if it is a reserved word. */
- kw = rb_reserved_word(tok(p), toklen(p));
+ kw = rb_reserved_word(tok(), toklen());
if (kw) {
- enum lex_state_e state = p->lex.state;
+ enum lex_state_e state = lex_state;
+ SET_LEX_STATE(kw->state);
if (IS_lex_state_for(state, EXPR_FNAME)) {
- SET_LEX_STATE(EXPR_ENDFN);
- set_yylval_name(rb_intern2(tok(p), toklen(p)));
+ set_yylval_name(rb_intern2(tok(), toklen()));
return kw->id[0];
}
- SET_LEX_STATE(kw->state);
if (IS_lex_state(EXPR_BEG)) {
- p->command_start = TRUE;
+ command_start = TRUE;
}
if (kw->id[0] == keyword_do) {
if (lambda_beginning_p()) {
- p->lex.lpar_beg = -1; /* make lambda_beginning_p() == FALSE in the body of "-> do ... end" */
+ lpar_beg = 0;
+ --paren_nest;
return keyword_do_LAMBDA;
}
if (COND_P()) return keyword_do_cond;
if (CMDARG_P() && !IS_lex_state_for(state, EXPR_CMDARG))
return keyword_do_block;
+ if (IS_lex_state_for(state, (EXPR_BEG | EXPR_ENDARG)))
+ return keyword_do_block;
return keyword_do;
}
if (IS_lex_state_for(state, (EXPR_BEG | EXPR_LABELED)))
@@ -8809,25 +8258,25 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
SET_LEX_STATE(EXPR_ARG);
}
}
- else if (p->lex.state == EXPR_FNAME) {
+ else if (lex_state == EXPR_FNAME) {
SET_LEX_STATE(EXPR_ENDFN);
}
else {
SET_LEX_STATE(EXPR_END);
}
- ident = tokenize_ident(p, last_state);
+ ident = tokenize_ident(parser, last_state);
if (result == tCONSTANT && is_local_id(ident)) result = tIDENTIFIER;
if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
(result == tIDENTIFIER) && /* not EXPR_FNAME, not attrasgn */
- lvar_defined(p, ident)) {
+ lvar_defined(ident)) {
SET_LEX_STATE(EXPR_END|EXPR_LABEL);
}
return result;
}
static enum yytokentype
-parser_yylex(struct parser_params *p)
+parser_yylex(struct parser_params *parser)
{
register int c;
int space_seen = 0;
@@ -8835,26 +8284,26 @@ parser_yylex(struct parser_params *p)
int label;
enum lex_state_e last_state;
int fallthru = FALSE;
- int token_seen = p->token_seen;
+ int token_seen = parser->token_seen;
- if (p->lex.strterm) {
- if (p->lex.strterm->flags & STRTERM_HEREDOC) {
- return here_document(p, &p->lex.strterm->u.heredoc);
+ if (lex_strterm) {
+ if (lex_strterm->flags & STRTERM_HEREDOC) {
+ return here_document(&lex_strterm->u.heredoc);
}
else {
- token_flush(p);
- return parse_string(p, &p->lex.strterm->u.literal);
+ token_flush(parser);
+ return parse_string(&lex_strterm->u.literal);
}
}
- cmd_state = p->command_start;
- p->command_start = FALSE;
- p->token_seen = TRUE;
+ cmd_state = command_start;
+ command_start = FALSE;
+ parser->token_seen = TRUE;
retry:
- last_state = p->lex.state;
+ last_state = lex_state;
#ifndef RIPPER
- token_flush(p);
+ token_flush(parser);
#endif
- switch (c = nextc(p)) {
+ switch (c = nextc()) {
case '\0': /* NUL */
case '\004': /* ^D */
case '\032': /* ^Z */
@@ -8866,7 +8315,7 @@ parser_yylex(struct parser_params *p)
case '\13': /* '\v' */
space_seen = 1;
#ifdef RIPPER
- while ((c = nextc(p))) {
+ while ((c = nextc())) {
switch (c) {
case ' ': case '\t': case '\f': case '\r':
case '\13': /* '\v' */
@@ -8876,88 +8325,84 @@ parser_yylex(struct parser_params *p)
}
}
outofloop:
- pushback(p, c);
- dispatch_scan_event(p, tSP);
+ pushback(c);
+ dispatch_scan_event(tSP);
#endif
goto retry;
case '#': /* it's a comment */
- p->token_seen = token_seen;
+ parser->token_seen = token_seen;
/* no magic_comment in shebang line */
- if (!parser_magic_comment(p, p->lex.pcur, p->lex.pend - p->lex.pcur)) {
- if (comment_at_top(p)) {
- set_file_encoding(p, p->lex.pcur, p->lex.pend);
+ if (!parser_magic_comment(parser, lex_p, lex_pend - lex_p)) {
+ if (comment_at_top(parser)) {
+ set_file_encoding(parser, lex_p, lex_pend);
}
}
- lex_goto_eol(p);
- dispatch_scan_event(p, tCOMMENT);
+ lex_p = lex_pend;
+ dispatch_scan_event(tCOMMENT);
fallthru = TRUE;
/* fall through */
case '\n':
- p->token_seen = token_seen;
+ parser->token_seen = token_seen;
c = (IS_lex_state(EXPR_BEG|EXPR_CLASS|EXPR_FNAME|EXPR_DOT) &&
!IS_lex_state(EXPR_LABELED));
if (c || IS_lex_state_all(EXPR_ARG|EXPR_LABELED)) {
if (!fallthru) {
- dispatch_scan_event(p, tIGNORED_NL);
+ dispatch_scan_event(tIGNORED_NL);
}
fallthru = FALSE;
- if (!c && p->in_kwarg) {
+ if (!c && parser->in_kwarg) {
goto normal_newline;
}
goto retry;
}
while (1) {
- switch (c = nextc(p)) {
+ switch (c = nextc()) {
case ' ': case '\t': case '\f': case '\r':
case '\13': /* '\v' */
space_seen = 1;
break;
- case '#':
- pushback(p, c);
- if (space_seen) dispatch_scan_event(p, tSP);
- goto retry;
case '&':
case '.': {
- dispatch_delayed_token(p, tIGNORED_NL);
- if (peek(p, '.') == (c == '&')) {
- pushback(p, c);
- dispatch_scan_event(p, tSP);
+ dispatch_delayed_token(tIGNORED_NL);
+ if (peek('.') == (c == '&')) {
+ pushback(c);
+ dispatch_scan_event(tSP);
goto retry;
}
}
default:
- p->ruby_sourceline--;
- p->lex.nextline = p->lex.lastline;
+ --ruby_sourceline;
+ lex_nextline = lex_lastline;
case -1: /* EOF no decrement*/
#ifndef RIPPER
- if (p->lex.prevline && !p->eofp) p->lex.lastline = p->lex.prevline;
- p->lex.pbeg = RSTRING_PTR(p->lex.lastline);
- p->lex.pend = p->lex.pcur = p->lex.pbeg + RSTRING_LEN(p->lex.lastline);
- pushback(p, 1); /* always pushback */
- p->lex.ptok = p->lex.pcur;
+ if (lex_prevline && !parser->eofp) lex_lastline = lex_prevline;
+ lex_pbeg = RSTRING_PTR(lex_lastline);
+ lex_pend = lex_p = lex_pbeg + RSTRING_LEN(lex_lastline);
+ pushback(1); /* always pushback */
+ parser->tokp = lex_p;
#else
- lex_goto_eol(p);
+ lex_goto_eol(parser);
if (c != -1) {
- p->lex.ptok = p->lex.pcur;
+ parser->tokp = lex_p;
}
#endif
goto normal_newline;
}
}
normal_newline:
- p->command_start = TRUE;
+ command_start = TRUE;
SET_LEX_STATE(EXPR_BEG);
return '\n';
case '*':
- if ((c = nextc(p)) == '*') {
- if ((c = nextc(p)) == '=') {
- set_yylval_id(idPow);
+ if ((c = nextc()) == '*') {
+ if ((c = nextc()) == '=') {
+ set_yylval_id(tPOW);
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- pushback(p, c);
+ pushback(c);
if (IS_SPCARG(c)) {
rb_warning0("`**' interpreted as argument prefix");
c = tDSTAR;
@@ -8975,7 +8420,7 @@ parser_yylex(struct parser_params *p)
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- pushback(p, c);
+ pushback(c);
if (IS_SPCARG(c)) {
rb_warning0("`*' interpreted as argument prefix");
c = tSTAR;
@@ -8991,7 +8436,7 @@ parser_yylex(struct parser_params *p)
return c;
case '!':
- c = nextc(p);
+ c = nextc();
if (IS_AFTER_OPERATOR()) {
SET_LEX_STATE(EXPR_ARG);
if (c == '@') {
@@ -9007,45 +8452,46 @@ parser_yylex(struct parser_params *p)
if (c == '~') {
return tNMATCH;
}
- pushback(p, c);
+ pushback(c);
return '!';
case '=':
- if (was_bol(p)) {
+ if (was_bol()) {
/* skip embedded rd document */
- if (word_match_p(p, "begin", 5)) {
+ if (strncmp(lex_p, "begin", 5) == 0 && ISSPACE(lex_p[5])) {
int first_p = TRUE;
- lex_goto_eol(p);
- dispatch_scan_event(p, tEMBDOC_BEG);
+ lex_goto_eol(parser);
+ dispatch_scan_event(tEMBDOC_BEG);
for (;;) {
- lex_goto_eol(p);
+ lex_goto_eol(parser);
if (!first_p) {
- dispatch_scan_event(p, tEMBDOC);
+ dispatch_scan_event(tEMBDOC);
}
first_p = FALSE;
- c = nextc(p);
+ c = nextc();
if (c == -1) {
- compile_error(p, "embedded document meets end of file");
+ compile_error(PARSER_ARG "embedded document meets end of file");
return 0;
}
- if (c == '=' && word_match_p(p, "end", 3)) {
+ if (c != '=') continue;
+ if (c == '=' && strncmp(lex_p, "end", 3) == 0 &&
+ (lex_p + 3 == lex_pend || ISSPACE(lex_p[3]))) {
break;
}
- pushback(p, c);
}
- lex_goto_eol(p);
- dispatch_scan_event(p, tEMBDOC_END);
+ lex_goto_eol(parser);
+ dispatch_scan_event(tEMBDOC_END);
goto retry;
}
}
SET_LEX_STATE(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
- if ((c = nextc(p)) == '=') {
- if ((c = nextc(p)) == '=') {
+ if ((c = nextc()) == '=') {
+ if ((c = nextc()) == '=') {
return tEQQ;
}
- pushback(p, c);
+ pushback(c);
return tEQ;
}
if (c == '~') {
@@ -9054,66 +8500,66 @@ parser_yylex(struct parser_params *p)
else if (c == '>') {
return tASSOC;
}
- pushback(p, c);
+ pushback(c);
return '=';
case '<':
- c = nextc(p);
+ last_state = lex_state;
+ c = nextc();
if (c == '<' &&
!IS_lex_state(EXPR_DOT | EXPR_CLASS) &&
!IS_END() &&
(!IS_ARG() || IS_lex_state(EXPR_LABELED) || space_seen)) {
- int token = heredoc_identifier(p);
- if (token) return token < 0 ? 0 : token;
+ int token = heredoc_identifier();
+ if (token) return token;
}
if (IS_AFTER_OPERATOR()) {
SET_LEX_STATE(EXPR_ARG);
}
else {
if (IS_lex_state(EXPR_CLASS))
- p->command_start = TRUE;
+ command_start = TRUE;
SET_LEX_STATE(EXPR_BEG);
}
if (c == '=') {
- if ((c = nextc(p)) == '>') {
+ if ((c = nextc()) == '>') {
return tCMP;
}
- pushback(p, c);
+ pushback(c);
return tLEQ;
}
if (c == '<') {
- if ((c = nextc(p)) == '=') {
- set_yylval_id(idLTLT);
+ if ((c = nextc()) == '=') {
+ set_yylval_id(tLSHFT);
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- pushback(p, c);
+ pushback(c);
return warn_balanced((enum ruby_method_ids)tLSHFT, "<<", "here document");
}
- pushback(p, c);
+ pushback(c);
return '<';
case '>':
SET_LEX_STATE(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
- if ((c = nextc(p)) == '=') {
+ if ((c = nextc()) == '=') {
return tGEQ;
}
if (c == '>') {
- if ((c = nextc(p)) == '=') {
- set_yylval_id(idGTGT);
+ if ((c = nextc()) == '=') {
+ set_yylval_id(tRSHFT);
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- pushback(p, c);
+ pushback(c);
return tRSHFT;
}
- pushback(p, c);
+ pushback(c);
return '>';
case '"':
label = (IS_LABEL_POSSIBLE() ? str_label : 0);
- p->lex.strterm = NEW_STRTERM(str_dquote | label, '"', 0);
- p->lex.ptok = p->lex.pcur-1;
+ lex_strterm = NEW_STRTERM(str_dquote | label, '"', 0);
return tSTRING_BEG;
case '`':
@@ -9128,27 +8574,26 @@ parser_yylex(struct parser_params *p)
SET_LEX_STATE(EXPR_ARG);
return c;
}
- p->lex.strterm = NEW_STRTERM(str_xquote, '`', 0);
+ lex_strterm = NEW_STRTERM(str_xquote, '`', 0);
return tXSTRING_BEG;
case '\'':
label = (IS_LABEL_POSSIBLE() ? str_label : 0);
- p->lex.strterm = NEW_STRTERM(str_squote | label, '\'', 0);
- p->lex.ptok = p->lex.pcur-1;
+ lex_strterm = NEW_STRTERM(str_squote | label, '\'', 0);
return tSTRING_BEG;
case '?':
- return parse_qmark(p, space_seen);
+ return parse_qmark(parser, space_seen);
case '&':
- if ((c = nextc(p)) == '&') {
+ if ((c = nextc()) == '&') {
SET_LEX_STATE(EXPR_BEG);
- if ((c = nextc(p)) == '=') {
- set_yylval_id(idANDOP);
+ if ((c = nextc()) == '=') {
+ set_yylval_id(tANDOP);
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- pushback(p, c);
+ pushback(c);
return tANDOP;
}
else if (c == '=') {
@@ -9157,16 +8602,15 @@ parser_yylex(struct parser_params *p)
return tOP_ASGN;
}
else if (c == '.') {
- set_yylval_id(idANDDOT);
SET_LEX_STATE(EXPR_DOT);
return tANDDOT;
}
- pushback(p, c);
+ pushback(c);
if (IS_SPCARG(c)) {
if ((c != ':') ||
- (c = peekc_n(p, 1)) == -1 ||
+ (c = peekc_n(1)) == -1 ||
!(c == '\'' || c == '"' ||
- is_identchar((p->lex.pcur+1), p->lex.pend, p->enc))) {
+ is_identchar((lex_p+1), lex_pend, current_enc))) {
rb_warning0("`&' interpreted as argument prefix");
}
c = tAMPER;
@@ -9181,19 +8625,14 @@ parser_yylex(struct parser_params *p)
return c;
case '|':
- if ((c = nextc(p)) == '|') {
+ if ((c = nextc()) == '|') {
SET_LEX_STATE(EXPR_BEG);
- if ((c = nextc(p)) == '=') {
- set_yylval_id(idOROP);
+ if ((c = nextc()) == '=') {
+ set_yylval_id(tOROP);
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- pushback(p, c);
- if (IS_lex_state_for(last_state, EXPR_BEG)) {
- c = '|';
- pushback(p, '|');
- return c;
- }
+ pushback(c);
return tOROP;
}
if (c == '=') {
@@ -9202,17 +8641,17 @@ parser_yylex(struct parser_params *p)
return tOP_ASGN;
}
SET_LEX_STATE(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG|EXPR_LABEL);
- pushback(p, c);
+ pushback(c);
return '|';
case '+':
- c = nextc(p);
+ c = nextc();
if (IS_AFTER_OPERATOR()) {
SET_LEX_STATE(EXPR_ARG);
if (c == '@') {
return tUPLUS;
}
- pushback(p, c);
+ pushback(c);
return '+';
}
if (c == '=') {
@@ -9220,26 +8659,26 @@ parser_yylex(struct parser_params *p)
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- if (IS_BEG() || (IS_SPCARG(c) && arg_ambiguous(p, '+'))) {
+ if (IS_BEG() || (IS_SPCARG(c) && arg_ambiguous('+'))) {
SET_LEX_STATE(EXPR_BEG);
- pushback(p, c);
+ pushback(c);
if (c != -1 && ISDIGIT(c)) {
- return parse_numeric(p, '+');
+ return parse_numeric(parser, '+');
}
return tUPLUS;
}
SET_LEX_STATE(EXPR_BEG);
- pushback(p, c);
+ pushback(c);
return warn_balanced('+', "+", "unary operator");
case '-':
- c = nextc(p);
+ c = nextc();
if (IS_AFTER_OPERATOR()) {
SET_LEX_STATE(EXPR_ARG);
if (c == '@') {
return tUMINUS;
}
- pushback(p, c);
+ pushback(c);
return '-';
}
if (c == '=') {
@@ -9249,105 +8688,81 @@ parser_yylex(struct parser_params *p)
}
if (c == '>') {
SET_LEX_STATE(EXPR_ENDFN);
+ token_info_push("->");
return tLAMBDA;
}
- if (IS_BEG() || (IS_SPCARG(c) && arg_ambiguous(p, '-'))) {
+ if (IS_BEG() || (IS_SPCARG(c) && arg_ambiguous('-'))) {
SET_LEX_STATE(EXPR_BEG);
- pushback(p, c);
+ pushback(c);
if (c != -1 && ISDIGIT(c)) {
return tUMINUS_NUM;
}
return tUMINUS;
}
SET_LEX_STATE(EXPR_BEG);
- pushback(p, c);
+ pushback(c);
return warn_balanced('-', "-", "unary operator");
- case '.': {
- int is_beg = IS_BEG();
+ case '.':
SET_LEX_STATE(EXPR_BEG);
- if ((c = nextc(p)) == '.') {
- if ((c = nextc(p)) == '.') {
- if (p->lex.paren_nest == 0 && looking_at_eol_p(p)) {
- rb_warn0("... at EOL, should be parenthesized?");
- }
- return is_beg ? tBDOT3 : tDOT3;
+ if ((c = nextc()) == '.') {
+ if ((c = nextc()) == '.') {
+ return tDOT3;
}
- pushback(p, c);
- return is_beg ? tBDOT2 : tDOT2;
+ pushback(c);
+ return tDOT2;
}
- pushback(p, c);
+ pushback(c);
if (c != -1 && ISDIGIT(c)) {
- char prev = p->lex.pcur-1 > p->lex.pbeg ? *(p->lex.pcur-2) : 0;
- parse_numeric(p, '.');
- if (ISDIGIT(prev)) {
- yyerror0("unexpected fraction part after numeric literal");
- }
- else {
- yyerror0("no .<digit> floating literal anymore; put 0 before dot");
- }
- SET_LEX_STATE(EXPR_END);
- p->lex.ptok = p->lex.pcur;
- goto retry;
+ yyerror0("no .<digit> floating literal anymore; put 0 before dot");
}
- set_yylval_id('.');
SET_LEX_STATE(EXPR_DOT);
return '.';
- }
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- return parse_numeric(p, c);
+ return parse_numeric(parser, c);
case ')':
- COND_POP();
- CMDARG_POP();
- SET_LEX_STATE(EXPR_ENDFN);
- p->lex.paren_nest--;
- return c;
-
case ']':
- COND_POP();
- CMDARG_POP();
- SET_LEX_STATE(EXPR_END);
- p->lex.paren_nest--;
- return c;
-
+ paren_nest--;
case '}':
- /* tSTRING_DEND does COND_POP and CMDARG_POP in the yacc's rule */
- if (!p->lex.brace_nest--) return tSTRING_DEND;
- COND_POP();
- CMDARG_POP();
- SET_LEX_STATE(EXPR_END);
- p->lex.paren_nest--;
+ COND_LEXPOP();
+ CMDARG_LEXPOP();
+ if (c == ')')
+ SET_LEX_STATE(EXPR_ENDFN);
+ else
+ SET_LEX_STATE(EXPR_END);
+ if (c == '}') {
+ if (!brace_nest--) c = tSTRING_DEND;
+ }
return c;
case ':':
- c = nextc(p);
+ c = nextc();
if (c == ':') {
if (IS_BEG() || IS_lex_state(EXPR_CLASS) || IS_SPCARG(-1)) {
SET_LEX_STATE(EXPR_BEG);
return tCOLON3;
}
- set_yylval_id(idCOLON2);
SET_LEX_STATE(EXPR_DOT);
return tCOLON2;
}
if (IS_END() || ISSPACE(c) || c == '#') {
- pushback(p, c);
+ pushback(c);
c = warn_balanced(':', ":", "symbol literal");
SET_LEX_STATE(EXPR_BEG);
return c;
}
switch (c) {
case '\'':
- p->lex.strterm = NEW_STRTERM(str_ssym, c, 0);
+ lex_strterm = NEW_STRTERM(str_ssym, c, 0);
break;
case '"':
- p->lex.strterm = NEW_STRTERM(str_dsym, c, 0);
+ lex_strterm = NEW_STRTERM(str_dsym, c, 0);
break;
default:
- pushback(p, c);
+ pushback(c);
break;
}
SET_LEX_STATE(EXPR_FNAME);
@@ -9355,36 +8770,36 @@ parser_yylex(struct parser_params *p)
case '/':
if (IS_BEG()) {
- p->lex.strterm = NEW_STRTERM(str_regexp, '/', 0);
+ lex_strterm = NEW_STRTERM(str_regexp, '/', 0);
return tREGEXP_BEG;
}
- if ((c = nextc(p)) == '=') {
+ if ((c = nextc()) == '=') {
set_yylval_id('/');
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- pushback(p, c);
+ pushback(c);
if (IS_SPCARG(c)) {
- arg_ambiguous(p, '/');
- p->lex.strterm = NEW_STRTERM(str_regexp, '/', 0);
+ (void)arg_ambiguous('/');
+ lex_strterm = NEW_STRTERM(str_regexp, '/', 0);
return tREGEXP_BEG;
}
SET_LEX_STATE(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
return warn_balanced('/', "/", "regexp literal");
case '^':
- if ((c = nextc(p)) == '=') {
+ if ((c = nextc()) == '=') {
set_yylval_id('^');
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
SET_LEX_STATE(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
- pushback(p, c);
+ pushback(c);
return '^';
case ';':
SET_LEX_STATE(EXPR_BEG);
- p->command_start = TRUE;
+ command_start = TRUE;
return ';';
case ',':
@@ -9393,8 +8808,8 @@ parser_yylex(struct parser_params *p)
case '~':
if (IS_AFTER_OPERATOR()) {
- if ((c = nextc(p)) != '@') {
- pushback(p, c);
+ if ((c = nextc()) != '@') {
+ pushback(c);
}
SET_LEX_STATE(EXPR_ARG);
}
@@ -9417,24 +8832,24 @@ parser_yylex(struct parser_params *p)
rb_warning0("parentheses after method name is interpreted as "
"an argument list, not a decomposed argument");
}
- p->lex.paren_nest++;
+ paren_nest++;
COND_PUSH(0);
CMDARG_PUSH(0);
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
return c;
case '[':
- p->lex.paren_nest++;
+ paren_nest++;
if (IS_AFTER_OPERATOR()) {
- if ((c = nextc(p)) == ']') {
+ if ((c = nextc()) == ']') {
SET_LEX_STATE(EXPR_ARG);
- if ((c = nextc(p)) == '=') {
+ if ((c = nextc()) == '=') {
return tASET;
}
- pushback(p, c);
+ pushback(c);
return tAREF;
}
- pushback(p, c);
+ pushback(c);
SET_LEX_STATE(EXPR_ARG|EXPR_LABEL);
return '[';
}
@@ -9450,10 +8865,16 @@ parser_yylex(struct parser_params *p)
return c;
case '{':
- ++p->lex.brace_nest;
- if (lambda_beginning_p())
- c = tLAMBEG;
- else if (IS_lex_state(EXPR_LABELED))
+ ++brace_nest;
+ if (lambda_beginning_p()) {
+ SET_LEX_STATE(EXPR_BEG);
+ lpar_beg = 0;
+ --paren_nest;
+ COND_PUSH(0);
+ CMDARG_PUSH(0);
+ return tLAMBEG;
+ }
+ if (IS_lex_state(EXPR_LABELED))
c = tLBRACE; /* hash */
else if (IS_lex_state(EXPR_ARG_ANY | EXPR_END | EXPR_ENDFN))
c = '{'; /* block (primary) */
@@ -9461,112 +8882,98 @@ parser_yylex(struct parser_params *p)
c = tLBRACE_ARG; /* block (expr) */
else
c = tLBRACE; /* hash */
- if (c != tLBRACE) {
- p->command_start = TRUE;
- SET_LEX_STATE(EXPR_BEG);
- }
- else {
- SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
- }
- ++p->lex.paren_nest; /* after lambda_beginning_p() */
COND_PUSH(0);
CMDARG_PUSH(0);
+ SET_LEX_STATE(c == tLBRACE_ARG ? EXPR_BEG : EXPR_BEG|EXPR_LABEL);
+ if (c != tLBRACE) command_start = TRUE;
return c;
case '\\':
- c = nextc(p);
+ c = nextc();
if (c == '\n') {
space_seen = 1;
- dispatch_scan_event(p, tSP);
+ dispatch_scan_event(tSP);
goto retry; /* skip \\n */
}
- if (c == ' ') return tSP;
- if (ISSPACE(c)) return c;
- pushback(p, c);
+ pushback(c);
return '\\';
case '%':
- return parse_percent(p, space_seen, last_state);
+ return parse_percent(parser, space_seen, last_state);
case '$':
- return parse_gvar(p, last_state);
+ return parse_gvar(parser, last_state);
case '@':
- return parse_atmark(p, last_state);
+ return parse_atmark(parser, last_state);
case '_':
- if (was_bol(p) && whole_match_p(p, "__END__", 7, 0)) {
- p->ruby__end__seen = 1;
- p->eofp = 1;
+ if (was_bol() && whole_match_p("__END__", 7, 0)) {
+ ruby__end__seen = 1;
+ parser->eofp = 1;
#ifndef RIPPER
return -1;
#else
- lex_goto_eol(p);
- dispatch_scan_event(p, k__END__);
+ lex_goto_eol(parser);
+ dispatch_scan_event(k__END__);
return 0;
#endif
}
- newtok(p);
+ newtok();
break;
default:
- if (!parser_is_identchar(p)) {
- compile_error(p, "Invalid char `\\x%02X' in expression", c);
- token_flush(p);
+ if (!parser_is_identchar()) {
+ compile_error(PARSER_ARG "Invalid char `\\x%02X' in expression", c);
goto retry;
}
- newtok(p);
+ newtok();
break;
}
- return parse_ident(p, c, cmd_state);
+ return parse_ident(parser, c, cmd_state);
}
static enum yytokentype
-yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *p)
+yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *parser)
{
enum yytokentype t;
- p->lval = lval;
+ parser->lval = lval;
lval->val = Qundef;
- t = parser_yylex(p);
+ t = parser_yylex(parser);
+ if (has_delayed_token())
+ dispatch_delayed_token(t);
+ else if (t != 0)
+ dispatch_scan_event(t);
- if (p->lex.strterm && (p->lex.strterm->flags & STRTERM_HEREDOC))
+ if (lex_strterm && (lex_strterm->flags & STRTERM_HEREDOC))
RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(*yylloc);
else
RUBY_SET_YYLLOC(*yylloc);
- if (has_delayed_token(p))
- dispatch_delayed_token(p, t);
- else if (t != 0)
- dispatch_scan_event(p, t);
-
return t;
}
#define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
static NODE*
-node_newnode(struct parser_params *p, enum node_type type, VALUE a0, VALUE a1, VALUE a2, const rb_code_location_t *loc)
+node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
{
- NODE *n = rb_ast_newnode(p->ast, type);
+ NODE *n = rb_ast_newnode(parser->ast);
rb_node_init(n, type, a0, a1, a2);
- nd_set_loc(n, loc);
- nd_set_node_id(n, parser_get_node_id(p));
+ nd_set_line(n, ruby_sourceline);
+ /* mark not cared lineno to 0 and column to -1 */
+ nd_set_first_lineno(n, 0);
+ nd_set_first_column(n, -1);
+ nd_set_last_lineno(n, 0);
+ nd_set_last_column(n, -1);
return n;
}
-static NODE *
-nd_set_loc(NODE *nd, const YYLTYPE *loc)
-{
- nd->nd_loc = *loc;
- nd_set_line(nd, loc->beg_pos.lineno);
- return nd;
-}
-
#ifndef RIPPER
static enum node_type
nodetype(NODE *node) /* for debug */
@@ -9599,19 +9006,29 @@ fixpos(NODE *node, NODE *orig)
}
static void
-parser_warning(struct parser_params *p, NODE *node, const char *mesg)
+parser_warning(struct parser_params *parser, NODE *node, const char *mesg)
{
- rb_compile_warning(p->ruby_sourcefile, nd_line(node), "%s", mesg);
+ rb_compile_warning(ruby_sourcefile, nd_line(node), "%s", mesg);
}
+#define parser_warning(node, mesg) parser_warning(parser, (node), (mesg))
static void
-parser_warn(struct parser_params *p, NODE *node, const char *mesg)
+parser_warn(struct parser_params *parser, NODE *node, const char *mesg)
+{
+ rb_compile_warn(ruby_sourcefile, nd_line(node), "%s", mesg);
+}
+#define parser_warn(node, mesg) parser_warn(parser, (node), (mesg))
+
+static NODE *
+nd_set_loc(NODE *nd, const YYLTYPE *location)
{
- rb_compile_warn(p->ruby_sourcefile, nd_line(node), "%s", mesg);
+ nd->nd_loc = *location;
+ nd_set_line(nd, location->first_loc.lineno);
+ return nd;
}
static NODE*
-block_append(struct parser_params *p, NODE *head, NODE *tail)
+block_append_gen(struct parser_params *parser, NODE *head, NODE *tail, const YYLTYPE *location)
{
NODE *end, *h = head, *nd;
@@ -9625,11 +9042,12 @@ block_append(struct parser_params *p, NODE *head, NODE *tail)
case NODE_TRUE:
case NODE_FALSE:
case NODE_NIL:
- parser_warning(p, h, "unused literal ignored");
+ parser_warning(h, "unused literal ignored");
return tail;
default:
- h = end = NEW_BLOCK(head, &head->nd_loc);
+ h = end = NEW_BLOCK(head);
end->nd_end = end;
+ nd_set_loc(end, location);
head = end;
break;
case NODE_BLOCK:
@@ -9645,7 +9063,7 @@ block_append(struct parser_params *p, NODE *head, NODE *tail)
case NODE_REDO:
case NODE_RETRY:
if (RTEST(ruby_verbose)) {
- parser_warning(p, tail, "statement not reached");
+ parser_warning(tail, "statement not reached");
}
break;
@@ -9654,7 +9072,8 @@ block_append(struct parser_params *p, NODE *head, NODE *tail)
}
if (nd_type(tail) != NODE_BLOCK) {
- tail = NEW_BLOCK(tail, &tail->nd_loc);
+ tail = NEW_BLOCK(tail);
+ nd_set_loc(tail, location);
tail->nd_end = tail;
}
end->nd_next = tail;
@@ -9665,11 +9084,11 @@ block_append(struct parser_params *p, NODE *head, NODE *tail)
/* append item to the list */
static NODE*
-list_append(struct parser_params *p, NODE *list, NODE *item)
+list_append_gen(struct parser_params *parser, NODE *list, NODE *item)
{
NODE *last;
- if (list == 0) return NEW_LIST(item, &item->nd_loc);
+ if (list == 0) return new_list(item, &item->nd_loc);
if (list->nd_next) {
last = list->nd_next->nd_end;
}
@@ -9678,7 +9097,7 @@ list_append(struct parser_params *p, NODE *list, NODE *item)
}
list->nd_alen += 1;
- last->nd_next = NEW_LIST(item, &item->nd_loc);
+ last->nd_next = new_list(item, &item->nd_loc);
list->nd_next->nd_end = last->nd_next;
nd_set_last_loc(list, nd_last_loc(item));
@@ -9714,11 +9133,11 @@ list_concat(NODE *head, NODE *tail)
}
static int
-literal_concat0(struct parser_params *p, VALUE head, VALUE tail)
+literal_concat0(struct parser_params *parser, VALUE head, VALUE tail)
{
if (NIL_P(tail)) return 1;
if (!rb_enc_compatible(head, tail)) {
- compile_error(p, "string literal encodings differ (%s / %s)",
+ compile_error(PARSER_ARG "string literal encodings differ (%s / %s)",
rb_enc_name(rb_enc_get(head)),
rb_enc_name(rb_enc_get(tail)));
rb_str_resize(head, 0);
@@ -9731,7 +9150,7 @@ literal_concat0(struct parser_params *p, VALUE head, VALUE tail)
/* concat two string literals */
static NODE *
-literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *loc)
+literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const YYLTYPE *location)
{
enum node_type htype;
NODE *headlast;
@@ -9742,17 +9161,16 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
htype = nd_type(head);
if (htype == NODE_EVSTR) {
- NODE *node = NEW_DSTR(STR_NEW0(), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
- head = list_append(p, node, head);
+ NODE *node = new_dstr(STR_NEW0(), location);
+ head = list_append(node, head);
htype = NODE_DSTR;
}
- if (p->heredoc_indent > 0) {
+ if (heredoc_indent > 0) {
switch (htype) {
case NODE_STR:
nd_set_type(head, NODE_DSTR);
case NODE_DSTR:
- return list_append(p, head, tail);
+ return list_append(head, tail);
default:
break;
}
@@ -9768,25 +9186,25 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
lit = head->nd_lit;
}
if (htype == NODE_STR) {
- if (!literal_concat0(p, lit, tail->nd_lit)) {
+ if (!literal_concat0(parser, lit, tail->nd_lit)) {
error:
- rb_discard_node(p, head);
- rb_discard_node(p, tail);
+ rb_discard_node(head);
+ rb_discard_node(tail);
return 0;
}
- rb_discard_node(p, tail);
+ rb_discard_node(tail);
}
else {
- list_append(p, head, tail);
+ list_append(head, tail);
}
break;
case NODE_DSTR:
if (htype == NODE_STR) {
- if (!literal_concat0(p, head->nd_lit, tail->nd_lit))
+ if (!literal_concat0(parser, head->nd_lit, tail->nd_lit))
goto error;
tail->nd_lit = head->nd_lit;
- rb_discard_node(p, head);
+ rb_discard_node(head);
head = tail;
}
else if (NIL_P(tail->nd_lit)) {
@@ -9794,18 +9212,20 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
head->nd_alen += tail->nd_alen - 1;
head->nd_next->nd_end->nd_next = tail->nd_next;
head->nd_next->nd_end = tail->nd_next->nd_end;
- rb_discard_node(p, tail);
+ rb_discard_node(tail);
}
else if (htype == NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
nd_type(headlast) == NODE_STR) {
lit = headlast->nd_lit;
- if (!literal_concat0(p, lit, tail->nd_lit))
+ if (!literal_concat0(parser, lit, tail->nd_lit))
goto error;
tail->nd_lit = Qnil;
goto append;
}
else {
- list_concat(head, NEW_NODE(NODE_LIST, NEW_STR(tail->nd_lit, loc), tail->nd_alen, tail->nd_next, loc));
+ nd_set_type(tail, NODE_ARRAY);
+ tail->nd_head = new_str(tail->nd_lit, location);
+ list_concat(head, tail);
}
break;
@@ -9814,27 +9234,26 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
nd_set_type(head, NODE_DSTR);
head->nd_alen = 1;
}
- list_append(p, head, tail);
+ list_append(head, tail);
break;
}
return head;
}
static NODE *
-evstr2dstr(struct parser_params *p, NODE *node)
+evstr2dstr_gen(struct parser_params *parser, NODE *node)
{
if (nd_type(node) == NODE_EVSTR) {
- NODE * dstr = NEW_DSTR(STR_NEW0(), &node->nd_loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, dstr->nd_lit);
- node = list_append(p, dstr, node);
+ node = list_append(new_dstr(STR_NEW0(), &node->nd_loc), node);
}
return node;
}
static NODE *
-new_evstr(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+new_evstr_gen(struct parser_params *parser, NODE *node, const YYLTYPE *location)
{
NODE *head = node;
+ NODE *evstr;
if (node) {
switch (nd_type(node)) {
@@ -9842,56 +9261,49 @@ new_evstr(struct parser_params *p, NODE *node, const YYLTYPE *loc)
return node;
}
}
- return NEW_EVSTR(head, loc);
+ evstr = NEW_EVSTR(head);
+ nd_set_loc(evstr, location);
+ return evstr;
}
static NODE *
-call_bin_op(struct parser_params *p, NODE *recv, ID id, NODE *arg1,
- const YYLTYPE *op_loc, const YYLTYPE *loc)
+call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1,
+ const YYLTYPE *op_loc, const YYLTYPE *location)
{
NODE *expr;
value_expr(recv);
value_expr(arg1);
- expr = NEW_OPCALL(recv, id, NEW_LIST(arg1, &arg1->nd_loc), loc);
- nd_set_line(expr, op_loc->beg_pos.lineno);
+ expr = NEW_OPCALL(recv, id, new_list(arg1, &arg1->nd_loc));
+ nd_set_line(expr, op_loc->first_loc.lineno);
+ expr->nd_loc = *location;
return expr;
}
static NODE *
-call_uni_op(struct parser_params *p, NODE *recv, ID id, const YYLTYPE *op_loc, const YYLTYPE *loc)
+call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, const YYLTYPE *op_loc, const YYLTYPE *location)
{
NODE *opcall;
value_expr(recv);
- opcall = NEW_OPCALL(recv, id, 0, loc);
- nd_set_line(opcall, op_loc->beg_pos.lineno);
+ opcall = NEW_OPCALL(recv, id, 0);
+ opcall->nd_loc = *location;
+ nd_set_line(opcall, op_loc->first_loc.lineno);
return opcall;
}
static NODE *
-new_qcall(struct parser_params* p, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_loc, const YYLTYPE *loc)
+new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *location)
{
- NODE *qcall = NEW_QCALL(atype, recv, mid, args, loc);
- nd_set_line(qcall, op_loc->beg_pos.lineno);
+ NODE *qcall = NEW_QCALL(atype, recv, mid, args);
+ qcall->nd_loc = *location;
return qcall;
}
+#define nd_once_body(node) (nd_type(node) == NODE_SCOPE ? (node)->nd_body : node)
static NODE*
-new_command_qcall(struct parser_params* p, ID atype, NODE *recv, ID mid, NODE *args, NODE *block, const YYLTYPE *op_loc, const YYLTYPE *loc)
-{
- NODE *ret;
- if (block) block_dup_check(p, args, block);
- ret = new_qcall(p, atype, recv, mid, args, op_loc, loc);
- if (block) ret = method_add_block(p, ret, block, loc);
- fixpos(ret, recv);
- return ret;
-}
-
-#define nd_once_body(node) (nd_type(node) == NODE_ONCE ? (node)->nd_body : node)
-static NODE*
-match_op(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *op_loc, const YYLTYPE *loc)
+match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *op_loc, const YYLTYPE *location)
{
NODE *n;
- int line = op_loc->beg_pos.lineno;
+ int line = op_loc->first_loc.lineno;
value_expr(node1);
value_expr(node2);
@@ -9899,7 +9311,8 @@ match_op(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *op_lo
switch (nd_type(n)) {
case NODE_DREGX:
{
- NODE *match = NEW_MATCH2(node1, node2, loc);
+ NODE *match = NEW_MATCH2(node1, node2);
+ match->nd_loc = *location;
nd_set_line(match, line);
return match;
}
@@ -9907,8 +9320,9 @@ match_op(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *op_lo
case NODE_LIT:
if (RB_TYPE_P(n->nd_lit, T_REGEXP)) {
const VALUE lit = n->nd_lit;
- NODE *match = NEW_MATCH2(node1, node2, loc);
- match->nd_args = reg_named_capture_assign(p, lit, loc);
+ NODE *match = NEW_MATCH2(node1, node2);
+ match->nd_args = reg_named_capture_assign(lit, location);
+ match->nd_loc = *location;
nd_set_line(match, line);
return match;
}
@@ -9923,21 +9337,23 @@ match_op(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *op_lo
if (!RB_TYPE_P(n->nd_lit, T_REGEXP)) break;
/* fallthru */
case NODE_DREGX:
- match3 = NEW_MATCH3(node2, node1, loc);
+ match3 = NEW_MATCH3(node2, node1);
+ match3->nd_loc = *location;
+ nd_set_line(match3, line);
return match3;
}
}
- n = NEW_CALL(node1, tMATCH, NEW_LIST(node2, &node2->nd_loc), loc);
+ n = new_call(node1, tMATCH, new_list(node2, &node2->nd_loc), location);
nd_set_line(n, line);
return n;
}
# if WARN_PAST_SCOPE
static int
-past_dvar_p(struct parser_params *p, ID id)
+past_dvar_p(struct parser_params *parser, ID id)
{
- struct vtable *past = p->lvtbl->past;
+ struct vtable *past = lvtbl->past;
while (past) {
if (vtable_included(past, id)) return 1;
past = past->prev;
@@ -9946,118 +9362,79 @@ past_dvar_p(struct parser_params *p, ID id)
}
# endif
-/* As Ripper#warn does not have arguments for the location, so the
- * following messages cannot be separated */
-#define WARN_LOCATION(type) do { \
- if (p->warn_location) { \
- int line; \
- VALUE file = rb_source_location(&line); \
- rb_warn3(type" in eval may not return location in binding;" \
- " use Binding#source_location instead\n" \
- "%"PRIsWARN":%d: warning: in `%"PRIsWARN"'", \
- file, WARN_I(line), rb_id2str(rb_frame_this_func())); \
- } \
-} while (0)
-
-static int
-numparam_nested_p(struct parser_params *p)
-{
- struct local_vars *local = p->lvtbl;
- NODE *outer = local->numparam.outer;
- NODE *inner = local->numparam.inner;
- if (outer || inner) {
- NODE *used = outer ? outer : inner;
- compile_error(p, "numbered parameter is already used in\n"
- "%s:%d: %s block here",
- p->ruby_sourcefile, nd_line(used),
- outer ? "outer" : "inner");
- parser_show_error_line(p, &used->nd_loc);
- return 1;
- }
- return 0;
-}
-
static NODE*
-gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
+gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *location)
{
ID *vidp = NULL;
NODE *node;
switch (id) {
case keyword_self:
- return NEW_SELF(loc);
+ node = NEW_SELF();
+ nd_set_loc(node, location);
+ return node;
case keyword_nil:
- return NEW_NIL(loc);
+ node = NEW_NIL();
+ nd_set_loc(node, location);
+ return node;
case keyword_true:
- return NEW_TRUE(loc);
+ node = NEW_TRUE();
+ nd_set_loc(node, location);
+ return node;
case keyword_false:
- return NEW_FALSE(loc);
+ node = NEW_FALSE();
+ nd_set_loc(node, location);
+ return node;
case keyword__FILE__:
- WARN_LOCATION("__FILE__");
- {
- VALUE file = p->ruby_sourcefile_string;
- if (NIL_P(file))
- file = rb_str_new(0, 0);
- else
- file = rb_str_dup(file);
- node = NEW_STR(file, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, file);
- }
+ node = new_str(rb_str_dup(ruby_sourcefile_string), location);
return node;
case keyword__LINE__:
- WARN_LOCATION("__LINE__");
- return NEW_LIT(INT2FIX(p->tokline), loc);
+ return new_lit(INT2FIX(tokline), location);
case keyword__ENCODING__:
- node = NEW_LIT(rb_enc_from_encoding(p->enc), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
- return node;
-
+ return new_lit(rb_enc_from_encoding(current_enc), location);
}
switch (id_type(id)) {
case ID_LOCAL:
- if (dyna_in_block(p) && dvar_defined_ref(p, id, &vidp)) {
- if (NUMPARAM_ID_P(id) && numparam_nested_p(p)) return 0;
- if (id == p->cur_arg) {
- compile_error(p, "circular argument reference - %"PRIsWARN, rb_id2str(id));
- return 0;
+ if (dyna_in_block() && dvar_defined_ref(id, vidp)) {
+ if (id == current_arg) {
+ rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id));
}
if (vidp) *vidp |= LVAR_USED;
- node = NEW_DVAR(id, loc);
+ node = new_dvar(id, location);
return node;
}
- if (local_id_ref(p, id, &vidp)) {
- if (id == p->cur_arg) {
- compile_error(p, "circular argument reference - %"PRIsWARN, rb_id2str(id));
- return 0;
+ if (local_id_ref(id, vidp)) {
+ if (id == current_arg) {
+ rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id));
}
if (vidp) *vidp |= LVAR_USED;
- node = NEW_LVAR(id, loc);
- return node;
- }
- if (dyna_in_block(p) && NUMPARAM_ID_P(id) &&
- parser_numbered_param(p, NUMPARAM_ID_TO_IDX(id))) {
- if (numparam_nested_p(p)) return 0;
- node = NEW_DVAR(id, loc);
- struct local_vars *local = p->lvtbl;
- if (!local->numparam.current) local->numparam.current = node;
+ node = new_lvar(id, location);
return node;
}
# if WARN_PAST_SCOPE
- if (!p->in_defined && RTEST(ruby_verbose) && past_dvar_p(p, id)) {
+ if (!in_defined && RTEST(ruby_verbose) && past_dvar_p(parser, id)) {
rb_warning1("possible reference to past scope - %"PRIsWARN, rb_id2str(id));
}
# endif
/* method call without arguments */
- return NEW_VCALL(id, loc);
+ node = NEW_VCALL(id);
+ nd_set_loc(node, location);
+ return node;
case ID_GLOBAL:
- return NEW_GVAR(id, loc);
+ node = new_gvar(id, location);
+ return node;
case ID_INSTANCE:
- return NEW_IVAR(id, loc);
+ node = new_ivar(id, location);
+ return node;
case ID_CONST:
- return NEW_CONST(id, loc);
+ node = NEW_CONST(id);
+ nd_set_loc(node, location);
+ return node;
case ID_CLASS:
- return NEW_CVAR(id, loc);
+ node = NEW_CVAR(id);
+ nd_set_loc(node, location);
+ return node;
}
- compile_error(p, "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id));
+ compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id));
return 0;
}
@@ -10065,11 +9442,11 @@ static NODE *
opt_arg_append(NODE *opt_list, NODE *opt)
{
NODE *opts = opt_list;
- opts->nd_loc.end_pos = opt->nd_loc.end_pos;
+ opts->nd_loc.last_loc = opt->nd_loc.last_loc;
while (opts->nd_next) {
opts = opts->nd_next;
- opts->nd_loc.end_pos = opt->nd_loc.end_pos;
+ opts->nd_loc.last_loc = opt->nd_loc.last_loc;
}
opts->nd_next = opt;
@@ -10081,10 +9458,10 @@ kwd_append(NODE *kwlist, NODE *kw)
{
if (kwlist) {
NODE *kws = kwlist;
- kws->nd_loc.end_pos = kw->nd_loc.end_pos;
+ kws->nd_loc.last_loc = kw->nd_loc.last_loc;
while (kws->nd_next) {
kws = kws->nd_next;
- kws->nd_loc.end_pos = kw->nd_loc.end_pos;
+ kws->nd_loc.last_loc = kw->nd_loc.last_loc;
}
kws->nd_next = kw;
}
@@ -10092,66 +9469,51 @@ kwd_append(NODE *kwlist, NODE *kw)
}
static NODE *
-new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc)
+new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *location)
{
- return NEW_DEFINED(remove_begin_all(expr), loc);
-}
-
-static NODE*
-symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol)
-{
- if (nd_type(symbol) == NODE_DSTR) {
- nd_set_type(symbol, NODE_DSYM);
- }
- else {
- nd_set_type(symbol, NODE_LIT);
- RB_OBJ_WRITTEN(p->ast, Qnil, symbol->nd_lit = rb_str_intern(symbol->nd_lit));
- }
- return list_append(p, symbols, symbol);
+ NODE *defined = NEW_DEFINED(remove_begin_all(expr));
+ nd_set_loc(defined, location);
+ return defined;
}
static NODE *
-new_regexp(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc)
+new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLTYPE *location)
{
NODE *list, *prev;
VALUE lit;
if (!node) {
- node = NEW_LIT(reg_compile(p, STR_NEW0(), options), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
- return node;
+ return new_lit(reg_compile(STR_NEW0(), options), location);
}
switch (nd_type(node)) {
case NODE_STR:
{
VALUE src = node->nd_lit;
nd_set_type(node, NODE_LIT);
- nd_set_loc(node, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit = reg_compile(p, src, options));
+ nd_set_loc(node, location);
+ add_mark_object(node->nd_lit = reg_compile(src, options));
}
break;
default:
- lit = STR_NEW0();
- node = NEW_NODE(NODE_DSTR, lit, 1, NEW_LIST(node, loc), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, lit);
- /* fall through */
+ add_mark_object(lit = STR_NEW0());
+ node = NEW_NODE(NODE_DSTR, lit, 1, new_list(node, location));
case NODE_DSTR:
nd_set_type(node, NODE_DREGX);
- nd_set_loc(node, loc);
+ nd_set_loc(node, location);
node->nd_cflag = options & RE_OPTION_MASK;
- if (!NIL_P(node->nd_lit)) reg_fragment_check(p, node->nd_lit, options);
+ if (!NIL_P(node->nd_lit)) reg_fragment_check(node->nd_lit, options);
for (list = (prev = node)->nd_next; list; list = list->nd_next) {
if (nd_type(list->nd_head) == NODE_STR) {
VALUE tail = list->nd_head->nd_lit;
- if (reg_fragment_check(p, tail, options) && prev && !NIL_P(prev->nd_lit)) {
+ if (reg_fragment_check(tail, options) && prev && !NIL_P(prev->nd_lit)) {
VALUE lit = prev == node ? prev->nd_lit : prev->nd_head->nd_lit;
- if (!literal_concat0(p, lit, tail)) {
- return NEW_NIL(loc); /* dummy node on error */
+ if (!literal_concat0(parser, lit, tail)) {
+ return NEW_NIL(); /* dummy node on error */
}
rb_str_resize(tail, 0);
prev->nd_next = list->nd_next;
- rb_discard_node(p, list->nd_head);
- rb_discard_node(p, list);
+ rb_discard_node(list->nd_head);
+ rb_discard_node(list);
list = prev;
}
else {
@@ -10165,10 +9527,11 @@ new_regexp(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc)
if (!node->nd_next) {
VALUE src = node->nd_lit;
nd_set_type(node, NODE_LIT);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit = reg_compile(p, src, options));
+ add_mark_object(node->nd_lit = reg_compile(src, options));
}
if (options & RE_OPTION_ONCE) {
- node = NEW_NODE(NODE_ONCE, 0, node, 0, loc);
+ node = NEW_NODE(NODE_SCOPE, 0, node, 0);
+ nd_set_loc(node, location);
}
break;
}
@@ -10176,87 +9539,244 @@ new_regexp(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc)
}
static NODE *
-new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc)
+new_lit_gen(struct parser_params *parser, VALUE sym, const YYLTYPE *location)
+{
+ NODE *lit = NEW_LIT(sym);
+ add_mark_object(sym);
+ nd_set_loc(lit, location);
+ return lit;
+}
+
+static NODE *
+new_list_gen(struct parser_params *parser, NODE *item, const YYLTYPE *location)
+{
+ NODE *list = NEW_LIST(item);
+ nd_set_loc(list, location);
+ return list;
+}
+
+static NODE *
+new_str_gen(struct parser_params *parser, VALUE str, const YYLTYPE *location)
+{
+ NODE *nd_str = NEW_STR(str);
+ add_mark_object(str);
+ nd_set_loc(nd_str, location);
+ return nd_str;
+}
+
+static NODE *
+new_dvar_gen(struct parser_params *parser, ID id, const YYLTYPE *location)
+{
+ NODE *dvar = NEW_DVAR(id);
+ nd_set_loc(dvar, location);
+ return dvar;
+}
+
+static NODE *
+new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, const YYLTYPE *location)
+{
+ NODE *resbody = NEW_RESBODY(exc_list, stmt, rescue);
+ nd_set_loc(resbody, location);
+ return resbody;
+}
+
+static NODE *
+new_errinfo_gen(struct parser_params *parser, const YYLTYPE *location)
+{
+ NODE *errinfo = NEW_ERRINFO();
+ nd_set_loc(errinfo, location);
+ return errinfo;
+}
+
+static NODE *
+new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, const YYLTYPE *location)
+{
+ NODE *call = NEW_CALL(recv, mid, args);
+ nd_set_loc(call, location);
+ return call;
+}
+
+static NODE *
+new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, const YYLTYPE *location)
+{
+ NODE *fcall = NEW_FCALL(mid, args);
+ nd_set_loc(fcall, location);
+ return fcall;
+}
+
+static NODE *
+new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, const YYLTYPE *location)
+{
+ NODE *nd_for = NEW_FOR(var, iter, body);
+ nd_set_loc(nd_for, location);
+ return nd_for;
+}
+
+static NODE *
+new_gvar_gen(struct parser_params *parser, ID id, const YYLTYPE *location)
+{
+ NODE *gvar = NEW_GVAR(id);
+ nd_set_loc(gvar, location);
+ return gvar;
+}
+
+static NODE *
+new_lvar_gen(struct parser_params *parser, ID id, const YYLTYPE *location)
+{
+ NODE *lvar = NEW_LVAR(id);
+ nd_set_loc(lvar, location);
+ return lvar;
+}
+
+static NODE *
+new_dstr_gen(struct parser_params *parser, VALUE str, const YYLTYPE *location)
+{
+ NODE *dstr = NEW_DSTR(str);
+ add_mark_object(str);
+ nd_set_loc(dstr, location);
+ return dstr;
+}
+
+static NODE *
+new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, const YYLTYPE *location)
+{
+ NODE *rescue = NEW_RESCUE(b, res, e);
+ nd_set_loc(rescue, location);
+ return rescue;
+}
+
+static NODE *
+new_undef_gen(struct parser_params *parser, NODE *i, const YYLTYPE *location)
+{
+ NODE *undef = NEW_UNDEF(i);
+ nd_set_loc(undef, location);
+ return undef;
+}
+
+static NODE *
+new_zarray_gen(struct parser_params *parser, const YYLTYPE *location)
+{
+ NODE *zarray = NEW_ZARRAY();
+ nd_set_loc(zarray, location);
+ return zarray;
+}
+
+static NODE *
+new_ivar_gen(struct parser_params *parser, ID id, const YYLTYPE *location)
+{
+ NODE *ivar = NEW_IVAR(id);
+ nd_set_loc(ivar, location);
+ return ivar;
+}
+
+static NODE *
+new_postarg_gen(struct parser_params *parser, NODE *i, NODE *v, const YYLTYPE *location)
+{
+ NODE *postarg = NEW_POSTARG(i, v);
+ nd_set_loc(postarg, location);
+ return postarg;
+}
+
+static NODE *
+new_cdecl_gen(struct parser_params *parser, ID v, NODE *val, NODE *path, const YYLTYPE *location)
+{
+ NODE *nd_cdecl = NEW_CDECL(v, val, path);
+ nd_set_loc(nd_cdecl, location);
+ return nd_cdecl;
+}
+
+static NODE *
+new_scope_gen(struct parser_params *parser, NODE *a, NODE *b, const YYLTYPE *location)
+{
+ NODE *scope = NEW_SCOPE(a, b);
+ nd_set_loc(scope, location);
+ return scope;
+}
+
+static NODE *
+new_begin_gen(struct parser_params *parser, NODE *b, const YYLTYPE *location)
+{
+ NODE *begin = NEW_BEGIN(b);
+ nd_set_loc(begin, location);
+ return begin;
+}
+
+static NODE *
+new_masgn_gen(struct parser_params *parser, NODE *l, NODE *r, const YYLTYPE *location)
+{
+ NODE *masgn = NEW_MASGN(l, r);
+ nd_set_loc(masgn, location);
+ return masgn;
+}
+
+
+static NODE *
+new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *location)
{
+ NODE *kw_arg;
if (!k) return 0;
- return NEW_KW_ARG(0, (k), loc);
+ kw_arg = NEW_KW_ARG(0, (k));
+ nd_set_loc(kw_arg, location);
+ return kw_arg;
}
static NODE *
-new_xstring(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+new_xstring_gen(struct parser_params *parser, NODE *node, const YYLTYPE *location)
{
if (!node) {
VALUE lit = STR_NEW0();
- NODE *xstr = NEW_XSTR(lit, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, lit);
+ NODE *xstr = NEW_XSTR(lit);
+ add_mark_object(lit);
+ xstr->nd_loc = *location;
return xstr;
}
switch (nd_type(node)) {
case NODE_STR:
nd_set_type(node, NODE_XSTR);
- nd_set_loc(node, loc);
+ nd_set_loc(node, location);
break;
case NODE_DSTR:
nd_set_type(node, NODE_DXSTR);
- nd_set_loc(node, loc);
+ nd_set_loc(node, location);
break;
default:
- node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node, loc), loc);
+ node = NEW_NODE(NODE_DXSTR, Qnil, 1, new_list(node, location));
+ nd_set_loc(node, location);
break;
}
return node;
}
-static void
-check_literal_when(struct parser_params *p, NODE *arg, const YYLTYPE *loc)
+static NODE *
+new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *location)
{
- VALUE lit;
+ NODE *iter = NEW_ITER(param, stmt);
+ nd_set_loc(iter->nd_body, location);
+ nd_set_loc(iter, location);
+ return iter;
- if (!arg || !p->case_labels) return;
-
- lit = rb_node_case_when_optimizable_literal(arg);
- if (lit == Qundef) return;
- if (nd_type(arg) == NODE_STR) {
- RB_OBJ_WRITTEN(p->ast, Qnil, arg->nd_lit = lit);
- }
-
- if (NIL_P(p->case_labels)) {
- p->case_labels = rb_obj_hide(rb_hash_new());
- }
- else {
- VALUE line = rb_hash_lookup(p->case_labels, lit);
- if (!NIL_P(line)) {
- rb_warning1("duplicated `when' clause with line %d is ignored",
- WARN_IVAL(line));
- return;
- }
- }
- rb_hash_aset(p->case_labels, lit, INT2NUM(p->ruby_sourceline));
}
-
#else /* !RIPPER */
static int
-id_is_var(struct parser_params *p, ID id)
+id_is_var_gen(struct parser_params *parser, ID id)
{
if (is_notop_id(id)) {
switch (id & ID_SCOPE_MASK) {
case ID_GLOBAL: case ID_INSTANCE: case ID_CONST: case ID_CLASS:
return 1;
case ID_LOCAL:
- if (dyna_in_block(p)) {
- if (NUMPARAM_ID_P(id) || dvar_defined(p, id)) return 1;
- }
- if (local_id(p, id)) return 1;
+ if (dyna_in_block() && dvar_defined(id)) return 1;
+ if (local_id(id)) return 1;
/* method call without arguments */
return 0;
}
}
- compile_error(p, "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id));
+ compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id));
return 0;
}
static VALUE
-new_regexp(struct parser_params *p, VALUE re, VALUE opt, const YYLTYPE *loc)
+new_regexp_gen(struct parser_params *parser, VALUE re, VALUE opt)
{
VALUE src = 0, err;
int options = 0;
@@ -10268,19 +9788,24 @@ new_regexp(struct parser_params *p, VALUE re, VALUE opt, const YYLTYPE *loc)
options = (int)RNODE(opt)->nd_tag;
opt = RNODE(opt)->nd_rval;
}
- if (src && NIL_P(parser_reg_compile(p, src, options, &err))) {
- compile_error(p, "%"PRIsVALUE, err);
+ if (src && NIL_P(parser_reg_compile(parser, src, options, &err))) {
+ compile_error(PARSER_ARG "%"PRIsVALUE, err);
}
return dispatch2(regexp_literal, re, opt);
}
-#endif /* !RIPPER */
+static VALUE
+new_xstring_gen(struct parser_params *parser, VALUE str)
+{
+ return dispatch1(xstring_literal, str);
+}
+#endif /* !RIPPER */
#ifndef RIPPER
-static const char rb_parser_lex_state_names[][8] = {
- "BEG", "END", "ENDARG", "ENDFN", "ARG",
- "CMDARG", "MID", "FNAME", "DOT", "CLASS",
- "LABEL", "LABELED","FITEM",
+const char rb_parser_lex_state_names[][13] = {
+ "EXPR_BEG", "EXPR_END", "EXPR_ENDARG", "EXPR_ENDFN", "EXPR_ARG",
+ "EXPR_CMDARG", "EXPR_MID", "EXPR_FNAME", "EXPR_DOT", "EXPR_CLASS",
+ "EXPR_LABEL", "EXPR_LABELED","EXPR_FITEM",
};
static VALUE
@@ -10288,7 +9813,7 @@ append_lex_state_name(enum lex_state_e state, VALUE buf)
{
int i, sep = 0;
unsigned int mask = 1;
- static const char none[] = "NONE";
+ static const char none[] = "EXPR_NONE";
for (i = 0; i < EXPR_MAX_STATE; ++i, mask <<= 1) {
if ((unsigned)state & mask) {
@@ -10306,21 +9831,21 @@ append_lex_state_name(enum lex_state_e state, VALUE buf)
}
static void
-flush_debug_buffer(struct parser_params *p, VALUE out, VALUE str)
+flush_debug_buffer(struct parser_params *parser, VALUE out, VALUE str)
{
- VALUE mesg = p->debug_buffer;
+ VALUE mesg = parser->debug_buffer;
if (!NIL_P(mesg) && RSTRING_LEN(mesg)) {
- p->debug_buffer = Qnil;
+ parser->debug_buffer = Qnil;
rb_io_puts(1, &mesg, out);
}
if (!NIL_P(str) && RSTRING_LEN(str)) {
- rb_io_write(p->debug_output, str);
+ rb_io_write(parser->debug_output, str);
}
}
enum lex_state_e
-rb_parser_trace_lex_state(struct parser_params *p, enum lex_state_e from,
+rb_parser_trace_lex_state(struct parser_params *parser, enum lex_state_e from,
enum lex_state_e to, int line)
{
VALUE mesg;
@@ -10329,7 +9854,7 @@ rb_parser_trace_lex_state(struct parser_params *p, enum lex_state_e from,
rb_str_cat_cstr(mesg, " -> ");
append_lex_state_name(to, mesg);
rb_str_catf(mesg, " at line %d\n", line);
- flush_debug_buffer(p, p->debug_output, mesg);
+ flush_debug_buffer(parser, parser->debug_output, mesg);
return to;
}
@@ -10353,17 +9878,17 @@ append_bitstack_value(stack_type stack, VALUE mesg)
}
void
-rb_parser_show_bitstack(struct parser_params *p, stack_type stack,
+rb_parser_show_bitstack(struct parser_params *parser, stack_type stack,
const char *name, int line)
{
VALUE mesg = rb_sprintf("%s: ", name);
append_bitstack_value(stack, mesg);
rb_str_catf(mesg, " at line %d\n", line);
- flush_debug_buffer(p, p->debug_output, mesg);
+ flush_debug_buffer(parser, parser->debug_output, mesg);
}
void
-rb_parser_fatal(struct parser_params *p, const char *fmt, ...)
+rb_parser_fatal(struct parser_params *parser, const char *fmt, ...)
{
va_list ap;
VALUE mesg = rb_str_new_cstr("internal parser error: ");
@@ -10371,189 +9896,154 @@ rb_parser_fatal(struct parser_params *p, const char *fmt, ...)
va_start(ap, fmt);
rb_str_vcatf(mesg, fmt, ap);
va_end(ap);
- parser_yyerror(p, NULL, RSTRING_PTR(mesg));
+#ifndef RIPPER
+ parser_yyerror(parser, RSTRING_PTR(mesg));
RB_GC_GUARD(mesg);
+#else
+ dispatch1(parse_error, mesg);
+ ripper_error();
+#endif /* !RIPPER */
mesg = rb_str_new(0, 0);
- append_lex_state_name(p->lex.state, mesg);
- compile_error(p, "lex.state: %"PRIsVALUE, mesg);
+ append_lex_state_name(lex_state, mesg);
+ compile_error(PARSER_ARG "lex_state: %"PRIsVALUE, mesg);
rb_str_resize(mesg, 0);
- append_bitstack_value(p->cond_stack, mesg);
- compile_error(p, "cond_stack: %"PRIsVALUE, mesg);
+ append_bitstack_value(cond_stack, mesg);
+ compile_error(PARSER_ARG "cond_stack: %"PRIsVALUE, mesg);
rb_str_resize(mesg, 0);
- append_bitstack_value(p->cmdarg_stack, mesg);
- compile_error(p, "cmdarg_stack: %"PRIsVALUE, mesg);
- if (p->debug_output == rb_stdout)
- p->debug_output = rb_stderr;
- p->debug = TRUE;
+ append_bitstack_value(cmdarg_stack, mesg);
+ compile_error(PARSER_ARG "cmdarg_stack: %"PRIsVALUE, mesg);
+ if (parser->debug_output == rb_stdout)
+ parser->debug_output = rb_stderr;
+ yydebug = TRUE;
}
-YYLTYPE *
-rb_parser_set_location_from_strterm_heredoc(struct parser_params *p, rb_strterm_heredoc_t *here, YYLTYPE *yylloc)
+void
+rb_parser_set_location_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc)
{
- int sourceline = here->sourceline;
- int beg_pos = (int)here->offset - here->quote
- - (rb_strlen_lit("<<-") - !(here->func & STR_FUNC_INDENT));
- int end_pos = (int)here->offset + here->length + here->quote;
+ const char *eos = RSTRING_PTR(here->term);
+ int term_len = (int)eos[0];
- yylloc->beg_pos.lineno = sourceline;
- yylloc->beg_pos.column = beg_pos;
- yylloc->end_pos.lineno = sourceline;
- yylloc->end_pos.column = end_pos;
- return yylloc;
+ yylloc->first_loc.lineno = (int)here->sourceline;
+ yylloc->first_loc.column = (int)(here->u3.lastidx - term_len);
+ yylloc->last_loc.lineno = (int)here->sourceline;
+ yylloc->last_loc.column = (int)(here->u3.lastidx);
}
-YYLTYPE *
-rb_parser_set_location_of_none(struct parser_params *p, YYLTYPE *yylloc)
+void
+rb_parser_set_location_of_none(struct parser_params *parser, YYLTYPE *yylloc)
{
- yylloc->beg_pos.lineno = p->ruby_sourceline;
- yylloc->beg_pos.column = (int)(p->lex.ptok - p->lex.pbeg);
- yylloc->end_pos.lineno = p->ruby_sourceline;
- yylloc->end_pos.column = (int)(p->lex.ptok - p->lex.pbeg);
- return yylloc;
+ yylloc->first_loc.lineno = ruby_sourceline;
+ yylloc->first_loc.column = (int)(parser->tokp - lex_pbeg);
+ yylloc->last_loc.lineno = ruby_sourceline;
+ yylloc->last_loc.column = (int)(parser->tokp - lex_pbeg);
}
-YYLTYPE *
-rb_parser_set_location(struct parser_params *p, YYLTYPE *yylloc)
+void
+rb_parser_set_location(struct parser_params *parser, YYLTYPE *yylloc)
{
- yylloc->beg_pos.lineno = p->ruby_sourceline;
- yylloc->beg_pos.column = (int)(p->lex.ptok - p->lex.pbeg);
- yylloc->end_pos.lineno = p->ruby_sourceline;
- yylloc->end_pos.column = (int)(p->lex.pcur - p->lex.pbeg);
- return yylloc;
+ yylloc->first_loc.lineno = ruby_sourceline;
+ yylloc->first_loc.column = (int)(parser->tokp - lex_pbeg);
+ yylloc->last_loc.lineno = ruby_sourceline;
+ yylloc->last_loc.column = (int)(lex_p - lex_pbeg);
}
#endif /* !RIPPER */
-static void
-parser_token_value_print(struct parser_params *p, enum yytokentype type, const YYSTYPE *valp)
+#ifndef RIPPER
+static NODE*
+assignable_result0(NODE *node, const YYLTYPE *location)
{
- VALUE v;
+ if (node) {
+ nd_set_loc(node, location);
+ }
+ return node;
+}
+#endif /* !RIPPER */
- switch (type) {
- case tIDENTIFIER: case tFID: case tGVAR: case tIVAR:
- case tCONSTANT: case tCVAR: case tLABEL: case tOP_ASGN:
-#ifndef RIPPER
- v = rb_id2str(valp->id);
-#else
- v = valp->node->nd_rval;
-#endif
- rb_parser_printf(p, "%"PRIsVALUE, v);
- break;
- case tINTEGER: case tFLOAT: case tRATIONAL: case tIMAGINARY:
- case tSTRING_CONTENT: case tCHAR:
-#ifndef RIPPER
- v = valp->node->nd_lit;
-#else
- v = valp->val;
-#endif
- rb_parser_printf(p, "%+"PRIsVALUE, v);
- break;
- case tNTH_REF:
-#ifndef RIPPER
- rb_parser_printf(p, "$%ld", valp->node->nd_nth);
+#ifdef RIPPER
+static VALUE
+assignable_gen(struct parser_params *parser, VALUE lhs)
#else
- rb_parser_printf(p, "%"PRIsVALUE, valp->val);
+static NODE*
+assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *location)
#endif
- break;
- case tBACK_REF:
-#ifndef RIPPER
- rb_parser_printf(p, "$%c", (int)valp->node->nd_nth);
+{
+#ifdef RIPPER
+ ID id = get_id(lhs);
+# define assignable_result(x) (lhs)
+# define assignable_error() (lhs)
+# define parser_yyerror(parser, x) (lhs = assign_error_gen(parser, lhs))
#else
- rb_parser_printf(p, "%"PRIsVALUE, valp->val);
+# define assignable_result(x) assignable_result0(x, location)
+# define assignable_error() new_begin(0, location)
#endif
- break;
- default:
- break;
- }
-}
-
-static int
-assignable0(struct parser_params *p, ID id, const char **err)
-{
- if (!id) return -1;
+ if (!id) return assignable_error();
switch (id) {
case keyword_self:
- *err = "Can't change the value of self";
- return -1;
+ yyerror0("Can't change the value of self");
+ goto error;
case keyword_nil:
- *err = "Can't assign to nil";
- return -1;
+ yyerror0("Can't assign to nil");
+ goto error;
case keyword_true:
- *err = "Can't assign to true";
- return -1;
+ yyerror0("Can't assign to true");
+ goto error;
case keyword_false:
- *err = "Can't assign to false";
- return -1;
+ yyerror0("Can't assign to false");
+ goto error;
case keyword__FILE__:
- *err = "Can't assign to __FILE__";
- return -1;
+ yyerror0("Can't assign to __FILE__");
+ goto error;
case keyword__LINE__:
- *err = "Can't assign to __LINE__";
- return -1;
+ yyerror0("Can't assign to __LINE__");
+ goto error;
case keyword__ENCODING__:
- *err = "Can't assign to __ENCODING__";
- return -1;
+ yyerror0("Can't assign to __ENCODING__");
+ goto error;
}
switch (id_type(id)) {
case ID_LOCAL:
- if (dyna_in_block(p)) {
- if (p->max_numparam > NO_PARAM && NUMPARAM_ID_P(id)) {
- compile_error(p, "Can't assign to numbered parameter _%d",
- NUMPARAM_ID_TO_IDX(id));
- return -1;
+ if (dyna_in_block()) {
+ if (dvar_curr(id)) {
+ return assignable_result(NEW_DASGN_CURR(id, val));
+ }
+ else if (dvar_defined(id)) {
+ return assignable_result(NEW_DASGN(id, val));
+ }
+ else if (local_id(id)) {
+ return assignable_result(NEW_LASGN(id, val));
+ }
+ else {
+ dyna_var(id);
+ return assignable_result(NEW_DASGN_CURR(id, val));
}
- if (dvar_curr(p, id)) return NODE_DASGN_CURR;
- if (dvar_defined(p, id)) return NODE_DASGN;
- if (local_id(p, id)) return NODE_LASGN;
- dyna_var(p, id);
- return NODE_DASGN_CURR;
}
else {
- if (!local_id(p, id)) local_var(p, id);
- return NODE_LASGN;
+ if (!local_id(id)) {
+ local_var(id);
+ }
+ return assignable_result(NEW_LASGN(id, val));
}
break;
- case ID_GLOBAL: return NODE_GASGN;
- case ID_INSTANCE: return NODE_IASGN;
+ case ID_GLOBAL:
+ return assignable_result(NEW_GASGN(id, val));
+ case ID_INSTANCE:
+ return assignable_result(NEW_IASGN(id, val));
case ID_CONST:
- if (!p->in_def) return NODE_CDECL;
- *err = "dynamic constant assignment";
- return -1;
- case ID_CLASS: return NODE_CVASGN;
+ if (!in_def)
+ return assignable_result(new_cdecl(id, val, 0, location));
+ yyerror0("dynamic constant assignment");
+ break;
+ case ID_CLASS:
+ return assignable_result(NEW_CVASGN(id, val));
default:
- compile_error(p, "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id));
+ compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id));
}
- return -1;
-}
-
-#ifndef RIPPER
-static NODE*
-assignable(struct parser_params *p, ID id, NODE *val, const YYLTYPE *loc)
-{
- const char *err = 0;
- int node_type = assignable0(p, id, &err);
- switch (node_type) {
- case NODE_DASGN_CURR: return NEW_DASGN_CURR(id, val, loc);
- case NODE_DASGN: return NEW_DASGN(id, val, loc);
- case NODE_LASGN: return NEW_LASGN(id, val, loc);
- case NODE_GASGN: return NEW_GASGN(id, val, loc);
- case NODE_IASGN: return NEW_IASGN(id, val, loc);
- case NODE_CDECL: return NEW_CDECL(id, val, 0, loc);
- case NODE_CVASGN: return NEW_CVASGN(id, val, loc);
- }
- if (err) yyerror1(loc, err);
- return NEW_BEGIN(0, loc);
-}
-#else
-static VALUE
-assignable(struct parser_params *p, VALUE lhs)
-{
- const char *err = 0;
- assignable0(p, get_id(lhs), &err);
- if (err) lhs = assign_error(p, lhs);
- return lhs;
+ error:
+ return assignable_error();
+#undef assignable_result
+#undef parser_yyerror
}
-#endif
static int
is_private_local_id(ID name)
@@ -10567,23 +10057,24 @@ is_private_local_id(ID name)
}
static int
-shadowing_lvar_0(struct parser_params *p, ID name)
+shadowing_lvar_0(struct parser_params *parser, ID name)
{
if (is_private_local_id(name)) return 1;
- if (dyna_in_block(p)) {
- if (dvar_curr(p, name)) {
+ if (dyna_in_block()) {
+ if (dvar_curr(name)) {
yyerror0("duplicated argument name");
}
- else if (dvar_defined(p, name) || local_id(p, name)) {
- vtable_add(p->lvtbl->vars, name);
- if (p->lvtbl->used) {
- vtable_add(p->lvtbl->used, (ID)p->ruby_sourceline | LVAR_USED);
+ else if (dvar_defined(name) || local_id(name)) {
+ rb_warning1("shadowing outer local variable - %"PRIsWARN, rb_id2str(name));
+ vtable_add(lvtbl->vars, name);
+ if (lvtbl->used) {
+ vtable_add(lvtbl->used, (ID)ruby_sourceline | LVAR_USED);
}
return 0;
}
}
else {
- if (local_id(p, name)) {
+ if (local_id(name)) {
yyerror0("duplicated argument name");
}
}
@@ -10591,159 +10082,147 @@ shadowing_lvar_0(struct parser_params *p, ID name)
}
static ID
-shadowing_lvar(struct parser_params *p, ID name)
+shadowing_lvar_gen(struct parser_params *parser, ID name)
{
- shadowing_lvar_0(p, name);
+ shadowing_lvar_0(parser, name);
return name;
}
static void
-new_bv(struct parser_params *p, ID name)
+new_bv_gen(struct parser_params *parser, ID name)
{
if (!name) return;
if (!is_local_id(name)) {
- compile_error(p, "invalid local variable - %"PRIsVALUE,
+ compile_error(PARSER_ARG "invalid local variable - %"PRIsVALUE,
rb_id2str(name));
return;
}
- if (!shadowing_lvar_0(p, name)) return;
- dyna_var(p, name);
+ if (!shadowing_lvar_0(parser, name)) return;
+ dyna_var(name);
}
#ifndef RIPPER
static NODE *
-aryset(struct parser_params *p, NODE *recv, NODE *idx, const YYLTYPE *loc)
+aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, const YYLTYPE *location)
{
- return NEW_ATTRASGN(recv, tASET, idx, loc);
+ NODE *attrasgn = NEW_ATTRASGN(recv, tASET, idx);
+ nd_set_loc(attrasgn, location);
+ return attrasgn;
}
static void
-block_dup_check(struct parser_params *p, NODE *node1, NODE *node2)
+block_dup_check_gen(struct parser_params *parser, NODE *node1, NODE *node2)
{
if (node2 && node1 && nd_type(node1) == NODE_BLOCK_PASS) {
- compile_error(p, "both block arg and actual block given");
+ compile_error(PARSER_ARG "both block arg and actual block given");
}
}
static NODE *
-attrset(struct parser_params *p, NODE *recv, ID atype, ID id, const YYLTYPE *loc)
+attrset_gen(struct parser_params *parser, NODE *recv, ID atype, ID id, const YYLTYPE *location)
{
+ NODE *attrasgn;
if (!CALL_Q_P(atype)) id = rb_id_attrset(id);
- return NEW_ATTRASGN(recv, id, 0, loc);
+ attrasgn = NEW_ATTRASGN(recv, id, 0);
+ nd_set_loc(attrasgn, location);
+ return attrasgn;
}
static void
-rb_backref_error(struct parser_params *p, NODE *node)
+rb_backref_error_gen(struct parser_params *parser, NODE *node)
{
switch (nd_type(node)) {
case NODE_NTH_REF:
- compile_error(p, "Can't set variable $%ld", node->nd_nth);
+ compile_error(PARSER_ARG "Can't set variable $%ld", node->nd_nth);
break;
case NODE_BACK_REF:
- compile_error(p, "Can't set variable $%c", (int)node->nd_nth);
+ compile_error(PARSER_ARG "Can't set variable $%c", (int)node->nd_nth);
break;
}
}
static NODE *
-arg_append(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *loc)
+arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *location)
{
- if (!node1) return NEW_LIST(node2, &node2->nd_loc);
- switch (nd_type(node1)) {
- case NODE_LIST:
- return list_append(p, node1, node2);
- case NODE_BLOCK_PASS:
- node1->nd_head = arg_append(p, node1->nd_head, node2, loc);
- node1->nd_loc.end_pos = node1->nd_head->nd_loc.end_pos;
- return node1;
- case NODE_ARGSPUSH:
- node1->nd_body = list_append(p, NEW_LIST(node1->nd_body, &node1->nd_body->nd_loc), node2);
- node1->nd_loc.end_pos = node1->nd_body->nd_loc.end_pos;
- nd_set_type(node1, NODE_ARGSCAT);
- return node1;
- case NODE_ARGSCAT:
- if (nd_type(node1->nd_body) != NODE_LIST) break;
- node1->nd_body = list_append(p, node1->nd_body, node2);
- node1->nd_loc.end_pos = node1->nd_body->nd_loc.end_pos;
- return node1;
- }
- return NEW_ARGSPUSH(node1, node2, loc);
-}
+ NODE *argscat;
-static NODE *
-arg_concat(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *loc)
-{
if (!node2) return node1;
switch (nd_type(node1)) {
case NODE_BLOCK_PASS:
if (node1->nd_head)
- node1->nd_head = arg_concat(p, node1->nd_head, node2, loc);
+ node1->nd_head = arg_concat(node1->nd_head, node2, location);
else
- node1->nd_head = NEW_LIST(node2, loc);
+ node1->nd_head = new_list(node2, location);
return node1;
case NODE_ARGSPUSH:
- if (nd_type(node2) != NODE_LIST) break;
- node1->nd_body = list_concat(NEW_LIST(node1->nd_body, loc), node2);
+ if (nd_type(node2) != NODE_ARRAY) break;
+ node1->nd_body = list_concat(new_list(node1->nd_body, location), node2);
nd_set_type(node1, NODE_ARGSCAT);
return node1;
case NODE_ARGSCAT:
- if (nd_type(node2) != NODE_LIST ||
- nd_type(node1->nd_body) != NODE_LIST) break;
+ if (nd_type(node2) != NODE_ARRAY ||
+ nd_type(node1->nd_body) != NODE_ARRAY) break;
node1->nd_body = list_concat(node1->nd_body, node2);
return node1;
}
- return NEW_ARGSCAT(node1, node2, loc);
+ argscat = NEW_ARGSCAT(node1, node2);
+ nd_set_loc(argscat, location);
+ return argscat;
}
static NODE *
-last_arg_append(struct parser_params *p, NODE *args, NODE *last_arg, const YYLTYPE *loc)
+arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *location)
{
- NODE *n1;
- if ((n1 = splat_array(args)) != 0) {
- return list_append(p, n1, last_arg);
- }
- return arg_append(p, args, last_arg, loc);
-}
+ NODE *argspush;
-static NODE *
-rest_arg_append(struct parser_params *p, NODE *args, NODE *rest_arg, const YYLTYPE *loc)
-{
- NODE *n1;
- if ((nd_type(rest_arg) == NODE_LIST) && (n1 = splat_array(args)) != 0) {
- return list_concat(n1, rest_arg);
+ if (!node1) return new_list(node2, &node2->nd_loc);
+ switch (nd_type(node1)) {
+ case NODE_ARRAY:
+ return list_append(node1, node2);
+ case NODE_BLOCK_PASS:
+ node1->nd_head = arg_append(node1->nd_head, node2, location);
+ node1->nd_loc.last_loc = node1->nd_head->nd_loc.last_loc;
+ return node1;
+ case NODE_ARGSPUSH:
+ node1->nd_body = list_append(new_list(node1->nd_body, &node1->nd_body->nd_loc), node2);
+ node1->nd_loc.last_loc = node1->nd_body->nd_loc.last_loc;
+ nd_set_type(node1, NODE_ARGSCAT);
+ return node1;
}
- return arg_concat(p, args, rest_arg, loc);
+ argspush = NEW_ARGSPUSH(node1, node2);
+ nd_set_loc(argspush, location);
+ return argspush;
}
static NODE *
splat_array(NODE* node)
{
if (nd_type(node) == NODE_SPLAT) node = node->nd_head;
- if (nd_type(node) == NODE_LIST) return node;
+ if (nd_type(node) == NODE_ARRAY) return node;
return 0;
}
static void
-mark_lvar_used(struct parser_params *p, NODE *rhs)
+mark_lvar_used(struct parser_params *parser, NODE *rhs)
{
ID *vidp = NULL;
if (!rhs) return;
switch (nd_type(rhs)) {
case NODE_LASGN:
- if (local_id_ref(p, rhs->nd_vid, &vidp)) {
+ if (local_id_ref(rhs->nd_vid, vidp)) {
if (vidp) *vidp |= LVAR_USED;
}
break;
case NODE_DASGN:
case NODE_DASGN_CURR:
- if (dvar_defined_ref(p, rhs->nd_vid, &vidp)) {
+ if (dvar_defined_ref(rhs->nd_vid, vidp)) {
if (vidp) *vidp |= LVAR_USED;
}
break;
#if 0
case NODE_MASGN:
for (rhs = rhs->nd_head; rhs; rhs = rhs->nd_next) {
- mark_lvar_used(p, rhs->nd_head);
+ mark_lvar_used(parser, rhs->nd_head);
}
break;
#endif
@@ -10751,7 +10230,7 @@ mark_lvar_used(struct parser_params *p, NODE *rhs)
}
static NODE *
-node_assign(struct parser_params *p, NODE *lhs, NODE *rhs, const YYLTYPE *loc)
+node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, const YYLTYPE *location)
{
if (!lhs) return 0;
@@ -10765,12 +10244,12 @@ node_assign(struct parser_params *p, NODE *lhs, NODE *rhs, const YYLTYPE *loc)
case NODE_CDECL:
case NODE_CVASGN:
lhs->nd_value = rhs;
- nd_set_loc(lhs, loc);
+ nd_set_loc(lhs, location);
break;
case NODE_ATTRASGN:
- lhs->nd_args = arg_append(p, lhs->nd_args, rhs, loc);
- nd_set_loc(lhs, loc);
+ lhs->nd_args = arg_append(lhs->nd_args, rhs, location);
+ nd_set_loc(lhs, location);
break;
default:
@@ -10781,10 +10260,10 @@ node_assign(struct parser_params *p, NODE *lhs, NODE *rhs, const YYLTYPE *loc)
return lhs;
}
-static NODE *
-value_expr_check(struct parser_params *p, NODE *node)
+static int
+value_expr_gen(struct parser_params *parser, NODE *node)
{
- NODE *void_node = 0, *vn;
+ int cond = 0;
if (!node) {
rb_warning0("empty expression");
@@ -10796,18 +10275,9 @@ value_expr_check(struct parser_params *p, NODE *node)
case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
- return void_node ? void_node : node;
-
- case NODE_CASE3:
- if (!node->nd_body || nd_type(node->nd_body) != NODE_IN) {
- compile_error(p, "unexpected node");
- return NULL;
- }
- if (node->nd_body->nd_body) {
- return NULL;
- }
- /* single line pattern matching */
- return void_node ? void_node : node;
+ if (!cond) yyerror0("void value expression");
+ /* or "control never reach"? */
+ return FALSE;
case NODE_BLOCK:
while (node->nd_next) {
@@ -10823,50 +10293,40 @@ value_expr_check(struct parser_params *p, NODE *node)
case NODE_IF:
case NODE_UNLESS:
if (!node->nd_body) {
- return NULL;
+ node = node->nd_else;
+ break;
}
else if (!node->nd_else) {
- return NULL;
+ node = node->nd_body;
+ break;
}
- vn = value_expr_check(p, node->nd_body);
- if (!vn) return NULL;
- if (!void_node) void_node = vn;
+ if (!value_expr(node->nd_body)) return FALSE;
node = node->nd_else;
break;
case NODE_AND:
case NODE_OR:
- node = node->nd_1st;
+ cond = 1;
+ node = node->nd_2nd;
break;
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_MASGN:
- mark_lvar_used(p, node);
- return NULL;
+ mark_lvar_used(parser, node);
+ return TRUE;
default:
- return NULL;
+ return TRUE;
}
}
- return NULL;
-}
-
-static int
-value_expr_gen(struct parser_params *p, NODE *node)
-{
- NODE *void_node = value_expr_check(p, node);
- if (void_node) {
- yyerror1(&void_node->nd_loc, "void value expression");
- /* or "control never reach"? */
- return FALSE;
- }
return TRUE;
}
+
static void
-void_expr(struct parser_params *p, NODE *node)
+void_expr_gen(struct parser_params *parser, NODE *node)
{
const char *useless = 0;
@@ -10949,19 +10409,18 @@ void_expr(struct parser_params *p, NODE *node)
}
}
-static NODE *
-void_stmts(struct parser_params *p, NODE *node)
+static void
+void_stmts_gen(struct parser_params *parser, NODE *node)
{
- NODE *const n = node;
- if (!RTEST(ruby_verbose)) return n;
- if (!node) return n;
- if (nd_type(node) != NODE_BLOCK) return n;
+ if (!RTEST(ruby_verbose)) return;
+ if (!node) return;
+ if (nd_type(node) != NODE_BLOCK) return;
- while (node->nd_next) {
- void_expr(p, node->nd_head);
+ for (;;) {
+ if (!node->nd_next) return;
+ void_expr0(node->nd_head);
node = node->nd_next;
}
- return n;
}
static NODE *
@@ -10985,18 +10444,18 @@ remove_begin_all(NODE *node)
}
static void
-reduce_nodes(struct parser_params *p, NODE **body)
+reduce_nodes_gen(struct parser_params *parser, NODE **body)
{
NODE *node = *body;
if (!node) {
- *body = NEW_NIL(&NULL_LOC);
+ *body = NEW_NIL();
return;
}
#define subnodes(n1, n2) \
((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
(!node->n2) ? (body = &node->n1, 1) : \
- (reduce_nodes(p, &node->n1), body = &node->n2, 1))
+ (reduce_nodes(&node->n1), body = &node->n2, 1))
while (node) {
int newline = (int)(node->flags & NODE_FL_NEWLINE);
@@ -11053,7 +10512,7 @@ is_static_content(NODE *node)
switch (nd_type(node)) {
case NODE_HASH:
if (!(node = node->nd_head)) break;
- case NODE_LIST:
+ case NODE_ARRAY:
do {
if (!is_static_content(node->nd_head)) return 0;
} while ((node = node->nd_next) != 0);
@@ -11062,7 +10521,7 @@ is_static_content(NODE *node)
case NODE_NIL:
case NODE_TRUE:
case NODE_FALSE:
- case NODE_ZLIST:
+ case NODE_ZARRAY:
break;
default:
return 0;
@@ -11071,7 +10530,7 @@ is_static_content(NODE *node)
}
static int
-assign_in_cond(struct parser_params *p, NODE *node)
+assign_in_cond(struct parser_params *parser, NODE *node)
{
switch (nd_type(node)) {
case NODE_MASGN:
@@ -11089,28 +10548,27 @@ assign_in_cond(struct parser_params *p, NODE *node)
if (!node->nd_value) return 1;
if (is_static_content(node->nd_value)) {
/* reports always */
- parser_warn(p, node->nd_value, "found `= literal' in conditional, should be ==");
+ parser_warn(node->nd_value, "found = in conditional, should be ==");
}
return 1;
}
-enum cond_type {
- COND_IN_OP,
- COND_IN_COND,
- COND_IN_FF
-};
+static void
+warn_unless_e_option(struct parser_params *parser, NODE *node, const char *str)
+{
+ if (!e_option_supplied(parser)) parser_warn(node, str);
+}
-#define SWITCH_BY_COND_TYPE(t, w, arg) \
- switch (t) { \
- case COND_IN_OP: break; \
- case COND_IN_COND: rb_##w##0(arg "literal in condition"); break; \
- case COND_IN_FF: rb_##w##0(arg "literal in flip-flop"); break; \
- }
+static void
+warning_unless_e_option(struct parser_params *parser, NODE *node, const char *str)
+{
+ if (!e_option_supplied(parser)) parser_warning(node, str);
+}
-static NODE *cond0(struct parser_params*,NODE*,enum cond_type,const YYLTYPE*);
+static NODE *cond0(struct parser_params*,NODE*,int,const YYLTYPE*);
static NODE*
-range_op(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+range_op(struct parser_params *parser, NODE *node, const YYLTYPE *location)
{
enum node_type type;
@@ -11119,60 +10577,92 @@ range_op(struct parser_params *p, NODE *node, const YYLTYPE *loc)
type = nd_type(node);
value_expr(node);
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
- if (!e_option_supplied(p)) parser_warn(p, node, "integer literal in flip-flop");
- return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(rb_intern("$."), loc), loc), loc);
+ warn_unless_e_option(parser, node, "integer literal in conditional range");
+ return new_call(node, tEQ, new_list(new_gvar(rb_intern("$."), location), location), location);
+ }
+ return cond0(parser, node, FALSE, location);
+}
+
+static int
+literal_node(NODE *node)
+{
+ if (!node) return 1; /* same as NODE_NIL */
+ if (!(node = nd_once_body(node))) return 1;
+ switch (nd_type(node)) {
+ case NODE_LIT:
+ case NODE_STR:
+ case NODE_DSTR:
+ case NODE_EVSTR:
+ case NODE_DREGX:
+ case NODE_DSYM:
+ return 2;
+ case NODE_TRUE:
+ case NODE_FALSE:
+ case NODE_NIL:
+ return 1;
}
- return cond0(p, node, COND_IN_FF, loc);
+ return 0;
}
static NODE*
-cond0(struct parser_params *p, NODE *node, enum cond_type type, const YYLTYPE *loc)
+cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *location)
{
if (node == 0) return 0;
if (!(node = nd_once_body(node))) return 0;
- assign_in_cond(p, node);
+ assign_in_cond(parser, node);
switch (nd_type(node)) {
case NODE_DSTR:
case NODE_EVSTR:
case NODE_STR:
- SWITCH_BY_COND_TYPE(type, warn, "string ")
+ if (!method_op) rb_warn0("string literal in condition");
break;
case NODE_DREGX:
- if (!e_option_supplied(p)) SWITCH_BY_COND_TYPE(type, warning, "regex ")
+ {
+ NODE *match;
+ if (!method_op)
+ warning_unless_e_option(parser, node, "regex literal in condition");
- return NEW_MATCH2(node, NEW_GVAR(idLASTLINE, loc), loc);
+ match = NEW_MATCH2(node, new_gvar(idLASTLINE, location));
+ nd_set_loc(match, location);
+ return match;
+ }
case NODE_AND:
case NODE_OR:
- node->nd_1st = cond0(p, node->nd_1st, COND_IN_COND, loc);
- node->nd_2nd = cond0(p, node->nd_2nd, COND_IN_COND, loc);
+ node->nd_1st = cond0(parser, node->nd_1st, FALSE, location);
+ node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, location);
break;
case NODE_DOT2:
case NODE_DOT3:
- node->nd_beg = range_op(p, node->nd_beg, loc);
- node->nd_end = range_op(p, node->nd_end, loc);
+ node->nd_beg = range_op(parser, node->nd_beg, location);
+ node->nd_end = range_op(parser, node->nd_end, location);
if (nd_type(node) == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
else if (nd_type(node) == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
+ if (!method_op && !e_option_supplied(parser)) {
+ int b = literal_node(node->nd_beg);
+ int e = literal_node(node->nd_end);
+ if ((b == 1 && e == 1) || (b + e >= 2 && RTEST(ruby_verbose))) {
+ parser_warn(node, "range literal in condition");
+ }
+ }
break;
case NODE_DSYM:
- SWITCH_BY_COND_TYPE(type, warning, "string ")
+ if (!method_op) parser_warning(node, "literal in condition");
break;
case NODE_LIT:
if (RB_TYPE_P(node->nd_lit, T_REGEXP)) {
- if (!e_option_supplied(p)) SWITCH_BY_COND_TYPE(type, warn, "regex ")
+ if (!method_op)
+ warn_unless_e_option(parser, node, "regex literal in condition");
nd_set_type(node, NODE_MATCH);
}
- else if (node->nd_lit == Qtrue ||
- node->nd_lit == Qfalse) {
- /* booleans are OK, e.g., while true */
- }
else {
- SWITCH_BY_COND_TYPE(type, warning, "")
+ if (!method_op)
+ parser_warning(node, "literal in condition");
}
default:
break;
@@ -11181,40 +10671,48 @@ cond0(struct parser_params *p, NODE *node, enum cond_type type, const YYLTYPE *l
}
static NODE*
-cond(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+cond_gen(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *location)
{
if (node == 0) return 0;
- return cond0(p, node, COND_IN_COND, loc);
+ return cond0(parser, node, method_op, location);
}
static NODE*
-method_cond(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+new_nil_gen(struct parser_params *parser, const YYLTYPE *location)
{
- if (node == 0) return 0;
- return cond0(p, node, COND_IN_OP, loc);
+ NODE *node_nil = NEW_NIL();
+ nd_set_loc(node_nil, location);
+ return node_nil;
}
static NODE*
-new_if(struct parser_params *p, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc)
+new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *location)
{
+ NODE *node_if;
+
if (!cc) return right;
- cc = cond0(p, cc, COND_IN_COND, loc);
- return newline_node(NEW_IF(cc, left, right, loc));
+ cc = cond0(parser, cc, FALSE, location);
+ node_if = NEW_IF(cc, left, right);
+ nd_set_loc(node_if, location);
+ return newline_node(node_if);
}
static NODE*
-new_unless(struct parser_params *p, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc)
+new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *location)
{
+ NODE *node_unless;
+
if (!cc) return right;
- cc = cond0(p, cc, COND_IN_COND, loc);
- return newline_node(NEW_UNLESS(cc, left, right, loc));
+ cc = cond0(parser, cc, FALSE, location);
+ node_unless = NEW_UNLESS(cc, left, right);
+ nd_set_loc(node_unless, location);
+ return newline_node(node_unless);
}
static NODE*
-logop(struct parser_params *p, ID id, NODE *left, NODE *right,
- const YYLTYPE *op_loc, const YYLTYPE *loc)
+logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right,
+ const YYLTYPE *op_loc, const YYLTYPE *location)
{
- enum node_type type = id == idAND || id == idANDOP ? NODE_AND : NODE_OR;
NODE *op;
value_expr(left);
if (left && (enum node_type)nd_type(left) == type) {
@@ -11222,30 +10720,32 @@ logop(struct parser_params *p, ID id, NODE *left, NODE *right,
while ((second = node->nd_2nd) != 0 && (enum node_type)nd_type(second) == type) {
node = second;
}
- node->nd_2nd = NEW_NODE(type, second, right, 0, loc);
- nd_set_line(node->nd_2nd, op_loc->beg_pos.lineno);
- left->nd_loc.end_pos = loc->end_pos;
+ node->nd_2nd = NEW_NODE(type, second, right, 0);
+ node->nd_2nd->nd_loc = *location;
+ nd_set_line(node->nd_2nd, op_loc->first_loc.lineno);
+ left->nd_loc.last_loc = location->last_loc;
return left;
}
- op = NEW_NODE(type, left, right, 0, loc);
- nd_set_line(op, op_loc->beg_pos.lineno);
+ op = NEW_NODE(type, left, right, 0);
+ op->nd_loc = *location;
+ nd_set_line(op, op_loc->first_loc.lineno);
return op;
}
static void
-no_blockarg(struct parser_params *p, NODE *node)
+no_blockarg(struct parser_params *parser, NODE *node)
{
if (node && nd_type(node) == NODE_BLOCK_PASS) {
- compile_error(p, "block argument should not be given");
+ compile_error(PARSER_ARG "block argument should not be given");
}
}
static NODE *
-ret_args(struct parser_params *p, NODE *node)
+ret_args_gen(struct parser_params *parser, NODE *node)
{
if (node) {
- no_blockarg(p, node);
- if (nd_type(node) == NODE_LIST) {
+ no_blockarg(parser, node);
+ if (nd_type(node) == NODE_ARRAY) {
if (node->nd_next == 0) {
node = node->nd_head;
}
@@ -11258,46 +10758,46 @@ ret_args(struct parser_params *p, NODE *node)
}
static NODE *
-new_yield(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+new_yield_gen(struct parser_params *parser, NODE *node, const YYLTYPE *location)
{
- if (node) no_blockarg(p, node);
+ NODE *yield;
+ if (node) no_blockarg(parser, node);
- return NEW_YIELD(node, loc);
+ yield = NEW_YIELD(node);
+ nd_set_loc(yield, location);
+ return yield;
}
static VALUE
-negate_lit(struct parser_params *p, VALUE lit)
+negate_lit_gen(struct parser_params *parser, VALUE lit)
{
- if (FIXNUM_P(lit)) {
- return LONG2FIX(-FIX2LONG(lit));
- }
- if (SPECIAL_CONST_P(lit)) {
-#if USE_FLONUM
- if (FLONUM_P(lit)) {
- return DBL2NUM(-RFLOAT_VALUE(lit));
- }
-#endif
- goto unknown;
- }
- switch (BUILTIN_TYPE(lit)) {
+ int type = TYPE(lit);
+ switch (type) {
+ case T_FIXNUM:
+ lit = LONG2FIX(-FIX2LONG(lit));
+ break;
case T_BIGNUM:
BIGNUM_NEGATE(lit);
lit = rb_big_norm(lit);
break;
case T_RATIONAL:
- RRATIONAL_SET_NUM(lit, negate_lit(p, RRATIONAL(lit)->num));
+ RRATIONAL_SET_NUM(lit, negate_lit(RRATIONAL(lit)->num));
break;
case T_COMPLEX:
- RCOMPLEX_SET_REAL(lit, negate_lit(p, RCOMPLEX(lit)->real));
- RCOMPLEX_SET_IMAG(lit, negate_lit(p, RCOMPLEX(lit)->imag));
+ RCOMPLEX_SET_REAL(lit, negate_lit(RCOMPLEX(lit)->real));
+ RCOMPLEX_SET_IMAG(lit, negate_lit(RCOMPLEX(lit)->imag));
break;
case T_FLOAT:
+#if USE_FLONUM
+ if (FLONUM_P(lit)) {
+ lit = DBL2NUM(-RFLOAT_VALUE(lit));
+ break;
+ }
+#endif
RFLOAT(lit)->float_value = -RFLOAT_VALUE(lit);
break;
- unknown:
default:
- rb_parser_fatal(p, "unknown literal type (%s) passed to negate_lit",
- rb_builtin_class_name(lit));
+ rb_parser_fatal(parser, "unknown literal type (%d) passed to negate_lit", type);
break;
}
return lit;
@@ -11316,234 +10816,122 @@ arg_blk_pass(NODE *node1, NODE *node2)
return node1;
}
-static bool
-args_info_empty_p(struct rb_args_info *args)
-{
- if (args->pre_args_num) return false;
- if (args->post_args_num) return false;
- if (args->rest_arg) return false;
- if (args->opt_args) return false;
- if (args->block_arg) return false;
- if (args->kw_args) return false;
- if (args->kw_rest_arg) return false;
- return true;
-}
static NODE*
-new_args(struct parser_params *p, NODE *pre_args, NODE *opt_args, ID rest_arg, NODE *post_args, NODE *tail, const YYLTYPE *loc)
+new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE *tail, const YYLTYPE *location)
{
- int saved_line = p->ruby_sourceline;
+ int saved_line = ruby_sourceline;
struct rb_args_info *args = tail->nd_ainfo;
- args->pre_args_num = pre_args ? rb_long2int(pre_args->nd_plen) : 0;
- args->pre_init = pre_args ? pre_args->nd_next : 0;
+ args->pre_args_num = m ? rb_long2int(m->nd_plen) : 0;
+ args->pre_init = m ? m->nd_next : 0;
- args->post_args_num = post_args ? rb_long2int(post_args->nd_plen) : 0;
- args->post_init = post_args ? post_args->nd_next : 0;
- args->first_post_arg = post_args ? post_args->nd_pid : 0;
+ args->post_args_num = p ? rb_long2int(p->nd_plen) : 0;
+ args->post_init = p ? p->nd_next : 0;
+ args->first_post_arg = p ? p->nd_pid : 0;
- args->rest_arg = rest_arg;
+ args->rest_arg = r;
- args->opt_args = opt_args;
+ args->opt_args = o;
- args->ruby2_keywords = rest_arg == idFWD_REST;
-
- p->ruby_sourceline = saved_line;
- nd_set_loc(tail, loc);
+ ruby_sourceline = saved_line;
+ nd_set_loc(tail, location);
return tail;
}
static NODE*
-new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block, const YYLTYPE *loc)
+new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLTYPE *kr_location)
{
- int saved_line = p->ruby_sourceline;
+ int saved_line = ruby_sourceline;
+ struct rb_args_info *args;
NODE *node;
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- struct rb_args_info *args = ZALLOC(struct rb_args_info);
- rb_imemo_tmpbuf_set_ptr(tmpbuf, args);
- args->imemo = tmpbuf;
- node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC);
- RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
- if (p->error_p) return node;
-
- args->block_arg = block;
- args->kw_args = kw_args;
-
- if (kw_args) {
+
+ args = ZALLOC(struct rb_args_info);
+ add_mark_object((VALUE)rb_imemo_alloc_new((VALUE)args, 0, 0, 0));
+ node = NEW_NODE(NODE_ARGS, 0, 0, args);
+ if (parser->error_p) return node;
+
+ args->block_arg = b;
+ args->kw_args = k;
+
+ if (k) {
/*
* def foo(k1: 1, kr1:, k2: 2, **krest, &b)
* variable order: k1, kr1, k2, &b, internal_id, krest
* #=> <reorder>
* variable order: kr1, k1, k2, internal_id, krest, &b
*/
- ID kw_bits = internal_id(p), *required_kw_vars, *kw_vars;
- struct vtable *vtargs = p->lvtbl->args;
- NODE *kwn = kw_args;
+ ID kw_bits;
+ NODE *kwn = k;
+ struct vtable *required_kw_vars = vtable_alloc(NULL);
+ struct vtable *kw_vars = vtable_alloc(NULL);
+ int i;
- vtable_pop(vtargs, !!block + !!kw_rest_arg);
- required_kw_vars = kw_vars = &vtargs->tbl[vtargs->pos];
while (kwn) {
- if (!NODE_REQUIRED_KEYWORD_P(kwn->nd_body))
- --kw_vars;
- --required_kw_vars;
- kwn = kwn->nd_next;
- }
-
- for (kwn = kw_args; kwn; kwn = kwn->nd_next) {
+ NODE *val_node = kwn->nd_body->nd_value;
ID vid = kwn->nd_body->nd_vid;
- if (NODE_REQUIRED_KEYWORD_P(kwn->nd_body)) {
- *required_kw_vars++ = vid;
+
+ if (val_node == NODE_SPECIAL_REQUIRED_KEYWORD) {
+ vtable_add(required_kw_vars, vid);
}
else {
- *kw_vars++ = vid;
+ vtable_add(kw_vars, vid);
}
- }
-
- arg_var(p, kw_bits);
- if (kw_rest_arg) arg_var(p, kw_rest_arg);
- if (block) arg_var(p, block);
-
- args->kw_rest_arg = NEW_DVAR(kw_rest_arg, loc);
- args->kw_rest_arg->nd_cflag = kw_bits;
- }
- else if (kw_rest_arg == idNil) {
- args->no_kwarg = 1;
- }
- else if (kw_rest_arg) {
- args->kw_rest_arg = NEW_DVAR(kw_rest_arg, loc);
- }
-
- p->ruby_sourceline = saved_line;
- return node;
-}
-
-static NODE *
-args_with_numbered(struct parser_params *p, NODE *args, int max_numparam)
-{
- if (max_numparam > NO_PARAM) {
- if (!args) {
- YYLTYPE loc = RUBY_INIT_YYLLOC();
- args = new_args_tail(p, 0, 0, 0, 0);
- nd_set_loc(args, &loc);
- }
- args->nd_ainfo->pre_args_num = max_numparam;
- }
- return args;
-}
-
-static NODE*
-new_array_pattern(struct parser_params *p, NODE *constant, NODE *pre_arg, NODE *aryptn, const YYLTYPE *loc)
-{
- struct rb_ary_pattern_info *apinfo = aryptn->nd_apinfo;
-
- aryptn->nd_pconst = constant;
-
- if (pre_arg) {
- NODE *pre_args = NEW_LIST(pre_arg, loc);
- if (apinfo->pre_args) {
- apinfo->pre_args = list_concat(pre_args, apinfo->pre_args);
- }
- else {
- apinfo->pre_args = pre_args;
- }
- }
- return aryptn;
-}
-
-static NODE*
-new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID rest_arg, NODE *post_args, const YYLTYPE *loc)
-{
- int saved_line = p->ruby_sourceline;
- NODE *node;
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- struct rb_ary_pattern_info *apinfo = ZALLOC(struct rb_ary_pattern_info);
- rb_imemo_tmpbuf_set_ptr(tmpbuf, apinfo);
- node = NEW_NODE(NODE_ARYPTN, 0, 0, apinfo, loc);
- apinfo->imemo = tmpbuf;
- RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
- apinfo->pre_args = pre_args;
-
- if (has_rest) {
- if (rest_arg) {
- apinfo->rest_arg = assignable(p, rest_arg, 0, loc);
- }
- else {
- apinfo->rest_arg = NODE_SPECIAL_NO_NAME_REST;
+ kwn = kwn->nd_next;
}
- }
- else {
- apinfo->rest_arg = NULL;
- }
- apinfo->post_args = post_args;
+ kw_bits = internal_id();
+ if (kr && is_junk_id(kr)) vtable_pop(lvtbl->args, 1);
+ vtable_pop(lvtbl->args, vtable_size(required_kw_vars) + vtable_size(kw_vars) + (b != 0));
- p->ruby_sourceline = saved_line;
- return node;
-}
-
-static NODE*
-new_hash_pattern(struct parser_params *p, NODE *constant, NODE *hshptn, const YYLTYPE *loc)
-{
- hshptn->nd_pconst = constant;
- return hshptn;
-}
+ for (i=0; i<vtable_size(required_kw_vars); i++) arg_var(required_kw_vars->tbl[i]);
+ for (i=0; i<vtable_size(kw_vars); i++) arg_var(kw_vars->tbl[i]);
+ vtable_free(required_kw_vars);
+ vtable_free(kw_vars);
-static NODE*
-new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, const YYLTYPE *loc)
-{
- int saved_line = p->ruby_sourceline;
- NODE *node, *kw_rest_arg_node;
+ arg_var(kw_bits);
+ if (kr) arg_var(kr);
+ if (b) arg_var(b);
- if (kw_rest_arg == idNil) {
- kw_rest_arg_node = NODE_SPECIAL_NO_REST_KEYWORD;
+ args->kw_rest_arg = new_dvar(kr, kr_location);
+ args->kw_rest_arg->nd_cflag = kw_bits;
}
- else if (kw_rest_arg) {
- kw_rest_arg_node = assignable(p, kw_rest_arg, 0, loc);
+ else if (kr) {
+ if (b) vtable_pop(lvtbl->args, 1); /* reorder */
+ arg_var(kr);
+ if (b) arg_var(b);
+ args->kw_rest_arg = new_dvar(kr, kr_location);
}
- else {
- kw_rest_arg_node = NULL;
- }
-
- node = NEW_NODE(NODE_HSHPTN, 0, kw_args, kw_rest_arg_node, loc);
-
- p->ruby_sourceline = saved_line;
- return node;
-}
-static NODE *
-new_case3(struct parser_params *p, NODE *val, NODE *pat, const YYLTYPE *loc)
-{
- NODE *node = NEW_CASE3(val, pat, loc);
-
- if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL))
- rb_warn0L(nd_line(node), "Pattern matching is experimental, and the behavior may change in future versions of Ruby!");
+ ruby_sourceline = saved_line;
return node;
}
static NODE*
-dsym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+dsym_node_gen(struct parser_params *parser, NODE *node, const YYLTYPE *location)
{
VALUE lit;
if (!node) {
- return NEW_LIT(ID2SYM(idNULL), loc);
+ return new_lit(ID2SYM(idNULL), location);
}
switch (nd_type(node)) {
case NODE_DSTR:
nd_set_type(node, NODE_DSYM);
- nd_set_loc(node, loc);
+ nd_set_loc(node, location);
break;
case NODE_STR:
lit = node->nd_lit;
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit = ID2SYM(rb_intern_str(lit)));
+ add_mark_object(node->nd_lit = ID2SYM(rb_intern_str(lit)));
nd_set_type(node, NODE_LIT);
- nd_set_loc(node, loc);
+ nd_set_loc(node, location);
break;
default:
- node = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(node, loc), loc);
+ node = NEW_NODE(NODE_DSYM, Qnil, 1, new_list(node, location));
+ nd_set_loc(node, location);
break;
}
return node;
@@ -11565,11 +10953,10 @@ append_literal_keys(st_data_t k, st_data_t v, st_data_t h)
}
static NODE *
-remove_duplicate_keys(struct parser_params *p, NODE *hash)
+remove_duplicate_keys(struct parser_params *parser, NODE *hash, const YYLTYPE *location)
{
st_table *literal_keys = st_init_numtable_with_size(hash->nd_alen / 2);
NODE *result = 0;
- rb_code_location_t loc = hash->nd_loc;
while (hash && hash->nd_head && hash->nd_next) {
NODE *head = hash->nd_head;
NODE *value = hash->nd_next;
@@ -11578,11 +10965,11 @@ remove_duplicate_keys(struct parser_params *p, NODE *hash)
st_data_t data;
if (nd_type(head) == NODE_LIT &&
st_lookup(literal_keys, (key = head->nd_lit), &data)) {
- rb_compile_warn(p->ruby_sourcefile, nd_line((NODE *)data),
+ rb_compile_warn(ruby_sourcefile, nd_line((NODE *)data),
"key %+"PRIsVALUE" is duplicated and overwritten on line %d",
head->nd_lit, nd_line(head));
head = ((NODE *)data)->nd_next;
- head->nd_head = block_append(p, head->nd_head, value->nd_head);
+ head->nd_head = block_append(head->nd_head, value->nd_head, location);
}
else {
st_insert(literal_keys, (st_data_t)key, (st_data_t)hash);
@@ -11595,66 +10982,34 @@ remove_duplicate_keys(struct parser_params *p, NODE *hash)
if (!result) result = hash;
else list_concat(result, hash);
}
- result->nd_loc = loc;
return result;
}
static NODE *
-new_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc)
-{
- if (hash) hash = remove_duplicate_keys(p, hash);
- return NEW_HASH(hash, loc);
-}
-#endif
-
-static void
-error_duplicate_pattern_variable(struct parser_params *p, ID id, const YYLTYPE *loc)
-{
- if (is_private_local_id(id)) {
- return;
- }
- if (st_is_member(p->pvtbl, id)) {
- yyerror1(loc, "duplicated variable name");
- }
- else {
- st_insert(p->pvtbl, (st_data_t)id, 0);
- }
-}
-
-static void
-error_duplicate_pattern_key(struct parser_params *p, VALUE key, const YYLTYPE *loc)
-{
- if (!p->pktbl) {
- p->pktbl = st_init_numtable();
- }
- else if (st_is_member(p->pktbl, key)) {
- yyerror1(loc, "duplicated key name");
- return;
- }
- st_insert(p->pktbl, (st_data_t)key, 0);
-}
-
-#ifndef RIPPER
-static NODE *
-new_unique_key_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc)
+new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *location)
{
- return NEW_HASH(hash, loc);
+ NODE *nd_hash;
+ if (hash) hash = remove_duplicate_keys(parser, hash, location);
+ nd_hash = NEW_HASH(hash);
+ nd_set_loc(nd_hash, location);
+ return nd_hash;
}
#endif /* !RIPPER */
#ifndef RIPPER
static NODE *
-new_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc)
+new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *location)
{
NODE *asgn;
if (lhs) {
ID vid = lhs->nd_vid;
- YYLTYPE lhs_loc = lhs->nd_loc;
+ YYLTYPE lhs_location = lhs->nd_loc;
if (op == tOROP) {
lhs->nd_value = rhs;
- nd_set_loc(lhs, loc);
- asgn = NEW_OP_ASGN_OR(gettable(p, vid, &lhs_loc), lhs, loc);
+ nd_set_loc(lhs, location);
+ asgn = NEW_OP_ASGN_OR(gettable(vid, &lhs_location), lhs);
+ nd_set_loc(asgn, location);
if (is_notop_id(vid)) {
switch (id_type(vid)) {
case ID_GLOBAL:
@@ -11666,278 +11021,247 @@ new_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, const YYLTYP
}
else if (op == tANDOP) {
lhs->nd_value = rhs;
- nd_set_loc(lhs, loc);
- asgn = NEW_OP_ASGN_AND(gettable(p, vid, &lhs_loc), lhs, loc);
+ nd_set_loc(lhs, location);
+ asgn = NEW_OP_ASGN_AND(gettable(vid, &lhs_location), lhs);
+ nd_set_loc(asgn, location);
}
else {
asgn = lhs;
- asgn->nd_value = NEW_CALL(gettable(p, vid, &lhs_loc), op, NEW_LIST(rhs, &rhs->nd_loc), loc);
- nd_set_loc(asgn, loc);
+ asgn->nd_value = new_call(gettable(vid, &lhs_location), op, new_list(rhs, &rhs->nd_loc), location);
+ nd_set_loc(asgn, location);
}
}
else {
- asgn = NEW_BEGIN(0, loc);
+ asgn = new_begin(0, location);
}
return asgn;
}
static NODE *
-new_ary_op_assign(struct parser_params *p, NODE *ary,
- NODE *args, ID op, NODE *rhs, const YYLTYPE *args_loc, const YYLTYPE *loc)
+new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs,
+ ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *location)
{
NODE *asgn;
- args = make_list(args, args_loc);
- if (nd_type(args) == NODE_BLOCK_PASS) {
- args = NEW_ARGSCAT(args, rhs, loc);
+ if (op == tOROP) {
+ op = 0;
}
- else {
- args = arg_concat(p, args, rhs, loc);
+ else if (op == tANDOP) {
+ op = 1;
}
- asgn = NEW_OP_ASGN1(ary, op, args, loc);
- fixpos(asgn, ary);
- return asgn;
-}
-
-static NODE *
-new_attr_op_assign(struct parser_params *p, NODE *lhs,
- ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc)
-{
- NODE *asgn;
-
- asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs, loc);
+ asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs);
+ nd_set_loc(asgn, location);
fixpos(asgn, lhs);
return asgn;
}
static NODE *
-new_const_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc)
+new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *location)
{
NODE *asgn;
+ if (op == tOROP) {
+ op = 0;
+ }
+ else if (op == tANDOP) {
+ op = 1;
+ }
if (lhs) {
- asgn = NEW_OP_CDECL(lhs, op, rhs, loc);
+ asgn = NEW_OP_CDECL(lhs, op, rhs);
}
else {
- asgn = NEW_BEGIN(0, loc);
+ asgn = new_begin(0, location);
}
fixpos(asgn, lhs);
+ nd_set_loc(asgn, location);
return asgn;
}
static NODE *
-const_decl(struct parser_params *p, NODE *path, const YYLTYPE *loc)
+const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *location)
+{
+ NODE *colon2 = NEW_COLON2(head, mid);
+ nd_set_loc(colon2, location);
+ return colon2;
+}
+
+static NODE *
+const_decl_gen(struct parser_params *parser, NODE *path, const YYLTYPE *location)
{
- if (p->in_def) {
- yyerror1(loc, "dynamic constant assignment");
+ if (in_def) {
+ yyerror0("dynamic constant assignment");
}
- return NEW_CDECL(0, 0, (path), loc);
+ return new_cdecl(0, 0, (path), location);
}
#else
static VALUE
-const_decl(struct parser_params *p, VALUE path)
+new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs)
{
- if (p->in_def) {
+ return dispatch3(opassign, lhs, op, rhs);
+}
+
+static VALUE
+new_attr_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE type, VALUE attr, VALUE op, VALUE rhs)
+{
+ VALUE recv = dispatch3(field, lhs, type, attr);
+ return dispatch3(opassign, recv, op, rhs);
+}
+
+static VALUE
+new_qcall_gen(struct parser_params *parser, VALUE r, VALUE q, VALUE m, VALUE a)
+{
+ VALUE ret = dispatch3(call, (r), (q), (m));
+ return method_optarg(ret, (a));
+}
+
+static VALUE
+const_decl_gen(struct parser_params *parser, VALUE path)
+{
+ if (in_def) {
path = dispatch1(assign_error, path);
- ripper_error(p);
+ ripper_error();
}
return path;
}
static VALUE
-assign_error(struct parser_params *p, VALUE a)
+assign_error_gen(struct parser_params *parser, VALUE a)
{
a = dispatch1(assign_error, a);
- ripper_error(p);
+ ripper_error();
return a;
}
static VALUE
-var_field(struct parser_params *p, VALUE a)
-{
- return ripper_new_yylval(p, get_id(a), dispatch1(var_field, a), 0);
-}
-#endif
-
-#ifndef RIPPER
-static NODE *
-new_bodystmt(struct parser_params *p, NODE *head, NODE *rescue, NODE *rescue_else, NODE *ensure, const YYLTYPE *loc)
+var_field_gen(struct parser_params *parser, VALUE a)
{
- NODE *result = head;
- if (rescue) {
- NODE *tmp = rescue_else ? rescue_else : rescue;
- YYLTYPE rescue_loc = code_loc_gen(&head->nd_loc, &tmp->nd_loc);
-
- result = NEW_RESCUE(head, rescue, rescue_else, &rescue_loc);
- nd_set_line(result, rescue->nd_loc.beg_pos.lineno);
- }
- else if (rescue_else) {
- result = block_append(p, result, rescue_else);
- }
- if (ensure) {
- result = NEW_ENSURE(result, ensure, loc);
- }
- fixpos(result, head);
- return result;
+ return ripper_new_yylval(get_id(a), dispatch1(var_field, a), 0);
}
#endif
static void
-warn_unused_var(struct parser_params *p, struct local_vars *local)
+warn_unused_var(struct parser_params *parser, struct local_vars *local)
{
- int cnt;
+ int i, cnt;
+ ID *v, *u;
if (!local->used) return;
+ v = local->vars->tbl;
+ u = local->used->tbl;
cnt = local->used->pos;
if (cnt != local->vars->pos) {
- rb_parser_fatal(p, "local->used->pos != local->vars->pos");
+ rb_parser_fatal(parser, "local->used->pos != local->vars->pos");
}
-#ifndef RIPPER
- ID *v = local->vars->tbl;
- ID *u = local->used->tbl;
- for (int i = 0; i < cnt; ++i) {
+ for (i = 0; i < cnt; ++i) {
if (!v[i] || (u[i] & LVAR_USED)) continue;
if (is_private_local_id(v[i])) continue;
rb_warn1L((int)u[i], "assigned but unused variable - %"PRIsWARN, rb_id2str(v[i]));
}
-#endif
}
static void
-local_push(struct parser_params *p, int toplevel_scope)
+local_push_gen(struct parser_params *parser, int inherit_dvars)
{
struct local_vars *local;
- int inherits_dvars = toplevel_scope && compile_for_eval;
- int warn_unused_vars = RTEST(ruby_verbose);
local = ALLOC(struct local_vars);
- local->prev = p->lvtbl;
+ local->prev = lvtbl;
local->args = vtable_alloc(0);
- local->vars = vtable_alloc(inherits_dvars ? DVARS_INHERIT : DVARS_TOPSCOPE);
-#ifndef RIPPER
- if (toplevel_scope && compile_for_eval) warn_unused_vars = 0;
- if (toplevel_scope && e_option_supplied(p)) warn_unused_vars = 0;
- local->numparam.outer = 0;
- local->numparam.inner = 0;
- local->numparam.current = 0;
-#endif
- local->used = warn_unused_vars ? vtable_alloc(0) : 0;
-
+ local->vars = vtable_alloc(inherit_dvars ? DVARS_INHERIT : DVARS_TOPSCOPE);
+ local->used = !(inherit_dvars &&
+ (ifndef_ripper(compile_for_eval || e_option_supplied(parser))+0)) &&
+ RTEST(ruby_verbose) ? vtable_alloc(0) : 0;
# if WARN_PAST_SCOPE
local->past = 0;
# endif
- CMDARG_PUSH(0);
- COND_PUSH(0);
- p->lvtbl = local;
+ local->cmdargs = cmdarg_stack;
+ CMDARG_SET(0);
+ lvtbl = local;
}
static void
-local_pop(struct parser_params *p)
+local_pop_gen(struct parser_params *parser)
{
- struct local_vars *local = p->lvtbl->prev;
- if (p->lvtbl->used) {
- warn_unused_var(p, p->lvtbl);
- vtable_free(p->lvtbl->used);
+ struct local_vars *local = lvtbl->prev;
+ if (lvtbl->used) {
+ warn_unused_var(parser, lvtbl);
+ vtable_free(lvtbl->used);
}
# if WARN_PAST_SCOPE
- while (p->lvtbl->past) {
- struct vtable *past = p->lvtbl->past;
- p->lvtbl->past = past->prev;
+ while (lvtbl->past) {
+ struct vtable *past = lvtbl->past;
+ lvtbl->past = past->prev;
vtable_free(past);
}
# endif
- vtable_free(p->lvtbl->args);
- vtable_free(p->lvtbl->vars);
- CMDARG_POP();
- COND_POP();
- ruby_sized_xfree(p->lvtbl, sizeof(*p->lvtbl));
- p->lvtbl = local;
+ vtable_free(lvtbl->args);
+ vtable_free(lvtbl->vars);
+ CMDARG_SET(lvtbl->cmdargs);
+ xfree(lvtbl);
+ lvtbl = local;
}
#ifndef RIPPER
static ID*
-local_tbl(struct parser_params *p)
+local_tbl_gen(struct parser_params *parser)
{
- int cnt_args = vtable_size(p->lvtbl->args);
- int cnt_vars = vtable_size(p->lvtbl->vars);
+ int cnt_args = vtable_size(lvtbl->args);
+ int cnt_vars = vtable_size(lvtbl->vars);
int cnt = cnt_args + cnt_vars;
int i, j;
ID *buf;
if (cnt <= 0) return 0;
- buf = ALLOC_N(ID, cnt + 2);
- MEMCPY(buf+1, p->lvtbl->args->tbl, ID, cnt_args);
+ buf = ALLOC_N(ID, cnt + 1);
+ MEMCPY(buf+1, lvtbl->args->tbl, ID, cnt_args);
/* remove IDs duplicated to warn shadowing */
for (i = 0, j = cnt_args+1; i < cnt_vars; ++i) {
- ID id = p->lvtbl->vars->tbl[i];
- if (!vtable_included(p->lvtbl->args, id)) {
+ ID id = lvtbl->vars->tbl[i];
+ if (!vtable_included(lvtbl->args, id)) {
buf[j++] = id;
}
}
- if (--j < cnt) {
- REALLOC_N(buf, ID, (cnt = j) + 2);
- }
+ if (--j < cnt) REALLOC_N(buf, ID, (cnt = j) + 1);
buf[0] = cnt;
- rb_ast_add_local_table(p->ast, buf);
- return buf;
-}
+ add_mark_object((VALUE)rb_imemo_alloc_new((VALUE)buf, 0, 0, 0));
-static NODE*
-node_newnode_with_locals(struct parser_params *p, enum node_type type, VALUE a1, VALUE a2, const rb_code_location_t *loc)
-{
- ID *a0;
- NODE *n;
-
- a0 = local_tbl(p);
- n = NEW_NODE(type, a0, a1, a2, loc);
- return n;
+ return buf;
}
-
#endif
static void
-numparam_name(struct parser_params *p, ID id)
-{
- if (!NUMPARAM_ID_P(id)) return;
- rb_warn1("`_%d' is reserved for numbered parameter; consider another name",
- WARN_I(NUMPARAM_ID_TO_IDX(id)));
-}
-
-static void
-arg_var(struct parser_params *p, ID id)
+arg_var_gen(struct parser_params *parser, ID id)
{
- numparam_name(p, id);
- vtable_add(p->lvtbl->args, id);
+ vtable_add(lvtbl->args, id);
}
static void
-local_var(struct parser_params *p, ID id)
+local_var_gen(struct parser_params *parser, ID id)
{
- numparam_name(p, id);
- vtable_add(p->lvtbl->vars, id);
- if (p->lvtbl->used) {
- vtable_add(p->lvtbl->used, (ID)p->ruby_sourceline);
+ vtable_add(lvtbl->vars, id);
+ if (lvtbl->used) {
+ vtable_add(lvtbl->used, (ID)ruby_sourceline);
}
}
static int
-local_id_ref(struct parser_params *p, ID id, ID **vidrefp)
+local_id_gen(struct parser_params *parser, ID id, ID **vidrefp)
{
struct vtable *vars, *args, *used;
- vars = p->lvtbl->vars;
- args = p->lvtbl->args;
- used = p->lvtbl->used;
+ vars = lvtbl->vars;
+ args = lvtbl->args;
+ used = lvtbl->used;
- while (vars && !DVARS_TERMINAL_P(vars->prev)) {
+ while (vars && POINTER_P(vars->prev)) {
vars = vars->prev;
args = args->prev;
if (used) used = used->prev;
}
if (vars && vars->prev == DVARS_INHERIT) {
- return rb_local_defined(id, p->parent_iseq);
+ return rb_local_defined(id, parser->base_block);
}
else if (vtable_included(args, id)) {
return 1;
@@ -11949,74 +11273,26 @@ local_id_ref(struct parser_params *p, ID id, ID **vidrefp)
}
}
-static int
-local_id(struct parser_params *p, ID id)
-{
- return local_id_ref(p, id, NULL);
-}
-
-static NODE *
-numparam_push(struct parser_params *p)
-{
-#ifndef RIPPER
- struct local_vars *local = p->lvtbl;
- NODE *inner = local->numparam.inner;
- if (!local->numparam.outer) {
- local->numparam.outer = local->numparam.current;
- }
- local->numparam.inner = 0;
- local->numparam.current = 0;
- return inner;
-#else
- return 0;
-#endif
-}
-
-static void
-numparam_pop(struct parser_params *p, NODE *prev_inner)
-{
-#ifndef RIPPER
- struct local_vars *local = p->lvtbl;
- if (prev_inner) {
- /* prefer first one */
- local->numparam.inner = prev_inner;
- }
- else if (local->numparam.current) {
- /* current and inner are exclusive */
- local->numparam.inner = local->numparam.current;
- }
- if (p->max_numparam > NO_PARAM) {
- /* current and outer are exclusive */
- local->numparam.current = local->numparam.outer;
- local->numparam.outer = 0;
- }
- else {
- /* no numbered parameter */
- local->numparam.current = 0;
- }
-#endif
-}
-
static const struct vtable *
-dyna_push(struct parser_params *p)
+dyna_push_gen(struct parser_params *parser)
{
- p->lvtbl->args = vtable_alloc(p->lvtbl->args);
- p->lvtbl->vars = vtable_alloc(p->lvtbl->vars);
- if (p->lvtbl->used) {
- p->lvtbl->used = vtable_alloc(p->lvtbl->used);
+ lvtbl->args = vtable_alloc(lvtbl->args);
+ lvtbl->vars = vtable_alloc(lvtbl->vars);
+ if (lvtbl->used) {
+ lvtbl->used = vtable_alloc(lvtbl->used);
}
- return p->lvtbl->args;
+ return lvtbl->args;
}
static void
-dyna_pop_vtable(struct parser_params *p, struct vtable **vtblp)
+dyna_pop_vtable(struct parser_params *parser, struct vtable **vtblp)
{
struct vtable *tmp = *vtblp;
*vtblp = tmp->prev;
# if WARN_PAST_SCOPE
- if (p->past_scope_enabled) {
- tmp->prev = p->lvtbl->past;
- p->lvtbl->past = tmp;
+ if (parser->past_scope_enabled) {
+ tmp->prev = lvtbl->past;
+ lvtbl->past = tmp;
return;
}
# endif
@@ -12024,50 +11300,50 @@ dyna_pop_vtable(struct parser_params *p, struct vtable **vtblp)
}
static void
-dyna_pop_1(struct parser_params *p)
+dyna_pop_1(struct parser_params *parser)
{
struct vtable *tmp;
- if ((tmp = p->lvtbl->used) != 0) {
- warn_unused_var(p, p->lvtbl);
- p->lvtbl->used = p->lvtbl->used->prev;
+ if ((tmp = lvtbl->used) != 0) {
+ warn_unused_var(parser, lvtbl);
+ lvtbl->used = lvtbl->used->prev;
vtable_free(tmp);
}
- dyna_pop_vtable(p, &p->lvtbl->args);
- dyna_pop_vtable(p, &p->lvtbl->vars);
+ dyna_pop_vtable(parser, &lvtbl->args);
+ dyna_pop_vtable(parser, &lvtbl->vars);
}
static void
-dyna_pop(struct parser_params *p, const struct vtable *lvargs)
+dyna_pop_gen(struct parser_params *parser, const struct vtable *lvargs)
{
- while (p->lvtbl->args != lvargs) {
- dyna_pop_1(p);
- if (!p->lvtbl->args) {
- struct local_vars *local = p->lvtbl->prev;
- ruby_sized_xfree(p->lvtbl, sizeof(*p->lvtbl));
- p->lvtbl = local;
+ while (lvtbl->args != lvargs) {
+ dyna_pop_1(parser);
+ if (!lvtbl->args) {
+ struct local_vars *local = lvtbl->prev;
+ xfree(lvtbl);
+ lvtbl = local;
}
}
- dyna_pop_1(p);
+ dyna_pop_1(parser);
}
static int
-dyna_in_block(struct parser_params *p)
+dyna_in_block_gen(struct parser_params *parser)
{
- return !DVARS_TERMINAL_P(p->lvtbl->vars) && p->lvtbl->vars->prev != DVARS_TOPSCOPE;
+ return POINTER_P(lvtbl->vars) && lvtbl->vars->prev != DVARS_TOPSCOPE;
}
static int
-dvar_defined_ref(struct parser_params *p, ID id, ID **vidrefp)
+dvar_defined_gen(struct parser_params *parser, ID id, ID **vidrefp)
{
struct vtable *vars, *args, *used;
int i;
- args = p->lvtbl->args;
- vars = p->lvtbl->vars;
- used = p->lvtbl->used;
+ args = lvtbl->args;
+ vars = lvtbl->vars;
+ used = lvtbl->used;
- while (!DVARS_TERMINAL_P(vars)) {
+ while (POINTER_P(vars)) {
if (vtable_included(args, id)) {
return 1;
}
@@ -12082,36 +11358,30 @@ dvar_defined_ref(struct parser_params *p, ID id, ID **vidrefp)
}
if (vars == DVARS_INHERIT) {
- return rb_dvar_defined(id, p->parent_iseq);
+ return rb_dvar_defined(id, parser->base_block);
}
return 0;
}
static int
-dvar_defined(struct parser_params *p, ID id)
-{
- return dvar_defined_ref(p, id, NULL);
-}
-
-static int
-dvar_curr(struct parser_params *p, ID id)
+dvar_curr_gen(struct parser_params *parser, ID id)
{
- return (vtable_included(p->lvtbl->args, id) ||
- vtable_included(p->lvtbl->vars, id));
+ return (vtable_included(lvtbl->args, id) ||
+ vtable_included(lvtbl->vars, id));
}
static void
-reg_fragment_enc_error(struct parser_params* p, VALUE str, int c)
+reg_fragment_enc_error(struct parser_params* parser, VALUE str, int c)
{
- compile_error(p,
+ compile_error(PARSER_ARG
"regexp encoding option '%c' differs from source encoding '%s'",
c, rb_enc_name(rb_enc_get(str)));
}
#ifndef RIPPER
int
-rb_reg_fragment_setenc(struct parser_params* p, VALUE str, int options)
+rb_reg_fragment_setenc(struct parser_params* parser, VALUE str, int options)
{
int c = RE_OPTION_ENCODING_IDX(options);
@@ -12132,7 +11402,7 @@ rb_reg_fragment_setenc(struct parser_params* p, VALUE str, int options)
}
rb_enc_associate(str, rb_ascii8bit_encoding());
}
- else if (p->enc == rb_usascii_encoding()) {
+ else if (current_enc == rb_usascii_encoding()) {
if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
/* raise in re.c */
rb_enc_associate(str, rb_usascii_encoding());
@@ -12148,21 +11418,21 @@ rb_reg_fragment_setenc(struct parser_params* p, VALUE str, int options)
}
static void
-reg_fragment_setenc(struct parser_params* p, VALUE str, int options)
+reg_fragment_setenc_gen(struct parser_params* parser, VALUE str, int options)
{
- int c = rb_reg_fragment_setenc(p, str, options);
- if (c) reg_fragment_enc_error(p, str, c);
+ int c = rb_reg_fragment_setenc(parser, str, options);
+ if (c) reg_fragment_enc_error(parser, str, c);
}
static int
-reg_fragment_check(struct parser_params* p, VALUE str, int options)
+reg_fragment_check_gen(struct parser_params* parser, VALUE str, int options)
{
VALUE err;
- reg_fragment_setenc(p, str, options);
+ reg_fragment_setenc(str, options);
err = rb_reg_check_preprocess(str);
if (err != Qnil) {
err = rb_obj_as_string(err);
- compile_error(p, "%"PRIsVALUE, err);
+ compile_error(PARSER_ARG "%"PRIsVALUE, err);
return 0;
}
return 1;
@@ -12172,7 +11442,7 @@ typedef struct {
struct parser_params* parser;
rb_encoding *enc;
NODE *succ_block;
- const YYLTYPE *loc;
+ const YYLTYPE *location;
} reg_named_capture_assign_t;
static int
@@ -12180,38 +11450,36 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
int back_num, int *back_refs, OnigRegex regex, void *arg0)
{
reg_named_capture_assign_t *arg = (reg_named_capture_assign_t*)arg0;
- struct parser_params* p = arg->parser;
+ struct parser_params* parser = arg->parser;
rb_encoding *enc = arg->enc;
long len = name_end - name;
const char *s = (const char *)name;
ID var;
NODE *node, *succ;
- if (!len) return ST_CONTINUE;
- if (rb_enc_symname_type(s, len, enc, (1U<<ID_LOCAL)) != ID_LOCAL)
+ if (!len || (*name != '_' && ISASCII(*name) && !rb_enc_islower(*name, enc)) ||
+ (len < MAX_WORD_LENGTH && rb_reserved_word(s, (int)len)) ||
+ !rb_enc_symname2_p(s, len, enc)) {
return ST_CONTINUE;
-
- var = intern_cstr(s, len, enc);
- if (len < MAX_WORD_LENGTH && rb_reserved_word(s, (int)len)) {
- if (!lvar_defined(p, var)) return ST_CONTINUE;
}
- node = node_assign(p, assignable(p, var, 0, arg->loc), NEW_LIT(ID2SYM(var), arg->loc), arg->loc);
+ var = intern_cstr(s, len, enc);
+ node = node_assign(assignable(var, 0, arg->location), new_lit(ID2SYM(var), arg->location), arg->location);
succ = arg->succ_block;
- if (!succ) succ = NEW_BEGIN(0, arg->loc);
- succ = block_append(p, succ, node);
+ if (!succ) succ = new_begin(0, arg->location);
+ succ = block_append(succ, node, arg->location);
arg->succ_block = succ;
return ST_CONTINUE;
}
static NODE *
-reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *loc)
+reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *location)
{
reg_named_capture_assign_t arg;
- arg.parser = p;
+ arg.parser = parser;
arg.enc = rb_enc_get(regexp);
arg.succ_block = 0;
- arg.loc = loc;
+ arg.location = location;
onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg);
if (!arg.succ_block) return 0;
@@ -12219,44 +11487,43 @@ reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *l
}
static VALUE
-parser_reg_compile(struct parser_params* p, VALUE str, int options)
+parser_reg_compile(struct parser_params* parser, VALUE str, int options)
{
- reg_fragment_setenc(p, str, options);
- return rb_parser_reg_compile(p, str, options);
+ reg_fragment_setenc(str, options);
+ return rb_parser_reg_compile(parser, str, options);
}
VALUE
-rb_parser_reg_compile(struct parser_params* p, VALUE str, int options)
+rb_parser_reg_compile(struct parser_params* parser, VALUE str, int options)
{
- return rb_reg_compile(str, options & RE_OPTION_MASK, p->ruby_sourcefile, p->ruby_sourceline);
+ return rb_reg_compile(str, options & RE_OPTION_MASK, ruby_sourcefile, ruby_sourceline);
}
static VALUE
-reg_compile(struct parser_params* p, VALUE str, int options)
+reg_compile_gen(struct parser_params* parser, VALUE str, int options)
{
VALUE re;
VALUE err;
err = rb_errinfo();
- re = parser_reg_compile(p, str, options);
+ re = parser_reg_compile(parser, str, options);
if (NIL_P(re)) {
VALUE m = rb_attr_get(rb_errinfo(), idMesg);
rb_set_errinfo(err);
- compile_error(p, "%"PRIsVALUE, m);
+ compile_error(PARSER_ARG "%"PRIsVALUE, m);
return Qnil;
}
return re;
}
#else
static VALUE
-parser_reg_compile(struct parser_params* p, VALUE str, int options, VALUE *errmsg)
+parser_reg_compile(struct parser_params* parser, VALUE str, int options, VALUE *errmsg)
{
VALUE err = rb_errinfo();
VALUE re;
- str = ripper_is_node_yylval(str) ? RNODE(str)->nd_cval : str;
- int c = rb_reg_fragment_setenc(p, str, options);
- if (c) reg_fragment_enc_error(p, str, c);
- re = rb_parser_reg_compile(p, str, options);
+ int c = rb_reg_fragment_setenc(parser, str, options);
+ if (c) reg_fragment_enc_error(parser, str, c);
+ re = rb_parser_reg_compile(parser, str, options);
if (NIL_P(re)) {
*errmsg = rb_attr_get(rb_errinfo(), idMesg);
rb_set_errinfo(err);
@@ -12269,51 +11536,39 @@ parser_reg_compile(struct parser_params* p, VALUE str, int options, VALUE *errms
void
rb_parser_set_options(VALUE vparser, int print, int loop, int chomp, int split)
{
- struct parser_params *p;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- p->do_print = print;
- p->do_loop = loop;
- p->do_chomp = chomp;
- p->do_split = split;
-}
-
-void
-rb_parser_warn_location(VALUE vparser, int warn)
-{
- struct parser_params *p;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- p->warn_location = warn;
+ struct parser_params *parser;
+ TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
+ parser->do_print = print;
+ parser->do_loop = loop;
+ parser->do_chomp = chomp;
+ parser->do_split = split;
}
static NODE *
-parser_append_options(struct parser_params *p, NODE *node)
+parser_append_options(struct parser_params *parser, NODE *node)
{
static const YYLTYPE default_location = {{1, 0}, {1, 0}};
- const YYLTYPE *const LOC = &default_location;
- if (p->do_print) {
- NODE *print = NEW_FCALL(rb_intern("print"),
- NEW_LIST(NEW_GVAR(idLASTLINE, LOC), LOC),
- LOC);
- node = block_append(p, node, print);
+ if (parser->do_print) {
+ node = block_append(node,
+ new_fcall(rb_intern("print"),
+ NEW_ARRAY(new_gvar(idLASTLINE, &default_location)), &default_location),
+ &default_location);
}
- if (p->do_loop) {
- if (p->do_split) {
- NODE *args = NEW_LIST(NEW_GVAR(rb_intern("$;"), LOC), LOC);
- NODE *split = NEW_GASGN(rb_intern("$F"),
- NEW_CALL(NEW_GVAR(idLASTLINE, LOC),
- rb_intern("split"), args, LOC),
- LOC);
- node = block_append(p, split, node);
+ if (parser->do_loop) {
+ if (parser->do_split) {
+ node = block_append(NEW_GASGN(rb_intern("$F"),
+ new_call(new_gvar(idLASTLINE, &default_location),
+ rb_intern("split"), 0, &default_location)),
+ node, &default_location);
}
- if (p->do_chomp) {
- NODE *chomp = NEW_CALL(NEW_GVAR(idLASTLINE, LOC),
- rb_intern("chomp!"), 0, LOC);
- node = block_append(p, chomp, node);
+ if (parser->do_chomp) {
+ node = block_append(new_call(new_gvar(idLASTLINE, &default_location),
+ rb_intern("chomp!"), 0, &default_location), node, &default_location);
}
- node = NEW_WHILE(NEW_VCALL(idGets, LOC), node, 1, LOC);
+ node = NEW_WHILE(NEW_VCALL(idGets), node, 1);
}
return node;
@@ -12326,35 +11581,33 @@ rb_init_parse(void)
(void)nodetype;
(void)nodeline;
}
+#endif /* !RIPPER */
static ID
-internal_id(struct parser_params *p)
+internal_id_gen(struct parser_params *parser)
{
const ID max_id = RB_ID_SERIAL_MAX & ~0xffff;
- ID id = (ID)vtable_size(p->lvtbl->args) + (ID)vtable_size(p->lvtbl->vars);
+ ID id = (ID)vtable_size(lvtbl->args) + (ID)vtable_size(lvtbl->vars);
id = max_id - id;
return ID_STATIC_SYM | ID_INTERNAL | (id << ID_SCOPE_SHIFT);
}
-#endif /* !RIPPER */
static void
-parser_initialize(struct parser_params *p)
+parser_initialize(struct parser_params *parser)
{
/* note: we rely on TypedData_Make_Struct to set most fields to 0 */
- p->command_start = TRUE;
- p->ruby_sourcefile_string = Qnil;
- p->lex.lpar_beg = -1; /* make lambda_beginning_p() == FALSE at first */
- p->node_id = 0;
+ command_start = TRUE;
+ ruby_sourcefile_string = Qnil;
#ifdef RIPPER
- p->delayed.token = Qnil;
- p->result = Qnil;
- p->parsing_thread = Qnil;
+ parser->delayed = Qnil;
+ parser->result = Qnil;
+ parser->parsing_thread = Qnil;
#else
- p->error_buffer = Qfalse;
+ parser->error_buffer = Qfalse;
#endif
- p->debug_buffer = Qnil;
- p->debug_output = rb_stdout;
- p->enc = rb_utf8_encoding();
+ parser->debug_buffer = Qnil;
+ parser->debug_output = rb_stdout;
+ parser->enc = rb_utf8_encoding();
}
#ifdef RIPPER
@@ -12365,51 +11618,50 @@ parser_initialize(struct parser_params *p)
static void
parser_mark(void *ptr)
{
- struct parser_params *p = (struct parser_params*)ptr;
+ struct parser_params *parser = (struct parser_params*)ptr;
- rb_gc_mark(p->lex.input);
- rb_gc_mark(p->lex.prevline);
- rb_gc_mark(p->lex.lastline);
- rb_gc_mark(p->lex.nextline);
- rb_gc_mark(p->ruby_sourcefile_string);
- rb_gc_mark((VALUE)p->lex.strterm);
- rb_gc_mark((VALUE)p->ast);
- rb_gc_mark(p->case_labels);
+ rb_gc_mark(lex_input);
+ rb_gc_mark(lex_prevline);
+ rb_gc_mark(lex_lastline);
+ rb_gc_mark(lex_nextline);
+ rb_gc_mark(ruby_sourcefile_string);
+ rb_gc_mark((VALUE)lex_strterm);
+ rb_gc_mark((VALUE)parser->ast);
#ifndef RIPPER
- rb_gc_mark(p->debug_lines);
- rb_gc_mark(p->compile_option);
- rb_gc_mark(p->error_buffer);
+ rb_gc_mark(ruby_debug_lines);
+ rb_gc_mark(parser->compile_option);
+ rb_gc_mark(parser->error_buffer);
#else
- rb_gc_mark(p->delayed.token);
- rb_gc_mark(p->value);
- rb_gc_mark(p->result);
- rb_gc_mark(p->parsing_thread);
+ rb_gc_mark(parser->delayed);
+ rb_gc_mark(parser->value);
+ rb_gc_mark(parser->result);
+ rb_gc_mark(parser->parsing_thread);
#endif
- rb_gc_mark(p->debug_buffer);
- rb_gc_mark(p->debug_output);
+ rb_gc_mark(parser->debug_buffer);
+ rb_gc_mark(parser->debug_output);
#ifdef YYMALLOC
- rb_gc_mark((VALUE)p->heap);
+ rb_gc_mark((VALUE)parser->heap);
#endif
}
static void
parser_free(void *ptr)
{
- struct parser_params *p = (struct parser_params*)ptr;
+ struct parser_params *parser = (struct parser_params*)ptr;
struct local_vars *local, *prev;
- if (p->tokenbuf) {
- ruby_sized_xfree(p->tokenbuf, p->toksiz);
+ if (tokenbuf) {
+ xfree(tokenbuf);
}
- for (local = p->lvtbl; local; local = prev) {
+ for (local = lvtbl; local; local = prev) {
if (local->vars) xfree(local->vars);
prev = local->prev;
xfree(local);
}
{
token_info *ptinfo;
- while ((ptinfo = p->token_info) != 0) {
- p->token_info = ptinfo->next;
+ while ((ptinfo = parser->token_info) != 0) {
+ parser->token_info = ptinfo->next;
xfree(ptinfo);
}
}
@@ -12419,12 +11671,12 @@ parser_free(void *ptr)
static size_t
parser_memsize(const void *ptr)
{
- struct parser_params *p = (struct parser_params*)ptr;
+ struct parser_params *parser = (struct parser_params*)ptr;
struct local_vars *local;
- size_t size = sizeof(*p);
+ size_t size = sizeof(*parser);
- size += p->toksiz;
- for (local = p->lvtbl; local; local = local->prev) {
+ size += toksiz;
+ for (local = lvtbl; local; local = local->prev) {
size += sizeof(*local);
if (local->vars) size += local->vars->capa * sizeof(ID);
}
@@ -12465,13 +11717,14 @@ rb_parser_new(void)
}
VALUE
-rb_parser_set_context(VALUE vparser, const struct rb_iseq_struct *base, int main)
+rb_parser_set_context(VALUE vparser, const struct rb_block *base, int main)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- p->error_buffer = main ? Qfalse : Qnil;
- p->parent_iseq = base;
+ TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
+ parser->error_buffer = main ? Qfalse : Qnil;
+ parser->base_block = base;
+ in_main = main;
return vparser;
}
#endif
@@ -12481,14 +11734,10 @@ rb_parser_set_context(VALUE vparser, const struct rb_iseq_struct *base, int main
#define rb_parser_encoding ripper_parser_encoding
#define rb_parser_get_yydebug ripper_parser_get_yydebug
#define rb_parser_set_yydebug ripper_parser_set_yydebug
-#define rb_parser_get_debug_output ripper_parser_get_debug_output
-#define rb_parser_set_debug_output ripper_parser_set_debug_output
static VALUE ripper_parser_end_seen_p(VALUE vparser);
static VALUE ripper_parser_encoding(VALUE vparser);
static VALUE ripper_parser_get_yydebug(VALUE self);
static VALUE ripper_parser_set_yydebug(VALUE self, VALUE flag);
-static VALUE ripper_parser_get_debug_output(VALUE self);
-static VALUE ripper_parser_set_debug_output(VALUE self, VALUE output);
/*
* call-seq:
@@ -12499,10 +11748,10 @@ static VALUE ripper_parser_set_debug_output(VALUE self, VALUE output);
static VALUE
ripper_error_p(VALUE vparser)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- return p->error_p ? Qtrue : Qfalse;
+ TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
+ return parser->error_p ? Qtrue : Qfalse;
}
#endif
@@ -12515,10 +11764,10 @@ ripper_error_p(VALUE vparser)
VALUE
rb_parser_end_seen_p(VALUE vparser)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- return p->ruby__end__seen ? Qtrue : Qfalse;
+ TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
+ return ruby__end__seen ? Qtrue : Qfalse;
}
/*
@@ -12530,13 +11779,12 @@ rb_parser_end_seen_p(VALUE vparser)
VALUE
rb_parser_encoding(VALUE vparser)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- return rb_enc_from_encoding(p->enc);
+ TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
+ return rb_enc_from_encoding(current_enc);
}
-#ifdef RIPPER
/*
* call-seq:
* ripper.yydebug -> true or false
@@ -12546,12 +11794,11 @@ rb_parser_encoding(VALUE vparser)
VALUE
rb_parser_get_yydebug(VALUE self)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- return p->debug ? Qtrue : Qfalse;
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
+ return yydebug ? Qtrue : Qfalse;
}
-#endif
/*
* call-seq:
@@ -12562,79 +11809,47 @@ rb_parser_get_yydebug(VALUE self)
VALUE
rb_parser_set_yydebug(VALUE self, VALUE flag)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- p->debug = RTEST(flag);
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
+ yydebug = RTEST(flag);
return flag;
}
-/*
- * call-seq:
- * ripper.debug_output -> obj
- *
- * Get debug output.
- */
-VALUE
-rb_parser_get_debug_output(VALUE self)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- return p->debug_output;
-}
-
-/*
- * call-seq:
- * ripper.debug_output = obj
- *
- * Set debug output.
- */
-VALUE
-rb_parser_set_debug_output(VALUE self, VALUE output)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- return p->debug_output = output;
-}
-
#ifndef RIPPER
#ifdef YYMALLOC
#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
-/* Keep the order; NEWHEAP then xmalloc and ADD2HEAP to get rid of
- * potential memory leak */
-#define NEWHEAP() rb_imemo_tmpbuf_parser_heap(0, p->heap, 0)
-#define ADD2HEAP(new, cnt, ptr) ((p->heap = (new))->ptr = (ptr), \
- (new)->cnt = (cnt), (ptr))
+#define NEWHEAP() rb_imemo_alloc_new(0, (VALUE)parser->heap, 0, 0)
+#define ADD2HEAP(n, c, p) ((parser->heap = (n))->ptr = (p), \
+ (n)->cnt = (c), (p))
void *
-rb_parser_malloc(struct parser_params *p, size_t size)
+rb_parser_malloc(struct parser_params *parser, size_t size)
{
size_t cnt = HEAPCNT(1, size);
- rb_imemo_tmpbuf_t *n = NEWHEAP();
+ rb_imemo_alloc_t *n = NEWHEAP();
void *ptr = xmalloc(size);
return ADD2HEAP(n, cnt, ptr);
}
void *
-rb_parser_calloc(struct parser_params *p, size_t nelem, size_t size)
+rb_parser_calloc(struct parser_params *parser, size_t nelem, size_t size)
{
size_t cnt = HEAPCNT(nelem, size);
- rb_imemo_tmpbuf_t *n = NEWHEAP();
+ rb_imemo_alloc_t *n = NEWHEAP();
void *ptr = xcalloc(nelem, size);
return ADD2HEAP(n, cnt, ptr);
}
void *
-rb_parser_realloc(struct parser_params *p, void *ptr, size_t size)
+rb_parser_realloc(struct parser_params *parser, void *ptr, size_t size)
{
- rb_imemo_tmpbuf_t *n;
+ rb_imemo_alloc_t *n;
size_t cnt = HEAPCNT(1, size);
- if (ptr && (n = p->heap) != NULL) {
+ if (ptr && (n = parser->heap) != NULL) {
do {
if (n->ptr == ptr) {
n->ptr = ptr = xrealloc(ptr, size);
@@ -12649,9 +11864,9 @@ rb_parser_realloc(struct parser_params *p, void *ptr, size_t size)
}
void
-rb_parser_free(struct parser_params *p, void *ptr)
+rb_parser_free(struct parser_params *parser, void *ptr)
{
- rb_imemo_tmpbuf_t **prev = &p->heap, *n;
+ rb_imemo_alloc_t **prev = &parser->heap, *n;
while ((n = *prev) != NULL) {
if (n->ptr == ptr) {
@@ -12666,119 +11881,43 @@ rb_parser_free(struct parser_params *p, void *ptr)
#endif
void
-rb_parser_printf(struct parser_params *p, const char *fmt, ...)
+rb_parser_printf(struct parser_params *parser, const char *fmt, ...)
{
va_list ap;
- VALUE mesg = p->debug_buffer;
+ VALUE mesg = parser->debug_buffer;
- if (NIL_P(mesg)) p->debug_buffer = mesg = rb_str_new(0, 0);
+ if (NIL_P(mesg)) parser->debug_buffer = mesg = rb_str_new(0, 0);
va_start(ap, fmt);
rb_str_vcatf(mesg, fmt, ap);
va_end(ap);
if (RSTRING_END(mesg)[-1] == '\n') {
- rb_io_write(p->debug_output, mesg);
- p->debug_buffer = Qnil;
+ rb_io_write(parser->debug_output, mesg);
+ parser->debug_buffer = Qnil;
}
}
static void
-parser_compile_error(struct parser_params *p, const char *fmt, ...)
+parser_compile_error(struct parser_params *parser, const char *fmt, ...)
{
va_list ap;
- rb_io_flush(p->debug_output);
- p->error_p = 1;
+ rb_io_flush(parser->debug_output);
+ parser->error_p = 1;
va_start(ap, fmt);
- p->error_buffer =
- rb_syntax_error_append(p->error_buffer,
- p->ruby_sourcefile_string,
- p->ruby_sourceline,
- rb_long2int(p->lex.pcur - p->lex.pbeg),
- p->enc, fmt, ap);
+ parser->error_buffer =
+ rb_syntax_error_append(parser->error_buffer,
+ ruby_sourcefile_string,
+ ruby_sourceline,
+ rb_long2int(lex_p - lex_pbeg),
+ current_enc, fmt, ap);
va_end(ap);
}
-
-static size_t
-count_char(const char *str, int c)
-{
- int n = 0;
- while (str[n] == c) ++n;
- return n;
-}
-
-/*
- * strip enclosing double-quotes, same as the default yytnamerr except
- * for that single-quotes matching back-quotes do not stop stripping.
- *
- * "\"`class' keyword\"" => "`class' keyword"
- */
-RUBY_FUNC_EXPORTED size_t
-rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr)
-{
- if (*yystr == '"') {
- size_t yyn = 0, bquote = 0;
- const char *yyp = yystr;
-
- while (*++yyp) {
- switch (*yyp) {
- case '`':
- if (!bquote) {
- bquote = count_char(yyp+1, '`') + 1;
- if (yyres) memcpy(&yyres[yyn], yyp, bquote);
- yyn += bquote;
- yyp += bquote - 1;
- break;
- }
- goto default_char;
-
- case '\'':
- if (bquote && count_char(yyp+1, '\'') + 1 == bquote) {
- if (yyres) memcpy(yyres + yyn, yyp, bquote);
- yyn += bquote;
- yyp += bquote - 1;
- bquote = 0;
- break;
- }
- if (yyp[1] && yyp[1] != '\'' && yyp[2] == '\'') {
- if (yyres) memcpy(yyres + yyn, yyp, 3);
- yyn += 3;
- yyp += 2;
- break;
- }
- goto do_not_strip_quotes;
-
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default_char:
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- case '\0':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- }
- do_not_strip_quotes: ;
- }
-
- if (!yyres) return strlen(yystr);
-
- return (YYSIZE_T)(yystpcpy(yyres, yystr) - yyres);
-}
#endif
#ifdef RIPPER
#ifdef RIPPER_DEBUG
+extern int rb_is_pointer_to_heap(VALUE);
+
/* :nodoc: */
static VALUE
ripper_validate_object(VALUE self, VALUE x)
@@ -12787,9 +11926,11 @@ ripper_validate_object(VALUE self, VALUE x)
if (x == Qtrue) return x;
if (x == Qnil) return x;
if (x == Qundef)
- rb_raise(rb_eArgError, "Qundef given");
+ rb_raise(rb_eArgError, "Qundef given");
if (FIXNUM_P(x)) return x;
if (SYMBOL_P(x)) return x;
+ if (!rb_is_pointer_to_heap(x))
+ rb_raise(rb_eArgError, "invalid pointer: %p", x);
switch (BUILTIN_TYPE(x)) {
case T_STRING:
case T_OBJECT:
@@ -12798,20 +11939,15 @@ ripper_validate_object(VALUE self, VALUE x)
case T_FLOAT:
case T_COMPLEX:
case T_RATIONAL:
- break;
+ return x;
case T_NODE:
- if (nd_type((NODE *)x) != NODE_RIPPER) {
- rb_raise(rb_eArgError, "NODE given: %p", (void *)x);
+ if (nd_type(x) != NODE_RIPPER) {
+ rb_raise(rb_eArgError, "NODE given: %p", x);
}
- x = ((NODE *)x)->nd_rval;
- break;
+ return ((NODE *)x)->nd_rval;
default:
- rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)",
- (void *)x, rb_obj_classname(x));
- }
- if (!RBASIC_CLASS(x)) {
- rb_raise(rb_eArgError, "hidden ruby object: %p (%s)",
- (void *)x, rb_builtin_type_name(TYPE(x)));
+ rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)",
+ x, rb_obj_classname(x));
}
return x;
}
@@ -12820,58 +11956,58 @@ ripper_validate_object(VALUE self, VALUE x)
#define validate(x) ((x) = get_value(x))
static VALUE
-ripper_dispatch0(struct parser_params *p, ID mid)
+ripper_dispatch0(struct parser_params *parser, ID mid)
{
- return rb_funcall(p->value, mid, 0);
+ return rb_funcall(parser->value, mid, 0);
}
static VALUE
-ripper_dispatch1(struct parser_params *p, ID mid, VALUE a)
+ripper_dispatch1(struct parser_params *parser, ID mid, VALUE a)
{
validate(a);
- return rb_funcall(p->value, mid, 1, a);
+ return rb_funcall(parser->value, mid, 1, a);
}
static VALUE
-ripper_dispatch2(struct parser_params *p, ID mid, VALUE a, VALUE b)
+ripper_dispatch2(struct parser_params *parser, ID mid, VALUE a, VALUE b)
{
validate(a);
validate(b);
- return rb_funcall(p->value, mid, 2, a, b);
+ return rb_funcall(parser->value, mid, 2, a, b);
}
static VALUE
-ripper_dispatch3(struct parser_params *p, ID mid, VALUE a, VALUE b, VALUE c)
+ripper_dispatch3(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c)
{
validate(a);
validate(b);
validate(c);
- return rb_funcall(p->value, mid, 3, a, b, c);
+ return rb_funcall(parser->value, mid, 3, a, b, c);
}
static VALUE
-ripper_dispatch4(struct parser_params *p, ID mid, VALUE a, VALUE b, VALUE c, VALUE d)
+ripper_dispatch4(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d)
{
validate(a);
validate(b);
validate(c);
validate(d);
- return rb_funcall(p->value, mid, 4, a, b, c, d);
+ return rb_funcall(parser->value, mid, 4, a, b, c, d);
}
static VALUE
-ripper_dispatch5(struct parser_params *p, ID mid, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e)
+ripper_dispatch5(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e)
{
validate(a);
validate(b);
validate(c);
validate(d);
validate(e);
- return rb_funcall(p->value, mid, 5, a, b, c, d, e);
+ return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
}
static VALUE
-ripper_dispatch7(struct parser_params *p, ID mid, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e, VALUE f, VALUE g)
+ripper_dispatch7(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e, VALUE f, VALUE g)
{
validate(a);
validate(b);
@@ -12880,7 +12016,7 @@ ripper_dispatch7(struct parser_params *p, ID mid, VALUE a, VALUE b, VALUE c, VAL
validate(e);
validate(f);
validate(g);
- return rb_funcall(p->value, mid, 7, a, b, c, d, e, f, g);
+ return rb_funcall(parser->value, mid, 7, a, b, c, d, e, f, g);
}
static ID
@@ -12905,13 +12041,13 @@ ripper_get_value(VALUE v)
}
static void
-ripper_error(struct parser_params *p)
+ripper_error_gen(struct parser_params *parser)
{
- p->error_p = TRUE;
+ parser->error_p = TRUE;
}
static void
-ripper_compile_error(struct parser_params *p, const char *fmt, ...)
+ripper_compile_error(struct parser_params *parser, const char *fmt, ...)
{
VALUE str;
va_list args;
@@ -12919,12 +12055,12 @@ ripper_compile_error(struct parser_params *p, const char *fmt, ...)
va_start(args, fmt);
str = rb_vsprintf(fmt, args);
va_end(args);
- rb_funcall(p->value, rb_intern("compile_error"), 1, str);
- ripper_error(p);
+ rb_funcall(parser->value, rb_intern("compile_error"), 1, str);
+ ripper_error_gen(parser);
}
static VALUE
-ripper_lex_get_generic(struct parser_params *p, VALUE src)
+ripper_lex_get_generic(struct parser_params *parser, VALUE src)
{
VALUE line = rb_funcallv_public(src, id_gets, 0, 0);
if (!NIL_P(line) && !RB_TYPE_P(line, T_STRING)) {
@@ -12936,7 +12072,7 @@ ripper_lex_get_generic(struct parser_params *p, VALUE src)
}
static VALUE
-ripper_lex_io_get(struct parser_params *p, VALUE src)
+ripper_lex_io_get(struct parser_params *parser, VALUE src)
{
return rb_io_gets(src);
}
@@ -12966,23 +12102,23 @@ ripper_s_allocate(VALUE klass)
static VALUE
ripper_initialize(int argc, VALUE *argv, VALUE self)
{
- struct parser_params *p;
+ struct parser_params *parser;
VALUE src, fname, lineno;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
if (RB_TYPE_P(src, T_FILE)) {
- p->lex.gets = ripper_lex_io_get;
+ lex_gets = ripper_lex_io_get;
}
else if (rb_respond_to(src, id_gets)) {
- p->lex.gets = ripper_lex_get_generic;
+ lex_gets = ripper_lex_get_generic;
}
else {
StringValue(src);
- p->lex.gets = lex_get_str;
+ lex_gets = lex_get_str;
}
- p->lex.input = src;
- p->eofp = 0;
+ lex_input = src;
+ parser->eofp = 0;
if (NIL_P(fname)) {
fname = STR_NEW2("(ripper)");
OBJ_FREEZE(fname);
@@ -12991,36 +12127,42 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
StringValueCStr(fname);
fname = rb_str_new_frozen(fname);
}
- parser_initialize(p);
+ parser_initialize(parser);
- p->ruby_sourcefile_string = fname;
- p->ruby_sourcefile = RSTRING_PTR(fname);
- p->ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
+ ruby_sourcefile_string = fname;
+ ruby_sourcefile = RSTRING_PTR(fname);
+ ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
return Qnil;
}
+struct ripper_args {
+ struct parser_params *parser;
+ int argc;
+ VALUE *argv;
+};
+
static VALUE
ripper_parse0(VALUE parser_v)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(parser_v, struct parser_params, &parser_data_type, p);
- parser_prepare(p);
- p->ast = rb_ast_new();
- ripper_yyparse((void*)p);
- rb_ast_dispose(p->ast);
- p->ast = 0;
- return p->result;
+ TypedData_Get_Struct(parser_v, struct parser_params, &parser_data_type, parser);
+ parser_prepare(parser);
+ parser->ast = rb_ast_new();
+ ripper_yyparse((void*)parser);
+ rb_ast_dispose(parser->ast);
+ parser->ast = 0;
+ return parser->result;
}
static VALUE
ripper_ensure(VALUE parser_v)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(parser_v, struct parser_params, &parser_data_type, p);
- p->parsing_thread = Qnil;
+ TypedData_Get_Struct(parser_v, struct parser_params, &parser_data_type, parser);
+ parser->parsing_thread = Qnil;
return Qnil;
}
@@ -13033,22 +12175,22 @@ ripper_ensure(VALUE parser_v)
static VALUE
ripper_parse(VALUE self)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
+ if (!ripper_initialized_p(parser)) {
rb_raise(rb_eArgError, "method called for uninitialized object");
}
- if (!NIL_P(p->parsing_thread)) {
- if (p->parsing_thread == rb_thread_current())
+ if (!NIL_P(parser->parsing_thread)) {
+ if (parser->parsing_thread == rb_thread_current())
rb_raise(rb_eArgError, "Ripper#parse is not reentrant");
else
rb_raise(rb_eArgError, "Ripper#parse is not multithread-safe");
}
- p->parsing_thread = rb_thread_current();
+ parser->parsing_thread = rb_thread_current();
rb_ensure(ripper_parse0, self, ripper_ensure, self);
- return p->result;
+ return parser->result;
}
/*
@@ -13061,15 +12203,15 @@ ripper_parse(VALUE self)
static VALUE
ripper_column(VALUE self)
{
- struct parser_params *p;
+ struct parser_params *parser;
long col;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
+ if (!ripper_initialized_p(parser)) {
rb_raise(rb_eArgError, "method called for uninitialized object");
}
- if (NIL_P(p->parsing_thread)) return Qnil;
- col = p->lex.ptok - p->lex.pbeg;
+ if (NIL_P(parser->parsing_thread)) return Qnil;
+ col = parser->tokp - lex_pbeg;
return LONG2NUM(col);
}
@@ -13082,13 +12224,13 @@ ripper_column(VALUE self)
static VALUE
ripper_filename(VALUE self)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
+ if (!ripper_initialized_p(parser)) {
rb_raise(rb_eArgError, "method called for uninitialized object");
}
- return p->ruby_sourcefile_string;
+ return ruby_sourcefile_string;
}
/*
@@ -13101,14 +12243,14 @@ ripper_filename(VALUE self)
static VALUE
ripper_lineno(VALUE self)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
+ if (!ripper_initialized_p(parser)) {
rb_raise(rb_eArgError, "method called for uninitialized object");
}
- if (NIL_P(p->parsing_thread)) return Qnil;
- return INT2NUM(p->ruby_sourceline);
+ if (NIL_P(parser->parsing_thread)) return Qnil;
+ return INT2NUM(ruby_sourceline);
}
/*
@@ -13120,36 +12262,14 @@ ripper_lineno(VALUE self)
static VALUE
ripper_state(VALUE self)
{
- struct parser_params *p;
+ struct parser_params *parser;
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
+ TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
+ if (!ripper_initialized_p(parser)) {
rb_raise(rb_eArgError, "method called for uninitialized object");
}
- if (NIL_P(p->parsing_thread)) return Qnil;
- return INT2NUM(p->lex.state);
-}
-
-/*
- * call-seq:
- * ripper.token -> String
- *
- * Return the current token string.
- */
-static VALUE
-ripper_token(VALUE self)
-{
- struct parser_params *p;
- long pos, len;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (NIL_P(p->parsing_thread)) return Qnil;
- pos = p->lex.ptok - p->lex.pbeg;
- len = p->lex.pcur - p->lex.ptok;
- return rb_str_subseq(p->lex.lastline, pos, len);
+ if (NIL_P(parser->parsing_thread)) return Qnil;
+ return INT2NUM(lex_state);
}
#ifdef RIPPER_DEBUG
@@ -13172,12 +12292,6 @@ ripper_value(VALUE self, VALUE obj)
}
#endif
-/*
- * call-seq:
- * Ripper.lex_state_name(integer) -> string
- *
- * Returns a string representation of lex_state.
- */
static VALUE
ripper_lex_state_name(VALUE self, VALUE state)
{
@@ -13192,9 +12306,6 @@ Init_ripper(void)
id_warn = rb_intern_const("warn");
id_warning = rb_intern_const("warning");
id_gets = rb_intern_const("gets");
- id_assoc = rb_intern_const("=>");
-
- (void)yystpcpy; /* may not used in newer bison */
InitVM(ripper);
}
@@ -13214,18 +12325,15 @@ InitVM_ripper(void)
rb_define_method(Ripper, "filename", ripper_filename, 0);
rb_define_method(Ripper, "lineno", ripper_lineno, 0);
rb_define_method(Ripper, "state", ripper_state, 0);
- rb_define_method(Ripper, "token", ripper_token, 0);
rb_define_method(Ripper, "end_seen?", rb_parser_end_seen_p, 0);
rb_define_method(Ripper, "encoding", rb_parser_encoding, 0);
rb_define_method(Ripper, "yydebug", rb_parser_get_yydebug, 0);
rb_define_method(Ripper, "yydebug=", rb_parser_set_yydebug, 1);
- rb_define_method(Ripper, "debug_output", rb_parser_get_debug_output, 0);
- rb_define_method(Ripper, "debug_output=", rb_parser_set_debug_output, 1);
rb_define_method(Ripper, "error?", ripper_error_p, 0);
#ifdef RIPPER_DEBUG
- rb_define_method(Ripper, "assert_Qundef", ripper_assert_Qundef, 2);
- rb_define_method(Ripper, "rawVALUE", ripper_value, 1);
- rb_define_method(Ripper, "validate_object", ripper_validate_object, 1);
+ rb_define_method(rb_mKernel, "assert_Qundef", ripper_assert_Qundef, 2);
+ rb_define_method(rb_mKernel, "rawVALUE", ripper_value, 1);
+ rb_define_method(rb_mKernel, "validate_object", ripper_validate_object, 1);
#endif
rb_define_singleton_method(Ripper, "dedent_string", parser_dedent_string, 2);
@@ -13253,10 +12361,3 @@ InitVM_ripper(void)
}
#endif /* RIPPER */
-
-/*
- * Local variables:
- * mode: c
- * c-file-style: "ruby"
- * End:
- */
diff --git a/prelude.rb b/prelude.rb
index be249af751..7cfe0892b3 100644
--- a/prelude.rb
+++ b/prelude.rb
@@ -1,20 +1,140 @@
-class << Thread
+class Thread
+ MUTEX_FOR_THREAD_EXCLUSIVE = Thread::Mutex.new # :nodoc:
+ private_constant :MUTEX_FOR_THREAD_EXCLUSIVE
+
# call-seq:
- # Thread.exclusive { block } -> obj
+ # Thread.exclusive { block } => obj
#
# Wraps the block in a single, VM-global Mutex.synchronize, returning the
# value of the block. A thread executing inside the exclusive section will
# only block other threads which also use the Thread.exclusive mechanism.
- def exclusive(&block) end if false
- mutex = Mutex.new # :nodoc:
- define_method(:exclusive) do |&block|
- warn "Thread.exclusive is deprecated, use Thread::Mutex", uplevel: 1
- mutex.synchronize(&block)
+ def self.exclusive(&block)
+ warn "Thread.exclusive is deprecated, use Thread::Mutex", caller
+ MUTEX_FOR_THREAD_EXCLUSIVE.synchronize(&block)
+ end
+end
+
+class IO
+
+ # call-seq:
+ # ios.read_nonblock(maxlen [, options]) -> string
+ # ios.read_nonblock(maxlen, outbuf [, options]) -> outbuf
+ #
+ # Reads at most <i>maxlen</i> bytes from <em>ios</em> using
+ # the read(2) system call after O_NONBLOCK is set for
+ # the underlying file descriptor.
+ #
+ # If the optional <i>outbuf</i> argument is present,
+ # it must reference a String, which will receive the data.
+ # The <i>outbuf</i> will contain only the received data after the method call
+ # even if it is not empty at the beginning.
+ #
+ # read_nonblock just calls the read(2) system call.
+ # It causes all errors the read(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
+ # The caller should care such errors.
+ #
+ # If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN,
+ # it is extended by IO::WaitReadable.
+ # So IO::WaitReadable can be used to rescue the exceptions for retrying
+ # read_nonblock.
+ #
+ # read_nonblock causes EOFError on EOF.
+ #
+ # If the read byte buffer is not empty,
+ # read_nonblock reads from the buffer like readpartial.
+ # In this case, the read(2) system call is not called.
+ #
+ # When read_nonblock raises an exception kind of IO::WaitReadable,
+ # read_nonblock should not be called
+ # until io is readable for avoiding busy loop.
+ # This can be done as follows.
+ #
+ # # emulates blocking read (readpartial).
+ # begin
+ # result = io.read_nonblock(maxlen)
+ # rescue IO::WaitReadable
+ # IO.select([io])
+ # retry
+ # end
+ #
+ # Although IO#read_nonblock doesn't raise IO::WaitWritable.
+ # OpenSSL::Buffering#read_nonblock can raise IO::WaitWritable.
+ # If IO and SSL should be used polymorphically,
+ # IO::WaitWritable should be rescued too.
+ # See the document of OpenSSL::Buffering#read_nonblock for sample code.
+ #
+ # Note that this method is identical to readpartial
+ # except the non-blocking flag is set.
+ #
+ # By specifying a keyword argument _exception_ to +false+, you can indicate
+ # that read_nonblock should not raise an IO::WaitReadable exception, but
+ # return the symbol +:wait_readable+ instead. At EOF, it will return nil
+ # instead of raising EOFError.
+ def read_nonblock(len, buf = nil, exception: true)
+ __read_nonblock(len, buf, exception)
+ end
+
+ # call-seq:
+ # ios.write_nonblock(string) -> integer
+ # ios.write_nonblock(string [, options]) -> integer
+ #
+ # Writes the given string to <em>ios</em> using
+ # the write(2) system call after O_NONBLOCK is set for
+ # the underlying file descriptor.
+ #
+ # It returns the number of bytes written.
+ #
+ # write_nonblock just calls the write(2) system call.
+ # It causes all errors the write(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
+ # The result may also be smaller than string.length (partial write).
+ # The caller should care such errors and partial write.
+ #
+ # If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN,
+ # it is extended by IO::WaitWritable.
+ # So IO::WaitWritable can be used to rescue the exceptions for retrying write_nonblock.
+ #
+ # # Creates a pipe.
+ # r, w = IO.pipe
+ #
+ # # write_nonblock writes only 65536 bytes and return 65536.
+ # # (The pipe size is 65536 bytes on this environment.)
+ # s = "a" * 100000
+ # p w.write_nonblock(s) #=> 65536
+ #
+ # # write_nonblock cannot write a byte and raise EWOULDBLOCK (EAGAIN).
+ # p w.write_nonblock("b") # Resource temporarily unavailable (Errno::EAGAIN)
+ #
+ # If the write buffer is not empty, it is flushed at first.
+ #
+ # When write_nonblock raises an exception kind of IO::WaitWritable,
+ # write_nonblock should not be called
+ # until io is writable for avoiding busy loop.
+ # This can be done as follows.
+ #
+ # begin
+ # result = io.write_nonblock(string)
+ # rescue IO::WaitWritable, Errno::EINTR
+ # IO.select(nil, [io])
+ # retry
+ # end
+ #
+ # Note that this doesn't guarantee to write all data in string.
+ # The length written is reported as result and it should be checked later.
+ #
+ # On some platforms such as Windows, write_nonblock is not supported
+ # according to the kind of the IO object.
+ # In such cases, write_nonblock raises <code>Errno::EBADF</code>.
+ #
+ # By specifying a keyword argument _exception_ to +false+, you can indicate
+ # that write_nonblock should not raise an IO::WaitWritable exception, but
+ # return the symbol +:wait_writable+ instead.
+ def write_nonblock(buf, exception: true)
+ __write_nonblock(buf, exception)
end
end
+# :stopdoc:
class Binding
- # :nodoc:
def irb
require 'irb'
irb
@@ -32,6 +152,4 @@ module Kernel
# suppress redefinition warning
alias pp pp # :nodoc:
-
- private :pp
end
diff --git a/probes_helper.h b/probes_helper.h
index 115c78d467..1393436b29 100644
--- a/probes_helper.h
+++ b/probes_helper.h
@@ -2,6 +2,7 @@
#define RUBY_PROBES_HELPER_H
#include "ruby/ruby.h"
+#include "probes.h"
struct ruby_dtrace_method_hook_args {
const char *classname;
diff --git a/proc.c b/proc.c
index 0c8889f04b..303fc047c2 100644
--- a/proc.c
+++ b/proc.c
@@ -12,7 +12,6 @@
#include "eval_intern.h"
#include "internal.h"
#include "gc.h"
-#include "vm_core.h"
#include "iseq.h"
/* Proc.new with no block will raise an exception in the future
@@ -25,9 +24,6 @@
# define NO_CLOBBERED(v) (v)
#endif
-#define UPDATE_TYPED_REFERENCE(_type, _ref) *(_type*)&_ref = (_type)rb_gc_location((VALUE)_ref)
-#define UPDATE_REFERENCE(_ref) UPDATE_TYPED_REFERENCE(VALUE, _ref)
-
const rb_cref_t *rb_vm_cref_in_context(VALUE self, VALUE cbase);
struct METHOD {
@@ -43,7 +39,7 @@ VALUE rb_cMethod;
VALUE rb_cBinding;
VALUE rb_cProc;
-static rb_block_call_func bmcall;
+static VALUE bmcall(VALUE, VALUE, int, VALUE *, VALUE);
static int method_arity(VALUE);
static int method_min_max_arity(VALUE, int *max);
@@ -61,54 +57,23 @@ block_mark(const struct rb_block *block)
case block_type_ifunc:
{
const struct rb_captured_block *captured = &block->as.captured;
- RUBY_MARK_NO_PIN_UNLESS_NULL(captured->self);
- RUBY_MARK_NO_PIN_UNLESS_NULL((VALUE)captured->code.val);
+ RUBY_MARK_UNLESS_NULL(captured->self);
+ RUBY_MARK_UNLESS_NULL((VALUE)captured->code.val);
if (captured->ep && captured->ep[VM_ENV_DATA_INDEX_ENV] != Qundef /* cfunc_proc_t */) {
- RUBY_MARK_NO_PIN_UNLESS_NULL(VM_ENV_ENVVAL(captured->ep));
+ RUBY_MARK_UNLESS_NULL(VM_ENV_ENVVAL(captured->ep));
}
}
break;
case block_type_symbol:
- RUBY_MARK_NO_PIN_UNLESS_NULL(block->as.symbol);
- break;
- case block_type_proc:
- RUBY_MARK_NO_PIN_UNLESS_NULL(block->as.proc);
- break;
- }
-}
-
-static void
-block_compact(struct rb_block *block)
-{
- switch (block->type) {
- case block_type_iseq:
- case block_type_ifunc:
- {
- struct rb_captured_block *captured = &block->as.captured;
- captured->self = rb_gc_location(captured->self);
- captured->code.val = rb_gc_location(captured->code.val);
- if (captured->ep && captured->ep[VM_ENV_DATA_INDEX_ENV] != Qundef /* cfunc_proc_t */) {
- UPDATE_REFERENCE(captured->ep[VM_ENV_DATA_INDEX_ENV]);
- }
- }
- break;
- case block_type_symbol:
- block->as.symbol = rb_gc_location(block->as.symbol);
+ RUBY_MARK_UNLESS_NULL(block->as.symbol);
break;
case block_type_proc:
- block->as.proc = rb_gc_location(block->as.proc);
+ RUBY_MARK_UNLESS_NULL(block->as.proc);
break;
}
}
static void
-proc_compact(void *ptr)
-{
- rb_proc_t *proc = ptr;
- block_compact((struct rb_block *)&proc->block);
-}
-
-static void
proc_mark(void *ptr)
{
rb_proc_t *proc = ptr;
@@ -136,7 +101,6 @@ static const rb_data_type_t proc_data_type = {
proc_mark,
RUBY_TYPED_DEFAULT_FREE,
proc_memsize,
- proc_compact,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
@@ -159,11 +123,28 @@ rb_obj_is_proc(VALUE proc)
}
}
+VALUE rb_proc_create(VALUE klass, const struct rb_block *block,
+ int8_t safe_level, int8_t is_from_method, int8_t is_lambda);
+
+/* :nodoc: */
+static VALUE
+proc_dup(VALUE self)
+{
+ VALUE procval;
+ rb_proc_t *src;
+
+ GetProcPtr(self, src);
+ procval = rb_proc_create(rb_cProc, &src->block,
+ src->safe_level, src->is_from_method, src->is_lambda);
+ RB_GC_GUARD(self); /* for: body = proc_dup(body) */
+ return procval;
+}
+
/* :nodoc: */
static VALUE
proc_clone(VALUE self)
{
- VALUE procval = rb_proc_dup(self);
+ VALUE procval = proc_dup(self);
CLONESETUP(procval, self);
return procval;
}
@@ -172,10 +153,8 @@ proc_clone(VALUE self)
* call-seq:
* prc.lambda? -> true or false
*
- * Returns +true+ if a Proc object is lambda.
- * +false+ if non-lambda.
- *
- * The lambda-ness affects argument handling and the behavior of +return+ and +break+.
+ * Returns +true+ for a Proc object for which argument handling is rigid.
+ * Such procs are typically generated by +lambda+.
*
* A Proc object generated by +proc+ ignores extra arguments.
*
@@ -297,19 +276,10 @@ binding_mark(void *ptr)
RUBY_MARK_ENTER("binding");
block_mark(&bind->block);
- rb_gc_mark_movable(bind->pathobj);
+ rb_gc_mark(bind->pathobj);
RUBY_MARK_LEAVE("binding");
}
-static void
-binding_compact(void *ptr)
-{
- rb_binding_t *bind = ptr;
-
- block_compact((struct rb_block *)&bind->block);
- UPDATE_REFERENCE(bind->pathobj);
-}
-
static size_t
binding_memsize(const void *ptr)
{
@@ -322,7 +292,6 @@ const rb_data_type_t ruby_binding_data_type = {
binding_mark,
binding_free,
binding_memsize,
- binding_compact,
},
0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -642,24 +611,6 @@ bind_receiver(VALUE bindval)
return vm_block_self(&bind->block);
}
-/*
- * call-seq:
- * binding.source_location -> [String, Integer]
- *
- * Returns the Ruby source filename and line number of the binding object.
- */
-static VALUE
-bind_location(VALUE bindval)
-{
- VALUE loc[2];
- const rb_binding_t *bind;
- GetBindingPtr(bindval, bind);
- loc[0] = pathobj_path(bind->pathobj);
- loc[1] = INT2FIX(bind->first_lineno);
-
- return rb_ary_new4(2, loc);
-}
-
static VALUE
cfunc_proc_new(VALUE klass, VALUE ifunc, int8_t is_lambda)
{
@@ -696,7 +647,7 @@ sym_proc_new(VALUE klass, VALUE sym)
}
struct vm_ifunc *
-rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc)
+rb_vm_ifunc_new(VALUE (*func)(ANYARGS), const void *data, int min_argc, int max_argc)
{
union {
struct vm_ifunc_argc argc;
@@ -724,7 +675,7 @@ rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int m
return IFUNC_NEW(func, data, arity.packed);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_func_proc_new(rb_block_call_func_t func, VALUE val)
{
struct vm_ifunc *ifunc = rb_vm_ifunc_proc_new(func, (void *)val);
@@ -741,7 +692,7 @@ rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_a
static const char proc_without_block[] = "tried to create Proc object without a block";
static VALUE
-proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
+proc_new(VALUE klass, int8_t is_lambda)
{
VALUE procval;
const rb_execution_context_t *ec = GET_EC();
@@ -753,17 +704,19 @@ proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
if ((block_handler = rb_vm_frame_block_handler(cfp)) != VM_BLOCK_HANDLER_NONE) {
+ const VALUE *lep = rb_vm_ep_local_ep(cfp->ep);
+
+ if (VM_ENV_ESCAPED_P(lep)) {
+ procval = VM_ENV_PROCVAL(lep);
+ goto return_existing_proc;
+ }
+
if (is_lambda) {
- rb_raise(rb_eArgError, proc_without_block);
- }
- else {
- const char *name = kernel ? "Kernel#proc" : "Proc.new";
- rb_warn_deprecated("Capturing the given block using %s",
- "`&block`", name);
+ rb_warn(proc_without_block);
}
}
#else
- if (0);
+ if (0)
#endif
else {
rb_raise(rb_eArgError, proc_without_block);
@@ -775,12 +728,13 @@ proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
case block_handler_type_proc:
procval = VM_BH_TO_PROC(block_handler);
+ return_existing_proc:
if (RBASIC_CLASS(procval) == klass) {
return procval;
}
else {
- VALUE newprocval = rb_proc_dup(procval);
- RBASIC_SET_CLASS(newprocval, klass);
+ VALUE newprocval = proc_dup(procval);
+ RBASIC_SET_CLASS(newprocval, klass);
return newprocval;
}
break;
@@ -792,16 +746,8 @@ proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
break;
case block_handler_type_ifunc:
- return rb_vm_make_proc_lambda(ec, VM_BH_TO_CAPT_BLOCK(block_handler), klass, is_lambda);
case block_handler_type_iseq:
- {
- const struct rb_captured_block *captured = VM_BH_TO_CAPT_BLOCK(block_handler);
- rb_control_frame_t *last_ruby_cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp);
- if (is_lambda && last_ruby_cfp && vm_cfp_forwarded_bh_p(last_ruby_cfp, block_handler)) {
- is_lambda = false;
- }
- return rb_vm_make_proc_lambda(ec, captured, klass, is_lambda);
- }
+ return rb_vm_make_proc_lambda(ec, VM_BH_TO_CAPT_BLOCK(block_handler), klass, is_lambda);
}
VM_UNREACHABLE(proc_new);
return Qnil;
@@ -812,10 +758,10 @@ proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
* Proc.new {|...| block } -> a_proc
* Proc.new -> a_proc
*
- * Creates a new Proc object, bound to the current context. Proc::new
- * may be called without a block only within a method with an
- * attached block, in which case that block is converted to the Proc
- * object.
+ * Creates a new <code>Proc</code> object, bound to the current
+ * context. <code>Proc::new</code> may be called without a block only
+ * within a method with an attached block, in which case that block is
+ * converted to the <code>Proc</code> object.
*
* def proc_from
* Proc.new
@@ -827,67 +773,55 @@ proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
static VALUE
rb_proc_s_new(int argc, VALUE *argv, VALUE klass)
{
- VALUE block = proc_new(klass, FALSE, FALSE);
+ VALUE block = proc_new(klass, FALSE);
- rb_obj_call_init_kw(block, argc, argv, RB_PASS_CALLED_KEYWORDS);
+ rb_obj_call_init(block, argc, argv);
return block;
}
-VALUE
-rb_block_proc(void)
-{
- return proc_new(rb_cProc, FALSE, FALSE);
-}
-
/*
* call-seq:
* proc { |...| block } -> a_proc
*
- * Equivalent to Proc.new.
+ * Equivalent to <code>Proc.new</code>.
*/
-static VALUE
-f_proc(VALUE _)
-{
- return proc_new(rb_cProc, FALSE, TRUE);
-}
-
VALUE
-rb_block_lambda(void)
+rb_block_proc(void)
{
- return proc_new(rb_cProc, TRUE, FALSE);
+ return proc_new(rb_cProc, FALSE);
}
/*
* call-seq:
* lambda { |...| block } -> a_proc
*
- * Equivalent to Proc.new, except the resulting Proc objects check the
- * number of parameters passed when called.
+ * Equivalent to <code>Proc.new</code>, except the resulting Proc objects
+ * check the number of parameters passed when called.
*/
-static VALUE
-f_lambda(VALUE _)
+VALUE
+rb_block_lambda(void)
{
- return rb_block_lambda();
+ return proc_new(rb_cProc, TRUE);
}
-/* Document-method: Proc#===
+/* Document-method: ===
*
* call-seq:
* proc === obj -> result_of_proc
*
- * Invokes the block with +obj+ as the proc's parameter like Proc#call.
- * This allows a proc object to be the target of a +when+ clause
- * in a case statement.
+ * Invokes the block with +obj+ as the proc's parameter like Proc#call. It
+ * is to allow a proc object to be a target of +when+ clause in a case
+ * statement.
*/
/* CHECKME: are the argument checking semantics correct? */
/*
- * Document-method: Proc#[]
- * Document-method: Proc#call
- * Document-method: Proc#yield
+ * Document-method: []
+ * Document-method: call
+ * Document-method: yield
*
* call-seq:
* prc.call(params,...) -> obj
@@ -908,11 +842,11 @@ f_lambda(VALUE _)
* Note that <code>prc.()</code> invokes <code>prc.call()</code> with
* the parameters given. It's syntactic sugar to hide "call".
*
- * For procs created using #lambda or <code>->()</code> an error is
- * generated if the wrong number of parameters are passed to the
- * proc. For procs created using Proc.new or Kernel.proc, extra
- * parameters are silently discarded and missing parameters are set
- * to +nil+.
+ * For procs created using <code>lambda</code> or <code>->()</code> an error
+ * is generated if the wrong number of parameters are passed to the proc.
+ * For procs created using <code>Proc.new</code> or <code>Kernel.proc</code>,
+ * extra parameters are silently discarded and missing parameters are
+ * set to +nil+.
*
* a_proc = proc {|a,b| [a,b] }
* a_proc.call(1) #=> [1, nil]
@@ -945,24 +879,6 @@ check_argc(long argc)
#endif
VALUE
-rb_proc_call_kw(VALUE self, VALUE args, int kw_splat)
-{
- VALUE vret;
- rb_proc_t *proc;
- VALUE v;
- int argc = check_argc(RARRAY_LEN(args));
- const VALUE *argv = RARRAY_CONST_PTR(args);
- GetProcPtr(self, proc);
- v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
- vret = rb_vm_invoke_proc(GET_EC(), proc, argc, argv,
- kw_splat, VM_BLOCK_HANDLER_NONE);
- rb_free_tmp_buffer(&v);
- RB_GC_GUARD(self);
- RB_GC_GUARD(args);
- return vret;
-}
-
-VALUE
rb_proc_call(VALUE self, VALUE args)
{
VALUE vret;
@@ -970,7 +886,7 @@ rb_proc_call(VALUE self, VALUE args)
GetProcPtr(self, proc);
vret = rb_vm_invoke_proc(GET_EC(), proc,
check_argc(RARRAY_LEN(args)), RARRAY_CONST_PTR(args),
- RB_NO_KEYWORDS, VM_BLOCK_HANDLER_NONE);
+ VM_BLOCK_HANDLER_NONE);
RB_GC_GUARD(self);
RB_GC_GUARD(args);
return vret;
@@ -983,27 +899,13 @@ proc_to_block_handler(VALUE procval)
}
VALUE
-rb_proc_call_with_block_kw(VALUE self, int argc, const VALUE *argv, VALUE passed_procval, int kw_splat)
-{
- rb_execution_context_t *ec = GET_EC();
- VALUE vret;
- rb_proc_t *proc;
- VALUE v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
- GetProcPtr(self, proc);
- vret = rb_vm_invoke_proc(ec, proc, argc, argv, kw_splat, proc_to_block_handler(passed_procval));
- rb_free_tmp_buffer(&v);
- RB_GC_GUARD(self);
- return vret;
-}
-
-VALUE
rb_proc_call_with_block(VALUE self, int argc, const VALUE *argv, VALUE passed_procval)
{
rb_execution_context_t *ec = GET_EC();
VALUE vret;
rb_proc_t *proc;
GetProcPtr(self, proc);
- vret = rb_vm_invoke_proc(ec, proc, argc, argv, RB_NO_KEYWORDS, proc_to_block_handler(passed_procval));
+ vret = rb_vm_invoke_proc(ec, proc, argc, argv, proc_to_block_handler(passed_procval));
RB_GC_GUARD(self);
return vret;
}
@@ -1022,8 +924,8 @@ rb_proc_call_with_block(VALUE self, int argc, const VALUE *argv, VALUE passed_pr
* in this latter case, returns n.
* Keyword arguments will be considered as a single additional argument,
* that argument being mandatory if any keyword argument is mandatory.
- * A #proc with no argument declarations is the same as a block
- * declaring <code>||</code> as its arguments.
+ * A <code>proc</code> with no argument declarations
+ * is the same as a block declaring <code>||</code> as its arguments.
*
* proc {}.arity #=> 0
* proc { || }.arity #=> 0
@@ -1238,12 +1140,6 @@ iseq_location(const rb_iseq_t *iseq)
return rb_ary_new4(2, loc);
}
-MJIT_FUNC_EXPORTED VALUE
-rb_iseq_location(const rb_iseq_t *iseq)
-{
- return iseq_location(iseq);
-}
-
/*
* call-seq:
* prc.source_location -> [String, Integer]
@@ -1258,8 +1154,8 @@ rb_proc_location(VALUE self)
return iseq_location(rb_proc_get_iseq(self, 0));
}
-VALUE
-rb_unnamed_parameters(int arity)
+static VALUE
+unnamed_parameters(int arity)
{
VALUE a, param = rb_ary_new2((arity < 0) ? -arity : arity);
int n = (arity < 0) ? ~arity : arity;
@@ -1293,7 +1189,7 @@ rb_proc_parameters(VALUE self)
int is_proc;
const rb_iseq_t *iseq = rb_proc_get_iseq(self, &is_proc);
if (!iseq) {
- return rb_unnamed_parameters(rb_proc_arity(self));
+ return unnamed_parameters(rb_proc_arity(self));
}
return rb_iseq_parameters(iseq, is_proc);
}
@@ -1308,7 +1204,7 @@ rb_hash_proc(st_index_t hash, VALUE prc)
return rb_hash_uint(hash, (st_index_t)proc->block.as.captured.ep >> 16);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_sym_to_proc(VALUE sym)
{
static VALUE sym_proc_cache = Qfalse;
@@ -1316,6 +1212,7 @@ rb_sym_to_proc(VALUE sym)
VALUE proc;
long index;
ID id;
+ VALUE *aryp;
if (!sym_proc_cache) {
sym_proc_cache = rb_ary_tmp_new(SYM_PROC_CACHE_SIZE * 2);
@@ -1326,13 +1223,14 @@ rb_sym_to_proc(VALUE sym)
id = SYM2ID(sym);
index = (id % SYM_PROC_CACHE_SIZE) << 1;
- if (RARRAY_AREF(sym_proc_cache, index) == sym) {
- return RARRAY_AREF(sym_proc_cache, index + 1);
+ aryp = RARRAY_PTR(sym_proc_cache);
+ if (aryp[index] == sym) {
+ return aryp[index + 1];
}
else {
- proc = sym_proc_new(rb_cProc, ID2SYM(id));
- RARRAY_ASET(sym_proc_cache, index, sym);
- RARRAY_ASET(sym_proc_cache, index + 1, proc);
+ proc = sym_proc_new(rb_cProc, ID2SYM(id));
+ aryp[index] = sym;
+ aryp[index + 1] = proc;
return proc;
}
}
@@ -1370,7 +1268,7 @@ rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_i
case block_type_iseq:
{
const rb_iseq_t *iseq = rb_iseq_check(block->as.captured.code.iseq);
- rb_str_catf(str, "%p %"PRIsVALUE":%d", (void *)self,
+ rb_str_catf(str, "%p@%"PRIsVALUE":%d", (void *)self,
rb_iseq_path(iseq),
FIX2INT(iseq->body->location.first_lineno));
}
@@ -1379,12 +1277,13 @@ rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_i
rb_str_catf(str, "%p(&%+"PRIsVALUE")", (void *)self, block->as.symbol);
break;
case block_type_ifunc:
- rb_str_catf(str, "%p", (void *)block->as.captured.code.ifunc);
+ rb_str_catf(str, "%p", block->as.captured.code.ifunc);
break;
}
if (additional_info) rb_str_cat_cstr(str, additional_info);
rb_str_cat_cstr(str, ">");
+ OBJ_INFECT_RAW(str, self);
return str;
}
@@ -1408,8 +1307,9 @@ proc_to_s(VALUE self)
* call-seq:
* prc.to_proc -> proc
*
- * Part of the protocol for converting objects to Proc objects.
- * Instances of class Proc simply return themselves.
+ * Part of the protocol for converting objects to <code>Proc</code>
+ * objects. Instances of class <code>Proc</code> simply return
+ * themselves.
*/
static VALUE
@@ -1422,20 +1322,10 @@ static void
bm_mark(void *ptr)
{
struct METHOD *data = ptr;
- rb_gc_mark_movable(data->recv);
- rb_gc_mark_movable(data->klass);
- rb_gc_mark_movable(data->iclass);
- rb_gc_mark_movable((VALUE)data->me);
-}
-
-static void
-bm_compact(void *ptr)
-{
- struct METHOD *data = ptr;
- UPDATE_REFERENCE(data->recv);
- UPDATE_REFERENCE(data->klass);
- UPDATE_REFERENCE(data->iclass);
- UPDATE_TYPED_REFERENCE(rb_method_entry_t *, data->me);
+ rb_gc_mark(data->recv);
+ rb_gc_mark(data->klass);
+ rb_gc_mark(data->iclass);
+ rb_gc_mark((VALUE)data->me);
}
static size_t
@@ -1450,7 +1340,6 @@ static const rb_data_type_t method_data_type = {
bm_mark,
RUBY_TYPED_DEFAULT_FREE,
bm_memsize,
- bm_compact,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -1497,16 +1386,9 @@ mnew_missing(VALUE klass, VALUE obj, ID id, VALUE mclass)
RB_OBJ_WRITE(method, &data->me, me);
- return method;
-}
+ OBJ_INFECT(method, klass);
-static VALUE
-mnew_missing_by_name(VALUE klass, VALUE obj, VALUE *name, int scope, VALUE mclass)
-{
- VALUE vid = rb_str_intern(*name);
- *name = vid;
- if (!respond_to_missing_p(klass, obj, vid, scope)) return Qfalse;
- return mnew_missing(klass, obj, SYM2ID(vid), mclass);
+ return method;
}
static VALUE
@@ -1536,7 +1418,7 @@ mnew_internal(const rb_method_entry_t *me, VALUE klass, VALUE iclass,
if (me->defined_class) {
VALUE klass = RCLASS_SUPER(RCLASS_ORIGIN(me->defined_class));
id = me->def->original_id;
- me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(klass, id, &iclass);
+ me = (rb_method_entry_t *)rb_callable_method_entry_without_refinements(klass, id, &iclass);
}
else {
VALUE klass = RCLASS_SUPER(me->owner);
@@ -1553,6 +1435,7 @@ mnew_internal(const rb_method_entry_t *me, VALUE klass, VALUE iclass,
RB_OBJ_WRITE(method, &data->iclass, iclass);
RB_OBJ_WRITE(method, &data->me, me);
+ OBJ_INFECT(method, klass);
return method;
}
@@ -1570,10 +1453,10 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
VALUE iclass = Qnil;
if (obj == Qundef) { /* UnboundMethod */
- me = rb_method_entry_with_refinements(klass, id, &iclass);
+ me = rb_method_entry_without_refinements(klass, id, &iclass);
}
else {
- me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(klass, id, &iclass);
+ me = (rb_method_entry_t *)rb_callable_method_entry_without_refinements(klass, id, &iclass);
}
return mnew_from_me(me, klass, iclass, obj, id, mclass, scope);
}
@@ -1589,11 +1472,12 @@ method_entry_defined_class(const rb_method_entry_t *me)
*
* Document-class: Method
*
- * Method objects are created by Object#method, and are associated
- * with a particular object (not just with a class). They may be
- * used to invoke the method within the object, and as a block
- * associated with an iterator. They may also be unbound from one
- * object (creating an UnboundMethod) and bound to another.
+ * Method objects are created by <code>Object#method</code>, and are
+ * associated with a particular object (not just with a class). They
+ * may be used to invoke the method within the object, and as a block
+ * associated with an iterator. They may also be unbound from one
+ * object (creating an <code>UnboundMethod</code>) and bound to
+ * another.
*
* class Thing
* def square(n)
@@ -1606,11 +1490,6 @@ method_entry_defined_class(const rb_method_entry_t *me)
* meth.call(9) #=> 81
* [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9]
*
- * [ 1, 2, 3 ].each(&method(:puts)) #=> prints 1, 2, 3
- *
- * require 'date'
- * %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
- * #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
*/
/*
@@ -1679,8 +1558,8 @@ method_hash(VALUE method)
* meth.unbind -> unbound_method
*
* Dissociates <i>meth</i> from its current receiver. The resulting
- * UnboundMethod can subsequently be bound to a new object of the
- * same class (see UnboundMethod).
+ * <code>UnboundMethod</code> can subsequently be bound to a new object
+ * of the same class (see <code>UnboundMethod</code>).
*/
static VALUE
@@ -1694,8 +1573,8 @@ method_unbind(VALUE obj)
&method_data_type, data);
RB_OBJ_WRITE(method, &data->recv, Qundef);
RB_OBJ_WRITE(method, &data->klass, orig->klass);
- RB_OBJ_WRITE(method, &data->iclass, orig->iclass);
RB_OBJ_WRITE(method, &data->me, rb_method_entry_clone(orig->me));
+ OBJ_INFECT(method, obj);
return method;
}
@@ -1705,8 +1584,6 @@ method_unbind(VALUE obj)
* meth.receiver -> object
*
* Returns the bound receiver of the method object.
- *
- * (1..3).method(:map).receiver # => 1..3
*/
static VALUE
@@ -1761,9 +1638,6 @@ method_original_name(VALUE obj)
* meth.owner -> class_or_module
*
* Returns the class or module that defines the method.
- * See also Method#receiver.
- *
- * (1..3).method(:map).owner #=> Enumerable
*/
static VALUE
@@ -1777,7 +1651,7 @@ method_owner(VALUE obj)
void
rb_method_name_error(VALUE klass, VALUE str)
{
-#define MSG(s) rb_fstring_lit("undefined method `%1$s' for"s" `%2$s'")
+#define MSG(s) rb_fstring_cstr("undefined method `%1$s' for"s" `%2$s'")
VALUE c = klass;
VALUE s;
@@ -1811,8 +1685,10 @@ obj_method(VALUE obj, VALUE vid, int scope)
const VALUE mclass = rb_cMethod;
if (!id) {
- VALUE m = mnew_missing_by_name(klass, obj, &vid, scope, mclass);
- if (m) return m;
+ if (respond_to_missing_p(klass, obj, vid, scope)) {
+ id = rb_intern_str(vid);
+ return mnew_missing(klass, obj, id, mclass);
+ }
rb_method_name_error(klass, vid);
}
return mnew(klass, obj, id, mclass, scope);
@@ -1823,9 +1699,10 @@ obj_method(VALUE obj, VALUE vid, int scope)
* obj.method(sym) -> method
*
* Looks up the named method as a receiver in <i>obj</i>, returning a
- * Method object (or raising NameError). The Method object acts as a
- * closure in <i>obj</i>'s object instance, so instance variables and
- * the value of <code>self</code> remain available.
+ * <code>Method</code> object (or raising <code>NameError</code>). The
+ * <code>Method</code> object acts as a closure in <i>obj</i>'s object
+ * instance, so instance variables and the value of <code>self</code>
+ * remain available.
*
* class Demo
* def initialize(n)
@@ -1843,18 +1720,6 @@ obj_method(VALUE obj, VALUE vid, int scope)
* l = Demo.new('Fred')
* m = l.method("hello")
* m.call #=> "Hello, @iv = Fred"
- *
- * Note that Method implements <code>to_proc</code> method, which
- * means it can be used with iterators.
- *
- * [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
- *
- * out = File.open('test.txt', 'w')
- * [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
- *
- * require 'date'
- * %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
- * #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
*/
VALUE
@@ -1913,8 +1778,10 @@ rb_obj_singleton_method(VALUE obj, VALUE vid)
obj, vid);
}
if (!id) {
- VALUE m = mnew_missing_by_name(klass, obj, &vid, FALSE, rb_cMethod);
- if (m) return m;
+ if (respond_to_missing_p(klass, obj, vid, FALSE)) {
+ id = rb_intern_str(vid);
+ return mnew_missing(klass, obj, id, rb_cMethod);
+ }
goto undef;
}
me = rb_method_entry_at(klass, id);
@@ -1991,10 +1858,8 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
*
* Defines an instance method in the receiver. The _method_
* parameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object.
- * If a block is specified, it is used as the method body.
- * If a block or the _method_ parameter has parameters,
- * they're used as method parameters.
- * This block is evaluated using #instance_eval.
+ * If a block is specified, it is used as the method body. This block
+ * is evaluated using <code>instance_eval</code>.
*
* class A
* def fred
@@ -2004,7 +1869,6 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
* self.class.define_method(name, &block)
* end
* define_method(:wilma) { puts "Charge it!" }
- * define_method(:flint) {|name| puts "I'm #{name}!"}
* end
* class B < A
* define_method(:barney, instance_method(:fred))
@@ -2012,7 +1876,6 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
* a = B.new
* a.barney
* a.wilma
- * a.flint('Dino')
* a.create_method(:betty) { p self }
* a.betty
*
@@ -2020,7 +1883,6 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
*
* In Fred
* Charge it!
- * I'm Dino!
* #<B:0x401b39e8>
*/
@@ -2074,7 +1936,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
}
else {
rb_raise(rb_eTypeError,
- "wrong argument type %s (expected Proc/Method/UnboundMethod)",
+ "wrong argument type %s (expected Proc/Method)",
rb_obj_classname(body));
}
}
@@ -2101,7 +1963,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
RB_GC_GUARD(body);
}
else {
- VALUE procval = rb_proc_dup(body);
+ VALUE procval = proc_dup(body);
if (vm_proc_iseq(procval) != NULL) {
rb_proc_t *proc;
GetProcPtr(procval, proc);
@@ -2125,7 +1987,6 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
* Defines a singleton method in the receiver. The _method_
* parameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object.
* If a block is specified, it is used as the method body.
- * If a block or a method has parameters, they're used as method parameters.
*
* class A
* class << self
@@ -2142,10 +2003,6 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
* guy = "Bob"
* guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
* guy.hello #=> "Bob: Hello there!"
- *
- * chris = "Chris"
- * chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
- * chris.greet("Hi") #=> "Hi, I'm Chris!"
*/
static VALUE
@@ -2207,45 +2064,14 @@ method_clone(VALUE self)
CLONESETUP(clone, self);
RB_OBJ_WRITE(clone, &data->recv, orig->recv);
RB_OBJ_WRITE(clone, &data->klass, orig->klass);
- RB_OBJ_WRITE(clone, &data->iclass, orig->iclass);
RB_OBJ_WRITE(clone, &data->me, rb_method_entry_clone(orig->me));
return clone;
}
-/* Document-method: Method#===
- *
- * call-seq:
- * method === obj -> result_of_method
- *
- * Invokes the method with +obj+ as the parameter like #call.
- * This allows a method object to be the target of a +when+ clause
- * in a case statement.
- *
- * require 'prime'
- *
- * case 1373
- * when Prime.method(:prime?)
- * # ...
- * end
- */
-
-
-/* Document-method: Method#[]
- *
- * call-seq:
- * meth[args, ...] -> obj
- *
- * Invokes the <i>meth</i> with the specified arguments, returning the
- * method's return value, like #call.
- *
- * m = 12.method("+")
- * m[3] #=> 15
- * m[20] #=> 32
- */
-
/*
* call-seq:
* meth.call(args, ...) -> obj
+ * meth[args, ...] -> obj
*
* Invokes the <i>meth</i> with the specified arguments, returning the
* method's return value.
@@ -2255,20 +2081,6 @@ method_clone(VALUE self)
* m.call(20) #=> 32
*/
-static VALUE
-rb_method_call_pass_called_kw(int argc, const VALUE *argv, VALUE method)
-{
- VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil;
- return rb_method_call_with_block_kw(argc, argv, method, procval, RB_PASS_CALLED_KEYWORDS);
-}
-
-VALUE
-rb_method_call_kw(int argc, const VALUE *argv, VALUE method, int kw_splat)
-{
- VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil;
- return rb_method_call_with_block_kw(argc, argv, method, procval, kw_splat);
-}
-
VALUE
rb_method_call(int argc, const VALUE *argv, VALUE method)
{
@@ -2285,15 +2097,36 @@ method_callable_method_entry(const struct METHOD *data)
static inline VALUE
call_method_data(rb_execution_context_t *ec, const struct METHOD *data,
- int argc, const VALUE *argv, VALUE passed_procval, int kw_splat)
+ int argc, const VALUE *argv, VALUE passed_procval)
{
vm_passed_block_handler_set(ec, proc_to_block_handler(passed_procval));
- return rb_vm_call_kw(ec, data->recv, data->me->called_id, argc, argv,
- method_callable_method_entry(data), kw_splat);
+ return rb_vm_call(ec, data->recv, data->me->called_id, argc, argv,
+ method_callable_method_entry(data));
+}
+
+static VALUE
+call_method_data_safe(rb_execution_context_t *ec, const struct METHOD *data,
+ int argc, const VALUE *argv, VALUE passed_procval,
+ int safe)
+{
+ VALUE result = Qnil; /* OK */
+ enum ruby_tag_type state;
+
+ EC_PUSH_TAG(ec);
+ if ((state = EC_EXEC_TAG()) == TAG_NONE) {
+ /* result is used only if state == 0, no exceptions is caught. */
+ /* otherwise it doesn't matter even if clobbered. */
+ NO_CLOBBERED(result) = call_method_data(ec, data, argc, argv, passed_procval);
+ }
+ EC_POP_TAG();
+ rb_set_safe_level_force(safe);
+ if (state)
+ EC_JUMP_TAG(ec, state);
+ return result;
}
VALUE
-rb_method_call_with_block_kw(int argc, const VALUE *argv, VALUE method, VALUE passed_procval, int kw_splat)
+rb_method_call_with_block(int argc, const VALUE *argv, VALUE method, VALUE passed_procval)
{
const struct METHOD *data;
rb_execution_context_t *ec = GET_EC();
@@ -2302,29 +2135,32 @@ rb_method_call_with_block_kw(int argc, const VALUE *argv, VALUE method, VALUE pa
if (data->recv == Qundef) {
rb_raise(rb_eTypeError, "can't call unbound method; bind first");
}
- return call_method_data(ec, data, argc, argv, passed_procval, kw_splat);
-}
-
-VALUE
-rb_method_call_with_block(int argc, const VALUE *argv, VALUE method, VALUE passed_procval)
-{
- return rb_method_call_with_block_kw(argc, argv, method, passed_procval, RB_NO_KEYWORDS);
+ if (OBJ_TAINTED(method)) {
+ const int safe_level_to_run = RUBY_SAFE_LEVEL_MAX;
+ int safe = rb_safe_level();
+ if (safe < safe_level_to_run) {
+ rb_set_safe_level_force(safe_level_to_run);
+ return call_method_data_safe(ec, data, argc, argv, passed_procval, safe);
+ }
+ }
+ return call_method_data(ec, data, argc, argv, passed_procval);
}
/**********************************************************************
*
* Document-class: UnboundMethod
*
- * Ruby supports two forms of objectified methods. Class Method is
- * used to represent methods that are associated with a particular
- * object: these method objects are bound to that object. Bound
- * method objects for an object can be created using Object#method.
+ * Ruby supports two forms of objectified methods. Class
+ * <code>Method</code> is used to represent methods that are associated
+ * with a particular object: these method objects are bound to that
+ * object. Bound method objects for an object can be created using
+ * <code>Object#method</code>.
*
* Ruby also supports unbound methods; methods objects that are not
- * associated with a particular object. These can be created either
- * by calling Module#instance_method or by calling #unbind on a bound
- * method object. The result of both of these is an UnboundMethod
- * object.
+ * associated with a particular object. These can be created either by
+ * calling <code>Module#instance_method</code> or by calling
+ * <code>unbind</code> on a bound method object. The result of both of
+ * these is an <code>UnboundMethod</code> object.
*
* Unbound methods can only be called after they are bound to an
* object. That object must be a kind_of? the method's original
@@ -2366,56 +2202,13 @@ rb_method_call_with_block(int argc, const VALUE *argv, VALUE method, VALUE passe
*
*/
-static void
-convert_umethod_to_method_components(VALUE method, VALUE recv, VALUE *methclass_out, VALUE *klass_out, VALUE *iclass_out, const rb_method_entry_t **me_out)
-{
- struct METHOD *data;
-
- TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
-
- VALUE methclass = data->me->owner;
- VALUE iclass = data->me->defined_class;
- VALUE klass = CLASS_OF(recv);
-
- if (!RB_TYPE_P(methclass, T_MODULE) &&
- methclass != CLASS_OF(recv) && !rb_obj_is_kind_of(recv, methclass)) {
- if (FL_TEST(methclass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError,
- "singleton method called for a different object");
- }
- else {
- rb_raise(rb_eTypeError, "bind argument must be an instance of % "PRIsVALUE,
- methclass);
- }
- }
-
- const rb_method_entry_t *me = rb_method_entry_clone(data->me);
-
- if (RB_TYPE_P(me->owner, T_MODULE)) {
- VALUE ic = rb_class_search_ancestor(klass, me->owner);
- if (ic) {
- klass = ic;
- iclass = ic;
- }
- else {
- klass = rb_include_class_new(methclass, klass);
- }
- me = (const rb_method_entry_t *) rb_method_entry_complement_defined_class(me, me->called_id, klass);
- }
-
- *methclass_out = methclass;
- *klass_out = klass;
- *iclass_out = iclass;
- *me_out = me;
-}
-
/*
* call-seq:
* umeth.bind(obj) -> method
*
- * Bind <i>umeth</i> to <i>obj</i>. If Klass was the class from which
- * <i>umeth</i> was obtained, <code>obj.kind_of?(Klass)</code> must
- * be true.
+ * Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
+ * from which <i>umeth</i> was obtained,
+ * <code>obj.kind_of?(Klass)</code> must be true.
*
* class A
* def test
@@ -2447,45 +2240,44 @@ convert_umethod_to_method_components(VALUE method, VALUE recv, VALUE *methclass_
static VALUE
umethod_bind(VALUE method, VALUE recv)
{
- VALUE methclass, klass, iclass;
- const rb_method_entry_t *me;
- convert_umethod_to_method_components(method, recv, &methclass, &klass, &iclass, &me);
+ struct METHOD *data, *bound;
+ VALUE methclass, klass;
- struct METHOD *bound;
- method = TypedData_Make_Struct(rb_cMethod, struct METHOD, &method_data_type, bound);
- RB_OBJ_WRITE(method, &bound->recv, recv);
- RB_OBJ_WRITE(method, &bound->klass, klass);
- RB_OBJ_WRITE(method, &bound->iclass, iclass);
- RB_OBJ_WRITE(method, &bound->me, me);
+ TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
- return method;
-}
+ methclass = data->me->owner;
-/*
- * call-seq:
- * umeth.bind_call(recv, args, ...) -> obj
- *
- * Bind <i>umeth</i> to <i>recv</i> and then invokes the method with the
- * specified arguments.
- * This is semantically equivalent to <code>umeth.bind(recv).call(args, ...)</code>.
- */
-static VALUE
-umethod_bind_call(int argc, VALUE *argv, VALUE method)
-{
- rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
- VALUE recv = argv[0];
- argc--;
- argv++;
+ if (!RB_TYPE_P(methclass, T_MODULE) &&
+ methclass != CLASS_OF(recv) && !rb_obj_is_kind_of(recv, methclass)) {
+ if (FL_TEST(methclass, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError,
+ "singleton method called for a different object");
+ }
+ else {
+ rb_raise(rb_eTypeError, "bind argument must be an instance of % "PRIsVALUE,
+ methclass);
+ }
+ }
- VALUE methclass, klass, iclass;
- const rb_method_entry_t *me;
- convert_umethod_to_method_components(method, recv, &methclass, &klass, &iclass, &me);
- struct METHOD bound = { recv, klass, 0, me };
+ klass = CLASS_OF(recv);
- VALUE passed_procval = rb_block_given_p() ? rb_block_proc() : Qnil;
+ method = TypedData_Make_Struct(rb_cMethod, struct METHOD, &method_data_type, bound);
+ RB_OBJ_WRITE(method, &bound->recv, recv);
+ RB_OBJ_WRITE(method, &bound->klass, data->klass);
+ RB_OBJ_WRITE(method, &bound->me, rb_method_entry_clone(data->me));
- rb_execution_context_t *ec = GET_EC();
- return call_method_data(ec, &bound, argc, argv, passed_procval, RB_PASS_CALLED_KEYWORDS);
+ if (RB_TYPE_P(bound->me->owner, T_MODULE)) {
+ VALUE ic = rb_class_search_ancestor(klass, bound->me->owner);
+ if (ic) {
+ klass = ic;
+ }
+ else {
+ klass = rb_include_class_new(methclass, klass);
+ }
+ RB_OBJ_WRITE(method, &bound->me, rb_method_entry_complement_defined_class(bound->me, bound->me->called_id, klass));
+ }
+
+ return method;
}
/*
@@ -2518,7 +2310,7 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
def = def->body.alias.original_me->def;
goto again;
case VM_METHOD_TYPE_BMETHOD:
- return rb_proc_min_max_arity(def->body.bmethod.proc, max);
+ return rb_proc_min_max_arity(def->body.proc, max);
case VM_METHOD_TYPE_ISEQ:
return rb_iseq_min_max_arity(rb_iseq_check(def->body.iseq.iseqptr), max);
case VM_METHOD_TYPE_UNDEF:
@@ -2535,9 +2327,6 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
case OPTIMIZED_METHOD_TYPE_CALL:
*max = UNLIMITED_ARGUMENTS;
return 0;
- case OPTIMIZED_METHOD_TYPE_BLOCK_CALL:
- *max = UNLIMITED_ARGUMENTS;
- return 0;
default:
break;
}
@@ -2548,7 +2337,7 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
return 0;
}
rb_bug("rb_method_entry_min_max_arity: invalid method entry type (%d)", def->type);
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
int
@@ -2654,8 +2443,8 @@ rb_obj_method_arity(VALUE obj, ID id)
return rb_mod_method_arity(CLASS_OF(obj), id);
}
-const rb_method_definition_t *
-rb_method_def(VALUE method)
+static inline const rb_method_definition_t *
+method_def(VALUE method)
{
const struct METHOD *data;
@@ -2670,7 +2459,7 @@ method_def_iseq(const rb_method_definition_t *def)
case VM_METHOD_TYPE_ISEQ:
return rb_iseq_check(def->body.iseq.iseqptr);
case VM_METHOD_TYPE_BMETHOD:
- return rb_proc_get_iseq(def->body.bmethod.proc, 0);
+ return rb_proc_get_iseq(def->body.proc, 0);
case VM_METHOD_TYPE_ALIAS:
return method_def_iseq(def->body.alias.original_me->def);
case VM_METHOD_TYPE_CFUNC:
@@ -2690,13 +2479,13 @@ method_def_iseq(const rb_method_definition_t *def)
const rb_iseq_t *
rb_method_iseq(VALUE method)
{
- return method_def_iseq(rb_method_def(method));
+ return method_def_iseq(method_def(method));
}
static const rb_cref_t *
method_cref(VALUE method)
{
- const rb_method_definition_t *def = rb_method_def(method);
+ const rb_method_definition_t *def = method_def(method);
again:
switch (def->type) {
@@ -2728,6 +2517,19 @@ rb_method_entry_location(const rb_method_entry_t *me)
return method_def_location(me->def);
}
+VALUE
+rb_mod_method_location(VALUE mod, ID id)
+{
+ const rb_method_entry_t *me = original_method_entry(mod, id);
+ return rb_method_entry_location(me);
+}
+
+VALUE
+rb_obj_method_location(VALUE obj, ID id)
+{
+ return rb_mod_method_location(CLASS_OF(obj), id);
+}
+
/*
* call-seq:
* meth.source_location -> [String, Integer]
@@ -2739,7 +2541,7 @@ rb_method_entry_location(const rb_method_entry_t *me)
VALUE
rb_method_location(VALUE method)
{
- return method_def_location(rb_method_def(method));
+ return method_def_location(method_def(method));
}
/*
@@ -2766,7 +2568,7 @@ rb_method_parameters(VALUE method)
{
const rb_iseq_t *iseq = rb_method_iseq(method);
if (!iseq) {
- return rb_unnamed_parameters(method_arity(method));
+ return unnamed_parameters(method_arity(method));
}
return rb_iseq_parameters(iseq, 0);
}
@@ -2776,32 +2578,9 @@ rb_method_parameters(VALUE method)
* meth.to_s -> string
* meth.inspect -> string
*
- * Returns a human-readable description of the underlying method.
- *
- * "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
- * (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map()>"
- *
- * In the latter case, the method description includes the "owner" of the
- * original method (+Enumerable+ module, which is included into +Range+).
- *
- * +inspect+ also provides, when possible, method argument names (call
- * sequence) and source location.
+ * Returns the name of the underlying method.
*
- * require 'net/http'
- * Net::HTTP.method(:get).inspect
- * #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
- *
- * <code>...</code> in argument definition means argument is optional (has
- * some default value).
- *
- * For methods defined in C (language core and extensions), location and
- * argument names can't be extracted, and only generic information is provided
- * in form of <code>*</code> (any number of arguments) or <code>_</code> (some
- * positional argument).
- *
- * "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
- * "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
-
+ * "cat".method(:count).inspect #=> "#<Method: String#count>"
*/
static VALUE
@@ -2815,17 +2594,10 @@ method_inspect(VALUE method)
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
str = rb_sprintf("#<% "PRIsVALUE": ", rb_obj_class(method));
+ OBJ_INFECT_RAW(str, method);
mklass = data->klass;
- if (RB_TYPE_P(mklass, T_ICLASS)) {
- /* TODO: I'm not sure why mklass is T_ICLASS.
- * UnboundMethod#bind() can set it as T_ICLASS at convert_umethod_to_method_components()
- * but not sure it is needed.
- */
- mklass = RBASIC_CLASS(mklass);
- }
-
if (data->me->def->type == VM_METHOD_TYPE_ALIAS) {
defined_class = data->me->def->body.alias.original_me->owner;
}
@@ -2870,100 +2642,6 @@ method_inspect(VALUE method)
if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
rb_str_buf_cat2(str, " (not-implemented)");
}
-
- // parameter information
- {
- VALUE params = rb_method_parameters(method);
- VALUE pair, name, kind;
- const VALUE req = ID2SYM(rb_intern("req"));
- const VALUE opt = ID2SYM(rb_intern("opt"));
- const VALUE keyreq = ID2SYM(rb_intern("keyreq"));
- const VALUE key = ID2SYM(rb_intern("key"));
- const VALUE rest = ID2SYM(rb_intern("rest"));
- const VALUE keyrest = ID2SYM(rb_intern("keyrest"));
- const VALUE block = ID2SYM(rb_intern("block"));
- const VALUE nokey = ID2SYM(rb_intern("nokey"));
- int forwarding = 0;
-
- rb_str_buf_cat2(str, "(");
-
- for (int i = 0; i < RARRAY_LEN(params); i++) {
- pair = RARRAY_AREF(params, i);
- kind = RARRAY_AREF(pair, 0);
- name = RARRAY_AREF(pair, 1);
- // FIXME: in tests it turns out that kind, name = [:req] produces name to be false. Why?..
- if (NIL_P(name) || name == Qfalse) {
- // FIXME: can it be reduced to switch/case?
- if (kind == req || kind == opt) {
- name = rb_str_new2("_");
- }
- else if (kind == rest || kind == keyrest) {
- name = rb_str_new2("");
- }
- else if (kind == block) {
- name = rb_str_new2("block");
- }
- else if (kind == nokey) {
- name = rb_str_new2("nil");
- }
- }
-
- if (kind == req) {
- rb_str_catf(str, "%"PRIsVALUE, name);
- }
- else if (kind == opt) {
- rb_str_catf(str, "%"PRIsVALUE"=...", name);
- }
- else if (kind == keyreq) {
- rb_str_catf(str, "%"PRIsVALUE":", name);
- }
- else if (kind == key) {
- rb_str_catf(str, "%"PRIsVALUE": ...", name);
- }
- else if (kind == rest) {
- if (name == ID2SYM('*')) {
- forwarding = 1;
- rb_str_cat_cstr(str, "...");
- }
- else {
- rb_str_catf(str, "*%"PRIsVALUE, name);
- }
- }
- else if (kind == keyrest) {
- rb_str_catf(str, "**%"PRIsVALUE, name);
- }
- else if (kind == block) {
- if (name == ID2SYM('&')) {
- if (forwarding) {
- rb_str_set_len(str, RSTRING_LEN(str) - 2);
- }
- else {
- rb_str_cat_cstr(str, "...");
- }
- }
- else {
- rb_str_catf(str, "&%"PRIsVALUE, name);
- }
- }
- else if (kind == nokey) {
- rb_str_buf_cat2(str, "**nil");
- }
-
- if (i < RARRAY_LEN(params) - 1) {
- rb_str_buf_cat2(str, ", ");
- }
- }
- rb_str_buf_cat2(str, ")");
- }
-
- { // source location
- VALUE loc = rb_method_location(method);
- if (!NIL_P(loc)) {
- rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE,
- RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1));
- }
- }
-
rb_str_buf_cat2(str, ">");
return str;
@@ -2982,14 +2660,14 @@ mlambda(VALUE method)
}
static VALUE
-bmcall(RB_BLOCK_CALL_FUNC_ARGLIST(args, method))
+bmcall(VALUE args, VALUE method, int argc, VALUE *argv, VALUE passed_proc)
{
- return rb_method_call_with_block_kw(argc, argv, method, blockarg, RB_PASS_CALLED_KEYWORDS);
+ return rb_method_call_with_block(argc, argv, method, passed_proc);
}
VALUE
rb_proc_new(
- rb_block_call_func_t func,
+ VALUE (*func)(ANYARGS), /* VALUE yieldarg[, VALUE procarg] */
VALUE val)
{
VALUE procval = rb_iterate(mproc, 0, func, val);
@@ -3000,7 +2678,7 @@ rb_proc_new(
* call-seq:
* meth.to_proc -> proc
*
- * Returns a Proc object corresponding to this method.
+ * Returns a <code>Proc</code> object corresponding to this method.
*/
static VALUE
@@ -3024,8 +2702,6 @@ method_to_proc(VALUE method)
return procval;
}
-extern VALUE rb_find_defined_class_by_owner(VALUE current_class, VALUE target_owner);
-
/*
* call-seq:
* meth.super_method -> method
@@ -3045,17 +2721,10 @@ method_super_method(VALUE method)
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
iclass = data->iclass;
if (!iclass) return Qnil;
- if (data->me->def->type == VM_METHOD_TYPE_ALIAS && data->me->defined_class) {
- super_class = RCLASS_SUPER(rb_find_defined_class_by_owner(data->me->defined_class,
- data->me->def->body.alias.original_me->owner));
- mid = data->me->def->body.alias.original_me->def->original_id;
- }
- else {
- super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass));
- mid = data->me->def->original_id;
- }
+ super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass));
+ mid = data->me->called_id;
if (!super_class) return Qnil;
- me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(super_class, mid, &iclass);
+ me = (rb_method_entry_t *)rb_callable_method_entry_without_refinements(super_class, mid, &iclass);
if (!me) return Qnil;
return mnew_internal(me, me->owner, iclass, data->recv, mid, rb_obj_class(method), FALSE, FALSE);
}
@@ -3115,7 +2784,9 @@ env_clone(const rb_env_t *env, const rb_cref_t *cref)
* call-seq:
* prc.binding -> binding
*
- * Returns the binding associated with <i>prc</i>.
+ * Returns the binding associated with <i>prc</i>. Note that
+ * <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
+ * <code>Binding</code> object as its second parameter.
*
* def fred(param)
* proc {}
@@ -3155,15 +2826,12 @@ proc_binding(VALUE self)
const struct vm_ifunc *ifunc = block->as.captured.code.ifunc;
if (IS_METHOD_PROC_IFUNC(ifunc)) {
VALUE method = (VALUE)ifunc->data;
- VALUE name = rb_fstring_lit("<empty_iseq>");
- rb_iseq_t *empty;
binding_self = method_receiver(method);
iseq = rb_method_iseq(method);
env = VM_ENV_ENVVAL_PTR(block->as.captured.ep);
env = env_clone(env, method_cref(method));
/* set empty iseq */
- empty = rb_iseq_new(NULL, name, name, Qnil, 0, ISEQ_TYPE_TOP);
- RB_OBJ_WRITE(env, &env->iseq, empty);
+ RB_OBJ_WRITE(env, &env->iseq, rb_iseq_new(NULL, rb_str_new2("<empty iseq>"), rb_str_new2("<empty_iseq>"), Qnil, 0, ISEQ_TYPE_TOP));
break;
}
else {
@@ -3188,14 +2856,14 @@ proc_binding(VALUE self)
}
else {
RB_OBJ_WRITE(bindval, &bind->pathobj,
- rb_iseq_pathobj_new(rb_fstring_lit("(binding)"), Qnil));
+ rb_iseq_pathobj_new(rb_fstring_cstr("(binding)"), Qnil));
bind->first_lineno = 1;
}
return bindval;
}
-static rb_block_call_func curry;
+static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc);
static VALUE
make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
@@ -3215,7 +2883,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
}
static VALUE
-curry(RB_BLOCK_CALL_FUNC_ARGLIST(_, args))
+curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
{
VALUE proc, passed, arity;
proc = RARRAY_AREF(args, 0);
@@ -3226,14 +2894,14 @@ curry(RB_BLOCK_CALL_FUNC_ARGLIST(_, args))
rb_ary_freeze(passed);
if (RARRAY_LEN(passed) < FIX2INT(arity)) {
- if (!NIL_P(blockarg)) {
+ if (!NIL_P(passed_proc)) {
rb_warn("given block not used");
}
arity = make_curry_proc(proc, passed, arity);
return arity;
}
else {
- return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_CONST_PTR(passed), blockarg);
+ return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_CONST_PTR(passed), passed_proc);
}
}
@@ -3285,7 +2953,8 @@ proc_curry(int argc, const VALUE *argv, VALUE self)
int sarity, max_arity, min_arity = rb_proc_min_max_arity(self, &max_arity);
VALUE arity;
- if (rb_check_arity(argc, 0, 1) == 0 || NIL_P(arity = argv[0])) {
+ rb_scan_args(argc, argv, "01", &arity);
+ if (NIL_P(arity)) {
arity = INT2FIX(min_arity);
}
else {
@@ -3337,245 +3006,6 @@ rb_method_curry(int argc, const VALUE *argv, VALUE self)
return proc_curry(argc, argv, proc);
}
-static VALUE
-compose(RB_BLOCK_CALL_FUNC_ARGLIST(_, args))
-{
- VALUE f, g, fargs;
- f = RARRAY_AREF(args, 0);
- g = RARRAY_AREF(args, 1);
-
- if (rb_obj_is_proc(g))
- fargs = rb_proc_call_with_block_kw(g, argc, argv, blockarg, RB_PASS_CALLED_KEYWORDS);
- else
- fargs = rb_funcall_with_block_kw(g, idCall, argc, argv, blockarg, RB_PASS_CALLED_KEYWORDS);
-
- if (rb_obj_is_proc(f))
- return rb_proc_call(f, rb_ary_new3(1, fargs));
- else
- return rb_funcallv(f, idCall, 1, &fargs);
-}
-
-static VALUE
-to_callable(VALUE f)
-{
- VALUE mesg;
-
- if (rb_obj_is_proc(f)) return f;
- if (rb_obj_is_method(f)) return f;
- if (rb_obj_respond_to(f, idCall, TRUE)) return f;
- mesg = rb_fstring_lit("callable object is expected");
- rb_exc_raise(rb_exc_new_str(rb_eTypeError, mesg));
-}
-
-static VALUE rb_proc_compose_to_left(VALUE self, VALUE g);
-static VALUE rb_proc_compose_to_right(VALUE self, VALUE g);
-
-/*
- * call-seq:
- * prc << g -> a_proc
- *
- * Returns a proc that is the composition of this proc and the given <i>g</i>.
- * The returned proc takes a variable number of arguments, calls <i>g</i> with them
- * then calls this proc with the result.
- *
- * f = proc {|x| x * x }
- * g = proc {|x| x + x }
- * p (f << g).call(2) #=> 16
- *
- * See Proc#>> for detailed explanations.
- */
-static VALUE
-proc_compose_to_left(VALUE self, VALUE g)
-{
- return rb_proc_compose_to_left(self, to_callable(g));
-}
-
-static VALUE
-rb_proc_compose_to_left(VALUE self, VALUE g)
-{
- VALUE proc, args, procs[2];
- rb_proc_t *procp;
- int is_lambda;
-
- procs[0] = self;
- procs[1] = g;
- args = rb_ary_tmp_new_from_values(0, 2, procs);
-
- GetProcPtr(self, procp);
- is_lambda = procp->is_lambda;
-
- proc = rb_proc_new(compose, args);
- GetProcPtr(proc, procp);
- procp->is_lambda = is_lambda;
-
- return proc;
-}
-
-/*
- * call-seq:
- * prc >> g -> a_proc
- *
- * Returns a proc that is the composition of this proc and the given <i>g</i>.
- * The returned proc takes a variable number of arguments, calls this proc with them
- * then calls <i>g</i> with the result.
- *
- * f = proc {|x| x * x }
- * g = proc {|x| x + x }
- * p (f >> g).call(2) #=> 8
- *
- * <i>g</i> could be other Proc, or Method, or any other object responding to
- * +call+ method:
- *
- * class Parser
- * def self.call(text)
- * # ...some complicated parsing logic...
- * end
- * end
- *
- * pipeline = File.method(:read) >> Parser >> proc { |data| puts "data size: #{data.count}" }
- * pipeline.call('data.json')
- *
- * See also Method#>> and Method#<<.
- */
-static VALUE
-proc_compose_to_right(VALUE self, VALUE g)
-{
- return rb_proc_compose_to_right(self, to_callable(g));
-}
-
-static VALUE
-rb_proc_compose_to_right(VALUE self, VALUE g)
-{
- VALUE proc, args, procs[2];
- rb_proc_t *procp;
- int is_lambda;
-
- procs[0] = g;
- procs[1] = self;
- args = rb_ary_tmp_new_from_values(0, 2, procs);
-
- GetProcPtr(self, procp);
- is_lambda = procp->is_lambda;
-
- proc = rb_proc_new(compose, args);
- GetProcPtr(proc, procp);
- procp->is_lambda = is_lambda;
-
- return proc;
-}
-
-/*
- * call-seq:
- * meth << g -> a_proc
- *
- * Returns a proc that is the composition of this method and the given <i>g</i>.
- * The returned proc takes a variable number of arguments, calls <i>g</i> with them
- * then calls this method with the result.
- *
- * def f(x)
- * x * x
- * end
- *
- * f = self.method(:f)
- * g = proc {|x| x + x }
- * p (f << g).call(2) #=> 16
- */
-static VALUE
-rb_method_compose_to_left(VALUE self, VALUE g)
-{
- g = to_callable(g);
- self = method_to_proc(self);
- return proc_compose_to_left(self, g);
-}
-
-/*
- * call-seq:
- * meth >> g -> a_proc
- *
- * Returns a proc that is the composition of this method and the given <i>g</i>.
- * The returned proc takes a variable number of arguments, calls this method
- * with them then calls <i>g</i> with the result.
- *
- * def f(x)
- * x * x
- * end
- *
- * f = self.method(:f)
- * g = proc {|x| x + x }
- * p (f >> g).call(2) #=> 8
- */
-static VALUE
-rb_method_compose_to_right(VALUE self, VALUE g)
-{
- g = to_callable(g);
- self = method_to_proc(self);
- return proc_compose_to_right(self, g);
-}
-
-/*
- * call-seq:
- * proc.ruby2_keywords -> proc
- *
- * Marks the proc as passing keywords through a normal argument splat.
- * This should only be called on procs that accept an argument splat
- * (<tt>*args</tt>) but not explicit keywords or a keyword splat. It
- * marks the proc such that if the proc is called with keyword arguments,
- * the final hash argument is marked with a special flag such that if it
- * is the final element of a normal argument splat to another method call,
- * and that method call does not include explicit keywords or a keyword
- * splat, the final element is interpreted as keywords. In other words,
- * keywords will be passed through the proc to other methods.
- *
- * This should only be used for procs that delegate keywords to another
- * method, and only for backwards compatibility with Ruby versions before
- * 2.7.
- *
- * This method will probably be removed at some point, as it exists only
- * for backwards compatibility. As it does not exist in Ruby versions
- * before 2.7, check that the proc responds to this method before calling
- * it. Also, be aware that if this method is removed, the behavior of the
- * proc will change so that it does not pass through keywords.
- *
- * module Mod
- * foo = ->(meth, *args, &block) do
- * send(:"do_#{meth}", *args, &block)
- * end
- * foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords)
- * end
- */
-
-static VALUE
-proc_ruby2_keywords(VALUE procval)
-{
- rb_proc_t *proc;
- GetProcPtr(procval, proc);
-
- rb_check_frozen(procval);
-
- if (proc->is_from_method) {
- rb_warn("Skipping set of ruby2_keywords flag for proc (proc created from method)");
- return procval;
- }
-
- switch (proc->block.type) {
- case block_type_iseq:
- if (proc->block.as.captured.code.iseq->body->param.flags.has_rest &&
- !proc->block.as.captured.code.iseq->body->param.flags.has_kw &&
- !proc->block.as.captured.code.iseq->body->param.flags.has_kwrest) {
- proc->block.as.captured.code.iseq->body->param.flags.ruby2_keywords = 1;
- }
- else {
- rb_warn("Skipping set of ruby2_keywords flag for proc (proc accepts keywords or proc does not accept argument splat)");
- }
- break;
- default:
- rb_warn("Skipping set of ruby2_keywords flag for proc (proc not defined in Ruby)");
- break;
- }
-
- return procval;
-}
-
/*
* Document-class: LocalJumpError
*
@@ -3620,25 +3050,12 @@ proc_ruby2_keywords(VALUE procval)
*/
/*
- * Document-class: Proc
- *
- * A +Proc+ object is an encapsulation of a block of code, which can be stored
- * in a local variable, passed to a method or another Proc, and can be called.
- * Proc is an essential concept in Ruby and a core of its functional
- * programming features.
- *
- * square = Proc.new {|x| x**2 }
- *
- * square.call(3) #=> 9
- * # shorthands:
- * square.(3) #=> 9
- * square[3] #=> 9
- *
- * Proc objects are _closures_, meaning they remember and can use the entire
- * context in which they were created.
+ * <code>Proc</code> objects are blocks of code that have been bound to
+ * a set of local variables. Once bound, the code may be called in
+ * different contexts and still access those variables.
*
* def gen_times(factor)
- * Proc.new {|n| n*factor } # remembers the value of factor at the moment of creation
+ * return Proc.new {|n| n*factor }
* end
*
* times3 = gen_times(3)
@@ -3648,280 +3065,17 @@ proc_ruby2_keywords(VALUE procval)
* times5.call(5) #=> 25
* times3.call(times5.call(4)) #=> 60
*
- * == Creation
- *
- * There are several methods to create a Proc
- *
- * * Use the Proc class constructor:
- *
- * proc1 = Proc.new {|x| x**2 }
- *
- * * Use the Kernel#proc method as a shorthand of Proc.new:
- *
- * proc2 = proc {|x| x**2 }
- *
- * * Receiving a block of code into proc argument (note the <code>&</code>):
- *
- * def make_proc(&block)
- * block
- * end
- *
- * proc3 = make_proc {|x| x**2 }
- *
- * * Construct a proc with lambda semantics using the Kernel#lambda method
- * (see below for explanations about lambdas):
- *
- * lambda1 = lambda {|x| x**2 }
- *
- * * Use the Lambda literal syntax (also constructs a proc with lambda semantics):
- *
- * lambda2 = ->(x) { x**2 }
- *
- * == Lambda and non-lambda semantics
- *
- * Procs are coming in two flavors: lambda and non-lambda (regular procs).
- * Differences are:
- *
- * * In lambdas, +return+ and +break+ means exit from this lambda;
- * * In non-lambda procs, +return+ means exit from embracing method
- * (and will throw +LocalJumpError+ if invoked outside the method);
- * * In non-lambda procs, +break+ means exit from the method which the block given for.
- * (and will throw +LocalJumpError+ if invoked after the method returns);
- * * In lambdas, arguments are treated in the same way as in methods: strict,
- * with +ArgumentError+ for mismatching argument number,
- * and no additional argument processing;
- * * Regular procs accept arguments more generously: missing arguments
- * are filled with +nil+, single Array arguments are deconstructed if the
- * proc has multiple arguments, and there is no error raised on extra
- * arguments.
- *
- * Examples:
- *
- * # +return+ in non-lambda proc, +b+, exits +m2+.
- * # (The block +{ return }+ is given for +m1+ and embraced by +m2+.)
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { return }; $a << :m2 end; m2; p $a
- * #=> []
- *
- * # +break+ in non-lambda proc, +b+, exits +m1+.
- * # (The block +{ break }+ is given for +m1+ and embraced by +m2+.)
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { break }; $a << :m2 end; m2; p $a
- * #=> [:m2]
- *
- * # +next+ in non-lambda proc, +b+, exits the block.
- * # (The block +{ next }+ is given for +m1+ and embraced by +m2+.)
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { next }; $a << :m2 end; m2; p $a
- * #=> [:m1, :m2]
- *
- * # Using +proc+ method changes the behavior as follows because
- * # The block is given for +proc+ method and embraced by +m2+.
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { return }); $a << :m2 end; m2; p $a
- * #=> []
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { break }); $a << :m2 end; m2; p $a
- * # break from proc-closure (LocalJumpError)
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { next }); $a << :m2 end; m2; p $a
- * #=> [:m1, :m2]
- *
- * # +return+, +break+ and +next+ in the stubby lambda exits the block.
- * # (+lambda+ method behaves same.)
- * # (The block is given for stubby lambda syntax and embraced by +m2+.)
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { return }); $a << :m2 end; m2; p $a
- * #=> [:m1, :m2]
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { break }); $a << :m2 end; m2; p $a
- * #=> [:m1, :m2]
- * $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { next }); $a << :m2 end; m2; p $a
- * #=> [:m1, :m2]
- *
- * p = proc {|x, y| "x=#{x}, y=#{y}" }
- * p.call(1, 2) #=> "x=1, y=2"
- * p.call([1, 2]) #=> "x=1, y=2", array deconstructed
- * p.call(1, 2, 8) #=> "x=1, y=2", extra argument discarded
- * p.call(1) #=> "x=1, y=", nil substituted instead of error
- *
- * l = lambda {|x, y| "x=#{x}, y=#{y}" }
- * l.call(1, 2) #=> "x=1, y=2"
- * l.call([1, 2]) # ArgumentError: wrong number of arguments (given 1, expected 2)
- * l.call(1, 2, 8) # ArgumentError: wrong number of arguments (given 3, expected 2)
- * l.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
- *
- * def test_return
- * -> { return 3 }.call # just returns from lambda into method body
- * proc { return 4 }.call # returns from method
- * return 5
- * end
- *
- * test_return # => 4, return from proc
- *
- * Lambdas are useful as self-sufficient functions, in particular useful as
- * arguments to higher-order functions, behaving exactly like Ruby methods.
- *
- * Procs are useful for implementing iterators:
- *
- * def test
- * [[1, 2], [3, 4], [5, 6]].map {|a, b| return a if a + b > 10 }
- * # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * end
- *
- * Inside +map+, the block of code is treated as a regular (non-lambda) proc,
- * which means that the internal arrays will be deconstructed to pairs of
- * arguments, and +return+ will exit from the method +test+. That would
- * not be possible with a stricter lambda.
- *
- * You can tell a lambda from a regular proc by using the #lambda? instance method.
- *
- * Lambda semantics is typically preserved during the proc lifetime, including
- * <code>&</code>-deconstruction to a block of code:
- *
- * p = proc {|x, y| x }
- * l = lambda {|x, y| x }
- * [[1, 2], [3, 4]].map(&p) #=> [1, 2]
- * [[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2)
- *
- * The only exception is dynamic method definition: even if defined by
- * passing a non-lambda proc, methods still have normal semantics of argument
- * checking.
- *
- * class C
- * define_method(:e, &proc {})
- * end
- * C.new.e(1,2) #=> ArgumentError
- * C.new.method(:e).to_proc.lambda? #=> true
- *
- * This exception ensures that methods never have unusual argument passing
- * conventions, and makes it easy to have wrappers defining methods that
- * behave as usual.
- *
- * class C
- * def self.def2(name, &body)
- * define_method(name, &body)
- * end
- *
- * def2(:f) {}
- * end
- * C.new.f(1,2) #=> ArgumentError
- *
- * The wrapper <code>def2</code> receives _body_ as a non-lambda proc,
- * yet defines a method which has normal semantics.
- *
- * == Conversion of other objects to procs
- *
- * Any object that implements the +to_proc+ method can be converted into
- * a proc by the <code>&</code> operator, and therefore con be
- * consumed by iterators.
- *
-
- * class Greeter
- * def initialize(greeting)
- * @greeting = greeting
- * end
- *
- * def to_proc
- * proc {|name| "#{@greeting}, #{name}!" }
- * end
- * end
- *
- * hi = Greeter.new("Hi")
- * hey = Greeter.new("Hey")
- * ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"]
- * ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"]
- *
- * Of the Ruby core classes, this method is implemented by Symbol,
- * Method, and Hash.
- *
- * :to_s.to_proc.call(1) #=> "1"
- * [1, 2].map(&:to_s) #=> ["1", "2"]
- *
- * method(:puts).to_proc.call(1) # prints 1
- * [1, 2].each(&method(:puts)) # prints 1, 2
- *
- * {test: 1}.to_proc.call(:test) #=> 1
- * %i[test many keys].map(&{test: 1}) #=> [1, nil, nil]
- *
- * == Orphaned Proc
- *
- * +return+ and +break+ in a block exit a method.
- * If a Proc object is generated from the block and the Proc object
- * survives until the method is returned, +return+ and +break+ cannot work.
- * In such case, +return+ and +break+ raises LocalJumpError.
- * A Proc object in such situation is called as orphaned Proc object.
- *
- * Note that the method to exit is different for +return+ and +break+.
- * There is a situation that orphaned for +break+ but not orphaned for +return+.
- *
- * def m1(&b) b.call end; def m2(); m1 { return } end; m2 # ok
- * def m1(&b) b.call end; def m2(); m1 { break } end; m2 # ok
- *
- * def m1(&b) b end; def m2(); m1 { return }.call end; m2 # ok
- * def m1(&b) b end; def m2(); m1 { break }.call end; m2 # LocalJumpError
- *
- * def m1(&b) b end; def m2(); m1 { return } end; m2.call # LocalJumpError
- * def m1(&b) b end; def m2(); m1 { break } end; m2.call # LocalJumpError
- *
- * Since +return+ and +break+ exits the block itself in lambdas,
- * lambdas cannot be orphaned.
- *
- * == Numbered parameters
- *
- * Numbered parameters are implicitly defined block parameters intended to
- * simplify writing short blocks:
- *
- * # Explicit parameter:
- * %w[test me please].each { |str| puts str.upcase } # prints TEST, ME, PLEASE
- * (1..5).map { |i| i**2 } # => [1, 4, 9, 16, 25]
- *
- * # Implicit parameter:
- * %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE
- * (1..5).map { _1**2 } # => [1, 4, 9, 16, 25]
- *
- * Parameter names from +_1+ to +_9+ are supported:
- *
- * [10, 20, 30].zip([40, 50, 60], [70, 80, 90]).map { _1 + _2 + _3 }
- * # => [120, 150, 180]
- *
- * Though, it is advised to resort to them wisely, probably limiting
- * yourself to +_1+ and +_2+, and to one-line blocks.
- *
- * Numbered parameters can't be used together with explicitly named
- * ones:
- *
- * [10, 20, 30].map { |x| _1**2 }
- * # SyntaxError (ordinary parameter is defined)
- *
- * To avoid conflicts, naming local variables or method
- * arguments +_1+, +_2+ and so on, causes a warning.
- *
- * _1 = 'test'
- * # warning: `_1' is reserved as numbered parameter
- *
- * Using implicit numbered parameters affects block's arity:
- *
- * p = proc { _1 + _2 }
- * l = lambda { _1 + _2 }
- * p.parameters # => [[:opt, :_1], [:opt, :_2]]
- * p.arity # => 2
- * l.parameters # => [[:req, :_1], [:req, :_2]]
- * l.arity # => 2
- *
- * Blocks with numbered parameters can't be nested:
- *
- * %w[test me].each { _1.each_char { p _1 } }
- * # SyntaxError (numbered parameter is already used in outer block here)
- * # %w[test me].each { _1.each_char { p _1 } }
- * # ^~
- *
- * Numbered parameters were introduced in Ruby 2.7.
*/
-
void
Init_Proc(void)
{
-#undef rb_intern
/* Proc */
rb_cProc = rb_define_class("Proc", rb_cObject);
rb_undef_alloc_func(rb_cProc);
rb_define_singleton_method(rb_cProc, "new", rb_proc_s_new, -1);
- rb_add_method(rb_cProc, idCall, VM_METHOD_TYPE_OPTIMIZED,
+ rb_add_method(rb_cProc, rb_intern("call"), VM_METHOD_TYPE_OPTIMIZED,
(void *)OPTIMIZED_METHOD_TYPE_CALL, METHOD_VISI_PUBLIC);
rb_add_method(rb_cProc, rb_intern("[]"), VM_METHOD_TYPE_OPTIMIZED,
(void *)OPTIMIZED_METHOD_TYPE_CALL, METHOD_VISI_PUBLIC);
@@ -3940,18 +3094,15 @@ Init_Proc(void)
rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
rb_define_method(rb_cProc, "arity", proc_arity, 0);
rb_define_method(rb_cProc, "clone", proc_clone, 0);
- rb_define_method(rb_cProc, "dup", rb_proc_dup, 0);
+ rb_define_method(rb_cProc, "dup", proc_dup, 0);
rb_define_method(rb_cProc, "hash", proc_hash, 0);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
rb_define_alias(rb_cProc, "inspect", "to_s");
rb_define_method(rb_cProc, "lambda?", rb_proc_lambda_p, 0);
rb_define_method(rb_cProc, "binding", proc_binding, 0);
rb_define_method(rb_cProc, "curry", proc_curry, -1);
- rb_define_method(rb_cProc, "<<", proc_compose_to_left, 1);
- rb_define_method(rb_cProc, ">>", proc_compose_to_right, 1);
rb_define_method(rb_cProc, "source_location", rb_proc_location, 0);
rb_define_method(rb_cProc, "parameters", rb_proc_parameters, 0);
- rb_define_method(rb_cProc, "ruby2_keywords", proc_ruby2_keywords, 0);
/* Exceptions */
rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
@@ -3962,8 +3113,8 @@ Init_Proc(void)
rb_vm_register_special_exception(ruby_error_sysstack, rb_eSysStackError, "stack level too deep");
/* utility functions */
- rb_define_global_function("proc", f_proc, 0);
- rb_define_global_function("lambda", f_lambda, 0);
+ rb_define_global_function("proc", rb_block_proc, 0);
+ rb_define_global_function("lambda", rb_block_lambda, 0);
/* Method */
rb_cMethod = rb_define_class("Method", rb_cObject);
@@ -3973,12 +3124,10 @@ Init_Proc(void)
rb_define_method(rb_cMethod, "eql?", method_eq, 1);
rb_define_method(rb_cMethod, "hash", method_hash, 0);
rb_define_method(rb_cMethod, "clone", method_clone, 0);
- rb_define_method(rb_cMethod, "call", rb_method_call_pass_called_kw, -1);
- rb_define_method(rb_cMethod, "===", rb_method_call_pass_called_kw, -1);
+ rb_define_method(rb_cMethod, "call", rb_method_call, -1);
+ rb_define_method(rb_cMethod, "===", rb_method_call, -1);
rb_define_method(rb_cMethod, "curry", rb_method_curry, -1);
- rb_define_method(rb_cMethod, "<<", rb_method_compose_to_left, 1);
- rb_define_method(rb_cMethod, ">>", rb_method_compose_to_right, 1);
- rb_define_method(rb_cMethod, "[]", rb_method_call_pass_called_kw, -1);
+ rb_define_method(rb_cMethod, "[]", rb_method_call, -1);
rb_define_method(rb_cMethod, "arity", method_arity_m, 0);
rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
rb_define_method(rb_cMethod, "to_s", method_inspect, 0);
@@ -4010,7 +3159,6 @@ Init_Proc(void)
rb_define_method(rb_cUnboundMethod, "original_name", method_original_name, 0);
rb_define_method(rb_cUnboundMethod, "owner", method_owner, 0);
rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1);
- rb_define_method(rb_cUnboundMethod, "bind_call", umethod_bind_call, -1);
rb_define_method(rb_cUnboundMethod, "source_location", rb_method_location, 0);
rb_define_method(rb_cUnboundMethod, "parameters", rb_method_parameters, 0);
rb_define_method(rb_cUnboundMethod, "super_method", method_super_method, 0);
@@ -4028,16 +3176,16 @@ Init_Proc(void)
}
/*
- * Objects of class Binding encapsulate the execution context at some
- * particular place in the code and retain this context for future
- * use. The variables, methods, value of <code>self</code>, and
- * possibly an iterator block that can be accessed in this context
+ * Objects of class <code>Binding</code> encapsulate the execution
+ * context at some particular place in the code and retain this context
+ * for future use. The variables, methods, value of <code>self</code>,
+ * and possibly an iterator block that can be accessed in this context
* are all retained. Binding objects can be created using
- * Kernel#binding, and are made available to the callback of
- * Kernel#set_trace_func and instances of TracePoint.
+ * <code>Kernel#binding</code>, and are made available to the callback
+ * of <code>Kernel#set_trace_func</code>.
*
* These binding objects can be passed as the second argument of the
- * Kernel#eval method, establishing an environment for the
+ * <code>Kernel#eval</code> method, establishing an environment for the
* evaluation.
*
* class Demo
@@ -4076,6 +3224,5 @@ Init_Binding(void)
rb_define_method(rb_cBinding, "local_variable_set", bind_local_variable_set, 2);
rb_define_method(rb_cBinding, "local_variable_defined?", bind_local_variable_defined_p, 1);
rb_define_method(rb_cBinding, "receiver", bind_receiver, 0);
- rb_define_method(rb_cBinding, "source_location", bind_location, 0);
rb_define_global_function("binding", rb_f_binding, 0);
}
diff --git a/process.c b/process.c
index 475b27545f..6c7a117c20 100644
--- a/process.c
+++ b/process.c
@@ -11,13 +11,11 @@
**********************************************************************/
-#include "ruby/config.h"
-#include "ruby/io.h"
#include "internal.h"
+#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "vm_core.h"
-#include "hrtime.h"
#include <stdio.h>
#include <errno.h>
@@ -154,40 +152,12 @@ static int exec_async_signal_safe(const struct rb_execarg *, char *, size_t);
#define p_gid_from_name p_gid_from_name
#endif
-#if defined(HAVE_UNISTD_H)
-# if defined(HAVE_GETLOGIN_R)
-# define USE_GETLOGIN_R 1
-# define GETLOGIN_R_SIZE_DEFAULT 0x100
-# define GETLOGIN_R_SIZE_LIMIT 0x1000
-# if defined(_SC_LOGIN_NAME_MAX)
-# define GETLOGIN_R_SIZE_INIT sysconf(_SC_LOGIN_NAME_MAX)
-# else
-# define GETLOGIN_R_SIZE_INIT GETLOGIN_R_SIZE_DEFAULT
-# endif
-# elif defined(HAVE_GETLOGIN)
-# define USE_GETLOGIN 1
-# endif
-#endif
-
#if defined(HAVE_PWD_H)
-# if defined(HAVE_GETPWUID_R)
-# define USE_GETPWUID_R 1
-# elif defined(HAVE_GETPWUID)
-# define USE_GETPWUID 1
-# endif
-# if defined(HAVE_GETPWNAM_R)
+# if defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX)
# define USE_GETPWNAM_R 1
-# elif defined(HAVE_GETPWNAM)
-# define USE_GETPWNAM 1
-# endif
-# if defined(HAVE_GETPWNAM_R) || defined(HAVE_GETPWUID_R)
+# define GETPW_R_SIZE_INIT sysconf(_SC_GETPW_R_SIZE_MAX)
# define GETPW_R_SIZE_DEFAULT 0x1000
# define GETPW_R_SIZE_LIMIT 0x10000
-# if defined(_SC_GETPW_R_SIZE_MAX)
-# define GETPW_R_SIZE_INIT sysconf(_SC_GETPW_R_SIZE_MAX)
-# else
-# define GETPW_R_SIZE_INIT GETPW_R_SIZE_DEFAULT
-# endif
# endif
# ifdef USE_GETPWNAM_R
# define PREPARE_GETPWNAM \
@@ -278,7 +248,6 @@ typedef unsigned LONG_LONG unsigned_clock_t;
typedef void (*sig_t) (int);
#endif
-#define id_exception idException
static ID id_in, id_out, id_err, id_pid, id_uid, id_gid;
static ID id_close, id_child;
#ifdef HAVE_SETPGID
@@ -303,6 +272,8 @@ static ID id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID;
static ID id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC;
#endif
static ID id_hertz;
+extern ID ruby_static_id_status;
+#define id_status ruby_static_id_status
/* execv and execl are async-signal-safe since SUSv4 (POSIX.1-2008, XPG7) */
#if defined(__sun) && !defined(_XPG7) /* Solaris 10, 9, ... */
@@ -313,30 +284,12 @@ static ID id_hertz;
#define ALWAYS_NEED_ENVP 0
#endif
-static void
-assert_close_on_exec(int fd)
-{
-#if VM_CHECK_MODE > 0
-#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(FD_CLOEXEC)
- int flags = fcntl(fd, F_GETFD);
- if (flags == -1) {
- static const char m[] = "reserved FD closed unexpectedly?\n";
- (void)!write(2, m, sizeof(m) - 1);
- return;
- }
- if (flags & FD_CLOEXEC) return;
- rb_bug("reserved FD did not have close-on-exec set");
-#else
- rb_bug("reserved FD without close-on-exec support");
-#endif /* FD_CLOEXEC */
-#endif /* VM_CHECK_MODE */
-}
-
static inline int
close_unless_reserved(int fd)
{
+ /* We should not have reserved FDs at this point */
if (rb_reserved_fd_p(fd)) { /* async-signal-safe */
- assert_close_on_exec(fd);
+ rb_async_bug_errno("BUG timer thread still running", 0 /* EDOOFUS */);
return 0;
}
return close(fd); /* async-signal-safe */
@@ -442,30 +395,6 @@ parent_redirect_close(int fd)
#endif
/*
- * Document-module: Process
- *
- * The module contains several groups of functionality for handling OS processes:
- *
- * * Low-level property introspection and management of the current process, like
- * Process.argv0, Process.pid;
- * * Low-level introspection of other processes, like Process.getpgid, Process.getpriority;
- * * Management of the current process: Process.abort, Process.exit, Process.daemon, etc.
- * (for convenience, most of those are also available as global functions
- * and module functions of Kernel);
- * * Creation and management of child processes: Process.fork, Process.spawn, and
- * related methods;
- * * Management of low-level system clock: Process.times and Process.clock_gettime,
- * which could be important for proper benchmarking and other elapsed
- * time measurement tasks.
- */
-
-static VALUE
-get_pid(void)
-{
- return PIDT2NUM(getpid());
-}
-
-/*
* call-seq:
* Process.pid -> integer
*
@@ -476,16 +405,11 @@ get_pid(void)
*/
static VALUE
-proc_get_pid(VALUE _)
+get_pid(void)
{
- return get_pid();
+ return PIDT2NUM(getpid());
}
-static VALUE
-get_ppid(void)
-{
- return PIDT2NUM(getppid());
-}
/*
* call-seq:
@@ -504,9 +428,9 @@ get_ppid(void)
*/
static VALUE
-proc_get_ppid(VALUE _)
+get_ppid(void)
{
- return get_ppid();
+ return PIDT2NUM(getppid());
}
@@ -514,10 +438,10 @@ proc_get_ppid(VALUE _)
*
* Document-class: Process::Status
*
- * Process::Status encapsulates the information on the
+ * <code>Process::Status</code> encapsulates the information on the
* status of a running or terminated system process. The built-in
* variable <code>$?</code> is either +nil+ or a
- * Process::Status object.
+ * <code>Process::Status</code> object.
*
* fork { exit 99 } #=> 26557
* Process.wait #=> 26557
@@ -534,7 +458,7 @@ proc_get_ppid(VALUE _)
* information (for example the program's return code in the case of
* exited processes). Pre Ruby 1.8, these bits were exposed directly
* to the Ruby program. Ruby now encapsulates these in a
- * Process::Status object. To maximize compatibility,
+ * <code>Process::Status</code> object. To maximize compatibility,
* however, these objects retain a bit-oriented interface. In the
* descriptions that follow, when we talk about the integer value of
* _stat_, we're referring to this 16 bit value.
@@ -587,8 +511,9 @@ rb_last_status_clear(void)
/*
* call-seq:
* stat.to_i -> integer
+ * stat.to_int -> integer
*
- * Returns the bits in _stat_ as a Integer. Poking
+ * Returns the bits in _stat_ as a <code>Integer</code>. Poking
* around in these bits is platform dependent.
*
* fork { exit 0xab } #=> 26566
@@ -621,18 +546,10 @@ pst_pid(VALUE st)
return rb_attr_get(st, id_pid);
}
-static VALUE pst_message_status(VALUE str, int status);
-
static void
pst_message(VALUE str, rb_pid_t pid, int status)
{
rb_str_catf(str, "pid %ld", (long)pid);
- pst_message_status(str, status);
-}
-
-static VALUE
-pst_message_status(VALUE str, int status)
-{
if (WIFSTOPPED(status)) {
int stopsig = WSTOPSIG(status);
const char *signame = ruby_signal_name(stopsig);
@@ -661,7 +578,6 @@ pst_message_status(VALUE str, int status)
rb_str_cat2(str, " (core dumped)");
}
#endif
- return str;
}
@@ -786,9 +702,9 @@ pst_rshift(VALUE st1, VALUE st2)
* call-seq:
* stat.stopped? -> true or false
*
- * Returns +true+ if this process is stopped. This is only returned
- * if the corresponding #wait call had the Process::WUNTRACED flag
- * set.
+ * Returns +true+ if this process is stopped. This is only
+ * returned if the corresponding <code>wait</code> call had the
+ * <code>WUNTRACED</code> flag set.
*/
static VALUE
@@ -888,7 +804,8 @@ pst_wifexited(VALUE st)
* stat.exitstatus -> integer or nil
*
* Returns the least significant eight bits of the return code of
- * _stat_. Only available if #exited? is +true+.
+ * _stat_. Only available if <code>exited?</code> is
+ * +true+.
*
* fork { } #=> 26572
* Process.wait #=> 26572
@@ -917,7 +834,7 @@ pst_wexitstatus(VALUE st)
* stat.success? -> true, false or nil
*
* Returns +true+ if _stat_ is successful, +false+ if not.
- * Returns +nil+ if #exited? is not +true+.
+ * Returns +nil+ if <code>exited?</code> is not +true+.
*/
static VALUE
@@ -954,6 +871,12 @@ pst_wcoredump(VALUE st)
#endif
}
+struct waitpid_arg {
+ rb_pid_t pid;
+ int flags;
+ int *st;
+};
+
static rb_pid_t
do_waitpid(rb_pid_t pid, int *st, int flags)
{
@@ -966,333 +889,47 @@ do_waitpid(rb_pid_t pid, int *st, int flags)
#endif
}
-#define WAITPID_LOCK_ONLY ((struct waitpid_state *)-1)
-
-struct waitpid_state {
- struct list_node wnode;
- rb_execution_context_t *ec;
- rb_nativethread_cond_t *cond;
- rb_pid_t ret;
- rb_pid_t pid;
- int status;
- int options;
- int errnum;
-};
-
-void rb_native_mutex_lock(rb_nativethread_lock_t *);
-void rb_native_mutex_unlock(rb_nativethread_lock_t *);
-void rb_native_cond_signal(rb_nativethread_cond_t *);
-void rb_native_cond_wait(rb_nativethread_cond_t *, rb_nativethread_lock_t *);
-int rb_sigwait_fd_get(const rb_thread_t *);
-void rb_sigwait_sleep(const rb_thread_t *, int fd, const rb_hrtime_t *);
-void rb_sigwait_fd_put(const rb_thread_t *, int fd);
-void rb_thread_sleep_interruptible(void);
-
-static int
-waitpid_signal(struct waitpid_state *w)
-{
- if (w->ec) { /* rb_waitpid */
- rb_threadptr_interrupt(rb_ec_thread_ptr(w->ec));
- return TRUE;
- }
- else { /* ruby_waitpid_locked */
- if (w->cond) {
- rb_native_cond_signal(w->cond);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/*
- * When a thread is done using sigwait_fd and there are other threads
- * sleeping on waitpid, we must kick one of the threads out of
- * rb_native_cond_wait so it can switch to rb_sigwait_sleep
- */
-static void
-sigwait_fd_migrate_sleeper(rb_vm_t *vm)
-{
- struct waitpid_state *w = 0;
-
- list_for_each(&vm->waiting_pids, w, wnode) {
- if (waitpid_signal(w)) return;
- }
- list_for_each(&vm->waiting_grps, w, wnode) {
- if (waitpid_signal(w)) return;
- }
-}
-
-void
-rb_sigwait_fd_migrate(rb_vm_t *vm)
-{
- rb_native_mutex_lock(&vm->waitpid_lock);
- sigwait_fd_migrate_sleeper(vm);
- rb_native_mutex_unlock(&vm->waitpid_lock);
-}
-
-#if RUBY_SIGCHLD
-extern volatile unsigned int ruby_nocldwait; /* signal.c */
-/* called by timer thread or thread which acquired sigwait_fd */
-static void
-waitpid_each(struct list_head *head)
-{
- struct waitpid_state *w = 0, *next;
-
- list_for_each_safe(head, w, next, wnode) {
- rb_pid_t ret = do_waitpid(w->pid, &w->status, w->options | WNOHANG);
-
- if (!ret) continue;
- if (ret == -1) w->errnum = errno;
-
- w->ret = ret;
- list_del_init(&w->wnode);
- waitpid_signal(w);
- }
-}
-#else
-# define ruby_nocldwait 0
-#endif
-
-void
-ruby_waitpid_all(rb_vm_t *vm)
-{
-#if RUBY_SIGCHLD
- rb_native_mutex_lock(&vm->waitpid_lock);
- waitpid_each(&vm->waiting_pids);
- if (list_empty(&vm->waiting_pids)) {
- waitpid_each(&vm->waiting_grps);
- }
- /* emulate SA_NOCLDWAIT */
- if (list_empty(&vm->waiting_pids) && list_empty(&vm->waiting_grps)) {
- while (ruby_nocldwait && do_waitpid(-1, 0, WNOHANG) > 0)
- ; /* keep looping */
- }
- rb_native_mutex_unlock(&vm->waitpid_lock);
-#endif
-}
-
-static void
-waitpid_state_init(struct waitpid_state *w, rb_pid_t pid, int options)
-{
- w->ret = 0;
- w->pid = pid;
- w->options = options;
-}
-
-static const rb_hrtime_t *
-sigwait_sleep_time(void)
-{
- if (SIGCHLD_LOSSY) {
- static const rb_hrtime_t busy_wait = 100 * RB_HRTIME_PER_MSEC;
-
- return &busy_wait;
- }
- return 0;
-}
-
-/*
- * must be called with vm->waitpid_lock held, this is not interruptible
- */
-rb_pid_t
-ruby_waitpid_locked(rb_vm_t *vm, rb_pid_t pid, int *status, int options,
- rb_nativethread_cond_t *cond)
-{
- struct waitpid_state w;
-
- assert(!ruby_thread_has_gvl_p() && "must not have GVL");
-
- waitpid_state_init(&w, pid, options);
- if (w.pid > 0 || list_empty(&vm->waiting_pids))
- w.ret = do_waitpid(w.pid, &w.status, w.options | WNOHANG);
- if (w.ret) {
- if (w.ret == -1) w.errnum = errno;
- }
- else {
- int sigwait_fd = -1;
-
- w.ec = 0;
- list_add(w.pid > 0 ? &vm->waiting_pids : &vm->waiting_grps, &w.wnode);
- do {
- if (sigwait_fd < 0)
- sigwait_fd = rb_sigwait_fd_get(0);
-
- if (sigwait_fd >= 0) {
- w.cond = 0;
- rb_native_mutex_unlock(&vm->waitpid_lock);
- rb_sigwait_sleep(0, sigwait_fd, sigwait_sleep_time());
- rb_native_mutex_lock(&vm->waitpid_lock);
- }
- else {
- w.cond = cond;
- rb_native_cond_wait(w.cond, &vm->waitpid_lock);
- }
- } while (!w.ret);
- list_del(&w.wnode);
-
- /* we're done, maybe other waitpid callers are not: */
- if (sigwait_fd >= 0) {
- rb_sigwait_fd_put(0, sigwait_fd);
- sigwait_fd_migrate_sleeper(vm);
- }
- }
- if (status) {
- *status = w.status;
- }
- if (w.ret == -1) errno = w.errnum;
- return w.ret;
-}
-
-static VALUE
-waitpid_sleep(VALUE x)
-{
- struct waitpid_state *w = (struct waitpid_state *)x;
-
- while (!w->ret) {
- rb_thread_sleep_interruptible();
- }
-
- return Qfalse;
-}
-
-static VALUE
-waitpid_cleanup(VALUE x)
-{
- struct waitpid_state *w = (struct waitpid_state *)x;
-
- /*
- * XXX w->ret is sometimes set but list_del is still needed, here,
- * Not sure why, so we unconditionally do list_del here:
- */
- if (TRUE || w->ret == 0) {
- rb_vm_t *vm = rb_ec_vm_ptr(w->ec);
-
- rb_native_mutex_lock(&vm->waitpid_lock);
- list_del(&w->wnode);
- rb_native_mutex_unlock(&vm->waitpid_lock);
- }
-
- return Qfalse;
-}
-
-static void
-waitpid_wait(struct waitpid_state *w)
-{
- rb_vm_t *vm = rb_ec_vm_ptr(w->ec);
- int need_sleep = FALSE;
-
- /*
- * Lock here to prevent do_waitpid from stealing work from the
- * ruby_waitpid_locked done by mjit workers since mjit works
- * outside of GVL
- */
- rb_native_mutex_lock(&vm->waitpid_lock);
-
- if (w->pid > 0 || list_empty(&vm->waiting_pids))
- w->ret = do_waitpid(w->pid, &w->status, w->options | WNOHANG);
- if (w->ret) {
- if (w->ret == -1) w->errnum = errno;
- }
- else if (w->options & WNOHANG) {
- }
- else {
- need_sleep = TRUE;
- }
-
- if (need_sleep) {
- w->cond = 0;
- /* order matters, favor specified PIDs rather than -1 or 0 */
- list_add(w->pid > 0 ? &vm->waiting_pids : &vm->waiting_grps, &w->wnode);
- }
-
- rb_native_mutex_unlock(&vm->waitpid_lock);
-
- if (need_sleep) {
- rb_ensure(waitpid_sleep, (VALUE)w, waitpid_cleanup, (VALUE)w);
- }
-}
-
static void *
-waitpid_blocking_no_SIGCHLD(void *x)
+rb_waitpid_blocking(void *data)
{
- struct waitpid_state *w = x;
-
- w->ret = do_waitpid(w->pid, &w->status, w->options);
-
- return 0;
+ struct waitpid_arg *arg = data;
+ rb_pid_t result = do_waitpid(arg->pid, arg->st, arg->flags);
+ return (void *)(VALUE)result;
}
-static void
-waitpid_no_SIGCHLD(struct waitpid_state *w)
+static rb_pid_t
+do_waitpid_nonblocking(rb_pid_t pid, int *st, int flags)
{
- if (w->options & WNOHANG) {
- w->ret = do_waitpid(w->pid, &w->status, w->options);
- }
- else {
- do {
- rb_thread_call_without_gvl(waitpid_blocking_no_SIGCHLD, w,
- RUBY_UBF_PROCESS, 0);
- } while (w->ret < 0 && errno == EINTR && (RUBY_VM_CHECK_INTS(w->ec),1));
- }
- if (w->ret == -1)
- w->errnum = errno;
+ void *result;
+ struct waitpid_arg arg;
+ arg.pid = pid;
+ arg.st = st;
+ arg.flags = flags;
+ result = rb_thread_call_without_gvl(rb_waitpid_blocking, &arg,
+ RUBY_UBF_PROCESS, 0);
+ return (rb_pid_t)(VALUE)result;
}
rb_pid_t
rb_waitpid(rb_pid_t pid, int *st, int flags)
{
- struct waitpid_state w;
+ rb_pid_t result;
- waitpid_state_init(&w, pid, flags);
- w.ec = GET_EC();
-
- if (WAITPID_USE_SIGCHLD) {
- waitpid_wait(&w);
+ if (flags & WNOHANG) {
+ result = do_waitpid(pid, st, flags);
}
else {
- waitpid_no_SIGCHLD(&w);
- }
-
- if (st) *st = w.status;
- if (w.ret == -1) {
- errno = w.errnum;
+ while ((result = do_waitpid_nonblocking(pid, st, flags)) < 0 &&
+ (errno == EINTR)) {
+ RUBY_VM_CHECK_INTS(GET_EC());
+ }
}
- else if (w.ret > 0) {
- if (ruby_nocldwait) {
- w.ret = -1;
- errno = ECHILD;
- }
- else {
- rb_last_status_set(w.status, w.ret);
- }
+ if (result > 0) {
+ rb_last_status_set(*st, result);
}
- return w.ret;
+ return result;
}
-static VALUE
-proc_wait(int argc, VALUE *argv)
-{
- rb_pid_t pid;
- int flags, status;
-
- flags = 0;
- if (rb_check_arity(argc, 0, 2) == 0) {
- pid = -1;
- }
- else {
- VALUE vflags;
- pid = NUM2PIDT(argv[0]);
- if (argc == 2 && !NIL_P(vflags = argv[1])) {
- flags = NUM2UINT(vflags);
- }
- }
- if ((pid = rb_waitpid(pid, &status, flags)) < 0)
- rb_sys_fail(0);
- if (pid == 0) {
- rb_last_status_clear();
- return Qnil;
- }
- return PIDT2NUM(pid);
-}
/* [MG]:FIXME: I wasn't sure how this should be done, since ::wait()
has historically been documented as if it didn't take any arguments
@@ -1315,7 +952,7 @@ proc_wait(int argc, VALUE *argv)
* Process.waitpid(pid=-1, flags=0) -> integer
*
* Waits for a child process to exit, returns its process id, and
- * sets <code>$?</code> to a Process::Status object
+ * sets <code>$?</code> to a <code>Process::Status</code> object
* containing information on that process. Which child it waits on
* depends on the value of _pid_:
*
@@ -1331,8 +968,8 @@ proc_wait(int argc, VALUE *argv)
* value of _pid_.
*
* The _flags_ argument may be a logical or of the flag values
- * Process::WNOHANG (do not block if no child available)
- * or Process::WUNTRACED (return stopped children that
+ * <code>Process::WNOHANG</code> (do not block if no child available)
+ * or <code>Process::WUNTRACED</code> (return stopped children that
* haven't been reported). Not all flags are available on all
* platforms, but a flag value of zero will work on all platforms.
*
@@ -1353,9 +990,29 @@ proc_wait(int argc, VALUE *argv)
*/
static VALUE
-proc_m_wait(int c, VALUE *v, VALUE _)
+proc_wait(int argc, VALUE *argv)
{
- return proc_wait(c, v);
+ rb_pid_t pid;
+ int flags, status;
+
+ flags = 0;
+ if (rb_check_arity(argc, 0, 2) == 0) {
+ pid = -1;
+ }
+ else {
+ VALUE vflags;
+ pid = NUM2PIDT(argv[0]);
+ if (argc == 2 && !NIL_P(vflags = argv[1])) {
+ flags = NUM2UINT(vflags);
+ }
+ }
+ if ((pid = rb_waitpid(pid, &status, flags)) < 0)
+ rb_sys_fail(0);
+ if (pid == 0) {
+ rb_last_status_clear();
+ return Qnil;
+ }
+ return PIDT2NUM(pid);
}
@@ -1366,7 +1023,7 @@ proc_m_wait(int c, VALUE *v, VALUE _)
*
* Waits for a child process to exit (see Process::waitpid for exact
* semantics) and returns an array containing the process id and the
- * exit status (a Process::Status object) of that
+ * exit status (a <code>Process::Status</code> object) of that
* child. Raises a SystemCallError if there are no child processes.
*
* Process.fork { exit 99 } #=> 27437
@@ -1376,7 +1033,7 @@ proc_m_wait(int c, VALUE *v, VALUE _)
*/
static VALUE
-proc_wait2(int argc, VALUE *argv, VALUE _)
+proc_wait2(int argc, VALUE *argv)
{
VALUE pid = proc_wait(argc, argv);
if (NIL_P(pid)) return Qnil;
@@ -1390,7 +1047,7 @@ proc_wait2(int argc, VALUE *argv, VALUE _)
*
* Waits for all children, returning an array of
* _pid_/_status_ pairs (where _status_ is a
- * Process::Status object).
+ * <code>Process::Status</code> object).
*
* fork { sleep 0.2; exit 2 } #=> 27432
* fork { sleep 0.1; exit 1 } #=> 27433
@@ -1405,7 +1062,7 @@ proc_wait2(int argc, VALUE *argv, VALUE _)
*/
static VALUE
-proc_waitall(VALUE _)
+proc_waitall(void)
{
VALUE result;
rb_pid_t pid;
@@ -1465,17 +1122,18 @@ rb_detach_process(rb_pid_t pid)
* processes until the parent collects that status (normally using
* some variant of <code>wait()</code>). If the parent never collects
* this status, the child stays around as a <em>zombie</em> process.
- * Process::detach prevents this by setting up a separate Ruby thread
- * whose sole job is to reap the status of the process _pid_ when it
- * terminates. Use #detach only when you do not intend to explicitly
- * wait for the child to terminate.
+ * <code>Process::detach</code> prevents this by setting up a
+ * separate Ruby thread whose sole job is to reap the status of the
+ * process _pid_ when it terminates. Use <code>detach</code>
+ * only when you do not intend to explicitly wait for the child to
+ * terminate.
*
* The waiting thread returns the exit status of the detached process
- * when it terminates, so you can use Thread#join to
+ * when it terminates, so you can use <code>Thread#join</code> to
* know the result. If specified _pid_ is not a valid child process
* ID, the thread returns +nil+ immediately.
*
- * The waiting thread has #pid method which returns the pid.
+ * The waiting thread has <code>pid</code> method which returns the pid.
*
* In this first example, we don't reap the first child process, so
* it appears as a zombie in the process status display.
@@ -1490,7 +1148,7 @@ rb_detach_process(rb_pid_t pid)
*
* 27389 Z
*
- * In the next example, Process::detach is used to reap
+ * In the next example, <code>Process::detach</code> is used to reap
* the child automatically.
*
* p1 = fork { sleep 0.1 }
@@ -1530,39 +1188,6 @@ before_exec_non_async_signal_safe(void)
rb_thread_stop_timer_thread();
}
-#define WRITE_CONST(fd, str) (void)(write((fd),(str),sizeof(str)-1)<0)
-#ifdef _WIN32
-int rb_w32_set_nonblock2(int fd, int nonblock);
-#endif
-
-static int
-set_blocking(int fd)
-{
-#ifdef _WIN32
- return rb_w32_set_nonblock2(fd, 0);
-#elif defined(F_GETFL) && defined(F_SETFL)
- int fl = fcntl(fd, F_GETFL); /* async-signal-safe */
-
- /* EBADF ought to be possible */
- if (fl == -1) return fl;
- if (fl & O_NONBLOCK) {
- fl &= ~O_NONBLOCK;
- return fcntl(fd, F_SETFL, fl);
- }
- return 0;
-#endif
-}
-
-static void
-stdfd_clear_nonblock(void)
-{
- /* many programs cannot deal with non-blocking stdin/stdout/stderr */
- int fd;
- for (fd = 0; fd < 3; fd++) {
- (void)set_blocking(fd); /* can't do much about errors anyhow */
- }
-}
-
static void
before_exec(void)
{
@@ -1590,17 +1215,20 @@ after_exec(void)
after_exec_non_async_signal_safe();
}
-#if defined HAVE_WORKING_FORK || defined HAVE_DAEMON
#define before_fork_ruby() before_exec()
+#define after_fork_ruby() (rb_threadptr_pending_interrupt_clear(GET_THREAD()), after_exec())
+
+#include "dln.h"
+
static void
-after_fork_ruby(void)
+security(const char *str)
{
- rb_threadptr_pending_interrupt_clear(GET_THREAD());
- after_exec();
+ if (rb_env_path_tainted()) {
+ if (rb_safe_level() > 0) {
+ rb_raise(rb_eSecurityError, "Insecure PATH - %s", str);
+ }
+ }
}
-#endif
-
-#include "dln.h"
#if defined(HAVE_WORKING_FORK)
@@ -1618,7 +1246,7 @@ exec_with_sh(const char *prog, char **argv, char **envp)
}
#else
-#define try_with_sh(err, prog, argv, envp) (void)0
+#define try_with_sh(prog, argv, envp) (void)0
#endif
/* This function should be async-signal-safe. Actually it is. */
@@ -1641,7 +1269,7 @@ proc_exec_cmd(const char *prog, VALUE argv_str, VALUE envp_str)
rb_w32_uaspawn(P_OVERLAY, prog, argv);
return errno;
#else
- envp = envp_str ? RB_IMEMO_TMPBUF_PTR(envp_str) : NULL;
+ envp = envp_str ? (char **)RSTRING_PTR(envp_str) : NULL;
if (envp_str)
execve(prog, argv, envp); /* async-signal-safe */
else
@@ -1682,7 +1310,7 @@ proc_exec_sh(const char *str, VALUE envp_str)
}
#else
if (envp_str)
- execle("/bin/sh", "sh", "-c", str, (char *)NULL, RB_IMEMO_TMPBUF_PTR(envp_str)); /* async-signal-safe */
+ execle("/bin/sh", "sh", "-c", str, (char *)NULL, (char **)RSTRING_PTR(envp_str)); /* async-signal-safe */
else
execl("/bin/sh", "sh", "-c", str, (char *)NULL); /* async-signal-safe (since SUSv4) */
#endif /* _WIN32 */
@@ -1777,6 +1405,7 @@ proc_spawn_cmd_internal(char **argv, char *prog)
if (!prog)
prog = argv[0];
+ security(prog);
prog = dln_find_exe_r(prog, 0, fbuf, sizeof(fbuf));
if (!prog)
return -1;
@@ -1857,7 +1486,7 @@ check_exec_redirect_fd(VALUE v, int iskey)
else
goto wrong;
}
- else if (!NIL_P(tmp = rb_io_check_io(v))) {
+ else if (!NIL_P(tmp = rb_check_convert_type_with_id(v, T_FILE, "IO", idTo_io))) {
rb_io_t *fptr;
GetOpenFile(tmp, fptr);
if (fptr->tied_io_for_writing)
@@ -1978,7 +1607,7 @@ check_exec_redirect(VALUE key, VALUE val, struct rb_execarg *eargp)
else if (RB_TYPE_P(key, T_ARRAY)) {
int i;
for (i = 0; i < RARRAY_LEN(key); i++) {
- VALUE v = RARRAY_AREF(key, i);
+ VALUE v = RARRAY_PTR(key)[i];
VALUE fd = check_exec_redirect_fd(v, 1);
if (FIX2INT(fd) != 1 && FIX2INT(fd) != 2) break;
}
@@ -2036,7 +1665,6 @@ rb_execarg_addopt_rlimit(struct rb_execarg *eargp, int rtype, VALUE val)
}
#endif
-#define TO_BOOL(val, name) NIL_P(val) ? 0 : rb_bool_expected((val), name)
int
rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val)
{
@@ -2084,7 +1712,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val)
rb_raise(rb_eArgError, "new_pgroup option specified twice");
}
eargp->new_pgroup_given = 1;
- eargp->new_pgroup_flag = TO_BOOL(val, "new_pgroup");
+ eargp->new_pgroup_flag = RTEST(val) ? 1 : 0;
}
else
#endif
@@ -2093,7 +1721,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val)
rb_raise(rb_eArgError, "unsetenv_others option specified twice");
}
eargp->unsetenv_others_given = 1;
- eargp->unsetenv_others_do = TO_BOOL(val, "unsetenv_others");
+ eargp->unsetenv_others_do = RTEST(val) ? 1 : 0;
}
else if (id == id_chdir) {
if (eargp->chdir_given) {
@@ -2117,7 +1745,7 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val)
rb_raise(rb_eArgError, "close_others option specified twice");
}
eargp->close_others_given = 1;
- eargp->close_others_do = TO_BOOL(val, "close_others");
+ eargp->close_others_do = RTEST(val) ? 1 : 0;
}
else if (id == id_in) {
key = INT2FIX(0);
@@ -2161,13 +1789,6 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val)
"gid option is unimplemented on this machine");
#endif
}
- else if (id == id_exception) {
- if (eargp->exception_given) {
- rb_raise(rb_eArgError, "exception option specified twice");
- }
- eargp->exception_given = 1;
- eargp->exception = TO_BOOL(val, "exception");
- }
else {
return ST_STOP;
}
@@ -2300,7 +1921,7 @@ rb_check_exec_options(VALUE opthash, VALUE execarg_obj)
{
if (RHASH_EMPTY_P(opthash))
return;
- rb_hash_stlike_foreach(opthash, check_exec_options_i, (st_data_t)execarg_obj);
+ st_foreach(rb_hash_tbl_raw(opthash), check_exec_options_i, (st_data_t)execarg_obj);
}
VALUE
@@ -2311,7 +1932,7 @@ rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash)
return Qnil;
args[0] = execarg_obj;
args[1] = Qnil;
- rb_hash_stlike_foreach(opthash, check_exec_options_i_extract, (st_data_t)args);
+ st_foreach(rb_hash_tbl_raw(opthash), check_exec_options_i_extract, (st_data_t)args);
return args[1];
}
@@ -2355,7 +1976,7 @@ rb_check_exec_env(VALUE hash, VALUE *path)
env[0] = hide_obj(rb_ary_new());
env[1] = Qfalse;
- rb_hash_stlike_foreach(hash, check_exec_env_i, (st_data_t)env);
+ st_foreach(rb_hash_tbl_raw(hash), check_exec_env_i, (st_data_t)env);
*path = env[1];
return env[0];
@@ -2366,6 +1987,7 @@ rb_check_argv(int argc, VALUE *argv)
{
VALUE tmp, prog;
int i;
+ const char *name = 0;
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
@@ -2380,12 +2002,14 @@ rb_check_argv(int argc, VALUE *argv)
SafeStringValue(prog);
StringValueCStr(prog);
prog = rb_str_new_frozen(prog);
+ name = RSTRING_PTR(prog);
}
for (i = 0; i < argc; i++) {
SafeStringValue(argv[i]);
argv[i] = rb_str_new_frozen(argv[i]);
StringValueCStr(argv[i]);
}
+ security(name ? name : RSTRING_PTR(argv[0]));
return prog;
}
@@ -2578,9 +2202,7 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, VAL
}
}
eargp->invoke.cmd.argv_buf = argv_buf;
- eargp->invoke.cmd.command_name =
- hide_obj(rb_str_subseq(argv_buf, 0, strlen(RSTRING_PTR(argv_buf))));
- rb_enc_copy(eargp->invoke.cmd.command_name, prog);
+ eargp->invoke.cmd.command_name = hide_obj(rb_str_new_cstr(RSTRING_PTR(argv_buf)));
}
}
#endif
@@ -2626,12 +2248,21 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, VAL
p += strlen(p) + 1;
}
rb_str_buf_cat(argv_str, (char *)&null, sizeof(null)); /* terminator for execve. */
- eargp->invoke.cmd.argv_str =
- rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(argv_str);
+ eargp->invoke.cmd.argv_str = argv_str;
}
RB_GC_GUARD(execarg_obj);
}
+VALUE
+rb_execarg_new(int argc, const VALUE *argv, int accept_shell)
+{
+ VALUE execarg_obj;
+ struct rb_execarg *eargp;
+ execarg_obj = TypedData_Make_Struct(0, struct rb_execarg, &exec_arg_data_type, eargp);
+ rb_execarg_init(argc, argv, accept_shell, execarg_obj);
+ return execarg_obj;
+}
+
struct rb_execarg *
rb_execarg_get(VALUE execarg_obj)
{
@@ -2640,7 +2271,7 @@ rb_execarg_get(VALUE execarg_obj)
return eargp;
}
-static VALUE
+VALUE
rb_execarg_init(int argc, const VALUE *orig_argv, int accept_shell, VALUE execarg_obj)
{
struct rb_execarg *eargp = rb_execarg_get(execarg_obj);
@@ -2657,19 +2288,6 @@ rb_execarg_init(int argc, const VALUE *orig_argv, int accept_shell, VALUE execar
return ret;
}
-VALUE
-rb_execarg_new(int argc, const VALUE *argv, int accept_shell, int allow_exc_opt)
-{
- VALUE execarg_obj;
- struct rb_execarg *eargp;
- execarg_obj = TypedData_Make_Struct(0, struct rb_execarg, &exec_arg_data_type, eargp);
- rb_execarg_init(argc, argv, accept_shell, execarg_obj);
- if (!allow_exc_opt && eargp->exception_given) {
- rb_raise(rb_eArgError, "exception option is not allowed");
- }
- return execarg_obj;
-}
-
void
rb_execarg_setenv(VALUE execarg_obj, VALUE env)
{
@@ -2714,14 +2332,6 @@ open_func(void *ptr)
return NULL;
}
-static void
-rb_execarg_allocate_dup2_tmpbuf(struct rb_execarg *eargp, long len)
-{
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- rb_imemo_tmpbuf_set_ptr(tmpbuf, ruby_xmalloc(run_exec_dup2_tmpbuf_size(len)));
- eargp->dup2_tmpbuf = tmpbuf;
-}
-
static VALUE
rb_execarg_parent_start1(VALUE execarg_obj)
{
@@ -2739,7 +2349,7 @@ rb_execarg_parent_start1(VALUE execarg_obj)
VALUE param = RARRAY_AREF(elt, 1);
VALUE vpath = RARRAY_AREF(param, 0);
int flags = NUM2INT(RARRAY_AREF(param, 1));
- mode_t perm = NUM2MODET(RARRAY_AREF(param, 2));
+ int perm = NUM2INT(RARRAY_AREF(param, 2));
VALUE fd2v = RARRAY_AREF(param, 3);
int fd2;
if (NIL_P(fd2v)) {
@@ -2776,7 +2386,10 @@ rb_execarg_parent_start1(VALUE execarg_obj)
ary = eargp->fd_dup2;
if (ary != Qfalse) {
- rb_execarg_allocate_dup2_tmpbuf(eargp, RARRAY_LEN(ary));
+ size_t len = run_exec_dup2_tmpbuf_size(RARRAY_LEN(ary));
+ VALUE tmpbuf = hide_obj(rb_str_new(0, len));
+ rb_str_set_len(tmpbuf, len);
+ eargp->dup2_tmpbuf = tmpbuf;
}
unsetenv_others = eargp->unsetenv_others_given && eargp->unsetenv_others_do;
@@ -2812,7 +2425,7 @@ rb_execarg_parent_start1(VALUE execarg_obj)
}
envp_buf = rb_str_buf_new(0);
hide_obj(envp_buf);
- rb_hash_stlike_foreach(envtbl, fill_envp_buf_i, (st_data_t)envp_buf);
+ st_foreach(RHASH_TBL_RAW(envtbl), fill_envp_buf_i, (st_data_t)envp_buf);
envp_str = rb_str_buf_new(sizeof(char*) * (RHASH_SIZE(envtbl) + 1));
hide_obj(envp_str);
p = RSTRING_PTR(envp_buf);
@@ -2823,8 +2436,7 @@ rb_execarg_parent_start1(VALUE execarg_obj)
}
p = NULL;
rb_str_buf_cat(envp_str, (char *)&p, sizeof(p));
- eargp->envp_str =
- rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(envp_str);
+ eargp->envp_str = envp_str;
eargp->envp_buf = envp_buf;
/*
@@ -2906,38 +2518,6 @@ rb_execarg_fail(VALUE execarg_obj, int err, const char *errmsg)
}
#endif
-VALUE
-rb_f_exec(int argc, const VALUE *argv)
-{
- VALUE execarg_obj, fail_str;
- struct rb_execarg *eargp;
-#define CHILD_ERRMSG_BUFLEN 80
- char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
- int err, state;
-
- execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
- eargp = rb_execarg_get(execarg_obj);
- if (mjit_enabled) mjit_finish(false); // avoid leaking resources, and do not leave files. XXX: JIT-ed handle can leak after exec error is rescued.
- before_exec(); /* stop timer thread before redirects */
-
- rb_protect(rb_execarg_parent_start1, execarg_obj, &state);
- if (state) {
- execarg_parent_end(execarg_obj);
- after_exec(); /* restart timer thread */
- rb_jump_tag(state);
- }
-
- fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;
-
- err = exec_async_signal_safe(eargp, errmsg, sizeof(errmsg));
- after_exec(); /* restart timer thread */
-
- rb_exec_fail(eargp, err, errmsg);
- RB_GC_GUARD(execarg_obj);
- rb_syserr_fail_str(err, fail_str);
- UNREACHABLE_RETURN(Qnil);
-}
-
/*
* call-seq:
* exec([env,] command... [,options])
@@ -2989,7 +2569,7 @@ rb_f_exec(int argc, const VALUE *argv)
* This behavior is modified by the given +env+ and +options+ parameters. See
* ::spawn for details.
*
- * If the command fails to execute (typically Errno::ENOENT when
+ * If the command fails to execute (typically <code>Errno::ENOENT</code> when
* it was not found) a SystemCallError exception is raised.
*
* This method modifies process attributes according to given +options+ before
@@ -3011,10 +2591,28 @@ rb_f_exec(int argc, const VALUE *argv)
* # never get here
*/
-static VALUE
-f_exec(int c, const VALUE *a, VALUE _)
+VALUE
+rb_f_exec(int argc, const VALUE *argv)
{
- return rb_f_exec(c, a);
+ VALUE execarg_obj, fail_str;
+ struct rb_execarg *eargp;
+#define CHILD_ERRMSG_BUFLEN 80
+ char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
+ int err;
+
+ execarg_obj = rb_execarg_new(argc, argv, TRUE);
+ eargp = rb_execarg_get(execarg_obj);
+ before_exec(); /* stop timer thread before redirects */
+ rb_execarg_parent_start(execarg_obj);
+ fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;
+
+ err = exec_async_signal_safe(eargp, errmsg, sizeof(errmsg));
+ after_exec(); /* restart timer thread */
+
+ rb_exec_fail(eargp, err, errmsg);
+ RB_GC_GUARD(execarg_obj);
+ rb_syserr_fail_str(err, fail_str);
+ UNREACHABLE;
}
#define ERRMSG(str) do { if (errmsg && 0 < errmsg_buflen) strlcpy(errmsg, (str), errmsg_buflen); } while (0)
@@ -3154,10 +2752,10 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
long n, i;
int ret;
int extra_fd = -1;
- struct rb_imemo_tmpbuf_struct *buf = (void *)tmpbuf;
- struct run_exec_dup2_fd_pair *pairs = (void *)buf->ptr;
+ struct run_exec_dup2_fd_pair *pairs = 0;
n = RARRAY_LEN(ary);
+ pairs = (struct run_exec_dup2_fd_pair *)RSTRING_PTR(tmpbuf);
/* initialize oldfd and newfd: O(n) */
for (i = 0; i < n; i++) {
@@ -3490,7 +3088,7 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp,
}
#ifdef HAVE_WORKING_FORK
- if (eargp->close_others_do) {
+ if (!eargp->close_others_given || eargp->close_others_do) {
rb_close_before_exec(3, eargp->close_others_maxhint, eargp->redirect_fds); /* async-signal-safe */
}
#endif
@@ -3534,14 +3132,12 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp,
if (sargp) {
VALUE ary = sargp->fd_dup2;
if (ary != Qfalse) {
- rb_execarg_allocate_dup2_tmpbuf(sargp, RARRAY_LEN(ary));
+ size_t len = run_exec_dup2_tmpbuf_size(RARRAY_LEN(ary));
+ VALUE tmpbuf = hide_obj(rb_str_new(0, len));
+ rb_str_set_len(tmpbuf, len);
+ sargp->dup2_tmpbuf = tmpbuf;
}
}
- {
- int preserve = errno;
- stdfd_clear_nonblock();
- errno = preserve;
- }
return 0;
}
@@ -3591,7 +3187,9 @@ rb_exec_atfork(void* arg, char *errmsg, size_t errmsg_buflen)
{
return rb_exec_async_signal_safe(arg, errmsg, errmsg_buflen); /* hopefully async-signal-safe */
}
+#endif
+#ifdef HAVE_WORKING_FORK
#if SIZEOF_INT == SIZEOF_LONG
#define proc_syswait (VALUE (*)(VALUE))rb_syswait
#else
@@ -3649,13 +3247,6 @@ pipe_nocrash(int filedes[2], VALUE fds)
#define O_BINARY 0
#endif
-static VALUE
-rb_thread_sleep_that_takes_VALUE_as_sole_argument(VALUE n)
-{
- rb_thread_sleep(NUM2INT(n));
- return Qundef;
-}
-
static int
handle_fork_error(int err, int *status, int *ep, volatile int *try_gc_p)
{
@@ -3677,7 +3268,7 @@ handle_fork_error(int err, int *status, int *ep, volatile int *try_gc_p)
return 0;
}
else {
- rb_protect(rb_thread_sleep_that_takes_VALUE_as_sole_argument, INT2FIX(1), &state);
+ rb_protect((VALUE (*)())rb_thread_sleep, 1, &state);
if (status) *status = state;
if (!state) return 0;
}
@@ -3740,12 +3331,6 @@ read_retry(int fd, void *buf, size_t len)
{
ssize_t r;
- if (set_blocking(fd) != 0) {
-#ifndef _WIN32
- rb_async_bug_errno("set_blocking failed reading child error", errno);
-#endif
- }
-
do {
r = read(fd, buf, len);
} while (r < 0 && errno == EINTR);
@@ -3891,6 +3476,7 @@ has_privilege(void)
struct child_handler_disabler_state
{
sigset_t sigmask;
+ int cancelstate;
};
static void
@@ -3911,6 +3497,13 @@ disable_child_handler_before_fork(struct child_handler_disabler_state *old)
#else
# pragma GCC warning "pthread_sigmask on fork is not available. potentially dangerous"
#endif
+
+#ifdef PTHREAD_CANCEL_DISABLE
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old->cancelstate);
+ if (ret != 0) {
+ rb_syserr_fail(ret, "pthread_setcancelstate");
+ }
+#endif
}
static void
@@ -3918,6 +3511,13 @@ disable_child_handler_fork_parent(struct child_handler_disabler_state *old)
{
int ret;
+#ifdef PTHREAD_CANCEL_DISABLE
+ ret = pthread_setcancelstate(old->cancelstate, NULL);
+ if (ret != 0) {
+ rb_syserr_fail(ret, "pthread_setcancelstate");
+ }
+#endif
+
#ifdef HAVE_PTHREAD_SIGMASK
ret = pthread_sigmask(SIG_SETMASK, &old->sigmask, NULL); /* not async-signal-safe */
if (ret != 0) {
@@ -3956,8 +3556,6 @@ disable_child_handler_fork_child(struct child_handler_disabler_state *old, char
}
}
- /* non-Ruby child process, ensure cmake can see SIGCHLD */
- sigemptyset(&old->sigmask);
ret = sigprocmask(SIG_SETMASK, &old->sigmask, NULL); /* async-signal-safe */
if (ret != 0) {
ERRMSG("sigprocmask");
@@ -3966,30 +3564,19 @@ disable_child_handler_fork_child(struct child_handler_disabler_state *old, char
return 0;
}
-COMPILER_WARNING_PUSH
-#ifdef __GNUC__
-COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
-#endif
static rb_pid_t
retry_fork_async_signal_safe(int *status, int *ep,
int (*chfunc)(void*, char *, size_t), void *charg,
- char *errmsg, size_t errmsg_buflen,
- struct waitpid_state *w)
+ char *errmsg, size_t errmsg_buflen)
{
rb_pid_t pid;
volatile int try_gc = 1;
struct child_handler_disabler_state old;
int err;
- rb_nativethread_lock_t *const volatile waitpid_lock_init =
- (w && WAITPID_USE_SIGCHLD) ? &GET_VM()->waitpid_lock : 0;
while (1) {
- rb_nativethread_lock_t *waitpid_lock = waitpid_lock_init;
prefork();
disable_child_handler_before_fork(&old);
- if (waitpid_lock) {
- rb_native_mutex_lock(waitpid_lock);
- }
#ifdef HAVE_WORKING_VFORK
if (!has_privilege())
pid = vfork();
@@ -4014,14 +3601,6 @@ retry_fork_async_signal_safe(int *status, int *ep,
#endif
}
err = errno;
- waitpid_lock = waitpid_lock_init;
- if (waitpid_lock) {
- if (pid > 0 && w != WAITPID_LOCK_ONLY) {
- w->pid = pid;
- list_add(&GET_VM()->waiting_pids, &w->wnode);
- }
- rb_native_mutex_unlock(waitpid_lock);
- }
disable_child_handler_fork_parent(&old);
if (0 < pid) /* fork succeed, parent process */
return pid;
@@ -4030,37 +3609,29 @@ retry_fork_async_signal_safe(int *status, int *ep,
return -1;
}
}
-COMPILER_WARNING_POP
-static rb_pid_t
-fork_check_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg,
- VALUE fds, char *errmsg, size_t errmsg_buflen,
- struct rb_execarg *eargp)
+rb_pid_t
+rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds,
+ char *errmsg, size_t errmsg_buflen)
{
rb_pid_t pid;
int err;
int ep[2];
int error_occurred;
- struct waitpid_state *w;
-
- w = eargp && eargp->waitpid_state ? eargp->waitpid_state : 0;
if (status) *status = 0;
if (pipe_nocrash(ep, fds)) return -1;
- pid = retry_fork_async_signal_safe(status, ep, chfunc, charg,
- errmsg, errmsg_buflen, w);
+ pid = retry_fork_async_signal_safe(status, ep, chfunc, charg, errmsg, errmsg_buflen);
if (pid < 0)
return pid;
close(ep[1]);
error_occurred = recv_child_error(ep[0], &err, errmsg, errmsg_buflen);
if (error_occurred) {
if (status) {
- VM_ASSERT((w == 0 || w == WAITPID_LOCK_ONLY) &&
- "only used by extensions");
rb_protect(proc_syswait, (VALUE)pid, status);
}
- else if (!w) {
+ else {
rb_syswait(pid);
}
errno = err;
@@ -4069,25 +3640,6 @@ fork_check_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg,
return pid;
}
-/*
- * The "async_signal_safe" name is a lie, but it is used by pty.c and
- * maybe other exts. fork() is not async-signal-safe due to pthread_atfork
- * and future POSIX revisions will remove it from a list of signal-safe
- * functions. rb_waitpid is not async-signal-safe since MJIT, either.
- * For our purposes, we do not need async-signal-safety, here
- */
-rb_pid_t
-rb_fork_async_signal_safe(int *status,
- int (*chfunc)(void*, char *, size_t), void *charg,
- VALUE fds, char *errmsg, size_t errmsg_buflen)
-{
- return fork_check_err(status, chfunc, charg, fds, errmsg, errmsg_buflen, 0);
-}
-
-COMPILER_WARNING_PUSH
-#ifdef __GNUC__
-COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
-#endif
rb_pid_t
rb_fork_ruby(int *status)
{
@@ -4099,14 +3651,12 @@ rb_fork_ruby(int *status)
while (1) {
prefork();
- if (mjit_enabled) mjit_pause(false); // Don't leave locked mutex to child. Note: child_handler must be enabled to pause MJIT.
disable_child_handler_before_fork(&old);
before_fork_ruby();
pid = fork();
err = errno;
- after_fork_ruby();
+ after_fork_ruby();
disable_child_handler_fork_parent(&old); /* yes, bad name */
- if (mjit_enabled && pid > 0) mjit_resume(); /* child (pid == 0) is cared by rb_thread_atfork */
if (pid >= 0) /* fork succeed */
return pid;
/* fork failed */
@@ -4114,7 +3664,6 @@ rb_fork_ruby(int *status)
return -1;
}
}
-COMPILER_WARNING_POP
#endif
@@ -4126,14 +3675,15 @@ COMPILER_WARNING_POP
*
* Creates a subprocess. If a block is specified, that block is run
* in the subprocess, and the subprocess terminates with a status of
- * zero. Otherwise, the +fork+ call returns twice, once in the
- * parent, returning the process ID of the child, and once in the
- * child, returning _nil_. The child process can exit using
- * Kernel.exit! to avoid running any <code>at_exit</code>
- * functions. The parent process should use Process.wait to collect
- * the termination statuses of its children or use Process.detach to
- * register disinterest in their status; otherwise, the operating
- * system may accumulate zombie processes.
+ * zero. Otherwise, the +fork+ call returns twice, once in
+ * the parent, returning the process ID of the child, and once in
+ * the child, returning _nil_. The child process can exit using
+ * <code>Kernel.exit!</code> to avoid running any
+ * <code>at_exit</code> functions. The parent process should
+ * use <code>Process.wait</code> to collect the termination statuses
+ * of its children or use <code>Process.detach</code> to register
+ * disinterest in their status; otherwise, the operating system
+ * may accumulate zombie processes.
*
* The thread calling fork is the only thread in the created child process.
* fork doesn't copy other threads.
@@ -4218,7 +3768,7 @@ rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)
}
_exit(istatus);
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
void
@@ -4234,21 +3784,6 @@ rb_exit(int status)
ruby_stop(status);
}
-VALUE
-rb_f_exit(int argc, const VALUE *argv)
-{
- int istatus;
-
- if (rb_check_arity(argc, 0, 1) == 1) {
- istatus = exit_status_code(argv[0]);
- }
- else {
- istatus = EXIT_SUCCESS;
- }
- rb_exit(istatus);
-
- UNREACHABLE_RETURN(Qnil);
-}
/*
* call-seq:
@@ -4257,7 +3792,7 @@ rb_f_exit(int argc, const VALUE *argv)
* Process::exit(status=true)
*
* Initiates the termination of the Ruby script by raising the
- * SystemExit exception. This exception may be caught. The
+ * <code>SystemExit</code> exception. This exception may be caught. The
* optional parameter is used to return a status code to the invoking
* environment.
* +true+ and +FALSE+ of _status_ means success and failure
@@ -4277,9 +3812,9 @@ rb_f_exit(int argc, const VALUE *argv)
* rescued a SystemExit exception
* after begin block
*
- * Just prior to termination, Ruby executes any <code>at_exit</code>
- * functions (see Kernel::at_exit) and runs any object finalizers
- * (see ObjectSpace::define_finalizer).
+ * Just prior to termination, Ruby executes any <code>at_exit</code> functions
+ * (see Kernel::at_exit) and runs any object finalizers (see
+ * ObjectSpace::define_finalizer).
*
* at_exit { puts "at_exit function" }
* ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
@@ -4291,12 +3826,23 @@ rb_f_exit(int argc, const VALUE *argv)
* in finalizer
*/
-static VALUE
-f_exit(int c, const VALUE *a, VALUE _)
+VALUE
+rb_f_exit(int argc, const VALUE *argv)
{
- return rb_f_exit(c, a);
+ int istatus;
+
+ if (rb_check_arity(argc, 0, 1) == 1) {
+ istatus = exit_status_code(argv[0]);
+ }
+ else {
+ istatus = EXIT_SUCCESS;
+ }
+ rb_exit(istatus);
+
+ UNREACHABLE;
}
+
/*
* call-seq:
* abort
@@ -4314,7 +3860,7 @@ rb_f_abort(int argc, const VALUE *argv)
rb_check_arity(argc, 0, 1);
if (argc == 0) {
rb_execution_context_t *ec = GET_EC();
- VALUE errinfo = rb_ec_get_errinfo(ec);
+ VALUE errinfo = ec->errinfo;
if (!NIL_P(errinfo)) {
rb_ec_error_print(ec, errinfo);
}
@@ -4330,13 +3876,7 @@ rb_f_abort(int argc, const VALUE *argv)
rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit));
}
- UNREACHABLE_RETURN(Qnil);
-}
-
-static VALUE
-f_abort(int c, const VALUE *a, VALUE _)
-{
- return rb_f_abort(c, a);
+ UNREACHABLE;
}
void
@@ -4383,8 +3923,7 @@ rb_spawn_process(struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
#endif
#if defined HAVE_WORKING_FORK && !USE_SPAWNV
- pid = fork_check_err(0, rb_exec_atfork, eargp, eargp->redirect_fds,
- errmsg, errmsg_buflen, eargp);
+ pid = rb_fork_async_signal_safe(NULL, rb_exec_atfork, eargp, eargp->redirect_fds, errmsg, errmsg_buflen);
#else
prog = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;
@@ -4411,9 +3950,7 @@ rb_spawn_process(struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
rb_last_status_set((status & 0xff) << 8, 0);
pid = 1; /* dummy */
# endif
- if (eargp->waitpid_state && eargp->waitpid_state != WAITPID_LOCK_ONLY) {
- eargp->waitpid_state->pid = pid;
- }
+
rb_execarg_run_options(&sarg, NULL, errmsg, errmsg_buflen);
#endif
return pid;
@@ -4440,15 +3977,6 @@ static rb_pid_t
rb_execarg_spawn(VALUE execarg_obj, char *errmsg, size_t errmsg_buflen)
{
struct spawn_args args;
- struct rb_execarg *eargp = rb_execarg_get(execarg_obj);
-
- /*
- * Prevent a race with MJIT where the compiler process where
- * can hold an FD of ours in between vfork + execve
- */
- if (!eargp->waitpid_state && mjit_enabled) {
- eargp->waitpid_state = WAITPID_LOCK_ONLY;
- }
args.execarg = execarg_obj;
args.errmsg.ptr = errmsg;
@@ -4462,7 +3990,7 @@ rb_spawn_internal(int argc, const VALUE *argv, char *errmsg, size_t errmsg_bufle
{
VALUE execarg_obj;
- execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
+ execarg_obj = rb_execarg_new(argc, argv, TRUE);
return rb_execarg_spawn(execarg_obj, errmsg, errmsg_buflen);
}
@@ -4480,31 +4008,25 @@ rb_spawn(int argc, const VALUE *argv)
/*
* call-seq:
- * system([env,] command... [,options], exception: false) -> true, false or nil
+ * system([env,] command... [,options]) -> true, false or nil
*
* Executes _command..._ in a subshell.
* _command..._ is one of following forms.
*
- * [<code>commandline</code>]
- * command line string which is passed to the standard shell
- * [<code>cmdname, arg1, ...</code>]
- * command name and one or more arguments (no shell)
- * [<code>[cmdname, argv0], arg1, ...</code>]
- * command name, <code>argv[0]</code> and zero or more arguments (no shell)
+ * commandline : command line string which is passed to the standard shell
+ * cmdname, arg1, ... : command name and one or more arguments (no shell)
+ * [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
*
* system returns +true+ if the command gives zero exit status,
* +false+ for non zero exit status.
* Returns +nil+ if command execution fails.
* An error status is available in <code>$?</code>.
- *
- * If the <code>exception: true</code> argument is passed, the method
- * raises an exception instead of returning +false+ or +nil+.
- *
* The arguments are processed in the same way as
- * for Kernel#spawn.
+ * for <code>Kernel.spawn</code>.
*
- * The hash arguments, env and options, are same as #exec and #spawn.
- * See Kernel#spawn for details.
+ * The hash arguments, env and options, are same as
+ * <code>exec</code> and <code>spawn</code>.
+ * See <code>Kernel.spawn</code> for details.
*
* system("echo *")
* system("echo", "*")
@@ -4514,77 +4036,43 @@ rb_spawn(int argc, const VALUE *argv)
* config.h main.rb
* *
*
- * Error handling:
- *
- * system("cat nonexistent.txt")
- * # => false
- * system("catt nonexistent.txt")
- * # => nil
- *
- * system("cat nonexistent.txt", exception: true)
- * # RuntimeError (Command failed with exit 1: cat)
- * system("catt nonexistent.txt", exception: true)
- * # Errno::ENOENT (No such file or directory - catt)
- *
- * See Kernel#exec for the standard shell.
+ * See <code>Kernel.exec</code> for the standard shell.
*/
static VALUE
-rb_f_system(int argc, VALUE *argv, VALUE _)
+rb_f_system(int argc, VALUE *argv)
{
- /*
- * n.b. using alloca for now to simplify future Thread::Light code
- * when we need to use malloc for non-native Fiber
- */
- struct waitpid_state *w = alloca(sizeof(struct waitpid_state));
- rb_pid_t pid; /* may be different from waitpid_state.pid on exec failure */
- VALUE execarg_obj;
- struct rb_execarg *eargp;
- int exec_errnum;
+ rb_pid_t pid;
+ int status;
- execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE);
- eargp = rb_execarg_get(execarg_obj);
- w->ec = GET_EC();
- waitpid_state_init(w, 0, 0);
- eargp->waitpid_state = w;
- pid = rb_execarg_spawn(execarg_obj, 0, 0);
- exec_errnum = pid < 0 ? errno : 0;
+#if defined(SIGCLD) && !defined(SIGCHLD)
+# define SIGCHLD SIGCLD
+#endif
+
+#ifdef SIGCHLD
+ RETSIGTYPE (*chfunc)(int);
+ rb_last_status_clear();
+ chfunc = signal(SIGCHLD, SIG_DFL);
+#endif
+ pid = rb_spawn_internal(argc, argv, NULL, 0);
#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV)
- if (w->pid > 0) {
- /* `pid' (not w->pid) may be < 0 here if execve failed in child */
- if (WAITPID_USE_SIGCHLD) {
- rb_ensure(waitpid_sleep, (VALUE)w, waitpid_cleanup, (VALUE)w);
- }
- else {
- waitpid_no_SIGCHLD(w);
- }
- rb_last_status_set(w->status, w->ret);
+ if (pid > 0) {
+ int ret, status;
+ ret = rb_waitpid(pid, &status, 0);
+ if (ret == (rb_pid_t)-1)
+ rb_sys_fail("Another thread waited the process started by system().");
}
#endif
- if (w->pid < 0 /* fork failure */ || pid < 0 /* exec failure */) {
- if (eargp->exception) {
- int err = exec_errnum ? exec_errnum : w->errnum;
- VALUE command = eargp->invoke.sh.shell_script;
- RB_GC_GUARD(execarg_obj);
- rb_syserr_fail_str(err, command);
- }
- else {
- return Qnil;
- }
- }
- if (w->status == EXIT_SUCCESS) return Qtrue;
- if (eargp->exception) {
- VALUE command = eargp->invoke.sh.shell_script;
- VALUE str = rb_str_new_cstr("Command failed with");
- rb_str_cat_cstr(pst_message_status(str, w->status), ": ");
- rb_str_append(str, command);
- RB_GC_GUARD(execarg_obj);
- rb_exc_raise(rb_exc_new_str(rb_eRuntimeError, str));
- }
- else {
- return Qfalse;
+#ifdef SIGCHLD
+ signal(SIGCHLD, chfunc);
+#endif
+ if (pid < 0) {
+ return Qnil;
}
+ status = PST2INT(rb_last_status_get());
+ if (status == EXIT_SUCCESS) return Qtrue;
+ return Qfalse;
}
/*
@@ -4604,9 +4092,9 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
* to finish.
*
* The parent process should
- * use Process.wait to collect
+ * use <code>Process.wait</code> to collect
* the termination status of its child or
- * use Process.detach to register
+ * use <code>Process.detach</code> to register
* disinterest in their status;
* otherwise, the operating system may accumulate zombie processes.
*
@@ -4656,18 +4144,17 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
* integer : the file descriptor of specified the integer
* io : the file descriptor specified as io.fileno
* file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not
- * :close_others => false : inherit
+ * :close_others => true : don't inherit
* current directory:
* :chdir => str
*
- * The <code>cmdname, arg1, ...</code> form does not use the shell.
- * However, on different OSes, different things are provided as
- * built-in commands. An example of this is +'echo'+, which is a
- * built-in on Windows, but is a normal program on Linux and Mac OS X.
- * This means that <code>Process.spawn 'echo', '%Path%'</code> will
- * display the contents of the <tt>%Path%</tt> environment variable
- * on Windows, but <code>Process.spawn 'echo', '$PATH'</code> prints
- * the literal <tt>$PATH</tt>.
+ * The 'cmdname, arg1, ...' form does not use the shell. However,
+ * on different OSes, different things are provided as built-in
+ * commands. An example of this is 'echo', which is a built-in
+ * on Windows, but is a normal program on Linux and Mac OS X.
+ * This means that `Process.spawn 'echo', '%Path%'` will display
+ * the contents of the `%Path%` environment variable on Windows,
+ * but `Process.spawn 'echo', '$PATH'` prints the literal '$PATH'.
*
* If a hash is given as +env+, the environment is
* updated by +env+ before <code>exec(2)</code> in the child process.
@@ -4737,12 +4224,12 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
* pid = spawn(command, STDERR=>:out)
* pid = spawn(command, STDERR=>STDOUT)
*
- * The hash keys specifies a file descriptor in the child process
- * started by #spawn.
+ * The hash keys specifies a file descriptor
+ * in the child process started by <code>spawn</code>.
* :err, 2 and STDERR specifies the standard error stream (stderr).
*
- * The hash values specifies a file descriptor in the parent process
- * which invokes #spawn.
+ * The hash values specifies a file descriptor
+ * in the parent process which invokes <code>spawn</code>.
* :out, 1 and STDOUT specifies the standard output stream (stdout).
*
* In the above example,
@@ -4816,7 +4303,7 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
* pid = spawn(command, :close_others=>true) # close 3,4,5,... (default)
* pid = spawn(command, :close_others=>false) # don't close 3,4,5,...
*
- * :close_others is false by default for spawn and IO.popen.
+ * :close_others is true by default for spawn and IO.popen.
*
* Note that fds which close-on-exec flag is already set are closed
* regardless of :close_others option.
@@ -4853,18 +4340,18 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
* Internally, +spawn+ uses an extra file descriptor to resolve such cyclic
* file descriptor mapping.
*
- * See Kernel.exec for the standard shell.
+ * See <code>Kernel.exec</code> for the standard shell.
*/
static VALUE
-rb_f_spawn(int argc, VALUE *argv, VALUE _)
+rb_f_spawn(int argc, VALUE *argv)
{
rb_pid_t pid;
char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
VALUE execarg_obj, fail_str;
struct rb_execarg *eargp;
- execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
+ execarg_obj = rb_execarg_new(argc, argv, TRUE);
eargp = rb_execarg_get(execarg_obj);
fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;
@@ -4890,7 +4377,7 @@ rb_f_spawn(int argc, VALUE *argv, VALUE _)
* Suspends the current thread for _duration_ seconds (which may be any number,
* including a +Float+ with fractional seconds). Returns the actual number of
* seconds slept (rounded), which may be less than that asked for if another
- * thread calls Thread#run. Called without an argument, sleep()
+ * thread calls <code>Thread#run</code>. Called without an argument, sleep()
* will sleep forever.
*
* Time.new #=> 2008-03-08 19:56:19 +0900
@@ -4901,7 +4388,7 @@ rb_f_spawn(int argc, VALUE *argv, VALUE _)
*/
static VALUE
-rb_f_sleep(int argc, VALUE *argv, VALUE _)
+rb_f_sleep(int argc, VALUE *argv)
{
time_t beg, end;
@@ -4933,7 +4420,7 @@ rb_f_sleep(int argc, VALUE *argv, VALUE _)
*/
static VALUE
-proc_getpgrp(VALUE _)
+proc_getpgrp(void)
{
rb_pid_t pgrp;
@@ -4962,7 +4449,7 @@ proc_getpgrp(VALUE _)
*/
static VALUE
-proc_setpgrp(VALUE _)
+proc_setpgrp(void)
{
/* check for posix setpgid() first; this matches the posix */
/* getpgrp() above. It appears that configure will set SETPGRP_VOID */
@@ -5044,7 +4531,7 @@ proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
* Process.getsid(Process.pid()) #=> 27422
*/
static VALUE
-proc_getsid(int argc, VALUE *argv, VALUE _)
+proc_getsid(int argc, VALUE *argv)
{
rb_pid_t sid;
rb_pid_t pid = 0;
@@ -5078,7 +4565,7 @@ static rb_pid_t ruby_setsid(void);
*/
static VALUE
-proc_setsid(VALUE _)
+proc_setsid(void)
{
rb_pid_t pid;
@@ -5126,9 +4613,9 @@ ruby_setsid(void)
*
* Gets the scheduling priority for specified process, process group,
* or user. <em>kind</em> indicates the kind of entity to find: one
- * of Process::PRIO_PGRP,
- * Process::PRIO_USER, or
- * Process::PRIO_PROCESS. _integer_ is an id
+ * of <code>Process::PRIO_PGRP</code>,
+ * <code>Process::PRIO_USER</code>, or
+ * <code>Process::PRIO_PROCESS</code>. _integer_ is an id
* indicating the particular process, process group, or user (an id
* of 0 means _current_). Lower priorities are more favorable
* for scheduling. Not available on all platforms.
@@ -5160,7 +4647,7 @@ proc_getpriority(VALUE obj, VALUE which, VALUE who)
* call-seq:
* Process.setpriority(kind, integer, priority) -> 0
*
- * See Process.getpriority.
+ * See <code>Process#getpriority</code>.
*
* Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0
* Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0
@@ -5362,7 +4849,7 @@ rlimit_resource_type(VALUE rtype)
rb_raise(rb_eArgError, "invalid resource name: % "PRIsVALUE, rtype);
- UNREACHABLE_RETURN(-1);
+ UNREACHABLE;
}
static rlim_t
@@ -5403,7 +4890,7 @@ rlimit_resource_value(VALUE rval)
#endif
rb_raise(rb_eArgError, "invalid resource value: %"PRIsVALUE, rval);
- UNREACHABLE_RETURN((rlim_t)-1);
+ UNREACHABLE;
}
#endif
@@ -5419,12 +4906,12 @@ rlimit_resource_value(VALUE rval)
* _resource_ indicates the kind of resource to limit.
* It is specified as a symbol such as <code>:CORE</code>,
* a string such as <code>"CORE"</code> or
- * a constant such as Process::RLIMIT_CORE.
+ * a constant such as <code>Process::RLIMIT_CORE</code>.
* See Process.setrlimit for details.
*
- * _cur_limit_ and _max_limit_ may be Process::RLIM_INFINITY,
- * Process::RLIM_SAVED_MAX or
- * Process::RLIM_SAVED_CUR.
+ * _cur_limit_ and _max_limit_ may be <code>Process::RLIM_INFINITY</code>,
+ * <code>Process::RLIM_SAVED_MAX</code> or
+ * <code>Process::RLIM_SAVED_CUR</code>.
* See Process.setrlimit and the system getrlimit(2) manual for details.
*/
@@ -5457,7 +4944,7 @@ proc_getrlimit(VALUE obj, VALUE resource)
* _resource_ indicates the kind of resource to limit.
* It should be a symbol such as <code>:CORE</code>,
* a string such as <code>"CORE"</code> or
- * a constant such as Process::RLIMIT_CORE.
+ * a constant such as <code>Process::RLIMIT_CORE</code>.
* The available resources are OS dependent.
* Ruby may support following resources.
*
@@ -5480,10 +4967,10 @@ proc_getrlimit(VALUE obj, VALUE resource)
*
* _cur_limit_ and _max_limit_ may be
* <code>:INFINITY</code>, <code>"INFINITY"</code> or
- * Process::RLIM_INFINITY,
+ * <code>Process::RLIM_INFINITY</code>,
* which means that the resource is not limited.
- * They may be Process::RLIM_SAVED_MAX,
- * Process::RLIM_SAVED_CUR and
+ * They may be <code>Process::RLIM_SAVED_MAX</code>,
+ * <code>Process::RLIM_SAVED_CUR</code> and
* corresponding symbols and strings too.
* See system setrlimit(2) manual for details.
*
@@ -5537,248 +5024,14 @@ check_gid_switch(void)
}
-#if defined(HAVE_PWD_H)
-/**
- * Best-effort attempt to obtain the name of the login user, if any,
- * associated with the process. Processes not descended from login(1) (or
- * similar) may not have a logged-in user; returns Qnil in that case.
- */
-VALUE
-rb_getlogin(void)
-{
-#if ( !defined(USE_GETLOGIN_R) && !defined(USE_GETLOGIN) )
- return Qnil;
-#else
- char MAYBE_UNUSED(*login) = NULL;
-
-# ifdef USE_GETLOGIN_R
-
- long loginsize = GETLOGIN_R_SIZE_INIT; /* maybe -1 */
-
- if (loginsize < 0)
- loginsize = GETLOGIN_R_SIZE_DEFAULT;
-
- VALUE maybe_result = rb_str_buf_new(loginsize);
-
- login = RSTRING_PTR(maybe_result);
- loginsize = rb_str_capacity(maybe_result);
- rb_str_set_len(maybe_result, loginsize);
-
- int gle;
- errno = 0;
- while ((gle = getlogin_r(login, loginsize)) != 0) {
-
- if (gle == ENOTTY || gle == ENXIO || gle == ENOENT) {
- rb_str_resize(maybe_result, 0);
- return Qnil;
- }
-
- if (gle != ERANGE || loginsize >= GETLOGIN_R_SIZE_LIMIT) {
- rb_str_resize(maybe_result, 0);
- rb_syserr_fail(gle, "getlogin_r");
- }
-
- rb_str_modify_expand(maybe_result, loginsize);
- login = RSTRING_PTR(maybe_result);
- loginsize = rb_str_capacity(maybe_result);
- }
-
- if (login == NULL) {
- rb_str_resize(maybe_result, 0);
- return Qnil;
- }
-
- return maybe_result;
-
-# elif USE_GETLOGIN
-
- errno = 0;
- login = getlogin();
- if (errno) {
- if (errno == ENOTTY || errno == ENXIO || errno == ENOENT) {
- return Qnil;
- }
- rb_syserr_fail(errno, "getlogin");
- }
-
- return login ? rb_str_new_cstr(login) : Qnil;
-# endif
-
-#endif
-}
-
-VALUE
-rb_getpwdirnam_for_login(VALUE login_name)
-{
-#if ( !defined(USE_GETPWNAM_R) && !defined(USE_GETPWNAM) )
- return Qnil;
-#else
-
- if (NIL_P(login_name)) {
- /* nothing to do; no name with which to query the password database */
- return Qnil;
- }
-
- char *login = RSTRING_PTR(login_name);
-
- struct passwd *pwptr;
-
-# ifdef USE_GETPWNAM_R
-
- struct passwd pwdnm;
- char *bufnm;
- long bufsizenm = GETPW_R_SIZE_INIT; /* maybe -1 */
-
- if (bufsizenm < 0)
- bufsizenm = GETPW_R_SIZE_DEFAULT;
-
- VALUE getpwnm_tmp = rb_str_tmp_new(bufsizenm);
-
- bufnm = RSTRING_PTR(getpwnm_tmp);
- bufsizenm = rb_str_capacity(getpwnm_tmp);
- rb_str_set_len(getpwnm_tmp, bufsizenm);
-
- int enm;
- errno = 0;
- while ((enm = getpwnam_r(login, &pwdnm, bufnm, bufsizenm, &pwptr)) != 0) {
-
- if (enm == ENOENT || enm== ESRCH || enm == EBADF || enm == EPERM) {
- /* not found; non-errors */
- rb_str_resize(getpwnm_tmp, 0);
- return Qnil;
- }
-
- if (enm != ERANGE || bufsizenm >= GETPW_R_SIZE_LIMIT) {
- rb_str_resize(getpwnm_tmp, 0);
- rb_syserr_fail(enm, "getpwnam_r");
- }
-
- rb_str_modify_expand(getpwnm_tmp, bufsizenm);
- bufnm = RSTRING_PTR(getpwnm_tmp);
- bufsizenm = rb_str_capacity(getpwnm_tmp);
- }
-
- if (pwptr == NULL) {
- /* no record in the password database for the login name */
- rb_str_resize(getpwnm_tmp, 0);
- return Qnil;
- }
-
- /* found it */
- VALUE result = rb_str_new_cstr(pwptr->pw_dir);
- rb_str_resize(getpwnm_tmp, 0);
- return result;
-
-# elif USE_GETPWNAM
-
- errno = 0;
- pwptr = getpwnam(login);
- if (pwptr) {
- /* found it */
- return rb_str_new_cstr(pwptr->pw_dir);
- }
- if (errno
- /* avoid treating as errors errno values that indicate "not found" */
- && ( errno != ENOENT && errno != ESRCH && errno != EBADF && errno != EPERM)) {
- rb_syserr_fail(errno, "getpwnam");
- }
-
- return Qnil; /* not found */
-# endif
-
-#endif
-}
-
-/**
- * Look up the user's dflt home dir in the password db, by uid.
- */
-VALUE
-rb_getpwdiruid(void)
-{
-# if !defined(USE_GETPWUID_R) && !defined(USE_GETPWUID)
- /* Should never happen... </famous-last-words> */
- return Qnil;
-# else
- uid_t ruid = getuid();
-
- struct passwd *pwptr;
-
-# ifdef USE_GETPWUID_R
-
- struct passwd pwdid;
- char *bufid;
- long bufsizeid = GETPW_R_SIZE_INIT; /* maybe -1 */
-
- if (bufsizeid < 0)
- bufsizeid = GETPW_R_SIZE_DEFAULT;
-
- VALUE getpwid_tmp = rb_str_tmp_new(bufsizeid);
-
- bufid = RSTRING_PTR(getpwid_tmp);
- bufsizeid = rb_str_capacity(getpwid_tmp);
- rb_str_set_len(getpwid_tmp, bufsizeid);
-
- int eid;
- errno = 0;
- while ((eid = getpwuid_r(ruid, &pwdid, bufid, bufsizeid, &pwptr)) != 0) {
-
- if (eid == ENOENT || eid== ESRCH || eid == EBADF || eid == EPERM) {
- /* not found; non-errors */
- rb_str_resize(getpwid_tmp, 0);
- return Qnil;
- }
-
- if (eid != ERANGE || bufsizeid >= GETPW_R_SIZE_LIMIT) {
- rb_str_resize(getpwid_tmp, 0);
- rb_syserr_fail(eid, "getpwuid_r");
- }
-
- rb_str_modify_expand(getpwid_tmp, bufsizeid);
- bufid = RSTRING_PTR(getpwid_tmp);
- bufsizeid = rb_str_capacity(getpwid_tmp);
- }
-
- if (pwptr == NULL) {
- /* no record in the password database for the uid */
- rb_str_resize(getpwid_tmp, 0);
- return Qnil;
- }
-
- /* found it */
- VALUE result = rb_str_new_cstr(pwptr->pw_dir);
- rb_str_resize(getpwid_tmp, 0);
- return result;
-
-# elif defined(USE_GETPWUID)
-
- errno = 0;
- pwptr = getpwuid(ruid);
- if (pwptr) {
- /* found it */
- return rb_str_new_cstr(pwptr->pw_dir);
- }
- if (errno
- /* avoid treating as errors errno values that indicate "not found" */
- && ( errno == ENOENT || errno == ESRCH || errno == EBADF || errno == EPERM)) {
- rb_syserr_fail(errno, "getpwuid");
- }
-
- return Qnil; /* not found */
-# endif
-
-#endif /* !defined(USE_GETPWUID_R) && !defined(USE_GETPWUID) */
-}
-#endif /* HAVE_PWD_H */
-
-
/*********************************************************************
* Document-class: Process::Sys
*
- * The Process::Sys module contains UID and GID
+ * The <code>Process::Sys</code> module contains UID and GID
* functions which provide direct bindings to the system calls of the
* same names instead of the more-portable versions of the same
- * functionality found in the Process,
- * Process::UID, and Process::GID modules.
+ * functionality found in the <code>Process</code>,
+ * <code>Process::UID</code>, and <code>Process::GID</code> modules.
*/
#if defined(HAVE_PWD_H)
@@ -6125,7 +5378,7 @@ proc_setuid(VALUE obj, VALUE id)
*
* Document-class: Process::UID
*
- * The Process::UID module contains a collection of
+ * The <code>Process::UID</code> module contains a collection of
* module functions which can be used to portably get, set, and
* switch the current process's real, effective, and saved user IDs.
*
@@ -6399,9 +5652,11 @@ static VALUE
p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
{
rb_gid_t rgid, egid;
+ PREPARE_GETGRNAM;
check_gid_switch();
rgid = OBJ2GID(rid);
egid = OBJ2GID(eid);
+ FINISH_GETGRNAM;
if (setregid(rgid, egid) != 0) rb_sys_fail(0);
return Qnil;
}
@@ -6425,10 +5680,12 @@ static VALUE
p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
{
rb_gid_t rgid, egid, sgid;
+ PREPARE_GETGRNAM;
check_gid_switch();
rgid = OBJ2GID(rid);
egid = OBJ2GID(eid);
sgid = OBJ2GID(sid);
+ FINISH_GETGRNAM;
if (setresgid(rgid, egid, sgid) != 0) rb_sys_fail(0);
return Qnil;
}
@@ -6576,24 +5833,11 @@ maxgroups(void)
* call-seq:
* Process.groups -> array
*
- * Get an Array of the group IDs in the
+ * Get an <code>Array</code> of the gids of groups in the
* supplemental group access list for this process.
*
* Process.groups #=> [27, 6, 10, 11]
*
- * Note that this method is just a wrapper of getgroups(2).
- * This means that the following characteristics of
- * the result completely depend on your system:
- *
- * - the result is sorted
- * - the result includes effective GIDs
- * - the result does not include duplicated GIDs
- *
- * You can make sure to get a sorted unique GID list of
- * the current process by this expression:
- *
- * Process.groups.uniq.sort
- *
*/
static VALUE
@@ -6632,7 +5876,7 @@ proc_getgroups(VALUE obj)
* Process.groups= array -> array
*
* Set the supplemental group access list to the given
- * Array of group IDs.
+ * <code>Array</code> of group IDs.
*
* Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
* Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11]
@@ -6683,7 +5927,7 @@ proc_setgroups(VALUE obj, VALUE ary)
* Initializes the supplemental group access list by reading the
* system group database and using all groups of which the given user
* is a member. The group with the specified <em>gid</em> is also
- * added to the list. Returns the resulting Array of the
+ * added to the list. Returns the resulting <code>Array</code> of the
* gids of all the groups in the supplementary group access list. Not
* available on all platforms.
*
@@ -6741,7 +5985,7 @@ proc_setmaxgroups(VALUE obj, VALUE val)
int ngroups_max = get_sc_ngroups_max();
if (ngroups <= 0)
- rb_raise(rb_eArgError, "maxgroups %d should be positive", ngroups);
+ rb_raise(rb_eArgError, "maxgroups %d shold be positive", ngroups);
if (ngroups > RB_MAX_GROUPS)
ngroups = RB_MAX_GROUPS;
@@ -6775,13 +6019,13 @@ static int rb_daemon(int nochdir, int noclose);
*/
static VALUE
-proc_daemon(int argc, VALUE *argv, VALUE _)
+proc_daemon(int argc, VALUE *argv)
{
int n, nochdir = FALSE, noclose = FALSE;
switch (rb_check_arity(argc, 0, 2)) {
- case 2: noclose = TO_BOOL(argv[1], "noclose");
- case 1: nochdir = TO_BOOL(argv[0], "nochdir");
+ case 2: noclose = RTEST(argv[1]);
+ case 1: nochdir = RTEST(argv[0]);
}
prefork();
@@ -6795,11 +6039,10 @@ rb_daemon(int nochdir, int noclose)
{
int err = 0;
#ifdef HAVE_DAEMON
- if (mjit_enabled) mjit_pause(false); // Don't leave locked mutex to child.
before_fork_ruby();
err = daemon(nochdir, noclose);
after_fork_ruby();
- rb_thread_atfork(); /* calls mjit_resume() */
+ rb_thread_atfork();
#else
int n;
@@ -6839,7 +6082,7 @@ rb_daemon(int nochdir, int noclose)
*
* Document-class: Process::GID
*
- * The Process::GID module contains a collection of
+ * The <code>Process::GID</code> module contains a collection of
* module functions which can be used to portably get, set, and
* switch the current process's real, effective, and saved group IDs.
*
@@ -7294,7 +6537,7 @@ p_gid_grant_privilege(VALUE obj, VALUE id)
*/
static VALUE
-p_uid_exchangeable(VALUE _)
+p_uid_exchangeable(void)
{
#if defined(HAVE_SETRESUID)
return Qtrue;
@@ -7356,7 +6599,7 @@ p_uid_exchange(VALUE obj)
*/
static VALUE
-p_gid_exchangeable(VALUE _)
+p_gid_exchangeable(void)
{
#if defined(HAVE_SETRESGID)
return Qtrue;
@@ -7419,7 +6662,7 @@ p_gid_exchange(VALUE obj)
*/
static VALUE
-p_uid_have_saved_id(VALUE _)
+p_uid_have_saved_id(void)
{
#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS)
return Qtrue;
@@ -7431,9 +6674,8 @@ p_uid_have_saved_id(VALUE _)
#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS)
static VALUE
-p_uid_sw_ensure(VALUE i)
+p_uid_sw_ensure(rb_uid_t id)
{
- rb_uid_t id = (rb_uid_t/* narrowing */)i;
under_uid_switch = 0;
id = rb_seteuid_core(id);
return UIDT2NUM(id);
@@ -7487,7 +6729,7 @@ p_uid_switch(VALUE obj)
rb_syserr_fail(EPERM, 0);
}
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
#else
static VALUE
@@ -7534,7 +6776,7 @@ p_uid_switch(VALUE obj)
*/
static VALUE
-p_gid_have_saved_id(VALUE _)
+p_gid_have_saved_id(void)
{
#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS)
return Qtrue;
@@ -7545,9 +6787,8 @@ p_gid_have_saved_id(VALUE _)
#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS)
static VALUE
-p_gid_sw_ensure(VALUE i)
+p_gid_sw_ensure(rb_gid_t id)
{
- rb_gid_t id = (rb_gid_t/* narrowing */)i;
under_gid_switch = 0;
id = rb_setegid_core(id);
return GIDT2NUM(id);
@@ -7601,7 +6842,7 @@ p_gid_switch(VALUE obj)
rb_syserr_fail(EPERM, 0);
}
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
#else
static VALUE
@@ -7640,22 +6881,27 @@ p_gid_switch(VALUE obj)
static long
get_clk_tck(void)
{
+ long hertz =
#ifdef HAVE__SC_CLK_TCK
- return sysconf(_SC_CLK_TCK);
-#elif defined CLK_TCK
- return CLK_TCK;
-#elif defined HZ
- return HZ;
+ (double)sysconf(_SC_CLK_TCK);
#else
- return 60;
+#ifndef HZ
+# ifdef CLK_TCK
+# define HZ CLK_TCK
+# else
+# define HZ 60
+# endif
+#endif /* HZ */
+ HZ;
#endif
+ return hertz;
}
/*
* call-seq:
* Process.times -> aProcessTms
*
- * Returns a <code>Tms</code> structure (see Process::Tms)
+ * Returns a <code>Tms</code> structure (see <code>Process::Tms</code>)
* that contains user and system CPU times for this process,
* and also for children processes.
*
@@ -7677,7 +6923,7 @@ rb_proc_times(VALUE obj)
cutime = DBL2NUM((double)usage_c.ru_utime.tv_sec + (double)usage_c.ru_utime.tv_usec/1e6);
cstime = DBL2NUM((double)usage_c.ru_stime.tv_sec + (double)usage_c.ru_stime.tv_usec/1e6);
#else
- const double hertz = (double)get_clk_tck();
+ const double hertz = get_clk_tck();
struct tms buf;
times(&buf);
@@ -7887,7 +7133,7 @@ make_clock_result(struct timetick *ttp,
}
#ifdef __APPLE__
-static const mach_timebase_info_data_t *
+static mach_timebase_info_data_t *
get_mach_timebase_info(void)
{
static mach_timebase_info_data_t sTimebaseInfo;
@@ -7898,14 +7144,6 @@ get_mach_timebase_info(void)
return &sTimebaseInfo;
}
-
-double
-ruby_real_ms_time(void)
-{
- const mach_timebase_info_data_t *info = get_mach_timebase_info();
- uint64_t t = mach_absolute_time();
- return (double)t * info->numer / info->denom / 1e6;
-}
#endif
/*
@@ -7926,7 +7164,7 @@ ruby_real_ms_time(void)
*
* [CLOCK_REALTIME] SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12
* [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12
- * [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12
+ * [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, OpenBSD 5.4, macOS 10.12
* [CLOCK_THREAD_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12
* [CLOCK_VIRTUAL] FreeBSD 3.0, OpenBSD 2.1
* [CLOCK_PROF] FreeBSD 3.0, OpenBSD 2.1
@@ -7947,7 +7185,6 @@ ruby_real_ms_time(void)
* [CLOCK_UPTIME_RAW_APPROX] macOS 10.12
* [CLOCK_UPTIME_PRECISE] FreeBSD 8.1
* [CLOCK_SECOND] FreeBSD 8.1
- * [CLOCK_TAI] Linux 3.10
*
* Note that SUS stands for Single Unix Specification.
* SUS contains POSIX and clock_gettime is defined in the POSIX part.
@@ -8035,8 +7272,8 @@ ruby_real_ms_time(void)
* So the result can be interpreted differently across systems.
* Time.now is recommended over CLOCK_REALTIME.
*/
-static VALUE
-rb_clock_gettime(int argc, VALUE *argv, VALUE _)
+VALUE
+rb_clock_gettime(int argc, VALUE *argv)
{
int ret;
@@ -8052,9 +7289,8 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
if (SYMBOL_P(clk_id)) {
/*
* Non-clock_gettime clocks are provided by symbol clk_id.
- */
-#ifdef HAVE_GETTIMEOFDAY
- /*
+ *
+ * gettimeofday is always available on platforms supported by Ruby.
* GETTIMEOFDAY_BASED_CLOCK_REALTIME is used for
* CLOCK_REALTIME if clock_gettime is not available.
*/
@@ -8069,7 +7305,6 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
denominators[num_denominators++] = 1000000000;
goto success;
}
-#endif
#define RUBY_TIME_BASED_CLOCK_REALTIME ID2SYM(id_TIME_BASED_CLOCK_REALTIME)
if (clk_id == RUBY_TIME_BASED_CLOCK_REALTIME) {
@@ -8162,7 +7397,7 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
#ifdef __APPLE__
#define RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ID2SYM(id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC)
if (clk_id == RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) {
- const mach_timebase_info_data_t *info = get_mach_timebase_info();
+ mach_timebase_info_data_t *info = get_mach_timebase_info();
uint64_t t = mach_absolute_time();
tt.count = (int32_t)(t % 1000000000);
tt.giga_count = t / 1000000000;
@@ -8205,7 +7440,7 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
*
* +clock_id+ can be a symbol as +Process.clock_gettime+.
* However the result may not be accurate.
- * For example, <code>Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME)</code>
+ * For example, +Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME)+
* returns 1.0e-06 which means 1 microsecond, but actual resolution can be more coarse.
*
* If the given +clock_id+ is not supported, Errno::EINVAL is raised.
@@ -8222,18 +7457,18 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
* the clock ticks per second for times() function and
* CLOCKS_PER_SEC for clock() function.
*
- * <code>Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)</code>
+ * +Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)+
* returns the clock ticks per second.
*
- * <code>Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)</code>
+ * +Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)+
* returns CLOCKS_PER_SEC.
*
* p Process.clock_getres(Process::CLOCK_MONOTONIC)
* #=> 1.0e-09
*
*/
-static VALUE
-rb_clock_getres(int argc, VALUE *argv, VALUE _)
+VALUE
+rb_clock_getres(int argc, VALUE *argv)
{
struct timetick tt;
timetick_int_t numerators[2];
@@ -8301,7 +7536,7 @@ rb_clock_getres(int argc, VALUE *argv, VALUE _)
#ifdef RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC
if (clk_id == RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) {
- const mach_timebase_info_data_t *info = get_mach_timebase_info();
+ mach_timebase_info_data_t *info = get_mach_timebase_info();
tt.count = 1;
tt.giga_count = 0;
numerators[num_numerators++] = info->numer;
@@ -8336,68 +7571,14 @@ rb_clock_getres(int argc, VALUE *argv, VALUE _)
}
}
-static VALUE
-get_CHILD_STATUS(ID _x, VALUE *_y)
-{
- return rb_last_status_get();
-}
-
-static VALUE
-get_PROCESS_ID(ID _x, VALUE *_y)
-{
- return get_pid();
-}
-
-/*
- * call-seq:
- * Process.kill(signal, pid, ...) -> integer
- *
- * Sends the given signal to the specified process id(s) if _pid_ is positive.
- * If _pid_ is zero, _signal_ is sent to all processes whose group ID is equal
- * to the group ID of the process. If _pid_ is negative, results are dependent
- * on the operating system. _signal_ may be an integer signal number or
- * a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is
- * negative (or starts with a minus sign), kills process groups instead of
- * processes. Not all signals are available on all platforms.
- * The keys and values of Signal.list are known signal names and numbers,
- * respectively.
- *
- * pid = fork do
- * Signal.trap("HUP") { puts "Ouch!"; exit }
- * # ... do some work ...
- * end
- * # ...
- * Process.kill("HUP", pid)
- * Process.wait
- *
- * <em>produces:</em>
- *
- * Ouch!
- *
- * If _signal_ is an integer but wrong for signal, Errno::EINVAL or
- * RangeError will be raised. Otherwise unless _signal_ is a String
- * or a Symbol, and a known signal name, ArgumentError will be
- * raised.
- *
- * Also, Errno::ESRCH or RangeError for invalid _pid_, Errno::EPERM
- * when failed because of no privilege, will be raised. In these
- * cases, signals may have been sent to preceding processes.
- */
-
-static VALUE
-proc_rb_f_kill(int c, const VALUE *v, VALUE _)
-{
- return rb_f_kill(c, v);
-}
-
VALUE rb_mProcess;
-static VALUE rb_mProcUID;
-static VALUE rb_mProcGID;
-static VALUE rb_mProcID_Syscall;
+VALUE rb_mProcUID;
+VALUE rb_mProcGID;
+VALUE rb_mProcID_Syscall;
/*
- * The Process module is a collection of methods used to
+ * The <code>Process</code> module is a collection of methods used to
* manipulate processes.
*/
@@ -8406,16 +7587,16 @@ InitVM_process(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
- rb_define_virtual_variable("$?", get_CHILD_STATUS, 0);
- rb_define_virtual_variable("$$", get_PROCESS_ID, 0);
- rb_define_global_function("exec", f_exec, -1);
+ rb_define_virtual_variable("$?", rb_last_status_get, 0);
+ rb_define_virtual_variable("$$", get_pid, 0);
+ rb_define_global_function("exec", rb_f_exec, -1);
rb_define_global_function("fork", rb_f_fork, 0);
rb_define_global_function("exit!", rb_f_exit_bang, -1);
rb_define_global_function("system", rb_f_system, -1);
rb_define_global_function("spawn", rb_f_spawn, -1);
rb_define_global_function("sleep", rb_f_sleep, -1);
- rb_define_global_function("exit", f_exit, -1);
- rb_define_global_function("abort", f_abort, -1);
+ rb_define_global_function("exit", rb_f_exit, -1);
+ rb_define_global_function("abort", rb_f_abort, -1);
rb_mProcess = rb_define_module("Process");
@@ -8434,23 +7615,22 @@ InitVM_process(void)
rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(0));
#endif
- rb_define_singleton_method(rb_mProcess, "exec", f_exec, -1);
+ rb_define_singleton_method(rb_mProcess, "exec", rb_f_exec, -1);
rb_define_singleton_method(rb_mProcess, "fork", rb_f_fork, 0);
rb_define_singleton_method(rb_mProcess, "spawn", rb_f_spawn, -1);
rb_define_singleton_method(rb_mProcess, "exit!", rb_f_exit_bang, -1);
- rb_define_singleton_method(rb_mProcess, "exit", f_exit, -1);
- rb_define_singleton_method(rb_mProcess, "abort", f_abort, -1);
+ rb_define_singleton_method(rb_mProcess, "exit", rb_f_exit, -1);
+ rb_define_singleton_method(rb_mProcess, "abort", rb_f_abort, -1);
rb_define_singleton_method(rb_mProcess, "last_status", proc_s_last_status, 0);
- rb_define_module_function(rb_mProcess, "kill", proc_rb_f_kill, -1);
- rb_define_module_function(rb_mProcess, "wait", proc_m_wait, -1);
+ rb_define_module_function(rb_mProcess, "kill", rb_f_kill, -1); /* in signal.c */
+ rb_define_module_function(rb_mProcess, "wait", proc_wait, -1);
rb_define_module_function(rb_mProcess, "wait2", proc_wait2, -1);
- rb_define_module_function(rb_mProcess, "waitpid", proc_m_wait, -1);
+ rb_define_module_function(rb_mProcess, "waitpid", proc_wait, -1);
rb_define_module_function(rb_mProcess, "waitpid2", proc_wait2, -1);
rb_define_module_function(rb_mProcess, "waitall", proc_waitall, 0);
rb_define_module_function(rb_mProcess, "detach", proc_detach, 1);
- /* :nodoc: */
rb_cWaiter = rb_define_class_under(rb_mProcess, "Waiter", rb_cThread);
rb_undef_alloc_func(rb_cWaiter);
rb_undef_method(CLASS_OF(rb_cWaiter), "new");
@@ -8477,8 +7657,8 @@ InitVM_process(void)
rb_define_method(rb_cProcessStatus, "success?", pst_success_p, 0);
rb_define_method(rb_cProcessStatus, "coredump?", pst_wcoredump, 0);
- rb_define_module_function(rb_mProcess, "pid", proc_get_pid, 0);
- rb_define_module_function(rb_mProcess, "ppid", proc_get_ppid, 0);
+ rb_define_module_function(rb_mProcess, "pid", get_pid, 0);
+ rb_define_module_function(rb_mProcess, "ppid", get_ppid, 0);
rb_define_module_function(rb_mProcess, "getpgrp", proc_getpgrp, 0);
rb_define_module_function(rb_mProcess, "setpgrp", proc_setpgrp, 0);
@@ -8758,19 +7938,12 @@ InitVM_process(void)
/* see Process.clock_gettime */
rb_define_const(rb_mProcess, "CLOCK_SECOND", CLOCKID2NUM(CLOCK_SECOND));
#endif
-#ifdef CLOCK_TAI
- /* see Process.clock_gettime */
- rb_define_const(rb_mProcess, "CLOCK_TAI", CLOCKID2NUM(CLOCK_TAI));
-#endif
rb_define_module_function(rb_mProcess, "clock_gettime", rb_clock_gettime, -1);
rb_define_module_function(rb_mProcess, "clock_getres", rb_clock_getres, -1);
#if defined(HAVE_TIMES) || defined(_WIN32)
- /* Placeholder for rusage */
rb_cProcessTms = rb_struct_define_under(rb_mProcess, "Tms", "utime", "stime", "cutime", "cstime", NULL);
- /* An obsolete name of Process::Tms for backward compatibility */
- rb_define_const(rb_cStruct, "Tms", rb_cProcessTms);
- rb_deprecate_constant(rb_cStruct, "Tms");
+ rb_define_const(rb_cStruct, "Tms", rb_cProcessTms); /* for the backward compatibility */
#endif
SAVED_USER_ID = geteuid();
diff --git a/random.c b/random.c
index f2e57909a3..4fbbebfc14 100644
--- a/random.c
+++ b/random.c
@@ -9,9 +9,55 @@
**********************************************************************/
-#if defined __APPLE__
-# include <AvailabilityMacros.h>
-#endif
+/*
+This is based on trimmed version of MT19937. To get the original version,
+contact <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html>.
+
+The original copyright notice follows.
+
+ A C-program for MT19937, with initialization improved 2002/2/10.
+ Coded by Takuji Nishimura and Makoto Matsumoto.
+ This is a faster version by taking Shawn Cokus's optimization,
+ Matthe Bellew's simplification, Isaku Wada's real version.
+
+ Before using, initialize the state by using init_genrand(mt, seed)
+ or init_by_array(mt, init_key, key_length).
+
+ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+ Any feedback is very welcome.
+ http://www.math.keio.ac.jp/matumoto/emt.html
+ email: matumoto@math.keio.ac.jp
+*/
#include "internal.h"
@@ -43,14 +89,113 @@
#endif
#include "ruby_atomic.h"
-#ifdef __OpenBSD__
-/* to define OpenBSD for version check */
-#include <sys/param.h>
-#endif
-
typedef int int_must_be_32bit_at_least[sizeof(int) * CHAR_BIT < 32 ? -1 : 1];
-#include "missing/mt19937.c"
+/* Period parameters */
+#define N 624
+#define M 397
+#define MATRIX_A 0x9908b0dfU /* constant vector a */
+#define UMASK 0x80000000U /* most significant w-r bits */
+#define LMASK 0x7fffffffU /* least significant r bits */
+#define MIXBITS(u,v) ( ((u) & UMASK) | ((v) & LMASK) )
+#define TWIST(u,v) ((MIXBITS((u),(v)) >> 1) ^ ((v)&1U ? MATRIX_A : 0U))
+
+enum {MT_MAX_STATE = N};
+
+struct MT {
+ /* assume int is enough to store 32bits */
+ uint32_t state[N]; /* the array for the state vector */
+ uint32_t *next;
+ int left;
+};
+
+#define genrand_initialized(mt) ((mt)->next != 0)
+#define uninit_genrand(mt) ((mt)->next = 0)
+
+/* initializes state[N] with a seed */
+static void
+init_genrand(struct MT *mt, unsigned int s)
+{
+ int j;
+ mt->state[0] = s & 0xffffffffU;
+ for (j=1; j<N; j++) {
+ mt->state[j] = (1812433253U * (mt->state[j-1] ^ (mt->state[j-1] >> 30)) + j);
+ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+ /* In the previous versions, MSBs of the seed affect */
+ /* only MSBs of the array state[]. */
+ /* 2002/01/09 modified by Makoto Matsumoto */
+ mt->state[j] &= 0xffffffff; /* for >32 bit machines */
+ }
+ mt->left = 1;
+ mt->next = mt->state + N;
+}
+
+/* initialize by an array with array-length */
+/* init_key is the array for initializing keys */
+/* key_length is its length */
+/* slight change for C++, 2004/2/26 */
+static void
+init_by_array(struct MT *mt, const uint32_t init_key[], int key_length)
+{
+ int i, j, k;
+ init_genrand(mt, 19650218U);
+ i=1; j=0;
+ k = (N>key_length ? N : key_length);
+ for (; k; k--) {
+ mt->state[i] = (mt->state[i] ^ ((mt->state[i-1] ^ (mt->state[i-1] >> 30)) * 1664525U))
+ + init_key[j] + j; /* non linear */
+ mt->state[i] &= 0xffffffffU; /* for WORDSIZE > 32 machines */
+ i++; j++;
+ if (i>=N) { mt->state[0] = mt->state[N-1]; i=1; }
+ if (j>=key_length) j=0;
+ }
+ for (k=N-1; k; k--) {
+ mt->state[i] = (mt->state[i] ^ ((mt->state[i-1] ^ (mt->state[i-1] >> 30)) * 1566083941U))
+ - i; /* non linear */
+ mt->state[i] &= 0xffffffffU; /* for WORDSIZE > 32 machines */
+ i++;
+ if (i>=N) { mt->state[0] = mt->state[N-1]; i=1; }
+ }
+
+ mt->state[0] = 0x80000000U; /* MSB is 1; assuring non-zero initial array */
+}
+
+static void
+next_state(struct MT *mt)
+{
+ uint32_t *p = mt->state;
+ int j;
+
+ mt->left = N;
+ mt->next = mt->state;
+
+ for (j=N-M+1; --j; p++)
+ *p = p[M] ^ TWIST(p[0], p[1]);
+
+ for (j=M; --j; p++)
+ *p = p[M-N] ^ TWIST(p[0], p[1]);
+
+ *p = p[M-N] ^ TWIST(p[0], mt->state[0]);
+}
+
+/* generates a random number on [0,0xffffffff]-interval */
+static unsigned int
+genrand_int32(struct MT *mt)
+{
+ /* mt must be initialized */
+ unsigned int y;
+
+ if (--mt->left <= 0) next_state(mt);
+ y = *mt->next++;
+
+ /* Tempering */
+ y ^= (y >> 11);
+ y ^= (y << 7) & 0x9d2c5680;
+ y ^= (y << 15) & 0xefc60000;
+ y ^= (y >> 18);
+
+ return y;
+}
/* generates a random number on [0,1) with 53-bit resolution*/
static double int_pair_to_real_exclusive(uint32_t a, uint32_t b);
@@ -97,14 +242,14 @@ typedef struct {
static rb_random_t default_rand;
static VALUE rand_init(struct MT *mt, VALUE vseed);
-static VALUE random_seed(VALUE);
+static VALUE random_seed(void);
static rb_random_t *
rand_start(rb_random_t *r)
{
struct MT *mt = &r->mt;
if (!genrand_initialized(mt)) {
- r->seed = rand_init(mt, random_seed(Qundef));
+ r->seed = rand_init(mt, random_seed());
}
return r;
}
@@ -157,7 +302,6 @@ VALUE rb_cRandom;
#define id_minus '-'
#define id_plus '+'
static ID id_rand, id_bytes;
-NORETURN(static void domain_error(void));
/* :nodoc: */
static void
@@ -179,8 +323,8 @@ random_memsize(const void *ptr)
return sizeof(rb_random_t);
}
-static const rb_data_type_t random_mt_type = {
- "random/MT",
+static const rb_data_type_t random_data_type = {
+ "random",
{
random_mark,
random_free,
@@ -193,7 +337,7 @@ static rb_random_t *
get_rnd(VALUE obj)
{
rb_random_t *ptr;
- TypedData_Get_Struct(obj, rb_random_t, &random_mt_type, ptr);
+ TypedData_Get_Struct(obj, rb_random_t, &random_data_type, ptr);
return rand_start(ptr);
}
@@ -203,7 +347,7 @@ try_get_rnd(VALUE obj)
if (obj == rb_cRandom) {
return rand_start(&default_rand);
}
- if (!rb_typeddata_is_kind_of(obj, &random_mt_type)) return NULL;
+ if (!rb_typeddata_is_kind_of(obj, &random_data_type)) return NULL;
return rand_start(DATA_PTR(obj));
}
@@ -212,7 +356,7 @@ static VALUE
random_alloc(VALUE klass)
{
rb_random_t *rnd;
- VALUE obj = TypedData_Make_Struct(klass, rb_random_t, &random_mt_type, rnd);
+ VALUE obj = TypedData_Make_Struct(klass, rb_random_t, &random_data_type, rnd);
rnd->seed = INT2FIX(0);
return obj;
}
@@ -265,7 +409,7 @@ random_init(int argc, VALUE *argv, VALUE obj)
if (rb_check_arity(argc, 0, 1) == 0) {
rb_check_frozen(obj);
- vseed = random_seed(obj);
+ vseed = random_seed();
}
else {
vseed = argv[0];
@@ -315,7 +459,7 @@ fill_random_bytes_urandom(void *seed, size_t size)
return -1;
}
offset += (size_t)ret;
- } while (offset < size);
+ } while(offset < size);
}
close(fd);
return 0;
@@ -324,52 +468,13 @@ fill_random_bytes_urandom(void *seed, size_t size)
# define fill_random_bytes_urandom(seed, size) -1
#endif
-#if defined HAVE_GETRANDOM
-# include <sys/random.h>
-#elif defined __linux__ && defined __NR_getrandom
-# include <linux/random.h>
-
-# ifndef GRND_NONBLOCK
-# define GRND_NONBLOCK 0x0001 /* not defined in musl libc */
-# endif
-# define getrandom(ptr, size, flags) \
- (ssize_t)syscall(__NR_getrandom, (ptr), (size), (flags))
-# define HAVE_GETRANDOM 1
-#endif
-
#if 0
-#elif defined MAC_OS_X_VERSION_10_7 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
-#include <Security/Security.h>
-
-static int
-fill_random_bytes_syscall(void *seed, size_t size, int unused)
-{
- int status = SecRandomCopyBytes(kSecRandomDefault, size, seed);
-
- if (status != errSecSuccess) {
-# if 0
- CFStringRef s = SecCopyErrorMessageString(status, NULL);
- const char *m = s ? CFStringGetCStringPtr(s, kCFStringEncodingUTF8) : NULL;
- fprintf(stderr, "SecRandomCopyBytes failed: %d: %s\n", status,
- m ? m : "unknown");
- if (s) CFRelease(s);
-# endif
- return -1;
- }
- return 0;
-}
#elif defined(HAVE_ARC4RANDOM_BUF)
static int
fill_random_bytes_syscall(void *buf, size_t size, int unused)
{
-#if (defined(__OpenBSD__) && OpenBSD >= 201411) || \
- (defined(__NetBSD__) && __NetBSD_Version__ >= 700000000) || \
- (defined(__FreeBSD__) && __FreeBSD_version >= 1200079)
arc4random_buf(buf, size);
return 0;
-#else
- return -1;
-#endif
}
#elif defined(_WIN32)
static void
@@ -391,12 +496,12 @@ fill_random_bytes_syscall(void *seed, size_t size, int unused)
prov = (HCRYPTPROV)INVALID_HANDLE_VALUE;
}
old_prov = (HCRYPTPROV)ATOMIC_PTR_CAS(perm_prov, 0, prov);
- if (LIKELY(!old_prov)) { /* no other threads acquired */
+ if (LIKELY(!old_prov)) { /* no other threads acquried */
if (prov != (HCRYPTPROV)INVALID_HANDLE_VALUE) {
rb_gc_register_mark_object(Data_Wrap_Struct(0, 0, release_crypt, &perm_prov));
}
}
- else { /* another thread acquired */
+ else { /* another thread acquried */
if (prov != (HCRYPTPROV)INVALID_HANDLE_VALUE) {
CryptReleaseContext(prov, 0);
}
@@ -407,25 +512,32 @@ fill_random_bytes_syscall(void *seed, size_t size, int unused)
CryptGenRandom(prov, size, seed);
return 0;
}
-#elif defined HAVE_GETRANDOM
+#elif defined __linux__ && defined __NR_getrandom
+#include <linux/random.h>
+
+# ifndef GRND_NONBLOCK
+# define GRND_NONBLOCK 0x0001 /* not defined in musl libc */
+# endif
+
static int
fill_random_bytes_syscall(void *seed, size_t size, int need_secure)
{
static rb_atomic_t try_syscall = 1;
if (try_syscall) {
+ long ret;
size_t offset = 0;
int flags = 0;
if (!need_secure)
flags = GRND_NONBLOCK;
do {
errno = 0;
- ssize_t ret = getrandom(((char*)seed) + offset, size - offset, flags);
+ ret = syscall(__NR_getrandom, ((char*)seed) + offset, size - offset, flags);
if (ret == -1) {
ATOMIC_SET(try_syscall, 0);
return -1;
}
offset += (size_t)ret;
- } while (offset < size);
+ } while(offset < size);
return 0;
}
return -1;
@@ -434,38 +546,27 @@ fill_random_bytes_syscall(void *seed, size_t size, int need_secure)
# define fill_random_bytes_syscall(seed, size, need_secure) -1
#endif
-int
-ruby_fill_random_bytes(void *seed, size_t size, int need_secure)
+static int
+fill_random_bytes(void *seed, size_t size, int need_secure)
{
int ret = fill_random_bytes_syscall(seed, size, need_secure);
if (ret == 0) return ret;
return fill_random_bytes_urandom(seed, size);
}
-#define fill_random_bytes ruby_fill_random_bytes
-
static void
fill_random_seed(uint32_t *seed, size_t cnt)
{
static int n = 0;
-#if defined HAVE_CLOCK_GETTIME
- struct timespec tv;
-#elif defined HAVE_GETTIMEOFDAY
struct timeval tv;
-#endif
size_t len = cnt * sizeof(*seed);
memset(seed, 0, len);
- fill_random_bytes(seed, len, FALSE);
+ fill_random_bytes(seed, len, TRUE);
-#if defined HAVE_CLOCK_GETTIME
- clock_gettime(CLOCK_REALTIME, &tv);
- seed[0] ^= tv.tv_nsec;
-#elif defined HAVE_GETTIMEOFDAY
gettimeofday(&tv, 0);
seed[0] ^= tv.tv_usec;
-#endif
seed[1] ^= (uint32_t)tv.tv_sec;
#if SIZEOF_TIME_T > SIZEOF_INT
seed[0] ^= (uint32_t)((time_t)tv.tv_sec >> SIZEOF_INT * CHAR_BIT);
@@ -502,7 +603,7 @@ make_seed_value(uint32_t *ptr, size_t len)
* Random.new_seed #=> 115032730400174366788466674494640623225
*/
static VALUE
-random_seed(VALUE _)
+random_seed(void)
{
VALUE v;
uint32_t buf[DEFAULT_SEED_CNT+1];
@@ -534,7 +635,7 @@ random_raw_seed(VALUE self, VALUE size)
long n = NUM2ULONG(size);
VALUE buf = rb_str_new(0, n);
if (n == 0) return buf;
- if (fill_random_bytes(RSTRING_PTR(buf), n, TRUE))
+ if (fill_random_bytes(RSTRING_PTR(buf), n, FALSE))
rb_raise(rb_eRuntimeError, "failed to get urandom");
return buf;
}
@@ -636,17 +737,19 @@ random_load(VALUE obj, VALUE dump)
rb_random_t *rnd = get_rnd(obj);
struct MT *mt = &rnd->mt;
VALUE state, left = INT2FIX(1), seed = INT2FIX(0);
+ const VALUE *ary;
unsigned long x;
rb_check_copyable(obj, dump);
Check_Type(dump, T_ARRAY);
+ ary = RARRAY_CONST_PTR(dump);
switch (RARRAY_LEN(dump)) {
case 3:
- seed = RARRAY_AREF(dump, 2);
+ seed = ary[2];
case 2:
- left = RARRAY_AREF(dump, 1);
+ left = ary[1];
case 1:
- state = RARRAY_AREF(dump, 0);
+ state = ary[0];
break;
default:
rb_raise(rb_eArgError, "wrong dump data");
@@ -695,7 +798,7 @@ rb_f_srand(int argc, VALUE *argv, VALUE obj)
rb_random_t *r = &default_rand;
if (rb_check_arity(argc, 0, 1) == 0) {
- seed = random_seed(obj);
+ seed = random_seed();
}
else {
seed = rb_to_int(argv[0]);
@@ -981,7 +1084,7 @@ random_ulong_limited_big(VALUE obj, rb_random_t *rnd, VALUE vmax)
static VALUE genrand_bytes(rb_random_t *rnd, long n);
/*
- * call-seq: prng.bytes(size) -> string
+ * call-seq: prng.bytes(size) -> a_string
*
* Returns a random binary string containing +size+ bytes.
*
@@ -1031,30 +1134,17 @@ rb_random_bytes(VALUE obj, long n)
return genrand_bytes(rnd, n);
}
-/*
- * call-seq: Random.bytes(size) -> string
- *
- * Returns a random binary string.
- * The argument +size+ specifies the length of the returned string.
- */
-static VALUE
-random_s_bytes(VALUE obj, VALUE len)
-{
- rb_random_t *rnd = rand_start(&default_rand);
- return genrand_bytes(rnd, NUM2LONG(rb_to_int(len)));
-}
-
static VALUE
range_values(VALUE vmax, VALUE *begp, VALUE *endp, int *exclp)
{
- VALUE beg, end;
+ VALUE end, r;
- if (!rb_range_values(vmax, &beg, &end, exclp)) return Qfalse;
- if (begp) *begp = beg;
- if (NIL_P(beg)) return Qnil;
+ if (!rb_range_values(vmax, begp, &end, exclp)) return Qfalse;
if (endp) *endp = end;
- if (NIL_P(end)) return Qnil;
- return rb_check_funcall_default(end, id_minus, 1, begp, Qfalse);
+ if (!rb_respond_to(end, id_minus)) return Qfalse;
+ r = rb_funcallv(end, id_minus, 1, begp);
+ if (NIL_P(r)) return Qfalse;
+ return r;
}
static VALUE
@@ -1093,6 +1183,7 @@ rand_int(VALUE obj, rb_random_t *rnd, VALUE vmax, int restrictive)
}
}
+NORETURN(static void domain_error(void));
static void
domain_error(void)
{
@@ -1138,7 +1229,6 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
if ((v = vmax = range_values(range, &beg, &end, &excl)) == Qfalse)
return Qfalse;
- if (NIL_P(v)) domain_error();
if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_int(vmax), !NIL_P(v))) {
long max;
vmax = v;
@@ -1275,16 +1365,6 @@ rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd)
return rand_range(obj, rnd, vmax);
}
-/*
- * call-seq:
- * prng.random_number -> float
- * prng.random_number(max) -> number
- * prng.rand -> float
- * prng.rand(max) -> number
- *
- * Generates formatted random number from raw random bytes.
- * See Random#rand.
- */
static VALUE
rand_random_number(int argc, VALUE *argv, VALUE obj)
{
@@ -1433,7 +1513,6 @@ init_seed(struct MT *mt)
seed.u32[i] = genrand_int32(mt);
}
-NO_SANITIZE("unsigned-integer-overflow", extern st_index_t rb_hash_start(st_index_t h));
st_index_t
rb_hash_start(st_index_t h)
{
@@ -1486,11 +1565,11 @@ init_randomseed(struct MT *mt)
/* construct Random::DEFAULT bits */
static VALUE
-Init_Random_default(VALUE klass)
+Init_Random_default(void)
{
rb_random_t *r = &default_rand;
struct MT *mt = &r->mt;
- VALUE v = TypedData_Wrap_Struct(klass, &random_mt_type, r);
+ VALUE v = TypedData_Wrap_Struct(rb_cRandom, &random_data_type, r);
rb_gc_register_mark_object(v);
r->seed = init_randomseed(mt);
@@ -1551,25 +1630,20 @@ InitVM_Random(void)
{
/* Direct access to Ruby's Pseudorandom number generator (PRNG). */
- VALUE rand_default = Init_Random_default(rb_cRandom);
- /* The default Pseudorandom number generator. Used by class
- * methods of Random. */
+ VALUE rand_default = Init_Random_default();
rb_define_const(rb_cRandom, "DEFAULT", rand_default);
}
rb_define_singleton_method(rb_cRandom, "srand", rb_f_srand, -1);
rb_define_singleton_method(rb_cRandom, "rand", random_s_rand, -1);
- rb_define_singleton_method(rb_cRandom, "bytes", random_s_bytes, 1);
rb_define_singleton_method(rb_cRandom, "new_seed", random_seed, 0);
rb_define_singleton_method(rb_cRandom, "urandom", random_raw_seed, 1);
rb_define_private_method(CLASS_OF(rb_cRandom), "state", random_s_state, 0);
rb_define_private_method(CLASS_OF(rb_cRandom), "left", random_s_left, 0);
{
- /* Format raw random number as Random does */
VALUE m = rb_define_module_under(rb_cRandom, "Formatter");
rb_include_module(rb_cRandom, m);
- rb_extend_object(rb_cRandom, m);
rb_define_method(m, "random_number", rand_random_number, -1);
rb_define_method(m, "rand", rand_random_number, -1);
}
diff --git a/range.c b/range.c
index 2deb495712..4993a5e645 100644
--- a/range.c
+++ b/range.c
@@ -11,7 +11,6 @@
#include "internal.h"
#include "id.h"
-#include <assert.h>
#ifdef HAVE_FLOAT_H
#include <float.h>
@@ -19,14 +18,15 @@
#include <math.h>
VALUE rb_cRange;
-static ID id_beg, id_end, id_excl;
+static ID id_beg, id_end, id_excl, id_integer_p, id_div;
#define id_cmp idCmp
#define id_succ idSucc
-#define id_min idMin
-#define id_max idMax
static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
+#define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0])
+#define RANGE_END(r) (RSTRUCT(r)->as.ary[1])
+#define RANGE_EXCL(r) (RSTRUCT(r)->as.ary[2])
#define RANGE_SET_BEG(r, v) (RSTRUCT_SET(r, 0, v))
#define RANGE_SET_END(r, v) (RSTRUCT_SET(r, 1, v))
#define RANGE_SET_EXCL(r, v) (RSTRUCT_SET(r, 2, v))
@@ -37,7 +37,7 @@ static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
static void
range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end)
{
- if ((!FIXNUM_P(beg) || !FIXNUM_P(end)) && !NIL_P(beg) && !NIL_P(end)) {
+ if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
VALUE v;
v = rb_funcall(beg, id_cmp, 1, end);
@@ -74,7 +74,7 @@ range_modify(VALUE range)
* Range.new(begin, end, exclude_end=false) -> rng
*
* Constructs a range using the given +begin+ and +end+. If the +exclude_end+
- * parameter is omitted or is <code>false</code>, the range will include
+ * parameter is omitted or is <code>false</code>, the +rng+ will include
* the end object; otherwise, it will be excluded.
*/
@@ -236,7 +236,7 @@ range_hash(VALUE range)
}
static void
-range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg)
+range_each_func(VALUE range, rb_block_call_func *func, VALUE arg)
{
int c;
VALUE b = RANGE_BEG(range);
@@ -245,21 +245,21 @@ range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg)
if (EXCL(range)) {
while (r_less(v, e) < 0) {
- if ((*func)(v, arg)) break;
+ (*func) (v, arg, 0, 0, 0);
v = rb_funcallv(v, id_succ, 0, 0);
}
}
else {
while ((c = r_less(v, e)) <= 0) {
- if ((*func)(v, arg)) break;
+ (*func) (v, arg, 0, 0, 0);
if (!c) break;
v = rb_funcallv(v, id_succ, 0, 0);
}
}
}
-static int
-sym_step_i(VALUE i, VALUE arg)
+static VALUE
+sym_step_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
{
VALUE *iter = (VALUE *)arg;
@@ -273,11 +273,11 @@ sym_step_i(VALUE i, VALUE arg)
rb_yield(rb_str_intern(i));
iter[0] = iter[1];
}
- return 0;
+ return Qnil;
}
-static int
-step_i(VALUE i, VALUE arg)
+static VALUE
+step_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
{
VALUE *iter = (VALUE *)arg;
@@ -291,7 +291,7 @@ step_i(VALUE i, VALUE arg)
rb_yield(i);
iter[0] = iter[1];
}
- return 0;
+ return Qnil;
}
static int
@@ -350,22 +350,16 @@ range_step_size(VALUE range, VALUE args, VALUE eobj)
}
/*
- * Document-method: Range#step
- * Document-method: Range#%
* call-seq:
* rng.step(n=1) {| obj | block } -> rng
* rng.step(n=1) -> an_enumerator
- * rng.step(n=1) -> an_arithmetic_sequence
- * rng % n -> an_enumerator
- * rng % n -> an_arithmetic_sequence
*
* Iterates over the range, passing each <code>n</code>th element to the block.
* If begin and end are numeric, +n+ is added for each iteration.
- * Otherwise #step invokes #succ to iterate through range elements.
+ * Otherwise <code>step</code> invokes <code>succ</code> to iterate through
+ * range elements.
*
* If no block is given, an enumerator is returned instead.
- * Especially, the enumerator is an Enumerator::ArithmeticSequence
- * if begin and end of the range are numeric.
*
* range = Xs.new(1)..Xs.new(10)
* range.step(2) {|x| puts x}
@@ -394,35 +388,19 @@ range_step(int argc, VALUE *argv, VALUE range)
{
VALUE b, e, step, tmp;
+ RETURN_SIZED_ENUMERATOR(range, argc, argv, range_step_size);
+
b = RANGE_BEG(range);
e = RANGE_END(range);
- step = (!rb_check_arity(argc, 0, 1) ? INT2FIX(1) : argv[0]);
-
- if (!rb_block_given_p()) {
- const VALUE b_num_p = rb_obj_is_kind_of(b, rb_cNumeric);
- const VALUE e_num_p = rb_obj_is_kind_of(e, rb_cNumeric);
- if ((b_num_p && (NIL_P(e) || e_num_p)) || (NIL_P(b) && e_num_p)) {
- return rb_arith_seq_new(range, ID2SYM(rb_frame_this_func()), argc, argv,
- range_step_size, b, e, step, EXCL(range));
- }
-
- RETURN_SIZED_ENUMERATOR(range, argc, argv, range_step_size);
+ if (argc == 0) {
+ step = INT2FIX(1);
}
-
- step = check_step_domain(step);
-
- if (FIXNUM_P(b) && NIL_P(e) && FIXNUM_P(step)) {
- long i = FIX2LONG(b), unit = FIX2LONG(step);
- do {
- rb_yield(LONG2FIX(i));
- i += unit; /* FIXABLE+FIXABLE never overflow */
- } while (FIXABLE(i));
- b = LONG2NUM(i);
-
- for (;; b = rb_big_plus(b, step))
- rb_yield(b);
+ else {
+ rb_scan_args(argc, argv, "01", &step);
+ step = check_step_domain(step);
}
- else if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) { /* fixnums are special */
+
+ if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) { /* fixnums are special */
long end = FIX2LONG(e);
long i, unit = FIX2LONG(step);
@@ -436,20 +414,16 @@ range_step(int argc, VALUE *argv, VALUE range)
}
}
- else if (SYMBOL_P(b) && (NIL_P(e) || SYMBOL_P(e))) { /* symbols are special */
- VALUE iter[2];
+ else if (SYMBOL_P(b) && SYMBOL_P(e)) { /* symbols are special */
+ VALUE args[2], iter[2];
+
+ args[0] = rb_sym2str(e);
+ args[1] = EXCL(range) ? Qtrue : Qfalse;
iter[0] = INT2FIX(1);
iter[1] = step;
-
- b = rb_sym2str(b);
- if (NIL_P(e)) {
- rb_str_upto_endless_each(b, sym_step_i, (VALUE)iter);
- }
- else {
- rb_str_upto_each(b, rb_sym2str(e), EXCL(range), sym_step_i, (VALUE)iter);
- }
+ rb_block_call(rb_sym2str(b), rb_intern("upto"), 2, args, sym_step_i, (VALUE)iter);
}
- else if (ruby_float_step(b, e, step, EXCL(range), TRUE)) {
+ else if (ruby_float_step(b, e, step, EXCL(range))) {
/* done */
}
else if (rb_obj_is_kind_of(b, rb_cNumeric) ||
@@ -459,7 +433,7 @@ range_step(int argc, VALUE *argv, VALUE range)
VALUE v = b;
int i = 0;
- while (NIL_P(e) || RTEST(rb_funcall(v, op, 1, e))) {
+ while (RTEST(rb_funcall(v, op, 1, e))) {
rb_yield(v);
i++;
v = rb_funcall(b, '+', 1, rb_funcall(INT2NUM(i), '*', 1, step));
@@ -469,18 +443,14 @@ range_step(int argc, VALUE *argv, VALUE range)
tmp = rb_check_string_type(b);
if (!NIL_P(tmp)) {
- VALUE iter[2];
+ VALUE args[2], iter[2];
b = tmp;
+ args[0] = e;
+ args[1] = EXCL(range) ? Qtrue : Qfalse;
iter[0] = INT2FIX(1);
iter[1] = step;
-
- if (NIL_P(e)) {
- rb_str_upto_endless_each(b, step_i, (VALUE)iter);
- }
- else {
- rb_str_upto_each(b, e, EXCL(range), step_i, (VALUE)iter);
- }
+ rb_block_call(b, rb_intern("upto"), 2, args, step_i, (VALUE)iter);
}
else {
VALUE args[2];
@@ -497,12 +467,6 @@ range_step(int argc, VALUE *argv, VALUE range)
return range;
}
-static VALUE
-range_percent_step(VALUE range, VALUE step)
-{
- return range_step(1, &step, range);
-}
-
#if SIZEOF_DOUBLE == 8 && defined(HAVE_INT64_T)
union int64_double {
int64_t i;
@@ -535,72 +499,10 @@ double_as_int64(double d)
static int
is_integer_p(VALUE v)
{
- ID id_integer_p;
- VALUE is_int;
- CONST_ID(id_integer_p, "integer?");
- is_int = rb_check_funcall(v, id_integer_p, 0, 0);
+ VALUE is_int = rb_check_funcall(v, id_integer_p, 0, 0);
return RTEST(is_int) && is_int != Qundef;
}
-static VALUE
-bsearch_integer_range(VALUE beg, VALUE end, int excl)
-{
- VALUE satisfied = Qnil;
- int smaller;
-
-#define BSEARCH_CHECK(expr) \
- do { \
- VALUE val = (expr); \
- VALUE v = rb_yield(val); \
- if (FIXNUM_P(v)) { \
- if (v == INT2FIX(0)) return val; \
- smaller = (SIGNED_VALUE)v < 0; \
- } \
- else if (v == Qtrue) { \
- satisfied = val; \
- smaller = 1; \
- } \
- else if (v == Qfalse || v == Qnil) { \
- smaller = 0; \
- } \
- else if (rb_obj_is_kind_of(v, rb_cNumeric)) { \
- int cmp = rb_cmpint(rb_funcall(v, id_cmp, 1, INT2FIX(0)), v, INT2FIX(0)); \
- if (!cmp) return val; \
- smaller = cmp < 0; \
- } \
- else { \
- rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE \
- " (must be numeric, true, false or nil)", \
- rb_obj_class(v)); \
- } \
- } while (0)
-
- VALUE low = rb_to_int(beg);
- VALUE high = rb_to_int(end);
- VALUE mid, org_high;
- ID id_div;
- CONST_ID(id_div, "div");
-
- if (excl) high = rb_funcall(high, '-', 1, INT2FIX(1));
- org_high = high;
-
- while (rb_cmpint(rb_funcall(low, id_cmp, 1, high), low, high) < 0) {
- mid = rb_funcall(rb_funcall(high, '+', 1, low), id_div, 1, INT2FIX(2));
- BSEARCH_CHECK(mid);
- if (smaller) {
- high = mid;
- }
- else {
- low = rb_funcall(mid, '+', 1, INT2FIX(1));
- }
- }
- if (rb_equal(low, org_high)) {
- BSEARCH_CHECK(low);
- if (!smaller) return Qnil;
- }
- return satisfied;
-}
-
/*
* call-seq:
* rng.bsearch {|obj| block } -> value
@@ -673,6 +575,33 @@ range_bsearch(VALUE range)
* (-1...0.0).bsearch to yield -0.0.
*/
+#define BSEARCH_CHECK(expr) \
+ do { \
+ VALUE val = (expr); \
+ VALUE v = rb_yield(val); \
+ if (FIXNUM_P(v)) { \
+ if (v == INT2FIX(0)) return val; \
+ smaller = (SIGNED_VALUE)v < 0; \
+ } \
+ else if (v == Qtrue) { \
+ satisfied = val; \
+ smaller = 1; \
+ } \
+ else if (v == Qfalse || v == Qnil) { \
+ smaller = 0; \
+ } \
+ else if (rb_obj_is_kind_of(v, rb_cNumeric)) { \
+ int cmp = rb_cmpint(rb_funcall(v, id_cmp, 1, INT2FIX(0)), v, INT2FIX(0)); \
+ if (!cmp) return val; \
+ smaller = cmp < 0; \
+ } \
+ else { \
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE \
+ " (must be numeric, true, false or nil)", \
+ rb_obj_class(v)); \
+ } \
+ } while (0)
+
#define BSEARCH(conv) \
do { \
RETURN_ENUMERATOR(range, 0, 0); \
@@ -708,39 +637,35 @@ range_bsearch(VALUE range)
}
#if SIZEOF_DOUBLE == 8 && defined(HAVE_INT64_T)
else if (RB_TYPE_P(beg, T_FLOAT) || RB_TYPE_P(end, T_FLOAT)) {
- int64_t low = double_as_int64(NIL_P(beg) ? -HUGE_VAL : RFLOAT_VALUE(rb_Float(beg)));
- int64_t high = double_as_int64(NIL_P(end) ? HUGE_VAL : RFLOAT_VALUE(rb_Float(end)));
+ int64_t low = double_as_int64(RFLOAT_VALUE(rb_Float(beg)));
+ int64_t high = double_as_int64(RFLOAT_VALUE(rb_Float(end)));
int64_t mid, org_high;
BSEARCH(int64_as_double_to_num);
}
#endif
else if (is_integer_p(beg) && is_integer_p(end)) {
+ VALUE low = rb_to_int(beg);
+ VALUE high = rb_to_int(end);
+ VALUE mid, org_high;
RETURN_ENUMERATOR(range, 0, 0);
- return bsearch_integer_range(beg, end, EXCL(range));
- }
- else if (is_integer_p(beg) && NIL_P(end)) {
- VALUE diff = LONG2FIX(1);
- RETURN_ENUMERATOR(range, 0, 0);
- while (1) {
- VALUE mid = rb_funcall(beg, '+', 1, diff);
+ if (EXCL(range)) high = rb_funcall(high, '-', 1, INT2FIX(1));
+ org_high = high;
+
+ while (rb_cmpint(rb_funcall(low, id_cmp, 1, high), low, high) < 0) {
+ mid = rb_funcall(rb_funcall(high, '+', 1, low), id_div, 1, INT2FIX(2));
BSEARCH_CHECK(mid);
if (smaller) {
- return bsearch_integer_range(beg, mid, 0);
+ high = mid;
}
- diff = rb_funcall(diff, '*', 1, LONG2FIX(2));
- }
- }
- else if (NIL_P(beg) && is_integer_p(end)) {
- VALUE diff = LONG2FIX(-1);
- RETURN_ENUMERATOR(range, 0, 0);
- while (1) {
- VALUE mid = rb_funcall(end, '+', 1, diff);
- BSEARCH_CHECK(mid);
- if (!smaller) {
- return bsearch_integer_range(mid, end, 0);
+ else {
+ low = rb_funcall(mid, '+', 1, INT2FIX(1));
}
- diff = rb_funcall(diff, '*', 1, LONG2FIX(2));
}
+ if (rb_equal(low, org_high)) {
+ BSEARCH_CHECK(low);
+ if (!smaller) return Qnil;
+ }
+ return satisfied;
}
else {
rb_raise(rb_eTypeError, "can't do binary search for %s", rb_obj_classname(beg));
@@ -748,18 +673,18 @@ range_bsearch(VALUE range)
return range;
}
-static int
-each_i(VALUE v, VALUE arg)
+static VALUE
+each_i(RB_BLOCK_CALL_FUNC_ARGLIST(v, arg))
{
rb_yield(v);
- return 0;
+ return Qnil;
}
-static int
-sym_each_i(VALUE v, VALUE arg)
+static VALUE
+sym_each_i(RB_BLOCK_CALL_FUNC_ARGLIST(v, arg))
{
rb_yield(rb_str_intern(v));
- return 0;
+ return Qnil;
}
/*
@@ -778,41 +703,12 @@ static VALUE
range_size(VALUE range)
{
VALUE b = RANGE_BEG(range), e = RANGE_END(range);
- if (rb_obj_is_kind_of(b, rb_cNumeric)) {
- if (rb_obj_is_kind_of(e, rb_cNumeric)) {
- return ruby_num_interval_step_size(b, e, INT2FIX(1), EXCL(range));
- }
- if (NIL_P(e)) {
- return DBL2NUM(HUGE_VAL);
- }
- }
- else if (NIL_P(b)) {
- return DBL2NUM(HUGE_VAL);
+ if (rb_obj_is_kind_of(b, rb_cNumeric) && rb_obj_is_kind_of(e, rb_cNumeric)) {
+ return ruby_num_interval_step_size(b, e, INT2FIX(1), EXCL(range));
}
-
return Qnil;
}
-/*
- * call-seq:
- * rng.to_a -> array
- * rng.entries -> array
- *
- * Returns an array containing the items in the range.
- *
- * (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
- * (1..).to_a #=> RangeError: cannot convert endless range to an array
- */
-
-static VALUE
-range_to_a(VALUE range)
-{
- if (NIL_P(RANGE_END(range))) {
- rb_raise(rb_eRangeError, "cannot convert endless range to an array");
- }
- return rb_call_super(0, 0);
-}
-
static VALUE
range_enum_size(VALUE range, VALUE args, VALUE eobj)
{
@@ -844,105 +740,45 @@ static VALUE
range_each(VALUE range)
{
VALUE beg, end;
- long i, lim;
RETURN_SIZED_ENUMERATOR(range, 0, 0, range_enum_size);
beg = RANGE_BEG(range);
end = RANGE_END(range);
- if (FIXNUM_P(beg) && NIL_P(end)) {
- fixnum_endless:
- i = FIX2LONG(beg);
- while (FIXABLE(i)) {
- rb_yield(LONG2FIX(i++));
- }
- beg = LONG2NUM(i);
- bignum_endless:
- for (;; beg = rb_big_plus(beg, INT2FIX(1)))
- rb_yield(beg);
- }
- else if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
- fixnum_loop:
- lim = FIX2LONG(end);
+ if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
+ long lim = FIX2LONG(end);
+ long i;
+
if (!EXCL(range))
lim += 1;
for (i = FIX2LONG(beg); i < lim; i++) {
rb_yield(LONG2FIX(i));
}
}
- else if (RB_INTEGER_TYPE_P(beg) && (NIL_P(end) || RB_INTEGER_TYPE_P(end))) {
- if (SPECIAL_CONST_P(end) || RBIGNUM_POSITIVE_P(end)) { /* end >= FIXNUM_MIN */
- if (!FIXNUM_P(beg)) {
- if (RBIGNUM_NEGATIVE_P(beg)) {
- do {
- rb_yield(beg);
- } while (!FIXNUM_P(beg = rb_big_plus(beg, INT2FIX(1))));
- if (NIL_P(end)) goto fixnum_endless;
- if (FIXNUM_P(end)) goto fixnum_loop;
- }
- else {
- if (NIL_P(end)) goto bignum_endless;
- if (FIXNUM_P(end)) return range;
- }
- }
- if (FIXNUM_P(beg)) {
- i = FIX2LONG(beg);
- do {
- rb_yield(LONG2FIX(i));
- } while (POSFIXABLE(++i));
- beg = LONG2NUM(i);
- }
- ASSUME(!FIXNUM_P(beg));
- ASSUME(!SPECIAL_CONST_P(end));
- }
- if (!FIXNUM_P(beg) && RBIGNUM_SIGN(beg) == RBIGNUM_SIGN(end)) {
- if (EXCL(range)) {
- while (rb_big_cmp(beg, end) == INT2FIX(-1)) {
- rb_yield(beg);
- beg = rb_big_plus(beg, INT2FIX(1));
- }
- }
- else {
- VALUE c;
- while ((c = rb_big_cmp(beg, end)) != INT2FIX(1)) {
- rb_yield(beg);
- if (c == INT2FIX(0)) break;
- beg = rb_big_plus(beg, INT2FIX(1));
- }
- }
- }
- }
- else if (SYMBOL_P(beg) && (NIL_P(end) || SYMBOL_P(end))) { /* symbols are special */
- beg = rb_sym2str(beg);
- if (NIL_P(end)) {
- rb_str_upto_endless_each(beg, sym_each_i, 0);
- }
- else {
- rb_str_upto_each(beg, rb_sym2str(end), EXCL(range), sym_each_i, 0);
- }
+ else if (SYMBOL_P(beg) && SYMBOL_P(end)) { /* symbols are special */
+ VALUE args[2];
+
+ args[0] = rb_sym2str(end);
+ args[1] = EXCL(range) ? Qtrue : Qfalse;
+ rb_block_call(rb_sym2str(beg), rb_intern("upto"), 2, args, sym_each_i, 0);
}
else {
VALUE tmp = rb_check_string_type(beg);
if (!NIL_P(tmp)) {
- if (!NIL_P(end)) {
- rb_str_upto_each(tmp, end, EXCL(range), each_i, 0);
- }
- else {
- rb_str_upto_endless_each(tmp, each_i, 0);
- }
+ VALUE args[2];
+
+ args[0] = end;
+ args[1] = EXCL(range) ? Qtrue : Qfalse;
+ rb_block_call(tmp, rb_intern("upto"), 2, args, each_i, 0);
}
else {
if (!discrete_object_p(beg)) {
rb_raise(rb_eTypeError, "can't iterate from %s",
rb_obj_classname(beg));
}
- if (!NIL_P(end))
- range_each_func(range, each_i, 0);
- else
- for (;; beg = rb_funcallv(beg, id_succ, 0, 0))
- rb_yield(beg);
+ range_each_func(range, each_i, 0);
}
}
return range;
@@ -1014,9 +850,6 @@ range_first(int argc, VALUE *argv, VALUE range)
{
VALUE n, ary[2];
- if (NIL_P(RANGE_BEG(range))) {
- rb_raise(rb_eRangeError, "cannot get the first element of beginless range");
- }
if (argc == 0) return RANGE_BEG(range);
rb_scan_args(argc, argv, "1", &n);
@@ -1027,58 +860,6 @@ range_first(int argc, VALUE *argv, VALUE range)
return ary[1];
}
-static VALUE
-rb_int_range_last(int argc, VALUE *argv, VALUE range)
-{
- static const VALUE ONE = INT2FIX(1);
-
- VALUE b, e, len_1, len, nv, ary;
- int x;
- long n;
-
- assert(argc > 0);
-
- b = RANGE_BEG(range);
- e = RANGE_END(range);
- assert(RB_INTEGER_TYPE_P(b) && RB_INTEGER_TYPE_P(e));
-
- x = EXCL(range);
-
- len_1 = rb_int_minus(e, b);
- if (FIXNUM_ZERO_P(len_1) || rb_num_negative_p(len_1)) {
- return rb_ary_new_capa(0);
- }
-
- if (x) {
- e = rb_int_minus(e, ONE);
- len = len_1;
- }
- else {
- len = rb_int_plus(len_1, ONE);
- }
-
- rb_scan_args(argc, argv, "1", &nv);
- n = NUM2LONG(nv);
- if (n < 0) {
- rb_raise(rb_eArgError, "negative array size");
- }
-
- nv = LONG2NUM(n);
- if (RTEST(rb_int_gt(nv, len))) {
- nv = len;
- n = NUM2LONG(nv);
- }
-
- ary = rb_ary_new_capa(n);
- b = rb_int_minus(e, nv);
- while (n) {
- b = rb_int_plus(b, ONE);
- rb_ary_push(ary, b);
- --n;
- }
-
- return ary;
-}
/*
* call-seq:
@@ -1100,19 +881,7 @@ rb_int_range_last(int argc, VALUE *argv, VALUE range)
static VALUE
range_last(int argc, VALUE *argv, VALUE range)
{
- VALUE b, e;
-
- if (NIL_P(RANGE_END(range))) {
- rb_raise(rb_eRangeError, "cannot get the last element of endless range");
- }
if (argc == 0) return RANGE_END(range);
-
- b = RANGE_BEG(range);
- e = RANGE_END(range);
- if (RB_INTEGER_TYPE_P(b) && RB_INTEGER_TYPE_P(e) &&
- RB_LIKELY(rb_method_basic_definition_p(rb_cRange, idEach))) {
- return rb_int_range_last(argc, argv, range);
- }
return rb_ary_last(argc, argv, rb_Array(range));
}
@@ -1138,14 +907,7 @@ range_last(int argc, VALUE *argv, VALUE range)
static VALUE
range_min(int argc, VALUE *argv, VALUE range)
{
- if (NIL_P(RANGE_BEG(range))) {
- rb_raise(rb_eRangeError, "cannot get the minimum of beginless range");
- }
-
if (rb_block_given_p()) {
- if (NIL_P(RANGE_END(range))) {
- rb_raise(rb_eRangeError, "cannot get the minimum of endless range with custom comparison method");
- }
return rb_call_super(argc, argv);
}
else if (argc != 0) {
@@ -1155,7 +917,7 @@ range_min(int argc, VALUE *argv, VALUE range)
struct cmp_opt_data cmp_opt = { 0, 0 };
VALUE b = RANGE_BEG(range);
VALUE e = RANGE_END(range);
- int c = NIL_P(e) ? -1 : OPTIMIZED_CMP(b, e, cmp_opt);
+ int c = OPTIMIZED_CMP(b, e, cmp_opt);
if (c > 0 || (c == 0 && EXCL(range)))
return Qnil;
@@ -1186,62 +948,31 @@ range_max(int argc, VALUE *argv, VALUE range)
VALUE e = RANGE_END(range);
int nm = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric);
- if (NIL_P(RANGE_END(range))) {
- rb_raise(rb_eRangeError, "cannot get the maximum of endless range");
- }
-
if (rb_block_given_p() || (EXCL(range) && !nm) || argc) {
- if (NIL_P(RANGE_BEG(range))) {
- rb_raise(rb_eRangeError, "cannot get the maximum of beginless range with custom comparison method");
- }
- return rb_call_super(argc, argv);
+ return rb_call_super(argc, argv);
}
else {
- struct cmp_opt_data cmp_opt = { 0, 0 };
- VALUE b = RANGE_BEG(range);
- int c = OPTIMIZED_CMP(b, e, cmp_opt);
-
- if (c > 0)
- return Qnil;
- if (EXCL(range)) {
- if (!RB_INTEGER_TYPE_P(e)) {
- rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
- }
- if (c == 0) return Qnil;
- if (!RB_INTEGER_TYPE_P(b)) {
- rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
- }
- if (FIXNUM_P(e)) {
- return LONG2NUM(FIX2LONG(e) - 1);
- }
- return rb_funcall(e, '-', 1, INT2FIX(1));
- }
- return e;
- }
-}
-
-/*
- * call-seq:
- * rng.minmax -> [obj, obj]
- * rng.minmax {| a,b | block } -> [obj, obj]
- *
- * Returns a two element array which contains the minimum and the
- * maximum value in the range.
- *
- * Can be given an optional block to override the default comparison
- * method <code>a <=> b</code>.
- */
+ struct cmp_opt_data cmp_opt = { 0, 0 };
+ VALUE b = RANGE_BEG(range);
+ int c = OPTIMIZED_CMP(b, e, cmp_opt);
-static VALUE
-range_minmax(VALUE range)
-{
- if (rb_block_given_p()) {
- return rb_call_super(0, NULL);
+ if (c > 0)
+ return Qnil;
+ if (EXCL(range)) {
+ if (!FIXNUM_P(e) && !rb_obj_is_kind_of(e, rb_cInteger)) {
+ rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
+ }
+ if (c == 0) return Qnil;
+ if (!FIXNUM_P(b) && !rb_obj_is_kind_of(b,rb_cInteger)) {
+ rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
+ }
+ if (FIXNUM_P(e)) {
+ return LONG2NUM(FIX2LONG(e) - 1);
+ }
+ return rb_funcall(e, '-', 1, INT2FIX(1));
+ }
+ return e;
}
- return rb_assoc_new(
- rb_funcall(range, id_min, 0),
- rb_funcall(range, id_max, 0)
- );
}
int
@@ -1255,9 +986,6 @@ rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
e = RANGE_END(range);
excl = EXCL(range);
}
- else if (RTEST(rb_obj_is_kind_of(range, rb_cArithSeq))) {
- return (int)Qfalse;
- }
else {
VALUE x;
b = rb_check_funcall(range, id_beg, 0, 0);
@@ -1283,9 +1011,8 @@ rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
if (!rb_range_values(range, &b, &e, &excl))
return Qfalse;
- beg = NIL_P(b) ? 0 : NUM2LONG(b);
- end = NIL_P(e) ? -1 : NUM2LONG(e);
- if (NIL_P(e)) excl = 0;
+ beg = NUM2LONG(b);
+ end = NUM2LONG(e);
origbeg = beg;
origend = end;
if (beg < 0) {
@@ -1337,6 +1064,7 @@ range_to_s(VALUE range)
str = rb_str_dup(str);
rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
rb_str_append(str, str2);
+ OBJ_INFECT(str, range);
return str;
}
@@ -1344,22 +1072,17 @@ range_to_s(VALUE range)
static VALUE
inspect_range(VALUE range, VALUE dummy, int recur)
{
- VALUE str, str2 = Qundef;
+ VALUE str, str2;
if (recur) {
return rb_str_new2(EXCL(range) ? "(... ... ...)" : "(... .. ...)");
}
- if (!NIL_P(RANGE_BEG(range)) || NIL_P(RANGE_END(range))) {
- str = rb_str_dup(rb_inspect(RANGE_BEG(range)));
- }
- else {
- str = rb_str_new(0, 0);
- }
+ str = rb_inspect(RANGE_BEG(range));
+ str2 = rb_inspect(RANGE_END(range));
+ str = rb_str_dup(str);
rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
- if (NIL_P(RANGE_BEG(range)) || !NIL_P(RANGE_END(range))) {
- str2 = rb_inspect(RANGE_END(range));
- }
- if (str2 != Qundef) rb_str_append(str, str2);
+ rb_str_append(str, str2);
+ OBJ_INFECT(str, range);
return str;
}
@@ -1368,8 +1091,9 @@ inspect_range(VALUE range, VALUE dummy, int recur)
* call-seq:
* rng.inspect -> string
*
- * Convert this range object to a printable form (using #inspect to
- * convert the begin and end objects).
+ * Convert this range object to a printable form (using
+ * <code>inspect</code> to convert the begin and end
+ * objects).
*/
@@ -1379,40 +1103,29 @@ range_inspect(VALUE range)
return rb_exec_recursive(inspect_range, range, 0);
}
-static VALUE range_include_internal(VALUE range, VALUE val, int string_use_cover);
-
/*
* call-seq:
* rng === obj -> true or false
*
- * Returns <code>true</code> if +obj+ is between begin and end of range,
- * <code>false</code> otherwise (same as #cover?). Conveniently,
- * <code>===</code> is the comparison operator used by <code>case</code>
- * statements.
+ * Returns <code>true</code> if +obj+ is an element of the range,
+ * <code>false</code> otherwise. Conveniently, <code>===</code> is the
+ * comparison operator used by <code>case</code> statements.
*
* case 79
- * when 1..50 then puts "low"
- * when 51..75 then puts "medium"
- * when 76..100 then puts "high"
+ * when 1..50 then print "low\n"
+ * when 51..75 then print "medium\n"
+ * when 76..100 then print "high\n"
* end
- * # Prints "high"
*
- * case "2.6.5"
- * when ..."2.4" then puts "EOL"
- * when "2.4"..."2.5" then puts "maintenance"
- * when "2.5"..."2.7" then puts "stable"
- * when "2.7".. then puts "upcoming"
- * end
- * # Prints "stable"
+ * <em>produces:</em>
*
+ * high
*/
static VALUE
range_eqq(VALUE range, VALUE val)
{
- VALUE ret = range_include_internal(range, val, 1);
- if (ret != Qundef) return ret;
- return r_cover_p(range, RANGE_BEG(range), RANGE_END(range), val);
+ return rb_funcall(range, rb_intern("include?"), 1, val);
}
@@ -1422,32 +1135,17 @@ range_eqq(VALUE range, VALUE val)
* rng.include?(obj) -> true or false
*
* Returns <code>true</code> if +obj+ is an element of
- * the range, <code>false</code> otherwise.
+ * the range, <code>false</code> otherwise. If begin and end are
+ * numeric, comparison is done according to the magnitude of the values.
*
* ("a".."z").include?("g") #=> true
* ("a".."z").include?("A") #=> false
* ("a".."z").include?("cc") #=> false
- *
- * If you need to ensure +obj+ is between +begin+ and +end+, use #cover?
- *
- * ("a".."z").cover?("cc") #=> true
- *
- * If begin and end are numeric, #include? behaves like #cover?
- *
- * (1..3).include?(1.5) # => true
*/
static VALUE
range_include(VALUE range, VALUE val)
{
- VALUE ret = range_include_internal(range, val, 0);
- if (ret != Qundef) return ret;
- return rb_call_super(1, &val);
-}
-
-static VALUE
-range_include_internal(VALUE range, VALUE val, int string_use_cover)
-{
VALUE beg = RANGE_BEG(range);
VALUE end = RANGE_END(range);
int nv = FIXNUM_P(beg) || FIXNUM_P(end) ||
@@ -1458,38 +1156,18 @@ range_include_internal(VALUE range, VALUE val, int string_use_cover)
!NIL_P(rb_check_to_integer(end, "to_int"))) {
return r_cover_p(range, beg, end, val);
}
- else if (RB_TYPE_P(beg, T_STRING) || RB_TYPE_P(end, T_STRING)) {
- if (RB_TYPE_P(beg, T_STRING) && RB_TYPE_P(end, T_STRING)) {
- if (string_use_cover) {
- return r_cover_p(range, beg, end, val);
- }
- else {
- VALUE rb_str_include_range_p(VALUE beg, VALUE end, VALUE val, VALUE exclusive);
- return rb_str_include_range_p(beg, end, val, RANGE_EXCL(range));
- }
- }
- else if (NIL_P(beg)) {
- VALUE r = rb_funcall(val, id_cmp, 1, end);
- if (NIL_P(r)) return Qfalse;
- if (rb_cmpint(r, val, end) <= 0) return Qtrue;
- return Qfalse;
- }
- else if (NIL_P(end)) {
- VALUE r = rb_funcall(beg, id_cmp, 1, val);
- if (NIL_P(r)) return Qfalse;
- if (rb_cmpint(r, beg, val) <= 0) return Qtrue;
- return Qfalse;
- }
+ else if (RB_TYPE_P(beg, T_STRING) && RB_TYPE_P(end, T_STRING)) {
+ VALUE rb_str_include_range_p(VALUE beg, VALUE end, VALUE val, VALUE exclusive);
+ return rb_str_include_range_p(beg, end, val, RANGE_EXCL(range));
}
- return Qundef;
+ /* TODO: ruby_frame->this_func = rb_intern("include?"); */
+ return rb_call_super(1, &val);
}
-static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
/*
* call-seq:
- * rng.cover?(obj) -> true or false
- * rng.cover?(range) -> true or false
+ * rng.cover?(obj) -> true or false
*
* Returns <code>true</code> if +obj+ is between the begin and end of
* the range.
@@ -1497,25 +1175,9 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
* This tests <code>begin <= obj <= end</code> when #exclude_end? is +false+
* and <code>begin <= obj < end</code> when #exclude_end? is +true+.
*
- * If called with a Range argument, returns <code>true</code> when the
- * given range is covered by the receiver,
- * by comparing the begin and end values. If the argument can be treated as
- * a sequence, this method treats it that way. In the specific case of
- * <code>(a..b).cover?(c...d)</code> with <code>a <= c && b < d</code>,
- * the end of the sequence must be calculated, which may exhibit poor
- * performance if <code>c</code> is non-numeric.
- * Returns <code>false</code> if the begin value of the
- * range is larger than the end value. Also returns +false+ if one of the
- * internal calls to <code><=></code> returns +nil+ (indicating the objects
- * are not comparable).
- *
- * ("a".."z").cover?("c") #=> true
- * ("a".."z").cover?("5") #=> false
- * ("a".."z").cover?("cc") #=> true
- * ("a".."z").cover?(1) #=> false
- * (1..5).cover?(2..3) #=> true
- * (1..5).cover?(0..6) #=> false
- * (1..5).cover?(1...6) #=> true
+ * ("a".."z").cover?("c") #=> true
+ * ("a".."z").cover?("5") #=> false
+ * ("a".."z").cover?("cc") #=> true
*/
static VALUE
@@ -1525,57 +1187,15 @@ range_cover(VALUE range, VALUE val)
beg = RANGE_BEG(range);
end = RANGE_END(range);
-
- if (rb_obj_is_kind_of(val, rb_cRange)) {
- return RBOOL(r_cover_range_p(range, beg, end, val));
- }
return r_cover_p(range, beg, end, val);
}
static VALUE
-r_call_max(VALUE r)
-{
- return rb_funcallv(r, rb_intern("max"), 0, 0);
-}
-
-static int
-r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val)
-{
- VALUE val_beg, val_end, val_max;
- int cmp_end;
-
- val_beg = RANGE_BEG(val);
- val_end = RANGE_END(val);
-
- if (!NIL_P(end) && NIL_P(val_end)) return FALSE;
- if (!NIL_P(beg) && NIL_P(val_beg)) return FALSE;
- if (!NIL_P(val_beg) && !NIL_P(val_end) && r_less(val_beg, val_end) > -EXCL(val)) return FALSE;
- if (!NIL_P(val_beg) && !r_cover_p(range, beg, end, val_beg)) return FALSE;
-
- cmp_end = r_less(end, val_end);
-
- if (EXCL(range) == EXCL(val)) {
- return cmp_end >= 0;
- }
- else if (EXCL(range)) {
- return cmp_end > 0;
- }
- else if (cmp_end >= 0) {
- return TRUE;
- }
-
- val_max = rb_rescue2(r_call_max, val, NULL, Qnil, rb_eTypeError, (VALUE)0);
- if (val_max == Qnil) return FALSE;
-
- return r_less(end, val_max) >= 0;
-}
-
-static VALUE
r_cover_p(VALUE range, VALUE beg, VALUE end, VALUE val)
{
- if (NIL_P(beg) || r_less(beg, val) <= 0) {
+ if (r_less(beg, val) <= 0) {
int excl = EXCL(range);
- if (NIL_P(end) || r_less(val, end) <= -excl)
+ if (r_less(val, end) <= -excl)
return Qtrue;
}
return Qfalse;
@@ -1622,43 +1242,7 @@ range_alloc(VALUE klass)
return rb_struct_alloc_noinit(klass);
}
-/*
- * call-seq:
- * range.count -> int
- * range.count(item) -> int
- * range.count { |obj| block } -> int
- *
- * Identical to Enumerable#count, except it returns Infinity for endless
- * ranges.
- *
- */
-static VALUE
-range_count(int argc, VALUE *argv, VALUE range)
-{
- if (argc != 0) {
- /* It is odd for instance (1...).count(0) to return Infinity. Just let
- * it loop. */
- return rb_call_super(argc, argv);
- }
- else if (rb_block_given_p()) {
- /* Likewise it is odd for instance (1...).count {|x| x == 0 } to return
- * Infinity. Just let it loop. */
- return rb_call_super(argc, argv);
- }
- else if (NIL_P(RANGE_END(range))) {
- /* We are confident that the answer is Infinity. */
- return DBL2NUM(HUGE_VAL);
- }
- else if (NIL_P(RANGE_BEG(range))) {
- /* We are confident that the answer is Infinity. */
- return DBL2NUM(HUGE_VAL);
- }
- else {
- return rb_call_super(argc, argv);
- }
-}
-
-/* A Range represents an interval---a set of values with a
+/* A <code>Range</code> represents an interval---a set of values with a
* beginning and an end. Ranges may be constructed using the
* <em>s</em><code>..</code><em>e</em> and
* <em>s</em><code>...</code><em>e</em> literals, or with
@@ -1672,42 +1256,6 @@ range_count(int argc, VALUE *argv, VALUE range)
* ('a'..'e').to_a #=> ["a", "b", "c", "d", "e"]
* ('a'...'e').to_a #=> ["a", "b", "c", "d"]
*
- * == Beginless/Endless Ranges
- *
- * A "beginless range" and "endless range" represents a semi-infinite
- * range. Literal notation for a beginless range is:
- *
- * (..1)
- * # or
- * (...1)
- *
- * Literal notation for an endless range is:
- *
- * (1..)
- * # or similarly
- * (1...)
- *
- * Which is equivalent to
- *
- * (1..nil) # or similarly (1...nil)
- * Range.new(1, nil) # or Range.new(1, nil, true)
- *
- * Beginless/endless ranges are useful, for example, for idiomatic
- * slicing of arrays:
- *
- * [1, 2, 3, 4, 5][...2] # => [1, 2]
- * [1, 2, 3, 4, 5][2...] # => [3, 4, 5]
- *
- * Some implementation details:
- *
- * * +begin+ of beginless range and +end+ of endless range are +nil+;
- * * +each+ of beginless range raises an exception;
- * * +each+ of endless range enumerates infinite sequence (may be
- * useful in combination with Enumerable#take_while or similar
- * methods);
- * * <code>(1..)</code> and <code>(1...)</code> are not equal,
- * although technically representing the same sequence.
- *
* == Custom Objects in Ranges
*
* Ranges can be constructed using any objects that can be compared
@@ -1760,6 +1308,8 @@ Init_Range(void)
id_beg = rb_intern("begin");
id_end = rb_intern("end");
id_excl = rb_intern("excl");
+ id_integer_p = rb_intern("integer?");
+ id_div = rb_intern("div");
rb_cRange = rb_struct_define_without_accessor(
"Range", rb_cObject, range_alloc,
@@ -1775,7 +1325,6 @@ Init_Range(void)
rb_define_method(rb_cRange, "hash", range_hash, 0);
rb_define_method(rb_cRange, "each", range_each, 0);
rb_define_method(rb_cRange, "step", range_step, -1);
- rb_define_method(rb_cRange, "%", range_percent_step, 1);
rb_define_method(rb_cRange, "bsearch", range_bsearch, 0);
rb_define_method(rb_cRange, "begin", range_begin, 0);
rb_define_method(rb_cRange, "end", range_end, 0);
@@ -1783,10 +1332,7 @@ Init_Range(void)
rb_define_method(rb_cRange, "last", range_last, -1);
rb_define_method(rb_cRange, "min", range_min, -1);
rb_define_method(rb_cRange, "max", range_max, -1);
- rb_define_method(rb_cRange, "minmax", range_minmax, 0);
rb_define_method(rb_cRange, "size", range_size, 0);
- rb_define_method(rb_cRange, "to_a", range_to_a, 0);
- rb_define_method(rb_cRange, "entries", range_to_a, 0);
rb_define_method(rb_cRange, "to_s", range_to_s, 0);
rb_define_method(rb_cRange, "inspect", range_inspect, 0);
@@ -1795,5 +1341,4 @@ Init_Range(void)
rb_define_method(rb_cRange, "member?", range_include, 1);
rb_define_method(rb_cRange, "include?", range_include, 1);
rb_define_method(rb_cRange, "cover?", range_cover, 1);
- rb_define_method(rb_cRange, "count", range_count, -1);
}
diff --git a/rational.c b/rational.c
index 9f6964f0aa..a29aec4000 100644
--- a/rational.c
+++ b/rational.c
@@ -33,24 +33,33 @@
VALUE rb_cRational;
-static ID id_abs, id_integer_p,
+static ID id_abs, id_idiv, id_integer_p, id_to_i,
id_i_num, id_i_den;
-#define id_idiv idDiv
-#define id_to_i idTo_i
-
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
#define f_inspect rb_inspect
#define f_to_s rb_obj_as_string
-static VALUE nurat_to_f(VALUE self);
+#define binop(n,op) \
+inline static VALUE \
+f_##n(VALUE x, VALUE y)\
+{\
+ return rb_funcall(x, (op), 1, y);\
+}
+
+#define fun1(n) \
+inline static VALUE \
+f_##n(VALUE x)\
+{\
+ return rb_funcall(x, id_##n, 0);\
+}
inline static VALUE
f_add(VALUE x, VALUE y)
{
- if (FIXNUM_ZERO_P(y))
+ if (FIXNUM_P(y) && FIXNUM_ZERO_P(y))
return x;
- if (FIXNUM_ZERO_P(x))
+ else if (FIXNUM_P(x) && FIXNUM_ZERO_P(x))
return y;
return rb_funcall(x, '+', 1, y);
}
@@ -58,7 +67,7 @@ f_add(VALUE x, VALUE y)
inline static VALUE
f_div(VALUE x, VALUE y)
{
- if (y == ONE)
+ if (FIXNUM_P(y) && FIX2LONG(y) == 1)
return x;
if (RB_INTEGER_TYPE_P(x))
return rb_int_div(x, y);
@@ -75,25 +84,32 @@ f_lt_p(VALUE x, VALUE y)
#ifndef NDEBUG
/* f_mod is used only in f_gcd defined when NDEBUG is not defined */
-inline static VALUE
-f_mod(VALUE x, VALUE y)
-{
- if (RB_INTEGER_TYPE_P(x))
- return rb_int_modulo(x, y);
- return rb_funcall(x, '%', 1, y);
-}
+binop(mod, '%')
#endif
inline static VALUE
f_mul(VALUE x, VALUE y)
{
- if (FIXNUM_ZERO_P(y) && RB_INTEGER_TYPE_P(x))
- return ZERO;
- if (y == ONE) return x;
- if (FIXNUM_ZERO_P(x) && RB_INTEGER_TYPE_P(y))
- return ZERO;
- if (x == ONE) return y;
- else if (RB_INTEGER_TYPE_P(x))
+ if (FIXNUM_P(y)) {
+ long iy = FIX2LONG(y);
+ if (iy == 0) {
+ if (RB_INTEGER_TYPE_P(x))
+ return ZERO;
+ }
+ else if (iy == 1)
+ return x;
+ }
+ else if (FIXNUM_P(x)) {
+ long ix = FIX2LONG(x);
+ if (ix == 0) {
+ if (RB_INTEGER_TYPE_P(y))
+ return ZERO;
+ }
+ else if (ix == 1)
+ return y;
+ return rb_int_mul(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM))
return rb_int_mul(x, y);
return rb_funcall(x, '*', 1, y);
}
@@ -114,12 +130,7 @@ f_abs(VALUE x)
return rb_funcall(x, id_abs, 0);
}
-
-inline static VALUE
-f_integer_p(VALUE x)
-{
- return RB_INTEGER_TYPE_P(x);
-}
+fun1(integer_p)
inline static VALUE
f_to_i(VALUE x)
@@ -389,6 +400,9 @@ f_lcm(VALUE x, VALUE y)
#define get_dat2(x,y) \
struct RRational *adat = RRATIONAL(x), *bdat = RRATIONAL(y)
+#define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
+#define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
+
inline static VALUE
nurat_s_new_internal(VALUE klass, VALUE num, VALUE den)
{
@@ -407,6 +421,38 @@ nurat_s_alloc(VALUE klass)
return nurat_s_new_internal(klass, ZERO, ONE);
}
+#if 0
+static VALUE
+nurat_s_new_bang(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE num, den;
+
+ switch (rb_scan_args(argc, argv, "11", &num, &den)) {
+ case 1:
+ if (!k_integer_p(num))
+ num = f_to_i(num);
+ den = ONE;
+ break;
+ default:
+ if (!k_integer_p(num))
+ num = f_to_i(num);
+ if (!k_integer_p(den))
+ den = f_to_i(den);
+
+ if (INT_NEGATIVE_P(den)) {
+ num = rb_int_uminus(num);
+ den = rb_int_uminus(den);
+ }
+ else if (INT_ZERO_P(den)) {
+ rb_num_zerodiv();
+ }
+ break;
+ }
+
+ return nurat_s_new_internal(klass, num, den);
+}
+#endif
+
inline static VALUE
f_rational_new_bang1(VALUE klass, VALUE x)
{
@@ -414,6 +460,10 @@ f_rational_new_bang1(VALUE klass, VALUE x)
}
#ifdef CANONICALIZATION_FOR_MATHN
+#define CANON
+#endif
+
+#ifdef CANON
static int canonicalization = 0;
RUBY_FUNC_EXPORTED void
@@ -446,8 +496,8 @@ nurat_int_value(VALUE num)
static void
nurat_canonicalize(VALUE *num, VALUE *den)
{
- assert(num); assert(RB_INTEGER_TYPE_P(*num));
- assert(den); assert(RB_INTEGER_TYPE_P(*den));
+ assert(num != NULL && RB_INTEGER_TYPE_P(*num));
+ assert(den != NULL && RB_INTEGER_TYPE_P(*den));
if (INT_NEGATIVE_P(*den)) {
*num = rb_int_uminus(*num);
*den = rb_int_uminus(*den);
@@ -523,13 +573,11 @@ f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y)
return nurat_s_canonicalize_internal_no_reduce(klass, x, y);
}
-static VALUE nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise);
static VALUE nurat_s_convert(int argc, VALUE *argv, VALUE klass);
-
/*
* call-seq:
- * Rational(x, y, exception: true) -> rational or nil
- * Rational(arg, exception: true) -> rational or nil
+ * Rational(x, y) -> rational
+ * Rational(arg) -> rational
*
* Returns +x/y+ or +arg+ as a Rational.
*
@@ -545,8 +593,6 @@ static VALUE nurat_s_convert(int argc, VALUE *argv, VALUE klass);
* Rational(nil) #=> TypeError
* Rational(1, nil) #=> TypeError
*
- * Rational("10 cents", exception: false) #=> nil
- *
* Syntax of the string form:
*
* string form = extra spaces , rational , extra spaces ;
@@ -566,16 +612,7 @@ static VALUE nurat_s_convert(int argc, VALUE *argv, VALUE klass);
static VALUE
nurat_f_rational(int argc, VALUE *argv, VALUE klass)
{
- VALUE a1, a2, opts = Qnil;
- int raise = TRUE;
-
- if (rb_scan_args(argc, argv, "11:", &a1, &a2, &opts) == 1) {
- a2 = Qundef;
- }
- if (!NIL_P(opts)) {
- raise = rb_opts_exception_p(opts, raise);
- }
- return nurat_convert(rb_cRational, a1, a2, raise);
+ return nurat_s_convert(argc, argv, rb_cRational);
}
/*
@@ -693,8 +730,7 @@ f_addsub(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
a = rb_int_idiv(bden, g);
den = rb_int_mul(a, b);
}
- else if (RB_INTEGER_TYPE_P(anum) && RB_INTEGER_TYPE_P(aden) &&
- RB_INTEGER_TYPE_P(bnum) && RB_INTEGER_TYPE_P(bden)) {
+ else {
VALUE g = f_gcd(aden, bden);
VALUE a = rb_int_mul(anum, rb_int_idiv(bden, g));
VALUE b = rb_int_mul(bnum, rb_int_idiv(aden, g));
@@ -711,12 +747,6 @@ f_addsub(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
a = rb_int_idiv(bden, g);
den = rb_int_mul(a, b);
}
- else {
- double a = NUM2DBL(anum) / NUM2DBL(aden);
- double b = NUM2DBL(bnum) / NUM2DBL(bden);
- double c = k == '+' ? a + b : a - b;
- return DBL2NUM(c);
- }
return f_rational_new_no_reduce2(CLASS_OF(self), num, den);
}
@@ -774,8 +804,8 @@ rb_rational_plus(VALUE self, VALUE other)
* Rational(9, 8) - 4 #=> (-23/8)
* Rational(20, 9) - 9.8 #=> -7.577777777777778
*/
-VALUE
-rb_rational_minus(VALUE self, VALUE other)
+static VALUE
+nurat_sub(VALUE self, VALUE other)
{
if (RB_INTEGER_TYPE_P(other)) {
{
@@ -809,16 +839,6 @@ f_muldiv(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
VALUE num, den;
assert(RB_TYPE_P(self, T_RATIONAL));
-
- /* Integer#** can return Rational with Float right now */
- if (RB_FLOAT_TYPE_P(anum) || RB_FLOAT_TYPE_P(aden) ||
- RB_FLOAT_TYPE_P(bnum) || RB_FLOAT_TYPE_P(bden)) {
- double an = NUM2DBL(anum), ad = NUM2DBL(aden);
- double bn = NUM2DBL(bnum), bd = NUM2DBL(bden);
- double x = (an * bn) / (ad * bd);
- return DBL2NUM(x);
- }
-
assert(RB_INTEGER_TYPE_P(anum));
assert(RB_INTEGER_TYPE_P(aden));
assert(RB_INTEGER_TYPE_P(bnum));
@@ -870,8 +890,8 @@ f_muldiv(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
* Rational(9, 8) * 4 #=> (9/2)
* Rational(20, 9) * 9.8 #=> 21.77777777777778
*/
-VALUE
-rb_rational_mul(VALUE self, VALUE other)
+static VALUE
+nurat_mul(VALUE self, VALUE other)
{
if (RB_INTEGER_TYPE_P(other)) {
{
@@ -912,8 +932,8 @@ rb_rational_mul(VALUE self, VALUE other)
* Rational(9, 8) / 4 #=> (9/32)
* Rational(20, 9) / 9.8 #=> 0.22675736961451246
*/
-VALUE
-rb_rational_div(VALUE self, VALUE other)
+static VALUE
+nurat_div(VALUE self, VALUE other)
{
if (RB_INTEGER_TYPE_P(other)) {
if (f_zero_p(other))
@@ -926,10 +946,8 @@ rb_rational_div(VALUE self, VALUE other)
other, ONE, '/');
}
}
- else if (RB_FLOAT_TYPE_P(other)) {
- VALUE v = nurat_to_f(self);
- return rb_flo_div_flo(v, other);
- }
+ else if (RB_FLOAT_TYPE_P(other))
+ return DBL2NUM(nurat_to_double(self) / RFLOAT_VALUE(other));
else if (RB_TYPE_P(other, T_RATIONAL)) {
if (f_zero_p(other))
rb_num_zerodiv();
@@ -950,6 +968,8 @@ rb_rational_div(VALUE self, VALUE other)
}
}
+static VALUE nurat_to_f(VALUE self);
+
/*
* call-seq:
* rat.fdiv(numeric) -> float
@@ -965,15 +985,15 @@ nurat_fdiv(VALUE self, VALUE other)
{
VALUE div;
if (f_zero_p(other))
- return rb_rational_div(self, rb_float_new(0.0));
+ return DBL2NUM(nurat_to_double(self) / 0.0);
if (FIXNUM_P(other) && other == LONG2FIX(1))
return nurat_to_f(self);
- div = rb_rational_div(self, other);
+ div = nurat_div(self, other);
if (RB_TYPE_P(div, T_RATIONAL))
return nurat_to_f(div);
if (RB_FLOAT_TYPE_P(div))
return div;
- return rb_funcall(div, idTo_f, 0);
+ return rb_funcall(div, rb_intern("to_f"), 0);
}
inline static VALUE
@@ -998,8 +1018,8 @@ f_odd_p(VALUE integer)
* Rational(1, 2) ** 0 #=> (1/1)
* Rational(1, 2) ** 0.0 #=> 1.0
*/
-VALUE
-rb_rational_pow(VALUE self, VALUE other)
+static VALUE
+nurat_expt(VALUE self, VALUE other)
{
if (k_numeric_p(other) && k_exact_zero_p(other))
return f_rational_new_bang1(CLASS_OF(self), ONE);
@@ -1052,8 +1072,7 @@ rb_rational_pow(VALUE self, VALUE other)
den = ONE;
}
if (RB_FLOAT_TYPE_P(num)) { /* infinity due to overflow */
- if (RB_FLOAT_TYPE_P(den))
- return DBL2NUM(nan(""));
+ if (RB_FLOAT_TYPE_P(den)) return DBL2NUM(NAN);
return num;
}
if (RB_FLOAT_TYPE_P(den)) { /* infinity due to overflow */
@@ -1074,7 +1093,6 @@ rb_rational_pow(VALUE self, VALUE other)
return rb_num_coerce_bin(self, other, rb_intern("**"));
}
}
-#define nurat_expt rb_rational_pow
/*
* call-seq:
@@ -1149,9 +1167,9 @@ static VALUE
nurat_eqeq_p(VALUE self, VALUE other)
{
if (RB_INTEGER_TYPE_P(other)) {
- get_dat1(self);
+ {
+ get_dat1(self);
- if (RB_INTEGER_TYPE_P(dat->num) && RB_INTEGER_TYPE_P(dat->den)) {
if (INT_ZERO_P(dat->num) && INT_ZERO_P(other))
return Qtrue;
@@ -1161,10 +1179,6 @@ nurat_eqeq_p(VALUE self, VALUE other)
return Qfalse;
return rb_int_equal(dat->num, other);
}
- else {
- const double d = nurat_to_double(self);
- return f_boolcast(FIXNUM_ZERO_P(rb_dbl_cmp(d, NUM2DBL(other))));
- }
}
else if (RB_FLOAT_TYPE_P(other)) {
const double d = nurat_to_double(self);
@@ -1212,6 +1226,39 @@ nurat_coerce(VALUE self, VALUE other)
return Qnil;
}
+#if 0
+/* :nodoc: */
+static VALUE
+nurat_idiv(VALUE self, VALUE other)
+{
+ return f_idiv(self, other);
+}
+
+/* :nodoc: */
+static VALUE
+nurat_quot(VALUE self, VALUE other)
+{
+ return f_truncate(f_div(self, other));
+}
+
+/* :nodoc: */
+static VALUE
+nurat_quotrem(VALUE self, VALUE other)
+{
+ VALUE val = f_truncate(f_div(self, other));
+ return rb_assoc_new(val, f_sub(self, f_mul(other, val)));
+}
+#endif
+
+#if 0
+/* :nodoc: */
+static VALUE
+nurat_true(VALUE self)
+{
+ return Qtrue;
+}
+#endif
+
/*
* call-seq:
* rat.positive? -> true or false
@@ -1380,16 +1427,16 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
{
VALUE n, b, s;
- if (rb_check_arity(argc, 0, 1) == 0)
+ if (argc == 0)
return (*func)(self);
- n = argv[0];
+ rb_scan_args(argc, argv, "01", &n);
if (!k_integer_p(n))
rb_raise(rb_eTypeError, "not an integer");
b = f_expt10(n);
- s = rb_rational_mul(self, b);
+ s = nurat_mul(self, b);
if (k_float_p(s)) {
if (INT_NEGATIVE_P(n))
@@ -1403,7 +1450,7 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
s = (*func)(s);
- s = rb_rational_div(f_rational_new_bang1(CLASS_OF(self), s), b);
+ s = nurat_div(f_rational_new_bang1(CLASS_OF(self), s), b);
if (RB_TYPE_P(s, T_RATIONAL) && FIX2INT(rb_int_cmp(n, ONE)) < 0)
s = nurat_truncate(s);
@@ -1411,18 +1458,6 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
return s;
}
-VALUE
-rb_rational_floor(VALUE self, int ndigits)
-{
- if (ndigits == 0) {
- return nurat_floor(self);
- }
- else {
- VALUE n = INT2NUM(ndigits);
- return f_round_common(1, &n, self, nurat_floor);
- }
-}
-
/*
* call-seq:
* rat.floor([ndigits]) -> integer or rational
@@ -1555,7 +1590,7 @@ nurat_round_n(int argc, VALUE *argv, VALUE self)
{
VALUE opt;
enum ruby_num_rounding_mode mode = (
- argc = rb_scan_args(argc, argv, "*:", NULL, &opt),
+ argc = rb_scan_args(argc, argv, "*:", NULL, &opt),
rb_num_get_rounding_option(opt));
VALUE (*round_func)(VALUE) = ROUND_FUNC(mode, nurat_round);
return f_round_common(argc, argv, self, round_func);
@@ -1565,9 +1600,6 @@ static double
nurat_to_double(VALUE self)
{
get_dat1(self);
- if (!RB_INTEGER_TYPE_P(dat->num) || !RB_INTEGER_TYPE_P(dat->den)) {
- return NUM2DBL(dat->num) / NUM2DBL(dat->den);
- }
return rb_int_fdiv_double(dat->num, dat->den);
}
@@ -1604,28 +1636,10 @@ nurat_to_r(VALUE self)
}
#define id_ceil rb_intern("ceil")
-static VALUE
-f_ceil(VALUE x)
-{
- if (RB_INTEGER_TYPE_P(x))
- return x;
- if (RB_FLOAT_TYPE_P(x))
- return rb_float_ceil(x, 0);
-
- return rb_funcall(x, id_ceil, 0);
-}
-
-#define id_quo idQuo
-static VALUE
-f_quo(VALUE x, VALUE y)
-{
- if (RB_INTEGER_TYPE_P(x))
- return rb_int_div(x, y);
- if (RB_FLOAT_TYPE_P(x))
- return DBL2NUM(RFLOAT_VALUE(x) / RFLOAT_VALUE(y));
+#define f_ceil(x) rb_funcall((x), id_ceil, 0)
- return rb_funcallv(x, id_quo, 1, &y);
-}
+#define id_quo rb_intern("quo")
+#define f_quo(x,y) rb_funcall((x), id_quo, 1, (y))
#define f_reciprocal(x) f_quo(ONE, (x))
@@ -1736,13 +1750,14 @@ nurat_rationalize(int argc, VALUE *argv, VALUE self)
{
VALUE e, a, b, p, q;
- if (rb_check_arity(argc, 0, 1) == 0)
+ if (argc == 0)
return self;
if (nurat_negative_p(self))
return rb_rational_uminus(nurat_rationalize(argc, argv, rb_rational_uminus(self)));
- e = f_abs(argv[0]);
+ rb_scan_args(argc, argv, "01", &e);
+ e = f_abs(e);
a = f_sub(self, e);
b = f_add(self, e);
@@ -1865,6 +1880,7 @@ nurat_marshal_load(VALUE self, VALUE a)
VALUE num, den;
rb_check_frozen(self);
+ rb_check_trusted(self);
Check_Type(a, T_ARRAY);
if (RARRAY_LEN(a) != 2)
@@ -1887,7 +1903,7 @@ VALUE
rb_rational_reciprocal(VALUE x)
{
get_dat1(x);
- return nurat_convert(CLASS_OF(x), dat->den, dat->num, FALSE);
+ return f_rational_new_no_reduce2(CLASS_OF(x), dat->den, dat->num);
}
/*
@@ -1986,7 +2002,7 @@ rb_rational_den(VALUE rat)
#define id_denominator rb_intern("denominator")
#define f_denominator(x) rb_funcall((x), id_denominator, 0)
-#define id_to_r idTo_r
+#define id_to_r rb_intern("to_r")
#define f_to_r(x) rb_funcall((x), id_to_r, 0)
/*
@@ -2025,12 +2041,8 @@ numeric_denominator(VALUE self)
VALUE
rb_numeric_quo(VALUE x, VALUE y)
{
- if (RB_TYPE_P(x, T_COMPLEX)) {
- return rb_complex_div(x, y);
- }
-
if (RB_FLOAT_TYPE_P(y)) {
- return rb_funcallv(x, idFdiv, 1, &y);
+ return rb_funcall(x, rb_intern("fdiv"), 1, y);
}
if (canonicalization) {
@@ -2039,18 +2051,9 @@ rb_numeric_quo(VALUE x, VALUE y)
else {
x = rb_convert_type(x, T_RATIONAL, "Rational", "to_r");
}
- return rb_rational_div(x, y);
+ return nurat_div(x, y);
}
-VALUE
-rb_rational_canonicalize(VALUE x)
-{
- if (RB_TYPE_P(x, T_RATIONAL)) {
- get_dat1(x);
- if (f_one_p(dat->den)) return dat->num;
- }
- return x;
-}
/*
* call-seq:
@@ -2089,8 +2092,8 @@ static VALUE float_to_r(VALUE self);
*
* See also Float#denominator.
*/
-VALUE
-rb_float_numerator(VALUE self)
+static VALUE
+float_numerator(VALUE self)
{
double d = RFLOAT_VALUE(self);
VALUE r;
@@ -2112,8 +2115,8 @@ rb_float_numerator(VALUE self)
*
* See also Float#numerator.
*/
-VALUE
-rb_float_denominator(VALUE self)
+static VALUE
+float_denominator(VALUE self)
{
double d = RFLOAT_VALUE(self);
VALUE r;
@@ -2148,7 +2151,7 @@ nilclass_to_r(VALUE self)
static VALUE
nilclass_rationalize(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", NULL);
return nilclass_to_r(self);
}
@@ -2177,20 +2180,33 @@ integer_to_r(VALUE self)
static VALUE
integer_rationalize(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 0, 1);
+ rb_scan_args(argc, argv, "01", NULL);
return integer_to_r(self);
}
static void
-float_decode_internal(VALUE self, VALUE *rf, int *n)
+float_decode_internal(VALUE self, VALUE *rf, VALUE *rn)
{
double f;
+ int n;
- f = frexp(RFLOAT_VALUE(self), n);
+ f = frexp(RFLOAT_VALUE(self), &n);
f = ldexp(f, DBL_MANT_DIG);
- *n -= DBL_MANT_DIG;
+ n -= DBL_MANT_DIG;
*rf = rb_dbl2big(f);
+ *rn = INT2FIX(n);
+}
+
+#if 0
+static VALUE
+float_decode(VALUE self)
+{
+ VALUE f, n;
+
+ float_decode_internal(self, &f, &n);
+ return rb_assoc_new(f, n);
}
+#endif
/*
* call-seq:
@@ -2215,17 +2231,20 @@ float_decode_internal(VALUE self, VALUE *rf, int *n)
static VALUE
float_to_r(VALUE self)
{
- VALUE f;
- int n;
+ VALUE f, n;
float_decode_internal(self, &f, &n);
#if FLT_RADIX == 2
- if (n == 0)
- return rb_rational_new1(f);
- if (n > 0)
- return rb_rational_new1(rb_int_lshift(f, INT2FIX(n)));
- n = -n;
- return rb_rational_new2(f, rb_int_lshift(ONE, INT2FIX(n)));
+ {
+ long ln = FIX2LONG(n);
+
+ if (ln == 0)
+ return rb_rational_new1(f);
+ if (ln > 0)
+ return rb_rational_new1(rb_int_lshift(f, n));
+ ln = -ln;
+ return rb_rational_new2(f, rb_int_lshift(ONE, INT2FIX(ln)));
+ }
#else
f = rb_int_mul(f, rb_int_pow(INT2FIX(FLT_RADIX), n));
if (RB_TYPE_P(f, T_RATIONAL))
@@ -2253,26 +2272,33 @@ rb_flt_rationalize_with_prec(VALUE flt, VALUE prec)
VALUE
rb_flt_rationalize(VALUE flt)
{
- VALUE a, b, f, p, q;
- int n;
+ VALUE a, b, f, n, p, q;
float_decode_internal(flt, &f, &n);
- if (INT_ZERO_P(f) || n >= 0)
- return rb_rational_new1(rb_int_lshift(f, INT2FIX(n)));
+ if (INT_ZERO_P(f) || FIX2INT(n) >= 0)
+ return rb_rational_new1(rb_int_lshift(f, n));
+#if FLT_RADIX == 2
+ {
+ VALUE two_times_f, den;
+
+ two_times_f = rb_int_mul(TWO, f);
+ den = rb_int_lshift(ONE, rb_int_minus(ONE, n));
+
+ a = rb_rational_new2(rb_int_minus(two_times_f, ONE), den);
+ b = rb_rational_new2(rb_int_plus(two_times_f, ONE), den);
+ }
+#else
{
VALUE radix_times_f, den;
radix_times_f = rb_int_mul(INT2FIX(FLT_RADIX), f);
-#if FLT_RADIX == 2 && 0
- den = rb_int_lshift(ONE, INT2FIX(1-n));
-#else
- den = rb_int_positive_pow(FLT_RADIX, 1-n);
-#endif
+ den = rb_int_pow(INT2FIX(FLT_RADIX), rb_int_minus(ONE, n));
a = rb_rational_new2(rb_int_minus(radix_times_f, INT2FIX(FLT_RADIX - 1)), den);
b = rb_rational_new2(rb_int_plus(radix_times_f, INT2FIX(FLT_RADIX - 1)), den);
}
+#endif
if (nurat_eqeq_p(a, b))
return float_to_r(flt);
@@ -2298,13 +2324,16 @@ rb_flt_rationalize(VALUE flt)
static VALUE
float_rationalize(int argc, VALUE *argv, VALUE self)
{
+ VALUE e;
double d = RFLOAT_VALUE(self);
if (d < 0.0)
return rb_rational_uminus(float_rationalize(argc, argv, DBL2NUM(-d)));
- if (rb_check_arity(argc, 0, 1)) {
- return rb_flt_rationalize_with_prec(self, argv[0]);
+ rb_scan_args(argc, argv, "01", &e);
+
+ if (argc != 0) {
+ return rb_flt_rationalize_with_prec(self, e);
}
else {
return rb_flt_rationalize(self);
@@ -2350,13 +2379,13 @@ negate_num(VALUE num)
}
static int
-read_num(const char **s, const char *const end, VALUE *num, VALUE *nexp)
+read_num(const char **s, const char *const end, VALUE *num, VALUE *div)
{
VALUE fp = ONE, exp, fn = ZERO, n = ZERO;
int expsign = 0, ok = 0;
char *e;
- *nexp = ZERO;
+ *div = ONE;
*num = ZERO;
if (*s < end && **s != '.') {
n = rb_int_parse_cstr(*s, end-*s, &e, NULL,
@@ -2378,9 +2407,10 @@ read_num(const char **s, const char *const end, VALUE *num, VALUE *nexp)
return 1;
*s = e;
{
- VALUE l = f_expt10(*nexp = SIZET2NUM(count));
+ VALUE l = f_expt10(SIZET2NUM(count));
n = n == ZERO ? fp : rb_int_plus(rb_int_mul(*num, l), fp);
*num = n;
+ *div = l;
fn = SIZET2NUM(count);
}
ok = 1;
@@ -2397,12 +2427,18 @@ read_num(const char **s, const char *const end, VALUE *num, VALUE *nexp)
if (exp != ZERO) {
if (expsign == '-') {
if (fn != ZERO) exp = rb_int_plus(exp, fn);
+ *div = f_expt10(exp);
}
else {
if (fn != ZERO) exp = rb_int_minus(exp, fn);
- exp = negate_num(exp);
+ if (INT_NEGATIVE_P(exp)) {
+ *div = f_expt10(negate_num(exp));
+ }
+ else {
+ *num = rb_int_mul(n, f_expt10(exp));
+ *div = ONE;
+ }
}
- *nexp = exp;
}
}
@@ -2418,65 +2454,44 @@ skip_ws(const char *s, const char *e)
}
static VALUE
-parse_rat(const char *s, const char *const e, int strict, int raise)
+parse_rat(const char *s, const char *const e, int strict)
{
int sign;
- VALUE num, den, nexp, dexp;
+ VALUE num, den, ndiv, ddiv;
s = skip_ws(s, e);
sign = read_sign(&s, e);
- if (!read_num(&s, e, &num, &nexp)) {
+ if (!read_num(&s, e, &num, &ndiv)) {
if (strict) return Qnil;
return canonicalization ? ZERO : nurat_s_alloc(rb_cRational);
}
- den = ONE;
+ nurat_reduce(&num, &ndiv);
+ den = ndiv;
if (s < e && *s == '/') {
s++;
- if (!read_num(&s, e, &den, &dexp)) {
+ if (!read_num(&s, e, &den, &ddiv)) {
if (strict) return Qnil;
- den = ONE;
+ den = ndiv;
}
else if (den == ZERO) {
- if (!raise) return Qnil;
rb_num_zerodiv();
}
else if (strict && skip_ws(s, e) != e) {
return Qnil;
}
else {
- nexp = rb_int_minus(nexp, dexp);
+ nurat_reduce(&den, &ddiv);
nurat_reduce(&num, &den);
+ nurat_reduce(&ndiv, &ddiv);
+ if (ndiv != ONE) den = rb_int_mul(den, ndiv);
+ if (ddiv != ONE) num = rb_int_mul(num, ddiv);
}
}
else if (strict && skip_ws(s, e) != e) {
return Qnil;
}
- if (nexp != ZERO) {
- if (INT_NEGATIVE_P(nexp)) {
- VALUE mul;
- if (!FIXNUM_P(nexp)) {
- overflow:
- return sign == '-' ? DBL2NUM(-HUGE_VAL) : DBL2NUM(HUGE_VAL);
- }
- mul = f_expt10(LONG2NUM(-FIX2LONG(nexp)));
- if (RB_FLOAT_TYPE_P(mul)) goto overflow;
- num = rb_int_mul(num, mul);
- }
- else {
- VALUE div;
- if (!FIXNUM_P(nexp)) {
- underflow:
- return sign == '-' ? DBL2NUM(-0.0) : DBL2NUM(+0.0);
- }
- div = f_expt10(nexp);
- if (RB_FLOAT_TYPE_P(div)) goto underflow;
- den = rb_int_mul(den, div);
- }
- nurat_reduce(&num, &den);
- }
-
if (sign == '-') {
num = negate_num(num);
}
@@ -2487,23 +2502,20 @@ parse_rat(const char *s, const char *const e, int strict, int raise)
}
static VALUE
-string_to_r_strict(VALUE self, int raise)
+string_to_r_strict(VALUE self)
{
VALUE num;
rb_must_asciicompat(self);
- num = parse_rat(RSTRING_PTR(self), RSTRING_END(self), 1, raise);
+ num = parse_rat(RSTRING_PTR(self), RSTRING_END(self), 1);
if (NIL_P(num)) {
- if (!raise) return Qnil;
- rb_raise(rb_eArgError, "invalid value for convert(): %+"PRIsVALUE,
- self);
+ rb_raise(rb_eArgError, "invalid value for convert(): %+"PRIsVALUE,
+ self);
}
- if (RB_FLOAT_TYPE_P(num) && !FLOAT_ZERO_P(num)) {
- if (!raise) return Qnil;
- rb_raise(rb_eFloatDomainError, "Infinity");
- }
+ if (RB_FLOAT_TYPE_P(num))
+ rb_raise(rb_eFloatDomainError, "Infinity");
return num;
}
@@ -2542,9 +2554,9 @@ string_to_r(VALUE self)
rb_must_asciicompat(self);
- num = parse_rat(RSTRING_PTR(self), RSTRING_END(self), 0, TRUE);
+ num = parse_rat(RSTRING_PTR(self), RSTRING_END(self), 0);
- if (RB_FLOAT_TYPE_P(num) && !FLOAT_ZERO_P(num))
+ if (RB_FLOAT_TYPE_P(num))
rb_raise(rb_eFloatDomainError, "Infinity");
return num;
}
@@ -2554,130 +2566,75 @@ rb_cstr_to_rat(const char *s, int strict) /* for complex's internal */
{
VALUE num;
- num = parse_rat(s, s + strlen(s), strict, TRUE);
+ num = parse_rat(s, s + strlen(s), strict);
- if (RB_FLOAT_TYPE_P(num) && !FLOAT_ZERO_P(num))
+ if (RB_FLOAT_TYPE_P(num))
rb_raise(rb_eFloatDomainError, "Infinity");
return num;
}
static VALUE
-to_rational(VALUE val)
+nurat_s_convert(int argc, VALUE *argv, VALUE klass)
{
- return rb_convert_type_with_id(val, T_RATIONAL, "Rational", idTo_r);
-}
+ VALUE a1, a2, backref;
-static VALUE
-nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise)
-{
- VALUE a1 = numv, a2 = denv;
- int state;
+ rb_scan_args(argc, argv, "11", &a1, &a2);
- if (NIL_P(a1) || NIL_P(a2)) {
- if (!raise) return Qnil;
- rb_raise(rb_eTypeError, "can't convert nil into Rational");
- }
+ if (NIL_P(a1) || (argc == 2 && NIL_P(a2)))
+ rb_raise(rb_eTypeError, "can't convert nil into Rational");
if (RB_TYPE_P(a1, T_COMPLEX)) {
- if (k_exact_zero_p(RCOMPLEX(a1)->imag))
- a1 = RCOMPLEX(a1)->real;
+ if (k_exact_zero_p(RCOMPLEX(a1)->imag))
+ a1 = RCOMPLEX(a1)->real;
}
if (RB_TYPE_P(a2, T_COMPLEX)) {
- if (k_exact_zero_p(RCOMPLEX(a2)->imag))
- a2 = RCOMPLEX(a2)->real;
+ if (k_exact_zero_p(RCOMPLEX(a2)->imag))
+ a2 = RCOMPLEX(a2)->real;
}
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
if (RB_FLOAT_TYPE_P(a1)) {
- a1 = float_to_r(a1);
+ a1 = float_to_r(a1);
}
else if (RB_TYPE_P(a1, T_STRING)) {
- a1 = string_to_r_strict(a1, raise);
- if (!raise && NIL_P(a1)) return Qnil;
+ a1 = string_to_r_strict(a1);
}
if (RB_FLOAT_TYPE_P(a2)) {
- a2 = float_to_r(a2);
+ a2 = float_to_r(a2);
}
else if (RB_TYPE_P(a2, T_STRING)) {
- a2 = string_to_r_strict(a2, raise);
- if (!raise && NIL_P(a2)) return Qnil;
+ a2 = string_to_r_strict(a2);
}
+ rb_backref_set(backref);
+
if (RB_TYPE_P(a1, T_RATIONAL)) {
- if (a2 == Qundef || (k_exact_one_p(a2)))
- return a1;
+ if (argc == 1 || (k_exact_one_p(a2)))
+ return a1;
}
- if (a2 == Qundef) {
- if (!k_integer_p(a1)) {
- if (!raise) {
- VALUE result = rb_protect(to_rational, a1, NULL);
- rb_set_errinfo(Qnil);
- return result;
- }
- return to_rational(a1);
- }
+ if (argc == 1) {
+ if (!(k_numeric_p(a1) && k_integer_p(a1)))
+ return rb_convert_type_with_id(a1, T_RATIONAL, "Rational", idTo_r);
}
else {
- if (!k_numeric_p(a1)) {
- if (!raise) {
- a1 = rb_protect(to_rational, a1, &state);
- if (state) {
- rb_set_errinfo(Qnil);
- return Qnil;
- }
- }
- else {
- a1 = rb_check_convert_type_with_id(a1, T_RATIONAL, "Rational", idTo_r);
- }
- }
- if (!k_numeric_p(a2)) {
- if (!raise) {
- a2 = rb_protect(to_rational, a2, &state);
- if (state) {
- rb_set_errinfo(Qnil);
- return Qnil;
- }
- }
- else {
- a2 = rb_check_convert_type_with_id(a2, T_RATIONAL, "Rational", idTo_r);
- }
- }
- if ((k_numeric_p(a1) && k_numeric_p(a2)) &&
- (!f_integer_p(a1) || !f_integer_p(a2)))
- return f_div(a1, a2);
+ if ((k_numeric_p(a1) && k_numeric_p(a2)) &&
+ (!f_integer_p(a1) || !f_integer_p(a2)))
+ return f_div(a1, a2);
}
{
- int argc;
- VALUE argv2[2];
- argv2[0] = a1;
- if (a2 == Qundef) {
- argv2[1] = Qnil;
- argc = 1;
- }
- else {
- if (!k_integer_p(a2) && !raise) return Qnil;
- argv2[1] = a2;
- argc = 2;
- }
- return nurat_s_new(argc, argv2, klass);
+ VALUE argv2[2];
+ argv2[0] = a1;
+ argv2[1] = a2;
+ return nurat_s_new(argc, argv2, klass);
}
}
-static VALUE
-nurat_s_convert(int argc, VALUE *argv, VALUE klass)
-{
- VALUE a1, a2;
-
- if (rb_scan_args(argc, argv, "11", &a1, &a2) == 1) {
- a2 = Qundef;
- }
-
- return nurat_convert(klass, a1, a2, TRUE);
-}
-
/*
* A rational number can be represented as a pair of integer numbers:
* a/b (b>0), where a is the numerator and b is the denominator.
@@ -2727,8 +2684,12 @@ Init_Rational(void)
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
+ assert(fprintf(stderr, "assert() is now active\n"));
+
id_abs = rb_intern("abs");
+ id_idiv = rb_intern("div");
id_integer_p = rb_intern("integer?");
+ id_to_i = rb_intern("to_i");
id_i_num = rb_intern("@numerator");
id_i_den = rb_intern("@denominator");
@@ -2737,7 +2698,12 @@ Init_Rational(void)
rb_define_alloc_func(rb_cRational, nurat_s_alloc);
rb_undef_method(CLASS_OF(rb_cRational), "allocate");
+#if 0
+ rb_define_private_method(CLASS_OF(rb_cRational), "new!", nurat_s_new_bang, -1);
+ rb_define_private_method(CLASS_OF(rb_cRational), "new", nurat_s_new, -1);
+#else
rb_undef_method(CLASS_OF(rb_cRational), "new");
+#endif
rb_define_global_function("Rational", nurat_f_rational, -1);
@@ -2746,10 +2712,10 @@ Init_Rational(void)
rb_define_method(rb_cRational, "-@", rb_rational_uminus, 0);
rb_define_method(rb_cRational, "+", rb_rational_plus, 1);
- rb_define_method(rb_cRational, "-", rb_rational_minus, 1);
- rb_define_method(rb_cRational, "*", rb_rational_mul, 1);
- rb_define_method(rb_cRational, "/", rb_rational_div, 1);
- rb_define_method(rb_cRational, "quo", rb_rational_div, 1);
+ rb_define_method(rb_cRational, "-", nurat_sub, 1);
+ rb_define_method(rb_cRational, "*", nurat_mul, 1);
+ rb_define_method(rb_cRational, "/", nurat_div, 1);
+ rb_define_method(rb_cRational, "quo", nurat_div, 1);
rb_define_method(rb_cRational, "fdiv", nurat_fdiv, 1);
rb_define_method(rb_cRational, "**", nurat_expt, 1);
@@ -2757,6 +2723,15 @@ Init_Rational(void)
rb_define_method(rb_cRational, "==", nurat_eqeq_p, 1);
rb_define_method(rb_cRational, "coerce", nurat_coerce, 1);
+#if 0
+ rb_define_method(rb_cRational, "quot", nurat_quot, 1);
+ rb_define_method(rb_cRational, "quotrem", nurat_quotrem, 1);
+#endif
+
+#if 0
+ rb_define_method(rb_cRational, "rational?", nurat_true, 0);
+ rb_define_method(rb_cRational, "exact?", nurat_true, 0);
+#endif
rb_define_method(rb_cRational, "positive?", nurat_positive_p, 0);
rb_define_method(rb_cRational, "negative?", nurat_negative_p, 0);
rb_define_method(rb_cRational, "abs", rb_rational_abs, 0);
@@ -2778,7 +2753,6 @@ Init_Rational(void)
rb_define_method(rb_cRational, "inspect", nurat_inspect, 0);
rb_define_private_method(rb_cRational, "marshal_dump", nurat_marshal_dump, 0);
- /* :nodoc: */
compat = rb_define_class_under(rb_cRational, "compatible", rb_cObject);
rb_define_private_method(compat, "marshal_load", nurat_marshal_load, 1);
rb_marshal_define_compat(rb_cRational, compat, nurat_dumper, nurat_loader);
@@ -2796,8 +2770,8 @@ Init_Rational(void)
rb_define_method(rb_cInteger, "numerator", integer_numerator, 0);
rb_define_method(rb_cInteger, "denominator", integer_denominator, 0);
- rb_define_method(rb_cFloat, "numerator", rb_float_numerator, 0);
- rb_define_method(rb_cFloat, "denominator", rb_float_denominator, 0);
+ rb_define_method(rb_cFloat, "numerator", float_numerator, 0);
+ rb_define_method(rb_cFloat, "denominator", float_denominator, 0);
rb_define_method(rb_cNilClass, "to_r", nilclass_to_r, 0);
rb_define_method(rb_cNilClass, "rationalize", nilclass_rationalize, -1);
@@ -2812,3 +2786,9 @@ Init_Rational(void)
rb_provide("rational.so"); /* for backward compatibility */
}
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
diff --git a/re.c b/re.c
index 718a66b031..fdccea434a 100644
--- a/re.c
+++ b/re.c
@@ -9,10 +9,9 @@
**********************************************************************/
-#include "ruby/encoding.h"
+#include "internal.h"
#include "ruby/re.h"
#include "ruby/util.h"
-#include "internal.h"
#include "regint.h"
#include "encindex.h"
#include <ctype.h>
@@ -95,7 +94,7 @@ rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n
{
const unsigned char *y;
- if ((y = memmem(ys, n, xs, m)) != NULL)
+ if (y = memmem(ys, n, xs, m))
return y - ys;
else
return -1;
@@ -106,7 +105,13 @@ rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n
{
const unsigned char *x = xs, *xe = xs + m;
const unsigned char *y = ys, *ye = ys + n;
-#define VALUE_MAX ((VALUE)~(VALUE)0)
+#ifndef VALUE_MAX
+# if SIZEOF_VALUE == 8
+# define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL
+# elif SIZEOF_VALUE == 4
+# define VALUE_MAX 0xFFFFFFFFUL
+# endif
+#endif
VALUE hx, hy, mask = VALUE_MAX >> ((SIZEOF_VALUE - m) * CHAR_BIT);
if (m > SIZEOF_VALUE)
@@ -351,7 +356,7 @@ rb_reg_check(VALUE re)
static void
rb_reg_expr_str(VALUE str, const char *s, long len,
- rb_encoding *enc, rb_encoding *resenc, int term)
+ rb_encoding *enc, rb_encoding *resenc)
{
const char *p, *pend;
int cr = ENC_CODERANGE_UNKNOWN;
@@ -372,7 +377,7 @@ rb_reg_expr_str(VALUE str, const char *s, long len,
break;
}
}
- else if (c != term && rb_enc_isprint(c, enc)) {
+ else if (c != '/' && rb_enc_isprint(c, enc)) {
p += clen;
}
else {
@@ -399,6 +404,11 @@ rb_reg_expr_str(VALUE str, const char *s, long len,
p += n;
continue;
}
+ else if (c == '/') {
+ char c = '\\';
+ rb_str_buf_cat(str, &c, 1);
+ rb_str_buf_cat(str, p, clen);
+ }
else if (c == -1) {
clen = rb_enc_precise_mbclen(p, pend, enc);
if (!MBCLEN_CHARFOUND_P(clen)) {
@@ -415,11 +425,6 @@ rb_reg_expr_str(VALUE str, const char *s, long len,
rb_str_buf_cat(str, p, clen);
}
}
- else if (c == term) {
- char c = '\\';
- rb_str_buf_cat(str, &c, 1);
- rb_str_buf_cat(str, p, clen);
- }
else if (rb_enc_isprint(c, enc)) {
rb_str_buf_cat(str, p, clen);
}
@@ -452,7 +457,7 @@ rb_reg_desc(const char *s, long len, VALUE re)
else {
rb_enc_associate(str, rb_usascii_encoding());
}
- rb_reg_expr_str(str, s, len, enc, resenc, '/');
+ rb_reg_expr_str(str, s, len, enc, resenc);
rb_str_buf_cat2(str, "/");
if (re) {
char opts[4];
@@ -462,6 +467,7 @@ rb_reg_desc(const char *s, long len, VALUE re)
if (RBASIC(re)->flags & REG_ENCODING_NONE)
rb_str_buf_cat2(str, "n");
}
+ OBJ_INFECT(str, re);
return str;
}
@@ -487,6 +493,7 @@ rb_reg_source(VALUE re)
rb_reg_check(re);
str = rb_str_dup(RREGEXP_SRC(re));
+ if (OBJ_TAINTED(re)) OBJ_TAINT(str);
return str;
}
@@ -511,7 +518,6 @@ rb_reg_inspect(VALUE re)
return rb_reg_desc(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), re);
}
-static VALUE rb_reg_str_with_term(VALUE re, int term);
/*
* call-seq:
@@ -519,11 +525,11 @@ static VALUE rb_reg_str_with_term(VALUE re, int term);
*
* Returns a string containing the regular expression and its options (using the
* <code>(?opts:source)</code> notation. This string can be fed back in to
- * Regexp::new to a regular expression with the same semantics as the
- * original. (However, <code>Regexp#==</code> may not return true
- * when comparing the two, as the source of the regular expression
- * itself may differ, as the example shows). Regexp#inspect produces
- * a generally more readable version of <i>rxp</i>.
+ * <code>Regexp::new</code> to a regular expression with the same semantics as
+ * the original. (However, <code>Regexp#==</code> may not return true when
+ * comparing the two, as the source of the regular expression itself may
+ * differ, as the example shows). <code>Regexp#inspect</code> produces a
+ * generally more readable version of <i>rxp</i>.
*
* r1 = /ab+c/ix #=> /ab+c/ix
* s1 = r1.to_s #=> "(?ix-m:ab+c)"
@@ -536,12 +542,6 @@ static VALUE rb_reg_str_with_term(VALUE re, int term);
static VALUE
rb_reg_to_s(VALUE re)
{
- return rb_reg_str_with_term(re, '/');
-}
-
-static VALUE
-rb_reg_str_with_term(VALUE re, int term)
-{
int options, opt;
const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
long len;
@@ -620,7 +620,7 @@ rb_reg_str_with_term(VALUE re, int term)
rb_str_buf_cat2(str, ":");
if (rb_enc_asciicompat(enc)) {
- rb_reg_expr_str(str, (char*)ptr, len, enc, NULL, term);
+ rb_reg_expr_str(str, (char*)ptr, len, enc, NULL);
rb_str_buf_cat2(str, ")");
}
else {
@@ -640,16 +640,15 @@ rb_reg_str_with_term(VALUE re, int term)
memcpy(paren, s, n);
rb_str_resize(str, RSTRING_LEN(str) - n);
- rb_reg_expr_str(str, (char*)ptr, len, enc, NULL, term);
+ rb_reg_expr_str(str, (char*)ptr, len, enc, NULL);
rb_str_buf_cat(str, paren, n);
}
rb_enc_copy(str, re);
+ OBJ_INFECT(str, re);
return str;
}
-NORETURN(static void rb_reg_raise(const char *s, long len, const char *err, VALUE re));
-
static void
rb_reg_raise(const char *s, long len, const char *err, VALUE re)
{
@@ -668,15 +667,13 @@ rb_enc_reg_error_desc(const char *s, long len, rb_encoding *enc, int options, co
rb_enc_associate(desc, enc);
rb_str_buf_cat2(desc, ": /");
- rb_reg_expr_str(desc, s, len, enc, resenc, '/');
+ rb_reg_expr_str(desc, s, len, enc, resenc);
opts[0] = '/';
option_to_str(opts + 1, options);
rb_str_buf_cat2(desc, opts);
return rb_exc_new3(rb_eRegexpError, desc);
}
-NORETURN(static void rb_enc_reg_raise(const char *s, long len, rb_encoding *enc, int options, const char *err));
-
static void
rb_enc_reg_raise(const char *s, long len, rb_encoding *enc, int options, const char *err)
{
@@ -690,8 +687,6 @@ rb_reg_error_desc(VALUE str, int options, const char *err)
rb_enc_get(str), options, err);
}
-NORETURN(static void rb_reg_raise_str(VALUE str, int options, const char *err));
-
static void
rb_reg_raise_str(VALUE str, int options, const char *err)
{
@@ -723,11 +718,11 @@ rb_reg_casefold_p(VALUE re)
* call-seq:
* rxp.options -> integer
*
- * Returns the set of bits corresponding to the options used when
- * creating this Regexp (see Regexp::new for details. Note that
- * additional bits may be set in the returned options: these are used
- * internally by the regular expression code. These extra bits are
- * ignored if the options are passed to Regexp::new.
+ * Returns the set of bits corresponding to the options used when creating this
+ * Regexp (see <code>Regexp::new</code> for details. Note that additional bits
+ * may be set in the returned options: these are used internally by the regular
+ * expression code. These extra bits are ignored if the options are passed to
+ * <code>Regexp::new</code>.
*
* Regexp::IGNORECASE #=> 1
* Regexp::EXTENDED #=> 2
@@ -881,50 +876,13 @@ make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_bu
/*
* Document-class: MatchData
*
- * MatchData encapsulates the result of matching a Regexp against
- * string. It is returned by Regexp#match and String#match, and also
- * stored in a global variable returned by Regexp.last_match.
- *
- * Usage:
- *
- * url = 'https://docs.ruby-lang.org/en/2.5.0/MatchData.html'
- * m = url.match(/(\d\.?)+/) # => #<MatchData "2.5.0" 1:"0">
- * m.string # => "https://docs.ruby-lang.org/en/2.5.0/MatchData.html"
- * m.regexp # => /(\d\.?)+/
- * # entire matched substring:
- * m[0] # => "2.5.0"
- *
- * # Working with unnamed captures
- * m = url.match(%r{([^/]+)/([^/]+)\.html$})
- * m.captures # => ["2.5.0", "MatchData"]
- * m[1] # => "2.5.0"
- * m.values_at(1, 2) # => ["2.5.0", "MatchData"]
- *
- * # Working with named captures
- * m = url.match(%r{(?<version>[^/]+)/(?<module>[^/]+)\.html$})
- * m.captures # => ["2.5.0", "MatchData"]
- * m.named_captures # => {"version"=>"2.5.0", "module"=>"MatchData"}
- * m[:version] # => "2.5.0"
- * m.values_at(:version, :module)
- * # => ["2.5.0", "MatchData"]
- * # Numerical indexes are working, too
- * m[1] # => "2.5.0"
- * m.values_at(1, 2) # => ["2.5.0", "MatchData"]
- *
- * == Global variables equivalence
- *
- * Parts of last MatchData (returned by Regexp.last_match) are also
- * aliased as global variables:
- *
- * * <code>$~</code> is Regexp.last_match;
- * * <code>$&</code> is Regexp.last_match<code>[0]</code>;
- * * <code>$1</code>, <code>$2</code>, and so on are
- * Regexp.last_match<code>[i]</code> (captures by number);
- * * <code>$`</code> is Regexp.last_match<code>.pre_match</code>;
- * * <code>$'</code> is Regexp.last_match<code>.post_match</code>;
- * * <code>$+</code> is Regexp.last_match<code>[-1]</code> (the last capture).
- *
- * See also "Special global variables" section in Regexp documentation.
+ * <code>MatchData</code> is the type of the special variable <code>$~</code>,
+ * and is the type of the object returned by <code>Regexp#match</code> and
+ * <code>Regexp.last_match</code>. It encapsulates all the results of a pattern
+ * match, results normally accessed through the special variables
+ * <code>$&</code>, <code>$'</code>, <code>$`</code>, <code>$1</code>,
+ * <code>$2</code>, and so on.
+ *
*/
VALUE rb_cMatch;
@@ -980,7 +938,7 @@ update_char_offset(VALUE match)
rb_encoding *enc;
pair_t *pairs;
- if (rm->char_offset_num_allocated)
+ if (rm->char_offset_updated)
return;
regs = &rm->regs;
@@ -997,6 +955,7 @@ update_char_offset(VALUE match)
rm->char_offset[i].beg = BEG(i);
rm->char_offset[i].end = END(i);
}
+ rm->char_offset_updated = 1;
return;
}
@@ -1035,13 +994,15 @@ update_char_offset(VALUE match)
found = bsearch(&key, pairs, num_pos, sizeof(pair_t), pair_byte_cmp);
rm->char_offset[i].end = found->char_pos;
}
+
+ rm->char_offset_updated = 1;
}
static void
match_check(VALUE match)
{
if (!RMATCH(match)->regexp) {
- rb_raise(rb_eTypeError, "uninitialized MatchData");
+ rb_raise(rb_eTypeError, "uninitialized Match");
}
}
@@ -1060,13 +1021,17 @@ match_init_copy(VALUE obj, VALUE orig)
if (rb_reg_region_copy(&rm->regs, RMATCH_REGS(orig)))
rb_memerror();
- if (RMATCH(orig)->rmatch->char_offset_num_allocated) {
+ if (!RMATCH(orig)->rmatch->char_offset_updated) {
+ rm->char_offset_updated = 0;
+ }
+ else {
if (rm->char_offset_num_allocated < rm->regs.num_regs) {
REALLOC_N(rm->char_offset, struct rmatch_offset, rm->regs.num_regs);
rm->char_offset_num_allocated = rm->regs.num_regs;
}
MEMCPY(rm->char_offset, RMATCH(orig)->rmatch->char_offset,
struct rmatch_offset, rm->regs.num_regs);
+ rm->char_offset_updated = 1;
RB_GC_GUARD(orig);
}
@@ -1141,14 +1106,6 @@ match_size(VALUE match)
}
static int name_to_backref_number(struct re_registers *, VALUE, const char*, const char*);
-NORETURN(static void name_to_backref_error(VALUE name));
-
-static void
-name_to_backref_error(VALUE name)
-{
- rb_raise(rb_eIndexError, "undefined group name reference: % "PRIsVALUE,
- name);
-}
static int
match_backref_number(VALUE match, VALUE backref)
@@ -1168,10 +1125,10 @@ match_backref_number(VALUE match, VALUE backref)
}
name = StringValueCStr(backref);
- num = name_to_backref_number(regs, regexp, name, name + RSTRING_LEN(backref));
+ num = name_to_backref_number(regs, regexp, name, name + strlen(name));
if (num < 1) {
- name_to_backref_error(backref);
+ rb_raise(rb_eIndexError, "undefined group name reference: %s", name);
}
return num;
@@ -1297,12 +1254,6 @@ rb_match_busy(VALUE match)
FL_SET(match, MATCH_BUSY);
}
-void
-rb_match_unbusy(VALUE match)
-{
- FL_UNSET(match, MATCH_BUSY);
-}
-
int
rb_match_count(VALUE match)
{
@@ -1338,10 +1289,11 @@ match_set_string(VALUE m, VALUE string, long pos, long len)
match->str = string;
match->regexp = Qnil;
- int err = onig_region_resize(&rmatch->regs, 1);
- if (err) rb_memerror();
+ onig_region_resize(&rmatch->regs, 1);
rmatch->regs.beg[0] = pos;
rmatch->regs.end[0] = pos + len;
+ rmatch->char_offset_updated = 0;
+ OBJ_INFECT(match, string);
}
void
@@ -1397,7 +1349,6 @@ static VALUE
rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
rb_encoding **fixed_enc, onig_errmsg_buffer err);
-NORETURN(static void reg_enc_error(VALUE re, VALUE str));
static void
reg_enc_error(VALUE re, VALUE str)
@@ -1605,14 +1556,21 @@ rb_reg_search0(VALUE re, VALUE str, long pos, int reverse, int set_backref_str)
onig_region_free(regs, 0);
if (err) rb_memerror();
}
+ else {
+ FL_UNSET(match, FL_TAINT);
+ }
if (set_backref_str) {
RMATCH(match)->str = rb_str_new4(str);
+ OBJ_INFECT(match, str);
}
RMATCH(match)->regexp = re;
+ RMATCH(match)->rmatch->char_offset_updated = 0;
rb_backref_set(match);
+ OBJ_INFECT(match, re);
+
return result;
}
@@ -1683,12 +1641,19 @@ rb_reg_start_with_p(VALUE re, VALUE str)
onig_region_free(regs, 0);
if (err) rb_memerror();
}
+ else {
+ FL_UNSET(match, FL_TAINT);
+ }
RMATCH(match)->str = rb_str_new4(str);
+ OBJ_INFECT(match, str);
RMATCH(match)->regexp = re;
+ RMATCH(match)->rmatch->char_offset_updated = 0;
rb_backref_set(match);
+ OBJ_INFECT(match, re);
+
return true;
}
@@ -1732,6 +1697,7 @@ rb_reg_nth_match(int nth, VALUE match)
end = END(nth);
len = end - start;
str = rb_str_subseq(RMATCH(match)->str, start, len);
+ OBJ_INFECT(str, match);
return str;
}
@@ -1764,6 +1730,7 @@ rb_reg_match_pre(VALUE match)
regs = RMATCH_REGS(match);
if (BEG(0) == -1) return Qnil;
str = rb_str_subseq(RMATCH(match)->str, 0, BEG(0));
+ if (OBJ_TAINTED(match)) OBJ_TAINT(str);
return str;
}
@@ -1793,6 +1760,7 @@ rb_reg_match_post(VALUE match)
str = RMATCH(match)->str;
pos = END(0);
str = rb_str_subseq(str, pos, RSTRING_LEN(str) - pos);
+ if (OBJ_TAINTED(match)) OBJ_TAINT(str);
return str;
}
@@ -1814,25 +1782,25 @@ rb_reg_match_last(VALUE match)
}
static VALUE
-last_match_getter(ID _x, VALUE *_y)
+last_match_getter(void)
{
return rb_reg_last_match(rb_backref_get());
}
static VALUE
-prematch_getter(ID _x, VALUE *_y)
+prematch_getter(void)
{
return rb_reg_match_pre(rb_backref_get());
}
static VALUE
-postmatch_getter(ID _x, VALUE *_y)
+postmatch_getter(void)
{
return rb_reg_match_post(rb_backref_get());
}
static VALUE
-last_paren_match_getter(ID _x, VALUE *_y)
+last_paren_match_getter(void)
{
return rb_reg_match_last(rb_backref_get());
}
@@ -1844,6 +1812,7 @@ match_array(VALUE match, int start)
VALUE ary;
VALUE target;
int i;
+ int taint = OBJ_TAINTED(match);
match_check(match);
regs = RMATCH_REGS(match);
@@ -1856,6 +1825,7 @@ match_array(VALUE match, int start)
}
else {
VALUE str = rb_str_subseq(target, regs->beg[i], regs->end[i]-regs->beg[i]);
+ if (taint) OBJ_TAINT(str);
rb_ary_push(ary, str);
}
}
@@ -1918,6 +1888,14 @@ name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name
(const unsigned char *)name, (const unsigned char *)name_end, regs);
}
+NORETURN(static void name_to_backref_error(VALUE name));
+static void
+name_to_backref_error(VALUE name)
+{
+ rb_raise(rb_eIndexError, "undefined group name reference: % "PRIsVALUE,
+ name);
+}
+
#define NAME_TO_NUMBER(regs, re, name, name_ptr, name_end) \
(NIL_P(re) ? 0 : \
!rb_enc_compatible(RREGEXP_SRC(re), (name)) ? 0 : \
@@ -1985,12 +1963,12 @@ match_ary_aref(VALUE match, VALUE idx, VALUE result)
* mtch[range] -> array
* mtch[name] -> str or nil
*
- * Match Reference -- MatchData acts as an array, and may be accessed
- * using the normal array indexing techniques. <code>mtch[0]</code>
- * is equivalent to the special variable <code>$&</code>, and returns
- * the entire matched string. <code>mtch[1]</code>,
- * <code>mtch[2]</code>, and so on return the values of the matched
- * backreferences (portions of the pattern between parentheses).
+ * Match Reference -- <code>MatchData</code> acts as an array, and may be
+ * accessed using the normal array indexing techniques. <code>mtch[0]</code>
+ * is equivalent to the special variable <code>$&</code>, and returns the
+ * entire matched string. <code>mtch[1]</code>, <code>mtch[2]</code>, and so
+ * on return the values of the matched backreferences (portions of the
+ * pattern between parentheses).
*
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m #=> #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
@@ -2051,7 +2029,7 @@ match_aref(int argc, VALUE *argv, VALUE match)
/*
* call-seq:
*
- * mtch.values_at(index, ...) -> array
+ * mtch.values_at([index]*) -> array
*
* Uses each <i>index</i> to access the matching values, returning an array of
* the corresponding matches.
@@ -2109,6 +2087,8 @@ match_to_s(VALUE match)
match_check(match);
if (NIL_P(str)) str = rb_str_new(0,0);
+ if (OBJ_TAINTED(match)) OBJ_TAINT(str);
+ if (OBJ_TAINTED(RMATCH(match)->str)) OBJ_TAINT(str);
return str;
}
@@ -2401,8 +2381,7 @@ unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc,
{
const char *p = *pp;
int chmaxlen = rb_enc_mbmaxlen(enc);
- unsigned char *area = ALLOCA_N(unsigned char, chmaxlen);
- char *chbuf = (char *)area;
+ char *chbuf = ALLOCA_N(char, chmaxlen);
int chlen = 0;
int byte;
int l;
@@ -2414,14 +2393,14 @@ unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc,
return -1;
}
- area[chlen++] = byte;
+ chbuf[chlen++] = byte;
while (chlen < chmaxlen &&
MBCLEN_NEEDMORE_P(rb_enc_precise_mbclen(chbuf, chbuf+chlen, enc))) {
byte = read_escaped_byte(&p, end, err);
if (byte == -1) {
return -1;
}
- area[chlen++] = byte;
+ chbuf[chlen++] = byte;
}
l = rb_enc_precise_mbclen(chbuf, chbuf+chlen, enc);
@@ -2429,7 +2408,7 @@ unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc,
errcpy(err, "invalid multibyte escape");
return -1;
}
- if (1 < chlen || (area[0] & 0x80)) {
+ if (1 < chlen || (chbuf[0] & 0x80)) {
rb_str_buf_cat(buf, chbuf, chlen);
if (*encp == 0)
@@ -2441,7 +2420,7 @@ unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc,
}
else {
char escbuf[5];
- snprintf(escbuf, sizeof(escbuf), "\\x%02X", area[0]&0xff);
+ snprintf(escbuf, sizeof(escbuf), "\\x%02X", chbuf[0]&0xff);
rb_str_buf_cat(buf, escbuf, 4);
}
*pp = p;
@@ -2551,19 +2530,17 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
VALUE buf, rb_encoding **encp, int *has_property,
onig_errmsg_buffer err)
{
- unsigned char c;
+ char c;
char smallbuf[2];
while (p < end) {
int chlen = rb_enc_precise_mbclen(p, end, enc);
if (!MBCLEN_CHARFOUND_P(chlen)) {
- invalid_multibyte:
errcpy(err, "invalid multibyte character");
return -1;
}
chlen = MBCLEN_CHARFOUND_LEN(chlen);
if (1 < chlen || (*p & 0x80)) {
- multibyte:
rb_str_buf_cat(buf, p, chlen);
p += chlen;
if (*encp == 0)
@@ -2581,16 +2558,6 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
errcpy(err, "too short escape sequence");
return -1;
}
- chlen = rb_enc_precise_mbclen(p, end, enc);
- if (!MBCLEN_CHARFOUND_P(chlen)) {
- goto invalid_multibyte;
- }
- if ((chlen = MBCLEN_CHARFOUND_LEN(chlen)) > 1) {
- /* include the previous backslash */
- --p;
- ++chlen;
- goto multibyte;
- }
switch (c = *p++) {
case '1': case '2': case '3':
case '4': case '5': case '6': case '7': /* \O, \OO, \OOO or backref */
@@ -2614,9 +2581,8 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
p = p-2;
if (enc == rb_usascii_encoding()) {
const char *pbeg = p;
- int byte = read_escaped_byte(&p, end, err);
- if (byte == -1) return -1;
- c = byte;
+ c = read_escaped_byte(&p, end, err);
+ if (c == (char)-1) return -1;
rb_str_buf_cat(buf, pbeg, p-pbeg);
}
else {
@@ -2665,7 +2631,7 @@ escape_asis:
break;
default:
- rb_str_buf_cat(buf, (char *)&c, 1);
+ rb_str_buf_cat(buf, &c, 1);
break;
}
}
@@ -2869,6 +2835,7 @@ rb_reg_initialize_str(VALUE obj, VALUE str, int options, onig_errmsg_buffer err,
}
ret = rb_reg_initialize(obj, RSTRING_PTR(str), RSTRING_LEN(str), enc,
options, err, sourcefile, sourceline);
+ OBJ_INFECT(obj, str);
if (ret == 0) reg_set_source(obj, str, str_enc);
return ret;
}
@@ -2923,7 +2890,7 @@ rb_reg_init_str_enc(VALUE re, VALUE s, rb_encoding *enc, int options)
return re;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_reg_new_ary(VALUE ary, int opt)
{
return rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
@@ -3097,11 +3064,8 @@ reg_operand(VALUE s, int check)
if (SYMBOL_P(s)) {
return rb_sym2str(s);
}
- else if (RB_TYPE_P(s, T_STRING)) {
- return s;
- }
else {
- return check ? rb_str_to_str(s) : rb_check_string_type(s);
+ return (check ? rb_str_to_str : rb_check_string_type)(s);
}
}
@@ -3260,11 +3224,11 @@ rb_reg_match2(VALUE re)
* rxp.match(str) -> matchdata or nil
* rxp.match(str,pos) -> matchdata or nil
*
- * Returns a MatchData object describing the match, or
- * <code>nil</code> if there was no match. This is equivalent to
- * retrieving the value of the special variable <code>$~</code>
- * following a normal match. If the second parameter is present, it
- * specifies the position in the string to begin the search.
+ * Returns a <code>MatchData</code> object describing the match, or
+ * <code>nil</code> if there was no match. This is equivalent to retrieving the
+ * value of the special variable <code>$~</code> following a normal match.
+ * If the second parameter is present, it specifies the position in the string
+ * to begin the search.
*
* /(.)(.)(.)/.match("abc")[2] #=> "b"
* /(.)(.)/.match("abc", 1)[2] #=> "c"
@@ -3391,7 +3355,7 @@ rb_reg_match_p(VALUE re, VALUE str, long pos)
/*
* Document-method: compile
*
- * Alias for Regexp.new
+ * Alias for <code>Regexp.new</code>
*/
/*
@@ -3551,6 +3515,7 @@ rb_reg_quote(VALUE str)
t += rb_enc_mbcput(c, t, enc);
}
rb_str_resize(tmp, t - RSTRING_PTR(tmp));
+ OBJ_INFECT(tmp, str);
return tmp;
}
@@ -3561,8 +3526,8 @@ rb_reg_quote(VALUE str)
* Regexp.quote(str) -> string
*
* Escapes any characters that would have special meaning in a regular
- * expression. Returns a new escaped string with the same or compatible
- * encoding. For any string,
+ * expression. Returns a new escaped string, or self if no characters are
+ * escaped. For any string,
* <code>Regexp.new(Regexp.escape(<i>str</i>))=~<i>str</i></code> will be true.
*
* Regexp.escape('\*?{}.') #=> \\\*\?\{\}\.
@@ -3673,7 +3638,7 @@ rb_reg_s_union(VALUE self, VALUE args0)
else {
has_asciionly = 1;
}
- v = rb_reg_str_with_term(v, -1);
+ v = rb_reg_to_s(v);
}
else {
rb_encoding *enc;
@@ -3735,12 +3700,11 @@ rb_reg_s_union(VALUE self, VALUE args0)
* Regexp.union(pat1, pat2, ...) -> new_regexp
* Regexp.union(pats_ary) -> new_regexp
*
- * Return a Regexp object that is the union of the given
- * <em>pattern</em>s, i.e., will match any of its parts. The
- * <em>pattern</em>s can be Regexp objects, in which case their
- * options will be preserved, or Strings. If no patterns are given,
- * returns <code>/(?!)/</code>. The behavior is unspecified if any
- * given <em>pattern</em> contains capture.
+ * Return a <code>Regexp</code> object that is the union of the given
+ * <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s
+ * can be Regexp objects, in which case their options will be preserved, or
+ * Strings. If no patterns are given, returns <code>/(?!)/</code>.
+ * The behavior is unspecified if any given <em>pattern</em> contains capture.
*
* Regexp.union #=> /(?!)/
* Regexp.union("penzance") #=> /penzance/
@@ -3896,27 +3860,27 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
}
static VALUE
-kcode_getter(ID _x, VALUE *_y)
+kcode_getter(void)
{
rb_warn("variable $KCODE is no longer effective");
return Qnil;
}
static void
-kcode_setter(VALUE val, ID id, VALUE *_)
+kcode_setter(VALUE val, ID id)
{
rb_warn("variable $KCODE is no longer effective; ignored");
}
static VALUE
-ignorecase_getter(ID _x, VALUE *_y)
+ignorecase_getter(void)
{
rb_warn("variable $= is no longer effective");
return Qfalse;
}
static void
-ignorecase_setter(VALUE val, ID id, VALUE *_)
+ignorecase_setter(VALUE val, ID id)
{
rb_warn("variable $= is no longer effective; ignored");
}
@@ -3931,14 +3895,8 @@ match_getter(void)
return match;
}
-static VALUE
-get_LAST_MATCH_INFO(ID _x, VALUE *_y)
-{
- return match_getter();
-}
-
static void
-match_setter(VALUE val, ID _x, VALUE *_y)
+match_setter(VALUE val)
{
if (!NIL_P(val)) {
Check_Type(val, T_MATCH);
@@ -3975,13 +3933,15 @@ match_setter(VALUE val, ID _x, VALUE *_y)
*/
static VALUE
-rb_reg_s_last_match(int argc, VALUE *argv, VALUE _)
+rb_reg_s_last_match(int argc, VALUE *argv)
{
- if (rb_check_arity(argc, 0, 1) == 1) {
+ VALUE nth;
+
+ if (argc > 0 && rb_scan_args(argc, argv, "01", &nth) == 1) {
VALUE match = rb_backref_get();
int n;
if (NIL_P(match)) return Qnil;
- n = match_backref_number(match, argv[0]);
+ n = match_backref_number(match, nth);
return rb_reg_nth_match(n, match);
}
return match_getter();
@@ -4008,9 +3968,9 @@ re_warn(const char *s)
/*
* Document-class: Regexp
*
- * A Regexp holds a regular expression, used to match a pattern
- * against strings. Regexps are created using the <code>/.../</code>
- * and <code>%r{...}</code> literals, and by the Regexp::new
+ * A <code>Regexp</code> holds a regular expression, used to match a pattern
+ * against strings. Regexps are created using the <code>/.../</code> and
+ * <code>%r{...}</code> literals, and by the <code>Regexp::new</code>
* constructor.
*
* :include: doc/regexp.rdoc
@@ -4025,7 +3985,7 @@ Init_Regexp(void)
onig_set_warn_func(re_warn);
onig_set_verb_warn_func(re_warn);
- rb_define_virtual_variable("$~", get_LAST_MATCH_INFO, match_setter);
+ rb_define_virtual_variable("$~", match_getter, match_setter);
rb_define_virtual_variable("$&", last_match_getter, 0);
rb_define_virtual_variable("$`", prematch_getter, 0);
rb_define_virtual_variable("$'", postmatch_getter, 0);
@@ -4080,7 +4040,6 @@ Init_Regexp(void)
rb_cMatch = rb_define_class("MatchData", rb_cObject);
rb_define_alloc_func(rb_cMatch, match_alloc);
rb_undef_method(CLASS_OF(rb_cMatch), "new");
- rb_undef_method(CLASS_OF(rb_cMatch), "allocate");
rb_define_method(rb_cMatch, "initialize_copy", match_init_copy, 1);
rb_define_method(rb_cMatch, "regexp", match_regexp, 0);
diff --git a/regcomp.c b/regcomp.c
index 00d3746348..59b1f40d46 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -772,7 +772,7 @@ compile_length_quantifier_node(QtfrNode* qn, regex_t* reg)
}
}
else if (qn->upper == 0) {
- if (qn->is_referred != 0) /* /(?<n>..){0}/ */
+ if (qn->is_refered != 0) /* /(?<n>..){0}/ */
len = SIZE_OP_JUMP + tlen;
else
len = 0;
@@ -901,7 +901,7 @@ compile_quantifier_node(QtfrNode* qn, regex_t* reg)
}
}
else if (qn->upper == 0) {
- if (qn->is_referred != 0) { /* /(?<n>..){0}/ */
+ if (qn->is_refered != 0) { /* /(?<n>..){0}/ */
r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
if (r) return r;
r = compile_tree(qn->target, reg);
@@ -1005,7 +1005,7 @@ compile_length_quantifier_node(QtfrNode* qn, regex_t* reg)
else
len += SIZE_OP_JUMP + mod_tlen + SIZE_OP_PUSH;
}
- else if (qn->upper == 0 && qn->is_referred != 0) { /* /(?<n>..){0}/ */
+ else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */
len = SIZE_OP_JUMP + tlen;
}
else if (!infinite && qn->greedy &&
@@ -1124,7 +1124,7 @@ compile_quantifier_node(QtfrNode* qn, regex_t* reg)
r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH));
}
}
- else if (qn->upper == 0 && qn->is_referred != 0) { /* /(?<n>..){0}/ */
+ else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */
r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
if (r) return r;
r = compile_tree(qn->target, reg);
@@ -1914,7 +1914,7 @@ noname_disable_map(Node** plink, GroupNumRemap* map, int* counter)
}
static int
-renumber_node_backref(Node* node, GroupNumRemap* map, const int num_mem)
+renumber_node_backref(Node* node, GroupNumRemap* map)
{
int i, pos, n, old_num;
int *backs;
@@ -1930,7 +1930,6 @@ renumber_node_backref(Node* node, GroupNumRemap* map, const int num_mem)
backs = bn->back_dynamic;
for (i = 0, pos = 0; i < old_num; i++) {
- if (backs[i] > num_mem) return ONIGERR_INVALID_BACKREF;
n = map[backs[i]].new_val;
if (n > 0) {
backs[pos] = n;
@@ -1943,7 +1942,7 @@ renumber_node_backref(Node* node, GroupNumRemap* map, const int num_mem)
}
static int
-renumber_by_map(Node* node, GroupNumRemap* map, const int num_mem)
+renumber_by_map(Node* node, GroupNumRemap* map)
{
int r = 0;
@@ -1951,30 +1950,28 @@ renumber_by_map(Node* node, GroupNumRemap* map, const int num_mem)
case NT_LIST:
case NT_ALT:
do {
- r = renumber_by_map(NCAR(node), map, num_mem);
+ r = renumber_by_map(NCAR(node), map);
} while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
break;
case NT_QTFR:
- r = renumber_by_map(NQTFR(node)->target, map, num_mem);
+ r = renumber_by_map(NQTFR(node)->target, map);
break;
case NT_ENCLOSE:
{
EncloseNode* en = NENCLOSE(node);
- if (en->type == ENCLOSE_CONDITION) {
- if (en->regnum > num_mem) return ONIGERR_INVALID_BACKREF;
+ if (en->type == ENCLOSE_CONDITION)
en->regnum = map[en->regnum].new_val;
- }
- r = renumber_by_map(en->target, map, num_mem);
+ r = renumber_by_map(en->target, map);
}
break;
case NT_BREF:
- r = renumber_node_backref(node, map, num_mem);
+ r = renumber_node_backref(node, map);
break;
case NT_ANCHOR:
if (NANCHOR(node)->target)
- r = renumber_by_map(NANCHOR(node)->target, map, num_mem);
+ r = renumber_by_map(NANCHOR(node)->target, map);
break;
default:
@@ -2036,7 +2033,7 @@ disable_noname_group_capture(Node** root, regex_t* reg, ScanEnv* env)
r = noname_disable_map(root, map, &counter);
if (r != 0) return r;
- r = renumber_by_map(*root, map, env->num_mem);
+ r = renumber_by_map(*root, map);
if (r != 0) return r;
for (i = 1, pos = 1; i <= env->num_mem; i++) {
@@ -3109,7 +3106,7 @@ subexp_recursive_check_trav(Node* node, ScanEnv* env)
r = subexp_recursive_check_trav(NQTFR(node)->target, env);
if (NQTFR(node)->upper == 0) {
if (r == FOUND_CALLED_NODE)
- NQTFR(node)->is_referred = 1;
+ NQTFR(node)->is_refered = 1;
}
break;
@@ -3599,7 +3596,6 @@ expand_case_fold_string(Node* node, regex_t* reg)
if (n == 0 || varlen == 0) {
if (IS_NULL(snode)) {
if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
- onig_node_free(top_root);
top_root = root = onig_node_list_add(NULL_NODE, prev_node);
if (IS_NULL(root)) {
onig_node_free(prev_node);
@@ -3631,7 +3627,6 @@ expand_case_fold_string(Node* node, regex_t* reg)
}
}
if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
- onig_node_free(top_root);
top_root = root = onig_node_list_add(NULL_NODE, prev_node);
if (IS_NULL(root)) {
onig_node_free(prev_node);
@@ -3682,7 +3677,6 @@ expand_case_fold_string(Node* node, regex_t* reg)
if (r != 0) goto mem_err;
if (IS_NOT_NULL(prev_node) && IS_NULL(root)) {
- onig_node_free(top_root);
top_root = root = onig_node_list_add(NULL_NODE, prev_node);
if (IS_NULL(root)) {
onig_node_free(srem);
diff --git a/regenc.h b/regenc.h
index 16ed6c39da..969e114bfd 100644
--- a/regenc.h
+++ b/regenc.h
@@ -122,7 +122,7 @@ typedef struct {
} PosixBracketEntryType;
#define POSIX_BRACKET_ENTRY_INIT(name, ctype) \
- {(short int )(sizeof(name) - 1), name, (ctype)}
+ {(short int )(sizeof(name) - 1), (name), (ctype)}
#ifndef numberof
# define numberof(array) (int )(sizeof(array) / sizeof((array)[0]))
diff --git a/regerror.c b/regerror.c
index efcfefffdf..aff6354196 100644
--- a/regerror.c
+++ b/regerror.c
@@ -242,8 +242,8 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
}
-/* < ONIG_MAX_ERROR_MESSAGE_LEN - max length of messages with %n */
-#define MAX_ERROR_PAR_LEN 50
+/* for ONIG_MAX_ERROR_MESSAGE_LEN */
+#define MAX_ERROR_PAR_LEN 30
extern int
onig_error_code_to_str(UChar* s, OnigPosition code, ...)
@@ -356,8 +356,7 @@ onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,
*s++ = *p++;
}
else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
- (!ONIGENC_IS_CODE_SPACE(enc, *p) ||
- ONIGENC_IS_CODE_CNTRL(enc, *p))) {
+ !ONIGENC_IS_CODE_SPACE(enc, *p)) {
sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
bp = bs;
diff --git a/regexec.c b/regexec.c
index 10ada4d81d..4582c35c3f 100644
--- a/regexec.c
+++ b/regexec.c
@@ -323,9 +323,7 @@ onig_region_init(OnigRegion* region)
region->allocated = 0;
region->beg = (OnigPosition* )0;
region->end = (OnigPosition* )0;
-#ifdef USE_CAPTURE_HISTORY
region->history_root = (OnigCaptureTreeNode* )0;
-#endif
}
extern OnigRegion*
@@ -1463,9 +1461,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
# define CASE(x) L_##x: sbegin = s; OPCODE_EXEC_HOOK;
# define DEFAULT L_DEFAULT:
# define NEXT sprev = sbegin; JUMP
-# define JUMP RB_GNUC_EXTENSION_BLOCK(goto *oplabels[*p++])
+# define JUMP goto *oplabels[*p++]
- RB_GNUC_EXTENSION static const void *oplabels[] = {
+ static const void *oplabels[] = {
&&L_OP_FINISH, /* matching process terminator (no more alternative) */
&&L_OP_END, /* pattern code terminator (success end) */
@@ -4619,3 +4617,4 @@ onig_copy_encoding(OnigEncodingType *to, OnigEncoding from)
{
*to = *from;
}
+
diff --git a/regint.h b/regint.h
index 0740429688..a2f5bbba1d 100644
--- a/regint.h
+++ b/regint.h
@@ -52,7 +52,7 @@
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
- defined(__powerpc64__) || defined(__aarch64__) || \
+ defined(__powerpc64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# else
diff --git a/regparse.c b/regparse.c
index a96c8c2fa7..c2812924a6 100644
--- a/regparse.c
+++ b/regparse.c
@@ -35,6 +35,7 @@
#define CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS
+extern const int onigenc_unicode_version_number[3];
const OnigSyntaxType OnigSyntaxRuby = {
(( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
@@ -108,7 +109,7 @@ extern void onig_set_verb_warn_func(OnigWarnFunc f)
onig_verb_warn = f;
}
-static void CC_DUP_WARN(ScanEnv *env, OnigCodePoint from, OnigCodePoint to);
+static void CC_DUP_WARN(ScanEnv *env);
static unsigned int ParseDepthLimit = DEFAULT_PARSE_DEPTH_LIMIT;
@@ -174,7 +175,7 @@ bbuf_clone(BBuf** rto, BBuf* from)
#define BITSET_SET_BIT_CHKDUP(bs, pos) do { \
- if (BITSET_AT(bs, pos)) CC_DUP_WARN(env, pos, pos); \
+ if (BITSET_AT(bs, pos)) CC_DUP_WARN(env); \
BS_ROOM(bs, pos) |= BS_BIT(pos); \
} while (0)
@@ -493,7 +494,7 @@ onig_print_names(FILE* fp, regex_t* reg)
if (IS_NOT_NULL(t)) {
fprintf(fp, "name table\n");
- onig_st_foreach(t, (st_foreach_callback_func *)i_print_name_entry, (HashDataType )fp);
+ onig_st_foreach(t, i_print_name_entry, (HashDataType )fp);
fputs("\n", fp);
}
return 0;
@@ -516,7 +517,7 @@ names_clear(regex_t* reg)
NameTable* t = (NameTable* )reg->name_table;
if (IS_NOT_NULL(t)) {
- onig_st_foreach(t, (st_foreach_callback_func *)i_free_name_entry, 0);
+ onig_st_foreach(t, i_free_name_entry, 0);
}
return 0;
}
@@ -585,7 +586,7 @@ onig_foreach_name(regex_t* reg,
narg.reg = reg;
narg.arg = arg;
narg.enc = reg->enc; /* should be pattern encoding. */
- onig_st_foreach(t, (st_foreach_callback_func *)i_names, (HashDataType )&narg);
+ onig_st_foreach(t, i_names, (HashDataType )&narg);
}
return narg.ret;
}
@@ -613,7 +614,7 @@ onig_renumber_name_table(regex_t* reg, GroupNumRemap* map)
NameTable* t = (NameTable* )reg->name_table;
if (IS_NOT_NULL(t)) {
- onig_st_foreach(t, (st_foreach_callback_func *)i_renumber_name, (HashDataType )map);
+ onig_st_foreach(t, i_renumber_name, (HashDataType )map);
}
return 0;
}
@@ -1315,7 +1316,7 @@ node_new_quantifier(int lower, int upper, int by_number)
NQTFR(node)->target_empty_info = NQ_TARGET_ISNOT_EMPTY;
NQTFR(node)->head_exact = NULL_NODE;
NQTFR(node)->next_head_exact = NULL_NODE;
- NQTFR(node)->is_referred = 0;
+ NQTFR(node)->is_refered = 0;
if (by_number != 0)
NQTFR(node)->state |= NST_BY_NUMBER;
@@ -1720,7 +1721,7 @@ add_code_range_to_buf0(BBuf** pbuf, ScanEnv* env, OnigCodePoint from, OnigCodePo
if (inc_n != 1) {
if (checkdup && from <= data[low*2+1]
&& (data[low*2] <= from || data[low*2+1] <= to))
- CC_DUP_WARN(env, from, to);
+ CC_DUP_WARN(env);
if (from > data[low*2])
from = data[low*2];
if (to < data[(high - 1)*2 + 1])
@@ -2886,18 +2887,14 @@ CLOSE_BRACKET_WITHOUT_ESC_WARN(ScanEnv* env, UChar* c)
#endif
static void
-CC_DUP_WARN(ScanEnv *env, OnigCodePoint from ARG_UNUSED, OnigCodePoint to ARG_UNUSED)
+CC_DUP_WARN(ScanEnv *env)
{
if (onig_warn == onig_null_warn || !RTEST(ruby_verbose)) return ;
if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_CC_DUP) &&
!(env->warnings_flag & ONIG_SYN_WARN_CC_DUP)) {
-#ifdef WARN_ALL_CC_DUP
- onig_syntax_warn(env, "character class has duplicated range: %04x-%04x", from, to);
-#else
env->warnings_flag |= ONIG_SYN_WARN_CC_DUP;
onig_syntax_warn(env, "character class has duplicated range");
-#endif
}
}
@@ -4663,7 +4660,7 @@ parse_char_class(Node** np, Node** asc_np, OnigToken* tok, UChar** src, UChar* e
p = psave;
for (i = 1; i < len; i++) {
(void)fetch_token_in_cc(tok, &p, end, env);
- /* no need to check the return value (already checked above) */
+ /* no need to check the retun value (already checked above) */
}
fetched = 0;
}
@@ -5701,329 +5698,739 @@ static int
propname2ctype(ScanEnv* env, const char* propname)
{
UChar* name = (UChar* )propname;
- UChar* name_end = name + strlen(propname);
int ctype = env->enc->property_name_to_ctype(ONIG_ENCODING_ASCII,
- name, name_end);
- if (ctype < 0) {
- onig_scan_env_set_error_string(env, ctype, name, name_end);
- }
+ name, name + strlen(propname));
return ctype;
}
static int
-add_property_to_cc(CClassNode* cc, const char* propname, int not, ScanEnv* env)
+node_extended_grapheme_cluster(Node** np, ScanEnv* env)
{
- int ctype = propname2ctype(env, propname);
- if (ctype < 0) return ctype;
- return add_ctype_to_cc(cc, ctype, not, 0, env);
-}
+ Node* tmp = NULL;
+ Node* np1 = NULL;
+ Node* list = NULL;
+ Node* list2 = NULL;
+ Node* alt = NULL;
+ Node* alt2 = NULL;
+ BBuf *pbuf1 = NULL;
+ int r = 0;
+ int num1;
+ UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN * 2];
+ OnigOptionType option;
-/*
- * helper methods for node_extended_grapheme_cluster (/\X/)
- */
-static int
-create_property_node(Node **np, ScanEnv* env, const char* propname)
-{
- int r;
- CClassNode* cc;
+#ifdef USE_UNICODE_PROPERTIES
+ if (ONIGENC_IS_UNICODE(env->enc)) {
+ /* UTF-8, UTF-16BE/LE, UTF-32BE/LE */
+ CClassNode* cc;
+ OnigCodePoint sb_out = (ONIGENC_MBC_MINLEN(env->enc) > 1) ? 0x00 : 0x80;
+ int extend = propname2ctype(env, "Grapheme_Cluster_Break=Extend");
+
+ /* Prepend*
+ * ( RI-sequence | Hangul-Syllable | !Control )
+ * ( Grapheme_Extend | SpacingMark )* */
+
+ /* ( Grapheme_Extend | SpacingMark )* */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, extend, 0, 0, env);
+ if (r != 0) goto err;
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=SpacingMark"), 0, 0, env);
+ if (r != 0) goto err;
+ r = add_code_range(&(cc->mbuf), env, 0x200D, 0x200D);
+ if (r != 0) goto err;
- *np = node_new_cclass();
- if (IS_NULL(*np)) return ONIGERR_MEMORY;
- cc = NCCLASS(*np);
- r = add_property_to_cc(cc, propname, 0, env);
- if (r != 0)
- onig_node_free(*np);
- return r;
-}
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list = tmp;
+ np1 = NULL;
+
+ /* ( RI-sequence | Hangul-Syllable | !Control ) */
+ /* !Control */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=Control"), 1, 0, env);
+ if (r != 0) goto err;
+ if (ONIGENC_MBC_MINLEN(env->enc) > 1) {
+ BBuf *pbuf2 = NULL;
+ r = add_code_range(&pbuf1, env, 0x0a, 0x0a);
+ if (r != 0) goto err;
+ r = add_code_range(&pbuf1, env, 0x0d, 0x0d);
+ if (r != 0) goto err;
+ r = and_code_range_buf(cc->mbuf, 0, pbuf1, 1, &pbuf2, env);
+ if (r != 0) {
+ bbuf_free(pbuf2);
+ goto err;
+ }
+ bbuf_free(pbuf1);
+ pbuf1 = NULL;
+ bbuf_free(cc->mbuf);
+ cc->mbuf = pbuf2;
+ }
+ else {
+ BITSET_CLEAR_BIT(cc->bs, 0x0a);
+ BITSET_CLEAR_BIT(cc->bs, 0x0d);
+ }
+
+ tmp = onig_node_new_alt(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ np1 = NULL;
+
+ /* Hangul-Syllable
+ * := L* V+ T*
+ * | L* LV V* T*
+ * | L* LVT T*
+ * | L+
+ * | T+ */
+
+ /* T+ */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=T"), 0, 0, env);
+ if (r != 0) goto err;
-static int
-quantify_node(Node **np, int lower, int upper)
-{
- Node* tmp = node_new_quantifier(lower, upper, 0);
- if (IS_NULL(tmp)) return ONIGERR_MEMORY;
- NQTFR(tmp)->target = *np;
- *np = tmp;
- return 0;
-}
+ tmp = node_new_quantifier(1, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = onig_node_new_alt(np1, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ np1 = NULL;
+
+ /* L+ */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=L"), 0, 0, env);
+ if (r != 0) goto err;
-static int
-quantify_property_node(Node **np, ScanEnv* env, const char* propname, char repetitions)
-{
- int r;
- int lower = 0;
- int upper = REPEAT_INFINITE;
+ tmp = node_new_quantifier(1, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = onig_node_new_alt(np1, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ np1 = NULL;
+
+ /* L* LVT T* */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=T"), 0, 0, env);
+ if (r != 0) goto err;
- r = create_property_node(np, env, propname);
- if (r != 0) return r;
- switch (repetitions) {
- case '?': upper = 1; break;
- case '+': lower = 1; break;
- case '*': break;
- case '2': lower = upper = 2; break;
- default : return ONIGERR_PARSER_BUG;
- }
- return quantify_node(np, lower, upper);
-}
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
-#define LIST 0
-#define ALT 1
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
-/* IMPORTANT: Make sure node_array ends with NULL_NODE */
-static int
-create_node_from_array(int kind, Node **np, Node **node_array)
-{
- Node* tmp = NULL_NODE;
- int i = 0;
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=LVT"), 0, 0, env);
+ if (r != 0) goto err;
- while (node_array[i] != NULL_NODE) i++;
- while (--i >= 0) {
- *np = kind==LIST ? node_new_list(node_array[i], tmp)
- : onig_node_new_alt(node_array[i], tmp);
- if (IS_NULL(*np)) {
- while (i >= 0) {
- onig_node_free(node_array[i]);
- node_array[i--] = NULL_NODE;
- }
- onig_node_free(tmp);
- return ONIGERR_MEMORY;
- }
- else
- node_array[i] = NULL_NODE;
- tmp = *np;
- }
- return 0;
-}
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
-#define R_ERR(call) r=(call);if(r!=0)goto err
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=L"), 0, 0, env);
+ if (r != 0) goto err;
-/* Memory layout for common node array:
- * The main purpose is to be able to easily free all leftover nodes
- * after an error. As a side effect, we share some memory.
- *
- * The layout is as shown below (each line corresponds to one call of
- * create_node_from_array()). Because create_node_from_array sets all
- * nodes of the source to NULL_NODE, we can overlap the target array
- * as long as we do not override the actual target location.
- *
- * Target Array name Index
- *
- * node_array 0 1 2 3 4 5 6 7 8 9 A B C D E F
- * top_alts alts[5] 0 1 2 3 4*
- * alts+1 list[4] 0 1 2 3*
- * list+1 core_alts[7] 0 1 2 3 4 5 6*
- * core_alts+0 H_list[4] 0 1 2 3*
- * H_list+1 H_alt2[4] 0 1 2 3*
- * h_alt2+1 H_list2[3] 0 1 2*
- * core_alts+4 XP_list[4] 0 1 2 3*
- * XP_list+1 Ex_list[4] 0 1 2 3*
- */
-#define NODE_COMMON_SIZE 16
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list2 = NULL;
+
+ /* L* LV V* T* */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=T"), 0, 0, env);
+ if (r != 0) goto err;
-static int
-node_extended_grapheme_cluster(Node** np, ScanEnv* env)
-{
- Node* tmp = NULL;
- Node* np1 = NULL;
- Node* top_alt = NULL;
- int r = 0;
- int num1;
- int i;
- int any_target_position;
- UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN * 2];
- OnigOptionType option;
- /* node_common is function-global so that we can free all nodes
- * in case of error. Unused slots are set to NULL_NODE at all times. */
- Node *node_common[NODE_COMMON_SIZE];
- Node **alts = node_common+0; /* size: 5 */
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
- for (i=0; i<NODE_COMMON_SIZE; i++)
- node_common[i] = NULL_NODE;
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
- /* CRLF, common for both Unicode and non-Unicode */
- /* \x0D\x0A */
- r = ONIGENC_CODE_TO_MBC(env->enc, 0x0D, buf);
- if (r < 0) goto err;
- num1 = r;
- r = ONIGENC_CODE_TO_MBC(env->enc, 0x0A, buf + num1);
- if (r < 0) goto err;
- alts[0] = node_new_str_raw(buf, buf + num1 + r);
- if (IS_NULL(alts[0])) goto err;
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=V"), 0, 0, env);
+ if (r != 0) goto err;
-#ifdef USE_UNICODE_PROPERTIES
- if (ONIGENC_IS_UNICODE(env->enc)) { /* UTF-8, UTF-16BE/LE, UTF-32BE/LE */
- CClassNode* cc;
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=LV"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=L"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list2 = NULL;
+
+ /* L* V+ T* */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=T"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=V"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(1, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=L"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list2 = NULL;
+
+ /* Emoji sequence := (E_Base | EBG) Extend* E_Modifier?
+ * (ZWJ (Glue_After_Zwj | EBG Extend* E_Modifier?) )* */
+
+ /* ZWJ (Glue_After_Zwj | E_Base_GAZ Extend* E_Modifier?) */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=E_Modifier"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, 1, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, extend, 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=E_Base_GAZ"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ alt2 = tmp;
+ list2 = NULL;
+
+ /* Glue_After_Zwj */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, extend, 0, 0, env);
+ if (r != 0) goto err;
- if (propname2ctype(env, "Grapheme_Cluster_Break=Extend") < 0) goto err;
- /* Unicode 11.0.0
- * CRLF (already done)
- * | [Control CR LF]
- * | precore* core postcore*
- * | . (to catch invalid stuff, because this seems to be spec for String#grapheme_clusters) */
-
- /* [Control CR LF] (CR and LF are not in the spec, but this is a conformed fix) */
- alts[1] = node_new_cclass();
- if (IS_NULL(alts[1])) goto err;
- cc = NCCLASS(alts[1]);
- R_ERR(add_property_to_cc(cc, "Grapheme_Cluster_Break=Control", 0, env));
- if (ONIGENC_MBC_MINLEN(env->enc) > 1) { /* UTF-16/UTF-32 */
- R_ERR(add_code_range(&(cc->mbuf), env, 0x000A, 0x000A)); /* CR */
- R_ERR(add_code_range(&(cc->mbuf), env, 0x000D, 0x000D)); /* LF */
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ if (onigenc_unicode_version_number[0] < 10) {
+ static const OnigCodePoint ranges[] = {
+ 13,
+ 0x1F308, 0x1F308,
+ 0x1F33E, 0x1F33E,
+ 0x1F373, 0x1F373,
+ 0x1F393, 0x1F393,
+ 0x1F3A4, 0x1F3A4,
+ 0x1F3A8, 0x1F3A8,
+ 0x1F3EB, 0x1F3EB,
+ 0x1F3ED, 0x1F3ED,
+ 0x1F4BB, 0x1F4BC,
+ 0x1F527, 0x1F527,
+ 0x1F52C, 0x1F52C,
+ 0x1F680, 0x1F680,
+ 0x1F692, 0x1F692,
+ };
+ r = add_ctype_to_cc_by_range(cc, -1, 0, env, sb_out, ranges);
+ if (r != 0) goto err;
}
- else {
- BITSET_SET_BIT(cc->bs, 0x0a);
- BITSET_SET_BIT(cc->bs, 0x0d);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=Glue_After_Zwj"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt2);
+ if (IS_NULL(tmp)) goto err;
+ alt2 = tmp;
+ list2 = NULL;
+
+ /* Emoji variation sequence
+ * http://unicode.org/Public/emoji/4.0/emoji-zwj-sequences.txt
+ */
+ r = ONIGENC_CODE_TO_MBC(env->enc, 0xfe0f, buf);
+ if (r < 0) goto err;
+ np1 = node_new_str_raw(buf, buf + r);
+ if (IS_NULL(np1)) goto err;
+
+ tmp = node_new_quantifier(0, 1, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ {
+ static const OnigCodePoint ranges[] = {
+ 4,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2695, 0x2696,
+ 0x2708, 0x2708,
+ };
+ r = add_ctype_to_cc_by_range(cc, -1, 0, env, sb_out, ranges);
+ if (r != 0) goto err;
}
- /* precore* core postcore* */
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt2);
+ if (IS_NULL(tmp)) goto err;
+ alt2 = tmp;
+ list2 = NULL;
+
+ tmp = node_new_list(alt2, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ alt2 = NULL;
+
+ /* ZWJ */
+ r = ONIGENC_CODE_TO_MBC(env->enc, 0x200D, buf);
+ if (r < 0) goto err;
+ np1 = node_new_str_raw(buf, buf + r);
+ if (IS_NULL(np1)) goto err;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = list2;
+ np1 = tmp;
+ list2 = NULL;
+
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ /* E_Modifier? */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=E_Modifier"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, 1, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ /* Extend* */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, extend, 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ /* (E_Base | EBG) */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
{
- Node **list = alts + 3; /* size: 4 */
+ static const OnigCodePoint ranges9[] = {
+ 8,
+ 0x1F3C2, 0x1F3C2,
+ 0x1F3C7, 0x1F3C7,
+ 0x1F3CC, 0x1F3CC,
+ 0x1F3F3, 0x1F3F3,
+ 0x1F441, 0x1F441,
+ 0x1F46F, 0x1F46F,
+ 0x1F574, 0x1F574,
+ 0x1F6CC, 0x1F6CC,
+ };
+ static const OnigCodePoint ranges10[] = {
+ 3,
+ 0x1F3F3, 0x1F3F3,
+ 0x1F441, 0x1F441,
+ 0x1F46F, 0x1F46F,
+ };
+ const OnigCodePoint *ranges =
+ (onigenc_unicode_version_number[0] < 10) ? ranges9 : ranges10;
+ r = add_ctype_to_cc_by_range(cc, -1, 0, env, sb_out, ranges);
+ if (r != 0) goto err;
+ }
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=E_Base"), 0, 0, env);
+ if (r != 0) goto err;
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=E_Base_GAZ"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list2 = NULL;
+
+ /* ZWJ (E_Base_GAZ | Glue_After_Zwj) E_Modifier? */
+ /* a sequence starting with ZWJ seems artificial, but GraphemeBreakTest
+ * has such examples.
+ * http://www.unicode.org/Public/9.0.0/ucd/auxiliary/GraphemeBreakTest.html
+ */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=E_Modifier"), 0, 0, env);
+ if (r != 0) goto err;
- /* precore*; precore := Prepend */
- R_ERR(quantify_property_node(list+0, env, "Grapheme_Cluster_Break=Prepend", '*'));
+ tmp = node_new_quantifier(0, 1, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
- /* core := hangul-syllable
- * | ri-sequence
- * | xpicto-sequence
- * | [^Control CR LF] */
- {
- Node **core_alts = list + 2; /* size: 7 */
-
- /* hangul-syllable :=
- * L* (V+ | LV V* | LVT) T*
- * | L+
- * | T+ */
- /* hangul-syllable is an alternative (would be called H_alt)
- * inside an alternative, but we flatten it into core_alts */
-
- /* L* (V+ | LV V* | LVT) T* */
- {
- Node **H_list = core_alts + 1; /* size: 4 */
- R_ERR(quantify_property_node(H_list+0, env, "Grapheme_Cluster_Break=L", '*'));
-
- /* V+ | LV V* | LVT */
- {
- Node **H_alt2 = H_list + 2; /* size: 4 */
- R_ERR(quantify_property_node(H_alt2+0, env, "Grapheme_Cluster_Break=V", '+'));
-
- /* LV V* */
- {
- Node **H_list2 = H_alt2 + 2; /* size: 3 */
-
- R_ERR(create_property_node(H_list2+0, env, "Grapheme_Cluster_Break=LV"));
- R_ERR(quantify_property_node(H_list2+1, env, "Grapheme_Cluster_Break=V", '*'));
- R_ERR(create_node_from_array(LIST, H_alt2+1, H_list2));
- }
-
- R_ERR(create_property_node(H_alt2+2, env, "Grapheme_Cluster_Break=LVT"));
- R_ERR(create_node_from_array(ALT, H_list+1, H_alt2));
- }
-
- R_ERR(quantify_property_node(H_list+2, env, "Grapheme_Cluster_Break=T", '*'));
- R_ERR(create_node_from_array(LIST, core_alts+0, H_list));
- }
-
- R_ERR(quantify_property_node(core_alts+1, env, "Grapheme_Cluster_Break=L", '+'));
- R_ERR(quantify_property_node(core_alts+2, env, "Grapheme_Cluster_Break=T", '+'));
- /* end of hangul-syllable */
-
- /* ri-sequence := RI RI */
- R_ERR(quantify_property_node(core_alts+3, env, "Regional_Indicator", '2'));
-
- /* xpicto-sequence := \p{Extended_Pictographic} (Extend* ZWJ \p{Extended_Pictographic})* */
- {
- Node **XP_list = core_alts + 5; /* size: 3 */
- R_ERR(create_property_node(XP_list+0, env, "Extended_Pictographic"));
-
- /* (Extend* ZWJ \p{Extended_Pictographic})* */
- {
- Node **Ex_list = XP_list + 2; /* size: 4 */
- /* assert(Ex_list+4 == node_common+NODE_COMMON_SIZE); */
- R_ERR(quantify_property_node(Ex_list+0, env, "Grapheme_Cluster_Break=Extend", '*'));
-
- /* ZWJ (ZERO WIDTH JOINER) */
- r = ONIGENC_CODE_TO_MBC(env->enc, 0x200D, buf);
- if (r < 0) goto err;
- Ex_list[1] = node_new_str_raw(buf, buf + r);
- if (IS_NULL(Ex_list[1])) goto err;
-
- R_ERR(create_property_node(Ex_list+2, env, "Extended_Pictographic"));
- R_ERR(create_node_from_array(LIST, XP_list+1, Ex_list));
- }
- R_ERR(quantify_node(XP_list+1, 0, REPEAT_INFINITE)); /* TODO: Check about node freeing */
-
- R_ERR(create_node_from_array(LIST, core_alts+4, XP_list));
- }
-
- /* [^Control CR LF] */
- core_alts[5] = node_new_cclass();
- if (IS_NULL(core_alts[5])) goto err;
- cc = NCCLASS(core_alts[5]);
- if (ONIGENC_MBC_MINLEN(env->enc) > 1) { /* UTF-16/UTF-32 */
- BBuf *inverted_buf = NULL;
-
- /* TODO: fix false warning */
- const int dup_not_warned = env->warnings_flag | ~ONIG_SYN_WARN_CC_DUP;
- env->warnings_flag |= ONIG_SYN_WARN_CC_DUP;
-
- /* Start with a positive buffer and invert at the end.
- * Otherwise, adding single-character ranges work the wrong way. */
- R_ERR(add_property_to_cc(cc, "Grapheme_Cluster_Break=Control", 0, env));
- R_ERR(add_code_range(&(cc->mbuf), env, 0x000A, 0x000A)); /* CR */
- R_ERR(add_code_range(&(cc->mbuf), env, 0x000D, 0x000D)); /* LF */
- R_ERR(not_code_range_buf(env->enc, cc->mbuf, &inverted_buf, env));
- cc->mbuf = inverted_buf; /* TODO: check what to do with buffer before inversion */
-
- env->warnings_flag &= dup_not_warned; /* TODO: fix false warning */
- }
- else {
- R_ERR(add_property_to_cc(cc, "Grapheme_Cluster_Break=Control", 1, env));
- BITSET_CLEAR_BIT(cc->bs, 0x0a);
- BITSET_CLEAR_BIT(cc->bs, 0x0d);
- }
-
- R_ERR(create_node_from_array(ALT, list+1, core_alts));
- }
-
- /* postcore*; postcore = [Extend ZWJ SpacingMark] */
- R_ERR(create_property_node(list+2, env, "Grapheme_Cluster_Break=Extend"));
- cc = NCCLASS(list[2]);
- R_ERR(add_property_to_cc(cc, "Grapheme_Cluster_Break=SpacingMark", 0, env));
- R_ERR(add_code_range(&(cc->mbuf), env, 0x200D, 0x200D));
- R_ERR(quantify_node(list+2, 0, REPEAT_INFINITE));
-
- R_ERR(create_node_from_array(LIST, alts+2, list));
- }
-
- any_target_position = 3;
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=Glue_After_Zwj"), 0, 0, env);
+ if (r != 0) goto err;
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=E_Base_GAZ"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ r = ONIGENC_CODE_TO_MBC(env->enc, 0x200D, buf);
+ if (r < 0) goto err;
+ np1 = node_new_str_raw(buf, buf + r);
+ if (IS_NULL(np1)) goto err;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list2 = NULL;
+
+ /* RI-Sequence := Regional_Indicator{2} */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_code_range(&(cc->mbuf), env, 0x1F1E6, 0x1F1FF);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(2, 2, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list2 = NULL;
+
+ tmp = node_new_list(alt, list);
+ if (IS_NULL(tmp)) goto err;
+ list = tmp;
+ alt = NULL;
+
+ /* Prepend* */
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=Prepend"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(0, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list);
+ if (IS_NULL(tmp)) goto err;
+ list = tmp;
+ np1 = NULL;
+
+ /* PerlSyntax: (?s:.), RubySyntax: (?m:.) */
+ np1 = node_new_anychar();
+ if (IS_NULL(np1)) goto err;
+
+ option = env->option;
+ ONOFF(option, ONIG_OPTION_MULTILINE, 0);
+ tmp = node_new_option(option);
+ if (IS_NULL(tmp)) goto err;
+ NENCLOSE(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = onig_node_new_alt(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ np1 = NULL;
+
+ /* Prepend+ */
+ r = ONIGENC_CODE_TO_MBC(env->enc, 0x200D, buf);
+ if (r < 0) goto err;
+ np1 = node_new_str_raw(buf, buf + r);
+ if (IS_NULL(np1)) goto err;
+
+ tmp = node_new_quantifier(0, 1, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, NULL_NODE);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ np1 = node_new_cclass();
+ if (IS_NULL(np1)) goto err;
+ cc = NCCLASS(np1);
+ r = add_ctype_to_cc(cc, propname2ctype(env, "Grapheme_Cluster_Break=Prepend"), 0, 0, env);
+ if (r != 0) goto err;
+
+ tmp = node_new_quantifier(1, REPEAT_INFINITE, 0);
+ if (IS_NULL(tmp)) goto err;
+ NQTFR(tmp)->target = np1;
+ np1 = tmp;
+
+ tmp = node_new_list(np1, list2);
+ if (IS_NULL(tmp)) goto err;
+ list2 = tmp;
+ np1 = NULL;
+
+ tmp = onig_node_new_alt(list2, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list2 = NULL;
+
+ tmp = onig_node_new_alt(list, alt);
+ if (IS_NULL(tmp)) goto err;
+ alt = tmp;
+ list = NULL;
}
else
#endif /* USE_UNICODE_PROPERTIES */
{
- any_target_position = 1;
+ /* PerlSyntax: (?s:.), RubySyntax: (?m:.) */
+ np1 = node_new_anychar();
+ if (IS_NULL(np1)) goto err;
+
+ option = env->option;
+ ONOFF(option, ONIG_OPTION_MULTILINE, 0);
+ tmp = node_new_option(option);
+ if (IS_NULL(tmp)) goto err;
+ NENCLOSE(tmp)->target = np1;
+ np1 = tmp;
+
+ alt = onig_node_new_alt(np1, NULL_NODE);
+ if (IS_NULL(alt)) goto err;
+ np1 = NULL;
}
- /* PerlSyntax: (?s:.), RubySyntax: (?m:.), common for both Unicode and non-Unicode */
- /* Not in Unicode spec (UAX #29), but added to catch invalid stuff,
- * because this is Ruby spec for String#grapheme_clusters. */
- np1 = node_new_anychar();
+ /* \x0D\x0A */
+ r = ONIGENC_CODE_TO_MBC(env->enc, 0x0D, buf);
+ if (r < 0) goto err;
+ num1 = r;
+ r = ONIGENC_CODE_TO_MBC(env->enc, 0x0A, buf + num1);
+ if (r < 0) goto err;
+ np1 = node_new_str_raw(buf, buf + num1 + r);
if (IS_NULL(np1)) goto err;
- option = env->option;
- ONOFF(option, ONIG_OPTION_MULTILINE, 0);
- tmp = node_new_option(option);
+ tmp = onig_node_new_alt(np1, alt);
if (IS_NULL(tmp)) goto err;
- NENCLOSE(tmp)->target = np1;
- alts[any_target_position] = tmp;
+ alt = tmp;
np1 = NULL;
- R_ERR(create_node_from_array(ALT, &top_alt, alts));
-
- /* (?>): For efficiency, because there is no text piece
- * that is not in a grapheme cluster, and there is only one way
- * to split a string into grapheme clusters. */
+ /* (?>\x0D\x0A|...) */
tmp = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
if (IS_NULL(tmp)) goto err;
- NENCLOSE(tmp)->target = top_alt;
+ NENCLOSE(tmp)->target = alt;
np1 = tmp;
#ifdef USE_UNICODE_PROPERTIES
@@ -6044,11 +6451,13 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env)
err:
onig_node_free(np1);
- for (i=0; i<NODE_COMMON_SIZE; i++)
- onig_node_free(node_common[i]);
+ onig_node_free(list);
+ onig_node_free(list2);
+ onig_node_free(alt);
+ onig_node_free(alt2);
+ bbuf_free(pbuf1);
return (r == 0) ? ONIGERR_MEMORY : r;
}
-#undef R_ERR
static int
countbits(unsigned int bits)
diff --git a/regparse.h b/regparse.h
index acdd3e2f5c..888ebf4ce6 100644
--- a/regparse.h
+++ b/regparse.h
@@ -186,7 +186,7 @@ typedef struct {
int target_empty_info;
struct _Node* head_exact;
struct _Node* next_head_exact;
- int is_referred; /* include called node. don't eliminate even if {0} */
+ int is_refered; /* include called node. don't eliminate even if {0} */
#ifdef USE_COMBINATION_EXPLOSION_CHECK
int comb_exp_check_num; /* 1,2,3...: check, 0: no check */
#endif
diff --git a/ruby-runner.c b/ruby-runner.c
index d41ba274c3..99be4a0013 100644
--- a/ruby-runner.c
+++ b/ruby-runner.c
@@ -1,18 +1,10 @@
#define _POSIX_C_SOURCE 200809L
-#include "ruby/config.h"
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include "ruby-runner.h"
-#ifdef MAKE_MJIT_BUILD_DIR
-const char MJIT_HEADER[] = BUILDDIR "/" MJIT_MIN_HEADER;
-#else
-
#define STRINGIZE(expr) STRINGIZE0(expr)
#define STRINGIZE0(expr) #expr
@@ -64,10 +56,6 @@ main(int argc, char **argv)
PATH_SEPARATOR
EXTOUT_DIR"/"ARCH
;
-#ifndef LOAD_RELATIVE
- static const char mjit_build_dir[] = BUILDDIR"/mjit_build_dir."SOEXT;
- struct stat stbuf;
-#endif
const size_t dirsize = sizeof(builddir);
const size_t namesize = sizeof(rubypath) - dirsize;
const char *rubyname = rubypath + dirsize;
@@ -75,12 +63,6 @@ main(int argc, char **argv)
insert_env_path(LIBPATHENV, builddir, dirsize, 1);
insert_env_path("RUBYLIB", rubylib, sizeof(rubylib), 0);
-#ifndef LOAD_RELATIVE
- if (PRELOADENV[0] && stat(mjit_build_dir, &stbuf) == 0) {
- insert_env_path(PRELOADENV, mjit_build_dir, sizeof(mjit_build_dir), 1);
- setenv("MJIT_SEARCH_BUILD_DIR", "true", 0);
- }
-#endif
if (!(p = strrchr(arg0, '/'))) p = arg0; else p++;
if (strlen(p) < namesize - 1) {
@@ -91,8 +73,5 @@ main(int argc, char **argv)
memcpy(p, rubyname, namesize);
execv(rubypath, argv);
- perror(rubypath);
return -1;
}
-
-#endif /* MAKE_MJIT_BUILD_DIR */
diff --git a/ruby.c b/ruby.c
index 7d8d8e38f5..4ff30cceca 100644
--- a/ruby.c
+++ b/ruby.c
@@ -15,10 +15,8 @@
#include <windows.h>
#include <sys/cygwin.h>
#endif
-#include "ruby/encoding.h"
-#include "ruby/thread.h"
-#include "ruby/version.h"
#include "internal.h"
+#include "ruby/thread.h"
#include "eval_intern.h"
#include "dln.h"
#include <stdio.h>
@@ -52,10 +50,6 @@
#include "ruby/util.h"
-#include "mjit.h"
-
-void Init_ruby_description(void);
-
#ifndef HAVE_STDLIB_H
char *getenv();
#endif
@@ -69,8 +63,6 @@ char *getenv();
#define DEFAULT_RUBYGEMS_ENABLED "enabled"
#endif
-void rb_warning_category_update(unsigned int mask, unsigned int bits);
-
#define COMMA ,
#define FEATURE_BIT(bit) (1U << feature_##bit)
#define EACH_FEATURES(X, SEP) \
@@ -81,8 +73,6 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
X(rubyopt) \
SEP \
X(frozen_string_literal) \
- SEP \
- X(jit) \
/* END OF FEATURES */
#define EACH_DEBUG_FEATURES(X, SEP) \
X(frozen_string_literal) \
@@ -131,24 +121,6 @@ enum dump_flag_bits {
typedef struct ruby_cmdline_options ruby_cmdline_options_t;
-typedef struct {
- unsigned int mask;
- unsigned int set;
-} ruby_features_t;
-
-static inline void
-rb_feature_set_to(ruby_features_t *feat, unsigned int bit_mask, unsigned int bit_set)
-{
- feat->mask |= bit_mask;
- feat->set = (feat->set & ~bit_mask) | bit_set;
-}
-
-#define FEATURE_SET_TO(feat, bit_mask, bit_set) \
- rb_feature_set_to(&(feat), bit_mask, bit_set)
-#define FEATURE_SET(feat, bits) FEATURE_SET_TO(feat, bits, bits)
-#define FEATURE_SET_RESTORE(feat, save) FEATURE_SET_TO(feat, (save).mask, (save).set & (save).mask)
-#define FEATURE_SET_P(feat, bits) ((feat).set & (bits))
-
struct ruby_cmdline_options {
const char *script;
VALUE script_name;
@@ -160,12 +132,9 @@ struct ruby_cmdline_options {
} enc;
} src, ext, intern;
VALUE req_list;
- ruby_features_t features;
- ruby_features_t warn;
+ unsigned int features;
unsigned int dump;
-#if USE_MJIT
- struct mjit_options mjit;
-#endif
+ int safe_level;
int sflag, xflag;
unsigned int warning: 1;
unsigned int verbose: 1;
@@ -193,7 +162,6 @@ enum {
& ~FEATURE_BIT(gems)
#endif
& ~FEATURE_BIT(frozen_string_literal)
- & ~FEATURE_BIT(jit)
)
};
@@ -205,10 +173,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
opt->src.enc.index = src_encoding_index;
opt->ext.enc.index = -1;
opt->intern.enc.index = -1;
- opt->features.set = DEFAULT_FEATURES;
-#ifdef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */
- opt->features.set |= FEATURE_BIT(jit);
-#endif
+ opt->features = DEFAULT_FEATURES;
return opt;
}
@@ -227,7 +192,7 @@ static void
show_usage_line(const char *str, unsigned int namelen, unsigned int secondlen, int help)
{
const unsigned int w = 16;
- const int wrap = help && namelen + secondlen - 1 > w;
+ const int wrap = help && namelen + secondlen - 2 > w;
printf(" %.*s%-*.*s%-*s%s\n", namelen-1, str,
(wrap ? 0 : w - namelen + 1),
(help ? secondlen-1 : 0), str + namelen,
@@ -267,12 +232,11 @@ usage(const char *name, int help)
M("-rlibrary", "", "require the library before executing your script"),
M("-s", "", "enable some switch parsing for switches after script name"),
M("-S", "", "look for the script using PATH environment variable"),
- M("-v", "", "print the version number, then turn on verbose mode"),
+ M("-T[level=1]", "", "turn on tainting checks"),
+ M("-v", ", --verbose", "print version number, then turn on verbose mode"),
M("-w", "", "turn warnings on for your script"),
- M("-W[level=2|:category]", "", "set warning level; 0=silence, 1=medium, 2=verbose"),
+ M("-W[level=2]", "", "set warning level; 0=silence, 1=medium, 2=verbose"),
M("-x[directory]", "", "strip off text before #!ruby line and perhaps cd to directory"),
- M("--jit", "", "enable JIT with default options (experimental)"),
- M("--jit-[option]","", "enable JIT with an option (experimental)"),
M("-h", "", "show this message, --help for more info"),
};
static const struct message help_msg[] = {
@@ -283,8 +247,7 @@ usage(const char *name, int help)
"enable or disable features. see below for available features"),
M("--external-encoding=encoding", ", --internal-encoding=encoding",
"specify the default external or internal character encoding"),
- M("--verbose", "", "turn on verbose mode and disable script from stdin"),
- M("--version", "", "print the version number, then exit"),
+ M("--version", "", "print the version"),
M("--help", "", "show this message, -h for short message"),
};
static const struct message dumps[] = {
@@ -298,20 +261,6 @@ usage(const char *name, int help)
M("did_you_mean", "", "did_you_mean (default: "DEFAULT_RUBYGEMS_ENABLED")"),
M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"),
M("frozen-string-literal", "", "freeze all string literals (default: disabled)"),
- M("jit", "", "JIT compiler (default: disabled)"),
- };
- static const struct message warn_categories[] = {
- M("deprecated", "", "deprecated features"),
- M("experimental", "", "experimental features"),
- };
- static const struct message mjit_options[] = {
- M("--jit-warnings", "", "Enable printing JIT warnings"),
- M("--jit-debug", "", "Enable JIT debugging (very slow), or add cflags if specified"),
- M("--jit-wait", "", "Wait until JIT compilation finishes every time (for testing)"),
- M("--jit-save-temps", "", "Save JIT temporary files in $TMP or /tmp (for testing)"),
- M("--jit-verbose=num", "", "Print JIT logs of level num or less to stderr (default: 0)"),
- M("--jit-max-cache=num", "", "Max number of methods to be JIT-ed in a cache (default: 100)"),
- M("--jit-min-calls=num", "", "Number of calls to trigger JIT (for testing, default: 10000)"),
};
int i;
const int num = numberof(usage_msg) - (help ? 1 : 0);
@@ -331,12 +280,6 @@ usage(const char *name, int help)
puts("Features:");
for (i = 0; i < numberof(features); ++i)
SHOW(features[i]);
- puts("Warning categories:");
- for (i = 0; i < numberof(warn_categories); ++i)
- SHOW(warn_categories[i]);
- puts("JIT options (experimental):");
- for (i = 0; i < numberof(mjit_options); ++i)
- SHOW(mjit_options[i]);
}
#define rubylib_path_new rb_str_new
@@ -499,61 +442,22 @@ str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
# define str_conv_enc(str, from, to) (str)
#endif
-void ruby_init_loadpath(void);
+void ruby_init_loadpath_safe(int safe_level);
-#if defined(LOAD_RELATIVE)
-static VALUE
-runtime_libruby_path(void)
+void
+ruby_init_loadpath(void)
{
-#if defined _WIN32 || defined __CYGWIN__
- DWORD len = RSTRING_EMBED_LEN_MAX, ret;
- VALUE path;
- VALUE wsopath = rb_str_new(0, len*sizeof(WCHAR));
- WCHAR *wlibpath;
- char *libpath;
+ ruby_init_loadpath_safe(0);
+}
- while (wlibpath = (WCHAR *)RSTRING_PTR(wsopath),
- ret = GetModuleFileNameW(libruby, wlibpath, len),
- (ret == len))
- {
- rb_str_modify_expand(wsopath, len*sizeof(WCHAR));
- rb_str_set_len(wsopath, (len += len)*sizeof(WCHAR));
- }
- if (!ret || ret > len) rb_fatal("failed to get module file name");
-#if defined __CYGWIN__
- {
- const int win_to_posix = CCP_WIN_W_TO_POSIX | CCP_RELATIVE;
- size_t newsize = cygwin_conv_path(win_to_posix, wlibpath, 0, 0);
- if (!newsize) rb_fatal("failed to convert module path to cygwin");
- path = rb_str_new(0, newsize);
- libpath = RSTRING_PTR(path);
- if (cygwin_conv_path(win_to_posix, wlibpath, libpath, newsize)) {
- rb_str_resize(path, 0);
- }
- }
-#else
- {
- DWORD i;
- for (len = ret, i = 0; i < len; ++i) {
- if (wlibpath[i] == L'\\') {
- wlibpath[i] = L'/';
- ret = i+1; /* chop after the last separator */
- }
- }
- }
- len = WideCharToMultiByte(CP_UTF8, 0, wlibpath, ret, NULL, 0, NULL, NULL);
- path = rb_utf8_str_new(0, len);
- libpath = RSTRING_PTR(path);
- WideCharToMultiByte(CP_UTF8, 0, wlibpath, ret, libpath, len, NULL, NULL);
-#endif
- rb_str_resize(wsopath, 0);
- return path;
-#elif defined(HAVE_DLADDR)
+#if defined(LOAD_RELATIVE) && defined(HAVE_DLADDR) && !defined(__CYGWIN__)
+static VALUE
+dladdr_path(const void* addr)
+{
Dl_info dli;
VALUE fname, path;
- const void* addr = (void *)(VALUE)expand_include_path;
- if (!dladdr((void *)addr, &dli)) {
+ if (!dladdr(addr, &dli)) {
return rb_str_new(0, 0);
}
#ifdef __linux__
@@ -568,66 +472,102 @@ runtime_libruby_path(void)
}
rb_str_resize(fname, 0);
return path;
-#else
-# error relative load path is not supported on this platform.
-#endif
}
#endif
#define INITIAL_LOAD_PATH_MARK rb_intern_const("@gem_prelude_index")
-VALUE ruby_archlibdir_path, ruby_prefix_path;
-
void
-ruby_init_loadpath(void)
+ruby_init_loadpath_safe(int safe_level)
{
- VALUE load_path, archlibdir = 0;
+ VALUE load_path;
ID id_initial_load_path_mark;
const char *paths = ruby_initial_load_paths;
#if defined LOAD_RELATIVE
-#if !defined ENABLE_MULTIARCH
-# define RUBY_ARCH_PATH ""
-#elif defined RUBY_ARCH
-# define RUBY_ARCH_PATH "/"RUBY_ARCH
-#else
-# define RUBY_ARCH_PATH "/"RUBY_PLATFORM
-#endif
+# if defined HAVE_DLADDR || defined __CYGWIN__ || defined _WIN32
+# define VARIABLE_LIBPATH 1
+# else
+# define VARIABLE_LIBPATH 0
+# endif
+# if VARIABLE_LIBPATH
char *libpath;
VALUE sopath;
+# else
+ char libpath[MAXPATHLEN + 1];
+# endif
size_t baselen;
- const char *p;
+ char *p;
- sopath = runtime_libruby_path();
+#if defined _WIN32 || defined __CYGWIN__
+ {
+ DWORD len = RSTRING_EMBED_LEN_MAX, ret, i;
+ VALUE wsopath = rb_str_new(0, len*sizeof(WCHAR));
+ WCHAR *wlibpath;
+ while (wlibpath = (WCHAR *)RSTRING_PTR(wsopath),
+ ret = GetModuleFileNameW(libruby, wlibpath, len),
+ (ret == len))
+ {
+ rb_str_modify_expand(wsopath, len*sizeof(WCHAR));
+ rb_str_set_len(wsopath, (len += len)*sizeof(WCHAR));
+ }
+ if (!ret || ret > len) rb_fatal("failed to get module file name");
+ for (len = ret, i = 0; i < len; ++i) {
+ if (wlibpath[i] == L'\\') {
+ wlibpath[i] = L'/';
+ ret = i+1; /* chop after the last separator */
+ }
+ }
+ len = WideCharToMultiByte(CP_UTF8, 0, wlibpath, ret, NULL, 0, NULL, NULL);
+ sopath = rb_utf8_str_new(0, len);
+ libpath = RSTRING_PTR(sopath);
+ WideCharToMultiByte(CP_UTF8, 0, wlibpath, ret, libpath, len, NULL, NULL);
+ rb_str_resize(wsopath, 0);
+ }
+#elif defined(HAVE_DLADDR)
+ sopath = dladdr_path((void *)(VALUE)expand_include_path);
libpath = RSTRING_PTR(sopath);
+#endif
+#if !VARIABLE_LIBPATH
+ libpath[sizeof(libpath) - 1] = '\0';
+#endif
+#if defined DOSISH && !defined _WIN32
+ translit_char(libpath, '\\', '/');
+#elif defined __CYGWIN__
+ {
+ const int win_to_posix = CCP_WIN_A_TO_POSIX | CCP_RELATIVE;
+ size_t newsize = cygwin_conv_path(win_to_posix, libpath, 0, 0);
+ if (newsize > 0) {
+ VALUE rubylib = rb_str_new(0, newsize);
+ p = RSTRING_PTR(rubylib);
+ if (cygwin_conv_path(win_to_posix, libpath, p, newsize) == 0) {
+ rb_str_resize(sopath, 0);
+ sopath = rubylib;
+ libpath = p;
+ }
+ }
+ }
+#endif
p = strrchr(libpath, '/');
if (p) {
- static const char libdir[] = "/"
+ static const char bindir[] = "/bin";
#ifdef LIBDIR_BASENAME
- LIBDIR_BASENAME
+ static const char libdir[] = "/"LIBDIR_BASENAME;
#else
- "lib"
+ static const char libdir[] = "/lib";
#endif
- RUBY_ARCH_PATH;
- const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir)
- - rb_strlen_lit(RUBY_ARCH_PATH) - 1;
- static const char bindir[] = "/bin";
const ptrdiff_t bindir_len = (ptrdiff_t)sizeof(bindir) - 1;
-
- const char *p2 = NULL;
+ const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir) - 1;
#ifdef ENABLE_MULTIARCH
+ char *p2 = NULL;
+
multiarch:
#endif
if (p - libpath >= bindir_len && !STRNCASECMP(p - bindir_len, bindir, bindir_len)) {
p -= bindir_len;
- archlibdir = rb_str_subseq(sopath, 0, p - libpath);
- rb_str_cat_cstr(archlibdir, libdir);
- OBJ_FREEZE_RAW(archlibdir);
}
else if (p - libpath >= libdir_len && !strncmp(p - libdir_len, libdir, libdir_len)) {
- archlibdir = rb_str_subseq(sopath, 0, (p2 ? p2 : p) - libpath);
- OBJ_FREEZE_RAW(archlibdir);
p -= libdir_len;
}
#ifdef ENABLE_MULTIARCH
@@ -641,28 +581,37 @@ ruby_init_loadpath(void)
p = p2;
}
#endif
+#if !VARIABLE_LIBPATH
+ *p = 0;
+#endif
+ }
+#if !VARIABLE_LIBPATH
+ else {
+ strlcpy(libpath, ".", sizeof(libpath));
+ p = libpath + 1;
}
baselen = p - libpath;
+#define PREFIX_PATH() rb_str_new(libpath, baselen)
+#else
+ baselen = p - libpath;
rb_str_resize(sopath, baselen);
libpath = RSTRING_PTR(sopath);
#define PREFIX_PATH() sopath
+#endif
+
#define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen)
+
#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))
#else
const size_t exec_prefix_len = strlen(ruby_exec_prefix);
#define RUBY_RELATIVE(path, len) rubylib_path_new((path), (len))
#define PREFIX_PATH() RUBY_RELATIVE(ruby_exec_prefix, exec_prefix_len)
#endif
- rb_gc_register_address(&ruby_prefix_path);
- ruby_prefix_path = PREFIX_PATH();
- OBJ_FREEZE_RAW(ruby_prefix_path);
- if (!archlibdir) archlibdir = ruby_prefix_path;
- rb_gc_register_address(&ruby_archlibdir_path);
- ruby_archlibdir_path = archlibdir;
-
load_path = GET_VM()->load_path;
- ruby_push_include(getenv("RUBYLIB"), identical_path);
+ if (safe_level == 0) {
+ ruby_push_include(getenv("RUBYLIB"), identical_path);
+ }
id_initial_load_path_mark = INITIAL_LOAD_PATH_MARK;
while (*paths) {
@@ -673,7 +622,7 @@ ruby_init_loadpath(void)
paths += len + 1;
}
- rb_const_set(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"), ruby_prefix_path);
+ rb_const_set(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"), rb_obj_freeze(PREFIX_PATH()));
}
@@ -684,9 +633,11 @@ add_modules(VALUE *req_list, const char *mod)
VALUE feature;
if (!list) {
- *req_list = list = rb_ary_tmp_new(0);
+ *req_list = list = rb_ary_new();
+ RBASIC_CLEAR_CLASS(list);
}
- feature = rb_str_cat_cstr(rb_str_tmp_new(0), mod);
+ feature = rb_str_new2(mod);
+ RBASIC_CLEAR_CLASS(feature);
rb_ary_push(list, feature);
}
@@ -788,7 +739,6 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
char **argv, *p;
const char *ap = 0;
VALUE argstr, argary;
- void *ptr;
while (ISSPACE(*s)) s++;
if (!*s) return;
@@ -811,8 +761,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
argc = RSTRING_LEN(argary) / sizeof(ap);
ap = 0;
rb_str_cat(argary, (char *)&ap, sizeof(ap));
- argv = ptr = ALLOC_N(char *, argc);
- MEMMOVE(argv, RSTRING_PTR(argary), char *, argc);
+ argv = (char **)RSTRING_PTR(argary);
while ((i = proc_options(argc, argv, opt, envopt)) > 1 && envopt && (argc -= i) > 0) {
argv += i;
@@ -825,7 +774,6 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
}
}
- ruby_xfree(ptr);
/* get rid of GC */
rb_str_resize(argary, 0);
rb_str_resize(argstr, 0);
@@ -835,7 +783,7 @@ static int
name_match_p(const char *name, const char *str, size_t len)
{
if (len == 0) return 0;
- while (1) {
+ do {
while (TOLOWER(*str) == *name) {
if (!--len || !*++str) return 1;
++name;
@@ -845,7 +793,8 @@ name_match_p(const char *name, const char *str, size_t len)
if (*name != '-' && *name != '_') return 0;
++name;
++str;
- }
+ } while (len > 0);
+ return !*name;
}
#define NAME_MATCH_P(name, str, len) \
@@ -869,21 +818,21 @@ static void
feature_option(const char *str, int len, void *arg, const unsigned int enable)
{
static const char list[] = EACH_FEATURES(LITERAL_NAME_ELEMENT, ", ");
- ruby_features_t *argp = arg;
+ unsigned int *argp = arg;
unsigned int mask = ~0U;
- unsigned int set = 0U;
#if AMBIGUOUS_FEATURE_NAMES
+ unsigned int set = 0U;
int matched = 0;
-# define FEATURE_FOUND ++matched
+#define SET_FEATURE(bit) \
+ if (NAME_MATCH_P(#bit, str, len)) {set |= mask = FEATURE_BIT(bit); ++matched;}
#else
-# define FEATURE_FOUND goto found
-#endif
#define SET_FEATURE(bit) \
- if (NAME_MATCH_P(#bit, str, len)) {set |= mask = FEATURE_BIT(bit); FEATURE_FOUND;}
+ if (NAME_MATCH_P(#bit, str, len)) {mask = FEATURE_BIT(bit); goto found;}
+#endif
EACH_FEATURES(SET_FEATURE, ;);
if (NAME_MATCH_P("all", str, len)) {
found:
- FEATURE_SET_TO(*argp, mask, (mask & enable));
+ *argp = (*argp & ~mask) | (mask & enable);
return;
}
#if AMBIGUOUS_FEATURE_NAMES
@@ -925,12 +874,7 @@ static void
debug_option(const char *str, int len, void *arg)
{
static const char list[] = EACH_DEBUG_FEATURES(LITERAL_NAME_ELEMENT, ", ");
- ruby_features_t *argp = arg;
-#define SET_WHEN_DEBUG(bit) \
- if (NAME_MATCH_P(#bit, str, len)) { \
- FEATURE_SET(*argp, DEBUG_BIT(bit)); \
- return; \
- }
+#define SET_WHEN_DEBUG(bit) SET_WHEN(#bit, DEBUG_BIT(bit), str, len)
EACH_DEBUG_FEATURES(SET_WHEN_DEBUG, ;);
#ifdef RUBY_DEVEL
if (ruby_patchlevel < 0 && ruby_env_debug_option(str, len, 0)) return;
@@ -972,42 +916,6 @@ set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen
#define set_source_encoding_once(opt, e, elen) \
set_option_encoding_once("source", &(opt)->src.enc.name, (e), (elen))
-#if USE_MJIT
-static void
-setup_mjit_options(const char *s, struct mjit_options *mjit_opt)
-{
- if (*s == 0) return;
- else if (strcmp(s, "-warnings") == 0) {
- mjit_opt->warnings = 1;
- }
- else if (strncmp(s, "-debug=", 7) == 0) {
- mjit_opt->debug_flags = strdup(s + 7);
- }
- else if (strcmp(s, "-debug") == 0) {
- mjit_opt->debug = 1;
- }
- else if (strcmp(s, "-wait") == 0) {
- mjit_opt->wait = 1;
- }
- else if (strcmp(s, "-save-temps") == 0) {
- mjit_opt->save_temps = 1;
- }
- else if (strncmp(s, "-verbose=", 9) == 0) {
- mjit_opt->verbose = atoi(s + 9);
- }
- else if (strncmp(s, "-max-cache=", 11) == 0) {
- mjit_opt->max_cache_size = atoi(s + 11);
- }
- else if (strncmp(s, "-min-calls=", 11) == 0) {
- mjit_opt->min_calls = atoi(s + 11);
- }
- else {
- rb_raise(rb_eRuntimeError,
- "invalid MJIT option `%s' (--help will show valid MJIT options)", s + 1);
- }
-}
-#endif
-
static long
proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
{
@@ -1066,29 +974,10 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
warning = 1;
ruby_verbose = Qtrue;
}
- FEATURE_SET(opt->warn, RB_WARN_CATEGORY_ALL_BITS);
s++;
goto reswitch;
case 'W':
- if (s[1] == ':') {
- unsigned int bits = 0;
- static const char no_prefix[] = "no-";
- int enable = strncmp(s += 2, no_prefix, sizeof(no_prefix)-1) != 0;
- if (!enable) s += sizeof(no_prefix)-1;
- size_t len = strlen(s);
- if (NAME_MATCH_P("deprecated", s, len)) {
- bits = 1U << RB_WARN_CATEGORY_DEPRECATED;
- }
- else if (NAME_MATCH_P("experimental", s, len)) {
- bits = 1U << RB_WARN_CATEGORY_EXPERIMENTAL;
- }
- else {
- rb_warn("unknown warning category: `%s'", s);
- }
- if (bits) FEATURE_SET_TO(opt->warn, bits, enable ? bits : 0);
- break;
- }
{
size_t numlen;
int v = 2; /* -W as -W2 */
@@ -1113,17 +1002,6 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
}
}
warning = 1;
- switch (v) {
- case 0:
- FEATURE_SET_TO(opt->warn, RB_WARN_CATEGORY_ALL_BITS, 0);
- break;
- case 1:
- FEATURE_SET_TO(opt->warn, 1U << RB_WARN_CATEGORY_DEPRECATED, 0);
- break;
- default:
- FEATURE_SET(opt->warn, RB_WARN_CATEGORY_ALL_BITS);
- break;
- }
}
goto reswitch;
@@ -1259,15 +1137,18 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
goto reswitch;
case 'T':
- {
- size_t numlen;
+ {
+ size_t numlen;
+ int v = 1;
- if (*++s) {
- scan_oct(s, 2, &numlen);
- s += numlen;
- }
- }
- rb_warn("ruby -T will be removed in Ruby 3.0");
+ if (*++s) {
+ v = scan_oct(s, 2, &numlen);
+ if (numlen == 0)
+ v = 1;
+ s += numlen;
+ }
+ if (v > opt->safe_level) opt->safe_level = v;
+ }
goto reswitch;
case 'I':
@@ -1387,14 +1268,6 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
opt->verbose = 1;
ruby_verbose = Qtrue;
}
- else if (strncmp("jit", s, 3) == 0) {
-#if USE_MJIT
- FEATURE_SET(opt->features, FEATURE_BIT(jit));
- setup_mjit_options(s + 3, &opt->mjit);
-#else
- rb_warn("MJIT support is disabled.");
-#endif
- }
else if (strcmp("yydebug", s) == 0) {
if (envopt) goto noenvopt_long;
opt->dump |= DUMP_BIT(yydebug);
@@ -1419,9 +1292,16 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
default:
{
- rb_raise(rb_eRuntimeError,
+ if (ISPRINT(*s)) {
+ rb_raise(rb_eRuntimeError,
"invalid option -%c (-h will show valid options)",
(int)(unsigned char)*s);
+ }
+ else {
+ rb_raise(rb_eRuntimeError,
+ "invalid option -\\x%02X (-h will show valid options)",
+ (int)(unsigned char)*s);
+ }
}
goto switch_end;
@@ -1449,12 +1329,10 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
return argc0 - argc;
}
-void Init_builtin_features(void);
-
static void
ruby_init_prelude(void)
{
- Init_builtin_features();
+ Init_prelude();
rb_const_remove(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"));
}
@@ -1476,16 +1354,15 @@ opt_enc_index(VALUE enc_name)
#define rb_progname (GET_VM()->progname)
#define rb_orig_progname (GET_VM()->orig_progname)
VALUE rb_argv0;
-VALUE rb_e_script;
static VALUE
-false_value(ID _x, VALUE *_y)
+false_value(void)
{
return Qfalse;
}
static VALUE
-true_value(ID _x, VALUE *_y)
+true_value(void)
{
return Qtrue;
}
@@ -1517,7 +1394,7 @@ uscore_get(void)
*/
static VALUE
-rb_f_sub(int argc, VALUE *argv, VALUE _)
+rb_f_sub(int argc, VALUE *argv)
{
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("sub"), argc, argv);
rb_lastline_set(str);
@@ -1536,7 +1413,7 @@ rb_f_sub(int argc, VALUE *argv, VALUE _)
*/
static VALUE
-rb_f_gsub(int argc, VALUE *argv, VALUE _)
+rb_f_gsub(int argc, VALUE *argv)
{
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("gsub"), argc, argv);
rb_lastline_set(str);
@@ -1548,13 +1425,13 @@ rb_f_gsub(int argc, VALUE *argv, VALUE _)
* chop -> $_
*
* Equivalent to <code>($_.dup).chop!</code>, except <code>nil</code>
- * is never returned. See String#chop!.
+ * is never returned. See <code>String#chop!</code>.
* Available only when -p/-n command line option specified.
*
*/
static VALUE
-rb_f_chop(VALUE _)
+rb_f_chop(void)
{
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("chop"), 0, 0);
rb_lastline_set(str);
@@ -1568,13 +1445,13 @@ rb_f_chop(VALUE _)
* chomp(string) -> $_
*
* Equivalent to <code>$_ = $_.chomp(<em>string</em>)</code>. See
- * String#chomp.
+ * <code>String#chomp</code>.
* Available only when -p/-n command line option specified.
*
*/
static VALUE
-rb_f_chomp(int argc, VALUE *argv, VALUE _)
+rb_f_chomp(int argc, VALUE *argv)
{
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("chomp"), argc, argv);
rb_lastline_set(str);
@@ -1595,6 +1472,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
const char *s;
char fbuf[MAXPATHLEN];
int i = (int)proc_options(argc, argv, opt, 0);
+ rb_binding_t *toplevel_binding;
+ const struct rb_block *base_block;
unsigned int dump = opt->dump & dump_exit_bits;
if (opt->dump & (DUMP_BIT(usage)|DUMP_BIT(help))) {
@@ -1609,12 +1488,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
argc -= i;
argv += i;
- if ((opt->features.set & FEATURE_BIT(rubyopt)) && (s = getenv("RUBYOPT"))) {
+ if ((opt->features & FEATURE_BIT(rubyopt)) &&
+ opt->safe_level == 0 && (s = getenv("RUBYOPT"))) {
VALUE src_enc_name = opt->src.enc.name;
VALUE ext_enc_name = opt->ext.enc.name;
VALUE int_enc_name = opt->intern.enc.name;
- ruby_features_t feat = opt->features;
- ruby_features_t warn = opt->warn;
opt->src.enc.name = opt->ext.enc.name = opt->intern.enc.name = 0;
moreswitches(s, opt, 1);
@@ -1624,22 +1502,12 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
opt->ext.enc.name = ext_enc_name;
if (int_enc_name)
opt->intern.enc.name = int_enc_name;
- FEATURE_SET_RESTORE(opt->features, feat);
- FEATURE_SET_RESTORE(opt->warn, warn);
}
if (opt->src.enc.name)
rb_warning("-K is specified; it is for 1.8 compatibility and may cause odd behavior");
-#if USE_MJIT
- if (opt->features.set & FEATURE_BIT(jit)) {
- opt->mjit.on = TRUE; /* set mjit.on for ruby_show_version() API and check to call mjit_init() */
- }
-#endif
if (opt->dump & (DUMP_BIT(version) | DUMP_BIT(version_v))) {
-#if USE_MJIT
- mjit_opts.on = opt->mjit.on; /* used by ruby_show_version(). mjit_init() still can't be called here. */
-#endif
ruby_show_version();
if (opt->dump & DUMP_BIT(version)) return Qtrue;
}
@@ -1689,16 +1557,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
translit_char(RSTRING_PTR(opt->script_name), '\\', '/');
#endif
- ruby_gc_set_params();
- ruby_init_loadpath();
-
-#if USE_MJIT
- if (opt->mjit.on)
- /* Using TMP_RUBY_PREFIX created by ruby_init_loadpath(). */
- mjit_init(&opt->mjit);
-#endif
-
- Init_ruby_description();
+ ruby_gc_set_params(opt->safe_level);
+ ruby_init_loadpath_safe(opt->safe_level);
Init_enc();
lenc = rb_locale_encoding();
rb_enc_associate(rb_progname, lenc);
@@ -1771,22 +1631,19 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_ary_replace(vm->load_path_snapshot, load_path);
}
}
-
- rb_warning_category_update(opt->warn.mask, opt->warn.set);
-
Init_ext(); /* load statically linked extensions before rubygems */
- if (opt->features.set & FEATURE_BIT(gems)) {
+ if (opt->features & FEATURE_BIT(gems)) {
rb_define_module("Gem");
- if (opt->features.set & FEATURE_BIT(did_you_mean)) {
- rb_define_module("DidYouMean");
- }
+ }
+ if (opt->features & FEATURE_BIT(did_you_mean)) {
+ rb_define_module("DidYouMean");
}
ruby_init_prelude();
- if (opt->features.mask & COMPILATION_FEATURES) {
+ if ((opt->features ^ DEFAULT_FEATURES) & COMPILATION_FEATURES) {
VALUE option = rb_hash_new();
#define SET_COMPILE_OPTION(h, o, name) \
rb_hash_aset((h), ID2SYM(rb_intern_const(#name)), \
- (FEATURE_SET_P(o->features, FEATURE_BIT(name)) ? Qtrue : Qfalse));
+ ((o)->features & FEATURE_BIT(name) ? Qtrue : Qfalse));
SET_COMPILE_OPTION(option, opt, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option);
@@ -1795,7 +1652,13 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
ruby_set_argv(argc, argv);
process_sflag(&opt->sflag);
- rb_parser_set_context(parser, 0, TRUE);
+ GetBindingPtr(rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING")),
+ toplevel_binding);
+ /* need to acquire env from toplevel_binding each time, since it
+ * may update after eval() */
+
+ base_block = toplevel_context(toplevel_binding);
+ rb_parser_set_context(parser, base_block, TRUE);
if (opt->e_script) {
VALUE progname = rb_progname;
@@ -1852,7 +1715,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_enc_set_default_internal(Qnil);
rb_stdio_set_default_encoding();
- if (!ast->body.root) {
+ if (!ast->root) {
rb_ast_dispose(ast);
return Qfalse;
}
@@ -1874,7 +1737,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
}
if (dump & (DUMP_BIT(parsetree)|DUMP_BIT(parsetree_with_comment))) {
- rb_io_write(rb_stdout, rb_parser_dump_tree(ast->body.root, dump & DUMP_BIT(parsetree_with_comment)));
+ rb_io_write(rb_stdout, rb_parser_dump_tree(ast->root, dump & DUMP_BIT(parsetree_with_comment)));
rb_io_flush(rb_stdout);
dump &= ~DUMP_BIT(parsetree)&~DUMP_BIT(parsetree_with_comment);
if (!dump) {
@@ -1896,12 +1759,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_enc_copy(path, opt->script_name);
}
}
-
- rb_binding_t *toplevel_binding;
- GetBindingPtr(rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING")),
- toplevel_binding);
- const struct rb_block *base_block = toplevel_context(toplevel_binding);
- iseq = rb_iseq_new_main(&ast->body, opt->script_name, path, vm_block_iseq(base_block));
+ base_block = toplevel_context(toplevel_binding);
+ iseq = rb_iseq_new_main(ast->root, opt->script_name, path, vm_block_iseq(base_block));
rb_ast_dispose(ast);
}
@@ -1917,22 +1776,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_define_readonly_boolean("$-l", opt->do_line);
rb_define_readonly_boolean("$-a", opt->do_split);
- if ((rb_e_script = opt->e_script) != 0) {
- rb_gc_register_mark_object(opt->e_script);
- }
-
- {
- rb_execution_context_t *ec = GET_EC();
+ rb_set_safe_level(opt->safe_level);
- if (opt->e_script) {
- /* -e */
- rb_exec_event_hook_script_compiled(ec, iseq, opt->e_script);
- }
- else {
- /* file */
- rb_exec_event_hook_script_compiled(ec, iseq, Qnil);
- }
- }
return (VALUE)iseq;
}
@@ -2041,7 +1886,7 @@ load_file_internal(VALUE argp_v)
else if (!NIL_P(c)) {
rb_io_ungetbyte(f, c);
}
- if (NIL_P(c)) {
+ else {
argp->f = f = Qnil;
}
if (!(opt->dump & ~DUMP_BIT(version_v))) {
@@ -2126,7 +1971,7 @@ open_load_file(VALUE fname_v, int *xflag)
#endif
if ((fd = rb_cloexec_open(fname, mode, 0)) < 0) {
- e = errno;
+ int e = errno;
if (!rb_gc_for_fd(e)) {
rb_load_fail(fname_v, strerror(e));
}
@@ -2261,7 +2106,7 @@ ruby_setproctitle(VALUE title)
}
static void
-set_arg0(VALUE val, ID id, VALUE *_)
+set_arg0(VALUE val, ID id)
{
if (origarg.argv == 0)
rb_raise(rb_eRuntimeError, "$0 not initialized");
@@ -2275,6 +2120,7 @@ external_str_new_cstr(const char *p)
#if UTF8_PATH
VALUE str = rb_utf8_str_new_cstr(p);
str = str_conv_enc(str, NULL, rb_default_external_encoding());
+ OBJ_TAINT_RAW(str);
return str;
#else
return rb_external_str_new_cstr(p);
@@ -2316,6 +2162,9 @@ init_ids(ruby_cmdline_options_t *opt)
if (uid != euid) opt->setids |= 1;
if (egid != gid) opt->setids |= 2;
+ if (uid && opt->setids) {
+ if (opt->safe_level < 1) opt->safe_level = 1;
+ }
}
#undef forbid_setid
@@ -2326,17 +2175,21 @@ forbid_setid(const char *s, const ruby_cmdline_options_t *opt)
rb_raise(rb_eSecurityError, "no %s allowed while running setuid", s);
if (opt->setids & 2)
rb_raise(rb_eSecurityError, "no %s allowed while running setgid", s);
+ if (opt->safe_level > 0)
+ rb_raise(rb_eSecurityError, "no %s allowed in tainted mode", s);
}
static void
-verbose_setter(VALUE val, ID id, VALUE *variable)
+verbose_setter(VALUE val, ID id, void *data)
{
+ VALUE *variable = data;
*variable = RTEST(val) ? Qtrue : val;
}
static VALUE
-opt_W_getter(ID id, VALUE *variable)
+opt_W_getter(ID id, void *data)
{
+ VALUE *variable = data;
switch (*variable) {
case Qnil:
return INT2FIX(0);
diff --git a/ruby_assert.h b/ruby_assert.h
index fa15da1e25..3383e4fc6c 100644
--- a/ruby_assert.h
+++ b/ruby_assert.h
@@ -1,15 +1,54 @@
-#include "ruby/assert.h"
+#ifndef RUBY_ASSERT_H
+#define RUBY_ASSERT_H
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
-/* C89 compilers are required to support strings of only 509 chars. */
-/* can't use RUBY_ASSERT for such compilers. */
-#include <assert.h>
+#include "ruby/ruby.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#if 0
+} /* satisfy cc-mode */
+#endif
+#endif
+
+NORETURN(void rb_assert_failure(const char *, int, const char *, const char *));
+#ifdef RUBY_FUNCTION_NAME_STRING
+# define RUBY_ASSERT_FAIL(expr) \
+ rb_assert_failure(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, expr)
+#else
+# define RUBY_ASSERT_FAIL(expr) \
+ rb_assert_failure(__FILE__, __LINE__, NULL, expr)
+#endif
+#define RUBY_ASSERT_MESG(expr, mesg) \
+ ((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg))
+#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P
+# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
+ __builtin_choose_expr( \
+ __builtin_constant_p(cond), \
+ __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \
+ RUBY_ASSERT_MESG(!(cond) || (expr), mesg))
#else
+# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
+ RUBY_ASSERT_MESG(!(cond) || (expr), mesg)
+#endif
+#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(!RUBY_NDEBUG+0, expr, #expr)
+#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr)
+
#undef assert
#define assert RUBY_ASSERT
+
+#ifndef RUBY_NDEBUG
+# ifdef NDEBUG
+# define RUBY_NDEBUG 1
+# else
+# define RUBY_NDEBUG 0
+# endif
+#endif
+
+#if defined(__cplusplus)
+#if 0
+{ /* satisfy cc-mode */
+#endif
+} /* extern "C" { */
#endif
-#ifdef NDEBUG
- #undef RUBY_NDEBUG
- #define RUBY_NDEBUG 1
#endif
diff --git a/ruby_atomic.h b/ruby_atomic.h
index 2516dbfb42..4bc9f37e0d 100644
--- a/ruby_atomic.h
+++ b/ruby_atomic.h
@@ -90,10 +90,6 @@ rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t new
# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange((LONG *)&(var), (val))
# endif
-# ifdef InterlockedExchangePointer
-# define ATOMIC_PTR_EXCHANGE(var, val) InterlockedExchangePointer((PVOID volatile *)&(var), (PVOID)(val))
-# endif /* See below for definitions of other situations */
-
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
#include <atomic.h>
typedef unsigned int rb_atomic_t;
@@ -150,15 +146,12 @@ ruby_atomic_size_exchange(size_t *ptr, size_t val)
#ifndef ATOMIC_SIZE_INC
# define ATOMIC_SIZE_INC(var) ATOMIC_INC(var)
#endif
-
#ifndef ATOMIC_SIZE_DEC
# define ATOMIC_SIZE_DEC(var) ATOMIC_DEC(var)
#endif
-
#ifndef ATOMIC_SIZE_EXCHANGE
# define ATOMIC_SIZE_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val)
#endif
-
#ifndef ATOMIC_SIZE_CAS
# define ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
#endif
@@ -167,7 +160,6 @@ ruby_atomic_size_exchange(size_t *ptr, size_t val)
# ifndef ATOMIC_PTR_EXCHANGE
# define ATOMIC_PTR_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val)
# endif
-
# ifndef ATOMIC_PTR_CAS
# define ATOMIC_PTR_CAS(var, oldval, newval) ATOMIC_CAS(var, oldval, newval)
# endif
@@ -175,7 +167,6 @@ ruby_atomic_size_exchange(size_t *ptr, size_t val)
# ifndef ATOMIC_VALUE_EXCHANGE
# define ATOMIC_VALUE_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val)
# endif
-
# ifndef ATOMIC_VALUE_CAS
# define ATOMIC_VALUE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
# endif
@@ -195,7 +186,6 @@ ruby_atomic_ptr_exchange(const void **ptr, const void *val)
}
# endif
#endif
-
#ifndef ATOMIC_PTR_CAS
# if SIZEOF_VOIDP == SIZEOF_SIZE_T
# define ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
@@ -225,7 +215,6 @@ ruby_atomic_value_exchange(VALUE *ptr, VALUE val)
}
# endif
#endif
-
#ifndef ATOMIC_VALUE_CAS
# if SIZEOF_VALUE == SIZEOF_SIZE_T
# define ATOMIC_VALUE_CAS(var, oldval, val) ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
diff --git a/safe.c b/safe.c
index a6b4905337..3575ecca15 100644
--- a/safe.c
+++ b/safe.c
@@ -9,6 +9,11 @@
**********************************************************************/
+/* safe-level:
+ 0 - strings from streams/environment/ARGV are tainted (default)
+ 1 - no dangerous operation by tainted value
+*/
+
#define SAFE_LEVEL_MAX RUBY_SAFE_LEVEL_MAX
#include "ruby/ruby.h"
@@ -23,91 +28,80 @@
int
ruby_safe_level_2_warning(void)
{
- rb_warn("rb_safe_level_2_warning will be removed in Ruby 3.0");
return 2;
}
int
rb_safe_level(void)
{
- rb_warn("rb_safe_level will be removed in Ruby 3.0");
- return GET_VM()->safe_level_;
+ return GET_EC()->safe_level;
}
void
rb_set_safe_level_force(int safe)
{
- rb_warn("rb_set_safe_level_force will be removed in Ruby 3.0");
- GET_VM()->safe_level_ = safe;
+ GET_EC()->safe_level = safe;
}
void
rb_set_safe_level(int level)
{
- rb_vm_t *vm = GET_VM();
-
- rb_warn("rb_set_safe_level will be removed in Ruby 3.0");
- if (level > SAFE_LEVEL_MAX) {
- rb_raise(rb_eArgError, "$SAFE=2 to 4 are obsolete");
- }
- else if (level < 0) {
- rb_raise(rb_eArgError, "$SAFE should be >= 0");
- }
- else {
- int line;
- const char *path = rb_source_location_cstr(&line);
+ rb_execution_context_t *ec = GET_EC();
- if (0) fprintf(stderr, "%s:%d $SAFE %d -> %d\n",
- path ? path : "-", line, vm->safe_level_, level);
+ if (level > ec->safe_level) {
+ if (level > SAFE_LEVEL_MAX) {
+ rb_raise(rb_eArgError, "$SAFE=2 to 4 are obsolete");
+ }
+ /* block parameters */
+ rb_vm_stack_to_heap(ec);
- vm->safe_level_ = level;
+ ec->safe_level = level;
}
}
static VALUE
-safe_getter(ID _x, VALUE *_y)
+safe_getter(void)
{
- rb_warn("$SAFE will become a normal global variable in Ruby 3.0");
- return INT2NUM(GET_VM()->safe_level_);
+ return INT2NUM(rb_safe_level());
}
static void
-safe_setter(VALUE val, ID _x, VALUE *_y)
+safe_setter(VALUE val)
{
+ rb_execution_context_t *ec = GET_EC();
+ int current_level = ec->safe_level;
int level = NUM2INT(val);
- rb_vm_t *vm = GET_VM();
- rb_warn("$SAFE will become a normal global variable in Ruby 3.0");
- if (level > SAFE_LEVEL_MAX) {
- rb_raise(rb_eArgError, "$SAFE=2 to 4 are obsolete");
+ if (level == current_level) {
+ return;
}
- else if (level < 0) {
- rb_raise(rb_eArgError, "$SAFE should be >= 0");
+ else if (level < current_level) {
+ rb_raise(rb_eSecurityError,
+ "tried to downgrade safe level from %d to %d",
+ current_level, level);
+ }
+ else if (level > SAFE_LEVEL_MAX) {
+ rb_raise(rb_eArgError, "$SAFE=2 to 4 are obsolete");
}
- else {
- int line;
- const char *path = rb_source_location_cstr(&line);
- if (0) fprintf(stderr, "%s:%d $SAFE %d -> %d\n",
- path ? path : "-", line, vm->safe_level_, level);
+ /* block parameters */
+ rb_vm_stack_to_heap(ec);
- vm->safe_level_ = level;
- }
+ ec->safe_level = level;
}
void
rb_secure(int level)
{
- rb_warn("rb_secure will be removed in Ruby 3.0");
- if (level <= GET_VM()->safe_level_) {
+ if (level <= rb_safe_level()) {
ID caller_name = rb_frame_callee();
if (caller_name) {
rb_raise(rb_eSecurityError, "Insecure operation `%"PRIsVALUE"' at level %d",
- rb_id2str(caller_name), GET_VM()->safe_level_);
+ rb_id2str(caller_name), rb_safe_level());
}
else {
rb_raise(rb_eSecurityError, "Insecure operation at level %d",
- GET_VM()->safe_level_);
+ rb_safe_level());
}
}
}
@@ -115,13 +109,11 @@ rb_secure(int level)
void
rb_secure_update(VALUE obj)
{
- rb_warn("rb_secure_update will be removed in Ruby 3.0");
}
void
rb_insecure_operation(void)
{
- rb_warn("rb_insecure_operation will be removed in Ruby 3.0");
ID caller_name = rb_frame_callee();
if (caller_name) {
rb_raise(rb_eSecurityError, "Insecure operation - %"PRIsVALUE,
@@ -135,7 +127,9 @@ rb_insecure_operation(void)
void
rb_check_safe_obj(VALUE x)
{
- rb_warn("rb_check_safe_obj will be removed in Ruby 3.0");
+ if (rb_safe_level() > 0 && OBJ_TAINTED(x)) {
+ rb_insecure_operation();
+ }
}
void
diff --git a/sample/README b/sample/README
index b55234a947..796aba1dc3 100644
--- a/sample/README
+++ b/sample/README
@@ -16,6 +16,7 @@ fib.pl Fibonacci number (Perl)
fib.py Fibonacci number (Python)
fib.rb Fibonacci number (Ruby)
fib.scm Fibonacci number (Scheme)
+freq.rb count word occurrence
from.rb scan mail spool
fullpath.rb convert ls -lR to fullpath format
less.rb front end for less
@@ -28,6 +29,7 @@ mpart.rb split file int multi part
observ.rb observer design pattern sample
occur.pl count word occurrence (Perl)
occur.rb count word occurrence (Ruby)
+occur2.rb count word occurrence - another style
philos.rb famous dining philosophers
pi.rb calculate PI
rcs.awk random character stereogram (AWK)
diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb
index f5d189014b..bd7c39f5aa 100644
--- a/sample/biorhythm.rb
+++ b/sample/biorhythm.rb
@@ -25,7 +25,7 @@
# Environment: basic, dos, os9
include Math
-require "date"
+require "date.rb"
require "optparse"
require "optparse/date"
@@ -36,10 +36,11 @@ def print_header(y, m, d, p, w)
end
def get_position(z)
+ pi = Math::PI
z = Integer(z)
- phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * PI / 180.0))).to_i
- emot = (50.0 * (1.0 + sin((z / 28.0 - (z / 28)) * 360.0 * PI / 180.0))).to_i
- geist =(50.0 * (1.0 + sin((z / 33.0 - (z / 33)) * 360.0 * PI / 180.0))).to_i
+ phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i
+ emot = (50.0 * (1.0 + sin((z / 28.0 - (z / 28)) * 360.0 * pi / 180.0))).to_i
+ geist =(50.0 * (1.0 + sin((z / 33.0 - (z / 33)) * 360.0 * pi / 180.0))).to_i
return phys, emot, geist
end
diff --git a/sample/dir.rb b/sample/dir.rb
index 0c55078973..44733c2cf4 100644
--- a/sample/dir.rb
+++ b/sample/dir.rb
@@ -3,7 +3,7 @@
dirp = Dir.open(".")
for f in dirp
case f
- when /\A\./, /~\z/, /\.o\z/
+ when /\A\./, /~\z/, /\.o/
# do not print
else
print f, "\n"
diff --git a/sample/drb/http0serv.rb b/sample/drb/http0serv.rb
index 2e853312e1..1a58811fed 100644
--- a/sample/drb/http0serv.rb
+++ b/sample/drb/http0serv.rb
@@ -1,6 +1,6 @@
require 'webrick'
require 'drb/drb'
-require_relative 'http0'
+require 'drb/http0'
module DRb
module HTTP0
@@ -61,7 +61,7 @@ module DRb
def accept
client = @queue.pop
- ServerSide.new(uri, client, @config)
+ ServerSide.new(client, @config)
end
def setup_webrick(uri)
@@ -79,14 +79,12 @@ module DRb
end
class ServerSide
- def initialize(uri, callback, config)
- @uri = uri
+ def initialize(callback, config)
@callback = callback
@config = config
@msg = DRbMessage.new(@config)
@req_stream = StrStream.new(@callback.req_body)
end
- attr_reader :uri
def close
@callback.close if @callback
diff --git a/sample/drb/old_tuplespace.rb b/sample/drb/old_tuplespace.rb
index 2d5310086e..8be1542c06 100644
--- a/sample/drb/old_tuplespace.rb
+++ b/sample/drb/old_tuplespace.rb
@@ -31,7 +31,7 @@ class TupleSpace
def initialize
@que = {}
@waiting = {}
- @que.taint # enable tainted communication
+ @que.taint # enable tainted comunication
@waiting.taint
self.taint
end
diff --git a/sample/fact.rb b/sample/fact.rb
index 9f6ca72ca7..d8147a40f1 100644
--- a/sample/fact.rb
+++ b/sample/fact.rb
@@ -4,6 +4,6 @@ def fact(n)
n.downto(1) do |i|
f *= i
end
- f
+ return f
end
-puts fact(ARGV[0].to_i)
+print fact(ARGV[0].to_i), "\n"
diff --git a/sample/fib.py b/sample/fib.py
index 90dc1e09ed..8318021d24 100644
--- a/sample/fib.py
+++ b/sample/fib.py
@@ -6,5 +6,5 @@ def fib(n):
else:
return fib(n-2)+fib(n-1)
-print(fib(20))
+print fib(20)
diff --git a/sample/freq.rb b/sample/freq.rb
new file mode 100644
index 0000000000..1b2194c69a
--- /dev/null
+++ b/sample/freq.rb
@@ -0,0 +1,12 @@
+# word occurrence listing
+# usage: ruby freq.rb file..
+freq = Hash.new(0)
+while line = gets()
+ line.scan(/\w+/) do |word|
+ freq[word] += 1
+ end
+end
+
+for word in freq.keys.sort!
+ print word, " -- ", freq[word], "\n"
+end
diff --git a/sample/iseq_loader.rb b/sample/iseq_loader.rb
index 8c271405d6..bb2d92ea77 100644
--- a/sample/iseq_loader.rb
+++ b/sample/iseq_loader.rb
@@ -41,7 +41,7 @@ class RubyVM::InstructionSequence
at_exit{
STDERR.puts "[ISEQ_LOADER] #{Process.pid} time: #{Time.now - LAUNCHED_TIME}, " +
"loaded: #{$ISEQ_LOADER_LOADED}, " +
- "compiled: #{$ISEQ_LOADER_COMPILED}, " +
+ "compied: #{$ISEQ_LOADER_COMPILED}, " +
"ignored: #{$ISEQ_LOADER_IGNORED}"
} if COMPILE_VERBOSE
@@ -141,11 +141,11 @@ class RubyVM::InstructionSequence
end
def read_compiled_iseq fname, iseq_key
- File.open(iseq_key, 'rb'){|f| f.read}
+ open(iseq_key, 'rb'){|f| f.read}
end
def write_compiled_iseq fname, iseq_key, binary
- File.open(iseq_key, 'wb'){|f| f.write(binary)}
+ open(iseq_key, 'wb'){|f| f.write(binary)}
end
end
diff --git a/sample/list3.rb b/sample/list3.rb
index 110e405cf9..1d9f04b710 100644
--- a/sample/list3.rb
+++ b/sample/list3.rb
@@ -7,7 +7,7 @@ class Point
self
end
- def inspect
+ def to_s
sprintf("%d@%d", @x, @y)
end
end
diff --git a/sample/observ.rb b/sample/observ.rb
index ef4a9f60f5..a7ea45271d 100644
--- a/sample/observ.rb
+++ b/sample/observ.rb
@@ -27,5 +27,5 @@ class Clock
end
end
-Clock.new(Tick.new)
+clock = Clock.new(Tick.new)
sleep
diff --git a/sample/occur.rb b/sample/occur.rb
index 5927ebc889..42151d85e8 100644
--- a/sample/occur.rb
+++ b/sample/occur.rb
@@ -2,7 +2,7 @@
# usage: ruby occur.rb file..
freq = Hash.new(0)
while line = gets()
- line.scan(/\w+/) do |word|
+ for word in line.split(/\W+/)
freq[word] += 1
end
end
diff --git a/sample/occur2.rb b/sample/occur2.rb
new file mode 100644
index 0000000000..ef8ad2c541
--- /dev/null
+++ b/sample/occur2.rb
@@ -0,0 +1,13 @@
+# word occurrence listing
+# usage: ruby occur2.rb file..
+freq = {}
+ARGF.each_line do |line|
+ for word in line.split(/\W+/)
+ freq[word] ||= 0
+ freq[word] += 1
+ end
+end
+
+for word in freq.keys.sort
+ printf("%s -- %d\n", word, freq[word])
+end
diff --git a/sample/ripper/ruby2html.rb b/sample/ripper/ruby2html.rb
index 1e6b3bf550..8f64f5a713 100644
--- a/sample/ripper/ruby2html.rb
+++ b/sample/ripper/ruby2html.rb
@@ -73,11 +73,7 @@ class ERB
end
def ruby2html(f, encoding, css, print_line_number)
- if RUBY_VERSION >= '2.6'
- erb = ERB.new(TEMPLATE, trim_mode: '>')
- else
- erb = ERB.new(TEMPLATE, nil, '>')
- end
+ erb = ERB.new(TEMPLATE, nil, '>')
erb.filename = __FILE__
erb.lineno = TEMPLATE_LINE
erb.result(binding())
diff --git a/sample/test.rb b/sample/test.rb
index 65dd9abd10..65dd9abd10 100644..100755
--- a/sample/test.rb
+++ b/sample/test.rb
diff --git a/sample/timeout.rb b/sample/timeout.rb
index ad4459aff0..8d25d72a76 100644
--- a/sample/timeout.rb
+++ b/sample/timeout.rb
@@ -1,31 +1,31 @@
require 'timeout'
def progress(n = 5)
- n.times {|i| print i; STDOUT.flush; sleep 1}
+ n.times {|i| print i; STDOUT.flush; sleep 1; i+= 1}
puts "never reach"
end
-p Timeout.timeout(5) {
+p timeout(5) {
45
}
-p Timeout.timeout(5, Timeout::Error) {
+p timeout(5, Timeout::Error) {
45
}
-p Timeout.timeout(nil) {
+p timeout(nil) {
54
}
-p Timeout.timeout(0) {
+p timeout(0) {
54
}
begin
- Timeout.timeout(5) {progress}
+ timeout(5) {progress}
rescue => e
puts e.message
end
begin
- Timeout.timeout(3) {
+ timeout(3) {
begin
- Timeout.timeout(5) {progress}
+ timeout(5) {progress}
rescue => e
puts "never reach"
end
@@ -36,7 +36,7 @@ end
class MyTimeout < StandardError
end
begin
- Timeout.timeout(2, MyTimeout) {progress}
+ timeout(2, MyTimeout) {progress}
rescue MyTimeout => e
puts e.message
end
diff --git a/sample/trick2013/kinaba/remarks.markdown b/sample/trick2013/kinaba/remarks.markdown
index dcdce7e9ae..a454a5f0a1 100644
--- a/sample/trick2013/kinaba/remarks.markdown
+++ b/sample/trick2013/kinaba/remarks.markdown
@@ -16,11 +16,11 @@ The program contains each ASCII character from 0x20 ' ' to 0x7e '~' exactly once
### Internals
-The algorithm is the obvious loop "32.upto(126){|x| putc x}".
+The algorthim is the obvious loop "32.upto(126){|x| putc x}".
It is not so hard to transform it to use each character *at most once*. The only slight difficulty comes from the constraint that we cannot "declare and then use" variables, because then the code will contain the variable name twice. This restriction is worked around by the $. global variable, the best friend of Ruby golfers.
-The relatively interesting part is to use all the characters *at least once*. Of course, this is easily accomplished by putting everything into a comment (i.e., #unused...) or to a string literal (%(unused...), note that normal string literals are forbidden since they use quotation marks twice). Hey, but that's not fun at all! I tried to minimize the escapeway.
+The relatively interesting part is to use all the charcters *at least once*. Of course, this is easily accomplished by putting everything into a comment (i.e., #unused...) or to a string literal (%(unused...), note that normal string literals are forbidden since they use quotation marks twice). Hey, but that's not fun at all! I tried to minimize the escapeway.
* "@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz". Trash box of unused alphabet. I wish I could have used "gkyz" somewhere else.
diff --git a/sample/trick2013/mame/music-box.mp4 b/sample/trick2013/mame/music-box.mp4
new file mode 100644
index 0000000000..6d1e87c01c
--- /dev/null
+++ b/sample/trick2013/mame/music-box.mp4
Binary files differ
diff --git a/sample/trick2013/yhara/entry.rb b/sample/trick2013/yhara/entry.rb
index 3666f271fa..ce125ed3df 100644
--- a/sample/trick2013/yhara/entry.rb
+++ b/sample/trick2013/yhara/entry.rb
@@ -2,7 +2,7 @@ def _(&b)$><<->(x){x ? (String===x ?x.upcase:
(Class===x ? x : x.class).name[$a?0:($a=5)]):
" "}[ begin b[];rescue Exception;$!;end ] end
-_ { 1.tap }
+_ { yield }
_ { method(:p).unbind }
_ { eval "{ " }
_ { Thread.current.join }
diff --git a/sample/trick2015/ksk_1/remarks.markdown b/sample/trick2015/ksk_1/remarks.markdown
index a0b8bbcdcc..b822dc55c8 100644
--- a/sample/trick2015/ksk_1/remarks.markdown
+++ b/sample/trick2015/ksk_1/remarks.markdown
@@ -110,7 +110,7 @@ is simply `/=/` and removing a padding `",,,,,"`. The program no
longer terminates, though.
-### Limitation
+### Limination
The implementation requires to manipulate long strings even for some
small starting numbers. For example, starting from 1,819, the number
diff --git a/sample/trick2015/ksk_2/remarks.markdown b/sample/trick2015/ksk_2/remarks.markdown
index 187a6804d2..bb9b705773 100644
--- a/sample/trick2015/ksk_2/remarks.markdown
+++ b/sample/trick2015/ksk_2/remarks.markdown
@@ -199,6 +199,6 @@ succeed to return 0. The meaning of ``\1nn`` in regular expression
seems to depend on the existence of capturing expressions.
In spite of these Ruby's behaviors, we have a good news! The present
-SAT solver does not suffer from the issues because the program cannot
+SAT sover does not suffer from the issues because the program cannot
return solutions in practical time for inputs with variables more than
-40.
+40. \ No newline at end of file
diff --git a/sample/trick2018/01-kinaba/authors.markdown b/sample/trick2018/01-kinaba/authors.markdown
deleted file mode 100644
index d0df0b379d..0000000000
--- a/sample/trick2018/01-kinaba/authors.markdown
+++ /dev/null
@@ -1,3 +0,0 @@
-* kinaba
- * twitter.com/kinaba
- * cctld: jp
diff --git a/sample/trick2018/01-kinaba/entry.rb b/sample/trick2018/01-kinaba/entry.rb
deleted file mode 100644
index eb8284d5ab..0000000000
--- a/sample/trick2018/01-kinaba/entry.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-alias BEGIN for unless def class
-super true or return defined? next
-break while begin undef do end
-rescue then retry else undef module
-nil ensure case if yield __LINE__
-self and redo elsif not __FILE__
-alias END in end when __ENCODING__
-end until false end
diff --git a/sample/trick2018/01-kinaba/remarks.markdown b/sample/trick2018/01-kinaba/remarks.markdown
deleted file mode 100644
index a1a05bfd73..0000000000
--- a/sample/trick2018/01-kinaba/remarks.markdown
+++ /dev/null
@@ -1,55 +0,0 @@
-### Remarks
-
-Just run it with no argument:
-
- ruby entry.rb
-
-(Anyway it is just a no-op program. The above command only verifies
-that entry.rb is a valid Ruby program.)
-
-I confirmed the following implementations/platforms:
-
-* ruby 2.5.0p0 (2017-12-25 revision 61468) [x64-mingw32]
-
-### Description
-
-First, look at
-
-https://docs.ruby-lang.org/ja/latest/doc/spec=2flexical.html#reserved
-
-and then, look at entry.rb.
-
-The source code of entry.rb consists only of reserved words of Ruby,
-and all the reserved words are used in the code, in a way that the code
-forms a valid Ruby program. No compile error, no warning, or no runtime error.
-
-
-### Internals
-
-Difficult (and interesting) points of the theme are:
-
-* Since many of the reserved words define program structures, we cannot
- use them independently. For instance, `retry` must be inside `rescue`,
- or `break`/`next`/`redo` must be inside a looping construct.
- Or, jump-out statements cannot occur at a position that requires a
- value; `if return then true end` is a "void value expression" syntax error.
-* Inserting newlines for each 6 word (to match with the spec html) is also
- an interseting challenge, since Ruby is sensitive to newlines.
-
-Tricks used in the code are:
-
-* def/alias/undef can take even reserved words as parameters.
- That is, `def class ... end` defines a method named `class`.
- The feature is crucial since otherwise `BEGIN` etc inevitably
- introduces non-reserved tokens (like `{}`).
-* `defined?` can take some reserved words too (which I didn't know
- until trying to write this program.)
-* "void value expression" can be avoided by using `or` or `and`.
- `if begin return end then true end` is a syntax error, but
- `if begin false or return end then true end` is not.
-
-
-### Limitation
-
-Sad to say that it's not a "perfect pangram".
-It uses 'alias' and 'undef' twice, and 'end' 4 times.
diff --git a/sample/trick2018/02-mame/authors.markdown b/sample/trick2018/02-mame/authors.markdown
deleted file mode 100644
index 0e420fdf5d..0000000000
--- a/sample/trick2018/02-mame/authors.markdown
+++ /dev/null
@@ -1,3 +0,0 @@
-* Yusuke Endoh
- * mame@ruby-lang.org
- * cctld: jp
diff --git a/sample/trick2018/02-mame/entry.rb b/sample/trick2018/02-mame/entry.rb
deleted file mode 100644
index cc4ef9cbc4..0000000000
--- a/sample/trick2018/02-mame/entry.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-'';eval(r=%q(->z{r="'';eval(r=\
-%q(#{r}))[%q`#{z}`]";i=-040;30.
-times{|n|(15+n%2*15-n/2).times{
-r<<r[i+=(1.-n&2)*(32-n%2*31)]}}
-i=r[524,0]=?\0;eval(r[479..-1])
-c['"']}))[%q`GFEDCBA"+"[e\"'"'t
-kE*;;\";" TRICK2018 ";tb,;{{r
-2E0$ob[us@*0)[90,336])_#i\n}s#i
-0H}>["t]];};o[1,?\n*8];ex"-}eac
-1Hl<1[-1]*2*t=n%2];o[14-n,0)mvk
-8M$<4,?\n];15.times{|n|;o[35ie2
-!Pss.slice!(0,1)+x;sleep(0.0t;0
-'W=%q"<<95<<$s<<95;o=->n,x{n.'1
-;@[2]}|\e../,%@s="'%trick2018!8
-eval$s=%q_eval($s.gsub!(/#{%@`]
diff --git a/sample/trick2018/02-mame/remarks.markdown b/sample/trick2018/02-mame/remarks.markdown
deleted file mode 100644
index 88b32c205a..0000000000
--- a/sample/trick2018/02-mame/remarks.markdown
+++ /dev/null
@@ -1,16 +0,0 @@
-This program quines with animation.
-
-```
-$ ruby entry.rb
-```
-
-Of course, the output is executable.
-
-```
-$ ruby entry.rb > output
-$ ruby output
-```
-
-Note, we don't cheat. This program uses escape sequences just for moving the cursor. It doesn't use attribution change nor overwrite to hide any code.
-
-The program is crafted so that it works in two ways; it works as a normal program text, and, it also works when it is rearranged in a spiral order. Some parts of the code are actually overlapped.
diff --git a/sample/trick2018/03-tompng/Gemfile b/sample/trick2018/03-tompng/Gemfile
deleted file mode 100644
index a24ff779dc..0000000000
--- a/sample/trick2018/03-tompng/Gemfile
+++ /dev/null
@@ -1,2 +0,0 @@
-source 'https://rubygems.org'
-gem 'chunky_png'
diff --git a/sample/trick2018/03-tompng/Gemfile.lock b/sample/trick2018/03-tompng/Gemfile.lock
deleted file mode 100644
index 467f5c3495..0000000000
--- a/sample/trick2018/03-tompng/Gemfile.lock
+++ /dev/null
@@ -1,13 +0,0 @@
-GEM
- remote: https://rubygems.org/
- specs:
- chunky_png (1.3.8)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- chunky_png
-
-BUNDLED WITH
- 1.16.1
diff --git a/sample/trick2018/03-tompng/authors.markdown b/sample/trick2018/03-tompng/authors.markdown
deleted file mode 100644
index 26ebe24da6..0000000000
--- a/sample/trick2018/03-tompng/authors.markdown
+++ /dev/null
@@ -1,3 +0,0 @@
-* Tomoya Ishida (tompng)
- * tomoyapenguin@gmail.com
- * cctld: jp
diff --git a/sample/trick2018/03-tompng/entry.rb b/sample/trick2018/03-tompng/entry.rb
deleted file mode 100644
index 26416c7019..0000000000
--- a/sample/trick2018/03-tompng/entry.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-X=[];class String def-@;replace ?-+self end;def-a;X.reject!{|x|x.
-__id__==__id__};a.replace(self+?-+a) end end;at_exit{eval C=(Zlib
-.inflate((X*?-).tr(?-,'').tr('q-z','0-9').to_i(26).digits(0x100).
-pack'C*'))};def method_missing n;(X<<n.to_s)[-1]end;require'zlib'
-fzygtoxyzgntmdmuwvfoffbpmvzojpkhczvjvjdbtscnldwbdoprackddovivvmkz
-ponzmosvtjciwkgaslscxxxwudeesmmqpfhislxuxnnypulxstzgobyaekqqhbjcg
-mvko------------ddkeys----eivhnccaqyiw---bzyccmt-----------ymtnge
-jwhi--------------pjxf------mdarbtumnv---qasda--------------gmwdt
-wrtk---qtpzgnce----fsl-------fkgzgtbpp---gwnm----pxkpqkdiw---owga
-momz---yjjvpnvar---zeo---v-----duvalwu---nsqt---waofemwakivnyqkjd
-fzag---uhvusmkl----kzb---rhc----iutzjr---mqlh---ayijpwativpweaato
-xexs--------------rvgv---pjdz-----lkkg---uiaw---lovitupw-----fwmn
-kfru------------jvjpgv---jskycf----pal---gbuf---hfdnywog-----iuca
-pntn---apmkqroeuzwuwkw---gqnmgof-----b---hlpl---vkkyhfyrqfr--jwrl
-kmdb---dhspujhmtgrkccu---uonfummdt-------rqfw----bpiactehwp--fncq
-yzvz---gdaxebplhfndran---ytfmviryeh------hqwkl---------------nced
-bibu---fnkdthgldhkxxjg---rwnmpudhbqin----gucoyki------------hfura
-cqdgqpyzqfzknvdjoxxhpjulwwyebtocxdrvklbuviwwcatlmdosxfvwntzbijguy
-iglrvvzlxerflupxvsyujfacuwhrvmnecgtewtqkhtdggcltejiyqcluclkycwvzg
-vvxfysvttfbeglvrlngntdngzyhqrmltazwdydxrsvjploembhgxdvfmmhepbschm
-brn--iqrcdb--evv----tqp------lg--uein-wzut--mr------wkh------foqz
-zsf--srjnjp--ampb--pfio--hgtekx--rrr---fwd--jn--xqkezcz--vsb--nya
-khrc--evlr--oioxs--mqce--bqfmag--bwz---xda--qw--jnuzelr--qzi--itx
-mdxd--duso--wxbot--nmon--ugnbdpc--a--c--e--hlg--twxndre--tby--rhg
-evhbn--zb--dtxmiz--dpia------vie--h--i--t--shh------kfn------owna
-ealmt--kb--scxdjy--smvl--dqmgebk--t--s--t--gfd--updcbnc--rh--dwwp
-dvpnxb----wpljjdy--kolc--qflyleok---xkv---usbj--jhrawbn--ewx--bgf
-eaqwrw----ejwxhet--dice--eoczconm---urz---rqyp--hovvvfc--bskj--el
-aocjcts--jtumwxm----mgy------xpaoq-jtwqr-aipay------dhy--iync--hk
-sckddmvuvvuhhqstumaykvczaaujrumqbbqsdvdycplyrlkkojlxnkrhbbrmnjxyf
-cdtcmpfmjvthwkpzucbblttgumomlxnxwjeypfeagaukfzeokzxjebkpigcvlqnso
diff --git a/sample/trick2018/03-tompng/output.txt b/sample/trick2018/03-tompng/output.txt
deleted file mode 100644
index ed9a4079cc..0000000000
--- a/sample/trick2018/03-tompng/output.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-undef p;X=[];class String def-@;replace ?-+dup end;def-a;X.reject!{|x|x.__id__==__id__};a.replace(self+?-+a) end end;at_exit{eval C=
-(Zlib.inflate (X*?-).tr(?-,'').tr('q-z','0-9').to_i(26).digits(256).pack'C*')};def method_missing n;(X<<n.to_s)[-1]end;require'zlib'
-gmlztzdculbtzgtjfetuh---k--htf----d-----------------------------------------------------g-b-----s--t-g--------jmuwescmgchftikfjafccs
-ivchcveidpvxdabnvwyga-f--v-------xf----------------------------------------------------q-v---l-------q---------liiNeawriayymwooxgxqw
-rfosepqsmojseyezmwbhi--------------ew--------------------------------------------------m---k-r-----------vwu--hiotltdmczwyjmlvbyfqwq
-uvvykqdjednoqgtcmtfbzs---------f----o--------------------------------------------------t--a------m----x---f-----dldzsakyofetfozfpmrq
-geusutariiiNiulkjbwlm-----d------------------------------------------------------------j---------o---------x--j-uitzrgwpupwhvendhyno
-uubvnssiywkklwwdufhhi-rw----k---v-------------------------------------------------------sty-----yg---l---c-v----wkffpskpumolqmkeryzg
-zrxdaiposwybbzgxdnegh-----g-----ma--n---------------------------------------------------------j----n--b-n-------yqavmscswdogpcgopygt
-axiqfswlhzeamvymdnteo---q-q-w--------------------------fhrmj-----------------hkou-----------f-----d----u-o------evcuxxegekfgivzzujan
-nslioftsvqvtkeigvfgwr-------------lyco-----------------igyvg-----------------okuk---------m--b-u--d--y------s---dadjrlykfhtermzfyktu
-btoxzfpPicxxfligbivvf--------h----yrat---------------------------------------vjwd---------------------d-ki--o--tyqosehopkwttigwwfskp
-komzvnyrvkjcjwbmdwdkp----------vxphiNdtawn--xms-saketo--jnld----ezulntdaz----nzna-----vhjwt------h----x--x--o--saxxsrkgktqotaluylbkk
-sclegratyaarmgmepheml----------hwgglhlrfcx--znvmpfsgjx-onhju---gtxsmzqprlt---mjzy---frhdk-------------v---mj----dzjujmbgldfwoybgicwu
-tfhgnhlzxlwtdtkgzlaca-------------gmex------arlm--------rvmh-ajtgf-----pqal--wcux-zatyi-------------------------xnluwybcugjclmablshn
-tnjohqtqzivgmyutrssil-------------lcwq------jrf--------gcaii-maie------------vvnfjfqwo--------------------------filivosyhkxcvuwdibwj
-tyxjiopiFqypvwdzoatuq-------------tdln------cnx---------ffuf-ajvq------------tyyypglpzmj------------------------vtqzwewqdsijrbymvpwn
-niNffphoehukpvvmzvhyd-------------ahqd------nfr---------jeqk--toap-----mxhyg-tedv---otrwy-----------------------mjxnrktackwxwiajdnuc
-kkxhuwbvibpvgvcampadi-------------ebmencqz--obf--------wfprz---qmrotkijiqv---ggfp-----hlzw----------------------kastwdpxiyftmypuxbtu
-xetudmwzpomktgnjkcsyc---------------fwpdx---xb----j-----se-k------tllakc-----gjoo-------we------mic---lktk------ubtnrxvrjzuqlrfrsnmf
-okdvfvcdbdqkckjialskk---------------------------v---u-------l----------------------------------z--q--qfg--------aaliNbxbjjpxebboneye
-kcbkjmdclwnfawtfnwkeq----------------------------------j---y-------------------------------a---jmbyo-sgef--gf---extljbozuoofgyvsilct
-xzoqmsqgzjxxpjqwkjkdd------------------------o--------m-------f---------------------------------n--de-ajz-rzv---fhnpbkrwdxoozpxeaxaf
-mbcwxuiqdwcmadheiykaa-----------------------q-f------l---i---------------------------------r----zf---k--y---fi--dcnycheytylcgnioauee
-yekiNacriqoevtdjerqbp----------------------------w---yy-----my----------------------------ko--mnbpskr--c-----j--ozyqpbfovhbhyoprzgqr
-czwtuopxkdbphocfawvbk--------------------------q-s----j--b---------------------------------hd-xsb----bfiNp--w---fmwuvfambdqvxtzldwmh
-xysnyrseydlkjcwfbsjnr-------------------------d-d-------------------------------------------f-enpss---qllpwr----almsdidvjwoigvldfqoa
-lrpbixjpofxocxlflscpo------------------------------q-fyu--z-------------------------------------kfd-z---n-------bqxurujnxzurrdgcojks
-jetyfdkcekckxbyosbfws-------------wdfhgwuvejjmf-----sxjubpvgcsl-------tnmixpv---------eurabjsdvstfv-------------qcyiqhonwoyixqeonfvp
-mopPhywsozohitutgmmrb------------zxwtxe--riedeo---mspgpnv--pimlh------jhtzajk--------qqovvq---ldbrh-------------xtooxpayonpcvvtmvpra
-vvuyiunpoeagdzqjecsub------------klrw------snrc---rrct------aajom--------nsyk--------peea-------azq-------------iNjefdkfhnagjicqwmsm
-mbwwbfgehhbdmvvlflmee---------------------hkejn---jtbo-------jdtje-------jcei---------afyz-----smtc-------------kksvfjyuaqtohxiohhlz
-dvfmfrzcmnsfruhqgjuxz------------------dfxdnlk----kkra-------xmmtf-------jwkw----------rdoozxtcho---------------bbwwferxwnnmdzcniicv
-mfneisdlyeqwynldjgonj----------------jgrjvc-------uxga-------ghnpr-------sers--------scbknx----gmjo-------------moedtnlbflhtlkjibrqk
-gobwqshnpbdcpjmjaeczr--------------iscsxs---------zfpo-------hhfwy-------qbba-------vhlxc-------ntod------------ndwzdomaptumzejiwqbn
-snucynymvfpnadyqkzfcv-------------ggze------------kuvfs-----zuhod--------mylo-------jhwyp-----z-pywd------------dqfmpnevmtqcikbrilto
-aotyxkipebdkassogpcbl-----------wgackesmvvsrihhd---orzndjndlzpb----------eobf-------kkayixzyotqfafa-w-----------mjjxoomwdglwvccozzut
-rthesuszfwycsqqrtxlot-----------ejcqlhriilqbtrys------lwbkzmvp-----------zzwm-------l--qijwfllndzb-ik-----------mmokqomjepdcotnsiNig
-nloryyoswwdmefywnnuhph------------------------------------------------------r--r-nd-----h--x--------------------hlgzeqqslwxgtjgghquf
-nssngjtiudsrvfuxjzclhjhj----------------------------------------------------------t----------------k-f-mp-------obhyehqebtpjbkeepqzt
-ezogzsimfynqmkteaipejo-g-yser-----------------------------------------------e------h-------------i---y----------qpgcqnltivmmsximbbsy
-wtjjolwyoselcumgklqwpldkl-ulm-m---------------------------------------------------------------q---u-f--l--------buixfiitufktsqdtnrei
-tgrtitcewseetlpeuuujb-osdokjozc------------------------------------------n---d-----f--------g--------q--g-------jyyqtezuzmcxgpcwuwfx
-dpPayqmzxrwhbswwalygfurtkruw-u-k---------------------------------------------d---h------i----------c----i-------ulowcddvjbxthqlxjzbe
diff --git a/sample/trick2018/03-tompng/remarks.markdown b/sample/trick2018/03-tompng/remarks.markdown
deleted file mode 100644
index fe9eec5989..0000000000
--- a/sample/trick2018/03-tompng/remarks.markdown
+++ /dev/null
@@ -1,19 +0,0 @@
-### Remarks
-
-Bundle install
- this program depends on `gem chunky_png`
-
-Run it with the following command:
- bundle exec ruby entry.rb trick.png
- bundle exec ruby entry.rb [other png file]
-
-I confirmed the following implementations/platforms:
-
-* ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
-* ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
-
-### Description
-
-This program is a png image viewer.
-The output is an asciiart of the given png file,
-and it is also a source code of the png viewer itself.
diff --git a/sample/trick2018/03-tompng/trick.png b/sample/trick2018/03-tompng/trick.png
deleted file mode 100644
index d4bb0bd7c3..0000000000
--- a/sample/trick2018/03-tompng/trick.png
+++ /dev/null
Binary files differ
diff --git a/sample/trick2018/04-colin/authors.markdown b/sample/trick2018/04-colin/authors.markdown
deleted file mode 100644
index a846d12535..0000000000
--- a/sample/trick2018/04-colin/authors.markdown
+++ /dev/null
@@ -1,3 +0,0 @@
-* Colin Fulton
- * justcolin@gmail.com
- * cctld: us
diff --git a/sample/trick2018/04-colin/entry.rb b/sample/trick2018/04-colin/entry.rb
deleted file mode 100644
index 442a8ea3a8..0000000000
--- a/sample/trick2018/04-colin/entry.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# Copyright 2018. Available for use under the terms of the MIT License.
-$🚀=0;def 🤔 ðŸ·,🤔=0,&b;puts ' '*$🚀+(🤔 ?"":"🚫 ")+ðŸ·;$🚀+=4;b&.[];$🚀-=4;end
diff --git a/sample/trick2018/04-colin/remarks.markdown b/sample/trick2018/04-colin/remarks.markdown
deleted file mode 100644
index 5f4f1a8dfe..0000000000
--- a/sample/trick2018/04-colin/remarks.markdown
+++ /dev/null
@@ -1,62 +0,0 @@
-### Remarks
-
-Create a Ruby file that requires entry.rb with a series of test in it the run the file using ruby:
-
-```
-ruby name_of_test_file.rb
-```
-
-To create a test, call 🤔 with two arguments. The first is a string describing what this tests, the second argument is the test assertion. If the assertion is truthy, the test passes. If the assertion is falsy, the test fails.
-
-```
-string_1 = "Hello world!"
-string_2 = "This is not the same!"
-
-🤔 "The two strings are equal",
- string_1 == string_2
-```
-
-To create a group of tests under a label, call 🤔 with a string describing the group and a block containing the tests in that group.
-
-```
-🤔 "This is a group of tests" do
- # Add other groups and/or tests here.
-end
-```
-
-Here is an example:
-
-```
-require './entry'
-
-🤔 "Math" do
- 🤔 "Addition" do
- 🤔 "One plus one equals two.",
- 1+1 == 2
- 🤔 "One plus one equals eleven. (This should fail.)",
- 1+1 == 11
- end
-
- 🤔 "Subtraction" do
- 🤔 "One minus one equals zero.",
- 1-1 == 0
- 🤔 "Ten minus one equal nine.",
- 10-1 == 9
- end
-end
-```
-
-It has been tested with the following Ruby versions:
-
-* ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
-* ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
-* If you replace `b&.[]` with `b&&b[]` it will work with ruby 2.0.0 as well, but it will be one character longer.
-
-
-### Description
-
-The goal was to create a testing library where the test files looked good and the output looked good in as few characters as possible. The result is 68 characters and has one method to handle everything.
-
-### Limitation
-
-Your terminal program must support Unicode characters for the test output to look correct. If your terminal does not support Unicode, simply replace the 🚫 in the code with whatever character you want to prefix failing tests.
diff --git a/sample/trick2018/05-tompng/authors.markdown b/sample/trick2018/05-tompng/authors.markdown
deleted file mode 100644
index 26ebe24da6..0000000000
--- a/sample/trick2018/05-tompng/authors.markdown
+++ /dev/null
@@ -1,3 +0,0 @@
-* Tomoya Ishida (tompng)
- * tomoyapenguin@gmail.com
- * cctld: jp
diff --git a/sample/trick2018/05-tompng/entry.rb b/sample/trick2018/05-tompng/entry.rb
deleted file mode 100644
index 31522b6de2..0000000000
--- a/sample/trick2018/05-tompng/entry.rb
+++ /dev/null
@@ -1,41 +0,0 @@
- X=[];def self.method_missing n;n.to_s.chars;end
- l=[];def l.-a;X<<a=[nil,*a];a;end;def l.+a;self-a;end
- class Array;def-@;[]-self;end;def-a;replace [*self,nil,*a
- ]end;alias +@ -@;alias + -;end;def gen3d f;yield;b=['solid obj'];w,
- h=X[0].size,X.size;X<<[];a=->r,z,dr,dz{;r-=w/2.0;z*=2;r2,z2=r+dr,z+dz*2;if r>0||r2>
- 0;r=[0,r].max;r2=[0,r2].max;16.times{|i|m=Math;p=m::PI/8;;c,s=m.cos(t=i*p),m.sin(t)
- c2,s2=m.cos(t=(i+1)*p),m.sin(t);t-=p/2;[[0,1,2],[0,2,3]].map{|a|b.push [:facet,'n'+
- + 'ormal',dz*m.cos(t),dz*m.sin(t),-dr]*' ','outer loop',a.map{|i|'v'+
- ++ "ertex #{[[r*c,r*s,z],[r*c2,r*s2,z],[r2*c2,r2*s2,z2],[r2*
- +c, r2*s,z2]][i]*' '}"},:endloop,:endfacet}}end};(0...h).
- map{| y|w.times{|x|[X[y-1][x]||a[x,y,1,0],X[y+1][x]||
- a[x+1,y+
- 1,-1,0],X[
- y][x-+1]||a[
- x,y+1,0,-1],X[y
- ][x++1]||a[x+1,y,
- 0,1]]if X[y][x]}}
- s=[b,'end'+b[0]]*
- $/;File.write(f,
- s);X.replace(
- []);end
-
-gen3d 'wine_glass.stl' do
- l--ww------------------ww--l
- l--ww------------------ww--l
- l--ww++++++++++++++++++ww--l
- l--ww++++++++++++++++++ww--l
- l--ww++++++++++++++++++ww--l
- l--ww++++++++++++++++++ww--l
- l---ww++++++++++++++++ww---l
- l----www++++++++++++www----l
- l------www++++++++www------l
- l--------wwwwwwwwww--------l
- l-----------wwww-----------l
- l------------ww------------l
- l------------ww------------l
- l------------ww------------l
- l-----------wwww-----------l
- l---------wwwwwwww---------l
- l----wwwwwwwwwwwwwwwwww----l
-end
diff --git a/sample/trick2018/05-tompng/preview_of_output.png b/sample/trick2018/05-tompng/preview_of_output.png
deleted file mode 100644
index db511ee2f3..0000000000
--- a/sample/trick2018/05-tompng/preview_of_output.png
+++ /dev/null
Binary files differ
diff --git a/sample/trick2018/05-tompng/remarks.markdown b/sample/trick2018/05-tompng/remarks.markdown
deleted file mode 100644
index b4e5708a43..0000000000
--- a/sample/trick2018/05-tompng/remarks.markdown
+++ /dev/null
@@ -1,31 +0,0 @@
-### Remarks
-
-Just run it with no argument:
-
- ruby entry.rb
-
-I confirmed the following implementations/platforms:
-
-* ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
-* ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
-* ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
-
-### Description
-
-This program will generate `wine_glass.stl`, a 3D data file(STL format) of a wine glass.
-You can change the shape by modifying the DSL part.
-For sake cup:
-```ruby
-gen3d 'ochoko.stl' do
- l------------------------l
- l-ww------------------ww-l
- l-ww------------------ww-l
- l-ww++++++++++++++++++ww-l
- l-ww++++++++++++++++++ww-l
- l--ww++++++++++++++++ww--l
- l---wwww++++++++++wwww---l
- l----wwwwwwwwwwwwwwww----l
- l----www----------www----l
-end
-```
-`+` and `-` are the same meaning(just for appearance)
diff --git a/sample/trick2018/README.md b/sample/trick2018/README.md
deleted file mode 100644
index 345500b00a..0000000000
--- a/sample/trick2018/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-This directory contains the award-winning entries of
-the 3rd Transcendental Ruby Imbroglio Contest for rubyKaigi (TRICK 2018).
-
-THESE ARE BAD EXAMPLES! You must NOT use them as a sample code.
-
-* 01-kinaba/entry.rb: "Most reserved" - **Gold award**
-* 02-mame/entry.rb: "Best spiral" - **Silver award**
-* 03-tompng/entry.rb: "Best png viewer" - **Bronze award**
-* 04-colin/entry.rb: "Best one-liner" - 4th prize
-* 05-tompng/entry.rb: "Most three-dimensional" - 5th prize
-
-These files are licensed under MIT license.
-
-For the contest outline and other winning entries, see:
-
-https://github.com/tric/trick2018
diff --git a/signal.c b/signal.c
index 68d68c54bf..e5468efb53 100644
--- a/signal.c
+++ b/signal.c
@@ -41,6 +41,9 @@
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#endif
+extern ID ruby_static_id_signo;
+#define id_signo ruby_static_id_signo
+
#ifdef NEED_RUBY_ATOMIC_OPS
rb_atomic_t
ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val)
@@ -62,11 +65,12 @@ ruby_atomic_compare_and_swap(rb_atomic_t *ptr, rb_atomic_t cmp,
}
#endif
-#define FOREACH_SIGNAL(sig, offset) \
- for (sig = siglist + (offset); sig < siglist + numberof(siglist); ++sig)
-enum { LONGEST_SIGNAME = 7 }; /* MIGRATE and RETRACT */
+#ifndef NSIG
+# define NSIG (_SIGMAX + 1) /* For QNX */
+#endif
+
static const struct signals {
- char signm[LONGEST_SIGNAME + 1];
+ const char *signm;
int signo;
} siglist [] = {
{"EXIT", 0},
@@ -128,9 +132,15 @@ static const struct signals {
#ifdef SIGCONT
{"CONT", SIGCONT},
#endif
-#if RUBY_SIGCHLD
- {"CHLD", RUBY_SIGCHLD },
- {"CLD", RUBY_SIGCHLD },
+#ifdef SIGCHLD
+ {"CHLD", SIGCHLD},
+#endif
+#ifdef SIGCLD
+ {"CLD", SIGCLD},
+#else
+# ifdef SIGCHLD
+ {"CLD", SIGCHLD},
+# endif
#endif
#ifdef SIGTTIN
{"TTIN", SIGTTIN},
@@ -195,81 +205,20 @@ static const struct signals {
#ifdef SIGINFO
{"INFO", SIGINFO},
#endif
+ {NULL, 0}
};
-static const char signame_prefix[] = "SIG";
-static const int signame_prefix_len = 3;
+static const char signame_prefix[3] = "SIG";
static int
-signm2signo(VALUE *sig_ptr, int negative, int exit, int *prefix_ptr)
+signm2signo(const char *nm)
{
const struct signals *sigs;
- VALUE vsig = *sig_ptr;
- const char *nm;
- long len, nmlen;
- int prefix = 0;
-
- if (RB_SYMBOL_P(vsig)) {
- *sig_ptr = vsig = rb_sym2str(vsig);
- }
- else if (!RB_TYPE_P(vsig, T_STRING)) {
- VALUE str = rb_check_string_type(vsig);
- if (NIL_P(str)) {
- rb_raise(rb_eArgError, "bad signal type %s",
- rb_obj_classname(vsig));
- }
- *sig_ptr = vsig = str;
- }
-
- rb_must_asciicompat(vsig);
- RSTRING_GETMEM(vsig, nm, len);
- if (memchr(nm, '\0', len)) {
- rb_raise(rb_eArgError, "signal name with null byte");
- }
-
- if (len > 0 && nm[0] == '-') {
- if (!negative)
- rb_raise(rb_eArgError, "negative signal name: % "PRIsVALUE, vsig);
- prefix = 1;
- }
- else {
- negative = 0;
- }
- if (len >= prefix + signame_prefix_len) {
- if (memcmp(nm + prefix, signame_prefix, signame_prefix_len) == 0)
- prefix += signame_prefix_len;
- }
- if (len <= (long)prefix) {
- unsupported:
- if (prefix == signame_prefix_len) {
- prefix = 0;
- }
- else if (prefix > signame_prefix_len) {
- prefix -= signame_prefix_len;
- len -= prefix;
- vsig = rb_str_subseq(vsig, prefix, len);
- prefix = 0;
- }
- else {
- len -= prefix;
- vsig = rb_str_subseq(vsig, prefix, len);
- prefix = signame_prefix_len;
- }
- rb_raise(rb_eArgError, "unsupported signal `%.*s%"PRIsVALUE"'",
- prefix, signame_prefix, vsig);
- }
- if (prefix_ptr) *prefix_ptr = prefix;
- nmlen = len - prefix;
- nm += prefix;
- if (nmlen > LONGEST_SIGNAME) goto unsupported;
- FOREACH_SIGNAL(sigs, !exit) {
- if (memcmp(sigs->signm, nm, nmlen) == 0 &&
- sigs->signm[nmlen] == '\0') {
- return negative ? -sigs->signo : sigs->signo;
- }
- }
- goto unsupported;
+ for (sigs = siglist; sigs->signm; sigs++)
+ if (strcmp(sigs->signm, nm) == 0)
+ return sigs->signo;
+ return 0;
}
static const char*
@@ -277,10 +226,9 @@ signo2signm(int no)
{
const struct signals *sigs;
- FOREACH_SIGNAL(sigs, 0) {
+ for (sigs = siglist; sigs->signm; sigs++)
if (sigs->signo == no)
return sigs->signm;
- }
return 0;
}
@@ -339,6 +287,7 @@ esignal_init(int argc, VALUE *argv, VALUE self)
int argnum = 1;
VALUE sig = Qnil;
int signo;
+ const char *signm;
if (argc > 0) {
sig = rb_check_to_integer(argv[0], "to_int");
@@ -359,11 +308,19 @@ esignal_init(int argc, VALUE *argv, VALUE self)
}
}
else {
- int prefix;
- signo = signm2signo(&sig, FALSE, FALSE, &prefix);
- if (prefix != signame_prefix_len) {
- sig = rb_str_append(rb_str_new_cstr("SIG"), sig);
+ int len = sizeof(signame_prefix);
+ if (SYMBOL_P(sig)) sig = rb_sym2str(sig); else StringValue(sig);
+ signm = RSTRING_PTR(sig);
+ if (strncmp(signm, signame_prefix, len) == 0) {
+ signm += len;
+ len = 0;
+ }
+ signo = signm2signo(signm);
+ if (!signo) {
+ rb_raise(rb_eArgError, "unsupported name `%.*s%"PRIsVALUE"'",
+ len, signame_prefix, sig);
}
+ sig = rb_sprintf("SIG%s", signm);
}
rb_call_super(1, &sig);
rb_ivar_set(self, id_signo, INT2NUM(signo));
@@ -391,21 +348,13 @@ interrupt_init(int argc, VALUE *argv, VALUE self)
VALUE args[2];
args[0] = INT2FIX(SIGINT);
- args[1] = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
+ rb_scan_args(argc, argv, "01", &args[1]);
return rb_call_super(2, args);
}
-#include "debug_counter.h"
-void rb_malloc_info_show_results(void); /* gc.c */
-
void
ruby_default_signal(int sig)
{
-#if USE_DEBUG_COUNTER
- rb_debug_counter_show_results("killed by signal.");
-#endif
- rb_malloc_info_show_results();
-
signal(sig, SIG_DFL);
raise(sig);
}
@@ -414,24 +363,93 @@ static RETSIGTYPE sighandler(int sig);
static int signal_ignored(int sig);
static void signal_enque(int sig);
+/*
+ * call-seq:
+ * Process.kill(signal, pid, ...) -> integer
+ *
+ * Sends the given signal to the specified process id(s) if _pid_ is positive.
+ * If _pid_ is zero _signal_ is sent to all processes whose group ID is equal
+ * to the group ID of the process. _signal_ may be an integer signal number or
+ * a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is
+ * negative (or starts with a minus sign), kills process groups instead of
+ * processes. Not all signals are available on all platforms.
+ * The keys and values of +Signal.list+ are known signal names and numbers,
+ * respectively.
+ *
+ * pid = fork do
+ * Signal.trap("HUP") { puts "Ouch!"; exit }
+ * # ... do some work ...
+ * end
+ * # ...
+ * Process.kill("HUP", pid)
+ * Process.wait
+ *
+ * <em>produces:</em>
+ *
+ * Ouch!
+ *
+ * If _signal_ is an integer but wrong for signal,
+ * <code>Errno::EINVAL</code> or +RangeError+ will be raised.
+ * Otherwise unless _signal_ is a +String+ or a +Symbol+, and a known
+ * signal name, +ArgumentError+ will be raised.
+ *
+ * Also, <code>Errno::ESRCH</code> or +RangeError+ for invalid _pid_,
+ * <code>Errno::EPERM</code> when failed because of no privilege,
+ * will be raised. In these cases, signals may have been sent to
+ * preceding processes.
+ */
+
VALUE
rb_f_kill(int argc, const VALUE *argv)
{
#ifndef HAVE_KILLPG
#define killpg(pg, sig) kill(-(pg), (sig))
#endif
+ int negative = 0;
int sig;
int i;
VALUE str;
+ const char *s;
rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS);
- if (FIXNUM_P(argv[0])) {
+ switch (TYPE(argv[0])) {
+ case T_FIXNUM:
sig = FIX2INT(argv[0]);
- }
- else {
+ break;
+
+ case T_SYMBOL:
+ str = rb_sym2str(argv[0]);
+ goto str_signal;
+
+ case T_STRING:
str = argv[0];
- sig = signm2signo(&str, TRUE, FALSE, NULL);
+ str_signal:
+ s = RSTRING_PTR(str);
+ if (s[0] == '-') {
+ negative++;
+ s++;
+ }
+ if (strncmp(signame_prefix, s, sizeof(signame_prefix)) == 0)
+ s += 3;
+ if ((sig = signm2signo(s)) == 0) {
+ long ofs = s - RSTRING_PTR(str);
+ if (ofs) str = rb_str_subseq(str, ofs, RSTRING_LEN(str)-ofs);
+ rb_raise(rb_eArgError, "unsupported name `SIG%"PRIsVALUE"'", str);
+ }
+
+ if (negative)
+ sig = -sig;
+ break;
+
+ default:
+ str = rb_check_string_type(argv[0]);
+ if (!NIL_P(str)) {
+ goto str_signal;
+ }
+ rb_raise(rb_eArgError, "bad signal type %s",
+ rb_obj_classname(argv[0]));
+ break;
}
if (argc <= 1) return INT2FIX(0);
@@ -503,12 +521,14 @@ static struct {
rb_atomic_t cnt[RUBY_NSIG];
rb_atomic_t size;
} signal_buff;
-#if RUBY_SIGCHLD
-volatile unsigned int ruby_nocldwait;
-#endif
+#ifdef __dietlibc__
+#define sighandler_t sh_t
+#else
#define sighandler_t ruby_sighandler_t
+#endif
+typedef RETSIGTYPE (*sighandler_t)(int);
#ifdef USE_SIGALTSTACK
typedef void ruby_sigaction_t(int, siginfo_t*, void*);
#define SIGINFO_ARG , siginfo_t *info, void *ctx
@@ -520,18 +540,15 @@ typedef RETSIGTYPE ruby_sigaction_t(int);
#endif
#ifdef USE_SIGALTSTACK
-static int
+int
rb_sigaltstack_size(void)
{
/* XXX: BSD_vfprintf() uses >1500KiB stack and x86-64 need >5KiB stack. */
int size = 16*1024;
#ifdef MINSIGSTKSZ
- {
- int minsigstksz = (int)MINSIGSTKSZ;
- if (size < minsigstksz)
- size = minsigstksz;
- }
+ if (size < MINSIGSTKSZ)
+ size = MINSIGSTKSZ;
#endif
#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
{
@@ -546,18 +563,19 @@ rb_sigaltstack_size(void)
}
/* alternate stack for SIGSEGV */
-void *
-rb_register_sigaltstack(void)
+void
+rb_register_sigaltstack(rb_thread_t *th)
{
stack_t newSS, oldSS;
+ if (!th->altstack)
+ rb_bug("rb_register_sigaltstack: th->altstack not initialized\n");
+
+ newSS.ss_sp = th->altstack;
newSS.ss_size = rb_sigaltstack_size();
- newSS.ss_sp = xmalloc(newSS.ss_size);
newSS.ss_flags = 0;
sigaltstack(&newSS, &oldSS); /* ignore error. */
-
- return newSS.ss_sp;
}
#endif /* USE_SIGALTSTACK */
@@ -587,25 +605,10 @@ ruby_signal(int signum, sighandler_t handler)
#endif
switch (signum) {
-#if RUBY_SIGCHLD
- case RUBY_SIGCHLD:
- if (handler == SIG_IGN) {
- ruby_nocldwait = 1;
-# ifdef USE_SIGALTSTACK
- if (sigact.sa_flags & SA_SIGINFO) {
- sigact.sa_sigaction = (ruby_sigaction_t*)sighandler;
- }
- else {
- sigact.sa_handler = sighandler;
- }
-# else
- sigact.sa_handler = handler;
- sigact.sa_flags = 0;
-# endif
- }
- else {
- ruby_nocldwait = 0;
- }
+#ifdef SA_NOCLDWAIT
+ case SIGCHLD:
+ if (handler == SIG_IGN)
+ sigact.sa_flags |= SA_NOCLDWAIT;
break;
#endif
#if defined(SA_ONSTACK) && defined(USE_SIGALTSTACK)
@@ -686,35 +689,13 @@ signal_enque(int sig)
ATOMIC_INC(signal_buff.size);
}
-#if RUBY_SIGCHLD
-static rb_atomic_t sigchld_hit;
-/* destructive getter than simple predicate */
-# define GET_SIGCHLD_HIT() ATOMIC_EXCHANGE(sigchld_hit, 0)
-#else
-# define GET_SIGCHLD_HIT() 0
-#endif
-
static RETSIGTYPE
sighandler(int sig)
{
int old_errnum = errno;
- /* the VM always needs to handle SIGCHLD for rb_waitpid */
- if (sig == RUBY_SIGCHLD) {
-#if RUBY_SIGCHLD
- rb_vm_t *vm = GET_VM();
- ATOMIC_EXCHANGE(sigchld_hit, 1);
-
- /* avoid spurious wakeup in main thread iff nobody uses trap(:CHLD) */
- if (vm && ACCESS_ONCE(VALUE, vm->trap_list.cmd[sig])) {
- signal_enque(sig);
- }
-#endif
- }
- else {
- signal_enque(sig);
- }
- rb_thread_wakeup_timer_thread(sig);
+ signal_enque(sig);
+ rb_thread_wakeup_timer_thread();
#if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL)
ruby_signal(sig, sighandler);
#endif
@@ -824,17 +805,12 @@ check_stack_overflow(int sig, const uintptr_t addr, const ucontext_t *ctx)
const greg_t bp = mctx->gregs[REG_EBP];
# endif
# elif defined __APPLE__
-# if __DARWIN_UNIX03
-# define MCTX_SS_REG(reg) __ss.__##reg
-# else
-# define MCTX_SS_REG(reg) ss.reg
-# endif
# if defined(__LP64__)
- const uintptr_t sp = mctx->MCTX_SS_REG(rsp);
- const uintptr_t bp = mctx->MCTX_SS_REG(rbp);
+ const uintptr_t sp = mctx->__ss.__rsp;
+ const uintptr_t bp = mctx->__ss.__rbp;
# else
- const uintptr_t sp = mctx->MCTX_SS_REG(esp);
- const uintptr_t bp = mctx->MCTX_SS_REG(ebp);
+ const uintptr_t sp = mctx->__ss.__esp;
+ const uintptr_t bp = mctx->__ss.__ebp;
# endif
# elif defined __FreeBSD__
# if defined(__amd64__)
@@ -861,7 +837,7 @@ check_stack_overflow(int sig, const uintptr_t addr, const ucontext_t *ctx)
/* SP in ucontext is not decremented yet when `push` failed, so
* the fault page can be the next. */
if (sp_page == fault_page || sp_page == fault_page + 1 ||
- (sp_page <= fault_page && fault_page <= bp_page)) {
+ sp_page <= fault_page && fault_page <= bp_page) {
rb_execution_context_t *ec = GET_EC();
int crit = FALSE;
if ((uintptr_t)ec->tag->buf / pagesize <= fault_page + 1) {
@@ -912,10 +888,6 @@ NOINLINE(static void check_reserved_signal_(const char *name, size_t name_len));
#define check_reserved_signal(name) check_reserved_signal_(name, sizeof(name)-1)
#ifdef SIGBUS
-
-static sighandler_t default_sigbus_handler;
-NORETURN(static ruby_sigaction_t sigbus);
-
static RETSIGTYPE
sigbus(int sig SIGINFO_ARG)
{
@@ -929,29 +901,35 @@ sigbus(int sig SIGINFO_ARG)
#if defined __APPLE__ || defined __linux__
CHECK_STACK_OVERFLOW();
#endif
- rb_bug_for_fatal_signal(default_sigbus_handler, sig, SIGINFO_CTX, "Bus Error" MESSAGE_FAULT_ADDRESS);
+ rb_bug_context(SIGINFO_CTX, "Bus Error" MESSAGE_FAULT_ADDRESS);
}
#endif
-#ifdef SIGSEGV
+static void
+ruby_abort(void)
+{
+#ifdef __sun
+ /* Solaris's abort() is async signal unsafe. Of course, it is not
+ * POSIX compliant.
+ */
+ raise(SIGABRT);
+#else
+ abort();
+#endif
-static sighandler_t default_sigsegv_handler;
-NORETURN(static ruby_sigaction_t sigsegv);
+}
+#ifdef SIGSEGV
static RETSIGTYPE
sigsegv(int sig SIGINFO_ARG)
{
check_reserved_signal("SEGV");
CHECK_STACK_OVERFLOW();
- rb_bug_for_fatal_signal(default_sigsegv_handler, sig, SIGINFO_CTX, "Segmentation fault" MESSAGE_FAULT_ADDRESS);
+ rb_bug_context(SIGINFO_CTX, "Segmentation fault" MESSAGE_FAULT_ADDRESS);
}
#endif
#ifdef SIGILL
-
-static sighandler_t default_sigill_handler;
-NORETURN(static ruby_sigaction_t sigill);
-
static RETSIGTYPE
sigill(int sig SIGINFO_ARG)
{
@@ -959,27 +937,10 @@ sigill(int sig SIGINFO_ARG)
#if defined __APPLE__
CHECK_STACK_OVERFLOW();
#endif
- rb_bug_for_fatal_signal(default_sigill_handler, sig, SIGINFO_CTX, "Illegal instruction" MESSAGE_FAULT_ADDRESS);
+ rb_bug_context(SIGINFO_CTX, "Illegal instruction" MESSAGE_FAULT_ADDRESS);
}
#endif
-#ifndef __sun
-NORETURN(static void ruby_abort(void));
-#endif
-
-static void
-ruby_abort(void)
-{
-#ifdef __sun
- /* Solaris's abort() is async signal unsafe. Of course, it is not
- * POSIX compliant.
- */
- raise(SIGABRT);
-#else
- abort();
-#endif
-}
-
static void
check_reserved_signal_(const char *name, size_t name_len)
{
@@ -1023,11 +984,11 @@ sig_do_nothing(int sig)
}
#endif
-static int
-signal_exec(VALUE cmd, int sig)
+static void
+signal_exec(VALUE cmd, int safe, int sig)
{
rb_execution_context_t *ec = GET_EC();
- volatile rb_atomic_t old_interrupt_mask = ec->interrupt_mask;
+ volatile unsigned long old_interrupt_mask = ec->interrupt_mask;
enum ruby_tag_type state;
/*
@@ -1037,13 +998,13 @@ signal_exec(VALUE cmd, int sig)
* 3. rb_signal_exec runs on queued signal
*/
if (IMMEDIATE_P(cmd))
- return FALSE;
+ return;
ec->interrupt_mask |= TRAP_INTERRUPT_MASK;
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
VALUE signum = INT2NUM(sig);
- rb_eval_cmd_kw(cmd, rb_ary_new3(1, signum), RB_NO_KEYWORDS);
+ rb_eval_cmd(cmd, rb_ary_new3(1, signum), safe);
}
EC_POP_TAG();
ec = GET_EC();
@@ -1053,36 +1014,26 @@ signal_exec(VALUE cmd, int sig)
/* XXX: should be replaced with rb_threadptr_pending_interrupt_enque() */
EC_JUMP_TAG(ec, state);
}
- return TRUE;
}
void
-rb_vm_trap_exit(rb_vm_t *vm)
+rb_trap_exit(void)
{
+ rb_vm_t *vm = GET_VM();
VALUE trap_exit = vm->trap_list.cmd[0];
if (trap_exit) {
vm->trap_list.cmd[0] = 0;
- signal_exec(trap_exit, 0);
+ signal_exec(trap_exit, vm->trap_list.safe[0], 0);
}
}
-void ruby_waitpid_all(rb_vm_t *); /* process.c */
-
void
-ruby_sigchld_handler(rb_vm_t *vm)
-{
- if (SIGCHLD_LOSSY || GET_SIGCHLD_HIT()) {
- ruby_waitpid_all(vm);
- }
-}
-
-/* returns true if a trap handler was run, false otherwise */
-int
rb_signal_exec(rb_thread_t *th, int sig)
{
rb_vm_t *vm = GET_VM();
VALUE cmd = vm->trap_list.cmd[sig];
+ int safe = vm->trap_list.safe[sig];
if (cmd == 0) {
switch (sig) {
@@ -1115,9 +1066,8 @@ rb_signal_exec(rb_thread_t *th, int sig)
rb_threadptr_signal_exit(th);
}
else {
- return signal_exec(cmd, sig);
+ signal_exec(cmd, safe, sig);
}
- return FALSE;
}
static sighandler_t
@@ -1144,9 +1094,6 @@ default_handler(int sig)
#ifdef SIGUSR2
case SIGUSR2:
#endif
-#if RUBY_SIGCHLD
- case RUBY_SIGCHLD:
-#endif
func = sighandler;
break;
#ifdef SIGBUS
@@ -1195,7 +1142,7 @@ trap_handler(VALUE *cmd, int sig)
if (!NIL_P(command)) {
const char *cptr;
long len;
- StringValue(command);
+ SafeStringValue(command); /* taint check */
*cmd = command;
RSTRING_GETMEM(command, cptr, len);
switch (len) {
@@ -1204,9 +1151,6 @@ trap_handler(VALUE *cmd, int sig)
break;
case 14:
if (memcmp(cptr, "SYSTEM_DEFAULT", 14) == 0) {
- if (sig == RUBY_SIGCHLD) {
- goto sig_dfl;
- }
func = SIG_DFL;
*cmd = 0;
}
@@ -1252,15 +1196,33 @@ static int
trap_signm(VALUE vsig)
{
int sig = -1;
+ const char *s;
- if (FIXNUM_P(vsig)) {
+ switch (TYPE(vsig)) {
+ case T_FIXNUM:
sig = FIX2INT(vsig);
if (sig < 0 || sig >= NSIG) {
rb_raise(rb_eArgError, "invalid signal number (%d)", sig);
}
- }
- else {
- sig = signm2signo(&vsig, FALSE, TRUE, NULL);
+ break;
+
+ case T_SYMBOL:
+ vsig = rb_sym2str(vsig);
+ s = RSTRING_PTR(vsig);
+ goto str_signal;
+
+ default:
+ s = StringValuePtr(vsig);
+
+ str_signal:
+ if (strncmp(signame_prefix, s, sizeof(signame_prefix)) == 0)
+ s += 3;
+ sig = signm2signo(s);
+ if (sig == 0 && strcmp(s, "EXIT") != 0) {
+ long ofs = s - RSTRING_PTR(vsig);
+ if (ofs) vsig = rb_str_subseq(vsig, ofs, RSTRING_LEN(vsig)-ofs);
+ rb_raise(rb_eArgError, "unsupported signal SIG%"PRIsVALUE"", vsig);
+ }
}
return sig;
}
@@ -1300,7 +1262,8 @@ trap(int sig, sighandler_t func, VALUE command)
break;
}
- ACCESS_ONCE(VALUE, vm->trap_list.cmd[sig]) = command;
+ vm->trap_list.cmd[sig] = command;
+ vm->trap_list.safe[sig] = rb_safe_level();
return oldcmd;
}
@@ -1367,7 +1330,7 @@ reserved_signal_p(int signo)
* Terminating: 27460
*/
static VALUE
-sig_trap(int argc, VALUE *argv, VALUE _)
+sig_trap(int argc, VALUE *argv)
{
int sig;
sighandler_t func;
@@ -1393,6 +1356,10 @@ sig_trap(int argc, VALUE *argv, VALUE _)
func = trap_handler(&cmd, sig);
}
+ if (OBJ_TAINTED(cmd)) {
+ rb_raise(rb_eSecurityError, "Insecure: tainted signal trap");
+ }
+
return trap(sig, func, cmd);
}
@@ -1406,12 +1373,12 @@ sig_trap(int argc, VALUE *argv, VALUE _)
* Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
*/
static VALUE
-sig_list(VALUE _)
+sig_list(void)
{
VALUE h = rb_hash_new();
const struct signals *sigs;
- FOREACH_SIGNAL(sigs, 0) {
+ for (sigs = siglist; sigs->signm; sigs++) {
rb_hash_aset(h, rb_fstring_cstr(sigs->signm), INT2FIX(sigs->signo));
}
return h;
@@ -1424,41 +1391,36 @@ sig_list(VALUE _)
perror(failed); \
} while (0)
static int
-install_sighandler_core(int signum, sighandler_t handler, sighandler_t *old_handler)
+install_sighandler(int signum, sighandler_t handler)
{
sighandler_t old;
old = ruby_signal(signum, handler);
if (old == SIG_ERR) return -1;
- if (old_handler) {
- *old_handler = (old == SIG_DFL || old == SIG_IGN) ? 0 : old;
- }
- else {
- /* signal handler should be inherited during exec. */
- if (old != SIG_DFL) {
- ruby_signal(signum, old);
- }
+ /* signal handler should be inherited during exec. */
+ if (old != SIG_DFL) {
+ ruby_signal(signum, old);
}
return 0;
}
# define install_sighandler(signum, handler) \
- INSTALL_SIGHANDLER(install_sighandler_core(signum, handler, NULL), #signum, signum)
-# define force_install_sighandler(signum, handler, old_handler) \
- INSTALL_SIGHANDLER(install_sighandler_core(signum, handler, old_handler), #signum, signum)
+ INSTALL_SIGHANDLER(install_sighandler(signum, handler), #signum, signum)
-#if RUBY_SIGCHLD
+#if defined(SIGCLD) || defined(SIGCHLD)
static int
init_sigchld(int sig)
{
sighandler_t oldfunc;
- sighandler_t func = sighandler;
oldfunc = ruby_signal(sig, SIG_DFL);
if (oldfunc == SIG_ERR) return -1;
- ruby_signal(sig, func);
- ACCESS_ONCE(VALUE, GET_VM()->trap_list.cmd[sig]) = 0;
-
+ if (oldfunc != SIG_DFL && oldfunc != SIG_IGN) {
+ ruby_signal(sig, oldfunc);
+ }
+ else {
+ GET_VM()->trap_list.cmd[sig] = 0;
+ }
return 0;
}
@@ -1557,14 +1519,16 @@ Init_signal(void)
if (!ruby_enable_coredump) {
#ifdef SIGBUS
- force_install_sighandler(SIGBUS, (sighandler_t)sigbus, &default_sigbus_handler);
+ install_sighandler(SIGBUS, (sighandler_t)sigbus);
#endif
#ifdef SIGILL
- force_install_sighandler(SIGILL, (sighandler_t)sigill, &default_sigill_handler);
+ install_sighandler(SIGILL, (sighandler_t)sigill);
#endif
#ifdef SIGSEGV
- RB_ALTSTACK_INIT(GET_VM()->main_altstack);
- force_install_sighandler(SIGSEGV, (sighandler_t)sigsegv, &default_sigsegv_handler);
+# ifdef USE_SIGALTSTACK
+ rb_register_sigaltstack(GET_THREAD());
+# endif
+ install_sighandler(SIGSEGV, (sighandler_t)sigsegv);
#endif
}
#ifdef SIGPIPE
@@ -1574,55 +1538,11 @@ Init_signal(void)
install_sighandler(SIGSYS, sig_do_nothing);
#endif
-#if RUBY_SIGCHLD
- init_sigchld(RUBY_SIGCHLD);
+#if defined(SIGCLD)
+ init_sigchld(SIGCLD);
+#elif defined(SIGCHLD)
+ init_sigchld(SIGCHLD);
#endif
rb_enable_interrupt();
}
-
-#if defined(HAVE_GRANTPT)
-extern int grantpt(int);
-#else
-static int
-fake_grantfd(int masterfd)
-{
- errno = ENOSYS;
- return -1;
-}
-#define grantpt(fd) fake_grantfd(fd)
-#endif
-
-int
-rb_grantpt(int masterfd)
-{
- if (RUBY_SIGCHLD) {
- rb_vm_t *vm = GET_VM();
- int ret, e;
-
- /*
- * Prevent waitpid calls from Ruby by taking waitpid_lock.
- * Pedantically, grantpt(3) is undefined if a non-default
- * SIGCHLD handler is defined, but preventing conflicting
- * waitpid calls ought to be sufficient.
- *
- * We could install the default sighandler temporarily, but that
- * could cause SIGCHLD to be missed by other threads. Blocking
- * SIGCHLD won't work here, either, unless we stop and restart
- * timer-thread (as only timer-thread sees SIGCHLD), but that
- * seems like overkill.
- */
- rb_nativethread_lock_lock(&vm->waitpid_lock);
- {
- ret = grantpt(masterfd); /* may spawn `pt_chown' and wait on it */
- if (ret < 0) e = errno;
- }
- rb_nativethread_lock_unlock(&vm->waitpid_lock);
-
- if (ret < 0) errno = e;
- return ret;
- }
- else {
- return grantpt(masterfd);
- }
-}
diff --git a/siphash.c b/siphash.c
index ddf8ee245d..153d2c690a 100644
--- a/siphash.c
+++ b/siphash.c
@@ -30,7 +30,7 @@
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
- defined(__powerpc64__) || defined(__aarch64__) || \
+ defined(__powerpc64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# endif
diff --git a/siphash.h b/siphash.h
index f49bc511b1..2e7553f208 100644
--- a/siphash.h
+++ b/siphash.h
@@ -43,6 +43,6 @@ int sip_hash_digest_integer(sip_hash *h, const uint8_t *data, size_t data_len, u
void sip_hash_free(sip_hash *h);
void sip_hash_dump(sip_hash *h);
-NO_SANITIZE("unsigned-integer-overflow", uint64_t sip_hash13(const uint8_t key[16], const uint8_t *data, size_t len));
+uint64_t sip_hash13(const uint8_t key[16], const uint8_t *data, size_t len);
#endif
diff --git a/spec/README.md b/spec/README.md
index 1b2e4d5f53..60d4849f9c 100644
--- a/spec/README.md
+++ b/spec/README.md
@@ -1,14 +1,3 @@
-# spec/bundler
-
-spec/bundler is rspec examples for bundler library(lib/bundler.rb, lib/bundler/*).
-
-## Running spec/bundler
-
-To run rspec for bundler:
-```bash
-make test-bundler
-```
-
# spec/ruby
ruby/spec (https://github.com/ruby/spec/) is
@@ -30,46 +19,6 @@ In other words: If adding a spec might reveal a bug in
another implementation, then it is worth adding it.
Currently, the only module which is MRI-specific is `RubyVM`.
-## Changing behavior and versions guards
-
-Version guards (`ruby_version_is`) must be added for new features or features
-which change behavior or are removed. This is necessary for other Ruby implementations
-to still be able to run the specs and contribute new specs.
-
-For example, change:
-```ruby
-describe "Some spec" do
- it "some example" do
- # Old behavior for Ruby < 2.7
- end
-end
-```
-to:
-```ruby
-describe "Some spec" do
- ruby_version_is ""..."2.7" do
- it "some example" do
- # Old behavior for Ruby < 2.7
- end
- end
-
- ruby_version_is "2.7" do
- it "some example" do
- # New behavior for Ruby >= 2.7
- end
- end
-end
-```
-
-See `spec/ruby/CONTRIBUTING.md` for more documentation about guards.
-
-To verify specs are compatible with older Ruby versions:
-```
-cd spec/ruby
-$RUBY_MANAGER use 2.4.6
-../mspec/bin/mspec -j
-```
-
## Running ruby/spec
To run all specs:
@@ -103,8 +52,8 @@ spec/mspec/bin/mspec spec/ruby/language/for_spec.rb
## ruby/spec and test/
-The main difference between a "spec" under `spec/ruby/` and
-a test under `test/` is that specs are documenting what they test.
+The main difference between a "spec" under spec/ruby and
+a test under test/ is that specs are documenting what they test.
This is extremely valuable when reading these tests, as it
helps to quickly understand what specific behavior is tested,
and how a method should behave. Basic English is fine for spec descriptions.
@@ -127,4 +76,4 @@ describe "The for expression" do
end
```
-For more details, see `spec/ruby/CONTRIBUTING.md`.
+For more details, see spec/ruby/CONTRIBUTING.md.
diff --git a/spec/bundler/bundler/build_metadata_spec.rb b/spec/bundler/bundler/build_metadata_spec.rb
deleted file mode 100644
index afa2d1716f..0000000000
--- a/spec/bundler/bundler/build_metadata_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler"
-require "bundler/build_metadata"
-
-RSpec.describe Bundler::BuildMetadata do
- before do
- allow(Time).to receive(:now).and_return(Time.at(0))
- Bundler::BuildMetadata.instance_variable_set(:@built_at, nil)
- end
-
- describe "#built_at" do
- it "returns %Y-%m-%d formatted time" do
- expect(Bundler::BuildMetadata.built_at).to eq "1970-01-01"
- end
- end
-
- describe "#release?" do
- it "returns false as default" do
- expect(Bundler::BuildMetadata.release?).to be_falsey
- end
- end
-
- describe "#git_commit_sha" do
- context "if instance valuable is defined" do
- before do
- Bundler::BuildMetadata.instance_variable_set(:@git_commit_sha, "foo")
- end
-
- after do
- Bundler::BuildMetadata.remove_instance_variable(:@git_commit_sha)
- end
-
- it "returns set value" do
- expect(Bundler::BuildMetadata.git_commit_sha).to eq "foo"
- end
- end
- end
-
- describe "#to_h" do
- subject { Bundler::BuildMetadata.to_h }
-
- it "returns a hash includes Built At, Git SHA and Released Version" do
- expect(subject["Built At"]).to eq "1970-01-01"
- expect(subject["Git SHA"]).to be_instance_of(String)
- expect(subject["Released Version"]).to be_falsey
- end
- end
-end
diff --git a/spec/bundler/bundler/bundler_spec.rb b/spec/bundler/bundler/bundler_spec.rb
deleted file mode 100644
index 247838600b..0000000000
--- a/spec/bundler/bundler/bundler_spec.rb
+++ /dev/null
@@ -1,460 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler"
-require "tmpdir"
-
-RSpec.describe Bundler do
- describe "#load_gemspec_uncached" do
- let(:app_gemspec_path) { tmp("test.gemspec") }
- subject { Bundler.load_gemspec_uncached(app_gemspec_path) }
-
- context "with incorrect YAML file" do
- before do
- File.open(app_gemspec_path, "wb") do |f|
- f.write strip_whitespace(<<-GEMSPEC)
- ---
- {:!00 ao=gu\g1= 7~f
- GEMSPEC
- end
- end
-
- it "catches YAML syntax errors" do
- expect { subject }.to raise_error(Bundler::GemspecError, /error while loading `test.gemspec`/)
- end
-
- context "on Rubies with a settable YAML engine", :if => defined?(YAML::ENGINE) do
- context "with Syck as YAML::Engine" do
- it "raises a GemspecError after YAML load throws ArgumentError" do
- orig_yamler = YAML::ENGINE.yamler
- YAML::ENGINE.yamler = "syck"
-
- expect { subject }.to raise_error(Bundler::GemspecError)
-
- YAML::ENGINE.yamler = orig_yamler
- end
- end
-
- context "with Psych as YAML::Engine" do
- it "raises a GemspecError after YAML load throws Psych::SyntaxError" do
- orig_yamler = YAML::ENGINE.yamler
- YAML::ENGINE.yamler = "psych"
-
- expect { subject }.to raise_error(Bundler::GemspecError)
-
- YAML::ENGINE.yamler = orig_yamler
- end
- end
- end
- end
-
- context "with correct YAML file", :if => defined?(Encoding) do
- it "can load a gemspec with unicode characters with default ruby encoding" do
- # spec_helper forces the external encoding to UTF-8 but that's not the
- # default until Ruby 2.0
- verbose = $VERBOSE
- $VERBOSE = false
- encoding = Encoding.default_external
- Encoding.default_external = "ASCII"
- $VERBOSE = verbose
-
- File.open(app_gemspec_path, "wb") do |file|
- file.puts <<-GEMSPEC.gsub(/^\s+/, "")
- # -*- encoding: utf-8 -*-
- Gem::Specification.new do |gem|
- gem.author = "André the Giant"
- end
- GEMSPEC
- end
-
- expect(subject.author).to eq("André the Giant")
-
- verbose = $VERBOSE
- $VERBOSE = false
- Encoding.default_external = encoding
- $VERBOSE = verbose
- end
- end
-
- it "sets loaded_from" do
- app_gemspec_path.open("w") do |f|
- f.puts <<-GEMSPEC
- Gem::Specification.new do |gem|
- gem.name = "validated"
- end
- GEMSPEC
- end
-
- expect(subject.loaded_from).to eq(app_gemspec_path.expand_path.to_s)
- end
-
- context "validate is true" do
- subject { Bundler.load_gemspec_uncached(app_gemspec_path, true) }
-
- it "validates the specification" do
- app_gemspec_path.open("w") do |f|
- f.puts <<-GEMSPEC
- Gem::Specification.new do |gem|
- gem.name = "validated"
- end
- GEMSPEC
- end
- expect(Bundler.rubygems).to receive(:validate).with have_attributes(:name => "validated")
- subject
- end
- end
-
- context "with gemspec containing local variables" do
- before do
- File.open(app_gemspec_path, "wb") do |f|
- f.write strip_whitespace(<<-GEMSPEC)
- must_not_leak = true
- Gem::Specification.new do |gem|
- gem.name = "leak check"
- end
- GEMSPEC
- end
- end
-
- it "should not pollute the TOPLEVEL_BINDING" do
- subject
- expect(TOPLEVEL_BINDING.eval("local_variables")).to_not include(:must_not_leak)
- end
- end
- end
-
- describe "#which" do
- let(:executable) { "executable" }
- let(:path) { %w[/a /b c ../d /e] }
- let(:expected) { "executable" }
-
- before do
- ENV["PATH"] = path.join(File::PATH_SEPARATOR)
-
- allow(File).to receive(:file?).and_return(false)
- allow(File).to receive(:executable?).and_return(false)
- if expected
- expect(File).to receive(:file?).with(expected).and_return(true)
- expect(File).to receive(:executable?).with(expected).and_return(true)
- end
- end
-
- subject { described_class.which(executable) }
-
- shared_examples_for "it returns the correct executable" do
- it "returns the expected file" do
- expect(subject).to eq(expected)
- end
- end
-
- it_behaves_like "it returns the correct executable"
-
- context "when the executable in inside a quoted path" do
- let(:expected) { "/e/executable" }
- it_behaves_like "it returns the correct executable"
- end
-
- context "when the executable is not found" do
- let(:expected) { nil }
- it_behaves_like "it returns the correct executable"
- end
- end
-
- describe "configuration" do
- context "disable_shared_gems" do
- it "should unset GEM_PATH with empty string" do
- env = {}
- expect(Bundler).to receive(:use_system_gems?).and_return(false)
- Bundler.send(:configure_gem_path, env)
- expect(env.keys).to include("GEM_PATH")
- expect(env["GEM_PATH"]).to eq ""
- end
- end
- end
-
- describe "#rm_rf" do
- context "the directory is world writable" do
- let(:bundler_ui) { Bundler.ui }
- it "should raise a friendly error" do
- allow(File).to receive(:exist?).and_return(true)
- allow(::Bundler::FileUtils).to receive(:remove_entry_secure).and_raise(ArgumentError)
- allow(File).to receive(:world_writable?).and_return(true)
- message = <<EOF
-It is a security vulnerability to allow your home directory to be world-writable, and bundler can not continue.
-You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
-Please refer to https://ruby-doc.org/stdlib-2.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
-EOF
- expect(bundler_ui).to receive(:warn).with(message)
- expect { Bundler.send(:rm_rf, bundled_app) }.to raise_error(Bundler::PathError)
- end
- end
- end
-
- describe "#mkdir_p" do
- it "creates a folder at the given path" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- Bundler.mkdir_p(bundled_app.join("foo", "bar"))
- expect(bundled_app.join("foo", "bar")).to exist
- end
-
- context "when mkdir_p requires sudo" do
- it "creates a new folder using sudo" do
- expect(Bundler).to receive(:requires_sudo?).and_return(true)
- expect(Bundler).to receive(:sudo).and_return true
- Bundler.mkdir_p(bundled_app.join("foo"))
- end
- end
-
- context "with :no_sudo option" do
- it "forces mkdir_p to not use sudo" do
- expect(Bundler).to receive(:requires_sudo?).and_return(true)
- expect(Bundler).to_not receive(:sudo)
- Bundler.mkdir_p(bundled_app.join("foo"), :no_sudo => true)
- end
- end
- end
-
- describe "#user_home" do
- context "home directory is set" do
- it "should return the user home" do
- path = "/home/oggy"
- allow(Bundler.rubygems).to receive(:user_home).and_return(path)
- allow(File).to receive(:directory?).with(path).and_return true
- allow(File).to receive(:writable?).with(path).and_return true
- expect(Bundler.user_home).to eq(Pathname(path))
- end
-
- context "is not a directory" do
- it "should issue a warning and return a temporary user home" do
- path = "/home/oggy"
- allow(Bundler.rubygems).to receive(:user_home).and_return(path)
- allow(File).to receive(:directory?).with(path).and_return false
- allow(Bundler).to receive(:tmp).and_return(Pathname.new("/tmp/trulyrandom"))
- message = <<EOF
-`/home/oggy` is not a directory.
-Bundler will use `/tmp/trulyrandom' as your home directory temporarily.
-EOF
- expect(Bundler.ui).to receive(:warn).with(message)
- expect(Bundler.user_home).to eq(Pathname("/tmp/trulyrandom"))
- end
- end
-
- context "is not writable" do
- let(:path) { "/home/oggy" }
- let(:dotbundle) { "/home/oggy/.bundle" }
-
- it "should issue a warning and return a temporary user home" do
- allow(Bundler.rubygems).to receive(:user_home).and_return(path)
- allow(File).to receive(:directory?).with(path).and_return true
- allow(File).to receive(:writable?).with(path).and_return false
- allow(File).to receive(:directory?).with(dotbundle).and_return false
- allow(Bundler).to receive(:tmp).and_return(Pathname.new("/tmp/trulyrandom"))
- message = <<EOF
-`/home/oggy` is not writable.
-Bundler will use `/tmp/trulyrandom' as your home directory temporarily.
-EOF
- expect(Bundler.ui).to receive(:warn).with(message)
- expect(Bundler.user_home).to eq(Pathname("/tmp/trulyrandom"))
- end
-
- context ".bundle exists and have correct permissions" do
- it "should return the user home" do
- allow(Bundler.rubygems).to receive(:user_home).and_return(path)
- allow(File).to receive(:directory?).with(path).and_return true
- allow(File).to receive(:writable?).with(path).and_return false
- allow(File).to receive(:directory?).with(dotbundle).and_return true
- allow(File).to receive(:writable?).with(dotbundle).and_return true
- expect(Bundler.user_home).to eq(Pathname(path))
- end
- end
- end
- end
-
- context "home directory is not set" do
- it "should issue warning and return a temporary user home" do
- allow(Bundler.rubygems).to receive(:user_home).and_return(nil)
- allow(Bundler).to receive(:tmp).and_return(Pathname.new("/tmp/trulyrandom"))
- message = <<EOF
-Your home directory is not set.
-Bundler will use `/tmp/trulyrandom' as your home directory temporarily.
-EOF
- expect(Bundler.ui).to receive(:warn).with(message)
- expect(Bundler.user_home).to eq(Pathname("/tmp/trulyrandom"))
- end
- end
- end
-
- describe "#requires_sudo?" do
- let!(:tmpdir) { Dir.mktmpdir }
- let(:bundle_path) { Pathname("#{tmpdir}/bundle") }
-
- def clear_cached_requires_sudo
- return unless Bundler.instance_variable_defined?(:@requires_sudo_ran)
- Bundler.remove_instance_variable(:@requires_sudo_ran)
- Bundler.remove_instance_variable(:@requires_sudo)
- end
-
- before do
- clear_cached_requires_sudo
- allow(Bundler).to receive(:which).with("sudo").and_return("/usr/bin/sudo")
- allow(Bundler).to receive(:bundle_path).and_return(bundle_path)
- end
-
- after do
- FileUtils.rm_rf(tmpdir)
- clear_cached_requires_sudo
- end
-
- subject { Bundler.requires_sudo? }
-
- context "bundle_path doesn't exist" do
- it { should be false }
-
- context "and parent dir can't be written" do
- before do
- FileUtils.chmod(0o500, tmpdir)
- end
-
- it { should be true }
- end
-
- context "with unwritable files in a parent dir" do
- # Regression test for https://github.com/bundler/bundler/pull/6316
- # It doesn't matter if there are other unwritable files so long as
- # bundle_path can be created
- before do
- file = File.join(tmpdir, "unrelated_file")
- FileUtils.touch(file)
- FileUtils.chmod(0o400, file)
- end
-
- it { should be false }
- end
- end
-
- context "bundle_path exists" do
- before do
- FileUtils.mkdir_p(bundle_path)
- end
-
- it { should be false }
-
- context "and is unwritable" do
- before do
- FileUtils.chmod(0o500, bundle_path)
- end
-
- it { should be true }
- end
- end
-
- context "path writability" do
- before do
- FileUtils.mkdir_p("tmp/vendor/bundle")
- FileUtils.mkdir_p("tmp/vendor/bin_dir")
- end
- after do
- FileUtils.rm_rf("tmp/vendor/bundle")
- FileUtils.rm_rf("tmp/vendor/bin_dir")
- end
- context "writable paths" do
- it "should return false and display nothing" do
- allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
- expect(Bundler.ui).to_not receive(:warn)
- expect(Bundler.requires_sudo?).to eq(false)
- end
- end
- context "unwritable paths" do
- before do
- FileUtils.touch("tmp/vendor/bundle/unwritable1.txt")
- FileUtils.touch("tmp/vendor/bundle/unwritable2.txt")
- FileUtils.touch("tmp/vendor/bin_dir/unwritable3.txt")
- FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable1.txt")
- FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable2.txt")
- FileUtils.chmod(0o400, "tmp/vendor/bin_dir/unwritable3.txt")
- end
- it "should return true and display warn message" do
- allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
- bin_dir = Pathname("tmp/vendor/bin_dir/")
-
- # allow File#writable? to be called with args other than the stubbed on below
- allow(File).to receive(:writable?).and_call_original
-
- # fake make the directory unwritable
- allow(File).to receive(:writable?).with(bin_dir).and_return(false)
- allow(Bundler).to receive(:system_bindir).and_return(Pathname("tmp/vendor/bin_dir/"))
- message = <<-MESSAGE.chomp
-Following files may not be writable, so sudo is needed:
- tmp/vendor/bin_dir/
- tmp/vendor/bundle/unwritable1.txt
- tmp/vendor/bundle/unwritable2.txt
-MESSAGE
- expect(Bundler.ui).to receive(:warn).with(message)
- expect(Bundler.requires_sudo?).to eq(true)
- end
- end
- end
- end
-
- context "user cache dir" do
- let(:home_path) { Pathname.new(ENV["HOME"]) }
-
- let(:xdg_data_home) { home_path.join(".local") }
- let(:xdg_cache_home) { home_path.join(".cache") }
- let(:xdg_config_home) { home_path.join(".config") }
-
- let(:bundle_user_home_default) { home_path.join(".bundle") }
- let(:bundle_user_home_custom) { xdg_data_home.join("bundle") }
-
- let(:bundle_user_cache_default) { bundle_user_home_default.join("cache") }
- let(:bundle_user_cache_custom) { xdg_cache_home.join("bundle") }
-
- let(:bundle_user_config_default) { bundle_user_home_default.join("config") }
- let(:bundle_user_config_custom) { xdg_config_home.join("bundle") }
-
- let(:bundle_user_plugin_default) { bundle_user_home_default.join("plugin") }
- let(:bundle_user_plugin_custom) { xdg_data_home.join("bundle").join("plugin") }
-
- describe "#user_bundle_path" do
- before do
- allow(Bundler.rubygems).to receive(:user_home).and_return(home_path)
- end
-
- it "should use the default home path" do
- expect(Bundler.user_bundle_path).to eq(bundle_user_home_default)
- expect(Bundler.user_bundle_path("home")).to eq(bundle_user_home_default)
- expect(Bundler.user_bundle_path("cache")).to eq(bundle_user_cache_default)
- expect(Bundler.user_cache).to eq(bundle_user_cache_default)
- expect(Bundler.user_bundle_path("config")).to eq(bundle_user_config_default)
- expect(Bundler.user_bundle_path("plugin")).to eq(bundle_user_plugin_default)
- end
-
- it "should use custom home path as root for other paths" do
- ENV["BUNDLE_USER_HOME"] = bundle_user_home_custom.to_s
- allow(Bundler.rubygems).to receive(:user_home).and_raise
- expect(Bundler.user_bundle_path).to eq(bundle_user_home_custom)
- expect(Bundler.user_bundle_path("home")).to eq(bundle_user_home_custom)
- expect(Bundler.user_bundle_path("cache")).to eq(bundle_user_home_custom.join("cache"))
- expect(Bundler.user_cache).to eq(bundle_user_home_custom.join("cache"))
- expect(Bundler.user_bundle_path("config")).to eq(bundle_user_home_custom.join("config"))
- expect(Bundler.user_bundle_path("plugin")).to eq(bundle_user_home_custom.join("plugin"))
- end
-
- it "should use all custom paths, except home" do
- ENV.delete("BUNDLE_USER_HOME")
- ENV["BUNDLE_USER_CACHE"] = bundle_user_cache_custom.to_s
- ENV["BUNDLE_USER_CONFIG"] = bundle_user_config_custom.to_s
- ENV["BUNDLE_USER_PLUGIN"] = bundle_user_plugin_custom.to_s
- expect(Bundler.user_bundle_path).to eq(bundle_user_home_default)
- expect(Bundler.user_bundle_path("home")).to eq(bundle_user_home_default)
- expect(Bundler.user_bundle_path("cache")).to eq(bundle_user_cache_custom)
- expect(Bundler.user_cache).to eq(bundle_user_cache_custom)
- expect(Bundler.user_bundle_path("config")).to eq(bundle_user_config_custom)
- expect(Bundler.user_bundle_path("plugin")).to eq(bundle_user_plugin_custom)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb
deleted file mode 100644
index ddcd699d6c..0000000000
--- a/spec/bundler/bundler/cli_spec.rb
+++ /dev/null
@@ -1,223 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/cli"
-
-RSpec.describe "bundle executable" do
- it "returns non-zero exit status when passed unrecognized options" do
- bundle "--invalid_argument"
- expect(exitstatus).to_not be_zero if exitstatus
- end
-
- it "returns non-zero exit status when passed unrecognized task" do
- bundle "unrecognized-task"
- expect(exitstatus).to_not be_zero if exitstatus
- end
-
- it "looks for a binary and executes it if it's named bundler-<task>" do
- File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
- ruby = ENV["RUBY"] || "/usr/bin/env ruby"
- f.puts "#!#{ruby}\nputs 'Hello, world'\n"
- end
-
- with_path_added(tmp) do
- bundle "testtasks"
- end
-
- expect(exitstatus).to be_zero if exitstatus
- expect(out).to eq("Hello, world")
- end
-
- describe "aliases" do
- it "aliases e to exec" do
- bundle "e --help"
-
- expect(out).to include("BUNDLE-EXEC")
- end
-
- it "aliases ex to exec" do
- bundle "ex --help"
-
- expect(out).to include("BUNDLE-EXEC")
- end
-
- it "aliases exe to exec" do
- bundle "exe --help"
-
- expect(out).to include("BUNDLE-EXEC")
- end
-
- it "aliases c to check" do
- bundle "c --help"
-
- expect(out).to include("BUNDLE-CHECK")
- end
-
- it "aliases i to install" do
- bundle "i --help"
-
- expect(out).to include("BUNDLE-INSTALL")
- end
-
- it "aliases ls to list" do
- bundle "ls --help"
-
- expect(out).to include("BUNDLE-LIST")
- end
-
- it "aliases package to cache" do
- bundle "package --help"
-
- expect(out).to include("BUNDLE-CACHE")
- end
-
- it "aliases pack to cache" do
- bundle "pack --help"
-
- expect(out).to include("BUNDLE-CACHE")
- end
- end
-
- context "with no arguments" do
- it "prints a concise help message", :bundler => "3" do
- bundle! ""
- expect(err).to be_empty
- expect(out).to include("Bundler version #{Bundler::VERSION}").
- and include("\n\nBundler commands:\n\n").
- and include("\n\n Primary commands:\n").
- and include("\n\n Utilities:\n").
- and include("\n\nOptions:\n")
- end
- end
-
- context "when ENV['BUNDLE_GEMFILE'] is set to an empty string" do
- it "ignores it" do
- gemfile bundled_app("Gemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle :install, :env => { "BUNDLE_GEMFILE" => "" }
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- context "when ENV['RUBYGEMS_GEMDEPS'] is set" do
- it "displays a warning" do
- gemfile bundled_app("Gemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle :install, :env => { "RUBYGEMS_GEMDEPS" => "foo" }
- expect(err).to include("RUBYGEMS_GEMDEPS")
- expect(err).to include("conflict with Bundler")
-
- bundle :install, :env => { "RUBYGEMS_GEMDEPS" => "" }
- expect(err).not_to include("RUBYGEMS_GEMDEPS")
- end
- end
-
- context "with --verbose" do
- it "prints the running command" do
- gemfile ""
- bundle! "info bundler", :verbose => true
- expect(out).to start_with("Running `bundle info bundler --verbose` with bundler #{Bundler::VERSION}")
- end
-
- it "doesn't print defaults" do
- install_gemfile! "", :verbose => true
- expect(out).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
- end
-
- it "doesn't print defaults" do
- install_gemfile! "", :verbose => true
- expect(out).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
- end
- end
-
- describe "printing the outdated warning" do
- shared_examples_for "no warning" do
- it "prints no warning" do
- bundle "fail"
- expect(last_command.stdboth).to eq("Could not find command \"fail\".")
- end
- end
-
- let(:bundler_version) { "1.1" }
- let(:latest_version) { nil }
- before do
- bundle! "config set --global disable_version_check false"
-
- simulate_bundler_version(bundler_version)
- if latest_version
- info_path = home(".bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/info/bundler")
- info_path.parent.mkpath
- info_path.open("w") {|f| f.write "#{latest_version}\n" }
- end
- end
-
- context "when there is no latest version" do
- include_examples "no warning"
- end
-
- context "when the latest version is equal to the current version" do
- let(:latest_version) { bundler_version }
- include_examples "no warning"
- end
-
- context "when the latest version is less than the current version" do
- let(:latest_version) { "0.9" }
- include_examples "no warning"
- end
-
- context "when the latest version is greater than the current version" do
- let(:latest_version) { "222.0" }
- it "prints the version warning" do
- bundle "fail"
- expect(err).to start_with(<<-EOS.strip)
-The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
-To install the latest version, run `gem install bundler`
- EOS
- end
-
- context "and disable_version_check is set" do
- before { bundle! "config set disable_version_check true" }
- include_examples "no warning"
- end
-
- context "running a parseable command" do
- it "prints no warning" do
- bundle! "config get --parseable foo"
- expect(last_command.stdboth).to eq ""
-
- bundle "platform --ruby"
- expect(last_command.stdboth).to eq "Could not locate Gemfile"
- end
- end
-
- context "and is a pre-release" do
- let(:latest_version) { "222.0.0.pre.4" }
- it "prints the version warning" do
- bundle "fail"
- expect(err).to start_with(<<-EOS.strip)
-The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
-To install the latest version, run `gem install bundler --pre`
- EOS
- end
- end
- end
- end
-end
-
-RSpec.describe "bundler executable" do
- it "shows the bundler version just as the `bundle` executable does", :bundler => "< 3" do
- bundler "--version"
- expect(out).to eq("Bundler version #{Bundler::VERSION}")
- end
-
- it "shows the bundler version just as the `bundle` executable does", :bundler => "3" do
- bundler "--version"
- expect(out).to eq(Bundler::VERSION)
- end
-end
diff --git a/spec/bundler/bundler/compact_index_client/updater_spec.rb b/spec/bundler/bundler/compact_index_client/updater_spec.rb
deleted file mode 100644
index fd554a7b0d..0000000000
--- a/spec/bundler/bundler/compact_index_client/updater_spec.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-require "net/http"
-require "bundler/compact_index_client"
-require "bundler/compact_index_client/updater"
-
-RSpec.describe Bundler::CompactIndexClient::Updater do
- let(:fetcher) { double(:fetcher) }
- let(:local_path) { Pathname("/tmp/localpath") }
- let(:remote_path) { double(:remote_path) }
-
- subject(:updater) { described_class.new(fetcher) }
-
- context "when the ETag header is missing" do
- # Regression test for https://github.com/bundler/bundler/issues/5463
-
- let(:response) { double(:response, :body => "") }
-
- it "MisMatchedChecksumError is raised" do
- # Twice: #update retries on failure
- expect(response).to receive(:[]).with("Content-Encoding").twice { "" }
- expect(response).to receive(:[]).with("ETag").twice { nil }
- expect(fetcher).to receive(:call).twice { response }
-
- expect do
- updater.update(local_path, remote_path)
- end.to raise_error(Bundler::CompactIndexClient::Updater::MisMatchedChecksumError)
- end
- end
-
- context "when the download is corrupt" do
- let(:response) { double(:response, :body => "") }
-
- it "raises HTTPError" do
- expect(response).to receive(:[]).with("Content-Encoding") { "gzip" }
- expect(fetcher).to receive(:call) { response }
-
- expect do
- updater.update(local_path, remote_path)
- end.to raise_error(Bundler::HTTPError)
- end
- end
-
- context "when bundler doesn't have permissions on Dir.tmpdir" do
- let(:response) { double(:response, :body => "") }
-
- it "Errno::EACCES is raised" do
- allow(Dir).to receive(:mktmpdir) { raise Errno::EACCES }
-
- expect do
- updater.update(local_path, remote_path)
- end.to raise_error(Bundler::PermissionError)
- end
- end
-end
diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb
deleted file mode 100644
index 1f4c1a0807..0000000000
--- a/spec/bundler/bundler/definition_spec.rb
+++ /dev/null
@@ -1,351 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/definition"
-
-RSpec.describe Bundler::Definition do
- describe "#lock" do
- before do
- allow(Bundler).to receive(:settings) { Bundler::Settings.new(".") }
- allow(Bundler::SharedHelpers).to receive(:find_gemfile) { Pathname.new("Gemfile") }
- allow(Bundler).to receive(:ui) { double("UI", :info => "", :debug => "") }
- end
- context "when it's not possible to write to the file" do
- subject { Bundler::Definition.new(nil, [], Bundler::SourceList.new, []) }
-
- it "raises an PermissionError with explanation" do
- allow(File).to receive(:open).and_call_original
- expect(File).to receive(:open).with("Gemfile.lock", "wb").
- and_raise(Errno::EACCES)
- expect { subject.lock("Gemfile.lock") }.
- to raise_error(Bundler::PermissionError, /Gemfile\.lock/)
- end
- end
- context "when a temporary resource access issue occurs" do
- subject { Bundler::Definition.new(nil, [], Bundler::SourceList.new, []) }
-
- it "raises a TemporaryResourceError with explanation" do
- allow(File).to receive(:open).and_call_original
- expect(File).to receive(:open).with("Gemfile.lock", "wb").
- and_raise(Errno::EAGAIN)
- expect { subject.lock("Gemfile.lock") }.
- to raise_error(Bundler::TemporaryResourceError, /temporarily unavailable/)
- end
- end
- end
-
- describe "detects changes" do
- it "for a path gem with changes", :bundler => "< 3" do
- build_lib "foo", "1.0", :path => lib_path("foo")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :path => "#{lib_path("foo")}"
- G
-
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "1.0"
- end
-
- bundle :install, :env => { "DEBUG" => "1" }
-
- expect(out).to match(/re-resolving dependencies/)
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo")}
- specs:
- foo (1.0)
- rack (= 1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "for a path gem with changes", :bundler => "3" do
- build_lib "foo", "1.0", :path => lib_path("foo")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :path => "#{lib_path("foo")}"
- G
-
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "1.0"
- end
-
- bundle :install, :env => { "DEBUG" => "1" }
-
- expect(out).to match(/re-resolving dependencies/)
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo")}
- specs:
- foo (1.0)
- rack (= 1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "for a path gem with deps and no changes" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "1.0"
- s.add_development_dependency "net-ssh", "1.0"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :path => "#{lib_path("foo")}"
- G
-
- bundle :check, :env => { "DEBUG" => "1" }
-
- expect(out).to match(/using resolution from the lockfile/)
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo")}
- specs:
- foo (1.0)
- rack (= 1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "for a locked gem for another platform" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "only_java", platform: :jruby
- G
-
- bundle "lock --add-platform java"
- bundle :check, :env => { "DEBUG" => "1" }
-
- expect(out).to match(/using resolution from the lockfile/)
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- only_java (1.1-java)
-
- PLATFORMS
- java
- #{lockfile_platforms}
-
- DEPENDENCIES
- only_java
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "for a rubygems gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo"
- G
-
- bundle :check, :env => { "DEBUG" => "1" }
-
- expect(out).to match(/using resolution from the lockfile/)
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- foo (1.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
- end
-
- describe "initialize" do
- context "gem version promoter" do
- context "with lockfile" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo"
- G
- end
-
- it "should get a locked specs list when updating all" do
- definition = Bundler::Definition.new(bundled_app("Gemfile.lock"), [], Bundler::SourceList.new, true)
- locked_specs = definition.gem_version_promoter.locked_specs
- expect(locked_specs.to_a.map(&:name)).to eq ["foo"]
- expect(definition.instance_variable_get("@locked_specs").empty?).to eq true
- end
- end
-
- context "without gemfile or lockfile" do
- it "should not attempt to parse empty lockfile contents" do
- definition = Bundler::Definition.new(nil, [], mock_source_list, true)
- expect(definition.gem_version_promoter.locked_specs.to_a).to eq []
- end
- end
-
- context "eager unlock" do
- let(:source_list) do
- Bundler::SourceList.new.tap do |source_list|
- source_list.global_rubygems_source = file_uri_for(gem_repo4)
- end
- end
-
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'isolated_owner'
-
- gem 'shared_owner_a'
- gem 'shared_owner_b'
- G
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo4)}
- specs:
- isolated_dep (2.0.1)
- isolated_owner (1.0.1)
- isolated_dep (~> 2.0)
- shared_dep (5.0.1)
- shared_owner_a (3.0.1)
- shared_dep (~> 5.0)
- shared_owner_b (4.0.1)
- shared_dep (~> 5.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- shared_owner_a
- shared_owner_b
- isolated_owner
-
- BUNDLED WITH
- 1.13.0
- L
- end
-
- it "should not eagerly unlock shared dependency with bundle install conservative updating behavior" do
- updated_deps_in_gemfile = [Bundler::Dependency.new("isolated_owner", ">= 0"),
- Bundler::Dependency.new("shared_owner_a", "3.0.2"),
- Bundler::Dependency.new("shared_owner_b", ">= 0")]
- unlock_hash_for_bundle_install = {}
- definition = Bundler::Definition.new(
- bundled_app("Gemfile.lock"),
- updated_deps_in_gemfile,
- source_list,
- unlock_hash_for_bundle_install
- )
- locked = definition.send(:converge_locked_specs).map(&:name)
- expect(locked).to include "shared_dep"
- end
-
- it "should not eagerly unlock shared dependency with bundle update conservative updating behavior" do
- updated_deps_in_gemfile = [Bundler::Dependency.new("isolated_owner", ">= 0"),
- Bundler::Dependency.new("shared_owner_a", ">= 0"),
- Bundler::Dependency.new("shared_owner_b", ">= 0")]
- definition = Bundler::Definition.new(
- bundled_app("Gemfile.lock"),
- updated_deps_in_gemfile,
- source_list,
- :gems => ["shared_owner_a"], :lock_shared_dependencies => true
- )
- locked = definition.send(:converge_locked_specs).map(&:name)
- expect(locked).to eq %w[isolated_dep isolated_owner shared_dep shared_owner_b]
- expect(locked.include?("shared_dep")).to be_truthy
- end
- end
- end
- end
-
- describe "find_resolved_spec" do
- it "with no platform set in SpecSet" do
- ss = Bundler::SpecSet.new([build_stub_spec("a", "1.0"), build_stub_spec("b", "1.0")])
- dfn = Bundler::Definition.new(nil, [], mock_source_list, true)
- dfn.instance_variable_set("@specs", ss)
- found = dfn.find_resolved_spec(build_spec("a", "0.9", "ruby").first)
- expect(found.name).to eq "a"
- expect(found.version.to_s).to eq "1.0"
- end
- end
-
- describe "find_indexed_specs" do
- it "with no platform set in indexed specs" do
- index = Bundler::Index.new
- %w[1.0.0 1.0.1 1.1.0].each {|v| index << build_stub_spec("foo", v) }
-
- dfn = Bundler::Definition.new(nil, [], mock_source_list, true)
- dfn.instance_variable_set("@index", index)
- found = dfn.find_indexed_specs(build_spec("foo", "0.9", "ruby").first)
- expect(found.length).to eq 3
- end
- end
-
- def build_stub_spec(name, version)
- Bundler::StubSpecification.new(name, version, nil, nil)
- end
-
- def mock_source_list
- Class.new do
- def all_sources
- []
- end
-
- def path_sources
- []
- end
-
- def rubygems_remotes
- []
- end
-
- def replace_sources!(arg)
- nil
- end
- end.new
- end
-end
diff --git a/spec/bundler/bundler/dep_proxy_spec.rb b/spec/bundler/bundler/dep_proxy_spec.rb
deleted file mode 100644
index 0f8d6b1076..0000000000
--- a/spec/bundler/bundler/dep_proxy_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::DepProxy do
- let(:dep) { Bundler::Dependency.new("rake", ">= 0") }
- subject { described_class.new(dep, Gem::Platform::RUBY) }
- let(:same) { subject }
- let(:other) { subject.dup }
- let(:different) { described_class.new(dep, Gem::Platform::JAVA) }
-
- describe "#eql?" do
- it { expect(subject.eql?(same)).to be true }
- it { expect(subject.eql?(other)).to be true }
- it { expect(subject.eql?(different)).to be false }
- it { expect(subject.eql?(nil)).to be false }
- it { expect(subject.eql?("foobar")).to be false }
- end
-
- describe "#hash" do
- it { expect(subject.hash).to eq(same.hash) }
- it { expect(subject.hash).to eq(other.hash) }
- end
-end
diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb
deleted file mode 100644
index 40739a431b..0000000000
--- a/spec/bundler/bundler/dsl_spec.rb
+++ /dev/null
@@ -1,302 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Dsl do
- before do
- @rubygems = double("rubygems")
- allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems }
- end
-
- describe "#git_source" do
- it "registers custom hosts" do
- subject.git_source(:example) {|repo_name| "git@git.example.com:#{repo_name}.git" }
- subject.git_source(:foobar) {|repo_name| "git@foobar.com:#{repo_name}.git" }
- subject.gem("dobry-pies", :example => "strzalek/dobry-pies")
- example_uri = "git@git.example.com:strzalek/dobry-pies.git"
- expect(subject.dependencies.first.source.uri).to eq(example_uri)
- end
-
- it "raises exception on invalid hostname" do
- expect do
- subject.git_source(:group) {|repo_name| "git@git.example.com:#{repo_name}.git" }
- end.to raise_error(Bundler::InvalidOption)
- end
-
- it "expects block passed" do
- expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption)
- end
-
- context "default hosts", :bundler => "2" do
- it "converts :github to URI using https" do
- subject.gem("sparks", :github => "indirect/sparks")
- github_uri = "https://github.com/indirect/sparks.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
-
- it "converts :github shortcut to URI using https" do
- subject.gem("sparks", :github => "rails")
- github_uri = "https://github.com/rails/rails.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
-
- it "converts numeric :gist to :git" do
- subject.gem("not-really-a-gem", :gist => 2_859_988)
- github_uri = "https://gist.github.com/2859988.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
-
- it "converts :gist to :git" do
- subject.gem("not-really-a-gem", :gist => "2859988")
- github_uri = "https://gist.github.com/2859988.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
-
- it "converts :bitbucket to :git" do
- subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
- bitbucket_uri = "https://mcorp@bitbucket.org/mcorp/flatlab-rails.git"
- expect(subject.dependencies.first.source.uri).to eq(bitbucket_uri)
- end
-
- it "converts 'mcorp' to 'mcorp/mcorp'" do
- subject.gem("not-really-a-gem", :bitbucket => "mcorp")
- bitbucket_uri = "https://mcorp@bitbucket.org/mcorp/mcorp.git"
- expect(subject.dependencies.first.source.uri).to eq(bitbucket_uri)
- end
- end
-
- context "default git sources", :bundler => "3" do
- it "has none" do
- expect(subject.instance_variable_get(:@git_sources)).to eq({})
- end
- end
- end
-
- describe "#method_missing" do
- it "raises an error for unknown DSL methods" do
- expect(Bundler).to receive(:read_file).with(bundled_app("Gemfile").to_s).
- and_return("unknown")
-
- error_msg = "There was an error parsing `Gemfile`: Undefined local variable or method `unknown' for Gemfile. Bundler cannot continue."
- expect { subject.eval_gemfile("Gemfile") }.
- to raise_error(Bundler::GemfileError, Regexp.new(error_msg))
- end
- end
-
- describe "#eval_gemfile" do
- it "handles syntax errors with a useful message" do
- expect(Bundler).to receive(:read_file).with(bundled_app("Gemfile").to_s).and_return("}")
- expect { subject.eval_gemfile("Gemfile") }.
- to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: (syntax error, unexpected tSTRING_DEND|(compile error - )?syntax error, unexpected '\}'). Bundler cannot continue./)
- end
-
- it "distinguishes syntax errors from evaluation errors" do
- expect(Bundler).to receive(:read_file).with(bundled_app("Gemfile").to_s).and_return(
- "ruby '2.1.5', :engine => 'ruby', :engine_version => '1.2.4'"
- )
- expect { subject.eval_gemfile("Gemfile") }.
- to raise_error(Bundler::GemfileError, /There was an error evaluating `Gemfile`: ruby_version must match the :engine_version for MRI/)
- end
- end
-
- describe "#gem" do
- [:ruby, :ruby_18, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25, :ruby_26, :mri, :mri_18, :mri_19,
- :mri_20, :mri_21, :mri_22, :mri_23, :mri_24, :mri_25, :mri_26, :jruby, :rbx, :truffleruby].each do |platform|
- it "allows #{platform} as a valid platform" do
- subject.gem("foo", :platform => platform)
- end
- end
-
- it "rejects invalid platforms" do
- expect { subject.gem("foo", :platform => :bogus) }.
- to raise_error(Bundler::GemfileError, /is not a valid platform/)
- end
-
- it "rejects empty gem name" do
- expect { subject.gem("") }.
- to raise_error(Bundler::GemfileError, /an empty gem name is not valid/)
- end
-
- it "rejects with a leading space in the name" do
- expect { subject.gem(" foo") }.
- to raise_error(Bundler::GemfileError, /' foo' is not a valid gem name because it contains whitespace/)
- end
-
- it "rejects with a trailing space in the name" do
- expect { subject.gem("foo ") }.
- to raise_error(Bundler::GemfileError, /'foo ' is not a valid gem name because it contains whitespace/)
- end
-
- it "rejects with a space in the gem name" do
- expect { subject.gem("fo o") }.
- to raise_error(Bundler::GemfileError, /'fo o' is not a valid gem name because it contains whitespace/)
- end
-
- it "rejects with a tab in the gem name" do
- expect { subject.gem("fo\to") }.
- to raise_error(Bundler::GemfileError, /'fo\to' is not a valid gem name because it contains whitespace/)
- end
-
- it "rejects with a newline in the gem name" do
- expect { subject.gem("fo\no") }.
- to raise_error(Bundler::GemfileError, /'fo\no' is not a valid gem name because it contains whitespace/)
- end
-
- it "rejects with a carriage return in the gem name" do
- expect { subject.gem("fo\ro") }.
- to raise_error(Bundler::GemfileError, /'fo\ro' is not a valid gem name because it contains whitespace/)
- end
-
- it "rejects with a form feed in the gem name" do
- expect { subject.gem("fo\fo") }.
- to raise_error(Bundler::GemfileError, /'fo\fo' is not a valid gem name because it contains whitespace/)
- end
-
- it "rejects symbols as gem name" do
- expect { subject.gem(:foo) }.
- to raise_error(Bundler::GemfileError, /You need to specify gem names as Strings. Use 'gem "foo"' instead/)
- end
-
- it "rejects branch option on non-git gems" do
- expect { subject.gem("foo", :branch => "test") }.
- to raise_error(Bundler::GemfileError, /The `branch` option for `gem 'foo'` is not allowed. Only gems with a git source can specify a branch/)
- end
-
- it "allows specifying a branch on git gems" do
- subject.gem("foo", :branch => "test", :git => "http://mytestrepo")
- dep = subject.dependencies.last
- expect(dep.name).to eq "foo"
- end
-
- it "allows specifying a branch on git gems with a git_source" do
- subject.git_source(:test_source) {|n| "https://github.com/#{n}" }
- subject.gem("foo", :branch => "test", :test_source => "bundler/bundler")
- dep = subject.dependencies.last
- expect(dep.name).to eq "foo"
- end
- end
-
- describe "#gemspec" do
- let(:spec) do
- Gem::Specification.new do |gem|
- gem.name = "example"
- gem.platform = platform
- end
- end
-
- before do
- allow(Dir).to receive(:[]).and_return(["spec_path"])
- allow(Bundler).to receive(:load_gemspec).with("spec_path").and_return(spec)
- allow(Bundler).to receive(:default_gemfile).and_return(Pathname.new("./Gemfile"))
- end
-
- context "with a ruby platform" do
- let(:platform) { "ruby" }
-
- it "keeps track of the ruby platforms in the dependency" do
- subject.gemspec
- expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::RUBY])
- end
- end
-
- context "with a jruby platform" do
- let(:platform) { "java" }
-
- it "keeps track of the jruby platforms in the dependency" do
- allow(Gem::Platform).to receive(:local).and_return(java)
- subject.gemspec
- expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::JAVA])
- end
- end
- end
-
- context "can bundle groups of gems with" do
- # git "https://github.com/rails/rails.git" do
- # gem "railties"
- # gem "action_pack"
- # gem "active_model"
- # end
- describe "#git" do
- it "from a single repo" do
- rails_gems = %w[railties action_pack active_model]
- subject.git "https://github.com/rails/rails.git" do
- rails_gems.each {|rails_gem| subject.send :gem, rails_gem }
- end
- expect(subject.dependencies.map(&:name)).to match_array rails_gems
- end
- end
-
- # github 'spree' do
- # gem 'spree_core'
- # gem 'spree_api'
- # gem 'spree_backend'
- # end
- describe "#github", :bundler => "< 3" do
- it "from github" do
- spree_gems = %w[spree_core spree_api spree_backend]
- subject.github "spree" do
- spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
- end
-
- subject.dependencies.each do |d|
- expect(d.source.uri).to eq("https://github.com/spree/spree.git")
- end
- end
- end
-
- describe "#github", :bundler => "2" do
- it "from github" do
- spree_gems = %w[spree_core spree_api spree_backend]
- subject.github "spree" do
- spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
- end
-
- subject.dependencies.each do |d|
- expect(d.source.uri).to eq("https://github.com/spree/spree.git")
- end
- end
- end
-
- describe "#github", :bundler => "3" do
- it "from github" do
- expect do
- spree_gems = %w[spree_core spree_api spree_backend]
- subject.github "spree" do
- spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
- end
- end.to raise_error(Bundler::DeprecatedError, /github method has been removed/)
- end
- end
- end
-
- describe "syntax errors" do
- it "will raise a Bundler::GemfileError" do
- gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
- expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
- to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`:( compile error -)? unknown regexp options - trg.+ Bundler cannot continue./)
- end
- end
-
- describe "Runtime errors" do
- it "will raise a Bundler::GemfileError" do
- gemfile "raise RuntimeError, 'foo'"
- expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
- to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: foo. Bundler cannot continue./i)
- end
- end
-
- describe "#with_source" do
- context "if there was a rubygem source already defined" do
- it "restores it after it's done" do
- other_source = double("other-source")
- allow(Bundler::Source::Rubygems).to receive(:new).and_return(other_source)
- allow(Bundler).to receive(:default_gemfile).and_return(Pathname.new("./Gemfile"))
-
- subject.source("https://other-source.org") do
- subject.gem("dobry-pies", :path => "foo")
- subject.gem("foo")
- end
-
- expect(subject.dependencies.last.source).to eq(other_source)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/endpoint_specification_spec.rb b/spec/bundler/bundler/endpoint_specification_spec.rb
deleted file mode 100644
index a9371f6617..0000000000
--- a/spec/bundler/bundler/endpoint_specification_spec.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::EndpointSpecification do
- let(:name) { "foo" }
- let(:version) { "1.0.0" }
- let(:platform) { Gem::Platform::RUBY }
- let(:dependencies) { [] }
- let(:metadata) { nil }
-
- subject(:spec) { described_class.new(name, version, platform, dependencies, metadata) }
-
- describe "#build_dependency" do
- let(:name) { "foo" }
- let(:requirement1) { "~> 1.1" }
- let(:requirement2) { ">= 1.1.7" }
-
- it "should return a Gem::Dependency" do
- expect(subject.send(:build_dependency, name, [requirement1, requirement2])).
- to eq(Gem::Dependency.new(name, requirement1, requirement2))
- end
-
- context "when an ArgumentError occurs" do
- before do
- allow(Gem::Dependency).to receive(:new).with(name, [requirement1, requirement2]) {
- raise ArgumentError.new("Some error occurred")
- }
- end
-
- it "should raise the original error" do
- expect { subject.send(:build_dependency, name, [requirement1, requirement2]) }.to raise_error(
- ArgumentError, "Some error occurred"
- )
- end
- end
-
- context "when there is an ill formed requirement" do
- before do
- allow(Gem::Dependency).to receive(:new).with(name, [requirement1, requirement2]) {
- raise ArgumentError.new("Ill-formed requirement [\"#<YAML::Syck::DefaultKey")
- }
- # Eliminate extra line break in rspec output due to `puts` in `#build_dependency`
- allow(subject).to receive(:puts) {}
- end
-
- it "should raise a Bundler::GemspecError with invalid gemspec message" do
- expect { subject.send(:build_dependency, name, [requirement1, requirement2]) }.to raise_error(
- Bundler::GemspecError, /Unfortunately, the gem foo \(1\.0\.0\) has an invalid gemspec/
- )
- end
- end
- end
-
- describe "#parse_metadata" do
- context "when the metadata has malformed requirements" do
- let(:metadata) { { "rubygems" => ">\n" } }
- it "raises a helpful error message" do
- expect { subject }.to raise_error(
- Bundler::GemspecError,
- a_string_including("There was an error parsing the metadata for the gem foo (1.0.0)").
- and(a_string_including('The metadata was {"rubygems"=>">\n"}'))
- )
- end
- end
- end
-
- it "supports equality comparison" do
- other_spec = described_class.new("bar", version, platform, dependencies, metadata)
- expect(spec).to eql(spec)
- expect(spec).to_not eql(other_spec)
- end
-end
diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb
deleted file mode 100644
index 7686fe386a..0000000000
--- a/spec/bundler/bundler/env_spec.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-# frozen_string_literal: true
-
-require "openssl"
-require "bundler/settings"
-
-RSpec.describe Bundler::Env do
- let(:git_proxy_stub) { Bundler::Source::Git::GitProxy.new(nil, nil, nil) }
-
- describe "#report" do
- it "prints the environment" do
- out = described_class.report
-
- expect(out).to include("Environment")
- expect(out).to include(Bundler::VERSION)
- expect(out).to include(Gem::VERSION)
- expect(out).to include(described_class.send(:ruby_version))
- expect(out).to include(described_class.send(:git_version))
- expect(out).to include(OpenSSL::OPENSSL_VERSION)
- end
-
- describe "rubygems paths" do
- it "prints gem home" do
- with_clear_paths("GEM_HOME", "/a/b/c") do
- out = described_class.report
- expect(out).to include("Gem Home /a/b/c")
- end
- end
-
- it "prints gem path" do
- with_clear_paths("GEM_PATH", "/a/b/c#{File::PATH_SEPARATOR}d/e/f") do
- out = described_class.report
- expect(out).to include("Gem Path /a/b/c#{File::PATH_SEPARATOR}d/e/f")
- end
- end
-
- it "prints user home" do
- with_clear_paths("HOME", "/a/b/c") do
- out = described_class.report
- expect(out).to include("User Home /a/b/c")
- end
- end
-
- it "prints user path" do
- with_clear_paths("HOME", "/a/b/c") do
- out = described_class.report
- expect(out).to include("User Path /a/b/c/.gem")
- end
- end
-
- it "prints bin dir" do
- with_clear_paths("GEM_HOME", "/a/b/c") do
- out = described_class.report
- expect(out).to include("Bin Dir /a/b/c/bin")
- end
- end
-
- private
-
- def with_clear_paths(env_var, env_value)
- old_env_var = ENV[env_var]
- ENV[env_var] = env_value
- Gem.clear_paths
- yield
- ensure
- ENV[env_var] = old_env_var
- end
- end
-
- context "when there is a Gemfile and a lockfile and print_gemfile is true" do
- before do
- gemfile "gem 'rack', '1.0.0'"
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 1.10.0
- L
- end
-
- let(:output) { described_class.report(:print_gemfile => true) }
-
- it "prints the Gemfile" do
- expect(output).to include("Gemfile")
- expect(output).to include("'rack', '1.0.0'")
- end
-
- it "prints the lockfile" do
- expect(output).to include("Gemfile.lock")
- expect(output).to include("rack (1.0.0)")
- end
- end
-
- context "when there no Gemfile and print_gemfile is true" do
- let(:output) { described_class.report(:print_gemfile => true) }
-
- it "prints the environment" do
- expect(output).to start_with("## Environment")
- end
- end
-
- context "when Gemfile contains a gemspec and print_gemspecs is true" do
- let(:gemspec) do
- strip_whitespace(<<-GEMSPEC)
- Gem::Specification.new do |gem|
- gem.name = "foo"
- gem.author = "Fumofu"
- end
- GEMSPEC
- end
-
- before do
- gemfile("gemspec")
-
- File.open(bundled_app.join("foo.gemspec"), "wb") do |f|
- f.write(gemspec)
- end
- end
-
- it "prints the gemspec" do
- output = described_class.report(:print_gemspecs => true)
-
- expect(output).to include("foo.gemspec")
- expect(output).to include(gemspec)
- end
- end
-
- context "when eval_gemfile is used" do
- it "prints all gemfiles" do
- create_file "other/Gemfile-other", "gem 'rack'"
- create_file "other/Gemfile", "eval_gemfile 'Gemfile-other'"
- create_file "Gemfile-alt", <<-G
- source "#{file_uri_for(gem_repo1)}"
- eval_gemfile "other/Gemfile"
- G
- gemfile "eval_gemfile #{File.expand_path("Gemfile-alt").dump}"
-
- output = described_class.report(:print_gemspecs => true)
- expect(output).to include(strip_whitespace(<<-ENV))
- ## Gemfile
-
- ### Gemfile
-
- ```ruby
- eval_gemfile #{File.expand_path("Gemfile-alt").dump}
- ```
-
- ### Gemfile-alt
-
- ```ruby
- source "#{file_uri_for(gem_repo1)}"
- eval_gemfile "other/Gemfile"
- ```
-
- ### other/Gemfile
-
- ```ruby
- eval_gemfile 'Gemfile-other'
- ```
-
- ### other/Gemfile-other
-
- ```ruby
- gem 'rack'
- ```
-
- ### Gemfile.lock
-
- ```
- <No #{bundled_app("Gemfile.lock")} found>
- ```
- ENV
- end
- end
-
- context "when the git version is OS specific" do
- it "includes OS specific information with the version number" do
- expect(git_proxy_stub).to receive(:git).with("--version").
- and_return("git version 1.2.3 (Apple Git-BS)")
- expect(Bundler::Source::Git::GitProxy).to receive(:new).and_return(git_proxy_stub)
-
- expect(described_class.report).to include("Git 1.2.3 (Apple Git-BS)")
- end
- end
- end
-
- describe ".version_of" do
- let(:parsed_version) { described_class.send(:version_of, "ruby") }
-
- it "strips version of new line characters" do
- expect(parsed_version).to_not end_with("\n")
- end
- end
-end
diff --git a/spec/bundler/bundler/environment_preserver_spec.rb b/spec/bundler/bundler/environment_preserver_spec.rb
deleted file mode 100644
index 530ca6f835..0000000000
--- a/spec/bundler/bundler/environment_preserver_spec.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::EnvironmentPreserver do
- let(:preserver) { described_class.new(env, ["foo"]) }
-
- describe "#backup" do
- let(:env) { { "foo" => "my-foo", "bar" => "my-bar" } }
- subject { preserver.backup }
-
- it "should create backup entries" do
- expect(subject["BUNDLER_ORIG_foo"]).to eq("my-foo")
- end
-
- it "should keep the original entry" do
- expect(subject["foo"]).to eq("my-foo")
- end
-
- it "should not create backup entries for unspecified keys" do
- expect(subject.key?("BUNDLER_ORIG_bar")).to eq(false)
- end
-
- it "should not affect the original env" do
- subject
- expect(env.keys.sort).to eq(%w[bar foo])
- end
-
- context "when a key is empty" do
- let(:env) { { "foo" => "" } }
-
- it "should not create backup entries" do
- expect(subject).not_to have_key "BUNDLER_ORIG_foo"
- end
- end
-
- context "when an original key is set" do
- let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "orig-foo" } }
-
- it "should keep the original value in the BUNDLER_ORIG_ variable" do
- expect(subject["BUNDLER_ORIG_foo"]).to eq("orig-foo")
- end
-
- it "should keep the variable" do
- expect(subject["foo"]).to eq("my-foo")
- end
- end
- end
-
- describe "#restore" do
- subject { preserver.restore }
-
- context "when an original key is set" do
- let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "orig-foo" } }
-
- it "should restore the original value" do
- expect(subject["foo"]).to eq("orig-foo")
- end
-
- it "should delete the backup value" do
- expect(subject.key?("BUNDLER_ORIG_foo")).to eq(false)
- end
- end
-
- context "when no original key is set" do
- let(:env) { { "foo" => "my-foo" } }
-
- it "should keep the current value" do
- expect(subject["foo"]).to eq("my-foo")
- end
- end
-
- context "when the original key is empty" do
- let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "" } }
-
- it "should keep the current value" do
- expect(subject["foo"]).to eq("my-foo")
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/fetcher/base_spec.rb b/spec/bundler/bundler/fetcher/base_spec.rb
deleted file mode 100644
index 02506591f3..0000000000
--- a/spec/bundler/bundler/fetcher/base_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Fetcher::Base do
- let(:downloader) { double(:downloader) }
- let(:remote) { double(:remote) }
- let(:display_uri) { "http://sample_uri.com" }
-
- class TestClass < described_class; end
-
- subject { TestClass.new(downloader, remote, display_uri) }
-
- describe "#initialize" do
- context "with the abstract Base class" do
- it "should raise an error" do
- expect { described_class.new(downloader, remote, display_uri) }.to raise_error(RuntimeError, "Abstract class")
- end
- end
-
- context "with a class that inherits the Base class" do
- it "should set the passed attributes" do
- expect(subject.downloader).to eq(downloader)
- expect(subject.remote).to eq(remote)
- expect(subject.display_uri).to eq("http://sample_uri.com")
- end
- end
- end
-
- describe "#remote_uri" do
- let(:remote_uri_obj) { double(:remote_uri_obj) }
-
- before { allow(remote).to receive(:uri).and_return(remote_uri_obj) }
-
- it "should return the remote's uri" do
- expect(subject.remote_uri).to eq(remote_uri_obj)
- end
- end
-
- describe "#fetch_uri" do
- let(:remote_uri_obj) { Bundler::URI("http://rubygems.org") }
-
- before { allow(subject).to receive(:remote_uri).and_return(remote_uri_obj) }
-
- context "when the remote uri's host is rubygems.org" do
- it "should create a copy of the remote uri with index.rubygems.org as the host" do
- fetched_uri = subject.fetch_uri
- expect(fetched_uri.host).to eq("index.rubygems.org")
- expect(fetched_uri).to_not be(remote_uri_obj)
- end
- end
-
- context "when the remote uri's host is not rubygems.org" do
- let(:remote_uri_obj) { Bundler::URI("http://otherhost.org") }
-
- it "should return the remote uri" do
- expect(subject.fetch_uri).to eq(Bundler::URI("http://otherhost.org"))
- end
- end
-
- it "memoizes the fetched uri" do
- expect(remote_uri_obj).to receive(:host).once
- 2.times { subject.fetch_uri }
- end
- end
-
- describe "#available?" do
- it "should return whether the api is available" do
- expect(subject.available?).to be_truthy
- end
- end
-
- describe "#api_fetcher?" do
- it "should return false" do
- expect(subject.api_fetcher?).to be_falsey
- end
- end
-end
diff --git a/spec/bundler/bundler/fetcher/compact_index_spec.rb b/spec/bundler/bundler/fetcher/compact_index_spec.rb
deleted file mode 100644
index c9419d3eb1..0000000000
--- a/spec/bundler/bundler/fetcher/compact_index_spec.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Fetcher::CompactIndex do
- let(:downloader) { double(:downloader) }
- let(:display_uri) { Bundler::URI("http://sampleuri.com") }
- let(:remote) { double(:remote, :cache_slug => "lsjdf", :uri => display_uri) }
- let(:compact_index) { described_class.new(downloader, remote, display_uri) }
-
- before do
- allow(compact_index).to receive(:log_specs) {}
- end
-
- describe "#specs_for_names" do
- let(:thread_list) { Thread.list.select {|thread| thread.status == "run" } }
- let(:thread_inspection) { thread_list.map {|th| " * #{th}:\n #{th.backtrace_locations.join("\n ")}" }.join("\n") }
-
- it "has only one thread open at the end of the run" do
- compact_index.specs_for_names(["lskdjf"])
-
- thread_count = thread_list.count
- expect(thread_count).to eq(1), "Expected 1 active thread after `#specs_for_names`, but found #{thread_count}. In particular, found:\n#{thread_inspection}"
- end
-
- it "calls worker#stop during the run" do
- expect_any_instance_of(Bundler::Worker).to receive(:stop).at_least(:once).and_call_original
-
- compact_index.specs_for_names(["lskdjf"])
- end
-
- describe "#available?" do
- before do
- allow(compact_index).to receive(:compact_index_client).
- and_return(double(:compact_index_client, :update_and_parse_checksums! => true))
- end
-
- it "returns true" do
- expect(compact_index).to be_available
- end
-
- context "when OpenSSL is not available" do
- before do
- allow(compact_index).to receive(:require).with("openssl").and_raise(LoadError)
- end
-
- it "returns true" do
- expect(compact_index).to be_available
- end
- end
-
- context "when OpenSSL is FIPS-enabled" do
- def remove_cached_md5_availability
- return unless Bundler::SharedHelpers.instance_variable_defined?(:@md5_available)
- Bundler::SharedHelpers.remove_instance_variable(:@md5_available)
- end
-
- before do
- remove_cached_md5_availability
- stub_const("OpenSSL::OPENSSL_FIPS", true)
- end
-
- after { remove_cached_md5_availability }
-
- context "when FIPS-mode is active" do
- before do
- allow(OpenSSL::Digest::MD5).to receive(:digest).
- and_raise(OpenSSL::Digest::DigestError)
- end
-
- it "returns false" do
- expect(compact_index).to_not be_available
- end
- end
-
- it "returns true" do
- expect(compact_index).to be_available
- end
- end
- end
-
- context "logging" do
- before { allow(compact_index).to receive(:log_specs).and_call_original }
-
- context "with debug on" do
- before do
- allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(true)
- end
-
- it "should log at info level" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with('Looking up gems ["lskdjf"]')
- compact_index.specs_for_names(["lskdjf"])
- end
- end
-
- context "with debug off" do
- before do
- allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(false)
- end
-
- it "should log at info level" do
- expect(Bundler).to receive_message_chain(:ui, :info).with(".", false)
- compact_index.specs_for_names(["lskdjf"])
- end
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/fetcher/dependency_spec.rb b/spec/bundler/bundler/fetcher/dependency_spec.rb
deleted file mode 100644
index 53249116cd..0000000000
--- a/spec/bundler/bundler/fetcher/dependency_spec.rb
+++ /dev/null
@@ -1,287 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Fetcher::Dependency do
- let(:downloader) { double(:downloader) }
- let(:remote) { double(:remote, :uri => Bundler::URI("http://localhost:5000")) }
- let(:display_uri) { "http://sample_uri.com" }
-
- subject { described_class.new(downloader, remote, display_uri) }
-
- describe "#available?" do
- let(:dependency_api_uri) { double(:dependency_api_uri) }
- let(:fetched_spec) { double(:fetched_spec) }
-
- before do
- allow(subject).to receive(:dependency_api_uri).and_return(dependency_api_uri)
- allow(downloader).to receive(:fetch).with(dependency_api_uri).and_return(fetched_spec)
- end
-
- it "should be truthy" do
- expect(subject.available?).to be_truthy
- end
-
- context "when there is no network access" do
- before do
- allow(downloader).to receive(:fetch).with(dependency_api_uri) {
- raise Bundler::Fetcher::NetworkDownError.new("Network Down Message")
- }
- end
-
- it "should raise an HTTPError with the original message" do
- expect { subject.available? }.to raise_error(Bundler::HTTPError, "Network Down Message")
- end
- end
-
- context "when authentication is required" do
- let(:remote_uri) { "http://remote_uri.org" }
-
- before do
- allow(downloader).to receive(:fetch).with(dependency_api_uri) {
- raise Bundler::Fetcher::AuthenticationRequiredError.new(remote_uri)
- }
- end
-
- it "should raise the original error" do
- expect { subject.available? }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
- %r{Authentication is required for http://remote_uri.org})
- end
- end
-
- context "when there is an http error" do
- before { allow(downloader).to receive(:fetch).with(dependency_api_uri) { raise Bundler::HTTPError.new } }
-
- it "should be falsey" do
- expect(subject.available?).to be_falsey
- end
- end
- end
-
- describe "#api_fetcher?" do
- it "should return true" do
- expect(subject.api_fetcher?).to be_truthy
- end
- end
-
- describe "#specs" do
- let(:gem_names) { %w[foo bar] }
- let(:full_dependency_list) { ["bar"] }
- let(:last_spec_list) { [["boulder", gem_version1, "ruby", resque]] }
- let(:fail_errors) { double(:fail_errors) }
- let(:bundler_retry) { double(:bundler_retry) }
- let(:gem_version1) { double(:gem_version1) }
- let(:resque) { double(:resque) }
- let(:remote_uri) { "http://remote-uri.org" }
-
- before do
- stub_const("Bundler::Fetcher::FAIL_ERRORS", fail_errors)
- allow(Bundler::Retry).to receive(:new).with("dependency api", fail_errors).and_return(bundler_retry)
- allow(bundler_retry).to receive(:attempts) {|&block| block.call }
- allow(subject).to receive(:log_specs) {}
- allow(subject).to receive(:remote_uri).and_return(remote_uri)
- allow(Bundler).to receive_message_chain(:ui, :debug?)
- allow(Bundler).to receive_message_chain(:ui, :info)
- allow(Bundler).to receive_message_chain(:ui, :debug)
- end
-
- context "when there are given gem names that are not in the full dependency list" do
- let(:spec_list) { [["top", gem_version2, "ruby", faraday]] }
- let(:deps_list) { [] }
- let(:dependency_specs) { [spec_list, deps_list] }
- let(:gem_version2) { double(:gem_version2) }
- let(:faraday) { double(:faraday) }
-
- before { allow(subject).to receive(:dependency_specs).with(["foo"]).and_return(dependency_specs) }
-
- it "should return a hash with the remote_uri and the list of specs" do
- expect(subject.specs(gem_names, full_dependency_list, last_spec_list)).to eq([
- ["top", gem_version2, "ruby", faraday],
- ["boulder", gem_version1, "ruby", resque],
- ])
- end
- end
-
- context "when all given gem names are in the full dependency list" do
- let(:gem_names) { ["foo"] }
- let(:full_dependency_list) { %w[foo bar] }
- let(:last_spec_list) { ["boulder"] }
-
- it "should return a hash with the remote_uri and the last spec list" do
- expect(subject.specs(gem_names, full_dependency_list, last_spec_list)).to eq(["boulder"])
- end
- end
-
- context "logging" do
- before { allow(subject).to receive(:log_specs).and_call_original }
-
- context "with debug on" do
- before do
- allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(true)
- allow(subject).to receive(:dependency_specs).with(["foo"]).and_return([[], []])
- end
-
- it "should log the query list at debug level" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("Query List: [\"foo\"]")
- expect(Bundler).to receive_message_chain(:ui, :debug).with("Query List: []")
- subject.specs(gem_names, full_dependency_list, last_spec_list)
- end
- end
-
- context "with debug off" do
- before do
- allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(false)
- allow(subject).to receive(:dependency_specs).with(["foo"]).and_return([[], []])
- end
-
- it "should log at info level" do
- expect(Bundler).to receive_message_chain(:ui, :info).with(".", false)
- expect(Bundler).to receive_message_chain(:ui, :info).with(".", false)
- subject.specs(gem_names, full_dependency_list, last_spec_list)
- end
- end
- end
-
- shared_examples_for "the error is properly handled" do
- it "should return nil" do
- expect(subject.specs(gem_names, full_dependency_list, last_spec_list)).to be_nil
- end
-
- context "debug logging is not on" do
- before { allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(false) }
-
- it "should log a new line to info" do
- expect(Bundler).to receive_message_chain(:ui, :info).with("")
- subject.specs(gem_names, full_dependency_list, last_spec_list)
- end
- end
- end
-
- shared_examples_for "the error suggests retrying with the full index" do
- it "should log the inability to fetch from API at debug level" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`")
- subject.specs(gem_names, full_dependency_list, last_spec_list)
- end
- end
-
- context "when an HTTPError occurs" do
- before { allow(subject).to receive(:dependency_specs) { raise Bundler::HTTPError.new } }
-
- it_behaves_like "the error is properly handled"
- it_behaves_like "the error suggests retrying with the full index"
- end
-
- context "when a GemspecError occurs" do
- before { allow(subject).to receive(:dependency_specs) { raise Bundler::GemspecError.new } }
-
- it_behaves_like "the error is properly handled"
- it_behaves_like "the error suggests retrying with the full index"
- end
-
- context "when a MarshalError occurs" do
- before { allow(subject).to receive(:dependency_specs) { raise Bundler::MarshalError.new } }
-
- it_behaves_like "the error is properly handled"
-
- it "should log the inability to fetch from API and mention retrying" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API, trying the full index")
- subject.specs(gem_names, full_dependency_list, last_spec_list)
- end
- end
- end
-
- describe "#dependency_specs" do
- let(:gem_names) { [%w[foo bar], %w[bundler rubocop]] }
- let(:gem_list) { double(:gem_list) }
- let(:formatted_specs_and_deps) { double(:formatted_specs_and_deps) }
-
- before do
- allow(subject).to receive(:unmarshalled_dep_gems).with(gem_names).and_return(gem_list)
- allow(subject).to receive(:get_formatted_specs_and_deps).with(gem_list).and_return(formatted_specs_and_deps)
- end
-
- it "should log the query list at debug level" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with(
- "Query Gemcutter Dependency Endpoint API: foo,bar,bundler,rubocop"
- )
- subject.dependency_specs(gem_names)
- end
-
- it "should return formatted specs and a unique list of dependencies" do
- expect(subject.dependency_specs(gem_names)).to eq(formatted_specs_and_deps)
- end
- end
-
- describe "#unmarshalled_dep_gems" do
- let(:gem_names) { [%w[foo bar], %w[bundler rubocop]] }
- let(:dep_api_uri) { double(:dep_api_uri) }
- let(:unmarshalled_gems) { double(:unmarshalled_gems) }
- let(:fetch_response) { double(:fetch_response, :body => double(:body)) }
- let(:rubygems_limit) { 50 }
-
- before { allow(subject).to receive(:dependency_api_uri).with(gem_names).and_return(dep_api_uri) }
-
- it "should fetch dependencies from RubyGems and unmarshal them" do
- expect(gem_names).to receive(:each_slice).with(rubygems_limit).and_call_original
- expect(downloader).to receive(:fetch).with(dep_api_uri).and_return(fetch_response)
- expect(Bundler).to receive(:load_marshal).with(fetch_response.body).and_return([unmarshalled_gems])
- expect(subject.unmarshalled_dep_gems(gem_names)).to eq([unmarshalled_gems])
- end
- end
-
- describe "#get_formatted_specs_and_deps" do
- let(:gem_list) do
- [
- {
- :dependencies => {
- "resque" => "req3,req4",
- },
- :name => "typhoeus",
- :number => "1.0.1",
- :platform => "ruby",
- },
- {
- :dependencies => {
- "faraday" => "req1,req2",
- },
- :name => "grape",
- :number => "2.0.2",
- :platform => "jruby",
- },
- ]
- end
-
- it "should return formatted specs and a unique list of dependencies" do
- spec_list, deps_list = subject.get_formatted_specs_and_deps(gem_list)
- expect(spec_list).to eq([["typhoeus", "1.0.1", "ruby", [["resque", ["req3,req4"]]]],
- ["grape", "2.0.2", "jruby", [["faraday", ["req1,req2"]]]]])
- expect(deps_list).to eq(%w[resque faraday])
- end
- end
-
- describe "#dependency_api_uri" do
- let(:uri) { Bundler::URI("http://gem-api.com") }
-
- context "with gem names" do
- let(:gem_names) { %w[foo bar bundler rubocop] }
-
- before { allow(subject).to receive(:fetch_uri).and_return(uri) }
-
- it "should return an api calling uri with the gems in the query" do
- expect(subject.dependency_api_uri(gem_names).to_s).to eq(
- "http://gem-api.com/api/v1/dependencies?gems=bar%2Cbundler%2Cfoo%2Crubocop"
- )
- end
- end
-
- context "with no gem names" do
- let(:gem_names) { [] }
-
- before { allow(subject).to receive(:fetch_uri).and_return(uri) }
-
- it "should return an api calling uri with no query" do
- expect(subject.dependency_api_uri(gem_names).to_s).to eq(
- "http://gem-api.com/api/v1/dependencies"
- )
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/fetcher/downloader_spec.rb b/spec/bundler/bundler/fetcher/downloader_spec.rb
deleted file mode 100644
index ba8451d9fa..0000000000
--- a/spec/bundler/bundler/fetcher/downloader_spec.rb
+++ /dev/null
@@ -1,269 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Fetcher::Downloader do
- let(:connection) { double(:connection) }
- let(:redirect_limit) { 5 }
- let(:uri) { Bundler::URI("http://www.uri-to-fetch.com/api/v2/endpoint") }
- let(:options) { double(:options) }
-
- subject { described_class.new(connection, redirect_limit) }
-
- describe "fetch" do
- let(:counter) { 0 }
- let(:httpv) { "1.1" }
- let(:http_response) { double(:response) }
-
- before do
- allow(subject).to receive(:request).with(uri, options).and_return(http_response)
- allow(http_response).to receive(:body).and_return("Body with info")
- end
-
- context "when the # requests counter is greater than the redirect limit" do
- let(:counter) { redirect_limit + 1 }
-
- it "should raise a Bundler::HTTPError specifying too many redirects" do
- expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::HTTPError, "Too many redirects")
- end
- end
-
- context "logging" do
- let(:http_response) { Net::HTTPSuccess.new("1.1", 200, "Success") }
-
- it "should log the HTTP response code and message to debug" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("HTTP 200 Success #{uri}")
- subject.fetch(uri, options, counter)
- end
- end
-
- context "when the request response is a Net::HTTPRedirection" do
- let(:http_response) { Net::HTTPRedirection.new(httpv, 308, "Moved") }
-
- before { http_response["location"] = "http://www.redirect-uri.com/api/v2/endpoint" }
-
- it "should try to fetch the redirect uri and iterate the # requests counter" do
- expect(subject).to receive(:fetch).with(Bundler::URI("http://www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original
- expect(subject).to receive(:fetch).with(Bundler::URI("http://www.redirect-uri.com/api/v2/endpoint"), options, 1)
- subject.fetch(uri, options, counter)
- end
-
- context "when the redirect uri and original uri are the same" do
- let(:uri) { Bundler::URI("ssh://username:password@www.uri-to-fetch.com/api/v2/endpoint") }
-
- before { http_response["location"] = "ssh://www.uri-to-fetch.com/api/v1/endpoint" }
-
- it "should set the same user and password for the redirect uri" do
- expect(subject).to receive(:fetch).with(Bundler::URI("ssh://username:password@www.uri-to-fetch.com/api/v2/endpoint"), options, 0).and_call_original
- expect(subject).to receive(:fetch).with(Bundler::URI("ssh://username:password@www.uri-to-fetch.com/api/v1/endpoint"), options, 1)
- subject.fetch(uri, options, counter)
- end
- end
- end
-
- context "when the request response is a Net::HTTPSuccess" do
- let(:http_response) { Net::HTTPSuccess.new("1.1", 200, "Success") }
-
- it "should return the response body" do
- expect(subject.fetch(uri, options, counter)).to eq(http_response)
- end
- end
-
- context "when the request response is a Net::HTTPRequestEntityTooLarge" do
- let(:http_response) { Net::HTTPRequestEntityTooLarge.new("1.1", 413, "Too Big") }
-
- it "should raise a Bundler::Fetcher::FallbackError with the response body" do
- expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::FallbackError, "Body with info")
- end
- end
-
- context "when the request response is a Net::HTTPUnauthorized" do
- let(:http_response) { Net::HTTPUnauthorized.new("1.1", 401, "Unauthorized") }
-
- it "should raise a Bundler::Fetcher::AuthenticationRequiredError with the uri host" do
- expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
- /Authentication is required for www.uri-to-fetch.com/)
- end
-
- context "when the there are credentials provided in the request" do
- let(:uri) { Bundler::URI("http://user:password@www.uri-to-fetch.com") }
-
- it "should raise a Bundler::Fetcher::BadAuthenticationError that doesn't contain the password" do
- expect { subject.fetch(uri, options, counter) }.
- to raise_error(Bundler::Fetcher::BadAuthenticationError, /Bad username or password for www.uri-to-fetch.com/)
- end
- end
- end
-
- context "when the request response is a Net::HTTPNotFound" do
- let(:http_response) { Net::HTTPNotFound.new("1.1", 404, "Not Found") }
-
- it "should raise a Bundler::Fetcher::FallbackError with Net::HTTPNotFound" do
- expect { subject.fetch(uri, options, counter) }.
- to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://www.uri-to-fetch.com/api/v2/endpoint")
- end
-
- context "when the there are credentials provided in the request" do
- let(:uri) { Bundler::URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") }
-
- it "should raise a Bundler::Fetcher::FallbackError that doesn't contain the password" do
- expect { subject.fetch(uri, options, counter) }.
- to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://username@www.uri-to-fetch.com/api/v2/endpoint")
- end
- end
- end
-
- context "when the request response is some other type" do
- let(:http_response) { Net::HTTPBadGateway.new("1.1", 500, "Fatal Error") }
-
- it "should raise a Bundler::HTTPError with the response class and body" do
- expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::HTTPError, "Net::HTTPBadGateway: Body with info")
- end
- end
- end
-
- describe "request" do
- let(:net_http_get) { double(:net_http_get) }
- let(:response) { double(:response) }
-
- before do
- allow(Net::HTTP::Get).to receive(:new).with("/api/v2/endpoint", options).and_return(net_http_get)
- allow(connection).to receive(:request).with(uri, net_http_get).and_return(response)
- end
-
- it "should log the HTTP GET request to debug" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("HTTP GET http://www.uri-to-fetch.com/api/v2/endpoint")
- subject.request(uri, options)
- end
-
- context "when there is a user provided in the request" do
- context "and there is also a password provided" do
- context "that contains cgi escaped characters" do
- let(:uri) { Bundler::URI("http://username:password%24@www.uri-to-fetch.com/api/v2/endpoint") }
-
- it "should request basic authentication with the username and password" do
- expect(net_http_get).to receive(:basic_auth).with("username", "password$")
- subject.request(uri, options)
- end
- end
-
- context "that is all unescaped characters" do
- let(:uri) { Bundler::URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") }
- it "should request basic authentication with the username and proper cgi compliant password" do
- expect(net_http_get).to receive(:basic_auth).with("username", "password")
- subject.request(uri, options)
- end
- end
- end
-
- context "and there is no password provided" do
- let(:uri) { Bundler::URI("http://username@www.uri-to-fetch.com/api/v2/endpoint") }
-
- it "should request basic authentication with just the user" do
- expect(net_http_get).to receive(:basic_auth).with("username", nil)
- subject.request(uri, options)
- end
- end
-
- context "that contains cgi escaped characters" do
- let(:uri) { Bundler::URI("http://username%24@www.uri-to-fetch.com/api/v2/endpoint") }
-
- it "should request basic authentication with the proper cgi compliant password user" do
- expect(net_http_get).to receive(:basic_auth).with("username$", nil)
- subject.request(uri, options)
- end
- end
- end
-
- context "when the request response causes a NoMethodError" do
- before { allow(connection).to receive(:request).with(uri, net_http_get) { raise NoMethodError.new(message) } }
-
- context "and the error message is about use_ssl=" do
- let(:message) { "undefined method 'use_ssl='" }
-
- it "should raise a LoadError about openssl" do
- expect { subject.request(uri, options) }.to raise_error(LoadError, "cannot load such file -- openssl")
- end
- end
-
- context "and the error message is not about use_ssl=" do
- let(:message) { "undefined method 'undefined_method_call'" }
-
- it "should raise the original NoMethodError" do
- expect { subject.request(uri, options) }.to raise_error(NoMethodError, "undefined method 'undefined_method_call'")
- end
- end
- end
-
- context "when the request response causes a OpenSSL::SSL::SSLError" do
- before { allow(connection).to receive(:request).with(uri, net_http_get) { raise OpenSSL::SSL::SSLError.new } }
-
- it "should raise a LoadError about openssl" do
- expect { subject.request(uri, options) }.to raise_error(Bundler::Fetcher::CertificateFailureError,
- %r{Could not verify the SSL certificate for http://www.uri-to-fetch.com/api/v2/endpoint})
- end
- end
-
- context "when the request response causes an error included in HTTP_ERRORS" do
- let(:message) { nil }
- let(:error) { RuntimeError.new(message) }
-
- before do
- stub_const("Bundler::Fetcher::HTTP_ERRORS", [RuntimeError])
- allow(connection).to receive(:request).with(uri, net_http_get) { raise error }
- end
-
- it "should trace log the error" do
- allow(Bundler).to receive_message_chain(:ui, :debug)
- expect(Bundler).to receive_message_chain(:ui, :trace).with(error)
- expect { subject.request(uri, options) }.to raise_error(Bundler::HTTPError)
- end
-
- context "when error message is about the host being down" do
- let(:message) { "host down: http://www.uri-to-fetch.com" }
-
- it "should raise a Bundler::Fetcher::NetworkDownError" do
- expect { subject.request(uri, options) }.to raise_error(Bundler::Fetcher::NetworkDownError,
- /Could not reach host www.uri-to-fetch.com/)
- end
- end
-
- context "when error message is about getaddrinfo issues" do
- let(:message) { "getaddrinfo: nodename nor servname provided for http://www.uri-to-fetch.com" }
-
- it "should raise a Bundler::Fetcher::NetworkDownError" do
- expect { subject.request(uri, options) }.to raise_error(Bundler::Fetcher::NetworkDownError,
- /Could not reach host www.uri-to-fetch.com/)
- end
- end
-
- context "when error message is about neither host down or getaddrinfo" do
- let(:message) { "other error about network" }
-
- it "should raise a Bundler::HTTPError" do
- expect { subject.request(uri, options) }.to raise_error(Bundler::HTTPError,
- "Network error while fetching http://www.uri-to-fetch.com/api/v2/endpoint (other error about network)")
- end
-
- context "when the there are credentials provided in the request" do
- let(:uri) { Bundler::URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") }
- before do
- allow(net_http_get).to receive(:basic_auth).with("username", "password")
- end
-
- it "should raise a Bundler::HTTPError that doesn't contain the password" do
- expect { subject.request(uri, options) }.to raise_error(Bundler::HTTPError,
- "Network error while fetching http://username@www.uri-to-fetch.com/api/v2/endpoint (other error about network)")
- end
- end
- end
-
- context "when error message is about no route to host" do
- let(:message) { "Failed to open TCP connection to www.uri-to-fetch.com:443 " }
-
- it "should raise a Bundler::Fetcher::HTTPError" do
- expect { subject.request(uri, options) }.to raise_error(Bundler::HTTPError,
- "Network error while fetching http://www.uri-to-fetch.com/api/v2/endpoint (#{message})")
- end
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/fetcher/index_spec.rb b/spec/bundler/bundler/fetcher/index_spec.rb
deleted file mode 100644
index 5ecd7d9e05..0000000000
--- a/spec/bundler/bundler/fetcher/index_spec.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Fetcher::Index do
- let(:downloader) { nil }
- let(:remote) { nil }
- let(:display_uri) { "http://sample_uri.com" }
- let(:rubygems) { double(:rubygems) }
- let(:gem_names) { %w[foo bar] }
-
- subject { described_class.new(downloader, remote, display_uri) }
-
- before { allow(Bundler).to receive(:rubygems).and_return(rubygems) }
-
- it "fetches and returns the list of remote specs" do
- expect(rubygems).to receive(:fetch_all_remote_specs) { nil }
- subject.specs(gem_names)
- end
-
- context "error handling" do
- shared_examples_for "the error is properly handled" do
- let(:remote_uri) { Bundler::URI("http://remote-uri.org") }
- before do
- allow(subject).to receive(:remote_uri).and_return(remote_uri)
- end
-
- context "when certificate verify failed" do
- let(:error_message) { "certificate verify failed" }
-
- it "should raise a Bundler::Fetcher::CertificateFailureError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::CertificateFailureError,
- %r{Could not verify the SSL certificate for http://sample_uri.com})
- end
- end
-
- context "when a 401 response occurs" do
- let(:error_message) { "401" }
-
- before do
- allow(remote_uri).to receive(:userinfo).and_return(userinfo)
- end
-
- context "and there was userinfo" do
- let(:userinfo) { double(:userinfo) }
-
- it "should raise a Bundler::Fetcher::BadAuthenticationError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::BadAuthenticationError,
- %r{Bad username or password for http://remote-uri.org})
- end
- end
-
- context "and there was no userinfo" do
- let(:userinfo) { nil }
-
- it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
- %r{Authentication is required for http://remote-uri.org})
- end
- end
- end
-
- context "when a 403 response occurs" do
- let(:error_message) { "403" }
-
- before do
- allow(remote_uri).to receive(:userinfo).and_return(userinfo)
- end
-
- context "and there was userinfo" do
- let(:userinfo) { double(:userinfo) }
-
- it "should raise a Bundler::Fetcher::BadAuthenticationError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::BadAuthenticationError,
- %r{Bad username or password for http://remote-uri.org})
- end
- end
-
- context "and there was no userinfo" do
- let(:userinfo) { nil }
-
- it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
- %r{Authentication is required for http://remote-uri.org})
- end
- end
- end
-
- context "any other message is returned" do
- let(:error_message) { "You get an error, you get an error!" }
-
- before { allow(Bundler).to receive(:ui).and_return(double(:trace => nil)) }
-
- it "should raise a Bundler::HTTPError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::HTTPError, "Could not fetch specs from http://sample_uri.com")
- end
- end
- end
-
- context "when a Gem::RemoteFetcher::FetchError occurs" do
- before { allow(rubygems).to receive(:fetch_all_remote_specs) { raise Gem::RemoteFetcher::FetchError.new(error_message, nil) } }
-
- it_behaves_like "the error is properly handled"
- end
-
- context "when a OpenSSL::SSL::SSLError occurs" do
- before { allow(rubygems).to receive(:fetch_all_remote_specs) { raise OpenSSL::SSL::SSLError.new(error_message) } }
-
- it_behaves_like "the error is properly handled"
- end
-
- context "when a Net::HTTPFatalError occurs" do
- before { allow(rubygems).to receive(:fetch_all_remote_specs) { raise Net::HTTPFatalError.new(error_message, 404) } }
-
- it_behaves_like "the error is properly handled"
- end
- end
-end
diff --git a/spec/bundler/bundler/fetcher_spec.rb b/spec/bundler/bundler/fetcher_spec.rb
deleted file mode 100644
index 539179db43..0000000000
--- a/spec/bundler/bundler/fetcher_spec.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/fetcher"
-
-RSpec.describe Bundler::Fetcher do
- let(:uri) { Bundler::URI("https://example.com") }
- let(:remote) { double("remote", :uri => uri, :original_uri => nil) }
-
- subject(:fetcher) { Bundler::Fetcher.new(remote) }
-
- before do
- allow(Bundler).to receive(:root) { Pathname.new("root") }
- end
-
- describe "#connection" do
- context "when Gem.configuration doesn't specify http_proxy" do
- it "specify no http_proxy" do
- expect(fetcher.http_proxy).to be_nil
- end
- it "consider environment vars when determine proxy" do
- with_env_vars("HTTP_PROXY" => "http://proxy-example.com") do
- expect(fetcher.http_proxy).to match("http://proxy-example.com")
- end
- end
- end
- context "when Gem.configuration specifies http_proxy " do
- let(:proxy) { "http://proxy-example2.com" }
- before do
- allow(Bundler.rubygems.configuration).to receive(:[]).with(:http_proxy).and_return(proxy)
- end
- it "consider Gem.configuration when determine proxy" do
- expect(fetcher.http_proxy).to match("http://proxy-example2.com")
- end
- it "consider Gem.configuration when determine proxy" do
- with_env_vars("HTTP_PROXY" => "http://proxy-example.com") do
- expect(fetcher.http_proxy).to match("http://proxy-example2.com")
- end
- end
- context "when the proxy is :no_proxy" do
- let(:proxy) { :no_proxy }
- it "does not set a proxy" do
- expect(fetcher.http_proxy).to be_nil
- end
- end
- end
-
- context "when a rubygems source mirror is set" do
- let(:orig_uri) { Bundler::URI("http://zombo.com") }
- let(:remote_with_mirror) do
- double("remote", :uri => uri, :original_uri => orig_uri, :anonymized_uri => uri)
- end
-
- let(:fetcher) { Bundler::Fetcher.new(remote_with_mirror) }
-
- it "sets the 'X-Gemfile-Source' header containing the original source" do
- expect(
- fetcher.send(:connection).override_headers["X-Gemfile-Source"]
- ).to eq("http://zombo.com")
- end
- end
-
- context "when there is no rubygems source mirror set" do
- let(:remote_no_mirror) do
- double("remote", :uri => uri, :original_uri => nil, :anonymized_uri => uri)
- end
-
- let(:fetcher) { Bundler::Fetcher.new(remote_no_mirror) }
-
- it "does not set the 'X-Gemfile-Source' header" do
- expect(fetcher.send(:connection).override_headers["X-Gemfile-Source"]).to be_nil
- end
- end
-
- context "when there are proxy environment variable(s) set" do
- it "consider http_proxy" do
- with_env_vars("HTTP_PROXY" => "http://proxy-example3.com") do
- expect(fetcher.http_proxy).to match("http://proxy-example3.com")
- end
- end
- it "consider no_proxy" do
- with_env_vars("HTTP_PROXY" => "http://proxy-example4.com", "NO_PROXY" => ".example.com,.example.net") do
- expect(
- fetcher.send(:connection).no_proxy
- ).to eq([".example.com", ".example.net"])
- end
- end
- end
-
- context "when no ssl configuration is set" do
- it "no cert" do
- expect(fetcher.send(:connection).cert).to be_nil
- expect(fetcher.send(:connection).key).to be_nil
- end
- end
-
- context "when bunder ssl ssl configuration is set" do
- before do
- cert = File.join(Spec::Path.tmpdir, "cert")
- File.open(cert, "w") {|f| f.write "PEM" }
- allow(Bundler.settings).to receive(:[]).and_return(nil)
- allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return(cert)
- expect(OpenSSL::X509::Certificate).to receive(:new).with("PEM").and_return("cert")
- expect(OpenSSL::PKey::RSA).to receive(:new).with("PEM").and_return("key")
- end
- after do
- FileUtils.rm File.join(Spec::Path.tmpdir, "cert")
- end
- it "use bundler configuration" do
- expect(fetcher.send(:connection).cert).to eq("cert")
- expect(fetcher.send(:connection).key).to eq("key")
- end
- end
-
- context "when gem ssl configuration is set" do
- before do
- allow(Bundler.rubygems.configuration).to receive_messages(
- :http_proxy => nil,
- :ssl_client_cert => "cert",
- :ssl_ca_cert => "ca"
- )
- expect(File).to receive(:read).and_return("")
- expect(OpenSSL::X509::Certificate).to receive(:new).and_return("cert")
- expect(OpenSSL::PKey::RSA).to receive(:new).and_return("key")
- store = double("ca store")
- expect(store).to receive(:add_file)
- expect(OpenSSL::X509::Store).to receive(:new).and_return(store)
- end
- it "use gem configuration" do
- expect(fetcher.send(:connection).cert).to eq("cert")
- expect(fetcher.send(:connection).key).to eq("key")
- end
- end
- end
-
- describe "#user_agent" do
- it "builds user_agent with current ruby version and Bundler settings" do
- allow(Bundler.settings).to receive(:all).and_return(%w[foo bar])
- expect(fetcher.user_agent).to match(%r{bundler/(\d.)})
- expect(fetcher.user_agent).to match(%r{rubygems/(\d.)})
- expect(fetcher.user_agent).to match(%r{ruby/(\d.)})
- expect(fetcher.user_agent).to match(%r{options/foo,bar})
- end
-
- describe "include CI information" do
- it "from one CI" do
- with_env_vars("JENKINS_URL" => "foo") do
- ci_part = fetcher.user_agent.split(" ").find {|x| x.start_with?("ci/") }
- expect(ci_part).to match("jenkins")
- end
- end
-
- it "from many CI" do
- with_env_vars("TRAVIS" => "foo", "CI_NAME" => "my_ci") do
- ci_part = fetcher.user_agent.split(" ").find {|x| x.start_with?("ci/") }
- expect(ci_part).to match("travis")
- expect(ci_part).to match("my_ci")
- end
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/friendly_errors_spec.rb b/spec/bundler/bundler/friendly_errors_spec.rb
deleted file mode 100644
index e9189b0514..0000000000
--- a/spec/bundler/bundler/friendly_errors_spec.rb
+++ /dev/null
@@ -1,255 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler"
-require "bundler/friendly_errors"
-require "cgi"
-
-RSpec.describe Bundler, "friendly errors" do
- context "with invalid YAML in .gemrc" do
- before do
- File.open(Gem.configuration.config_file_name, "w") do |f|
- f.write "invalid: yaml: hah"
- end
- end
-
- after do
- FileUtils.rm(Gem.configuration.config_file_name)
- end
-
- it "reports a relevant friendly error message" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle :install, :env => { "DEBUG" => "true" }
-
- expect(err).to include("Failed to load #{home(".gemrc")}")
- expect(exitstatus).to eq(0) if exitstatus
- end
- end
-
- it "calls log_error in case of exception" do
- exception = Exception.new
- expect(Bundler::FriendlyErrors).to receive(:exit_status).with(exception).and_return(1)
- expect do
- Bundler.with_friendly_errors do
- raise exception
- end
- end.to raise_error(SystemExit)
- end
-
- it "calls exit_status on exception" do
- exception = Exception.new
- expect(Bundler::FriendlyErrors).to receive(:log_error).with(exception)
- expect do
- Bundler.with_friendly_errors do
- raise exception
- end
- end.to raise_error(SystemExit)
- end
-
- describe "#log_error" do
- shared_examples "Bundler.ui receive error" do |error, message|
- it "" do
- expect(Bundler.ui).to receive(:error).with(message || error.message)
- Bundler::FriendlyErrors.log_error(error)
- end
- end
-
- shared_examples "Bundler.ui receive trace" do |error|
- it "" do
- expect(Bundler.ui).to receive(:trace).with(error)
- Bundler::FriendlyErrors.log_error(error)
- end
- end
-
- context "YamlSyntaxError" do
- it_behaves_like "Bundler.ui receive error", Bundler::YamlSyntaxError.new(StandardError.new, "sample_message")
-
- it "Bundler.ui receive trace" do
- std_error = StandardError.new
- exception = Bundler::YamlSyntaxError.new(std_error, "sample_message")
- expect(Bundler.ui).to receive(:trace).with(std_error)
- Bundler::FriendlyErrors.log_error(exception)
- end
- end
-
- context "Dsl::DSLError, GemspecError" do
- it_behaves_like "Bundler.ui receive error", Bundler::Dsl::DSLError.new("description", "dsl_path", "backtrace")
- it_behaves_like "Bundler.ui receive error", Bundler::GemspecError.new
- end
-
- context "GemRequireError" do
- let(:orig_error) { StandardError.new }
- let(:error) { Bundler::GemRequireError.new(orig_error, "sample_message") }
-
- before do
- allow(orig_error).to receive(:backtrace).and_return([])
- end
-
- it "Bundler.ui receive error" do
- expect(Bundler.ui).to receive(:error).with(error.message)
- Bundler::FriendlyErrors.log_error(error)
- end
-
- it "writes to Bundler.ui.trace" do
- expect(Bundler.ui).to receive(:trace).with(orig_error)
- Bundler::FriendlyErrors.log_error(error)
- end
- end
-
- context "BundlerError" do
- it "Bundler.ui receive error" do
- error = Bundler::BundlerError.new
- expect(Bundler.ui).to receive(:error).with(error.message, :wrap => true)
- Bundler::FriendlyErrors.log_error(error)
- end
- it_behaves_like "Bundler.ui receive trace", Bundler::BundlerError.new
- end
-
- context "Thor::Error" do
- it_behaves_like "Bundler.ui receive error", Bundler::Thor::Error.new
- end
-
- context "LoadError" do
- let(:error) { LoadError.new("cannot load such file -- openssl") }
-
- it "Bundler.ui receive error" do
- expect(Bundler.ui).to receive(:error).with("\nCould not load OpenSSL.")
- Bundler::FriendlyErrors.log_error(error)
- end
-
- it "Bundler.ui receive warn" do
- expect(Bundler.ui).to receive(:warn).with(any_args, :wrap => true)
- Bundler::FriendlyErrors.log_error(error)
- end
-
- it "Bundler.ui receive trace" do
- expect(Bundler.ui).to receive(:trace).with(error)
- Bundler::FriendlyErrors.log_error(error)
- end
- end
-
- context "Interrupt" do
- it "Bundler.ui receive error" do
- expect(Bundler.ui).to receive(:error).with("\nQuitting...")
- Bundler::FriendlyErrors.log_error(Interrupt.new)
- end
- it_behaves_like "Bundler.ui receive trace", Interrupt.new
- end
-
- context "Gem::InvalidSpecificationException" do
- it "Bundler.ui receive error" do
- error = Gem::InvalidSpecificationException.new
- expect(Bundler.ui).to receive(:error).with(error.message, :wrap => true)
- Bundler::FriendlyErrors.log_error(error)
- end
- end
-
- context "SystemExit" do
- # Does nothing
- end
-
- context "Java::JavaLang::OutOfMemoryError" do
- module Java
- module JavaLang
- class OutOfMemoryError < StandardError; end
- end
- end
-
- it "Bundler.ui receive error" do
- error = Java::JavaLang::OutOfMemoryError.new
- expect(Bundler.ui).to receive(:error).with(/JVM has run out of memory/)
- Bundler::FriendlyErrors.log_error(error)
- end
- end
-
- context "unexpected error" do
- it "calls request_issue_report_for with error" do
- error = StandardError.new
- expect(Bundler::FriendlyErrors).to receive(:request_issue_report_for).with(error)
- Bundler::FriendlyErrors.log_error(error)
- end
- end
- end
-
- describe "#exit_status" do
- it "calls status_code for BundlerError" do
- error = Bundler::BundlerError.new
- expect(error).to receive(:status_code).and_return("sample_status_code")
- expect(Bundler::FriendlyErrors.exit_status(error)).to eq("sample_status_code")
- end
-
- it "returns 15 for Thor::Error" do
- error = Bundler::Thor::Error.new
- expect(Bundler::FriendlyErrors.exit_status(error)).to eq(15)
- end
-
- it "calls status for SystemExit" do
- error = SystemExit.new
- expect(error).to receive(:status).and_return("sample_status")
- expect(Bundler::FriendlyErrors.exit_status(error)).to eq("sample_status")
- end
-
- it "returns 1 in other cases" do
- error = StandardError.new
- expect(Bundler::FriendlyErrors.exit_status(error)).to eq(1)
- end
- end
-
- describe "#request_issue_report_for" do
- it "calls relevant methods for Bundler.ui" do
- expect(Bundler.ui).to receive(:info)
- expect(Bundler.ui).to receive(:error)
- expect(Bundler.ui).to receive(:warn)
- Bundler::FriendlyErrors.request_issue_report_for(StandardError.new)
- end
-
- it "includes error class, message and backlog" do
- error = StandardError.new
- allow(Bundler::FriendlyErrors).to receive(:issues_url).and_return("")
-
- expect(error).to receive(:class).at_least(:once)
- expect(error).to receive(:message).at_least(:once)
- expect(error).to receive(:backtrace).at_least(:once)
- Bundler::FriendlyErrors.request_issue_report_for(error)
- end
- end
-
- describe "#issues_url" do
- it "generates a search URL for the exception message" do
- exception = Exception.new("Exception message")
-
- expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=Exception+message&type=Issues")
- end
-
- it "generates a search URL for only the first line of a multi-line exception message" do
- exception = Exception.new(<<END)
-First line of the exception message
-Second line of the exception message
-END
-
- expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=First+line+of+the+exception+message&type=Issues")
- end
-
- it "generates the url without colons" do
- exception = Exception.new(<<END)
-Exception ::: with ::: colons :::
-END
- issues_url = Bundler::FriendlyErrors.issues_url(exception)
- expect(issues_url).not_to include("%3A")
- expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Exception with colons ")}&type=Issues")
- end
-
- it "removes information after - for Errono::EACCES" do
- exception = Exception.new(<<END)
-Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/foo/bar/
-END
- allow(exception).to receive(:is_a?).with(Errno).and_return(true)
- issues_url = Bundler::FriendlyErrors.issues_url(exception)
- expect(issues_url).not_to include("/Users/foo/bar")
- expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Errno EACCES Permission denied @ dir_s_mkdir ")}&type=Issues")
- end
- end
-end
diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb
deleted file mode 100644
index 29e10d64f8..0000000000
--- a/spec/bundler/bundler/gem_helper_spec.rb
+++ /dev/null
@@ -1,348 +0,0 @@
-# frozen_string_literal: true
-
-require "rake"
-require "bundler/gem_helper"
-
-RSpec.describe Bundler::GemHelper do
- let(:app_name) { "lorem__ipsum" }
- let(:app_path) { bundled_app app_name }
- let(:app_gemspec_path) { app_path.join("#{app_name}.gemspec") }
-
- before(:each) do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
- bundle "gem #{app_name}"
- prepare_gemspec(app_gemspec_path)
- end
-
- context "determining gemspec" do
- subject { Bundler::GemHelper.new(app_path) }
-
- context "fails" do
- it "when there is no gemspec" do
- FileUtils.rm app_gemspec_path
- expect { subject }.to raise_error(/Unable to determine name/)
- end
-
- it "when there are two gemspecs and the name isn't specified" do
- FileUtils.touch app_path.join("#{app_name}-2.gemspec")
- expect { subject }.to raise_error(/Unable to determine name/)
- end
- end
-
- context "interpolates the name" do
- it "when there is only one gemspec" do
- expect(subject.gemspec.name).to eq(app_name)
- end
-
- it "for a hidden gemspec" do
- FileUtils.mv app_gemspec_path, app_path.join(".gemspec")
- expect(subject.gemspec.name).to eq(app_name)
- end
- end
-
- it "handles namespaces and converts them to CamelCase" do
- bundle "gem #{app_name}-foo_bar"
- underscore_path = bundled_app "#{app_name}-foo_bar"
-
- lib = underscore_path.join("lib/#{app_name}/foo_bar.rb").read
- expect(lib).to include("module LoremIpsum")
- expect(lib).to include("module FooBar")
- end
- end
-
- context "gem management" do
- def mock_confirm_message(message)
- expect(Bundler.ui).to receive(:confirm).with(message)
- end
-
- def mock_build_message(name, version)
- message = "#{name} #{version} built to pkg/#{name}-#{version}.gem."
- mock_confirm_message message
- end
-
- subject! { Bundler::GemHelper.new(app_path) }
- let(:app_version) { "0.1.0" }
- let(:app_gem_dir) { app_path.join("pkg") }
- let(:app_gem_path) { app_gem_dir.join("#{app_name}-#{app_version}.gem") }
- let(:app_gemspec_content) { File.read(app_gemspec_path) }
-
- before(:each) do
- content = app_gemspec_content.gsub("TODO: ", "")
- content.sub!(/homepage\s+= ".*"/, 'homepage = ""')
- content.gsub!(/spec\.metadata.+\n/, "")
- File.open(app_gemspec_path, "w") {|file| file << content }
- end
-
- it "uses a shell UI for output" do
- expect(Bundler.ui).to be_a(Bundler::UI::Shell)
- end
-
- describe "#install" do
- let!(:rake_application) { Rake.application }
-
- before(:each) do
- Rake.application = Rake::Application.new
- end
-
- after(:each) do
- Rake.application = rake_application
- end
-
- context "defines Rake tasks" do
- let(:task_names) do
- %w[build install release release:guard_clean
- release:source_control_push release:rubygem_push]
- end
-
- context "before installation" do
- it "raises an error with appropriate message" do
- task_names.each do |name|
- expect { Rake.application[name] }.
- to raise_error(/^Don't know how to build task '#{name}'/)
- end
- end
- end
-
- context "after installation" do
- before do
- subject.install
- end
-
- it "adds Rake tasks successfully" do
- task_names.each do |name|
- expect { Rake.application[name] }.not_to raise_error
- expect(Rake.application[name]).to be_instance_of Rake::Task
- end
- end
-
- it "provides a way to access the gemspec object" do
- expect(subject.gemspec.name).to eq(app_name)
- end
- end
- end
- end
-
- describe "#build_gem" do
- context "when build failed" do
- it "raises an error with appropriate message" do
- # break the gemspec by adding back the TODOs
- File.open(app_gemspec_path, "w") {|file| file << app_gemspec_content }
- expect { subject.build_gem }.to raise_error(/TODO/)
- end
- end
-
- context "when build was successful" do
- it "creates .gem file" do
- mock_build_message app_name, app_version
- subject.build_gem
- expect(app_gem_path).to exist
- end
- end
- end
-
- describe "#install_gem" do
- context "when installation was successful" do
- it "gem is installed" do
- mock_build_message app_name, app_version
- mock_confirm_message "#{app_name} (#{app_version}) installed."
- subject.install_gem(nil, :local)
- expect(app_gem_path).to exist
- gem_command! :list
- expect(out).to include("#{app_name} (#{app_version})")
- end
- end
-
- context "when installation fails" do
- it "raises an error with appropriate message" do
- # create empty gem file in order to simulate install failure
- allow(subject).to receive(:build_gem) do
- FileUtils.mkdir_p(app_gem_dir)
- FileUtils.touch app_gem_path
- app_gem_path
- end
- expect { subject.install_gem }.to raise_error(/Couldn't install gem/)
- end
- end
- end
-
- describe "rake release" do
- let!(:rake_application) { Rake.application }
-
- before(:each) do
- Rake.application = Rake::Application.new
- subject.install
- end
-
- after(:each) do
- Rake.application = rake_application
- end
-
- before do
- Dir.chdir(app_path) do
- `git init`
- `git config user.email "you@example.com"`
- `git config user.name "name"`
- `git config commit.gpgsign false`
- `git config push.default simple`
- end
-
- # silence messages
- allow(Bundler.ui).to receive(:confirm)
- allow(Bundler.ui).to receive(:error)
- end
-
- context "fails" do
- it "when there are unstaged files" do
- expect { Rake.application["release"].invoke }.
- to raise_error("There are files that need to be committed first.")
- end
-
- it "when there are uncommitted files" do
- Dir.chdir(app_path) { `git add .` }
- expect { Rake.application["release"].invoke }.
- to raise_error("There are files that need to be committed first.")
- end
-
- it "when there is no git remote" do
- Dir.chdir(app_path) { `git commit -a -m "initial commit"` }
- expect { Rake.application["release"].invoke }.to raise_error(RuntimeError)
- end
- end
-
- context "succeeds" do
- let(:repo) { build_git("foo", :bare => true) }
-
- before do
- Dir.chdir(app_path) do
- sys_exec("git remote add origin #{file_uri_for(repo.path)}")
- sys_exec('git commit -a -m "initial commit"')
- end
- end
-
- context "on releasing" do
- before do
- mock_build_message app_name, app_version
- mock_confirm_message "Tagged v#{app_version}."
- mock_confirm_message "Pushed git commits and tags."
-
- Dir.chdir(app_path) { sys_exec("git push -u origin master") }
- end
-
- it "calls rubygem_push with proper arguments" do
- expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
-
- Rake.application["release"].invoke
- end
-
- it "uses Kernel.system" do
- expect(Kernel).to receive(:system).with(gem_bin, "push", app_gem_path.to_s, "--host", "http://example.org").and_return(true)
-
- Rake.application["release"].invoke
- end
- end
-
- it "even if tag already exists" do
- mock_build_message app_name, app_version
- mock_confirm_message "Tag v#{app_version} has already been created."
- expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
-
- Dir.chdir(app_path) do
- `git tag -a -m \"Version #{app_version}\" v#{app_version}`
- end
-
- Rake.application["release"].invoke
- end
- end
- end
-
- describe "release:rubygem_push" do
- let!(:rake_application) { Rake.application }
-
- before(:each) do
- Rake.application = Rake::Application.new
- subject.install
- allow(subject).to receive(:sh_with_input)
- end
-
- after(:each) do
- Rake.application = rake_application
- end
-
- before do
- Dir.chdir(app_path) do
- `git init`
- `git config user.email "you@example.com"`
- `git config user.name "name"`
- `git config push.default simple`
- end
-
- # silence messages
- allow(Bundler.ui).to receive(:confirm)
- allow(Bundler.ui).to receive(:error)
-
- credentials = double("credentials", "file?" => true)
- allow(Bundler.user_home).to receive(:join).
- with(".gem/credentials").and_return(credentials)
- end
-
- describe "success messaging" do
- context "No allowed_push_host set" do
- before do
- allow(subject).to receive(:allowed_push_host).and_return(nil)
- end
-
- around do |example|
- orig_host = ENV["RUBYGEMS_HOST"]
- ENV["RUBYGEMS_HOST"] = rubygems_host_env
-
- example.run
-
- ENV["RUBYGEMS_HOST"] = orig_host
- end
-
- context "RUBYGEMS_HOST env var is set" do
- let(:rubygems_host_env) { "https://custom.env.gemhost.com" }
-
- it "should report successful push to the host from the environment" do
- mock_confirm_message "Pushed #{app_name} #{app_version} to #{rubygems_host_env}"
-
- Rake.application["release:rubygem_push"].invoke
- end
- end
-
- context "RUBYGEMS_HOST env var is not set" do
- let(:rubygems_host_env) { nil }
-
- it "should report successful push to rubygems.org" do
- mock_confirm_message "Pushed #{app_name} #{app_version} to rubygems.org"
-
- Rake.application["release:rubygem_push"].invoke
- end
- end
-
- context "RUBYGEMS_HOST env var is an empty string" do
- let(:rubygems_host_env) { "" }
-
- it "should report successful push to rubygems.org" do
- mock_confirm_message "Pushed #{app_name} #{app_version} to rubygems.org"
-
- Rake.application["release:rubygem_push"].invoke
- end
- end
- end
-
- context "allowed_push_host set in gemspec" do
- before do
- allow(subject).to receive(:allowed_push_host).and_return("https://my.gemhost.com")
- end
-
- it "should report successful push to the allowed gem host" do
- mock_confirm_message "Pushed #{app_name} #{app_version} to https://my.gemhost.com"
-
- Rake.application["release:rubygem_push"].invoke
- end
- end
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/gem_version_promoter_spec.rb b/spec/bundler/bundler/gem_version_promoter_spec.rb
deleted file mode 100644
index 01e0232fba..0000000000
--- a/spec/bundler/bundler/gem_version_promoter_spec.rb
+++ /dev/null
@@ -1,179 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::GemVersionPromoter do
- context "conservative resolver" do
- def versions(result)
- result.flatten.map(&:version).map(&:to_s)
- end
-
- def make_instance(*args)
- @gvp = Bundler::GemVersionPromoter.new(*args).tap do |gvp|
- gvp.class.class_eval { public :filter_dep_specs, :sort_dep_specs }
- end
- end
-
- def unlocking(options)
- make_instance(Bundler::SpecSet.new([]), ["foo"]).tap do |p|
- p.level = options[:level] if options[:level]
- p.strict = options[:strict] if options[:strict]
- end
- end
-
- def keep_locked(options)
- make_instance(Bundler::SpecSet.new([]), ["bar"]).tap do |p|
- p.level = options[:level] if options[:level]
- p.strict = options[:strict] if options[:strict]
- end
- end
-
- def build_spec_groups(name, versions)
- versions.map do |v|
- Bundler::Resolver::SpecGroup.new(build_spec(name, v))
- end
- end
-
- # Rightmost (highest array index) in result is most preferred.
- # Leftmost (lowest array index) in result is least preferred.
- # `build_spec_groups` has all versions of gem in index.
- # `build_spec` is the version currently in the .lock file.
- #
- # In default (not strict) mode, all versions in the index will
- # be returned, allowing Bundler the best chance to resolve all
- # dependencies, but sometimes resulting in upgrades that some
- # would not consider conservative.
- context "filter specs (strict) level patch" do
- it "when keeping build_spec, keep current, next release" do
- keep_locked(:level => :patch)
- res = @gvp.filter_dep_specs(
- build_spec_groups("foo", %w[1.7.8 1.7.9 1.8.0]),
- build_spec("foo", "1.7.8").first
- )
- expect(versions(res)).to eq %w[1.7.9 1.7.8]
- end
-
- it "when unlocking prefer next release first" do
- unlocking(:level => :patch)
- res = @gvp.filter_dep_specs(
- build_spec_groups("foo", %w[1.7.8 1.7.9 1.8.0]),
- build_spec("foo", "1.7.8").first
- )
- expect(versions(res)).to eq %w[1.7.8 1.7.9]
- end
-
- it "when unlocking keep current when already at latest release" do
- unlocking(:level => :patch)
- res = @gvp.filter_dep_specs(
- build_spec_groups("foo", %w[1.7.9 1.8.0 2.0.0]),
- build_spec("foo", "1.7.9").first
- )
- expect(versions(res)).to eq %w[1.7.9]
- end
- end
-
- context "filter specs (strict) level minor" do
- it "when unlocking favor next releases, remove minor and major increases" do
- unlocking(:level => :minor)
- res = @gvp.filter_dep_specs(
- build_spec_groups("foo", %w[0.2.0 0.3.0 0.3.1 0.9.0 1.0.0 2.0.0 2.0.1]),
- build_spec("foo", "0.2.0").first
- )
- expect(versions(res)).to eq %w[0.2.0 0.3.0 0.3.1 0.9.0]
- end
-
- it "when keep locked, keep current, then favor next release, remove minor and major increases" do
- keep_locked(:level => :minor)
- res = @gvp.filter_dep_specs(
- build_spec_groups("foo", %w[0.2.0 0.3.0 0.3.1 0.9.0 1.0.0 2.0.0 2.0.1]),
- build_spec("foo", "0.2.0").first
- )
- expect(versions(res)).to eq %w[0.3.0 0.3.1 0.9.0 0.2.0]
- end
- end
-
- context "sort specs (not strict) level patch" do
- it "when not unlocking, same order but make sure build_spec version is most preferred to stay put" do
- keep_locked(:level => :patch)
- res = @gvp.sort_dep_specs(
- build_spec_groups("foo", %w[1.5.4 1.6.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 2.0.0 2.0.1]),
- build_spec("foo", "1.7.7").first
- )
- expect(versions(res)).to eq %w[1.5.4 1.6.5 1.7.6 2.0.0 2.0.1 1.8.0 1.8.1 1.7.8 1.7.9 1.7.7]
- end
-
- it "when unlocking favor next release, then current over minor increase" do
- unlocking(:level => :patch)
- res = @gvp.sort_dep_specs(
- build_spec_groups("foo", %w[1.7.7 1.7.8 1.7.9 1.8.0]),
- build_spec("foo", "1.7.8").first
- )
- expect(versions(res)).to eq %w[1.7.7 1.8.0 1.7.8 1.7.9]
- end
-
- it "when unlocking do proper integer comparison, not string" do
- unlocking(:level => :patch)
- res = @gvp.sort_dep_specs(
- build_spec_groups("foo", %w[1.7.7 1.7.8 1.7.9 1.7.15 1.8.0]),
- build_spec("foo", "1.7.8").first
- )
- expect(versions(res)).to eq %w[1.7.7 1.8.0 1.7.8 1.7.9 1.7.15]
- end
-
- it "leave current when unlocking but already at latest release" do
- unlocking(:level => :patch)
- res = @gvp.sort_dep_specs(
- build_spec_groups("foo", %w[1.7.9 1.8.0 2.0.0]),
- build_spec("foo", "1.7.9").first
- )
- expect(versions(res)).to eq %w[2.0.0 1.8.0 1.7.9]
- end
- end
-
- context "sort specs (not strict) level minor" do
- it "when unlocking favor next release, then minor increase over current" do
- unlocking(:level => :minor)
- res = @gvp.sort_dep_specs(
- build_spec_groups("foo", %w[0.2.0 0.3.0 0.3.1 0.9.0 1.0.0 2.0.0 2.0.1]),
- build_spec("foo", "0.2.0").first
- )
- expect(versions(res)).to eq %w[2.0.0 2.0.1 1.0.0 0.2.0 0.3.0 0.3.1 0.9.0]
- end
- end
-
- context "level error handling" do
- subject { Bundler::GemVersionPromoter.new }
-
- it "should raise if not major, minor or patch is passed" do
- expect { subject.level = :minjor }.to raise_error ArgumentError
- end
-
- it "should raise if invalid classes passed" do
- [123, nil].each do |value|
- expect { subject.level = value }.to raise_error ArgumentError
- end
- end
-
- it "should accept major, minor patch symbols" do
- [:major, :minor, :patch].each do |value|
- subject.level = value
- expect(subject.level).to eq value
- end
- end
-
- it "should accept major, minor patch strings" do
- %w[major minor patch].each do |value|
- subject.level = value
- expect(subject.level).to eq value.to_sym
- end
- end
- end
-
- context "debug output" do
- it "should not kerblooie on its own debug output" do
- gvp = unlocking(:level => :patch)
- dep = Bundler::DepProxy.new(dep("foo", "1.2.0").first, "ruby")
- result = gvp.send(:debug_format_result, dep, build_spec_groups("foo", %w[1.2.0 1.3.0]))
- expect(result.class).to eq Array
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/index_spec.rb b/spec/bundler/bundler/index_spec.rb
deleted file mode 100644
index 0f3f6e4944..0000000000
--- a/spec/bundler/bundler/index_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Index do
- let(:specs) { [] }
- subject { described_class.build {|i| i.use(specs) } }
-
- context "specs with a nil platform" do
- let(:spec) do
- Gem::Specification.new do |s|
- s.name = "json"
- s.version = "1.8.3"
- allow(s).to receive(:platform).and_return(nil)
- end
- end
- let(:specs) { [spec] }
-
- describe "#search_by_spec" do
- it "finds the spec when a nil platform is specified" do
- expect(subject.search(spec)).to eq([spec])
- end
-
- it "finds the spec when a ruby platform is specified" do
- query = spec.dup.tap {|s| s.platform = "ruby" }
- expect(subject.search(query)).to eq([spec])
- end
- end
- end
-
- context "with specs that include development dependencies" do
- let(:specs) { [*build_spec("a", "1.0.0") {|s| s.development("b", "~> 1.0") }] }
-
- it "does not include b in #dependency_names" do
- expect(subject.dependency_names).not_to include("b")
- end
- end
-end
diff --git a/spec/bundler/bundler/installer/gem_installer_spec.rb b/spec/bundler/bundler/installer/gem_installer_spec.rb
deleted file mode 100644
index 8f8d1c6d15..0000000000
--- a/spec/bundler/bundler/installer/gem_installer_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/installer/gem_installer"
-
-RSpec.describe Bundler::GemInstaller do
- let(:installer) { instance_double("Installer") }
- let(:spec_source) { instance_double("SpecSource") }
- let(:spec) { instance_double("Specification", :name => "dummy", :version => "0.0.1", :loaded_from => "dummy", :source => spec_source) }
-
- subject { described_class.new(spec, installer) }
-
- context "spec_settings is nil" do
- it "invokes install method with empty build_args" do
- allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => [])
- subject.install_from_spec
- end
- end
-
- context "spec_settings is build option" do
- it "invokes install method with build_args" do
- allow(Bundler.settings).to receive(:[]).with(:bin)
- allow(Bundler.settings).to receive(:[]).with(:inline)
- allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
- allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy")
- expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy"])
- subject.install_from_spec
- end
- end
-
- context "spec_settings is build option with spaces" do
- it "invokes install method with build_args" do
- allow(Bundler.settings).to receive(:[]).with(:bin)
- allow(Bundler.settings).to receive(:[]).with(:inline)
- allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
- allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy --with-another-dummy-config")
- expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy", "--with-another-dummy-config"])
- subject.install_from_spec
- end
- end
-end
diff --git a/spec/bundler/bundler/installer/parallel_installer_spec.rb b/spec/bundler/bundler/installer/parallel_installer_spec.rb
deleted file mode 100644
index ace5c1a23a..0000000000
--- a/spec/bundler/bundler/installer/parallel_installer_spec.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/installer/parallel_installer"
-
-RSpec.describe Bundler::ParallelInstaller do
- let(:installer) { instance_double("Installer") }
- let(:all_specs) { [] }
- let(:size) { 1 }
- let(:standalone) { false }
- let(:force) { false }
-
- subject { described_class.new(installer, all_specs, size, standalone, force) }
-
- context "when dependencies that are not on the overall installation list are the only ones not installed" do
- let(:all_specs) do
- [
- build_spec("alpha", "1.0") {|s| s.runtime "a", "1" },
- ].flatten
- end
-
- it "prints a warning" do
- expect(Bundler.ui).to receive(:warn).with(<<-W.strip)
-Your lockfile was created by an old Bundler that left some things out.
-You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile.
-The missing gems are:
-* a depended upon by alpha
- W
- subject.check_for_corrupt_lockfile
- end
-
- context "when size > 1" do
- let(:size) { 500 }
-
- it "prints a warning and sets size to 1" do
- expect(Bundler.ui).to receive(:warn).with(<<-W.strip)
-Your lockfile was created by an old Bundler that left some things out.
-Because of the missing DEPENDENCIES, we can only install gems one at a time, instead of installing 500 at a time.
-You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile.
-The missing gems are:
-* a depended upon by alpha
- W
- subject.check_for_corrupt_lockfile
- expect(subject.size).to eq(1)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/installer/spec_installation_spec.rb b/spec/bundler/bundler/installer/spec_installation_spec.rb
deleted file mode 100644
index a9cf09a372..0000000000
--- a/spec/bundler/bundler/installer/spec_installation_spec.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/installer/parallel_installer"
-
-RSpec.describe Bundler::ParallelInstaller::SpecInstallation do
- let!(:dep) do
- a_spec = Object.new
- def a_spec.name
- "I like tests"
- end
- a_spec
- end
-
- describe "#ready_to_enqueue?" do
- context "when in enqueued state" do
- it "is falsey" do
- spec = described_class.new(dep)
- spec.state = :enqueued
- expect(spec.ready_to_enqueue?).to be_falsey
- end
- end
-
- context "when in installed state" do
- it "returns falsey" do
- spec = described_class.new(dep)
- spec.state = :installed
- expect(spec.ready_to_enqueue?).to be_falsey
- end
- end
-
- it "returns truthy" do
- spec = described_class.new(dep)
- expect(spec.ready_to_enqueue?).to be_truthy
- end
- end
-
- describe "#dependencies_installed?" do
- context "when all dependencies are installed" do
- it "returns true" do
- dependencies = []
- dependencies << instance_double("SpecInstallation", :spec => "alpha", :name => "alpha", :installed? => true, :all_dependencies => [], :type => :production)
- dependencies << instance_double("SpecInstallation", :spec => "beta", :name => "beta", :installed? => true, :all_dependencies => [], :type => :production)
- all_specs = dependencies + [instance_double("SpecInstallation", :spec => "gamma", :name => "gamma", :installed? => false, :all_dependencies => [], :type => :production)]
- spec = described_class.new(dep)
- allow(spec).to receive(:all_dependencies).and_return(dependencies)
- expect(spec.dependencies_installed?(all_specs)).to be_truthy
- end
- end
-
- context "when all dependencies are not installed" do
- it "returns false" do
- dependencies = []
- dependencies << instance_double("SpecInstallation", :spec => "alpha", :name => "alpha", :installed? => false, :all_dependencies => [], :type => :production)
- dependencies << instance_double("SpecInstallation", :spec => "beta", :name => "beta", :installed? => true, :all_dependencies => [], :type => :production)
- all_specs = dependencies + [instance_double("SpecInstallation", :spec => "gamma", :name => "gamma", :installed? => false, :all_dependencies => [], :type => :production)]
- spec = described_class.new(dep)
- allow(spec).to receive(:all_dependencies).and_return(dependencies)
- expect(spec.dependencies_installed?(all_specs)).to be_falsey
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/lockfile_parser_spec.rb b/spec/bundler/bundler/lockfile_parser_spec.rb
deleted file mode 100644
index 3a6d61336f..0000000000
--- a/spec/bundler/bundler/lockfile_parser_spec.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/lockfile_parser"
-
-RSpec.describe Bundler::LockfileParser do
- let(:lockfile_contents) { strip_whitespace(<<-L) }
- GIT
- remote: https://github.com/alloy/peiji-san.git
- revision: eca485d8dc95f12aaec1a434b49d295c7e91844b
- specs:
- peiji-san (1.2.0)
-
- GEM
- remote: https://rubygems.org/
- specs:
- rake (10.3.2)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- peiji-san!
- rake
-
- RUBY VERSION
- ruby 2.1.3p242
-
- BUNDLED WITH
- 1.12.0.rc.2
- L
-
- describe ".sections_in_lockfile" do
- it "returns the attributes" do
- attributes = described_class.sections_in_lockfile(lockfile_contents)
- expect(attributes).to contain_exactly(
- "BUNDLED WITH", "DEPENDENCIES", "GEM", "GIT", "PLATFORMS", "RUBY VERSION"
- )
- end
- end
-
- describe ".unknown_sections_in_lockfile" do
- let(:lockfile_contents) { strip_whitespace(<<-L) }
- UNKNOWN ATTR
-
- UNKNOWN ATTR 2
- random contents
- L
-
- it "returns the unknown attributes" do
- attributes = described_class.unknown_sections_in_lockfile(lockfile_contents)
- expect(attributes).to contain_exactly("UNKNOWN ATTR", "UNKNOWN ATTR 2")
- end
- end
-
- describe ".sections_to_ignore" do
- subject { described_class.sections_to_ignore(base_version) }
-
- context "with a nil base version" do
- let(:base_version) { nil }
-
- it "returns the same as > 1.0" do
- expect(subject).to contain_exactly(
- described_class::BUNDLED, described_class::RUBY, described_class::PLUGIN
- )
- end
- end
-
- context "with a prerelease base version" do
- let(:base_version) { Gem::Version.create("1.11.0.rc.1") }
-
- it "returns the same as for the release version" do
- expect(subject).to contain_exactly(
- described_class::RUBY, described_class::PLUGIN
- )
- end
- end
-
- context "with a current version" do
- let(:base_version) { Gem::Version.create(Bundler::VERSION) }
-
- it "returns an empty array" do
- expect(subject).to eq([])
- end
- end
-
- context "with a future version" do
- let(:base_version) { Gem::Version.create("5.5.5") }
-
- it "returns an empty array" do
- expect(subject).to eq([])
- end
- end
- end
-
- describe "#initialize" do
- before { allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app("gems.rb")) }
- subject { described_class.new(lockfile_contents) }
-
- let(:sources) do
- [Bundler::Source::Git.new("uri" => "https://github.com/alloy/peiji-san.git", "revision" => "eca485d8dc95f12aaec1a434b49d295c7e91844b"),
- Bundler::Source::Rubygems.new("remotes" => ["https://rubygems.org"])]
- end
- let(:dependencies) do
- {
- "peiji-san" => Bundler::Dependency.new("peiji-san", ">= 0"),
- "rake" => Bundler::Dependency.new("rake", ">= 0"),
- }
- end
- let(:specs) do
- [
- Bundler::LazySpecification.new("peiji-san", v("1.2.0"), rb),
- Bundler::LazySpecification.new("rake", v("10.3.2"), rb),
- ]
- end
- let(:platforms) { [rb] }
- let(:bundler_version) { Gem::Version.new("1.12.0.rc.2") }
- let(:ruby_version) { "ruby 2.1.3p242" }
-
- shared_examples_for "parsing" do
- it "parses correctly" do
- expect(subject.sources).to eq sources
- expect(subject.dependencies).to eq dependencies
- expect(subject.specs).to eq specs
- expect(Hash[subject.specs.map {|s| [s, s.dependencies] }]).to eq Hash[subject.specs.map {|s| [s, s.dependencies] }]
- expect(subject.platforms).to eq platforms
- expect(subject.bundler_version).to eq bundler_version
- expect(subject.ruby_version).to eq ruby_version
- end
- end
-
- include_examples "parsing"
-
- context "when an extra section is at the end" do
- let(:lockfile_contents) { super() + "\n\nFOO BAR\n baz\n baa\n qux\n" }
- include_examples "parsing"
- end
-
- context "when an extra section is at the start" do
- let(:lockfile_contents) { "FOO BAR\n baz\n baa\n qux\n\n" + super() }
- include_examples "parsing"
- end
-
- context "when an extra section is in the middle" do
- let(:lockfile_contents) { super().split(/(?=GEM)/).insert(1, "FOO BAR\n baz\n baa\n qux\n\n").join }
- include_examples "parsing"
- end
-
- context "when a dependency has options" do
- let(:lockfile_contents) { super().sub("peiji-san!", "peiji-san!\n foo: bar") }
- include_examples "parsing"
- end
- end
-end
diff --git a/spec/bundler/bundler/mirror_spec.rb b/spec/bundler/bundler/mirror_spec.rb
deleted file mode 100644
index 4a8a0c7c48..0000000000
--- a/spec/bundler/bundler/mirror_spec.rb
+++ /dev/null
@@ -1,329 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/mirror"
-
-RSpec.describe Bundler::Settings::Mirror do
- let(:mirror) { Bundler::Settings::Mirror.new }
-
- it "returns zero when fallback_timeout is not set" do
- expect(mirror.fallback_timeout).to eq(0)
- end
-
- it "takes a number as a fallback_timeout" do
- mirror.fallback_timeout = 1
- expect(mirror.fallback_timeout).to eq(1)
- end
-
- it "takes truthy as a default fallback timeout" do
- mirror.fallback_timeout = true
- expect(mirror.fallback_timeout).to eq(0.1)
- end
-
- it "takes falsey as a zero fallback timeout" do
- mirror.fallback_timeout = false
- expect(mirror.fallback_timeout).to eq(0)
- end
-
- it "takes a string with 'true' as a default fallback timeout" do
- mirror.fallback_timeout = "true"
- expect(mirror.fallback_timeout).to eq(0.1)
- end
-
- it "takes a string with 'false' as a zero fallback timeout" do
- mirror.fallback_timeout = "false"
- expect(mirror.fallback_timeout).to eq(0)
- end
-
- it "takes a string for the uri but returns an uri object" do
- mirror.uri = "http://localhost:9292"
- expect(mirror.uri).to eq(Bundler::URI("http://localhost:9292"))
- end
-
- it "takes an uri object for the uri" do
- mirror.uri = Bundler::URI("http://localhost:9293")
- expect(mirror.uri).to eq(Bundler::URI("http://localhost:9293"))
- end
-
- context "without a uri" do
- it "invalidates the mirror" do
- mirror.validate!
- expect(mirror.valid?).to be_falsey
- end
- end
-
- context "with an uri" do
- before { mirror.uri = "http://localhost:9292" }
-
- context "without a fallback timeout" do
- it "is not valid by default" do
- expect(mirror.valid?).to be_falsey
- end
-
- context "when probed" do
- let(:probe) { double }
-
- context "with a replying mirror" do
- before do
- allow(probe).to receive(:replies?).and_return(true)
- mirror.validate!(probe)
- end
-
- it "is valid" do
- expect(mirror.valid?).to be_truthy
- end
- end
-
- context "with a non replying mirror" do
- before do
- allow(probe).to receive(:replies?).and_return(false)
- mirror.validate!(probe)
- end
-
- it "is still valid" do
- expect(mirror.valid?).to be_truthy
- end
- end
- end
- end
-
- context "with a fallback timeout" do
- before { mirror.fallback_timeout = 1 }
-
- it "is not valid by default" do
- expect(mirror.valid?).to be_falsey
- end
-
- context "when probed" do
- let(:probe) { double }
-
- context "with a replying mirror" do
- before do
- allow(probe).to receive(:replies?).and_return(true)
- mirror.validate!(probe)
- end
-
- it "is valid" do
- expect(mirror.valid?).to be_truthy
- end
-
- it "is validated only once" do
- allow(probe).to receive(:replies?).and_raise("Only once!")
- mirror.validate!(probe)
- expect(mirror.valid?).to be_truthy
- end
- end
-
- context "with a non replying mirror" do
- before do
- allow(probe).to receive(:replies?).and_return(false)
- mirror.validate!(probe)
- end
-
- it "is not valid" do
- expect(mirror.valid?).to be_falsey
- end
-
- it "is validated only once" do
- allow(probe).to receive(:replies?).and_raise("Only once!")
- mirror.validate!(probe)
- expect(mirror.valid?).to be_falsey
- end
- end
- end
- end
-
- describe "#==" do
- it "returns true if uri and fallback timeout are the same" do
- uri = "https://ruby.taobao.org"
- mirror = Bundler::Settings::Mirror.new(uri, 1)
- another_mirror = Bundler::Settings::Mirror.new(uri, 1)
-
- expect(mirror == another_mirror).to be true
- end
- end
- end
-end
-
-RSpec.describe Bundler::Settings::Mirrors do
- let(:localhost_uri) { Bundler::URI("http://localhost:9292") }
-
- context "with a just created mirror" do
- let(:mirrors) do
- probe = double
- allow(probe).to receive(:replies?).and_return(true)
- Bundler::Settings::Mirrors.new(probe)
- end
-
- it "returns a mirror that contains the source uri for an unknown uri" do
- mirror = mirrors.for("http://rubygems.org/")
- expect(mirror).to eq(Bundler::Settings::Mirror.new("http://rubygems.org/"))
- end
-
- it "parses a mirror key and returns a mirror for the parsed uri" do
- mirrors.parse("mirror.http://rubygems.org/", localhost_uri)
- expect(mirrors.for("http://rubygems.org/").uri).to eq(localhost_uri)
- end
-
- it "parses a relative mirror key and returns a mirror for the parsed http uri" do
- mirrors.parse("mirror.rubygems.org", localhost_uri)
- expect(mirrors.for("http://rubygems.org/").uri).to eq(localhost_uri)
- end
-
- it "parses a relative mirror key and returns a mirror for the parsed https uri" do
- mirrors.parse("mirror.rubygems.org", localhost_uri)
- expect(mirrors.for("https://rubygems.org/").uri).to eq(localhost_uri)
- end
-
- context "with a uri parsed already" do
- before { mirrors.parse("mirror.http://rubygems.org/", localhost_uri) }
-
- it "takes a mirror fallback_timeout and assigns the timeout" do
- mirrors.parse("mirror.http://rubygems.org.fallback_timeout", "2")
- expect(mirrors.for("http://rubygems.org/").fallback_timeout).to eq(2)
- end
-
- it "parses a 'true' fallback timeout and sets the default timeout" do
- mirrors.parse("mirror.http://rubygems.org.fallback_timeout", "true")
- expect(mirrors.for("http://rubygems.org/").fallback_timeout).to eq(0.1)
- end
-
- it "parses a 'false' fallback timeout and sets it to zero" do
- mirrors.parse("mirror.http://rubygems.org.fallback_timeout", "false")
- expect(mirrors.for("http://rubygems.org/").fallback_timeout).to eq(0)
- end
- end
- end
-
- context "with a mirror prober that replies on time" do
- let(:mirrors) do
- probe = double
- allow(probe).to receive(:replies?).and_return(true)
- Bundler::Settings::Mirrors.new(probe)
- end
-
- context "with a default fallback_timeout for rubygems.org" do
- before do
- mirrors.parse("mirror.http://rubygems.org/", localhost_uri)
- mirrors.parse("mirror.http://rubygems.org.fallback_timeout", "true")
- end
-
- it "returns localhost" do
- expect(mirrors.for("http://rubygems.org").uri).to eq(localhost_uri)
- end
- end
-
- context "with a mirror for all" do
- before do
- mirrors.parse("mirror.all", localhost_uri)
- end
-
- context "without a fallback timeout" do
- it "returns localhost uri for rubygems" do
- expect(mirrors.for("http://rubygems.org").uri).to eq(localhost_uri)
- end
-
- it "returns localhost for any other url" do
- expect(mirrors.for("http://whatever.com/").uri).to eq(localhost_uri)
- end
- end
- context "with a fallback timeout" do
- before { mirrors.parse("mirror.all.fallback_timeout", "1") }
-
- it "returns localhost uri for rubygems" do
- expect(mirrors.for("http://rubygems.org").uri).to eq(localhost_uri)
- end
-
- it "returns localhost for any other url" do
- expect(mirrors.for("http://whatever.com/").uri).to eq(localhost_uri)
- end
- end
- end
- end
-
- context "with a mirror prober that does not reply on time" do
- let(:mirrors) do
- probe = double
- allow(probe).to receive(:replies?).and_return(false)
- Bundler::Settings::Mirrors.new(probe)
- end
-
- context "with a localhost mirror for all" do
- before { mirrors.parse("mirror.all", localhost_uri) }
-
- context "without a fallback timeout" do
- it "returns localhost" do
- expect(mirrors.for("http://whatever.com").uri).to eq(localhost_uri)
- end
- end
-
- context "with a fallback timeout" do
- before { mirrors.parse("mirror.all.fallback_timeout", "true") }
-
- it "returns the source uri, not localhost" do
- expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/"))
- end
- end
- end
-
- context "with localhost as a mirror for rubygems.org" do
- before { mirrors.parse("mirror.http://rubygems.org/", localhost_uri) }
-
- context "without a fallback timeout" do
- it "returns the uri that is not mirrored" do
- expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/"))
- end
-
- it "returns localhost for rubygems.org" do
- expect(mirrors.for("http://rubygems.org/").uri).to eq(localhost_uri)
- end
- end
-
- context "with a fallback timeout" do
- before { mirrors.parse("mirror.http://rubygems.org/.fallback_timeout", "true") }
-
- it "returns the uri that is not mirrored" do
- expect(mirrors.for("http://whatever.com").uri).to eq(Bundler::URI("http://whatever.com/"))
- end
-
- it "returns rubygems.org for rubygems.org" do
- expect(mirrors.for("http://rubygems.org/").uri).to eq(Bundler::URI("http://rubygems.org/"))
- end
- end
- end
- end
-end
-
-RSpec.describe Bundler::Settings::TCPSocketProbe do
- let(:probe) { Bundler::Settings::TCPSocketProbe.new }
-
- context "with a listening TCP Server" do
- def with_server_and_mirror
- server = TCPServer.new("0.0.0.0", 0)
- mirror = Bundler::Settings::Mirror.new("http://0.0.0.0:#{server.addr[1]}", 1)
- yield server, mirror
- server.close unless server.closed?
- end
-
- it "probes the server correctly" do
- with_server_and_mirror do |server, mirror|
- expect(server.closed?).to be_falsey
- expect(probe.replies?(mirror)).to be_truthy
- end
- end
-
- it "probes falsey when the server is down" do
- with_server_and_mirror do |server, mirror|
- server.close
- expect(probe.replies?(mirror)).to be_falsey
- end
- end
- end
-
- context "with an invalid mirror" do
- let(:mirror) { Bundler::Settings::Mirror.new("http://127.0.0.127:9292", true) }
-
- it "fails with a timeout when there is nothing to tcp handshake" do
- expect(probe.replies?(mirror)).to be_falsey
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin/api/source_spec.rb b/spec/bundler/bundler/plugin/api/source_spec.rb
deleted file mode 100644
index 2c50ff56a4..0000000000
--- a/spec/bundler/bundler/plugin/api/source_spec.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Plugin::API::Source do
- let(:uri) { "uri://to/test" }
- let(:type) { "spec_type" }
-
- subject(:source) do
- klass = Class.new
- klass.send :include, Bundler::Plugin::API::Source
- klass.new("uri" => uri, "type" => type)
- end
-
- describe "attributes" do
- it "allows access to uri" do
- expect(source.uri).to eq("uri://to/test")
- end
-
- it "allows access to name" do
- expect(source.name).to eq("spec_type at uri://to/test")
- end
- end
-
- context "post_install" do
- let(:installer) { double(:installer) }
-
- before do
- allow(Bundler::Source::Path::Installer).to receive(:new) { installer }
- end
-
- it "calls Path::Installer's post_install" do
- expect(installer).to receive(:post_install).once
-
- source.post_install(double(:spec))
- end
- end
-
- context "install_path" do
- let(:uri) { "uri://to/a/repository-name" }
- let(:hash) { Digest(:SHA1).hexdigest(uri) }
- let(:install_path) { Pathname.new "/bundler/install/path" }
-
- before do
- allow(Bundler).to receive(:install_path) { install_path }
- end
-
- it "returns basename with uri_hash" do
- expected = Pathname.new "#{install_path}/repository-name-#{hash[0..11]}"
- expect(source.install_path).to eq(expected)
- end
- end
-
- context "to_lock" do
- it "returns the string with remote and type" do
- expected = strip_whitespace <<-L
- PLUGIN SOURCE
- remote: #{uri}
- type: #{type}
- specs:
- L
-
- expect(source.to_lock).to eq(expected)
- end
-
- context "with additional options to lock" do
- before do
- allow(source).to receive(:options_to_lock) { { "first" => "option" } }
- end
-
- it "includes them" do
- expected = strip_whitespace <<-L
- PLUGIN SOURCE
- remote: #{uri}
- type: #{type}
- first: option
- specs:
- L
-
- expect(source.to_lock).to eq(expected)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin/api_spec.rb b/spec/bundler/bundler/plugin/api_spec.rb
deleted file mode 100644
index 58fb908572..0000000000
--- a/spec/bundler/bundler/plugin/api_spec.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Plugin::API do
- context "plugin declarations" do
- before do
- stub_const "UserPluginClass", Class.new(Bundler::Plugin::API)
- end
-
- describe "#command" do
- it "declares a command plugin with same class as handler" do
- expect(Bundler::Plugin).
- to receive(:add_command).with("meh", UserPluginClass).once
-
- UserPluginClass.command "meh"
- end
-
- it "accepts another class as argument that handles the command" do
- stub_const "NewClass", Class.new
- expect(Bundler::Plugin).to receive(:add_command).with("meh", NewClass).once
-
- UserPluginClass.command "meh", NewClass
- end
- end
-
- describe "#source" do
- it "declares a source plugin with same class as handler" do
- expect(Bundler::Plugin).
- to receive(:add_source).with("a_source", UserPluginClass).once
-
- UserPluginClass.source "a_source"
- end
-
- it "accepts another class as argument that handles the command" do
- stub_const "NewClass", Class.new
- expect(Bundler::Plugin).to receive(:add_source).with("a_source", NewClass).once
-
- UserPluginClass.source "a_source", NewClass
- end
- end
-
- describe "#hook" do
- it "accepts a block and passes it to Plugin module" do
- foo = double("tester")
- expect(foo).to receive(:called)
-
- expect(Bundler::Plugin).to receive(:add_hook).with("post-foo").and_yield
-
- Bundler::Plugin::API.hook("post-foo") { foo.called }
- end
- end
- end
-
- context "bundler interfaces provided" do
- before do
- stub_const "UserPluginClass", Class.new(Bundler::Plugin::API)
- end
-
- subject(:api) { UserPluginClass.new }
-
- # A test of delegation
- it "provides the Bundler's functions" do
- expect(Bundler).to receive(:an_unknown_function).once
-
- api.an_unknown_function
- end
-
- it "includes Bundler::SharedHelpers' functions" do
- expect(Bundler::SharedHelpers).to receive(:an_unknown_helper).once
-
- api.an_unknown_helper
- end
-
- context "#tmp" do
- it "provides a tmp dir" do
- expect(api.tmp("mytmp")).to be_directory
- end
-
- it "accepts multiple names for suffix" do
- expect(api.tmp("myplugin", "download")).to be_directory
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin/dsl_spec.rb b/spec/bundler/bundler/plugin/dsl_spec.rb
deleted file mode 100644
index be23db3bba..0000000000
--- a/spec/bundler/bundler/plugin/dsl_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Plugin::DSL do
- DSL = Bundler::Plugin::DSL
-
- subject(:dsl) { Bundler::Plugin::DSL.new }
-
- before do
- allow(Bundler).to receive(:root) { Pathname.new "/" }
- end
-
- describe "it ignores only the methods defined in Bundler::Dsl" do
- it "doesn't raises error for Dsl methods" do
- expect { dsl.install_if }.not_to raise_error
- end
-
- it "raises error for other methods" do
- expect { dsl.no_method }.to raise_error(DSL::PluginGemfileError)
- end
- end
-
- describe "source block" do
- it "adds #source with :type to list and also inferred_plugins list" do
- expect(dsl).to receive(:plugin).with("bundler-source-news").once
-
- dsl.source("some_random_url", :type => "news") {}
-
- expect(dsl.inferred_plugins).to eq(["bundler-source-news"])
- end
-
- it "registers a source type plugin only once for multiple declataions" do
- expect(dsl).to receive(:plugin).with("bundler-source-news").and_call_original.once
-
- dsl.source("some_random_url", :type => "news") {}
- dsl.source("another_random_url", :type => "news") {}
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin/events_spec.rb b/spec/bundler/bundler/plugin/events_spec.rb
deleted file mode 100644
index 28d70c6fdd..0000000000
--- a/spec/bundler/bundler/plugin/events_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Plugin::Events do
- context "plugin events" do
- before { Bundler::Plugin::Events.send :reset }
-
- describe "#define" do
- it "raises when redefining a constant" do
- Bundler::Plugin::Events.send(:define, :TEST_EVENT, "foo")
-
- expect do
- Bundler::Plugin::Events.send(:define, :TEST_EVENT, "bar")
- end.to raise_error(ArgumentError)
- end
-
- it "can define a new constant" do
- Bundler::Plugin::Events.send(:define, :NEW_CONSTANT, "value")
- expect(Bundler::Plugin::Events::NEW_CONSTANT).to eq("value")
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin/index_spec.rb b/spec/bundler/bundler/plugin/index_spec.rb
deleted file mode 100644
index e18e960fb8..0000000000
--- a/spec/bundler/bundler/plugin/index_spec.rb
+++ /dev/null
@@ -1,197 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Plugin::Index do
- Index = Bundler::Plugin::Index
-
- before do
- gemfile ""
- path = lib_path(plugin_name)
- index.register_plugin("new-plugin", path.to_s, [path.join("lib").to_s], commands, sources, hooks)
- end
-
- let(:plugin_name) { "new-plugin" }
- let(:commands) { [] }
- let(:sources) { [] }
- let(:hooks) { [] }
-
- subject(:index) { Index.new }
-
- describe "#register plugin" do
- it "is available for retrieval" do
- expect(index.plugin_path(plugin_name)).to eq(lib_path(plugin_name))
- end
-
- it "load_paths is available for retrival" do
- expect(index.load_paths(plugin_name)).to eq([lib_path(plugin_name).join("lib").to_s])
- end
-
- it "is persistent" do
- new_index = Index.new
- expect(new_index.plugin_path(plugin_name)).to eq(lib_path(plugin_name))
- end
-
- it "load_paths are persistent" do
- new_index = Index.new
- expect(new_index.load_paths(plugin_name)).to eq([lib_path(plugin_name).join("lib").to_s])
- end
- end
-
- describe "commands" do
- let(:commands) { ["newco"] }
-
- it "returns the plugins name on query" do
- expect(index.command_plugin("newco")).to eq(plugin_name)
- end
-
- it "raises error on conflict" do
- expect do
- index.register_plugin("aplugin", lib_path("aplugin").to_s, lib_path("aplugin").join("lib").to_s, ["newco"], [], [])
- end.to raise_error(Index::CommandConflict)
- end
-
- it "is persistent" do
- new_index = Index.new
- expect(new_index.command_plugin("newco")).to eq(plugin_name)
- end
- end
-
- describe "source" do
- let(:sources) { ["new_source"] }
-
- it "returns the plugins name on query" do
- expect(index.source_plugin("new_source")).to eq(plugin_name)
- end
-
- it "raises error on conflict" do
- expect do
- index.register_plugin("aplugin", lib_path("aplugin").to_s, lib_path("aplugin").join("lib").to_s, [], ["new_source"], [])
- end.to raise_error(Index::SourceConflict)
- end
-
- it "is persistent" do
- new_index = Index.new
- expect(new_index.source_plugin("new_source")).to eq(plugin_name)
- end
- end
-
- describe "hook" do
- let(:hooks) { ["after-bar"] }
-
- it "returns the plugins name on query" do
- expect(index.hook_plugins("after-bar")).to include(plugin_name)
- end
-
- it "is persistent" do
- new_index = Index.new
- expect(new_index.hook_plugins("after-bar")).to eq([plugin_name])
- end
-
- it "only registers a gem once for an event" do
- path = lib_path(plugin_name)
- index.register_plugin(plugin_name,
- path.to_s,
- [path.join("lib").to_s],
- commands,
- sources,
- hooks + hooks)
- expect(index.hook_plugins("after-bar")).to eq([plugin_name])
- end
-
- context "that are not registered", :focused do
- let(:file) { double("index-file") }
-
- before do
- index.hook_plugins("not-there")
- allow(File).to receive(:open).and_yield(file)
- end
-
- it "should not save it with next registered hook" do
- expect(file).to receive(:puts) do |content|
- expect(content).not_to include("not-there")
- end
-
- index.register_plugin("aplugin", lib_path("aplugin").to_s, lib_path("aplugin").join("lib").to_s, [], [], [])
- end
- end
- end
-
- describe "global index" do
- before do
- Dir.chdir(tmp) do
- Bundler::Plugin.reset!
- path = lib_path("gplugin")
- index.register_plugin("gplugin", path.to_s, [path.join("lib").to_s], [], ["glb_source"], [])
- end
- end
-
- it "skips sources" do
- new_index = Index.new
- expect(new_index.source_plugin("glb_source")).to be_falsy
- end
- end
-
- describe "after conflict" do
- let(:commands) { ["foo"] }
- let(:sources) { ["bar"] }
- let(:hooks) { ["hoook"] }
-
- shared_examples "it cleans up" do
- it "the path" do
- expect(index.installed?("cplugin")).to be_falsy
- end
-
- it "the command" do
- expect(index.command_plugin("xfoo")).to be_falsy
- end
-
- it "the source" do
- expect(index.source_plugin("xbar")).to be_falsy
- end
-
- it "the hook" do
- expect(index.hook_plugins("xhoook")).to be_empty
- end
- end
-
- context "on command conflict it cleans up" do
- before do
- expect do
- path = lib_path("cplugin")
- index.register_plugin("cplugin", path.to_s, [path.join("lib").to_s], ["foo"], ["xbar"], ["xhoook"])
- end.to raise_error(Index::CommandConflict)
- end
-
- include_examples "it cleans up"
- end
-
- context "on source conflict it cleans up" do
- before do
- expect do
- path = lib_path("cplugin")
- index.register_plugin("cplugin", path.to_s, [path.join("lib").to_s], ["xfoo"], ["bar"], ["xhoook"])
- end.to raise_error(Index::SourceConflict)
- end
-
- include_examples "it cleans up"
- end
-
- context "on command and source conflict it cleans up" do
- before do
- expect do
- path = lib_path("cplugin")
- index.register_plugin("cplugin", path.to_s, [path.join("lib").to_s], ["foo"], ["bar"], ["xhoook"])
- end.to raise_error(Index::CommandConflict)
- end
-
- include_examples "it cleans up"
- end
- end
-
- describe "readonly disk without home" do
- it "ignores being unable to create temp home dir" do
- expect_any_instance_of(Bundler::Plugin::Index).to receive(:global_index_file).
- and_raise(Bundler::GenericSystemCallError.new("foo", "bar"))
- Bundler::Plugin::Index.new
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin/installer_spec.rb b/spec/bundler/bundler/plugin/installer_spec.rb
deleted file mode 100644
index e89720f6f7..0000000000
--- a/spec/bundler/bundler/plugin/installer_spec.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Plugin::Installer do
- subject(:installer) { Bundler::Plugin::Installer.new }
-
- describe "cli install" do
- it "uses Gem.sources when non of the source is provided" do
- sources = double(:sources)
- Bundler.settings # initialize it before we have to touch rubygems.ext_lock
- allow(Bundler).to receive_message_chain("rubygems.sources") { sources }
-
- allow(installer).to receive(:install_rubygems).
- with("new-plugin", [">= 0"], sources).once
-
- installer.install("new-plugin", {})
- end
-
- describe "with mocked installers" do
- let(:spec) { double(:spec) }
- it "returns the installed spec after installing git plugins" do
- allow(installer).to receive(:install_git).
- and_return("new-plugin" => spec)
-
- expect(installer.install(["new-plugin"], :git => "https://some.ran/dom")).
- to eq("new-plugin" => spec)
- end
-
- it "returns the installed spec after installing local git plugins" do
- allow(installer).to receive(:install_local_git).
- and_return("new-plugin" => spec)
-
- expect(installer.install(["new-plugin"], :local_git => "/phony/path/repo")).
- to eq("new-plugin" => spec)
- end
-
- it "returns the installed spec after installing rubygems plugins" do
- allow(installer).to receive(:install_rubygems).
- and_return("new-plugin" => spec)
-
- expect(installer.install(["new-plugin"], :source => "https://some.ran/dom")).
- to eq("new-plugin" => spec)
- end
- end
-
- describe "with actual installers" do
- before do
- build_repo2 do
- build_plugin "re-plugin"
- build_plugin "ma-plugin"
- end
- end
-
- context "git plugins" do
- before do
- build_git "ga-plugin", :path => lib_path("ga-plugin") do |s|
- s.write "plugins.rb"
- end
- end
-
- let(:result) do
- installer.install(["ga-plugin"], :git => file_uri_for(lib_path("ga-plugin")))
- end
-
- it "returns the installed spec after installing" do
- spec = result["ga-plugin"]
- expect(spec.full_name).to eq "ga-plugin-1.0"
- end
-
- it "has expected full_gem_path" do
- rev = revision_for(lib_path("ga-plugin"))
- expect(result["ga-plugin"].full_gem_path).
- to eq(Bundler::Plugin.root.join("bundler", "gems", "ga-plugin-#{rev[0..11]}").to_s)
- end
- end
-
- context "local git plugins" do
- before do
- build_git "ga-plugin", :path => lib_path("ga-plugin") do |s|
- s.write "plugins.rb"
- end
- end
-
- let(:result) do
- installer.install(["ga-plugin"], :local_git => lib_path("ga-plugin").to_s)
- end
-
- it "returns the installed spec after installing" do
- spec = result["ga-plugin"]
- expect(spec.full_name).to eq "ga-plugin-1.0"
- end
-
- it "has expected full_gem_path" do
- rev = revision_for(lib_path("ga-plugin"))
- expect(result["ga-plugin"].full_gem_path).
- to eq(Bundler::Plugin.root.join("bundler", "gems", "ga-plugin-#{rev[0..11]}").to_s)
- end
- end
-
- context "rubygems plugins" do
- let(:result) do
- installer.install(["re-plugin"], :source => file_uri_for(gem_repo2))
- end
-
- it "returns the installed spec after installing " do
- expect(result["re-plugin"]).to be_kind_of(Bundler::RemoteSpecification)
- end
-
- it "has expected full_gem_path" do
- expect(result["re-plugin"].full_gem_path).
- to eq(global_plugin_gem("re-plugin-1.0").to_s)
- end
- end
-
- context "multiple plugins" do
- let(:result) do
- installer.install(["re-plugin", "ma-plugin"], :source => file_uri_for(gem_repo2))
- end
-
- it "returns the installed spec after installing " do
- expect(result["re-plugin"]).to be_kind_of(Bundler::RemoteSpecification)
- expect(result["ma-plugin"]).to be_kind_of(Bundler::RemoteSpecification)
- end
-
- it "has expected full_gem_path" do
- expect(result["re-plugin"].full_gem_path).to eq(global_plugin_gem("re-plugin-1.0").to_s)
- expect(result["ma-plugin"].full_gem_path).to eq(global_plugin_gem("ma-plugin-1.0").to_s)
- end
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin/source_list_spec.rb b/spec/bundler/bundler/plugin/source_list_spec.rb
deleted file mode 100644
index 64a1233dd1..0000000000
--- a/spec/bundler/bundler/plugin/source_list_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Plugin::SourceList do
- SourceList = Bundler::Plugin::SourceList
-
- before do
- allow(Bundler).to receive(:root) { Pathname.new "/" }
- end
-
- subject(:source_list) { SourceList.new }
-
- describe "adding sources uses classes for plugin" do
- it "uses Plugin::Installer::Rubygems for rubygems sources" do
- source = source_list.
- add_rubygems_source("remotes" => ["https://existing-rubygems.org"])
- expect(source).to be_instance_of(Bundler::Plugin::Installer::Rubygems)
- end
-
- it "uses Plugin::Installer::Git for git sources" do
- source = source_list.
- add_git_source("uri" => "git://existing-git.org/path.git")
- expect(source).to be_instance_of(Bundler::Plugin::Installer::Git)
- end
- end
-end
diff --git a/spec/bundler/bundler/plugin_spec.rb b/spec/bundler/bundler/plugin_spec.rb
deleted file mode 100644
index e0e2e9afdf..0000000000
--- a/spec/bundler/bundler/plugin_spec.rb
+++ /dev/null
@@ -1,334 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../support/streams"
-
-RSpec.describe Bundler::Plugin do
- Plugin = Bundler::Plugin
-
- let(:installer) { double(:installer) }
- let(:index) { double(:index) }
- let(:spec) { double(:spec) }
- let(:spec2) { double(:spec2) }
-
- before do
- build_lib "new-plugin", :path => lib_path("new-plugin") do |s|
- s.write "plugins.rb"
- end
-
- build_lib "another-plugin", :path => lib_path("another-plugin") do |s|
- s.write "plugins.rb"
- end
-
- allow(spec).to receive(:full_gem_path).
- and_return(lib_path("new-plugin").to_s)
- allow(spec).to receive(:load_paths).
- and_return([lib_path("new-plugin").join("lib").to_s])
-
- allow(spec2).to receive(:full_gem_path).
- and_return(lib_path("another-plugin").to_s)
- allow(spec2).to receive(:load_paths).
- and_return([lib_path("another-plugin").join("lib").to_s])
-
- allow(Plugin::Installer).to receive(:new) { installer }
- allow(Plugin).to receive(:index) { index }
- allow(index).to receive(:register_plugin)
- end
-
- describe "list command" do
- context "when no plugins are installed" do
- before { allow(index).to receive(:installed_plugins) { [] } }
- it "outputs no plugins installed" do
- expect(Bundler.ui).to receive(:info).with("No plugins installed")
- subject.list
- end
- end
-
- context "with installed plugins" do
- before do
- allow(index).to receive(:installed_plugins) { %w[plug1 plug2] }
- allow(index).to receive(:plugin_commands).with("plug1") { %w[c11 c12] }
- allow(index).to receive(:plugin_commands).with("plug2") { %w[c21 c22] }
- end
- it "list plugins followed by commands" do
- expected_output = "plug1\n-----\n c11\n c12\n\nplug2\n-----\n c21\n c22\n\n"
- expect(Bundler.ui).to receive(:info).with(expected_output)
- subject.list
- end
- end
- end
-
- describe "install command" do
- let(:opts) { { "version" => "~> 1.0", "source" => "foo" } }
-
- before do
- allow(installer).to receive(:install).with(["new-plugin"], opts) do
- { "new-plugin" => spec }
- end
- end
-
- it "passes the name and options to installer" do
- allow(installer).to receive(:install).with(["new-plugin"], opts) do
- { "new-plugin" => spec }
- end.once
-
- subject.install ["new-plugin"], opts
- end
-
- it "validates the installed plugin" do
- allow(subject).
- to receive(:validate_plugin!).with(lib_path("new-plugin")).once
-
- subject.install ["new-plugin"], opts
- end
-
- it "registers the plugin with index" do
- allow(index).to receive(:register_plugin).
- with("new-plugin", lib_path("new-plugin").to_s, [lib_path("new-plugin").join("lib").to_s], []).once
- subject.install ["new-plugin"], opts
- end
-
- context "multiple plugins" do
- it do
- allow(installer).to receive(:install).
- with(["new-plugin", "another-plugin"], opts) do
- {
- "new-plugin" => spec,
- "another-plugin" => spec2,
- }
- end.once
-
- allow(subject).to receive(:validate_plugin!).twice
- allow(index).to receive(:register_plugin).twice
- subject.install ["new-plugin", "another-plugin"], opts
- end
- end
- end
-
- describe "evaluate gemfile for plugins" do
- let(:definition) { double("definition") }
- let(:builder) { double("builder") }
- let(:gemfile) { bundled_app("Gemfile") }
-
- before do
- allow(Plugin::DSL).to receive(:new) { builder }
- allow(builder).to receive(:eval_gemfile).with(gemfile)
- allow(builder).to receive(:to_definition) { definition }
- allow(builder).to receive(:inferred_plugins) { [] }
- end
-
- it "doesn't calls installer without any plugins" do
- allow(definition).to receive(:dependencies) { [] }
- allow(installer).to receive(:install_definition).never
-
- subject.gemfile_install(gemfile)
- end
-
- context "with dependencies" do
- let(:plugin_specs) do
- {
- "new-plugin" => spec,
- "another-plugin" => spec2,
- }
- end
-
- before do
- allow(index).to receive(:installed?) { nil }
- allow(definition).to receive(:dependencies) { [Bundler::Dependency.new("new-plugin", ">=0"), Bundler::Dependency.new("another-plugin", ">=0")] }
- allow(installer).to receive(:install_definition) { plugin_specs }
- end
-
- it "should validate and register the plugins" do
- expect(subject).to receive(:validate_plugin!).twice
- expect(subject).to receive(:register_plugin).twice
-
- subject.gemfile_install(gemfile)
- end
-
- it "should pass the optional plugins to #register_plugin" do
- allow(builder).to receive(:inferred_plugins) { ["another-plugin"] }
-
- expect(subject).to receive(:register_plugin).
- with("new-plugin", spec, false).once
-
- expect(subject).to receive(:register_plugin).
- with("another-plugin", spec2, true).once
-
- subject.gemfile_install(gemfile)
- end
- end
- end
-
- describe "#command?" do
- it "returns true value for commands in index" do
- allow(index).
- to receive(:command_plugin).with("newcommand") { "my-plugin" }
- result = subject.command? "newcommand"
- expect(result).to be_truthy
- end
-
- it "returns false value for commands not in index" do
- allow(index).to receive(:command_plugin).with("newcommand") { nil }
- result = subject.command? "newcommand"
- expect(result).to be_falsy
- end
- end
-
- describe "#exec_command" do
- it "raises UndefinedCommandError when command is not found" do
- allow(index).to receive(:command_plugin).with("newcommand") { nil }
- expect { subject.exec_command("newcommand", []) }.
- to raise_error(Plugin::UndefinedCommandError)
- end
- end
-
- describe "#source?" do
- it "returns true value for sources in index" do
- allow(index).
- to receive(:command_plugin).with("foo-source") { "my-plugin" }
- result = subject.command? "foo-source"
- expect(result).to be_truthy
- end
-
- it "returns false value for source not in index" do
- allow(index).to receive(:command_plugin).with("foo-source") { nil }
- result = subject.command? "foo-source"
- expect(result).to be_falsy
- end
- end
-
- describe "#source" do
- it "raises UnknownSourceError when source is not found" do
- allow(index).to receive(:source_plugin).with("bar") { nil }
- expect { subject.source("bar") }.
- to raise_error(Plugin::UnknownSourceError)
- end
-
- it "loads the plugin, if not loaded" do
- allow(index).to receive(:source_plugin).with("foo-bar") { "plugin_name" }
-
- expect(subject).to receive(:load_plugin).with("plugin_name")
- subject.source("foo-bar")
- end
-
- it "returns the class registered with #add_source" do
- allow(index).to receive(:source_plugin).with("foo") { "plugin_name" }
- stub_const "NewClass", Class.new
-
- subject.add_source("foo", NewClass)
- expect(subject.source("foo")).to be(NewClass)
- end
- end
-
- describe "#source_from_lock" do
- it "returns instance of registered class initialized with locked opts" do
- opts = { "type" => "l_source", "remote" => "xyz", "other" => "random" }
- allow(index).to receive(:source_plugin).with("l_source") { "plugin_name" }
-
- stub_const "SClass", Class.new
- s_instance = double(:s_instance)
- subject.add_source("l_source", SClass)
-
- expect(SClass).to receive(:new).
- with(hash_including("type" => "l_source", "uri" => "xyz", "other" => "random")) { s_instance }
- expect(subject.source_from_lock(opts)).to be(s_instance)
- end
- end
-
- describe "#root" do
- context "in app dir" do
- before do
- gemfile ""
- end
-
- it "returns plugin dir in app .bundle path" do
- expect(subject.root).to eq(bundled_app.join(".bundle/plugin"))
- end
- end
-
- context "outside app dir" do
- it "returns plugin dir in global bundle path" do
- Dir.chdir tmp
- expect(subject.root).to eq(home.join(".bundle/plugin"))
- end
- end
- end
-
- describe "#add_hook" do
- it "raises an ArgumentError on an unregistered event" do
- ran = false
- expect do
- Plugin.add_hook("unregistered-hook") { ran = true }
- end.to raise_error(ArgumentError)
- expect(ran).to be(false)
- end
- end
-
- describe "#hook" do
- before do
- path = lib_path("foo-plugin")
- build_lib "foo-plugin", :path => path do |s|
- s.write "plugins.rb", code
- end
-
- Bundler::Plugin::Events.send(:reset)
- Bundler::Plugin::Events.send(:define, :EVENT_1, "event-1")
- Bundler::Plugin::Events.send(:define, :EVENT_2, "event-2")
-
- allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT_1).
- and_return(["foo-plugin"])
- allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT_2).
- and_return(["foo-plugin"])
- allow(index).to receive(:plugin_path).with("foo-plugin").and_return(path)
- allow(index).to receive(:load_paths).with("foo-plugin").and_return([])
- end
-
- let(:code) { <<-RUBY }
- Bundler::Plugin::API.hook("event-1") { puts "hook for event 1" }
- RUBY
-
- it "raises an ArgumentError on an unregistered event" do
- expect do
- Plugin.hook("unregistered-hook")
- end.to raise_error(ArgumentError)
- end
-
- it "executes the hook" do
- out = capture(:stdout) do
- Plugin.hook(Bundler::Plugin::Events::EVENT_1)
- end.strip
-
- expect(out).to eq("hook for event 1")
- end
-
- context "single plugin declaring more than one hook" do
- let(:code) { <<-RUBY }
- Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT_1) {}
- Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT_2) {}
- puts "loaded"
- RUBY
-
- it "evals plugins.rb once" do
- out = capture(:stdout) do
- Plugin.hook(Bundler::Plugin::Events::EVENT_1)
- Plugin.hook(Bundler::Plugin::Events::EVENT_2)
- end.strip
-
- expect(out).to eq("loaded")
- end
- end
-
- context "a block is passed" do
- let(:code) { <<-RUBY }
- Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT_1) { |&blk| blk.call }
- RUBY
-
- it "is passed to the hook" do
- out = capture(:stdout) do
- Plugin.hook(Bundler::Plugin::Events::EVENT_1) { puts "win" }
- end.strip
-
- expect(out).to eq("win")
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/psyched_yaml_spec.rb b/spec/bundler/bundler/psyched_yaml_spec.rb
deleted file mode 100644
index d5d68c5cc3..0000000000
--- a/spec/bundler/bundler/psyched_yaml_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/psyched_yaml"
-
-RSpec.describe "Bundler::YamlLibrarySyntaxError" do
- it "is raised on YAML parse errors" do
- expect { YAML.parse "{foo" }.to raise_error(Bundler::YamlLibrarySyntaxError)
- end
-end
diff --git a/spec/bundler/bundler/remote_specification_spec.rb b/spec/bundler/bundler/remote_specification_spec.rb
deleted file mode 100644
index 8115e026d8..0000000000
--- a/spec/bundler/bundler/remote_specification_spec.rb
+++ /dev/null
@@ -1,187 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::RemoteSpecification do
- let(:name) { "foo" }
- let(:version) { Gem::Version.new("1.0.0") }
- let(:platform) { Gem::Platform::RUBY }
- let(:spec_fetcher) { double(:spec_fetcher) }
-
- subject { described_class.new(name, version, platform, spec_fetcher) }
-
- it "is Comparable" do
- expect(described_class.ancestors).to include(Comparable)
- end
-
- it "can match platforms" do
- expect(described_class.ancestors).to include(Bundler::MatchPlatform)
- end
-
- describe "#fetch_platform" do
- let(:remote_spec) { double(:remote_spec, :platform => "jruby") }
-
- before { allow(spec_fetcher).to receive(:fetch_spec).and_return(remote_spec) }
-
- it "should return the spec platform" do
- expect(subject.fetch_platform).to eq("jruby")
- end
- end
-
- describe "#full_name" do
- context "when platform is ruby" do
- it "should return the spec name and version" do
- expect(subject.full_name).to eq("foo-1.0.0")
- end
- end
-
- context "when platform is nil" do
- let(:platform) { nil }
-
- it "should return the spec name and version" do
- expect(subject.full_name).to eq("foo-1.0.0")
- end
- end
-
- context "when platform is a non-ruby platform" do
- let(:platform) { "jruby" }
-
- it "should return the spec name, version, and platform" do
- expect(subject.full_name).to eq("foo-1.0.0-jruby")
- end
- end
- end
-
- describe "#<=>" do
- let(:other_name) { name }
- let(:other_version) { version }
- let(:other_platform) { platform }
- let(:other_spec_fetcher) { spec_fetcher }
-
- shared_examples_for "a comparison" do
- context "which exactly matches" do
- it "returns 0" do
- expect(subject <=> other).to eq(0)
- end
- end
-
- context "which is different by name" do
- let(:other_name) { "a" }
- it "returns 1" do
- expect(subject <=> other).to eq(1)
- end
- end
-
- context "which has a lower version" do
- let(:other_version) { Gem::Version.new("0.9.0") }
- it "returns 1" do
- expect(subject <=> other).to eq(1)
- end
- end
-
- context "which has a higher version" do
- let(:other_version) { Gem::Version.new("1.1.0") }
- it "returns -1" do
- expect(subject <=> other).to eq(-1)
- end
- end
-
- context "which has a different platform" do
- let(:other_platform) { Gem::Platform.new("x86-mswin32") }
- it "returns -1" do
- expect(subject <=> other).to eq(-1)
- end
- end
- end
-
- context "comparing another Bundler::RemoteSpecification" do
- let(:other) do
- Bundler::RemoteSpecification.new(other_name, other_version,
- other_platform, nil)
- end
-
- it_should_behave_like "a comparison"
- end
-
- context "comparing a Gem::Specification" do
- let(:other) do
- Gem::Specification.new(other_name, other_version).tap do |s|
- s.platform = other_platform
- end
- end
-
- it_should_behave_like "a comparison"
- end
-
- context "comparing a non sortable object" do
- let(:other) { Object.new }
- let(:remote_spec) { double(:remote_spec, :platform => "jruby") }
-
- before do
- allow(spec_fetcher).to receive(:fetch_spec).and_return(remote_spec)
- allow(remote_spec).to receive(:<=>).and_return(nil)
- end
-
- it "should use default object comparison" do
- expect(subject <=> other).to eq(nil)
- end
- end
- end
-
- describe "#__swap__" do
- let(:spec) { double(:spec, :dependencies => []) }
- let(:new_spec) { double(:new_spec, :dependencies => [], :runtime_dependencies => []) }
-
- before { subject.instance_variable_set(:@_remote_specification, spec) }
-
- it "should replace remote specification with the passed spec" do
- expect(subject.instance_variable_get(:@_remote_specification)).to be(spec)
- subject.__swap__(new_spec)
- expect(subject.instance_variable_get(:@_remote_specification)).to be(new_spec)
- end
- end
-
- describe "#sort_obj" do
- context "when platform is ruby" do
- it "should return a sorting delegate array with name, version, and -1" do
- expect(subject.sort_obj).to match_array(["foo", version, -1])
- end
- end
-
- context "when platform is not ruby" do
- let(:platform) { "jruby" }
-
- it "should return a sorting delegate array with name, version, and 1" do
- expect(subject.sort_obj).to match_array(["foo", version, 1])
- end
- end
- end
-
- describe "method missing" do
- context "and is present in Gem::Specification" do
- let(:remote_spec) { double(:remote_spec, :authors => "abcd") }
-
- before do
- allow(subject).to receive(:_remote_specification).and_return(remote_spec)
- expect(subject.methods.map(&:to_sym)).not_to include(:authors)
- end
-
- it "should send through to Gem::Specification" do
- expect(subject.authors).to eq("abcd")
- end
- end
- end
-
- describe "respond to missing?" do
- context "and is present in Gem::Specification" do
- let(:remote_spec) { double(:remote_spec, :authors => "abcd") }
-
- before do
- allow(subject).to receive(:_remote_specification).and_return(remote_spec)
- expect(subject.methods.map(&:to_sym)).not_to include(:authors)
- end
-
- it "should send through to Gem::Specification" do
- expect(subject.respond_to?(:authors)).to be_truthy
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/retry_spec.rb b/spec/bundler/bundler/retry_spec.rb
deleted file mode 100644
index b893580d72..0000000000
--- a/spec/bundler/bundler/retry_spec.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Retry do
- it "return successful result if no errors" do
- attempts = 0
- result = Bundler::Retry.new(nil, nil, 3).attempt do
- attempts += 1
- :success
- end
- expect(result).to eq(:success)
- expect(attempts).to eq(1)
- end
-
- it "returns the first valid result" do
- jobs = [proc { raise "foo" }, proc { :bar }, proc { raise "foo" }]
- attempts = 0
- result = Bundler::Retry.new(nil, nil, 3).attempt do
- attempts += 1
- jobs.shift.call
- end
- expect(result).to eq(:bar)
- expect(attempts).to eq(2)
- end
-
- it "raises the last error" do
- errors = [StandardError, StandardError, StandardError, Bundler::GemfileNotFound]
- attempts = 0
- expect do
- Bundler::Retry.new(nil, nil, 3).attempt do
- attempts += 1
- raise errors.shift
- end
- end.to raise_error(Bundler::GemfileNotFound)
- expect(attempts).to eq(4)
- end
-
- it "raises exceptions" do
- error = Bundler::GemfileNotFound
- attempts = 0
- expect do
- Bundler::Retry.new(nil, error).attempt do
- attempts += 1
- raise error
- end
- end.to raise_error(error)
- expect(attempts).to eq(1)
- end
-
- context "logging" do
- let(:error) { Bundler::GemfileNotFound }
- let(:failure_message) { "Retrying test due to error (2/2): #{error} #{error}" }
-
- context "with debugging on" do
- it "print error message with newline" do
- allow(Bundler.ui).to receive(:debug?).and_return(true)
- expect(Bundler.ui).to_not receive(:info)
- expect(Bundler.ui).to receive(:warn).with(failure_message, true)
-
- expect do
- Bundler::Retry.new("test", [], 1).attempt do
- raise error
- end
- end.to raise_error(error)
- end
- end
-
- context "with debugging off" do
- it "print error message with newlines" do
- allow(Bundler.ui).to receive(:debug?).and_return(false)
- expect(Bundler.ui).to receive(:info).with("").twice
- expect(Bundler.ui).to receive(:warn).with(failure_message, false)
-
- expect do
- Bundler::Retry.new("test", [], 1).attempt do
- raise error
- end
- end.to raise_error(error)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/ruby_dsl_spec.rb b/spec/bundler/bundler/ruby_dsl_spec.rb
deleted file mode 100644
index bc1ca98457..0000000000
--- a/spec/bundler/bundler/ruby_dsl_spec.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/ruby_dsl"
-
-RSpec.describe Bundler::RubyDsl do
- class MockDSL
- include Bundler::RubyDsl
-
- attr_reader :ruby_version
- end
-
- let(:dsl) { MockDSL.new }
- let(:ruby_version) { "2.0.0" }
- let(:version) { "2.0.0" }
- let(:engine) { "jruby" }
- let(:engine_version) { "9000" }
- let(:patchlevel) { "100" }
- let(:options) do
- { :patchlevel => patchlevel,
- :engine => engine,
- :engine_version => engine_version }
- end
-
- let(:invoke) do
- proc do
- args = Array(ruby_version) + [options]
- dsl.ruby(*args)
- end
- end
-
- subject do
- invoke.call
- dsl.ruby_version
- end
-
- describe "#ruby_version" do
- shared_examples_for "it stores the ruby version" do
- it "stores the version" do
- expect(subject.versions).to eq(Array(ruby_version))
- expect(subject.gem_version.version).to eq(version)
- end
-
- it "stores the engine details" do
- expect(subject.engine).to eq(engine)
- expect(subject.engine_versions).to eq(Array(engine_version))
- end
-
- it "stores the patchlevel" do
- expect(subject.patchlevel).to eq(patchlevel)
- end
- end
-
- context "with a plain version" do
- it_behaves_like "it stores the ruby version"
- end
-
- context "with a single requirement" do
- let(:ruby_version) { ">= 2.0.0" }
- it_behaves_like "it stores the ruby version"
- end
-
- context "with two requirements in the same string" do
- let(:ruby_version) { ">= 2.0.0, < 3.0" }
- it "raises an error" do
- expect { subject }.to raise_error(ArgumentError)
- end
- end
-
- context "with two requirements" do
- let(:ruby_version) { ["~> 2.0.0", "> 2.0.1"] }
- it_behaves_like "it stores the ruby version"
- end
-
- context "with multiple engine versions" do
- let(:engine_version) { ["> 200", "< 300"] }
- it_behaves_like "it stores the ruby version"
- end
-
- context "with no options hash" do
- let(:invoke) { proc { dsl.ruby(ruby_version) } }
-
- let(:patchlevel) { nil }
- let(:engine) { "ruby" }
- let(:engine_version) { version }
-
- it_behaves_like "it stores the ruby version"
-
- context "and with multiple requirements" do
- let(:ruby_version) { ["~> 2.0.0", "> 2.0.1"] }
- let(:engine_version) { ruby_version }
- it_behaves_like "it stores the ruby version"
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/ruby_version_spec.rb b/spec/bundler/bundler/ruby_version_spec.rb
deleted file mode 100644
index 8c6c071d7f..0000000000
--- a/spec/bundler/bundler/ruby_version_spec.rb
+++ /dev/null
@@ -1,528 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/ruby_version"
-
-RSpec.describe "Bundler::RubyVersion and its subclasses" do
- let(:version) { "2.0.0" }
- let(:patchlevel) { "645" }
- let(:engine) { "jruby" }
- let(:engine_version) { "2.0.1" }
-
- describe Bundler::RubyVersion do
- subject { Bundler::RubyVersion.new(version, patchlevel, engine, engine_version) }
-
- let(:ruby_version) { subject }
- let(:other_version) { version }
- let(:other_patchlevel) { patchlevel }
- let(:other_engine) { engine }
- let(:other_engine_version) { engine_version }
- let(:other_ruby_version) { Bundler::RubyVersion.new(other_version, other_patchlevel, other_engine, other_engine_version) }
-
- describe "#initialize" do
- context "no engine is passed" do
- let(:engine) { nil }
-
- it "should set ruby as the engine" do
- expect(subject.engine).to eq("ruby")
- end
- end
-
- context "no engine_version is passed" do
- let(:engine_version) { nil }
-
- it "should set engine version as the passed version" do
- expect(subject.engine_versions).to eq(["2.0.0"])
- end
- end
-
- context "with engine in symbol" do
- let(:engine) { :jruby }
-
- it "should coerce engine to string" do
- expect(subject.engine).to eq("jruby")
- end
- end
-
- context "is called with multiple requirements" do
- let(:version) { ["<= 2.0.0", "> 1.9.3"] }
- let(:engine_version) { nil }
-
- it "sets the versions" do
- expect(subject.versions).to eq(version)
- end
-
- it "sets the engine versions" do
- expect(subject.engine_versions).to eq(version)
- end
- end
-
- context "is called with multiple engine requirements" do
- let(:engine_version) { [">= 2.0", "< 2.3"] }
-
- it "sets the engine versions" do
- expect(subject.engine_versions).to eq(engine_version)
- end
- end
- end
-
- describe ".from_string" do
- shared_examples_for "returning" do
- it "returns the original RubyVersion" do
- expect(described_class.from_string(subject.to_s)).to eq(subject)
- end
- end
-
- include_examples "returning"
-
- context "no patchlevel" do
- let(:patchlevel) { nil }
-
- include_examples "returning"
- end
-
- context "engine is ruby" do
- let(:engine) { "ruby" }
- let(:engine_version) { version }
-
- include_examples "returning"
- end
-
- context "with multiple requirements" do
- let(:engine_version) { ["> 9", "< 11"] }
- let(:version) { ["> 8", "< 10"] }
- let(:patchlevel) { nil }
-
- it "returns nil" do
- expect(described_class.from_string(subject.to_s)).to be_nil
- end
- end
- end
-
- describe "#to_s" do
- it "should return info string with the ruby version, patchlevel, engine, and engine version" do
- expect(subject.to_s).to eq("ruby 2.0.0p645 (jruby 2.0.1)")
- end
-
- context "no patchlevel" do
- let(:patchlevel) { nil }
-
- it "should return info string with the version, engine, and engine version" do
- expect(subject.to_s).to eq("ruby 2.0.0 (jruby 2.0.1)")
- end
- end
-
- context "engine is ruby" do
- let(:engine) { "ruby" }
-
- it "should return info string with the ruby version and patchlevel" do
- expect(subject.to_s).to eq("ruby 2.0.0p645")
- end
- end
-
- context "with multiple requirements" do
- let(:engine_version) { ["> 9", "< 11"] }
- let(:version) { ["> 8", "< 10"] }
- let(:patchlevel) { nil }
-
- it "should return info string with all requirements" do
- expect(subject.to_s).to eq("ruby > 8, < 10 (jruby > 9, < 11)")
- end
- end
- end
-
- describe "#==" do
- shared_examples_for "two ruby versions are not equal" do
- it "should return false" do
- expect(subject).to_not eq(other_ruby_version)
- end
- end
-
- context "the versions, pathlevels, engines, and engine_versions match" do
- it "should return true" do
- expect(subject).to eq(other_ruby_version)
- end
- end
-
- context "the versions do not match" do
- let(:other_version) { "1.21.6" }
-
- it_behaves_like "two ruby versions are not equal"
- end
-
- context "the patchlevels do not match" do
- let(:other_patchlevel) { "21" }
-
- it_behaves_like "two ruby versions are not equal"
- end
-
- context "the engines do not match" do
- let(:other_engine) { "ruby" }
-
- it_behaves_like "two ruby versions are not equal"
- end
-
- context "the engine versions do not match" do
- let(:other_engine_version) { "1.11.2" }
-
- it_behaves_like "two ruby versions are not equal"
- end
- end
-
- describe "#host" do
- before do
- allow(RbConfig::CONFIG).to receive(:[]).with("host_cpu").and_return("x86_64")
- allow(RbConfig::CONFIG).to receive(:[]).with("host_vendor").and_return("apple")
- allow(RbConfig::CONFIG).to receive(:[]).with("host_os").and_return("darwin14.5.0")
- end
-
- it "should return an info string with the host cpu, vendor, and os" do
- expect(subject.host).to eq("x86_64-apple-darwin14.5.0")
- end
-
- it "memoizes the info string with the host cpu, vendor, and os" do
- expect(RbConfig::CONFIG).to receive(:[]).with("host_cpu").once.and_call_original
- expect(RbConfig::CONFIG).to receive(:[]).with("host_vendor").once.and_call_original
- expect(RbConfig::CONFIG).to receive(:[]).with("host_os").once.and_call_original
- 2.times { ruby_version.host }
- end
- end
-
- describe "#gem_version" do
- let(:gem_version) { "2.0.0" }
- let(:gem_version_obj) { Gem::Version.new(gem_version) }
-
- shared_examples_for "it parses the version from the requirement string" do |version|
- let(:version) { version }
- it "should return the underlying version" do
- expect(ruby_version.gem_version).to eq(gem_version_obj)
- expect(ruby_version.gem_version.version).to eq(gem_version)
- end
- end
-
- it_behaves_like "it parses the version from the requirement string", "2.0.0"
- it_behaves_like "it parses the version from the requirement string", ">= 2.0.0"
- it_behaves_like "it parses the version from the requirement string", "~> 2.0.0"
- it_behaves_like "it parses the version from the requirement string", "< 2.0.0"
- it_behaves_like "it parses the version from the requirement string", "= 2.0.0"
- it_behaves_like "it parses the version from the requirement string", ["> 2.0.0", "< 2.4.5"]
- end
-
- describe "#diff" do
- let(:engine) { "ruby" }
-
- shared_examples_for "there is a difference in the engines" do
- it "should return a tuple with :engine and the two different engines" do
- expect(ruby_version.diff(other_ruby_version)).to eq([:engine, engine, other_engine])
- end
- end
-
- shared_examples_for "there is a difference in the versions" do
- it "should return a tuple with :version and the two different versions" do
- expect(ruby_version.diff(other_ruby_version)).to eq([:version, Array(version).join(", "), Array(other_version).join(", ")])
- end
- end
-
- shared_examples_for "there is a difference in the engine versions" do
- it "should return a tuple with :engine_version and the two different engine versions" do
- expect(ruby_version.diff(other_ruby_version)).to eq([:engine_version, Array(engine_version).join(", "), Array(other_engine_version).join(", ")])
- end
- end
-
- shared_examples_for "there is a difference in the patchlevels" do
- it "should return a tuple with :patchlevel and the two different patchlevels" do
- expect(ruby_version.diff(other_ruby_version)).to eq([:patchlevel, patchlevel, other_patchlevel])
- end
- end
-
- shared_examples_for "there are no differences" do
- it "should return nil" do
- expect(ruby_version.diff(other_ruby_version)).to be_nil
- end
- end
-
- context "all things match exactly" do
- it_behaves_like "there are no differences"
- end
-
- context "detects engine discrepancies first" do
- let(:other_version) { "2.0.1" }
- let(:other_patchlevel) { "643" }
- let(:other_engine) { "rbx" }
- let(:other_engine_version) { "2.0.0" }
-
- it_behaves_like "there is a difference in the engines"
- end
-
- context "detects version discrepancies second" do
- let(:other_version) { "2.0.1" }
- let(:other_patchlevel) { "643" }
- let(:other_engine_version) { "2.0.0" }
-
- it_behaves_like "there is a difference in the versions"
- end
-
- context "detects version discrepancies with multiple requirements second" do
- let(:other_version) { "2.0.1" }
- let(:other_patchlevel) { "643" }
- let(:other_engine_version) { "2.0.0" }
-
- let(:version) { ["> 2.0.0", "< 1.0.0"] }
-
- it_behaves_like "there is a difference in the versions"
- end
-
- context "detects engine version discrepancies third" do
- let(:other_patchlevel) { "643" }
- let(:other_engine_version) { "2.0.0" }
-
- it_behaves_like "there is a difference in the engine versions"
- end
-
- context "detects engine version discrepancies with multiple requirements third" do
- let(:other_patchlevel) { "643" }
- let(:other_engine_version) { "2.0.0" }
-
- let(:engine_version) { ["> 2.0.0", "< 1.0.0"] }
-
- it_behaves_like "there is a difference in the engine versions"
- end
-
- context "detects patchlevel discrepancies last" do
- let(:other_patchlevel) { "643" }
-
- it_behaves_like "there is a difference in the patchlevels"
- end
-
- context "successfully matches gem requirements" do
- let(:version) { ">= 2.0.0" }
- let(:patchlevel) { "< 643" }
- let(:engine) { "ruby" }
- let(:engine_version) { "~> 2.0.1" }
- let(:other_version) { "2.0.0" }
- let(:other_patchlevel) { "642" }
- let(:other_engine) { "ruby" }
- let(:other_engine_version) { "2.0.5" }
-
- it_behaves_like "there are no differences"
- end
-
- context "successfully matches multiple gem requirements" do
- let(:version) { [">= 2.0.0", "< 2.4.5"] }
- let(:patchlevel) { "< 643" }
- let(:engine) { "ruby" }
- let(:engine_version) { ["~> 2.0.1", "< 2.4.5"] }
- let(:other_version) { "2.0.0" }
- let(:other_patchlevel) { "642" }
- let(:other_engine) { "ruby" }
- let(:other_engine_version) { "2.0.5" }
-
- it_behaves_like "there are no differences"
- end
-
- context "successfully detects bad gem requirements with versions with multiple requirements" do
- let(:version) { ["~> 2.0.0", "< 2.0.5"] }
- let(:patchlevel) { "< 643" }
- let(:engine) { "ruby" }
- let(:engine_version) { "~> 2.0.1" }
- let(:other_version) { "2.0.5" }
- let(:other_patchlevel) { "642" }
- let(:other_engine) { "ruby" }
- let(:other_engine_version) { "2.0.5" }
-
- it_behaves_like "there is a difference in the versions"
- end
-
- context "successfully detects bad gem requirements with versions" do
- let(:version) { "~> 2.0.0" }
- let(:patchlevel) { "< 643" }
- let(:engine) { "ruby" }
- let(:engine_version) { "~> 2.0.1" }
- let(:other_version) { "2.1.0" }
- let(:other_patchlevel) { "642" }
- let(:other_engine) { "ruby" }
- let(:other_engine_version) { "2.0.5" }
-
- it_behaves_like "there is a difference in the versions"
- end
-
- context "successfully detects bad gem requirements with patchlevels" do
- let(:version) { ">= 2.0.0" }
- let(:patchlevel) { "< 643" }
- let(:engine) { "ruby" }
- let(:engine_version) { "~> 2.0.1" }
- let(:other_version) { "2.0.0" }
- let(:other_patchlevel) { "645" }
- let(:other_engine) { "ruby" }
- let(:other_engine_version) { "2.0.5" }
-
- it_behaves_like "there is a difference in the patchlevels"
- end
-
- context "successfully detects bad gem requirements with engine versions" do
- let(:version) { ">= 2.0.0" }
- let(:patchlevel) { "< 643" }
- let(:engine) { "ruby" }
- let(:engine_version) { "~> 2.0.1" }
- let(:other_version) { "2.0.0" }
- let(:other_patchlevel) { "642" }
- let(:other_engine) { "ruby" }
- let(:other_engine_version) { "2.1.0" }
-
- it_behaves_like "there is a difference in the engine versions"
- end
-
- context "with a patchlevel of -1" do
- let(:version) { ">= 2.0.0" }
- let(:patchlevel) { "-1" }
- let(:engine) { "ruby" }
- let(:engine_version) { "~> 2.0.1" }
- let(:other_version) { version }
- let(:other_engine) { engine }
- let(:other_engine_version) { engine_version }
-
- context "and comparing with another patchlevel of -1" do
- let(:other_patchlevel) { patchlevel }
-
- it_behaves_like "there are no differences"
- end
-
- context "and comparing with a patchlevel that is not -1" do
- let(:other_patchlevel) { "642" }
-
- it_behaves_like "there is a difference in the patchlevels"
- end
- end
- end
-
- describe "#system" do
- subject { Bundler::RubyVersion.system }
-
- let(:bundler_system_ruby_version) { subject }
-
- around do |example|
- if Bundler::RubyVersion.instance_variable_defined?("@ruby_version")
- begin
- old_ruby_version = Bundler::RubyVersion.instance_variable_get("@ruby_version")
- Bundler::RubyVersion.remove_instance_variable("@ruby_version")
- example.run
- ensure
- Bundler::RubyVersion.instance_variable_set("@ruby_version", old_ruby_version)
- end
- else
- begin
- example.run
- ensure
- Bundler::RubyVersion.remove_instance_variable("@ruby_version")
- end
- end
- end
-
- it "should return an instance of Bundler::RubyVersion" do
- expect(subject).to be_kind_of(Bundler::RubyVersion)
- end
-
- it "memoizes the instance of Bundler::RubyVersion" do
- expect(Bundler::RubyVersion).to receive(:new).once.and_call_original
- 2.times { subject }
- end
-
- describe "#version" do
- it "should return a copy of the value of RUBY_VERSION" do
- expect(subject.versions).to eq([RUBY_VERSION])
- expect(subject.versions.first).to_not be(RUBY_VERSION)
- end
- end
-
- describe "#engine" do
- before { stub_const("RUBY_ENGINE", "jruby") }
- before { stub_const("RUBY_ENGINE_VERSION", "2.1.1") }
-
- it "should return a copy of the value of RUBY_ENGINE" do
- expect(subject.engine).to eq("jruby")
- expect(subject.engine).to_not be(RUBY_ENGINE)
- end
- end
-
- describe "#engine_version" do
- context "engine is ruby" do
- before do
- stub_const("RUBY_ENGINE_VERSION", "2.2.4")
- stub_const("RUBY_ENGINE", "ruby")
- end
-
- it "should return a copy of the value of RUBY_ENGINE_VERSION" do
- expect(bundler_system_ruby_version.engine_versions).to eq(["2.2.4"])
- expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
- end
- end
-
- context "engine is rbx" do
- before do
- stub_const("RUBY_ENGINE", "rbx")
- stub_const("RUBY_ENGINE_VERSION", "2.0.0")
- end
-
- it "should return a copy of the value of RUBY_ENGINE_VERSION" do
- expect(bundler_system_ruby_version.engine_versions).to eq(["2.0.0"])
- expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
- end
- end
-
- context "engine is jruby" do
- before do
- stub_const("RUBY_ENGINE", "jruby")
- stub_const("RUBY_ENGINE_VERSION", "2.1.1")
- end
-
- it "should return a copy of the value of RUBY_ENGINE_VERSION" do
- expect(subject.engine_versions).to eq(["2.1.1"])
- expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
- end
- end
-
- context "engine is some other ruby engine" do
- before do
- stub_const("RUBY_ENGINE", "not_supported_ruby_engine")
- stub_const("RUBY_ENGINE_VERSION", "1.2.3")
- end
-
- it "returns RUBY_ENGINE_VERSION" do
- expect(bundler_system_ruby_version.engine_versions).to eq(["1.2.3"])
- end
- end
- end
-
- describe "#patchlevel" do
- it "should return a string with the value of RUBY_PATCHLEVEL" do
- expect(subject.patchlevel).to eq(RUBY_PATCHLEVEL.to_s)
- end
- end
- end
-
- describe "#to_gem_version_with_patchlevel" do
- shared_examples_for "the patchlevel is omitted" do
- it "does not include a patch level" do
- expect(subject.to_gem_version_with_patchlevel.to_s).to eq(version)
- end
- end
-
- context "with nil patch number" do
- let(:patchlevel) { nil }
-
- it_behaves_like "the patchlevel is omitted"
- end
-
- context "with negative patch number" do
- let(:patchlevel) { -1 }
-
- it_behaves_like "the patchlevel is omitted"
- end
-
- context "with a valid patch number" do
- it "uses the specified patchlevel as patchlevel" do
- expect(subject.to_gem_version_with_patchlevel.to_s).to eq("#{version}.#{patchlevel}")
- end
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/rubygems_integration_spec.rb b/spec/bundler/bundler/rubygems_integration_spec.rb
deleted file mode 100644
index 11fa2f4e0d..0000000000
--- a/spec/bundler/bundler/rubygems_integration_spec.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::RubygemsIntegration do
- it "uses the same chdir lock as rubygems" do
- expect(Bundler.rubygems.ext_lock).to eq(Gem::Ext::Builder::CHDIR_MONITOR)
- end
-
- context "#validate" do
- let(:spec) do
- Gem::Specification.new do |s|
- s.name = "to-validate"
- s.version = "1.0.0"
- s.loaded_from = __FILE__
- end
- end
- subject { Bundler.rubygems.validate(spec) }
-
- it "validates with packaging mode disabled" do
- expect(spec).to receive(:validate).with(false)
- subject
- end
-
- context "with an invalid spec" do
- before do
- expect(spec).to receive(:validate).with(false).
- and_raise(Gem::InvalidSpecificationException.new("TODO is not an author"))
- end
-
- it "should raise a Gem::InvalidSpecificationException and produce a helpful warning message" do
- expect { subject }.to raise_error(Gem::InvalidSpecificationException,
- "The gemspec at #{__FILE__} is not valid. "\
- "Please fix this gemspec.\nThe validation error was 'TODO is not an author'\n")
- end
- end
- end
-
- describe "#configuration" do
- it "handles Gem::SystemExitException errors" do
- allow(Gem).to receive(:configuration) { raise Gem::SystemExitException.new(1) }
- expect { Bundler.rubygems.configuration }.to raise_error(Gem::SystemExitException)
- end
- end
-
- describe "#download_gem" do
- let(:bundler_retry) { double(Bundler::Retry) }
- let(:retry) { double("Bundler::Retry") }
- let(:uri) { Bundler::URI.parse("https://foo.bar") }
- let(:path) { Gem.path.first }
- let(:spec) do
- spec = Bundler::RemoteSpecification.new("Foo", Gem::Version.new("2.5.2"),
- Gem::Platform::RUBY, nil)
- spec.remote = Bundler::Source::Rubygems::Remote.new(uri.to_s)
- spec
- end
- let(:fetcher) { double("gem_remote_fetcher") }
-
- it "successfully downloads gem with retries" do
- expect(Bundler.rubygems).to receive(:gem_remote_fetcher).and_return(fetcher)
- expect(fetcher).to receive(:headers=).with("X-Gemfile-Source" => "https://foo.bar")
- expect(Bundler::Retry).to receive(:new).with("download gem from #{uri}/").
- and_return(bundler_retry)
- expect(bundler_retry).to receive(:attempts).and_yield
- expect(fetcher).to receive(:download).with(spec, uri, path)
-
- Bundler.rubygems.download_gem(spec, uri, path)
- end
- end
-
- describe "#fetch_all_remote_specs" do
- let(:uri) { "https://example.com" }
- let(:fetcher) { double("gem_remote_fetcher") }
- let(:specs_response) { Marshal.dump(["specs"]) }
- let(:prerelease_specs_response) { Marshal.dump(["prerelease_specs"]) }
-
- context "when a rubygems source mirror is set" do
- let(:orig_uri) { Bundler::URI("http://zombo.com") }
- let(:remote_with_mirror) { double("remote", :uri => uri, :original_uri => orig_uri) }
-
- it "sets the 'X-Gemfile-Source' header containing the original source" do
- expect(Bundler.rubygems).to receive(:gem_remote_fetcher).twice.and_return(fetcher)
- expect(fetcher).to receive(:headers=).with("X-Gemfile-Source" => "http://zombo.com").twice
- expect(fetcher).to receive(:fetch_path).with(uri + "specs.4.8.gz").and_return(specs_response)
- expect(fetcher).to receive(:fetch_path).with(uri + "prerelease_specs.4.8.gz").and_return(prerelease_specs_response)
- result = Bundler.rubygems.fetch_all_remote_specs(remote_with_mirror)
- expect(result).to eq(%w[specs prerelease_specs])
- end
- end
-
- context "when there is no rubygems source mirror set" do
- let(:remote_no_mirror) { double("remote", :uri => uri, :original_uri => nil) }
-
- it "does not set the 'X-Gemfile-Source' header" do
- expect(Bundler.rubygems).to receive(:gem_remote_fetcher).twice.and_return(fetcher)
- expect(fetcher).to_not receive(:headers=)
- expect(fetcher).to receive(:fetch_path).with(uri + "specs.4.8.gz").and_return(specs_response)
- expect(fetcher).to receive(:fetch_path).with(uri + "prerelease_specs.4.8.gz").and_return(prerelease_specs_response)
- result = Bundler.rubygems.fetch_all_remote_specs(remote_no_mirror)
- expect(result).to eq(%w[specs prerelease_specs])
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/settings/validator_spec.rb b/spec/bundler/bundler/settings/validator_spec.rb
deleted file mode 100644
index e4ffd89435..0000000000
--- a/spec/bundler/bundler/settings/validator_spec.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Settings::Validator do
- describe ".validate!" do
- def validate!(key, value, settings)
- transformed_key = Bundler.settings.key_for(key)
- if value.nil?
- settings.delete(transformed_key)
- else
- settings[transformed_key] = value
- end
- described_class.validate!(key, value, settings)
- settings
- end
-
- it "path and path.system are mutually exclusive" do
- expect(validate!("path", "bundle", {})).to eq("BUNDLE_PATH" => "bundle")
- expect(validate!("path", "bundle", "BUNDLE_PATH__SYSTEM" => false)).to eq("BUNDLE_PATH" => "bundle")
- expect(validate!("path", "bundle", "BUNDLE_PATH__SYSTEM" => true)).to eq("BUNDLE_PATH" => "bundle")
- expect(validate!("path", nil, "BUNDLE_PATH__SYSTEM" => true)).to eq("BUNDLE_PATH__SYSTEM" => true)
- expect(validate!("path", nil, "BUNDLE_PATH__SYSTEM" => false)).to eq("BUNDLE_PATH__SYSTEM" => false)
- expect(validate!("path", nil, {})).to eq({})
-
- expect(validate!("path.system", true, "BUNDLE_PATH" => "bundle")).to eq("BUNDLE_PATH__SYSTEM" => true)
- expect(validate!("path.system", false, "BUNDLE_PATH" => "bundle")).to eq("BUNDLE_PATH" => "bundle", "BUNDLE_PATH__SYSTEM" => false)
- expect(validate!("path.system", nil, "BUNDLE_PATH" => "bundle")).to eq("BUNDLE_PATH" => "bundle")
- expect(validate!("path.system", true, {})).to eq("BUNDLE_PATH__SYSTEM" => true)
- expect(validate!("path.system", false, {})).to eq("BUNDLE_PATH__SYSTEM" => false)
- expect(validate!("path.system", nil, {})).to eq({})
- end
-
- it "a group cannot be in both `with` & `without` simultaneously" do
- expect do
- validate!("with", "", {})
- validate!("with", nil, {})
- validate!("with", "", "BUNDLE_WITHOUT" => "a")
- validate!("with", nil, "BUNDLE_WITHOUT" => "a")
- validate!("with", "b:c", "BUNDLE_WITHOUT" => "a")
-
- validate!("without", "", {})
- validate!("without", nil, {})
- validate!("without", "", "BUNDLE_WITH" => "a")
- validate!("without", nil, "BUNDLE_WITH" => "a")
- validate!("without", "b:c", "BUNDLE_WITH" => "a")
- end.not_to raise_error
-
- expect { validate!("with", "b:c", "BUNDLE_WITHOUT" => "c:d") }.to raise_error Bundler::InvalidOption, strip_whitespace(<<-EOS).strip
- Setting `with` to "b:c" failed:
- - a group cannot be in both `with` & `without` simultaneously
- - `without` is current set to [:c, :d]
- - the `c` groups conflict
- EOS
-
- expect { validate!("without", "b:c", "BUNDLE_WITH" => "c:d") }.to raise_error Bundler::InvalidOption, strip_whitespace(<<-EOS).strip
- Setting `without` to "b:c" failed:
- - a group cannot be in both `with` & `without` simultaneously
- - `with` is current set to [:c, :d]
- - the `c` groups conflict
- EOS
- end
- end
-
- describe described_class::Rule do
- let(:keys) { %w[key] }
- let(:description) { "rule description" }
- let(:validate) { proc { raise "validate called!" } }
- subject(:rule) { described_class.new(keys, description, &validate) }
-
- describe "#validate!" do
- it "calls the block" do
- expect { rule.validate!("key", nil, {}) }.to raise_error(RuntimeError, /validate called!/)
- end
- end
-
- describe "#fail!" do
- it "raises with a helpful message" do
- expect { subject.fail!("key", "value", "reason1", "reason2") }.to raise_error Bundler::InvalidOption, strip_whitespace(<<-EOS).strip
- Setting `key` to "value" failed:
- - rule description
- - reason1
- - reason2
- EOS
- end
- end
-
- describe "#set" do
- it "works when the value has not changed" do
- allow(Bundler.ui).to receive(:info).never
-
- subject.set({}, "key", nil)
- subject.set({ "BUNDLE_KEY" => "value" }, "key", "value")
- end
-
- it "prints out when the value is changing" do
- settings = {}
-
- expect(Bundler.ui).to receive(:info).with("Setting `key` to \"value\", since rule description, reason1")
- subject.set(settings, "key", "value", "reason1")
- expect(settings).to eq("BUNDLE_KEY" => "value")
-
- expect(Bundler.ui).to receive(:info).with("Setting `key` to \"value2\", since rule description, reason2")
- subject.set(settings, "key", "value2", "reason2")
- expect(settings).to eq("BUNDLE_KEY" => "value2")
-
- expect(Bundler.ui).to receive(:info).with("Setting `key` to nil, since rule description, reason3")
- subject.set(settings, "key", nil, "reason3")
- expect(settings).to eq({})
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/settings_spec.rb b/spec/bundler/bundler/settings_spec.rb
deleted file mode 100644
index b83d768477..0000000000
--- a/spec/bundler/bundler/settings_spec.rb
+++ /dev/null
@@ -1,328 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/settings"
-
-RSpec.describe Bundler::Settings do
- subject(:settings) { described_class.new(bundled_app) }
-
- describe "#set_local" do
- context "when the local config file is not found" do
- subject(:settings) { described_class.new(nil) }
-
- it "raises a GemfileNotFound error with explanation" do
- expect { subject.set_local("foo", "bar") }.
- to raise_error(Bundler::GemfileNotFound, "Could not locate Gemfile")
- end
- end
- end
-
- describe "load_config" do
- let(:hash) do
- {
- "build.thrift" => "--with-cppflags=-D_FORTIFY_SOURCE=0",
- "build.libv8" => "--with-system-v8",
- "build.therubyracer" => "--with-v8-dir",
- "build.pg" => "--with-pg-config=/usr/local/Cellar/postgresql92/9.2.8_1/bin/pg_config",
- "gem.coc" => "false",
- "gem.mit" => "false",
- "gem.test" => "minitest",
- "thingy" => <<-EOS.tr("\n", " "),
---asdf --fdsa --ty=oh man i hope this doesnt break bundler because
-that would suck --ehhh=oh geez it looks like i might have broken bundler somehow
---very-important-option=DontDeleteRoo
---very-important-option=DontDeleteRoo
---very-important-option=DontDeleteRoo
---very-important-option=DontDeleteRoo
- EOS
- "xyz" => "zyx",
- }
- end
-
- before do
- hash.each do |key, value|
- settings.set_local key, value
- end
- end
-
- it "can load the config" do
- loaded = settings.send(:load_config, bundled_app("config"))
- expected = Hash[hash.map do |k, v|
- [settings.send(:key_for, k), v.to_s]
- end]
- expect(loaded).to eq(expected)
- end
-
- context "when BUNDLE_IGNORE_CONFIG is set" do
- before { ENV["BUNDLE_IGNORE_CONFIG"] = "TRUE" }
-
- it "ignores the config" do
- loaded = settings.send(:load_config, bundled_app("config"))
- expect(loaded).to eq({})
- end
- end
- end
-
- describe "#global_config_file" do
- context "when $HOME is not accessible" do
- context "when $TMPDIR is not writable" do
- it "does not raise" do
- expect(Bundler.rubygems).to receive(:user_home).twice.and_return(nil)
- expect(Bundler).to receive(:tmp).twice.and_raise(Errno::EROFS, "Read-only file system @ dir_s_mkdir - /tmp/bundler")
-
- expect(subject.send(:global_config_file)).to be_nil
- end
- end
- end
- end
-
- describe "#[]" do
- context "when the local config file is not found" do
- subject(:settings) { described_class.new }
-
- it "does not raise" do
- expect do
- subject["foo"]
- end.not_to raise_error
- end
- end
-
- context "when not set" do
- context "when default value present" do
- it "retrieves value" do
- expect(settings[:retry]).to be 3
- end
- end
-
- it "returns nil" do
- expect(settings[:buttermilk]).to be nil
- end
- end
-
- context "when is boolean" do
- it "returns a boolean" do
- settings.set_local :frozen, "true"
- expect(settings[:frozen]).to be true
- end
- context "when specific gem is configured" do
- it "returns a boolean" do
- settings.set_local "ignore_messages.foobar", "true"
- expect(settings["ignore_messages.foobar"]).to be true
- end
- end
- end
-
- context "when is number" do
- it "returns a number" do
- settings.set_local :ssl_verify_mode, "1"
- expect(settings[:ssl_verify_mode]).to be 1
- end
- end
-
- context "when it's not possible to write to the file" do
- it "raises an PermissionError with explanation" do
- expect(::Bundler::FileUtils).to receive(:mkdir_p).with(settings.send(:local_config_file).dirname).
- and_raise(Errno::EACCES)
- expect { settings.set_local :frozen, "1" }.
- to raise_error(Bundler::PermissionError, /config/)
- end
- end
- end
-
- describe "#temporary" do
- it "reset after used" do
- Bundler.settings.set_command_option :no_install, true
-
- Bundler.settings.temporary(:no_install => false) do
- expect(Bundler.settings[:no_install]).to eq false
- end
-
- expect(Bundler.settings[:no_install]).to eq true
-
- Bundler.settings.set_command_option :no_install, nil
- end
-
- it "returns the return value of the block" do
- ret = Bundler.settings.temporary({}) { :ret }
- expect(ret).to eq :ret
- end
-
- context "when called without a block" do
- it "leaves the setting changed" do
- Bundler.settings.temporary(:foo => :random)
- expect(Bundler.settings[:foo]).to eq "random"
- end
-
- it "returns nil" do
- expect(Bundler.settings.temporary(:foo => :bar)).to be_nil
- end
- end
- end
-
- describe "#set_global" do
- context "when it's not possible to write to the file" do
- it "raises an PermissionError with explanation" do
- expect(::Bundler::FileUtils).to receive(:mkdir_p).with(settings.send(:global_config_file).dirname).
- and_raise(Errno::EACCES)
- expect { settings.set_global(:frozen, "1") }.
- to raise_error(Bundler::PermissionError, %r{\.bundle/config})
- end
- end
- end
-
- describe "#pretty_values_for" do
- it "prints the converted value rather than the raw string" do
- bool_key = described_class::BOOL_KEYS.first
- settings.set_local(bool_key, "false")
- expect(subject.pretty_values_for(bool_key)).to eq [
- "Set for your local app (#{bundled_app("config")}): false",
- ]
- end
- end
-
- describe "#mirror_for" do
- let(:uri) { Bundler::URI("https://rubygems.org/") }
-
- context "with no configured mirror" do
- it "returns the original URI" do
- expect(settings.mirror_for(uri)).to eq(uri)
- end
-
- it "converts a string parameter to a URI" do
- expect(settings.mirror_for("https://rubygems.org/")).to eq(uri)
- end
- end
-
- context "with a configured mirror" do
- let(:mirror_uri) { Bundler::URI("https://rubygems-mirror.org/") }
-
- before { settings.set_local "mirror.https://rubygems.org/", mirror_uri.to_s }
-
- it "returns the mirror URI" do
- expect(settings.mirror_for(uri)).to eq(mirror_uri)
- end
-
- it "converts a string parameter to a URI" do
- expect(settings.mirror_for("https://rubygems.org/")).to eq(mirror_uri)
- end
-
- it "normalizes the URI" do
- expect(settings.mirror_for("https://rubygems.org")).to eq(mirror_uri)
- end
-
- it "is case insensitive" do
- expect(settings.mirror_for("HTTPS://RUBYGEMS.ORG/")).to eq(mirror_uri)
- end
-
- context "with a file URI" do
- let(:mirror_uri) { Bundler::URI("file:/foo/BAR/baz/qUx/") }
-
- it "returns the mirror URI" do
- expect(settings.mirror_for(uri)).to eq(mirror_uri)
- end
-
- it "converts a string parameter to a URI" do
- expect(settings.mirror_for("file:/foo/BAR/baz/qUx/")).to eq(mirror_uri)
- end
-
- it "normalizes the URI" do
- expect(settings.mirror_for("file:/foo/BAR/baz/qUx")).to eq(mirror_uri)
- end
- end
- end
- end
-
- describe "#credentials_for" do
- let(:uri) { Bundler::URI("https://gemserver.example.org/") }
- let(:credentials) { "username:password" }
-
- context "with no configured credentials" do
- it "returns nil" do
- expect(settings.credentials_for(uri)).to be_nil
- end
- end
-
- context "with credentials configured by URL" do
- before { settings.set_local "https://gemserver.example.org/", credentials }
-
- it "returns the configured credentials" do
- expect(settings.credentials_for(uri)).to eq(credentials)
- end
- end
-
- context "with credentials configured by hostname" do
- before { settings.set_local "gemserver.example.org", credentials }
-
- it "returns the configured credentials" do
- expect(settings.credentials_for(uri)).to eq(credentials)
- end
- end
- end
-
- describe "URI normalization" do
- it "normalizes HTTP URIs in credentials configuration" do
- settings.set_local "http://gemserver.example.org", "username:password"
- expect(settings.all).to include("http://gemserver.example.org/")
- end
-
- it "normalizes HTTPS URIs in credentials configuration" do
- settings.set_local "https://gemserver.example.org", "username:password"
- expect(settings.all).to include("https://gemserver.example.org/")
- end
-
- it "normalizes HTTP URIs in mirror configuration" do
- settings.set_local "mirror.http://rubygems.org", "http://rubygems-mirror.org"
- expect(settings.all).to include("mirror.http://rubygems.org/")
- end
-
- it "normalizes HTTPS URIs in mirror configuration" do
- settings.set_local "mirror.https://rubygems.org", "http://rubygems-mirror.org"
- expect(settings.all).to include("mirror.https://rubygems.org/")
- end
-
- it "does not normalize other config keys that happen to contain 'http'" do
- settings.set_local "local.httparty", home("httparty")
- expect(settings.all).to include("local.httparty")
- end
-
- it "does not normalize other config keys that happen to contain 'https'" do
- settings.set_local "local.httpsmarty", home("httpsmarty")
- expect(settings.all).to include("local.httpsmarty")
- end
-
- it "reads older keys without trailing slashes" do
- settings.set_local "mirror.https://rubygems.org", "http://rubygems-mirror.org"
- expect(settings.mirror_for("https://rubygems.org/")).to eq(
- Bundler::URI("http://rubygems-mirror.org/")
- )
- end
-
- it "normalizes URIs with a fallback_timeout option" do
- settings.set_local "mirror.https://rubygems.org/.fallback_timeout", "true"
- expect(settings.all).to include("mirror.https://rubygems.org/.fallback_timeout")
- end
-
- it "normalizes URIs with a fallback_timeout option without a trailing slash" do
- settings.set_local "mirror.https://rubygems.org.fallback_timeout", "true"
- expect(settings.all).to include("mirror.https://rubygems.org/.fallback_timeout")
- end
- end
-
- describe "BUNDLE_ keys format" do
- let(:settings) { described_class.new(bundled_app(".bundle")) }
-
- it "converts older keys without double dashes" do
- config("BUNDLE_MY__PERSONAL.RACK" => "~/Work/git/rack")
- expect(settings["my.personal.rack"]).to eq("~/Work/git/rack")
- end
-
- it "converts older keys without trailing slashes and double dashes" do
- config("BUNDLE_MIRROR__HTTPS://RUBYGEMS.ORG" => "http://rubygems-mirror.org")
- expect(settings["mirror.https://rubygems.org/"]).to eq("http://rubygems-mirror.org")
- end
-
- it "reads newer keys format properly" do
- config("BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/" => "http://rubygems-mirror.org")
- expect(settings["mirror.https://rubygems.org/"]).to eq("http://rubygems-mirror.org")
- end
- end
-end
diff --git a/spec/bundler/bundler/shared_helpers_spec.rb b/spec/bundler/bundler/shared_helpers_spec.rb
deleted file mode 100644
index 4530a9a5cd..0000000000
--- a/spec/bundler/bundler/shared_helpers_spec.rb
+++ /dev/null
@@ -1,515 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::SharedHelpers do
- let(:ext_lock_double) { double(:ext_lock) }
-
- before do
- allow(Bundler.rubygems).to receive(:ext_lock).and_return(ext_lock_double)
- allow(ext_lock_double).to receive(:synchronize) {|&block| block.call }
- end
-
- subject { Bundler::SharedHelpers }
-
- describe "#default_gemfile" do
- before { ENV["BUNDLE_GEMFILE"] = "/path/Gemfile" }
-
- context "Gemfile is present" do
- let(:expected_gemfile_path) { Pathname.new("/path/Gemfile").expand_path }
-
- it "returns the Gemfile path" do
- expect(subject.default_gemfile).to eq(expected_gemfile_path)
- end
- end
-
- context "Gemfile is not present" do
- before { ENV["BUNDLE_GEMFILE"] = nil }
-
- it "raises a GemfileNotFound error" do
- expect { subject.default_gemfile }.to raise_error(
- Bundler::GemfileNotFound, "Could not locate Gemfile"
- )
- end
- end
-
- context "Gemfile is not an absolute path" do
- before { ENV["BUNDLE_GEMFILE"] = "Gemfile" }
-
- let(:expected_gemfile_path) { Pathname.new("Gemfile").expand_path }
-
- it "returns the Gemfile path" do
- expect(subject.default_gemfile).to eq(expected_gemfile_path)
- end
- end
- end
-
- describe "#default_lockfile" do
- context "gemfile is gems.rb" do
- let(:gemfile_path) { Pathname.new("/path/gems.rb") }
- let(:expected_lockfile_path) { Pathname.new("/path/gems.locked") }
-
- before { allow(subject).to receive(:default_gemfile).and_return(gemfile_path) }
-
- it "returns the gems.locked path" do
- expect(subject.default_lockfile).to eq(expected_lockfile_path)
- end
- end
-
- context "is a regular Gemfile" do
- let(:gemfile_path) { Pathname.new("/path/Gemfile") }
- let(:expected_lockfile_path) { Pathname.new("/path/Gemfile.lock") }
-
- before { allow(subject).to receive(:default_gemfile).and_return(gemfile_path) }
-
- it "returns the lock file path" do
- expect(subject.default_lockfile).to eq(expected_lockfile_path)
- end
- end
- end
-
- describe "#default_bundle_dir" do
- context ".bundle does not exist" do
- it "returns nil" do
- expect(subject.default_bundle_dir).to be_nil
- end
- end
-
- context ".bundle is global .bundle" do
- let(:global_rubygems_dir) { Pathname.new(bundled_app) }
-
- before do
- Dir.mkdir ".bundle"
- allow(Bundler.rubygems).to receive(:user_home).and_return(global_rubygems_dir)
- end
-
- it "returns nil" do
- expect(subject.default_bundle_dir).to be_nil
- end
- end
-
- context ".bundle is not global .bundle" do
- let(:global_rubygems_dir) { Pathname.new("/path/rubygems") }
- let(:expected_bundle_dir_path) { Pathname.new("#{bundled_app}/.bundle") }
-
- before do
- Dir.mkdir ".bundle"
- allow(Bundler.rubygems).to receive(:user_home).and_return(global_rubygems_dir)
- end
-
- it "returns the .bundle path" do
- expect(subject.default_bundle_dir).to eq(expected_bundle_dir_path)
- end
- end
- end
-
- describe "#in_bundle?" do
- it "calls the find_gemfile method" do
- expect(subject).to receive(:find_gemfile)
- subject.in_bundle?
- end
-
- shared_examples_for "correctly determines whether to return a Gemfile path" do
- context "currently in directory with a Gemfile" do
- before { File.new("Gemfile", "w") }
-
- it "returns path of the bundle Gemfile" do
- expect(subject.in_bundle?).to eq("#{bundled_app}/Gemfile")
- end
- end
-
- context "currently in directory without a Gemfile" do
- it "returns nil" do
- expect(subject.in_bundle?).to be_nil
- end
- end
- end
-
- context "ENV['BUNDLE_GEMFILE'] set" do
- before { ENV["BUNDLE_GEMFILE"] = "/path/Gemfile" }
-
- it "returns ENV['BUNDLE_GEMFILE']" do
- expect(subject.in_bundle?).to eq("/path/Gemfile")
- end
- end
-
- context "ENV['BUNDLE_GEMFILE'] not set" do
- before { ENV["BUNDLE_GEMFILE"] = nil }
-
- it_behaves_like "correctly determines whether to return a Gemfile path"
- end
-
- context "ENV['BUNDLE_GEMFILE'] is blank" do
- before { ENV["BUNDLE_GEMFILE"] = "" }
-
- it_behaves_like "correctly determines whether to return a Gemfile path"
- end
- end
-
- describe "#chdir" do
- let(:op_block) { proc { Dir.mkdir "nested_dir" } }
-
- before { Dir.mkdir "chdir_test_dir" }
-
- it "executes the passed block while in the specified directory" do
- subject.chdir("chdir_test_dir", &op_block)
- expect(Pathname.new("chdir_test_dir/nested_dir")).to exist
- end
- end
-
- describe "#pwd" do
- it "returns the current absolute path" do
- expect(subject.pwd).to eq(bundled_app)
- end
- end
-
- describe "#with_clean_git_env" do
- let(:with_clean_git_env_block) { proc { Dir.mkdir "with_clean_git_env_test_dir" } }
-
- before do
- ENV["GIT_DIR"] = "ORIGINAL_ENV_GIT_DIR"
- ENV["GIT_WORK_TREE"] = "ORIGINAL_ENV_GIT_WORK_TREE"
- end
-
- it "executes the passed block" do
- subject.with_clean_git_env(&with_clean_git_env_block)
- expect(Pathname.new("with_clean_git_env_test_dir")).to exist
- end
-
- context "when a block is passed" do
- let(:with_clean_git_env_block) do
- proc do
- Dir.mkdir "git_dir_test_dir" unless ENV["GIT_DIR"].nil?
- Dir.mkdir "git_work_tree_test_dir" unless ENV["GIT_WORK_TREE"].nil?
- end end
-
- it "uses a fresh git env for execution" do
- subject.with_clean_git_env(&with_clean_git_env_block)
- expect(Pathname.new("git_dir_test_dir")).to_not exist
- expect(Pathname.new("git_work_tree_test_dir")).to_not exist
- end
- end
-
- context "passed block does not throw errors" do
- let(:with_clean_git_env_block) do
- proc do
- ENV["GIT_DIR"] = "NEW_ENV_GIT_DIR"
- ENV["GIT_WORK_TREE"] = "NEW_ENV_GIT_WORK_TREE"
- end end
-
- it "restores the git env after" do
- subject.with_clean_git_env(&with_clean_git_env_block)
- expect(ENV["GIT_DIR"]).to eq("ORIGINAL_ENV_GIT_DIR")
- expect(ENV["GIT_WORK_TREE"]).to eq("ORIGINAL_ENV_GIT_WORK_TREE")
- end
- end
-
- context "passed block throws errors" do
- let(:with_clean_git_env_block) do
- proc do
- ENV["GIT_DIR"] = "NEW_ENV_GIT_DIR"
- ENV["GIT_WORK_TREE"] = "NEW_ENV_GIT_WORK_TREE"
- raise RuntimeError.new
- end end
-
- it "restores the git env after" do
- expect { subject.with_clean_git_env(&with_clean_git_env_block) }.to raise_error(RuntimeError)
- expect(ENV["GIT_DIR"]).to eq("ORIGINAL_ENV_GIT_DIR")
- expect(ENV["GIT_WORK_TREE"]).to eq("ORIGINAL_ENV_GIT_WORK_TREE")
- end
- end
- end
-
- describe "#set_bundle_environment" do
- before do
- ENV["BUNDLE_GEMFILE"] = "Gemfile"
- end
-
- shared_examples_for "ENV['PATH'] gets set correctly" do
- before { Dir.mkdir ".bundle" }
-
- it "ensures bundle bin path is in ENV['PATH']" do
- subject.set_bundle_environment
- paths = ENV["PATH"].split(File::PATH_SEPARATOR)
- expect(paths).to include("#{Bundler.bundle_path}/bin")
- end
- end
-
- shared_examples_for "ENV['RUBYOPT'] gets set correctly" do
- it "ensures -rbundler/setup is at the beginning of ENV['RUBYOPT']" do
- subject.set_bundle_environment
- expect(ENV["RUBYOPT"].split(" ")).to start_with("-r#{lib_dir}/bundler/setup")
- end
- end
-
- shared_examples_for "ENV['RUBYLIB'] gets set correctly" do
- let(:ruby_lib_path) { "stubbed_ruby_lib_dir" }
-
- before do
- allow(Bundler::SharedHelpers).to receive(:bundler_ruby_lib).and_return(ruby_lib_path)
- end
-
- it "ensures bundler's ruby version lib path is in ENV['RUBYLIB']" do
- subject.set_bundle_environment
- paths = (ENV["RUBYLIB"]).split(File::PATH_SEPARATOR)
- expect(paths).to include(ruby_lib_path)
- end
- end
-
- it "calls the appropriate set methods" do
- expect(subject).to receive(:set_bundle_variables)
- expect(subject).to receive(:set_path)
- expect(subject).to receive(:set_rubyopt)
- expect(subject).to receive(:set_rubylib)
- subject.set_bundle_environment
- end
-
- it "ignores if bundler_ruby_lib is same as rubylibdir" do
- allow(Bundler::SharedHelpers).to receive(:bundler_ruby_lib).and_return(RbConfig::CONFIG["rubylibdir"])
-
- subject.set_bundle_environment
-
- paths = (ENV["RUBYLIB"]).split(File::PATH_SEPARATOR)
- expect(paths.count(RbConfig::CONFIG["rubylibdir"])).to eq(0)
- end
-
- it "exits if bundle path contains the unix-like path separator" do
- if Gem.respond_to?(:path_separator)
- allow(Gem).to receive(:path_separator).and_return(":")
- else
- stub_const("File::PATH_SEPARATOR", ":".freeze)
- end
- allow(Bundler).to receive(:bundle_path) { Pathname.new("so:me/dir/bin") }
- expect { subject.send(:validate_bundle_path) }.to raise_error(
- Bundler::PathError,
- "Your bundle path contains text matching \":\", which is the " \
- "path separator for your system. Bundler cannot " \
- "function correctly when the Bundle path contains the " \
- "system's PATH separator. Please change your " \
- "bundle path to not match \":\".\nYour current bundle " \
- "path is '#{Bundler.bundle_path}'."
- )
- end
-
- context "with a jruby path_separator regex" do
- # In versions of jruby that supported ruby 1.8, the path separator was the standard File::PATH_SEPARATOR
- let(:regex) { Regexp.new("(?<!jar:file|jar|file|classpath|uri:classloader|uri|http|https):") }
- it "does not exit if bundle path is the standard uri path" do
- allow(Bundler.rubygems).to receive(:path_separator).and_return(regex)
- allow(Bundler).to receive(:bundle_path) { Pathname.new("uri:classloader:/WEB-INF/gems") }
- expect { subject.send(:validate_bundle_path) }.not_to raise_error
- end
-
- it "exits if bundle path contains another directory" do
- allow(Bundler.rubygems).to receive(:path_separator).and_return(regex)
- allow(Bundler).to receive(:bundle_path) {
- Pathname.new("uri:classloader:/WEB-INF/gems:other/dir")
- }
-
- expect { subject.send(:validate_bundle_path) }.to raise_error(
- Bundler::PathError,
- "Your bundle path contains text matching " \
- "/(?<!jar:file|jar|file|classpath|uri:classloader|uri|http|https):/, which is the " \
- "path separator for your system. Bundler cannot " \
- "function correctly when the Bundle path contains the " \
- "system's PATH separator. Please change your " \
- "bundle path to not match " \
- "/(?<!jar:file|jar|file|classpath|uri:classloader|uri|http|https):/." \
- "\nYour current bundle path is '#{Bundler.bundle_path}'."
- )
- end
- end
-
- context "ENV['PATH'] does not exist" do
- before { ENV.delete("PATH") }
-
- it_behaves_like "ENV['PATH'] gets set correctly"
- end
-
- context "ENV['PATH'] is empty" do
- before { ENV["PATH"] = "" }
-
- it_behaves_like "ENV['PATH'] gets set correctly"
- end
-
- context "ENV['PATH'] exists" do
- before { ENV["PATH"] = "/some_path/bin" }
-
- it_behaves_like "ENV['PATH'] gets set correctly"
- end
-
- context "ENV['PATH'] already contains the bundle bin path" do
- let(:bundle_path) { "#{Bundler.bundle_path}/bin" }
-
- before do
- ENV["PATH"] = bundle_path
- end
-
- it_behaves_like "ENV['PATH'] gets set correctly"
-
- it "ENV['PATH'] should only contain one instance of bundle bin path" do
- subject.set_bundle_environment
- paths = (ENV["PATH"]).split(File::PATH_SEPARATOR)
- expect(paths.count(bundle_path)).to eq(1)
- end
- end
-
- context "ENV['RUBYOPT'] does not exist" do
- before { ENV.delete("RUBYOPT") }
-
- it_behaves_like "ENV['RUBYOPT'] gets set correctly"
- end
-
- context "ENV['RUBYOPT'] exists without -rbundler/setup" do
- before { ENV["RUBYOPT"] = "-I/some_app_path/lib" }
-
- it_behaves_like "ENV['RUBYOPT'] gets set correctly"
- end
-
- context "ENV['RUBYOPT'] exists and contains -rbundler/setup" do
- before { ENV["RUBYOPT"] = "-rbundler/setup" }
-
- it_behaves_like "ENV['RUBYOPT'] gets set correctly"
- end
-
- context "ENV['RUBYLIB'] does not exist" do
- before { ENV.delete("RUBYLIB") }
-
- it_behaves_like "ENV['RUBYLIB'] gets set correctly"
- end
-
- context "ENV['RUBYLIB'] is empty" do
- before { ENV["PATH"] = "" }
-
- it_behaves_like "ENV['RUBYLIB'] gets set correctly"
- end
-
- context "ENV['RUBYLIB'] exists" do
- before { ENV["PATH"] = "/some_path/bin" }
-
- it_behaves_like "ENV['RUBYLIB'] gets set correctly"
- end
-
- context "bundle executable in ENV['BUNDLE_BIN_PATH'] does not exist" do
- before { ENV["BUNDLE_BIN_PATH"] = "/does/not/exist" }
- before { Bundler.rubygems.replace_bin_path [] }
-
- it "sets BUNDLE_BIN_PATH to the bundle executable file" do
- subject.set_bundle_environment
- bin_path = ENV["BUNDLE_BIN_PATH"]
- expect(bin_path).to eq(bindir.join("bundle").to_s)
- expect(File.exist?(bin_path)).to be true
- end
- end
-
- context "ENV['RUBYLIB'] already contains the bundler's ruby version lib path" do
- let(:ruby_lib_path) { "stubbed_ruby_lib_dir" }
-
- before do
- ENV["RUBYLIB"] = ruby_lib_path
- end
-
- it_behaves_like "ENV['RUBYLIB'] gets set correctly"
-
- it "ENV['RUBYLIB'] should only contain one instance of bundler's ruby version lib path" do
- subject.set_bundle_environment
- paths = (ENV["RUBYLIB"]).split(File::PATH_SEPARATOR)
- expect(paths.count(ruby_lib_path)).to eq(1)
- end
- end
- end
-
- describe "#filesystem_access" do
- context "system has proper permission access" do
- let(:file_op_block) { proc {|path| FileUtils.mkdir_p(path) } }
-
- it "performs the operation in the passed block" do
- subject.filesystem_access("./test_dir", &file_op_block)
- expect(Pathname.new("test_dir")).to exist
- end
- end
-
- context "system throws Errno::EACESS" do
- let(:file_op_block) { proc {|_path| raise Errno::EACCES } }
-
- it "raises a PermissionError" do
- expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::PermissionError
- )
- end
- end
-
- context "system throws Errno::EAGAIN" do
- let(:file_op_block) { proc {|_path| raise Errno::EAGAIN } }
-
- it "raises a TemporaryResourceError" do
- expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::TemporaryResourceError
- )
- end
- end
-
- context "system throws Errno::EPROTO" do
- let(:file_op_block) { proc {|_path| raise Errno::EPROTO } }
-
- it "raises a VirtualProtocolError" do
- expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::VirtualProtocolError
- )
- end
- end
-
- context "system throws Errno::ENOTSUP" do
- let(:file_op_block) { proc {|_path| raise Errno::ENOTSUP } }
-
- it "raises a OperationNotSupportedError" do
- expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::OperationNotSupportedError
- )
- end
- end
-
- context "system throws Errno::ENOSPC" do
- let(:file_op_block) { proc {|_path| raise Errno::ENOSPC } }
-
- it "raises a NoSpaceOnDeviceError" do
- expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::NoSpaceOnDeviceError
- )
- end
- end
-
- context "system throws an unhandled SystemCallError" do
- let(:error) { SystemCallError.new("Shields down", 1337) }
- let(:file_op_block) { proc {|_path| raise error } }
-
- it "raises a GenericSystemCallError" do
- expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::GenericSystemCallError, /error accessing.+underlying.+Shields down/m
- )
- end
- end
- end
-
- describe "#const_get_safely" do
- module TargetNamespace
- VALID_CONSTANT = 1
- end
-
- context "when the namespace does have the requested constant" do
- it "returns the value of the requested constant" do
- expect(subject.const_get_safely(:VALID_CONSTANT, TargetNamespace)).to eq(1)
- end
- end
-
- context "when the requested constant is passed as a string" do
- it "returns the value of the requested constant" do
- expect(subject.const_get_safely("VALID_CONSTANT", TargetNamespace)).to eq(1)
- end
- end
-
- context "when the namespace does not have the requested constant" do
- it "returns nil" do
- expect(subject.const_get_safely("INVALID_CONSTANT", TargetNamespace)).to be_nil
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/source/git/git_proxy_spec.rb b/spec/bundler/bundler/source/git/git_proxy_spec.rb
deleted file mode 100644
index c18490233d..0000000000
--- a/spec/bundler/bundler/source/git/git_proxy_spec.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Source::Git::GitProxy do
- let(:path) { Pathname("path") }
- let(:uri) { "https://github.com/bundler/bundler.git" }
- let(:ref) { "HEAD" }
- let(:revision) { nil }
- let(:git_source) { nil }
- subject { described_class.new(path, uri, ref, revision, git_source) }
-
- context "with configured credentials" do
- it "adds username and password to URI" do
- Bundler.settings.temporary(uri => "u:p") do
- expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
- subject.checkout
- end
- end
-
- it "adds username and password to URI for host" do
- Bundler.settings.temporary("github.com" => "u:p") do
- expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
- subject.checkout
- end
- end
-
- it "does not add username and password to mismatched URI" do
- Bundler.settings.temporary("https://u:p@github.com/bundler/bundler-mismatch.git" => "u:p") do
- expect(subject).to receive(:git_retry).with(match(uri))
- subject.checkout
- end
- end
-
- it "keeps original userinfo" do
- Bundler.settings.temporary("github.com" => "u:p") do
- original = "https://orig:info@github.com/bundler/bundler.git"
- subject = described_class.new(Pathname("path"), original, "HEAD")
- expect(subject).to receive(:git_retry).with(match(original))
- subject.checkout
- end
- end
- end
-
- describe "#version" do
- context "with a normal version number" do
- before do
- expect(subject).to receive(:git).with("--version").
- and_return("git version 1.2.3")
- end
-
- it "returns the git version number" do
- expect(subject.version).to eq("1.2.3")
- end
-
- it "does not raise an error when passed into Gem::Version.create" do
- expect { Gem::Version.create subject.version }.not_to raise_error
- end
- end
-
- context "with a OSX version number" do
- before do
- expect(subject).to receive(:git).with("--version").
- and_return("git version 1.2.3 (Apple Git-BS)")
- end
-
- it "strips out OSX specific additions in the version string" do
- expect(subject.version).to eq("1.2.3")
- end
-
- it "does not raise an error when passed into Gem::Version.create" do
- expect { Gem::Version.create subject.version }.not_to raise_error
- end
- end
-
- context "with a msysgit version number" do
- before do
- expect(subject).to receive(:git).with("--version").
- and_return("git version 1.2.3.msysgit.0")
- end
-
- it "strips out msysgit specific additions in the version string" do
- expect(subject.version).to eq("1.2.3")
- end
-
- it "does not raise an error when passed into Gem::Version.create" do
- expect { Gem::Version.create subject.version }.not_to raise_error
- end
- end
- end
-
- describe "#full_version" do
- context "with a normal version number" do
- before do
- expect(subject).to receive(:git).with("--version").
- and_return("git version 1.2.3")
- end
-
- it "returns the git version number" do
- expect(subject.full_version).to eq("1.2.3")
- end
- end
-
- context "with a OSX version number" do
- before do
- expect(subject).to receive(:git).with("--version").
- and_return("git version 1.2.3 (Apple Git-BS)")
- end
-
- it "does not strip out OSX specific additions in the version string" do
- expect(subject.full_version).to eq("1.2.3 (Apple Git-BS)")
- end
- end
-
- context "with a msysgit version number" do
- before do
- expect(subject).to receive(:git).with("--version").
- and_return("git version 1.2.3.msysgit.0")
- end
-
- it "does not strip out msysgit specific additions in the version string" do
- expect(subject.full_version).to eq("1.2.3.msysgit.0")
- end
- end
- end
-
- describe "#copy_to" do
- let(:destination) { tmpdir("copy_to_path") }
- let(:submodules) { false }
-
- context "when given a SHA as a revision" do
- let(:revision) { "abcd" * 10 }
- let(:command) { "reset --hard #{revision}" }
-
- it "fails gracefully when resetting to the revision fails" do
- expect(subject).to receive(:git_retry).with(start_with("clone ")) { destination.mkpath }
- expect(subject).to receive(:git_retry).with(start_with("fetch "))
- expect(subject).to receive(:git).with(command).and_raise(Bundler::Source::Git::GitCommandError, command)
- expect(subject).not_to receive(:git)
-
- expect { subject.copy_to(destination, submodules) }.
- to raise_error(
- Bundler::Source::Git::MissingGitRevisionError,
- "Git error: command `git #{command}` in directory #{destination} has failed.\n" \
- "Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?" \
- )
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/source/git_spec.rb b/spec/bundler/bundler/source/git_spec.rb
deleted file mode 100644
index f7475a35aa..0000000000
--- a/spec/bundler/bundler/source/git_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Source::Git do
- before do
- allow(Bundler).to receive(:root) { Pathname.new("root") }
- end
-
- let(:uri) { "https://github.com/foo/bar.git" }
- let(:options) do
- { "uri" => uri }
- end
-
- subject { described_class.new(options) }
-
- describe "#to_s" do
- it "returns a description" do
- expect(subject.to_s).to eq "https://github.com/foo/bar.git (at master)"
- end
-
- context "when the URI contains credentials" do
- let(:uri) { "https://my-secret-token:x-oauth-basic@github.com/foo/bar.git" }
-
- it "filters credentials" do
- expect(subject.to_s).to eq "https://x-oauth-basic@github.com/foo/bar.git (at master)"
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/source/path_spec.rb b/spec/bundler/bundler/source/path_spec.rb
deleted file mode 100644
index 1d13e03ec1..0000000000
--- a/spec/bundler/bundler/source/path_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Source::Path do
- before do
- allow(Bundler).to receive(:root) { Pathname.new("root") }
- end
-
- describe "#eql?" do
- subject { described_class.new("path" => "gems/a") }
-
- context "with two equivalent relative paths from different roots" do
- let(:a_gem_opts) { { "path" => "../gems/a", "root_path" => Bundler.root.join("nested") } }
- let(:a_gem) { described_class.new a_gem_opts }
-
- it "returns true" do
- expect(subject).to eq a_gem
- end
- end
-
- context "with the same (but not equivalent) relative path from different roots" do
- subject { described_class.new("path" => "gems/a") }
-
- let(:a_gem_opts) { { "path" => "gems/a", "root_path" => Bundler.root.join("nested") } }
- let(:a_gem) { described_class.new a_gem_opts }
-
- it "returns false" do
- expect(subject).to_not eq a_gem
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/source/rubygems/remote_spec.rb b/spec/bundler/bundler/source/rubygems/remote_spec.rb
deleted file mode 100644
index 07ce4f968e..0000000000
--- a/spec/bundler/bundler/source/rubygems/remote_spec.rb
+++ /dev/null
@@ -1,172 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/source/rubygems/remote"
-
-RSpec.describe Bundler::Source::Rubygems::Remote do
- def remote(uri)
- Bundler::Source::Rubygems::Remote.new(uri)
- end
-
- before do
- allow(Digest(:MD5)).to receive(:hexdigest).with(duck_type(:to_s)) {|string| "MD5HEX(#{string})" }
- end
-
- let(:uri_no_auth) { Bundler::URI("https://gems.example.com") }
- let(:uri_with_auth) { Bundler::URI("https://#{credentials}@gems.example.com") }
- let(:credentials) { "username:password" }
-
- context "when the original URI has no credentials" do
- describe "#uri" do
- it "returns the original URI" do
- expect(remote(uri_no_auth).uri).to eq(uri_no_auth)
- end
-
- it "applies configured credentials" do
- Bundler.settings.temporary(uri_no_auth.to_s => credentials) do
- expect(remote(uri_no_auth).uri).to eq(uri_with_auth)
- end
- end
- end
-
- describe "#anonymized_uri" do
- it "returns the original URI" do
- expect(remote(uri_no_auth).anonymized_uri).to eq(uri_no_auth)
- end
-
- it "does not apply given credentials" do
- Bundler.settings.temporary(uri_no_auth.to_s => credentials) do
- expect(remote(uri_no_auth).anonymized_uri).to eq(uri_no_auth)
- end
- end
- end
-
- describe "#cache_slug" do
- it "returns the correct slug" do
- expect(remote(uri_no_auth).cache_slug).to eq("gems.example.com.443.MD5HEX(gems.example.com.443./)")
- end
-
- it "only applies the given user" do
- Bundler.settings.temporary(uri_no_auth.to_s => credentials) do
- expect(remote(uri_no_auth).cache_slug).to eq("gems.example.com.username.443.MD5HEX(gems.example.com.username.443./)")
- end
- end
- end
- end
-
- context "when the original URI has a username and password" do
- describe "#uri" do
- it "returns the original URI" do
- expect(remote(uri_with_auth).uri).to eq(uri_with_auth)
- end
-
- it "does not apply configured credentials" do
- Bundler.settings.temporary(uri_no_auth.to_s => "other:stuff")
- expect(remote(uri_with_auth).uri).to eq(uri_with_auth)
- end
- end
-
- describe "#anonymized_uri" do
- it "returns the URI without username and password" do
- expect(remote(uri_with_auth).anonymized_uri).to eq(uri_no_auth)
- end
-
- it "does not apply given credentials" do
- Bundler.settings.temporary(uri_no_auth.to_s => "other:stuff")
- expect(remote(uri_with_auth).anonymized_uri).to eq(uri_no_auth)
- end
- end
-
- describe "#cache_slug" do
- it "returns the correct slug" do
- expect(remote(uri_with_auth).cache_slug).to eq("gems.example.com.username.443.MD5HEX(gems.example.com.username.443./)")
- end
-
- it "does not apply given credentials" do
- Bundler.settings.temporary(uri_with_auth.to_s => credentials)
- expect(remote(uri_with_auth).cache_slug).to eq("gems.example.com.username.443.MD5HEX(gems.example.com.username.443./)")
- end
- end
- end
-
- context "when the original URI has only a username" do
- let(:uri) { Bundler::URI("https://SeCrEt-ToKeN@gem.fury.io/me/") }
-
- describe "#anonymized_uri" do
- it "returns the URI without username and password" do
- expect(remote(uri).anonymized_uri).to eq(Bundler::URI("https://gem.fury.io/me/"))
- end
- end
-
- describe "#cache_slug" do
- it "returns the correct slug" do
- expect(remote(uri).cache_slug).to eq("gem.fury.io.SeCrEt-ToKeN.443.MD5HEX(gem.fury.io.SeCrEt-ToKeN.443./me/)")
- end
- end
- end
-
- context "when a mirror with inline credentials is configured for the URI" do
- let(:uri) { Bundler::URI("https://rubygems.org/") }
- let(:mirror_uri_with_auth) { Bundler::URI("https://username:password@rubygems-mirror.org/") }
- let(:mirror_uri_no_auth) { Bundler::URI("https://rubygems-mirror.org/") }
-
- before { Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_with_auth.to_s) }
-
- after { Bundler.settings.temporary("mirror.https://rubygems.org/" => nil) }
-
- specify "#uri returns the mirror URI with credentials" do
- expect(remote(uri).uri).to eq(mirror_uri_with_auth)
- end
-
- specify "#anonymized_uri returns the mirror URI without credentials" do
- expect(remote(uri).anonymized_uri).to eq(mirror_uri_no_auth)
- end
-
- specify "#original_uri returns the original source" do
- expect(remote(uri).original_uri).to eq(uri)
- end
-
- specify "#cache_slug returns the correct slug" do
- expect(remote(uri).cache_slug).to eq("rubygems.org.443.MD5HEX(rubygems.org.443./)")
- end
- end
-
- context "when a mirror with configured credentials is configured for the URI" do
- let(:uri) { Bundler::URI("https://rubygems.org/") }
- let(:mirror_uri_with_auth) { Bundler::URI("https://#{credentials}@rubygems-mirror.org/") }
- let(:mirror_uri_no_auth) { Bundler::URI("https://rubygems-mirror.org/") }
-
- before do
- Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_no_auth.to_s)
- Bundler.settings.temporary(mirror_uri_no_auth.to_s => credentials)
- end
-
- after do
- Bundler.settings.temporary("mirror.https://rubygems.org/" => nil)
- Bundler.settings.temporary(mirror_uri_no_auth.to_s => nil)
- end
-
- specify "#uri returns the mirror URI with credentials" do
- expect(remote(uri).uri).to eq(mirror_uri_with_auth)
- end
-
- specify "#anonymized_uri returns the mirror URI without credentials" do
- expect(remote(uri).anonymized_uri).to eq(mirror_uri_no_auth)
- end
-
- specify "#original_uri returns the original source" do
- expect(remote(uri).original_uri).to eq(uri)
- end
-
- specify "#cache_slug returns the original source" do
- expect(remote(uri).cache_slug).to eq("rubygems.org.443.MD5HEX(rubygems.org.443./)")
- end
- end
-
- context "when there is no mirror set" do
- describe "#original_uri" do
- it "is not set" do
- expect(remote(uri_no_auth).original_uri).to be_nil
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/source/rubygems_spec.rb b/spec/bundler/bundler/source/rubygems_spec.rb
deleted file mode 100644
index 7c457a7265..0000000000
--- a/spec/bundler/bundler/source/rubygems_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Source::Rubygems do
- before do
- allow(Bundler).to receive(:root) { Pathname.new("root") }
- end
-
- describe "caches" do
- it "includes Bundler.app_cache" do
- expect(subject.caches).to include(Bundler.app_cache)
- end
-
- it "includes GEM_PATH entries" do
- Gem.path.each do |path|
- expect(subject.caches).to include(File.expand_path("#{path}/cache"))
- end
- end
-
- it "is an array of strings or pathnames" do
- subject.caches.each do |cache|
- expect([String, Pathname]).to include(cache.class)
- end
- end
- end
-
- describe "#add_remote" do
- context "when the source is an HTTP(s) URI with no host" do
- it "raises error" do
- expect { subject.add_remote("https:rubygems.org") }.to raise_error(ArgumentError)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/source_list_spec.rb b/spec/bundler/bundler/source_list_spec.rb
deleted file mode 100644
index 93159998c6..0000000000
--- a/spec/bundler/bundler/source_list_spec.rb
+++ /dev/null
@@ -1,463 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::SourceList do
- before do
- allow(Bundler).to receive(:root) { Pathname.new "./tmp/bundled_app" }
-
- stub_const "ASourcePlugin", Class.new(Bundler::Plugin::API)
- ASourcePlugin.source "new_source"
- allow(Bundler::Plugin).to receive(:source?).with("new_source").and_return(true)
- end
-
- subject(:source_list) { Bundler::SourceList.new }
-
- let(:rubygems_aggregate) { Bundler::Source::Rubygems.new }
- let(:metadata_source) { Bundler::Source::Metadata.new }
-
- describe "adding sources" do
- before do
- source_list.add_path_source("path" => "/existing/path/to/gem")
- source_list.add_git_source("uri" => "git://existing-git.org/path.git")
- source_list.add_rubygems_source("remotes" => ["https://existing-rubygems.org"])
- source_list.add_plugin_source("new_source", "uri" => "https://some.url/a")
- end
-
- describe "#add_path_source" do
- before do
- @duplicate = source_list.add_path_source("path" => "/path/to/gem")
- @new_source = source_list.add_path_source("path" => "/path/to/gem")
- end
-
- it "returns the new path source" do
- expect(@new_source).to be_instance_of(Bundler::Source::Path)
- end
-
- it "passes the provided options to the new source" do
- expect(@new_source.options).to eq("path" => "/path/to/gem")
- end
-
- it "adds the source to the beginning of path_sources" do
- expect(source_list.path_sources.first).to equal(@new_source)
- end
-
- it "removes existing duplicates" do
- expect(source_list.path_sources).not_to include equal(@duplicate)
- end
- end
-
- describe "#add_git_source" do
- before do
- @duplicate = source_list.add_git_source("uri" => "git://host/path.git")
- @new_source = source_list.add_git_source("uri" => "git://host/path.git")
- end
-
- it "returns the new git source" do
- expect(@new_source).to be_instance_of(Bundler::Source::Git)
- end
-
- it "passes the provided options to the new source" do
- @new_source = source_list.add_git_source("uri" => "git://host/path.git")
- expect(@new_source.options).to eq("uri" => "git://host/path.git")
- end
-
- it "adds the source to the beginning of git_sources" do
- @new_source = source_list.add_git_source("uri" => "git://host/path.git")
- expect(source_list.git_sources.first).to equal(@new_source)
- end
-
- it "removes existing duplicates" do
- @duplicate = source_list.add_git_source("uri" => "git://host/path.git")
- @new_source = source_list.add_git_source("uri" => "git://host/path.git")
- expect(source_list.git_sources).not_to include equal(@duplicate)
- end
-
- context "with the git: protocol" do
- let(:msg) do
- "The git source `git://existing-git.org/path.git` " \
- "uses the `git` protocol, which transmits data without encryption. " \
- "Disable this warning with `bundle config set git.allow_insecure true`, " \
- "or switch to the `https` protocol to keep your data secure."
- end
-
- it "warns about git protocols" do
- expect(Bundler.ui).to receive(:warn).with(msg)
- source_list.add_git_source("uri" => "git://existing-git.org/path.git")
- end
-
- it "ignores git protocols on request" do
- Bundler.settings.temporary(:"git.allow_insecure" => true)
- expect(Bundler.ui).to_not receive(:warn).with(msg)
- source_list.add_git_source("uri" => "git://existing-git.org/path.git")
- end
- end
- end
-
- describe "#add_rubygems_source" do
- before do
- @duplicate = source_list.add_rubygems_source("remotes" => ["https://rubygems.org/"])
- @new_source = source_list.add_rubygems_source("remotes" => ["https://rubygems.org/"])
- end
-
- it "returns the new rubygems source" do
- expect(@new_source).to be_instance_of(Bundler::Source::Rubygems)
- end
-
- it "passes the provided options to the new source" do
- expect(@new_source.options).to eq("remotes" => ["https://rubygems.org/"])
- end
-
- it "adds the source to the beginning of rubygems_sources" do
- expect(source_list.rubygems_sources.first).to equal(@new_source)
- end
-
- it "removes duplicates" do
- expect(source_list.rubygems_sources).not_to include equal(@duplicate)
- end
- end
-
- describe "#add_rubygems_remote", :bundler => "< 3" do
- let!(:returned_source) { source_list.add_rubygems_remote("https://rubygems.org/") }
-
- it "returns the aggregate rubygems source" do
- expect(returned_source).to be_instance_of(Bundler::Source::Rubygems)
- end
-
- it "adds the provided remote to the beginning of the aggregate source" do
- source_list.add_rubygems_remote("https://othersource.org")
- expect(returned_source.remotes).to eq [
- Bundler::URI("https://othersource.org/"),
- Bundler::URI("https://rubygems.org/"),
- ]
- end
- end
-
- describe "#add_plugin_source" do
- before do
- @duplicate = source_list.add_plugin_source("new_source", "uri" => "http://host/path.")
- @new_source = source_list.add_plugin_source("new_source", "uri" => "http://host/path.")
- end
-
- it "returns the new plugin source" do
- expect(@new_source).to be_a(Bundler::Plugin::API::Source)
- end
-
- it "passes the provided options to the new source" do
- expect(@new_source.options).to eq("uri" => "http://host/path.")
- end
-
- it "adds the source to the beginning of git_sources" do
- expect(source_list.plugin_sources.first).to equal(@new_source)
- end
-
- it "removes existing duplicates" do
- expect(source_list.plugin_sources).not_to include equal(@duplicate)
- end
- end
- end
-
- describe "#all_sources" do
- it "includes the aggregate rubygems source when rubygems sources have been added" do
- source_list.add_git_source("uri" => "git://host/path.git")
- source_list.add_rubygems_source("remotes" => ["https://rubygems.org"])
- source_list.add_path_source("path" => "/path/to/gem")
- source_list.add_plugin_source("new_source", "uri" => "https://some.url/a")
-
- expect(source_list.all_sources).to include rubygems_aggregate
- end
-
- it "includes the aggregate rubygems source when no rubygems sources have been added" do
- source_list.add_git_source("uri" => "git://host/path.git")
- source_list.add_path_source("path" => "/path/to/gem")
- source_list.add_plugin_source("new_source", "uri" => "https://some.url/a")
-
- expect(source_list.all_sources).to include rubygems_aggregate
- end
-
- it "returns sources of the same type in the reverse order that they were added" do
- source_list.add_git_source("uri" => "git://third-git.org/path.git")
- source_list.add_rubygems_source("remotes" => ["https://fifth-rubygems.org"])
- source_list.add_path_source("path" => "/third/path/to/gem")
- source_list.add_plugin_source("new_source", "uri" => "https://some.url/b")
- source_list.add_rubygems_source("remotes" => ["https://fourth-rubygems.org"])
- source_list.add_path_source("path" => "/second/path/to/gem")
- source_list.add_rubygems_source("remotes" => ["https://third-rubygems.org"])
- source_list.add_plugin_source("new_source", "uri" => "https://some.o.url/")
- source_list.add_git_source("uri" => "git://second-git.org/path.git")
- source_list.add_rubygems_source("remotes" => ["https://second-rubygems.org"])
- source_list.add_path_source("path" => "/first/path/to/gem")
- source_list.add_plugin_source("new_source", "uri" => "https://some.url/c")
- source_list.add_rubygems_source("remotes" => ["https://first-rubygems.org"])
- source_list.add_git_source("uri" => "git://first-git.org/path.git")
-
- expect(source_list.all_sources).to eq [
- Bundler::Source::Path.new("path" => "/first/path/to/gem"),
- Bundler::Source::Path.new("path" => "/second/path/to/gem"),
- Bundler::Source::Path.new("path" => "/third/path/to/gem"),
- Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://third-git.org/path.git"),
- ASourcePlugin.new("uri" => "https://some.url/c"),
- ASourcePlugin.new("uri" => "https://some.o.url/"),
- ASourcePlugin.new("uri" => "https://some.url/b"),
- Bundler::Source::Rubygems.new("remotes" => ["https://first-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://second-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://third-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://fourth-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://fifth-rubygems.org"]),
- rubygems_aggregate,
- metadata_source,
- ]
- end
- end
-
- describe "#path_sources" do
- it "returns an empty array when no path sources have been added" do
- source_list.add_rubygems_remote("https://rubygems.org")
- source_list.add_git_source("uri" => "git://host/path.git")
- expect(source_list.path_sources).to be_empty
- end
-
- it "returns path sources in the reverse order that they were added" do
- source_list.add_git_source("uri" => "git://third-git.org/path.git")
- source_list.add_rubygems_remote("https://fifth-rubygems.org")
- source_list.add_path_source("path" => "/third/path/to/gem")
- source_list.add_rubygems_remote("https://fourth-rubygems.org")
- source_list.add_path_source("path" => "/second/path/to/gem")
- source_list.add_rubygems_remote("https://third-rubygems.org")
- source_list.add_git_source("uri" => "git://second-git.org/path.git")
- source_list.add_rubygems_remote("https://second-rubygems.org")
- source_list.add_path_source("path" => "/first/path/to/gem")
- source_list.add_rubygems_remote("https://first-rubygems.org")
- source_list.add_git_source("uri" => "git://first-git.org/path.git")
-
- expect(source_list.path_sources).to eq [
- Bundler::Source::Path.new("path" => "/first/path/to/gem"),
- Bundler::Source::Path.new("path" => "/second/path/to/gem"),
- Bundler::Source::Path.new("path" => "/third/path/to/gem"),
- ]
- end
- end
-
- describe "#git_sources" do
- it "returns an empty array when no git sources have been added" do
- source_list.add_rubygems_remote("https://rubygems.org")
- source_list.add_path_source("path" => "/path/to/gem")
-
- expect(source_list.git_sources).to be_empty
- end
-
- it "returns git sources in the reverse order that they were added" do
- source_list.add_git_source("uri" => "git://third-git.org/path.git")
- source_list.add_rubygems_remote("https://fifth-rubygems.org")
- source_list.add_path_source("path" => "/third/path/to/gem")
- source_list.add_rubygems_remote("https://fourth-rubygems.org")
- source_list.add_path_source("path" => "/second/path/to/gem")
- source_list.add_rubygems_remote("https://third-rubygems.org")
- source_list.add_git_source("uri" => "git://second-git.org/path.git")
- source_list.add_rubygems_remote("https://second-rubygems.org")
- source_list.add_path_source("path" => "/first/path/to/gem")
- source_list.add_rubygems_remote("https://first-rubygems.org")
- source_list.add_git_source("uri" => "git://first-git.org/path.git")
-
- expect(source_list.git_sources).to eq [
- Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://third-git.org/path.git"),
- ]
- end
- end
-
- describe "#plugin_sources" do
- it "returns an empty array when no plugin sources have been added" do
- source_list.add_rubygems_remote("https://rubygems.org")
- source_list.add_path_source("path" => "/path/to/gem")
-
- expect(source_list.plugin_sources).to be_empty
- end
-
- it "returns plugin sources in the reverse order that they were added" do
- source_list.add_plugin_source("new_source", "uri" => "https://third-git.org/path.git")
- source_list.add_git_source("https://new-git.org")
- source_list.add_path_source("path" => "/third/path/to/gem")
- source_list.add_rubygems_remote("https://fourth-rubygems.org")
- source_list.add_path_source("path" => "/second/path/to/gem")
- source_list.add_rubygems_remote("https://third-rubygems.org")
- source_list.add_plugin_source("new_source", "uri" => "git://second-git.org/path.git")
- source_list.add_rubygems_remote("https://second-rubygems.org")
- source_list.add_path_source("path" => "/first/path/to/gem")
- source_list.add_rubygems_remote("https://first-rubygems.org")
- source_list.add_plugin_source("new_source", "uri" => "git://first-git.org/path.git")
-
- expect(source_list.plugin_sources).to eq [
- ASourcePlugin.new("uri" => "git://first-git.org/path.git"),
- ASourcePlugin.new("uri" => "git://second-git.org/path.git"),
- ASourcePlugin.new("uri" => "https://third-git.org/path.git"),
- ]
- end
- end
-
- describe "#rubygems_sources" do
- it "includes the aggregate rubygems source when rubygems sources have been added" do
- source_list.add_git_source("uri" => "git://host/path.git")
- source_list.add_rubygems_source("remotes" => ["https://rubygems.org"])
- source_list.add_path_source("path" => "/path/to/gem")
-
- expect(source_list.rubygems_sources).to include rubygems_aggregate
- end
-
- it "returns only the aggregate rubygems source when no rubygems sources have been added" do
- source_list.add_git_source("uri" => "git://host/path.git")
- source_list.add_path_source("path" => "/path/to/gem")
-
- expect(source_list.rubygems_sources).to eq [rubygems_aggregate]
- end
-
- it "returns rubygems sources in the reverse order that they were added" do
- source_list.add_git_source("uri" => "git://third-git.org/path.git")
- source_list.add_rubygems_source("remotes" => ["https://fifth-rubygems.org"])
- source_list.add_path_source("path" => "/third/path/to/gem")
- source_list.add_rubygems_source("remotes" => ["https://fourth-rubygems.org"])
- source_list.add_path_source("path" => "/second/path/to/gem")
- source_list.add_rubygems_source("remotes" => ["https://third-rubygems.org"])
- source_list.add_git_source("uri" => "git://second-git.org/path.git")
- source_list.add_rubygems_source("remotes" => ["https://second-rubygems.org"])
- source_list.add_path_source("path" => "/first/path/to/gem")
- source_list.add_rubygems_source("remotes" => ["https://first-rubygems.org"])
- source_list.add_git_source("uri" => "git://first-git.org/path.git")
-
- expect(source_list.rubygems_sources).to eq [
- Bundler::Source::Rubygems.new("remotes" => ["https://first-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://second-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://third-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://fourth-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://fifth-rubygems.org"]),
- rubygems_aggregate,
- ]
- end
- end
-
- describe "#get" do
- context "when it includes an equal source" do
- let(:rubygems_source) { Bundler::Source::Rubygems.new("remotes" => ["https://rubygems.org"]) }
- before { @equal_source = source_list.add_rubygems_remote("https://rubygems.org") }
-
- it "returns the equal source" do
- expect(source_list.get(rubygems_source)).to be @equal_source
- end
- end
-
- context "when it does not include an equal source" do
- let(:path_source) { Bundler::Source::Path.new("path" => "/path/to/gem") }
-
- it "returns nil" do
- expect(source_list.get(path_source)).to be_nil
- end
- end
- end
-
- describe "#lock_sources" do
- before do
- source_list.add_git_source("uri" => "git://third-git.org/path.git")
- source_list.add_rubygems_source("remotes" => ["https://duplicate-rubygems.org"])
- source_list.add_plugin_source("new_source", "uri" => "https://third-bar.org/foo")
- source_list.add_path_source("path" => "/third/path/to/gem")
- source_list.add_rubygems_source("remotes" => ["https://third-rubygems.org"])
- source_list.add_path_source("path" => "/second/path/to/gem")
- source_list.add_rubygems_source("remotes" => ["https://second-rubygems.org"])
- source_list.add_git_source("uri" => "git://second-git.org/path.git")
- source_list.add_rubygems_source("remotes" => ["https://first-rubygems.org"])
- source_list.add_plugin_source("new_source", "uri" => "https://second-plugin.org/random")
- source_list.add_path_source("path" => "/first/path/to/gem")
- source_list.add_rubygems_source("remotes" => ["https://duplicate-rubygems.org"])
- source_list.add_git_source("uri" => "git://first-git.org/path.git")
- end
-
- it "combines the rubygems sources into a single instance, removing duplicate remotes from the end", :bundler => "< 3" do
- expect(source_list.lock_sources).to eq [
- Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://third-git.org/path.git"),
- ASourcePlugin.new("uri" => "https://second-plugin.org/random"),
- ASourcePlugin.new("uri" => "https://third-bar.org/foo"),
- Bundler::Source::Path.new("path" => "/first/path/to/gem"),
- Bundler::Source::Path.new("path" => "/second/path/to/gem"),
- Bundler::Source::Path.new("path" => "/third/path/to/gem"),
- Bundler::Source::Rubygems.new("remotes" => [
- "https://duplicate-rubygems.org",
- "https://first-rubygems.org",
- "https://second-rubygems.org",
- "https://third-rubygems.org",
- ]),
- ]
- end
-
- it "returns all sources, without combining rubygems sources", :bundler => "3" do
- expect(source_list.lock_sources).to eq [
- Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"),
- Bundler::Source::Git.new("uri" => "git://third-git.org/path.git"),
- ASourcePlugin.new("uri" => "https://second-plugin.org/random"),
- ASourcePlugin.new("uri" => "https://third-bar.org/foo"),
- Bundler::Source::Path.new("path" => "/first/path/to/gem"),
- Bundler::Source::Path.new("path" => "/second/path/to/gem"),
- Bundler::Source::Path.new("path" => "/third/path/to/gem"),
- Bundler::Source::Rubygems.new,
- Bundler::Source::Rubygems.new("remotes" => ["https://duplicate-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://first-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://second-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://third-rubygems.org"]),
- ]
- end
- end
-
- describe "replace_sources!" do
- let(:existing_locked_source) { Bundler::Source::Path.new("path" => "/existing/path") }
- let(:removed_locked_source) { Bundler::Source::Path.new("path" => "/removed/path") }
-
- let(:locked_sources) { [existing_locked_source, removed_locked_source] }
-
- before do
- @existing_source = source_list.add_path_source("path" => "/existing/path")
- @new_source = source_list.add_path_source("path" => "/new/path")
- source_list.replace_sources!(locked_sources)
- end
-
- it "maintains the order and number of sources" do
- expect(source_list.path_sources).to eq [@new_source, @existing_source]
- end
-
- it "retains the same instance of the new source" do
- expect(source_list.path_sources[0]).to be @new_source
- end
-
- it "replaces the instance of the existing source" do
- expect(source_list.path_sources[1]).to be existing_locked_source
- end
- end
-
- describe "#cached!" do
- let(:rubygems_source) { source_list.add_rubygems_source("remotes" => ["https://rubygems.org"]) }
- let(:git_source) { source_list.add_git_source("uri" => "git://host/path.git") }
- let(:path_source) { source_list.add_path_source("path" => "/path/to/gem") }
-
- it "calls #cached! on all the sources" do
- expect(rubygems_source).to receive(:cached!)
- expect(git_source).to receive(:cached!)
- expect(path_source).to receive(:cached!)
- source_list.cached!
- end
- end
-
- describe "#remote!" do
- let(:rubygems_source) { source_list.add_rubygems_source("remotes" => ["https://rubygems.org"]) }
- let(:git_source) { source_list.add_git_source("uri" => "git://host/path.git") }
- let(:path_source) { source_list.add_path_source("path" => "/path/to/gem") }
-
- it "calls #remote! on all the sources" do
- expect(rubygems_source).to receive(:remote!)
- expect(git_source).to receive(:remote!)
- expect(path_source).to receive(:remote!)
- source_list.remote!
- end
- end
-end
diff --git a/spec/bundler/bundler/source_spec.rb b/spec/bundler/bundler/source_spec.rb
deleted file mode 100644
index 0c35c27fdf..0000000000
--- a/spec/bundler/bundler/source_spec.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::Source do
- class ExampleSource < Bundler::Source
- end
-
- subject { ExampleSource.new }
-
- describe "#unmet_deps" do
- let(:specs) { double(:specs) }
- let(:unmet_dependency_names) { double(:unmet_dependency_names) }
-
- before do
- allow(subject).to receive(:specs).and_return(specs)
- allow(specs).to receive(:unmet_dependency_names).and_return(unmet_dependency_names)
- end
-
- it "should return the names of unmet dependencies" do
- expect(subject.unmet_deps).to eq(unmet_dependency_names)
- end
- end
-
- describe "#version_message" do
- let(:spec) { double(:spec, :name => "nokogiri", :version => ">= 1.6", :platform => rb) }
-
- shared_examples_for "the lockfile specs are not relevant" do
- it "should return a string with the spec name and version" do
- expect(subject.version_message(spec)).to eq("nokogiri >= 1.6")
- end
- end
-
- context "when there are locked gems" do
- let(:locked_gems) { double(:locked_gems) }
-
- before { allow(Bundler).to receive(:locked_gems).and_return(locked_gems) }
-
- context "that contain the relevant gem spec" do
- before do
- specs = double(:specs)
- allow(locked_gems).to receive(:specs).and_return(specs)
- allow(specs).to receive(:find).and_return(locked_gem)
- end
-
- context "without a version" do
- let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => nil) }
-
- it_behaves_like "the lockfile specs are not relevant"
- end
-
- context "with the same version" do
- let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => ">= 1.6") }
-
- it_behaves_like "the lockfile specs are not relevant"
- end
-
- context "with a different version" do
- let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => "< 1.5") }
-
- context "with color", :no_color_tty do
- before do
- allow($stdout).to receive(:tty?).and_return(true)
- end
-
- it "should return a string with the spec name and version and locked spec version" do
- expect(subject.version_message(spec)).to eq("nokogiri >= 1.6\e[32m (was < 1.5)\e[0m")
- end
- end
-
- context "without color" do
- around do |example|
- with_ui(Bundler::UI::Shell.new("no-color" => true)) do
- example.run
- end
- end
-
- it "should return a string with the spec name and version and locked spec version" do
- expect(subject.version_message(spec)).to eq("nokogiri >= 1.6 (was < 1.5)")
- end
- end
- end
-
- context "with a more recent version" do
- let(:spec) { double(:spec, :name => "nokogiri", :version => "1.6.1", :platform => rb) }
- let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => "1.7.0") }
-
- context "with color", :no_color_tty do
- before do
- allow($stdout).to receive(:tty?).and_return(true)
- end
-
- it "should return a string with the locked spec version in yellow" do
- expect(subject.version_message(spec)).to eq("nokogiri 1.6.1\e[33m (was 1.7.0)\e[0m")
- end
- end
-
- context "without color" do
- around do |example|
- with_ui(Bundler::UI::Shell.new("no-color" => true)) do
- example.run
- end
- end
-
- it "should return a string with the locked spec version in yellow" do
- expect(subject.version_message(spec)).to eq("nokogiri 1.6.1 (was 1.7.0)")
- end
- end
- end
-
- context "with an older version" do
- let(:spec) { double(:spec, :name => "nokogiri", :version => "1.7.1", :platform => rb) }
- let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => "1.7.0") }
-
- context "with color", :no_color_tty do
- before do
- allow($stdout).to receive(:tty?).and_return(true)
- end
-
- it "should return a string with the locked spec version in green" do
- expect(subject.version_message(spec)).to eq("nokogiri 1.7.1\e[32m (was 1.7.0)\e[0m")
- end
- end
-
- context "without color" do
- around do |example|
- with_ui(Bundler::UI::Shell.new("no-color" => true)) do
- example.run
- end
- end
-
- it "should return a string with the locked spec version in yellow" do
- expect(subject.version_message(spec)).to eq("nokogiri 1.7.1 (was 1.7.0)")
- end
- end
- end
- end
-
- context "that do not contain the relevant gem spec" do
- before do
- specs = double(:specs)
- allow(locked_gems).to receive(:specs).and_return(specs)
- allow(specs).to receive(:find).and_return(nil)
- end
-
- it_behaves_like "the lockfile specs are not relevant"
- end
- end
-
- context "when there are no locked gems" do
- before { allow(Bundler).to receive(:locked_gems).and_return(nil) }
-
- it_behaves_like "the lockfile specs are not relevant"
- end
- end
-
- describe "#can_lock?" do
- context "when the passed spec's source is equivalent" do
- let(:spec) { double(:spec, :source => subject) }
-
- it "should return true" do
- expect(subject.can_lock?(spec)).to be_truthy
- end
- end
-
- context "when the passed spec's source is not equivalent" do
- let(:spec) { double(:spec, :source => double(:other_source)) }
-
- it "should return false" do
- expect(subject.can_lock?(spec)).to be_falsey
- end
- end
- end
-
- describe "#include?" do
- context "when the passed source is equivalent" do
- let(:source) { subject }
-
- it "should return true" do
- expect(subject).to include(source)
- end
- end
-
- context "when the passed source is not equivalent" do
- let(:source) { double(:source) }
-
- it "should return false" do
- expect(subject).to_not include(source)
- end
- end
- end
-
-private
-
- def with_ui(ui)
- old_ui = Bundler.ui
- Bundler.ui = ui
- yield
- ensure
- Bundler.ui = old_ui
- end
-end
diff --git a/spec/bundler/bundler/spec_set_spec.rb b/spec/bundler/bundler/spec_set_spec.rb
deleted file mode 100644
index 6fedd38b50..0000000000
--- a/spec/bundler/bundler/spec_set_spec.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::SpecSet do
- let(:specs) do
- [
- build_spec("a", "1.0"),
- build_spec("b", "1.0"),
- build_spec("c", "1.1") do |s|
- s.dep "a", "< 2.0"
- s.dep "e", "> 0"
- end,
- build_spec("d", "2.0") do |s|
- s.dep "a", "1.0"
- s.dep "c", "~> 1.0"
- end,
- build_spec("e", "1.0.0.pre.1"),
- ].flatten
- end
-
- subject { described_class.new(specs) }
-
- context "enumerable methods" do
- it "has a length" do
- expect(subject.length).to eq(5)
- end
-
- it "has a size" do
- expect(subject.size).to eq(5)
- end
- end
-
- describe "#find_by_name_and_platform" do
- let(:platform) { Gem::Platform.new("universal-darwin-64") }
- let(:platform_spec) { build_spec("b", "2.0", platform).first }
- let(:specs) do
- [
- build_spec("a", "1.0"),
- platform_spec,
- ].flatten
- end
-
- it "finds spec with given name and platform" do
- spec = described_class.new(specs).find_by_name_and_platform("b", platform)
- expect(spec).to eq platform_spec
- end
- end
-
- describe "#merge" do
- let(:other_specs) do
- [
- build_spec("f", "1.0"),
- build_spec("g", "2.0"),
- ].flatten
- end
-
- let(:other_spec_set) { described_class.new(other_specs) }
-
- it "merges the items in each gemspec" do
- new_spec_set = subject.merge(other_spec_set)
- specs = new_spec_set.to_a.map(&:full_name)
- expect(specs).to include("a-1.0")
- expect(specs).to include("f-1.0")
- end
- end
-
- describe "#to_a" do
- it "returns the specs in order" do
- expect(subject.to_a.map(&:full_name)).to eq %w[
- a-1.0
- b-1.0
- e-1.0.0.pre.1
- c-1.1
- d-2.0
- ]
- end
- end
-end
diff --git a/spec/bundler/bundler/stub_specification_spec.rb b/spec/bundler/bundler/stub_specification_spec.rb
deleted file mode 100644
index 7495b5d661..0000000000
--- a/spec/bundler/bundler/stub_specification_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::StubSpecification do
- let(:gemspec) do
- Gem::Specification.new do |s|
- s.name = "gemname"
- s.version = "1.0.0"
- s.loaded_from = __FILE__
- end
- end
-
- let(:with_bundler_stub_spec) do
- described_class.from_stub(gemspec)
- end
-
- describe "#from_stub" do
- it "returns the same stub if already a Bundler::StubSpecification" do
- stub = described_class.from_stub(with_bundler_stub_spec)
- expect(stub).to be(with_bundler_stub_spec)
- end
- end
-end
diff --git a/spec/bundler/bundler/ui/shell_spec.rb b/spec/bundler/bundler/ui/shell_spec.rb
deleted file mode 100644
index 536014c6aa..0000000000
--- a/spec/bundler/bundler/ui/shell_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../../support/streams"
-
-RSpec.describe Bundler::UI::Shell do
- subject { described_class.new }
-
- before { subject.level = "debug" }
-
- describe "#info" do
- before { subject.level = "info" }
- it "prints to stdout" do
- expect { subject.info("info") }.to output("info\n").to_stdout
- end
- end
-
- describe "#confirm" do
- before { subject.level = "confirm" }
- it "prints to stdout" do
- expect { subject.confirm("confirm") }.to output("confirm\n").to_stdout
- end
- end
-
- describe "#warn" do
- before { subject.level = "warn" }
- it "prints to stderr" do
- expect { subject.warn("warning") }.to output("warning\n").to_stderr
- end
- end
-
- describe "#debug" do
- it "prints to stdout" do
- expect { subject.debug("debug") }.to output("debug\n").to_stdout
- end
- end
-
- describe "#error" do
- before { subject.level = "error" }
-
- it "prints to stderr" do
- expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
- end
-
- context "when stderr is closed" do
- it "doesn't report anything" do
- output = capture(:stderr, :closed => true) do
- subject.error("Something went wrong")
- end
- expect(output).to_not eq("Something went wrong\n")
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/ui_spec.rb b/spec/bundler/bundler/ui_spec.rb
deleted file mode 100644
index 6df0d2e290..0000000000
--- a/spec/bundler/bundler/ui_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::UI do
- describe Bundler::UI::Silent do
- it "has the same instance methods as Shell" do
- shell = Bundler::UI::Shell
- methods = proc do |cls|
- cls.instance_methods.map do |i|
- m = shell.instance_method(i)
- [i, m.parameters]
- end.sort_by(&:first)
- end
- expect(methods.call(described_class)).to eq(methods.call(shell))
- end
-
- it "has the same instance class as Shell" do
- shell = Bundler::UI::Shell
- methods = proc do |cls|
- cls.methods.map do |i|
- m = shell.method(i)
- [i, m.parameters]
- end.sort_by(&:first)
- end
- expect(methods.call(described_class)).to eq(methods.call(shell))
- end
- end
-
- describe Bundler::UI::Shell do
- let(:options) { {} }
- subject { described_class.new(options) }
- describe "debug?" do
- it "returns a boolean" do
- subject.level = :debug
- expect(subject.debug?).to eq(true)
-
- subject.level = :error
- expect(subject.debug?).to eq(false)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/uri_credentials_filter_spec.rb b/spec/bundler/bundler/uri_credentials_filter_spec.rb
deleted file mode 100644
index 466c1b8594..0000000000
--- a/spec/bundler/bundler/uri_credentials_filter_spec.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::URICredentialsFilter do
- subject { described_class }
-
- describe "#credential_filtered_uri" do
- shared_examples_for "original type of uri is maintained" do
- it "maintains same type for return value as uri input type" do
- expect(subject.credential_filtered_uri(uri)).to be_kind_of(uri.class)
- end
- end
-
- shared_examples_for "sensitive credentials in uri are filtered out" do
- context "authentication using oauth credentials" do
- context "specified via 'x-oauth-basic'" do
- let(:credentials) { "oauth_token:x-oauth-basic@" }
-
- it "returns the uri without the oauth token" do
- expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://x-oauth-basic@github.com/company/private-repo").to_s)
- end
-
- it_behaves_like "original type of uri is maintained"
- end
-
- context "specified via 'x'" do
- let(:credentials) { "oauth_token:x@" }
-
- it "returns the uri without the oauth token" do
- expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://x@github.com/company/private-repo").to_s)
- end
-
- it_behaves_like "original type of uri is maintained"
- end
- end
-
- context "authentication using login credentials" do
- let(:credentials) { "username1:hunter3@" }
-
- it "returns the uri without the password" do
- expect(subject.credential_filtered_uri(uri).to_s).to eq(Bundler::URI("https://username1@github.com/company/private-repo").to_s)
- end
-
- it_behaves_like "original type of uri is maintained"
- end
-
- context "authentication without credentials" do
- let(:credentials) { "" }
-
- it "returns the same uri" do
- expect(subject.credential_filtered_uri(uri).to_s).to eq(uri.to_s)
- end
-
- it_behaves_like "original type of uri is maintained"
- end
- end
-
- context "uri is a uri object" do
- let(:uri) { Bundler::URI("https://#{credentials}github.com/company/private-repo") }
-
- it_behaves_like "sensitive credentials in uri are filtered out"
- end
-
- context "uri is a uri string" do
- let(:uri) { "https://#{credentials}github.com/company/private-repo" }
-
- it_behaves_like "sensitive credentials in uri are filtered out"
- end
-
- context "uri is a non-uri format string (ex. path)" do
- let(:uri) { "/path/to/repo" }
-
- it "returns the same uri" do
- expect(subject.credential_filtered_uri(uri).to_s).to eq(uri.to_s)
- end
-
- it_behaves_like "original type of uri is maintained"
- end
-
- context "uri is nil" do
- let(:uri) { nil }
-
- it "returns nil" do
- expect(subject.credential_filtered_uri(uri)).to be_nil
- end
-
- it_behaves_like "original type of uri is maintained"
- end
- end
-
- describe "#credential_filtered_string" do
- let(:str_to_filter) { "This is a git message containing a uri #{uri}!" }
- let(:credentials) { "" }
- let(:uri) { Bundler::URI("https://#{credentials}github.com/company/private-repo") }
-
- context "with a uri that contains credentials" do
- let(:credentials) { "oauth_token:x-oauth-basic@" }
-
- it "returns the string without the sensitive credentials" do
- expect(subject.credential_filtered_string(str_to_filter, uri)).to eq(
- "This is a git message containing a uri https://x-oauth-basic@github.com/company/private-repo!"
- )
- end
- end
-
- context "that does not contains credentials" do
- it "returns the same string" do
- expect(subject.credential_filtered_string(str_to_filter, uri)).to eq(str_to_filter)
- end
- end
-
- context "string to filter is nil" do
- let(:str_to_filter) { nil }
-
- it "returns nil" do
- expect(subject.credential_filtered_string(str_to_filter, uri)).to be_nil
- end
- end
-
- context "uri to filter out is nil" do
- let(:uri) { nil }
-
- it "returns the same string" do
- expect(subject.credential_filtered_string(str_to_filter, uri)).to eq(str_to_filter)
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/vendored_persistent_spec.rb b/spec/bundler/bundler/vendored_persistent_spec.rb
deleted file mode 100644
index 3ed899dbcf..0000000000
--- a/spec/bundler/bundler/vendored_persistent_spec.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/vendored_persistent"
-
-RSpec.describe Bundler::PersistentHTTP do
- describe "#warn_old_tls_version_rubygems_connection" do
- let(:uri) { "https://index.rubygems.org" }
- let(:connection) { instance_double(Bundler::Persistent::Net::HTTP::Persistent::Connection) }
- let(:tls_version) { "TLSv1.2" }
- let(:socket) { double("Socket") }
- let(:socket_io) { double("SocketIO") }
-
- before do
- allow(connection).to receive_message_chain(:http, :use_ssl?).and_return(!tls_version.nil?)
- allow(socket).to receive(:io).and_return(socket_io) if socket
- connection.instance_variable_set(:@socket, socket)
-
- if tls_version
- allow(socket_io).to receive(:ssl_version).and_return(tls_version)
- end
- end
-
- shared_examples_for "does not warn" do
- it "does not warn" do
- allow(Bundler.ui).to receive(:warn).never
- subject.warn_old_tls_version_rubygems_connection(Bundler::URI(uri), connection)
- end
- end
-
- shared_examples_for "does warn" do |*expected|
- it "warns" do
- expect(Bundler.ui).to receive(:warn).with(*expected)
- subject.warn_old_tls_version_rubygems_connection(Bundler::URI(uri), connection)
- end
- end
-
- context "an HTTPS uri with TLSv1.2" do
- include_examples "does not warn"
- end
-
- context "without SSL" do
- let(:tls_version) { nil }
-
- include_examples "does not warn"
- end
-
- context "without a socket" do
- let(:socket) { nil }
-
- include_examples "does not warn"
- end
-
- context "with a different TLD" do
- let(:uri) { "https://foo.bar" }
- include_examples "does not warn"
-
- context "and an outdated TLS version" do
- let(:tls_version) { "TLSv1" }
- include_examples "does not warn"
- end
- end
-
- context "with a nonsense TLS version" do
- let(:tls_version) { "BlahBlah2.0Blah" }
- include_examples "does not warn"
- end
-
- context "with an outdated TLS version" do
- let(:tls_version) { "TLSv1" }
- include_examples "does warn",
- "Warning: Your Ruby version is compiled against a copy of OpenSSL that is very old. " \
- "Starting in January 2018, RubyGems.org will refuse connection requests from these very old versions of OpenSSL. " \
- "If you will need to continue installing gems after January 2018, please follow this guide to upgrade: http://ruby.to/tls-outdated.",
- :wrap => true
- end
- end
-end
diff --git a/spec/bundler/bundler/version_ranges_spec.rb b/spec/bundler/bundler/version_ranges_spec.rb
deleted file mode 100644
index bca044b0c0..0000000000
--- a/spec/bundler/bundler/version_ranges_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/version_ranges"
-
-RSpec.describe Bundler::VersionRanges do
- describe ".empty?" do
- shared_examples_for "empty?" do |exp, *req|
- it "returns #{exp} for #{req}" do
- r = Gem::Requirement.new(*req)
- ranges = described_class.for(r)
- expect(described_class.empty?(*ranges)).to eq(exp), "expected `#{r}` #{exp ? "" : "not "}to be empty"
- end
- end
-
- include_examples "empty?", false
- include_examples "empty?", false, "!= 1"
- include_examples "empty?", false, "!= 1", "= 2"
- include_examples "empty?", false, "!= 1", "> 1"
- include_examples "empty?", false, "!= 1", ">= 1"
- include_examples "empty?", false, "= 1", ">= 0.1", "<= 1.1"
- include_examples "empty?", false, "= 1", ">= 1", "<= 1"
- include_examples "empty?", false, "= 1", "~> 1"
- include_examples "empty?", false, ">= 0.z", "= 0"
- include_examples "empty?", false, ">= 0"
- include_examples "empty?", false, ">= 1.0.0", "< 2.0.0"
- include_examples "empty?", false, "~> 1"
- include_examples "empty?", false, "~> 2.0", "~> 2.1"
- include_examples "empty?", true, ">= 4.1.0", "< 5.0", "= 5.2.1"
- include_examples "empty?", true, "< 5.0", "< 5.3", "< 6.0", "< 6", "= 5.2.0", "> 2", ">= 3.0", ">= 3.1", ">= 3.2", ">= 4.0.0", ">= 4.1.0", ">= 4.2.0", ">= 4.2", ">= 4"
- include_examples "empty?", true, "!= 1", "< 2", "> 2"
- include_examples "empty?", true, "!= 1", "<= 1", ">= 1"
- include_examples "empty?", true, "< 2", "> 2"
- include_examples "empty?", true, "< 2", "> 2", "= 2"
- include_examples "empty?", true, "= 1", "!= 1"
- include_examples "empty?", true, "= 1", "= 2"
- include_examples "empty?", true, "= 1", "~> 2"
- include_examples "empty?", true, ">= 0", "<= 0.a"
- include_examples "empty?", true, "~> 2.0", "~> 3"
- end
-end
diff --git a/spec/bundler/bundler/worker_spec.rb b/spec/bundler/bundler/worker_spec.rb
deleted file mode 100644
index 2e5642709d..0000000000
--- a/spec/bundler/bundler/worker_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/worker"
-
-RSpec.describe Bundler::Worker do
- let(:size) { 5 }
- let(:name) { "Spec Worker" }
- let(:function) { proc {|object, worker_number| [object, worker_number] } }
- subject { described_class.new(size, name, function) }
-
- after { subject.stop }
-
- describe "#initialize" do
- context "when Thread.start raises ThreadError" do
- it "raises when no threads can be created" do
- allow(Thread).to receive(:start).and_raise(ThreadError, "error creating thread")
-
- expect { subject.enq "a" }.to raise_error(Bundler::ThreadCreationError, "Failed to create threads for the Spec Worker worker: error creating thread")
- end
- end
- end
-end
diff --git a/spec/bundler/bundler/yaml_serializer_spec.rb b/spec/bundler/bundler/yaml_serializer_spec.rb
deleted file mode 100644
index 1241c74bbf..0000000000
--- a/spec/bundler/bundler/yaml_serializer_spec.rb
+++ /dev/null
@@ -1,194 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/yaml_serializer"
-
-RSpec.describe Bundler::YAMLSerializer do
- subject(:serializer) { Bundler::YAMLSerializer }
-
- describe "#dump" do
- it "works for simple hash" do
- hash = { "Q" => "Where does Thursday come before Wednesday? In the dictionary. :P" }
-
- expected = strip_whitespace <<-YAML
- ---
- Q: "Where does Thursday come before Wednesday? In the dictionary. :P"
- YAML
-
- expect(serializer.dump(hash)).to eq(expected)
- end
-
- it "handles nested hash" do
- hash = {
- "nice-one" => {
- "read_ahead" => "All generalizations are false, including this one",
- },
- }
-
- expected = strip_whitespace <<-YAML
- ---
- nice-one:
- read_ahead: "All generalizations are false, including this one"
- YAML
-
- expect(serializer.dump(hash)).to eq(expected)
- end
-
- it "array inside an hash" do
- hash = {
- "nested_hash" => {
- "contains_array" => [
- "Jack and Jill went up the hill",
- "To fetch a pail of water.",
- "Jack fell down and broke his crown,",
- "And Jill came tumbling after.",
- ],
- },
- }
-
- expected = strip_whitespace <<-YAML
- ---
- nested_hash:
- contains_array:
- - "Jack and Jill went up the hill"
- - "To fetch a pail of water."
- - "Jack fell down and broke his crown,"
- - "And Jill came tumbling after."
- YAML
-
- expect(serializer.dump(hash)).to eq(expected)
- end
- end
-
- describe "#load" do
- it "works for simple hash" do
- yaml = strip_whitespace <<-YAML
- ---
- Jon: "Air is free dude!"
- Jack: "Yes.. until you buy a bag of chips!"
- YAML
-
- hash = {
- "Jon" => "Air is free dude!",
- "Jack" => "Yes.. until you buy a bag of chips!",
- }
-
- expect(serializer.load(yaml)).to eq(hash)
- end
-
- it "works for nested hash" do
- yaml = strip_whitespace <<-YAML
- ---
- baa:
- baa: "black sheep"
- have: "you any wool?"
- yes: "merry have I"
- three: "bags full"
- YAML
-
- hash = {
- "baa" => {
- "baa" => "black sheep",
- "have" => "you any wool?",
- "yes" => "merry have I",
- },
- "three" => "bags full",
- }
-
- expect(serializer.load(yaml)).to eq(hash)
- end
-
- it "handles colon in key/value" do
- yaml = strip_whitespace <<-YAML
- BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/: http://rubygems-mirror.org
- YAML
-
- expect(serializer.load(yaml)).to eq("BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/" => "http://rubygems-mirror.org")
- end
-
- it "handles arrays inside hashes" do
- yaml = strip_whitespace <<-YAML
- ---
- nested_hash:
- contains_array:
- - "Why shouldn't you write with a broken pencil?"
- - "Because it's pointless!"
- YAML
-
- hash = {
- "nested_hash" => {
- "contains_array" => [
- "Why shouldn't you write with a broken pencil?",
- "Because it's pointless!",
- ],
- },
- }
-
- expect(serializer.load(yaml)).to eq(hash)
- end
-
- it "handles windows-style CRLF line endings" do
- yaml = strip_whitespace(<<-YAML).gsub("\n", "\r\n")
- ---
- nested_hash:
- contains_array:
- - "Why shouldn't you write with a broken pencil?"
- - "Because it's pointless!"
- - oh so silly
- YAML
-
- hash = {
- "nested_hash" => {
- "contains_array" => [
- "Why shouldn't you write with a broken pencil?",
- "Because it's pointless!",
- "oh so silly",
- ],
- },
- }
-
- expect(serializer.load(yaml)).to eq(hash)
- end
- end
-
- describe "against yaml lib" do
- let(:hash) do
- {
- "a_joke" => {
- "my-stand" => "I can totally keep secrets",
- "but" => "The people I tell them to can't :P",
- "wouldn't it be funny if this string were empty?" => "",
- },
- "more" => {
- "first" => [
- "Can a kangaroo jump higher than a house?",
- "Of course, a house doesn't jump at all.",
- ],
- "second" => [
- "What did the sea say to the sand?",
- "Nothing, it simply waved.",
- ],
- "array with empty string" => [""],
- },
- "sales" => {
- "item" => "A Parachute",
- "description" => "Only used once, never opened.",
- },
- "one-more" => "I'd tell you a chemistry joke but I know I wouldn't get a reaction.",
- }
- end
-
- context "#load" do
- it "retrieves the original hash" do
- require "yaml"
- expect(serializer.load(YAML.dump(hash))).to eq(hash)
- end
- end
-
- context "#dump" do
- it "retrieves the original hash" do
- require "yaml"
- expect(YAML.load(serializer.dump(hash))).to eq(hash)
- end
- end
- end
-end
diff --git a/spec/bundler/cache/cache_path_spec.rb b/spec/bundler/cache/cache_path_spec.rb
deleted file mode 100644
index 12385427b1..0000000000
--- a/spec/bundler/cache/cache_path_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle package" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- context "with --cache-path" do
- it "caches gems at given path" do
- bundle :cache, "cache-path" => "vendor/cache-foo"
- expect(bundled_app("vendor/cache-foo/rack-1.0.0.gem")).to exist
- end
- end
-
- context "with config cache_path" do
- it "caches gems at given path" do
- bundle "config set cache_path vendor/cache-foo"
- bundle :cache
- expect(bundled_app("vendor/cache-foo/rack-1.0.0.gem")).to exist
- end
- end
-
- context "with absolute --cache-path" do
- it "caches gems at given path" do
- bundle :cache, "cache-path" => "/tmp/cache-foo"
- expect(bundled_app("/tmp/cache-foo/rack-1.0.0.gem")).to exist
- end
- end
-end
diff --git a/spec/bundler/cache/gems_spec.rb b/spec/bundler/cache/gems_spec.rb
deleted file mode 100644
index 89d6d41570..0000000000
--- a/spec/bundler/cache/gems_spec.rb
+++ /dev/null
@@ -1,304 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle cache" do
- shared_examples_for "when there are only gemsources" do
- before :each do
- gemfile <<-G
- gem 'rack'
- G
-
- system_gems "rack-1.0.0", :path => :bundle_path
- bundle! :cache
- end
-
- it "copies the .gem file to vendor/cache" do
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
-
- it "uses the cache as a source when installing gems" do
- build_gem "omg", :path => bundled_app("vendor/cache")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "omg"
- G
-
- expect(the_bundle).to include_gems "omg 1.0.0"
- end
-
- it "uses the cache as a source when installing gems with --local" do
- system_gems [], :path => :bundle_path
- bundle "install --local"
-
- expect(the_bundle).to include_gems("rack 1.0.0")
- end
-
- it "does not reinstall gems from the cache if they exist on the system" do
- build_gem "rack", "1.0.0", :path => bundled_app("vendor/cache") do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
-
- install_gemfile <<-G
- gem "rack"
- G
-
- expect(the_bundle).to include_gems("rack 1.0.0")
- end
-
- it "does not reinstall gems from the cache if they exist in the bundle" do
- system_gems "rack-1.0.0", :path => :bundle_path
-
- gemfile <<-G
- gem "rack"
- G
-
- build_gem "rack", "1.0.0", :path => bundled_app("vendor/cache") do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
-
- bundle! :install, :local => true
- expect(the_bundle).to include_gems("rack 1.0.0")
- end
-
- it "creates a lockfile" do
- cache_gems "rack-1.0.0"
-
- gemfile <<-G
- gem "rack"
- G
-
- bundle "cache"
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
- end
-
- context "using system gems" do
- before { bundle! "config set path.system true" }
- it_behaves_like "when there are only gemsources"
- end
-
- context "installing into a local path" do
- before { bundle! "config set path ./.bundle" }
- it_behaves_like "when there are only gemsources"
- end
-
- describe "when there is a built-in gem" do
- before :each do
- build_repo2 do
- build_gem "builtin_gem", "1.0.2"
- end
-
- build_gem "builtin_gem", "1.0.2", :to_system => true do |s|
- s.summary = "This builtin_gem is bundled with Ruby"
- end
-
- FileUtils.rm("#{system_gem_path}/cache/builtin_gem-1.0.2.gem")
- end
-
- it "uses builtin gems when installing to system gems" do
- bundle! "config set path.system true"
- install_gemfile %(gem 'builtin_gem', '1.0.2')
- expect(the_bundle).to include_gems("builtin_gem 1.0.2")
- end
-
- it "caches remote and builtin gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'builtin_gem', '1.0.2'
- gem 'rack', '1.0.0'
- G
-
- bundle :cache
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/builtin_gem-1.0.2.gem")).to exist
- end
-
- it "doesn't make remote request after caching the gem" do
- build_gem "builtin_gem_2", "1.0.2", :path => bundled_app("vendor/cache") do |s|
- s.summary = "This builtin_gem is bundled with Ruby"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'builtin_gem_2', '1.0.2'
- G
-
- bundle "install --local"
- expect(the_bundle).to include_gems("builtin_gem_2 1.0.2")
- end
-
- it "errors if the builtin gem isn't available to cache" do
- bundle! "config set path.system true"
-
- install_gemfile <<-G
- gem 'builtin_gem', '1.0.2'
- G
-
- bundle :cache
- expect(exitstatus).to_not eq(0) if exitstatus
- expect(err).to include("builtin_gem-1.0.2 is built in to Ruby, and can't be cached")
- end
- end
-
- describe "when there are also git sources" do
- before do
- build_git "foo"
- system_gems "rack-1.0.0"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- git "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- gem 'rack'
- G
- end
-
- it "still works" do
- bundle :cache
-
- system_gems []
- bundle "install --local"
-
- expect(the_bundle).to include_gems("rack 1.0.0", "foo 1.0")
- end
-
- it "should not explode if the lockfile is not present" do
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- bundle :cache
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
- end
-
- describe "when previously cached" do
- before :each do
- build_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- gem "actionpack"
- G
- bundle :cache
- expect(cached_gem("rack-1.0.0")).to exist
- expect(cached_gem("actionpack-2.3.2")).to exist
- expect(cached_gem("activesupport-2.3.2")).to exist
- end
-
- it "re-caches during install" do
- cached_gem("rack-1.0.0").rmtree
- bundle :install
- expect(out).to include("Updating files in vendor/cache")
- expect(cached_gem("rack-1.0.0")).to exist
- end
-
- it "adds and removes when gems are updated" do
- update_repo2
- bundle "update", :all => true
- expect(cached_gem("rack-1.2")).to exist
- expect(cached_gem("rack-1.0.0")).not_to exist
- end
-
- it "adds new gems and dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails"
- G
- expect(cached_gem("rails-2.3.2")).to exist
- expect(cached_gem("activerecord-2.3.2")).to exist
- end
-
- it "removes .gems for removed gems and dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- G
- expect(cached_gem("rack-1.0.0")).to exist
- expect(cached_gem("actionpack-2.3.2")).not_to exist
- expect(cached_gem("activesupport-2.3.2")).not_to exist
- end
-
- it "removes .gems when gem changes to git source" do
- build_git "rack"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack", :git => "#{lib_path("rack-1.0")}"
- gem "actionpack"
- G
- expect(cached_gem("rack-1.0.0")).not_to exist
- expect(cached_gem("actionpack-2.3.2")).to exist
- expect(cached_gem("activesupport-2.3.2")).to exist
- end
-
- it "doesn't remove gems that are for another platform" do
- simulate_platform "java" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
-
- bundle :cache
- expect(cached_gem("platform_specific-1.0-java")).to exist
- end
-
- simulate_new_machine
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
-
- expect(cached_gem("platform_specific-1.0-#{Bundler.local_platform}")).to exist
- expect(cached_gem("platform_specific-1.0-java")).to exist
- end
-
- it "doesn't remove gems with mismatched :rubygems_version or :date" do
- cached_gem("rack-1.0.0").rmtree
- build_gem "rack", "1.0.0",
- :path => bundled_app("vendor/cache"),
- :rubygems_version => "1.3.2"
- simulate_new_machine
-
- bundle :install
- expect(cached_gem("rack-1.0.0")).to exist
- end
-
- it "handles directories and non .gem files in the cache" do
- bundled_app("vendor/cache/foo").mkdir
- File.open(bundled_app("vendor/cache/bar"), "w") {|f| f.write("not a gem") }
- bundle :cache
- end
-
- it "does not say that it is removing gems when it isn't actually doing so" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundle "cache"
- bundle "install"
- expect(out).not_to match(/removing/i)
- end
-
- it "does not warn about all if it doesn't have any git/path dependency" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundle "cache"
- expect(out).not_to match(/\-\-all/)
- end
-
- it "should install gems with the name bundler in them (that aren't bundler)" do
- build_gem "foo-bundler", "1.0",
- :path => bundled_app("vendor/cache")
-
- install_gemfile <<-G
- gem "foo-bundler"
- G
-
- expect(the_bundle).to include_gems "foo-bundler 1.0"
- end
- end
-end
diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb
deleted file mode 100644
index 75525d405b..0000000000
--- a/spec/bundler/cache/git_spec.rb
+++ /dev/null
@@ -1,239 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "git base name" do
- it "base_name should strip private repo uris" do
- source = Bundler::Source::Git.new("uri" => "git@github.com:bundler.git")
- expect(source.send(:base_name)).to eq("bundler")
- end
-
- it "base_name should strip network share paths" do
- source = Bundler::Source::Git.new("uri" => "//MachineName/ShareFolder")
- expect(source.send(:base_name)).to eq("ShareFolder")
- end
-end
-
-RSpec.describe "bundle cache with git" do
- it "copies repository to vendor cache and uses it" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
-
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "copies repository to vendor cache and uses it even when installed with bundle --path" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle "install --path vendor/bundle"
- bundle "config set cache_all true"
- bundle :cache
-
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
-
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "runs twice without exploding" do
- build_git "foo"
-
- install_gemfile! <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle! :cache
- bundle! :cache
-
- expect(out).to include "Updating files in vendor/cache"
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "tracks updates" do
- git = build_git "foo"
- old_ref = git.ref_for("master", 11)
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
-
- update_git "foo" do |s|
- s.write "lib/foo.rb", "puts :CACHE"
- end
-
- ref = git.ref_for("master", 11)
- expect(ref).not_to eq(old_ref)
-
- bundle! "update", :all => true
- bundle "config set cache_all true"
- bundle! :cache
-
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
-
- FileUtils.rm_rf lib_path("foo-1.0")
- run! "require 'foo'"
- expect(out).to eq("CACHE")
- end
-
- it "tracks updates when specifying the gem" do
- git = build_git "foo"
- old_ref = git.ref_for("master", 11)
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle! :cache
-
- update_git "foo" do |s|
- s.write "lib/foo.rb", "puts :CACHE"
- end
-
- ref = git.ref_for("master", 11)
- expect(ref).not_to eq(old_ref)
-
- bundle "update foo"
-
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
-
- FileUtils.rm_rf lib_path("foo-1.0")
- run "require 'foo'"
- expect(out).to eq("CACHE")
- end
-
- it "uses the local repository to generate the cache" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
-
- gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-invalid")}', :branch => :master
- G
-
- bundle %(config set local.foo #{lib_path("foo-1.0")})
- bundle "install"
- bundle "config set cache_all true"
- bundle :cache
-
- expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist
-
- # Updating the local still uses the local.
- update_git "foo" do |s|
- s.write "lib/foo.rb", "puts :LOCAL"
- end
-
- run "require 'foo'"
- expect(out).to eq("LOCAL")
- end
-
- it "copies repository to vendor cache, including submodules" do
- build_git "submodule", "1.0"
-
- git = build_git "has_submodule", "1.0" do |s|
- s.add_dependency "submodule"
- end
-
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
-
- install_gemfile <<-G
- git "#{lib_path("has_submodule-1.0")}", :submodules => true do
- gem "has_submodule"
- end
- G
-
- ref = git.ref_for("master", 11)
- bundle "config set cache_all true"
- bundle :cache
-
- expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist
- expect(the_bundle).to include_gems "has_submodule 1.0"
- end
-
- it "displays warning message when detecting git repo in Gemfile", :bundler => "< 3" do
- build_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :cache
-
- expect(err).to include("Your Gemfile contains path and git dependencies.")
- end
-
- it "does not display warning message if cache_all is set in bundle config" do
- build_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
- bundle :cache
-
- expect(err).not_to include("Your Gemfile contains path and git dependencies.")
- end
-
- it "caches pre-evaluated gemspecs" do
- git = build_git "foo"
-
- # Insert a gemspec method that shells out
- spec_lines = lib_path("foo-1.0/foo.gemspec").read.split("\n")
- spec_lines.insert(-2, "s.description = `echo bob`")
- update_git("foo") {|s| s.write "foo.gemspec", spec_lines.join("\n") }
-
- install_gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
- bundle "config set cache_all true"
- bundle :cache
-
- ref = git.ref_for("master", 11)
- gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read
- expect(gemspec).to_not match("`echo bob`")
- end
-
- it "can install after bundle cache with git not installed" do
- build_git "foo"
-
- gemfile <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
- bundle! "config set cache_all true"
- bundle! :cache, "all-platforms" => true, :install => false, :path => "./vendor/cache"
-
- simulate_new_machine
- with_path_as "" do
- bundle! "config set deployment true"
- bundle! :install, :local => true
- expect(the_bundle).to include_gem "foo 1.0"
- end
- end
-end
diff --git a/spec/bundler/cache/path_spec.rb b/spec/bundler/cache/path_spec.rb
deleted file mode 100644
index 79e8b4a82b..0000000000
--- a/spec/bundler/cache/path_spec.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle cache with path" do
- it "is no-op when the path is within the bundle" do
- build_lib "foo", :path => bundled_app("lib/foo")
-
- install_gemfile <<-G
- gem "foo", :path => '#{bundled_app("lib/foo")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
- expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "copies when the path is outside the bundle " do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
- expect(bundled_app("vendor/cache/foo-1.0")).to exist
- expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file
-
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "copies when the path is outside the bundle and the paths intersect" do
- libname = File.basename(Dir.pwd) + "_gem"
- libpath = File.join(File.dirname(Dir.pwd), libname)
-
- build_lib libname, :path => libpath
-
- install_gemfile <<-G
- gem "#{libname}", :path => '#{libpath}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
- expect(bundled_app("vendor/cache/#{libname}")).to exist
- expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file
-
- FileUtils.rm_rf libpath
- expect(the_bundle).to include_gems "#{libname} 1.0"
- end
-
- it "updates the path on each cache" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
-
- build_lib "foo" do |s|
- s.write "lib/foo.rb", "puts :CACHE"
- end
-
- bundle :cache
-
- expect(bundled_app("vendor/cache/foo-1.0")).to exist
- FileUtils.rm_rf lib_path("foo-1.0")
-
- run "require 'foo'"
- expect(out).to eq("CACHE")
- end
-
- it "removes stale entries cache" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
-
- install_gemfile <<-G
- gem "bar", :path => '#{lib_path("bar-1.0")}'
- G
-
- bundle :cache
- expect(bundled_app("vendor/cache/bar-1.0")).not_to exist
- end
-
- it "raises a warning without --all", :bundler => "< 3" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- G
-
- bundle :cache
- expect(err).to match(/please pass the \-\-all flag/)
- expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
- end
-
- it "stores the given flag" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
- build_lib "bar"
-
- install_gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- gem "bar", :path => '#{lib_path("bar-1.0")}'
- G
-
- bundle :cache
- expect(bundled_app("vendor/cache/bar-1.0")).to exist
- end
-
- it "can rewind chosen configuration" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- G
-
- bundle "config set cache_all true"
- bundle :cache
- build_lib "baz"
-
- gemfile <<-G
- gem "foo", :path => '#{lib_path("foo-1.0")}'
- gem "baz", :path => '#{lib_path("baz-1.0")}'
- G
-
- bundle "cache --no-all"
- expect(bundled_app("vendor/cache/baz-1.0")).not_to exist
- end
-end
diff --git a/spec/bundler/cache/platform_spec.rb b/spec/bundler/cache/platform_spec.rb
deleted file mode 100644
index b65bb06ae6..0000000000
--- a/spec/bundler/cache/platform_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle cache with multiple platforms" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- platforms :mri, :rbx do
- gem "rack", "1.0.0"
- end
-
- platforms :jruby do
- gem "activesupport", "2.3.5"
- end
- G
-
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
- activesupport (2.3.5)
-
- PLATFORMS
- ruby
- java
-
- DEPENDENCIES
- rack (1.0.0)
- activesupport (2.3.5)
- G
-
- cache_gems "rack-1.0.0", "activesupport-2.3.5"
- end
-
- it "ensures that a successful bundle install does not delete gems for other platforms" do
- bundle! "install"
-
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/activesupport-2.3.5.gem")).to exist
- end
-
- it "ensures that a successful bundle update does not delete gems for other platforms" do
- bundle! "update", :all => true
-
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/activesupport-2.3.5.gem")).to exist
- end
-end
diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb
deleted file mode 100644
index 35fd43d3d2..0000000000
--- a/spec/bundler/commands/add_spec.rb
+++ /dev/null
@@ -1,251 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle add" do
- before :each do
- build_repo2 do
- build_gem "foo", "1.1"
- build_gem "foo", "2.0"
- build_gem "baz", "1.2.3"
- build_gem "bar", "0.12.3"
- build_gem "cat", "0.12.3.pre"
- build_gem "dog", "1.1.3.pre"
- end
-
- build_git "foo", "2.0"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "weakling", "~> 0.0.1"
- G
- end
-
- context "when no gems are specified" do
- it "shows error" do
- bundle "add"
-
- expect(err).to include("Please specify gems to add")
- end
- end
-
- describe "without version specified" do
- it "version requirement becomes ~> major.minor.patch when resolved version is < 1.0" do
- bundle "add 'bar'"
- expect(bundled_app("Gemfile").read).to match(/gem "bar", "~> 0.12.3"/)
- expect(the_bundle).to include_gems "bar 0.12.3"
- end
-
- it "version requirement becomes ~> major.minor when resolved version is > 1.0" do
- bundle "add 'baz'"
- expect(bundled_app("Gemfile").read).to match(/gem "baz", "~> 1.2"/)
- expect(the_bundle).to include_gems "baz 1.2.3"
- end
-
- it "version requirement becomes ~> major.minor.patch.pre when resolved version is < 1.0" do
- bundle "add 'cat'"
- expect(bundled_app("Gemfile").read).to match(/gem "cat", "~> 0.12.3.pre"/)
- expect(the_bundle).to include_gems "cat 0.12.3.pre"
- end
-
- it "version requirement becomes ~> major.minor.pre when resolved version is > 1.0.pre" do
- bundle "add 'dog'"
- expect(bundled_app("Gemfile").read).to match(/gem "dog", "~> 1.1.pre"/)
- expect(the_bundle).to include_gems "dog 1.1.3.pre"
- end
- end
-
- describe "with --version" do
- it "adds dependency of specified version and runs install" do
- bundle "add 'foo' --version='~> 1.0'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 1.0"/)
- expect(the_bundle).to include_gems "foo 1.1"
- end
-
- it "adds multiple version constraints when specified" do
- requirements = ["< 3.0", "> 1.0"]
- bundle "add 'foo' --version='#{requirements.join(", ")}'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", #{Gem::Requirement.new(requirements).as_list.map(&:dump).join(', ')}/)
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with --group" do
- it "adds dependency for the specified group" do
- bundle "add 'foo' --group='development'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :group => :development/)
- expect(the_bundle).to include_gems "foo 2.0"
- end
-
- it "adds dependency to more than one group" do
- bundle "add 'foo' --group='development, test'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :groups => \[:development, :test\]/)
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with --source" do
- it "adds dependency with specified source" do
- bundle "add 'foo' --source='#{file_uri_for(gem_repo2)}'"
-
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :source => "#{file_uri_for(gem_repo2)}"/)
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with --git" do
- it "adds dependency with specified github source" do
- bundle "add foo --git=#{lib_path("foo-2.0")}"
-
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/)
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with --git and --branch" do
- before do
- update_git "foo", "2.0", :branch => "test"
- end
-
- it "adds dependency with specified github source and branch" do
- bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test"
-
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/)
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with --skip-install" do
- it "adds gem to Gemfile but is not installed" do
- bundle "add foo --skip-install --version=2.0"
-
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "= 2.0"/)
- expect(the_bundle).to_not include_gems "foo 2.0"
- end
- end
-
- it "using combination of short form options works like long form" do
- bundle "add 'foo' -s='#{file_uri_for(gem_repo2)}' -g='development' -v='~>1.0'"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => :development, :source => "#{file_uri_for(gem_repo2)}")
- expect(the_bundle).to include_gems "foo 1.1"
- end
-
- it "shows error message when version is not formatted correctly" do
- bundle "add 'foo' -v='~>1 . 0'"
- expect(err).to match("Invalid gem requirement pattern '~>1 . 0'")
- end
-
- it "shows error message when gem cannot be found" do
- bundle "config set force_ruby_platform true"
- bundle "add 'werk_it'"
- expect(err).to match("Could not find gem 'werk_it' in")
-
- bundle "add 'werk_it' -s='#{file_uri_for(gem_repo2)}'"
- expect(err).to match("Could not find gem 'werk_it' in rubygems repository")
- end
-
- it "shows error message when source cannot be reached" do
- bundle "add 'baz' --source='http://badhostasdf'"
- expect(err).to include("Could not reach host badhostasdf. Check your network connection and try again.")
-
- bundle "add 'baz' --source='file://does/not/exist'"
- expect(err).to include("Could not fetch specs from file://does/not/exist/")
- end
-
- describe "with --optimistic" do
- it "adds optimistic version" do
- bundle! "add 'foo' --optimistic"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", ">= 2.0")
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with --strict option" do
- it "adds strict version" do
- bundle! "add 'foo' --strict"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", "= 2.0")
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with no option" do
- it "adds pessimistic version" do
- bundle! "add 'foo'"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 2.0")
- expect(the_bundle).to include_gems "foo 2.0"
- end
- end
-
- describe "with --optimistic and --strict" do
- it "throws error" do
- bundle "add 'foo' --strict --optimistic"
-
- expect(err).to include("You can not specify `--strict` and `--optimistic` at the same time")
- end
- end
-
- context "multiple gems" do
- it "adds multiple gems to gemfile" do
- bundle! "add bar baz"
-
- expect(bundled_app("Gemfile").read).to match(/gem "bar", "~> 0.12.3"/)
- expect(bundled_app("Gemfile").read).to match(/gem "baz", "~> 1.2"/)
- end
-
- it "throws error if any of the specified gems are present in the gemfile with different version" do
- bundle "add weakling bar"
-
- expect(err).to include("You cannot specify the same gem twice with different version requirements")
- expect(err).to include("You specified: weakling (~> 0.0.1) and weakling (>= 0).")
- end
- end
-
- describe "when a gem is added which is already specified in Gemfile with version" do
- it "shows an error when added with different version requirement" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack", "1.0"
- G
-
- bundle "add 'rack' --version=1.1"
-
- expect(err).to include("You cannot specify the same gem twice with different version requirements")
- expect(err).to include("If you want to update the gem version, run `bundle update rack`. You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
- end
-
- it "shows error when added without version requirements" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack", "1.0"
- G
-
- bundle "add 'rack'"
-
- expect(err).to include("Gem already added.")
- expect(err).to include("You cannot specify the same gem twice with different version requirements")
- expect(err).not_to include("If you want to update the gem version, run `bundle update rack`. You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
- end
- end
-
- describe "when a gem is added which is already specified in Gemfile without version" do
- it "shows an error when added with different version requirement" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- G
-
- bundle "add 'rack' --version=1.1"
-
- expect(err).to include("You cannot specify the same gem twice with different version requirements")
- expect(err).to include("If you want to update the gem version, run `bundle update rack`.")
- expect(err).not_to include("You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
- end
- end
-
- describe "when a gem is added and cache exists" do
- it "caches all new dependencies added for the specified gem" do
- bundle! :cache
-
- bundle "add 'rack' --version=1.0.0"
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
- end
-end
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb
deleted file mode 100644
index 7c04e8ddbd..0000000000
--- a/spec/bundler/commands/binstubs_spec.rb
+++ /dev/null
@@ -1,465 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle binstubs <gem>" do
- context "when the gem exists in the lockfile" do
- it "sets up the binstub" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack"
-
- expect(bundled_app("bin/rackup")).to exist
- end
-
- it "does not install other binstubs" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rails"
- G
-
- bundle "binstubs rails"
-
- expect(bundled_app("bin/rackup")).not_to exist
- expect(bundled_app("bin/rails")).to exist
- end
-
- it "does install multiple binstubs" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rails"
- G
-
- bundle "binstubs rails rack"
-
- expect(bundled_app("bin/rackup")).to exist
- expect(bundled_app("bin/rails")).to exist
- end
-
- it "allows installing all binstubs" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- bundle! :binstubs, :all => true
-
- expect(bundled_app("bin/rails")).to exist
- expect(bundled_app("bin/rake")).to exist
- end
-
- it "displays an error when used without any gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs"
- expect(exitstatus).to eq(1) if exitstatus
- expect(err).to include("`bundle binstubs` needs at least one gem to run.")
- end
-
- it "displays an error when used with --all and gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack", :all => true
- expect(last_command).to be_failure
- expect(err).to include("Cannot specify --all with specific gems")
- end
-
- context "when generating bundle binstub outside bundler" do
- it "should abort" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack"
-
- File.open("bin/bundle", "wb") do |file|
- file.print "OMG"
- end
-
- sys_exec "bin/rackup"
-
- expect(err).to include("was not generated by Bundler")
- end
- end
-
- context "the bundle binstub" do
- before do
- if system_bundler_version == :bundler
- system_gems :bundler
- elsif system_bundler_version
- build_repo4 do
- build_gem "bundler", system_bundler_version do |s|
- s.executables = "bundle"
- s.bindir = "exe"
- s.write "exe/bundle", "puts %(system bundler #{system_bundler_version}\\n\#{ARGV.inspect})"
- end
- end
- system_gems "bundler-#{system_bundler_version}", :gem_repo => gem_repo4
- end
- build_repo2 do
- build_gem "prints_loaded_gems", "1.0" do |s|
- s.executables = "print_loaded_gems"
- s.bindir = "exe"
- s.write "exe/print_loaded_gems", <<-R
- specs = Gem.loaded_specs.values.reject {|s| Bundler.rubygems.spec_default_gem?(s) }
- puts specs.map(&:full_name).sort.inspect
- R
- end
- end
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- gem "prints_loaded_gems"
- G
- bundle! "binstubs bundler rack prints_loaded_gems"
- end
-
- let(:system_bundler_version) { Bundler::VERSION }
-
- it "runs bundler" do
- sys_exec! "#{bundled_app("bin/bundle")} install"
- expect(out).to eq %(system bundler #{system_bundler_version}\n["install"])
- end
-
- context "when BUNDLER_VERSION is set" do
- it "runs the correct version of bundler" do
- sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999"
- expect(exitstatus).to eq(42) if exitstatus
- expect(err).to include("Activating bundler (~> 999.999) failed:").
- and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`")
- end
- end
-
- context "when a lockfile exists with a locked bundler version" do
- context "and the version is newer" do
- before do
- lockfile lockfile.gsub(system_bundler_version, "999.999")
- end
-
- it "runs the correct version of bundler" do
- sys_exec "#{bundled_app("bin/bundle")} install"
- expect(exitstatus).to eq(42) if exitstatus
- expect(err).to include("Activating bundler (~> 999.999) failed:").
- and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`")
- end
- end
-
- context "and the version is older and a different major" do
- let(:system_bundler_version) { "55" }
-
- before do
- lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 44.0")
- end
-
- it "runs the correct version of bundler" do
- sys_exec "#{bundled_app("bin/bundle")} install"
- expect(exitstatus).to eq(42) if exitstatus
- expect(err).to include("Activating bundler (~> 44.0) failed:").
- and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 44.0'`")
- end
- end
-
- context "and the version is older and the same major" do
- let(:system_bundler_version) { "55.1" }
-
- before do
- lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 55.0")
- end
-
- it "runs the available version of bundler when the version is older and the same major" do
- sys_exec "#{bundled_app("bin/bundle")} install"
- expect(exitstatus).not_to eq(42) if exitstatus
- expect(err).not_to include("Activating bundler (~> 55.0) failed:")
- end
- end
-
- context "and the version is a pre-releaser" do
- let(:system_bundler_version) { "55" }
-
- before do
- lockfile lockfile.gsub(/BUNDLED WITH\n .*$/m, "BUNDLED WITH\n 2.12.0.a")
- end
-
- it "runs the correct version of bundler when the version is a pre-release" do
- sys_exec "#{bundled_app("bin/bundle")} install"
- expect(exitstatus).to eq(42) if exitstatus
- expect(err).to include("Activating bundler (~> 2.12.a) failed:").
- and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 2.12.a'`")
- end
- end
- end
-
- context "when update --bundler is called" do
- before { lockfile.gsub(system_bundler_version, "1.1.1") }
-
- it "calls through to the latest bundler version" do
- sys_exec! "#{bundled_app("bin/bundle")} update --bundler"
- expect(out).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"])
- end
-
- it "calls through to the explicit bundler version" do
- sys_exec "#{bundled_app("bin/bundle")} update --bundler=999.999.999"
- expect(exitstatus).to eq(42) if exitstatus
- expect(err).to include("Activating bundler (~> 999.999) failed:").
- and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`")
- end
- end
-
- context "without a lockfile" do
- it "falls back to the latest installed bundler" do
- FileUtils.rm bundled_app("Gemfile.lock")
- sys_exec! bundled_app("bin/bundle").to_s
- expect(out).to eq "system bundler #{system_bundler_version}\n[]"
- end
- end
-
- context "using another binstub" do
- let(:system_bundler_version) { :bundler }
- it "loads all gems" do
- sys_exec! bundled_app("bin/print_loaded_gems").to_s
- expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"])
- end
-
- context "when requesting a different bundler version" do
- before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") }
-
- it "attempts to load that version" do
- sys_exec bundled_app("bin/rackup").to_s
- expect(exitstatus).to eq(42) if exitstatus
- expect(err).to include("Activating bundler (~> 999.999) failed:").
- and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`")
- end
- end
- end
- end
-
- it "installs binstubs from git gems" do
- FileUtils.mkdir_p(lib_path("foo/bin"))
- FileUtils.touch(lib_path("foo/bin/foo"))
- build_git "foo", "1.0", :path => lib_path("foo") do |s|
- s.executables = %w[foo]
- end
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo")}"
- G
-
- bundle "binstubs foo"
-
- expect(bundled_app("bin/foo")).to exist
- end
-
- it "installs binstubs from path gems" do
- FileUtils.mkdir_p(lib_path("foo/bin"))
- FileUtils.touch(lib_path("foo/bin/foo"))
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.executables = %w[foo]
- end
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo")}"
- G
-
- bundle "binstubs foo"
-
- expect(bundled_app("bin/foo")).to exist
- end
-
- it "sets correct permissions for binstubs" do
- with_umask(0o002) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack"
- binary = bundled_app("bin/rackup")
- expect(File.stat(binary).mode.to_s(8)).to eq("100775")
- end
- end
-
- context "when using --shebang" do
- it "sets the specified shebang for the binstub" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack --shebang jruby"
-
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env jruby\n")
- end
- end
- end
-
- context "when the gem doesn't exist" do
- it "displays an error with correct status" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
-
- bundle "binstubs doesnt_exist"
-
- expect(exitstatus).to eq(7) if exitstatus
- expect(err).to include("Could not find gem 'doesnt_exist'.")
- end
- end
-
- context "--path" do
- it "sets the binstubs dir" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack --path exec"
-
- expect(bundled_app("exec/rackup")).to exist
- end
-
- it "setting is saved for bundle install", :bundler => "< 3" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rails"
- G
-
- bundle! "binstubs rack", :path => "exec"
- bundle! :install
-
- expect(bundled_app("exec/rails")).to exist
- end
- end
-
- context "with --standalone option" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "generates a standalone binstub" do
- bundle! "binstubs rack --standalone"
- expect(bundled_app("bin/rackup")).to exist
- end
-
- it "generates a binstub that does not depend on rubygems or bundler" do
- bundle! "binstubs rack --standalone"
- expect(File.read(bundled_app("bin/rackup"))).to_not include("Gem.bin_path")
- end
-
- context "when specified --path option" do
- it "generates a standalone binstub at the given path" do
- bundle! "binstubs rack --standalone --path foo"
- expect(bundled_app("foo/rackup")).to exist
- end
- end
- end
-
- context "when the bin already exists" do
- it "doesn't overwrite and warns" do
- FileUtils.mkdir_p(bundled_app("bin"))
- File.open(bundled_app("bin/rackup"), "wb") do |file|
- file.print "OMG"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack"
-
- expect(bundled_app("bin/rackup")).to exist
- expect(File.read(bundled_app("bin/rackup"))).to eq("OMG")
- expect(err).to include("Skipped rackup")
- expect(err).to include("overwrite skipped stubs, use --force")
- end
-
- context "when using --force" do
- it "overwrites the binstub" do
- FileUtils.mkdir_p(bundled_app("bin"))
- File.open(bundled_app("bin/rackup"), "wb") do |file|
- file.print "OMG"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "binstubs rack --force"
-
- expect(bundled_app("bin/rackup")).to exist
- expect(File.read(bundled_app("bin/rackup"))).not_to eq("OMG")
- end
- end
- end
-
- context "when the gem has no bins" do
- it "suggests child gems if they have bins" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack-obama"
- G
-
- bundle "binstubs rack-obama"
- expect(err).to include("rack-obama has no executables")
- expect(err).to include("rack has: rackup")
- end
-
- it "works if child gems don't have bins" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "actionpack"
- G
-
- bundle "binstubs actionpack"
- expect(err).to include("no executables for the gem actionpack")
- end
-
- it "works if the gem has development dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "with_development_dependency"
- G
-
- bundle "binstubs with_development_dependency"
- expect(err).to include("no executables for the gem with_development_dependency")
- end
- end
-
- context "when BUNDLE_INSTALL is specified" do
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "config set auto_install 1"
- bundle "binstubs rack"
- expect(out).to include("Installing rack 1.0.0")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does nothing when already up to date" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "config set auto_install 1"
- bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => "1" }
- expect(out).not_to include("Installing rack 1.0.0")
- end
- end
-end
diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb
deleted file mode 100644
index 07ec186c2f..0000000000
--- a/spec/bundler/commands/cache_spec.rb
+++ /dev/null
@@ -1,351 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle cache" do
- context "with --gemfile" do
- it "finds the gemfile" do
- gemfile bundled_app("NotGemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle "cache --gemfile=NotGemfile"
-
- ENV["BUNDLE_GEMFILE"] = "NotGemfile"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- context "with --all" do
- context "without a gemspec" do
- it "caches all dependencies except bundler itself" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- gem 'bundler'
- D
-
- bundle "config set cache_all true"
- bundle :cache
-
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
- end
- end
-
- context "with a gemspec" do
- context "that has the same name as the gem" do
- before do
- File.open(bundled_app("mygem.gemspec"), "w") do |f|
- f.write <<-G
- Gem::Specification.new do |s|
- s.name = "mygem"
- s.version = "0.1.1"
- s.summary = ""
- s.authors = ["gem author"]
- s.add_development_dependency "nokogiri", "=1.4.2"
- end
- G
- end
- end
-
- it "caches all dependencies except bundler and the gemspec specified gem" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- gemspec
- D
-
- bundle "config set cache_all true"
- bundle! :cache
-
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
- expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist
- expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
- end
- end
-
- context "that has a different name as the gem" do
- before do
- File.open(bundled_app("mygem_diffname.gemspec"), "w") do |f|
- f.write <<-G
- Gem::Specification.new do |s|
- s.name = "mygem"
- s.version = "0.1.1"
- s.summary = ""
- s.authors = ["gem author"]
- s.add_development_dependency "nokogiri", "=1.4.2"
- end
- G
- end
- end
-
- it "caches all dependencies except bundler and the gemspec specified gem" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- gemspec
- D
-
- bundle "config set cache_all true"
- bundle! :cache
-
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
- expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist
- expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
- end
- end
- end
-
- context "with multiple gemspecs" do
- before do
- File.open(bundled_app("mygem.gemspec"), "w") do |f|
- f.write <<-G
- Gem::Specification.new do |s|
- s.name = "mygem"
- s.version = "0.1.1"
- s.summary = ""
- s.authors = ["gem author"]
- s.add_development_dependency "nokogiri", "=1.4.2"
- end
- G
- end
- File.open(bundled_app("mygem_client.gemspec"), "w") do |f|
- f.write <<-G
- Gem::Specification.new do |s|
- s.name = "mygem_test"
- s.version = "0.1.1"
- s.summary = ""
- s.authors = ["gem author"]
- s.add_development_dependency "weakling", "=0.0.3"
- end
- G
- end
- end
-
- it "caches all dependencies except bundler and the gemspec specified gems" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- gemspec :name => 'mygem'
- gemspec :name => 'mygem_test'
- D
-
- bundle "config set cache_all true"
- bundle! :cache
-
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
- expect(bundled_app("vendor/cache/weakling-0.0.3.gem")).to exist
- expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist
- expect(bundled_app("vendor/cache/mygem_test-0.1.1.gem")).to_not exist
- expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
- end
- end
- end
-
- context "with --path", :bundler => "< 3" do
- it "sets root directory for gems" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- D
-
- bundle! :cache, forgotten_command_line_options(:path => bundled_app("test"))
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(bundled_app("test/vendor/cache/")).to exist
- end
- end
-
- context "with --no-install" do
- it "puts the gems in vendor/cache but does not install them" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- D
-
- bundle! "cache --no-install"
-
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
-
- it "does not prevent installing gems with bundle install" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- D
-
- bundle! "cache --no-install"
- bundle! "install"
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not prevent installing gems with bundle update" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- D
-
- bundle! "cache --no-install"
- bundle! "update --all"
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- context "with --all-platforms" do
- it "puts the gems in vendor/cache even for other rubies" do
- gemfile <<-D
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack', :platforms => :ruby_19
- D
-
- bundle "cache --all-platforms"
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
-
- it "does not attempt to install gems in without groups" do
- build_repo4 do
- build_gem "uninstallable", "2.0" do |s|
- s.add_development_dependency "rake"
- s.extensions << "Rakefile"
- s.write "Rakefile", "task(:default) { raise 'CANNOT INSTALL' }"
- end
- end
-
- install_gemfile! <<-G, forgotten_command_line_options(:without => "wo")
- source "file:#{gem_repo1}"
- gem "rack"
- group :wo do
- gem "weakling"
- gem "uninstallable", :source => "file:#{gem_repo4}"
- end
- G
-
- bundle! :cache, "all-platforms" => true
- expect(bundled_app("vendor/cache/weakling-0.0.3.gem")).to exist
- expect(bundled_app("vendor/cache/uninstallable-2.0.gem")).to exist
- expect(the_bundle).to include_gem "rack 1.0"
- expect(the_bundle).not_to include_gems "weakling", "uninstallable"
-
- bundle! :install, forgotten_command_line_options(:without => "wo")
- expect(the_bundle).to include_gem "rack 1.0"
- expect(the_bundle).not_to include_gems "weakling", "uninstallable"
- end
- end
-
- context "with --frozen" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundle "install"
- end
-
- subject { bundle :cache, forgotten_command_line_options(:frozen => true) }
-
- it "tries to install with frozen" do
- bundle! "config set deployment true"
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
- subject
- expect(exitstatus).to eq(16) if exitstatus
- expect(err).to include("deployment mode")
- expect(err).to include("You have added to the Gemfile")
- expect(err).to include("* rack-obama")
- bundle "env"
- expect(out).to include("frozen").or include("deployment")
- end
- end
-end
-
-RSpec.describe "bundle install with gem sources" do
- describe "when cached and locked" do
- it "does not hit the remote at all" do
- build_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- G
-
- bundle :cache
- simulate_new_machine
- FileUtils.rm_rf gem_repo2
-
- bundle "install --local"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not hit the remote at all" do
- build_repo2
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- G
-
- bundle! :cache
- simulate_new_machine
- FileUtils.rm_rf gem_repo2
-
- bundle! :install, forgotten_command_line_options(:deployment => true, :path => "vendor/bundle")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not reinstall already-installed gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundle :cache
-
- build_gem "rack", "1.0.0", :path => bundled_app("vendor/cache") do |s|
- s.write "lib/rack.rb", "raise 'omg'"
- end
-
- bundle :install
- expect(err).to be_empty
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "ignores cached gems for the wrong platform" do
- simulate_platform "java" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
- bundle :cache
- end
-
- simulate_new_machine
-
- simulate_platform "ruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
- run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
- expect(out).to eq("1.0.0 RUBY")
- end
- end
-
- it "does not update the cache if --no-cache is passed" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundled_app("vendor/cache").mkpath
- expect(bundled_app("vendor/cache").children).to be_empty
-
- bundle "install --no-cache"
- expect(bundled_app("vendor/cache").children).to be_empty
- end
- end
-end
diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb
deleted file mode 100644
index c755ef2804..0000000000
--- a/spec/bundler/commands/check_spec.rb
+++ /dev/null
@@ -1,359 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle check" do
- it "returns success when the Gemfile is satisfied" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- bundle :check
- expect(exitstatus).to eq(0) if exitstatus
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "works with the --gemfile flag when not in the directory" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- Dir.chdir tmp
- bundle "check --gemfile bundled_app/Gemfile"
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "creates a Gemfile.lock by default if one does not exist" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- FileUtils.rm("Gemfile.lock")
-
- bundle "check"
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "does not create a Gemfile.lock if --dry-run was passed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- FileUtils.rm("Gemfile.lock")
-
- bundle "check --dry-run"
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- end
-
- it "prints a generic error if the missing gems are unresolvable" do
- system_gems ["rails-2.3.2"]
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- bundle :check
- expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
- end
-
- it "prints a generic error if a Gemfile.lock does not exist and a toplevel dependency does not exist" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- bundle :check
- expect(exitstatus).to be > 0 if exitstatus
- expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
- end
-
- it "prints a generic message if you changed your lockfile" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rails'
- G
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rails_fail'
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- gem "rails_fail"
- G
-
- bundle :check
- expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
- end
-
- it "remembers --without option from install", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- group :foo do
- gem "rack"
- end
- G
-
- bundle! "install --without foo"
- bundle! "check"
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "uses the without setting" do
- bundle! "config set without foo"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- group :foo do
- gem "rack"
- end
- G
-
- bundle! "check"
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "ensures that gems are actually installed and not just cached" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :group => :foo
- G
-
- bundle :install, forgotten_command_line_options(:without => "foo")
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "check"
- expect(err).to include("* rack (1.0.0)")
- expect(exitstatus).to eq(1) if exitstatus
- end
-
- it "ignores missing gems restricted to other platforms" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- platforms :#{not_local_tag} do
- gem "activesupport"
- end
- G
-
- system_gems "rack-1.0.0", :path => :bundle_path
-
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- activesupport (2.3.5)
- rack (1.0.0)
-
- PLATFORMS
- #{local}
- #{not_local}
-
- DEPENDENCIES
- rack
- activesupport
- G
-
- bundle :check
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "works with env conditionals" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- env :NOT_GOING_TO_BE_SET do
- gem "activesupport"
- end
- G
-
- system_gems "rack-1.0.0", :path => :bundle_path
-
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- activesupport (2.3.5)
- rack (1.0.0)
-
- PLATFORMS
- #{local}
- #{not_local}
-
- DEPENDENCIES
- rack
- activesupport
- G
-
- bundle :check
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "outputs an error when the default Gemfile is not found" do
- bundle :check
- expect(exitstatus).to eq(10) if exitstatus
- expect(err).to include("Could not locate Gemfile")
- end
-
- it "does not output fatal error message" do
- bundle :check
- expect(exitstatus).to eq(10) if exitstatus
- expect(err).not_to include("Unfortunately, a fatal error has occurred. ")
- end
-
- it "should not crash when called multiple times on a new machine" do
- gemfile <<-G
- gem 'rails', '3.0.0.beta3'
- gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
- G
-
- simulate_new_machine
- bundle "check"
- last_out = out
- 3.times do
- bundle :check
- expect(out).to eq(last_out)
- end
- end
-
- it "fails when there's no lock file and frozen is set" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo"
- G
-
- bundle! "install", forgotten_command_line_options(:deployment => true)
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- bundle :check
- expect(last_command).to be_failure
- end
-
- context "--path", :bundler => "< 3" do
- context "after installing gems in the proper directory" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
- bundle "install --path vendor/bundle"
-
- FileUtils.rm_rf(bundled_app(".bundle"))
- end
-
- it "returns success" do
- bundle! "check --path vendor/bundle"
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "should write to .bundle/config" do
- bundle "check --path vendor/bundle"
- bundle! "check"
- end
- end
-
- context "after installing gems on a different directory" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- bundle "check --path vendor/bundle"
- end
-
- it "returns false" do
- expect(exitstatus).to eq(1) if exitstatus
- expect(err).to match(/The following gems are missing/)
- end
- end
- end
-
- describe "when locked" do
- before :each do
- system_gems "rack-1.0.0"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0"
- G
- end
-
- it "returns success when the Gemfile is satisfied" do
- bundle :install
- bundle :check
- expect(exitstatus).to eq(0) if exitstatus
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "shows what is missing with the current Gemfile if it is not satisfied" do
- simulate_new_machine
- bundle :check
- expect(err).to match(/The following gems are missing/)
- expect(err).to include("* rack (1.0")
- end
- end
-
- describe "BUNDLED WITH" do
- def lock_with(bundler_version = nil)
- lock = <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
- L
-
- if bundler_version
- lock += "\n BUNDLED WITH\n #{bundler_version}\n"
- end
-
- lock
- end
-
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- context "is not present" do
- it "does not change the lock" do
- lockfile lock_with(nil)
- bundle :check
- lockfile_should_be lock_with(nil)
- end
- end
-
- context "is newer" do
- it "does not change the lock but warns" do
- lockfile lock_with(Bundler::VERSION.succ)
- bundle! :check
- expect(err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})")
- lockfile_should_be lock_with(Bundler::VERSION.succ)
- end
- end
-
- context "is older" do
- it "does not change the lock" do
- lockfile lock_with("1.10.1")
- bundle :check
- lockfile_should_be lock_with("1.10.1")
- end
- end
- end
-end
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
deleted file mode 100644
index 5cc97de912..0000000000
--- a/spec/bundler/commands/clean_spec.rb
+++ /dev/null
@@ -1,892 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle clean" do
- def should_have_gems(*gems)
- gems.each do |g|
- expect(vendored_gems("gems/#{g}")).to exist
- expect(vendored_gems("specifications/#{g}.gemspec")).to exist
- expect(vendored_gems("cache/#{g}.gem")).to exist
- end
- end
-
- def should_not_have_gems(*gems)
- gems.each do |g|
- expect(vendored_gems("gems/#{g}")).not_to exist
- expect(vendored_gems("specifications/#{g}.gemspec")).not_to exist
- expect(vendored_gems("cache/#{g}.gem")).not_to exist
- end
- end
-
- it "removes unused gems that are different" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle! "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- G
- bundle! "install"
-
- bundle! :clean
-
- expect(out).to include("Removing foo (1.0)")
-
- should_have_gems "thin-1.0", "rack-1.0.0"
- should_not_have_gems "foo-1.0"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "removes old version of gem if unused" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "0.9.1"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- gem "foo"
- G
- bundle "install"
-
- bundle :clean
-
- expect(out).to include("Removing rack (0.9.1)")
-
- should_have_gems "foo-1.0", "rack-1.0.0"
- should_not_have_gems "rack-0.9.1"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "removes new version of gem if unused" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle! "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "0.9.1"
- gem "foo"
- G
- bundle! "update rack"
-
- bundle! :clean
-
- expect(out).to include("Removing rack (1.0.0)")
-
- should_have_gems "foo-1.0", "rack-0.9.1"
- should_not_have_gems "rack-1.0.0"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "removes gems in bundle without groups" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo"
-
- group :test_group do
- gem "rack", "1.0.0"
- end
- G
-
- bundle "config set path vendor/bundle"
- bundle "install"
- bundle "config set without test_group"
- bundle "install"
- bundle :clean
-
- expect(out).to include("Removing rack (1.0.0)")
-
- should_have_gems "foo-1.0"
- should_not_have_gems "rack-1.0.0"
-
- expect(vendored_gems("bin/rackup")).to_not exist
- end
-
- it "does not remove cached git dir if it's being used" do
- build_git "foo"
- revision = revision_for(lib_path("foo-1.0"))
- git_path = lib_path("foo-1.0")
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- git "#{git_path}", :ref => "#{revision}" do
- gem "foo"
- end
- G
-
- bundle "config set path vendor/bundle"
- bundle "install"
-
- bundle :clean
-
- digest = Digest(:SHA1).hexdigest(git_path.to_s)
- cache_path = Bundler::VERSION.start_with?("2.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}")
- expect(cache_path).to exist
- end
-
- it "removes unused git gems" do
- build_git "foo", :path => lib_path("foo")
- git_path = lib_path("foo")
- revision = revision_for(git_path)
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- git "#{git_path}", :ref => "#{revision}" do
- gem "foo"
- end
- G
-
- bundle "config set path vendor/bundle"
- bundle "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- G
- bundle "install"
-
- bundle :clean
-
- expect(out).to include("Removing foo (#{revision[0..11]})")
-
- expect(vendored_gems("gems/rack-1.0.0")).to exist
- expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).not_to exist
- digest = Digest(:SHA1).hexdigest(git_path.to_s)
- expect(vendored_gems("cache/bundler/git/foo-#{digest}")).not_to exist
-
- expect(vendored_gems("specifications/rack-1.0.0.gemspec")).to exist
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "keeps used git gems even if installed to a symlinked location" do
- build_git "foo", :path => lib_path("foo")
- git_path = lib_path("foo")
- revision = revision_for(git_path)
-
- gemfile <<-G
- source "file://#{gem_repo1}"
-
- gem "rack", "1.0.0"
- git "#{git_path}", :ref => "#{revision}" do
- gem "foo"
- end
- G
-
- FileUtils.mkdir_p(bundled_app("real-path"))
- FileUtils.ln_sf(bundled_app("real-path"), bundled_app("symlink-path"))
-
- bundle "config set path #{bundled_app("symlink-path")}"
- bundle "install"
-
- bundle :clean
-
- expect(out).not_to include("Removing foo (#{revision[0..11]})")
-
- expect(bundled_app("symlink-path/#{Bundler.ruby_scope}/bundler/gems/foo-#{revision[0..11]}")).to exist
- end
-
- it "removes old git gems" do
- build_git "foo-bar", :path => lib_path("foo-bar")
- revision = revision_for(lib_path("foo-bar"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- git "#{lib_path("foo-bar")}" do
- gem "foo-bar"
- end
- G
-
- bundle "config set path vendor/bundle"
- bundle! "install"
-
- update_git "foo", :path => lib_path("foo-bar")
- revision2 = revision_for(lib_path("foo-bar"))
-
- bundle! "update", :all => true
- bundle! :clean
-
- expect(out).to include("Removing foo-bar (#{revision[0..11]})")
-
- expect(vendored_gems("gems/rack-1.0.0")).to exist
- expect(vendored_gems("bundler/gems/foo-bar-#{revision[0..11]}")).not_to exist
- expect(vendored_gems("bundler/gems/foo-bar-#{revision2[0..11]}")).to exist
-
- expect(vendored_gems("specifications/rack-1.0.0.gemspec")).to exist
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "does not remove nested gems in a git repo" do
- build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport")
- build_git "rails", "3.0", :path => lib_path("rails") do |s|
- s.add_dependency "activesupport", "= 3.0"
- end
- revision = revision_for(lib_path("rails"))
-
- gemfile <<-G
- gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}'
- G
-
- bundle "config set path vendor/bundle"
- bundle "install"
- bundle :clean
- expect(out).to include("")
-
- expect(vendored_gems("bundler/gems/rails-#{revision[0..11]}")).to exist
- end
-
- it "does not remove git sources that are in without groups" do
- build_git "foo", :path => lib_path("foo")
- git_path = lib_path("foo")
- revision = revision_for(git_path)
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- group :test do
- git "#{git_path}", :ref => "#{revision}" do
- gem "foo"
- end
- end
- G
- bundle "config set path vendor/bundle"
- bundle "config set without test"
- bundle "install"
-
- bundle :clean
-
- expect(out).to include("")
- expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).to exist
- digest = Digest(:SHA1).hexdigest(git_path.to_s)
- expect(vendored_gems("cache/bundler/git/foo-#{digest}")).to_not exist
- end
-
- it "does not blow up when using without groups" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
-
- group :development do
- gem "foo"
- end
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set without development"
- bundle "install"
-
- bundle :clean
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- it "displays an error when used without --path" do
- bundle! "config set path.system true"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- G
-
- bundle :clean
-
- expect(exitstatus).to eq(15) if exitstatus
- expect(err).to include("--force")
- end
-
- # handling bundle clean upgrade path from the pre's
- it "removes .gem/.gemspec file even if there's no corresponding gem dir" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo"
- G
- bundle "install"
-
- FileUtils.rm(vendored_gems("bin/rackup"))
- FileUtils.rm_rf(vendored_gems("gems/thin-1.0"))
- FileUtils.rm_rf(vendored_gems("gems/rack-1.0.0"))
-
- bundle :clean
-
- should_not_have_gems "thin-1.0", "rack-1.0"
- should_have_gems "foo-1.0"
-
- expect(vendored_gems("bin/rackup")).not_to exist
- end
-
- it "does not call clean automatically when using system gems" do
- bundle! "config set path.system true"
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "rack"
- G
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- gem_command! :list
- expect(out).to include("rack (1.0.0)").and include("thin (1.0)")
- end
-
- it "--clean should override the bundle setting on install", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "rack"
- G
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle "install --clean true"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
- bundle "install"
-
- should_have_gems "rack-1.0.0"
- should_not_have_gems "thin-1.0"
- end
-
- it "--clean should override the bundle setting on update", :bundler => "< 3" do
- build_repo2
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "foo"
- G
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle "install --clean true"
-
- update_repo2 do
- build_gem "foo", "1.0.1"
- end
-
- bundle! "update", :all => true
-
- should_have_gems "foo-1.0.1"
- should_not_have_gems "foo-1.0"
- end
-
- it "automatically cleans when path has not been set", :bundler => "3" do
- build_repo2
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "foo"
- G
-
- update_repo2 do
- build_gem "foo", "1.0.1"
- end
-
- bundle! "update", :all => true
-
- files = Pathname.glob(bundled_app(".bundle", Bundler.ruby_scope, "*", "*"))
- files.map! {|f| f.to_s.sub(bundled_app(".bundle", Bundler.ruby_scope).to_s, "") }
- expect(files.sort).to eq %w[
- /cache/foo-1.0.1.gem
- /gems/foo-1.0.1
- /specifications/foo-1.0.1.gemspec
- ]
- end
-
- it "does not clean automatically on --path" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "rack"
- G
- bundle "config set path vendor/bundle"
- bundle "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
- bundle "install"
-
- should_have_gems "rack-1.0.0", "thin-1.0"
- end
-
- it "does not clean on bundle update with --path" do
- build_repo2
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "foo"
- G
- bundle "config set path vendor/bundle"
- bundle! "install"
-
- update_repo2 do
- build_gem "foo", "1.0.1"
- end
-
- bundle! :update, :all => true
- should_have_gems "foo-1.0", "foo-1.0.1"
- end
-
- it "does not clean on bundle update when using --system" do
- bundle! "config set path.system true"
-
- build_repo2
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "foo"
- G
- bundle! "install"
-
- update_repo2 do
- build_gem "foo", "1.0.1"
- end
- bundle! :update, :all => true
-
- gem_command! :list
- expect(out).to include("foo (1.0.1, 1.0)")
- end
-
- it "cleans system gems when --force is used" do
- bundle! "config set path.system true"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo"
- gem "rack"
- G
- bundle :install
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
- bundle :install
- bundle "clean --force"
-
- expect(out).to include("Removing foo (1.0)")
- gem_command! :list
- expect(out).not_to include("foo (1.0)")
- expect(out).to include("rack (1.0.0)")
- end
-
- describe "when missing permissions" do
- before { ENV["BUNDLE_PATH__SYSTEM"] = "true" }
- let(:system_cache_path) { system_gem_path("cache") }
- after do
- FileUtils.chmod(0o755, system_cache_path)
- end
- it "returns a helpful error message" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo"
- gem "rack"
- G
- bundle :install
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
- bundle :install
-
- FileUtils.chmod(0o500, system_cache_path)
-
- bundle :clean, :force => true
-
- expect(err).to include(system_gem_path.to_s)
- expect(err).to include("grant write permissions")
-
- gem_command! :list
- expect(out).to include("foo (1.0)")
- expect(out).to include("rack (1.0.0)")
- end
- end
-
- it "cleans git gems with a 7 length git revision" do
- build_git "foo"
- revision = revision_for(lib_path("foo-1.0"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- bundle "config set path vendor/bundle"
- bundle "install"
-
- # mimic 7 length git revisions in Gemfile.lock
- gemfile_lock = File.read(bundled_app("Gemfile.lock")).split("\n")
- gemfile_lock.each_with_index do |line, index|
- gemfile_lock[index] = line[0..(11 + 7)] if line.include?(" revision:")
- end
- lockfile(bundled_app("Gemfile.lock"), gemfile_lock.join("\n"))
-
- bundle "config set path vendor/bundle"
- bundle "install"
-
- bundle :clean
-
- expect(out).not_to include("Removing foo (1.0 #{revision[0..6]})")
-
- expect(vendored_gems("bundler/gems/foo-1.0-#{revision[0..6]}")).to exist
- end
-
- it "when using --force on system gems, it doesn't remove binaries" do
- bundle! "config set path.system true"
-
- build_repo2
- update_repo2 do
- build_gem "bindir" do |s|
- s.bindir = "exe"
- s.executables = "foo"
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "bindir"
- G
- bundle :install
-
- bundle "clean --force"
-
- sys_exec "foo"
-
- expect(exitstatus).to eq(0) if exitstatus
- expect(out).to eq("1.0")
- end
-
- it "doesn't blow up on path gems without a .gemspec" do
- relative_path = "vendor/private_gems/bar-1.0"
- absolute_path = bundled_app(relative_path)
- FileUtils.mkdir_p("#{absolute_path}/lib/bar")
- File.open("#{absolute_path}/lib/bar/bar.rb", "wb") do |file|
- file.puts "module Bar; end"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo"
- gem "bar", "1.0", :path => "#{relative_path}"
- G
-
- bundle "config set path vendor/bundle"
- bundle "install"
- bundle! :clean
- end
-
- it "doesn't remove gems in dry-run mode with path set" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- G
-
- bundle :install
-
- bundle "clean --dry-run"
-
- expect(out).not_to include("Removing foo (1.0)")
- expect(out).to include("Would have removed foo (1.0)")
-
- should_have_gems "thin-1.0", "rack-1.0.0", "foo-1.0"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "doesn't remove gems in dry-run mode with no path set" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- G
-
- bundle :install
-
- bundle "clean --dry-run"
-
- expect(out).not_to include("Removing foo (1.0)")
- expect(out).to include("Would have removed foo (1.0)")
-
- should_have_gems "thin-1.0", "rack-1.0.0", "foo-1.0"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "doesn't store dry run as a config setting" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle "install"
- bundle "config set dry_run false"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- G
-
- bundle :install
-
- bundle "clean"
-
- expect(out).to include("Removing foo (1.0)")
- expect(out).not_to include("Would have removed foo (1.0)")
-
- should_have_gems "thin-1.0", "rack-1.0.0"
- should_not_have_gems "foo-1.0"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "foo"
- G
-
- bundle "config set path vendor/bundle"
- bundle "config set clean false"
- bundle! "install"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "weakling"
- G
-
- bundle! "config set auto_install 1"
- bundle! :clean
- expect(out).to include("Installing weakling 0.0.3")
- should_have_gems "thin-1.0", "rack-1.0.0", "weakling-0.0.3"
- should_not_have_gems "foo-1.0"
- end
-
- it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo do
- build_git "very_simple_git_binary", &:add_c_extension
-
- revision = revision_for(lib_path("very_simple_git_binary-1.0"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
- G
-
- bundle "config set path vendor/bundle"
- bundle! "install"
- expect(vendored_gems("bundler/gems/extensions")).to exist
- expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
-
- bundle! :clean
- expect(out).to be_empty
-
- expect(vendored_gems("bundler/gems/extensions")).to exist
- expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
- end
-
- it "removes extension directories", :ruby_repo do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "very_simple_binary"
- gem "simple_binary"
- G
-
- bundle "config set path vendor/bundle"
- bundle! "install"
-
- very_simple_binary_extensions_dir =
- Pathname.glob("#{vendored_gems}/extensions/*/*/very_simple_binary-1.0").first
-
- simple_binary_extensions_dir =
- Pathname.glob("#{vendored_gems}/extensions/*/*/simple_binary-1.0").first
-
- expect(very_simple_binary_extensions_dir).to exist
- expect(simple_binary_extensions_dir).to exist
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "simple_binary"
- G
-
- bundle! "install"
- bundle! :clean
- expect(out).to eq("Removing very_simple_binary (1.0)")
-
- expect(very_simple_binary_extensions_dir).not_to exist
- expect(simple_binary_extensions_dir).to exist
- end
-
- it "removes git extension directories", :ruby_repo do
- build_git "very_simple_git_binary", &:add_c_extension
-
- revision = revision_for(lib_path("very_simple_git_binary-1.0"))
- short_revision = revision[0..11]
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
- G
-
- bundle "config set path vendor/bundle"
- bundle! "install"
-
- very_simple_binary_extensions_dir =
- Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
-
- expect(very_simple_binary_extensions_dir).to exist
-
- gemfile <<-G
- gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
- G
-
- bundle! "install"
- bundle! :clean
- expect(out).to include("Removing thin (1.0)")
- expect(very_simple_binary_extensions_dir).to exist
-
- gemfile <<-G
- G
-
- bundle! "install"
- bundle! :clean
- expect(out).to eq("Removing very_simple_git_binary-1.0 (#{short_revision})")
-
- expect(very_simple_binary_extensions_dir).not_to exist
- end
-
- it "keeps git extension directories when excluded by group", :ruby_repo do
- build_git "very_simple_git_binary", &:add_c_extension
-
- revision = revision_for(lib_path("very_simple_git_binary-1.0"))
- short_revision = revision[0..11]
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :development do
- gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
- end
- G
-
- bundle :lock
- bundle "config set without development"
- bundle "config set path vendor/bundle"
- bundle! "install"
- bundle! :clean
-
- very_simple_binary_extensions_dir =
- Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
-
- expect(very_simple_binary_extensions_dir).to be_nil
- end
-end
diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb
deleted file mode 100644
index ef580463e5..0000000000
--- a/spec/bundler/commands/config_spec.rb
+++ /dev/null
@@ -1,493 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe ".bundle/config" do
- describe "config" do
- before { bundle "config set foo bar" }
-
- it "prints a detailed report of local and user configuration" do
- bundle "config list"
-
- expect(out).to include("Settings are listed in order of priority. The top value will be used")
- expect(out).to include("foo\nSet for the current user")
- expect(out).to include(": \"bar\"")
- end
-
- context "given --parseable flag" do
- it "prints a minimal report of local and user configuration" do
- bundle "config list --parseable"
- expect(out).to include("foo=bar")
- end
-
- context "with global config" do
- it "prints config assigned to local scope" do
- bundle "config set --local foo bar2"
- bundle "config list --parseable"
- expect(out).to include("foo=bar2")
- end
- end
-
- context "with env overwrite" do
- it "prints config with env" do
- bundle "config list --parseable", :env => { "BUNDLE_FOO" => "bar3" }
- expect(out).to include("foo=bar3")
- end
- end
- end
- end
-
- describe "location" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- G
- end
-
- it "can be moved with an environment variable" do
- ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s
- bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
-
- expect(bundled_app(".bundle")).not_to exist
- expect(tmp("foo/bar/config")).to exist
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "can provide a relative path with the environment variable" do
- FileUtils.mkdir_p bundled_app("omg")
- Dir.chdir bundled_app("omg")
-
- ENV["BUNDLE_APP_CONFIG"] = "../foo"
- bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
-
- expect(bundled_app(".bundle")).not_to exist
- expect(bundled_app("../foo/config")).to exist
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- describe "global" do
- before(:each) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- G
- end
-
- it "is the default" do
- bundle "config set foo global"
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("global")
- end
-
- it "can also be set explicitly" do
- bundle! "config set --global foo global"
- run! "puts Bundler.settings[:foo]"
- expect(out).to eq("global")
- end
-
- it "has lower precedence than local" do
- bundle "config set --local foo local"
-
- bundle "config set --global foo global"
- expect(out).to match(/Your application has set foo to "local"/)
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("local")
- end
-
- it "has lower precedence than env" do
- begin
- ENV["BUNDLE_FOO"] = "env"
-
- bundle "config set --global foo global"
- expect(out).to match(/You have a bundler environment variable for foo set to "env"/)
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("env")
- ensure
- ENV.delete("BUNDLE_FOO")
- end
- end
-
- it "can be deleted" do
- bundle "config set --global foo global"
- bundle "config unset foo"
-
- run "puts Bundler.settings[:foo] == nil"
- expect(out).to eq("true")
- end
-
- it "warns when overriding" do
- bundle "config set --global foo previous"
- bundle "config set --global foo global"
- expect(out).to match(/You are replacing the current global value of foo/)
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("global")
- end
-
- it "does not warn when using the same value twice" do
- bundle "config set --global foo value"
- bundle "config set --global foo value"
- expect(out).not_to match(/You are replacing the current global value of foo/)
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("value")
- end
-
- it "expands the path at time of setting" do
- bundle "config set --global local.foo .."
- run "puts Bundler.settings['local.foo']"
- expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
- end
-
- it "saves with parseable option" do
- bundle "config set --global --parseable foo value"
- expect(out).to eq("foo=value")
- run "puts Bundler.settings['foo']"
- expect(out).to eq("value")
- end
-
- context "when replacing a current value with the parseable flag" do
- before { bundle "config set --global foo value" }
- it "prints the current value in a parseable format" do
- bundle "config set --global --parseable foo value2"
- expect(out).to eq "foo=value2"
- run "puts Bundler.settings['foo']"
- expect(out).to eq("value2")
- end
- end
- end
-
- describe "local" do
- before(:each) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- G
- end
-
- it "can also be set explicitly" do
- bundle "config set --local foo local"
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("local")
- end
-
- it "has higher precedence than env" do
- begin
- ENV["BUNDLE_FOO"] = "env"
- bundle "config set --local foo local"
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("local")
- ensure
- ENV.delete("BUNDLE_FOO")
- end
- end
-
- it "can be deleted" do
- bundle "config set --local foo local"
- bundle "config unset foo"
-
- run "puts Bundler.settings[:foo] == nil"
- expect(out).to eq("true")
- end
-
- it "warns when overriding" do
- bundle "config set --local foo previous"
- bundle "config set --local foo local"
- expect(out).to match(/You are replacing the current local value of foo/)
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("local")
- end
-
- it "expands the path at time of setting" do
- bundle "config set --local local.foo .."
- run "puts Bundler.settings['local.foo']"
- expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
- end
-
- it "can be deleted with parseable option" do
- bundle "config set --local foo value"
- bundle "config unset --parseable foo"
- expect(out).to eq ""
- run "puts Bundler.settings['foo'] == nil"
- expect(out).to eq("true")
- end
- end
-
- describe "env" do
- before(:each) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- G
- end
-
- it "can set boolean properties via the environment" do
- ENV["BUNDLE_FROZEN"] = "true"
-
- run "if Bundler.settings[:frozen]; puts 'true' else puts 'false' end"
- expect(out).to eq("true")
- end
-
- it "can set negative boolean properties via the environment" do
- run "if Bundler.settings[:frozen]; puts 'true' else puts 'false' end"
- expect(out).to eq("false")
-
- ENV["BUNDLE_FROZEN"] = "false"
-
- run "if Bundler.settings[:frozen]; puts 'true' else puts 'false' end"
- expect(out).to eq("false")
-
- ENV["BUNDLE_FROZEN"] = "0"
-
- run "if Bundler.settings[:frozen]; puts 'true' else puts 'false' end"
- expect(out).to eq("false")
-
- ENV["BUNDLE_FROZEN"] = ""
-
- run "if Bundler.settings[:frozen]; puts 'true' else puts 'false' end"
- expect(out).to eq("false")
- end
-
- it "can set properties with periods via the environment" do
- ENV["BUNDLE_FOO__BAR"] = "baz"
-
- run "puts Bundler.settings['foo.bar']"
- expect(out).to eq("baz")
- end
- end
-
- describe "parseable option" do
- it "prints an empty string" do
- bundle "config get foo --parseable"
-
- expect(out).to eq ""
- end
-
- it "only prints the value of the config" do
- bundle "config set foo local"
- bundle "config get foo --parseable"
-
- expect(out).to eq "foo=local"
- end
-
- it "can print global config" do
- bundle "config set --global bar value"
- bundle "config get bar --parseable"
-
- expect(out).to eq "bar=value"
- end
-
- it "prefers local config over global" do
- bundle "config set --local bar value2"
- bundle "config set --global bar value"
- bundle "config get bar --parseable"
-
- expect(out).to eq "bar=value2"
- end
- end
-
- describe "gem mirrors" do
- before(:each) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- G
- end
-
- it "configures mirrors using keys with `mirror.`" do
- bundle "config set --local mirror.http://gems.example.org http://gem-mirror.example.org"
- run(<<-E)
-Bundler.settings.gem_mirrors.each do |k, v|
- puts "\#{k} => \#{v}"
-end
-E
- expect(out).to eq("http://gems.example.org/ => http://gem-mirror.example.org/")
- end
- end
-
- describe "quoting" do
- before(:each) { gemfile "# no gems" }
- let(:long_string) do
- "--with-xml2-include=/usr/pkg/include/libxml2 --with-xml2-lib=/usr/pkg/lib " \
- "--with-xslt-dir=/usr/pkg"
- end
-
- it "saves quotes" do
- bundle "config set foo something\\'"
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("something'")
- end
-
- it "doesn't return quotes around values" do
- bundle "config set foo '1'"
- run "puts Bundler.settings.send(:global_config_file).read"
- expect(out).to include('"1"')
- run "puts Bundler.settings[:foo]"
- expect(out).to eq("1")
- end
-
- it "doesn't duplicate quotes around values" do
- bundled_app(".bundle").mkpath
- File.open(bundled_app(".bundle/config"), "w") do |f|
- f.write 'BUNDLE_FOO: "$BUILD_DIR"'
- end
-
- bundle "config set bar baz"
- run "puts Bundler.settings.send(:local_config_file).read"
-
- # Starting in Ruby 2.1, YAML automatically adds double quotes
- # around some values, including $ and newlines.
- expect(out).to include('BUNDLE_FOO: "$BUILD_DIR"')
- end
-
- it "doesn't duplicate quotes around long wrapped values" do
- bundle "config set foo #{long_string}"
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq(long_string)
-
- bundle "config set bar baz"
-
- run "puts Bundler.settings[:foo]"
- expect(out).to eq(long_string)
- end
- end
-
- describe "very long lines" do
- before(:each) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- G
- end
-
- let(:long_string) do
- "--with-xml2-include=/usr/pkg/include/libxml2 --with-xml2-lib=/usr/pkg/lib " \
- "--with-xslt-dir=/usr/pkg"
- end
-
- let(:long_string_without_special_characters) do
- "here is quite a long string that will wrap to a second line but will not be " \
- "surrounded by quotes"
- end
-
- it "doesn't wrap values" do
- bundle "config set foo #{long_string}"
- run "puts Bundler.settings[:foo]"
- expect(out).to match(long_string)
- end
-
- it "can read wrapped unquoted values" do
- bundle "config set foo #{long_string_without_special_characters}"
- run "puts Bundler.settings[:foo]"
- expect(out).to match(long_string_without_special_characters)
- end
- end
-
- describe "subcommands" do
- it "list" do
- bundle! "config list"
- expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
-
- bundle! "config list", :parseable => true
- expect(out).to eq "spec_run=true"
- end
-
- it "get" do
- ENV["BUNDLE_BAR"] = "bar_val"
-
- bundle! "config get foo"
- expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
-
- ENV["BUNDLE_FOO"] = "foo_val"
-
- bundle! "config get foo --parseable"
- expect(out).to eq "foo=foo_val"
-
- bundle! "config get foo"
- expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
- end
-
- it "set" do
- bundle! "config set foo 1"
- expect(out).to eq ""
-
- bundle! "config set --local foo 2"
- expect(out).to eq ""
-
- bundle! "config set --global foo 3"
- expect(out).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
-
- bundle! "config set --parseable --local foo 4"
- expect(out).to eq "foo=4"
-
- bundle! "config set --local foo 4.1"
- expect(out).to eq "You are replacing the current local value of foo, which is currently \"4\""
-
- bundle "config set --global --local foo 5"
- expect(last_command).to be_failure
- expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
- end
-
- it "unset" do
- bundle! "config unset foo"
- expect(out).to eq ""
-
- bundle! "config set foo 1"
- bundle! "config unset foo --parseable"
- expect(out).to eq ""
-
- bundle! "config set --local foo 1"
- bundle! "config set --global foo 2"
-
- bundle! "config unset foo"
- expect(out).to eq ""
- expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
-
- bundle! "config set --local foo 1"
- bundle! "config set --global foo 2"
-
- bundle! "config unset foo --local"
- expect(out).to eq ""
- expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\""
- bundle! "config unset foo --global"
- expect(out).to eq ""
- expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
-
- bundle! "config set --local foo 1"
- bundle! "config set --global foo 2"
-
- bundle! "config unset foo --global"
- expect(out).to eq ""
- expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\""
- bundle! "config unset foo --local"
- expect(out).to eq ""
- expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
-
- bundle "config unset foo --local --global"
- expect(last_command).to be_failure
- expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
- end
- end
-end
-
-RSpec.describe "setting gemfile via config" do
- context "when only the non-default Gemfile exists" do
- it "persists the gemfile location to .bundle/config" do
- gemfile bundled_app("NotGemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
- expect(File.exist?(".bundle/config")).to eq(true)
-
- bundle "config list"
- expect(out).to include("NotGemfile")
- end
- end
-end
diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb
deleted file mode 100644
index a0b71ff016..0000000000
--- a/spec/bundler/commands/console_spec.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle console", :bundler => "< 3" do
- before :each do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
- G
- end
-
- it "starts IRB with the default group loaded" do
- bundle "console" do |input, _, _|
- input.puts("puts RACK")
- input.puts("exit")
- end
- expect(out).to include("0.9.1")
- end
-
- it "uses IRB as default console" do
- bundle "console" do |input, _, _|
- input.puts("__method__")
- input.puts("exit")
- end
- expect(out).to include(":irb_binding")
- end
-
- it "starts another REPL if configured as such" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "pry"
- G
- bundle "config set console pry"
-
- bundle "console" do |input, _, _|
- input.puts("__method__")
- input.puts("exit")
- end
- expect(out).to include(":__pry__")
- end
-
- it "falls back to IRB if the other REPL isn't available" do
- bundle "config set console pry"
- # make sure pry isn't there
-
- bundle "console" do |input, _, _|
- input.puts("__method__")
- input.puts("exit")
- end
- expect(out).to include(":irb_binding")
- end
-
- it "doesn't load any other groups" do
- bundle "console" do |input, _, _|
- input.puts("puts ACTIVESUPPORT")
- input.puts("exit")
- end
- expect(out).to include("NameError")
- end
-
- describe "when given a group" do
- it "loads the given group" do
- bundle "console test" do |input, _, _|
- input.puts("puts ACTIVESUPPORT")
- input.puts("exit")
- end
- expect(out).to include("2.3.5")
- end
-
- it "loads the default group" do
- bundle "console test" do |input, _, _|
- input.puts("puts RACK")
- input.puts("exit")
- end
- expect(out).to include("0.9.1")
- end
-
- it "doesn't load other groups" do
- bundle "console test" do |input, _, _|
- input.puts("puts RACK_MIDDLEWARE")
- input.puts("exit")
- end
- expect(out).to include("NameError")
- end
- end
-
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
- gem "foo"
- G
-
- bundle "config set auto_install 1"
- bundle :console do |input, _, _|
- input.puts("puts 'hello'")
- input.puts("exit")
- end
- expect(out).to include("Installing foo 1.0")
- expect(out).to include("hello")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-end
diff --git a/spec/bundler/commands/doctor_spec.rb b/spec/bundler/commands/doctor_spec.rb
deleted file mode 100644
index d829f00092..0000000000
--- a/spec/bundler/commands/doctor_spec.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-# frozen_string_literal: true
-
-require "find"
-require "stringio"
-require "bundler/cli"
-require "bundler/cli/doctor"
-
-RSpec.describe "bundle doctor" do
- before(:each) do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- @stdout = StringIO.new
-
- [:error, :warn].each do |method|
- allow(Bundler.ui).to receive(method).and_wrap_original do |m, message|
- m.call message
- @stdout.puts message
- end
- end
- end
-
- it "succeeds on a sane installation" do
- bundle :doctor
-
- expect(exitstatus).to eq(0)
- end
-
- context "when all files in home are readable/writable" do
- before(:each) do
- stat = double("stat")
- unwritable_file = double("file")
- allow(Find).to receive(:find).with(Bundler.bundle_path.to_s) { [unwritable_file] }
- allow(File).to receive(:stat).with(unwritable_file) { stat }
- allow(stat).to receive(:uid) { Process.uid }
- allow(File).to receive(:writable?).with(unwritable_file) { true }
- allow(File).to receive(:readable?).with(unwritable_file) { true }
- end
-
- it "exits with no message if the installed gem has no C extensions" do
- expect { Bundler::CLI::Doctor.new({}).run }.not_to raise_error
- expect(@stdout.string).to be_empty
- end
-
- it "exits with no message if the installed gem's C extension dylib breakage is fine" do
- doctor = Bundler::CLI::Doctor.new({})
- expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
- expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/lib/libSystem.dylib"]
- allow(File).to receive(:exist?).and_call_original
- allow(File).to receive(:exist?).with("/usr/lib/libSystem.dylib").and_return(true)
- expect { doctor.run }.not_to(raise_error, @stdout.string)
- expect(@stdout.string).to be_empty
- end
-
- it "exits with a message if one of the linked libraries is missing" do
- doctor = Bundler::CLI::Doctor.new({})
- expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
- expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"]
- allow(File).to receive(:exist?).and_call_original
- allow(File).to receive(:exist?).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_return(false)
- expect { doctor.run }.to raise_error(Bundler::ProductionError, strip_whitespace(<<-E).strip), @stdout.string
- The following gems are missing OS dependencies:
- * bundler: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
- * rack: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
- E
- end
- end
-
- context "when home contains files that are not readable/writable" do
- before(:each) do
- @stat = double("stat")
- @unwritable_file = double("file")
- allow(Find).to receive(:find).with(Bundler.bundle_path.to_s) { [@unwritable_file] }
- allow(File).to receive(:stat).with(@unwritable_file) { @stat }
- end
-
- it "exits with an error if home contains files that are not readable/writable" do
- allow(@stat).to receive(:uid) { Process.uid }
- allow(File).to receive(:writable?).with(@unwritable_file) { false }
- allow(File).to receive(:readable?).with(@unwritable_file) { false }
- expect { Bundler::CLI::Doctor.new({}).run }.not_to raise_error
- expect(@stdout.string).to include(
- "Files exist in the Bundler home that are not readable/writable by the current user. These files are:\n - #{@unwritable_file}"
- )
- expect(@stdout.string).not_to include("No issues")
- end
-
- context "when home contains files that are not owned by the current process" do
- before(:each) do
- allow(@stat).to receive(:uid) { 0o0000 }
- end
-
- it "exits with an error if home contains files that are not readable/writable and are not owned by the current user" do
- allow(File).to receive(:writable?).with(@unwritable_file) { false }
- allow(File).to receive(:readable?).with(@unwritable_file) { false }
- expect { Bundler::CLI::Doctor.new({}).run }.not_to raise_error
- expect(@stdout.string).to include(
- "Files exist in the Bundler home that are owned by another user, and are not readable/writable. These files are:\n - #{@unwritable_file}"
- )
- expect(@stdout.string).not_to include("No issues")
- end
-
- it "exits with a warning if home contains files that are read/write but not owned by current user" do
- allow(File).to receive(:writable?).with(@unwritable_file) { true }
- allow(File).to receive(:readable?).with(@unwritable_file) { true }
- expect { Bundler::CLI::Doctor.new({}).run }.not_to raise_error
- expect(@stdout.string).to include(
- "Files exist in the Bundler home that are owned by another user, but are still readable/writable. These files are:\n - #{@unwritable_file}"
- )
- expect(@stdout.string).not_to include("No issues")
- end
- end
- end
-end
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
deleted file mode 100644
index 42f760ab12..0000000000
--- a/spec/bundler/commands/exec_spec.rb
+++ /dev/null
@@ -1,913 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle exec" do
- let(:system_gems_to_install) { %w[rack-1.0.0 rack-0.9.1] }
- before :each do
- system_gems(system_gems_to_install, :path => :bundle_path)
- end
-
- it "works with --gemfile flag" do
- create_file "CustomGemfile", <<-G
- gem "rack", "1.0.0"
- G
-
- bundle "exec --gemfile CustomGemfile rackup"
- expect(out).to eq("1.0.0")
- end
-
- it "activates the correct gem" do
- gemfile <<-G
- gem "rack", "0.9.1"
- G
-
- bundle "exec rackup"
- expect(out).to eq("0.9.1")
- end
-
- it "works when the bins are in ~/.bundle" do
- install_gemfile <<-G
- gem "rack"
- G
-
- bundle "exec rackup"
- expect(out).to eq("1.0.0")
- end
-
- it "works when running from a random directory" do
- install_gemfile <<-G
- gem "rack"
- G
-
- bundle "exec 'cd #{tmp("gems")} && rackup'"
-
- expect(out).to eq("1.0.0")
- end
-
- it "works when exec'ing something else" do
- install_gemfile 'gem "rack"'
- bundle "exec echo exec"
- expect(out).to eq("exec")
- end
-
- it "works when exec'ing to ruby" do
- install_gemfile 'gem "rack"'
- bundle "exec ruby -e 'puts %{hi}'"
- expect(out).to eq("hi")
- end
-
- it "works when exec'ing to rubygems" do
- install_gemfile 'gem "rack"'
- bundle "exec #{gem_cmd} --version"
- expect(out).to eq(Gem::VERSION)
- end
-
- it "works when exec'ing to rubygems through sh -c" do
- install_gemfile 'gem "rack"'
- bundle "exec sh -c '#{gem_cmd} --version'"
- expect(out).to eq(Gem::VERSION)
- end
-
- it "respects custom process title when loading through ruby" do
- script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY'
- Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15")
- puts `ps -ocommand= -p#{$$}`
- RUBY
- create_file "Gemfile"
- create_file "a.rb", script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility
- bundle "exec ruby a.rb"
- expect(out).to eq("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15")
- end
-
- it "accepts --verbose" do
- install_gemfile 'gem "rack"'
- bundle "exec --verbose echo foobar"
- expect(out).to eq("foobar")
- end
-
- it "passes --verbose to command if it is given after the command" do
- install_gemfile 'gem "rack"'
- bundle "exec echo --verbose"
- expect(out).to eq("--verbose")
- end
-
- it "handles --keep-file-descriptors" do
- require "tempfile"
-
- command = Tempfile.new("io-test")
- command.sync = true
- command.write <<-G
- if ARGV[0]
- IO.for_fd(ARGV[0].to_i)
- else
- require 'tempfile'
- io = Tempfile.new("io-test-fd")
- args = %W[#{Gem.ruby} -I#{lib_dir} #{bindir.join("bundle")} exec --keep-file-descriptors #{Gem.ruby} #{command.path} \#{io.to_i}]
- args << { io.to_i => io }
- exec(*args)
- end
- G
-
- install_gemfile ""
- sys_exec "#{Gem.ruby} #{command.path}"
-
- expect(out).to be_empty
- expect(err).to be_empty
- end
-
- it "accepts --keep-file-descriptors" do
- install_gemfile ""
- bundle "exec --keep-file-descriptors echo foobar"
-
- expect(err).to be_empty
- end
-
- it "can run a command named --verbose" do
- install_gemfile 'gem "rack"'
- File.open("--verbose", "w") do |f|
- f.puts "#!/bin/sh"
- f.puts "echo foobar"
- end
- File.chmod(0o744, "--verbose")
- with_path_as(".") do
- bundle "exec -- --verbose"
- end
- expect(out).to eq("foobar")
- end
-
- it "handles different versions in different bundles" do
- build_repo2 do
- build_gem "rack_two", "1.0.0" do |s|
- s.executables = "rackup"
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- G
-
- Dir.chdir bundled_app2 do
- install_gemfile bundled_app2("Gemfile"), <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack_two", "1.0.0"
- G
- end
-
- bundle! "exec rackup"
-
- expect(out).to eq("0.9.1")
-
- Dir.chdir bundled_app2 do
- bundle! "exec rackup"
- expect(out).to eq("1.0.0")
- end
- end
-
- context "with default gems" do
- let(:system_gems_to_install) { [] }
-
- let(:default_irb_version) { ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION" }
-
- context "when not specified in Gemfile" do
- before do
- skip "irb isn't a default gem" if default_irb_version.empty?
-
- install_gemfile ""
- end
-
- it "uses version provided by ruby" do
- bundle! "exec irb --version"
-
- expect(out).to include(default_irb_version)
- expect(err).to be_empty
- end
- end
-
- context "when specified in Gemfile directly" do
- let(:specified_irb_version) { "0.9.6" }
-
- before do
- skip "irb isn't a default gem" if default_irb_version.empty?
-
- build_repo2 do
- build_gem "irb", specified_irb_version do |s|
- s.executables = "irb"
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "irb", "#{specified_irb_version}"
- G
- end
-
- it "uses version specified" do
- bundle! "exec irb --version"
-
- expect(out).to eq(specified_irb_version)
- expect(err).to be_empty
- end
- end
-
- context "when specified in Gemfile indirectly" do
- let(:indirect_irb_version) { "0.9.6" }
-
- before do
- skip "irb isn't a default gem" if default_irb_version.empty?
-
- build_repo2 do
- build_gem "irb", indirect_irb_version do |s|
- s.executables = "irb"
- end
-
- build_gem "gem_depending_on_old_irb" do |s|
- s.add_dependency "irb", indirect_irb_version
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "gem_depending_on_old_irb"
- G
-
- bundle! "exec irb --version"
- end
-
- it "uses resolved version" do
- expect(out).to eq(indirect_irb_version)
- expect(err).to be_empty
- end
- end
- end
-
- it "warns about executable conflicts" do
- build_repo2 do
- build_gem "rack_two", "1.0.0" do |s|
- s.executables = "rackup"
- end
- end
-
- bundle "config set path.system true"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- G
-
- Dir.chdir bundled_app2 do
- install_gemfile bundled_app2("Gemfile"), <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack_two", "1.0.0"
- G
- end
-
- bundle! "exec rackup"
-
- expect(last_command.stderr).to eq(
- "Bundler is using a binstub that was created for a different gem (rack).\n" \
- "You should run `bundle binstub rack_two` to work around a system/bundle conflict."
- )
- end
-
- it "handles gems installed with --without" do
- install_gemfile <<-G, forgotten_command_line_options(:without => "middleware")
- source "#{file_uri_for(gem_repo1)}"
- gem "rack" # rack 0.9.1 and 1.0 exist
-
- group :middleware do
- gem "rack_middleware" # rack_middleware depends on rack 0.9.1
- end
- G
-
- bundle "exec rackup"
-
- expect(out).to eq("0.9.1")
- expect(the_bundle).not_to include_gems "rack_middleware 1.0"
- end
-
- it "does not duplicate already exec'ed RUBYOPT" do
- install_gemfile <<-G
- gem "rack"
- G
-
- rubyopt = ENV["RUBYOPT"]
- rubyopt = "-r#{lib_dir}/bundler/setup #{rubyopt}"
-
- bundle "exec 'echo $RUBYOPT'"
- expect(out).to have_rubyopts(rubyopt)
-
- bundle "exec 'echo $RUBYOPT'", :env => { "RUBYOPT" => rubyopt }
- expect(out).to have_rubyopts(rubyopt)
- end
-
- it "does not duplicate already exec'ed RUBYLIB" do
- install_gemfile <<-G
- gem "rack"
- G
-
- rubylib = ENV["RUBYLIB"]
- rubylib = rubylib.to_s.split(File::PATH_SEPARATOR).unshift lib_dir.to_s
- rubylib = rubylib.uniq.join(File::PATH_SEPARATOR)
-
- bundle "exec 'echo $RUBYLIB'"
- expect(out).to include(rubylib)
-
- bundle "exec 'echo $RUBYLIB'", :env => { "RUBYLIB" => rubylib }
- expect(out).to include(rubylib)
- end
-
- it "errors nicely when the argument doesn't exist" do
- install_gemfile <<-G
- gem "rack"
- G
-
- bundle "exec foobarbaz"
- expect(exitstatus).to eq(127) if exitstatus
- expect(err).to include("bundler: command not found: foobarbaz")
- expect(err).to include("Install missing gem executables with `bundle install`")
- end
-
- it "errors nicely when the argument is not executable" do
- install_gemfile <<-G
- gem "rack"
- G
-
- bundle "exec touch foo"
- bundle "exec ./foo"
- expect(exitstatus).to eq(126) if exitstatus
- expect(err).to include("bundler: not executable: ./foo")
- end
-
- it "errors nicely when no arguments are passed" do
- install_gemfile <<-G
- gem "rack"
- G
-
- bundle "exec"
- expect(exitstatus).to eq(128) if exitstatus
- expect(err).to include("bundler: exec needs a command to run")
- end
-
- it "raises a helpful error when exec'ing to something outside of the bundle" do
- bundle! "config set clean false" # want to keep the rackup binstub
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "with_license"
- G
- [true, false].each do |l|
- bundle! "config set disable_exec_load #{l}"
- bundle "exec rackup"
- expect(err).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
- end
- end
-
- describe "with help flags" do
- each_prefix = proc do |string, &blk|
- 1.upto(string.length) {|l| blk.call(string[0, l]) }
- end
- each_prefix.call("exec") do |exec|
- describe "when #{exec} is used" do
- before(:each) do
- install_gemfile <<-G
- gem "rack"
- G
-
- create_file("print_args", <<-'RUBY')
- #!/usr/bin/env ruby
- puts "args: #{ARGV.inspect}"
- RUBY
- bundled_app("print_args").chmod(0o755)
- end
-
- it "shows executable's man page when --help is after the executable" do
- bundle "#{exec} print_args --help"
- expect(out).to eq('args: ["--help"]')
- end
-
- it "shows executable's man page when --help is after the executable and an argument" do
- bundle "#{exec} print_args foo --help"
- expect(out).to eq('args: ["foo", "--help"]')
-
- bundle "#{exec} print_args foo bar --help"
- expect(out).to eq('args: ["foo", "bar", "--help"]')
-
- bundle "#{exec} print_args foo --help bar"
- expect(out).to eq('args: ["foo", "--help", "bar"]')
- end
-
- it "shows executable's man page when the executable has a -" do
- FileUtils.mv(bundled_app("print_args"), bundled_app("docker-template"))
- bundle "#{exec} docker-template build discourse --help"
- expect(out).to eq('args: ["build", "discourse", "--help"]')
- end
-
- it "shows executable's man page when --help is after another flag" do
- bundle "#{exec} print_args --bar --help"
- expect(out).to eq('args: ["--bar", "--help"]')
- end
-
- it "uses executable's original behavior for -h" do
- bundle "#{exec} print_args -h"
- expect(out).to eq('args: ["-h"]')
- end
-
- it "shows bundle-exec's man page when --help is between exec and the executable" do
- with_fake_man do
- bundle "#{exec} --help cat"
- end
- expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
- end
-
- it "shows bundle-exec's man page when --help is before exec" do
- with_fake_man do
- bundle "--help #{exec}"
- end
- expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
- end
-
- it "shows bundle-exec's man page when -h is before exec" do
- with_fake_man do
- bundle "-h #{exec}"
- end
- expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
- end
-
- it "shows bundle-exec's man page when --help is after exec" do
- with_fake_man do
- bundle "#{exec} --help"
- end
- expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
- end
-
- it "shows bundle-exec's man page when -h is after exec" do
- with_fake_man do
- bundle "#{exec} -h"
- end
- expect(out).to include(%(["#{root}/man/bundle-exec.1"]))
- end
- end
- end
- end
-
- describe "with gem executables" do
- describe "run from a random directory", :ruby_repo do
- before(:each) do
- install_gemfile <<-G
- gem "rack"
- G
- end
-
- it "works when unlocked" do
- bundle "exec 'cd #{tmp("gems")} && rackup'"
- expect(out).to eq("1.0.0")
- end
-
- it "works when locked" do
- expect(the_bundle).to be_locked
- bundle "exec 'cd #{tmp("gems")} && rackup'"
- expect(out).to eq("1.0.0")
- end
- end
-
- describe "from gems bundled via :path" do
- before(:each) do
- build_lib "fizz", :path => home("fizz") do |s|
- s.executables = "fizz"
- end
-
- install_gemfile <<-G
- gem "fizz", :path => "#{File.expand_path(home("fizz"))}"
- G
- end
-
- it "works when unlocked" do
- bundle "exec fizz"
- expect(out).to eq("1.0")
- end
-
- it "works when locked" do
- expect(the_bundle).to be_locked
-
- bundle "exec fizz"
- expect(out).to eq("1.0")
- end
- end
-
- describe "from gems bundled via :git" do
- before(:each) do
- build_git "fizz_git" do |s|
- s.executables = "fizz_git"
- end
-
- install_gemfile <<-G
- gem "fizz_git", :git => "#{lib_path("fizz_git-1.0")}"
- G
- end
-
- it "works when unlocked" do
- bundle "exec fizz_git"
- expect(out).to eq("1.0")
- end
-
- it "works when locked" do
- expect(the_bundle).to be_locked
- bundle "exec fizz_git"
- expect(out).to eq("1.0")
- end
- end
-
- describe "from gems bundled via :git with no gemspec" do
- before(:each) do
- build_git "fizz_no_gemspec", :gemspec => false do |s|
- s.executables = "fizz_no_gemspec"
- end
-
- install_gemfile <<-G
- gem "fizz_no_gemspec", "1.0", :git => "#{lib_path("fizz_no_gemspec-1.0")}"
- G
- end
-
- it "works when unlocked" do
- bundle "exec fizz_no_gemspec"
- expect(out).to eq("1.0")
- end
-
- it "works when locked" do
- expect(the_bundle).to be_locked
- bundle "exec fizz_no_gemspec"
- expect(out).to eq("1.0")
- end
- end
- end
-
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- gem "foo"
- G
-
- bundle "config set auto_install 1"
- bundle "exec rackup"
- expect(out).to include("Installing foo 1.0")
- end
-
- describe "with gems bundled via :path with invalid gemspecs" do
- it "outputs the gemspec validation errors" do
- build_lib "foo"
-
- gemspec = lib_path("foo-1.0").join("foo.gemspec").to_s
- File.open(gemspec, "w") do |f|
- f.write <<-G
- Gem::Specification.new do |s|
- s.name = 'foo'
- s.version = '1.0'
- s.summary = 'TODO: Add summary'
- s.authors = 'Me'
- end
- G
- end
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- bundle "exec irb"
-
- expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
- expect(err).to match('"TODO" is not a summary')
- end
- end
-
- describe "with gems bundled for deployment" do
- it "works when calling bundler from another script" do
- gemfile <<-G
- module Monkey
- def bin_path(a,b,c)
- raise Gem::GemNotFoundException.new('Fail')
- end
- end
- Bundler.rubygems.extend(Monkey)
- G
- bundle "install --deployment"
- bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'"
- expect(out).to match("true")
- end
- end
-
- context "`load`ing a ruby file instead of `exec`ing" do
- let(:path) { bundled_app("ruby_executable") }
- let(:shebang) { "#!/usr/bin/env ruby" }
- let(:executable) { <<-RUBY.gsub(/^ */, "").strip }
- #{shebang}
-
- require "rack"
- puts "EXEC: \#{caller.grep(/load/).empty? ? 'exec' : 'load'}"
- puts "ARGS: \#{$0} \#{ARGV.join(' ')}"
- puts "RACK: \#{RACK}"
- process_title = `ps -o args -p \#{Process.pid}`.split("\n", 2).last.strip
- puts "PROCESS: \#{process_title}"
- RUBY
-
- before do
- path.open("w") {|f| f << executable }
- path.chmod(0o755)
-
- install_gemfile <<-G
- gem "rack"
- G
- end
-
- let(:exec) { "EXEC: load" }
- let(:args) { "ARGS: #{path} arg1 arg2" }
- let(:rack) { "RACK: 1.0.0" }
- let(:process) do
- title = "PROCESS: #{path}"
- title += " arg1 arg2"
- title
- end
- let(:exit_code) { 0 }
- let(:expected) { [exec, args, rack, process].join("\n") }
- let(:expected_err) { "" }
-
- subject { bundle "exec #{path} arg1 arg2" }
-
- shared_examples_for "it runs" do
- it "like a normally executed executable" do
- subject
- expect(exitstatus).to eq(exit_code) if exitstatus
- expect(err).to eq(expected_err)
- expect(out).to eq(expected)
- end
- end
-
- it_behaves_like "it runs"
-
- context "the executable exits explicitly" do
- let(:executable) { super() << "\nexit #{exit_code}\nputs 'POST_EXIT'\n" }
-
- context "with exit 0" do
- it_behaves_like "it runs"
- end
-
- context "with exit 99" do
- let(:exit_code) { 99 }
- it_behaves_like "it runs"
- end
- end
-
- context "the executable exits by SignalException" do
- let(:executable) do
- ex = super()
- ex << "\n"
- ex << "raise SignalException, 'SIGTERM'\n"
- ex
- end
- let(:expected_err) { "" }
- let(:exit_code) do
- # signal mask 128 + plus signal 15 -> TERM
- # this is specified by C99
- 128 + 15
- end
- it_behaves_like "it runs"
- end
-
- context "the executable is empty" do
- let(:executable) { "" }
-
- let(:exit_code) { 0 }
- let(:expected_err) { "#{path} is empty" }
- let(:expected) { "" }
- it_behaves_like "it runs"
- end
-
- context "the executable raises" do
- let(:executable) { super() << "\nraise 'ERROR'" }
- let(:exit_code) { 1 }
- let(:expected_err) do
- "bundler: failed to load command: #{path} (#{path})" \
- "\nRuntimeError: ERROR\n #{path}:10:in `<top (required)>'"
- end
- it_behaves_like "it runs"
- end
-
- context "the executable raises an error without a backtrace" do
- let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" }
- let(:exit_code) { 1 }
- let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" }
- let(:expected) { super() }
-
- it_behaves_like "it runs"
- end
-
- context "when the file uses the current ruby shebang" do
- let(:shebang) { "#!#{Gem.ruby}" }
- it_behaves_like "it runs"
- end
-
- context "when Bundler.setup fails", :bundler => "< 3" do
- before do
- gemfile <<-G
- gem 'rack', '2'
- G
- ENV["BUNDLER_FORCE_TTY"] = "true"
- end
-
- let(:exit_code) { Bundler::GemNotFound.new.status_code }
- let(:expected) { "" }
- let(:expected_err) { <<-EOS.strip }
-\e[31mCould not find gem 'rack (= 2)' in any of the gem sources listed in your Gemfile.\e[0m
-\e[33mRun `bundle install` to install missing gems.\e[0m
- EOS
-
- it_behaves_like "it runs"
- end
-
- context "when Bundler.setup fails", :bundler => "3" do
- before do
- gemfile <<-G
- gem 'rack', '2'
- G
- ENV["BUNDLER_FORCE_TTY"] = "true"
- end
-
- let(:exit_code) { Bundler::GemNotFound.new.status_code }
- let(:expected) { "" }
- let(:expected_err) { <<-EOS.strip }
-\e[31mCould not find gem 'rack (= 2)' in locally installed gems.
-The source contains 'rack' at: 1.0.0\e[0m
-\e[33mRun `bundle install` to install missing gems.\e[0m
- EOS
-
- it_behaves_like "it runs"
- end
-
- context "when the executable exits non-zero via at_exit" do
- let(:executable) { super() + "\n\nat_exit { $! ? raise($!) : exit(1) }" }
- let(:exit_code) { 1 }
-
- it_behaves_like "it runs"
- end
-
- context "when disable_exec_load is set" do
- let(:exec) { "EXEC: exec" }
- let(:process) { "PROCESS: ruby #{path} arg1 arg2" }
-
- before do
- bundle "config set disable_exec_load true"
- end
-
- it_behaves_like "it runs"
- end
-
- context "regarding $0 and __FILE__" do
- let(:executable) { super() + <<-'RUBY' }
-
- puts "$0: #{$0.inspect}"
- puts "__FILE__: #{__FILE__.inspect}"
- RUBY
-
- let(:expected) { super() + <<-EOS.chomp }
-
-$0: #{path.to_s.inspect}
-__FILE__: #{path.to_s.inspect}
- EOS
-
- it_behaves_like "it runs"
-
- context "when the path is relative" do
- let(:path) { super().relative_path_from(bundled_app) }
-
- it_behaves_like "it runs"
- end
-
- context "when the path is relative with a leading ./" do
- let(:path) { Pathname.new("./#{super().relative_path_from(Pathname.pwd)}") }
-
- pending "relative paths with ./ have absolute __FILE__"
- end
- end
-
- context "signal handling" do
- let(:test_signals) do
- open3_reserved_signals = %w[CHLD CLD PIPE]
- reserved_signals = %w[SEGV BUS ILL FPE VTALRM KILL STOP EXIT]
- bundler_signals = %w[INT]
-
- Signal.list.keys - (bundler_signals + reserved_signals + open3_reserved_signals)
- end
-
- context "signals being trapped by bundler" do
- let(:executable) { strip_whitespace <<-RUBY }
- #{shebang}
- begin
- Thread.new do
- puts 'Started' # For process sync
- STDOUT.flush
- sleep 1 # ignore quality_spec
- raise "Didn't receive INT at all"
- end.join
- rescue Interrupt
- puts "foo"
- end
- RUBY
-
- it "receives the signal" do
- bundle!("exec #{path}") do |_, o, thr|
- o.gets # Consumes 'Started' and ensures that thread has started
- Process.kill("INT", thr.pid)
- end
-
- expect(out).to eq("foo")
- end
- end
-
- context "signals not being trapped by bunder" do
- let(:executable) { strip_whitespace <<-RUBY }
- #{shebang}
-
- signals = #{test_signals.inspect}
- result = signals.map do |sig|
- Signal.trap(sig, "IGNORE")
- end
- puts result.select { |ret| ret == "IGNORE" }.count
- RUBY
-
- it "makes sure no unexpected signals are restored to DEFAULT" do
- test_signals.each do |n|
- Signal.trap(n, "IGNORE")
- end
-
- bundle!("exec #{path}")
-
- expect(out).to eq(test_signals.count.to_s)
- end
- end
- end
- end
-
- context "nested bundle exec" do
- context "when bundle in a local path" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundle "config set path vendor/bundler"
- bundle! :install
- end
-
- it "correctly shells out", :ruby_repo do
- file = bundled_app("file_that_bundle_execs.rb")
- create_file(file, <<-RB)
- #!#{Gem.ruby}
- puts `bundle exec echo foo`
- RB
- file.chmod(0o777)
- bundle! "exec #{file}"
- expect(out).to eq("foo")
- end
- end
-
- context "with a system gem that shadows a default gem" do
- let(:openssl_version) { "99.9.9" }
- let(:expected) { ruby "gem 'openssl', '< 999999'; require 'openssl'; puts OpenSSL::VERSION", :artifice => nil }
-
- it "only leaves the default gem in the stdlib available" do
- skip "openssl isn't a default gem" if expected.empty?
-
- install_gemfile! "" # must happen before installing the broken system gem
-
- build_repo4 do
- build_gem "openssl", openssl_version do |s|
- s.write("lib/openssl.rb", <<-RB)
- raise "custom openssl should not be loaded, it's not in the gemfile!"
- RB
- end
- end
-
- system_gems(:bundler, "openssl-#{openssl_version}", :gem_repo => gem_repo4)
-
- file = bundled_app("require_openssl.rb")
- create_file(file, <<-RB)
- #!/usr/bin/env ruby
- require "openssl"
- puts OpenSSL::VERSION
- warn Gem.loaded_specs.values.map(&:full_name)
- RB
- file.chmod(0o777)
-
- aggregate_failures do
- expect(bundle!("exec #{file}", :artifice => nil)).to eq(expected)
- expect(bundle!("exec bundle exec #{file}", :artifice => nil)).to eq(expected)
- expect(bundle!("exec ruby #{file}", :artifice => nil)).to eq(expected)
- expect(run!(file.read, :artifice => nil)).to eq(expected)
- end
-
- # sanity check that we get the newer, custom version without bundler
- sys_exec("#{Gem.ruby} #{file}")
- expect(err).to include("custom openssl should not be loaded")
- end
- end
- end
-end
diff --git a/spec/bundler/commands/help_spec.rb b/spec/bundler/commands/help_spec.rb
deleted file mode 100644
index f4f90b9347..0000000000
--- a/spec/bundler/commands/help_spec.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle help" do
- it "uses mann when available" do
- with_fake_man do
- bundle "help gemfile"
- end
- expect(out).to eq(%(["#{root}/man/gemfile.5"]))
- end
-
- it "prefixes bundle commands with bundle- when finding the groff files" do
- with_fake_man do
- bundle "help install"
- end
- expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
- end
-
- it "simply outputs the txt file when there is no man on the path" do
- with_path_as("") do
- bundle "help install"
- end
- expect(out).to match(/BUNDLE-INSTALL/)
- end
-
- it "still outputs the old help for commands that do not have man pages yet" do
- bundle "help version"
- expect(out).to include("Prints the bundler's version information")
- end
-
- it "looks for a binary and executes it with --help option if it's named bundler-<task>" do
- File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
- f.puts "#!/usr/bin/env ruby\nputs ARGV.join(' ')\n"
- end
-
- with_path_added(tmp) do
- bundle "help testtasks"
- end
-
- expect(exitstatus).to be_zero if exitstatus
- expect(out).to eq("--help")
- end
-
- it "is called when the --help flag is used after the command" do
- with_fake_man do
- bundle "install --help"
- end
- expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
- end
-
- it "is called when the --help flag is used before the command" do
- with_fake_man do
- bundle "--help install"
- end
- expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
- end
-
- it "is called when the -h flag is used before the command" do
- with_fake_man do
- bundle "-h install"
- end
- expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
- end
-
- it "is called when the -h flag is used after the command" do
- with_fake_man do
- bundle "install -h"
- end
- expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
- end
-
- it "has helpful output when using --help flag for a non-existent command" do
- with_fake_man do
- bundle "instill -h"
- end
- expect(err).to include('Could not find command "instill".')
- end
-
- it "is called when only using the --help flag" do
- with_fake_man do
- bundle "--help"
- end
- expect(out).to eq(%(["#{root}/man/bundle.1"]))
-
- with_fake_man do
- bundle "-h"
- end
- expect(out).to eq(%(["#{root}/man/bundle.1"]))
- end
-end
diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb
deleted file mode 100644
index 4572823498..0000000000
--- a/spec/bundler/commands/info_spec.rb
+++ /dev/null
@@ -1,145 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle info" do
- context "with a standard Gemfile" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
- end
-
- it "creates a Gemfile.lock when invoked with a gem name" do
- FileUtils.rm("Gemfile.lock")
-
- bundle "info rails"
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "prints information if gem exists in bundle" do
- bundle "info rails"
- expect(out).to include "* rails (2.3.2)
-\tSummary: This is just a fake gem for testing
-\tHomepage: http://example.com
-\tPath: #{default_bundle_path("gems", "rails-2.3.2")}"
- end
-
- it "prints path if gem exists in bundle" do
- bundle "info rails --path"
- expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
- end
-
- it "prints the path to the running bundler" do
- bundle "info bundler --path"
- expect(out).to eq(root.to_s)
- end
-
- it "complains if gem not in bundle" do
- bundle "info missing"
- expect(err).to eq("Could not find gem 'missing'.")
- end
-
- context "given a default gem shippped in ruby", :ruby_repo do
- it "prints information about the default gem" do
- bundle "info rdoc"
- expect(out).to include("* rdoc")
- expect(out).to include("Default Gem: yes")
- end
- end
-
- context "when gem does not have homepage" do
- before do
- build_repo2 do
- build_gem "rails", "2.3.2" do |s|
- s.executables = "rails"
- s.summary = "Just another test gem"
- end
- end
- end
-
- it "excludes the homepage field from the output" do
- expect(out).to_not include("Homepage:")
- end
- end
- end
-
- context "with a git repo in the Gemfile" do
- before :each do
- @git = build_git "foo", "1.0"
- end
-
- it "prints out git info" do
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
- expect(the_bundle).to include_gems "foo 1.0"
-
- bundle "info foo"
- expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
- end
-
- it "prints out branch names other than master" do
- update_git "foo", :branch => "omg" do |s|
- s.write "lib/foo.rb", "FOO = '1.0.omg'"
- end
- @revision = revision_for(lib_path("foo-1.0"))[0...6]
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
- G
- expect(the_bundle).to include_gems "foo 1.0.omg"
-
- bundle "info foo"
- expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
- end
-
- it "doesn't print the branch when tied to a ref" do
- sha = revision_for(lib_path("foo-1.0"))
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
- G
-
- bundle "info foo"
- expect(out).to include("foo (1.0 #{sha[0..6]})")
- end
-
- it "handles when a version is a '-' prerelease" do
- @git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
- install_gemfile <<-G
- gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
- G
- expect(the_bundle).to include_gems "foo 1.0.0.pre.beta.1"
-
- bundle! "info foo"
- expect(out).to include("foo (1.0.0.pre.beta.1")
- end
- end
-
- context "with a valid regexp for gem name" do
- it "presents alternatives" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- bundle "info rac"
- expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
- end
- end
-
- context "with an invalid regexp for gem name" do
- it "does not find the gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- invalid_regexp = "[]"
-
- bundle "info #{invalid_regexp}"
- expect(err).to include("Could not find gem '#{invalid_regexp}'.")
- end
- end
-end
diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb
deleted file mode 100644
index 7960ce85bd..0000000000
--- a/spec/bundler/commands/init_spec.rb
+++ /dev/null
@@ -1,177 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle init" do
- it "generates a Gemfile" do
- bundle! :init
- expect(out).to include("Writing new Gemfile")
- expect(bundled_app("Gemfile")).to be_file
- end
-
- context "when a Gemfile already exists" do
- before do
- create_file "Gemfile", <<-G
- gem "rails"
- G
- end
-
- it "does not change existing Gemfiles" do
- expect { bundle :init }.not_to change { File.read(bundled_app("Gemfile")) }
- end
-
- it "notifies the user that an existing Gemfile already exists" do
- bundle :init
- expect(err).to include("Gemfile already exists")
- end
- end
-
- context "when a Gemfile exists in a parent directory" do
- let(:subdir) { "child_dir" }
-
- it "lets users generate a Gemfile in a child directory" do
- bundle! :init
-
- FileUtils.mkdir bundled_app(subdir)
-
- Dir.chdir bundled_app(subdir) do
- bundle! :init
- end
-
- expect(out).to include("Writing new Gemfile")
- expect(bundled_app("#{subdir}/Gemfile")).to be_file
- end
- end
-
- context "when the dir is not writable by the current user" do
- let(:subdir) { "child_dir" }
-
- it "notifies the user that it can not write to it" do
- FileUtils.mkdir bundled_app(subdir)
- # chmod a-w it
- mode = File.stat(bundled_app(subdir)).mode ^ 0o222
- FileUtils.chmod mode, bundled_app(subdir)
-
- Dir.chdir bundled_app(subdir) do
- bundle :init
- end
-
- expect(err).to include("directory is not writable")
- expect(Dir[bundled_app("#{subdir}/*")]).to be_empty
- end
- end
-
- context "given --gemspec option" do
- let(:spec_file) { tmp.join("test.gemspec") }
-
- it "should generate from an existing gemspec" do
- File.open(spec_file, "w") do |file|
- file << <<-S
- Gem::Specification.new do |s|
- s.name = 'test'
- s.add_dependency 'rack', '= 1.0.1'
- s.add_development_dependency 'rspec', '1.2'
- end
- S
- end
-
- bundle :init, :gemspec => spec_file
-
- gemfile = bundled_app("Gemfile").read
- expect(gemfile).to match(%r{source 'https://rubygems.org'})
- expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1)
- expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1)
- expect(gemfile.scan(/group :development/).size).to eq(1)
- end
-
- context "when gemspec file is invalid" do
- it "notifies the user that specification is invalid" do
- File.open(spec_file, "w") do |file|
- file << <<-S
- Gem::Specification.new do |s|
- s.name = 'test'
- s.invalid_method_name
- end
- S
- end
-
- bundle :init, :gemspec => spec_file
- expect(err).to include("There was an error while loading `test.gemspec`")
- end
- end
- end
-
- context "when init_gems_rb setting is enabled" do
- before { bundle "config set init_gems_rb true" }
-
- it "generates a gems.rb" do
- bundle! :init
- expect(out).to include("Writing new gems.rb")
- expect(bundled_app("gems.rb")).to be_file
- end
-
- context "when gems.rb already exists" do
- before do
- create_file("gems.rb", <<-G)
- gem "rails"
- G
- end
-
- it "does not change existing Gemfiles" do
- expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
- end
-
- it "notifies the user that an existing gems.rb already exists" do
- bundle :init
- expect(err).to include("gems.rb already exists")
- end
- end
-
- context "when a gems.rb file exists in a parent directory" do
- let(:subdir) { "child_dir" }
-
- it "lets users generate a Gemfile in a child directory" do
- bundle! :init
-
- FileUtils.mkdir bundled_app(subdir)
-
- Dir.chdir bundled_app(subdir) do
- bundle! :init
- end
-
- expect(out).to include("Writing new gems.rb")
- expect(bundled_app("#{subdir}/gems.rb")).to be_file
- end
- end
-
- context "given --gemspec option" do
- let(:spec_file) { tmp.join("test.gemspec") }
-
- before do
- File.open(spec_file, "w") do |file|
- file << <<-S
- Gem::Specification.new do |s|
- s.name = 'test'
- s.add_dependency 'rack', '= 1.0.1'
- s.add_development_dependency 'rspec', '1.2'
- end
- S
- end
- end
-
- it "should generate from an existing gemspec" do
- bundle :init, :gemspec => spec_file
-
- gemfile = bundled_app("gems.rb").read
- expect(gemfile).to match(%r{source 'https://rubygems.org'})
- expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1)
- expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1)
- expect(gemfile.scan(/group :development/).size).to eq(1)
- end
-
- it "prints message to user" do
- bundle :init, :gemspec => spec_file
-
- expect(out).to include("Writing new gems.rb")
- end
- end
- end
-end
diff --git a/spec/bundler/commands/inject_spec.rb b/spec/bundler/commands/inject_spec.rb
deleted file mode 100644
index 01c1f91877..0000000000
--- a/spec/bundler/commands/inject_spec.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle inject", :bundler => "< 3" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- context "without a lockfile" do
- it "locks with the injected gems" do
- expect(bundled_app("Gemfile.lock")).not_to exist
- bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile.lock").read).to match(/rack-obama/)
- end
- end
-
- context "with a lockfile" do
- before do
- bundle "install"
- end
-
- it "adds the injected gems to the Gemfile" do
- expect(bundled_app("Gemfile").read).not_to match(/rack-obama/)
- bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile").read).to match(/rack-obama/)
- end
-
- it "locks with the injected gems" do
- expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
- bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile.lock").read).to match(/rack-obama/)
- end
- end
-
- context "with injected gems already in the Gemfile" do
- it "doesn't add existing gems" do
- bundle "inject 'rack' '> 0'"
- expect(err).to match(/cannot specify the same gem twice/i)
- end
- end
-
- context "incorrect arguments" do
- it "fails when more than 2 arguments are passed" do
- bundle "inject gem_name 1 v"
- expect(err).to eq(<<-E.strip)
-ERROR: "bundle inject" was called with arguments ["gem_name", "1", "v"]
-Usage: "bundle inject GEM VERSION"
- E
- end
- end
-
- context "with source option" do
- it "add gem with source option in gemfile" do
- bundle "inject 'foo' '>0' --source #{file_uri_for(gem_repo1)}"
- gemfile = bundled_app("Gemfile").read
- str = "gem \"foo\", \"> 0\", :source => \"#{file_uri_for(gem_repo1)}\""
- expect(gemfile).to include str
- end
- end
-
- context "with group option" do
- it "add gem with group option in gemfile" do
- bundle "inject 'rack-obama' '>0' --group=development"
- gemfile = bundled_app("Gemfile").read
- str = "gem \"rack-obama\", \"> 0\", :group => :development"
- expect(gemfile).to include str
- end
-
- it "add gem with multiple groups in gemfile" do
- bundle "inject 'rack-obama' '>0' --group=development,test"
- gemfile = bundled_app("Gemfile").read
- str = "gem \"rack-obama\", \"> 0\", :groups => [:development, :test]"
- expect(gemfile).to include str
- end
- end
-
- context "when frozen" do
- before do
- bundle "install"
- if Bundler.feature_flag.bundler_3_mode?
- bundle! "config set --local deployment true"
- else
- bundle! "config set --local frozen true"
- end
- end
-
- it "injects anyway" do
- bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile").read).to match(/rack-obama/)
- end
-
- it "locks with the injected gems" do
- expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
- bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile.lock").read).to match(/rack-obama/)
- end
-
- it "restores frozen afterwards" do
- bundle "inject 'rack-obama' '> 0'"
- config = YAML.load(bundled_app(".bundle/config").read)
- expect(config["BUNDLE_DEPLOYMENT"] || config["BUNDLE_FROZEN"]).to eq("true")
- end
-
- it "doesn't allow Gemfile changes" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack-obama"
- G
- bundle "inject 'rack' '> 0'"
- expect(err).to match(/trying to install in deployment mode after changing/)
-
- expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
- end
- end
-end
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
deleted file mode 100644
index b57d81b10a..0000000000
--- a/spec/bundler/commands/install_spec.rb
+++ /dev/null
@@ -1,589 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with gem sources" do
- describe "the simple case" do
- it "prints output and returns if no dependencies are specified" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
-
- bundle :install
- expect(err).to match(/no dependencies/)
- end
-
- it "does not make a lockfile if the install fails" do
- install_gemfile <<-G
- raise StandardError, "FAIL"
- G
-
- expect(err).to include('StandardError, "FAIL"')
- expect(bundled_app("Gemfile.lock")).not_to exist
- end
-
- it "creates a Gemfile.lock" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "does not create ./.bundle by default", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle! :install # can't use install_gemfile since it sets retry
- expect(bundled_app(".bundle")).not_to exist
- end
-
- it "does not create ./.bundle by default when installing to system gems" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle! :install, :env => { "BUNDLE_PATH__SYSTEM" => "true" } # can't use install_gemfile since it sets retry
- expect(bundled_app(".bundle")).not_to exist
- end
-
- it "creates lock files based on the Gemfile name" do
- gemfile bundled_app("OmgFile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0"
- G
-
- bundle "install --gemfile OmgFile"
-
- expect(bundled_app("OmgFile.lock")).to exist
- end
-
- it "doesn't delete the lockfile if one already exists" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- lockfile = File.read(bundled_app("Gemfile.lock"))
-
- install_gemfile <<-G
- raise StandardError, "FAIL"
- G
-
- expect(File.read(bundled_app("Gemfile.lock"))).to eq(lockfile)
- end
-
- it "does not touch the lockfile if nothing changed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- expect { run "1" }.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
- end
-
- it "fetches gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- expect(default_bundle_path("gems/rack-1.0.0")).to exist
- expect(the_bundle).to include_gems("rack 1.0.0")
- end
-
- it "fetches gems when multiple versions are specified" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack', "> 0.9", "< 1.0"
- G
-
- expect(default_bundle_path("gems/rack-0.9.1")).to exist
- expect(the_bundle).to include_gems("rack 0.9.1")
- end
-
- it "fetches gems when multiple versions are specified take 2" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack', "< 1.0", "> 0.9"
- G
-
- expect(default_bundle_path("gems/rack-0.9.1")).to exist
- expect(the_bundle).to include_gems("rack 0.9.1")
- end
-
- it "raises an appropriate error when gems are specified using symbols" do
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo1)}"
- gem :rack
- G
- expect(exitstatus).to eq(4) if exitstatus
- end
-
- it "pulls in dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- expect(the_bundle).to include_gems "actionpack 2.3.2", "rails 2.3.2"
- end
-
- it "does the right version" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- G
-
- expect(the_bundle).to include_gems "rack 0.9.1"
- end
-
- it "does not install the development dependency" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "with_development_dependency"
- G
-
- expect(the_bundle).to include_gems("with_development_dependency 1.0.0").
- and not_include_gems("activesupport 2.3.5")
- end
-
- it "resolves correctly" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activemerchant"
- gem "rails"
- G
-
- expect(the_bundle).to include_gems "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
- end
-
- it "activates gem correctly according to the resolved gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport", "2.3.5"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activemerchant"
- gem "rails"
- G
-
- expect(the_bundle).to include_gems "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
- end
-
- it "does not reinstall any gem that is already available locally" do
- system_gems "activesupport-2.3.2", :path => :bundle_path
-
- build_repo2 do
- build_gem "activesupport", "2.3.2" do |s|
- s.write "lib/activesupport.rb", "ACTIVESUPPORT = 'fail'"
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activerecord", "2.3.2"
- G
-
- expect(the_bundle).to include_gems "activesupport 2.3.2"
- end
-
- it "works when the gemfile specifies gems that only exist in the system" do
- build_gem "foo", :to_bundle => true
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "foo"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "foo 1.0.0"
- end
-
- it "prioritizes local gems over remote gems" do
- build_gem "rack", "1.0.0", :to_bundle => true do |s|
- s.add_dependency "activesupport", "2.3.5"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
- end
-
- describe "with a gem that installs multiple platforms" do
- it "installs gems for the local platform as first choice" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
-
- run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
- expect(out).to eq("1.0.0 #{Bundler.local_platform}")
- end
-
- it "falls back on plain ruby" do
- simulate_platform "foo-bar-baz"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
-
- run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
- expect(out).to eq("1.0.0 RUBY")
- end
-
- it "installs gems for java" do
- simulate_platform "java"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
-
- run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
- expect(out).to eq("1.0.0 JAVA")
- end
-
- it "installs gems for windows" do
- simulate_platform mswin
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "platform_specific"
- G
-
- run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
- expect(out).to eq("1.0.0 MSWIN")
- end
- end
-
- describe "doing bundle install foo" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "works" do
- bundle "install", forgotten_command_line_options(:path => "vendor")
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "allows running bundle install --system without deleting foo", :bundler => "< 3" do
- bundle "install", forgotten_command_line_options(:path => "vendor")
- bundle "install", forgotten_command_line_options(:system => true)
- FileUtils.rm_rf(bundled_app("vendor"))
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "allows running bundle install --system after deleting foo", :bundler => "< 3" do
- bundle "install", forgotten_command_line_options(:path => "vendor")
- FileUtils.rm_rf(bundled_app("vendor"))
- bundle "install", forgotten_command_line_options(:system => true)
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- it "finds gems in multiple sources", :bundler => "< 3" do
- build_repo2
- update_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- source "#{file_uri_for(gem_repo2)}"
-
- gem "activesupport", "1.2.3"
- gem "rack", "1.2"
- G
-
- expect(the_bundle).to include_gems "rack 1.2", "activesupport 1.2.3"
- end
-
- it "gives a useful error if no sources are set" do
- install_gemfile <<-G
- gem "rack"
- G
-
- bundle :install
- expect(err).to include("Your Gemfile has no gem server sources")
- end
-
- it "creates a Gemfile.lock on a blank Gemfile" do
- install_gemfile <<-G
- G
-
- expect(File.exist?(bundled_app("Gemfile.lock"))).to eq(true)
- end
-
- context "throws a warning if a gem is added twice in Gemfile" do
- it "without version requirements" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- gem "rack"
- G
-
- expect(err).to include("Your Gemfile lists the gem rack (>= 0) more than once.")
- expect(err).to include("Remove any duplicate entries and specify the gem only once.")
- expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
- end
-
- it "with same versions" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack", "1.0"
- gem "rack", "1.0"
- G
-
- expect(err).to include("Your Gemfile lists the gem rack (= 1.0) more than once.")
- expect(err).to include("Remove any duplicate entries and specify the gem only once.")
- expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
- end
- end
-
- context "throws an error if a gem is added twice in Gemfile" do
- it "when version of one dependency is not specified" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- gem "rack", "1.0"
- G
-
- expect(err).to include("You cannot specify the same gem twice with different version requirements")
- expect(err).to include("You specified: rack (>= 0) and rack (= 1.0).")
- end
-
- it "when different versions of both dependencies are specified" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack", "1.0"
- gem "rack", "1.1"
- G
-
- expect(err).to include("You cannot specify the same gem twice with different version requirements")
- expect(err).to include("You specified: rack (= 1.0) and rack (= 1.1).")
- end
- end
-
- it "gracefully handles error when rubygems server is unavailable" do
- install_gemfile <<-G, :artifice => nil
- source "#{file_uri_for(gem_repo1)}"
- source "http://0.0.0.0:9384" do
- gem 'foo'
- end
- G
-
- bundle :install, :artifice => nil
- expect(err).to include("Could not fetch specs from http://0.0.0.0:9384/")
- expect(err).not_to include("file://")
- end
-
- it "fails gracefully when downloading an invalid specification from the full index" do
- build_repo2 do
- build_gem "ajp-rails", "0.0.0", :gemspec => false, :skip_validation => true do |s|
- bad_deps = [["ruby-ajp", ">= 0.2.0"], ["rails", ">= 0.14"]]
- s.
- instance_variable_get(:@spec).
- instance_variable_set(:@dependencies, bad_deps)
-
- raise "failed to set bad deps" unless s.dependencies == bad_deps
- end
- build_gem "ruby-ajp", "1.0.0"
- end
-
- install_gemfile <<-G, :full_index => true
- source "#{file_uri_for(gem_repo2)}"
-
- gem "ajp-rails", "0.0.0"
- G
-
- expect(last_command.stdboth).not_to match(/Error Report/i)
- expect(err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
- and include("Make sure that `gem install ajp-rails -v '0.0.0' --source '#{file_uri_for(gem_repo2)}/'` succeeds before bundling.")
- end
-
- it "doesn't blow up when the local .bundle/config is empty" do
- FileUtils.mkdir_p(bundled_app(".bundle"))
- FileUtils.touch(bundled_app(".bundle/config"))
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo1)}"
-
- gem 'foo'
- G
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- it "doesn't blow up when the global .bundle/config is empty" do
- FileUtils.mkdir_p("#{Bundler.rubygems.user_home}/.bundle")
- FileUtils.touch("#{Bundler.rubygems.user_home}/.bundle/config")
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo1)}"
-
- gem 'foo'
- G
- expect(exitstatus).to eq(0) if exitstatus
- end
- end
-
- describe "Ruby version in Gemfile.lock" do
- include Bundler::GemHelpers
-
- context "and using an unsupported Ruby version" do
- it "prints an error" do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.0.1'
- ruby '~> 2.2'
- G
- expect(err).to include("Your Ruby version is 2.0.1, but your Gemfile specified ~> 2.2")
- end
- end
-
- context "and using a supported Ruby version" do
- before do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.3'
- ::RUBY_PATCHLEVEL = 100
- ruby '~> 2.1.0'
- G
- end
-
- it "writes current Ruby version to Gemfile.lock" do
- lockfile_should_be <<-L
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
-
- RUBY VERSION
- ruby 2.1.3p100
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-
- it "updates Gemfile.lock with updated incompatible ruby version" do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.2.3'
- ::RUBY_PATCHLEVEL = 100
- ruby '~> 2.2.0'
- G
-
- lockfile_should_be <<-L
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
-
- RUBY VERSION
- ruby 2.2.3p100
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
- end
-
- describe "when Bundler root contains regex chars" do
- before do
- root_dir = tmp("foo[]bar")
-
- FileUtils.mkdir_p(root_dir)
- in_app_root_custom(root_dir)
- end
-
- it "doesn't blow up" do
- build_lib "foo"
- gemfile = <<-G
- gem 'foo', :path => "#{lib_path("foo-1.0")}"
- G
- File.open("Gemfile", "w") do |file|
- file.puts gemfile
- end
-
- bundle :install
-
- expect(exitstatus).to eq(0) if exitstatus
- end
- end
-
- describe "when requesting a quiet install via --quiet" do
- it "should be quiet" do
- bundle "config set force_ruby_platform true"
-
- gemfile <<-G
- gem 'rack'
- G
-
- bundle :install, :quiet => true
- expect(err).to include("Could not find gem 'rack'")
- expect(err).to_not include("Your Gemfile has no gem server sources")
- end
- end
-
- describe "when bundle path does not have write access" do
- before do
- FileUtils.mkdir_p(bundled_app("vendor"))
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
- end
-
- it "should display a proper message to explain the problem" do
- FileUtils.chmod(0o500, bundled_app("vendor"))
-
- bundle :install, forgotten_command_line_options(:path => "vendor")
- expect(err).to include(bundled_app("vendor").to_s)
- expect(err).to include("grant write permissions")
- end
- end
-
- context "after installing with --standalone" do
- before do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- forgotten_command_line_options(:path => "bundle")
- bundle! "install", :standalone => true
- end
-
- it "includes the standalone path" do
- bundle! "binstubs rack", :standalone => true
- standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip
- expect(standalone_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath)
- end
- end
-
- describe "when bundle install is executed with unencoded authentication" do
- before do
- gemfile <<-G
- source 'https://rubygems.org/'
- gem "."
- G
- end
-
- it "should display a helpful message explaining how to fix it" do
- bundle :install, :env => { "BUNDLE_RUBYGEMS__ORG" => "user:pass{word" }
- expect(exitstatus).to eq(17) if exitstatus
- expect(err).to eq("Please CGI escape your usernames and passwords before " \
- "setting them for authentication.")
- end
- end
-end
diff --git a/spec/bundler/commands/issue_spec.rb b/spec/bundler/commands/issue_spec.rb
deleted file mode 100644
index 143f6333ce..0000000000
--- a/spec/bundler/commands/issue_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle issue" do
- it "exits with a message" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- bundle "issue"
- expect(out).to include "Did you find an issue with Bundler?"
- expect(out).to include "## Environment"
- expect(out).to include "## Gemfile"
- expect(out).to include "## Bundle Doctor"
- end
-end
diff --git a/spec/bundler/commands/licenses_spec.rb b/spec/bundler/commands/licenses_spec.rb
deleted file mode 100644
index d4fa02d0a7..0000000000
--- a/spec/bundler/commands/licenses_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle licenses" do
- before :each do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- gem "with_license"
- G
- end
-
- it "prints license information for all gems in the bundle" do
- bundle "licenses"
-
- expect(out).to include("bundler: MIT")
- expect(out).to include("with_license: MIT")
- end
-
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- gem "with_license"
- gem "foo"
- G
-
- bundle "config set auto_install 1"
- bundle :licenses
- expect(out).to include("Installing foo 1.0")
- end
-end
diff --git a/spec/bundler/commands/list_spec.rb b/spec/bundler/commands/list_spec.rb
deleted file mode 100644
index 71d2136d38..0000000000
--- a/spec/bundler/commands/list_spec.rb
+++ /dev/null
@@ -1,168 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle list" do
- context "with name-only and paths option" do
- it "raises an error" do
- bundle "list --name-only --paths"
-
- expect(err).to eq "The `--name-only` and `--paths` options cannot be used together"
- end
- end
-
- context "with without-group and only-group option" do
- it "raises an error" do
- bundle "list --without-group dev --only-group test"
-
- expect(err).to eq "The `--only-group` and `--without-group` options cannot be used together"
- end
- end
-
- describe "with without-group option" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
- context "when group is present" do
- it "prints the gems not in the specified group" do
- bundle! "list --without-group test"
-
- expect(out).to include(" * rack (1.0.0)")
- expect(out).not_to include(" * rspec (1.2.7)")
- end
- end
-
- context "when group is not found" do
- it "raises an error" do
- bundle "list --without-group random"
-
- expect(err).to eq "`random` group could not be found."
- end
- end
- end
-
- describe "with only-group option" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
- context "when group is present" do
- it "prints the gems in the specified group" do
- bundle! "list --only-group default"
-
- expect(out).to include(" * rack (1.0.0)")
- expect(out).not_to include(" * rspec (1.2.7)")
- end
- end
-
- context "when group is not found" do
- it "raises an error" do
- bundle "list --only-group random"
-
- expect(err).to eq "`random` group could not be found."
- end
- end
- end
-
- context "with name-only option" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
- it "prints only the name of the gems in the bundle" do
- bundle "list --name-only"
-
- expect(out).to include("rack")
- expect(out).to include("rspec")
- end
- end
-
- context "with paths option" do
- before do
- build_repo2 do
- build_gem "bar"
- end
-
- build_git "git_test", "1.0.0", :path => lib_path("git_test")
-
- build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s|
- s.add_dependency "bar", "=1.0.0"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- gem "rails"
- gem "git_test", :git => "#{lib_path("git_test")}"
- gemspec :path => "#{tmp.join("gemspec_test")}"
- G
- end
-
- it "prints the path of each gem in the bundle" do
- bundle "list --paths"
- expect(out).to match(%r{.*\/rails\-2\.3\.2})
- expect(out).to match(%r{.*\/rack\-1\.2})
- expect(out).to match(%r{.*\/git_test\-\w})
- expect(out).to match(%r{.*\/gemspec_test})
- end
- end
-
- context "when no gems are in the gemfile" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
-
- it "prints message saying no gems are in the bundle" do
- bundle "list"
- expect(out).to include("No gems in the Gemfile")
- end
- end
-
- context "without options" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
- it "lists gems installed in the bundle" do
- bundle "list"
- expect(out).to include(" * rack (1.0.0)")
- end
- end
-
- context "when using the ls alias" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
- it "runs the list command" do
- bundle "ls"
- expect(out).to include("Gems included by the bundle")
- end
- end
-end
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
deleted file mode 100644
index 1d9813a835..0000000000
--- a/spec/bundler/commands/lock_spec.rb
+++ /dev/null
@@ -1,362 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle lock" do
- def strip_lockfile(lockfile)
- strip_whitespace(lockfile).sub(/\n\Z/, "")
- end
-
- def read_lockfile(file = "Gemfile.lock")
- strip_lockfile bundled_app(file).read
- end
-
- let(:repo) { gem_repo1 }
-
- before :each do
- gemfile <<-G
- source "#{file_uri_for(repo)}"
- gem "rails"
- gem "with_license"
- gem "foo"
- G
-
- @lockfile = strip_lockfile(<<-L)
- GEM
- remote: #{file_uri_for(repo)}/
- specs:
- actionmailer (2.3.2)
- activesupport (= 2.3.2)
- actionpack (2.3.2)
- activesupport (= 2.3.2)
- activerecord (2.3.2)
- activesupport (= 2.3.2)
- activeresource (2.3.2)
- activesupport (= 2.3.2)
- activesupport (2.3.2)
- foo (1.0)
- rails (2.3.2)
- actionmailer (= 2.3.2)
- actionpack (= 2.3.2)
- activerecord (= 2.3.2)
- activeresource (= 2.3.2)
- rake (= 12.3.2)
- rake (12.3.2)
- with_license (1.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo
- rails
- with_license
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-
- it "prints a lockfile when there is no existing lockfile with --print" do
- bundle "lock --print"
-
- expect(out).to eq(@lockfile)
- end
-
- it "prints a lockfile when there is an existing lockfile with --print" do
- lockfile @lockfile
-
- bundle "lock --print"
-
- expect(out).to eq(@lockfile)
- end
-
- it "writes a lockfile when there is no existing lockfile" do
- bundle "lock"
-
- expect(read_lockfile).to eq(@lockfile)
- end
-
- it "writes a lockfile when there is an outdated lockfile using --update" do
- lockfile @lockfile.gsub("2.3.2", "2.3.1")
-
- bundle! "lock --update"
-
- expect(read_lockfile).to eq(@lockfile)
- end
-
- it "does not fetch remote specs when using the --local option" do
- bundle "lock --update --local"
-
- expect(err).to match(/sources listed in your Gemfile|installed locally/)
- end
-
- it "works with --gemfile flag" do
- create_file "CustomGemfile", <<-G
- source "#{file_uri_for(repo)}"
- gem "foo"
- G
- lockfile = strip_lockfile(<<-L)
- GEM
- remote: #{file_uri_for(repo)}/
- specs:
- foo (1.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- bundle "lock --gemfile CustomGemfile"
-
- expect(out).to match(/Writing lockfile to.+CustomGemfile\.lock/)
- expect(read_lockfile("CustomGemfile.lock")).to eq(lockfile)
- expect { read_lockfile }.to raise_error(Errno::ENOENT)
- end
-
- it "writes to a custom location using --lockfile" do
- bundle "lock --lockfile=lock"
-
- expect(out).to match(/Writing lockfile to.+lock/)
- expect(read_lockfile("lock")).to eq(@lockfile)
- expect { read_lockfile }.to raise_error(Errno::ENOENT)
- end
-
- it "writes to custom location using --lockfile when a default lockfile is present" do
- bundle "install"
- bundle "lock --lockfile=lock"
-
- expect(out).to match(/Writing lockfile to.+lock/)
- expect(read_lockfile("lock")).to eq(@lockfile)
- end
-
- it "update specific gems using --update" do
- lockfile @lockfile.gsub("2.3.2", "2.3.1").gsub("12.3.2", "10.0.1")
-
- bundle "lock --update rails rake"
-
- expect(read_lockfile).to eq(@lockfile)
- end
-
- it "errors when updating a missing specific gems using --update" do
- lockfile @lockfile
-
- bundle "lock --update blahblah"
- expect(err).to eq("Could not find gem 'blahblah'.")
-
- expect(read_lockfile).to eq(@lockfile)
- end
-
- it "can lock without downloading gems" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "thin"
- gem "rack_middleware", :group => "test"
- G
- bundle! "config set without test"
- bundle! "config set path .bundle"
- bundle! "lock"
- expect(bundled_app(".bundle")).not_to exist
- end
-
- # see update_spec for more coverage on same options. logic is shared so it's not necessary
- # to repeat coverage here.
- context "conservative updates" do
- before do
- build_repo4 do
- build_gem "foo", %w[1.4.3 1.4.4] do |s|
- s.add_dependency "bar", "~> 2.0"
- end
- build_gem "foo", %w[1.4.5 1.5.0] do |s|
- s.add_dependency "bar", "~> 2.1"
- end
- build_gem "foo", %w[1.5.1] do |s|
- s.add_dependency "bar", "~> 3.0"
- end
- build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
- build_gem "qux", %w[1.0.0 1.0.1 1.1.0 2.0.0]
- end
-
- # establish a lockfile set to 1.4.3
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo', '1.4.3'
- gem 'bar', '2.0.3'
- gem 'qux', '1.0.0'
- G
-
- # remove 1.4.3 requirement and bar altogether
- # to setup update specs below
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo'
- gem 'qux'
- G
- end
-
- it "single gem updates dependent gem to minor" do
- bundle "lock --update foo --patch"
-
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[foo-1.4.5 bar-2.1.1 qux-1.0.0].sort)
- end
-
- it "minor preferred with strict" do
- bundle "lock --update --minor --strict"
-
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[foo-1.5.0 bar-2.1.1 qux-1.1.0].sort)
- end
- end
-
- it "supports adding new platforms" do
- bundle! "lock --add-platform java x86-mingw32"
-
- lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
- end
-
- it "supports adding the `ruby` platform" do
- bundle! "lock --add-platform ruby"
- lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to match_array(local_platforms.unshift("ruby").uniq)
- end
-
- it "warns when adding an unknown platform" do
- bundle "lock --add-platform foobarbaz"
- expect(err).to include("The platform `foobarbaz` is unknown to RubyGems and adding it will likely lead to resolution errors")
- end
-
- it "allows removing platforms" do
- bundle! "lock --add-platform java x86-mingw32"
-
- lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
-
- bundle! "lock --remove-platform java"
-
- lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to match_array(local_platforms.unshift(mingw).uniq)
- end
-
- it "errors when removing all platforms" do
- bundle "lock --remove-platform #{local_platforms.join(" ")}"
- expect(err).to include("Removing all platforms from the bundle is not allowed")
- end
-
- # from https://github.com/bundler/bundler/issues/4896
- it "properly adds platforms when platform requirements come from different dependencies" do
- build_repo4 do
- build_gem "ffi", "1.9.14"
- build_gem "ffi", "1.9.14" do |s|
- s.platform = mingw
- end
-
- build_gem "gssapi", "0.1"
- build_gem "gssapi", "0.2"
- build_gem "gssapi", "0.3"
- build_gem "gssapi", "1.2.0" do |s|
- s.add_dependency "ffi", ">= 1.0.1"
- end
-
- build_gem "mixlib-shellout", "2.2.6"
- build_gem "mixlib-shellout", "2.2.6" do |s|
- s.platform = "universal-mingw32"
- s.add_dependency "win32-process", "~> 0.8.2"
- end
-
- # we need all these versions to get the sorting the same as it would be
- # pulling from rubygems.org
- %w[0.8.3 0.8.2 0.8.1 0.8.0].each do |v|
- build_gem "win32-process", v do |s|
- s.add_dependency "ffi", ">= 1.0.0"
- end
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
-
- gem "mixlib-shellout"
- gem "gssapi"
- G
-
- simulate_platform(mingw) { bundle! :lock }
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo4)}/
- specs:
- ffi (1.9.14-x86-mingw32)
- gssapi (1.2.0)
- ffi (>= 1.0.1)
- mixlib-shellout (2.2.6-universal-mingw32)
- win32-process (~> 0.8.2)
- win32-process (0.8.3)
- ffi (>= 1.0.0)
-
- PLATFORMS
- x86-mingw32
-
- DEPENDENCIES
- gssapi
- mixlib-shellout
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- simulate_platform(rb) { bundle! :lock }
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo4)}/
- specs:
- ffi (1.9.14)
- ffi (1.9.14-x86-mingw32)
- gssapi (1.2.0)
- ffi (>= 1.0.1)
- mixlib-shellout (2.2.6)
- mixlib-shellout (2.2.6-universal-mingw32)
- win32-process (~> 0.8.2)
- win32-process (0.8.3)
- ffi (>= 1.0.0)
-
- PLATFORMS
- ruby
- x86-mingw32
-
- DEPENDENCIES
- gssapi
- mixlib-shellout
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- context "when an update is available" do
- let(:repo) { gem_repo2 }
-
- before do
- lockfile(@lockfile)
- build_repo2 do
- build_gem "foo", "2.0"
- end
- end
-
- it "does not implicitly update" do
- bundle! "lock"
-
- expect(read_lockfile).to eq(@lockfile)
- end
-
- it "accounts for changes in the gemfile" do
- gemfile gemfile.gsub('"foo"', '"foo", "2.0"')
- bundle! "lock"
-
- expect(read_lockfile).to eq(@lockfile.sub("foo (1.0)", "foo (2.0)").sub(/foo$/, "foo (= 2.0)"))
- end
- end
-end
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
deleted file mode 100644
index 708b41f623..0000000000
--- a/spec/bundler/commands/newgem_spec.rb
+++ /dev/null
@@ -1,732 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle gem" do
- def gem_skeleton_assertions
- expect(bundled_app("#{gem_name}/#{gem_name}.gemspec")).to exist
- expect(bundled_app("#{gem_name}/README.md")).to exist
- expect(bundled_app("#{gem_name}/Gemfile")).to exist
- expect(bundled_app("#{gem_name}/Rakefile")).to exist
- expect(bundled_app("#{gem_name}/lib/#{require_path}.rb")).to exist
- expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb")).to exist
- end
-
- let(:generated_gemspec) { Bundler.load_gemspec_uncached(bundled_app(gem_name).join("#{gem_name}.gemspec")) }
-
- let(:gem_name) { "mygem" }
-
- let(:require_path) { "mygem" }
-
- before do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
- git_config_content = <<-EOF
- [user]
- name = "Bundler User"
- email = user@example.com
- [github]
- user = bundleuser
- EOF
- @git_config_location = ENV["GIT_CONFIG"]
- path = "#{tmp}/test_git_config.txt"
- File.open(path, "w") {|f| f.write(git_config_content) }
- ENV["GIT_CONFIG"] = path
- end
-
- after do
- FileUtils.rm(ENV["GIT_CONFIG"]) if File.exist?(ENV["GIT_CONFIG"])
- ENV["GIT_CONFIG"] = @git_config_location
- end
-
- shared_examples_for "git config is present" do
- context "git config user.{name,email} present" do
- it "sets gemspec author to git user.name if available" do
- expect(generated_gemspec.authors.first).to eq("Bundler User")
- end
-
- it "sets gemspec email to git user.email if available" do
- expect(generated_gemspec.email.first).to eq("user@example.com")
- end
- end
- end
-
- shared_examples_for "git config is absent" do
- it "sets gemspec author to default message if git user.name is not set or empty" do
- expect(generated_gemspec.authors.first).to eq("TODO: Write your name")
- end
-
- it "sets gemspec email to default message if git user.email is not set or empty" do
- expect(generated_gemspec.email.first).to eq("TODO: Write your email address")
- end
- end
-
- describe "git repo initialization" do
- shared_examples_for "a gem with an initial git repo" do
- before do
- bundle! "gem #{gem_name} #{flags}"
- end
-
- it "generates a gem skeleton with a .git folder" do
- gem_skeleton_assertions
- expect(bundled_app("#{gem_name}/.git")).to exist
- end
- end
-
- context "when using the default" do
- it_behaves_like "a gem with an initial git repo" do
- let(:flags) { "" }
- end
- end
-
- context "when explicitly passing --git" do
- it_behaves_like "a gem with an initial git repo" do
- let(:flags) { "--git" }
- end
- end
-
- context "when passing --no-git" do
- before do
- bundle! "gem #{gem_name} --no-git"
- end
- it "generates a gem skeleton without a .git folder" do
- gem_skeleton_assertions
- expect(bundled_app("#{gem_name}/.git")).not_to exist
- end
- end
- end
-
- shared_examples_for "--mit flag" do
- before do
- bundle! "gem #{gem_name} --mit"
- end
- it "generates a gem skeleton with MIT license" do
- gem_skeleton_assertions
- expect(bundled_app("#{gem_name}/LICENSE.txt")).to exist
- expect(generated_gemspec.license).to eq("MIT")
- end
- end
-
- shared_examples_for "--no-mit flag" do
- before do
- bundle! "gem #{gem_name} --no-mit"
- end
- it "generates a gem skeleton without MIT license" do
- gem_skeleton_assertions
- expect(bundled_app("#{gem_name}/LICENSE.txt")).to_not exist
- end
- end
-
- shared_examples_for "--coc flag" do
- before do
- bundle! "gem #{gem_name} --coc"
- end
- it "generates a gem skeleton with MIT license" do
- gem_skeleton_assertions
- expect(bundled_app("#{gem_name}/CODE_OF_CONDUCT.md")).to exist
- end
-
- describe "README additions" do
- it "generates the README with a section for the Code of Conduct" do
- expect(bundled_app("#{gem_name}/README.md").read).to include("## Code of Conduct")
- expect(bundled_app("#{gem_name}/README.md").read).to include("https://github.com/bundleuser/#{gem_name}/blob/master/CODE_OF_CONDUCT.md")
- end
- end
- end
-
- shared_examples_for "--no-coc flag" do
- before do
- bundle! "gem #{gem_name} --no-coc"
- end
- it "generates a gem skeleton without Code of Conduct" do
- gem_skeleton_assertions
- expect(bundled_app("#{gem_name}/CODE_OF_CONDUCT.md")).to_not exist
- end
-
- describe "README additions" do
- it "generates the README without a section for the Code of Conduct" do
- expect(bundled_app("#{gem_name}/README.md").read).not_to include("## Code of Conduct")
- expect(bundled_app("#{gem_name}/README.md").read).not_to include("https://github.com/bundleuser/#{gem_name}/blob/master/CODE_OF_CONDUCT.md")
- end
- end
- end
-
- context "README.md" do
- context "git config github.user present" do
- before do
- bundle! "gem #{gem_name}"
- end
-
- it "contribute URL set to git username" do
- expect(bundled_app("#{gem_name}/README.md").read).not_to include("[USERNAME]")
- expect(bundled_app("#{gem_name}/README.md").read).to include("github.com/bundleuser")
- end
- end
-
- context "git config github.user is absent" do
- before do
- sys_exec("git config --unset github.user")
- bundle "gem #{gem_name}"
- end
-
- it "contribute URL set to [USERNAME]" do
- expect(bundled_app("#{gem_name}/README.md").read).to include("[USERNAME]")
- expect(bundled_app("#{gem_name}/README.md").read).not_to include("github.com/bundleuser")
- end
- end
- end
-
- it "creates a new git repository" do
- bundle "gem #{gem_name}"
- expect(bundled_app("#{gem_name}/.git")).to exist
- end
-
- context "when git is not available" do
- # This spec cannot have `git` available in the test env
- before do
- load_paths = [lib_dir, spec_dir]
- load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}"
-
- sys_exec "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", "PATH" => ""
- end
-
- it "creates the gem without the need for git" do
- expect(bundled_app("#{gem_name}/README.md")).to exist
- end
-
- it "doesn't create a git repo" do
- expect(bundled_app("#{gem_name}/.git")).to_not exist
- end
-
- it "doesn't create a .gitignore file" do
- expect(bundled_app("#{gem_name}/.gitignore")).to_not exist
- end
- end
-
- it "generates a valid gemspec" do
- bundle! "gem newgem --bin"
-
- prepare_gemspec(bundled_app("newgem", "newgem.gemspec"))
-
- Dir.chdir(bundled_app("newgem")) do
- gems = ["rake-12.3.2"]
- system_gems gems, :path => :bundle_path
- bundle! "exec rake build"
- end
-
- expect(last_command.stdboth).not_to include("ERROR")
- end
-
- context "gem naming with relative paths" do
- it "resolves ." do
- create_temporary_dir("tmp")
-
- bundle "gem ."
-
- expect(bundled_app("tmp/lib/tmp.rb")).to exist
- end
-
- it "resolves .." do
- create_temporary_dir("temp/empty_dir")
-
- bundle "gem .."
-
- expect(bundled_app("temp/lib/temp.rb")).to exist
- end
-
- it "resolves relative directory" do
- create_temporary_dir("tmp/empty/tmp")
-
- bundle "gem ../../empty"
-
- expect(bundled_app("tmp/empty/lib/empty.rb")).to exist
- end
-
- def create_temporary_dir(dir)
- FileUtils.mkdir_p(dir)
- Dir.chdir(dir)
- end
- end
-
- shared_examples_for "generating a gem" do
- it "generates a gem skeleton" do
- bundle! "gem #{gem_name}"
-
- expect(bundled_app("#{gem_name}/#{gem_name}.gemspec")).to exist
- expect(bundled_app("#{gem_name}/Gemfile")).to exist
- expect(bundled_app("#{gem_name}/Rakefile")).to exist
- expect(bundled_app("#{gem_name}/lib/#{require_path}.rb")).to exist
- expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb")).to exist
- expect(bundled_app("#{gem_name}/.gitignore")).to exist
-
- expect(bundled_app("#{gem_name}/bin/setup")).to exist
- expect(bundled_app("#{gem_name}/bin/console")).to exist
- expect(bundled_app("#{gem_name}/bin/setup")).to be_executable
- expect(bundled_app("#{gem_name}/bin/console")).to be_executable
- end
-
- it "starts with version 0.1.0" do
- bundle! "gem #{gem_name}"
-
- expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/VERSION = "0.1.0"/)
- end
-
- context "git config user.{name,email} is set" do
- before do
- bundle! "gem #{gem_name}"
- end
-
- it_should_behave_like "git config is present"
- end
-
- context "git config user.{name,email} is not set" do
- before do
- `git config --unset user.name`
- `git config --unset user.email`
- bundle "gem #{gem_name}"
- end
-
- it_should_behave_like "git config is absent"
- end
-
- it "sets gemspec metadata['allowed_push_host']" do
- bundle! "gem #{gem_name}"
-
- expect(generated_gemspec.metadata["allowed_push_host"]).
- to match(/mygemserver\.com/)
- end
-
- it "sets a minimum ruby version" do
- bundle! "gem #{gem_name}"
-
- bundler_gemspec = Bundler::GemHelper.new(gemspec_dir).gemspec
-
- expect(bundler_gemspec.required_ruby_version).to eq(generated_gemspec.required_ruby_version)
- end
-
- it "requires the version file" do
- bundle! "gem #{gem_name}"
-
- expect(bundled_app("#{gem_name}/lib/#{require_path}.rb").read).to match(%r{require "#{require_path}/version"})
- end
-
- it "creates a base error class" do
- bundle! "gem #{gem_name}"
-
- expect(bundled_app("#{gem_name}/lib/#{require_path}.rb").read).to match(/class Error < StandardError; end$/)
- end
-
- it "runs rake without problems" do
- bundle! "gem #{gem_name}"
-
- system_gems ["rake-12.3.2"]
-
- rakefile = strip_whitespace <<-RAKEFILE
- task :default do
- puts 'SUCCESS'
- end
- RAKEFILE
- File.open(bundled_app("#{gem_name}/Rakefile"), "w") do |file|
- file.puts rakefile
- end
-
- Dir.chdir(bundled_app(gem_name)) do
- sys_exec(rake)
- expect(out).to include("SUCCESS")
- end
- end
-
- context "--exe parameter set" do
- before do
- bundle "gem #{gem_name} --exe"
- end
-
- it "builds exe skeleton" do
- expect(bundled_app("#{gem_name}/exe/#{gem_name}")).to exist
- end
-
- it "requires the main file" do
- expect(bundled_app("#{gem_name}/exe/#{gem_name}").read).to match(/require "#{require_path}"/)
- end
- end
-
- context "--bin parameter set" do
- before do
- bundle "gem #{gem_name} --bin"
- end
-
- it "builds exe skeleton" do
- expect(bundled_app("#{gem_name}/exe/#{gem_name}")).to exist
- end
-
- it "requires the main file" do
- expect(bundled_app("#{gem_name}/exe/#{gem_name}").read).to match(/require "#{require_path}"/)
- end
- end
-
- context "no --test parameter" do
- before do
- bundle "gem #{gem_name}"
- end
-
- it "doesn't create any spec/test file" do
- expect(bundled_app("#{gem_name}/.rspec")).to_not exist
- expect(bundled_app("#{gem_name}/spec/#{require_path}_spec.rb")).to_not exist
- expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to_not exist
- expect(bundled_app("#{gem_name}/test/#{require_path}.rb")).to_not exist
- expect(bundled_app("#{gem_name}/test/minitest_helper.rb")).to_not exist
- end
- end
-
- context "--test parameter set to rspec" do
- before do
- bundle "gem #{gem_name} --test=rspec"
- end
-
- it "builds spec skeleton" do
- expect(bundled_app("#{gem_name}/.rspec")).to exist
- expect(bundled_app("#{gem_name}/spec/#{require_path}_spec.rb")).to exist
- expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to exist
- end
-
- it "depends on a specific version of rspec in generated Gemfile" do
- Dir.chdir(bundled_app(gem_name)) do
- builder = Bundler::Dsl.new
- builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
- builder.dependencies
- rspec_dep = builder.dependencies.find {|d| d.name == "rspec" }
- expect(rspec_dep).to be_specific
- end
- end
-
- it "requires the main file" do
- expect(bundled_app("#{gem_name}/spec/spec_helper.rb").read).to include(%(require "#{require_path}"))
- end
-
- it "creates a default test which fails" do
- expect(bundled_app("#{gem_name}/spec/#{require_path}_spec.rb").read).to include("expect(false).to eq(true)")
- end
- end
-
- context "gem.test setting set to rspec" do
- before do
- bundle "config set gem.test rspec"
- bundle "gem #{gem_name}"
- end
-
- it "builds spec skeleton" do
- expect(bundled_app("#{gem_name}/.rspec")).to exist
- expect(bundled_app("#{gem_name}/spec/#{require_path}_spec.rb")).to exist
- expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to exist
- end
- end
-
- context "gem.test setting set to rspec and --test is set to minitest" do
- before do
- bundle "config set gem.test rspec"
- bundle "gem #{gem_name} --test=minitest"
- end
-
- it "builds spec skeleton" do
- expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb")).to exist
- expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
- end
- end
-
- context "--test parameter set to minitest" do
- before do
- bundle "gem #{gem_name} --test=minitest"
- end
-
- it "depends on a specific version of minitest" do
- Dir.chdir(bundled_app(gem_name)) do
- builder = Bundler::Dsl.new
- builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
- builder.dependencies
- minitest_dep = builder.dependencies.find {|d| d.name == "minitest" }
- expect(minitest_dep).to be_specific
- end
- end
-
- it "builds spec skeleton" do
- expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb")).to exist
- expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
- end
-
- it "requires the main file" do
- expect(bundled_app("#{gem_name}/test/test_helper.rb").read).to include(%(require "#{require_path}"))
- end
-
- it "requires 'minitest_helper'" do
- expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include(%(require "test_helper"))
- end
-
- it "creates a default test which fails" do
- expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include("assert false")
- end
- end
-
- context "gem.test setting set to minitest" do
- before do
- bundle "config set gem.test minitest"
- bundle "gem #{gem_name}"
- end
-
- it "creates a default rake task to run the test suite" do
- rakefile = strip_whitespace <<-RAKEFILE
- require "bundler/gem_tasks"
- require "rake/testtask"
-
- Rake::TestTask.new(:test) do |t|
- t.libs << "test"
- t.libs << "lib"
- t.test_files = FileList["test/**/*_test.rb"]
- end
-
- task :default => :test
- RAKEFILE
-
- expect(bundled_app("#{gem_name}/Rakefile").read).to eq(rakefile)
- end
- end
-
- context "--test with no arguments" do
- before do
- bundle "gem #{gem_name} --test"
- end
-
- it "defaults to rspec" do
- expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to exist
- expect(bundled_app("#{gem_name}/test/minitest_helper.rb")).to_not exist
- end
-
- it "creates a .travis.yml file to test the library against the current Ruby version on Travis CI" do
- expect(bundled_app("#{gem_name}/.travis.yml").read).to match(/- #{RUBY_VERSION}/)
- end
- end
-
- context "--edit option" do
- it "opens the generated gemspec in the user's text editor" do
- output = bundle "gem #{gem_name} --edit=echo"
- gemspec_path = File.join(Dir.pwd, gem_name, "#{gem_name}.gemspec")
- expect(output).to include("echo \"#{gemspec_path}\"")
- end
- end
- end
-
- context "testing --mit and --coc options against bundle config settings" do
- let(:gem_name) { "test-gem" }
-
- let(:require_path) { "test/gem" }
-
- context "with mit option in bundle config settings set to true" do
- before do
- global_config "BUNDLE_GEM__MIT" => "true", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
- end
- it_behaves_like "--mit flag"
- it_behaves_like "--no-mit flag"
- end
-
- context "with mit option in bundle config settings set to false" do
- it_behaves_like "--mit flag"
- it_behaves_like "--no-mit flag"
- end
-
- context "with coc option in bundle config settings set to true" do
- before do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "true"
- end
- it_behaves_like "--coc flag"
- it_behaves_like "--no-coc flag"
- end
-
- context "with coc option in bundle config settings set to false" do
- it_behaves_like "--coc flag"
- it_behaves_like "--no-coc flag"
- end
- end
-
- context "gem naming with underscore" do
- let(:gem_name) { "test_gem" }
-
- let(:require_path) { "test_gem" }
-
- let(:flags) { nil }
-
- before do
- bundle! ["gem", gem_name, flags].compact.join(" ")
- end
-
- it "does not nest constants" do
- expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/module TestGem/)
- expect(bundled_app("#{gem_name}/lib/#{require_path}.rb").read).to match(/module TestGem/)
- end
-
- include_examples "generating a gem"
-
- context "--ext parameter set" do
- let(:flags) { "--ext" }
-
- it "builds ext skeleton" do
- expect(bundled_app("#{gem_name}/ext/#{gem_name}/extconf.rb")).to exist
- expect(bundled_app("#{gem_name}/ext/#{gem_name}/#{gem_name}.h")).to exist
- expect(bundled_app("#{gem_name}/ext/#{gem_name}/#{gem_name}.c")).to exist
- end
-
- it "includes rake-compiler" do
- expect(bundled_app("#{gem_name}/Gemfile").read).to include('gem "rake-compiler"')
- end
-
- it "depends on compile task for build" do
- rakefile = strip_whitespace <<-RAKEFILE
- require "bundler/gem_tasks"
- require "rake/extensiontask"
-
- task :build => :compile
-
- Rake::ExtensionTask.new("#{gem_name}") do |ext|
- ext.lib_dir = "lib/#{gem_name}"
- end
-
- task :default => [:clobber, :compile, :spec]
- RAKEFILE
-
- expect(bundled_app("#{gem_name}/Rakefile").read).to eq(rakefile)
- end
- end
- end
-
- context "gem naming with dashed" do
- let(:gem_name) { "test-gem" }
-
- let(:require_path) { "test/gem" }
-
- before do
- bundle! "gem #{gem_name}"
- end
-
- it "nests constants so they work" do
- expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/module Test\n module Gem/)
- expect(bundled_app("#{gem_name}/lib/#{require_path}.rb").read).to match(/module Test\n module Gem/)
- end
-
- include_examples "generating a gem"
- end
-
- describe "uncommon gem names" do
- it "can deal with two dashes" do
- bundle! "gem a--a"
-
- expect(bundled_app("a--a/a--a.gemspec")).to exist
- end
-
- it "fails gracefully with a ." do
- bundle "gem foo.gemspec"
- expect(err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
- end
-
- it "fails gracefully with a ^" do
- bundle "gem ^"
- expect(err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
- end
-
- it "fails gracefully with a space" do
- bundle "gem 'foo bar'"
- expect(err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
- end
-
- it "fails gracefully when multiple names are passed" do
- bundle "gem foo bar baz"
- expect(err).to eq(<<-E.strip)
-ERROR: "bundle gem" was called with arguments ["foo", "bar", "baz"]
-Usage: "bundle gem NAME [OPTIONS]"
- E
- end
- end
-
- describe "#ensure_safe_gem_name" do
- before do
- bundle "gem #{subject}"
- end
-
- context "with an existing const name" do
- subject { "gem" }
- it { expect(err).to include("Invalid gem name #{subject}") }
- end
-
- context "with an existing hyphenated const name" do
- subject { "gem-specification" }
- it { expect(err).to include("Invalid gem name #{subject}") }
- end
-
- context "starting with an existing const name" do
- subject { "gem-somenewconstantname" }
- it { expect(err).not_to include("Invalid gem name #{subject}") }
- end
-
- context "ending with an existing const name" do
- subject { "somenewconstantname-gem" }
- it { expect(err).not_to include("Invalid gem name #{subject}") }
- end
- end
-
- context "on first run" do
- it "asks about test framework" do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__COC" => "false"
-
- bundle "gem foobar" do |input, _, _|
- input.puts "rspec"
- end
-
- expect(bundled_app("foobar/spec/spec_helper.rb")).to exist
- rakefile = strip_whitespace <<-RAKEFILE
- require "bundler/gem_tasks"
- require "rspec/core/rake_task"
-
- RSpec::Core::RakeTask.new(:spec)
-
- task :default => :spec
- RAKEFILE
-
- expect(bundled_app("foobar/Rakefile").read).to eq(rakefile)
- expect(bundled_app("foobar/Gemfile").read).to include('gem "rspec"')
- end
-
- it "asks about MIT license" do
- global_config "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
-
- bundle "config list"
-
- bundle "gem foobar" do |input, _, _|
- input.puts "yes"
- end
-
- expect(bundled_app("foobar/LICENSE.txt")).to exist
- end
-
- it "asks about CoC" do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false"
-
- bundle "gem foobar" do |input, _, _|
- input.puts "yes"
- end
-
- expect(bundled_app("foobar/CODE_OF_CONDUCT.md")).to exist
- end
- end
-
- context "on conflicts with a previously created file" do
- it "should fail gracefully" do
- FileUtils.touch("conflict-foobar")
- bundle "gem conflict-foobar"
- expect(err).to include("Errno::ENOTDIR")
- expect(exitstatus).to eql(32) if exitstatus
- end
- end
-
- context "on conflicts with a previously created directory" do
- it "should succeed" do
- FileUtils.mkdir_p("conflict-foobar/Gemfile")
- bundle! "gem conflict-foobar"
- expect(out).to include("file_clash conflict-foobar/Gemfile").
- and include "Initializing git repo in #{bundled_app("conflict-foobar")}"
- end
- end
-end
diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb
deleted file mode 100644
index 8fae4af5b4..0000000000
--- a/spec/bundler/commands/open_spec.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle open" do
- context "when opening a regular gem" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
- end
-
- it "opens the gem with BUNDLER_EDITOR as highest priority" do
- bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
- expect(out).to include("bundler_editor #{default_bundle_path("gems", "rails-2.3.2")}")
- end
-
- it "opens the gem with VISUAL as 2nd highest priority" do
- bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "" }
- expect(out).to include("visual #{default_bundle_path("gems", "rails-2.3.2")}")
- end
-
- it "opens the gem with EDITOR as 3rd highest priority" do
- bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(out).to include("editor #{default_bundle_path("gems", "rails-2.3.2")}")
- end
-
- it "complains if no EDITOR is set" do
- bundle "open rails", :env => { "EDITOR" => "", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(out).to eq("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR")
- end
-
- it "complains if gem not in bundle" do
- bundle "open missing", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(err).to match(/could not find gem 'missing'/i)
- end
-
- it "does not blow up if the gem to open does not have a Gemfile" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'foo', :git => "#{lib_path("foo-1.0")}"
- G
-
- bundle "open foo", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(out).to match("editor #{default_bundle_path.join("bundler/gems/foo-1.0-#{ref}")}")
- end
-
- it "suggests alternatives for similar-sounding gems" do
- bundle "open Rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(err).to match(/did you mean rails\?/i)
- end
-
- it "opens the gem with short words" do
- bundle "open rec", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
-
- expect(out).to include("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2")}")
- end
-
- it "select the gem from many match gems" do
- env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
- bundle "open active", :env => env do |input, _, _|
- input.puts "2"
- end
-
- expect(out).to match(/bundler_editor #{default_bundle_path('gems', 'activerecord-2.3.2')}\z/)
- end
-
- it "allows selecting exit from many match gems" do
- env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
- bundle! "open active", :env => env do |input, _, _|
- input.puts "0"
- end
- end
-
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- gem "foo"
- G
-
- bundle "config set auto_install 1"
- bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(out).to include("Installing foo 1.0")
- end
-
- it "opens the editor with a clean env" do
- bundle "open", :env => { "EDITOR" => "sh -c 'env'", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(out).not_to include("BUNDLE_GEMFILE=")
- end
- end
-
- context "when opening a default gem" do
- let(:default_gems) do
- ruby!(<<-RUBY).split("\n")
- if Gem::Specification.is_a?(Enumerable)
- puts Gem::Specification.select(&:default_gem?).map(&:name)
- end
- RUBY
- end
-
- before do
- skip "No default gems available on this test run" if default_gems.empty?
-
- install_gemfile <<-G
- gem "json"
- G
- end
-
- it "throws proper error when trying to open default gem" do
- bundle "open json", :env => { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
- expect(out).to include("Unable to open json because it's a default gem, so the directory it would normally be installed to does not exist.")
- end
- end
-end
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
deleted file mode 100644
index df911eaffd..0000000000
--- a/spec/bundler/commands/outdated_spec.rb
+++ /dev/null
@@ -1,780 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle outdated" do
- before :each do
- build_repo2 do
- build_git "foo", :path => lib_path("foo")
- build_git "zebra", :path => lib_path("zebra")
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "zebra", :git => "#{lib_path("zebra")}"
- gem "foo", :git => "#{lib_path("foo")}"
- gem "activesupport", "2.3.5"
- gem "weakling", "~> 0.0.1"
- gem "duradura", '7.0'
- gem "terranova", '8'
- G
- end
-
- describe "with no arguments" do
- it "returns a sorted list of outdated gems" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- build_gem "weakling", "0.2"
- update_git "foo", :path => lib_path("foo")
- update_git "zebra", :path => lib_path("zebra")
- end
-
- bundle "outdated"
-
- expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)")
- expect(out).to include("weakling (newest 0.2, installed 0.0.3, requested ~> 0.0.1)")
- expect(out).to include("foo (newest 1.0")
-
- # Gem names are one per-line, between "*" and their parenthesized version.
- gem_list = out.split("\n").map {|g| g[/\* (.*) \(/, 1] }.compact
- expect(gem_list).to eq(gem_list.sort)
- end
-
- it "returns non zero exit status if outdated gems present" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- bundle "outdated"
-
- expect(exitstatus).to_not be_zero if exitstatus
- end
-
- it "returns success exit status if no outdated gems present" do
- bundle "outdated"
-
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "adds gem group to dependency output when repo is updated" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "terranova", '8'
-
- group :development, :test do
- gem 'activesupport', '2.3.5'
- end
- G
-
- update_repo2 { build_gem "activesupport", "3.0" }
- update_repo2 { build_gem "terranova", "9" }
-
- bundle "outdated --verbose"
- expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5) in groups \"development, test\"")
- expect(out).to include("terranova (newest 9, installed 8, requested = 8) in group \"default\"")
- end
- end
-
- describe "with --group option" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "weakling", "~> 0.0.1"
- gem "terranova", '8'
- group :development, :test do
- gem "duradura", '7.0'
- gem 'activesupport', '2.3.5'
- end
- G
- end
-
- def test_group_option(group = nil, gems_list_size = 1)
- update_repo2 do
- build_gem "activesupport", "3.0"
- build_gem "terranova", "9"
- build_gem "duradura", "8.0"
- end
-
- bundle "outdated --group #{group}"
-
- # Gem names are one per-line, between "*" and their parenthesized version.
- gem_list = out.split("\n").map {|g| g[/\* (.*) \(/, 1] }.compact
- expect(gem_list).to eq(gem_list.sort)
- expect(gem_list.size).to eq gems_list_size
- end
-
- it "not outdated gems" do
- bundle "outdated --group"
- expect(out).to include("Bundle up to date!")
- end
-
- it "returns a sorted list of outdated gems from one group => 'default'" do
- test_group_option("default")
-
- expect(out).to include("===== Group \"default\" =====")
- expect(out).to include("terranova (")
-
- expect(out).not_to include("===== Groups \"development, test\" =====")
- expect(out).not_to include("activesupport")
- expect(out).not_to include("duradura")
- end
-
- it "returns a sorted list of outdated gems from one group => 'development'" do
- test_group_option("development", 2)
-
- expect(out).not_to include("===== Group \"default\" =====")
- expect(out).not_to include("terranova (")
-
- expect(out).to include("===== Groups \"development, test\" =====")
- expect(out).to include("activesupport")
- expect(out).to include("duradura")
- end
-
- it "returns a sorted list of outdated gems from one group => 'test'" do
- test_group_option("test", 2)
-
- expect(out).not_to include("===== Group \"default\" =====")
- expect(out).not_to include("terranova (")
-
- expect(out).to include("===== Groups \"development, test\" =====")
- expect(out).to include("activesupport")
- expect(out).to include("duradura")
- end
- end
-
- describe "with --groups option" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "weakling", "~> 0.0.1"
- gem "terranova", '8'
- group :development, :test do
- gem 'activesupport', '2.3.5'
- gem "duradura", '7.0'
- end
- G
- end
-
- it "not outdated gems" do
- bundle "outdated --groups"
- expect(out).to include("Bundle up to date!")
- end
-
- it "returns a sorted list of outdated gems by groups" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- build_gem "terranova", "9"
- build_gem "duradura", "8.0"
- end
-
- bundle "outdated --groups"
- expect(out).to include("===== Group \"default\" =====")
- expect(out).to include("terranova (newest 9, installed 8, requested = 8)")
- expect(out).to include("===== Groups \"development, test\" =====")
- expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)")
- expect(out).to include("duradura (newest 8.0, installed 7.0, requested = 7.0)")
-
- expect(out).not_to include("weakling (")
-
- # TODO: check gems order inside the group
- end
- end
-
- describe "with --local option" do
- it "uses local cache to return a list of outdated gems" do
- update_repo2 do
- build_gem "activesupport", "2.3.4"
- end
-
- bundle! "config set clean false"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.4"
- G
-
- bundle "outdated --local"
-
- expect(out).to include("activesupport (newest 2.3.5, installed 2.3.4, requested = 2.3.4)")
- end
-
- it "doesn't hit repo2" do
- FileUtils.rm_rf(gem_repo2)
-
- bundle "outdated --local"
- expect(out).not_to match(/Fetching (gem|version|dependency) metadata from/)
- end
- end
-
- shared_examples_for "a minimal output is desired" do
- context "and gems are outdated" do
- before do
- update_repo2 do
- build_gem "activesupport", "3.0"
- build_gem "weakling", "0.2"
- end
- end
-
- it "outputs a sorted list of outdated gems with a more minimal format" do
- minimal_output = "activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)\n" \
- "weakling (newest 0.2, installed 0.0.3, requested ~> 0.0.1)"
- subject
- expect(out).to eq(minimal_output)
- end
- end
-
- context "and no gems are outdated" do
- it "has empty output" do
- subject
- expect(out).to be_empty
- end
- end
- end
-
- describe "with --parseable option" do
- subject { bundle "outdated --parseable" }
-
- it_behaves_like "a minimal output is desired"
- end
-
- describe "with aliased --porcelain option" do
- subject { bundle "outdated --porcelain" }
-
- it_behaves_like "a minimal output is desired"
- end
-
- describe "with specified gems" do
- it "returns list of outdated gems" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- bundle "outdated foo"
- expect(out).not_to include("activesupport (newest")
- expect(out).to include("foo (newest 1.0")
- end
- end
-
- describe "pre-release gems" do
- context "without the --pre option" do
- it "ignores pre-release versions" do
- update_repo2 do
- build_gem "activesupport", "3.0.0.beta"
- end
-
- bundle "outdated"
- expect(out).not_to include("activesupport (3.0.0.beta > 2.3.5)")
- end
- end
-
- context "with the --pre option" do
- it "includes pre-release versions" do
- update_repo2 do
- build_gem "activesupport", "3.0.0.beta"
- end
-
- bundle "outdated --pre"
- expect(out).to include("activesupport (newest 3.0.0.beta, installed 2.3.5, requested = 2.3.5)")
- end
- end
-
- context "when current gem is a pre-release" do
- it "includes the gem" do
- update_repo2 do
- build_gem "activesupport", "3.0.0.beta.1"
- build_gem "activesupport", "3.0.0.beta.2"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "3.0.0.beta.1"
- G
-
- bundle "outdated"
- expect(out).to include("(newest 3.0.0.beta.2, installed 3.0.0.beta.1, requested = 3.0.0.beta.1)")
- end
- end
- end
-
- filter_strict_option = Bundler.feature_flag.bundler_2_mode? ? :"filter-strict" : :strict
- describe "with --#{filter_strict_option} option" do
- it "only reports gems that have a newer version that matches the specified dependency version requirements" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- build_gem "weakling", "0.0.5"
- end
-
- bundle :outdated, filter_strict_option => true
-
- expect(out).to_not include("activesupport (newest")
- expect(out).to include("(newest 0.0.5, installed 0.0.3, requested ~> 0.0.1)")
- end
-
- it "only reports gem dependencies when they can actually be updated" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack_middleware", "1.0"
- G
-
- bundle :outdated, filter_strict_option => true
-
- expect(out).to_not include("rack (1.2")
- end
-
- describe "and filter options" do
- it "only reports gems that match requirement and patch filter level" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "~> 2.3"
- gem "weakling", ">= 0.0.1"
- G
-
- update_repo2 do
- build_gem "activesupport", %w[2.4.0 3.0.0]
- build_gem "weakling", "0.0.5"
- end
-
- bundle :outdated, filter_strict_option => true, "filter-patch" => true
-
- expect(out).to_not include("activesupport (newest")
- expect(out).to include("(newest 0.0.5, installed 0.0.3")
- end
-
- it "only reports gems that match requirement and minor filter level" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "~> 2.3"
- gem "weakling", ">= 0.0.1"
- G
-
- update_repo2 do
- build_gem "activesupport", %w[2.3.9]
- build_gem "weakling", "0.1.5"
- end
-
- bundle :outdated, filter_strict_option => true, "filter-minor" => true
-
- expect(out).to_not include("activesupport (newest")
- expect(out).to include("(newest 0.1.5, installed 0.0.3")
- end
-
- it "only reports gems that match requirement and major filter level" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "~> 2.3"
- gem "weakling", ">= 0.0.1"
- G
-
- update_repo2 do
- build_gem "activesupport", %w[2.4.0 2.5.0]
- build_gem "weakling", "1.1.5"
- end
-
- bundle :outdated, filter_strict_option => true, "filter-major" => true
-
- expect(out).to_not include("activesupport (newest")
- expect(out).to include("(newest 1.1.5, installed 0.0.3")
- end
- end
- end
-
- describe "with invalid gem name" do
- it "returns could not find gem name" do
- bundle "outdated invalid_gem_name"
- expect(err).to include("Could not find gem 'invalid_gem_name'.")
- end
-
- it "returns non-zero exit code" do
- bundle "outdated invalid_gem_name"
- expect(exitstatus).to_not be_zero if exitstatus
- end
- end
-
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- gem "foo"
- G
-
- bundle "config set auto_install 1"
- bundle :outdated
- expect(out).to include("Installing foo 1.0")
- end
-
- context "after bundle install --deployment", :bundler => "< 3" do
- before do
- install_gemfile <<-G, forgotten_command_line_options(:deployment => true)
- source "#{file_uri_for(gem_repo2)}"
-
- gem "rack"
- gem "foo"
- G
- end
-
- it "outputs a helpful message about being in deployment mode" do
- update_repo2 { build_gem "activesupport", "3.0" }
-
- bundle "outdated"
- expect(last_command).to be_failure
- expect(err).to include("You are trying to check outdated gems in deployment mode.")
- expect(err).to include("Run `bundle outdated` elsewhere.")
- expect(err).to include("If this is a development machine, remove the ")
- expect(err).to include("Gemfile freeze\nby running `bundle config unset deployment`.")
- end
- end
-
- context "after bundle config set deployment true" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "rack"
- gem "foo"
- G
- bundle! "config set deployment true"
- end
-
- it "outputs a helpful message about being in deployment mode" do
- update_repo2 { build_gem "activesupport", "3.0" }
-
- bundle "outdated"
- expect(last_command).to be_failure
- expect(err).to include("You are trying to check outdated gems in deployment mode.")
- expect(err).to include("Run `bundle outdated` elsewhere.")
- expect(err).to include("If this is a development machine, remove the ")
- expect(err).to include("Gemfile freeze\nby running `bundle config unset deployment`.")
- end
- end
-
- context "update available for a gem on a different platform" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "laduradura", '= 5.15.2'
- G
- end
-
- it "reports that no updates are available" do
- bundle "outdated"
- expect(out).to include("Bundle up to date!")
- end
- end
-
- context "update available for a gem on the same platform while multiple platforms used for gem" do
- it "reports that updates are available if the Ruby platform is used" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "laduradura", '= 5.15.2', :platforms => [:ruby, :jruby]
- G
-
- bundle "outdated"
- expect(out).to include("Bundle up to date!")
- end
-
- it "reports that updates are available if the JRuby platform is used" do
- simulate_ruby_engine "jruby", "1.6.7" do
- simulate_platform "jruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "laduradura", '= 5.15.2', :platforms => [:ruby, :jruby]
- G
-
- bundle "outdated"
- expect(out).to include("Outdated gems included in the bundle:")
- expect(out).to include("laduradura (newest 5.15.3, installed 5.15.2, requested = 5.15.2)")
- end
- end
- end
- end
-
- shared_examples_for "version update is detected" do
- it "reports that a gem has a newer version" do
- subject
- expect(out).to include("Outdated gems included in the bundle:")
- expect(out).to include("activesupport (newest")
- expect(out).to_not include("ERROR REPORT TEMPLATE")
- end
- end
-
- shared_examples_for "major version updates are detected" do
- before do
- update_repo2 do
- build_gem "activesupport", "3.3.5"
- build_gem "weakling", "0.8.0"
- end
- end
-
- it_behaves_like "version update is detected"
- end
-
- context "when on a new machine" do
- before do
- simulate_new_machine
-
- update_git "foo", :path => lib_path("foo")
- update_repo2 do
- build_gem "activesupport", "3.3.5"
- build_gem "weakling", "0.8.0"
- end
- end
-
- subject { bundle "outdated" }
- it_behaves_like "version update is detected"
- end
-
- shared_examples_for "minor version updates are detected" do
- before do
- update_repo2 do
- build_gem "activesupport", "2.7.5"
- build_gem "weakling", "2.0.1"
- end
- end
-
- it_behaves_like "version update is detected"
- end
-
- shared_examples_for "patch version updates are detected" do
- before do
- update_repo2 do
- build_gem "activesupport", "2.3.7"
- build_gem "weakling", "0.3.1"
- end
- end
-
- it_behaves_like "version update is detected"
- end
-
- shared_examples_for "no version updates are detected" do
- it "does not detect any version updates" do
- subject
- expect(out).to include("updates to display.")
- expect(out).to_not include("ERROR REPORT TEMPLATE")
- expect(out).to_not include("activesupport (newest")
- expect(out).to_not include("weakling (newest")
- end
- end
-
- shared_examples_for "major version is ignored" do
- before do
- update_repo2 do
- build_gem "activesupport", "3.3.5"
- build_gem "weakling", "1.0.1"
- end
- end
-
- it_behaves_like "no version updates are detected"
- end
-
- shared_examples_for "minor version is ignored" do
- before do
- update_repo2 do
- build_gem "activesupport", "2.4.5"
- build_gem "weakling", "0.3.1"
- end
- end
-
- it_behaves_like "no version updates are detected"
- end
-
- shared_examples_for "patch version is ignored" do
- before do
- update_repo2 do
- build_gem "activesupport", "2.3.6"
- build_gem "weakling", "0.0.4"
- end
- end
-
- it_behaves_like "no version updates are detected"
- end
-
- describe "with --filter-major option" do
- subject { bundle "outdated --filter-major" }
-
- it_behaves_like "major version updates are detected"
- it_behaves_like "minor version is ignored"
- it_behaves_like "patch version is ignored"
- end
-
- describe "with --filter-minor option" do
- subject { bundle "outdated --filter-minor" }
-
- it_behaves_like "minor version updates are detected"
- it_behaves_like "major version is ignored"
- it_behaves_like "patch version is ignored"
- end
-
- describe "with --filter-patch option" do
- subject { bundle "outdated --filter-patch" }
-
- it_behaves_like "patch version updates are detected"
- it_behaves_like "major version is ignored"
- it_behaves_like "minor version is ignored"
- end
-
- describe "with --filter-minor --filter-patch options" do
- subject { bundle "outdated --filter-minor --filter-patch" }
-
- it_behaves_like "minor version updates are detected"
- it_behaves_like "patch version updates are detected"
- it_behaves_like "major version is ignored"
- end
-
- describe "with --filter-major --filter-minor options" do
- subject { bundle "outdated --filter-major --filter-minor" }
-
- it_behaves_like "major version updates are detected"
- it_behaves_like "minor version updates are detected"
- it_behaves_like "patch version is ignored"
- end
-
- describe "with --filter-major --filter-patch options" do
- subject { bundle "outdated --filter-major --filter-patch" }
-
- it_behaves_like "major version updates are detected"
- it_behaves_like "patch version updates are detected"
- it_behaves_like "minor version is ignored"
- end
-
- describe "with --filter-major --filter-minor --filter-patch options" do
- subject { bundle "outdated --filter-major --filter-minor --filter-patch" }
-
- it_behaves_like "major version updates are detected"
- it_behaves_like "minor version updates are detected"
- it_behaves_like "patch version updates are detected"
- end
-
- context "conservative updates" do
- context "without update-strict" do
- before do
- build_repo4 do
- build_gem "patch", %w[1.0.0 1.0.1]
- build_gem "minor", %w[1.0.0 1.0.1 1.1.0]
- build_gem "major", %w[1.0.0 1.0.1 1.1.0 2.0.0]
- end
-
- # establish a lockfile set to 1.0.0
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'patch', '1.0.0'
- gem 'minor', '1.0.0'
- gem 'major', '1.0.0'
- G
-
- # remove 1.4.3 requirement and bar altogether
- # to setup update specs below
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'patch'
- gem 'minor'
- gem 'major'
- G
- end
-
- it "shows nothing when patching and filtering to minor" do
- bundle "outdated --patch --filter-minor"
-
- expect(out).to include("No minor updates to display.")
- expect(out).not_to include("patch (newest")
- expect(out).not_to include("minor (newest")
- expect(out).not_to include("major (newest")
- end
-
- it "shows all gems when patching and filtering to patch" do
- bundle "outdated --patch --filter-patch"
-
- expect(out).to include("patch (newest 1.0.1")
- expect(out).to include("minor (newest 1.0.1")
- expect(out).to include("major (newest 1.0.1")
- end
-
- it "shows minor and major when updating to minor and filtering to patch and minor" do
- bundle "outdated --minor --filter-minor"
-
- expect(out).not_to include("patch (newest")
- expect(out).to include("minor (newest 1.1.0")
- expect(out).to include("major (newest 1.1.0")
- end
-
- it "shows minor when updating to major and filtering to minor with parseable" do
- bundle "outdated --major --filter-minor --parseable"
-
- expect(out).not_to include("patch (newest")
- expect(out).to include("minor (newest")
- expect(out).not_to include("major (newest")
- end
- end
-
- context "with update-strict" do
- before do
- build_repo4 do
- build_gem "foo", %w[1.4.3 1.4.4] do |s|
- s.add_dependency "bar", "~> 2.0"
- end
- build_gem "foo", %w[1.4.5 1.5.0] do |s|
- s.add_dependency "bar", "~> 2.1"
- end
- build_gem "foo", %w[1.5.1] do |s|
- s.add_dependency "bar", "~> 3.0"
- end
- build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
- build_gem "qux", %w[1.0.0 1.1.0 2.0.0]
- end
-
- # establish a lockfile set to 1.4.3
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo', '1.4.3'
- gem 'bar', '2.0.3'
- gem 'qux', '1.0.0'
- G
-
- # remove 1.4.3 requirement and bar altogether
- # to setup update specs below
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo'
- gem 'qux'
- G
- end
-
- it "shows gems with update-strict updating to patch and filtering to patch" do
- bundle "outdated --patch --update-strict --filter-patch"
-
- expect(out).to include("foo (newest 1.4.4")
- expect(out).to include("bar (newest 2.0.5")
- expect(out).not_to include("qux (newest")
- end
- end
- end
-
- describe "with --only-explicit" do
- it "does not report outdated dependent gems" do
- build_repo4 do
- build_gem "weakling", %w[0.2 0.3] do |s|
- s.add_dependency "bar", "~> 2.1"
- end
- build_gem "bar", %w[2.1 2.2]
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'weakling', '0.2'
- gem 'bar', '2.1'
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'weakling'
- G
-
- bundle "outdated --only-explicit"
-
- expect(out).to include("weakling (newest 0.3")
- expect(out).not_to include("bar (newest 2.2")
- end
- end
-end
diff --git a/spec/bundler/commands/post_bundle_message_spec.rb b/spec/bundler/commands/post_bundle_message_spec.rb
deleted file mode 100644
index 6fd4fb7089..0000000000
--- a/spec/bundler/commands/post_bundle_message_spec.rb
+++ /dev/null
@@ -1,210 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "post bundle message" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", "2.3.5", :group => [:emo, :test]
- group :test do
- gem "rspec"
- end
- gem "rack-obama", :group => :obama
- G
- end
-
- let(:bundle_path) { "./.bundle" }
- let(:bundle_show_system_message) { "Use `bundle info [gemname]` to see where a bundled gem is installed." }
- let(:bundle_show_path_message) { "Bundled gems are installed into `#{bundle_path}`" }
- let(:bundle_complete_message) { "Bundle complete!" }
- let(:bundle_updated_message) { "Bundle updated!" }
- let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." }
- let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message }
-
- describe "for fresh bundle install" do
- it "without any options" do
- bundle :install
- expect(out).to include(bundle_show_message)
- expect(out).not_to include("Gems in the group")
- expect(out).to include(bundle_complete_message)
- expect(out).to include(installed_gems_stats)
- end
-
- it "with --without one group" do
- bundle! :install, forgotten_command_line_options(:without => "emo")
- expect(out).to include(bundle_show_message)
- expect(out).to include("Gems in the group emo were not installed")
- expect(out).to include(bundle_complete_message)
- expect(out).to include(installed_gems_stats)
- end
-
- it "with --without two groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo test")
- expect(out).to include(bundle_show_message)
- expect(out).to include("Gems in the groups emo and test were not installed")
- expect(out).to include(bundle_complete_message)
- expect(out).to include("4 Gemfile dependencies, 3 gems now installed.")
- end
-
- it "with --without more groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo obama test")
- expect(out).to include(bundle_show_message)
- expect(out).to include("Gems in the groups emo, obama and test were not installed")
- expect(out).to include(bundle_complete_message)
- expect(out).to include("4 Gemfile dependencies, 2 gems now installed.")
- end
-
- describe "with --path and" do
- let(:bundle_path) { "./vendor" }
-
- it "without any options" do
- bundle! :install, forgotten_command_line_options(:path => "vendor")
- expect(out).to include(bundle_show_path_message)
- expect(out).to_not include("Gems in the group")
- expect(out).to include(bundle_complete_message)
- end
-
- it "with --without one group" do
- bundle! :install, forgotten_command_line_options(:without => "emo", :path => "vendor")
- expect(out).to include(bundle_show_path_message)
- expect(out).to include("Gems in the group emo were not installed")
- expect(out).to include(bundle_complete_message)
- end
-
- it "with --without two groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo test", :path => "vendor")
- expect(out).to include(bundle_show_path_message)
- expect(out).to include("Gems in the groups emo and test were not installed")
- expect(out).to include(bundle_complete_message)
- end
-
- it "with --without more groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo obama test", :path => "vendor")
- expect(out).to include(bundle_show_path_message)
- expect(out).to include("Gems in the groups emo, obama and test were not installed")
- expect(out).to include(bundle_complete_message)
- end
-
- it "with an absolute --path inside the cwd" do
- bundle! :install, forgotten_command_line_options(:path => bundled_app("cache"))
- expect(out).to include("Bundled gems are installed into `./cache`")
- expect(out).to_not include("Gems in the group")
- expect(out).to include(bundle_complete_message)
- end
-
- it "with an absolute --path outside the cwd" do
- bundle! :install, forgotten_command_line_options(:path => tmp("not_bundled_app"))
- expect(out).to include("Bundled gems are installed into `#{tmp("not_bundled_app")}`")
- expect(out).to_not include("Gems in the group")
- expect(out).to include(bundle_complete_message)
- end
- end
-
- describe "with misspelled or non-existent gem name" do
- before do
- bundle "config set force_ruby_platform true"
- end
-
- it "should report a helpful error message", :bundler => "< 3" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "not-a-gem", :group => :development
- G
- expect(err).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.")
- end
-
- it "should report a helpful error message", :bundler => "3" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "not-a-gem", :group => :development
- G
- expect(err).to include <<-EOS.strip
-Could not find gem 'not-a-gem' in rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally.
-The source does not contain any versions of 'not-a-gem'
- EOS
- end
-
- it "should report a helpful error message with reference to cache if available" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundle :cache
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "not-a-gem", :group => :development
- G
- expect(err).to include("Could not find gem 'not-a-gem' in").
- and include("or in gems cached in vendor/cache.")
- end
- end
- end
-
- describe "for second bundle install run" do
- it "without any options" do
- 2.times { bundle :install }
- expect(out).to include(bundle_show_message)
- expect(out).to_not include("Gems in the groups")
- expect(out).to include(bundle_complete_message)
- expect(out).to include(installed_gems_stats)
- end
-
- it "with --without one group" do
- bundle! :install, forgotten_command_line_options(:without => "emo")
- bundle! :install
- expect(out).to include(bundle_show_message)
- expect(out).to include("Gems in the group emo were not installed")
- expect(out).to include(bundle_complete_message)
- expect(out).to include(installed_gems_stats)
- end
-
- it "with --without two groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo test")
- bundle! :install
- expect(out).to include(bundle_show_message)
- expect(out).to include("Gems in the groups emo and test were not installed")
- expect(out).to include(bundle_complete_message)
- end
-
- it "with --without more groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo obama test")
- bundle :install
- expect(out).to include(bundle_show_message)
- expect(out).to include("Gems in the groups emo, obama and test were not installed")
- expect(out).to include(bundle_complete_message)
- end
- end
-
- describe "for bundle update" do
- it "without any options" do
- bundle! :update, :all => true
- expect(out).not_to include("Gems in the groups")
- expect(out).to include(bundle_updated_message)
- end
-
- it "with --without one group" do
- bundle! :install, forgotten_command_line_options(:without => "emo")
- bundle! :update, :all => true
- expect(out).to include("Gems in the group emo were not updated")
- expect(out).to include(bundle_updated_message)
- end
-
- it "with --without two groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo test")
- bundle! :update, :all => true
- expect(out).to include("Gems in the groups emo and test were not updated")
- expect(out).to include(bundle_updated_message)
- end
-
- it "with --without more groups" do
- bundle! :install, forgotten_command_line_options(:without => "emo obama test")
- bundle! :update, :all => true
- expect(out).to include("Gems in the groups emo, obama and test were not updated")
- expect(out).to include(bundle_updated_message)
- end
- end
-end
diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb
deleted file mode 100644
index cc7f760d74..0000000000
--- a/spec/bundler/commands/pristine_spec.rb
+++ /dev/null
@@ -1,191 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/vendored_fileutils"
-
-RSpec.describe "bundle pristine", :ruby_repo do
- before :each do
- build_lib "baz", :path => bundled_app do |s|
- s.version = "1.0.0"
- s.add_development_dependency "baz-dev", "=1.0.0"
- end
-
- build_repo2 do
- build_gem "weakling"
- build_gem "baz-dev", "1.0.0"
- build_gem "very_simple_binary", &:add_c_extension
- build_git "foo", :path => lib_path("foo")
- build_git "git_with_ext", :path => lib_path("git_with_ext"), &:add_c_extension
- build_lib "bar", :path => lib_path("bar")
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "weakling"
- gem "very_simple_binary"
- gem "foo", :git => "#{lib_path("foo")}"
- gem "git_with_ext", :git => "#{lib_path("git_with_ext")}"
- gem "bar", :path => "#{lib_path("bar")}"
-
- gemspec
- G
- end
-
- context "when sourced from RubyGems" do
- it "reverts using cached .gem file" do
- spec = Bundler.definition.specs["weakling"].first
- changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
-
- FileUtils.touch(changes_txt)
- expect(changes_txt).to be_file
-
- bundle "pristine"
- expect(changes_txt).to_not be_file
- end
-
- it "does not delete the bundler gem" do
- system_gems :bundler
- bundle! "install"
- bundle! "pristine", :system_bundler => true
- bundle! "-v", :system_bundler => true
-
- expected = if Bundler::VERSION < "3.0"
- "Bundler version"
- else
- Bundler::VERSION
- end
-
- expect(out).to start_with(expected)
- end
- end
-
- context "when sourced from git repo" do
- it "reverts by resetting to current revision`" do
- spec = Bundler.definition.specs["foo"].first
- changed_file = Pathname.new(spec.full_gem_path).join("lib/foo.rb")
- diff = "#Pristine spec changes"
-
- File.open(changed_file, "a") {|f| f.puts diff }
- expect(File.read(changed_file)).to include(diff)
-
- bundle! "pristine"
- expect(File.read(changed_file)).to_not include(diff)
- end
-
- it "removes added files" do
- spec = Bundler.definition.specs["foo"].first
- changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
-
- FileUtils.touch(changes_txt)
- expect(changes_txt).to be_file
-
- bundle! "pristine"
- expect(changes_txt).not_to be_file
- end
- end
-
- context "when sourced from gemspec" do
- it "displays warning and ignores changes when sourced from gemspec" do
- spec = Bundler.definition.specs["baz"].first
- changed_file = Pathname.new(spec.full_gem_path).join("lib/baz.rb")
- diff = "#Pristine spec changes"
-
- File.open(changed_file, "a") {|f| f.puts diff }
- expect(File.read(changed_file)).to include(diff)
-
- bundle "pristine"
- expect(File.read(changed_file)).to include(diff)
- expect(err).to include("Cannot pristine #{spec.name} (#{spec.version}#{spec.git_version}). Gem is sourced from local path.")
- end
-
- it "reinstall gemspec dependency" do
- spec = Bundler.definition.specs["baz-dev"].first
- changed_file = Pathname.new(spec.full_gem_path).join("lib/baz/dev.rb")
- diff = "#Pristine spec changes"
-
- File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" }
- expect(File.read(changed_file)).to include(diff)
-
- bundle "pristine"
- expect(File.read(changed_file)).to_not include(diff)
- end
- end
-
- context "when sourced from path" do
- it "displays warning and ignores changes when sourced from local path" do
- spec = Bundler.definition.specs["bar"].first
- changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
- FileUtils.touch(changes_txt)
- expect(changes_txt).to be_file
- bundle "pristine"
- expect(err).to include("Cannot pristine #{spec.name} (#{spec.version}#{spec.git_version}). Gem is sourced from local path.")
- expect(changes_txt).to be_file
- end
- end
-
- context "when passing a list of gems to pristine" do
- it "resets them" do
- foo = Bundler.definition.specs["foo"].first
- foo_changes_txt = Pathname.new(foo.full_gem_path).join("lib/changes.txt")
- FileUtils.touch(foo_changes_txt)
- expect(foo_changes_txt).to be_file
-
- bar = Bundler.definition.specs["bar"].first
- bar_changes_txt = Pathname.new(bar.full_gem_path).join("lib/changes.txt")
- FileUtils.touch(bar_changes_txt)
- expect(bar_changes_txt).to be_file
-
- weakling = Bundler.definition.specs["weakling"].first
- weakling_changes_txt = Pathname.new(weakling.full_gem_path).join("lib/changes.txt")
- FileUtils.touch(weakling_changes_txt)
- expect(weakling_changes_txt).to be_file
-
- bundle! "pristine foo bar weakling"
-
- expect(err).to include("Cannot pristine bar (1.0). Gem is sourced from local path.")
- expect(out).to include("Installing weakling 1.0")
-
- expect(weakling_changes_txt).not_to be_file
- expect(foo_changes_txt).not_to be_file
- expect(bar_changes_txt).to be_file
- end
-
- it "raises when one of them is not in the lockfile" do
- bundle "pristine abcabcabc"
- expect(err).to include("Could not find gem 'abcabcabc'.")
- end
- end
-
- context "when a build config exists for one of the gems" do
- let(:very_simple_binary) { Bundler.definition.specs["very_simple_binary"].first }
- let(:c_ext_dir) { Pathname.new(very_simple_binary.full_gem_path).join("ext") }
- let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
- before { bundle "config set build.very_simple_binary -- #{build_opt}" }
-
- # This just verifies that the generated Makefile from the c_ext gem makes
- # use of the build_args from the bundle config
- it "applies the config when installing the gem" do
- bundle! "pristine"
-
- makefile_contents = File.read(c_ext_dir.join("Makefile").to_s)
- expect(makefile_contents).to match(/libpath =.*#{c_ext_dir}/)
- expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/)
- end
- end
-
- context "when a build config exists for a git sourced gem" do
- let(:git_with_ext) { Bundler.definition.specs["git_with_ext"].first }
- let(:c_ext_dir) { Pathname.new(git_with_ext.full_gem_path).join("ext") }
- let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
- before { bundle "config set build.git_with_ext -- #{build_opt}" }
-
- # This just verifies that the generated Makefile from the c_ext gem makes
- # use of the build_args from the bundle config
- it "applies the config when installing the gem" do
- bundle! "pristine"
-
- makefile_contents = File.read(c_ext_dir.join("Makefile").to_s)
- expect(makefile_contents).to match(/libpath =.*#{c_ext_dir}/)
- expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/)
- end
- end
-end
diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb
deleted file mode 100644
index 402faaf1f3..0000000000
--- a/spec/bundler/commands/remove_spec.rb
+++ /dev/null
@@ -1,595 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle remove" do
- context "when no gems are specified" do
- it "throws error" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
-
- bundle "remove"
-
- expect(err).to include("Please specify gems to remove.")
- end
- end
-
- context "when --install flag is specified" do
- it "removes gems from .bundle" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- bundle! "remove rack --install"
-
- expect(out).to include("rack was removed.")
- expect(the_bundle).to_not include_gems "rack"
- end
- end
-
- describe "remove single gem from gemfile" do
- context "when gem is present in gemfile" do
- it "shows success for removed gem" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- bundle! "remove rack"
-
- expect(out).to include("rack was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "when gem is not present in gemfile" do
- it "shows warning for gem that could not be removed" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
-
- bundle "remove rack"
-
- expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
- end
- end
- end
-
- describe "remove mutiple gems from gemfile" do
- context "when all gems are present in gemfile" do
- it "shows success fir all removed gems" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- gem "rails"
- G
-
- bundle! "remove rack rails"
-
- expect(out).to include("rack was removed.")
- expect(out).to include("rails was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "when some gems are not present in the gemfile" do
- it "shows warning for those not present and success for those that can be removed" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rails"
- gem "minitest"
- gem "rspec"
- G
-
- bundle "remove rails rack minitest"
-
- expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rails"
- gem "minitest"
- gem "rspec"
- G
- end
- end
- end
-
- context "with inline groups" do
- it "removes the specified gem" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", :group => [:dev]
- G
-
- bundle! "remove rack"
-
- expect(out).to include("rack was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- describe "with group blocks" do
- context "when single group block with gem to be removed is present" do
- it "removes the group block" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- gem "rspec"
- end
- G
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "when gem to be removed is outside block" do
- it "does not modify group" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- group :test do
- gem "coffee-script-source"
- end
- G
-
- bundle! "remove rack"
-
- expect(out).to include("rack was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- gem "coffee-script-source"
- end
- G
- end
- end
-
- context "when an empty block is also present" do
- it "removes all empty blocks" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- gem "rspec"
- end
-
- group :dev do
- end
- G
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "when the gem belongs to mutiple groups" do
- it "removes the groups" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test, :serioustest do
- gem "rspec"
- end
- G
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "when the gem is present in mutiple groups" do
- it "removes all empty blocks" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :one do
- gem "rspec"
- end
-
- group :two do
- gem "rspec"
- end
- G
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
- end
-
- describe "nested group blocks" do
- context "when all the groups will be empty after removal" do
- it "removes the empty nested blocks" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- group :serioustest do
- gem "rspec"
- end
- end
- G
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "when outer group will not be empty after removal" do
- it "removes only empty blocks" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- gem "rack-test"
-
- group :serioustest do
- gem "rspec"
- end
- end
- G
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- gem "rack-test"
-
- end
- G
- end
- end
-
- context "when inner group will not be empty after removal" do
- it "removes only empty blocks" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- group :serioustest do
- gem "rspec"
- gem "rack-test"
- end
- end
- G
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- group :test do
- group :serioustest do
- gem "rack-test"
- end
- end
- G
- end
- end
- end
-
- describe "arbitrary gemfile" do
- context "when mutiple gems are present in same line" do
- it "shows warning for gems not removed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"; gem "rails"
- G
-
- bundle "remove rails"
-
- expect(err).to include("Gems could not be removed. rack (>= 0) would also have been removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"; gem "rails"
- G
- end
- end
-
- context "when some gems could not be removed" do
- it "shows warning for gems not removed and success for those removed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem"rack"
- gem"rspec"
- gem "rails"
- gem "minitest"
- G
-
- bundle! "remove rails rack rspec minitest"
-
- expect(out).to include("rails was removed.")
- expect(out).to include("minitest was removed.")
- expect(out).to include("rack, rspec could not be removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem"rack"
- gem"rspec"
- G
- end
- end
- end
-
- context "with sources" do
- before do
- build_repo gem_repo3 do
- build_gem "rspec"
- end
- end
-
- it "removes gems and empty source blocks" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
-
- source "#{file_uri_for(gem_repo3)}" do
- gem "rspec"
- end
- G
-
- bundle! "install"
-
- bundle! "remove rspec"
-
- expect(out).to include("rspec was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
- end
- end
-
- describe "with eval_gemfile" do
- context "when gems are present in both gemfiles" do
- it "removes the gems" do
- create_file "Gemfile-other", <<-G
- gem "rack"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
-
- gem "rack"
- G
-
- bundle! "remove rack"
-
- expect(out).to include("rack was removed.")
- end
- end
-
- context "when gems are present in other gemfile" do
- it "removes the gems" do
- create_file "Gemfile-other", <<-G
- gem "rack"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- G
-
- bundle! "remove rack"
-
- expect(bundled_app("Gemfile-other").read).to_not include("gem \"rack\"")
- expect(out).to include("rack was removed.")
- end
- end
-
- context "when gems to be removed are not specified in any of the gemfiles" do
- it "throws error for the gems not present" do
- # an empty gemfile
- # indicating the gem is not present in the gemfile
- create_file "Gemfile-other", <<-G
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- G
-
- bundle "remove rack"
-
- expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
- end
- end
-
- context "when the gem is present in parent file but not in gemfile specified by eval_gemfile" do
- it "removes the gem" do
- create_file "Gemfile-other", <<-G
- gem "rails"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- gem "rack"
- G
-
- bundle "remove rack"
-
- expect(out).to include("rack was removed.")
- expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile-other")} so it could not be removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- G
- end
- end
-
- context "when gems can not be removed from other gemfile" do
- it "shows error" do
- create_file "Gemfile-other", <<-G
- gem "rails"; gem "rack"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- gem "rack"
- G
-
- bundle "remove rack"
-
- expect(out).to include("rack was removed.")
- expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- G
- end
- end
-
- context "when gems could not be removed from parent gemfile" do
- it "shows error" do
- create_file "Gemfile-other", <<-G
- gem "rack"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- gem "rails"; gem "rack"
- G
-
- bundle "remove rack"
-
- expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.")
- expect(bundled_app("Gemfile-other").read).to include("gem \"rack\"")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- gem "rails"; gem "rack"
- G
- end
- end
-
- context "when gem present in gemfiles but could not be removed from one from one of them" do
- it "removes gem which can be removed and shows warning for file from which it can not be removed" do
- create_file "Gemfile-other", <<-G
- gem "rack"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- eval_gemfile "Gemfile-other"
- gem"rack"
- G
-
- bundle! "remove rack"
-
- expect(out).to include("rack was removed.")
- expect(bundled_app("Gemfile-other").read).to_not include("gem \"rack\"")
- end
- end
- end
-
- context "with install_if" do
- it "removes gems inside blocks and empty blocks" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- install_if(lambda { false }) do
- gem "rack"
- end
- G
-
- bundle! "remove rack"
-
- expect(out).to include("rack was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "with env" do
- it "removes gems inside blocks and empty blocks" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- env "BUNDLER_TEST" do
- gem "rack"
- end
- G
-
- bundle! "remove rack"
-
- expect(out).to include("rack was removed.")
- gemfile_should_be <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
- end
- end
-
- context "with gemspec" do
- it "should not remove the gem" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("foo.gemspec", "")
- s.add_dependency "rack"
- end
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo1)}"
- gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
- G
-
- bundle! "remove foo"
-
- expect(out).to include("foo could not be removed.")
- end
- end
-end
diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb
deleted file mode 100644
index 61b8f73e7f..0000000000
--- a/spec/bundler/commands/show_spec.rb
+++ /dev/null
@@ -1,225 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle show", :bundler => "< 3" do
- context "with a standard Gemfile" do
- before :each do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
- end
-
- it "creates a Gemfile.lock if one did not exist" do
- FileUtils.rm("Gemfile.lock")
-
- bundle "show"
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "creates a Gemfile.lock when invoked with a gem name" do
- FileUtils.rm("Gemfile.lock")
-
- bundle "show rails"
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "prints path if gem exists in bundle" do
- bundle "show rails"
- expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
- end
-
- it "prints path if gem exists in bundle (with --paths option)" do
- bundle "show rails --paths"
- expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
- end
-
- it "warns if path no longer exists on disk" do
- FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
-
- bundle "show rails"
-
- expect(err).to match(/has been deleted/i)
- expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
- end
-
- it "prints the path to the running bundler" do
- bundle "show bundler"
- expect(out).to eq(root.to_s)
- end
-
- it "complains if gem not in bundle" do
- bundle "show missing"
- expect(err).to match(/could not find gem 'missing'/i)
- end
-
- it "prints path of all gems in bundle sorted by name" do
- bundle "show --paths"
-
- expect(out).to include(default_bundle_path("gems", "rake-12.3.2").to_s)
- expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
-
- # Gem names are the last component of their path.
- gem_list = out.split.map {|p| p.split("/").last }
- expect(gem_list).to eq(gem_list.sort)
- end
-
- it "prints summary of gems" do
- bundle "show --verbose"
-
- expect(out).to include <<~MSG
- * actionmailer (2.3.2)
- \tSummary: This is just a fake gem for testing
- \tHomepage: http://example.com
- \tStatus: Up to date
- MSG
- end
-
- it "includes bundler in the summary of gems" do
- bundle "show --verbose"
-
- expect(out).to include <<~MSG
- * bundler (#{Bundler::VERSION})
- \tSummary: The best way to manage your application's dependencies
- \tHomepage: https://bundler.io
- \tStatus: Up to date
- MSG
- end
- end
-
- context "with a git repo in the Gemfile" do
- before :each do
- @git = build_git "foo", "1.0"
- end
-
- it "prints out git info" do
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
- expect(the_bundle).to include_gems "foo 1.0"
-
- bundle :show
- expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
- end
-
- it "prints out branch names other than master" do
- update_git "foo", :branch => "omg" do |s|
- s.write "lib/foo.rb", "FOO = '1.0.omg'"
- end
- @revision = revision_for(lib_path("foo-1.0"))[0...6]
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
- G
- expect(the_bundle).to include_gems "foo 1.0.omg"
-
- bundle :show
- expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
- end
-
- it "doesn't print the branch when tied to a ref" do
- sha = revision_for(lib_path("foo-1.0"))
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
- G
-
- bundle :show
- expect(out).to include("foo (1.0 #{sha[0..6]})")
- end
-
- it "handles when a version is a '-' prerelease" do
- @git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
- install_gemfile <<-G
- gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
- G
- expect(the_bundle).to include_gems "foo 1.0.0.pre.beta.1"
-
- bundle! :show
- expect(out).to include("foo (1.0.0.pre.beta.1")
- end
- end
-
- context "in a fresh gem in a blank git repo" do
- before :each do
- build_git "foo", :path => lib_path("foo")
- in_app_root_custom lib_path("foo")
- File.open("Gemfile", "w") {|f| f.puts "gemspec" }
- sys_exec "rm -rf .git && git init"
- end
-
- it "does not output git errors" do
- bundle :show
- expect(err_without_deprecations).to be_empty
- end
- end
-
- it "performs an automatic bundle install" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo"
- G
-
- bundle "config set auto_install 1"
- bundle :show
- expect(out).to include("Installing foo 1.0")
- end
-
- context "with a valid regexp for gem name" do
- it "presents alternatives" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- bundle "show rac"
- expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
- end
- end
-
- context "with an invalid regexp for gem name" do
- it "does not find the gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- invalid_regexp = "[]"
-
- bundle "show #{invalid_regexp}"
- expect(err).to include("Could not find gem '#{invalid_regexp}'.")
- end
- end
-
- context "--outdated option" do
- # Regression test for https://github.com/bundler/bundler/issues/5375
- before do
- build_repo2
- end
-
- it "doesn't update gems to newer versions" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails"
- G
-
- expect(the_bundle).to include_gem("rails 2.3.2")
-
- update_repo2 do
- build_gem "rails", "3.0.0" do |s|
- s.executables = "rails"
- end
- end
-
- bundle! "show --outdated"
-
- bundle! "install"
- expect(the_bundle).to include_gem("rails 2.3.2")
- end
- end
-end
-
-RSpec.describe "bundle show", :bundler => "3" do
- pending "shows a friendly error about the command removal"
-end
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
deleted file mode 100644
index e4449312eb..0000000000
--- a/spec/bundler/commands/update_spec.rb
+++ /dev/null
@@ -1,1021 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle update" do
- before :each do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
- gem "platform_specific"
- G
- end
-
- describe "with no arguments", :bundler => "< 3" do
- it "updates the entire bundle" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle "update"
- expect(out).to include("Bundle updated!")
- expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
- end
-
- it "doesn't delete the Gemfile.lock file if something goes wrong" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
- exit!
- G
- bundle "update"
- expect(bundled_app("Gemfile.lock")).to exist
- end
- end
-
- describe "with --all", :bundler => "3" do
- it "updates the entire bundle" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle! "update", :all => true
- expect(out).to include("Bundle updated!")
- expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
- end
-
- it "doesn't delete the Gemfile.lock file if something goes wrong" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
- exit!
- G
- bundle "update", :all => true
- expect(bundled_app("Gemfile.lock")).to exist
- end
- end
-
- describe "with --gemfile" do
- it "creates lock files based on the Gemfile name" do
- gemfile bundled_app("OmgFile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0"
- G
-
- bundle! "update --gemfile OmgFile", :all => true
-
- expect(bundled_app("OmgFile.lock")).to exist
- end
- end
-
- context "when update_requires_all_flag is set" do
- before { bundle! "config set update_requires_all_flag true" }
-
- it "errors when passed nothing" do
- install_gemfile! ""
- bundle :update
- expect(err).to eq("To update everything, pass the `--all` flag.")
- end
-
- it "errors when passed --all and another option" do
- install_gemfile! ""
- bundle "update --all foo"
- expect(err).to eq("Cannot specify --all along with specific options.")
- end
-
- it "updates everything when passed --all" do
- install_gemfile! ""
- bundle "update --all"
- expect(out).to include("Bundle updated!")
- end
- end
-
- describe "--quiet argument" do
- it "hides UI messages" do
- bundle "update --quiet"
- expect(out).not_to include("Bundle updated!")
- end
- end
-
- describe "with a top level dependency" do
- it "unlocks all child dependencies that are unrelated to other locked dependencies" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle "update rack-obama"
- expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 2.3.5"
- end
- end
-
- describe "with an unknown dependency" do
- it "should inform the user" do
- bundle "update halting-problem-solver"
- expect(err).to include "Could not find gem 'halting-problem-solver'"
- end
- it "should suggest alternatives" do
- bundle "update platformspecific"
- expect(err).to include "Did you mean platform_specific?"
- end
- end
-
- describe "with a child dependency" do
- it "should update the child dependency" do
- update_repo2
- bundle "update rack"
- expect(the_bundle).to include_gems "rack 1.2"
- end
- end
-
- describe "when a possible resolve requires an older version of a locked gem" do
- context "and only_update_to_newer_versions is set" do
- before do
- bundle! "config set only_update_to_newer_versions true"
- end
-
- it "does not go to an older version" do
- build_repo4 do
- build_gem "tilt", "2.0.8"
- build_gem "slim", "3.0.9" do |s|
- s.add_dependency "tilt", [">= 1.3.3", "< 2.1"]
- end
- build_gem "slim_lint", "0.16.1" do |s|
- s.add_dependency "slim", [">= 3.0", "< 5.0"]
- end
- build_gem "slim-rails", "0.2.1" do |s|
- s.add_dependency "slim", ">= 0.9.2"
- end
- build_gem "slim-rails", "3.1.3" do |s|
- s.add_dependency "slim", "~> 3.0"
- end
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "slim-rails"
- gem "slim_lint"
- G
-
- expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")
-
- update_repo4 do
- build_gem "slim", "4.0.0" do |s|
- s.add_dependency "tilt", [">= 2.0.6", "< 2.1"]
- end
- end
-
- bundle! "update", :all => true
-
- expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")
- end
-
- it "should still downgrade if forced by the Gemfile" do
- build_repo4 do
- build_gem "a"
- build_gem "b", "1.0"
- build_gem "b", "2.0"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "a"
- gem "b"
- G
-
- expect(the_bundle).to include_gems("a 1.0", "b 2.0")
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "a"
- gem "b", "1.0"
- G
-
- bundle! "update b"
-
- expect(the_bundle).to include_gems("a 1.0", "b 1.0")
- end
- end
- end
-
- describe "with --local option" do
- it "doesn't hit repo2" do
- FileUtils.rm_rf(gem_repo2)
-
- bundle "update --local --all"
- expect(out).not_to include("Fetching source index")
- end
- end
-
- describe "with --group option" do
- it "should update only specified group gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", :group => :development
- gem "rack"
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
- bundle "update --group development"
- expect(the_bundle).to include_gems "activesupport 3.0"
- expect(the_bundle).not_to include_gems "rack 1.2"
- end
-
- context "when conservatively updating a group with non-group sub-deps" do
- it "should update only specified group gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activemerchant", :group => :development
- gem "activesupport"
- G
- update_repo2 do
- build_gem "activemerchant", "2.0"
- build_gem "activesupport", "3.0"
- end
- bundle "update --conservative --group development"
- expect(the_bundle).to include_gems "activemerchant 2.0"
- expect(the_bundle).not_to include_gems "activesupport 3.0"
- end
- end
-
- context "when there is a source with the same name as a gem in a group" do
- before :each do
- build_git "foo", :path => lib_path("activesupport")
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", :group => :development
- gem "foo", :git => "#{lib_path("activesupport")}"
- G
- end
-
- it "should not update the gems from that source" do
- update_repo2 { build_gem "activesupport", "3.0" }
- update_git "foo", "2.0", :path => lib_path("activesupport")
-
- bundle "update --group development"
- expect(the_bundle).to include_gems "activesupport 3.0"
- expect(the_bundle).not_to include_gems "foo 2.0"
- end
- end
-
- context "when bundler itself is a transitive dependency" do
- it "executes without error" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport", :group => :development
- gem "rack"
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
- bundle "update --group development"
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}"
- expect(the_bundle).not_to include_gems "rack 1.2"
- end
- end
- end
-
- describe "in a frozen bundle" do
- it "should fail loudly", :bundler => "< 3" do
- bundle! "install --deployment"
- bundle "update", :all => true
-
- expect(last_command).to be_failure
- expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
- expect(err).to match(/freeze \nby running `bundle config unset deployment`./m)
- end
-
- it "should suggest different command when frozen is set globally", :bundler => "< 3" do
- bundle! "config set --global frozen 1"
- bundle "update", :all => true
- expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
- and match(/freeze \nby running `bundle config unset frozen`./m)
- end
-
- it "should suggest different command when frozen is set globally", :bundler => "3" do
- bundle! "config set --global deployment true"
- bundle "update", :all => true
- expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
- and match(/freeze \nby running `bundle config unset deployment`./m)
- end
- end
-
- describe "with --source option" do
- it "should not update gems not included in the source that happen to have the same name", :bundler => "< 3" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- G
- update_repo2 { build_gem "activesupport", "3.0" }
-
- bundle! "update --source activesupport"
- expect(the_bundle).to include_gem "activesupport 3.0"
- end
-
- it "should not update gems not included in the source that happen to have the same name", :bundler => "3" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- G
- update_repo2 { build_gem "activesupport", "3.0" }
-
- bundle! "update --source activesupport"
- expect(the_bundle).not_to include_gem "activesupport 3.0"
- end
-
- context "with unlock_source_unlocks_spec set to false" do
- before { bundle! "config set unlock_source_unlocks_spec false" }
-
- it "should not update gems not included in the source that happen to have the same name" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- G
- update_repo2 { build_gem "activesupport", "3.0" }
-
- bundle "update --source activesupport"
- expect(the_bundle).not_to include_gems "activesupport 3.0"
- end
- end
- end
-
- context "when there is a child dependency that is also in the gemfile" do
- before do
- build_repo2 do
- build_gem "fred", "1.0"
- build_gem "harry", "1.0" do |s|
- s.add_dependency "fred"
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "harry"
- gem "fred"
- G
- end
-
- it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do
- update_repo2 do
- build_gem "fred", "2.0"
- build_gem "harry", "2.0" do |s|
- s.add_dependency "fred"
- end
- end
-
- bundle "update --source harry"
- expect(the_bundle).to include_gems "harry 2.0"
- expect(the_bundle).to include_gems "fred 1.0"
- end
-
- it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do
- update_repo2 do
- build_gem "fred", "2.0"
- build_gem "harry", "2.0" do |s|
- s.add_dependency "fred"
- end
- end
-
- bundle "update --source harry"
- expect(the_bundle).to include_gems "harry 1.0", "fred 1.0"
- end
- end
-
- context "when there is a child dependency that appears elsewhere in the dependency graph" do
- before do
- build_repo2 do
- build_gem "fred", "1.0" do |s|
- s.add_dependency "george"
- end
- build_gem "george", "1.0"
- build_gem "harry", "1.0" do |s|
- s.add_dependency "george"
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "harry"
- gem "fred"
- G
- end
-
- it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do
- update_repo2 do
- build_gem "george", "2.0"
- build_gem "harry", "2.0" do |s|
- s.add_dependency "george"
- end
- end
-
- bundle "update --source harry"
- expect(the_bundle).to include_gems "harry 2.0"
- expect(the_bundle).to include_gems "fred 1.0"
- expect(the_bundle).to include_gems "george 1.0"
- end
-
- it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do
- update_repo2 do
- build_gem "george", "2.0"
- build_gem "harry", "2.0" do |s|
- s.add_dependency "george"
- end
- end
-
- bundle "update --source harry"
- expect(the_bundle).to include_gems "harry 1.0", "fred 1.0", "george 1.0"
- end
- end
-end
-
-RSpec.describe "bundle update in more complicated situations" do
- before :each do
- build_repo2
- end
-
- it "will eagerly unlock dependencies of a specified gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "thin"
- gem "rack-obama"
- G
-
- update_repo2 do
- build_gem "thin", "2.0" do |s|
- s.add_dependency "rack"
- end
- end
-
- bundle "update thin"
- expect(the_bundle).to include_gems "thin 2.0", "rack 1.2", "rack-obama 1.0"
- end
-
- it "will warn when some explicitly updated gems are not updated" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "thin"
- gem "rack-obama"
- G
-
- update_repo2 do
- build_gem("thin", "2.0") {|s| s.add_dependency "rack" }
- build_gem "rack", "10.0"
- end
-
- bundle! "update thin rack-obama"
- expect(last_command.stdboth).to include "Bundler attempted to update rack-obama but its version stayed the same"
- expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0"
- end
-
- it "will not warn when an explicitly updated git gem changes sha but not version" do
- build_git "foo"
-
- install_gemfile! <<-G
- gem "foo", :git => '#{lib_path("foo-1.0")}'
- G
-
- update_git "foo" do |s|
- s.write "lib/foo2.rb", "puts :foo2"
- end
-
- bundle! "update foo"
-
- expect(last_command.stdboth).not_to include "attempted to update"
- end
-
- it "will not warn when changing gem sources but not versions" do
- build_git "rack"
-
- install_gemfile! <<-G
- gem "rack", :git => '#{lib_path("rack-1.0")}'
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle! "update rack"
-
- expect(last_command.stdboth).not_to include "attempted to update"
- end
-
- it "will update only from pinned source" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- source "#{file_uri_for(gem_repo1)}" do
- gem "thin"
- end
- G
-
- update_repo2 do
- build_gem "thin", "2.0"
- end
-
- bundle "update"
- expect(the_bundle).to include_gems "thin 1.0"
- end
-
- context "when the lockfile is for a different platform" do
- before do
- build_repo4 do
- build_gem("a", "0.9")
- build_gem("a", "0.9") {|s| s.platform = "java" }
- build_gem("a", "1.1")
- build_gem("a", "1.1") {|s| s.platform = "java" }
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "a"
- G
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo4)}
- specs:
- a (0.9-java)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- a
- L
-
- simulate_platform linux
- end
-
- it "allows updating" do
- bundle! :update, :all => true
- expect(the_bundle).to include_gem "a 1.1"
- end
-
- it "allows updating a specific gem" do
- bundle! "update a"
- expect(the_bundle).to include_gem "a 1.1"
- end
- end
-
- context "when the dependency is for a different platform" do
- before do
- build_repo4 do
- build_gem("a", "0.9") {|s| s.platform = "java" }
- build_gem("a", "1.1") {|s| s.platform = "java" }
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "a", platform: :jruby
- G
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo4)}
- specs:
- a (0.9-java)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- a
- L
-
- simulate_platform linux
- end
-
- it "is not updated because it is not actually included in the bundle" do
- bundle! "update a"
- expect(last_command.stdboth).to include "Bundler attempted to update a but it was not considered because it is for a different platform from the current one"
- expect(the_bundle).to_not include_gem "a"
- end
- end
-end
-
-RSpec.describe "bundle update without a Gemfile.lock" do
- it "should not explode" do
- build_repo2
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "rack", "1.0"
- G
-
- bundle "update", :all => true
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-end
-
-RSpec.describe "bundle update when a gem depends on a newer version of bundler" do
- before(:each) do
- build_repo2 do
- build_gem "rails", "3.0.1" do |s|
- s.add_dependency "bundler", Bundler::VERSION.succ
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0.1"
- G
- end
-
- it "should explain that bundler conflicted", :bundler => "< 3" do
- bundle "update", :all => true
- expect(last_command.stdboth).not_to match(/in snapshot/i)
- expect(err).to match(/current Bundler version/i).
- and match(/perhaps you need to update bundler/i)
- end
-
- it "should warn that the newer version of Bundler would conflict", :bundler => "3" do
- bundle! "update", :all => true
- expect(err).to include("rails (3.0.1) has dependency bundler").
- and include("so the dependency is being ignored")
- expect(the_bundle).to include_gem "rails 3.0.1"
- end
-end
-
-RSpec.describe "bundle update" do
- it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- G
-
- bundle "update", :all => true
- expect(out).to include("Using activesupport 2.3.5")
-
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle "update", :all => true
- expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
- end
-
- context "with suppress_install_using_messages set" do
- before { bundle! "config set suppress_install_using_messages true" }
-
- it "only prints `Using` for versions that have changed" do
- build_repo4 do
- build_gem "bar"
- build_gem "foo"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "bar"
- gem "foo"
- G
-
- bundle! "update", :all => true
- out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
- expect(out).to include "Resolving dependencies...\nBundle updated!"
-
- update_repo4 do
- build_gem "foo", "2.0"
- end
-
- bundle! "update", :all => true
- out.sub!("Removing foo (1.0)\n", "")
- out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
- expect(out).to include strip_whitespace(<<-EOS).strip
- Resolving dependencies...
- Fetching foo 2.0 (was 1.0)
- Installing foo 2.0 (was 1.0)
- Bundle updated
- EOS
- end
- end
-
- it "shows error message when Gemfile.lock is not preset and gem is specified" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- G
-
- bundle "update nonexisting"
- expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
- expect(exitstatus).to eq(22) if exitstatus
- end
-end
-
-RSpec.describe "bundle update --ruby" do
- before do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.3'
- ::RUBY_PATCHLEVEL = 100
- ruby '~> 2.1.0'
- G
- bundle "update --ruby"
- end
-
- context "when the Gemfile removes the ruby" do
- before do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.4'
- ::RUBY_PATCHLEVEL = 222
- G
- end
- it "removes the Ruby from the Gemfile.lock" do
- bundle "update --ruby"
-
- lockfile_should_be <<-L
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "when the Gemfile specified an updated Ruby version" do
- before do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.4'
- ::RUBY_PATCHLEVEL = 222
- ruby '~> 2.1.0'
- G
- end
- it "updates the Gemfile.lock with the latest version" do
- bundle "update --ruby"
-
- lockfile_should_be <<-L
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
-
- RUBY VERSION
- ruby 2.1.4p222
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "when a different Ruby is being used than has been versioned" do
- before do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.2.2'
- ::RUBY_PATCHLEVEL = 505
- ruby '~> 2.1.0'
- G
- end
- it "shows a helpful error message" do
- bundle "update --ruby"
-
- expect(err).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
- end
- end
-
- context "when updating Ruby version and Gemfile `ruby`" do
- before do
- install_gemfile <<-G
- ::RUBY_VERSION = '1.8.3'
- ::RUBY_PATCHLEVEL = 55
- ruby '~> 1.8.0'
- G
- end
- it "updates the Gemfile.lock with the latest version" do
- bundle "update --ruby"
-
- lockfile_should_be <<-L
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
-
- RUBY VERSION
- ruby 1.8.3p55
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-end
-
-RSpec.describe "bundle update --bundler" do
- it "updates the bundler version in the lockfile without re-resolving" do
- build_repo4 do
- build_gem "rack", "1.0"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "rack"
- G
- lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2')
-
- FileUtils.rm_r gem_repo4
-
- bundle! :update, :bundler => true, :verbose => true
- expect(the_bundle).to include_gem "rack 1.0"
-
- expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION)
- end
-end
-
-# these specs are slow and focus on integration and therefore are not exhaustive. unit specs elsewhere handle that.
-RSpec.describe "bundle update conservative" do
- context "patch and minor options" do
- before do
- build_repo4 do
- build_gem "foo", %w[1.4.3 1.4.4] do |s|
- s.add_dependency "bar", "~> 2.0"
- end
- build_gem "foo", %w[1.4.5 1.5.0] do |s|
- s.add_dependency "bar", "~> 2.1"
- end
- build_gem "foo", %w[1.5.1] do |s|
- s.add_dependency "bar", "~> 3.0"
- end
- build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
- build_gem "qux", %w[1.0.0 1.0.1 1.1.0 2.0.0]
- end
-
- # establish a lockfile set to 1.4.3
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo', '1.4.3'
- gem 'bar', '2.0.3'
- gem 'qux', '1.0.0'
- G
-
- # remove 1.4.3 requirement and bar altogether
- # to setup update specs below
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'foo'
- gem 'qux'
- G
- end
-
- context "with patch set as default update level in config" do
- it "should do a patch level update" do
- bundle! "config set --local prefer_patch true"
- bundle! "update foo"
-
- expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
- end
- end
-
- context "patch preferred" do
- it "single gem updates dependent gem to minor" do
- bundle! "update --patch foo"
-
- expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
- end
-
- it "update all" do
- bundle! "update --patch", :all => true
-
- expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.1"
- end
- end
-
- context "minor preferred" do
- it "single gem updates dependent gem to major" do
- bundle! "update --minor foo"
-
- expect(the_bundle).to include_gems "foo 1.5.1", "bar 3.0.0", "qux 1.0.0"
- end
- end
-
- context "strict" do
- it "patch preferred" do
- bundle! "update --patch foo bar --strict"
-
- expect(the_bundle).to include_gems "foo 1.4.4", "bar 2.0.5", "qux 1.0.0"
- end
-
- it "minor preferred" do
- bundle! "update --minor --strict", :all => true
-
- expect(the_bundle).to include_gems "foo 1.5.0", "bar 2.1.1", "qux 1.1.0"
- end
- end
- end
-
- context "eager unlocking" do
- before do
- build_repo4 do
- build_gem "isolated_owner", %w[1.0.1 1.0.2] do |s|
- s.add_dependency "isolated_dep", "~> 2.0"
- end
- build_gem "isolated_dep", %w[2.0.1 2.0.2]
-
- build_gem "shared_owner_a", %w[3.0.1 3.0.2] do |s|
- s.add_dependency "shared_dep", "~> 5.0"
- end
- build_gem "shared_owner_b", %w[4.0.1 4.0.2] do |s|
- s.add_dependency "shared_dep", "~> 5.0"
- end
- build_gem "shared_dep", %w[5.0.1 5.0.2]
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'isolated_owner'
-
- gem 'shared_owner_a'
- gem 'shared_owner_b'
- G
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo4)}
- specs:
- isolated_dep (2.0.1)
- isolated_owner (1.0.1)
- isolated_dep (~> 2.0)
- shared_dep (5.0.1)
- shared_owner_a (3.0.1)
- shared_dep (~> 5.0)
- shared_owner_b (4.0.1)
- shared_dep (~> 5.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- shared_owner_a
- shared_owner_b
- isolated_owner
-
- BUNDLED WITH
- 1.13.0
- L
- end
-
- it "should eagerly unlock isolated dependency" do
- bundle "update isolated_owner"
-
- expect(the_bundle).to include_gems "isolated_owner 1.0.2", "isolated_dep 2.0.2", "shared_dep 5.0.1", "shared_owner_a 3.0.1", "shared_owner_b 4.0.1"
- end
-
- it "should eagerly unlock shared dependency" do
- bundle "update shared_owner_a"
-
- expect(the_bundle).to include_gems "isolated_owner 1.0.1", "isolated_dep 2.0.1", "shared_dep 5.0.2", "shared_owner_a 3.0.2", "shared_owner_b 4.0.1"
- end
-
- it "should not eagerly unlock with --conservative" do
- bundle "update --conservative shared_owner_a isolated_owner"
-
- expect(the_bundle).to include_gems "isolated_owner 1.0.2", "isolated_dep 2.0.2", "shared_dep 5.0.1", "shared_owner_a 3.0.2", "shared_owner_b 4.0.1"
- end
-
- it "should match bundle install conservative update behavior when not eagerly unlocking" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem 'isolated_owner', '1.0.2'
-
- gem 'shared_owner_a', '3.0.2'
- gem 'shared_owner_b'
- G
-
- bundle "install"
-
- expect(the_bundle).to include_gems "isolated_owner 1.0.2", "isolated_dep 2.0.2", "shared_dep 5.0.1", "shared_owner_a 3.0.2", "shared_owner_b 4.0.1"
- end
- end
-
- context "error handling" do
- before do
- gemfile ""
- end
-
- it "raises if too many flags are provided" do
- bundle "update --patch --minor", :all => true
-
- expect(err).to eq "Provide only one of the following options: minor, patch"
- end
- end
-end
diff --git a/spec/bundler/commands/version_spec.rb b/spec/bundler/commands/version_spec.rb
deleted file mode 100644
index 8eecd9c53e..0000000000
--- a/spec/bundler/commands/version_spec.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../support/path"
-
-RSpec.describe "bundle version" do
- if Spec::Path.ruby_core?
- COMMIT_HASH = /unknown|[a-fA-F0-9]{7,}/.freeze
- else
- COMMIT_HASH = /[a-fA-F0-9]{7,}/.freeze
- end
-
- context "with -v" do
- it "outputs the version", :bundler => "< 3" do
- bundle! "-v"
- expect(out).to eq("Bundler version #{Bundler::VERSION}")
- end
-
- it "outputs the version", :bundler => "3" do
- bundle! "-v"
- expect(out).to eq(Bundler::VERSION)
- end
- end
-
- context "with --version" do
- it "outputs the version", :bundler => "< 3" do
- bundle! "--version"
- expect(out).to eq("Bundler version #{Bundler::VERSION}")
- end
-
- it "outputs the version", :bundler => "3" do
- bundle! "--version"
- expect(out).to eq(Bundler::VERSION)
- end
- end
-
- context "with version" do
- it "outputs the version with build metadata", :bundler => "< 3" do
- bundle! "version"
- expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/)
- end
-
- it "outputs the version with build metadata", :bundler => "3" do
- bundle! "version"
- expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/)
- end
- end
-end
diff --git a/spec/bundler/commands/viz_spec.rb b/spec/bundler/commands/viz_spec.rb
deleted file mode 100644
index 029c3aca24..0000000000
--- a/spec/bundler/commands/viz_spec.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do
- let(:ruby_graphviz) do
- graphviz_glob = base_system_gems.join("cache/ruby-graphviz*")
- Pathname.glob(graphviz_glob).first
- end
-
- before do
- system_gems ruby_graphviz
- end
-
- it "graphs gems from the Gemfile" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- bundle! "viz"
- expect(out).to include("gem_graph.png")
-
- bundle! "viz", :format => "debug"
- expect(out).to eq(strip_whitespace(<<-DOT).strip)
- digraph Gemfile {
- concentrate = "true";
- normalize = "true";
- nodesep = "0.55";
- edge[ weight = "2"];
- node[ fontname = "Arial, Helvetica, SansSerif"];
- edge[ fontname = "Arial, Helvetica, SansSerif" , fontsize = "12"];
- default [style = "filled", fillcolor = "#B9B9D5", shape = "box3d", fontsize = "16", label = "default"];
- rack [style = "filled", fillcolor = "#B9B9D5", label = "rack"];
- default -> rack [constraint = "false"];
- "rack-obama" [style = "filled", fillcolor = "#B9B9D5", label = "rack-obama"];
- default -> "rack-obama" [constraint = "false"];
- "rack-obama" -> rack;
- }
- debugging bundle viz...
- DOT
- end
-
- it "graphs gems that are prereleases" do
- build_repo2 do
- build_gem "rack", "1.3.pre"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack", "= 1.3.pre"
- gem "rack-obama"
- G
-
- bundle! "viz"
- expect(out).to include("gem_graph.png")
-
- bundle! "viz", :format => :debug, :version => true
- expect(out).to eq(strip_whitespace(<<-EOS).strip)
- digraph Gemfile {
- concentrate = "true";
- normalize = "true";
- nodesep = "0.55";
- edge[ weight = "2"];
- node[ fontname = "Arial, Helvetica, SansSerif"];
- edge[ fontname = "Arial, Helvetica, SansSerif" , fontsize = "12"];
- default [style = "filled", fillcolor = "#B9B9D5", shape = "box3d", fontsize = "16", label = "default"];
- rack [style = "filled", fillcolor = "#B9B9D5", label = "rack\\n1.3.pre"];
- default -> rack [constraint = "false"];
- "rack-obama" [style = "filled", fillcolor = "#B9B9D5", label = "rack-obama\\n1.0"];
- default -> "rack-obama" [constraint = "false"];
- "rack-obama" -> rack;
- }
- debugging bundle viz...
- EOS
- end
-
- context "with another gem that has a graphviz file" do
- before do
- build_repo4 do
- build_gem "graphviz", "999" do |s|
- s.write("lib/graphviz.rb", "abort 'wrong graphviz gem loaded'")
- end
- end
-
- system_gems ruby_graphviz, "graphviz-999", :gem_repo => gem_repo4
- end
-
- it "loads the correct ruby-graphviz gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- bundle! "viz", :format => "debug"
- expect(out).to eq(strip_whitespace(<<-DOT).strip)
- digraph Gemfile {
- concentrate = "true";
- normalize = "true";
- nodesep = "0.55";
- edge[ weight = "2"];
- node[ fontname = "Arial, Helvetica, SansSerif"];
- edge[ fontname = "Arial, Helvetica, SansSerif" , fontsize = "12"];
- default [style = "filled", fillcolor = "#B9B9D5", shape = "box3d", fontsize = "16", label = "default"];
- rack [style = "filled", fillcolor = "#B9B9D5", label = "rack"];
- default -> rack [constraint = "false"];
- "rack-obama" [style = "filled", fillcolor = "#B9B9D5", label = "rack-obama"];
- default -> "rack-obama" [constraint = "false"];
- "rack-obama" -> rack;
- }
- debugging bundle viz...
- DOT
- end
- end
-
- context "--without option" do
- it "one group" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
-
- group :rails do
- gem "rails"
- end
- G
-
- bundle! "viz --without=rails"
- expect(out).to include("gem_graph.png")
- end
-
- it "two groups" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
-
- group :rack do
- gem "rack"
- end
-
- group :rails do
- gem "rails"
- end
- G
-
- bundle! "viz --without=rails:rack"
- expect(out).to include("gem_graph.png")
- end
- end
-end
diff --git a/spec/bundler/install/allow_offline_install_spec.rb b/spec/bundler/install/allow_offline_install_spec.rb
deleted file mode 100644
index 8af88b7efe..0000000000
--- a/spec/bundler/install/allow_offline_install_spec.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with :allow_offline_install" do
- before do
- bundle "config set allow_offline_install true"
- end
-
- context "with no cached data locally" do
- it "still installs" do
- install_gemfile! <<-G, :artifice => "compact_index"
- source "http://testgemserver.local"
- gem "rack-obama"
- G
- expect(the_bundle).to include_gem("rack 1.0")
- end
-
- it "still fails when the network is down" do
- install_gemfile <<-G, :artifice => "fail"
- source "http://testgemserver.local"
- gem "rack-obama"
- G
- expect(err).to include("Could not reach host testgemserver.local.")
- expect(the_bundle).to_not be_locked
- end
- end
-
- context "with cached data locally" do
- it "will install from the compact index" do
- system_gems ["rack-1.0.0"], :path => :bundle_path
-
- bundle! "config set clean false"
- install_gemfile! <<-G, :artifice => "compact_index"
- source "http://testgemserver.local"
- gem "rack-obama"
- gem "rack", "< 1.0"
- G
-
- expect(the_bundle).to include_gems("rack-obama 1.0", "rack 0.9.1")
-
- gemfile <<-G
- source "http://testgemserver.local"
- gem "rack-obama"
- G
-
- bundle! :update, :artifice => "fail", :all => true
- expect(last_command.stdboth).to include "Using the cached data for the new index because of a network error"
-
- expect(the_bundle).to include_gems("rack-obama 1.0", "rack 1.0.0")
- end
-
- def break_git_remote_ops!
- FileUtils.mkdir_p(tmp("broken_path"))
- File.open(tmp("broken_path/git"), "w", 0o755) do |f|
- f.puts strip_whitespace(<<-RUBY)
- #!/usr/bin/env ruby
- if %w(fetch --force --quiet --tags refs/heads/*:refs/heads/*).-(ARGV).empty? || %w(clone --bare --no-hardlinks --quiet).-(ARGV).empty?
- warn "git remote ops have been disabled"
- exit 1
- end
- ENV["PATH"] = ENV["PATH"].sub(/^.*?:/, "")
- exec("git", *ARGV)
- RUBY
- end
-
- old_path = ENV["PATH"]
- ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
- yield if block_given?
- ensure
- ENV["PATH"] = old_path if block_given?
- end
-
- it "will install from a cached git repo" do
- git = build_git "a", "1.0.0", :path => lib_path("a")
- update_git("a", :path => git.path, :branch => "new_branch")
- install_gemfile! <<-G
- gem "a", :git => #{git.path.to_s.dump}
- G
-
- break_git_remote_ops! { bundle! :update, :all => true }
- expect(err).to include("Using cached git data because of network errors")
- expect(the_bundle).to be_locked
-
- break_git_remote_ops! do
- install_gemfile! <<-G
- gem "a", :git => #{git.path.to_s.dump}, :branch => "new_branch"
- G
- end
- expect(err).to include("Using cached git data because of network errors")
- expect(the_bundle).to be_locked
- end
- end
-end
diff --git a/spec/bundler/install/binstubs_spec.rb b/spec/bundler/install/binstubs_spec.rb
deleted file mode 100644
index 78ee893b81..0000000000
--- a/spec/bundler/install/binstubs_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- describe "when system_bindir is set" do
- # On OS X, Gem.bindir defaults to /usr/bin, so system_bindir is useful if
- # you want to avoid sudo installs for system gems with OS X's default ruby
- it "overrides Gem.bindir" do
- expect(Pathname.new("/usr/bin")).not_to be_writable unless Process.euid == 0
- gemfile <<-G
- def Gem.bindir; "/usr/bin"; end
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- config "BUNDLE_SYSTEM_BINDIR" => system_gem_path("altbin").to_s
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(system_gem_path("altbin/rackup")).to exist
- end
- end
-
- describe "when multiple gems contain the same exe" do
- before do
- build_repo2 do
- build_gem "fake", "14" do |s|
- s.executables = "rackup"
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "fake"
- gem "rack"
- G
- end
-
- it "warns about the situation" do
- bundle! "exec rackup"
-
- expect(last_command.stderr).to include(
- "The `rackup` executable in the `fake` gem is being loaded, but it's also present in other gems (rack).\n" \
- "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
- "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
- ).or include(
- "The `rackup` executable in the `rack` gem is being loaded, but it's also present in other gems (fake).\n" \
- "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
- "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
- )
- end
- end
-end
diff --git a/spec/bundler/install/bundler_spec.rb b/spec/bundler/install/bundler_spec.rb
deleted file mode 100644
index 6ea15d13b5..0000000000
--- a/spec/bundler/install/bundler_spec.rb
+++ /dev/null
@@ -1,182 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- describe "with bundler dependencies" do
- before(:each) do
- build_repo2 do
- build_gem "rails", "3.0" do |s|
- s.add_dependency "bundler", ">= 0.9.0.pre"
- end
- build_gem "bundler", "0.9.1"
- build_gem "bundler", Bundler::VERSION
- end
- end
-
- it "are forced to the current bundler version" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0"
- G
-
- expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}"
- end
-
- it "are not added if not already present" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- expect(the_bundle).not_to include_gems "bundler #{Bundler::VERSION}"
- end
-
- it "causes a conflict if explicitly requesting a different version" do
- bundle "config set force_ruby_platform true"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0"
- gem "bundler", "0.9.2"
- G
-
- nice_error = <<-E.strip.gsub(/^ {8}/, "")
- Bundler could not find compatible versions for gem "bundler":
- In Gemfile:
- bundler (= 0.9.2)
-
- Current Bundler version:
- bundler (#{Bundler::VERSION})
- This Gemfile requires a different version of Bundler.
- Perhaps you need to update Bundler by running `gem install bundler`?
-
- Could not find gem 'bundler (= 0.9.2)' in any
- E
- expect(err).to include(nice_error)
- end
-
- it "works for gems with multiple versions in its dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "multiple_versioned_deps"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "multiple_versioned_deps"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "multiple_versioned_deps 1.0.0"
- end
-
- it "includes bundler in the bundle when it's a child dependency" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0"
- G
-
- run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError; puts 'FAIL'; end"
- expect(out).to eq("WIN")
- end
-
- it "allows gem 'bundler' when Bundler is not in the Gemfile or its dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- G
-
- run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError => e; puts e.backtrace; end"
- expect(out).to eq("WIN")
- end
-
- it "causes a conflict if child dependencies conflict" do
- bundle "config set force_ruby_platform true"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activemerchant"
- gem "rails_fail"
- G
-
- nice_error = <<-E.strip.gsub(/^ {8}/, "")
- Bundler could not find compatible versions for gem "activesupport":
- In Gemfile:
- activemerchant was resolved to 1.0, which depends on
- activesupport (>= 2.0.0)
-
- rails_fail was resolved to 1.0, which depends on
- activesupport (= 1.2.3)
- E
- expect(err).to include(nice_error)
- end
-
- it "causes a conflict if a child dependency conflicts with the Gemfile" do
- bundle "config set force_ruby_platform true"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails_fail"
- gem "activesupport", "2.3.5"
- G
-
- nice_error = <<-E.strip.gsub(/^ {8}/, "")
- Bundler could not find compatible versions for gem "activesupport":
- In Gemfile:
- activesupport (= 2.3.5)
-
- rails_fail was resolved to 1.0, which depends on
- activesupport (= 1.2.3)
- E
- expect(err).to include(nice_error)
- end
-
- it "can install dependencies with newer bundler version with system gems" do
- bundle! "config set path.system true"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0"
- G
-
- simulate_bundler_version "99999999.99.1"
-
- bundle! "check"
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- it "can install dependencies with newer bundler version with a local path" do
- bundle! "config set path .bundle"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0"
- G
-
- simulate_bundler_version "99999999.99.1"
-
- bundle! "check"
- expect(out).to include("The Gemfile's dependencies are satisfied")
- end
-
- context "with allow_bundler_dependency_conflicts set" do
- before { bundle! "config set allow_bundler_dependency_conflicts true" }
-
- it "are forced to the current bundler version with warnings when no compatible version is found" do
- build_repo4 do
- build_gem "requires_nonexistant_bundler" do |s|
- s.add_runtime_dependency "bundler", "99.99.99.99"
- end
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "requires_nonexistant_bundler"
- G
-
- expect(err).to include "requires_nonexistant_bundler (1.0) has dependency bundler (= 99.99.99.99), " \
- "which is unsatisfied by the current bundler version #{Bundler::VERSION}, so the dependency is being ignored"
-
- expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}", "requires_nonexistant_bundler 1.0"
- end
- end
- end
-end
diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb
deleted file mode 100644
index f92a531bf5..0000000000
--- a/spec/bundler/install/deploy_spec.rb
+++ /dev/null
@@ -1,429 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "install with --deployment or --frozen" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- context "with CLI flags", :bundler => "< 3" do
- it "fails without a lockfile and says that --deployment requires a lock" do
- bundle "install --deployment"
- expect(err).to include("The --deployment flag requires a Gemfile.lock")
- end
-
- it "fails without a lockfile and says that --frozen requires a lock" do
- bundle "install --frozen"
- expect(err).to include("The --frozen flag requires a Gemfile.lock")
- end
-
- it "disallows --deployment --system" do
- bundle "install --deployment --system"
- expect(err).to include("You have specified both --deployment")
- expect(err).to include("Please choose only one option")
- expect(exitstatus).to eq(15) if exitstatus
- end
-
- it "disallows --deployment --path --system" do
- bundle "install --deployment --path . --system"
- expect(err).to include("You have specified both --path")
- expect(err).to include("as well as --system")
- expect(err).to include("Please choose only one option")
- expect(exitstatus).to eq(15) if exitstatus
- end
-
- it "doesn't mess up a subsequent `bundle install` after you try to deploy without a lock" do
- bundle "install --deployment"
- bundle! :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- it "still works if you are not in the app directory and specify --gemfile" do
- bundle! "install"
- Dir.chdir tmp do
- simulate_new_machine
- bundle! :install,
- forgotten_command_line_options(:gemfile => "#{tmp}/bundled_app/Gemfile",
- :deployment => true,
- :path => "vendor/bundle")
- end
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "works if you exclude a group with a git gem" do
- build_git "foo"
- gemfile <<-G
- group :test do
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- end
- G
- bundle! :install
- bundle! :install, forgotten_command_line_options(:deployment => true, :without => "test")
- end
-
- it "works when you bundle exec bundle" do
- bundle! :install
- bundle "install --deployment"
- bundle! "exec bundle check"
- end
-
- it "works when using path gems from the same path and the version is specified" do
- build_lib "foo", :path => lib_path("nested/foo")
- build_lib "bar", :path => lib_path("nested/bar")
- gemfile <<-G
- gem "foo", "1.0", :path => "#{lib_path("nested")}"
- gem "bar", :path => "#{lib_path("nested")}"
- G
-
- bundle! :install
- bundle! :install, forgotten_command_line_options(:deployment => true)
- end
-
- it "works when there are credentials in the source URL" do
- install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
- source "http://user:pass@localgemserver.test/"
-
- gem "rack-obama", ">= 1.0"
- G
-
- bundle! :install, forgotten_command_line_options(:deployment => true).merge(:artifice => "endpoint_strict_basic_authentication")
- end
-
- it "works with sources given by a block" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}" do
- gem "rack"
- end
- G
-
- bundle! :install, forgotten_command_line_options(:deployment => true)
-
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- context "when replacing a host with the same host with credentials" do
- before do
- bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
- gemfile <<-G
- source "http://user_name:password@localgemserver.test/"
- gem "rack"
- G
-
- lockfile <<-G
- GEM
- remote: http://localgemserver.test/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{local}
-
- DEPENDENCIES
- rack
- G
-
- bundle! "config set --local deployment true"
- end
-
- it "prevents the replace by default" do
- bundle :install
-
- expect(err).to match(/The list of sources changed/)
- end
-
- context "when allow_deployment_source_credential_changes is true" do
- before { bundle! "config set allow_deployment_source_credential_changes true" }
-
- it "allows the replace" do
- bundle! :install
-
- expect(out).to match(/Bundle complete!/)
- end
- end
-
- context "when allow_deployment_source_credential_changes is false" do
- before { bundle! "config set allow_deployment_source_credential_changes false" }
-
- it "prevents the replace" do
- bundle :install
-
- expect(err).to match(/The list of sources changed/)
- end
- end
-
- context "when BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES env var is true" do
- before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "true" }
-
- it "allows the replace" do
- bundle :install
-
- expect(out).to match(/Bundle complete!/)
- end
- end
-
- context "when BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES env var is false" do
- before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "false" }
-
- it "prevents the replace" do
- bundle :install
-
- expect(err).to match(/The list of sources changed/)
- end
- end
- end
-
- describe "with an existing lockfile" do
- before do
- bundle! "install"
- end
-
- it "installs gems by default to vendor/bundle", :bundler => "< 3" do
- bundle! "install --deployment"
- expect(out).to include("vendor/bundle")
- end
-
- it "installs gems to custom path if specified", :bundler => "< 3" do
- bundle! "install --path vendor/bundle2 --deployment"
- expect(out).to include("vendor/bundle2")
- end
-
- it "works with the --deployment flag if you didn't change anything", :bundler => "< 3" do
- bundle! "install --deployment"
- end
-
- it "works with the --frozen flag if you didn't change anything", :bundler => "< 3" do
- bundle! "install --frozen"
- end
-
- it "works with BUNDLE_FROZEN if you didn't change anything" do
- bundle! :install, :env => { "BUNDLE_FROZEN" => "true" }
- end
-
- it "explodes with the --deployment flag if you make a change and don't check in the lockfile" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- bundle :install, forgotten_command_line_options(:deployment => true)
- expect(err).to include("deployment mode")
- expect(err).to include("You have added to the Gemfile")
- expect(err).to include("* rack-obama")
- expect(err).not_to include("You have deleted from the Gemfile")
- expect(err).not_to include("You have changed in the Gemfile")
- end
-
- it "works if a path gem is missing but is in a without group" do
- build_lib "path_gem"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rake"
- gem "path_gem", :path => "#{lib_path("path_gem-1.0")}", :group => :development
- G
- expect(the_bundle).to include_gems "path_gem 1.0"
- FileUtils.rm_r lib_path("path_gem-1.0")
-
- bundle! :install, forgotten_command_line_options(:path => ".bundle", :without => "development", :deployment => true).merge(:env => { "DEBUG" => "1" })
- run! "puts :WIN"
- expect(out).to eq("WIN")
- end
-
- it "explodes if a path gem is missing" do
- build_lib "path_gem"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rake"
- gem "path_gem", :path => "#{lib_path("path_gem-1.0")}", :group => :development
- G
- expect(the_bundle).to include_gems "path_gem 1.0"
- FileUtils.rm_r lib_path("path_gem-1.0")
-
- bundle :install, forgotten_command_line_options(:path => ".bundle", :deployment => true)
- expect(err).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.")
- end
-
- it "can have --frozen set via an environment variable", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- ENV["BUNDLE_FROZEN"] = "1"
- bundle "install"
- expect(err).to include("deployment mode")
- expect(err).to include("You have added to the Gemfile")
- expect(err).to include("* rack-obama")
- expect(err).not_to include("You have deleted from the Gemfile")
- expect(err).not_to include("You have changed in the Gemfile")
- end
-
- it "can have --deployment set via an environment variable" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- ENV["BUNDLE_DEPLOYMENT"] = "true"
- bundle "install"
- expect(err).to include("deployment mode")
- expect(err).to include("You have added to the Gemfile")
- expect(err).to include("* rack-obama")
- expect(err).not_to include("You have deleted from the Gemfile")
- expect(err).not_to include("You have changed in the Gemfile")
- end
-
- it "installs gems by default to vendor/bundle when `--deployment` is set via an environment variable", :bundler => "< 3" do
- ENV["BUNDLE_DEPLOYMENT"] = "true"
- bundle "install"
- expect(out).to include("vendor/bundle")
- end
-
- it "installs gems to custom path when deployment mode is set via an environment variable ", :bundler => "< 3" do
- ENV["BUNDLE_DEPLOYMENT"] = "true"
- ENV["BUNDLE_PATH"] = "vendor/bundle2"
- bundle "install"
- expect(out).to include("vendor/bundle2")
- end
-
- it "can have --frozen set to false via an environment variable" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- ENV["BUNDLE_FROZEN"] = "false"
- ENV["BUNDLE_DEPLOYMENT"] = "false"
- bundle "install"
- expect(out).not_to include("deployment mode")
- expect(out).not_to include("You have added to the Gemfile")
- expect(out).not_to include("* rack-obama")
- end
-
- it "explodes if you remove a gem and don't check in the lockfile" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
- G
-
- bundle :install, forgotten_command_line_options(:deployment => true)
- expect(err).to include("deployment mode")
- expect(err).to include("You have added to the Gemfile:\n* activesupport\n\n")
- expect(err).to include("You have deleted from the Gemfile:\n* rack")
- expect(err).not_to include("You have changed in the Gemfile")
- end
-
- it "explodes if you add a source" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "git://hubz.com"
- G
-
- bundle :install, forgotten_command_line_options(:deployment => true)
- expect(err).to include("deployment mode")
- expect(err).to include("You have added to the Gemfile:\n* source: git://hubz.com (at master)")
- expect(err).not_to include("You have changed in the Gemfile")
- end
-
- it "explodes if you unpin a source" do
- build_git "rack"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-1.0")}"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle :install, forgotten_command_line_options(:deployment => true)
- expect(err).to include("deployment mode")
- expect(err).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")} (at master@#{revision_for(lib_path("rack-1.0"))[0..6]}")
- expect(err).not_to include("You have added to the Gemfile")
- expect(err).not_to include("You have changed in the Gemfile")
- end
-
- it "explodes if you unpin a source, leaving it pinned somewhere else" do
- build_lib "foo", :path => lib_path("rack/foo")
- build_git "rack", :path => lib_path("rack")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack")}"
- gem "foo", :git => "#{lib_path("rack")}"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "foo", :git => "#{lib_path("rack")}"
- G
-
- bundle :install, forgotten_command_line_options(:deployment => true)
- expect(err).to include("deployment mode")
- expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")} (at master@#{revision_for(lib_path("rack"))[0..6]})`")
- expect(err).not_to include("You have added to the Gemfile")
- expect(err).not_to include("You have deleted from the Gemfile")
- end
-
- it "remembers that the bundle is frozen at runtime" do
- bundle! :lock
-
- bundle! "config set --local deployment true"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- gem "rack-obama"
- G
-
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(err).to include strip_whitespace(<<-E).strip
-The dependencies in your gemfile changed
-
-You have added to the Gemfile:
-* rack (= 1.0.0)
-* rack-obama
-
-You have deleted from the Gemfile:
-* rack
- E
- end
- end
-
- context "with path in Gemfile and packed" do
- it "works fine after bundle package and bundle install --local" do
- build_lib "foo", :path => lib_path("foo")
- install_gemfile! <<-G
- gem "foo", :path => "#{lib_path("foo")}"
- G
-
- bundle! :install
- expect(the_bundle).to include_gems "foo 1.0"
-
- bundle "config set cache_all true"
- bundle! :cache
- expect(bundled_app("vendor/cache/foo")).to be_directory
-
- bundle! "install --local"
- expect(out).to include("Updating files in vendor/cache")
-
- simulate_new_machine
- bundle! "config set --local deployment true"
- bundle! "install --verbose"
- expect(out).not_to include("You are trying to install in deployment mode after changing your Gemfile")
- expect(out).not_to include("You have added to the Gemfile")
- expect(out).not_to include("You have deleted from the Gemfile")
- expect(out).to include("vendor/cache/foo")
- expect(the_bundle).to include_gems "foo 1.0"
- end
- end
-end
diff --git a/spec/bundler/install/failure_spec.rb b/spec/bundler/install/failure_spec.rb
deleted file mode 100644
index 57ffafd588..0000000000
--- a/spec/bundler/install/failure_spec.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- context "installing a gem fails" do
- it "prints out why that gem was being installed" do
- build_repo2 do
- build_gem "activesupport", "2.3.2" do |s|
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- abort "make installing activesupport-2.3.2 fail"
- end
- RUBY
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails"
- G
- expect(err).to end_with(<<-M.strip)
-An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
-Make sure that `gem install activesupport -v '2.3.2' --source '#{file_uri_for(gem_repo2)}/'` succeeds before bundling.
-
-In Gemfile:
- rails was resolved to 2.3.2, which depends on
- actionmailer was resolved to 2.3.2, which depends on
- activesupport
- M
- end
-
- context "when installing a git gem" do
- it "does not tell the user to run 'gem install'" do
- build_git "activesupport", "2.3.2", :path => lib_path("activesupport") do |s|
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- abort "make installing activesupport-2.3.2 fail"
- end
- RUBY
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- gem "activesupport", :git => "#{lib_path("activesupport")}"
- G
-
- expect(err).to end_with(<<-M.strip)
-An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
-
-In Gemfile:
- rails was resolved to 2.3.2, which depends on
- actionmailer was resolved to 2.3.2, which depends on
- activesupport
- M
- end
- end
-
- context "when installing a gem using a git block" do
- it "does not tell the user to run 'gem install'" do
- build_git "activesupport", "2.3.2", :path => lib_path("activesupport") do |s|
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- abort "make installing activesupport-2.3.2 fail"
- end
- RUBY
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- git "#{lib_path("activesupport")}" do
- gem "activesupport"
- end
- G
-
- expect(err).to end_with(<<-M.strip)
-An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
-
-
-In Gemfile:
- rails was resolved to 2.3.2, which depends on
- actionmailer was resolved to 2.3.2, which depends on
- activesupport
- M
- end
- end
-
- it "prints out the hint for the remote source when available" do
- build_repo2 do
- build_gem "activesupport", "2.3.2" do |s|
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- abort "make installing activesupport-2.3.2 fail"
- end
- RUBY
- end
- end
-
- build_repo4 do
- build_gem "a"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- source "#{file_uri_for(gem_repo2)}" do
- gem "rails"
- end
- G
- expect(err).to end_with(<<-M.strip)
-An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
-Make sure that `gem install activesupport -v '2.3.2' --source '#{file_uri_for(gem_repo2)}/'` succeeds before bundling.
-
-In Gemfile:
- rails was resolved to 2.3.2, which depends on
- actionmailer was resolved to 2.3.2, which depends on
- activesupport
- M
- end
-
- context "because the downloaded .gem was invalid" do
- before do
- build_repo4 do
- build_gem "a"
- end
-
- gem_repo4("gems", "a-1.0.gem").open("w") {|f| f << "<html></html>" }
- end
-
- it "removes the downloaded .gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "a"
- G
-
- expect(default_bundle_path("cache", "a-1.0.gem")).not_to exist
- end
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/eval_gemfile_spec.rb b/spec/bundler/install/gemfile/eval_gemfile_spec.rb
deleted file mode 100644
index 7df94aaff5..0000000000
--- a/spec/bundler/install/gemfile/eval_gemfile_spec.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with gemfile that uses eval_gemfile" do
- before do
- build_lib("gunks", :path => bundled_app.join("gems/gunks")) do |s|
- s.name = "gunks"
- s.version = "0.0.1"
- end
- end
-
- context "eval-ed Gemfile points to an internal gemspec" do
- before do
- create_file "Gemfile-other", <<-G
- gemspec :path => 'gems/gunks'
- G
- end
-
- it "installs the gemspec specified gem" do
- install_gemfile <<-G
- eval_gemfile 'Gemfile-other'
- G
- expect(out).to include("Resolving dependencies")
- expect(out).to include("Bundle complete")
-
- expect(the_bundle).to include_gem "gunks 0.0.1", :source => "path@#{bundled_app("gems", "gunks")}"
- end
- end
-
- context "eval-ed Gemfile has relative-path gems" do
- before do
- build_lib("a", :path => "gems/a")
- create_file "nested/Gemfile-nested", <<-G
- gem "a", :path => "../gems/a"
- G
-
- gemfile <<-G
- eval_gemfile "nested/Gemfile-nested"
- G
- end
-
- it "installs the path gem" do
- bundle! :install
- expect(the_bundle).to include_gem("a 1.0")
- end
-
- # Make sure that we are properly comparing path based gems between the
- # parsed lockfile and the evaluated gemfile.
- it "bundles with --deployment" do
- bundle! :install
- bundle! :install, forgotten_command_line_options(:deployment => true)
- end
- end
-
- context "Gemfile uses gemspec paths after eval-ing a Gemfile" do
- before { create_file "other/Gemfile-other" }
-
- it "installs the gemspec specified gem" do
- install_gemfile <<-G
- eval_gemfile 'other/Gemfile-other'
- gemspec :path => 'gems/gunks'
- G
- expect(out).to include("Resolving dependencies")
- expect(out).to include("Bundle complete")
-
- expect(the_bundle).to include_gem "gunks 0.0.1", :source => "path@#{bundled_app("gems", "gunks")}"
- end
- end
-
- context "eval-ed Gemfile references other gemfiles" do
- it "works with relative paths" do
- create_file "other/Gemfile-other", "gem 'rack'"
- create_file "other/Gemfile", "eval_gemfile 'Gemfile-other'"
- create_file "Gemfile-alt", <<-G
- source "#{file_uri_for(gem_repo1)}"
- eval_gemfile "other/Gemfile"
- G
- install_gemfile! "eval_gemfile File.expand_path('Gemfile-alt')"
-
- expect(the_bundle).to include_gem "rack 1.0.0"
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb
deleted file mode 100644
index 26a6235166..0000000000
--- a/spec/bundler/install/gemfile/gemspec_spec.rb
+++ /dev/null
@@ -1,583 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install from an existing gemspec" do
- before(:each) do
- build_repo2 do
- build_gem "bar"
- build_gem "bar-dev"
- end
- end
-
- it "should install runtime and development dependencies" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("Gemfile", "source :rubygems\ngemspec")
- s.add_dependency "bar", "=1.0.0"
- s.add_development_dependency "bar-dev", "=1.0.0"
- end
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gemspec :path => '#{tmp.join("foo")}'
- G
-
- expect(the_bundle).to include_gems "bar 1.0.0"
- expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :development
- end
-
- it "that is hidden should install runtime and development dependencies" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("Gemfile", "source :rubygems\ngemspec")
- s.add_dependency "bar", "=1.0.0"
- s.add_development_dependency "bar-dev", "=1.0.0"
- end
- FileUtils.mv tmp.join("foo", "foo.gemspec"), tmp.join("foo", ".gemspec")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gemspec :path => '#{tmp.join("foo")}'
- G
-
- expect(the_bundle).to include_gems "bar 1.0.0"
- expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :development
- end
-
- it "should handle a list of requirements" do
- update_repo2 do
- build_gem "baz", "1.0"
- build_gem "baz", "1.1"
- end
-
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("Gemfile", "source :rubygems\ngemspec")
- s.add_dependency "baz", ">= 1.0", "< 1.1"
- end
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gemspec :path => '#{tmp.join("foo")}'
- G
-
- expect(the_bundle).to include_gems "baz 1.0"
- end
-
- it "should raise if there are no gemspecs available" do
- build_lib("foo", :path => tmp.join("foo"), :gemspec => false)
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo2)}"
- gemspec :path => '#{tmp.join("foo")}'
- G
- expect(err).to match(/There are no gemspecs at #{tmp.join('foo')}/)
- end
-
- it "should raise if there are too many gemspecs available" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("foo2.gemspec", build_spec("foo", "4.0").first.to_ruby)
- end
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo2)}"
- gemspec :path => '#{tmp.join("foo")}'
- G
- expect(err).to match(/There are multiple gemspecs at #{tmp.join('foo')}/)
- end
-
- it "should pick a specific gemspec" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("foo2.gemspec", "")
- s.add_dependency "bar", "=1.0.0"
- s.add_development_dependency "bar-dev", "=1.0.0"
- end
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo2)}"
- gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
- G
-
- expect(the_bundle).to include_gems "bar 1.0.0"
- expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :development
- end
-
- it "should use a specific group for development dependencies" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("foo2.gemspec", "")
- s.add_dependency "bar", "=1.0.0"
- s.add_development_dependency "bar-dev", "=1.0.0"
- end
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo2)}"
- gemspec :path => '#{tmp.join("foo")}', :name => 'foo', :development_group => :dev
- G
-
- expect(the_bundle).to include_gems "bar 1.0.0"
- expect(the_bundle).not_to include_gems "bar-dev 1.0.0", :groups => :development
- expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :dev
- end
-
- it "should match a lockfile even if the gemspec defines development dependencies" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("Gemfile", "source '#{file_uri_for(gem_repo1)}'\ngemspec")
- s.add_dependency "actionpack", "=2.3.2"
- s.add_development_dependency "rake", "=12.3.2"
- end
-
- Dir.chdir(tmp.join("foo")) do
- bundle "install"
- # This should really be able to rely on $stderr, but, it's not written
- # right, so we can't. In fact, this is a bug negation test, and so it'll
- # ghost pass in future, and will only catch a regression if the message
- # doesn't change. Exit codes should be used correctly (they can be more
- # than just 0 and 1).
- output = bundle("install --deployment")
- expect(output).not_to match(/You have added to the Gemfile/)
- expect(output).not_to match(/You have deleted from the Gemfile/)
- expect(output).not_to match(/install in deployment mode after changing/)
- end
- end
-
- it "should match a lockfile without needing to re-resolve" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.add_dependency "rack"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec :path => '#{tmp.join("foo")}'
- G
-
- bundle! "install", :verbose => true
-
- message = "Found no changes, using resolution from the lockfile"
- expect(out.scan(message).size).to eq(1)
- end
-
- it "should match a lockfile without needing to re-resolve with development dependencies" do
- simulate_platform java
-
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.add_dependency "rack"
- s.add_development_dependency "thin"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec :path => '#{tmp.join("foo")}'
- G
-
- bundle! "install", :verbose => true
-
- message = "Found no changes, using resolution from the lockfile"
- expect(out.scan(message).size).to eq(1)
- end
-
- it "should match a lockfile on non-ruby platforms with a transitive platform dependency" do
- simulate_platform java
- simulate_ruby_engine "jruby"
-
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.add_dependency "platform_specific"
- end
-
- system_gems "platform_specific-1.0-java", :path => :bundle_path, :keep_path => true
-
- install_gemfile! <<-G
- gemspec :path => '#{tmp.join("foo")}'
- G
-
- bundle! "update --bundler", :verbose => true
- expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 JAVA"
- end
-
- it "should evaluate the gemspec in its directory" do
- build_lib("foo", :path => tmp.join("foo"))
- File.open(tmp.join("foo/foo.gemspec"), "w") do |s|
- s.write "raise 'ahh' unless Dir.pwd == '#{tmp.join("foo")}'"
- end
-
- install_gemfile <<-G
- gemspec :path => '#{tmp.join("foo")}'
- G
- expect(last_command.stdboth).not_to include("ahh")
- end
-
- it "allows the gemspec to activate other gems" do
- ENV["BUNDLE_PATH__SYSTEM"] = "true"
- # see https://github.com/bundler/bundler/issues/5409
- #
- # issue was caused by rubygems having an unresolved gem during a require,
- # so emulate that
- system_gems %w[rack-1.0.0 rack-0.9.1 rack-obama-1.0]
-
- build_lib("foo", :path => bundled_app)
- gemspec = bundled_app("foo.gemspec").read
- bundled_app("foo.gemspec").open("w") do |f|
- f.write "#{gemspec.strip}.tap { gem 'rack-obama'; require 'rack/obama' }"
- end
-
- install_gemfile! <<-G
- gemspec
- G
-
- expect(the_bundle).to include_gem "foo 1.0"
- end
-
- it "allows conflicts" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.version = "1.0.0"
- s.add_dependency "bar", "= 1.0.0"
- end
- build_gem "deps", :to_bundle => true do |s|
- s.add_dependency "foo", "= 0.0.1"
- end
- build_gem "foo", "0.0.1", :to_bundle => true
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "deps"
- gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
- G
-
- expect(the_bundle).to include_gems "foo 1.0.0"
- end
-
- it "does not break Gem.finish_resolve with conflicts" do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.version = "1.0.0"
- s.add_dependency "bar", "= 1.0.0"
- end
- update_repo2 do
- build_gem "deps" do |s|
- s.add_dependency "foo", "= 0.0.1"
- end
- build_gem "foo", "0.0.1"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "deps"
- gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
- G
-
- expect(the_bundle).to include_gems "foo 1.0.0"
-
- run! "Gem.finish_resolve; puts 'WIN'"
- expect(out).to eq("WIN")
- end
-
- it "works with only_update_to_newer_versions" do
- build_lib "omg", "2.0", :path => lib_path("omg")
-
- install_gemfile <<-G
- gemspec :path => "#{lib_path("omg")}"
- G
-
- build_lib "omg", "1.0", :path => lib_path("omg")
-
- bundle! :install, :env => { "BUNDLE_BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS" => "true" }
-
- expect(the_bundle).to include_gems "omg 1.0"
- end
-
- context "in deployment mode" do
- context "when the lockfile was not updated after a change to the gemspec's dependencies" do
- it "reports that installation failed" do
- build_lib "cocoapods", :path => bundled_app do |s|
- s.add_dependency "activesupport", ">= 1"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec
- G
-
- expect(the_bundle).to include_gems("cocoapods 1.0", "activesupport 2.3.5")
-
- build_lib "cocoapods", :path => bundled_app do |s|
- s.add_dependency "activesupport", ">= 1.0.1"
- end
-
- bundle :install, forgotten_command_line_options(:deployment => true)
-
- expect(err).to include("changed")
- end
- end
- end
-
- context "when child gemspecs conflict with a released gemspec" do
- before do
- # build the "parent" gem that depends on another gem in the same repo
- build_lib "source_conflict", :path => bundled_app do |s|
- s.add_dependency "rack_middleware"
- end
-
- # build the "child" gem that is the same version as a released gem, but
- # has completely different and conflicting dependency requirements
- build_lib "rack_middleware", "1.0", :path => bundled_app("rack_middleware") do |s|
- s.add_dependency "rack", "1.0" # anything other than 0.9.1
- end
- end
-
- it "should install the child gemspec's deps" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec
- G
-
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- context "with a lockfile and some missing dependencies" do
- let(:source_uri) { "http://localgemserver.test" }
-
- context "previously bundled for Ruby" do
- let(:platform) { "ruby" }
-
- before do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.add_dependency "rack", "=1.0.0"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- gemspec :path => "../foo"
- G
-
- lockfile <<-L
- PATH
- remote: ../foo
- specs:
- foo (1.0)
- rack (= 1.0.0)
-
- GEM
- remote: #{source_uri}
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-
- context "using JRuby with explicit platform" do
- let(:platform) { "java" }
-
- before do
- create_file(
- tmp.join("foo", "foo-#{platform}.gemspec"),
- build_spec("foo", "1.0", platform) do
- dep "rack", "=1.0.0"
- @spec.authors = "authors"
- @spec.summary = "summary"
- end.first.to_ruby
- )
- end
-
- it "should install" do
- simulate_ruby_engine "jruby" do
- simulate_platform "java" do
- results = bundle "install", :artifice => "endpoint"
- expect(results).to include("Installing rack 1.0.0")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
- end
-
- context "using JRuby" do
- let(:platform) { "java" }
-
- it "should install" do
- simulate_ruby_engine "jruby" do
- simulate_platform "java" do
- results = bundle "install", :artifice => "endpoint"
- expect(results).to include("Installing rack 1.0.0")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
- end
-
- context "using Windows" do
- it "should install" do
- simulate_windows do
- results = bundle "install", :artifice => "endpoint"
- expect(results).to include("Installing rack 1.0.0")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
- end
-
- context "bundled for ruby and jruby" do
- let(:platform_specific_type) { :runtime }
- let(:dependency) { "platform_specific" }
- before do
- build_repo2 do
- build_gem "indirect_platform_specific" do |s|
- s.add_runtime_dependency "platform_specific"
- end
- end
-
- build_lib "foo", :path => "." do |s|
- if platform_specific_type == :runtime
- s.add_runtime_dependency dependency
- elsif platform_specific_type == :development
- s.add_development_dependency dependency
- else
- raise "wrong dependency type #{platform_specific_type}, can only be :development or :runtime"
- end
- end
-
- %w[ruby jruby].each do |platform|
- simulate_platform(platform) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gemspec
- G
- end
- end
- end
-
- context "on ruby" do
- before do
- simulate_platform("ruby")
- bundle :install
- end
-
- context "as a runtime dependency" do
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq strip_whitespace(<<-L)
- PATH
- remote: .
- specs:
- foo (1.0)
- platform_specific
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "as a development dependency" do
- let(:platform_specific_type) { :development }
-
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq strip_whitespace(<<-L)
- PATH
- remote: .
- specs:
- foo (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
- platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "with an indirect platform-specific development dependency" do
- let(:platform_specific_type) { :development }
- let(:dependency) { "indirect_platform_specific" }
-
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq strip_whitespace(<<-L)
- PATH
- remote: .
- specs:
- foo (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- indirect_platform_specific (1.0)
- platform_specific
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
- indirect_platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
- end
- end
- end
-
- context "with multiple platforms" do
- before do
- build_lib("foo", :path => tmp.join("foo")) do |s|
- s.version = "1.0.0"
- s.add_development_dependency "rack"
- s.write "foo-universal-java.gemspec", build_spec("foo", "1.0.0", "universal-java") {|sj| sj.runtime "rack", "1.0.0" }.first.to_ruby
- end
- end
-
- it "installs the ruby platform gemspec" do
- simulate_platform "ruby"
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
- G
-
- expect(the_bundle).to include_gems "foo 1.0.0", "rack 1.0.0"
- end
-
- it "installs the ruby platform gemspec and skips dev deps with --without development" do
- simulate_platform "ruby"
-
- install_gemfile! <<-G, forgotten_command_line_options(:without => "development")
- source "#{file_uri_for(gem_repo1)}"
- gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
- G
-
- expect(the_bundle).to include_gem "foo 1.0.0"
- expect(the_bundle).not_to include_gem "rack"
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
deleted file mode 100644
index 00f8e96625..0000000000
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ /dev/null
@@ -1,1455 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with git sources" do
- describe "when floating on master" do
- before :each do
- build_git "foo" do |s|
- s.executables = "foobar"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- git "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
- end
-
- it "fetches gems" do
- expect(the_bundle).to include_gems("foo 1.0")
-
- run <<-RUBY
- require 'foo'
- puts "WIN" unless defined?(FOO_PREV_REF)
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "caches the git repo", :bundler => "< 3" do
- expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1
- end
-
- it "caches the git repo globally" do
- simulate_new_machine
- bundle! "config set global_gem_cache true"
- bundle! :install
- expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes :size => 1
- end
-
- it "caches the evaluated gemspec" do
- git = update_git "foo" do |s|
- s.executables = ["foobar"] # we added this the first time, so keep it now
- s.files = ["bin/foobar"] # updating git nukes the files list
- foospec = s.to_ruby.gsub(/s\.files.*/, 's.files = `git ls-files -z`.split("\x0")')
- s.write "foo.gemspec", foospec
- end
-
- bundle "update foo"
-
- sha = git.ref_for("master", 11)
- spec_file = default_bundle_path.join("bundler/gems/foo-1.0-#{sha}/foo.gemspec").to_s
- ruby_code = Gem::Specification.load(spec_file).to_ruby
- file_code = File.read(spec_file)
- expect(file_code).to eq(ruby_code)
- end
-
- it "does not update the git source implicitly" do
- update_git "foo"
-
- in_app_root2 do
- install_gemfile bundled_app2("Gemfile"), <<-G
- git "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
- end
-
- in_app_root do
- run <<-RUBY
- require 'foo'
- puts "fail" if defined?(FOO_PREV_REF)
- RUBY
-
- expect(out).to be_empty
- end
- end
-
- it "sets up git gem executables on the path" do
- bundle "exec foobar"
- expect(out).to eq("1.0")
- end
-
- it "complains if pinned specs don't exist in the git repo" do
- build_git "foo"
-
- install_gemfile <<-G
- gem "foo", "1.1", :git => "#{lib_path("foo-1.0")}"
- G
-
- expect(err).to include("The source contains 'foo' at: 1.0")
- end
-
- it "complains with version and platform if pinned specs don't exist in the git repo" do
- simulate_platform "java"
-
- build_git "only_java" do |s|
- s.platform = "java"
- end
-
- install_gemfile <<-G
- platforms :jruby do
- gem "only_java", "1.2", :git => "#{lib_path("only_java-1.0-java")}"
- end
- G
-
- expect(err).to include("The source contains 'only_java' at: 1.0 java")
- end
-
- it "complains with multiple versions and platforms if pinned specs don't exist in the git repo" do
- simulate_platform "java"
-
- build_git "only_java", "1.0" do |s|
- s.platform = "java"
- end
-
- build_git "only_java", "1.1" do |s|
- s.platform = "java"
- s.write "only_java1-0.gemspec", File.read("#{lib_path("only_java-1.0-java")}/only_java.gemspec")
- end
-
- install_gemfile <<-G
- platforms :jruby do
- gem "only_java", "1.2", :git => "#{lib_path("only_java-1.1-java")}"
- end
- G
-
- expect(err).to include("The source contains 'only_java' at: 1.0 java, 1.1 java")
- end
-
- it "still works after moving the application directory" do
- bundle "install --path vendor/bundle"
- FileUtils.mv bundled_app, tmp("bundled_app.bck")
-
- Dir.chdir tmp("bundled_app.bck")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "can still install after moving the application directory" do
- bundle "install --path vendor/bundle"
- FileUtils.mv bundled_app, tmp("bundled_app.bck")
-
- update_git "foo", "1.1", :path => lib_path("foo-1.0")
-
- Dir.chdir tmp("bundled_app.bck")
- gemfile tmp("bundled_app.bck/Gemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- git "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
-
- gem "rack", "1.0"
- G
-
- bundle "update foo"
-
- expect(the_bundle).to include_gems "foo 1.1", "rack 1.0"
- end
- end
-
- describe "with an empty git block" do
- before do
- build_git "foo"
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- git "#{lib_path("foo-1.0")}" do
- # this page left intentionally blank
- end
- G
- end
-
- it "does not explode" do
- bundle "install"
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when specifying a revision" do
- before(:each) do
- build_git "foo"
- @revision = revision_for(lib_path("foo-1.0"))
- update_git "foo"
- end
-
- it "works" do
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}", :ref => "#{@revision}" do
- gem "foo"
- end
- G
-
- run <<-RUBY
- require 'foo'
- puts "WIN" unless defined?(FOO_PREV_REF)
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "works when the revision is a symbol" do
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}", :ref => #{@revision.to_sym.inspect} do
- gem "foo"
- end
- G
- expect(err).to be_empty
-
- run <<-RUBY
- require 'foo'
- puts "WIN" unless defined?(FOO_PREV_REF)
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "works when the revision is a non-head ref" do
- # want to ensure we don't fallback to master
- update_git "foo", :path => lib_path("foo-1.0") do |s|
- s.write("lib/foo.rb", "raise 'FAIL'")
- end
-
- Dir.chdir(lib_path("foo-1.0")) do
- `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1`
- end
-
- # want to ensure we don't fallback to HEAD
- update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s|
- s.write("lib/foo.rb", "raise 'FAIL'")
- end
-
- install_gemfile! <<-G
- git "#{lib_path("foo-1.0")}", :ref => "refs/bundler/1" do
- gem "foo"
- end
- G
- expect(err).to be_empty
-
- run! <<-RUBY
- require 'foo'
- puts "WIN" if defined?(FOO)
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "works when the revision is a non-head ref and it was previously downloaded" do
- install_gemfile! <<-G
- git "#{lib_path("foo-1.0")}" do
- gem "foo"
- end
- G
-
- # want to ensure we don't fallback to master
- update_git "foo", :path => lib_path("foo-1.0") do |s|
- s.write("lib/foo.rb", "raise 'FAIL'")
- end
-
- Dir.chdir(lib_path("foo-1.0")) do
- `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1`
- end
-
- # want to ensure we don't fallback to HEAD
- update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s|
- s.write("lib/foo.rb", "raise 'FAIL'")
- end
-
- install_gemfile! <<-G
- git "#{lib_path("foo-1.0")}", :ref => "refs/bundler/1" do
- gem "foo"
- end
- G
- expect(err).to be_empty
-
- run! <<-RUBY
- require 'foo'
- puts "WIN" if defined?(FOO)
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "does not download random non-head refs" do
- Dir.chdir(lib_path("foo-1.0")) do
- sys_exec!('git update-ref -m "Bundler Spec!" refs/bundler/1 master~1')
- end
-
- bundle! "config set global_gem_cache true"
-
- install_gemfile! <<-G
- git "#{lib_path("foo-1.0")}" do
- gem "foo"
- end
- G
-
- # ensure we also git fetch after cloning
- bundle! :update, :all => true
-
- Dir.chdir(Dir[home(".bundle/cache/git/foo-*")].first) do
- sys_exec("git ls-remote .")
- end
-
- expect(out).not_to include("refs/bundler/1")
- end
- end
-
- describe "when specifying a branch" do
- let(:branch) { "branch" }
- let(:repo) { build_git("foo").path }
- before(:each) do
- update_git("foo", :path => repo, :branch => branch)
- end
-
- it "works" do
- install_gemfile <<-G
- git "#{repo}", :branch => #{branch.dump} do
- gem "foo"
- end
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- context "when the branch starts with a `#`" do
- let(:branch) { "#149/redirect-url-fragment" }
- it "works" do
- install_gemfile <<-G
- git "#{repo}", :branch => #{branch.dump} do
- gem "foo"
- end
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
- end
-
- context "when the branch includes quotes" do
- let(:branch) { %('") }
- it "works" do
- install_gemfile <<-G
- git "#{repo}", :branch => #{branch.dump} do
- gem "foo"
- end
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
- end
- end
-
- describe "when specifying a tag" do
- let(:tag) { "tag" }
- let(:repo) { build_git("foo").path }
- before(:each) do
- update_git("foo", :path => repo, :tag => tag)
- end
-
- it "works" do
- install_gemfile <<-G
- git "#{repo}", :tag => #{tag.dump} do
- gem "foo"
- end
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- context "when the tag starts with a `#`" do
- let(:tag) { "#149/redirect-url-fragment" }
- it "works" do
- install_gemfile <<-G
- git "#{repo}", :tag => #{tag.dump} do
- gem "foo"
- end
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
- end
-
- context "when the tag includes quotes" do
- let(:tag) { %('") }
- it "works" do
- install_gemfile <<-G
- git "#{repo}", :tag => #{tag.dump} do
- gem "foo"
- end
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
- end
- end
-
- describe "when specifying local override" do
- it "uses the local repository instead of checking a new one out" do
- # We don't generate it because we actually don't need it
- # build_git "rack", "0.8"
-
- build_git "rack", "0.8", :path => lib_path("local-rack") do |s|
- s.write "lib/rack.rb", "puts :LOCAL"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle! %(config set local.rack #{lib_path("local-rack")})
- bundle! :install
-
- run "require 'rack'"
- expect(out).to eq("LOCAL")
- end
-
- it "chooses the local repository on runtime" do
- build_git "rack", "0.8"
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- update_git "rack", "0.8", :path => lib_path("local-rack") do |s|
- s.write "lib/rack.rb", "puts :LOCAL"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- run "require 'rack'"
- expect(out).to eq("LOCAL")
- end
-
- it "unlocks the source when the dependencies have changed while switching to the local" do
- build_git "rack", "0.8"
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- update_git "rack", "0.8", :path => lib_path("local-rack") do |s|
- s.write "rack.gemspec", build_spec("rack", "0.8") { runtime "rspec", "> 0" }.first.to_ruby
- s.write "lib/rack.rb", "puts :LOCAL"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle! %(config set local.rack #{lib_path("local-rack")})
- bundle! :install
- run! "require 'rack'"
- expect(out).to eq("LOCAL")
- end
-
- it "updates specs on runtime" do
- system_gems "nokogiri-1.4.2"
-
- build_git "rack", "0.8"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- lockfile0 = File.read(bundled_app("Gemfile.lock"))
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
- update_git "rack", "0.8", :path => lib_path("local-rack") do |s|
- s.add_dependency "nokogiri", "1.4.2"
- end
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- run "require 'rack'"
-
- lockfile1 = File.read(bundled_app("Gemfile.lock"))
- expect(lockfile1).not_to eq(lockfile0)
- end
-
- it "updates ref on install" do
- build_git "rack", "0.8"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- lockfile0 = File.read(bundled_app("Gemfile.lock"))
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
- update_git "rack", "0.8", :path => lib_path("local-rack")
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle :install
-
- lockfile1 = File.read(bundled_app("Gemfile.lock"))
- expect(lockfile1).not_to eq(lockfile0)
- end
-
- it "explodes and gives correct solution if given path does not exist on install" do
- build_git "rack", "0.8"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle :install
- expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
-
- solution = "config unset local.rack"
- expect(err).to match(/Run `bundle #{solution}` to remove the local override/)
-
- bundle solution
- bundle :install
-
- expect(err).to be_empty
- end
-
- it "explodes and gives correct solution if branch is not given on install" do
- build_git "rack", "0.8"
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle :install
- expect(err).to match(/Cannot use local override for rack-0.8 at #{Regexp.escape(lib_path('local-rack').to_s)} because :branch is not specified in Gemfile/)
-
- solution = "config unset local.rack"
- expect(err).to match(/Specify a branch or run `bundle #{solution}` to remove the local override/)
-
- bundle solution
- bundle :install
-
- expect(err).to be_empty
- end
-
- it "does not explode if disable_local_branch_check is given" do
- build_git "rack", "0.8"
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle %(config set disable_local_branch_check true)
- bundle :install
- expect(out).to match(/Bundle complete!/)
- end
-
- it "explodes on different branches on install" do
- build_git "rack", "0.8"
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- update_git "rack", "0.8", :path => lib_path("local-rack"), :branch => "another" do |s|
- s.write "lib/rack.rb", "puts :LOCAL"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle :install
- expect(err).to match(/is using branch another but Gemfile specifies master/)
- end
-
- it "explodes on invalid revision on install" do
- build_git "rack", "0.8"
-
- build_git "rack", "0.8", :path => lib_path("local-rack") do |s|
- s.write "lib/rack.rb", "puts :LOCAL"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle :install
- expect(err).to match(/The Gemfile lock is pointing to revision \w+/)
- end
- end
-
- describe "specified inline" do
- # TODO: Figure out how to write this test so that it is not flaky depending
- # on the current network situation.
- # it "supports private git URLs" do
- # gemfile <<-G
- # gem "thingy", :git => "git@notthere.fallingsnow.net:somebody/thingy.git"
- # G
- #
- # bundle :install
- #
- # # p out
- # # p err
- # puts err unless err.empty? # This spec fails randomly every so often
- # err.should include("notthere.fallingsnow.net")
- # err.should include("ssh")
- # end
-
- it "installs from git even if a newer gem is available elsewhere" do
- build_git "rack", "0.8"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}"
- G
-
- expect(the_bundle).to include_gems "rack 0.8"
- end
-
- it "installs dependencies from git even if a newer gem is available elsewhere" do
- system_gems "rack-1.0.0"
-
- build_lib "rack", "1.0", :path => lib_path("nested/bar") do |s|
- s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
- end
-
- build_git "foo", :path => lib_path("nested") do |s|
- s.add_dependency "rack", "= 1.0"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("nested")}"
- G
-
- run "require 'rack'"
- expect(out).to eq("WIN OVERRIDE")
- end
-
- it "correctly unlocks when changing to a git source" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- G
-
- build_git "rack", :path => lib_path("rack")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0", :git => "#{lib_path("rack")}"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "correctly unlocks when changing to a git source without versions" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- build_git "rack", "1.2", :path => lib_path("rack")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack")}"
- G
-
- expect(the_bundle).to include_gems "rack 1.2"
- end
- end
-
- describe "block syntax" do
- it "pulls all gems from a git block" do
- build_lib "omg", :path => lib_path("hi2u/omg")
- build_lib "hi2u", :path => lib_path("hi2u")
-
- install_gemfile <<-G
- path "#{lib_path("hi2u")}" do
- gem "omg"
- gem "hi2u"
- end
- G
-
- expect(the_bundle).to include_gems "omg 1.0", "hi2u 1.0"
- end
- end
-
- it "uses a ref if specified" do
- build_git "foo"
- @revision = revision_for(lib_path("foo-1.0"))
- update_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{@revision}"
- G
-
- run <<-RUBY
- require 'foo'
- puts "WIN" unless defined?(FOO_PREV_REF)
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "correctly handles cases with invalid gemspecs" do
- build_git "foo" do |s|
- s.summary = nil
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- gem "rails", "2.3.2"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rails 2.3.2"
- end
-
- it "runs the gemspec in the context of its parent directory" do
- build_lib "bar", :path => lib_path("foo/bar"), :gemspec => false do |s|
- s.write lib_path("foo/bar/lib/version.rb"), %(BAR_VERSION = '1.0')
- s.write "bar.gemspec", <<-G
- $:.unshift Dir.pwd
- require 'lib/version'
- Gem::Specification.new do |s|
- s.name = 'bar'
- s.author = 'no one'
- s.version = BAR_VERSION
- s.summary = 'Bar'
- s.files = Dir["lib/**/*.rb"]
- end
- G
- end
-
- build_git "foo", :path => lib_path("foo") do |s|
- s.write "bin/foo", ""
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "bar", :git => "#{lib_path("foo")}"
- gem "rails", "2.3.2"
- G
-
- expect(the_bundle).to include_gems "bar 1.0"
- expect(the_bundle).to include_gems "rails 2.3.2"
- end
-
- it "installs from git even if a rubygems gem is present" do
- build_gem "foo", "1.0", :path => lib_path("fake_foo"), :to_system => true do |s|
- s.write "lib/foo.rb", "raise 'FAIL'"
- end
-
- build_git "foo", "1.0"
-
- install_gemfile <<-G
- gem "foo", "1.0", :git => "#{lib_path("foo-1.0")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "fakes the gem out if there is no gemspec" do
- build_git "foo", :gemspec => false
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", "1.0", :git => "#{lib_path("foo-1.0")}"
- gem "rails", "2.3.2"
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "catches git errors and spits out useful output" do
- gemfile <<-G
- gem "foo", "1.0", :git => "omgomg"
- G
-
- bundle :install
-
- expect(err).to include("Git error:")
- expect(err).to include("fatal")
- expect(err).to include("omgomg")
- end
-
- it "works when the gem path has spaces in it" do
- build_git "foo", :path => lib_path("foo space-1.0")
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo space-1.0")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "handles repos that have been force-pushed" do
- build_git "forced", "1.0"
-
- install_gemfile <<-G
- git "#{lib_path("forced-1.0")}" do
- gem 'forced'
- end
- G
- expect(the_bundle).to include_gems "forced 1.0"
-
- update_git "forced" do |s|
- s.write "lib/forced.rb", "FORCED = '1.1'"
- end
-
- bundle "update", :all => true
- expect(the_bundle).to include_gems "forced 1.1"
-
- Dir.chdir(lib_path("forced-1.0")) do
- `git reset --hard HEAD^`
- end
-
- bundle "update", :all => true
- expect(the_bundle).to include_gems "forced 1.0"
- end
-
- it "ignores submodules if :submodule is not passed" do
- build_git "submodule", "1.0"
- build_git "has_submodule", "1.0" do |s|
- s.add_dependency "submodule"
- end
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
-
- install_gemfile <<-G
- git "#{lib_path("has_submodule-1.0")}" do
- gem "has_submodule"
- end
- G
- expect(err).to match(/could not find gem 'submodule/i)
-
- expect(the_bundle).not_to include_gems "has_submodule 1.0"
- end
-
- it "handles repos with submodules" do
- build_git "submodule", "1.0"
- build_git "has_submodule", "1.0" do |s|
- s.add_dependency "submodule"
- end
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
-
- install_gemfile <<-G
- git "#{lib_path("has_submodule-1.0")}", :submodules => true do
- gem "has_submodule"
- end
- G
-
- expect(the_bundle).to include_gems "has_submodule 1.0"
- end
-
- it "handles implicit updates when modifying the source info" do
- git = build_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}" do
- gem "foo"
- end
- G
-
- update_git "foo"
- update_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}", :ref => "#{git.ref_for("HEAD^")}" do
- gem "foo"
- end
- G
-
- run <<-RUBY
- require 'foo'
- puts "WIN" if FOO_PREV_REF == '#{git.ref_for("HEAD^^")}'
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "does not to a remote fetch if the revision is cached locally" do
- build_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- FileUtils.rm_rf(lib_path("foo-1.0"))
-
- bundle "install"
- expect(out).not_to match(/updating/i)
- end
-
- it "doesn't blow up if bundle install is run twice in a row" do
- build_git "foo"
-
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- bundle "install"
- bundle "install"
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- it "prints a friendly error if a file blocks the git repo" do
- build_git "foo"
-
- FileUtils.mkdir_p(default_bundle_path)
- FileUtils.touch(default_bundle_path("bundler"))
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- expect(exitstatus).to_not eq(0) if exitstatus
- expect(err).to include("Bundler could not install a gem because it " \
- "needs to create a directory, but a file exists " \
- "- #{default_bundle_path("bundler")}")
- end
-
- it "does not duplicate git gem sources" do
- build_lib "foo", :path => lib_path("nested/foo")
- build_lib "bar", :path => lib_path("nested/bar")
-
- build_git "foo", :path => lib_path("nested")
- build_git "bar", :path => lib_path("nested")
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("nested")}"
- gem "bar", :git => "#{lib_path("nested")}"
- G
-
- expect(File.read(bundled_app("Gemfile.lock")).scan("GIT").size).to eq(1)
- end
-
- describe "switching sources" do
- it "doesn't explode when switching Path to Git sources" do
- build_gem "foo", "1.0", :to_system => true do |s|
- s.write "lib/foo.rb", "raise 'fail'"
- end
- build_lib "foo", "1.0", :path => lib_path("bar/foo")
- build_git "bar", "1.0", :path => lib_path("bar") do |s|
- s.add_dependency "foo"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "bar", :path => "#{lib_path("bar")}"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "bar", :git => "#{lib_path("bar")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0", "bar 1.0"
- end
-
- it "doesn't explode when switching Gem to Git source" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack-obama"
- gem "rack", "1.0.0"
- G
-
- build_git "rack", "1.0" do |s|
- s.write "lib/new_file.rb", "puts 'USING GIT'"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack-obama"
- gem "rack", "1.0.0", :git => "#{lib_path("rack-1.0")}"
- G
-
- run "require 'new_file'"
- expect(out).to eq("USING GIT")
- end
- end
-
- describe "bundle install after the remote has been updated" do
- it "installs" do
- build_git "valim"
-
- install_gemfile <<-G
- gem "valim", :git => "#{file_uri_for(lib_path("valim-1.0"))}"
- G
-
- old_revision = revision_for(lib_path("valim-1.0"))
- update_git "valim"
- new_revision = revision_for(lib_path("valim-1.0"))
-
- old_lockfile = File.read(bundled_app("Gemfile.lock"))
- lockfile(bundled_app("Gemfile.lock"), old_lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}"))
-
- bundle "install"
-
- run <<-R
- require "valim"
- puts VALIM_PREV_REF
- R
-
- expect(out).to eq(old_revision)
- end
-
- it "gives a helpful error message when the remote ref no longer exists" do
- build_git "foo"
- revision = revision_for(lib_path("foo-1.0"))
-
- install_gemfile <<-G
- gem "foo", :git => "#{file_uri_for(lib_path("foo-1.0"))}", :ref => "#{revision}"
- G
- expect(out).to_not match(/Revision.*does not exist/)
-
- install_gemfile <<-G
- gem "foo", :git => "#{file_uri_for(lib_path("foo-1.0"))}", :ref => "deadbeef"
- G
- expect(err).to include("Revision deadbeef does not exist in the repository")
- end
- end
-
- describe "bundle install --deployment with git sources" do
- it "works" do
- build_git "valim", :path => lib_path("valim")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "valim", "= 1.0", :git => "#{lib_path("valim")}"
- G
-
- simulate_new_machine
-
- bundle! :install, forgotten_command_line_options(:deployment => true)
- end
- end
-
- describe "gem install hooks" do
- it "runs pre-install hooks" do
- build_git "foo"
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- File.open(lib_path("install_hooks.rb"), "w") do |h|
- h.write <<-H
- Gem.pre_install_hooks << lambda do |inst|
- STDERR.puts "Ran pre-install hook: \#{inst.spec.full_name}"
- end
- H
- end
-
- bundle :install,
- :requires => [lib_path("install_hooks.rb")]
- expect(err_without_deprecations).to eq("Ran pre-install hook: foo-1.0")
- end
-
- it "runs post-install hooks" do
- build_git "foo"
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- File.open(lib_path("install_hooks.rb"), "w") do |h|
- h.write <<-H
- Gem.post_install_hooks << lambda do |inst|
- STDERR.puts "Ran post-install hook: \#{inst.spec.full_name}"
- end
- H
- end
-
- bundle :install,
- :requires => [lib_path("install_hooks.rb")]
- expect(err_without_deprecations).to eq("Ran post-install hook: foo-1.0")
- end
-
- it "complains if the install hook fails" do
- build_git "foo"
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- File.open(lib_path("install_hooks.rb"), "w") do |h|
- h.write <<-H
- Gem.pre_install_hooks << lambda do |inst|
- false
- end
- H
- end
-
- bundle :install,
- :requires => [lib_path("install_hooks.rb")]
- expect(err).to include("failed for foo-1.0")
- end
- end
-
- context "with an extension" do
- it "installs the extension" do
- build_git "foo" do |s|
- s.add_dependency "rake"
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- path = File.expand_path("../lib", __FILE__)
- FileUtils.mkdir_p(path)
- File.open("\#{path}/foo.rb", "w") do |f|
- f.puts "FOO = 'YES'"
- end
- end
- RUBY
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- run <<-R
- require 'foo'
- puts FOO
- R
- expect(out).to eq("YES")
-
- run! <<-R
- puts $:.grep(/ext/)
- R
- expect(out).to include(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s)
- end
-
- it "does not use old extension after ref changes", :ruby_repo do
- git_reader = build_git "foo", :no_default => true do |s|
- s.extensions = ["ext/extconf.rb"]
- s.write "ext/extconf.rb", <<-RUBY
- require "mkmf"
- create_makefile("foo")
- RUBY
- s.write "ext/foo.c", "void Init_foo() {}"
- end
-
- 2.times do |i|
- Dir.chdir(git_reader.path) do
- File.open("ext/foo.c", "w") do |file|
- file.write <<-C
- #include "ruby.h"
- VALUE foo() { return INT2FIX(#{i}); }
- void Init_foo() { rb_define_global_function("foo", &foo, 0); }
- C
- end
- `git commit -m "commit for iteration #{i}" ext/foo.c`
- end
- git_commit_sha = git_reader.ref_for("HEAD")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{git_commit_sha}"
- G
-
- run <<-R
- require 'foo'
- puts foo
- R
-
- expect(out).to eq(i.to_s)
- end
- end
-
- it "does not prompt to gem install if extension fails" do
- build_git "foo" do |s|
- s.add_dependency "rake"
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- raise
- end
- RUBY
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- expect(err).to end_with(<<-M.strip)
-An error occurred while installing foo (1.0), and Bundler cannot continue.
-
-In Gemfile:
- foo
- M
- expect(out).not_to include("gem install foo")
- end
-
- it "does not reinstall the extension" do
- build_git "foo" do |s|
- s.add_dependency "rake"
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- path = File.expand_path("../lib", __FILE__)
- FileUtils.mkdir_p(path)
- cur_time = Time.now.to_f.to_s
- File.open("\#{path}/foo.rb", "w") do |f|
- f.puts "FOO = \#{cur_time}"
- end
- end
- RUBY
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- run! <<-R
- require 'foo'
- puts FOO
- R
-
- installed_time = out
- expect(installed_time).to match(/\A\d+\.\d+\z/)
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- run! <<-R
- require 'foo'
- puts FOO
- R
- expect(out).to eq(installed_time)
- end
-
- it "does not reinstall the extension when changing another gem" do
- build_git "foo" do |s|
- s.add_dependency "rake"
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- path = File.expand_path("../lib", __FILE__)
- FileUtils.mkdir_p(path)
- cur_time = Time.now.to_f.to_s
- File.open("\#{path}/foo.rb", "w") do |f|
- f.puts "FOO = \#{cur_time}"
- end
- end
- RUBY
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- run! <<-R
- require 'foo'
- puts FOO
- R
-
- installed_time = out
- expect(installed_time).to match(/\A\d+\.\d+\z/)
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- run! <<-R
- require 'foo'
- puts FOO
- R
- expect(out).to eq(installed_time)
- end
-
- it "does reinstall the extension when changing refs" do
- build_git "foo" do |s|
- s.add_dependency "rake"
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- path = File.expand_path("../lib", __FILE__)
- FileUtils.mkdir_p(path)
- cur_time = Time.now.to_f.to_s
- File.open("\#{path}/foo.rb", "w") do |f|
- f.puts "FOO = \#{cur_time}"
- end
- end
- RUBY
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- run! <<-R
- require 'foo'
- puts FOO
- R
-
- update_git("foo", :branch => "branch2")
-
- installed_time = out
- expect(installed_time).to match(/\A\d+\.\d+\z/)
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "branch2"
- G
-
- run! <<-R
- require 'foo'
- puts FOO
- R
- expect(out).not_to eq(installed_time)
-
- installed_time = out
-
- update_git("foo")
- bundle! "update foo"
-
- run! <<-R
- require 'foo'
- puts FOO
- R
- expect(out).not_to eq(installed_time)
- end
- end
-
- it "ignores git environment variables" do
- build_git "xxxxxx" do |s|
- s.executables = "xxxxxxbar"
- end
-
- Bundler::SharedHelpers.with_clean_git_env do
- ENV["GIT_DIR"] = "bar"
- ENV["GIT_WORK_TREE"] = "bar"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- git "#{lib_path("xxxxxx-1.0")}" do
- gem 'xxxxxx'
- end
- G
-
- expect(exitstatus).to eq(0) if exitstatus
- expect(ENV["GIT_DIR"]).to eq("bar")
- expect(ENV["GIT_WORK_TREE"]).to eq("bar")
- end
- end
-
- describe "without git installed" do
- it "prints a better error message" do
- build_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
-
- with_path_as("") do
- bundle "update", :all => true
- end
- expect(err).
- to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git")
- end
-
- it "installs a packaged git gem successfully" do
- build_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
- bundle "config set cache_all true"
- bundle :cache
- simulate_new_machine
-
- bundle! "install", :env => { "PATH" => "" }
- expect(out).to_not include("You need to install git to be able to use gems from git repositories.")
- end
- end
-
- describe "when the git source is overridden with a local git repo" do
- before do
- bundle! "config set --global local.foo #{lib_path("foo")}"
- end
-
- describe "and git output is colorized" do
- before do
- File.open("#{ENV["HOME"]}/.gitconfig", "w") do |f|
- f.write("[color]\n\tui = always\n")
- end
- end
-
- it "installs successfully" do
- build_git "foo", "1.0", :path => lib_path("foo")
-
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo")}", :branch => "master"
- G
-
- bundle :install
- expect(the_bundle).to include_gems "foo 1.0"
- end
- end
- end
-
- context "git sources that include credentials" do
- context "that are username and password" do
- let(:credentials) { "user1:password1" }
-
- it "does not display the password" do
- install_gemfile <<-G
- git "https://#{credentials}@github.com/company/private-repo" do
- gem "foo"
- end
- G
-
- expect(last_command.stdboth).to_not include("password1")
- expect(out).to include("Fetching https://user1@github.com/company/private-repo")
- end
- end
-
- context "that is an oauth token" do
- let(:credentials) { "oauth_token" }
-
- it "displays the oauth scheme but not the oauth token" do
- install_gemfile <<-G
- git "https://#{credentials}:x-oauth-basic@github.com/company/private-repo" do
- gem "foo"
- end
- G
-
- expect(last_command.stdboth).to_not include("oauth_token")
- expect(out).to include("Fetching https://x-oauth-basic@github.com/company/private-repo")
- end
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/groups_spec.rb b/spec/bundler/install/gemfile/groups_spec.rb
deleted file mode 100644
index 63be1a4e43..0000000000
--- a/spec/bundler/install/gemfile/groups_spec.rb
+++ /dev/null
@@ -1,384 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with groups" do
- describe "installing with no options" do
- before :each do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- group :emo do
- gem "activesupport", "2.3.5"
- end
- gem "thin", :groups => [:emo]
- G
- end
-
- it "installs gems in the default group" do
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs gems in a group block into that group" do
- expect(the_bundle).to include_gems "activesupport 2.3.5"
-
- load_error_run <<-R, "activesupport", :default
- require 'activesupport'
- puts ACTIVESUPPORT
- R
-
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
- end
-
- it "installs gems with inline :groups into those groups" do
- expect(the_bundle).to include_gems "thin 1.0"
-
- load_error_run <<-R, "thin", :default
- require 'thin'
- puts THIN
- R
-
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
- end
-
- it "sets up everything if Bundler.setup is used with no groups" do
- output = run("require 'rack'; puts RACK")
- expect(output).to eq("1.0.0")
-
- output = run("require 'activesupport'; puts ACTIVESUPPORT")
- expect(output).to eq("2.3.5")
-
- output = run("require 'thin'; puts THIN")
- expect(output).to eq("1.0")
- end
-
- it "removes old groups when new groups are set up" do
- load_error_run <<-RUBY, "thin", :emo
- Bundler.setup(:default)
- require 'thin'
- puts THIN
- RUBY
-
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
- end
-
- it "sets up old groups when they have previously been removed" do
- output = run <<-RUBY, :emo
- Bundler.setup(:default)
- Bundler.setup(:default, :emo)
- require 'thin'; puts THIN
- RUBY
- expect(output).to eq("1.0")
- end
- end
-
- describe "installing --without" do
- describe "with gems assigned to a single group" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- group :emo do
- gem "activesupport", "2.3.5"
- end
- group :debugging, :optional => true do
- gem "thin"
- end
- G
- end
-
- it "installs gems in the default group" do
- bundle! :install, forgotten_command_line_options(:without => "emo")
- expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
- end
-
- it "does not install gems from the excluded group" do
- bundle :install, :without => "emo"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default]
- end
-
- it "does not install gems from the previously excluded group" do
- bundle :install, forgotten_command_line_options(:without => "emo")
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- bundle :install
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- end
-
- it "does not say it installed gems from the excluded group" do
- bundle! :install, forgotten_command_line_options(:without => "emo")
- expect(out).not_to include("activesupport")
- end
-
- it "allows Bundler.setup for specific groups" do
- bundle :install, forgotten_command_line_options(:without => "emo")
- run!("require 'rack'; puts RACK", :default)
- expect(out).to eq("1.0.0")
- end
-
- it "does not effect the resolve" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
- group :emo do
- gem "rails", "2.3.2"
- end
- G
-
- bundle :install, forgotten_command_line_options(:without => "emo")
- expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => [:default]
- end
-
- it "still works on a different machine and excludes gems" do
- bundle :install, forgotten_command_line_options(:without => "emo")
-
- simulate_new_machine
- bundle :install, forgotten_command_line_options(:without => "emo")
-
- expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
- expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default]
- end
-
- it "still works when BUNDLE_WITHOUT is set" do
- ENV["BUNDLE_WITHOUT"] = "emo"
-
- bundle :install
- expect(out).not_to include("activesupport")
-
- expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
- expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default]
-
- ENV["BUNDLE_WITHOUT"] = nil
- end
-
- it "clears without when passed an empty list" do
- bundle :install, forgotten_command_line_options(:without => "emo")
-
- bundle :install, forgotten_command_line_options(:without => "")
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- end
-
- it "doesn't clear without when nothing is passed" do
- bundle :install, forgotten_command_line_options(:without => "emo")
-
- bundle :install
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- end
-
- it "does not install gems from the optional group" do
- bundle :install
- expect(the_bundle).not_to include_gems "thin 1.0"
- end
-
- it "does install gems from the optional group when requested" do
- bundle :install, forgotten_command_line_options(:with => "debugging")
- expect(the_bundle).to include_gems "thin 1.0"
- end
-
- it "does install gems from the previously requested group" do
- bundle :install, forgotten_command_line_options(:with => "debugging")
- expect(the_bundle).to include_gems "thin 1.0"
- bundle :install
- expect(the_bundle).to include_gems "thin 1.0"
- end
-
- it "does install gems from the optional groups requested with BUNDLE_WITH" do
- ENV["BUNDLE_WITH"] = "debugging"
- bundle :install
- expect(the_bundle).to include_gems "thin 1.0"
- ENV["BUNDLE_WITH"] = nil
- end
-
- it "clears with when passed an empty list" do
- bundle :install, forgotten_command_line_options(:with => "debugging")
- bundle :install, forgotten_command_line_options(:with => "")
- expect(the_bundle).not_to include_gems "thin 1.0"
- end
-
- it "does remove groups from without when passed at --with", :bundler => "< 3" do
- bundle :install, forgotten_command_line_options(:without => "emo")
- bundle :install, forgotten_command_line_options(:with => "emo")
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- end
-
- it "does remove groups from with when passed at --without", :bundler => "< 3" do
- bundle :install, forgotten_command_line_options(:with => "debugging")
- bundle :install, forgotten_command_line_options(:without => "debugging")
- expect(the_bundle).not_to include_gem "thin 1.0"
- end
-
- it "errors out when passing a group to with and without via CLI flags", :bundler => "< 3" do
- bundle :install, forgotten_command_line_options(:with => "emo debugging", :without => "emo")
- expect(last_command).to be_failure
- expect(err).to include("The offending groups are: emo")
- end
-
- it "allows the BUNDLE_WITH setting to override BUNDLE_WITHOUT" do
- ENV["BUNDLE_WITH"] = "debugging"
-
- bundle! :install
- expect(the_bundle).to include_gem "thin 1.0"
-
- ENV["BUNDLE_WITHOUT"] = "debugging"
- expect(the_bundle).to include_gem "thin 1.0"
-
- bundle! :install
- expect(the_bundle).to include_gem "thin 1.0"
- end
-
- it "can add and remove a group at the same time" do
- bundle :install, forgotten_command_line_options(:with => "debugging", :without => "emo")
- expect(the_bundle).to include_gems "thin 1.0"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- end
-
- it "does have no effect when listing a not optional group in with" do
- bundle :install, forgotten_command_line_options(:with => "emo")
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- end
-
- it "does have no effect when listing an optional group in without" do
- bundle :install, forgotten_command_line_options(:without => "debugging")
- expect(the_bundle).not_to include_gems "thin 1.0"
- end
- end
-
- describe "with gems assigned to multiple groups" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- group :emo, :lolercoaster do
- gem "activesupport", "2.3.5"
- end
- G
- end
-
- it "installs gems in the default group" do
- bundle! :install, forgotten_command_line_options(:without => "emo lolercoaster")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs the gem if any of its groups are installed" do
- bundle! :install, forgotten_command_line_options(:without => "emo")
- expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
- end
-
- describe "with a gem defined multiple times in different groups" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- group :emo do
- gem "activesupport", "2.3.5"
- end
-
- group :lolercoaster do
- gem "activesupport", "2.3.5"
- end
- G
- end
-
- it "installs the gem w/ option --without emo" do
- bundle :install, forgotten_command_line_options(:without => "emo")
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- end
-
- it "installs the gem w/ option --without lolercoaster" do
- bundle :install, forgotten_command_line_options(:without => "lolercoaster")
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- end
-
- it "does not install the gem w/ option --without emo lolercoaster" do
- bundle :install, forgotten_command_line_options(:without => "emo lolercoaster")
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- end
-
- it "does not install the gem w/ option --without 'emo lolercoaster'" do
- bundle :install, forgotten_command_line_options(:without => "'emo lolercoaster'")
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- end
- end
- end
-
- describe "nesting groups" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- group :emo do
- group :lolercoaster do
- gem "activesupport", "2.3.5"
- end
- end
- G
- end
-
- it "installs gems in the default group" do
- bundle! :install, forgotten_command_line_options(:without => "emo lolercoaster")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs the gem if any of its groups are installed" do
- bundle! :install, forgotten_command_line_options(:without => "emo")
- expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
- end
- end
- end
-
- describe "when loading only the default group" do
- it "should not load all groups" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :groups => :development
- G
-
- ruby <<-R
- require "#{lib_dir}/bundler"
- Bundler.setup :default
- Bundler.require :default
- puts RACK
- begin
- require "activesupport"
- rescue LoadError
- puts "no activesupport"
- end
- R
-
- expect(out).to include("1.0")
- expect(out).to include("no activesupport")
- end
- end
-
- describe "when locked and installed with --without" do
- before(:each) do
- build_repo2
- system_gems "rack-0.9.1" do
- install_gemfile <<-G, forgotten_command_line_options(:without => "rack")
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
-
- group :rack do
- gem "rack_middleware"
- end
- G
- end
- end
-
- it "uses the correct versions even if --without was used on the original" do
- expect(the_bundle).to include_gems "rack 0.9.1"
- expect(the_bundle).not_to include_gems "rack_middleware 1.0"
- simulate_new_machine
-
- bundle :install
-
- expect(the_bundle).to include_gems "rack 0.9.1"
- expect(the_bundle).to include_gems "rack_middleware 1.0"
- end
-
- it "does not hit the remote a second time" do
- FileUtils.rm_rf gem_repo2
- bundle! :install, forgotten_command_line_options(:without => "rack").merge(:verbose => true)
- expect(last_command.stdboth).not_to match(/fetching/i)
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/install_if.rb b/spec/bundler/install/gemfile/install_if.rb
deleted file mode 100644
index bfdd8fbae8..0000000000
--- a/spec/bundler/install/gemfile/install_if.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-describe "bundle install with install_if conditionals" do
- it "follows the install_if DSL" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- install_if(lambda { true }) do
- gem "activesupport", "2.3.5"
- end
- gem "thin", :install_if => false
- install_if(lambda { false }) do
- gem "foo"
- end
- gem "rack"
- G
-
- expect(the_bundle).to include_gems("rack 1.0", "activesupport 2.3.5")
- expect(the_bundle).not_to include_gems("thin")
- expect(the_bundle).not_to include_gems("foo")
-
- lockfile_should_be <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- activesupport (2.3.5)
- foo (1.0)
- rack (1.0.0)
- thin (1.0)
- rack
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- activesupport (= 2.3.5)
- foo
- rack
- thin
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-end
diff --git a/spec/bundler/install/gemfile/lockfile_spec.rb b/spec/bundler/install/gemfile/lockfile_spec.rb
deleted file mode 100644
index b9545b91c2..0000000000
--- a/spec/bundler/install/gemfile/lockfile_spec.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with a lockfile present" do
- let(:gf) { <<-G }
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- G
-
- subject do
- install_gemfile(gf)
- end
-
- context "gemfile evaluation" do
- let(:gf) { super() + "\n\n File.open('evals', 'a') {|f| f << %(1\n) } unless ENV['BUNDLER_SPEC_NO_APPEND']" }
-
- context "with plugins disabled" do
- before do
- bundle! "config set plugins false"
- subject
- end
-
- it "does not evaluate the gemfile twice" do
- bundle! :install
-
- with_env_vars("BUNDLER_SPEC_NO_APPEND" => "1") { expect(the_bundle).to include_gem "rack 1.0.0" }
-
- # The first eval is from the initial install, we're testing that the
- # second install doesn't double-eval
- expect(bundled_app("evals").read.lines.to_a.size).to eq(2)
- end
-
- context "when the gem is not installed" do
- before { FileUtils.rm_rf ".bundle" }
-
- it "does not evaluate the gemfile twice" do
- bundle! :install
-
- with_env_vars("BUNDLER_SPEC_NO_APPEND" => "1") { expect(the_bundle).to include_gem "rack 1.0.0" }
-
- # The first eval is from the initial install, we're testing that the
- # second install doesn't double-eval
- expect(bundled_app("evals").read.lines.to_a.size).to eq(2)
- end
- end
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb
deleted file mode 100644
index e53636da09..0000000000
--- a/spec/bundler/install/gemfile/path_spec.rb
+++ /dev/null
@@ -1,747 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with explicit source paths" do
- it "fetches gems with a global path source", :bundler => "< 3" do
- build_lib "foo"
-
- install_gemfile <<-G
- path "#{lib_path("foo-1.0")}"
- gem 'foo'
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "fetches gems" do
- build_lib "foo"
-
- install_gemfile <<-G
- path "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "supports pinned paths" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem 'foo', :path => "#{lib_path("foo-1.0")}"
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "supports relative paths" do
- build_lib "foo"
-
- relative_path = lib_path("foo-1.0").relative_path_from(Pathname.new(Dir.pwd))
-
- install_gemfile <<-G
- gem 'foo', :path => "#{relative_path}"
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "expands paths" do
- build_lib "foo"
-
- relative_path = lib_path("foo-1.0").relative_path_from(Pathname.new("~").expand_path)
-
- install_gemfile <<-G
- gem 'foo', :path => "~/#{relative_path}"
- G
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "expands paths raise error with not existing user's home dir" do
- build_lib "foo"
- username = "some_unexisting_user"
- relative_path = lib_path("foo-1.0").relative_path_from(Pathname.new("/home/#{username}").expand_path)
-
- install_gemfile <<-G
- gem 'foo', :path => "~#{username}/#{relative_path}"
- G
- expect(err).to match("There was an error while trying to use the path `~#{username}/#{relative_path}`.")
- expect(err).to match("user #{username} doesn't exist")
- end
-
- it "expands paths relative to Bundler.root" do
- build_lib "foo", :path => bundled_app("foo-1.0")
-
- install_gemfile <<-G
- gem 'foo', :path => "./foo-1.0"
- G
-
- bundled_app("subdir").mkpath
- Dir.chdir(bundled_app("subdir")) do
- expect(the_bundle).to include_gems("foo 1.0")
- end
- end
-
- it "sorts paths consistently on install and update when they start with ./" do
- build_lib "demo", :path => lib_path("demo")
- build_lib "aaa", :path => lib_path("demo/aaa")
-
- gemfile = <<-G
- gemspec
- gem "aaa", :path => "./aaa"
- G
-
- File.open(lib_path("demo/Gemfile"), "w") {|f| f.puts gemfile }
-
- lockfile = <<~L
- PATH
- remote: .
- specs:
- demo (1.0)
-
- PATH
- remote: aaa
- specs:
- aaa (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- aaa!
- demo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- Dir.chdir(lib_path("demo")) do
- bundle :install
- expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
- bundle :update, :all => true
- expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
- end
- end
-
- it "expands paths when comparing locked paths to Gemfile paths" do
- build_lib "foo", :path => bundled_app("foo-1.0")
-
- install_gemfile <<-G
- gem 'foo', :path => File.expand_path("../foo-1.0", __FILE__)
- G
-
- bundle! :install, forgotten_command_line_options(:frozen => true)
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- it "installs dependencies from the path even if a newer gem is available elsewhere" do
- system_gems "rack-1.0.0"
-
- build_lib "rack", "1.0", :path => lib_path("nested/bar") do |s|
- s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
- end
-
- build_lib "foo", :path => lib_path("nested") do |s|
- s.add_dependency "rack", "= 1.0"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :path => "#{lib_path("nested")}"
- G
-
- run "require 'rack'"
- expect(out).to eq("WIN OVERRIDE")
- end
-
- it "works" do
- build_gem "foo", "1.0.0", :to_system => true do |s|
- s.write "lib/foo.rb", "puts 'FAIL'"
- end
-
- build_lib "omg", "1.0", :path => lib_path("omg") do |s|
- s.add_dependency "foo"
- end
-
- build_lib "foo", "1.0.0", :path => lib_path("omg/foo")
-
- install_gemfile <<-G
- gem "omg", :path => "#{lib_path("omg")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "works with only_update_to_newer_versions" do
- build_lib "omg", "2.0", :path => lib_path("omg")
-
- install_gemfile <<-G
- gem "omg", :path => "#{lib_path("omg")}"
- G
-
- build_lib "omg", "1.0", :path => lib_path("omg")
-
- bundle! :install, :env => { "BUNDLE_BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS" => "true" }
-
- expect(the_bundle).to include_gems "omg 1.0"
- end
-
- it "prefers gemspecs closer to the path root" do
- build_lib "premailer", "1.0.0", :path => lib_path("premailer") do |s|
- s.write "gemfiles/ruby187.gemspec", <<-G
- Gem::Specification.new do |s|
- s.name = 'premailer'
- s.version = '1.0.0'
- s.summary = 'Hi'
- s.authors = 'Me'
- end
- G
- end
-
- install_gemfile <<-G
- gem "premailer", :path => "#{lib_path("premailer")}"
- G
-
- # Installation of the 'gemfiles' gemspec would fail since it will be unable
- # to require 'premailer.rb'
- expect(the_bundle).to include_gems "premailer 1.0.0"
- end
-
- it "warns on invalid specs" do
- build_lib "foo"
-
- gemspec = lib_path("foo-1.0").join("foo.gemspec").to_s
- File.open(gemspec, "w") do |f|
- f.write <<-G
- Gem::Specification.new do |s|
- s.name = "foo"
- end
- G
- end
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- expect(err).to_not include("ERROR REPORT")
- expect(err).to_not include("Your Gemfile has no gem server sources.")
- expect(err).to match(/is not valid. Please fix this gemspec./)
- expect(err).to match(/The validation error was 'missing value for attribute version'/)
- expect(err).to match(/You have one or more invalid gemspecs that need to be fixed/)
- end
-
- it "supports gemspec syntax" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "1.0"
- end
-
- gemfile = <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec
- G
-
- File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts gemfile }
-
- Dir.chdir(lib_path("foo")) do
- bundle "install"
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- it "supports gemspec syntax with an alternative path" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "1.0"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec :path => "#{lib_path("foo")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "doesn't automatically unlock dependencies when using the gemspec syntax" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", ">= 1.0"
- end
-
- Dir.chdir lib_path("foo")
-
- install_gemfile lib_path("foo/Gemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec
- G
-
- build_gem "rack", "1.0.1", :to_system => true
-
- bundle "install"
-
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "doesn't automatically unlock dependencies when using the gemspec syntax and the gem has development dependencies" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", ">= 1.0"
- s.add_development_dependency "activesupport"
- end
-
- Dir.chdir lib_path("foo")
-
- install_gemfile lib_path("foo/Gemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec
- G
-
- build_gem "rack", "1.0.1", :to_system => true
-
- bundle "install"
-
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "raises if there are multiple gemspecs" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.write "bar.gemspec", build_spec("bar", "1.0").first.to_ruby
- end
-
- install_gemfile <<-G
- gemspec :path => "#{lib_path("foo")}"
- G
-
- expect(exitstatus).to eq(15) if exitstatus
- expect(err).to match(/There are multiple gemspecs/)
- end
-
- it "allows :name to be specified to resolve ambiguity" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.write "bar.gemspec"
- end
-
- install_gemfile <<-G
- gemspec :path => "#{lib_path("foo")}", :name => "foo"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "sets up executables" do
- build_lib "foo" do |s|
- s.executables = "foobar"
- end
-
- install_gemfile <<-G
- path "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
- expect(the_bundle).to include_gems "foo 1.0"
-
- bundle "exec foobar"
- expect(out).to eq("1.0")
- end
-
- it "handles directories in bin/" do
- build_lib "foo"
- lib_path("foo-1.0").join("foo.gemspec").rmtree
- lib_path("foo-1.0").join("bin/performance").mkpath
-
- install_gemfile <<-G
- gem 'foo', '1.0', :path => "#{lib_path("foo-1.0")}"
- G
- expect(err).to be_empty
- end
-
- it "removes the .gem file after installing" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem 'foo', :path => "#{lib_path("foo-1.0")}"
- G
-
- expect(lib_path("foo-1.0").join("foo-1.0.gem")).not_to exist
- end
-
- describe "block syntax" do
- it "pulls all gems from a path block" do
- build_lib "omg"
- build_lib "hi2u"
-
- install_gemfile <<-G
- path "#{lib_path}" do
- gem "omg"
- gem "hi2u"
- end
- G
-
- expect(the_bundle).to include_gems "omg 1.0", "hi2u 1.0"
- end
- end
-
- it "keeps source pinning" do
- build_lib "foo", "1.0", :path => lib_path("foo")
- build_lib "omg", "1.0", :path => lib_path("omg")
- build_lib "foo", "1.0", :path => lib_path("omg/foo") do |s|
- s.write "lib/foo.rb", "puts 'FAIL'"
- end
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo")}"
- gem "omg", :path => "#{lib_path("omg")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "works when the path does not have a gemspec" do
- build_lib "foo", :gemspec => false
-
- gemfile <<-G
- gem "foo", "1.0", :path => "#{lib_path("foo-1.0")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0"
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "works when the path does not have a gemspec but there is a lockfile" do
- lockfile <<~L
- PATH
- remote: vendor/bar
- specs:
-
- GEM
- remote: http://rubygems.org
- L
-
- in_app_root { FileUtils.mkdir_p("vendor/bar") }
-
- install_gemfile <<-G
- gem "bar", "1.0.0", path: "vendor/bar", require: "bar/nyard"
- G
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- context "existing lockfile" do
- it "rubygems gems don't re-resolve without changes" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack-obama', '1.0'
- gem 'net-ssh', '1.0'
- G
-
- bundle :check, :env => { "DEBUG" => "1" }
- expect(out).to match(/using resolution from the lockfile/)
- expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0"
- end
-
- it "source path gems w/deps don't re-resolve without changes" do
- build_lib "rack-obama", "1.0", :path => lib_path("omg") do |s|
- s.add_dependency "yard"
- end
-
- build_lib "net-ssh", "1.0", :path => lib_path("omg") do |s|
- s.add_dependency "yard"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack-obama', :path => "#{lib_path("omg")}"
- gem 'net-ssh', :path => "#{lib_path("omg")}"
- G
-
- bundle :check, :env => { "DEBUG" => "1" }
- expect(out).to match(/using resolution from the lockfile/)
- expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0"
- end
- end
-
- it "installs executable stubs" do
- build_lib "foo" do |s|
- s.executables = ["foo"]
- end
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- bundle "exec foo"
- expect(out).to eq("1.0")
- end
-
- describe "when the gem version in the path is updated" do
- before :each do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "bar"
- end
- build_lib "bar", "1.0", :path => lib_path("foo/bar")
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo")}"
- G
- end
-
- it "unlocks all gems when the top level gem is updated" do
- build_lib "foo", "2.0", :path => lib_path("foo") do |s|
- s.add_dependency "bar"
- end
-
- bundle "install"
-
- expect(the_bundle).to include_gems "foo 2.0", "bar 1.0"
- end
-
- it "unlocks all gems when a child dependency gem is updated" do
- build_lib "bar", "2.0", :path => lib_path("foo/bar")
-
- bundle "install"
-
- expect(the_bundle).to include_gems "foo 1.0", "bar 2.0"
- end
- end
-
- describe "when dependencies in the path are updated" do
- before :each do
- build_lib "foo", "1.0", :path => lib_path("foo")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "foo", :path => "#{lib_path("foo")}"
- G
- end
-
- it "gets dependencies that are updated in the path" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack"
- end
-
- bundle "install"
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "keeps using the same version if it's compatible" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "0.9.1"
- end
-
- bundle "install"
-
- expect(the_bundle).to include_gems "rack 0.9.1"
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo")}
- specs:
- foo (1.0)
- rack (= 0.9.1)
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack"
- end
-
- bundle "install"
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo")}
- specs:
- foo (1.0)
- rack
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- expect(the_bundle).to include_gems "rack 0.9.1"
- end
- end
-
- describe "switching sources" do
- it "doesn't switch pinned git sources to rubygems when pinning the parent gem to a path source" do
- build_gem "foo", "1.0", :to_system => true do |s|
- s.write "lib/foo.rb", "raise 'fail'"
- end
- build_lib "foo", "1.0", :path => lib_path("bar/foo")
- build_git "bar", "1.0", :path => lib_path("bar") do |s|
- s.add_dependency "foo"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "bar", :git => "#{lib_path("bar")}"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "bar", :path => "#{lib_path("bar")}"
- G
-
- expect(the_bundle).to include_gems "foo 1.0", "bar 1.0"
- end
-
- it "switches the source when the gem existed in rubygems and the path was already being used for another gem" do
- build_lib "foo", "1.0", :path => lib_path("foo")
- build_gem "bar", "1.0", :to_system => true do |s|
- s.write "lib/bar.rb", "raise 'fail'"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "bar"
- path "#{lib_path("foo")}" do
- gem "foo"
- end
- G
-
- build_lib "bar", "1.0", :path => lib_path("foo/bar")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- path "#{lib_path("foo")}" do
- gem "foo"
- gem "bar"
- end
- G
-
- expect(the_bundle).to include_gems "bar 1.0"
- end
- end
-
- describe "when there are both a gemspec and remote gems" do
- it "doesn't query rubygems for local gemspec name" do
- build_lib "private_lib", "2.2", :path => lib_path("private_lib")
- gemfile = <<-G
- source "http://localgemserver.test"
- gemspec
- gem 'rack'
- G
- File.open(lib_path("private_lib/Gemfile"), "w") {|f| f.puts gemfile }
-
- Dir.chdir(lib_path("private_lib")) do
- bundle :install, :env => { "DEBUG" => "1" }, :artifice => "endpoint"
- expect(out).to match(%r{^HTTP GET http://localgemserver\.test/api/v1/dependencies\?gems=rack$})
- expect(out).not_to match(/^HTTP GET.*private_lib/)
- expect(the_bundle).to include_gems "private_lib 2.2"
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
- end
-
- describe "gem install hooks" do
- it "runs pre-install hooks" do
- build_git "foo"
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- File.open(lib_path("install_hooks.rb"), "w") do |h|
- h.write <<-H
- Gem.pre_install_hooks << lambda do |inst|
- STDERR.puts "Ran pre-install hook: \#{inst.spec.full_name}"
- end
- H
- end
-
- bundle :install,
- :requires => [lib_path("install_hooks.rb")]
- expect(err_without_deprecations).to eq("Ran pre-install hook: foo-1.0")
- end
-
- it "runs post-install hooks" do
- build_git "foo"
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- File.open(lib_path("install_hooks.rb"), "w") do |h|
- h.write <<-H
- Gem.post_install_hooks << lambda do |inst|
- STDERR.puts "Ran post-install hook: \#{inst.spec.full_name}"
- end
- H
- end
-
- bundle :install,
- :requires => [lib_path("install_hooks.rb")]
- expect(err_without_deprecations).to eq("Ran post-install hook: foo-1.0")
- end
-
- it "complains if the install hook fails" do
- build_git "foo"
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- File.open(lib_path("install_hooks.rb"), "w") do |h|
- h.write <<-H
- Gem.pre_install_hooks << lambda do |inst|
- false
- end
- H
- end
-
- bundle :install,
- :requires => [lib_path("install_hooks.rb")]
- expect(err).to include("failed for foo-1.0")
- end
-
- it "loads plugins from the path gem" do
- foo_file = home("foo_plugin_loaded")
- bar_file = home("bar_plugin_loaded")
- expect(foo_file).not_to be_file
- expect(bar_file).not_to be_file
-
- build_lib "foo" do |s|
- s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{foo_file}')")
- end
-
- build_git "bar" do |s|
- s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{bar_file}')")
- end
-
- install_gemfile! <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- gem "bar", :path => "#{lib_path("bar-1.0")}"
- G
-
- expect(foo_file).to be_file
- expect(bar_file).to be_file
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb
deleted file mode 100644
index c096531398..0000000000
--- a/spec/bundler/install/gemfile/platform_spec.rb
+++ /dev/null
@@ -1,425 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install across platforms" do
- it "maintains the same lockfile if all gems are compatible across platforms" do
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- #{not_local}
-
- DEPENDENCIES
- rack
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 0.9.1"
- end
-
- it "pulls in the correct platform specific gem" do
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}
- specs:
- platform_specific (1.0)
- platform_specific (1.0-java)
- platform_specific (1.0-x86-mswin32)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- platform_specific
- G
-
- simulate_platform "java"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "platform_specific"
- G
-
- expect(the_bundle).to include_gems "platform_specific 1.0 JAVA"
- end
-
- it "works with gems that have different dependencies" do
- simulate_platform "java"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "nokogiri"
- G
-
- expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
-
- simulate_new_machine
-
- simulate_platform "ruby"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "nokogiri"
- G
-
- expect(the_bundle).to include_gems "nokogiri 1.4.2"
- expect(the_bundle).not_to include_gems "weakling"
- end
-
- it "does not keep unneeded platforms for gems that are used" do
- build_repo4 do
- build_gem "empyrean", "0.1.0"
- build_gem "coderay", "1.1.2"
- build_gem "method_source", "0.9.0"
- build_gem("spoon", "0.0.6") {|s| s.add_runtime_dependency "ffi" }
- build_gem "pry", "0.11.3" do |s|
- s.platform = "java"
- s.add_runtime_dependency "coderay", "~> 1.1.0"
- s.add_runtime_dependency "method_source", "~> 0.9.0"
- s.add_runtime_dependency "spoon", "~> 0.0"
- end
- build_gem "pry", "0.11.3" do |s|
- s.add_runtime_dependency "coderay", "~> 1.1.0"
- s.add_runtime_dependency "method_source", "~> 0.9.0"
- end
- build_gem("ffi", "1.9.23") {|s| s.platform = "java" }
- build_gem("ffi", "1.9.23")
- end
-
- simulate_platform java
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
-
- gem "empyrean", "0.1.0"
- gem "pry"
- G
-
- lockfile_should_be <<-L
- GEM
- remote: #{file_uri_for(gem_repo4)}/
- specs:
- coderay (1.1.2)
- empyrean (0.1.0)
- ffi (1.9.23-java)
- method_source (0.9.0)
- pry (0.11.3-java)
- coderay (~> 1.1.0)
- method_source (~> 0.9.0)
- spoon (~> 0.0)
- spoon (0.0.6)
- ffi
-
- PLATFORMS
- java
-
- DEPENDENCIES
- empyrean (= 0.1.0)
- pry
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- bundle! "lock --add-platform ruby"
-
- good_lockfile = strip_whitespace(<<-L)
- GEM
- remote: #{file_uri_for(gem_repo4)}/
- specs:
- coderay (1.1.2)
- empyrean (0.1.0)
- ffi (1.9.23-java)
- method_source (0.9.0)
- pry (0.11.3)
- coderay (~> 1.1.0)
- method_source (~> 0.9.0)
- pry (0.11.3-java)
- coderay (~> 1.1.0)
- method_source (~> 0.9.0)
- spoon (~> 0.0)
- spoon (0.0.6)
- ffi
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- empyrean (= 0.1.0)
- pry
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- lockfile_should_be good_lockfile
-
- bad_lockfile = strip_whitespace <<-L
- GEM
- remote: #{file_uri_for(gem_repo4)}/
- specs:
- coderay (1.1.2)
- empyrean (0.1.0)
- ffi (1.9.23)
- ffi (1.9.23-java)
- method_source (0.9.0)
- pry (0.11.3)
- coderay (~> 1.1.0)
- method_source (~> 0.9.0)
- pry (0.11.3-java)
- coderay (~> 1.1.0)
- method_source (~> 0.9.0)
- spoon (~> 0.0)
- spoon (0.0.6)
- ffi
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- empyrean (= 0.1.0)
- pry
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- aggregate_failures do
- lockfile bad_lockfile
- bundle! :install
- lockfile_should_be good_lockfile
-
- lockfile bad_lockfile
- bundle! :update, :all => true
- lockfile_should_be good_lockfile
-
- lockfile bad_lockfile
- bundle! "update ffi"
- lockfile_should_be good_lockfile
-
- lockfile bad_lockfile
- bundle! "update empyrean"
- lockfile_should_be good_lockfile
-
- lockfile bad_lockfile
- bundle! :lock
- lockfile_should_be good_lockfile
- end
- end
-
- it "works the other way with gems that have different dependencies" do
- simulate_platform "ruby"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "nokogiri"
- G
-
- simulate_platform "java"
- bundle "install"
-
- expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
- end
-
- it "works with gems that have extra platform-specific runtime dependencies", :bundler => "< 3" do
- simulate_platform x64_mac
-
- update_repo2 do
- build_gem "facter", "2.4.6"
- build_gem "facter", "2.4.6" do |s|
- s.platform = "universal-darwin"
- s.add_runtime_dependency "CFPropertyList"
- end
- build_gem "CFPropertyList"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "facter"
- G
-
- expect(err).to include "Unable to use the platform-specific (universal-darwin) version of facter (2.4.6) " \
- "because it has different dependencies from the ruby version. " \
- "To use the platform-specific version of the gem, run `bundle config set specific_platform true` and install again."
-
- expect(the_bundle).to include_gem "facter 2.4.6"
- expect(the_bundle).not_to include_gem "CFPropertyList"
- end
-
- it "fetches gems again after changing the version of Ruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "1.0.0"
- G
-
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
-
- FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, "1.8"))
-
- bundle! :install
- expect(vendored_gems("gems/rack-1.0.0")).to exist
- end
-end
-
-RSpec.describe "bundle install with platform conditionals" do
- it "installs gems tagged w/ the current platforms" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- platforms :#{local_tag} do
- gem "nokogiri"
- end
- G
-
- expect(the_bundle).to include_gems "nokogiri 1.4.2"
- end
-
- it "does not install gems tagged w/ another platforms" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- platforms :#{not_local_tag} do
- gem "nokogiri"
- end
- G
-
- expect(the_bundle).to include_gems "rack 1.0"
- expect(the_bundle).not_to include_gems "nokogiri 1.4.2"
- end
-
- it "installs gems tagged w/ the current platforms inline" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "nokogiri", :platforms => :#{local_tag}
- G
- expect(the_bundle).to include_gems "nokogiri 1.4.2"
- end
-
- it "does not install gems tagged w/ another platforms inline" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "nokogiri", :platforms => :#{not_local_tag}
- G
- expect(the_bundle).to include_gems "rack 1.0"
- expect(the_bundle).not_to include_gems "nokogiri 1.4.2"
- end
-
- it "installs gems tagged w/ the current platform inline" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "nokogiri", :platform => :#{local_tag}
- G
- expect(the_bundle).to include_gems "nokogiri 1.4.2"
- end
-
- it "doesn't install gems tagged w/ another platform inline" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "nokogiri", :platform => :#{not_local_tag}
- G
- expect(the_bundle).not_to include_gems "nokogiri 1.4.2"
- end
-
- it "does not blow up on sources with all platform-excluded specs" do
- build_git "foo"
-
- install_gemfile <<-G
- platform :#{not_local_tag} do
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- end
- G
-
- bundle :list
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- it "does not attempt to install gems from :rbx when using --local" do
- simulate_platform "ruby"
- simulate_ruby_engine "ruby"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "some_gem", :platform => :rbx
- G
-
- bundle "install --local"
- expect(out).not_to match(/Could not find gem 'some_gem/)
- end
-
- it "does not attempt to install gems from other rubies when using --local" do
- simulate_platform "ruby"
- simulate_ruby_engine "ruby"
- other_ruby_version_tag = RUBY_VERSION =~ /^1\.8/ ? :ruby_19 : :ruby_18
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "some_gem", platform: :#{other_ruby_version_tag}
- G
-
- bundle "install --local"
- expect(out).not_to match(/Could not find gem 'some_gem/)
- end
-
- it "prints a helpful warning when a dependency is unused on any platform" do
- simulate_platform "ruby"
- simulate_ruby_engine "ruby"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby]
- G
-
- bundle! "install"
-
- expect(err).to include <<-O.strip
-The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
- O
- end
-
- context "when disable_platform_warnings is true" do
- before { bundle! "config set disable_platform_warnings true" }
-
- it "does not print the warning when a dependency is unused on any platform" do
- simulate_platform "ruby"
- simulate_ruby_engine "ruby"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby]
- G
-
- bundle! "install"
-
- expect(out).not_to match(/The dependency (.*) will be unused/)
- end
- end
-end
-
-RSpec.describe "when a gem has no architecture" do
- it "still installs correctly" do
- simulate_platform mswin
-
- gemfile <<-G
- # Try to install gem with nil arch
- source "http://localgemserver.test/"
- gem "rcov"
- G
-
- bundle :install, :artifice => "windows"
- expect(the_bundle).to include_gems "rcov 1.0.0"
- end
-end
diff --git a/spec/bundler/install/gemfile/ruby_spec.rb b/spec/bundler/install/gemfile/ruby_spec.rb
deleted file mode 100644
index d1e9fc7e05..0000000000
--- a/spec/bundler/install/gemfile/ruby_spec.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "ruby requirement" do
- def locked_ruby_version
- Bundler::RubyVersion.from_string(Bundler::LockfileParser.new(lockfile).ruby_version)
- end
-
- # As discovered by https://github.com/bundler/bundler/issues/4147, there is
- # no test coverage to ensure that adding a gem is possible with a ruby
- # requirement. This test verifies the fix, committed in bfbad5c5.
- it "allows adding gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "#{RUBY_VERSION}"
- gem "rack"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "#{RUBY_VERSION}"
- gem "rack"
- gem "rack-obama"
- G
-
- expect(exitstatus).to eq(0) if exitstatus
- expect(the_bundle).to include_gems "rack-obama 1.0"
- end
-
- it "allows removing the ruby version requirement" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "~> #{RUBY_VERSION}"
- gem "rack"
- G
-
- expect(lockfile).to include("RUBY VERSION")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(lockfile).not_to include("RUBY VERSION")
- end
-
- it "allows changing the ruby version requirement to something compatible" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby ">= 1.0.0"
- gem "rack"
- G
-
- expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
-
- simulate_ruby_version "5100"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby ">= 1.0.1"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
- end
-
- it "allows changing the ruby version requirement to something incompatible" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby ">= 1.0.0"
- gem "rack"
- G
-
- expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
-
- simulate_ruby_version "5100"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby ">= 5000.0"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(locked_ruby_version.versions).to eq(["5100"])
- end
-
- it "allows requirements with trailing whitespace" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "#{RUBY_VERSION}\\n \t\\n"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "fails gracefully with malformed requirements" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby ">= 0", "-.\\0"
- gem "rack"
- G
-
- expect(err).to include("There was an error parsing") # i.e. DSL error, not error template
- end
-end
diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb
deleted file mode 100644
index 61943ef2e5..0000000000
--- a/spec/bundler/install/gemfile/sources_spec.rb
+++ /dev/null
@@ -1,647 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with gems on multiple sources" do
- # repo1 is built automatically before all of the specs run
- # it contains rack-obama 1.0.0 and rack 0.9.1 & 1.0.0 amongst other gems
-
- context "without source affinity" do
- before do
- # Oh no! Someone evil is trying to hijack rack :(
- # need this to be broken to check for correct source ordering
- build_repo gem_repo3 do
- build_gem "rack", repo3_rack_version do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
- end
- end
-
- context "with multiple toplevel sources", :bundler => "< 3" do
- let(:repo3_rack_version) { "1.0.0" }
-
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo3)}"
- source "#{file_uri_for(gem_repo1)}"
- gem "rack-obama"
- gem "rack"
- G
- end
-
- it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "2" do
- bundle :install
-
- expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(err).to include("Installed from: #{file_uri_for(gem_repo1)}")
- expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
- end
-
- it "fails", :bundler => "3" do
- bundle :install
- expect(err).to include("Each source after the first must include a block")
- expect(exitstatus).to eq(4) if exitstatus
- end
- end
-
- context "when different versions of the same gem are in multiple sources", :bundler => "< 3" do
- let(:repo3_rack_version) { "1.2" }
-
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo3)}"
- source "#{file_uri_for(gem_repo1)}"
- gem "rack-obama"
- gem "rack", "1.0.0" # force it to install the working version in repo1
- G
-
- bundle :install
- end
-
- it "warns about ambiguous gems, but installs anyway", :bundler => "2" do
- expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(err).to include("Installed from: #{file_uri_for(gem_repo1)}")
- expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
- end
-
- it "fails", :bundler => "3" do
- expect(err).to include("Each source after the first must include a block")
- expect(exitstatus).to eq(4) if exitstatus
- end
- end
- end
-
- context "with source affinity" do
- context "with sources given by a block" do
- before do
- # Oh no! Someone evil is trying to hijack rack :(
- # need this to be broken to check for correct source ordering
- build_repo gem_repo3 do
- build_gem "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
-
- build_gem "rack-obama" do |s|
- s.add_dependency "rack"
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo3)}"
- source "#{file_uri_for(gem_repo1)}" do
- gem "thin" # comes first to test name sorting
- gem "rack"
- end
- gem "rack-obama" # shoud come from repo3!
- G
- end
-
- it "installs the gems without any warning" do
- bundle! :install
- expect(out).not_to include("Warning")
- expect(the_bundle).to include_gems("rack-obama 1.0.0")
- expect(the_bundle).to include_gems("rack 1.0.0", :source => "remote1")
- end
-
- it "can cache and deploy" do
- bundle! :cache
-
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/rack-obama-1.0.gem")).to exist
-
- bundle! :install, forgotten_command_line_options(:deployment => true)
-
- expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0")
- end
- end
-
- context "with sources set by an option" do
- before do
- # Oh no! Someone evil is trying to hijack rack :(
- # need this to be broken to check for correct source ordering
- build_repo gem_repo3 do
- build_gem "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
-
- build_gem "rack-obama" do |s|
- s.add_dependency "rack"
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo3)}"
- gem "rack-obama" # should come from repo3!
- gem "rack", :source => "#{file_uri_for(gem_repo1)}"
- G
- end
-
- it "installs the gems without any warning" do
- bundle :install
- expect(out).not_to include("Warning")
- expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0")
- end
- end
-
- context "when a pinned gem has an indirect dependency" do
- before do
- build_repo gem_repo3 do
- build_gem "depends_on_rack", "1.0.1" do |s|
- s.add_dependency "rack"
- end
- end
- end
-
- context "when the indirect dependency is in the pinned source" do
- before do
- # we need a working rack gem in repo3
- update_repo gem_repo3 do
- build_gem "rack", "1.0.0"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- source "#{file_uri_for(gem_repo3)}" do
- gem "depends_on_rack"
- end
- G
- end
-
- context "and not in any other sources" do
- before do
- build_repo(gem_repo2) {}
- end
-
- it "installs from the same source without any warning" do
- bundle :install
- expect(out).not_to include("Warning")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
- end
- end
-
- context "and in another source" do
- before do
- # need this to be broken to check for correct source ordering
- build_repo gem_repo2 do
- build_gem "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
- end
- end
-
- context "when disable_multisource is set" do
- before do
- bundle! "config set disable_multisource true"
- end
-
- it "installs from the same source without any warning" do
- bundle! :install
-
- expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
-
- # when there is already a lock file, and the gems are missing, so try again
- system_gems []
- bundle! :install
-
- expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
- end
- end
- end
- end
-
- context "when the indirect dependency is in a different source" do
- before do
- # In these tests, we need a working rack gem in repo2 and not repo3
- build_repo gem_repo2 do
- build_gem "rack", "1.0.0"
- end
- end
-
- context "and not in any other sources" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- source "#{file_uri_for(gem_repo3)}" do
- gem "depends_on_rack"
- end
- G
- end
-
- it "installs from the other source without any warning" do
- bundle :install
- expect(out).not_to include("Warning")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
- end
- end
-
- context "and in yet another source", :bundler => "< 3" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- source "#{file_uri_for(gem_repo2)}"
- source "#{file_uri_for(gem_repo3)}" do
- gem "depends_on_rack"
- end
- G
-
- bundle :install
- end
-
- it "installs from the other source and warns about ambiguous gems", :bundler => "2" do
- expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(err).to include("Installed from: #{file_uri_for(gem_repo2)}")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
- end
-
- it "fails", :bundler => "3" do
- expect(err).to include("Each source after the first must include a block")
- expect(exitstatus).to eq(4) if exitstatus
- end
- end
-
- context "and only the dependency is pinned", :bundler => "< 3" do
- before do
- # need this to be broken to check for correct source ordering
- build_repo gem_repo2 do
- build_gem "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo3)}" # contains depends_on_rack
- source "#{file_uri_for(gem_repo2)}" # contains broken rack
-
- gem "depends_on_rack" # installed from gem_repo3
- gem "rack", :source => "#{file_uri_for(gem_repo1)}"
- G
- end
-
- it "installs the dependency from the pinned source without warning", :bundler => "2" do
- bundle :install
-
- expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
-
- # In https://github.com/bundler/bundler/issues/3585 this failed
- # when there is already a lock file, and the gems are missing, so try again
- system_gems []
- bundle :install
-
- expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
- end
-
- it "fails", :bundler => "3" do
- bundle :install
- expect(err).to include("Each source after the first must include a block")
- expect(exitstatus).to eq(4) if exitstatus
- end
- end
- end
- end
-
- context "when a top-level gem has an indirect dependency" do
- context "when disable_multisource is set" do
- before do
- bundle! "config set disable_multisource true"
- end
-
- before do
- build_repo gem_repo2 do
- build_gem "depends_on_rack", "1.0.1" do |s|
- s.add_dependency "rack"
- end
- end
-
- build_repo gem_repo3 do
- build_gem "unrelated_gem", "1.0.0"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- gem "depends_on_rack"
-
- source "#{file_uri_for(gem_repo3)}" do
- gem "unrelated_gem"
- end
- G
- end
-
- context "and the dependency is only in the top-level source" do
- before do
- update_repo gem_repo2 do
- build_gem "rack", "1.0.0"
- end
- end
-
- it "installs all gems without warning" do
- bundle :install
- expect(err).not_to include("Warning")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
- end
- end
-
- context "and the dependency is only in a pinned source" do
- before do
- update_repo gem_repo3 do
- build_gem "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
- end
- end
-
- it "does not find the dependency" do
- bundle :install
- expect(err).to include("Could not find gem 'rack', which is required by gem 'depends_on_rack', in any of the relevant sources")
- end
- end
-
- context "and the dependency is in both the top-level and a pinned source" do
- before do
- update_repo gem_repo2 do
- build_gem "rack", "1.0.0"
- end
-
- update_repo gem_repo3 do
- build_gem "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
- end
- end
-
- it "installs the dependency from the top-level source without warning" do
- bundle :install
- expect(err).not_to include("Warning")
- expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
- end
- end
- end
- end
-
- context "with a gem that is only found in the wrong source" do
- before do
- build_repo gem_repo3 do
- build_gem "not_in_repo1", "1.0.0"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo3)}"
- gem "not_in_repo1", :source => "#{file_uri_for(gem_repo1)}"
- G
- end
-
- it "does not install the gem" do
- bundle :install
- expect(err).to include("Could not find gem 'not_in_repo1'")
- end
- end
-
- context "with an existing lockfile" do
- before do
- system_gems "rack-0.9.1", "rack-1.0.0", :path => :bundle_path
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}
- remote: #{file_uri_for(gem_repo3)}
- specs:
- rack (0.9.1)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack!
- L
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- source "#{file_uri_for(gem_repo3)}" do
- gem 'rack'
- end
- G
- end
-
- # Reproduction of https://github.com/bundler/bundler/issues/3298
- it "does not unlock the installed gem on exec" do
- expect(the_bundle).to include_gems("rack 0.9.1")
- end
- end
-
- context "with a path gem in the same Gemfile" do
- before do
- build_lib "foo"
-
- gemfile <<-G
- gem "rack", :source => "#{file_uri_for(gem_repo1)}"
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
- end
-
- it "does not unlock the non-path gem after install" do
- bundle! :install
-
- bundle! %(exec ruby -e 'puts "OK"')
-
- expect(out).to include("OK")
- end
- end
- end
-
- context "when an older version of the same gem also ships with Ruby" do
- before do
- system_gems "rack-0.9.1"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack" # shoud come from repo1!
- G
- end
-
- it "installs the gems without any warning" do
- bundle :install
- expect(err).not_to include("Warning")
- expect(the_bundle).to include_gems("rack 1.0.0")
- end
- end
-
- context "when a single source contains multiple locked gems" do
- before do
- # With these gems,
- build_repo4 do
- build_gem "foo", "0.1"
- build_gem "bar", "0.1"
- end
-
- # Installing this gemfile...
- gemfile <<-G
- source '#{file_uri_for(gem_repo1)}'
- gem 'rack'
- gem 'foo', '~> 0.1', :source => '#{file_uri_for(gem_repo4)}'
- gem 'bar', '~> 0.1', :source => '#{file_uri_for(gem_repo4)}'
- G
-
- bundle! :install, forgotten_command_line_options(:path => "../gems/system")
-
- # And then we add some new versions...
- update_repo4 do
- build_gem "foo", "0.2"
- build_gem "bar", "0.3"
- end
- end
-
- it "allows them to be unlocked separately" do
- # And install this gemfile, updating only foo.
- install_gemfile <<-G
- source '#{file_uri_for(gem_repo1)}'
- gem 'rack'
- gem 'foo', '~> 0.2', :source => '#{file_uri_for(gem_repo4)}'
- gem 'bar', '~> 0.1', :source => '#{file_uri_for(gem_repo4)}'
- G
-
- # It should update foo to 0.2, but not the (locked) bar 0.1
- expect(the_bundle).to include_gems("foo 0.2", "bar 0.1")
- end
- end
-
- context "re-resolving" do
- context "when there is a mix of sources in the gemfile" do
- before do
- build_repo3
- build_lib "path1"
- build_lib "path2"
- build_git "git1"
- build_git "git2"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- source "#{file_uri_for(gem_repo3)}" do
- gem "rack"
- end
-
- gem "path1", :path => "#{lib_path("path1-1.0")}"
- gem "path2", :path => "#{lib_path("path2-1.0")}"
- gem "git1", :git => "#{lib_path("git1-1.0")}"
- gem "git2", :git => "#{lib_path("git2-1.0")}"
- G
- end
-
- it "does not re-resolve" do
- bundle! :install, :verbose => true
- expect(out).to include("using resolution from the lockfile")
- expect(out).not_to include("re-resolving dependencies")
- end
- end
- end
-
- context "when a gem is installed to system gems" do
- before do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- context "and the gemfile changes" do
- it "is still able to find that gem from remote sources" do
- source_uri = file_uri_for(gem_repo1)
- second_uri = file_uri_for(gem_repo4)
-
- build_repo4 do
- build_gem "rack", "2.0.1.1.forked"
- build_gem "thor", "0.19.1.1.forked"
- end
-
- # When this gemfile is installed...
- install_gemfile <<-G
- source "#{source_uri}"
-
- source "#{second_uri}" do
- gem "rack", "2.0.1.1.forked"
- gem "thor"
- end
- gem "rack-obama"
- G
-
- # Then we change the Gemfile by adding a version to thor
- gemfile <<-G
- source "#{source_uri}"
-
- source "#{second_uri}" do
- gem "rack", "2.0.1.1.forked"
- gem "thor", "0.19.1.1.forked"
- end
- gem "rack-obama"
- G
-
- # But we should still be able to find rack 2.0.1.1.forked and install it
- bundle! :install
- end
- end
- end
-
- describe "source changed to one containing a higher version of a dependency" do
- before do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- build_repo2 do
- build_gem "bar"
- end
-
- build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s|
- s.add_dependency "bar", "=1.0.0"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- gemspec :path => "#{tmp.join("gemspec_test")}"
- G
- end
-
- it "keeps the old version", :bundler => "2" do
- expect(the_bundle).to include_gems("rack 1.0.0")
- end
-
- it "installs the higher version in the new repo", :bundler => "3" do
- expect(the_bundle).to include_gems("rack 1.2")
- end
- end
-
- context "when a gem is available from multiple ambiguous sources", :bundler => "3" do
- it "raises, suggesting a source block" do
- build_repo4 do
- build_gem "depends_on_rack" do |s|
- s.add_dependency "rack"
- end
- build_gem "rack"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- source "#{file_uri_for(gem_repo1)}" do
- gem "thin"
- end
- gem "depends_on_rack"
- G
- expect(last_command).to be_failure
- expect(err).to eq strip_whitespace(<<-EOS).strip
- The gem 'rack' was found in multiple relevant sources.
- * rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally
- * rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally
- You must add this gem to the source block for the source you wish it to be installed from.
- EOS
- expect(the_bundle).not_to be_locked
- end
- end
-end
diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb
deleted file mode 100644
index 24b602589f..0000000000
--- a/spec/bundler/install/gemfile/specific_platform_spec.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with specific_platform enabled" do
- before do
- bundle "config set specific_platform true"
-
- build_repo2 do
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5.1")
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5.1") {|s| s.platform = "x86_64-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5.1") {|s| s.platform = "x86-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5.1") {|s| s.platform = "x86-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5.1") {|s| s.platform = "x64-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5.1") {|s| s.platform = "universal-darwin" }
-
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5") {|s| s.platform = "x86_64-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5") {|s| s.platform = "x86-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5") {|s| s.platform = "x64-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5") {|s| s.platform = "x86-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.5")
-
- build_gem("google-protobuf", "3.0.0.alpha.5.0.4") {|s| s.platform = "universal-darwin" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.4") {|s| s.platform = "x86_64-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.4") {|s| s.platform = "x86-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.4") {|s| s.platform = "x86-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.4") {|s| s.platform = "x64-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.4")
-
- build_gem("google-protobuf", "3.0.0.alpha.5.0.3")
- build_gem("google-protobuf", "3.0.0.alpha.5.0.3") {|s| s.platform = "x86_64-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.3") {|s| s.platform = "x86-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.3") {|s| s.platform = "x86-linux" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.3") {|s| s.platform = "x64-mingw32" }
- build_gem("google-protobuf", "3.0.0.alpha.5.0.3") {|s| s.platform = "universal-darwin" }
-
- build_gem("google-protobuf", "3.0.0.alpha.4.0")
- build_gem("google-protobuf", "3.0.0.alpha.3.1.pre")
- build_gem("google-protobuf", "3.0.0.alpha.3")
- build_gem("google-protobuf", "3.0.0.alpha.2.0")
- build_gem("google-protobuf", "3.0.0.alpha.1.1")
- build_gem("google-protobuf", "3.0.0.alpha.1.0")
-
- build_gem("facter", "2.4.6")
- build_gem("facter", "2.4.6") do |s|
- s.platform = "universal-darwin"
- s.add_runtime_dependency "CFPropertyList"
- end
- build_gem("CFPropertyList")
- end
- end
-
- let(:google_protobuf) { <<-G }
- source "#{file_uri_for(gem_repo2)}"
- gem "google-protobuf"
- G
-
- context "when on a darwin machine" do
- before { simulate_platform "x86_64-darwin-15" }
-
- it "locks to both the specific darwin platform and ruby" do
- install_gemfile!(google_protobuf)
- expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")])
- expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin")
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[
- google-protobuf-3.0.0.alpha.5.0.5.1
- google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin
- ])
- end
-
- it "caches both the universal-darwin and ruby gems when --all-platforms is passed" do
- gemfile(google_protobuf)
- bundle! "package --all-platforms"
- expect([cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1"), cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")]).
- to all(exist)
- end
-
- it "uses the platform-specific gem with extra dependencies" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "facter"
- G
-
- expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")])
- expect(the_bundle).to include_gems("facter 2.4.6 universal-darwin", "CFPropertyList 1.0")
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(["CFPropertyList-1.0",
- "facter-2.4.6",
- "facter-2.4.6-universal-darwin"])
- end
-
- context "when adding a platform via lock --add_platform" do
- it "adds the foreign platform" do
- install_gemfile!(google_protobuf)
- bundle! "lock --add-platform=#{x64_mingw}"
-
- expect(the_bundle.locked_gems.platforms).to eq([rb, x64_mingw, pl("x86_64-darwin-15")])
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[
- google-protobuf-3.0.0.alpha.5.0.5.1
- google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin
- google-protobuf-3.0.0.alpha.5.0.5.1-x64-mingw32
- ])
- end
-
- it "falls back on plain ruby when that version doesnt have a platform-specific gem" do
- install_gemfile!(google_protobuf)
- bundle! "lock --add-platform=#{java}"
-
- expect(the_bundle.locked_gems.platforms).to eq([java, rb, pl("x86_64-darwin-15")])
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[
- google-protobuf-3.0.0.alpha.5.0.5.1
- google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin
- ])
- end
- end
- end
-end
diff --git a/spec/bundler/install/gemfile_spec.rb b/spec/bundler/install/gemfile_spec.rb
deleted file mode 100644
index dd08939cb0..0000000000
--- a/spec/bundler/install/gemfile_spec.rb
+++ /dev/null
@@ -1,124 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- context "with duplicated gems" do
- it "will display a warning" do
- install_gemfile <<-G
- gem 'rails', '~> 4.0.0'
- gem 'rails', '~> 4.0.0'
- G
- expect(err).to include("more than once")
- end
- end
-
- context "with --gemfile" do
- it "finds the gemfile" do
- gemfile bundled_app("NotGemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle :install, :gemfile => bundled_app("NotGemfile")
-
- # Specify BUNDLE_GEMFILE for `the_bundle`
- # to retrieve the proper Gemfile
- ENV["BUNDLE_GEMFILE"] = "NotGemfile"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- context "with gemfile set via config" do
- before do
- gemfile bundled_app("NotGemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
- end
- it "uses the gemfile to install" do
- bundle "install"
- bundle "list"
-
- expect(out).to include("rack (1.0.0)")
- end
- it "uses the gemfile while in a subdirectory" do
- bundled_app("subdir").mkpath
- Dir.chdir(bundled_app("subdir")) do
- bundle "install"
- bundle "list"
-
- expect(out).to include("rack (1.0.0)")
- end
- end
- end
-
- context "with deprecated features" do
- before :each do
- in_app_root
- end
-
- it "reports that lib is an invalid option" do
- gemfile <<-G
- gem "rack", :lib => "rack"
- G
-
- bundle :install
- expect(err).to match(/You passed :lib as an option for gem 'rack', but it is invalid/)
- end
- end
-
- context "with engine specified in symbol" do
- it "does not raise any error parsing Gemfile" do
- simulate_ruby_version "2.3.0" do
- simulate_ruby_engine "jruby", "9.1.2.0" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "2.3.0", :engine => :jruby, :engine_version => "9.1.2.0"
- G
-
- expect(out).to match(/Bundle complete!/)
- end
- end
- end
-
- it "installation succeeds" do
- simulate_ruby_version "2.3.0" do
- simulate_ruby_engine "jruby", "9.1.2.0" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "2.3.0", :engine => :jruby, :engine_version => "9.1.2.0"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
- end
-
- context "with a Gemfile containing non-US-ASCII characters" do
- it "reads the Gemfile with the UTF-8 encoding by default" do
- install_gemfile <<-G
- str = "Il était une fois ..."
- puts "The source encoding is: " + str.encoding.name
- G
-
- expect(out).to include("The source encoding is: UTF-8")
- expect(out).not_to include("The source encoding is: ASCII-8BIT")
- expect(out).to include("Bundle complete!")
- end
-
- it "respects the magic encoding comment" do
- # NOTE: This works thanks to #eval interpreting the magic encoding comment
- install_gemfile <<-G
- # encoding: iso-8859-1
- str = "Il #{"\xE9".dup.force_encoding("binary")}tait une fois ..."
- puts "The source encoding is: " + str.encoding.name
- G
-
- expect(out).to include("The source encoding is: ISO-8859-1")
- expect(out).to include("Bundle complete!")
- end
- end
-end
diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb
deleted file mode 100644
index a294b83d1c..0000000000
--- a/spec/bundler/install/gems/compact_index_spec.rb
+++ /dev/null
@@ -1,940 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "compact index api" do
- let(:source_hostname) { "localgemserver.test" }
- let(:source_uri) { "http://#{source_hostname}" }
-
- it "should use the API" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should URI encode gem names" do
- gemfile <<-G
- source "#{source_uri}"
- gem " sinatra"
- G
-
- bundle :install, :artifice => "compact_index"
- expect(err).to include("' sinatra' is not a valid gem name because it contains whitespace.")
- end
-
- it "should handle nested dependencies" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems(
- "rails 2.3.2",
- "actionpack 2.3.2",
- "activerecord 2.3.2",
- "actionmailer 2.3.2",
- "activeresource 2.3.2",
- "activesupport 2.3.2"
- )
- end
-
- it "should handle case sensitivity conflicts" do
- build_repo4 do
- build_gem "rack", "1.0" do |s|
- s.add_runtime_dependency("Rack", "0.1")
- end
- build_gem "Rack", "0.1"
- end
-
- install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
- source "#{source_uri}"
- gem "rack", "1.0"
- gem "Rack", "0.1"
- G
-
- # can't use `include_gems` here since the `require` will conflict on a
- # case-insensitive FS
- run! "Bundler.require; puts Gem.loaded_specs.values_at('rack', 'Rack').map(&:full_name)"
- expect(out).to eq("rack-1.0\nRack-0.1")
- end
-
- it "should handle multiple gem dependencies on the same gem" do
- gemfile <<-G
- source "#{source_uri}"
- gem "net-sftp"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(the_bundle).to include_gems "net-sftp 1.1.1"
- end
-
- it "should use the endpoint when using --deployment" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- bundle! :install, :artifice => "compact_index"
-
- bundle! :install, forgotten_command_line_options(:deployment => true, :path => "vendor/bundle").merge(:artifice => "compact_index")
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles git dependencies that are in rubygems" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- git "#{file_uri_for(lib_path("foo-1.0"))}" do
- gem 'foo'
- end
- G
-
- bundle! :install, :artifice => "compact_index"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "handles git dependencies that are in rubygems using --deployment" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "#{file_uri_for(lib_path("foo-1.0"))}"
- G
-
- bundle! :install, :artifice => "compact_index"
-
- bundle "install --deployment", :artifice => "compact_index"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "doesn't fail if you only have a git gem with no deps when using --deployment" do
- build_git "foo"
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "#{file_uri_for(lib_path("foo-1.0"))}"
- G
-
- bundle "install", :artifice => "compact_index"
- bundle! :install, forgotten_command_line_options(:deployment => true).merge(:artifice => "compact_index")
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "falls back when the API errors out" do
- simulate_platform mswin
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rcov"
- G
-
- bundle! :install, :artifice => "windows"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rcov 1.0.0"
- end
-
- it "falls back when the API URL returns 403 Forbidden" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :verbose => true, :artifice => "compact_index_forbidden"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "falls back when the versions endpoint has a checksum mismatch" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :verbose => true, :artifice => "compact_index_checksum_mismatch"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(out).to include <<-'WARN'
-The checksum of /versions does not match the checksum provided by the server! Something is wrong (local checksum is "\"d41d8cd98f00b204e9800998ecf8427e\"", was expecting "\"123\"").
- WARN
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "falls back when the user's home directory does not exist or is not writable" do
- ENV["HOME"] = tmp("missing_home").to_s
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_host_redirect"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects without Net::HTTP::Persistent" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- FileUtils.mkdir_p lib_path
- File.open(lib_path("disable_net_http_persistent.rb"), "w") do |h|
- h.write <<-H
- module Kernel
- alias require_without_disabled_net_http require
- def require(*args)
- raise LoadError, 'simulated' if args.first == 'openssl' && !caller.grep(/vendored_persistent/).empty?
- require_without_disabled_net_http(*args)
- end
- end
- H
- end
-
- bundle! :install, :artifice => "compact_index_host_redirect", :requires => [lib_path("disable_net_http_persistent.rb")]
- expect(out).to_not match(/Too many redirects/)
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "times out when Bundler::Fetcher redirects too much" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "compact_index_redirects"
- expect(err).to match(/Too many redirects/)
- end
-
- context "when --full-index is specified" do
- it "should use the modern index for install" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --full-index", :artifice => "compact_index"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the modern index for update" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! "update --full-index", :artifice => "compact_index", :all => true
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- it "does not double check for gems that are only installed locally" do
- system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0]
- bundle! "config set --local path.system true"
- ENV["BUNDLER_SPEC_ALL_REQUESTS"] = strip_whitespace(<<-EOS).strip
- #{source_uri}/versions
- #{source_uri}/info/rack
- EOS
-
- install_gemfile! <<-G, :artifice => "compact_index", :verbose => true
- source "#{source_uri}"
- gem "rack"
- G
-
- expect(last_command.stdboth).not_to include "Double checking"
- end
-
- it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- G
-
- bundle! :install, :artifice => "compact_index_extra"
- expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0"
- end
-
- it "fetches again when more dependencies are found in subsequent sources with source blocks" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- install_gemfile! <<-G, :artifice => "compact_index_extra", :verbose => true
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0"
- end
-
- it "fetches gem versions even when those gems are already installed" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack", "1.0.0"
- G
- bundle! :install, :artifice => "compact_index_extra_api"
- expect(the_bundle).to include_gems "rack 1.0.0"
-
- build_repo4 do
- build_gem "rack", "1.2" do |s|
- s.executables = "rackup"
- end
- end
-
- gemfile <<-G
- source "#{source_uri}" do; end
- source "#{source_uri}/extra"
- gem "rack", "1.2"
- G
- bundle! :install, :artifice => "compact_index_extra_api"
- expect(the_bundle).to include_gems "rack 1.2"
- end
-
- it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do
- # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
- # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
- # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
- # repo and installs it.
- build_repo4 do
- build_gem "activesupport", "1.2.0"
- build_gem "somegem", "1.0.0" do |s|
- s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1
- end
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem 'somegem', '1.0.0'
- G
-
- bundle! :install, :artifice => "compact_index_extra_api"
-
- expect(the_bundle).to include_gems "somegem 1.0.0"
- expect(the_bundle).to include_gems "activesupport 1.2.3"
- end
-
- it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 3" do
- # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
- # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
- # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
- # repo and installs it.
- build_repo4 do
- build_gem "activesupport", "1.2.0"
- build_gem "somegem", "1.0.0" do |s|
- s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1
- end
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem 'somegem', '1.0.0'
- end
- G
-
- bundle! :install, :artifice => "compact_index_extra_api"
-
- expect(the_bundle).to include_gems "somegem 1.0.0"
- expect(the_bundle).to include_gems "activesupport 1.2.3"
- end
-
- it "prints API output properly with back deps" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- bundle! :install, :artifice => "compact_index_extra"
-
- expect(out).to include("Fetching gem metadata from http://localgemserver.test/")
- expect(out).to include("Fetching source index from http://localgemserver.test/extra")
- end
-
- it "does not fetch every spec if the index of gems is large when doing back deps" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- build_gem "missing"
- # need to hit the limit
- 1.upto(Bundler::Source::Rubygems::API_REQUEST_LIMIT) do |i|
- build_gem "gem#{i}"
- end
-
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- bundle! :install, :artifice => "compact_index_extra_missing"
- expect(the_bundle).to include_gems "back_deps 1.0"
- end
-
- it "does not fetch every spec if the index of gems is large when doing back deps & everything is the compact index" do
- build_repo4 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- build_gem "missing"
- # need to hit the limit
- 1.upto(Bundler::Source::Rubygems::API_REQUEST_LIMIT) do |i|
- build_gem "gem#{i}"
- end
-
- FileUtils.rm_rf Dir[gem_repo4("gems/foo-*.gem")]
- end
-
- install_gemfile! <<-G, :artifice => "compact_index_extra_api_missing"
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- expect(the_bundle).to include_gem "back_deps 1.0"
- end
-
- it "uses the endpoint if all sources support it" do
- gemfile <<-G
- source "#{source_uri}"
-
- gem 'foo'
- G
-
- bundle! :install, :artifice => "compact_index_api_missing"
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- G
-
- bundle! :install, :artifice => "compact_index_extra"
-
- bundle "install --deployment", :artifice => "compact_index_extra"
- expect(the_bundle).to include_gems "back_deps 1.0"
- end
-
- it "fetches again when more dependencies are found in subsequent sources using --deployment with blocks" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- bundle! :install, :artifice => "compact_index_extra"
-
- bundle "install --deployment", :artifice => "compact_index_extra"
- expect(the_bundle).to include_gems "back_deps 1.0"
- end
-
- it "does not refetch if the only unmet dependency is bundler" do
- gemfile <<-G
- source "#{source_uri}"
-
- gem "bundler_dep"
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- end
-
- it "should install when EndpointSpecification has a bin dir owned by root", :sudo => true do
- sudo "mkdir -p #{system_gem_path("bin")}"
- sudo "chown -R root #{system_gem_path("bin")}"
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
- bundle! :install, :artifice => "compact_index"
- expect(the_bundle).to include_gems "rails 2.3.2"
- end
-
- it "installs the binstubs", :bundler => "< 3" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --binstubs", :artifice => "compact_index"
-
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
-
- it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle", :artifice => "compact_index"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle --no-clean", :artifice => "compact_index"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "prints post_install_messages" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack-obama'
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Post-install message from rack:")
- end
-
- it "should display the post install message for a dependency" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack_middleware'
- G
-
- bundle! :install, :artifice => "compact_index"
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- end
-
- context "when using basic authentication" do
- let(:user) { "user" }
- let(:password) { "pass" }
- let(:basic_auth_source_uri) do
- uri = URI.parse(source_uri)
- uri.user = user
- uri.password = password
-
- uri
- end
-
- it "passes basic authentication details and strips out creds" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic authentication creds for modern index" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "endopint_marshal_fail_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic auth creds when it can't reach the server" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_500"
- expect(out).not_to include("#{user}:#{password}")
- end
-
- it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(err).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not pass the user / password to different hosts on redirect" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_creds_diff_host"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- describe "with authentication details in bundle config" do
- before do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- end
-
- it "reads authentication details by host name from bundle config" do
- bundle "config set #{source_hostname} #{user}:#{password}"
-
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "reads authentication details by full url from bundle config" do
- # The trailing slash is necessary here; Fetcher canonicalizes the URI.
- bundle "config set #{source_uri}/ #{user}:#{password}"
-
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the API" do
- bundle "config set #{source_hostname} #{user}:#{password}"
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "prefers auth supplied in the source uri" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle "config set #{source_hostname} otheruser:wrong"
-
- bundle! :install, :artifice => "compact_index_strict_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "shows instructions if auth is not provided for the source" do
- bundle :install, :artifice => "compact_index_strict_basic_authentication"
- expect(err).to include("bundle config set #{source_hostname} username:password")
- end
-
- it "fails if authentication has already been provided, but failed" do
- bundle "config set #{source_hostname} #{user}:wrong"
-
- bundle :install, :artifice => "compact_index_strict_basic_authentication"
- expect(err).to include("Bad username or password")
- end
- end
-
- describe "with no password" do
- let(:password) { nil }
-
- it "passes basic authentication details" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
-
- context "when ruby is compiled without openssl" do
- before do
- # Install a monkeypatch that reproduces the effects of openssl being
- # missing when the fetcher runs, as happens in real life. The reason
- # we can't just overwrite openssl.rb is that Artifice uses it.
- bundled_app("broken_ssl").mkpath
- bundled_app("broken_ssl/openssl.rb").open("w") do |f|
- f.write <<-RUBY
- raise LoadError, "cannot load such file -- openssl"
- RUBY
- end
- end
-
- it "explains what to do to get it" do
- gemfile <<-G
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install, :env => { "RUBYOPT" => "-I#{bundled_app("broken_ssl")}" }
- expect(err).to include("OpenSSL")
- end
- end
-
- context "when SSL certificate verification fails" do
- it "explains what happened" do
- # Install a monkeypatch that reproduces the effects of openssl raising
- # a certificate validation error when RubyGems tries to connect.
- gemfile <<-G
- class Net::HTTP
- def start
- raise OpenSSL::SSL::SSLError, "certificate verify failed"
- end
- end
-
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install
- expect(err).to match(/could not verify the SSL certificate/i)
- end
- end
-
- context ".gemrc with sources is present" do
- before do
- File.open(home(".gemrc"), "w") do |file|
- file.puts({ :sources => ["https://rubygems.org"] }.to_yaml)
- end
- end
-
- after do
- home(".gemrc").rmtree
- end
-
- it "uses other sources declared in the Gemfile" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
-
- bundle! :install, :artifice => "compact_index_forbidden"
- end
- end
-
- it "performs partial update with a non-empty range" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack', '0.9.1'
- G
-
- # Initial install creates the cached versions file
- bundle! :install, :artifice => "compact_index"
-
- # Update the Gemfile so we can check subsequent install was successful
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack', '1.0.0'
- G
-
- # Second install should make only a partial request to /versions
- bundle! :install, :artifice => "compact_index_partial_update"
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "performs partial update while local cache is updated by another process" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
-
- # Create an empty file to trigger a partial download
- versions = File.join(Bundler.rubygems.user_home, ".bundle", "cache", "compact_index",
- "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", "versions")
- FileUtils.mkdir_p(File.dirname(versions))
- FileUtils.touch(versions)
-
- bundle! :install, :artifice => "compact_index_concurrent_download"
-
- expect(File.read(versions)).to start_with("created_at")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "performs full update of compact index info cache if range is not satisfiable" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack', '0.9.1'
- G
-
- rake_info_path = File.join(Bundler.rubygems.user_home, ".bundle", "cache", "compact_index",
- "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", "info", "rack")
-
- bundle! :install, :artifice => "compact_index"
-
- expected_rack_info_content = File.read(rake_info_path)
-
- # Modify the cache files. We expect them to be reset to the normal ones when we re-run :install
- File.open(rake_info_path, "w") {|f| f << (expected_rack_info_content + "this is different") }
-
- # Update the Gemfile so the next install does its normal things
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack', '1.0.0'
- G
-
- # The cache files now being longer means the requested range is going to be not satisfiable
- # Bundler must end up requesting the whole file to fix things up.
- bundle! :install, :artifice => "compact_index_range_not_satisfiable"
-
- resulting_rack_info_content = File.read(rake_info_path)
-
- expect(resulting_rack_info_content).to eq(expected_rack_info_content)
- end
-
- it "fails gracefully when the source URI has an invalid scheme" do
- install_gemfile <<-G
- source "htps://rubygems.org"
- gem "rack"
- G
- expect(exitstatus).to eq(15) if exitstatus
- expect(err).to end_with(<<-E.strip)
- The request uri `htps://index.rubygems.org/versions` has an invalid scheme (`htps`). Did you mean `http` or `https`?
- E
- end
-
- describe "checksum validation" do
- it "raises when the checksum does not match" do
- install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum"
- source "#{source_uri}"
- gem "rack"
- G
-
- expect(exitstatus).to eq(19) if exitstatus
- expect(err).
- to include("Bundler cannot continue installing rack (1.0.0).").
- and include("The checksum for the downloaded `rack-1.0.0.gem` does not match the checksum given by the server.").
- and include("This means the contents of the downloaded gem is different from what was uploaded to the server, and could be a potential security issue.").
- and include("To resolve this issue:").
- and include("1. delete the downloaded gem located at: `#{default_bundle_path}/gems/rack-1.0.0/rack-1.0.0.gem`").
- and include("2. run `bundle install`").
- and include("If you wish to continue installing the downloaded gem, and are certain it does not pose a security issue despite the mismatching checksum, do the following:").
- and include("1. run `bundle config set disable_checksum_validation true` to turn off checksum verification").
- and include("2. run `bundle install`").
- and match(/\(More info: The expected SHA256 checksum was "#{"ab" * 22}", but the checksum for the downloaded gem was ".+?"\.\)/)
- end
-
- it "raises when the checksum is the wrong length" do
- install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum", :env => { "BUNDLER_SPEC_RACK_CHECKSUM" => "checksum!" }
- source "#{source_uri}"
- gem "rack"
- G
- expect(exitstatus).to eq(5) if exitstatus
- expect(err).to include("The given checksum for rack-1.0.0 (\"checksum!\") is not a valid SHA256 hexdigest nor base64digest")
- end
-
- it "does not raise when disable_checksum_validation is set" do
- bundle! "config set disable_checksum_validation true"
- install_gemfile! <<-G, :artifice => "compact_index_wrong_gem_checksum"
- source "#{source_uri}"
- gem "rack"
- G
- end
- end
-
- it "works when cache dir is world-writable" do
- install_gemfile! <<-G, :artifice => "compact_index"
- File.umask(0000)
- source "#{source_uri}"
- gem "rack"
- G
- end
-
- it "doesn't explode when the API dependencies are wrong" do
- install_gemfile <<-G, :artifice => "compact_index_wrong_dependencies", :env => { "DEBUG" => "true" }
- source "#{source_uri}"
- gem "rails"
- G
- deps = [Gem::Dependency.new("rake", "= 12.3.2"),
- Gem::Dependency.new("actionpack", "= 2.3.2"),
- Gem::Dependency.new("activerecord", "= 2.3.2"),
- Gem::Dependency.new("actionmailer", "= 2.3.2"),
- Gem::Dependency.new("activeresource", "= 2.3.2")]
- expect(out).to include(<<-E.strip).and include("rails-2.3.2 from rubygems remote at #{source_uri}/ has either corrupted API or lockfile dependencies")
-Bundler::APIResponseMismatchError: Downloading rails-2.3.2 revealed dependencies not in the API or the lockfile (#{deps.map(&:to_s).join(", ")}).
-Either installing with `--full-index` or running `bundle update rails` should fix the problem.
- E
- end
-
- it "does not duplicate specs in the lockfile when updating and a dependency is not installed" do
- install_gemfile! <<-G, :artifice => "compact_index"
- source "#{source_uri}" do
- gem "rails"
- gem "activemerchant"
- end
- G
- gem_command! :uninstall, "activemerchant"
- bundle! "update rails", :artifice => "compact_index"
- expect(lockfile.scan(/activemerchant \(/).size).to eq(1)
- end
-end
diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb
deleted file mode 100644
index a8713eb445..0000000000
--- a/spec/bundler/install/gems/dependency_api_spec.rb
+++ /dev/null
@@ -1,760 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "gemcutter's dependency API" do
- let(:source_hostname) { "localgemserver.test" }
- let(:source_uri) { "http://#{source_hostname}" }
-
- it "should use the API" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should URI encode gem names" do
- gemfile <<-G
- source "#{source_uri}"
- gem " sinatra"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(err).to include("' sinatra' is not a valid gem name because it contains whitespace.")
- end
-
- it "should handle nested dependencies" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Fetching gem metadata from #{source_uri}/...")
- expect(the_bundle).to include_gems(
- "rails 2.3.2",
- "actionpack 2.3.2",
- "activerecord 2.3.2",
- "actionmailer 2.3.2",
- "activeresource 2.3.2",
- "activesupport 2.3.2"
- )
- end
-
- it "should handle multiple gem dependencies on the same gem" do
- gemfile <<-G
- source "#{source_uri}"
- gem "net-sftp"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(the_bundle).to include_gems "net-sftp 1.1.1"
- end
-
- it "should use the endpoint when using --deployment" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- bundle :install, :artifice => "endpoint"
-
- bundle! :install, forgotten_command_line_options(:deployment => true, :path => "vendor/bundle").merge(:artifice => "endpoint")
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles git dependencies that are in rubygems" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- git "#{file_uri_for(lib_path("foo-1.0"))}" do
- gem 'foo'
- end
- G
-
- bundle :install, :artifice => "endpoint"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "handles git dependencies that are in rubygems using --deployment" do
- build_git "foo" do |s|
- s.executables = "foobar"
- s.add_dependency "rails", "2.3.2"
- end
-
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "#{file_uri_for(lib_path("foo-1.0"))}"
- G
-
- bundle :install, :artifice => "endpoint"
-
- bundle "install --deployment", :artifice => "endpoint"
-
- expect(the_bundle).to include_gems("rails 2.3.2")
- end
-
- it "doesn't fail if you only have a git gem with no deps when using --deployment" do
- build_git "foo"
- gemfile <<-G
- source "#{source_uri}"
- gem 'foo', :git => "#{file_uri_for(lib_path("foo-1.0"))}"
- G
-
- bundle "install", :artifice => "endpoint"
- bundle! :install, forgotten_command_line_options(:deployment => true).merge(:artifice => "endpoint")
-
- expect(the_bundle).to include_gems("foo 1.0")
- end
-
- it "falls back when the API errors out" do
- simulate_platform mswin
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rcov"
- G
-
- bundle :install, :artifice => "windows"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rcov 1.0.0"
- end
-
- it "falls back when hitting the Gemcutter Dependency Limit" do
- gemfile <<-G
- source "#{source_uri}"
- gem "activesupport"
- gem "actionpack"
- gem "actionmailer"
- gem "activeresource"
- gem "thin"
- gem "rack"
- gem "rails"
- G
- bundle :install, :artifice => "endpoint_fallback"
- expect(out).to include("Fetching source index from #{source_uri}")
-
- expect(the_bundle).to include_gems(
- "activesupport 2.3.2",
- "actionpack 2.3.2",
- "actionmailer 2.3.2",
- "activeresource 2.3.2",
- "activesupport 2.3.2",
- "thin 1.0.0",
- "rack 1.0.0",
- "rails 2.3.2"
- )
- end
-
- it "falls back when Gemcutter API doesn't return proper Marshal format" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :verbose => true, :artifice => "endpoint_marshal_fail"
- expect(out).to include("could not fetch from the dependency API, trying the full index")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "falls back when the API URL returns 403 Forbidden" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :verbose => true, :artifice => "endpoint_api_forbidden"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_host_redirect"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles host redirects without Net::HTTP::Persistent" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- FileUtils.mkdir_p lib_path
- File.open(lib_path("disable_net_http_persistent.rb"), "w") do |h|
- h.write <<-H
- module Kernel
- alias require_without_disabled_net_http require
- def require(*args)
- raise LoadError, 'simulated' if args.first == 'openssl' && !caller.grep(/vendored_persistent/).empty?
- require_without_disabled_net_http(*args)
- end
- end
- H
- end
-
- bundle :install, :artifice => "endpoint_host_redirect", :requires => [lib_path("disable_net_http_persistent.rb")]
- expect(out).to_not match(/Too many redirects/)
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "timeouts when Bundler::Fetcher redirects too much" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_redirect"
- expect(err).to match(/Too many redirects/)
- end
-
- context "when --full-index is specified" do
- it "should use the modern index for install" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --full-index", :artifice => "endpoint"
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the modern index for update" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle! "update --full-index", :artifice => "endpoint", :all => true
- expect(out).to include("Fetching source index from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- G
-
- bundle :install, :artifice => "endpoint_extra"
- expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0"
- end
-
- it "fetches again when more dependencies are found in subsequent sources using blocks" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- bundle :install, :artifice => "endpoint_extra"
- expect(the_bundle).to include_gems "back_deps 1.0", "foo 1.0"
- end
-
- it "fetches gem versions even when those gems are already installed" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack", "1.0.0"
- G
- bundle :install, :artifice => "endpoint_extra_api"
-
- build_repo4 do
- build_gem "rack", "1.2" do |s|
- s.executables = "rackup"
- end
- end
-
- gemfile <<-G
- source "#{source_uri}" do; end
- source "#{source_uri}/extra"
- gem "rack", "1.2"
- G
- bundle :install, :artifice => "endpoint_extra_api"
- expect(the_bundle).to include_gems "rack 1.2"
- end
-
- it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do
- # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
- # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
- # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
- # repo and installs it.
- build_repo4 do
- build_gem "activesupport", "1.2.0"
- build_gem "somegem", "1.0.0" do |s|
- s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1
- end
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem 'somegem', '1.0.0'
- G
-
- bundle! :install, :artifice => "endpoint_extra_api"
-
- expect(the_bundle).to include_gems "somegem 1.0.0"
- expect(the_bundle).to include_gems "activesupport 1.2.3"
- end
-
- it "considers all possible versions of dependencies from all api gem sources using blocks" do
- # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
- # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
- # of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
- # repo and installs it.
- build_repo4 do
- build_gem "activesupport", "1.2.0"
- build_gem "somegem", "1.0.0" do |s|
- s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1
- end
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem 'somegem', '1.0.0'
- end
- G
-
- bundle :install, :artifice => "endpoint_extra_api"
-
- expect(the_bundle).to include_gems "somegem 1.0.0"
- expect(the_bundle).to include_gems "activesupport 1.2.3"
- end
-
- it "prints API output properly with back deps" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- bundle :install, :artifice => "endpoint_extra"
-
- expect(out).to include("Fetching gem metadata from http://localgemserver.test/.")
- expect(out).to include("Fetching source index from http://localgemserver.test/extra")
- end
-
- it "does not fetch every spec if the index of gems is large when doing back deps", :bundler => "< 3" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- build_gem "missing"
- # need to hit the limit
- 1.upto(Bundler::Source::Rubygems::API_REQUEST_LIMIT) do |i|
- build_gem "gem#{i}"
- end
-
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- G
-
- bundle :install, :artifice => "endpoint_extra_missing"
- expect(the_bundle).to include_gems "back_deps 1.0"
- end
-
- it "does not fetch every spec if the index of gems is large when doing back deps using blocks" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- build_gem "missing"
- # need to hit the limit
- 1.upto(Bundler::Source::Rubygems::API_REQUEST_LIMIT) do |i|
- build_gem "gem#{i}"
- end
-
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- bundle :install, :artifice => "endpoint_extra_missing"
- expect(the_bundle).to include_gems "back_deps 1.0"
- end
-
- it "uses the endpoint if all sources support it" do
- gemfile <<-G
- source "#{source_uri}"
-
- gem 'foo'
- G
-
- bundle :install, :artifice => "endpoint_api_missing"
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra"
- gem "back_deps"
- G
-
- bundle :install, :artifice => "endpoint_extra"
-
- bundle "install --deployment", :artifice => "endpoint_extra"
- expect(the_bundle).to include_gems "back_deps 1.0"
- end
-
- it "fetches again when more dependencies are found in subsequent sources using --deployment with blocks" do
- build_repo2 do
- build_gem "back_deps" do |s|
- s.add_dependency "foo"
- end
- FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
- end
-
- gemfile <<-G
- source "#{source_uri}"
- source "#{source_uri}/extra" do
- gem "back_deps"
- end
- G
-
- bundle :install, :artifice => "endpoint_extra"
-
- bundle "install --deployment", :artifice => "endpoint_extra"
- expect(the_bundle).to include_gems "back_deps 1.0"
- end
-
- it "does not refetch if the only unmet dependency is bundler" do
- gemfile <<-G
- source "#{source_uri}"
-
- gem "bundler_dep"
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- end
-
- it "should install when EndpointSpecification has a bin dir owned by root", :sudo => true do
- sudo "mkdir -p #{system_gem_path("bin")}"
- sudo "chown -R root #{system_gem_path("bin")}"
-
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
- bundle :install, :artifice => "endpoint"
- expect(the_bundle).to include_gems "rails 2.3.2"
- end
-
- it "installs the binstubs", :bundler => "< 3" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --binstubs", :artifice => "endpoint"
-
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
-
- it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle", :artifice => "endpoint"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
-
- bundle "install --path vendor/bundle --no-clean", :artifice => "endpoint"
-
- expect(vendored_gems("bin/rackup")).to exist
- end
-
- it "prints post_install_messages" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack-obama'
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Post-install message from rack:")
- end
-
- it "should display the post install message for a dependency" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack_middleware'
- G
-
- bundle :install, :artifice => "endpoint"
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- end
-
- context "when using basic authentication" do
- let(:user) { "user" }
- let(:password) { "pass" }
- let(:basic_auth_source_uri) do
- uri = URI.parse(source_uri)
- uri.user = user
- uri.password = password
-
- uri
- end
-
- it "passes basic authentication details and strips out creds" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic authentication creds for modern index" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endopint_marshal_fail_basic_authentication"
- expect(out).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "strips http basic auth creds when it can't reach the server" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_500"
- expect(out).not_to include("#{user}:#{password}")
- end
-
- it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_basic_authentication"
- expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(err).not_to include("#{user}:#{password}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not pass the user / password to different hosts on redirect" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_creds_diff_host"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- describe "with authentication details in bundle config" do
- before do
- gemfile <<-G
- source "#{source_uri}"
- gem "rack"
- G
- end
-
- it "reads authentication details by host name from bundle config" do
- bundle "config set #{source_hostname} #{user}:#{password}"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "reads authentication details by full url from bundle config" do
- # The trailing slash is necessary here; Fetcher canonicalizes the URI.
- bundle "config set #{source_uri}/ #{user}:#{password}"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
-
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "should use the API" do
- bundle "config set #{source_hostname} #{user}:#{password}"
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(out).to include("Fetching gem metadata from #{source_uri}")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "prefers auth supplied in the source uri" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle "config set #{source_hostname} otheruser:wrong"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "shows instructions if auth is not provided for the source" do
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(err).to include("bundle config set #{source_hostname} username:password")
- end
-
- it "fails if authentication has already been provided, but failed" do
- bundle "config set #{source_hostname} #{user}:wrong"
-
- bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(err).to include("Bad username or password")
- end
- end
-
- describe "with no password" do
- let(:password) { nil }
-
- it "passes basic authentication details" do
- gemfile <<-G
- source "#{basic_auth_source_uri}"
- gem "rack"
- G
-
- bundle :install, :artifice => "endpoint_basic_authentication"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
-
- context "when ruby is compiled without openssl" do
- before do
- # Install a monkeypatch that reproduces the effects of openssl being
- # missing when the fetcher runs, as happens in real life. The reason
- # we can't just overwrite openssl.rb is that Artifice uses it.
- bundled_app("broken_ssl").mkpath
- bundled_app("broken_ssl/openssl.rb").open("w") do |f|
- f.write <<-RUBY
- raise LoadError, "cannot load such file -- openssl"
- RUBY
- end
- end
-
- it "explains what to do to get it" do
- gemfile <<-G
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install, :env => { "RUBYOPT" => "-I#{bundled_app("broken_ssl")}" }
- expect(err).to include("OpenSSL")
- end
- end
-
- context "when SSL certificate verification fails" do
- it "explains what happened" do
- # Install a monkeypatch that reproduces the effects of openssl raising
- # a certificate validation error when RubyGems tries to connect.
- gemfile <<-G
- class Net::HTTP
- def start
- raise OpenSSL::SSL::SSLError, "certificate verify failed"
- end
- end
-
- source "#{source_uri.gsub(/http/, "https")}"
- gem "rack"
- G
-
- bundle :install
- expect(err).to match(/could not verify the SSL certificate/i)
- end
- end
-
- context ".gemrc with sources is present" do
- before do
- File.open(home(".gemrc"), "w") do |file|
- file.puts({ :sources => ["https://rubygems.org"] }.to_yaml)
- end
- end
-
- after do
- home(".gemrc").rmtree
- end
-
- it "uses other sources declared in the Gemfile" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
-
- bundle "install", :artifice => "endpoint_marshal_fail"
-
- expect(exitstatus).to eq(0) if exitstatus
- end
- end
-end
diff --git a/spec/bundler/install/gems/env_spec.rb b/spec/bundler/install/gems/env_spec.rb
deleted file mode 100644
index a6dfadcfc8..0000000000
--- a/spec/bundler/install/gems/env_spec.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with ENV conditionals" do
- describe "when just setting an ENV key as a string" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- env "BUNDLER_TEST" do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set" do
- ENV["BUNDLER_TEST"] = "1"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when just setting an ENV key as a symbol" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- env :BUNDLER_TEST do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set" do
- ENV["BUNDLER_TEST"] = "1"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when setting a string to match the env" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- env "BUNDLER_TEST" => "foo" do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "excludes the gems when the ENV variable is set but does not match the condition" do
- ENV["BUNDLER_TEST"] = "1"
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set and matches the condition" do
- ENV["BUNDLER_TEST"] = "foo"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when setting a regex to match the env" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- env "BUNDLER_TEST" => /foo/ do
- gem "rack"
- end
- G
- end
-
- it "excludes the gems when the ENV variable is not set" do
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "excludes the gems when the ENV variable is set but does not match the condition" do
- ENV["BUNDLER_TEST"] = "fo"
- bundle :install
- expect(the_bundle).not_to include_gems "rack"
- end
-
- it "includes the gems when the ENV variable is set and matches the condition" do
- ENV["BUNDLER_TEST"] = "foobar"
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-end
diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb
deleted file mode 100644
index 865bc7b72a..0000000000
--- a/spec/bundler/install/gems/flex_spec.rb
+++ /dev/null
@@ -1,353 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle flex_install" do
- it "installs the gems as expected" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).to be_locked
- end
-
- it "installs even when the lockfile is invalid" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).to be_locked
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack', '1.0'
- G
-
- bundle :install
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).to be_locked
- end
-
- it "keeps child dependencies at the same version" do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack-obama"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0"
-
- update_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack-obama", "1.0"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0"
- end
-
- describe "adding new gems" do
- it "installs added gems without updating previously installed gems" do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack'
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack'
- gem 'activesupport', '2.3.5'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
- end
-
- it "keeps child dependencies pinned" do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack-obama"
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack-obama"
- gem "thin"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0", "thin 1.0"
- end
- end
-
- describe "removing gems" do
- it "removes gems without changing the versions of remaining gems" do
- build_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack'
- gem 'activesupport', '2.3.5'
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack'
- gem 'activesupport', '2.3.2'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.2"
- end
-
- it "removes top level dependencies when removed from the Gemfile while leaving other dependencies intact" do
- build_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack'
- gem 'activesupport', '2.3.5'
- G
-
- update_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack'
- G
-
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- end
-
- it "removes child dependencies" do
- build_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'rack-obama'
- gem 'activesupport'
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0", "activesupport 2.3.5"
-
- update_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'activesupport'
- G
-
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- expect(the_bundle).not_to include_gems "rack-obama", "rack"
- end
- end
-
- describe "when Gemfile conflicts with lockfile" do
- before(:each) do
- build_repo2
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack_middleware"
- G
-
- expect(the_bundle).to include_gems "rack_middleware 1.0", "rack 0.9.1"
-
- build_repo2
- update_repo2 do
- build_gem "rack-obama", "2.0" do |s|
- s.add_dependency "rack", "=1.2"
- end
- build_gem "rack_middleware", "2.0" do |s|
- s.add_dependency "rack", ">=1.0"
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack-obama", "2.0"
- gem "rack_middleware"
- G
- end
-
- it "does not install gems whose dependencies are not met" do
- bundle :install
- ruby <<-RUBY
- require 'bundler/setup'
- RUBY
- expect(err).to match(/could not find gem 'rack-obama/i)
- end
-
- it "suggests bundle update when the Gemfile requires different versions than the lock" do
- bundle "config set force_ruby_platform true"
-
- nice_error = <<-E.strip.gsub(/^ {8}/, "")
- Bundler could not find compatible versions for gem "rack":
- In snapshot (Gemfile.lock):
- rack (= 0.9.1)
-
- In Gemfile:
- rack-obama (= 2.0) was resolved to 2.0, which depends on
- rack (= 1.2)
-
- rack_middleware was resolved to 1.0, which depends on
- rack (= 0.9.1)
-
- Running `bundle update` will rebuild your snapshot from scratch, using only
- the gems in your Gemfile, which may resolve the conflict.
- E
-
- bundle :install, :retry => 0
- expect(err).to end_with(nice_error)
- end
- end
-
- describe "subtler cases" do
- before :each do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "rack-obama"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- gem "rack-obama"
- G
- end
-
- it "does something" do
- expect do
- bundle "install"
- end.not_to change { File.read(bundled_app("Gemfile.lock")) }
-
- expect(err).to include("rack = 0.9.1")
- expect(err).to include("locked at 1.0.0")
- expect(err).to include("bundle update rack")
- end
-
- it "should work when you update" do
- bundle "update rack"
- end
- end
-
- describe "when adding a new source" do
- it "updates the lockfile", :bundler => "< 3" do
- build_repo2
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- G
-
- lockfile_should_be <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-
- it "updates the lockfile", :bundler => "3" do
- build_repo2
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- source "#{file_uri_for(gem_repo2)}" do
- end
- gem "rack"
- G
-
- lockfile_should_be <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- # This was written to test github issue #636
- describe "when a locked child dependency conflicts" do
- before(:each) do
- build_repo2 do
- build_gem "capybara", "0.3.9" do |s|
- s.add_dependency "rack", ">= 1.0.0"
- end
-
- build_gem "rack", "1.1.0"
- build_gem "rails", "3.0.0.rc4" do |s|
- s.add_dependency "rack", "~> 1.1.0"
- end
-
- build_gem "rack", "1.2.1"
- build_gem "rails", "3.0.0" do |s|
- s.add_dependency "rack", "~> 1.2.1"
- end
- end
- end
-
- it "prints the correct error message" do
- # install Rails 3.0.0.rc
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0.0.rc4"
- gem "capybara", "0.3.9"
- G
-
- # upgrade Rails to 3.0.0 and then install again
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rails", "3.0.0"
- gem "capybara", "0.3.9"
- G
-
- expect(err).to include("Gemfile.lock")
- end
- end
-end
diff --git a/spec/bundler/install/gems/mirror_spec.rb b/spec/bundler/install/gems/mirror_spec.rb
deleted file mode 100644
index 9611973701..0000000000
--- a/spec/bundler/install/gems/mirror_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with a mirror configured" do
- describe "when the mirror does not match the gem source" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
- bundle "config set --local mirror.http://gems.example.org http://gem-mirror.example.org"
- end
-
- it "installs from the normal location" do
- bundle :install
- expect(out).to include("Fetching source index from #{file_uri_for(gem_repo1)}")
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- describe "when the gem source matches a configured mirror" do
- before :each do
- gemfile <<-G
- # This source is bogus and doesn't have the gem we're looking for
- source "#{file_uri_for(gem_repo2)}"
-
- gem "rack"
- G
- bundle "config set --local mirror.#{file_uri_for(gem_repo2)} #{file_uri_for(gem_repo1)}"
- end
-
- it "installs the gem from the mirror" do
- bundle :install
- expect(out).to include("Fetching source index from #{file_uri_for(gem_repo1)}")
- expect(out).not_to include("Fetching source index from #{file_uri_for(gem_repo2)}")
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-end
diff --git a/spec/bundler/install/gems/native_extensions_spec.rb b/spec/bundler/install/gems/native_extensions_spec.rb
deleted file mode 100644
index 3e59a3cebd..0000000000
--- a/spec/bundler/install/gems/native_extensions_spec.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "installing a gem with native extensions", :ruby_repo do
- it "installs" do
- build_repo2 do
- build_gem "c_extension" do |s|
- s.extensions = ["ext/extconf.rb"]
- s.write "ext/extconf.rb", <<-E
- require "mkmf"
- name = "c_extension_bundle"
- dir_config(name)
- raise "OMG" unless with_config("c_extension") == "hello"
- create_makefile(name)
- E
-
- s.write "ext/c_extension.c", <<-C
- #include "ruby.h"
-
- VALUE c_extension_true(VALUE self) {
- return Qtrue;
- }
-
- void Init_c_extension_bundle() {
- VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
- rb_define_method(c_Extension, "its_true", c_extension_true, 0);
- }
- C
-
- s.write "lib/c_extension.rb", <<-C
- require "c_extension_bundle"
- C
- end
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "c_extension"
- G
-
- bundle "config set build.c_extension --with-c_extension=hello"
- bundle "install"
-
- expect(out).not_to include("extconf.rb failed")
- expect(out).to include("Installing c_extension 1.0 with native extensions")
-
- run "Bundler.require; puts CExtension.new.its_true"
- expect(out).to eq("true")
- end
-
- it "installs from git" do
- build_git "c_extension" do |s|
- s.extensions = ["ext/extconf.rb"]
- s.write "ext/extconf.rb", <<-E
- require "mkmf"
- name = "c_extension_bundle"
- dir_config(name)
- raise "OMG" unless with_config("c_extension") == "hello"
- create_makefile(name)
- E
-
- s.write "ext/c_extension.c", <<-C
- #include "ruby.h"
-
- VALUE c_extension_true(VALUE self) {
- return Qtrue;
- }
-
- void Init_c_extension_bundle() {
- VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
- rb_define_method(c_Extension, "its_true", c_extension_true, 0);
- }
- C
-
- s.write "lib/c_extension.rb", <<-C
- require "c_extension_bundle"
- C
- end
-
- bundle! "config set build.c_extension --with-c_extension=hello"
-
- install_gemfile! <<-G
- gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
- G
-
- expect(out).not_to include("extconf.rb failed")
-
- run! "Bundler.require; puts CExtension.new.its_true"
- expect(out).to eq("true")
- end
-
- it "install with multiple build flags" do
- build_git "c_extension" do |s|
- s.extensions = ["ext/extconf.rb"]
- s.write "ext/extconf.rb", <<-E
- require "mkmf"
- name = "c_extension_bundle"
- dir_config(name)
- raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola"
- create_makefile(name)
- E
-
- s.write "ext/c_extension.c", <<-C
- #include "ruby.h"
-
- VALUE c_extension_true(VALUE self) {
- return Qtrue;
- }
-
- void Init_c_extension_bundle() {
- VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
- rb_define_method(c_Extension, "its_true", c_extension_true, 0);
- }
- C
-
- s.write "lib/c_extension.rb", <<-C
- require "c_extension_bundle"
- C
- end
-
- bundle! "config set build.c_extension --with-c_extension=hello --with-c_extension_bundle-dir=hola"
-
- install_gemfile! <<-G
- gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
- G
-
- expect(out).not_to include("extconf.rb failed")
-
- run! "Bundler.require; puts CExtension.new.its_true"
- expect(out).to eq("true")
- end
-end
diff --git a/spec/bundler/install/gems/post_install_spec.rb b/spec/bundler/install/gems/post_install_spec.rb
deleted file mode 100644
index 3f6d7ce42c..0000000000
--- a/spec/bundler/install/gems/post_install_spec.rb
+++ /dev/null
@@ -1,150 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- context "with gem sources" do
- context "when gems include post install messages" do
- it "should display the post-install messages after installing" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- gem 'thin'
- gem 'rack-obama'
- G
-
- bundle :install
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- expect(out).to include("Post-install message from thin:")
- expect(out).to include("Thin's post install message")
- expect(out).to include("Post-install message from rack-obama:")
- expect(out).to include("Rack-obama's post install message")
- end
- end
-
- context "when gems do not include post install messages" do
- it "should not display any post-install messages" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
- G
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-
- context "when a dependecy includes a post install message" do
- it "should display the post install message" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack_middleware'
- G
-
- bundle :install
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- end
- end
- end
-
- context "with git sources" do
- context "when gems include post install messages" do
- it "should display the post-install messages after installing" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
- end
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :install
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's post install message")
- end
-
- it "should display the post-install messages if repo is updated" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
- end
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
- bundle :install
-
- build_git "foo", "1.1" do |s|
- s.post_install_message = "Foo's 1.1 post install message"
- end
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'foo', :git => '#{lib_path("foo-1.1")}'
- G
- bundle :install
-
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's 1.1 post install message")
- end
-
- it "should not display the post-install messages if repo is not updated" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
- end
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :install
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's post install message")
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-
- context "when gems do not include post install messages" do
- it "should not display any post-install messages" do
- build_git "foo" do |s|
- s.post_install_message = nil
- end
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
- end
-
- context "when ignore post-install messages for gem is set" do
- it "doesn't display any post-install messages" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "config set ignore_messages.rack true"
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-
- context "when ignore post-install messages for all gems" do
- it "doesn't display any post-install messages" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "config set ignore_messages true"
-
- bundle :install
- expect(out).not_to include("Post-install message")
- end
- end
-end
diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb
deleted file mode 100644
index 52511ff67f..0000000000
--- a/spec/bundler/install/gems/resolving_spec.rb
+++ /dev/null
@@ -1,214 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with install-time dependencies" do
- it "installs gems with implicit rake dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "with_implicit_rake_dep"
- gem "another_implicit_rake_dep"
- gem "rake"
- G
-
- run <<-R
- require 'implicit_rake_dep'
- require 'another_implicit_rake_dep'
- puts IMPLICIT_RAKE_DEP
- puts ANOTHER_IMPLICIT_RAKE_DEP
- R
- expect(out).to eq("YES\nYES")
- end
-
- it "installs gems with a dependency with no type" do
- build_repo2
-
- path = "#{gem_repo2}/#{Gem::MARSHAL_SPEC_DIR}/actionpack-2.3.2.gemspec.rz"
- spec = Marshal.load(Bundler.rubygems.inflate(File.binread(path)))
- spec.dependencies.each do |d|
- d.instance_variable_set(:@type, :fail)
- end
- File.open(path, "w") do |f|
- f.write Gem.deflate(Marshal.dump(spec))
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "actionpack", "2.3.2"
- G
-
- expect(the_bundle).to include_gems "actionpack 2.3.2", "activesupport 2.3.2"
- end
-
- describe "with crazy rubygem plugin stuff" do
- it "installs plugins" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "net_b"
- G
-
- expect(the_bundle).to include_gems "net_b 1.0"
- end
-
- it "installs plugins depended on by other plugins" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "net_a"
- G
-
- expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0"
- end
-
- it "installs multiple levels of dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "net_c"
- gem "net_e"
- G
-
- expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0", "net_c 1.0", "net_d 1.0", "net_e 1.0"
- end
-
- context "with ENV['DEBUG_RESOLVER'] set" do
- it "produces debug output" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "net_c"
- gem "net_e"
- G
-
- bundle :install, :env => { "DEBUG_RESOLVER" => "1" }
-
- expect(err).to include("Creating possibility state for net_c")
- end
- end
-
- context "with ENV['DEBUG_RESOLVER_TREE'] set" do
- it "produces debug output" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "net_c"
- gem "net_e"
- G
-
- bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
-
- expect(err).to include(" net_b").
- and include("Starting resolution").
- and include("Finished resolution").
- and include("Attempting to activate")
- end
- end
- end
-
- describe "when a required ruby version" do
- context "allows only an older version" do
- it "installs the older version" do
- build_repo2 do
- build_gem "rack", "9001.0.0" do |s|
- s.required_ruby_version = "> 9000"
- end
- end
-
- install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
- ruby "#{RUBY_VERSION}"
- source "http://localgemserver.test/"
- gem 'rack'
- G
-
- expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
- expect(the_bundle).to include_gems("rack 1.2")
- end
-
- it "installs the older version under rate limiting conditions" do
- build_repo4 do
- build_gem "rack", "9001.0.0" do |s|
- s.required_ruby_version = "> 9000"
- end
- build_gem "rack", "1.2"
- build_gem "foo1", "1.0"
- end
-
- install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
- ruby "#{RUBY_VERSION}"
- source "http://localgemserver.test/"
- gem 'rack'
- gem 'foo1'
- G
-
- expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
- expect(the_bundle).to include_gems("rack 1.2")
- end
- end
-
- context "allows no gems" do
- before do
- build_repo2 do
- build_gem "require_ruby" do |s|
- s.required_ruby_version = "> 9000"
- end
- end
- end
-
- let(:ruby_requirement) { %("#{RUBY_VERSION}") }
- let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" }
-
- shared_examples_for "ruby version conflicts" do
- it "raises an error during resolution" do
- install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
- source "http://localgemserver.test/"
- ruby #{ruby_requirement}
- gem 'require_ruby'
- G
-
- expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")
-
- nice_error = strip_whitespace(<<-E).strip
- Bundler found conflicting requirements for the Ruby\0 version:
- In Gemfile:
- Ruby\0 (#{error_message_requirement})
-
- require_ruby was resolved to 1.0, which depends on
- Ruby\0 (> 9000)
-
- Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
- E
- expect(err).to end_with(nice_error)
- end
- end
-
- it_behaves_like "ruby version conflicts"
-
- describe "with a < requirement" do
- let(:ruby_requirement) { %("< 5000") }
- let(:error_message_requirement) { "< 5000" }
-
- it_behaves_like "ruby version conflicts"
- end
-
- describe "with a compound requirement" do
- let(:reqs) { ["> 0.1", "< 5000"] }
- let(:ruby_requirement) { reqs.map(&:dump).join(", ") }
- let(:error_message_requirement) { Gem::Requirement.new(reqs).to_s }
-
- it_behaves_like "ruby version conflicts"
- end
- end
- end
-
- describe "when a required rubygems version disallows a gem" do
- it "does not try to install those gems" do
- build_repo2 do
- build_gem "require_rubygems" do |s|
- s.required_rubygems_version = "> 9000"
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem 'require_rubygems'
- G
-
- expect(err).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
- expect(err).to include("require_rubygems-1.0 requires rubygems version > 9000, which is incompatible with the current version, #{Gem::VERSION}")
- end
- end
-end
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
deleted file mode 100644
index f1d5c8b505..0000000000
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ /dev/null
@@ -1,337 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.shared_examples "bundle install --standalone" do
- shared_examples "common functionality" do
- it "still makes the gems available to normal bundler" do
- args = expected_gems.map {|k, v| "#{k} #{v}" }
- expect(the_bundle).to include_gems(*args)
- end
-
- it "generates a bundle/bundler/setup.rb" do
- expect(bundled_app("bundle/bundler/setup.rb")).to exist
- end
-
- it "makes the gems available without bundler" do
- testrb = String.new <<-RUBY
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- RUBY
- expected_gems.each do |k, _|
- testrb << "\nrequire \"#{k}\""
- testrb << "\nputs #{k.upcase}"
- end
- Dir.chdir(bundled_app) do
- ruby testrb, :no_lib => true
- end
-
- expect(out).to eq(expected_gems.values.join("\n"))
- end
-
- it "works on a different system" do
- FileUtils.mv(bundled_app, "#{bundled_app}2")
-
- testrb = String.new <<-RUBY
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- RUBY
- expected_gems.each do |k, _|
- testrb << "\nrequire \"#{k}\""
- testrb << "\nputs #{k.upcase}"
- end
- Dir.chdir("#{bundled_app}2") do
- ruby testrb, :no_lib => true
- end
-
- expect(out).to eq(expected_gems.values.join("\n"))
- end
- end
-
- describe "with simple gems" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
- end
-
- let(:expected_gems) do
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
- end
-
- describe "with gems with native extension", :ruby_repo do
- before do
- install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
- source "#{file_uri_for(gem_repo1)}"
- gem "very_simple_binary"
- G
- end
-
- it "generates a bundle/bundler/setup.rb with the proper paths" do
- expected_path = bundled_app("bundle/bundler/setup.rb")
- extension_line = File.read(expected_path).each_line.find {|line| line.include? "/extensions/" }.strip
- expect(extension_line).to start_with '$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/'
- expect(extension_line).to end_with '/very_simple_binary-1.0"'
- end
- end
-
- describe "with gem that has an invalid gemspec" do
- before do
- build_git "bar", :gemspec => false do |s|
- s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0')
- s.write "bar.gemspec", <<-G
- lib = File.expand_path('../lib/', __FILE__)
- $:.unshift lib unless $:.include?(lib)
- require 'bar/version'
-
- Gem::Specification.new do |s|
- s.name = 'bar'
- s.version = BAR_VERSION
- s.summary = 'Bar'
- s.files = Dir["lib/**/*.rb"]
- s.author = 'Anonymous'
- s.require_path = [1,2]
- end
- G
- end
- install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
- gem "bar", :git => "#{lib_path("bar-1.0")}"
- G
- end
-
- it "outputs a helpful error message" do
- expect(err).to include("You have one or more invalid gemspecs that need to be fixed.")
- expect(err).to include("bar 1.0 has an invalid gemspec")
- end
- end
-
- describe "with a combination of gems and git repos" do
- before do
- build_git "devise", "1.0"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- gem "devise", :git => "#{lib_path("devise-1.0")}"
- G
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
- end
-
- let(:expected_gems) do
- {
- "actionpack" => "2.3.2",
- "devise" => "1.0",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
- end
-
- describe "with groups" do
- before do
- build_git "devise", "1.0"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- group :test do
- gem "rspec"
- gem "rack-test"
- end
- G
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
- end
-
- let(:expected_gems) do
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
-
- it "allows creating a standalone file with limited groups" do
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => "default")
-
- Dir.chdir(bundled_app) do
- load_error_ruby <<-RUBY, "spec", :no_lib => true
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- require "spec"
- RUBY
- end
-
- expect(out).to eq("2.3.2")
- expect(err).to eq("ZOMG LOAD ERROR")
- end
-
- it "allows --without to limit the groups used in a standalone" do
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle"), :without => "test").merge(:standalone => true)
-
- Dir.chdir(bundled_app) do
- load_error_ruby <<-RUBY, "spec", :no_lib => true
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- require "spec"
- RUBY
- end
-
- expect(out).to eq("2.3.2")
- expect(err).to eq("ZOMG LOAD ERROR")
- end
-
- it "allows --path to change the location of the standalone bundle", :bundler => "< 3" do
- bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true)
-
- Dir.chdir(bundled_app) do
- ruby <<-RUBY, :no_lib => true
- $:.unshift File.expand_path("path/to/bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- RUBY
- end
-
- expect(out).to eq("2.3.2")
- end
-
- it "allows --path to change the location of the standalone bundle", :bundler => "3" do
- bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true)
- path = File.expand_path("path/to/bundle")
-
- Dir.chdir(bundled_app) do
- ruby <<-RUBY, :no_lib => true
- $:.unshift File.expand_path(#{path.dump})
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- RUBY
- end
-
- expect(out).to eq("2.3.2")
- end
-
- it "allows remembered --without to limit the groups used in a standalone" do
- bundle! :install, forgotten_command_line_options(:without => "test")
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true)
-
- Dir.chdir(bundled_app) do
- load_error_ruby <<-RUBY, "spec", :no_lib => true
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- require "actionpack"
- puts ACTIONPACK
- require "spec"
- RUBY
- end
-
- expect(out).to eq("2.3.2")
- expect(err).to eq("ZOMG LOAD ERROR")
- end
- end
-
- describe "with gemcutter's dependency API" do
- let(:source_uri) { "http://localgemserver.test" }
-
- describe "simple gems" do
- before do
- gemfile <<-G
- source "#{source_uri}"
- gem "rails"
- G
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :artifice => "endpoint")
- end
-
- let(:expected_gems) do
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
- end
- end
-
- describe "with --binstubs", :bundler => "< 3" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
- bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :binstubs => true)
- end
-
- let(:expected_gems) do
- {
- "actionpack" => "2.3.2",
- "rails" => "2.3.2",
- }
- end
-
- include_examples "common functionality"
-
- it "creates stubs that use the standalone load path" do
- Dir.chdir(bundled_app) do
- expect(`bin/rails -v`.chomp).to eql "2.3.2"
- end
- end
-
- it "creates stubs that can be executed from anywhere" do
- require "tmpdir"
- Dir.chdir(Dir.tmpdir) do
- sys_exec!(%(#{bundled_app("bin/rails")} -v))
- expect(out).to eq("2.3.2")
- end
- end
-
- it "creates stubs that can be symlinked" do
- pending "File.symlink is unsupported on Windows" if Bundler::WINDOWS
-
- symlink_dir = tmp("symlink")
- FileUtils.mkdir_p(symlink_dir)
- symlink = File.join(symlink_dir, "rails")
-
- File.symlink(bundled_app("bin/rails"), symlink)
- sys_exec!("#{symlink} -v")
- expect(out).to eq("2.3.2")
- end
-
- it "creates stubs with the correct load path" do
- extension_line = File.read(bundled_app("bin/rails")).each_line.find {|line| line.include? "$:.unshift" }.strip
- expect(extension_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath)
- end
- end
-end
-
-RSpec.describe "bundle install --standalone" do
- include_examples("bundle install --standalone")
-end
-
-RSpec.describe "bundle install --standalone run in a subdirectory" do
- before do
- Dir.chdir(bundled_app("bob").tap(&:mkpath))
- end
-
- include_examples("bundle install --standalone")
-end
diff --git a/spec/bundler/install/gems/sudo_spec.rb b/spec/bundler/install/gems/sudo_spec.rb
deleted file mode 100644
index 170ffaca03..0000000000
--- a/spec/bundler/install/gems/sudo_spec.rb
+++ /dev/null
@@ -1,187 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "when using sudo", :sudo => true do
- describe "and BUNDLE_PATH is writable" do
- context "but BUNDLE_PATH/build_info is not writable" do
- let(:subdir) do
- system_gem_path("cache")
- end
-
- before do
- bundle! "config set path.system true"
- subdir.mkpath
- sudo "chmod u-w #{subdir}"
- end
-
- after do
- sudo "chmod u+w #{subdir}"
- end
-
- it "installs" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- expect(out).to_not match(/an error occurred/i)
- expect(system_gem_path("cache/rack-1.0.0.gem")).to exist
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
- end
-
- describe "and GEM_HOME is owned by root" do
- before :each do
- bundle! "config set path.system true"
- chown_system_gems_to_root
- end
-
- it "installs" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", '1.0'
- gem "thin"
- G
-
- expect(system_gem_path("gems/rack-1.0.0")).to exist
- expect(system_gem_path("gems/rack-1.0.0").stat.uid).to eq(0)
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "installs rake and a gem dependent on rake in the same session" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rake"
- gem "another_implicit_rake_dep"
- G
- bundle "install"
- expect(system_gem_path("gems/another_implicit_rake_dep-1.0")).to exist
- end
-
- it "installs when BUNDLE_PATH is owned by root" do
- bundle_path = tmp("owned_by_root")
- FileUtils.mkdir_p bundle_path
- sudo "chown -R root #{bundle_path}"
-
- ENV["BUNDLE_PATH"] = bundle_path.to_s
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", '1.0'
- G
-
- expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0")).to exist
- expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0").stat.uid).to eq(0)
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "installs when BUNDLE_PATH does not exist" do
- root_path = tmp("owned_by_root")
- FileUtils.mkdir_p root_path
- sudo "chown -R root #{root_path}"
- bundle_path = root_path.join("does_not_exist")
-
- ENV["BUNDLE_PATH"] = bundle_path.to_s
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", '1.0'
- G
-
- expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0")).to exist
- expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0").stat.uid).to eq(0)
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "installs extensions/" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "very_simple_binary"
- G
-
- expect(system_gem_path("gems/very_simple_binary-1.0")).to exist
- binary_glob = system_gem_path("extensions/*/*/very_simple_binary-1.0")
- expect(Dir.glob(binary_glob).first).to be
- end
- end
-
- describe "and BUNDLE_PATH is not writable" do
- before do
- sudo "chmod ugo-w #{default_bundle_path}"
- end
-
- after do
- sudo "chmod ugo+w #{default_bundle_path}"
- end
-
- it "installs" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", '1.0'
- G
-
- expect(default_bundle_path("gems/rack-1.0.0")).to exist
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- it "cleans up the tmpdirs generated" do
- require "tmpdir"
- Dir.glob("#{Dir.tmpdir}/bundler*").each do |tmpdir|
- FileUtils.remove_entry_secure(tmpdir)
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- tmpdirs = Dir.glob("#{Dir.tmpdir}/bundler*")
-
- expect(tmpdirs).to be_empty
- end
- end
-
- describe "and GEM_HOME is not writable" do
- it "installs" do
- bundle! "config set path.system true"
- gem_home = tmp("sudo_gem_home")
- sudo "mkdir -p #{gem_home}"
- sudo "chmod ugo-w #{gem_home}"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", '1.0'
- G
-
- bundle :install, :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
- expect(gem_home.join("bin/rackup")).to exist
- expect(the_bundle).to include_gems "rack 1.0", :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
-
- sudo "rm -rf #{tmp("sudo_gem_home")}"
- end
- end
-
- describe "and root runs install" do
- let(:warning) { "Don't run Bundler as root." }
-
- before do
- gemfile %(source "#{file_uri_for(gem_repo1)}")
- end
-
- it "warns against that" do
- bundle :install, :sudo => true
- expect(err).to include(warning)
- end
-
- context "when ENV['BUNDLE_SILENCE_ROOT_WARNING'] is set" do
- it "skips the warning" do
- bundle :install, :sudo => :preserve_env, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => "true" }
- expect(err).to_not include(warning)
- end
- end
-
- context "when silence_root_warning = false" do
- it "warns against that" do
- bundle :install, :sudo => true, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => "false" }
- expect(err).to include(warning)
- end
- end
- end
-end
diff --git a/spec/bundler/install/gems/win32_spec.rb b/spec/bundler/install/gems/win32_spec.rb
deleted file mode 100644
index 01edcca803..0000000000
--- a/spec/bundler/install/gems/win32_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install with win32-generated lockfile" do
- it "should read lockfile" do
- File.open(bundled_app("Gemfile.lock"), "wb") do |f|
- f << "GEM\r\n"
- f << " remote: #{file_uri_for(gem_repo1)}/\r\n"
- f << " specs:\r\n"
- f << "\r\n"
- f << " rack (1.0.0)\r\n"
- f << "\r\n"
- f << "PLATFORMS\r\n"
- f << " ruby\r\n"
- f << "\r\n"
- f << "DEPENDENCIES\r\n"
- f << " rack\r\n"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
- expect(exitstatus).to eq(0) if exitstatus
- end
-end
diff --git a/spec/bundler/install/gemspecs_spec.rb b/spec/bundler/install/gemspecs_spec.rb
deleted file mode 100644
index 4c00caa60c..0000000000
--- a/spec/bundler/install/gemspecs_spec.rb
+++ /dev/null
@@ -1,151 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- describe "when a gem has a YAML gemspec" do
- before :each do
- build_repo2 do
- build_gem "yaml_spec", :gemspec => :yaml
- end
- end
-
- it "still installs correctly" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "yaml_spec"
- G
- bundle :install
- expect(err).to be_empty
- end
-
- it "still installs correctly when using path" do
- build_lib "yaml_spec", :gemspec => :yaml
-
- install_gemfile <<-G
- gem 'yaml_spec', :path => "#{lib_path("yaml_spec-1.0")}"
- G
- expect(err).to be_empty
- end
- end
-
- it "should use gemspecs in the system cache when available" do
- gemfile <<-G
- source "http://localtestserver.gem"
- gem 'rack'
- G
-
- FileUtils.mkdir_p "#{default_bundle_path}/specifications"
- File.open("#{default_bundle_path}/specifications/rack-1.0.0.gemspec", "w+") do |f|
- spec = Gem::Specification.new do |s|
- s.name = "rack"
- s.version = "1.0.0"
- s.add_runtime_dependency "activesupport", "2.3.2"
- end
- f.write spec.to_ruby
- end
- bundle :install, :artifice => "endpoint_marshal_fail" # force gemspec load
- expect(the_bundle).to include_gems "activesupport 2.3.2"
- end
-
- it "does not hang when gemspec has incompatible encoding" do
- create_file("foo.gemspec", <<-G)
- Gem::Specification.new do |gem|
- gem.name = "pry-byebug"
- gem.version = "3.4.2"
- gem.author = "David Rodríguez"
- gem.summary = "Good stuff"
- end
- G
-
- install_gemfile <<-G, :env => { "LANG" => "C" }
- gemspec
- G
-
- expect(out).to include("Bundle complete!")
- end
-
- it "reads gemspecs respecting their encoding" do
- create_file "version.rb", <<-RUBY
- module Persistent💎
- VERSION = "0.0.1"
- end
- RUBY
-
- create_file "persistent-dmnd.gemspec", <<-G
- require_relative "version"
-
- Gem::Specification.new do |gem|
- gem.name = "persistent-dmnd"
- gem.version = Persistent💎::VERSION
- gem.author = "Ivo Anjo"
- gem.summary = "Unscratchable stuff"
- end
- G
-
- install_gemfile <<-G
- gemspec
- G
-
- expect(out).to include("Bundle complete!")
- end
-
- context "when ruby version is specified in gemspec and gemfile" do
- it "installs when patch level is not specified and the version matches" do
- build_lib("foo", :path => bundled_app) do |s|
- s.required_ruby_version = "~> #{RUBY_VERSION}.0"
- end
-
- install_gemfile <<-G
- ruby '#{RUBY_VERSION}', :engine_version => '#{RUBY_VERSION}', :engine => 'ruby'
- gemspec
- G
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "installs when patch level is specified and the version still matches the current version",
- :if => RUBY_PATCHLEVEL >= 0 do
- build_lib("foo", :path => bundled_app) do |s|
- s.required_ruby_version = "#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
- end
-
- install_gemfile <<-G
- ruby '#{RUBY_VERSION}', :engine_version => '#{RUBY_VERSION}', :engine => 'ruby', :patchlevel => '#{RUBY_PATCHLEVEL}'
- gemspec
- G
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "fails and complains about patchlevel on patchlevel mismatch",
- :if => RUBY_PATCHLEVEL >= 0 do
- patchlevel = RUBY_PATCHLEVEL.to_i + 1
- build_lib("foo", :path => bundled_app) do |s|
- s.required_ruby_version = "#{RUBY_VERSION}.#{patchlevel}"
- end
-
- install_gemfile <<-G
- ruby '#{RUBY_VERSION}', :engine_version => '#{RUBY_VERSION}', :engine => 'ruby', :patchlevel => '#{patchlevel}'
- gemspec
- G
-
- expect(err).to include("Ruby patchlevel")
- expect(err).to include("but your Gemfile specified")
- expect(exitstatus).to eq(18) if exitstatus
- end
-
- it "fails and complains about version on version mismatch" do
- version = Gem::Requirement.create(RUBY_VERSION).requirements.first.last.bump.version
-
- build_lib("foo", :path => bundled_app) do |s|
- s.required_ruby_version = version
- end
-
- install_gemfile <<-G
- ruby '#{version}', :engine_version => '#{version}', :engine => 'ruby'
- gemspec
- G
-
- expect(err).to include("Ruby version")
- expect(err).to include("but your Gemfile specified")
- expect(exitstatus).to eq(18) if exitstatus
- end
- end
-end
diff --git a/spec/bundler/install/git_spec.rb b/spec/bundler/install/git_spec.rb
deleted file mode 100644
index cc8bf70b03..0000000000
--- a/spec/bundler/install/git_spec.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- context "git sources" do
- it "displays the revision hash of the gem repository", :bundler => "< 3" do
- build_git "foo", "1.0", :path => lib_path("foo")
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo")}"
- G
-
- bundle! :install
- expect(out).to include("Using foo 1.0 from #{lib_path("foo")} (at master@#{revision_for(lib_path("foo"))[0..6]})")
- expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
- end
-
- it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 3" do
- build_git "foo", "1.0", :path => lib_path("foo")
- rev = revision_for(lib_path("foo"))[0..6]
- update_git "foo", "2.0", :path => lib_path("foo"), :gemspec => true
- rev2 = revision_for(lib_path("foo"))[0..6]
- update_git "foo", "3.0", :path => lib_path("foo"), :gemspec => true
-
- install_gemfile! <<-G
- gem "foo", :git => "#{lib_path("foo")}", :ref => "master~2"
- G
-
- bundle! :install
- expect(out).to include("Using foo 1.0 from #{lib_path("foo")} (at master~2@#{rev})")
- expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
-
- update_git "foo", "4.0", :path => lib_path("foo"), :gemspec => true
-
- bundle! :update, :all => true
- expect(out).to include("Using foo 2.0 (was 1.0) from #{lib_path("foo")} (at master~2@#{rev2})")
- expect(the_bundle).to include_gems "foo 2.0", :source => "git@#{lib_path("foo")}"
- end
-
- it "should allows git repos that are missing but not being installed" do
- revision = build_git("foo").ref_for("HEAD")
-
- gemfile <<-G
- gem "foo", :git => "#{file_uri_for(lib_path("foo-1.0"))}", :group => :development
- G
-
- lockfile <<-L
- GIT
- remote: #{file_uri_for(lib_path("foo-1.0"))}
- revision: #{revision}
- specs:
- foo (1.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- foo!
- L
-
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle", :without => "development")
-
- expect(out).to include("Bundle complete!")
- end
-
- it "allows multiple gems from the same git source" do
- build_repo2 do
- build_lib "foo", "1.0", :path => lib_path("gems/foo")
- build_lib "zebra", "2.0", :path => lib_path("gems/zebra")
- build_git "gems", :path => lib_path("gems"), :gemspec => false
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "foo", :git => "#{lib_path("gems")}", :glob => "foo/*.gemspec"
- gem "zebra", :git => "#{lib_path("gems")}", :glob => "zebra/*.gemspec"
- G
-
- bundle "info foo"
- expect(out).to include("* foo (1.0 #{revision_for(lib_path("gems"))[0..6]})")
-
- bundle "info zebra"
- expect(out).to include("* zebra (2.0 #{revision_for(lib_path("gems"))[0..6]})")
- end
- end
-end
diff --git a/spec/bundler/install/global_cache_spec.rb b/spec/bundler/install/global_cache_spec.rb
deleted file mode 100644
index 023e52b060..0000000000
--- a/spec/bundler/install/global_cache_spec.rb
+++ /dev/null
@@ -1,235 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "global gem caching" do
- before { bundle! "config set global_gem_cache true" }
-
- describe "using the cross-application user cache" do
- let(:source) { "http://localgemserver.test" }
- let(:source2) { "http://gemserver.example.org" }
-
- def source_global_cache(*segments)
- home(".bundle", "cache", "gems", "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", *segments)
- end
-
- def source2_global_cache(*segments)
- home(".bundle", "cache", "gems", "gemserver.example.org.80.1ae1663619ffe0a3c9d97712f44c705b", *segments)
- end
-
- it "caches gems into the global cache on download" do
- install_gemfile! <<-G, :artifice => "compact_index"
- source "#{source}"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- end
-
- it "uses globally cached gems if they exist" do
- source_global_cache.mkpath
- FileUtils.cp(gem_repo1("gems/rack-1.0.0.gem"), source_global_cache("rack-1.0.0.gem"))
-
- install_gemfile! <<-G, :artifice => "compact_index_no_gem"
- source "#{source}"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- describe "when the same gem from different sources is installed" do
- it "should use the appropriate one from the global cache" do
- install_gemfile! <<-G, :artifice => "compact_index"
- source "#{source}"
- gem "rack"
- G
-
- FileUtils.rm_r(default_bundle_path)
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- # rack 1.0.0 is not installed and it is in the global cache
-
- install_gemfile! <<-G, :artifice => "compact_index"
- source "#{source2}"
- gem "rack", "0.9.1"
- G
-
- FileUtils.rm_r(default_bundle_path)
- expect(the_bundle).not_to include_gems "rack 0.9.1"
- expect(source2_global_cache("rack-0.9.1.gem")).to exist
- # rack 0.9.1 is not installed and it is in the global cache
-
- gemfile <<-G
- source "#{source}"
- gem "rack", "1.0.0"
- G
-
- bundle! :install, :artifice => "compact_index_no_gem"
- # rack 1.0.0 is installed and rack 0.9.1 is not
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "rack 0.9.1"
- FileUtils.rm_r(default_bundle_path)
-
- gemfile <<-G
- source "#{source2}"
- gem "rack", "0.9.1"
- G
-
- bundle! :install, :artifice => "compact_index_no_gem"
- # rack 0.9.1 is installed and rack 1.0.0 is not
- expect(the_bundle).to include_gems "rack 0.9.1"
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- end
-
- it "should not install if the wrong source is provided" do
- gemfile <<-G
- source "#{source}"
- gem "rack"
- G
-
- bundle! :install, :artifice => "compact_index"
- FileUtils.rm_r(default_bundle_path)
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- # rack 1.0.0 is not installed and it is in the global cache
-
- gemfile <<-G
- source "#{source2}"
- gem "rack", "0.9.1"
- G
-
- bundle! :install, :artifice => "compact_index"
- FileUtils.rm_r(default_bundle_path)
- expect(the_bundle).not_to include_gems "rack 0.9.1"
- expect(source2_global_cache("rack-0.9.1.gem")).to exist
- # rack 0.9.1 is not installed and it is in the global cache
-
- gemfile <<-G
- source "#{source2}"
- gem "rack", "1.0.0"
- G
-
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source2_global_cache("rack-0.9.1.gem")).to exist
- bundle :install, :artifice => "compact_index_no_gem"
- expect(err).to include("Internal Server Error 500")
- # rack 1.0.0 is not installed and rack 0.9.1 is not
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "rack 0.9.1"
-
- gemfile <<-G
- source "#{source}"
- gem "rack", "0.9.1"
- G
-
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source2_global_cache("rack-0.9.1.gem")).to exist
- bundle :install, :artifice => "compact_index_no_gem"
- expect(err).to include("Internal Server Error 500")
- # rack 0.9.1 is not installed and rack 1.0.0 is not
- expect(the_bundle).not_to include_gems "rack 0.9.1"
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- end
- end
-
- describe "when installing gems from a different directory" do
- it "uses the global cache as a source" do
- install_gemfile! <<-G, :artifice => "compact_index"
- source "#{source}"
- gem "rack"
- gem "activesupport"
- G
-
- # Both gems are installed and in the global cache
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source_global_cache("activesupport-2.3.5.gem")).to exist
- FileUtils.rm_r(default_bundle_path)
- # Both gems are now only in the global cache
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
-
- install_gemfile! <<-G, :artifice => "compact_index_no_gem"
- source "#{source}"
- gem "rack"
- G
-
- # rack is installed and both are in the global cache
- expect(the_bundle).to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source_global_cache("activesupport-2.3.5.gem")).to exist
-
- Dir.chdir bundled_app2 do
- create_file bundled_app2("gems.rb"), <<-G
- source "#{source}"
- gem "activesupport"
- G
-
- # Neither gem is installed and both are in the global cache
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source_global_cache("activesupport-2.3.5.gem")).to exist
-
- # Install using the global cache instead of by downloading the .gem
- # from the server
- bundle! :install, :artifice => "compact_index_no_gem"
-
- # activesupport is installed and both are in the global cache
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source_global_cache("activesupport-2.3.5.gem")).to exist
- end
- end
- end
- end
-
- describe "extension caching", :ruby_repo do
- it "works" do
- build_git "very_simple_git_binary", &:add_c_extension
- build_lib "very_simple_path_binary", &:add_c_extension
- revision = revision_for(lib_path("very_simple_git_binary-1.0"))[0, 12]
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "very_simple_binary"
- gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}"
- gem "very_simple_path_binary", :path => "#{lib_path("very_simple_path_binary-1.0")}"
- G
-
- gem_binary_cache = home(".bundle", "cache", "extensions", specific_local_platform.to_s, Bundler.ruby_scope,
- Digest(:MD5).hexdigest("#{gem_repo1}/"), "very_simple_binary-1.0")
- git_binary_cache = home(".bundle", "cache", "extensions", specific_local_platform.to_s, Bundler.ruby_scope,
- "very_simple_git_binary-1.0-#{revision}", "very_simple_git_binary-1.0")
-
- cached_extensions = Pathname.glob(home(".bundle", "cache", "extensions", "*", "*", "*", "*", "*")).sort
- expect(cached_extensions).to eq [gem_binary_cache, git_binary_cache].sort
-
- run! <<-R
- require 'very_simple_binary_c'; puts ::VERY_SIMPLE_BINARY_IN_C
- require 'very_simple_git_binary_c'; puts ::VERY_SIMPLE_GIT_BINARY_IN_C
- R
- expect(out).to eq "VERY_SIMPLE_BINARY_IN_C\nVERY_SIMPLE_GIT_BINARY_IN_C"
-
- FileUtils.rm Dir[home(".bundle", "cache", "extensions", "**", "*binary_c*")]
-
- gem_binary_cache.join("very_simple_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" }
- git_binary_cache.join("very_simple_git_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" }
-
- bundle! "config set --local path different_path"
- bundle! :install
-
- expect(Dir[home(".bundle", "cache", "extensions", "**", "*binary_c*")]).to all(end_with(".rb"))
-
- run! <<-R
- require 'very_simple_binary_c'
- require 'very_simple_git_binary_c'
- R
- expect(out).to eq "very_simple_binary_c.rb\nvery_simple_git_binary_c.rb"
- end
- end
-end
diff --git a/spec/bundler/install/path_spec.rb b/spec/bundler/install/path_spec.rb
deleted file mode 100644
index 5240c5820c..0000000000
--- a/spec/bundler/install/path_spec.rb
+++ /dev/null
@@ -1,221 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- describe "with --path" do
- before :each do
- build_gem "rack", "1.0.0", :to_system => true do |s|
- s.write "lib/rack.rb", "puts 'FAIL'"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "does not use available system gems with bundle --path vendor/bundle", :bundler => "< 3" do
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "handles paths with regex characters in them" do
- dir = bundled_app("bun++dle")
- dir.mkpath
-
- Dir.chdir(dir) do
- bundle! :install, forgotten_command_line_options(:path => dir.join("vendor/bundle"))
- expect(out).to include("installed into `./vendor/bundle`")
- end
-
- dir.rmtree
- end
-
- it "prints a warning to let the user know what has happened with bundle --path vendor/bundle" do
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- expect(out).to include("gems are installed into `./vendor/bundle`")
- end
-
- it "disallows --path vendor/bundle --system", :bundler => "< 3" do
- bundle "install --path vendor/bundle --system"
- expect(err).to include("Please choose only one option.")
- expect(exitstatus).to eq(15) if exitstatus
- end
-
- it "remembers to disable system gems after the first time with bundle --path vendor/bundle", :bundler => "< 3" do
- bundle "install --path vendor/bundle"
- FileUtils.rm_rf bundled_app("vendor")
- bundle "install"
-
- expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- context "with path_relative_to_cwd set to true" do
- before { bundle! "config set path_relative_to_cwd true" }
-
- it "installs the bundle relatively to current working directory", :bundler => "< 3" do
- Dir.chdir(bundled_app.parent) do
- bundle! "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle"
- expect(out).to include("installed into `./vendor/bundle`")
- expect(bundled_app("../vendor/bundle")).to be_directory
- end
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs the standalone bundle relative to the cwd" do
- Dir.chdir(bundled_app.parent) do
- bundle! :install, :gemfile => bundled_app("Gemfile"), :standalone => true
- expect(out).to include("installed into `./bundled_app/bundle`")
- expect(bundled_app("bundle")).to be_directory
- expect(bundled_app("bundle/ruby")).to be_directory
- end
-
- bundle! "config unset path"
-
- Dir.chdir(bundled_app("subdir").tap(&:mkpath)) do
- bundle! :install, :gemfile => bundled_app("Gemfile"), :standalone => true
- expect(out).to include("installed into `../bundle`")
- expect(bundled_app("bundle")).to be_directory
- expect(bundled_app("bundle/ruby")).to be_directory
- end
- end
- end
- end
-
- describe "when BUNDLE_PATH or the global path config is set" do
- before :each do
- build_lib "rack", "1.0.0", :to_system => true do |s|
- s.write "lib/rack.rb", "raise 'FAIL'"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- def set_bundle_path(type, location)
- if type == :env
- ENV["BUNDLE_PATH"] = location
- elsif type == :global
- bundle! "config set path #{location}", "no-color" => nil
- end
- end
-
- [:env, :global].each do |type|
- context "when set via #{type}" do
- it "installs gems to a path if one is specified" do
- set_bundle_path(type, bundled_app("vendor2").to_s)
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
-
- expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- expect(bundled_app("vendor2")).not_to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs gems to ." do
- set_bundle_path(type, ".")
- bundle! "config set --global disable_shared_gems true"
-
- bundle! :install
-
- paths_to_exist = %w[cache/rack-1.0.0.gem gems/rack-1.0.0 specifications/rack-1.0.0.gemspec].map {|path| bundled_app(Bundler.ruby_scope, path) }
- expect(paths_to_exist).to all exist
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs gems to the path" do
- set_bundle_path(type, bundled_app("vendor").to_s)
-
- bundle! :install
-
- expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs gems to the path relative to root when relative" do
- set_bundle_path(type, "vendor")
-
- FileUtils.mkdir_p bundled_app("lol")
- Dir.chdir(bundled_app("lol")) do
- bundle! :install
- end
-
- expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
-
- it "installs gems to BUNDLE_PATH from .bundle/config" do
- config "BUNDLE_PATH" => bundled_app("vendor/bundle").to_s
-
- bundle :install
-
- expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "sets BUNDLE_PATH as the first argument to bundle install" do
- bundle! :install, forgotten_command_line_options(:path => "./vendor/bundle")
-
- expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "disables system gems when passing a path to install" do
- # This is so that vendored gems can be distributed to others
- build_gem "rack", "1.1.0", :to_system => true
- bundle! :install, forgotten_command_line_options(:path => "./vendor/bundle")
-
- expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "re-installs gems whose extensions have been deleted", :ruby_repo do
- build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
- s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "very_simple_binary"
- G
-
- bundle! :install, forgotten_command_line_options(:path => "./vendor/bundle")
-
- expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory
- expect(vendored_gems("extensions")).to be_directory
- expect(the_bundle).to include_gems "very_simple_binary 1.0", :source => "remote1"
-
- vendored_gems("extensions").rmtree
-
- run "require 'very_simple_binary_c'"
- expect(err).to include("Bundler::GemNotFound")
-
- bundle :install, forgotten_command_line_options(:path => "./vendor/bundle")
-
- expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory
- expect(vendored_gems("extensions")).to be_directory
- expect(the_bundle).to include_gems "very_simple_binary 1.0", :source => "remote1"
- end
- end
-
- describe "to a file" do
- before do
- in_app_root do
- FileUtils.touch "bundle"
- end
- end
-
- it "reports the file exists" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle :install, forgotten_command_line_options(:path => "bundle")
- expect(err).to include("file already exists")
- end
- end
-end
diff --git a/spec/bundler/install/prereleases_spec.rb b/spec/bundler/install/prereleases_spec.rb
deleted file mode 100644
index fb01220ed7..0000000000
--- a/spec/bundler/install/prereleases_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- describe "when prerelease gems are available" do
- it "finds prereleases" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "not_released"
- G
- expect(the_bundle).to include_gems "not_released 1.0.pre"
- end
-
- it "uses regular releases if available" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "has_prerelease"
- G
- expect(the_bundle).to include_gems "has_prerelease 1.0"
- end
-
- it "uses prereleases if requested" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "has_prerelease", "1.1.pre"
- G
- expect(the_bundle).to include_gems "has_prerelease 1.1.pre"
- end
- end
-
- describe "when prerelease gems are not available" do
- it "still works" do
- build_repo3
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo3)}"
- gem "rack"
- G
-
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-end
diff --git a/spec/bundler/install/process_lock_spec.rb b/spec/bundler/install/process_lock_spec.rb
deleted file mode 100644
index cab4ba0819..0000000000
--- a/spec/bundler/install/process_lock_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "process lock spec" do
- describe "when an install operation is already holding a process lock" do
- before { FileUtils.mkdir_p(default_bundle_path) }
-
- it "will not run a second concurrent bundle install until the lock is released" do
- thread = Thread.new do
- Bundler::ProcessLock.lock(default_bundle_path) do
- sleep 1 # ignore quality_spec
- expect(the_bundle).not_to include_gems "rack 1.0"
- end
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- thread.join
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- context "when creating a lock raises Errno::ENOTSUP" do
- before { allow(File).to receive(:open).and_raise(Errno::ENOTSUP) }
-
- it "skips creating the lock file and yields" do
- processed = false
- Bundler::ProcessLock.lock(default_bundle_path) { processed = true }
-
- expect(processed).to eq true
- end
- end
- end
-end
diff --git a/spec/bundler/install/redownload_spec.rb b/spec/bundler/install/redownload_spec.rb
deleted file mode 100644
index 818c33bd61..0000000000
--- a/spec/bundler/install/redownload_spec.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- before :each do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- shared_examples_for "an option to force redownloading gems" do
- it "re-installs installed gems" do
- rack_lib = default_bundle_path("gems/rack-1.0.0/lib/rack.rb")
-
- bundle! :install
- rack_lib.open("w") {|f| f.write("blah blah blah") }
- bundle! :install, flag => true
-
- expect(out).to include "Installing rack 1.0.0"
- expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "works on first bundle install" do
- bundle! :install, flag => true
-
- expect(out).to include "Installing rack 1.0.0"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- context "with a git gem" do
- let!(:ref) { build_git("foo", "1.0").ref_for("HEAD", 11) }
-
- before do
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
- end
-
- it "re-installs installed gems" do
- foo_lib = default_bundle_path("bundler/gems/foo-1.0-#{ref}/lib/foo.rb")
-
- bundle! :install
- foo_lib.open("w") {|f| f.write("blah blah blah") }
- bundle! :install, flag => true
-
- expect(foo_lib.open(&:read)).to eq("FOO = '1.0'\n")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "works on first bundle install" do
- bundle! :install, flag => true
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
- end
- end
-
- describe "with --force", :bundler => 2 do
- it_behaves_like "an option to force redownloading gems" do
- let(:flag) { "force" }
- end
-
- it "shows a deprecation when single flag passed" do
- bundle! "install --force"
- expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
-
- it "shows a deprecation when multiple flags passed" do
- bundle! "install --no-color --force"
- expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
- end
-
- describe "with --redownload" do
- it_behaves_like "an option to force redownloading gems" do
- let(:flag) { "redownload" }
- end
-
- it "does not show a deprecation when single flag passed" do
- bundle! "install --redownload"
- expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
-
- it "does not show a deprecation when single multiple flags passed" do
- bundle! "install --no-color --redownload"
- expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
- end
-end
diff --git a/spec/bundler/install/security_policy_spec.rb b/spec/bundler/install/security_policy_spec.rb
deleted file mode 100644
index 28c34d9ce7..0000000000
--- a/spec/bundler/install/security_policy_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: true
-
-require "rubygems/security"
-
-# unfortunately, testing signed gems with a provided CA is extremely difficult
-# as 'gem cert' is currently the only way to add CAs to the system.
-
-RSpec.describe "policies with unsigned gems" do
- before do
- build_security_repo
- gemfile <<-G
- source "#{file_uri_for(security_repo)}"
- gem "rack"
- gem "signed_gem"
- G
- end
-
- it "will work after you try to deploy without a lock" do
- bundle "install --deployment"
- bundle :install
- expect(exitstatus).to eq(0) if exitstatus
- expect(the_bundle).to include_gems "rack 1.0", "signed_gem 1.0"
- end
-
- it "will fail when given invalid security policy" do
- bundle "install --trust-policy=InvalidPolicyName"
- expect(err).to include("RubyGems doesn't know about trust policy")
- end
-
- it "will fail with High Security setting due to presence of unsigned gem" do
- bundle "install --trust-policy=HighSecurity"
- expect(err).to include("security policy didn't allow")
- end
-
- it "will fail with Medium Security setting due to presence of unsigned gem" do
- bundle "install --trust-policy=MediumSecurity"
- expect(err).to include("security policy didn't allow")
- end
-
- it "will succeed with no policy" do
- bundle "install"
- expect(exitstatus).to eq(0) if exitstatus
- end
-end
-
-RSpec.describe "policies with signed gems and no CA" do
- before do
- build_security_repo
- gemfile <<-G
- source "#{file_uri_for(security_repo)}"
- gem "signed_gem"
- G
- end
-
- it "will fail with High Security setting, gem is self-signed" do
- bundle "install --trust-policy=HighSecurity"
- expect(err).to include("security policy didn't allow")
- end
-
- it "will fail with Medium Security setting, gem is self-signed" do
- bundle "install --trust-policy=MediumSecurity"
- expect(err).to include("security policy didn't allow")
- end
-
- it "will succeed with Low Security setting, low security accepts self signed gem" do
- bundle "install --trust-policy=LowSecurity"
- expect(exitstatus).to eq(0) if exitstatus
- expect(the_bundle).to include_gems "signed_gem 1.0"
- end
-
- it "will succeed with no policy" do
- bundle "install"
- expect(exitstatus).to eq(0) if exitstatus
- expect(the_bundle).to include_gems "signed_gem 1.0"
- end
-end
diff --git a/spec/bundler/install/yanked_spec.rb b/spec/bundler/install/yanked_spec.rb
deleted file mode 100644
index 80729b3f5b..0000000000
--- a/spec/bundler/install/yanked_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.context "when installing a bundle that includes yanked gems" do
- before(:each) do
- build_repo4 do
- build_gem "foo", "9.0.0"
- end
- end
-
- it "throws an error when the original gem version is yanked" do
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo4)}
- specs:
- foo (10.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- foo (= 10.0.0)
-
- L
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "foo", "10.0.0"
- G
-
- expect(err).to include("Your bundle is locked to foo (10.0.0)")
- end
-
- it "throws the original error when only the Gemfile specifies a gem version that doesn't exist" do
- bundle "config set force_ruby_platform true"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "foo", "10.0.0"
- G
-
- expect(err).not_to include("Your bundle is locked to foo (10.0.0)")
- expect(err).to include("Could not find gem 'foo (= 10.0.0)' in")
- end
-end
-
-RSpec.context "when using gem before installing" do
- it "does not suggest the author has yanked the gem" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- G
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}
- specs:
- rack (0.9.1)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (= 0.9.1)
- L
-
- bundle :list
-
- expect(err).to include("Could not find rack-0.9.1 in any of the sources")
- expect(err).to_not include("Your bundle is locked to rack (0.9.1), but that version could not be found in any of the sources listed in your Gemfile.")
- expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")
- expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.")
- end
-end
diff --git a/spec/bundler/lock/git_spec.rb b/spec/bundler/lock/git_spec.rb
deleted file mode 100644
index 14b80483ee..0000000000
--- a/spec/bundler/lock/git_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle lock with git gems" do
- before :each do
- build_git "foo"
-
- install_gemfile <<-G
- gem 'foo', :git => "#{lib_path("foo-1.0")}"
- G
- end
-
- it "doesn't break right after running lock" do
- expect(the_bundle).to include_gems "foo 1.0.0"
- end
-
- it "locks a git source to the current ref" do
- update_git "foo"
- bundle :install
-
- run <<-RUBY
- require 'foo'
- puts "WIN" unless defined?(FOO_PREV_REF)
- RUBY
-
- expect(out).to eq("WIN")
- end
-
- it "provides correct #full_gem_path" do
- run <<-RUBY
- puts Bundler.rubygems.find_name('foo').first.full_gem_path
- RUBY
- expect(out).to eq(bundle("info foo --path"))
- end
-end
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
deleted file mode 100644
index ddab4831a5..0000000000
--- a/spec/bundler/lock/lockfile_spec.rb
+++ /dev/null
@@ -1,1489 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "the lockfile format" do
- include Bundler::GemHelpers
-
- it "generates a simple lockfile for a single source, gem" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "updates the lockfile's bundler version if current ver. is newer" do
- lockfile <<-L
- GIT
- remote: git://github.com/nex3/haml.git
- revision: 8a2271f
- specs:
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- omg!
- rack
-
- BUNDLED WITH
- 1.8.2
- L
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not update the lockfile's bundler version if nothing changed during bundle install" do
- version = "#{Bundler::VERSION.split(".").first}.0.0.a"
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{version}
- L
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{version}
- G
- end
-
- it "updates the lockfile's bundler version if not present" do
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
- L
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack", "> 0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack (> 0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "warns if the current is older than lockfile's bundler version" do
- current_version = Bundler::VERSION
- newer_minor = bump_minor(current_version)
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{newer_minor}
- L
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rack"
- G
-
- pre_flag = prerelease?(newer_minor) ? " --pre" : ""
- warning_message = "the running version of Bundler (#{current_version}) is older " \
- "than the version that created the lockfile (#{newer_minor}). " \
- "We suggest you to upgrade to the version that created the " \
- "lockfile by running `gem install bundler:#{newer_minor}#{pre_flag}`."
- expect(err).to include warning_message
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{newer_minor}
- G
- end
-
- it "warns when updating bundler major version" do
- current_version = Bundler::VERSION
- older_major = previous_major(current_version)
-
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{older_major}
- L
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack"
- G
-
- expect(err).to include(
- "Warning: the lockfile is being updated to Bundler " \
- "#{current_version.split(".").first}, after which you will be unable to return to Bundler #{older_major.split(".").first}."
- )
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{current_version}
- G
- end
-
- it "generates a simple lockfile for a single source, gem with dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack-obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack-obama
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a simple lockfile for a single source, gem with a version requirement" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack-obama", ">= 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile without credentials for a configured source", :bundler => "< 3" do
- bundle "config set http://localgemserver.test/ user:pass"
-
- install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
- source "http://localgemserver.test/" do
-
- end
-
- source "http://user:pass@othergemserver.test/" do
- gem "rack-obama", ">= 1.0"
- end
- G
-
- lockfile_should_be <<-G
- GEM
- remote: http://localgemserver.test/
- remote: http://user:pass@othergemserver.test/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack-obama (>= 1.0)!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile without credentials for a configured source", :bundler => "3" do
- bundle "config set http://localgemserver.test/ user:pass"
-
- install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
- source "http://localgemserver.test/" do
-
- end
-
- source "http://user:pass@othergemserver.test/" do
- gem "rack-obama", ">= 1.0"
- end
- G
-
- lockfile_should_be <<-G
- GEM
- specs:
-
- GEM
- remote: http://localgemserver.test/
- specs:
-
- GEM
- remote: http://user:pass@othergemserver.test/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack-obama (>= 1.0)!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates lockfiles with multiple requirements" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "net-sftp"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- net-sftp (1.1.1)
- net-ssh (>= 1.0.0, < 1.99.0)
- net-ssh (1.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- net-sftp
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- expect(the_bundle).to include_gems "net-sftp 1.1.1", "net-ssh 1.0.0"
- end
-
- it "generates a simple lockfile for a single pinned source, gem with a version requirement", :bundler => "< 3" do
- git = build_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("master")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a simple lockfile for a single pinned source, gem with a version requirement" do
- git = build_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("master")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not asplode when a platform specific dependency is present and the Gemfile has not been resolved on that platform" do
- build_lib "omg", :path => lib_path("omg")
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- platforms :#{not_local_tag} do
- gem "omg", :path => "#{lib_path("omg")}"
- end
-
- gem "rack"
- G
-
- lockfile <<-L
- GIT
- remote: git://github.com/nex3/haml.git
- revision: 8a2271f
- specs:
-
- GEM
- remote: #{file_uri_for(gem_repo1)}//
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{not_local}
-
- DEPENDENCIES
- omg!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- bundle! "install"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "serializes global git sources" do
- git = build_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}" do
- gem "foo"
- end
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("master")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile with a ref for a single pinned source, git gem with a branch requirement" do
- git = build_git "foo"
- update_git "foo", :branch => "omg"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("omg")}
- branch: omg
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile with a ref for a single pinned source, git gem with a tag requirement" do
- git = build_git "foo"
- update_git "foo", :tag => "omg"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :tag => "omg"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("omg")}
- tag: omg
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "serializes pinned path sources to the lockfile" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "serializes pinned path sources to the lockfile even when packaging" do
- build_lib "foo"
-
- install_gemfile! <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- bundle "config set cache_all true"
- bundle! :cache
- bundle! :install, :local => true
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "sorts serialized sources by type" do
- build_lib "foo"
- bar = build_git "bar"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack"
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- gem "bar", :git => "#{lib_path("bar-1.0")}"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("bar-1.0")}
- revision: #{bar.ref_for("master")}
- specs:
- bar (1.0)
-
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- bar!
- foo!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "lists gems alphabetically" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "thin"
- gem "actionpack"
- gem "rack-obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- actionpack (2.3.2)
- activesupport (= 2.3.2)
- activesupport (2.3.2)
- rack (1.0.0)
- rack-obama (1.0)
- rack
- thin (1.0)
- rack
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- actionpack
- rack-obama
- thin
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "orders dependencies' dependencies in alphabetical order" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rails"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- actionmailer (2.3.2)
- activesupport (= 2.3.2)
- actionpack (2.3.2)
- activesupport (= 2.3.2)
- activerecord (2.3.2)
- activesupport (= 2.3.2)
- activeresource (2.3.2)
- activesupport (= 2.3.2)
- activesupport (2.3.2)
- rails (2.3.2)
- actionmailer (= 2.3.2)
- actionpack (= 2.3.2)
- activerecord (= 2.3.2)
- activeresource (= 2.3.2)
- rake (= 12.3.2)
- rake (12.3.2)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rails
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "orders dependencies by version" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem 'double_deps'
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- double_deps (1.0)
- net-ssh
- net-ssh (>= 1.0.0)
- net-ssh (1.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- double_deps
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add the :require option to the lockfile" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack-obama", ">= 1.0", :require => "rack/obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add the :group option to the lockfile" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack-obama", ">= 1.0", :group => :test
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in a relative fashion and in Gemfile dir" do
- build_lib "foo", :path => bundled_app("foo")
-
- install_gemfile <<-G
- path "foo" do
- gem "foo"
- end
- G
-
- lockfile_should_be <<-G
- PATH
- remote: foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in a relative fashion and is above Gemfile dir" do
- build_lib "foo", :path => bundled_app(File.join("..", "foo"))
-
- install_gemfile <<-G
- path "../foo" do
- gem "foo"
- end
- G
-
- lockfile_should_be <<-G
- PATH
- remote: ../foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in an absolute fashion but is relative" do
- build_lib "foo", :path => bundled_app("foo")
-
- install_gemfile <<-G
- path File.expand_path("../foo", __FILE__) do
- gem "foo"
- end
- G
-
- lockfile_should_be <<-G
- PATH
- remote: foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided for gemspec" do
- build_lib("foo", :path => tmp.join("foo"))
-
- install_gemfile <<-G
- gemspec :path => "../foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: ../foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "keeps existing platforms in the lockfile", :bundler => "< 3" do
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- java
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "keeps existing platforms in the lockfile", :bundler => "3" do
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- java
- #{generic_local_platform}
- #{specific_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "persists the spec's platform to the lockfile", :bundler => "< 3" do
- build_repo2 do
- build_gem "platform_specific", "1.0" do |s|
- s.platform = Gem::Platform.new("universal-java-16")
- end
- end
-
- simulate_platform "universal-java-16"
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "platform_specific"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- platform_specific (1.0-java)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "persists the spec's platform and specific platform to the lockfile", :bundler => "3" do
- build_repo2 do
- build_gem "platform_specific", "1.0" do |s|
- s.platform = Gem::Platform.new("universal-java-16")
- end
- end
-
- simulate_platform "universal-java-16"
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "platform_specific"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- platform_specific (1.0-java)
- platform_specific (1.0-universal-java-16)
-
- PLATFORMS
- java
- universal-java-16
-
- DEPENDENCIES
- platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate gems" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack"
- G
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack"
- gem "activesupport"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- activesupport (2.3.5)
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- activesupport
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack"
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies with versions" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack", "1.0"
- gem "rack", "1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack (= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies in different groups" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack", "1.0", :group => :one
- gem "rack", "1.0", :group => :two
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack (= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "raises if two different versions are used" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack", "1.0"
- gem "rack", "1.1"
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- expect(err).to include "rack (= 1.0) and rack (= 1.1)"
- end
-
- it "raises if two different sources are used" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack"
- gem "rack", :git => "git://hubz.com"
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)"
- end
-
- it "works correctly with multiple version dependencies" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack", "> 0.9", "< 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack (> 0.9, < 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "captures the Ruby version in the lockfile" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- ruby '#{RUBY_VERSION}'
- gem "rack", "> 0.9", "< 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack (> 0.9, < 1.0)
-
- RUBY VERSION
- ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- # Some versions of the Bundler 1.1 RC series introduced corrupted
- # lockfiles. There were two major problems:
- #
- # * multiple copies of the same GIT section appeared in the lockfile
- # * when this happened, those sections got multiple copies of gems
- # in those sections.
- it "fixes corrupted lockfiles" do
- build_git "omg", :path => lib_path("omg")
- revision = revision_for(lib_path("omg"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}/"
- gem "omg", :git => "#{lib_path("omg")}", :branch => 'master'
- G
-
- bundle! :install, forgotten_command_line_options(:path => "vendor")
- expect(the_bundle).to include_gems "omg 1.0"
-
- # Create a Gemfile.lock that has duplicate GIT sections
- lockfile <<-L
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- omg!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- FileUtils.rm_rf(bundled_app("vendor"))
- bundle "install"
- expect(the_bundle).to include_gems "omg 1.0"
-
- # Confirm that duplicate specs do not appear
- lockfile_should_be(<<-L)
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- omg!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-
- it "raises a helpful error message when the lockfile is missing deps" do
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack_middleware (1.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack_middleware
- L
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack_middleware"
- G
-
- expect(err).to include("Downloading rack_middleware-1.0 revealed dependencies not in the API or the lockfile (#{Gem::Dependency.new("rack", "= 0.9.1")}).").
- and include("Either installing with `--full-index` or running `bundle update rack_middleware` should fix the problem.")
- end
-
- describe "a line ending" do
- def set_lockfile_mtime_to_known_value
- time = Time.local(2000, 1, 1, 0, 0, 0)
- File.utime(time, time, bundled_app("Gemfile.lock"))
- end
- before(:each) do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack"
- G
- set_lockfile_mtime_to_known_value
- end
-
- it "generates Gemfile.lock with \\n line endings" do
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- context "during updates" do
- it "preserves Gemfile.lock \\n line endings" do
- update_repo2
-
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.2"
- end
-
- it "preserves Gemfile.lock \\n\\r line endings" do
- update_repo2
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
- set_lockfile_mtime_to_known_value
-
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.2"
- end
- end
-
- context "when nothing changes" do
- it "preserves Gemfile.lock \\n line endings" do
- expect do
- ruby <<-RUBY
- require 'bundler'
- Bundler.setup
- RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
- end
-
- it "preserves Gemfile.lock \\n\\r line endings" do
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
- set_lockfile_mtime_to_known_value
-
- expect do
- ruby <<-RUBY
- require 'bundler'
- Bundler.setup
- RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
- end
- end
- end
-
- it "refuses to install if Gemfile.lock contains conflict markers" do
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}//
- specs:
- <<<<<<<
- rack (1.0.0)
- =======
- rack (1.0.1)
- >>>>>>>
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- install_gemfile(<<-G)
- source "#{file_uri_for(gem_repo1)}/"
- gem "rack"
- G
-
- expect(err).to match(/your Gemfile.lock contains merge conflicts/i)
- expect(err).to match(/git checkout HEAD -- Gemfile.lock/i)
- end
-
-private
-
- def prerelease?(version)
- Gem::Version.new(version).prerelease?
- end
-
- def previous_major(version)
- version.split(".").map.with_index {|v, i| i == 0 ? v.to_i - 1 : v }.join(".")
- end
-
- def bump_minor(version)
- bump(version, 1)
- end
-
- def bump(version, segment)
- version.split(".").map.with_index {|v, i| i == segment ? v.to_i + 1 : v }.join(".")
- end
-end
diff --git a/spec/bundler/other/cli_dispatch_spec.rb b/spec/bundler/other/cli_dispatch_spec.rb
deleted file mode 100644
index 0082606d7e..0000000000
--- a/spec/bundler/other/cli_dispatch_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle command names" do
- it "work when given fully" do
- bundle "install"
- expect(err).to eq("Could not locate Gemfile")
- expect(last_command.stdboth).not_to include("Ambiguous command")
- end
-
- it "work when not ambiguous" do
- bundle "ins"
- expect(err).to eq("Could not locate Gemfile")
- expect(last_command.stdboth).not_to include("Ambiguous command")
- end
-
- it "print a friendly error when ambiguous" do
- bundle "in"
- expect(err).to eq("Ambiguous command in matches [info, init, inject, install]")
- end
-end
diff --git a/spec/bundler/other/ext_spec.rb b/spec/bundler/other/ext_spec.rb
deleted file mode 100644
index f2a512e629..0000000000
--- a/spec/bundler/other/ext_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Gem::Specification#match_platform" do
- it "does not match platforms other than the gem platform" do
- darwin = gem "lol", "1.0", "platform_specific-1.0-x86-darwin-10"
- expect(darwin.match_platform(pl("java"))).to eq(false)
- end
-
- context "when platform is a string" do
- it "matches when platform is a string" do
- lazy_spec = Bundler::LazySpecification.new("lol", "1.0", "universal-mingw32")
- expect(lazy_spec.match_platform(pl("x86-mingw32"))).to eq(true)
- expect(lazy_spec.match_platform(pl("x64-mingw32"))).to eq(true)
- end
- end
-end
-
-RSpec.describe "Bundler::GemHelpers#generic" do
- include Bundler::GemHelpers
-
- it "converts non-windows platforms into ruby" do
- expect(generic(pl("x86-darwin-10"))).to eq(pl("ruby"))
- expect(generic(pl("ruby"))).to eq(pl("ruby"))
- end
-
- it "converts java platform variants into java" do
- expect(generic(pl("universal-java-17"))).to eq(pl("java"))
- expect(generic(pl("java"))).to eq(pl("java"))
- end
-
- it "converts mswin platform variants into x86-mswin32" do
- expect(generic(pl("mswin32"))).to eq(pl("x86-mswin32"))
- expect(generic(pl("i386-mswin32"))).to eq(pl("x86-mswin32"))
- expect(generic(pl("x86-mswin32"))).to eq(pl("x86-mswin32"))
- end
-
- it "converts 32-bit mingw platform variants into x86-mingw32" do
- expect(generic(pl("mingw32"))).to eq(pl("x86-mingw32"))
- expect(generic(pl("i386-mingw32"))).to eq(pl("x86-mingw32"))
- expect(generic(pl("x86-mingw32"))).to eq(pl("x86-mingw32"))
- end
-
- it "converts 64-bit mingw platform variants into x64-mingw32" do
- expect(generic(pl("x64-mingw32"))).to eq(pl("x64-mingw32"))
- expect(generic(pl("x86_64-mingw32"))).to eq(pl("x64-mingw32"))
- end
-end
-
-RSpec.describe "Gem::SourceIndex#refresh!" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "does not explode when called" do
- run "Gem.source_index.refresh!"
- run "Gem::SourceIndex.new([]).refresh!"
- end
-end
diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb
deleted file mode 100644
index df2fdd263a..0000000000
--- a/spec/bundler/other/major_deprecation_spec.rb
+++ /dev/null
@@ -1,562 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "major deprecations" do
- let(:warnings) { err }
-
- describe "Bundler" do
- before do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- describe ".clean_env" do
- before do
- source = "Bundler.clean_env"
- bundle "exec ruby -e #{source.dump}"
- end
-
- it "is deprecated in favor of .unbundled_env", :bundler => "2" do
- expect(deprecations).to include \
- "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env` " \
- "(called at -e:1)"
- end
-
- pending "is removed and shows a helpful error message about it", :bundler => "3"
- end
-
- describe ".with_clean_env" do
- before do
- source = "Bundler.with_clean_env {}"
- bundle "exec ruby -e #{source.dump}"
- end
-
- it "is deprecated in favor of .unbundled_env", :bundler => "2" do
- expect(deprecations).to include(
- "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env` " \
- "(called at -e:1)"
- )
- end
-
- pending "is removed and shows a helpful error message about it", :bundler => "3"
- end
-
- describe ".clean_system" do
- before do
- source = "Bundler.clean_system('ls')"
- bundle "exec ruby -e #{source.dump}"
- end
-
- it "is deprecated in favor of .unbundled_system", :bundler => "2" do
- expect(deprecations).to include(
- "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
- "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system` " \
- "(called at -e:1)"
- )
- end
-
- pending "is removed and shows a helpful error message about it", :bundler => "3"
- end
-
- describe ".clean_exec" do
- before do
- source = "Bundler.clean_exec('ls')"
- bundle "exec ruby -e #{source.dump}"
- end
-
- it "is deprecated in favor of .unbundled_exec", :bundler => "2" do
- expect(deprecations).to include(
- "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
- "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec` " \
- "(called at -e:1)"
- )
- end
-
- pending "is removed and shows a helpful error message about it", :bundler => "3"
- end
-
- describe ".environment" do
- before do
- source = "Bundler.environment"
- bundle "exec ruby -e #{source.dump}"
- end
-
- it "is deprecated in favor of .load", :bundler => "2" do
- expect(deprecations).to include "Bundler.environment has been removed in favor of Bundler.load (called at -e:1)"
- end
-
- pending "is removed and shows a helpful error message about it", :bundler => "3"
- end
- end
-
- describe "bundle update --quiet" do
- it "does not print any deprecations" do
- bundle :update, :quiet => true
- expect(deprecations).to be_empty
- end
- end
-
- context "bundle check --path" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle "check --path vendor/bundle"
- end
-
- it "should print a deprecation warning", :bundler => "2" do
- expect(deprecations).to include(
- "The `--path` flag is deprecated because it relies on being " \
- "remembered across bundler invocations, which bundler will no " \
- "longer do in future versions. Instead please use `bundle config set " \
- "path 'vendor/bundle'`, and stop using this flag"
- )
- end
-
- pending "should fail with a helpful error", :bundler => "3"
- end
-
- describe "bundle config" do
- describe "old list interface" do
- before do
- bundle! "config"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config list` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- describe "old get interface" do
- before do
- bundle! "config waka"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config get waka` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- describe "old set interface" do
- before do
- bundle! "config waka wakapun"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set waka wakapun` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- describe "old set interface with --local" do
- before do
- bundle! "config --local waka wakapun"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --local waka wakapun` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- describe "old set interface with --global" do
- before do
- bundle! "config --global waka wakapun"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --global waka wakapun` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- describe "old unset interface" do
- before do
- bundle! "config --delete waka"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset waka` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- describe "old unset interface with --local" do
- before do
- bundle! "config --delete --local waka"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --local waka` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- describe "old unset interface with --global" do
- before do
- bundle! "config --delete --global waka"
- end
-
- it "warns", :bundler => "3" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --global waka` instead.")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
- end
-
- describe "bundle update" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "warns when no options are given", :bundler => "3" do
- bundle! "update"
- expect(deprecations).to include("Pass --all to `bundle update` to update everything")
- end
-
- pending "fails with a helpful error when no options are given", :bundler => "3"
-
- it "does not warn when --all is passed" do
- bundle! "update --all"
- expect(deprecations).to be_empty
- end
- end
-
- describe "bundle install --binstubs" do
- before do
- install_gemfile <<-G, :binstubs => true
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "should output a deprecation warning", :bundler => "2" do
- expect(deprecations).to include("The --binstubs option will be removed in favor of `bundle binstubs`")
- end
-
- pending "fails with a helpful error", :bundler => "3"
- end
-
- context "bundle install with both gems.rb and Gemfile present" do
- it "should not warn about gems.rb" do
- create_file "gems.rb", <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- bundle :install
- expect(deprecations).to be_empty
- end
-
- it "should print a proper warning, and use gems.rb" do
- create_file "gems.rb"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- expect(warnings).to include(
- "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
- )
-
- expect(the_bundle).not_to include_gem "rack 1.0"
- end
- end
-
- context "bundle install with flags" do
- before do
- bundle "config set --local path vendor/bundle"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- {
- :clean => true,
- :deployment => true,
- :frozen => true,
- :"no-cache" => true,
- :"no-prune" => true,
- :path => "vendor/bundle",
- :shebang => "ruby27",
- :system => true,
- :without => "development",
- :with => "development",
- }.each do |name, value|
- flag_name = "--#{name}"
-
- context "with the #{flag_name} flag" do
- before do
- bundle "install" # to create a lockfile, which deployment or frozen need
- bundle "install #{flag_name} #{value}"
- end
-
- it "should print a deprecation warning", :bundler => "2" do
- expect(deprecations).to include(
- "The `#{flag_name}` flag is deprecated because it relies on " \
- "being remembered across bundler invocations, which bundler " \
- "will no longer do in future versions. Instead please use " \
- "`bundle config set #{name} '#{value}'`, and stop using this flag"
- )
- end
-
- pending "should fail with a helpful error", :bundler => "3"
- end
- end
- end
-
- context "bundle install with multiple sources" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo3)}"
- source "#{file_uri_for(gem_repo1)}"
- G
- end
-
- it "shows a deprecation", :bundler => "2" do
- expect(deprecations).to include(
- "Your Gemfile contains multiple primary sources. " \
- "Using `source` more than once without a block is a security risk, and " \
- "may result in installing unexpected gems. To resolve this warning, use " \
- "a block to indicate which gems should come from the secondary source. " \
- "To upgrade this warning to an error, run `bundle config set " \
- "disable_multisource true`."
- )
- end
-
- pending "should fail with a helpful error", :bundler => "3"
- end
-
- context "when Bundler.setup is run in a ruby script" do
- before do
- create_file "gems.rb"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :group => :test
- G
-
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
-
- Bundler.setup
- Bundler.setup
- RUBY
- end
-
- it "should print a single deprecation warning" do
- expect(warnings).to include(
- "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
- )
- end
- end
-
- context "when `bundler/deployment` is required in a ruby script" do
- before do
- ruby(<<-RUBY)
- require 'bundler/deployment'
- RUBY
- end
-
- it "should print a capistrano deprecation warning", :bundler => "2" do
- expect(deprecations).to include("Bundler no longer integrates " \
- "with Capistrano, but Capistrano provides " \
- "its own integration with Bundler via the " \
- "capistrano-bundler gem. Use it instead.")
- end
-
- pending "should fail with a helpful error", :bundler => "3"
- end
-
- describe Bundler::Dsl do
- before do
- @rubygems = double("rubygems")
- allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems }
- end
-
- context "with github gems" do
- it "warns about removal", :bundler => "2" do
- msg = <<-EOS
-The :github git source is deprecated, and will be removed in the future. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
-
- git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
-
- EOS
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
- subject.gem("sparks", :github => "indirect/sparks")
- github_uri = "https://github.com/indirect/sparks.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
-
- pending "should fail with a helpful error", :bundler => "3"
- end
-
- context "with bitbucket gems" do
- it "warns about removal", :bundler => "2" do
- allow(Bundler.ui).to receive(:deprecate)
- msg = <<-EOS
-The :bitbucket git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
-
- git_source(:bitbucket) do |repo_name|
- user_name, repo_name = repo_name.split("/")
- repo_name ||= user_name
- "https://\#{user_name}@bitbucket.org/\#{user_name}/\#{repo_name}.git"
- end
-
- EOS
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
- subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
- end
-
- pending "should fail with a helpful error", :bundler => "3"
- end
-
- context "with gist gems" do
- it "warns about removal", :bundler => "2" do
- allow(Bundler.ui).to receive(:deprecate)
- msg = <<-EOS
-The :gist git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
-
- git_source(:gist) {|repo_name| "https://gist.github.com/\#{repo_name}.git" }
-
- EOS
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
- subject.gem("not-really-a-gem", :gist => "1234")
- end
-
- pending "should fail with a helpful error", :bundler => "3"
- end
- end
-
- context "bundle show" do
- before do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- context "without flags" do
- before do
- bundle! :show
- end
-
- it "prints a deprecation warning recommending `bundle list`", :bundler => "2" do
- expect(deprecations).to include("use `bundle list` instead of `bundle show`")
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
-
- context "with --outdated flag" do
- before do
- bundle! "show --outdated"
- end
-
- it "prints a deprecation warning informing about its removal", :bundler => "2" do
- expect(deprecations).to include("the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement")
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
-
- context "with --verbose flag" do
- before do
- bundle! "show --verbose"
- end
-
- it "prints a deprecation warning informing about its removal", :bundler => "2" do
- expect(deprecations).to include("the `--verbose` flag to `bundle show` was undocumented and will be removed without replacement")
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
-
- context "with a gem argument" do
- before do
- bundle! "show rack"
- end
-
- it "prints a deprecation warning recommending `bundle info`", :bundler => "2" do
- expect(deprecations).to include("use `bundle info rack` instead of `bundle show rack`")
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
-
- context "with the --paths option" do
- before do
- bundle "show --paths"
- end
-
- it "prints a deprecation warning recommending `bundle list`", :bundler => "2" do
- expect(deprecations).to include("use `bundle list` instead of `bundle show --paths`")
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
-
- context "with a gem argument and the --paths option" do
- before do
- bundle "show rack --paths"
- end
-
- it "prints deprecation warning recommending `bundle info`", :bundler => "2" do
- expect(deprecations).to include("use `bundle info rack --path` instead of `bundle show rack --paths`")
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
- end
-
- context "bundle console" do
- before do
- bundle "console"
- end
-
- it "prints a deprecation warning", :bundler => "2" do
- expect(deprecations).to include \
- "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`"
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
-
- context "bundle viz" do
- let(:ruby_graphviz) do
- graphviz_glob = base_system_gems.join("cache/ruby-graphviz*")
- Pathname.glob(graphviz_glob).first
- end
-
- before do
- system_gems ruby_graphviz
- create_file "gems.rb"
- bundle "viz"
- end
-
- it "prints a deprecation warning", :bundler => "2" do
- expect(deprecations).to include "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
- end
-
- pending "fails with a helpful message", :bundler => "3"
- end
-end
diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb
deleted file mode 100644
index 9f25637622..0000000000
--- a/spec/bundler/other/platform_spec.rb
+++ /dev/null
@@ -1,1307 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle platform" do
- context "without flags" do
- let(:bundle_platform_platforms_string) do
- local_platforms.reverse.map {|pl| "* #{pl}" }.join("\n")
- end
-
- it "returns all the output" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- #{ruby_version_correct}
-
- gem "foo"
- G
-
- bundle "platform"
- expect(out).to eq(<<-G.chomp)
-Your platform is: #{RUBY_PLATFORM}
-
-Your app has gems that work on these platforms:
-#{bundle_platform_platforms_string}
-
-Your Gemfile specifies a Ruby version requirement:
-* ruby #{RUBY_VERSION}
-
-Your current platform satisfies the Ruby version requirement.
-G
- end
-
- it "returns all the output including the patchlevel" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- #{ruby_version_correct_patchlevel}
-
- gem "foo"
- G
-
- bundle "platform"
- expect(out).to eq(<<-G.chomp)
-Your platform is: #{RUBY_PLATFORM}
-
-Your app has gems that work on these platforms:
-#{bundle_platform_platforms_string}
-
-Your Gemfile specifies a Ruby version requirement:
-* ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
-
-Your current platform satisfies the Ruby version requirement.
-G
- end
-
- it "doesn't print ruby version requirement if it isn't specified" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo"
- G
-
- bundle "platform"
- expect(out).to eq(<<-G.chomp)
-Your platform is: #{RUBY_PLATFORM}
-
-Your app has gems that work on these platforms:
-#{bundle_platform_platforms_string}
-
-Your Gemfile does not specify a Ruby version requirement.
-G
- end
-
- it "doesn't match the ruby version requirement" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- #{ruby_version_incorrect}
-
- gem "foo"
- G
-
- bundle "platform"
- expect(out).to eq(<<-G.chomp)
-Your platform is: #{RUBY_PLATFORM}
-
-Your app has gems that work on these platforms:
-#{bundle_platform_platforms_string}
-
-Your Gemfile specifies a Ruby version requirement:
-* ruby #{not_local_ruby_version}
-
-Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}
-G
- end
- end
-
- context "--ruby" do
- it "returns ruby version when explicit" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3'
-
- gem "foo"
- G
-
- bundle "platform --ruby"
-
- expect(out).to eq("ruby 1.9.3")
- end
-
- it "defaults to MRI" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "1.9.3"
-
- gem "foo"
- G
-
- bundle "platform --ruby"
-
- expect(out).to eq("ruby 1.9.3")
- end
-
- it "handles jruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "1.8.7", :engine => 'jruby', :engine_version => '1.6.5'
-
- gem "foo"
- G
-
- bundle "platform --ruby"
-
- expect(out).to eq("ruby 1.8.7 (jruby 1.6.5)")
- end
-
- it "handles rbx" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "1.8.7", :engine => 'rbx', :engine_version => '1.2.4'
-
- gem "foo"
- G
-
- bundle "platform --ruby"
-
- expect(out).to eq("ruby 1.8.7 (rbx 1.2.4)")
- end
-
- it "handles truffleruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "2.5.1", :engine => 'truffleruby', :engine_version => '1.0.0-rc6'
-
- gem "foo"
- G
-
- bundle "platform --ruby"
-
- expect(out).to eq("ruby 2.5.1 (truffleruby 1.0.0-rc6)")
- end
-
- it "raises an error if engine is used but engine version is not" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "1.8.7", :engine => 'rbx'
-
- gem "foo"
- G
-
- bundle "platform"
-
- expect(exitstatus).not_to eq(0) if exitstatus
- end
-
- it "raises an error if engine_version is used but engine is not" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "1.8.7", :engine_version => '1.2.4'
-
- gem "foo"
- G
-
- bundle "platform"
-
- expect(exitstatus).not_to eq(0) if exitstatus
- end
-
- it "raises an error if engine version doesn't match ruby version for MRI" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- ruby "1.8.7", :engine => 'ruby', :engine_version => '1.2.4'
-
- gem "foo"
- G
-
- bundle "platform"
-
- expect(exitstatus).not_to eq(0) if exitstatus
- end
-
- it "should print if no ruby version is specified" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "foo"
- G
-
- bundle "platform --ruby"
-
- expect(out).to eq("No ruby version specified")
- end
-
- it "handles when there is a locked requirement" do
- gemfile <<-G
- ruby "< 1.8.7"
- G
-
- lockfile <<-L
- GEM
- specs:
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
-
- RUBY VERSION
- ruby 1.0.0p127
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- bundle! "platform --ruby"
- expect(out).to eq("ruby 1.0.0p127")
- end
-
- it "handles when there is a requirement in the gemfile" do
- gemfile <<-G
- ruby ">= 1.8.7"
- G
-
- bundle! "platform --ruby"
- expect(out).to eq("ruby 1.8.7")
- end
-
- it "handles when there are multiple requirements in the gemfile" do
- gemfile <<-G
- ruby ">= 1.8.7", "< 2.0.0"
- G
-
- bundle! "platform --ruby"
- expect(out).to eq("ruby 1.8.7")
- end
- end
-
- let(:ruby_version_correct) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{local_engine_version}\"" }
- let(:ruby_version_correct_engineless) { "ruby \"#{RUBY_VERSION}\"" }
- let(:ruby_version_correct_patchlevel) { "#{ruby_version_correct}, :patchlevel => '#{RUBY_PATCHLEVEL}'" }
- let(:ruby_version_incorrect) { "ruby \"#{not_local_ruby_version}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_ruby_version}\"" }
- let(:engine_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{not_local_tag}\", :engine_version => \"#{RUBY_VERSION}\"" }
- let(:engine_version_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_engine_version}\"" }
- let(:patchlevel_incorrect) { "#{ruby_version_correct}, :patchlevel => '#{not_local_patchlevel}'" }
- let(:patchlevel_fixnum) { "#{ruby_version_correct}, :patchlevel => #{RUBY_PATCHLEVEL}1" }
-
- def should_be_ruby_version_incorrect
- expect(exitstatus).to eq(18) if exitstatus
- expect(err).to be_include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}")
- end
-
- def should_be_engine_incorrect
- expect(exitstatus).to eq(18) if exitstatus
- expect(err).to be_include("Your Ruby engine is #{local_ruby_engine}, but your Gemfile specified #{not_local_tag}")
- end
-
- def should_be_engine_version_incorrect
- expect(exitstatus).to eq(18) if exitstatus
- expect(err).to be_include("Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}")
- end
-
- def should_be_patchlevel_incorrect
- expect(exitstatus).to eq(18) if exitstatus
- expect(err).to be_include("Your Ruby patchlevel is #{RUBY_PATCHLEVEL}, but your Gemfile specified #{not_local_patchlevel}")
- end
-
- def should_be_patchlevel_fixnum
- expect(exitstatus).to eq(18) if exitstatus
- expect(err).to be_include("The Ruby patchlevel in your Gemfile must be a string")
- end
-
- context "bundle install" do
- it "installs fine when the ruby version matches" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{ruby_version_correct}
- G
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "installs fine with any engine" do
- simulate_ruby_engine "jruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{ruby_version_correct_engineless}
- G
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
- end
-
- it "installs fine when the patchlevel matches" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{ruby_version_correct_patchlevel}
- G
-
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "doesn't install when the ruby version doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{ruby_version_incorrect}
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_ruby_version_incorrect
- end
-
- it "doesn't install when engine doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{engine_incorrect}
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_engine_incorrect
- end
-
- it "doesn't install when engine version doesn't match" do
- simulate_ruby_engine "jruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{engine_version_incorrect}
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_engine_version_incorrect
- end
- end
-
- it "doesn't install when patchlevel doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle check" do
- it "checks fine when the ruby version matches" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{ruby_version_correct}
- G
-
- bundle :check
- expect(exitstatus).to eq(0) if exitstatus
- expect(out).to eq("Resolving dependencies...\nThe Gemfile's dependencies are satisfied")
- end
-
- it "checks fine with any engine" do
- simulate_ruby_engine "jruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{ruby_version_correct_engineless}
- G
-
- bundle :check
- expect(exitstatus).to eq(0) if exitstatus
- expect(out).to eq("Resolving dependencies...\nThe Gemfile's dependencies are satisfied")
- end
- end
-
- it "fails when ruby version doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{ruby_version_incorrect}
- G
-
- bundle :check
- should_be_ruby_version_incorrect
- end
-
- it "fails when engine doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{engine_incorrect}
- G
-
- bundle :check
- should_be_engine_incorrect
- end
-
- it "fails when engine version doesn't match" do
- simulate_ruby_engine "ruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{engine_version_incorrect}
- G
-
- bundle :check
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when patchlevel doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
-
- bundle :check
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle update" do
- before do
- build_repo2
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
- G
- end
-
- it "updates successfully when the ruby version matches" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
-
- #{ruby_version_correct}
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle "update", :all => true
- expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
- end
-
- it "updates fine with any engine" do
- simulate_ruby_engine "jruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
-
- #{ruby_version_correct_engineless}
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle "update", :all => true
- expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
- end
- end
-
- it "fails when ruby version doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
-
- #{ruby_version_incorrect}
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle :update, :all => true
- should_be_ruby_version_incorrect
- end
-
- it "fails when ruby engine doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
-
- #{engine_incorrect}
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle :update, :all => true
- should_be_engine_incorrect
- end
-
- it "fails when ruby engine version doesn't match" do
- simulate_ruby_engine "jruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport"
- gem "rack-obama"
-
- #{engine_version_incorrect}
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle :update, :all => true
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when patchlevel doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle :update, :all => true
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle info" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
- end
-
- it "prints path if ruby version is correct" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- #{ruby_version_correct}
- G
-
- bundle "info rails --path"
- expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
- end
-
- it "prints path if ruby version is correct for any engine" do
- simulate_ruby_engine "jruby" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- #{ruby_version_correct_engineless}
- G
-
- bundle "info rails --path"
- expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
- end
- end
-
- it "fails if ruby version doesn't match", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- #{ruby_version_incorrect}
- G
-
- bundle "show rails"
- should_be_ruby_version_incorrect
- end
-
- it "fails if engine doesn't match", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- #{engine_incorrect}
- G
-
- bundle "show rails"
- should_be_engine_incorrect
- end
-
- it "fails if engine version doesn't match", :bundler => "< 3" do
- simulate_ruby_engine "jruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
-
- #{engine_version_incorrect}
- G
-
- bundle "show rails"
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when patchlevel doesn't match", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
- update_repo2 do
- build_gem "activesupport", "3.0"
- end
-
- bundle "show rails"
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle cache" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
- end
-
- it "copies the .gem file to vendor/cache when ruby version matches" do
- gemfile <<-G
- gem 'rack'
-
- #{ruby_version_correct}
- G
-
- bundle :cache
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
-
- it "copies the .gem file to vendor/cache when ruby version matches for any engine" do
- simulate_ruby_engine "jruby" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
-
- #{ruby_version_correct_engineless}
- G
-
- bundle! :cache
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
- end
-
- it "fails if the ruby version doesn't match" do
- gemfile <<-G
- gem 'rack'
-
- #{ruby_version_incorrect}
- G
-
- bundle :cache
- should_be_ruby_version_incorrect
- end
-
- it "fails if the engine doesn't match" do
- gemfile <<-G
- gem 'rack'
-
- #{engine_incorrect}
- G
-
- bundle :cache
- should_be_engine_incorrect
- end
-
- it "fails if the engine version doesn't match" do
- simulate_ruby_engine "jruby" do
- gemfile <<-G
- gem 'rack'
-
- #{engine_version_incorrect}
- G
-
- bundle :cache
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when patchlevel doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
-
- bundle :cache
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle pack" do
- before do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
- end
-
- it "copies the .gem file to vendor/cache when ruby version matches" do
- gemfile <<-G
- gem 'rack'
-
- #{ruby_version_correct}
- G
-
- bundle :cache
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
-
- it "copies the .gem file to vendor/cache when ruby version matches any engine" do
- simulate_ruby_engine "jruby" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
-
- #{ruby_version_correct_engineless}
- G
-
- bundle :cache
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- end
- end
-
- it "fails if the ruby version doesn't match" do
- gemfile <<-G
- gem 'rack'
-
- #{ruby_version_incorrect}
- G
-
- bundle :cache
- should_be_ruby_version_incorrect
- end
-
- it "fails if the engine doesn't match" do
- gemfile <<-G
- gem 'rack'
-
- #{engine_incorrect}
- G
-
- bundle :cache
- should_be_engine_incorrect
- end
-
- it "fails if the engine version doesn't match" do
- simulate_ruby_engine "jruby" do
- gemfile <<-G
- gem 'rack'
-
- #{engine_version_incorrect}
- G
-
- bundle :cache
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when patchlevel doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
-
- bundle :cache
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle exec" do
- before do
- ENV["BUNDLER_FORCE_TTY"] = "true"
- system_gems "rack-1.0.0", "rack-0.9.1", :path => :bundle_path
- end
-
- it "activates the correct gem when ruby version matches" do
- gemfile <<-G
- gem "rack", "0.9.1"
-
- #{ruby_version_correct}
- G
-
- bundle "exec rackup"
- expect(out).to include("0.9.1")
- end
-
- it "activates the correct gem when ruby version matches any engine" do
- simulate_ruby_engine "jruby" do
- system_gems "rack-1.0.0", "rack-0.9.1", :path => :bundle_path
- gemfile <<-G
- gem "rack", "0.9.1"
-
- #{ruby_version_correct_engineless}
- G
-
- bundle "exec rackup"
- expect(out).to include("0.9.1")
- end
- end
-
- it "fails when the ruby version doesn't match" do
- gemfile <<-G
- gem "rack", "0.9.1"
-
- #{ruby_version_incorrect}
- G
-
- bundle "exec rackup"
- should_be_ruby_version_incorrect
- end
-
- it "fails when the engine doesn't match" do
- gemfile <<-G
- gem "rack", "0.9.1"
-
- #{engine_incorrect}
- G
-
- bundle "exec rackup"
- should_be_engine_incorrect
- end
-
- # it "fails when the engine version doesn't match" do
- # simulate_ruby_engine "jruby" do
- # gemfile <<-G
- # gem "rack", "0.9.1"
- #
- # #{engine_version_incorrect}
- # G
- #
- # bundle "exec rackup"
- # should_be_engine_version_incorrect
- # end
- # end
-
- it "fails when patchlevel doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
-
- bundle "exec rackup"
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle console", :bundler => "< 3" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
- G
- end
-
- it "starts IRB with the default group loaded when ruby version matches" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
-
- #{ruby_version_correct}
- G
-
- bundle "console" do |input, _, _|
- input.puts("puts RACK")
- input.puts("exit")
- end
- expect(out).to include("0.9.1")
- end
-
- it "starts IRB with the default group loaded when ruby version matches any engine" do
- skip "irb depend on JRuby.compile_ir and don't work in simulated environment." unless RUBY_ENGINE == "jruby"
- simulate_ruby_engine "jruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
-
- #{ruby_version_correct_engineless}
- G
-
- bundle "console" do |input, _, _|
- input.puts("puts RACK")
- input.puts("exit")
- end
- expect(out).to include("0.9.1")
- end
- end
-
- it "fails when ruby version doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
-
- #{ruby_version_incorrect}
- G
-
- bundle "console"
- should_be_ruby_version_incorrect
- end
-
- it "fails when engine doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
-
- #{engine_incorrect}
- G
-
- bundle "console"
- should_be_engine_incorrect
- end
-
- it "fails when engine version doesn't match" do
- simulate_ruby_engine "jruby" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
-
- #{engine_version_incorrect}
- G
-
- bundle "console"
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when patchlevel doesn't match" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- gem "rack_middleware", :group => :development
-
- #{patchlevel_incorrect}
- G
-
- bundle "console"
- should_be_patchlevel_incorrect
- end
- end
-
- context "Bundler.setup" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack", :group => :test
- G
-
- ENV["BUNDLER_FORCE_TTY"] = "true"
- end
-
- it "makes a Gemfile.lock if setup succeeds" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack"
-
- #{ruby_version_correct}
- G
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- run "1"
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- it "makes a Gemfile.lock if setup succeeds for any engine" do
- simulate_ruby_engine "jruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack"
-
- #{ruby_version_correct_engineless}
- G
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- run "1"
- expect(bundled_app("Gemfile.lock")).to exist
- end
- end
-
- it "fails when ruby version doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack"
-
- #{ruby_version_incorrect}
- G
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- ruby <<-R
- require 'bundler/setup'
- R
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_ruby_version_incorrect
- end
-
- it "fails when engine doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack"
-
- #{engine_incorrect}
- G
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- ruby <<-R
- require 'bundler/setup'
- R
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_engine_incorrect
- end
-
- it "fails when engine version doesn't match" do
- simulate_ruby_engine "jruby" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack"
-
- #{engine_version_incorrect}
- G
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- ruby <<-R
- require 'bundler/setup'
- R
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when patchlevel doesn't match" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack"
-
- #{patchlevel_incorrect}
- G
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- ruby <<-R
- require 'bundler/setup'
- R
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- should_be_patchlevel_incorrect
- end
- end
-
- context "bundle outdated" do
- before do
- build_repo2 do
- build_git "foo", :path => lib_path("foo")
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
- G
- end
-
- it "returns list of outdated gems when the ruby version matches" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{ruby_version_correct}
- G
-
- bundle "outdated"
- expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5")
- expect(out).to include("foo (newest 1.0")
- end
-
- it "returns list of outdated gems when the ruby version matches for any engine" do
- simulate_ruby_engine "jruby" do
- bundle! :install
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{ruby_version_correct_engineless}
- G
-
- bundle "outdated"
- expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)")
- expect(out).to include("foo (newest 1.0")
- end
- end
-
- it "fails when the ruby version doesn't match" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{ruby_version_incorrect}
- G
-
- bundle "outdated"
- should_be_ruby_version_incorrect
- end
-
- it "fails when the engine doesn't match" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{engine_incorrect}
- G
-
- bundle "outdated"
- should_be_engine_incorrect
- end
-
- it "fails when the engine version doesn't match" do
- simulate_ruby_engine "jruby" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{engine_version_incorrect}
- G
-
- bundle "outdated"
- should_be_engine_version_incorrect
- end
- end
-
- it "fails when the patchlevel doesn't match" do
- simulate_ruby_engine "jruby" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{patchlevel_incorrect}
- G
-
- bundle "outdated"
- should_be_patchlevel_incorrect
- end
- end
-
- it "fails when the patchlevel is a fixnum" do
- simulate_ruby_engine "jruby" do
- update_repo2 do
- build_gem "activesupport", "3.0"
- update_git "foo", :path => lib_path("foo")
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "activesupport", "2.3.5"
- gem "foo", :git => "#{lib_path("foo")}"
-
- #{patchlevel_fixnum}
- G
-
- bundle "outdated"
- should_be_patchlevel_fixnum
- end
- end
- end
-end
diff --git a/spec/bundler/plugins/command_spec.rb b/spec/bundler/plugins/command_spec.rb
deleted file mode 100644
index 4728f66f5f..0000000000
--- a/spec/bundler/plugins/command_spec.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "command plugins" do
- before do
- build_repo2 do
- build_plugin "command-mah" do |s|
- s.write "plugins.rb", <<-RUBY
- module Mah
- class Plugin < Bundler::Plugin::API
- command "mahcommand" # declares the command
-
- def exec(command, args)
- puts "MahHello"
- end
- end
- end
- RUBY
- end
- end
-
- bundle "plugin install command-mah --source #{file_uri_for(gem_repo2)}"
- end
-
- it "executes without arguments" do
- expect(out).to include("Installed plugin command-mah")
-
- bundle "mahcommand"
- expect(out).to eq("MahHello")
- end
-
- it "accepts the arguments" do
- build_repo2 do
- build_plugin "the-echoer" do |s|
- s.write "plugins.rb", <<-RUBY
- module Resonance
- class Echoer
- # Another method to declare the command
- Bundler::Plugin::API.command "echo", self
-
- def exec(command, args)
- puts "You gave me \#{args.join(", ")}"
- end
- end
- end
- RUBY
- end
- end
-
- bundle "plugin install the-echoer --source #{file_uri_for(gem_repo2)}"
- expect(out).to include("Installed plugin the-echoer")
-
- bundle "echo tacos tofu lasange"
- expect(out).to eq("You gave me tacos, tofu, lasange")
- end
-
- it "raises error on redeclaration of command" do
- build_repo2 do
- build_plugin "copycat" do |s|
- s.write "plugins.rb", <<-RUBY
- module CopyCat
- class Cheater < Bundler::Plugin::API
- command "mahcommand", self
-
- def exec(command, args)
- end
- end
- end
- RUBY
- end
- end
-
- bundle "plugin install copycat --source #{file_uri_for(gem_repo2)}"
-
- expect(out).not_to include("Installed plugin copycat")
-
- expect(err).to include("Failed to install plugin")
-
- expect(err).to include("Command(s) `mahcommand` declared by copycat are already registered.")
- end
-end
diff --git a/spec/bundler/plugins/hook_spec.rb b/spec/bundler/plugins/hook_spec.rb
deleted file mode 100644
index 72feb14d84..0000000000
--- a/spec/bundler/plugins/hook_spec.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "hook plugins" do
- context "before-install-all hook" do
- before do
- build_repo2 do
- build_plugin "before-install-all-plugin" do |s|
- s.write "plugins.rb", <<-RUBY
- Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_BEFORE_INSTALL_ALL do |deps|
- puts "gems to be installed \#{deps.map(&:name).join(", ")}"
- end
- RUBY
- end
- end
-
- bundle "plugin install before-install-all-plugin --source #{file_uri_for(gem_repo2)}"
- end
-
- it "runs before all rubygems are installed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rake"
- gem "rack"
- G
-
- expect(out).to include "gems to be installed rake, rack"
- end
- end
-
- context "before-install hook" do
- before do
- build_repo2 do
- build_plugin "before-install-plugin" do |s|
- s.write "plugins.rb", <<-RUBY
- Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_BEFORE_INSTALL do |spec_install|
- puts "installing gem \#{spec_install.name}"
- end
- RUBY
- end
- end
-
- bundle "plugin install before-install-plugin --source #{file_uri_for(gem_repo2)}"
- end
-
- it "runs before each rubygem is installed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rake"
- gem "rack"
- G
-
- expect(out).to include "installing gem rake"
- expect(out).to include "installing gem rack"
- end
- end
-
- context "after-install-all hook" do
- before do
- build_repo2 do
- build_plugin "after-install-all-plugin" do |s|
- s.write "plugins.rb", <<-RUBY
- Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_AFTER_INSTALL_ALL do |deps|
- puts "installed gems \#{deps.map(&:name).join(", ")}"
- end
- RUBY
- end
- end
-
- bundle "plugin install after-install-all-plugin --source #{file_uri_for(gem_repo2)}"
- end
-
- it "runs after each rubygem is installed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rake"
- gem "rack"
- G
-
- expect(out).to include "installed gems rake, rack"
- end
- end
-
- context "after-install hook" do
- before do
- build_repo2 do
- build_plugin "after-install-plugin" do |s|
- s.write "plugins.rb", <<-RUBY
- Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_AFTER_INSTALL do |spec_install|
- puts "installed gem \#{spec_install.name} : \#{spec_install.state}"
- end
- RUBY
- end
- end
-
- bundle "plugin install after-install-plugin --source #{file_uri_for(gem_repo2)}"
- end
-
- it "runs after each rubygem is installed" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rake"
- gem "rack"
- G
-
- expect(out).to include "installed gem rake : installed"
- expect(out).to include "installed gem rack : installed"
- end
- end
-end
diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb
deleted file mode 100644
index 669ed09fb5..0000000000
--- a/spec/bundler/plugins/install_spec.rb
+++ /dev/null
@@ -1,309 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundler plugin install" do
- before do
- build_repo2 do
- build_plugin "foo"
- build_plugin "kung-foo"
- end
- end
-
- it "shows proper message when gem in not found in the source" do
- bundle "plugin install no-foo --source #{file_uri_for(gem_repo1)}"
-
- expect(err).to include("Could not find")
- plugin_should_not_be_installed("no-foo")
- end
-
- it "installs from rubygems source" do
- bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
-
- expect(out).to include("Installed plugin foo")
- plugin_should_be_installed("foo")
- end
-
- context "plugin is already installed" do
- before do
- bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
- end
-
- it "doesn't install plugin again" do
- bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
- expect(out).not_to include("Installing plugin foo")
- expect(out).not_to include("Installed plugin foo")
- end
- end
-
- it "installs multiple plugins" do
- bundle "plugin install foo kung-foo --source #{file_uri_for(gem_repo2)}"
-
- expect(out).to include("Installed plugin foo")
- expect(out).to include("Installed plugin kung-foo")
-
- plugin_should_be_installed("foo", "kung-foo")
- end
-
- it "uses the same version for multiple plugins" do
- update_repo2 do
- build_plugin "foo", "1.1"
- build_plugin "kung-foo", "1.1"
- end
-
- bundle "plugin install foo kung-foo --version '1.0' --source #{file_uri_for(gem_repo2)}"
-
- expect(out).to include("Installing foo 1.0")
- expect(out).to include("Installing kung-foo 1.0")
- plugin_should_be_installed("foo", "kung-foo")
- end
-
- it "works with different load paths" do
- build_repo2 do
- build_plugin "testing" do |s|
- s.write "plugins.rb", <<-RUBY
- require "fubar"
- class Test < Bundler::Plugin::API
- command "check2"
-
- def exec(command, args)
- puts "mate"
- end
- end
- RUBY
- s.require_paths = %w[lib src]
- s.write("src/fubar.rb")
- end
- end
- bundle "plugin install testing --source #{file_uri_for(gem_repo2)}"
-
- bundle "check2", "no-color" => false
- expect(out).to eq("mate")
- end
-
- context "malformatted plugin" do
- it "fails when plugins.rb is missing" do
- update_repo2 do
- build_plugin "foo", "1.1"
- build_plugin "kung-foo", "1.1"
- end
-
- bundle "plugin install foo kung-foo --version '1.0' --source #{file_uri_for(gem_repo2)}"
-
- expect(out).to include("Installing foo 1.0")
- expect(out).to include("Installing kung-foo 1.0")
- plugin_should_be_installed("foo", "kung-foo")
-
- build_repo2 do
- build_gem "charlie"
- end
-
- bundle "plugin install charlie --source #{file_uri_for(gem_repo2)}"
-
- expect(err).to include("plugins.rb was not found")
-
- expect(global_plugin_gem("charlie-1.0")).not_to be_directory
-
- plugin_should_be_installed("foo", "kung-foo")
- plugin_should_not_be_installed("charlie")
- end
-
- it "fails when plugins.rb throws exception on load" do
- build_repo2 do
- build_plugin "chaplin" do |s|
- s.write "plugins.rb", <<-RUBY
- raise "I got you man"
- RUBY
- end
- end
-
- bundle "plugin install chaplin --source #{file_uri_for(gem_repo2)}"
-
- expect(global_plugin_gem("chaplin-1.0")).not_to be_directory
-
- plugin_should_not_be_installed("chaplin")
- end
- end
-
- context "git plugins" do
- it "installs form a git source" do
- build_git "foo" do |s|
- s.write "plugins.rb"
- end
-
- bundle "plugin install foo --git #{file_uri_for(lib_path("foo-1.0"))}"
-
- expect(out).to include("Installed plugin foo")
- plugin_should_be_installed("foo")
- end
-
- it "installs form a local git source" do
- build_git "foo" do |s|
- s.write "plugins.rb"
- end
-
- bundle "plugin install foo --local_git #{lib_path("foo-1.0")}"
-
- expect(out).to include("Installed plugin foo")
- plugin_should_be_installed("foo")
- end
-
- it "raises an error when both git and local git sources are specified" do
- bundle "plugin install foo --local_git /phony/path/project --git git@gitphony.com:/repo/project"
-
- expect(exitstatus).not_to eq(0) if exitstatus
- expect(err).to eq("Remote and local plugin git sources can't be both specified")
- end
- end
-
- context "Gemfile eval" do
- it "installs plugins listed in gemfile" do
- gemfile <<-G
- source '#{file_uri_for(gem_repo2)}'
- plugin 'foo'
- gem 'rack', "1.0.0"
- G
-
- bundle "install"
-
- expect(out).to include("Installed plugin foo")
-
- expect(out).to include("Bundle complete!")
-
- expect(the_bundle).to include_gems("rack 1.0.0")
- plugin_should_be_installed("foo")
- end
-
- it "accepts plugin version" do
- update_repo2 do
- build_plugin "foo", "1.1.0"
- end
-
- gemfile <<-G
- source '#{file_uri_for(gem_repo2)}'
- plugin 'foo', "1.0"
- G
-
- bundle "install"
-
- expect(out).to include("Installing foo 1.0")
-
- plugin_should_be_installed("foo")
-
- expect(out).to include("Bundle complete!")
- end
-
- it "accepts git sources" do
- build_git "ga-plugin" do |s|
- s.write "plugins.rb"
- end
-
- install_gemfile <<-G
- plugin 'ga-plugin', :git => "#{lib_path("ga-plugin-1.0")}"
- G
-
- expect(out).to include("Installed plugin ga-plugin")
- plugin_should_be_installed("ga-plugin")
- end
-
- context "in deployment mode" do
- it "installs plugins" do
- install_gemfile! <<-G
- source '#{file_uri_for(gem_repo2)}'
- gem 'rack', "1.0.0"
- G
-
- install_gemfile! <<-G, forgotten_command_line_options(:deployment => true)
- source '#{file_uri_for(gem_repo2)}'
- plugin 'foo'
- gem 'rack', "1.0.0"
- G
-
- expect(out).to include("Installed plugin foo")
-
- expect(out).to include("Bundle complete!")
-
- expect(the_bundle).to include_gems("rack 1.0.0")
- plugin_should_be_installed("foo")
- end
- end
- end
-
- context "inline gemfiles" do
- it "installs the listed plugins" do
- code = <<-RUBY
- require "bundler/inline"
-
- gemfile do
- source '#{file_uri_for(gem_repo2)}'
- plugin 'foo'
- end
- RUBY
-
- ruby code
- expect(local_plugin_gem("foo-1.0", "plugins.rb")).to exist
- end
- end
-
- describe "local plugin" do
- it "is installed when inside an app" do
- gemfile ""
- bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
-
- plugin_should_be_installed("foo")
- expect(local_plugin_gem("foo-1.0")).to be_directory
- end
-
- context "conflict with global plugin" do
- before do
- update_repo2 do
- build_plugin "fubar" do |s|
- s.write "plugins.rb", <<-RUBY
- class Fubar < Bundler::Plugin::API
- command "shout"
-
- def exec(command, args)
- puts "local_one"
- end
- end
- RUBY
- end
- end
-
- # inside the app
- gemfile "source '#{file_uri_for(gem_repo2)}'\nplugin 'fubar'"
- bundle "install"
-
- update_repo2 do
- build_plugin "fubar", "1.1" do |s|
- s.write "plugins.rb", <<-RUBY
- class Fubar < Bundler::Plugin::API
- command "shout"
-
- def exec(command, args)
- puts "global_one"
- end
- end
- RUBY
- end
- end
-
- # outside the app
- Dir.chdir tmp
- bundle "plugin install fubar --source #{file_uri_for(gem_repo2)}"
- end
-
- it "inside the app takes precedence over global plugin" do
- Dir.chdir bundled_app
-
- bundle "shout"
- expect(out).to eq("local_one")
- end
-
- it "outside the app global plugin is used" do
- Dir.chdir tmp
-
- bundle "shout"
- expect(out).to eq("global_one")
- end
- end
- end
-end
diff --git a/spec/bundler/plugins/list_spec.rb b/spec/bundler/plugins/list_spec.rb
deleted file mode 100644
index 4a686415ad..0000000000
--- a/spec/bundler/plugins/list_spec.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundler plugin list" do
- before do
- build_repo2 do
- build_plugin "foo" do |s|
- s.write "plugins.rb", <<-RUBY
- class Foo < Bundler::Plugin::API
- command "shout"
-
- def exec(command, args)
- puts "Foo shout"
- end
- end
- RUBY
- end
- build_plugin "bar" do |s|
- s.write "plugins.rb", <<-RUBY
- class Bar < Bundler::Plugin::API
- command "scream"
-
- def exec(command, args)
- puts "Bar scream"
- end
- end
- RUBY
- end
- end
- end
-
- context "no plugins installed" do
- it "shows proper no plugins installed message" do
- bundle "plugin list"
-
- expect(out).to include("No plugins installed")
- end
- end
-
- context "single plugin installed" do
- it "shows plugin name with commands list" do
- bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
- plugin_should_be_installed("foo")
- bundle "plugin list"
-
- expected_output = "foo\n-----\n shout"
- expect(out).to include(expected_output)
- end
- end
-
- context "multiple plugins installed" do
- it "shows plugin names with commands list" do
- bundle "plugin install foo bar --source #{file_uri_for(gem_repo2)}"
- plugin_should_be_installed("foo", "bar")
- bundle "plugin list"
-
- expected_output = "foo\n-----\n shout\n\nbar\n-----\n scream"
- expect(out).to include(expected_output)
- end
- end
-end
diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb
deleted file mode 100644
index f2151a5a73..0000000000
--- a/spec/bundler/plugins/source/example_spec.rb
+++ /dev/null
@@ -1,508 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "real source plugins" do
- context "with a minimal source plugin" do
- before do
- build_repo2 do
- build_plugin "bundler-source-mpath" do |s|
- s.write "plugins.rb", <<-RUBY
- require "bundler-source-mpath"
-
- class MPath < Bundler::Plugin::API
- source "mpath"
-
- attr_reader :path
-
- def initialize(opts)
- super
-
- @path = Pathname.new options["uri"]
- end
-
- def fetch_gemspec_files
- @spec_files ||= begin
- glob = "{,*,*/*}.gemspec"
- if installed?
- search_path = install_path
- else
- search_path = path
- end
- Dir["\#{search_path.to_s}/\#{glob}"]
- end
- end
-
- def install(spec, opts)
- mkdir_p(install_path.parent)
- FileUtils.cp_r(path, install_path)
-
- spec_path = install_path.join("\#{spec.full_name}.gemspec")
- spec_path.open("wb") {|f| f.write spec.to_ruby }
- spec.loaded_from = spec_path.to_s
-
- post_install(spec)
-
- nil
- end
- end
- RUBY
- end # build_plugin
- end
-
- build_lib "a-path-gem"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}" # plugin source
- source "#{lib_path("a-path-gem-1.0")}", :type => :mpath do
- gem "a-path-gem"
- end
- G
- end
-
- it "installs" do
- bundle "install"
-
- expect(out).to include("Bundle complete!")
-
- expect(the_bundle).to include_gems("a-path-gem 1.0")
- end
-
- it "writes to lock file", :bundler => "< 3" do
- bundle "install"
-
- lockfile_should_be <<-G
- PLUGIN SOURCE
- remote: #{lib_path("a-path-gem-1.0")}
- type: mpath
- specs:
- a-path-gem (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- a-path-gem!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "writes to lock file", :bundler => "3" do
- bundle "install"
-
- lockfile_should_be <<-G
- PLUGIN SOURCE
- remote: #{lib_path("a-path-gem-1.0")}
- type: mpath
- specs:
- a-path-gem (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- a-path-gem!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "provides correct #full_gem_path" do
- bundle "install"
- run <<-RUBY
- puts Bundler.rubygems.find_name('a-path-gem').first.full_gem_path
- RUBY
- expect(out).to eq(bundle("info a-path-gem --path"))
- end
-
- it "installs the gem executables" do
- build_lib "gem_with_bin" do |s|
- s.executables = ["foo"]
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}" # plugin source
- source "#{lib_path("gem_with_bin-1.0")}", :type => :mpath do
- gem "gem_with_bin"
- end
- G
-
- bundle "exec foo"
- expect(out).to eq("1.0")
- end
-
- describe "bundle cache/package" do
- let(:uri_hash) { Digest(:SHA1).hexdigest(lib_path("a-path-gem-1.0").to_s) }
- it "copies repository to vendor cache and uses it" do
- bundle "install"
- bundle "config set cache_all true"
- bundle :cache
-
- expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
- expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}/.git")).not_to exist
- expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}/.bundlecache")).to be_file
-
- FileUtils.rm_rf lib_path("a-path-gem-1.0")
- expect(the_bundle).to include_gems("a-path-gem 1.0")
- end
-
- it "copies repository to vendor cache and uses it even when installed with bundle --path" do
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- bundle "config set cache_all true"
- bundle! :cache
-
- expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
-
- FileUtils.rm_rf lib_path("a-path-gem-1.0")
- expect(the_bundle).to include_gems("a-path-gem 1.0")
- end
-
- it "bundler package copies repository to vendor cache" do
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- bundle "config set cache_all true"
- bundle! :cache
-
- expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
-
- FileUtils.rm_rf lib_path("a-path-gem-1.0")
- expect(the_bundle).to include_gems("a-path-gem 1.0")
- end
- end
-
- context "with lockfile" do
- before do
- lockfile <<-G
- PLUGIN SOURCE
- remote: #{lib_path("a-path-gem-1.0")}
- type: mpath
- specs:
- a-path-gem (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- a-path-gem!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "installs" do
- bundle! "install"
-
- expect(the_bundle).to include_gems("a-path-gem 1.0")
- end
- end
- end
-
- context "with a more elaborate source plugin" do
- before do
- build_repo2 do
- build_plugin "bundler-source-gitp" do |s|
- s.write "plugins.rb", <<-RUBY
- class SPlugin < Bundler::Plugin::API
- source "gitp"
-
- attr_reader :ref
-
- def initialize(opts)
- super
-
- @ref = options["ref"] || options["branch"] || options["tag"] || "master"
- @unlocked = false
- end
-
- def eql?(other)
- other.is_a?(self.class) && uri == other.uri && ref == other.ref
- end
-
- alias_method :==, :eql?
-
- def fetch_gemspec_files
- @spec_files ||= begin
- glob = "{,*,*/*}.gemspec"
- if !cached?
- cache_repo
- end
-
- if installed? && !@unlocked
- path = install_path
- else
- path = cache_path
- end
-
- Dir["\#{path}/\#{glob}"]
- end
- end
-
- def install(spec, opts)
- mkdir_p(install_path.dirname)
- rm_rf(install_path)
- `git clone --no-checkout --quiet "\#{cache_path}" "\#{install_path}"`
- Dir.chdir install_path do
- `git reset --hard \#{revision}`
- end
-
- spec_path = install_path.join("\#{spec.full_name}.gemspec")
- spec_path.open("wb") {|f| f.write spec.to_ruby }
- spec.loaded_from = spec_path.to_s
-
- post_install(spec)
-
- nil
- end
-
- def options_to_lock
- opts = {"revision" => revision}
- opts["ref"] = ref if ref != "master"
- opts
- end
-
- def unlock!
- @unlocked = true
- @revision = latest_revision
- end
-
- def app_cache_dirname
- "\#{base_name}-\#{shortref_for_path(revision)}"
- end
-
- private
-
- def cache_path
- @cache_path ||= cache_dir.join("gitp", base_name)
- end
-
- def cache_repo
- `git clone --quiet \#{@options["uri"]} \#{cache_path}`
- end
-
- def cached?
- File.directory?(cache_path)
- end
-
- def locked_revision
- options["revision"]
- end
-
- def revision
- @revision ||= locked_revision || latest_revision
- end
-
- def latest_revision
- if !cached? || @unlocked
- rm_rf(cache_path)
- cache_repo
- end
-
- Dir.chdir cache_path do
- `git rev-parse --verify \#{@ref}`.strip
- end
- end
-
- def base_name
- File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)?(//\w*/)?(\w*/)*}, ""), ".git")
- end
-
- def shortref_for_path(ref)
- ref[0..11]
- end
-
- def install_path
- @install_path ||= begin
- git_scope = "\#{base_name}-\#{shortref_for_path(revision)}"
-
- path = gem_install_dir.join(git_scope)
-
- if !path.exist? && requires_sudo?
- user_bundle_path.join(ruby_scope).join(git_scope)
- else
- path
- end
- end
- end
-
- def installed?
- File.directory?(install_path)
- end
- end
- RUBY
- end
- end
-
- build_git "ma-gitp-gem"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}" # plugin source
- source "#{file_uri_for(lib_path("ma-gitp-gem-1.0"))}", :type => :gitp do
- gem "ma-gitp-gem"
- end
- G
- end
-
- it "handles the source option" do
- bundle "install"
- expect(out).to include("Bundle complete!")
- expect(the_bundle).to include_gems("ma-gitp-gem 1.0")
- end
-
- it "writes to lock file", :bundler => "< 3" do
- revision = revision_for(lib_path("ma-gitp-gem-1.0"))
- bundle "install"
-
- lockfile_should_be <<-G
- PLUGIN SOURCE
- remote: #{file_uri_for(lib_path("ma-gitp-gem-1.0"))}
- type: gitp
- revision: #{revision}
- specs:
- ma-gitp-gem (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- ma-gitp-gem!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "writes to lock file", :bundler => "3" do
- revision = revision_for(lib_path("ma-gitp-gem-1.0"))
- bundle "install"
-
- lockfile_should_be <<-G
- PLUGIN SOURCE
- remote: #{file_uri_for(lib_path("ma-gitp-gem-1.0"))}
- type: gitp
- revision: #{revision}
- specs:
- ma-gitp-gem (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- ma-gitp-gem!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- context "with lockfile" do
- before do
- revision = revision_for(lib_path("ma-gitp-gem-1.0"))
- lockfile <<-G
- PLUGIN SOURCE
- remote: #{file_uri_for(lib_path("ma-gitp-gem-1.0"))}
- type: gitp
- revision: #{revision}
- specs:
- ma-gitp-gem (1.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- ma-gitp-gem!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "installs" do
- bundle "install"
- expect(the_bundle).to include_gems("ma-gitp-gem 1.0")
- end
-
- it "uses the locked ref" do
- update_git "ma-gitp-gem"
- bundle "install"
-
- run <<-RUBY
- require 'ma/gitp/gem'
- puts "WIN" unless defined?(MAGITPGEM_PREV_REF)
- RUBY
- expect(out).to eq("WIN")
- end
-
- it "updates the deps on bundler update" do
- update_git "ma-gitp-gem"
- bundle "update ma-gitp-gem"
-
- run <<-RUBY
- require 'ma/gitp/gem'
- puts "WIN" if defined?(MAGITPGEM_PREV_REF)
- RUBY
- expect(out).to eq("WIN")
- end
-
- it "updates the deps on change in gemfile" do
- update_git "ma-gitp-gem", "1.1", :path => lib_path("ma-gitp-gem-1.0"), :gemspec => true
- gemfile <<-G
- source "#{file_uri_for(gem_repo2)}" # plugin source
- source "#{file_uri_for(lib_path("ma-gitp-gem-1.0"))}", :type => :gitp do
- gem "ma-gitp-gem", "1.1"
- end
- G
- bundle "install"
-
- expect(the_bundle).to include_gems("ma-gitp-gem 1.1")
- end
- end
-
- describe "bundle cache with gitp" do
- it "copies repository to vendor cache and uses it" do
- git = build_git "foo"
- ref = git.ref_for("master", 11)
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}" # plugin source
- source '#{lib_path("foo-1.0")}', :type => :gitp do
- gem "foo"
- end
- G
-
- bundle "config set cache_all true"
- bundle :cache
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
- expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
-
- FileUtils.rm_rf lib_path("foo-1.0")
- expect(the_bundle).to include_gems "foo 1.0"
- end
- end
- end
-end
diff --git a/spec/bundler/plugins/source_spec.rb b/spec/bundler/plugins/source_spec.rb
deleted file mode 100644
index c8deee96b1..0000000000
--- a/spec/bundler/plugins/source_spec.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundler source plugin" do
- describe "plugins dsl eval for #source with :type option" do
- before do
- update_repo2 do
- build_plugin "bundler-source-psource" do |s|
- s.write "plugins.rb", <<-RUBY
- class OPSource < Bundler::Plugin::API
- source "psource"
- end
- RUBY
- end
- end
- end
-
- it "installs bundler-source-* gem when no handler for source is present" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- source "#{file_uri_for(lib_path("gitp"))}", :type => :psource do
- end
- G
-
- plugin_should_be_installed("bundler-source-psource")
- end
-
- it "enables the plugin to require a lib path" do
- update_repo2 do
- build_plugin "bundler-source-psource" do |s|
- s.write "plugins.rb", <<-RUBY
- require "bundler-source-psource"
- class PSource < Bundler::Plugin::API
- source "psource"
- end
- RUBY
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- source "#{file_uri_for(lib_path("gitp"))}", :type => :psource do
- end
- G
-
- expect(out).to include("Bundle complete!")
- end
-
- context "with an explicit handler" do
- before do
- update_repo2 do
- build_plugin "another-psource" do |s|
- s.write "plugins.rb", <<-RUBY
- class Cheater < Bundler::Plugin::API
- source "psource"
- end
- RUBY
- end
- end
- end
-
- context "explicit presence in gemfile" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- plugin "another-psource"
-
- source "#{file_uri_for(lib_path("gitp"))}", :type => :psource do
- end
- G
- end
-
- it "completes successfully" do
- expect(out).to include("Bundle complete!")
- end
-
- it "installs the explicit one" do
- plugin_should_be_installed("another-psource")
- end
-
- it "doesn't install the default one" do
- plugin_should_not_be_installed("bundler-source-psource")
- end
- end
-
- context "explicit default source" do
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
-
- plugin "bundler-source-psource"
-
- source "#{file_uri_for(lib_path("gitp"))}", :type => :psource do
- end
- G
- end
-
- it "completes successfully" do
- expect(out).to include("Bundle complete!")
- end
-
- it "installs the default one" do
- plugin_should_be_installed("bundler-source-psource")
- end
- end
- end
- end
-end
diff --git a/spec/bundler/quality_es_spec.rb b/spec/bundler/quality_es_spec.rb
deleted file mode 100644
index 4238ac7452..0000000000
--- a/spec/bundler/quality_es_spec.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "La biblioteca si misma" do
- def check_for_expendable_words(filename)
- failing_line_message = []
- useless_words = %w[
- básicamente
- claramente
- sólo
- solamente
- obvio
- obviamente
- fácil
- fácilmente
- sencillamente
- simplemente
- ]
- pattern = /\b#{Regexp.union(useless_words)}\b/i
-
- File.readlines(filename).each_with_index do |line, number|
- next unless word_found = pattern.match(line)
- failing_line_message << "#{filename}:#{number.succ} contiene '#{word_found}'. Esta palabra tiene un significado subjetivo y es mejor obviarla en textos técnicos."
- end
-
- failing_line_message unless failing_line_message.empty?
- end
-
- def check_for_specific_pronouns(filename)
- failing_line_message = []
- specific_pronouns = /\b(él|ella|ellos|ellas)\b/i
-
- File.readlines(filename).each_with_index do |line, number|
- next unless word_found = specific_pronouns.match(line)
- failing_line_message << "#{filename}:#{number.succ} contiene '#{word_found}'. Use pronombres más genéricos en la documentación."
- end
-
- failing_line_message unless failing_line_message.empty?
- end
-
- it "mantiene la calidad de lenguaje de la documentación" do
- included = /ronn/
- error_messages = []
- Dir.chdir(root) do
- `git ls-files -z -- man`.split("\x0").each do |filename|
- next unless filename =~ included
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-
- it "mantiene la calidad de lenguaje de oraciones usadas en el código fuente" do
- error_messages = []
- exempt = /vendor/
- Dir.chdir(root) do
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-end
diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb
deleted file mode 100644
index 09e59d88ae..0000000000
--- a/spec/bundler/quality_spec.rb
+++ /dev/null
@@ -1,289 +0,0 @@
-# frozen_string_literal: true
-
-require "set"
-
-RSpec.describe "The library itself" do
- def check_for_debugging_mechanisms(filename)
- debugging_mechanisms_regex = /
- (binding\.pry)|
- (debugger)|
- (sleep\s*\(?\d+)|
- (fit\s*\(?("|\w))
- /x
-
- failing_lines = []
- each_line(filename) do |line, number|
- if line =~ debugging_mechanisms_regex && !line.end_with?("# ignore quality_spec\n")
- failing_lines << number + 1
- end
- end
-
- return if failing_lines.empty?
- "#{filename} has debugging mechanisms (like binding.pry, sleep, debugger, rspec focusing, etc.) on lines #{failing_lines.join(", ")}"
- end
-
- def check_for_git_merge_conflicts(filename)
- merge_conflicts_regex = /
- <<<<<<<|
- =======|
- >>>>>>>
- /x
-
- failing_lines = []
- each_line(filename) do |line, number|
- failing_lines << number + 1 if line =~ merge_conflicts_regex
- end
-
- return if failing_lines.empty?
- "#{filename} has unresolved git merge conflicts on lines #{failing_lines.join(", ")}"
- end
-
- def check_for_tab_characters(filename)
- failing_lines = []
- each_line(filename) do |line, number|
- failing_lines << number + 1 if line =~ /\t/
- end
-
- return if failing_lines.empty?
- "#{filename} has tab characters on lines #{failing_lines.join(", ")}"
- end
-
- def check_for_extra_spaces(filename)
- failing_lines = []
- each_line(filename) do |line, number|
- next if line =~ /^\s+#.*\s+\n$/
- failing_lines << number + 1 if line =~ /\s+\n$/
- end
-
- return if failing_lines.empty?
- "#{filename} has spaces on the EOL on lines #{failing_lines.join(", ")}"
- end
-
- def check_for_straneous_quotes(filename)
- return if File.expand_path(filename) == __FILE__
-
- failing_lines = []
- each_line(filename) do |line, number|
- failing_lines << number + 1 if line =~ /’/
- end
-
- return if failing_lines.empty?
- "#{filename} has an straneous quote on lines #{failing_lines.join(", ")}"
- end
-
- def check_for_expendable_words(filename)
- failing_line_message = []
- useless_words = %w[
- actually
- basically
- clearly
- just
- obviously
- really
- simply
- ]
- pattern = /\b#{Regexp.union(useless_words)}\b/i
-
- each_line(filename) do |line, number|
- next unless word_found = pattern.match(line)
- failing_line_message << "#{filename}:#{number.succ} has '#{word_found}'. Avoid using these kinds of weak modifiers."
- end
-
- failing_line_message unless failing_line_message.empty?
- end
-
- def check_for_specific_pronouns(filename)
- failing_line_message = []
- specific_pronouns = /\b(he|she|his|hers|him|her|himself|herself)\b/i
-
- each_line(filename) do |line, number|
- next unless word_found = specific_pronouns.match(line)
- failing_line_message << "#{filename}:#{number.succ} has '#{word_found}'. Use more generic pronouns in documentation."
- end
-
- failing_line_message unless failing_line_message.empty?
- end
-
- it "has no malformed whitespace" do
- exempt = /\.gitmodules|fixtures|vendor|LICENSE|vcr_cassettes|rbreadline\.diff|\.txt$/
- error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_tab_characters(filename)
- error_messages << check_for_extra_spaces(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-
- it "has no estraneous quotes" do
- exempt = /vendor|vcr_cassettes|LICENSE|rbreadline\.diff/
- error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_straneous_quotes(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-
- it "does not include any leftover debugging or development mechanisms" do
- exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn|\.txt|\.5|\.1}
- error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_debugging_mechanisms(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-
- it "does not include any unresolved merge conflicts" do
- error_messages = []
- exempt = %r{lock/lockfile_spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb}
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_git_merge_conflicts(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-
- it "maintains language quality of the documentation" do
- included = /ronn/
- error_messages = []
- Dir.chdir(root) do
- `git ls-files -z -- man`.split("\x0").each do |filename|
- next unless filename =~ included
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-
- it "maintains language quality of sentences used in source code" do
- error_messages = []
- exempt = /vendor|vcr_cassettes/
- Dir.chdir(root) do
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
- end
- expect(error_messages.compact).to be_well_formed
- end
-
- it "documents all used settings" do
- exemptions = %w[
- auto_config_jobs
- deployment_means_frozen
- forget_cli_options
- gem.coc
- gem.mit
- inline
- use_gem_version_promoter_for_major_updates
- ]
-
- all_settings = Hash.new {|h, k| h[k] = [] }
- documented_settings = []
-
- Bundler::Settings::BOOL_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::BOOL_KEYS" }
- Bundler::Settings::NUMBER_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::NUMBER_KEYS" }
- Bundler::Settings::ARRAY_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::ARRAY_KEYS" }
-
- Dir.chdir(root) do
- key_pattern = /([a-z\._-]+)/i
- lib_tracked_files.split("\x0").each do |filename|
- each_line(filename) do |line, number|
- line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
- end
- end
- documented_settings = File.read("man/bundle-config.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten
- end
-
- documented_settings.each do |s|
- all_settings.delete(s)
- expect(exemptions.delete(s)).to be_nil, "setting #{s} was exempted but was actually documented"
- end
-
- exemptions.each do |s|
- expect(all_settings.delete(s)).to be_truthy, "setting #{s} was exempted but unused"
- end
- error_messages = all_settings.map do |setting, refs|
- "The `#{setting}` setting is undocumented\n\t- #{refs.join("\n\t- ")}\n"
- end
-
- expect(error_messages.sort).to be_well_formed
-
- expect(documented_settings).to be_sorted
- end
-
- it "can still be built" do
- with_built_bundler do |_gem_path|
- expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
- end
- end
-
- it "ships the correct set of files" do
- Dir.chdir(root) do
- git_list = shipped_files.split("\x0")
-
- gem_list = Gem::Specification.load(gemspec.to_s).files
-
- expect(git_list.to_set).to eq(gem_list.to_set)
- end
- end
-
- it "does not contain any warnings" do
- Dir.chdir(root) do
- exclusions = %w[
- lib/bundler/capistrano.rb
- lib/bundler/deployment.rb
- lib/bundler/gem_tasks.rb
- lib/bundler/vlad.rb
- lib/bundler/templates/gems.rb
- ]
- files_to_require = lib_tracked_files.split("\x0").grep(/\.rb$/) - exclusions
- files_to_require.reject! {|f| f.start_with?("lib/bundler/vendor") }
- files_to_require.map! {|f| f.chomp(".rb") }
- sys_exec!("ruby -w -Ilib") do |input, _, _|
- files_to_require.each do |f|
- input.puts "require '#{f.sub(%r{\Alib/}, "")}'"
- end
- end
-
- warnings = last_command.stdboth.split("\n")
- # ignore warnings around deprecated Object#=~ method in RubyGems
- warnings.reject! {|w| w =~ %r{rubygems\/version.rb.*deprecated\ Object#=~} }
-
- expect(warnings).to be_well_formed
- end
- end
-
- it "does not use require internally, but require_relative" do
- Dir.chdir(root) do
- exempt = %r{templates/|vendor/}
- all_bad_requires = []
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- each_line(filename) do |line, number|
- line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
- end
- end
-
- expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}"
- end
- end
-
-private
-
- def each_line(filename, &block)
- File.readlines(filename, :encoding => "UTF-8").each_with_index(&block)
- end
-end
diff --git a/spec/bundler/realworld/dependency_api_spec.rb b/spec/bundler/realworld/dependency_api_spec.rb
deleted file mode 100644
index dea8329a4d..0000000000
--- a/spec/bundler/realworld/dependency_api_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../support/silent_logger"
-
-RSpec.describe "gemcutter's dependency API", :realworld => true do
- context "when Gemcutter API takes too long to respond" do
- before do
- require_rack
-
- port = find_unused_port
- @server_uri = "http://127.0.0.1:#{port}"
-
- require_relative "../support/artifice/endpoint_timeout"
-
- @t = Thread.new do
- server = Rack::Server.start(:app => EndpointTimeout,
- :Host => "0.0.0.0",
- :Port => port,
- :server => "webrick",
- :AccessLog => [],
- :Logger => Spec::SilentLogger.new)
- server.start
- end
- @t.run
-
- wait_for_server("127.0.0.1", port)
- bundle! "config set timeout 1"
- end
-
- after do
- Artifice.deactivate
- @t.kill
- @t.join
- end
-
- it "times out and falls back on the modern index" do
- install_gemfile! <<-G, :artifice => nil
- source "#{@server_uri}"
- gem "rack"
- G
-
- expect(out).to include("Fetching source index from #{@server_uri}/")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-end
diff --git a/spec/bundler/realworld/double_check_spec.rb b/spec/bundler/realworld/double_check_spec.rb
deleted file mode 100644
index 90cf298b33..0000000000
--- a/spec/bundler/realworld/double_check_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "double checking sources", :realworld => true, :sometimes => true do
- it "finds already-installed gems" do
- create_file("rails.gemspec", <<-RUBY)
- Gem::Specification.new do |s|
- s.name = "rails"
- s.version = "5.1.4"
- s.summary = ""
- s.description = ""
- s.author = ""
- s.add_dependency "actionpack", "5.1.4"
- end
- RUBY
-
- create_file("actionpack.gemspec", <<-RUBY)
- Gem::Specification.new do |s|
- s.name = "actionpack"
- s.version = "5.1.4"
- s.summary = ""
- s.description = ""
- s.author = ""
- s.add_dependency "rack", "~> 2.0.0"
- end
- RUBY
-
- cmd = <<-RUBY
- require "#{lib_dir}/bundler"
- require "#{spec_dir}/support/artifice/vcr"
- require "#{lib_dir}/bundler/inline"
- gemfile(true) do
- source "https://rubygems.org"
- gem "rails", path: "."
- end
- RUBY
-
- ruby! cmd
- ruby! cmd
- end
-end
diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb
deleted file mode 100644
index a91e6a359e..0000000000
--- a/spec/bundler/realworld/edgecases_spec.rb
+++ /dev/null
@@ -1,347 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
- def rubygems_version(name, requirement)
- ruby! <<-RUBY
- require "#{spec_dir}/support/artifice/vcr"
- require "#{lib_dir}/bundler"
- require "#{lib_dir}/bundler/source/rubygems/remote"
- require "#{lib_dir}/bundler/fetcher"
- rubygem = Bundler.ui.silence do
- source = Bundler::Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org"))
- fetcher = Bundler::Fetcher.new(source)
- index = fetcher.specs([#{name.dump}], nil)
- index.search(Gem::Dependency.new(#{name.dump}, #{requirement.dump})).last
- end
- if rubygem.nil?
- raise "Could not find #{name} (#{requirement}) on rubygems.org!\n" \
- "Found specs:\n\#{index.send(:specs).inspect}"
- end
- puts "#{name} (\#{rubygem.version})"
- RUBY
- end
-
- it "resolves dependencies correctly" do
- gemfile <<-G
- source "https://rubygems.org"
-
- gem 'rails', '~> 5.0'
- gem 'capybara', '~> 2.2.0'
- gem 'rack-cache', '1.2.0' # last version that works on Ruby 1.9
- G
- bundle! :lock
- expect(lockfile).to include(rubygems_version("rails", "~> 5.0"))
- expect(lockfile).to include("capybara (2.2.1)")
- end
-
- it "installs the latest version of gxapi_rails" do
- gemfile <<-G
- source "https://rubygems.org"
-
- gem "sass-rails"
- gem "rails", "~> 5"
- gem "gxapi_rails", "< 0.1.0" # 0.1.0 was released way after the test was written
- gem 'rack-cache', '1.2.0' # last version that works on Ruby 1.9
- G
- bundle! :lock
- expect(lockfile).to include("gxapi_rails (0.0.6)")
- end
-
- it "installs the latest version of i18n" do
- gemfile <<-G
- source "https://rubygems.org"
-
- gem "i18n", "~> 0.6.0"
- gem "activesupport", "~> 3.0"
- gem "activerecord", "~> 3.0"
- gem "builder", "~> 2.1.2"
- G
- bundle! :lock
- expect(lockfile).to include(rubygems_version("i18n", "~> 0.6.0"))
- expect(lockfile).to include(rubygems_version("activesupport", "~> 3.0"))
- end
-
- it "is able to update a top-level dependency when there is a conflict on a shared transitive child" do
- # from https://github.com/bundler/bundler/issues/5031
-
- gemfile <<-G
- source "https://rubygems.org"
- gem 'rails', '~> 4.2.7.1'
- gem 'paperclip', '~> 5.1.0'
- G
-
- lockfile <<-L
- GEM
- remote: https://rubygems.org/
- specs:
- actionmailer (4.2.7.1)
- actionpack (= 4.2.7.1)
- actionview (= 4.2.7.1)
- activejob (= 4.2.7.1)
- mail (~> 2.5, >= 2.5.4)
- rails-dom-testing (~> 1.0, >= 1.0.5)
- actionpack (4.2.7.1)
- actionview (= 4.2.7.1)
- activesupport (= 4.2.7.1)
- rack (~> 1.6)
- rack-test (~> 0.6.2)
- rails-dom-testing (~> 1.0, >= 1.0.5)
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
- actionview (4.2.7.1)
- activesupport (= 4.2.7.1)
- builder (~> 3.1)
- erubis (~> 2.7.0)
- rails-dom-testing (~> 1.0, >= 1.0.5)
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
- activejob (4.2.7.1)
- activesupport (= 4.2.7.1)
- globalid (>= 0.3.0)
- activemodel (4.2.7.1)
- activesupport (= 4.2.7.1)
- builder (~> 3.1)
- activerecord (4.2.7.1)
- activemodel (= 4.2.7.1)
- activesupport (= 4.2.7.1)
- arel (~> 6.0)
- activesupport (4.2.7.1)
- i18n (~> 0.7)
- json (~> 1.7, >= 1.7.7)
- minitest (~> 5.1)
- thread_safe (~> 0.3, >= 0.3.4)
- tzinfo (~> 1.1)
- arel (6.0.3)
- builder (3.2.2)
- climate_control (0.0.3)
- activesupport (>= 3.0)
- cocaine (0.5.8)
- climate_control (>= 0.0.3, < 1.0)
- concurrent-ruby (1.0.2)
- erubis (2.7.0)
- globalid (0.3.7)
- activesupport (>= 4.1.0)
- i18n (0.7.0)
- json (1.8.3)
- loofah (2.0.3)
- nokogiri (>= 1.5.9)
- mail (2.6.4)
- mime-types (>= 1.16, < 4)
- mime-types (3.1)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2016.0521)
- mimemagic (0.3.2)
- mini_portile2 (2.1.0)
- minitest (5.9.1)
- nokogiri (1.6.8)
- mini_portile2 (~> 2.1.0)
- pkg-config (~> 1.1.7)
- paperclip (5.1.0)
- activemodel (>= 4.2.0)
- activesupport (>= 4.2.0)
- cocaine (~> 0.5.5)
- mime-types
- mimemagic (~> 0.3.0)
- pkg-config (1.1.7)
- rack (1.6.4)
- rack-test (0.6.3)
- rack (>= 1.0)
- rails (4.2.7.1)
- actionmailer (= 4.2.7.1)
- actionpack (= 4.2.7.1)
- actionview (= 4.2.7.1)
- activejob (= 4.2.7.1)
- activemodel (= 4.2.7.1)
- activerecord (= 4.2.7.1)
- activesupport (= 4.2.7.1)
- bundler (>= 1.3.0, < 3.0)
- railties (= 4.2.7.1)
- sprockets-rails
- rails-deprecated_sanitizer (1.0.3)
- activesupport (>= 4.2.0.alpha)
- rails-dom-testing (1.0.7)
- activesupport (>= 4.2.0.beta, < 5.0)
- nokogiri (~> 1.6.0)
- rails-deprecated_sanitizer (>= 1.0.1)
- rails-html-sanitizer (1.0.3)
- loofah (~> 2.0)
- railties (4.2.7.1)
- actionpack (= 4.2.7.1)
- activesupport (= 4.2.7.1)
- rake (>= 0.8.7)
- thor (>= 0.18.1, < 2.0)
- rake (11.3.0)
- sprockets (3.7.0)
- concurrent-ruby (~> 1.0)
- rack (> 1, < 3)
- sprockets-rails (3.2.0)
- actionpack (>= 4.0)
- activesupport (>= 4.0)
- sprockets (>= 3.0.0)
- thor (0.19.1)
- thread_safe (0.3.5)
- tzinfo (1.2.2)
- thread_safe (~> 0.1)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- paperclip (~> 5.1.0)
- rails (~> 4.2.7.1)
- L
-
- bundle! "lock --update paperclip"
-
- expect(lockfile).to include(rubygems_version("paperclip", "~> 5.1.0"))
- end
-
- # https://github.com/bundler/bundler/issues/1500
- it "does not fail install because of gem plugins" do
- realworld_system_gems("open_gem --version 1.4.2", "rake --version 0.9.2")
- gemfile <<-G
- source "https://rubygems.org"
-
- gem 'rack', '1.0.1'
- G
-
- bundle "config set --local path vendor/bundle"
- bundle! :install
- expect(err).not_to include("Could not find rake")
- expect(err).to be_empty
- end
-
- it "checks out git repos when the lockfile is corrupted" do
- gemfile <<-G
- source "https://rubygems.org"
- git_source(:github) {|repo| "https://github.com/\#{repo}.git" }
-
- gem 'activerecord', :github => 'carlhuda/rails-bundler-test', :branch => 'master'
- gem 'activesupport', :github => 'carlhuda/rails-bundler-test', :branch => 'master'
- gem 'actionpack', :github => 'carlhuda/rails-bundler-test', :branch => 'master'
- G
-
- lockfile <<-L
- GIT
- remote: https://github.com/carlhuda/rails-bundler-test.git
- revision: 369e28a87419565f1940815219ea9200474589d4
- branch: master
- specs:
- actionpack (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.1)
- rack (~> 1.4.0)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.1.2)
- activemodel (3.2.2)
- activesupport (= 3.2.2)
- builder (~> 3.0.0)
- activerecord (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activesupport (3.2.2)
- i18n (~> 0.6)
- multi_json (~> 1.0)
-
- GIT
- remote: https://github.com/carlhuda/rails-bundler-test.git
- revision: 369e28a87419565f1940815219ea9200474589d4
- branch: master
- specs:
- actionpack (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.1)
- rack (~> 1.4.0)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.1.2)
- activemodel (3.2.2)
- activesupport (= 3.2.2)
- builder (~> 3.0.0)
- activerecord (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activesupport (3.2.2)
- i18n (~> 0.6)
- multi_json (~> 1.0)
-
- GIT
- remote: https://github.com/carlhuda/rails-bundler-test.git
- revision: 369e28a87419565f1940815219ea9200474589d4
- branch: master
- specs:
- actionpack (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.1)
- rack (~> 1.4.0)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.1.2)
- activemodel (3.2.2)
- activesupport (= 3.2.2)
- builder (~> 3.0.0)
- activerecord (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activesupport (3.2.2)
- i18n (~> 0.6)
- multi_json (~> 1.0)
-
- GEM
- remote: https://rubygems.org/
- specs:
- arel (3.0.2)
- builder (3.0.0)
- erubis (2.7.0)
- hike (1.2.1)
- i18n (0.6.0)
- journey (1.0.3)
- multi_json (1.1.0)
- rack (1.4.1)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-test (0.6.1)
- rack (>= 1.0)
- sprockets (2.1.2)
- hike (~> 1.2)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- tilt (1.3.3)
- tzinfo (0.3.32)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- actionpack!
- activerecord!
- activesupport!
- L
-
- bundle! :lock
- expect(err).to be_empty
- end
-
- it "outputs a helpful error message when gems have invalid gemspecs" do
- install_gemfile <<-G, :standalone => true
- source 'https://rubygems.org'
- gem "resque-scheduler", "2.2.0"
- G
- expect(err).to include("You have one or more invalid gemspecs that need to be fixed.")
- expect(err).to include("resque-scheduler 2.2.0 has an invalid gemspec")
- end
-end
diff --git a/spec/bundler/realworld/gemfile_source_header_spec.rb b/spec/bundler/realworld/gemfile_source_header_spec.rb
deleted file mode 100644
index 3f507b056a..0000000000
--- a/spec/bundler/realworld/gemfile_source_header_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../support/silent_logger"
-
-RSpec.describe "fetching dependencies with a mirrored source", :realworld => true do
- let(:mirror) { "https://server.example.org" }
- let(:original) { "http://127.0.0.1:#{@port}" }
-
- before do
- setup_server
- bundle "config set --local mirror.#{mirror} #{original}"
- end
-
- after do
- Artifice.deactivate
- @t.kill
- @t.join
- end
-
- it "sets the 'X-Gemfile-Source' header and bundles successfully" do
- gemfile <<-G
- source "#{mirror}"
- gem 'weakling'
- G
-
- bundle :install, :artifice => nil
-
- expect(out).to include("Installing weakling")
- expect(out).to include("Bundle complete")
- expect(the_bundle).to include_gems "weakling 0.0.3"
- end
-
-private
-
- def setup_server
- require_rack
- @port = find_unused_port
- @server_uri = "http://127.0.0.1:#{@port}"
-
- require_relative "../support/artifice/endpoint_mirror_source"
-
- @t = Thread.new do
- Rack::Server.start(:app => EndpointMirrorSource,
- :Host => "0.0.0.0",
- :Port => @port,
- :server => "webrick",
- :AccessLog => [],
- :Logger => Spec::SilentLogger.new)
- end.run
-
- wait_for_server("127.0.0.1", @port)
- end
-end
diff --git a/spec/bundler/realworld/mirror_probe_spec.rb b/spec/bundler/realworld/mirror_probe_spec.rb
deleted file mode 100644
index 735fb2b3dd..0000000000
--- a/spec/bundler/realworld/mirror_probe_spec.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../support/silent_logger"
-
-RSpec.describe "fetching dependencies with a not available mirror", :realworld => true do
- let(:mirror) { @mirror_uri }
- let(:original) { @server_uri }
- let(:server_port) { @server_port }
- let(:host) { "127.0.0.1" }
-
- before do
- require_rack
- setup_server
- setup_mirror
- end
-
- after do
- Artifice.deactivate
- @server_thread.kill
- @server_thread.join
- end
-
- context "with a specific fallback timeout" do
- before do
- global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/__FALLBACK_TIMEOUT/" => "true",
- "BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror)
- end
-
- it "install a gem using the original uri when the mirror is not responding" do
- gemfile <<-G
- source "#{original}"
- gem 'weakling'
- G
-
- bundle :install, :artifice => nil
-
- expect(out).to include("Installing weakling")
- expect(out).to include("Bundle complete")
- expect(the_bundle).to include_gems "weakling 0.0.3"
- end
- end
-
- context "with a global fallback timeout" do
- before do
- global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1",
- "BUNDLE_MIRROR__ALL" => mirror)
- end
-
- it "install a gem using the original uri when the mirror is not responding" do
- gemfile <<-G
- source "#{original}"
- gem 'weakling'
- G
-
- bundle :install, :artifice => nil
-
- expect(out).to include("Installing weakling")
- expect(out).to include("Bundle complete")
- expect(the_bundle).to include_gems "weakling 0.0.3"
- end
- end
-
- context "with a specific mirror without a fallback timeout" do
- before do
- global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror)
- end
-
- it "fails to install the gem with a timeout error" do
- gemfile <<-G
- source "#{original}"
- gem 'weakling'
- G
-
- bundle :install, :artifice => nil
-
- expect(out).to include("Fetching source index from #{mirror}")
- expect(err).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(err).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(err).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(err).to include("Could not fetch specs from #{mirror}")
- end
-
- it "prints each error and warning on a new line" do
- gemfile <<-G
- source "#{original}"
- gem 'weakling'
- G
-
- bundle :install, :artifice => nil
-
- expect(out).to include "Fetching source index from #{mirror}/"
- expect(err).to include <<-EOS.strip
-Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
-Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
-Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
-Could not fetch specs from #{mirror}/
- EOS
- end
- end
-
- context "with a global mirror without a fallback timeout" do
- before do
- global_config("BUNDLE_MIRROR__ALL" => mirror)
- end
-
- it "fails to install the gem with a timeout error" do
- gemfile <<-G
- source "#{original}"
- gem 'weakling'
- G
-
- bundle :install, :artifice => nil
-
- expect(out).to include("Fetching source index from #{mirror}")
- expect(err).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(err).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(err).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(err).to include("Could not fetch specs from #{mirror}")
- end
- end
-
- def setup_server
- @server_port = find_unused_port
- @server_uri = "http://#{host}:#{@server_port}"
-
- require_relative "../support/artifice/endpoint"
-
- @server_thread = Thread.new do
- Rack::Server.start(:app => Endpoint,
- :Host => host,
- :Port => @server_port,
- :server => "webrick",
- :AccessLog => [],
- :Logger => Spec::SilentLogger.new)
- end.run
-
- wait_for_server(host, @server_port)
- end
-
- def setup_mirror
- mirror_port = find_unused_port
- @mirror_uri = "http://#{host}:#{mirror_port}"
- end
-end
diff --git a/spec/bundler/realworld/parallel_spec.rb b/spec/bundler/realworld/parallel_spec.rb
deleted file mode 100644
index 7738b46aac..0000000000
--- a/spec/bundler/realworld/parallel_spec.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "parallel", :realworld => true, :sometimes => true do
- it "installs" do
- gemfile <<-G
- source "https://rubygems.org"
- gem 'activesupport', '~> 3.2.13'
- gem 'faker', '~> 1.1.2'
- gem 'i18n', '~> 0.6.0' # Because 0.7+ requires Ruby 1.9.3+
- G
-
- bundle :install, :jobs => 4, :env => { "DEBUG" => "1" }
-
- expect(out).to match(/[1-3]: /)
-
- bundle "info activesupport --path"
- expect(out).to match(/activesupport/)
-
- bundle "info faker --path"
- expect(out).to match(/faker/)
- end
-
- it "updates" do
- install_gemfile <<-G
- source "https://rubygems.org"
- gem 'activesupport', '3.2.12'
- gem 'faker', '~> 1.1.2'
- G
-
- gemfile <<-G
- source "https://rubygems.org"
- gem 'activesupport', '~> 3.2.12'
- gem 'faker', '~> 1.1.2'
- gem 'i18n', '~> 0.6.0' # Because 0.7+ requires Ruby 1.9.3+
- G
-
- bundle :update, :jobs => 4, :env => { "DEBUG" => "1" }, :all => true
-
- expect(out).to match(/[1-3]: /)
-
- bundle "info activesupport --path"
- expect(out).to match(/activesupport-3\.2\.\d+/)
-
- bundle "info faker --path"
- expect(out).to match(/faker/)
- end
-
- it "works with --standalone" do
- gemfile <<-G, :standalone => true
- source "https://rubygems.org"
- gem "diff-lcs"
- G
-
- bundle :install, :standalone => true, :jobs => 4
-
- ruby <<-RUBY, :no_lib => true
- $:.unshift File.expand_path("bundle")
- require "bundler/setup"
-
- require "diff/lcs"
- puts Diff::LCS
- RUBY
-
- expect(out).to eq("Diff::LCS")
- end
-end
diff --git a/spec/bundler/resolver/basic_spec.rb b/spec/bundler/resolver/basic_spec.rb
deleted file mode 100644
index 57897f89b4..0000000000
--- a/spec/bundler/resolver/basic_spec.rb
+++ /dev/null
@@ -1,308 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Resolving" do
- before :each do
- @index = an_awesome_index
- end
-
- it "resolves a single gem" do
- dep "rack"
-
- should_resolve_as %w[rack-1.1]
- end
-
- it "resolves a gem with dependencies" do
- dep "actionpack"
-
- should_resolve_as %w[actionpack-2.3.5 activesupport-2.3.5 rack-1.0]
- end
-
- it "resolves a conflicting index" do
- @index = a_conflict_index
- dep "my_app"
- should_resolve_as %w[activemodel-3.2.11 builder-3.0.4 grape-0.2.6 my_app-1.0.0]
- end
-
- it "resolves a complex conflicting index" do
- @index = a_complex_conflict_index
- dep "my_app"
- should_resolve_as %w[a-1.4.0 b-0.3.5 c-3.2 d-0.9.8 my_app-1.1.0]
- end
-
- it "resolves a index with conflict on child" do
- @index = index_with_conflict_on_child
- dep "chef_app"
- should_resolve_as %w[berkshelf-2.0.7 chef-10.26 chef_app-1.0.0 json-1.7.7]
- end
-
- it "prefers explicitly requested dependencies when resolving an index which would otherwise be ambiguous" do
- @index = an_ambiguous_index
- dep "a"
- dep "b"
- should_resolve_as %w[a-1.0.0 b-2.0.0 c-1.0.0 d-1.0.0]
- end
-
- it "prefers non-prerelease resolutions in sort order" do
- @index = optional_prereleases_index
- dep "a"
- dep "b"
- should_resolve_as %w[a-1.0.0 b-1.5.0]
- end
-
- it "resolves a index with root level conflict on child" do
- @index = a_index_with_root_conflict_on_child
- dep "i18n", "~> 0.4"
- dep "activesupport", "~> 3.0"
- dep "activerecord", "~> 3.0"
- dep "builder", "~> 2.1.2"
- should_resolve_as %w[activesupport-3.0.5 i18n-0.4.2 builder-2.1.2 activerecord-3.0.5 activemodel-3.0.5]
- end
-
- it "resolves a gem specified with a pre-release version" do
- dep "activesupport", "~> 3.0.0.beta"
- dep "activemerchant"
- should_resolve_as %w[activemerchant-2.3.5 activesupport-3.0.0.beta1]
- end
-
- it "doesn't select a pre-release if not specified in the Gemfile" do
- dep "activesupport"
- dep "reform"
- should_resolve_as %w[reform-1.0.0 activesupport-2.3.5]
- end
-
- it "doesn't select a pre-release for sub-dependencies" do
- dep "reform"
- should_resolve_as %w[reform-1.0.0 activesupport-2.3.5]
- end
-
- it "selects a pre-release for sub-dependencies if it's the only option" do
- dep "need-pre"
- should_resolve_as %w[need-pre-1.0.0 activesupport-3.0.0.beta1]
- end
-
- it "selects a pre-release if it's specified in the Gemfile" do
- dep "activesupport", "= 3.0.0.beta"
- dep "actionpack"
-
- should_resolve_as %w[activesupport-3.0.0.beta actionpack-3.0.0.beta rack-1.1 rack-mount-0.6]
- end
-
- it "prefers non-pre-releases when doing conservative updates" do
- @index = build_index do
- gem "mail", "2.7.0"
- gem "mail", "2.7.1.rc1"
- gem "RubyGems\0", Gem::VERSION
- end
- dep "mail"
- @locked = locked ["mail", "2.7.0"]
- @base = locked
- should_conservative_resolve_and_include [:patch], [], ["mail-2.7.0"]
- end
-
- it "raises an exception if a child dependency is not resolved" do
- @index = a_unresovable_child_index
- dep "chef_app_error"
- expect do
- resolve
- end.to raise_error(Bundler::VersionConflict)
- end
-
- it "raises an exception with the minimal set of conflicting dependencies" do
- @index = build_index do
- %w[0.9 1.0 2.0].each {|v| gem("a", v) }
- gem("b", "1.0") { dep "a", ">= 2" }
- gem("c", "1.0") { dep "a", "< 1" }
- end
- dep "a"
- dep "b"
- dep "c"
- expect do
- resolve
- end.to raise_error(Bundler::VersionConflict, <<-E.strip)
-Bundler could not find compatible versions for gem "a":
- In Gemfile:
- b was resolved to 1.0, which depends on
- a (>= 2)
-
- c was resolved to 1.0, which depends on
- a (< 1)
- E
- end
-
- it "should throw error in case of circular dependencies" do
- @index = a_circular_index
- dep "circular_app"
-
- expect do
- resolve
- end.to raise_error(Bundler::CyclicDependencyError, /please remove either gem 'bar' or gem 'foo'/i)
- end
-
- # Issue #3459
- it "should install the latest possible version of a direct requirement with no constraints given" do
- @index = a_complicated_index
- dep "foo"
- should_resolve_and_include %w[foo-3.0.5]
- end
-
- # Issue #3459
- it "should install the latest possible version of a direct requirement with constraints given" do
- @index = a_complicated_index
- dep "foo", ">= 3.0.0"
- should_resolve_and_include %w[foo-3.0.5]
- end
-
- it "takes into account required_ruby_version" do
- @index = build_index do
- gem "foo", "1.0.0" do
- dep "bar", ">= 0"
- end
-
- gem "foo", "2.0.0" do |s|
- dep "bar", ">= 0"
- s.required_ruby_version = "~> 2.0.0"
- end
-
- gem "bar", "1.0.0"
-
- gem "bar", "2.0.0" do |s|
- s.required_ruby_version = "~> 2.0.0"
- end
-
- gem "Ruby\0", "1.8.7"
- end
- dep "foo"
- dep "Ruby\0", "1.8.7"
-
- deps = []
- @deps.each do |d|
- deps << Bundler::DepProxy.new(d, "ruby")
- end
-
- should_resolve_and_include %w[foo-1.0.0 bar-1.0.0], [[]]
- end
-
- context "conservative" do
- before :each do
- @index = build_index do
- gem("foo", "1.3.7") { dep "bar", "~> 2.0" }
- gem("foo", "1.3.8") { dep "bar", "~> 2.0" }
- gem("foo", "1.4.3") { dep "bar", "~> 2.0" }
- gem("foo", "1.4.4") { dep "bar", "~> 2.0" }
- gem("foo", "1.4.5") { dep "bar", "~> 2.1" }
- gem("foo", "1.5.0") { dep "bar", "~> 2.1" }
- gem("foo", "1.5.1") { dep "bar", "~> 3.0" }
- gem("foo", "2.0.0") { dep "bar", "~> 3.0" }
- gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
- end
- dep "foo"
-
- # base represents declared dependencies in the Gemfile that are still satisfied by the lockfile
- @base = Bundler::SpecSet.new([])
-
- # locked represents versions in lockfile
- @locked = locked(%w[foo 1.4.3], %w[bar 2.0.3])
- end
-
- it "resolves all gems to latest patch" do
- # strict is not set, so bar goes up a minor version due to dependency from foo 1.4.5
- should_conservative_resolve_and_include :patch, [], %w[foo-1.4.5 bar-2.1.1]
- end
-
- it "resolves all gems to latest patch strict" do
- # strict is set, so foo can only go up to 1.4.4 to avoid bar going up a minor version, and bar can go up to 2.0.5
- should_conservative_resolve_and_include [:patch, :strict], [], %w[foo-1.4.4 bar-2.0.5]
- end
-
- it "resolves foo only to latest patch - same dependency case" do
- @locked = locked(%w[foo 1.3.7], %w[bar 2.0.3])
- # bar is locked, and the lock holds here because the dependency on bar doesn't change on the matching foo version.
- should_conservative_resolve_and_include :patch, ["foo"], %w[foo-1.3.8 bar-2.0.3]
- end
-
- it "resolves foo only to latest patch - changing dependency not declared case" do
- # foo is the only gem being requested for update, therefore bar is locked, but bar is NOT
- # declared as a dependency in the Gemfile. In this case, locks don't apply to _changing_
- # dependencies and since the dependency of the selected foo gem changes, the latest matching
- # dependency of "bar", "~> 2.1" -- bar-2.1.1 -- is selected. This is not a bug and follows
- # the long-standing documented Conservative Updating behavior of bundle install.
- # https://bundler.io/v1.12/man/bundle-install.1.html#CONSERVATIVE-UPDATING
- should_conservative_resolve_and_include :patch, ["foo"], %w[foo-1.4.5 bar-2.1.1]
- end
-
- it "resolves foo only to latest patch - changing dependency declared case" do
- # bar is locked AND a declared dependency in the Gemfile, so it will not move, and therefore
- # foo can only move up to 1.4.4.
- @base << build_spec("bar", "2.0.3").first
- should_conservative_resolve_and_include :patch, ["foo"], %w[foo-1.4.4 bar-2.0.3]
- end
-
- it "resolves foo only to latest patch strict" do
- # adding strict helps solve the possibly unexpected behavior of bar changing in the prior test case,
- # because no versions will be returned for bar ~> 2.1, so the engine falls back to ~> 2.0 (turn on
- # debugging to see this happen).
- should_conservative_resolve_and_include [:patch, :strict], ["foo"], %w[foo-1.4.4 bar-2.0.3]
- end
-
- it "resolves bar only to latest patch" do
- # bar is locked, so foo can only go up to 1.4.4
- should_conservative_resolve_and_include :patch, ["bar"], %w[foo-1.4.3 bar-2.0.5]
- end
-
- it "resolves all gems to latest minor" do
- # strict is not set, so bar goes up a major version due to dependency from foo 1.4.5
- should_conservative_resolve_and_include :minor, [], %w[foo-1.5.1 bar-3.0.0]
- end
-
- it "resolves all gems to latest minor strict" do
- # strict is set, so foo can only go up to 1.5.0 to avoid bar going up a major version
- should_conservative_resolve_and_include [:minor, :strict], [], %w[foo-1.5.0 bar-2.1.1]
- end
-
- it "resolves all gems to latest major" do
- should_conservative_resolve_and_include :major, [], %w[foo-2.0.0 bar-3.0.0]
- end
-
- it "resolves all gems to latest major strict" do
- should_conservative_resolve_and_include [:major, :strict], [], %w[foo-2.0.0 bar-3.0.0]
- end
-
- # Why would this happen in real life? If bar 2.2 has a bug that the author of foo wants to bypass
- # by reverting the dependency, the author of foo could release a new gem with an older requirement.
- context "revert to previous" do
- before :each do
- @index = build_index do
- gem("foo", "1.4.3") { dep "bar", "~> 2.2" }
- gem("foo", "1.4.4") { dep "bar", "~> 2.1.0" }
- gem("foo", "1.5.0") { dep "bar", "~> 2.0.0" }
- gem "bar", %w[2.0.5 2.1.1 2.2.3]
- end
- dep "foo"
-
- # base represents declared dependencies in the Gemfile that are still satisfied by the lockfile
- @base = Bundler::SpecSet.new([])
-
- # locked represents versions in lockfile
- @locked = locked(%w[foo 1.4.3], %w[bar 2.2.3])
- end
-
- it "could revert to a previous version level patch" do
- should_conservative_resolve_and_include :patch, [], %w[foo-1.4.4 bar-2.1.1]
- end
-
- it "cannot revert to a previous version in strict mode level patch" do
- # fall back to the locked resolution since strict means we can't regress either version
- should_conservative_resolve_and_include [:patch, :strict], [], %w[foo-1.4.3 bar-2.2.3]
- end
-
- it "could revert to a previous version level minor" do
- should_conservative_resolve_and_include :minor, [], %w[foo-1.5.0 bar-2.0.5]
- end
-
- it "cannot revert to a previous version in strict mode level minor" do
- # fall back to the locked resolution since strict means we can't regress either version
- should_conservative_resolve_and_include [:minor, :strict], [], %w[foo-1.4.3 bar-2.2.3]
- end
- end
- end
-end
diff --git a/spec/bundler/resolver/platform_spec.rb b/spec/bundler/resolver/platform_spec.rb
deleted file mode 100644
index fee0cf1f1c..0000000000
--- a/spec/bundler/resolver/platform_spec.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Resolving platform craziness" do
- describe "with cross-platform gems" do
- before :each do
- @index = an_awesome_index
- end
-
- it "resolves a simple multi platform gem" do
- dep "nokogiri"
- platforms "ruby", "java"
-
- should_resolve_as %w[nokogiri-1.4.2 nokogiri-1.4.2-java weakling-0.0.3]
- end
-
- it "doesn't pull gems that don't exist for the current platform" do
- dep "nokogiri"
- platforms "ruby"
-
- should_resolve_as %w[nokogiri-1.4.2]
- end
-
- it "doesn't pull gems when the version is available for all requested platforms" do
- dep "nokogiri"
- platforms "mswin32"
-
- should_resolve_as %w[nokogiri-1.4.2.1-x86-mswin32]
- end
- end
-
- describe "with mingw32" do
- before :each do
- @index = build_index do
- platforms "mingw32 mswin32 x64-mingw32" do |platform|
- gem "thin", "1.2.7", platform
- end
- gem "win32-api", "1.5.1", "universal-mingw32"
- end
- end
-
- it "finds mswin gems" do
- # win32 is hardcoded to get CPU x86 in rubygems
- platforms "mswin32"
- dep "thin"
- should_resolve_as %w[thin-1.2.7-x86-mswin32]
- end
-
- it "finds mingw gems" do
- # mingw is _not_ hardcoded to add CPU x86 in rubygems
- platforms "x86-mingw32"
- dep "thin"
- should_resolve_as %w[thin-1.2.7-mingw32]
- end
-
- it "finds x64-mingw gems" do
- platforms "x64-mingw32"
- dep "thin"
- should_resolve_as %w[thin-1.2.7-x64-mingw32]
- end
-
- it "finds universal-mingw gems on x86-mingw" do
- platform "x86-mingw32"
- dep "win32-api"
- should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
- end
-
- it "finds universal-mingw gems on x64-mingw" do
- platform "x64-mingw32"
- dep "win32-api"
- should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
- end
- end
-
- describe "with conflicting cases" do
- before :each do
- @index = build_index do
- gem "foo", "1.0.0" do
- dep "bar", ">= 0"
- end
-
- gem "bar", "1.0.0" do
- dep "baz", "~> 1.0.0"
- end
-
- gem "bar", "1.0.0", "java" do
- dep "baz", " ~> 1.1.0"
- end
-
- gem "baz", %w[1.0.0 1.1.0 1.2.0]
- end
- end
-
- it "reports on the conflict" do
- platforms "ruby", "java"
- dep "foo"
-
- should_conflict_on "baz"
- end
- end
-end
diff --git a/spec/bundler/runtime/executable_spec.rb b/spec/bundler/runtime/executable_spec.rb
deleted file mode 100644
index 003be97cd6..0000000000
--- a/spec/bundler/runtime/executable_spec.rb
+++ /dev/null
@@ -1,173 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Running bin/* commands" do
- before :each do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "runs the bundled command when in the bundle" do
- bundle! "binstubs rack"
-
- build_gem "rack", "2.0", :to_system => true do |s|
- s.executables = "rackup"
- end
-
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
-
- it "allows the location of the gem stubs to be specified" do
- bundle! "binstubs rack", :path => "gbin"
-
- expect(bundled_app("bin")).not_to exist
- expect(bundled_app("gbin/rackup")).to exist
-
- gembin bundled_app("gbin/rackup")
- expect(out).to eq("1.0.0")
- end
-
- it "allows absolute paths as a specification of where to install bin stubs" do
- bundle! "binstubs rack", :path => tmp("bin")
-
- gembin tmp("bin/rackup")
- expect(out).to eq("1.0.0")
- end
-
- it "uses the default ruby install name when shebang is not specified" do
- bundle! "binstubs rack"
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n")
- end
-
- it "allows the name of the shebang executable to be specified" do
- bundle! "binstubs rack", :shebang => "ruby-foo"
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env ruby-foo\n")
- end
-
- it "runs the bundled command when out of the bundle" do
- bundle! "binstubs rack"
-
- build_gem "rack", "2.0", :to_system => true do |s|
- s.executables = "rackup"
- end
-
- Dir.chdir(tmp) do
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
- end
-
- it "works with gems in path" do
- build_lib "rack", :path => lib_path("rack") do |s|
- s.executables = "rackup"
- end
-
- gemfile <<-G
- gem "rack", :path => "#{lib_path("rack")}"
- G
-
- bundle! "binstubs rack"
-
- build_gem "rack", "2.0", :to_system => true do |s|
- s.executables = "rackup"
- end
-
- gembin "rackup"
- expect(out).to eq("1.0")
- end
-
- it "creates a bundle binstub" do
- build_gem "bundler", Bundler::VERSION, :to_system => true do |s|
- s.executables = "bundle"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "bundler"
- G
-
- bundle! "binstubs bundler"
-
- expect(bundled_app("bin/bundle")).to exist
- end
-
- it "does not generate bin stubs if the option was not specified" do
- bundle! "install"
-
- expect(bundled_app("bin/rackup")).not_to exist
- end
-
- it "allows you to stop installing binstubs", :bundler => "< 3" do
- bundle! "install --binstubs bin/"
- bundled_app("bin/rackup").rmtree
- bundle! "install --binstubs \"\""
-
- expect(bundled_app("bin/rackup")).not_to exist
-
- bundle! "config bin"
- expect(out).to include("You have not configured a value for `bin`")
- end
-
- it "remembers that the option was specified", :bundler => "< 3" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
- G
-
- bundle! :install, :binstubs => "bin"
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
- gem "rack"
- G
-
- bundle "install"
-
- expect(bundled_app("bin/rackup")).to exist
- end
-
- it "rewrites bins on binstubs (to maintain backwards compatibility)" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- create_file("bin/rackup", "OMG")
-
- bundle! "binstubs rack"
-
- expect(bundled_app("bin/rackup").read).to_not eq("OMG")
- end
-
- it "use BUNDLE_GEMFILE gemfile for binstub" do
- # context with bin/bundler w/ default Gemfile
- bundle! "binstubs bundler"
-
- # generate other Gemfile with executable gem
- build_repo2 do
- build_gem("bindir") {|s| s.executables = "foo" }
- end
-
- create_file("OtherGemfile", <<-G)
- source "#{file_uri_for(gem_repo2)}"
- gem 'bindir'
- G
-
- # generate binstub for executable from non default Gemfile (other then bin/bundler version)
- ENV["BUNDLE_GEMFILE"] = "OtherGemfile"
- bundle "install"
- bundle! "binstubs bindir"
-
- # remove user settings
- ENV["BUNDLE_GEMFILE"] = nil
-
- # run binstub for non default Gemfile
- gembin "foo"
-
- expect(exitstatus).to eq(0) if exitstatus
- expect(out).to eq("1.0")
- end
-end
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
deleted file mode 100644
index 74270a2316..0000000000
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "require 'bundler/gem_tasks'" do
- before :each do
- bundled_app("foo.gemspec").open("w") do |f|
- f.write <<-GEMSPEC
- Gem::Specification.new do |s|
- s.name = "foo"
- s.version = "1.0"
- s.summary = "dummy"
- s.author = "Perry Mason"
- end
- GEMSPEC
- end
-
- bundled_app("Rakefile").open("w") do |f|
- f.write <<-RAKEFILE
- $:.unshift("#{lib_dir}")
- require "bundler/gem_tasks"
- RAKEFILE
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "rake"
- G
- end
-
- it "includes the relevant tasks" do
- with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec "#{rake} -T", "RUBYOPT" => "-I#{lib_dir}"
- end
-
- expect(err).to be_empty
- expected_tasks = [
- "rake build",
- "rake clean",
- "rake clobber",
- "rake install",
- "rake release[remote]",
- ]
- tasks = out.lines.to_a.map {|s| s.split("#").first.strip }
- expect(tasks & expected_tasks).to eq(expected_tasks)
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- it "defines a working `rake install` task" do
- with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec "#{rake} install", "RUBYOPT" => "-I#{lib_dir}"
- end
-
- expect(err).to be_empty
-
- bundle! "exec rake install"
-
- expect(err).to be_empty
- end
-
- context "rake build when path has spaces" do
- before do
- spaced_bundled_app = tmp.join("bundled app")
- FileUtils.mv bundled_app, spaced_bundled_app
- Dir.chdir(spaced_bundled_app)
- end
-
- it "still runs successfully" do
- bundle! "exec rake build"
-
- expect(err).to be_empty
- end
- end
-
- it "adds 'pkg' to rake/clean's CLOBBER" do
- with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
- end
- expect(out).to eq '["pkg"]'
- end
-end
diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb
deleted file mode 100644
index cd762fe636..0000000000
--- a/spec/bundler/runtime/inline_spec.rb
+++ /dev/null
@@ -1,353 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundler/inline#gemfile" do
- def script(code, options = {})
- requires = ["#{lib_dir}/bundler/inline"]
- requires.unshift "#{spec_dir}/support/artifice/" + options.delete(:artifice) if options.key?(:artifice)
- requires = requires.map {|r| "require '#{r}'" }.join("\n")
- ruby("#{requires}\n\n" + code, options)
- end
-
- before :each do
- build_lib "one", "1.0.0" do |s|
- s.write "lib/baz.rb", "puts 'baz'"
- s.write "lib/qux.rb", "puts 'qux'"
- end
-
- build_lib "two", "1.0.0" do |s|
- s.write "lib/two.rb", "puts 'two'"
- s.add_dependency "three", "= 1.0.0"
- end
-
- build_lib "three", "1.0.0" do |s|
- s.write "lib/three.rb", "puts 'three'"
- s.add_dependency "seven", "= 1.0.0"
- end
-
- build_lib "four", "1.0.0" do |s|
- s.write "lib/four.rb", "puts 'four'"
- end
-
- build_lib "five", "1.0.0", :no_default => true do |s|
- s.write "lib/mofive.rb", "puts 'five'"
- end
-
- build_lib "six", "1.0.0" do |s|
- s.write "lib/six.rb", "puts 'six'"
- end
-
- build_lib "seven", "1.0.0" do |s|
- s.write "lib/seven.rb", "puts 'seven'"
- end
-
- build_lib "eight", "1.0.0" do |s|
- s.write "lib/eight.rb", "puts 'eight'"
- end
- end
-
- it "requires the gems" do
- script <<-RUBY
- gemfile do
- path "#{lib_path}" do
- gem "two"
- end
- end
- RUBY
-
- expect(out).to eq("two")
- expect(exitstatus).to be_zero if exitstatus
-
- script <<-RUBY
- gemfile do
- path "#{lib_path}" do
- gem "eleven"
- end
- end
-
- puts "success"
- RUBY
-
- expect(err).to include "Could not find gem 'eleven'"
- expect(out).not_to include "success"
-
- script <<-RUBY
- gemfile(true) do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
- RUBY
-
- expect(out).to include("Rack's post install message")
- expect(exitstatus).to be_zero if exitstatus
-
- script <<-RUBY, :artifice => "endpoint"
- gemfile(true) do
- source "https://notaserver.com"
- gem "activesupport", :require => true
- end
- RUBY
-
- expect(out).to include("Installing activesupport")
- err_lines = err.split("\n")
- err_lines.reject!{|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7"
- expect(err_lines).to be_empty
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "lets me use my own ui object" do
- script <<-RUBY, :artifice => "endpoint"
- require '#{lib_dir}/bundler'
- class MyBundlerUI < Bundler::UI::Silent
- def confirm(msg, newline = nil)
- puts "CONFIRMED!"
- end
- end
- gemfile(true, :ui => MyBundlerUI.new) do
- source "https://notaserver.com"
- gem "activesupport", :require => true
- end
- RUBY
-
- expect(out).to eq("CONFIRMED!\nCONFIRMED!")
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "has an option for quiet installation" do
- script <<-RUBY, :artifice => "endpoint"
- require '#{lib_dir}/bundler/inline'
-
- gemfile(true, :quiet => true) do
- source "https://notaserver.com"
- gem "activesupport", :require => true
- end
- RUBY
-
- expect(out).to be_empty
- end
-
- it "raises an exception if passed unknown arguments" do
- script <<-RUBY
- gemfile(true, :arglebargle => true) do
- path "#{lib_path}"
- gem "two"
- end
-
- puts "success"
- RUBY
- expect(err).to include "Unknown options: arglebargle"
- expect(out).not_to include "success"
- end
-
- it "does not mutate the option argument" do
- script <<-RUBY
- require '#{lib_dir}/bundler'
- options = { :ui => Bundler::UI::Shell.new }
- gemfile(false, options) do
- path "#{lib_path}" do
- gem "two"
- end
- end
- puts "OKAY" if options.key?(:ui)
- RUBY
-
- expect(out).to match("OKAY")
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "installs quietly if necessary when the install option is not set" do
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
-
- puts RACK
- RUBY
-
- expect(out).to eq("1.0.0")
- expect(err).to be_empty
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "installs quietly from git if necessary when the install option is not set" do
- build_git "foo", "1.0.0"
- baz_ref = build_git("baz", "2.0.0").ref_for("HEAD")
- script <<-RUBY
- gemfile do
- gem "foo", :git => #{lib_path("foo-1.0.0").to_s.dump}
- gem "baz", :git => #{lib_path("baz-2.0.0").to_s.dump}, :ref => #{baz_ref.dump}
- end
-
- puts FOO
- puts BAZ
- RUBY
-
- expect(out).to eq("1.0.0\n2.0.0")
- expect(err).to be_empty
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "allows calling gemfile twice" do
- script <<-RUBY
- gemfile do
- path "#{lib_path}" do
- gem "two"
- end
- end
-
- gemfile do
- path "#{lib_path}" do
- gem "four"
- end
- end
- RUBY
-
- expect(out).to eq("two\nfour")
- expect(err).to be_empty
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "installs inline gems when a Gemfile.lock is present" do
- gemfile <<-G
- source "https://notaserver.com"
- gem "rake"
- G
-
- lockfile <<-G
- GEM
- remote: https://rubygems.org/
- specs:
- rake (11.3.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rake
-
- BUNDLED WITH
- 1.13.6
- G
-
- in_app_root do
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
-
- puts RACK
- RUBY
- end
-
- expect(err).to be_empty
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "installs inline gems when frozen is set" do
- script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" }
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
-
- puts RACK
- RUBY
-
- expect(last_command.stderr).to be_empty
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "installs inline gems when BUNDLE_GEMFILE is set to an empty string" do
- ENV["BUNDLE_GEMFILE"] = ""
-
- in_app_root do
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
-
- puts RACK
- RUBY
- end
-
- expect(err).to be_empty
- expect(exitstatus).to be_zero if exitstatus
- end
-
- it "installs inline gems when BUNDLE_BIN is set" do
- ENV["BUNDLE_BIN"] = "/usr/local/bundle/bin"
-
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack" # has the rackup executable
- end
-
- puts RACK
- RUBY
- expect(last_command).to be_success
- expect(out).to eq "1.0.0"
- end
-
- context "when BUNDLE_PATH is set" do
- it "installs inline gems to the system path regardless" do
- script <<-RUBY, :env => { "BUNDLE_PATH" => "./vendor/inline" }
- gemfile(true) do
- source "file://#{gem_repo1}"
- gem "rack"
- end
- RUBY
- expect(last_command).to be_success
- expect(system_gem_path("gems/rack-1.0.0")).to exist
- end
- end
-
- it "skips platform warnings" do
- simulate_platform "ruby"
-
- script <<-RUBY
- gemfile(true) do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", platform: :jruby
- end
- RUBY
-
- expect(err).to be_empty
- end
-
- it "preserves previous BUNDLE_GEMFILE value" do
- ENV["BUNDLE_GEMFILE"] = ""
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
-
- puts "BUNDLE_GEMFILE is empty" if ENV["BUNDLE_GEMFILE"].empty?
- system("#{Gem.ruby} -w -e '42'") # this should see original value of BUNDLE_GEMFILE
- exit $?.exitstatus
- RUBY
-
- expect(last_command).to be_success
- expect(out).to include("BUNDLE_GEMFILE is empty")
- end
-
- it "resets BUNDLE_GEMFILE to the empty string if it wasn't set previously" do
- ENV["BUNDLE_GEMFILE"] = nil
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
-
- puts "BUNDLE_GEMFILE is empty" if ENV["BUNDLE_GEMFILE"].empty?
- system("#{Gem.ruby} -w -e '42'") # this should see original value of BUNDLE_GEMFILE
- exit $?.exitstatus
- RUBY
-
- expect(last_command).to be_success
- expect(out).to include("BUNDLE_GEMFILE is empty")
- end
-end
diff --git a/spec/bundler/runtime/load_spec.rb b/spec/bundler/runtime/load_spec.rb
deleted file mode 100644
index 7de67e247c..0000000000
--- a/spec/bundler/runtime/load_spec.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Bundler.load" do
- describe "with a gemfile" do
- before(:each) do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- it "provides a list of the env dependencies" do
- expect(Bundler.load.dependencies).to have_dep("rack", ">= 0")
- end
-
- it "provides a list of the resolved gems" do
- expect(Bundler.load.gems).to have_gem("rack-1.0.0", "bundler-#{Bundler::VERSION}")
- end
-
- it "ignores blank BUNDLE_GEMFILEs" do
- expect do
- ENV["BUNDLE_GEMFILE"] = ""
- Bundler.load
- end.not_to raise_error
- end
- end
-
- describe "with a gems.rb file" do
- before(:each) do
- create_file "gems.rb", <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- bundle! :install
- end
-
- it "provides a list of the env dependencies" do
- expect(Bundler.load.dependencies).to have_dep("rack", ">= 0")
- end
-
- it "provides a list of the resolved gems" do
- expect(Bundler.load.gems).to have_gem("rack-1.0.0", "bundler-#{Bundler::VERSION}")
- end
- end
-
- describe "without a gemfile" do
- it "raises an exception if the default gemfile is not found" do
- expect do
- Bundler.load
- end.to raise_error(Bundler::GemfileNotFound, /could not locate gemfile/i)
- end
-
- it "raises an exception if a specified gemfile is not found" do
- expect do
- ENV["BUNDLE_GEMFILE"] = "omg.rb"
- Bundler.load
- end.to raise_error(Bundler::GemfileNotFound, /omg\.rb/)
- end
-
- it "does not find a Gemfile above the testing directory" do
- bundler_gemfile = Pathname.new(__dir__).join("../../Gemfile")
- unless File.exist?(bundler_gemfile)
- FileUtils.touch(bundler_gemfile)
- @remove_bundler_gemfile = true
- end
- begin
- expect { Bundler.load }.to raise_error(Bundler::GemfileNotFound)
- ensure
- bundler_gemfile.rmtree if @remove_bundler_gemfile
- end
- end
- end
-
- describe "when called twice" do
- it "doesn't try to load the runtime twice" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "activesupport", :group => :test
- G
-
- ruby! <<-RUBY
- require "#{lib_dir}/bundler"
- Bundler.setup :default
- Bundler.require :default
- puts RACK
- begin
- require "activesupport"
- rescue LoadError
- puts "no activesupport"
- end
- RUBY
-
- expect(out.split("\n")).to eq(["1.0.0", "no activesupport"])
- end
- end
-
- describe "not hurting brittle rubygems" do
- it "does not inject #source into the generated YAML of the gem specs" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activerecord"
- G
-
- Bundler.load.specs.each do |spec|
- expect(spec.to_yaml).not_to match(/^\s+source:/)
- expect(spec.to_yaml).not_to match(/^\s+groups:/)
- end
- end
- end
-end
diff --git a/spec/bundler/runtime/platform_spec.rb b/spec/bundler/runtime/platform_spec.rb
deleted file mode 100644
index f7e93eacf1..0000000000
--- a/spec/bundler/runtime/platform_spec.rb
+++ /dev/null
@@ -1,169 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Bundler.setup with multi platform stuff" do
- it "raises a friendly error when gems are missing locally" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0)
-
- PLATFORMS
- #{local_tag}
-
- DEPENDENCIES
- rack
- G
-
- ruby <<-R
- begin
- require 'bundler'
- Bundler.ui.silence { Bundler.setup }
- rescue Bundler::GemNotFound => e
- puts "WIN"
- end
- R
-
- expect(out).to eq("WIN")
- end
-
- it "will resolve correctly on the current platform when the lockfile was targeted for a different one" do
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- nokogiri (1.4.2-java)
- weakling (= 0.0.3)
- weakling (0.0.3)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- nokogiri
- G
-
- simulate_platform "x86-darwin-10"
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "nokogiri"
- G
-
- expect(the_bundle).to include_gems "nokogiri 1.4.2"
- end
-
- it "will add the resolve for the current platform" do
- lockfile <<-G
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- nokogiri (1.4.2-java)
- weakling (= 0.0.3)
- weakling (0.0.3)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- nokogiri
- G
-
- simulate_platform "x86-darwin-100"
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "nokogiri"
- gem "platform_specific"
- G
-
- expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100"
- end
-
- it "allows specifying only-ruby-platform" do
- simulate_platform "java"
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "nokogiri"
- gem "platform_specific"
- G
-
- bundle! "config set force_ruby_platform true"
-
- bundle! "install"
-
- expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 RUBY"
- end
-
- it "allows specifying only-ruby-platform on windows with dependency platforms" do
- simulate_windows do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "nokogiri", :platforms => [:mingw, :mswin, :x64_mingw, :jruby]
- gem "platform_specific"
- G
-
- bundle! "config set force_ruby_platform true"
-
- bundle! "install"
-
- expect(the_bundle).to include_gems "platform_specific 1.0 RUBY"
- end
- end
-
- it "allows specifying only-ruby-platform on windows with gemspec dependency" do
- build_lib("foo", "1.0", :path => ".") do |s|
- s.add_dependency "rack"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gemspec
- G
- bundle! :lock
-
- simulate_windows do
- bundle! "config set force_ruby_platform true"
- bundle! "install"
-
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- it "recovers when the lockfile is missing a platform-specific gem" do
- build_repo2 do
- build_gem "requires_platform_specific" do |s|
- s.add_dependency "platform_specific"
- end
- end
- simulate_windows x64_mingw do
- lockfile <<-L
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- platform_specific (1.0-x86-mingw32)
- requires_platform_specific (1.0)
- platform_specific
-
- PLATFORMS
- x64-mingw32
- x86-mingw32
-
- DEPENDENCIES
- requires_platform_specific
- L
-
- install_gemfile! <<-G, :verbose => true
- source "#{file_uri_for(gem_repo2)}"
- gem "requires_platform_specific"
- G
-
- expect(the_bundle).to include_gem "platform_specific 1.0 x64-mingw32"
- end
- end
-end
diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb
deleted file mode 100644
index a8d7826123..0000000000
--- a/spec/bundler/runtime/require_spec.rb
+++ /dev/null
@@ -1,450 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Bundler.require" do
- before :each do
- build_lib "one", "1.0.0" do |s|
- s.write "lib/baz.rb", "puts 'baz'"
- s.write "lib/qux.rb", "puts 'qux'"
- end
-
- build_lib "two", "1.0.0" do |s|
- s.write "lib/two.rb", "puts 'two'"
- s.add_dependency "three", "= 1.0.0"
- end
-
- build_lib "three", "1.0.0" do |s|
- s.write "lib/three.rb", "puts 'three'"
- s.add_dependency "seven", "= 1.0.0"
- end
-
- build_lib "four", "1.0.0" do |s|
- s.write "lib/four.rb", "puts 'four'"
- end
-
- build_lib "five", "1.0.0", :no_default => true do |s|
- s.write "lib/mofive.rb", "puts 'five'"
- end
-
- build_lib "six", "1.0.0" do |s|
- s.write "lib/six.rb", "puts 'six'"
- end
-
- build_lib "seven", "1.0.0" do |s|
- s.write "lib/seven.rb", "puts 'seven'"
- end
-
- build_lib "eight", "1.0.0" do |s|
- s.write "lib/eight.rb", "puts 'eight'"
- end
-
- build_lib "nine", "1.0.0" do |s|
- s.write "lib/nine.rb", "puts 'nine'"
- end
-
- build_lib "ten", "1.0.0" do |s|
- s.write "lib/ten.rb", "puts 'ten'"
- end
-
- gemfile <<-G
- path "#{lib_path}" do
- gem "one", :group => :bar, :require => %w[baz qux]
- gem "two"
- gem "three", :group => :not
- gem "four", :require => false
- gem "five"
- gem "six", :group => "string"
- gem "seven", :group => :not
- gem "eight", :require => true, :group => :require_true
- env "BUNDLER_TEST" => "nine" do
- gem "nine", :require => true
- end
- gem "ten", :install_if => lambda { ENV["BUNDLER_TEST"] == "ten" }
- end
- G
- end
-
- it "requires the gems" do
- # default group
- run "Bundler.require"
- expect(out).to eq("two")
-
- # specific group
- run "Bundler.require(:bar)"
- expect(out).to eq("baz\nqux")
-
- # default and specific group
- run "Bundler.require(:default, :bar)"
- expect(out).to eq("baz\nqux\ntwo")
-
- # specific group given as a string
- run "Bundler.require('bar')"
- expect(out).to eq("baz\nqux")
-
- # specific group declared as a string
- run "Bundler.require(:string)"
- expect(out).to eq("six")
-
- # required in resolver order instead of gemfile order
- run("Bundler.require(:not)")
- expect(out.split("\n").sort).to eq(%w[seven three])
-
- # test require: true
- run "Bundler.require(:require_true)"
- expect(out).to eq("eight")
- end
-
- it "allows requiring gems with non standard names explicitly" do
- run "Bundler.require ; require 'mofive'"
- expect(out).to eq("two\nfive")
- end
-
- it "allows requiring gems which are scoped by env" do
- ENV["BUNDLER_TEST"] = "nine"
- run "Bundler.require"
- expect(out).to eq("two\nnine")
- end
-
- it "allows requiring gems which are scoped by install_if" do
- ENV["BUNDLER_TEST"] = "ten"
- run "Bundler.require"
- expect(out).to eq("two\nten")
- end
-
- it "raises an exception if a require is specified but the file does not exist" do
- gemfile <<-G
- path "#{lib_path}" do
- gem "two", :require => 'fail'
- end
- G
-
- load_error_run <<-R, "fail"
- Bundler.require
- R
-
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
- end
-
- it "displays a helpful message if the required gem throws an error" do
- build_lib "faulty", "1.0.0" do |s|
- s.write "lib/faulty.rb", "raise RuntimeError.new(\"Gem Internal Error Message\")"
- end
-
- gemfile <<-G
- path "#{lib_path}" do
- gem "faulty"
- end
- G
-
- run "Bundler.require"
- expect(err).to match("error while trying to load the gem 'faulty'")
- expect(err).to match("Gem Internal Error Message")
- end
-
- it "doesn't swallow the error when the library has an unrelated error" do
- build_lib "loadfuuu", "1.0.0" do |s|
- s.write "lib/loadfuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
- end
-
- gemfile <<-G
- path "#{lib_path}" do
- gem "loadfuuu"
- end
- G
-
- cmd = <<-RUBY
- begin
- Bundler.require
- rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
- end
- RUBY
- run(cmd)
-
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar")
- end
-
- describe "with namespaced gems" do
- before :each do
- build_lib "jquery-rails", "1.0.0" do |s|
- s.write "lib/jquery/rails.rb", "puts 'jquery/rails'"
- end
- end
-
- it "requires gem names that are namespaced" do
- gemfile <<-G
- path '#{lib_path}' do
- gem 'jquery-rails'
- end
- G
-
- run "Bundler.require"
- expect(out).to eq("jquery/rails")
- end
-
- it "silently passes if the require fails" do
- build_lib "bcrypt-ruby", "1.0.0", :no_default => true do |s|
- s.write "lib/brcrypt.rb", "BCrypt = '1.0.0'"
- end
- gemfile <<-G
- path "#{lib_path}" do
- gem "bcrypt-ruby"
- end
- G
-
- cmd = <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.require
- RUBY
- ruby(cmd)
-
- expect(err).to be_empty
- end
-
- it "does not mangle explicitly given requires" do
- gemfile <<-G
- path "#{lib_path}" do
- gem 'jquery-rails', :require => 'jquery-rails'
- end
- G
-
- load_error_run <<-R, "jquery-rails"
- Bundler.require
- R
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
- end
-
- it "handles the case where regex fails" do
- build_lib "load-fuuu", "1.0.0" do |s|
- s.write "lib/load-fuuu.rb", "raise LoadError.new(\"Could not open library 'libfuuu-1.0': libfuuu-1.0: cannot open shared object file: No such file or directory.\")"
- end
-
- gemfile <<-G
- path "#{lib_path}" do
- gem "load-fuuu"
- end
- G
-
- cmd = <<-RUBY
- begin
- Bundler.require
- rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR" if e.message.include?("Could not open library 'libfuuu-1.0'")
- end
- RUBY
- run(cmd)
-
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
- end
-
- it "doesn't swallow the error when the library has an unrelated error" do
- build_lib "load-fuuu", "1.0.0" do |s|
- s.write "lib/load/fuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
- end
-
- gemfile <<-G
- path "#{lib_path}" do
- gem "load-fuuu"
- end
- G
-
- cmd = <<-RUBY
- begin
- Bundler.require
- rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
- end
- RUBY
- run(cmd)
-
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar")
- end
- end
-
- describe "using bundle exec" do
- it "requires the locked gems" do
- bundle "exec ruby -e 'Bundler.require'"
- expect(out).to eq("two")
-
- bundle "exec ruby -e 'Bundler.require(:bar)'"
- expect(out).to eq("baz\nqux")
-
- bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
- expect(out).to eq("baz\nqux\ntwo")
- end
- end
-
- describe "order" do
- before(:each) do
- build_lib "one", "1.0.0" do |s|
- s.write "lib/one.rb", <<-ONE
- if defined?(Two)
- Two.two
- else
- puts "two_not_loaded"
- end
- puts 'one'
- ONE
- end
-
- build_lib "two", "1.0.0" do |s|
- s.write "lib/two.rb", <<-TWO
- module Two
- def self.two
- puts 'module_two'
- end
- end
- puts 'two'
- TWO
- end
- end
-
- it "works when the gems are in the Gemfile in the correct order" do
- gemfile <<-G
- path "#{lib_path}" do
- gem "two"
- gem "one"
- end
- G
-
- run "Bundler.require"
- expect(out).to eq("two\nmodule_two\none")
- end
-
- describe "a gem with different requires for different envs" do
- before(:each) do
- build_gem "multi_gem", :to_bundle => true do |s|
- s.write "lib/one.rb", "puts 'ONE'"
- s.write "lib/two.rb", "puts 'TWO'"
- end
-
- install_gemfile <<-G
- gem "multi_gem", :require => "one", :group => :one
- gem "multi_gem", :require => "two", :group => :two
- G
- end
-
- it "requires both with Bundler.require(both)" do
- run "Bundler.require(:one, :two)"
- expect(out).to eq("ONE\nTWO")
- end
-
- it "requires one with Bundler.require(:one)" do
- run "Bundler.require(:one)"
- expect(out).to eq("ONE")
- end
-
- it "requires :two with Bundler.require(:two)" do
- run "Bundler.require(:two)"
- expect(out).to eq("TWO")
- end
- end
-
- it "fails when the gems are in the Gemfile in the wrong order" do
- gemfile <<-G
- path "#{lib_path}" do
- gem "one"
- gem "two"
- end
- G
-
- run "Bundler.require"
- expect(out).to eq("two_not_loaded\none\ntwo")
- end
-
- describe "with busted gems" do
- it "should be busted" do
- build_gem "busted_require", :to_bundle => true do |s|
- s.write "lib/busted_require.rb", "require 'no_such_file_omg'"
- end
-
- install_gemfile <<-G
- gem "busted_require"
- G
-
- load_error_run <<-R, "no_such_file_omg"
- Bundler.require
- R
- expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
- end
- end
- end
-
- it "does not load rubygems gemspecs that are used" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- run! <<-R
- path = File.join(Gem.dir, "specifications", "rack-1.0.0.gemspec")
- contents = File.read(path)
- contents = contents.lines.to_a.insert(-2, "\n raise 'broken gemspec'\n").join
- File.open(path, "w") do |f|
- f.write contents
- end
- R
-
- run! <<-R
- Bundler.require
- puts "WIN"
- R
-
- expect(out).to eq("WIN")
- end
-
- it "does not load git gemspecs that are used" do
- build_git "foo"
-
- install_gemfile! <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- run! <<-R
- path = Gem.loaded_specs["foo"].loaded_from
- contents = File.read(path)
- contents = contents.lines.to_a.insert(-2, "\n raise 'broken gemspec'\n").join
- File.open(path, "w") do |f|
- f.write contents
- end
- R
-
- run! <<-R
- Bundler.require
- puts "WIN"
- R
-
- expect(out).to eq("WIN")
- end
-end
-
-RSpec.describe "Bundler.require with platform specific dependencies" do
- it "does not require the gems that are pinned to other platforms" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- platforms :#{not_local_tag} do
- gem "fail", :require => "omgomg"
- end
-
- gem "rack", "1.0.0"
- G
-
- run "Bundler.require"
- expect(err).to be_empty
- end
-
- it "requires gems pinned to multiple platforms, including the current one" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- platforms :#{not_local_tag}, :#{local_tag} do
- gem "rack", :require => "rack"
- end
- G
-
- run "Bundler.require; puts RACK"
-
- expect(out).to eq("1.0.0")
- expect(err).to be_empty
- end
-end
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
deleted file mode 100644
index 7f00a63078..0000000000
--- a/spec/bundler/runtime/setup_spec.rb
+++ /dev/null
@@ -1,1375 +0,0 @@
-# frozen_string_literal: true
-
-require "tmpdir"
-require "tempfile"
-
-RSpec.describe "Bundler.setup" do
- describe "with no arguments" do
- it "makes all groups available" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :group => :test
- G
-
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup
-
- require 'rack'
- puts RACK
- RUBY
- expect(err).to be_empty
- expect(out).to eq("1.0.0")
- end
- end
-
- describe "when called with groups" do
- before(:each) do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- gem "rack", :group => :test
- G
- end
-
- it "doesn't make all groups available" do
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup(:default)
-
- begin
- require 'rack'
- rescue LoadError
- puts "WIN"
- end
- RUBY
- expect(err).to be_empty
- expect(out).to eq("WIN")
- end
-
- it "accepts string for group name" do
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup(:default, 'test')
-
- require 'rack'
- puts RACK
- RUBY
- expect(err).to be_empty
- expect(out).to eq("1.0.0")
- end
-
- it "leaves all groups available if they were already" do
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup
- Bundler.setup(:default)
-
- require 'rack'
- puts RACK
- RUBY
- expect(err).to be_empty
- expect(out).to eq("1.0.0")
- end
-
- it "leaves :default available if setup is called twice" do
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup(:default)
- Bundler.setup(:default, :test)
-
- begin
- require 'yard'
- puts "WIN"
- rescue LoadError
- puts "FAIL"
- end
- RUBY
- expect(err).to be_empty
- expect(out).to match("WIN")
- end
-
- it "handles multiple non-additive invocations" do
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup(:default, :test)
- Bundler.setup(:default)
- require 'rack'
-
- puts "FAIL"
- RUBY
-
- expect(err).to match("rack")
- expect(err).to match("LoadError")
- expect(out).not_to match("FAIL")
- end
- end
-
- context "load order" do
- def clean_load_path(lp)
- without_bundler_load_path = ruby!("puts $LOAD_PATH").split("\n")
- lp -= without_bundler_load_path
- lp.map! {|p| p.sub(/^#{Regexp.union system_gem_path.to_s, default_bundle_path.to_s, lib_dir.to_s}/i, "") }
- end
-
- it "puts loaded gems after -I and RUBYLIB", :ruby_repo do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -Idash_i_dir"
- ENV["RUBYLIB"] = "rubylib_dir"
-
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup
- puts $LOAD_PATH
- RUBY
-
- load_path = out.split("\n")
- rack_load_order = load_path.index {|path| path.include?("rack") }
-
- expect(err).to be_empty
- expect(load_path).to include(a_string_ending_with("dash_i_dir"), "rubylib_dir")
- expect(rack_load_order).to be > 0
- end
-
- it "orders the load path correctly when there are dependencies" do
- system_gems :bundler
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rails"
- G
-
- ruby! <<-RUBY
- require '#{lib_dir}/bundler'
- Bundler.setup
- puts $LOAD_PATH
- RUBY
-
- load_path = clean_load_path(out.split("\n"))
-
- expect(load_path).to start_with(
- "/gems/rails-2.3.2/lib",
- "/gems/bundler-#{Bundler::VERSION}/lib",
- "/gems/activeresource-2.3.2/lib",
- "/gems/activerecord-2.3.2/lib",
- "/gems/actionpack-2.3.2/lib",
- "/gems/actionmailer-2.3.2/lib",
- "/gems/activesupport-2.3.2/lib",
- "/gems/rake-12.3.2/lib"
- )
- end
-
- it "falls back to order the load path alphabetically for backwards compatibility" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "weakling"
- gem "duradura"
- gem "terranova"
- G
-
- ruby! <<-RUBY
- require '#{lib_dir}/bundler/setup'
- puts $LOAD_PATH
- RUBY
-
- load_path = clean_load_path(out.split("\n"))
-
- expect(load_path).to start_with(
- "/gems/weakling-0.0.3/lib",
- "/gems/terranova-8/lib",
- "/gems/duradura-7.0/lib"
- )
- end
- end
-
- it "raises if the Gemfile was not yet installed" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- ruby <<-R
- require '#{lib_dir}/bundler'
-
- begin
- Bundler.setup
- puts "FAIL"
- rescue Bundler::GemNotFound
- puts "WIN"
- end
- R
-
- expect(out).to eq("WIN")
- end
-
- it "doesn't create a Gemfile.lock if the setup fails" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- ruby <<-R
- require '#{lib_dir}/bundler'
-
- Bundler.setup
- R
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- end
-
- it "doesn't change the Gemfile.lock if the setup fails" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- lockfile = File.read(bundled_app("Gemfile.lock"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "nosuchgem", "10.0"
- G
-
- ruby <<-R
- require '#{lib_dir}/bundler'
-
- Bundler.setup
- R
-
- expect(File.read(bundled_app("Gemfile.lock"))).to eq(lockfile)
- end
-
- it "makes a Gemfile.lock if setup succeeds" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- File.read(bundled_app("Gemfile.lock"))
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- run "1"
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
- describe "$BUNDLE_GEMFILE" do
- context "user provides an absolute path" do
- it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- gemfile bundled_app("4realz"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport", "2.3.5"
- G
-
- ENV["BUNDLE_GEMFILE"] = bundled_app("4realz").to_s
- bundle :install
-
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- end
- end
-
- context "an absolute path is not provided" do
- it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
-
- bundle "install"
- bundle "install --deployment"
-
- ENV["BUNDLE_GEMFILE"] = "Gemfile"
- ruby <<-R
- require '#{lib_dir}/bundler'
-
- begin
- Bundler.setup
- puts "WIN"
- rescue ArgumentError => e
- puts "FAIL"
- end
- R
-
- expect(out).to eq("WIN")
- end
- end
- end
-
- it "prioritizes gems in BUNDLE_PATH over gems in GEM_HOME" do
- ENV["BUNDLE_PATH"] = bundled_app(".bundle").to_s
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- G
-
- build_gem "rack", "1.0", :to_system => true do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
- end
-
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- describe "integrate with rubygems" do
- describe "by replacing #gem" do
- before :each do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "0.9.1"
- G
- end
-
- it "replaces #gem but raises when the gem is missing" do
- run <<-R
- begin
- gem "activesupport"
- puts "FAIL"
- rescue LoadError
- puts "WIN"
- end
- R
-
- expect(out).to eq("WIN")
- end
-
- it "version_requirement is now deprecated in rubygems 1.4.0+ when gem is missing" do
- run <<-R
- begin
- gem "activesupport"
- puts "FAIL"
- rescue LoadError
- puts "WIN"
- end
- R
-
- expect(err).to be_empty
- end
-
- it "replaces #gem but raises when the version is wrong" do
- run <<-R
- begin
- gem "rack", "1.0.0"
- puts "FAIL"
- rescue LoadError
- puts "WIN"
- end
- R
-
- expect(out).to eq("WIN")
- end
-
- it "version_requirement is now deprecated in rubygems 1.4.0+ when the version is wrong" do
- run <<-R
- begin
- gem "rack", "1.0.0"
- puts "FAIL"
- rescue LoadError
- puts "WIN"
- end
- R
-
- expect(err).to be_empty
- end
- end
-
- describe "by hiding system gems" do
- before :each do
- system_gems "activesupport-2.3.5"
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "yard"
- G
- end
-
- it "removes system gems from Gem.source_index" do
- run "require 'yard'"
- expect(out).to eq("bundler-#{Bundler::VERSION}\nyard-1.0")
- end
-
- context "when the ruby stdlib is a substring of Gem.path" do
- it "does not reject the stdlib from $LOAD_PATH" do
- substring = "/" + $LOAD_PATH.find {|p| p =~ /vendor_ruby/ }.split("/")[2]
- run "puts 'worked!'", :env => { "GEM_PATH" => substring }
- expect(out).to eq("worked!")
- end
- end
- end
- end
-
- describe "with paths" do
- it "activates the gems in the path source" do
- system_gems "rack-1.0.0"
-
- build_lib "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "puts 'WIN'"
- end
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- path "#{lib_path("rack-1.0.0")}" do
- gem "rack"
- end
- G
-
- run "require 'rack'"
- expect(out).to eq("WIN")
- end
- end
-
- describe "with git" do
- before do
- build_git "rack", "1.0.0"
-
- gemfile <<-G
- gem "rack", :git => "#{lib_path("rack-1.0.0")}"
- G
- end
-
- it "provides a useful exception when the git repo is not checked out yet" do
- run "1"
- expect(err).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
- end
-
- it "does not hit the git binary if the lockfile is available and up to date" do
- bundle "install"
-
- break_git!
-
- ruby <<-R
- require '#{lib_dir}/bundler'
-
- begin
- Bundler.setup
- puts "WIN"
- rescue Exception => e
- puts "FAIL"
- end
- R
-
- expect(out).to eq("WIN")
- end
-
- it "provides a good exception if the lockfile is unavailable" do
- bundle "install"
-
- FileUtils.rm(bundled_app("Gemfile.lock"))
-
- break_git!
-
- ruby <<-R
- require "#{lib_dir}/bundler"
-
- begin
- Bundler.setup
- puts "FAIL"
- rescue Bundler::GitError => e
- puts e.message
- end
- R
-
- run "puts 'FAIL'"
-
- expect(err).not_to include "This is not the git you are looking for"
- end
-
- it "works even when the cache directory has been deleted" do
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- FileUtils.rm_rf vendored_gems("cache")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
-
- with_read_only("**/*") do
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- it "finds git gem when default bundle path becomes read only" do
- bundle "install"
-
- with_read_only("#{Bundler.bundle_path}/**/*") do
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
- end
-
- describe "when specifying local override" do
- it "explodes if given path does not exist on runtime" do
- build_git "rack", "0.8"
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle! :install
-
- FileUtils.rm_rf(lib_path("local-rack"))
- run "require 'rack'"
- expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
- end
-
- it "explodes if branch is not given on runtime" do
- build_git "rack", "0.8"
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle! :install
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}"
- G
-
- run "require 'rack'"
- expect(err).to match(/because :branch is not specified in Gemfile/)
- end
-
- it "explodes on different branches on runtime" do
- build_git "rack", "0.8"
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle! :install
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "changed"
- G
-
- run "require 'rack'"
- expect(err).to match(/is using branch master but Gemfile specifies changed/)
- end
-
- it "explodes on refs with different branches on runtime" do
- build_git "rack", "0.8"
-
- FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :ref => "master", :branch => "master"
- G
-
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :ref => "master", :branch => "nonexistant"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- run "require 'rack'"
- expect(err).to match(/is using branch master but Gemfile specifies nonexistant/)
- end
- end
-
- describe "when excluding groups" do
- it "doesn't change the resolve if --without is used" do
- install_gemfile <<-G, forgotten_command_line_options(:without => :rails)
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
-
- group :rails do
- gem "rails", "2.3.2"
- end
- G
-
- install_gems "activesupport-2.3.5"
-
- expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => :default
- end
-
- it "remembers --without and does not bail on bare Bundler.setup" do
- install_gemfile <<-G, forgotten_command_line_options(:without => :rails)
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
-
- group :rails do
- gem "rails", "2.3.2"
- end
- G
-
- install_gems "activesupport-2.3.5"
-
- expect(the_bundle).to include_gems "activesupport 2.3.2"
- end
-
- it "remembers --without and does not include groups passed to Bundler.setup" do
- install_gemfile <<-G, forgotten_command_line_options(:without => :rails)
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
-
- group :rack do
- gem "rack"
- end
-
- group :rails do
- gem "rails", "2.3.2"
- end
- G
-
- expect(the_bundle).not_to include_gems "activesupport 2.3.2", :groups => :rack
- expect(the_bundle).to include_gems "rack 1.0.0", :groups => :rack
- end
- end
-
- # RubyGems returns loaded_from as a string
- it "has loaded_from as a string on all specs" do
- build_git "foo"
- build_git "no-gemspec", :gemspec => false
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- gem "no-gemspec", "1.0", :git => "#{lib_path("no-gemspec-1.0")}"
- G
-
- run <<-R
- Gem.loaded_specs.each do |n, s|
- puts "FAIL" unless s.loaded_from.is_a?(String)
- end
- R
-
- expect(out).to be_empty
- end
-
- it "does not load all gemspecs" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- run! <<-R
- File.open(File.join(Gem.dir, "specifications", "broken.gemspec"), "w") do |f|
- f.write <<-RUBY
-# -*- encoding: utf-8 -*-
-# stub: broken 1.0.0 ruby lib
-
-Gem::Specification.new do |s|
- s.name = "broken"
- s.version = "1.0.0"
- raise "BROKEN GEMSPEC"
-end
- RUBY
- end
- R
-
- run! <<-R
- puts "WIN"
- R
-
- expect(out).to eq("WIN")
- end
-
- it "ignores empty gem paths" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- ENV["GEM_HOME"] = ""
- bundle %(exec ruby -e "require 'set'")
-
- expect(err).to be_empty
- end
-
- describe "$MANPATH" do
- before do
- build_repo4 do
- build_gem "with_man" do |s|
- s.write("man/man1/page.1", "MANPAGE")
- end
- end
- end
-
- context "when the user has one set" do
- before { ENV["MANPATH"] = "/foo:" }
-
- it "adds the gem's man dir to the MANPATH" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "with_man"
- G
-
- run! "puts ENV['MANPATH']"
- expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}:/foo")
- end
- end
-
- context "when the user does not have one set" do
- before { ENV.delete("MANPATH") }
-
- it "adds the gem's man dir to the MANPATH" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "with_man"
- G
-
- run! "puts ENV['MANPATH']"
- expect(out).to eq(default_bundle_path("gems/with_man-1.0/man").to_s)
- end
- end
- end
-
- it "should prepend gemspec require paths to $LOAD_PATH in order" do
- update_repo2 do
- build_gem("requirepaths") do |s|
- s.write("lib/rq.rb", "puts 'yay'")
- s.write("src/rq.rb", "puts 'nooo'")
- s.require_paths = %w[lib src]
- end
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "requirepaths", :require => nil
- G
-
- run "require 'rq'"
- expect(out).to eq("yay")
- end
-
- it "should clean $LOAD_PATH properly", :ruby_repo do
- gem_name = "very_simple_binary"
- full_gem_name = gem_name + "-1.0"
- ext_dir = File.join(tmp("extensions", full_gem_name))
-
- install_gems full_gem_name
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- G
-
- ruby <<-R
- if Gem::Specification.method_defined? :extension_dir
- s = Gem::Specification.find_by_name '#{gem_name}'
- s.extension_dir = '#{ext_dir}'
-
- # Don't build extensions.
- s.class.send(:define_method, :build_extensions) { nil }
- end
-
- require '#{lib_dir}/bundler'
- gem '#{gem_name}'
-
- puts $LOAD_PATH.count {|path| path =~ /#{gem_name}/} >= 2
-
- Bundler.setup
-
- puts $LOAD_PATH.count {|path| path =~ /#{gem_name}/} == 0
- R
-
- expect(out).to eq("true\ntrue")
- end
-
- context "with bundler is located in symlinked GEM_HOME" do
- let(:gem_home) { Dir.mktmpdir }
- let(:symlinked_gem_home) { Tempfile.new("gem_home").path }
- let(:full_name) { "bundler-#{Bundler::VERSION}" }
-
- before do
- FileUtils.ln_sf(gem_home, symlinked_gem_home)
- gems_dir = File.join(gem_home, "gems")
- specifications_dir = File.join(gem_home, "specifications")
- Dir.mkdir(gems_dir)
- Dir.mkdir(specifications_dir)
-
- FileUtils.ln_s(root, File.join(gems_dir, full_name))
-
- gemspec_content = File.binread(gemspec).
- sub("Bundler::VERSION", %("#{Bundler::VERSION}")).
- lines.reject {|line| line =~ %r{lib/bundler/version} }.join
-
- File.open(File.join(specifications_dir, "#{full_name}.gemspec"), "wb") do |f|
- f.write(gemspec_content)
- end
- end
-
- it "should not remove itself from the LOAD_PATH and require a different copy of 'bundler/setup'" do
- install_gemfile ""
-
- ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
- TracePoint.trace(:class) do |tp|
- if tp.path.include?("bundler") && !tp.path.start_with?("#{root}")
- puts "OMG. Defining a class from another bundler at \#{tp.path}:\#{tp.lineno}"
- end
- end
- gem 'bundler', '#{Bundler::VERSION}'
- require 'bundler/setup'
- R
-
- expect(out).to be_empty
- end
- end
-
- it "does not reveal system gems even when Gem.refresh is called" do
- system_gems "rack-1.0.0"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "activesupport"
- G
-
- run <<-R
- puts Bundler.rubygems.all_specs.map(&:name)
- Gem.refresh
- puts Bundler.rubygems.all_specs.map(&:name)
- R
-
- expect(out).to eq("activesupport\nbundler\nactivesupport\nbundler")
- end
-
- describe "when a vendored gem specification uses the :path option" do
- let(:filesystem_root) do
- current = Pathname.new(Dir.pwd)
- current = current.parent until current == current.parent
- current
- end
-
- it "should resolve paths relative to the Gemfile" do
- path = bundled_app(File.join("vendor", "foo"))
- build_lib "foo", :path => path
-
- # If the .gemspec exists, then Bundler handles the path differently.
- # See Source::Path.load_spec_files for details.
- FileUtils.rm(File.join(path, "foo.gemspec"))
-
- install_gemfile <<-G
- gem 'foo', '1.2.3', :path => 'vendor/foo'
- G
-
- Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
- require 'foo'
- R
- end
- expect(err).to be_empty
- end
-
- it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
- relative_path = File.join("vendor", Dir.pwd.gsub(/^#{filesystem_root}/, ""))
- absolute_path = bundled_app(relative_path)
- FileUtils.mkdir_p(absolute_path)
- build_lib "foo", :path => absolute_path
-
- # If the .gemspec exists, then Bundler handles the path differently.
- # See Source::Path.load_spec_files for details.
- FileUtils.rm(File.join(absolute_path, "foo.gemspec"))
-
- gemfile <<-G
- gem 'foo', '1.2.3', :path => '#{relative_path}'
- G
-
- bundle :install
-
- Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
- require 'foo'
- R
- end
-
- expect(err).to be_empty
- end
- end
-
- describe "with git gems that don't have gemspecs" do
- before :each do
- build_git "no_gemspec", :gemspec => false
-
- install_gemfile <<-G
- gem "no_gemspec", "1.0", :git => "#{lib_path("no_gemspec-1.0")}"
- G
- end
-
- it "loads the library via a virtual spec" do
- run <<-R
- require 'no_gemspec'
- puts NO_GEMSPEC
- R
-
- expect(out).to eq("1.0")
- end
- end
-
- describe "with bundled and system gems" do
- before :each do
- system_gems "rack-1.0.0"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
-
- gem "activesupport", "2.3.5"
- G
- end
-
- it "does not pull in system gems" do
- run <<-R
- begin;
- require 'rack'
- rescue LoadError
- puts 'WIN'
- end
- R
-
- expect(out).to eq("WIN")
- end
-
- it "provides a gem method" do
- run <<-R
- gem 'activesupport'
- require 'activesupport'
- puts ACTIVESUPPORT
- R
-
- expect(out).to eq("2.3.5")
- end
-
- it "raises an exception if gem is used to invoke a system gem not in the bundle" do
- run <<-R
- begin
- gem 'rack'
- rescue LoadError => e
- puts e.message
- end
- R
-
- expect(out).to eq("rack is not part of the bundle. Add it to your Gemfile.")
- end
-
- it "sets GEM_HOME appropriately" do
- run "puts ENV['GEM_HOME']"
- expect(out).to eq(default_bundle_path.to_s)
- end
- end
-
- describe "with system gems in the bundle" do
- before :each do
- bundle! "config set path.system true"
- system_gems "rack-1.0.0"
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", "1.0.0"
- gem "activesupport", "2.3.5"
- G
- end
-
- it "sets GEM_PATH appropriately" do
- run "puts Gem.path"
- paths = out.split("\n")
- expect(paths).to include(system_gem_path.to_s)
- end
- end
-
- describe "with a gemspec that requires other files" do
- before :each do
- build_git "bar", :gemspec => false do |s|
- s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0')
- s.write "bar.gemspec", <<-G
- require_relative 'lib/bar/version'
-
- Gem::Specification.new do |s|
- s.name = 'bar'
- s.version = BAR_VERSION
- s.summary = 'Bar'
- s.files = Dir["lib/**/*.rb"]
- s.author = 'no one'
- end
- G
- end
-
- gemfile <<-G
- gem "bar", :git => "#{lib_path("bar-1.0")}"
- G
- end
-
- it "evals each gemspec in the context of its parent directory" do
- bundle :install
- run "require 'bar'; puts BAR"
- expect(out).to eq("1.0")
- end
-
- it "error intelligently if the gemspec has a LoadError" do
- ref = update_git "bar", :gemspec => false do |s|
- s.write "bar.gemspec", "require 'foobarbaz'"
- end.ref_for("HEAD")
- bundle :install
-
- expect(err.lines.map(&:chomp)).to include(
- a_string_starting_with("[!] There was an error while loading `bar.gemspec`:"),
- a_string_starting_with("Does it try to require a relative path? That's been removed in Ruby 1.9."),
- " # from #{default_bundle_path "bundler", "gems", "bar-1.0-#{ref[0, 12]}", "bar.gemspec"}:1",
- " > require 'foobarbaz'"
- )
- end
-
- it "evals each gemspec with a binding from the top level" do
- bundle "install"
-
- ruby <<-RUBY
- require '#{lib_dir}/bundler'
- bundler_module = class << Bundler; self; end
- bundler_module.send(:remove_method, :require)
- def Bundler.require(path)
- raise "LOSE"
- end
- Bundler.load
- RUBY
-
- expect(err).to be_empty
- expect(out).to be_empty
- end
- end
-
- describe "when Bundler is bundled" do
- it "doesn't blow up" do
- install_gemfile <<-G
- gem "bundler", :path => "#{root}"
- G
-
- bundle %(exec ruby -e "require 'bundler'; Bundler.setup")
- expect(err).to be_empty
- end
- end
-
- describe "when BUNDLED WITH" do
- def lock_with(bundler_version = nil)
- lock = <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
- L
-
- if bundler_version
- lock += "\n BUNDLED WITH\n #{bundler_version}\n"
- end
-
- lock
- end
-
- before do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- context "is not present" do
- it "does not change the lock" do
- lockfile lock_with(nil)
- ruby "require '#{lib_dir}/bundler/setup'"
- lockfile_should_be lock_with(nil)
- end
- end
-
- context "is newer" do
- it "does not change the lock or warn" do
- lockfile lock_with(Bundler::VERSION.succ)
- ruby "require '#{lib_dir}/bundler/setup'"
- expect(out).to be_empty
- expect(err).to be_empty
- lockfile_should_be lock_with(Bundler::VERSION.succ)
- end
- end
-
- context "is older" do
- it "does not change the lock" do
- lockfile lock_with("1.10.1")
- ruby "require '#{lib_dir}/bundler/setup'"
- lockfile_should_be lock_with("1.10.1")
- end
- end
- end
-
- describe "when RUBY VERSION" do
- let(:ruby_version) { nil }
-
- def lock_with(ruby_version = nil)
- lock = <<-L
- GEM
- remote: #{file_uri_for(gem_repo1)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
- L
-
- if ruby_version
- lock += "\n RUBY VERSION\n ruby #{ruby_version}\n"
- end
-
- lock += <<-L
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- lock
- end
-
- before do
- install_gemfile <<-G
- ruby ">= 0"
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- lockfile lock_with(ruby_version)
- end
-
- context "is not present" do
- it "does not change the lock" do
- expect { ruby! "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile }
- end
- end
-
- context "is newer" do
- let(:ruby_version) { "5.5.5" }
- it "does not change the lock or warn" do
- expect { ruby! "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile }
- expect(out).to be_empty
- expect(err).to be_empty
- end
- end
-
- context "is older" do
- let(:ruby_version) { "1.0.0" }
- it "does not change the lock" do
- expect { ruby! "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile }
- end
- end
- end
-
- describe "with gemified standard libraries" do
- it "does not load Psych" do
- gemfile ""
- ruby <<-RUBY
- require '#{lib_dir}/bundler/setup'
- puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined"
- require 'psych'
- puts Psych::VERSION
- RUBY
- pre_bundler, post_bundler = out.split("\n")
- expect(pre_bundler).to eq("undefined")
- expect(post_bundler).to match(/\d+\.\d+\.\d+/)
- end
-
- it "does not load openssl" do
- install_gemfile! ""
- ruby! <<-RUBY
- require "#{lib_dir}/bundler/setup"
- puts defined?(OpenSSL) || "undefined"
- require "openssl"
- puts defined?(OpenSSL) || "undefined"
- RUBY
- expect(out).to eq("undefined\nconstant")
- end
-
- describe "default gem activation" do
- let(:exemptions) do
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
- %w[did_you_mean]
- else
- %w[io-console openssl]
- end << "bundler"
- end
-
- let(:activation_warning_hack) { strip_whitespace(<<-RUBY) }
- require #{spec_dir.join("support/hax").to_s.dump}
-
- Gem::Specification.send(:alias_method, :bundler_spec_activate, :activate)
- Gem::Specification.send(:define_method, :activate) do
- unless #{exemptions.inspect}.include?(name)
- warn '-' * 80
- warn "activating \#{full_name}"
- warn(*caller)
- warn '*' * 80
- end
- bundler_spec_activate
- end
- RUBY
-
- let(:activation_warning_hack_rubyopt) do
- create_file("activation_warning_hack.rb", activation_warning_hack)
- "-r#{bundled_app("activation_warning_hack.rb")} #{ENV["RUBYOPT"]}"
- end
-
- let(:code) { strip_whitespace(<<-RUBY) }
- require "pp"
- loaded_specs = Gem.loaded_specs.dup
- #{exemptions.inspect}.each {|s| loaded_specs.delete(s) }
- pp loaded_specs
-
- # not a default gem, but harmful to have loaded
- open_uri = $LOADED_FEATURES.grep(/open.uri/)
- unless open_uri.empty?
- warn "open_uri: \#{open_uri}"
- end
- RUBY
-
- it "activates no gems with -rbundler/setup" do
- install_gemfile! ""
- ruby! code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" }
- expect(out).to eq("{}")
- end
-
- it "activates no gems with bundle exec" do
- install_gemfile! ""
- create_file("script.rb", code)
- bundle! "exec ruby ./script.rb", :env => { "RUBYOPT" => activation_warning_hack_rubyopt }
- expect(out).to eq("{}")
- end
-
- it "activates no gems with bundle exec that is loaded" do
- install_gemfile! ""
- create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}")
- FileUtils.chmod(0o777, bundled_app("script.rb"))
- bundle! "exec ./script.rb", :artifice => nil, :env => { "RUBYOPT" => activation_warning_hack_rubyopt }
- expect(out).to eq("{}")
- end
-
- it "does not load net-http-pipeline too early" do
- build_repo4 do
- build_gem "net-http-pipeline", "1.0.1"
- end
-
- system_gems "net-http-pipeline-1.0.1", :gem_repo => gem_repo4 do
- gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "net-http-pipeline", "1.0.1"
- G
-
- bundle "config set --local path vendor/bundle"
-
- bundle! :install
-
- bundle! :check
-
- expect(out).to eq("The Gemfile's dependencies are satisfied")
- end
- end
-
- Gem::Specification.select(&:default_gem?).map(&:name).each do |g|
- it "activates newer versions of #{g}" do
- skip if exemptions.include?(g)
-
- build_repo4 do
- build_gem g, "999999"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "#{g}", "999999"
- G
-
- expect(the_bundle).to include_gem("#{g} 999999", :env => { "RUBYOPT" => activation_warning_hack_rubyopt })
- end
-
- it "activates older versions of #{g}" do
- skip if exemptions.include?(g)
-
- build_repo4 do
- build_gem g, "0.0.0.a"
- end
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- gem "#{g}", "0.0.0.a"
- G
-
- expect(the_bundle).to include_gem("#{g} 0.0.0.a", :env => { "RUBYOPT" => activation_warning_hack_rubyopt })
- end
- end
- end
- end
-
- describe "after setup" do
- it "allows calling #gem on random objects", :bundler => "< 3" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- ruby! <<-RUBY
- require "#{lib_dir}/bundler/setup"
- Object.new.gem "rack"
- puts Gem.loaded_specs["rack"].full_name
- RUBY
-
- expect(out).to eq("rack-1.0.0")
- end
-
- it "keeps Kernel#gem private", :bundler => "3" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- ruby <<-RUBY
- require "#{lib_dir}/bundler/setup"
- Object.new.gem "rack"
- puts "FAIL"
- RUBY
-
- expect(last_command.stdboth).not_to include "FAIL"
- expect(err).to include "private method `gem'"
- end
-
- it "keeps Kernel#require private" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
-
- ruby <<-RUBY
- require "#{lib_dir}/bundler/setup"
- Object.new.require "rack"
- puts "FAIL"
- RUBY
-
- expect(last_command.stdboth).not_to include "FAIL"
- expect(err).to include "private method `require'"
- end
-
- it "takes care of requiring rubygems" do
- sys_exec("#{Gem.ruby} -I#{lib_dir} -e \"puts require('bundler/setup')\"", "RUBYOPT" => "--disable=gems")
-
- expect(last_command.stdboth).to eq("true")
- end
- end
-end
diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb
deleted file mode 100644
index 4aaf9d499c..0000000000
--- a/spec/bundler/runtime/with_unbundled_env_spec.rb
+++ /dev/null
@@ -1,270 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Bundler.with_env helpers" do
- def bundle_exec_ruby!(code, options = {})
- build_bundler_context options
- bundle! "exec '#{Gem.ruby}' -e #{code}", options
- end
-
- def build_bundler_context(options = {})
- bundle "config set path vendor/bundle"
- gemfile ""
- bundle "install", options
- end
-
- describe "Bundler.original_env" do
- it "should return the PATH present before bundle was activated" do
- code = "print Bundler.original_env['PATH']"
- path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo"
- with_path_as(path) do
- bundle_exec_ruby!(code.dump)
- expect(last_command.stdboth).to eq(path)
- end
- end
-
- it "should return the GEM_PATH present before bundle was activated" do
- code = "print Bundler.original_env['GEM_PATH']"
- gem_path = ENV["GEM_PATH"] + ":/foo"
- with_gem_path_as(gem_path) do
- bundle_exec_ruby!(code.dump)
- expect(last_command.stdboth).to eq(gem_path)
- end
- end
-
- it "works with nested bundle exec invocations" do
- create_file("exe.rb", <<-'RB')
- count = ARGV.first.to_i
- exit if count < 0
- STDERR.puts "#{count} #{ENV["PATH"].end_with?(":/foo")}"
- if count == 2
- ENV["PATH"] = "#{ENV["PATH"]}:/foo"
- end
- exec(Gem.ruby, __FILE__, (count - 1).to_s)
- RB
- path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby)
- with_path_as(path) do
- build_bundler_context
- bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2"
- end
- expect(err).to eq <<-EOS.strip
-2 false
-1 true
-0 true
- EOS
- end
-
- it "removes variables that bundler added", :ruby_repo do
- # Simulate bundler has not yet been loaded
- ENV.replace(ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) })
-
- original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")')
- code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")'
- bundle_exec_ruby! code.dump
- expect(out).to eq original
- end
- end
-
- shared_examples_for "an unbundling helper" do
- it "should delete BUNDLE_PATH" do
- code = "print #{modified_env}.has_key?('BUNDLE_PATH')"
- ENV["BUNDLE_PATH"] = "./foo"
- bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to include "false"
- end
-
- it "should remove '-rbundler/setup' from RUBYOPT" do
- code = "print #{modified_env}['RUBYOPT']"
- ENV["RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
- bundle_exec_ruby! code.dump, :env => { "BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM" => "true" }
- expect(last_command.stdboth).not_to include("-rbundler/setup")
- end
-
- it "should restore RUBYLIB", :ruby_repo do
- code = "print #{modified_env}['RUBYLIB']"
- ENV["RUBYLIB"] = lib_dir.to_s + File::PATH_SEPARATOR + "/foo"
- ENV["BUNDLER_ORIG_RUBYLIB"] = lib_dir.to_s + File::PATH_SEPARATOR + "/foo-original"
- bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to include("/foo-original")
- end
-
- it "should restore the original MANPATH" do
- code = "print #{modified_env}['MANPATH']"
- ENV["MANPATH"] = "/foo"
- ENV["BUNDLER_ORIG_MANPATH"] = "/foo-original"
- bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to include("/foo-original")
- end
- end
-
- describe "Bundler.unbundled_env" do
- let(:modified_env) { "Bundler.unbundled_env" }
-
- it_behaves_like "an unbundling helper"
- end
-
- describe "Bundler.clean_env", :bundler => 2 do
- let(:modified_env) { "Bundler.clean_env" }
-
- it_behaves_like "an unbundling helper"
- end
-
- describe "Bundler.with_original_env" do
- it "should set ENV to original_env in the block" do
- expected = Bundler.original_env
- actual = Bundler.with_original_env { ENV.to_hash }
- expect(actual).to eq(expected)
- end
-
- it "should restore the environment after execution" do
- Bundler.with_original_env do
- ENV["FOO"] = "hello"
- end
-
- expect(ENV).not_to have_key("FOO")
- end
- end
-
- describe "Bundler.with_clean_env", :bundler => 2 do
- it "should set ENV to unbundled_env in the block" do
- expected = Bundler.unbundled_env
-
- actual = Bundler.ui.silence do
- Bundler.with_clean_env { ENV.to_hash }
- end
-
- expect(actual).to eq(expected)
- end
-
- it "should restore the environment after execution" do
- Bundler.ui.silence do
- Bundler.with_clean_env { ENV["FOO"] = "hello" }
- end
-
- expect(ENV).not_to have_key("FOO")
- end
- end
-
- describe "Bundler.with_unbundled_env" do
- it "should set ENV to unbundled_env in the block" do
- expected = Bundler.unbundled_env
- actual = Bundler.with_unbundled_env { ENV.to_hash }
- expect(actual).to eq(expected)
- end
-
- it "should restore the environment after execution" do
- Bundler.with_unbundled_env do
- ENV["FOO"] = "hello"
- end
-
- expect(ENV).not_to have_key("FOO")
- end
- end
-
- describe "Bundler.original_system" do
- let(:code) do
- <<~RUBY
- Bundler.original_system(%([ "\$BUNDLE_FOO" = "bar" ] && exit 42))
-
- exit $?.exitstatus
- RUBY
- end
-
- it "runs system inside with_original_env" do
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(42)
- end
- end
-
- describe "Bundler.clean_system", :bundler => 2 do
- let(:code) do
- <<~RUBY
- Bundler.ui.silence { Bundler.clean_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42)) }
-
- exit $?.exitstatus
- RUBY
- end
-
- it "runs system inside with_clean_env" do
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(42)
- end
- end
-
- describe "Bundler.unbundled_system" do
- let(:code) do
- <<~RUBY
- Bundler.unbundled_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
-
- exit $?.exitstatus
- RUBY
- end
-
- it "runs system inside with_unbundled_env" do
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(42)
- end
- end
-
- describe "Bundler.original_exec" do
- let(:code) do
- <<~RUBY
- Process.fork do
- exit Bundler.original_exec(%(test "\$BUNDLE_FOO" = "bar"))
- end
-
- _, status = Process.wait2
-
- exit(status.exitstatus)
- RUBY
- end
-
- it "runs exec inside with_original_env" do
- skip "Fork not implemented" if Gem.win_platform?
-
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(0)
- end
- end
-
- describe "Bundler.clean_exec", :bundler => 2 do
- let(:code) do
- <<~RUBY
- Process.fork do
- exit Bundler.ui.silence { Bundler.clean_exec(%(test "\$BUNDLE_FOO" = "bar")) }
- end
-
- _, status = Process.wait2
-
- exit(status.exitstatus)
- RUBY
- end
-
- it "runs exec inside with_clean_env" do
- skip "Fork not implemented" if Gem.win_platform?
-
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(1)
- end
- end
-
- describe "Bundler.unbundled_exec" do
- let(:code) do
- <<~RUBY
- Process.fork do
- exit Bundler.unbundled_exec(%(test "\$BUNDLE_FOO" = "bar"))
- end
-
- _, status = Process.wait2
-
- exit(status.exitstatus)
- RUBY
- end
-
- it "runs exec inside with_clean_env" do
- skip "Fork not implemented" if Gem.win_platform?
-
- system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(1)
- end
- end
-end
diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb
deleted file mode 100644
index 0a49b46aaa..0000000000
--- a/spec/bundler/spec_helper.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "support/path"
-
-$:.unshift Spec::Path.spec_dir.to_s
-$:.unshift Spec::Path.lib_dir.to_s
-
-require "bundler/psyched_yaml"
-require "bundler/vendored_fileutils"
-require "bundler/vendored_uri"
-require "digest"
-
-if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
- abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
-end
-
-require "bundler"
-require "rspec"
-
-require_relative "support/builders"
-require_relative "support/filters"
-require_relative "support/helpers"
-require_relative "support/indexes"
-require_relative "support/matchers"
-require_relative "support/parallel"
-require_relative "support/permissions"
-require_relative "support/platforms"
-require_relative "support/sometimes"
-require_relative "support/sudo"
-
-$debug = false
-
-module Gem
- def self.ruby=(ruby)
- @ruby = ruby
- end
-end
-
-RSpec.configure do |config|
- config.include Spec::Builders
- config.include Spec::Helpers
- config.include Spec::Indexes
- config.include Spec::Matchers
- config.include Spec::Path
- config.include Spec::Platforms
- config.include Spec::Sudo
- config.include Spec::Permissions
-
- # Enable flags like --only-failures and --next-failure
- config.example_status_persistence_file_path = ".rspec_status"
-
- config.disable_monkey_patching!
-
- # Since failures cause us to keep a bunch of long strings in memory, stop
- # once we have a large number of failures (indicative of core pieces of
- # bundler being broken) so that running the full test suite doesn't take
- # forever due to memory constraints
- config.fail_fast ||= 25 if ENV["CI"]
-
- config.bisect_runner = :shell
-
- original_wd = Dir.pwd
- original_env = ENV.to_hash
-
- config.expect_with :rspec do |c|
- c.syntax = :expect
- end
-
- config.mock_with :rspec do |mocks|
- mocks.allow_message_expectations_on_nil = false
- end
-
- config.around :each do |example|
- if ENV["RUBY"]
- orig_ruby = Gem.ruby
- Gem.ruby = ENV["RUBY"]
- end
- example.run
- Gem.ruby = orig_ruby if ENV["RUBY"]
- end
-
- config.before :suite do
- require_relative "support/rubygems_ext"
- Spec::Rubygems.setup
- ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
- ENV["BUNDLE_SPEC_RUN"] = "true"
- ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil
- ENV["GEMRC"] = nil
-
- # Don't wrap output in tests
- ENV["THOR_COLUMNS"] = "10000"
-
- original_env = ENV.to_hash
-
- if ENV["RUBY"]
- FileUtils.cp_r Spec::Path.bindir, File.join(Spec::Path.root, "lib", "exe")
- end
- end
-
- config.before :all do
- build_repo1
- end
-
- config.around :each do |example|
- ENV.replace(original_env)
- reset!
- system_gems []
- in_app_root
- @command_executions = []
-
- Bundler.ui.silence { example.run }
-
- all_output = @command_executions.map(&:to_s_verbose).join("\n\n")
- if example.exception && !all_output.empty?
- warn all_output unless config.formatters.grep(RSpec::Core::Formatters::DocumentationFormatter).empty?
- message = example.exception.message + "\n\nCommands:\n#{all_output}"
- (class << example.exception; self; end).send(:define_method, :message) do
- message
- end
- end
-
- Dir.chdir(original_wd)
- end
-
- config.after :suite do
- if ENV["RUBY"]
- FileUtils.rm_rf File.join(Spec::Path.root, "lib", "exe")
- end
- end
-end
diff --git a/spec/bundler/support/artifice/compact_index.rb b/spec/bundler/support/artifice/compact_index.rb
deleted file mode 100644
index 72abf26224..0000000000
--- a/spec/bundler/support/artifice/compact_index.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-$LOAD_PATH.unshift Dir[base_system_gems.join("gems/compact_index*/lib")].first.to_s
-require "compact_index"
-
-class CompactIndexAPI < Endpoint
- helpers do
- def load_spec(name, version, platform, gem_repo)
- full_name = "#{name}-#{version}"
- full_name += "-#{platform}" if platform != "ruby"
- Marshal.load(Bundler.rubygems.inflate(File.binread(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz"))))
- end
-
- def etag_response
- response_body = yield
- checksum = Digest(:MD5).hexdigest(response_body)
- return if not_modified?(checksum)
- headers "ETag" => quote(checksum)
- headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60"
- content_type "text/plain"
- requested_range_for(response_body)
- rescue StandardError => e
- puts e
- puts e.backtrace
- raise
- end
-
- def not_modified?(checksum)
- etags = parse_etags(request.env["HTTP_IF_NONE_MATCH"])
-
- return unless etags.include?(checksum)
- headers "ETag" => quote(checksum)
- status 304
- body ""
- end
-
- def requested_range_for(response_body)
- ranges = Rack::Utils.byte_ranges(env, response_body.bytesize)
-
- if ranges
- status 206
- body ranges.map! {|range| slice_body(response_body, range) }.join
- else
- status 200
- body response_body
- end
- end
-
- def quote(string)
- %("#{string}")
- end
-
- def parse_etags(value)
- value ? value.split(/, ?/).select {|s| s.sub!(/"(.*)"/, '\1') } : []
- end
-
- def slice_body(body, range)
- body.byteslice(range)
- end
-
- def gems(gem_repo = GEM_REPO)
- @gems ||= {}
- @gems[gem_repo] ||= begin
- specs = Bundler::Deprecate.skip_during do
- %w[specs.4.8 prerelease_specs.4.8].map do |filename|
- Marshal.load(File.open(gem_repo.join(filename)).read).map do |name, version, platform|
- load_spec(name, version, platform, gem_repo)
- end
- end.flatten
- end
-
- specs.group_by(&:name).map do |name, versions|
- gem_versions = versions.map do |spec|
- deps = spec.dependencies.select {|d| d.type == :runtime }.map do |d|
- reqs = d.requirement.requirements.map {|r| r.join(" ") }.join(", ")
- CompactIndex::Dependency.new(d.name, reqs)
- end
- checksum = begin
- Digest(:SHA256).file("#{GEM_REPO}/gems/#{spec.original_name}.gem").base64digest
- rescue StandardError
- nil
- end
- CompactIndex::GemVersion.new(spec.version.version, spec.platform.to_s, checksum, nil,
- deps, spec.required_ruby_version, spec.required_rubygems_version)
- end
- CompactIndex::Gem.new(name, gem_versions)
- end
- end
- end
- end
-
- get "/names" do
- etag_response do
- CompactIndex.names(gems.map(&:name))
- end
- end
-
- get "/versions" do
- etag_response do
- file = tmp("versions.list")
- file.delete if file.file?
- file = CompactIndex::VersionsFile.new(file.to_s)
- file.create(gems)
- file.contents
- end
- end
-
- get "/info/:name" do
- etag_response do
- gem = gems.find {|g| g.name == params[:name] }
- CompactIndex.info(gem ? gem.versions : [])
- end
- end
-end
-
-Artifice.activate_with(CompactIndexAPI)
diff --git a/spec/bundler/support/artifice/compact_index_api_missing.rb b/spec/bundler/support/artifice/compact_index_api_missing.rb
deleted file mode 100644
index 6514fde01e..0000000000
--- a/spec/bundler/support/artifice/compact_index_api_missing.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexApiMissing < CompactIndexAPI
- get "/fetch/actual/gem/:id" do
- warn params[:id]
- if params[:id] == "rack-1.0.gemspec.rz"
- halt 404
- else
- File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
- end
- end
-end
-
-Artifice.activate_with(CompactIndexApiMissing)
diff --git a/spec/bundler/support/artifice/compact_index_basic_authentication.rb b/spec/bundler/support/artifice/compact_index_basic_authentication.rb
deleted file mode 100644
index 775f1a3977..0000000000
--- a/spec/bundler/support/artifice/compact_index_basic_authentication.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexBasicAuthentication < CompactIndexAPI
- before do
- unless env["HTTP_AUTHORIZATION"]
- halt 401, "Authentication info not supplied"
- end
- end
-end
-
-Artifice.activate_with(CompactIndexBasicAuthentication)
diff --git a/spec/bundler/support/artifice/compact_index_checksum_mismatch.rb b/spec/bundler/support/artifice/compact_index_checksum_mismatch.rb
deleted file mode 100644
index 1abe64236c..0000000000
--- a/spec/bundler/support/artifice/compact_index_checksum_mismatch.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexChecksumMismatch < CompactIndexAPI
- get "/versions" do
- headers "ETag" => quote("123")
- headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60"
- content_type "text/plain"
- body ""
- end
-end
-
-Artifice.activate_with(CompactIndexChecksumMismatch)
diff --git a/spec/bundler/support/artifice/compact_index_concurrent_download.rb b/spec/bundler/support/artifice/compact_index_concurrent_download.rb
deleted file mode 100644
index 7f989a3f37..0000000000
--- a/spec/bundler/support/artifice/compact_index_concurrent_download.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexConcurrentDownload < CompactIndexAPI
- get "/versions" do
- versions = File.join(Bundler.rubygems.user_home, ".bundle", "cache", "compact_index",
- "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", "versions")
-
- # Verify the original (empty) content hasn't been deleted, e.g. on a retry
- File.read(versions) == "" || raise("Original file should be present and empty")
-
- # Verify this is only requested once for a partial download
- env["HTTP_RANGE"] || raise("Missing Range header for expected partial download")
-
- # Overwrite the file in parallel, which should be then overwritten
- # after a successful download to prevent corruption
- File.open(versions, "w") {|f| f.puts "another process" }
-
- etag_response do
- file = tmp("versions.list")
- file.delete if file.file?
- file = CompactIndex::VersionsFile.new(file.to_s)
- file.create(gems)
- file.contents
- end
- end
-end
-
-Artifice.activate_with(CompactIndexConcurrentDownload)
diff --git a/spec/bundler/support/artifice/compact_index_creds_diff_host.rb b/spec/bundler/support/artifice/compact_index_creds_diff_host.rb
deleted file mode 100644
index 6c3442e14b..0000000000
--- a/spec/bundler/support/artifice/compact_index_creds_diff_host.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexCredsDiffHost < CompactIndexAPI
- helpers do
- def auth
- @auth ||= Rack::Auth::Basic::Request.new(request.env)
- end
-
- def authorized?
- auth.provided? && auth.basic? && auth.credentials && auth.credentials == %w[user pass]
- end
-
- def protected!
- return if authorized?
- response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth")
- throw(:halt, [401, "Not authorized\n"])
- end
- end
-
- before do
- protected! unless request.path_info.include?("/no/creds/")
- end
-
- get "/gems/:id" do
- redirect "http://diffhost.com/no/creds/#{params[:id]}"
- end
-
- get "/no/creds/:id" do
- if request.host.include?("diffhost") && !auth.provided?
- File.read("#{gem_repo1}/gems/#{params[:id]}")
- end
- end
-end
-
-Artifice.activate_with(CompactIndexCredsDiffHost)
diff --git a/spec/bundler/support/artifice/compact_index_extra.rb b/spec/bundler/support/artifice/compact_index_extra.rb
deleted file mode 100644
index 3a09afd06f..0000000000
--- a/spec/bundler/support/artifice/compact_index_extra.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexExtra < CompactIndexAPI
- get "/extra/versions" do
- halt 404
- end
-
- get "/extra/api/v1/dependencies" do
- halt 404
- end
-
- get "/extra/specs.4.8.gz" do
- File.read("#{gem_repo2}/specs.4.8.gz")
- end
-
- get "/extra/prerelease_specs.4.8.gz" do
- File.read("#{gem_repo2}/prerelease_specs.4.8.gz")
- end
-
- get "/extra/quick/Marshal.4.8/:id" do
- redirect "/extra/fetch/actual/gem/#{params[:id]}"
- end
-
- get "/extra/fetch/actual/gem/:id" do
- File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
- end
-
- get "/extra/gems/:id" do
- File.read("#{gem_repo2}/gems/#{params[:id]}")
- end
-end
-
-Artifice.activate_with(CompactIndexExtra)
diff --git a/spec/bundler/support/artifice/compact_index_extra_api.rb b/spec/bundler/support/artifice/compact_index_extra_api.rb
deleted file mode 100644
index 3c716763c0..0000000000
--- a/spec/bundler/support/artifice/compact_index_extra_api.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexExtraApi < CompactIndexAPI
- get "/extra/names" do
- etag_response do
- CompactIndex.names(gems(gem_repo4).map(&:name))
- end
- end
-
- get "/extra/versions" do
- etag_response do
- file = tmp("versions.list")
- file.delete if file.file?
- file = CompactIndex::VersionsFile.new(file.to_s)
- file.create(gems(gem_repo4))
- file.contents
- end
- end
-
- get "/extra/info/:name" do
- etag_response do
- gem = gems(gem_repo4).find {|g| g.name == params[:name] }
- CompactIndex.info(gem ? gem.versions : [])
- end
- end
-
- get "/extra/specs.4.8.gz" do
- File.read("#{gem_repo4}/specs.4.8.gz")
- end
-
- get "/extra/prerelease_specs.4.8.gz" do
- File.read("#{gem_repo4}/prerelease_specs.4.8.gz")
- end
-
- get "/extra/quick/Marshal.4.8/:id" do
- redirect "/extra/fetch/actual/gem/#{params[:id]}"
- end
-
- get "/extra/fetch/actual/gem/:id" do
- File.read("#{gem_repo4}/quick/Marshal.4.8/#{params[:id]}")
- end
-
- get "/extra/gems/:id" do
- File.read("#{gem_repo4}/gems/#{params[:id]}")
- end
-end
-
-Artifice.activate_with(CompactIndexExtraApi)
diff --git a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb b/spec/bundler/support/artifice/compact_index_extra_api_missing.rb
deleted file mode 100644
index b9d757c266..0000000000
--- a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index_extra_api"
-
-Artifice.deactivate
-
-class CompactIndexExtraAPIMissing < CompactIndexExtraApi
- get "/extra/fetch/actual/gem/:id" do
- if params[:id] == "missing-1.0.gemspec.rz"
- halt 404
- else
- File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
- end
- end
-end
-
-Artifice.activate_with(CompactIndexExtraAPIMissing)
diff --git a/spec/bundler/support/artifice/compact_index_extra_missing.rb b/spec/bundler/support/artifice/compact_index_extra_missing.rb
deleted file mode 100644
index ff1e47a1bb..0000000000
--- a/spec/bundler/support/artifice/compact_index_extra_missing.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index_extra"
-
-Artifice.deactivate
-
-class CompactIndexExtraMissing < CompactIndexExtra
- get "/extra/fetch/actual/gem/:id" do
- if params[:id] == "missing-1.0.gemspec.rz"
- halt 404
- else
- File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
- end
- end
-end
-
-Artifice.activate_with(CompactIndexExtraMissing)
diff --git a/spec/bundler/support/artifice/compact_index_forbidden.rb b/spec/bundler/support/artifice/compact_index_forbidden.rb
deleted file mode 100644
index 3eebe0fbd8..0000000000
--- a/spec/bundler/support/artifice/compact_index_forbidden.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexForbidden < CompactIndexAPI
- get "/versions" do
- halt 403
- end
-end
-
-Artifice.activate_with(CompactIndexForbidden)
diff --git a/spec/bundler/support/artifice/compact_index_host_redirect.rb b/spec/bundler/support/artifice/compact_index_host_redirect.rb
deleted file mode 100644
index 304c897d68..0000000000
--- a/spec/bundler/support/artifice/compact_index_host_redirect.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexHostRedirect < CompactIndexAPI
- get "/fetch/actual/gem/:id", :host_name => "localgemserver.test" do
- redirect "http://bundler.localgemserver.test#{request.path_info}"
- end
-
- get "/versions" do
- status 404
- end
-
- get "/api/v1/dependencies" do
- status 404
- end
-end
-
-Artifice.activate_with(CompactIndexHostRedirect)
diff --git a/spec/bundler/support/artifice/compact_index_no_gem.rb b/spec/bundler/support/artifice/compact_index_no_gem.rb
deleted file mode 100644
index 0a4be08a46..0000000000
--- a/spec/bundler/support/artifice/compact_index_no_gem.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexNoGem < CompactIndexAPI
- get "/gems/:id" do
- halt 500
- end
-end
-
-Artifice.activate_with(CompactIndexNoGem)
diff --git a/spec/bundler/support/artifice/compact_index_partial_update.rb b/spec/bundler/support/artifice/compact_index_partial_update.rb
deleted file mode 100644
index 6e7c05d423..0000000000
--- a/spec/bundler/support/artifice/compact_index_partial_update.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexPartialUpdate < CompactIndexAPI
- # Stub the server to never return 304s. This simulates the behaviour of
- # Fastly / Rubygems ignoring ETag headers.
- def not_modified?(_checksum)
- false
- end
-
- get "/versions" do
- cached_versions_path = File.join(
- Bundler.rubygems.user_home, ".bundle", "cache", "compact_index",
- "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", "versions"
- )
-
- # Verify a cached copy of the versions file exists
- unless File.read(cached_versions_path).start_with?("created_at: ")
- raise("Cached versions file should be present and have content")
- end
-
- # Verify that a partial request is made, starting from the index of the
- # final byte of the cached file.
- unless env["HTTP_RANGE"] == "bytes=#{File.read(cached_versions_path).bytesize - 1}-"
- raise("Range header should be present, and start from the index of the final byte of the cache.")
- end
-
- etag_response do
- # Return the exact contents of the cache.
- File.read(cached_versions_path)
- end
- end
-end
-
-Artifice.activate_with(CompactIndexPartialUpdate)
diff --git a/spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb b/spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb
deleted file mode 100644
index 788f9d6f99..0000000000
--- a/spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexRangeNotSatisfiable < CompactIndexAPI
- get "/versions" do
- if env["HTTP_RANGE"]
- status 416
- else
- etag_response do
- file = tmp("versions.list")
- file.delete if file.file?
- file = CompactIndex::VersionsFile.new(file.to_s)
- file.create(gems)
- file.contents
- end
- end
- end
-
- get "/info/:name" do
- if env["HTTP_RANGE"]
- status 416
- else
- etag_response do
- gem = gems.find {|g| g.name == params[:name] }
- CompactIndex.info(gem ? gem.versions : [])
- end
- end
- end
-end
-
-Artifice.activate_with(CompactIndexRangeNotSatisfiable)
diff --git a/spec/bundler/support/artifice/compact_index_rate_limited.rb b/spec/bundler/support/artifice/compact_index_rate_limited.rb
deleted file mode 100644
index ba17476045..0000000000
--- a/spec/bundler/support/artifice/compact_index_rate_limited.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexRateLimited < CompactIndexAPI
- class RequestCounter
- def self.queue
- @queue ||= Queue.new
- end
-
- def self.size
- @queue.size
- end
-
- def self.enq(name)
- @queue.enq(name)
- end
-
- def self.deq
- @queue.deq
- end
- end
-
- configure do
- RequestCounter.queue
- end
-
- get "/info/:name" do
- RequestCounter.enq(params[:name])
-
- begin
- if RequestCounter.size == 1
- etag_response do
- gem = gems.find {|g| g.name == params[:name] }
- CompactIndex.info(gem ? gem.versions : [])
- end
- else
- status 429
- end
- ensure
- RequestCounter.deq
- end
- end
-end
-
-Artifice.activate_with(CompactIndexRateLimited)
diff --git a/spec/bundler/support/artifice/compact_index_redirects.rb b/spec/bundler/support/artifice/compact_index_redirects.rb
deleted file mode 100644
index 99adc797bf..0000000000
--- a/spec/bundler/support/artifice/compact_index_redirects.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexRedirect < CompactIndexAPI
- get "/fetch/actual/gem/:id" do
- redirect "/fetch/actual/gem/#{params[:id]}"
- end
-
- get "/versions" do
- status 404
- end
-
- get "/api/v1/dependencies" do
- status 404
- end
-end
-
-Artifice.activate_with(CompactIndexRedirect)
diff --git a/spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb b/spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb
deleted file mode 100644
index 7d427b5382..0000000000
--- a/spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexStrictBasicAuthentication < CompactIndexAPI
- before do
- unless env["HTTP_AUTHORIZATION"]
- halt 401, "Authentication info not supplied"
- end
-
- # Only accepts password == "password"
- unless env["HTTP_AUTHORIZATION"] == "Basic dXNlcjpwYXNz"
- halt 403, "Authentication failed"
- end
- end
-end
-
-Artifice.activate_with(CompactIndexStrictBasicAuthentication)
diff --git a/spec/bundler/support/artifice/compact_index_wrong_dependencies.rb b/spec/bundler/support/artifice/compact_index_wrong_dependencies.rb
deleted file mode 100644
index 036fac70b3..0000000000
--- a/spec/bundler/support/artifice/compact_index_wrong_dependencies.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexWrongDependencies < CompactIndexAPI
- get "/info/:name" do
- etag_response do
- gem = gems.find {|g| g.name == params[:name] }
- gem.versions.each {|gv| gv.dependencies.clear } if gem
- CompactIndex.info(gem ? gem.versions : [])
- end
- end
-end
-
-Artifice.activate_with(CompactIndexWrongDependencies)
diff --git a/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb b/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb
deleted file mode 100644
index 8add32b88f..0000000000
--- a/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "compact_index"
-
-Artifice.deactivate
-
-class CompactIndexWrongGemChecksum < CompactIndexAPI
- get "/info/:name" do
- etag_response do
- name = params[:name]
- gem = gems.find {|g| g.name == name }
- checksum = ENV.fetch("BUNDLER_SPEC_#{name.upcase}_CHECKSUM") { "ab" * 22 }
- versions = gem ? gem.versions : []
- versions.each {|v| v.checksum = checksum }
- CompactIndex.info(versions)
- end
- end
-end
-
-Artifice.activate_with(CompactIndexWrongGemChecksum)
diff --git a/spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb b/spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb
deleted file mode 100644
index c341c3993f..0000000000
--- a/spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint_marshal_fail"
-
-Artifice.deactivate
-
-class EndpointMarshalFailBasicAuthentication < EndpointMarshalFail
- before do
- unless env["HTTP_AUTHORIZATION"]
- halt 401, "Authentication info not supplied"
- end
- end
-end
-
-Artifice.activate_with(EndpointMarshalFailBasicAuthentication)
diff --git a/spec/bundler/support/artifice/endpoint.rb b/spec/bundler/support/artifice/endpoint.rb
deleted file mode 100644
index 7bca681e70..0000000000
--- a/spec/bundler/support/artifice/endpoint.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../path"
-require Spec::Path.lib_dir.join("bundler/deprecate")
-include Spec::Path
-
-$LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra}-*/lib")].map(&:to_s))
-
-require "artifice"
-require "sinatra/base"
-
-ALL_REQUESTS = [] # rubocop:disable Style/MutableConstant
-ALL_REQUESTS_MUTEX = Mutex.new
-
-at_exit do
- if expected = ENV["BUNDLER_SPEC_ALL_REQUESTS"]
- expected = expected.split("\n").sort
- actual = ALL_REQUESTS.sort
-
- unless expected == actual
- raise "Unexpected requests!\nExpected:\n\t#{expected.join("\n\t")}\n\nActual:\n\t#{actual.join("\n\t")}"
- end
- end
-end
-
-class Endpoint < Sinatra::Base
- def self.all_requests
- @all_requests ||= []
- end
-
- GEM_REPO = Pathname.new(ENV["BUNDLER_SPEC_GEM_REPO"] || Spec::Path.gem_repo1)
- set :raise_errors, true
- set :show_exceptions, false
-
- def call!(*)
- super.tap do
- ALL_REQUESTS_MUTEX.synchronize do
- ALL_REQUESTS << @request.url
- end
- end
- end
-
- helpers do
- def dependencies_for(gem_names, gem_repo = GEM_REPO)
- return [] if gem_names.nil? || gem_names.empty?
-
- require "#{Spec::Path.lib_dir}/bundler"
- Bundler::Deprecate.skip_during do
- all_specs = %w[specs.4.8 prerelease_specs.4.8].map do |filename|
- Marshal.load(File.open(gem_repo.join(filename)).read)
- end.inject(:+)
-
- all_specs.map do |name, version, platform|
- spec = load_spec(name, version, platform, gem_repo)
- next unless gem_names.include?(spec.name)
- {
- :name => spec.name,
- :number => spec.version.version,
- :platform => spec.platform.to_s,
- :dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep|
- [dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")]
- end,
- }
- end.compact
- end
- end
-
- def load_spec(name, version, platform, gem_repo)
- full_name = "#{name}-#{version}"
- full_name += "-#{platform}" if platform != "ruby"
- Marshal.load(Bundler.rubygems.inflate(File.binread(gem_repo.join("quick/Marshal.4.8/#{full_name}.gemspec.rz"))))
- end
- end
-
- get "/quick/Marshal.4.8/:id" do
- redirect "/fetch/actual/gem/#{params[:id]}"
- end
-
- get "/fetch/actual/gem/:id" do
- File.read("#{GEM_REPO}/quick/Marshal.4.8/#{params[:id]}")
- end
-
- get "/gems/:id" do
- File.read("#{GEM_REPO}/gems/#{params[:id]}")
- end
-
- get "/api/v1/dependencies" do
- Marshal.dump(dependencies_for(params[:gems]))
- end
-
- get "/specs.4.8.gz" do
- File.read("#{GEM_REPO}/specs.4.8.gz")
- end
-
- get "/prerelease_specs.4.8.gz" do
- File.read("#{GEM_REPO}/prerelease_specs.4.8.gz")
- end
-end
-
-Artifice.activate_with(Endpoint)
diff --git a/spec/bundler/support/artifice/endpoint_500.rb b/spec/bundler/support/artifice/endpoint_500.rb
deleted file mode 100644
index f98e7e3bc2..0000000000
--- a/spec/bundler/support/artifice/endpoint_500.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../path"
-include Spec::Path
-
-$LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra}-*/lib")].map(&:to_s))
-
-require "artifice"
-require "sinatra/base"
-
-Artifice.deactivate
-
-class Endpoint500 < Sinatra::Base
- before do
- halt 500
- end
-end
-
-Artifice.activate_with(Endpoint500)
diff --git a/spec/bundler/support/artifice/endpoint_api_forbidden.rb b/spec/bundler/support/artifice/endpoint_api_forbidden.rb
deleted file mode 100644
index edc2463424..0000000000
--- a/spec/bundler/support/artifice/endpoint_api_forbidden.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointApiForbidden < Endpoint
- get "/api/v1/dependencies" do
- halt 403
- end
-end
-
-Artifice.activate_with(EndpointApiForbidden)
diff --git a/spec/bundler/support/artifice/endpoint_api_missing.rb b/spec/bundler/support/artifice/endpoint_api_missing.rb
deleted file mode 100644
index 755c42e836..0000000000
--- a/spec/bundler/support/artifice/endpoint_api_missing.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointApiMissing < Endpoint
- get "/fetch/actual/gem/:id" do
- warn params[:id]
- if params[:id] == "rack-1.0.gemspec.rz"
- halt 404
- else
- File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
- end
- end
-end
-
-Artifice.activate_with(EndpointApiMissing)
diff --git a/spec/bundler/support/artifice/endpoint_basic_authentication.rb b/spec/bundler/support/artifice/endpoint_basic_authentication.rb
deleted file mode 100644
index ff3d1493d6..0000000000
--- a/spec/bundler/support/artifice/endpoint_basic_authentication.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointBasicAuthentication < Endpoint
- before do
- unless env["HTTP_AUTHORIZATION"]
- halt 401, "Authentication info not supplied"
- end
- end
-end
-
-Artifice.activate_with(EndpointBasicAuthentication)
diff --git a/spec/bundler/support/artifice/endpoint_creds_diff_host.rb b/spec/bundler/support/artifice/endpoint_creds_diff_host.rb
deleted file mode 100644
index f20ef74ac6..0000000000
--- a/spec/bundler/support/artifice/endpoint_creds_diff_host.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointCredsDiffHost < Endpoint
- helpers do
- def auth
- @auth ||= Rack::Auth::Basic::Request.new(request.env)
- end
-
- def authorized?
- auth.provided? && auth.basic? && auth.credentials && auth.credentials == %w[user pass]
- end
-
- def protected!
- return if authorized?
- response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth")
- throw(:halt, [401, "Not authorized\n"])
- end
- end
-
- before do
- protected! unless request.path_info.include?("/no/creds/")
- end
-
- get "/gems/:id" do
- redirect "http://diffhost.com/no/creds/#{params[:id]}"
- end
-
- get "/no/creds/:id" do
- if request.host.include?("diffhost") && !auth.provided?
- File.read("#{gem_repo1}/gems/#{params[:id]}")
- end
- end
-end
-
-Artifice.activate_with(EndpointCredsDiffHost)
diff --git a/spec/bundler/support/artifice/endpoint_extra.rb b/spec/bundler/support/artifice/endpoint_extra.rb
deleted file mode 100644
index 31f6822161..0000000000
--- a/spec/bundler/support/artifice/endpoint_extra.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointExtra < Endpoint
- get "/extra/api/v1/dependencies" do
- halt 404
- end
-
- get "/extra/specs.4.8.gz" do
- File.read("#{gem_repo2}/specs.4.8.gz")
- end
-
- get "/extra/prerelease_specs.4.8.gz" do
- File.read("#{gem_repo2}/prerelease_specs.4.8.gz")
- end
-
- get "/extra/quick/Marshal.4.8/:id" do
- redirect "/extra/fetch/actual/gem/#{params[:id]}"
- end
-
- get "/extra/fetch/actual/gem/:id" do
- File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
- end
-
- get "/extra/gems/:id" do
- File.read("#{gem_repo2}/gems/#{params[:id]}")
- end
-end
-
-Artifice.activate_with(EndpointExtra)
diff --git a/spec/bundler/support/artifice/endpoint_extra_api.rb b/spec/bundler/support/artifice/endpoint_extra_api.rb
deleted file mode 100644
index 213b8e5895..0000000000
--- a/spec/bundler/support/artifice/endpoint_extra_api.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointExtraApi < Endpoint
- get "/extra/api/v1/dependencies" do
- deps = dependencies_for(params[:gems], gem_repo4)
- Marshal.dump(deps)
- end
-
- get "/extra/specs.4.8.gz" do
- File.read("#{gem_repo4}/specs.4.8.gz")
- end
-
- get "/extra/prerelease_specs.4.8.gz" do
- File.read("#{gem_repo4}/prerelease_specs.4.8.gz")
- end
-
- get "/extra/quick/Marshal.4.8/:id" do
- redirect "/extra/fetch/actual/gem/#{params[:id]}"
- end
-
- get "/extra/fetch/actual/gem/:id" do
- File.read("#{gem_repo4}/quick/Marshal.4.8/#{params[:id]}")
- end
-
- get "/extra/gems/:id" do
- File.read("#{gem_repo4}/gems/#{params[:id]}")
- end
-end
-
-Artifice.activate_with(EndpointExtraApi)
diff --git a/spec/bundler/support/artifice/endpoint_extra_missing.rb b/spec/bundler/support/artifice/endpoint_extra_missing.rb
deleted file mode 100644
index 5fd9238207..0000000000
--- a/spec/bundler/support/artifice/endpoint_extra_missing.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint_extra"
-
-Artifice.deactivate
-
-class EndpointExtraMissing < EndpointExtra
- get "/extra/fetch/actual/gem/:id" do
- if params[:id] == "missing-1.0.gemspec.rz"
- halt 404
- else
- File.binread("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
- end
- end
-end
-
-Artifice.activate_with(EndpointExtraMissing)
diff --git a/spec/bundler/support/artifice/endpoint_fallback.rb b/spec/bundler/support/artifice/endpoint_fallback.rb
deleted file mode 100644
index 08edf232e3..0000000000
--- a/spec/bundler/support/artifice/endpoint_fallback.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointFallback < Endpoint
- DEPENDENCY_LIMIT = 60
-
- get "/api/v1/dependencies" do
- if params[:gems] && params[:gems].size <= DEPENDENCY_LIMIT
- Marshal.dump(dependencies_for(params[:gems]))
- else
- halt 413, "Too many gems to resolve, please request less than #{DEPENDENCY_LIMIT} gems"
- end
- end
-end
-
-Artifice.activate_with(EndpointFallback)
diff --git a/spec/bundler/support/artifice/endpoint_host_redirect.rb b/spec/bundler/support/artifice/endpoint_host_redirect.rb
deleted file mode 100644
index 338cbcad00..0000000000
--- a/spec/bundler/support/artifice/endpoint_host_redirect.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointHostRedirect < Endpoint
- get "/fetch/actual/gem/:id", :host_name => "localgemserver.test" do
- redirect "http://bundler.localgemserver.test#{request.path_info}"
- end
-
- get "/api/v1/dependencies" do
- status 404
- end
-end
-
-Artifice.activate_with(EndpointHostRedirect)
diff --git a/spec/bundler/support/artifice/endpoint_marshal_fail.rb b/spec/bundler/support/artifice/endpoint_marshal_fail.rb
deleted file mode 100644
index 22c13e3e17..0000000000
--- a/spec/bundler/support/artifice/endpoint_marshal_fail.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint_fallback"
-
-Artifice.deactivate
-
-class EndpointMarshalFail < EndpointFallback
- get "/api/v1/dependencies" do
- "f0283y01hasf"
- end
-end
-
-Artifice.activate_with(EndpointMarshalFail)
diff --git a/spec/bundler/support/artifice/endpoint_mirror_source.rb b/spec/bundler/support/artifice/endpoint_mirror_source.rb
deleted file mode 100644
index 318866e420..0000000000
--- a/spec/bundler/support/artifice/endpoint_mirror_source.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-class EndpointMirrorSource < Endpoint
- get "/gems/:id" do
- if request.env["HTTP_X_GEMFILE_SOURCE"] == "https://server.example.org/"
- File.read("#{gem_repo1}/gems/#{params[:id]}")
- else
- halt 500
- end
- end
-end
-
-Artifice.activate_with(EndpointMirrorSource)
diff --git a/spec/bundler/support/artifice/endpoint_redirect.rb b/spec/bundler/support/artifice/endpoint_redirect.rb
deleted file mode 100644
index ee97fccf64..0000000000
--- a/spec/bundler/support/artifice/endpoint_redirect.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointRedirect < Endpoint
- get "/fetch/actual/gem/:id" do
- redirect "/fetch/actual/gem/#{params[:id]}"
- end
-
- get "/api/v1/dependencies" do
- status 404
- end
-end
-
-Artifice.activate_with(EndpointRedirect)
diff --git a/spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb b/spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb
deleted file mode 100644
index 4d4da08770..0000000000
--- a/spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint"
-
-Artifice.deactivate
-
-class EndpointStrictBasicAuthentication < Endpoint
- before do
- unless env["HTTP_AUTHORIZATION"]
- halt 401, "Authentication info not supplied"
- end
-
- # Only accepts password == "password"
- unless env["HTTP_AUTHORIZATION"] == "Basic dXNlcjpwYXNz"
- halt 403, "Authentication failed"
- end
- end
-end
-
-Artifice.activate_with(EndpointStrictBasicAuthentication)
diff --git a/spec/bundler/support/artifice/endpoint_timeout.rb b/spec/bundler/support/artifice/endpoint_timeout.rb
deleted file mode 100644
index c118da1893..0000000000
--- a/spec/bundler/support/artifice/endpoint_timeout.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "endpoint_fallback"
-
-Artifice.deactivate
-
-class EndpointTimeout < EndpointFallback
- SLEEP_TIMEOUT = 3
-
- get "/api/v1/dependencies" do
- sleep(SLEEP_TIMEOUT)
- end
-end
-
-Artifice.activate_with(EndpointTimeout)
diff --git a/spec/bundler/support/artifice/fail.rb b/spec/bundler/support/artifice/fail.rb
deleted file mode 100644
index 1059c6df4e..0000000000
--- a/spec/bundler/support/artifice/fail.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require "net/http"
-begin
- require "net/https"
-rescue LoadError
- nil # net/https or openssl
-end
-
-# We can't use artifice here because it uses rack
-
-module Artifice; end # for < 2.0, Net::HTTP::Persistent::SSLReuse
-
-class Fail < Net::HTTP
- # Net::HTTP uses a @newimpl instance variable to decide whether
- # to use a legacy implementation. Since we are subclassing
- # Net::HTTP, we must set it
- @newimpl = true
-
- def request(req, body = nil, &block)
- raise(exception(req))
- end
-
- # Ensure we don't start a connect here
- def connect
- end
-
- def exception(req)
- name = ENV.fetch("BUNDLER_SPEC_EXCEPTION") { "Errno::ENETUNREACH" }
- const = name.split("::").reduce(Object) {|mod, sym| mod.const_get(sym) }
- const.new("host down: Bundler spec artifice fail! #{req["PATH_INFO"]}")
- end
-end
-
-# Replace Net::HTTP with our failing subclass
-::Net.class_eval do
- remove_const(:HTTP)
- const_set(:HTTP, ::Fail)
-end
diff --git a/spec/bundler/support/artifice/vcr.rb b/spec/bundler/support/artifice/vcr.rb
deleted file mode 100644
index a46f8e9391..0000000000
--- a/spec/bundler/support/artifice/vcr.rb
+++ /dev/null
@@ -1,152 +0,0 @@
-# frozen_string_literal: true
-
-require "net/http"
-require_relative "../path"
-
-CASSETTE_PATH = "#{Spec::Path.spec_dir}/support/artifice/vcr_cassettes"
-CASSETTE_NAME = ENV.fetch("BUNDLER_SPEC_VCR_CASSETTE_NAME") { "realworld" }
-
-class BundlerVCRHTTP < Net::HTTP
- class RequestHandler
- attr_reader :http, :request, :body, :response_block
- def initialize(http, request, body = nil, &response_block)
- @http = http
- @request = request
- @body = body
- @response_block = response_block
- end
-
- def handle_request
- handler = self
- request.instance_eval do
- @__vcr_request_handler = handler
- end
-
- if recorded_response?
- recorded_response
- else
- record_response
- end
- end
-
- def recorded_response?
- return true if ENV["BUNDLER_SPEC_PRE_RECORDED"]
- return false if ENV["BUNDLER_SPEC_FORCE_RECORD"]
- request_pair_paths.all? {|f| File.exist?(f) }
- end
-
- def recorded_response
- File.open(request_pair_paths.last, "rb:ASCII-8BIT") do |response_file|
- response_io = ::Net::BufferedIO.new(response_file)
- ::Net::HTTPResponse.read_new(response_io).tap do |response|
- response.decode_content = request.decode_content if request.respond_to?(:decode_content)
- response.uri = request.uri if request.respond_to?(:uri)
-
- response.reading_body(response_io, request.response_body_permitted?) do
- response_block.call(response) if response_block
- end
- end
- end
- end
-
- def record_response
- request_path, response_path = *request_pair_paths
-
- @recording = true
-
- response = http.request_without_vcr(request, body, &response_block)
- @recording = false
- unless @recording
- FileUtils.mkdir_p(File.dirname(request_path))
- binwrite(request_path, request_to_string(request))
- binwrite(response_path, response_to_string(response))
- end
- response
- end
-
- def key
- [request["host"] || http.address, request.path, request.method].compact
- end
-
- def file_name_for_key(key)
- key.join("/").gsub(/[\:*?"<>|]/, "-")
- end
-
- def request_pair_paths
- %w[request response].map do |kind|
- File.join(CASSETTE_PATH, CASSETTE_NAME, file_name_for_key(key + [kind]))
- end
- end
-
- def read_stored_request(path)
- contents = File.read(path)
- headers = {}
- method = nil
- path = nil
- contents.lines.grep(/^> /).each do |line|
- if line =~ /^> (GET|HEAD|POST|PATCH|PUT|DELETE) (.*)/
- method = $1
- path = $2.strip
- elsif line =~ /^> (.*?): (.*)/
- headers[$1] = $2
- end
- end
- body = contents =~ /^([^>].*)/m && $1
- Net::HTTP.const_get(method.capitalize).new(path, headers).tap {|r| r.body = body if body }
- end
-
- def request_to_string(request)
- request_string = []
- request_string << "> #{request.method.upcase} #{request.path}"
- request.to_hash.each do |key, value|
- request_string << "> #{key}: #{Array(value).first}"
- end
- request << "" << request.body if request.body
- request_string.join("\n")
- end
-
- def response_to_string(response)
- headers = response.to_hash
- body = response.body
-
- response_string = []
- response_string << "HTTP/1.1 #{response.code} #{response.message}"
-
- headers["content-length"] = [body.bytesize.to_s] if body
-
- headers.each do |header, value|
- response_string << "#{header}: #{value.join(", ")}"
- end
-
- response_string << "" << body
-
- response_string = response_string.join("\n")
- if response_string.respond_to?(:force_encoding)
- response_string.force_encoding("ASCII-8BIT")
- else
- response_string
- end
- end
-
- def binwrite(path, contents)
- File.open(path, "wb:ASCII-8BIT") {|f| f.write(contents) }
- end
- end
-
- def request_with_vcr(request, *args, &block)
- handler = request.instance_eval do
- remove_instance_variable(:@__vcr_request_handler) if defined?(@__vcr_request_handler)
- end || RequestHandler.new(self, request, *args, &block)
-
- handler.handle_request
- end
-
- alias_method :request_without_vcr, :request
- alias_method :request, :request_with_vcr
-end
-
-# Replace Net::HTTP with our VCR subclass
-::Net.class_eval do
- remove_const(:HTTP)
- const_set(:HTTP, BundlerVCRHTTP)
-end
diff --git a/spec/bundler/support/artifice/windows.rb b/spec/bundler/support/artifice/windows.rb
deleted file mode 100644
index 21170c81d9..0000000000
--- a/spec/bundler/support/artifice/windows.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../path"
-include Spec::Path
-
-$LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra}-*/lib")].map(&:to_s))
-
-require "artifice"
-require "sinatra/base"
-
-Artifice.deactivate
-
-class Windows < Sinatra::Base
- set :raise_errors, true
- set :show_exceptions, false
-
- helpers do
- def gem_repo
- Pathname.new(ENV["BUNDLER_SPEC_GEM_REPO"] || Spec::Path.gem_repo1)
- end
- end
-
- files = ["specs.4.8.gz",
- "prerelease_specs.4.8.gz",
- "quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz",
- "gems/rcov-1.0-mswin32.gem"]
-
- files.each do |file|
- get "/#{file}" do
- File.binread gem_repo.join(file)
- end
- end
-
- get "/gems/rcov-1.0-x86-mswin32.gem" do
- halt 404
- end
-
- get "/api/v1/dependencies" do
- halt 404
- end
-
- get "/versions" do
- halt 500
- end
-end
-
-Artifice.activate_with(Windows)
diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb
deleted file mode 100644
index b3f5f9b876..0000000000
--- a/spec/bundler/support/builders.rb
+++ /dev/null
@@ -1,823 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/shared_helpers"
-require "shellwords"
-
-module Spec
- module Builders
- def self.constantize(name)
- name.delete("-").upcase
- end
-
- def v(version)
- Gem::Version.new(version)
- end
-
- def pl(platform)
- Gem::Platform.new(platform)
- end
-
- def build_repo1
- build_repo gem_repo1 do
- build_gem "rack", %w[0.9.1 1.0.0] do |s|
- s.executables = "rackup"
- s.post_install_message = "Rack's post install message"
- end
-
- build_gem "thin" do |s|
- s.add_dependency "rack"
- s.post_install_message = "Thin's post install message"
- end
-
- build_gem "rack-obama" do |s|
- s.add_dependency "rack"
- s.post_install_message = "Rack-obama's post install message"
- end
-
- build_gem "rack_middleware", "1.0" do |s|
- s.add_dependency "rack", "0.9.1"
- end
-
- build_gem "rails", "2.3.2" do |s|
- s.executables = "rails"
- s.add_dependency "rake", "12.3.2"
- s.add_dependency "actionpack", "2.3.2"
- s.add_dependency "activerecord", "2.3.2"
- s.add_dependency "actionmailer", "2.3.2"
- s.add_dependency "activeresource", "2.3.2"
- end
- build_gem "actionpack", "2.3.2" do |s|
- s.add_dependency "activesupport", "2.3.2"
- end
- build_gem "activerecord", ["2.3.1", "2.3.2"] do |s|
- s.add_dependency "activesupport", "2.3.2"
- end
- build_gem "actionmailer", "2.3.2" do |s|
- s.add_dependency "activesupport", "2.3.2"
- end
- build_gem "activeresource", "2.3.2" do |s|
- s.add_dependency "activesupport", "2.3.2"
- end
- build_gem "activesupport", %w[1.2.3 2.3.2 2.3.5]
-
- build_gem "activemerchant" do |s|
- s.add_dependency "activesupport", ">= 2.0.0"
- end
-
- build_gem "rails_fail" do |s|
- s.add_dependency "activesupport", "= 1.2.3"
- end
-
- build_gem "missing_dep" do |s|
- s.add_dependency "not_here"
- end
-
- build_gem "rspec", "1.2.7", :no_default => true do |s|
- s.write "lib/spec.rb", "SPEC = '1.2.7'"
- end
-
- build_gem "rack-test", :no_default => true do |s|
- s.write "lib/rack/test.rb", "RACK_TEST = '1.0'"
- end
-
- build_gem "platform_specific" do |s|
- s.platform = Bundler.local_platform
- s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'"
- end
-
- build_gem "platform_specific" do |s|
- s.platform = "java"
- s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 JAVA'"
- end
-
- build_gem "platform_specific" do |s|
- s.platform = "ruby"
- s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'"
- end
-
- build_gem "platform_specific" do |s|
- s.platform = "x86-mswin32"
- s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 MSWIN'"
- end
-
- build_gem "platform_specific" do |s|
- s.platform = "x86-mingw32"
- end
-
- build_gem "platform_specific" do |s|
- s.platform = "x64-mingw32"
- end
-
- build_gem "platform_specific" do |s|
- s.platform = "x86-darwin-100"
- s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 x86-darwin-100'"
- end
-
- build_gem "only_java", "1.0" do |s|
- s.platform = "java"
- s.write "lib/only_java.rb", "ONLY_JAVA = '1.0.0 JAVA'"
- end
-
- build_gem "only_java", "1.1" do |s|
- s.platform = "java"
- s.write "lib/only_java.rb", "ONLY_JAVA = '1.1.0 JAVA'"
- end
-
- build_gem "nokogiri", "1.4.2"
- build_gem "nokogiri", "1.4.2" do |s|
- s.platform = "java"
- s.write "lib/nokogiri.rb", "NOKOGIRI = '1.4.2 JAVA'"
- s.add_dependency "weakling", ">= 0.0.3"
- end
-
- build_gem "laduradura", "5.15.2"
- build_gem "laduradura", "5.15.2" do |s|
- s.platform = "java"
- s.write "lib/laduradura.rb", "LADURADURA = '5.15.2 JAVA'"
- end
- build_gem "laduradura", "5.15.3" do |s|
- s.platform = "java"
- s.write "lib/laduradura.rb", "LADURADURA = '5.15.2 JAVA'"
- end
-
- build_gem "weakling", "0.0.3"
-
- build_gem "terranova", "8"
-
- build_gem "duradura", "7.0"
-
- build_gem "multiple_versioned_deps" do |s|
- s.add_dependency "weakling", ">= 0.0.1", "< 0.1"
- end
-
- build_gem "not_released", "1.0.pre"
-
- build_gem "has_prerelease", "1.0"
- build_gem "has_prerelease", "1.1.pre"
-
- build_gem "with_development_dependency" do |s|
- s.add_development_dependency "activesupport", "= 2.3.5"
- end
-
- build_gem "with_license" do |s|
- s.license = "MIT"
- end
-
- build_gem "with_implicit_rake_dep" do |s|
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- path = File.expand_path("../lib", __FILE__)
- FileUtils.mkdir_p(path)
- File.open("\#{path}/implicit_rake_dep.rb", "w") do |f|
- f.puts "IMPLICIT_RAKE_DEP = 'YES'"
- end
- end
- RUBY
- end
-
- build_gem "another_implicit_rake_dep" do |s|
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- path = File.expand_path("../lib", __FILE__)
- FileUtils.mkdir_p(path)
- File.open("\#{path}/another_implicit_rake_dep.rb", "w") do |f|
- f.puts "ANOTHER_IMPLICIT_RAKE_DEP = 'YES'"
- end
- end
- RUBY
- end
-
- build_gem "very_simple_binary", &:add_c_extension
- build_gem "simple_binary", &:add_c_extension
-
- build_gem "bundler", "0.9" do |s|
- s.executables = "bundle"
- s.write "bin/bundle", "puts 'FAIL'"
- end
-
- # The bundler 0.8 gem has a rubygems plugin that always loads :(
- build_gem "bundler", "0.8.1" do |s|
- s.write "lib/bundler/omg.rb", ""
- s.write "lib/rubygems_plugin.rb", "require 'bundler/omg' ; puts 'FAIL'"
- end
-
- build_gem "bundler_dep" do |s|
- s.add_dependency "bundler"
- end
-
- # The yard gem iterates over Gem.source_index looking for plugins
- build_gem "yard" do |s|
- s.write "lib/yard.rb", <<-Y
- Gem::Specification.sort_by(&:name).each do |gem|
- puts gem.full_name
- end
- Y
- end
-
- # The rcov gem is platform mswin32, but has no arch
- build_gem "rcov" do |s|
- s.platform = Gem::Platform.new([nil, "mswin32", nil])
- s.write "lib/rcov.rb", "RCOV = '1.0.0'"
- end
-
- build_gem "net-ssh"
- build_gem "net-sftp", "1.1.1" do |s|
- s.add_dependency "net-ssh", ">= 1.0.0", "< 1.99.0"
- end
-
- # Test complicated gem dependencies for install
- build_gem "net_a" do |s|
- s.add_dependency "net_b"
- s.add_dependency "net_build_extensions"
- end
-
- build_gem "net_b"
-
- build_gem "net_build_extensions" do |s|
- s.add_dependency "rake"
- s.extensions << "Rakefile"
- s.write "Rakefile", <<-RUBY
- task :default do
- path = File.expand_path("../lib", __FILE__)
- FileUtils.mkdir_p(path)
- File.open("\#{path}/net_build_extensions.rb", "w") do |f|
- f.puts "NET_BUILD_EXTENSIONS = 'YES'"
- end
- end
- RUBY
- end
-
- build_gem "net_c" do |s|
- s.add_dependency "net_a"
- s.add_dependency "net_d"
- end
-
- build_gem "net_d"
-
- build_gem "net_e" do |s|
- s.add_dependency "net_d"
- end
-
- # Capistrano did this (at least until version 2.5.10)
- # RubyGems 2.2 doesn't allow the specifying of a dependency twice
- # See https://github.com/rubygems/rubygems/commit/03dbac93a3396a80db258d9bc63500333c25bd2f
- build_gem "double_deps", "1.0", :skip_validation => true do |s|
- s.add_dependency "net-ssh", ">= 1.0.0"
- s.add_dependency "net-ssh"
- end
-
- build_gem "foo"
-
- # A minimal fake pry console
- build_gem "pry" do |s|
- s.write "lib/pry.rb", <<-RUBY
- class Pry
- class << self
- def toplevel_binding
- unless defined?(@toplevel_binding) && @toplevel_binding
- TOPLEVEL_BINDING.eval %{
- def self.__pry__; binding; end
- Pry.instance_variable_set(:@toplevel_binding, __pry__)
- class << self; undef __pry__; end
- }
- end
- @toplevel_binding.eval('private')
- @toplevel_binding
- end
-
- def __pry__
- while line = gets
- begin
- puts eval(line, toplevel_binding).inspect.sub(/^"(.*)"$/, '=> \\1')
- rescue Exception => e
- puts "\#{e.class}: \#{e.message}"
- puts e.backtrace.first
- end
- end
- end
- alias start __pry__
- end
- end
- RUBY
- end
- end
- end
-
- def build_repo2(&blk)
- FileUtils.rm_rf gem_repo2
- FileUtils.cp_r gem_repo1, gem_repo2
- update_repo2(&blk) if block_given?
- end
-
- def build_repo3
- build_repo gem_repo3 do
- build_gem "rack"
- end
- FileUtils.rm_rf Dir[gem_repo3("prerelease*")]
- end
-
- # A repo that has no pre-installed gems included. (The caller completely
- # determines the contents with the block.)
- def build_repo4(&blk)
- FileUtils.rm_rf gem_repo4
- build_repo(gem_repo4, &blk)
- end
-
- def update_repo4(&blk)
- update_repo(gem_repo4, &blk)
- end
-
- def update_repo2
- update_repo gem_repo2 do
- build_gem "rack", "1.2" do |s|
- s.executables = "rackup"
- end
- yield if block_given?
- end
- end
-
- def build_security_repo
- build_repo security_repo do
- build_gem "rack"
-
- build_gem "signed_gem" do |s|
- cert = "signing-cert.pem"
- pkey = "signing-pkey.pem"
- s.write cert, TEST_CERT
- s.write pkey, TEST_PKEY
- s.signing_key = pkey
- s.cert_chain = [cert]
- end
- end
- end
-
- def build_repo(path, &blk)
- return if File.directory?(path)
- rake_path = Dir["#{Path.base_system_gems}/**/rake*.gem"].first
-
- if rake_path.nil?
- Spec::Path.base_system_gems.rmtree
- Spec::Rubygems.setup
- rake_path = Dir["#{Path.base_system_gems}/**/rake*.gem"].first
- end
-
- if rake_path
- FileUtils.mkdir_p("#{path}/gems")
- FileUtils.cp rake_path, "#{path}/gems/"
- else
- abort "Your test gems are missing! Run `rm -rf #{tmp}` and try again."
- end
-
- update_repo(path, &blk)
- end
-
- def update_repo(path)
- if path == gem_repo1 && caller.first.split(" ").last == "`build_repo`"
- raise "Updating gem_repo1 is unsupported -- use gem_repo2 instead"
- end
- return unless block_given?
- @_build_path = "#{path}/gems"
- @_build_repo = File.basename(path)
- yield
- with_gem_path_as Path.base_system_gems do
- Dir.chdir(path) { gem_command! :generate_index }
- end
- ensure
- @_build_path = nil
- @_build_repo = nil
- end
-
- def build_index(&block)
- index = Bundler::Index.new
- IndexBuilder.run(index, &block) if block_given?
- index
- end
-
- def build_spec(name, version = "0.0.1", platform = nil, &block)
- Array(version).map do |v|
- Gem::Specification.new do |s|
- s.name = name
- s.version = Gem::Version.new(v)
- s.platform = platform
- s.authors = ["no one in particular"]
- s.summary = "a gemspec used only for testing"
- DepBuilder.run(s, &block) if block_given?
- end
- end
- end
-
- def build_dep(name, requirements = Gem::Requirement.default, type = :runtime)
- Bundler::Dependency.new(name, :version => requirements)
- end
-
- def build_lib(name, *args, &blk)
- build_with(LibBuilder, name, args, &blk)
- end
-
- def build_gem(name, *args, &blk)
- build_with(GemBuilder, name, args, &blk)
- end
-
- def build_git(name, *args, &block)
- opts = args.last.is_a?(Hash) ? args.last : {}
- builder = opts[:bare] ? GitBareBuilder : GitBuilder
- spec = build_with(builder, name, args, &block)
- GitReader.new(opts[:path] || lib_path(spec.full_name))
- end
-
- def update_git(name, *args, &block)
- opts = args.last.is_a?(Hash) ? args.last : {}
- spec = build_with(GitUpdater, name, args, &block)
- GitReader.new(opts[:path] || lib_path(spec.full_name))
- end
-
- def build_plugin(name, *args, &blk)
- build_with(PluginBuilder, name, args, &blk)
- end
-
- private
-
- def build_with(builder, name, args, &blk)
- @_build_path ||= nil
- @_build_repo ||= nil
- options = args.last.is_a?(Hash) ? args.pop : {}
- versions = args.last || "1.0"
- spec = nil
-
- options[:path] ||= @_build_path
- options[:source] ||= @_build_repo
-
- Array(versions).each do |version|
- spec = builder.new(self, name, version)
- spec.authors = ["no one"] if !spec.authors || spec.authors.empty?
- yield spec if block_given?
- spec._build(options)
- end
-
- spec
- end
-
- class IndexBuilder
- include Builders
-
- def self.run(index, &block)
- new(index).run(&block)
- end
-
- def initialize(index)
- @index = index
- end
-
- def run(&block)
- instance_eval(&block)
- end
-
- def gem(*args, &block)
- build_spec(*args, &block).each do |s|
- @index << s
- end
- end
-
- def platforms(platforms)
- platforms.split(/\s+/).each do |platform|
- platform.gsub!(/^(mswin32)$/, 'x86-\1')
- yield Gem::Platform.new(platform)
- end
- end
-
- def versions(versions)
- versions.split(/\s+/).each {|version| yield v(version) }
- end
- end
-
- class DepBuilder
- include Builders
-
- def self.run(spec, &block)
- new(spec).run(&block)
- end
-
- def initialize(spec)
- @spec = spec
- end
-
- def run(&block)
- instance_eval(&block)
- end
-
- def runtime(name, requirements)
- @spec.add_runtime_dependency(name, requirements)
- end
-
- def development(name, requirements)
- @spec.add_development_dependency(name, requirements)
- end
-
- def required_ruby_version=(*reqs)
- @spec.required_ruby_version = *reqs
- end
-
- alias_method :dep, :runtime
- end
-
- class LibBuilder
- def initialize(context, name, version)
- @context = context
- @name = name
- @spec = Gem::Specification.new do |s|
- s.name = name
- s.version = version
- s.summary = "This is just a fake gem for testing"
- s.description = "This is a completely fake gem, for testing purposes."
- s.author = "no one"
- s.email = "foo@bar.baz"
- s.homepage = "http://example.com"
- s.license = "MIT"
- end
- @files = {}
- end
-
- def method_missing(*args, &blk)
- @spec.send(*args, &blk)
- end
-
- def write(file, source = "")
- @files[file] = source
- end
-
- def executables=(val)
- @spec.executables = Array(val)
- @spec.executables.each do |file|
- executable = "#{@spec.bindir}/#{file}"
- shebang = if Bundler.current_ruby.jruby?
- "#!/usr/bin/env jruby\n"
- else
- "#!/usr/bin/env ruby\n"
- end
- @spec.files << executable
- write executable, "#{shebang}require_relative '../lib/#{@name}' ; puts #{Builders.constantize(@name)}"
- end
- end
-
- def add_c_extension
- require_paths << "ext"
- extensions << "ext/extconf.rb"
- write "ext/extconf.rb", <<-RUBY
- require "mkmf"
-
-
- # exit 1 unless with_config("simple")
-
- extension_name = "#{name}_c"
- if extra_lib_dir = with_config("ext-lib")
- # add extra libpath if --with-ext-lib is
- # passed in as a build_arg
- dir_config extension_name, nil, extra_lib_dir
- else
- dir_config extension_name
- end
- create_makefile extension_name
- RUBY
- write "ext/#{name}.c", <<-C
- #include "ruby.h"
-
- void Init_#{name}_c() {
- rb_define_module("#{Builders.constantize(name)}_IN_C");
- }
- C
- end
-
- def _build(options)
- path = options[:path] || _default_path
-
- if options[:rubygems_version]
- @spec.rubygems_version = options[:rubygems_version]
- def @spec.mark_version; end
-
- def @spec.validate(*); end
- end
-
- case options[:gemspec]
- when false
- # do nothing
- when :yaml
- @files["#{name}.gemspec"] = @spec.to_yaml
- else
- @files["#{name}.gemspec"] = @spec.to_ruby
- end
-
- unless options[:no_default]
- gem_source = options[:source] || "path@#{path}"
- @files = _default_files.
- merge("lib/#{entrypoint}/source.rb" => "#{Builders.constantize(name)}_SOURCE = #{gem_source.to_s.dump}").
- merge(@files)
- end
-
- @spec.authors = ["no one"]
-
- @files.each do |file, source|
- file = Pathname.new(path).join(file)
- FileUtils.mkdir_p(file.dirname)
- File.open(file, "w") {|f| f.puts source }
- end
- @spec.files = @files.keys
- path
- end
-
- def _default_files
- @_default_files ||= { "lib/#{entrypoint}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'" }
- end
-
- def entrypoint
- name.tr("-", "/")
- end
-
- def _default_path
- @context.tmp("libs", @spec.full_name)
- end
-
- def platform_string
- " #{@spec.platform}" unless @spec.platform == Gem::Platform::RUBY
- end
- end
-
- class GitBuilder < LibBuilder
- def _build(options)
- path = options[:path] || _default_path
- source = options[:source] || "git@#{path}"
- super(options.merge(:path => path, :source => source))
- Dir.chdir(path) do
- `git init`
- `git add *`
- `git config user.email "lol@wut.com"`
- `git config user.name "lolwut"`
- `git config commit.gpgsign false`
- `git commit -m "OMG INITIAL COMMIT"`
- end
- end
- end
-
- class GitBareBuilder < LibBuilder
- def _build(options)
- path = options[:path] || _default_path
- super(options.merge(:path => path))
- Dir.chdir(path) do
- `git init --bare`
- end
- end
- end
-
- class GitUpdater < LibBuilder
- def silently(str)
- `#{str} 2>#{Bundler::NULL}`
- end
-
- def _build(options)
- libpath = options[:path] || _default_path
- update_gemspec = options[:gemspec] || false
- source = options[:source] || "git@#{libpath}"
-
- Dir.chdir(libpath) do
- silently "git checkout master"
-
- if branch = options[:branch]
- raise "You can't specify `master` as the branch" if branch == "master"
- escaped_branch = Shellwords.shellescape(branch)
-
- if `git branch | grep #{escaped_branch}`.empty?
- silently("git branch #{escaped_branch}")
- end
-
- silently("git checkout #{escaped_branch}")
- elsif tag = options[:tag]
- `git tag #{Shellwords.shellescape(tag)}`
- elsif options[:remote]
- silently("git remote add origin #{options[:remote]}")
- elsif options[:push]
- silently("git push origin #{options[:push]}")
- end
-
- current_ref = `git rev-parse HEAD`.strip
- _default_files.keys.each do |path|
- _default_files[path] += "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
- end
- super(options.merge(:path => libpath, :gemspec => update_gemspec, :source => source))
- `git add *`
- `git commit -m "BUMP"`
- end
- end
- end
-
- class GitReader
- attr_reader :path
-
- def initialize(path)
- @path = path
- end
-
- def ref_for(ref, len = nil)
- ref = git "rev-parse #{ref}"
- ref = ref[0..len] if len
- ref
- end
-
- private
-
- def git(cmd)
- Bundler::SharedHelpers.with_clean_git_env do
- Dir.chdir(@path) { `git #{cmd}`.strip }
- end
- end
- end
-
- class GemBuilder < LibBuilder
- def _build(opts)
- lib_path = super(opts.merge(:path => @context.tmp(".tmp/#{@spec.full_name}"), :no_default => opts[:no_default]))
- destination = opts[:path] || _default_path
- Dir.chdir(lib_path) do
- FileUtils.mkdir_p(destination)
-
- @spec.authors = ["that guy"] if !@spec.authors || @spec.authors.empty?
-
- Bundler.rubygems.build(@spec, opts[:skip_validation])
- end
- gem_path = File.expand_path("#{@spec.full_name}.gem", lib_path)
- if opts[:to_system]
- @context.system_gems gem_path, :keep_path => true
- elsif opts[:to_bundle]
- @context.system_gems gem_path, :path => :bundle_path, :keep_path => true
- else
- FileUtils.mv(gem_path, destination)
- end
- end
-
- def _default_path
- @context.gem_repo1("gems")
- end
- end
-
- class PluginBuilder < GemBuilder
- def _default_files
- @_default_files ||= {
- "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'",
- "plugins.rb" => "",
- }
- end
- end
-
- TEST_CERT = <<-CERT.gsub(/^\s*/, "")
- -----BEGIN CERTIFICATE-----
- MIIDMjCCAhqgAwIBAgIBATANBgkqhkiG9w0BAQUFADAnMQwwCgYDVQQDDAN5b3Ux
- FzAVBgoJkiaJk/IsZAEZFgdleGFtcGxlMB4XDTE1MDIwODAwMTIyM1oXDTQyMDYy
- NTAwMTIyM1owJzEMMAoGA1UEAwwDeW91MRcwFQYKCZImiZPyLGQBGRYHZXhhbXBs
- ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANlvFdpN43c4DMS9Jo06
- m0a7k3bQ3HWQ1yrYhZMi77F1F73NpBknYHIzDktQpGn6hs/4QFJT4m4zNEBF47UL
- jHU5nTK5rjkS3niGYUjvh3ZEzVeo9zHUlD/UwflDo4ALl3TSo2KY/KdPS/UTdLXL
- ajkQvaVJtEDgBPE3DPhlj5whp+Ik3mDHej7qpV6F502leAwYaFyOtlEG/ZGNG+nZ
- L0clH0j77HpP42AylHDi+vakEM3xcjo9BeWQ6Vkboic93c9RTt6CWBWxMQP7Nol1
- MOebz9XOSQclxpxWteXNfPRtMdAhmRl76SMI8ywzThNPpa4EH/yz34ftebVOgKyM
- nd0CAwEAAaNpMGcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFA7D
- n9qo0np23qi3aOYuAAPn/5IdMBYGA1UdEQQPMA2BC3lvdUBleGFtcGxlMBYGA1Ud
- EgQPMA2BC3lvdUBleGFtcGxlMA0GCSqGSIb3DQEBBQUAA4IBAQA7Gyk62sWOUX/N
- vk4tJrgKESph6Ns8+E36A7n3jt8zCep8ldzMvwTWquf9iqhsC68FilEoaDnUlWw7
- d6oNuaFkv7zfrWGLlvqQJC+cu2X5EpcCksg5oRp8VNbwJysJ6JgwosxzROII8eXc
- R+j1j6mDvQYqig2QOnzf480pjaqbP+tspfDFZbhKPrgM3Blrb3ZYuFpv4zkqI7aB
- 6fuk2DUhNO1CuwrJA84TqC+jGo73bDKaT5hrIDiaJRrN5+zcWja2uEWrj5jSbep4
- oXdEdyH73hOHMBP40uds3PqnUsxEJhzjB2sCCe1geV24kw9J4m7EQXPVkUKDgKrt
- LlpDmOoo
- -----END CERTIFICATE-----
- CERT
-
- TEST_PKEY = <<-PKEY.gsub(/^\s*/, "")
- -----BEGIN RSA PRIVATE KEY-----
- MIIEowIBAAKCAQEA2W8V2k3jdzgMxL0mjTqbRruTdtDcdZDXKtiFkyLvsXUXvc2k
- GSdgcjMOS1CkafqGz/hAUlPibjM0QEXjtQuMdTmdMrmuORLeeIZhSO+HdkTNV6j3
- MdSUP9TB+UOjgAuXdNKjYpj8p09L9RN0tctqORC9pUm0QOAE8TcM+GWPnCGn4iTe
- YMd6PuqlXoXnTaV4DBhoXI62UQb9kY0b6dkvRyUfSPvsek/jYDKUcOL69qQQzfFy
- Oj0F5ZDpWRuiJz3dz1FO3oJYFbExA/s2iXUw55vP1c5JByXGnFa15c189G0x0CGZ
- GXvpIwjzLDNOE0+lrgQf/LPfh+15tU6ArIyd3QIDAQABAoIBACbDqz20TS1gDMa2
- gj0DidNedbflHKjJHdNBru7Ad8NHgOgR1YO2hXdWquG6itVqGMbTF4SV9/R1pIcg
- 7qvEV1I+50u31tvOBWOvcYCzU48+TO2n7gowQA3xPHPYHzog1uu48fAOHl0lwgD7
- av9OOK3b0jO5pC08wyTOD73pPWU0NrkTh2+N364leIi1pNuI1z4V+nEuIIm7XpVd
- 5V4sXidMTiEMJwE6baEDfTjHKaoRndXrrPo3ryIXmcX7Ag1SwAQwF5fBCRToCgIx
- dszEZB1bJD5gA6r+eGnJLB/F60nK607az5o3EdguoB2LKa6q6krpaRCmZU5svvoF
- J7xgBPECgYEA8RIzHAQ3zbaibKdnllBLIgsqGdSzebTLKheFuigRotEV3Or/z5Lg
- k/nVnThWVkTOSRqXTNpJAME6a4KTdcVSxYP+SdZVO1esazHrGb7xPVb7MWSE1cqp
- WEk3Yy8OUOPoPQMc4dyGzd30Mi8IBB6gnFIYOTrpUo0XtkBv8rGGhfsCgYEA5uYn
- 6QgL4NqNT84IXylmMb5ia3iBt6lhxI/A28CDtQvfScl4eYK0IjBwdfG6E1vJgyzg
- nJzv3xEVo9bz+Kq7CcThWpK5JQaPnsV0Q74Wjk0ShHet15txOdJuKImnh5F6lylC
- GTLR9gnptytfMH/uuw4ws0Q2kcg4l5NHKOWOnAcCgYEAvAwIVkhsB0n59Wu4gCZu
- FUZENxYWUk/XUyQ6KnZrG2ih90xQ8+iMyqFOIm/52R2fFKNrdoWoALC6E3ct8+ZS
- pMRLrelFXx8K3it4SwMJR2H8XBEfFW4bH0UtsW7Zafv+AunUs9LETP5gKG1LgXsq
- qgXX43yy2LQ61O365YPZfdUCgYBVbTvA3MhARbvYldrFEnUL3GtfZbNgdxuD9Mee
- xig0eJMBIrgfBLuOlqtVB70XYnM4xAbKCso4loKSHnofO1N99siFkRlM2JOUY2tz
- kMWZmmxKdFjuF0WZ5f/5oYxI/QsFGC+rUQEbbWl56mMKd5qkvEhKWudxoklF0yiV
- ufC8SwKBgDWb8iWqWN5a/kfvKoxFcDM74UHk/SeKMGAL+ujKLf58F+CbweM5pX9C
- EUsxeoUEraVWTiyFVNqD81rCdceus9TdBj0ZIK1vUttaRZyrMAwF0uQSfjtxsOpd
- l69BkyvzjgDPkmOHVGiSZDLi3YDvypbUpo6LOy4v5rVg5U2F/A0v
- -----END RSA PRIVATE KEY-----
- PKEY
- end
-end
diff --git a/spec/bundler/support/command_execution.rb b/spec/bundler/support/command_execution.rb
deleted file mode 100644
index b3c289979f..0000000000
--- a/spec/bundler/support/command_execution.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-module Spec
- CommandExecution = Struct.new(:command, :working_directory, :exitstatus, :stdout, :stderr) do
- def to_s
- c = Shellwords.shellsplit(command.strip).map {|s| s.include?("\n") ? " \\\n <<EOS\n#{s.gsub(/^/, " ").chomp}\nEOS" : Shellwords.shellescape(s) }
- c = c.reduce("") do |acc, elem|
- concat = acc + " " + elem
-
- last_line = concat.match(/.*\z/)[0]
- if last_line.size >= 100
- acc + " \\\n " + elem
- else
- concat
- end
- end
- "$ #{c.strip}"
- end
- alias_method :inspect, :to_s
-
- def stdboth
- @stdboth ||= [stderr, stdout].join("\n").strip
- end
-
- def to_s_verbose
- [
- to_s,
- stdout,
- stderr,
- exitstatus ? "# $? => #{exitstatus}" : "",
- ].reject(&:empty?).join("\n")
- end
-
- def success?
- return true unless exitstatus
- exitstatus == 0
- end
-
- def failure?
- return true unless exitstatus
- exitstatus > 0
- end
- end
-end
diff --git a/spec/bundler/support/filters.rb b/spec/bundler/support/filters.rb
deleted file mode 100644
index 4ce6648cdc..0000000000
--- a/spec/bundler/support/filters.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "sudo"
-
-class RequirementChecker < Proc
- def self.against(present)
- provided = Gem::Version.new(present)
-
- new do |required|
- !Gem::Requirement.new(required).satisfied_by?(provided)
- end.tap do |checker|
- checker.provided = provided
- end
- end
-
- attr_accessor :provided
-
- def inspect
- "\"!= #{provided}\""
- end
-end
-
-RSpec.configure do |config|
- if ENV["BUNDLER_SUDO_TESTS"] && Spec::Sudo.present?
- config.filter_run :sudo => true
- else
- config.filter_run_excluding :sudo => true
- end
-
- if ENV["BUNDLER_REALWORLD_TESTS"]
- config.filter_run :realworld => true
- else
- config.filter_run_excluding :realworld => true
- end
-
- git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version
-
- config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION)
- config.filter_run_excluding :git => RequirementChecker.against(git_version)
- config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
- config.filter_run_excluding :ruby_repo => !ENV["GEM_COMMAND"].nil?
- config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil?
-
- config.filter_run_when_matching :focus unless ENV["CI"]
-end
diff --git a/spec/bundler/support/hax.rb b/spec/bundler/support/hax.rb
deleted file mode 100644
index c18470acd2..0000000000
--- a/spec/bundler/support/hax.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# frozen_string_literal: true
-
-module Gem
- def self.ruby=(ruby)
- @ruby = ruby
- end
-
- if ENV["RUBY"]
- Gem.ruby = ENV["RUBY"]
- end
-
- if version = ENV["BUNDLER_SPEC_RUBYGEMS_VERSION"]
- remove_const(:VERSION) if const_defined?(:VERSION)
- VERSION = version
- end
-
- class Platform
- @local = new(ENV["BUNDLER_SPEC_PLATFORM"]) if ENV["BUNDLER_SPEC_PLATFORM"]
- end
- @platforms = [Gem::Platform::RUBY, Gem::Platform.local]
-
- # We only need this hack for rubygems versions without the BundlerVersionFinder
- if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0") || ENV["BUNDLER_SPEC_DISABLE_DEFAULT_BUNDLER_GEM"]
- @path_to_default_spec_map.delete_if do |_path, spec|
- spec.name == "bundler"
- end
- end
-end
-
-if ENV["BUNDLER_SPEC_VERSION"]
- require_relative "path"
- require "#{Spec::Path.lib_dir}/bundler/version"
-
- module Bundler
- remove_const(:VERSION) if const_defined?(:VERSION)
- VERSION = ENV["BUNDLER_SPEC_VERSION"].dup
- end
-end
-
-if ENV["BUNDLER_SPEC_WINDOWS"] == "true"
- require_relative "path"
- require "#{Spec::Path.lib_dir}/bundler/constants"
-
- module Bundler
- remove_const :WINDOWS if defined?(WINDOWS)
- WINDOWS = true
- end
-end
-
-class Object
- if ENV["BUNDLER_SPEC_RUBY_ENGINE"]
- if RUBY_ENGINE != "jruby" && ENV["BUNDLER_SPEC_RUBY_ENGINE"] == "jruby"
- begin
- # this has to be done up front because psych will try to load a .jar
- # if it thinks its on jruby
- require "psych"
- rescue LoadError
- nil
- end
- end
-
- remove_const :RUBY_ENGINE
- RUBY_ENGINE = ENV["BUNDLER_SPEC_RUBY_ENGINE"]
-
- remove_const :RUBY_ENGINE_VERSION
- RUBY_ENGINE_VERSION = ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
- end
-end
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
deleted file mode 100644
index e9c9e766cf..0000000000
--- a/spec/bundler/support/helpers.rb
+++ /dev/null
@@ -1,587 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "command_execution"
-require_relative "the_bundle"
-
-module Spec
- module Helpers
- def reset!
- Dir.glob("#{tmp}/{gems/*,*}", File::FNM_DOTMATCH).each do |dir|
- next if %w[base remote1 gems rubygems . ..].include?(File.basename(dir))
- if ENV["BUNDLER_SUDO_TESTS"]
- `sudo rm -rf "#{dir}"`
- else
- FileUtils.rm_rf(dir)
- end
- end
- FileUtils.mkdir_p(home)
- FileUtils.mkdir_p(tmpdir)
- Bundler.reset!
- end
-
- def self.bang(method)
- define_method("#{method}!") do |*args, &blk|
- send(method, *args, &blk).tap do
- unless last_command.success?
- raise "Invoking #{method}!(#{args.map(&:inspect).join(", ")}) failed:\n#{last_command.stdboth}"
- end
- end
- end
- end
-
- def the_bundle(*args)
- TheBundle.new(*args)
- end
-
- def last_command
- @command_executions.last || raise("There is no last command")
- end
-
- def out
- last_command.stdout
- end
-
- def err
- last_command.stderr
- end
-
- MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/.freeze
-
- def err_without_deprecations
- err.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "")
- end
-
- def deprecations
- err.split("\n").select {|l| l =~ MAJOR_DEPRECATION }.join("\n").split(MAJOR_DEPRECATION)
- end
-
- def exitstatus
- last_command.exitstatus
- end
-
- def in_app_root(&blk)
- Dir.chdir(bundled_app, &blk)
- end
-
- def in_app_root2(&blk)
- Dir.chdir(bundled_app2, &blk)
- end
-
- def in_app_root_custom(root, &blk)
- Dir.chdir(root, &blk)
- end
-
- def run(cmd, *args)
- opts = args.last.is_a?(Hash) ? args.pop : {}
- groups = args.map(&:inspect).join(", ")
- setup = "require '#{lib_dir}/bundler' ; Bundler.ui.silence { Bundler.setup(#{groups}) }\n"
- ruby(setup + cmd, opts)
- end
- bang :run
-
- def load_error_run(ruby, name, *args)
- cmd = <<-RUBY
- begin
- #{ruby}
- rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR" if e.message.include?("-- #{name}")
- end
- RUBY
- opts = args.last.is_a?(Hash) ? args.pop : {}
- args += [opts]
- run(cmd, *args)
- end
-
- def bundle(cmd, options = {})
- with_sudo = options.delete(:sudo)
- sudo = with_sudo == :preserve_env ? "sudo -E" : "sudo" if with_sudo
-
- bundle_bin = options.delete("bundle_bin") || bindir.join("bundle")
-
- if system_bundler = options.delete(:system_bundler)
- bundle_bin = system_gem_path.join("bin/bundler")
- end
-
- env = options.delete(:env) || {}
- env["PATH"].gsub!("#{Path.root}/exe", "") if env["PATH"] && system_bundler
-
- requires = options.delete(:requires) || []
- requires << "support/hax"
-
- artifice = options.delete(:artifice) do
- if RSpec.current_example.metadata[:realworld]
- "vcr"
- else
- "fail"
- end
- end
- if artifice
- requires << "support/artifice/#{artifice}"
- end
-
- requires_str = requires.map {|r| "-r#{r}" }.join(" ")
-
- load_path = []
- load_path << lib_dir unless system_bundler
- load_path << spec_dir
- load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}"
-
- args = options.map do |k, v|
- case v
- when nil
- next
- when true
- " --#{k}"
- when false
- " --no-#{k}"
- else
- " --#{k} #{v}"
- end
- end.join
-
- cmd = "#{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}"
- sys_exec(cmd, env) {|i, o, thr| yield i, o, thr if block_given? }
- end
- bang :bundle
-
- def forgotten_command_line_options(options)
- remembered = Bundler::VERSION.split(".", 2).first == "2"
- options = options.map do |k, v|
- v = '""' if v && v.to_s.empty?
- [k, v]
- end
- return Hash[options] if remembered
- options.each do |k, v|
- if v.nil?
- bundle! "config unset #{k}"
- else
- bundle! "config set --local #{k} #{v}"
- end
- end
- {}
- end
-
- def bundler(cmd, options = {})
- options["bundle_bin"] = bindir.join("bundler")
- bundle(cmd, options)
- end
-
- def ruby(ruby, options = {})
- env = options.delete(:env) || {}
- ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" }
- lib_option = options[:no_lib] ? "" : " -I#{lib_dir}"
- sys_exec(%(#{Gem.ruby}#{lib_option} -w -e "#{ruby}"), env)
- end
- bang :ruby
-
- def load_error_ruby(ruby, name, opts = {})
- ruby(<<-R)
- begin
- #{ruby}
- rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR"# if e.message.include?("-- #{name}")
- end
- R
- end
-
- def gembin(cmd)
- old = ENV["RUBYOPT"]
- ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -I#{lib_dir}"
- cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
- sys_exec(cmd.to_s)
- ensure
- ENV["RUBYOPT"] = old
- end
-
- def gem_command(command, args = "")
- sys_exec("#{Path.gem_bin} #{command} #{args}")
- end
- bang :gem_command
-
- def rake
- "#{Gem.ruby} -S #{ENV["GEM_PATH"]}/bin/rake"
- end
-
- def sys_exec(cmd, env = {})
- command_execution = CommandExecution.new(cmd.to_s, Dir.pwd)
-
- require "open3"
- Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr|
- yield stdin, stdout, wait_thr if block_given?
- stdin.close
-
- stdout_read_thread = Thread.new { stdout.read }
- stderr_read_thread = Thread.new { stderr.read }
- command_execution.stdout = stdout_read_thread.value.strip
- command_execution.stderr = stderr_read_thread.value.strip
- command_execution.exitstatus = wait_thr && wait_thr.value.exitstatus
- end
-
- (@command_executions ||= []) << command_execution
-
- command_execution.stdout
- end
- bang :sys_exec
-
- def config(config = nil, path = bundled_app(".bundle/config"))
- return YAML.load_file(path) unless config
- FileUtils.mkdir_p(File.dirname(path))
- File.open(path, "w") do |f|
- f.puts config.to_yaml
- end
- config
- end
-
- def global_config(config = nil)
- config(config, home(".bundle/config"))
- end
-
- def create_file(*args)
- path = bundled_app(args.shift)
- path = args.shift if args.first.is_a?(Pathname)
- str = args.shift || ""
- path.dirname.mkpath
- File.open(path.to_s, "w") do |f|
- f.puts strip_whitespace(str)
- end
- end
-
- def gemfile(*args)
- contents = args.shift
-
- if contents.nil?
- File.open("Gemfile", "r", &:read)
- else
- create_file("Gemfile", contents, *args)
- end
- end
-
- def lockfile(*args)
- contents = args.shift
-
- if contents.nil?
- File.open("Gemfile.lock", "r", &:read)
- else
- create_file("Gemfile.lock", contents, *args)
- end
- end
-
- def strip_whitespace(str)
- # Trim the leading spaces
- spaces = str[/\A\s+/, 0] || ""
- str.gsub(/^#{spaces}/, "")
- end
-
- def install_gemfile(*args)
- gemfile(*args)
- opts = args.last.is_a?(Hash) ? args.last : {}
- opts[:retry] ||= 0
- bundle :install, opts
- end
- bang :install_gemfile
-
- def lock_gemfile(*args)
- gemfile(*args)
- opts = args.last.is_a?(Hash) ? args.last : {}
- opts[:retry] ||= 0
- bundle :lock, opts
- end
-
- def install_gems(*gems)
- options = gems.last.is_a?(Hash) ? gems.pop : {}
- gem_repo = options.fetch(:gem_repo) { gem_repo1 }
- gems.each do |g|
- if g == :bundler
- with_built_bundler {|gem_path| install_gem(gem_path) }
- elsif g.to_s =~ %r{\A(?:[A-Z]:)?/.*\.gem\z}
- install_gem(g)
- else
- install_gem("#{gem_repo}/gems/#{g}.gem")
- end
- end
- end
-
- def install_gem(path)
- raise "OMG `#{path}` does not exist!" unless File.exist?(path)
-
- gem_command! :install, "--no-document --ignore-dependencies '#{path}'"
- end
-
- def with_built_bundler
- with_root_gemspec do |gemspec|
- Dir.chdir(root) { gem_command! :build, gemspec.to_s }
- end
-
- bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
-
- begin
- yield(bundler_path)
- ensure
- bundler_path.rmtree
- end
- end
-
- def with_gem_path_as(path)
- backup = ENV.to_hash
- ENV["GEM_HOME"] = path.to_s
- ENV["GEM_PATH"] = path.to_s
- ENV["BUNDLER_ORIG_GEM_PATH"] = nil
- yield
- ensure
- ENV.replace(backup)
- end
-
- def with_path_as(path)
- backup = ENV.to_hash
- ENV["PATH"] = path.to_s
- ENV["BUNDLER_ORIG_PATH"] = nil
- yield
- ensure
- ENV.replace(backup)
- end
-
- def with_path_added(path)
- with_path_as(path.to_s + ":" + ENV["PATH"]) do
- yield
- end
- end
-
- def break_git!
- FileUtils.mkdir_p(tmp("broken_path"))
- File.open(tmp("broken_path/git"), "w", 0o755) do |f|
- f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
- end
-
- ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
- end
-
- def with_fake_man
- FileUtils.mkdir_p(tmp("fake_man"))
- File.open(tmp("fake_man/man"), "w", 0o755) do |f|
- f.puts "#!/usr/bin/env ruby\nputs ARGV.inspect\n"
- end
- with_path_added(tmp("fake_man")) { yield }
- end
-
- def system_gems(*gems)
- opts = gems.last.is_a?(Hash) ? gems.last : {}
- path = opts.fetch(:path, system_gem_path)
- if path == :bundle_path
- path = ruby!(<<-RUBY)
- require "bundler"
- begin
- puts Bundler.bundle_path
- rescue Bundler::GemfileNotFound
- ENV["BUNDLE_GEMFILE"] = "Gemfile"
- retry
- end
-
- RUBY
- end
- gems = gems.flatten
-
- unless opts[:keep_path]
- FileUtils.rm_rf(path)
- FileUtils.mkdir_p(path)
- end
-
- Gem.clear_paths
-
- env_backup = ENV.to_hash
- ENV["GEM_HOME"] = path.to_s
- ENV["GEM_PATH"] = path.to_s
- ENV["BUNDLER_ORIG_GEM_PATH"] = nil
-
- install_gems(*gems)
- return unless block_given?
- begin
- yield
- ensure
- ENV.replace(env_backup)
- end
- end
-
- def realworld_system_gems(*gems)
- gems = gems.flatten
-
- FileUtils.rm_rf(system_gem_path)
- FileUtils.mkdir_p(system_gem_path)
-
- Gem.clear_paths
-
- gem_home = ENV["GEM_HOME"]
- gem_path = ENV["GEM_PATH"]
- path = ENV["PATH"]
- ENV["GEM_HOME"] = system_gem_path.to_s
- ENV["GEM_PATH"] = system_gem_path.to_s
-
- gems.each do |gem|
- gem_command! :install, "--no-document #{gem}"
- end
- return unless block_given?
- begin
- yield
- ensure
- ENV["GEM_HOME"] = gem_home
- ENV["GEM_PATH"] = gem_path
- ENV["PATH"] = path
- end
- end
-
- def cache_gems(*gems)
- gems = gems.flatten
-
- FileUtils.rm_rf("#{bundled_app}/vendor/cache")
- FileUtils.mkdir_p("#{bundled_app}/vendor/cache")
-
- gems.each do |g|
- path = "#{gem_repo1}/gems/#{g}.gem"
- raise "OMG `#{path}` does not exist!" unless File.exist?(path)
- FileUtils.cp(path, "#{bundled_app}/vendor/cache")
- end
- end
-
- def simulate_new_machine
- system_gems []
- FileUtils.rm_rf system_gem_path
- FileUtils.rm_rf bundled_app(".bundle")
- end
-
- def simulate_platform(platform)
- old = ENV["BUNDLER_SPEC_PLATFORM"]
- ENV["BUNDLER_SPEC_PLATFORM"] = platform.to_s
- yield if block_given?
- ensure
- ENV["BUNDLER_SPEC_PLATFORM"] = old if block_given?
- end
-
- def simulate_ruby_version(version)
- return if version == RUBY_VERSION
- old = ENV["BUNDLER_SPEC_RUBY_VERSION"]
- ENV["BUNDLER_SPEC_RUBY_VERSION"] = version
- yield if block_given?
- ensure
- ENV["BUNDLER_SPEC_RUBY_VERSION"] = old if block_given?
- end
-
- def simulate_ruby_engine(engine, version = "1.6.0")
- return if engine == local_ruby_engine
-
- old = ENV["BUNDLER_SPEC_RUBY_ENGINE"]
- ENV["BUNDLER_SPEC_RUBY_ENGINE"] = engine
- old_version = ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
- ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"] = version
- yield if block_given?
- ensure
- ENV["BUNDLER_SPEC_RUBY_ENGINE"] = old if block_given?
- ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"] = old_version if block_given?
- end
-
- def simulate_bundler_version(version)
- old = ENV["BUNDLER_SPEC_VERSION"]
- ENV["BUNDLER_SPEC_VERSION"] = version.to_s
- yield if block_given?
- ensure
- ENV["BUNDLER_SPEC_VERSION"] = old if block_given?
- end
-
- def simulate_rubygems_version(version)
- old = ENV["BUNDLER_SPEC_RUBYGEMS_VERSION"]
- ENV["BUNDLER_SPEC_RUBYGEMS_VERSION"] = version.to_s
- yield if block_given?
- ensure
- ENV["BUNDLER_SPEC_RUBYGEMS_VERSION"] = old if block_given?
- end
-
- def simulate_windows(platform = mswin)
- old = ENV["BUNDLER_SPEC_WINDOWS"]
- ENV["BUNDLER_SPEC_WINDOWS"] = "true"
- simulate_platform platform do
- yield
- end
- ensure
- ENV["BUNDLER_SPEC_WINDOWS"] = old
- end
-
- def revision_for(path)
- Dir.chdir(path) { `git rev-parse HEAD`.strip }
- end
-
- def with_read_only(pattern)
- chmod = lambda do |dirmode, filemode|
- lambda do |f|
- mode = File.directory?(f) ? dirmode : filemode
- File.chmod(mode, f)
- end
- end
-
- Dir[pattern].each(&chmod[0o555, 0o444])
- yield
- ensure
- Dir[pattern].each(&chmod[0o755, 0o644])
- end
-
- # Simulate replacing TODOs with real values
- def prepare_gemspec(pathname)
- process_file(pathname) do |line|
- case line
- when /spec\.metadata\["(?:allowed_push_host|homepage_uri|source_code_uri|changelog_uri)"\]/, /spec\.homepage/
- line.gsub(/\=.*$/, "= 'http://example.org'")
- when /spec\.summary/
- line.gsub(/\=.*$/, "= %q{A short summary of my new gem.}")
- when /spec\.description/
- line.gsub(/\=.*$/, "= %q{A longer description of my new gem.}")
- else
- line
- end
- end
- end
-
- def process_file(pathname)
- changed_lines = pathname.readlines.map do |line|
- yield line
- end
- File.open(pathname, "w") {|file| file.puts(changed_lines.join) }
- end
-
- def with_env_vars(env_hash, &block)
- current_values = {}
- env_hash.each do |k, v|
- current_values[k] = ENV[k]
- ENV[k] = v
- end
- block.call if block_given?
- env_hash.each do |k, _|
- ENV[k] = current_values[k]
- end
- end
-
- def require_rack
- # need to hack, so we can require rack
- old_gem_home = ENV["GEM_HOME"]
- ENV["GEM_HOME"] = Spec::Path.base_system_gems.to_s
- require "rack"
- ENV["GEM_HOME"] = old_gem_home
- end
-
- def wait_for_server(host, port, seconds = 15)
- tries = 0
- sleep 0.5
- TCPSocket.new(host, port)
- rescue StandardError => e
- raise(e) if tries > (seconds * 2)
- tries += 1
- retry
- end
-
- def find_unused_port
- port = 21_453
- begin
- port += 1 while TCPSocket.new("127.0.0.1", port)
- rescue StandardError
- false
- end
- port
- end
- end
-end
diff --git a/spec/bundler/support/indexes.rb b/spec/bundler/support/indexes.rb
deleted file mode 100644
index dc6e0bd1e9..0000000000
--- a/spec/bundler/support/indexes.rb
+++ /dev/null
@@ -1,421 +0,0 @@
-# frozen_string_literal: true
-
-module Spec
- module Indexes
- def dep(name, reqs = nil)
- @deps ||= []
- @deps << Bundler::Dependency.new(name, reqs)
- end
-
- def platform(*args)
- @platforms ||= []
- @platforms.concat args.map {|p| Gem::Platform.new(p) }
- end
-
- alias_method :platforms, :platform
-
- def resolve(args = [])
- @platforms ||= ["ruby"]
- deps = []
- default_source = instance_double("Bundler::Source::Rubygems", :specs => @index)
- source_requirements = { :default => default_source }
- @deps.each do |d|
- @platforms.each do |p|
- source_requirements[d.name] = d.source = default_source
- deps << Bundler::DepProxy.new(d, p)
- end
- end
- source_requirements ||= {}
- Bundler::Resolver.resolve(deps, @index, source_requirements, *args)
- end
-
- def should_resolve_as(specs)
- got = resolve
- got = got.map(&:full_name).sort
- expect(got).to eq(specs.sort)
- end
-
- def should_resolve_and_include(specs, args = [])
- got = resolve(args)
- got = got.map(&:full_name).sort
- specs.each do |s|
- expect(got).to include(s)
- end
- end
-
- def should_conflict_on(names)
- got = resolve
- raise "The resolve succeeded with: #{got.map(&:full_name).sort.inspect}"
- rescue Bundler::VersionConflict => e
- expect(Array(names).sort).to eq(e.conflicts.sort)
- end
-
- def gem(*args, &blk)
- build_spec(*args, &blk).first
- end
-
- def locked(*args)
- Bundler::SpecSet.new(args.map do |name, version|
- gem(name, version)
- end)
- end
-
- def should_conservative_resolve_and_include(opts, unlock, specs)
- # empty unlock means unlock all
- opts = Array(opts)
- search = Bundler::GemVersionPromoter.new(@locked, unlock).tap do |s|
- s.level = opts.first
- s.strict = opts.include?(:strict)
- s.prerelease_specified = Hash[@deps.map {|d| [d.name, d.requirement.prerelease?] }]
- end
- should_resolve_and_include specs, [@base, search]
- end
-
- def an_awesome_index
- build_index do
- gem "rack", %w[0.8 0.9 0.9.1 0.9.2 1.0 1.1]
- gem "rack-mount", %w[0.4 0.5 0.5.1 0.5.2 0.6]
-
- # --- Pre-release support
- gem "RubyGems\0", ["1.3.2"]
-
- # --- Rails
- versions "1.2.3 2.2.3 2.3.5 3.0.0.beta 3.0.0.beta1" do |version|
- gem "activesupport", version
- gem "actionpack", version do
- dep "activesupport", version
- if version >= v("3.0.0.beta")
- dep "rack", "~> 1.1"
- dep "rack-mount", ">= 0.5"
- elsif version > v("2.3") then dep "rack", "~> 1.0.0"
- elsif version > v("2.0.0") then dep "rack", "~> 0.9.0"
- end
- end
- gem "activerecord", version do
- dep "activesupport", version
- dep "arel", ">= 0.2" if version >= v("3.0.0.beta")
- end
- gem "actionmailer", version do
- dep "activesupport", version
- dep "actionmailer", version
- end
- if version < v("3.0.0.beta")
- gem "railties", version do
- dep "activerecord", version
- dep "actionpack", version
- dep "actionmailer", version
- dep "activesupport", version
- end
- else
- gem "railties", version
- gem "rails", version do
- dep "activerecord", version
- dep "actionpack", version
- dep "actionmailer", version
- dep "activesupport", version
- dep "railties", version
- end
- end
- end
-
- versions "1.0 1.2 1.2.1 1.2.2 1.3 1.3.0.1 1.3.5 1.4.0 1.4.2 1.4.2.1" do |version|
- platforms "ruby java mswin32 mingw32 x64-mingw32" do |platform|
- next if version == v("1.4.2.1") && platform != pl("x86-mswin32")
- next if version == v("1.4.2") && platform == pl("x86-mswin32")
- gem "nokogiri", version, platform do
- dep "weakling", ">= 0.0.3" if platform =~ pl("java")
- end
- end
- end
-
- versions "0.0.1 0.0.2 0.0.3" do |version|
- gem "weakling", version
- end
-
- # --- Rails related
- versions "1.2.3 2.2.3 2.3.5" do |version|
- gem "activemerchant", version do
- dep "activesupport", ">= #{version}"
- end
- end
-
- gem "reform", ["1.0.0"] do
- dep "activesupport", ">= 1.0.0.beta1"
- end
-
- gem "need-pre", ["1.0.0"] do
- dep "activesupport", "~> 3.0.0.beta1"
- end
- end
- end
-
- # Builder 3.1.4 will activate first, but if all
- # goes well, it should resolve to 3.0.4
- def a_conflict_index
- build_index do
- gem "builder", %w[3.0.4 3.1.4]
- gem("grape", "0.2.6") do
- dep "builder", ">= 0"
- end
-
- versions "3.2.8 3.2.9 3.2.10 3.2.11" do |version|
- gem("activemodel", version) do
- dep "builder", "~> 3.0.0"
- end
- end
-
- gem("my_app", "1.0.0") do
- dep "activemodel", ">= 0"
- dep "grape", ">= 0"
- end
- end
- end
-
- def a_complex_conflict_index
- build_index do
- gem("a", %w[1.0.2 1.1.4 1.2.0 1.4.0]) do
- dep "d", ">= 0"
- end
-
- gem("d", %w[1.3.0 1.4.1]) do
- dep "x", ">= 0"
- end
-
- gem "d", "0.9.8"
-
- gem("b", "0.3.4") do
- dep "a", ">= 1.5.0"
- end
-
- gem("b", "0.3.5") do
- dep "a", ">= 1.2"
- end
-
- gem("b", "0.3.3") do
- dep "a", "> 1.0"
- end
-
- versions "3.2 3.3" do |version|
- gem("c", version) do
- dep "a", "~> 1.0"
- end
- end
-
- gem("my_app", "1.3.0") do
- dep "c", ">= 4.0"
- dep "b", ">= 0"
- end
-
- gem("my_app", "1.2.0") do
- dep "c", "~> 3.3.0"
- dep "b", "0.3.4"
- end
-
- gem("my_app", "1.1.0") do
- dep "c", "~> 3.2.0"
- dep "b", "0.3.5"
- end
- end
- end
-
- def index_with_conflict_on_child
- build_index do
- gem "json", %w[1.6.5 1.7.7 1.8.0]
-
- gem("chef", "10.26") do
- dep "json", [">= 1.4.4", "<= 1.7.7"]
- end
-
- gem("berkshelf", "2.0.7") do
- dep "json", ">= 1.7.7"
- end
-
- gem("chef_app", "1.0.0") do
- dep "berkshelf", "~> 2.0"
- dep "chef", "~> 10.26"
- end
- end
- end
-
- # Issue #3459
- def a_complicated_index
- build_index do
- gem "foo", %w[3.0.0 3.0.5] do
- dep "qux", ["~> 3.1"]
- dep "baz", ["< 9.0", ">= 5.0"]
- dep "bar", ["~> 1.0"]
- dep "grault", ["~> 3.1"]
- end
-
- gem "foo", "1.2.1" do
- dep "baz", ["~> 4.2"]
- dep "bar", ["~> 1.0"]
- dep "qux", ["~> 3.1"]
- dep "grault", ["~> 2.0"]
- end
-
- gem "bar", "1.0.5" do
- dep "grault", ["~> 3.1"]
- dep "baz", ["< 9", ">= 4.2"]
- end
-
- gem "bar", "1.0.3" do
- dep "baz", ["< 9", ">= 4.2"]
- dep "grault", ["~> 2.0"]
- end
-
- gem "baz", "8.2.10" do
- dep "grault", ["~> 3.0"]
- dep "garply", [">= 0.5.1", "~> 0.5"]
- end
-
- gem "baz", "5.0.2" do
- dep "grault", ["~> 2.0"]
- dep "garply", [">= 0.3.1"]
- end
-
- gem "baz", "4.2.0" do
- dep "grault", ["~> 2.0"]
- dep "garply", [">= 0.3.1"]
- end
-
- gem "grault", %w[2.6.3 3.1.1]
-
- gem "garply", "0.5.1" do
- dep "waldo", ["~> 0.1.3"]
- end
-
- gem "waldo", "0.1.5" do
- dep "plugh", ["~> 0.6.0"]
- end
-
- gem "plugh", %w[0.6.3 0.6.11 0.7.0]
-
- gem "qux", "3.2.21" do
- dep "plugh", [">= 0.6.4", "~> 0.6"]
- dep "corge", ["~> 1.0"]
- end
-
- gem "corge", "1.10.1"
- end
- end
-
- def a_unresovable_child_index
- build_index do
- gem "json", %w[1.8.0]
-
- gem("chef", "10.26") do
- dep "json", [">= 1.4.4", "<= 1.7.7"]
- end
-
- gem("berkshelf", "2.0.7") do
- dep "json", ">= 1.7.7"
- end
-
- gem("chef_app_error", "1.0.0") do
- dep "berkshelf", "~> 2.0"
- dep "chef", "~> 10.26"
- end
- end
- end
-
- def a_index_with_root_conflict_on_child
- build_index do
- gem "builder", %w[2.1.2 3.0.1 3.1.3]
- gem "i18n", %w[0.4.1 0.4.2]
-
- gem "activesupport", %w[3.0.0 3.0.1 3.0.5 3.1.7]
-
- gem("activemodel", "3.0.5") do
- dep "activesupport", "= 3.0.5"
- dep "builder", "~> 2.1.2"
- dep "i18n", "~> 0.4"
- end
-
- gem("activemodel", "3.0.0") do
- dep "activesupport", "= 3.0.0"
- dep "builder", "~> 2.1.2"
- dep "i18n", "~> 0.4.1"
- end
-
- gem("activemodel", "3.1.3") do
- dep "activesupport", "= 3.1.3"
- dep "builder", "~> 2.1.2"
- dep "i18n", "~> 0.5"
- end
-
- gem("activerecord", "3.0.0") do
- dep "activesupport", "= 3.0.0"
- dep "activemodel", "= 3.0.0"
- end
-
- gem("activerecord", "3.0.5") do
- dep "activesupport", "= 3.0.5"
- dep "activemodel", "= 3.0.5"
- end
-
- gem("activerecord", "3.0.9") do
- dep "activesupport", "= 3.1.5"
- dep "activemodel", "= 3.1.5"
- end
- end
- end
-
- def a_circular_index
- build_index do
- gem "rack", "1.0.1"
- gem("foo", "0.2.6") do
- dep "bar", ">= 0"
- end
-
- gem("bar", "1.0.0") do
- dep "foo", ">= 0"
- end
-
- gem("circular_app", "1.0.0") do
- dep "foo", ">= 0"
- dep "bar", ">= 0"
- end
- end
- end
-
- def an_ambiguous_index
- build_index do
- gem("a", "1.0.0") do
- dep "c", ">= 0"
- end
-
- gem("b", %w[0.5.0 1.0.0])
-
- gem("b", "2.0.0") do
- dep "c", "< 2.0.0"
- end
-
- gem("c", "1.0.0") do
- dep "d", "1.0.0"
- end
-
- gem("c", "2.0.0") do
- dep "d", "2.0.0"
- end
-
- gem("d", %w[1.0.0 2.0.0])
- end
- end
-
- def optional_prereleases_index
- build_index do
- gem("a", %w[1.0.0])
-
- gem("a", "2.0.0") do
- dep "b", ">= 2.0.0.pre"
- end
-
- gem("b", %w[0.9.0 1.5.0 2.0.0.pre])
-
- # --- Pre-release support
- gem "RubyGems\0", ["1.3.2"]
- end
- end
- end
-end
diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb
deleted file mode 100644
index df35854c2f..0000000000
--- a/spec/bundler/support/matchers.rb
+++ /dev/null
@@ -1,224 +0,0 @@
-# frozen_string_literal: true
-
-require "forwardable"
-require_relative "the_bundle"
-
-module Spec
- module Matchers
- extend RSpec::Matchers
-
- class Precondition
- include RSpec::Matchers::Composable
- extend Forwardable
- def_delegators :failing_matcher,
- :failure_message,
- :actual,
- :description,
- :diffable?,
- :expected,
- :failure_message_when_negated
-
- def initialize(matcher, preconditions)
- @matcher = with_matchers_cloned(matcher)
- @preconditions = with_matchers_cloned(preconditions)
- @failure_index = nil
- end
-
- def matches?(target, &blk)
- return false if @failure_index = @preconditions.index {|pc| !pc.matches?(target, &blk) }
- @matcher.matches?(target, &blk)
- end
-
- def does_not_match?(target, &blk)
- return false if @failure_index = @preconditions.index {|pc| !pc.matches?(target, &blk) }
- if @matcher.respond_to?(:does_not_match?)
- @matcher.does_not_match?(target, &blk)
- else
- !@matcher.matches?(target, &blk)
- end
- end
-
- def expects_call_stack_jump?
- @matcher.expects_call_stack_jump? || @preconditions.any?(&:expects_call_stack_jump)
- end
-
- def supports_block_expectations?
- @matcher.supports_block_expectations? || @preconditions.any?(&:supports_block_expectations)
- end
-
- def failing_matcher
- @failure_index ? @preconditions[@failure_index] : @matcher
- end
- end
-
- def self.define_compound_matcher(matcher, preconditions, &declarations)
- raise "Must have preconditions to define a compound matcher" if preconditions.empty?
- define_method(matcher) do |*expected, &block_arg|
- Precondition.new(
- RSpec::Matchers::DSL::Matcher.new(matcher, declarations, self, *expected, &block_arg),
- preconditions
- )
- end
- end
-
- RSpec::Matchers.define :have_dep do |*args|
- dep = Bundler::Dependency.new(*args)
-
- match do |actual|
- actual.length == 1 && actual.all? {|d| d == dep }
- end
- end
-
- RSpec::Matchers.define :have_gem do |*args|
- match do |actual|
- actual.length == args.length && actual.all? {|a| args.include?(a.full_name) }
- end
- end
-
- RSpec::Matchers.define :have_rubyopts do |*args|
- args = args.flatten
- args = args.first.split(/\s+/) if args.size == 1
-
- match do |actual|
- actual = actual.split(/\s+/) if actual.is_a?(String)
- args.all? {|arg| actual.include?(arg) } && actual.uniq.size == actual.size
- end
- end
-
- RSpec::Matchers.define :be_sorted do
- diffable
- attr_reader :expected
- match do |actual|
- expected = block_arg ? actual.sort_by(&block_arg) : actual.sort
- actual.==(expected).tap do
- # HACK: since rspec won't show a diff when everything is a string
- differ = RSpec::Support::Differ.new
- @actual = differ.send(:object_to_string, actual)
- @expected = differ.send(:object_to_string, expected)
- end
- end
- end
-
- RSpec::Matchers.define :be_well_formed do
- match(&:empty?)
-
- failure_message do |actual|
- actual.join("\n")
- end
- end
-
- define_compound_matcher :read_as, [exist] do |file_contents|
- diffable
-
- match do |actual|
- @actual = Bundler.read_file(actual)
- values_match?(file_contents, @actual)
- end
- end
-
- def indent(string, padding = 4, indent_character = " ")
- string.to_s.gsub(/^/, indent_character * padding).gsub("\t", " ")
- end
-
- define_compound_matcher :include_gems, [be_an_instance_of(Spec::TheBundle)] do |*names|
- match do
- opts = names.last.is_a?(Hash) ? names.pop : {}
- source = opts.delete(:source)
- groups = Array(opts[:groups])
- groups << opts
- @errors = names.map do |name|
- name, version, platform = name.split(/\s+/)
- require_path = name == "bundler" ? "#{lib_dir}/bundler" : name.tr("-", "/")
- version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
- begin
- run! "require '#{require_path}.rb'; puts #{version_const}", *groups
- rescue StandardError => e
- next "#{name} is not installed:\n#{indent(e)}"
- end
- actual_version, actual_platform = out.strip.split(/\s+/, 2)
- unless Gem::Version.new(actual_version) == Gem::Version.new(version)
- next "#{name} was expected to be at version #{version} but was #{actual_version}"
- end
- unless actual_platform == platform
- next "#{name} was expected to be of platform #{platform} but was #{actual_platform}"
- end
- next unless source
- begin
- source_const = "#{Spec::Builders.constantize(name)}_SOURCE"
- run! "require '#{require_path}/source'; puts #{source_const}", *groups
- rescue StandardError
- next "#{name} does not have a source defined:\n#{indent(e)}"
- end
- unless out.strip == source
- next "Expected #{name} (#{version}) to be installed from `#{source}`, was actually from `#{out}`"
- end
- end.compact
-
- @errors.empty?
- end
-
- match_when_negated do
- opts = names.last.is_a?(Hash) ? names.pop : {}
- groups = Array(opts[:groups]) || []
- @errors = names.map do |name|
- name, version = name.split(/\s+/, 2)
- begin
- run <<-R, *(groups + [opts])
- begin
- require '#{name}'
- puts #{Spec::Builders.constantize(name)}
- rescue LoadError, NameError
- puts "WIN"
- end
- R
- rescue StandardError => e
- next "checking for #{name} failed:\n#{e}\n#{e.backtrace.join("\n")}"
- end
- next if out == "WIN"
- next "expected #{name} to not be installed, but it was" if version.nil?
- if Gem::Version.new(out) == Gem::Version.new(version)
- next "expected #{name} (#{version}) not to be installed, but it was"
- end
- end.compact
-
- @errors.empty?
- end
-
- failure_message do
- super() + " but:\n" + @errors.map {|e| indent(e) }.join("\n")
- end
-
- failure_message_when_negated do
- super() + " but:\n" + @errors.map {|e| indent(e) }.join("\n")
- end
- end
- RSpec::Matchers.define_negated_matcher :not_include_gems, :include_gems
- RSpec::Matchers.alias_matcher :include_gem, :include_gems
-
- def have_lockfile(expected)
- read_as(strip_whitespace(expected))
- end
-
- def plugin_should_be_installed(*names)
- names.each do |name|
- expect(Bundler::Plugin).to be_installed(name)
- path = Pathname.new(Bundler::Plugin.installed?(name))
- expect(path + "plugins.rb").to exist
- end
- end
-
- def plugin_should_not_be_installed(*names)
- names.each do |name|
- expect(Bundler::Plugin).not_to be_installed(name)
- end
- end
-
- def lockfile_should_be(expected)
- expect(bundled_app("Gemfile.lock")).to have_lockfile(expected)
- end
-
- def gemfile_should_be(expected)
- expect(bundled_app("Gemfile")).to read_as(strip_whitespace(expected))
- end
- end
-end
diff --git a/spec/bundler/support/parallel.rb b/spec/bundler/support/parallel.rb
deleted file mode 100644
index 8763cb9ec4..0000000000
--- a/spec/bundler/support/parallel.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.configure do |config|
- config.silence_filter_announcements = true
-end
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
deleted file mode 100644
index 645da52c97..0000000000
--- a/spec/bundler/support/path.rb
+++ /dev/null
@@ -1,191 +0,0 @@
-# frozen_string_literal: true
-
-require "pathname"
-require "rbconfig"
-
-module Spec
- module Path
- def root
- @root ||= Pathname.new(ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__)
- end
-
- def gemspec
- @gemspec ||= root.join(ruby_core? ? "lib/bundler/bundler.gemspec" : "bundler.gemspec")
- end
-
- def gemspec_dir
- @gemspec_dir ||= gemspec.parent
- end
-
- def bindir
- @bindir ||= root.join(ruby_core? ? "libexec" : "exe")
- end
-
- def gem_cmd
- @gem_cmd ||= ruby_core? ? root.join("bin/gem") : "gem"
- end
-
- def gem_bin
- @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "gem"
- end
-
- def spec_dir
- @spec_dir ||= root.join(ruby_core? ? "spec/bundler" : "spec")
- end
-
- def tracked_files
- skip "not in git working directory" unless git_root_dir?
-
- @tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*` : `git ls-files -z`
- end
-
- def shipped_files
- skip "not in git working directory" unless git_root_dir?
-
- @shipped_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb man/bundler* libexec/bundle*` : `git ls-files -z -- lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec`
- end
-
- def lib_tracked_files
- skip "not in git working directory" unless git_root_dir?
-
- @lib_tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
- end
-
- def tmp(*path)
- root.join("tmp", scope, *path)
- end
-
- def scope
- test_number = ENV["TEST_ENV_NUMBER"]
- return "1" if test_number.nil?
-
- test_number.empty? ? "1" : test_number
- end
-
- def home(*path)
- tmp.join("home", *path)
- end
-
- def default_bundle_path(*path)
- if Bundler::VERSION.split(".").first.to_i < 3
- system_gem_path(*path)
- else
- bundled_app(*[".bundle", ENV.fetch("BUNDLER_SPEC_RUBY_ENGINE", Gem.ruby_engine), RbConfig::CONFIG["ruby_version"], *path].compact)
- end
- end
-
- def bundled_app(*path)
- root = tmp.join("bundled_app")
- FileUtils.mkdir_p(root)
- root.join(*path)
- end
-
- alias_method :bundled_app1, :bundled_app
-
- def bundled_app2(*path)
- root = tmp.join("bundled_app2")
- FileUtils.mkdir_p(root)
- root.join(*path)
- end
-
- def vendored_gems(path = nil)
- bundled_app(*["vendor/bundle", Gem.ruby_engine, RbConfig::CONFIG["ruby_version"], path].compact)
- end
-
- def cached_gem(path)
- bundled_app("vendor/cache/#{path}.gem")
- end
-
- def base_system_gems
- tmp.join("gems/base")
- end
-
- def file_uri_for(path)
- protocol = "file://"
- root = Gem.win_platform? ? "/" : ""
-
- protocol + root + path.to_s
- end
-
- def gem_repo1(*args)
- tmp("gems/remote1", *args)
- end
-
- def gem_repo_missing(*args)
- tmp("gems/missing", *args)
- end
-
- def gem_repo2(*args)
- tmp("gems/remote2", *args)
- end
-
- def gem_repo3(*args)
- tmp("gems/remote3", *args)
- end
-
- def gem_repo4(*args)
- tmp("gems/remote4", *args)
- end
-
- def security_repo(*args)
- tmp("gems/security_repo", *args)
- end
-
- def system_gem_path(*path)
- tmp("gems/system", *path)
- end
-
- def lib_path(*args)
- tmp("libs", *args)
- end
-
- def lib_dir
- root.join("lib")
- end
-
- def global_plugin_gem(*args)
- home ".bundle", "plugin", "gems", *args
- end
-
- def local_plugin_gem(*args)
- bundled_app ".bundle", "plugin", "gems", *args
- end
-
- def tmpdir(*args)
- tmp "tmpdir", *args
- end
-
- def with_root_gemspec
- if ruby_core?
- root_gemspec = root.join("bundler.gemspec")
- # Dir.chdir(root) for Dir.glob in gemspec
- spec = Dir.chdir(root) { Gem::Specification.load(gemspec.to_s) }
- spec.bindir = "libexec"
- File.open(root_gemspec.to_s, "w") {|f| f.write spec.to_ruby }
- yield(root_gemspec)
- FileUtils.rm(root_gemspec)
- else
- yield(gemspec)
- end
- end
-
- def ruby_core?
- # avoid to warnings
- @ruby_core ||= nil
-
- if @ruby_core.nil?
- @ruby_core = true & ENV["GEM_COMMAND"]
- else
- @ruby_core
- end
- end
-
- extend self
-
- private
-
- def git_root_dir?
- root.to_s == `git rev-parse --show-toplevel`.chomp
- end
- end
-end
diff --git a/spec/bundler/support/permissions.rb b/spec/bundler/support/permissions.rb
deleted file mode 100644
index b21ce3848d..0000000000
--- a/spec/bundler/support/permissions.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-module Spec
- module Permissions
- def with_umask(new_umask)
- old_umask = File.umask(new_umask)
- yield if block_given?
- ensure
- File.umask(old_umask)
- end
- end
-end
diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb
deleted file mode 100644
index f4d63c8ded..0000000000
--- a/spec/bundler/support/platforms.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-# frozen_string_literal: true
-
-module Spec
- module Platforms
- include Bundler::GemHelpers
-
- def rb
- Gem::Platform::RUBY
- end
-
- def mac
- Gem::Platform.new("x86-darwin-10")
- end
-
- def x64_mac
- Gem::Platform.new("x86_64-darwin-15")
- end
-
- def java
- Gem::Platform.new([nil, "java", nil])
- end
-
- def linux
- Gem::Platform.new(["x86", "linux", nil])
- end
-
- def mswin
- Gem::Platform.new(["x86", "mswin32", nil])
- end
-
- def mingw
- Gem::Platform.new(["x86", "mingw32", nil])
- end
-
- def x64_mingw
- Gem::Platform.new(["x64", "mingw32", nil])
- end
-
- def all_platforms
- [rb, java, linux, mswin, mingw, x64_mingw]
- end
-
- def local
- generic_local_platform
- end
-
- def specific_local_platform
- Bundler.local_platform
- end
-
- def not_local
- all_platforms.find {|p| p != generic_local_platform }
- end
-
- def local_tag
- if RUBY_PLATFORM == "java"
- :jruby
- else
- :ruby
- end
- end
-
- def not_local_tag
- [:ruby, :jruby].find {|tag| tag != local_tag }
- end
-
- def local_ruby_engine
- ENV["BUNDLER_SPEC_RUBY_ENGINE"] || RUBY_ENGINE
- end
-
- def local_engine_version
- return ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"] if ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
-
- RUBY_ENGINE_VERSION
- end
-
- def not_local_engine_version
- case not_local_tag
- when :ruby
- not_local_ruby_version
- when :jruby
- "1.6.1"
- end
- end
-
- def not_local_ruby_version
- "1.12"
- end
-
- def not_local_patchlevel
- 9999
- end
-
- def lockfile_platforms
- local_platforms.map(&:to_s).sort.join("\n ")
- end
-
- def local_platforms
- if Bundler.feature_flag.specific_platform?
- [local, specific_local_platform]
- else
- [local]
- end
- end
- end
-end
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
deleted file mode 100644
index ee9c750a52..0000000000
--- a/spec/bundler/support/rubygems_ext.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "path"
-
-module Spec
- module Rubygems
- DEV_DEPS = {
- "automatiek" => "~> 0.3.0",
- "parallel_tests" => "~> 2.29",
- "rake" => "~> 12.0",
- "ronn" => "~> 0.7.3",
- "rspec" => "~> 3.8",
- "rubocop" => "= 0.77.0",
- "rubocop-performance" => "= 1.5.1",
- }.freeze
-
- DEPS = {
- "rack" => "~> 2.0",
- "rack-test" => "~> 1.1",
- "artifice" => "~> 0.6.0",
- "compact_index" => "~> 0.11.0",
- "sinatra" => "~> 2.0",
- # Rake version has to be consistent for tests to pass
- "rake" => "12.3.2",
- "builder" => "~> 3.2",
- # ruby-graphviz is used by the viz tests
- "ruby-graphviz" => ">= 0.a",
- }.freeze
-
- extend self
-
- def dev_setup
- deps = DEV_DEPS
-
- # JRuby can't build ronn, so we skip that
- deps.delete("ronn") if RUBY_ENGINE == "jruby"
-
- install_gems(deps)
- end
-
- def gem_load(gem_name, bin_container)
- require_relative "rubygems_version_manager"
- RubygemsVersionManager.new(ENV["RGV"]).switch
-
- gem_load_and_activate(gem_name, bin_container)
- end
-
- def gem_require(gem_name)
- gem_activate(gem_name)
- require gem_name
- end
-
- def setup
- require "fileutils"
-
- Gem.clear_paths
-
- ENV["BUNDLE_PATH"] = nil
- ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
- ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
-
- manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" }
- manifest_path = Path.base_system_gems.join("manifest.txt")
- # it's OK if there are extra gems
- if !manifest_path.file? || !(manifest - manifest_path.readlines).empty?
- FileUtils.rm_rf(Path.base_system_gems)
- FileUtils.mkdir_p(Path.base_system_gems)
- puts "installing gems for the tests to use..."
- install_gems(DEPS)
- manifest_path.open("wb") {|f| f << manifest.join }
- end
-
- FileUtils.mkdir_p(Path.home)
- FileUtils.mkdir_p(Path.tmpdir)
-
- ENV["HOME"] = Path.home.to_s
- ENV["TMPDIR"] = Path.tmpdir.to_s
-
- require "rubygems/user_interaction"
- Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
- end
-
- private
-
- def gem_load_and_activate(gem_name, bin_container)
- gem_activate(gem_name)
- load Gem.bin_path(gem_name, bin_container)
- rescue Gem::LoadError => e
- abort "We couln't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`"
- end
-
- def gem_activate(gem_name)
- gem_requirement = DEV_DEPS[gem_name]
- gem gem_name, gem_requirement
- end
-
- def install_gems(gems)
- reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? }
- no_reqs.map!(&:first)
- reqs.map! {|name, req| "'#{name}:#{req}'" }
- deps = reqs.concat(no_reqs).join(" ")
- gem = ENV["GEM_COMMAND"] || "#{Gem.ruby} -S gem --backtrace"
- cmd = "#{gem} install #{deps} --no-document --conservative"
- system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")
- end
- end
-end
diff --git a/spec/bundler/support/rubygems_version_manager.rb b/spec/bundler/support/rubygems_version_manager.rb
deleted file mode 100644
index 854bce890d..0000000000
--- a/spec/bundler/support/rubygems_version_manager.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-# frozen_string_literal: true
-
-require "pathname"
-require_relative "helpers"
-require_relative "path"
-
-class RubygemsVersionManager
- include Spec::Helpers
- include Spec::Path
-
- def initialize(source)
- @source = source
- end
-
- def switch
- return if use_system?
-
- switch_local_copy_if_needed
-
- reexec_if_needed
- end
-
-private
-
- def use_system?
- @source.nil?
- end
-
- def reexec_if_needed
- return unless rubygems_unrequire_needed?
-
- require "rbconfig"
-
- ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"])
- ruby << RbConfig::CONFIG["EXEEXT"]
-
- cmd = [ruby, $0, *ARGV].compact
-
- ENV["RUBYOPT"] = "-I#{local_copy_path.join("lib")} #{ENV["RUBYOPT"]}"
-
- exec(ENV, *cmd)
- end
-
- def switch_local_copy_if_needed
- return unless local_copy_switch_needed?
-
- Dir.chdir(local_copy_path) do
- sys_exec!("git remote update")
- sys_exec!("git checkout #{target_tag} --quiet")
- end
-
- ENV["RGV"] = local_copy_path.to_s
- end
-
- def rubygems_unrequire_needed?
- !$LOADED_FEATURES.include?(local_copy_path.join("lib/rubygems.rb").to_s)
- end
-
- def local_copy_switch_needed?
- !source_is_path? && target_tag != local_copy_tag
- end
-
- def target_tag
- @target_tag ||= resolve_target_tag
- end
-
- def local_copy_tag
- Dir.chdir(local_copy_path) do
- sys_exec!("git rev-parse --abbrev-ref HEAD")
- end
- end
-
- def local_copy_path
- @local_copy_path ||= resolve_local_copy_path
- end
-
- def resolve_local_copy_path
- return expanded_source if source_is_path?
-
- rubygems_path = root.join("tmp/rubygems")
-
- unless rubygems_path.directory?
- rubygems_path.parent.mkpath
- sys_exec!("git clone https://github.com/rubygems/rubygems.git #{rubygems_path}")
- end
-
- rubygems_path
- end
-
- def source_is_path?
- expanded_source.directory?
- end
-
- def expanded_source
- @expanded_source ||= Pathname.new(@source).expand_path(root)
- end
-
- def resolve_target_tag
- return "v#{@source}" if @source.match(/^\d/)
-
- @source
- end
-end
diff --git a/spec/bundler/support/silent_logger.rb b/spec/bundler/support/silent_logger.rb
deleted file mode 100644
index 8665beb2c9..0000000000
--- a/spec/bundler/support/silent_logger.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-require "logger"
-module Spec
- class SilentLogger
- (::Logger.instance_methods - Object.instance_methods).each do |logger_instance_method|
- define_method(logger_instance_method) {|*args, &blk| }
- end
- end
-end
diff --git a/spec/bundler/support/sometimes.rb b/spec/bundler/support/sometimes.rb
deleted file mode 100644
index 65a95ed59c..0000000000
--- a/spec/bundler/support/sometimes.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-module Sometimes
- def run_with_retries(example_to_run, retries)
- example = RSpec.current_example
- example.metadata[:retries] ||= retries
-
- retries.times do |t|
- example.metadata[:retried] = t + 1
- example.instance_variable_set(:@exception, nil)
- example_to_run.run
- break unless example.exception
- end
-
- if e = example.exception
- new_exception = e.exception(e.message + "[Retried #{retries} times]")
- new_exception.set_backtrace e.backtrace
- example.instance_variable_set(:@exception, new_exception)
- end
- end
-end
-
-RSpec.configure do |config|
- config.include Sometimes
- config.alias_example_to :sometimes, :sometimes => true
- config.add_setting :sometimes_retry_count, :default => 5
-
- config.around(:each, :sometimes => true) do |example|
- retries = example.metadata[:retries] || RSpec.configuration.sometimes_retry_count
- run_with_retries(example, retries)
- end
-
- config.after(:suite) do
- message = proc do |color, text|
- colored = RSpec::Core::Formatters::ConsoleCodes.wrap(text, color)
- notification = RSpec::Core::Notifications::MessageNotification.new(colored)
- formatter = RSpec.configuration.formatters.first
- formatter.message(notification) if formatter.respond_to?(:message)
- end
-
- retried_examples = RSpec.world.example_groups.map do |g|
- g.descendants.map do |d|
- d.filtered_examples.select do |e|
- e.metadata[:sometimes] && e.metadata.fetch(:retried, 1) > 1
- end
- end
- end.flatten
-
- message.call(retried_examples.empty? ? :green : :yellow, "\n\nRetried examples: #{retried_examples.count}")
-
- retried_examples.each do |e|
- message.call(:cyan, " #{e.full_description}")
- path = RSpec::Core::Metadata.relative_path(e.location)
- message.call(:cyan, " [#{e.metadata[:retried]}/#{e.metadata[:retries]}] " + path)
- end
- end
-end
diff --git a/spec/bundler/support/streams.rb b/spec/bundler/support/streams.rb
deleted file mode 100644
index a947eebf6f..0000000000
--- a/spec/bundler/support/streams.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-require "stringio"
-
-def capture(*args)
- opts = args.pop if args.last.is_a?(Hash)
- opts ||= {}
-
- args.map!(&:to_s)
- begin
- result = StringIO.new
- result.close if opts[:closed]
- args.each {|stream| eval "$#{stream} = result" }
- yield
- ensure
- args.each {|stream| eval("$#{stream} = #{stream.upcase}") }
- end
- result.string
-end
diff --git a/spec/bundler/support/sudo.rb b/spec/bundler/support/sudo.rb
deleted file mode 100644
index 04e9443945..0000000000
--- a/spec/bundler/support/sudo.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-module Spec
- module Sudo
- def self.present?
- @which_sudo ||= Bundler.which("sudo")
- end
-
- def sudo(cmd)
- raise "sudo not present" unless Sudo.present?
- sys_exec("sudo #{cmd}")
- end
-
- def chown_system_gems_to_root
- sudo "chown -R root #{system_gem_path}"
- end
- end
-end
diff --git a/spec/bundler/support/the_bundle.rb b/spec/bundler/support/the_bundle.rb
deleted file mode 100644
index f252a4515b..0000000000
--- a/spec/bundler/support/the_bundle.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "path"
-
-module Spec
- class TheBundle
- include Spec::Path
-
- attr_accessor :bundle_dir
-
- def initialize(opts = {})
- opts = opts.dup
- @bundle_dir = Pathname.new(opts.delete(:bundle_dir) { bundled_app })
- raise "Too many options! #{opts}" unless opts.empty?
- end
-
- def to_s
- "the bundle"
- end
- alias_method :inspect, :to_s
-
- def locked?
- lockfile.file?
- end
-
- def lockfile
- bundle_dir.join("Gemfile.lock")
- end
-
- def locked_gems
- raise "Cannot read lockfile if it doesn't exist" unless locked?
- Bundler::LockfileParser.new(lockfile.read)
- end
- end
-end
diff --git a/spec/bundler/update/gemfile_spec.rb b/spec/bundler/update/gemfile_spec.rb
deleted file mode 100644
index 8c2bd9ccbf..0000000000
--- a/spec/bundler/update/gemfile_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle update" do
- context "with --gemfile" do
- it "finds the gemfile" do
- gemfile bundled_app("NotGemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle! :install, :gemfile => bundled_app("NotGemfile")
- bundle! :update, :gemfile => bundled_app("NotGemfile"), :all => true
-
- # Specify BUNDLE_GEMFILE for `the_bundle`
- # to retrieve the proper Gemfile
- ENV["BUNDLE_GEMFILE"] = "NotGemfile"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
- end
-
- context "with gemfile set via config" do
- before do
- gemfile bundled_app("NotGemfile"), <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- G
-
- bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
- bundle! :install
- end
-
- it "uses the gemfile to update" do
- bundle! "update", :all => true
- bundle "list"
-
- expect(out).to include("rack (1.0.0)")
- end
-
- it "uses the gemfile while in a subdirectory" do
- bundled_app("subdir").mkpath
- Dir.chdir(bundled_app("subdir")) do
- bundle! "update", :all => true
- bundle "list"
-
- expect(out).to include("rack (1.0.0)")
- end
- end
- end
-end
diff --git a/spec/bundler/update/gems/post_install_spec.rb b/spec/bundler/update/gems/post_install_spec.rb
deleted file mode 100644
index 5b061eb61b..0000000000
--- a/spec/bundler/update/gems/post_install_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle update" do
- let(:config) {}
-
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack', "< 1.0"
- gem 'thin'
- G
-
- bundle! "config set #{config}" if config
-
- bundle! :install
- end
-
- shared_examples "a config observer" do
- context "when ignore post-install messages for gem is set" do
- let(:config) { "ignore_messages.rack true" }
-
- it "doesn't display gem's post-install message" do
- expect(out).not_to include("Rack's post install message")
- end
- end
-
- context "when ignore post-install messages for all gems" do
- let(:config) { "ignore_messages true" }
-
- it "doesn't display any post-install messages" do
- expect(out).not_to include("Post-install message")
- end
- end
- end
-
- shared_examples "a post-install message outputter" do
- it "should display post-install messages for updated gems" do
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- end
-
- it "should not display the post-install message for non-updated gems" do
- expect(out).not_to include("Thin's post install message")
- end
- end
-
- context "when listed gem is updated" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack'
- gem 'thin'
- G
-
- bundle! :update, :all => true
- end
-
- it_behaves_like "a post-install message outputter"
- it_behaves_like "a config observer"
- end
-
- context "when dependency triggers update" do
- before do
- gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem 'rack-obama'
- gem 'thin'
- G
-
- bundle! :update, :all => true
- end
-
- it_behaves_like "a post-install message outputter"
- it_behaves_like "a config observer"
- end
-end
diff --git a/spec/bundler/update/git_spec.rb b/spec/bundler/update/git_spec.rb
deleted file mode 100644
index 752033c842..0000000000
--- a/spec/bundler/update/git_spec.rb
+++ /dev/null
@@ -1,374 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle update" do
- describe "git sources" do
- it "floats on a branch when :branch is used" do
- build_git "foo", "1.0"
- update_git "foo", :branch => "omg"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}", :branch => "omg" do
- gem 'foo'
- end
- G
-
- update_git "foo", :branch => "omg" do |s|
- s.write "lib/foo.rb", "FOO = '1.1'"
- end
-
- bundle "update", :all => true
-
- expect(the_bundle).to include_gems "foo 1.1"
- end
-
- it "updates correctly when you have like craziness" do
- build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport")
- build_git "rails", "3.0", :path => lib_path("rails") do |s|
- s.add_dependency "activesupport", "= 3.0"
- end
-
- install_gemfile! <<-G
- gem "rails", :git => "#{lib_path("rails")}"
- G
-
- bundle! "update rails"
- expect(the_bundle).to include_gems "rails 3.0", "activesupport 3.0"
- end
-
- it "floats on a branch when :branch is used and the source is specified in the update" do
- build_git "foo", "1.0", :path => lib_path("foo")
- update_git "foo", :branch => "omg", :path => lib_path("foo")
-
- install_gemfile <<-G
- git "#{lib_path("foo")}", :branch => "omg" do
- gem 'foo'
- end
- G
-
- update_git "foo", :branch => "omg", :path => lib_path("foo") do |s|
- s.write "lib/foo.rb", "FOO = '1.1'"
- end
-
- bundle "update --source foo"
-
- expect(the_bundle).to include_gems "foo 1.1"
- end
-
- it "floats on master when updating all gems that are pinned to the source even if you have child dependencies" do
- build_git "foo", :path => lib_path("foo")
- build_gem "bar", :to_bundle => true do |s|
- s.add_dependency "foo"
- end
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo")}"
- gem "bar"
- G
-
- update_git "foo", :path => lib_path("foo") do |s|
- s.write "lib/foo.rb", "FOO = '1.1'"
- end
-
- bundle "update foo"
-
- expect(the_bundle).to include_gems "foo 1.1"
- end
-
- it "notices when you change the repo url in the Gemfile" do
- build_git "foo", :path => lib_path("foo_one")
- build_git "foo", :path => lib_path("foo_two")
-
- install_gemfile <<-G
- gem "foo", "1.0", :git => "#{lib_path("foo_one")}"
- G
-
- FileUtils.rm_rf lib_path("foo_one")
-
- install_gemfile <<-G
- gem "foo", "1.0", :git => "#{lib_path("foo_two")}"
- G
-
- expect(err).to be_empty
- expect(out).to include("Fetching #{lib_path}/foo_two")
- expect(out).to include("Bundle complete!")
- end
-
- it "fetches tags from the remote" do
- build_git "foo"
- @remote = build_git("bar", :bare => true)
- update_git "foo", :remote => file_uri_for(@remote.path)
- update_git "foo", :push => "master"
-
- install_gemfile <<-G
- gem 'foo', :git => "#{@remote.path}"
- G
-
- # Create a new tag on the remote that needs fetching
- update_git "foo", :tag => "fubar"
- update_git "foo", :push => "fubar"
-
- gemfile <<-G
- gem 'foo', :git => "#{@remote.path}", :tag => "fubar"
- G
-
- bundle "update", :all => true
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- describe "with submodules" do
- before :each do
- build_repo4 do
- build_gem "submodule" do |s|
- s.write "lib/submodule.rb", "puts 'GEM'"
- end
- end
-
- build_git "submodule", "1.0" do |s|
- s.write "lib/submodule.rb", "puts 'GIT'"
- end
-
- build_git "has_submodule", "1.0" do |s|
- s.add_dependency "submodule"
- end
-
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
- end
-
- it "it unlocks the source when submodules are added to a git source" do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- git "#{lib_path("has_submodule-1.0")}" do
- gem "has_submodule"
- end
- G
-
- run "require 'submodule'"
- expect(out).to eq("GEM")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo4)}"
- git "#{lib_path("has_submodule-1.0")}", :submodules => true do
- gem "has_submodule"
- end
- G
-
- run "require 'submodule'"
- expect(out).to eq("GIT")
- end
-
- it "unlocks the source when submodules are removed from git source", :git => ">= 2.9.0" do
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- git "#{lib_path("has_submodule-1.0")}", :submodules => true do
- gem "has_submodule"
- end
- G
-
- run! "require 'submodule'"
- expect(out).to eq("GIT")
-
- install_gemfile! <<-G
- source "#{file_uri_for(gem_repo4)}"
- git "#{lib_path("has_submodule-1.0")}" do
- gem "has_submodule"
- end
- G
-
- run! "require 'submodule'"
- expect(out).to eq("GEM")
- end
- end
-
- it "errors with a message when the .git repo is gone" do
- build_git "foo", "1.0"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- lib_path("foo-1.0").join(".git").rmtree
-
- bundle :update, :all => true
- expect(err).to include(lib_path("foo-1.0").to_s).
- and match(/Git error: command `git fetch.+has failed/)
- end
-
- it "should not explode on invalid revision on update of gem by name" do
- build_git "rack", "0.8"
-
- build_git "rack", "0.8", :path => lib_path("local-rack") do |s|
- s.write "lib/rack.rb", "puts :LOCAL"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
- G
-
- bundle %(config set local.rack #{lib_path("local-rack")})
- bundle "update rack"
- expect(out).to include("Bundle updated!")
- end
-
- it "shows the previous version of the gem" do
- build_git "rails", "3.0", :path => lib_path("rails")
-
- install_gemfile <<-G
- gem "rails", :git => "#{lib_path("rails")}"
- G
-
- lockfile <<-G
- GIT
- remote: #{lib_path("rails")}
- specs:
- rails (2.3.2)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rails!
- G
-
- bundle "update", :all => true
- expect(out).to include("Using rails 3.0 (was 2.3.2) from #{lib_path("rails")} (at master@#{revision_for(lib_path("rails"))[0..6]})")
- end
- end
-
- describe "with --source flag" do
- before :each do
- build_repo2
- @git = build_git "foo", :path => lib_path("foo") do |s|
- s.executables = "foobar"
- end
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- git "#{lib_path("foo")}" do
- gem 'foo'
- end
- gem 'rack'
- G
- end
-
- it "updates the source" do
- update_git "foo", :path => @git.path
-
- bundle "update --source foo"
-
- in_app_root do
- run <<-RUBY
- require 'foo'
- puts "WIN" if defined?(FOO_PREV_REF)
- RUBY
-
- expect(out).to eq("WIN")
- end
- end
-
- it "unlocks gems that were originally pulled in by the source" do
- update_git "foo", "2.0", :path => @git.path
-
- bundle "update --source foo"
- expect(the_bundle).to include_gems "foo 2.0"
- end
-
- it "leaves all other gems frozen" do
- update_repo2
- update_git "foo", :path => @git.path
-
- bundle "update --source foo"
- expect(the_bundle).to include_gems "rack 1.0"
- end
- end
-
- context "when the gem and the repository have different names" do
- before :each do
- build_repo2
- @git = build_git "foo", :path => lib_path("bar")
-
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo2)}"
- git "#{lib_path("bar")}" do
- gem 'foo'
- end
- gem 'rack'
- G
- end
-
- it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "< 3" do
- spec_lines = lib_path("bar/foo.gemspec").read.split("\n")
- spec_lines[5] = "s.version = '2.0'"
-
- update_git "foo", "2.0", :path => @git.path do |s|
- s.write "foo.gemspec", spec_lines.join("\n")
- end
-
- ref = @git.ref_for "master"
-
- bundle "update --source bar"
-
- lockfile_should_be <<-G
- GIT
- remote: #{@git.path}
- revision: #{ref}
- specs:
- foo (2.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "3" do
- spec_lines = lib_path("bar/foo.gemspec").read.split("\n")
- spec_lines[5] = "s.version = '2.0'"
-
- update_git "foo", "2.0", :path => @git.path do |s|
- s.write "foo.gemspec", spec_lines.join("\n")
- end
-
- ref = @git.ref_for "master"
-
- bundle "update --source bar"
-
- lockfile_should_be <<-G
- GIT
- remote: #{@git.path}
- revision: #{ref}
- specs:
- foo (2.0)
-
- GEM
- remote: #{file_uri_for(gem_repo2)}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- foo!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
- end
-end
diff --git a/spec/bundler/update/path_spec.rb b/spec/bundler/update/path_spec.rb
deleted file mode 100644
index 38c125e04b..0000000000
--- a/spec/bundler/update/path_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "path sources" do
- describe "bundle update --source" do
- it "shows the previous version of the gem when updated from path source" do
- build_lib "activesupport", "2.3.5", :path => lib_path("rails/activesupport")
-
- install_gemfile <<-G
- gem "activesupport", :path => "#{lib_path("rails/activesupport")}"
- G
-
- build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport")
-
- bundle "update --source activesupport"
- expect(out).to include("Using activesupport 3.0 (was 2.3.5) from source at `#{lib_path("rails/activesupport")}`")
- end
- end
-end
diff --git a/spec/bundler/update/redownload_spec.rb b/spec/bundler/update/redownload_spec.rb
deleted file mode 100644
index b34a02c78c..0000000000
--- a/spec/bundler/update/redownload_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle update" do
- before :each do
- install_gemfile <<-G
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- G
- end
-
- describe "with --force" do
- it "shows a deprecation when single flag passed", :bundler => 2 do
- bundle! "update rack --force"
- expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
-
- it "shows a deprecation when multiple flags passed", :bundler => 2 do
- bundle! "update rack --no-color --force"
- expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
- end
-
- describe "with --redownload" do
- it "does not show a deprecation when single flag passed" do
- bundle! "update rack --redownload"
- expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
-
- it "does not show a deprecation when single multiple flags passed" do
- bundle! "update rack --no-color --redownload"
- expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
- end
-end
diff --git a/spec/mspec/.gitignore b/spec/mspec/.gitignore
new file mode 100644
index 0000000000..5c5ecd9731
--- /dev/null
+++ b/spec/mspec/.gitignore
@@ -0,0 +1,26 @@
+pkg
+*.rbc
+*.iml
+*.iws
+*.ipr
+*.sw?
+
+.rbx
+
+# ctags dir
+/tags
+
+*.gem
+.bundle
+.config
+.yardoc
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
diff --git a/spec/mspec/.travis.yml b/spec/mspec/.travis.yml
new file mode 100644
index 0000000000..73f141d2ae
--- /dev/null
+++ b/spec/mspec/.travis.yml
@@ -0,0 +1,18 @@
+sudo: false
+language: ruby
+before_script:
+ # https://github.com/travis-ci/travis-ci/issues/8408
+ - unset _JAVA_OPTIONS
+script:
+ - bundle exec rspec
+matrix:
+ include:
+ - rvm: 2.2.8
+ - rvm: 2.3.5
+ - rvm: 2.4.2
+ - rvm: ruby-head
+ - jdk: oraclejdk8
+ install:
+ - curl -L https://github.com/graalvm/truffleruby/releases/download/vm-enterprise-0.28/truffleruby-testing-0.28.tar.gz | tar xz
+ - source truffleruby/setup_env
+ - bundle install
diff --git a/spec/mspec/Gemfile.lock b/spec/mspec/Gemfile.lock
index ce0aa98417..d07c04638b 100644
--- a/spec/mspec/Gemfile.lock
+++ b/spec/mspec/Gemfile.lock
@@ -1,8 +1,8 @@
GEM
remote: https://rubygems.org/
specs:
- diff-lcs (1.3)
- rake (10.5.0)
+ diff-lcs (1.2.5)
+ rake (10.4.2)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
@@ -19,3 +19,6 @@ PLATFORMS
DEPENDENCIES
rake (~> 10.0)
rspec (~> 2.14.1)
+
+BUNDLED WITH
+ 1.14.5
diff --git a/spec/mspec/README.md b/spec/mspec/README.md
index e6fe44c6a2..18ca8fcdd3 100644
--- a/spec/mspec/README.md
+++ b/spec/mspec/README.md
@@ -2,14 +2,13 @@
## Overview
-MSpec is a specialized framework that is syntax-compatible with RSpec 2 for
-basic things like `describe`, `it` blocks and `before`, `after` actions.
-MSpec contains additional features that assist in writing specs for
-Ruby implementations in [ruby/spec](https://github.com/ruby/spec).
+MSpec is a specialized framework that is syntax-compatible with RSpec for
+basic things like 'describe', 'it' blocks and 'before', 'after' actions. MSpec
+contains additional features that assist in writing the RubySpecs used by
+multiple Ruby implementations.
MSpec attempts to use the simplest Ruby language features so that beginning
-Ruby implementations can run the Ruby specs. For example, no file from the
-standard library or RubyGems is necessary to run MSpec.
+Ruby implementations can run the Ruby specs.
MSpec is not intended as a replacement for RSpec. MSpec attempts to provide a
subset of RSpec's features in some cases and a superset in others. It does not
@@ -24,6 +23,8 @@ specs in a manner compatible with multiple Ruby implementations.
2. MSpec provides a different shared spec implementation specifically
designed to ease writing specs for the numerous aliased methods in Ruby.
+ The MSpec shared spec implementation should not conflict with RSpec's own
+ shared behavior facility.
3. MSpec provides various helper methods to simplify some specs, for
example, creating temporary file names.
@@ -32,13 +33,9 @@ specs in a manner compatible with multiple Ruby implementations.
configuration facility with a default project file and user-specific
overrides.
- 5. MSpec support "tagging", that is excluding specs known as failing on
- a particular Ruby implementation, and automatically adding and removing tags
- while running the specs.
-
## Requirements
-MSpec requires Ruby 2.4 or more recent.
+MSpec requires Ruby 2.2 or more recent.
## Bundler
@@ -58,7 +55,7 @@ ruby -S bundle install
## Running Specs
Use RSpec to run the MSpec specs. There are no plans currently to make the
-MSpec specs runnable by MSpec: https://github.com/ruby/mspec/issues/19.
+MSpec specs runnable by MSpec.
After installing the gem dependencies, the specs can be run as follows:
@@ -66,21 +63,29 @@ After installing the gem dependencies, the specs can be run as follows:
ruby -S bundle exec rspec
```
+Or
+
+```bash
+ruby -S rake
+```
+
To run an individual spec file, use the following example:
```bash
ruby -S bundle exec rspec spec/helpers/ruby_exe_spec.rb
```
+
## Documentation
-See [CONTRIBUTING.md](https://github.com/ruby/spec/blob/master/CONTRIBUTING.md) in ruby/spec
-for a list of matchers and how to use `mspec`.
+See http://ruby.github.io/rubyspec.github.io/
+
## Source Code
See https://github.com/ruby/mspec
+
## License
See the LICENSE in the source code.
diff --git a/spec/mspec/Rakefile b/spec/mspec/Rakefile
index 6a9de7a95e..0e294cde8e 100644
--- a/spec/mspec/Rakefile
+++ b/spec/mspec/Rakefile
@@ -1,3 +1,4 @@
+require 'bundler/gem_tasks'
require 'bundler/setup'
require 'rspec/core/rake_task'
diff --git a/spec/mspec/lib/mspec.rb b/spec/mspec/lib/mspec.rb
index d24abd96f1..42d590c99a 100644
--- a/spec/mspec/lib/mspec.rb
+++ b/spec/mspec/lib/mspec.rb
@@ -1,4 +1,3 @@
-require 'mspec/utils/format'
require 'mspec/matchers'
require 'mspec/expectations'
require 'mspec/mocks'
@@ -6,3 +5,16 @@ require 'mspec/runner'
require 'mspec/guards'
require 'mspec/helpers'
require 'mspec/version'
+
+# If the implementation on which the specs are run cannot
+# load pp from the standard library, add a pp.rb file that
+# defines the #pretty_inspect method on Object or Kernel.
+begin
+ require 'pp'
+rescue LoadError
+ module Kernel
+ def pretty_inspect
+ inspect
+ end
+ end
+end
diff --git a/spec/mspec/lib/mspec/commands/mkspec.rb b/spec/mspec/lib/mspec/commands/mkspec.rb
index d10cc35d18..7a943aa1fe 100755
--- a/spec/mspec/lib/mspec/commands/mkspec.rb
+++ b/spec/mspec/lib/mspec/commands/mkspec.rb
@@ -19,7 +19,7 @@ class MkSpec
@map = NameMap.new true
end
- def options(argv = ARGV)
+ def options(argv=ARGV)
options = MSpecOptions.new "mkspec [options]", 32
options.on("-c", "--constant", "CONSTANT",
@@ -75,7 +75,7 @@ class MkSpec
parents = '../' * (sub.split('/').length + 1)
File.open(file, 'w') do |f|
- f.puts "require_relative '#{parents}spec_helper'"
+ f.puts "require File.expand_path('../#{parents}spec_helper', __FILE__)"
config[:requires].each do |lib|
f.puts "require '#{lib}'"
end
diff --git a/spec/mspec/lib/mspec/commands/mspec-ci.rb b/spec/mspec/lib/mspec/commands/mspec-ci.rb
index a31db1d7dc..cb0193f42d 100644
--- a/spec/mspec/lib/mspec/commands/mspec-ci.rb
+++ b/spec/mspec/lib/mspec/commands/mspec-ci.rb
@@ -8,7 +8,7 @@ require 'mspec/utils/script'
class MSpecCI < MSpecScript
- def options(argv = ARGV)
+ def options(argv=ARGV)
options = MSpecOptions.new "mspec ci [options] (FILE|DIRECTORY|GLOB)+", 30, config
options.doc " Ask yourself:"
@@ -24,7 +24,6 @@ class MSpecCI < MSpecScript
options.configure { |f| load f }
options.pretend
options.interrupt
- options.timeout
options.doc "\n How to modify the guard behavior"
options.unguarded
diff --git a/spec/mspec/lib/mspec/commands/mspec-run.rb b/spec/mspec/lib/mspec/commands/mspec-run.rb
index 4d8f4d9984..249f9f5771 100644
--- a/spec/mspec/lib/mspec/commands/mspec-run.rb
+++ b/spec/mspec/lib/mspec/commands/mspec-run.rb
@@ -14,7 +14,7 @@ class MSpecRun < MSpecScript
config[:files] = []
end
- def options(argv = ARGV)
+ def options(argv=ARGV)
options = MSpecOptions.new "mspec run [options] (FILE|DIRECTORY|GLOB)+", 30, config
options.doc " Ask yourself:"
@@ -36,7 +36,6 @@ class MSpecRun < MSpecScript
options.repeat
options.pretend
options.interrupt
- options.timeout
options.doc "\n How to modify the guard behavior"
options.unguarded
diff --git a/spec/mspec/lib/mspec/commands/mspec-tag.rb b/spec/mspec/lib/mspec/commands/mspec-tag.rb
index e1d04d1446..8bc3382e91 100644
--- a/spec/mspec/lib/mspec/commands/mspec-tag.rb
+++ b/spec/mspec/lib/mspec/commands/mspec-tag.rb
@@ -15,7 +15,7 @@ class MSpecTag < MSpecScript
config[:ltags] = []
end
- def options(argv = ARGV)
+ def options(argv=ARGV)
options = MSpecOptions.new "mspec tag [options] (FILE|DIRECTORY|GLOB)+", 30, config
options.doc " Ask yourself:"
@@ -33,7 +33,6 @@ class MSpecTag < MSpecScript
options.pretend
options.unguarded
options.interrupt
- options.timeout
options.doc "\n How to display their output"
options.formatters
diff --git a/spec/mspec/lib/mspec/commands/mspec.rb b/spec/mspec/lib/mspec/commands/mspec.rb
index 9d82949ff1..6cb1e87a58 100755
--- a/spec/mspec/lib/mspec/commands/mspec.rb
+++ b/spec/mspec/lib/mspec/commands/mspec.rb
@@ -21,7 +21,7 @@ class MSpecMain < MSpecScript
config[:launch] = []
end
- def options(argv = ARGV)
+ def options(argv=ARGV)
config[:command] = argv.shift if ["ci", "run", "tag"].include?(argv[0])
options = MSpecOptions.new "mspec [COMMAND] [options] (FILE|DIRECTORY|GLOB)+", 30, config
@@ -89,12 +89,72 @@ class MSpecMain < MSpecScript
def register; end
def multi_exec(argv)
+ MSpec.register_files @files
+
require 'mspec/runner/formatters/multi'
- formatter = config_formatter.extend(MultiFormatter)
+ formatter = MultiFormatter.new
+ if config[:formatter]
+ warn "formatter options is ignored due to multi option"
+ end
- require 'mspec/runner/parallel'
+ output_files = []
processes = cores(@files.size)
- ParallelRunner.new(@files, processes, formatter, argv).run
+ children = processes.times.map { |i|
+ name = tmp "mspec-multi-#{i}"
+ output_files << name
+
+ env = {
+ "SPEC_TEMP_DIR" => "rubyspec_temp_#{i}",
+ "MSPEC_MULTI" => i.to_s
+ }
+ command = argv + ["-fy", "-o", name]
+ $stderr.puts "$ #{command.join(' ')}" if $MSPEC_DEBUG
+ IO.popen([env, *command, close_others: false], "rb+")
+ }
+
+ puts children.map { |child| child.gets }.uniq
+ formatter.start
+ last_files = {}
+
+ until @files.empty?
+ IO.select(children)[0].each { |io|
+ reply = io.read(1)
+ case reply
+ when '.'
+ formatter.unload
+ when nil
+ raise "Worker died!"
+ else
+ while chunk = (io.read_nonblock(4096) rescue nil)
+ reply += chunk
+ end
+ reply.chomp!('.')
+ msg = "A child mspec-run process printed unexpected output on STDOUT"
+ if last_file = last_files[io]
+ msg += " while running #{last_file}"
+ end
+ abort "\n#{msg}: #{reply.inspect}"
+ end
+
+ unless @files.empty?
+ file = @files.shift
+ last_files[io] = file
+ io.puts file
+ end
+ }
+ end
+
+ success = true
+ children.each { |child|
+ child.puts "QUIT"
+ _pid, status = Process.wait2(child.pid)
+ success &&= status.success?
+ child.close
+ }
+
+ formatter.aggregate_results(output_files)
+ formatter.finish
+ success
end
def run
diff --git a/spec/mspec/lib/mspec/expectations/expectations.rb b/spec/mspec/lib/mspec/expectations/expectations.rb
index 8d01dc22ab..cfdc2b63a3 100644
--- a/spec/mspec/lib/mspec/expectations/expectations.rb
+++ b/spec/mspec/lib/mspec/expectations/expectations.rb
@@ -7,29 +7,15 @@ class SpecExpectationNotFoundError < StandardError
end
end
-class SkippedSpecError < StandardError
-end
-
class SpecExpectation
def self.fail_with(expected, actual)
expected_to_s = expected.to_s
actual_to_s = actual.to_s
if expected_to_s.size + actual_to_s.size > 80
- message = "#{expected_to_s}\n#{actual_to_s}"
+ message = "#{expected_to_s.chomp}\n#{actual_to_s}"
else
message = "#{expected_to_s} #{actual_to_s}"
end
- raise SpecExpectationNotMetError, message
- end
-
- def self.fail_predicate(receiver, predicate, args, block, result, expectation)
- receiver_to_s = MSpec.format(receiver)
- before_method = predicate.to_s =~ /^[a-z]/ ? "." : " "
- predicate_to_s = "#{before_method}#{predicate}"
- predicate_to_s += " " unless args.empty?
- args_to_s = args.map { |arg| MSpec.format(arg) }.join(', ')
- args_to_s += " { ... }" if block
- result_to_s = MSpec.format(result)
- raise SpecExpectationNotMetError, "Expected #{receiver_to_s}#{predicate_to_s}#{args_to_s}\n#{expectation} but was #{result_to_s}"
+ Kernel.raise SpecExpectationNotMetError, message
end
end
diff --git a/spec/mspec/lib/mspec/expectations/should.rb b/spec/mspec/lib/mspec/expectations/should.rb
index 231ad15c21..f6d83053f5 100644
--- a/spec/mspec/lib/mspec/expectations/should.rb
+++ b/spec/mspec/lib/mspec/expectations/should.rb
@@ -4,26 +4,26 @@ class Object
def should(matcher = NO_MATCHER_GIVEN)
MSpec.expectation
MSpec.actions :expectation, MSpec.current.state
- if NO_MATCHER_GIVEN.equal?(matcher)
- SpecPositiveOperatorMatcher.new(self)
- else
+ unless matcher.equal? NO_MATCHER_GIVEN
unless matcher.matches? self
expected, actual = matcher.failure_message
SpecExpectation.fail_with(expected, actual)
end
+ else
+ SpecPositiveOperatorMatcher.new(self)
end
end
def should_not(matcher = NO_MATCHER_GIVEN)
MSpec.expectation
MSpec.actions :expectation, MSpec.current.state
- if NO_MATCHER_GIVEN.equal?(matcher)
- SpecNegativeOperatorMatcher.new(self)
- else
+ unless matcher.equal? NO_MATCHER_GIVEN
if matcher.matches? self
expected, actual = matcher.negative_failure_message
SpecExpectation.fail_with(expected, actual)
end
+ else
+ SpecNegativeOperatorMatcher.new(self)
end
end
end
diff --git a/spec/mspec/lib/mspec/guards/conflict.rb b/spec/mspec/lib/mspec/guards/conflict.rb
index 4930e5734d..7a27671c1e 100644
--- a/spec/mspec/lib/mspec/guards/conflict.rb
+++ b/spec/mspec/lib/mspec/guards/conflict.rb
@@ -1,12 +1,6 @@
require 'mspec/guards/guard'
-require 'mspec/utils/deprecate'
class ConflictsGuard < SpecGuard
- def initialize(*args)
- MSpec.deprecate 'conflicts_with', 'guard -> { condition } do'
- super(*args)
- end
-
def match?
# Always convert constants to symbols regardless of version.
constants = Object.constants.map { |x| x.to_sym }
diff --git a/spec/mspec/lib/mspec/guards/feature.rb b/spec/mspec/lib/mspec/guards/feature.rb
index d4c6dd1cde..30984e0cc5 100644
--- a/spec/mspec/lib/mspec/guards/feature.rb
+++ b/spec/mspec/lib/mspec/guards/feature.rb
@@ -39,7 +39,3 @@ end
def with_feature(*features, &block)
FeatureGuard.new(*features).run_if(:with_feature, &block)
end
-
-def without_feature(*features, &block)
- FeatureGuard.new(*features).run_unless(:without_feature, &block)
-end
diff --git a/spec/mspec/lib/mspec/guards/platform.rb b/spec/mspec/lib/mspec/guards/platform.rb
index 2d22d4fb59..96176b8753 100644
--- a/spec/mspec/lib/mspec/guards/platform.rb
+++ b/spec/mspec/lib/mspec/guards/platform.rb
@@ -6,8 +6,10 @@ class PlatformGuard < SpecGuard
case name
when :rubinius
RUBY_ENGINE.start_with?('rbx')
- else
+ when :ruby, :jruby, :truffleruby, :ironruby, :macruby, :maglev, :topaz, :opal
RUBY_ENGINE.start_with?(name.to_s)
+ else
+ raise "unknown implementation #{name}"
end
end
end
@@ -16,20 +18,20 @@ class PlatformGuard < SpecGuard
implementation? :ruby
end
- PLATFORM = if RUBY_ENGINE == "jruby"
+ HOST_OS = begin
require 'rbconfig'
- "#{RbConfig::CONFIG['host_cpu']}-#{RbConfig::CONFIG['host_os']}"
- else
+ RbConfig::CONFIG['host_os'] || RUBY_PLATFORM
+ rescue LoadError
RUBY_PLATFORM
- end
+ end.downcase
def self.os?(*oses)
oses.any? do |os|
raise ":java is not a valid OS" if os == :java
if os == :windows
- PLATFORM =~ /(mswin|mingw)/
+ HOST_OS =~ /(mswin|mingw)/
else
- PLATFORM.include?(os.to_s)
+ HOST_OS.include?(os.to_s)
end
end
end
@@ -38,21 +40,8 @@ class PlatformGuard < SpecGuard
os?(:windows)
end
- WORD_SIZE = 1.size * 8
-
- POINTER_SIZE = begin
- require 'rbconfig/sizeof'
- RbConfig::SIZEOF["void*"] * 8
- rescue LoadError
- WORD_SIZE
- end
-
def self.wordsize?(size)
- size == WORD_SIZE
- end
-
- def self.pointer_size?(size)
- size == POINTER_SIZE
+ size == 8 * 1.size
end
def initialize(*args)
@@ -72,8 +61,6 @@ class PlatformGuard < SpecGuard
match &&= PlatformGuard.os?(*value)
when :wordsize
match &&= PlatformGuard.wordsize? value
- when :pointer_size
- match &&= PlatformGuard.pointer_size? value
end
end
match
diff --git a/spec/mspec/lib/mspec/helpers/datetime.rb b/spec/mspec/lib/mspec/helpers/datetime.rb
index 3a40cc0902..1520b971ea 100644
--- a/spec/mspec/lib/mspec/helpers/datetime.rb
+++ b/spec/mspec/lib/mspec/helpers/datetime.rb
@@ -6,7 +6,7 @@
#
# Possible keys are:
# :year, :month, :day, :hour, :minute, :second, :offset and :sg.
-def new_datetime(opts = {})
+def new_datetime(opts={})
require 'date'
value = {
diff --git a/spec/mspec/lib/mspec/helpers/flunk.rb b/spec/mspec/lib/mspec/helpers/flunk.rb
index 84fb3ab39c..68fb3cadac 100644
--- a/spec/mspec/lib/mspec/helpers/flunk.rb
+++ b/spec/mspec/lib/mspec/helpers/flunk.rb
@@ -1,3 +1,3 @@
-def flunk(msg = "This example is a failure")
+def flunk(msg="This example is a failure")
SpecExpectation.fail_with "Failed:", msg
end
diff --git a/spec/mspec/lib/mspec/helpers/frozen_error_class.rb b/spec/mspec/lib/mspec/helpers/frozen_error_class.rb
index 07cc2b4ba2..26788ad9ad 100644
--- a/spec/mspec/lib/mspec/helpers/frozen_error_class.rb
+++ b/spec/mspec/lib/mspec/helpers/frozen_error_class.rb
@@ -2,7 +2,7 @@ require 'mspec/guards/version'
# This helper makes it easy to write version independent
# specs for frozen objects.
-unless respond_to? :frozen_error_class, true
+unless respond_to? :frozen_error_class
ruby_version_is "2.5" do
def frozen_error_class
FrozenError
diff --git a/spec/mspec/lib/mspec/helpers/fs.rb b/spec/mspec/lib/mspec/helpers/fs.rb
index 67453eb302..fb2c0f702c 100644
--- a/spec/mspec/lib/mspec/helpers/fs.rb
+++ b/spec/mspec/lib/mspec/helpers/fs.rb
@@ -1,6 +1,12 @@
# Copies a file
def cp(source, dest)
- IO.copy_stream source, dest
+ File.open(dest, "wb") do |d|
+ File.open(source, "rb") do |s|
+ while data = s.read(1024)
+ d.write data
+ end
+ end
+ end
end
# Creates each directory in path that does not exist.
@@ -55,7 +61,7 @@ end
# Creates a file +name+. Creates the directory for +name+
# if it does not exist.
-def touch(name, mode = "w")
+def touch(name, mode="w")
mkdir_p File.dirname(name)
File.open(name, mode) do |f|
diff --git a/spec/mspec/lib/mspec/helpers/io.rb b/spec/mspec/lib/mspec/helpers/io.rb
index 1938255d1a..57dc0d53a4 100644
--- a/spec/mspec/lib/mspec/helpers/io.rb
+++ b/spec/mspec/lib/mspec/helpers/io.rb
@@ -64,7 +64,9 @@ end
# Creates a "bare" file descriptor (i.e. one that is not associated
# with any Ruby object). The file descriptor can safely be passed
# to IO.new without creating a Ruby object alias to the fd.
-def new_fd(name, mode = "w:utf-8")
+def new_fd(name, mode="w:utf-8")
+ mode = options_or_mode(mode)
+
if mode.kind_of? Hash
if mode.key? :mode
mode = mode[:mode]
@@ -73,19 +75,37 @@ def new_fd(name, mode = "w:utf-8")
end
end
- IO.sysopen name, mode
+ IO.sysopen name, fmode(mode)
end
# Creates an IO instance for a temporary file name. The file
# must be deleted.
-def new_io(name, mode = "w:utf-8")
- if Hash === mode # Avoid kwargs warnings on Ruby 2.7+
- File.new(name, **mode)
+def new_io(name, mode="w:utf-8")
+ IO.new new_fd(name, options_or_mode(mode)), options_or_mode(mode)
+end
+
+# This helper simplifies passing file access modes regardless of
+# whether the :encoding feature is enabled. Only the access specifier
+# itself will be returned if :encoding is not enabled. Otherwise,
+# the full mode string will be returned (i.e. the helper is a no-op).
+def fmode(mode)
+ if FeatureGuard.enabled? :encoding
+ mode
else
- File.new(name, mode)
+ mode.split(':').first
end
end
-def find_unused_fd
- Dir.entries("/dev/fd").map(&:to_i).max + 1
+# This helper simplifies passing file access modes or options regardless of
+# whether the :encoding feature is enabled. Only the access specifier itself
+# will be returned if :encoding is not enabled. Otherwise, the full mode
+# string or option will be returned (i.e. the helper is a no-op).
+def options_or_mode(oom)
+ return fmode(oom) if oom.kind_of? String
+
+ if FeatureGuard.enabled? :encoding
+ oom
+ else
+ fmode(oom[:mode] || "r:utf-8")
+ end
end
diff --git a/spec/mspec/lib/mspec/helpers/numeric.rb b/spec/mspec/lib/mspec/helpers/numeric.rb
index c6c2e82722..312aafae35 100644
--- a/spec/mspec/lib/mspec/helpers/numeric.rb
+++ b/spec/mspec/lib/mspec/helpers/numeric.rb
@@ -8,7 +8,7 @@ def infinity_value
1/0.0
end
-def bignum_value(plus = 0)
+def bignum_value(plus=0)
0x8000_0000_0000_0000 + plus
end
diff --git a/spec/mspec/lib/mspec/helpers/ruby_exe.rb b/spec/mspec/lib/mspec/helpers/ruby_exe.rb
index 6d5470bbb5..f74ed014ce 100644
--- a/spec/mspec/lib/mspec/helpers/ruby_exe.rb
+++ b/spec/mspec/lib/mspec/helpers/ruby_exe.rb
@@ -2,12 +2,11 @@ require 'mspec/guards/platform'
require 'mspec/helpers/tmp'
# The ruby_exe helper provides a wrapper for invoking the
-# same Ruby interpreter with the same flags as the one running
+# same Ruby interpreter with the same falgs as the one running
# the specs and getting the output from running the code.
-#
# If +code+ is a file that exists, it will be run.
-# Otherwise, +code+ will be written to a temporary file and be run.
-# For example:
+# Otherwise, +code+ should be Ruby code that will be run with
+# the -e command line option. For example:
#
# ruby_exe('path/to/some/file.rb')
#
@@ -15,16 +14,24 @@ require 'mspec/helpers/tmp'
#
# `#{RUBY_EXE} 'path/to/some/file.rb'`
#
+# while
+#
+# ruby_exe('puts "hello, world."')
+#
+# will be executed as
+#
+# `#{RUBY_EXE} -e 'puts "hello, world."'`
+#
# The ruby_exe helper also accepts an options hash with three
# keys: :options, :args and :env. For example:
#
# ruby_exe('file.rb', :options => "-w",
-# :args => "arg1 arg2",
+# :args => "> file.txt",
# :env => { :FOO => "bar" })
#
# will be executed as
#
-# `#{RUBY_EXE} -w file.rb arg1 arg2`
+# `#{RUBY_EXE} -w #{'file.rb'} > file.txt`
#
# with access to ENV["FOO"] with value "bar".
#
@@ -42,11 +49,33 @@ require 'mspec/helpers/tmp'
# The RUBY_EXE constant is setup by mspec automatically
# and is used by ruby_exe and ruby_cmd. The mspec runner script
# will set ENV['RUBY_EXE'] to the name of the executable used
-# to invoke the mspec-run script.
+# to invoke the mspec-run script. The value of RUBY_EXE will be
+# constructed as follows:
+#
+# 1. the value of ENV['RUBY_EXE']
+# 2. an explicit value based on RUBY_ENGINE
+# 3. cwd/(RUBY_ENGINE + $(EXEEXT) || $(exeext) || '')
+# 4. $(bindir)/$(RUBY_INSTALL_NAME)
#
# The value will only be used if the file exists and is executable.
-# The flags will then be appended to the resulting value, such that
-# the RUBY_EXE constant contains both the executable and the flags.
+# The flags will then be appended to the resulting value.
+#
+# These 4 ways correspond to the following scenarios:
+#
+# 1. Using the MSpec runner scripts, the name of the
+# executable is explicitly passed by ENV['RUBY_EXE']
+# so there is no ambiguity.
+#
+# Otherwise, if using RSpec (or something else)
+#
+# 2. Running the specs while developing an alternative
+# Ruby implementation. This explicitly names the
+# executable in the development directory based on
+# the value of RUBY_ENGINE.
+# 3. Running the specs within the source directory for
+# some implementation. (E.g. a local build directory.)
+# 4. Running the specs against some installed Ruby
+# implementation.
#
# Additionally, the flags passed to mspec
# (with -T on the command line or in the config with set :flags)
@@ -72,12 +101,12 @@ def ruby_exe_options(option)
end
when :name
require 'rbconfig'
- bin = RUBY_ENGINE + (RbConfig::CONFIG['EXEEXT'] || '')
+ bin = RUBY_ENGINE + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
File.join(".", bin)
when :install_name
require 'rbconfig'
bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
- bin << (RbConfig::CONFIG['EXEEXT'] || '')
+ bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
File.join(RbConfig::CONFIG['bindir'], bin)
end
end
@@ -100,10 +129,6 @@ def resolve_ruby_exe
raise Exception, "Unable to find a suitable ruby executable."
end
-unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
- RUBY_EXE = resolve_ruby_exe
-end
-
def ruby_exe(code = :not_given, opts = {})
if opts[:dir]
raise "ruby_exe(..., dir: dir) is no longer supported, use Dir.chdir"
@@ -155,3 +180,7 @@ def ruby_cmd(code, opts = {})
[RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
end
+
+unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
+ RUBY_EXE = resolve_ruby_exe
+end
diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb
index 1677fb4f14..4e1273dcfe 100644
--- a/spec/mspec/lib/mspec/helpers/tmp.rb
+++ b/spec/mspec/lib/mspec/helpers/tmp.rb
@@ -30,7 +30,7 @@ all specs are cleaning up temporary files:
end
end
-def tmp(name, uniquify = true)
+def tmp(name, uniquify=true)
Dir.mkdir SPEC_TEMP_DIR unless Dir.exist? SPEC_TEMP_DIR
if uniquify and !name.empty?
diff --git a/spec/mspec/lib/mspec/helpers/warning.rb b/spec/mspec/lib/mspec/helpers/warning.rb
index f94551c185..9e093074e5 100644
--- a/spec/mspec/lib/mspec/helpers/warning.rb
+++ b/spec/mspec/lib/mspec/helpers/warning.rb
@@ -1,5 +1,3 @@
-require 'mspec/guards/version'
-
def suppress_warning
verbose = $VERBOSE
$VERBOSE = nil
@@ -7,13 +5,3 @@ def suppress_warning
ensure
$VERBOSE = verbose
end
-
-if ruby_version_is("2.7")
- def suppress_keyword_warning(&block)
- suppress_warning(&block)
- end
-else
- def suppress_keyword_warning
- yield
- end
-end
diff --git a/spec/mspec/lib/mspec/matchers.rb b/spec/mspec/lib/mspec/matchers.rb
index 356e4a9f32..8eab73198a 100644
--- a/spec/mspec/lib/mspec/matchers.rb
+++ b/spec/mspec/lib/mspec/matchers.rb
@@ -25,7 +25,6 @@ require 'mspec/matchers/have_protected_instance_method'
require 'mspec/matchers/have_public_instance_method'
require 'mspec/matchers/have_singleton_method'
require 'mspec/matchers/include'
-require 'mspec/matchers/include_any_of'
require 'mspec/matchers/infinity'
require 'mspec/matchers/match_yaml'
require 'mspec/matchers/raise_error'
@@ -34,4 +33,3 @@ require 'mspec/matchers/output_to_fd'
require 'mspec/matchers/respond_to'
require 'mspec/matchers/signed_zero'
require 'mspec/matchers/block_caller'
-require 'mspec/matchers/skip'
diff --git a/spec/mspec/lib/mspec/matchers/base.rb b/spec/mspec/lib/mspec/matchers/base.rb
index 94d3b71e55..fc2d36c84a 100644
--- a/spec/mspec/lib/mspec/matchers/base.rb
+++ b/spec/mspec/lib/mspec/matchers/base.rb
@@ -10,52 +10,98 @@ class Module
include MSpecMatchers
end
-class SpecPositiveOperatorMatcher < BasicObject
+class SpecPositiveOperatorMatcher
def initialize(actual)
@actual = actual
end
def ==(expected)
- method_missing(:==, expected)
+ unless @actual == expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "to equal #{expected.pretty_inspect}")
+ end
end
- def !=(expected)
- method_missing(:!=, expected)
+ def <(expected)
+ unless @actual < expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "to be less than #{expected.pretty_inspect}")
+ end
+ end
+
+ def <=(expected)
+ unless @actual <= expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "to be less than or equal to #{expected.pretty_inspect}")
+ end
end
- def equal?(expected)
- method_missing(:equal?, expected)
+ def >(expected)
+ unless @actual > expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "to be greater than #{expected.pretty_inspect}")
+ end
+ end
+
+ def >=(expected)
+ unless @actual >= expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "to be greater than or equal to #{expected.pretty_inspect}")
+ end
end
- def method_missing(name, *args, &block)
- result = @actual.__send__(name, *args, &block)
- unless result
- ::SpecExpectation.fail_predicate(@actual, name, args, block, result, "to be truthy")
+ def =~(expected)
+ unless @actual =~ expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "to match #{expected.pretty_inspect}")
end
end
end
-class SpecNegativeOperatorMatcher < BasicObject
+class SpecNegativeOperatorMatcher
def initialize(actual)
@actual = actual
end
def ==(expected)
- method_missing(:==, expected)
+ if @actual == expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "not to equal #{expected.pretty_inspect}")
+ end
end
- def !=(expected)
- method_missing(:!=, expected)
+ def <(expected)
+ if @actual < expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "not to be less than #{expected.pretty_inspect}")
+ end
+ end
+
+ def <=(expected)
+ if @actual <= expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "not to be less than or equal to #{expected.pretty_inspect}")
+ end
end
- def equal?(expected)
- method_missing(:equal?, expected)
+ def >(expected)
+ if @actual > expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "not to be greater than #{expected.pretty_inspect}")
+ end
+ end
+
+ def >=(expected)
+ if @actual >= expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "not to be greater than or equal to #{expected.pretty_inspect}")
+ end
end
- def method_missing(name, *args, &block)
- result = @actual.__send__(name, *args, &block)
- if result
- ::SpecExpectation.fail_predicate(@actual, name, args, block, result, "to be falsy")
+ def =~(expected)
+ if @actual =~ expected
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
+ "not to match #{expected.pretty_inspect}")
end
end
end
diff --git a/spec/mspec/lib/mspec/matchers/be_close.rb b/spec/mspec/lib/mspec/matchers/be_close.rb
index d6a6626f31..8662aabd26 100644
--- a/spec/mspec/lib/mspec/matchers/be_close.rb
+++ b/spec/mspec/lib/mspec/matchers/be_close.rb
@@ -1,6 +1,4 @@
TOLERANCE = 0.00003 unless Object.const_defined?(:TOLERANCE)
-# To account for GC, context switches, other processes, load, etc.
-TIME_TOLERANCE = 20.0 unless Object.const_defined?(:TIME_TOLERANCE)
class BeCloseMatcher
def initialize(expected, tolerance)
@@ -10,7 +8,7 @@ class BeCloseMatcher
def matches?(actual)
@actual = actual
- (@actual - @expected).abs <= @tolerance
+ (@actual - @expected).abs < @tolerance
end
def failure_message
diff --git a/spec/mspec/lib/mspec/matchers/block_caller.rb b/spec/mspec/lib/mspec/matchers/block_caller.rb
index 30fab4fc68..017bce3cb7 100644
--- a/spec/mspec/lib/mspec/matchers/block_caller.rb
+++ b/spec/mspec/lib/mspec/matchers/block_caller.rb
@@ -1,24 +1,22 @@
class BlockingMatcher
def matches?(block)
- t = Thread.new do
+ started = false
+ blocking = true
+
+ thread = Thread.new do
+ started = true
block.call
+
+ blocking = false
end
- loop do
- case t.status
- when "sleep" # blocked
- t.kill
- t.join
- return true
- when false # terminated normally, so never blocked
- t.join
- return false
- when nil # terminated exceptionally
- t.value
- else
- Thread.pass
- end
+ while !started and status = thread.status and status != "sleep"
+ Thread.pass
end
+ thread.kill
+ thread.join
+
+ blocking
end
def failure_message
@@ -31,7 +29,7 @@ class BlockingMatcher
end
module MSpecMatchers
- private def block_caller
+ private def block_caller(timeout = 0.1)
BlockingMatcher.new
end
end
diff --git a/spec/mspec/lib/mspec/matchers/complain.rb b/spec/mspec/lib/mspec/matchers/complain.rb
index 887e72b4b0..4bcb255040 100644
--- a/spec/mspec/lib/mspec/matchers/complain.rb
+++ b/spec/mspec/lib/mspec/matchers/complain.rb
@@ -1,28 +1,17 @@
require 'mspec/helpers/io'
class ComplainMatcher
- def initialize(complaint = nil, options = nil)
- # the proper solution is to use double splat operator e.g.
- # def initialize(complaint = nil, **options)
- # but we are trying to minimize language features required to run MSpec
- if complaint.is_a?(Hash)
- @complaint = nil
- @options = complaint
- else
- @complaint = complaint
- @options = options || {}
- end
+ def initialize(complaint)
+ @complaint = complaint
end
def matches?(proc)
@saved_err = $stderr
@verbose = $VERBOSE
- err = IOStub.new
-
- Thread.current[:in_mspec_complain_matcher] = true
- $stderr = err
- $VERBOSE = @options.key?(:verbose) ? @options[:verbose] : false
begin
+ err = $stderr = IOStub.new
+ $VERBOSE = false
+ Thread.current[:in_mspec_complain_matcher] = true
proc.call
ensure
$VERBOSE = @verbose
@@ -65,7 +54,7 @@ class ComplainMatcher
end
module MSpecMatchers
- private def complain(complaint = nil, options = nil)
- ComplainMatcher.new(complaint, options)
+ private def complain(complaint=nil)
+ ComplainMatcher.new(complaint)
end
end
diff --git a/spec/mspec/lib/mspec/matchers/eql.rb b/spec/mspec/lib/mspec/matchers/eql.rb
index bcab88ebee..a855789550 100644
--- a/spec/mspec/lib/mspec/matchers/eql.rb
+++ b/spec/mspec/lib/mspec/matchers/eql.rb
@@ -9,13 +9,13 @@ class EqlMatcher
end
def failure_message
- ["Expected #{MSpec.format(@actual)}",
- "to have same value and type as #{MSpec.format(@expected)}"]
+ ["Expected #{@actual.pretty_inspect}",
+ "to have same value and type as #{@expected.pretty_inspect}"]
end
def negative_failure_message
- ["Expected #{MSpec.format(@actual)}",
- "not to have same value or type as #{MSpec.format(@expected)}"]
+ ["Expected #{@actual.pretty_inspect}",
+ "not to have same value or type as #{@expected.pretty_inspect}"]
end
end
diff --git a/spec/mspec/lib/mspec/matchers/equal.rb b/spec/mspec/lib/mspec/matchers/equal.rb
index 5ba4856d82..5dc77d27ea 100644
--- a/spec/mspec/lib/mspec/matchers/equal.rb
+++ b/spec/mspec/lib/mspec/matchers/equal.rb
@@ -9,13 +9,13 @@ class EqualMatcher
end
def failure_message
- ["Expected #{MSpec.format(@actual)}",
- "to be identical to #{MSpec.format(@expected)}"]
+ ["Expected #{@actual.pretty_inspect}",
+ "to be identical to #{@expected.pretty_inspect}"]
end
def negative_failure_message
- ["Expected #{MSpec.format(@actual)}",
- "not to be identical to #{MSpec.format(@expected)}"]
+ ["Expected #{@actual.pretty_inspect}",
+ "not to be identical to #{@expected.pretty_inspect}"]
end
end
diff --git a/spec/mspec/lib/mspec/matchers/equal_element.rb b/spec/mspec/lib/mspec/matchers/equal_element.rb
index 8da2567fcf..1e9dfbcca1 100644
--- a/spec/mspec/lib/mspec/matchers/equal_element.rb
+++ b/spec/mspec/lib/mspec/matchers/equal_element.rb
@@ -37,12 +37,12 @@ class EqualElementMatcher
end
def failure_message
- ["Expected #{MSpec.format(@actual)}",
+ ["Expected #{@actual.pretty_inspect}",
"to be a '#{@element}' element with #{attributes_for_failure_message} and #{content_for_failure_message}"]
end
def negative_failure_message
- ["Expected #{MSpec.format(@actual)}",
+ ["Expected #{@actual.pretty_inspect}",
"not to be a '#{@element}' element with #{attributes_for_failure_message} and #{content_for_failure_message}"]
end
diff --git a/spec/mspec/lib/mspec/matchers/have_instance_method.rb b/spec/mspec/lib/mspec/matchers/have_instance_method.rb
index 9a5a31aa0f..636aaf3e47 100644
--- a/spec/mspec/lib/mspec/matchers/have_instance_method.rb
+++ b/spec/mspec/lib/mspec/matchers/have_instance_method.rb
@@ -18,7 +18,7 @@ class HaveInstanceMethodMatcher < MethodMatcher
end
module MSpecMatchers
- private def have_instance_method(method, include_super = true)
+ private def have_instance_method(method, include_super=true)
HaveInstanceMethodMatcher.new method, include_super
end
end
diff --git a/spec/mspec/lib/mspec/matchers/have_method.rb b/spec/mspec/lib/mspec/matchers/have_method.rb
index e962e69e0a..35dae03af0 100644
--- a/spec/mspec/lib/mspec/matchers/have_method.rb
+++ b/spec/mspec/lib/mspec/matchers/have_method.rb
@@ -18,7 +18,7 @@ class HaveMethodMatcher < MethodMatcher
end
module MSpecMatchers
- private def have_method(method, include_super = true)
+ private def have_method(method, include_super=true)
HaveMethodMatcher.new method, include_super
end
end
diff --git a/spec/mspec/lib/mspec/matchers/have_private_instance_method.rb b/spec/mspec/lib/mspec/matchers/have_private_instance_method.rb
index d32db76c6a..4eb7133055 100644
--- a/spec/mspec/lib/mspec/matchers/have_private_instance_method.rb
+++ b/spec/mspec/lib/mspec/matchers/have_private_instance_method.rb
@@ -18,7 +18,7 @@ class HavePrivateInstanceMethodMatcher < MethodMatcher
end
module MSpecMatchers
- private def have_private_instance_method(method, include_super = true)
+ private def have_private_instance_method(method, include_super=true)
HavePrivateInstanceMethodMatcher.new method, include_super
end
end
diff --git a/spec/mspec/lib/mspec/matchers/have_private_method.rb b/spec/mspec/lib/mspec/matchers/have_private_method.rb
index c74165cfc7..3433d982cc 100644
--- a/spec/mspec/lib/mspec/matchers/have_private_method.rb
+++ b/spec/mspec/lib/mspec/matchers/have_private_method.rb
@@ -18,7 +18,7 @@ class HavePrivateMethodMatcher < MethodMatcher
end
module MSpecMatchers
- private def have_private_method(method, include_super = true)
+ private def have_private_method(method, include_super=true)
HavePrivateMethodMatcher.new method, include_super
end
end
diff --git a/spec/mspec/lib/mspec/matchers/have_protected_instance_method.rb b/spec/mspec/lib/mspec/matchers/have_protected_instance_method.rb
index 1deb2f995d..641d4d0dc2 100644
--- a/spec/mspec/lib/mspec/matchers/have_protected_instance_method.rb
+++ b/spec/mspec/lib/mspec/matchers/have_protected_instance_method.rb
@@ -18,7 +18,7 @@ class HaveProtectedInstanceMethodMatcher < MethodMatcher
end
module MSpecMatchers
- private def have_protected_instance_method(method, include_super = true)
+ private def have_protected_instance_method(method, include_super=true)
HaveProtectedInstanceMethodMatcher.new method, include_super
end
end
diff --git a/spec/mspec/lib/mspec/matchers/have_public_instance_method.rb b/spec/mspec/lib/mspec/matchers/have_public_instance_method.rb
index 0e620532c0..501c0a418e 100644
--- a/spec/mspec/lib/mspec/matchers/have_public_instance_method.rb
+++ b/spec/mspec/lib/mspec/matchers/have_public_instance_method.rb
@@ -18,7 +18,7 @@ class HavePublicInstanceMethodMatcher < MethodMatcher
end
module MSpecMatchers
- private def have_public_instance_method(method, include_super = true)
+ private def have_public_instance_method(method, include_super=true)
HavePublicInstanceMethodMatcher.new method, include_super
end
end
diff --git a/spec/mspec/lib/mspec/matchers/have_singleton_method.rb b/spec/mspec/lib/mspec/matchers/have_singleton_method.rb
index b60dd2536b..95d78709ff 100644
--- a/spec/mspec/lib/mspec/matchers/have_singleton_method.rb
+++ b/spec/mspec/lib/mspec/matchers/have_singleton_method.rb
@@ -18,7 +18,7 @@ class HaveSingletonMethodMatcher < MethodMatcher
end
module MSpecMatchers
- private def have_singleton_method(method, include_super = true)
+ private def have_singleton_method(method, include_super=true)
HaveSingletonMethodMatcher.new method, include_super
end
end
diff --git a/spec/mspec/lib/mspec/matchers/include_any_of.rb b/spec/mspec/lib/mspec/matchers/include_any_of.rb
deleted file mode 100644
index ce097ccf0f..0000000000
--- a/spec/mspec/lib/mspec/matchers/include_any_of.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-class IncludeAnyOfMatcher
- def initialize(*expected)
- @expected = expected
- end
-
- def matches?(actual)
- @actual = actual
- @expected.each do |e|
- if @actual.include?(e)
- return true
- end
- end
- return false
- end
-
- def failure_message
- ["Expected #{@actual.inspect}", "to include any of #{@expected.inspect}"]
- end
-
- def negative_failure_message
- ["Expected #{@actual.inspect}", "not to include any of #{@expected.inspect}"]
- end
-end
-
-module MSpecMatchers
- private def include_any_of(*expected)
- IncludeAnyOfMatcher.new(*expected)
- end
-end
diff --git a/spec/mspec/lib/mspec/matchers/method.rb b/spec/mspec/lib/mspec/matchers/method.rb
index 2b54419faa..e8cdfa62ff 100644
--- a/spec/mspec/lib/mspec/matchers/method.rb
+++ b/spec/mspec/lib/mspec/matchers/method.rb
@@ -1,5 +1,5 @@
class MethodMatcher
- def initialize(method, include_super = true)
+ def initialize(method, include_super=true)
@include_super = include_super
@method = method.to_sym
end
diff --git a/spec/mspec/lib/mspec/matchers/output.rb b/spec/mspec/lib/mspec/matchers/output.rb
index 20721df743..b89b6ca0f6 100644
--- a/spec/mspec/lib/mspec/matchers/output.rb
+++ b/spec/mspec/lib/mspec/matchers/output.rb
@@ -61,7 +61,7 @@ class OutputMatcher
end
module MSpecMatchers
- private def output(stdout = nil, stderr = nil)
+ private def output(stdout=nil, stderr=nil)
OutputMatcher.new(stdout, stderr)
end
end
diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb
index 0e57c1b863..2f9afdc687 100644
--- a/spec/mspec/lib/mspec/matchers/raise_error.rb
+++ b/spec/mspec/lib/mspec/matchers/raise_error.rb
@@ -1,3 +1,5 @@
+require 'mspec/utils/deprecate'
+
class RaiseErrorMatcher
def initialize(exception, message, &block)
@exception = exception
@@ -12,9 +14,6 @@ class RaiseErrorMatcher
rescue Exception => actual
@actual = actual
if matching_exception?(actual)
- # The block has its own expectations and will throw an exception if it fails
- @block[actual] if @block
-
return true
else
raise actual
@@ -23,7 +22,6 @@ class RaiseErrorMatcher
def matching_exception?(exc)
return false unless @exception === exc
-
if @message then
case @message
when String
@@ -33,6 +31,9 @@ class RaiseErrorMatcher
end
end
+ # The block has its own expectations and will throw an exception if it fails
+ @block[exc] if @block
+
return true
end
@@ -52,13 +53,19 @@ class RaiseErrorMatcher
exception_class_and_message(exception.class, exception.message)
end
+ def format_result(result)
+ result.pretty_inspect.chomp
+ rescue => e
+ "#pretty_inspect raised #{e.class}; A #<#{result.class}>"
+ end
+
def failure_message
message = ["Expected #{format_expected_exception}"]
if @actual
message << "but got #{format_exception(@actual)}"
else
- message << "but no exception was raised (#{MSpec.format(@result)} was returned)"
+ message << "but no exception was raised (#{format_result(@result)} was returned)"
end
message
@@ -74,7 +81,7 @@ class RaiseErrorMatcher
end
module MSpecMatchers
- private def raise_error(exception = Exception, message = nil, &block)
+ private def raise_error(exception=Exception, message=nil, &block)
RaiseErrorMatcher.new(exception, message, &block)
end
end
diff --git a/spec/mspec/lib/mspec/matchers/skip.rb b/spec/mspec/lib/mspec/matchers/skip.rb
deleted file mode 100644
index 7c175d358d..0000000000
--- a/spec/mspec/lib/mspec/matchers/skip.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module MSpecMatchers
- private def skip(reason = 'no reason')
- raise SkippedSpecError, reason
- end
-end
diff --git a/spec/mspec/lib/mspec/mocks/mock.rb b/spec/mspec/lib/mspec/mocks/mock.rb
index bce41b630f..b11d469186 100644
--- a/spec/mspec/lib/mspec/mocks/mock.rb
+++ b/spec/mspec/lib/mspec/mocks/mock.rb
@@ -48,17 +48,12 @@ module Mock
end
end
- def self.install_method(obj, sym, type = nil)
+ def self.install_method(obj, sym, type=nil)
meta = obj.singleton_class
key = replaced_key obj, sym
sym = sym.to_sym
- if type == :stub and mocks.key?(key)
- # Defining a stub and there is already a mock, ignore the stub
- return
- end
-
if (sym == :respond_to? or mock_respond_to?(obj, sym, true)) and !replaced?(key.first)
meta.__send__ :alias_method, key.first, sym
end
@@ -78,11 +73,6 @@ module Mock
MSpec.actions :expectation, MSpec.current.state
end
- if proxy.mock? and stubs.key?(key)
- # Defining a mock and there is already a stub, remove the stub
- stubs.delete key
- end
-
if proxy.stub?
stubs[key].unshift proxy
else
@@ -97,10 +87,6 @@ module Mock
obj.instance_variable_get(:@name) || obj.inspect
end
- def self.inspect_args(args)
- "(#{Array(args).map(&:inspect).join(', ')})"
- end
-
def self.verify_count
mocks.each do |key, proxies|
obj = objects[key]
@@ -120,7 +106,7 @@ module Mock
end
unless pass
SpecExpectation.fail_with(
- "Mock '#{name_or_inspect obj}' expected to receive #{key.last}#{inspect_args proxy.arguments} " + \
+ "Mock '#{name_or_inspect obj}' expected to receive '#{key.last}' " + \
"#{qualifier.to_s.sub('_', ' ')} #{count} times",
"but received it #{proxy.calls} times")
end
@@ -134,7 +120,7 @@ module Mock
key = replaced_key obj, sym
[mocks, stubs].each do |proxies|
- proxies.fetch(key, []).each do |proxy|
+ proxies[key].each do |proxy|
pass = case proxy.arguments
when :any_args
true
@@ -180,7 +166,7 @@ module Mock
mock_respond_to? obj, *args
else
SpecExpectation.fail_with("Mock '#{name_or_inspect obj}': method #{sym}\n",
- "called with unexpected arguments #{inspect_args compare}")
+ "called with unexpected arguments (#{Array(compare).join(' ')})")
end
end
diff --git a/spec/mspec/lib/mspec/mocks/object.rb b/spec/mspec/lib/mspec/mocks/object.rb
index fcaa1caef0..19a50ac4e1 100644
--- a/spec/mspec/lib/mspec/mocks/object.rb
+++ b/spec/mspec/lib/mspec/mocks/object.rb
@@ -15,7 +15,7 @@ class Object
end
end
-def mock(name, options = {})
+def mock(name, options={})
MockObject.new name, options
end
@@ -23,6 +23,6 @@ def mock_int(val)
MockIntObject.new(val)
end
-def mock_numeric(name, options = {})
+def mock_numeric(name, options={})
NumericMockObject.new name, options
end
diff --git a/spec/mspec/lib/mspec/mocks/proxy.rb b/spec/mspec/lib/mspec/mocks/proxy.rb
index 8473132b0b..f5acc89d62 100644
--- a/spec/mspec/lib/mspec/mocks/proxy.rb
+++ b/spec/mspec/lib/mspec/mocks/proxy.rb
@@ -1,5 +1,5 @@
class MockObject
- def initialize(name, options = {})
+ def initialize(name, options={})
@name = name
@null = options[:null_object]
end
@@ -11,7 +11,7 @@ class MockObject
end
class NumericMockObject < Numeric
- def initialize(name, options = {})
+ def initialize(name, options={})
@name = name
@null = options[:null_object]
end
@@ -50,7 +50,7 @@ end
class MockProxy
attr_reader :raising, :yielding
- def initialize(type = nil)
+ def initialize(type=nil)
@multiple_returns = nil
@returning = nil
@raising = nil
diff --git a/spec/mspec/lib/mspec/runner/actions/constants_leak_checker.rb b/spec/mspec/lib/mspec/runner/actions/constants_leak_checker.rb
deleted file mode 100644
index fd0a3efe14..0000000000
--- a/spec/mspec/lib/mspec/runner/actions/constants_leak_checker.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-class ConstantsLockFile
- LOCK_FILE_NAME = '.mspec.constants'
-
- def self.load
- if File.exist?(LOCK_FILE_NAME)
- File.readlines(LOCK_FILE_NAME).map(&:chomp)
- else
- []
- end
- end
-
- def self.dump(ary)
- contents = ary.map(&:to_s).uniq.sort.join("\n") + "\n"
- File.write(LOCK_FILE_NAME, contents)
- end
-end
-
-class ConstantLeakError < StandardError
-end
-
-class ConstantsLeakCheckerAction
- def initialize(save)
- @save = save
- @check = !save
- @constants_locked = ConstantsLockFile.load
- @exclude_patterns = MSpecScript.get(:toplevel_constants_excludes) || []
- end
-
- def register
- MSpec.register :start, self
- MSpec.register :before, self
- MSpec.register :after, self
- MSpec.register :finish, self
- end
-
- def start
- @constants_start = constants_now
- end
-
- def before(state)
- @constants_before = constants_now
- end
-
- def after(state)
- constants = remove_excludes(constants_now - @constants_before - @constants_locked)
-
- if @check && !constants.empty?
- MSpec.protect 'Constants leak check' do
- raise ConstantLeakError, "Top level constants leaked: #{constants.join(', ')}"
- end
- end
- end
-
- def finish
- constants = remove_excludes(constants_now - @constants_start - @constants_locked)
-
- if @save
- ConstantsLockFile.dump(@constants_locked + constants)
- end
-
- if @check && !constants.empty?
- MSpec.protect 'Global constants leak check' do
- raise ConstantLeakError, "Top level constants leaked in the whole test suite: #{constants.join(', ')}"
- end
- end
- end
-
- private
-
- def constants_now
- Object.constants.map(&:to_s)
- end
-
- def remove_excludes(constants)
- constants.reject { |name|
- @exclude_patterns.any? { |pattern| pattern === name }
- }
- end
-end
diff --git a/spec/mspec/lib/mspec/runner/actions/filter.rb b/spec/mspec/lib/mspec/runner/actions/filter.rb
index b0ad7080da..35899c8dc8 100644
--- a/spec/mspec/lib/mspec/runner/actions/filter.rb
+++ b/spec/mspec/lib/mspec/runner/actions/filter.rb
@@ -10,7 +10,7 @@ require 'mspec/runner/filters/match'
# trigger the action.
class ActionFilter
- def initialize(tags = nil, descs = nil)
+ def initialize(tags=nil, descs=nil)
@tags = Array(tags)
descs = Array(descs)
@sfilter = descs.empty? ? nil : MatchFilter.new(nil, *descs)
diff --git a/spec/mspec/lib/mspec/runner/actions/leakchecker.rb b/spec/mspec/lib/mspec/runner/actions/leakchecker.rb
index f70799d904..ec17a156bf 100644
--- a/spec/mspec/lib/mspec/runner/actions/leakchecker.rb
+++ b/spec/mspec/lib/mspec/runner/actions/leakchecker.rb
@@ -24,12 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-class LeakError < StandardError
-end
-
class LeakChecker
- attr_reader :leaks
-
def initialize
@fd_info = find_fds
@tempfile_info = find_tempfiles
@@ -39,18 +34,19 @@ class LeakChecker
@encoding_info = find_encodings
end
- def check(state)
- @state = state
- @leaks = []
- check_fd_leak
- check_tempfile_leak
- check_thread_leak
- check_process_leak
- check_env
- check_argv
- check_encodings
- GC.start if !@leaks.empty?
- @leaks.empty?
+ def check(test_name)
+ @no_leaks = true
+ leaks = [
+ check_fd_leak(test_name),
+ check_tempfile_leak(test_name),
+ check_thread_leak(test_name),
+ check_process_leak(test_name),
+ check_env(test_name),
+ check_argv(test_name),
+ check_encodings(test_name)
+ ]
+ GC.start if leaks.any?
+ return leaks.none?
end
private
@@ -70,7 +66,8 @@ class LeakChecker
end
end
- def check_fd_leak
+ def check_fd_leak(test_name)
+ leaked = false
live1 = @fd_info
if IO.respond_to?(:console) and (m = IO.method(:console)).arity.nonzero?
m[:close]
@@ -79,11 +76,12 @@ class LeakChecker
fd_closed = live1 - live2
if !fd_closed.empty?
fd_closed.each {|fd|
- leak "Closed file descriptor: #{fd}"
+ puts "Closed file descriptor: #{test_name}: #{fd}"
}
end
fd_leaked = live2 - live1
if !fd_leaked.empty?
+ leaked = true
h = {}
ObjectSpace.each_object(IO) {|io|
inspect = io.inspect
@@ -107,18 +105,19 @@ class LeakChecker
str << s
}
end
- leak "Leaked file descriptor: #{fd}#{str}"
+ puts "Leaked file descriptor: #{test_name}: #{fd}#{str}"
}
#system("lsof -p #$$") if !fd_leaked.empty?
h.each {|fd, list|
next if list.length <= 1
if 1 < list.count {|io, autoclose, inspect| autoclose }
str = list.map {|io, autoclose, inspect| " #{inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join
- leak "Multiple autoclose IO object for a file descriptor:#{str}"
+ puts "Multiple autoclose IO object for a file descriptor:#{str}"
end
}
end
@fd_info = live2
+ return leaked
end
def extend_tempfile_counter
@@ -141,7 +140,7 @@ class LeakChecker
end
end
- def find_tempfiles(prev_count = -1)
+ def find_tempfiles(prev_count=-1)
return [prev_count, []] unless defined? Tempfile
extend_tempfile_counter
count = TempfileCounter.count
@@ -153,19 +152,22 @@ class LeakChecker
end
end
- def check_tempfile_leak
+ def check_tempfile_leak(test_name)
return false unless defined? Tempfile
count1, initial_tempfiles = @tempfile_info
count2, current_tempfiles = find_tempfiles(count1)
+ leaked = false
tempfiles_leaked = current_tempfiles - initial_tempfiles
if !tempfiles_leaked.empty?
+ leaked = true
list = tempfiles_leaked.map {|t| t.inspect }.sort
list.each {|str|
- leak "Leaked tempfile: #{str}"
+ puts "Leaked tempfile: #{test_name}: #{str}"
}
tempfiles_leaked.each {|t| t.close! }
end
@tempfile_info = [count2, initial_tempfiles]
+ return leaked
end
def find_threads
@@ -174,98 +176,108 @@ class LeakChecker
}
end
- def check_thread_leak
+ def check_thread_leak(test_name)
live1 = @thread_info
live2 = find_threads
thread_finished = live1 - live2
+ leaked = false
if !thread_finished.empty?
list = thread_finished.map {|t| t.inspect }.sort
list.each {|str|
- leak "Finished thread: #{str}"
+ puts "Finished thread: #{test_name}: #{str}"
}
end
thread_leaked = live2 - live1
if !thread_leaked.empty?
+ leaked = true
list = thread_leaked.map {|t| t.inspect }.sort
list.each {|str|
- leak "Leaked thread: #{str}"
+ puts "Leaked thread: #{test_name}: #{str}"
}
end
@thread_info = live2
+ return leaked
end
- def check_process_leak
+ def check_process_leak(test_name)
subprocesses_leaked = Process.waitall
subprocesses_leaked.each { |pid, status|
- leak "Leaked subprocess: #{pid}: #{status}"
+ puts "Leaked subprocess: #{pid}: #{status}"
}
+ return !subprocesses_leaked.empty?
end
def find_env
ENV.to_h
end
- def check_env
+ def check_env(test_name)
old_env = @env_info
new_env = find_env
- return if old_env == new_env
-
+ return false if old_env == new_env
(old_env.keys | new_env.keys).sort.each {|k|
if old_env.has_key?(k)
if new_env.has_key?(k)
if old_env[k] != new_env[k]
- leak "Environment variable changed : #{k.inspect} changed : #{old_env[k].inspect} -> #{new_env[k].inspect}"
+ puts "Environment variable changed: #{test_name} : #{k.inspect} changed : #{old_env[k].inspect} -> #{new_env[k].inspect}"
end
else
- leak "Environment variable changed: #{k.inspect} deleted"
+ puts "Environment variable changed: #{test_name} : #{k.inspect} deleted"
end
else
if new_env.has_key?(k)
- leak "Environment variable changed: #{k.inspect} added"
+ puts "Environment variable changed: #{test_name} : #{k.inspect} added"
else
flunk "unreachable"
end
end
}
@env_info = new_env
+ return true
end
def find_argv
ARGV.map { |e| e.dup }
end
- def check_argv
+ def check_argv(test_name)
old_argv = @argv_info
new_argv = find_argv
+ leaked = false
if new_argv != old_argv
- leak "ARGV changed: #{old_argv.inspect} to #{new_argv.inspect}"
+ puts "ARGV changed: #{test_name} : #{old_argv.inspect} to #{new_argv.inspect}"
@argv_info = new_argv
+ leaked = true
end
+ return leaked
end
def find_encodings
[Encoding.default_internal, Encoding.default_external]
end
- def check_encodings
+ def check_encodings(test_name)
old_internal, old_external = @encoding_info
new_internal, new_external = find_encodings
+ leaked = false
if new_internal != old_internal
- leak "Encoding.default_internal changed: #{old_internal.inspect} to #{new_internal.inspect}"
+ leaked = true
+ puts "Encoding.default_internal changed: #{test_name} : #{old_internal.inspect} to #{new_internal.inspect}"
end
if new_external != old_external
- leak "Encoding.default_external changed: #{old_external.inspect} to #{new_external.inspect}"
+ leaked = true
+ puts "Encoding.default_external changed: #{test_name} : #{old_external.inspect} to #{new_external.inspect}"
end
@encoding_info = [new_internal, new_external]
+ return leaked
end
- def leak(message)
- if @leaks.empty?
- $stderr.puts "\n"
- $stderr.puts @state.description
+ def puts(*args)
+ if @no_leaks
+ @no_leaks = false
+ print "\n"
end
- @leaks << message
- $stderr.puts message
+ super(*args)
end
end
@@ -280,14 +292,9 @@ class LeakCheckerAction
end
def after(state)
- unless @checker.check(state)
- leak_messages = @checker.leaks
- location = state.description
+ unless @checker.check(state.description)
if state.example
- location = "#{location}\n#{state.example.source_location.join(':')}"
- end
- MSpec.protect(location) do
- raise LeakError, leak_messages.join("\n")
+ puts state.example.source_location.join(':')
end
end
end
diff --git a/spec/mspec/lib/mspec/runner/actions/profile.rb b/spec/mspec/lib/mspec/runner/actions/profile.rb
deleted file mode 100644
index c743d6e3e8..0000000000
--- a/spec/mspec/lib/mspec/runner/actions/profile.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-class ProfileAction
- def initialize
- @describe_name = nil
- @describe_time = nil
- @describes = []
- @its = []
- end
-
- def register
- MSpec.register :enter, self
- MSpec.register :before,self
- MSpec.register :after, self
- MSpec.register :finish,self
- end
-
- def enter(describe)
- if @describe_time
- @describes << [@describe_name, now - @describe_time]
- end
-
- @describe_name = describe
- @describe_time = now
- end
-
- def before(state)
- @it_name = state.it
- @it_time = now
- end
-
- def after(state = nil)
- @its << [@describe_name, @it_name, now - @it_time]
- end
-
- def finish
- puts "\nProfiling info:"
-
- desc = @describes.sort { |a,b| b.last <=> a.last }
- desc.delete_if { |a| a.last <= 0.001 }
- show = desc[0, 100]
-
- puts "Top #{show.size} describes:"
-
- show.each do |des, time|
- printf "%3.3f - %s\n", time, des
- end
-
- its = @its.sort { |a,b| b.last <=> a.last }
- its.delete_if { |a| a.last <= 0.001 }
- show = its[0, 100]
-
- puts "\nTop #{show.size} its:"
- show.each do |des, it, time|
- printf "%3.3f - %s %s\n", time, des, it
- end
- end
-
- def now
- Time.now.to_f
- end
-end
diff --git a/spec/mspec/lib/mspec/runner/actions/tag.rb b/spec/mspec/lib/mspec/runner/actions/tag.rb
index d40d562451..760152b2a3 100644
--- a/spec/mspec/lib/mspec/runner/actions/tag.rb
+++ b/spec/mspec/lib/mspec/runner/actions/tag.rb
@@ -22,7 +22,7 @@ require 'mspec/runner/actions/filter'
# spec description strings
class TagAction < ActionFilter
- def initialize(action, outcome, tag, comment, tags = nil, descs = nil)
+ def initialize(action, outcome, tag, comment, tags=nil, descs=nil)
super tags, descs
@action = action
@outcome = outcome
diff --git a/spec/mspec/lib/mspec/runner/actions/taglist.rb b/spec/mspec/lib/mspec/runner/actions/taglist.rb
index 3097e655d5..c1aba53794 100644
--- a/spec/mspec/lib/mspec/runner/actions/taglist.rb
+++ b/spec/mspec/lib/mspec/runner/actions/taglist.rb
@@ -4,7 +4,7 @@ require 'mspec/runner/actions/filter'
# tagged with +tags+. If +tags+ is an empty list, prints out
# descriptions for any specs that are tagged.
class TagListAction
- def initialize(tags = nil)
+ def initialize(tags=nil)
@tags = tags.nil? || tags.empty? ? nil : Array(tags)
@filter = nil
end
diff --git a/spec/mspec/lib/mspec/runner/actions/tally.rb b/spec/mspec/lib/mspec/runner/actions/tally.rb
index d6ada53bab..33f937293c 100644
--- a/spec/mspec/lib/mspec/runner/actions/tally.rb
+++ b/spec/mspec/lib/mspec/runner/actions/tally.rb
@@ -5,31 +5,31 @@ class Tally
@files = @examples = @expectations = @failures = @errors = @guards = @tagged = 0
end
- def files!(add = 1)
+ def files!(add=1)
@files += add
end
- def examples!(add = 1)
+ def examples!(add=1)
@examples += add
end
- def expectations!(add = 1)
+ def expectations!(add=1)
@expectations += add
end
- def failures!(add = 1)
+ def failures!(add=1)
@failures += add
end
- def errors!(add = 1)
+ def errors!(add=1)
@errors += add
end
- def guards!(add = 1)
+ def guards!(add=1)
@guards += add
end
- def tagged!(add = 1)
+ def tagged!(add=1)
@tagged += add
end
diff --git a/spec/mspec/lib/mspec/runner/actions/timeout.rb b/spec/mspec/lib/mspec/runner/actions/timeout.rb
deleted file mode 100644
index 03fe14811f..0000000000
--- a/spec/mspec/lib/mspec/runner/actions/timeout.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-class TimeoutAction
- def initialize(timeout)
- @timeout = timeout
- @queue = Queue.new
- @started = now
- end
-
- def register
- MSpec.register :start, self
- MSpec.register :before, self
- MSpec.register :finish, self
- end
-
- private def now
- Process.clock_gettime(Process::CLOCK_MONOTONIC)
- end
-
- private def fetch_item
- @queue.pop(true)
- rescue ThreadError
- nil
- end
-
- def start
- @thread = Thread.new do
- loop do
- if action = fetch_item
- action.call
- else
- wakeup_at = @started + @timeout
- left = wakeup_at - now
- sleep left if left > 0
- Thread.pass # Let the main thread run
-
- if @queue.empty?
- elapsed = now - @started
- if elapsed > @timeout
- STDERR.puts "\n#{@current_state.description}"
- STDERR.flush
- abort "Example took #{now - @started}s, which is longer than the timeout of #{@timeout}s"
- end
- end
- end
- end
- end
- end
-
- def before(state = nil)
- time = now
- @queue << -> do
- @current_state = state
- @started = time
- end
- end
-
- def finish
- @thread.kill
- @thread.join
- end
-end
diff --git a/spec/mspec/lib/mspec/runner/context.rb b/spec/mspec/lib/mspec/runner/context.rb
index 5f6c9c8ae9..30d8a4ad1b 100644
--- a/spec/mspec/lib/mspec/runner/context.rb
+++ b/spec/mspec/lib/mspec/runner/context.rb
@@ -12,7 +12,7 @@
class ContextState
attr_reader :state, :parent, :parents, :children, :examples, :to_s
- def initialize(mod, options = nil)
+ def initialize(mod, options=nil)
@to_s = mod.to_s
if options.is_a? Hash
@options = options
@@ -174,7 +174,7 @@ class ContextState
# so that exceptions are handled and tallied. Returns true and does
# NOT evaluate any blocks if +check+ is true and
# <tt>MSpec.mode?(:pretend)</tt> is true.
- def protect(what, blocks, check = true)
+ def protect(what, blocks, check=true)
return true if check and MSpec.mode? :pretend
Array(blocks).all? { |block| MSpec.protect what, &block }
end
@@ -214,7 +214,7 @@ class ContextState
if example
passed = protect nil, example
MSpec.actions :example, state, example
- protect nil, @expectation_missing if !MSpec.expectation? and passed
+ protect nil, @expectation_missing unless MSpec.expectation? or !passed
end
end
protect "after :each", post(:each)
diff --git a/spec/mspec/lib/mspec/runner/evaluate.rb b/spec/mspec/lib/mspec/runner/evaluate.rb
index 396a84c118..ecf7460a90 100644
--- a/spec/mspec/lib/mspec/runner/evaluate.rb
+++ b/spec/mspec/lib/mspec/runner/evaluate.rb
@@ -19,7 +19,7 @@ class SpecEvaluate
# single quotes to set if off from the rest of the description string. If
# the source does contain newline characters, sets the indent level to four
# characters.
- def format(ruby, newline = true)
+ def format(ruby, newline=true)
if ruby.include?("\n")
lines = ruby.each_line.to_a
if /( *)/ =~ lines.first
@@ -49,6 +49,6 @@ class SpecEvaluate
end
end
-def evaluate(str, desc = nil, &block)
+def evaluate(str, desc=nil, &block)
SpecEvaluate.new(str, desc).define(&block)
end
diff --git a/spec/mspec/lib/mspec/runner/example.rb b/spec/mspec/lib/mspec/runner/example.rb
index 82feba0b03..19eb29b079 100644
--- a/spec/mspec/lib/mspec/runner/example.rb
+++ b/spec/mspec/lib/mspec/runner/example.rb
@@ -5,7 +5,7 @@ require 'mspec/runner/mspec'
class ExampleState
attr_reader :context, :it, :example
- def initialize(context, it, example = nil)
+ def initialize(context, it, example=nil)
@context = context
@it = it
@example = example
diff --git a/spec/mspec/lib/mspec/runner/filters/regexp.rb b/spec/mspec/lib/mspec/runner/filters/regexp.rb
index 097ec6a755..2bd1448d3f 100644
--- a/spec/mspec/lib/mspec/runner/filters/regexp.rb
+++ b/spec/mspec/lib/mspec/runner/filters/regexp.rb
@@ -1,23 +1,7 @@
-class RegexpFilter
- def initialize(what, *regexps)
- @what = what
- @regexps = to_regexp(*regexps)
- end
-
- def ===(string)
- @regexps.any? { |regexp| regexp === string }
- end
-
- def register
- MSpec.register @what, self
- end
-
- def unregister
- MSpec.unregister @what, self
- end
+require 'mspec/runner/filters/match'
- def to_regexp(*regexps)
- regexps.map { |str| Regexp.new str }
+class RegexpFilter < MatchFilter
+ def to_regexp(*strings)
+ strings.map { |str| Regexp.new str }
end
- private :to_regexp
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/base.rb b/spec/mspec/lib/mspec/runner/formatters/base.rb
deleted file mode 100644
index 6c075c4d0a..0000000000
--- a/spec/mspec/lib/mspec/runner/formatters/base.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-require 'mspec/expectations/expectations'
-require 'mspec/runner/actions/timer'
-require 'mspec/runner/actions/tally'
-
-if ENV['CHECK_LEAKS']
- require 'mspec/runner/actions/leakchecker'
- require 'mspec/runner/actions/constants_leak_checker'
-end
-
-class BaseFormatter
- attr_reader :exceptions, :timer, :tally
-
- def initialize(out = nil)
- @current_state = nil
- @exception = false
- @failure = false
- @exceptions = []
-
- @count = 0 # For subclasses
-
- if out.nil?
- @out = $stdout
- else
- @out = File.open out, "w"
- end
- end
-
- # Creates the +TimerAction+ and +TallyAction+ instances and registers them.
- def register
- (@timer = TimerAction.new).register
- (@tally = TallyAction.new).register
- @counter = @tally.counter
-
- if ENV['CHECK_LEAKS']
- save = ENV['CHECK_LEAKS'] == 'save'
- LeakCheckerAction.new.register
- ConstantsLeakCheckerAction.new(save).register
- end
-
- MSpec.register :abort, self
- MSpec.register :before, self
- MSpec.register :after, self
- MSpec.register :exception, self
- MSpec.register :finish, self
- end
-
- def abort
- if @current_state
- puts "\naborting example: #{@current_state.description}"
- end
- end
-
- # Returns true if any exception is raised while running
- # an example. This flag is reset before each example
- # is evaluated.
- def exception?
- @exception
- end
-
- # Returns true if all exceptions during the evaluation
- # of an example are failures rather than errors. See
- # <tt>ExceptionState#failure</tt>. This flag is reset
- # before each example is evaluated.
- def failure?
- @failure
- end
-
- # Callback for the MSpec :before event. Resets the
- # +#exception?+ and +#failure+ flags.
- def before(state = nil)
- @current_state = state
- @failure = @exception = false
- end
-
- # Callback for the MSpec :exception event. Stores the
- # +ExceptionState+ object to generate the list of backtraces
- # after all the specs are run. Also updates the internal
- # +#exception?+ and +#failure?+ flags.
- def exception(exception)
- @count += 1
- @failure = @exception ? @failure && exception.failure? : exception.failure?
- @exception = true
- @exceptions << exception
- end
-
- # Callback for the MSpec :after event.
- def after(state = nil)
- @current_state = nil
- end
-
- # Callback for the MSpec :start event. Calls :after event.
- # Defined here, in the base class, and used by MultiFormatter.
- def start
- after
- end
-
- # Callback for the MSpec :unload event. Calls :after event.
- # Defined here, in the base class, and used by MultiFormatter.
- def unload
- after
- end
-
- # Callback for the MSpec :finish event. Prints a description
- # and backtrace for every exception that occurred while
- # evaluating the examples.
- def finish
- print "\n"
- count = 0
- @exceptions.each do |exc|
- count += 1
- print_exception(exc, count)
- end
- print "\n#{@timer.format}\n\n#{@tally.format}\n"
- end
-
- def print_exception(exc, count)
- outcome = exc.failure? ? "FAILED" : "ERROR"
- print "\n#{count})\n#{exc.description} #{outcome}\n"
- print exc.message, "\n"
- print exc.backtrace, "\n"
- end
-
- # A convenience method to allow printing to different outputs.
- def print(*args)
- @out.print(*args)
- @out.flush
- end
-end
diff --git a/spec/mspec/lib/mspec/runner/formatters/describe.rb b/spec/mspec/lib/mspec/runner/formatters/describe.rb
index fc4122d13b..176bd79279 100644
--- a/spec/mspec/lib/mspec/runner/formatters/describe.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/describe.rb
@@ -1,4 +1,5 @@
require 'mspec/runner/formatters/dotted'
+require 'mspec/runner/actions/tally'
class DescribeFormatter < DottedFormatter
# Callback for the MSpec :finish event. Prints a summary of
diff --git a/spec/mspec/lib/mspec/runner/formatters/dotted.rb b/spec/mspec/lib/mspec/runner/formatters/dotted.rb
index 672cdf81dc..61c8e4c27c 100644
--- a/spec/mspec/lib/mspec/runner/formatters/dotted.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/dotted.rb
@@ -1,9 +1,77 @@
-require 'mspec/runner/formatters/base'
+require 'mspec/expectations/expectations'
+require 'mspec/runner/actions/timer'
+require 'mspec/runner/actions/tally'
+require 'mspec/runner/actions/leakchecker' if ENV['CHECK_LEAKS']
-class DottedFormatter < BaseFormatter
+class DottedFormatter
+ attr_reader :exceptions, :timer, :tally
+
+ def initialize(out=nil)
+ @exception = @failure = false
+ @exceptions = []
+ @count = 0 # For subclasses
+ if out.nil?
+ @out = $stdout
+ else
+ @out = File.open out, "w"
+ end
+
+ @current_state = nil
+ end
+
+ # Creates the +TimerAction+ and +TallyAction+ instances and
+ # registers them. Registers +self+ for the +:exception+,
+ # +:before+, +:after+, and +:finish+ actions.
def register
- super
- MSpec.register :after, self
+ (@timer = TimerAction.new).register
+ (@tally = TallyAction.new).register
+ LeakCheckerAction.new.register if ENV['CHECK_LEAKS']
+ @counter = @tally.counter
+
+ MSpec.register :exception, self
+ MSpec.register :before, self
+ MSpec.register :after, self
+ MSpec.register :finish, self
+ MSpec.register :abort, self
+ end
+
+ def abort
+ if @current_state
+ puts "\naborting example: #{@current_state.description}"
+ end
+ end
+
+ # Returns true if any exception is raised while running
+ # an example. This flag is reset before each example
+ # is evaluated.
+ def exception?
+ @exception
+ end
+
+ # Returns true if all exceptions during the evaluation
+ # of an example are failures rather than errors. See
+ # <tt>ExceptionState#failure</tt>. This flag is reset
+ # before each example is evaluated.
+ def failure?
+ @failure
+ end
+
+ # Callback for the MSpec :before event. Resets the
+ # +#exception?+ and +#failure+ flags.
+ def before(state=nil)
+ @current_state = state
+ @failure = @exception = false
+ end
+
+ # Callback for the MSpec :exception event. Stores the
+ # +ExceptionState+ object to generate the list of backtraces
+ # after all the specs are run. Also updates the internal
+ # +#exception?+ and +#failure?+ flags.
+ def exception(exception)
+ @count += 1
+ @failure = @exception ? @failure && exception.failure? : exception.failure?
+ @exception = true
+ @exceptions << exception
end
# Callback for the MSpec :after event. Prints an indicator
@@ -12,12 +80,38 @@ class DottedFormatter < BaseFormatter
# F = An SpecExpectationNotMetError was raised
# E = Any exception other than SpecExpectationNotMetError
def after(state = nil)
- super(state)
+ @current_state = nil
- if exception?
- print failure? ? "F" : "E"
- else
+ unless exception?
print "."
+ else
+ print failure? ? "F" : "E"
end
end
+
+ # Callback for the MSpec :finish event. Prints a description
+ # and backtrace for every exception that occurred while
+ # evaluating the examples.
+ def finish
+ print "\n"
+ count = 0
+ @exceptions.each do |exc|
+ count += 1
+ print_exception(exc, count)
+ end
+ print "\n#{@timer.format}\n\n#{@tally.format}\n"
+ end
+
+ def print_exception(exc, count)
+ outcome = exc.failure? ? "FAILED" : "ERROR"
+ print "\n#{count})\n#{exc.description} #{outcome}\n"
+ print exc.message, "\n"
+ print exc.backtrace, "\n"
+ end
+
+ # A convenience method to allow printing to different outputs.
+ def print(*args)
+ @out.print(*args)
+ @out.flush
+ end
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/file.rb b/spec/mspec/lib/mspec/runner/formatters/file.rb
index 65cfb1f75b..6db72af4ff 100644
--- a/spec/mspec/lib/mspec/runner/formatters/file.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/file.rb
@@ -14,11 +14,6 @@ class FileFormatter < DottedFormatter
MSpec.register :unload, self
end
- def load(state = nil)
- before(state)
- end
-
- def unload(state = nil)
- after(state)
- end
+ alias_method :load, :before
+ alias_method :unload, :after
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/html.rb b/spec/mspec/lib/mspec/runner/formatters/html.rb
index e37e89a088..fd64cd0d20 100644
--- a/spec/mspec/lib/mspec/runner/formatters/html.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/html.rb
@@ -1,6 +1,7 @@
-require 'mspec/runner/formatters/base'
+require 'mspec/expectations/expectations'
+require 'mspec/runner/formatters/dotted'
-class HtmlFormatter < BaseFormatter
+class HtmlFormatter < DottedFormatter
def register
super
MSpec.register :start, self
@@ -43,14 +44,13 @@ EOH
end
def exception(exception)
- super(exception)
+ super
outcome = exception.failure? ? "FAILED" : "ERROR"
print %[<li class="fail">- #{exception.it} (<a href="#details-#{@count}">]
print %[#{outcome} - #{@count}</a>)</li>\n]
end
- def after(state = nil)
- super(state)
+ def after(state)
print %[<li class="pass">- #{state.it}</li>\n] unless exception?
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/junit.rb b/spec/mspec/lib/mspec/runner/formatters/junit.rb
index 12e43a3263..76d46c2414 100644
--- a/spec/mspec/lib/mspec/runner/formatters/junit.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/junit.rb
@@ -1,18 +1,19 @@
+require 'mspec/expectations/expectations'
require 'mspec/runner/formatters/yaml'
class JUnitFormatter < YamlFormatter
- def initialize(out = nil)
- super(out)
+ def initialize(out=nil)
+ super
@tests = []
end
def after(state = nil)
- super(state)
+ super
@tests << {:test => state, :exception => false} unless exception?
end
def exception(exception)
- super(exception)
+ super
@tests << {:test => exception, :exception => true}
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/method.rb b/spec/mspec/lib/mspec/runner/formatters/method.rb
index 8fe02575c4..ff115193fd 100644
--- a/spec/mspec/lib/mspec/runner/formatters/method.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/method.rb
@@ -1,10 +1,10 @@
-require 'mspec/runner/formatters/base'
+require 'mspec/runner/formatters/dotted'
-class MethodFormatter < BaseFormatter
+class MethodFormatter < DottedFormatter
attr_accessor :methods
- def initialize(out = nil)
- super(out)
+ def initialize(out=nil)
+ super
@methods = Hash.new do |h, k|
hash = {}
hash[:examples] = 0
@@ -34,7 +34,7 @@ class MethodFormatter < BaseFormatter
# Resets the tallies so the counts are only for this
# example.
def before(state)
- super(state)
+ super
# The pattern for a method name is not correctly
# restrictive but it is simplistic and useful
@@ -60,9 +60,7 @@ class MethodFormatter < BaseFormatter
# Callback for the MSpec :after event. Sets or adds to
# tallies for the example block.
- def after(state = nil)
- super(state)
-
+ def after(state)
h = methods[@key]
h[:examples] += tally.counter.examples
h[:expectations] += tally.counter.expectations
diff --git a/spec/mspec/lib/mspec/runner/formatters/multi.rb b/spec/mspec/lib/mspec/runner/formatters/multi.rb
index a723ae8eb9..f69055025f 100644
--- a/spec/mspec/lib/mspec/runner/formatters/multi.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/multi.rb
@@ -1,24 +1,13 @@
-module MultiFormatter
- def self.extend_object(obj)
- super
- obj.multi_initialize
- end
+require 'mspec/runner/formatters/spinner'
- def multi_initialize
- @tally = TallyAction.new
- @counter = @tally.counter
+class MultiFormatter < SpinnerFormatter
+ def initialize(out=nil)
+ super(out)
+ @counter = @tally = Tally.new
@timer = TimerAction.new
@timer.start
end
- def register
- super
-
- MSpec.register :start, self
- MSpec.register :unload, self
- MSpec.unregister :before, self
- end
-
def aggregate_results(files)
require 'yaml'
@@ -26,22 +15,23 @@ module MultiFormatter
@exceptions = []
files.each do |file|
- contents = File.read(file)
- d = YAML.load(contents)
+ d = File.open(file, "r") { |f| YAML.load f }
File.delete file
- if d # The file might be empty if the child process died
- @exceptions += Array(d['exceptions'])
- @counter.files! d['files']
- @counter.examples! d['examples']
- @counter.expectations! d['expectations']
- @counter.errors! d['errors']
- @counter.failures! d['failures']
- end
+ @exceptions += Array(d['exceptions'])
+ @tally.files! d['files']
+ @tally.examples! d['examples']
+ @tally.expectations! d['expectations']
+ @tally.errors! d['errors']
+ @tally.failures! d['failures']
end
end
def print_exception(exc, count)
print "\n#{count})\n#{exc}\n"
end
+
+ def finish
+ super(false)
+ end
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/profile.rb b/spec/mspec/lib/mspec/runner/formatters/profile.rb
index 38ef5b12ed..498cd4a3b7 100644
--- a/spec/mspec/lib/mspec/runner/formatters/profile.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/profile.rb
@@ -1,9 +1,9 @@
+require 'mspec/expectations/expectations'
require 'mspec/runner/formatters/dotted'
-require 'mspec/runner/actions/profile'
class ProfileFormatter < DottedFormatter
- def initialize(out = nil)
- super(out)
+ def initialize(out=nil)
+ super
@describe_name = nil
@describe_time = nil
@@ -12,7 +12,59 @@ class ProfileFormatter < DottedFormatter
end
def register
- (@profile = ProfileAction.new).register
+ super
+ MSpec.register :enter, self
+ end
+
+ # Callback for the MSpec :enter event. Prints the
+ # +describe+ block string.
+ def enter(describe)
+ if @describe_time
+ @describes << [@describe_name, Time.now.to_f - @describe_time]
+ end
+
+ @describe_name = describe
+ @describe_time = Time.now.to_f
+ end
+
+ # Callback for the MSpec :before event. Prints the
+ # +it+ block string.
+ def before(state)
+ super
+
+ @it_name = state.it
+ @it_time = Time.now.to_f
+ end
+
+ # Callback for the MSpec :after event. Prints a
+ # newline to finish the description string output.
+ def after(state)
+ @its << [@describe_name, @it_name, Time.now.to_f - @it_time]
+ super
+ end
+
+ def finish
+ puts "\nProfiling info:"
+
+ desc = @describes.sort { |a,b| b.last <=> a.last }
+ desc.delete_if { |a| a.last <= 0.001 }
+ show = desc[0, 100]
+
+ puts "Top #{show.size} describes:"
+
+ show.each do |des, time|
+ printf "%3.3f - %s\n", time, des
+ end
+
+ its = @its.sort { |a,b| b.last <=> a.last }
+ its.delete_if { |a| a.last <= 0.001 }
+ show = its[0, 100]
+
+ puts "\nTop #{show.size} its:"
+ show.each do |des, it, time|
+ printf "%3.3f - %s %s\n", time, des, it
+ end
+
super
end
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/specdoc.rb b/spec/mspec/lib/mspec/runner/formatters/specdoc.rb
index d3a5c3d729..29adde3c5c 100644
--- a/spec/mspec/lib/mspec/runner/formatters/specdoc.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/specdoc.rb
@@ -1,6 +1,7 @@
-require 'mspec/runner/formatters/base'
+require 'mspec/expectations/expectations'
+require 'mspec/runner/formatters/dotted'
-class SpecdocFormatter < BaseFormatter
+class SpecdocFormatter < DottedFormatter
def register
super
MSpec.register :enter, self
@@ -15,7 +16,7 @@ class SpecdocFormatter < BaseFormatter
# Callback for the MSpec :before event. Prints the
# +it+ block string.
def before(state)
- super(state)
+ super
print "- #{state.it}"
end
@@ -24,18 +25,17 @@ class SpecdocFormatter < BaseFormatter
# the sequential number of the exception raised. If
# there has already been an exception raised while
# evaluating this example, it prints another +it+
- # block description string so that each description
+ # block description string so that each discription
# string has an associated 'ERROR' or 'FAILED'
def exception(exception)
print "\n- #{exception.it}" if exception?
- super(exception)
+ super
print " (#{exception.failure? ? 'FAILED' : 'ERROR'} - #{@count})"
end
# Callback for the MSpec :after event. Prints a
# newline to finish the description string output.
- def after(state = nil)
- super(state)
+ def after(state)
print "\n"
end
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/spinner.rb b/spec/mspec/lib/mspec/runner/formatters/spinner.rb
index 8815e1a48a..f6f35cc476 100644
--- a/spec/mspec/lib/mspec/runner/formatters/spinner.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/spinner.rb
@@ -1,13 +1,14 @@
-require 'mspec/runner/formatters/base'
+require 'mspec/expectations/expectations'
+require 'mspec/runner/formatters/dotted'
-class SpinnerFormatter < BaseFormatter
+class SpinnerFormatter < DottedFormatter
attr_reader :length
Spins = %w!| / - \\!
HOUR = 3600
MIN = 60
- def initialize(out = nil)
+ def initialize(out=nil)
super(nil)
@which = 0
@@ -27,6 +28,7 @@ class SpinnerFormatter < BaseFormatter
MSpec.register :start, self
MSpec.register :unload, self
+ MSpec.unregister :before, self
end
def length=(length)
@@ -100,12 +102,16 @@ class SpinnerFormatter < BaseFormatter
clear_progress_line
print_exception(exception, @count)
- exceptions.clear
end
# Callback for the MSpec :after event. Updates the spinner.
- def after(state = nil)
- super(state)
+ def after(state)
print progress_line
end
+
+ def finish(printed_exceptions = true)
+ # We already printed the exceptions
+ @exceptions = [] if printed_exceptions
+ super()
+ end
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/summary.rb b/spec/mspec/lib/mspec/runner/formatters/summary.rb
index 41819d2158..0c9207194c 100644
--- a/spec/mspec/lib/mspec/runner/formatters/summary.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/summary.rb
@@ -1,4 +1,11 @@
-require 'mspec/runner/formatters/base'
+require 'mspec/expectations/expectations'
+require 'mspec/runner/formatters/dotted'
-class SummaryFormatter < BaseFormatter
+class SummaryFormatter < DottedFormatter
+ # Callback for the MSpec :after event. Overrides the
+ # callback provided by +DottedFormatter+ and does not
+ # print any output for each example evaluated.
+ def after(state)
+ # do nothing
+ end
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/unit.rb b/spec/mspec/lib/mspec/runner/formatters/unit.rb
index d03ae79e9f..cebc18a49b 100644
--- a/spec/mspec/lib/mspec/runner/formatters/unit.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/unit.rb
@@ -1,3 +1,4 @@
+require 'mspec/expectations/expectations'
require 'mspec/runner/formatters/dotted'
class UnitdiffFormatter < DottedFormatter
diff --git a/spec/mspec/lib/mspec/runner/formatters/yaml.rb b/spec/mspec/lib/mspec/runner/formatters/yaml.rb
index 6c05cc902f..090a9b1b9d 100644
--- a/spec/mspec/lib/mspec/runner/formatters/yaml.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/yaml.rb
@@ -1,7 +1,8 @@
-require 'mspec/runner/formatters/base'
+require 'mspec/expectations/expectations'
+require 'mspec/runner/formatters/dotted'
-class YamlFormatter < BaseFormatter
- def initialize(out = nil)
+class YamlFormatter < DottedFormatter
+ def initialize(out=nil)
super(nil)
if out.nil?
@@ -15,6 +16,9 @@ class YamlFormatter < BaseFormatter
@out = @finish
end
+ def after(state)
+ end
+
def finish
switch
diff --git a/spec/mspec/lib/mspec/runner/mspec.rb b/spec/mspec/lib/mspec/runner/mspec.rb
index 5528f27cf8..d47657326b 100644
--- a/spec/mspec/lib/mspec/runner/mspec.rb
+++ b/spec/mspec/lib/mspec/runner/mspec.rb
@@ -38,7 +38,7 @@ module MSpec
@expectation = nil
@expectations = false
- def self.describe(mod, options = nil, &block)
+ def self.describe(mod, options=nil, &block)
state = ContextState.new mod, options
state.parent = current
@@ -50,7 +50,6 @@ module MSpec
def self.process
STDOUT.puts RUBY_DESCRIPTION
- STDOUT.flush
actions :start
files
@@ -59,8 +58,9 @@ module MSpec
def self.each_file(&block)
if ENV["MSPEC_MULTI"]
- while file = STDIN.gets
- file = file.chomp
+ STDOUT.print "."
+ STDOUT.flush
+ while file = STDIN.gets and file = file.chomp
return if file == "QUIT"
yield file
begin
@@ -105,8 +105,6 @@ module MSpec
return true
rescue SystemExit => e
raise e
- rescue SkippedSpecError => e
- return false
rescue Exception => exc
register_exit 1
actions :exception, ExceptionState.new(current && current.state, location, exc)
@@ -259,7 +257,7 @@ module MSpec
end
end
- def self.randomize(flag = true)
+ def self.randomize(flag=true)
@randomize = flag
end
diff --git a/spec/mspec/lib/mspec/runner/object.rb b/spec/mspec/lib/mspec/runner/object.rb
index d5d9650795..2ea8197165 100644
--- a/spec/mspec/lib/mspec/runner/object.rb
+++ b/spec/mspec/lib/mspec/runner/object.rb
@@ -1,18 +1,18 @@
class Object
- private def before(at = :each, &block)
+ private def before(at=:each, &block)
MSpec.current.before at, &block
end
- private def after(at = :each, &block)
+ private def after(at=:each, &block)
MSpec.current.after at, &block
end
- private def describe(mod, msg = nil, options = nil, &block)
+ private def describe(mod, msg=nil, options=nil, &block)
MSpec.describe mod, msg, &block
end
- private def it(desc, &block)
- MSpec.current.it desc, &block
+ private def it(msg, &block)
+ MSpec.current.it msg, &block
end
private def it_should_behave_like(desc)
diff --git a/spec/mspec/lib/mspec/runner/parallel.rb b/spec/mspec/lib/mspec/runner/parallel.rb
deleted file mode 100644
index 7428b33682..0000000000
--- a/spec/mspec/lib/mspec/runner/parallel.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-class ParallelRunner
- def initialize(files, processes, formatter, argv)
- @files = files
- @processes = processes
- @formatter = formatter
- @argv = argv
- @last_files = {}
- @output_files = []
- @success = true
- end
-
- def launch_children
- @children = @processes.times.map { |i|
- name = tmp "mspec-multi-#{i}"
- @output_files << name
-
- env = {
- "SPEC_TEMP_DIR" => "rubyspec_temp_#{i}",
- "MSPEC_MULTI" => i.to_s
- }
- command = @argv + ["-fy", "-o", name]
- $stderr.puts "$ #{command.join(' ')}" if $MSPEC_DEBUG
- IO.popen([env, *command, close_others: false], "rb+")
- }
- end
-
- def handle(child, message)
- case message
- when '.'
- @formatter.unload
- send_new_file_or_quit(child)
- else
- if message == nil
- msg = "A child mspec-run process died unexpectedly"
- else
- msg = "A child mspec-run process printed unexpected output on STDOUT"
- while chunk = (child.read_nonblock(4096) rescue nil)
- message += chunk
- end
- message.chomp!('.')
- msg += ": #{message.inspect}"
- end
-
- if last_file = @last_files[child]
- msg += " while running #{last_file}"
- end
-
- @success = false
- quit(child)
- abort "\n#{msg}"
- end
- end
-
- def quit(child)
- begin
- child.puts "QUIT"
- rescue Errno::EPIPE
- # The child process already died
- end
- _pid, status = Process.wait2(child.pid)
- @success &&= status.success?
- child.close
- @children.delete(child)
- end
-
- def send_new_file_or_quit(child)
- if @files.empty?
- quit(child)
- else
- file = @files.shift
- @last_files[child] = file
- child.puts file
- end
- end
-
- def run
- MSpec.register_files @files
- launch_children
-
- puts @children.map { |child| child.gets }.uniq
- @formatter.start
- begin
- @children.each { |child| send_new_file_or_quit(child) }
-
- until @children.empty?
- IO.select(@children)[0].each { |child|
- handle(child, child.read(1))
- }
- end
- ensure
- @children.dup.each { |child| quit(child) }
- @formatter.aggregate_results(@output_files)
- @formatter.finish
- end
-
- @success
- end
-end
diff --git a/spec/mspec/lib/mspec/runner/shared.rb b/spec/mspec/lib/mspec/runner/shared.rb
index 1d68365474..b606de473b 100644
--- a/spec/mspec/lib/mspec/runner/shared.rb
+++ b/spec/mspec/lib/mspec/runner/shared.rb
@@ -1,6 +1,6 @@
require 'mspec/runner/mspec'
-def it_behaves_like(desc, meth, obj = nil)
+def it_behaves_like(desc, meth, obj=nil)
send :before, :all do
@method = meth
@object = obj
diff --git a/spec/mspec/lib/mspec/runner/tag.rb b/spec/mspec/lib/mspec/runner/tag.rb
index 820df9159e..e2275ad3a6 100644
--- a/spec/mspec/lib/mspec/runner/tag.rb
+++ b/spec/mspec/lib/mspec/runner/tag.rb
@@ -1,7 +1,7 @@
class SpecTag
attr_accessor :tag, :comment, :description
- def initialize(string = nil)
+ def initialize(string=nil)
parse(string) if string
end
diff --git a/spec/mspec/lib/mspec/utils/format.rb b/spec/mspec/lib/mspec/utils/format.rb
deleted file mode 100644
index bb75e131de..0000000000
--- a/spec/mspec/lib/mspec/utils/format.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# If the implementation on which the specs are run cannot
-# load pp from the standard library, add a pp.rb file that
-# defines the #pretty_inspect method on Object or Kernel.
-begin
- require 'pp'
-rescue LoadError
- module Kernel
- def pretty_inspect
- inspect
- end
- end
-end
-
-module MSpec
- def self.format(obj)
- obj.pretty_inspect.chomp
- rescue => e
- "#<#{obj.class}>(#pretty_inspect raised #{e.inspect})"
- end
-end
diff --git a/spec/mspec/lib/mspec/utils/name_map.rb b/spec/mspec/lib/mspec/utils/name_map.rb
index a389b9d1de..c1de081af0 100644
--- a/spec/mspec/lib/mspec/utils/name_map.rb
+++ b/spec/mspec/lib/mspec/utils/name_map.rb
@@ -8,9 +8,10 @@ class NameMap
'*' => 'multiply',
'/' => 'divide',
'%' => 'modulo',
- '<<' => {'Integer' => 'left_shift',
- 'IO' => 'output',
- :default => 'append' },
+ '<<' => {'Bignum' => 'left_shift',
+ 'Fixnum' => 'left_shift',
+ 'IO' => 'output',
+ :default => 'append' },
'>>' => 'right_shift',
'<' => 'lt',
'<=' => 'lte',
@@ -24,22 +25,33 @@ class NameMap
'[]=' => 'element_set',
'**' => 'exponent',
'!' => 'not',
- '~' => {'Integer' => 'complement',
- :default => 'match' },
+ '~' => {'Bignum' => 'complement',
+ 'Fixnum' => 'complement',
+ 'Regexp' => 'match',
+ 'String' => 'match' },
'!=' => 'not_equal',
'!~' => 'not_match',
'=~' => 'match',
- '&' => {'Integer' => 'bit_and',
+ '&' => {'Bignum' => 'bit_and',
+ 'Fixnum' => 'bit_and',
'Array' => 'intersection',
- 'Set' => 'intersection',
- :default => 'and' },
- '|' => {'Integer' => 'bit_or',
+ 'TrueClass' => 'and',
+ 'FalseClass' => 'and',
+ 'NilClass' => 'and',
+ 'Set' => 'intersection' },
+ '|' => {'Bignum' => 'bit_or',
+ 'Fixnum' => 'bit_or',
'Array' => 'union',
- 'Set' => 'union',
- :default => 'or' },
- '^' => {'Integer' => 'bit_xor',
- 'Set' => 'exclusion',
- :default => 'xor' },
+ 'TrueClass' => 'or',
+ 'FalseClass' => 'or',
+ 'NilClass' => 'or',
+ 'Set' => 'union' },
+ '^' => {'Bignum' => 'bit_xor',
+ 'Fixnum' => 'bit_xor',
+ 'TrueClass' => 'xor',
+ 'FalseClass' => 'xor',
+ 'NilClass' => 'xor',
+ 'Set' => 'exclusion'},
}
EXCLUDED = %w[
@@ -51,7 +63,7 @@ class NameMap
SpecVersion
]
- def initialize(filter = false)
+ def initialize(filter=false)
@seen = {}
@filter = filter
end
@@ -73,7 +85,7 @@ class NameMap
"#{mod}::#{const}"
end
- def map(hash, constants, mod = nil)
+ def map(hash, constants, mod=nil)
@seen = {} unless mod
constants.each do |const|
@@ -107,12 +119,7 @@ class NameMap
def file_name(m, c)
if MAP.key?(m)
- mapping = MAP[m]
- if mapping.is_a?(Hash)
- name = mapping[c.split('::').last] || mapping.fetch(:default)
- else
- name = mapping
- end
+ name = MAP[m].is_a?(Hash) ? MAP[m][c.split('::').last] || MAP[m][:default] : MAP[m]
else
name = m.gsub(/[?!=]/, '')
end
diff --git a/spec/mspec/lib/mspec/utils/options.rb b/spec/mspec/lib/mspec/utils/options.rb
index 3e3f708a2f..9f8dd01dbf 100644
--- a/spec/mspec/lib/mspec/utils/options.rb
+++ b/spec/mspec/lib/mspec/utils/options.rb
@@ -34,7 +34,7 @@ class MSpecOptions
attr_accessor :config, :banner, :width, :options
- def initialize(banner = "", width = 30, config = nil)
+ def initialize(banner="", width=30, config=nil)
@banner = banner
@config = config
@width = width
@@ -94,7 +94,7 @@ class MSpecOptions
@options.find { |o| o.match? opt }
end
- # Processes an option. Calls the #on_extra block (or default) for
+ # Processes an option. Calles the #on_extra block (or default) for
# unrecognized options. For registered options, possibly fetches an
# argument and invokes the option's block if it is not nil.
def process(argv, entry, opt, arg)
@@ -123,7 +123,7 @@ class MSpecOptions
# Parses an array of command line entries, calling blocks for
# registered options.
- def parse(argv = ARGV)
+ def parse(argv=ARGV)
argv = Array(argv).dup
while entry = argv.shift
@@ -384,7 +384,7 @@ class MSpecOptions
def repeat
on("-R", "--repeat", "NUMBER",
"Repeatedly run an example NUMBER times") do |o|
- MSpec.repeat = Integer(o)
+ MSpec.repeat = o.to_i
end
end
@@ -414,19 +414,11 @@ class MSpecOptions
end
def interrupt
- on("--int-spec", "Control-C interrupts the current spec only") do
+ on("--int-spec", "Control-C interupts the current spec only") do
config[:abort] = false
end
end
- def timeout
- on("--timeout", "TIMEOUT", "Abort if a spec takes longer than TIMEOUT seconds") do |timeout|
- require 'mspec/runner/actions/timeout'
- timeout = Float(timeout)
- TimeoutAction.new(timeout).register
- end
- end
-
def verify
on("--report-on", "GUARD", "Report specs guarded by GUARD") do |g|
MSpec.register_mode :report_on
diff --git a/spec/mspec/lib/mspec/utils/script.rb b/spec/mspec/lib/mspec/utils/script.rb
index 2545a16bae..24cd069bb4 100644
--- a/spec/mspec/lib/mspec/utils/script.rb
+++ b/spec/mspec/lib/mspec/utils/script.rb
@@ -39,8 +39,8 @@ class MSpecScript
end
def initialize
- ruby_version_is ""..."2.4" do
- abort "MSpec needs Ruby 2.4 or more recent"
+ ruby_version_is ""..."2.2" do
+ abort "MSpec needs Ruby 2.2 or more recent"
end
config[:formatter] = nil
@@ -125,7 +125,12 @@ class MSpecScript
require 'mspec/runner/formatters/file'
require 'mspec/runner/filters'
- if formatter = config_formatter
+ if config[:formatter].nil?
+ config[:formatter] = STDOUT.tty? ? SpinnerFormatter : @files.size < 50 ? DottedFormatter : FileFormatter
+ end
+
+ if config[:formatter]
+ formatter = config[:formatter].new(config[:output])
formatter.register
MSpec.store :formatter, formatter
end
@@ -144,17 +149,6 @@ class MSpecScript
custom_register
end
- # Makes a formatter specified by :formatter option.
- def config_formatter
- if config[:formatter].nil?
- config[:formatter] = STDOUT.tty? ? SpinnerFormatter : @files.size < 50 ? DottedFormatter : FileFormatter
- end
-
- if config[:formatter]
- config[:formatter].new(config[:output])
- end
- end
-
# Callback for enabling custom actions, etc. This version is a
# no-op. Provide an implementation specific version in a config
# file. Called by #register.
@@ -195,11 +189,7 @@ class MSpecScript
end
patterns.each do |pattern|
- begin
- expanded = File.realpath(pattern)
- rescue Errno::ENOENT, Errno::ENOTDIR
- next
- end
+ expanded = File.expand_path(pattern)
if File.file?(expanded) && expanded.end_with?('.rb')
return [expanded]
elsif File.directory?(expanded)
diff --git a/spec/mspec/lib/mspec/utils/warnings.rb b/spec/mspec/lib/mspec/utils/warnings.rb
index 7c2bc6fe88..4d23474236 100644
--- a/spec/mspec/lib/mspec/utils/warnings.rb
+++ b/spec/mspec/lib/mspec/utils/warnings.rb
@@ -51,7 +51,7 @@ if RUBY_ENGINE == "ruby" and ruby_version_is("2.4")
when /hash\/shared\/index\.rb:\d+: warning: Hash#index is deprecated; use Hash#key/
when /env\/shared\/key\.rb:\d+: warning: ENV\.index is deprecated; use ENV\.key/
when /exponent(_spec)?\.rb:\d+: warning: in a\*\*b, b may be too big/
- when /enumerator\/(new_spec|initialize_spec)\.rb:\d+: warning: Enumerator\.new without a block is deprecated/
+ when /enumerator\/(new|initialize_spec)\.rb:\d+: warning: Enumerator\.new without a block is deprecated/
else
$stderr.write message
end
diff --git a/spec/mspec/spec/commands/mkspec_spec.rb b/spec/mspec/spec/commands/mkspec_spec.rb
index 1b959dcb78..14c363f286 100644
--- a/spec/mspec/spec/commands/mkspec_spec.rb
+++ b/spec/mspec/spec/commands/mkspec_spec.rb
@@ -167,13 +167,13 @@ describe MkSpec, "#write_requires" do
end
it "writes the spec_helper require line" do
- @file.should_receive(:puts).with("require_relative '../../../spec_helper'")
+ @file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)")
@script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
end
it "writes require lines for each library specified on the command line" do
@file.stub(:puts)
- @file.should_receive(:puts).with("require_relative '../../../spec_helper'")
+ @file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)")
@file.should_receive(:puts).with("require 'complex'")
@script.config[:requires] << 'complex'
@script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
diff --git a/spec/mspec/spec/expectations/should.rb b/spec/mspec/spec/expectations/should.rb
index 48503b1631..24b1cf2bf8 100644
--- a/spec/mspec/spec/expectations/should.rb
+++ b/spec/mspec/spec/expectations/should.rb
@@ -41,7 +41,7 @@ describe "MSpec expectation method #should" do
:sym.should be_kind_of(Symbol)
end
- it "causes a failure to be recorded" do
+ it "causes a failue to be recorded" do
1.should == 2
end
diff --git a/spec/mspec/spec/expectations/should_spec.rb b/spec/mspec/spec/expectations/should_spec.rb
index b8bda8f86f..3258caf13c 100644
--- a/spec/mspec/spec/expectations/should_spec.rb
+++ b/spec/mspec/spec/expectations/should_spec.rb
@@ -13,9 +13,9 @@ describe "MSpec" do
it "records failures" do
@out.should include <<-EOS
1)
-MSpec expectation method #should causes a failure to be recorded FAILED
-Expected 1 == 2
-to be truthy but was false
+MSpec expectation method #should causes a failue to be recorded FAILED
+Expected 1
+ to equal 2
EOS
end
@@ -33,8 +33,8 @@ EOS
@out.should include <<-EOS
3)
MSpec expectation method #should_not causes a failure to be recorded FAILED
-Expected 1 == 1
-to be falsy but was true
+Expected 1
+ not to equal 1
EOS
end
diff --git a/spec/mspec/spec/fixtures/chatty_spec.rb b/spec/mspec/spec/fixtures/chatty_spec.rb
deleted file mode 100644
index 2d110d8ce4..0000000000
--- a/spec/mspec/spec/fixtures/chatty_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-unless defined?(RSpec)
- describe "Chatty#spec" do
- it "prints too much" do
- STDOUT.puts "Hello\nIt's me!"
- 1.should == 1
- end
- end
-end
diff --git a/spec/mspec/spec/fixtures/die_spec.rb b/spec/mspec/spec/fixtures/die_spec.rb
deleted file mode 100644
index 0f66793274..0000000000
--- a/spec/mspec/spec/fixtures/die_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-unless defined?(RSpec)
- describe "Deadly#spec" do
- it "dies" do
- abort "DEAD"
- end
- end
-end
diff --git a/spec/mspec/spec/guards/conflict_spec.rb b/spec/mspec/spec/guards/conflict_spec.rb
index deada96821..e06a2809ee 100644
--- a/spec/mspec/spec/guards/conflict_spec.rb
+++ b/spec/mspec/spec/guards/conflict_spec.rb
@@ -3,7 +3,6 @@ require 'mspec/guards'
describe Object, "#conflicts_with" do
before :each do
- hide_deprecation_warnings
ScratchPad.clear
end
@@ -34,7 +33,6 @@ end
describe Object, "#conflicts_with" do
before :each do
- hide_deprecation_warnings
@guard = ConflictsGuard.new
ConflictsGuard.stub(:new).and_return(@guard)
end
diff --git a/spec/mspec/spec/guards/feature_spec.rb b/spec/mspec/spec/guards/feature_spec.rb
index 8761cb2fbb..d14e5f8e67 100644
--- a/spec/mspec/spec/guards/feature_spec.rb
+++ b/spec/mspec/spec/guards/feature_spec.rb
@@ -78,43 +78,3 @@ describe Object, "#with_feature" do
ScratchPad.recorded.should be_nil
end
end
-
-describe Object, "#without_feature" do
- before :each do
- ScratchPad.clear
-
- @guard = FeatureGuard.new :encoding
- FeatureGuard.stub(:new).and_return(@guard)
- end
-
- it "sets the name of the guard to :without_feature" do
- without_feature(:encoding) { }
- @guard.name.should == :without_feature
- end
-
- it "calls #unregister even when an exception is raised in the guard block" do
- @guard.should_receive(:match?).and_return(false)
- @guard.should_receive(:unregister)
- lambda do
- without_feature { raise Exception }
- end.should raise_error(Exception)
- end
-end
-
-describe Object, "#without_feature" do
- before :each do
- ScratchPad.clear
- end
-
- it "does not yield if the feature is enabled" do
- MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(true)
- without_feature(:encoding) { ScratchPad.record :yield }
- ScratchPad.recorded.should be_nil
- end
-
- it "yields if the feature is disabled" do
- MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(false)
- without_feature(:encoding) { ScratchPad.record :yield }
- ScratchPad.recorded.should == :yield
- end
-end
diff --git a/spec/mspec/spec/guards/platform_spec.rb b/spec/mspec/spec/guards/platform_spec.rb
index 6088fb2ba6..749963d3db 100644
--- a/spec/mspec/spec/guards/platform_spec.rb
+++ b/spec/mspec/spec/guards/platform_spec.rb
@@ -165,10 +165,11 @@ describe PlatformGuard, ".implementation?" do
PlatformGuard.implementation?(:ruby).should == true
end
- it "works for an unrecognized name" do
- stub_const 'RUBY_ENGINE', 'myrubyimplementation'
- PlatformGuard.implementation?(:myrubyimplementation).should == true
- PlatformGuard.implementation?(:other).should == false
+ it "raises an error when passed an unrecognized name" do
+ stub_const 'RUBY_ENGINE', 'ruby'
+ lambda {
+ PlatformGuard.implementation?(:python)
+ }.should raise_error(/unknown implementation/)
end
end
@@ -196,7 +197,7 @@ end
describe PlatformGuard, ".os?" do
before :each do
- stub_const 'PlatformGuard::PLATFORM', 'solarce'
+ stub_const 'PlatformGuard::HOST_OS', 'solarce'
end
it "returns false when arg does not match the platform" do
@@ -216,36 +217,26 @@ describe PlatformGuard, ".os?" do
end
it "returns true when arg is :windows and the platform contains 'mswin'" do
- stub_const 'PlatformGuard::PLATFORM', 'mswin32'
+ stub_const 'PlatformGuard::HOST_OS', 'mswin32'
PlatformGuard.os?(:windows).should == true
end
it "returns true when arg is :windows and the platform contains 'mingw'" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
PlatformGuard.os?(:windows).should == true
end
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mswin32'
PlatformGuard.os?(:linux).should == false
end
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
PlatformGuard.os?(:linux).should == false
end
end
-describe PlatformGuard, ".os?" do
- it "returns true if called with the current OS or architecture" do
- os = RbConfig::CONFIG["host_os"].sub("-gnu", "")
- arch = RbConfig::CONFIG["host_arch"]
- PlatformGuard.os?(os).should == true
- PlatformGuard.os?(arch).should == true
- PlatformGuard.os?("#{arch}-#{os}").should == true
- end
-end
-
describe PlatformGuard, ".os? on JRuby" do
before :all do
@verbose = $VERBOSE
@@ -272,19 +263,19 @@ describe PlatformGuard, ".os? on JRuby" do
end
it "returns true when arg is :windows and RUBY_PLATFORM contains 'java' and os?(:windows) is true" do
- stub_const 'PlatformGuard::PLATFORM', 'mswin32'
+ stub_const 'PlatformGuard::HOST_OS', 'mswin32'
PlatformGuard.os?(:windows).should == true
end
it "returns true when RUBY_PLATFORM contains 'java' and os?(argument) is true" do
- stub_const 'PlatformGuard::PLATFORM', 'amiga'
+ stub_const 'PlatformGuard::HOST_OS', 'amiga'
PlatformGuard.os?(:amiga).should == true
end
end
describe PlatformGuard, ".os?" do
before :each do
- stub_const 'PlatformGuard::PLATFORM', 'unreal'
+ stub_const 'PlatformGuard::HOST_OS', 'unreal'
end
it "returns true if argument matches RbConfig::CONFIG['host_os']" do
@@ -304,34 +295,34 @@ describe PlatformGuard, ".os?" do
end
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mswin32'
PlatformGuard.os?(:windows).should == true
end
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
PlatformGuard.os?(:windows).should == true
end
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
PlatformGuard.os?(:linux).should == false
end
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
PlatformGuard.os?(:linux).should == false
end
end
describe PlatformGuard, ".windows?" do
it "returns true on windows" do
- stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
+ stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
PlatformGuard.windows?.should == true
end
it "returns false on non-windows" do
- stub_const 'PlatformGuard::PLATFORM', 'i586-linux'
+ stub_const 'PlatformGuard::HOST_OS', 'i586-linux'
PlatformGuard.windows?.should == false
end
end
diff --git a/spec/mspec/spec/helpers/io_spec.rb b/spec/mspec/spec/helpers/io_spec.rb
index 19f8384912..3219f59947 100644
--- a/spec/mspec/spec/helpers/io_spec.rb
+++ b/spec/mspec/spec/helpers/io_spec.rb
@@ -64,7 +64,7 @@ describe Object, "#new_fd" do
fd = new_fd @name
fd.should be_kind_of(Integer)
- @io = IO.new fd, 'w:utf-8'
+ @io = IO.new fd, fmode('w:utf-8')
@io.sync = true
@io.print "io data"
@@ -76,7 +76,7 @@ describe Object, "#new_fd" do
fd = new_fd @name, { :mode => 'w:utf-8' }
fd.should be_kind_of(Integer)
- @io = IO.new fd, 'w:utf-8'
+ @io = IO.new fd, fmode('w:utf-8')
@io.sync = true
@io.print "io data"
@@ -99,9 +99,9 @@ describe Object, "#new_io" do
rm_r @name
end
- it "returns a File instance" do
+ it "returns an IO instance" do
@io = new_io @name
- @io.should be_an_instance_of(File)
+ @io.should be_an_instance_of(IO)
end
it "opens the IO for reading if passed 'r'" do
@@ -134,3 +134,41 @@ describe Object, "#new_io" do
IO.read(@name).should == "io data"
end
end
+
+describe Object, "#fmode" do
+ it "returns the argument unmodified if :encoding feature is enabled" do
+ FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
+ fmode("rb:binary:utf-8").should == "rb:binary:utf-8"
+ end
+
+ it "returns only the file access mode if :encoding feature is not enabled" do
+ FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(false)
+ fmode("rb:binary:utf-8").should == "rb"
+ end
+end
+
+describe Object, "#options_or_mode" do
+ describe "if passed a Hash" do
+ it "returns a mode string if :encoding feature is not enabled" do
+ FeatureGuard.should_receive(:enabled?).with(:encoding).twice.and_return(false)
+ options_or_mode(:mode => "rb:binary").should == "rb"
+ end
+
+ it "returns a Hash if :encoding feature is enabled" do
+ FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
+ options_or_mode(:mode => "rb:utf-8").should == { :mode => "rb:utf-8" }
+ end
+ end
+
+ describe "if passed a String" do
+ it "returns only the file access mode if :encoding feature is not enabled" do
+ FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(false)
+ options_or_mode("rb:binary:utf-8").should == "rb"
+ end
+
+ it "returns the argument unmodified if :encoding feature is enabled" do
+ FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
+ options_or_mode("rb:binary:utf-8").should == "rb:binary:utf-8"
+ end
+ end
+end
diff --git a/spec/mspec/spec/integration/run_spec.rb b/spec/mspec/spec/integration/run_spec.rb
index df10f77094..93d2ef8b68 100644
--- a/spec/mspec/spec/integration/run_spec.rb
+++ b/spec/mspec/spec/integration/run_spec.rb
@@ -5,8 +5,9 @@ describe "Running mspec" do
1)
Foo#bar errors FAILED
-Expected 1 == 2
-to be truthy but was false
+Expected 1
+ to equal 2
+
CWD/spec/fixtures/a_spec.rb:8:in `block (2 levels) in <top (required)>'
CWD/spec/fixtures/a_spec.rb:2:in `<top (required)>'
CWD/bin/mspec-run:7:in `<main>'
@@ -23,28 +24,24 @@ EOS
a_stats = "1 file, 3 examples, 2 expectations, 1 failure, 1 error, 0 tagged\n"
ab_stats = "2 files, 4 examples, 3 expectations, 1 failure, 1 error, 0 tagged\n"
- fixtures = "spec/fixtures"
it "runs the specs" do
+ fixtures = "spec/fixtures"
out, ret = run_mspec("run", "#{fixtures}/a_spec.rb")
out.should == "RUBY_DESCRIPTION\n.FE\n#{a_spec_output}\n#{a_stats}"
ret.success?.should == false
end
it "directly with mspec-run runs the specs" do
+ fixtures = "spec/fixtures"
out, ret = run_mspec("-run", "#{fixtures}/a_spec.rb")
out.should == "RUBY_DESCRIPTION\n.FE\n#{a_spec_output}\n#{a_stats}"
ret.success?.should == false
end
- it "runs the specs in parallel with -j using the dotted formatter" do
+ it "runs the specs in parallel with -j" do
+ fixtures = "spec/fixtures"
out, ret = run_mspec("run", "-j #{fixtures}/a_spec.rb #{fixtures}/b_spec.rb")
- out.should == "RUBY_DESCRIPTION\n...\n#{a_spec_output}\n#{ab_stats}"
- ret.success?.should == false
- end
-
- it "runs the specs in parallel with -j -fa" do
- out, ret = run_mspec("run", "-j -fa #{fixtures}/a_spec.rb #{fixtures}/b_spec.rb")
progress_bar =
"\r[/ | 0% | 00:00:00] \e[0;32m 0F \e[0;32m 0E\e[0m " +
"\r[- | ==================50% | 00:00:00] \e[0;32m 0F \e[0;32m 0E\e[0m " +
@@ -52,22 +49,4 @@ EOS
out.should == "RUBY_DESCRIPTION\n#{progress_bar}\n#{a_spec_output}\n#{ab_stats}"
ret.success?.should == false
end
-
- it "gives a useful error message when a subprocess dies in parallel mode" do
- out, ret = run_mspec("run", "-j #{fixtures}/b_spec.rb #{fixtures}/die_spec.rb")
- lines = out.lines
- lines.should include "A child mspec-run process died unexpectedly while running CWD/spec/fixtures/die_spec.rb\n"
- lines.should include "Finished in D.DDDDDD seconds\n"
- lines.last.should =~ /^\d files?, \d examples?, \d expectations?, 0 failures, 0 errors, 0 tagged$/
- ret.success?.should == false
- end
-
- it "gives a useful error message when a subprocess prints unexpected output on STDOUT in parallel mode" do
- out, ret = run_mspec("run", "-j #{fixtures}/b_spec.rb #{fixtures}/chatty_spec.rb")
- lines = out.lines
- lines.should include "A child mspec-run process printed unexpected output on STDOUT: #{'"Hello\nIt\'s me!\n"'} while running CWD/spec/fixtures/chatty_spec.rb\n"
- lines.should include "Finished in D.DDDDDD seconds\n"
- lines.last.should == "2 files, 2 examples, 2 expectations, 0 failures, 0 errors, 0 tagged\n"
- ret.success?.should == false
- end
end
diff --git a/spec/mspec/spec/integration/tag_spec.rb b/spec/mspec/spec/integration/tag_spec.rb
index 1882d71e32..d980769043 100644
--- a/spec/mspec/spec/integration/tag_spec.rb
+++ b/spec/mspec/spec/integration/tag_spec.rb
@@ -24,16 +24,18 @@ Tag#me érròrs in unicode
1)
Tag#me errors FAILED
-Expected 1 == 2
-to be truthy but was false
+Expected 1
+ to equal 2
+
CWD/spec/fixtures/tagging_spec.rb:9:in `block (2 levels) in <top (required)>'
CWD/spec/fixtures/tagging_spec.rb:3:in `<top (required)>'
CWD/bin/mspec-tag:7:in `<main>'
2)
Tag#me érròrs in unicode FAILED
-Expected 1 == 2
-to be truthy but was false
+Expected 1
+ to equal 2
+
CWD/spec/fixtures/tagging_spec.rb:13:in `block (2 levels) in <top (required)>'
CWD/spec/fixtures/tagging_spec.rb:3:in `<top (required)>'
CWD/bin/mspec-tag:7:in `<main>'
diff --git a/spec/mspec/spec/matchers/base_spec.rb b/spec/mspec/spec/matchers/base_spec.rb
index 762822bf09..cc13c29d1d 100644
--- a/spec/mspec/spec/matchers/base_spec.rb
+++ b/spec/mspec/spec/matchers/base_spec.rb
@@ -4,225 +4,222 @@ require 'mspec/matchers'
require 'time'
describe SpecPositiveOperatorMatcher, "== operator" do
- it "provides a failure message that 'Expected x to equal y'" do
+ it "raises an SpecExpectationNotMetError when expected == actual returns false" do
lambda {
SpecPositiveOperatorMatcher.new(1) == 2
- }.should raise_error(SpecExpectationNotMetError, "Expected 1 == 2\nto be truthy but was false")
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "does not raise an exception when == returns true" do
+ it "provides a failure message that 'Expected x to equal y'" do
+ SpecExpectation.should_receive(:fail_with).with("Expected 1\n", "to equal 2\n")
+ SpecPositiveOperatorMatcher.new(1) == 2
+ end
+
+ it "does not raise an exception when expected == actual returns true" do
SpecPositiveOperatorMatcher.new(1) == 1
end
end
describe SpecPositiveOperatorMatcher, "=~ operator" do
- it "provides a failure message that 'Expected \"x\" to match y'" do
+ it "raises an SpecExpectationNotMetError when expected =~ actual returns false" do
lambda {
SpecPositiveOperatorMatcher.new('real') =~ /fake/
- }.should raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /fake/\nto be truthy but was nil")
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "does not raise an exception when =~ returns true" do
+ it "provides a failure message that 'Expected \"x\" to match y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected \"real\"\n", "to match /fake/\n")
+ SpecPositiveOperatorMatcher.new('real') =~ /fake/
+ end
+
+ it "does not raise an exception when expected =~ actual returns true" do
SpecPositiveOperatorMatcher.new('real') =~ /real/
end
end
describe SpecPositiveOperatorMatcher, "> operator" do
- it "provides a failure message that 'Expected x to be greater than y'" do
+ it "raises an SpecExpectationNotMetError when expected > actual returns false" do
lambda {
SpecPositiveOperatorMatcher.new(4) > 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 > 5\nto be truthy but was false")
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "does not raise an exception when > returns true" do
+ it "provides a failure message that 'Expected x to be greater than y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "to be greater than 5\n")
+ SpecPositiveOperatorMatcher.new(4) > 5
+ end
+
+ it "does not raise an exception when expected > actual returns true" do
SpecPositiveOperatorMatcher.new(5) > 4
end
end
describe SpecPositiveOperatorMatcher, ">= operator" do
- it "provides a failure message that 'Expected x to be greater than or equal to y'" do
+ it "raises an SpecExpectationNotMetError when expected >= actual returns false" do
lambda {
SpecPositiveOperatorMatcher.new(4) >= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 >= 5\nto be truthy but was false")
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "does not raise an exception when > returns true" do
+ it "provides a failure message that 'Expected x to be greater than or equal to y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "to be greater than or equal to 5\n")
+ SpecPositiveOperatorMatcher.new(4) >= 5
+ end
+
+ it "does not raise an exception when expected > actual returns true" do
SpecPositiveOperatorMatcher.new(5) >= 4
SpecPositiveOperatorMatcher.new(5) >= 5
end
end
-describe SpecPositiveOperatorMatcher, "< operator" do
- it "provides a failure message that 'Expected x to be less than y'" do
+describe SpecPositiveOperatorMatcher, "< operater" do
+ it "raises an SpecExpectationNotMetError when expected < actual returns false" do
lambda {
SpecPositiveOperatorMatcher.new(5) < 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 < 4\nto be truthy but was false")
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "does not raise an exception when < returns true" do
+ it "provides a failure message that 'Expected x to be less than y'" do
+ SpecExpectation.should_receive(:fail_with).with("Expected 5\n", "to be less than 4\n")
+ SpecPositiveOperatorMatcher.new(5) < 4
+ end
+
+ it "does not raise an exception when expected < actual returns true" do
SpecPositiveOperatorMatcher.new(4) < 5
end
end
-describe SpecPositiveOperatorMatcher, "<= operator" do
- it "provides a failure message that 'Expected x to be less than or equal to y'" do
+describe SpecPositiveOperatorMatcher, "<= operater" do
+ it "raises an SpecExpectationNotMetError when expected < actual returns false" do
lambda {
SpecPositiveOperatorMatcher.new(5) <= 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 <= 4\nto be truthy but was false")
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "does not raise an exception when < returns true" do
- SpecPositiveOperatorMatcher.new(4) <= 5
- SpecPositiveOperatorMatcher.new(4) <= 4
- end
-end
-
-describe SpecPositiveOperatorMatcher, "arbitrary predicates" do
- it "do not raise an exception when the predicate is truthy" do
- SpecPositiveOperatorMatcher.new(2).eql?(2)
- SpecPositiveOperatorMatcher.new(2).equal?(2)
- SpecPositiveOperatorMatcher.new([1, 2, 3]).include?(2)
- SpecPositiveOperatorMatcher.new("abc").start_with?("ab")
- SpecPositiveOperatorMatcher.new("abc").start_with?("d", "a")
- SpecPositiveOperatorMatcher.new(3).odd?
- SpecPositiveOperatorMatcher.new([1, 2]).any? { |e| e.even? }
+ it "provides a failure message that 'Expected x to be less than or equal to y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 5\n", "to be less than or equal to 4\n")
+ SpecPositiveOperatorMatcher.new(5) <= 4
end
- it "provide a failure message when the predicate returns a falsy value" do
- lambda {
- SpecPositiveOperatorMatcher.new(2).eql?(3)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.eql? 3\nto be truthy but was false")
- lambda {
- SpecPositiveOperatorMatcher.new(2).equal?(3)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.equal? 3\nto be truthy but was false")
- lambda {
- SpecPositiveOperatorMatcher.new([1, 2, 3]).include?(4)
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 4\nto be truthy but was false")
- lambda {
- SpecPositiveOperatorMatcher.new("abc").start_with?("de")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"de\"\nto be truthy but was false")
- lambda {
- SpecPositiveOperatorMatcher.new("abc").start_with?("d", "e")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"e\"\nto be truthy but was false")
- lambda {
- SpecPositiveOperatorMatcher.new(2).odd?
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.odd?\nto be truthy but was false")
- lambda {
- SpecPositiveOperatorMatcher.new([1, 3]).any? { |e| e.even? }
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 3].any? { ... }\nto be truthy but was false")
+ it "does not raise an exception when expected < actual returns true" do
+ SpecPositiveOperatorMatcher.new(4) <= 5
+ SpecPositiveOperatorMatcher.new(4) <= 4
end
end
-describe SpecNegativeOperatorMatcher, "arbitrary predicates" do
- it "do not raise an exception when the predicate returns a falsy value" do
- SpecNegativeOperatorMatcher.new(2).eql?(3)
- SpecNegativeOperatorMatcher.new(2).equal?(3)
- SpecNegativeOperatorMatcher.new([1, 2, 3]).include?(4)
- SpecNegativeOperatorMatcher.new("abc").start_with?("de")
- SpecNegativeOperatorMatcher.new("abc").start_with?("d", "e")
- SpecNegativeOperatorMatcher.new(2).odd?
- SpecNegativeOperatorMatcher.new([1, 3]).any? { |e| e.even? }
- end
-
- it "provide a failure message when the predicate returns a truthy value" do
- lambda {
- SpecNegativeOperatorMatcher.new(2).eql?(2)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.eql? 2\nto be falsy but was true")
- lambda {
- SpecNegativeOperatorMatcher.new(2).equal?(2)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.equal? 2\nto be falsy but was true")
- lambda {
- SpecNegativeOperatorMatcher.new([1, 2, 3]).include?(2)
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 2\nto be falsy but was true")
- lambda {
- SpecNegativeOperatorMatcher.new("abc").start_with?("ab")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"ab\"\nto be falsy but was true")
- lambda {
- SpecNegativeOperatorMatcher.new("abc").start_with?("d", "a")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"a\"\nto be falsy but was true")
- lambda {
- SpecNegativeOperatorMatcher.new(3).odd?
- }.should raise_error(SpecExpectationNotMetError, "Expected 3.odd?\nto be falsy but was true")
+describe SpecNegativeOperatorMatcher, "== operator" do
+ it "raises an SpecExpectationNotMetError when expected == actual returns true" do
lambda {
- SpecNegativeOperatorMatcher.new([1, 2]).any? { |e| e.even? }
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2].any? { ... }\nto be falsy but was true")
+ SpecNegativeOperatorMatcher.new(1) == 1
+ }.should raise_error(SpecExpectationNotMetError)
end
-end
-describe SpecNegativeOperatorMatcher, "== operator" do
it "provides a failure message that 'Expected x not to equal y'" do
- lambda {
- SpecNegativeOperatorMatcher.new(1) == 1
- }.should raise_error(SpecExpectationNotMetError, "Expected 1 == 1\nto be falsy but was true")
+ SpecExpectation.should_receive(:fail_with).with("Expected 1\n", "not to equal 1\n")
+ SpecNegativeOperatorMatcher.new(1) == 1
end
- it "does not raise an exception when == returns false" do
+ it "does not raise an exception when expected == actual returns false" do
SpecNegativeOperatorMatcher.new(1) == 2
end
end
describe SpecNegativeOperatorMatcher, "=~ operator" do
- it "provides a failure message that 'Expected \"x\" not to match /y/'" do
+ it "raises an SpecExpectationNotMetError when expected =~ actual returns true" do
lambda {
SpecNegativeOperatorMatcher.new('real') =~ /real/
- }.should raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /real/\nto be falsy but was 0")
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "does not raise an exception when =~ returns false" do
+ it "provides a failure message that 'Expected \"x\" not to match /y/'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected \"real\"\n", "not to match /real/\n")
+ SpecNegativeOperatorMatcher.new('real') =~ /real/
+ end
+
+ it "does not raise an exception when expected =~ actual returns false" do
SpecNegativeOperatorMatcher.new('real') =~ /fake/
end
end
describe SpecNegativeOperatorMatcher, "< operator" do
- it "provides a failure message that 'Expected x not to be less than y'" do
+ it "raises an SpecExpectationNotMetError when expected < actual returns true" do
lambda {
SpecNegativeOperatorMatcher.new(4) < 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 < 5\nto be falsy but was true")
+ }.should raise_error(SpecExpectationNotMetError)
+ end
+
+ it "provides a failure message that 'Expected x not to be less than y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "not to be less than 5\n")
+ SpecNegativeOperatorMatcher.new(4) < 5
end
- it "does not raise an exception when < returns false" do
+ it "does not raise an exception when expected < actual returns false" do
SpecNegativeOperatorMatcher.new(5) < 4
end
end
describe SpecNegativeOperatorMatcher, "<= operator" do
- it "provides a failure message that 'Expected x not to be less than or equal to y'" do
+ it "raises an SpecExpectationNotMetError when expected <= actual returns true" do
lambda {
SpecNegativeOperatorMatcher.new(4) <= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 <= 5\nto be falsy but was true")
+ }.should raise_error(SpecExpectationNotMetError)
lambda {
SpecNegativeOperatorMatcher.new(5) <= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 <= 5\nto be falsy but was true")
+ }.should raise_error(SpecExpectationNotMetError)
+ end
+
+ it "provides a failure message that 'Expected x not to be less than or equal to y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "not to be less than or equal to 5\n")
+ SpecNegativeOperatorMatcher.new(4) <= 5
end
- it "does not raise an exception when <= returns false" do
+ it "does not raise an exception when expected <= actual returns false" do
SpecNegativeOperatorMatcher.new(5) <= 4
end
end
describe SpecNegativeOperatorMatcher, "> operator" do
- it "provides a failure message that 'Expected x not to be greater than y'" do
+ it "raises an SpecExpectationNotMetError when expected > actual returns true" do
lambda {
SpecNegativeOperatorMatcher.new(5) > 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 > 4\nto be falsy but was true")
+ }.should raise_error(SpecExpectationNotMetError)
+ end
+
+ it "provides a failure message that 'Expected x not to be greater than y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 5\n", "not to be greater than 4\n")
+ SpecNegativeOperatorMatcher.new(5) > 4
end
- it "does not raise an exception when > returns false" do
+ it "does not raise an exception when expected > actual returns false" do
SpecNegativeOperatorMatcher.new(4) > 5
end
end
describe SpecNegativeOperatorMatcher, ">= operator" do
- it "provides a failure message that 'Expected x not to be greater than or equal to y'" do
+ it "raises an SpecExpectationNotMetError when expected >= actual returns true" do
lambda {
SpecNegativeOperatorMatcher.new(5) >= 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 >= 4\nto be falsy but was true")
+ }.should raise_error(SpecExpectationNotMetError)
lambda {
SpecNegativeOperatorMatcher.new(5) >= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 >= 5\nto be falsy but was true")
+ }.should raise_error(SpecExpectationNotMetError)
+ end
+
+ it "provides a failure message that 'Expected x not to be greater than or equal to y'" do
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 5\n", "not to be greater than or equal to 4\n")
+ SpecNegativeOperatorMatcher.new(5) >= 4
end
- it "does not raise an exception when >= returns false" do
+ it "does not raise an exception when expected >= actual returns false" do
SpecNegativeOperatorMatcher.new(4) >= 5
end
end
diff --git a/spec/mspec/spec/matchers/be_close_spec.rb b/spec/mspec/spec/matchers/be_close_spec.rb
index 6edff98e4a..9b6e56e6d5 100644
--- a/spec/mspec/spec/matchers/be_close_spec.rb
+++ b/spec/mspec/spec/matchers/be_close_spec.rb
@@ -16,14 +16,12 @@ describe BeCloseMatcher do
BeCloseMatcher.new(5.0, 0.5).matches?(4.51).should == true
end
- it "matches when actual == (expected + tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(5.5).should == true
- BeCloseMatcher.new(3, 2).matches?(5).should == true
+ it "does not match when actual == (expected + tolerance)" do
+ BeCloseMatcher.new(5.0, 0.5).matches?(5.5).should == false
end
- it "matches when actual == (expected - tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(4.5).should == true
- BeCloseMatcher.new(3, 2).matches?(1).should == true
+ it "does not match when actual == (expected - tolerance)" do
+ BeCloseMatcher.new(5.0, 0.5).matches?(4.5).should == false
end
it "does not match when actual < (expected - tolerance)" do
diff --git a/spec/mspec/spec/matchers/complain_spec.rb b/spec/mspec/spec/matchers/complain_spec.rb
index 90f94c3684..709b57be6c 100644
--- a/spec/mspec/spec/matchers/complain_spec.rb
+++ b/spec/mspec/spec/matchers/complain_spec.rb
@@ -8,7 +8,7 @@ describe ComplainMatcher do
ComplainMatcher.new(nil).matches?(proc).should == true
end
- it "matches when executing the proc results in the expected output to $stderr" do
+ it "maches when executing the proc results in the expected output to $stderr" do
proc = lambda { warn "Que haces?" }
ComplainMatcher.new("Que haces?\n").matches?(proc).should == true
ComplainMatcher.new("Que pasa?\n").matches?(proc).should == false
@@ -49,49 +49,4 @@ describe ComplainMatcher do
matcher.negative_failure_message.should ==
["Expected warning not to match: /ou/", "but got: \"ouch\""]
end
-
- context "`verbose` option specified" do
- before do
- $VERBOSE, @verbose = nil, $VERBOSE
- end
-
- after do
- $VERBOSE = @verbose
- end
-
- it "sets $VERBOSE with specified second optional parameter" do
- verbose = nil
- proc = lambda { verbose = $VERBOSE }
-
- ComplainMatcher.new(nil, verbose: true).matches?(proc)
- verbose.should == true
-
- ComplainMatcher.new(nil, verbose: false).matches?(proc)
- verbose.should == false
- end
-
- it "sets $VERBOSE with false by default" do
- verbose = nil
- proc = lambda { verbose = $VERBOSE }
-
- ComplainMatcher.new(nil).matches?(proc)
- verbose.should == false
- end
-
- it "does not have side effect" do
- proc = lambda { safe_value = $VERBOSE }
-
- lambda do
- ComplainMatcher.new(nil, verbose: true).matches?(proc)
- end.should_not change { $VERBOSE }
- end
-
- it "accepts a verbose level as single argument" do
- verbose = nil
- proc = lambda { verbose = $VERBOSE }
-
- ComplainMatcher.new(verbose: true).matches?(proc)
- verbose.should == true
- end
- end
end
diff --git a/spec/mspec/spec/matchers/eql_spec.rb b/spec/mspec/spec/matchers/eql_spec.rb
index f29e6976da..711ebdb679 100644
--- a/spec/mspec/spec/matchers/eql_spec.rb
+++ b/spec/mspec/spec/matchers/eql_spec.rb
@@ -22,12 +22,12 @@ describe EqlMatcher do
it "provides a useful failure message" do
matcher = EqlMatcher.new("red")
matcher.matches?("red")
- matcher.failure_message.should == ["Expected \"red\"", "to have same value and type as \"red\""]
+ matcher.failure_message.should == ["Expected \"red\"\n", "to have same value and type as \"red\"\n"]
end
it "provides a useful negative failure message" do
matcher = EqlMatcher.new(1)
matcher.matches?(1.0)
- matcher.negative_failure_message.should == ["Expected 1.0", "not to have same value or type as 1"]
+ matcher.negative_failure_message.should == ["Expected 1.0\n", "not to have same value or type as 1\n"]
end
end
diff --git a/spec/mspec/spec/matchers/equal_element_spec.rb b/spec/mspec/spec/matchers/equal_element_spec.rb
index 06fae762c4..45b8390364 100644
--- a/spec/mspec/spec/matchers/equal_element_spec.rb
+++ b/spec/mspec/spec/matchers/equal_element_spec.rb
@@ -48,28 +48,28 @@ describe EqualElementMatcher do
it "provides a useful failure message" do
equal_element = EqualElementMatcher.new("A", {}, "Test")
equal_element.matches?('<A></A>').should be_false
- equal_element.failure_message.should == [%{Expected "<A></A>"}, %{to be a 'A' element with no attributes and "Test" as content}]
+ equal_element.failure_message.should == [%{Expected "<A></A>"\n}, %{to be a 'A' element with no attributes and "Test" as content}]
equal_element = EqualElementMatcher.new("A", {}, "")
equal_element.matches?('<A>Test</A>').should be_false
- equal_element.failure_message.should == [%{Expected "<A>Test</A>"}, %{to be a 'A' element with no attributes and no content}]
+ equal_element.failure_message.should == [%{Expected "<A>Test</A>"\n}, %{to be a 'A' element with no attributes and no content}]
equal_element = EqualElementMatcher.new("A", "HREF" => "http://www.example.com")
equal_element.matches?('<A>Test</A>').should be_false
- equal_element.failure_message.should == [%{Expected "<A>Test</A>"}, %{to be a 'A' element with HREF="http://www.example.com" and any content}]
+ equal_element.failure_message.should == [%{Expected "<A>Test</A>"\n}, %{to be a 'A' element with HREF="http://www.example.com" and any content}]
end
it "provides a useful negative failure message" do
equal_element = EqualElementMatcher.new("A", {}, "Test")
equal_element.matches?('<A></A>').should be_false
- equal_element.negative_failure_message.should == [%{Expected "<A></A>"}, %{not to be a 'A' element with no attributes and "Test" as content}]
+ equal_element.negative_failure_message.should == [%{Expected "<A></A>"\n}, %{not to be a 'A' element with no attributes and "Test" as content}]
equal_element = EqualElementMatcher.new("A", {}, "")
equal_element.matches?('<A>Test</A>').should be_false
- equal_element.negative_failure_message.should == [%{Expected "<A>Test</A>"}, %{not to be a 'A' element with no attributes and no content}]
+ equal_element.negative_failure_message.should == [%{Expected "<A>Test</A>"\n}, %{not to be a 'A' element with no attributes and no content}]
equal_element = EqualElementMatcher.new("A", "HREF" => "http://www.example.com")
equal_element.matches?('<A>Test</A>').should be_false
- equal_element.negative_failure_message.should == [%{Expected "<A>Test</A>"}, %{not to be a 'A' element with HREF="http://www.example.com" and any content}]
+ equal_element.negative_failure_message.should == [%{Expected "<A>Test</A>"\n}, %{not to be a 'A' element with HREF="http://www.example.com" and any content}]
end
end
diff --git a/spec/mspec/spec/matchers/equal_spec.rb b/spec/mspec/spec/matchers/equal_spec.rb
index a61432b750..ca7bf83fdd 100644
--- a/spec/mspec/spec/matchers/equal_spec.rb
+++ b/spec/mspec/spec/matchers/equal_spec.rb
@@ -21,12 +21,12 @@ describe EqualMatcher do
it "provides a useful failure message" do
matcher = EqualMatcher.new("red")
matcher.matches?("red")
- matcher.failure_message.should == ["Expected \"red\"", "to be identical to \"red\""]
+ matcher.failure_message.should == ["Expected \"red\"\n", "to be identical to \"red\"\n"]
end
it "provides a useful negative failure message" do
matcher = EqualMatcher.new(1)
matcher.matches?(1)
- matcher.negative_failure_message.should == ["Expected 1", "not to be identical to 1"]
+ matcher.negative_failure_message.should == ["Expected 1\n", "not to be identical to 1\n"]
end
end
diff --git a/spec/mspec/spec/matchers/include_any_of_spec.rb b/spec/mspec/spec/matchers/include_any_of_spec.rb
deleted file mode 100644
index 697c8d8886..0000000000
--- a/spec/mspec/spec/matchers/include_any_of_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'spec_helper'
-require 'mspec/expectations/expectations'
-require 'mspec/matchers'
-
-describe IncludeAnyOfMatcher do
- it "matches when actual includes expected" do
- IncludeAnyOfMatcher.new(2).matches?([1,2,3]).should == true
- IncludeAnyOfMatcher.new("b").matches?("abc").should == true
- end
-
- it "does not match when actual does not include expected" do
- IncludeAnyOfMatcher.new(4).matches?([1,2,3]).should == false
- IncludeAnyOfMatcher.new("d").matches?("abc").should == false
- end
-
- it "matches when actual includes all expected" do
- IncludeAnyOfMatcher.new(3, 2, 1).matches?([1,2,3]).should == true
- IncludeAnyOfMatcher.new("a", "b", "c").matches?("abc").should == true
- end
-
- it "matches when actual includes any expected" do
- IncludeAnyOfMatcher.new(3, 4, 5).matches?([1,2,3]).should == true
- IncludeAnyOfMatcher.new("c", "d", "e").matches?("abc").should == true
- end
-
- it "does not match when actual does not include any expected" do
- IncludeAnyOfMatcher.new(4, 5).matches?([1,2,3]).should == false
- IncludeAnyOfMatcher.new("de").matches?("abc").should == false
- end
-
- it "provides a useful failure message" do
- matcher = IncludeAnyOfMatcher.new(5, 6)
- matcher.matches?([1,2,3])
- matcher.failure_message.should == ["Expected [1, 2, 3]", "to include any of [5, 6]"]
- end
-
- it "provides a useful negative failure message" do
- matcher = IncludeAnyOfMatcher.new(1, 2, 3)
- matcher.matches?([1,2])
- matcher.negative_failure_message.should == ["Expected [1, 2]", "not to include any of [1, 2, 3]"]
- end
-end
diff --git a/spec/mspec/spec/matchers/raise_error_spec.rb b/spec/mspec/spec/matchers/raise_error_spec.rb
index 1ed794e0a9..7c93f0f64c 100644
--- a/spec/mspec/spec/matchers/raise_error_spec.rb
+++ b/spec/mspec/spec/matchers/raise_error_spec.rb
@@ -74,18 +74,6 @@ describe RaiseErrorMatcher do
["Expected ExpectedException (expected)", "but got UnexpectedException (unexpected)"]
end
- it "provides a useful failure message when the proc raises the expected exception with an unexpected message" do
- exc = ExpectedException.new("unexpected")
- matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
-
- matcher.matching_exception?(exc).should == false
- lambda {
- matcher.matches?(Proc.new { raise exc })
- }.should raise_error(ExpectedException)
- matcher.failure_message.should ==
- ["Expected ExpectedException (expected)", "but got ExpectedException (unexpected)"]
- end
-
it "provides a useful failure message when no exception is raised" do
proc = Proc.new { 120 }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
@@ -111,7 +99,7 @@ describe RaiseErrorMatcher do
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
matcher.failure_message.should ==
- ["Expected ExpectedException (expected)", "but no exception was raised (#<Object>(#pretty_inspect raised #<ArgumentError: bad>) was returned)"]
+ ["Expected ExpectedException (expected)", "but no exception was raised (#pretty_inspect raised ArgumentError; A #<Object> was returned)"]
end
it "provides a useful negative failure message" do
diff --git a/spec/mspec/spec/mocks/mock_spec.rb b/spec/mspec/spec/mocks/mock_spec.rb
index 8cf04cf462..c814ec7bfe 100644
--- a/spec/mspec/spec/mocks/mock_spec.rb
+++ b/spec/mspec/spec/mocks/mock_spec.rb
@@ -313,58 +313,6 @@ describe Mock, ".verify_call" do
end
end
-describe Mock, ".verify_call mixing mocks and stubs" do
- before :each do
- MSpec.stub(:actions)
- MSpec.stub(:current).and_return(double("spec state").as_null_object)
-
- @mock = double('verify_call')
- end
-
- after :each do
- ScratchPad.clear
- Mock.cleanup
- end
-
- it "checks the mock arguments when a mock is defined after a stub" do
- Mock.install_method @mock, :method_call, :stub
- Mock.install_method(@mock, :method_call, :mock).with("arg")
-
- -> {
- @mock.method_call
- }.should raise_error(SpecExpectationNotMetError, /called with unexpected arguments \(\)/)
-
- -> {
- @mock.method_call("a", "b")
- }.should raise_error(SpecExpectationNotMetError, /called with unexpected arguments \("a", "b"\)/)
-
- -> {
- @mock.method_call("foo")
- }.should raise_error(SpecExpectationNotMetError, /called with unexpected arguments \("foo"\)/)
-
- @mock.method_call("arg")
- end
-
- it "checks the mock arguments when a stub is defined after a mock" do
- Mock.install_method(@mock, :method_call, :mock).with("arg")
- Mock.install_method @mock, :method_call, :stub
-
- -> {
- @mock.method_call
- }.should raise_error(SpecExpectationNotMetError, /called with unexpected arguments \(\)/)
-
- -> {
- @mock.method_call("a", "b")
- }.should raise_error(SpecExpectationNotMetError, /called with unexpected arguments \("a", "b"\)/)
-
- -> {
- @mock.method_call("foo")
- }.should raise_error(SpecExpectationNotMetError, /called with unexpected arguments \("foo"\)/)
-
- @mock.method_call("arg")
- end
-end
-
describe Mock, ".verify_count" do
before :each do
MSpec.stub(:actions)
@@ -448,11 +396,6 @@ describe Mock, ".verify_count mixing mocks and stubs" do
it "verifies the calls to the mocked method when a mock is defined after a stub" do
Mock.install_method @mock, :method_call, :stub
Mock.install_method @mock, :method_call, :mock
-
- -> {
- Mock.verify_count
- }.should raise_error(SpecExpectationNotMetError, /received it 0 times/)
-
@mock.method_call
Mock.verify_count
end
@@ -460,11 +403,6 @@ describe Mock, ".verify_count mixing mocks and stubs" do
it "verifies the calls to the mocked method when a mock is defined before a stub" do
Mock.install_method @mock, :method_call, :mock
Mock.install_method @mock, :method_call, :stub
-
- -> {
- Mock.verify_count
- }.should raise_error(SpecExpectationNotMetError, /received it 0 times/)
-
@mock.method_call
Mock.verify_count
end
@@ -477,6 +415,7 @@ describe Mock, ".cleanup" do
@mock = double('cleanup')
@proxy = Mock.install_method @mock, :method_call
+ @stub = Mock.install_method @mock, :method_call, :stub
end
after :each do
@@ -510,8 +449,6 @@ describe Mock, ".cleanup" do
end
it "removes all stubs" do
- Mock.cleanup # remove @proxy
- @stub = Mock.install_method @mock, :method_call, :stub
Mock.stubs.should == { Mock.replaced_key(@mock, :method_call) => [@stub] }
Mock.cleanup
Mock.stubs.should == {}
diff --git a/spec/mspec/spec/runner/filters/regexp_spec.rb b/spec/mspec/spec/runner/filters/regexp_spec.rb
index 8e9b0ec7e8..6c05b0f42f 100644
--- a/spec/mspec/spec/runner/filters/regexp_spec.rb
+++ b/spec/mspec/spec/runner/filters/regexp_spec.rb
@@ -2,30 +2,12 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require 'mspec/runner/mspec'
require 'mspec/runner/filters/regexp'
-describe MatchFilter, "#===" do
- before :each do
- @filter = RegexpFilter.new nil, 'a(b|c)', 'b[^ab]', 'cc?'
- end
-
- it "returns true if the argument matches any of the #initialize strings" do
- @filter.===('ab').should == true
- @filter.===('bc suffix').should == true
- @filter.===('prefix cc').should == true
- end
-
- it "returns false if the argument matches none of the #initialize strings" do
- @filter.===('aa').should == false
- @filter.===('ba').should == false
- @filter.===('prefix d suffix').should == false
- end
-end
-
describe RegexpFilter, "#to_regexp" do
before :each do
@filter = RegexpFilter.new nil
end
it "converts its arguments to Regexp instances" do
- @filter.send(:to_regexp, 'a(b|c)', 'b[^ab]', 'cc?').should == [/a(b|c)/, /b[^ab]/, /cc?/]
+ @filter.to_regexp('a(b|c)', 'b[^ab]', 'cc?').should == [/a(b|c)/, /b[^ab]/, /cc?/]
end
end
diff --git a/spec/mspec/spec/runner/formatters/dotted_spec.rb b/spec/mspec/spec/runner/formatters/dotted_spec.rb
index 5af2ff55f8..1e9b06f6e1 100644
--- a/spec/mspec/spec/runner/formatters/dotted_spec.rb
+++ b/spec/mspec/spec/runner/formatters/dotted_spec.rb
@@ -91,7 +91,7 @@ describe DottedFormatter, "#exception" do
@formatter.exception?.should be_true
end
- it "adds the exception to the list of exceptions" do
+ it "addes the exception to the list of exceptions" do
@formatter.exceptions.should == []
@formatter.exception @error
@formatter.exception @failure
diff --git a/spec/mspec/spec/runner/formatters/multi_spec.rb b/spec/mspec/spec/runner/formatters/multi_spec.rb
index d0ed8edc93..afcc7e9cea 100644
--- a/spec/mspec/spec/runner/formatters/multi_spec.rb
+++ b/spec/mspec/spec/runner/formatters/multi_spec.rb
@@ -1,8 +1,6 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'mspec/runner/formatters/dotted'
require 'mspec/runner/formatters/multi'
require 'mspec/runner/example'
-require 'yaml'
describe MultiFormatter, "#aggregate_results" do
before :each do
@@ -11,12 +9,12 @@ describe MultiFormatter, "#aggregate_results" do
@file = double("file").as_null_object
File.stub(:delete)
- File.stub(:read)
+ YAML.stub(:load)
@hash = { "files"=>1, "examples"=>1, "expectations"=>2, "failures"=>0, "errors"=>0 }
- YAML.stub(:load).and_return(@hash)
+ File.stub(:open).and_yield(@file).and_return(@hash)
- @formatter = DottedFormatter.new.extend(MultiFormatter)
+ @formatter = MultiFormatter.new
@formatter.timer.stub(:format).and_return("Finished in 42 seconds")
end
diff --git a/spec/mspec/spec/spec_helper.rb b/spec/mspec/spec/spec_helper.rb
index a307eaf460..0d497f6627 100644
--- a/spec/mspec/spec/spec_helper.rb
+++ b/spec/mspec/spec/spec_helper.rb
@@ -1,4 +1,4 @@
-require 'mspec/utils/format'
+require 'pp'
require 'mspec/helpers/io'
require 'mspec/helpers/scratch'
diff --git a/spec/mspec/spec/utils/name_map_spec.rb b/spec/mspec/spec/utils/name_map_spec.rb
index d5d2cca84a..d38230ce06 100644
--- a/spec/mspec/spec/utils/name_map_spec.rb
+++ b/spec/mspec/spec/utils/name_map_spec.rb
@@ -129,7 +129,7 @@ describe NameMap, "#file_name" do
it "returns the name of the spec file based on the special entry for the method" do
@map.file_name("~", "Regexp").should == "match_spec.rb"
- @map.file_name("~", "Integer").should == "complement_spec.rb"
+ @map.file_name("~", "Fixnum").should == "complement_spec.rb"
end
it "returns the name of the spec file based on the default entry for the method" do
@@ -137,7 +137,7 @@ describe NameMap, "#file_name" do
end
it "uses the last component of the constant to look up the method name" do
- @map.file_name("^", "NameMapSpecs::Integer").should == "bit_xor_spec.rb"
+ @map.file_name("^", "NameMapSpecs::Fixnum").should == "bit_xor_spec.rb"
end
end
diff --git a/spec/mspec/spec/utils/script_spec.rb b/spec/mspec/spec/utils/script_spec.rb
index 3cc85fa1e2..2582809fae 100644
--- a/spec/mspec/spec/utils/script_spec.rb
+++ b/spec/mspec/spec/utils/script_spec.rb
@@ -350,20 +350,20 @@ describe MSpecScript, "#entries" do
before :each do
@script = MSpecScript.new
- File.stub(:realpath).and_return("name")
+ File.stub(:expand_path).and_return("name")
File.stub(:file?).and_return(false)
File.stub(:directory?).and_return(false)
end
it "returns the pattern in an array if it is a file" do
- File.should_receive(:realpath).with("file").and_return("file/expanded.rb")
+ File.should_receive(:expand_path).with("file").and_return("file/expanded.rb")
File.should_receive(:file?).with("file/expanded.rb").and_return(true)
@script.entries("file").should == ["file/expanded.rb"]
end
it "returns Dir['pattern/**/*_spec.rb'] if pattern is a directory" do
File.should_receive(:directory?).with("name").and_return(true)
- File.stub(:realpath).and_return("name", "name/**/*_spec.rb")
+ File.stub(:expand_path).and_return("name","name/**/*_spec.rb")
Dir.should_receive(:[]).with("name/**/*_spec.rb").and_return(["dir1", "dir2"])
@script.entries("name").should == ["dir1", "dir2"]
end
@@ -382,13 +382,13 @@ describe MSpecScript, "#entries" do
it "returns the pattern in an array if it is a file" do
name = "#{@name}.rb"
- File.should_receive(:realpath).with(name).and_return(name)
+ File.should_receive(:expand_path).with(name).and_return(name)
File.should_receive(:file?).with(name).and_return(true)
@script.entries("name.rb").should == [name]
end
it "returns Dir['pattern/**/*_spec.rb'] if pattern is a directory" do
- File.stub(:realpath).and_return(@name, @name+"/**/*_spec.rb")
+ File.stub(:expand_path).and_return(@name, @name+"/**/*_spec.rb")
File.should_receive(:directory?).with(@name).and_return(true)
Dir.should_receive(:[]).with(@name + "/**/*_spec.rb").and_return(["dir1", "dir2"])
@script.entries("name").should == ["dir1", "dir2"]
@@ -406,7 +406,7 @@ describe MSpecScript, "#files" do
@script = MSpecScript.new
end
- it "accumulates the values returned by #entries" do
+ it "accumlates the values returned by #entries" do
@script.should_receive(:entries).and_return(["file1"], ["file2"])
@script.files(["a", "b"]).should == ["file1", "file2"]
end
diff --git a/spec/mspec/tool/pull-latest-mspec-spec b/spec/mspec/tool/pull-latest-mspec-spec
deleted file mode 100755
index 154a353e64..0000000000
--- a/spec/mspec/tool/pull-latest-mspec-spec
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-# Assumes all commits have been synchronized to https://github.com/ruby/spec
-# See spec/mspec/tool/sync/sync-rubyspec.rb
-
-function sync {
- dir="$1"
- repo="$2"
- short_repo_name="ruby/$(basename "$repo" .git)"
-
- rm -rf "$dir"
- git clone --depth 1 "$repo" "$dir"
- commit=$(git -C "$dir" log -n 1 --format='%h')
- rm -rf "$dir/.git"
-
- # Remove CI files to avoid confusion
- rm -f "$dir/appveyor.yml"
- rm -f "$dir/.travis.yml"
- rm -rf "$dir/.github"
-
- git add "$dir"
- git commit -m "Update to ${short_repo_name}@${commit}"
-}
-
-sync spec/mspec https://github.com/ruby/mspec.git
-sync spec/ruby https://github.com/ruby/spec.git
diff --git a/spec/mspec/tool/remove_old_guards.rb b/spec/mspec/tool/remove_old_guards.rb
index d6ed619d98..feb4ee4662 100644
--- a/spec/mspec/tool/remove_old_guards.rb
+++ b/spec/mspec/tool/remove_old_guards.rb
@@ -1,6 +1,4 @@
-# Removes old version guards in ruby/spec.
-# Run it from the ruby/spec repository root.
-# The argument is the new minimum supported version.
+# Remove old version guards in ruby/spec
def dedent(line)
if line.start_with?(" ")
@@ -10,13 +8,9 @@ def dedent(line)
end
end
-def each_spec_file(&block)
- Dir["*/**/*.rb"].each(&block)
-end
-
def remove_guards(guard, keep)
- each_spec_file do |file|
- contents = File.binread(file)
+ Dir["*/**/*.rb"].each do |file|
+ contents = File.read(file)
if contents =~ guard
puts file
lines = contents.lines.to_a
@@ -37,29 +31,11 @@ def remove_guards(guard, keep)
lines[first..last] = []
end
end
- File.binwrite file, lines.join
- end
- end
-end
-
-def search(regexp)
- each_spec_file do |file|
- contents = File.binread(file)
- if contents =~ regexp
- puts file
- contents.each_line do |line|
- if line =~ regexp
- puts line
- end
- end
+ File.write file, lines.join
end
end
end
-version = Regexp.escape(ARGV.fetch(0))
+version = (ARGV[0] || "2.2")
remove_guards(/ruby_version_is ["']#{version}["'] do/, true)
remove_guards(/ruby_version_is ["'][0-9.]*["']...["']#{version}["'] do/, false)
-remove_guards(/ruby_bug "#\d+", ["'][0-9.]*["']...["']#{version}["'] do/, true)
-
-search(/["']#{version}["']/)
-search(/^\s*#.+#{version}/)
diff --git a/spec/mspec/tool/sync/sync-rubyspec.rb b/spec/mspec/tool/sync/sync-rubyspec.rb
index 48047e013f..fbd37fe95b 100644
--- a/spec/mspec/tool/sync/sync-rubyspec.rb
+++ b/spec/mspec/tool/sync/sync-rubyspec.rb
@@ -1,6 +1,6 @@
IMPLS = {
truffleruby: {
- git: "https://github.com/oracle/truffleruby.git",
+ git: "https://github.com/graalvm/truffleruby.git",
from_commit: "f10ab6988d",
},
jruby: {
@@ -13,14 +13,12 @@ IMPLS = {
mri: {
git: "https://github.com/ruby/ruby.git",
master: "trunk",
+ merge_message: "Update to ruby/spec@",
},
}
MSPEC = ARGV.delete('--mspec')
-CHECK_LAST_MERGE = ENV['CHECK_LAST_MERGE'] != 'false'
-TEST_TRUNK = ENV['TEST_TRUNK'] != 'false'
-
MSPEC_REPO = File.expand_path("../../..", __FILE__)
raise MSPEC_REPO if !Dir.exist?(MSPEC_REPO) or !Dir.exist?("#{MSPEC_REPO}/.git")
@@ -66,7 +64,7 @@ class RubyImplementation
end
def last_merge_message
- message = @data[:merge_message] || "Update to ruby/spec@"
+ message = @data[:merge_message] || "Merge ruby/spec commit"
message.gsub!("ruby/spec", "ruby/mspec") if MSPEC
message
end
@@ -147,7 +145,7 @@ def rebase_commits(impl)
commit_date = Time.at(Integer(commit_timestamp))
days_since_last_merge = (NOW-commit_date) / 86400
- if CHECK_LAST_MERGE and days_since_last_merge > 60
+ if days_since_last_merge > 60
raise "#{days_since_last_merge.floor} days since last merge, probably wrong commit"
end
@@ -162,30 +160,43 @@ end
def test_new_specs
require "yaml"
Dir.chdir(SOURCE_REPO) do
- versions = YAML.load_file("#{MSPEC_REPO}/.travis.yml").fetch("rvm")
- versions = versions.grep(/^\d+\./) # Test on MRI
- min_version, max_version = versions.minmax
-
- test_command = MSPEC ? "bundle exec rspec" : "../mspec/bin/mspec -j"
-
- run_test = -> version {
- command = "chruby #{version} && #{test_command}"
- sh ENV["SHELL"], "-c", command
- }
-
- run_test[min_version]
- run_test[max_version]
- run_test["trunk"] if TEST_TRUNK
+ if MSPEC
+ sh "bundle", "exec", "rspec"
+ else
+ versions = YAML.load_file(".travis.yml")
+ versions = versions["matrix"]["include"].map { |job| job["rvm"] }
+ versions.delete "ruby-head"
+ min_version, max_version = versions.minmax
+
+ run_rubyspec = -> version {
+ command = "chruby #{version} && ../mspec/bin/mspec -j"
+ sh ENV["SHELL"], "-c", command
+ }
+ run_rubyspec[min_version]
+ run_rubyspec[max_version]
+ run_rubyspec["trunk"]
+ end
end
end
def verify_commits(impl)
puts
Dir.chdir(SOURCE_REPO) do
+ history = `git log master...`
+ history.lines.slice_before(/^commit \h{40}$/).each do |commit, *message|
+ commit = commit.chomp.split.last
+ message = message.join
+ if /\W(#\d+)/ === message
+ puts "Commit #{commit} contains an unqualified issue number: #{$1}"
+ puts "Replace it with #{impl.repo_org}/#{impl.repo_name}#{$1}"
+ sh "git", "rebase", "-i", "#{commit}^"
+ end
+ end
+
puts "Manually check commit messages:"
print "Press enter >"
STDIN.gets
- system "git", "log", "master..."
+ sh "git", "log", "master..."
end
end
@@ -193,7 +204,6 @@ def fast_forward_master(impl)
Dir.chdir(SOURCE_REPO) do
sh "git", "checkout", "master"
sh "git", "merge", "--ff-only", "#{impl.name}-rebased"
- sh "git", "branch", "--delete", "#{impl.name}-rebased"
end
end
diff --git a/spec/mspec/tool/tag_from_output.rb b/spec/mspec/tool/tag_from_output.rb
deleted file mode 100755
index 43fc4808bc..0000000000
--- a/spec/mspec/tool/tag_from_output.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env ruby
-
-# Adds tags based on error and failures output (e.g., from a CI log),
-# without running any spec code.
-
-tags_dir = %w[
- spec/tags
- spec/tags/ruby
-].find { |dir| Dir.exist?("#{dir}/language") }
-abort 'Could not find tags directory' unless tags_dir
-
-output = ARGF.readlines
-
-NUMBER = /^\d+\)$/
-ERROR_OR_FAILED = / (ERROR|FAILED)$/
-SPEC_FILE = /^(\/.+_spec\.rb)\:\d+/
-
-output.slice_before(NUMBER).select { |number, error_line, *rest|
- number =~ NUMBER and error_line =~ ERROR_OR_FAILED
-}.each { |number, error_line, *rest|
- description = error_line.match(ERROR_OR_FAILED).pre_match
-
- spec_file = rest.find { |line| line =~ SPEC_FILE }
- unless spec_file
- warn "Could not find file for:\n#{error_line}"
- next
- end
- spec_file = spec_file[SPEC_FILE, 1]
- prefix = spec_file.index('spec/ruby')
- spec_file = spec_file[prefix..-1]
-
- tags_file = spec_file.sub('spec/ruby/', "#{tags_dir}/").sub(/_spec\.rb$/, '_tags.txt')
-
- dir = File.dirname(tags_file)
- Dir.mkdir(dir) unless Dir.exist?(dir)
-
- tag_line = "fails:#{description}"
- lines = File.exist?(tags_file) ? File.readlines(tags_file, chomp: true) : []
- unless lines.include?(tag_line)
- File.write(tags_file, (lines + [tag_line]).join("\n") + "\n")
- end
-}
diff --git a/spec/ruby/.mspec.constants b/spec/ruby/.mspec.constants
deleted file mode 100644
index e88e58989f..0000000000
--- a/spec/ruby/.mspec.constants
+++ /dev/null
@@ -1,225 +0,0 @@
-Abbrev
-Addrinfo
-AliasObject
-AliasObject2
-AnonWithConstant
-ArbitraryException
-ArraySub
-ArraySubPush
-AryChild
-Base64
-BaseClass
-BasicSocket
-BeCloseToMatrixMatcher
-BigDecimal
-BigMath
-BitwiseAndTest
-BreakTest
-BreakTest2
-CAPI_SIZEOF_LONG
-CApiModuleSpecsAutoload
-CApiModuleSpecsModuleA
-CGI
-CMath
-CODE_LOADING_DIR
-CSAutoloadA
-CSAutoloadB
-CSAutoloadC
-CSAutoloadD
-CSV
-ChainedNextTest
-ChildClass
-ClassIdUnderAutoload
-ClassSpecDefineClass
-ClassSpecsKeywordWithSemicolon
-ClassSpecsKeywordWithoutSemicolon
-ClassSpecsNumber
-ClassUnderAutoload
-CodingUS_ASCII
-CodingUTF_8
-ComparisonTest
-ConstantSpecsIncludedModule
-ConstantVisibility
-Coverage
-CustomArgumentError
-DRb
-DRbIdConv
-DRbObject
-DRbUndumped
-Date
-DateTime
-DefSpecNested
-DefSpecNestedB
-DefSpecSingleton
-DefSpecsLambdaVisibility
-DefineMethodByProcClass
-DefineMethodSpecClass
-DefineSingletonMethodSpecClass
-DescArray
-DescObjectTest
-Digest
-DumpableDir
-ERB
-EnsureInClassExample
-EnumerableSpecGrep
-EnumerableSpecGrep2
-EnumerableSpecIncludeP
-EnumerableSpecIncludeP11
-Etc
-EvalBindingA
-EvalBindingProcA
-Exception2MessageMapper
-ExceptionForMatrix
-Fcntl
-FileStat
-FileUtils
-Find
-Forwardable
-GetoptLong
-HMACConstants
-HashStringsBinary
-HashStringsUSASCII
-HashStringsUTF8
-IPAddr
-IPSocket
-Importer
-IncludeSpecsClass
-IncludeSpecsMiddle
-IncludeSpecsTop
-IncludesMath
-JSON
-KSAutoloadA
-KSAutoloadB
-KSAutoloadBB
-KSAutoloadCallsRequire
-KSAutoloadD
-Logger
-MD5Constants
-MY_INPUT4_FOR_ERB
-Matrix
-MatrixSub
-MethodArity
-Meths
-MethsMore
-Mixin
-ModuleSpecsKeywordWithoutSemicolon
-ModuleSpecsToplevel
-ModuleSpecs_CS1
-ModuleSpecs_CS2
-ModuleSpecs_CS3
-MyClass
-MyClass0ForErb
-MyClass1ForErb
-MyClass1ForErb_
-MyClass2ForErb
-MyClass4ForErb
-MyFiber
-MyModule2ForErb
-MyString
-NamespaceTest
-Net
-OBJDIR
-OBJECT_SPACE_TOP_LEVEL_CONSTANT
-OFor
-ObjectSpaceFixtures
-ObjectSpecDup
-ObjectSpecDupInitCopy
-ObjectTest
-Observable
-Open3
-OpenSSL
-OpenStruct
-OperatorImplementor
-OptParse
-OptionParser
-OrAndXorTest
-OtherCustomException
-ParentClass
-Pathname
-Person
-Prime
-Private
-ProcFromMethod
-Psych
-REXML
-RUBY_SIGNALS
-RbReadline
-Readline
-ReceiverClass
-RegexpSpecsSubclass
-RegexpSpecsSubclassTwo
-RescueInClassExample
-Resolv
-SHA1Constants
-SHA256Constants
-SHA384Constants
-SHA512Constants
-SameName
-ScanError
-Scanf
-SecondClass
-SecureRandom
-Set
-Shellwords
-SingleForwardable
-Singleton
-Socket
-SocketError
-SomeClass
-SortedSet
-SpecificExampleException
-Specs
-StrChild
-StrangeEach
-StringIO
-StringRefinement
-StringScanner
-StringSubclass
-StructClasses
-Syck
-Syslog
-TCPServer
-TCPSocket
-TSort
-Tempfile
-TestServer
-Timeout
-TimeoutError
-UDPSocket
-UNIXServer
-UNIXSocket
-UnaryMinusTest
-UnicodeNormalize
-UnloadableDumpableDir
-UserArray
-UserCustomConstructorString
-UserDefined
-UserDefinedImmediate
-UserDefinedWithIvar
-UserHash
-UserHashInitParams
-UserMarshal
-UserMarshalWithClassName
-UserMarshalWithIvar
-UserObject
-UserPreviouslyDefinedWithInitializedIvar
-UserRegexp
-UserString
-Vector
-WEBrick
-WIN32OLE
-WIN32OLEQueryInterfaceError
-WIN32OLERuntimeError
-WIN32OLE_EVENT
-WIN32OLE_METHOD
-WIN32OLE_PARAM
-WIN32OLE_RECORD
-WIN32OLE_RUBYSPEC
-WIN32OLE_TYPE
-WIN32OLE_TYPELIB
-WIN32OLE_VARIABLE
-WIN32OLE_VARIANT
-WeakRef
-Win32
-YAML
-Zlib
diff --git a/spec/ruby/.rubocop.yml b/spec/ruby/.rubocop.yml
index 77e4e78e77..762fe42bad 100644
--- a/spec/ruby/.rubocop.yml
+++ b/spec/ruby/.rubocop.yml
@@ -10,11 +10,6 @@ AllCops:
Layout/TrailingWhitespace:
Enabled: true
-Layout/TrailingBlankLines:
- Enabled: true
- Exclude:
- - library/coverage/fixtures/some_class.rb
-
Lint:
Enabled: true
@@ -37,9 +32,6 @@ Lint/LiteralAsCondition:
Lint/UnneededRequireStatement:
Enabled: false
-Lint/UnneededSplatExpansion:
- Enabled: false
-
Lint/UnifiedInteger:
Enabled: false
@@ -55,6 +47,7 @@ Lint/UselessAssignment:
Lint/UselessComparison:
Enabled: false
+# The cop registers too many false positives to `.should == something`
Lint/Void:
Enabled: false
@@ -62,63 +55,6 @@ Lint/EmptyExpression:
Exclude:
- 'language/**/*.rb'
-Lint/EmptyWhen:
- Exclude:
- - language/case_spec.rb
- - optional/capi/spec_helper.rb
-
-Lint/FormatParameterMismatch:
- Exclude:
- - 'core/kernel/shared/sprintf.rb'
- - 'core/string/modulo_spec.rb'
-
-Lint/NestedMethodDefinition:
- Exclude:
- - language/def_spec.rb
- - language/fixtures/def.rb
-
-Lint/ShadowingOuterLocalVariable:
- Exclude:
- - 'core/binding/local_variables_spec.rb'
- - 'core/kernel/local_variables_spec.rb'
- - 'language/block_spec.rb'
- - 'language/proc_spec.rb'
-
-Lint/UnreachableCode:
- Exclude:
- - 'core/enumerator/lazy/fixtures/classes.rb'
- - 'core/kernel/catch_spec.rb'
- - 'core/kernel/throw_spec.rb'
- - 'language/break_spec.rb'
- - 'language/fixtures/break.rb'
- - 'language/fixtures/break_lambda_toplevel.rb'
- - 'language/fixtures/break_lambda_toplevel_block.rb'
- - 'language/fixtures/break_lambda_toplevel_method.rb'
- - 'language/fixtures/return.rb'
- - 'language/next_spec.rb'
- - 'language/return_spec.rb'
- - 'optional/capi/kernel_spec.rb'
- - 'shared/kernel/raise.rb'
-
Lint/UriRegexp:
Exclude:
- 'library/uri/regexp_spec.rb'
-
-Lint/Debugger:
- Exclude:
- - 'core/binding/fixtures/irb.rb'
-
-Style/Lambda:
- Enabled: true
- EnforcedStyle: literal
- Exclude:
- - 'language/lambda_spec.rb'
- - 'language/proc_spec.rb'
- - 'core/kernel/lambda_spec.rb'
-
-Style/EmptyLambdaParameter:
- Enabled: true
-
-Style/StabbyLambdaParentheses:
- Enabled: true
- EnforcedStyle: require_no_parentheses
diff --git a/spec/ruby/.rubocop_todo.yml b/spec/ruby/.rubocop_todo.yml
index aac54f62ae..c227ca032d 100644
--- a/spec/ruby/.rubocop_todo.yml
+++ b/spec/ruby/.rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
-# on 2018-04-03 22:23:59 +0900 using RuboCop version 0.54.0.
+# on 2017-12-15 22:14:22 +0900 using RuboCop version 0.52.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -20,6 +20,11 @@ Lint/DuplicateMethods:
- 'core/unboundmethod/fixtures/classes.rb'
- 'fixtures/class.rb'
+# Offense count: 4
+Lint/EmptyWhen:
+ Exclude:
+ - 'language/case_spec.rb'
+
# Offense count: 5
Lint/EnsureReturn:
Exclude:
@@ -32,7 +37,13 @@ Lint/FloatOutOfRange:
Exclude:
- 'core/string/modulo_spec.rb'
-# Offense count: 29
+# Offense count: 107
+Lint/FormatParameterMismatch:
+ Exclude:
+ - 'core/kernel/shared/sprintf.rb'
+ - 'core/string/modulo_spec.rb'
+
+# Offense count: 28
Lint/HandleExceptions:
Enabled: false
@@ -48,7 +59,7 @@ Lint/IneffectiveAccessModifier:
- 'core/module/fixtures/classes.rb'
- 'language/fixtures/private.rb'
-# Offense count: 6
+# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: runtime_error, standard_error
@@ -58,13 +69,13 @@ Lint/InheritException:
- 'core/exception/fixtures/common.rb'
- 'core/module/fixtures/autoload_ex1.rb'
-# Offense count: 5
+# Offense count: 3
# Cop supports --auto-correct.
Lint/LiteralInInterpolation:
Exclude:
- - 'core/module/refine_spec.rb'
- 'language/defined_spec.rb'
- 'language/fixtures/squiggly_heredoc.rb'
+ - 'core/module/refine_spec.rb'
# Offense count: 16
Lint/Loop:
@@ -78,13 +89,20 @@ Lint/MultipleCompare:
Exclude:
- 'language/precedence_spec.rb'
+# Offense count: 8
+Lint/NestedMethodDefinition:
+ Exclude:
+ - 'language/def_spec.rb'
+
# Offense count: 12
Lint/ParenthesesAsGroupedExpression:
Exclude:
+ - 'command_line/rubyopt_spec.rb'
- 'core/string/fixtures/freeze_magic_comment.rb'
- 'language/block_spec.rb'
- 'language/fixtures/send.rb'
- 'language/method_spec.rb'
+ - 'library/socket/socket/getaddrinfo_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
@@ -92,7 +110,7 @@ Lint/RedundantWithIndex:
Exclude:
- 'core/enumerator/with_index_spec.rb'
-# Offense count: 26
+# Offense count: 24
Lint/RescueException:
Exclude:
- 'command_line/fixtures/debug_info.rb'
@@ -110,12 +128,25 @@ Lint/RescueException:
- 'language/rescue_spec.rb'
- 'library/erb/filename_spec.rb'
+# Offense count: 1
+# Cop supports --auto-correct.
+Lint/ScriptPermission:
+ Exclude:
+ - 'command_line/fixtures/bin/launcher.rb'
+
# Offense count: 2
# Configuration parameters: IgnoreImplicitReferences.
Lint/ShadowedArgument:
Exclude:
- 'language/fixtures/super.rb'
+# Offense count: 10
+Lint/ShadowingOuterLocalVariable:
+ Exclude:
+ - 'core/binding/local_variables_spec.rb'
+ - 'language/block_spec.rb'
+ - 'language/proc_spec.rb'
+
# Offense count: 2
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
@@ -129,6 +160,42 @@ Lint/UnderscorePrefixedVariableName:
- 'core/io/popen_spec.rb'
- 'language/block_spec.rb'
+# Offense count: 90
+# Cop supports --auto-correct.
+Lint/UnneededSplatExpansion:
+ Exclude:
+ - 'core/array/element_reference_spec.rb'
+ - 'core/enumerable/fixtures/classes.rb'
+ - 'core/enumerable/max_by_spec.rb'
+ - 'core/enumerable/min_by_spec.rb'
+ - 'core/enumerable/minmax_by_spec.rb'
+ - 'core/enumerator/lazy/fixtures/classes.rb'
+ - 'core/file/basename_spec.rb'
+ - 'core/kernel/p_spec.rb'
+ - 'language/array_spec.rb'
+ - 'language/break_spec.rb'
+ - 'language/case_spec.rb'
+ - 'language/next_spec.rb'
+ - 'language/send_spec.rb'
+ - 'language/variables_spec.rb'
+
+# Offense count: 54
+Lint/UnreachableCode:
+ Exclude:
+ - 'core/enumerator/lazy/fixtures/classes.rb'
+ - 'core/kernel/catch_spec.rb'
+ - 'core/kernel/throw_spec.rb'
+ - 'language/break_spec.rb'
+ - 'language/fixtures/break.rb'
+ - 'language/fixtures/break_lambda_toplevel.rb'
+ - 'language/fixtures/break_lambda_toplevel_block.rb'
+ - 'language/fixtures/break_lambda_toplevel_method.rb'
+ - 'language/fixtures/return.rb'
+ - 'language/next_spec.rb'
+ - 'language/return_spec.rb'
+ - 'optional/capi/kernel_spec.rb'
+ - 'shared/kernel/raise.rb'
+
# Offense count: 7
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
@@ -137,13 +204,4 @@ Lint/UselessAccessModifier:
- 'core/module/fixtures/classes.rb'
- 'core/module/module_function_spec.rb'
- 'core/module/private_class_method_spec.rb'
- - 'core/module/private_spec.rb'
- - 'core/module/protected_spec.rb'
- - 'core/module/public_spec.rb'
- 'language/fixtures/send.rb'
-
-# Offense count: 6186
-# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
-# URISchemes: http, https
-Metrics/LineLength:
- Max: 588
diff --git a/spec/ruby/.travis.yml b/spec/ruby/.travis.yml
new file mode 100644
index 0000000000..767d437f67
--- /dev/null
+++ b/spec/ruby/.travis.yml
@@ -0,0 +1,36 @@
+sudo: false
+language: ruby
+install:
+ - git clone https://github.com/ruby/mspec.git ../mspec
+script:
+ - if [ -n "$RUBOCOP" ]; then gem install rubocop -v 0.52.0 && rubocop; fi
+ - ../mspec/bin/mspec $MSPEC_OPTS
+matrix:
+ include:
+ - os: osx
+ osx_image: xcode9
+ rvm: 2.4.2
+ env: CHECK_LEAKS=true
+ - os: linux
+ rvm: 2.4.2
+ env: MSPEC_OPTS="-R2 -ff"
+ - os: linux
+ rvm: 2.2.8
+ - os: linux
+ rvm: 2.3.5
+ - os: linux
+ rvm: 2.4.2
+ env: CHECK_LEAKS=true RUBOCOP=true
+ - os: linux
+ rvm: ruby-head
+ allow_failures:
+ - os: linux
+ rvm: ruby-head
+branches:
+ only:
+ - master
+ - /^try/
+notifications:
+ email:
+ on_success: change
+ on_failure: change
diff --git a/spec/ruby/CHANGES.before-2008-05-10 b/spec/ruby/CHANGES.before-2008-05-10
new file mode 100644
index 0000000000..18778bc146
--- /dev/null
+++ b/spec/ruby/CHANGES.before-2008-05-10
@@ -0,0 +1,17796 @@
+ Changelog
+===========
+
+This file contains the entire revision history of the specs from
+December 2006 onwards, when the spec project got started more or
+less officially by converting the remaining Test::Unit style tests
+in Rubinius to the spec style. The history is not preserved in the
+git repository history itself, so this data is here for reference.
+All the commit hashes are from the Rubinius repository.
+
+It still misses quite a few of the earlier, disparate specs and
+tests because up to that point the organisation was much looser
+and gathering an exhaustive accounting of the entire history of
+TDD/BDD would be time-consuming, particularly with the few full
+directory moves in there and such. All of the data is preserved
+in the Rubinius repository if someone is interested in that bit
+of history.
+
+Be aware that the history contains some Rubinius-specific specs
+by necessity. If you find any commits listed that were _solely_
+for Rubinius, feel free to strip them out.
+
+Thanks to everyone committing up to this point--over 2600 commits
+in just this incomplete version. Keep it up.
+
+
+
+ Revision History
+------------------
+
+
+commit 2b24a1e84c350810817885eeb6532f43c698a95c
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Fri May 9 16:45:07 2008 -0700
+
+ Fixed up pack for base64 and uuencode to be MUCH MUCH cleaner and 2x faster
+
+commit 022bc5dbfafcf1f9fd5e25820104718bd4d45661
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 9 23:51:47 2008 +0200
+
+ Share common specs for BigDecimal's #mult and #*.
+
+commit 414e7eedce9d0cea982e24f1031c407daccc648b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 9 23:19:38 2008 +0200
+
+ New rubyspecs for BigDecimal#mult
+
+ * Verifies that proper signs are calculated when
+ zero is involved.
+
+commit 6883d7d0c67f7be84e7ea1703912452eaecaac6c
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 9 22:54:49 2008 +0200
+
+ New rubyspec for Module#new with block.
+
+commit f8bd3e34014a7351470685676b6b168abd787794
+Author: Phil Hagelberg <technomancy@gmail.com>
+Date: Fri May 9 12:53:00 2008 -0700
+
+ Added specs for OpenSSL::HMAC.hexdigest and .digest
+
+commit 686c28493d42b9c798aa791823395d1000423225
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 9 20:20:13 2008 +0200
+
+ Some more rubyspecs for BigDecimal's #floor and #ceil.
+
+commit aba022a6620ec8d3a09067e9677f0f9c5d8078ee
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 9 17:51:35 2008 +0200
+
+ New rubyspecs for BigDecimal's #floor and #ceil.
+
+commit e4d844ba5851a798b7acb684cf68fdcef353d13c
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu May 8 22:13:58 2008 -0700
+
+ Excluded stdlib specs from default CI run. Added spec/full.mspec.
+
+commit 6a133574617cb435ad1684f208430112ff6839f6
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu May 8 16:19:50 2008 -0700
+
+ String#unpack overhaul. NO extra methods littered through Fixnum/Integer/String. NO procs. More readable, but still messy.
+
+commit 11dd3ae2c4e0dd81304e85ba662db41196f1ce4c
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed May 7 23:59:31 2008 -0700
+
+ Fixed constant type clash for ModuleSpecs modules.
+
+commit 4e702d10b32fdba62cdeae476b8217019839c3b0
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed May 7 21:42:11 2008 -0700
+
+ Some specs for Kernel#__add_method__ and Module.__add_method__.
+
+commit 819649f24f59819be185b0562b94f9089f8c000c
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed May 7 14:48:01 2008 -0700
+
+ Added spec for Kernel#eval with binding from method defined by #eval.
+
+commit d73b17b88b6084fdf7cab764b0fbdd3b3882dd81
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed May 7 10:06:26 2008 -0700
+
+ Use literals in Bignum#to_f specs (alternate fix for #535).
+
+commit ee211770eb8792b3f58f78ff60eec6d5289caa20
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Wed May 7 02:38:00 2008 -0700
+
+ Added specs for big uncovered areas, still not 100%
+
+commit 7ce9bc2d7edc64f6886c3d34836bc0394414ed66
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue May 6 03:56:19 2008 -0700
+
+ Fixed typo
+
+commit af3407251ee0f287ec80232c354153af169636e4
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue May 6 22:01:23 2008 +1000
+
+ Fix bug in Debugger::Output.wrap
+
+commit d9322306ea70f2b847b0f806bdb13ea02f2d6b4d
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon May 5 13:09:32 2008 -0400
+
+ Fix some bugs in BigDecimal#/. More may yet lurk.
+
+commit 2f3a4cc14433858b13caa932c8a50c31e024c7e8
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Mon May 5 12:04:26 2008 -0500
+
+ Adding more specs for REXML::Element
+
+ * Covers REXML::Element#{add_attribute, add_attributes, add_namespace, add_text, clone, comments}
+
+commit 7db8c2b563ea474cf2db5fa14bb2a6345c8c469f
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Mon May 5 10:54:00 2008 -0500
+
+ One more case for YAML.load specs
+
+commit 098decdf510b05f82ff9a6cc6769cf478a3236ab
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sun May 4 22:29:35 2008 -0400
+
+ Define BigDecimal#ver.
+
+commit f6f1fe6a667570e4c1521649b964dca1352d1c32
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sun May 4 22:12:08 2008 -0400
+
+ BigDecimal#new: Make space between '-' and 'Infinity' unparsable, as per spec.
+
+commit 503aae7cdbb208da8f25080762e17f0866845c4d
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon May 5 06:19:40 2008 -0400
+
+ Method call parsing spec from Jim Kingdon with minor addition.
+
+ * Moved the SyntaxError producing code into an #eval because the file
+ cannot be compiled to run otherwise.
+
+commit 398d5de0a0ffaf746e39e5f6a6ded02483fd1842
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon May 5 02:26:39 2008 -0400
+
+ Spec for :match node, implicit Regexp matches against $_.
+
+ * Compiler and Language specs.
+
+commit 206cea31c6a93fe434948dcb79321e2c119edf21
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat May 3 11:40:17 2008 -0400
+
+ Implement BigDecimal#power and #**, fix some bugs in #mult.
+
+commit a197099d9be6e48ad32480ae323302c83146147b
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat May 3 02:18:35 2008 -0400
+
+ Fixed a logic and syntax error in BigDecimal#mult specs.
+
+ * Removed some parentheses too.
+
+commit 081afd58a29ccd5025b806f53e9d7679b9296a7f
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat May 3 02:25:45 2008 -0400
+
+ Make sure subclasses that implement their own Hash#default work (Merb)
+
+commit 203ca288175416fadb110b2aa9cdf8cfbf13215d
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat May 3 01:49:35 2008 -0400
+
+ Specs and implementation for module include order (fixes abstract.rb)
+
+commit c788a9f2d9c4561a2837bbf78f68a6885d626917
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 18:14:32 2008 -0400
+
+ Implement BigDecimal#*, as well as #mult without precision support.
+
+commit 57d78528ff4cf249d906785ffbfdde1fda4aa3cc
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 17:36:15 2008 -0400
+
+ Implement BigDecimal#/ and #quo. Not perfect; still relies on #/.
+
+commit c42cc2cacc347d8284650c7046d4dadf94d7d4a5
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 16:13:07 2008 -0400
+
+ Fix a typo in specs.
+
+commit ae179b410665da18628f249e6796f1e07ab83763
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 16:10:43 2008 -0400
+
+ Get BigDecimal#floor basically working.
+ * The failing specs depend on #/, which isn't implemented yet.
+
+commit f8221117d174b91affe406c8089ed25e887232b3
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 16:06:32 2008 -0400
+
+ Fix bugs in BigDecimal#add and #+. This also affects #sub, #-, and #ceil.
+
+commit cdd196daf7643e846b7f3582b1e441b883e02aba
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 15:41:29 2008 -0400
+
+ More specs to fix bugs in BigDecimal#add and #+.
+
+commit c1c52a2a531b570fa1025d99e464d93c570cf59e
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 15:22:33 2008 -0400
+
+ Write another spec for BigDecimal#ceil.
+
+commit 71b65cdbfa5aae461fc52c997df9fca3bee9c8d5
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri May 2 14:47:34 2008 -0400
+
+ Write tests for a bug in BigDecimal#add and #+ where 0 + 1 = 0.1.
+
+commit 55988ef53879c1c489c570b3f37717365c7f8e2b
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat May 3 01:04:11 2008 -0400
+
+ Fix use of alias keyword inside instance_eval
+
+commit d4011595a0077e91665f85410d458c57367cf50b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 2 20:38:15 2008 +0200
+
+ Added news specs for BigDecimal#mult.
+
+commit b6771644d35b6b8f3c87f7f4461bcaba99cd976f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 2 19:41:09 2008 +0200
+
+ More BigDecimal#divmod rubyspecs.
+
+ MRI-specific bug is hidden behind ruby-bug guard.
+
+commit 854a011324ce717cfd47ddec6389a9e9abb0db18
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 2 18:45:29 2008 +0200
+
+ New BigDecimal#divmod specs.
+
+commit b9806e0efb2a8e51d70f6d51733df7bed88152d9
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 2 16:45:10 2008 +0200
+
+ A couple of test cases for BigDecimal's #quo, #div, #/.
+
+commit 3cf6c1e03001ba1dda966e3392b665f5b08a1b9d
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri May 2 15:03:37 2008 +0200
+
+ More tests for BigDecimal#floor.
+
+commit b70023978562af89cf4349e14e9443adb37ecbbe
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu May 1 21:15:29 2008 -0400
+
+ Improved a spec description for String#index.
+
+ * The description looks exactly like we had the wrong implementation
+ relying on % 256 and someone wrote a spec to make sure that did not
+ happen. However, the description was more or less meaningless to
+ what was actually being specced.
+
+commit 6e6aa411ff4c7a837d5d4adb9ab893719cf9e122
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu May 1 10:48:20 2008 -0700
+
+ Fix a number of things to pass all def specs
+
+ This is the result of ping-pong between Evan and Wilson. It refactors
+ out enclosing_class from being used, and instead information is always
+ pulled directly from the StaticScope object. This lets us inject proper
+ scoping changes in ruby.
+
+commit 2db27aef88e2ca7752beba846d172ede276275e0
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu May 1 19:03:50 2008 +0200
+
+ Implemented Socket.unpack_sockaddr_un
+
+commit d515221698e02b52ed4661113d659744fbfae36f
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu May 1 18:18:32 2008 +0200
+
+ Forgot to update spec tags for TCPSocket.gethostbyname
+
+commit bf839a99c3a5b773b6b96c6d5a1fcc5056511e7a
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu May 1 14:03:30 2008 +0200
+
+ Implement File#mtime specs
+
+commit b8c713e6b972b464788c740b4283a5b4226c123c
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu May 1 13:55:36 2008 +0200
+
+ Implemented File.lchmod and initial specs
+
+commit 059c926d7280c2e7c9f8bf710c5aef70cde3e777
+Author: Adam Wiggins <adam@heroku.com>
+Date: Sun Apr 27 15:03:31 2008 -0700
+
+ IO.popen read/write pipes
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit d9a050aa45efd00a40395b7ac7ac069f4be1fd1c
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu May 1 16:25:18 2008 +1000
+
+ Spec fixes for Tuple#to_a
+
+commit 0b610359fbfe8137fdba95d90b659238168d6788
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Wed Apr 30 17:45:51 2008 -0400
+
+ Update spectags.
+
+commit 024ebfdf3fa9c54b8a81134edb52fe10b09e4b91
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 30 22:56:44 2008 +0200
+
+ Added BigDecimal#divmod excludes.
+
+commit e12d21a90760df723c0f48265cb49a9c4463db7c
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 30 20:51:06 2008 +0200
+
+ More tests for BigDecimal#divmod.
+
+commit 68cfef604f9b5411ca9e0349883bac4f59541f0d
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Wed Apr 30 16:47:31 2008 -0400
+
+ Make BigDecimal#finite? handle NaN correctly, and refactor accordingly.
+
+commit 5066bcb8881241caf6d13be625b32633bda6567e
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Wed Apr 30 15:01:12 2008 -0400
+
+ Make BigDecimal#<= and #>= pass Vladimir's new specs.
+
+commit 49601aff01c394fe2168f5f221a987be63a9ebc7
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 30 20:20:18 2008 +0200
+
+ Various improvements to BigDecimal rubyspecs.
+
+ * Corrected comparison specs (properly add arrays there)
+ * New reminder specs
+ * New modulo and % specs
+ * Tagged rbx failures
+
+commit dd1700b747ba26b27eff0b249623aca559db06e1
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 30 17:48:20 2008 +0200
+
+ More test cases for BigDecimal#modulo and #%.
+
+commit 8eb9dc1b0aee3587f4da8b9cbe306fd431159d79
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 30 16:57:16 2008 +0200
+
+ New specs for BigDecimal#modulo and #%.
+
+commit 4a846f807fe2c4c12d8719bc5c9ccb4ab696aff9
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Tue Apr 29 15:29:34 2008 -0500
+
+ Fixes REXML::Element#namespaces specs
+
+ * Use sort on the arrays to make sure the specs pass on JRuby too.
+
+commit 823683a864072ef6a81e808dbf792dee45d29c52
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Tue Apr 29 14:54:08 2008 -0500
+
+ Adds more specs for REXML.
+
+ * Specs for REXML#{inspect, namespace, namespaces, prefixes, text and text=}.
+
+commit a11a10760ce92ee373e04a5445234521a27874cc
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 28 17:55:55 2008 -0400
+
+ Committing so we can bisect.
+
+commit df94214b1d132b02e3dd5b166d1c7c5cd5d50a21
+Author: Drew Olson <olsonas@gmail.com>
+Date: Mon Apr 28 19:21:07 2008 -0700
+
+ Added spec for Array#remove_outer_arrays
+
+commit ec4ece9c06b42c257b4ffce2cf319f0ad23f65e8
+Author: Drew Olson <olsonas@gmail.com>
+Date: Sun Apr 27 20:15:47 2008 -0500
+
+ Added more edge cases for recursive arrays to spec for File#join
+ * an empty array containing an empty array which contains a recursive array should return
+ '[...]' when File#join is called on it.
+
+commit 698a5d291cf63e56e9a3508a8850c77fa2c23430
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 28 16:17:05 2008 -0400
+
+ Implement BigDecimal#=== as alias of #eql?.
+
+commit 18f515e735eecc519be55a6e3253db7135a137ad
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 28 16:09:43 2008 -0400
+
+ Implement BigDecimal#sub.
+
+commit b331faa567dc1d98163c6447897221877cf756eb
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 28 16:04:06 2008 -0400
+
+ Implement BigDecimal#add.
+
+commit f3f94c9b53045ddde335981897e2f6087dab7ef2
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Apr 28 12:01:41 2008 -0500
+
+ hack to fix DRb.start_service spec to at least test start_service
+
+commit 4c8d6d90c69615386e26c71633e242f4e1f19342
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Apr 28 11:56:47 2008 -0500
+
+ spec for DRb.stop_service to see if it clears the socket correctly
+
+commit 03cb539f42f0b558fa29911c1dfc71ec5f2b183f
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Apr 28 11:20:17 2008 -0500
+
+ Revert "Revert "Made DRb spec depend partially on PID so multiple runs don't clash.""
+
+ Apparently this is a supposed fix for concurrent spec runs, not for the spec failure
+
+ This reverts commit 08695d9a6940ab74f6eb8965e449a417002a42a6.
+
+commit 2172e2ac20b69a97c2ad66551b3620a43bfda700
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 28 02:14:18 2008 -0400
+
+ Make BigDecimal#exponent return Bignums as necessary, not just Fixnums.
+
+commit dc93d06163e80cdf89a67532654a850828119287
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 28 01:23:19 2008 -0400
+
+ Correct implementation of BigDecimal#+ and #-. There's still a lot of repetition to be factored out, but this algorithm is more correct than the last try.
+
+commit 1da58bb7f0afbba4f8412e06983304dc7d887ac9
+Author: Luis Lavena <luislavena@gmail.com>
+Date: Thu Apr 24 16:37:59 2008 -0300
+
+ Corrected small typo on File#join specs under Windows.
+
+commit b287619579ad11535722a2374b6f849d88fe9931
+Author: Drew Olson <olsonas@gmail.com>
+Date: Thu Apr 24 14:24:10 2008 -0700
+
+ Spec for File#join now describes correct behavior for arrays with recursive sub-arrays.
+
+commit 5830380895c0bec16c6af39d0f29d8d70268028d
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Sun Apr 27 14:53:47 2008 -0500
+
+ DRb.start_service spec fails because of a timing bug in DRb
+
+ See http://jira.codehaus.org/browse/JRUBY-2347
+
+commit 08695d9a6940ab74f6eb8965e449a417002a42a6
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Sun Apr 27 14:51:16 2008 -0500
+
+ Revert "Made DRb spec depend partially on PID so multiple runs don't clash."
+
+ The spec is designed for sane behavior, if Rubinius or the
+ implementation of DRb is causing problems then they should be
+ fixed, not the spec in this case. Fixing the spec will only
+ hide the bug.
+
+ See http://jira.codehaus.org/browse/JRUBY-2347 for more commentary on the problem.
+
+ This reverts commit f89bd8c6c425c9d9bcc3e589b8d3b05ce3ccbced.
+
+commit 94ba0884c8e7f398b6fe8d6736834f62f6a49815
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Apr 27 21:23:47 2008 +0200
+
+ More checks for BigDecimal#abs specs.
+
+commit 80932d25ca95e2e8c803d244a7636e3004525ade
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Apr 27 21:10:26 2008 +0200
+
+ More test cases for BigDecimal#finite? specs.
+
+commit 4b541ed23ccac65f6f4b2ef8aad56e9aa7a69e12
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Apr 27 21:04:08 2008 +0200
+
+ Added testcase for BigDecimal#infinite? for NaN.
+
+commit 4a1f39426fc60ae7c2ed0470259fa0752a46d030
+Author: Adam Wiggins <adam@heroku.com>
+Date: Sat Apr 26 22:57:09 2008 -0700
+
+ IO#write returns 0 when writing a blank string, to match behavior of MRI
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 56c0088f9b075769933c8c87e3c2d256cff3a3e8
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sun Apr 27 00:28:47 2008 -0400
+
+ Typo.
+
+commit c11410654b9046cdb58dba1d116f58ce74f4c263
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sun Apr 27 00:24:32 2008 -0400
+
+ Finish implementing #@- and #infinite?. Update spectags, of course
+
+commit dc9f427ecb9d55559d800af70f9c1a3f2f2123b5
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sun Apr 27 00:07:31 2008 -0400
+
+ Amplify a comment.
+
+commit b9776b953ae67f2088e44b640145af464a1cf942
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sun Apr 27 00:02:48 2008 -0400
+
+ Get BigDecimal#+ working. I hate this algorithm, but it works without running out of memory.
+ * Update spec tags.
+
+commit b87ff5c22891f19ad0b956e7e02cc3a3d1adcc93
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 14:27:00 2008 -0400
+
+ Implement BigDecimal#coerce.
+ * Update spectags.
+ * Rewrite one spec so it doesn't depend on BigDecimal#-, which is not yet implemented.
+
+commit f89bd8c6c425c9d9bcc3e589b8d3b05ce3ccbced
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Apr 26 15:52:49 2008 -0700
+
+ Made DRb spec depend partially on PID so multiple runs don't clash.
+
+commit 3c49a1d16f20726c4ee2d7eb5f5c671537aa59d5
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Apr 26 15:13:47 2008 -0700
+
+ Added wordsize guard for BigDecimal#exponent spec.
+
+commit 3aac5f6d64f4cbbca70ecf01b7ed9be596fa5b76
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Apr 26 15:09:40 2008 -0700
+
+ Updated spec_helper and renamed CaptureOutput to IOStub.
+
+commit 94322a6a95770a030d28925cc7213a38c5687ea1
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Apr 26 23:16:59 2008 +0200
+
+ A bit more test cases for BigDecimal#-@.
+
+commit 9919c5e3be59562532c967b479c959cf6270046e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Apr 26 21:01:44 2008 +0200
+
+ New specs for BigDecimal#uminus.
+
+commit c3e74531f1ca1e70671f529671c0fa474968dc87
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Sat Apr 26 13:08:04 2008 +0200
+
+ FreeBSD seems to work like the rest, not darwin
+
+ Tested on FreeBSD/i386 7-STABLE
+
+commit c06a091b285f388f09b11037975921662759eea2
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 12:14:33 2008 -0400
+
+ Implement BigDecimal#exponent, update spectags. Looks like parts of #** have accidentally stopped failing too. :)
+
+commit e5b753b7e659b29f5ed4aa57018f922111b238f5
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 11:53:55 2008 -0400
+
+ Specify return type of BigDecimal#ceil as BigDecimal, as per library documentation.
+
+commit 0ca3b9ceb6ef5ca1898250b89f75c0194b5da481
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 11:50:24 2008 -0400
+
+ Fix BigDecimal#inspect output, update spectags.
+
+commit ca99aa062afe9106ec614e2d8969d3491803c9a2
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 11:48:00 2008 -0400
+
+ Specify return type of BigDecimal#ceil as BigDecimal, as per library documentation.
+
+commit 587a5cdbbfa4cccdbfe98339ca999f1d63bd66cf
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Apr 26 15:02:33 2008 +0200
+
+ Corrected one Array#hash test case.
+
+ Now Array#hash pass MRI 1.8.6, 1.8.7, 1.9 and JRuby.
+
+commit f86bdb98b8b9f5ea878c5d142f3a694e5278db77
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Apr 26 14:19:14 2008 +0200
+
+ Quarantined couple of specs that fail on *ALL* implmenetations.
+
+ Probably, we need a better way to do that, but quarantine
+ is a quick and simple way, easily detectable later on.
+
+commit 7ca928211180c66b9879afbc382c376a7649e1b0
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 00:51:39 2008 -0400
+
+ Implement BigDecimal#to_f, update tags. Will this need more work?
+
+commit 69dec41f6b5b532c5de7f46e97f97c9e102305c7
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 00:44:40 2008 -0400
+
+ Implement BigDecimal#truncate.
+ * Update spec tags.
+ * Reorganize variables slightly to remove duplication.
+
+commit c823e62c3a6776b62f65c34b16bdca5748d1add9
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 00:36:43 2008 -0400
+
+ Implement BigDecimal#truncate.
+ * Update spec tags.
+ * Reorganize variables slightly to remove duplication.
+
+commit 3f4e5dc78de5bf3e81ae1ce7a0d14852a32aeade
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Sat Apr 26 00:16:38 2008 -0400
+
+ Rewrite spec description to bring it in line with what the spec actually does. :)
+
+commit 15d87e8a983d08d99fc3ec6bfbb7f36ed0cd4c4e
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 25 18:09:33 2008 -0400
+
+ Implement BigDecimal#to_i, update spec tags.
+
+commit 59873b144ea836e2f9bbef7d5186a1287155e76a
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Apr 25 20:46:17 2008 -0400
+
+ Specs for autoload path normalization
+
+commit 71fe2d45d147fe2c41937ae5ef6dbb8814f491c4
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Apr 25 17:05:17 2008 -0400
+
+ Use a separate class in Singleton 'new' specs to avoid contamination
+
+commit 2dc8f9eb9c6db014bd6cc132d987fdb4612816f8
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Apr 25 16:45:28 2008 -0400
+
+ Handle more nightmare Autoload edge cases by hooking into Kernel#require
+
+commit 5c1a375a15adbe20a9bf3d1b95e1f2d30feaa90e
+Author: Michael Fellinger <m.fellinger@gmail.com>
+Date: Sat Apr 26 04:26:52 2008 +0900
+
+ Spec for Module#autoload when the load path has already been required
+
+ Signed-off-by: Wilson Bilkovich <wilson@supremetyrant.com>
+
+commit ee47a0cc0da787599479fc8dd085b7481b591176
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Fri Apr 25 15:41:19 2008 -0500
+
+ Enabled another $_ spec and added a proc dispatch scoping test to $~ and $_
+
+commit eabc4609758dc99727c77493c58f187782ea957f
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Fri Apr 25 15:32:03 2008 -0500
+
+ Added some basic specs for $_: implicit assign, explicit assign, scoping
+
+commit 61194dec429a9f288791156639f058e45a4e72e9
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Fri Apr 25 14:49:53 2008 -0500
+
+ Add some specs for $~ scoping and assignment.
+
+commit 4c5cec4f6e10864c68b140e71cc2559e7a7d636b
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 24 18:28:08 2008 -0700
+
+ Added incomplete tags for CSV spec stubs.
+
+commit 6e231caef62e678413e86317881aaab200d0802e
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 24 18:15:06 2008 -0700
+
+ Reprocessed library CSV specs with new mkspec.
+
+commit 4cdc61a76cce73b52f05f53f820838cc7e3c2823
+Author: Michael Fellinger <m.fellinger@gmail.com>
+Date: Fri Apr 25 08:46:32 2008 +0900
+
+ Updating specs for the module #included calling #extend issue.
+
+ Signed-off-by: Brian Ford <bford@engineyard.com>
+
+commit 40e775bf036aa59e69268708f8c78b8a56e0f9ce
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 24 17:10:55 2008 -0700
+
+ Moved #bignum_value helper to MSpec.
+
+commit 9b52edbb14ff2fc18faa429daf4ceaff5b87db11
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Thu Apr 24 14:37:53 2008 -0400
+
+ Implement BigDecimal#fix, make #frac trap for a few common cases without running out of memory for big numbers.
+
+ * Update spec tags.
+
+commit 6a604c0a9863073cfd7540ff755e7ca035a7dff5
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Thu Apr 24 19:32:14 2008 +0200
+
+ Don't run Process.setpriority spec on FreeBSD
+
+commit 0ab639af500d947c5b5feb1d8f00f5fbc97a0edc
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 13:37:23 2008 +0200
+
+ Adjusted IO specs to supply blocks for each-like methods.
+
+ See [ruby-core:16557] for more details.
+
+commit a7b603a9ce6bfb570785e803bdb89ae36bb6253d
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 13:14:40 2008 +0200
+
+ Fixed IO, Process, Regexp specs ('should' was missing).
+
+commit 26de6c05c050d0dbcb073c407abda47f964bfd29
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 12:50:46 2008 +0200
+
+ Fixed File specs ('should' is misspelled)
+
+commit 99a2b23d8fb42cb377cb3fb9ab2569c555aec8bf
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 12:47:57 2008 +0200
+
+ Fixed Array specs ('should' was missing).
+
+commit 67b301a03fd6f7f0fa38ce106ab05825f2cbb15c
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 12:43:39 2008 +0200
+
+ Fixed specs ('should' was missing), some new test cases for BigDecimal.
+
+commit aecbea57de7ee1b50bd4b06871dd08e762a6ccb8
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 12:35:54 2008 +0200
+
+ More test cases for BigDecimal#nan?
+
+commit 7aaf8fa137b8961ca122eb92e7447936ad7a44cc
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 12:26:20 2008 +0200
+
+ More test cases for BigDecimal#zero?
+
+commit 58ecee694f191aa05e7867544cf8d63129558447
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 12:19:11 2008 +0200
+
+ A bit more test cases for BigDecimas#-.
+
+commit e946dd03d590e29a1d344e7579d5ff047df4a76b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 24 12:17:16 2008 +0200
+
+ New and updated specs for BigDecimal#-.
+
+commit 01d82db424b4e447b98e5f2eb3e162b991dece8a
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 24 01:25:20 2008 -0700
+
+ Tag for new private setter method spec.
+
+commit c0ee2e133a4e5fc179b96329ffd3934dd9263c2b
+Merge: 374ab81... e9826b9...
+Author: Tony Arcieri <tony@medioh.com>
+Date: Thu Apr 24 02:19:00 2008 -0600
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 374ab81e2c01ea5ac48cda2004ae92a989d7f3d7
+Author: Tony Arcieri <tony@medioh.com>
+Date: Thu Apr 24 02:18:26 2008 -0600
+
+ Specs for calling a private setter method on self
+
+ * Not presently working under rbx, works under MRI
+ * I don't entirely know the process for this, but this is expected to break
+
+commit 39505393f330b5f622788f1d98ea8ff3781499c7
+Author: Luis Lavena <luislavena@gmail.com>
+Date: Thu Apr 24 04:04:32 2008 -0300
+
+ Fixes Dir fixtures and specs for Windows.
+
+ Usage of special characters *, ?, | and : is not allowed under Windows
+ * and ? represent wildcards, | is pipe tunelling and : is drive letter
+ separator.
+
+ Files or Directories cannot contain slashes (\/), wildcards, double-
+ quotes, pipe tunelling or stream redirectors (<>).
+
+commit 2ecc076e488ed1a519fc5b6876c68a3d91d55c87
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Apr 23 22:55:44 2008 -0700
+
+ Update tags for newly passing File.join specs.
+
+commit ff3756e179920b84d5a55fc7bbc2688706df044f
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Apr 24 01:09:17 2008 -0400
+
+ Add specs for nested method definitions and other complex scenarios
+
+commit 24785f7c28cde09ce0400e5d80f832ae11cddefa
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Apr 23 20:56:55 2008 -0400
+
+ Spec for using ||= to initialize a class variable
+
+commit 98b0c44057cb827107cae0f0174b5e81ac2064fd
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Apr 23 19:49:21 2008 -0400
+
+ Rewrite descriptions of language/def specs
+
+commit 598c287cc36179644a1bbf2a303a56fc85bb1b12
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Apr 23 12:39:04 2008 -0700
+
+ Replaced use of :mswin with :windows in platform_is[_not] guards.
+
+commit 01fe417f27ad43495327a522ece2f02769064df7
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 23 21:30:34 2008 +0200
+
+ Added excludes for BigDecimal#div specs.
+
+commit 46f022d49c394b027491295e7fd5cb305af33404
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 23 21:27:42 2008 +0200
+
+ More specs for BigDecimal#div
+
+commit 72433091c6a845c5f550b27111748e29fb5eac09
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Apr 23 10:56:57 2008 -0700
+
+ Added #tmp helper to MSpec for returning a temp file name.
+
+commit f4e975e5255fb36bb8e9be7d310850135ce3515f
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Wed Apr 23 10:54:42 2008 -0400
+
+ Implement BigDecimal#frac, update spec tags.
+
+commit b60deba2368a1212d6acd3e49481ba9495de7f2f
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Wed Apr 23 10:49:39 2008 -0400
+
+ Correct a spec error.
+
+commit e19cf9401c029f90e117b1c17083c928b0d1c9ca
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Wed Apr 23 10:24:50 2008 -0400
+
+ Implement BigDecimal#-@, update spec tags.
+
+commit c3fc05389c75aca3150038814b324266501fdb8f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 23 16:12:24 2008 +0200
+
+ A bit more test cases for BigDecimal#sqrt.
+
+commit b2a220f86887bfe6030a34bc8cd1b748c88cc2b8
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Wed Apr 23 01:43:16 2008 -0400
+
+ Get BigDecimal#to_s working according to spec.
+
+ * Implement #to_s.
+ * Update spec tags.
+
+commit 82638601be12e410413047779f01840d6d0db3d8
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Apr 23 09:56:48 2008 +1000
+
+ Refactor Debugger to remove dependencies on Debugger::Interface
+
+ Also:
+ - Add List#inspect to show number of items in list
+ - Fix decode output to show original instructions in place of
+ yield_debugger
+ - Improve regex used to match method names to handle more
+ operators
+
+commit 41c64f2825d347fbe2ef9edc33dd8f1e84773251
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Apr 22 18:12:06 2008 -0400
+
+ Spec and implementation for NilClass#dup
+
+commit d3e313ed38a847e29225ba814a956d0929ea6460
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Apr 22 22:03:47 2008 +0200
+
+ New and updated specs for Bigdecimal's #abs and #sqrt.
+
+commit 2013e106181879b886f2e1cb78e81f52cd284666
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Apr 22 15:52:10 2008 -0400
+
+ Re-implement Module#autoload and autoload?. Now passing all autoload specs.
+
+commit 9156271e2b12138e2b2b712a76f0110f20a757b7
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Apr 22 15:34:43 2008 -0400
+
+ Add (failing) spec for toplevel autoloaded constant access
+
+commit 8eb5451f88a37dc247e42913c1d72d072a9b02ef
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Apr 22 19:06:00 2008 +0200
+
+ One more test case, for BigDecimal#sqrt with nil.
+
+commit e7894fb78cf92b53e9bdc6dcf023d8dd2d66b2ed
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Apr 22 18:52:24 2008 +0200
+
+ More detailed specs for BigDecimal#sqrt and fixes for old ones.
+
+commit 527a4b663c487cd9222ee2e6917e330ff9a130a1
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Apr 22 12:38:53 2008 -0400
+
+ Rename ambiguously-worded autoload spec
+
+commit 3e6f16c41569dbba291bc3cececf137fc8952ee2
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Tue Apr 22 12:31:17 2008 -0400
+
+ Change to a significand-and-exponent implementation.
+
+ * Update spec tags.
+
+commit f1b2bf51042ca563ca74a9cf83db0e46a1bfabce
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Tue Apr 22 09:54:53 2008 -0400
+
+ Fix BigDecimal#zero, update spec tags. Also make #precs deal correctly with lowercase exponents.
+
+commit d0171de114e777f07a3e62972663475dd7747b05
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Tue Apr 22 09:24:06 2008 -0400
+
+ Implement BigDecimal#precs.
+
+ * Get #precs working. This will be less tortured once I implement a significand-and-exponent format.
+ * Update spec tags.
+
+commit e1fc7c6dc4c02c1763947c34d05f894661a84525
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Tue Apr 22 01:30:10 2008 -0400
+
+ Continue implementing bits of #inspect and updating spec tags.
+
+commit e4371f120c9c5c3c88a26d5f24f0d3ab888c954f
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Tue Apr 22 01:24:14 2008 -0400
+
+ Implement BigDecimal#==/eql? and the beginnings of #inspect.
+
+ * Find a way of implementing the equality test that satisfies the specs.
+ * Don't be so baroque in parsing strings in constructor.
+ * Update spec tags.
+ * Fix regression in abs_spec.
+ * Start implementing #inspect. Not really ready for prime time yet.
+
+commit 0494c1c35582381345194c76f7384eb9044797fc
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Tue Apr 22 00:41:03 2008 -0400
+
+ Start implementing BigDecimal#sign and #zero?.
+
+ * Clean up specs for #sign.
+ * Write some initial code to get these working. Not all there yet.
+
+commit 3c071b5f921898d87437803a500535b639d465ef
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 21 23:43:10 2008 -0400
+
+ Get BigDecimal#abs working.
+
+ * Implement the function.
+ * Improve the spec.
+
+commit 054582f3b89d757f033cd5f09cbf90fa08ad81d6
+Author: MenTaLguY <mental@rydia.net>
+Date: Mon Apr 21 22:32:42 2008 -0400
+
+ fix linked actors spec (sort of)
+
+commit d7a7d0c4d0d83d7e69216c96a249c4091fe75323
+Author: MenTaLguY <mental@rydia.net>
+Date: Mon Apr 21 22:28:29 2008 -0400
+
+ fix up registration spec
+
+commit 645784c3d39f776f583874e7c9244ff3de64cfe7
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 21 19:56:51 2008 -0400
+
+ Update tags on failing specs.
+
+commit 960faf5382d90db376ff14bb836463f1860a4b62
+Merge: 2e2150f... 046ba62...
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 21 18:46:45 2008 -0400
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 046ba622836321f487f241c145a3bdf0968f0a67
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Apr 21 18:44:50 2008 -0400
+
+ Specs for failing Module#autoload case (replicates a scenario from Merb)
+
+commit 18a2a26fa511d4943a724e27ce09e5855a257e90
+Merge: 1f5f4b5... 991c6e6...
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Mon Apr 21 14:15:07 2008 -0400
+
+ Merge branch 'master' of git://git.rubini.us/code
+
+ Conflicts:
+
+ lib/bigdecimal.rb
+ spec/ruby/1.8/library/matrix/diagonal_spec.rb
+ spec/ruby/1.8/library/matrix/element_reference_spec.rb
+ spec/ruby/1.8/library/matrix/shared/identity.rb
+ spec/ruby/1.8/library/matrix/shared/transpose.rb
+
+commit edd397c82a924e406eabbcd7e84243d94f8e8067
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Sun Apr 20 18:11:23 2008 -0500
+
+ Adds MinGW to the IO#popen spec guard
+
+commit 10df9f89189637b2c5a54b01a88eca6c9fbb4601
+Author: Adam Wiggins <adam@heroku.com>
+Date: Sun Apr 20 14:53:41 2008 -0700
+
+ IO.popen specs for reading and writing to pipes
+
+commit 3f70eceb3b9415a14f602c5b96121a459dca1e67
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Apr 19 22:32:28 2008 -0700
+
+ Fix silly typo in Numeric#quo specs.
+
+commit 6101a4992ddc15c0140f4d7702cf88d2d3a2ac53
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Apr 19 22:23:14 2008 -0700
+
+ Guard affected specs with conflicts_with :Rational.
+
+commit 354445f4d20ec66f207d65d1ccceb681bba7fff0
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Sat Apr 19 14:23:14 2008 -0500
+
+ Clarifying some of the Matrix specs
+
+ * Fixes two errors introduced by 28700c5cf7
+
+commit 2f5ca541fc08f0c033bc6541c72962228ea607de
+Author: Eero Saynatkari <projects@kittensoft.org>
+Date: Sat Apr 19 15:07:49 2008 -0400
+
+ Compiler specs' TestGenerator relies on broken #=== semantics, comply.
+
+commit 37cc9d4d6eb3442814ecc51845f025f464da64f7
+Author: Eero Saynatkari <projects@kittensoft.org>
+Date: Sat Apr 19 15:05:30 2008 -0400
+
+ Specs for default #=== and its relationship with #== and #equal?
+
+ * Rubinius deviates to not check object id directly.
+
+commit 28700c5cf7630be59877122e6470c42622b7365a
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Sat Apr 19 13:53:33 2008 -0500
+
+ Additional specs for Matrix
+
+ * Some of the constructors in Matrix keep referencing the original arguments after creation, these specs cover those cases.
+
+commit 12b0bc93e5a6b328ad0968c03c47af71f671aae2
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Sat Apr 19 13:06:04 2008 -0500
+
+ Replace object_id for equal? in Matrix specs
+
+commit ae377f0e56b8f31356935b3ac0800f561b2d1b2c
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Apr 19 14:49:34 2008 +0200
+
+ Fix File::Stat#uid specs
+
+commit 2e01a86a3977fe87f4f0734e50598b41f66f29d7
+Author: MenTaLguY <mental@rydia.net>
+Date: Sat Apr 19 03:24:32 2008 -0400
+
+ Gutted and reworked Actor, following Erlang more closely.
+
+commit de40303e17e2de1e7980564b43ee162c5080afa6
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Sat Apr 19 01:05:43 2008 -0500
+
+ Fixes Matrix#clone specs for MRI
+
+ * Makes sure the values (not the references) of the original rows are copied.
+
+commit 2b3a44158ae93ab5883da22e5f36df92485f3ad4
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Fri Apr 18 22:47:15 2008 -0500
+
+ Fixes a few things inside the Matrix specs.
+
+ * Removes some of the "needs to be reviewed for completeness" messages.
+ * Changes some of the descriptions
+
+commit 3be265a93a75b6a0267b1770f8cad671c4244671
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:26:29 2008 -0400
+
+ Matrix.unit, one more alias for .identity.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit 57aa8ba9a1dbdf62e9cf644bbde4603b841ffc76
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:25:55 2008 -0400
+
+ Name spec correctly.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit 3390dc4c6725d996eeb0c2e4ec73949bc0be2290
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:23:54 2008 -0400
+
+ Specs for Matrix.scalar and .identity/I.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit 958ca1faa1dc60ce591b4b2f768f22ac7f6cb56f
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:22:09 2008 -0400
+
+ Move the "needs to be reviewed" indicator to the right place.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit bf3eab630654eaaca9256850d258343e3024989e
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:03:45 2008 -0400
+
+ Use size functions instead of constants.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit 3981c931e7f4fde730d51614d40e44b9209347f9
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 11:58:22 2008 -0400
+
+ Specs for Matrix#clone and #transpose (alias #t).
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit 72e1ea8900a638c796de9e715c5dffcf4ac90546
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:27:06 2008 -0400
+
+ Basic specs for Matrix.zero.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit f5d294ad941c477060e9b5d2329790db7e1e5700
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:20:27 2008 -0400
+
+ Move before block to a clearer place.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit b6bc5b224ade56ab96f3585b6b1c25e6dd5e1ad5
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:19:27 2008 -0400
+
+ Write specs for Matrix.diagonal.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit b4d056baa33a2181ab64c065ad1eb4adebcfaddf
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:11:11 2008 -0400
+
+ Some initial specs for Matrix#[] and Matrix.[].
+
+ These are in the same file because of coding conventions, but they probably should not be since .[] is a constructor and has very little in common conceptually with #[], which is a subscript operator.
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit 5476d836577c0fbdbda097762862cf153ffb5e07
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Apr 18 18:35:34 2008 -0700
+
+ Some method profiles of data provided by John Lam.
+
+ Run these as follows:
+
+ bin/mspec -w rails.yaml spec/ruby
+
+ We'll be adding our own trace script, but for now, these
+ are snapshots of methods used by Rails loading a simple
+ "hello world" controller. The rails.yaml file is core
+ methods. The core.yaml file is generated by NameMap from
+ mspec/bin/name_map.rb.
+
+commit 24c71675cc63c86832ef8bc55d2f0167dff53073
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 17:24:08 2008 -0400
+
+ First stab at BigDecimal.
+
+ * A skeleton of a somewhat naïve implementation of BigDecimal.
+ * Updated spec tags.
+
+commit 1f5f4b59400b8b11df83b274efc8ce98186220ef
+Merge: 9d21b0e... 968a0ec...
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 17:28:02 2008 -0400
+
+ Merge branch 'bigdecimal'
+
+commit 9d21b0e890a9394658689af2bdee7e449cd2200b
+Merge: c3f3507... 1a08506...
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 17:25:09 2008 -0400
+
+ Merge branch 'master' of git://git.rubini.us/code
+
+commit 968a0ecda8477b33ceab2e7d0c7e7d084a105bdb
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 17:24:08 2008 -0400
+
+ First stab at BigDecimal.
+
+ * A skeleton of a somewhat naïve implementation of BigDecimal.
+ * Updated spec tags.
+
+commit 1f410d918a59b9b49e87a407cc8fba4bbf342a79
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Apr 18 22:34:53 2008 +0200
+
+ Fix a bunch of specs and minor issues in File::Stat
+
+ Specs for File::Stat#<=>, File::Stat#ino, File::Stat#inspect,
+ File::Stat#mode, File#Stat.initialize and some minor bugfixes
+ such as the fact that File::Stat needs to include Comparable
+ (like MRI).
+
+commit d6f2c6995941762878f4b777a39b0c23ea654605
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Apr 17 22:30:36 2008 +0200
+
+ Remove specs for non-existent File::Stat#initialize_copy
+
+commit c3f350716a35cb869b3ea0289c0e404d07b8819f
+Merge: 810afff... b861102...
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 16:18:34 2008 -0400
+
+ Merge branch 'master' of git://git.rubini.us/code
+
+commit 72101783ec6e66a4f9ac3f9c90f7e8f5b67058ec
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Apr 8 17:05:26 2008 -0700
+
+ Reworked masgn specs to evaluate L2R and assign L2R. excluded.
+
+commit 4e4bec628b21938617bdfa5a2ef17aedf02c112c
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Apr 8 15:17:00 2008 -0700
+
+ trailing whitespace is killing me... evan\! fix your editor\!
+
+commit 810afffa2e549048947c07b30d77be255db42d73
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:26:29 2008 -0400
+
+ Matrix.unit, one more alias for .identity.
+
+commit 2c84f77535d677a42bee93759c77f79c2cdd4d93
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:25:55 2008 -0400
+
+ Name spec correctly.
+
+commit 762f5ee0f7ba4234847c695c92e3ed27dd05e134
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:23:54 2008 -0400
+
+ Specs for Matrix.scalar and .identity/I.
+
+commit b68295e0046a2eb1fb911ea891d6e0a29174ea30
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:22:09 2008 -0400
+
+ Move the "needs to be reviewed" indicator to the right place.
+
+commit 4b6e1097feafe2247e59d6004a36bb0987734138
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 12:03:45 2008 -0400
+
+ Use size functions instead of constants.
+
+commit 2086f0c1f1f899f2e41307a5434a5bb6446e20a2
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 11:58:22 2008 -0400
+
+ Specs for Matrix#clone and #transpose (alias #t).
+
+commit 2939c55b2e9f38b5115b98429de97bc4fff6f165
+Merge: a47f2b8... 42d3212...
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 02:09:07 2008 -0400
+
+ Merge branch 'master' of git://github.com/evanphx/rubinius
+
+commit a47f2b852ca309a68b687157a6cd973716328887
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:27:06 2008 -0400
+
+ Basic specs for Matrix.zero.
+
+commit aa3b2eeef70cb8967ef6c92ee24a226c2d1202c1
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:20:27 2008 -0400
+
+ Move before block to a clearer place.
+
+commit ca6ac1e59ddb268b388975a2fb5b11e6026e65c8
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:19:27 2008 -0400
+
+ Write specs for Matrix.diagonal.
+
+commit b24216d8b0ecfba6888f909415e2523eaed2aeb2
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Fri Apr 18 01:11:11 2008 -0400
+
+ Some initial specs for Matrix#[] and Matrix.[].
+
+ These are in the same file because of coding conventions, but they probably should not be since .[] is a constructor and has very little in common conceptually with #[], which is a subscript operator.
+
+commit 9313f29ed952f604e0d124ced38ee930b5780b27
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Thu Apr 17 22:35:43 2008 -0400
+
+ New spec tags for Complex#%.
+
+commit 08f316de96c94b7d4865d77873327deddeabb664
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Thu Apr 17 22:32:08 2008 -0400
+
+ More specs for Complex.
+
+ * Specs for <=>, conj/conjugate, to_s.
+
+commit 973c304cc16fa6b78dba31de11b151da2daae762
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Thu Apr 17 22:09:20 2008 -0400
+
+ More specs for Complex
+ * Complex#abs, abs2, angle, arg, and %. Not sure that % is correctly specified.
+
+commit e32b26694277065fe28f138dca837b8c0509c735
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Thu Apr 17 21:17:26 2008 -0400
+
+ More specs for Complex.
+
+ * Write specs for * and /.
+ * Rewrite + and - to use alternate constructor syntax.
+
+ Signed-off-by: Marnen Laibow-Koser <marnen@marnen.org>
+
+commit 0cbf88a6c61e477f4b9a7758a9fab1258efbf30f
+Author: Marnen Laibow-Koser <marnen@marnen.org>
+Date: Thu Apr 17 20:46:04 2008 -0400
+
+ Write some specs for Complex.
+
+ * Basic specs for Complex.new, Complex.new!, Complex#+, and Complex#-.
+
+ Signed-off-by: Marnen Laibow-Koser <marnen@marnen.org>
+
+commit 71909e78b8d77f7e48d306e30f51fbc21b5fbefb
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 17 15:26:53 2008 -0700
+
+ Reorganize and fix Matrix specs.
+
+commit 5a9325457696dfba3c410c0adcbdec706ecda3bf
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 17 12:49:45 2008 -0700
+
+ Added spec templates and incomplete tags for CGI.
+
+commit d62de6b4096a9b3bd3fda197b70d6e603596e865
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 17 21:12:08 2008 +0200
+
+ More detailed speecs for BigDecimal#new
+
+commit ebd6fb8f879f94ff51b74cb4e76080fad7b66cb5
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 17 19:55:31 2008 +0200
+
+ More detailed specs for BigDecimal's <, <=, >, >=, <=>.
+
+commit 8caef40cbe873dc2825bc0ba1e66f983b8219cca
+Author: MenTaLguY <mental@rydia.net>
+Date: Thu Apr 17 01:16:25 2008 -0400
+
+ add tag object argument to send_in_*
+
+commit 0596b1aca45a85de5f3d727632585da924fd3eb0
+Author: Matthias Reitinger <m.reitinger@mytum.de>
+Date: Sat Apr 12 10:11:13 2008 +0200
+
+ New specs for BigDecimal.new.
+
+ Signed-off-by: Marius Nuennerich <marius@nuenneri.ch>
+
+commit 5c176e50fe962de1095a75221b4d63e75acc505f
+Author: Benjamin Stiglitz <ben@tanjero.com>
+Date: Wed Apr 16 11:32:18 2008 -0700
+
+ Cleaned up Numeric#div spec
+
+ The spec names are no longer quite as atrocious; the spec output is now fairly
+ readable. The different Integer-Float quotient permutations are now correctly
+ specified as well.
+
+ Signed-off-by: Brian Ford <bford@engineyard.com>
+
+commit e1406b19c51bfca5f6936d143087043316c68c13
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 15 20:07:48 2008 -0400
+
+ Specs for Kernel#p behaviour.
+
+ * Args vs. no args.
+ * Record separator is not taken into account.
+
+commit 30c717e1736b65a852df501f71e320599fc17786
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Apr 15 21:32:13 2008 +0200
+
+ Fix typo in File.grpowned? spec
+
+commit 1bc17a0b4c8f19b84ffdd0b17ec24243a1df6092
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Apr 15 21:31:02 2008 +0200
+
+ Fix File.grpowned? and it's spec
+
+commit f49cf4d0319b5772ede7bcddd763c691d5253b18
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Apr 15 20:44:18 2008 +0200
+
+ Update tags for implemented File.grpowned? specs
+
+commit ea19fb07cb7b789165aec5da0f571345b96f1f0f
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Apr 15 20:41:02 2008 +0200
+
+ Spec File::Stat#grpowned? and implement File.grpowned?
+
+commit c411b15b9f94fec21b02a9208cbae4b42452431d
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Apr 15 20:19:24 2008 +0200
+
+ Properly rename File::Stat#dev_major and File::Stat#dev_minor specs
+
+commit 26ba3ad30cd726b058cd76f23dc7a79555be724e
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Tue Apr 15 10:25:44 2008 -0700
+
+ Quarantine the cvar-related instance_eval spec for now; it's not clean.
+
+commit d72c609ce4567d7a7fdfd2ee4713ac07033c81db
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Mon Apr 14 20:13:38 2008 +0200
+
+ Use EnvSpecs where possible
+
+commit 8ccdf2d612f15515837095e2e4a570861024294c
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Mon Apr 14 17:42:36 2008 +0200
+
+ Use EnvSpecs module for platform dependent stuff
+
+commit 130e4bdb1d9fa9512dfe45d4ff4d718096683cdb
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Mon Apr 14 19:45:24 2008 +0200
+
+ Fix specs for a bunch of File::Stat methods and implement File::Stat#<=>
+
+ Created specs for atime, blksize, blocks, ctime, mtime and <=>
+
+commit e5aa89ff13128afb9b43ad77678792aeae4d48ea
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Apr 12 17:54:57 2008 +0200
+
+ Remove tag for fixed File#lstat
+
+commit 21cd4a10833ef3bdda1593423faccb334de16536
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Apr 12 17:52:33 2008 +0200
+
+ Remove unneccary spec placeholders for File#stat / File#lstat
+
+ The shared spec already tests this behavior. With the new added spec
+ for the difference between the two, File.stat / File.lstat is pretty
+ well covered for now.
+
+commit eacb4f8a4d0ba606458a5756ddd6f2ce723a3dfa
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Apr 12 17:45:55 2008 +0200
+
+ Specced different behavior between File.stat and File.lstat
+
+commit 4ae163810074effc068babf538f004e9ff117156
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Mon Apr 14 16:49:04 2008 +1000
+
+ Refactor Debugger interface into a CmdLineInterface class
+
+commit e61241498f6ca63b7d5e50e94a70456bc40e929b
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Mon Apr 14 14:17:03 2008 +1000
+
+ Breakpoint clean-up
+
+commit ae738f21979edf727437438b992629dd0b59a42e
+Author: MenTaLguY <mental@rydia.net>
+Date: Sun Apr 13 16:14:34 2008 -0400
+
+ elminate Mailbox#clear; difficult to implement with sane semanitics
+
+commit 76385484049e47f53b840ddf3c0dfe9e365ca8cf
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Sat Apr 12 16:39:19 2008 -0500
+
+ More specs for REXML::Element
+
+commit 00547bc562c359ddac13d04a5c955ee25171bcb4
+Author: Matthias Reitinger <m.reitinger@mytum.de>
+Date: Sat Apr 12 11:15:12 2008 +0200
+
+ Fixed incorrect check for object equality in BigDecimal#nonzero? spec
+
+ One should not use == to check if the method returns self, but equal?
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit e8403792167c86f120ce7bdcd1e2c7ce1bc31fea
+Author: Matthias Reitinger <m.reitinger@mytum.de>
+Date: Sat Apr 12 11:31:25 2008 +0200
+
+ Eliminated use of to_s to check for NaN in BigDecimal specs
+
+ Changed "to_s.should == 'NaN'" to "nan?.should == true"
+
+ Signed-off-by: Federico Builes <federico.builes@gmail.com>
+
+commit 5883dd78ad92031c920bb9ee2b703702969a5854
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Sat Apr 12 09:42:11 2008 -0500
+
+ A few more instance_eval specs, for non-immediate numerics and cvars.
+
+commit e8fd8e696d5487fa698a9a8b1bab2fb54b420133
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Sat Apr 12 08:28:41 2008 -0500
+
+ Added instance_eval spec for defining methods under immediates.
+
+commit c23b365a95862cd438e6228929a3a4e935d60de9
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 22:09:06 2008 +0200
+
+ New rubypsecs for BigDecimal#fix and #frac.
+
+commit 6b6b63ebedb61466b4f04f510bf859574efec7d9
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 20:07:07 2008 +0200
+
+ New rubyspecs for Bigdecimal#floor and #ceil.
+
+commit 75e9118aea32baaeec82efedb5106c63bb0eef44
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 17:50:36 2008 +0200
+
+ Corrected Bigdecimal specs since they were missing "should" statements. :)
+
+ Also, added some more cases.
+
+commit 18fafb2e1f653887fdd3cdef693448d9b2bea29e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 17:21:02 2008 +0200
+
+ New rubyspecs for BigDecimal's #power, #** and #exponent.
+
+commit 35e32daa38c7df385aac99f7b709a4038141faaa
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 13:41:13 2008 +0200
+
+ New and updated rubyspecs for BigDecimal#precs.
+
+commit e0172d4eee7a775ab53562477997855ed66615a7
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 12:31:22 2008 +0200
+
+ More rubyspecs for BigDecimal#split and some corrections for older ones.
+
+commit 37d312770700da5eb124fdce7a7b1687c2d9b839
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Apr 11 13:55:00 2008 +1000
+
+ Get breakpoint handling working properly
+
+commit 498b95a720e98b70b56af9dfd2c1ba20c0bf89c3
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Apr 9 17:23:56 2008 +1000
+
+ Make ISeq#decode return symbols rather than objects by default
+
+commit b8bda0546cdb9ac04ae629f13ccfce5f474e6f2c
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Mon Mar 17 14:33:45 2008 +1100
+
+ Ensure breakpoint original instruction is correct
+
+ When multiple breakpoints are set at the same location,
+ only the first breakpoint sees the original instruction.
+ This commit ensures the BreakpointTracker detects such
+ situations, and updates the breakpoint to set the correct
+ oringinal instruction to use.
+
+commit 2700924f23e0283a059583f9e92188b1c3c4f220
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu Mar 13 17:20:49 2008 +1100
+
+ Reorganize Breakpoint class hierarchy
+
+ Refactor Breakpoint class hierarchy in preparation for
+ adding PersistentBreakpoint and BreakpointRestorer classes.
+
+commit bfa69d930c38897df18b656d7b86f0b549bed57f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 03:01:37 2008 +0200
+
+ Some more test cases for BigDecimas#finite? and #nonzero?.
+
+commit 71a4b0a51ea4da0c41d7b096aa7b88deb8d0d049
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 02:42:33 2008 +0200
+
+ A bit more rubyspecs for BigDecimal#sub and #to_s.
+
+commit 8ff9ae455c6c7f4b38f3b4dcbdc6c677759f13e2
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Apr 11 01:35:16 2008 +0200
+
+ New rubyspecs for BigDecimal#truncate.
+
+commit f0a5c13f218d1e2187dfff09bd27cbd6dde544ca
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 10 15:09:55 2008 -0700
+
+ Converted VMActor specs to dir/files. Added incomplete tags.
+
+commit df74b0fd98597b51d4c1d51ae09706d51e1a5d3c
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 10 15:01:08 2008 -0700
+
+ Converted Mailbox specs to dir/files. Added incomplete tags.
+
+commit 29d223d8bfcc36edc16db58d50f8186905df773a
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 10 14:49:52 2008 -0700
+
+ Converted Actor specs to dir/files. Added incomplete tags.
+
+commit 08ab8db440cfdaa7e06b19a0d88750678d4fccbf
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 10 22:09:39 2008 +0200
+
+ New rubyspecs for bigdecimal, and excludes.
+
+commit b76a9e964899348d667181d288c5d4ec0e422c9f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 10 19:33:03 2008 +0200
+
+ One rubyspec for the class definition: def nil:Foo; end
+
+commit c526f5744ece40e312340556991ee54e4504ebcd
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 10 00:53:06 2008 -0700
+
+ Processed Rational, Complex, Matrix with mkspec.
+
+commit 3de6f530c42bdca8c9b1202e60d0d14850024d15
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 10 00:27:40 2008 -0700
+
+ Processed IO with mkspec. Added incomplete tags.
+
+commit faaf8bdb8893f71234d7e2fab07aa11d6c556384
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 10 00:17:35 2008 -0700
+
+ Clean up especially bad whitespace in File specs.
+
+commit fedda8f6865c6cdb07c7599606204f0700042574
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 10 00:09:56 2008 -0700
+
+ Processed File specs with mkspec. Added incomplete tags.
+
+commit 09f6f1b5138b7ca1d276a8c68ee6bf1cba7691b7
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Apr 9 23:42:40 2008 -0700
+
+ Processed Kernel specs with mkspec. Added incomplete tags.
+
+commit e3ca2e3e077c0e026b96e1e68808b95d44233cf5
+Merge: cf0c855... 4d0d1f6...
+Author: Thomas Lachmann <thomas_lachmann@gmx.de>
+Date: Thu Apr 10 02:48:31 2008 +0200
+
+ Merge branch 'master' into bigdecimal_specs
+
+commit cf0c8552f31cfd856822c8aa43a5d9d265481ac0
+Author: Thomas Lachmann <thomas_lachmann@gmx.de>
+Date: Thu Apr 10 02:40:22 2008 +0200
+
+ Next bunch of specs for Bigdecimal.
+
+commit 4d0d1f6b98ac2dafa487ece31512443a07bbc928
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Wed Apr 9 23:42:10 2008 +0200
+
+ Fix ENV specs
+
+ * Try to avoid `env`
+
+commit dfcc69ea8bd78e9e463defdef3b4529a5af40bb5
+Merge: 75e6ccd... 6a50f0d...
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Wed Apr 9 22:26:26 2008 +0200
+
+ Merge branch 'master' of git://git.rubini.us/code
+
+commit 75e6ccd48bce9e0e939a0ff1d484f14a029969f9
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Wed Apr 9 22:26:11 2008 +0200
+
+ Fixes for ENV
+
+ * Add specs
+ * Add some missing methods to ENV
+
+commit 6a50f0d2f5146901fe96fe86802df155c9266a21
+Author: Thomas Lachmann <thomas_lachmann@gmx.de>
+Date: Wed Apr 9 21:11:05 2008 +0200
+
+ Fixed failures for BigDecimal#specs.
+
+commit 09bc62e39a8b92c25aeb6287f9fbf4e9cd2b9a6f
+Author: Thomas Lachmann <thomas_lachmann@gmx.de>
+Date: Wed Apr 9 19:55:45 2008 +0200
+
+ Bunch of specs for BigDecimal.
+
+commit c281add79d621f6327740109895c624dd25a2e1b
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Wed Apr 9 09:13:29 2008 -0500
+
+ Cleaning up UPSocket#send specs
+
+ * Got rid of the weird exception catching
+ * DRY things up a bit with before :each
+
+commit 8ebefe3c0a61b7aab8ac3d0ae9768c35b657cdb6
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Wed Apr 9 09:11:43 2008 -0500
+
+ Adding spec helpers to REXML specs
+
+commit e3064084efbbac1147d477435010d933ce101413
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 8 22:20:43 2008 -0400
+
+ Amended spec wording for Singleton._load slightly. Updated exclude.
+
+commit 23e621625b95e0db82bd406a5eb8fa7324e41a6e
+Author: Chris Shea <chris@tie-rack.org>
+Date: Tue Apr 8 15:49:11 2008 -0600
+
+ Create spec for Marshal.load of Singleton instance
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit eec07baa07d591059c64f32c0ddef169cfcccaef
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Apr 8 20:20:02 2008 -0500
+
+ Thread#wakeup deadlock for MRI marked as ruby_bug
+
+commit dbb744d9692c2432d7aebecac17365125efe9087
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Apr 8 20:02:08 2008 -0500
+
+ spec for wakeup which causes MRI to deadlock when it shouldn't
+
+commit 208a7df6ec2d3c8f550a7ac24db849e593cdc9f3
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Apr 8 17:58:15 2008 -0500
+
+ specs for Thread::list
+
+commit f6f307e75e49cdf597b0b3755ab214c6fc1950dd
+Author: Thomas Lachmann <thomas_lachmann@gmx.de>
+Date: Wed Apr 9 00:54:34 2008 +0200
+
+ specs for BigDecimal.new and BigDecimal#zero? (plus tag files).
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 5b1f2043f70b0088f1c32be79eeaa8179c2210a6
+Author: Jeff Rose <jeff@rosejn.net>
+Date: Wed Apr 9 00:44:27 2008 +0200
+
+ Specs for Actor linking and registration, and Mailbox timeouts.
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 4eea149d3d503c121fb7c65115e374838fff8c8a
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Apr 8 14:55:18 2008 -0700
+
+ Added extra Array subclass dup spec
+
+commit 783a884931b718b8fa65dd9768fbebd8a0d1ac0c
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Apr 8 14:18:45 2008 -0700
+
+ minor cleanup
+
+commit 0e047cc97aa6a5acd7193bdde1139f6a89f108b8
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Apr 8 14:18:27 2008 -0700
+
+ minor cleanup
+
+commit f4797827393e0d9d0e5df5aa5184ecebb066d766
+Author: Matthias Reitinger <m.reitinger@mytum.de>
+Date: Tue Apr 8 17:08:32 2008 +0200
+
+ Extended Symbol#inspect spec and reworked Symbol#inspect to fulfill them
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit b3c3a5f60177f9c52725b6cacf019412d2c747ea
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 8 17:29:58 2008 -0400
+
+ Excludes for BigDecimal specs.
+
+commit b7cd3c38d146a7833ef1d426ea8acd4ee4cb09bf
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 8 17:13:48 2008 -0400
+
+ Switched #requires around to have access to #pretty_inspect.
+
+commit aba428095e09ead8ed66895b175e5f3673c4310e
+Author: Thomas Lachmann <thomas_lachmann@gmx.de>
+Date: Tue Apr 8 17:45:13 2008 +0200
+
+ Spec for BigDecimal#to_f.
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 20a5789f9dc4e6d30dffb594476b354e4aeee201
+Author: Thomas Lachmann <thomas_lachmann@gmx.de>
+Date: Tue Apr 8 17:21:39 2008 +0200
+
+ Spec for BigDecimal#finite?
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 896609e7ae8ee12c72e4e3ce86897c1f8b98f3fb
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Apr 8 02:03:22 2008 -0700
+
+ overlooked 2 specs
+
+commit 77774ed4300d5245c58dbcc686cd72dc48f08a1f
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Apr 8 02:00:24 2008 -0700
+
+ Added a bunch of specs to String#to_f
+
+commit 1b91113c3e8fb46a0d355cae9000ee4c82f95ac3
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Mon Apr 7 21:46:17 2008 -0500
+
+ More specs for REXML
+
+commit 2460839e3fbe2967b9df70db3de33b2a102b9a44
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Apr 7 12:19:40 2008 -0700
+
+ Reworked how MSpec handles config files. Use 'set :sym, value' now.
+
+commit 67d3869e9b3fef6d47727206d02814da410e02fc
+Author: Jeff <rosejn@warp.(none)>
+Date: Mon Apr 7 15:04:09 2008 +0200
+
+ Adding specs for Mailbox and Actor, and renaming the VMActor describe to match the standard scheme.
+
+ Signed-off-by: Charles Comstock <dgtized@gmail.com>
+
+commit 7391c1fbc02966165de03724c42fc1d5243ac99f
+Author: Marius Nuennerich <marius@nuenneri.ch>
+Date: Sun Apr 6 22:29:22 2008 +0200
+
+ repair UDPSocket spec
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 5a205207faad0a85271bfcb459390793702c4143
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Apr 5 04:54:21 2008 -0400
+
+ Partially revert "Add spec files for cgi.rb."
+
+ This partially reverts commit e2714f2fd2d8825ac8af761a5a4545e4d0731735.
+
+ Conflicts, left these files:
+
+ spec/ruby/1.8/library/cgi/escapeHTML_spec.rb
+ spec/ruby/1.8/library/cgi/escape_spec.rb
+ spec/ruby/1.8/library/cgi/rfc1123_date_spec.rb
+ spec/ruby/1.8/library/cgi/unescapeHTML_spec.rb
+ spec/ruby/1.8/library/cgi/unescape_spec.rb
+
+commit 22f3042377731cb6ff963b9e322b24014b286895
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Apr 5 03:18:15 2008 -0400
+
+ Added excludes for the CGI specs.
+
+commit 7b9f5a213c971636b663e992fcb8578888d27f52
+Author: makoto kuwata <kwa@kuwata-lab.com>
+Date: Sat Apr 5 13:03:59 2008 +0900
+
+ Add spec file for CGI::rfc1123_date().
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 31edbd64bba7f352930ac04d51b63e72553796a9
+Author: makoto kuwata <kwa@kuwata-lab.com>
+Date: Sat Apr 5 13:03:14 2008 +0900
+
+ Add spec files for CGI::escapeHTML() and CGI::unescapeHTML().
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit fc321869d73f58dcfbb55ba374646c1568528004
+Author: makoto kuwata <kwa@kuwata-lab.com>
+Date: Sat Apr 5 13:01:33 2008 +0900
+
+ Add spec files for CGI::escape() and CGI::unescape().
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit e2714f2fd2d8825ac8af761a5a4545e4d0731735
+Author: makoto kuwata <kwa@kuwata-lab.com>
+Date: Sat Apr 5 12:44:57 2008 +0900
+
+ Add spec files for cgi.rb.
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 2a1d0ad7e51ba52a918111d53be6a641c41a0445
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Apr 4 22:21:47 2008 -0400
+
+ Improved the *rest argument count spec a bit.
+
+commit e8053e4bb108cf877ac8fdafc104eb34bad671f0
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Apr 4 20:38:23 2008 -0400
+
+ Specs for unlimited argument count for *rest defns.
+
+commit 03e092e45015f8115f806e11460121c560e60b4b
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Fri Apr 4 17:54:25 2008 -0700
+
+ Converted symbol spec to be generative, allowing easier pattern detection
+
+commit bbda617127a8ac319a58fa190d43b3a0d960d309
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Apr 4 14:07:50 2008 -0500
+
+ updated File#inspect tags
+
+commit 38eb679d6b6c5aef8bccb2139e681c926b3290c7
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Apr 4 06:00:37 2008 -0400
+
+ Specs for ~/ expansion in #require, #load. It has broken at some point.
+
+commit 2d600c01205fbb7ccd98e7f7a88ebcbd0e1d1d43
+Author: Paul Thornthwaite <tokengeek@gmail.com>
+Date: Fri Apr 4 08:43:42 2008 +0100
+
+ Updated specs for Set library
+
+ * Added specs for Set#subset and Set#proper_subset
+ * Added specs covering empty sets and comparisons
+ * Corrected spec string to include ? on superset method names
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 3a547c2b82434c64b72967ebd917fc063ff1317d
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Apr 3 23:16:18 2008 -0700
+
+ Fixed GetoptLong specs to not depend on value of ARGV.
+
+commit 5dd9b0ecdddfd990d6387a0a7c70173ea0cededa
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Apr 2 23:27:04 2008 -0700
+
+ Add config file for and rework MSpec runners.
+
+commit 773a13ed9005628e48ed146180041caa035f4072
+Author: David Yip <yipdw@member.fsf.org>
+Date: Thu Apr 3 03:18:48 2008 -0400
+
+ Added spec: full contents of StringIO stream should be accessible after rewind.
+
+ Spec tested against Ruby 1.8.6p111 and Ruby 1.8.6p114 on OS X 10.4.11.
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit ba2ca41cb29ac08c94231a2383940464e6fd1c9d
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Thu Apr 3 08:45:49 2008 -0500
+
+ Updated tags for REXML specs
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 09c080bf33092b9d147d1b0a5de920fce8527fdc
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Thu Apr 3 08:45:26 2008 -0500
+
+ Fixes whitespace in REXML::Element specs
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 3a997bc18f589b91b4cd518448644171f3054abf
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Thu Apr 3 08:29:23 2008 -0500
+
+ More specs for REXML::Element
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit d250939060a4a91a6fee59bd4bfa4e86eb271373
+Author: Paul Thornthwaite <tokengeek@gmail.com>
+Date: Thu Apr 3 14:36:42 2008 +0100
+
+ Specs for Set#superset and Set#proper_superset added
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 01399738d5ad0136ef205b8501b12012c7e42230
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Apr 3 18:09:20 2008 -0400
+
+ Removed excludes for Object#kind_of?, #is_a?.
+
+commit 0e7d1c6e02e5617bb251366e0d60760edb29377e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Apr 3 20:04:34 2008 +0200
+
+ Fixed copy-paste error in Object#is_a? specs.
+
+ Adjusted the Object#is_a? exclude.
+
+commit 4a9cb7cc0c734b4280c3a65906c85e1c1e2f4990
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Thu Apr 3 19:02:05 2008 +0200
+
+ Add specs for #kind_of? / #is_a? behaviour that are failing in Rubinius.
+
+commit e88fdb6cbd9fa829a81e6c7664e88f6956ddae64
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Apr 3 07:18:56 2008 -0400
+
+ Spec to check `A = 12; class A; end` raises TypeError. Works as is.
+
+commit 3c0db09626333405bdcb72e62ddb8fb2ea176ff5
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Apr 3 06:44:32 2008 -0400
+
+ Spec for const lookup: `A = 12; class A::B; end` should raise TypeError.
+
+ * Currently crashes due to a lookup problem.
+ * VVSiz discovered and reported.
+
+commit edda5994c293e4d26b4a741e90e0ab61513e8dec
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Apr 2 16:39:09 2008 +1100
+
+ Do not strip leading spaces in debugger output
+
+commit eecc2bca5045921368378abfccafcf70339441f9
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 2 21:34:52 2008 +0200
+
+ Enabled File#truncate testcase for JRuby.
+
+commit 4d555cf50dfe6a8e9cb2f24a6a636a9df3f03768
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Apr 2 20:03:02 2008 +0200
+
+ Added test case to File.open rubyspecs.
+
+ Courtesy of David Yip.
+
+commit 42f0b52cd9fbac4a39fc1e5c2a241462bee5bf3b
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Apr 2 01:11:38 2008 -0700
+
+ Use kind_of instruction since #kind_of? is not available at all times.
+
+commit 9ee52514eee820b9af7c9e6d2eaaca8d2bca363b
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Apr 1 17:16:47 2008 -0500
+
+ IO#reopen should return self
+
+commit f1481283091fcbe662fd01d409f5a2d2d7e3aa59
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Apr 1 18:57:06 2008 -0500
+
+ added primitive io_close_ng and tagged IO#close spec failures
+
+commit 3861e75e01af9319e2af879e2644fc8509947903
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Apr 1 16:07:27 2008 -0500
+
+ IO#close should return nil and refactored TCPServer.accept specs
+
+commit d6dfbd3b0bab57453e67991c3320744b08346979
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Apr 1 15:04:18 2008 -0500
+
+ DRb specs now attempt to check if server is up/down prior to each call to start_server
+
+ note that there is something wrong with the way stop_server works in rubinius as it appears that the TCPServer is still binding the port. Spec is tagged to deal with this but technically it's probably a bug in TCPServer
+
+commit 4119fe8baab45be6b1d1370b8a9537e710b1a60a
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 1 12:40:47 2008 -0400
+
+ Sanity changes to #load specs to bring them up to date.
+
+ * Please change the specs if you change the implementation, sheesh.
+
+commit 3b58cb35abeba31f7ac72e3ab37b2630949406a7
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 1 10:59:58 2008 -0400
+
+ Spec for forced recompiling through second parameter of Kernel#load.
+
+commit 5d7a73ae15a4c40e31486a60cbb66f3de1ac4697
+Author: David Whittington <djwhitt@gmail.com>
+Date: Wed Apr 2 02:57:35 2008 +0000
+
+ Add tags for failing private keyword specs
+
+commit 1b2f118be7ff9b6adfea736ecbbb8f3fd8dd0f49
+Author: David Whittington <djwhitt@gmail.com>
+Date: Wed Apr 2 02:53:43 2008 +0000
+
+ Added a couple evil private keyword tests
+
+commit f58c67e33a99f751c3520ab65c96e28a91c45900
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 1 09:59:22 2008 -0400
+
+ Conditional compilation. Rubinius.compile_if($DEBUG) { p somevariable }.
+
+ * Hacky and probably fragile but it seems to work. Whenever the gvar
+ given as condition evaluates to false, the entire block is omitted
+ from the produced bytecode. If it evaluates to true, then the extra
+ block itself is stripped and only the block contents remain.
+ * Do NOT use indiscriminately until we have played around with it for
+ a bit to avoid problems.
+ * Manipulates the sexp, not the AST to avoid worrying about locals
+ and scopes and whatnot.
+ * Enabled by default; for example -d will work out of the box (you
+ do need to have the file recompiled obviously.)
+
+commit 4f78ee2b0bebb9170a483927af9c7520ca67f912
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Apr 1 09:58:53 2008 -0400
+
+ Specs to verify conditional compilation in the compiler.
+
+commit 8dfece35e3bc83e14e92bfee9ea0ebabb795da70
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Apr 1 01:07:14 2008 -0700
+
+ Fix up language symbol specs.
+
+commit 29cc22f2c1f7ce2ce15a7f339d1159cf93510daa
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Apr 1 00:40:34 2008 -0700
+
+ Constant lookup only searches class or module (#457).
+
+commit 538611f2aa06a1cf1c3958583bd6a8487deee994
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Mar 31 18:03:41 2008 -0400
+
+ Spec for empty loop body.
+
+commit fd0d1079671d7664de3a6a836c5e5624d487a4e1
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Mon Mar 31 23:47:40 2008 +0200
+
+ Spec for constant lookup on non Module or Class objects
+
+ This exposes the bug also described in ticket \#457
+
+commit 3b7cf550c70db2dd53cb58ef3efd2651ee352134
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 31 21:53:40 2008 +0200
+
+ Added a couple of Dir.glob/Dir[] rubyspecs.
+ (Courtesy of Roland Swingler)
+
+commit bbfa77a8517390bdc807f41bfe6d101791980d8f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 31 19:04:09 2008 +0200
+
+ Fixed DRb rubyspecs (proper spec name, removed invalid file, better cleanup).
+
+commit d8a4fb0b16dc4c722cf148ff83bcad05fbb4af1e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 31 14:29:54 2008 +0200
+
+ Make sure Marshall#load rubyspec closes the file.
+
+commit 4082a7663eaef50000be46d909c22fbb97a1a3e8
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 31 13:57:35 2008 +0200
+
+ Reverted new Range#step rubyspecs, since they fail on MRI and JRuby.
+
+ Partial revert "Fixes for Range#step."
+ This (PARTIALLY) reverts commit a6b06a67207c40ffa9ccf191c051fdf2fa0f5359.
+
+ The specs are reverted since they fail on:
+ MRI 1.8.6 pl 36 (Ubuntu default)
+ MRI 1.8.6 pl 114 (Current compatibility target)
+ MRI 1.8.6 from 1_8 branch
+ MRI 1.9 from Ruby trunk
+ JRuby 1.1 from trunk
+
+ The specs expect that to_f is invoked, but MRI and JRuby don't behave
+ that way. Furthermore, Float is not a special case. There are other
+ cases, like Rational. Take a look into MRI code, there is no special
+ handling for Float.
+
+ Please, test your spec updates at least against the current
+ compatibility target (MRI 1.8.6 patchlevel 114) to avoid problems.
+
+commit 6d9680ecaaa2a9aadd35699c8064bf6481acc107
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 31 13:23:20 2008 +0200
+
+ Added new rubyspecs for IndexError out of String#[]=
+
+commit c8a52bb7cf191bb35efc89c560bdeced4241f015
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Mar 31 04:38:49 2008 -0400
+
+ Split Regexp#=~, #match specs; they behave differently on match.
+
+ * #=~ Returns index, #match returns MatchData.
+ * Grammar fixes.
+
+commit 6c2727e928991cdf9f809cb5941c3afedb5171ff
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Mar 31 04:07:17 2008 -0400
+
+ Fix Regexp#match, #=~ spec to actually be shared. Exposes #454.
+
+commit e258a2bccafffba57ab86d1c1a104839bda424da
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Mar 31 03:30:48 2008 -0400
+
+ Spec to verify IO behaviour with an altered BufferSize from Le Huy.
+
+ * Moved spec to spec/core/io/ and simply used the first one.
+ * This problem seems to have been largely corrected.
+
+commit 7a39be8bea055464838ff24c70e170a91f8df68c
+Author: Ben Burkert <ben@benburkert.com>
+Date: Sat Mar 29 19:39:11 2008 -0500
+
+ Added spec for Module#define_method
+
+ Methods defined by define_method with a proc should have the
+ same scope for local variables as the proc.
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 12c639d90ff3d14f8010ca7c782612bd7c1777ab
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Mar 29 23:58:13 2008 -0400
+
+ Tony Arcieri's specs for inter-VM Actors.
+
+ * VMActor implements the Actor interface to work in Rubinius' Multi-VM
+ context: VMActors can reside on any VM instance.
+
+commit a0d0884aa3c9e7a6fa949cbde1cdf2392bc4ff23
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Mar 29 15:59:42 2008 -0400
+
+ Module#attach_foreign allows using a symbol to give the function name.
+
+ * Specs for the same.
+
+commit a5f397f38d6c9eafcac163c2cf678d5c55a6b79b
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Mar 28 23:40:04 2008 -0400
+
+ Specs for FFI in general and Module#attach_foreign in particular.
+
+ * Very basic specs to verify that FFI in fact works correctly.
+ * We need to define what the behaviour should be in the case of e.g. an
+ incorrect function signature. Currently it may or may not cause SEGVs
+ depending on the exact usage. Remainder specs are in but quarantined.
+
+commit 3dc5c635b56bc599a718a94f990976b67ab52b6c
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Mar 26 02:01:12 2008 -0400
+
+ Specs for Module#attach_foreign.
+
+ * The method is a replacement for #attach_function but allows
+ giving the library name as well to access external libs.
+ * This acts a higher-level interface to FFI.create_function. The
+ "real" FFI specs will be written for that method instead.
+
+commit 677412353409ba4e5d67f19a3d095c62d009c88f
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Mar 28 18:04:40 2008 -0700
+
+ Added CType#isctrl, #toprint. Rework String#inspect, #dump.
+
+commit 87ba991b9b488b808ebf729b9e41765df76cc602
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Mar 28 15:09:11 2008 -0700
+
+ Reworked String#each and #sum. Added String#modified? and specs.
+
+commit 204d8ce1a792a61882e549953b5b878139ac9cda
+Author: Hongli Lai <hongli@plan99.net>
+Date: Fri Mar 28 23:32:18 2008 +0100
+
+ Spec: Marshal raises EOFError on loading an empty file
+
+ Signed-off-by: Michael S. Klishin <michael@novemberain.com>
+
+commit f6e698f96ce9e2a8c8abe856322add02931df8b7
+Author: Michael S. Klishin <michael@novemberain.com>
+Date: Sat Mar 29 02:20:23 2008 +0200
+
+ Tag new spec for ensure as failing
+
+commit ef7e4436389a0f4346b3a3bc5c275b653f46d6bb
+Author: Hongli Lai <hongli@plan99.net>
+Date: Fri Mar 28 23:22:44 2008 +0100
+
+ Add spec for exception handling inside ensure block.
+
+ Signed-off-by: Michael S. Klishin <michael@novemberain.com>
+
+commit f54c91f6cb7498fe44b1b05a1372d9f6ed3ea1ee
+Author: Stuart Halloway <stu@thinkrelevance.com>
+Date: Fri Mar 28 10:11:05 2008 -0400
+
+ Fixes Pathname#absolute? and #relative?.
+
+ * specs now pass
+ * underlying cause was corner case in File#basename
+ * new passing spec for corner case
+
+ Signed-off-by: Charles Comstock <dgtized@gmail.com>
+
+commit 0d4606d53d8fc0bcb2370bd648546abffd402673
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Mar 28 16:45:47 2008 -0500
+
+ fixed CSV::Reader.parse spec to use local fixtures
+
+commit 35a15c6c85ebb6eabaec16e03aa88399061844e9
+Author: Alister Lee <rubinius@dev.shortepic.com>
+Date: Sat Mar 8 18:11:24 2008 +1100
+
+ Beginning of specs for CVS::Reader.parse
+
+ Signed-off-by: Charles Comstock <dgtized@gmail.com>
+
+commit d4161a379eab621e338a8c82f088b834756082e9
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Mar 28 16:39:50 2008 -0500
+
+ removed csv/reader/parse_spec to commit alister lee's spec
+
+commit 534806c10a95435873efcb0d215732d7da4f2fd6
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Mar 28 16:38:03 2008 -0500
+
+ mkspec generated specs for csv.rb
+
+commit a6b06a67207c40ffa9ccf191c051fdf2fa0f5359
+Author: Stuart Halloway <stu@thinkrelevance.com>
+Date: Fri Mar 28 06:09:34 2008 -0400
+
+ Fixes for Range#step.
+
+ * previously failing specs pass
+ * new spec added to cover float/int difference
+
+ Signed-off-by: Michael S. Klishin <michael@novemberain.com>
+
+commit 6886ec5851783c5364ff5bc464ee94071fc8535e
+Author: Michael S. Klishin <michael@novemberain.com>
+Date: Fri Mar 28 00:06:56 2008 +0200
+
+ Update stdlib and specs for REXML from 1.8.6 patchlevel 114 (see details!)
+
+ * Update stdlib/rexml to use REXML from Ruby 1.8.6 p114.
+ * REXML in p114 is screwed up: call sites were not updated
+ after REXML::Formatters::Transient#initialize arity
+ change. Ruby 1.8.x branch in SVN though has
+ completely different REXML layout and organization
+ (rev. 15833) so there's no way to fix it until we know
+ where REXML changes are headed in 1.8.x branch.
+ * Update REXML spec and tags for it.
+
+commit 3145a74a85d72f6ef8a93384a74d96a589bfb5eb
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Mar 26 22:27:41 2008 -0700
+
+ Rework and cleanup of various String methods.
+
+ Also, ensure that when Strings are converted through FFI
+ and passed to C functions, the char array is explicitly
+ terminated with \0.
+
+commit 9ba3e515b49729e0cb80181af9e28e3ce4c70e97
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Mar 26 18:40:57 2008 -0700
+
+ Shuffle some String methods. Add specs for and rework String#substring.
+
+commit 990d47b84bc6301be2a8bcbaccbae65ef697c417
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Mar 25 16:22:45 2008 -0700
+
+ Added String#compare_substring. Reworked String#chop! and #chomp!.
+
+ Also, to ensure that ByteArray instances that are accessible in
+ Ruby are properly handled by C functions, changed string_equal_p
+ to use strncmp instead of strcmp.
+
+commit f47c446daa136e6f31f5c590dd535ba22e89a0b2
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Mar 25 11:36:16 2008 -0700
+
+ Fix errors in String#count_table spec descriptions.
+
+commit 9425d0de9a7883c14de6ae9ae5db05ab92141ab9
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Mar 26 22:38:48 2008 +0100
+
+ Guarded two failing specs on OpenBSD that also fail on MRI
+
+ MRI on OpenBSD also suffers from the 0.0 / -0.0 issue (the
+ GCC version on that platform too). The child reaping spec
+ also fails on both MRI and Rubinius
+
+commit 288a6e2ca3675a1e60bfd6b8b328c2a4d513c12f
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Mar 26 22:15:16 2008 +0100
+
+ Fix Socket specs for more strict BSD behavior
+
+commit 63513d23f16ca7919b8605e016a3a941b79c0834
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Mar 25 17:20:53 2008 -0700
+
+ oops! extra exclude
+
+commit a36a4bf8cde95c99282e07f46438430588288736
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Mar 25 17:20:19 2008 -0700
+
+ really minor changes
+
+commit e9b759812deaf97e7fe5846c116d53f69b63e244
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Mar 25 17:19:41 2008 -0700
+
+ Added the sucky parser spec--not passed yet
+
+commit 90eb74998e132373e6b96e3c66bfa909854e3ef0
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Mar 18 17:41:50 2008 -0700
+
+ Added spec for 'a [ 42 ]'
+
+commit 2d34643c75b53b832e89d2473d501ab1c8a5df02
+Author: David Whittington <djwhitt@gmail.com>
+Date: Wed Mar 26 08:01:20 2008 +0000
+
+ Tagged Generator specs as unstable due to memory consumption
+
+ Each spec consumes > 60MB of memory. After looking at the specs there is no way
+ they should be consuming that much memory.
+
+commit 52d81e0593dbca8abfecefe2e9c3d2ab504cfe0b
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Mar 25 10:43:17 2008 -0700
+
+ Added String#copy_from primitive. Reworked String justify methods.
+
+commit 1aabda50ea82974b96a7032a0ea13865b2332b5d
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Mar 24 21:57:02 2008 -0700
+
+ Added Tuple.template and reworked String#tr and friends.
+
+commit bc7d9ccb8b8ca77d8479f325ea314fc09bc34907
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Mar 21 00:51:10 2008 -0700
+
+ Rework methods that behave like String#count.
+
+commit 1e5ac9a6818c972882e080aeb723a105108e0c57
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Mar 19 21:25:07 2008 -0700
+
+ Rewrite of String#casecmp, approx 2x faster.
+
+commit c39f2cb708169d35c2fbeb969ee3323c704f0566
+Author: Matt Palmer <mpalmer@engineyard.com>
+Date: Tue Mar 25 21:09:37 2008 +1100
+
+ Some specs for the timeout library
+
+commit cb69bdadeb10cf6b4b2c71a095562f8d8371d76d
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Mon Mar 24 17:55:23 2008 -0500
+
+ Small fix for Socket.getaddrinfo spec
+
+ Signed-off-by: Michael S. Klishin <michael@novemberain.com>
+
+commit 5c3a61edef3c456b8296e65f8e06026347339a36
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Mon Mar 24 17:06:36 2008 -0500
+
+ Fix for the socket's issue
+
+ Signed-off-by: Michael S. Klishin <michael@novemberain.com>
+
+commit f3fd9ac4eebd0bc2a0a06bbe06921463d03177eb
+Author: Federico Builes <federico.builes@gmail.com>
+Date: Mon Mar 24 14:10:46 2008 -0500
+
+ Fixes specs for Socket and adds a gethostname spec
+
+ * Changes hardcoded "localhost"s to Socket#gethostname calls.
+ * Adds a simple spec for Socket#gethostname
+
+ Signed-off-by: Michael S. Klishin <michael@novemberain.com>
+
+commit 7131328bc02057b16071a933fe98f331b27e00bb
+Author: Michael S. Klishin <michael@novemberain.com>
+Date: Tue Mar 25 00:24:01 2008 +0200
+
+ Applied slightly modified patch by Federico Builes:
+
+ * Add REXML::Document and REXML::Attribute specs
+
+commit cb464295e5accb00e783f7f9e2a0b10c64ad6579
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Mar 23 12:06:07 2008 +0100
+
+ Added new Range#step rubyspecs.
+
+ Excludes for rbx also updated.
+
+commit 7d181716ac3b92d8a31a20ec30daee455d36fc58
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Sat Mar 22 14:51:30 2008 -0500
+
+ Added order-of-evaluation spec and tags for rubinius failures.
+
+commit 5caf94ce6deb5e28c9a3de02e60a9b86cbdaf7ec
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Mar 21 12:37:02 2008 -0500
+
+ tagged new specs for pathname
+
+commit 62f88983ee3fa1b09d8f7df56e35cbfdac6d2a06
+Author: Martin Stannard <mstannard@gmail.com>
+Date: Fri Mar 21 12:10:23 2008 +1100
+
+ added some specs for pathname library
+
+ there are failures in absolute and relative specs
+
+ Signed-off-by: Charles Comstock <dgtized@gmail.com>
+
+commit 655f61650bb299f38c9fd978594baa483fc0d0cc
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Mar 18 16:22:24 2008 -0700
+
+ Reduced parser todos from 113 to 89
+
+commit f97b2fc2ee3310e81871200125bbd7e33c2636bf
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Tue Mar 18 13:51:31 2008 -0700
+
+ Moved sexp_expectations.rb to fixtures subdir
+
+commit 0a185e5ac48954cf4addae0c8f09dcb5be259f8e
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Mon Mar 17 17:55:50 2008 -0700
+
+ Added f'd up note about the spec failing
+
+commit 978f043e1ed3a2b7cb7d4129e0002be485b0a78c
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Mar 18 21:17:32 2008 +0100
+
+ Fix Process.groups spec
+
+ Process.groups can return an array with the same gid multiple
+ times on certain platforms (at least on FreeBSD and OpenBSD).
+
+commit 8812658dde5e317dfebd0ea3c159ad0a1b98e8e8
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Mar 18 21:02:00 2008 +0100
+
+ Update spec tags for ERB
+
+commit 47216560d4a980cbaac2855e0c5ee302e0754bf8
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Mar 18 20:53:16 2008 +0100
+
+ Update spec tags for IO
+
+commit 7d34f4053023d99c3be4964bfebb3a1c74cd40c9
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Mar 18 20:32:39 2008 +0100
+
+ Update spec tags for File
+
+commit 8a66bc6f5e378f49febb80fba37723a7de0d2475
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Mar 17 15:46:51 2008 -0700
+
+ Added specs for File.[l]chown/#chown, code for File.lchown.
+
+commit 960872ae163a5615f513c58d727a7fd93664673e
+Author: Glenn Davy <glenn@thor.local>
+Date: Mon Mar 10 10:00:40 2008 +1100
+
+ Make File.fnmatch respect case when using square brackets
+
+commit 0e32f8e224543a3c152b0351540eaa36fdfcdb06
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Mar 17 11:04:27 2008 -0700
+
+ Added exclude for failing spec added in b635fcf0.
+
+commit 62687753b239984acba4f0e80899ca75a8a08cfe
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Mar 17 10:56:31 2008 -0700
+
+ Fixes and specs for Module class_variables methods.
+
+commit b635fcf041707fe55a26b7709aef8dc1b2509161
+Author: Charles Oliver Nutter <charles.nutter@sun.com>
+Date: Mon Mar 17 12:52:13 2008 -0500
+
+ Add a simple Module#private spec.
+
+commit 2aa98e1df50bba768b57018f6e90c56fe39206f4
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 17 13:28:17 2008 +0100
+
+ Make sure no processes left hanging after IO#close specs.
+
+commit 8f332dde4460c03c378f1d1ecc1fbae54557d8ee
+Author: Matt Palmer <mpalmer@engineyard.com>
+Date: Mon Mar 17 16:44:24 2008 +1100
+
+ Raise an Errno exception if a write fails
+
+commit 55c830063115e4455eeda3f8de639a7f7e0624f5
+Author: Matt Palmer <mpalmer@engineyard.com>
+Date: Mon Mar 17 16:42:16 2008 +1100
+
+ Raise IOError if we attempt to write to a readonly file
+
+commit ad64c0ea7598b8a4c62ba2dd435f70c976186a50
+Author: David Whittington <djwhitt@gmail.com>
+Date: Sun Mar 16 04:24:54 2008 +0000
+
+ Modified file type specs to search for sockets in /var/run instead of /var
+
+ Doing a find on /var could take quite a while + might do nasty things like do
+ finds on backup files etc. Running a find on /var/run should be faster and
+ safer.
+
+commit ff5e9d3b9d7f3e484211b66fff96e665ed13614b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Mar 12 17:44:55 2008 +0100
+
+ Revert "Added simple spec for range splatting".
+
+ This reverts commit 9b3988436a21f61c86168a7566d472c4dfa22162.
+
+ The spec uses '=' instead of '==', and it verifies something
+ that is not true for MRI (1.8, 1.9) or JRuby.
+
+commit 004662e54477269a98475f84724972b82885d9cb
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Mar 15 01:09:43 2008 -0700
+
+ Exclude failing UNIXServer.new spec.
+
+commit 13340924519f607d9c48da04c3f3ab41a1de3e86
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Mar 14 18:14:06 2008 -0700
+
+ Tagged unstable Process.kill specs that cause hangup on linux.
+
+commit c4a4dc19a26db058594c8056933cdab42d4f26fd
+Author: Matt Palmer <mpalmer@engineyard.com>
+Date: Fri Mar 14 21:13:31 2008 +1100
+
+ Fix up IO#write spec so it works cross-platform
+
+ It looks like the Linux implementation of IO#write and IO#read are a bit
+ different from the OS X version, because the spec worked on OS X.
+ Presumably this tiny change won't cause any conniptions.
+
+commit 33890d9a77d5a34c15263f84b9b415ffc084815a
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Mar 14 14:42:11 2008 +0800
+
+ Remove fail tags from passing ruby/1.8/core specs
+
+commit 4bdd3df099fe627d158f4c6d35e5a7df0a891e86
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Mar 14 12:58:40 2008 +1100
+
+ Fix bug where stepping by line would sometimes skip a line
+
+commit 260190092afbcfadd1a6e1d6db1674ecf021b686
+Author: Matt Palmer <mpalmer@hezmatt.org>
+Date: Sat Mar 8 19:26:41 2008 +1100
+
+ Put in an explicit IO.new test for single-argument
+
+ Assuming that your UDPSocket tests passing will prove that IO.new takes
+ one argument might have been, in retrospect, a little retarded.
+
+commit 58216e07f0728415762fe5fbe98e1e984dfea31b
+Author: Matt Palmer <mpalmer@hezmatt.org>
+Date: Sat Mar 8 18:45:17 2008 +1100
+
+ Mark changing failures in the CI test suite
+
+ Fix up so that the CI doesn't fail as a result of my previous changes to the
+ UDPSocket specs.
+
+commit 36f91c5da132f309fbf6d047fd74ebd8aa7cbf22
+Author: Matt Palmer <mpalmer@hezmatt.org>
+Date: Sat Mar 8 17:26:49 2008 +1100
+
+ Rearrange the UDPSocket test cases for better separation
+
+ * open_specs now only contains a spec that calls UDPSocket.open;
+ * send_specs now has separate tests for ad-hoc and connection-oriented
+ sends.
+
+commit b40c1cf434bd0879f672ec1dc471f1e1dfaccc1c
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Mar 13 17:07:50 2008 -0700
+
+ Add (failing) Symbol#to_yaml spec based on ticket 322
+
+commit c0bcb0151379fe9858d0fafd2ef56cf1b08daff3
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Mar 13 16:23:37 2008 -0700
+
+ Apply ticket 351 and resolve ticket 350 (RbYAML bugs)
+
+commit a8d6e8cddfd8bc2dccaa93b25adfb31b39b96dba
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Mar 13 16:25:55 2008 -0700
+
+ Removed all should_not raise_error from shared/time_params.rb
+
+commit 01f09f4e5697c4a775ac321a71d3b777196d9001
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Mar 13 15:47:37 2008 -0700
+
+ cleaned up spec with new raise_error block form
+
+commit e965fc735311915dd43c47cc4853e163376cc6be
+Author: Lachie Cox <lachie@smartbomb.com.au>
+Date: Sat Mar 8 17:14:37 2008 +1100
+
+ enhanced syntax error to give same message as MRI
+
+commit 868b38152ca99189fce85542a9068c0d01ee4a41
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Mar 13 15:07:33 2008 -0700
+
+ Added exclude for last patch applied
+
+commit 9b3988436a21f61c86168a7566d472c4dfa22162
+Author: Patrick Hurley <phurley@gmail.com>
+Date: Mon Mar 3 14:04:14 2008 -0500
+
+ Added simple spec for range splatting
+
+commit 3c7a017e173945d3f9b18d566bb1c3d6d04e97e4
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Thu Mar 13 17:18:39 2008 -0500
+
+ fixed tags for new constant specs
+
+commit a966436b7be78bc063e32bc16496f5cabbb0a152
+Author: Matt Palmer <mpalmer@hezmatt.org>
+Date: Sat Mar 8 14:56:58 2008 +1100
+
+ Make sure modules included in Object are found
+
+ Add a spec to make sure that constants from modules included in Object are
+ found. Evan is committing the fix for this separately.
+
+ Signed-off-by: Charles Comstock <dgtized@gmail.com>
+
+commit 4e0ddd3e701f68b592cb69972f7d587b90392913
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Mar 13 15:05:54 2008 -0700
+
+ Correct a 'defined?' spec added by ticket 388
+
+commit 407095d8ffbf0563fa46e5d4ed6a08423eddb2ad
+Author: Martin Stannard <mstannard@gmail.com>
+Date: Sat Mar 8 15:47:59 2008 +1100
+
+ Added tests where defined? method should return string descriptions of objects
+
+commit f366309a8fff28552d7d27101d8b3d7b4352e235
+Author: Gianluigi Spagnuolo <glgspg@gmail.com>
+Date: Fri Feb 29 10:42:42 2008 +0100
+
+ Fixed Array set element problem
+
+commit 42c22bf542edc8c8379587507fd9e35ba25b190c
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Thu Mar 13 17:00:31 2008 -0500
+
+ updated tags for new read specs
+
+commit 45c43a7ab3310a41b0b3367f4762a1bb55b02405
+Author: Ben Askins <benj@supernova.local>
+Date: Sun Mar 9 11:41:49 2008 +1100
+
+ Fix typo in file/open_spec.rb
+
+ Signed-off-by: Charles Comstock <dgtized@gmail.com>
+
+commit a221ea56325fe082154a629094abb27d40919a39
+Author: Alister Lee <rubinius@dev.shortepic.com>
+Date: Sun Mar 9 15:27:34 2008 +1100
+
+ Specs to expose defect in eof treatment in IO.read
+
+ Signed-off-by: Charles Comstock <dgtized@gmail.com>
+
+commit 4967adb3d49252aae75b6b57159fb5879ac75db1
+Author: Myles Byrne <myles@ducknewmedia.com.au>
+Date: Sat Mar 8 12:14:20 2008 +1100
+
+ Check existence of ArgumentError
+
+commit 45e46234da288052e639bb5c9c122874fd4d4e1c
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Mar 13 10:28:54 2008 -0700
+
+ Fix File[Test].size? and specs for it.
+
+commit d467bf21c4037784a21ba964b24c28fc80b34736
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 17:36:56 2008 +0800
+
+ Fix IO::foreach when separator is nil
+
+commit 70615e1c15692b8a8149e1616c802db9eb5bad11
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 17:32:40 2008 +0800
+
+ Fix IO#flush to raise IOError on closed stream. Remove empty tag files.
+
+commit 9c9e7f422c98bf6add6c9a426ae25e3a6dbced85
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 17:29:31 2008 +0800
+
+ Fix IO#fcntl to raise IOError on closed stream
+
+commit 215d600002948efb949422c0163aa9bbe5790507
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 17:27:43 2008 +0800
+
+ Fix IO#dup to raise IOError on closed stream
+
+commit 879ee8124a2ad8ce83bcd9c51b2d6df0baecb40d
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 16:29:03 2008 +0800
+
+ Fix a bunch more IOError when closed stream
+
+commit 487d9561992eb03c3d12de5128772cd194b37b8b
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 16:26:33 2008 +0800
+
+ Implement IO#read_nonblock
+
+commit 15c58fa2c47d2dc61b3dac436ab3b56a727b7dc5
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 15:46:22 2008 +0800
+
+ Fix remaining IO.read specs
+
+ * Passing nil to length treats it as no length limit
+ * Passing nil to offset treats it as 0
+
+commit 9daee4f9c3b62db34b07d74171d1017fa823533c
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 15:32:13 2008 +0800
+
+ Fix IO#sync to raise IOError on closed stream
+
+commit 2ac848c09e055b3eacc8bb18f713d56715484063
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 15:24:36 2008 +0800
+
+ Fix IO#sync to raise IOError on closed stream
+
+commit 36aa8577603f1d8ca76344fc3e889bb7c991bfe9
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 14:51:13 2008 +0800
+
+ Fix IO#sysseek to raise IOError on closed stream
+
+commit 3307f5a4db121c2097b450278bc3cf19550f267b
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 14:48:30 2008 +0800
+
+ Fix IO#pos and #IO#tell to raise IOError, move their specs to shared
+
+commit 72890065371f3e1d1cde43618a3da04c900749aa
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 14:39:21 2008 +0800
+
+ Implement IO#to_io
+
+commit 4977bd1f22278e19ba69203c2545ad97c297ae23
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 14:33:03 2008 +0800
+
+ Remove IO#isatty tag file also, since they are sharing the same specs
+
+commit 5dd3115465852ddb03b7100b21739f9d38f0ee58
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 14:29:13 2008 +0800
+
+ Fix IO#tty? should raise IOError on closed stream
+
+commit 063f56b4c402180c2c989a15b75fe7a15d4c5c61
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 13:55:55 2008 +0800
+
+ Make IO#syswrite use the shared IO#write specs
+
+commit 22de413f6cccb3eb100fd29da90c2ded84ea19f3
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 12:08:50 2008 +0800
+
+ Update IO#write_nonblock's tag
+
+commit 25a5ac7e9123512e87e6460f1fa5ecbcfc7349b5
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 12:07:22 2008 +0800
+
+ Pull out 2 differences between IO#write and IO#write_nonblock specs
+
+commit a40dbd0f36f0237bc27c905c399aba1e62bbfa70
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 11:39:03 2008 +0800
+
+ Alias IO#write_nonblock IO#write and make IO#write specs shared
+
+commit 1c8eb4bc04405753dd607af1f5d231df01fd2536
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 11:06:09 2008 +0800
+
+ Make the mock return a string to prevent a coercion error
+
+commit a85b2105c826a7d39dc45c90cad37faf75baac86
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 10:39:00 2008 +0800
+
+ Fix IO#write should raise IOError on closed stream
+
+commit e8c8af1aa888dc3e5600cad64f03c09aebaf6d22
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Mar 13 10:34:08 2008 +0800
+
+ Fix IO#to_i should raise IOError on closed stream
+
+commit 49d48c381b7ed0f2576c2c5bff3ac8825a0dd49e
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Wed Mar 12 17:56:26 2008 -0700
+
+ Fix the insanity
+
+commit 646136d0f75b165a3a62266791556d3f4f03c835
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Wed Mar 12 17:04:30 2008 -0700
+
+ Finally got compiler specs passing
+
+commit 052bbcbe4f51b322ae44dc387320f9b4964d74cd
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Mar 12 16:23:58 2008 -0700
+
+ Correctly set Syslog mask in Syslog::open and add crappy spec for it
+
+commit dbabc5bda94a2bd77b2cb777666d286155c75ee0
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Mar 12 14:55:08 2008 -0700
+
+ Correct Syslog specs and modify syslog.rb to pass them
+
+commit 5b8bee08f2a19d6f25df98183a24745ed33ed519
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Mar 12 14:54:38 2008 -0700
+
+ Modify Kernel#load specs so that they pass on 1.8.6-p111
+
+commit b96974693cee75772b09052f8ec7110a000c2429
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Wed Mar 12 14:00:42 2008 -0700
+
+ Fixed specs for wilson's compiler encloser changes
+
+commit 2a21597719bea1ea7db27a552ea6dfb6865963d7
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Wed Mar 12 14:00:06 2008 -0700
+
+ half work on pretty_inspect
+
+commit 6e398ca491b67a6c468798fd92a9764f70bc68a8
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Wed Mar 12 15:18:02 2008 +0800
+
+ Share String#to_a a specs with String#entries
+
+commit 2ff775cbcf2ade4315fbdbb37fa78ee84a1e645a
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Wed Mar 12 11:59:26 2008 +0800
+
+ Add String#to_a specs
+
+commit 4f1204bac224ad28375f06e5fb77156367895156
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Mar 11 19:53:32 2008 -0700
+
+ Spec and implement Array#pack 'v' option
+
+commit 91d51783f44c3a9b1adfe03b7b9fa35476494ce1
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Mar 12 12:45:56 2008 +1100
+
+ Debugger::Output#wrap should handle width of 0
+
+commit 51c316464ad44cadad7ecd997ce45e8392695f4c
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Mar 11 15:26:52 2008 -0700
+
+ Implement support for :postexe nodes (END { some_code })
+
+commit 569dd9f10d5194c22335ce58a678d1f9c73f91d0
+Author: oleg dashevskii <be9@be9.ru>
+Date: Wed Mar 12 03:54:39 2008 +0600
+
+ Import matrix lib with specs (#389 and #400)
+
+ Original patches by Chris Lloyd and matta.
+
+commit 6beb50b7cc2dd3a0f57f3dee45767bb363082159
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Mar 11 13:20:07 2008 -0700
+
+ More Integer#times specs.
+
+commit 746d89d6d55c82f26be08f182301926efd62d362
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Mar 10 15:39:26 2008 -0700
+
+ Correctly set the enclosing class for evaled code.
+
+commit 218cc7fbdd1b5d1c52248e65817752b8a50821ad
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 10 04:46:00 2008 +0100
+
+ Added JRuby speciifc guard to singleton rubyspecs (JRUBY-2239).
+
+commit 25e3f23e78f2b17e02d2c0a058925f8a0ec0d790
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Mon Mar 10 11:25:38 2008 +0100
+
+ Be sure not to close the socket before the Errno.handle call
+
+ Also a small fix for a spec that fails on OpenBSD
+
+commit 9e7fdf3b0040971f7b8402b9cf5422efaedb2f4f
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Mon Mar 10 09:54:16 2008 +0100
+
+ Fix TCPSocket#new spec, BSD systems make a distinction between IPv6/IPv4 localhost
+
+commit e5512b2a7725a67471eba086b107b0f4b1f136b2
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Mon Mar 10 08:35:50 2008 +0100
+
+ Fix for failing unpack_sockaddr_in spec on Linux
+
+commit b9eab2266e5d1f073b6f876710dc9e848fe25b0c
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 23:37:05 2008 +0100
+
+ Remove spec tag for now fixed Hash.allocate
+
+commit b6ba9a757b0531791424df38bce6587a53db6002
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 23:12:16 2008 +0100
+
+ Remove tag for now correct Fixnum#[] spec
+
+commit 6785c2b44da90d95ef77e98cba42a953828b622f
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 23:11:37 2008 +0100
+
+ Fix Fixnum#[] specs
+
+commit 0aa09ce9b7269d54cdef583a2eaf0cb57c32f773
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 23:05:21 2008 +0100
+
+ Removed tags for working Socket specs
+
+commit 18b27b0ebdc3713962771ca75c1321cabee08d61
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 22:48:45 2008 +0100
+
+ Untag now working IPAddr specs
+
+commit f4c0d08bec8fb2db7d130363b0609de7b7720d7e
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 19:56:25 2008 +0100
+
+ Slow IPAddr specs are now fast
+
+commit ff71385a67b2853130e63f9942bcea6ac69d591f
+Author: Eero <ruerue@yawn.kittensoft.org>
+Date: Sun Mar 9 10:35:27 2008 -0400
+
+ Specs for #412. Array#sort and #sort block form calls #<=> on elements.
+
+ * Block form should not expect anything of the elements, all is
+ done through the return value of the block.
+
+commit e6edd1bb4bc52053bdb834d52e31fa185f2a2d62
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 14:51:00 2008 +0100
+
+ Updated tags for IPAddr because of fixed bit operations
+
+commit 4f59fa9bd187822cd836aa046bb8fd40e4412c30
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 14:49:02 2008 +0100
+
+ Fix Fixnum and Bignum shift operations to match MRI
+
+ Added behavior for the edge cases, but took a different
+ approach than the LH tickets. I don't think we should
+ change coercion functions for this.
+
+commit ad8c630662dcb611cd955db08a6f4d53d1dc0dfd
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Mar 9 13:43:38 2008 +0100
+
+ Fix Bignum#& and specs for Fixnum AND, OR and XOR
+
+commit 2529acd5e1cc8e61bd995e00834ee1f6941b1d9d
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Sun Mar 9 14:18:04 2008 +1100
+
+ Fix require_spec and load_spec.
+
+commit 57c7ded8e4d9567aa3c392e8a8262389387ebbfb
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Sun Mar 9 12:25:40 2008 +1100
+
+ Don't spec .rba require behavior in spec/ruby/1.8.
+
+commit ac630b23da01dcc3a1de1bfa06bac4d301a5031b
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Mar 8 17:23:34 2008 -0800
+
+ Better fix for calling to_proc on BlockPass nodes
+
+commit c17b32d44be8452cd867a8212a0fd8bb49c94821
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Mar 8 16:34:02 2008 -0800
+
+ Tag failing Method spec for CI
+
+commit c5d4a3b8f84b7558a5dfedb699a1a3ee4d61f118
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Mar 8 16:26:58 2008 -0800
+
+ Call Proc.__from_block__ on block_pass arguments
+
+commit a63f457821e67d138d9cf1c5ac8b0760cb25bfc2
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Sun Mar 9 10:42:51 2008 +1100
+
+ Remove support for zip rba files, libzip. rake clean required.
+
+commit 142222e41bddd2138d82f349f73dbc0fe2cf3fc2
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Sat Mar 8 16:23:37 2008 -0600
+
+ Adding a spec for Method#to_proc proc used in define_method.
+
+commit b748efa9904baf0be26aa5b7297fc8ba76e46a74
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Mar 8 13:09:44 2008 -0800
+
+ Fix Module#method_defined? and friends for accessors
+
+commit 9b9d8216014c95eb7b4a925e93d0db8e9f5fd308
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Mar 8 10:46:18 2008 +0100
+
+ Adedd a couple of GzipReader#rewind specs.
+
+commit 4612812bde4a2fccbaa72ea54ef76c7d964d216b
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Mar 8 15:49:57 2008 +0100
+
+ Fix the Array#pack specs, network order is the same everywhere
+
+commit a720bba1619deb4358b453f58913d30a1a311b07
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Mar 8 15:27:47 2008 +0100
+
+ Fix Sprintf for positive non decimal notation
+
+ This fix combined with the pack/unpack implementation for
+ type n also fix some IPAddr specs.
+
+commit caef838aca82665d4c2f691e4873e339a9c7238d
+Author: Lachie Cox <lachie@smartbomb.com.au>
+Date: Sat Mar 8 12:47:19 2008 +1100
+
+ updated Array#pack specs to work on big endian machines
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit e3763469a224b4b3668bc1ddef2d982245787646
+Author: Lachie Cox <lachie@smartbomb.com.au>
+Date: Sat Mar 8 12:42:36 2008 +1100
+
+ Added implementation of pack schemes for "n" and added handling of multiple items for "i","s" and "l"
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 41b26c49f5a16377af2c677eb702d665dd062a56
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Sat Mar 8 15:35:10 2008 +1100
+
+ Fix IO#pos EOF spec. Pair: Lincoln, Evan.
+
+commit 1e039fb5c9bcff987769c8644ec47c30aa250952
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Sat Mar 8 14:53:01 2008 +1100
+
+ Fix Zlib::GzipWriter#finish. Pair: Lincoln.
+
+commit 8551da47a01ef24eaf31fac55253fb05fe81cfcd
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Sat Mar 8 14:21:08 2008 +1100
+
+ Add Zlib::GzipReader #eof?, #pos, #read w/length
+
+commit a4dba8317311cc3a51231895b2eaea09daaa61be
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Sat Mar 8 10:41:33 2008 +1100
+
+ Ensure #pos clears internal eof flag
+
+commit 407e1a4191da6ecd59c1347198a60be2556e043b
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Mar 7 17:04:09 2008 -0800
+
+ Tweaks to LookupTable. Converted Errno::Mapping to use LT.
+
+commit eb937c8f1041884e412e3d074387ca9f14bb03ef
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Mar 7 13:48:45 2008 -0800
+
+ Fixed LookupTable#delete. Added LookupTable#entries, #dup.
+
+commit d7d9bfd01180cf2c4fc74d2709f71fc7dd59f2f6
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Mar 7 15:03:14 2008 -0800
+
+ Bandaid fix for failing #autoload specs.
+
+ These need to be properly scoped. However, changing
+ :A to ModuleSpec:A causes a sigbus.
+
+commit aea5cc446cd2c1b0cbd29e606b21b6d5959eb5ee
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Fri Mar 7 16:18:19 2008 -0500
+
+ Add rb_gv_get and rb_gv_set, plus specs.
+
+ Add rb_set_safe_level, rb_secure, and rb_safe_level methods, and specs.
+
+commit cd0b8969487af84a4f40466714dab2d5a1efc224
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Mar 6 17:11:20 2008 -0800
+
+ excluded
+
+commit e40f2bb09d8e3137de2856cb1e9c9438945603dc
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Mar 6 17:11:00 2008 -0800
+
+ More specs to test out const scoping with eval
+
+commit 3926add9039d1af4a60b633ef8805d471f28e02f
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Mar 6 17:01:21 2008 -0800
+
+ Further clarified StringIO#getc specs.
+ They weren't really testing what they were doing.
+ Fixed StringIO#getc. now properly pushes single chars and sets @pos so it can be mixed with puts/write as needed
+
+commit d2d3750c4960d4a6f2a5d2b16b8bae3d598fbe36
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Thu Mar 6 19:16:24 2008 -0500
+
+ Add rb_define_global_function to subtend, with tests
+
+commit 4ab5cc17b70b6569cf9311142d4b278dedfd0a64
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Mar 6 09:53:20 2008 -0800
+
+ Added LookupTable and specs.
+
+commit 1ca8a272137ed7020cb977bf51dd2b7164ccbd7e
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Wed Mar 5 17:28:40 2008 -0600
+
+ TCPServer.new coerces non-integer port to string and uses getservbyname logic.
+
+commit f0c03880972c19d1a12367dc51ed77f69d9ce8ca
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Wed Mar 5 16:44:33 2008 -0600
+
+ Add a couple specs for killing/raising in a thread blocked on accept.
+
+commit 9f80ef157851671727653f46225b99af5d1a259e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Mar 4 21:26:33 2008 +0100
+
+ Proper spec for %u with negative bignums and comments on MRI behavior.
+
+commit 3f9c36081c9b62bcde40206e64afdc2ac088bee8
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Mar 4 19:09:56 2008 +0100
+
+ Update tags for fixed File#chmod specs
+
+commit 735e818c38f8cefe0cd90514dac5282845a67dd4
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Mar 4 15:13:23 2008 +0100
+
+ Improve testing of coercion in File#chmod specs
+
+commit 77a717f5962b2965ad9146e16cb36bedac891c80
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Mar 3 18:16:04 2008 +0100
+
+ Adjusted syslog specs to better handle impls that don't provide syslog.
+
+ For example, JRuby does not provide syslog (yet).
+
+commit 605bdc53e9dd4fb95dae6557d9ee6f9e2b8ceb80
+Author: David Whittington <djwhitt@gmail.com>
+Date: Mon Mar 3 08:44:33 2008 +0000
+
+ Modified Bignum threshold specs to take into account platform wordsize
+
+commit 0af27d11d7dd68cfe49985dc4588933cc41f4fc8
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Mar 2 16:40:15 2008 -0500
+
+ Tag headius's new to_proc spec as failing
+
+commit b1caeeac673451a960917bb699a20e74cf488432
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Mar 2 13:30:35 2008 +0100
+
+ Adjusted Kernel#catch test a bit, to make it more generic.
+
+commit 60f9544ade9d6e71fe3e423ab82cc87838478032
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Sun Mar 2 04:36:53 2008 -0600
+
+ Add a spec for #363, & not coercing using to_proc.
+
+commit 70aa320f7f5bc75ed95362b0fb6d724e64224a88
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Mar 1 17:17:55 2008 -0500
+
+ Tweak new Marshal spec to pass on MatzRuby
+
+commit 35476e1bde23de26c01df409b750e91ef981fefc
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Mar 1 17:11:53 2008 -0500
+
+ Tag new failing Marshal spec
+
+commit d9f83819f1ed2505740ae0737199fecab29809bb
+Author: Jared Luxenberg <jared@jaredlux.com>
+Date: Sat Mar 1 16:20:18 2008 -0500
+
+ Added specs for marshalling subclasses of Hash with init parameters
+
+ Test that Marshal.dump gives correct output for such an object (passes)
+ Test that Marshal.load is able to deal such an object (fails)
+
+commit 6039a3bd457c5d3dc99f5935999da574d17f1e5d
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Mar 1 16:20:08 2008 -0500
+
+ Tweak Process.setrlimit spec for odd Linux platforms
+
+commit 25cfa6a96315ee203d06381ee3ddb76b60023360
+Author: Chuck Remes <cremes.devlist@mac.com>
+Date: Sat Mar 1 10:24:55 2008 -0600
+
+ Fixes a race condition on OSX when "find"-ing character devices
+
+ - on OSX the spec fixture would return /dev/fd/0 as a character
+ device when run from the command line. This always succeeded.
+ When run as a subprocess (like from cron or rubuildius'
+ IO#popen) then OSX uses /dev/fd/0 and /dev/fd/2 for capturing
+ stdin, stdout, stderr and others in that environment. While
+ the fixture would "find" /dev/fd/2 as a character device, by
+ the time the assertion tested it the underlying OS would change
+ it to another device type causing the assertion to fail. This
+ is just bad luck. We now grab the #last device found rather
+ than the first.
+
+commit b6e95321df023ac989c4e5bb926ec55493260bc9
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 29 16:04:10 2008 +0100
+
+ New rubyspecs for IO#ungetc.
+
+commit 9bd2f0740c71d426cfa3c3636c2451762f640c14
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Feb 28 21:59:35 2008 -0800
+
+ Specs for Hash.allocate. Fix awaits replacing Hash with LookupTable in core.
+
+commit c1d979639bfc19072351211815ffd5c8da772dcd
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Feb 28 21:56:33 2008 -0800
+
+ Specs and fixes for Module.allocate.
+
+commit 904fd6136f00bab5fec62e8e702a0508dec44bac
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Feb 28 19:45:39 2008 -0800
+
+ Specs and fixes for Array.allocate.
+
+commit 776a24f0d14bbb5127c804cf0579960335c1a049
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Feb 28 19:35:55 2008 -0800
+
+ Specs for String.allocate and fixes to make them pass.
+
+commit fa35211f357ff1b9660a318c12b86ca156c5f26d
+Author: Ari Brown <ari@aribrown.com>
+Date: Thu Feb 28 20:27:55 2008 -0500
+
+ Moved stdlib/syslog.rb to lib/syslog.rb . it works!
+
+ * everything runs! yay!
+
+commit 8f103a6f9d7a168e37d1063e40bee960d64fc609
+Author: Ari Brown <ari@aribrown.com>
+Date: Thu Feb 28 19:42:11 2008 -0500
+
+ Added specs and the constant module for stdlib/syslog.rb
+
+ * added some specs for that which is testable
+ * fixed the constant module so the constants are defined
+ * fixed 'undefined method' problem in #write (private)
+
+commit 0c89dc90fdcb7933169e23462197d59f9627f510
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Feb 28 14:31:05 2008 -0800
+
+ Added basic throw/catch specs. Fixed raised NameError to contain the name
+
+commit c8f4db4270984b60a087dd423c9e0da3e3760622
+Author: Phil Hagelberg <phil@hagelb.org>
+Date: Thu Feb 28 14:11:30 2008 -0800
+
+ tag failing proc spec
+
+commit a1591319696385191f3301516d2f8265cd8fedcb
+Merge: f167f8f... 3f1acce...
+Author: Phil Hagelberg <phil@hagelb.org>
+Date: Thu Feb 28 13:43:52 2008 -0800
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit f167f8f6f7f3a1b8804a5452643236a23c0ce4c4
+Author: Phil Hagelberg <phil@hagelb.org>
+Date: Thu Feb 28 13:43:40 2008 -0800
+
+ failing spec for returning from procs
+
+commit 3f1acce781c0dcf43698441036a085a0cef02d29
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Feb 28 16:14:55 2008 -0500
+
+ Basic support for UNIXSocket and UNIXServer
+ Fix some 'Errno' typos in socket.rb
+
+commit afbf38613364436630933753d99ee94c03b85074
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Feb 28 21:34:10 2008 +0100
+
+ Added specs for File.fnmatch with case-sensitive brackets.
+
+commit 28323bda3d1f3295371b6ea99ed8ba6ee15661bb
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Feb 28 20:47:51 2008 +0100
+
+ Added specs for File.fnmatch with '**/' patterns.
+
+commit 893ff4729d024198d5b423cc4426153f49cb5ebe
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Feb 28 11:30:49 2008 -0800
+
+ Fixed lookup of class variables defined in metaclasses.
+
+commit dee531b18d96199d608d8e2e8e27f54ef500a716
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 27 21:47:13 2008 -0800
+
+ Additional Symbol#inspect specs. Another try at making them pass.
+
+commit 3bfb705b709ab35593684a68b35fb0ee8e1e01d7
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 27 21:46:37 2008 -0800
+
+ Silence 'woot' echo on ubuntu from #system specs.
+
+commit 7fb76f2c4a9fb0c5695a38b90150ea6f50097237
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Wed Feb 27 18:05:48 2008 -0800
+
+ Fixed Symbol#inspect from over quoting
+
+commit 4ac32e4c9d0ff55aad50a00944f1a64931cfd1c6
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Wed Feb 27 17:18:09 2008 -0800
+
+ Added some pretty rude specs for Kernel#system and got them to pass.
+ Fixed a wierd problem with system/exec not cleaning up the fork process right
+
+commit 73be3b88af1ac96a6d4afabddd2871cfc4691eec
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 27 15:36:17 2008 -0800
+
+ Fix String to properly initialize backing store when subclassed.
+
+commit 5ab2f9e594b7e66a04028e60f3517488e345f508
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 27 15:04:09 2008 -0800
+
+ Scope classes used in String specs.
+
+commit e45d58100850443fedada905f654bae3f4144790
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Wed Feb 27 17:04:58 2008 -0600
+
+ Add /devices to find commands; Solaris uses /devices instead of /dev.
+
+commit 1403477197873d613cfb93d644f78b4067d180d3
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 27 20:21:48 2008 +0100
+
+ Adjusted Env spec, to be able to run it on Solaris.
+
+ grep is replaced by egrep, since older greps don't
+ take -e parameter (like on Solaris).
+
+commit b239a3b615d341f982a7a4a3a1b1200d95f79684
+Author: Adam Shelly <adam.shelly@gmail.com>
+Date: Wed Feb 27 04:09:24 2008 -0500
+
+ Amending specs for Array#pack('U')
+
+ * rbx is now passing most specs
+ * failing specs are due to String#unpack.
+
+ Signed-off-by: Brian Ford <bford@engineyard.com>
+
+commit 328c40e0f24601e739f404ab252652deca477513
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 27 02:46:21 2008 -0800
+
+ Fixed Array instantiation to work with subclasses.
+
+commit 96c4ea885fbd075765b9d234de2754df3c857b07
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Feb 27 09:26:25 2008 +1100
+
+ Move Debugger::Output specs to match new location of class
+
+commit c59f16f34f47860b200c6de4a2c1144c566de3dd
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Feb 26 10:23:14 2008 -0800
+
+ Exclude new failing Array specs.
+
+commit 27248a45f079fd5a8cdb9ee71d008d135dcbe63d
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Tue Feb 26 00:10:29 2008 -0600
+
+ Add additional Array tests from BFTS.
+
+commit a0e156f4c5bc12bf39950afeb58a6962b37efaa7
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Feb 26 16:53:01 2008 +1100
+
+ Fix Debugger help output formatting to use wrapping
+
+commit fa5304d42c72a07b09cece99cb22c90f6b399a51
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Feb 26 13:22:31 2008 +1100
+
+ Add wrapping to debugger column output
+
+commit 1a5d830b41eef37bb78168c959dd5b2f0757fde4
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 25 18:58:11 2008 -0800
+
+ Conform Bignum#div, #divmod to weird MRI maths.
+
+commit eb5c6e367990bfdd193bcdf3055009f3e3e1aeaf
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Feb 26 13:23:29 2008 +1100
+
+ Fix Debugger specs to pass on ci
+
+commit a2feff6782a052a9b71da90e9d4e1b2d991cc598
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Feb 25 18:53:24 2008 -0500
+
+ Patch by Jos Backus (josb) - Closes ticket 364 (FreeBSD warnings)
+
+commit cee08883cc3de2e41a88b506f7d7f8d40697eaa2
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Mon Feb 25 13:20:21 2008 -0800
+
+ Fixed autotest churn by removing empty.txt and moving to /tmp
+
+commit f26bb0c4e3b8435a853a9f4843173748d98075fd
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 25 11:25:10 2008 -0800
+
+ Add the rest of spec/* directories to CI process.
+
+commit 29f36833e79de6115c27d744adf158e1b3ba42f0
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 25 00:29:45 2008 -0800
+
+ Excludes for spec/kernel, spec/debugger to run with CI.
+
+commit 12bbdf70af31d5168c2df0a9b53651f94b36899d
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 25 00:22:13 2008 -0800
+
+ Excludes for subtend specs so they will run with CI.
+
+commit 0cbc2b1f20d8aee7ea74eb14e1f9cf242f8b47d5
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 24 23:57:56 2008 -0800
+
+ Remove specs for removed Compression::ZLib.
+
+commit 1b4fbc76c2eb84e5cb45562f54ac105784f9e134
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 24 23:49:57 2008 -0800
+
+ Conform Ar specs.
+
+commit f8e62002711c3cfd8024faca497775f7253a326a
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Mon Feb 25 05:24:54 2008 +0100
+
+ Add a second case for truncating IO buffers that specifies too-small size.
+
+commit 9f3e25289cc52cd3f3fb240de1ad82a16a8b135c
+Author: Nikolai Lugovoi <meadow.nnick@gmail.com>
+Date: Tue Feb 12 23:19:27 2008 +0200
+
+ Fixes for String#to_sub_replacement:
+
+ * removed String#replace_slashes
+ * using plain byte-by-byte scan instead of regexps to detect and handle backslash escapes
+ * better handle unknown escapes and cases like '\\\1'
+ * updated specs for String#sub
+
+ Signed-off-by: Brian Ford <bford@engineyard.com>
+
+commit d87df0b7634ae37f85fc8f2795e4c8c425614b11
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Mon Feb 25 02:57:27 2008 +0100
+
+ Add a spec for Enumerable#inject with a *arg; JRUBY-2162 exposed it.
+
+commit f04fcabf8c064dfcbf3b118bdc83289da169a30c
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Feb 24 21:24:51 2008 +0100
+
+ truncate behaves different on OpenBSD, changed specs according to MRI behavior
+
+commit b74a2f45b32a02469d61d4ace04912ec25f19543
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Feb 24 20:18:02 2008 +0100
+
+ Looks like Darwin does provide Process::RLIMIT_AS
+
+commit 7113973abff64eeb1304b15be46f07d301d84f3f
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Feb 24 18:25:55 2008 +0100
+
+ OpenBSD doesn't provide Process::RLIMIT_AS, so this spec should be excluded
+
+commit 49b72719bf5c732f4aa2ad0d70e5a224556fb471
+Author: oleg dashevskii <be9@be9.ru>
+Date: Sun Feb 24 11:04:07 2008 +0600
+
+ Spec for method taking lambda and block.
+
+ * should raise SyntaxError
+ * passes on MRI
+ * fails on rubinius
+
+ Signed-off-by: oleg dashevskii <be9@be9.ru>
+
+commit 60bbc8506d70571249972dbf124df520f0a4a476
+Author: Chuck Remes <cremes.devlist@mac.com>
+Date: Sat Feb 23 10:23:09 2008 -0600
+
+ Fix unpack_spec expectation for little-endian byte ordering
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 17e45cee97057684e6c24608f97de48c28947384
+Author: Chuck Remes <cremes.devlist@mac.com>
+Date: Sat Feb 23 09:44:37 2008 -0600
+
+ Fix unpack to use native host byte order for formats /ILQS/
+
+ - unpack_spec had a bad expectation on little-endian platforms
+ - unpack_spec got some updated description strings to correctly identify
+ the host byte ordering expected in the spec
+ - kernel/core/string.rb now unpacks formats /ILQS/ in the platform's native byte
+ ordering
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 1540cb7caa0f200ed6d318971fb7302cd089e27d
+Author: Chuck Remes <cremes.devlist@mac.com>
+Date: Sat Feb 23 08:10:00 2008 -0600
+
+ Add some missing endian guards to the unpack_spec
+
+ - in my haste, forgot one set of guards around some specs
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 8488676fc0dac5db5d01dd92e061476226d58bd1
+Author: Chuck Remes <cremes.devlist@mac.com>
+Date: Sat Feb 23 00:19:33 2008 -0600
+
+ Fix several Array#pack and String#unpack bugs related to byte ordering (endiannes)
+
+ - added a small utility method endian? to the kernel module; determines host byte
+ ordering by taking a symbol (:big, :little) and comparing it to Rubinius::ENDIAN
+ - modified Array#pack to check for the native byte ordering for /ils/i formats
+ - modified String#unpack to use native byte ordering for /DdFfIiLlQqSs/ formats
+ - modified String#extract_number to do special processing for big-endian platforms
+ and for formats using native byte ordering on a big-endian platform
+ - added little_endian and big_endian guards around several String#unpack specs;
+ now passes running against MRI and rbx
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit f8146d29bfdf67349f3f9c0c7105ce595981255f
+Author: Gianluigi Spagnuolo <glgspg@gmail.com>
+Date: Sat Feb 23 12:44:25 2008 +0100
+
+ Added some test to Regexp.quote to manage tab and white space
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 714efa8574687e1fd31f904a4f35cce8056719f5
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Feb 23 00:01:38 2008 -0800
+
+ Fixed Digest specs to pass with RSpec.
+
+commit a0fe2f7fa080729b77b32ffe21be5705a162ed71
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 22 22:26:52 2008 -0800
+
+ Remove ffi_decode_sockaddr, replace with existing ruby code.
+
+commit b2baf0911e4a88ba2f6c4cb8e3e31d2a3aa1c6bf
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 22 17:06:18 2008 -0800
+
+ Move Ar to kernel/core.
+
+commit 01baf002a8c7bd6e249b9477c1f78e6b99a67bf6
+Author: Philipp Bruschweiler <blei42@gmail.com>
+Date: Wed Jan 16 00:11:12 2008 +0100
+
+ added specs for SHA256/384/512
+
+ these specs were as well shamelessly copied from the md5 specs.
+ they work, but every sha* class has a folder for itsself, that's a
+ lot of duplicatd code. maybe someone with more experience in
+ writing specs should have a look at this.
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 924224fcf655da90148ebd8234033a71e1b23090
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Fri Feb 22 17:13:14 2008 -0500
+
+ Catch no block given in rb_yield, raise LocalJumpError
+
+ As well, define that as an exception for subtend
+
+ Update spec
+
+commit 3748843421832df5b842a677ddd2e55fbefb0b5f
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Fri Feb 22 17:04:33 2008 -0500
+
+ Update rb_yield spec
+
+commit f60ca442b1466f29432995700457e8b34f4ff294
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Fri Feb 22 17:00:36 2008 -0500
+
+ Fix rb_yield call
+
+commit a75afc4595fd20d7853ff65afe015de88b265b93
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Fri Feb 22 16:48:17 2008 -0500
+
+ Add blocks to subtend methods, as they should be able to access them like any other method.
+
+ Also, update the spec
+
+commit d9911f8b00243f3c95759612dde35edf6edaa678
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Thu Jan 31 13:54:24 2008 -0500
+
+ Add block specs and rb_block_given_p
+
+commit b6c806f0d8213c4751c69638174f60b80f9ba303
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Feb 22 15:31:58 2008 -0500
+
+ Failing spec and exclude for left-to-right masgn evaluation order
+
+commit 8f9e3c9e5e7dfc535e8fe6b10b945587586651ec
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Feb 22 13:59:44 2008 +0100
+
+ Fix Socket#getservbyname, not every platform defines http/udp
+
+commit f29ff3bcaf0bf83d2924d08ea5f6c0bbb5df9948
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Thu Feb 21 16:47:02 2008 -0800
+
+ Allow Ar to create archives
+
+commit e50ec6470dfc905198065a98b65b33a99da60e15
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Feb 21 20:20:41 2008 -0500
+
+ Some compiler specs for 'defined?' handling
+
+commit ba5a0d87182d83000205e1202f5c473568a50489
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Feb 22 01:08:51 2008 +0100
+
+ Fixed #332 and cleaned up Time a bit. Thanks to gls
+
+commit edf1e0d530ebb39a1b46d0fa518b9ca85db544da
+Author: Evan Phoenix <ephoenix@engineyard.com>
+Date: Thu Feb 21 02:01:21 2008 -0800
+
+ Fix the last usage of block return (ie, internal long return).
+
+ * LongReturnException is now used whenever a block requests that
+ it's home context should return.
+
+commit 83ed7161701202d48490e7f38b568bc504f9690f
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 23:59:47 2008 -0800
+
+ Added little/big_endian guards to Array#pack and String#unpack specs.
+
+commit 65b4ed86002371f2b56759aadc61e61c1cbbdba4
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Feb 20 22:49:19 2008 -0800
+
+ Exclude Socket#unpack_sockaddr_in spec. See tag comment.
+
+commit 9fbda05c4dffb964a9f10e26d62240fbd52200a0
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Feb 20 22:48:31 2008 -0800
+
+ Exclude super slow IPAddr specs.
+
+commit 3d39fb35dcd3c28fa626aeb96057b927c6bfe7c9
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 18:54:50 2008 -0800
+
+ Redo expectation in Socket#getaddrinfo spec.
+
+commit 69576ede38d9bf09d1afd0120726ca756a0aa7cf
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 18:31:27 2008 -0800
+
+ Account for variable length array in Socket#getaddrinfo.
+
+commit f396bd718572d9402d0d7eeb8da02474914396a8
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 17:59:29 2008 -0800
+
+ Use File.delete in YAML specs instead of rm.
+
+commit 7698ec3855ce572f1e10962596804b82f3cd6534
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu Feb 14 10:07:48 2008 +1100
+
+ Hook-up new StepBreakpoint to new debugger step commands
+
+ * The commands step and stepi have now been added to the
+ debugger, and step into called methods.
+ * The commands next, nexti and out have been converted
+ to use the new StepBreakpoint. The legacy versions
+ remain, but have been renamed as ln, lni, and lo; these
+ will be removed once the new commands have proven stable.
+ * Replaced VM method cache command with VM send site command
+ to show details of SendSites in the current method.
+
+commit f192d65ec5eb31b4a807b9c3eb7360b84739d9f2
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu Jan 31 16:43:19 2008 +1100
+
+ Initial implementation of StepBreakpoint
+
+ StepBreakpoint class moves step logic out of the Debugger
+ and into breakpoint, where it more logically belongs.
+
+commit fd0ff43d2d384e221ff8de611843f3406d192657
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 17:04:46 2008 -0800
+
+ Fixed YAML spec to pass MRI. Added fails tag for rbx.
+
+commit d69834a5217ddc6667b495fbe7d4dd8ad413ba88
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Feb 20 15:42:25 2008 -0500
+
+ Fix dead code in TCPSocket.new specs
+
+commit 4644222e63046783933ca9b2e4514e3ff21fbb57
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 12:31:14 2008 -0800
+
+ Add missing tag file for method_spec.
+
+commit 230d5d506f4203bcd3922880fae506fa480e6308
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 12:17:13 2008 -0800
+
+ Fix typo in socket specs.
+
+commit a5d49537832a9cc33b07cade265af0834f123533
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 12:09:11 2008 -0800
+
+ Move specs for calling methods to language/method_spec.rb.
+
+commit ead32a1f2820a4e2fcc906a8e7f3603490ba901c
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 11:53:45 2008 -0800
+
+ Use bignum_value where a Bignum is intended in the specs.
+
+commit 1021345337bca1f928879713cb84a76b9c7935a1
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 10:21:42 2008 -0800
+
+ Removed unused require 'stringio' from io/syswrite specs.
+
+commit cfd51af482321b4d672d69569de185f582a21831
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 09:00:36 2008 -0800
+
+ Symbols as Fixnums is long deprecated. We don't spec it.
+
+commit a8bd2a1aba97653625a9b568d1a7112b5fce45f6
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 00:15:54 2008 -0800
+
+ RbYAML is not in Ruby standard lib. Move specs for it to spec/library/rbyaml.
+
+commit 56b454af2ded18d0459bc974efa666ccf3b8de0f
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 20 00:10:24 2008 -0800
+
+ Restrict specs in spec/ruby/1.8 to current stable 1.8 version.
+
+commit 22e01d1914db92d159ee15d3cf73c9d6e9d0a24b
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Feb 19 23:20:27 2008 -0800
+
+ Fix Dir#pos=/#seek specs. We shouldn't spec undefined platform behavior.
+
+commit d522af83d0cfcdf39932afff7ba7d75d77dd0453
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 20 11:51:44 2008 +0100
+
+ New IO.read specs.
+
+commit 77fdbe404e31f44e1c302eb99a7ff129523183ce
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Feb 19 16:14:43 2008 -0800
+
+ Add library to read/write ar(5) files
+
+commit d7702f979732de90358dc35d795c6ac621f815bc
+Author: Matthijs Langenberg <mlangenberg@gmail.com>
+Date: Mon Feb 18 18:04:27 2008 +0100
+
+ writen some examples for Base64 module
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 33b189478c05bd687ac8b062cd5307a3290d8931
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Feb 19 00:27:51 2008 -0800
+
+ Convert platform guard :size option to :wordsize.
+
+commit cbcdb8346a2c75ba65910b486cee718cd3aa5175
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Feb 18 23:07:41 2008 -0800
+
+ Exclude TCPSocket.new for now, hangs on ubuntu gutsy.
+
+commit ec990b6ebcd35cbf9dc192852f37e184c3e4079b
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Feb 19 15:55:25 2008 +1100
+
+ Re-enable debug on context change
+
+ The cpu_yield_debugger_check was not being performed as
+ a result of changes to method dispatch related to the
+ implementation of SendSite.
+
+commit aa585b7e637e2fd873602ee6725256429f413582
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 18 18:59:18 2008 -0800
+
+ Removed :version guarded specs that are not current stable.
+
+commit 431af5920a0a02dfca927961a2d6457ae5f050e2
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 18 17:40:56 2008 -0800
+
+ Added new tags files for excludes.
+
+commit 10dd37903533cac9a6f77ead70f3aa9ee1dc9098
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 18 16:38:58 2008 -0800
+
+ Removed deprecated $deferr from getoptlong.rb. Moved to /lib.
+
+ Small fixes to other library specs to get them running under CI.
+
+commit ee2dabf771a5e6d8d70c47fa49b1298d2d002c8c
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 18 00:42:54 2008 -0800
+
+ Use the spec guards properly.
+
+commit 91d6c64be8827768ba2e39b80a4eb81b9affc122
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 17 22:40:21 2008 -0800
+
+ Deprecate #setup, #teardown in specs; use #before, #after.
+
+commit 6ba49012504c08973e1fb2fd1b9fce75c351d148
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 17 22:00:56 2008 -0800
+
+ The #fails_on guard has been removed. Use #ruby_bug or tagged excludes.
+
+commit e24231f5c62c0b73768c7503f50b53e8ffc345d1
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 17 21:08:01 2008 -0800
+
+ Renamed *_excludes.txt to *_tags.txt for specs.
+
+commit a1c707b517e13115692173bc2048309e74c00915
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 17 20:45:14 2008 -0800
+
+ Hand merge recent excludes changes to spec/tags directory.
+
+commit 838bee7e99bb1179c9a3a7782dcab9c2b904e72e
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 17 00:17:51 2008 -0800
+
+ Moved excludes from spec/data to spec/tags. Added "fails" tags.
+
+commit 8ad91b03788d89ccd12fbcf19c06c9ef4f0cfee8
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 4 19:19:00 2008 -0800
+
+ Misc fixes to get MSpec running specs.
+
+commit a683dd75786ab6c6a255c9bac399dc6be7aaa4b5
+Author: Tyler McMullen <tbmcmullen@gmail.com>
+Date: Sat Feb 16 23:39:38 2008 -0500
+
+ Add support for H and h to Array#pack.
+
+ * Updated array/pack_spec with specs for H and h, separately
+ * Updated Array#pack to handle both with a single block of code
+
+ Signed-off-by: Brian Ford <bford@engineyard.com>
+
+commit b1d3ba9d10f6a9ea87d8cb9be21d0d432e973117
+Author: oleg dashevskii <be9@be9.ru>
+Date: Mon Feb 18 01:18:24 2008 +0600
+
+ Update specs for calling methods.
+
+ Nasty binding stuff (first noted in #293) got specced and put into excludes.
+
+commit 02225daa5cef4fa3f48cac73d4bf0f9d02f3ebe0
+Author: oleg dashevskii <be9@be9.ru>
+Date: Sun Feb 17 23:20:08 2008 +0600
+
+ Cross-breed and update for, while & until language specs. Little fix for hash spec.
+
+ The compiler drops out on "for @@var in 1..3", so this is commented out.
+ Variable scope stuff arrived into excludes.
+
+commit f43383a150131278d30535196e8da4e60dff97b1
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Feb 17 13:10:55 2008 +0100
+
+ New specs for RangeExceptions out of Fixnum and Array methods.
+
+commit 7d1c744d9c1ae50376be406a28e383a04ca6b4fc
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Feb 16 13:49:11 2008 +0100
+
+ Corrected copy-paste error in recent fixnum specs.
+
+commit 08982321472008f7645212289d2624d19053ed7e
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 15 21:18:53 2008 -0800
+
+ Fix IO#read for large files and small parts of files.
+
+ Fix IO#read with buffer.
+
+ Fix IO#eof? when buffer reaches eof.
+
+commit 1d07588d61b3835a6165c5de1f731277812cff79
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 15 19:11:42 2008 -0800
+
+ Add missing spec for IO#eof? and fix.
+
+commit e0a6c8e179e48b423b6eb142b27460cd86d0223b
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 15 17:50:47 2008 -0800
+
+ (Last change was ok). Force check for data so #eof? works
+
+commit d7e67c257c213f9e25b3123ce85576feb71a0089
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 15 17:28:48 2008 -0800
+
+ Revert "Force a check for more data on the IO for IO#eof?"
+
+ This reverts commit 3d4427e802756678608bf9840ba6f26fc81cf7fe.
+
+commit 4c1182c184bb6c2c97c5fc8ce83f242fe5f5144b
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 15 17:26:08 2008 -0800
+
+ Force a check for more data on the IO for IO#eof?
+
+commit 94466db3347889850feb25dd7c83883df21bac92
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Feb 15 14:13:29 2008 -0800
+
+ Added Float examples to Bignum bitwise operator specs.
+
+commit 3a668451d3bcc46b162a69ce1f8ec5d6a98b2d22
+Author: Brian Ford <bford@engineyard.com>
+Date: Fri Feb 15 13:44:24 2008 -0800
+
+ Added bignum_value helper. Added specs for Fixnum bitwise operators.
+
+commit 217eb67a4c2f0bf1222628abfecfadbede5fb3b8
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Feb 15 21:09:43 2008 +0100
+
+ Fix process specs for FreeBSD
+
+commit f25e0e130110ebbef0b5bc0c28c9b08db6c73a1f
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Feb 15 13:18:40 2008 +0100
+
+ Removed now working exclude for Array#sort
+
+commit 56af7be26dcc9b7270de6d96e73e09a4f17cc710
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Feb 14 20:48:37 2008 -0500
+
+ Improved Array#sort, #sort! specs.
+
+commit 714ea4b5245172cc6d5c815ef7399d1a991dd83f
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Feb 13 10:30:22 2008 -0500
+
+ Improved Array#sort specs a bit.
+
+commit 8944e873848c610182405c2de466e41e6260573d
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Feb 13 02:34:37 2008 -0500
+
+ Tuple#swap specs.
+
+commit 24199f731dba40b72af6d121121dec9f085f890d
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Feb 14 20:03:16 2008 +0100
+
+ New rubyspecs for IO#reopen.
+
+commit 4f70320e5b7089c74b3899216763cd37d8854230
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Feb 14 17:27:32 2008 +0100
+
+ Removed JRuby-specific guards. Please don't use guards to hide bugs.
+
+ Guards to be used only when it is agreed that the JRuby behavior
+ is intentionally differs from MRI. For plain bugs, guards should
+ not be used. Instead, we maintain spec exclusions in JRuby repository.
+
+commit 0198a11b3bdf60983846a6c722dfa11d1b9f57bb
+Merge: ef3393e... 1f1e32e...
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 15:57:57 2008 +0100
+
+ Merge branch 'mutle_file_specs_refactoring'
+
+commit 1f1e32e5e1fd12fb323e2a74a7f5caae96aa867b
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 15:18:14 2008 +0100
+
+ Specs for File#chown #flock and #truncate now pass on JRuby
+
+commit 3a8e601d5205e050f83179376d2be3e922e80c20
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu Feb 14 17:25:02 2008 +1100
+
+ Fix context specs to wait for debug listener thread
+
+commit 608d7a99e75d293d6f9786cee940c0dd23156be3
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 12:59:32 2008 +0100
+
+ Adding guards to only run File#chown and File.chown specs as root.
+
+commit b3a1069cf6c18b844b9eced32b7bcdb91ad7c558
+Author: Brian Ford <bford@engineyard.com>
+Date: Thu Feb 14 01:31:47 2008 -0800
+
+ Rework Bignum#==. Change Numeric#== to conform to MRI.
+
+commit 4eb58ebc45b2ee79f01d75fdb3e9104c73ad66e2
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Wed Feb 13 23:56:37 2008 -0800
+
+ Common implementation for Zlib::Inflate and Zlib::Deflate.
+
+commit 1804fdacce5c195a90befe502706d1f1e066e886
+Author: Brian Ford <bford@engineyard.com>
+Date: Wed Feb 13 19:31:20 2008 -0800
+
+ Port of JRuby's File.fnmatch to Ruby (yeah, like writing Java in Ruby).
+
+commit 1a78da8438535ee8ed231359bdb15ff3624c6b37
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 01:27:52 2008 +0100
+
+ Adding File#truncate improvements from #325 and #326
+
+commit 5b62acbdcf0aab2e89be5ac3e12859ae36cd6950
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 00:47:53 2008 +0100
+
+ Adding File#truncate with specs
+
+commit 1a2b3dde4f67abe0936e7ec6fb749e5bb8fda7d2
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 00:36:32 2008 +0100
+
+ Adding File#chown with specs
+
+commit e132cd6f11285f0e106a5d2a292e23c8375fa1ee
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 00:12:31 2008 +0100
+
+ Renamed File#flock spec to properly reflect an instance method
+
+commit 00cd22ccdf2b70fa53693000d4a5bb803c7d6df6
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Thu Feb 14 00:07:05 2008 +0100
+
+ Adding File::flock with specs
+
+commit 3c9b3e4e4272889dd26ec9ddb25f7aaf88c6c380
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Wed Feb 13 23:25:30 2008 +0100
+
+ Adding File::chown with specs
+
+ * The spec works fine on OS X, but was not tested anywhere else
+
+commit c894a6c46b4a3d0b9010020c394d3ba366bf145e
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Feb 13 11:59:38 2008 +0100
+
+ Module#undef_method should accept string parameter, not only symbols by Nikolai Lugovoi (#321)
+
+commit c968d5c29cc3126c789cf5bb2005bd9637e85312
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Feb 13 11:52:10 2008 +0100
+
+ Update excludes for File#truncate
+
+commit 408e69864546aea061e006073bb452b8db8c4610
+Author: Ragnar Dahlén <r.dahlen@gmail.com>
+Date: Wed Feb 13 11:15:31 2008 +0100
+
+ Implement File.truncate, passes specs.
+
+ * Adds truncate, ftruncate (not used yet) to posix.rb
+
+ Only tested on Mac OS X 10.5.1.
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit 5c75721d5a78e25a77e9f068bf4c95e729604959
+Author: oleg dashevskii <be9@be9.ru>
+Date: Wed Feb 13 11:26:34 2008 +0600
+
+ Remove tests that have been superseded by precedence_spec.
+
+commit 83a372674786a0be51a206cadcae644d72a1e8d2
+Author: oleg dashevskii <be9@be9.ru>
+Date: Wed Feb 13 11:05:34 2008 +0600
+
+ Made a real precedence_spec.
+
+ One test still commented out till the bug with flip2 is fixed.
+
+commit c3988a4a906594c050e058add8aa6996870dc115
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Feb 13 02:10:49 2008 +0100
+
+ Remove excludes for File#stats specs
+
+commit 1624b463d0f70a27b6772d90626c94b6eed4e5c4
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Feb 12 18:25:05 2008 -0500
+
+ Add specs for pass subclasses of Module to 'include'
+
+commit 64b0fb4131276feda0d0ab13301824b20f8d7f8e
+Author: oleg dashevskii <be9@be9.ru>
+Date: Wed Feb 13 00:49:37 2008 +0600
+
+ Make Dir.chdir spec work when /home is symlinked to /usr/home.
+
+commit 8cbf6312df160f30e284a4537039f808a42543fe
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Feb 12 12:30:19 2008 -0500
+
+ Add failing Array#sort spec and matching exclude
+
+commit 9bef807b3b469b8790edbe96f1442394d528cb5a
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Feb 12 12:09:11 2008 -0500
+
+ Move Time#<=> specs around until the descriptions make sense
+
+commit 60fbbc62cb04b2fddcd406f01f906482fbc84370
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Feb 12 05:33:49 2008 +0100
+
+ Mark JRuby as not deviating from MRI on unboundmethod specs.
+
+commit 4e6d8f7e3326f937a6916ed11984172670a71094
+Author: Yehuda Katz <ephoenix@engineyard.com>
+Date: Mon Feb 11 23:26:31 2008 -0800
+
+ Zlib.adler32
+
+commit 2f2d10e1aa57bae79f7fcda5e5a30b2a2ef3e37c
+Author: Yehuda Katz <ephoenix@engineyard.com>
+Date: Mon Feb 11 23:12:40 2008 -0800
+
+ Zlib.crc_table
+
+commit 49b9e4b624074d151e89f078c4080a0a7584abaa
+Author: Yehuda Katz <ephoenix@engineyard.com>
+Date: Mon Feb 11 22:56:52 2008 -0800
+
+ Zlib#crc32
+
+commit 7cb2ebfa008afc96135912ceefdbd81b1cd7e478
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Mon Feb 11 17:36:32 2008 -0800
+
+ Fix class variables for RDoc.
+
+commit 571d837bbeff221daacebc79c1ccab7de15c77f2
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Feb 11 08:54:36 2008 -0800
+
+ Exclude [r]dev_(major|minor) specs. We need some autoconf facilities.
+
+commit fb2bc81d50bf504e3997d009e3c13f841b859803
+Merge: 55a52f1... 9b58a59...
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Mon Feb 11 16:19:02 2008 +0100
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 55a52f18133fc9f92eef64838008a83dfaab3ffc
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Mon Feb 11 16:18:37 2008 +0100
+
+ Removed Math.asinh excludes.
+
+ It wasn't working on OS X. Evan fixed the culprit FFI over the weekend.
+
+commit 9b58a59ca21c6622d246e629410230bfbe8cd4ce
+Author: makoto kuwata <kwa@kuwata-lab.com>
+Date: Mon Feb 11 21:24:05 2008 +0900
+
+ Modified to address differences of SyntaxError class between MRI and Rubinius in 'erb/filename_spec.rb'
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit d1c4280b70b82d6cd541251e3d7e1a3091fb304f
+Author: makoto kuwata <kwa@kuwata-lab.com>
+Date: Mon Feb 11 20:19:12 2008 +0900
+
+ Add 'erb/util/shared/url_encode.rb' which is missed file
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit b4b1114ac7dffabd672d462b5857a7e1957e8f07
+Author: makoto kuwata <kwa@kuwata-lab.com>
+Date: Mon Feb 11 19:10:58 2008 +0900
+
+ Add spec files for erb.rb
+
+ Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
+
+commit dfdf90968e78f14e0755b5f3279ec878034dbdb5
+Author: Yehuda Katz <ephoenix@engineyard.com>
+Date: Mon Feb 11 00:09:23 2008 -0800
+
+ Added singleton specs (and reorganized stale one):
+ * Singleton#_dump
+ * Singleton._load
+ * Singleton#instance
+ * Singleton.instantiate?
+ * Singleton.new and Singleton.allocate
+ * Singleton#dup and Singleton#clone
+
+commit 54c4a4cab187be4328d6a810bae4bc4bd01ca1d8
+Author: Brian Ford <bford@engineyard.com>
+Date: Sun Feb 10 20:19:30 2008 -0800
+
+ Additional specs for File::Stat#rdev, #rdev_major, #rdev_minor.
+
+commit 6b2f05af4758c488b3e2e3b19ee9d2e872817932
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Feb 10 23:00:41 2008 -0500
+
+ Rubinius now passes all 'super' specs
+
+commit 5be84fce241c67bd8439bccbe54cec575b0ea93a
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Feb 10 22:53:11 2008 -0500
+
+ Failing spec for 'super' behavior
+
+commit 975d51e80d3df437eaa8ddd3c3384a5766255b12
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Feb 9 15:18:37 2008 -0800
+
+ Exclude Process constants spec until LFS is fixed on 32bit linux.
+
+commit 236def62bcfa3dca75a6eebf378a68235c4613ed
+Author: Yehuda Katz <ephoenix@engineyard.com>
+Date: Sat Feb 9 17:04:59 2008 -0500
+
+ Fixes exclude
+
+commit 26bedb481b45e77434b487c6395903c6110ef99e
+Author: Yehuda Katz <ephoenix@engineyard.com>
+Date: Sat Feb 9 16:01:58 2008 -0500
+
+ Moved bad variables spec out
+
+commit 87efbf9036e5c524e1b40481c89107538d574ba8
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Feb 9 11:26:30 2008 -0800
+
+ Revert all File::Stat stuff. We'll fix Dir first.
+
+commit 1f5bc0f98a23fc90b9bd00048af1551df8e534f7
+Author: Brian Ford <bford@engineyard.com>
+Date: Sat Feb 9 00:39:20 2008 -0800
+
+ Reduced File::Stat.stat primitive further. Details follow.
+
+ * Added ffi_major and ffi_minor to calculate the major, minor
+ parts of st_dev and st_rdev.
+ * Added (temporary) new primitive basic_stat to change the
+ return type from a tuple to a single MemoryPointer instance.
+ * Added simple specs for rdev, rdev_major, rdev_minor, nlink.
+
+commit e478731a2fc558c62cecbe327c5b35882d90b53d
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 8 16:45:05 2008 +0100
+
+ One more rubyspec for File#open.
+
+commit 5f6ac709500cb64df110a44d31e0c0b89dd68aec
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 8 16:39:47 2008 +0100
+
+ New rubyspecs for File#umask.
+
+commit fddaa684bd7e8c403ff96179ca71a5837f609b63
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 8 16:30:20 2008 +0100
+
+ New File#chmod rubyspecs.
+
+commit ed20c3f9f36f343a37e2ac05ea91d84b54c87bc8
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Feb 8 12:00:57 2008 -0500
+
+ Correctly guard Bignum specs for CI
+
+commit 36e9749984d6e4412c26d348afa8c501cf043ecf
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 8 13:09:37 2008 +0100
+
+ Some more specs for File#new and File#open, and permissions.
+
+commit 29376695550c5608f466d63d49de76a6ee163e37
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 8 12:10:27 2008 +0100
+
+ New specs for IO#new and IO#open, invoked with permissions parameter..
+
+commit 8cf27fcd86f88b75716b65dc1d94b721c01c3af9
+Author: oleg dashevskii <be9@be9.ru>
+Date: Fri Feb 1 21:03:08 2008 +0600
+
+ Heredocs and more stuff added to string_spec.
+
+commit 2cccd38a081c0303f8fa567058e4c26fa354abc5
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Feb 8 12:51:53 2008 +0100
+
+ Add exclude for currently failing for_spec
+
+commit 031bb1b565a3446ab995ea55e6ae8890573ba6c0
+Author: oleg dashevskii <be9@be9.ru>
+Date: Fri Feb 1 20:23:56 2008 +0600
+
+ Added more tests to for expression spec.
+
+commit 73e40331c6b4c1c1b6e41ae312299f6815e089c2
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Feb 7 19:12:46 2008 -0500
+
+ Add a failing spec for Array#join and then fix it
+
+commit fa49548fe704252c352a1bc4833b5da20262061a
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Feb 7 23:12:03 2008 +0100
+
+ Fix last two Failing Time specs for Time#+ and Time#-
+
+commit e4e51c6aa39e5a5a61b0df919ba02b88d4878f43
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Feb 7 22:35:57 2008 +0100
+
+ Fix Time.at so it also works with floats
+
+commit f5505522fd0396c3864fce155681ac577bf2e7e6
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Feb 7 17:10:48 2008 +0100
+
+ Fix Time#<=> for objects other than Time
+
+commit e8ab7b5eb30da84262a9395e20ac420e83674edf
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Wed Feb 6 13:59:18 2008 -0800
+
+ Only call Class#inherited once
+
+commit dc9ff28ae919292287f5562b8c105ff6310c5920
+Author: Phil Hagelberg <phil@hagelb.org>
+Date: Wed Feb 6 15:00:59 2008 -0800
+
+ Kernel#eval should be a module function
+
+ Added a spec as well
+
+commit 7dd83410a2159fd65f951689a8a1297baded4fa6
+Merge: 698ffa4... 339fed9...
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Wed Feb 6 22:54:12 2008 +0100
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 698ffa4e04fee58da5c3f2191372c4e4f2bc070d
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Wed Feb 6 22:51:54 2008 +0100
+
+ Adding missing specs for ftools
+
+ * specs for chmod, compare, copy, install, makedirs, move and safe_unlink
+
+commit 339fed9821b75de056febc406b32fe52ff9354a9
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Feb 6 22:00:46 2008 +0100
+
+ Forgot to remove spec excludes...
+
+commit 7ecca7222823a82252ed09b17eefafe6fec9f12e
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Feb 6 21:46:19 2008 +0100
+
+ Fix last two failing Dir#glob specs
+
+commit fec39f27d287ca74becbecc120de8533e346b864
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 18:13:13 2008 +0100
+
+ A few more corner cases fo IO#lineno specs.
+
+commit 3691d3f9a202abb22e11024e41b868d531a549be
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 18:02:50 2008 +0100
+
+ New rubyspecs for IO#lineno.
+
+commit a5b0f9aa15c9372f74816e77073926780a9cc219
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 15:58:26 2008 +0100
+
+ Improved IO#foreach specs.
+
+commit 91ea9f304c75592e7454411ef21391a0e34da5e5
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 15:03:02 2008 +0100
+
+ New rubyspecs for IO#gets and IO#foreach.
+
+commit 9c494786fbf400bb295e1f19d142e2c903c21e54
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 13:37:43 2008 +0100
+
+ New rubyspecs for IO#foreach.
+
+commit cdbbeba8f3351fe43f44d732348f380599ad5719
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 10:40:13 2008 +0100
+
+ New rubyspecs for IO's sysread and read with buffer argument.
+
+commit e1cb4410b7e0a0ba2fd580784334bdfd05ba4b8a
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 10:15:29 2008 +0100
+
+ Excluded rbx failure after spec rename.
+
+commit 1fde018b9378b55f6d51cb85bd65813b5cef5493
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Wed Feb 6 02:50:44 2008 -0600
+
+ Tidy up an apparent copy/paste mistake in IO#syswrite spec
+
+commit 1aa624e625dafaeebd70eac11819f02ecf570f8e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Feb 6 00:19:39 2008 +0100
+
+ New IO specs for writing non-string data.
+
+commit f94a0cffd5fd0e186a9403d97800b55f8c44bdd1
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Feb 5 15:13:47 2008 -0800
+
+ Regenerate zlib stubs.
+
+commit 52ce0e702170676ce02dcc288305097d58834cf8
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Feb 5 13:34:47 2008 -0800
+
+ Add Zlib spec stubs
+
+commit b24ad594837b974a3ae3b207d63ce5cdc956a1a0
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Feb 5 21:45:09 2008 +0100
+
+ Added some boundary test cases for Float.
+
+commit 1a8c9966fa148fc3e912f8aecd42c8c00ca4f89c
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Feb 5 22:46:18 2008 +0100
+
+ Removed problematic Marshal spec because 2**40 is a Bignum on some archs and a Fixnum on others
+
+commit 6ad8a0a25f20fd137bcb7fcb83bc88440a2a2069
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Feb 5 17:03:56 2008 +0100
+
+ Eliminated file descriptors leakage out of IO tests.
+
+ These things make runs unpredictable, causing all kinds
+ of troubles (non-deterministic failures, fluctating
+ number of tests).
+
+commit 95ac3cb9900c52e4819b37166c71840d4bb4e3d9
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Feb 5 14:50:31 2008 +0100
+
+ New rubyspecs for File.open with block.
+
+ Also, IO.open specs improved to handle closing better.
+
+commit 66f636c346a63853ae37a06f1c3e8b5083370892
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Feb 5 13:22:34 2008 +0100
+
+ New tests for IO.open, and additional cases for IO's inspect and stat.
+
+commit dfb941da0f7503bce58dc88a85ccfd201615e13b
+Author: Brian Ford <bford@engineyard.com>
+Date: Tue Feb 5 01:57:20 2008 -0800
+
+ Ezra's patch for Regexp#inspect, #309.
+
+commit c5f9381ee74ed2d9c91cca1dd2ce9719b6f51bd8
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Feb 5 10:07:57 2008 +0100
+
+ Corrected IO test to not interfere with Kernel#puts tests.
+
+commit 751293c1ea14de1b1d2757bf5d60b082cc771e7a
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Mon Feb 4 17:43:06 2008 -0800
+
+ removed empty excludes
+
+commit 206399aee9ae7845d76c0726702c424b9fc44e80
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Mon Feb 4 17:39:45 2008 -0800
+
+ StringIO#seek now raises if passed bignum offset - should be platform specific, but this'll do for now
+
+commit b00f04ec0fcd8f8edf9943abb5999f1cca9e9e9e
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Mon Feb 4 17:06:34 2008 -0800
+
+ Knocked off the last of the method excludes.
+ Tightened up the spec for #to_s
+
+commit 3d4f87741135343a2e8ec6032fa3a69529cfbf69
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Mon Feb 4 16:51:37 2008 -0800
+
+ Fix Hash#key? to work with objects that have the same #hash.
+
+commit f814a15639f6e6ecd47ab99ad9e37e93fd6bc165
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Mon Feb 4 15:17:08 2008 -0800
+
+ Fix Marshal format version check
+
+commit 6d9e0afb5600416e5d66d5123abcfa5dd6c40903
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Mon Feb 4 14:24:48 2008 -0800
+
+ removed tmpfiles from dir/fixtures and moved them to tmp where they belong
+
+commit 4e18d1cf49573b1fa3f484686352734aa39457d0
+Author: Ruben Nine <ruben@leftbee.net>
+Date: Mon Feb 4 02:32:26 2008 +0100
+
+ Added support for tag:yaml.org,2002:sym to RbYAML library.
+
+ Signed-off-by: Jonas Pfenniger <zimbatm@oree.ch>
+
+commit 220ed05f204f4b8fe7f1f303fae9a18988f8879b
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Feb 4 17:16:44 2008 -0500
+
+ Use an example number that is actually a Bignum everywhere in compiler Bignum spec
+
+commit db3f20c8ec905641de887bbd1ed581aa78f73471
+Merge: e33350e... 6e3dad3...
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Feb 4 16:50:14 2008 -0500
+
+ Merge branch 'wilson64'
+
+commit 6e3dad3e5b2e982f96e991e9df2d46de5bf4ee1f
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Feb 4 16:49:09 2008 -0500
+
+ Use the correct Fixnum#size spec on 64bit platforms
+
+commit e33350eddc3441b2ebe06336500e6445406285d1
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 22:12:14 2008 +0100
+
+ Moved one IO#inspect spec to File#inspect specs.
+
+ Since the behavior is File-specific.
+
+commit 1586e3a2c5d12f5438adddb8c84bc90c3defee82
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 20:57:09 2008 +0100
+
+ Add more IO specs. God, make it stop!
+
+commit e64f3b02423acb783ba8a62996847b0393e7f3ee
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 20:33:57 2008 +0100
+
+ And more IO specs.
+
+commit 3d584f0ee2cf988720bb5985c20b3bec6c2e143f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 20:08:26 2008 +0100
+
+ Next batch of IO methods specs with closed streams.
+
+commit 6e22a99350195cfa7a40d6049d6d72a9ae7e1168
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 19:47:06 2008 +0100
+
+ And yet more specs for IO methods with closed streams.
+
+commit 12e8d881b90cbd60bc792693e799923fdb1041b0
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 19:20:39 2008 +0100
+
+ More rubysecs for IO methods invoked on closed streams.
+
+ Plus some refactoring to move repetitive code to the fixture.
+
+ NOTE: two specs marked as fails_on :rubinius due to fact
+ that they crash rubinius.
+
+commit 3ae3cafcb10725953c8e595641af277f36c88677
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 18:39:34 2008 +0100
+
+ New rubyspecs for IO#to_io.
+
+commit 4980bb83f53845e88cd0d1a3b0823fdbf0c0a001
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 18:09:36 2008 +0100
+
+ New rubyspecs for IO#ungetc.
+
+ Unfortunately, MRI doesn't follow some of its own
+ specified behaviors...
+
+commit f27fe4f3e4ccb298dcaa5014dac69d3148ee169e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 17:18:08 2008 +0100
+
+ Added rubyspecs for IO's putc, puts, printf, print and closed streams.
+
+commit a1d7b67942aed8d1b185476dee6f2d99403ed227
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 17:07:00 2008 +0100
+
+ Added rubyspecs for IO#pid.
+
+commit cfa1ef21ce862a05ae352a4fe49a3ac4c04b9bed
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 16:36:21 2008 +0100
+
+ Added new rubyspecs for IO#sync and IO#sync=.
+
+commit b4f6c33c17e57fa44322124af088a97d475905e2
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 16:20:50 2008 +0100
+
+ New exclusions for rbx.
+
+commit 60309280c48b2bd1f1d8a5ea018f401e75b7dac1
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 16:17:27 2008 +0100
+
+ Added new tests for IO's pos, pos=, rewind, seek on closed streams.
+
+commit 40414ad1b39222494ff2a79a0091890a60b7adf1
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 14:26:13 2008 +0100
+
+ One more test for IO#eof?.
+
+commit 29db340f24c043b240fec6722c323fa1567ce855
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 14:19:46 2008 +0100
+
+ Added new rubyspecs for IO#getc and IO#getchar.
+
+commit 0e0a987782fc7834ba95a2e8e2c8ab6cd8dcea81
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Feb 4 13:54:59 2008 +0100
+
+ More rubyspecs for IO#eof?.
+
+commit f7d1139e4eace4a86f0c0512bf9269964442628d
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Feb 3 15:55:10 2008 +0100
+
+ Fix Date#strptime specs
+
+commit ac4600fcb42928aeba508371aea2f76510e70d5c
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Feb 3 13:26:52 2008 +0100
+
+ Fixed Time specs for non Rubinius platforms
+
+commit a5081ca646e99ec94fedfabf03b7eb0a8d37afc3
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Feb 2 23:53:52 2008 +0100
+
+ Fixed Time specs for 64 bit archs
+
+commit 26eef47571b921fe6b3228033119e5969c4100db
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Feb 2 13:30:16 2008 -0500
+
+ Updated IO excludes.
+
+commit 8edd73d9915f72ee70b661b23e8b42f8b985fa9c
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Feb 2 10:45:23 2008 -0600
+
+ Repair IO#sysseek spec to not write to fixture file; uses a tmpfile now.
+
+commit bf6348c935c816a981672e9c26a40354cf0d722c
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Feb 2 02:35:42 2008 -0600
+
+ Additional IO#sysseek spec for the warning after buffered writes
+
+commit 5241316a1c74e6580fb91940a9f061047e89cdbf
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Feb 2 02:32:36 2008 -0600
+
+ Modify IO#seek specs for IO#sysseek, adding appropriate error tests
+
+commit 7f124cbf66b96fdcdaec73917e86eedfb4a9ddf8
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Fri Feb 1 18:05:15 2008 -0800
+
+ Refactored Marshal#dump specs and merged with fixtures/marshal_data.rb
+
+commit 3766b3ed41ffba71ecb1bef8079027bffe518e2a
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Fri Feb 1 16:54:32 2008 -0800
+
+ Refactored specs for Marshal#load
+
+commit e134d5bf8e247f4a231bfbfc1c3251b262f219e4
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 1 15:36:06 2008 -0800
+
+ Update excludes for recent failures
+
+commit 8ded8b443f55b47a1c30b59cfb0d96d8752d5fa9
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 1 15:11:37 2008 -0800
+
+ Process.group spec is missing a suplemental group on OS X
+
+commit 4b7de6ff839b220115dd29f34b5a9f46cb8f5bef
+Author: Evan Phoenix <ephoenix@engineyard.com>
+Date: Thu Jan 31 17:16:13 2008 -0800
+
+ Add proper primitive failures, fix empty symbol.
+
+commit dc55c88beee6a3a3a7fd352c1e374ecf84863459
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 1 16:17:00 2008 +0100
+
+ Fixed 2 Date#strptime specs that otherwise would pass only in January.
+
+commit 86c372d0fb50aeb6235ed1595d18a876e09330db
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 1 15:32:40 2008 +0100
+
+ Few specs for Time#<=> with non-Time arguments.
+
+commit 765ef93acd294922dc22a986213a5842ce3e67a7
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 1 14:09:01 2008 +0100
+
+ Added more specs to Time#+ and Time#-.
+
+commit af76adac2182e46e34e68d29b3cd8614edd27d50
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 1 13:38:20 2008 +0100
+
+ Added more test cases for Array#join on recursive arrays.
+
+commit bb15b72393b34d3d10bb644fb1d6ce47b6dc0826
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Feb 1 13:15:24 2008 +0100
+
+ Added more test cases for File::join with recursive arrays.
+
+commit 7041b2aef1e574dfe220a70da5210c683074f8ae
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 1 03:18:31 2008 -0800
+
+ Describe an unambiguous method.
+
+commit 84edf54799e0ccd09276a5cda3fccf544f971c48
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Fri Feb 1 03:07:48 2008 -0800
+
+ Use fixed Marshal data for all specs and fix many broken or useless specs.
+
+ Clean up spec naming and definition.
+
+ Use descriptive names for test classes.
+
+commit e0c3aa074c9525450a7a667ec2cc843ff3560e65
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 31 23:29:57 2008 -0500
+
+ Hash.new patch from Phil Hagelberg + MethodTable workaround.
+
+ * The Hash.new patch splits a separate #setup method so that subclasses
+ can override #initialize without problems.
+ * Because it is part of the core code, MethodTable needs to explicitly
+ call #setup in its #initialize.
+
+commit a32f16d9288c5c0822cc6962ce3caed5e1bac5d0
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 31 15:35:08 2008 -0500
+
+ Updated Module excludes.
+
+commit df731f327c4d47373ba6f2fe2f79d5d9acbf398e
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 31 15:30:11 2008 -0500
+
+ More Module#module_function specs in #eval and #module_eval.
+
+ * #module_eval separates the two scopes but #eval does not.
+
+commit 6358e5893c52042c10c355173d1ad8441a00bcfa
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 31 15:13:49 2008 -0500
+
+ Better Module#module_function specs.
+
+commit 1646bb6e99a6b4190641046ae730ea1be9c8be2a
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 31 13:59:20 2008 -0500
+
+ Various whitespace removal in preparation to fix #module_function.
+
+commit 108601d85d2c41d05f9c00945664d9980e0e46c3
+Author: Evan Phoenix <ephoenix@engineyard.com>
+Date: Thu Jan 31 13:39:53 2008 -0800
+
+ Add meta_send_call instruction, speeds up calling blocks
+
+commit 50f9c50820b4305877af1c7fd7597c5dc94c623c
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 31 12:20:11 2008 -0500
+
+ Added LC_ALL=C for all other platforms for Time specs too.
+
+ * If it breaks, report and we will figure out something else.
+
+commit 26059c1570c5ad2a64a796e2678ff2d9ace23e58
+Author: Pierre Yager <pierre@levosgien.net>
+Date: Tue Jan 29 22:48:22 2008 +0100
+
+ Fix for bin/ci spec failure on localised linux
+
+ * Force system date to be executed against "C" locale
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit e5ce9e7c29a34f685f7d3f8a9f855db28aece460
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 31 11:32:56 2008 -0500
+
+ Removed trailing whitespace for Time and some Time specs.
+
+commit 3546f721ac86efa318b3802a2f498d41aa830c9f
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Thu Jan 31 10:53:53 2008 -0500
+
+ Subtend: Add rb_define_private_method, rb_define_protected_method, rb_define_module_method, etc.
+
+commit 7553cb993a0c7e60c2212800b0ecc033ffc0b206
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Thu Jan 31 10:39:08 2008 -0500
+
+ Add rb_class2name in subtend
+
+commit 4570b7c5d837025d765a6a2909d5536c466b9dcb
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Jan 31 02:26:09 2008 -0800
+
+ quick addition of 2 exclusions
+
+commit 53c76326e76869a87ad0fc67adbd3aef9059ee35
+Author: Ryan Davis <rdavis@engineyard.com>
+Date: Thu Jan 31 02:15:15 2008 -0800
+
+ Parser spec updates
+
+commit 8fb2eb68858a1ee1dafb06b833f43d6da817756f
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 30 19:29:25 2008 -0500
+
+ Slightly more permissive TCPServer.new spec for hostname string.
+
+commit 2a60dbbf011e806ae51c30ab2cb2b8e7b9b633a5
+Author: Mutwin Kraus <mutwin.kraus@blogage.de>
+Date: Wed Jan 23 18:41:12 2008 +0100
+
+ Fixing TCPSocket#new for localhost (with specs for both IPv4 and IPv6)
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit f485a6818a754c8110feafa9f6dced42a99187d0
+Author: Jacob Maine <jacob.maine@gmail.com>
+Date: Tue Jan 29 21:13:28 2008 -0500
+
+ Making Enumerable#inject only accept one paramter
+
+ Uses 'Undefined' idiom, which fixes spec, and cleans up code (thanks
+ for the pointer Eero)
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit ebfa5a0bf9f8e3efe61c0d34fe63a8cd74b7ddf8
+Author: Jacob Maine <jacob.maine@gmail.com>
+Date: Tue Jan 29 20:52:16 2008 -0500
+
+ spec to verify inject accepts one argument, at the most
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit b131b80df72a9ceaa9e920b7f78434f301135a6f
+Author: Jacob Maine <jacob.maine@gmail.com>
+Date: Wed Jan 30 00:33:03 2008 -0500
+
+ Adding Enumerable#count spec, including a few failing specs.
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 82b63bc0f5b79735a8021b6c5c69786dc76fa7f6
+Author: Alexandre Perrin <alexandre.perrin@epfl.ch>
+Date: Tue Jan 29 15:59:22 2008 +0100
+
+ udpdated language/string_spec.rb
+
+ * added spec for class/global variable with the \# simple interpolation
+ * added spec for ends of a \# simple interpolation
+ * added more delimiter character with the percent String construction
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit c58110bde52d64b30cf36ba3cb342357f3654812
+Author: Evan Phoenix <ephoenix@engineyard.com>
+Date: Wed Jan 30 17:19:26 2008 -0800
+
+ Fix break. It now uses LRE to properly return to callsite and appear like
+ it returned.
+
+commit 45109c222502de955d705f810333d8e7b331c953
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Jan 31 00:42:12 2008 +0100
+
+ Added Date#strptime specs
+
+commit fe60e6a022d9e64bb568ccd47494f07a99382c58
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 30 11:36:46 2008 -0500
+
+ Updated excludes for Marshal. Looks like Fixnum/Bignum issues.
+
+commit 209dde412310edc384be7d4a86bdfb0444f3b3bf
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 30 01:45:27 2008 -0500
+
+ Updated IO/File excludes.
+
+commit 91031e51e49a1a3ddb9f74da31e2ed65c48e1ef5
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 30 01:43:11 2008 -0500
+
+ IO.new and IO#close use stream API.
+
+ * IO.new uses fdopen() to open the given fd which also checks the mode
+ string for us. The returned FILE* is stored as a MemoryPointer in
+ @fptr.
+ * IO#close checks for presence of @fptr and if found, uses fflush() and
+ fclose() to release the handle instead of going the normal route.
+
+commit f4d64553a2a53c77235ef9acc3353ac455514057
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 30 01:20:32 2008 -0500
+
+ Made probably broken File.open spec compliant_on :ruby.
+
+ * File.open should not take three args. File.new does.
+
+commit dc496f35502b4642137d3f0f74571c8245a6ae56
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 30 01:19:29 2008 -0500
+
+ Slight IO.new spec tweaks.
+
+commit a9d9288315e88cffd59ec1b27e3c3209ceb1a3a9
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Jan 29 20:32:44 2008 -0500
+
+ Combined IO.new and IO.open specs for the shared parts.
+
+commit effa81cce1d42f7c1bc2e275cb75bd9069e934b8
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Jan 29 19:14:51 2008 -0500
+
+ Changed specs to use the two-argument IO.new.
+
+commit 1394b360fe70966e25809a349b400a69262060ca
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Jan 29 14:56:47 2008 -0500
+
+ Rewrote IO.new specs (still a bit sparse.)
+
+commit 94d50eb3e60971ffeff28bffa0beaff405c581bd
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 30 21:47:35 2008 +0100
+
+ File#utime specs to use be_close rather than ==.
+
+ On some platforms, direct comparison just doesn't work,
+ producing non-deterministic test failures.
+
+commit 0f5574c28ff08c96326298b98b4ea50108168044
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Jan 30 13:13:25 2008 +1100
+
+ Remove race in debug_context_change specs
+
+commit 00a62c3476dd0717f5c4caece453914e1392de9d
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Jan 29 14:39:06 2008 -0800
+
+ Remove bogus Marshal specs for Fixnum/Bignum changeover
+
+commit db1b140db0fbecf70f8adda983e010ef2bbe94c4
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Jan 29 22:58:18 2008 +0100
+
+ Finished first version of Date specs. All public methods are specced
+
+commit 8ee52fd8dfd3ef6048c63b30d8aea71da944abb2
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 29 17:21:57 2008 +0100
+
+ Follow rbx lead, and allow deviation in UnboundMethod#== for JRuby.
+
+commit f670bcb9e086ac9cc73b6ef6083966b296268f04
+Author: Caleb Tennis <ctennis@engineyard.com>
+Date: Tue Jan 29 09:46:50 2008 -0500
+
+ Fix typo
+
+commit 4e990269fd42aabd48cdc29b4288c78984d0e5cf
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Jan 29 02:44:20 2008 -0800
+
+ Add File::join recursive Array spec.
+
+commit 4d947218e949e19515a9e89af99d4823048f3bb2
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Jan 29 02:41:54 2008 -0800
+
+ Fix File::join spec name, duplication
+
+commit a38e10ddc19ebd59f8775a01f3e899c5348ba23f
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Jan 29 02:40:37 2008 -0800
+
+ Make File::join remove extra / appropriately.
+
+commit 074251c03093ba40c0fc3558d512a77844ac45aa
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Tue Jan 29 00:53:23 2008 -0800
+
+ Make File::join specs more clear, remove whitespace
+
+commit f968bbe15a27d8ac6716d103119d41c4eef37696
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Mon Jan 28 18:07:24 2008 -0800
+
+ Use const_lookup in Marshal, fix #marshal_load.
+
+commit 7e00b857f56879564c1bf27f2e694f3c0783a4bb
+Author: Eric Hodel <ehodel@engineyard.com>
+Date: Mon Jan 28 17:23:26 2008 -0800
+
+ Support nested modules in Marshal
+
+commit 5c6e2af3d9ace07ca8387c5aecaa5c1d85e8d81f
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 28 20:22:40 2008 -0500
+
+ Added specs for rest of the filetypes to File::Stat#ftype specs.
+
+commit 221a077bef5e9007b548993eaf16c86137c6b0b3
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 28 20:08:12 2008 -0500
+
+ Added support to spec file type against sockets too.
+
+commit 9cb4791db10bc79f8c30a86f17e6c099dabeea80
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 28 19:52:07 2008 -0500
+
+ Moved File and File::Stat-related fixtures to fixtures.
+
+ * Module FileSpecs defines methods that yield filenames corresponding
+ to specific file types so they can be easily tested.
+
+commit c28c85602d3ab6770ed567a64b744baa15795511
+Author: Ben Hughes <ben@pixelmachine.org>
+Date: Sat Jan 19 16:10:36 2008 -0500
+
+ Added spec for File::Stat#dev, dev_major, and dev_minor
+
+ * Check that the result values are Integers for each operation
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 86ce52e32a35cb11564d0d5f306f4eea6d6b714d
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Jan 22 15:21:38 2008 +1100
+
+ Added yield_debugger on context change
+
+ Added capability to set a flag in the VM that causes a
+ yield to the debugger to occur immediately following a
+ change in the active context. This provides a foundation
+ for step in logic for the debugger, which need only set
+ a flag on a task and have a breakpoint triggered at
+ whatever receiver is activated following a send.
+
+commit 3904ff2fbb209b8c2d476bb3f4a4ea4825a16f6e
+Author: Brian Ford <bford@engineyard.com>
+Date: Mon Jan 28 17:58:35 2008 -0800
+
+ Fixes for mSpec to coexist with autotest.
+
+commit 45f2d6de4b025acfa2429d88c729a3eb58a79528
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Mon Jan 28 17:08:45 2008 -0800
+
+ Added more brains to .autotest. Removed bad files that it pointed out
+
+commit 70eaa7feffcfd552c51b67a651cdf6063c9b549a
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Mon Jan 28 15:57:24 2008 -0800
+
+ Add File::Stat#dev.
+
+commit 020f4bec691ba658fab0f1ff24fa5df5a6f1921f
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Mon Jan 28 16:13:11 2008 -0800
+
+ Added enough process spec exclusions to drop the HUP issues
+
+commit 76b393566f2a89001952dbf1ec46dd52a5750448
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Sat Jan 26 10:58:42 2008 -0800
+
+ Fixed autotest support (needs latest version of zentest).
+ Minor clean up on bin/ci and kernel/core/module.rb.
+ Hacked mspec/matchers/base.rb to output with pretty print.
+ Fixed mspec's runner to output time BEFORE failures. Fixes unit_diff.
+ Updated Parser excludes.
+ Deleted a bunch of excludes.
+ Updated spec/parser/sexp_expectations.rb with latest ParseTreeTestCase.
+ Started adding a rewriter to make maintaining sexp_expectations easier.
+
+commit d147f6f0a87e30e240750d8c660bc89f8c84a472
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Mon Jan 28 18:20:38 2008 -0600
+
+ update CI excludes
+
+commit 159f17a228fa6a42cea79b9e3663e1f2b9dea9e4
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Mon Jan 28 18:07:56 2008 -0600
+
+ add Marshal specs
+
+commit 72e739590b6bbe571607df674e2f4106c64c8042
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Mon Jan 28 15:15:26 2008 -0800
+
+ Fix String#gsub when matching '^'.
+
+commit fc8c2c5584305b3e0b2a74ba8250a0b7072a372f
+Author: Ben Hughes <ben@pixelmachine.org>
+Date: Sat Jan 19 16:20:55 2008 -0500
+
+ Added specs for File::Stat#ftype. #264.
+
+ * Tests "file" and "directory"
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 2f9872b66d4dffc82e0a97e617fb9de18105f668
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 19:56:06 2008 -0500
+
+ Better living through mocks. String#+ spec cleanup & correction.
+
+ * String#+ in fact raises a TypeError when given ANY non-#to_str
+ object.
+ * Simplified spec code.
+
+commit f5a0f1e0e401db8f28727cdd8be99228c9c6aee3
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 19:37:08 2008 -0500
+
+ Removed trailing whitespace in String.
+
+commit 03c1c270236786b66930063669b95ac7cbf17f10
+Author: Matthew Draper <matthew@trebex.net>
+Date: Thu Jan 10 22:40:35 2008 +1030
+
+ String#+(65) throws a TypeError, unlike String#<<(65).
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit a17ede3e9c85c1bd2e06efa7381c1e5dbab47f80
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 19:10:33 2008 -0500
+
+ Minimal IO#open specs, IO#sysseek. Merged from Chen Yufei's patch.
+
+ * Merged patch by hand, most of it was already implemented separately
+ too.
+
+commit 30116d672d950687646c1668eac4d9f5b10f4df7
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 18:53:19 2008 -0500
+
+ IO#readline EOFError spec modified from Chen Yufei's patch.
+
+ * Patch was out-of-date, applied by hand.
+
+commit 1b81e68249741d53b38857440bba897987d00e43
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 17:44:30 2008 -0500
+
+ Separated and excluded NUL byte stripping for String#lstrip specs.
+
+ * Rubinius does strip leading NULs, MRI does not.
+
+commit 55f50888f22288b0fa45298d873dd265d7340aec
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 16:52:51 2008 -0500
+
+ Updated various excludes.
+
+commit b085f63d66519f93b59e3851b7e6796877e97107
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 16:47:24 2008 -0500
+
+ Documented Method, deleted unnecessary Method#module spec.
+
+commit f71f5c91e8ceab59d59614fe885dfeff096d7655
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 15:41:26 2008 -0500
+
+ More precise specs for Method and UnboundMethod #to_s / #inspect.
+
+ * Checks presence of own class, method name, name of the Module where
+ the method is defined and name of the Module where the method was
+ extracted from.
+
+commit 400b522d27515698e0a35b2507a4a8825ec9bf8f
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 15:22:46 2008 -0500
+
+ Rewrote Method#unbind specs, touch-up for Module#instance_method spec.
+
+commit 57bddb7b38dbb762b2469c51eb961e01f03c8518
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 14:50:38 2008 -0500
+
+ Updated UnboundMethod#== spec for Rubinius/MRI difference on Modules.
+
+ * Rubinius' UnboundMethod#== is true for methods from included Modules also.
+
+commit 8503c92f914d72e72eeeaede225f52242a1afad9
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 14:25:29 2008 -0500
+
+ Rewrote and added Module#instance_method specs.
+
+commit 8541f4cf83f8b776276e81ca41eb0f7b595e4fb7
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 13:43:36 2008 -0500
+
+ Improved/added UnboundMethod#bind specs.
+
+ * Removed unnecessarily specific error message check. Exception type
+ is plenty.
+ * Specified correct behaviour only in terms of Method since a Method
+ is returned and anything after that is not #bind's responsibility.
+ * Rubinius allows binding to any object that is kind_of? with respect
+ to the Module that the method is *defined* in. MRI requires that it
+ can only apply to objects of the same Module that the method was
+ extracted from.
+
+commit fc7073c85b5e201265e24a82c19bd6413681f6e1
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 13:02:24 2008 -0500
+
+ Removed trailing whitespace in UnboundMethod#bind specs.
+
+commit bde0cacff5f061accab7feb8a27b2417456f2f95
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 12:38:39 2008 -0500
+
+ Specced Rubinius to deviate in UnboundMethod#==.
+
+ * MRI requires that both UMs were extracted from the exact same
+ Module. Subclasses etc. are not OK even if the UMs both refer to
+ the original in the parent. This is somewhat nonsensical and
+ harder to implement so Rubinius allows it.
+
+commit e7ba146d3d0ef0aed1d297d157008661458723eb
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 12:16:07 2008 -0500
+
+ Much more comprehensive and precise UnboundMethod#== specs, documented.
+
+ * #== has some stupid behaviour but this is what we get.
+ * Explanation of criteria in the method doc.
+
+commit 43f2226c8882900a472f0a5347fa549936e8f000
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 09:37:51 2008 -0500
+
+ UnboundMethod String representation specs improved.
+
+ * Specs require that the returned String contains this object's class
+ and the [Module]#[method_name] it was extracted from.
+ * The spec specifies nothing else about the format or order etc.
+
+commit 67e3b5993d92776e0c9535549e8ffdb172225d52
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 09:11:19 2008 -0500
+
+ Trimmed whitespace for kernel/core/method.rb for patching.
+
+commit c61c5185589cf5a86b58b2e8c8b8d7a26cdc25ec
+Author: Scott Taylor <scott@railsnewbie.com>
+Date: Mon Jan 14 00:23:27 2008 -0500
+
+ fixing the specs for UnboundMethod#inspect
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 48bcca32329d48a20d5a6f2dd19598ea7b4167ce
+Author: Scott Taylor <scott@railsnewbie.com>
+Date: Mon Jan 14 00:16:24 2008 -0500
+
+ UnboundMethod#==, plus an extra spec
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 232015fed94b59adf627a7712da0d5d4d44c87d0
+Author: Scott Taylor <scott@railsnewbie.com>
+Date: Mon Jan 14 00:03:32 2008 -0500
+
+ UnboundMethod#bind
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit fcd0139307fd48f78f122457af1af43a543343ce
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 12:11:34 2008 -0500
+
+ Updated excludes for IO#write.
+
+commit eed253158fe0cc20b91f6c8dcc06f6a671092d84
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Sat Jan 26 14:36:33 2008 -0800
+
+ IO#write calls #to_s on it's argument
+
+commit bb5ff251bcc4baceac25a3a1fa64797b94551145
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 03:22:02 2008 -0500
+
+ Updated #attr_writer spec that was picking up a stray method.
+
+commit fa985a57f6cf802d6a83a6d02a31dd7fd33ebd36
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 01:20:27 2008 -0500
+
+ Module#const_get can now access top-level constants for Modules also.
+
+ * Modules explicitly check Object last, Classes already do it since
+ they all inherit from Object.
+ * Added some more specs too.
+
+commit fbc1cfb2d461891ee478802f44de3736959905a7
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 00:47:52 2008 -0500
+
+ Renamed the Module field 'parent' to 'encloser.' Some docs.
+
+ * When dealing with Modules and Classes, 'parent' is an ambiguous term.
+ In typical OO literature, 'parent' means the superclass which is not
+ the case here. Two separate sections of code already showedsome
+ uncertainty about the intent of this field.
+ * Added a few bits of documentation to Module.
+
+commit 92903e92564857350061d83f8eb3b54886986ac3
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 00:36:10 2008 -0500
+
+ Updated Module excludes.
+
+commit a705e687ce0d55e7ea184e1a3e67ba8d9d7c610c
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 27 00:24:20 2008 -0500
+
+ Improved Module#const_get specs for better coverage.
+
+commit bca6aef9b81166f9c5f4aeaafc673a54710d4d35
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 19:57:33 2008 -0500
+
+ Corrected semantics of spec statements for Module#const_get.
+
+ * Specs were correct but the description was inaccurate.
+ * Prettified just a little.
+
+commit f699c18b68dee73086afb92d15b61745319a5321
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 19:55:40 2008 -0500
+
+ Module#const_get specs for top-level constants by Le Huy.
+
+commit f3831a0693ea90271843bcc5910516e5a40ed3c1
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 19:15:27 2008 -0500
+
+ Module whitespace cleanup before patching.
+
+commit e3cbe8136351f055bd99f10646d4f77515078430
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sun Jan 27 00:51:55 2008 -0600
+
+ A few basic IO#write specs for file IO
+
+commit fd05adfedf70d795d8d91f650d5b76b05104dd7a
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 18:54:35 2008 -0500
+
+ Specs for Enumerable#max_by (Rubinius extension.)
+
+commit 560b6460745c7821b9479b356c032a10daaa61ec
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 18:53:52 2008 -0500
+
+ Specs for Enumerable#min_by (Rubinius extension.)
+
+commit 6ab0bc901bdc60bde1e251f72f0028dfb736a2dd
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 14:25:41 2008 -0500
+
+ Updated excludes for Enumerable.
+
+commit 2e09eedb31e15c791e491e97bc2af1977a629c2b
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 14:20:19 2008 -0500
+
+ Fixed Enumerable#max and #min nil problems using Undefined.
+
+commit d8e6ebf604fdcc228e9158336250dd29c6d35932
+Author: Jacob Maine <jacob.maine@gmail.com>
+Date: Sat Jan 26 13:22:33 2008 -0500
+
+ Failing spec for finding max when Enumerable contains nil
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 313ee6badb177c101e39e122c5b5d6ff4d73d93d
+Author: Jacob Maine <jacob.maine@gmail.com>
+Date: Sat Jan 26 13:01:06 2008 -0500
+
+ Failing spec for sorting a list that contains nils
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 467e8a60e0e25003894013e68f6d48e7bd6a22fc
+Author: Jacob Maine <jacob.maine@gmail.com>
+Date: Sat Jan 26 12:01:15 2008 -0500
+
+ adding failing spec for sorting enumerables that contain nils
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 8719a4ad46d7643c6e54aab3dffedb6831bde5f3
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 13:42:11 2008 -0500
+
+ Whitespace cleanup before applying Enumerable patches.
+
+commit 015a0d023e8c649160800ddb8a269aa789266d51
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Jan 26 13:31:00 2008 -0500
+
+ Added/changed the Dir open specs after previous simplification.
+
+commit 6735df441af2489d47674b0cc500dab37dd4319e
+Author: Jonathan Younger <jonathan@daikini.com>
+Date: Thu Jan 24 17:09:49 2008 -0700
+
+ Simplify Dir#open spec dependencies.
+
+ The "takes a block which yields the Dir instance and closes it after"
+ expectation was failing because it depended on File.for_fd working
+ properly with closed file descriptors which it does not.
+
+ This revision removes the dependency on File.for_fd as well as
+ IO.sysopen (which is not yet implemented in jruby) such that
+ the spec now passes on ruby, rbx and jruby.
+
+ Signed-off-by: Eero Saynatkari <rubinius@projects.kittensoft.org>
+
+commit 27834ebec570c78011eaaf37998272d46ab9d118
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Jan 26 21:51:13 2008 +0100
+
+ Added Date#strftime specs and fixed some constants
+
+commit 767e58ec38af7c3bc78dd98541fb8235616e9691
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Jan 26 21:45:23 2008 +0100
+
+ Add spec for Rational#round, works because of added Numeric#round
+
+commit 2497d3b7b9d6112356204dc429c3c368e1a65573
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 26 12:31:45 2008 -0800
+
+ Templates for Rational specs.
+
+commit 5d63550a13cad4acbae3ae67e9ee9f672cbe5e61
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Sat Jan 26 00:47:35 2008 -0800
+
+ Revert back old date.rb, but use newer date/format.rb, with some fixes
+
+commit ecd3ee8a0a528f516283558585b86e729bd388ec
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 25 21:47:38 2008 +0100
+
+ Updated not_compliant_on --> not_supported_on, where appropriate.
+
+commit 78ca098893d6231f74386eeadf0c30787f3dd2e6
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri Jan 25 12:18:43 2008 -0800
+
+ A couple of easy fixes, fix Time to handle 2 digit dates, pull in trunk date
+
+commit fe8433cda8ca49835e2581f35bbf0d31025e84c1
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 25 18:42:31 2008 +0100
+
+ Better detection of AF_INET6 support in socket specs.
+
+commit 1834801229bf8b2c0abfea4c18448ed105691682
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 25 18:16:56 2008 +0100
+
+ Added a guard for undefined AF_UNIX in Socket specs.
+
+commit 3af242cc180675272ee24d588f3328bc11342048
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 25 14:32:04 2008 +0100
+
+ New specs for IO#seek, IO#pos=, StringIO#seek and non-fixnum args.
+
+ Rubinius fails all of them.
+
+commit 0ef7d55ebb5108bd5cf2f951236c8fade3999dfb
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 25 13:42:08 2008 +0100
+
+ New specs for String#unpack with 'Q/q' patterns.
+
+commit 907081db80262a1403f659433934ef707c2ddee0
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 25 12:35:07 2008 +0100
+
+ Adjusted socket specs, so they pass on MacOS (MRI/JRuby).
+
+commit 9cca76acbe066da357692a19d5af1c8f5e4601c9
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 24 17:31:38 2008 -0800
+
+ Fix race in compiler version number, fix regex spec
+
+commit be18fcc2e0ee16f861f1e2bff0636c3288bce8d6
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 24 15:10:00 2008 -0800
+
+ Be more flexible with set_priority (OSs are a bitch)
+
+commit 845336d81df42b5d1f93123ef148b78c2b220d25
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 24 13:46:08 2008 -0800
+
+ Kernel flesh out, passes all but 1 spec now
+
+commit ab87e7641336dfb07f0ad99cc2881ec59a25053a
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Thu Jan 24 12:36:50 2008 +0100
+
+ Changed __const_set__ to handle corner cases.
+
+ * Kernel#__const_set__ is now the catch-all. It triggers on things like :
+ M = 3
+ M::M = 3
+ * MAIN#__const_set__ is forwarded to Object
+ * Module#__const_set__: logic has been moved here, it is no more and alias
+ of Module#const_set because it needs to trigger a warning on re-assignment.
+
+commit 13dbdf62e802028cb61f9375196712f0b789ff37
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Jan 24 21:30:02 2008 +0100
+
+ Added some SystemCallError specs.
+
+ And exclusions for rubinius too.
+
+commit 75e2aac1d4b031fa36c8967549452436521b5eea
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Jan 23 19:41:30 2008 -0800
+
+ Rework Class.new and Module.new to initialize without VM help
+
+commit 2551e57644d091d44e5e2fa715a017a557a0b18c
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Jan 23 19:03:51 2008 -0800
+
+ Userland now uses __const_set__ for 'A = 3' syntax
+
+commit 400c5ceaf677aa2cd05a451c22144613ad7bdbe9
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Jan 23 14:32:26 2008 -0800
+
+ Introduce kernel/user land. Adds use of Module#__add_method__
+
+commit 9ee17f227ebe572b09d44b3b0d703b9f95717751
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Wed Jan 23 14:50:25 2008 -0800
+
+ Fix Hash#clone
+
+commit bf4875d337017736bd94781c1bf4cd7500fae5f5
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Jan 23 22:55:02 2008 +0100
+
+ Implemented Enumerable#inject fix
+
+commit 0bd07f50ba75910ab579e3356dae93bc32b695bd
+Author: Jacob Maine <jacob.maine@gmail.com>
+Date: Wed Jan 23 15:46:06 2008 -0500
+
+ Enumerable#inject(nil) should yield nil as the first 'memo'
+
+ * Currently yields the first element of the enumerable instead
+
+commit 319f937284e60acc156c6b7f91e56d460e65ac94
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 23 18:12:56 2008 +0100
+
+ Excluded the IO#new spec.
+
+commit 04da4120d939603d4a64aab71bbf94ca202e04b2
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 23 18:11:45 2008 +0100
+
+ Added IO#new spec (block should be ignored, warning printed)
+
+commit 5617c3eb81a3f1d8f9a581695fe7897fadee500a
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 23 17:50:48 2008 +0100
+
+ Excluded failures after IO specs additions.
+
+commit 107a072689bc9b97842f049f4fab2860ab79237d
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 23 17:48:34 2008 +0100
+
+ Added specs for IO#open/popen, File#open with close inside block.
+
+commit bc3393a9041f8116d53bedfa6b604ec6dce3fd19
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Wed Jan 23 14:25:13 2008 +0100
+
+ Revert "Added Module#name memoization spec". dbussink told me this behavior
+ is not wished.
+
+ This reverts commit ff411600202a59d00ffaca2c51330599c6b84966.
+
+commit 73e7d61d756cb7a06ea18b7f92c49bbebb06cc3f
+Merge: ff41160... 1dab607...
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Wed Jan 23 13:57:28 2008 +0100
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit ff411600202a59d00ffaca2c51330599c6b84966
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Wed Jan 23 13:55:36 2008 +0100
+
+ Added Module#name memoization spec
+
+commit 1dab607a79b79b370eda4776daf07a262451aea0
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 23 13:28:29 2008 +0100
+
+ Added IO#close specs.
+
+commit c78091236495f4a16aa874de97cce3ec485c1f5b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 23 12:54:25 2008 +0100
+
+ Added IO#close_write and IO#close_read specs.
+
+ And all of them fail in rubinius. (not implemented)
+ And most of them fail in JRuby. (recent bugs)
+ They pass just fine on MRI 1.8.6 (p111 and latest)
+
+commit dc39943a4595855d64f23f9155a4e9cf658c39a3
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Jan 23 10:37:45 2008 +0100
+
+ Small refactor of regexp_new
+
+commit 132ac4986a648dbf1354216145e5715a727a735b
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 23 00:14:34 2008 -0500
+
+ Type.coerce_to no longer falls prey to identity fraudsters.
+
+ * Type.obj_kind_of? directly uses the internal kind_of instruction
+ so that overridden #kind_of? does not get in the way.
+ * Type.coerce_to uses Type.obj_kind_of? for its checks so that
+ Core can safely use it without worrying about breakage due to
+ overridden #kind_of?.
+ * Specs for both and a little documentation.
+
+commit 192882902154c9a68554337ccd1b8f3ee9aedd9e
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Jan 23 00:42:24 2008 -0800
+
+ Remove Symbol#to_i and Symbol#to_int. Farewell bastard children.
+
+commit f854667ff62528fe541c8cf67b9a1b291598d654
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Jan 23 00:35:29 2008 -0800
+
+ Removed Fixnum#to_sym and Fixnum#id2name, as well as fixed specs
+
+commit eb6cbc3604c81cc093edb1c182be1e456b05bef6
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Jan 23 16:30:22 2008 +1100
+
+ Added specs for context iseq manipulation
+
+ Added specs to test MethodContext#reload_method and
+
+commit fd5fb764ee21b354b75b84f34906663874a24639
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Jan 22 22:28:02 2008 -0600
+
+ spec for DRb method call using a block
+
+commit a928762b48f7dc84bba0d43125063e9d8d54f183
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Jan 22 19:15:10 2008 -0800
+
+ Better test of #instance_method.
+
+commit c055a5981bf4ecfd2efc0df74adb071056ff83b9
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Tue Jan 22 15:40:59 2008 -0800
+
+ removed remove_method_excludes.txt
+
+commit 08cb27454e7ae73e79bb432887dba917feaa1f92
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Tue Jan 22 15:36:36 2008 -0800
+
+ Clarified undef/remove specs a bit.
+ Fixed remove_method to raise NameError if you're not acting on local method.
+ Removed some fails_on calls to make specs pass... gonna remove them all soon.
+
+commit 62d93ac7916ff0d56a5b40ae1b9b501f10081638
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 22 15:35:05 2008 -0800
+
+ Fix up sysread and syswrite, disable testing for warnings on rubinius
+
+commit a482b17c4bfe9f40474839ba0cce2a37d8524c62
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 22 15:13:19 2008 -0800
+
+ Remove stale binding excludes
+
+commit f45030d33a9e1fe3c6bc111401a893e5649239f7
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 22 15:03:37 2008 -0800
+
+ Update Proc excludes
+
+commit 7f932fbdf5fa4e16df10d7731313d458ca21966c
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 22 14:55:50 2008 -0800
+
+ Add Proc#==
+
+commit 811cbe8ef876ef452051a9b07b3c95dbf57a7d9f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 22 23:41:55 2008 +0100
+
+ Removed debugging stdout from one spec.
+
+commit 2bf52de43bb90721d921f6d29504a8f098ed09b5
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Tue Jan 22 14:11:17 2008 -0800
+
+ Removed a lot of passing specs from the excludes
+
+commit b0e5a9ba6577c301f2737682d745128e268ebdab
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Tue Jan 22 14:02:38 2008 -0800
+
+ Fixed Symbol::all_symbols
+
+commit 68ae0b5acd647b9ebd73e53638b728cfaee6b6e0
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 22 22:09:45 2008 +0100
+
+ Revert "Completed MRI's Module#name spec with corner case."
+
+ This reverts commit 970ede321d31ec75dd578866c683defe768fa356.
+
+ This spec seems like an implementation detail rather than
+ a specified behavior. It was agreed on IRC to revert it,
+ and that rbx won't support it.
+
+commit cc0e45cab2167e0fbc1d29308a5dcb4e7e077319
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 22 22:06:28 2008 +0100
+
+ Revert "Module#name memoization work."
+
+ This reverts commit 7cd9fce4908aaeea9a35e273a3f15ed7ee7aa783.
+
+commit 996f9f4e5fc05f1b3aa618db3e1a4947730780b7
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 22 12:23:39 2008 -0800
+
+ Fix LongReturnException to be terminated in the correct place
+
+commit f453121dd2f3b4d9506a3f1c1e61d24e46bc9083
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 22 20:53:45 2008 +0100
+
+ Corrected Module#instance_method failing spec. It was failing on all impls.
+
+commit c1d59239ddea95e73e2edd3a97ed6e1113a35d3c
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 22 19:58:32 2008 +0100
+
+ Corrected Module#instance_method spec, it was failing on MRI/1.8/1.9/JRuby.
+
+commit ef5f4489caac2ad4bad94783a780aa40a054481c
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 22 19:30:48 2008 +0100
+
+ Corrected String#to_f spec.
+
+commit 7cd9fce4908aaeea9a35e273a3f15ed7ee7aa783
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sun Jan 20 22:00:34 2008 -0600
+
+ Module#name memoization work.
+
+ * Module#name is now memoized on access if @name is set
+ * Full module path is lazily calculcated on memoization
+ * Module#const_set(Ruby) and module_const_set(C) only set @name and @parent.
+ * The following methods unifily use module_const_set:
+ * cpu_const_set
+ * cpu_open_class
+ * cpu_open_module
+ * module_setup_name
+ * Module#calculate_name reworked, hack removed
+
+commit 7b4ef1344812faa76018ab41cc7fba97a3af8448
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Tue Jan 22 02:47:49 2008 -0600
+
+ implement more of Marshal.load
+
+ Float, obj._load, obj.marshal_load, IO.read, proc arg
+
+commit 41f07f0253a8fba205dbb0402e5d5e88c115d76c
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Jan 22 16:32:01 2008 +1100
+
+ Fix Task#get_stack_value to not raise exception from primitive
+
+commit 14c811adaba3e8cfc5104d70e67c2e89c18cac4d
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 21 19:28:18 2008 -0800
+
+ Exclude Kernel#require is private spec when running with RSpec.
+
+commit 05a180e0051a0409c685d326a41e882545faaa53
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 21 19:26:41 2008 -0800
+
+ Explicitly run /bin/sh to get around limited /bin/pwd on linux.
+
+commit c09b3da391995a0e9006055ce19e838d3f180947
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 21 19:09:07 2008 -0800
+
+ Protect String#% specs from segfaulting on linux (ubuntu gutsy).
+
+commit d36b3f65f92b08ae078812788482387077d03380
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 21 17:55:03 2008 -0800
+
+ Removed use of `pwd -P` as at least ubuntu bin/pwd doesn't support it.
+
+commit 6d7a8292fb9a68a0dcfbd3f29f595e0ecf5902ae
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 21 17:54:11 2008 -0800
+
+ Unexclude Kernel#callcc specs as Evan's recent commits seems to fix it.
+
+commit eb04d409575772a85510770bd0db4f36490de6aa
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Mon Jan 21 13:28:06 2008 +0100
+
+ Fix Regexp error handling
+
+commit 93e50808eb7355c404a7f5295923083c8cf63549
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sun Jan 20 22:00:34 2008 -0600
+
+ Quarantining IO#dup spec "sharing" example due to platform differences.
+
+commit ae9e2829becc495892c7ddce5eae67514f268120
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 10:26:56 2008 +0800
+
+ Update Module instance_method_specs excludes after revert put it back in
+
+commit df6c82f97987c233eab0534740054e2d0f0f2f2c
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 10:25:00 2008 +0800
+
+ Revert "Update CI excludes for Module"
+
+ This reverts commit 8aa00146f2eee9576094daa76c6f158b0deaf2e2.
+
+ * Fails when run with other specs
+
+commit 6f5245d4c20bf009bc120967f4a93d24faae66ba
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 10:23:15 2008 +0800
+
+ Revert "Update CI excludes for Symbol.all_symbols spec"
+
+ This reverts commit cb27e31b2a757ad108842bfa579eb9170d6cf244.
+
+ * Returns an F if run with other specs in ./bin/ci
+
+commit ec9677e593247ed8dfcbfc680151d04ac97936e3
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 10:11:35 2008 +0800
+
+ Fix Module instance_method_spec to match the inspect with a regexp
+
+commit 7e3474a16ec20094630e865594405ea7f1658c58
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 10:08:06 2008 +0800
+
+ Module#instance_method raises TypeError/ArgumentError on invalid arg
+
+ * Fixed spec to expect TypeError when passed nil
+ * Fixed spec to expect ArgumentError when passed non-symbol/string
+
+commit 8aa00146f2eee9576094daa76c6f158b0deaf2e2
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 09:41:37 2008 +0800
+
+ Update CI excludes for Module
+
+commit 9158b959d30babdceafc416650c1ba3234e5029a
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 09:10:06 2008 +0800
+
+ Add alias for Proc.to_s from Proc.inspect
+
+commit cb27e31b2a757ad108842bfa579eb9170d6cf244
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 09:09:40 2008 +0800
+
+ Update CI excludes for Symbol.all_symbols spec
+
+commit 7f16f313c907de0e22762d97fbba24e70c3259a3
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 21 08:46:36 2008 +0800
+
+ Raise TypeError/ArgumentError for invalid Thread key
+
+ * Raise TypeError is key is nil
+ * Raise ArgumentError is key is not Symbol or String
+ * Correct the description of Thread's element_set_spec to use #[]=
+
+commit 0b849f884beae9d11327e315da5c79fe789b8391
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Jan 20 23:05:33 2008 +0100
+
+ Added rubyspecs for Zlib.crc32.
+
+commit 67b52b6fb92b9e9a037e584474cff2dc97ce0163
+Merge: e6d8a61... 6f08d5e...
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Sun Jan 20 22:30:52 2008 +0100
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit e6d8a61771b76198c0784677bb0a8fc97b1988bc
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Sun Jan 20 22:30:29 2008 +0100
+
+ Fixed Struct#[] and Struct#[]= with negative indexes.
+
+ * Added corresponding specs
+ * Fixed kernel/core/struct.rb code
+
+ Example:
+
+ s = Struct.new(:x, :y)
+ x1 = s.new(:a, :b)
+ x1[-4] #=> should raise IndexError: offset -2 too small for struct
+
+commit 6f08d5e21473d0f2adff66a32acd46ddd8945fa0
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 20 12:47:11 2008 -0800
+
+ Added spec for Kernel.format.
+
+commit 6ab2691b455ac07643d98dc58f8a0f45487ab20d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 20 11:52:56 2008 -0800
+
+ Added sane handling of non-reals for #format %e, %E.
+
+commit 1caab1ce237a52d78a402a5f0a7ce1d3ed9ac6b7
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Jan 20 18:55:27 2008 +0100
+
+ Add spec for singleton_methods and fix for Fixnum
+
+commit d7c46a0a1660f1d53e03a97571f3ec7b2431d0e4
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sun Jan 20 12:29:10 2008 +0100
+
+ Added failing spec for Regexp#new that could cause a segfailt. Needs error handling as stated in shotgut/lib/regexp.c:122
+
+commit d15c6605b7fb7db337d87ac1bd15f9a1371caa42
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 19 19:28:00 2008 -0800
+
+ Added language spec for return within a block.
+
+commit 3b516c028c4c9e064fbe839f0f9402a135eb90b0
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 19 17:27:13 2008 -0800
+
+ Added spec for class vars set from Kernel#instance_eval based on #267.
+
+commit 970ede321d31ec75dd578866c683defe768fa356
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Sun Jan 20 00:44:04 2008 +0100
+
+ Completed MRI's Module#name spec with corner case.
+
+ It looks like Module#name is memoized in MRI
+
+commit caf440ac6a8037a2c223834c0ca4c5decd8e68ab
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Jan 19 22:48:31 2008 +0100
+
+ Revert "Wrapped one spec to prevent JRuby crash."
+
+ This reverts commit 9f266e3c785c7e3edbb6a30271f32debe6c14164.
+ JRuby issue is resolved.
+
+commit 9673e2c1c5a1142af52a0d82d8981bdd9e236c27
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 19 12:46:12 2008 -0800
+
+ Changed IO#syswrite to use should complain matcher.
+
+commit 8522186df7050782c4911f40aef381106e5e8c5b
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 19 12:29:12 2008 -0800
+
+ Added mSpec lambda { .. }.should complain matcher for warnings.
+
+commit 9f266e3c785c7e3edbb6a30271f32debe6c14164
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Jan 19 21:24:13 2008 +0100
+
+ Wrapped one spec to prevent JRuby crash.
+
+commit 54d1989997561271553ba72bd99f59ef2deb7c72
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Sat Jan 19 19:13:06 2008 +0100
+
+ Fixed "X::X = 3". It would return a tuple instead of 3.
+
+ * changed shotgun's const_set instruction to push the variable on the stack.
+ * added corresponding specs under `language'
+ * found a new problem but added it to excludes
+
+commit d25ec129902789bc7d636ff5ccda8ff858ae38d3
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 19 10:21:19 2008 -0800
+
+ Added spec/README. Reformatted mspec/README. Removed old sprintf spec.
+
+commit 5eb06e3010707de1e273c23b3f0addf2ceaa824d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 19 09:37:29 2008 -0800
+
+ Removed unused Sprintf, rename YSprintf to Sprintf.
+
+commit c144abc12230175a2a503c4426804ed19c8559e7
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Jan 19 16:21:08 2008 +0100
+
+ File::Stat time functions should return Time objects and added stat and lstat instance methods on File
+
+commit 177ef99db435a59e942566f7904167fc5e849d8d
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sat Jan 19 22:24:16 2008 +0800
+
+ Fix ThreadGroup's add spec
+
+ * Fix is by initializing a new ThreadGroup on Thread setup
+
+commit 3fad84ec370eda1cab596adf5589e43240dfc381
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Sat Jan 19 12:16:55 2008 +0100
+
+ Removed empty *excludes.txt for better searchability
+
+ `find -name "*excludes.txt" -size 0 -exec git rm {} \;`
+
+commit 9a2b1e6232f36c7a1508085b4606e25fbcf3cb4a
+Author: Jonathan Younger <jonathan@daikini.com>
+Date: Fri Jan 18 23:19:16 2008 -0700
+
+ Additional String#% platform specific formatting failure fixes
+
+commit aa32d6fcbed79b9e2afedc00f429ea78f5c540d3
+Author: Jonathan Younger <jonathan@daikini.com>
+Date: Fri Jan 18 22:12:23 2008 -0700
+
+ Fix String#% platform specific formatting failure
+
+ Darwin and FreeBSD return a different string format than other platforms,
+ so a different expectation is needed to match the appropriate format.
+
+commit c64dfd449dc89ec0016f14afd7f85522dbaa4148
+Author: Jonathan Younger <jonathan@daikini.com>
+Date: Fri Jan 18 21:05:44 2008 -0700
+
+ Moved String#% specs to ruby/1.8 and fixed to work with rbx and MRI
+
+commit e5e7f44983f1dbbc79726776b56a9cc7cb910e9f
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 18 19:53:50 2008 -0800
+
+ Updated IO excludes.
+
+commit b8b549dbc1aaf63e15717c3902d4485c97f845f7
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Jan 18 21:40:01 2008 -0600
+
+ Add regexp matching for output matcher and enable warning specs for syswrite.
+
+commit 004bd58b597034cbe734d9b7da318135a689190f
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Fri Jan 18 21:06:38 2008 -0600
+
+ implement some of Marshal.load
+
+commit 2c52db8022f060866d839992aaa6bff0f61963cf
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sat Jan 19 11:21:55 2008 +0800
+
+ Fix UnboundMethod#bind
+
+commit a5680db20cf998f0db292e3b9aa69ed74fb19b10
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 18 17:49:44 2008 +0800
+
+ Implement UnboundMethod#==
+
+commit a1de7b0f405830f6bfe8000c051f4445135d8f63
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Jan 18 20:54:11 2008 -0600
+
+ Added some specs for sysread/syswrite on a file and p flushing to File.
+
+commit e7bc994d96398519ca205e87dec8e775bb0e67c6
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Sat Jan 19 01:31:46 2008 +0100
+
+ Fixed File#utime segfault
+
+commit 9887c6135e9353c3094dcf3c76d8e788b98f2bed
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 18 22:00:10 2008 +0100
+
+ Added Time#strftime specs for '%U' and '%W' patterns.
+
+commit 0338fb5adb325e58d1ce61bccc9310fc7284e235
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 18 20:35:23 2008 +0100
+
+ Added two testcases for String#% rubyspecs ('x', 'X').
+
+ There was a bug in JRuby's sprintf, which wasn't
+ detected by rubyspecs.
+
+commit 97db9fb72d6205227d61d92ed3153331b2328f97
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 18 10:50:00 2008 -0800
+
+ File#utime spec. Some cleanup of File#open specs.
+
+commit 10647cf8abfd0ea7a87d39978a22f68fdfa9fbd6
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 18 17:08:04 2008 +0100
+
+ Wrapped 3 IO spec tests into fails_on :jruby.
+
+ Because these tests just break the spec run completely.
+
+commit cf6195eeabe382c4267e295ab786acedaed89050
+Author: Jonathan Younger <jonathan@daikini.com>
+Date: Thu Jan 17 21:55:48 2008 -0700
+
+ Fix specs that use `pwd` to use -P option so that symlinks are resolved
+
+commit 1b79705fb965ecd6fc897b6bf14c605d8325dabe
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Jan 18 15:57:46 2008 +0100
+
+ Added IPAddr specs by manveru. Closes #262
+
+commit f05b96b33970e3f08da5c8992f7c6cb710649f42
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Fri Jan 18 02:23:15 2008 -0800
+
+ Fix spec for IPv6 environments
+
+commit 2007019ebad7974d7a54e6d599320675548313f0
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 18 17:39:09 2008 +0800
+
+ Fix UnboundMethod#inspect to use regexp
+
+ * Also aliased UnboundMethod#to_s to UnboundMethod#inspect
+
+commit c47b473b99b59074673adb7e8d50a250e34436e7
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 18 17:37:29 2008 +0800
+
+ Use a regexp to match the inspect output instead of deviating on rbx
+
+commit 8dc2a2b3115a49a15ed931301b1999560ee27db5
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri Jan 18 01:05:14 2008 -0800
+
+ Fix up specs and finalize LongReturnException
+
+commit 7c30ca7337b56a4194eb58952f74662e222b7707
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 17 23:23:27 2008 -0800
+
+ Add support for return in a block obeying ensure properly
+
+commit c06fc665c6bf5898163f2854b93d62b8b314216e
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 17 21:20:42 2008 -0800
+
+ Changed Exception#backtrace to return an MRI compatible one.
+
+ * Exception#awesome_backtrace returns an Rubinius Backtrace
+ instance, as Exception#backtrace used to.
+ * Added templates for Backtrace specs.
+ * UnHACKed lib/test/unit to use the #backtrace as expected.
+
+commit a29f35c5a45776f10132c3ce0ef058b1e98a4f75
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Jan 17 20:18:04 2008 -0500
+
+ Guard failing Process.setpriority spec, add an exclude to CI
+
+commit 333d5c6920c01366c8b2887ecc7e33f775210c00
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 17 16:50:31 2008 -0800
+
+ Specs and fixes for Class.inherited.
+
+commit ac90d87a69c19c441b854660105d21ed771989f0
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Thu Jan 17 16:37:31 2008 -0800
+
+ One more step into the foray of bootstrap madness... removed useless 0 from lasgn nodes. needs full clean
+
+commit 0dbabefd081be4890d0d789a9c3ec122b9196cf8
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 17 12:00:55 2008 -0800
+
+ Fixes to enable RSpec 1.1.2 to run the spec/ruby specs.
+
+commit 9bd611ff5c5b411518c2f4ce5d3cd4b93f4bcebe
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 17 08:25:24 2008 -0500
+
+ IO#puts, #isatty fixes from Dan Lucraft, slightly modified.
+
+ * The #puts spec exposed an issue with String#suffix? which Ifixed in
+ fa9a6c which means IO#puts did not need to be changed.
+ * #puts spec uses output_to_fd.
+
+commit 3f519a98bbc3a66d59884add5fcd98d5ca095149
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Jan 17 08:02:51 2008 -0500
+
+ String#suffix? specs and correct behaviour.
+
+ * The suffix can be the entire string, there is no need for it to
+ just be a substring always.
+
+commit ca6fa9cd760b06827f4f953ff28e8baed357f447
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Jan 17 12:48:20 2008 +0100
+
+ Additional Date specs
+
+commit 8541022ffc918879142ecb3707e977050f774ece
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 17 00:47:04 2008 -0800
+
+ Added ?d, ?e, ?f to Kernel#test.
+
+commit e6f36980c2c94414e5c051b35d9ce403c492f1a2
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Thu Jan 17 02:18:25 2008 -0600
+
+ Fix my oops; missing 'do' for the fails_on
+
+commit 44483d8e414f107b3202cc69b8cdfbbe1222ee33
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Thu Jan 17 02:07:57 2008 -0600
+
+ Add a fails_on guard to IO#printf spec for JRuby; output dies otherwise
+
+commit 53a36c934ec44fad7e6d18424cb13b37496cf720
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 16 18:39:34 2008 -0800
+
+ Updates to compiler and core to protect Fixnum#/.
+
+ * Added compiler plugin SafeMathOperators.
+ * Added very simplistic way to pass flags to the compiler.
+ * Added -frbx-safe-math flag
+ * Changed core Fixnum, Float, Bignum, and Numeric methods
+ to use #divide rather than #/. Aliased #/ to #divide.
+ * Updated Rakefile to send flag when compiling core.
+
+commit feb260b904d87487428b558f7b7e9ac0170c160c
+Author: Ryan T Mulligan <ryan@ryantm.com>
+Date: Wed Jan 16 22:47:02 2008 -0600
+
+ very minimal SHA1 specs
+
+commit 511732d932d2fe934968c78b89cefa46e699b996
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Wed Jan 16 16:30:40 2008 -0800
+
+ Moved old spec excludes to new location and deleted all old
+
+commit cae6bba077190e158ceee7b8991daf16fd8c55d1
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Wed Jan 16 13:36:19 2008 +0100
+
+ Added more Date specs
+
+commit 75d49657f31091d37dfdba1fc5487164db861802
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Jan 16 15:58:42 2008 -0600
+
+ more specs for TcpServer and TcpSocket
+
+commit b1d45cb0fdc573bfe5995456d846c11747d48b90
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Jan 16 13:31:33 2008 -0800
+
+ Implement ObjectSpace.define_finalizer, using WeakRef.
+
+commit 4e8a0d264dc7d5a4866a1a1b83238bebb47e4ab6
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Wed Jan 16 21:51:52 2008 +0100
+
+ Removed platform-specific specs in spec/ruby/1.8/core/signal/list_spec.rb
+
+ There is not direct way to know if a signal exists or not, since it all
+ depends on <signal.h>. In practice, there is no real risk for rubinius
+ to miss a signal.
+
+commit 32537f8d3378154f7f52c278cd56a7d4159a3446
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 16 12:41:54 2008 -0800
+
+ Added IO#printf, fixed Kernel#printf to use IO's.
+
+commit e7bccb3f38f6ace3cb25a9f227ab5f6b1d2be346
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Wed Jan 16 21:19:48 2008 +0100
+
+ Signal.list spec now passes. bin/ci removed list_excludes.txt
+
+commit b3a6461af30f2c144b4ee65e8539c51291e0156b
+Author: Jonas Pfenniger <zimbatm@oree.ch>
+Date: Wed Jan 16 20:03:15 2008 +0100
+
+ kernel/core/signal is no more platform dependent
+
+ * Now publishing platform.conf with rbx.platform.signal.* (only using the ones
+ defined in MRI's "signal.c")
+ * Signal::Names is now published with those values on @after_loaded@
+ * New method: Signal.list => Signal::Names
+ * Added EXIT=>0 and CLD=CHLD exceptions (see "signal.c" in MRI)
+ * Updated the corresponding specs for more details (on FIXME, please help !)
+
+commit bdbd712a5953f011f8d6f1142d50a452e1607f65
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Jan 16 13:42:01 2008 -0600
+
+ updated Continuation excludes -- Kernel#callcc specs still bleedover
+
+commit 22d32d3461660ee7cd29760163b622fc94b6ea5b
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Wed Jan 16 01:55:21 2008 -0600
+
+ apply Marshal.dump patch by Justin Bradford. #252
+
+commit 513de8ab67ab9c017285a48108ccceb185ebaf24
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Jan 16 16:44:34 2008 +1100
+
+ Bunch of Debugger fixes
+
+ * Debugger now has proper quit behaviour, which causes
+ the debugger to remove all breakpoints, clear the debug
+ channel, and resume the debuggee.
+ * Fix singleton(-ish) semantics of Debugger; essentially,
+ only a single Debugger instance can be instantiated at
+ one time.
+ * Added a bunch of specs for the above
+ * Changed Rubinius::VM.set_debug_channel to accessor
+ style Rubinius::VM.debug_channel.
+
+commit 2174009b215ce2f0445fc8df4711e7e6c64b0332
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Tue Jan 15 21:59:30 2008 -0600
+
+ add Marshal.load specs
+
+commit ec002dd0f0daddedaa5241c4f8f6d85fad0e9768
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Jan 16 09:47:28 2008 +1100
+
+ Move VM under Rubinius namespace
+
+commit 983c54400542a03535accf2705ae227ae58970dc
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Tue Jan 15 15:24:10 2008 -0600
+
+ Added spec for File.new coercing filename using to_str.
+
+commit ff6a081de28711b0d8c1136e6e4272baf769043c
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Jan 15 14:29:43 2008 -0600
+
+ since DRbObject is within DRb it should be a subdirectory but mkspec generated the wrong path to helper
+
+commit a48cbbd3f5da3c971a215423b3e27b058de04196
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Jan 15 21:15:09 2008 +0100
+
+ Add more Date specs
+
+commit 9de289f1bbae86b12bc383e7e535de404f8aaa5f
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Tue Jan 15 14:58:31 2008 -0500
+
+ Add a servent class to StructGenerator for Socket.getservbyname
+
+ Also, add Socket.htons and Socket.ntohs for byte order encoding
+
+ And complete Socket.getservbyname along with specs.
+
+commit d9e37ff3c0f975a418fafbc7163ee1a9717dd92b
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Wed Jan 16 03:31:05 2008 +0800
+
+ Fix Proc#[] calling the wrong #call method
+
+ * Re-aliasing in Proc::Function because aiases don't follow subclass
+ methods
+
+commit 2273c919e80ab7186e3139941dc4d73a292bcd2d
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Jan 15 19:30:23 2008 +0100
+
+ Add add and minus specs for Date
+
+commit 1325e22c11c48c366d9f0387823de5941b59df66
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Jan 15 16:35:23 2008 +0100
+
+ First specs for Date object
+
+commit a3b76d162e58e75b4523151bb6911c840db8319f
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Tue Jan 15 12:58:14 2008 -0500
+
+ Implement Socket#pair (and Socket#socketpair) with corresponding spec.
+
+commit 836f1cf828ab62606a6b0e2f7313228b7482dcbe
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Jan 15 11:47:11 2008 -0600
+
+ generate spec files for DRbObject
+
+commit ef99f25be36f6ccd33b297bed14c1175847f1ecc
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Jan 15 11:31:08 2008 -0600
+
+ generated spec files for DRb with a basic spec for DRb.start_service
+
+commit 9637cf1e77efd1a3b53e6c4d82a7c7afe8509621
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Jan 15 18:48:09 2008 +0100
+
+ Eliminate stdout from IO#dup spec runs.
+
+ At least, under JRuby it was printing things like:
+ "No such file or directory".
+
+commit 30a2fce2a4fd7e840586ce8ae390ecb632c8bee0
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Tue Jan 15 23:00:32 2008 +0800
+
+ Implemented Dir#pos which fixes #pos, #pos=, #seek, and #rewind specs
+
+commit 013ab2e88ecd8d887c6a0009e7f8d2add4849143
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Tue Jan 15 22:52:26 2008 +0800
+
+ Revert "Updated CI excludes"
+
+ This reverts commit 15d1c7674496a99bf1d5ec42420864b22bf1569a.
+
+commit 15d1c7674496a99bf1d5ec42420864b22bf1569a
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Tue Jan 15 21:50:55 2008 +0800
+
+ Updated CI excludes
+
+commit 18470055d83a43c3371609aaac4471767adb3b1b
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Jan 15 04:32:54 2008 -0800
+
+ Make TCPSocket.new work. Use socket library names for familiarity.
+
+ Make inheritance hierarchy of sockets better match MRI.
+
+ Add syscall names to Errno.handle checks.
+
+ Spec less of the socket library.
+
+commit bd34303986a068b40cce1366c85ea288fc24a3f5
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 14 23:55:38 2008 -0500
+
+ Regexp subclasses work now. Documented Regexp.new.
+
+commit 343acee55519fc97a35a9d50e8bdcfd679d432b7
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 14 23:49:47 2008 -0500
+
+ More Regexp.new specs.
+
+ * Subclass initialization verification.
+ * Multibyte options are case-insensitive.
+
+commit 758a468ffafdeea78016dbbce78f21e19f6735f6
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Mon Jan 14 18:22:32 2008 -0800
+
+ Fixed require modifying LOADED_FEATURES even if require raises an exception
+
+commit 5c8ff74b64f7ec6bd4c413b0e0e93334dff009ca
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 14 21:57:19 2008 -0500
+
+ Fixed Regexp#kcode specs.
+
+commit 34867cc1f1f3b7ac3145fb926491c0dc44629312
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Mon Jan 14 22:41:58 2008 -0800
+
+ Add Socket::getaddrinfo. Raise SocketError appropriately.
+
+commit e2009a38a8e1ef0dff6394b92a677f3120280f72
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Mon Jan 14 22:39:55 2008 -0800
+
+ Remove platform-specific code, remove spec of socket library behavior.
+
+commit 5afa1c34808c68c17bc02f5f76c42d64efdd7dd2
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Tue Jan 15 00:32:14 2008 -0600
+
+ Modified retry-in-rescue example to test nested blocks and be clearer.
+
+commit 17fd0cb781ec90d268668c5678e1135eb5f6e323
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 22:28:46 2008 -0800
+
+ Added Module#autload?.
+
+commit 96ca83312d1b5a1e38e25f94504f6f69a137b96d
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 21:50:37 2008 -0800
+
+ Updated CI excludes for language.
+
+commit ef4f49de672d40f43f53dadff1aa8fdbcafe1d45
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Jan 14 21:37:23 2008 -0800
+
+ Fix specs for dregx change, fix regexp for specs
+
+commit 5cd2ef2a173394910249d93d8ef433d220f2d9a9
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Jan 15 16:32:15 2008 +1100
+
+ Fix breakpoint specs
+
+ The breakpoint specs were interfering with one another,
+ due to the fact that each was modifying the bytecode for
+ a fixture class that is compiled only once.
+
+ Workaround this by saving off the bytecode and resetting
+ before each test.
+
+commit 29bf88b07f87182d94fcf7c550724efc07067239
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 20:00:27 2008 -0800
+
+ File spec/data/critical.txt is empty! Congrats to everyone!
+
+commit 8082760cc2215742464a9846295ec4a8a0c49244
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 19:37:33 2008 -0800
+
+ Removed Module methods from critical excludes.
+
+commit d075c115087c001d0d35562aeeea21efadc5e3b6
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 18:53:46 2008 -0800
+
+ Added not_compliant_on :rbx for class variable specs that use Fixnums.
+
+commit 23f1b523da2478f2ad962f0045dca3e7034f9b56
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 18:16:46 2008 -0800
+
+ Multiple fixes for #class_variable_get/set. Updated CI excludes.
+
+commit dbc5675058aa426dbfbbf7489d5393819edb16f8
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Jan 14 16:42:27 2008 -0800
+
+ Fix attrasgn usage to pass specs
+
+commit 3e250999d6f1a7fdaf2bb5cd169a1024e2ab5ddc
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 16:07:08 2008 -0800
+
+ Removed leftover excludes for compiler[12].
+
+commit a2b8b5511e79b47fa7777e716ee16511fdec3fd4
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Mon Jan 14 16:47:21 2008 -0600
+
+ Remove the goofy Hash#delete spec and replace with two others.
+
+ The old version of this example depended on individual hash buckets having a
+ specific ordering, which overreaches a bit. The new version, while a little
+ cumbersome, should work correctly regardless of hash implementation or hash
+ and bucket ordering.
+
+ I also moved out a few lines that were unrelated to this example into a
+ separate one.
+
+commit 67d858885f1841e9c9aa295150da3c472949198d
+Author: Gregor Schmidt <ruby@schmidtwisser.de>
+Date: Mon Jan 14 14:57:53 2008 +0100
+
+ Passes Module#extended specs by added extended method to module and adding a call to it in Object#extend
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 302ba965def902ccc5d3e97ed6bd5841f09d8f00
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 14 14:14:08 2008 -0800
+
+ Philipp Brüschweiler's patch for String#%, #242.
+
+commit abaf2efa9e467bb7b5ef3b53b8490f1e056a832e
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Mon Jan 14 16:59:23 2008 -0500
+
+ Another round of socket specs, and add a Rake StructGenerator to find sockaddr_un if it's available
+
+commit f5d0e435023a80bcc4c101a8d3ab9fc056a14c80
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Mon Jan 14 15:52:47 2008 -0500
+
+ More socket specs
+
+commit 7bbc927a9d8a6f9202025be62a3db861ced3216f
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Mon Jan 14 14:58:34 2008 -0500
+
+ More socket functions and specs.
+
+ Namely, this implements a Socket::SockAddr_In class that is a FFI::Struct around the
+ sockaddr_in C struct. This gives us a better ability to inspect what's going on in the
+ struct from the Ruby side of things.
+
+commit f351c6d3d8831705f0398abdae240abba9252a75
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Mon Jan 14 11:09:04 2008 -0500
+
+ More socket specs update
+
+commit cb8ce936394cafa00f77008083bccf9cded59f28
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Jan 14 14:39:41 2008 -0500
+
+ Split process/constant expectations into Linux and BSD sections
+
+commit 0964d53edd80367611f63cd6eb4b294ec898cc8d
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 14 10:04:53 2008 -0500
+
+ Revert IO#dup spec to unmask errors, removed FileUtils dependency.
+
+ * Any errors occurring in specs should generally be raised normally
+ so that any potential problem or spec deficiency is exposed.
+
+commit 04f542e928c5fa0df460d8f11b4d87e008fa343f
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Jan 14 13:36:49 2008 -0500
+
+ Update Process::Constants to fetch values from RUBY_CONFIG
+ Update process/constants_spec so that it passes on MRI as well
+
+commit 0ad02b57fd040196d11662bd1ab9b259dc2ce6d2
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Mon Jan 14 12:23:20 2008 -0600
+
+ squash Marshal.dump bugs
+
+ * fix order of evaluation problem
+ * put more objects in links and symlinks hashes
+
+commit ed98b9a14459b011f97fee5c781410c4d413ed9a
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Jan 14 17:36:00 2008 +0100
+
+ Updated Arry#pack specs to guard for always big-endian JRuby.
+
+commit 550f07dc7551573a975183209ba8904fdbd62607
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Jan 14 15:57:04 2008 +0100
+
+ More robust cleanup in IO#dup specs.
+
+ Without it, mspec against JRuby was reporting EIGHT
+ failures, while only 5 tests are actually exist.
+
+commit 1ea4f82183190c4c87da48c381f1db417c7403ac
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Mon Jan 14 09:26:36 2008 -0500
+
+ Updated some socket specs
+
+commit e20ab7ea377cd39209011b44204d2688b53611c5
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 14 02:23:26 2008 -0500
+
+ Fixed Regexp.new kcode setting, improved Regexp specs.
+
+ * Regexp kcode can be upper- or lowercase.
+ * More robust Regexp#options and #inspect specs.
+ * Updated Regexp excludes.
+
+commit cc71f359aa65101d2c00cfbb0c396b7cdc697ef2
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Jan 14 01:25:21 2008 -0800
+
+ Improve bytecode performance a tiny bit, fix Kernel#`
+
+commit c561368c03c605de41746fac2ce5a6386fcf4f54
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Mon Jan 14 03:17:15 2008 -0600
+
+ Quarantine a suspicious TCPSocket.new speck failing on MRI on OS X.
+
+commit 71a9cf2afbbe6903b8d652b3ee201957e0b0c633
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 13 22:58:16 2008 -0500
+
+ Finished IO#print specs.
+
+commit ff75b95a690051736f49a9a113d21027f7f03e92
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 13 22:44:21 2008 -0500
+
+ IO#dup and specs.
+
+commit 02f1c03f4df3327ce1ddd20e2249a5e9830627a0
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 13 23:11:48 2008 -0800
+
+ Justin Bradford's patch for Float failure, #237.
+
+commit e43c148954ad609c438e5a4f14811c0349239374
+Author: Matthew Draper <matthew@trebex.net>
+Date: Fri Jan 11 21:35:57 2008 +1030
+
+ Kernel#Integer is very fussy about the strings it accepts.
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit adad84f7a26bf40809366f2f7b6acfc61dcfefc2
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Mon Jan 14 00:31:12 2008 -0600
+
+ Class.inherited gets invoked regardless of visibility
+
+commit c746fad52e9503d04c3cf65de979b0a5a9f9e495
+Author: Matthew Draper <matthew@trebex.net>
+Date: Mon Jan 14 10:25:58 2008 +1030
+
+ Many of Kernel's methods should be module_functions.
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 0b8a4bfefaed3179f96721fdde35e32ed8ff7263
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 13 21:43:45 2008 -0800
+
+ Update CI excludes for Regexp. Remove empty CI exclude files.
+
+commit 89a87edbc61a877621c6f43266000aff32e92ae7
+Author: Warren Seen <warren@warrenseen.com>
+Date: Mon Jan 14 07:12:13 2008 +1100
+
+ Fixes visibility of methods passed to Module#module_function
+
+ * Make instance methods versions of functions passed to Module#module_function private
+ * Correctly identify visibility in error message raised in Module#set_visibility
+ * Added specs for module_function
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 25d6fa558f88732d1aa28c68b0eb7c9910366243
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 13 20:42:52 2008 -0500
+
+ Updated Regexp excludes.
+
+commit 69e200276898f1c9208be527bdc64c318c56f86e
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 13 20:24:42 2008 -0500
+
+ Shared spec for Object#dup and Object#clone.
+
+commit 8a6fe609224c126bcf86987edd3f0690fc9e45ff
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Jan 13 18:19:56 2008 -0500
+
+ VM calls private hook methods now. Object#dup and #clone specs.
+
+ * Object#dup and #clone have rudimentary specs which also partially
+ confirm the private hook fix through #initialize_copy.
+
+commit 84773b6ba63ea6f715dcc4e99e0a8a2e2b739152
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Jan 11 10:46:15 2008 -0500
+
+ Specs for Regexp.{new,compile}, updated excludes for same.
+
+commit 6c1603723bba7d58203aa9b03bbf92b4900e53d1
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 13 18:49:40 2008 -0800
+
+ Numerous fixes for File::Stat.
+
+ * Implemented readable(_real)?, writable(_real)?, executable(_real)?.
+ * Implemented a number of helper methods like rowned?, rgrpowned?,
+ superuser?, rsuperuser?. Made these private.
+ * Implemented owned?, grpowned?.
+
+commit d1b05e0bf98a3cdfda8a3d2398e78035a49c0c66
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Mon Jan 14 12:25:41 2008 +1100
+
+ Deprecate meta_send_stack* opcodes
+
+ The code path for these opcodes is almost identical to
+ send_stack, and no measurable performance improvement
+ comes from using them.
+
+commit 154fe5e1faad94f371c51a979240a6d7f5cd8909
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Sun Jan 13 20:07:12 2008 -0500
+
+ Implement BasicSocket#setsocketopt for String optvals, and add a spec for it.
+
+commit c21636d6b2502db344049e7dc62d42ff8c18b040
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Sun Jan 13 19:34:50 2008 -0500
+
+ Add specs for BasicSocket#getsockopt
+
+commit 1584f41148b8d8967df4c3ee6376b59919cb7db3
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Sun Jan 13 19:24:58 2008 -0500
+
+ Add Array.pack for i, s and l arguments.
+
+commit 7131e187e19bf0889f8ece802495865f7b3f1e5c
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Sat Jan 12 13:55:20 2008 -0800
+
+ Cleanup String#split, add edge case check
+
+commit 4ff46602c8a54a61697bb8d9eaa9ae89e56f7abe
+Merge: 1c95721... 908ccff...
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Sun Jan 13 14:49:48 2008 -0500
+
+ Merge branch 'socketspecs'
+
+commit 908ccff0a854038372dad0780e1de35727e2d657
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Sun Jan 13 14:49:17 2008 -0500
+
+ Some TCPSocket spec mods
+
+commit 1c95721bd873c4b30c187bfa7673cd7e3568a0fb
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 13 10:20:43 2008 -0800
+
+ Fixed File::Stat specs to output method name correctly with -f s.
+
+commit acb7505d41aa789157e50962253e686827a702d5
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Sun Jan 13 12:07:06 2008 -0600
+
+ update CI excludes
+
+commit c8db419ae06e9642b346e1bcae99367f3b72845f
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Sun Jan 13 11:55:50 2008 -0600
+
+ squash bug in Marshal.dump
+
+ symbols need a separate links hash
+
+commit eb953ae2c3fdeac4ae13b5461246b9f51b0f39cc
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Sun Jan 13 09:40:39 2008 -0500
+
+ Make the spec text more verbose
+
+commit db013bc06cef2dea4b77a215d4437e2172b391b6
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Sun Jan 13 09:04:08 2008 -0500
+
+ Commit an updated spec that shows the failure on rbx and passes MRI,
+ w.r.t. opening a module and aliasing a private module function from that
+ module.
+
+commit 759a9f8bd70ead9b5d2fc67b3872e3bf3bd34001
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 13 01:45:07 2008 -0800
+
+ Updated CI excludes for File::Stat.
+
+commit 107feb74eaf01c09d8c5bd14ac29e53900a5ed26
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 13 00:38:00 2008 -0800
+
+ Modified File, File::Stat, FileTest specs.
+
+ * Added templates for File::Stat specs.
+ * Added shared specs for some File::Stat methods.
+ * Altered toplevel File shared specs to take the name
+ of the constant to enable File::Stat to use a fixture
+ proxy but still have the correct name show with -f s.
+ * Split out specs for missing files because File.[l]stat
+ behaves differently than e.g. File.file?.
+
+commit e1a13f7ecfe7f2d18fd6ac20dd8c63cbd6d11855
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Sun Jan 13 02:26:09 2008 -0600
+
+ implement more of Marshal.dump
+
+ obj.marshal_dump, IO.write, depth limit, exceptions
+
+commit bc070232eab1bfa5d294897487339d259a406e74
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Sat Jan 12 15:16:21 2008 -0600
+
+ implement more of Marshal.dump
+
+ Float, obj._dump
+
+commit ad7a67ed5a3a1399773dda74c4688e9b00c8f9aa
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sun Jan 13 01:46:36 2008 +0800
+
+ Update CI excludes for Process.initgroups
+
+ * It was affected earlier by the Enumerable lambda/Proc-arity issue
+
+commit 7b7a1e3e4712f35688823543b7a7c3c25405ef77
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sun Jan 13 01:40:22 2008 +0800
+
+ Fix implicit block in Enumerable not passing the arg check in Proc#call
+
+ * Changed instances of lambda to Proc.new and arity once again
+ returned the correct value. Will investigate, but until then, this
+ passes.
+
+commit d9c21aaa18044bd54ed3b1f6ec5daacf9bd250fa
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sun Jan 13 01:02:00 2008 +0800
+
+ WIP Fix block argument checking
+
+ * Passes all the proc/lambda call specs
+ * However, specs for methods that add implicit blocks like
+ Enumerable#all fail because their arity is somehow 0 - excluded for now
+
+commit 3d400bc8a91a793f49dcf5655dc28e6141d999d0
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sat Jan 12 20:03:26 2008 +0800
+
+ Update CI excludes and add Module#class_variable_get to critical.txt
+
+commit 6bf7b8616837649ddd2c1435a54c86ed30910985
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sat Jan 12 19:27:12 2008 +0800
+
+ Move custom classes for NoMethodError specs into fixtures
+
+commit 10cc61bb816ae67a7fad5b135f66d263d7ee07b1
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sat Jan 12 19:20:27 2008 +0800
+
+ Swap the protected/private method calls around in the NoMethodError spec
+
+commit 6b2e66d3f9222b52cdae42b57206363ad47949e2
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sat Jan 12 11:51:28 2008 +0100
+
+ Corrected Module#alias_method spec.
+
+ Now it should pass on both MRI and JRuby.
+
+commit 67f74a936655b72c689d09c77d9fbe9d7194a0a0
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sat Jan 12 17:50:22 2008 +0800
+
+ Fix proc/lambda/Proc.new arity
+
+commit 03440114d5e3f07111cdcae3657258cae4c803e7
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 11 13:24:26 2008 +0800
+
+ Fix Kernel.Integer parsing of invalid String
+
+commit 598598c10c66de38b52a8092cdd2fa99604eda6e
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Sat Jan 12 00:21:22 2008 -0800
+
+ Clean up expectations to use a common list.
+
+ Update excludes for other things using shared glob specs.
+
+commit 55aa5a1f10655618e45d0ec84502cc13c982227e
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Fri Jan 11 23:31:45 2008 -0800
+
+ Specs for File.fnmatch handling of Regexp specials.
+
+commit 7c0dc7edfcdf4948047ba051b0cbed7ba761f1dc
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Fri Jan 11 21:57:10 2008 -0800
+
+ Dir.glob support for {}.
+
+commit 9a097fe5634c1109919d1e120b1276827371c332
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Fri Jan 11 19:42:31 2008 -0800
+
+ Exclude {} specs for WIP Dir.glob
+
+commit ccdc6f5ae5fabbd0d2c32072811e2ecf7cca8987
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Fri Jan 11 21:40:04 2008 -0500
+
+ In MRI, you can alias private module methods. Not so here. This spec catches it.
+
+commit 8b402d1e32dc283124375374532024f6cfe7020d
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 11 17:35:21 2008 -0800
+
+ Added toplevel shared specs. Converted File, FileTest specs.
+
+ * spec/ruby/1.8/shared is the directory for sharing
+ specs across multiple classes.
+ * Added methods for FileTest
+
+commit c6aea2e10d7a4d0ee14175d5b79894e1e11699b1
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 11 15:59:34 2008 -0800
+
+ Converted File/FileTest#exist(s)? to toplevel shared specs.
+
+commit 06a5d8a3d5874303a71e4e9b939b44c204041edf
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Fri Jan 11 17:39:39 2008 -0500
+
+ Fix failing specs in udpsocket/open_spec.rb
+
+commit 530e40005d09140fdb55608890f0994f3a48d8be
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Fri Jan 11 13:11:58 2008 -0500
+
+ Observer specs
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 0907a20d2bad2207be8e937c403c49634f3a23b6
+Author: Caleb Tennis <caleb@tarknology.com>
+Date: Fri Jan 11 12:24:44 2008 -0500
+
+ Add observer to lib and base-spec file
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit ec0ff1dfa1ee9de38d35537bec5071f6bb31cf7f
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Fri Jan 11 13:11:02 2008 -0600
+
+ implement more of Marshal.dump
+
+ Array, Hash, links
+
+commit 640e81394ad2385b535b08b535a4fca06a5f3eec
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 11 10:24:54 2008 -0800
+
+ Added CI exclude for failing MD5#== spec.
+
+commit 3c238cc9f4b32f63bc681bd64a507fc2ff49b017
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 11 10:00:50 2008 -0800
+
+ Converted Socket specs to use subdirs for subclasses.
+
+commit 2b98950eaa33b532fcef079b0997f9793228c608
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Jan 11 09:23:23 2008 -0500
+
+ Specs and implementation for IO#print. Closes #222.
+
+ * IO#print without arguments spec excluded due to a lack of a lower
+ level output matcher. To be added shortly.
+
+commit d65c8c6899cf8e4a1fa56486cf417451e0c7fce6
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Fri Jan 11 19:19:56 2008 +0100
+
+ Fix String#* spec.
+
+commit 481e075bfeb9f8fb3bd4db645129a463307de09e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 11 17:41:07 2008 +0100
+
+ Improved digest/md5 specs a bit, some new test cases.
+
+commit 67f48236da3d114638310ab37bcc706719bf7fcd
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 11 11:59:06 2008 +0800
+
+ Updated Method's specs as Method#inspect and #to_s deviates on Rubinius
+
+commit 76846154773a87bc8d99c97e91250abda22f6378
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 10 19:24:57 2008 -0800
+
+ A bunch of fixes found while working on Socket
+
+commit f69613740662d3ba4f85573c6c860a5987b29765
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Fri Jan 11 00:17:14 2008 +0100
+
+ Fixed Time object for throwing errors where appropriate
+
+commit 9396386f700646d0c55b9a7a75bc399dfe055d2c
+Merge: baae72c... 4d2e53e...
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Jan 10 22:39:24 2008 +0100
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit baae72cc47c9c1f41c3478732b7bbfdfe514024a
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Jan 10 22:39:11 2008 +0100
+
+ Fixed Time#xmlschema conversion
+
+commit 4d2e53e7376080e42b84dca486debcf4f153f32f
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Thu Jan 10 15:17:00 2008 -0600
+
+ implement more of Marshal.dump
+
+ negative Fixnum, Bignum, Regexp, Struct
+
+commit abdbcd70bba99149b7391effa48452971407b4d2
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 13:18:52 2008 -0800
+
+ Annotate Rubinius spec as non compliant.
+
+commit 2a2b3a016bfd70eb8cd14b6a043d59f119e0ad7c
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Jan 10 21:52:18 2008 +0100
+
+ Re-added divmod specs for Ruby/JRuby, with comments.
+
+commit 2f079e416e4389b091c8c9b5522d49c6f356c6c9
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 12:29:39 2008 -0800
+
+ Updated Bignum#divmod specs.
+
+commit 7a5c79415f2e6555bf2c69e416f6d3189f2e0c3e
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 10:46:05 2008 -0800
+
+ Simplify wording of VM.coerce_to_array specs.
+
+commit abc1237a0c96ecd77baee6ecbcf71a7bba338139
+Author: Ryan T Mulligan <ryan@ryantm.com>
+Date: Thu Jan 10 12:35:23 2008 -0600
+
+ md5 is now fully 1.8.6 MRI compatible
+
+ * MD5 digest specs
+ * Specs pass on MRI and RBX
+ * Platform::POSIX.memcpy hooked
+
+commit 9f991bd850c51cd624169b51768c2215d4b56edb
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 11 01:35:15 2008 +0800
+
+ Method#bind raises TypeError when binding a method from a non-descendant
+
+commit fc029ab13ded7eeb1ba838b99f00e2f14e232d65
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 11 00:12:44 2008 +0800
+
+ Implement that Precision.induced_from raises TypeError in certain cases
+
+ * For case when mixer class doesn't define it's own induced_from method
+ * Update CI exclude for precision
+
+commit 35d1a7bc3694bdcc327dd5ac89ca0f261e0bd705
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Jan 10 16:57:38 2008 +0100
+
+ Added one more Bignum#divmod testcase, known to fail on some implementations.
+
+ In fact, this test case fails on Rubinius and JRuby.
+
+commit 955676613f5e38cf029998e2712013e4575dd03e
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Jan 10 16:12:37 2008 +0100
+
+ Changed spec failing on MRI
+
+commit f7b4f3fe02833081cc7f40c0feebbef0e5012f10
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Jan 10 15:58:23 2008 +0100
+
+ Fixed Float#divmod
+
+commit aff6e1fc1a16eb9e7b7e207ebc2234154d891a92
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Jan 10 22:53:25 2008 +0800
+
+ Converted VM specs
+
+commit 969c0d8e0dbf43caa3999976cf259c623ff05ff1
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Jan 10 22:50:17 2008 +0800
+
+ Convert Options specs
+
+commit cc7c9dcb6697dea991342328a9b00fa01740e809
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Jan 10 22:28:42 2008 +0800
+
+ Replace example blocks using 'specify' with 'it'
+
+commit 7a5fa30a71072346abda17cdb79c2aa3b3922239
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Thu Jan 10 15:27:49 2008 +0100
+
+ Fixed Bignum#quo
+
+commit f2aafe4a352fd884d217b0361d2e7e617f58ebd5
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Jan 10 20:38:45 2008 +0800
+
+ Converted Generator specs and generated new CI exclude files for it
+
+commit edb7e341d9b3ab1c3bdc08bc57ec55d6bf8ace8b
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Thu Jan 10 19:33:53 2008 +0800
+
+ Remove generator_spec.rb because of spec conversion
+
+commit bb4de530c5980f0205875bdb5548e40a22ef6a62
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 01:45:47 2008 -0800
+
+ Updated CI excludes for library because of spec conversions.
+
+commit 61a66f69fe3a94d9ad5568ee2dd846cfc0b5211a
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 01:45:17 2008 -0800
+
+ Converted Socket specs.
+
+commit 167e05039eeeeb959f7aab1f3611268170037296
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 00:59:20 2008 -0800
+
+ Converted YAML specs and added template files for other methods.
+
+commit 027f568f79222cdee492f088edf8a2f14250635a
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 00:47:35 2008 -0800
+
+ Converted ostruct specs and added template files for other methods.
+
+commit e964c9342ade9341518bc46cf998703a2c16aa2b
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 00:39:49 2008 -0800
+
+ Converted ftools specs.
+
+commit 6263280187c81b0ee27893eae90f9d6a8a511b65
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 00:26:40 2008 -0800
+
+ Converted Etc specs.
+
+commit 7b94284063222eef42b9b7ad0d1c820adabe210d
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 10 00:39:01 2008 -0800
+
+ Fix a few more Kernel bugs
+
+commit 1c58ee51f388da0490a7815c9a1787d21e151aab
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 10 00:08:15 2008 -0800
+
+ Fixed path for mock dirs in Dir specs.
+
+commit 320f7e7d3503d53216733f9b6eb75c387155ae5f
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 9 22:44:37 2008 -0800
+
+ Converted StringIO and Singleton specs.
+
+commit 5a94a7c3b73103c99a337a089f9cf2c7e601d2bc
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 9 21:50:14 2008 -0800
+
+ Converted stdlib Singleton specs.
+
+commit 12864a2057d1b6f5fa392f34d1fa3e8873a8c566
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Mon Dec 24 23:06:12 2007 +1100
+
+ Initial commit of Rubinius Debugger
+
+ * Created Debugger class for debugging Ruby code in Rubinius
+ * Added Kernel#debugger convenience method to set a breakpoint
+ and activate the debugger at the point at which the
+ debugger statement is encountered.
+ * Implemented the following debug commands:
+ - h: get a listing of commands
+ - b: list breakpoints
+ - b <Method>: set a breakpoint at the start of the method
+ - n: Step to the next line
+ - ni: step to the next VM instruction
+ - c: continue execution until the next breakpoint
+ - l: list source code around the current breakpoint
+ - d: decode VM bytecode around the current breakpoint
+ - v: display local variables and their values
+ - vs: display the contents of the VM stack
+ - Anything else is evaluated as a Ruby expression in the
+ context of the current breakpoint (so you can, e.g. change
+ the value of locals before resuming, etc)
+
+commit 01a189cc3e52e8bcc6f22bcc5713e765bba84160
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 9 10:29:27 2008 -0500
+
+ Object#is_a?, #kind_of? and #instance_of? specs.
+
+ * Removed obsolete kernel specs for same.
+
+commit ab9645614bbbd0bca63c215819c12cc85a1507b1
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 9 21:35:39 2008 -0800
+
+ Converted specs for stdlib Time.
+
+commit 733b069f11c7136175036154a45b924cf89cc8ff
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Wed Jan 9 20:01:09 2008 -0600
+
+ update CI excludes
+
+commit 01e98dee4c24838ca518610443e43473ffdcf43c
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Wed Jan 9 16:42:07 2008 -0800
+
+ Fixed block args for |*a|
+
+commit dc9c1d05dd5e0e828a77acc09220f5894a9aa453
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 9 16:04:11 2008 -0800
+
+ Fixed Enumerator spec style. Updated YAML excludes.
+
+commit 0363685a97df83feb0d07f40a7a5c4d7a78e2a27
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Wed Jan 9 14:55:53 2008 -0800
+
+ Spec for String#sub bug.
+
+commit 23052eb5f993c959fdb2b327895df08e0a344edb
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Jan 8 23:47:27 2008 -0800
+
+ Implement { } matching for Dir.glob
+
+commit c90b2531d183e4534268d4699634828f29e803cb
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Jan 8 23:44:35 2008 -0800
+
+ Spec File::Stat#blksize.
+
+commit 62d2a1809936a304c0cf0b94fd28f5b83932f58f
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Jan 8 22:47:37 2008 -0800
+
+ Implement Dir.glob '{a,b}'
+
+commit d9430ad1a3e582e830a994a83d6f99e017bfbe4d
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Jan 8 20:56:37 2008 -0800
+
+ Fix module X::Y; end; X::Y.name
+
+commit 1baa9468e0d89777fdb6f23e78e8ab510a19d534
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Wed Jan 9 16:16:35 2008 -0600
+
+ incomplete Marshal.dump
+
+ an evil ivar_as_index is added to Object to hold
+ the names of modules that extend the object
+
+commit 85e98490fe45446e03801840d4628149f8977098
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Jan 9 12:26:19 2008 -0800
+
+ Move compiler2 => compiler, and Compiler2 => Compiler
+
+commit 5aa5cc66e2b0196728c80eb394ec3b2dfccd77ae
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 9 10:30:42 2008 -0500
+
+ Centralised specs for Object#=~.
+
+commit e1fe9f57c942460338a18e38f66fbf6feb69b4bc
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 9 13:23:59 2008 +0100
+
+ Added few edge cases to Numeric#eql? tests.
+
+commit b8dfd675fad5e82ebfd50c737beb9a9b919a9c8b
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Wed Jan 9 15:52:18 2008 +0800
+
+ Remove excludes for String#slice with the fixed send in place
+
+commit d7f69f17ac30f6b3161851e8df6a1e0a7694219d
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 8 22:42:43 2008 -0800
+
+ A couple more fixups
+
+commit 055d7545c7046102cd92b7054992b1b47f711c4a
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 8 22:31:50 2008 -0800
+
+ A boatload of fixes done while getting flexmock and rake running
+
+commit fd7c266e52c25d151214512cc801901813630d7a
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Wed Jan 9 11:49:02 2008 +0800
+
+ Removed last array exclude due to fix in 02e6e28
+
+commit 690626f43f7b4ce888de081033eaadfba543acff
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 8 18:58:50 2008 -0800
+
+ Removed subtend specs from CI run. Increase File#mtime tolerance.
+
+commit dec4f25a47a9a962b77a97dea47985fe17421e5f
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Jan 9 13:39:51 2008 +1100
+
+ Specs for stack usage
+
+commit d699f6605db86e6f6bc61d0f3a79fc1535816c70
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Wed Jan 9 10:38:06 2008 +0800
+
+ Add spec to illustrate Numeric#divmod bug in MRI and rubinius (excluded)
+
+commit 8a55f3047dc0fd502bb632dc9f5bdb9668b180fe
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 8 18:32:18 2008 -0800
+
+ Subtend CI exclude to (hopefully) fix the build server runs.
+
+commit 33bde75b57a88baa850edccea382e1130ed586da
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 8 17:19:30 2008 -0800
+
+ Added spec/compiler2 to CI. Added CI excludes for compiler2.
+
+commit 6964fc5644fddeef2238591674786f035d9db842
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Tue Jan 8 17:19:20 2008 -0800
+
+ Fixed up against evan's changes. ping
+
+commit 9423d1e8e9ed91fb9f0934b939899c753972cee1
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue Jan 8 20:11:54 2008 -0500
+
+ Fix warnings encountered when running compiler2 specs under MRI
+
+commit d71ad87c14a4378ad2f01c49d90304c29be548f3
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jan 8 17:02:02 2008 -0800
+
+ Fix a block_arg bytecode generation case
+
+commit 57199b5b468c0009512a479e13bbcf086d0d9526
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Tue Jan 8 16:16:07 2008 -0800
+
+ Added new combo bytecode/runtime tests for block args
+
+commit 8a88699af73d272a61332e11d022bd629aa0460d
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Tue Jan 8 16:15:24 2008 -0800
+
+ Improved inspect output for compiler spec objects. Added convencience methods for testing iter bytecode generation.
+
+commit 0dd9cd298cf735dc13cc2a2410ad6b5195790c11
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 8 13:19:21 2008 -0800
+
+ Added subtend specs to CI. Updated subtend excludes.
+
+commit c07a5273844b32fe39090bb16d0e4ad59ecb0564
+Author: Dirkjan Bussink <d.bussink@gmail.com>
+Date: Tue Jan 8 21:28:48 2008 +0100
+
+ Fixed given_spec? because of changed block_given? behavior
+
+commit 0f9a8dfee9dd1c7af1f8ba69497c8dd85539760a
+Author: Nitay <nitay@powerset.com>
+Date: Tue Jan 8 11:49:41 2008 -0800
+
+ Fix setpgid spec using pipes to avoid race condition
+
+commit 09feb8677c529d04969e63d1ff4e3746037611cf
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 8 10:00:06 2008 -0800
+
+ CI excludes for ruby/1.8/library.
+
+commit cda3d86fa44f1d62fe503e54f42c5c5df361b8f9
+Author: Benjamin Andresen <bandresen@gmail.com>
+Date: Tue Jan 8 08:22:49 2008 +0100
+
+ Added explicit umask to File permission spec so it won't fail on
+ non-standard umasks.
+
+commit 6df303e29d7fd04f4a1a0af379f4947854dd4635
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Mon Jan 7 23:20:22 2008 -0500
+
+ Method#== and specs from Scott Taylor, slightly tweaked. Closes #137.
+
+commit 9b86b12be687bb29e25d0292786351d89a698adc
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 7 19:45:24 2008 -0800
+
+ Added CI exclude for Array#pack.
+
+commit 17a746b0aa2c89aa9e61b8965d125e962748c20d
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Mon Jan 7 21:07:25 2008 -0600
+
+ adds Marshal.dump and Float#to_s specs
+
+commit d5c19db2778e0cc3cbee5bf994b511448cb6bd78
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Mon Jan 7 15:31:11 2008 -0800
+
+ Fix IO#pos=
+
+commit 21f44f03f0aa44b2f172f89ad27797c943dc618b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Jan 7 22:03:28 2008 +0100
+
+ Remove non-needed std output from Array#pack test.
+
+commit 9ec20509ad6533876bbbc984052e6b7e05d2ea55
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Jan 7 21:50:46 2008 +0100
+
+ Added Array#pack tests with empty array.
+
+commit 35170103bdba14d824780a41112f12034cb5c79e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Jan 7 21:13:47 2008 +0100
+
+ Added Array#pack tests with 'w' pattern.
+
+commit 71b00e03ce2c6424fd262d737feb991835605da2
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Jan 7 20:46:58 2008 +0100
+
+ Added Array#pack('U') test with negative values.
+
+commit 7be0813127635ea54909179c9553c5052c4a3d90
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 7 18:00:03 2008 +0800
+
+ Add specs for Array.[]
+
+commit 0b762336e8c6040cbbe794cece64c56bfa46c296
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Sun Jan 6 23:35:35 2008 -0800
+
+ Fix breakages, comment out at_exit spec (need a better way to test)
+
+commit 8896e459f1bffb7ae2da2f2aa708419e6316cb4b
+Author: Matijs van Zuijlen <Matijs.van.Zuijlen@xs4all.nl>
+Date: Mon Jan 7 14:03:03 2008 +0900
+
+ Spec to demo failure of cases like "yield 1, *[1, 2]"
+
+commit 79da85bb1b1d63e617251b3a3ea6b0657c1e8ddb
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Mon Jan 7 13:04:22 2008 +1100
+
+ Modified CompiledMethod#decode to use #local_names
+
+ * CompiledMethod#decode now leverages new #local_names
+ method to return the names of locals accessed via
+ push_local/set_local etc.
+ * Removed excludes, as all decode specs now pass
+
+commit 89c1026cecbb9fcd09a62139e2d28b24b5658c25
+Author: David Whittington <djwhitt@gmail.com>
+Date: Mon Jan 7 01:37:10 2008 +0000
+
+ Added args to NoMethodError raised by Object.method_missing
+
+commit 0e4a02f0e2fede5d785b15a6b34c582c6ba586f1
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Sun Jan 6 12:43:14 2008 -0800
+
+ Removed redundant Bignum#to_s. Moved private radix_to_s to bottom. Cleaned up to_s spec a bit
+
+commit 48446c40a759d60b7465d82b40f2911d0f7e444b
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sun Jan 6 13:45:22 2008 -0600
+
+ Add some additional Math.asinh specs from JRuby.
+
+commit 7c81ca307cd01d3752a08487bc3742c8452d61c4
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Mon Jan 7 00:41:10 2008 +0800
+
+ Add failing specs for Time.{local|mktime|utc|gm}
+
+commit 35816e118b327a150a2d26638f289633f5e51f16
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sun Jan 6 17:56:23 2008 +0800
+
+ Add spec for Time.local to handle string arguments (excluded for now)
+
+commit f9f36f5bb99ddb62e15cb9a9ddd98414e3df93e2
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Sat Jan 5 23:44:33 2008 -0800
+
+ Allow Regexp to match nil.
+
+commit e650c39627b81498fc97c51725f2ac1277870e15
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Sat Jan 5 23:38:52 2008 -0800
+
+ Add some IO#read specs
+
+commit 20257ecce0d3161fae7ac78454f2b8672f2c1de3
+Merge: bc576b8... e549cc5...
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sun Jan 6 14:45:13 2008 +0800
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit bc576b8e26fdb43d050df4fe3ad5ed974ec85057
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Sun Jan 6 14:44:44 2008 +0800
+
+ Fix handling of string-like second parameter to Time.local
+
+commit e549cc53a4905f21082a97cd6bcb279ace6d9eae
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Sat Jan 5 22:31:42 2008 -0800
+
+ Don't shift more bytes than available in the Buffer.
+
+commit 71285a2a9a8d0d3e71c678872ff2a146d5b2dc16
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Sat Jan 5 22:53:51 2008 -0500
+
+ Fixup the Process specs for setpgrp, getpgrp, setpgid, and getpgid.
+
+ They no longer may unwarranted assumptions about the relationship
+ between a progress group ids and process ids.
+
+commit 7b57b3ac6df612f81d60d3a31b030ba054b357a6
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 5 13:22:51 2008 -0800
+
+ Patch from Brandon Mitchell for #195, Float#to_s bug.
+
+commit 70ddfd43fd727122f56e8bdfcf3febd1ac1b5479
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 4 01:01:11 2008 +0800
+
+ Fix for Time#yday spec when Time.at might return yday+1 depending on tz
+
+ * Wrapped Time.at in a with_timezone("UTC") for consistent results
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 7d4396e4e69fb7b046efdaaf87d1090a02c883a0
+Author: Kamal Fariz Mahyuddin <kamal.fariz@gmail.com>
+Date: Fri Jan 4 02:26:38 2008 +0800
+
+ Fixed Array#fill behavior when passed index and negative count
+
+ * Added additional spec when negative count is acceptable
+ * raise ArgumentError when negative count absolute value exceeds index
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 8af2b55313eb55082df6a71cd3e6bd865f2901fc
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Jan 5 13:33:26 2008 -0600
+
+ Save mtime during file creation to make mtime spec more reliable.
+
+commit 7043933af0475370462984c8d2df2b9301e58cfa
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 5 00:45:01 2008 -0800
+
+ Updated CI excludes after spec description changes.
+
+commit 3d7650100ba1756a4d67be8044e31498ea96d88e
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 4 21:13:28 2008 -0800
+
+ Multitudinous style cleanups in spec description strings.
+
+commit d54ed8791a74661adb87c938e92e037ece924c90
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Sat Jan 5 00:29:22 2008 -0800
+
+ A real, working eval and friends.
+
+ * Implements binding, eval, etc.
+ * Passes all eval and instance_eval specs currently
+
+commit 02ad19ab4132bf5d3ae35c2e11fa1a963d1f1805
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri Jan 4 00:25:39 2008 -0800
+
+ Fix a few more String specs, fix Integer()
+
+commit d67cfbcf4e7d35641de555ac1edd61b51780def8
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Fri Jan 4 19:16:43 2008 -0800
+
+ Make class variables work with inheritance.
+
+ Move class_variable* to Module.
+
+commit d79836e04d72796b723cdaab228871c87abe064a
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Fri Jan 4 16:26:21 2008 -0800
+
+ Replace Struct with a Struct that can be subclassed
+
+commit 8efb042a9c160af9e9c177ca14aed220dedcc26f
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Fri Jan 4 15:41:43 2008 -0800
+
+ Finished |*args| spec. Fixed MethodDescription and TestGenerator inspect methods
+
+commit 76cc487434f6cd9d60356560f1bbc3fba000397c
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Thu Jan 3 16:54:56 2008 -0800
+
+ Fuck you git. Adds a broken spec to compiler2/masgn for splatted goalpost arg
+
+commit dd2697b602a732e3e00c131f54f9cc557ae0cbe3
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Fri Jan 4 15:40:50 2008 -0800
+
+ Failing spec for case when with an empty body
+
+commit 22dcedebd484f655bba51399e38e83c5a14d4053
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Jan 4 18:31:48 2008 +0100
+
+ Added Time#local specs with string-like second arg.
+
+commit 43ff733a3097fff44ba8a12334f20a1bf77a965f
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu Jan 3 23:54:34 2008 +1100
+
+ CompiledMethod#decode now uses local variable names (if avail)
+
+ * CompiledMethod#decode now looks in the bonus tuple for the names
+ of stack and slot local variables
+ * Moved compiledmethod specs to spec/core/compiledmethod
+
+ Note: Compiler2 appears not to be setting the bonus tuple, so code
+ compiled under it cannot decode local names at present.
+
+commit 06006ec2a053ae49b243fa0aa98fc71c2ea7a524
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 4 01:24:49 2008 -0800
+
+ Updated CI excludes.
+
+commit dff2e75df3c371522b6a3ba4495d269bf793fe97
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 4 01:01:24 2008 -0800
+
+ Updated CI excludes for Bignum.
+
+commit 569fa3b9fc81410ce9fe6568427f0a0bc65b7036
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 3 19:26:22 2008 -0800
+
+ Updated CI excludes for String, Regexp.
+
+commit 7aedec383850eacad5db8248bfcea7615a3d1793
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 3 17:48:32 2008 -0800
+
+ Fix up setrlimit/getrlimit on darwin
+
+commit d9aea8bba7276b53ca7c18b8625531be389d2cdc
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 3 16:40:09 2008 -0800
+
+ Refactor $~ out as a global, into Regexp.last_match directly
+
+ * Uses MethodContext to store $~ now, so it's method local.
+
+commit c19dde305fd751c14a1b4dc798557e0b63c08c8d
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 3 16:25:54 2008 -0800
+
+ Clean up compiler2 specs
+
+ * For is still broken, needs more love
+
+commit d02603a7e225d3b48ecf7899ea74768880aba7ec
+Author: Gregor Schmidt <ruby@schmidtwisser.de>
+Date: Wed Dec 12 16:56:11 2007 +0100
+
+ Add default implementation of Module#method_added
+
+commit 7ba5d1478106e4e0f5fcf21c66029df2f38d7e2f
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Sun Dec 30 17:55:21 2007 -0500
+
+ Unquarantine Process.kill specs.
+
+commit d68b380bdd2e0a0ec3bd968ffabd02f6e30a3aa1
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Tue Jan 1 22:14:59 2008 -0500
+
+ Improve kill, wait, detach, and setpriority specs for Process.
+
+ Restore any previously installed signal handler after the spec has run.
+
+ User IO.read(1) instead of IO.getc since rubinius has it implemented.
+
+ Fix a failing Process.detach spec uncovered by the raise_error fix.
+
+commit da7329d094b6ff437d37e6a1fcaf93883ac9172f
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Mon Dec 31 16:23:24 2007 -0500
+
+ Add specs for Process.setrlimit, Process.getrlimit, and Process.setsid.
+
+commit 42bef2feb46434b0ea67bc3f93d941d587c2d9c9
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 3 12:46:57 2008 -0800
+
+ Updated Process spec excludes.
+
+commit ca98172b8a923cce1691b0fcc5d2418417d82662
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 3 10:07:55 2008 -0800
+
+ Update CI excludes for IO from Evan's fixes.
+
+commit cde20d6c32156e4fc06859f1e84414f81f5af69e
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Jan 2 23:40:59 2008 -0500
+
+ Fixed #require specs.
+
+commit 06d99a2ac4be06b50848056b381c91531293a49e
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Jan 3 01:12:29 2008 -0800
+
+ Add read buffering to IO, passes 100% of IO specs
+
+commit 86170283715371b5a87c0518f89c2b882a49bc93
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Thu Jan 3 01:21:52 2008 -0600
+
+ Fix off-by-one on a few signal values. Doh!
+
+commit c7a64b10410308cec83077a66cda5859b326f296
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Thu Jan 3 01:13:27 2008 -0600
+
+ Modify Signal.list spec to not depend on hash ordering.
+
+commit f2980d9584c08d873cf1646c281d083946bcbc6c
+Author: Nitay <nitay@powerset.com>
+Date: Wed Jan 2 14:36:56 2008 -0800
+
+ Module#autoload:
+ * raises a NameError when an invalid constant name is given
+ * raises an ArgumentError when an empty filename is given
+ * does not autoload when the specified constant was already set
+ * registers the given filename to be loaded the first time that the Module
+ with the given name is accessed
+
+commit e68bd05defe5ab749110af507c86769c9a036b25
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Wed Jan 2 19:04:48 2008 -0600
+
+ Removing 'Range#initialize can't be called twice' spec.
+
+ Evan agreed that these specs aren't useful, and I don't believe they're
+ within the bounds of reasonable language specification since they're
+ going around visibility and testing behaviors no sane programmer would
+ ever be able to see.
+
+commit 1870720bac174feb627654f08c1749e1666c2acc
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Wed Jan 2 18:54:33 2008 -0600
+
+ Fix inspect spec to guarantee the target thread is actually sleeping.
+
+ A reminder for folks adding Thread specs: You *CAN NOT* know that a target
+ thread is sleeping unless you are polling for status == 'sleep'. No amount
+ of channel, lock, or state variable tricks will get around that. Please
+ use polling if you want to guarantee a target thread is asleep.
+
+commit df3057a541862bbd1c5c72b8626bb591bb5ae6fd
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Wed Jan 2 16:39:37 2008 -0800
+
+ Refactor Module#undef_method spec to #respond_to? and #instance_methods.
+
+ Now only method dispatch is tested for #undef_method. #respond_to? and
+
+commit d2ecd4119a152370210ccb6c2a816c9dccb9fe90
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Wed Jan 2 16:00:09 2008 -0800
+
+ Fix Rails indenting and whitespace
+
+commit f5b8afee4931bd09b0ce9fb88fc959c2ea0a1743
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Wed Jan 2 15:30:41 2008 -0800
+
+ Fix Module#undef_method and Module#instance_methods
+
+commit 82bf31562361a21f85a90d5628a40ff50280c555
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Wed Jan 2 14:10:35 2008 -0800
+
+ Rebuild excludes for #eof?
+
+commit b2aa0d56b04d7da5d333ba1449acda7c0b64c0c4
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Wed Jan 2 14:09:21 2008 -0800
+
+ Add IO#eof? spec.
+
+commit addeb47d834d1ce60f8146f747defacf1682e6c4
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 2 22:31:30 2008 +0100
+
+ Removed JRuby spec excludes.
+
+ The JRuby excludes will reside in JRuby repository.
+
+commit 3239661ed5c38b37c966588341a043d6cdd9445b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Jan 2 21:28:11 2008 +0100
+
+ Corrected String#modulo tests after clarifications from ruby-core.
+
+commit a0f3ba6632f8486e8f07a21a8e4720d8727ba4d2
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 2 11:28:42 2008 -0800
+
+ Fix require_spec_recursive on Ubuntu.
+
+commit 857c39564df2d8da480f549fff46ec3ab880066e
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 2 00:48:53 2008 -0800
+
+ A couple fixes. Updated CI excludes for last couple failures.
+
+commit 58c48ed05b493c71ee445062f27d47909e18b395
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 1 23:49:14 2008 -0800
+
+ Updated CI excludes.
+
+commit 426f5a15eaac05ed1e900433837de0b9d0246c8d
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 1 22:43:47 2008 -0800
+
+ Moved CI excludes files from .spec dirs to spec/data/*.
+
+commit a1d6211f3185f23cbc2c929f0352feca05fd079c
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 1 22:03:43 2008 -0800
+
+ Moved ruby specs to spec/ruby/1.8/...
+
+commit af55eefd29c8acaf462efe03d2e0b3d95195cb21
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 1 21:44:35 2008 -0800
+
+ Updates for bin/ci and bin/mspec.
+
+ * Removed -2 switch from both because compiler 2 is default.
+ * Added CI_EXCLUDES_DIR and -E switch to bin/ci to allow for
+ specifying the exclude directories. The default is '.spec'
+ in each directory containing spec files. Use a path starting
+ with a '/' to create the exclude directories relative to
+ that path, otherwise the exclude directories are created
+ relative to the directories containing the spec files.
+ * Moved spec/excludes.txt to spec/data/critical.txt
+
+commit 0e6645eb74f1f63b84f674dbcdfa991153a3ccd0
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Jan 2 12:10:39 2008 +1100
+
+ Couple of Breakpoint changes
+
+ * Raise ArgumentError if no block given (spec for this
+ existed, but was masked by RaiseErrorMatcher bug)
+ * Added line property to Breakpoint
+
+commit 36a7acddfe74ab25895d13dd775741b042ba3b0c
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Jan 1 23:10:13 2008 +1100
+
+ Reorganise breakpoint specs to new dir layout
+
+commit 8aa6712dd9e5e870194f77ff74dc8cf11c273805
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Dec 21 16:15:19 2007 +1100
+
+ Refactored BreakpointTracker in preparation for debugger
+
+ * Moved code from debugger.rb to breakpoint.rb
+ * Refactored code extensively to support debugger
+ * Added breakpoint specs
+
+commit d16e905a67d64f67d7a24ce113f39b4b059c4139
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 31 17:51:59 2007 -0800
+
+ Removed the rubinius dir from specs. It was redundant.
+
+commit 85ed07b6d739f013892a6cbcae5d0bb2c19f6e80
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 29 15:45:31 2007 -0800
+
+ Split Ruby specs proper from Rubinius specs.
+
+commit b8e1466dc1b814bfb2022c1e4319d5ba63f5d762
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 29 15:02:55 2007 -0800
+
+ Updated guards in specs.
+
+ * Changed guard names to new, more descriptive names.
+ * Removed all #extended_on guards for Rubinius-only specs.
+
+commit 5773ebe9e6f78abec9bfb03f144b5c7a86a27c7e
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 29 00:50:56 2007 -0800
+
+ Changed Float constants specs to compare against precise values.
+
+commit 71874fcdc9eaf45a5adecf57d7609831a2a8e6c2
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Dec 29 17:26:06 2007 -0600
+
+ Fix dump_spec to expect 1 or more write calls, rather than exactly 1.
+
+commit d4bfb39910aa4adf2c0c4e2dee214487bac34093
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Dec 29 14:51:38 2007 -0600
+
+ Add a spec for procs being block-passed and some peculiarities therein.
+
+commit 1b0333479bf6da2c76c8d3c1e1640dc156086d9f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Dec 28 08:24:30 2007 +0100
+
+ Improved ObjectSpace#each_object spec test.
+
+ Previously, the test was failing from time to time,
+ depending on Garbage Collector behavior.
+
+commit 3d7e628acc6699f9652383317bd416d8c75329d5
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Fri Dec 28 05:27:24 2007 +0100
+
+ Updated Time specs to use new :os guard.
+
+ The Time specs use this :os guard to properly detect
+ which external program with proper parameters to invoke.
+
+commit 7662638e9afa631f0581fc1c2b2b422b1b926f98
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Sat Dec 29 03:06:51 2007 -0600
+
+ adds Marshal.dump specs
+
+ for nil, true, false, String, Symbol, Fixnum, Bignum
+
+commit 93431a28d687372b95f1a1420a3bd1f24e660117
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Dec 29 00:15:44 2007 -0600
+
+ Guard Continuation specs to not run on JRuby (JRuby does not, will not support continuations)
+
+commit ccf745b9eafe068de6f888de24387bc0a0e68859
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Sat Dec 29 00:08:04 2007 -0600
+
+ Fix for Fixnum size spec to guard "java" platform with 8 byte size
+
+commit 6f448f0dd72b5df2cc69e28db3d5593f897a9dbd
+Author: MenTaLguY <mental@rydia.net>
+Date: Sat Dec 29 00:58:58 2007 -0500
+
+ a more modest spec for Thread.pass
+
+commit b32c2d95d044a4979ab92b5881e32fc8b169d931
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 23:51:10 2007 -0600
+
+ Adjust Float MAX spec tolerance to work on both JRuby and MRI, since there's a few powers of precision difference.
+
+commit af7bb00beeb359fd6183def039b9a1fcd0ce7c48
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 23:39:15 2007 -0600
+
+ Expand Float divmod array equality comparisons to use be_close with a default tolerance.
+
+commit dbdf373751bce2c8a334315c8c5ed21458614c70
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 23:34:09 2007 -0600
+
+ Add a tolerance to the Float induced spec around the same scale as the value under test.
+
+commit a713d277e6a8148d4c53b66a3a8fa3aedbd6a108
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 23:31:25 2007 -0600
+
+ Modify Float multiply spec to be_close with a TOLERANCE multiplied by a similar scale as the value under test.
+
+commit b82d8af43356de31d16b1c36296d9e819ce70d46
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 23:13:38 2007 -0600
+
+ Fix Module class_variables spec to sort the variables before checking if they are all there.
+
+commit 1e60a25b57273dd6fd7e21b0a443da1f5c0be9e5
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 19:44:51 2007 -0600
+
+ Mark Process#fork specs as not_compliant_on jruby.
+
+commit 021a6ff317ed826a46ca2168f4ee9c7540a27214
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 19:19:14 2007 -0600
+
+ Remove fail and "failure" guard around the require/extension spec, since an unimplemented spec isn't necessarily a failure of any kind.
+
+commit 520c423860ef6553dae34eefd85188ab9b4773f6
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 19:12:52 2007 -0600
+
+ Modify previous compliance change to callcc spec to use not_compliant_on instead.
+
+commit ab85bfff2f9fea8e28f9518311aacccd30f380dd
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 17:56:42 2007 -0600
+
+ Remove compliance guards on identical spec's link/unlink, since they don't blow up now and JRuby supports them.
+
+commit e79c8af0ad6fb7ddf094b6ba4747932145f9b89b
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 15:19:24 2007 -0600
+
+ Removing "fail" and "failure" wrapper from unimplemented "loads extension files" spec; an empty or unimplemented spec is not a failing spec.
+
+commit 0f6b7387bcc8df946ec8d7504cc3935b6d0f9c58
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 15:06:07 2007 -0600
+
+ Add compliance to callcc specs, so JRuby doesn't run them (since it never will)
+
+commit ed43292ce58468e31b771eb4926a39dff8d70793
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 14:48:45 2007 -0600
+
+ Make umask spec work with different host process starting umasks, clean up literals to be easier to read through.
+
+commit 7e9f96741739e544c547f2898e8b5183dec87323
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 14:43:02 2007 -0600
+
+ Fix goofed-up paths in requires for rubinius-specific Integer spec
+
+commit d54fb1e7c3f586a6d8ac200d6de839ebe6cb4c46
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 28 14:40:50 2007 -0600
+
+ Move rubinius-specific spec from core/kernel/Integer_spec to rubinius/core/kernel/Integer_spec.
+
+commit eb561025707736ebe196eab3b4ff2bd1c98f45a4
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 27 23:51:42 2007 -0800
+
+ Fixed language/block specs to guard ruby18 feature.
+
+commit 5659d057d756effe3acba1037d0ad6d638d930dd
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 27 22:58:17 2007 -0800
+
+ Changed Bignum specs to use value suitable for all implementations.
+
+commit 2646b1a17f898f05233622c9251c3c36632e82a7
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Thu Dec 27 23:43:42 2007 -0600
+
+ implements m directive for String#unpack
+
+ moves a couple misplaced methods from Numeric to Integer
+
+commit 496d6761d7377081ff76b263a51bb39d0e30d80a
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Dec 26 18:07:45 2007 +0100
+
+ Marked one Rubinius-specific Kernel spec test as such.
+
+ Kernel#compile is not official part of Ruby.
+
+commit 50e35293bd3a117874203a75d214c3435170e5d3
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Dec 26 17:43:03 2007 +0100
+
+ Corrected String#pack with 'DEFG' pattern test.
+
+ Now, numeric comparison of values is used, with precision,
+ not literal string comparison.
+
+commit 0ef00fe14a04ef240fcca17d15271f92f2a44525
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Dec 26 16:00:20 2007 +0100
+
+ Added String#inspect test case with malformed UTF-8 string.
+
+commit 5bbde0cda03ea782090586a9afdb620663633456
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Thu Dec 27 13:30:34 2007 -0600
+
+ switched ThreadGroup specs to use Channels
+
+commit e3abd8b834b9f923d94ae381e81977feb4a4f6f8
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Thu Dec 27 13:22:20 2007 -0600
+
+ added Thread#stop? and fixed Thread#status + specs for Thread#status
+
+commit f8835353bc8be47760f70811616991463e4e681e
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Dec 26 09:18:24 2007 +0100
+
+ "Unexcluded" one Struct spec test for JRuby.
+
+commit 8a1b127cb33e43b916b0ccd820c6e16680cd4030
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Dec 26 09:12:23 2007 +0100
+
+ "Unexcluded" 6 Hash tests for JRuby.
+
+commit ae4ce805fb7611ea6de12b01b2500f501b54bd6a
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Wed Dec 26 09:01:35 2007 +0100
+
+ "Unexcluded" 27 Array tests for JRuby.
+
+commit c84540f96d7e265732a204ed72b3873545624444
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 27 00:08:06 2007 -0800
+
+ Fixed Set#delete? spec to actually call delete?.
+
+commit e137c3279f511b49442ce2cea1b1832c1a0c6ab0
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 27 00:00:56 2007 -0800
+
+ Added some specs for Set.
+
+commit 8054ed86a93a72ad4629d6f52455892d620138b0
+Author: Nitay <nitay@powerset.com>
+Date: Tue Dec 25 17:30:56 2007 -0800
+
+ require should prevent recursive includes infinite loop
+
+commit 23fb497a7ba2a853cbdc5e8a38b091df284a377e
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 26 16:50:22 2007 -0800
+
+ Updated status output options for bin/ci and bin/mspec.
+
+ * Made dotted the default output format for bin/ci.
+ * Added -m MARKER option to ci and mspec.
+ * Added "Started" output as requested by autotest folks.
+
+commit 036b073753763afe86330d3f7fa0f61d755ac991
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Dec 26 10:41:01 2007 -0500
+
+ Moved class fixture back to spec/fixtures/.
+
+commit 91d46b86a86270bb3174909a2d5cbc343ea138c7
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Dec 25 19:20:18 2007 -0500
+
+ Added specs for $~, $&, $`, $', $+ and $1..N.
+
+commit c434614505511b8816548efcf4a4cf56d77220f4
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Dec 25 19:19:11 2007 -0500
+
+ Improved language-level class specs, moved fixture.
+
+ * Class fixture copied to spec/language/fixtures/.
+ * Disabled unnecessary class instance variable check and added
+ new ones.
+
+commit 0a49f3485fe7e26cc7d7d5bc3cb800ddf9fd6231
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Dec 25 19:13:22 2007 -0500
+
+ Changed strange_block_args_subspec.rb to block_args_subspec_strange.rb
+
+ * Name change to improve alphabetical sorting.
+
+commit 2ac50215dd32fd7ad2f2c20c7ae06ed73dc9f856
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Dec 25 13:32:06 2007 +0100
+
+ Added tests for Array#pack with "U" pattern.
+
+ Note: The tests are exclided for Rubinius.
+
+commit 4c0993fa90010322bb823a9799a8b3ccdd585e2e
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Wed Dec 26 04:07:02 2007 -0600
+
+ return excluded spec
+
+commit 0a69d9cd5a7d3a0be9411fa00c4eeebe5d270a0c
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Wed Dec 26 03:55:43 2007 -0600
+
+ implements @AM directives for String#unpack
+
+ squashes bug in a regexp where an alternation of things
+ between begin and end assertions wasn't wrapped in group delimiters
+
+commit ddda4d49f5535577c147d2154ecdae7cb4e32e24
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 26 01:16:13 2007 -0800
+
+ Moved Kernel#load/#require fixtures to spec/fixtures.
+
+commit 0438e9e61c5958c5daf691b025e34bc79e7b2573
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 26 01:06:12 2007 -0800
+
+ Reorganized specs to group all Rubinius specs under spec/rubinius.
+
+commit a4c3e286e44ee3df88395b9b5f44d5804154ed2b
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 25 19:32:55 2007 -0800
+
+ Updated CI excludes.
+
+commit 8535481571712cf8c35f437c42ec53dcbfd44bc0
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 25 15:52:53 2007 -0800
+
+ Enhanced guard for detecting :ruby, :ruby18, :ruby19 engines.
+
+ Changed dir specs to create the fixture directories with every
+ run to prevent pollution of the directories from causing spurious
+ errors.
+
+ Added spec/core/dir/fixtures/mock to .gitignore.
+
+commit a6b07ec37da7a59f34f45dfc84a66729b12f63b7
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 24 16:25:16 2007 -0800
+
+ Removed Dir specs mock directories from version control.
+
+commit b0e4addbf7c6505c760e143e5fac0dab0109d8ac
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Dec 25 13:17:28 2007 -0500
+
+ Updated CI excludes for Dir.
+
+commit 80a9c6c2e2e5cd2acdcb6492c4a06fef258bb49e
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Dec 25 13:17:09 2007 -0500
+
+ Moved Rubinius-specific parts of #load/#require specs to extensions.
+
+commit 85f6b6e24518868f39ff39a5014a41a233237671
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Tue Dec 25 02:53:45 2007 -0600
+
+ implements U directive for String#unpack
+
+ uses only one of the exception messages every time
+
+commit b414c94db1fa1af8e6cd3382c34fc6de5ed3bd1e
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Mon Dec 24 16:42:22 2007 -0800
+
+ Merge identical specs
+
+commit e0f28c224a2348dbf7c005694971a86f8e6162e1
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Mon Dec 24 15:59:24 2007 -0800
+
+ Kernel.Integer() shouldn't pass a base to String#to_inum
+
+commit eb93da7c578599469fe209f7b1d30f0f77d148f5
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Dec 23 16:43:33 2007 +0100
+
+ Wrapped one String#crypt case into compliant block for JRuby.
+
+ "hello".crypt("\x00\x00") is not really defined,
+ and heavily platform dependent.
+
+commit 7594c89cf2f017cb1fffad16bac6fcc7c9629422
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Sun Dec 23 10:53:30 2007 +0100
+
+ Added JRuby wrapper for String#% test.
+
+ Allow "%e" % (0.0/0) in JRuby to return "NaN", and not "nan".
+ I think, returning "NaN" is a proper behavior, and
+ it seems that MRI 1.9 is also following it.
+
+commit eaf9e328e81f9c1d4e80737a96d0eea6b511fabb
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Mon Dec 24 06:55:30 2007 -0600
+
+ implements BbHhIiLlSs directives for String#unpack
+
+commit 701945421d6a656f8b0b183052c4535a895e2afd
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 24 00:44:26 2007 -0800
+
+ Converted specs to use the new #platform guard syntax.
+
+commit 238fbbc2331a1926f3d3f447d8433b046e7d34ac
+Author: Tom Mornini <tmornini@engineyard.com>
+Date: Sun Dec 23 15:43:26 2007 -0800
+
+ Clean up language on now understood and fixed alias_method e2mmap spec.
+ Fixing the alias_method problem has now uncovered something in const_set,
+ so I've included a very vague test (require 'e2mmap') to document the
+ problem until it's better understood.
+
+commit 69149b261ac13cc1a2b7c80c7b103d397fd96b9b
+Author: Tom Mornini <tmornini@engineyard.com>
+Date: Sun Dec 23 14:13:22 2007 -0800
+
+ Add spec for alias usage that breaks e2mmap.rb
+
+commit 71d9a4144811b2c9c74edc55f348637c57b0cb84
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Sun Dec 23 05:25:37 2007 -0600
+
+ implements aDdEeFfGgXx directives for String#unpack
+
+commit bebafb1383a5126c959c33a1336f3a2e4b6993f6
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 18:16:14 2007 -0500
+
+ Saner specs for stream-style Dir access. Passes 1.8.6-p111.
+
+ * Dir#read, #tell, #pos, #pos=, #seek and #rewind which are a part
+ of the stream interface to Dir no longer rely on platform-specific
+ position values, instead opting to just ensure they work as expected.
+
+commit a2e4c318a3406c9532404611f14d2790695c0a7a
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 16:29:00 2007 -0500
+
+ Enabled Time#at spec to work with BSD `date`.
+
+commit 0e983f2e948ab997834dbc703e9eeb11d86a7022
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 16:17:14 2007 -0500
+
+ String#to_i spec to check for correctly parsing 0x-1 and the like.
+
+ * This was fixed in 1.8.6-p111.
+
+commit 5e635a46f4733bcc2071b52ea076584614fe5655
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 15:52:03 2007 -0500
+
+ Fixed various String spec issues and added a few. Passes 1.8.6-p111.
+
+ * String#% with o for octal numbers is still broken but that seems
+ to be due to MRI's sprintf.c.
+
+commit 780f22bde03e280f5af2509bef260585341f4e0b
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 15:48:55 2007 -0500
+
+ Fixed incorrect use of #should raise_error.
+
+commit 0b239b4f66c20ad5690e429639c4bf11a809ab58
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 12:22:20 2007 -0500
+
+ Hash specs fixed. Pass under 1.8.6-p111.
+
+ * Changed to use HashSpecs#frozen_hash and #empty_frozen_hash
+ for clarity and being less error-prone.
+ * Fixed various typos causing problems.
+
+commit 9a2450e5c51333474cf012c3a1364e95384af9e0
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 12:20:48 2007 -0500
+
+ Kernel.caller specs revised. Pass 1.8.6-p111.
+
+ * Fuzzier matching of the data in the call stack.
+ * Fixed specs for omitting frames.
+
+commit 692f4e8a652e273096c0f77ffe571318c59d2b12
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 10:59:19 2007 -0500
+
+ File.ftype specs pass on 1.8.6.
+
+ * Use `find` to locate specific file types instead of relying on
+ predefined paths being correct.
+ * Re-enabled character devices.
+ * FreeBSD does not implement block devices.
+
+commit f1251ebc602311ec305a4b1b35a765ee45b9c164
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 10:11:07 2007 -0500
+
+ Bignum#div returns an Integer if evenly divided.
+
+commit b62e1b7a21df1d7736767530f216148b8a93e38a
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 09:52:33 2007 -0500
+
+ Fixed Array spec failures under 1.8.6-p111.
+
+ * Array#fill raises if given a negative count.
+ * Array#initialize will always raise if frozen.
+
+commit e3d6a3df6c1dfc37731ff4de5de32dc996bb61bb
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 09:37:46 2007 -0500
+
+ Silence warnings from removing *.rbc in #load and #require specs.
+
+commit a11171e853b3efb94b4cba03786ea851d81411c6
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Sat Dec 22 07:39:40 2007 -0600
+
+ implements CcQqVv directives for String#unpack
+
+commit eea90994f2a1b76ed11b29e05a16c9c299d59235
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Dec 22 00:23:29 2007 -0500
+
+ Added __FILE__ specs to #load.
+
+commit 0e04ca49ebdba35a7a293b6de82d9d67c6ff4ac5
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Dec 21 22:59:50 2007 -0500
+
+ Correct __FILE__ information from #load and #require.
+
+commit 51c2543fe032b680a6c8f8cf8121196070c61c66
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 21 23:51:37 2007 -0800
+
+ Replaced use of @path1 with equivalent nil in File#fnmatch.
+
+commit b9f979393456dc3c93250e3a50b54b489a25c5d1
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 21 23:29:51 2007 -0800
+
+ Added -w to bin/mspec to emit warnings. Fixed warning in mSpec.
+
+commit 16ce249216f490b9f7921aa69932f9e8bd60ca0e
+Author: Jeremy Roach <jero_rub@yahoo.com>
+Date: Fri Dec 21 22:50:40 2007 -0800
+
+ Implements N, n, and Z directives for String#unpack.
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit e1d292e28fe409c087f314bb139371a1f248850d
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Thu Dec 20 15:04:12 2007 +0100
+
+ Fixed race condition in ThreadGroup#add specs.
+
+commit 469527ddf33484a4a77f3d73c611e9a393bd48ad
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Dec 21 12:02:50 2007 +1100
+
+ Added CompiledMethod#decode specs
+
+ * Added UnboundMethod#compiled_method accessor
+ * Improved robustness of ISeq decode when dealing with junk at
+ the end of an iseq
+
+commit 08c2f5c29a2debed90ae1fff817c30e269913609
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Dec 20 23:45:53 2007 -0500
+
+ Re-enabled purging .rbc files in require_spec and fixed the masked problem.
+
+commit dd4f3c52e79d01e826918e49fa626d7358f87901
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Dec 20 22:53:48 2007 -0800
+
+ Clean up a couple of failures seen in ci. spec/core passes.
+
+commit a5667632ae8d112c0271e00cbba53a274075cd1a
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 20 22:49:05 2007 -0800
+
+ Removed legacy, unused spec/reports/base.txt.
+
+commit 853e100b6f7fff24e4aaa40ed30c6add523f8df2
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Dec 20 17:49:36 2007 -0800
+
+ Fix a bunch of String specs (thanks random8r)
+
+ * Note: rubinius now has the same behavior as MRI for Nan,
+ Infinity and -Infinity when using String#to_f
+
+commit b220f4921fd799ac28c60132ca08cf16df6f713e
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Thu Dec 20 15:37:25 2007 -0600
+
+ fixed require specs to work correctly on any run including first
+
+commit 56ac483e3559e1d4913e4c36c9a8f007523fdab0
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Thu Dec 20 19:36:21 2007 +0000
+
+ Fix typo in spec/core/regexp/union_spec.rb
+
+commit 634300eed40ef0ded16ab7cac7865dd783486c2d
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Thu Dec 20 03:46:59 2007 -0600
+
+ Add 'sleep' checks to threadgroup spec to avoid the same race conditions seen in kernel/sleep_spec.
+
+commit 72b7123c9b3d1d266f4ce035b4e99dd0c2dbd88d
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Dec 19 22:46:17 2007 -0500
+
+ New compliant (moreso, anyway) #load and #require.
+
+ * Improved #load and #require.
+ * Specs for the above.
+ * File.to_sexp and String#to_sexp allow empty input. They are
+ processed as a file containing 'nil'.
+ * Archive#get_object_fuzzy allows no extension or .rb instead
+ of .rbc only.
+
+commit fe633062095096fe00599cbb89aa4370ab5ccb3e
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Dec 19 23:03:08 2007 -0800
+
+ Fix Kernel#puts
+
+commit 364ca08cbbb1848b549d99deb11e2449ad99334a
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 19 23:10:17 2007 -0800
+
+ Updated CI excludes.
+
+commit 5f1c381560a8d4d594749d42b5b2feeec341d4e5
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Dec 19 22:24:10 2007 -0800
+
+ Fix Kernel#open
+
+commit 3b3ed6304deab01cb448665c5f4b17d813f04e65
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Dec 19 21:43:58 2007 -0800
+
+ Cleanup more method specs, all pass on rubinius now
+
+commit 76bbbf275f4e835444f684b2e688b292f20c1ffe
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Dec 19 18:08:09 2007 -0800
+
+ Implement protected methods
+
+ * Added a bit more verbose specs to methods_spec.rb, to show
+ specific cases.
+
+commit dce06b35481bb1951c587d36f63abaae069d0ae4
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Dec 18 22:28:30 2007 +0100
+
+ Wrapped one String#unpack test case into compliant block.
+
+ The test case is platform-specific, and not suitable for, say, JRuby.
+
+commit bb4945ea7b9253150f753508e92633b6e355194a
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Dec 18 21:30:24 2007 +0100
+
+ Added new String#unpack test to exclude file for CI.
+
+commit 1bd8beb8e0b335f1de309d6320312a1b64af1e4d
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Tue Dec 18 19:51:47 2007 +0100
+
+ Added more tests for String#unpack with Z/Z* patterns.
+
+ These patterns are known to be tricky, and their
+ handling was changed during Ruby's life.
+ See [ruby-talk:98364].
+
+commit d26edc2269a77667dbefcfb1ea6212d8ada9ef97
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Dec 19 01:25:27 2007 -0800
+
+ Fix a bunch of Task GC problems, better memory management.
+
+ * Use ALLOC* macros instead of malloc/calloc directly
+ * Also, simple fix for Time
+ * A Kernel#loop implementation
+
+commit 4143b92e6112241ff2facd64047491ce579bf0e9
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 19 00:43:32 2007 -0800
+
+ Finished converting Object.new to mock() in specs.
+
+commit 9cae61f827d2eeca0a744e551551efd6bc85a2ae
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 19 00:02:46 2007 -0800
+
+ Spec #it blocks must be inside #describe blocks for RSpec.
+
+commit 7df00ef6d2471d0b37829e0a4d1ef45edf782a44
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 18 23:28:43 2007 -0800
+
+ More conversion of Object.new to mock() in specs.
+
+commit 12463512d0ad48fae3a1843d9d409649551dd13b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 22:53:38 2007 +0100
+
+ Corrected String#* test to pick large enough Bignum, even on x64.
+
+commit 79cbff2c9a0cb15e9e5767f94242fa4360a0c4a0
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 16:43:16 2007 +0100
+
+ Removed race condition from Kernel.sleep spec.
+
+ This problem caused JRuby spec runs to hang.
+
+commit 3032e60e10dd1ae61ffb40b351f4f6731395602b
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 15:43:42 2007 +0100
+
+ Enabled one Hash#rehash test case for JRuby
+
+commit 1808106191856f4f82b948abc5c7e708a747d059
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 15:40:49 2007 +0100
+
+ Issue #153: Hash#rehash test enforces unspecified impl detail
+
+ Wrapped the test so that it won't run with JRuby.
+
+commit efbf30477ea289911d9cafbde89ecbe2c8c65089
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 15:25:23 2007 +0100
+
+ Corrected :mri --> :ruby
+
+commit 60a3ede3c64b62fb26905ed1c236c0e241b64515
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 15:23:42 2007 +0100
+
+ Issue #182: String#to_f spec corrections for NaN, Infinity
+
+ JRuby AND Rubinius treat "Infinity".to_f, "-Infinity".to_f ,
+ "NaN".to_f differently than MRI.
+
+ MRI returns 0.0 in all those cases, but JRuby and Rubinius probably
+ do something more meaningful, they return Infinity, -Infinity and Nan
+ respectively.
+
+ It was agreed that JRuby's and Rubinius' behavior is a feature rather
+ than a bug, and worth preserving and checking for.
+
+commit 521a82d8c325a33b3409423d61b589c7b8681870
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 15:14:28 2007 +0100
+
+ Refactored commonly used generators into fixtures.
+
+ Thus reducing copy-paste.
+
+commit 86820a339c74e3ca8fc9515e5fdf31ad42780201
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 14:12:43 2007 +0100
+
+ Initial version of Generator specs.
+
+commit 91353183ace65d8e751db14a829e8f24d043710c
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 03:18:19 2007 -0600
+
+ updated excludes for Kernel#sleep and Thread
+
+commit 6de193c0819f74717eb2e9eff8480f0d801b0e41
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 18 01:01:31 2007 -0800
+
+ Replaced Object.new with mock() where appropriate.
+
+commit 1217fa030ff26712e9718ebecfe351830c543d7e
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 02:16:10 2007 -0600
+
+ fixed redo in loop by save/restore condmod around loop context in compiler1
+
+commit df757142c774becfc2cbc4b38e43e31056acbae2
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 02:00:27 2007 -0600
+
+ spec for using redo,next, and break in one loop
+
+commit 7169fd31b7c22750241212c242bc8aacdafe632f
+Author: Vladimir Sizikov <vsizikov@gmail.com>
+Date: Mon Dec 17 13:08:09 2007 +0100
+
+ String#sub specs wrapped to correct JRuby test failures.
+
+ JRuby reports Ruby version to be 1.8.5, but in this
+ particular case it behaves like Ruby 1.8.6
+
+ Differences between Ruby 1.8.5 and Ruby 1.8.6:
+ different error raised.
+
+commit 04e228e131d06cd764d69375ddfdf44e4fec2b38
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 01:27:00 2007 -0600
+
+ spec for Thread.pass and updated :mri to :ruby
+
+commit 11348e25ba30199e3beb05f8c38c18820fbefc3f
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 01:11:38 2007 -0600
+
+ Some minor fixes in Thread specs
+
+commit 5cb3bcbf8f1d2a2237200ca0a9a9c6408d478ad6
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 01:11:05 2007 -0600
+
+ spec and basic functionality for Thread.stop
+
+commit 3301fbb3ec43b5252c0aa6d45eb2f0e21581ff0a
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 01:09:49 2007 -0600
+
+ Thread.sleep doesn't even exist in rubinius
+
+commit bd964f579f84a39097ecee1271664d672b6553a7
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 17 21:40:16 2007 -0800
+
+ Replaced :mri with :ruby for spec guards.
+
+commit d21810882621356c35dcd101daca5ee5549f6607
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 00:42:32 2007 -0600
+
+ Threads should report there status of sleep, aborting, and run
+
+commit 85a6476a236bd1e65d42ca03846c662a10842f37
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 18 00:41:09 2007 -0600
+
+ Thread#status should return nil if Thread terminates with an exception
+
+commit ecb4455a75f4af2ae0059ca4960c2282b4ec632a
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Dec 17 23:50:24 2007 -0600
+
+ specs for Thread#{key?,keys} and added key type checks for Thread#{[],[]=}
+
+commit c1a5d7e52b33ba6686441c61652bcc41ae0547f8
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Dec 17 22:15:37 2007 -0600
+
+ specs for Thread#[]
+
+commit c2c7f0adc6ebbad925adb2471b6064b67528b420
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Dec 17 21:47:52 2007 -0600
+
+ ensure LocalThread#current != Thread.current
+
+commit d05dac276f36326e143aa75bb43e4ab07bd8ddc9
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Dec 17 21:28:44 2007 -0800
+
+ Fix a bunch more Kernel specs
+
+commit 4ddd0e144b4e4f64c51fc8d64952826d92a5e83f
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Dec 17 19:45:26 2007 -0800
+
+ Fix Thread.abort_on_exception and Thread#inspect
+
+commit a12ad6fbc2589a7864a7c784386fb6ce7dae1db1
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Dec 17 21:29:49 2007 -0600
+
+ Kernel#sleep and Thread#join specs now use locks to maintain automaticity instead of while th.status == 'run' loops
+ added a Channel fixture to Kernel to support the use of locks in Kernel#sleep specs
+
+commit 72e3fb453c266e514b817daa66bf6033f1d19e40
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Dec 17 19:01:18 2007 -0800
+
+ Fix callcc specs, revert all locals back to using the locals tuple
+
+ * compiler1 now does what compiler2 is going to do, ie, only use the
+ locals tuple to store locals. Storing them on the stack has proved
+ to be a pain, and wont be used further.
+
+commit 6e35be2ddef8d055e064462c88a8b3f33eb4fe0f
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Dec 17 18:37:16 2007 -0800
+
+ Faster Class#new, initialize can be private
+
+ * Class#new now uses a bunch of inline assembly to be able
+ to call a private initialize
+ * Clean up Module#name a little
+ * Made machine's rbt a little more robust
+
+commit 47a5bbf34ef8a60a18c1c8c6130d493a299ff852
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Tue Dec 18 01:10:33 2007 +0000
+
+ Make sure files opened with "w" are truncated.
+
+commit 0fdc8c9b7d05cc2e96908b280ac144de0d04f646
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Tue Dec 18 00:16:27 2007 +0000
+
+ Fix excludes for spec/core/stuct/{new,struct}_spec.rb
+
+commit 5b1252e6b2d8f8d70343b06f3520114de2040524
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Sat Dec 15 17:31:25 2007 +0000
+
+ Minor fix to struct_spec to include fixture.
+
+commit 4fd0356ab9e9bb5c2a805b1f863b3177458966fe
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Sat Dec 15 16:29:49 2007 +0000
+
+ Add case to spec/core/class/new_spec for names of nested classes.
+
+ * Updated spec
+ * Add some comments where this may be fixed
+
+commit 86736d564f34a2f97f7c7bedcab09c2472861b01
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Sat Dec 15 16:16:26 2007 +0000
+
+ Fixes for struct class names.
+
+ * Tighten up specs to show what class names should be.
+ * Fixes #inspect
+ * (Partially) solves the larger issue of an anon class getting a name when
+ assigned to a constant - works now when Module.const_set is called.
+
+commit ad0d5ff2396baf43c8b2e37a3132765a074b241d
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Fri Dec 14 02:33:23 2007 +0000
+
+ Fixes related to Struct.new
+
+ * Fix to method_table to correctly handle DelegatedMethods
+ * Changed spec/core/stuct/new_spec.rb to allow :rbx to call
+ to_sym on objects passed to Struct.new to get the symbol
+ value.
+
+commit 18f10dc700fe24f3bd230063bc7c1e8a82e8348f
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 17 08:58:22 2007 -0800
+
+ Updated spec excludes to run with bin/ci under the new mspec.
+
+commit 678fb90c5c8aa96e10a9f95f520312f12f8fa3f2
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 15 22:43:44 2007 -0800
+
+ Changed true/false/nil specs to not use def in describe block.
+
+commit 9e132474aafb6a0f0c968c2e085b09bfc07e1a0d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 15 18:49:31 2007 -0800
+
+ Fixes to run the specs under RSpec and mSpec.
+
+commit cd3ecf52645b94921db92393e6e4d295d12bba88
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 15 00:59:11 2007 -0800
+
+ Misc fixes to mspec. bin/mspec -t r spec finally runs!
+
+commit f3b3f70bb47b04e7a67c1dbc3ae38711857b5184
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 13 22:46:54 2007 -0800
+
+ Multitudinous miscellaneous fixups for mspec and mmock.
+
+commit 55ab5b2ee42e4fabcfd8c51d6fac304cdfec31c7
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 10 01:01:58 2007 -0800
+
+ Various fixes to mspec to run Rubinius specs.
+
+commit 86c0f131608b4ad7cba93eabd172a48e5b60ca0f
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 7 15:34:06 2007 -0800
+
+ Added runner guards to omit specs that will always fail under RSpec.
+
+commit 75706dbfabbe359b6410f0d3743f0ea682146ac1
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 7 14:03:46 2007 -0800
+
+ Added #runner guards to mspec.
+
+commit 3da390988031bf0066a849934ee758475ebbfa04
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 7 02:38:13 2007 -0800
+
+ More fixes to run the specs under RSpec.
+
+commit 2b0f4e408b733dcd9089a19d78cd8e4cce20b99c
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 6 18:40:33 2007 -0800
+
+ Yet more spec cleanup to run under RSpec.
+
+commit 1e4171d4682f55776e01e42f564714548c1d9bd9
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 6 02:16:42 2007 -0800
+
+ More changes to run specs under RSpec.
+
+commit db020d30374e419792f76077757784008953c0a6
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 5 02:01:30 2007 -0800
+
+ Various changes to get the specs running under RSpec.
+
+commit 968c2daa5345a0cddb8d3d5bd2b6bf2eeb0c1d6f
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 4 23:51:52 2007 -0800
+
+ Convert remaining mocks to RSpec syntax.
+
+commit e5dc3ac814d1cda923131257dfbc9a30bf501b62
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 4 23:28:17 2007 -0800
+
+ Convert remaining 'should_raise' to 'should raise_error'.
+
+commit a7be230ac71ece2bb8dcece72d629bcd0ce6a5e0
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 4 18:29:26 2007 -0800
+
+ Converted specs from mini_mock to RSpec mock syntax.
+
+commit 4136e2fef4a81eb6e9e14070ff5301638f9acf14
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 4 02:25:31 2007 -0800
+
+ Integrated mini mock with mspec. Updated spec_helper for main specs.
+
+commit d71c0c7412af01d6295d8caab43a80d0221ea16d
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 4 01:49:17 2007 -0800
+
+ Added #shared and #it_behaves_like to mspec.
+
+commit da61adc0a079c858385773b12d683e2f5e2cc0e8
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 4 00:43:15 2007 -0800
+
+ Converted 'should_be_ancestor_of' to 'should be_ancestor_of'.
+
+commit 5ed0096aac58fef09fc766d808aea74356aacfa8
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 3 17:57:56 2007 -0800
+
+ Replaced dev_null with CaptureOutput.
+
+commit 62282bd5cb5c555e6447dcf2d6d0da355913fe8b
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 3 17:30:01 2007 -0800
+
+ Replaced 'should_include' with 'should include'.
+
+commit f990a7c58a7eee6dbbb3c50df7682942048b959f
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 3 17:21:50 2007 -0800
+
+ Replaced 'should_be_close' to 'should be_close'.
+
+commit c53601c56bd222dfacf03f134132869eb71c5146
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 3 17:10:41 2007 -0800
+
+ Finished converting should_raise to raise_error.
+
+commit 165dd99535b0829d2e2364fac24375068969c6ab
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Dec 2 23:22:54 2007 -0800
+
+ Convert should_raise to should raise_error for RSpec compatibility.
+
+commit c9ff50a4b4be25614cc0ac2ea5540cfe87a939d3
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 23:30:44 2007 -0800
+
+ Moved mspec out of spec dir.
+
+commit e9a40a77b6fa7d08969ea195aabbb930b665fe02
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 23:25:59 2007 -0800
+
+ MSpec base formatter and specs.
+
+commit 2fc3ac3f8efbaf0861cadfd59bcdf926d2196284
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 20:32:42 2007 -0800
+
+ Port fix to ruby engine detection from mainline.
+
+commit 9a52e660536b4723bf24e2717fec757a1bdfa49f
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 01:35:52 2007 -0800
+
+ Match RUBY_NAME against /^ruby/ to pick up e.g. ruby1.8.
+
+commit 85536b98862f6abec310bfad03be17652ee65944
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 01:01:46 2007 -0800
+
+ Implemented mspec matchers.
+
+commit c953335397c6c8b9d7b27a3d240fde3b3518cb48
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Nov 27 01:35:07 2007 -0800
+
+ The rest of the mspec big picture.
+
+commit 2f598f193eb1b10065c8e1a8d5c2aaa89c689072
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Nov 27 00:39:59 2007 -0800
+
+ Added base operator matchers and specs.
+
+commit 0cc0b5a97661970d4cbb5e46406e7ee06421e637
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 26 21:03:33 2007 -0800
+
+ Migrated mspec and ci runners to mspec dir.
+
+ Created stubs in bin/ci and bin/mspec that call the respective
+ scripts in spec/mspec/scripts.
+
+commit b98d65eaa90d966fc2f7b8f8387266e241c202de
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 25 01:03:26 2007 -0800
+
+ Added specs and guards for mspec.
+
+commit 7bb316d1291c9d0a16904d4a3ee60094a713f215
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Nov 24 21:40:46 2007 -0800
+
+ Prevent MSpec's #should(_not) from overriding RSpec's.
+
+commit c446988257a2104d72abd4a362dc21ca6183aab0
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Nov 20 22:47:25 2007 -0800
+
+ Defines #should and #should_not for mspec.
+
+ Specs for #should and #should_not.
+ Adds example for using mspec "base" layer.
+
+commit 1aecf8e828dfd3d86f43d8c9c927e7c0ccb16b68
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 12 00:40:04 2007 -0800
+
+ The mini rspec big picture.
+
+commit f2979b03f29e7ac810b81f9087ea53923de5a35c
+Author: Charles Lowe <aquasync@gmail.com>
+Date: Mon Dec 17 15:18:24 2007 +0100
+
+ Added missing error checks to Dir.chdir block form.
+
+commit 028fee4e6d48514cae53f87c143bb68501bf58e9
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Wed Dec 12 20:01:35 2007 -0500
+
+ Add further specification of size changes during Hash#delete.
+
+ This was actually failing a while ago but now passes after recent
+ changes.
+
+commit f757f4359c86f778ac8e5931b8915511fd03506d
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Wed Dec 12 19:59:28 2007 -0500
+
+ Tighten another spec in core/hash/equal_value_spec.rb
+
+ Hash#== compares keys with matching hash codes via eql?
+
+ This spec was using hash keys where key.eql?(key) was false.
+
+ That's pretty pathological, but there's probably some real
+ non-conformance with MRI here. MRI can test for object identity
+ without calling eql? so a key is still found even if it doesn't
+ eql? itself.
+
+ That's not really related to the behavior this spec is specifying,
+ though. So, this patch just uses a less pathological implementation
+ of eql?
+
+commit 3f73ddf6bec5c704ceb5ed43481971860293353d
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Wed Dec 12 19:49:49 2007 -0500
+
+ Tighten spec in core/hash/equal_value_spec.rb
+
+ "Hash does not compare keys with different hash codes via eql?" was
+ failing because it detected that eql? was called on a key. However,
+ eql? was not being used to compare keys with different hash codes
+ from the two hashes. Instead, eql? is used to compare a key to itself
+ during hash element reference, in order to distinguish between two keys
+ with equal hash codes that aren't eql?.
+
+ The tightened spec only fails if the keys are compared eql? to each other.
+
+commit e355e98a32f34619628a17f5052750da6881cda9
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Wed Dec 12 12:26:15 2007 -0500
+
+ Add specs for hash stability of various Numeric subclasses.
+
+commit 0d774c99254b2c5992a17ecb2a5a12dcd2cad05e
+Author: Chris Shoemaker <chris.shoemaker@cox.net>
+Date: Tue Dec 11 20:37:45 2007 -0500
+
+ Add a Hash#store spec for storing unequal keys w/ same hash.
+
+commit edfff4981285007ecac132f565243150a8a8bd7e
+Author: Curtis Schofield <123@noself.net>
+Date: Tue Nov 27 19:02:45 2007 -0800
+
+ Specs created for Process#gid and Process#uid
+
+ * both are using the unix system command 'id'
+
+commit 4e269d01238537cc45f4c347b12053616007d94d
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Dec 16 23:46:50 2007 +0100
+
+ Excluded evil Thread specs.
+
+ This makes bin/ci usable (pass) again on my system, where it was horribly
+ broken before.
+
+commit b32c46ba95f2ecdaf646a030b96ee9b3737929a0
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Dec 16 23:37:26 2007 +0100
+
+ Excluded failing Kernel#eval specs.
+
+commit 0c56f3a1f84dd94d1f9685af9e9d6e0efd0cfabf
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Sun Dec 16 20:24:54 2007 +0000
+
+ Tighten up specs for what should happen when array shrinks during iteration.
+
+commit bfa8c532605c9e3b3d7f853516de9aae596c611d
+Author: Hunter Kelly <retnuh@gmail.com>
+Date: Sun Dec 16 19:11:25 2007 +0000
+
+ Added specs for Array#each when the array is changed during iteration.
+
+ Ditto for Array#each_index.
+
+commit b3aa2af4a3467b4eeb8765010286c12bd5adfbf9
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Dec 15 22:53:35 2007 +0100
+
+ Sanitized Object#id spec.
+
+commit cce5b7004a774041d78c3b2e55af8063335a9512
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri Dec 14 19:02:57 2007 -0800
+
+ Fix sleep spec, implement Thread sleep status and death detection
+
+commit c2475838be23ae287075b7e9ea832013f1db77c4
+Merge: 30f20cf... d061b86...
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 14 10:56:53 2007 +0100
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 30f20cfbd67487c426827406890fdb06fac8045c
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Fri Dec 14 10:56:17 2007 +0100
+
+ Fix race conditions in Kernel#sleep spec by ensuring target thread is actually sleeping before continuing.
+
+commit d061b864f636210e40982d961b0aa5afc24543d0
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Dec 13 23:04:27 2007 -0800
+
+ Fix require specs to not require checked in .rbc or .rba files
+
+commit 41831976d25a4d5a8e26673199276098cc45b4d3
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Dec 13 22:40:43 2007 -0800
+
+ Fixed Thread#run, added corruption detection to rbc files
+
+ * Thread#run was confusing the Thread scheduler, cause things the VM
+ to quit running.
+ * Added corruption detection to .rbc files in the form of a SHA1
+ hash placed in the .rbc, just after the header.
+
+commit 77f0f29060d5ba3f33dc45029525acb715eb61c2
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Dec 14 15:10:59 2007 +1100
+
+ Compiler2 fix for attrasgn in masgn
+
+ An attrasgn node contained within an masgn does not include
+ the assigned value in the attrasgn sexp. This was leading
+ to the argument count to []= to be understated by 1.
+
+commit faaa1932fe05ee4d506b768f8d9d884af5345547
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Dec 12 19:59:11 2007 -0600
+
+ fix non-determinism from Thread.sleep by removing blocking sleep
+ add check for duration of 0 or 0.0 to instant return and added more specs
+
+commit e98b2d1f9788c1813bef2d920779c95effbd3d9f
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 11 17:27:43 2007 -0600
+
+ spec and fix to allow floating point timeouts to Thread#join
+
+commit 801cb5ef58a6debfd348a33f864737cbce7c3d77
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 11 17:26:58 2007 -0600
+
+ added noncompliant spec showing that sleep(nil) is allowed in rubinius
+
+commit 84d280810c840d6699b5c9ad094964fe779235df
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Tue Dec 11 16:30:41 2007 -0600
+
+ fixed Thread#sleep to allows floats, and switched Thread::sleep, Kernel::sleep to use Thread#sleep on current thread
+
+commit 3d10a8a10741786ba76a4cc1083934f908d52ec2
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Mon Dec 10 17:13:34 2007 -0800
+
+ Allow Thread.new to take arguments
+
+commit 4f5258b938a7aacf31e73b5fe6312e3c927d9cf8
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Mon Dec 10 00:21:20 2007 -0800
+
+ Fix rb_define_alloc_func
+
+commit 7ab0f524de5a6b796ec1000402392cb138150eed
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Fri Dec 7 15:06:45 2007 -0800
+
+ Initial ThreadGroup implementation
+
+commit 53fff95e300b1b26ed16f12c13684eadf8235d7a
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Fri Dec 7 01:30:55 2007 -0800
+
+ Add rb_str_substr
+
+commit ec82de9f67e271718b874c0d777765da696bef88
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sat Dec 8 15:26:17 2007 -0800
+
+ Add wrapped struct spec
+
+commit 65998d601aae601b3b43878f534362136a01ff17
+Author: Brian Takita & Nathan Sobo <brian.takita@gmail.com>
+Date: Fri Dec 7 17:18:24 2007 -0800
+
+ Added specs for Module#undef_method.
+
+commit 97f8c9c32b9400ae42d0dc80aa7e17b22864fce9
+Author: Brian Takita & Nathan Sobo <brian.takita@gmail.com>
+Date: Fri Dec 7 16:13:02 2007 -0800
+
+ Moved Object#to_a to Kernel#to_a. Added VM.coerce_to_array.
+
+ VM.coerce_to_array will be used for splatting any object.
+
+commit 865ce7d771a101bc8c2c9ae3a82cbc3f37450c4b
+Author: Brian Takita <brian.takita@gmail.com>
+Date: Fri Dec 7 12:47:08 2007 -0800
+
+ Merge branch 'array'; commit 'nathan/array' into array
+
+commit b4541a90f84c898e3cd9851ac4b207d559078a59
+Author: Nathan Sobo <nathansobo@gmail.com>
+Date: Thu Dec 6 23:33:10 2007 -0800
+
+ Updated language/array_spec.rb for more detail on splat operator.
+
+commit 577b2f1c395dc49165842c405fb47bbb7591158a
+Author: Nathan Sobo <nathansobo@gmail.com>
+Date: Thu Dec 6 18:30:16 2007 -0800
+
+ Fixed :many_if for compiler 1.
+
+ Before it was translating many_ifs to a flat array of if statements instead
+ of nesting them. Also, multiple boolean expressions in the case were not
+ expanded to a boolean disjunction.
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 1d555fa07aaed8e59e728cb0013daa10b3b17b25
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Dec 6 21:24:44 2007 -0500
+
+ Add some JRuby-inspired eval specs
+
+commit 3131fb81eef380d163d028f5587475bbf170befb
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Dec 6 12:19:49 2007 -0800
+
+ Fix minor constant lookup issue and add timing to mspec
+
+commit 26897cd85c693cac10229d7467436717552088c0
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Dec 6 11:42:36 2007 -0800
+
+ Fix another constant lookup bug
+
+commit 06a3f07999aeb4f7379ea40205451d326d1ba596
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Dec 6 16:37:15 2007 +0100
+
+ Updated CI excludes for IO#each and IO#each_line.
+
+commit b495ab1019e9ee136e9d099faa51cba03c48e947
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Dec 6 16:01:31 2007 +0100
+
+ Extended argument checking in IO.read.
+
+ We're now checking that offset isn't negative either. This is done
+ before the length argument is checked, mirroring MRI's behaviour.
+ Also fixed a typo in the length check.
+
+commit 4fa2fbb6b6c27ced5d6cf902e63e3989c2d29b64
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Dec 6 14:56:41 2007 +0100
+
+ File.truncate raises Errno::ENOENT if the given file doesn't exist.
+
+commit cb7a0a7315e57f1adff0976bcd6b0c4a1a94d8c5
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Dec 6 14:15:55 2007 +0100
+
+ Added support for the length and offset arguments to IO.read.
+
+commit 9fe8f2bd73e28d28b7a9249e629ab7681321e4d5
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Dec 6 14:07:21 2007 +0100
+
+ IO.read only accepts file names and uses File to open and read them.
+
+commit 7ab1d9f3434e3f3b021de2f4087f2502e229c7a0
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Dec 6 14:00:19 2007 +0100
+
+ IO.new(nil) raises TypeError now.
+
+commit 227f6b4bf45b55eb659d41507d38fe5071ef7424
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Dec 6 13:24:31 2007 +0100
+
+ Fixed a typo in File.writable?.
+
+commit 645f30882c9dd39d13f49e45f2f32c43ebe25182
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Thu Dec 6 03:51:11 2007 -0800
+
+ Update Dir excludes
+
+commit e60ee517013d44c2ec6faf147f7dbd685fa520c2
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Thu Dec 6 00:40:17 2007 -0800
+
+ Fix flag checking in Dir.glob
+
+ Also clean ".", ".." skipping
+
+commit fa681ad7a3c1d0e1b4fb0702c2fc63cd80ec9377
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Wed Dec 5 18:08:41 2007 -0800
+
+ File.fnmatch? should accept escaped wildcards
+
+ Also fixes more Dir.glob specs
+
+commit e6b8ce23729606bf6fa748ea63c0e0a59b48a476
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Wed Dec 5 15:35:32 2007 -0800
+
+ Don't unescape leading period in File.fnmatch?
+
+commit 1cf054a08b0aeea7c348ff26c71ccaf22c02ce70
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Dec 6 02:36:54 2007 -0500
+
+ Rename Array#pretty_inspect to avoid conflict with pp
+ Hardcore bikeshed action on the way TestGenerators are inspected
+ Change describe.rb to call the renamed pretty_inspect
+
+commit 519d1226027623274766641a256e2a9753257266
+Author: Nitay <nitay@powerset.com>
+Date: Wed Dec 5 16:07:25 2007 -0800
+
+ Fix Constant = Class.new setting of name
+
+ Signed-off-by: Kevin Clark <kevin.clark@gmail.com>
+
+commit 568c57ca57d4a9183e492024e17aa1352902d1d2
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Dec 5 20:31:43 2007 -0500
+
+ Clean up mspec output to prepare for unit_diff support
+ Use pretty_inspect to display compiler2 TestGenerator output
+
+commit e250521194380f4c942fd6d53664b746ca63e3e3
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Dec 5 17:27:27 2007 -0800
+
+ Fix constants spec to scope the fixtures
+
+commit 7010073617a4fa95ea5491284fef97a083d9d4f3
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Dec 5 14:42:27 2007 -0800
+
+ Vastly simplify and fix constant lookup
+
+ * New constant lookup specs to test behavior
+ * Added StaticScope object and field on CompiledMethod which stores
+ a StaticScope instance which indicates the lexical scope of the CM.
+
+commit 163e56646a817301201af843b45c973da058688c
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Wed Dec 5 23:00:16 2007 +0100
+
+ The spec for Dir#rewind doesn't pass on Rubinius.
+
+ It's not platform specific, but we don't have a working Dir#pos yet
+ and the Dir#rewind spec relies on it.
+
+commit 3afe61bd78aa9e850f081b83ca2c478ae297bda1
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 5 13:51:05 2007 -0800
+
+ Changed mini_rspec to show failures unless being run by autotest.
+
+ Added dir_entry.rb to .gitignore.
+
+commit 0c661894b54615ee4915d61569e072ffdfa8826d
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Wed Dec 5 09:17:24 2007 -0500
+
+ Much-improved tiny option parser lib/options.rb.
+
+ * The Options API is much more user-friendly now,
+ size is still about 100 LoC
+ * Specs for the API.
+
+commit 092e0081c26eeda2ca6561eb19123b468965c84a
+Author: Ryan Davis <ryand-ruby@zenspider.com>
+Date: Wed Dec 5 01:40:31 2007 -0800
+
+ Added support for autotest.
+ Requires a new release of ZenTest to actually work.
+ I'm tired, I'll do that tomorrow
+
+commit 9e3e41d71d1bab8104ae17ff34aaa2311be3b0b1
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Dec 4 22:59:49 2007 -0800
+
+ Commit miss for require specs
+
+commit d1a6f0805b739930e54406188e32ac1e0f30a74b
+Author: Eric Hodel <drbrain@segment7.net>
+Date: Tue Dec 4 22:24:49 2007 -0800
+
+ Add specs for Kernel#require, never add .rbc files to $LOADED_FEATURES
+
+commit a60e3bf901b62fbbbef59acb2c6c9f164be1fbbc
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Dec 5 14:10:15 2007 +1100
+
+ Cleanup case spec, update excludes
+
+ * converted case specs to not use should
+ * separated out case specs with target expressions from those without
+ * updated excludes for two failing specs under compiler1
+
+commit f0de77911ff0b4532a47fb9803685e8d968d51ec
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Tue Dec 4 09:42:49 2007 +1100
+
+ Fixes for compiler2 when_spec failures
+
+ * Added compiler2 spec for when without an arg
+ * Added spec for when without arg with an else to
+ spec/language/case_spec.rb
+ * Implemented many_if sexp compilation
+
+commit c9c67738ecae341441098993923838a15b64d166
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Dec 4 20:42:27 2007 +0100
+
+ Test Etc.getgrnam() with "daemon" instead of "root".
+
+ The "root" group seems to be a Linux-ism.
+
+commit 1fd6d97e8eb20ce9908cc0abd09b7c5555ff5720
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Dec 4 19:31:24 2007 +0100
+
+ Post-move fix for the Options spec.
+
+commit ead52428d99549b6b53b8897d969e80072395ef6
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Dec 4 19:12:28 2007 +0100
+
+ Moved codearchive.rb, options.rb and readline.rb from kernel/core to lib.
+
+commit 0e4568bcc23011957cc250de2a93031648281b21
+Merge: 78fba04... fbc5ad5...
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Tue Dec 4 00:50:46 2007 -0600
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 78fba04c31e9d97c32862e9e104e3917dcff9137
+Author: Charles Nutter <headius@wlan100.headius.com>
+Date: Tue Dec 4 00:39:05 2007 -0600
+
+ Making socket spec more reliable by using nonblocking accept for TCPServer and adding a "ready" flag for UDPServer.
+
+commit 7e925ea53239207f5dd9ac5daddda8e0f1f3b687
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Dec 2 23:33:29 2007 +0100
+
+ Implemented Etc.
+
+commit 450778cf5f416f6b9531664d4fff2c159c93cbe7
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Sun Dec 2 01:39:28 2007 -0600
+
+ Shared spec for class_eval.
+
+ - removed method-arguments from describe string
+ This was causing bin/completeness to report 0 examples for Module#class_eval/module_eval
+ - examples checking for TypeErrors test the exception is raised, but don't check
+ the exact message as it is not part of the interface.
+
+commit cd0d11c7eb23d881f1dd73701bd3edc12c5bd744
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 1 15:28:41 2007 -0800
+
+ Updated CI excludes for Dir.[].
+
+commit e41e501bcf686937fbd3b8cfc86f325d7e06184d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 1 10:54:35 2007 -0800
+
+ CI spec excludes updates.
+
+ * Fixed rake pristine task to whitelist Kernel#require fixtures.
+ * Updated CI excludes for Dir.glob and Dir.[].
+
+commit 8f362a0350238366565a373f1feb9594efe03407
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Dec 1 18:50:55 2007 +0100
+
+ Make sure we delete the directories we're creating in the mock dir.
+
+commit dfc1b1cd32f47b48dd358ca50226d614425ef8b2
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Dec 1 18:08:27 2007 +0100
+
+ Dir.chdir now always resets the working directory when called with a block.
+
+commit 02f41a92bbafd1a555344e1082970e090cd1f9a5
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 30 23:41:29 2007 +0100
+
+ Call StringValue on require's and load's argument.
+
+commit 601fd404ba04f383ee286be015edb7e8c58574d5
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri Nov 30 14:27:44 2007 -0800
+
+ Refactor Kernel#require
+
+ * Refactor a bunch of Kernel#require into Compile#require_feature
+ * VM.load_library now detects if the extension is already there
+ and doesn't readd it
+ * Added specs for #require
+
+commit 9b903cb7c5c6a3bfbaa3a7a91dc7bad830af7294
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Nov 30 10:56:02 2007 +1100
+
+ Compiler2 fix for anonymous masgn, e.g. * = 1,2
+
+commit 08bc0a2f14494a30d5956d5bdcca9eb37c921780
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 30 00:16:07 2007 +0100
+
+ Made check_argcount work with methods that don't take any arguments.
+
+commit 96108240fead7d764f3ec37d5eb20294f3a9dd97
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Nov 29 21:45:32 2007 +0100
+
+ Updated the CI excludes for Method#call.
+
+commit 61805ab7fac6ae9855baa05b42aebe66c3a2b3d3
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Nov 29 21:44:49 2007 +0100
+
+ Made Method#[] an alias for Method#call.
+
+commit 219d34dedf6ff0ed083cb5f1e8b6a5c437ad366c
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Nov 29 21:22:05 2007 +0100
+
+ Enabled the Kernel#method_missing specs.
+
+ They pass now that they specs aren't confused by the Dir spec helper
+ methods anymore.
+
+commit de5320efe8095e612e235bea7053084bb61d300d
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Nov 29 21:17:58 2007 +0100
+
+ Moved the Dir spec helper methods in their own module.
+
+commit 1ae47b5c091c209597bec7475935bbcff34b50b5
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 23:45:09 2007 -0800
+
+ Applied patch from #151.
+
+commit adb5b139afa452869464fe53b710d7cb8b93131b
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 20:29:38 2007 -0800
+
+ Better fix for guards to distinguish ruby, ruby1.x from ruby1.9.
+
+commit e53f72172e395c7766dcecadd2ffd6c7caf303e7
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 28 20:15:27 2007 -0800
+
+ Patches (or modified patches) from #157-162.
+
+commit b07eeee79ea5a0c0160c34aec2d690f1b46f7380
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Wed Nov 28 14:43:41 2007 +0100
+
+ Fixed Bignum#modulo and Bignum#remainder.
+
+commit 85b05b5103aaeb5d946e0f691f77af2dafa6f30a
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Wed Nov 28 01:00:07 2007 +0100
+
+ Unified the File.unlink and File.delete specs.
+
+commit 2ec59a82f279a4ba6b5b781c90a7714aba767ed9
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Nov 27 23:30:43 2007 +0100
+
+ Be more specific wrt the expected exception.
+
+commit 54236949e9b974d4c4dcf95b63318c844c62aca4
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Tue Nov 27 19:58:50 2007 -0600
+
+ Module#<=> is working, Updated CI excludes for Module specs.
+
+commit 55c7529f4c8b02eff7e0b594f33b28750877fca2
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Tue Nov 27 14:53:02 2007 -0600
+
+ Specs for Module#private/public/protected
+
+commit 5b693fae3464abb6a5aa05d8236bd8f4610c89d4
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Nov 27 19:36:06 2007 +0100
+
+ We cannot use File.exists? to check whether a symlink exists.
+
+ Use File.symlink? instead.
+
+commit e7eb6a8e1e1310c08220db0ed7979ec4c721fccb
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Nov 27 19:34:48 2007 +0100
+
+ Moved the after(:each) block before the specs, so the block is actually run.
+
+commit 4c284abb32029029ab7002147ef544493c7070f6
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Nov 27 19:00:30 2007 +0100
+
+ Added a missing Errno.handle to File.readlink.
+
+commit f163ca7c5e4a03d698a881853d1e0fab8a5be1a4
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Nov 27 18:42:08 2007 +0100
+
+ readlink() only works with symbolic links.
+
+ This makes the spec pass on MRI.
+
+commit ca1cb21b5f694b3850a838f88d3ac5ded7de3e1f
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Nov 27 18:40:43 2007 +0100
+
+ Naming convention fixes.
+
+commit cbf351cb59152a5528f6c6105cee96c67f7f6fcd
+Merge: f70d531... 5452983...
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Mon Nov 26 19:48:21 2007 +1100
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit f70d5314fcc75ef2e32fbd484de58bd5f7ed6cbc
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Sat Nov 24 17:29:29 2007 +1100
+
+ Implemented File::symlink and spec.
+
+ Kudos to the Melbourne Railscamp :)
+
+commit c4a6a804185c18a182206afc1b8d5209d208077e
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Sat Nov 24 01:08:41 2007 +1100
+
+ Removed trailing whitespace.
+
+commit 9b9820e512f56b2c23c760887251d72c187aa297
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Sat Nov 24 00:50:11 2007 +1100
+
+ "Added File::readlink spec"
+
+commit 2dd272afe315dae0ad0b9bd49b6dfa9e98e50b1c
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Nov 23 17:11:54 2007 +1100
+
+ Spec-ed implementation differences on masgn RHS eval order
+
+ Rubinius is (for now) deliberately non-compliant wrt eval
+ order of RHS expressions in an masgn.
+ * MRI, JRuby eval left-to-right
+ * Rubinius evals right-to-left
+
+commit 361a1adcee182cf069352effd0949064b621bddc
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Fri Nov 23 16:16:08 2007 +1100
+
+ Additional parallel assignment specs - use of to_ary
+
+ * Added spec for when to_ary should be called on the RHS of an masgn
+ * Added additional example of a complex masgn (from JRuby tests)
+
+commit 97cb3f5758f102cf8a07262c4c9bef4b22ca88b7
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Thu Nov 22 22:04:51 2007 -0600
+
+ Added specs for metaclasses of true/false/nil on metaclass_spec as suggested by rue.
+
+commit d4f9eb7cd5fb17e3e8ce52db39e95a96362d3ad0
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Nov 22 13:05:10 2007 -0800
+
+ Fixed wording of Rubinius extension Bignum domain specs.
+
+commit 50e1f80ef54d25aaa69d52a3d422547593836ac6
+Author: Jeremy Durham <jeremydurham@gmail.com>
+Date: Thu Nov 22 17:18:54 2007 -0500
+
+ Added excludes for Kernel#open and Thread#abort_on_exception
+
+ * Excludes Kernel#open raise specs
+ * Excludes Thread#abort_on_exception specs
+
+commit 25607d4d884b4597bc69560e9390cd9dc1f4e44d
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Thu Nov 22 13:47:50 2007 -0600
+
+ Specs for Module#alias_method
+
+commit c207618ad4113501aa5df4adb5d5aa3a60f5b9ff
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Nov 22 10:59:34 2007 -0800
+
+ Use RUBY_ENGINE first, then pull in rbconfig
+
+commit ed5a46e13b35d6ad48cce1d3eed96c2f78ace049
+Author: Jeremy Durham <jeremydurham@gmail.com>
+Date: Thu Nov 22 11:42:36 2007 -0500
+
+ Added basic specs for abort_on_exception
+
+ * Added specs for Thread#abort_on_exception ($DEBUG on and off)
+ * Added specs for Thread#abort_on_exception=
+
+commit 05ecef9162ba2c4a0da90c966a20a4f45c353d93
+Author: Jeremy Durham <jeremydurham@gmail.com>
+Date: Thu Nov 22 08:39:53 2007 -0500
+
+ Added specs for when parameters are missing or invalid parameters are given
+
+commit 25d2c940d561dcac2c06df747762a229dddfbed1
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu Nov 22 15:33:17 2007 +1100
+
+ Another parallel assignment spec - rhs should evaluate l->r
+
+commit 8e4f8de446b842c13ad45a8e0e2c3c1ebf30bddb
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 21 17:42:17 2007 -0800
+
+ Stop-gap prevention for Kernel#callcc hanging CI specs.
+
+commit a9d7163e4d9e8d4fb79c9769691b232676a44bd8
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Nov 21 15:50:39 2007 -0600
+
+ remove compliant(MRI) from callcc specs
+
+commit 812e922c8e7cda728d6b7f32933b75eb009eef11
+Merge: 2e221b9... f24bb1f...
+Author: Nathan Witmer <nwitmer@gmail.com>
+Date: Wed Nov 21 12:32:18 2007 -0700
+
+ Merge branch 'callcc_spec'
+
+commit f24bb1ffdf941df78098da262a62e881653b1a99
+Author: Nathan Witmer <nwitmer@gmail.com>
+Date: Wed Nov 21 12:31:28 2007 -0700
+
+ Added scope-related callcc specs, compliant(:ruby) only.
+
+commit 2e221b9f1d7ffa41431e5bd51fdd36434e7f838f
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Wed Nov 21 14:41:43 2007 +0100
+
+ Spec and fix some more String#slice bugs when given nil, also use Undefined.
+
+commit db338d9d8705fd668a5639d483ff47908aa014ca
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Nov 6 16:53:13 2007 +0100
+
+ Fix String#rindex when given nil as offset.
+
+commit 6eab3b692a50c1a37cc39c21d743de1488402f64
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 21 00:00:24 2007 -0800
+
+ Added MRI stdlib Fcntl to lib/ext with build script.
+
+ Added lib/fcntl to load extension. This may need a better solution.
+ Added INT2FIX to subtend.
+
+commit 5268c0b29c1fb07a911fe601e30b21ffe04f7e81
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Nov 21 17:02:14 2007 +1100
+
+ Additional specs for parallel assignment
+
+ MRI allows parallel assignment to:
+ - assign via object.method=
+ - assign via []=
+ - use a lhs arg as an arg to another lhs assignment
+
+ All three scenarios currently fail in Rubinius, apparently due to
+ miscalculating the number of args to an assignment method under
+ parallel assignment.
+
+commit 462f68b95a70c24e41cad5a40969c4651c7de181
+Author: Jeremy Durham <jeremydurham@gmail.com>
+Date: Tue Nov 20 02:12:44 2007 -0500
+
+ Added specs for Kernel#open when block is given
+
+commit ab9e40600fd2522d4abce86f7b8bdc632f6e9018
+Author: Jeremy Durham <jeremydurham@gmail.com>
+Date: Mon Nov 19 23:42:55 2007 -0500
+
+ Added very basic specs for Kernel#open
+
+commit b47efc9f9872ecca68a06f6864f39617e06762b0
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 19 00:24:15 2007 -0800
+
+ Updated CI excludes. Runs clean on Leopard.
+
+commit 3ff04e52bc9cb03439567ddb9b3b63b3034b30c3
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Nov 19 00:03:58 2007 -0600
+
+ more specs for Kernel.callcc, ensures callcc return value semantics
+
+commit 06d5312c51b09faef87d2deb53f3c472eaa94100
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Sun Nov 18 17:49:44 2007 -0600
+
+ basic callcc behavioral specs
+
+commit 53433f0e9ddba2eac876f7a1fb0f9d292ee37286
+Author: Nathan Witmer <nwitmer@gmail.com>
+Date: Fri Nov 16 16:51:18 2007 -0700
+
+ Added Kernel#callcc spec and fix for LocalJumpError with no block given
+
+commit d324779b8b5c8dd84438c08ec4f2b2574282f93e
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 16 15:17:21 2007 -0600
+
+ Added Module.nesting
+
+ Some specs are failing on rubinius because the parent
+ field is not being properly set.
+
+commit cff726c9dc3631b2e0ddc3e12bd3af532f7e1ef4
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 16 14:49:38 2007 -0600
+
+ Added spec for calling Module.nesting on root level
+
+commit 05adb6070889d7021a1e53ab82b855c3554d4f5c
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 16 14:45:23 2007 -0600
+
+ Fixed specs for Module#constants
+
+commit 1f1c857e1d8c37213a91daaad3fc3bfcbf2bef61
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 16 14:43:55 2007 -0600
+
+ Fixed spec description for calling Module.nesting from methods.
+
+commit 242c947c6e4d007685e8aa0c44ac505c7dab4239
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 16 14:38:32 2007 -0600
+
+ More specs for Module.nesting
+
+commit 3560fd7ef0d5a65a9cb055d87fa7103ed3bdb029
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 16 10:24:45 2007 -0600
+
+ private keyword specs reflecting problem described on ticket #133
+
+commit fd31e1e592237832bd5e605f604d15385df0615a
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 16 04:15:27 2007 -0600
+
+ specs for Kernel#block_given? by Francisco Laguna
+
+commit 87ebce4cf2430198578decdb4c7dc1003db37f8e
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Nov 15 22:07:39 2007 -0800
+
+ Ticket #121 by Jeremy Durham -- File modes
+
+commit 4a67e0ade233aaaa3a2ff17161b298872f8a5f83
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Thu Nov 15 14:20:19 2007 -0600
+
+ Splitted enumerable_spec.rb into a file per method.
+
+ Added some specs by Francisco Laguna.
+
+commit 0b933650330f57e7db1bf8574d0b7eecf0635996
+Author: Bryan Helmkamp <bryan@brynary.com>
+Date: Tue Nov 13 11:34:20 2007 -0500
+
+ Added specs for File.mtime.
+
+commit 42a7de27c1a6082fee7b9baaf05b9394ffe90ddd
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Mon Nov 12 19:57:38 2007 +0100
+
+ Updated CI excludes for File#atime and File.new.
+
+commit 3d106d6a9b8ce0b34e7b6f9426da51b83fe5f676
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Mon Nov 12 19:54:43 2007 +0100
+
+ Added File#path.
+
+commit 247da25a0120d468fe9f189a6235962f9658b65e
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Mon Nov 12 19:23:09 2007 +0100
+
+ File now deals with numeric modes and accepts a permission argument, too.
+
+commit 087deaed0dcf4ae2c8dc713eeccfed9a0ebabe6f
+Merge: 4355e96... 1c9d213...
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 11 23:15:01 2007 -0800
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 4355e96b05de4d4d086dfa86b8fe19bdcecfbe82
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 11 23:14:16 2007 -0800
+
+ -a
+
+commit 7e975d1aca38a3bfe07fda431aeaba376bce19c1
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 11 23:09:47 2007 -0800
+
+ Get rid of irrelevant specs
+
+commit 1c9d2133fc294964ce08e9a7020083c379f74ca0
+Author: David Waite <david@alkaline-solutions.com>
+Date: Sun Nov 11 23:46:08 2007 -0700
+
+ Remove temp directories within mkdir spec on exception.
+
+commit 2110fc75dc6a7ab521249f259bc6fdc78d565b11
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 11 22:36:08 2007 -0800
+
+ Update CI Excludes
+
+ * Expected failure of "raise an Exception if it has
+ the wrong number of argments" due to dispatcher bug
+
+commit 0f2a183a46ba085d9c99ed4767cd18c0482e6d45
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 11 22:14:07 2007 -0800
+
+ Implement File#atime
+
+commit 671b340f340ab6b8d9c13b27d52a782ce3268b2a
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 11 21:24:34 2007 -0800
+
+ Update CI excludes
+
+commit f7ba96f6b41de9a3696a03e9efe25c8b037a4f07
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sat Nov 10 11:24:12 2007 -0800
+
+ Adds spec for File.open
+
+ * In resonse to Lighthouse Ticket #102
+ "File.open should throw Errno::EACCES opening non-permitted file"
+ * Passes MRI, doesn't yet pass RBX
+
+commit 719329b3f5179766e23a27e427cd0c0846c85ffa
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Mon Nov 12 10:38:42 2007 +1100
+
+ Added IO#to_i implementation and spec.
+
+commit cc100fc08be101ecdf0daba1966977fb8e39fa6e
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Mon Nov 12 10:30:25 2007 +1100
+
+ Added IO#fileno implementation and spec.
+
+commit d036f5c16a4836d638be83108be35df532d9221a
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Nov 11 23:17:12 2007 +0100
+
+ Made SystemStackError subclass of StandardError.
+
+commit bf1c3dc3e463aeaf4e0cee1cbd46b15e7693a395
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Nov 11 20:36:25 2007 +0100
+
+ Removed an old Method#arity spec exclude.
+
+commit 72c3495f3513e54c2488292bcdaca9208b6f0339
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 11 10:44:53 2007 -0800
+
+ Removed transient dirs from Dir specs.
+
+commit 11f0ed51b4bfb3bea2b544a82b3158fd3daf2ad8
+Author: Victor Hugo Borja <vic.borja@gmail.com>
+Date: Fri Nov 2 03:02:28 2007 -0600
+
+ Specs for Module#remove_const
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit e8158f14f0f02e3b0cdcb4182e1277928324cc0c
+Author: Nathan Witmer <nwitmer@gmail.com>
+Date: Sun Nov 11 08:19:10 2007 -0700
+
+ Fixes for UDPSocket spec
+
+ * Renamed the description to match what was actually being tested
+ * Uncommented the code and wrapped it in an "it" block, to prevent
+ conflicts/hangs with bin/completeness runs.
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 9b973a98d2ebddacd50f0fcb58903bb53bdff3f5
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Nov 11 13:30:22 2007 +0100
+
+ Ticket #98: Dir includes Enumerable now.
+
+commit 8d957f186cd4d2c5e6b236de4a0878d38b464848
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Nov 11 13:26:00 2007 +0100
+
+ Implemented Module#included_modules.
+
+commit 0021b24ba490fe01f96ef17957328feeedfc4c29
+Author: Nathan Witmer <nwitmer@gmail.com>
+Date: Thu Nov 8 21:42:41 2007 -0700
+
+ Commented out code in UDPSocket spec so bin/completeness doesn't hang
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 56687aed201fb864587807cca893268a9f1e2050
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 11 00:10:14 2007 -0800
+
+ Method fixture for yield specs.
+
+commit 421aa58f9135807487864adcdcac79f7b6da33c1
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 11 00:08:35 2007 -0800
+
+ Specs for yield keyword based on patch in #114.
+
+commit 5ba0b2030c55474f9d8a096d309678ca24a4699b
+Author: Jeremy Durham <jeremydurham@gmail.com>
+Date: Sun Nov 11 01:35:08 2007 +0100
+
+ Ticket #105: Implemented Bignum#eql?.
+
+commit 47356fe39033f8571559a4fef933681fda871efd
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Nov 11 01:14:26 2007 +0100
+
+ Made specs for Kernel#respond_to? and Kernel#method pass.
+
+ KernelSpecs::Foo#baz is defined in another spec, so these two specs
+ may not rely on #baz being undefined. This is a horrible workaround
+ for the problem that multiple specs make use of the same module and modify
+ it freely.
+
+commit 68b4fc7c0192f537fe9727927ac35c440dbdc03a
+Author: Akshay Rawat <akshay.rawat@gmail.com>
+Date: Thu Nov 8 18:21:03 2007 +0530
+
+ Updated CI excludes.
+
+commit a1eee3814a5d054cd00e26b40c063d41880bf6c7
+Author: Chris Pettitt <cpettitt@gmail.com>
+Date: Sat Nov 10 14:10:47 2007 -0800
+
+ Refactor IO.gets spec to have less duplication.
+
+commit 56497d27bdb3a82d549f89b9fc9fcf0709f99b3e
+Author: Chris Pettitt <cpettitt@gmail.com>
+Date: Sat Nov 10 14:07:21 2007 -0800
+
+ New spec: IO.gets('') should advance the file position to the next non $/ character.
+
+commit 95158f5a4141d5d3e2893304e49bfeb62cc7b226
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Nov 10 13:35:03 2007 -0800
+
+ Added rescue to prevent meltdown until rbx begin/rescue/ensure is fixed.
+
+commit a39155cb029ca3c1e5e5d69e0e269c685c040f6e
+Author: Chen Yufei <cyfdecyf@gmail.com>
+Date: Sat Nov 10 12:24:38 2007 +0000
+
+ Fixed IO#gets when separator is empty.
+
+commit f9c31ce1d2a68c15def98aad6c6ff35eb56cd523
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Fri Nov 9 20:24:40 2007 -0800
+
+ Clean up Enumerable#include? specs
+
+commit f017fad69be5d4034a4c5437acf77ec4749b0d75
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 4 20:54:06 2007 -0500
+
+ Clean up Enumerable#(collect, entries, find, find_all) specs
+
+commit 81550f082396b4455c3681ae966be1371be0a5db
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 4 13:18:52 2007 -0500
+
+ Update excludes
+
+commit d5fd2ee893ea608c7e19cb674a4da7b9f49542e6
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 4 12:16:58 2007 -0500
+
+ Cleanup/rewrite Enumerable#find tests for sanity and clarity
+
+commit 39f21aa76f6ddc45be79e4e4e978b4c1c2beed71
+Merge: 17d2e4c... c1b9f74...
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Fri Nov 9 20:25:13 2007 -0800
+
+ Merge branch 'master' of http://git.rubini.us/code
+
+commit c1b9f74f88be963e72de763da9130f46869d89fb
+Author: Chris Pettitt <cpettitt@gmail.com>
+Date: Fri Nov 9 12:36:04 2007 -0800
+
+ Fix some failing specs for IO#each and IO#each_line.
+
+ Also refactor some common code into a helper method.
+
+commit 74af37b849507e504503359a08245effaad7634a
+Author: Chris Pettitt <cpettitt@gmail.com>
+Date: Fri Nov 9 10:58:33 2007 -0800
+
+ New specs for IO#each and IO#each_line
+
+ This change adds some new specs for IO#each and IO#each_line factored into
+ a shared .rb, because one is the alias of the other. Added failing specs to
+ excludes.
+
+commit d162a396b566846445328d6c42d3d5f10fcf7ee6
+Author: Matt Pelletier <matt@eastmedia.com>
+Date: Fri Nov 9 02:32:25 2007 -0500
+
+ Add and refactor patches from Andrea OK regarding #send
+
+commit 63f0ed010e65549597f6bddb0686ba04157ca478
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Nov 7 09:52:25 2007 -0800
+
+ Fixed Method#call spec failing from renamed fixture method name.
+
+commit 1ef46468d7808c52b07388130069cb2e7854bff8
+Author: Matt Pelletier <matt@eastmedia.com>
+Date: Wed Nov 7 04:48:39 2007 -0500
+
+ * Update CompiledMethod#arity to be accurate for cases of required and/or optional arguments, with or without blocks
+ * CompiledMethod#arity is still inaccurate when splat argument is present (the presence of splat overrides #required)
+ * Add specs for more thorough coverage of various argument use cases
+ * Includes known Rubinius-failing specs for splat-related arity
+
+commit b7726f26dae95936aa1c3fdf2c52dd18ef7413cf
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 5 17:48:51 2007 -0800
+
+ Updated CI excludes for fixes to public|private_class_method.
+
+commit eb18f898e3ae8e5a1bf3b01291a12516c6a22301
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 5 17:18:22 2007 -0800
+
+ Added Module#protected_method_defined?. Updated CI excludes.
+
+commit aa8904cdbd8b4851be4f05cec3000b04cfc9f6c1
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 5 17:14:12 2007 -0800
+
+ Added Module#private_method_defined?.
+
+ Fixed specs for Module#public_method_defined? and
+ private_method_defined?. Updated CI excludes.
+
+commit 063b61759ee86f5def2422d16f1eb854c8b9eb76
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 5 13:39:21 2007 -0800
+
+ Updated CI excludes for StringIO.
+
+commit 3c79f871379d2d4b5431138033f723efbf4a795d
+Author: Dr Nic <drnicwilliams@gmail.com>
+Date: Sun Nov 4 16:45:30 2007 -0500
+
+ Extended StringIO spec "flattens a nested array before writing it" to ensure deeper test scenario
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 916d617a60cf83ac26c3090310236193f5842ff6
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 5 13:11:54 2007 -0800
+
+ Updated CI excludes for String#scan.
+
+commit fee1d904197c369c561ae3b11aaf582f1b87d1b0
+Author: Matt Pelletier <matt@eastmedia.com>
+Date: Sat Nov 3 16:06:16 2007 -0400
+
+ Fix test of String#scan. Do not force matches into array using splat.
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit cc9182cfcde60a63bf566f73c6004b7e46347e77
+Author: Daniel Lucraft <dan@fluentradical.com>
+Date: Thu Nov 1 17:01:03 2007 +0000
+
+ Added File.rename
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit fc2b7aa65ab338d8ff543552659046c93659c3ce
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 5 12:06:13 2007 -0800
+
+ Commit rework of Carl Drinkwater's patch from #72.
+
+commit 7f6564b96762d7b3deb9f021789182f5c664a766
+Author: Chris Pettitt <cpettitt@gmail.com>
+Date: Sun Nov 4 10:38:04 2007 -0800
+
+ Fixes for two IO#gets spec failures.
+
+ This patch fixes the following two IO#gets spec failures:
+
+ IO#gets assigns the returned line to $_
+ IO#gets returns the entire content if the separator is nil
+
+ Signed-off-by: Brian Ford <brixen@gmail.com>
+
+commit 705e8e05496167b1af3a1e3ff3446d325ca54e07
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Nov 5 02:10:56 2007 -0800
+
+ Added Module#public_method_defined?.
+
+ Updated CI specs for #public_method_defined?.
+ Small fix to find_method_in_hierarchy to symbolize arg.
+ Updated some spec wording and removed spec'ing exception string.
+
+commit 17d2e4c6ae0c40376fe121786a362c8bc8ce951c
+Merge: 2b77ee8... c07472c...
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 4 20:58:42 2007 -0500
+
+ Merge branch 'master' of http://git.rubini.us/code
+
+commit bd6c27f4724bdc461a7036e6373a0ad23060020a
+Author: Trotter Cashion <cashion@gmail.com>
+Date: Sat Nov 3 15:57:21 2007 -0400
+
+ Added operator precedence specs for '&&' and 'and'.
+
+commit 2b77ee8b74373a3251973d96c931422909605e29
+Merge: 30d7618... 76aa72e...
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sun Nov 4 13:43:23 2007 -0500
+
+ Merge branch 'master' of http://git.rubini.us/code
+
+commit 2c90ce28cc73e08d9fb74b5c7e815807314ba269
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 4 07:18:09 2007 -0800
+
+ Updated CI excludes from 85d63b676e.
+
+commit 85d63b676e463a2bec9a322bc8eeffd2daee433b
+Author: Chen Yufei <cyfdecyf@gmail.com>
+Date: Sat Nov 3 23:39:23 2007 +0000
+
+ Added specs for IO#gets
+
+commit be5b9595f2077080c0c1179ab9689352d8faea3a
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 4 00:31:12 2007 -0700
+
+ Updated CI excludes.
+
+commit d46ad4b63d4a5f77609b0880b7f24e8e27404805
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 4 00:11:52 2007 -0700
+
+ Updated CI excludes.
+
+commit 1f307223c673c6744f8b85fc3e707a3419b1a0e8
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Nov 4 00:06:48 2007 -0700
+
+ Guarded #freeze specs for MRI and JRuby.
+
+commit ca50fd7d979c36f8af306e0e1474aac5408dd66d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Nov 3 23:22:31 2007 -0700
+
+ Guarded specs for #frozen? for MRI and JRuby.
+
+commit 16b36030a796b877809d5d6ea556266c4b4a6413
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Nov 3 20:53:26 2007 -0700
+
+ Removed NULL characters from language/precedence.
+
+ Enhanced rescue output when loading spec files.
+
+commit 10510ece16ebb5e0ba921e0be631a4740f3e4453
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Sat Nov 3 23:09:30 2007 -0400
+
+ Fix a method_missing cache error.
+
+commit b313c5632b039c03a448ae3b1046701c8b3243a2
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Nov 3 14:10:29 2007 -0700
+
+ Changed shared spec behavior to be compatible with RSpec.
+
+commit 7b825b89e96b3c8e38f9b8bcc8edf2bc6ec6ff22
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Nov 3 14:09:47 2007 -0700
+
+ Fixed language/class specs.
+
+commit 30d76181b0b3a9c5ac99c9d0e22a6a451346eff4
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Sat Nov 3 16:47:49 2007 -0400
+
+ Fix Dir#each/Dir#entries/Dir.foreach specs. They weren't updated for fixtures
+
+commit f44a8cceb9a186a7127276db2207dfc79957ee8d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Nov 3 13:06:35 2007 -0700
+
+ Guard File.(un)link for jruby.
+
+commit 1ec2c3a99ca562c8944aac1f4a60f8e0af0aaf17
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Nov 3 18:20:48 2007 +0100
+
+ Properly resize the array in Array#<<.
+
+commit 8dec9918d8a6233ec2cde29d54687a5d950dc8df
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Nov 3 17:13:57 2007 +0100
+
+ Fixed Array#unshift for the case when @start > 0 && @start < values.size.
+
+ Also extended the Array#unshift specs to cover this case.
+
+commit 50b90918cd5a9a05e475690703c7867b443d191b
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Nov 2 13:47:53 2007 -0500
+
+ added IO::foreach, fixed gets to use string separator, and fixed IO::readlines to use File.open
+
+commit 3efc01e110473d003ffb0a1376ec179f30e600de
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Nov 2 13:30:44 2007 -0500
+
+ specs for IO::foreach and specs to test IO::readlines,IO.readlines with string separator
+
+commit fad18610b4416dfcfaf35db5029e880dff7e9820
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Oct 29 14:10:11 2007 -0500
+
+ basic exec implementation and a single basic spec (not sure how test test exec)
+
+commit 730fc3ed9afc54612d14093148fb8583c9e39fe3
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 2 21:41:25 2007 +0100
+
+ Return mkdir()'s return value from Dir.mkdir.
+
+commit f5766696e701a069f908b3b5d5cfbccfee15ef1f
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 2 20:46:11 2007 +0100
+
+ Implemented Dir.foreach.
+
+commit c696f1edc50c58b87270811c0c9aa0e49b356fe7
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 2 20:38:36 2007 +0100
+
+ Implemented Dir.entries.
+
+commit e8e6188b252172690c1b584e528e3c71035897cd
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 2 18:16:13 2007 +0100
+
+ Raise an error if the opendir() call in Dir#initialize fails.
+
+commit 024309b560c6c69f6f331c614df1da221be7054c
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 2 16:15:19 2007 +0100
+
+ The Array#[]= spec seems to work now, so enable it.
+
+commit 76f118e62a0784326f5edf1c0fe46f6b6e682eee
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 2 14:28:49 2007 +0100
+
+ Made Math.ldexp only accept integers as the second argument.
+
+commit 22bd7369efd1f738835e9c0a6a4624a26dae02d1
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Nov 2 13:30:50 2007 +0100
+
+ Implemented some missing File::Stat methods.
+
+commit d6dc42d9085fed5f8bf482d7f84dd9c5fbd4423c
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Nov 1 12:24:53 2007 -0700
+
+ Fixed specs failing MRI for File.stat and File.basename.
+
+commit 46f4de189e987f3071ede57f2bb1f7c892d67bd4
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Nov 1 17:30:47 2007 +0100
+
+ Fixed ticket #83: Array#push doesn't die anymore after calling Array#shift.
+
+commit 8debed24e957e48b10d60885d9a43083aab4d923
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Nov 1 11:14:22 2007 +0100
+
+ In the Numeric#coerce spec, coercing strings to numerics should work.
+
+ We can remove the TypeError checks from this spec, since those
+ are included in the specs for the Numeric operators.
+
+commit 28cf656fb25ce38453acb2efdcf2e9ac16bb4460
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Nov 1 01:33:31 2007 -0700
+
+ Removed Hash#fetch definition from fetch spec.
+
+ Fixed spelling of Hash#find_unambiguous.
+ Updated CI excludes.
+
+commit a6a69b469d94d0912ccbf123fdb9f53cbaf32830
+Author: Akshay Rawat <akshay.rawat@gmail.com>
+Date: Tue Oct 30 21:47:51 2007 +0530
+
+ In the Time#isdst spec, don't depend on the system's current time zone.
+
+commit 1be129f98e0d548a023cc32f5ab763361e2a9c6b
+Author: Daniel Lucraft <dan@fluentradical.com>
+Date: Wed Oct 31 21:05:04 2007 +0000
+
+ Fixed String#split to not return non-matching captures anymore.
+
+commit 5f7f798ef26fc8ee1e83c5e392c1fb2e60e31382
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Wed Oct 31 21:54:56 2007 +0100
+
+ In the Numeric#coerce spec, don't try to coerce strings to numerics.
+
+commit e26b7645af27d5bfc250c2c11f7e72349750f5c7
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Wed Oct 31 10:52:13 2007 +0100
+
+ Added a failing spec for Ticket #83.
+
+commit 9144f0c55eb5f40409bec514f08f89bdba61f800
+Author: Daniel Lucraft <dan@fluentradical.com>
+Date: Wed Oct 31 13:57:54 2007 +0100
+
+ Fixed math/constants_spec.rb.
+
+commit 4b521cacb667ca5245954bc03ebfec67c0ac235c
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Wed Oct 31 23:26:45 2007 +1100
+
+ Modified spec to reflect expected differences in masgn retval behavior
+ between rbx (true) and MRI (array of rhs vals).
+
+commit 1f6c50f5c77566e66cb0b842733b7f4f4b24e937
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Oct 30 18:13:47 2007 +0100
+
+ Use a fixed timezone for the Time#strftime spec.
+
+commit 60a25e997def085f3ae29773ce70ddc5b7c38d46
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 30 00:47:38 2007 -0700
+
+ Fixed Kernel#raise to not output if $VERBOSE == nil.
+
+ Guard Marshal.dump specs to eliminate error output until
+ a proper Marshal is implemented.
+
+commit e446f2e329a6dfaacb45b5b86ba43ebd9ec606a3
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 29 23:17:49 2007 -0700
+
+ Added IO::SEEK_SET, SEEK_CUR, SEEK_END with FFI.
+
+ Fixed IO#close to raise IOError if already closed.
+
+commit fcb1ac4d076c07065878c2e65bf7bb44ddef400c
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 29 22:37:23 2007 -0700
+
+ Specs for IO#seek and IO::SEEK_SET, SEEK_CUR, SEEK_END.
+
+commit a3570f6702dabd303fcd10d4cfc0e753cff69bb5
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Mon Oct 29 22:33:34 2007 +0100
+
+ Make Module.new actually work.
+
+commit 9709fa96b91afe5140f76726f1f7d4b89f8a6d54
+Author: Brian Donovan <brian.donovan@gmail.com>
+Date: Mon Oct 29 11:30:32 2007 -0700
+
+ Ticket #75: Fixed Enumerable#sort_by.
+
+ We must not call the comparison proc when the object and pivot are
+ identical.
+
+commit 52e97da6bbcd28ec4349abcf25b089648d085652
+Author: Akshay Rawat <akshay.rawat@gmail.com>
+Date: Tue Oct 30 02:18:56 2007 +0530
+
+ Enabled Math specs that were fixed by Ticket #59.
+
+commit 0f98800d4ab1db526304f1d26597ca3880c811da
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Mon Oct 29 19:29:16 2007 +0100
+
+ Ticket #59: Kernel#send now calls private methods, too.
+
+commit 754e48c223c3464c7d048452585c07b8d0b3d8c7
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 29 00:11:41 2007 -0700
+
+ Specs for IO#rewind.
+
+commit 0bfd6bcca8fb287899fadeae81dd7c00b05d07e9
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Oct 28 23:40:37 2007 +0100
+
+ Module#public_instance_methods now handles attribute accessor methods.
+
+commit 0a22b36b9bc50a34f1da1d0e994f1a6689195652
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Oct 28 23:26:17 2007 +0100
+
+ Added a failing spec for Enumerable#sort_by.
+
+commit 006534b173a186c25c228b653d5ac9d81b20f57e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 28 21:51:40 2007 +0100
+
+ Update Module spec excludes.
+
+commit 496df827eeeb600858fa8c7b26482aa3f653fee1
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 28 21:50:47 2007 +0100
+
+ Make Module#ancestors specs pass.
+
+commit 18185cde2b47374c304e2528a084ea1f7b5178d2
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sun Oct 28 19:46:22 2007 +0100
+
+ Added a failing spec for building an array that includes a splatted array.
+
+commit f120a470a5e07a7e53b1e006173942d58956e86b
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 28 19:33:10 2007 +0100
+
+ Extended Kernel#` specs.
+
+commit 7e184c5bbc7be16cc8f7be01713543f222edd267
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 28 19:00:52 2007 +0100
+
+ Removed Exception message dependencies and extended Kernel.String specs.
+
+commit 2853dc58209b3b8d122cee66c7d83e967d0879de
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Sun Oct 28 23:01:54 2007 +1100
+
+ Fix for multi-arg operator assign through [], e.g. x[0,3] += 5
+
+commit 91b88710ddc1e8553e51c404cee4039f4d6abf24
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 28 13:05:08 2007 +0100
+
+ Fixed File.ftype specs.
+
+commit 448fdc2def3a9ab249dadf9335568ca30b76f70e
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Oct 28 00:36:11 2007 -0700
+
+ Updated compiler specs.
+
+commit 0fb510c14ee8787b5965d5665e50da92a988faa6
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Oct 28 00:32:41 2007 -0700
+
+ Fixed Bignum#coerce specs.
+
+commit 5e52a259b91e81fe5497f44107dee6ffd613b3be
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Oct 28 00:22:40 2007 -0700
+
+ Fixed wording on Rubinius Bignum#coerce extension specs.
+
+commit 19e0259ca51691afe341b1217ab92862b307fe17
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Oct 28 00:15:18 2007 -0700
+
+ Revert "Remove invalid and failing Bignum#coerce spec."
+
+ This reverts commit 2371b920ca3f956213ab9e406a3b5d2afab4f18e.
+
+commit 4986ec283ee5aa9e392065c74d64952d36554b91
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Oct 27 23:50:05 2007 -0700
+
+ Updated CI excludes for Array#pack.
+
+commit 5472f30201d7cddd4465adb246fa32927fe03d91
+Author: Alan Hurdle <alan.hurdle@gmail.com>
+Date: Sat Oct 27 18:38:30 2007 +1000
+
+ Bunch of fixes to Array#pack to pass the current set of pack specs
+
+commit 20210a617a3f31c5dc0eda9fa371c49200c11f67
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 28 02:30:02 2007 +0100
+
+ Updated spec excludes for Module specs.
+
+commit 712e3cc6a5d8a69834449e1039dfae3e07fcdcc2
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 28 02:18:00 2007 +0100
+
+ Removed the dependency on some Exception messages.
+
+commit 2371b920ca3f956213ab9e406a3b5d2afab4f18e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 27 16:15:33 2007 +0200
+
+ Remove invalid and failing Bignum#coerce spec.
+
+commit e1e62e7749d47c838d6b7cd1e95863c0c90d3de0
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Oct 27 20:59:49 2007 +0200
+
+ Fixnum#div now always rounds towards negative infinity.
+
+commit 9a4ccbe8381db5b6280c9d1dfcf6fa21a4838c4e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 27 15:09:57 2007 +0200
+
+ Updated Spec excludes for Bignum and Fixnum specs.
+
+commit 889c939a668b9b1a4fd8f5a0cfd8bad85c3a5977
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 27 14:24:27 2007 +0200
+
+ Fix Integer#[] when given a Bignum.
+
+commit 45d97332f4ec5a174884024c954ceeb6eb852f5f
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 27 13:46:51 2007 +0200
+
+ Partial fix for #68: Fix Hash#fetch to correctly handle yielding with a default value passed.
+
+commit a785ea28f39c71a98007a7fafc23985dd21b596f
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Oct 27 13:39:42 2007 +0200
+
+ Updated CI excludes for recent Hash fixes.
+
+commit 6dd909fede466ed813ec7c5d207c5deeb69c9eb7
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 27 11:33:22 2007 +0200
+
+ Fix for #67: Enumerable#sort should not depend on #size.
+
+commit 720489aa52bfabd492c307330204772b5eba6755
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 26 00:21:37 2007 -0700
+
+ Updated CI excludes for spec/language.
+
+commit 41e8a07252b2df9c1e858922195a72f9a40c882c
+Author: Akshay Rawat <akshay.rawat@gmail.com>
+Date: Fri Oct 26 02:37:18 2007 +0530
+
+ private keyword should mark a Module method private
+
+commit a201e631cbaabcc5964cfa3eb28a9fa8be1bf347
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 26 00:11:01 2007 -0700
+
+ Added spec/language into CI specs.
+
+ Updated CI excludes for spec/language.
+
+commit 833fe76de0c0b900ef5255b2abecd19943404c0c
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Oct 25 23:53:35 2007 -0700
+
+ Updated compiler specs and CI excludes.
+
+commit f31e5af358d2b5c3ff4afd3819b3a3e571427f8e
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Oct 25 23:28:13 2007 -0700
+
+ Migrated Adam Gardiner's compiler patch 236d213de8 to stable.
+
+ Updated CI excludes for language/variables specs.
+
+commit bd9e47b1b7624df5e2ae0f31a7fd53c787ecc7e4
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Oct 25 22:50:22 2007 -0700
+
+ Fixed language/variables spec to use fixture class.
+
+ Added CI exclude file for language/variables specs.
+
+commit 688f03ac452f698105812c28c29dcc7162b7037c
+Author: Adam Gardiner <adam.b.gardiner@gmail.com>
+Date: Thu Oct 25 22:43:20 2007 +1000
+
+ Added specs for operator assignment, i.e. +=, *=, ||= etc
+
+commit 982dfee01bedb55e8dbf62d279bc4a375e58ec50
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Oct 25 16:53:45 2007 +0200
+
+ Don't hardcode the result of Hash#to_a in the Hash#shift spec.
+
+commit 4bf7c8d2d387c002004da5df9f9c2a06fb65e61e
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Oct 25 01:42:32 2007 -0700
+
+ Commit tilman's language block spec additions with some modifications.
+
+commit ff8f6f5b5f5285b0fcf361d84523bf21320074b2
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Wed Oct 24 20:20:12 2007 +0200
+
+ Extended the Hash#[] spec with a test case for ticket #65.
+
+commit dc61b1e771c70e54f98859da3dd31a4ea61384e1
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Oct 24 07:11:07 2007 -0700
+
+ Specs after(:each) MUST come before it blocks.
+
+ Updated CI excludes for IO.read specs.
+
+commit 06539bad037e0ef7368ea5cbb5780fce7bbea443
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Wed Oct 24 21:26:49 2007 +1000
+
+ Initial IO::read specs.
+
+commit a2f26d7a7b1997510edff1792eaec6507ba38208
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Oct 23 19:30:46 2007 +0200
+
+ Implemented Numeric#remainder.
+
+commit 2bc5fcee6be4db3e0e0c46aa7c1b8ef5a5c57957
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Oct 23 19:10:54 2007 +0200
+
+ Fixed Bignum#modulo(0.0).
+
+commit 68965dc12ea369f6db64c208cb2ce123c1398bb8
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Oct 23 10:20:04 2007 +0200
+
+ Extended the Numeric#nonzero? spec a bit.
+
+commit 290ddde29d6c64e9c81f69780b7b0c967b2b4901
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Oct 23 10:15:57 2007 +0200
+
+ Added Numeric#nonzero? and killed bad Fixnum#nonzero? in bootstrap.
+
+ This fixes the Numeric#nonzero? specs.
+
+commit e9a1b257fc95c181e46c679d301a324134a725d4
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Oct 23 16:07:58 2007 +0200
+
+ Enabled the Numeric#step spec now that it works fine.
+
+commit f4016db94eee2ec93a2cc487181c9ec2fa0d59d0
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Oct 17 13:51:04 2007 -0700
+
+ A number of fixes found while debugging test/unit and optparse
+
+commit 7c7920c3e7727c3514b493ba299a52c5e5cde8f6
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Oct 22 18:12:42 2007 -0500
+
+ Numeric#step is capable of floats and passes all tests
+
+commit ebc6ec5be0239bba544c55ff77fdc88903f4bb28
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Mon Oct 22 20:56:33 2007 +0200
+
+ Made the Symbol#inspect spec pass.
+
+commit f0db8c3d1bb5dc444fc72ed5ca222f4cf5df8b35
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 21 14:00:30 2007 +0200
+
+ Fixed a bug in process_op_asgn1 and added a simple spec for it.
+
+commit 4fbce6e8a6ab8fbb6b69944677678611db68bcf2
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 20 20:03:50 2007 +0200
+
+ Fixed a failure in String#sub specs
+
+commit ca0332f9edb9e01ae216dee90674fb6f9809951c
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Oct 20 22:33:42 2007 +0200
+
+ Fixed the Bignum#size spec for Rubinius' implementation.
+
+commit ae9c2ac3fe9dc59a027af7571d6d3083bcccb490
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 20 14:14:49 2007 +0200
+
+ Don't rely on #respond_to? calls.
+
+commit 94938622aaf74e1f068c3b7ec8bfeccf763792ba
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Fri Oct 19 20:56:50 2007 +0200
+
+ Extended the private spec.
+
+commit bf000a15edcfdd30c43ae6563b5766617f245a60
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 19 00:49:16 2007 -0700
+
+ Updated CI excludes.
+
+commit ad146fc7ae22bfc26a536a40cf8dc4c0338cf25c
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Oct 18 19:45:27 2007 +0200
+
+ Added a spec for the 'private' keyword.
+
+commit f15b5a8c818932d0ab5bea46f48a326e468b3511
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Thu Oct 18 19:44:54 2007 +0200
+
+ Added Object#should_not_include.
+
+commit 80fdbd626d8ff99dc7ba4cf23a05d44ad98bd0cb
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Oct 18 09:31:51 2007 -0700
+
+ Updates Hash so:
+ * No longer freezes keys
+ * Specs reflect the lack of freezing
+ * shift spec doesn't fail purely because to_a is broken
+
+commit 197f36b6626b61203709704db869324a539764d5
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 17 20:11:50 2007 -0500
+
+ moved File::expand_path to platform and made several fixes + new specs
+
+commit 7e8506fd510ab4e6f07e6d36456fdfef6e5b080a
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Wed Oct 17 21:07:44 2007 +0200
+
+ Make sure that File.dirname doesn't modify its argument.
+
+commit 271bc31ba814e68fb414ebf29cf9648f57fe4cb6
+Author: David Altenburg <david@gensym.org>
+Date: Wed Oct 17 00:39:59 2007 -0500
+
+ Added to fork spec: check that fork returns a nil pid for the child process
+
+commit 5d45341c55400a51d8cae3128bba265e7d441fab
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 17 05:19:49 2007 -0500
+
+ moved File.basename to platform, added specs, and fixed specs for all but a disputable behavior
+
+commit ae7afd794881a4dedadf876f61369e5e88da695b
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 17 04:47:24 2007 -0500
+
+ added platform/file.rb and fixed File.dirname for all and updated specs
+
+commit 71bf9b1c9cd7fb81692186d21b133fde43e8a6b7
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 17 03:44:33 2007 -0500
+
+ spec to check if break exits all types of yields and loops correctly
+
+commit 3a546b40271d35bf7c60bb56a68ca49089ac9a34
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 17 03:01:40 2007 -0500
+
+ clarified include_spec
+
+commit 40d8ed96fa689daf31039e71f91ed5520a821aa2
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 17 02:38:46 2007 -0500
+
+ specs Module#include and Class#include that check to see if constants, public_methods and instance_methods are imported correctly
+
+commit ff462080a58aaa61759830e18f3a5757a883980d
+Merge: 5a2c858... 5cf41ab...
+Author: Jon Guymon <gnarg@kiryo.(none)>
+Date: Wed Oct 17 01:55:33 2007 -0400
+
+ Merge branch 'puts_specs'
+
+commit 5cf41abaff9dc04cdba5fe50492d4ebfdde2a274
+Author: Jon Guymon <gnarg@kiryo.(none)>
+Date: Wed Oct 17 01:55:01 2007 -0400
+
+ normalized specs for IO#puts StringIO#puts and Kernel#puts
+
+commit 5a2c858086c1b02a54864ff82c12d4bf3a559535
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 17 00:43:24 2007 -0500
+
+ fixed posix File.join and added edge cases to specs
+
+commit e7972b8617b8b0ef2a19a1f7ddedd4d93ab80f5c
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 16 21:17:21 2007 -0700
+
+ Commit gnarg's loop specs (#49).
+
+commit 3fcdd60b4c9fc20081987bb13aab37b9419939a3
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Tue Oct 16 19:46:36 2007 +0200
+
+ Make this spec usable by loading pathname.
+
+commit 276b6cc5620a5a3629d56b04ade7c397a48c2488
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 16 00:53:11 2007 -0700
+
+ Exclude metaclass instances from Module#ancestors list.
+
+commit e108e7f3f8a6ef7cf2acf4bb7e7a6609900a3ebc
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 16 00:06:54 2007 -0700
+
+ Updated CI excludes.
+
+ Updated compiler specs to match recent changes.
+ Added compiled core/string.rb from changes in edeffe90517.
+
+commit 1a1410f394b3de23b63560f2a5c1312cc6451d2e
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Oct 15 19:49:40 2007 -0500
+
+ spec for __FILE__ added
+
+commit e158c3130f033a1029ae26888b8e7e541f2b388a
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Oct 15 19:46:58 2007 -0500
+
+ spec for __LINE__ added
+
+commit d09ad9e6b28c91f5d00db5d0b369c4932eabbe2b
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Oct 15 18:45:48 2007 -0500
+
+ spec for throw/catch inside of ensure reverted and clarified
+
+commit 0e5336f1572fc1ad766cff61d8843410d28df9db
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Oct 15 18:33:27 2007 -0500
+
+ spec super refactored into fixtures and expanded to test all methods on each class
+
+commit b998ec8e682c3a0f2160066bb84f40b68f748407
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Oct 15 16:26:58 2007 -0700
+
+ Implement undef and Module#undef_method
+
+commit fed8486110930cabce64e0421638a867740e4d21
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon Oct 15 15:54:44 2007 -0700
+
+ A bunch more language spec cleanups.
+
+commit 66086cb333432a29d4c4ce4fec6a01c0ac88c5a5
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri Oct 12 19:33:59 2007 -0700
+
+ Bunch of compiler fixes to pass more language specs
+
+commit 680e0ca4cafb20fa053f0dd5cd72915da9fbc86f
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Mon Oct 15 17:36:09 2007 -0500
+
+ specs for super involving inheritence, modules and metaclasses
+
+commit 167febd232f5cf4696cf8e81a96d1c9d80744e36
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 15 15:32:48 2007 -0700
+
+ Update CI excludes on OS X.
+
+commit 948e2573800859931e8c61e72069c21e9a50193b
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 15 14:23:02 2007 -0700
+
+ Update compiler specs to match recent changes.
+
+commit a015bac050e1080548bd947c5f59b344175a809d
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Mon Oct 15 23:51:01 2007 +0200
+
+ Enabled the remaining Bignum#& spec.
+
+commit 0b37b2946772ea41fe7b14c762be7fdbaa4a6f8d
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Mon Oct 15 18:20:56 2007 +0200
+
+ Updated Spec excludes for Bignum.
+
+commit ae613272bcf0c260ad3da00ffd14d4a76422ac46
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Mon Oct 15 08:30:11 2007 +0200
+
+ Added the beginnings of a File.stat spec.
+
+commit 81147d2eadb0397c2bcc1b9dd620bb55b6e0e53d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Oct 14 11:33:21 2007 -0700
+
+ Fixed Float#to_s for numbers of the form "\d+.0".
+
+commit 2f9ba53190ca19ca425126d1319f47b3bbce12f6
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 14 18:57:04 2007 +0200
+
+ Updated Bignum excludes.
+
+commit 0c81822cf703da13f6a8783cc6cd4ad453d2ff74
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 14 18:05:45 2007 +0200
+
+ Add some OpenStruct specs.
+
+commit add2a900029530cb35b6463525313f432b7f36f4
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 14 17:29:38 2007 +0200
+
+ Extended some more Bignum specs.
+
+commit 45cf3a275d390d4ae1d995eca89e10ba82d2288f
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 14 17:29:01 2007 +0200
+
+ Extended the Fixnum#to_s specs a bit.
+
+commit d8a42cdd57967ee07cccfa5f3f814d97353c48c9
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Oct 13 23:16:37 2007 +0200
+
+ Fixed the bug that broke 'case' blocks with a single 'when' statement.
+
+ Acked-by: Wilson Bilkovich <wilson@supremetyrant.com>
+
+commit 5624627fd61378fce65aebf2ffacc39c45ac5ee6
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Oct 13 23:48:32 2007 +0200
+
+ Ticket #37: Fixed Bignum#& segfaults when the argument isn't a bignum.
+
+commit 2081e5f53ba80cb9aa2ee272d4e543db1d4e732e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 13 23:43:08 2007 +0200
+
+ Modify and extend Bignum specs a bit.
+
+commit 7917f4f8a538a3251e3cb17d55e4cf2a523af8d5
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 13 23:42:44 2007 +0200
+
+ Modify the fixnum specs a bit.
+
+ Remove dependencies on Exception messages.
+
+commit 171f25c25865da618c2e2a9a7b221abda613efa4
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 13 02:02:12 2007 +0200
+
+ Extended Fixnum#<=> specs a bit.
+
+commit f708429a161c52dd713b4239527247c57fa158af
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 13 23:30:37 2007 +0200
+
+ Guard bin/ci from running the new Bignum#& specs, which segfault (on OS X at least).
+
+commit 19f40e0ae1b60c037d0c38537a0924ad5726902a
+Author: Ben Curren <ben@esomnie.com>
+Date: Sat Oct 13 13:46:35 2007 -0700
+
+ Refactored const_name_to_sym to share logic with Class#attr.
+
+commit ee9daad614fa746a3fe2fc1b9123c65dbb0814c7
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Oct 13 11:52:08 2007 -0700
+
+ Identify which ruby platform and version before changing this spec!
+
+ Revert "Fix spec to expect correct result."
+
+ This reverts commit 8268469c563943cba6c1afce5d84defbc35f1789.
+
+commit 14a7781944491e5a1c3f5c664adcac4e1c383f2f
+Author: Tilman Sauerbeck <tilman@code-monkey.de>
+Date: Sat Oct 13 17:15:24 2007 +0200
+
+ Added a failing spec for 'case' with only one 'when' statement.
+
+commit 8268469c563943cba6c1afce5d84defbc35f1789
+Author: Tom Mornini <tmornini@engineyard.com>
+Date: Sat Oct 13 03:22:47 2007 -0700
+
+ Fix spec to expect correct result.
+
+commit 671f93c69e74976c3f5886c7fe8eb32402ccd338
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Oct 12 19:06:07 2007 -0500
+
+ specs exiting threads using return, raise, and throw
+
+commit 119154a3ea5ecee20e77726b38fb58ee4b536d48
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Oct 12 18:59:47 2007 -0500
+
+ spec to ensure throw exits from correct nesting and can return a value
+
+commit f36f68f075b34b5436257aba1ae41c14c04adcae
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 13 01:54:42 2007 +0200
+
+ Method#[] specs should include the fixture classes.
+
+commit 22d32a24eb799307e42af55b04752c74ff500080
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 13 01:40:01 2007 +0200
+
+ Extend Bignum#coerce, Bignum#&, Bignum#| and Bignum#^ specs.
+
+commit e1f682e27d2486d65297cf2121c354a99954a56e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 13 01:38:55 2007 +0200
+
+ Removed a dependency on an exception message in Fixnum#coerce specs.
+
+commit 9754ed5e74eeb6d62f0015f3615d077aa2e58a6f
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Fri Oct 12 21:41:56 2007 +0200
+
+ Fixed File.chmod and File#chmod specs on win32.
+
+commit 5ad3a4b7035bdade48586191c6e26cde1e74976c
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 13 01:37:46 2007 +0200
+
+ Remove wrong spec from Bignum#divmod.
+ Update CI excludes.
+
+commit b068c8634b56cd9129f9fc7c309bfa81869209c8
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Oct 12 18:21:52 2007 -0500
+
+ specs for behavior of throw/catch and how they interact with ensure
+
+commit 45d4a8be8f20b2b70d32d0fdd340feb8897a1ad7
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 13 01:21:21 2007 +0200
+
+ Add (skeletal) Process::Status.
+ Set $? in Kernel#system and Kernel#`.
+
+commit ef1499962a16a7ce85bffe9e61863d2806caf6ec
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 12 23:52:16 2007 +0200
+
+ Regenerate core/dir.rbc and CI excludes for Dir.
+
+commit b999f31ded2a7eccb856d95653a2826a3a190204
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 12 23:02:39 2007 +0200
+
+ Fix typo in Dir.mkdir.
+
+commit de235630aa08df803be0420084b0a61ee35f5448
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 12 13:56:13 2007 -0700
+
+ Added dev_null spec helper for capturing or silencing $stderr, etc.
+
+ Fixed failing specs on OS X MRI 1.8.5.
+
+commit 01e27ea5fa0e0f0d170cd88f128adfbb2a2703bd
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 12 22:01:43 2007 +0200
+
+ Add spec for backticks and their setting of $?.
+
+commit f7b18c19e47c15f3ab05f8fa548eff034206b0d8
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 12 13:21:03 2007 -0700
+
+ Added guards to make specs pass on ubuntu feisty MRI 1.8.5.
+
+ Fixed rspec_helper should_include to take multiple args.
+
+commit b2d25d4a502dca79ea98f60d937be7dbd8f496d2
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Oct 12 14:19:55 2007 -0500
+
+ spec for retry/redo to control order of an enumeration
+
+commit eec535a19dc2b20156349720dc3bb526c9fa4f1e
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 12 18:53:33 2007 +0200
+
+ Revert "Fix Kernel#`: set $? to the subprocesses exit status. Add a spec to check that."
+
+ This reverts commit 40da2d5c68196c3c9002c4ca75ead0fefc520bef.
+
+commit 40da2d5c68196c3c9002c4ca75ead0fefc520bef
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 12 18:43:44 2007 +0200
+
+ Fix Kernel#`: set $? to the subprocesses exit status. Add a spec to check that.
+
+commit 5da57253750e854bd9baf5378684222a895e7fd9
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 12 16:24:18 2007 +0200
+
+ Shield "strange block args" spec from being run by mspec.
+
+commit 2a8f7d7dd6b0f7f800320f84d16d5d089357e085
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 12 14:48:42 2007 +0200
+
+ Fix block specs for MRI.
+
+commit ade6c39f6199198e0015558698bc7d0333f7bcd0
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Fri Oct 12 12:07:49 2007 +0200
+
+ Fix Array#delete specs.
+
+commit 825af45d5effb6909bb0832f92621b96e51dc380
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 12 01:15:23 2007 -0700
+
+ Updated CI excludes.
+
+commit e1bfb47d3560929512cbdf5c27f56c92435ce29f
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 12 00:40:53 2007 -0700
+
+ Removed printing summary at exit in mini_rspec.
+
+ Set $VERBOSE=nil when running the specs.
+ Fixed specs failing MRI.
+
+commit 1f1a041d8bcfaeb8dd3cb17f7d31b21281e690a2
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Oct 11 18:26:14 2007 -0700
+
+ Moved shared specs to shared directories.
+
+ Rewrote Module#method_missing specs.
+
+commit f9177eb198003b495f485a13910808fe603030ad
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 20:54:22 2007 -0700
+
+ Added a failing test for setting and getting constants on an instance of a module.
+
+commit d9cbad87fd4d578e4f637627fa03cab312882a36
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 20:51:27 2007 -0700
+
+ Updated the excludes for module tests.
+
+commit 938f034bad41f4fe3391b941e536bce9e1be0af6
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 20:49:57 2007 -0700
+
+ Updated const_set_spec to not create a new instance of Module for testing purposes.
+
+commit 550caaf78723b00f95c5f8f38215b15a0940698a
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 18:21:01 2007 -0700
+
+ Updated the excludes for the tests that are now passing.
+
+commit 82c51fc652e215f0dc421099329c03a37af8e8f8
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 17:56:48 2007 -0700
+
+ Updated const_set and refactored the valid_const_name? further.
+
+commit c6323c74d0ee7b554d2cfbff3bd8d85ea910e0c9
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 12:01:27 2007 -0700
+
+ Added logic to remove Object and empty from a recursive string for const_get and const_defined?
+
+commit c108d2a623f5041f46b6efa32d0b331f4f91d669
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 11:58:04 2007 -0700
+
+ Added back the recursive case for const_get and const_defined?
+
+commit b976f184d8ade3b5d32d3e7ec11027c21c2bce2a
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 11:33:41 2007 -0700
+
+ Refactored const_defined to use const_get.
+
+commit 82c5c14b948cedbf3bed5f7996634b0238e4de55
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Oct 11 17:38:05 2007 -0700
+
+ Bunch of compiler fixes, almost have test/unit and optparse running.
+
+ * Adds support for /ao#{name}/o (aka dregx_once)
+ * Invalid redo's raise an exception at runtime instead of compile time
+ * defined?(a.foo) works
+ * Lots of work on getting the block arg semantics right, including a new
+ instruction, passed_blockarg which is used to detect at runtime how
+ many block args were passed in.
+ * bug in 'yield 1, 2' versus 'yield [1, 2]' fixed
+ * A little better error reporting on compile errors
+ * Fixed Class#<, added #>, #<=, and #>=
+ * Fixed Hash.new
+ * Fixed nested case problem
+
+commit 1369b104a3f966dd4d279362afdc6ccb72f06de3
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Thu Oct 11 22:47:16 2007 +0200
+
+ Fix String#eql? specs.
+
+commit b190009707c120edb257a9ad92697145092c5612
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Oct 11 10:57:10 2007 -0700
+
+ Shield parse errors in block args properly
+
+commit 0509ecbd6aeb973061866c5e04c590f975174b41
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 10:21:08 2007 -0700
+
+ Updated tests to test FixNum being passed to const_defined?
+
+commit 80116298779dc5afd3294cd83d758d76d0dcdf50
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 10:16:46 2007 -0700
+
+ Added error checking to const_defined?
+
+commit eed3ae097b1dae17e45cdb959b75d1fa7cf21c1b
+Author: Ben Curren <ben@esomnie.com>
+Date: Thu Oct 11 09:25:53 2007 -0700
+
+ Convert paramter to_str if it responds to the method.
+
+commit 348df85a082eee56c301bce594d6c522050e34dd
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 10 18:49:34 2007 -0500
+
+ specs for language/retry and updated redo to show differences between them
+
+commit e924e2bb206317e8f5375c979f5e4e1046fccca9
+Author: Tom Mornini <tmornini@engineyard.com>
+Date: Wed Oct 10 00:55:47 2007 -0700
+
+ Add Class#attr, refactor Class#attr_reader, Class#attr_writer and
+ Class#attr_accessor, pass all specs for Class#attr_*, fix a couple of issues
+ with said specs.
+
+commit 21b0bdc67c6a8cc4ad4b9d3942a2608fb45da31d
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 9 15:10:04 2007 -0700
+
+ Commit #198, patch from Will for Module#(private|public)_class_method.
+
+commit 2cf5f0b4683d0a65181c1450d0714c4e165db1cd
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Oct 9 21:00:13 2007 +0200
+
+ Moved shared specs.
+
+ Moved shared specs into the 'shared'-subdirectory so specs don't depend on each other anymore. Added some more shared specs.
+
+commit e558fab61ce9f7c5211d005aff2c5e8fc1b39931
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Oct 9 19:53:46 2007 +0200
+
+ Fixed a failing Array#each spec. Closes #14.
+
+commit 0d77eefd718c826e02376edc8643364eb511773d
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Oct 9 19:09:17 2007 +0200
+
+ Removed remaining dependencies on Exception messages in Fixnum specs.
+
+commit dd4063ba46eb313a57957d76dce3608dd8e5c161
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Oct 9 18:58:01 2007 +0200
+
+ Fixed String#crypt spec.
+
+commit d5a2bb2b000fae7391e512c5bcab054ce967de3b
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 9 09:35:51 2007 -0700
+
+ Updated CI excludes after applying Akshay's Precision specs patch.
+
+commit 10cd5764bbf51f1defa6815f8b07fcdce0de8875
+Author: Akshay Rawat <akshay.rawat@gmail.com>
+Date: Thu Oct 4 21:48:15 2007 +0530
+
+ Specs for the module Precision
+
+commit 2e711c30e4e9ce50d9c20ab14a3b99ea47be32e9
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 9 13:56:45 2007 +0200
+
+ Make IO#puts specs pass in MRI.
+
+commit 13dc28c47c3211f01663d002847badb50277f277
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 9 13:44:51 2007 +0200
+
+ Silence warnings when running Hash specs in MRI.
+
+commit 52f903938f4eacf4465f7a36cacb25aa662aa559
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 9 13:44:02 2007 +0200
+
+ Turn Hash#values_at into a shared spec.
+
+commit 1e02ced5a68f16b8a65809136d954c68c9fdc590
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 9 12:59:58 2007 +0200
+
+ Add a few more specs for Struct#new.
+ Regenerate CI excludes for Struct.
+
+commit 94ea8c1f25761384796e9499e0b4b3faeba9da66
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 9 12:48:03 2007 +0200
+
+ Silence warnings when running Struct specs in MRI.
+
+commit 5ea6b219a8465cfad86dae9ae12d6a8d85812532
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 9 12:42:58 2007 +0200
+
+ Apply patch from ticker #23 by Jon Guymon (gnarg).
+ Make Struct specs not depend on method argument evaluation order.
+
+commit 8cbf7b94300e6ebcc0ee3cbe0de8123ef3563e96
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 8 22:08:29 2007 -0700
+
+ Fixed that including a module includes the whole chain.
+
+ Fixed that Module#include only allows modules.
+ Simplified some module fixtures.
+ Updated CI specs for module.
+
+commit 4e7e2768d50392831a4d26f236d4cff733418225
+Author: Ben Curren <ben@esomnie.com>
+Date: Mon Oct 8 11:54:51 2007 -0700
+
+ Added puts spec for io and updated IO implementation to match MRI's. Updated Kernal#puts to delegate to $stdout.puts.
+
+commit edc724086e84725995ed1720d4fa7a781fd9c3c6
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 8 09:24:40 2007 -0700
+
+ Updated CI excludes for Module#define_method.
+
+commit a53ddb723a10d692223f05a49679e17f403fa128
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Mon Oct 8 01:05:04 2007 +0200
+
+ Fixed some Fixnum specs to not depend on error messages.
+
+commit d6bc4b47f3f395980c92f323cf029da1ccdba709
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 7 23:42:12 2007 +0200
+
+ Added another failing spec for Module#define_method.
+
+commit 49435e31289f593a118377b3513ec9e7cdfea06b
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 7 23:37:19 2007 +0200
+
+ Added failing specs for Module#define_method when given an UnboundMethod.
+
+commit 821c0114777fb2a77f1c85f216ee54e4c5340943
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Oct 7 22:29:47 2007 +0200
+
+ Apply patch from ticket #15 by Jon Guymon (gnarg).
+ Add Struct#eql?.
+ Rebuild core/struct.rbc.
+ Add more struct specs.
+ Update CI excludes for Struct.
+
+commit 1f14c3510d4563930d11155f36717c0fb851c678
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Oct 7 18:13:33 2007 +0200
+
+ Added some GetoptLong Specs.
+
+commit f9c8c00649212b924561300abbd0cb037c1d278d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Oct 6 23:00:05 2007 -0700
+
+ Update CI excludes for File#executable.
+
+commit 6d4427d07fc474e2404cdd2b6f3b925d99d90e67
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Oct 6 22:50:45 2007 -0700
+
+ Updated spec/excludes.txt from 72 items to 17.
+
+ Added -V | --verbose flag to bin/mspec.
+ Updated CI excludes.
+
+commit d4f5e44a8e2f8e682b779f45d12d060e83eb9fc7
+Merge: a035e9d... 42abc5e...
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 15:18:45 2007 -0400
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit a035e9d3d204cf7e5ddb2fec72ca471ff33c3b9b
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 15:13:28 2007 -0400
+
+ fix a bug in the File.executable? spec
+
+commit 3c23c945aaf143aa8706b1cd2956908a71940e26
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 15:09:55 2007 -0400
+
+ fix bug in File.executable? spec
+
+commit 94e59065bf921ae167a6b04edfef40de336978a1
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 15:03:14 2007 -0400
+
+ Revert "Revert "Add a few more Proc#call specs. And CI excludes.""
+
+ This reverts commit 7658362c3882c6be2ef67f6b57d6c6796ff5de98.
+
+commit 42abc5ed6e1ced2fa86e9dc9379c6bed4da4537e
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Oct 6 11:40:49 2007 -0700
+
+ Updated CI excludes for Kernel specs.
+
+commit 7658362c3882c6be2ef67f6b57d6c6796ff5de98
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 14:29:28 2007 -0400
+
+ Revert "Add a few more Proc#call specs. And CI excludes."
+
+ This reverts commit 567659dee34014d037d4797bf0c171597e0ac05d.
+
+commit 567659dee34014d037d4797bf0c171597e0ac05d
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 16:23:54 2007 +0200
+
+ Add a few more Proc#call specs. And CI excludes.
+
+commit d8e737b09f8ed984e57b4fbbd5c016a7643aa67d
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 15:56:33 2007 +0200
+
+ Fix Array#slice specs. Regenerate CI excludes.
+
+commit c79eeb620296a1802e6d194463063555638911bf
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 14:34:05 2007 +0200
+
+ Fix Array specs that depended on respond_to? being called on coercion.
+ Regenerate CI excludes for core/array.
+
+commit 8a60522fd8237fdfa36ef5518c9642216c66f8d6
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 14:08:22 2007 +0200
+
+ Guard Array specs for #freeze. Fix MRI Array specs for #freeze.
+ Regenerate CI excludes.
+
+commit eaaab65c54c3b81397441169761774ef95867297
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 12:47:55 2007 +0200
+
+ Add specs for Proc#call. Regenerate CI excludes.
+ (Most of these seem to be from e6cf8978.)
+
+commit 19bcb0f6ec1b2247985823492f0c25f0aa5d94ab
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 12:09:29 2007 +0200
+
+ Slightly amend the core/hash specs.
+ Regenerate CI excludes.
+
+commit 6d1afe325098a73757980bb208fb2c8c64bd016b
+Merge: ac9365e... 0d22ef5...
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 01:13:59 2007 -0400
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit ac9365e384263b6f062353f2afab3e33d8f84f3e
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 01:13:23 2007 -0400
+
+ added spec for OpenStruct
+
+commit e6cf8978a6dd441d5d4793c48438fab4150ca750
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Sat Oct 6 00:14:01 2007 -0400
+
+ added several tests to Proc
+ added tests for Kernel#lambda and Kernel#proc
+
+commit 7b69ae066cab2252375d1ad19c6f17b365c47c32
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 5 18:51:11 2007 -0700
+
+ Updated CI excludes for Array.
+
+commit f216e89033d10f3500798561282e48aa0e5b5537
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Fri Oct 5 20:45:41 2007 -0400
+
+ really simple spec for the Singleton class.
+
+commit d682b176237a988afa7ebdb3460d64ea41fab919
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Oct 6 01:54:31 2007 +0200
+
+ Applied esomnies
+
+commit b3018362c0cad86a5a026eb39b5f6ea4a8af1192
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 01:24:05 2007 +0200
+
+ Guard Hash specs for #freeze.
+
+commit a185f463adbab1d6f82126dde9abe88a29e83283
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 01:15:23 2007 +0200
+
+ Fix workarounds in core/hash specs.
+
+commit d796eb3d8a5d9a070b105f1fe0e9f46be5bfaaee
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Fri Oct 5 17:09:48 2007 -0500
+
+ specs for UDPSocket client/server
+
+commit 46a9c1a0d0610865b659c289293b444f0b3d6ae9
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 5 15:32:56 2007 -0700
+
+ Fixed bin/ci to not load spec/excludes.txt for every file.
+
+ Fixed bin/mkspec to not overwrite an existing spec file.
+ Updated Fixnum CI excludes.
+
+commit 1099f49c06de5621aff36216179f46c308e60a38
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 5 14:40:24 2007 -0700
+
+ Added basic IO#readlines spec and implementation.
+
+commit edc438039ee503c7b9d1fb83b04bd9bc1664cda5
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sat Oct 6 00:09:41 2007 +0200
+
+ Regenerate core/hash.rbc, core/hash CI excludes.
+
+commit 2ad7d015a316620a488ed1cdeb45fe696b9d410a
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 5 23:56:59 2007 +0200
+
+ Extend core/hash specs to check for LocalJumpErrors.
+
+commit 42d961f0ab8a7e23a822b41ca82aaed5a48da2bf
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 5 23:21:20 2007 +0200
+
+ Refactor and fix Hash#inspect.
+
+commit b51402d8724478b85789d19857a2a48442470fcb
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 5 11:29:08 2007 -0700
+
+ Fixed bin/mkspec to not create the spec file stub if the file exists.
+
+commit efe79de398db491ce97666a3f4f3b38265c1ab95
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 5 10:55:52 2007 -0700
+
+ Updated CI specs. Guarded String specs for #freeze.
+
+commit 8647951df433d427be31bec060edf5b7efb46e46
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Fri Oct 5 17:04:25 2007 +0200
+
+ Replaced all occurrences of Object#coerce_to with Type.coerce_to and removed Object#coerce_to.
+
+commit 778e11d2df647cf91a712bb30df34152c71dbc3f
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 5 11:42:40 2007 +0200
+
+ Don't work around rbx bugs in Hash specs.
+
+commit 4b42923eb2cdebe43f9e9dd80fff98d9ded26e4b
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 5 11:29:33 2007 +0200
+
+ Fix Hash specs to pass in MRI again. (Doh!)
+
+commit 8a4f0b1c0d95b7a87ed99583797cf7d3710fb15a
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 5 02:24:30 2007 -0700
+
+ Updated CI excludes for Hash.
+
+commit cecbf342546f37f4923728e8381e7fafcb039633
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Oct 5 02:22:41 2007 -0700
+
+ Changed bin/ci to run in a single process. Updated CI excludes.
+
+commit ba0f4ef5405665c84af4410d70be5ef911a93195
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Oct 4 22:58:50 2007 -0700
+
+ Adds the intern spec from Ticket #8
+
+commit 0721f6ea40f51202ec9d2d421061be92e05a18b9
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Thu Oct 4 22:39:00 2007 -0400
+
+ Commit #207 Xavier Shay Enhanced specs for Hash
+ fixed Binding#dup spec
+
+commit ce4a1866ef65e041fbed224c3f694ca534d0a0d1
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Oct 4 18:24:21 2007 -0700
+
+ makes String#delete faster
+
+commit 7ec0eeadf554150159f0a04468b16de8f06c2e8a
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Fri Oct 5 00:32:25 2007 +0200
+
+ Whoops, two more frozen TypeErrors I forgot.
+
+commit 78a3de42bf0e6f1478b2aac903c25143fd56195a
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Thu Oct 4 23:17:42 2007 +0200
+
+ Regenerate CI excludes and core/hash.rbc after revert.
+
+commit beaa5d022b19cb70213d4fe14e10d7f1a5f90a3a
+Merge: c7ea881... 8cb4b0b...
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Thu Oct 4 16:12:41 2007 -0500
+
+ Merge branch 'spec_block_parameters'
+
+commit 8cb4b0b2c3c766618a523a0ef9a83106761ee2f8
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Thu Oct 4 16:11:15 2007 -0500
+
+ specs for setting variables in block parameters
+
+commit c7ea8812f74184e6ee33bb236766f32fface2f95
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Thu Oct 4 22:57:09 2007 +0200
+
+ Regenerate CI excludes for spec/core/hash. New hash.rbc.
+
+commit 939e8c533fb70586f8c7c6f3506d6be13f492d78
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Thu Oct 4 22:11:18 2007 +0200
+
+ Fix Hash specs: don't depend on coercion to call respond_to?
+
+commit 422e45f210ec9dc2438ae3b11544823bb6ffdd50
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Thu Oct 4 16:21:27 2007 -0400
+
+ added specs for FileTest#exists? and FileTest#exist?
+
+commit e43466b52184a042bd38d33273acf7afa4580a96
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Thu Oct 4 16:12:58 2007 -0400
+
+ added spec for File.exists?
+
+commit 9f69c8193d92752a2be7c21d23dfe90fb9765f11
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Thu Oct 4 16:03:33 2007 -0400
+
+ fixed grammar error in Method#clone
+
+commit 9321aacf703eaec6d6bc26cce83ed7475cb27d46
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Thu Oct 4 16:00:31 2007 -0400
+
+ added several specs for Module
+
+commit a282c1c4c137e1bdeae34f2f9cd58bc73f257809
+Author: Jason Yates <jaywhy@gmail.com>
+Date: Thu Oct 4 14:19:07 2007 -0400
+
+ added specs for Kernel#binding and Binding
+
+commit 3e92b4528dbf47b80a25232979554f7e4309460a
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Oct 4 10:45:10 2007 -0700
+
+ Fixed ffi_sprintf_[fd]. Updated String spec CI excludes.
+
+commit 9e9a292a8a4befeb8a928d476119b02ac0df976e
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Thu Oct 4 18:53:47 2007 +0200
+
+ Alias Object#object_id to Object#__id__
+ Regenerate CI excludes for spec/core/kernel
+
+commit 8790e93c6d231baf7da07f11d02b91a38d28375e
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Oct 3 18:23:42 2007 -0700
+
+ Superclass checking and loop {} fix.
+
+commit 718ae6f28223e94b8ca0f3af7ce321c81a597804
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Thu Oct 4 15:05:59 2007 +0200
+
+ Slightly extend Object#kind_of? specs.
+
+commit 7fa087a7058fe8872bb9743abd6dd472cd2119d7
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Thu Oct 4 08:43:55 2007 +0200
+
+ Fixed some String#slice specs.
+
+commit b9be176a9e64669f2a787c9bdebc1ba30e344d97
+Author: Paul Meserve <pmeserve@gmail.com>
+Date: Thu Oct 4 01:37:56 2007 -0400
+
+ adding String#each_char
+
+commit c1b17108a78a4dc5d3e224158f8f9d76232003e6
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 3 17:42:06 2007 -0500
+
+ basic specs for Kernel#sleep
+
+commit 1fe895518bdccb93991f85a92f53876ed3d4df13
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 3 14:16:14 2007 -0500
+
+ added spec for Kernel.local_variables
+
+commit 00417283b36dcb58da82c6fc2e9be7580de945b0
+Author: Charles Comstock <dgtized@gmail.com>
+Date: Wed Oct 3 14:15:25 2007 -0500
+
+ added specs for Kernel#global_variables
+
+commit 5b944520099f129462c3b03fa6ee7d1bb0636fc0
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Wed Oct 3 14:07:09 2007 +0200
+
+ Fix String#index specs.
+
+commit c9cdef77c7fa8dda92c91cee5a47624b9c9dc9e8
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Wed Oct 3 14:05:34 2007 +0200
+
+ Fix String#hex specs
+
+commit 4625a7afe509545f782cd4631632b4d7a58011aa
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Tue Oct 2 23:53:20 2007 -0700
+
+ String#% works with a few exceptions:
+
+ * %u doesn't work (it's aliased to %d for now, as in 1.9)
+ * There's a weird glitch in Float(10_1_0.5_5_5) that I can't track down
+
+commit 54ab6f559093e66f78cfa30db8aa6587061552d6
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 02:05:41 2007 +0200
+
+ Extend Kernel#kind_of? specs.
+ Regenerate CI excludes.
+
+commit 4583be7e7ed76e5843dcb396f8bae735f341de73
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 02:03:58 2007 +0200
+
+ Remove superfluous whitespace from Object#kind_of? specs.
+
+commit 5c237626469f4b0f4d227916752dd2e03510fcf9
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:50:33 2007 +0200
+
+ Remove superfluous comment from Object#kind_of? specs.
+
+commit 7a2c673d04b0d0506e89073ff231104e21c3304c
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:47:56 2007 +0200
+
+ Simplify Kernel#freeze specs.
+ Move Object#extend vs. frozen? spec to extend_spec.
+ Rebuild CI excludes for Object#extend specs.
+
+commit 3f6a27603b0b1f91ce32b9ff2a5fe3222fa7220b
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 2 17:03:37 2007 -0700
+
+ Commit Charles Comstock's language return specs.
+
+commit ad4e7affcbaae4f0e967c97da485313168595a5e
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:36:27 2007 +0200
+
+ Fix Kernel#caller.
+ New core/kernel.rbc.
+ Regenerate CI excludes for Kernel#caller.
+
+commit 73b2ef1c889c940d22da6ad6bb8882eef66592fa
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:34:10 2007 +0200
+
+ Add spec for checking the default argument value for Kernel#caller.
+
+commit 180ecd6a7fa1d32e1932a322b1f8f82efd558e7f
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:32:29 2007 +0200
+
+ Add spec for checking that Kernel#caller returns nil.
+
+commit 9ad0c1428df70c9fd9e0081651e3b60cf5773267
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:30:46 2007 +0200
+
+ Add spec for checking the argument handling of Kernel#caller.
+
+commit 7a9483b823115b3122a4e42b21dfcb5b0f369a54
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:23:17 2007 +0200
+
+ Refactor the tedious part of the Kernel#caller specs.
+
+commit e204755859e4dc147217816ab3bf587db3d51dd6
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Wed Oct 3 01:22:26 2007 +0200
+
+ Cleanup description of Kernel#caller specs.
+
+commit dadbbb7930b62a4a6e47c8c32a4d9f26fcea38b4
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 2 23:52:49 2007 +0200
+
+ Regenerate CI excludes for spec/core/kernel. Again. Because I fixed the typos.
+
+commit 4a3587da37fd27effb30356fdd2e496f8c898be7
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 2 23:45:33 2007 +0200
+
+ Fix CI specs to pass in MRI 1.8.6.
+
+commit a46f5085f3c2a4849fe709044e447e5d6dacda4f
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 2 23:27:51 2007 +0200
+
+ Fix typos in spec/core/kernel specs.
+
+commit cb3d5867ec91a59a2a75136eb5210a10540b0ce0
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 2 23:27:23 2007 +0200
+
+ Regenerate spec/core/kernel excludes.
+
+commit 22e6fe0ef8dbf13aa01124447e09c9dc96f63fe3
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 2 23:26:51 2007 +0200
+
+ Fix Kernel#Array spec: don't depend on the exception message.
+
+commit 7b79130f38925cb48712be617cef5a80c71f0ba4
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 2 14:29:42 2007 -0700
+
+ Commit #5 (LH) Charles Comstock Process.wait2 spec.
+
+commit 859c119a48909030f29a2085fbe0a80ed96d2408
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Oct 2 20:57:31 2007 +0200
+
+ Fix Float#to_i and add a spec to catch the old misbehaviour.
+
+commit f2b5b2304588b4fb0efd9818c79a4b9774b2c850
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Oct 2 19:07:49 2007 +0200
+
+ Fix some String#scan specs.
+
+commit 8e0ce11df329181efa440cbd55f29848e12188bf
+Author: Kevin Clark <kevin.clark@gmail.com>
+Date: Tue Oct 2 00:39:15 2007 -0700
+
+ Add error handling for Dir.mkdir/rmdir
+
+ Add aliases for Dir.delete/unlink
+
+commit 20e66dd965bfceb29e4939090a0fd543d05392a3
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Oct 2 00:21:49 2007 -0700
+
+ Commit #206 Jason Yates' UnboundMethod specs.
+
+commit 00d7d22b7d106c6aac5d9664cb444e14811171b0
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Mon Oct 1 17:57:29 2007 -0700
+
+ First pass at actually getting my modulo impl working
+
+commit c90766a09c7e1fe7a2261f8b09d9caa8eaf2214e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Mon Oct 1 21:21:34 2007 +0200
+
+ Fix the String#crypt spec.
+
+commit a0f6f8e51a6f7a65230f8f2ea53587ccb09f9270
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Mon Oct 1 20:18:29 2007 +0200
+
+ Changed the String#to_f specs a bit.
+
+commit 21d43e565bb55a31b45dc9fabbefface156ec516
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Oct 1 16:13:28 2007 -0400
+
+ Add failing Array#pack spec for use case taken from Mongrel
+
+commit b1d70b4a847fc1c8df3eb4a219c4318420121e82
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Oct 1 09:04:03 2007 -0700
+
+ Commit #205 Jason Yates' Method specs.
+
+commit de7e0f0183d072f101e0781635fc2fdb1af1b851
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Mon Oct 1 00:11:12 2007 +0200
+
+ Fix compiler specs to expect sret when appropriate.
+ Rewrite compiler specs for multiple assignments.
+ Regenerate CI excludes for compiler specs.
+
+commit 1d1e704306fca4453d600259e87175dcdc9de314
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 23:27:12 2007 +0200
+
+ Add edge cases for File#extname specs.
+
+commit 108d757e6c24447b89fa785b2bf091b72d29933d
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 22:34:15 2007 +0200
+
+ Regenerate CI excludes for Dir specs.
+
+commit 20c6c3cd9b5d59b9782b702ac6afeb828e895d5f
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 21:49:52 2007 +0200
+
+ Make Dir specs pass in MRI.
+
+commit dcd172338bce5b70cb367db3c1e6f4653c05f9e8
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 21:10:36 2007 +0200
+
+ Fix case comparison with Symbols.
+
+commit 2a45cd71d1eb90a7c11ff62d81371df9479b0d43
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 13:28:32 2007 +0200
+
+ Add specs for String#tr! and String#tr_s!.
+ Cleanup specs for String#tr! and String#tr_s!.
+ Regenerate CI excludes for String#tr! and String#tr_s!.
+
+commit 6418bd672c8ea031d8ac2364c8a98bb631e53deb
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 13:26:19 2007 +0200
+
+ Add specs for multiple asignments with splats vs. Array#dup.
+
+commit 10b04881d286acab9dc97147750743e03ee4509f
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 13:25:14 2007 +0200
+
+ Fix Class.new to raise TypeError when the superclass is not a class.
+
+commit 0b9debba0672305f8551f5d5f35cdd3aaf16c1f1
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 13:20:49 2007 +0200
+
+ Add specs for the names of classes generated with Class.new.
+
+commit e15cef6eb851318838351a4d8717b708bb09d31d
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 13:15:43 2007 +0200
+
+ Remove debugging output from spec/core/dir/chdir_spec.rb
+
+commit f3251ba0e8ade79f157bc02dca550481488bf888
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Sun Sep 30 13:15:17 2007 +0200
+
+ Remove debugging output from spec/core/extensions/rubinius/options_spec.rb
+
+commit 5d4d2abaf02aef6caa7e532208da5e5f57bc6373
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Sep 30 20:54:14 2007 -0400
+
+ Working Socket implementation and specs. Still needs readpartial to support Mongrel.
+
+commit b514e53f589d509c287516d8dd985f96e66d9a1c
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat Sep 29 15:44:06 2007 -0400
+
+ Working IPSocket#peername implementation
+
+commit 965ed2d88527ae8aa4ac962e8ca84180f61e6345
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Sep 24 02:34:26 2007 -0400
+
+ Yet another interim socket commit
+
+commit ecd54e981a1098c4b3abf14587212e7d1d9049a6
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Sep 20 16:29:21 2007 -0400
+
+ Another interim Socket commit
+
+commit 351bbdf08f190e24328328df7b3f995b8dc27a9f
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Sep 19 22:17:52 2007 -0400
+
+ Interim commit of Socket work so I can generate a patch
+
+commit 65a73cdfea95c5991f2044bee150e53643216ad3
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Wed Sep 26 13:15:45 2007 +0200
+
+ Added some Marshal#load and Marshal#dump specs.
+
+commit 89e1b91c606dfe18581c3ed3923340b952471d8e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Wed Sep 26 13:15:19 2007 +0200
+
+ Extended Specs for Kernel.Float and Kernel.Array
+
+commit 5d46933362b8c54cb5d0370bbf61e063459de514
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Wed Sep 26 13:14:41 2007 +0200
+
+ Added specs for Symbol.all_symbols.
+
+commit b3324808584d7b4ee6af58d98eeb7c2162c31208
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Sep 27 10:57:46 2007 -0700
+
+ Commit #180, Jason Barton's specs for Module#undef_method, #remove_method.
+
+commit 2e1219fc03d9cb673074ee34b1f8af4bdffe9c0e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Thu Sep 27 18:49:26 2007 +0200
+
+ Fix Kernel.Integer by making use of String#to_inum. Add some more Kernel.Integer specs.
+
+commit b0d4747cab49f4a17e9899392171087d7b67f687
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Thu Sep 27 18:23:42 2007 +0200
+
+ Fixed String#to_i. Added String#to_inum. Extended String#to_i specs.
+
+commit 2799c392b3f5383e9e74745ceb9cf7a52f82918b
+Author: Paul Meserve <pmeserve@gmail.com>
+Date: Thu Sep 27 01:20:00 2007 -0400
+
+ fix for Struct#new and a small struct spec changes
+
+ (also re-ran bin/ci on struct specs - most of the changes were from previous commits though)
+
+commit 30d9bf1f6ef9dcff067d427d6226bbce985f5e69
+Author: Paul Meserve <pmeserve@gmail.com>
+Date: Wed Sep 26 19:08:37 2007 -0400
+
+ raise proper error when passing non-block args to Enumerable#all?
+
+commit 1ef1e0ef65ef3c86558da3d313dee5cada6dd4c5
+Author: Paul Meserve <pmeserve@gmail.com>
+Date: Wed Sep 26 17:25:17 2007 -0400
+
+ adding alias for Float#quo to fix a couple number specs, and some modifications to Enumerable#min/#max, along with a couple new spec assertions. fixes failing specs and implementation should be a lot closer to MRI
+
+commit 547dd89791d92f061afcaef7184f054affae871d
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 26 09:46:50 2007 -0700
+
+ Fixed placement of after(:each) block in numerous File specs.
+
+commit fa3dcbfdd623a7a7cdb15bc29b38ae47bb4056d5
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Sep 25 20:25:36 2007 +0200
+
+ Added specs for UnboundMethod#arity
+
+commit 33783408b8ce1bdfcd205fd02bc3848119a632cc
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Sep 25 18:00:10 2007 +0200
+
+ Added specs for Class.
+
+commit 0edea3c3a7dda5c453c527b2cef3ffba1eef1396
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Tue Sep 25 17:25:40 2007 +0200
+
+ Created some specs for Proc.
+
+commit 62c92f1c3aef6c2ff7ab8cbcd49eefb236d5caed
+Merge: b79d04d... 2d9c698...
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 26 01:09:42 2007 -0700
+
+ Merge branch 'dir'
+
+commit 2d9c69848f4ca34685b95b07e17d1b5fe1ec2391
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 26 01:09:28 2007 -0700
+
+ Updated CI spec excludes for Array, Dir, Fixnum, Enumerable, Hash.
+
+commit b79d04db673d9b7b5cc47f2918bccf1b0400bdbd
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 26 00:56:01 2007 -0700
+
+ Commit crayz's patch from #195, #196, #197.
+
+commit ec960578671a327469d9545d6ced827736ceafa0
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Sep 25 19:40:54 2007 -0700
+
+ Fixed Dir specs failing MRI after conversion.
+
+commit 00b398352ed0f4cbcd326d56b7f8a4469056ee0d
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Sep 25 00:54:06 2007 -0700
+
+ Many cleanups of Dir specs.
+
+ Added Dir specs fixture directories and files.
+
+commit b75cfa7c0a9871dc34b8b315ca2311e65000b2f3
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Sep 23 00:41:36 2007 -0700
+
+ Converted Dir.glob specs.
+
+commit 3d8ea2a55e67cc6cfb85d2f4f7845a45984f6504
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Sep 25 21:52:54 2007 +0200
+
+ Fix a few Struct specs. Failures are down to 15.
+
+commit a477ff678e9f5f39d3d2b94e559c77b34f0c56c5
+Author: Martin Kuehl <martin.kuehl@gmail.com>
+Date: Tue Sep 25 20:51:38 2007 +0200
+
+ Fix compiler warnings in Subtend spec extensions.
+
+commit db3e1be4e25b7e8cc463443d050afe9a5acaa7de
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Mon Sep 24 22:31:03 2007 +0200
+
+ Extended Fixnum specs.
+
+commit d136b779736af52d1eac08a40814ab4a47de93b3
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Sun Sep 23 17:47:30 2007 -0700
+
+ Array#each explosion spec
+
+commit 8a24a71ff13aac465f7f4a14587981c3c23dc800
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Sep 23 20:06:04 2007 +0200
+
+ Extended Comparable specs.
+
+commit ea9ba046ddfe91601d4453972a6d6f8fce96c392
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Sep 23 12:17:17 2007 +0200
+
+ Fix Numeric#divmod and Fixnum#divmod.
+
+commit 1c5ecb9d2e9066c66b9f0625d65cc4cefaee1f83
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Sep 23 12:00:16 2007 +0200
+
+ Fix Float#to_i for infinite, negative values. Fix Numeric#/ and Numeric#div. Add Numeric#do_coerce.
+
+commit 2d67d024e11e887eb07622963bfc36b0ec377746
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Sat Sep 22 20:08:38 2007 -0700
+
+ Added Onig 5 and got rindex working with it
+
+commit adc26eb525447010e28fc884eaa54b9d2228f4d6
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Sep 23 01:35:11 2007 +0200
+
+ Fix Kernel.Float specs
+
+commit 9a2ecf258fee3bda410776b3d3b77366590d64fe
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Sep 22 23:18:46 2007 +0200
+
+ Extended more Fixnum specs. Removed the spec/fixnum/induced_from_spec.rb.
+
+commit 53b0042824bb1b1c523d790cb3645aec6b789abe
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Sep 22 22:35:53 2007 +0200
+
+ Extended many Fixnum specs.
+
+commit 8661cdb78cd2c4afa0fb231aa9cc959e338e097e
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Sep 22 22:35:11 2007 +0200
+
+ Extended nil#to_s spec.
+
+commit 4008d8b39032ffa5667e95fb445ff816b1428330
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Sep 22 14:25:27 2007 +0200
+
+ Added some more specs and fixed some bugs in Range#initialize, Range#step and Range#each.
+
+commit 254e3d57dc6e859616ca7e0c44058d4b73211f68
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sat Sep 22 11:31:02 2007 +0200
+
+ Some updates to Range specs.
+
+commit b87e28bfc06e81fe5c4c3d6e285947f635f79f61
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Sep 21 20:12:18 2007 -0700
+
+ Commit wycats Regexp.regexp_match_region primitive.
+
+commit eaa56811836b4b5ed09a5e26d00f26eb004f2853
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Sep 21 18:44:25 2007 -0700
+
+ Added StringValue to some File methods.
+
+ Upated File CI spec excludes.
+
+commit 83f7b6020dbc881fbd6bd13da6ebb049d6080c2c
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Sep 21 17:54:53 2007 -0700
+
+ Upated spec excludes for Float, Fixnum, and Math.
+
+commit af0b0c8da8357fcae7437f6cdfd7797f03ffd73b
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 20 22:10:54 2007 -0700
+
+ Fixed a number of string-related issues:
+
+ String#inspect respects $KCODE
+ String#inspect returns tainted subclass
+ String#dump is no longer a copy of inspect, and does not respect $KCODE
+ String#match tries to call #to_str if it can before throwing an error
+
+commit 9409ace6d3e97946d10f9f7fcefa69ebcae43c47
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 20 16:55:11 2007 -0700
+
+ String#index works
+
+ Tweaked spec because [[x,y], [x,y]].each{|x,y| ... } wasn't working
+
+commit 6a72e4c4defef170f53a31c930c112022934dbc4
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Sep 20 15:22:28 2007 -0400
+
+ Correct StringIO#reopen specs and implementation. Submitted patch for 1.8.x stable.
+
+commit 2b10dd99c2de4f97b5faa45060eba929d02052c4
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Wed Sep 19 22:20:33 2007 +0200
+
+ Implemented File.identical?
+
+commit 2c3c1fc7bd2f6365b28262cae46872eb0925c2e7
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Wed Sep 19 21:48:13 2007 +0200
+
+ Implemented File.link.
+
+ Kudos to the Frankfurt Rails User Group! :)
+
+commit 0330b22006e39b5b173c78800f412831296de59a
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 20 01:32:43 2007 -0700
+
+ String#gsub works correctly
+
+ There was a weird segfault issue which I tracked down to a use of gsub inside of gsub.
+ I got things working by extracting that functionality into a mini-gsub for just that
+ use case, but we should fix it.
+
+commit 6c825ce63ca0eb7d6f882a767ee0e6a597219883
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Sep 19 22:14:31 2007 -0400
+
+ Discover and fix an edge case in StringIO
+
+commit 6bd7adcfa115f11829a7efe8f526fabbb56d5c4c
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Sep 18 19:00:20 2007 -0700
+
+ File.fnmatch(?) now passes all existing specs.
+
+commit f626f4199b88ca09a2ba75127270c0bec2ec2c86
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Mon Sep 17 15:04:44 2007 -0700
+
+ Adds a new match_all primitive
+
+ * will be used as the base of regex-related String functions
+ * is called match_all instead of scan because it's more primitive than Ruby's scan
+
+commit 0b42d4d2610ec36a4ae5e21c37d5b587f2b9dcf8
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Sep 17 02:06:50 2007 -0400
+
+ Avoid using $/ in IO#puts and StringIO#puts
+ Additional StringIO specs and fixes for failures
+
+commit 75969031a57bea50e4a6450bbc9ae9e5adf76fa7
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Sep 16 18:26:29 2007 -0700
+
+ Replaced File.fnmatch FFI version with custom version.
+
+ The custom version is needed to be as compliant as possible
+ with MRI on different platforms.
+
+ Lots of fixups to File.fnmatch specs.
+
+commit 18d098062cb1b996a571a946740eea7c52421e12
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Sep 17 01:11:45 2007 -0400
+
+ Some failing sprintf specs and then the fixes for said failures
+
+commit 84f94ab41d72012e4ec3d0d236b183fd8a51fbe0
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon Sep 17 00:53:30 2007 -0400
+
+ Additional StringIO specs and fixes for the failures that arose
+
+commit 9b44df55c682f239f036d46efe45edc2190a7345
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Sep 16 12:55:27 2007 -0400
+
+ Add StringIO spec for $/ global handling
+
+commit dfcba62eb69f88d373359c75c3fa7fe827e24c69
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Sun Sep 16 00:43:41 2007 -0700
+
+ Fixes string/equal_spec to pass
+
+commit 5026350a166b94fc5fffff70dae510fa2abf2094
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Sun Sep 16 00:20:52 2007 -0700
+
+ String#slice works
+
+commit a4f3aa09d3aeb8d2b0a640ca9f659a5945692e04
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Sep 15 13:49:42 2007 -0700
+
+ Added ability to read/write to pointer to int or double in FFI.
+
+ * Fixed Math.frexp to use pointer to int to return exponent.
+ * Completed Math specs.
+
+commit 1a88ca4def8d7aa566a4254eebee3236a1359fc8
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Sep 14 20:57:01 2007 -0400
+
+ mini_rspec.expectation_messages.yak_shave!
+
+commit 64f53c8b40b3a80b41a2c27b4ac7255b7aad5f4d
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Sep 14 02:18:16 2007 -0400
+
+ Hopefully full StringIO coverage now
+
+commit 7cf9fe62bc9a5a00ae69ed3cac82e50012f3bb69
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Sep 14 00:54:33 2007 -0400
+
+ Yet more StringIO specs
+
+commit 92da0550bd32db984fbb54f105b9701867d4faf9
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Sep 14 00:38:55 2007 -0400
+
+ More StringIO specs
+
+commit 29826669197f44850d323910c7e60897e1ef7796
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Sep 14 00:23:45 2007 -0400
+
+ Beginnings of StringIO specs
+
+commit 0c19e3557125dd366ddd119a34451715bfe5e7a1
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Wed Sep 12 18:11:49 2007 -0700
+
+ Fixed object allocation bug and Bignum spec
+
+commit e42a1b960f530a987527d8795a98b2de18fea824
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Sep 13 19:19:03 2007 -0400
+
+ Re-implement Module#define_method. Passes existing specs.
+
+commit a8b1a148e5fbfeb3c91558fd6caccc95006a5617
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Thu Sep 13 03:55:15 2007 -0500
+
+ Adding a non-compiling spec to case_spec and updating core.rba that didn't seem to get updated correctly.
+
+commit bbd682ba2e12ba5907fe2edf2f14f11fb110cac8
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Sep 13 04:04:33 2007 -0400
+
+ Fix anonymous 'rest' arguments
+ Suppress stray STDOUT traffic from 'defined?'
+
+commit 8f11498019eb49a4dd8bf52c4361432ebb1175d5
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 12 22:21:30 2007 -0700
+
+ Updated CI process.
+
+ * Changed bin/ci to generate an exclude file per file put
+ in .spec directory.
+ * Generated CI spec excludes files.
+ * Updated .gitignore to not exclude .spec directory.
+ * Moved the critical excludes file to spec/excludes.txt
+
+commit b736263ff325efabb907f300c1c69a2e63bd5620
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 12 22:21:30 2007 -0700
+
+ Updated CI process.
+
+ * Changed bin/ci to generate an exclude file per file put
+ in .spec directory.
+ * Generated CI spec excludes files.
+ * Updated .gitignore to not exclude .spec directory.
+ * Moved the critical excludes file to spec/excludes.txt
+
+commit 58ff9428a2a20e93e3682f834e32f754ed2c47d4
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 12 18:39:48 2007 -0700
+
+ Fixed specs failing MRI.
+
+commit f54b1dffb9372e5cb1c71d93c67f2407fce0a1d0
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 12 17:17:46 2007 -0700
+
+ Fixes to specs failing MRI for hash, float, fixnum, file, enumerable.
+
+commit e1d359eec451a69deb67ffdedd09b86d00774cc2
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 12 14:34:50 2007 -0700
+
+ Fixes to Hash specs based on Ruby version differences.
+
+commit ee5eec5d32bb42fbf549068905ddebe215fbcf70
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 12 08:53:47 2007 -0700
+
+ Fixed failing specs in kernel, module, numeric, string.
+
+commit 4f0af824f132428762f1e06409ca16c1022867bc
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Sep 12 06:24:16 2007 -0700
+
+ Added #platform and #version guards for specs.
+
+commit 355c602704cd402a1d7cbadc9b4d8fae0b34f1f4
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Sep 11 00:35:03 2007 -0700
+
+ Misc changes to specs to cleanup after the breakup.
+
+commit 85336c6a83736b01d63b645baf0e7e18bb5ce569
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Sep 10 23:21:24 2007 -0700
+
+ Converted exception, kernel, struct, object specs.
+
+commit e10bc8cbbaa26123724dad9f97f44d82e8cbf600
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Sep 10 21:48:15 2007 -0700
+
+ Converted string and numeric specs.
+
+commit 8ec64d24811a7951756c840c98a66a7c7d2ae7c8
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Sep 10 18:35:18 2007 -0700
+
+ Converted array and module specs.
+
+commit 2849f4a41b3fbda6c626d934bbf3d7476ea31848
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Sep 10 15:22:36 2007 -0700
+
+ Converted enumerable, file, hash, process, regexp, thread.
+
+ Fixed bin/mkspec to remove '=' from string for file name.
+
+commit ffa5328aa8ed7ea079c0cc8b4228ababa5919cf6
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Sep 10 13:16:14 2007 -0700
+
+ Converted time and bignum specs.
+
+commit 7798952047471d28a8e12a796092c4df7ae002f2
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Sep 10 01:21:38 2007 -0700
+
+ Converted range, math, matchdata, integer, float, fixnum, comparable, io.
+
+commit 423d85f4a7eb4b40d2eea83a462f5c38c4a6aee3
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Sep 9 23:43:14 2007 -0700
+
+ Added dir and files for ENV. Converted true, false, nil, symbol, process.
+
+ Added .spec to .gitignore.
+
+commit 8274bdcd0c747c21806065feb743e7794231f48f
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Sep 9 22:40:37 2007 -0700
+
+ Converted kernel specs.
+
+commit bc1917d630d7938b62a866c3825dfa08e5ec99e1
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Sep 9 21:57:03 2007 -0700
+
+ Initial create of spec/core subdirectories and files.
+
+ Updated bin/mkspec to exclude Exception subclasses and
+ OptionParser (which is in Object.constants because of
+ the script requiring it). Also normalize TrueClass etc.
+ to directory 'true'.
+
+commit b941eceb681c57d23d35f952b11b2a2d3a1ea4dd
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Sep 13 01:00:22 2007 -0400
+
+ Add a minimal spec for the 'undef' keyword
+
+commit 3af389594f3828763a85d8eef65f773b183e1b46
+Author: Charles Nutter <headius@charles-nutters-computer.local>
+Date: Wed Sep 12 19:33:36 2007 -0500
+
+ Adding a bunch of default argument specs to language/def_spec.
+
+commit 6b4936e834a2814602be54f01e08dcdc1f9433b5
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Sep 9 16:58:35 2007 +0200
+
+ Another fix for multiple mock expectations on the same method.
+
+commit f686ff256289263eb473249dd734cf2214c41cc2
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Sun Sep 9 16:13:53 2007 +0200
+
+ Mocks now support multiple expectations of the same method with different arguments.
+
+commit 860e0d08adc8cdee9ac4d9ff3bd0e30d5d3aaa49
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Sep 8 02:36:19 2007 -0700
+
+ Added to critical-excludes and ci-excludes. bin/ci -f s -C runs to completion.
+
+ rake build:core compiled string.rb, so checking in core.rba.
+
+commit c9c79c910a57e5628d1743f3b440c0066875500e
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Sep 7 23:24:44 2007 -0700
+
+ Added Math methods using FFI.
+
+ Added Kernel.coerce_to and rewrote Float(), Integer(),
+ Array(), and String() with it. Float() needs to be fixed
+ to raise on strings like rb_cstr_to_dbl does.
+
+ Fixed -C options for bin/ci and bin/mspec.
+
+commit b8d8b8c8475fde1ce3519e29788a34780dffae8c
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 19:40:02 2007 -0700
+
+ Fixes String#<<
+
+ * Added taint if other has taint
+ * Fixed 10 spec failures
+
+commit b0b85547ab9dd16ba88a75c64a91c3ae0d079b27
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 15:36:44 2007 -0700
+
+ Added bus error to critical-excludes
+
+commit ed13a10112d0a262a48c8e5db7d1eaaa3e076e55
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 15:19:51 2007 -0700
+
+ String specs work in 1.8.6 MRI
+
+commit 6fc507c96e990139c311900c73c7e31447879071
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Sep 7 12:03:09 2007 -0700
+
+ Changed VERSION and RUBY_VERSION to shadow MRI (currently 1.8.6).
+
+ Added RBX_VERSION (currently 0.8.0). Updated loader -v to display
+ RBX_VERSION and RUBY_VERSION and truncated BUILDREV.
+
+ Enabled before|after(:all) for mini_rspec.
+
+commit 8ce602f80b35f5859c58730968a9a7053a87bd59
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Sep 7 11:16:16 2007 -0400
+
+ Array#uniq, #uniq! simplified. 72 failures.
+
+commit 38f271a1b7d49074d8db9285553756fb75ffe78b
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 11:23:36 2007 -0700
+
+ define_attr added to subtend
+
+commit 843706d585334c30943c8bbdd3ef6ca22297d42d
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 10:48:51 2007 -0700
+
+ Added rb_cstr2inum to subtend
+
+commit 97a22e2144b623a62780995333d65986c98c4ba2
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 10:42:30 2007 -0700
+
+ Added rb_const_defined to subtend
+
+ It also seems that my fixture for require didn't make it in; adding that as well
+
+commit 0ac9ec2b0f381bf2fb3a36cd0b6f30748771e818
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 10:21:28 2007 -0700
+
+ Added check_*_type to subtend
+
+ * check_array_type
+ * check_string_type
+ * check_convert_type
+
+commit b2bf1c44fa7c2663e6fc0b27127aa4f5e38e073f
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 09:45:03 2007 -0700
+
+ Added rb_attr_get to subtend
+
+commit 81605662ab8acc5a50536f1fc613e7d24e142df1
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 00:27:38 2007 -0700
+
+ int2inum added to subtend as well as INT2NUM
+
+commit e80084e6b245173c17403891c65d86db1e6b3022
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Fri Sep 7 00:02:06 2007 -0700
+
+ rb_str_split added to subtend
+
+commit 90f1fa95825caa8b21e147248d1a7d999579b937
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 6 23:51:56 2007 -0700
+
+ rb_require in subtend added
+
+commit 5bb87f516b2a26f77a864a15636331102d6d8499
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 6 22:58:29 2007 -0700
+
+ rb_to_id added
+
+commit e0532b3fb62089da7b7362ec2232997878a1221d
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 6 22:31:30 2007 -0700
+
+ Added specs
+
+commit 75f7a1d2b37067f55099dd117e8fcd905baa748d
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 6 21:59:12 2007 -0700
+
+ string subtend fixes
+
+ * rb_str_cmp added
+ * rb_str_cat fixed with working spec
+
+commit f058cea3e5291c349f5b2b1cfbdad4d734240f95
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 6 21:34:52 2007 -0700
+
+ added rb_define_const
+
+commit ec7ca7f45ef32794afb919851e4bfd5e8d7aa46d
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 6 21:03:44 2007 -0700
+
+ rb_include_module added
+
+commit 5b3471544508e973ba6afbd16daf47f5796f8b30
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Sep 6 20:41:09 2007 -0700
+
+ float_new added and some functions missing in ruby.h added
+
+commit cd2af0bae996a4addfe23baa0558125a8a5523e7
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Sep 6 17:09:06 2007 -0700
+
+ Fixed subtend. Added diagram of the context chain.
+
+ NMCs (NativeMethodContext) now use the proper context stack.
+ The stack maintenance was all screwed up when calling in and out of
+ native methods, which was the source of a few problems.
+
+commit da5f9e6f942c11d906760e952debae4d05b3d872
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Sep 4 22:26:48 2007 -0700
+
+ Added load-order dependency generation to rake build:(core|platform) task.
+
+ Added 'depends on:' declarations to kernel/platform and kernel/core files.
+
+ Updated ci-excludes.txt to reflect recent spec checkins.
+
+commit 7b1ca6f305e33b34a99e8c9e049843a76cceeca7
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Sep 2 21:29:49 2007 -0400
+
+ Add more 'alias' specs. Show singleton methods in 'public_methods' output.
+
+commit 5c0b5fcb2a0c9f47a04e6a5d5027484224d0a942
+Merge: 4896039... 01c2126...
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Sep 2 18:58:53 2007 -0400
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 48960394ab7f36ccd1b18609677b40721c30d7a2
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun Sep 2 18:57:29 2007 -0400
+
+ Add some 'alias' specs that fail on rbx and pass on MRI
+
+commit 01c2126b705327d99aa183d51dc014169e8b4e07
+Merge: 04602c6... b6d92ec...
+Author: Florian Gross <flgr@ccan.de>
+Date: Sun Sep 2 19:45:25 2007 +0200
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+ Conflicts:
+
+ spec/core/string_spec.rb
+
+commit 04602c6756a9199b64e7d909c01dc995b25fa8a7
+Author: Florian Gross <flgr@ccan.de>
+Date: Sun Sep 2 19:32:47 2007 +0200
+
+ * New specs for String#tr_s(!) and upcase(!)
+ * Improved specs for String#capitalize!, downcase(!) and swapcase
+
+commit c94f83b20f7b11dc48c523c84de59b9ac6f76cce
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Aug 31 23:15:07 2007 -0400
+
+ Array#reverse_each, #rindex fixed and cleaned. 80 failures.
+
+commit f531f812f87283b950c62648e3cf08a7400c2779
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Aug 31 22:03:05 2007 -0400
+
+ Array#replace fixed, specs. 88 failures. * Disabled specs for #initialize_copy which is private.
+
+commit 1656b8a04a40bc5a43adec88ffd1480d9da6ba28
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Aug 31 11:50:56 2007 -0400
+
+ Array#reject, #reject!, specs fixed and cleaned * Added spec to check #reject returning Array and corrected implementation.
+
+commit e1c499c6feafc19788addd098a6da052904cb09c
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Aug 31 11:25:45 2007 -0400
+
+ Fixed logic in Array#rassoc, specs. 91 failures.
+
+commit da79b116d3fdc5fd4cd04f5ad1ad44b2c269ad77
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Aug 31 10:38:39 2007 -0400
+
+ Array#push checks frozenness, specs. 92 failures.
+
+commit 290aa6fe561453821f59be3fa92695d0b0d77c04
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Aug 31 10:26:25 2007 -0400
+
+ Uncommented most of Array#pack specs. * float -> int conversions still hang both C and c and are therefore disabled.
+
+commit 885f2522244c1792f45260194aba085028d5c919
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Fri Aug 31 09:59:30 2007 -0400
+
+ Fixed logic errors in Array#assoc, Array#include? * Both, contrary to docs, compare elem == obj, not the other way around.
+
+commit d825038a409f4d931e80736e2de49ff0752857a9
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Aug 31 00:12:06 2007 -0700
+
+ bin/ci supports options for separately running spec files
+
+ Use bin/ci -s to separately process each spec file. Use
+ bin/ci -m to run all the spec files in a single VM process.
+ -s is the default for --create, but -m is the default for
+ everything else.
+
+ Updated ci-excludes.txt and critical-excludes.txt.
+
+commit 7dfe5cb7936051685a2c79effb6295b9aa179810
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Aug 30 23:44:28 2007 -0700
+
+ Updated ci-excludes.txt to only exclude failing specs.
+
+commit fb09f0a7a6969adffd8d99bf869eb50c91eef097
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu Aug 30 20:31:20 2007 -0400
+
+ Fix object and array specs that failed under MRI
+
+commit 6fb73244537b61a20538c1f3d5a060a40a358be5
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Thu Aug 30 17:08:12 2007 -0700
+
+ Fixed two typos in the subtend string specs
+
+commit 00256f41d4e3ebfcdafdc25e27bfbf4bc7d3de3f
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Aug 30 11:19:09 2007 -0400
+
+ Array#last fixed. 48 failures.
+
+commit 887d41c64c6bdff693f6ecd8d3078f8453669648
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Aug 30 11:02:27 2007 -0400
+
+ Array#insert, specs corrected. 49 failures.
+ * Fixed Array#insert
+ * Re-complianced frozenness specs for Array#inspect.
+
+commit 1bc536e1128bc76b1c9efae593340f67bdcb5fb5
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Aug 30 10:42:05 2007 -0400
+
+ Array#indexes correct implementation. 51 failures.
+ * Array#indexes and #indices is now correct although
+ both methods are deprecated in favour of #values_at.
+
+commit 5de09c707b1ce43bf689e8ded9ea19784e77a49e
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Aug 30 10:09:27 2007 -0400
+
+ Array#include? implemented. 53 failures.
+ * Replaced use of Enumerable#include?
+ * Re-complianced to a simpler Array#include? spec to
+ avoid implementation-dependedness.
+
+commit 14ca6c2533764eea508b24b0ec89475a7aae5e94
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Aug 30 09:32:40 2007 -0400
+
+ Array#hash spec compliance change. 54 failures.
+ * Disabled an Array#hash spec for Rubinius because it
+ relies too much on implementation details.
+
+commit fc4f392fa7fba88b36bfdec61db3acaa1f1fadc2
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Thu Aug 30 00:42:03 2007 -0400
+
+ Array#flatten, #flatten!. Improved Array specs. 384 ex, 55 failures.
+ * Array#flatten, #flatten! implementation improved, they
+ also work recursively now.
+ * Re-enabled Array#flatten, #flatten! specs and the
+ recursive test for Array#inspect.
+
+commit efeaa622994e9868b9324247b0ff1fd5743792ac
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Wed Aug 29 23:29:36 2007 -0700
+
+ A series of rb_str functions in subtend, plus fixes to some of the tests earlier committed
+
+commit e4f5281148799ed716065c489d384a42d208290d
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Wed Aug 29 19:16:26 2007 -0700
+
+ rb_str_append() added
+
+commit a05c376478f7407da4e0aa2a6a7e3de98176a63b
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Wed Aug 29 13:25:17 2007 -0700
+
+ Updated subtend array functions
+
+ * rb_ary_reverse() added
+ * tests added for rb_ary_join() and rb_ary_reverse()
+
+commit 779fb97c35b78b9749cbb118fcb555096957e4c6
+Merge: 2793a99... e17987e...
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Wed Aug 29 12:40:33 2007 -0700
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 2793a9917f8f5cc2f0fc14ba605cec499532e680
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Wed Aug 29 12:40:21 2007 -0700
+
+ Slightly improved rb_ary_pop() test
+
+commit c196c60b6cd32c85b18bdab31ee000cf097309b5
+Author: Me <rue@meow.kittensoft.org>
+Date: Tue Aug 28 23:49:46 2007 -0400
+
+ Array#fill fixed, cleaned up. 375 examples, 59 failures.
+
+commit 7736413f262357479c2f3354a73533fd89b3c9a6
+Author: Yehuda Katz <wycats@gmail.com>
+Date: Tue Aug 28 17:54:28 2007 -0700
+
+ added rb_ary_join() to subtend
+
+ Trying to get tests working but it's hard to see if I'm correct without the ability to run them.
+ I'll take care of making sure there are passing tests as soon as I can.
+
+commit 0effcaf3e948d80ae3ad17b33f0483313d85cdbe
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Tue Aug 28 00:24:41 2007 -0400
+
+ Array#fetch, specs, slightly cleaned array.rb. 62 failures.
+ * Array#fetch uses to_int.
+ * Specs for Array#fetch check for correct block var.
+ * Removed extra comments from array.rb.
+ * Removed old implementations from array.rb.
+
+commit 51737d35c24f853a23e14f7a227138d4d0f6b457
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Aug 27 21:46:30 2007 -0700
+
+ Added failing File specs to ci-excludes
+
+commit a195970e2b2d34fa4388e6a72e91ada13b4b0d32
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Tue Aug 28 09:20:33 2007 +1000
+
+ Ensure exists? is prefixed by File.
+
+commit 804b6f3358c1bb73492beaa0e978d4df8dbac138
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Tue Aug 28 00:18:41 2007 +1000
+
+ Minor refactoring work on file spec.
+
+ Removed duplicated constant tests.
+
+commit ef18eaaaa1a79b964667900b19f3f10e1b67032b
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Aug 27 14:25:06 2007 -0700
+
+ Updates to enable bin/ci to run to completion.
+
+ Changed mini_rspec to not use File.open with a block to work
+ around IO#read failing to catch EOFError.
+
+ Commented out object_spec.rb specs that need to be completely redone.
+
+ Updated spec/reports exclude files to enable bin/ci to work.
+
+commit 505617b26829d5f489c4488ed934a6dc720f64f0
+Author: Florian Gross <flgr@ccan.de>
+Date: Sun Aug 26 22:53:42 2007 +0200
+
+ A few new specs for String#sum, #to_i, #to_s, #to_str, #tr and #tr!
+
+commit a6a24a97dce2a4072a6ea17e48259b76f0c3681a
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Aug 26 02:52:55 2007 -0400
+
+ Array#delete, Array#delete_at, Array#delete_if. 63 failures.
+ * Fixed the three delete* methods, they still need clean-up
+ * The specs reflect difference in frozen handling for rbx and r18
+
+commit 063f8c25d45e0934bca236ecb8af36dcb517187f
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Aug 26 02:26:15 2007 -0400
+
+ Array#concat fixed. 69 failures.
+ * Array#concat checks frozenness and cleaned up
+ * Improved specs for #concat
+
+commit a9f3593593948cf72d94712765d05bfcc27f2e78
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sun Aug 26 01:53:05 2007 -0400
+
+ Array#dup, Array#compact, Array#compact!. 71 failing.
+ * Array#dup properly returns subclass
+ * Array#compact(!) improved to pass specs
+
+commit 7be3bc12ea2e5432e442cb44103b4b1c6d981163
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 23:57:38 2007 -0400
+
+ Array#clear, Array#frozen?. 372 examples, 73 failures. * Array#frozen? checks for sorting freezes * Array#clear fails on frozen Arrays
+
+commit 5c958242fe25f8a18cd8d315f81fb3db80dc7a40
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 17:19:23 2007 -0400
+
+ Array#==, Array#assoc improvements. 75 failures
+ * Cleaned up Array#==
+ * Array#assoc processes correctly
+
+commit f82f8a300ee394f9f1038cc84de1cf6b132d7ef5
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 16:24:22 2007 -0400
+
+ Array#* improved. 371 specs, 81 failures
+ * Array#* processes to_int and to_ary correctly and forwards
+ to #join when needed.
+
+commit 91e16f06d5b5b16f1fa7ffc1d3673d7f1c681587
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 15:54:12 2007 -0400
+
+ Array#join can process recursive Arrays.
+ * Rubinius cannot create recursive Arrays so this is somewhat moot.
+
+commit 2d7427bb638f1af6d7437beed4beafde5274dbdf
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 13:46:45 2007 -0400
+
+ Array#|, better Array#&. 371 examples, 86 failures.
+ * Array#& explicitly uses #eql? semantics
+ * Cleaned up Array#|, uses to_ary
+
+commit 2b8707466f763662d52efaeab71b4789b132bb40
+Merge: c61b1e5... 76be87f...
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 12:41:06 2007 -0400
+
+ Merge branch 'array'
+
+commit 76be87f74d352d79425e9c46d3df55678257fda9
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 12:28:32 2007 -0400
+
+ Array#<< improvements. 371 examples, 89 failures.
+ * Specced and fixed resizing bug in Array#<<
+
+commit c61b1e54cc11c297b9e9a9eca70cb6a354ed21d9
+Merge: 3618a8b... c6cc98f...
+Author: Pedro Del Gallego Vida <pedro@la-vaca-roja.(none)>
+Date: Sat Aug 25 18:16:45 2007 +0200
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 3618a8bc588588ef8fb0dcc4753bc42606b86c13
+Author: Pedro Del Gallego Vida <pedro@la-vaca-roja.(none)>
+Date: Sat Aug 25 18:16:05 2007 +0200
+
+ Update object specs
+ Update the object_spec.rb file
+ * add more specs
+ * refactor using it_behave_like
+
+commit 294e5aacda8a74a9d8f57d05bb433f2fadcd08f1
+Author: Eero Saynatkari <rubinius@projects.kittensoft.org>
+Date: Sat Aug 25 12:07:06 2007 -0400
+
+ Array#[], modified parts of array_spec. 369 examples, 90 failures.
+ * Array#[] passes its specs
+ * Disabled some parts of array_spec while fixing Array. These
+ will be re-enabled as soon as possible.
+
+commit 1369465aefcd1d50ddd268ba9af968c62137e2b2
+Author: Pedro Del Gallego Vida <pedro@la-vaca-roja.(none)>
+Date: Fri Aug 24 11:14:20 2007 +0200
+
+ Array#new correct implementation
+
+commit e321427a52878ef9d9c7c04aa7c3c4f1e3a6c940
+Merge: bff7c05... 69c0407...
+Author: Pedro Del Gallego Vida <pedro@la-vaca-roja.(none)>
+Date: Fri Aug 24 11:14:20 2007 +0200
+
+ Merge branch 'master' of git@git.rubini.us:code
+
+commit 07c7f93a64fc37f3cf94a0a2c272468d015a7fb3
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Aug 23 21:18:13 2007 -0700
+
+ Converted Regexp specs to new describe style.
+
+ Fixed String specs to be compatible with bin/completeness.
+ Fixed bin/completeness to use dotted reporter instead of CI
+ reporter since the latter no longer outputs summary info.
+
+commit 6776e1478fa7e78a0944a1ee59c55c3839f51ea4
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Fri Aug 24 13:14:47 2007 +1000
+
+ Added implementation of File.split and updated specs.
+
+commit 4053b9076b4b996f544095a75317453967723faa
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Wed Aug 22 21:58:13 2007 +1000
+
+ Added spec for mocking methods on a class
+
+commit 54cae1196db08f6a734c35079db8df62e491f300
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Thu Aug 23 17:38:40 2007 -0700
+
+ Added more IO stuff and platform methods.
+
+ I'm still a little unhappy with the input buffer situation.
+ (ie, there is none.)
+
+ Adds IO#sysread and IO#syswrite as well as a bunch of POSIX stuff.
+
+commit 12a755004c0a8a0319212965da61385738166f98
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Aug 21 12:44:48 2007 -0700
+
+ Beginnings of ftools spec, fix backtrace generation.
+
+ Backtraces were failing to be properly built if the sender was a Block.
+
+commit bff7c05ce12c79ef111422ecf4525f1a65e7a5f0
+Author: Pedro Del Gallego Vida <pedro@la-vaca-roja.(none)>
+Date: Fri Aug 24 01:15:41 2007 +0200
+
+ More specs dor enumerable
+ * add inject, min, grep, find, detect, find_all, select
+
+commit ed9a8fefcc384bb6548a7f66bbafb97192ec8fd3
+Merge: 4ef0b9f... 8dd800e...
+Author: Arthur Schreiber <schreiber.arthur@gmail.com>
+Date: Thu Aug 23 11:01:25 2007 +0200
+
+ Merge branch 'specs'
+
+commit 8dd800e8189f616dc54390c0ebf96c331de41230
+Author: schreiber.arthur@gmail.com <arthur@arthur-desktop.(none)>
+Date: Thu Aug 23 10:45:56 2007 +0200
+
+ * Some more Module Specs.
+
+commit 0f414f56f9050d86011df75e7fd23428fe378996
+Author: schreiber.arthur@gmail.com <arthur@arthur-desktop.(none)>
+Date: Thu Aug 23 10:44:59 2007 +0200
+
+ * Added :count => :any option to mock expectations
+
+commit 4ef0b9feddfebfd1b6177fce6e3a1a4077f4f098
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Aug 22 23:10:22 2007 -0700
+
+ Updated exclusion list for CI specs.
+ Updated rake spec:ci task.
+ Changed ci spec run action to execute all specs in one process.
+ Added guard on file specs to prevent compilation exception.
+
+commit c3b61b239fa6a02327e5651513986d998d826eaf
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Aug 22 21:48:08 2007 -0700
+
+ Updated CI spec process to exclude specs failing on compilation.
+
+ Added critical failures to enable running especially spec/core.
+ Added failure guards to struct specs.
+
+commit f339a284c66357bc52749e5fe9c0d59bbbdc7ade
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Aug 20 22:31:56 2007 -0700
+
+ Fleshed out bin/ci constructs for running specs.
+
+commit 4f750d59adfff6c1751372c0d2853778dc7ae16d
+Author: Pedro Del Gallego Vida <pedro@la-vaca-roja.(none)>
+Date: Tue Aug 21 22:40:33 2007 +0200
+
+ * more enumerable specs
+ * refactor to it_behaves_like
+
+commit 3c79d5cf67b40b945602d5c5fa77589e0d7bae2c
+Author: Pedro Del Gallego Vida <pedro@la-vaca-roja.(none)>
+Date: Tue Aug 21 20:52:16 2007 +0200
+
+ update file_spec.rb
+
+commit b2a64089bffe5afb9148a665ecb6e70c3bc62b67
+Merge: 6865b97... 1b6a8a1...
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Aug 19 16:22:53 2007 -0700
+
+ merge 1b6a8a157
+
+commit bf54767922eb8d494c683ed8d57c6ffb5164fc29
+Merge: 6c6032e... 37d71c9...
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Aug 19 15:24:21 2007 -0700
+
+ merge from e83bcd022
+
+commit 05db33909c319231ac375812025ea2378710a299
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Sun Aug 19 21:26:15 2007 +1000
+
+ Add conditional when deleting a file in after(:each) block to prevent an exception if the file is missing.
+
+commit 138ab001175987cd38aff092a850e515745f9292
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Sun Aug 19 21:18:22 2007 +1000
+
+ Converted remaining context/specify spec's into describe/it, and followed class/method naming convention.
+
+commit 749b883d0260326573c581cc63eab67e1a4bc590
+Author: Marcus Crafter <crafterm@redartisan.com>
+Date: Sun Aug 19 20:23:11 2007 +1000
+
+ Added implementation of exists? blockdev? chardev? zero? size size? writable_real? executable_real? readable_real? unlink delete and chmod using ffi where needed. Specs for most of these methods existed already, added specs for those that weren't. Fixed a few typos.
+
+commit ddcb14f9f2311ec843a1f1f8d2b3fa868384ff0d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Aug 18 23:19:32 2007 -0700
+
+ more misc changes to get ci specs working
+ added alias for File.exists? and File.exist?
+ added Dir.getcwd
+ added empty File.delete
+
+commit afb252fd6170ed051e97f1911e5f1200414ebf98
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Aug 18 22:20:10 2007 -0700
+
+ updated compiler specs.
+
+commit d0e6b658d9065b0fbc9180cd5d19139834f64f59
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Aug 18 21:04:18 2007 -0700
+
+ changes to support better CI specs
+ hat mini_rspec will take a filename as an exclude/include argument and read the actual excludes/includes from the file.
+ added that mspec will take -o FILE to use an alternate to STDOUT for the spec reporter output.
+ updated spec tasks. misc spec changes.
+ added naive implementation of IO#each.
+
+commit 541bcb521a8ee589c7d28c095ad7ee1489af42db
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri Aug 17 19:30:05 2007 -0700
+
+ Complete reorganization of bootstrap. Addition of kernel/platform. FFI fixed.
+
+ New restrictions for meta-programming in core bodies (not in methods).
+ kernel/platform is now where platform specific code, mainly related to FFI, lives.
+ A bunch of FFI bugs have been fixed and it should be working much better now.
+
+ FFI Note: you may now only specify :state as your first argument, and you must
+ leave it off when you call the method (rather than passing nil like before).
+
+commit af245dfbc80ff942de62408e70db7499a798fb0a
+Author: schreiber.arthur@gmail.com <arthur@arthur-desktop.(none)>
+Date: Tue Aug 14 01:30:09 2007 +0200
+
+ Forgot to add the autoloaded file for Module#autoload
+
+commit b946940f463028de067ef2e082c96fe431c94b0a
+Author: schreiber.arthur@gmail.com <arthur@arthur-desktop.(none)>
+Date: Tue Aug 14 01:09:10 2007 +0200
+
+ Updated Module Specs
+
+commit 6cd6aa53a5d20c78941442f7e367ef8c7aee17c2
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Aug 10 00:14:09 2007 +0000
+
+ converted array specs with a few edits.
+
+commit c075f7f70da2a029c69f3fff1f9caec419db64d5
+Author: Arthur <arthur@unknown>
+Date: Wed Aug 8 12:47:18 2007 +0000
+
+ fix a small typo
+
+commit c7262df9ee1c2544890b001574c8cb0f8ae26a75
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Aug 8 01:24:25 2007 +0000
+
+ converted exception specs. added #should_be_ancestor_of. use ExpectationNotMetError in mini_rspec like rspec does.
+
+commit f591e18978b73c508505db73f274f4bd69c372c5
+Author: Arthur <arthur@unknown>
+Date: Tue Aug 7 08:36:15 2007 +0000
+
+ * String#to_str specs should actually use String#to_str
+
+commit 80f69571c5378d6bbb2e7a118ada00db66226797
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Aug 7 06:47:53 2007 +0000
+
+ converted range specs.
+
+commit aca62d253a6b2df891ca4ec4b177ea95b621d636
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Aug 7 03:52:46 2007 +0000
+
+ fixed mini_rspec -e option, allows multiples. converted hash specs.
+
+commit 928c9a392102fa7b7945f332480a7477ec203467
+Author: Florian Gross <florgro@gmail.com>
+Date: Mon Aug 6 22:04:16 2007 +0000
+
+ New specs for String#swapcase(!), to_f, to_i, to_str, to_sym
+
+commit 6d0a6b0051a55af32743d9d98d6425489a622ebe
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Mon Aug 6 21:58:55 2007 +0000
+
+ * more specs for File.open. Specs for File.truncate
+
+commit 8b19b683a8593b4dd5024841d8023df827a44875
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Aug 5 23:39:36 2007 +0000
+
+ fixed completeness to not over match methods. converted comparable specs.
+
+commit c6f4d90df72b103884fa5470a433f5513d2c524d
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Sun Aug 5 22:52:17 2007 +0000
+
+ * more specs for File.open. Some of them are plataform dependent
+
+commit 38bfff9d014b90409e272ddf041dc63f53d48f5d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Aug 5 22:45:31 2007 +0000
+
+ converted bignum specs. misc cleanup.
+
+commit 14890b68c447731417ce53ca2e4310175e39b440
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Aug 5 22:00:04 2007 +0000
+
+ Small spec fix
+
+commit b6c3cfca5cf1b2cb85dc216180ad21a6bf653a10
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Aug 5 17:20:32 2007 +0000
+
+ converted time specs. according to completeness, need to spec 9 more methods.
+
+commit 8829cf7e94ec0434f642fafa7dbf117a860045b9
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Aug 5 07:53:47 2007 +0000
+
+ more converted specs.
+
+commit 5bf174780e893b7ee9b82b6ca3964db7cad84e30
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Aug 5 07:08:08 2007 +0000
+
+ converted fixnum specs to describe per method.
+
+commit 88023701a88c1113e4874c193d26c6bf21fad383
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Aug 4 22:19:18 2007 +0000
+
+ misc noise cleanup in specs. use bin/completeness to find missing specs rather than warns.
+
+commit 3d960a021cb9ac2bdc2a204f94b4f024f3ef60a4
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Aug 4 22:06:12 2007 +0000
+
+ fixed completeness to pass correct spec example string for class methods. changed float specs to describe per method.
+
+commit 8a7abb5996e5bdf8b9d6c5884e0e0d8ae73d060e
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Aug 4 20:10:38 2007 +0000
+
+ beginning of a completeness reporter. use 'bin/completeness -t ruby' to report on the completeness of the specs against MRI. use 'bin/completeness' to report on the completeness of rbx relative to MRI. use -t target for other implementations. updated some specs to the 'describe Class#method' style.
+
+commit 463f13be4462e22bc3f4491a475658624c5832ab
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Sat Aug 4 17:09:25 2007 +0000
+
+ * fix some bugs in bignum_spec
+ * changed the File::Foo.shouid == bar assert to defined?(File::Foo).should == "constant". The specific value dependence on OS.
+
+commit 989d72394f1e175b058f55ccf3e60f09a2c76401
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Aug 4 04:15:01 2007 +0000
+
+ fixed mini_rspec specdox reporter to not output describe message until examples are executed. fixed specdox and dotted reporter to distinguish between errors and failures.
+
+commit f98fe7f211e5784a35e99643fb52c9350b20d7ae
+Author: Florian Gross <florgro@gmail.com>
+Date: Sat Aug 4 01:40:52 2007 +0000
+
+ More compatibility and a few small fixes
+
+commit c78ba9f96d7d4d229d6b1b1b11cf314fb5a0271d
+Author: Florian Gross <florgro@gmail.com>
+Date: Sat Aug 4 00:40:42 2007 +0000
+
+ Compatibility for USE_RSPEC=1, sanity, some clean-up
+
+commit 761d05b5cbd92339f9d02e65d005a65c5155618e
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Aug 3 21:49:26 2007 +0000
+
+ * Compiler and Normalizer fixes for method definitions without bodies
+
+commit ad7abe4d61171f9650d08b277d45c7f680f37950
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Aug 3 17:07:19 2007 +0000
+
+ fixed mini_rspec shared behavior to be compatible with rspec.
+
+commit 1e1ccb902d11547e9f67db82c31a5898e6227d67
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Aug 3 16:39:07 2007 +0000
+
+ added an implementation of shared behavior for mini_rspec. altered Array#[] and Array#slice specs to use shared behavior.
+
+commit 7697b2ae3db6ed1d8697010a7e0f52f8e3587c8a
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Aug 2 20:41:43 2007 +0000
+
+ added SpecRunner class to mini_rspec to properly encapsulate behavior. added --example option to specify a regexp to match examples to execute.
+
+commit b80bb3d295d3648988b15a29553189f219d8ac0a
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Thu Aug 2 15:56:07 2007 +0000
+
+ * added specs for file_spec
+
+commit c277fd3de82678f055693422af19c3f45ffc2a88
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Aug 2 00:46:27 2007 +0000
+
+ mspec: Add -x option for excluding specs by RE
+
+commit aa53967c694ed7621aa1a8a8b542d067d9e58925
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Aug 2 00:05:53 2007 +0000
+
+ New specs for String#succ(!)
+
+commit eafa5b0fd43168b4ae649b145f9528f7deae3aa7
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Aug 1 22:59:38 2007 +0000
+
+ New specs for String#sub(!)
+
+commit 3406e64032251a2a9849da3f6c27d872dd339175
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Aug 1 22:17:18 2007 +0000
+
+ New specs for String#squeeze(!) and String#strip(!)
+
+commit fa4d66576528725085ef47cca27c5c85c55b3150
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Aug 1 21:08:26 2007 +0000
+
+ added Object#(public|private|protected)_methods and Module#(public|private|protected)_instance_methods. added Tuple#first, last.
+
+commit 4ca071ba4a48aa984308e0ba9448718a6e214d7a
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jul 31 20:56:37 2007 +0000
+
+ Some Object#methods et al specs.
+
+commit 67be404ac0714ec01c1c92c77465915d90fd794b
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jul 31 18:41:54 2007 +0000
+
+ Renamed variables_spec.rb to assignment_spec.rb
+
+commit c0187db3e51297dfffabebe9acb6d6321bd04578
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jul 31 18:22:41 2007 +0000
+
+ New specs for String#split
+
+commit 06cb5ab7c39866c99bb8d9a5fbb678f2f8a19cf2
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jul 22 06:47:54 2007 +0000
+
+ Removed the .rbc files from externals dir and set svn:ignore. Added Tuple specs, fixed a couple small problems with Tuple. Modified mspec to pass -I, -r to the target; added -n RUBY_NAME to affect which specs are run. Added hashi dir as an experiment to implement a bootstrap that could be run on e.g. MRI or JRuby to allow the core libs to be run and tested against the specs.
+
+commit 567d4f710bc232fc9223972e22a7d92e4abe940d
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue Jul 17 17:49:53 2007 +0000
+
+ Stack allocated lvars, GC fixes, compiler changes, oh my!
+
+ This is a biggy (too big in fact). It started as a change to allow
+ arguments to be accessed directly from the stack, and turned into a
+ monster.
+
+ Arguments and some lvars can now be accessed directly from the stack,
+ making them cheaper to create and use. This turned out to expose
+ a large number of bugs in the VM related to stack access, as well
+ as some in the GC.
+
+ The big GC change here is that the mark/sweep GC is actually run now,
+ as opposed to before when it would just allocated more and more memory
+ (the source of memory issues I suspect).
+
+commit 564ac024e14a790f4a3d257ddf1d9fa0cb93ee3b
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jul 17 00:20:52 2007 +0000
+
+ $~ specs all over the place;
+ Revised % format string specs (match MRI trunk);
+ Revised hex and oct specs (match MRI trunk);
+ Merged slice together with [];
+ New specs for scan and slice!
+
+commit 2389eb4b36d86732dbb621be1cad3edca0e36aa5
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Mon Jul 16 09:26:20 2007 +0000
+
+ * added specs for file_spec
+
+commit a6453b6184353633d14c271533c2e2af7a6c4b12
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Jul 15 17:53:58 2007 +0000
+
+ A few specs for char numbers outside of 0..255;
+ A few specs for modifying strings while iterating;
+ New specs for hex, index, initialize(_copy), ljust, lstrip(!), match, next(!), oct, replace, reverse(!), rindex, rjust, rstrip(!);
+ Small additions, fixes & refactoring
+
+commit 217dd5dae127c146559dd1512edac23a94565ae9
+Author: Florian Gross <florgro@gmail.com>
+Date: Sat Jul 14 23:52:52 2007 +0000
+
+ Taintedness specs all over the place;
+ String subclass specs for String#%;
+ Range subclass specs for access methods;
+ str[idx, count] = str specs (contributed by John Lam);
+ New cases for capitalize(!) / center / gsub(!);
+ Refactoring
+
+commit b8b0c3dd380335260c3870934ca51dce736ce15d
+Author: Florian Gross <florgro@gmail.com>
+Date: Sat Jul 14 23:39:38 2007 +0000
+
+ Added custom range subclass cases for access methods
+
+commit 558552ec549fd605bed2c8f5c384e8c944e780a2
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Fri Jul 13 14:40:15 2007 +0000
+
+ * added cases for file_spec
+
+commit 5218708c630bd8a631522a00aa6cba4e91cbec54
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Fri Jul 13 13:36:53 2007 +0000
+
+ * added cases for file_spec
+ * refactoring numeric_spec.rb
+
+commit 3e9dbc15a81950e55a15a7fcca0ab04a5fd5353f
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Jul 11 22:09:49 2007 +0000
+
+ Add specs for to_* calls having correct semantics with method_missing() and respond_to?();
+ Small clean up
+
+commit 23961f46af6f74d2d6b9019972e451a5ae12b728
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Jul 11 22:00:26 2007 +0000
+
+ Add specs for to_* calls having correct semantics with method_missing() and respond_to?();
+ Removed a few duplicate specs (probably resulting from a mismerge)
+
+commit 639c64ca0965ff79401989ca7dbde862815f13fb
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Jul 11 21:09:33 2007 +0000
+
+ Add specs for to_* calls having correct semantics with method_missing() and respond_to?();
+ Fixed String#%'s %E/e/f/G/g and %b/d/i/o/u/X/x specs to verify Kernel#Float / Kernel#Integer semantics instead of to_f / to_i ones
+
+commit e97879670bbc8425810a3c83f15a523066899a89
+Author: Arthur <arthur@unknown>
+Date: Tue Jul 10 20:04:48 2007 +0000
+
+ * fix a typo
+
+commit 1e8890613a215c61ef90629b8b6023ac4612c499
+Author: Arthur <arthur@unknown>
+Date: Tue Jul 10 20:03:44 2007 +0000
+
+ * Update Symbol Specs to the new format.
+ * make Symbol#to_int show a warning as in MRI.
+
+commit 1262f24460463628c7cc4e275b7c814048937b57
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jul 10 18:28:06 2007 +0000
+
+ New specs for gsub() without block
+
+commit 0ba87f6edc183385551e4cf8c05212fadaf36427
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jul 10 16:48:46 2007 +0000
+
+ New specs for capitalize, chomp, concat, crypt, eql?;
+ Added missing methods chop, chop!, count;
+ Small improvements and refactoring
+
+commit 226942caef6bd217a13dc235a89c5ccf4a18f98b
+Author: Florian Gross <florgro@gmail.com>
+Date: Mon Jul 9 21:29:19 2007 +0000
+
+ Strings specs for letters c through e
+
+commit e41c027537f1e4f8ea4b8b5b6fe90df9a21e3aff
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Fri Jul 6 17:13:39 2007 +0000
+
+ * added 62 cases for file_spec
+ * remove a bug from obejct#method_missing_spec that break the specs
+
+commit 06d2fd71b847e139a39ab3b7a132ab041a8d4c1e
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Wed Jul 4 16:05:21 2007 +0000
+
+ * add 84 cases to the numeric_spec.rb
+
+commit b8d334f575322c65932279346bba61caead61555
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Wed Jul 4 10:28:27 2007 +0000
+
+ * 14 cases for Object.method_missing
+ * Add File#atime, File.atime, File#ctime, File.ctime, File.delete, File.executable?, File.executable?
+
+commit f2276130c4bf1894ffb6efb451203dcbfe9322bb
+Author: Charles Nutter <charles.nutter@sun.com>
+Date: Wed Jul 4 08:48:57 2007 +0000
+
+ Added a spec for Process::times...it's not great, but it's something.
+
+commit f71bb57b3fc69c35d34abdb9959e27efb71bbdff
+Author: Charles Nutter <charles.nutter@sun.com>
+Date: Wed Jul 4 06:14:06 2007 +0000
+
+ Fixes for #150; handle Time - Time correctly, don't assume it's a number of seconds.
+
+commit 895f1abdc0bfcdb213f97067704b1bb87a7e6d17
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jul 3 17:01:27 2007 +0000
+
+ New specs for casecmp
+
+commit 2aa7cb37925cd92c3b23d4a33a6d7bc7c2b66737
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jul 3 14:07:56 2007 +0000
+
+ New #[] and #[]=, capitalize and casecmp specs;
+ Converted "should work" messages to "works" using a few regular expressions -- I'm still going through the file so bad replacements (if any) will be fixed
+
+commit 719ff3b8959d93d7da8165d6e5b44989afde92d7
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Tue Jul 3 00:33:59 2007 +0000
+
+ * new NoMethodErro_spec.rb
+
+commit 5363324044fdc1457cfbf1b738dd931d3255b191
+Author: Florian Gross <florgro@gmail.com>
+Date: Mon Jul 2 23:58:09 2007 +0000
+
+ Some more new specs
+
+commit fa1b3694e366bf087a8d1ac107257c38ce447251
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Mon Jul 2 20:29:20 2007 +0000
+
+ * Add to_s with a base spec
+ * Change foo.aMethod.to_s.should == "bar" with foo.aMethod.should_be_close(bar,TOLERANCE) because floats representation are plataform/implementation dependents, but not changed aBignum.to_s.should = ...
+
+commit 2a5c93afd4ddfef7c30de17c531f49849e9bb957
+Author: Pedro Del Gallego <pedro.delgallego@gmail.com>
+Date: Mon Jul 2 00:10:06 2007 +0000
+
+ * Add Float::Constant specs
+ * Change foo.aMethod.to_s.should == "bar" with foo.aMethod.should_be_close(bar,TOLERANCE) because floats representation are plataform/implementation dependents
+
+commit 7d3dcc24cb72d6548cf44d8519691f4cd7344801
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Jul 1 21:00:37 2007 +0000
+
+ Heavily extended and refactored String#% specs;
+ some cleanup
+
+commit 79ce6628df39d20d03efcd715ea42ba70ae9f03e
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Jul 1 20:59:38 2007 +0000
+
+ Add support for MRI as :mri for failure() and similar methods
+
+commit 7e43cd858c0380aaf17dd7bacd8a24cef96bb309
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Jul 1 17:11:08 2007 +0000
+
+ rindex terror specs
+
+commit e5b7cf88092cf59357124e3d8f35bc19f8ee589a
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Jul 1 01:14:09 2007 +0000
+
+ Added a few new format specs (Most of these should probably be moved to Kernel::format later)
+
+commit a533693824608a03ab6a66882b607fecab3a3a75
+Author: Florian Gross <florgro@gmail.com>
+Date: Sat Jun 30 00:29:29 2007 +0000
+
+ A few more specs, clean up and compatibility with MRI 1.9 head
+
+commit b9e8936562ec23db63879f9c127dadeadd8adf2e
+Author: Florian Gross <florgro@gmail.com>
+Date: Fri Jun 29 02:41:40 2007 +0000
+
+ New specs for [], default(), delete(), shift(), yield argument count semantics and modifying hashes while iterating over them;
+ Also removed some warnings and cleaned up the code a bit
+
+commit 72d1b106c1de4b00b9af184eb890e950854a9c77
+Author: Florian Gross <florgro@gmail.com>
+Date: Fri Jun 29 02:37:55 2007 +0000
+
+ Adding spec for join passing along separator argument for nested arrays
+
+commit 6e2848b7143cd0ae47a7b9ac632a567df7fd30fc
+Author: Florian Gross <florgro@gmail.com>
+Date: Fri Jun 29 02:35:09 2007 +0000
+
+ Adding message argument for should_raise()
+
+commit 31591886dde4bfd9b4e9de34c26960e45566b7ee
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jun 27 05:15:15 2007 +0000
+
+ Commiting (#147) math specs by pedro (modified for style, structure, and legibility).
+
+commit c7d623ee836363d0f3d443ba1c676ef0f86e34f7
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jun 26 04:06:49 2007 +0000
+
+ enhanced spec:ci to take a target on the command line, invoke like: SPEC_TARGET=jruby rake spec:ci. removed deprecated #only and #except from spec_helper.
+
+commit c13a588cb7e37c20ce7e8a9430d854cc51be7b00
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 25 08:28:10 2007 +0000
+
+ misc cleanups to specs to eliminate interaction effects.
+
+commit 280296208bd699cb574c662f92b585519a739c6b
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 25 02:42:07 2007 +0000
+
+ removed extension dir and added README for subtend specs.
+
+commit 7ce8d4addc77ea9da0daf3ea3dc1fc7b00030b29
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 25 02:30:15 2007 +0000
+
+ reorganized subtend specs. stragglers from spec/language reorg.
+
+commit d499ebfd98d8fb9bd50c0f7a46b3587aa1f28c8a
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jun 24 19:44:12 2007 +0000
+
+ significant reorganization of spec/language, added files that correspond to the desired layout of this section. there remains to be done a large amount of cleanup for existing language specs, and especially spec description strings.
+
+commit bc0d0965bb5a6b3966884b63edd37218359aa46d
+Author: Tilman <tilman@unknown>
+Date: Sun Jun 24 14:52:15 2007 +0000
+
+ Extended specs for File.join.
+
+commit a4e189f31a8c256821564041c4dbce2a832ba78e
+Author: Tilman <tilman@unknown>
+Date: Sun Jun 24 13:00:33 2007 +0000
+
+ Fixed a typo.
+
+commit ecaf1abafeb69994b05463742ca4220797f62ad3
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Fri Jun 22 23:25:13 2007 +0000
+
+ * Array specs by Josh Susser (hasmanyjosh)
+
+commit 1c8987b6195d356126ebc3cc9c21e473be915240
+Author: Arthur <arthur@unknown>
+Date: Fri Jun 22 21:22:30 2007 +0000
+
+ * Heavily extended String specs
+
+commit 663e2cbe0c026aa7e792b6aab682301570ccd766
+Author: Tilman <tilman@unknown>
+Date: Fri Jun 22 08:59:42 2007 +0000
+
+ Added specs for Time#dup.
+
+commit f9dd8149bd7d794e8686053e8dca010ea71eacba
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jun 21 06:47:57 2007 +0000
+
+ added methods #compliant, #noncompliant, #extension, #failure. Please read the comments for them in spec_helper.rb. #only, #except are deprecated but have not yet been removed.
+
+commit 389b3cef5176b0244f78294a3c820cc84797e0df
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jun 21 05:22:36 2007 +0000
+
+ added -f i (immediate) reporter for mini_rspec.
+
+commit d113f855e32d09abaa74bb0ccafa4a65ffce66b1
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Jun 20 21:59:27 2007 +0000
+
+ A few more hash order consistency specs
+
+commit 8df2a605937c29b0ca4e89fae37b725e7244fbee
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Jun 20 21:24:01 2007 +0000
+
+ Small spec improvements all over the place
+
+commit 5c2472584637b6f5accaaf2450d4c23904b0bbd7
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jun 19 23:06:33 2007 +0000
+
+ Small tweaks to let us run specs against Ruby 1.9
+
+commit 18b06659146f00f0ecf72846c445b03268305328
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jun 19 15:56:02 2007 +0000
+
+ More specs, including frozen hash ones
+
+commit 3cc17a6c7d4c4e4d13b67da4e2bd8937160916f0
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jun 19 15:02:21 2007 +0000
+
+ Specs for methods involving to_hash and more
+
+commit a33e72ba27dc7c80fb7c3947d4fe86521b8987e0
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jun 19 13:35:14 2007 +0000
+
+ New specs for each, each_key, each_pair, each_value, fetch, has_value?, index, initialize_copy, inspect, invert, key?, keys, length, merge, merge!, rehash, to_a and value?
+
+commit f5ec55b0233fd6b7825b04afc6157caac0c529ce
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jun 19 13:18:33 2007 +0000
+
+ Using except(:rbx) for "inspect should handle recursive arrays" instead of commenting it out
+
+commit 7fec6cb5534d22dbfa4dd245cf3b0c0776b3b465
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jun 19 00:56:35 2007 +0000
+
+ New specs for Hash.new, #==, #[], #[]=, #clear, #default=, #delete and #empty?
+
+commit e3085af8e97177f8b7e4ff1c2aad2f306a4f474d
+Author: Florian Gross <florgro@gmail.com>
+Date: Tue Jun 19 00:53:43 2007 +0000
+
+ Specs for how Array#uniq should use eql?() and hash()
+
+commit 01799e95c71453e8dff9730dd283bf76989e75e5
+Author: Florian Gross <florgro@gmail.com>
+Date: Mon Jun 18 11:22:47 2007 +0000
+
+ Adding new specs from rue plus more. The diff is a bit chaotic, but everything should be OK.
+
+commit 890deed76153d05c6874b46ec29c474eb4e36e41
+Author: Florian Gross <florgro@gmail.com>
+Date: Mon Jun 18 11:12:04 2007 +0000
+
+ Moving only() to general spec helpers, adding expect()
+
+commit bf89af6c3b632b88e3cc74bead42f21561da58a7
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 18 07:19:15 2007 +0000
+
+ (Jason Toy) added some specs for File (with some modifications) (#130).
+
+commit a7a6d8e336f8d331c60e973fb8f9e0aac1fb61ac
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 18 05:20:29 2007 +0000
+
+ (Jason Toy) initial specs for YAML (#123).
+
+commit 4c2f70040050e35da28a8684296f913a3dd4a198
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 18 05:14:41 2007 +0000
+
+ (nitay) patch for Bignum#size (#120).
+
+commit b1e57c9c718acfc7f1e61ae1fb60f10b918f8e5c
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 18 01:40:29 2007 +0000
+
+ Range specs and code from Ryan Mulligan (#141).
+
+commit 9fa70f392bf83c55d67e682c36d9ebd247cff62c
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Jun 17 22:02:48 2007 +0000
+
+ New specs from Ryan Mulligan (#140)
+
+commit 64c970bddeb754115ed193d2f786c797ea90dab3
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jun 17 20:08:40 2007 +0000
+
+ reorganized specs to put implementation-specific extensions in a subdirectory within the logical division of the specs into core, library, language.
+
+commit 8d437f0f63d4d3f9eea6e4436a28f437e6e76053
+Author: Florian Gross <florgro@gmail.com>
+Date: Sun Jun 17 19:39:37 2007 +0000
+
+ Initial work on hash specs -- a few new cases and a bit of reorganization
+
+commit d8222049004ba0d6ec51db0c962b5200bb180aec
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jun 17 03:53:45 2007 +0000
+
+ (yipstar) module specs for undef_method, define_method, remove_method. all pass MRI.
+
+commit 0162cfe6a443ded5d6c8e01a866f5a8d1fbce901
+Author: Florian Gross <florgro@gmail.com>
+Date: Sat Jun 16 23:11:31 2007 +0000
+
+ Added specs for * / join / to_s with recursive arrays
+
+commit 0744e57d7860b9f6eefcc8e14962d7ee777d2ec4
+Author: Florian Gross <florgro@gmail.com>
+Date: Sat Jun 16 22:05:32 2007 +0000
+
+ A few more specs for array sub classes with to_ary [ruby-core:11472]
+
+commit 07e0df5111c8ceeda83e50ef434948ee17e92aae
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jun 16 19:09:19 2007 +0000
+
+ commented out specs that cause the VM to seriously misbehave allocating memory without bound or causing SIGBUS. currently 434 examples, 130 failures at r1357 on MBP.
+
+commit 2abc6e6dc5df662e8f0587636bd1cf3573e39f28
+Author: Tilman <tilman@unknown>
+Date: Sat Jun 16 16:41:07 2007 +0000
+
+ Don't use timezone names that aren't portable.
+ Instead, specify timezones by their standard name and the offset from GMT.
+ This makes the specs pass on FreeBSD w/ MRI.
+
+commit d4106115c2ca9a4678b7060b6ac0091d66312624
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jun 16 08:20:29 2007 +0000
+
+ a first, big step to making the entire set of specs more agnostic about the ruby implementation/engine by, paradoxically, qualifying certain specs to only run under certain ruby engines. removed incompatible and rubinius directories. folded in specs where appropriate and moved spec files (e.g. bytearray, tuple, compression) into the appropriate directories. the spec/parser and spec/compiler dividing line is not clearly defined given the range of types of implementations and perhaps should be merged.
+
+commit 3de0340e693e20b5e32c643f1f4dae7e1943e077
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jun 16 07:07:41 2007 +0000
+
+ migrated more tests from shotgun-tests to specs.
+
+commit 369813306643d98c277841c1e9b400f6b60d3316
+Author: Florian Gross <florgro@gmail.com>
+Date: Fri Jun 15 22:43:05 2007 +0000
+
+ Add spec for elements returning odd stuff on <=>
+
+commit d70ab64def5ebdcb0e1946618b06e810270eb2aa
+Author: Florian Gross <florgro@gmail.com>
+Date: Fri Jun 15 22:17:03 2007 +0000
+
+ New specs for frozen arrays
+
+commit fda7128521254d2db2668fec55ef7ce9337ecf1a
+Author: Florian Gross <florgro@gmail.com>
+Date: Fri Jun 15 21:55:30 2007 +0000
+
+ More specs, mostly for array subclasses
+
+commit 2d57166d2ef2ff63f333b7ee0c196f5c4e10b8cf
+Author: Florian Gross <florgro@gmail.com>
+Date: Fri Jun 15 16:56:25 2007 +0000
+
+ More than five bazillion new specs including a ton for the very evil []= method (letters i through s)
+
+commit b905a952af41a96f72499750c4635b1352b237ba
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 14 23:06:33 2007 +0000
+
+ A few more specs.
+
+commit e17aa3690f7dcd2dab346bf7def0dd26b38072f1
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 14 22:16:54 2007 +0000
+
+ A bunch of new specs. Includes highly exotic corner cases.
+
+commit 7845d8928d138353ad03bd496d1800c03e82b538
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 14 20:52:23 2007 +0000
+
+ Fix cleanup to work with symbolic method names like ==
+
+commit c677ac036baa847cef3de6a34b2b56c9fd09213c
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 14 18:04:43 2007 +0000
+
+ Fixed the test for DATA to match MRI (it's only supposed to be defined when the main file contains __END__);
+ Added test for TOPLEVEL_BINDING
+
+commit 27b2767cd21b5a69ee10a2a629a68de64fd8ae5a
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 14 18:03:26 2007 +0000
+
+ Introducing RUBY_NAME so we can spawn a new Ruby for things that can't be tested otherwise
+
+commit 4c4a96f51b4c06dd6896f996ae0e87a68152a3bc
+Author: Tilman <tilman@unknown>
+Date: Thu Jun 14 15:15:56 2007 +0000
+
+ Don't call Time.now multiple times when comparing their values.
+
+commit cde774be8b188f5870b1ee387b5e5fffd9948163
+Author: Tilman <tilman@unknown>
+Date: Thu Jun 14 15:00:17 2007 +0000
+
+ Fixed a typo.
+
+commit 6e51eee65c310255183d81d97a98be313ca68afc
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 11 04:07:03 2007 +0000
+
+ put guards on imcompatible specs to prevent ruby, jruby from running them. work around for Dir ** globbing being broken.
+
+commit 03dfae6b896a6b67ac6066e94284d992833afac5
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jun 11 02:00:25 2007 +0000
+
+ Added rake task spec:ci. added svn:executable for bin/mspec. enhanced readability of system command in mspec. added globbing across directories to mspec command.
+
+commit 96425667fbff044333c13c5a88c3b8cad156504f
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jun 10 21:45:52 2007 +0000
+
+ modified mini_rspec to include proper reporters. converted mspec to use ruby to generate a command line to run specs. mspec usage should be similar to spec: mspec spec/core spec/language/class_spec.rb will execute any spec/core/*_spec.rb plus spec/language/class_spec.rb and output a single summary of exceptions, examples, failures.
+
+commit 1075f2cf34a81c00a1b06d2474c78300ae013161
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Sun Jun 10 06:59:40 2007 +0000
+
+ Cleaned up MatchData, added support for accessing named groups.
+
+commit c678d79f125d67328e267001e5fe353f5ef38a2c
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sat Jun 9 04:20:51 2007 +0000
+
+ * =~ for regexps to mini_rspec by dean (Ticket #136)
+ * Kernel.caller spec relocation for reliability
+
+commit 00eec364dbf3cef03915a68a359ed06b7e501553
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jun 8 07:10:56 2007 +0000
+
+ reintegrated String specs. all specs in core follow the convention that there is one file named <class>_spec.
+
+commit 9f9817bbb9fea5cc02eb280f01eb50e45ea03118
+Author: Arthur <arthur@unknown>
+Date: Thu Jun 7 23:49:47 2007 +0000
+
+ * String#replace, String#chop! and String#chop behave now as in MRI.
+ * Specs
+
+commit 129e492fcacf937473bb1c602176b48a352f8572
+Author: Arthur <arthur@unknown>
+Date: Thu Jun 7 23:39:00 2007 +0000
+
+ * Fix String#<=> when the given object is not a String.
+ * Fix String#to_sym for invalid symbols.
+ * String#to_i raises an error when invalid radix is given.
+ * More specs.
+
+commit 8d7a9e21874d9e44c63d17dd8f6832b942805707
+Author: Arthur <arthur@unknown>
+Date: Thu Jun 7 23:31:25 2007 +0000
+
+ * Make String#capitalize!, String#downcase! and String#upcase! check for the 'frozenness' of self
+ * Specs
+
+commit 10087a0c92217d1fbadfede9fdb0099c7eb195e6
+Author: Arthur <arthur@unknown>
+Date: Thu Jun 7 23:25:08 2007 +0000
+
+ * Spec for String#==
+
+commit e51ca54f6f4e9e3dabd48895fa2cb746fb0d3c17
+Author: Arthur <arthur@unknown>
+Date: Thu Jun 7 23:23:23 2007 +0000
+
+ * Fix String#=~ to work as in MRI.
+ * Specs
+
+commit d2c7d6e6bb624c23e994888b6a235022486e0c69
+Author: Arthur <arthur@unknown>
+Date: Thu Jun 7 23:16:35 2007 +0000
+
+ * Alias String#size to String#length.
+ * String#<< now correctly checks and converts (where applicable) arguments.
+ * String#<< raises an error if used on frozen string.
+ * Added extended specs for String#<<.
+
+commit c389493556e3394cce846698aa4fc6a67a5f4b40
+Author: Tilman <tilman@unknown>
+Date: Thu Jun 7 18:14:02 2007 +0000
+
+ Time#zone_offset and #zone_utc? are also in stdlib already.
+
+commit 7dcd86dca123edaec7edec2853cba2af27ca6d52
+Author: Tilman <tilman@unknown>
+Date: Thu Jun 7 18:07:59 2007 +0000
+
+ Moved the specs for Time methods that should be in stdlib rather than in core to spec/lib/time_spec.rb
+
+commit 953dfdfdea395ead465a9e19339d94f8b8c7d684
+Author: Hapk <hapk@unknown>
+Date: Thu Jun 7 17:36:20 2007 +0000
+
+ Added more specs for Array#pack: covering %#bB.
+
+commit 7aa84bc102ad6943aed46cbb357f233ac4b6d3f9
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 7 16:47:03 2007 +0000
+
+ Make next with arg match MRI; Fixed typos and a copy&paste error
+
+commit 40c354444d6d7a2fd3aeb940c3bdcf6fd2a28940
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 7 16:43:17 2007 +0000
+
+ Fixed to run on MRI (uses Object.const_get now)
+
+commit 95dd0ca698d0b1f79a11f4a556c171bea33ba176
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 7 12:52:40 2007 +0000
+
+ Make behaviour match MRI, fixed copy&paste errors, did some refactoring
+
+commit 191d4e80406a6e4ffd08594ddeada47fb3219bf0
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 7 01:41:08 2007 +0000
+
+ Fix chaos introduced in rev 1283
+
+commit e0f5184493607f7d9c216146207dc298893a744c
+Author: Florian Gross <florgro@gmail.com>
+Date: Thu Jun 7 01:28:55 2007 +0000
+
+ Fix Dir.chdir test on OS X (/tmp is symlinked to /private/tmp)
+
+commit a32062d6099556a93afee61f0b0000a28675fbb6
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 21:44:00 2007 +0000
+
+ Deleted old specs.
+
+commit de7b3ecaa61c4d3514c8a3534805e9c8d0d1bb2f
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 21:09:48 2007 +0000
+
+ Made the Time#to_a spec pass with any time zone, too. MRI passes all the specs for me now.
+
+commit ac1e295da36f23184e583f5e62a4909959550dbd
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 21:06:32 2007 +0000
+
+ Fixed specs for Time#localtime, #gmtime and friends.
+
+commit 064a5967f5550cf4a2e10885ab2c9f22afa59da2
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 20:56:41 2007 +0000
+
+ Fixed a few more Time specs. Instead of the imaginary time zone "PDT"
+ I'm now using Asia/Kuwait for some specs, because those lucky people
+ don't have DST, which means we don't have to flip the spec expectations
+ every 6 months.
+
+commit 8f6b6a5a5f8e62631a58061b6cdeeaff5654aeb0
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Jun 6 20:41:32 2007 +0000
+
+ module_function specs matched to MRI (module_function makes the instance methods private)
+
+commit 8cc656b95cb71ea476e787ce635df889090f8050
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 20:41:02 2007 +0000
+
+ Fixed the Time#year spec. Using CET, too, since specc'ing using 1969 just feels wrong.
+
+commit ed7be9eaa73b8b1d85964f5c8fdfc250e2e8f62f
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 20:38:43 2007 +0000
+
+ Oops, fixed a stupid error in r1281.
+
+commit e81d716092e0c6a8b52775ca2b9e0d44c4e3ef7f
+Author: Florian Gross <florgro@gmail.com>
+Date: Wed Jun 6 20:35:42 2007 +0000
+
+ Divmod matched to MRI (Special casing darwin on MRI because it doesn't raise FloatDomainError exceptions in some cases)
+
+commit fc5f461c47b7212f05f8699110e313aeab46d46d
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 20:35:34 2007 +0000
+
+ Fixed the Time#hour, #min and #day specs.
+
+commit 6847a1e49ff4ad4dfe7c6e9e4d7352f92d72b4cd
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 20:26:26 2007 +0000
+
+ Don't call Time#seconds as MRI doesn't have it and it doesn't seem to be needed anyway.
+
+commit b9a6ccc89d46ffa910c9bdc0fece9d013440872d
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 20:14:15 2007 +0000
+
+ Time#asctime needs to use %e to print the day of the month.
+
+commit 7311fdf31481ba7a4373d5b007efb62c1f84c389
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 20:03:30 2007 +0000
+
+ Hardcode output for Time.gm(...).inspect. This makes utctime superfluous for now.
+
+commit 229e7eefe7944df92ab2f84e553992fc0c868dbd
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 19:19:38 2007 +0000
+
+ Fixed two more Time specs.
+
+commit 7f490d752ed97bfb9b830d24f4e2c2f44107c141
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 18:41:47 2007 +0000
+
+ Make sure that with_timezone resets .
+
+commit 9c8d25c4d072510215407209fa52a06b85e95d35
+Author: Tilman <tilman@unknown>
+Date: Wed Jun 6 15:57:32 2007 +0000
+
+ Made the wday spec work with any timezone.
+
+commit 4882f8a676d5234339296d6a4489f3a7134cf5fd
+Author: Tilman <tilman@unknown>
+Date: Tue Jun 5 20:08:22 2007 +0000
+
+ Fixed a typo.
+
+commit fb63faa2165cafdc7907f173344638609f884833
+Author: Tilman <tilman@unknown>
+Date: Tue Jun 5 20:03:06 2007 +0000
+
+ Make sure that a GMT Time object returns true from gmt?
+
+commit deae4911588b555264f529e765dc5baf7a2c6e69
+Author: Tilman <tilman@unknown>
+Date: Tue Jun 5 20:00:45 2007 +0000
+
+ Use with_timezone for the gmtoff specs.
+
+commit 625dd8e366f846cf15165e323a719199627ae422
+Author: Tilman <tilman@unknown>
+Date: Tue Jun 5 19:47:29 2007 +0000
+
+ Added a helper method to temporarily override the TZ env var and fixed one of the specs by using it.
+
+commit b359eb74d41749919c6177ec2af6b5b516308bd8
+Author: Tilman <tilman@unknown>
+Date: Tue Jun 5 19:33:01 2007 +0000
+
+ Provided 'date' calls for coreutils' date program.
+ Checking for coreutils using RUBY_PLATFORM isn't the right way,
+ but it will do for now.
+
+commit b19c3c8d886885adc08ac69469792b14e47ba265
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Mon Jun 4 23:42:20 2007 +0000
+
+ * Improved Array#sort with additional spec by wycats (ticket #135)
+
+commit 8513e72a5af7596c8782ee45dff39607489dbf12
+Author: Tilman <tilman@unknown>
+Date: Mon Jun 4 16:39:53 2007 +0000
+
+ Ticket #132: Implemented ENV in core and removed read-only ENV from shotgun.
+
+commit 03d75a78855213f6267fb8f80f9c71d0a031641f
+Author: Mojombo <mojombo@unknown>
+Date: Sun Jun 3 20:49:41 2007 +0000
+
+ Implemented most of Time, updated time specs accordingly
+
+commit 36975b1b79abbd38de68223cdc8ecbca9ba0feee
+Author: Bremac <bremac@unknown>
+Date: Sun Jun 3 16:20:59 2007 +0000
+
+ Add Functions::abort, Functions::printf, and Functions::sprintf, and minimal specs. Closes ticket 87.
+
+commit 9d25d95a4aa3fd22d3f3a340427d40410488a770
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sun Jun 3 12:41:49 2007 +0000
+
+ * Lots of new assignment specs by crafterm (Marcus Crafter) (Ticket #133)
+ * MatchData#inspect and #to_s now indicate it is an MD object
+ * -dc notes which file/method is being compiled
+
+commit ec0fb5beed68155c9e1ff67185cc2c8e4e474c04
+Author: Arthur <arthur@unknown>
+Date: Fri Jun 1 22:23:39 2007 +0000
+
+ * Fix String#[] and add some edge cases to the specs
+
+commit 068b48538ec574558ab787d59b14ebd2925f1126
+Author: Tilman <tilman@unknown>
+Date: Fri Jun 1 18:12:10 2007 +0000
+
+ Renamed module 'B' to something more meaningful to avoid name clashes.
+
+commit eb3de8af03d070b03216daa4fc0c2216d9d3e2a2
+Author: Arthur <arthur@unknown>
+Date: Fri Jun 1 18:09:52 2007 +0000
+
+ * Extend String#slice! specs
+
+commit db4775403d57ea29165165b9cbf0110739d91e2a
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Jun 1 02:26:30 2007 +0000
+
+ * Ticket #128 - Patch by Marcus Crafter to enhance assignment specs
+
+commit 6098aa16357ce4261feb51bdf083c02442b1f074
+Author: Tilman <tilman@unknown>
+Date: Thu May 31 19:05:45 2007 +0000
+
+ Implemented rb_obj_alloc() and friends in subtend.
+ The spec for rb_class_new_instance() is still failing because of strange
+ subtend behavior.
+
+commit ae2c3cb4502ba9475111eeef10b2b70780a1b9f4
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Thu May 31 13:54:24 2007 +0000
+
+ * Fixed shotgun compile failure (possibly r1204)
+ * Various casts to avoid warnings
+
+commit d317d336412d0c1778d4c015dfe96287c44e1bd9
+Author: Hapk <hapk@unknown>
+Date: Thu May 31 11:12:02 2007 +0000
+
+ Added specs for "break", "next" and "redo" keywords.
+
+commit a33f801f8f142d997a553e41cde9f5b10d75ee65
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Thu May 31 04:23:33 2007 +0000
+
+ * Kernel.caller spec by jtoy (Ticket #112)
+ (kernel_spec is badly broken still)
+
+commit ce15eb69e721820e75b0f7aeae6488701cbe9555
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Thu May 31 03:55:27 2007 +0000
+
+ * Fixed String#dump spec expectation (Ticket #105)
+ * Moved RUBY_ENGINE to rubinius-specific variables_spec (Ticket #109)
+
+commit 7d2c575164dfbbd436d7c6ff400c088a68b29fa8
+Author: Hapk <hapk@unknown>
+Date: Thu May 31 00:42:50 2007 +0000
+
+ Added "if" specs for variable scoping.
+
+commit ceb4430f9c713f409f2567a0aa324f19afb09b79
+Author: Hapk <hapk@unknown>
+Date: Thu May 31 00:35:49 2007 +0000
+
+ Added specs for while / until condition/block evaluation order.
+ Added specs for next and redo statements.
+
+commit 4adeecf9333236800396bd77f928fb902e785692
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed May 30 22:17:04 2007 +0000
+
+ * Fixes to RSpec cleanliness of specs, most patches by zimbatm.
+ (Tickets #97 #98 #100 #103, partially #99)
+
+commit bbb0714b6ae60adb0af7445ed56544ceec3bc890
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed May 30 21:41:03 2007 +0000
+
+ * Array specs are RSpec/MRI-clean and pass (Ticket #95)
+ * Fix to should_raise for MRI by zimbatm
+
+commit d627ab36d3839745e057d9f5de781269ba7b154a
+Author: Hapk <hapk@unknown>
+Date: Wed May 30 21:15:39 2007 +0000
+
+ Added specs for 'while' and 'until' statements.
+
+commit 8a2177c7f23181909c5dcb51dd6df1e5b930fdbe
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 30 20:32:13 2007 +0000
+
+ * Enhanced hatefulness of 'for' specs
+
+commit 9f64f2a1c584420fcabfc73a7c464aa3b1ba2e90
+Author: Hapk <hapk@unknown>
+Date: Wed May 30 19:46:57 2007 +0000
+
+ Added specs for postfix "if" form.
+
+commit 9dd8a846adf356d75ceac566612f35d1d30840bf
+Author: Hapk <hapk@unknown>
+Date: Wed May 30 19:34:50 2007 +0000
+
+ Moved loop specs from spec/language/expressions into spec/core/kernel_spec.rb.
+ Added more specs for Kernel#loop.
+
+commit ddf2e3169c3a8b587f9abfb0ddf196635aec5186
+Author: Hapk <hapk@unknown>
+Date: Wed May 30 18:57:38 2007 +0000
+
+ Removed obsolete "elsif" statement spec.
+
+commit 3b6dca92ea810aa7866a2c7aa0b8812e72b6630e
+Author: Hapk <hapk@unknown>
+Date: Wed May 30 18:56:00 2007 +0000
+
+ Updated specs for "if" statement to cover more cases.
+
+commit 678f609bfe826538ec16e75f7362bcb3f50c8d6d
+Author: Arthur <arthur@unknown>
+Date: Wed May 30 17:09:09 2007 +0000
+
+ * Extend Specs for expressions
+ * Break the Specs up
+
+commit df60cc21e4213ac8344b5ed91e802d8cbbfa47a0
+Author: Tilman <tilman@unknown>
+Date: Wed May 30 17:00:17 2007 +0000
+
+ Implemented rb_ary_store() in subtend. The last spec still fails, but we'll fix that later.
+
+commit 8e0fea820c1683913625dfe95c7d3210d4548814
+Author: Arthur <arthur@unknown>
+Date: Wed May 30 10:09:55 2007 +0000
+
+ * Extend Specs for Class Definitions (nested class definitions, class definitions that extend objects, Multiple Definitions of the same class).
+ * Lots of them are failing in rbx.
+
+commit ce16f2b568ea89cb5f13660d3175165b105e4233
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 30 01:18:39 2007 +0000
+
+ * OK, that should really be in 'rubinius', not 'incompatible'
+
+commit 888b777539baa116eedc14191ac85d57aec54349
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 30 01:15:37 2007 +0000
+
+ * 'Options' is a Rubinius-only class, and should therefore be in 'incompatible'. Closes ticket #102
+
+commit 46a58344fa2f03fb4154b78f34239a815b2d9944
+Author: Bremac <bremac@unknown>
+Date: Tue May 29 23:52:52 2007 +0000
+
+ Fix typos in specc'ing module_function, and make that spec play nicer with MRI.
+
+commit e0cedb691f76af4554bfc7522a7668ff861492f0
+Author: Bremac <bremac@unknown>
+Date: Tue May 29 20:49:42 2007 +0000
+
+ More complete raise implementation and specs: Handle instantiation.
+
+commit 9f3a3bfe9d2610dd7e9e752c86a1b8aba47f7fdf
+Author: Hapk <hapk@unknown>
+Date: Tue May 29 20:39:07 2007 +0000
+
+ Added 'case' spec for case with empty 'else' body.
+
+commit 8f888bd3d0a01afc945c45c0502a0b97f3227c48
+Author: Arthur <arthur@unknown>
+Date: Tue May 29 20:34:18 2007 +0000
+
+ Extend Class specs. Some specs failing in rbx.
+
+commit f52d9faadc1eac31e7b92c1edb1cf45ca1d42c89
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 20:29:53 2007 +0000
+
+ Implemented rb_str_new2() in subtend.
+
+commit d4d5e3d1eb8e5ee44acff6697a29a37b9eca25b2
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 29 20:00:51 2007 +0000
+
+ * Patch by HaPK - Add specs for 'case', and enhance specs for 'for'
+
+commit f3e736731e852dacbf90e8e3e33d840384909354
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 18:56:41 2007 +0000
+
+ Actually exercise rb_ary_unshift() in the spec.
+
+commit 69d756ae17fce1fb53be5e7a1b5b7169b69c4aa2
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 18:55:32 2007 +0000
+
+ Implemented rb_ary_shift() in subtend.
+
+commit 9f84a5ecddae6c0daf1fd7e46815275c7d7429db
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Tue May 29 18:50:41 2007 +0000
+
+ * Fix to Array#to_a for subclasses
+
+commit 2bbc87fc1b5261b57927a02f75915829b398b478
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 18:50:33 2007 +0000
+
+ Implemented rb_ary_unshift() in subtend.
+
+commit 4e69b95ad7991a57fd3f9b7cbf350cb5b13c6a5c
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 18:46:53 2007 +0000
+
+ Implemented rb_ary_dup() in subtend.
+
+commit 122a9cfbe79e872146116c8e045a243fffd333e6
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 18:31:48 2007 +0000
+
+ Marked SubtendArray method functions as static.
+
+commit 0e3319c07aa1d536343343fbbe1004c4cdce2df0
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 18:28:05 2007 +0000
+
+ Implemented rb_ary_clear() in subtend.
+
+commit 621f0082fca85140791e2c40aabc8ad3fe3318a6
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 17:58:31 2007 +0000
+
+ Implemented rb_ary_entry() in subtend.
+
+commit 9c7d05c0bb19e65f57fc6aab778785e2a727c4a4
+Author: Tilman <tilman@unknown>
+Date: Tue May 29 17:42:40 2007 +0000
+
+ Ticket #91: Made spec/subtend/rake_helper.rb more portable.
+
+commit 5dba201079bdf8da63364ea760342f3cef85df74
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 29 15:56:01 2007 +0000
+
+ * Add specs for Array#pack, patch by HaPK
+
+commit 2d71e18c6f08144d4fb402904a9226a8500343bd
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 29 15:28:45 2007 +0000
+
+ * Better fix to method argument scoping, to support: def foo(a, b=a.length)
+
+commit f9deebb38b80cdea3dff44d7461404e5f501f566
+Author: Defunkt <defunkt@unknown>
+Date: Tue May 29 09:59:00 2007 +0000
+
+ * Add spec for Struct subclasses. Closes ticket #110
+ * Add failing specs for Class.new. Closes tickets #89 and #94
+
+commit 3be02f950f32a288fac1cd5cff0ae014057c96fb
+Author: Defunkt <defunkt@unknown>
+Date: Tue May 29 09:12:00 2007 +0000
+
+ * Add should_include convenience method to make rspec more compatible with mspec. Closes ticket #106
+
+commit 68e716e1874e7dd4186c7eef2aea5e25157a44fd
+Author: Vagabond <vagabond@unknown>
+Date: Tue May 29 03:46:33 2007 +0000
+
+ * Add HaPk's fix to Numeric#== to handle failed coersion with corresponding specs
+ * Removed duplicate definition of Numeric#==
+
+commit a63e6fcb08e34c625957d8d23bbe602964863c5b
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 29 02:59:43 2007 +0000
+
+ * Add Kernel#eval. Probably lacks some crazy MRI semantics at the moment
+ * Method definitions should properly create a clean scope for locals
+ * Support wacky default arguments, such as blah = lambda {|z| z.foo(another_arg) }
+ * Optional label prefixes in assembly output, for easier debugging
+
+commit f1295ac58d2b601f539efe0e660dfed9d043d1d7
+Author: Vagabond <vagabond@unknown>
+Date: Tue May 29 01:39:46 2007 +0000
+
+ Change Time specs to use ENV['TZ'] instead of `date` in hopes of being more portable
+
+commit 404faeca93c007f3eb9b3df52c2bde7673565113
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Mon May 28 19:20:27 2007 +0000
+
+ * Fix some mistakes in method_spec that caused it not to pass under MRI
+
+commit d336078c02e1306acb4b2664a427b63e93b02788
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun May 27 06:03:25 2007 +0000
+
+ * Fix local scoping to allow for method definitions on local variables
+ * Pass all the horrible method definition specs
+
+commit 7759a0f91f794d05a32d48dd2e67d05c0b1dace7
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sun May 27 05:03:53 2007 +0000
+
+ * Rename Thread.yield to Thread.pass
+ * Implementation of 'module_function' by bremac, with minor tweaks
+
+commit 55f30c5e59d16ebbf045be93a7d406fed9a4dcbd
+Author: Vagabond <vagabond@unknown>
+Date: Sun May 27 00:34:44 2007 +0000
+
+ Added defunkt's implementation of Module#const_set and const_get and associated specs (Ticket #72)
+
+commit 9cebe0c56fda41b83ab14d39275e327daf0bdcc9
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sun May 27 00:31:47 2007 +0000
+
+ * Fixes to mini_mock by bremac (Tickets #85 and #86)
+
+commit f33756f22597bd280e453d5c7ad97685fa284579
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sun May 27 00:24:51 2007 +0000
+
+ * Fix typos in splat_spec (Ticket #77) by tilman
+
+commit ea13a828e5fc19694fc24da25b2224a75462a88c
+Author: Vagabond <vagabond@unknown>
+Date: Sun May 27 00:11:58 2007 +0000
+
+ Add Chris Wanstrath's (defunkt) Struct patches. Tested working against MRI.
+
+commit 3ca0ddcc2c39fec74f10b75df2af5c1581b9eaa3
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sat May 26 23:56:26 2007 +0000
+
+ * Array fixes. Only spec failure remaining is #pack
+
+commit 4d91aa707a47189398455eb1c40b341dc3766ccf
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sat May 26 20:05:13 2007 +0000
+
+ * Array fixes to pass specs (including HaPK's code).
+ All remaining failing Array specs except #pack are
+ not Array bugs. Test this heavily.
+
+commit 6793b34a54ab8e24e8a66a8af026a34315ac9f5b
+Author: Vagabond <vagabond@unknown>
+Date: Sat May 26 07:34:12 2007 +0000
+
+ Add cdcarter's Enumerator implementation and specs translated from his test/unit tests
+
+commit fd10c39192825aeef68c8843c2813cf50b8137f2
+Author: Vagabond <vagabond@unknown>
+Date: Fri May 25 20:12:22 2007 +0000
+
+ Some fixes to rand with associated specs
+
+commit 60d37d28b715854f5186598c90101824665ce715
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri May 25 19:43:11 2007 +0000
+
+ * Properly normalize default method arguments, to support: def(x, y=puts('hi'))
+ * Fix 'for' loops so that they use 'create_block' in the proper way
+ * Move all 'for' processing out of compiler.rb
+
+commit 3c04a44e8ff9e84f48fbd2d3afabb886494b5a98
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri May 25 06:35:48 2007 +0000
+
+ * Patch by HaPK - Fixes String#dump / inspect / upto
+
+commit 9e2442110ec33ff9ca4875407b227f2cf79a606a
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri May 25 05:36:31 2007 +0000
+
+ * Use a random pivot point for better worst-case Array#sort performance
+ * Add 'rake pristine' task to kill all .rbc files
+ * More tricky specs for splats and multiple-assignments
+
+commit 7bea77d8d3e8f190dba4f34fead888551fd07730
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu May 24 23:50:06 2007 +0000
+
+ * HaPK's patch to String#<=>, along with its specs
+
+commit 0e6007e7eb9eee5e3ab1acdf55da00f4ab8c4be0
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu May 24 23:29:49 2007 +0000
+
+ * Add spec for masgn semantics
+ * Fix numerous multiple assignment bugs
+
+commit 6d68d22efd7d2dba75c77cf957edb28dca6df6ef
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu May 24 07:05:00 2007 +0000
+
+ * New Array#sort implementation, fixes several Array and Hash specs
+ * Add a warning comment to bytearray.rb about some incorrect <=> behavior
+ * Prevent unimplemented Array specs from crashing the spec run
+
+commit 0ca089c7354ec96103cb637f861751ca7df01136
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Thu May 24 01:15:40 2007 +0000
+
+ * Support all kinda crazy splat syntax
+ * Updated some compiler specs, though some TODOs remain
+ * Added a comment above unshift_tuple, since it really shifts
+
+commit bbe0b73b07a393f94724964941d2fdd717a2d72e
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 23 19:58:10 2007 +0000
+
+ * Add compiler support for: yield(*args)
+ * Update some compiler specs to match recent fixes
+
+commit 32a7082205d3d214ad43a477286270a96076b140
+Author: Kev <kev@unknown>
+Date: Wed May 23 17:32:06 2007 +0000
+
+ Make spec titles consistent (describing C api behavior)
+
+commit 699c66f8c8304522fbb3589356fe2bcd298277c8
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 23 06:56:25 2007 +0000
+
+ * Use yield instead of &prc.call when initializing a thread.
+ * Fixes VM crash / closes ticket #68
+ * TODO - Why the HELL does this fix it?
+
+commit f8b6e1ff9e19e786b08fee30988eb874eae748b5
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 23 03:18:26 2007 +0000
+
+ * Implement Thread.main
+ * Prevent Object#inspect from crashing the VM when the inspected object has itself as one of its instance variables
+
+commit f24f573608ee5569b29754a017769db0f866cf4c
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 22 22:35:14 2007 +0000
+
+ * Implement 'class_variables' method
+ * instance_variables and class_variables now accept an optional argument, causing them to return symbols instead of strings
+ * Support defined?(@@class_var)
+ * Support defined?(a_vcall)
+ * Fix false-positives in defined_spec.rb
+
+commit da540b51c47b2349b0ab8d4ca0bd11124138f9ce
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 22 20:52:30 2007 +0000
+
+ * Add compiler support for begin/rescue/else/end syntax
+ * Default rescue clause should be StandardError, not RuntimeError
+ * Add specs for 'else' and empty begin sections
+ * All Exception specs now pass
+
+commit 82abf73fd99ec45f7cb6d98d19b219a61af59a61
+Author: Vagabond <vagabond@unknown>
+Date: Tue May 22 18:39:59 2007 +0000
+
+ * Fix Object#instance_eval to bring it into line with the specs and MRI
+ * Fix Object#instance_variable_validate to not accept fixnums as instance variable names
+ * Add another Object#send spec that tests exception raising for missing singleton method names
+
+commit 3b624f3f49c0433289224baf656b3d7be78cecd8
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue May 22 08:15:48 2007 +0000
+
+ Fix the block arg scoping problem, also add a missing file from the compiler specs.
+
+commit 59af7028c060c8e3f9b9c107fb750a71dd37a1d6
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Tue May 22 07:14:54 2007 +0000
+
+ A bunch of yummy-ness. Local variables now conform to the 'standard' behavior, ie they're allocated at different depths inside blocks (this is the yarv/jruby behavior).
+
+ Cleaned up a couple of subtend things.
+
+commit f8ed63efac6fa661dd39db2c207b66c34d132546
+Author: Vagabond <vagabond@unknown>
+Date: Tue May 22 03:28:17 2007 +0000
+
+ Add specs for Object #method, #respond_to? and #__send__. These currently fail with singleton methods on rubinius.
+
+commit 0d6e6b7109014c97d8f8be136166b3279d5a1108
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 22 02:06:19 2007 +0000
+
+ * Handle 'call' nodes containing newlines, e.g. x = [5,6,7,8];p Hash[*x]
+ * This is probably the wrong implementation, but it does work
+
+commit 518f7d34112e536d726cecfb2473c7b3db9ec33e
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 22 00:52:01 2007 +0000
+
+ * Fix mini_mock's cleanup process
+ * Add the ParseTree sexp test cases as specs. Currently in serious need of auditing
+
+commit 17ad76c162ff0cfe9662c20d418f455581389b42
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon May 21 21:50:13 2007 +0000
+
+ Add a failing spec
+
+commit 1744773b7f57c766c75d188b04e55540d45e19d0
+Author: Vagabond <vagabond@unknown>
+Date: Mon May 21 20:22:04 2007 +0000
+
+ Do some env trickery to make Kernel#at_exit testable
+ Improve implementation and specs for Kernel#warn
+
+commit 45733aa44e8daee9e8c5e552ac9312f21163fe39
+Author: Vagabond <vagabond@unknown>
+Date: Mon May 21 20:16:18 2007 +0000
+
+ Convert time specs to compare against output of the date command
+ Change Time#inspect to use %z (GMT offset) instead of %Z (timezone)
+
+commit e58ef35a05d2a565befeaf3600bc00f21203a84c
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon May 21 20:12:34 2007 +0000
+
+ Add spec for breakage caused by 1089.
+
+commit a5d54efe9a45f3acc1cdb0183a8c13ce6ed5e327
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Mon May 21 04:57:41 2007 +0000
+
+ * Options implements a minimal lightweight option parser
+
+commit b28b77af82d99a7a3ec5a78f6ab8b4e138ac577b
+Author: Kev <kev@unknown>
+Date: Mon May 21 03:54:33 2007 +0000
+
+ Add missing hash spec
+
+commit 81496352bdc2b6b27e293b7542908c6be54b9b6b
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon May 21 02:08:57 2007 +0000
+
+ added specs from ticket #38 (David Anderson), but not patch because implementation was invalid (e.g. [].first(0) => [] not nil) and superceded by recent patches. fixed Array#[i,0] => [] exposed by the added specs.
+
+commit 4ed6afc81262a4197f1ddc646ada94277cd9abe6
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon May 21 01:07:36 2007 +0000
+
+ HaPK's patch to Array#[] with specs. Knocks 14 failures down to 6. Ticket #60.
+
+commit b267aee1c10b6092d954c72d5776f4eafc109e51
+Author: Kev <kev@unknown>
+Date: Sun May 20 21:09:49 2007 +0000
+
+ rb_raise, rb_const_get, exception definitions. Wooooo exceptions from C
+
+commit 37793ed650e6ce7352a7547cf4bc68f2ceb2f0b4
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat May 19 08:42:23 2007 +0000
+
+ * Added nastier multiple-assignment-with-splat specs
+
+commit 39c9817fa1932f9fe708a8ba78f43cb39e7cb68b
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat May 19 08:30:06 2007 +0000
+
+ twifkak's Kernel.fail patch with slightly modified specs.
+
+commit 264a42e8c11d08afa895b415453d59e1e1efe2e1
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Sat May 19 08:01:47 2007 +0000
+
+ * Remove a misleading comment in exception_spec
+ * Pre-compile bin/*.rb after a make install
+
+commit 7608e585e02283677275aaf5e5283e397ed2d671
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri May 18 23:57:09 2007 +0000
+
+ Vagabond's Kernel.warn.
+
+commit 9a41c5a21bbc822ff9ff758eb2962ba80e2d454b
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri May 18 18:52:36 2007 +0000
+
+ * Re-enable tr and unpack String specs
+ * Change 'Nan' to 'nan' in Sprintf to match MRI
+
+commit fdc7032c6e4823727312cc7e5c33386cf9d91429
+Author: Mental <mental@unknown>
+Date: Fri May 18 06:01:20 2007 +0000
+
+ add spec for ensure result elision
+
+commit 37438dc826624c3fee3afc1d30a9f661bbb1ab8d
+Author: Mental <mental@unknown>
+Date: Fri May 18 05:45:28 2007 +0000
+
+ basic thread spec
+
+commit d89b7728d148ba8c1ddd74323aa8f9e3dae79691
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri May 18 02:37:55 2007 +0000
+
+ * Fix 'should_raise' in mspec and rspec helpers
+ * Added some new Module specs, and fixed existing failures
+
+commit f63e0cf797158a239f65714918debf7a6c1bb687
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Thu May 17 04:12:58 2007 +0000
+
+ * First draft of a mock lib for mini_rspec
+
+commit c7fd82a8b4b84088de45463dbc25ae7eea5aabe2
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 16 22:38:27 2007 +0000
+
+ * at_exit handlers should run in reverse order of registration
+
+commit 2fb5c6e46f1682d927be8a9e116a609c75ec8be5
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 16 22:14:21 2007 +0000
+
+ * Fix Kernel.Array(). All core/kernel specs pass now
+ * Add Kernel#at_exit specs
+ * Fix Kernel#`
+ * Move AtExit handler array from Ruby namespace to Rubinius
+ * It's spelled 'occurred', not 'occured'
+
+commit 3d1605a3ca731b05b5c03ebd8a6edcf386612930
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed May 16 06:04:16 2007 +0000
+
+ added incompatible specs for #instance_methods returning symbols.
+
+commit 8ba8409ae0ab94a33cd082f02a81d4d1eab35b59
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 16 04:27:22 2007 +0000
+
+ * Patch by shadowfiend - Enhance Module specs and implement Module#instance_methods
+ * Make sure instance_methods always returns symbols, not strings
+
+commit 1e9b0066d712d4507260be02cf2bf116b2519af2
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed May 16 03:24:35 2007 +0000
+
+ * MethodTable 'is a' Hash, and does not need its own fields in the bootstrap. Fixes 'Object.methods.keys'
+
+commit 8c57dd0e26cb5468c1b0150c5d9c5d80ae6f2de2
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon May 14 06:18:42 2007 +0000
+
+ fixed class specs to pass on MRI. put rbx-specific integer specs in spec/rubinius.
+
+commit 8b43acd25a14f540447a9f958f7671822f836817
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon May 14 05:59:06 2007 +0000
+
+ moved rbx-specific proc specs to a new home. made core proc_specs pass MRI.
+
+commit 4feb384d0a02b272bd1a3581dd4070ef475b25af
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon May 14 02:59:22 2007 +0000
+
+ added RUBY_ENGINE == 'rbx' to global constants and exposed Rubinius::<const> on Object like MRI. converted sprintf specs.
+
+commit 34ad791d5f60177de7992a24f07992bb0d6c8b09
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Mon May 14 02:25:06 2007 +0000
+
+ * Disabled Lightning's dissembler on amd64
+ * Split specrunner into bin/mspec and a wrapper
+
+commit 8796b1f00501813c62676266508a6f89a82ec48e
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun May 13 22:47:28 2007 +0000
+
+ minor reorganization, cleanup of spec dir.
+
+commit 9be73815e2037dcc5347c2ef9876e76316efc504
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun May 13 22:06:54 2007 +0000
+
+ specrunner outputs summary with 'examples'. converted language/literals, keywords, straggler method_spec.
+
+commit 647fe38ce5f132b7944cca8550233249d8b3c113
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun May 13 21:21:04 2007 +0000
+
+ converted language, parser, library specs.
+
+commit d9e8f1fd3bc70231c89a1bdc17a9af5a46fce819
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun May 13 08:28:21 2007 +0000
+
+ converted incompatible specs.
+
+commit 9a07bb52c526ce8883c53d437077d78510b0ac73
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun May 13 08:09:34 2007 +0000
+
+ added Object#coerce_string that should act like 1.8.x StringValue function. added String#crypt and a couple other String things.
+
+commit 2bae9b5e3baa33da21c1335e84c2eab062eac3a4
+Author: Kev <kev@unknown>
+Date: Sun May 13 06:21:06 2007 +0000
+
+ add rb_hash_delete
+
+commit 0ca1a5baa94b5984b0812365a408688420168d24
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Sun May 13 05:31:24 2007 +0000
+
+ Imported GNU Lightning. subtend's rb_define_method_ now generates stub's to pop the args and call the function. Next step, add type conversion to call functions that don't take handles.
+
+commit 141e795d5042cb4ea398c9b8eaa9cd7045f5625e
+Author: Kev <kev@unknown>
+Date: Sun May 13 05:15:33 2007 +0000
+
+ Add rb_hash_aset
+
+commit 0988a253d8e23b400a738ad74637e8b3655eae8c
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat May 12 19:40:35 2007 +0000
+
+ new .rba's with rue's changes. converted spec/shotgun specs. added specs for Tuple. added aliases size, length for Tuple#fields.
+
+commit abd44484b4b2a28a4c7f0bf7acdf12ff30123729
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sat May 12 19:32:06 2007 +0000
+
+ * Fixed class variables, should work everywhere now
+ * Specs for cvar behaviour
+
+commit 8ec7dac58577cea314ff0fcd976219b23591bc4d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat May 12 07:40:42 2007 +0000
+
+ reimplemented Object#instance_variable_get|set and #instance_variables. now works with immediate values, and classes with no __ivars__.
+
+commit 30c4dd441243277ec5b814ad9b4d4697e87641d0
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri May 11 07:56:14 2007 +0000
+
+ added primitives for instance_variable_get|set so that methods operate identically on objects that do not have an __ivars__ field (e.g. Array, String). this needs more work because an exception occurs when attempting to set|get instance vars on an immediate value.
+
+commit 998a0ab62542f36f9e36bdd497116349421951ce
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed May 9 23:07:35 2007 +0000
+
+ * Converted rest of spec/core/
+ * mini_rspec/specrunner improvements
+
+commit 0cac71dd1e4dbb728bd3401e73fda5b3fbe95e38
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed May 9 08:18:59 2007 +0000
+
+ updated expectations to be the actual compiler output. these specs should be carefully reviewed.
+
+commit 8d551887fd1fabc7700f9f0a432b728829dcef96
+Author: Kev <kev@unknown>
+Date: Wed May 9 07:42:15 2007 +0000
+
+ Pull out bundle that got caught in the commit
+
+commit 736916decc6d9bfd7096079a0118f41a168d735d
+Author: Kev <kev@unknown>
+Date: Wed May 9 07:41:42 2007 +0000
+
+ Add hash specs, and impl of rb_hash_new
+
+commit 2352f0a526be0f277f2e5d60f18acddc216045c1
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed May 9 07:06:45 2007 +0000
+
+ converted test/bytecode/test_compiler to specs.
+
+commit 1f1d30f9ca690214a61f299a4bb408c2d28ef004
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed May 9 06:08:41 2007 +0000
+
+ * Converted MatchData specs
+ * Default warnings for empty spec files
+ * Improved specrunner
+
+commit 04c03e648ca83de2c2aee37f9aef9079d0493bd7
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Tue May 8 06:24:48 2007 +0000
+
+ * Converted Integer and Kernel specs
+
+commit a202ef1dfb21cebf3ee33376775d86b9dc89269d
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue May 8 05:45:33 2007 +0000
+
+ added before, after methods to mini_rspec. started adding compiler specs as conversion from test/bytecode/test_compiler. removed all host/target junk. thanks. bye.
+
+commit 692da2d89089bc94c95915c90da756480a057dc1
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue May 8 03:36:51 2007 +0000
+
+ converted object specs. these really blow up rubinius.
+
+commit 714f5df86f583158d73eda366e2f2527156c3b8e
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Mon May 7 17:29:56 2007 +0000
+
+ The first compiler spec, testing the masgn assembly. Some are commented out because they don't yet work.
+
+commit 8ccfe13ca0eca4ceae6a201905a64666a75dd6ba
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Mon May 7 05:52:41 2007 +0000
+
+ * Converted and reviewed Hash specs
+ * specrunner reports specifications and failures
+
+commit aa32b8e94de5c1ccd49a9d6ddca5836d6303c460
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun May 6 06:50:52 2007 +0000
+
+ finished converting fixnum specs.
+
+commit 7c55264dc15ed2b8a1b341a5d605701c6626ad34
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Sat May 5 06:22:37 2007 +0000
+
+ * Converted Enumerable specs
+
+commit 1c660edd87fa91d8c244289b00eb9252d5654c3d
+Author: Evan Phoenix <evan@fallingsnow.net>
+Date: Fri May 4 23:45:08 2007 +0000
+
+ Fix array_append as well as the logic to call the extension function so the arguments are correct.
+
+commit 6b9c27b8f8d12be443d37635e17b23b7f0d76388
+Author: Kev <kev@unknown>
+Date: Fri May 4 07:54:10 2007 +0000
+
+ Complete rspec coverage of subtend string compat to date.
+
+commit 32db2e9a157cee24ae883b7b8fd563d98fc2dce5
+Author: Kev <kev@unknown>
+Date: Fri May 4 07:11:21 2007 +0000
+
+ Add loading of C extensions via require.
+ Stop grammar.c from generating every fricking time
+ Cleanup formatting on subtend
+ Add proper minispec tests for subtend
+ Remove old subtend test extension
+
+commit 851fbe6e587596fd074b4c99e42c43865118ae00
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri May 4 06:58:35 2007 +0000
+
+ converted (but not to the new new style) fixnum specs. fixed mini_rspec to rescue backtrace.show on MRI.
+
+commit 3e8deacb57ef80684281b1329778bc52681a8601
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri May 4 06:22:53 2007 +0000
+
+ converted module specs. added incompatible spec for const_defined?(Some::Class). made mini_rspec print backtrace on error.
+
+commit 3c1cc4ff4f6bf4fa28f65d9909a74f77f6524aa8
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri May 4 05:45:50 2007 +0000
+
+ converted math and exception. added two helper methods: should_be_close, should_include. I think spec_translator should handle converting these to 0.9.x syntax as soon as rspec runs.
+
+commit 28e3cdba63f2853b9e9a084f27ad764437830799
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu May 3 15:26:39 2007 +0000
+
+ converted float specs. added ignore for *.rbc on externals/rspec-0.9.1.
+
+commit 69ea5db15fb0562d8a4114d4e8ec54f2e19ad8fd
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu May 3 06:40:17 2007 +0000
+
+ converted range, nil, regexp specs. added ignore *.rbc on rspec dirs.
+
+commit 6cc364770406e4e04ef7baf2fdaab7425a7f5a6c
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Thu May 3 03:27:04 2007 +0000
+
+ * Converted Dir specs
+
+commit 5e39be7f97d5cd131b0cf564746d881245030f7d
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu May 3 03:04:24 2007 +0000
+
+ okay, rue insists that we use describe ... it now. (see spec_translator with rspec 0.9.1).
+
+commit 99f05b9d6572600ed0bf6a732048c1c4a2d2bb0b
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu May 3 03:00:06 2007 +0000
+
+ converted bignum specs. 100% pass on MRI.
+
+commit f9e4df4bdb721eb32c4ac7e5abd4a646daaf20d2
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu May 3 00:06:19 2007 +0000
+
+ fixed mini_rspec aliases for specify, etc. to work around exception: No method 'alias_method' on an instance of Object. (NoMethodError)
+
+commit 89d3ca0681816afd389907cbb52f7e0372dbecef
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed May 2 07:13:56 2007 +0000
+
+ * Converted spec/core/ binding, class and continuation
+
+commit 086f889a9bae2e40dd6a8b1ffa80113070f3ad46
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed May 2 04:22:12 2007 +0000
+
+ * bin/specrunner is a small bash kludge for running mini_rspec over
+ a directory (recursively) or a single file
+ * Rakefile allows diffing a current spec run against a base run to
+ easily see all changes among the thousands of specs as well as
+ storing a base run
+ * specrunner produces decent output for the minimal spec output
+ from mini_rspec
+
+commit ba89b2c015d2754b6470b324a013f018d8202cfe
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Tue May 1 22:57:22 2007 +0000
+
+ * Converted spec/core/array_spec.rb to mini_rspec
+ * Reviewed and fixed some specs for Array
+ * Spec-style output to mini_rspec (manual comment/uncomment to switch)
+ * should_raise for slightly more natural exception verification
+
+commit 0330bcc23fa1609db291cd382cb13fc168ec5bf3
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Tue May 1 22:44:40 2007 +0000
+
+ * Implement correct behavior for String#split when called with a zero-width Regexp
+
+commit c8e806e2dafd237fa8117ead21553a195900613e
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue May 1 02:29:35 2007 +0000
+
+ converted symbol_spec. 100% pass.
+
+commit 76e31065df70ebc5790fdb604f1b07d28ffaa81c
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue May 1 02:19:33 2007 +0000
+
+ commented out specs that cause rubinius to hang. String#delete and #tr (and methods that are implemented in terms of these).
+
+commit 2ae8aea13161a71c3fb4ca8e0486acd55c897579
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue May 1 01:17:14 2007 +0000
+
+ converted core/string_spec to regular syntax. added mspec_helper.
+
+commit ff84053991295b259ca8b1c17adff95f5d471961
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Apr 30 22:31:26 2007 +0000
+
+ converted false_spec. added svn:ignore *.rbc on all spec dirs.
+
+commit 3fc864ba235c56118e1db66dbf9537d6ff8c0c5f
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Apr 30 22:00:12 2007 +0000
+
+ Let the breakage begin. Converting all specs to use mini_rspec with 100% compatible syntax with rspec proper. usage: 'USE_RSPEC=1 spec spec/core/false_spec.rb' for any specs that use example {} method. spec spec/core/true_spec.rb OR ./shotgun/rubinius spec/core/true_spec.rb for converted specs.
+
+commit 4c6c7f406d0e5504a72c52b1ae5339a9dba36865
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Apr 29 17:28:11 2007 +0000
+
+ added setup method and print to STDERR and STDOUT to support a shell script runner.
+
+commit 958a0e9b1a066cf2d825b960b66788b05c928f36
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Apr 29 08:26:09 2007 +0000
+
+ mini rspec implementation. example {} method is dead.
+
+commit a323b3d424f226322cf20e65e87f8a4e962ed497
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Apr 29 03:23:17 2007 +0000
+
+ Added Array#first, Array#last that take numeric args to core. Added a bunch of failing specs for Array#[]. #first and #last are implemented using #[] so several of the specs for those fail, but the implementation of #first and #last was tested in MRI.
+
+commit 3897c943069582b1e5d1649a097bd77c0c895e0a
+Author: Hurdlea <hurdlea@unknown>
+Date: Thu Mar 29 13:51:13 2007 +0000
+
+ * Support for Floats in Sprintf
+ - Sprintf is still missing support for unsigned twos complement
+ * String#% now implemented
+ * Fixed a minor issue in the Rakefile
+
+commit 5ed87ff88793f8d44cfe34b443eb032d27dc2a4c
+Author: Hurdlea <hurdlea@unknown>
+Date: Thu Mar 15 05:08:34 2007 +0000
+
+ * Added Sprintf core module and classes for string % and Kernel
+ - Still needs some work with floats and requires a couple of
+ primitives to achieve this.
+ * Fixed a small issue with String#Index(Fixnum, offset)
+
+commit 982c09b15710429fc97d8d43d9f24a3a0badb6d5
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Mar 10 22:35:18 2007 +0000
+
+ Fixed array spec for #sort which improperly depended on the accidental order in which two elements of the array were being compared.
+
+commit 32fe004da7f35e9b7dcc96f8e57e1acb37164748
+Author: Hornbeck <hornbeck@unknown>
+Date: Sat Mar 10 06:38:23 2007 +0000
+
+ Two tests in the ObjectSpace spec. It was bare and needed love.
+
+commit e1530bb1999118bf88037dccc27d78f54bdbe5e4
+Author: Tlockney <tlockney@unknown>
+Date: Sat Mar 3 23:28:27 2007 +0000
+
+ updated all rspec exceptions. exception specs all pass in MRI. still a few rubinius exception spec issues
+
+commit 2c278533cbfe0efc7076d2c947323640be5f207a
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Mar 3 21:29:55 2007 +0000
+
+ Committing tlockney's additions to core/exception_spec.rb. These pass on MRI but illustrate areas to fix on rubinius.
+
+commit fd8993c0996e4524440a6572c45dad4ab112fb2f
+Author: Hornbeck <hornbeck@unknown>
+Date: Fri Feb 23 15:58:33 2007 +0000
+
+ committing Aki Reijonen's Hash patches for hash.rb and the hash_spec.rb. Also included is Thomas Lockney's exception_spec.rb patches.
+
+commit 08e6d924b8c0175242c1c40322ed3e45855a86c2
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Feb 18 07:48:46 2007 +0000
+
+ Altered Object#instance_variable_[get|set] rearranging flow control. Added specs for instance_variable_[get|set] for Array, IO, String.
+
+commit 2a2385413c03f21dfc038e110f46a7a3bd2fc9c7
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Feb 18 06:05:47 2007 +0000
+
+ Increased time out value when running rspec error report. Minor changes to text in class specs.
+
+commit bd0d7fcf72546a0a3a5a6a59b1a6f2aadd8e4262
+Author: Mae <mae@unknown>
+Date: Sun Feb 18 03:53:00 2007 +0000
+
+ Integer#bits for future refactoring of shift
+ * added Integer#bits which calculates minimum bit storage required for (signed int) form of the Integer
+ * spec'd it too
+
+commit 4e6b39d5e69c04d92ceac76ce5a5bd792fb65f39
+Author: Mae <mae@unknown>
+Date: Sun Feb 18 02:55:55 2007 +0000
+
+ Object#extend-a-gogo
+ *Fixed Small bug in rubinius_target where failures wouldn't be reported
+ *Implemented Object#extend and changed math.rb to use it accordingly
+
+commit 5472c10579cef38f9f28c904710246509633a040
+Author: Mae <mae@unknown>
+Date: Sun Feb 18 01:21:11 2007 +0000
+
+ A great Time patch from John Hornbeck <hornbeck@gmail.com>:
+
+ A more complete Time diff. This includes many of the instance methods for Time and a new primitive for usec. This diff also includes some failing specs as I went ahead and added the specs for the rest of the class methods. Also included is the constants for Time.
+
+ Keep the good work coming John!
+
+commit 83ab11e0ab6679b1c9eefc5095d3f20af9a61661
+Author: Mae <mae@unknown>
+Date: Sat Feb 17 23:26:33 2007 +0000
+
+ Patch from Aki Reijonen <aki.reijonen@gmail.com> without the Float.induced_from part
+
+ Summary of the changes:
+
+ ** Added methods **
+
+ Numeric#integer?
+ Numeric#div
+
+ Integer#to_int
+ Integer#round
+ Integer#truncate
+ Integer#next
+ Integer#succ
+ Integer#integer?
+
+ String#slice!
+
+ Object#to_a
+
+ Kernel#Array
+ Kernel#String
+
+ ** Fixed methods **
+ Float.induced_from
+ - Now return the passed object if it's an Float insted of calling #to_f
+
+ ** Removed methods **
+ Fixnum#div was broken, the end result should be converted to Integer,
+ not the number passed as a argument. (superceded by Numeric#div)
+
+ --
+ Aki Reijonen
+
+commit 243a4e9ba46149b8ba39c7238f8ff3d5f267689e
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Feb 17 06:17:44 2007 +0000
+
+ Ditched all the instance vars in array specs since we've got locals now.
+
+commit be5363e22e04b8baf26cb4abd8a8a67e7dd3cc0c
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed Feb 14 01:05:49 2007 +0000
+
+ Fixed * varargs to work in method definitions. Currently still
+ does not work as the single named parameter (foo(*a)). This
+ means that lib/bytecode/encoder.rb now compiles under Shotgun.
+
+commit 3bb810688e848c90d5c20929c630f36a32796d2d
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 13 18:42:09 2007 +0000
+
+ Added Object#instance_variable_set and specs.
+
+commit 54392c99dc3db5b58c85799416cc528c60b12533
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 13 18:25:24 2007 +0000
+
+ Added Object#instance_variable_get and specs. Uncommented Math module constants specs.
+
+commit 84267901502ca1e8e8b13afa0e3a16e0cdc8e493
+Author: Mae <mae@unknown>
+Date: Sun Feb 11 10:30:13 2007 +0000
+
+ * Primitive Specs
+ - Added spec for bignum_div (and fixed a problem where it would always fail)
+ - Fixed primitive_spec_helper (because it broke the old specs last time)
+ - Removed magic method chaining because it sucks
+ - DISCLAIMER: primitive specs atm just test functional things, _NOT_ stateful side-effects
+ - We can do this properly once rubinius can run rspec
+
+ * SIRB
+ - Made it so that => wouldn't get printed before the command prompt if you typed "exit"
+ - Made Kernel#p, Kernel#puts, Kernel#print return nil (like MRI)
+ - added #!shotgun/rubinius to top of sirb and symlinked it to bin/sirb.rb as well (for convenience)
+
+ * Removed unused local from __loader
+
+commit efce7d8a56748ab1831a34d21b8c92ff8b2eb977
+Author: Mae <mae@unknown>
+Date: Sun Feb 11 07:25:51 2007 +0000
+
+ Moved math to math_spec; added object_spec for primitives; made primitives_spec_helper maybe too smart? -- they chain methods on to the remote target
+
+commit 087a5e5a6e89e4a53a39e025ffe08d21e96b8f6e
+Author: Mae <mae@unknown>
+Date: Sun Feb 11 05:51:30 2007 +0000
+
+ * Made rubinius_target and example much more helpful
+ - backtraces are shown on failure now
+ - you can do this: example { 1 + nil }.should_raise(TypeError) and it works :) (with bt and all)
+ - injected some extra code in example snippets so try(exc) syntax still works
+ - Float, Nil, True, False specs all pass 100 %
+ - made rubinius_target make use of @src (used in bignum)
+
+ * Made Kernel.Float() and Kernel.Integer() behave appropriately like MRI _with_ the exception of Float() also checking for to_i method
+ - Integer(nil) => 0 and Float(nil) => 0.0
+ - lots of spec coverage
+
+ * Numeric#coerce was slightly tweaked to use new Float() and Integer() behavior
+ - Specifically complains about other being nil (so 1 == nil doesn't work)
+
+ * Made Float.induced_from() more anal retentive (only accepts core Fixnum, Bignum, Float types like mri)
+ - specs cover it
+
+ * Fixed infinite loop on Bignum#& and moved & out of Numeric into Integer (Float doesn't have &)
+
+commit eadf1ead754d3dbfaf703c205f6f5e8f4dc5c430
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Feb 11 03:00:25 2007 +0000
+
+ Put object flags values into a single include file. Added Object#taint, tainted?, freeze, frozen?. Neither of these states actually effect execution yet. Fixed up Object specs.
+
+commit 38e7f757e67b4ec985835e0e93ba4d32bbee5ca4
+Author: Mae <mae@unknown>
+Date: Sat Feb 10 23:57:37 2007 +0000
+
+ - Created specs for math_sqrt primitive (and created spec/primitives/math_spec.rb)
+ - Tweaked primitives_spec_helper to properly transport NaN's to testing environment
+ - Removed non-needed self parameter from math_sqrt c function
+
+commit a4267a136d7f0bf7f92421fcebd8011600a1d92e
+Author: Mae <mae@unknown>
+Date: Sat Feb 10 22:29:46 2007 +0000
+
+ Float.induced_from love
+ - made Float.induced_from work for any to_f item (controversial whether this should be done in Kernel.Float() or not)
+ - apparently this fixed some float failures
+ - made Float.induced_from safer because it now complains if to_f returns a non-float
+ - wrote specs for new induced_from behavior
+ - try (spec_helper) needs to be investigated, manual running of the premises of 'Float divmod should raise FloatDomainError if other is zero' show this to be a spec that _should_ pass
+
+commit 65a4e8abfc7f690456e4f44e7e4cc38911288516
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Feb 10 18:54:15 2007 +0000
+
+ Added spec files for the rest of the core classes documented in Pickaxe book. Add simple class hierarchy specs for exception classes.
+
+commit c7a2f68c36dd95f51af88e8fa62b24b71d68578a
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Feb 10 17:29:46 2007 +0000
+
+ Commit of scoopr's Math module beginnings. Thanks scoopr.
+
+commit b1e8d150460f2ae9ea2e5ef87d0df3b705c1d0d6
+Author: Mae <mae@unknown>
+Date: Fri Feb 9 08:54:25 2007 +0000
+
+ Bignum primitive specs
+ - Added spec and changed to metaprogramming style for primitives: bignum_add, bignum_compare, bignum_equal, bignum_and, bignum_divmod
+ - fixed bug that bignum_divmod spec found where bignum_divmod would always fail on divide by zero GUARD
+
+commit 0487a39ec9995af8eb5a8dff5ec64492261852e7
+Author: Mae <mae@unknown>
+Date: Fri Feb 9 07:48:56 2007 +0000
+
+ Primitive Spec Sexiness
+ - Added spec and changed to metaprogramming style for primitive fixnum_to_f
+ - Made usage of run_primitive(:add, 1, 5) more sexy i.e. 1.prim.add(5)
+ - converted fixnum spes to use sexiness
+
+commit 95fa48f29eaa7e3f10ccd63d385fb3f582f57eea
+Author: Hurdlea <hurdlea@unknown>
+Date: Fri Feb 9 01:36:14 2007 +0000
+
+ * Added String#delete, delete!, tr, tr!, tr_s, tr_s!
+ - String#count and squeeze to follow ...
+ * String#<< now accepts Fixnums
+
+commit 017bdc57602e2e5d55705de070c07edba46a347f
+Author: Mae <mae@unknown>
+Date: Thu Feb 8 09:23:55 2007 +0000
+
+ - removed noop from primitives (it does nothing)
+ - removed noop primitive spec
+ - changed CPU::Primitives.name_to_index to offset by +1 (to leave room for special 0 value)
+ - still having same closed parens issue with spec:primitives:
+ syntax error, unexpected $end, expecting ')' (SyntaxError)
+
+commit 18a3347bb32d8ac5269438376f0100ecce2c9e73
+Author: Mae <mae@unknown>
+Date: Thu Feb 8 08:20:14 2007 +0000
+
+ - made shotgun/lib/primitives.rb have less dependencies
+ - fixed bug where if a false was popped of the stack it wouldn't be recognized as an argument in primitives_spec_helper (nil will only do this now)
+ - fixed regression in primitives_spec_helper where the proper code wasn't showed when shotgun crashes
+ - noop_spec works again
+
+commit 16b08e446b69344da1edbc1f793e0161deac8e6c
+Author: Mae <mae@unknown>
+Date: Wed Feb 7 23:59:14 2007 +0000
+
+ More Primitive Goodness, Conform to unified rspec standards
+ - Added specs and changed to new metaprogramming style for the following primitives: fixnum_and, fixnum_or, fixnum_xor, fixnum_invert, fixnum_neg
+
+commit cb2ac85b45a41a63100cac673919ad8db1f93f43
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed Feb 7 23:16:35 2007 +0000
+
+ Basic specs for Symbol literals.
+
+commit 3ab7aced51f3a63c8f76706a2f159d0d5753dc64
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Feb 7 20:35:27 2007 +0000
+
+ Changed Fixnum primitives specs to be in a single file, spec/primitives/fixnum_spec.rb. Added back the alternative example of writing specs for others to evaluate or use. Updated the wiki specs page to lay down the law on spec files. Kindly follow it.
+
+commit cf16d691990f43f5bf8807bbef2ba1876892be57
+Author: Mae <mae@unknown>
+Date: Wed Feb 7 18:27:15 2007 +0000
+
+ Autotest, C warnings cleanup, and some primitive_spec usage cleanup
+ - Added Autotest Facilities for primitive bin/autotest/primitives
+ - need to gem install zentest to use this (and some diff gem i can't remember)
+ - Removed ugly require statement from cpu/primitives it was causing annoying ruby errors
+ - Added missing prototypes to cpu.h and regexp.h (primitives.gen was complaining)
+ - Localized bt and bt_size variable declarations to where they would be included by the preprocessor to make more warnings go away
+ - Added newlines to the end of numeric.c, numeric.h, float.c
+ - Used one of brixens suggestions (injection of primitive spec helper automatically)
+ - Removed extraneous primitive helper inclusion in each spec
+
+commit f4bbce9d761d27e1381b95a4ff6076e85577074d
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Feb 7 16:56:21 2007 +0000
+
+ This shows an example to 'fix' mae's rubyesquely-challenged (bluntly, ugly) primitive specs. Also, there should be one spec file for a group of related contexts. In this case, the group is the class Fixnum. So, mae, fixnum_spec.rb, NOT fixnum_xxx_spec.rb. Sorry. Cry tyrany, weep and gnash thy teeth, howl in protest, but please fix it. This is non-negotiable. Thank you and good work on the primitive specs. :)
+
+commit e5f6215824a40beb0ca678575596bd06afa8dd3a
+Author: Mae <mae@unknown>
+Date: Wed Feb 7 09:54:54 2007 +0000
+
+ - Added specs for primitives: add, sub, fixnum_mul, fixnum_size, fixnum_div, fixnum_modulo, fixnum_divmod, fixnum_to_s
+ - Updated primitives to new metaprogramming style: sub, fixnum_mul, fixnum_size, fixnum_div, fixnum_modulo, fixnum_divmod, fixnum_to_s
+ - Changed wording in a couple primitive spec files to be more explicit
+ - Made reporting by primitive_spec_helper more helpful when shotgun crashes from injected code
+
+commit 3032c6bd869a04c1517508850f94119975c36e54
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Feb 7 02:26:47 2007 +0000
+
+ Fixed up String#to_i a bit; added a bunch more specs for it.
+
+commit d8a24ffa8d9983a85b0f03784a89bfa667af1615
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Wed Feb 7 01:46:30 2007 +0000
+
+ Added very basic set of specs for assignment and multiple assignment semantics.
+
+commit edb7c82523b36b26e24437de42fd2638eef1653f
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 6 19:02:46 2007 +0000
+
+ Added specs for and methods CType#isalnum, isdigit.
+
+commit e84ba1b12c51331d00bdd06684dcff96ea229322
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 6 17:30:55 2007 +0000
+
+ Added spec/shotgun/bytearray_spec.rb. Added spec for ByteArray#[], []=. Modified various string methods to use BA#[], []= instead of get_byte, set_byte.
+
+commit be9589cc47cbf35edd94ca22407de4b1527a3fdb
+Author: Mae <mae@unknown>
+Date: Tue Feb 6 11:26:31 2007 +0000
+
+ Tweaks to primitive metaprogramming and addition of noop spec
+ - Added types 'qnil' 'qtrue' 'qfalse' to be used in primitive metaprogramming
+ - Added spec for noop primitive
+ - Added run_asm method to primitives_spec_helper for those tricky tests
+ - Converted noop primitive to new metaprogramming style
+
+commit e31f1af903dd8dd31427e34a718b30f5c63af8df
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 6 10:33:00 2007 +0000
+
+ Some fixes to String#to_i and additions to specs. Added String#oct and hex.
+
+commit 2a157827bd72b6c7ce8a025928cdd9d7f2f8d00f
+Author: Mae <mae@unknown>
+Date: Tue Feb 6 10:18:16 2007 +0000
+
+ moved equal and compare to use new primitive technique
+ - also updated equal_spec to ask for ArgumentError instead
+ - uploaded new rba *glares at brixen*
+
+commit 771d0fede3086ce58d225ac4001ea0934f3bb0e3
+Author: Mae <mae@unknown>
+Date: Tue Feb 6 09:33:03 2007 +0000
+
+ ARITY macro raises ArgumentError directly from the primtive now and made specs pass
+ - Made ARITY macro raise an argument error exception instead of just ambiguously failing
+ - Made _ret return TRUE on arity failure (exception directly raised)
+ - Moved GUARD and POP macros to shotgun/lib/cpu_primitives.c where they belong (localized)
+ - Removed side-effect printf in cpu_raise_arg_error since stack trace is fine now
+ - Tweaked primitives_spec_helper should_raise to work for all exceptions
+ - Made specs for equal/compare pass again (expect ArgumentError instead of PrimitiveFailure)
+ - New compiler.rba (update these ppl!)
+
+commit e89190c8fdc4a71c7b8cd9c8b873a63b9d1888c5
+Author: Hurdlea <hurdlea@unknown>
+Date: Tue Feb 6 07:51:08 2007 +0000
+
+ * Finished String#[]= for string index
+ * found odd bug with spec where string[1,2]="foo" is not interpreted correctly
+ changed methods to use send(:[]=, ... and the tests pass
+
+commit c6e1bb68e930a537bd51d77afd37cdc8b5d62d31
+Author: Hurdlea <hurdlea@unknown>
+Date: Tue Feb 6 07:18:15 2007 +0000
+
+ * Added String#[]= slice functionality
+
+commit e405d4f5f32fd8192c435b3488f394b2635c7db7
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 6 06:37:31 2007 +0000
+
+ Added String#chomp[(bang)].
+
+commit ff48a6c333f34c1b1882c260db7145facce3d71f
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 6 06:00:56 2007 +0000
+
+ Added String#replace_if that calls replace if self != other else returns nil; Added upcase, downcase.
+
+commit f46d747eba82c215fa07b067a30f2a2e8868d284
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 6 05:31:13 2007 +0000
+
+ Implemented String#reverse directly rather than with String#<<. Modified some string specs for [lr]strip but forgot to commit them earlier.
+
+commit d3b0e71e810a985f3b8f2e5f5c7d5c4619f151f9
+Author: Hurdlea <hurdlea@unknown>
+Date: Tue Feb 6 03:00:28 2007 +0000
+
+ * Added NilClass specs to detect NilClass coercion
+
+commit c570ca475cabeb3fcfcca26d4c57b8e57f6606b4
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Feb 6 02:01:19 2007 +0000
+
+ Added module CType mixin for Integer to provide isspace, isupper and friends. Added specs for CType in spec/shotgun. Implemented String#capitalize[(bang)]. Moved ByteArray into it's own file. Updated various string specs and commented out temporarily index spec.
+
+commit 4694d1511e880e43dfccb3e3f5309f0920395ba0
+Author: Hurdlea <hurdlea@unknown>
+Date: Tue Feb 6 00:22:17 2007 +0000
+
+ * Fixed operation of Regexp#=~
+ * Updated Regexp spec for =~
+ * String#== now works correcly for duck typed objects
+
+commit 8e42aa9c789fcc9bc475d460e7158f2adcc8ab64
+Author: Mae <mae@unknown>
+Date: Mon Feb 5 22:46:21 2007 +0000
+
+ Added arity checking for primitives
+ -for use in primitives: #define ARITY(length) GUARD( (length) == num_args )
+ -for instance if i have a primitive that takes one argument (self + arg) i put ARITY(1) at the top
+ -changed specs with regard to arity accordingly
+ -made block_given conform to the "self rule for primitives" by padding Qtrue where self would be
+ -fixed block_given? to pass the right arity (0) in the compiler
+ -specs for compare and equal pass now
+ -added primitives_spec_helper (forgot last time)
+
+ NOTE: Binary .rbc compatibility is broken now since there are arity checks done on block_given?
+ -the rba's i uploaded should be fine but if they arent...
+ do find -type f | grep .rbc | grep -v .svn | xargs rm
+ then rake build:rubinius
+
+commit 2d5c9bc3170bf959390627def10c0208088b48ee
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Feb 5 22:39:08 2007 +0000
+
+ Added Integer#isspace and spec in spec/incompatible. Added spec/incompatible/string_spec to describe behavior of stripping runs of whitespace and nulls from end of a string. Added or modified String#lstrip, lstrip(bang), strip, strip(bang), rstrip, rstrip(bang).
+
+commit d4b07b06ca85543423a308f12b82ae4671bdd0c2
+Author: Mae <mae@unknown>
+Date: Mon Feb 5 21:01:59 2007 +0000
+
+ -split out common primitive testing functionality to primitives_spec_helper.rb
+ -added spec for primitive "equal"
+ -again primitive specs are rake spec:primitives
+
+commit c1a7896f24e018df13af7f0d3d60db9f461130a5
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Feb 5 20:58:21 2007 +0000
+
+ Added that Module#include passes off to append_features. Added Module#include that takes multiple args later in the bootstrap sequence. Added specs for include and append_features.
+
+commit d407ecab13722599b75fecc20bdebd86c9f76fa6
+Author: Mae <mae@unknown>
+Date: Mon Feb 5 20:48:02 2007 +0000
+
+ Misc Changes to Tweak primitive specs
+ -Added spec to test arity restrictions of compare
+ -Fixed bug where should_raise for primitives was not catching the error condition
+ -Changed wording of some specs to be english rather than engrish :)
+
+commit f68ad63065002d4a3c9a0742770da4a112780aa7
+Author: Mae <mae@unknown>
+Date: Mon Feb 5 20:02:24 2007 +0000
+
+ - Remove printf from cpu_raise_primitive_failure so that the screen doesn't get littered
+ - Created PrimitiveSpecHelper and a "primitives" spec subdirectory
+ - Added rake task spec:primitives
+ - Added compare_spec as an example
+ - New rba's
+
+commit f997d3791099912001d09a427f24252182ba1d6c
+Author: Hurdlea <hurdlea@unknown>
+Date: Sat Feb 3 08:10:48 2007 +0000
+
+ * Added MatchData#values_at
+ * Fixed implementation of MatchData#select
+ * Updated specs for MatchData#values_at, select
+
+commit 4f8301aeb3a5a296a64b887b0f164ca02be2a71f
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Feb 2 17:00:10 2007 +0000
+
+ Added specs for and empty module methods private, protected, public as a first approximation to allow code that uses them to not choke. Added String#match.
+
+commit 15c3678ddcc365891fd92cc9cd33eb22308916e8
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Feb 2 10:43:58 2007 +0000
+
+ Committing Adam Ritter's patch to recognize 'for i in ...' expression, and associated spec. Uncommented line in float_spec.
+
+commit 370d7a955bf6e41c4ea7cf0f9217128ae7a72fd4
+Author: Hurdlea <hurdlea@unknown>
+Date: Fri Feb 2 07:06:22 2007 +0000
+
+ * Added MatchData#inspect, select, to_a, size, to_s
+ * MatchData#[] is now more compliant - behaves more like Array#[]
+ * Added Regexp#hash
+ * Added Regexp#hash spec
+
+commit b496d50c0ebf7d5c523efe2ef5383dd8043aa3f0
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Fri Feb 2 00:36:37 2007 +0000
+
+ Added specs for Dir and modified rubinius_target to allow
+ specs to change directories safely.
+
+commit 6ddf4051f3a6be7076e947bf3eccbc5dd9a7803f
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 19:11:14 2007 +0000
+
+ Fixed Float#divmod, returning 0 guard on primitive, raising FloatDomainError rather than ZeroDivisionError. Fixed Float#% when other is zero. Spec try helper doesn't yet work with rubinius_target
+
+commit 679f3fbe54960a690f4e41e1403fdc8f50c0f346
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 18:36:44 2007 +0000
+
+ Added more zero division behavior specs.
+
+commit b4d739a7cb68d6f82d657b69aee00923e0bfdbb4
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 18:12:02 2007 +0000
+
+ oops, damn keystrokes. Previous commit msg should just include Fixnum. This change points out a problem that I'm not sure about: 1.quo(0) => Infinity in irb and run from a file, but in the spec I get zero division error. wth?
+
+commit 4e24fe43a7d6c55a53880a1c347e836f12937ed4
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 18:03:13 2007 +0000
+
+ Added more specs around zero division behavior for Float and Fixnum.
+
+commit b8f412ee2bf3701acd211372d28ec596d6858ac8
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 18:01:44 2007 +0000
+
+ Added more specs around zero division behavior for Float and Fixnum.
+
+commit 17a17e3008422bab9e91f8464d1ce2823c13ce78
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 17:51:47 2007 +0000
+
+ Added try spec helper method for spec'ing things that raise exceptions. Added more Float specs that describe division by 0 behavior.
+
+commit 2c2bfc3663a34fbf4fd70a5787236ec8b9a87024
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 17:22:39 2007 +0000
+
+ Added spec for Float#% when other is zero to show current implementation is broken.
+
+commit d1ddd71d5bd45df0c16651ecad2db3c1b75d90f8
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Feb 1 17:06:56 2007 +0000
+
+ Reverted mae's breakage to Float. seriously mae: you did NOT run the float specs and you did NOT write new specs for the behavior you were changing so you did NOT understand what you were doing. As a good CS student, you can negate the above to know what you SHOULD do. ;) Please, WRITE and RUN your specs.
+
+commit b2e08a170d1ab222d67d8767fa880a5e21c5bf74
+Author: Mae <mae@unknown>
+Date: Thu Feb 1 10:53:48 2007 +0000
+
+ know when to shoot your baby in the crib -- cleanup outdated unused code
+
+commit aac75dd658c96cf930852d86dbc79b66830bace5
+Author: Eero Saynatkari <eero@kittensoft.org>
+Date: Thu Feb 1 09:12:03 2007 +0000
+
+ Improved specs for Hash.[].
+
+commit 40f637f2685e969f097fbbb2ffa3f0173e6f9866
+Author: Mae <mae@unknown>
+Date: Thu Feb 1 02:44:14 2007 +0000
+
+ Fixed my pure ruby Numeric#floor and Numeric#ceil methods
+ - Please smash your c primitive brix BWAHAHA
+ - Also implemented eql? for float and now all 32 float specs pass
+ - Added some edge cases for ceil/float that were not previously covered in specs
+
+commit 5cc6f6b6068e945c6f5896370ee20567e57122e7
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 31 11:24:23 2007 +0000
+
+ Added Float#round. We now have 32 of 32 float specs passing. Please confirm on your platform.
+
+commit 9b902a80a008120a86ae18d4abff04d42efefc8f
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 31 06:22:10 2007 +0000
+
+ Folded in coerce specs.
+
+commit 09e61132d5b9e9b08d27f2f51db9580808bb370e
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 31 03:22:23 2007 +0000
+
+ Created spec/incompatible for specs that show where Rubinius is incompatible with other implementations. Added bignum_spec and fixnum_spec to incompatible dir. Under MRI, Bignum.coerce(Fixnum) => [Bignum, Bignum] whereas Fixnum.coerce(Bignum) => [Float, Float]. Since Bignum should be a seamless extension of Fixnum, this behavior in MRI seems less than consistent. Under Rubinius, mixed Fixnum and Bignum promote to Bignum uniformly, and this makes much more sense. There are other places where Rubinius implementation may deviate from MRI, so spec/incompatible is for describing those behaviors. Updated coerce specs.
+
+commit cb52bb9633d0e323d2f7d6c90879fb7decfea7d7
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 30 10:44:46 2007 +0000
+
+ Added Numeric#coerce primitive. Reimplemented a number of primitves and methods on Fixnum, Float, Bignum to use Numeric#coerce rather than implementing knowledge of one another all over the place. Folded in mae's coerce specs. There is currently a (desirable IMHO) incompatibility in Numeric#coerce in that Bignum.coerce(Fixnum) == Fixnum.coerce(Bignum). There are a lot of other methods that need to be reimplemented using Numeric#coerce. Also, bignum_compare needs to be implemented (just returns 0 atm).
+
+commit e1aa382f2d596a73ef20dfde4184af7a721724e9
+Author: Mae <mae@unknown>
+Date: Tue Jan 30 00:26:11 2007 +0000
+
+ added specs for coercion of Fixnum, Bignum, and Float
+
+commit bd292d64a511eba51ea1569870bcf0fa365c903d
+Author: Cabo <cabo@unknown>
+Date: Sun Jan 28 21:05:10 2007 +0000
+
+ include yesterday's failed cases
+
+commit 7cac7f32e5c80e78aa75dfed7f4822e65d1ab4df
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 28 08:08:12 2007 +0000
+
+ committing rue's continuation specs. doomo arigatoo.
+
+commit f542b93031f8982daa13777d2eada81068e96ad5
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 28 07:03:46 2007 +0000
+
+ committing rue's class specs. thanks rue!
+
+commit 319b6f194d3c699a75de8da2ba3b53b8a4feffb1
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 28 04:49:01 2007 +0000
+
+ Commiting rue's binding specs.
+
+commit d8326b1321cc09c0aa64f441d2a81df6735603fd
+Author: Cabo <cabo@unknown>
+Date: Sat Jan 27 00:02:33 2007 +0000
+
+ remove superfluous p from "& should create an array with no
+ duplicates" (which now passes)
+
+commit 7d3baf10a79c1500e660fe5566ba8f3107d5a826
+Author: Hurdlea <hurdlea@unknown>
+Date: Thu Jan 25 05:43:50 2007 +0000
+
+ * Added MatchData specs
+
+commit 2d9966c9c30e541c18ac77ca646a1af41daf702e
+Author: Hurdlea <hurdlea@unknown>
+Date: Thu Jan 25 05:42:44 2007 +0000
+
+ * Added Match2 and correct Match3 in compiler.rb
+ * Added alias String#to_str
+ * Tweaked a few regexep specs for string return types
+ * Fixed MatchData#length so it uses Tuple#fields to get the no. items
+
+commit 0d9f9e21c2a268e0710c963c745f07d494e2ab1f
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 24 21:43:17 2007 +0000
+
+ Commiting zimbatm's update to exception_spec.
+
+commit 037d8b29872f1c4a81108a0713afd78cbdf9b484
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 20 04:03:20 2007 +0000
+
+ a few more tweaks to get string specs to execute with rcompile and shotgun.
+
+commit cfe7a6b4c87ac3ffccaeb7e70b9e6c386054e052
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 20 03:49:01 2007 +0000
+
+ added parser dir under spec. added parser/symbol_spec.rb to capture parsing a complex symbol like :' for one or two', which rcompile and shotgun choke on at the moment. removed this from core/string_spec because it crashes shotgun and makes it impossible to run all the specs.
+
+commit d39040ab1563f063192a3835723cfbae7bf147cb
+Author: Cabo <cabo@unknown>
+Date: Fri Jan 19 23:45:52 2007 +0000
+
+ lib/kernel.rbc is no longer a required (or wanted) command line argument
+
+commit 4774788e0ae9b24b3ff0b769aede0ba2de3f00b1
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 19 21:05:10 2007 +0000
+
+ added correct guard on Array#first to return nil when array is empty. added specs for #first and #last to describe this behavior. Thanks to cabo for finding this.
+
+commit baf1453678c9906c65b2f7c82bdb0e179e22d1b8
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 19 02:49:02 2007 +0000
+
+ added some minor changes to structure and wording of language/expression_spec. removed array and defined spec from language directory since they were added to language/literals directory. renamed several spec files to follow naming conventions.
+
+commit 7a24923ab9b79b226b6d8831e834ab509d5d2b76
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 19 01:27:10 2007 +0000
+
+ committing zimbatm's patch to language specs. super nice and thank you. please give zimbatm a commit bit!
+
+commit 9cd8c779a88f48604733afbe4357b7101a487669
+Author: Vic <vic@unknown>
+Date: Thu Jan 18 22:20:34 2007 +0000
+
+ Added Proc.given, the analog of MethodContext.current
+ Proc.given obtains the proc given to the current MethodContext.
+ Later will be able to get a Proc from a given Binding.
+
+ Original author: Victor Hugo Borja <vic@rubyforge.org>
+ Date: 2007-01-18 16:16:06+00:00
+
+commit 50c42413d33951397a46edb55ca910a2e8fb87e6
+Author: Vic <vic@unknown>
+Date: Thu Jan 18 21:34:29 2007 +0000
+
+ No output is available for specs if the returning value is a Numeric or Symbol
+ When the :example execution on shotgun evaluates to a Numeric or Symbol, no method
+ :stdout is added, because these object do not have singleton-classes on MRI.
+ If you really need both, stdout and a Numeric/Symbol, your evaluation may lead to
+ an array containing that Numeric/Symbol.
+
+ Also saved MRI from getting eval errors in cases like the following:
+
+ example do
+ class A; end
+ A.new
+ end
+
+ This leads to the following being evaled by MRI: [ #<A:0xb7a69c8c> , stdout]
+ which causes an error because of #<A:0xb7a69c8c> being invalid ruby syntax.
+ This patch fixes this situation by converting #<A:0xb7a69c8c> into "#<A:0xb7a69c8c>"
+
+ Original author: Victor Hugo Borja <vic@rubyforge.org>
+ Date: 2007-01-18 15:23:55+00:00
+
+commit ec5bea103b4b96ecde54668e47ab9e10ac8ec4ee
+Author: Hurdlea <hurdlea@unknown>
+Date: Thu Jan 18 21:04:22 2007 +0000
+
+ * Added bitwsie operators to Fixnum & | ^ << >> ~
+ * Split the fixnum specs into coerced and non-coerced tests
+ * Added primitives to support fixnum bitwise ops
+ * Fixed a bounds tests in Interger#chr
+
+commit 238d7e0611e9198c28a5e0ebe684bc7f1f03bf0f
+Author: Vic <vic@unknown>
+Date: Thu Jan 18 20:11:58 2007 +0000
+
+ [rAdded specs for the new STDOUT support] Empty log message
+
+ Original author: Victor Hugo Borja <vic@rubyforge.org>
+ Date: 2007-01-18 13:44:19+00:00
+
+commit 859b26f38749f160a706ed9dbb8f2a80886e94ef
+Author: Vic <vic@unknown>
+Date: Thu Jan 18 19:37:03 2007 +0000
+
+ Allow to specs to test what is written to STDOUT
+
+ also added String#unindent on spec_helper to help make output heredocs more readable.
+
+ You can access both the evaluation result and the stdout produced, ej:
+
+ context "Rubinius target" do
+
+ specify "should allow to get the resulting STDOUT" do
+ example do
+ puts "hola"
+ puts "space is significant in this heredoc"
+ puts "unindent removes the first blanks found on the first line"
+ puts "on each of these lines"
+ puts "adios"
+ end.stdout.should == <<-OUT.unindent
+ hola
+ space is significant in this heredoc
+ unindent removes the first blanks found on the first line
+ on each of these lines
+ adios
+ OUT
+ end
+
+ specify "should allow to get the lines written to STDOUT" do
+ example do
+ puts "hello"
+ end.stdout_lines.length == 1
+
+ example do
+ print "bye"
+ end.stdout_lines.first.should == "bye"
+ end
+
+ specify "should allow to access the evaluation result along with STDOUT" do
+ result = example do
+ puts "ok"
+ Object.new.class
+ end
+ result.should == Object
+ result.stdout_lines.should == ["ok\n"]
+ end
+
+ end
+
+commit e17069925d139c93acec00161a7111e6c78d54bb
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 18 08:44:33 2007 +0000
+
+ converted shotgun-test/test_sexp to spec/shotgun/sexp_spec. thanks to Victor Borja's recent additions to rubinius_target, it was a breeze.
+
+commit 46e9a259bc2212dee1fa7efa8ead468e63970731
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 17 08:02:35 2007 +0000
+
+ filled in the rest of the documented String instance methods except #pack.
+
+commit dfd08d6536ea497cf86d06ca503206d54b19479d
+Author: Cabo <cabo@unknown>
+Date: Tue Jan 16 10:24:18 2007 +0000
+
+ A bit more array fun (and lots of FIXMEs)
+
+commit b1e50e43d8d79a5dbd82345134ecd4bdffc6d182
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 16 08:46:48 2007 +0000
+
+ and yet a few more string specs. these will asymptotically approach done.
+
+commit 4048d3dfa90a6de54ea2ed0aec2ec6adafb50b0c
+Author: Cabo <cabo@unknown>
+Date: Tue Jan 16 07:02:50 2007 +0000
+
+ I want to see what 'Shotgun has crashed' means, beautiful backtrace and all
+
+commit 0387baa914cb35c589c7872f7f98cf9f8ee10711
+Author: Cabo <cabo@unknown>
+Date: Tue Jan 16 02:19:45 2007 +0000
+
+ Fix Array#slice! bug workarounds
+
+commit c6b110b47667c5d6750492177492434f4c0446f8
+Author: Cabo <cabo@unknown>
+Date: Tue Jan 16 01:33:18 2007 +0000
+
+ add shift spec and fix String#strip so it works
+
+commit 19bcc086b7674f12e01f879a6ca83f3289feb770
+Author: Cabo <cabo@unknown>
+Date: Tue Jan 16 00:06:03 2007 +0000
+
+ Integer#chr should return a new string (spec)
+
+commit 5aa81499711ad5e57f5dfc03417f23705eb79b44
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 15 23:48:16 2007 +0000
+
+ a few more string specs.
+
+commit 8cd873e183c62b8929305ea54b9a437ca22ddb28
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 15 22:42:24 2007 +0000
+
+ committing Victor's define_method patch.
+
+commit cd04f4c570cd95fb869f025c4dac6e9342e2ba2a
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 15 22:02:23 2007 +0000
+
+ committing Victor Hugo Borja's instance_eval patch.
+
+commit a481142988d585bb8fa54e0186f5c9cf88ada8d9
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 15 20:13:03 2007 +0000
+
+ added a code method to mri_target and jruby_target to parallel the behavior of the code method for rubinius_target. now core/proc_spec.rb is passing with mri target.
+
+commit a4c621e8319349eda766f73ed9ca55f2a9323ac2
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 15 19:08:22 2007 +0000
+
+ checked in nicksieger's patch to spec_helper that enables specs to run on jruby, woohoo!
+
+commit 6b02aac6107b01258f85f9d15a77b498ad15e5b0
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 15 18:06:23 2007 +0000
+
+ checking in cabo's changes to target specs for jruby and rubinius. modified rubinius_target specs that compared paths to use should_match because a hash is used to generate part of the path.
+
+commit 6aa175d3367d76152476888ff1c52479530c56a2
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 15 17:57:25 2007 +0000
+
+ committing cabo's changes to remove heredocs from a number of specs. It is still possible to pass code as a source string to the example method. Use this if the block method is causing rubinius to choke on the ruby2ruby generated source. soon, soon, we'll have rspec running (I hope\!).
+
+commit 6679194f8e6afdbbb71f5213508bb81f12fdb2e7
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 14 17:28:06 2007 +0000
+
+ incorporated nicksieger's changes to mri_target removing needless requires. added jruby_target.rb and spec to parallel mri_target.rb.
+
+commit f573b9c16efccb92eec98d923831deafc7a3c809
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 14 08:10:24 2007 +0000
+
+ converted mri_target to use eval, yield to execute specs. converted some specs to new style. addressed issues with hash specs that implicitly relied on hash ordering, fixed numerous issues that result from loss of floating-point precision by using #inspect where necessary (more of these issues may arise in the specs on different platforms). added spec templates for documented String instance methods (many of which need to be filled in).
+
+commit 917cd03e5bee749d18d8d0c257381bca2362abbd
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 14 00:11:17 2007 +0000
+
+ checking in Alan Hurdles patch to allow running specific files, e.g. COMPILER=rcompile rake spec:core:array .
+
+commit 508eaacf9aaf67465a78ac53284ba6f06c3bcb3d
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 21:09:51 2007 +0000
+
+ added integer specs. these should be platform independent but other platforms may have some trouble with spec for 'chr' ;)
+
+commit 21463a87bac2121fa61c1c99927cdb039c724d89
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 20:37:37 2007 +0000
+
+ implemented the rest of the hash specs, this should cover the documented class, instance methods.
+
+commit 3656a95a1829b0be1a8b0d968e0a9e433ef9c847
+Author: Frederick <frederick@unknown>
+Date: Sat Jan 13 13:14:41 2007 +0000
+
+ Implements Fixnum#size
+
+commit ca38e49022f6bdf41b0e98409d3fec3528e59bfd
+Author: Frederick <frederick@unknown>
+Date: Sat Jan 13 12:54:30 2007 +0000
+
+ shotgun/string_spec.rb now follow new spec conventions
+
+commit 1b684385fe970f11a526e280d15c3f147a826886
+Author: Frederick <frederick@unknown>
+Date: Sat Jan 13 12:42:38 2007 +0000
+
+ language/expression_spec.rb and language/exception_spec.rb now use new spec style
+
+commit f62c2539a1eef27b356e4d809d76c4f9ddecd2a5
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 08:14:12 2007 +0000
+
+ new style specs for hash. numerous of these need to be implemented but there should be templates for all the documented class and instance methods.
+
+commit 28083a6e6dc89502d1c76e2a16f0003a589f01e0
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 08:12:37 2007 +0000
+
+ one more, bignum.
+
+commit 076aab00b795ff777c5ac11955130f12f69e1377
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 08:07:30 2007 +0000
+
+ new style specs for float, fixnum, symbol, string, object, file, module, regexp, range.
+
+commit 0161ab3527e91674eed4eeaad029eee654325155
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 07:39:26 2007 +0000
+
+ true, false, nil, enumerable specs are new style.
+
+commit bb11cce41a472606312eb0a62948c4a339f23dd9
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 07:27:05 2007 +0000
+
+ converted existing class and comparable specs to new style.
+
+commit 595b83a75044772136b83eaf84402ed73eb79da5
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Jan 13 07:08:14 2007 +0000
+
+ ladies and gentlemen, a huge round of applause and gratitude to headius for inspiration and help getting specs in a form that will easily run on MRI, JRuby, and Rubinius. Checking in the modified spec/core/array_spec.rb. The rest to follow. The mri_target is still using the sub-process method, but that should be superfluous now.
+
+commit ae75e76915432757be3c9a7126c2ee8c6656652c
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 12 08:13:29 2007 +0000
+
+ added a bunch more specs for array. two still need to be filled out. I think that covers all the documented class and instance methods.
+
+commit 8daf38e0f99eed3e42d654086a98e673d9855bef
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 12 01:14:35 2007 +0000
+
+ checking in more of cabo's changes to kernel/core/array.rb and array specs.
+
+commit 0a349583aba629748d5e85de0ede6f38730512f1
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 12 00:57:22 2007 +0000
+
+ checking in cabo's changes to array and array spec.
+
+commit 052512fea9b74e532ef6b68612c81061ad84e4f2
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 11 05:16:47 2007 +0000
+
+ finished Bignum specs for documented instance methods.
+
+commit 7f4786c85b2e0e95abc2728492ed1a7424d01dbe
+Author: Frederick <frederick@unknown>
+Date: Wed Jan 10 23:44:34 2007 +0000
+
+ Added File.mtime, File.atime, File.ctime
+ Avoid reusing old .rbc is .rb is newer
+ Remove useless CHECK_PTR
+
+commit 70458d6446f0858570571a64b5294c0bb4ac358f
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 10 17:40:36 2007 +0000
+
+ moved exception and expression specs to spec/language. added stub for time_spec in spec/library. updated a string spec that was failing. added specs for all (I think) float and fixnum instance methods. added specs for bignum, but about half need examples.
+
+commit ffe4a7a48dcc116f73b89b9a046d4430ed51975a
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 9 18:07:31 2007 +0000
+
+ removed duplicate bk task from Rakefile. removed shotgun-tests/test-array.rb as all tests have corresponding specs in spec/core. added beginning of specs for bignum separated into spec/core for stuff that should be indendent of mri or rubinius, and spec/shotgun for implementation specific.
+
+commit 946d0b42293ea081666e71e13c4b77d5b5dba886
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 7 05:38:33 2007 +0000
+
+ checking in Alan Hurdles patches to regexp, string, and spec_string.
+
+commit 5f035040c4b3ce842fff4b39d1ca657c97deb7a4
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 7 03:03:31 2007 +0000
+
+ updated mri and rubinius target impl specs. added environment option for running rubinius target using obsolete.rcompile, e.g.: COMPILER=rcompile spec spec/core/symbol_spec -f s. If you don't use the COMPILER env var, rubinius target will use shotgun to compile.
+
+commit 6ea911ae5740508cdbd8feb5cddba5b8bf7fe1c3
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Jan 7 02:32:35 2007 +0000
+
+ changed some Hash specs to use instance vars rather than local vars because some versions of Ruby2Ruby output borked sexp for block local vars. E.g. use @h rather than h.
+
+commit 256fe9a8cada7ed512556e1701a5264670c6c28f
+Author: Mae <mae@unknown>
+Date: Sat Jan 6 07:55:32 2007 +0000
+
+ made regression spec for buggy behavior of [1,2,3][2..-1]
+
+commit 0ffe8a3e6cd92bc5cd872cc22919885ea80366a0
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 5 20:05:03 2007 +0000
+
+ added spec for String#reverse! to Laurent Julliard's spec for String#reverse and his implementation of both methods.
+
+commit 170737d2c77a4b2de862380cb87f7705560cca64
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Jan 5 18:24:32 2007 +0000
+
+ * Much better implementation of Hash#key?
+ * Added working support for default Hash values and procs
+ * Added hash_get_undef for situations where nil and undefined hash values need to be differentiated
+
+commit 332378a8900f09009626cb7c4dbf0c8740a657c7
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 5 07:31:56 2007 +0000
+
+ added specs for aliases of Hash#key?
+
+commit 27c3b2aeaa3208a7e0218f051f623b93e2e635d8
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 5 07:28:29 2007 +0000
+
+ added spec for Hash#key?
+
+commit 2e88d941bc1b1ea506396a915e3c3c4e3dfd1601
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Jan 5 06:35:09 2007 +0000
+
+ updated and simplified float and fixnum specs.
+
+commit e4a5b6d8529d60e62875004bb60f33c6452ccf98
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Fri Jan 5 06:28:04 2007 +0000
+
+ * defined?() now handles: defined?(Kernel.puts) flavors of arguments.
+
+commit 27660379c09e561590cf1bc48a9459e29fc00e9c
+Author: Mae <mae@unknown>
+Date: Fri Jan 5 06:10:11 2007 +0000
+
+ Added spec for cvar declaration in class bodies
+
+commit a9b7b9f7db02ba78514eb869c2c52d4e5067f8d2
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 4 08:08:59 2007 +0000
+
+ added class def source code to specs.
+
+commit cdfa499ee238671c655800a81b51611704383500
+Author: Mae <mae@unknown>
+Date: Thu Jan 4 07:54:20 2007 +0000
+
+ fixed typo in spec still 7 failing specs *GLARES AT DEFILER*
+
+commit 03be9ca7da61363f8f0a02ee951bbafaf297c31b
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 4 07:43:58 2007 +0000
+
+ added specs for Module#const_defined?.
+
+commit c511d4c7a75001f2597b13f9fc2e910d2dd4d9a2
+Author: Mae <mae@unknown>
+Date: Thu Jan 4 06:54:07 2007 +0000
+
+ changed defined spec to be more dumb and just figure out whether its a true/false evaluation
+
+commit 4d9135f9694e4b692faf6a4c7b8dcd59f79f5069
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 4 06:38:57 2007 +0000
+
+ added library spec (beginning) for enumerator. trivial update for comparable specs. added specs for enumerable.
+
+commit 3de6e339526b1402f8995a5acc38fde707ec0695
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Jan 4 00:34:50 2007 +0000
+
+ added specs for comparable methods.
+
+commit ea25c6b17533c280e640dc97e3fec1207fb4be7b
+Author: Mae <mae@unknown>
+Date: Wed Jan 3 17:47:09 2007 +0000
+
+ almost done with defined? spec -- still need 'yield' and 'zsuper' test cases
+ from project dir: SPEC_TARGET=mri spec spec/language/defined_spec.rb
+ change SPEC_TARGET to rubinius to test on rubinius
+
+commit b795f6c2dc98952e7fa7231cded9156ade962b18
+Author: Mae <mae@unknown>
+Date: Wed Jan 3 17:25:31 2007 +0000
+
+ added incomplete specs for defined? behavior -- more work to be done
+
+commit 25e30e4668f1ef814bfb1182e032449263651590
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 3 17:17:03 2007 +0000
+
+ small fix to mri_target to generate reasonable cache soure name. added a couple specs.
+
+commit 3b5bc977ea2a4a3ad42ff83bcab2966459c262c0
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 3 08:51:18 2007 +0000
+
+ added object_spec for methods provided by Object, even mixed in ones. added a few specs for basic class, module, exceptions.
+
+commit c4f4dd722658b2a09ae273092744b76e65ce05b2
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Jan 3 02:36:58 2007 +0000
+
+ renamed flow_control_spec to expression_spec as these are all covered under heading expressions in pickaxe. run expression spec with mri target and then rubinius target to see an interesting rubinius failure. updated an incorrect string splice spec.
+
+commit ef8aa2f74896944134f5a8884ccc723ca9b472c1
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Jan 2 01:40:16 2007 +0000
+
+ separated specs that are shotgun specific methods (e.g. String#prefix?) into spec/shotgun/... fixed wrong specs so that all pass under mri/mir configuration.
+
+commit 8661488b40b9fccccf356889834c6a9162c8bebf
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 1 22:37:41 2007 +0000
+
+ very quick n' dirty implementation of example et al to run specs under mri like under rubinius.
+
+commit 0ebfa43e222ca4794243d36f10c2e429e930f527
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 1 20:47:13 2007 +0000
+
+ added methods for TrueClass and FalseClass, updated specs for each.
+
+commit e9bb50ced8bf997535f0bc9c6deeeffb86c40879
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 1 20:29:37 2007 +0000
+
+ added specs for true, false, nil.
+
+commit c30b0e38b88c686c11c6f7442e027d685d405505
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 1 18:59:59 2007 +0000
+
+ added spec templates for true, false, nil, class, module, enumerable, comparable, flow_control, exception. added specs to various others.
+
+commit b26777261970c213506e444b90412543f39b3c59
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 1 18:58:37 2007 +0000
+
+ added that rubinius target example method takes a default argument to pass strings of code to allow for creating classes, since classes can't be defined in a method body and for now example puts the block code into a method using ruby2ruby.
+
+commit 560c5a1331c76bce07289f1e5950b816fe7c9c24
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Jan 1 01:17:44 2007 +0000
+
+ added more string specs.
+
+commit 807864c76b701f6f976f3f2935599ba875fcc10e
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Dec 31 23:13:16 2006 +0000
+
+ added more core specs (or templates for specs) to cover existing tests in shotgun-tests.
+
+commit 8f83b600b12722d46b9791b2e2c3a399618474a0
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Dec 31 21:23:07 2006 +0000
+
+ removed shotgun/primitives_spec as spec/shotgun should be for shotgun-specific code. created spec/core for ruby core classes. spec/library is now for ruby stdlib classes. added more array specs.
+
+commit 58cc3ce5bd8b84a151b1a6e2334845f268ab894a
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Dec 31 08:58:50 2006 +0000
+
+ added specs for class methods of Regexp. added alias Regexp.compile for Regexp.new.
+
+commit 0a5a31bc6ef539eeda3de951ab633f5152d58153
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Dec 31 02:01:34 2006 +0000
+
+ added specs for symbol methods. added aliases to symbol for to_i, to_int, and id2name.
+
+commit cdfa28e492b8edfa55b950b06ce05ebb04b64643
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 30 17:27:18 2006 +0000
+
+ changed example method for rubinius_target to raise exception if compile fails. added specs for range.
+
+commit 5316e652084b8624828d0a9306f580bfc93184dc
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 29 20:37:46 2006 +0000
+
+ added spec files in spec/library for basic types (according to pickaxe book). added specs for all the methods in Regexp. there are many failing specs for a variety of reasons, but the goal is to get a good overview of where work needs to be done. more specs to follow.
+
+commit 06cd5ad6da819f2894996e42f4da70321767c9c7
+Author: Mae <mae@unknown>
+Date: Thu Dec 28 07:36:21 2006 +0000
+
+ Added Array expressions gleaned from spec/library/array_spec.rb as proof of concept for rapid compatibility testing
+ - A thought occurred to me that the scope for this type of testing might be limited severely to simple compatibility testing
+ - Its not very human understandable as a spec -- it just unravels incompatibilities given no hint as to why things are the way they are.
+ - It lets the ruby rval speak for itself
+ - Is this useful for rubinius?!
+
+commit 1c1fc9335aee4acbcd692c555b0ca194c5301013
+Author: Frederick <frederick@unknown>
+Date: Wed Dec 27 22:46:43 2006 +0000
+
+ Fix a bug in the allocation of a string. The underlying storage (byte array) did not have the correct size, leading to a write in a non allocated memory area.
+ The rationale is that, the storage are should be able to store the string plus a terminal \0. As we're allocating per block of 4 bytes (a word) we need to get the nearest multiple of 4.
+ This patch adds a spec to highlight the bug, and a fix to .. well, fix it ;)
+
+commit cdfdc272b71bbfca23b4c17e5572ebd2b966615e
+Author: Mae <mae@unknown>
+Date: Tue Dec 26 17:52:24 2006 +0000
+
+ Added my idea of a sanity check against MRI for compatibility purposes
+ - try it out!
+ - rake spec:compatibility
+ - example compatibility expressions go in spec/compatibility/expressions/*
+ - all the expression files are line-separated ruby expressions that return something basic and eval-able
+
+commit f9887648c7f239f8c862158b39f44b2410377204
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 22 19:20:58 2006 +0000
+
+ added spec file for String methods.
+
+commit 8178e4478977c81940ac4bdcd8bea608be11708b
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 22 17:14:46 2006 +0000
+
+ fixed that ruby2ruby was not generating correct ruby source when a local var was used in a block. changed local var to instance var and it works, converted primitives_spec to new block-style.
+
+commit 8a00080a1edb864af7573e8f9761f65fa1202d07
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 22 06:58:28 2006 +0000
+
+ changed array_spec to not use local variables in blocks where possible because rubytoruby is not converting them to ruby source correctly. Array#uniq! fails at the moment. re-added that compile checks code-cache first so specs run faster.
+
+commit 4a199c559eebe73cd21d0997126b799f5d4e2be5
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 22 06:00:21 2006 +0000
+
+ converted array_spec.rb to block-style specs, but they still depend on strings to be output. rewrote spec_helper based on nicksieger's example code. some specs are failing due to bugs converting to sexp and back to ruby source.
+
+commit 854bbc3617559a2ceac975d79a57ffa825a5cda6
+Author: Brian Ford <brixen@gmail.com>
+Date: Fri Dec 22 03:34:18 2006 +0000
+
+ added spec/targets for specs for 'target' part of host/target spec runner configuration. added mri_target and rubinius_target and specs.
+
+commit db81559c9c914413d2064b4202ec8ce43e503af2
+Author: Brian Ford <brixen@gmail.com>
+Date: Thu Dec 21 05:51:55 2006 +0000
+
+ added spec:targets task to run specs for target part of host/target spec configuration. added specs for mri_target and rubinius_target.
+
+commit a243a70bd17ec7e9839b69bb18e63d5d943b6095
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 20 19:02:01 2006 +0000
+
+ updated primitives_spec to use example method.
+
+commit 9ce077283dd10c21377add499c5bcc4ea87cfe0f
+Author: Brian Ford <brixen@gmail.com>
+Date: Wed Dec 20 17:11:00 2006 +0000
+
+ Changed method from rubinius to example for specs. This is in anticipation of having independent 'host' (system running rspec) and 'target' (system executing spec). Created parallel arrayb_spec that illustrates this with a mri/mri configuration. Also added spec_bhelper that is a *very rough* beginning for having mri/rubinius configuration using block-style specs.
+
+commit a8ad71a0da9e1a866521074743ea1dfcceb596cb
+Author: Wilson Bilkovich <wilson@supremetyrant.com>
+Date: Wed Dec 20 15:39:36 2006 +0000
+
+ Applying 'array patch' from Jason Perkins (2006-12-20 8:30 EST)
+
+commit 82b3d880131e7080ebc6b4289b3954d89a988c13
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 19 17:30:21 2006 +0000
+
+ added more specs to array_spec. most of these are failing, so there seems to be a lot of Array that needs implementing.
+
+commit c24f0e83b4d446afd541ffefbcb313f199b684ee
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 19 08:24:00 2006 +0000
+
+ added specs for Array#* and <<, simplified other specs.
+
+commit 62b0737ce69768a8292bd3d9f13401ec8056f6eb
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 19 07:46:39 2006 +0000
+
+ fixed messed up spec for &.
+
+commit 7635389b2abf5c492952a49eb8251d6fb34250c7
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 19 07:40:01 2006 +0000
+
+ added spec for Array#&, which is currently unimplemented. updated spec_helper.
+
+commit 42b5e9fc47bcf6bcd403d25795c9bcf07bb5c007
+Author: Brian Ford <brixen@gmail.com>
+Date: Tue Dec 19 06:13:15 2006 +0000
+
+ added spec tasks :only to run only spec, :language for high level language conformance spcs, :library for ruby stdlib implementation specs, and :shotgun for specs related to shotgun. rake spec will run all specs and tests. removed spec/spec_suite.rb because all specs can be run from rake. minor updates to spec_helper.
+
+commit da4c42890f4b8163b8d49de64bdb76c16b0e5d1f
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 18 17:41:44 2006 +0000
+
+ added shotgun dir under spec for things that relate to shotgun implementation of VM, like the prmitives_spec, while reserving spec/library for general ruby implementation of the std lib.
+
+commit 925cbf9f84f78a48189f7030c205942d266a6f66
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 18 09:45:25 2006 +0000
+
+ added Fixnum#% primitive implementation. changed array_spec to use Fixnum#%. fixed test_primitive test for Fixnum#%.
+
+commit 06e50e48a92e3fa7d1fc4d6b681872d08e5aeba3
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 18 09:10:37 2006 +0000
+
+ Added Fixnum#% primitive test, spec, cpu/primitive, stub.
+
+commit e0fbcf29f46dde89f65d13c1b6d7601a470cf223
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 18 07:54:02 2006 +0000
+
+ all ports of test_array test to array_spec are now passing.
+
+commit c2330c2ff65cfa964d954340fb0eb2507972efd5
+Author: Brian Ford <brixen@gmail.com>
+Date: Mon Dec 18 07:39:55 2006 +0000
+
+ updated spec_helper to ensure code-cache dir exists. fixed several failing specs in array_spec by correcting expected value.
+
+commit 81cc03c6f7ce499da563543f00d273d3a9c3a184
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Dec 17 06:27:15 2006 +0000
+
+ Ported the rest of test_array.rb tests to specs. Several of these specs are not passing but ported them all to illustrate behavior of specs.
+
+commit b4cb073931f403119a5ed9b63a2c915612a9c46f
+Author: Brian Ford <brixen@gmail.com>
+Date: Sun Dec 17 04:42:55 2006 +0000
+
+ spec/spec_helper.rb rubinius method is a very naive port of shotgun-tests/helper.rb run_code method. spec/library/array_spec.rb is several ports of the tests in shotgun-tests/test_array.rb, which is testing /kernel/array.rb. In other words, you can now create specs that run under RSpec (which is running under MRI 1.8.x) that exercises the rubinius vm, shotgun, and the stdlib that is being written in ruby. Confused? Read the source, Luke. :)
+
+commit 1b37cd1ee800060fb215a52d2902c3f4b778a656
+Author: Brian Ford <brixen@gmail.com>
+Date: Sat Dec 16 07:55:41 2006 +0000
+
+ Added spec dir with spec_suite.rb and spec_helper.rb provided by nullstyle.
diff --git a/spec/ruby/CONTRIBUTING.md b/spec/ruby/CONTRIBUTING.md
index 1ec6f0ff4b..fc88475970 100644
--- a/spec/ruby/CONTRIBUTING.md
+++ b/spec/ruby/CONTRIBUTING.md
@@ -88,14 +88,6 @@ Array.should have_method(:new)
raise "oops"
}.should raise_error(RuntimeError, /oops/)
--> {
- raise "oops"
-}.should raise_error(RuntimeError) { |e|
- # Custom checks on the Exception object
- e.message.should include("oops")
- e.cause.should == nil
-}
-
# To avoid! Instead, use an expectation testing what the code in the lambda does.
# If an exception is raised, it will fail the example anyway.
-> { ... }.should_not raise_error
@@ -152,11 +144,11 @@ end
# Combining guards
-guard -> { platform_is :windows and ruby_version_is ""..."2.5" } do
- # Windows and RUBY_VERSION < 2.5
+guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
+ # Windows and RUBY_VERSION < 2.3
end
-guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
+guard_not -> { platform_is :windows and ruby_version_is ""..."2.3" } do
# The opposite
end
@@ -166,8 +158,6 @@ guard -> { max_uint <= fixnum_max } do
end
```
-Custom guards are better than a simple `if` as they allow [mspec commands](https://github.com/ruby/mspec/issues/30#issuecomment-312487779) to work properly.
-
In general, the usage of guards should be minimized as possible.
There are no guards to define implementation-specific behavior because
@@ -176,76 +166,6 @@ Use the implementation test suite for these.
If an implementation does not support some feature, simply tag the related specs as failing instead.
-### Shared Specs
-
-Often throughout Ruby, identical functionality is used by different methods and modules. In order
-to avoid duplication of specs, we have shared specs that are re-used in other specs. The use is a
-bit tricky however, so let's go over it.
-
-Commonly, if a shared spec is only reused within its own module, the shared spec will live within a
-shared directory inside that module's directory. For example, the `core/hash/shared/key.rb` spec is
-only used by `Hash` specs, and so it lives inside `core/hash/shared/`.
-
-When a shared spec is used across multiple modules or classes, it lives within the `shared/` directory.
-An example of this is the `shared/file/socket.rb` which is used by `core/file/socket_spec.rb`,
-`core/filetest/socket_spec.rb`, and `core/file/state/socket_spec.rb` and so it lives in the root `shared/`.
-
-Defining a shared spec involves adding a `shared: true` option to the top-level `describe` block. This
-will signal not to run the specs directly by the runner. Shared specs have access to two instance
-variables from the implementor spec: `@method` and `@object`, which the implementor spec will pass in.
-
-Here's an example of a snippet of a shared spec and two specs which integrates it:
-
-```ruby
-# core/hash/shared/key.rb
-describe :hash_key_p, shared: true do
- it "returns true if the key's matching value was false" do
- { xyz: false }.send(@method, :xyz).should == true
- end
-end
-
-# core/hash/key_spec.rb
-describe "Hash#key?" do
- it_behaves_like :hash_key_p, :key?
-end
-
-# core/hash/include_spec.rb
-describe "Hash#include?" do
- it_behaves_like :hash_key_p, :include?
-end
-```
-
-In the example, the first `describe` defines the shared spec `:hash_key_p`, which defines a spec that
-calls the `@method` method with an expectation. In the implementor spec, we use `it_behaves_like` to
-integrate the shared spec. `it_behaves_like` takes 3 parameters: the key of the shared spec, a method,
-and an object. These last two parameters are accessible via `@method` and `@object` in the shared spec.
-
-Sometimes, shared specs require more context from the implementor class than a simple object. We can address
-this by passing a lambda as the method, which will have the scope of the implementor. Here's an example of
-how this is used currently:
-
-```ruby
-describe :kernel_sprintf, shared: true do
- it "raises TypeError exception if cannot convert to Integer" do
- -> { @method.call("%b", Object.new) }.should raise_error(TypeError)
- end
-end
-
-describe "Kernel#sprintf" do
- it_behaves_like :kernel_sprintf, -> (format, *args) {
- sprintf(format, *args)
- }
-end
-
-describe "Kernel.sprintf" do
- it_behaves_like :kernel_sprintf, -> (format, *args) {
- Kernel.sprintf(format, *args)
- }
-end
-```
-
-In the above example, the method being passed is a lambda that triggers the specific conditions of the shared spec.
-
### Style
-Do not leave any trailing space and follow the existing style.
+Do not leave any trailing space and respect the existing style.
diff --git a/spec/ruby/README.md b/spec/ruby/README.md
index c1316a9246..9c13ede75c 100644
--- a/spec/ruby/README.md
+++ b/spec/ruby/README.md
@@ -1,10 +1,10 @@
# The Ruby Spec Suite
-[![Actions Build Status](https://github.com/ruby/spec/workflows/CI/badge.svg?branch=master)](https://github.com/ruby/spec/actions)
-[![Windows Actions Build Status](https://github.com/ruby/spec/workflows/Windows/badge.svg?branch=master)](https://github.com/ruby/spec/actions)
+[![Build Status](https://travis-ci.org/ruby/spec.svg)](https://travis-ci.org/ruby/spec)
+[![Build Status](https://ci.appveyor.com/api/projects/status/1gs6f399320o44b1?svg=true)](https://ci.appveyor.com/project/eregon/spec-x948i)
[![Gitter](https://badges.gitter.im/ruby/spec.svg)](https://gitter.im/ruby/spec)
-The Ruby Spec Suite, abbreviated `ruby/spec`, is a test suite for the behavior of the Ruby programming language.
+The Ruby Spec Suite is a test suite for the behavior of the Ruby programming language.
It is not a standardized specification like the ISO one, and does not aim to become one.
Instead, it is a practical tool to describe and test the behavior of Ruby with code.
@@ -24,33 +24,17 @@ The language specs are grouped by keyword while the core and standard library sp
ruby/spec is known to be tested in these implementations for every commit:
* [MRI](http://rubyci.org/) on 30 platforms and 4 versions
-* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) for both 1.7 and 9.x
-* [TruffleRuby](https://github.com/oracle/truffleruby/tree/master/spec/ruby)
-* [Opal](https://github.com/opal/opal/tree/master/spec)
+* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) on Travis for both 1.7 and 9.x
+* [TruffleRuby](https://github.com/graalvm/truffleruby) on Travis
+* [Opal](https://github.com/opal/opal/tree/master/spec) on Travis
-ruby/spec describes the behavior of Ruby 2.4 and more recent Ruby versions.
-More precisely, every latest stable MRI release should [pass](https://travis-ci.org/ruby/spec) all specs of ruby/spec (2.4.x, 2.5.x, 2.6.x, etc), and those are tested in TravisCI.
-
-The specs are synchronized both ways around once a month by @eregon between ruby/spec, MRI, JRuby and TruffleRuby.
-Each of these repositories has a full copy of the specs under `spec/ruby` to ease editing specs.
-Any of these repositories can be used to add or edit specs, use what is most convenient for you.
-
-For *testing* a Ruby implementation, one should always test against the implementation's copy of the specs under `spec/ruby`, as that's what the Ruby implementation tests against in their CI.
-Also, this repository doesn't always contain the latest spec changes from MRI (it's synchronized monthly), and does not contain tags (specs marked as failing on that Ruby implementation).
-Running specs in a Ruby implementation can be done with:
-
-```
-$ cd ruby_implementation/spec/ruby
-# Add ../ruby_implementation/bin in PATH, or pass -t /path/to/bin/ruby
-$ ../mspec/bin/mspec
-```
+ruby/spec describes the behavior of Ruby 2.2 and more recent Ruby versions.
+More precisely, every latest stable MRI release [passes](https://rubyci.org/) all specs of ruby/spec
+(latest 2.2.x, 2.3.x, 2.4.x, etc).
For older specs try these commits:
* Ruby 2.0.0-p647 - [Suite](https://github.com/ruby/spec/commit/245862558761d5abc676843ef74f86c9bcc8ea8d) using [MSpec](https://github.com/ruby/mspec/commit/f90efa068791064f955de7a843e96e2d7d3041c2) (may encounter 2 failures)
* Ruby 2.1.9 - [Suite](https://github.com/ruby/spec/commit/f029e65241374386077ac500add557ae65069b55) using [MSpec](https://github.com/ruby/mspec/commit/55568ea3918c6380e64db8c567d732fa5781efed)
-* Ruby 2.2.10 - [Suite](https://github.com/ruby/spec/commit/cbaa0e412270c944df0c2532fc500c920dba0e92) using [MSpec](https://github.com/ruby/mspec/commit/d84d7668449e96856c5f6bac8cb1526b6d357ce3)
-* Ruby 2.3.8 - [Suite](https://github.com/ruby/spec/commit/dc733114d8ae66a3368ba3a98422c50147a76ba5) using [MSpec](https://github.com/ruby/mspec/commit/4599bc195fb109f2a482a01c32a7d659518369ea)
-* Ruby 2.4.10 - [Suite](https://github.com/ruby/spec/commit/bce4f2b81d6c31db67cf4d023a0625ceadde59bd) using [MSpec](https://github.com/ruby/mspec/commit/e7eb8aa4c26495b7b461e687d950b96eb08b3ff2)
### Running the specs
@@ -75,7 +59,7 @@ This will execute all the specs using the executable named `ruby` on your curren
### Running Specs with a Specific Ruby Implementation
Use the `-t` option to specify the Ruby implementation with which to run the specs.
-The argument is either a full path to the Ruby binary, or an executable in `$PATH`.
+The argument may be a full path to the Ruby binary.
$ ../mspec/bin/mspec -t /path/to/some/bin/ruby
@@ -100,38 +84,13 @@ In similar fashion, the following commands run the respective specs:
$ ../mspec/bin/mspec :library
$ ../mspec/bin/mspec :capi
-### Sanity Checks When Running Specs
-
-A number of checks for various kind of "leaks" (file descriptors, temporary files,
-threads, subprocesses, `ENV`, `ARGV`, global encodings, top-level constants) can be
-enabled with `CHECK_LEAKS=true`:
-
- $ CHECK_LEAKS=true ../mspec/bin/mspec
-
-New top-level constants should only be introduced when needed or follow the
-pattern `<ClassBeingTested>Specs` such as `module StringSpecs`.
-Other constants used for testing should be nested under such a module.
-
-Exceptions to these rules are contained in the file `.mspec.constants`.
-MSpec can automatically add new top-level constants in this file with:
-
- $ CHECK_LEAKS=save mspec ../mspec/bin/mspec file
-
-### Contributing and Writing Specs
-
-See [CONTRIBUTING.md](https://github.com/ruby/spec/blob/master/CONTRIBUTING.md) for documentation about contributing and writing specs (guards, matchers, etc).
-
-### Socket specs from rubysl-socket
+### Contributing
-Most specs under `library/socket` were imported from [the rubysl-socket project](https://github.com/rubysl/rubysl-socket).
-The 3 copyright holders of rubysl-socket, Yorick Peterse, Chuck Remes and
-Brian Shirai, [agreed to relicense those specs](https://github.com/rubysl/rubysl-socket/issues/15)
-under the MIT license in ruby/spec.
+See [CONTRIBUTING.md](https://github.com/ruby/spec/blob/master/CONTRIBUTING.md).
### History and RubySpec
This project was originally born from [Rubinius](https://github.com/rubinius/rubinius) tests being converted to the spec style.
-The revision history of these specs is available [here](https://github.com/ruby/spec/blob/2b886623/CHANGES.before-2008-05-10).
These specs were later extracted to their own project, RubySpec, with a specific vision and principles.
At the end of 2014, Brian Shirai, the creator of RubySpec, decided to [end RubySpec](http://rubinius.com/2014/12/31/matz-s-ruby-developers-don-t-use-rubyspec/).
A couple months later, the different repositories were merged and [the project was revived](http://eregon.github.io/rubyspec/2015/07/29/rubyspec-is-reborn.html).
diff --git a/spec/ruby/appveyor.yml b/spec/ruby/appveyor.yml
new file mode 100644
index 0000000000..8ee5abd8b4
--- /dev/null
+++ b/spec/ruby/appveyor.yml
@@ -0,0 +1,30 @@
+---
+version: "{build}"
+clone_depth: 5
+init:
+ # To avoid duplicated executables in PATH, see https://github.com/ruby/spec/pull/468
+ - set PATH=C:\ruby%RUBY_VERSION%\bin;C:\Program Files\7-Zip;C:\Program Files\AppVeyor\BuildAgent;C:\Program Files\Git\cmd;C:\Windows\system32;C:\Program Files;C:\Windows
+ # Loads trunk build and updates MSYS2 / MinGW to most recent gcc compiler
+ - if %ruby_version%==_trunk (
+ appveyor DownloadFile https://ci.appveyor.com/api/projects/MSP-Greg/ruby-loco/artifacts/ruby_trunk.7z -FileName C:\ruby_trunk.7z &
+ 7z x C:\ruby_trunk.7z -oC:\ruby_trunk & C:\ruby_trunk\trunk_msys2.cmd)
+environment:
+ matrix:
+ - RUBY_VERSION: 23-x64
+ - RUBY_VERSION: 24-x64
+ - RUBY_VERSION: _trunk # So the folder name is ruby_trunk
+install:
+ - git clone https://github.com/ruby/mspec.git ../mspec
+build: off
+test_script:
+ - SET CHECK_LEAKS=true
+ - ../mspec/bin/mspec -rdevkit -ff
+on_finish:
+ - ruby -v
+matrix:
+ allow_failures:
+ - ruby_version: _trunk
+branches:
+ only:
+ - master
+ - /^try/
diff --git a/spec/ruby/command_line/dash_a_spec.rb b/spec/ruby/command_line/dash_a_spec.rb
index 9ea135dc76..65f79ec208 100644
--- a/spec/ruby/command_line/dash_a_spec.rb
+++ b/spec/ruby/command_line/dash_a_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -a command line option" do
before :each do
@names = fixture __FILE__, "full_names.txt"
diff --git a/spec/ruby/command_line/dash_c_spec.rb b/spec/ruby/command_line/dash_c_spec.rb
index 6b3a5de685..375d945a07 100644
--- a/spec/ruby/command_line/dash_c_spec.rb
+++ b/spec/ruby/command_line/dash_c_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -c command line option" do
it "checks syntax in given file" do
diff --git a/spec/ruby/command_line/dash_d_spec.rb b/spec/ruby/command_line/dash_d_spec.rb
index 26891b4791..009a14e16c 100644
--- a/spec/ruby/command_line/dash_d_spec.rb
+++ b/spec/ruby/command_line/dash_d_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -d command line option" do
before :each do
diff --git a/spec/ruby/command_line/dash_e_spec.rb b/spec/ruby/command_line/dash_e_spec.rb
index 9f600eb414..3435e78e29 100644
--- a/spec/ruby/command_line/dash_e_spec.rb
+++ b/spec/ruby/command_line/dash_e_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -e command line option" do
it "evaluates the given string" do
diff --git a/spec/ruby/command_line/dash_encoding_spec.rb b/spec/ruby/command_line/dash_encoding_spec.rb
deleted file mode 100644
index 36ce55af5f..0000000000
--- a/spec/ruby/command_line/dash_encoding_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The --encoding command line option" do
- before :each do
- @test_string = "print [Encoding.default_external.name, Encoding.default_internal&.name].inspect"
- @enc2 = Encoding::ISO_8859_1
- end
-
- describe "sets Encoding.default_external and optionally Encoding.default_internal" do
- it "if given a single encoding with an =" do
- ruby_exe(@test_string, options: "--disable-gems --encoding=big5").should == [Encoding::Big5.name, nil].inspect
- end
-
- it "if given a single encoding as a separate argument" do
- ruby_exe(@test_string, options: "--disable-gems --encoding big5").should == [Encoding::Big5.name, nil].inspect
- end
-
- it "if given two encodings with an =" do
- ruby_exe(@test_string, options: "--disable-gems --encoding=big5:#{@enc2}").should == [Encoding::Big5.name, @enc2.name].inspect
- end
-
- it "if given two encodings as a separate argument" do
- ruby_exe(@test_string, options: "--disable-gems --encoding big5:#{@enc2}").should == [Encoding::Big5.name, @enc2.name].inspect
- end
- end
-
- it "does not accept a third encoding" do
- ruby_exe(@test_string, options: "--disable-gems --encoding big5:#{@enc2}:utf-32le", args: "2>&1").should =~ /extra argument for --encoding: utf-32le/
- end
-end
diff --git a/spec/ruby/command_line/dash_external_encoding_spec.rb b/spec/ruby/command_line/dash_external_encoding_spec.rb
deleted file mode 100644
index f052674dc8..0000000000
--- a/spec/ruby/command_line/dash_external_encoding_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'The --external-encoding command line option sets Encoding.default_external' do
- before :each do
- @test_string = "print Encoding.default_external.name"
- end
-
- it "if given an encoding with an =" do
- ruby_exe(@test_string, options: '--external-encoding=big5').should == Encoding::Big5.name
- end
-
- it "if given an encoding as a separate argument" do
- ruby_exe(@test_string, options: '--external-encoding big5').should == Encoding::Big5.name
- end
-end
diff --git a/spec/ruby/command_line/dash_internal_encoding_spec.rb b/spec/ruby/command_line/dash_internal_encoding_spec.rb
deleted file mode 100644
index 3049040bb4..0000000000
--- a/spec/ruby/command_line/dash_internal_encoding_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'The --internal-encoding command line option sets Encoding.default_internal' do
- before :each do
- @test_string = "print Encoding.default_internal.name"
- end
-
- it "if given an encoding with an =" do
- ruby_exe(@test_string, options: '--internal-encoding=big5').should == Encoding::Big5.name
- end
-
- it "if given an encoding as a separate argument" do
- ruby_exe(@test_string, options: '--internal-encoding big5').should == Encoding::Big5.name
- end
-end
diff --git a/spec/ruby/command_line/dash_n_spec.rb b/spec/ruby/command_line/dash_n_spec.rb
index 9d331d6065..f4dd9f1851 100644
--- a/spec/ruby/command_line/dash_n_spec.rb
+++ b/spec/ruby/command_line/dash_n_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -n command line option" do
before :each do
@names = fixture __FILE__, "names.txt"
diff --git a/spec/ruby/command_line/dash_p_spec.rb b/spec/ruby/command_line/dash_p_spec.rb
index 39827c3868..67562b5bc3 100644
--- a/spec/ruby/command_line/dash_p_spec.rb
+++ b/spec/ruby/command_line/dash_p_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -p command line option" do
before :each do
@names = fixture __FILE__, "names.txt"
diff --git a/spec/ruby/command_line/dash_r_spec.rb b/spec/ruby/command_line/dash_r_spec.rb
index b29895bd26..3d3abcf0b7 100644
--- a/spec/ruby/command_line/dash_r_spec.rb
+++ b/spec/ruby/command_line/dash_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -r command line option" do
before :each do
diff --git a/spec/ruby/command_line/dash_s_spec.rb b/spec/ruby/command_line/dash_s_spec.rb
index eaaeea7c96..70e41208e0 100644
--- a/spec/ruby/command_line/dash_s_spec.rb
+++ b/spec/ruby/command_line/dash_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -s command line option" do
describe "when using -- to stop parsing" do
diff --git a/spec/ruby/command_line/dash_upper_c_spec.rb b/spec/ruby/command_line/dash_upper_c_spec.rb
index ece1b32105..e8a54b01c1 100644
--- a/spec/ruby/command_line/dash_upper_c_spec.rb
+++ b/spec/ruby/command_line/dash_upper_c_spec.rb
@@ -1,6 +1,18 @@
-require_relative '../spec_helper'
-require_relative 'shared/change_directory'
+require File.expand_path('../../spec_helper', __FILE__)
-describe "The -C command line option" do
- it_behaves_like :command_line_change_directory, "-C"
+describe 'The -C command line option' do
+ before :all do
+ @script = fixture(__FILE__, 'dash_upper_c_script.rb')
+ @tempdir = File.dirname(@script)
+ end
+
+ it 'changes the PWD when using a file' do
+ output = ruby_exe(@script, options: "-C #{@tempdir}")
+ output.should == @tempdir
+ end
+
+ it 'changes the PWD when using -e' do
+ output = ruby_exe(nil, options: "-C #{@tempdir} -e 'print Dir.pwd'")
+ output.should == @tempdir
+ end
end
diff --git a/spec/ruby/command_line/dash_upper_e_spec.rb b/spec/ruby/command_line/dash_upper_e_spec.rb
index b3c6ce262b..716f1304b7 100644
--- a/spec/ruby/command_line/dash_upper_e_spec.rb
+++ b/spec/ruby/command_line/dash_upper_e_spec.rb
@@ -1,33 +1,4 @@
-require_relative '../spec_helper'
-
describe "ruby -E" do
- it "sets the external encoding with '-E external'" do
- result = ruby_exe("print Encoding.default_external", options: '-E euc-jp')
- result.should == "EUC-JP"
- end
-
- platform_is_not :windows do
- it "also sets the filesystem encoding with '-E external'" do
- result = ruby_exe("print Encoding.find('filesystem')", options: '-E euc-jp')
- result.should == "EUC-JP"
- end
- end
-
- it "sets the external encoding with '-E external:'" do
- result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:')
- result.should == "Shift_JIS"
- end
-
- it "sets the internal encoding with '-E :internal'" do
- ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS').
- should == 'Shift_JIS'
- end
-
- it "sets the external and internal encodings with '-E external:internal'" do
- ruby_exe("puts Encoding.default_external, Encoding.default_internal", options: '-E euc-jp:SHIFT_JIS').
- should == "EUC-JP\nShift_JIS\n"
- end
-
it "raises a RuntimeError if used with -U" do
ruby_exe("p 1",
options: '-Eascii:ascii -U',
diff --git a/spec/ruby/command_line/dash_upper_f_spec.rb b/spec/ruby/command_line/dash_upper_f_spec.rb
index 967acc2ece..020968b1f9 100644
--- a/spec/ruby/command_line/dash_upper_f_spec.rb
+++ b/spec/ruby/command_line/dash_upper_f_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "the -F command line option" do
before :each do
@passwd = fixture __FILE__, "passwd_file.txt"
diff --git a/spec/ruby/command_line/dash_upper_i_spec.rb b/spec/ruby/command_line/dash_upper_i_spec.rb
index 4cafb724e3..0a00059949 100644
--- a/spec/ruby/command_line/dash_upper_i_spec.rb
+++ b/spec/ruby/command_line/dash_upper_i_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The -I command line option" do
before :each do
@@ -8,44 +8,4 @@ describe "The -I command line option" do
it "adds the path to the load path ($:)" do
ruby_exe(@script, options: "-I fixtures").should include("fixtures")
end
-
- it "adds the path at the front of $LOAD_PATH" do
- lines = ruby_exe(@script, options: "-I fixtures").lines
- if PlatformGuard.implementation? :ruby
- # In a MRI checkout, $PWD ends up as the first entry in $LOAD_PATH.
- # So just assert that it's at the beginning.
- idx = lines.index { |l| l.include?("fixtures") }
- idx.should < 2
- idx.should < lines.size-1
- else
- lines[0].should include("fixtures")
- end
- end
-
- it "adds the path expanded from CWD to $LOAD_PATH" do
- ruby_exe(@script, options: "-I fixtures").lines.should include "#{Dir.pwd}/fixtures\n"
- end
-
- it "expands a path from CWD even if it does not exist" do
- ruby_exe(@script, options: "-I not_exist/not_exist").lines.should include "#{Dir.pwd}/not_exist/not_exist\n"
- end
-end
-
-platform_is_not :windows do
- describe "The -I command line option" do
- before :each do
- @script = fixture __FILE__, "loadpath.rb"
- @fixtures = File.dirname(@script)
- @symlink = tmp("loadpath_symlink")
- File.symlink(@fixtures, @symlink)
- end
-
- after :each do
- rm_r @symlink
- end
-
- it "does not expand symlinks" do
- ruby_exe(@script, options: "-I #{@symlink}").lines.should include "#{@symlink}\n"
- end
- end
end
diff --git a/spec/ruby/command_line/dash_upper_k_spec.rb b/spec/ruby/command_line/dash_upper_k_spec.rb
index a060eab793..3c3b9fa4d3 100644
--- a/spec/ruby/command_line/dash_upper_k_spec.rb
+++ b/spec/ruby/command_line/dash_upper_k_spec.rb
@@ -1,65 +1,33 @@
-require_relative '../spec_helper'
-
-describe 'The -K command line option' do
- before :each do
- @test_string = "print [__ENCODING__&.name, Encoding.default_external&.name, Encoding.default_internal&.name].inspect"
+describe 'The -K command line option sets __ENCODING__' do
+ it "to Encoding::ASCII_8BIT with -Ka" do
+ ruby_exe("print __ENCODING__", options: '-Ka').should == Encoding::ASCII_8BIT.to_s
end
- describe 'sets __ENCODING__ and Encoding.default_external' do
- it "to Encoding::BINARY with -Ka" do
- ruby_exe(@test_string, options: '-Ka').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::BINARY with -KA" do
- ruby_exe(@test_string, options: '-KA').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::BINARY with -Kn" do
- ruby_exe(@test_string, options: '-Kn').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::BINARY with -KN" do
- ruby_exe(@test_string, options: '-KN').should ==
- [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
- end
-
- it "to Encoding::EUC_JP with -Ke" do
- ruby_exe(@test_string, options: '-Ke').should ==
- [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
- end
+ it "to Encoding::ASCII_8BIT with -KA" do
+ ruby_exe("print __ENCODING__", options: '-KA').should == Encoding::ASCII_8BIT.to_s
+ end
- it "to Encoding::EUC_JP with -KE" do
- ruby_exe(@test_string, options: '-KE').should ==
- [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
- end
+ it "to Encoding::EUC_JP with -Ke" do
+ ruby_exe("print __ENCODING__", options: '-Ke').should == Encoding::EUC_JP.to_s
+ end
- it "to Encoding::UTF_8 with -Ku" do
- ruby_exe(@test_string, options: '-Ku').should ==
- [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
- end
+ it "to Encoding::EUC_JP with -KE" do
+ ruby_exe("print __ENCODING__", options: '-KE').should == Encoding::EUC_JP.to_s
+ end
- it "to Encoding::UTF_8 with -KU" do
- ruby_exe(@test_string, options: '-KU').should ==
- [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
- end
+ it "to Encoding::UTF_8 with -Ku" do
+ ruby_exe("print __ENCODING__", options: '-Ku').should == Encoding::UTF_8.to_s
+ end
- it "to Encoding::Windows_31J with -Ks" do
- ruby_exe(@test_string, options: '-Ks').should ==
- [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
- end
+ it "to Encoding::UTF_8 with -KU" do
+ ruby_exe("print __ENCODING__", options: '-KU').should == Encoding::UTF_8.to_s
+ end
- it "to Encoding::Windows_31J with -KS" do
- ruby_exe(@test_string, options: '-KS').should ==
- [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
- end
+ it "to Encoding::Windows_31J with -Ks" do
+ ruby_exe("print __ENCODING__", options: '-Ks').should == Encoding::Windows_31J.to_s
end
- it "ignores unknown codes" do
- locale = Encoding.find('locale')
- ruby_exe(@test_string, options: '-KZ').should ==
- [Encoding::UTF_8.name, locale.name, nil].inspect
+ it "to Encoding::Windows_31J with -KS" do
+ ruby_exe("print __ENCODING__", options: '-KS').should == Encoding::Windows_31J.to_s
end
end
diff --git a/spec/ruby/command_line/dash_upper_s_spec.rb b/spec/ruby/command_line/dash_upper_s_spec.rb
index 3a28fa2ad2..2e293e9a62 100644
--- a/spec/ruby/command_line/dash_upper_s_spec.rb
+++ b/spec/ruby/command_line/dash_upper_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe 'The -S command line option' do
before :each do
diff --git a/spec/ruby/command_line/dash_upper_u_spec.rb b/spec/ruby/command_line/dash_upper_u_spec.rb
index 2546b5b9f4..6cd52a3647 100644
--- a/spec/ruby/command_line/dash_upper_u_spec.rb
+++ b/spec/ruby/command_line/dash_upper_u_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "ruby -U" do
it "sets Encoding.default_internal to UTF-8" do
ruby_exe('print Encoding.default_internal.name',
diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb
index 31bb976ad2..4e517a422a 100644
--- a/spec/ruby/command_line/dash_upper_w_spec.rb
+++ b/spec/ruby/command_line/dash_upper_w_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'shared/verbose'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/verbose', __FILE__)
describe "The -W command line option" do
before :each do
diff --git a/spec/ruby/command_line/dash_upper_x_spec.rb b/spec/ruby/command_line/dash_upper_x_spec.rb
deleted file mode 100644
index 8ef9aae4b1..0000000000
--- a/spec/ruby/command_line/dash_upper_x_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../spec_helper'
-require_relative 'shared/change_directory'
-
-describe "The -X command line option" do
- it_behaves_like :command_line_change_directory, "-X"
-end
diff --git a/spec/ruby/command_line/dash_v_spec.rb b/spec/ruby/command_line/dash_v_spec.rb
index 04d684fdad..2ee9099419 100644
--- a/spec/ruby/command_line/dash_v_spec.rb
+++ b/spec/ruby/command_line/dash_v_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../spec_helper'
-require_relative 'shared/verbose'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/verbose', __FILE__)
describe "The -v command line option" do
it_behaves_like :command_line_verbose, "-v"
describe "when used alone" do
it "prints version and ends" do
- ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION)
+ ruby_exe(nil, args: '-v').include?(RUBY_DESCRIPTION).should == true
end
end
end
diff --git a/spec/ruby/command_line/dash_w_spec.rb b/spec/ruby/command_line/dash_w_spec.rb
index 1d93e0347b..bb038cb10c 100644
--- a/spec/ruby/command_line/dash_w_spec.rb
+++ b/spec/ruby/command_line/dash_w_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'shared/verbose'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/verbose', __FILE__)
describe "The -w command line option" do
it_behaves_like :command_line_verbose, "-w"
diff --git a/spec/ruby/command_line/dash_x_spec.rb b/spec/ruby/command_line/dash_x_spec.rb
index eb89db0144..a5306b4f75 100644
--- a/spec/ruby/command_line/dash_x_spec.rb
+++ b/spec/ruby/command_line/dash_x_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../spec_helper'
-
describe "The -x command line option" do
it "runs code after the first /\#!.*ruby.*/-ish line in target file" do
embedded_ruby = fixture __FILE__, "bin/embedded_ruby.txt"
@@ -18,4 +16,6 @@ describe "The -x command line option" do
result = ruby_exe(embedded_ruby)
result.should == "success\n"
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/command_line/error_message_spec.rb b/spec/ruby/command_line/error_message_spec.rb
index 5fee3ead44..6212452739 100644
--- a/spec/ruby/command_line/error_message_spec.rb
+++ b/spec/ruby/command_line/error_message_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The error message caused by an exception" do
it "is not printed to stdout" do
diff --git a/spec/ruby/command_line/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb
deleted file mode 100644
index 02571ee8c6..0000000000
--- a/spec/ruby/command_line/feature_spec.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The --enable and --disable flags" do
-
- it "can be used with gems" do
- ruby_exe("p defined?(Gem)", options: "--enable=gems").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable=gems").chomp.should == "nil"
- ruby_exe("p defined?(Gem)", options: "--enable-gems").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable-gems").chomp.should == "nil"
- end
-
- it "can be used with gem" do
- ruby_exe("p defined?(Gem)", options: "--enable=gem").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable=gem").chomp.should == "nil"
- ruby_exe("p defined?(Gem)", options: "--enable-gem").chomp.should == "\"constant\""
- ruby_exe("p defined?(Gem)", options: "--disable-gem").chomp.should == "nil"
- end
-
- it "can be used with did_you_mean" do
- ruby_exe("p defined?(DidYouMean)", options: "--enable=did_you_mean").chomp.should == "\"constant\""
- ruby_exe("p defined?(DidYouMean)", options: "--disable=did_you_mean").chomp.should == "nil"
- ruby_exe("p defined?(DidYouMean)", options: "--enable-did_you_mean").chomp.should == "\"constant\""
- ruby_exe("p defined?(DidYouMean)", options: "--disable-did_you_mean").chomp.should == "nil"
- end
-
- it "can be used with rubyopt" do
- ruby_exe("p $VERBOSE", options: "--enable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "true"
- ruby_exe("p $VERBOSE", options: "--disable=rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false"
- ruby_exe("p $VERBOSE", options: "--enable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "true"
- ruby_exe("p $VERBOSE", options: "--disable-rubyopt", env: {'RUBYOPT' => '-w'}).chomp.should == "false"
- end
-
- it "can be used with frozen-string-literal" do
- ruby_exe("p 'foo'.frozen?", options: "--enable=frozen-string-literal").chomp.should == "true"
- ruby_exe("p 'foo'.frozen?", options: "--disable=frozen-string-literal").chomp.should == "false"
- ruby_exe("p 'foo'.frozen?", options: "--enable-frozen-string-literal").chomp.should == "true"
- ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false"
- end
-
- it "can be used with all" do
- e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]"
- env = {'RUBYOPT' => '-w'}
- ruby_exe(e, options: "--enable=all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]"
- ruby_exe(e, options: "--enable-all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]"
- ruby_exe(e, options: "--disable=all", env: env).chomp.should == "[nil, nil, false, false]"
- ruby_exe(e, options: "--disable-all", env: env).chomp.should == "[nil, nil, false, false]"
- end
-
- it "prints a warning for unknown features" do
- ruby_exe("p 14", options: "--enable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable')
- ruby_exe("p 14", options: "--disable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable')
- ruby_exe("p 14", options: "--enable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable')
- ruby_exe("p 14", options: "--disable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable')
- end
-
-end
diff --git a/spec/ruby/command_line/fixtures/bin/launcher.rb b/spec/ruby/command_line/fixtures/bin/launcher.rb
index 92a0ee2b49..92a0ee2b49 100755..100644
--- a/spec/ruby/command_line/fixtures/bin/launcher.rb
+++ b/spec/ruby/command_line/fixtures/bin/launcher.rb
diff --git a/spec/ruby/command_line/fixtures/change_directory_script.rb b/spec/ruby/command_line/fixtures/dash_upper_c_script.rb
index abe244705f..abe244705f 100644
--- a/spec/ruby/command_line/fixtures/change_directory_script.rb
+++ b/spec/ruby/command_line/fixtures/dash_upper_c_script.rb
diff --git a/spec/ruby/command_line/frozen_strings_spec.rb b/spec/ruby/command_line/frozen_strings_spec.rb
index 647b69daed..f3ee797c78 100644
--- a/spec/ruby/command_line/frozen_strings_spec.rb
+++ b/spec/ruby/command_line/frozen_strings_spec.rb
@@ -1,29 +1,30 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
-describe "The --enable-frozen-string-literal flag causes string literals to" do
+ruby_version_is "2.3" do
+ describe "The --enable-frozen-string-literal flag causes string literals to" do
- it "produce the same object each time" do
- ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
- end
+ it "produce the same object each time" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
- it "produce the same object for literals with the same content" do
- ruby_exe(fixture(__FILE__, "freeze_flag_two_literals.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
- end
+ it "produce the same object for literals with the same content" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_two_literals.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
- it "produce the same object for literals with the same content in different files" do
- ruby_exe(fixture(__FILE__, "freeze_flag_across_files.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
- end
+ it "produce the same object for literals with the same content in different files" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_across_files.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
- it "produce different objects for literals with the same content in different files if they have different encodings" do
- ruby_exe(fixture(__FILE__, "freeze_flag_across_files_diff_enc.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ it "produce different objects for literals with the same content in different files if they have different encodings" do
+ ruby_exe(fixture(__FILE__, "freeze_flag_across_files_diff_enc.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
+ end
end
-end
-describe "The --debug flag produces" do
- it "debugging info on attempted frozen string modification" do
- error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--debug', args: "2>&1")
- error_str.should include("can't modify frozen String")
- error_str.should include("created at")
- error_str.should include("command_line/fixtures/debug_info.rb:2")
+ describe "The --debug flag produces" do
+ it "debugging info on attempted frozen string modification" do
+ error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--debug', args: "2>&1")
+ error_str.should include("can't modify frozen String, created at ")
+ error_str.should include("command_line/fixtures/debug_info.rb:2")
+ end
end
end
diff --git a/spec/ruby/command_line/rubylib_spec.rb b/spec/ruby/command_line/rubylib_spec.rb
deleted file mode 100644
index b45919b997..0000000000
--- a/spec/ruby/command_line/rubylib_spec.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The RUBYLIB environment variable" do
- before :each do
- @rubylib, ENV["RUBYLIB"] = ENV["RUBYLIB"], nil
- @pre = @rubylib.nil? ? '' : @rubylib + File::PATH_SEPARATOR
- end
-
- after :each do
- ENV["RUBYLIB"] = @rubylib
- end
-
- it "adds a directory to $LOAD_PATH" do
- dir = tmp("rubylib/incl")
- ENV["RUBYLIB"] = @pre + dir
- paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
- paths.should include(dir)
- end
-
- it "adds a File::PATH_SEPARATOR-separated list of directories to $LOAD_PATH" do
- dir1, dir2 = tmp("rubylib/incl1"), tmp("rubylib/incl2")
- ENV["RUBYLIB"] = @pre + "#{dir1}#{File::PATH_SEPARATOR}#{dir2}"
- paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
- paths.should include(dir1)
- paths.should include(dir2)
- paths.index(dir1).should < paths.index(dir2)
- end
-
- it "adds the directory at the front of $LOAD_PATH" do
- dir = tmp("rubylib/incl_front")
- ENV["RUBYLIB"] = @pre + dir
- paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp)
- paths.shift if paths.first.end_with?('/gem-rehash')
- if PlatformGuard.implementation? :ruby
- # In a MRI checkout, $PWD and some extra -I entries end up as
- # the first entries in $LOAD_PATH. So just assert that it's not last.
- idx = paths.index(dir)
- idx.should < paths.size-1
- else
- paths[0].should == dir
- end
- end
-
- it "adds the directory after directories added by -I" do
- dash_i_dir = tmp("dash_I_include")
- rubylib_dir = tmp("rubylib_include")
- ENV["RUBYLIB"] = @pre + rubylib_dir
- paths = ruby_exe("puts $LOAD_PATH", options: "-I #{dash_i_dir}").lines.map(&:chomp)
- paths.should include(dash_i_dir)
- paths.should include(rubylib_dir)
- paths.index(dash_i_dir).should < paths.index(rubylib_dir)
- end
-
- it "adds the directory after directories added by -I within RUBYOPT" do
- rubyopt_dir = tmp("rubyopt_include")
- rubylib_dir = tmp("rubylib_include")
- ENV["RUBYLIB"] = @pre + rubylib_dir
- paths = ruby_exe("puts $LOAD_PATH", env: { "RUBYOPT" => "-I#{rubyopt_dir}" }).lines.map(&:chomp)
- paths.should include(rubyopt_dir)
- paths.should include(rubylib_dir)
- paths.index(rubyopt_dir).should < paths.index(rubylib_dir)
- end
-
- it "keeps spaces in the value" do
- ENV["RUBYLIB"] = @pre + " rubylib/incl "
- out = ruby_exe("puts $LOAD_PATH")
- out.should include(" rubylib/incl ")
- end
-end
diff --git a/spec/ruby/command_line/rubyopt_spec.rb b/spec/ruby/command_line/rubyopt_spec.rb
index 2db42f77ef..a662b026bf 100644
--- a/spec/ruby/command_line/rubyopt_spec.rb
+++ b/spec/ruby/command_line/rubyopt_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "Processing RUBYOPT" do
- before :each do
+ before (:each) do
@rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], nil
end
- after :each do
+ after (:each) do
ENV["RUBYOPT"] = @rubyopt
end
@@ -22,16 +22,14 @@ describe "Processing RUBYOPT" do
result.should =~ /value of \$DEBUG is true/
end
- guard -> { not CROSS_COMPILING } do
- it "prints the version number for '-v'" do
- ENV["RUBYOPT"] = '-v'
- ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
- end
+ it "prints the version number for '-v'" do
+ ENV["RUBYOPT"] = '-v'
+ ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
+ end
- it "ignores whitespace around the option" do
- ENV["RUBYOPT"] = ' -v '
- ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
- end
+ it "ignores whitespace around the option" do
+ ENV["RUBYOPT"] = ' -v '
+ ruby_exe("")[/\A.*/].should == RUBY_DESCRIPTION
end
it "sets $VERBOSE to true for '-w'" do
diff --git a/spec/ruby/command_line/shared/change_directory.rb b/spec/ruby/command_line/shared/change_directory.rb
deleted file mode 100644
index 9cb6e90ac6..0000000000
--- a/spec/ruby/command_line/shared/change_directory.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-describe :command_line_change_directory, shared: true do
- before :all do
- @script = fixture(__FILE__, 'change_directory_script.rb')
- @tempdir = File.dirname(@script)
- end
-
- it 'changes the PWD when using a file' do
- output = ruby_exe(@script, options: "#{@method} #{@tempdir}")
- output.should == @tempdir
- end
-
- it 'does not need a space after -C for the argument' do
- output = ruby_exe(@script, options: "#{@method}#{@tempdir}")
- output.should == @tempdir
- end
-
- it 'changes the PWD when using -e' do
- output = ruby_exe(nil, options: "#{@method} #{@tempdir} -e 'print Dir.pwd'")
- output.should == @tempdir
- end
-end
diff --git a/spec/ruby/command_line/shared/verbose.rb b/spec/ruby/command_line/shared/verbose.rb
index c5c44c269e..457fe3006a 100644
--- a/spec/ruby/command_line/shared/verbose.rb
+++ b/spec/ruby/command_line/shared/verbose.rb
@@ -4,6 +4,6 @@ describe :command_line_verbose, shared: true do
end
it "sets $VERBOSE to true" do
- ruby_exe(@script, options: @method).chomp.b.split.last.should == "true"
+ ruby_exe(@script, options: @method).chomp.split.last.should == "true"
end
end
diff --git a/spec/ruby/command_line/syntax_error_spec.rb b/spec/ruby/command_line/syntax_error_spec.rb
index f61cfe928d..71cee32e23 100644
--- a/spec/ruby/command_line/syntax_error_spec.rb
+++ b/spec/ruby/command_line/syntax_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The interpreter" do
it "prints an error when given a file with invalid syntax" do
diff --git a/spec/ruby/core/argf/argf_spec.rb b/spec/ruby/core/argf/argf_spec.rb
index af67170b98..b47e77c17f 100644
--- a/spec/ruby/core/argf/argf_spec.rb
+++ b/spec/ruby/core/argf/argf_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF" do
it "is extended by the Enumerable module" do
diff --git a/spec/ruby/core/argf/argv_spec.rb b/spec/ruby/core/argf/argv_spec.rb
index eab03c450f..e294b3993f 100644
--- a/spec/ruby/core/argf/argv_spec.rb
+++ b/spec/ruby/core/argf/argv_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.argv" do
before :each do
diff --git a/spec/ruby/core/argf/binmode_spec.rb b/spec/ruby/core/argf/binmode_spec.rb
index bdcc6aa30a..62202360e3 100644
--- a/spec/ruby/core/argf/binmode_spec.rb
+++ b/spec/ruby/core/argf/binmode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.binmode" do
before :each do
@@ -22,7 +22,7 @@ describe "ARGF.binmode" do
end
end
- it "puts all subsequent streams reading through ARGF into binmode" do
+ it "puts alls subsequent stream reading through ARGF into binmode" do
argf [@bin_file, @bin_file] do
@argf.binmode
@argf.gets.should == "test\r\n"
@@ -31,13 +31,13 @@ describe "ARGF.binmode" do
end
end
- it "sets the file's encoding to BINARY" do
+ it "sets the file's encoding to ASCII-8BIT" do
argf [@bin_file, @file1] do
@argf.binmode
@argf.binmode?.should == true
- @argf.gets.encoding.should == Encoding::BINARY
+ @argf.gets.encoding.should == Encoding::ASCII_8BIT
@argf.skip
- @argf.read.encoding.should == Encoding::BINARY
+ @argf.read.encoding.should == Encoding::ASCII_8BIT
end
end
end
diff --git a/spec/ruby/core/argf/bytes_spec.rb b/spec/ruby/core/argf/bytes_spec.rb
index 71d07fabcb..01a3a3db0d 100644
--- a/spec/ruby/core/argf/bytes_spec.rb
+++ b/spec/ruby/core/argf/bytes_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_byte'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_byte', __FILE__)
describe "ARGF.bytes" do
it_behaves_like :argf_each_byte, :bytes
diff --git a/spec/ruby/core/argf/chars_spec.rb b/spec/ruby/core/argf/chars_spec.rb
index ee79ea763b..8c9e4844c0 100644
--- a/spec/ruby/core/argf/chars_spec.rb
+++ b/spec/ruby/core/argf/chars_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_char'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_char', __FILE__)
describe "ARGF.chars" do
it_behaves_like :argf_each_char, :chars
diff --git a/spec/ruby/core/argf/close_spec.rb b/spec/ruby/core/argf/close_spec.rb
index d4d6a51e72..b56f7f5564 100644
--- a/spec/ruby/core/argf/close_spec.rb
+++ b/spec/ruby/core/argf/close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.close" do
before :each do
@@ -20,10 +20,21 @@ describe "ARGF.close" do
end
end
- it "doesn't raise an IOError if called on a closed stream" do
- argf [@file1_name] do
- -> { @argf.close }.should_not raise_error
- -> { @argf.close }.should_not raise_error
+ ruby_version_is ""..."2.3" do
+ it "raises an IOError if called on a closed stream" do
+ argf [@file1_name] do
+ lambda { @argf.close }.should_not raise_error
+ lambda { @argf.close }.should raise_error(IOError)
+ end
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "doesn't raise an IOError if called on a closed stream" do
+ argf [@file1_name] do
+ lambda { @argf.close }.should_not raise_error
+ lambda { @argf.close }.should_not raise_error
+ end
end
end
end
diff --git a/spec/ruby/core/argf/closed_spec.rb b/spec/ruby/core/argf/closed_spec.rb
index e2dd6134e5..745f102484 100644
--- a/spec/ruby/core/argf/closed_spec.rb
+++ b/spec/ruby/core/argf/closed_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.closed?" do
before :each do
diff --git a/spec/ruby/core/argf/codepoints_spec.rb b/spec/ruby/core/argf/codepoints_spec.rb
index 7aa8a761fe..cd839cbb8c 100644
--- a/spec/ruby/core/argf/codepoints_spec.rb
+++ b/spec/ruby/core/argf/codepoints_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_codepoint'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_codepoint', __FILE__)
describe "ARGF.codepoints" do
it_behaves_like :argf_each_codepoint, :codepoints
diff --git a/spec/ruby/core/argf/each_byte_spec.rb b/spec/ruby/core/argf/each_byte_spec.rb
index c5cce9f250..8b4a62c2b1 100644
--- a/spec/ruby/core/argf/each_byte_spec.rb
+++ b/spec/ruby/core/argf/each_byte_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_byte'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_byte', __FILE__)
describe "ARGF.each_byte" do
it_behaves_like :argf_each_byte, :each_byte
diff --git a/spec/ruby/core/argf/each_char_spec.rb b/spec/ruby/core/argf/each_char_spec.rb
index 724e5e6e3e..58ac0bf783 100644
--- a/spec/ruby/core/argf/each_char_spec.rb
+++ b/spec/ruby/core/argf/each_char_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_char'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_char', __FILE__)
describe "ARGF.each_char" do
it_behaves_like :argf_each_char, :each_char
diff --git a/spec/ruby/core/argf/each_codepoint_spec.rb b/spec/ruby/core/argf/each_codepoint_spec.rb
index 0bf8bf9764..d0725841a7 100644
--- a/spec/ruby/core/argf/each_codepoint_spec.rb
+++ b/spec/ruby/core/argf/each_codepoint_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_codepoint'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_codepoint', __FILE__)
describe "ARGF.each_codepoint" do
it_behaves_like :argf_each_codepoint, :each_codepoint
diff --git a/spec/ruby/core/argf/each_line_spec.rb b/spec/ruby/core/argf/each_line_spec.rb
index 52a7e5c411..d37968af3d 100644
--- a/spec/ruby/core/argf/each_line_spec.rb
+++ b/spec/ruby/core/argf/each_line_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_line'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_line', __FILE__)
describe "ARGF.each_line" do
it_behaves_like :argf_each_line, :each_line
diff --git a/spec/ruby/core/argf/each_spec.rb b/spec/ruby/core/argf/each_spec.rb
index 5742ba43bd..5a1e0dc73c 100644
--- a/spec/ruby/core/argf/each_spec.rb
+++ b/spec/ruby/core/argf/each_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_line'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_line', __FILE__)
describe "ARGF.each" do
it_behaves_like :argf_each_line, :each
diff --git a/spec/ruby/core/argf/eof_spec.rb b/spec/ruby/core/argf/eof_spec.rb
index 518f6e566e..534bf1f8d8 100644
--- a/spec/ruby/core/argf/eof_spec.rb
+++ b/spec/ruby/core/argf/eof_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eof'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eof', __FILE__)
describe "ARGF.eof" do
it_behaves_like :argf_eof, :eof
diff --git a/spec/ruby/core/argf/file_spec.rb b/spec/ruby/core/argf/file_spec.rb
index df8552d457..248ffeff17 100644
--- a/spec/ruby/core/argf/file_spec.rb
+++ b/spec/ruby/core/argf/file_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.file" do
before :each do
diff --git a/spec/ruby/core/argf/filename_spec.rb b/spec/ruby/core/argf/filename_spec.rb
index 7c0446269d..f7ebafa7c5 100644
--- a/spec/ruby/core/argf/filename_spec.rb
+++ b/spec/ruby/core/argf/filename_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/filename'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/filename', __FILE__)
describe "ARGF.filename" do
it_behaves_like :argf_filename, :filename
diff --git a/spec/ruby/core/argf/fileno_spec.rb b/spec/ruby/core/argf/fileno_spec.rb
index 29d50c3582..b35047695c 100644
--- a/spec/ruby/core/argf/fileno_spec.rb
+++ b/spec/ruby/core/argf/fileno_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/fileno'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/fileno', __FILE__)
describe "ARGF.fileno" do
it_behaves_like :argf_fileno, :fileno
diff --git a/spec/ruby/core/argf/getc_spec.rb b/spec/ruby/core/argf/getc_spec.rb
index dc5de9b7df..de5e6fa73c 100644
--- a/spec/ruby/core/argf/getc_spec.rb
+++ b/spec/ruby/core/argf/getc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/getc'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/getc', __FILE__)
describe "ARGF.getc" do
it_behaves_like :argf_getc, :getc
diff --git a/spec/ruby/core/argf/gets_spec.rb b/spec/ruby/core/argf/gets_spec.rb
index cc7673b190..b65aa076bd 100644
--- a/spec/ruby/core/argf/gets_spec.rb
+++ b/spec/ruby/core/argf/gets_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gets'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gets', __FILE__)
describe "ARGF.gets" do
it_behaves_like :argf_gets, :gets
@@ -26,23 +26,25 @@ describe "ARGF.gets" do
end
end
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
+ with_feature :encoding do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- Encoding.default_external = Encoding::UTF_8
- Encoding.default_internal = nil
- end
+ Encoding.default_external = Encoding::UTF_8
+ Encoding.default_internal = nil
+ end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+ end
- it "reads the contents of the file with default encoding" do
- Encoding.default_external = Encoding::US_ASCII
- argf [@file1_name, @file2_name] do
- @argf.gets.encoding.should == Encoding::US_ASCII
+ it "reads the contents of the file with default encoding" do
+ Encoding.default_external = Encoding::US_ASCII
+ argf [@file1_name, @file2_name] do
+ @argf.gets.encoding.should == Encoding::US_ASCII
+ end
end
end
diff --git a/spec/ruby/core/argf/lineno_spec.rb b/spec/ruby/core/argf/lineno_spec.rb
index 72a108c187..13b1916fb1 100644
--- a/spec/ruby/core/argf/lineno_spec.rb
+++ b/spec/ruby/core/argf/lineno_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.lineno" do
before :each do
diff --git a/spec/ruby/core/argf/lines_spec.rb b/spec/ruby/core/argf/lines_spec.rb
index 6ca6ff1256..ea3578e3a2 100644
--- a/spec/ruby/core/argf/lines_spec.rb
+++ b/spec/ruby/core/argf/lines_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/each_line'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each_line', __FILE__)
describe "ARGF.lines" do
it_behaves_like :argf_each_line, :lines
diff --git a/spec/ruby/core/argf/path_spec.rb b/spec/ruby/core/argf/path_spec.rb
index 7120f7d0e3..098de8693a 100644
--- a/spec/ruby/core/argf/path_spec.rb
+++ b/spec/ruby/core/argf/path_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/filename'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/filename', __FILE__)
describe "ARGF.path" do
it_behaves_like :argf_filename, :path
diff --git a/spec/ruby/core/argf/pos_spec.rb b/spec/ruby/core/argf/pos_spec.rb
index fb3f25b945..b6e5c3a254 100644
--- a/spec/ruby/core/argf/pos_spec.rb
+++ b/spec/ruby/core/argf/pos_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "ARGF.pos" do
it_behaves_like :argf_pos, :pos
diff --git a/spec/ruby/core/argf/read_nonblock_spec.rb b/spec/ruby/core/argf/read_nonblock_spec.rb
index 804a459a62..8176a206e5 100644
--- a/spec/ruby/core/argf/read_nonblock_spec.rb
+++ b/spec/ruby/core/argf/read_nonblock_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/read'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/read', __FILE__)
platform_is_not :windows do
describe 'ARGF.read_nonblock' do
@@ -64,15 +64,17 @@ platform_is_not :windows do
it 'raises IO::EAGAINWaitReadable when empty' do
argf ['-'] do
- -> {
+ lambda {
@argf.read_nonblock(4)
}.should raise_error(IO::EAGAINWaitReadable)
end
end
- it 'returns :wait_readable when the :exception is set to false' do
- argf ['-'] do
- @argf.read_nonblock(4, nil, exception: false).should == :wait_readable
+ ruby_version_is "2.3" do
+ it 'returns :wait_readable when the :exception is set to false' do
+ argf ['-'] do
+ @argf.read_nonblock(4, nil, exception: false).should == :wait_readable
+ end
end
end
end
diff --git a/spec/ruby/core/argf/read_spec.rb b/spec/ruby/core/argf/read_spec.rb
index bbeef95456..4eaaea46bb 100644
--- a/spec/ruby/core/argf/read_spec.rb
+++ b/spec/ruby/core/argf/read_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/read'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/read', __FILE__)
describe "ARGF.read" do
it_behaves_like :argf_read, :read
@@ -62,24 +62,26 @@ describe "ARGF.read" do
end
end
+ with_feature :encoding do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- Encoding.default_external = Encoding::UTF_8
- Encoding.default_internal = nil
- end
+ Encoding.default_external = Encoding::UTF_8
+ Encoding.default_internal = nil
+ end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+ end
- it "reads the contents of the file with default encoding" do
- Encoding.default_external = Encoding::US_ASCII
- argf [@file1_name, @file2_name] do
- @argf.read.encoding.should == Encoding::US_ASCII
+ it "reads the contents of the file with default encoding" do
+ Encoding.default_external = Encoding::US_ASCII
+ argf [@file1_name, @file2_name] do
+ @argf.read.encoding.should == Encoding::US_ASCII
+ end
end
end
end
diff --git a/spec/ruby/core/argf/readchar_spec.rb b/spec/ruby/core/argf/readchar_spec.rb
index 4eca2efcf7..71e2a6c742 100644
--- a/spec/ruby/core/argf/readchar_spec.rb
+++ b/spec/ruby/core/argf/readchar_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/getc'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/getc', __FILE__)
describe "ARGF.getc" do
it_behaves_like :argf_getc, :readchar
@@ -13,7 +13,7 @@ describe "ARGF.readchar" do
it "raises EOFError when end of stream reached" do
argf [@file1, @file2] do
- -> { while @argf.readchar; end }.should raise_error(EOFError)
+ lambda { while @argf.readchar; end }.should raise_error(EOFError)
end
end
end
diff --git a/spec/ruby/core/argf/readline_spec.rb b/spec/ruby/core/argf/readline_spec.rb
index db53c499e9..d31cfce415 100644
--- a/spec/ruby/core/argf/readline_spec.rb
+++ b/spec/ruby/core/argf/readline_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gets'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gets', __FILE__)
describe "ARGF.readline" do
it_behaves_like :argf_gets, :readline
@@ -17,7 +17,7 @@ describe "ARGF.readline" do
it "raises an EOFError when reaching end of files" do
argf [@file1, @file2] do
- -> { while @argf.readline; end }.should raise_error(EOFError)
+ lambda { while @argf.readline; end }.should raise_error(EOFError)
end
end
end
diff --git a/spec/ruby/core/argf/readlines_spec.rb b/spec/ruby/core/argf/readlines_spec.rb
index 30be936dab..8e68429aa8 100644
--- a/spec/ruby/core/argf/readlines_spec.rb
+++ b/spec/ruby/core/argf/readlines_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/readlines'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/readlines', __FILE__)
describe "ARGF.readlines" do
it_behaves_like :argf_readlines, :readlines
diff --git a/spec/ruby/core/argf/readpartial_spec.rb b/spec/ruby/core/argf/readpartial_spec.rb
index 5e284b3423..61c330182c 100644
--- a/spec/ruby/core/argf/readpartial_spec.rb
+++ b/spec/ruby/core/argf/readpartial_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/read'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/read', __FILE__)
describe "ARGF.readpartial" do
it_behaves_like :argf_read, :readpartial
@@ -16,7 +16,7 @@ describe "ARGF.readpartial" do
it "raises an ArgumentError if called without a maximum read length" do
argf [@file1_name] do
- -> { @argf.readpartial }.should raise_error(ArgumentError)
+ lambda { @argf.readpartial }.should raise_error(ArgumentError)
end
end
@@ -54,13 +54,15 @@ describe "ARGF.readpartial" do
end
end
- it "raises an EOFError if the exception was raised while reading the last file" do
- argf [@file1_name, @file2_name] do
- @argf.readpartial(@file1.size)
- @argf.readpartial(1)
- @argf.readpartial(@file2.size)
- -> { @argf.readpartial(1) }.should raise_error(EOFError)
- -> { @argf.readpartial(1) }.should raise_error(EOFError)
+ ruby_version_is "2.3" do
+ it "raises an EOFError if the exception was raised while reading the last file" do
+ argf [@file1_name, @file2_name] do
+ @argf.readpartial(@file1.size)
+ @argf.readpartial(1)
+ @argf.readpartial(@file2.size)
+ lambda { @argf.readpartial(1) }.should raise_error(EOFError)
+ lambda { @argf.readpartial(1) }.should raise_error(EOFError)
+ end
end
end
diff --git a/spec/ruby/core/argf/rewind_spec.rb b/spec/ruby/core/argf/rewind_spec.rb
index b29f0b75b7..d6abc3a856 100644
--- a/spec/ruby/core/argf/rewind_spec.rb
+++ b/spec/ruby/core/argf/rewind_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.rewind" do
before :each do
@@ -33,7 +33,7 @@ describe "ARGF.rewind" do
it "raises an ArgumentError when end of stream reached" do
argf [@file1_name, @file2_name] do
@argf.read
- -> { @argf.rewind }.should raise_error(ArgumentError)
+ lambda { @argf.rewind }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/argf/seek_spec.rb b/spec/ruby/core/argf/seek_spec.rb
index 2b73bd46fb..97dacb6cfc 100644
--- a/spec/ruby/core/argf/seek_spec.rb
+++ b/spec/ruby/core/argf/seek_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.seek" do
before :each do
@@ -57,7 +57,7 @@ describe "ARGF.seek" do
it "takes at least one argument (offset)" do
argf [@file1_name] do
- -> { @argf.seek }.should raise_error(ArgumentError)
+ lambda { @argf.seek }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/argf/set_encoding_spec.rb b/spec/ruby/core/argf/set_encoding_spec.rb
index a871e084b6..f6ec74ded1 100644
--- a/spec/ruby/core/argf/set_encoding_spec.rb
+++ b/spec/ruby/core/argf/set_encoding_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.set_encoding" do
before :each do
diff --git a/spec/ruby/core/argf/shared/eof.rb b/spec/ruby/core/argf/shared/eof.rb
index 0e684f943f..bba18ede50 100644
--- a/spec/ruby/core/argf/shared/eof.rb
+++ b/spec/ruby/core/argf/shared/eof.rb
@@ -18,7 +18,7 @@ describe :argf_eof, shared: true do
it "raises IOError when called on a closed stream" do
argf [@file1] do
@argf.read
- -> { @argf.send(@method) }.should raise_error(IOError)
+ lambda { @argf.send(@method) }.should raise_error(IOError)
end
end
end
diff --git a/spec/ruby/core/argf/shared/fileno.rb b/spec/ruby/core/argf/shared/fileno.rb
index 5d674048e2..891e250ad9 100644
--- a/spec/ruby/core/argf/shared/fileno.rb
+++ b/spec/ruby/core/argf/shared/fileno.rb
@@ -18,7 +18,7 @@ describe :argf_fileno, shared: true do
it "raises an ArgumentError when called on a closed stream" do
argf [@file1] do
@argf.read
- -> { @argf.send(@method) }.should raise_error(ArgumentError)
+ lambda { @argf.send(@method) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/argf/shared/pos.rb b/spec/ruby/core/argf/shared/pos.rb
index 9836d5f1e4..f7184f3d7c 100644
--- a/spec/ruby/core/argf/shared/pos.rb
+++ b/spec/ruby/core/argf/shared/pos.rb
@@ -25,7 +25,7 @@ describe :argf_pos, shared: true do
it "raises an ArgumentError when called on a closed stream" do
argf [@file1] do
@argf.read
- -> { @argf.send(@method) }.should raise_error(ArgumentError)
+ lambda { @argf.send(@method) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/argf/skip_spec.rb b/spec/ruby/core/argf/skip_spec.rb
index 0181801c2d..5f5e9eb79a 100644
--- a/spec/ruby/core/argf/skip_spec.rb
+++ b/spec/ruby/core/argf/skip_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.skip" do
before :each do
@@ -37,6 +37,6 @@ describe "ARGF.skip" do
# which as a side-effect calls argf.file which will initialize
# internals of ARGF enough for this to work.
it "has no effect when nothing has been processed yet" do
- -> { ARGF.class.new(@file1_name).skip }.should_not raise_error
+ lambda { ARGF.class.new(@file1_name).skip }.should_not raise_error
end
end
diff --git a/spec/ruby/core/argf/tell_spec.rb b/spec/ruby/core/argf/tell_spec.rb
index 16d9f29920..bcd824f087 100644
--- a/spec/ruby/core/argf/tell_spec.rb
+++ b/spec/ruby/core/argf/tell_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "ARGF.tell" do
it_behaves_like :argf_pos, :tell
diff --git a/spec/ruby/core/argf/to_a_spec.rb b/spec/ruby/core/argf/to_a_spec.rb
index b17a93db33..75b5c10c9b 100644
--- a/spec/ruby/core/argf/to_a_spec.rb
+++ b/spec/ruby/core/argf/to_a_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/readlines'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/readlines', __FILE__)
describe "ARGF.to_a" do
it_behaves_like :argf_readlines, :to_a
diff --git a/spec/ruby/core/argf/to_i_spec.rb b/spec/ruby/core/argf/to_i_spec.rb
index 2183de6cd4..27359014af 100644
--- a/spec/ruby/core/argf/to_i_spec.rb
+++ b/spec/ruby/core/argf/to_i_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/fileno'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/fileno', __FILE__)
describe "ARGF.to_i" do
it_behaves_like :argf_fileno, :to_i
diff --git a/spec/ruby/core/argf/to_io_spec.rb b/spec/ruby/core/argf/to_io_spec.rb
index 062383d291..0575c35f25 100644
--- a/spec/ruby/core/argf/to_io_spec.rb
+++ b/spec/ruby/core/argf/to_io_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.to_io" do
before :each do
diff --git a/spec/ruby/core/argf/to_s_spec.rb b/spec/ruby/core/argf/to_s_spec.rb
index 3f505898f4..0128049c3f 100644
--- a/spec/ruby/core/argf/to_s_spec.rb
+++ b/spec/ruby/core/argf/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ARGF.to_s" do
before :each do
diff --git a/spec/ruby/core/array/allocate_spec.rb b/spec/ruby/core/array/allocate_spec.rb
index 04f7c0d0ad..bb5168cb74 100644
--- a/spec/ruby/core/array/allocate_spec.rb
+++ b/spec/ruby/core/array/allocate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array.allocate" do
it "returns an instance of Array" do
@@ -14,6 +14,6 @@ describe "Array.allocate" do
end
it "does not accept any arguments" do
- -> { Array.allocate(1) }.should raise_error(ArgumentError)
+ lambda { Array.allocate(1) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/array/any_spec.rb b/spec/ruby/core/array/any_spec.rb
index 2fa5353e99..7e9863420f 100644
--- a/spec/ruby/core/array/any_spec.rb
+++ b/spec/ruby/core/array/any_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#any?" do
describe 'with no block given (a default block of { |x| x } is implicit)' do
diff --git a/spec/ruby/core/array/append_spec.rb b/spec/ruby/core/array/append_spec.rb
index 302dc4a901..90e1688c5a 100644
--- a/spec/ruby/core/array/append_spec.rb
+++ b/spec/ruby/core/array/append_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/push'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/push', __FILE__)
describe "Array#<<" do
it "pushes the object onto the end of the array" do
@@ -30,13 +30,13 @@ describe "Array#<<" do
a.should == [:foo]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array << 5 }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array << 5 }.should raise_error(RuntimeError)
end
end
ruby_version_is "2.5" do
describe "Array#append" do
- it_behaves_like :array_push, :append
+ it_behaves_like(:array_push, :append)
end
end
diff --git a/spec/ruby/core/array/array_spec.rb b/spec/ruby/core/array/array_spec.rb
index 855f17348f..186bd40f10 100644
--- a/spec/ruby/core/array/array_spec.rb
+++ b/spec/ruby/core/array/array_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array" do
it "includes Enumerable" do
diff --git a/spec/ruby/core/array/assoc_spec.rb b/spec/ruby/core/array/assoc_spec.rb
index f8479d763c..37b0357806 100644
--- a/spec/ruby/core/array/assoc_spec.rb
+++ b/spec/ruby/core/array/assoc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#assoc" do
it "returns the first array whose 1st item is == obj or nil" do
diff --git a/spec/ruby/core/array/at_spec.rb b/spec/ruby/core/array/at_spec.rb
index 8bc789fef7..f2af0e13a1 100644
--- a/spec/ruby/core/array/at_spec.rb
+++ b/spec/ruby/core/array/at_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#at" do
it "returns the (n+1)'th element for the passed index n" do
@@ -47,10 +47,10 @@ describe "Array#at" do
end
it "raises a TypeError when the passed argument can't be coerced to Integer" do
- -> { [].at("cat") }.should raise_error(TypeError)
+ lambda { [].at("cat") }.should raise_error(TypeError)
end
it "raises an ArgumentError when 2 or more arguments are passed" do
- -> { [:a, :b].at(0,1) }.should raise_error(ArgumentError)
+ lambda { [:a, :b].at(0,1) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/array/bsearch_index_spec.rb b/spec/ruby/core/array/bsearch_index_spec.rb
index aafded178d..1ed11876b4 100644
--- a/spec/ruby/core/array/bsearch_index_spec.rb
+++ b/spec/ruby/core/array/bsearch_index_spec.rb
@@ -1,84 +1,86 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "Array#bsearch_index" do
+ context "when not passed a block" do
+ before :each do
+ @enum = [1, 2, 42, 100, 666].bsearch_index
+ end
-describe "Array#bsearch_index" do
- context "when not passed a block" do
- before :each do
- @enum = [1, 2, 42, 100, 666].bsearch_index
- end
+ it "returns an Enumerator" do
+ @enum.should be_an_instance_of(Enumerator)
+ end
- it "returns an Enumerator" do
- @enum.should be_an_instance_of(Enumerator)
- end
+ it "returns an Enumerator with unknown size" do
+ @enum.size.should be_nil
+ end
- it "returns an Enumerator with unknown size" do
- @enum.size.should be_nil
+ it "returns index of element when block condition is satisfied" do
+ @enum.each { |x| x >= 33 }.should == 2
+ end
end
- it "returns index of element when block condition is satisfied" do
- @enum.each { |x| x >= 33 }.should == 2
+ it "raises a TypeError when block returns a String" do
+ lambda { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError)
end
- end
- it "raises a TypeError when block returns a String" do
- -> { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError)
- end
-
- it "returns nil when block is empty" do
- [1, 2, 3].bsearch_index {}.should be_nil
- end
-
- context "minimum mode" do
- before :each do
- @array = [0, 4, 7, 10, 12]
+ it "returns nil when block is empty" do
+ [1, 2, 3].bsearch_index {}.should be_nil
end
- it "returns index of first element which satisfies the block" do
- @array.bsearch_index { |x| x >= 4 }.should == 1
- @array.bsearch_index { |x| x >= 6 }.should == 2
- @array.bsearch_index { |x| x >= -1 }.should == 0
- end
-
- it "returns nil when block condition is never satisfied" do
- @array.bsearch_index { false }.should be_nil
- @array.bsearch_index { |x| x >= 100 }.should be_nil
- end
- end
-
- context "find any mode" do
- before :each do
- @array = [0, 4, 7, 10, 12]
- end
+ context "minimum mode" do
+ before :each do
+ @array = [0, 4, 7, 10, 12]
+ end
- it "returns the index of any matched elements where element is between 4 <= x < 8" do
- [1, 2].should include(@array.bsearch_index { |x| 1 - x / 4 })
- end
+ it "returns index of first element which satisfies the block" do
+ @array.bsearch_index { |x| x >= 4 }.should == 1
+ @array.bsearch_index { |x| x >= 6 }.should == 2
+ @array.bsearch_index { |x| x >= -1 }.should == 0
+ end
- it "returns the index of any matched elements where element is between 8 <= x < 10" do
- @array.bsearch_index { |x| 4 - x / 2 }.should be_nil
+ it "returns nil when block condition is never satisfied" do
+ @array.bsearch_index { false }.should be_nil
+ @array.bsearch_index { |x| x >= 100 }.should be_nil
+ end
end
- it "returns nil when block never returns 0" do
- @array.bsearch_index { |x| 1 }.should be_nil
- @array.bsearch_index { |x| -1 }.should be_nil
- end
+ context "find any mode" do
+ before :each do
+ @array = [0, 4, 7, 10, 12]
+ end
- it "returns the middle element when block always returns zero" do
- @array.bsearch_index { |x| 0 }.should == 2
- end
+ it "returns the index of any matched elements where element is between 4 <= x < 8" do
+ [1, 2].should include(@array.bsearch_index { |x| 1 - x / 4 })
+ end
- context "magnitude does not effect the result" do
- it "returns the index of any matched elements where element is between 4n <= xn < 8n" do
- [1, 2].should include(@array.bsearch_index { |x| (1 - x / 4) * (2**100) })
+ it "returns the index of any matched elements where element is between 8 <= x < 10" do
+ @array.bsearch_index { |x| 4 - x / 2 }.should be_nil
end
it "returns nil when block never returns 0" do
- @array.bsearch_index { |x| 1 * (2**100) }.should be_nil
- @array.bsearch_index { |x| (-1) * (2**100) }.should be_nil
+ @array.bsearch_index { |x| 1 }.should be_nil
+ @array.bsearch_index { |x| -1 }.should be_nil
end
- it "handles values from Bignum#coerce" do
- [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first })
+ it "returns the middle element when block always returns zero" do
+ @array.bsearch_index { |x| 0 }.should == 2
+ end
+
+ context "magnitude does not effect the result" do
+ it "returns the index of any matched elements where element is between 4n <= xn < 8n" do
+ [1, 2].should include(@array.bsearch_index { |x| (1 - x / 4) * (2**100) })
+ end
+
+ it "returns nil when block never returns 0" do
+ @array.bsearch_index { |x| 1 * (2**100) }.should be_nil
+ @array.bsearch_index { |x| (-1) * (2**100) }.should be_nil
+ end
+
+ it "handles values from Bignum#coerce" do
+ [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first })
+ end
end
end
end
diff --git a/spec/ruby/core/array/bsearch_spec.rb b/spec/ruby/core/array/bsearch_spec.rb
index 8fa6245dbf..71e945f390 100644
--- a/spec/ruby/core/array/bsearch_spec.rb
+++ b/spec/ruby/core/array/bsearch_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Array#bsearch" do
it "returns an Enumerator when not passed a block" do
@@ -9,11 +9,11 @@ describe "Array#bsearch" do
it_behaves_like :enumeratorized_with_unknown_size, :bsearch, [1,2,3]
it "raises a TypeError if the block returns an Object" do
- -> { [1].bsearch { Object.new } }.should raise_error(TypeError)
+ lambda { [1].bsearch { Object.new } }.should raise_error(TypeError)
end
it "raises a TypeError if the block returns a String" do
- -> { [1].bsearch { "1" } }.should raise_error(TypeError)
+ lambda { [1].bsearch { "1" } }.should raise_error(TypeError)
end
context "with a block returning true or false" do
diff --git a/spec/ruby/core/array/clear_spec.rb b/spec/ruby/core/array/clear_spec.rb
index d399d5a373..851c90d654 100644
--- a/spec/ruby/core/array/clear_spec.rb
+++ b/spec/ruby/core/array/clear_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#clear" do
it "removes all elements" do
@@ -10,7 +10,8 @@ describe "Array#clear" do
it "returns self" do
a = [1]
- a.should equal a.clear
+ oid = a.object_id
+ a.clear.object_id.should == oid
end
it "leaves the Array empty" do
@@ -20,33 +21,29 @@ describe "Array#clear" do
a.size.should == 0
end
- ruby_version_is ''...'2.7' do
- it "keeps tainted status" do
- a = [1]
- a.taint
- a.tainted?.should be_true
- a.clear
- a.tainted?.should be_true
- end
+ it "keeps tainted status" do
+ a = [1]
+ a.taint
+ a.tainted?.should be_true
+ a.clear
+ a.tainted?.should be_true
end
it "does not accept any arguments" do
- -> { [1].clear(true) }.should raise_error(ArgumentError)
+ lambda { [1].clear(true) }.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "keeps untrusted status" do
- a = [1]
- a.untrust
- a.untrusted?.should be_true
- a.clear
- a.untrusted?.should be_true
- end
+ it "keeps untrusted status" do
+ a = [1]
+ a.untrust
+ a.untrusted?.should be_true
+ a.clear
+ a.untrusted?.should be_true
end
- it "raises a #{frozen_error_class} on a frozen array" do
+ it "raises a RuntimeError on a frozen array" do
a = [1]
a.freeze
- -> { a.clear }.should raise_error(frozen_error_class)
+ lambda { a.clear }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/clone_spec.rb b/spec/ruby/core/array/clone_spec.rb
index 803e746e02..c88e10337f 100644
--- a/spec/ruby/core/array/clone_spec.rb
+++ b/spec/ruby/core/array/clone_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/clone'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/clone', __FILE__)
describe "Array#clone" do
it_behaves_like :array_clone, :clone
diff --git a/spec/ruby/core/array/collect_spec.rb b/spec/ruby/core/array/collect_spec.rb
index 0ad4c283b1..1c2c28c6bd 100644
--- a/spec/ruby/core/array/collect_spec.rb
+++ b/spec/ruby/core/array/collect_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/collect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Array#collect" do
- it_behaves_like :array_collect, :collect
+ it_behaves_like(:array_collect, :collect)
end
describe "Array#collect!" do
- it_behaves_like :array_collect_b, :collect!
+ it_behaves_like(:array_collect_b, :collect!)
end
diff --git a/spec/ruby/core/array/combination_spec.rb b/spec/ruby/core/array/combination_spec.rb
index f16d6f98fc..7869783d1e 100644
--- a/spec/ruby/core/array/combination_spec.rb
+++ b/spec/ruby/core/array/combination_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#combination" do
before :each do
@@ -58,7 +58,7 @@ describe "Array#combination" do
@array.combination(-1).size.should == 0
[].combination(-2).size.should == 0
end
- it "returns the binomial coefficient between the array size the number of combinations" do
+ it "returns the binomial coeficient between the array size the number of combinations" do
@array.combination(5).size.should == 0
@array.combination(4).size.should == 1
@array.combination(3).size.should == 4
diff --git a/spec/ruby/core/array/compact_spec.rb b/spec/ruby/core/array/compact_spec.rb
index ee3dfc0ca2..b80f0214ec 100644
--- a/spec/ruby/core/array/compact_spec.rb
+++ b/spec/ruby/core/array/compact_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#compact" do
it "returns a copy of array with all nil elements removed" do
@@ -22,18 +22,16 @@ describe "Array#compact" do
ArraySpecs::MyArray[1, 2, 3, nil].compact.should be_an_instance_of(Array)
end
- ruby_version_is ''...'2.7' do
- it "does not keep tainted status even if all elements are removed" do
- a = [nil, nil]
- a.taint
- a.compact.tainted?.should be_false
- end
+ it "does not keep tainted status even if all elements are removed" do
+ a = [nil, nil]
+ a.taint
+ a.compact.tainted?.should be_false
+ end
- it "does not keep untrusted status even if all elements are removed" do
- a = [nil, nil]
- a.untrust
- a.compact.untrusted?.should be_false
- end
+ it "does not keep untrusted status even if all elements are removed" do
+ a = [nil, nil]
+ a.untrust
+ a.compact.untrusted?.should be_false
end
end
@@ -52,30 +50,28 @@ describe "Array#compact!" do
it "returns self if some nil elements are removed" do
a = ['a', nil, 'b', false, 'c']
- a.compact!.should equal a
+ a.compact!.object_id.should == a.object_id
end
it "returns nil if there are no nil elements to remove" do
[1, 2, false, 3].compact!.should == nil
end
- ruby_version_is ''...'2.7' do
- it "keeps tainted status even if all elements are removed" do
- a = [nil, nil]
- a.taint
- a.compact!
- a.tainted?.should be_true
- end
+ it "keeps tainted status even if all elements are removed" do
+ a = [nil, nil]
+ a.taint
+ a.compact!
+ a.tainted?.should be_true
+ end
- it "keeps untrusted status even if all elements are removed" do
- a = [nil, nil]
- a.untrust
- a.compact!
- a.untrusted?.should be_true
- end
+ it "keeps untrusted status even if all elements are removed" do
+ a = [nil, nil]
+ a.untrust
+ a.compact!
+ a.untrusted?.should be_true
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.compact! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.compact! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/comparison_spec.rb b/spec/ruby/core/array/comparison_spec.rb
index 5d1c3265f1..e5a5f4da10 100644
--- a/spec/ruby/core/array/comparison_spec.rb
+++ b/spec/ruby/core/array/comparison_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#<=>" do
it "calls <=> left to right and return first non-0 result" do
diff --git a/spec/ruby/core/array/concat_spec.rb b/spec/ruby/core/array/concat_spec.rb
index b297c091a3..86ec557bde 100644
--- a/spec/ruby/core/array/concat_spec.rb
+++ b/spec/ruby/core/array/concat_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#concat" do
it "returns the array itself" do
@@ -32,71 +32,69 @@ describe "Array#concat" do
[].concat(obj).should == [5, 6, 7]
end
- it "raises a #{frozen_error_class} when Array is frozen and modification occurs" do
- -> { ArraySpecs.frozen_array.concat [1] }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when Array is frozen and modification occurs" do
+ lambda { ArraySpecs.frozen_array.concat [1] }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} when Array is frozen and no modification occurs" do
- -> { ArraySpecs.frozen_array.concat([]) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when Array is frozen and no modification occurs" do
+ lambda { ArraySpecs.frozen_array.concat([]) }.should raise_error(RuntimeError)
end
- ruby_version_is ''...'2.7' do
- it "keeps tainted status" do
- ary = [1, 2]
- ary.taint
- ary.concat([3])
- ary.tainted?.should be_true
- ary.concat([])
- ary.tainted?.should be_true
- end
+ it "keeps tainted status" do
+ ary = [1, 2]
+ ary.taint
+ ary.concat([3])
+ ary.tainted?.should be_true
+ ary.concat([])
+ ary.tainted?.should be_true
+ end
- it "is not infected by the other" do
- ary = [1,2]
- other = [3]; other.taint
- ary.tainted?.should be_false
- ary.concat(other)
- ary.tainted?.should be_false
- end
+ it "is not infected by the other" do
+ ary = [1,2]
+ other = [3]; other.taint
+ ary.tainted?.should be_false
+ ary.concat(other)
+ ary.tainted?.should be_false
+ end
- it "keeps the tainted status of elements" do
- ary = [ Object.new, Object.new, Object.new ]
- ary.each {|x| x.taint }
+ it "keeps the tainted status of elements" do
+ ary = [ Object.new, Object.new, Object.new ]
+ ary.each {|x| x.taint }
- ary.concat([ Object.new ])
- ary[0].tainted?.should be_true
- ary[1].tainted?.should be_true
- ary[2].tainted?.should be_true
- ary[3].tainted?.should be_false
- end
+ ary.concat([ Object.new ])
+ ary[0].tainted?.should be_true
+ ary[1].tainted?.should be_true
+ ary[2].tainted?.should be_true
+ ary[3].tainted?.should be_false
+ end
- it "keeps untrusted status" do
- ary = [1, 2]
- ary.untrust
- ary.concat([3])
- ary.untrusted?.should be_true
- ary.concat([])
- ary.untrusted?.should be_true
- end
+ it "keeps untrusted status" do
+ ary = [1, 2]
+ ary.untrust
+ ary.concat([3])
+ ary.untrusted?.should be_true
+ ary.concat([])
+ ary.untrusted?.should be_true
+ end
- it "is not infected untrustedness by the other" do
- ary = [1,2]
- other = [3]; other.untrust
- ary.untrusted?.should be_false
- ary.concat(other)
- ary.untrusted?.should be_false
- end
+ it "is not infected untrustedness by the other" do
+ ary = [1,2]
+ other = [3]; other.untrust
+ ary.untrusted?.should be_false
+ ary.concat(other)
+ ary.untrusted?.should be_false
+ end
- it "keeps the untrusted status of elements" do
- ary = [ Object.new, Object.new, Object.new ]
- ary.each {|x| x.untrust }
+ it "keeps the untrusted status of elements" do
+ ary = [ Object.new, Object.new, Object.new ]
+ ary.each {|x| x.untrust }
- ary.concat([ Object.new ])
- ary[0].untrusted?.should be_true
- ary[1].untrusted?.should be_true
- ary[2].untrusted?.should be_true
- ary[3].untrusted?.should be_false
- end
+ ary.concat([ Object.new ])
+ ary[0].untrusted?.should be_true
+ ary[1].untrusted?.should be_true
+ ary[2].untrusted?.should be_true
+ ary[3].untrusted?.should be_false
end
it "appends elements to an Array with enough capacity that has been shifted" do
@@ -112,21 +110,23 @@ describe "Array#concat" do
ary.concat([5, 6]).should == [4, 5, 6]
end
- it "takes multiple arguments" do
- ary = [1, 2]
- ary.concat [3, 4]
- ary.should == [1, 2, 3, 4]
- end
+ ruby_version_is "2.4" do
+ it "takes multiple arguments" do
+ ary = [1, 2]
+ ary.concat [3, 4]
+ ary.should == [1, 2, 3, 4]
+ end
- it "concatenates the initial value when given arguments contain 2 self" do
- ary = [1, 2]
- ary.concat ary, ary
- ary.should == [1, 2, 1, 2, 1, 2]
- end
+ it "concatenates the initial value when given arguments contain 2 self" do
+ ary = [1, 2]
+ ary.concat ary, ary
+ ary.should == [1, 2, 1, 2, 1, 2]
+ end
- it "returns self when given no arguments" do
- ary = [1, 2]
- ary.concat.should equal(ary)
- ary.should == [1, 2]
+ it "returns self when given no arguments" do
+ ary = [1, 2]
+ ary.concat.should equal(ary)
+ ary.should == [1, 2]
+ end
end
end
diff --git a/spec/ruby/core/array/constructor_spec.rb b/spec/ruby/core/array/constructor_spec.rb
index 6f36074c45..8ec2e5de1e 100644
--- a/spec/ruby/core/array/constructor_spec.rb
+++ b/spec/ruby/core/array/constructor_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array.[]" do
it "returns a new array populated with the given elements" do
diff --git a/spec/ruby/core/array/count_spec.rb b/spec/ruby/core/array/count_spec.rb
index eaf275aeb7..52314d8579 100644
--- a/spec/ruby/core/array/count_spec.rb
+++ b/spec/ruby/core/array/count_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#count" do
it "returns the number of elements" do
diff --git a/spec/ruby/core/array/cycle_spec.rb b/spec/ruby/core/array/cycle_spec.rb
index 7219b49883..2e60798c8c 100644
--- a/spec/ruby/core/array/cycle_spec.rb
+++ b/spec/ruby/core/array/cycle_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Array#cycle" do
before :each do
ScratchPad.record []
@array = [1, 2, 3]
- @prc = -> x { ScratchPad << x }
+ @prc = lambda { |x| ScratchPad << x }
end
it "does not yield and returns nil when the array is empty and passed value is an integer" do
@@ -46,13 +46,13 @@ describe "Array#cycle" do
end
it "does not rescue StopIteration when not passed a count" do
- -> do
+ lambda do
@array.cycle { raise StopIteration }
end.should raise_error(StopIteration)
end
it "does not rescue StopIteration when passed a count" do
- -> do
+ lambda do
@array.cycle(3) { raise StopIteration }
end.should raise_error(StopIteration)
end
@@ -74,23 +74,23 @@ describe "Array#cycle" do
count = mock("cycle count 2")
count.should_receive(:to_int).and_return("2")
- -> { @array.cycle(count, &@prc) }.should raise_error(TypeError)
+ lambda { @array.cycle(count, &@prc) }.should raise_error(TypeError)
end
it "raises a TypeError if passed a String" do
- -> { @array.cycle("4") { } }.should raise_error(TypeError)
+ lambda { @array.cycle("4") { } }.should raise_error(TypeError)
end
it "raises a TypeError if passed an Object" do
- -> { @array.cycle(mock("cycle count")) { } }.should raise_error(TypeError)
+ lambda { @array.cycle(mock("cycle count")) { } }.should raise_error(TypeError)
end
it "raises a TypeError if passed true" do
- -> { @array.cycle(true) { } }.should raise_error(TypeError)
+ lambda { @array.cycle(true) { } }.should raise_error(TypeError)
end
it "raises a TypeError if passed false" do
- -> { @array.cycle(false) { } }.should raise_error(TypeError)
+ lambda { @array.cycle(false) { } }.should raise_error(TypeError)
end
before :all do
diff --git a/spec/ruby/core/array/delete_at_spec.rb b/spec/ruby/core/array/delete_at_spec.rb
index 0ed56c18bb..1d73ceb33a 100644
--- a/spec/ruby/core/array/delete_at_spec.rb
+++ b/spec/ruby/core/array/delete_at_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#delete_at" do
it "removes the element at the specified index" do
@@ -35,29 +35,27 @@ describe "Array#delete_at" do
a.delete_at(-2).should == 1
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { [1,2,3].freeze.delete_at(0) }.should raise_error(frozen_error_class)
- end
-
- ruby_version_is ''...'2.7' do
- it "keeps tainted status" do
- ary = [1, 2]
- ary.taint
- ary.tainted?.should be_true
- ary.delete_at(0)
- ary.tainted?.should be_true
- ary.delete_at(0) # now empty
- ary.tainted?.should be_true
- end
-
- it "keeps untrusted status" do
- ary = [1, 2]
- ary.untrust
- ary.untrusted?.should be_true
- ary.delete_at(0)
- ary.untrusted?.should be_true
- ary.delete_at(0) # now empty
- ary.untrusted?.should be_true
- end
+ it "raises a RuntimeError on a frozen array" do
+ lambda { [1,2,3].freeze.delete_at(0) }.should raise_error(RuntimeError)
+ end
+
+ it "keeps tainted status" do
+ ary = [1, 2]
+ ary.taint
+ ary.tainted?.should be_true
+ ary.delete_at(0)
+ ary.tainted?.should be_true
+ ary.delete_at(0) # now empty
+ ary.tainted?.should be_true
+ end
+
+ it "keeps untrusted status" do
+ ary = [1, 2]
+ ary.untrust
+ ary.untrusted?.should be_true
+ ary.delete_at(0)
+ ary.untrusted?.should be_true
+ ary.delete_at(0) # now empty
+ ary.untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/array/delete_if_spec.rb b/spec/ruby/core/array/delete_if_spec.rb
index 2312917c41..4276a1fb65 100644
--- a/spec/ruby/core/array/delete_if_spec.rb
+++ b/spec/ruby/core/array/delete_if_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorize'
-require_relative 'shared/delete_if'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorize', __FILE__)
+require File.expand_path('../shared/delete_if', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Array#delete_if" do
before do
@@ -39,28 +39,26 @@ describe "Array#delete_if" do
@a.freeze.delete_if.should be_an_instance_of(Enumerator)
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.delete_if {} }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.delete_if {} }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} on an empty frozen array" do
- -> { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on an empty frozen array" do
+ lambda { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(RuntimeError)
end
- ruby_version_is ''...'2.7' do
- it "keeps tainted status" do
- @a.taint
- @a.tainted?.should be_true
- @a.delete_if{ true }
- @a.tainted?.should be_true
- end
+ it "keeps tainted status" do
+ @a.taint
+ @a.tainted?.should be_true
+ @a.delete_if{ true }
+ @a.tainted?.should be_true
+ end
- it "keeps untrusted status" do
- @a.untrust
- @a.untrusted?.should be_true
- @a.delete_if{ true }
- @a.untrusted?.should be_true
- end
+ it "keeps untrusted status" do
+ @a.untrust
+ @a.untrusted?.should be_true
+ @a.delete_if{ true }
+ @a.untrusted?.should be_true
end
it_behaves_like :enumeratorized_with_origin_size, :delete_if, [1,2,3]
diff --git a/spec/ruby/core/array/delete_spec.rb b/spec/ruby/core/array/delete_spec.rb
index 41e211e660..7b6bf3930c 100644
--- a/spec/ruby/core/array/delete_spec.rb
+++ b/spec/ruby/core/array/delete_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#delete" do
it "removes elements that are #== to object" do
@@ -40,29 +40,27 @@ describe "Array#delete" do
[1, 2, 3].freeze.delete(0).should == nil
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { [1, 2, 3].freeze.delete(1) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { [1, 2, 3].freeze.delete(1) }.should raise_error(RuntimeError)
end
- ruby_version_is ''...'2.7' do
- it "keeps tainted status" do
- a = [1, 2]
- a.taint
- a.tainted?.should be_true
- a.delete(2)
- a.tainted?.should be_true
- a.delete(1) # now empty
- a.tainted?.should be_true
- end
+ it "keeps tainted status" do
+ a = [1, 2]
+ a.taint
+ a.tainted?.should be_true
+ a.delete(2)
+ a.tainted?.should be_true
+ a.delete(1) # now empty
+ a.tainted?.should be_true
+ end
- it "keeps untrusted status" do
- a = [1, 2]
- a.untrust
- a.untrusted?.should be_true
- a.delete(2)
- a.untrusted?.should be_true
- a.delete(1) # now empty
- a.untrusted?.should be_true
- end
+ it "keeps untrusted status" do
+ a = [1, 2]
+ a.untrust
+ a.untrusted?.should be_true
+ a.delete(2)
+ a.untrusted?.should be_true
+ a.delete(1) # now empty
+ a.untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/array/difference_spec.rb b/spec/ruby/core/array/difference_spec.rb
deleted file mode 100644
index a357657967..0000000000
--- a/spec/ruby/core/array/difference_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/difference'
-
-ruby_version_is "2.6" do
- describe "Array#difference" do
- it_behaves_like :array_binary_difference, :difference
-
- it "returns a copy when called without any parameter" do
- x = [1, 2, 3, 2]
- x.difference.should == x
- x.difference.should_not equal x
- end
-
- it "does not return subclass instances for Array subclasses" do
- ArraySpecs::MyArray[1, 2, 3].difference.should be_an_instance_of(Array)
- end
-
- it "accepts multiple arguments" do
- x = [1, 2, 3, 1]
- x.difference([], [0, 1], [3, 4], [3]).should == [2]
- end
- end
-end
diff --git a/spec/ruby/core/array/dig_spec.rb b/spec/ruby/core/array/dig_spec.rb
index f2d8ff47fd..9c20b2d160 100644
--- a/spec/ruby/core/array/dig_spec.rb
+++ b/spec/ruby/core/array/dig_spec.rb
@@ -1,52 +1,54 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+
+ruby_version_is '2.3' do
+ describe "Array#dig" do
+
+ it "returns #at with one arg" do
+ ['a'].dig(0).should == 'a'
+ ['a'].dig(1).should be_nil
+ end
+
+ it "recurses array elements" do
+ a = [ [ 1, [2, '3'] ] ]
+ a.dig(0, 0).should == 1
+ a.dig(0, 1, 1).should == '3'
+ a.dig(0, -1, 0).should == 2
+ end
+
+ it "returns the nested value specified if the sequence includes a key" do
+ a = [42, { foo: :bar }]
+ a.dig(1, :foo).should == :bar
+ end
+
+ it "raises a TypeError for a non-numeric index" do
+ lambda {
+ ['a'].dig(:first)
+ }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError if any intermediate step does not respond to #dig" do
+ a = [1, 2]
+ lambda {
+ a.dig(0, 1)
+ }.should raise_error(TypeError)
+ end
+
+ it "raises an ArgumentError if no arguments provided" do
+ lambda {
+ [10].dig()
+ }.should raise_error(ArgumentError)
+ end
+
+ it "returns nil if any intermediate step is nil" do
+ a = [[1, [2, 3]]]
+ a.dig(1, 2, 3).should == nil
+ end
+
+ it "calls #dig on the result of #at with the remaining arguments" do
+ h = [[nil, [nil, nil, 42]]]
+ h[0].should_receive(:dig).with(1, 2).and_return(42)
+ h.dig(0, 1, 2).should == 42
+ end
-describe "Array#dig" do
-
- it "returns #at with one arg" do
- ['a'].dig(0).should == 'a'
- ['a'].dig(1).should be_nil
- end
-
- it "recurses array elements" do
- a = [ [ 1, [2, '3'] ] ]
- a.dig(0, 0).should == 1
- a.dig(0, 1, 1).should == '3'
- a.dig(0, -1, 0).should == 2
- end
-
- it "returns the nested value specified if the sequence includes a key" do
- a = [42, { foo: :bar }]
- a.dig(1, :foo).should == :bar
- end
-
- it "raises a TypeError for a non-numeric index" do
- -> {
- ['a'].dig(:first)
- }.should raise_error(TypeError)
- end
-
- it "raises a TypeError if any intermediate step does not respond to #dig" do
- a = [1, 2]
- -> {
- a.dig(0, 1)
- }.should raise_error(TypeError)
- end
-
- it "raises an ArgumentError if no arguments provided" do
- -> {
- [10].dig()
- }.should raise_error(ArgumentError)
- end
-
- it "returns nil if any intermediate step is nil" do
- a = [[1, [2, 3]]]
- a.dig(1, 2, 3).should == nil
- end
-
- it "calls #dig on the result of #at with the remaining arguments" do
- h = [[nil, [nil, nil, 42]]]
- h[0].should_receive(:dig).with(1, 2).and_return(42)
- h.dig(0, 1, 2).should == 42
end
-
end
diff --git a/spec/ruby/core/array/drop_spec.rb b/spec/ruby/core/array/drop_spec.rb
index 84ea86b04c..763b45e05a 100644
--- a/spec/ruby/core/array/drop_spec.rb
+++ b/spec/ruby/core/array/drop_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#drop" do
it "removes the specified number of elements from the start of the array" do
@@ -6,7 +6,7 @@ describe "Array#drop" do
end
it "raises an ArgumentError if the number of elements specified is negative" do
- -> { [1, 2].drop(-3) }.should raise_error(ArgumentError)
+ lambda { [1, 2].drop(-3) }.should raise_error(ArgumentError)
end
it "returns an empty Array if all elements are dropped" do
@@ -30,22 +30,4 @@ describe "Array#drop" do
ary.shift
ary.drop(1).should == [2]
end
-
- it "tries to convert the passed argument to an Integer using #to_int" do
- obj = mock("to_int")
- obj.should_receive(:to_int).and_return(2)
-
- [1, 2, 3].drop(obj).should == [3]
- end
-
- it "raises a TypeError when the passed argument can't be coerced to Integer" do
- -> { [1, 2].drop("cat") }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when the passed argument isn't an integer and #to_int returns non-Integer" do
- obj = mock("to_int")
- obj.should_receive(:to_int).and_return("cat")
-
- -> { [1, 2].drop(obj) }.should raise_error(TypeError)
- end
end
diff --git a/spec/ruby/core/array/drop_while_spec.rb b/spec/ruby/core/array/drop_while_spec.rb
index cfb6b1e267..40cc29d6b3 100644
--- a/spec/ruby/core/array/drop_while_spec.rb
+++ b/spec/ruby/core/array/drop_while_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#drop_while" do
it "removes elements from the start of the array while the block evaluates to true" do
diff --git a/spec/ruby/core/array/dup_spec.rb b/spec/ruby/core/array/dup_spec.rb
index 17f467d5fc..01ad12523d 100644
--- a/spec/ruby/core/array/dup_spec.rb
+++ b/spec/ruby/core/array/dup_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/clone'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/clone', __FILE__)
describe "Array#dup" do
it_behaves_like :array_clone, :dup # FIX: no, clone and dup are not alike
diff --git a/spec/ruby/core/array/each_index_spec.rb b/spec/ruby/core/array/each_index_spec.rb
index 51af5842c4..8872c00f8c 100644
--- a/spec/ruby/core/array/each_index_spec.rb
+++ b/spec/ruby/core/array/each_index_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorize'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorize', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
diff --git a/spec/ruby/core/array/each_spec.rb b/spec/ruby/core/array/each_spec.rb
index 256647d61e..a8bac6442e 100644
--- a/spec/ruby/core/array/each_spec.rb
+++ b/spec/ruby/core/array/each_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorize'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorize', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
@@ -27,22 +27,6 @@ describe "Array#each" do
b.should == [2, nil, 4]
end
- it "yields elements added to the end of the array by the block" do
- a = [2]
- iterated = []
- a.each { |x| iterated << x; x.times { a << 0 } }
-
- iterated.should == [2, 0, 0]
- end
-
- it "does not yield elements deleted from the end of the array" do
- a = [2, 3, 1]
- iterated = []
- a.each { |x| iterated << x; a.delete_at(2) if x == 3 }
-
- iterated.should == [2, 3]
- end
-
it_behaves_like :enumeratorize, :each
it_behaves_like :enumeratorized_with_origin_size, :each, [1,2,3]
end
diff --git a/spec/ruby/core/array/element_reference_spec.rb b/spec/ruby/core/array/element_reference_spec.rb
index 31e5578a09..55b6b73d1e 100644
--- a/spec/ruby/core/array/element_reference_spec.rb
+++ b/spec/ruby/core/array/element_reference_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/slice'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/slice', __FILE__)
describe "Array#[]" do
- it_behaves_like :array_slice, :[]
+ it_behaves_like(:array_slice, :[])
end
describe "Array.[]" do
diff --git a/spec/ruby/core/array/element_set_spec.rb b/spec/ruby/core/array/element_set_spec.rb
index 9375ff9b80..6544ad9b6f 100644
--- a/spec/ruby/core/array/element_set_spec.rb
+++ b/spec/ruby/core/array/element_set_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#[]=" do
it "sets the value of the element at index" do
@@ -94,8 +94,8 @@ describe "Array#[]=" do
it "checks frozen before attempting to coerce arguments" do
a = [1,2,3,4].freeze
- -> {a[:foo] = 1}.should raise_error(frozen_error_class)
- -> {a[:foo, :bar] = 1}.should raise_error(frozen_error_class)
+ lambda {a[:foo] = 1}.should raise_error(RuntimeError)
+ lambda {a[:foo, :bar] = 1}.should raise_error(RuntimeError)
end
it "sets elements in the range arguments when passed ranges" do
@@ -195,25 +195,25 @@ describe "Array#[]=" do
a[to .. from] = ["x"]
a.should == [1, "a", "b", "x", "c", 4]
- -> { a["a" .. "b"] = [] }.should raise_error(TypeError)
- -> { a[from .. "b"] = [] }.should raise_error(TypeError)
+ lambda { a["a" .. "b"] = [] }.should raise_error(TypeError)
+ lambda { a[from .. "b"] = [] }.should raise_error(TypeError)
end
it "raises an IndexError when passed indexes out of bounds" do
a = [1, 2, 3, 4]
- -> { a[-5] = "" }.should raise_error(IndexError)
- -> { a[-5, -1] = "" }.should raise_error(IndexError)
- -> { a[-5, 0] = "" }.should raise_error(IndexError)
- -> { a[-5, 1] = "" }.should raise_error(IndexError)
- -> { a[-5, 2] = "" }.should raise_error(IndexError)
- -> { a[-5, 10] = "" }.should raise_error(IndexError)
-
- -> { a[-5..-5] = "" }.should raise_error(RangeError)
- -> { a[-5...-5] = "" }.should raise_error(RangeError)
- -> { a[-5..-4] = "" }.should raise_error(RangeError)
- -> { a[-5...-4] = "" }.should raise_error(RangeError)
- -> { a[-5..10] = "" }.should raise_error(RangeError)
- -> { a[-5...10] = "" }.should raise_error(RangeError)
+ lambda { a[-5] = "" }.should raise_error(IndexError)
+ lambda { a[-5, -1] = "" }.should raise_error(IndexError)
+ lambda { a[-5, 0] = "" }.should raise_error(IndexError)
+ lambda { a[-5, 1] = "" }.should raise_error(IndexError)
+ lambda { a[-5, 2] = "" }.should raise_error(IndexError)
+ lambda { a[-5, 10] = "" }.should raise_error(IndexError)
+
+ lambda { a[-5..-5] = "" }.should raise_error(RangeError)
+ lambda { a[-5...-5] = "" }.should raise_error(RangeError)
+ lambda { a[-5..-4] = "" }.should raise_error(RangeError)
+ lambda { a[-5...-4] = "" }.should raise_error(RangeError)
+ lambda { a[-5..10] = "" }.should raise_error(RangeError)
+ lambda { a[-5...10] = "" }.should raise_error(RangeError)
# ok
a[0..-9] = [1]
@@ -236,8 +236,8 @@ describe "Array#[]=" do
ary.should == [5, 6, 7]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array[0, 0] = [] }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array[0, 0] = [] }.should raise_error(RuntimeError)
end
end
@@ -337,12 +337,12 @@ describe "Array#[]= with [index, count]" do
it "raises an IndexError when passed start and negative length" do
a = [1, 2, 3, 4]
- -> { a[-2, -1] = "" }.should raise_error(IndexError)
- -> { a[0, -1] = "" }.should raise_error(IndexError)
- -> { a[2, -1] = "" }.should raise_error(IndexError)
- -> { a[4, -1] = "" }.should raise_error(IndexError)
- -> { a[10, -1] = "" }.should raise_error(IndexError)
- -> { [1, 2, 3, 4, 5][2, -1] = [7, 8] }.should raise_error(IndexError)
+ lambda { a[-2, -1] = "" }.should raise_error(IndexError)
+ lambda { a[0, -1] = "" }.should raise_error(IndexError)
+ lambda { a[2, -1] = "" }.should raise_error(IndexError)
+ lambda { a[4, -1] = "" }.should raise_error(IndexError)
+ lambda { a[10, -1] = "" }.should raise_error(IndexError)
+ lambda { [1, 2, 3, 4, 5][2, -1] = [7, 8] }.should raise_error(IndexError)
end
end
@@ -350,13 +350,11 @@ describe "Array#[]= with [m..n]" do
it "returns non-array value if non-array value assigned" do
a = [1, 2, 3, 4, 5]
(a[2..4] = 10).should == 10
- (a.[]=(2..4, 10)).should == 10
end
it "returns array if array assigned" do
a = [1, 2, 3, 4, 5]
(a[2..4] = [7, 8]).should == [7, 8]
- (a.[]=(2..4, [7, 8])).should == [7, 8]
end
it "just sets the section defined by range to nil even if the rhs is nil" do
@@ -396,32 +394,15 @@ describe "Array#[]= with [m..n]" do
a.should == [1, 2, 3, 8, 4, 5]
end
- describe "Range subclasses" do
- before :each do
- @range_incl = ArraySpecs::MyRange.new(1, 2)
- @range_excl = ArraySpecs::MyRange.new(-3, -1, true)
- end
-
- it "accepts Range subclasses" do
- a = [1, 2, 3, 4]
-
- a[@range_incl] = ["a", "b"]
- a.should == [1, "a", "b", 4]
- a[@range_excl] = ["A", "B"]
- a.should == [1, "A", "B", 4]
- end
-
- it "returns non-array value if non-array value assigned" do
- a = [1, 2, 3, 4, 5]
- (a[@range_incl] = 10).should == 10
- (a.[]=(@range_incl, 10)).should == 10
- end
+ it "accepts Range subclasses" do
+ a = [1, 2, 3, 4]
+ range_incl = ArraySpecs::MyRange.new(1, 2)
+ range_excl = ArraySpecs::MyRange.new(-3, -1, true)
- it "returns array if array assigned" do
- a = [1, 2, 3, 4, 5]
- (a[@range_incl] = [7, 8]).should == [7, 8]
- a.[]=(@range_incl, [7, 8]).should == [7, 8]
- end
+ a[range_incl] = ["a", "b"]
+ a.should == [1, "a", "b", 4]
+ a[range_excl] = ["A", "B"]
+ a.should == [1, "A", "B", 4]
end
end
diff --git a/spec/ruby/core/array/empty_spec.rb b/spec/ruby/core/array/empty_spec.rb
index b5f3e8ed48..d6235114b7 100644
--- a/spec/ruby/core/array/empty_spec.rb
+++ b/spec/ruby/core/array/empty_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#empty?" do
it "returns true if the array has no elements" do
diff --git a/spec/ruby/core/array/eql_spec.rb b/spec/ruby/core/array/eql_spec.rb
index 8565b94c60..7621316e07 100644
--- a/spec/ruby/core/array/eql_spec.rb
+++ b/spec/ruby/core/array/eql_spec.rb
@@ -1,19 +1,19 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "Array#eql?" do
it_behaves_like :array_eql, :eql?
it "returns false if any corresponding elements are not #eql?" do
- [1, 2, 3, 4].should_not eql([1, 2, 3, 4.0])
+ [1, 2, 3, 4].send(@method, [1, 2, 3, 4.0]).should be_false
end
it "returns false if other is not a kind of Array" do
obj = mock("array eql?")
obj.should_not_receive(:to_ary)
- obj.should_not_receive(:eql?)
+ obj.should_not_receive(@method)
- [1, 2, 3].should_not eql(obj)
+ [1, 2, 3].send(@method, obj).should be_false
end
end
diff --git a/spec/ruby/core/array/equal_value_spec.rb b/spec/ruby/core/array/equal_value_spec.rb
index a82e07b218..d923d0e503 100644
--- a/spec/ruby/core/array/equal_value_spec.rb
+++ b/spec/ruby/core/array/equal_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "Array#==" do
it_behaves_like :array_eql, :==
@@ -44,8 +44,8 @@ describe "Array#==" do
[obj].should == [5]
end
- # See https://bugs.ruby-lang.org/issues/1720
- it "returns true for [NaN] == [NaN] because Array#== first checks with #equal? and NaN.equal?(NaN) is true" do
- [Float::NAN].should == [Float::NAN]
+ # As per bug #1720
+ it "returns false for [NaN] == [NaN]" do
+ [nan_value].should_not == [nan_value]
end
end
diff --git a/spec/ruby/core/array/fetch_spec.rb b/spec/ruby/core/array/fetch_spec.rb
index b81c0b48d7..5adf96fed8 100644
--- a/spec/ruby/core/array/fetch_spec.rb
+++ b/spec/ruby/core/array/fetch_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#fetch" do
it "returns the element at the passed index" do
@@ -12,9 +12,9 @@ describe "Array#fetch" do
end
it "raises an IndexError if there is no element at index" do
- -> { [1, 2, 3].fetch(3) }.should raise_error(IndexError)
- -> { [1, 2, 3].fetch(-4) }.should raise_error(IndexError)
- -> { [].fetch(0) }.should raise_error(IndexError)
+ lambda { [1, 2, 3].fetch(3) }.should raise_error(IndexError)
+ lambda { [1, 2, 3].fetch(-4) }.should raise_error(IndexError)
+ lambda { [].fetch(0) }.should raise_error(IndexError)
end
it "returns default if there is no element at index if passed a default value" do
@@ -37,7 +37,7 @@ describe "Array#fetch" do
end
it "gives precedence to the default block over the default argument" do
- -> {
+ lambda {
@result = [1, 2, 3].fetch(9, :foo) { |i| i * i }
}.should complain(/block supersedes default value argument/)
@result.should == 81
@@ -50,6 +50,6 @@ describe "Array#fetch" do
end
it "raises a TypeError when the passed argument can't be coerced to Integer" do
- -> { [].fetch("cat") }.should raise_error(TypeError)
+ lambda { [].fetch("cat") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/array/fill_spec.rb b/spec/ruby/core/array/fill_spec.rb
index 1c1beef25e..5ff7f8a250 100644
--- a/spec/ruby/core/array/fill_spec.rb
+++ b/spec/ruby/core/array/fill_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#fill" do
before :all do
- @never_passed = -> i do
+ @never_passed = lambda do |i|
raise ExpectationNotMetError, "the control path should not pass here"
end
end
@@ -43,34 +43,34 @@ describe "Array#fill" do
[nil, nil, nil, nil].fill { |i| i * 2 }.should == [0, 2, 4, 6]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.fill('x') }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.fill('x') }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} on an empty frozen array" do
- -> { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on an empty frozen array" do
+ lambda { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(RuntimeError)
end
it "raises an ArgumentError if 4 or more arguments are passed when no block given" do
- -> { [].fill('a') }.should_not raise_error(ArgumentError)
+ lambda { [].fill('a') }.should_not raise_error(ArgumentError)
- -> { [].fill('a', 1) }.should_not raise_error(ArgumentError)
+ lambda { [].fill('a', 1) }.should_not raise_error(ArgumentError)
- -> { [].fill('a', 1, 2) }.should_not raise_error(ArgumentError)
- -> { [].fill('a', 1, 2, true) }.should raise_error(ArgumentError)
+ lambda { [].fill('a', 1, 2) }.should_not raise_error(ArgumentError)
+ lambda { [].fill('a', 1, 2, true) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if no argument passed and no block given" do
- -> { [].fill }.should raise_error(ArgumentError)
+ lambda { [].fill }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if 3 or more arguments are passed when a block given" do
- -> { [].fill() {|i|} }.should_not raise_error(ArgumentError)
+ lambda { [].fill() {|i|} }.should_not raise_error(ArgumentError)
- -> { [].fill(1) {|i|} }.should_not raise_error(ArgumentError)
+ lambda { [].fill(1) {|i|} }.should_not raise_error(ArgumentError)
- -> { [].fill(1, 2) {|i|} }.should_not raise_error(ArgumentError)
- -> { [].fill(1, 2, true) {|i|} }.should raise_error(ArgumentError)
+ lambda { [].fill(1, 2) {|i|} }.should_not raise_error(ArgumentError)
+ lambda { [].fill(1, 2, true) {|i|} }.should raise_error(ArgumentError)
end
end
@@ -171,23 +171,23 @@ describe "Array#fill with (filler, index, length)" do
# See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17481
it "does not raise an exception if the given length is negative and its absolute value does not exceed the index" do
- -> { [1, 2, 3, 4].fill('a', 3, -1)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill('a', 3, -2)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill('a', 3, -3)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill('a', 3, -1)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill('a', 3, -2)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill('a', 3, -3)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill(3, -1, &@never_passed)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill(3, -2, &@never_passed)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill(3, -3, &@never_passed)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill(3, -1, &@never_passed)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill(3, -2, &@never_passed)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill(3, -3, &@never_passed)}.should_not raise_error(ArgumentError)
end
it "does not raise an exception even if the given length is negative and its absolute value exceeds the index" do
- -> { [1, 2, 3, 4].fill('a', 3, -4)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill('a', 3, -5)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill('a', 3, -10000)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill('a', 3, -4)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill('a', 3, -5)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill('a', 3, -10000)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill(3, -4, &@never_passed)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill(3, -5, &@never_passed)}.should_not raise_error(ArgumentError)
- -> { [1, 2, 3, 4].fill(3, -10000, &@never_passed)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill(3, -4, &@never_passed)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill(3, -5, &@never_passed)}.should_not raise_error(ArgumentError)
+ lambda { [1, 2, 3, 4].fill(3, -10000, &@never_passed)}.should_not raise_error(ArgumentError)
end
it "tries to convert the second and third arguments to Integers using #to_int" do
@@ -199,17 +199,17 @@ describe "Array#fill with (filler, index, length)" do
end
it "raises a TypeError if the index is not numeric" do
- -> { [].fill 'a', true }.should raise_error(TypeError)
+ lambda { [].fill 'a', true }.should raise_error(TypeError)
obj = mock('nonnumeric')
- -> { [].fill('a', obj) }.should raise_error(TypeError)
+ lambda { [].fill('a', obj) }.should raise_error(TypeError)
end
not_supported_on :opal do
it "raises an ArgumentError or RangeError for too-large sizes" do
arr = [1, 2, 3]
- -> { arr.fill(10, 1, fixnum_max) }.should raise_error(ArgumentError)
- -> { arr.fill(10, 1, bignum_value) }.should raise_error(RangeError)
+ lambda { arr.fill(10, 1, fixnum_max) }.should raise_error(ArgumentError)
+ lambda { arr.fill(10, 1, bignum_value) }.should raise_error(RangeError)
end
end
end
@@ -239,7 +239,7 @@ describe "Array#fill with (filler, range)" do
end
it "raises a TypeError with range and length argument" do
- -> { [].fill('x', 0 .. 2, 5) }.should raise_error(TypeError)
+ lambda { [].fill('x', 0 .. 2, 5) }.should raise_error(TypeError)
end
it "replaces elements between the (-m)th to the last and the (n+1)th from the first if given an range m..n where m < 0 and n >= 0" do
@@ -291,13 +291,13 @@ describe "Array#fill with (filler, range)" do
end
it "raises an exception if some of the given range lies before the first of the array" do
- -> { [1, 2, 3].fill('x', -5..-3) }.should raise_error(RangeError)
- -> { [1, 2, 3].fill('x', -5...-3) }.should raise_error(RangeError)
- -> { [1, 2, 3].fill('x', -5..-4) }.should raise_error(RangeError)
+ lambda { [1, 2, 3].fill('x', -5..-3) }.should raise_error(RangeError)
+ lambda { [1, 2, 3].fill('x', -5...-3) }.should raise_error(RangeError)
+ lambda { [1, 2, 3].fill('x', -5..-4) }.should raise_error(RangeError)
- -> { [1, 2, 3].fill(-5..-3, &@never_passed) }.should raise_error(RangeError)
- -> { [1, 2, 3].fill(-5...-3, &@never_passed) }.should raise_error(RangeError)
- -> { [1, 2, 3].fill(-5..-4, &@never_passed) }.should raise_error(RangeError)
+ lambda { [1, 2, 3].fill(-5..-3, &@never_passed) }.should raise_error(RangeError)
+ lambda { [1, 2, 3].fill(-5...-3, &@never_passed) }.should raise_error(RangeError)
+ lambda { [1, 2, 3].fill(-5..-4, &@never_passed) }.should raise_error(RangeError)
end
it "tries to convert the start and end of the passed range to Integers using #to_int" do
@@ -312,6 +312,6 @@ describe "Array#fill with (filler, range)" do
it "raises a TypeError if the start or end of the passed range is not numeric" do
obj = mock('nonnumeric')
def obj.<=>(rhs); rhs == self ? 0 : nil end
- -> { [].fill('a', obj..obj) }.should raise_error(TypeError)
+ lambda { [].fill('a', obj..obj) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/array/filter_spec.rb b/spec/ruby/core/array/filter_spec.rb
deleted file mode 100644
index ee4f71ca28..0000000000
--- a/spec/ruby/core/array/filter_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
-
-ruby_version_is "2.6" do
- describe "Array#filter" do
- it_behaves_like :array_select, :filter
- end
-
- describe "Array#filter!" do
- it "returns nil if no changes were made in the array" do
- [1, 2, 3].filter! { true }.should be_nil
- end
-
- it_behaves_like :keep_if, :filter!
- end
-end
diff --git a/spec/ruby/core/array/find_index_spec.rb b/spec/ruby/core/array/find_index_spec.rb
index 759472024a..522b4b31c6 100644
--- a/spec/ruby/core/array/find_index_spec.rb
+++ b/spec/ruby/core/array/find_index_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/index'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/index', __FILE__)
describe "Array#find_index" do
it_behaves_like :array_index, :find_index
diff --git a/spec/ruby/core/array/first_spec.rb b/spec/ruby/core/array/first_spec.rb
index 66eeba6565..60a0a76594 100644
--- a/spec/ruby/core/array/first_spec.rb
+++ b/spec/ruby/core/array/first_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#first" do
it "returns the first element" do
@@ -30,11 +30,11 @@ describe "Array#first" do
end
it "raises an ArgumentError when count is negative" do
- -> { [1, 2].first(-1) }.should raise_error(ArgumentError)
+ lambda { [1, 2].first(-1) }.should raise_error(ArgumentError)
end
it "raises a RangeError when count is a Bignum" do
- -> { [].first(bignum_value) }.should raise_error(RangeError)
+ lambda { [].first(bignum_value) }.should raise_error(RangeError)
end
it "returns the entire array when count > length" do
@@ -66,11 +66,11 @@ describe "Array#first" do
end
it "raises a TypeError if the passed argument is not numeric" do
- -> { [1,2].first(nil) }.should raise_error(TypeError)
- -> { [1,2].first("a") }.should raise_error(TypeError)
+ lambda { [1,2].first(nil) }.should raise_error(TypeError)
+ lambda { [1,2].first("a") }.should raise_error(TypeError)
obj = mock("nonnumeric")
- -> { [1,2].first(obj) }.should raise_error(TypeError)
+ lambda { [1,2].first(obj) }.should raise_error(TypeError)
end
it "does not return subclass instance when passed count on Array subclasses" do
diff --git a/spec/ruby/core/array/fixtures/classes.rb b/spec/ruby/core/array/fixtures/classes.rb
index 42071ed0cd..4292554724 100644
--- a/spec/ruby/core/array/fixtures/classes.rb
+++ b/spec/ruby/core/array/fixtures/classes.rb
@@ -2,10 +2,9 @@ class Object
# This helper is defined here rather than in MSpec because
# it is only used in #pack specs.
def pack_format(count=nil, repeat=nil)
- format = instance_variable_get(:@method)
- format += count.to_s unless format == 'P' || format == 'p'
+ format = "#{instance_variable_get(:@method)}#{count}"
format *= repeat if repeat
- format.dup # because it may then become tainted
+ format
end
end
@@ -14,11 +13,15 @@ module ArraySpecs
SampleCount = 1000
def self.frozen_array
- [1,2,3].freeze
+ frozen_array = [1,2,3]
+ frozen_array.freeze
+ frozen_array
end
def self.empty_frozen_array
- [].freeze
+ frozen_array = []
+ frozen_array.freeze
+ frozen_array
end
def self.recursive_array
@@ -81,7 +84,7 @@ module ArraySpecs
end
end
- class ArrayConvertible
+ class ArrayConvertable
attr_accessor :called
def initialize(*values, &block)
@values = values;
@@ -426,7 +429,7 @@ module ArraySpecs
"assert_no_queries",
"test_change_column_quotes_column_names",
"assert_match",
- "test_keeping_default_and_notnull_constraint_on_change",
+ "test_keeping_default_and_notnull_constaint_on_change",
"methods",
"connection_allow_concurrency_setup",
"connection_allow_concurrency_teardown",
@@ -476,7 +479,7 @@ module ArraySpecs
"test_create_table_without_id",
"test_finds_migrations",
"test_finds_pending_migrations",
- "test_keeping_default_and_notnull_constraint_on_change",
+ "test_keeping_default_and_notnull_constaint_on_change",
"test_migrator",
"test_migrator_db_has_no_schema_migrations_table",
"test_migrator_double_down",
diff --git a/spec/ruby/core/array/fixtures/encoded_strings.rb b/spec/ruby/core/array/fixtures/encoded_strings.rb
index 5b85bd0e06..e31e247afe 100644
--- a/spec/ruby/core/array/fixtures/encoded_strings.rb
+++ b/spec/ruby/core/array/fixtures/encoded_strings.rb
@@ -37,33 +37,33 @@ module ArraySpecs
]
end
- def self.array_with_utf8_and_7bit_binary_strings
+ def self.array_with_utf8_and_7bit_ascii8bit_strings
[
'bar',
'báz',
- 'foo'.force_encoding('BINARY')
+ 'foo'.force_encoding('ASCII-8BIT')
]
end
- def self.array_with_utf8_and_binary_strings
+ def self.array_with_utf8_and_ascii8bit_strings
[
'bar',
'báz',
- [255].pack('C').force_encoding('BINARY')
+ [255].pack('C').force_encoding('ASCII-8BIT')
]
end
- def self.array_with_usascii_and_7bit_binary_strings
+ def self.array_with_usascii_and_7bit_ascii8bit_strings
[
'bar'.force_encoding('US-ASCII'),
- 'foo'.force_encoding('BINARY')
+ 'foo'.force_encoding('ASCII-8BIT')
]
end
- def self.array_with_usascii_and_binary_strings
+ def self.array_with_usascii_and_ascii8bit_strings
[
'bar'.force_encoding('US-ASCII'),
- [255].pack('C').force_encoding('BINARY')
+ [255].pack('C').force_encoding('ASCII-8BIT')
]
end
end
diff --git a/spec/ruby/core/array/flatten_spec.rb b/spec/ruby/core/array/flatten_spec.rb
index 66af20ad70..3b20e976b6 100644
--- a/spec/ruby/core/array/flatten_spec.rb
+++ b/spec/ruby/core/array/flatten_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#flatten" do
it "returns a one-dimensional flattening recursively" do
@@ -30,7 +30,7 @@ describe "Array#flatten" do
it "raises a TypeError when the passed Object can't be converted to an Integer" do
obj = mock("Not converted")
- -> { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should raise_error(TypeError)
+ lambda { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should raise_error(TypeError)
end
it "does not call flatten on elements" do
@@ -46,13 +46,13 @@ describe "Array#flatten" do
it "raises an ArgumentError on recursive arrays" do
x = []
x << x
- -> { x.flatten }.should raise_error(ArgumentError)
+ lambda { x.flatten }.should raise_error(ArgumentError)
x = []
y = []
x << y
y << x
- -> { x.flatten }.should raise_error(ArgumentError)
+ lambda { x.flatten }.should raise_error(ArgumentError)
end
it "flattens any element which responds to #to_ary, using the return value of said method" do
@@ -69,10 +69,12 @@ describe "Array#flatten" do
[1, z, 6].flatten.should == [1, 2, 3, 4, 5, 6]
end
- it "does not call #to_ary on elements beyond the given level" do
- obj = mock("1")
- obj.should_not_receive(:to_ary)
- [[obj]].flatten(1)
+ ruby_version_is "2.3" do
+ it "does not call #to_ary on elements beyond the given level" do
+ obj = mock("1")
+ obj.should_not_receive(:to_ary)
+ [[obj]].flatten(1)
+ end
end
it "returns subclass instance for Array subclasses" do
@@ -106,7 +108,7 @@ describe "Array#flatten" do
it "raises a TypeError if #to_ary does not return an Array" do
@obj.should_receive(:to_ary).and_return(1)
- -> { [@obj].flatten }.should raise_error(TypeError)
+ lambda { [@obj].flatten }.should raise_error(TypeError)
end
ruby_version_is ""..."2.5" do
@@ -135,7 +137,7 @@ describe "Array#flatten" do
it "calls #to_ary if not defined when #respond_to_missing? returns true" do
def @obj.respond_to_missing?(name, priv) ScratchPad << name; true end
- -> { [@obj].flatten }.should raise_error(NoMethodError)
+ lambda { [@obj].flatten }.should raise_error(NoMethodError)
ScratchPad.recorded.should == [:to_ary]
end
@@ -145,14 +147,12 @@ describe "Array#flatten" do
end
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted array if self is tainted" do
- [].taint.flatten.tainted?.should be_true
- end
+ it "returns a tainted array if self is tainted" do
+ [].taint.flatten.tainted?.should be_true
+ end
- it "returns an untrusted array if self is untrusted" do
- [].untrust.flatten.untrusted?.should be_true
- end
+ it "returns an untrusted array if self is untrusted" do
+ [].untrust.flatten.untrusted?.should be_true
end
it "performs respond_to? and method_missing-aware checks when coercing elements to array" do
@@ -228,7 +228,7 @@ describe "Array#flatten!" do
it "raises a TypeError when the passed Object can't be converted to an Integer" do
obj = mock("Not converted")
- -> { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should raise_error(TypeError)
+ lambda { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should raise_error(TypeError)
end
it "does not call flatten! on elements" do
@@ -244,13 +244,13 @@ describe "Array#flatten!" do
it "raises an ArgumentError on recursive arrays" do
x = []
x << x
- -> { x.flatten! }.should raise_error(ArgumentError)
+ lambda { x.flatten! }.should raise_error(ArgumentError)
x = []
y = []
x << y
y << x
- -> { x.flatten! }.should raise_error(ArgumentError)
+ lambda { x.flatten! }.should raise_error(ArgumentError)
end
it "flattens any elements which responds to #to_ary, using the return value of said method" do
@@ -272,15 +272,15 @@ describe "Array#flatten!" do
ary.should == [1, 2, 3]
end
- it "raises a #{frozen_error_class} on frozen arrays when the array is modified" do
+ it "raises a RuntimeError on frozen arrays when the array is modified" do
nested_ary = [1, 2, []]
nested_ary.freeze
- -> { nested_ary.flatten! }.should raise_error(frozen_error_class)
+ lambda { nested_ary.flatten! }.should raise_error(RuntimeError)
end
# see [ruby-core:23663]
- it "raises a #{frozen_error_class} on frozen arrays when the array would not be modified" do
- -> { ArraySpecs.frozen_array.flatten! }.should raise_error(frozen_error_class)
- -> { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on frozen arrays when the array would not be modified" do
+ lambda { ArraySpecs.frozen_array.flatten! }.should raise_error(RuntimeError)
+ lambda { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/frozen_spec.rb b/spec/ruby/core/array/frozen_spec.rb
index bb4b2b4067..6c8384f5f7 100644
--- a/spec/ruby/core/array/frozen_spec.rb
+++ b/spec/ruby/core/array/frozen_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#frozen?" do
it "returns true if array is frozen" do
diff --git a/spec/ruby/core/array/hash_spec.rb b/spec/ruby/core/array/hash_spec.rb
index 8392253ae4..b576cbbdc6 100644
--- a/spec/ruby/core/array/hash_spec.rb
+++ b/spec/ruby/core/array/hash_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#hash" do
it "returns the same fixnum for arrays with the same content" do
@@ -13,10 +13,10 @@ describe "Array#hash" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
- -> { empty.hash }.should_not raise_error
+ lambda { empty.hash }.should_not raise_error
array = ArraySpecs.recursive_array
- -> { array.hash }.should_not raise_error
+ lambda { array.hash }.should_not raise_error
end
it "returns the same hash for equal recursive arrays" do
diff --git a/spec/ruby/core/array/include_spec.rb b/spec/ruby/core/array/include_spec.rb
index 227173218f..26d788afeb 100644
--- a/spec/ruby/core/array/include_spec.rb
+++ b/spec/ruby/core/array/include_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#include?" do
it "returns true if object is present, false otherwise" do
diff --git a/spec/ruby/core/array/index_spec.rb b/spec/ruby/core/array/index_spec.rb
index 3acb7d0ef3..55ed7b2a94 100644
--- a/spec/ruby/core/array/index_spec.rb
+++ b/spec/ruby/core/array/index_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/index'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/index', __FILE__)
describe "Array#index" do
- it_behaves_like :array_index, :index
+ it_behaves_like(:array_index, :index)
end
diff --git a/spec/ruby/core/array/initialize_spec.rb b/spec/ruby/core/array/initialize_spec.rb
index dfc2ae3518..0c37c6136d 100644
--- a/spec/ruby/core/array/initialize_spec.rb
+++ b/spec/ruby/core/array/initialize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#initialize" do
before :each do
@@ -24,21 +24,21 @@ describe "Array#initialize" do
end
it "raises an ArgumentError if passed 3 or more arguments" do
- -> do
+ lambda do
[1, 2].send :initialize, 1, 'x', true
end.should raise_error(ArgumentError)
- -> do
+ lambda do
[1, 2].send(:initialize, 1, 'x', true) {}
end.should raise_error(ArgumentError)
end
- it "raises a #{frozen_error_class} on frozen arrays" do
- -> do
+ it "raises a RuntimeError on frozen arrays" do
+ lambda do
ArraySpecs.frozen_array.send :initialize
- end.should raise_error(frozen_error_class)
- -> do
+ end.should raise_error(RuntimeError)
+ lambda do
ArraySpecs.frozen_array.send :initialize, ArraySpecs.frozen_array
- end.should raise_error(frozen_error_class)
+ end.should raise_error(RuntimeError)
end
it "calls #to_ary to convert the value to an array, even if it's private" do
@@ -53,7 +53,7 @@ describe "Array#initialize with no arguments" do
end
it "does not use the given block" do
- ->{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
+ lambda{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
end
end
@@ -64,7 +64,7 @@ describe "Array#initialize with (array)" do
end
it "does not use the given block" do
- ->{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
+ lambda{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
end
it "calls #to_ary to convert the value to an array" do
@@ -81,7 +81,7 @@ describe "Array#initialize with (array)" do
end
it "raises a TypeError if an Array type argument and a default object" do
- -> { [].send(:initialize, [1, 2], 1) }.should raise_error(TypeError)
+ lambda { [].send(:initialize, [1, 2], 1) }.should raise_error(TypeError)
end
end
@@ -103,12 +103,12 @@ describe "Array#initialize with (size, object=nil)" do
end
it "raises an ArgumentError if size is negative" do
- -> { [].send(:initialize, -1, :a) }.should raise_error(ArgumentError)
- -> { [].send(:initialize, -1) }.should raise_error(ArgumentError)
+ lambda { [].send(:initialize, -1, :a) }.should raise_error(ArgumentError)
+ lambda { [].send(:initialize, -1) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if size is too large" do
- -> { [].send(:initialize, fixnum_max+1) }.should raise_error(ArgumentError)
+ lambda { [].send(:initialize, fixnum_max+1) }.should raise_error(ArgumentError)
end
it "calls #to_int to convert the size argument to an Integer when object is given" do
@@ -126,7 +126,7 @@ describe "Array#initialize with (size, object=nil)" do
it "raises a TypeError if the size argument is not an Integer type" do
obj = mock('nonnumeric')
obj.stub!(:to_ary).and_return([1, 2])
- ->{ [].send(:initialize, obj, :a) }.should raise_error(TypeError)
+ lambda{ [].send(:initialize, obj, :a) }.should raise_error(TypeError)
end
it "yields the index of the element and sets the element to the value of the block" do
@@ -134,7 +134,7 @@ describe "Array#initialize with (size, object=nil)" do
end
it "uses the block value instead of using the default value" do
- -> {
+ lambda {
@result = [].send(:initialize, 3, :obj) { |i| i.to_s }
}.should complain(/block supersedes default value argument/)
@result.should == ['0', '1', '2']
diff --git a/spec/ruby/core/array/insert_spec.rb b/spec/ruby/core/array/insert_spec.rb
index 7577a8f743..cdf870df2a 100644
--- a/spec/ruby/core/array/insert_spec.rb
+++ b/spec/ruby/core/array/insert_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#insert" do
it "returns self" do
@@ -46,8 +46,8 @@ describe "Array#insert" do
end
it "raises an IndexError if the negative index is out of bounds" do
- -> { [].insert(-2, 1) }.should raise_error(IndexError)
- -> { [1].insert(-3, 2) }.should raise_error(IndexError)
+ lambda { [].insert(-2, 1) }.should raise_error(IndexError)
+ lambda { [1].insert(-3, 2) }.should raise_error(IndexError)
end
it "does nothing of no object is passed" do
@@ -64,15 +64,15 @@ describe "Array#insert" do
end
it "raises an ArgumentError if no argument passed" do
- -> { [].insert() }.should raise_error(ArgumentError)
+ lambda { [].insert() }.should raise_error(ArgumentError)
end
- it "raises a #{frozen_error_class} on frozen arrays when the array is modified" do
- -> { ArraySpecs.frozen_array.insert(0, 'x') }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on frozen arrays when the array is modified" do
+ lambda { ArraySpecs.frozen_array.insert(0, 'x') }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on frozen arrays when the array would not be modified" do
- -> { ArraySpecs.frozen_array.insert(0) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on frozen arrays when the array would not be modified" do
+ lambda { ArraySpecs.frozen_array.insert(0) }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/inspect_spec.rb b/spec/ruby/core/array/inspect_spec.rb
index 0832224f5a..9896406fd5 100644
--- a/spec/ruby/core/array/inspect_spec.rb
+++ b/spec/ruby/core/array/inspect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/inspect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "Array#inspect" do
it_behaves_like :array_inspect, :inspect
diff --git a/spec/ruby/core/array/intersection_spec.rb b/spec/ruby/core/array/intersection_spec.rb
index 7bf2ec4dbe..e399509ea7 100644
--- a/spec/ruby/core/array/intersection_spec.rb
+++ b/spec/ruby/core/array/intersection_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#&" do
it "creates an array with elements common to both arrays (intersection)" do
diff --git a/spec/ruby/core/array/join_spec.rb b/spec/ruby/core/array/join_spec.rb
index e78ea6f9e1..c4c6277c87 100644
--- a/spec/ruby/core/array/join_spec.rb
+++ b/spec/ruby/core/array/join_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/join'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/join', __FILE__)
describe "Array#join" do
it_behaves_like :array_join_with_string_separator, :join
@@ -24,11 +24,11 @@ describe "Array#join" do
it "raises a TypeError if the separator cannot be coerced to a String by calling #to_str" do
obj = mock("not a string")
- -> { [1, 2].join(obj) }.should raise_error(TypeError)
+ lambda { [1, 2].join(obj) }.should raise_error(TypeError)
end
it "raises a TypeError if passed false as the separator" do
- -> { [1, 2].join(false) }.should raise_error(TypeError)
+ lambda { [1, 2].join(false) }.should raise_error(TypeError)
end
end
@@ -38,13 +38,11 @@ describe "Array#join with $," do
end
after :each do
- suppress_warning {$, = @before_separator}
+ $, = @before_separator
end
it "separates elements with default separator when the passed separator is nil" do
- suppress_warning {
- $, = "_"
- [1, 2, 3].join(nil).should == '1_2_3'
- }
+ $, = "_"
+ [1, 2, 3].join(nil).should == '1_2_3'
end
end
diff --git a/spec/ruby/core/array/keep_if_spec.rb b/spec/ruby/core/array/keep_if_spec.rb
index bf2bdeaf91..2657d5e3b6 100644
--- a/spec/ruby/core/array/keep_if_spec.rb
+++ b/spec/ruby/core/array/keep_if_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/keep_if'
+require File.expand_path('../shared/keep_if', __FILE__)
describe "Array#keep_if" do
it "returns the same array if no changes were made" do
diff --git a/spec/ruby/core/array/last_spec.rb b/spec/ruby/core/array/last_spec.rb
index d6fefada09..c707e3ff7e 100644
--- a/spec/ruby/core/array/last_spec.rb
+++ b/spec/ruby/core/array/last_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#last" do
it "returns the last element" do
@@ -28,7 +28,7 @@ describe "Array#last" do
end
it "raises an ArgumentError when count is negative" do
- -> { [1, 2].last(-1) }.should raise_error(ArgumentError)
+ lambda { [1, 2].last(-1) }.should raise_error(ArgumentError)
end
it "returns the entire array when count > length" do
@@ -53,18 +53,18 @@ describe "Array#last" do
array.last.should equal(array)
end
- it "tries to convert the passed argument to an Integer using #to_int" do
+ it "tries to convert the passed argument to an Integer usinig #to_int" do
obj = mock('to_int')
obj.should_receive(:to_int).and_return(2)
[1, 2, 3, 4, 5].last(obj).should == [4, 5]
end
it "raises a TypeError if the passed argument is not numeric" do
- -> { [1,2].last(nil) }.should raise_error(TypeError)
- -> { [1,2].last("a") }.should raise_error(TypeError)
+ lambda { [1,2].last(nil) }.should raise_error(TypeError)
+ lambda { [1,2].last("a") }.should raise_error(TypeError)
obj = mock("nonnumeric")
- -> { [1,2].last(obj) }.should raise_error(TypeError)
+ lambda { [1,2].last(obj) }.should raise_error(TypeError)
end
it "does not return subclass instance on Array subclasses" do
diff --git a/spec/ruby/core/array/length_spec.rb b/spec/ruby/core/array/length_spec.rb
index a90c001300..6f4469dda5 100644
--- a/spec/ruby/core/array/length_spec.rb
+++ b/spec/ruby/core/array/length_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Array#length" do
- it_behaves_like :array_length, :length
+ it_behaves_like(:array_length, :length)
end
diff --git a/spec/ruby/core/array/map_spec.rb b/spec/ruby/core/array/map_spec.rb
index 0c7f3afa8c..c23bb4241a 100644
--- a/spec/ruby/core/array/map_spec.rb
+++ b/spec/ruby/core/array/map_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/collect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Array#map" do
- it_behaves_like :array_collect, :map
+ it_behaves_like(:array_collect, :map)
end
describe "Array#map!" do
- it_behaves_like :array_collect_b, :map!
+ it_behaves_like(:array_collect_b, :map!)
end
diff --git a/spec/ruby/core/array/max_spec.rb b/spec/ruby/core/array/max_spec.rb
index d1c64519d0..db1d755645 100644
--- a/spec/ruby/core/array/max_spec.rb
+++ b/spec/ruby/core/array/max_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#max" do
- it "is defined on Array" do
- [1].method(:max).owner.should equal Array
+ ruby_version_is "2.4" do
+ it "is defined on Array" do
+ [1].method(:max).owner.should equal Array
+ end
end
it "returns nil with no values" do
@@ -68,16 +70,16 @@ describe "Array#max" do
end
it "raises a NoMethodError for elements without #<=>" do
- -> do
+ lambda do
[BasicObject.new, BasicObject.new].max
end.should raise_error(NoMethodError)
end
it "raises an ArgumentError for incomparable elements" do
- -> do
+ lambda do
[11,"22"].max
end.should raise_error(ArgumentError)
- -> do
+ lambda do
[11,12,22,33].max{|a, b| nil}
end.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/array/min_spec.rb b/spec/ruby/core/array/min_spec.rb
index 3bdef0dd00..59f3814da2 100644
--- a/spec/ruby/core/array/min_spec.rb
+++ b/spec/ruby/core/array/min_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#min" do
- it "is defined on Array" do
- [1].method(:max).owner.should equal Array
+ ruby_version_is "2.4" do
+ it "is defined on Array" do
+ [1].method(:max).owner.should equal Array
+ end
end
it "returns nil with no values" do
@@ -68,16 +70,16 @@ describe "Array#min" do
end
it "raises a NoMethodError for elements without #<=>" do
- -> do
+ lambda do
[BasicObject.new, BasicObject.new].min
end.should raise_error(NoMethodError)
end
it "raises an ArgumentError for incomparable elements" do
- -> do
+ lambda do
[11,"22"].min
end.should raise_error(ArgumentError)
- -> do
+ lambda do
[11,12,22,33].min{|a, b| nil}
end.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/array/minus_spec.rb b/spec/ruby/core/array/minus_spec.rb
index cb1bf56d76..ffb8d7db06 100644
--- a/spec/ruby/core/array/minus_spec.rb
+++ b/spec/ruby/core/array/minus_spec.rb
@@ -1,7 +1,87 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/difference'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#-" do
- it_behaves_like :array_binary_difference, :-
+ it "creates an array minus any items from other array" do
+ ([] - [ 1, 2, 4 ]).should == []
+ ([1, 2, 4] - []).should == [1, 2, 4]
+ ([ 1, 2, 3, 4, 5 ] - [ 1, 2, 4 ]).should == [3, 5]
+ end
+
+ it "removes multiple items on the lhs equal to one on the rhs" do
+ ([1, 1, 2, 2, 3, 3, 4, 5] - [1, 2, 4]).should == [3, 3, 5]
+ end
+
+ it "properly handles recursive arrays" do
+ empty = ArraySpecs.empty_recursive_array
+ (empty - empty).should == []
+
+ ([] - ArraySpecs.recursive_array).should == []
+
+ array = ArraySpecs.recursive_array
+ (array - array).should == []
+ end
+
+ it "tries to convert the passed arguments to Arrays using #to_ary" do
+ obj = mock('[2,3,3,4]')
+ obj.should_receive(:to_ary).and_return([2, 3, 3, 4])
+ ([1, 1, 2, 2, 3, 4] - obj).should == [1, 1]
+ end
+
+ it "raises a TypeError if the argument cannot be coerced to an Array by calling #to_ary" do
+ obj = mock('not an array')
+ lambda { [1, 2, 3] - obj }.should raise_error(TypeError)
+ end
+
+ it "does not return subclass instance for Array subclasses" do
+ (ArraySpecs::MyArray[1, 2, 3] - []).should be_an_instance_of(Array)
+ (ArraySpecs::MyArray[1, 2, 3] - ArraySpecs::MyArray[]).should be_an_instance_of(Array)
+ ([1, 2, 3] - ArraySpecs::MyArray[]).should be_an_instance_of(Array)
+ end
+
+ it "does not call to_ary on array subclasses" do
+ ([5, 6, 7] - ArraySpecs::ToAryArray[7]).should == [5, 6]
+ end
+
+ it "removes an item identified as equivalent via #hash and #eql?" do
+ obj1 = mock('1')
+ obj2 = mock('2')
+ obj1.stub!(:hash).and_return(0)
+ obj2.stub!(:hash).and_return(0)
+ obj1.should_receive(:eql?).at_least(1).and_return(true)
+
+ ([obj1] - [obj2]).should == []
+ ([obj1, obj1, obj2, obj2] - [obj2]).should == []
+ end
+
+ it "doesn't remove an item with the same hash but not #eql?" do
+ obj1 = mock('1')
+ obj2 = mock('2')
+ obj1.stub!(:hash).and_return(0)
+ obj2.stub!(:hash).and_return(0)
+ obj1.should_receive(:eql?).at_least(1).and_return(false)
+
+ ([obj1] - [obj2]).should == [obj1]
+ ([obj1, obj1, obj2, obj2] - [obj2]).should == [obj1, obj1]
+ end
+
+ it "removes an identical item even when its #eql? isn't reflexive" do
+ x = mock('x')
+ x.stub!(:hash).and_return(42)
+ x.stub!(:eql?).and_return(false) # Stubbed for clarity and latitude in implementation; not actually sent by MRI.
+
+ ([x] - [x]).should == []
+ end
+
+ it "is not destructive" do
+ a = [1, 2, 3]
+ a - []
+ a.should == [1, 2, 3]
+ a - [1]
+ a.should == [1, 2, 3]
+ a - [1,2,3]
+ a.should == [1, 2, 3]
+ a - [:a, :b, :c]
+ a.should == [1, 2, 3]
+ end
end
diff --git a/spec/ruby/core/array/multiply_spec.rb b/spec/ruby/core/array/multiply_spec.rb
index 4060666d4b..ecd5eba5f7 100644
--- a/spec/ruby/core/array/multiply_spec.rb
+++ b/spec/ruby/core/array/multiply_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/join'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/join', __FILE__)
describe "Array#*" do
it "tries to convert the passed argument to a String using #to_str" do
@@ -17,7 +17,7 @@ describe "Array#*" do
it "raises a TypeError if the argument can neither be converted to a string nor an integer" do
obj = mock('not a string or integer')
- ->{ [1,2] * obj }.should raise_error(TypeError)
+ lambda{ [1,2] * obj }.should raise_error(TypeError)
end
it "converts the passed argument to a String rather than an Integer" do
@@ -28,15 +28,15 @@ describe "Array#*" do
end
it "raises a TypeError is the passed argument is nil" do
- ->{ [1,2] * nil }.should raise_error(TypeError)
+ lambda{ [1,2] * nil }.should raise_error(TypeError)
end
it "raises an ArgumentError when passed 2 or more arguments" do
- ->{ [1,2].send(:*, 1, 2) }.should raise_error(ArgumentError)
+ lambda{ [1,2].send(:*, 1, 2) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed no arguments" do
- ->{ [1,2].send(:*) }.should raise_error(ArgumentError)
+ lambda{ [1,2].send(:*) }.should raise_error(ArgumentError)
end
end
@@ -65,8 +65,8 @@ describe "Array#* with an integer" do
end
it "raises an ArgumentError when passed a negative integer" do
- -> { [ 1, 2, 3 ] * -1 }.should raise_error(ArgumentError)
- -> { [] * -1 }.should raise_error(ArgumentError)
+ lambda { [ 1, 2, 3 ] * -1 }.should raise_error(ArgumentError)
+ lambda { [] * -1 }.should raise_error(ArgumentError)
end
describe "with a subclass of Array" do
@@ -88,44 +88,42 @@ describe "Array#* with an integer" do
end
end
- ruby_version_is ''...'2.7' do
- it "copies the taint status of the original array even if the passed count is 0" do
- ary = [1, 2, 3]
- ary.taint
- (ary * 0).tainted?.should == true
- end
+ it "copies the taint status of the original array even if the passed count is 0" do
+ ary = [1, 2, 3]
+ ary.taint
+ (ary * 0).tainted?.should == true
+ end
- it "copies the taint status of the original array even if the array is empty" do
- ary = []
- ary.taint
- (ary * 3).tainted?.should == true
- end
+ it "copies the taint status of the original array even if the array is empty" do
+ ary = []
+ ary.taint
+ (ary * 3).tainted?.should == true
+ end
- it "copies the taint status of the original array if the passed count is not 0" do
- ary = [1, 2, 3]
- ary.taint
- (ary * 1).tainted?.should == true
- (ary * 2).tainted?.should == true
- end
+ it "copies the taint status of the original array if the passed count is not 0" do
+ ary = [1, 2, 3]
+ ary.taint
+ (ary * 1).tainted?.should == true
+ (ary * 2).tainted?.should == true
+ end
- it "copies the untrusted status of the original array even if the passed count is 0" do
- ary = [1, 2, 3]
- ary.untrust
- (ary * 0).untrusted?.should == true
- end
+ it "copies the untrusted status of the original array even if the passed count is 0" do
+ ary = [1, 2, 3]
+ ary.untrust
+ (ary * 0).untrusted?.should == true
+ end
- it "copies the untrusted status of the original array even if the array is empty" do
- ary = []
- ary.untrust
- (ary * 3).untrusted?.should == true
- end
+ it "copies the untrusted status of the original array even if the array is empty" do
+ ary = []
+ ary.untrust
+ (ary * 3).untrusted?.should == true
+ end
- it "copies the untrusted status of the original array if the passed count is not 0" do
- ary = [1, 2, 3]
- ary.untrust
- (ary * 1).untrusted?.should == true
- (ary * 2).untrusted?.should == true
- end
+ it "copies the untrusted status of the original array if the passed count is not 0" do
+ ary = [1, 2, 3]
+ ary.untrust
+ (ary * 1).untrusted?.should == true
+ (ary * 2).untrusted?.should == true
end
end
diff --git a/spec/ruby/core/array/new_spec.rb b/spec/ruby/core/array/new_spec.rb
index 96ec6b8198..4d26024ff2 100644
--- a/spec/ruby/core/array/new_spec.rb
+++ b/spec/ruby/core/array/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array.new" do
it "returns an instance of Array" do
@@ -11,10 +11,10 @@ describe "Array.new" do
end
it "raises an ArgumentError if passed 3 or more arguments" do
- -> do
+ lambda do
[1, 2].send :initialize, 1, 'x', true
end.should raise_error(ArgumentError)
- -> do
+ lambda do
[1, 2].send(:initialize, 1, 'x', true) {}
end.should raise_error(ArgumentError)
end
@@ -26,7 +26,7 @@ describe "Array.new with no arguments" do
end
it "does not use the given block" do
- ->{ Array.new { raise } }.should_not raise_error
+ lambda{ Array.new { raise } }.should_not raise_error
end
end
@@ -37,7 +37,7 @@ describe "Array.new with (array)" do
end
it "does not use the given block" do
- ->{ Array.new([1, 2]) { raise } }.should_not raise_error
+ lambda{ Array.new([1, 2]) { raise } }.should_not raise_error
end
it "calls #to_ary to convert the value to an array" do
@@ -54,7 +54,7 @@ describe "Array.new with (array)" do
end
it "raises a TypeError if an Array type argument and a default object" do
- -> { Array.new([1, 2], 1) }.should raise_error(TypeError)
+ lambda { Array.new([1, 2], 1) }.should raise_error(TypeError)
end
end
@@ -74,12 +74,12 @@ describe "Array.new with (size, object=nil)" do
end
it "raises an ArgumentError if size is negative" do
- -> { Array.new(-1, :a) }.should raise_error(ArgumentError)
- -> { Array.new(-1) }.should raise_error(ArgumentError)
+ lambda { Array.new(-1, :a) }.should raise_error(ArgumentError)
+ lambda { Array.new(-1) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if size is too large" do
- -> { Array.new(fixnum_max+1) }.should raise_error(ArgumentError)
+ lambda { Array.new(fixnum_max+1) }.should raise_error(ArgumentError)
end
it "calls #to_int to convert the size argument to an Integer when object is given" do
@@ -97,7 +97,7 @@ describe "Array.new with (size, object=nil)" do
it "raises a TypeError if the size argument is not an Integer type" do
obj = mock('nonnumeric')
obj.stub!(:to_ary).and_return([1, 2])
- ->{ Array.new(obj, :a) }.should raise_error(TypeError)
+ lambda{ Array.new(obj, :a) }.should raise_error(TypeError)
end
it "yields the index of the element and sets the element to the value of the block" do
@@ -105,7 +105,7 @@ describe "Array.new with (size, object=nil)" do
end
it "uses the block value instead of using the default value" do
- -> {
+ lambda {
@result = Array.new(3, :obj) { |i| i.to_s }
}.should complain(/block supersedes default value argument/)
@result.should == ['0', '1', '2']
diff --git a/spec/ruby/core/array/pack/a_spec.rb b/spec/ruby/core/array/pack/a_spec.rb
index 7af7a16c68..e7fbdcd179 100644
--- a/spec/ruby/core/array/pack/a_spec.rb
+++ b/spec/ruby/core/array/pack/a_spec.rb
@@ -1,16 +1,14 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/string'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/string', __FILE__)
describe "Array#pack with format 'A'" do
it_behaves_like :array_pack_basic, 'A'
it_behaves_like :array_pack_basic_non_float, 'A'
it_behaves_like :array_pack_no_platform, 'A'
it_behaves_like :array_pack_string, 'A'
- it_behaves_like :array_pack_taint, 'A'
it "adds all the bytes to the output when passed the '*' modifier" do
["abc"].pack("A*").should == "abc"
@@ -38,7 +36,6 @@ describe "Array#pack with format 'a'" do
it_behaves_like :array_pack_basic_non_float, 'a'
it_behaves_like :array_pack_no_platform, 'a'
it_behaves_like :array_pack_string, 'a'
- it_behaves_like :array_pack_taint, 'a'
it "adds all the bytes to the output when passed the '*' modifier" do
["abc"].pack("a*").should == "abc"
diff --git a/spec/ruby/core/array/pack/at_spec.rb b/spec/ruby/core/array/pack/at_spec.rb
index 3942677913..dd538e8951 100644
--- a/spec/ruby/core/array/pack/at_spec.rb
+++ b/spec/ruby/core/array/pack/at_spec.rb
@@ -1,7 +1,7 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "Array#pack with format '@'" do
it_behaves_like :array_pack_basic, '@'
diff --git a/spec/ruby/core/array/pack/b_spec.rb b/spec/ruby/core/array/pack/b_spec.rb
index 872c1b88d5..62294ab8d1 100644
--- a/spec/ruby/core/array/pack/b_spec.rb
+++ b/spec/ruby/core/array/pack/b_spec.rb
@@ -1,16 +1,14 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/encodings'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/encodings', __FILE__)
describe "Array#pack with format 'B'" do
it_behaves_like :array_pack_basic, 'B'
it_behaves_like :array_pack_basic_non_float, 'B'
it_behaves_like :array_pack_arguments, 'B'
it_behaves_like :array_pack_hex, 'B'
- it_behaves_like :array_pack_taint, 'B'
it "calls #to_str to convert an Object to a String" do
obj = mock("pack H string")
@@ -47,8 +45,8 @@ describe "Array#pack with format 'B'" do
].should be_computed_by(:pack, "B*")
end
- it "returns a binary string" do
- ["1"].pack("B").encoding.should == Encoding::BINARY
+ it "returns an ASCII-8BIT string" do
+ ["1"].pack("B").encoding.should == Encoding::ASCII_8BIT
end
it "encodes the string as a sequence of bytes" do
@@ -61,7 +59,6 @@ describe "Array#pack with format 'b'" do
it_behaves_like :array_pack_basic_non_float, 'b'
it_behaves_like :array_pack_arguments, 'b'
it_behaves_like :array_pack_hex, 'b'
- it_behaves_like :array_pack_taint, 'b'
it "calls #to_str to convert an Object to a String" do
obj = mock("pack H string")
@@ -98,8 +95,8 @@ describe "Array#pack with format 'b'" do
].should be_computed_by(:pack, "b*")
end
- it "returns a binary string" do
- ["1"].pack("b").encoding.should == Encoding::BINARY
+ it "returns an ASCII-8BIT string" do
+ ["1"].pack("b").encoding.should == Encoding::ASCII_8BIT
end
it "encodes the string as a sequence of bytes" do
diff --git a/spec/ruby/core/array/pack/buffer_spec.rb b/spec/ruby/core/array/pack/buffer_spec.rb
index ecb40bfd06..928f7db731 100644
--- a/spec/ruby/core/array/pack/buffer_spec.rb
+++ b/spec/ruby/core/array/pack/buffer_spec.rb
@@ -1,50 +1,52 @@
-# encoding: binary
+# encoding: ascii-8bit
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Array#pack with :buffer option" do
- it "returns specified buffer" do
- n = [ 65, 66, 67 ]
- buffer = " "*3
- result = n.pack("ccc", buffer: buffer) #=> "ABC"
- result.should equal(buffer)
- end
-
- it "adds result at the end of buffer content" do
- n = [ 65, 66, 67 ] # result without buffer is "ABC"
-
- buffer = ""
- n.pack("ccc", buffer: buffer).should == "ABC"
+ruby_version_is '2.4' do
+ describe "Aray#pack with `buffer` option" do
+ it "returns specified buffer" do
+ n = [ 65, 66, 67 ]
+ buffer = " "*3
+ result = n.pack("ccc", buffer: buffer) #=> "ABC"
+ result.should equal(buffer)
+ end
- buffer = "123"
- n.pack("ccc", buffer: buffer).should == "123ABC"
+ it "adds result at the end of buffer content" do
+ n = [ 65, 66, 67 ] # result without buffer is "ABC"
- buffer = "12345"
- n.pack("ccc", buffer: buffer).should == "12345ABC"
- end
+ buffer = ""
+ n.pack("ccc", buffer: buffer).should == "ABC"
- it "raises TypeError exception if buffer is not String" do
- -> { [65].pack("ccc", buffer: []) }.should raise_error(
- TypeError, "buffer must be String, not Array")
- end
+ buffer = "123"
+ n.pack("ccc", buffer: buffer).should == "123ABC"
- context "offset (@) is specified" do
- it 'keeps buffer content if it is longer than offset' do
- n = [ 65, 66, 67 ]
- buffer = "123456"
- n.pack("@3ccc", buffer: buffer).should == "123ABC"
+ buffer = "12345"
+ n.pack("ccc", buffer: buffer).should == "12345ABC"
end
- it "fills the gap with \\0 if buffer content is shorter than offset" do
- n = [ 65, 66, 67 ]
- buffer = "123"
- n.pack("@6ccc", buffer: buffer).should == "123\0\0\0ABC"
+ it "raises TypeError exception if buffer is not String" do
+ lambda { [65].pack("ccc", buffer: []) }.should raise_error(
+ TypeError, "buffer must be String, not Array")
end
- it 'does not keep buffer content if it is longer than offset + result' do
- n = [ 65, 66, 67 ]
- buffer = "1234567890"
- n.pack("@3ccc", buffer: buffer).should == "123ABC"
+ context "offset (@) is specified" do
+ it 'keeps buffer content if it is longer than offset' do
+ n = [ 65, 66, 67 ]
+ buffer = "123456"
+ n.pack("@3ccc", buffer: buffer).should == "123ABC"
+ end
+
+ it "fills the gap with \0 if buffer content is shorter than offset" do
+ n = [ 65, 66, 67 ]
+ buffer = "123"
+ n.pack("@6ccc", buffer: buffer).should == "123\0\0\0ABC"
+ end
+
+ it 'does not keep buffer content if it is longer than offset + result' do
+ n = [ 65, 66, 67 ]
+ buffer = "1234567890"
+ n.pack("@3ccc", buffer: buffer).should == "123ABC"
+ end
end
end
end
diff --git a/spec/ruby/core/array/pack/c_spec.rb b/spec/ruby/core/array/pack/c_spec.rb
index 7200830331..74afa72f56 100644
--- a/spec/ruby/core/array/pack/c_spec.rb
+++ b/spec/ruby/core/array/pack/c_spec.rb
@@ -1,9 +1,9 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
describe :array_pack_8bit, shared: true do
it "encodes the least significant eight bits of a positive number" do
diff --git a/spec/ruby/core/array/pack/comment_spec.rb b/spec/ruby/core/array/pack/comment_spec.rb
index 254c827ccc..00c5fb6ecd 100644
--- a/spec/ruby/core/array/pack/comment_spec.rb
+++ b/spec/ruby/core/array/pack/comment_spec.rb
@@ -1,6 +1,6 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Array#pack" do
it "ignores directives text from '#' to the first newline" do
diff --git a/spec/ruby/core/array/pack/d_spec.rb b/spec/ruby/core/array/pack/d_spec.rb
index 8bb3654633..40f28d1e52 100644
--- a/spec/ruby/core/array/pack/d_spec.rb
+++ b/spec/ruby/core/array/pack/d_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
describe "Array#pack with format 'D'" do
it_behaves_like :array_pack_basic, 'D'
diff --git a/spec/ruby/core/array/pack/e_spec.rb b/spec/ruby/core/array/pack/e_spec.rb
index ab61ef578f..9c6a1b5485 100644
--- a/spec/ruby/core/array/pack/e_spec.rb
+++ b/spec/ruby/core/array/pack/e_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
describe "Array#pack with format 'E'" do
it_behaves_like :array_pack_basic, 'E'
diff --git a/spec/ruby/core/array/pack/empty_spec.rb b/spec/ruby/core/array/pack/empty_spec.rb
index d635d6a563..701e20b0af 100644
--- a/spec/ruby/core/array/pack/empty_spec.rb
+++ b/spec/ruby/core/array/pack/empty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Array#pack with empty format" do
it "returns an empty String" do
diff --git a/spec/ruby/core/array/pack/f_spec.rb b/spec/ruby/core/array/pack/f_spec.rb
index d436e0787c..94ce57f34d 100644
--- a/spec/ruby/core/array/pack/f_spec.rb
+++ b/spec/ruby/core/array/pack/f_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
describe "Array#pack with format 'F'" do
it_behaves_like :array_pack_basic, 'F'
diff --git a/spec/ruby/core/array/pack/g_spec.rb b/spec/ruby/core/array/pack/g_spec.rb
index 83b7f81acc..a0a902ebbe 100644
--- a/spec/ruby/core/array/pack/g_spec.rb
+++ b/spec/ruby/core/array/pack/g_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
describe "Array#pack with format 'G'" do
it_behaves_like :array_pack_basic, 'G'
diff --git a/spec/ruby/core/array/pack/h_spec.rb b/spec/ruby/core/array/pack/h_spec.rb
index 85a875fc8b..2412bf57c9 100644
--- a/spec/ruby/core/array/pack/h_spec.rb
+++ b/spec/ruby/core/array/pack/h_spec.rb
@@ -1,16 +1,14 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/encodings'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/encodings', __FILE__)
describe "Array#pack with format 'H'" do
it_behaves_like :array_pack_basic, 'H'
it_behaves_like :array_pack_basic_non_float, 'H'
it_behaves_like :array_pack_arguments, 'H'
it_behaves_like :array_pack_hex, 'H'
- it_behaves_like :array_pack_taint, 'H'
it "calls #to_str to convert an Object to a String" do
obj = mock("pack H string")
@@ -97,8 +95,8 @@ describe "Array#pack with format 'H'" do
].should be_computed_by(:pack, "H")
end
- it "returns a binary string" do
- ["41"].pack("H").encoding.should == Encoding::BINARY
+ it "returns an ASCII-8BIT string" do
+ ["41"].pack("H").encoding.should == Encoding::ASCII_8BIT
end
end
@@ -107,7 +105,6 @@ describe "Array#pack with format 'h'" do
it_behaves_like :array_pack_basic_non_float, 'h'
it_behaves_like :array_pack_arguments, 'h'
it_behaves_like :array_pack_hex, 'h'
- it_behaves_like :array_pack_taint, 'h'
it "calls #to_str to convert an Object to a String" do
obj = mock("pack H string")
@@ -194,7 +191,7 @@ describe "Array#pack with format 'h'" do
].should be_computed_by(:pack, "h")
end
- it "returns a binary string" do
- ["41"].pack("h").encoding.should == Encoding::BINARY
+ it "returns an ASCII-8BIT string" do
+ ["41"].pack("h").encoding.should == Encoding::ASCII_8BIT
end
end
diff --git a/spec/ruby/core/array/pack/i_spec.rb b/spec/ruby/core/array/pack/i_spec.rb
index a237071227..c22f367a65 100644
--- a/spec/ruby/core/array/pack/i_spec.rb
+++ b/spec/ruby/core/array/pack/i_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "Array#pack with format 'I'" do
it_behaves_like :array_pack_basic, 'I'
diff --git a/spec/ruby/core/array/pack/j_spec.rb b/spec/ruby/core/array/pack/j_spec.rb
index 7b62d5efdf..88f074724c 100644
--- a/spec/ruby/core/array/pack/j_spec.rb
+++ b/spec/ruby/core/array/pack/j_spec.rb
@@ -1,217 +1,222 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/integer'
-
-platform_is pointer_size: 64 do
- describe "Array#pack with format 'J'" do
- it_behaves_like :array_pack_basic, 'J'
- it_behaves_like :array_pack_basic_non_float, 'J'
- it_behaves_like :array_pack_arguments, 'J'
- it_behaves_like :array_pack_numeric_basic, 'J'
- it_behaves_like :array_pack_integer, 'J'
- end
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
- describe "Array#pack with format 'j'" do
- it_behaves_like :array_pack_basic, 'j'
- it_behaves_like :array_pack_basic_non_float, 'j'
- it_behaves_like :array_pack_arguments, 'j'
- it_behaves_like :array_pack_numeric_basic, 'j'
- it_behaves_like :array_pack_integer, 'j'
- end
+ruby_version_is '2.3' do
+ # To handle the special case of x64-mingw32
+ pointer_size = RUBY_PLATFORM =~ /\bx64\b/ ? 64 : 1.size * 8
- little_endian do
+ guard -> { pointer_size == 64 } do
describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_le, 'J_'
+ it_behaves_like :array_pack_basic, 'J'
+ it_behaves_like :array_pack_basic_non_float, 'J'
+ it_behaves_like :array_pack_arguments, 'J'
+ it_behaves_like :array_pack_numeric_basic, 'J'
+ it_behaves_like :array_pack_integer, 'J'
+ end
+
+ describe "Array#pack with format 'j'" do
+ it_behaves_like :array_pack_basic, 'j'
+ it_behaves_like :array_pack_basic_non_float, 'j'
+ it_behaves_like :array_pack_arguments, 'j'
+ it_behaves_like :array_pack_numeric_basic, 'j'
+ it_behaves_like :array_pack_integer, 'j'
+ end
+
+ little_endian do
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_le, 'J_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_le, 'J!'
+ end
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_le, 'J!'
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_le, 'j_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_le, 'j!'
+ end
end
end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_le, 'j_'
+ big_endian do
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_be, 'J_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_be, 'J!'
+ end
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_le, 'j!'
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_be, 'j_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_be, 'j!'
+ end
end
end
- end
- big_endian do
describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_be, 'J_'
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_64bit_le, 'J<_'
+ it_behaves_like :array_pack_64bit_le, 'J_<'
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_be, 'J!'
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_64bit_le, 'J<!'
+ it_behaves_like :array_pack_64bit_le, 'J!<'
end
- end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_be, 'j_'
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_64bit_be, 'J>_'
+ it_behaves_like :array_pack_64bit_be, 'J_>'
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_be, 'j!'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_64bit_be, 'J>!'
+ it_behaves_like :array_pack_64bit_be, 'J!>'
end
end
- end
- describe "Array#pack with format 'J'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_64bit_le, 'J<_'
- it_behaves_like :array_pack_64bit_le, 'J_<'
- end
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_64bit_le, 'j<_'
+ it_behaves_like :array_pack_64bit_le, 'j_<'
+ end
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_64bit_le, 'J<!'
- it_behaves_like :array_pack_64bit_le, 'J!<'
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_64bit_le, 'j<!'
+ it_behaves_like :array_pack_64bit_le, 'j!<'
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_64bit_be, 'J>_'
- it_behaves_like :array_pack_64bit_be, 'J_>'
- end
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_64bit_be, 'j>_'
+ it_behaves_like :array_pack_64bit_be, 'j_>'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_64bit_be, 'J>!'
- it_behaves_like :array_pack_64bit_be, 'J!>'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_64bit_be, 'j>!'
+ it_behaves_like :array_pack_64bit_be, 'j!>'
+ end
end
end
- describe "Array#pack with format 'j'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_64bit_le, 'j<_'
- it_behaves_like :array_pack_64bit_le, 'j_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_64bit_le, 'j<!'
- it_behaves_like :array_pack_64bit_le, 'j!<'
+ guard -> { pointer_size == 32 } do
+ describe "Array#pack with format 'J'" do
+ it_behaves_like :array_pack_basic, 'J'
+ it_behaves_like :array_pack_basic_non_float, 'J'
+ it_behaves_like :array_pack_arguments, 'J'
+ it_behaves_like :array_pack_numeric_basic, 'J'
+ it_behaves_like :array_pack_integer, 'J'
end
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_64bit_be, 'j>_'
- it_behaves_like :array_pack_64bit_be, 'j_>'
+ describe "Array#pack with format 'j'" do
+ it_behaves_like :array_pack_basic, 'j'
+ it_behaves_like :array_pack_basic_non_float, 'j'
+ it_behaves_like :array_pack_arguments, 'j'
+ it_behaves_like :array_pack_numeric_basic, 'j'
+ it_behaves_like :array_pack_integer, 'j'
end
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_64bit_be, 'j>!'
- it_behaves_like :array_pack_64bit_be, 'j!>'
- end
- end
-end
+ big_endian do
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_be, 'J_'
+ end
-platform_is pointer_size: 32 do
- describe "Array#pack with format 'J'" do
- it_behaves_like :array_pack_basic, 'J'
- it_behaves_like :array_pack_basic_non_float, 'J'
- it_behaves_like :array_pack_arguments, 'J'
- it_behaves_like :array_pack_numeric_basic, 'J'
- it_behaves_like :array_pack_integer, 'J'
- end
-
- describe "Array#pack with format 'j'" do
- it_behaves_like :array_pack_basic, 'j'
- it_behaves_like :array_pack_basic_non_float, 'j'
- it_behaves_like :array_pack_arguments, 'j'
- it_behaves_like :array_pack_numeric_basic, 'j'
- it_behaves_like :array_pack_integer, 'j'
- end
-
- big_endian do
- describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_be, 'J_'
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_be, 'J!'
+ end
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_be, 'J!'
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_be, 'j_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_be, 'j!'
+ end
end
end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_be, 'j_'
+ little_endian do
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_le, 'J_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_le, 'J!'
+ end
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_be, 'j!'
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_le, 'j_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_le, 'j!'
+ end
end
end
- end
- little_endian do
describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_le, 'J_'
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_32bit_le, 'J<_'
+ it_behaves_like :array_pack_32bit_le, 'J_<'
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_le, 'J!'
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_32bit_le, 'J<!'
+ it_behaves_like :array_pack_32bit_le, 'J!<'
end
- end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_le, 'j_'
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_32bit_be, 'J>_'
+ it_behaves_like :array_pack_32bit_be, 'J_>'
end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_le, 'j!'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_32bit_be, 'J>!'
+ it_behaves_like :array_pack_32bit_be, 'J!>'
end
end
- end
-
- describe "Array#pack with format 'J'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_32bit_le, 'J<_'
- it_behaves_like :array_pack_32bit_le, 'J_<'
- end
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_32bit_le, 'J<!'
- it_behaves_like :array_pack_32bit_le, 'J!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_32bit_be, 'J>_'
- it_behaves_like :array_pack_32bit_be, 'J_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_32bit_be, 'J>!'
- it_behaves_like :array_pack_32bit_be, 'J!>'
- end
- end
-
- describe "Array#pack with format 'j'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_32bit_le, 'j<_'
- it_behaves_like :array_pack_32bit_le, 'j_<'
- end
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_32bit_le, 'j<_'
+ it_behaves_like :array_pack_32bit_le, 'j_<'
+ end
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_32bit_le, 'j<!'
- it_behaves_like :array_pack_32bit_le, 'j!<'
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_32bit_le, 'j<!'
+ it_behaves_like :array_pack_32bit_le, 'j!<'
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_32bit_be, 'j>_'
- it_behaves_like :array_pack_32bit_be, 'j_>'
- end
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_32bit_be, 'j>_'
+ it_behaves_like :array_pack_32bit_be, 'j_>'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_32bit_be, 'j>!'
- it_behaves_like :array_pack_32bit_be, 'j!>'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_32bit_be, 'j>!'
+ it_behaves_like :array_pack_32bit_be, 'j!>'
+ end
end
end
end
diff --git a/spec/ruby/core/array/pack/l_spec.rb b/spec/ruby/core/array/pack/l_spec.rb
index b446a7a36a..5c1ad21d12 100644
--- a/spec/ruby/core/array/pack/l_spec.rb
+++ b/spec/ruby/core/array/pack/l_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "Array#pack with format 'L'" do
it_behaves_like :array_pack_basic, 'L'
@@ -29,7 +29,7 @@ describe "Array#pack with format 'L'" do
it_behaves_like :array_pack_32bit_be, 'L>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'L<_'
it_behaves_like :array_pack_32bit_le, 'L_<'
@@ -51,7 +51,7 @@ describe "Array#pack with format 'L'" do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_64bit_le, 'L<_'
it_behaves_like :array_pack_64bit_le, 'L_<'
@@ -83,7 +83,7 @@ describe "Array#pack with format 'l'" do
it_behaves_like :array_pack_32bit_be, 'l>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'l<_'
it_behaves_like :array_pack_32bit_le, 'l_<'
@@ -105,7 +105,7 @@ describe "Array#pack with format 'l'" do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_64bit_le, 'l<_'
it_behaves_like :array_pack_64bit_le, 'l_<'
@@ -137,7 +137,7 @@ little_endian do
it_behaves_like :array_pack_32bit_le, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_le, 'L_'
end
@@ -155,7 +155,7 @@ little_endian do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_64bit_le, 'L_'
end
@@ -183,7 +183,7 @@ big_endian do
it_behaves_like :array_pack_32bit_be, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_be, 'L_'
end
@@ -201,7 +201,7 @@ big_endian do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_64bit_be, 'L_'
end
diff --git a/spec/ruby/core/array/pack/m_spec.rb b/spec/ruby/core/array/pack/m_spec.rb
index 2b1a84abca..36d996cba6 100644
--- a/spec/ruby/core/array/pack/m_spec.rb
+++ b/spec/ruby/core/array/pack/m_spec.rb
@@ -1,14 +1,12 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "Array#pack with format 'M'" do
it_behaves_like :array_pack_basic, 'M'
it_behaves_like :array_pack_basic_non_float, 'M'
it_behaves_like :array_pack_arguments, 'M'
- it_behaves_like :array_pack_taint, 'M'
it "encodes an empty string as an empty string" do
[""].pack("M").should == ""
@@ -194,7 +192,6 @@ describe "Array#pack with format 'm'" do
it_behaves_like :array_pack_basic, 'm'
it_behaves_like :array_pack_basic_non_float, 'm'
it_behaves_like :array_pack_arguments, 'm'
- it_behaves_like :array_pack_taint, 'm'
it "encodes an empty string as an empty string" do
[""].pack("m").should == ""
@@ -285,16 +282,16 @@ describe "Array#pack with format 'm'" do
it "raises a TypeError if #to_str does not return a String" do
obj = mock("pack m non-string")
- -> { [obj].pack("m") }.should raise_error(TypeError)
+ lambda { [obj].pack("m") }.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- -> { [nil].pack("m") }.should raise_error(TypeError)
+ lambda { [nil].pack("m") }.should raise_error(TypeError)
end
it "raises a TypeError if passed an Integer" do
- -> { [0].pack("m") }.should raise_error(TypeError)
- -> { [bignum_value].pack("m") }.should raise_error(TypeError)
+ lambda { [0].pack("m") }.should raise_error(TypeError)
+ lambda { [bignum_value].pack("m") }.should raise_error(TypeError)
end
it "does not emit a newline if passed zero as the count modifier" do
diff --git a/spec/ruby/core/array/pack/n_spec.rb b/spec/ruby/core/array/pack/n_spec.rb
index ab9409fc1e..72a83e082b 100644
--- a/spec/ruby/core/array/pack/n_spec.rb
+++ b/spec/ruby/core/array/pack/n_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "Array#pack with format 'N'" do
it_behaves_like :array_pack_basic, 'N'
diff --git a/spec/ruby/core/array/pack/p_spec.rb b/spec/ruby/core/array/pack/p_spec.rb
index d7dff8a4da..65a08281e2 100644
--- a/spec/ruby/core/array/pack/p_spec.rb
+++ b/spec/ruby/core/array/pack/p_spec.rb
@@ -1,62 +1,11 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/taint'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "Array#pack with format 'P'" do
it_behaves_like :array_pack_basic_non_float, 'P'
- it_behaves_like :array_pack_taint, 'P'
-
- it "produces as many bytes as there are in a pointer" do
- ["hello"].pack("P").size.should == [0].pack("J").size
- end
-
- it "round-trips a string through pack and unpack" do
- ["hello"].pack("P").unpack("P5").should == ["hello"]
- end
-
- ruby_version_is ''...'2.7' do
- it "taints the input string" do
- input_string = "hello"
- [input_string].pack("P")
- input_string.tainted?.should be_true
- end
-
- it "does not taint the output string in normal cases" do
- ["hello"].pack("P").tainted?.should be_false
- end
- end
-
- it "with nil gives a null pointer" do
- [nil].pack("P").unpack("J").should == [0]
- end
end
describe "Array#pack with format 'p'" do
it_behaves_like :array_pack_basic_non_float, 'p'
- it_behaves_like :array_pack_taint, 'p'
-
- it "produces as many bytes as there are in a pointer" do
- ["hello"].pack("p").size.should == [0].pack("J").size
- end
-
- it "round-trips a string through pack and unpack" do
- ["hello"].pack("p").unpack("p").should == ["hello"]
- end
-
- ruby_version_is ''...'2.7' do
- it "taints the input string" do
- input_string = "hello"
- [input_string].pack("p")
- input_string.tainted?.should be_true
- end
-
- it "does not taint the output string in normal cases" do
- ["hello"].pack("p").tainted?.should be_false
- end
- end
-
- it "with nil gives a null pointer" do
- [nil].pack("p").unpack("J").should == [0]
- end
end
diff --git a/spec/ruby/core/array/pack/percent_spec.rb b/spec/ruby/core/array/pack/percent_spec.rb
index 5d56dea5fe..55d6de3424 100644
--- a/spec/ruby/core/array/pack/percent_spec.rb
+++ b/spec/ruby/core/array/pack/percent_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Array#pack with format '%'" do
it "raises an Argument Error" do
- -> { [1].pack("%") }.should raise_error(ArgumentError)
+ lambda { [1].pack("%") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/array/pack/q_spec.rb b/spec/ruby/core/array/pack/q_spec.rb
index bd6b2a4b71..83e115c54a 100644
--- a/spec/ruby/core/array/pack/q_spec.rb
+++ b/spec/ruby/core/array/pack/q_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "Array#pack with format 'Q'" do
it_behaves_like :array_pack_basic, 'Q'
diff --git a/spec/ruby/core/array/pack/s_spec.rb b/spec/ruby/core/array/pack/s_spec.rb
index 4212d6a0b1..b2f8cb48f8 100644
--- a/spec/ruby/core/array/pack/s_spec.rb
+++ b/spec/ruby/core/array/pack/s_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "Array#pack with format 'S'" do
it_behaves_like :array_pack_basic, 'S'
diff --git a/spec/ruby/core/array/pack/shared/basic.rb b/spec/ruby/core/array/pack/shared/basic.rb
index 9061273ad6..39ab15308d 100644
--- a/spec/ruby/core/array/pack/shared/basic.rb
+++ b/spec/ruby/core/array/pack/shared/basic.rb
@@ -1,6 +1,6 @@
describe :array_pack_arguments, shared: true do
it "raises an ArgumentError if there are fewer elements than the format requires" do
- -> { [].pack(pack_format(1)) }.should raise_error(ArgumentError)
+ lambda { [].pack(pack_format(1)) }.should raise_error(ArgumentError)
end
end
@@ -10,11 +10,11 @@ describe :array_pack_basic, shared: true do
end
it "raises a TypeError when passed nil" do
- -> { [@obj].pack(nil) }.should raise_error(TypeError)
+ lambda { [@obj].pack(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed an Integer" do
- -> { [@obj].pack(1) }.should raise_error(TypeError)
+ lambda { [@obj].pack(1) }.should raise_error(TypeError)
end
end
@@ -33,10 +33,8 @@ describe :array_pack_basic_non_float, shared: true do
[@obj, @obj].pack(d).should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "taints the output string if the format string is tainted" do
- [@obj, @obj].pack("x"+pack_format.taint).tainted?.should be_true
- end
+ it "taints the output string if the format string is tainted" do
+ [@obj, @obj].pack("x"+pack_format.taint).tainted?.should be_true
end
end
@@ -51,19 +49,17 @@ describe :array_pack_basic_float, shared: true do
[1.2, 4.7].pack(d).should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "taints the output string if the format string is tainted" do
- [3.2, 2.8].pack("x"+pack_format.taint).tainted?.should be_true
- end
+ it "taints the output string if the format string is tainted" do
+ [3.2, 2.8].pack("x"+pack_format.taint).tainted?.should be_true
end
end
describe :array_pack_no_platform, shared: true do
it "raises ArgumentError when the format modifier is '_'" do
- ->{ [1].pack(pack_format("_")) }.should raise_error(ArgumentError)
+ lambda{ [1].pack(pack_format("_")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError when the format modifier is '!'" do
- ->{ [1].pack(pack_format("!")) }.should raise_error(ArgumentError)
+ lambda{ [1].pack(pack_format("!")) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/array/pack/shared/encodings.rb b/spec/ruby/core/array/pack/shared/encodings.rb
index 6b7ffac764..3724a5d859 100644
--- a/spec/ruby/core/array/pack/shared/encodings.rb
+++ b/spec/ruby/core/array/pack/shared/encodings.rb
@@ -5,12 +5,12 @@ describe :array_pack_hex, shared: true do
it "raises a TypeError if the object does not respond to #to_str" do
obj = mock("pack hex non-string")
- -> { [obj].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_str does not return a String" do
obj = mock("pack hex non-string")
obj.should_receive(:to_str).and_return(1)
- -> { [obj].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/array/pack/shared/float.rb b/spec/ruby/core/array/pack/shared/float.rb
index c6b194007f..082de27acd 100644
--- a/spec/ruby/core/array/pack/shared/float.rb
+++ b/spec/ruby/core/array/pack/shared/float.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
describe :array_pack_float_le, shared: true do
it "encodes a positive Float" do
@@ -14,7 +14,7 @@ describe :array_pack_float_le, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
- -> { ["13"].pack(pack_format) }.should raise_error(TypeError)
+ lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do
@@ -41,9 +41,16 @@ describe :array_pack_float_le, shared: true do
[-infinity_value].pack(pack_format).should == "\x00\x00\x80\xff"
end
- it "encodes NaN" do
- nans = ["\x00\x00\xc0\xff", "\x00\x00\xc0\x7f", "\xFF\xFF\xFF\x7F"]
- nans.should include([nan_value].pack(pack_format))
+ platform_is "86" do # x86 / x86_64
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\x00\x00\xc0\xff"
+ end
+ end
+
+ platform_is "powerpc64" do
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\x00\x00\xc0\x7f"
+ end
end
it "encodes a positive Float outside the range of a single precision float" do
@@ -69,7 +76,7 @@ describe :array_pack_float_be, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
- -> { ["13"].pack(pack_format) }.should raise_error(TypeError)
+ lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do
@@ -96,9 +103,16 @@ describe :array_pack_float_be, shared: true do
[-infinity_value].pack(pack_format).should == "\xff\x80\x00\x00"
end
- it "encodes NaN" do
- nans = ["\xff\xc0\x00\x00", "\x7f\xc0\x00\x00", "\x7F\xFF\xFF\xFF"]
- nans.should include([nan_value].pack(pack_format))
+ platform_is "86" do # x86 / x86_64
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\xff\xc0\x00\x00"
+ end
+ end
+
+ platform_is "powerpc64" do
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\x7f\xc0\x00\x00"
+ end
end
it "encodes a positive Float outside the range of a single precision float" do
@@ -124,7 +138,7 @@ describe :array_pack_double_le, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
- -> { ["13"].pack(pack_format) }.should raise_error(TypeError)
+ lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do
@@ -151,13 +165,16 @@ describe :array_pack_double_le, shared: true do
[-infinity_value].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\xf0\xff"
end
- it "encodes NaN" do
- nans = [
- "\x00\x00\x00\x00\x00\x00\xf8\xff",
- "\x00\x00\x00\x00\x00\x00\xf8\x7f",
- "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F"
- ]
- nans.should include([nan_value].pack(pack_format))
+ platform_is "86" do # x86 / x86_64
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\xf8\xff"
+ end
+ end
+
+ platform_is "powerpc64" do
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\xf8\x7f"
+ end
end
it "encodes a positive Float outside the range of a single precision float" do
@@ -183,7 +200,7 @@ describe :array_pack_double_be, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
- -> { ["13"].pack(pack_format) }.should raise_error(TypeError)
+ lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do
@@ -210,13 +227,16 @@ describe :array_pack_double_be, shared: true do
[-infinity_value].pack(pack_format).should == "\xff\xf0\x00\x00\x00\x00\x00\x00"
end
- it "encodes NaN" do
- nans = [
- "\xff\xf8\x00\x00\x00\x00\x00\x00",
- "\x7f\xf8\x00\x00\x00\x00\x00\x00",
- "\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
- ]
- nans.should include([nan_value].pack(pack_format))
+ platform_is "86" do # x86 / x86_64
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\xff\xf8\x00\x00\x00\x00\x00\x00"
+ end
+ end
+
+ platform_is "powerpc64" do
+ it "encodes NaN" do
+ [nan_value].pack(pack_format).should == "\x7f\xf8\x00\x00\x00\x00\x00\x00"
+ end
end
it "encodes a positive Float outside the range of a single precision float" do
diff --git a/spec/ruby/core/array/pack/shared/integer.rb b/spec/ruby/core/array/pack/shared/integer.rb
index 6592f85022..0df03bbfd1 100644
--- a/spec/ruby/core/array/pack/shared/integer.rb
+++ b/spec/ruby/core/array/pack/shared/integer.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
describe :array_pack_16bit_le, shared: true do
it "encodes the least significant 16 bits of a positive number" do
diff --git a/spec/ruby/core/array/pack/shared/numeric_basic.rb b/spec/ruby/core/array/pack/shared/numeric_basic.rb
index 7c36ba4a32..9224d6080e 100644
--- a/spec/ruby/core/array/pack/shared/numeric_basic.rb
+++ b/spec/ruby/core/array/pack/shared/numeric_basic.rb
@@ -4,41 +4,41 @@ describe :array_pack_numeric_basic, shared: true do
end
it "raises a TypeError when passed nil" do
- -> { [nil].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [nil].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when passed true" do
- -> { [true].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [true].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when passed false" do
- -> { [false].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [false].pack(pack_format) }.should raise_error(TypeError)
end
- it "returns a binary string" do
- [0xFF].pack(pack_format).encoding.should == Encoding::BINARY
- [0xE3, 0x81, 0x82].pack(pack_format(3)).encoding.should == Encoding::BINARY
+ it "returns an ASCII-8BIT string" do
+ [0xFF].pack(pack_format).encoding.should == Encoding::ASCII_8BIT
+ [0xE3, 0x81, 0x82].pack(pack_format(3)).encoding.should == Encoding::ASCII_8BIT
end
end
describe :array_pack_integer, shared: true do
it "raises a TypeError when the object does not respond to #to_int" do
obj = mock('not an integer')
- -> { [obj].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- -> { ["5"].pack(pack_format) }.should raise_error(TypeError)
+ lambda { ["5"].pack(pack_format) }.should raise_error(TypeError)
end
end
describe :array_pack_float, shared: true do
it "raises a TypeError if a String does not represent a floating point number" do
- -> { ["a"].pack(pack_format) }.should raise_error(TypeError)
+ lambda { ["a"].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when the object does not respond to #to_f" do
obj = mock('not an float')
- -> { [obj].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/array/pack/shared/string.rb b/spec/ruby/core/array/pack/shared/string.rb
index 8c82e8c617..cedb0886e2 100644
--- a/spec/ruby/core/array/pack/shared/string.rb
+++ b/spec/ruby/core/array/pack/shared/string.rb
@@ -17,11 +17,11 @@ describe :array_pack_string, shared: true do
end
it "raises an ArgumentError when the Array is empty" do
- -> { [].pack(pack_format) }.should raise_error(ArgumentError)
+ lambda { [].pack(pack_format) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the Array has too few elements" do
- -> { ["a"].pack(pack_format(nil, 2)) }.should raise_error(ArgumentError)
+ lambda { ["a"].pack(pack_format(nil, 2)) }.should raise_error(ArgumentError)
end
it "calls #to_str to convert the element to a String" do
@@ -33,16 +33,48 @@ describe :array_pack_string, shared: true do
it "raises a TypeError when the object does not respond to #to_str" do
obj = mock("not a string")
- -> { [obj].pack(pack_format) }.should raise_error(TypeError)
+ lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
+ end
+
+ it "returns a tainted string when a pack argument is tainted" do
+ ["abcd".taint, 0x20].pack(pack_format("3C")).tainted?.should be_true
+ end
+
+ it "does not return a tainted string when the array is tainted" do
+ ["abcd", 0x20].taint.pack(pack_format("3C")).tainted?.should be_false
+ end
+
+ it "returns a tainted string when the format is tainted" do
+ ["abcd", 0x20].pack(pack_format("3C").taint).tainted?.should be_true
+ end
+
+ it "returns a tainted string when an empty format is tainted" do
+ ["abcd", 0x20].pack("".taint).tainted?.should be_true
+ end
+
+ it "returns a untrusted string when the format is untrusted" do
+ ["abcd", 0x20].pack(pack_format("3C").untrust).untrusted?.should be_true
+ end
+
+ it "returns a untrusted string when the empty format is untrusted" do
+ ["abcd", 0x20].pack("".untrust).untrusted?.should be_true
+ end
+
+ it "returns a untrusted string when a pack argument is untrusted" do
+ ["abcd".untrust, 0x20].pack(pack_format("3C")).untrusted?.should be_true
+ end
+
+ it "returns a trusted string when the array is untrusted" do
+ ["abcd", 0x20].untrust.pack(pack_format("3C")).untrusted?.should be_false
end
it "returns a string in encoding of common to the concatenated results" do
f = pack_format("*")
- [ [["\u{3042 3044 3046 3048}", 0x2000B].pack(f+"U"), Encoding::BINARY],
- [["abcde\xd1", "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::BINARY],
- [["a".force_encoding("ascii"), "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::BINARY],
+ [ [["\u{3042 3044 3046 3048}", 0x2000B].pack(f+"U"), Encoding::ASCII_8BIT],
+ [["abcde\xd1", "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::ASCII_8BIT],
+ [["a".force_encoding("ascii"), "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::ASCII_8BIT],
# under discussion [ruby-dev:37294]
- [["\u{3042 3044 3046 3048}", 1].pack(f+"N"), Encoding::BINARY]
+ [["\u{3042 3044 3046 3048}", 1].pack(f+"N"), Encoding::ASCII_8BIT]
].should be_computed_by(:encoding)
end
end
diff --git a/spec/ruby/core/array/pack/shared/taint.rb b/spec/ruby/core/array/pack/shared/taint.rb
deleted file mode 100644
index 565f04b8b9..0000000000
--- a/spec/ruby/core/array/pack/shared/taint.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-describe :array_pack_taint, shared: true do
- ruby_version_is ''...'2.7' do
- it "returns a tainted string when a pack argument is tainted" do
- ["abcd".taint, 0x20].pack(pack_format("3C")).tainted?.should be_true
- end
-
- it "does not return a tainted string when the array is tainted" do
- ["abcd", 0x20].taint.pack(pack_format("3C")).tainted?.should be_false
- end
-
- it "returns a tainted string when the format is tainted" do
- ["abcd", 0x20].pack(pack_format("3C").taint).tainted?.should be_true
- end
-
- it "returns a tainted string when an empty format is tainted" do
- ["abcd", 0x20].pack("".taint).tainted?.should be_true
- end
-
- it "returns a untrusted string when the format is untrusted" do
- ["abcd", 0x20].pack(pack_format("3C").untrust).untrusted?.should be_true
- end
-
- it "returns a untrusted string when the empty format is untrusted" do
- ["abcd", 0x20].pack("".untrust).untrusted?.should be_true
- end
-
- it "returns a untrusted string when a pack argument is untrusted" do
- ["abcd".untrust, 0x20].pack(pack_format("3C")).untrusted?.should be_true
- end
-
- it "returns a trusted string when the array is untrusted" do
- ["abcd", 0x20].untrust.pack(pack_format("3C")).untrusted?.should be_false
- end
- end
-end
diff --git a/spec/ruby/core/array/pack/shared/unicode.rb b/spec/ruby/core/array/pack/shared/unicode.rb
index dd0f8b38aa..e16110c491 100644
--- a/spec/ruby/core/array/pack/shared/unicode.rb
+++ b/spec/ruby/core/array/pack/shared/unicode.rb
@@ -64,7 +64,7 @@ describe :array_pack_unicode, shared: true do
it "raises a TypeError if #to_int does not return an Integer" do
obj = mock('to_int')
obj.should_receive(:to_int).and_return("5")
- -> { [obj].pack("U") }.should raise_error(TypeError)
+ lambda { [obj].pack("U") }.should raise_error(TypeError)
end
it "ignores NULL bytes between directives" do
@@ -76,11 +76,11 @@ describe :array_pack_unicode, shared: true do
end
it "raises a RangeError if passed a negative number" do
- -> { [-1].pack("U") }.should raise_error(RangeError)
+ lambda { [-1].pack("U") }.should raise_error(RangeError)
end
it "raises a RangeError if passed a number larger than an unsigned 32-bit integer" do
- -> { [2**32].pack("U") }.should raise_error(RangeError)
+ lambda { [2**32].pack("U") }.should raise_error(RangeError)
end
it "sets the output string to UTF-8 encoding" do
diff --git a/spec/ruby/core/array/pack/u_spec.rb b/spec/ruby/core/array/pack/u_spec.rb
index fe969cbb2d..0bc78fcb88 100644
--- a/spec/ruby/core/array/pack/u_spec.rb
+++ b/spec/ruby/core/array/pack/u_spec.rb
@@ -1,9 +1,8 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/unicode'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/unicode', __FILE__)
describe "Array#pack with format 'U'" do
it_behaves_like :array_pack_basic, 'U'
@@ -16,7 +15,6 @@ describe "Array#pack with format 'u'" do
it_behaves_like :array_pack_basic, 'u'
it_behaves_like :array_pack_basic_non_float, 'u'
it_behaves_like :array_pack_arguments, 'u'
- it_behaves_like :array_pack_taint, 'u'
it "encodes an empty string as an empty string" do
[""].pack("u").should == ""
@@ -112,16 +110,16 @@ describe "Array#pack with format 'u'" do
it "raises a TypeError if #to_str does not return a String" do
obj = mock("pack m non-string")
- -> { [obj].pack("u") }.should raise_error(TypeError)
+ lambda { [obj].pack("u") }.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- -> { [nil].pack("u") }.should raise_error(TypeError)
+ lambda { [nil].pack("u") }.should raise_error(TypeError)
end
it "raises a TypeError if passed an Integer" do
- -> { [0].pack("u") }.should raise_error(TypeError)
- -> { [bignum_value].pack("u") }.should raise_error(TypeError)
+ lambda { [0].pack("u") }.should raise_error(TypeError)
+ lambda { [bignum_value].pack("u") }.should raise_error(TypeError)
end
it "sets the output string to US-ASCII encoding" do
diff --git a/spec/ruby/core/array/pack/v_spec.rb b/spec/ruby/core/array/pack/v_spec.rb
index d3932c84af..8ebb863686 100644
--- a/spec/ruby/core/array/pack/v_spec.rb
+++ b/spec/ruby/core/array/pack/v_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "Array#pack with format 'V'" do
it_behaves_like :array_pack_basic, 'V'
diff --git a/spec/ruby/core/array/pack/w_spec.rb b/spec/ruby/core/array/pack/w_spec.rb
index 439fa02198..9ada3e84cb 100644
--- a/spec/ruby/core/array/pack/w_spec.rb
+++ b/spec/ruby/core/array/pack/w_spec.rb
@@ -1,8 +1,8 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/numeric_basic'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/numeric_basic', __FILE__)
describe "Array#pack with format 'w'" do
it_behaves_like :array_pack_basic, 'w'
@@ -33,10 +33,10 @@ describe "Array#pack with format 'w'" do
end
it "raises an ArgumentError when passed a negative value" do
- -> { [-1].pack("w") }.should raise_error(ArgumentError)
+ lambda { [-1].pack("w") }.should raise_error(ArgumentError)
end
- it "returns a binary string" do
- [1].pack('w').encoding.should == Encoding::BINARY
+ it "returns an ASCII-8BIT string" do
+ [1].pack('w').encoding.should == Encoding::ASCII_8BIT
end
end
diff --git a/spec/ruby/core/array/pack/x_spec.rb b/spec/ruby/core/array/pack/x_spec.rb
index a28dd0bf21..8d54ab84ee 100644
--- a/spec/ruby/core/array/pack/x_spec.rb
+++ b/spec/ruby/core/array/pack/x_spec.rb
@@ -1,7 +1,7 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "Array#pack with format 'x'" do
it_behaves_like :array_pack_basic, 'x'
@@ -55,10 +55,10 @@ describe "Array#pack with format 'X'" do
end
it "raises an ArgumentError if the output string is empty" do
- -> { [1, 2, 3].pack("XC") }.should raise_error(ArgumentError)
+ lambda { [1, 2, 3].pack("XC") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the count modifier is greater than the bytes in the string" do
- -> { [1, 2, 3].pack("C2X3") }.should raise_error(ArgumentError)
+ lambda { [1, 2, 3].pack("C2X3") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/array/pack/z_spec.rb b/spec/ruby/core/array/pack/z_spec.rb
index 82ce7b4a1c..b28a460a8e 100644
--- a/spec/ruby/core/array/pack/z_spec.rb
+++ b/spec/ruby/core/array/pack/z_spec.rb
@@ -1,16 +1,14 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/string'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/string', __FILE__)
describe "Array#pack with format 'Z'" do
it_behaves_like :array_pack_basic, 'Z'
it_behaves_like :array_pack_basic_non_float, 'Z'
it_behaves_like :array_pack_no_platform, 'Z'
it_behaves_like :array_pack_string, 'Z'
- it_behaves_like :array_pack_taint, 'Z'
it "adds all the bytes and appends a NULL byte when passed the '*' modifier" do
["abc"].pack("Z*").should == "abc\x00"
diff --git a/spec/ruby/core/array/partition_spec.rb b/spec/ruby/core/array/partition_spec.rb
index be36fffcab..787b574c28 100644
--- a/spec/ruby/core/array/partition_spec.rb
+++ b/spec/ruby/core/array/partition_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#partition" do
it "returns two arrays" do
diff --git a/spec/ruby/core/array/permutation_spec.rb b/spec/ruby/core/array/permutation_spec.rb
index f15bd76639..c0eba57a3e 100644
--- a/spec/ruby/core/array/permutation_spec.rb
+++ b/spec/ruby/core/array/permutation_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#permutation" do
diff --git a/spec/ruby/core/array/plus_spec.rb b/spec/ruby/core/array/plus_spec.rb
index 45f8438208..4517087550 100644
--- a/spec/ruby/core/array/plus_spec.rb
+++ b/spec/ruby/core/array/plus_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#+" do
it "concatenates two arrays" do
@@ -41,19 +41,17 @@ describe "Array#+" do
([5, 6] + ArraySpecs::ToAryArray[1, 2]).should == [5, 6, 1, 2]
end
- ruby_version_is ''...'2.7' do
- it "does not get infected even if an original array is tainted" do
- ([1, 2] + [3, 4]).tainted?.should be_false
- ([1, 2].taint + [3, 4]).tainted?.should be_false
- ([1, 2] + [3, 4].taint).tainted?.should be_false
- ([1, 2].taint + [3, 4].taint).tainted?.should be_false
- end
-
- it "does not infected even if an original array is untrusted" do
- ([1, 2] + [3, 4]).untrusted?.should be_false
- ([1, 2].untrust + [3, 4]).untrusted?.should be_false
- ([1, 2] + [3, 4].untrust).untrusted?.should be_false
- ([1, 2].untrust + [3, 4].untrust).untrusted?.should be_false
- end
+ it "does not get infected even if an original array is tainted" do
+ ([1, 2] + [3, 4]).tainted?.should be_false
+ ([1, 2].taint + [3, 4]).tainted?.should be_false
+ ([1, 2] + [3, 4].taint).tainted?.should be_false
+ ([1, 2].taint + [3, 4].taint).tainted?.should be_false
+ end
+
+ it "does not infected even if an original array is untrusted" do
+ ([1, 2] + [3, 4]).untrusted?.should be_false
+ ([1, 2].untrust + [3, 4]).untrusted?.should be_false
+ ([1, 2] + [3, 4].untrust).untrusted?.should be_false
+ ([1, 2].untrust + [3, 4].untrust).untrusted?.should be_false
end
end
diff --git a/spec/ruby/core/array/pop_spec.rb b/spec/ruby/core/array/pop_spec.rb
index 2cfecbb2b4..ea649c6585 100644
--- a/spec/ruby/core/array/pop_spec.rb
+++ b/spec/ruby/core/array/pop_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#pop" do
it "removes and returns the last element of the array" do
@@ -30,32 +30,28 @@ describe "Array#pop" do
array.pop.should == [1, 'two', 3.0, array, array, array, array]
end
- ruby_version_is ''...'2.7' do
- it "keeps taint status" do
- a = [1, 2].taint
- a.pop
- a.tainted?.should be_true
- a.pop
- a.tainted?.should be_true
- end
+ it "keeps taint status" do
+ a = [1, 2].taint
+ a.pop
+ a.tainted?.should be_true
+ a.pop
+ a.tainted?.should be_true
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.pop }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.pop }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} on an empty frozen array" do
- -> { ArraySpecs.empty_frozen_array.pop }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on an empty frozen array" do
+ lambda { ArraySpecs.empty_frozen_array.pop }.should raise_error(RuntimeError)
end
- ruby_version_is ''...'2.7' do
- it "keeps untrusted status" do
- a = [1, 2].untrust
- a.pop
- a.untrusted?.should be_true
- a.pop
- a.untrusted?.should be_true
- end
+ it "keeps untrusted status" do
+ a = [1, 2].untrust
+ a.pop
+ a.untrusted?.should be_true
+ a.pop
+ a.untrusted?.should be_true
end
describe "passed a number n as an argument" do
@@ -109,7 +105,7 @@ describe "Array#pop" do
end
it "raises an ArgumentError if n is negative" do
- ->{ [1, 2, 3].pop(-1) }.should raise_error(ArgumentError)
+ lambda{ [1, 2, 3].pop(-1) }.should raise_error(ArgumentError)
end
it "tries to convert n to an Integer using #to_int" do
@@ -124,53 +120,49 @@ describe "Array#pop" do
end
it "raises a TypeError when the passed n cannot be coerced to Integer" do
- ->{ [1, 2].pop("cat") }.should raise_error(TypeError)
- ->{ [1, 2].pop(nil) }.should raise_error(TypeError)
+ lambda{ [1, 2].pop("cat") }.should raise_error(TypeError)
+ lambda{ [1, 2].pop(nil) }.should raise_error(TypeError)
end
it "raises an ArgumentError if more arguments are passed" do
- ->{ [1, 2].pop(1, 2) }.should raise_error(ArgumentError)
+ lambda{ [1, 2].pop(1, 2) }.should raise_error(ArgumentError)
end
it "does not return subclass instances with Array subclass" do
ArraySpecs::MyArray[1, 2, 3].pop(2).should be_an_instance_of(Array)
end
- ruby_version_is ''...'2.7' do
- it "returns an untainted array even if the array is tainted" do
- ary = [1, 2].taint
- ary.pop(2).tainted?.should be_false
- ary.pop(0).tainted?.should be_false
- end
-
- it "keeps taint status" do
- a = [1, 2].taint
- a.pop(2)
- a.tainted?.should be_true
- a.pop(2)
- a.tainted?.should be_true
- end
-
- it "returns a trusted array even if the array is untrusted" do
- ary = [1, 2].untrust
- ary.pop(2).untrusted?.should be_false
- ary.pop(0).untrusted?.should be_false
- end
+ it "returns an untainted array even if the array is tainted" do
+ ary = [1, 2].taint
+ ary.pop(2).tainted?.should be_false
+ ary.pop(0).tainted?.should be_false
+ end
+
+ it "keeps taint status" do
+ a = [1, 2].taint
+ a.pop(2)
+ a.tainted?.should be_true
+ a.pop(2)
+ a.tainted?.should be_true
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.pop(2) }.should raise_error(frozen_error_class)
- -> { ArraySpecs.frozen_array.pop(0) }.should raise_error(frozen_error_class)
+ it "returns a trusted array even if the array is untrusted" do
+ ary = [1, 2].untrust
+ ary.pop(2).untrusted?.should be_false
+ ary.pop(0).untrusted?.should be_false
end
- ruby_version_is ''...'2.7' do
- it "keeps untrusted status" do
- a = [1, 2].untrust
- a.pop(2)
- a.untrusted?.should be_true
- a.pop(2)
- a.untrusted?.should be_true
- end
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.pop(2) }.should raise_error(RuntimeError)
+ lambda { ArraySpecs.frozen_array.pop(0) }.should raise_error(RuntimeError)
+ end
+
+ it "keeps untrusted status" do
+ a = [1, 2].untrust
+ a.pop(2)
+ a.untrusted?.should be_true
+ a.pop(2)
+ a.untrusted?.should be_true
end
end
end
diff --git a/spec/ruby/core/array/prepend_spec.rb b/spec/ruby/core/array/prepend_spec.rb
index 22230ec300..d8c6bad1a8 100644
--- a/spec/ruby/core/array/prepend_spec.rb
+++ b/spec/ruby/core/array/prepend_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/unshift'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/unshift', __FILE__)
ruby_version_is "2.5" do
describe "Array#prepend" do
- it_behaves_like :array_unshift, :prepend
+ it_behaves_like(:array_unshift, :prepend)
end
end
diff --git a/spec/ruby/core/array/product_spec.rb b/spec/ruby/core/array/product_spec.rb
index 07d2880a96..1ab38e34be 100644
--- a/spec/ruby/core/array/product_spec.rb
+++ b/spec/ruby/core/array/product_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#product" do
it "returns converted arguments using :to_ary" do
- ->{ [1].product(2..3) }.should raise_error(TypeError)
- ar = ArraySpecs::ArrayConvertible.new(2,3)
+ lambda{ [1].product(2..3) }.should raise_error(TypeError)
+ ar = ArraySpecs::ArrayConvertable.new(2,3)
[1].product(ar).should == [[1,2],[1,3]]
ar.called.should == :to_ary
end
@@ -24,7 +24,7 @@ describe "Array#product" do
it "does not attempt to produce an unreasonable number of products" do
a = (0..100).to_a
- -> do
+ lambda do
a.product(a, a, a, a, a, a, a, a, a, a)
end.should raise_error(RangeError)
end
@@ -49,7 +49,7 @@ describe "Array#product" do
it "will ignore unreasonable numbers of products and yield anyway" do
a = (0..100).to_a
- -> do
+ lambda do
a.product(a, a, a, a, a, a, a, a, a, a)
end.should raise_error(RangeError)
end
diff --git a/spec/ruby/core/array/push_spec.rb b/spec/ruby/core/array/push_spec.rb
index 607cbc7b4d..0207474579 100644
--- a/spec/ruby/core/array/push_spec.rb
+++ b/spec/ruby/core/array/push_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/push'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/push', __FILE__)
describe "Array#push" do
- it_behaves_like :array_push, :push
+ it_behaves_like(:array_push, :push)
end
diff --git a/spec/ruby/core/array/rassoc_spec.rb b/spec/ruby/core/array/rassoc_spec.rb
index 62fbd40611..cf3daccfc9 100644
--- a/spec/ruby/core/array/rassoc_spec.rb
+++ b/spec/ruby/core/array/rassoc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#rassoc" do
it "returns the first contained array whose second element is == object" do
@@ -28,7 +28,7 @@ describe "Array#rassoc" do
[[1, :foobar], [2, o], [3, mock('foo')]].rassoc(key).should == [2, o]
end
- it "does not check the last element in each contained but specifically the second" do
+ it "does not check the last element in each contained but speficically the second" do
key = 'foobar'
o = mock('foobar')
def o.==(other); other == 'foobar'; end
diff --git a/spec/ruby/core/array/reject_spec.rb b/spec/ruby/core/array/reject_spec.rb
index 1e9c296c8d..857cbf6a4d 100644
--- a/spec/ruby/core/array/reject_spec.rb
+++ b/spec/ruby/core/array/reject_spec.rb
@@ -1,17 +1,17 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorize'
-require_relative 'shared/delete_if'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorize', __FILE__)
+require File.expand_path('../shared/delete_if', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Array#reject" do
it "returns a new array without elements for which block is true" do
ary = [1, 2, 3, 4, 5]
ary.reject { true }.should == []
ary.reject { false }.should == ary
- ary.reject { false }.should_not equal ary
+ ary.reject { false }.object_id.should_not == ary.object_id
ary.reject { nil }.should == ary
- ary.reject { nil }.should_not equal ary
+ ary.reject { nil }.object_id.should_not == ary.object_id
ary.reject { 5 }.should == []
ary.reject { |i| i < 3 }.should == [3, 4, 5]
ary.reject { |i| i % 2 == 0 }.should == [1, 3, 5]
@@ -103,38 +103,12 @@ describe "Array#reject!" do
ArraySpecs.frozen_array.reject!.should be_an_instance_of(Enumerator)
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.reject! {} }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.reject! {} }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} on an empty frozen array" do
- -> { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(frozen_error_class)
- end
-
- it "does not truncate the array is the block raises an exception" do
- a = [1, 2, 3]
- begin
- a.reject! { raise StandardError, 'Oops' }
- rescue
- end
-
- a.should == [1, 2, 3]
- end
-
- it "only removes elements for which the block returns true, keeping the element which raised an error." do
- a = [1, 2, 3, 4]
- begin
- a.reject! do |x|
- case x
- when 2 then true
- when 3 then raise StandardError, 'Oops'
- else false
- end
- end
- rescue StandardError
- end
-
- a.should == [1, 3, 4]
+ it "raises a RuntimeError on an empty frozen array" do
+ lambda { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(RuntimeError)
end
it_behaves_like :enumeratorize, :reject!
diff --git a/spec/ruby/core/array/repeated_combination_spec.rb b/spec/ruby/core/array/repeated_combination_spec.rb
index b62382024a..e79c34a520 100644
--- a/spec/ruby/core/array/repeated_combination_spec.rb
+++ b/spec/ruby/core/array/repeated_combination_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#repeated_combination" do
before :each do
@@ -68,7 +68,7 @@ describe "Array#repeated_combination" do
[].repeated_combination(0).size.should == 1
end
- it "returns the binomial coefficient between combination_size and array size + combination_size -1" do
+ it "returns the binomial coeficient between combination_size and array size + combination_size -1" do
@array.repeated_combination(5).size.should == 21
@array.repeated_combination(4).size.should == 15
@array.repeated_combination(3).size.should == 10
diff --git a/spec/ruby/core/array/repeated_permutation_spec.rb b/spec/ruby/core/array/repeated_permutation_spec.rb
index a165fda09e..9038d49560 100644
--- a/spec/ruby/core/array/repeated_permutation_spec.rb
+++ b/spec/ruby/core/array/repeated_permutation_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#repeated_permutation" do
diff --git a/spec/ruby/core/array/replace_spec.rb b/spec/ruby/core/array/replace_spec.rb
index 2f53338f5e..e8b0d53e04 100644
--- a/spec/ruby/core/array/replace_spec.rb
+++ b/spec/ruby/core/array/replace_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/replace'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/replace', __FILE__)
describe "Array#replace" do
- it_behaves_like :array_replace, :replace
+ it_behaves_like(:array_replace, :replace)
end
diff --git a/spec/ruby/core/array/reverse_each_spec.rb b/spec/ruby/core/array/reverse_each_spec.rb
index 28b8bfcb34..1bc0ed5ac5 100644
--- a/spec/ruby/core/array/reverse_each_spec.rb
+++ b/spec/ruby/core/array/reverse_each_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorize'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorize', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
diff --git a/spec/ruby/core/array/reverse_spec.rb b/spec/ruby/core/array/reverse_spec.rb
index e738be6fe7..a3a6db9506 100644
--- a/spec/ruby/core/array/reverse_spec.rb
+++ b/spec/ruby/core/array/reverse_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#reverse" do
it "returns a new array with the elements in reverse order" do
@@ -36,7 +36,7 @@ describe "Array#reverse!" do
array.reverse!.should == [array, array, array, array, array, 3.0, 'two', 1]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.reverse! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.reverse! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/rindex_spec.rb b/spec/ruby/core/array/rindex_spec.rb
index 175c7bcfe2..19a6f04c85 100644
--- a/spec/ruby/core/array/rindex_spec.rb
+++ b/spec/ruby/core/array/rindex_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
diff --git a/spec/ruby/core/array/rotate_spec.rb b/spec/ruby/core/array/rotate_spec.rb
index cc1aabf986..270bfeb446 100644
--- a/spec/ruby/core/array/rotate_spec.rb
+++ b/spec/ruby/core/array/rotate_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#rotate" do
describe "when passed no argument" do
@@ -27,10 +27,10 @@ describe "Array#rotate" do
end
it "raises a TypeError if not passed an integer-like argument" do
- -> {
+ lambda {
[1, 2].rotate(nil)
}.should raise_error(TypeError)
- -> {
+ lambda {
[1, 2].rotate("4")
}.should raise_error(TypeError)
end
@@ -46,7 +46,7 @@ describe "Array#rotate" do
end
it "does not mutate the receiver" do
- -> {
+ lambda {
[].freeze.rotate
[2].freeze.rotate(2)
[1,2,3].freeze.rotate(-3)
@@ -94,10 +94,10 @@ describe "Array#rotate!" do
end
it "raises a TypeError if not passed an integer-like argument" do
- -> {
+ lambda {
[1, 2].rotate!(nil)
}.should raise_error(TypeError)
- -> {
+ lambda {
[1, 2].rotate!("4")
}.should raise_error(TypeError)
end
@@ -121,9 +121,9 @@ describe "Array#rotate!" do
a.should == []
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { [1, 2, 3].freeze.rotate!(0) }.should raise_error(frozen_error_class)
- -> { [1].freeze.rotate!(42) }.should raise_error(frozen_error_class)
- -> { [].freeze.rotate! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { [1, 2, 3].freeze.rotate!(0) }.should raise_error(RuntimeError)
+ lambda { [1].freeze.rotate!(42) }.should raise_error(RuntimeError)
+ lambda { [].freeze.rotate! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/sample_spec.rb b/spec/ruby/core/array/sample_spec.rb
index 44be91ba18..53601dd5c4 100644
--- a/spec/ruby/core/array/sample_spec.rb
+++ b/spec/ruby/core/array/sample_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#sample" do
it "samples evenly" do
@@ -57,7 +57,7 @@ describe "Array#sample" do
end
it "raises ArgumentError when passed a negative count" do
- -> { [1, 2].sample(-1) }.should raise_error(ArgumentError)
+ lambda { [1, 2].sample(-1) }.should raise_error(ArgumentError)
end
it "does not return subclass instances with Array subclass" do
@@ -92,7 +92,7 @@ describe "Array#sample" do
it "raises a NoMethodError if an object passed for the RNG does not define #rand" do
obj = BasicObject.new
- -> { [1, 2].sample(random: obj) }.should raise_error(NoMethodError)
+ lambda { [1, 2].sample(random: obj) }.should raise_error(NoMethodError)
end
describe "when the object returned by #rand is a Fixnum" do
@@ -112,14 +112,14 @@ describe "Array#sample" do
random = mock("array_sample_random")
random.should_receive(:rand).and_return(-1)
- -> { [1, 2].sample(random: random) }.should raise_error(RangeError)
+ lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
end
it "raises a RangeError if the value is equal to the Array size" do
random = mock("array_sample_random")
random.should_receive(:rand).and_return(2)
- -> { [1, 2].sample(random: random) }.should raise_error(RangeError)
+ lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
end
end
end
@@ -140,7 +140,7 @@ describe "Array#sample" do
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)
- -> { [1, 2].sample(random: random) }.should raise_error(RangeError)
+ lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
end
it "raises a RangeError if the value is equal to the Array size" do
@@ -149,7 +149,7 @@ describe "Array#sample" do
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)
- -> { [1, 2].sample(random: random) }.should raise_error(RangeError)
+ lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
end
end
end
diff --git a/spec/ruby/core/array/select_spec.rb b/spec/ruby/core/array/select_spec.rb
index 298b591744..8b83acaa5f 100644
--- a/spec/ruby/core/array/select_spec.rb
+++ b/spec/ruby/core/array/select_spec.rb
@@ -1,8 +1,30 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorize', __FILE__)
+require File.expand_path('../shared/keep_if', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Array#select" do
- it_behaves_like :array_select, :select
+ it_behaves_like :enumeratorize, :select
+ it_behaves_like :enumeratorized_with_origin_size, :select, [1,2,3]
+
+ it "returns a new array of elements for which block is true" do
+ [1, 3, 4, 5, 6, 9].select { |i| i % ((i + 1) / 2) == 0}.should == [1, 4, 6]
+ end
+
+ it "does not return subclass instance on Array subclasses" do
+ ArraySpecs::MyArray[1, 2, 3].select { true }.should be_an_instance_of(Array)
+ end
+
+ it "properly handles recursive arrays" do
+ empty = ArraySpecs.empty_recursive_array
+ empty.select { true }.should == empty
+ empty.select { false }.should == []
+
+ array = ArraySpecs.recursive_array
+ array.select { true }.should == [1, 'two', 3.0, array, array, array, array, array]
+ array.select { false }.should == []
+ end
end
describe "Array#select!" do
diff --git a/spec/ruby/core/array/shared/clone.rb b/spec/ruby/core/array/shared/clone.rb
index f6f581b17c..6fc7ae31eb 100644
--- a/spec/ruby/core/array/shared/clone.rb
+++ b/spec/ruby/core/array/shared/clone.rb
@@ -7,8 +7,8 @@ describe :array_clone, shared: true do
it "produces a shallow copy where the references are directly copied" do
a = [mock('1'), mock('2')]
b = a.send @method
- b.first.should equal a.first
- b.last.should equal a.last
+ b.first.object_id.should == a.first.object_id
+ b.last.object_id.should == a.last.object_id
end
it "creates a new array containing all elements or the original" do
@@ -18,27 +18,25 @@ describe :array_clone, shared: true do
b.__id__.should_not == a.__id__
end
- ruby_version_is ''...'2.7' do
- it "copies taint status from the original" do
- a = [1, 2, 3, 4]
- b = [1, 2, 3, 4]
- a.taint
- aa = a.send @method
- bb = b.send @method
+ it "copies taint status from the original" do
+ a = [1, 2, 3, 4]
+ b = [1, 2, 3, 4]
+ a.taint
+ aa = a.send @method
+ bb = b.send @method
- aa.tainted?.should == true
- bb.tainted?.should == false
- end
+ aa.tainted?.should == true
+ bb.tainted?.should == false
+ end
- it "copies untrusted status from the original" do
- a = [1, 2, 3, 4]
- b = [1, 2, 3, 4]
- a.untrust
- aa = a.send @method
- bb = b.send @method
+ it "copies untrusted status from the original" do
+ a = [1, 2, 3, 4]
+ b = [1, 2, 3, 4]
+ a.untrust
+ aa = a.send @method
+ bb = b.send @method
- aa.untrusted?.should == true
- bb.untrusted?.should == false
- end
+ aa.untrusted?.should == true
+ bb.untrusted?.should == false
end
end
diff --git a/spec/ruby/core/array/shared/collect.rb b/spec/ruby/core/array/shared/collect.rb
index cbe32d2ab4..f6bcfd8904 100644
--- a/spec/ruby/core/array/shared/collect.rb
+++ b/spec/ruby/core/array/shared/collect.rb
@@ -1,11 +1,11 @@
-require_relative '../../enumerable/shared/enumeratorized'
+require File.expand_path('../../../enumerable/shared/enumeratorized', __FILE__)
describe :array_collect, shared: true do
it "returns a copy of array with each element replaced by the value returned by block" do
a = ['a', 'b', 'c', 'd']
b = a.send(@method) { |i| i + '!' }
b.should == ["a!", "b!", "c!", "d!"]
- b.should_not equal a
+ b.object_id.should_not == a.object_id
end
it "does not return subclass instance" do
@@ -37,23 +37,21 @@ describe :array_collect, shared: true do
it "raises an ArgumentError when no block and with arguments" do
a = [1, 2, 3]
- -> {
+ lambda {
a.send(@method, :foo)
}.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "does not copy tainted status" do
- a = [1, 2, 3]
- a.taint
- a.send(@method){|x| x}.tainted?.should be_false
- end
+ it "does not copy tainted status" do
+ a = [1, 2, 3]
+ a.taint
+ a.send(@method){|x| x}.tainted?.should be_false
+ end
- it "does not copy untrusted status" do
- a = [1, 2, 3]
- a.untrust
- a.send(@method){|x| x}.untrusted?.should be_false
- end
+ it "does not copy untrusted status" do
+ a = [1, 2, 3]
+ a.untrust
+ a.send(@method){|x| x}.untrusted?.should be_false
end
before :all do
@@ -72,7 +70,7 @@ describe :array_collect_b, shared: true do
it "returns self" do
a = [1, 2, 3, 4, 5]
b = a.send(@method) {|i| i+1 }
- a.should equal b
+ a.object_id.should == b.object_id
end
it "returns the evaluated value of block but its contents is partially modified, if it broke in the block" do
@@ -96,40 +94,38 @@ describe :array_collect_b, shared: true do
a.should == ["1!", "2!", "3!"]
end
- ruby_version_is ''...'2.7' do
- it "keeps tainted status" do
- a = [1, 2, 3]
- a.taint
- a.tainted?.should be_true
- a.send(@method){|x| x}
- a.tainted?.should be_true
- end
+ it "keeps tainted status" do
+ a = [1, 2, 3]
+ a.taint
+ a.tainted?.should be_true
+ a.send(@method){|x| x}
+ a.tainted?.should be_true
+ end
- it "keeps untrusted status" do
- a = [1, 2, 3]
- a.untrust
- a.send(@method){|x| x}
- a.untrusted?.should be_true
- end
+ it "keeps untrusted status" do
+ a = [1, 2, 3]
+ a.untrust
+ a.send(@method){|x| x}
+ a.untrusted?.should be_true
end
describe "when frozen" do
- it "raises a #{frozen_error_class}" do
- -> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError" do
+ lambda { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when empty" do
- -> { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when empty" do
+ lambda { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when calling #each on the returned Enumerator" do
+ it "raises a RuntimeError when calling #each on the returned Enumerator" do
enumerator = ArraySpecs.frozen_array.send(@method)
- -> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
+ lambda { enumerator.each {|x| x } }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when calling #each on the returned Enumerator when empty" do
+ it "raises a RuntimeError when calling #each on the returned Enumerator when empty" do
enumerator = ArraySpecs.empty_frozen_array.send(@method)
- -> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
+ lambda { enumerator.each {|x| x } }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/shared/delete_if.rb b/spec/ruby/core/array/shared/delete_if.rb
index a3fdcf4fac..a9fb57e0d9 100644
--- a/spec/ruby/core/array/shared/delete_if.rb
+++ b/spec/ruby/core/array/shared/delete_if.rb
@@ -3,11 +3,25 @@ describe :delete_if, shared: true do
@object = [1,2,3]
end
- it "updates the receiver after all blocks" do
- @object.send(@method) do |e|
- @object.length.should == 3
- true
+ ruby_version_is "2.3" do
+ it "updates the receiver after all blocks" do
+ @object.send(@method) do |e|
+ @object.length.should == 3
+ true
+ end
+ @object.length.should == 0
+ end
+ end
+
+ ruby_version_is ""..."2.3" do
+ it "updates the receiver after each true block" do
+ count = 0
+ @object.send(@method) do |e|
+ @object.length.should == (3 - count)
+ count += 1
+ true
+ end
+ @object.length.should == 0
end
- @object.length.should == 0
end
end
diff --git a/spec/ruby/core/array/shared/difference.rb b/spec/ruby/core/array/shared/difference.rb
deleted file mode 100644
index 3e69050d82..0000000000
--- a/spec/ruby/core/array/shared/difference.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-describe :array_binary_difference, shared: true do
- it "creates an array minus any items from other array" do
- [].send(@method, [ 1, 2, 4 ]).should == []
- [1, 2, 4].send(@method, []).should == [1, 2, 4]
- [ 1, 2, 3, 4, 5 ].send(@method, [ 1, 2, 4 ]).should == [3, 5]
- end
-
- it "removes multiple items on the lhs equal to one on the rhs" do
- [1, 1, 2, 2, 3, 3, 4, 5].send(@method, [1, 2, 4]).should == [3, 3, 5]
- end
-
- it "properly handles recursive arrays" do
- empty = ArraySpecs.empty_recursive_array
- empty.send(@method, empty).should == []
-
- [].send(@method, ArraySpecs.recursive_array).should == []
-
- array = ArraySpecs.recursive_array
- array.send(@method, array).should == []
- end
-
- it "tries to convert the passed arguments to Arrays using #to_ary" do
- obj = mock('[2,3,3,4]')
- obj.should_receive(:to_ary).and_return([2, 3, 3, 4])
- [1, 1, 2, 2, 3, 4].send(@method, obj).should == [1, 1]
- end
-
- it "raises a TypeError if the argument cannot be coerced to an Array by calling #to_ary" do
- obj = mock('not an array')
- -> { [1, 2, 3].send(@method, obj) }.should raise_error(TypeError)
- end
-
- it "does not return subclass instance for Array subclasses" do
- ArraySpecs::MyArray[1, 2, 3].send(@method, []).should be_an_instance_of(Array)
- ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[]).should be_an_instance_of(Array)
- [1, 2, 3].send(@method, ArraySpecs::MyArray[]).should be_an_instance_of(Array)
- end
-
- it "does not call to_ary on array subclasses" do
- [5, 6, 7].send(@method, ArraySpecs::ToAryArray[7]).should == [5, 6]
- end
-
- it "removes an item identified as equivalent via #hash and #eql?" do
- obj1 = mock('1')
- obj2 = mock('2')
- obj1.stub!(:hash).and_return(0)
- obj2.stub!(:hash).and_return(0)
- obj1.should_receive(:eql?).at_least(1).and_return(true)
-
- [obj1].send(@method, [obj2]).should == []
- [obj1, obj1, obj2, obj2].send(@method, [obj2]).should == []
- end
-
- it "doesn't remove an item with the same hash but not #eql?" do
- obj1 = mock('1')
- obj2 = mock('2')
- obj1.stub!(:hash).and_return(0)
- obj2.stub!(:hash).and_return(0)
- obj1.should_receive(:eql?).at_least(1).and_return(false)
-
- [obj1].send(@method, [obj2]).should == [obj1]
- [obj1, obj1, obj2, obj2].send(@method, [obj2]).should == [obj1, obj1]
- end
-
- it "removes an identical item even when its #eql? isn't reflexive" do
- x = mock('x')
- x.stub!(:hash).and_return(42)
- x.stub!(:eql?).and_return(false) # Stubbed for clarity and latitude in implementation; not actually sent by MRI.
-
- [x].send(@method, [x]).should == []
- end
-
- it "is not destructive" do
- a = [1, 2, 3]
- a.send(@method, [1])
- a.should == [1, 2, 3]
- end
-end
diff --git a/spec/ruby/core/array/shared/inspect.rb b/spec/ruby/core/array/shared/inspect.rb
index 736f8d946b..6a60781b45 100644
--- a/spec/ruby/core/array/shared/inspect.rb
+++ b/spec/ruby/core/array/shared/inspect.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/encoded_strings'
+require File.expand_path('../../fixtures/encoded_strings', __FILE__)
describe :array_inspect, shared: true do
it "returns a string" do
@@ -55,7 +55,7 @@ describe :array_inspect, shared: true do
obj.should_receive(:inspect).and_return(obj)
obj.should_receive(:to_s).and_raise(Exception)
- -> { [obj].send(@method) }.should raise_error(Exception)
+ lambda { [obj].send(@method) }.should raise_error(Exception)
end
it "represents a recursive element with '[...]'" do
@@ -64,30 +64,28 @@ describe :array_inspect, shared: true do
ArraySpecs.empty_recursive_array.send(@method).should == "[[...]]"
end
- ruby_version_is ''...'2.7' do
- it "taints the result if the Array is non-empty and tainted" do
- [1, 2].taint.send(@method).tainted?.should be_true
- end
+ it "taints the result if the Array is non-empty and tainted" do
+ [1, 2].taint.send(@method).tainted?.should be_true
+ end
- it "does not taint the result if the Array is tainted but empty" do
- [].taint.send(@method).tainted?.should be_false
- end
+ it "does not taint the result if the Array is tainted but empty" do
+ [].taint.send(@method).tainted?.should be_false
+ end
- it "taints the result if an element is tainted" do
- ["str".taint].send(@method).tainted?.should be_true
- end
+ it "taints the result if an element is tainted" do
+ ["str".taint].send(@method).tainted?.should be_true
+ end
- it "untrusts the result if the Array is untrusted" do
- [1, 2].untrust.send(@method).untrusted?.should be_true
- end
+ it "untrusts the result if the Array is untrusted" do
+ [1, 2].untrust.send(@method).untrusted?.should be_true
+ end
- it "does not untrust the result if the Array is untrusted but empty" do
- [].untrust.send(@method).untrusted?.should be_false
- end
+ it "does not untrust the result if the Array is untrusted but empty" do
+ [].untrust.send(@method).untrusted?.should be_false
+ end
- it "untrusts the result if an element is untrusted" do
- ["str".untrust].send(@method).untrusted?.should be_true
- end
+ it "untrusts the result if an element is untrusted" do
+ ["str".untrust].send(@method).untrusted?.should be_true
end
describe "with encoding" do
@@ -123,11 +121,24 @@ describe :array_inspect, shared: true do
array.send(@method).encoding.name.should == "US-ASCII"
end
- it "does not raise if inspected result is not default external encoding" do
- utf_16be = mock("utf_16be")
- utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
+ ruby_version_is ''...'2.3' do
+ it "raises if inspected result is not default external encoding" do
+ utf_16be = mock("utf_16be")
+ utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
+
+ lambda {
+ [utf_16be].send(@method)
+ }.should raise_error(Encoding::CompatibilityError)
+ end
+ end
+
+ ruby_version_is '2.3' do
+ it "does not raise if inspected result is not default external encoding" do
+ utf_16be = mock("utf_16be")
+ utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
- [utf_16be].send(@method).should == '["utf_16be \u3042"]'
+ [utf_16be].send(@method).should == '["utf_16be \u3042"]'
+ end
end
end
end
diff --git a/spec/ruby/core/array/shared/join.rb b/spec/ruby/core/array/shared/join.rb
index 5e7193de8a..fa66588b47 100644
--- a/spec/ruby/core/array/shared/join.rb
+++ b/spec/ruby/core/array/shared/join.rb
@@ -1,5 +1,5 @@
-require_relative '../fixtures/classes'
-require_relative '../fixtures/encoded_strings'
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../fixtures/encoded_strings', __FILE__)
describe :array_join_with_default_separator, shared: true do
before :each do
@@ -19,10 +19,8 @@ describe :array_join_with_default_separator, shared: true do
end
it "returns a string formed by concatenating each String element separated by $," do
- suppress_warning {
- $, = " | "
- ["1", "2", "3"].send(@method).should == "1 | 2 | 3"
- }
+ $, = " | "
+ ["1", "2", "3"].send(@method).should == "1 | 2 | 3"
end
it "attempts coercion via #to_str first" do
@@ -49,50 +47,48 @@ describe :array_join_with_default_separator, shared: true do
it "raises a NoMethodError if an element does not respond to #to_str, #to_ary, or #to_s" do
obj = mock('o')
class << obj; undef :to_s; end
- -> { [1, obj].send(@method) }.should raise_error(NoMethodError)
+ lambda { [1, obj].send(@method) }.should raise_error(NoMethodError)
end
it "raises an ArgumentError when the Array is recursive" do
- -> { ArraySpecs.recursive_array.send(@method) }.should raise_error(ArgumentError)
- -> { ArraySpecs.head_recursive_array.send(@method) }.should raise_error(ArgumentError)
- -> { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
+ lambda { ArraySpecs.recursive_array.send(@method) }.should raise_error(ArgumentError)
+ lambda { ArraySpecs.head_recursive_array.send(@method) }.should raise_error(ArgumentError)
+ lambda { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "taints the result if the Array is tainted and non-empty" do
- [1, 2].taint.send(@method).tainted?.should be_true
- end
+ it "taints the result if the Array is tainted and non-empty" do
+ [1, 2].taint.send(@method).tainted?.should be_true
+ end
- it "does not taint the result if the Array is tainted but empty" do
- [].taint.send(@method).tainted?.should be_false
- end
+ it "does not taint the result if the Array is tainted but empty" do
+ [].taint.send(@method).tainted?.should be_false
+ end
- it "taints the result if the result of coercing an element is tainted" do
- s = mock("taint")
- s.should_receive(:to_s).and_return("str".taint)
- [s].send(@method).tainted?.should be_true
- end
+ it "taints the result if the result of coercing an element is tainted" do
+ s = mock("taint")
+ s.should_receive(:to_s).and_return("str".taint)
+ [s].send(@method).tainted?.should be_true
+ end
- it "untrusts the result if the Array is untrusted and non-empty" do
- [1, 2].untrust.send(@method).untrusted?.should be_true
- end
+ it "untrusts the result if the Array is untrusted and non-empty" do
+ [1, 2].untrust.send(@method).untrusted?.should be_true
+ end
- it "does not untrust the result if the Array is untrusted but empty" do
- [].untrust.send(@method).untrusted?.should be_false
- end
+ it "does not untrust the result if the Array is untrusted but empty" do
+ [].untrust.send(@method).untrusted?.should be_false
+ end
- it "untrusts the result if the result of coercing an element is untrusted" do
- s = mock("untrust")
- s.should_receive(:to_s).and_return("str".untrust)
- [s].send(@method).untrusted?.should be_true
- end
+ it "untrusts the result if the result of coercing an element is untrusted" do
+ s = mock("untrust")
+ s.should_receive(:to_s).and_return("str".untrust)
+ [s].send(@method).untrusted?.should be_true
end
it "uses the first encoding when other strings are compatible" do
ary1 = ArraySpecs.array_with_7bit_utf8_and_usascii_strings
ary2 = ArraySpecs.array_with_usascii_and_7bit_utf8_strings
- ary3 = ArraySpecs.array_with_utf8_and_7bit_binary_strings
- ary4 = ArraySpecs.array_with_usascii_and_7bit_binary_strings
+ ary3 = ArraySpecs.array_with_utf8_and_7bit_ascii8bit_strings
+ ary4 = ArraySpecs.array_with_usascii_and_7bit_ascii8bit_strings
ary1.send(@method).encoding.should == Encoding::UTF_8
ary2.send(@method).encoding.should == Encoding::US_ASCII
@@ -109,9 +105,9 @@ describe :array_join_with_default_separator, shared: true do
end
it "fails for arrays with incompatibly-encoded strings" do
- ary_utf8_bad_binary = ArraySpecs.array_with_utf8_and_binary_strings
+ ary_utf8_bad_ascii8bit = ArraySpecs.array_with_utf8_and_ascii8bit_strings
- -> { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError)
+ lambda { ary_utf8_bad_ascii8bit.send(@method) }.should raise_error(EncodingError)
end
end
@@ -127,41 +123,39 @@ describe :array_join_with_string_separator, shared: true do
[1, [2, ArraySpecs::MyArray[3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6"
end
- ruby_version_is ''...'2.7' do
- describe "with a tainted separator" do
- before :each do
- @sep = ":".taint
- end
+ describe "with a tainted separator" do
+ before :each do
+ @sep = ":".taint
+ end
- it "does not taint the result if the array is empty" do
- [].send(@method, @sep).tainted?.should be_false
- end
+ it "does not taint the result if the array is empty" do
+ [].send(@method, @sep).tainted?.should be_false
+ end
- it "does not taint the result if the array has only one element" do
- [1].send(@method, @sep).tainted?.should be_false
- end
+ it "does not taint the result if the array has only one element" do
+ [1].send(@method, @sep).tainted?.should be_false
+ end
- it "taints the result if the array has two or more elements" do
- [1, 2].send(@method, @sep).tainted?.should be_true
- end
+ it "taints the result if the array has two or more elements" do
+ [1, 2].send(@method, @sep).tainted?.should be_true
end
+ end
- describe "with an untrusted separator" do
- before :each do
- @sep = ":".untrust
- end
+ describe "with an untrusted separator" do
+ before :each do
+ @sep = ":".untrust
+ end
- it "does not untrust the result if the array is empty" do
- [].send(@method, @sep).untrusted?.should be_false
- end
+ it "does not untrust the result if the array is empty" do
+ [].send(@method, @sep).untrusted?.should be_false
+ end
- it "does not untrust the result if the array has only one element" do
- [1].send(@method, @sep).untrusted?.should be_false
- end
+ it "does not untrust the result if the array has only one element" do
+ [1].send(@method, @sep).untrusted?.should be_false
+ end
- it "untrusts the result if the array has two or more elements" do
- [1, 2].send(@method, @sep).untrusted?.should be_true
- end
+ it "untrusts the result if the array has two or more elements" do
+ [1, 2].send(@method, @sep).untrusted?.should be_true
end
end
end
diff --git a/spec/ruby/core/array/shared/keep_if.rb b/spec/ruby/core/array/shared/keep_if.rb
index 2f1299c2b3..581ba31d1b 100644
--- a/spec/ruby/core/array/shared/keep_if.rb
+++ b/spec/ruby/core/array/shared/keep_if.rb
@@ -1,4 +1,4 @@
-require_relative '../../enumerable/shared/enumeratorized'
+require File.expand_path('../../../enumerable/shared/enumeratorized', __FILE__)
describe :keep_if, shared: true do
it "deletes elements for which the block returns a false value" do
@@ -37,23 +37,23 @@ describe :keep_if, shared: true do
describe "with truthy block" do
it "keeps elements after any exception" do
- -> { @frozen.send(@method) { true } }.should raise_error(Exception)
+ lambda { @frozen.send(@method) { true } }.should raise_error(Exception)
@frozen.should == @origin
end
- it "raises a #{frozen_error_class}" do
- -> { @frozen.send(@method) { true } }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError" do
+ lambda { @frozen.send(@method) { true } }.should raise_error(RuntimeError)
end
end
describe "with falsy block" do
it "keeps elements after any exception" do
- -> { @frozen.send(@method) { false } }.should raise_error(Exception)
+ lambda { @frozen.send(@method) { false } }.should raise_error(Exception)
@frozen.should == @origin
end
- it "raises a #{frozen_error_class}" do
- -> { @frozen.send(@method) { false } }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError" do
+ lambda { @frozen.send(@method) { false } }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/array/shared/push.rb b/spec/ruby/core/array/shared/push.rb
index df307073cd..5951b71a19 100644
--- a/spec/ruby/core/array/shared/push.rb
+++ b/spec/ruby/core/array/shared/push.rb
@@ -26,8 +26,8 @@ describe :array_push, shared: true do
array.send(@method, :last).should == [1, 'two', 3.0, array, array, array, array, array, :last]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
- -> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(RuntimeError)
+ lambda { ArraySpecs.frozen_array.send(@method) }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/shared/replace.rb b/spec/ruby/core/array/shared/replace.rb
index b3474fad09..8442d9a841 100644
--- a/spec/ruby/core/array/shared/replace.rb
+++ b/spec/ruby/core/array/shared/replace.rb
@@ -52,9 +52,9 @@ describe :array_replace, shared: true do
[].send(@method, ArraySpecs::ToAryArray[5, 6, 7]).should == [5, 6, 7]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> {
+ it "raises a RuntimeError on a frozen array" do
+ lambda {
ArraySpecs.frozen_array.send(@method, ArraySpecs.frozen_array)
- }.should raise_error(frozen_error_class)
+ }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/shared/select.rb b/spec/ruby/core/array/shared/select.rb
deleted file mode 100644
index 09101e8ab5..0000000000
--- a/spec/ruby/core/array/shared/select.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/enumeratorize'
-require_relative '../shared/keep_if'
-require_relative '../../enumerable/shared/enumeratorized'
-
-describe :array_select, shared: true do
- it_should_behave_like :enumeratorize
-
- before :each do
- @object = [1,2,3]
- end
- it_should_behave_like :enumeratorized_with_origin_size
-
- it "returns a new array of elements for which block is true" do
- [1, 3, 4, 5, 6, 9].send(@method) { |i| i % ((i + 1) / 2) == 0}.should == [1, 4, 6]
- end
-
- it "does not return subclass instance on Array subclasses" do
- ArraySpecs::MyArray[1, 2, 3].send(@method) { true }.should be_an_instance_of(Array)
- end
-
- it "properly handles recursive arrays" do
- empty = ArraySpecs.empty_recursive_array
- empty.send(@method) { true }.should == empty
- empty.send(@method) { false }.should == []
-
- array = ArraySpecs.recursive_array
- array.send(@method) { true }.should == [1, 'two', 3.0, array, array, array, array, array]
- array.send(@method) { false }.should == []
- end
-end
diff --git a/spec/ruby/core/array/shared/slice.rb b/spec/ruby/core/array/shared/slice.rb
index 1e7fdf934a..b3f4ccb9a6 100644
--- a/spec/ruby/core/array/shared/slice.rb
+++ b/spec/ruby/core/array/shared/slice.rb
@@ -117,27 +117,6 @@ describe :array_slice, shared: true do
a.send(@method, 0, obj).should == [1, 2]
end
- it "raises TypeError if to_int returns non-integer" do
- from = mock('from')
- to = mock('to')
-
- # So we can construct a range out of them...
- def from.<=>(o) 0 end
- def to.<=>(o) 0 end
-
- a = [1, 2, 3, 4, 5]
-
- def from.to_int() 'cat' end
- def to.to_int() -2 end
-
- -> { a.send(@method, from..to) }.should raise_error(TypeError)
-
- def from.to_int() 1 end
- def to.to_int() 'cat' end
-
- -> { a.send(@method, from..to) }.should raise_error(TypeError)
- end
-
it "returns the elements specified by Range indexes with [m..n]" do
[ "a", "b", "c", "d", "e" ].send(@method, 1..3).should == ["b", "c", "d"]
[ "a", "b", "c", "d", "e" ].send(@method, 4..-1).should == ['e']
@@ -287,10 +266,10 @@ describe :array_slice, shared: true do
a.send(@method, 1..0).should == []
a.send(@method, 1...0).should == []
- -> { a.send(@method, "a" .. "b") }.should raise_error(TypeError)
- -> { a.send(@method, "a" ... "b") }.should raise_error(TypeError)
- -> { a.send(@method, from .. "b") }.should raise_error(TypeError)
- -> { a.send(@method, from ... "b") }.should raise_error(TypeError)
+ lambda { a.send(@method, "a" .. "b") }.should raise_error(TypeError)
+ lambda { a.send(@method, "a" ... "b") }.should raise_error(TypeError)
+ lambda { a.send(@method, from .. "b") }.should raise_error(TypeError)
+ lambda { a.send(@method, from ... "b") }.should raise_error(TypeError)
end
it "returns the same elements as [m..n] and [m...n] with Range subclasses" do
@@ -462,19 +441,19 @@ describe :array_slice, shared: true do
array = [1, 2, 3, 4, 5, 6]
obj = mock('large value')
obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
- -> { array.send(@method, obj) }.should raise_error(RangeError)
+ lambda { array.send(@method, obj) }.should raise_error(RangeError)
obj = 8e19
- -> { array.send(@method, obj) }.should raise_error(RangeError)
+ lambda { array.send(@method, obj) }.should raise_error(RangeError)
end
it "raises a RangeError when the length is out of range of Fixnum" do
array = [1, 2, 3, 4, 5, 6]
obj = mock('large value')
obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
- -> { array.send(@method, 1, obj) }.should raise_error(RangeError)
+ lambda { array.send(@method, 1, obj) }.should raise_error(RangeError)
obj = 8e19
- -> { array.send(@method, 1, obj) }.should raise_error(RangeError)
+ lambda { array.send(@method, 1, obj) }.should raise_error(RangeError)
end
end
diff --git a/spec/ruby/core/array/shared/union.rb b/spec/ruby/core/array/shared/union.rb
deleted file mode 100644
index 12a98cc9fe..0000000000
--- a/spec/ruby/core/array/shared/union.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-describe :array_binary_union, shared: true do
- it "returns an array of elements that appear in either array (union)" do
- [].send(@method, []).should == []
- [1, 2].send(@method, []).should == [1, 2]
- [].send(@method, [1, 2]).should == [1, 2]
- [ 1, 2, 3, 4 ].send(@method, [ 3, 4, 5 ]).should == [1, 2, 3, 4, 5]
- end
-
- it "creates an array with no duplicates" do
- [ 1, 2, 3, 1, 4, 5 ].send(@method, [ 1, 3, 4, 5, 3, 6 ]).should == [1, 2, 3, 4, 5, 6]
- end
-
- it "creates an array with elements in order they are first encountered" do
- [ 1, 2, 3, 1 ].send(@method, [ 1, 3, 4, 5 ]).should == [1, 2, 3, 4, 5]
- end
-
- it "properly handles recursive arrays" do
- empty = ArraySpecs.empty_recursive_array
- empty.send(@method, empty).should == empty
-
- array = ArraySpecs.recursive_array
- array.send(@method, []).should == [1, 'two', 3.0, array]
- [].send(@method, array).should == [1, 'two', 3.0, array]
- array.send(@method, array).should == [1, 'two', 3.0, array]
- array.send(@method, empty).should == [1, 'two', 3.0, array, empty]
- end
-
- it "tries to convert the passed argument to an Array using #to_ary" do
- obj = mock('[1,2,3]')
- obj.should_receive(:to_ary).and_return([1, 2, 3])
- [0].send(@method, obj).should == ([0] | [1, 2, 3])
- end
-
- # MRI follows hashing semantics here, so doesn't actually call eql?/hash for Fixnum/Symbol
- it "acts as if using an intermediate hash to collect values" do
- not_supported_on :opal do
- [5.0, 4.0].send(@method, [5, 4]).should == [5.0, 4.0, 5, 4]
- end
-
- str = "x"
- [str].send(@method, [str.dup]).should == [str]
-
- obj1 = mock('1')
- obj2 = mock('2')
- obj1.stub!(:hash).and_return(0)
- obj2.stub!(:hash).and_return(0)
- obj2.should_receive(:eql?).at_least(1).and_return(true)
-
- [obj1].send(@method, [obj2]).should == [obj1]
- [obj1, obj1, obj2, obj2].send(@method, [obj2]).should == [obj1]
-
- obj1 = mock('3')
- obj2 = mock('4')
- obj1.stub!(:hash).and_return(0)
- obj2.stub!(:hash).and_return(0)
- obj2.should_receive(:eql?).at_least(1).and_return(false)
-
- [obj1].send(@method, [obj2]).should == [obj1, obj2]
- [obj1, obj1, obj2, obj2].send(@method, [obj2]).should == [obj1, obj2]
- end
-
- it "does not return subclass instances for Array subclasses" do
- ArraySpecs::MyArray[1, 2, 3].send(@method, []).should be_an_instance_of(Array)
- ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array)
- [].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array)
- end
-
- it "does not call to_ary on array subclasses" do
- [1, 2].send(@method, ArraySpecs::ToAryArray[5, 6]).should == [1, 2, 5, 6]
- end
-
- it "properly handles an identical item even when its #eql? isn't reflexive" do
- x = mock('x')
- x.stub!(:hash).and_return(42)
- x.stub!(:eql?).and_return(false) # Stubbed for clarity and latitude in implementation; not actually sent by MRI.
-
- [x].send(@method, [x]).should == [x]
- end
-end
diff --git a/spec/ruby/core/array/shared/unshift.rb b/spec/ruby/core/array/shared/unshift.rb
index be62084e95..367bab4166 100644
--- a/spec/ruby/core/array/shared/unshift.rb
+++ b/spec/ruby/core/array/shared/unshift.rb
@@ -35,12 +35,12 @@ describe :array_unshift, shared: true do
array[0..5].should == [:new, 1, 'two', 3.0, array, array]
end
- it "raises a #{frozen_error_class} on a frozen array when the array is modified" do
- -> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array when the array is modified" do
+ lambda { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on a frozen array when the array would not be modified" do
- -> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array when the array would not be modified" do
+ lambda { ArraySpecs.frozen_array.send(@method) }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/shift_spec.rb b/spec/ruby/core/array/shift_spec.rb
index 13f1abbbfe..a7b6f58392 100644
--- a/spec/ruby/core/array/shift_spec.rb
+++ b/spec/ruby/core/array/shift_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#shift" do
it "removes and returns the first element" do
@@ -30,11 +30,11 @@ describe "Array#shift" do
array[0..2].should == ['two', 3.0, array]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.shift }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.shift }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} on an empty frozen array" do
- -> { ArraySpecs.empty_frozen_array.shift }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on an empty frozen array" do
+ lambda { ArraySpecs.empty_frozen_array.shift }.should raise_error(RuntimeError)
end
describe "passed a number n as an argument" do
@@ -90,7 +90,7 @@ describe "Array#shift" do
end
it "raises an ArgumentError if n is negative" do
- ->{ [1, 2, 3].shift(-1) }.should raise_error(ArgumentError)
+ lambda{ [1, 2, 3].shift(-1) }.should raise_error(ArgumentError)
end
it "tries to convert n to an Integer using #to_int" do
@@ -105,32 +105,30 @@ describe "Array#shift" do
end
it "raises a TypeError when the passed n cannot be coerced to Integer" do
- ->{ [1, 2].shift("cat") }.should raise_error(TypeError)
- ->{ [1, 2].shift(nil) }.should raise_error(TypeError)
+ lambda{ [1, 2].shift("cat") }.should raise_error(TypeError)
+ lambda{ [1, 2].shift(nil) }.should raise_error(TypeError)
end
it "raises an ArgumentError if more arguments are passed" do
- ->{ [1, 2].shift(1, 2) }.should raise_error(ArgumentError)
+ lambda{ [1, 2].shift(1, 2) }.should raise_error(ArgumentError)
end
it "does not return subclass instances with Array subclass" do
ArraySpecs::MyArray[1, 2, 3].shift(2).should be_an_instance_of(Array)
end
- ruby_version_is ''...'2.7' do
- it "returns an untainted array even if the array is tainted" do
- ary = [1, 2].taint
- ary.shift(2).tainted?.should be_false
- ary.shift(0).tainted?.should be_false
- end
-
- it "keeps taint status" do
- a = [1, 2].taint
- a.shift(2)
- a.tainted?.should be_true
- a.shift(2)
- a.tainted?.should be_true
- end
+ it "returns an untainted array even if the array is tainted" do
+ ary = [1, 2].taint
+ ary.shift(2).tainted?.should be_false
+ ary.shift(0).tainted?.should be_false
+ end
+
+ it "keeps taint status" do
+ a = [1, 2].taint
+ a.shift(2)
+ a.tainted?.should be_true
+ a.shift(2)
+ a.tainted?.should be_true
end
end
end
diff --git a/spec/ruby/core/array/shuffle_spec.rb b/spec/ruby/core/array/shuffle_spec.rb
index 7a2fed7d50..4c3b820186 100644
--- a/spec/ruby/core/array/shuffle_spec.rb
+++ b/spec/ruby/core/array/shuffle_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#shuffle" do
it "returns the same values, in a usually different order" do
@@ -43,7 +43,7 @@ describe "Array#shuffle" do
it "raises a NoMethodError if an object passed for the RNG does not define #rand" do
obj = BasicObject.new
- -> { [1, 2].shuffle(random: obj) }.should raise_error(NoMethodError)
+ lambda { [1, 2].shuffle(random: obj) }.should raise_error(NoMethodError)
end
it "accepts a Float for the value returned by #rand" do
@@ -68,7 +68,7 @@ describe "Array#shuffle" do
random = mock("array_shuffle_random")
random.should_receive(:rand).and_return(value)
- -> { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
+ lambda { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
end
it "raises a RangeError if the value is equal to one" do
@@ -77,7 +77,7 @@ describe "Array#shuffle" do
random = mock("array_shuffle_random")
random.should_receive(:rand).at_least(1).times.and_return(value)
- -> { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
+ lambda { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
end
end
@@ -95,8 +95,8 @@ describe "Array#shuffle!" do
a.should equal(original)
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.shuffle! }.should raise_error(frozen_error_class)
- -> { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.shuffle! }.should raise_error(RuntimeError)
+ lambda { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/size_spec.rb b/spec/ruby/core/array/size_spec.rb
index d68f956a83..2c8a18ade6 100644
--- a/spec/ruby/core/array/size_spec.rb
+++ b/spec/ruby/core/array/size_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Array#size" do
- it_behaves_like :array_length, :size
+ it_behaves_like(:array_length, :size)
end
diff --git a/spec/ruby/core/array/slice_spec.rb b/spec/ruby/core/array/slice_spec.rb
index 16220bdf0d..f6cbd1bcc4 100644
--- a/spec/ruby/core/array/slice_spec.rb
+++ b/spec/ruby/core/array/slice_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/slice'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/slice', __FILE__)
describe "Array#slice!" do
it "removes and return the element at index" do
@@ -116,8 +116,8 @@ describe "Array#slice!" do
a.slice!(from .. to).should == [2, 3, 4]
a.should == [1, 5]
- -> { a.slice!("a" .. "b") }.should raise_error(TypeError)
- -> { a.slice!(from .. "b") }.should raise_error(TypeError)
+ lambda { a.slice!("a" .. "b") }.should raise_error(TypeError)
+ lambda { a.slice!(from .. "b") }.should raise_error(TypeError)
end
it "returns last element for consecutive calls at zero index" do
@@ -150,11 +150,11 @@ describe "Array#slice!" do
a.should == [1, 2]
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(RuntimeError)
end
end
describe "Array#slice" do
- it_behaves_like :array_slice, :slice
+ it_behaves_like(:array_slice, :slice)
end
diff --git a/spec/ruby/core/array/sort_by_spec.rb b/spec/ruby/core/array/sort_by_spec.rb
index 045051d307..9f45f3ef4d 100644
--- a/spec/ruby/core/array/sort_by_spec.rb
+++ b/spec/ruby/core/array/sort_by_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Array#sort_by!" do
it "sorts array in place by passing each element to the given block" do
@@ -23,12 +23,12 @@ describe "Array#sort_by!" do
a.should be_an_instance_of(Array)
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} on an empty frozen array" do
- -> { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on an empty frozen array" do
+ lambda { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(RuntimeError)
end
it "returns the specified value when it would break in the given block" do
diff --git a/spec/ruby/core/array/sort_spec.rb b/spec/ruby/core/array/sort_spec.rb
index 6b84a82a48..0578742175 100644
--- a/spec/ruby/core/array/sort_spec.rb
+++ b/spec/ruby/core/array/sort_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#sort" do
it "returns a new array sorted based on comparing elements with <=>" do
@@ -66,7 +66,7 @@ describe "Array#sort" do
it "does not deal with exceptions raised by unimplemented or incorrect #<=>" do
o = Object.new
- -> {
+ lambda {
[o, 1].sort
}.should raise_error(ArgumentError)
end
@@ -78,7 +78,7 @@ describe "Array#sort" do
end
it "raises an error when a given block returns nil" do
- -> { [1, 2].sort {} }.should raise_error(ArgumentError)
+ lambda { [1, 2].sort {} }.should raise_error(ArgumentError)
end
it "does not call #<=> on contained objects when invoked with a block" do
@@ -134,7 +134,7 @@ describe "Array#sort" do
a.sort { |n, m|
ArraySpecs::ComparableWithFixnum.new(n-m)
}.should == [-4, 1, 2, 5, 7, 10, 12]
- -> {
+ lambda {
a.sort { |n, m| (n - m).to_s }
}.should raise_error(ArgumentError)
end
@@ -155,7 +155,7 @@ describe "Array#sort" do
it "raises an error if objects can't be compared" do
a=[ArraySpecs::Uncomparable.new, ArraySpecs::Uncomparable.new]
- -> {a.sort}.should raise_error(ArgumentError)
+ lambda {a.sort}.should raise_error(ArgumentError)
end
# From a strange Rubinius bug
@@ -233,8 +233,8 @@ describe "Array#sort!" do
a.sort!{ -1 }.should be_an_instance_of(Array)
end
- it "raises a #{frozen_error_class} on a frozen array" do
- -> { ArraySpecs.frozen_array.sort! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.sort! }.should raise_error(RuntimeError)
end
it "returns the specified value when it would break in the given block" do
diff --git a/spec/ruby/core/array/sum_spec.rb b/spec/ruby/core/array/sum_spec.rb
index 39c769d328..6548655c35 100644
--- a/spec/ruby/core/array/sum_spec.rb
+++ b/spec/ruby/core/array/sum_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
-
-describe "Array#sum" do
- it "returns the sum of elements" do
- [1, 2, 3].sum.should == 6
- end
-
- it "applies a block to each element before adding if it's given" do
- [1, 2, 3].sum { |i| i * 10 }.should == 60
- end
-
- it "returns init value if array is empty" do
- [].sum(-1).should == -1
- end
-
- it "returns 0 if array is empty and init is omitted" do
- [].sum.should == 0
- end
-
- it "adds init value to the sum of elements" do
- [1, 2, 3].sum(10).should == 16
- end
-
- it "can be used for non-numeric objects by providing init value" do
- ["a", "b", "c"].sum("").should == "abc"
- end
-
- it 'raises TypeError if any element are not numeric' do
- -> { ["a"].sum }.should raise_error(TypeError)
- end
-
- it 'raises TypeError if any element cannot be added to init value' do
- -> { [1].sum([]) }.should raise_error(TypeError)
- end
-
- it "calls + to sum the elements" do
- a = mock("a")
- b = mock("b")
- a.should_receive(:+).with(b).and_return(42)
- [b].sum(a).should == 42
+require File.expand_path('../../../spec_helper', __FILE__)
+
+ruby_version_is '2.4' do
+ describe "Array#sum" do
+ it "returns the sum of elements" do
+ [1, 2, 3].sum.should == 6
+ end
+
+ it "applies a block to each element before adding if it's given" do
+ [1, 2, 3].sum { |i| i * 10 }.should == 60
+ end
+
+ it "returns init value if array is empty" do
+ [].sum(-1).should == -1
+ end
+
+ it "returns 0 if array is empty and init is omitted" do
+ [].sum.should == 0
+ end
+
+ it "adds init value to the sum of elemens" do
+ [1, 2, 3].sum(10).should == 16
+ end
+
+ it "can be used for non-numeric objects by providing init value" do
+ ["a", "b", "c"].sum("").should == "abc"
+ end
+
+ it 'raises TypeError if any element are not numeric' do
+ lambda { ["a"].sum }.should raise_error(TypeError)
+ end
+
+ it 'raises TypeError if any element cannot be added to init value' do
+ lambda { [1].sum([]) }.should raise_error(TypeError)
+ end
+
+ it "calls + to sum the elements" do
+ a = mock("a")
+ b = mock("b")
+ a.should_receive(:+).with(b).and_return(42)
+ [b].sum(a).should == 42
+ end
end
end
diff --git a/spec/ruby/core/array/take_spec.rb b/spec/ruby/core/array/take_spec.rb
index 0de99b0a7e..6ba87706cf 100644
--- a/spec/ruby/core/array/take_spec.rb
+++ b/spec/ruby/core/array/take_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#take" do
it "returns the first specified number of elements" do
@@ -22,6 +22,6 @@ describe "Array#take" do
end
it "raises an ArgumentError when the argument is negative" do
- ->{ [1].take(-3) }.should raise_error(ArgumentError)
+ lambda{ [1].take(-3) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/array/take_while_spec.rb b/spec/ruby/core/array/take_while_spec.rb
index f159e6f251..a97f304490 100644
--- a/spec/ruby/core/array/take_while_spec.rb
+++ b/spec/ruby/core/array/take_while_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#take_while" do
it "returns all elements until the block returns false" do
diff --git a/spec/ruby/core/array/to_a_spec.rb b/spec/ruby/core/array/to_a_spec.rb
index 49d0a4782e..f3761a275e 100644
--- a/spec/ruby/core/array/to_a_spec.rb
+++ b/spec/ruby/core/array/to_a_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#to_a" do
it "returns self" do
diff --git a/spec/ruby/core/array/to_ary_spec.rb b/spec/ruby/core/array/to_ary_spec.rb
index 314699b709..ab4dfdb5ed 100644
--- a/spec/ruby/core/array/to_ary_spec.rb
+++ b/spec/ruby/core/array/to_ary_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#to_ary" do
it "returns self" do
diff --git a/spec/ruby/core/array/to_h_spec.rb b/spec/ruby/core/array/to_h_spec.rb
index 46a79ba58b..17783914aa 100644
--- a/spec/ruby/core/array/to_h_spec.rb
+++ b/spec/ruby/core/array/to_h_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#to_h" do
it "converts empty array to empty hash" do
@@ -24,58 +24,14 @@ describe "Array#to_h" do
end
it "raises TypeError if an element is not an array" do
- -> { [:x].to_h }.should raise_error(TypeError)
+ lambda { [:x].to_h }.should raise_error(TypeError)
end
it "raises ArgumentError if an element is not a [key, value] pair" do
- -> { [[:x]].to_h }.should raise_error(ArgumentError)
+ lambda { [[:x]].to_h }.should raise_error(ArgumentError)
end
it "does not accept arguments" do
- -> { [].to_h(:a, :b) }.should raise_error(ArgumentError)
- end
-
- it "produces a hash that returns nil for a missing element" do
- [[:a, 1], [:b, 2]].to_h[:c].should be_nil
- end
-
- ruby_version_is "2.6" do
- context "with block" do
- it "converts [key, value] pairs returned by the block to a Hash" do
- [:a, :b].to_h { |k| [k, k.to_s] }.should == { a: 'a', b: 'b' }
- end
-
- it "raises ArgumentError if block returns longer or shorter array" do
- -> do
- [:a, :b].to_h { |k| [k, k.to_s, 1] }
- end.should raise_error(ArgumentError, /wrong array length at 0/)
-
- -> do
- [:a, :b].to_h { |k| [k] }
- end.should raise_error(ArgumentError, /wrong array length at 0/)
- end
-
- it "raises TypeError if block returns something other than Array" do
- -> do
- [:a, :b].to_h { |k| "not-array" }
- end.should raise_error(TypeError, /wrong element type String at 0/)
- end
-
- it "coerces returned pair to Array with #to_ary" do
- x = mock('x')
- x.stub!(:to_ary).and_return([:b, 'b'])
-
- [:a].to_h { |k| x }.should == { :b => 'b' }
- end
-
- it "does not coerce returned pair to Array with #to_a" do
- x = mock('x')
- x.stub!(:to_a).and_return([:b, 'b'])
-
- -> do
- [:a].to_h { |k| x }
- end.should raise_error(TypeError, /wrong element type MockObject at 0/)
- end
- end
+ lambda { [].to_h(:a, :b) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/array/to_s_spec.rb b/spec/ruby/core/array/to_s_spec.rb
index e8476702ec..3a34d5ee0e 100644
--- a/spec/ruby/core/array/to_s_spec.rb
+++ b/spec/ruby/core/array/to_s_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/join'
-require_relative 'shared/inspect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/join', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "Array#to_s" do
it_behaves_like :array_inspect, :to_s
diff --git a/spec/ruby/core/array/transpose_spec.rb b/spec/ruby/core/array/transpose_spec.rb
index b39077f4c9..a8edad7bab 100644
--- a/spec/ruby/core/array/transpose_spec.rb
+++ b/spec/ruby/core/array/transpose_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#transpose" do
it "assumes an array of arrays and returns the result of transposing rows and columns" do
@@ -32,7 +32,7 @@ describe "Array#transpose" do
end
it "raises a TypeError if the passed Argument does not respond to #to_ary" do
- -> { [Object.new, [:a, :b]].transpose }.should raise_error(TypeError)
+ lambda { [Object.new, [:a, :b]].transpose }.should raise_error(TypeError)
end
it "does not call to_ary on array subclass elements" do
@@ -41,7 +41,7 @@ describe "Array#transpose" do
end
it "raises an IndexError if the arrays are not of the same length" do
- -> { [[1, 2], [:a]].transpose }.should raise_error(IndexError)
+ lambda { [[1, 2], [:a]].transpose }.should raise_error(IndexError)
end
it "does not return subclass instance on Array subclasses" do
diff --git a/spec/ruby/core/array/try_convert_spec.rb b/spec/ruby/core/array/try_convert_spec.rb
index 47b4722d80..5d8f9f100f 100644
--- a/spec/ruby/core/array/try_convert_spec.rb
+++ b/spec/ruby/core/array/try_convert_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array.try_convert" do
it "returns the argument if it's an Array" do
@@ -39,12 +39,12 @@ describe "Array.try_convert" do
it "sends #to_ary to the argument and raises TypeError if it's not a kind of Array" do
obj = mock("to_ary")
obj.should_receive(:to_ary).and_return(Object.new)
- -> { Array.try_convert obj }.should raise_error(TypeError)
+ lambda { Array.try_convert obj }.should raise_error(TypeError)
end
it "does not rescue exceptions raised by #to_ary" do
obj = mock("to_ary")
obj.should_receive(:to_ary).and_raise(RuntimeError)
- -> { Array.try_convert obj }.should raise_error(RuntimeError)
+ lambda { Array.try_convert obj }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/array/union_spec.rb b/spec/ruby/core/array/union_spec.rb
index 1dca47696d..58fe23448d 100644
--- a/spec/ruby/core/array/union_spec.rb
+++ b/spec/ruby/core/array/union_spec.rb
@@ -1,27 +1,82 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/union'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#|" do
- it_behaves_like :array_binary_union, :|
-end
+ it "returns an array of elements that appear in either array (union)" do
+ ([] | []).should == []
+ ([1, 2] | []).should == [1, 2]
+ ([] | [1, 2]).should == [1, 2]
+ ([ 1, 2, 3, 4 ] | [ 3, 4, 5 ]).should == [1, 2, 3, 4, 5]
+ end
-ruby_version_is "2.6" do
- describe "Array#union" do
- it_behaves_like :array_binary_union, :union
+ it "creates an array with no duplicates" do
+ ([ 1, 2, 3, 1, 4, 5 ] | [ 1, 3, 4, 5, 3, 6 ]).should == [1, 2, 3, 4, 5, 6]
+ end
- it "returns unique elements when given no argument" do
- x = [1, 2, 3, 2]
- x.union.should == [1, 2, 3]
- end
+ it "creates an array with elements in order they are first encountered" do
+ ([ 1, 2, 3, 1 ] | [ 1, 3, 4, 5 ]).should == [1, 2, 3, 4, 5]
+ end
- it "does not return subclass instances for Array subclasses" do
- ArraySpecs::MyArray[1, 2, 3].union.should be_an_instance_of(Array)
- end
+ it "properly handles recursive arrays" do
+ empty = ArraySpecs.empty_recursive_array
+ (empty | empty).should == empty
- it "accepts multiple arguments" do
- x = [1, 2, 3]
- x.union(x, x, x, x, [3, 4], x).should == [1, 2, 3, 4]
+ array = ArraySpecs.recursive_array
+ (array | []).should == [1, 'two', 3.0, array]
+ ([] | array).should == [1, 'two', 3.0, array]
+ (array | array).should == [1, 'two', 3.0, array]
+ (array | empty).should == [1, 'two', 3.0, array, empty]
+ end
+
+ it "tries to convert the passed argument to an Array using #to_ary" do
+ obj = mock('[1,2,3]')
+ obj.should_receive(:to_ary).and_return([1, 2, 3])
+ ([0] | obj).should == ([0] | [1, 2, 3])
+ end
+
+ # MRI follows hashing semantics here, so doesn't actually call eql?/hash for Fixnum/Symbol
+ it "acts as if using an intermediate hash to collect values" do
+ not_supported_on :opal do
+ ([5.0, 4.0] | [5, 4]).should == [5.0, 4.0, 5, 4]
end
+
+ str = "x"
+ ([str] | [str.dup]).should == [str]
+
+ obj1 = mock('1')
+ obj2 = mock('2')
+ obj1.stub!(:hash).and_return(0)
+ obj2.stub!(:hash).and_return(0)
+ obj2.should_receive(:eql?).at_least(1).and_return(true)
+
+ ([obj1] | [obj2]).should == [obj1]
+ ([obj1, obj1, obj2, obj2] | [obj2]).should == [obj1]
+
+ obj1 = mock('3')
+ obj2 = mock('4')
+ obj1.stub!(:hash).and_return(0)
+ obj2.stub!(:hash).and_return(0)
+ obj2.should_receive(:eql?).at_least(1).and_return(false)
+
+ ([obj1] | [obj2]).should == [obj1, obj2]
+ ([obj1, obj1, obj2, obj2] | [obj2]).should == [obj1, obj2]
+ end
+
+ it "does not return subclass instances for Array subclasses" do
+ (ArraySpecs::MyArray[1, 2, 3] | []).should be_an_instance_of(Array)
+ (ArraySpecs::MyArray[1, 2, 3] | ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array)
+ ([] | ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array)
+ end
+
+ it "does not call to_ary on array subclasses" do
+ ([1, 2] | ArraySpecs::ToAryArray[5, 6]).should == [1, 2, 5, 6]
+ end
+
+ it "properly handles an identical item even when its #eql? isn't reflexive" do
+ x = mock('x')
+ x.stub!(:hash).and_return(42)
+ x.stub!(:eql?).and_return(false) # Stubbed for clarity and latitude in implementation; not actually sent by MRI.
+
+ ([x] | [x]).should == [x]
end
end
diff --git a/spec/ruby/core/array/uniq_spec.rb b/spec/ruby/core/array/uniq_spec.rb
index 4b56f3c841..199b084376 100644
--- a/spec/ruby/core/array/uniq_spec.rb
+++ b/spec/ruby/core/array/uniq_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#uniq" do
it "returns an array with no duplicates" do
@@ -39,76 +39,44 @@ describe "Array#uniq" do
[x, y].uniq.should == [x, y]
end
- ruby_version_is '2.7' do
- it "compares elements with matching hash codes with #eql?" do
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
+ it "compares elements with matching hash codes with #eql?" do
+ a = Array.new(2) do
+ obj = mock('0')
+ obj.should_receive(:hash).at_least(1).and_return(0)
- def obj.eql?(o)
- false
- end
-
- obj
+ def obj.eql?(o)
+ # It's undefined whether the impl does a[0].eql?(a[1]) or
+ # a[1].eql?(a[0]) so we taint both.
+ taint
+ o.taint
+ false
end
- a.uniq.should == a
-
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
-
- def obj.eql?(o)
- true
- end
-
- obj
- end
-
- a.uniq.size.should == 1
+ obj
end
- end
- ruby_version_is ''...'2.7' do
- it "compares elements with matching hash codes with #eql?" do
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
+ a.uniq.should == a
+ a[0].tainted?.should == true
+ a[1].tainted?.should == true
- def obj.eql?(o)
- # It's undefined whether the impl does a[0].eql?(a[1]) or
- # a[1].eql?(a[0]) so we taint both.
- taint
- o.taint
- false
- end
-
- obj
- end
-
- a.uniq.should == a
- a[0].tainted?.should == true
- a[1].tainted?.should == true
+ a = Array.new(2) do
+ obj = mock('0')
+ obj.should_receive(:hash).at_least(1).and_return(0)
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
-
- def obj.eql?(o)
- # It's undefined whether the impl does a[0].eql?(a[1]) or
- # a[1].eql?(a[0]) so we taint both.
- taint
- o.taint
- true
- end
-
- obj
+ def obj.eql?(o)
+ # It's undefined whether the impl does a[0].eql?(a[1]) or
+ # a[1].eql?(a[0]) so we taint both.
+ taint
+ o.taint
+ true
end
- a.uniq.size.should == 1
- a[0].tainted?.should == true
- a[1].tainted?.should == true
+ obj
end
+
+ a.uniq.size.should == 1
+ a[0].tainted?.should == true
+ a[1].tainted?.should == true
end
it "compares elements based on the value returned from the block" do
@@ -220,20 +188,20 @@ describe "Array#uniq!" do
[ "a", "b", "c" ].uniq!.should == nil
end
- it "raises a #{frozen_error_class} on a frozen array when the array is modified" do
+ it "raises a RuntimeError on a frozen array when the array is modified" do
dup_ary = [1, 1, 2]
dup_ary.freeze
- -> { dup_ary.uniq! }.should raise_error(frozen_error_class)
+ lambda { dup_ary.uniq! }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on a frozen array when the array would not be modified" do
- -> { ArraySpecs.frozen_array.uniq!}.should raise_error(frozen_error_class)
- -> { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen array when the array would not be modified" do
+ lambda { ArraySpecs.frozen_array.uniq!}.should raise_error(RuntimeError)
+ lambda { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(RuntimeError)
end
it "doesn't yield to the block on a frozen array" do
- -> { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should raise_error(frozen_error_class)
+ lambda { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should raise_error(RuntimeError)
end
it "compares elements based on the value returned from the block" do
diff --git a/spec/ruby/core/array/unshift_spec.rb b/spec/ruby/core/array/unshift_spec.rb
index b8b675e5f8..eb224acfe8 100644
--- a/spec/ruby/core/array/unshift_spec.rb
+++ b/spec/ruby/core/array/unshift_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/unshift'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/unshift', __FILE__)
describe "Array#unshift" do
- it_behaves_like :array_unshift, :unshift
+ it_behaves_like(:array_unshift, :unshift)
end
diff --git a/spec/ruby/core/array/values_at_spec.rb b/spec/ruby/core/array/values_at_spec.rb
index 13860150bb..f36356f0d3 100644
--- a/spec/ruby/core/array/values_at_spec.rb
+++ b/spec/ruby/core/array/values_at_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#values_at" do
it "returns an array of elements at the indexes when passed indexes" do
diff --git a/spec/ruby/core/array/zip_spec.rb b/spec/ruby/core/array/zip_spec.rb
index af4013debe..7aac13536b 100644
--- a/spec/ruby/core/array/zip_spec.rb
+++ b/spec/ruby/core/array/zip_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Array#zip" do
it "returns an array of arrays containing corresponding elements of each array" do
@@ -42,7 +42,7 @@ describe "Array#zip" do
[1, 2].zip(10.upto(Float::INFINITY)).should == [[1, 10], [2, 11]]
end
- it "fills nil when the given enumerator is shorter than self" do
+ it "fills nil when the given enumereator is shorter than self" do
obj = Object.new
def obj.each
yield 10
diff --git a/spec/ruby/core/basicobject/__id__spec.rb b/spec/ruby/core/basicobject/__id__spec.rb
index 6766db4e82..fba9ed3b34 100644
--- a/spec/ruby/core/basicobject/__id__spec.rb
+++ b/spec/ruby/core/basicobject/__id__spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/kernel/object_id'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/kernel/object_id', __FILE__)
describe "BasicObject#__id__" do
it_behaves_like :object_id, :__id__, BasicObject
diff --git a/spec/ruby/core/basicobject/__send___spec.rb b/spec/ruby/core/basicobject/__send___spec.rb
index 005b1d0d90..f25339fac7 100644
--- a/spec/ruby/core/basicobject/__send___spec.rb
+++ b/spec/ruby/core/basicobject/__send___spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/basicobject/send'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/basicobject/send', __FILE__)
describe "BasicObject#__send__" do
it "is a public instance method" do
BasicObject.should have_public_instance_method(:__send__)
end
- it_behaves_like :basicobject_send, :__send__
+ it_behaves_like(:basicobject_send, :__send__)
end
diff --git a/spec/ruby/core/basicobject/basicobject_spec.rb b/spec/ruby/core/basicobject/basicobject_spec.rb
index 27a322e72c..f58c17a0c0 100644
--- a/spec/ruby/core/basicobject/basicobject_spec.rb
+++ b/spec/ruby/core/basicobject/basicobject_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "BasicObject" do
it "raises NoMethodError for nonexistent methods after #method_missing is removed" do
@@ -8,7 +8,7 @@ describe "BasicObject" do
end
it "raises NameError when referencing built-in constants" do
- -> { class BasicObjectSpecs::BOSubclass; Kernel; end }.should raise_error(NameError)
+ lambda { class BasicObjectSpecs::BOSubclass; Kernel; end }.should raise_error(NameError)
end
it "does not define built-in constants (according to const_defined?)" do
@@ -19,12 +19,8 @@ describe "BasicObject" do
BasicObjectSpecs::BOSubclass.kernel_defined?.should be_nil
end
- it "is included in Object's list of constants" do
- Object.constants(false).should include(:BasicObject)
- end
-
it "includes itself in its list of constants" do
- BasicObject.constants(false).should include(:BasicObject)
+ BasicObject.constants.should include(:BasicObject)
end
end
@@ -85,7 +81,7 @@ describe "BasicObject subclass" do
describe "BasicObject references" do
it "can refer to BasicObject from within itself" do
- -> { BasicObject::BasicObject }.should_not raise_error
+ lambda { BasicObject::BasicObject }.should_not raise_error
end
end
end
diff --git a/spec/ruby/core/basicobject/equal_spec.rb b/spec/ruby/core/basicobject/equal_spec.rb
index 3c1ad56d4a..8120df836f 100644
--- a/spec/ruby/core/basicobject/equal_spec.rb
+++ b/spec/ruby/core/basicobject/equal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/kernel/equal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/kernel/equal', __FILE__)
describe "BasicObject#equal?" do
it "is a public instance method" do
diff --git a/spec/ruby/core/basicobject/equal_value_spec.rb b/spec/ruby/core/basicobject/equal_value_spec.rb
index 6c825513c1..7d67634884 100644
--- a/spec/ruby/core/basicobject/equal_value_spec.rb
+++ b/spec/ruby/core/basicobject/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/kernel/equal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/kernel/equal', __FILE__)
describe "BasicObject#==" do
it "is a public instance method" do
diff --git a/spec/ruby/core/basicobject/initialize_spec.rb b/spec/ruby/core/basicobject/initialize_spec.rb
index b7ce73ffd5..7e6680df61 100644
--- a/spec/ruby/core/basicobject/initialize_spec.rb
+++ b/spec/ruby/core/basicobject/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "BasicObject#initialize" do
it "is a private instance method" do
@@ -6,7 +6,7 @@ describe "BasicObject#initialize" do
end
it "does not accept arguments" do
- -> {
+ lambda {
BasicObject.new("This", "makes it easier", "to call super", "from other constructors")
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/basicobject/instance_eval_spec.rb b/spec/ruby/core/basicobject/instance_eval_spec.rb
index d3dd05b745..3898e96b8b 100644
--- a/spec/ruby/core/basicobject/instance_eval_spec.rb
+++ b/spec/ruby/core/basicobject/instance_eval_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "BasicObject#instance_eval" do
before :each do
@@ -21,11 +21,11 @@ describe "BasicObject#instance_eval" do
end
it "expects a block with no arguments" do
- -> { "hola".instance_eval }.should raise_error(ArgumentError)
+ lambda { "hola".instance_eval }.should raise_error(ArgumentError)
end
it "takes no arguments with a block" do
- -> { "hola".instance_eval(4, 5) {|a,b| a + b } }.should raise_error(ArgumentError)
+ lambda { "hola".instance_eval(4, 5) {|a,b| a + b } }.should raise_error(ArgumentError)
end
it "yields the object to the block" do
@@ -45,7 +45,7 @@ describe "BasicObject#instance_eval" do
end
end
f.foo.should == 1
- -> { Object.new.foo }.should raise_error(NoMethodError)
+ lambda { Object.new.foo }.should raise_error(NoMethodError)
end
it "preserves self in the original block when passed a block argument" do
@@ -122,10 +122,10 @@ describe "BasicObject#instance_eval" do
end
it "raises a TypeError when defining methods on an immediate" do
- -> do
+ lambda do
1.instance_eval { def foo; end }
end.should raise_error(TypeError)
- -> do
+ lambda do
:foo.instance_eval { def foo; end }
end.should raise_error(TypeError)
end
@@ -143,10 +143,10 @@ quarantine! do # Not clean, leaves cvars lying around to break other specs
end
it "raises a TypeError when defining methods on numerics" do
- -> do
+ lambda do
(1.0).instance_eval { def foo; end }
end.should raise_error(TypeError)
- -> do
+ lambda do
(1 << 64).instance_eval { def foo; end }
end.should raise_error(TypeError)
end
@@ -177,12 +177,4 @@ end
end
err.backtrace.first.split(":")[0..1].should == ["b_file", "-98"]
end
-
- it "has access to the caller's local variables" do
- x = nil
-
- instance_eval "x = :value"
-
- x.should == :value
- end
end
diff --git a/spec/ruby/core/basicobject/instance_exec_spec.rb b/spec/ruby/core/basicobject/instance_exec_spec.rb
index e25482d58a..f41af6f64f 100644
--- a/spec/ruby/core/basicobject/instance_exec_spec.rb
+++ b/spec/ruby/core/basicobject/instance_exec_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "BasicObject#instance_exec" do
it "is a public instance method" do
@@ -17,7 +17,7 @@ describe "BasicObject#instance_exec" do
end
it "raises a LocalJumpError unless given a block" do
- -> { "hola".instance_exec }.should raise_error(LocalJumpError)
+ lambda { "hola".instance_exec }.should raise_error(LocalJumpError)
end
it "has an arity of -1" do
@@ -25,7 +25,7 @@ describe "BasicObject#instance_exec" do
end
it "accepts arguments with a block" do
- -> { "hola".instance_exec(4, 5) { |a,b| a + b } }.should_not raise_error
+ lambda { "hola".instance_exec(4, 5) { |a,b| a + b } }.should_not raise_error
end
it "doesn't pass self to the block as an argument" do
@@ -44,7 +44,7 @@ describe "BasicObject#instance_exec" do
end
end
f.foo.should == 1
- -> { Object.new.foo }.should raise_error(NoMethodError)
+ lambda { Object.new.foo }.should raise_error(NoMethodError)
end
# TODO: This should probably be replaced with a "should behave like" that uses
@@ -76,10 +76,10 @@ describe "BasicObject#instance_exec" do
end
it "raises a TypeError when defining methods on an immediate" do
- -> do
+ lambda do
1.instance_exec { def foo; end }
end.should raise_error(TypeError)
- -> do
+ lambda do
:foo.instance_exec { def foo; end }
end.should raise_error(TypeError)
end
@@ -97,10 +97,10 @@ quarantine! do # Not clean, leaves cvars lying around to break other specs
end
it "raises a TypeError when defining methods on numerics" do
- -> do
+ lambda do
(1.0).instance_exec { def foo; end }
end.should raise_error(TypeError)
- -> do
+ lambda do
(1 << 64).instance_exec { def foo; end }
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/basicobject/method_missing_spec.rb b/spec/ruby/core/basicobject/method_missing_spec.rb
index b048780ee8..eea45a8ddc 100644
--- a/spec/ruby/core/basicobject/method_missing_spec.rb
+++ b/spec/ruby/core/basicobject/method_missing_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../shared/basicobject/method_missing'
+require File.expand_path('../../../shared/basicobject/method_missing', __FILE__)
describe "BasicObject#method_missing" do
it "is a private method" do
diff --git a/spec/ruby/core/basicobject/not_equal_spec.rb b/spec/ruby/core/basicobject/not_equal_spec.rb
index 9329128c43..9177380154 100644
--- a/spec/ruby/core/basicobject/not_equal_spec.rb
+++ b/spec/ruby/core/basicobject/not_equal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "BasicObject#!=" do
it "is a public instance method" do
diff --git a/spec/ruby/core/basicobject/not_spec.rb b/spec/ruby/core/basicobject/not_spec.rb
index ca4cb6f5ff..f02b31edb2 100644
--- a/spec/ruby/core/basicobject/not_spec.rb
+++ b/spec/ruby/core/basicobject/not_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "BasicObject#!" do
it "is a public instance method" do
diff --git a/spec/ruby/core/basicobject/singleton_method_added_spec.rb b/spec/ruby/core/basicobject/singleton_method_added_spec.rb
index 8d256e22db..7622798dee 100644
--- a/spec/ruby/core/basicobject/singleton_method_added_spec.rb
+++ b/spec/ruby/core/basicobject/singleton_method_added_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/singleton_method'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/singleton_method', __FILE__)
describe "BasicObject#singleton_method_added" do
before :each do
diff --git a/spec/ruby/core/basicobject/singleton_method_removed_spec.rb b/spec/ruby/core/basicobject/singleton_method_removed_spec.rb
index 46f9a6894c..406f4a888e 100644
--- a/spec/ruby/core/basicobject/singleton_method_removed_spec.rb
+++ b/spec/ruby/core/basicobject/singleton_method_removed_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "BasicObject#singleton_method_removed" do
before :each do
diff --git a/spec/ruby/core/basicobject/singleton_method_undefined_spec.rb b/spec/ruby/core/basicobject/singleton_method_undefined_spec.rb
index 7d6c7207db..4f33cc5dbe 100644
--- a/spec/ruby/core/basicobject/singleton_method_undefined_spec.rb
+++ b/spec/ruby/core/basicobject/singleton_method_undefined_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "BasicObject#singleton_method_undefined" do
before :each do
diff --git a/spec/ruby/core/bignum/abs_spec.rb b/spec/ruby/core/bignum/abs_spec.rb
new file mode 100644
index 0000000000..b551dd95ad
--- /dev/null
+++ b/spec/ruby/core/bignum/abs_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/abs', __FILE__)
+
+describe "Bignum#abs" do
+ it_behaves_like(:bignum_abs, :abs)
+end
+
diff --git a/spec/ruby/core/bignum/bignum_spec.rb b/spec/ruby/core/bignum/bignum_spec.rb
new file mode 100644
index 0000000000..3df43aec2d
--- /dev/null
+++ b/spec/ruby/core/bignum/bignum_spec.rb
@@ -0,0 +1,31 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum" do
+ it "includes Comparable" do
+ Bignum.include?(Comparable).should == true
+ end
+
+ it ".allocate raises a TypeError" do
+ lambda do
+ Bignum.allocate
+ end.should raise_error(TypeError)
+ end
+
+ it ".new is undefined" do
+ lambda do
+ Bignum.new
+ end.should raise_error(NoMethodError)
+ end
+
+ ruby_version_is '2.4' do
+ it "unified into Integer" do
+ Bignum.should equal(Integer)
+ end
+
+ it "is deprecated" do
+ -> {
+ Bignum
+ }.should complain(/constant ::Bignum is deprecated/)
+ end
+ end
+end
diff --git a/spec/ruby/core/bignum/bit_and_spec.rb b/spec/ruby/core/bignum/bit_and_spec.rb
new file mode 100644
index 0000000000..4bc5c11e1b
--- /dev/null
+++ b/spec/ruby/core/bignum/bit_and_spec.rb
@@ -0,0 +1,50 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#&" do
+ before :each do
+ @bignum = bignum_value(5)
+ end
+
+ it "returns self bitwise AND other" do
+ @bignum = bignum_value(5)
+ (@bignum & 3).should == 1
+ (@bignum & 52).should == 4
+ (@bignum & bignum_value(9921)).should == 9223372036854775809
+
+ ((2*bignum_value) & 1).should == 0
+ ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616
+ end
+
+ it "returns self bitwise AND other when one operand is negative" do
+ ((2*bignum_value) & -1).should == (2*bignum_value)
+ ((4*bignum_value) & -1).should == (4*bignum_value)
+ (@bignum & -0xffffffffffffff5).should == 9223372036854775809
+ (@bignum & -@bignum).should == 1
+ (@bignum & -0x8000000000000000).should == 9223372036854775808
+ end
+
+ it "returns self bitwise AND other when both operands are negative" do
+ (-@bignum & -0x4000000000000005).should == -13835058055282163717
+ (-@bignum & -@bignum).should == -9223372036854775813
+ (-@bignum & -0x4000000000000000).should == -13835058055282163712
+ end
+
+ it "returns self bitwise AND other when both are negative and a multiple in bitsize of Fixnum::MIN" do
+ val = - ((1 << 93) - 1)
+ (val & val).should == val
+
+ val = - ((1 << 126) - 1)
+ (val & val).should == val
+ end
+
+ it "raises a TypeError when passed a Float" do
+ lambda { (@bignum & 3.4) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError and does not call #to_int when defined on an object" do
+ obj = mock("bignum bit and")
+ obj.should_not_receive(:to_int)
+
+ lambda { @bignum & obj }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/bit_length_spec.rb b/spec/ruby/core/bignum/bit_length_spec.rb
new file mode 100644
index 0000000000..1c4c518345
--- /dev/null
+++ b/spec/ruby/core/bignum/bit_length_spec.rb
@@ -0,0 +1,33 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#bit_length" do
+ it "returns the position of the leftmost bit of a positive number" do
+ (2**1000-1).bit_length.should == 1000
+ (2**1000).bit_length.should == 1001
+ (2**1000+1).bit_length.should == 1001
+
+ (2**10000-1).bit_length.should == 10000
+ (2**10000).bit_length.should == 10001
+ (2**10000+1).bit_length.should == 10001
+
+ (1 << 100).bit_length.should == 101
+ (1 << 100).succ.bit_length.should == 101
+ (1 << 100).pred.bit_length.should == 100
+ (1 << 10000).bit_length.should == 10001
+ end
+
+ it "returns the position of the leftmost 0 bit of a negative number" do
+ (-2**10000-1).bit_length.should == 10001
+ (-2**10000).bit_length.should == 10000
+ (-2**10000+1).bit_length.should == 10000
+
+ (-2**1000-1).bit_length.should == 1001
+ (-2**1000).bit_length.should == 1000
+ (-2**1000+1).bit_length.should == 1000
+
+ ((-1 << 100)-1).bit_length.should == 101
+ ((-1 << 100)-1).succ.bit_length.should == 100
+ ((-1 << 100)-1).pred.bit_length.should == 101
+ ((-1 << 10000)-1).bit_length.should == 10001
+ end
+end
diff --git a/spec/ruby/core/bignum/bit_or_spec.rb b/spec/ruby/core/bignum/bit_or_spec.rb
new file mode 100644
index 0000000000..6bcb6ead6b
--- /dev/null
+++ b/spec/ruby/core/bignum/bit_or_spec.rb
@@ -0,0 +1,41 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#|" do
+ before :each do
+ @bignum = bignum_value(11)
+ end
+
+ it "returns self bitwise OR other" do
+ (@bignum | 2).should == 9223372036854775819
+ (@bignum | 9).should == 9223372036854775819
+ (@bignum | bignum_value).should == 9223372036854775819
+ end
+
+ it "returns self bitwise OR other when one operand is negative" do
+ (@bignum | -0x40000000000000000).should == -64563604257983430645
+ (@bignum | -@bignum).should == -1
+ (@bignum | -0x8000000000000000).should == -9223372036854775797
+ end
+
+ it "returns self bitwise OR other when both operands are negative" do
+ (-@bignum | -0x4000000000000005).should == -1
+ (-@bignum | -@bignum).should == -9223372036854775819
+ (-@bignum | -0x4000000000000000).should == -11
+ end
+
+ it "raises a TypeError when passed a Float" do
+ not_supported_on :opal do
+ lambda {
+ bignum_value | bignum_value(0xffff).to_f
+ }.should raise_error(TypeError)
+ end
+ lambda { @bignum | 9.9 }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError and does not call #to_int when defined on an object" do
+ obj = mock("bignum bit or")
+ obj.should_not_receive(:to_int)
+
+ lambda { @bignum | obj }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/bit_xor_spec.rb b/spec/ruby/core/bignum/bit_xor_spec.rb
new file mode 100644
index 0000000000..ef4b4e6ae3
--- /dev/null
+++ b/spec/ruby/core/bignum/bit_xor_spec.rb
@@ -0,0 +1,47 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#^" do
+ before :each do
+ @bignum = bignum_value(18)
+ end
+
+ it "returns self bitwise EXCLUSIVE OR other" do
+ (@bignum ^ 2).should == 9223372036854775824
+ (@bignum ^ @bignum).should == 0
+ (@bignum ^ 14).should == 9223372036854775836
+ end
+
+ it "returns self bitwise EXCLUSIVE OR other when one operand is negative" do
+ (@bignum ^ -0x40000000000000000).should == -64563604257983430638
+ (@bignum ^ -@bignum).should == -4
+ (@bignum ^ -0x8000000000000000).should == -18446744073709551598
+ end
+
+ it "returns self bitwise EXCLUSIVE OR other when both operands are negative" do
+ (-@bignum ^ -0x40000000000000000).should == 64563604257983430638
+ (-@bignum ^ -@bignum).should == 0
+ (-@bignum ^ -0x4000000000000000).should == 13835058055282163694
+ end
+
+ it "returns self bitwise EXCLUSIVE OR other when all bits are 1 and other value is negative" do
+ (9903520314283042199192993791 ^ -1).should == -9903520314283042199192993792
+ (784637716923335095479473677900958302012794430558004314111 ^ -1).should ==
+ -784637716923335095479473677900958302012794430558004314112
+ end
+
+ it "raises a TypeError when passed a Float" do
+ not_supported_on :opal do
+ lambda {
+ bignum_value ^ bignum_value(0xffff).to_f
+ }.should raise_error(TypeError)
+ end
+ lambda { @bignum ^ 14.5 }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError and does not call #to_int when defined on an object" do
+ obj = mock("bignum bit xor")
+ obj.should_not_receive(:to_int)
+
+ lambda { @bignum ^ obj }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/case_compare_spec.rb b/spec/ruby/core/bignum/case_compare_spec.rb
new file mode 100644
index 0000000000..d7e0a89487
--- /dev/null
+++ b/spec/ruby/core/bignum/case_compare_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
+
+describe "Bignum#===" do
+ it_behaves_like :bignum_equal, :===
+end
diff --git a/spec/ruby/core/bignum/coerce_spec.rb b/spec/ruby/core/bignum/coerce_spec.rb
new file mode 100644
index 0000000000..40decaf51a
--- /dev/null
+++ b/spec/ruby/core/bignum/coerce_spec.rb
@@ -0,0 +1,65 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#coerce" do
+ it "coerces other to a Bignum and returns [other, self] when passed a Fixnum" do
+ a = bignum_value
+ ary = a.coerce(2)
+
+ ary[0].should be_kind_of(Bignum)
+ ary[1].should be_kind_of(Bignum)
+ ary.should == [2, a]
+ end
+
+ it "returns [other, self] when passed a Bignum" do
+ a = bignum_value
+ b = bignum_value
+ ary = a.coerce(b)
+
+ ary[0].should be_kind_of(Bignum)
+ ary[1].should be_kind_of(Bignum)
+ ary.should == [b, a]
+ end
+
+ it "raises a TypeError when not passed a Fixnum or Bignum" do
+ a = bignum_value
+
+ lambda { a.coerce(nil) }.should raise_error(TypeError)
+ lambda { a.coerce(mock('str')) }.should raise_error(TypeError)
+ lambda { a.coerce(1..4) }.should raise_error(TypeError)
+ lambda { a.coerce(:test) }.should raise_error(TypeError)
+ end
+
+ ruby_version_is ""..."2.4" do
+ it "raises a TypeError when passed a String" do
+ a = bignum_value
+ lambda { a.coerce("123") }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed a Float" do
+ a = bignum_value
+ lambda { a.coerce(12.3) }.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is "2.4" do
+ it "coerces both values to Floats and returns [other, self] when passed a Float" do
+ a = bignum_value
+ a.coerce(1.2).should == [1.2, a.to_f]
+ end
+
+ it "coerces both values to Floats and returns [other, self] when passed a String" do
+ a = bignum_value
+ a.coerce("123").should == [123.0, a.to_f]
+ end
+
+ it "calls #to_f to coerce other to a Float" do
+ b = mock("bignum value")
+ b.should_receive(:to_f).and_return(1.2)
+
+ a = bignum_value
+ ary = a.coerce(b)
+
+ ary.should == [1.2, a.to_f]
+ end
+ end
+end
diff --git a/spec/ruby/core/bignum/comparison_spec.rb b/spec/ruby/core/bignum/comparison_spec.rb
new file mode 100644
index 0000000000..435cc9aea2
--- /dev/null
+++ b/spec/ruby/core/bignum/comparison_spec.rb
@@ -0,0 +1,162 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#<=>" do
+ describe "with a Fixnum" do
+ it "returns -1 when other is larger" do
+ (-bignum_value <=> 2).should == -1
+ end
+
+ it "returns 1 when other is smaller" do
+ (bignum_value <=> 2).should == 1
+ end
+ end
+
+ describe "with a Bignum" do
+ describe "when other is negative" do
+ it "returns -1 when self is negative and other is larger" do
+ (-bignum_value(42) <=> -bignum_value).should == -1
+ end
+
+ it "returns 0 when other is equal" do
+ (-bignum_value <=> -bignum_value).should == 0
+ end
+
+ it "returns 1 when self is negative and other is smaller" do
+ (-bignum_value <=> -bignum_value(94)).should == 1
+ end
+
+ it "returns 1 when self is positive" do
+ (bignum_value <=> -bignum_value).should == 1
+ end
+ end
+
+ describe "when other is positive" do
+ it "returns -1 when self is negative" do
+ (-bignum_value <=> bignum_value).should == -1
+ end
+
+ it "returns -1 when self is positive and other is larger" do
+ (bignum_value <=> bignum_value(38)).should == -1
+ end
+
+ it "returns 0 when other is equal" do
+ (bignum_value <=> bignum_value).should == 0
+ end
+
+ it "returns 1 when other is smaller" do
+ (bignum_value(56) <=> bignum_value).should == 1
+ end
+ end
+ end
+
+ describe "with a Float" do
+ describe "when other is negative" do
+ it "returns -1 when self is negative and other is larger" do
+ (-bignum_value(0xffff) <=> -bignum_value.to_f).should == -1
+ end
+
+ it "returns 0 when other is equal" do
+ (-bignum_value <=> -bignum_value.to_f).should == 0
+ end
+
+ it "returns 1 when self is negative and other is smaller" do
+ (-bignum_value <=> -bignum_value(0xffef).to_f).should == 1
+ end
+
+ it "returns 1 when self is positive" do
+ (bignum_value <=> -bignum_value.to_f).should == 1
+ end
+ end
+
+ describe "when other is positive" do
+ it "returns -1 when self is negative" do
+ (-bignum_value <=> bignum_value.to_f).should == -1
+ end
+
+ it "returns -1 when self is positive and other is larger" do
+ (bignum_value <=> bignum_value(0xfffe).to_f).should == -1
+ end
+
+ it "returns 0 when other is equal" do
+ (bignum_value <=> bignum_value.to_f).should == 0
+ end
+
+ it "returns 1 when other is smaller" do
+ (bignum_value(0xfeff) <=> bignum_value.to_f).should == 1
+ end
+ end
+ end
+
+ describe "with an Object" do
+ before :each do
+ @big = bignum_value
+ @num = mock("value for Bignum#<=>")
+ end
+
+ it "calls #coerce on other" do
+ @num.should_receive(:coerce).with(@big).and_return([@big.to_f, 2.5])
+ @big <=> @num
+ end
+
+ ruby_version_is ""..."2.5" do
+ it "returns nil if #coerce raises an exception" do
+ @num.should_receive(:coerce).with(@big).and_raise(RuntimeError)
+ lambda {
+ @result = (@big <=> @num)
+ }.should complain(/Numerical comparison operators will no more rescue exceptions/)
+ @result.should be_nil
+ end
+ end
+
+ ruby_version_is "2.5" do
+ it "lets the exception go through if #coerce raises an exception" do
+ @num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error"))
+ lambda {
+ @big <=> @num
+ }.should raise_error(RuntimeError, "my error")
+ end
+ end
+
+ it "raises an exception if #coerce raises a non-StandardError exception" do
+ @num.should_receive(:coerce).with(@big).and_raise(Exception)
+ lambda { @big <=> @num }.should raise_error(Exception)
+ end
+
+ it "returns nil if #coerce does not return an Array" do
+ @num.should_receive(:coerce).with(@big).and_return(nil)
+ (@big <=> @num).should be_nil
+ end
+
+ it "returns -1 if the coerced value is larger" do
+ @num.should_receive(:coerce).with(@big).and_return([@big, bignum_value(10)])
+ (@big <=> @num).should == -1
+ end
+
+ it "returns 0 if the coerced value is equal" do
+ @num.should_receive(:coerce).with(@big).and_return([@big, bignum_value])
+ (@big <=> @num).should == 0
+ end
+
+ it "returns 1 if the coerced value is smaller" do
+ @num.should_receive(:coerce).with(@big).and_return([@big, 22])
+ (@big <=> @num).should == 1
+ end
+ end
+
+ # The tests below are taken from matz's revision 23730 for Ruby trunk
+ it "returns 1 when self is Infinity and other is a Bignum" do
+ (infinity_value <=> Float::MAX.to_i*2).should == 1
+ end
+
+ it "returns -1 when self is negative and other is Infinty" do
+ (-Float::MAX.to_i*2 <=> infinity_value).should == -1
+ end
+
+ it "returns 1 when self is negative and other is -Infinity" do
+ (-Float::MAX.to_i*2 <=> -infinity_value).should == 1
+ end
+
+ it "returns -1 when self is -Infinity and other is negative" do
+ (-infinity_value <=> -Float::MAX.to_i*2).should == -1
+ end
+end
diff --git a/spec/ruby/core/bignum/complement_spec.rb b/spec/ruby/core/bignum/complement_spec.rb
new file mode 100644
index 0000000000..be6bc21b19
--- /dev/null
+++ b/spec/ruby/core/bignum/complement_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#~" do
+ it "returns self with each bit flipped" do
+ (~bignum_value(48)).should == -9223372036854775857
+ (~(-bignum_value(21))).should == 9223372036854775828
+ (~bignum_value(1)).should == -9223372036854775810
+ end
+end
diff --git a/spec/ruby/core/bignum/div_spec.rb b/spec/ruby/core/bignum/div_spec.rb
new file mode 100644
index 0000000000..6c165289e8
--- /dev/null
+++ b/spec/ruby/core/bignum/div_spec.rb
@@ -0,0 +1,21 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/divide', __FILE__)
+
+describe "Bignum#div" do
+ it_behaves_like(:bignum_divide, :div)
+
+ it "returns a result of integer division of self by a float argument" do
+ bignum_value(88).div(4294967295.5).should eql(2147483648)
+ not_supported_on :opal do
+ bignum_value(88).div(4294967295.0).should eql(2147483648)
+ bignum_value(88).div(bignum_value(88).to_f).should eql(1)
+ bignum_value(88).div(-bignum_value(88).to_f).should eql(-1)
+ end
+ end
+
+ # #5490
+ it "raises ZeroDivisionError if the argument is Float zero" do
+ lambda { bignum_value(88).div(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { bignum_value(88).div(-0.0) }.should raise_error(ZeroDivisionError)
+ end
+end
diff --git a/spec/ruby/core/bignum/divide_spec.rb b/spec/ruby/core/bignum/divide_spec.rb
new file mode 100644
index 0000000000..b81938b707
--- /dev/null
+++ b/spec/ruby/core/bignum/divide_spec.rb
@@ -0,0 +1,18 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/divide', __FILE__)
+
+describe "Bignum#/" do
+ it_behaves_like(:bignum_divide, :/)
+
+ it "returns self divided by float" do
+ not_supported_on :opal do
+ (bignum_value(88) / 4294967295.0).should be_close(2147483648.5, TOLERANCE)
+ end
+ (bignum_value(88) / 4294967295.5).should be_close(2147483648.25, TOLERANCE)
+ end
+
+ it "does NOT raise ZeroDivisionError if other is zero and is a Float" do
+ (bignum_value / 0.0).to_s.should == 'Infinity'
+ (bignum_value / -0.0).to_s.should == '-Infinity'
+ end
+end
diff --git a/spec/ruby/core/bignum/divmod_spec.rb b/spec/ruby/core/bignum/divmod_spec.rb
new file mode 100644
index 0000000000..656f23482b
--- /dev/null
+++ b/spec/ruby/core/bignum/divmod_spec.rb
@@ -0,0 +1,81 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#divmod" do
+ before :each do
+ @bignum = bignum_value(55)
+ end
+
+ # Based on MRI's test/test_integer.rb (test_divmod),
+ # MRI maintains the following property:
+ # if q, r = a.divmod(b) ==>
+ # assert(0 < b ? (0 <= r && r < b) : (b < r && r <= 0))
+ # So, r is always between 0 and b.
+ it "returns an Array containing quotient and modulus obtained from dividing self by the given argument" do
+ @bignum.divmod(4).should == [2305843009213693965, 3]
+ @bignum.divmod(13).should == [709490156681136604, 11]
+
+ @bignum.divmod(4.5).should == [2049638230412172288, 3.5]
+
+ not_supported_on :opal do
+ @bignum.divmod(4.0).should == [2305843009213693952, 0.0]
+ @bignum.divmod(13.0).should == [709490156681136640, 8.0]
+
+ @bignum.divmod(2.0).should == [4611686018427387904, 0.0]
+ end
+
+ @bignum.divmod(bignum_value).should == [1, 55]
+
+ (-(10**50)).divmod(-(10**40 + 1)).should == [9999999999, -9999999999999999999999999999990000000001]
+ (10**50).divmod(10**40 + 1).should == [9999999999, 9999999999999999999999999999990000000001]
+
+ (-10**50).divmod(10**40 + 1).should == [-10000000000, 10000000000]
+ (10**50).divmod(-(10**40 + 1)).should == [-10000000000, -10000000000]
+ end
+
+ describe "with q = floor(x/y), a = q*b + r," do
+ it "returns [q,r] when a < 0, b > 0 and |a| < b" do
+ a = -@bignum + 1
+ b = @bignum
+ a.divmod(b).should == [-1, 1]
+ end
+
+ it "returns [q,r] when a > 0, b < 0 and a > |b|" do
+ b = -@bignum + 1
+ a = @bignum
+ a.divmod(b).should == [-2, -@bignum + 2]
+ end
+
+ it "returns [q,r] when a > 0, b < 0 and a < |b|" do
+ a = @bignum - 1
+ b = -@bignum
+ a.divmod(b).should == [-1, -1]
+ end
+
+ it "returns [q,r] when a < 0, b < 0 and |a| < |b|" do
+ a = -@bignum + 1
+ b = -@bignum
+ a.divmod(b).should == [0, -@bignum + 1]
+ end
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0" do
+ lambda { @bignum.divmod(0) }.should raise_error(ZeroDivisionError)
+ lambda { (-@bignum).divmod(0) }.should raise_error(ZeroDivisionError)
+ end
+
+ # Behaviour established as correct in r23953
+ it "raises a FloatDomainError if other is NaN" do
+ lambda { @bignum.divmod(nan_value) }.should raise_error(FloatDomainError)
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
+ lambda { @bignum.divmod(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { (-@bignum).divmod(0.0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a TypeError when the given argument is not an Integer" do
+ lambda { @bignum.divmod(mock('10')) }.should raise_error(TypeError)
+ lambda { @bignum.divmod("10") }.should raise_error(TypeError)
+ lambda { @bignum.divmod(:symbol) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/element_reference_spec.rb b/spec/ruby/core/bignum/element_reference_spec.rb
new file mode 100644
index 0000000000..e5ee9e15ac
--- /dev/null
+++ b/spec/ruby/core/bignum/element_reference_spec.rb
@@ -0,0 +1,30 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#[]" do
+ before :each do
+ @bignum = bignum_value(4996)
+ end
+
+ it "returns the nth bit in the binary representation of self" do
+ @bignum[2].should == 1
+ @bignum[9.2].should == 1
+ @bignum[21].should == 0
+ @bignum[0xffffffff].should == 0
+ @bignum[-0xffffffff].should == 0
+ end
+
+ it "tries to convert the given argument to an Integer using #to_int" do
+ @bignum[1.3].should == @bignum[1]
+
+ (obj = mock('2')).should_receive(:to_int).at_least(1).and_return(2)
+ @bignum[obj].should == 1
+ end
+
+ it "raises a TypeError when the given argument can't be converted to Integer" do
+ obj = mock('asdf')
+ lambda { @bignum[obj] }.should raise_error(TypeError)
+
+ obj.should_receive(:to_int).and_return("asdf")
+ lambda { @bignum[obj] }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/eql_spec.rb b/spec/ruby/core/bignum/eql_spec.rb
new file mode 100644
index 0000000000..c9eff9ef08
--- /dev/null
+++ b/spec/ruby/core/bignum/eql_spec.rb
@@ -0,0 +1,22 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#eql? when given a Bignum" do
+ it "returns true if the given argument has the same value" do
+ a = bignum_value(13)
+ a.should eql(bignum_value(13))
+ (-a).should eql(-bignum_value(13))
+ end
+end
+
+describe "Bignum#eql? when given a non-Bignum" do
+ it "returns false" do
+ a = bignum_value(13)
+ a.should_not eql(a.to_f)
+
+ a.should_not eql(2)
+ a.should_not eql(3.14)
+ a.should_not eql(:symbol)
+ a.should_not eql("String")
+ a.should_not eql(mock('str'))
+ end
+end
diff --git a/spec/ruby/core/bignum/equal_value_spec.rb b/spec/ruby/core/bignum/equal_value_spec.rb
new file mode 100644
index 0000000000..0117d58683
--- /dev/null
+++ b/spec/ruby/core/bignum/equal_value_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
+
+describe "Bignum#==" do
+ it_behaves_like :bignum_equal, :==
+end
diff --git a/spec/ruby/core/bignum/even_spec.rb b/spec/ruby/core/bignum/even_spec.rb
new file mode 100644
index 0000000000..a84ea80075
--- /dev/null
+++ b/spec/ruby/core/bignum/even_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#even?" do
+ it "returns true if self is even and positive" do
+ (10000**10).even?.should be_true
+ end
+
+ it "returns true if self is even and negative" do
+ (-10000**10).even?.should be_true
+ end
+
+ it "returns false if self is odd and positive" do
+ (9879**976).even?.should be_false
+ end
+
+ it "returns false if self is odd and negative" do
+ (-9879**976).even?.should be_false
+ end
+end
diff --git a/spec/ruby/core/bignum/exponent_spec.rb b/spec/ruby/core/bignum/exponent_spec.rb
new file mode 100644
index 0000000000..9026c1ff3b
--- /dev/null
+++ b/spec/ruby/core/bignum/exponent_spec.rb
@@ -0,0 +1,29 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#**" do
+ before :each do
+ @bignum = bignum_value(47)
+ end
+
+ it "returns self raised to other power" do
+ (@bignum ** 4).should == 7237005577332262361485077344629993318496048279512298547155833600056910050625
+ (@bignum ** 1.2).should be_close(57262152889751597425762.57804, TOLERANCE)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda { @bignum ** mock('10') }.should raise_error(TypeError)
+ lambda { @bignum ** "10" }.should raise_error(TypeError)
+ lambda { @bignum ** :symbol }.should raise_error(TypeError)
+ end
+
+ it "switch to a Float when the values is too big" do
+ flt = (@bignum ** @bignum)
+ flt.should be_kind_of(Float)
+ flt.infinite?.should == 1
+ end
+
+ it "returns a complex number when negative and raised to a fractional power" do
+ ((-@bignum) ** (1.0/3)) .should be_close(Complex(1048576,1816186.907597341), TOLERANCE)
+ ((-@bignum) ** Rational(1,3)).should be_close(Complex(1048576,1816186.907597341), TOLERANCE)
+ end
+end
diff --git a/spec/ruby/core/bignum/fdiv_spec.rb b/spec/ruby/core/bignum/fdiv_spec.rb
new file mode 100644
index 0000000000..35f3ede010
--- /dev/null
+++ b/spec/ruby/core/bignum/fdiv_spec.rb
@@ -0,0 +1,5 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#fdiv" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/bignum/gt_spec.rb b/spec/ruby/core/bignum/gt_spec.rb
new file mode 100644
index 0000000000..5c814eedd1
--- /dev/null
+++ b/spec/ruby/core/bignum/gt_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#>" do
+ before :each do
+ @bignum = bignum_value(732)
+ end
+
+ it "returns true if self is greater than the given argument" do
+ (@bignum > (@bignum - 1)).should == true
+ (@bignum > 14.6).should == true
+ (@bignum > 10).should == true
+
+ (@bignum > (@bignum + 500)).should == false
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { @bignum > "4" }.should raise_error(ArgumentError)
+ lambda { @bignum > mock('str') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/bignum/gte_spec.rb b/spec/ruby/core/bignum/gte_spec.rb
new file mode 100644
index 0000000000..e32ce19e0f
--- /dev/null
+++ b/spec/ruby/core/bignum/gte_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#>=" do
+ before :each do
+ @bignum = bignum_value(14)
+ end
+
+ it "returns true if self is greater than or equal to other" do
+ (@bignum >= @bignum).should == true
+ (@bignum >= (@bignum + 2)).should == false
+ (@bignum >= 5664.2).should == true
+ (@bignum >= 4).should == true
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { @bignum >= "4" }.should raise_error(ArgumentError)
+ lambda { @bignum >= mock('str') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/bignum/hash_spec.rb b/spec/ruby/core/bignum/hash_spec.rb
new file mode 100644
index 0000000000..bdc85c3fdc
--- /dev/null
+++ b/spec/ruby/core/bignum/hash_spec.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#hash" do
+ it "is provided" do
+ bignum_value.respond_to?(:hash).should == true
+ end
+
+ it "is stable" do
+ bignum_value.hash.should == bignum_value.hash
+ bignum_value.hash.should_not == bignum_value(1).hash
+ end
+end
diff --git a/spec/ruby/core/bignum/left_shift_spec.rb b/spec/ruby/core/bignum/left_shift_spec.rb
new file mode 100644
index 0000000000..364f51b708
--- /dev/null
+++ b/spec/ruby/core/bignum/left_shift_spec.rb
@@ -0,0 +1,73 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#<< with n << m" do
+ before :each do
+ @bignum = bignum_value * 16
+ end
+
+ it "returns n shifted left m bits when n > 0, m > 0" do
+ (@bignum << 4).should == 2361183241434822606848
+ end
+
+ it "returns n shifted left m bits when n < 0, m > 0" do
+ (-@bignum << 9).should == -75557863725914323419136
+ end
+
+ it "returns n shifted right m bits when n > 0, m < 0" do
+ (@bignum << -1).should == 73786976294838206464
+ end
+
+ it "returns n shifted right m bits when n < 0, m < 0" do
+ (-@bignum << -2).should == -36893488147419103232
+ end
+
+ it "returns n when n > 0, m == 0" do
+ (@bignum << 0).should == @bignum
+ end
+
+ it "returns n when n < 0, m == 0" do
+ (-@bignum << 0).should == -@bignum
+ end
+
+ it "returns 0 when m < 0 and m == p where 2**p > n >= 2**(p-1)" do
+ (@bignum << -68).should == 0
+ end
+
+ it "returns 0 when m < 0 and m is a Bignum" do
+ (@bignum << -bignum_value).should == 0
+ end
+
+ it "returns a Fixnum == fixnum_max when (fixnum_max * 2) << -1 and n > 0" do
+ result = (fixnum_max * 2) << -1
+ result.should be_an_instance_of(Fixnum)
+ result.should == fixnum_max
+ end
+
+ it "returns a Fixnum == fixnum_min when (fixnum_min * 2) << -1 and n < 0" do
+ result = (fixnum_min * 2) << -1
+ result.should be_an_instance_of(Fixnum)
+ result.should == fixnum_min
+ end
+
+ it "calls #to_int to convert the argument to an Integer" do
+ obj = mock("4")
+ obj.should_receive(:to_int).and_return(4)
+
+ (@bignum << obj).should == 2361183241434822606848
+ end
+
+ it "raises a TypeError when #to_int does not return an Integer" do
+ obj = mock("a string")
+ obj.should_receive(:to_int).and_return("asdf")
+
+ lambda { @bignum << obj }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed nil" do
+ lambda { @bignum << nil }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed a String" do
+ lambda { @bignum << "4" }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/lt_spec.rb b/spec/ruby/core/bignum/lt_spec.rb
new file mode 100644
index 0000000000..802c68a58b
--- /dev/null
+++ b/spec/ruby/core/bignum/lt_spec.rb
@@ -0,0 +1,22 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#<" do
+ before :each do
+ @bignum = bignum_value(32)
+ end
+
+ it "returns true if self is less than the given argument" do
+ (@bignum < @bignum + 1).should == true
+ (-@bignum < -(@bignum - 1)).should == true
+
+ (@bignum < 1).should == false
+ (@bignum < 5).should == false
+
+ (@bignum < 4.999).should == false
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { @bignum < "4" }.should raise_error(ArgumentError)
+ lambda { @bignum < mock('str') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/bignum/lte_spec.rb b/spec/ruby/core/bignum/lte_spec.rb
new file mode 100644
index 0000000000..9a1d22d3be
--- /dev/null
+++ b/spec/ruby/core/bignum/lte_spec.rb
@@ -0,0 +1,24 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#<=" do
+ before :each do
+ @bignum = bignum_value(39)
+ end
+
+ it "returns true if self is less than or equal to other" do
+ (@bignum <= @bignum).should == true
+ (-@bignum <= -(@bignum - 1)).should == true
+
+ (@bignum <= 4.999).should == false
+ end
+
+ it "returns false if compares with near float" do
+ (@bignum <= (@bignum + 0.0)).should == false
+ (@bignum <= (@bignum + 0.5)).should == false
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { @bignum <= "4" }.should raise_error(ArgumentError)
+ lambda { @bignum <= mock('str') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/bignum/magnitude_spec.rb b/spec/ruby/core/bignum/magnitude_spec.rb
new file mode 100644
index 0000000000..35b9ba6f1e
--- /dev/null
+++ b/spec/ruby/core/bignum/magnitude_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/abs', __FILE__)
+
+describe "Bignum#magnitude" do
+ it_behaves_like(:bignum_abs, :magnitude)
+end
diff --git a/spec/ruby/core/bignum/minus_spec.rb b/spec/ruby/core/bignum/minus_spec.rb
new file mode 100644
index 0000000000..754ef7fa42
--- /dev/null
+++ b/spec/ruby/core/bignum/minus_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#-" do
+ before :each do
+ @bignum = bignum_value(314)
+ end
+
+ it "returns self minus the given Integer" do
+ (@bignum - 9).should == 9223372036854776113
+ (@bignum - 12.57).should be_close(9223372036854776109.43, TOLERANCE)
+ (@bignum - bignum_value(42)).should == 272
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda { @bignum - mock('10') }.should raise_error(TypeError)
+ lambda { @bignum - "10" }.should raise_error(TypeError)
+ lambda { @bignum - :symbol }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/modulo_spec.rb b/spec/ruby/core/bignum/modulo_spec.rb
new file mode 100644
index 0000000000..eee1dc76a6
--- /dev/null
+++ b/spec/ruby/core/bignum/modulo_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/modulo', __FILE__)
+
+describe "Bignum#%" do
+ it_behaves_like(:bignum_modulo, :%)
+end
+
+describe "Bignum#modulo" do
+ it_behaves_like(:bignum_modulo, :modulo)
+end
diff --git a/spec/ruby/core/bignum/multiply_spec.rb b/spec/ruby/core/bignum/multiply_spec.rb
new file mode 100644
index 0000000000..486e36ecbc
--- /dev/null
+++ b/spec/ruby/core/bignum/multiply_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#*" do
+ before :each do
+ @bignum = bignum_value(772)
+ end
+
+ it "returns self multiplied by the given Integer" do
+ (@bignum * (1/bignum_value(0xffff).to_f)).should be_close(1.0, TOLERANCE)
+ (@bignum * (1/bignum_value(0xffff).to_f)).should be_close(1.0, TOLERANCE)
+ (@bignum * 10).should == 92233720368547765800
+ (@bignum * (@bignum - 40)).should == 85070591730234629737795195287525433200
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda { @bignum * mock('10') }.should raise_error(TypeError)
+ lambda { @bignum * "10" }.should raise_error(TypeError)
+ lambda { @bignum * :symbol }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/odd_spec.rb b/spec/ruby/core/bignum/odd_spec.rb
new file mode 100644
index 0000000000..9d4c1191f6
--- /dev/null
+++ b/spec/ruby/core/bignum/odd_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#odd?" do
+ it "returns true if self is odd and positive" do
+ (987279**19).odd?.should be_true
+ end
+
+ it "returns true if self is odd and negative" do
+ (-9873389**97).odd?.should be_true
+ end
+
+ it "returns false if self is even and positive" do
+ (10000000**10).odd?.should be_false
+ end
+
+ it "returns false if self is even and negative" do
+ (-1000000**100).odd?.should be_false
+ end
+end
diff --git a/spec/ruby/core/bignum/plus_spec.rb b/spec/ruby/core/bignum/plus_spec.rb
new file mode 100644
index 0000000000..411e226649
--- /dev/null
+++ b/spec/ruby/core/bignum/plus_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#+" do
+ before :each do
+ @bignum = bignum_value(76)
+ end
+
+ it "returns self plus the given Integer" do
+ (@bignum + 4).should == 9223372036854775888
+ (@bignum + 4.2).should be_close(9223372036854775888.2, TOLERANCE)
+ (@bignum + bignum_value(3)).should == 18446744073709551695
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda { @bignum + mock('10') }.should raise_error(TypeError)
+ lambda { @bignum + "10" }.should raise_error(TypeError)
+ lambda { @bignum + :symbol}.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/remainder_spec.rb b/spec/ruby/core/bignum/remainder_spec.rb
new file mode 100644
index 0000000000..59f7eb4326
--- /dev/null
+++ b/spec/ruby/core/bignum/remainder_spec.rb
@@ -0,0 +1,21 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#remainder" do
+ it "returns the remainder of dividing self by other" do
+ a = bignum_value(79)
+ a.remainder(2).should == 1
+ a.remainder(97.345).should be_close(46.5674996147722, TOLERANCE)
+ a.remainder(bignum_value).should == 79
+ end
+
+ it "raises a ZeroDivisionError if other is zero and not a Float" do
+ lambda { bignum_value(66).remainder(0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "does raises ZeroDivisionError if other is zero and a Float" do
+ a = bignum_value(7)
+ b = bignum_value(32)
+ lambda { a.remainder(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { b.remainder(-0.0) }.should raise_error(ZeroDivisionError)
+ end
+end
diff --git a/spec/ruby/core/bignum/right_shift_spec.rb b/spec/ruby/core/bignum/right_shift_spec.rb
new file mode 100644
index 0000000000..d65f7c00a9
--- /dev/null
+++ b/spec/ruby/core/bignum/right_shift_spec.rb
@@ -0,0 +1,99 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#>> with n >> m" do
+ before :each do
+ @bignum = bignum_value * 16
+ end
+
+ it "returns n shifted right m bits when n > 0, m > 0" do
+ (@bignum >> 1).should == 73786976294838206464
+ end
+
+ it "returns n shifted right m bits when n < 0, m > 0" do
+ (-@bignum >> 2).should == -36893488147419103232
+ end
+
+ it "respects twos complement signed shifting" do
+ # This explicit left hand value is important because it is the
+ # exact bit pattern that matters, so it's important it's right
+ # here to show the significance.
+ #
+
+ (-42949672980000000000000 >> 14).should == -2621440001220703125
+ (-42949672980000000000001 >> 14).should == -2621440001220703126
+ # Note the off by one -------------------- ^^^^^^^^^^^^^^^^^^^^
+ # This is because even though we discard the lowest bit, in twos
+ # complement it would influence the bits to the left of it.
+
+ (-42949672980000000000000 >> 15).should == -1310720000610351563
+ (-42949672980000000000001 >> 15).should == -1310720000610351563
+
+ (-0xfffffffffffffffff >> 32).should == -68719476736
+ end
+
+ it "respects twos complement signed shifting for very large values" do
+ giant = 42949672980000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ neg = -giant
+
+ (giant >> 84).should == 2220446050284288846538547929770901490087453566957265138626098632812
+ (neg >> 84).should == -2220446050284288846538547929770901490087453566957265138626098632813
+ end
+
+ it "returns n shifted left m bits when n > 0, m < 0" do
+ (@bignum >> -2).should == 590295810358705651712
+ end
+
+ it "returns n shifted left m bits when n < 0, m < 0" do
+ (-@bignum >> -3).should == -1180591620717411303424
+ end
+
+ it "returns n when n > 0, m == 0" do
+ (@bignum >> 0).should == @bignum
+ end
+
+ it "returns n when n < 0, m == 0" do
+ (-@bignum >> 0).should == -@bignum
+ end
+
+ it "returns 0 when m > 0 and m == p where 2**p > n >= 2**(p-1)" do
+ (@bignum >> 68).should == 0
+ end
+
+ it "returns 0 when m is a Bignum" do
+ (@bignum >> bignum_value).should == 0
+ end
+
+ it "returns a Fixnum == fixnum_max when (fixnum_max * 2) >> 1 and n > 0" do
+ result = (fixnum_max * 2) >> 1
+ result.should be_an_instance_of(Fixnum)
+ result.should == fixnum_max
+ end
+
+ it "returns a Fixnum == fixnum_min when (fixnum_min * 2) >> 1 and n < 0" do
+ result = (fixnum_min * 2) >> 1
+ result.should be_an_instance_of(Fixnum)
+ result.should == fixnum_min
+ end
+
+ it "calls #to_int to convert the argument to an Integer" do
+ obj = mock("2")
+ obj.should_receive(:to_int).and_return(2)
+
+ (@bignum >> obj).should == 36893488147419103232
+ end
+
+ it "raises a TypeError when #to_int does not return an Integer" do
+ obj = mock("a string")
+ obj.should_receive(:to_int).and_return("asdf")
+
+ lambda { @bignum >> obj }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed nil" do
+ lambda { @bignum >> nil }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed a String" do
+ lambda { @bignum >> "4" }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/shared/abs.rb b/spec/ruby/core/bignum/shared/abs.rb
new file mode 100644
index 0000000000..35fd85060c
--- /dev/null
+++ b/spec/ruby/core/bignum/shared/abs.rb
@@ -0,0 +1,6 @@
+describe :bignum_abs, shared: true do
+ it "returns the absolute value" do
+ bignum_value(39).send(@method).should == 9223372036854775847
+ (-bignum_value(18)).send(@method).should == 9223372036854775826
+ end
+end
diff --git a/spec/ruby/core/bignum/shared/divide.rb b/spec/ruby/core/bignum/shared/divide.rb
new file mode 100644
index 0000000000..cbde69bbb2
--- /dev/null
+++ b/spec/ruby/core/bignum/shared/divide.rb
@@ -0,0 +1,27 @@
+describe :bignum_divide, shared: true do
+ before :each do
+ @bignum = bignum_value(88)
+ end
+
+ it "returns self divided by other" do
+ @bignum.send(@method, 4).should == 2305843009213693974
+
+ @bignum.send(@method, bignum_value(2)).should be_close(1, TOLERANCE)
+
+ (-(10**50)).send(@method, -(10**40 + 1)).should == 9999999999
+ (10**50).send(@method, 10**40 + 1).should == 9999999999
+
+ (-10**50).send(@method, 10**40 + 1).should == -10000000000
+ (10**50).send(@method, -(10**40 + 1)).should == -10000000000
+ end
+
+ it "raises a ZeroDivisionError if other is zero and not a Float" do
+ lambda { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda { @bignum.send(@method, mock('10')) }.should raise_error(TypeError)
+ lambda { @bignum.send(@method, "2") }.should raise_error(TypeError)
+ lambda { @bignum.send(@method, :symbol) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/shared/equal.rb b/spec/ruby/core/bignum/shared/equal.rb
new file mode 100644
index 0000000000..ffe4daf4f1
--- /dev/null
+++ b/spec/ruby/core/bignum/shared/equal.rb
@@ -0,0 +1,31 @@
+describe :bignum_equal, shared: true do
+ before :each do
+ @bignum = bignum_value
+ end
+
+ it "returns true if self has the same value as the given argument" do
+ @bignum.send(@method, @bignum).should == true
+ @bignum.send(@method, @bignum.to_f).should == true
+
+ @bignum.send(@method, @bignum + 1).should == false
+ (@bignum + 1).send(@method, @bignum).should == false
+
+ @bignum.send(@method, 9).should == false
+ @bignum.send(@method, 9.01).should == false
+
+ @bignum.send(@method, bignum_value(10)).should == false
+ end
+
+ it "calls 'other == self' if the given argument is not an Integer" do
+ obj = mock('not integer')
+ obj.should_receive(:==).and_return(true)
+ @bignum.send(@method, obj).should == true
+ end
+
+ it "returns the result of 'other == self' as a boolean" do
+ obj = mock('not integer')
+ obj.should_receive(:==).exactly(2).times.and_return("woot", nil)
+ @bignum.send(@method, obj).should == true
+ @bignum.send(@method, obj).should == false
+ end
+end
diff --git a/spec/ruby/core/bignum/shared/modulo.rb b/spec/ruby/core/bignum/shared/modulo.rb
new file mode 100644
index 0000000000..9814e22f3b
--- /dev/null
+++ b/spec/ruby/core/bignum/shared/modulo.rb
@@ -0,0 +1,29 @@
+describe :bignum_modulo, shared: true do
+ before :each do
+ @bignum = bignum_value
+ end
+
+ it "returns the modulus obtained from dividing self by the given argument" do
+ @bignum.send(@method, 5).should == 3
+ @bignum.send(@method, -5).should == -2
+ @bignum.send(@method, -100).should == -92
+ @bignum.send(@method, 2.22).should be_close(0.780180180180252, TOLERANCE)
+ @bignum.send(@method, bignum_value(10)).should == 9223372036854775808
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0" do
+ lambda { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ lambda { (-@bignum).send(@method, 0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
+ lambda { @bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
+ lambda { -@bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda { @bignum.send(@method, mock('10')) }.should raise_error(TypeError)
+ lambda { @bignum.send(@method, "10") }.should raise_error(TypeError)
+ lambda { @bignum.send(@method, :symbol) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/bignum/size_spec.rb b/spec/ruby/core/bignum/size_spec.rb
new file mode 100644
index 0000000000..8629cba972
--- /dev/null
+++ b/spec/ruby/core/bignum/size_spec.rb
@@ -0,0 +1,16 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#size" do
+ it "returns the number of bytes required to hold the unsigned bignum data" do
+ # that is, n such that 256 * n <= val.abs < 256 * (n+1)
+ (256**7).size.should == 8
+ (256**8).size.should == 9
+ (256**9).size.should == 10
+ (256**10).size.should == 11
+ (256**10-1).size.should == 10
+ (256**11).size.should == 12
+ (256**12).size.should == 13
+ (256**20-1).size.should == 20
+ (256**40-1).size.should == 40
+ end
+end
diff --git a/spec/ruby/core/bignum/to_f_spec.rb b/spec/ruby/core/bignum/to_f_spec.rb
new file mode 100644
index 0000000000..8d99045c95
--- /dev/null
+++ b/spec/ruby/core/bignum/to_f_spec.rb
@@ -0,0 +1,13 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#to_f" do
+ it "returns self converted to a Float" do
+ bignum_value(0x4000_0aa0_0bb0_0000).to_f.should eql(13_835_069_737_789_292_544.00)
+ bignum_value(0x8000_0000_0000_0ccc).to_f.should eql(18_446_744_073_709_555_712.00)
+ (-bignum_value(99)).to_f.should eql(-9_223_372_036_854_775_808.00)
+ end
+
+ it "converts number close to Float::MAX without exceeding MAX or producing NaN" do
+ (10**308).to_f.should == 10.0 ** 308
+ end
+end
diff --git a/spec/ruby/core/bignum/to_s_spec.rb b/spec/ruby/core/bignum/to_s_spec.rb
new file mode 100644
index 0000000000..524639adb6
--- /dev/null
+++ b/spec/ruby/core/bignum/to_s_spec.rb
@@ -0,0 +1,48 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#to_s when given a base" do
+ it "returns self converted to a String using the given base" do
+ a = 2**64
+ a.to_s(2).should == "10000000000000000000000000000000000000000000000000000000000000000"
+ a.to_s(8).should == "2000000000000000000000"
+ a.to_s(16).should == "10000000000000000"
+ a.to_s(32).should == "g000000000000"
+ end
+
+ it "raises an ArgumentError if the base is less than 2 or higher than 36" do
+ lambda { 123.to_s(-1) }.should raise_error(ArgumentError)
+ lambda { 123.to_s(0) }.should raise_error(ArgumentError)
+ lambda { 123.to_s(1) }.should raise_error(ArgumentError)
+ lambda { 123.to_s(37) }.should raise_error(ArgumentError)
+ end
+end
+
+describe "Bignum#to_s when given no base" do
+ it "returns self converted to a String using base 10" do
+ bignum_value(9).to_s.should == "9223372036854775817"
+ bignum_value.to_s.should == "9223372036854775808"
+ (-bignum_value(675)).to_s.should == "-9223372036854776483"
+ end
+end
+
+with_feature :encoding do
+ describe "Bignum#to_s" do
+ before :each do
+ @internal = Encoding.default_internal
+ end
+
+ after :each do
+ Encoding.default_internal = @internal
+ end
+
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ bignum_value.to_s.encoding.should equal(Encoding::US_ASCII)
+ end
+
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
+ Encoding.default_internal = Encoding::IBM437
+ bignum_value.to_s.encoding.should equal(Encoding::US_ASCII)
+ end
+ end
+end
diff --git a/spec/ruby/core/bignum/uminus_spec.rb b/spec/ruby/core/bignum/uminus_spec.rb
new file mode 100644
index 0000000000..7ec432ac71
--- /dev/null
+++ b/spec/ruby/core/bignum/uminus_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Bignum#-@" do
+ it "returns self as a negative value" do
+ bignum_value.send(:-@).should == -9223372036854775808
+ (-bignum_value).send(:-@).should == 9223372036854775808
+
+ bignum_value(921).send(:-@).should == -9223372036854776729
+ (-bignum_value(921).send(:-@)).should == 9223372036854776729
+ end
+end
diff --git a/spec/ruby/core/binding/clone_spec.rb b/spec/ruby/core/binding/clone_spec.rb
index ebd40f5377..d607ae2a9e 100644
--- a/spec/ruby/core/binding/clone_spec.rb
+++ b/spec/ruby/core/binding/clone_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/clone'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/clone', __FILE__)
describe "Binding#clone" do
- it_behaves_like :binding_clone, :clone
+ it_behaves_like(:binding_clone, :clone)
end
diff --git a/spec/ruby/core/binding/dup_spec.rb b/spec/ruby/core/binding/dup_spec.rb
index 43968213c8..7f242626d7 100644
--- a/spec/ruby/core/binding/dup_spec.rb
+++ b/spec/ruby/core/binding/dup_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/clone'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/clone', __FILE__)
describe "Binding#dup" do
- it_behaves_like :binding_clone, :dup
+ it_behaves_like(:binding_clone, :dup)
end
diff --git a/spec/ruby/core/binding/eval_spec.rb b/spec/ruby/core/binding/eval_spec.rb
index fff8c9cf44..4864b9f61f 100644
--- a/spec/ruby/core/binding/eval_spec.rb
+++ b/spec/ruby/core/binding/eval_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Binding#eval" do
it "behaves like Kernel.eval(..., self)" do
@@ -23,73 +23,15 @@ describe "Binding#eval" do
bind2.local_variables.should == []
end
- it "inherits __LINE__ from the enclosing scope" do
- obj = BindingSpecs::Demo.new(1)
- bind = obj.get_binding
- suppress_warning {bind.eval("__LINE__")}.should == obj.get_line_of_binding
- end
-
- it "preserves __LINE__ across multiple calls to eval" do
- obj = BindingSpecs::Demo.new(1)
- bind = obj.get_binding
- suppress_warning {bind.eval("__LINE__")}.should == obj.get_line_of_binding
- suppress_warning {bind.eval("__LINE__")}.should == obj.get_line_of_binding
- end
-
- it "increments __LINE__ on each line of a multiline eval" do
- obj = BindingSpecs::Demo.new(1)
- bind = obj.get_binding
- suppress_warning {bind.eval("#foo\n__LINE__")}.should == obj.get_line_of_binding + 1
- end
-
- it "inherits __LINE__ from the enclosing scope even if the Binding is created with #send" do
- obj = BindingSpecs::Demo.new(1)
- bind, line = obj.get_binding_with_send_and_line
- suppress_warning {bind.eval("__LINE__")}.should == line
- end
-
- it "starts with a __LINE__ of 1 if a filename is passed" do
- bind = BindingSpecs::Demo.new(1).get_binding
- bind.eval("__LINE__", "(test)").should == 1
- bind.eval("#foo\n__LINE__", "(test)").should == 2
- end
-
- it "starts with a __LINE__ from the third argument if passed" do
- bind = BindingSpecs::Demo.new(1).get_binding
- bind.eval("__LINE__", "(test)", 88).should == 88
- bind.eval("#foo\n__LINE__", "(test)", 88).should == 89
- end
-
- it "inherits __FILE__ from the enclosing scope" do
- obj = BindingSpecs::Demo.new(1)
- bind = obj.get_binding
- suppress_warning {bind.eval("__FILE__")}.should == obj.get_file_of_binding
- end
-
- it "uses the __FILE__ that is passed in" do
- bind = BindingSpecs::Demo.new(1).get_binding
- bind.eval("__FILE__", "(test)").should == "(test)"
- end
-
describe "with a file given" do
it "does not store the filename permanently" do
obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding
bind.eval("__FILE__", "test.rb").should == "test.rb"
- suppress_warning {bind.eval("__FILE__")}.should_not == "test.rb"
+ bind.eval("__FILE__").should_not == "test.rb"
end
end
- it "with __method__ returns the method where the Binding was created" do
- obj = BindingSpecs::Demo.new(1)
- bind, meth = obj.get_binding_and_method
- bind.eval("__method__").should == meth
- end
-
- it "with __method__ returns the method where the Binding was created, ignoring #send" do
- obj = BindingSpecs::Demo.new(1)
- bind, meth = obj.get_binding_with_send_and_method
- bind.eval("__method__").should == meth
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/binding/fixtures/classes.rb b/spec/ruby/core/binding/fixtures/classes.rb
index 43e32cacf6..05ca2479ba 100644
--- a/spec/ruby/core/binding/fixtures/classes.rb
+++ b/spec/ruby/core/binding/fixtures/classes.rb
@@ -25,18 +25,6 @@ module BindingSpecs
__FILE__
end
- def get_binding_with_send_and_line
- [send(:binding), __LINE__]
- end
-
- def get_binding_and_method
- [binding, :get_binding_and_method]
- end
-
- def get_binding_with_send_and_method
- [send(:binding), :get_binding_with_send_and_method]
- end
-
def get_empty_binding
binding
end
diff --git a/spec/ruby/core/binding/fixtures/irb.rb b/spec/ruby/core/binding/fixtures/irb.rb
deleted file mode 100644
index 5f305f2d5d..0000000000
--- a/spec/ruby/core/binding/fixtures/irb.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-a = 10
-
-binding.irb
diff --git a/spec/ruby/core/binding/fixtures/irbrc b/spec/ruby/core/binding/fixtures/irbrc
deleted file mode 100644
index 2bc12af2f7..0000000000
--- a/spec/ruby/core/binding/fixtures/irbrc
+++ /dev/null
@@ -1 +0,0 @@
-# empty configuration
diff --git a/spec/ruby/core/binding/fixtures/location.rb b/spec/ruby/core/binding/fixtures/location.rb
deleted file mode 100644
index a78ae75731..0000000000
--- a/spec/ruby/core/binding/fixtures/location.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module BindingSpecs
- module LocationMethod
- FILE_PATH = __FILE__
- TEST_BINDING = binding
- end
-end
diff --git a/spec/ruby/core/binding/irb_spec.rb b/spec/ruby/core/binding/irb_spec.rb
deleted file mode 100644
index bd37b419f9..0000000000
--- a/spec/ruby/core/binding/irb_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.5" do
- describe "Binding#irb" do
- it "creates an IRB session with the binding in scope" do
- irb_fixture = fixture __FILE__, "irb.rb"
- irbrc_fixture = fixture __FILE__, "irbrc"
-
- out = IO.popen([{"IRBRC"=>irbrc_fixture}, *ruby_exe, irb_fixture], "r+") do |pipe|
- pipe.puts "a ** 2"
- pipe.puts "exit"
- pipe.readlines.map(&:chomp)
- end
-
- out[-3..-1].should == ["a ** 2", "100", "exit"]
- end
- end
-end
diff --git a/spec/ruby/core/binding/local_variable_defined_spec.rb b/spec/ruby/core/binding/local_variable_defined_spec.rb
index 2fc6504ee5..5fa79b19e2 100644
--- a/spec/ruby/core/binding/local_variable_defined_spec.rb
+++ b/spec/ruby/core/binding/local_variable_defined_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'Binding#local_variable_defined?' do
it 'returns false when a variable is not defined' do
@@ -26,7 +26,7 @@ describe 'Binding#local_variable_defined?' do
it 'returns true when a local variable is defined in a parent scope' do
foo = 10
- -> {
+ lambda {
binding.local_variable_defined?(:foo)
}.call.should == true
end
diff --git a/spec/ruby/core/binding/local_variable_get_spec.rb b/spec/ruby/core/binding/local_variable_get_spec.rb
index 005670becc..e65d08130e 100644
--- a/spec/ruby/core/binding/local_variable_get_spec.rb
+++ b/spec/ruby/core/binding/local_variable_get_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Binding#local_variable_get" do
it "reads local variables captured in the binding" do
@@ -11,7 +11,7 @@ describe "Binding#local_variable_get" do
it "raises a NameError for missing variables" do
bind = BindingSpecs::Demo.new(1).get_empty_binding
- -> {
+ lambda {
bind.local_variable_get(:no_such_variable)
}.should raise_error(NameError)
end
@@ -19,7 +19,7 @@ describe "Binding#local_variable_get" do
it "reads variables added later to the binding" do
bind = BindingSpecs::Demo.new(1).get_empty_binding
- -> {
+ lambda {
bind.local_variable_get(:a)
}.should raise_error(NameError)
@@ -31,7 +31,7 @@ describe "Binding#local_variable_get" do
it 'gets a local variable defined in a parent scope' do
number = 10
- -> {
+ lambda {
binding.local_variable_get(:number)
}.call.should == 10
end
@@ -45,12 +45,12 @@ describe "Binding#local_variable_get" do
it "raises a NameError on global access" do
bind = binding
- -> { bind.local_variable_get(:$0) }.should raise_error(NameError)
+ lambda { bind.local_variable_get(:$0) }.should raise_error(NameError)
end
it "raises a NameError on special variable access" do
bind = binding
- -> { bind.local_variable_get(:$~) }.should raise_error(NameError)
- -> { bind.local_variable_get(:$_) }.should raise_error(NameError)
+ lambda { bind.local_variable_get(:$~) }.should raise_error(NameError)
+ lambda { bind.local_variable_get(:$_) }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/binding/local_variable_set_spec.rb b/spec/ruby/core/binding/local_variable_set_spec.rb
index 1456c6dda1..067dcbd03e 100644
--- a/spec/ruby/core/binding/local_variable_set_spec.rb
+++ b/spec/ruby/core/binding/local_variable_set_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Binding#local_variable_set" do
it "adds nonexistent variables to the binding's eval scope" do
@@ -38,7 +38,7 @@ describe "Binding#local_variable_set" do
bind = binding
bind.local_variable_set(:number, 10)
- -> { number }.should raise_error(NameError)
+ lambda { number }.should raise_error(NameError)
end
it 'overwrites an existing local variable defined before a Binding' do
@@ -59,13 +59,13 @@ describe "Binding#local_variable_set" do
it "raises a NameError on global access" do
bind = binding
- -> { bind.local_variable_set(:$0, "") }.should raise_error(NameError)
+ lambda { bind.local_variable_set(:$0, "") }.should raise_error(NameError)
end
it "raises a NameError on special variable access" do
bind = binding
- -> { bind.local_variable_set(:$~, "") }.should raise_error(NameError)
- -> { bind.local_variable_set(:$_, "") }.should raise_error(NameError)
+ lambda { bind.local_variable_set(:$~, "") }.should raise_error(NameError)
+ lambda { bind.local_variable_set(:$_, "") }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/binding/local_variables_spec.rb b/spec/ruby/core/binding/local_variables_spec.rb
index 92c817b9a8..bc6ea71f10 100644
--- a/spec/ruby/core/binding/local_variables_spec.rb
+++ b/spec/ruby/core/binding/local_variables_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Binding#local_variables" do
it "returns an Array" do
diff --git a/spec/ruby/core/binding/location_spec.rb b/spec/ruby/core/binding/location_spec.rb
new file mode 100644
index 0000000000..b4a066038d
--- /dev/null
+++ b/spec/ruby/core/binding/location_spec.rb
@@ -0,0 +1,46 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+describe "Binding#eval" do
+ it "inherits __LINE__ from the enclosing scope" do
+ obj = BindingSpecs::Demo.new(1)
+ bind = obj.get_binding
+ bind.eval("__LINE__").should == obj.get_line_of_binding
+ end
+
+ it "preserves __LINE__ across multiple calls to eval" do
+ obj = BindingSpecs::Demo.new(1)
+ bind = obj.get_binding
+ bind.eval("__LINE__").should == obj.get_line_of_binding
+ bind.eval("__LINE__").should == obj.get_line_of_binding
+ end
+
+ it "increments __LINE__ on each line of a multiline eval" do
+ obj = BindingSpecs::Demo.new(1)
+ bind = obj.get_binding
+ bind.eval("#foo\n__LINE__").should == obj.get_line_of_binding + 1
+ end
+
+ it "starts with a __LINE__ of 1 if a filename is passed" do
+ bind = BindingSpecs::Demo.new(1).get_binding
+ bind.eval("__LINE__", "(test)").should == 1
+ bind.eval("#foo\n__LINE__", "(test)").should == 2
+ end
+
+ it "starts with a __LINE__ from the third argument if passed" do
+ bind = BindingSpecs::Demo.new(1).get_binding
+ bind.eval("__LINE__", "(test)", 88).should == 88
+ bind.eval("#foo\n__LINE__", "(test)", 88).should == 89
+ end
+
+ it "inherits __FILE__ from the enclosing scope" do
+ obj = BindingSpecs::Demo.new(1)
+ bind = obj.get_binding
+ bind.eval("__FILE__").should == obj.get_file_of_binding
+ end
+
+ it "uses the __FILE__ that is passed in" do
+ bind = BindingSpecs::Demo.new(1).get_binding
+ bind.eval("__FILE__", "(test)").should == "(test)"
+ end
+end
diff --git a/spec/ruby/core/binding/receiver_spec.rb b/spec/ruby/core/binding/receiver_spec.rb
index 4bf5e7a7bd..8784ab0e38 100644
--- a/spec/ruby/core/binding/receiver_spec.rb
+++ b/spec/ruby/core/binding/receiver_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Binding#receiver" do
it "returns the object to which binding is bound" do
diff --git a/spec/ruby/core/binding/source_location_spec.rb b/spec/ruby/core/binding/source_location_spec.rb
deleted file mode 100644
index e562bc65c8..0000000000
--- a/spec/ruby/core/binding/source_location_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/location'
-
-ruby_version_is "2.6" do
- describe "Binding#source_location" do
- it "returns an [file, line] pair" do
- b = BindingSpecs::LocationMethod::TEST_BINDING
- b.source_location.should == [BindingSpecs::LocationMethod::FILE_PATH, 4]
- end
- end
-end
diff --git a/spec/ruby/core/builtin_constants/builtin_constants_spec.rb b/spec/ruby/core/builtin_constants/builtin_constants_spec.rb
index a5141c3008..9019b127c2 100644
--- a/spec/ruby/core/builtin_constants/builtin_constants_spec.rb
+++ b/spec/ruby/core/builtin_constants/builtin_constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "RUBY_VERSION" do
it "is a String" do
@@ -43,15 +43,7 @@ describe "RUBY_RELEASE_DATE" do
end
describe "RUBY_REVISION" do
- ruby_version_is ""..."2.7" do
- it "is an Integer" do
- RUBY_REVISION.should be_kind_of(Fixnum)
- end
- end
-
- ruby_version_is "2.7" do
- it "is a String" do
- RUBY_REVISION.should be_kind_of(String)
- end
+ it "is a Fixnum" do
+ RUBY_REVISION.should be_kind_of(Fixnum)
end
end
diff --git a/spec/ruby/core/class/allocate_spec.rb b/spec/ruby/core/class/allocate_spec.rb
index c426c38ff9..015db292eb 100644
--- a/spec/ruby/core/class/allocate_spec.rb
+++ b/spec/ruby/core/class/allocate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Class#allocate" do
it "returns an instance of self" do
@@ -14,7 +14,7 @@ describe "Class#allocate" do
it "throws an exception when calling a method on a new instance" do
klass = Class.allocate
- -> do
+ lambda do
klass.new
end.should raise_error(Exception)
end
@@ -34,7 +34,7 @@ describe "Class#allocate" do
end
it "raises TypeError for #superclass" do
- -> do
+ lambda do
Class.allocate.superclass
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/class/dup_spec.rb b/spec/ruby/core/class/dup_spec.rb
index 701fd72e19..0548536bd6 100644
--- a/spec/ruby/core/class/dup_spec.rb
+++ b/spec/ruby/core/class/dup_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# NOTE: This is actually implemented by Module#initialize_copy
describe "Class#dup" do
diff --git a/spec/ruby/core/class/inherited_spec.rb b/spec/ruby/core/class/inherited_spec.rb
index 8ef8bb8c35..356e46be7c 100644
--- a/spec/ruby/core/class/inherited_spec.rb
+++ b/spec/ruby/core/class/inherited_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Class.inherited" do
@@ -92,10 +92,11 @@ describe "Class.inherited" do
end
class << top; private :inherited; end
- -> { Class.new(top) }.should_not raise_error
+ lambda { Class.new(top) }.should_not raise_error
class << top; protected :inherited; end
- -> { Class.new(top) }.should_not raise_error
+ lambda { Class.new(top) }.should_not raise_error
end
end
+
diff --git a/spec/ruby/core/class/initialize_spec.rb b/spec/ruby/core/class/initialize_spec.rb
index 9678d7b373..d268596dfe 100644
--- a/spec/ruby/core/class/initialize_spec.rb
+++ b/spec/ruby/core/class/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Class#initialize" do
it "is private" do
@@ -6,18 +6,18 @@ describe "Class#initialize" do
end
it "raises a TypeError when called on already initialized classes" do
- ->{
+ lambda{
Fixnum.send :initialize
}.should raise_error(TypeError)
- ->{
+ lambda{
Object.send :initialize
}.should raise_error(TypeError)
end
# See [redmine:2601]
it "raises a TypeError when called on BasicObject" do
- ->{
+ lambda{
BasicObject.send :initialize
}.should raise_error(TypeError)
end
@@ -28,7 +28,7 @@ describe "Class#initialize" do
end
it "raises a TypeError" do
- ->{@uninitialized.send(:initialize, Class)}.should raise_error(TypeError)
+ lambda{@uninitialized.send(:initialize, Class)}.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/core/class/new_spec.rb b/spec/ruby/core/class/new_spec.rb
index 8191ce6a37..86323b1575 100644
--- a/spec/ruby/core/class/new_spec.rb
+++ b/spec/ruby/core/class/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Class.new with a block given" do
it "yields the new class as self in the block" do
@@ -70,7 +70,7 @@ describe "Class.new" do
it "raises a TypeError if passed a metaclass" do
obj = mock("Class.new metaclass")
meta = obj.singleton_class
- -> { Class.new meta }.should raise_error(TypeError)
+ lambda { Class.new meta }.should raise_error(TypeError)
end
it "creates a class without a name" do
@@ -96,11 +96,11 @@ describe "Class.new" do
it "raises a TypeError when given a non-Class" do
error_msg = /superclass must be a Class/
- -> { Class.new("") }.should raise_error(TypeError, error_msg)
- -> { Class.new(1) }.should raise_error(TypeError, error_msg)
- -> { Class.new(:symbol) }.should raise_error(TypeError, error_msg)
- -> { Class.new(mock('o')) }.should raise_error(TypeError, error_msg)
- -> { Class.new(Module.new) }.should raise_error(TypeError, error_msg)
+ lambda { Class.new("") }.should raise_error(TypeError, error_msg)
+ lambda { Class.new(1) }.should raise_error(TypeError, error_msg)
+ lambda { Class.new(:symbol) }.should raise_error(TypeError, error_msg)
+ lambda { Class.new(mock('o')) }.should raise_error(TypeError, error_msg)
+ lambda { Class.new(Module.new) }.should raise_error(TypeError, error_msg)
end
end
diff --git a/spec/ruby/core/class/superclass_spec.rb b/spec/ruby/core/class/superclass_spec.rb
index deb5a45336..18b7ce5bde 100644
--- a/spec/ruby/core/class/superclass_spec.rb
+++ b/spec/ruby/core/class/superclass_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Class#superclass" do
it "returns the superclass of self" do
diff --git a/spec/ruby/core/class/to_s_spec.rb b/spec/ruby/core/class/to_s_spec.rb
new file mode 100644
index 0000000000..693517f0da
--- /dev/null
+++ b/spec/ruby/core/class/to_s_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+describe "Class#to_s" do
+ it 'regular class returns same name as Module#to_s' do
+ String.to_s.should == 'String'
+ end
+
+ describe 'singleton class' do
+ it 'for modules includes module name' do
+ CoreClassSpecs.singleton_class.to_s.should == '#<Class:CoreClassSpecs>'
+ end
+
+ it 'for classes includes class name' do
+ CoreClassSpecs::Record.singleton_class.to_s.should == '#<Class:CoreClassSpecs::Record>'
+ end
+
+ it 'for objects includes class name and object ID' do
+ obj = CoreClassSpecs::Record.new
+ obj.singleton_class.to_s.should =~ /#<Class:#<CoreClassSpecs::Record:0x[0-9a-f]+>>/
+ end
+ end
+end
diff --git a/spec/ruby/core/comparable/between_spec.rb b/spec/ruby/core/comparable/between_spec.rb
index fd79bb9b4c..ebeadb7569 100644
--- a/spec/ruby/core/comparable/between_spec.rb
+++ b/spec/ruby/core/comparable/between_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Comparable#between?" do
it "returns true if self is greater than or equal to the first and less than or equal to the second argument" do
diff --git a/spec/ruby/core/comparable/clamp_spec.rb b/spec/ruby/core/comparable/clamp_spec.rb
index 393496fc76..75868258b5 100644
--- a/spec/ruby/core/comparable/clamp_spec.rb
+++ b/spec/ruby/core/comparable/clamp_spec.rb
@@ -1,88 +1,50 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe 'Comparable#clamp' do
- ruby_version_is ""..."2.7" do
+ruby_version_is '2.4' do
+ describe 'Comparable#clamp' do
it 'raises an Argument error unless given 2 parameters' do
c = ComparableSpecs::Weird.new(0)
- -> { c.clamp(c) }.should raise_error(ArgumentError)
- -> { c.clamp(c, c, c) }.should raise_error(ArgumentError)
+ lambda { c.clamp(c) }.should raise_error(ArgumentError)
+ lambda { c.clamp(c, c, c) }.should raise_error(ArgumentError)
end
- end
-
- it 'raises an Argument error unless the 2 parameters are correctly ordered' do
- one = ComparableSpecs::WithOnlyCompareDefined.new(1)
- two = ComparableSpecs::WithOnlyCompareDefined.new(2)
- c = ComparableSpecs::Weird.new(3)
-
- -> { c.clamp(two, one) }.should raise_error(ArgumentError)
- one.should_receive(:<=>).any_number_of_times.and_return(nil)
- -> { c.clamp(one, two) }.should raise_error(ArgumentError)
- end
-
- it 'returns self if within the given parameters' do
- one = ComparableSpecs::WithOnlyCompareDefined.new(1)
- two = ComparableSpecs::WithOnlyCompareDefined.new(2)
- three = ComparableSpecs::WithOnlyCompareDefined.new(3)
- c = ComparableSpecs::Weird.new(2)
-
- c.clamp(one, two).should equal(c)
- c.clamp(two, two).should equal(c)
- c.clamp(one, three).should equal(c)
- c.clamp(two, three).should equal(c)
- end
-
- it 'returns the min parameter if smaller than it' do
- one = ComparableSpecs::WithOnlyCompareDefined.new(1)
- two = ComparableSpecs::WithOnlyCompareDefined.new(2)
- c = ComparableSpecs::Weird.new(0)
-
- c.clamp(one, two).should equal(one)
- end
-
- it 'returns the max parameter if greater than it' do
- one = ComparableSpecs::WithOnlyCompareDefined.new(1)
- two = ComparableSpecs::WithOnlyCompareDefined.new(2)
- c = ComparableSpecs::Weird.new(3)
- c.clamp(one, two).should equal(two)
- end
-
- ruby_version_is "2.7" do
- it 'returns self if within the given range parameters' do
+ it 'raises an Argument error unless the 2 parameters are correctly ordered' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
- three = ComparableSpecs::WithOnlyCompareDefined.new(3)
- c = ComparableSpecs::Weird.new(2)
+ c = ComparableSpecs::Weird.new(3)
- c.clamp(one..two).should equal(c)
- c.clamp(two..two).should equal(c)
- c.clamp(one..three).should equal(c)
- c.clamp(two..three).should equal(c)
+ lambda { c.clamp(two, one) }.should raise_error(ArgumentError)
+ one.should_receive(:<=>).any_number_of_times.and_return(nil)
+ lambda { c.clamp(one, two) }.should raise_error(ArgumentError)
end
- it 'returns the minimum value of the range parameters if smaller than it' do
+ it 'returns self if within the given parameters' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
- c = ComparableSpecs::Weird.new(0)
+ three = ComparableSpecs::WithOnlyCompareDefined.new(3)
+ c = ComparableSpecs::Weird.new(2)
- c.clamp(one..two).should equal(one)
+ c.clamp(one, two).should equal(c)
+ c.clamp(two, two).should equal(c)
+ c.clamp(one, three).should equal(c)
+ c.clamp(two, three).should equal(c)
end
- it 'returns the maximum value of the range parameters if greater than it' do
+ it 'returns the min parameter if smaller than it' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
- c = ComparableSpecs::Weird.new(3)
+ c = ComparableSpecs::Weird.new(0)
- c.clamp(one..two).should equal(two)
+ c.clamp(one, two).should equal(one)
end
- it 'raises an Argument error if the range parameter is exclusive' do
+ it 'returns the max parameter if greater than it' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
c = ComparableSpecs::Weird.new(3)
- -> { c.clamp(one...two) }.should raise_error(ArgumentError)
+ c.clamp(one, two).should equal(two)
end
end
end
diff --git a/spec/ruby/core/comparable/equal_value_spec.rb b/spec/ruby/core/comparable/equal_value_spec.rb
index ddcc03cb41..2bc22771b4 100644
--- a/spec/ruby/core/comparable/equal_value_spec.rb
+++ b/spec/ruby/core/comparable/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Comparable#==" do
a = b = nil
@@ -48,8 +48,16 @@ describe "Comparable#==" do
a.should_receive(:<=>).once.and_return("abc")
end
- it "raises an ArgumentError" do
- -> { (a == b) }.should raise_error(ArgumentError)
+ ruby_version_is ""..."2.3" do
+ it "returns false" do
+ (a == b).should be_false
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "raises an ArgumentError" do
+ lambda { (a == b) }.should raise_error(ArgumentError)
+ end
end
end
@@ -59,8 +67,17 @@ describe "Comparable#==" do
a.should_receive(:<=>).once.and_raise(StandardError)
end
- it "lets it go through" do
- -> { (a == b) }.should raise_error(StandardError)
+ ruby_version_is ""..."2.3" do
+ # Behaviour confirmed by MRI test suite
+ it "returns false" do
+ (a == b).should be_false
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "lets it go through" do
+ lambda { (a == b) }.should raise_error(StandardError)
+ end
end
end
@@ -70,14 +87,22 @@ describe "Comparable#==" do
a.should_receive(:<=>).once.and_raise(TypeError)
end
- it "lets it go through" do
- -> { (a == b) }.should raise_error(TypeError)
+ ruby_version_is ""..."2.3" do
+ it "returns false" do
+ (a == b).should be_false
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "lets it go through" do
+ lambda { (a == b) }.should raise_error(TypeError)
+ end
end
end
it "lets it go through if it is not a StandardError" do
a.should_receive(:<=>).once.and_raise(Exception)
- -> { (a == b) }.should raise_error(Exception)
+ lambda { (a == b) }.should raise_error(Exception)
end
end
diff --git a/spec/ruby/core/comparable/gt_spec.rb b/spec/ruby/core/comparable/gt_spec.rb
index 150e653dc7..c4739bcf2a 100644
--- a/spec/ruby/core/comparable/gt_spec.rb
+++ b/spec/ruby/core/comparable/gt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Comparable#>" do
it "calls #<=> on self with other and returns true if #<=> returns any Integer greater than 0" do
@@ -38,6 +38,6 @@ describe "Comparable#>" do
b = ComparableSpecs::Weird.new(20)
a.should_receive(:<=>).any_number_of_times.and_return(nil)
- -> { (a > b) }.should raise_error(ArgumentError)
+ lambda { (a > b) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/comparable/gte_spec.rb b/spec/ruby/core/comparable/gte_spec.rb
index 328f58c66c..c9d8264ee6 100644
--- a/spec/ruby/core/comparable/gte_spec.rb
+++ b/spec/ruby/core/comparable/gte_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'fixtures/classes'
-require_relative '../../spec_helper'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Comparable#>=" do
it "calls #<=> on self with other and returns true if #<=> returns 0 or any Integer greater than 0" do
@@ -42,6 +42,6 @@ describe "Comparable#>=" do
b = ComparableSpecs::Weird.new(20)
a.should_receive(:<=>).any_number_of_times.and_return(nil)
- -> { (a >= b) }.should raise_error(ArgumentError)
+ lambda { (a >= b) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/comparable/lt_spec.rb b/spec/ruby/core/comparable/lt_spec.rb
index 4db92719e2..e9e76360b9 100644
--- a/spec/ruby/core/comparable/lt_spec.rb
+++ b/spec/ruby/core/comparable/lt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Comparable#<" do
it "calls #<=> on self with other and returns true if #<=> returns any Integer less than 0" do
@@ -38,6 +38,6 @@ describe "Comparable#<" do
b = ComparableSpecs::Weird.new(20)
a.should_receive(:<=>).any_number_of_times.and_return(nil)
- -> { (a < b) }.should raise_error(ArgumentError)
+ lambda { (a < b) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/comparable/lte_spec.rb b/spec/ruby/core/comparable/lte_spec.rb
index b5cb9cc4e7..96ed38ecd5 100644
--- a/spec/ruby/core/comparable/lte_spec.rb
+++ b/spec/ruby/core/comparable/lte_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Comparable#<=" do
it "calls #<=> on self with other and returns true if #<=> returns 0 or any Integer less than 0" do
@@ -41,6 +41,6 @@ describe "Comparable#<=" do
b = ComparableSpecs::Weird.new(20)
a.should_receive(:<=>).any_number_of_times.and_return(nil)
- -> { (a <= b) }.should raise_error(ArgumentError)
+ lambda { (a <= b) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/complex/abs2_spec.rb b/spec/ruby/core/complex/abs2_spec.rb
index 3e5c5fd225..debfade075 100644
--- a/spec/ruby/core/complex/abs2_spec.rb
+++ b/spec/ruby/core/complex/abs2_spec.rb
@@ -1,9 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/abs2', __FILE__)
describe "Complex#abs2" do
- it "returns the sum of the squares of the real and imaginary parts" do
- Complex(1, -2).abs2.should == 1 + 4
- Complex(-0.1, 0.2).abs2.should be_close(0.01 + 0.04, TOLERANCE)
- Complex(0).abs2.should == 0
- end
+ it_behaves_like(:complex_abs2, :abs2)
end
diff --git a/spec/ruby/core/complex/abs_spec.rb b/spec/ruby/core/complex/abs_spec.rb
index 43912c517f..a00d161ee9 100644
--- a/spec/ruby/core/complex/abs_spec.rb
+++ b/spec/ruby/core/complex/abs_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/abs'
+require File.expand_path('../../../shared/complex/abs', __FILE__)
describe "Complex#abs" do
- it_behaves_like :complex_abs, :abs
+ it_behaves_like(:complex_abs, :abs)
end
diff --git a/spec/ruby/core/complex/angle_spec.rb b/spec/ruby/core/complex/angle_spec.rb
index 4aa176956f..f0c46bfd03 100644
--- a/spec/ruby/core/complex/angle_spec.rb
+++ b/spec/ruby/core/complex/angle_spec.rb
@@ -1,6 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../spec_helper', __FILE__)
+
+require File.expand_path('../../../shared/complex/arg', __FILE__)
describe "Complex#angle" do
- it_behaves_like :complex_arg, :angle
+ it_behaves_like(:complex_arg, :angle)
end
diff --git a/spec/ruby/core/complex/arg_spec.rb b/spec/ruby/core/complex/arg_spec.rb
index 009f19429f..48f8a94cf5 100644
--- a/spec/ruby/core/complex/arg_spec.rb
+++ b/spec/ruby/core/complex/arg_spec.rb
@@ -1,6 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../spec_helper', __FILE__)
+
+require File.expand_path('../../../shared/complex/arg', __FILE__)
describe "Complex#arg" do
- it_behaves_like :complex_arg, :arg
+ it_behaves_like(:complex_arg, :arg)
end
diff --git a/spec/ruby/core/complex/coerce_spec.rb b/spec/ruby/core/complex/coerce_spec.rb
index a30a6c1d5f..7c01170fde 100644
--- a/spec/ruby/core/complex/coerce_spec.rb
+++ b/spec/ruby/core/complex/coerce_spec.rb
@@ -1,70 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/coerce', __FILE__)
describe "Complex#coerce" do
- before :each do
- @one = Complex(1)
- end
-
- it "returns an array containing other and self as Complex when other is an Integer" do
- result = @one.coerce(2)
- result.should == [2, 1]
- result.first.should be_kind_of(Complex)
- result.last.should be_kind_of(Complex)
- end
-
- it "returns an array containing other and self as Complex when other is a Float" do
- result = @one.coerce(20.5)
- result.should == [20.5, 1]
- result.first.should be_kind_of(Complex)
- result.last.should be_kind_of(Complex)
- end
-
- it "returns an array containing other and self as Complex when other is a Bignum" do
- result = @one.coerce(4294967296)
- result.should == [4294967296, 1]
- result.first.should be_kind_of(Complex)
- result.last.should be_kind_of(Complex)
- end
-
- it "returns an array containing other and self as Complex when other is a Rational" do
- result = @one.coerce(Rational(5,6))
- result.should == [Rational(5,6), 1]
- result.first.should be_kind_of(Complex)
- result.last.should be_kind_of(Complex)
- end
-
- it "returns an array containing other and self when other is a Complex" do
- other = Complex(2)
- result = @one.coerce(other)
- result.should == [other, @one]
- result.first.should equal(other)
- result.last.should equal(@one)
- end
-
- it "returns an array containing other as Complex and self when other is a Numeric which responds to #real? with true" do
- other = mock_numeric('other')
- other.should_receive(:real?).any_number_of_times.and_return(true)
- result = @one.coerce(other)
- result.should == [other, @one]
- result.first.should eql(Complex(other))
- result.last.should equal(@one)
- end
-
- it "raises TypeError when other is a Numeric which responds to #real? with false" do
- other = mock_numeric('other')
- other.should_receive(:real?).any_number_of_times.and_return(false)
- -> { @one.coerce(other) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when other is a String" do
- -> { @one.coerce("20") }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when other is nil" do
- -> { @one.coerce(nil) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when other is false" do
- -> { @one.coerce(false) }.should raise_error(TypeError)
- end
+ it_behaves_like(:complex_coerce, :coerce)
end
diff --git a/spec/ruby/core/complex/conj_spec.rb b/spec/ruby/core/complex/conj_spec.rb
index 5e3bc1acb8..ad2c885b3b 100644
--- a/spec/ruby/core/complex/conj_spec.rb
+++ b/spec/ruby/core/complex/conj_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/conjugate'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/conjugate', __FILE__)
describe "Complex#conj" do
- it_behaves_like :complex_conjugate, :conj
+ it_behaves_like(:complex_conjugate, :conj)
end
diff --git a/spec/ruby/core/complex/conjugate_spec.rb b/spec/ruby/core/complex/conjugate_spec.rb
index f658bab4da..7fc2ddb430 100644
--- a/spec/ruby/core/complex/conjugate_spec.rb
+++ b/spec/ruby/core/complex/conjugate_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/conjugate'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/conjugate', __FILE__)
describe "Complex#conjugate" do
- it_behaves_like :complex_conjugate, :conjugate
+ it_behaves_like(:complex_conjugate, :conjugate)
end
diff --git a/spec/ruby/core/complex/constants_spec.rb b/spec/ruby/core/complex/constants_spec.rb
index 50303de16c..a8fcebbd31 100644
--- a/spec/ruby/core/complex/constants_spec.rb
+++ b/spec/ruby/core/complex/constants_spec.rb
@@ -1,7 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/constants', __FILE__)
describe "Complex::I" do
- it "is Complex(0, 1)" do
- Complex::I.should eql(Complex(0, 1))
- end
+ it_behaves_like :complex_I, :I
end
diff --git a/spec/ruby/core/complex/denominator_spec.rb b/spec/ruby/core/complex/denominator_spec.rb
index c1a2003820..2568967968 100644
--- a/spec/ruby/core/complex/denominator_spec.rb
+++ b/spec/ruby/core/complex/denominator_spec.rb
@@ -1,13 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/denominator', __FILE__)
describe "Complex#denominator" do
- it "returns the least common multiple denominator of the real and imaginary parts" do
- Complex(3, 4).denominator.should == 1
- Complex(3, bignum_value).denominator.should == 1
-
- Complex(3, Rational(3,4)).denominator.should == 4
-
- Complex(Rational(4,8), Rational(3,4)).denominator.should == 4
- Complex(Rational(3,8), Rational(3,4)).denominator.should == 8
- end
+ it_behaves_like(:complex_denominator, :denominator)
end
diff --git a/spec/ruby/core/complex/divide_spec.rb b/spec/ruby/core/complex/divide_spec.rb
index bebf862312..71614c76e1 100644
--- a/spec/ruby/core/complex/divide_spec.rb
+++ b/spec/ruby/core/complex/divide_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'shared/divide'
+require File.expand_path('../../../shared/complex/divide', __FILE__)
describe "Complex#/" do
it_behaves_like :complex_divide, :/
diff --git a/spec/ruby/core/complex/eql_spec.rb b/spec/ruby/core/complex/eql_spec.rb
index 9194efc074..c8e432029f 100644
--- a/spec/ruby/core/complex/eql_spec.rb
+++ b/spec/ruby/core/complex/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Complex#eql?" do
it "returns false if other is not Complex" do
diff --git a/spec/ruby/core/complex/equal_value_spec.rb b/spec/ruby/core/complex/equal_value_spec.rb
index b1e4f9cfcd..b3d93911bd 100644
--- a/spec/ruby/core/complex/equal_value_spec.rb
+++ b/spec/ruby/core/complex/equal_value_spec.rb
@@ -1,93 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/equal_value', __FILE__)
describe "Complex#==" do
- describe "with Complex" do
- it "returns true when self and other have numerical equality" do
- Complex(1, 2).should == Complex(1, 2)
- Complex(3, 9).should == Complex(3, 9)
- Complex(-3, -9).should == Complex(-3, -9)
-
- Complex(1, 2).should_not == Complex(3, 4)
- Complex(3, 9).should_not == Complex(9, 3)
-
- Complex(1.0, 2.0).should == Complex(1, 2)
- Complex(3.0, 9.0).should_not == Complex(9.0, 3.0)
-
- Complex(1.5, 2.5).should == Complex(1.5, 2.5)
- Complex(1.5, 2.5).should == Complex(1.5, 2.5)
- Complex(-1.5, 2.5).should == Complex(-1.5, 2.5)
-
- Complex(1.5, 2.5).should_not == Complex(2.5, 1.5)
- Complex(3.75, 2.5).should_not == Complex(1.5, 2.5)
-
- Complex(bignum_value, 2.5).should == Complex(bignum_value, 2.5)
- Complex(3.75, bignum_value).should_not == Complex(1.5, bignum_value)
-
- Complex(nan_value).should_not == Complex(nan_value)
- end
- end
-
- describe "with Numeric" do
- it "returns true when self's imaginary part is 0 and the real part and other have numerical equality" do
- Complex(3, 0).should == 3
- Complex(-3, 0).should == -3
-
- Complex(3.5, 0).should == 3.5
- Complex(-3.5, 0).should == -3.5
-
- Complex(bignum_value, 0).should == bignum_value
- Complex(-bignum_value, 0).should == -bignum_value
-
- Complex(3.0, 0).should == 3
- Complex(-3.0, 0).should == -3
-
- Complex(3, 0).should_not == 4
- Complex(-3, 0).should_not == -4
-
- Complex(3.5, 0).should_not == -4.5
- Complex(-3.5, 0).should_not == 2.5
-
- Complex(bignum_value, 0).should_not == bignum_value(10)
- Complex(-bignum_value, 0).should_not == -bignum_value(20)
- end
- end
-
- describe "with Object" do
- # Fixnum#==, Float#== and Bignum#== only return booleans - Bug?
- it "calls other#== with self" do
- value = Complex(3, 0)
-
- obj = mock("Object")
- obj.should_receive(:==).with(value).and_return(:expected)
-
- (value == obj).should_not be_false
- end
- end
-
- describe "with a Numeric which responds to #real? with true" do
- before do
- @other = mock_numeric('other')
- @other.should_receive(:real?).any_number_of_times.and_return(true)
- end
-
- it "returns real == other when the imaginary part is zero" do
- real = mock_numeric('real')
- real.should_receive(:==).with(@other).and_return(true)
- (Complex(real, 0) == @other).should be_true
- end
-
- it "returns false when when the imaginary part is not zero" do
- (Complex(3, 1) == @other).should be_false
- end
- end
-
- describe "with a Numeric which responds to #real? with false" do
- it "returns other == self" do
- complex = Complex(3, 0)
- other = mock_numeric('other')
- other.should_receive(:real?).any_number_of_times.and_return(false)
- other.should_receive(:==).with(complex).and_return(true)
- (complex == other).should be_true
- end
- end
+ it_behaves_like :complex_equal_value, :==
end
diff --git a/spec/ruby/core/complex/exponent_spec.rb b/spec/ruby/core/complex/exponent_spec.rb
index bf07c90038..62f61a2bf3 100644
--- a/spec/ruby/core/complex/exponent_spec.rb
+++ b/spec/ruby/core/complex/exponent_spec.rb
@@ -1,61 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/exponent', __FILE__)
describe "Complex#**" do
- describe "with Fixnum 0" do
- it "returns Complex(1)" do
- (Complex(3, 4) ** 0).should eql(Complex(1))
- end
- end
-
- describe "with Float 0.0" do
- it "returns Complex(1.0, 0.0)" do
- (Complex(3, 4) ** 0.0).should eql(Complex(1.0, 0.0))
- end
- end
-
- describe "with Complex" do
- it "returns self raised to the given power" do
- (Complex(2, 1) ** Complex(2, 1)).should be_close(Complex(-0.504824688978319, 3.10414407699553), TOLERANCE)
- (Complex(2, 1) ** Complex(3, 4)).should be_close(Complex(-0.179174656916581, -1.74071656397662), TOLERANCE)
-
- (Complex(2, 1) ** Complex(-2, -1)).should be_close(Complex(-0.051041070450869, -0.313849223270419), TOLERANCE)
- (Complex(-2, -1) ** Complex(2, 1)).should be_close(Complex(-11.6819929610857, 71.8320439736158), TOLERANCE)
- end
- end
-
- describe "with Integer" do
- it "returns self raised to the given power" do
- (Complex(2, 1) ** 2).should == Complex(3, 4)
- (Complex(3, 4) ** 2).should == Complex(-7, 24)
- (Complex(3, 4) ** -2).should be_close(Complex(-0.0112, -0.0384), TOLERANCE)
-
-
- (Complex(2, 1) ** 2.5).should be_close(Complex(2.99179707178602, 6.85206901006896), TOLERANCE)
- (Complex(3, 4) ** 2.5).should be_close(Complex(-38.0, 41.0), TOLERANCE)
- (Complex(3, 4) ** -2.5).should be_close(Complex(-0.01216, -0.01312), TOLERANCE)
-
- (Complex(1) ** 1).should == Complex(1)
-
- # NOTE: Takes way too long...
- #(Complex(2, 1) ** bignum_value)
- end
- end
-
- describe "with Rational" do
- it "returns self raised to the given power" do
- (Complex(2, 1) ** Rational(3, 4)).should be_close(Complex(1.71913265276568, 0.623124744394697), TOLERANCE)
- (Complex(2, 1) ** Rational(4, 3)).should be_close(Complex(2.3828547125173, 1.69466313833091), TOLERANCE)
- (Complex(2, 1) ** Rational(-4, 3)).should be_close(Complex(0.278700377879388, -0.198209003071003), TOLERANCE)
- end
- end
-
- describe "with Object" do
- it "tries to coerce self into other" do
- value = Complex(3, 9)
-
- obj = mock("Object")
- obj.should_receive(:coerce).with(value).and_return([2, 5])
- (value ** obj).should == 2 ** 5
- end
- end
+ it_behaves_like :complex_exponent, :**
end
diff --git a/spec/ruby/core/complex/fdiv_spec.rb b/spec/ruby/core/complex/fdiv_spec.rb
index 68f7d1b309..8211dfc9de 100644
--- a/spec/ruby/core/complex/fdiv_spec.rb
+++ b/spec/ruby/core/complex/fdiv_spec.rb
@@ -1,22 +1,22 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Complex#fdiv" do
it "accepts a numeric argument" do
- -> { Complex(20).fdiv(2) }.should_not raise_error(TypeError)
- -> { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError)
- -> { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError)
+ lambda { Complex(20).fdiv(2) }.should_not raise_error(TypeError)
+ lambda { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError)
+ lambda { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError)
end
it "accepts a negative numeric argument" do
- -> { Complex(20).fdiv(-2) }.should_not raise_error(TypeError)
- -> { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError)
- -> { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError)
+ lambda { Complex(20).fdiv(-2) }.should_not raise_error(TypeError)
+ lambda { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError)
+ lambda { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError)
end
it "raises a TypeError if passed a non-numeric argument" do
- -> { Complex(20).fdiv([]) }.should raise_error(TypeError)
- -> { Complex(20).fdiv(:sym) }.should raise_error(TypeError)
- -> { Complex(20).fdiv('s') }.should raise_error(TypeError)
+ lambda { Complex(20).fdiv([]) }.should raise_error(TypeError)
+ lambda { Complex(20).fdiv(:sym) }.should raise_error(TypeError)
+ lambda { Complex(20).fdiv('s') }.should raise_error(TypeError)
end
it "sets the real part to NaN if self's real part is NaN" do
diff --git a/spec/ruby/core/complex/finite_spec.rb b/spec/ruby/core/complex/finite_spec.rb
index 718848390c..e9ee19bef3 100644
--- a/spec/ruby/core/complex/finite_spec.rb
+++ b/spec/ruby/core/complex/finite_spec.rb
@@ -1,32 +1,36 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Complex#finite?" do
- it "returns true if magnitude is finite" do
- (1+1i).finite?.should == true
- end
+ruby_version_is "2.4" do
+ describe "Complex#finite?" do
+ it "returns true if magnitude is finite" do
+ (1+1i).finite?.should == true
+ end
- it "returns false for positive infinity" do
- value = Complex(Float::INFINITY, 42)
- value.finite?.should == false
- end
+ it "returns false for positive infinity" do
+ value = Complex(Float::INFINITY, 42)
+ value.finite?.should == false
+ end
- it "returns false for positive complex with infinite imaginary" do
- value = Complex(1, Float::INFINITY)
- value.finite?.should == false
- end
+ it "returns false for positive complex with infinite imaginary" do
+ value = Complex(1, Float::INFINITY)
+ value.finite?.should == false
+ end
- it "returns false for negative infinity" do
- value = -Complex(Float::INFINITY, 42)
- value.finite?.should == false
- end
+ it "returns false for negative infinity" do
+ value = -Complex(Float::INFINITY, 42)
+ value.finite?.should == false
+ end
- it "returns false for negative complex with infinite imaginary" do
- value = -Complex(1, Float::INFINITY)
- value.finite?.should == false
- end
+ it "returns false for negative complex with infinite imaginary" do
+ value = -Complex(1, Float::INFINITY)
+ value.finite?.should == false
+ end
- it "returns false for NaN" do
- value = Complex(Float::NAN, Float::NAN)
- value.finite?.should == false
+ ruby_bug "#14014", "2.4"..."2.5" do
+ it "returns false for NaN" do
+ value = Complex(Float::NAN, Float::NAN)
+ value.finite?.should == false
+ end
+ end
end
end
diff --git a/spec/ruby/core/complex/hash_spec.rb b/spec/ruby/core/complex/hash_spec.rb
index cad283309d..db4b3590df 100644
--- a/spec/ruby/core/complex/hash_spec.rb
+++ b/spec/ruby/core/complex/hash_spec.rb
@@ -1,16 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/hash', __FILE__)
describe "Complex#hash" do
- it "is static" do
- Complex(1).hash.should == Complex(1).hash
- Complex(1, 0).hash.should == Complex(1).hash
- Complex(1, 1).hash.should == Complex(1, 1).hash
- end
-
- it "is different for different instances" do
- Complex(1, 2).hash.should_not == Complex(1, 1).hash
- Complex(2, 1).hash.should_not == Complex(1, 1).hash
-
- Complex(1, 2).hash.should_not == Complex(2, 1).hash
- end
+ it_behaves_like(:complex_hash, :hash)
end
diff --git a/spec/ruby/core/complex/imag_spec.rb b/spec/ruby/core/complex/imag_spec.rb
index 2bafd1ab54..6aa8803f5d 100644
--- a/spec/ruby/core/complex/imag_spec.rb
+++ b/spec/ruby/core/complex/imag_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/image'
+require File.expand_path('../../../shared/complex/image', __FILE__)
describe "Complex#imag" do
- it_behaves_like :complex_image, :imag
+ it_behaves_like(:complex_image, :imag)
end
diff --git a/spec/ruby/core/complex/imaginary_spec.rb b/spec/ruby/core/complex/imaginary_spec.rb
index a8a1bfea90..ecae19283b 100644
--- a/spec/ruby/core/complex/imaginary_spec.rb
+++ b/spec/ruby/core/complex/imaginary_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'shared/image'
+require File.expand_path('../../../shared/complex/image', __FILE__)
describe "Complex#imaginary" do
it_behaves_like :complex_image, :imaginary
diff --git a/spec/ruby/core/complex/infinite_spec.rb b/spec/ruby/core/complex/infinite_spec.rb
index 9e48860dee..79792c3169 100644
--- a/spec/ruby/core/complex/infinite_spec.rb
+++ b/spec/ruby/core/complex/infinite_spec.rb
@@ -1,32 +1,34 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Complex#infinite?" do
- it "returns nil if magnitude is finite" do
- (1+1i).infinite?.should == nil
- end
+ruby_version_is "2.4" do
+ describe "Complex#infinite?" do
+ it "returns nil if magnitude is finite" do
+ (1+1i).infinite?.should == nil
+ end
- it "returns 1 for positive infinity" do
- value = Complex(Float::INFINITY, 42).infinite?
- value.should == 1
- end
+ it "returns 1 for positive infinity" do
+ value = Complex(Float::INFINITY, 42).infinite?
+ value.should == 1
+ end
- it "returns 1 for positive complex with infinite imaginary" do
- value = Complex(1, Float::INFINITY).infinite?
- value.should == 1
- end
+ it "returns 1 for positive complex with infinite imaginary" do
+ value = Complex(1, Float::INFINITY).infinite?
+ value.should == 1
+ end
- it "returns -1 for negative infinity" do
- value = -Complex(Float::INFINITY, 42).infinite?
- value.should == -1
- end
+ it "returns -1 for negative infinity" do
+ value = -Complex(Float::INFINITY, 42).infinite?
+ value.should == -1
+ end
- it "returns -1 for negative complex with infinite imaginary" do
- value = -Complex(1, Float::INFINITY).infinite?
- value.should == -1
- end
+ it "returns -1 for negative complex with infinite imaginary" do
+ value = -Complex(1, Float::INFINITY).infinite?
+ value.should == -1
+ end
- it "returns nil for NaN" do
- value = Complex(0, Float::NAN).infinite?
- value.should == nil
+ it "returns nil for NaN" do
+ value = Complex(0, Float::NAN).infinite?
+ value.should == nil
+ end
end
end
diff --git a/spec/ruby/core/complex/inspect_spec.rb b/spec/ruby/core/complex/inspect_spec.rb
index 71aabde5be..b766e7f730 100644
--- a/spec/ruby/core/complex/inspect_spec.rb
+++ b/spec/ruby/core/complex/inspect_spec.rb
@@ -1,16 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/inspect', __FILE__)
describe "Complex#inspect" do
- it "returns (${real}+${image}i) for positive imaginary parts" do
- Complex(1).inspect.should == "(1+0i)"
- Complex(7).inspect.should == "(7+0i)"
- Complex(-1, 4).inspect.should == "(-1+4i)"
- Complex(-7, 6.7).inspect.should == "(-7+6.7i)"
- end
-
- it "returns (${real}-${image}i) for negative imaginary parts" do
- Complex(0, -1).inspect.should == "(0-1i)"
- Complex(-1, -4).inspect.should == "(-1-4i)"
- Complex(-7, -6.7).inspect.should == "(-7-6.7i)"
- end
+ it_behaves_like(:complex_inspect, :inspect)
end
diff --git a/spec/ruby/core/complex/integer_spec.rb b/spec/ruby/core/complex/integer_spec.rb
index 0957accb70..54b420e62c 100644
--- a/spec/ruby/core/complex/integer_spec.rb
+++ b/spec/ruby/core/complex/integer_spec.rb
@@ -1,5 +1,3 @@
-require_relative '../../spec_helper'
-
describe "Complex#integer?" do
it "returns false for a Complex with no imaginary part" do
Complex(20).integer?.should be_false
diff --git a/spec/ruby/core/complex/magnitude_spec.rb b/spec/ruby/core/complex/magnitude_spec.rb
index 86f3b29868..e9175d763e 100644
--- a/spec/ruby/core/complex/magnitude_spec.rb
+++ b/spec/ruby/core/complex/magnitude_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/abs'
+require File.expand_path('../../../shared/complex/abs', __FILE__)
describe "Complex#magnitude" do
- it_behaves_like :complex_abs, :magnitude
+ it_behaves_like(:complex_abs, :magnitude)
end
diff --git a/spec/ruby/core/complex/marshal_dump_spec.rb b/spec/ruby/core/complex/marshal_dump_spec.rb
index 116899b0ad..8d37929f54 100644
--- a/spec/ruby/core/complex/marshal_dump_spec.rb
+++ b/spec/ruby/core/complex/marshal_dump_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Complex#marshal_dump" do
it "is a private method" do
diff --git a/spec/ruby/core/complex/minus_spec.rb b/spec/ruby/core/complex/minus_spec.rb
index 7c104ce784..2b7b8bb270 100644
--- a/spec/ruby/core/complex/minus_spec.rb
+++ b/spec/ruby/core/complex/minus_spec.rb
@@ -1,45 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/minus', __FILE__)
describe "Complex#-" do
- describe "with Complex" do
- it "subtracts both the real and imaginary components" do
- (Complex(1, 2) - Complex(10, 20)).should == Complex(1 - 10, 2 - 20)
- (Complex(1.5, 2.1) - Complex(100.2, -30.3)).should == Complex(1.5 - 100.2, 2.1 - (-30.3))
- end
- end
-
- describe "with Integer" do
- it "subtracts the real number from the real component of self" do
- (Complex(1, 2) - 50).should == Complex(-49, 2)
- (Complex(1, 2) - 50.5).should == Complex(-49.5, 2)
- end
- end
-
- describe "with Object" do
- it "tries to coerce self into other" do
- value = Complex(3, 9)
-
- obj = mock("Object")
- obj.should_receive(:coerce).with(value).and_return([2, 5])
- (value - obj).should == 2 - 5
- end
- end
-
- describe "passed Numeric which responds to #real? with true" do
- it "coerces the passed argument to the type of the real part and subtracts the resulting elements" do
- n = mock_numeric('n')
- n.should_receive(:real?).and_return(true)
- n.should_receive(:coerce).with(1).and_return([1, 4])
- (Complex(1, 2) - n).should == Complex(-3, 2)
- end
- end
-
- describe "passed Numeric which responds to #real? with false" do
- it "coerces the passed argument to Complex and subtracts the resulting elements" do
- n = mock_numeric('n')
- n.should_receive(:real?).and_return(false)
- n.should_receive(:coerce).with(Complex(1, 2)).and_return([Complex(1, 2), Complex(3, 4)])
- (Complex(1, 2) - n).should == Complex(-2, -2)
- end
- end
+ it_behaves_like :complex_minus, :-
end
diff --git a/spec/ruby/core/complex/multiply_spec.rb b/spec/ruby/core/complex/multiply_spec.rb
index 35bf7c8455..7f600fc1ab 100644
--- a/spec/ruby/core/complex/multiply_spec.rb
+++ b/spec/ruby/core/complex/multiply_spec.rb
@@ -1,49 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/multiply', __FILE__)
describe "Complex#*" do
- describe "with Complex" do
- it "multiplies according to the usual rule for complex numbers: (a + bi) * (c + di) = ac - bd + (ad + bc)i" do
- (Complex(1, 2) * Complex(10, 20)).should == Complex((1 * 10) - (2 * 20), (1 * 20) + (2 * 10))
- (Complex(1.5, 2.1) * Complex(100.2, -30.3)).should == Complex((1.5 * 100.2) - (2.1 * -30.3), (1.5 * -30.3) + (2.1 * 100.2))
- end
- end
-
- describe "with Integer" do
- it "multiplies both parts of self by the given Integer" do
- (Complex(3, 2) * 50).should == Complex(150, 100)
- (Complex(-3, 2) * 50.5).should == Complex(-151.5, 101)
- end
- end
-
- describe "with Object" do
- it "tries to coerce self into other" do
- value = Complex(3, 9)
-
- obj = mock("Object")
- obj.should_receive(:coerce).with(value).and_return([2, 5])
- (value * obj).should == 2 * 5
- end
- end
-
- describe "with a Numeric which responds to #real? with true" do
- it "multiples both parts of self by other" do
- other = mock_numeric('other')
- real = mock_numeric('real')
- imag = mock_numeric('imag')
- other.should_receive(:real?).and_return(true)
- real.should_receive(:*).with(other).and_return(1)
- imag.should_receive(:*).with(other).and_return(2)
- (Complex(real, imag) * other).should == Complex(1, 2)
- end
-
- describe "with a Numeric which responds to #real? with false" do
- it "coerces the passed argument to Complex and multiplies the resulting elements" do
- complex = Complex(3, 0)
- other = mock_numeric('other')
- other.should_receive(:real?).any_number_of_times.and_return(false)
- other.should_receive(:coerce).with(complex).and_return([5, 2])
- (complex * other).should == 10
- end
- end
- end
+ it_behaves_like :complex_multiply, :*
end
diff --git a/spec/ruby/core/complex/negative_spec.rb b/spec/ruby/core/complex/negative_spec.rb
index 62ab89c04a..5b51933106 100644
--- a/spec/ruby/core/complex/negative_spec.rb
+++ b/spec/ruby/core/complex/negative_spec.rb
@@ -1,12 +1,10 @@
-require_relative '../../spec_helper'
-
describe "Complex#negative?" do
it "is undefined" do
c = Complex(1)
c.methods.should_not include(:negative?)
- -> {
+ lambda {
c.negative?
}.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/complex/numerator_spec.rb b/spec/ruby/core/complex/numerator_spec.rb
index 7ab66e6a61..8c0e8761bd 100644
--- a/spec/ruby/core/complex/numerator_spec.rb
+++ b/spec/ruby/core/complex/numerator_spec.rb
@@ -1,19 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/numerator', __FILE__)
describe "Complex#numerator" do
- it "returns self's numerator" do
- Complex(2).numerator.should == Complex(2)
- Complex(3, 4).numerator.should == Complex(3, 4)
-
- Complex(Rational(3, 4), Rational(3, 4)).numerator.should == Complex(3, 3)
- Complex(Rational(7, 4), Rational(8, 4)).numerator.should == Complex(7, 8)
-
- Complex(Rational(7, 8), Rational(8, 4)).numerator.should == Complex(7, 16)
- Complex(Rational(7, 4), Rational(8, 8)).numerator.should == Complex(7, 4)
-
- # NOTE:
- # Bug? - Fails with a MethodMissingError
- # (undefined method `denominator' for 3.5:Float)
- # Complex(3.5, 3.7).numerator
- end
+ it_behaves_like(:complex_numerator, :numerator)
end
diff --git a/spec/ruby/core/complex/phase_spec.rb b/spec/ruby/core/complex/phase_spec.rb
index 89574bf533..c17f922c7f 100644
--- a/spec/ruby/core/complex/phase_spec.rb
+++ b/spec/ruby/core/complex/phase_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/arg', __FILE__)
describe "Complex#phase" do
it_behaves_like :complex_arg, :phase
diff --git a/spec/ruby/core/complex/plus_spec.rb b/spec/ruby/core/complex/plus_spec.rb
index 2056ca786c..076582681f 100644
--- a/spec/ruby/core/complex/plus_spec.rb
+++ b/spec/ruby/core/complex/plus_spec.rb
@@ -1,45 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/plus', __FILE__)
describe "Complex#+" do
- describe "with Complex" do
- it "adds both the real and imaginary components" do
- (Complex(1, 2) + Complex(10, 20)).should == Complex(1 + 10, 2 + 20)
- (Complex(1.5, 2.1) + Complex(100.2, -30.3)).should == Complex(1.5 + 100.2, 2.1 + (-30.3))
- end
- end
-
- describe "with Integer" do
- it "adds the real number to the real component of self" do
- (Complex(1, 2) + 50).should == Complex(51, 2)
- (Complex(1, 2) + 50.5).should == Complex(51.5, 2)
- end
- end
-
- describe "with Object" do
- it "tries to coerce self into other" do
- value = Complex(3, 9)
-
- obj = mock("Object")
- obj.should_receive(:coerce).with(value).and_return([2, 5])
- (value + obj).should == 2 + 5
- end
- end
-
- describe "passed Numeric which responds to #real? with true" do
- it "coerces the passed argument to the type of the real part and adds the resulting elements" do
- n = mock_numeric('n')
- n.should_receive(:real?).and_return(true)
- n.should_receive(:coerce).with(1).and_return([1, 4])
- (Complex(1, 2) + n).should == Complex(5, 2)
- end
- end
-
- describe "passed Numeric which responds to #real? with false" do
- it "coerces the passed argument to Complex and adds the resulting elements" do
- n = mock_numeric('n')
- n.should_receive(:real?).and_return(false)
- n.should_receive(:coerce).with(Complex(1, 2)).and_return([Complex(1, 2), Complex(3, 4)])
- (Complex(1, 2) + n).should == Complex(4, 6)
- end
- end
+ it_behaves_like :complex_plus, :+
end
diff --git a/spec/ruby/core/complex/polar_spec.rb b/spec/ruby/core/complex/polar_spec.rb
index 2a5d8ebd69..d847e916ff 100644
--- a/spec/ruby/core/complex/polar_spec.rb
+++ b/spec/ruby/core/complex/polar_spec.rb
@@ -1,27 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/polar', __FILE__)
describe "Complex.polar" do
- it "returns a complex number in terms of radius and angle" do
- Complex.polar(50, 60).should be_close(Complex(-47.6206490207578, -15.2405310551108), TOLERANCE)
- Complex.polar(-10, -20).should be_close(Complex(-4.08082061813392, 9.12945250727628), TOLERANCE)
- end
+ it_behaves_like(:complex_polar_class, :polar)
it "raises a TypeError when given non real arguments" do
- ->{ Complex.polar(nil) }.should raise_error(TypeError)
- ->{ Complex.polar(nil, nil) }.should raise_error(TypeError)
+ lambda{ Complex.polar(nil) }.should raise_error(TypeError)
+ lambda{ Complex.polar(nil, nil) }.should raise_error(TypeError)
end
end
describe "Complex#polar" do
- it "returns the absolute value and the argument" do
- a = Complex(3, 4)
- a.polar.size.should == 2
- a.polar.first.should == 5.0
- a.polar.last.should be_close(0.927295218001612, TOLERANCE)
-
- b = Complex(-3.5, 4.7)
- b.polar.size.should == 2
- b.polar.first.should be_close(5.86003412959345, TOLERANCE)
- b.polar.last.should be_close(2.21088447955664, TOLERANCE)
- end
+ it_behaves_like(:complex_polar, :polar)
end
diff --git a/spec/ruby/core/complex/positive_spec.rb b/spec/ruby/core/complex/positive_spec.rb
index f1bad8608c..88898d31cf 100644
--- a/spec/ruby/core/complex/positive_spec.rb
+++ b/spec/ruby/core/complex/positive_spec.rb
@@ -1,12 +1,10 @@
-require_relative '../../spec_helper'
-
describe "Complex#positive?" do
it "is undefined" do
c = Complex(1)
c.methods.should_not include(:positive?)
- -> {
+ lambda {
c.positive?
}.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/complex/quo_spec.rb b/spec/ruby/core/complex/quo_spec.rb
index ee6fd65c79..cb3f1203b4 100644
--- a/spec/ruby/core/complex/quo_spec.rb
+++ b/spec/ruby/core/complex/quo_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'shared/divide'
+require File.expand_path('../../../shared/complex/divide', __FILE__)
describe "Complex#quo" do
it_behaves_like :complex_divide, :quo
diff --git a/spec/ruby/core/complex/rationalize_spec.rb b/spec/ruby/core/complex/rationalize_spec.rb
index 043b8ddf2a..2dd1e9b122 100644
--- a/spec/ruby/core/complex/rationalize_spec.rb
+++ b/spec/ruby/core/complex/rationalize_spec.rb
@@ -1,12 +1,10 @@
-require_relative '../../spec_helper'
-
describe "Complex#rationalize" do
it "raises RangeError if self has non-zero imaginary part" do
- -> { Complex(1,5).rationalize }.should raise_error(RangeError)
+ lambda { Complex(1,5).rationalize }.should raise_error(RangeError)
end
it "raises RangeError if self has 0.0 imaginary part" do
- -> { Complex(1,0.0).rationalize }.should raise_error(RangeError)
+ lambda { Complex(1,0.0).rationalize }.should raise_error(RangeError)
end
it "returns a Rational if self has zero imaginary part" do
@@ -25,7 +23,7 @@ describe "Complex#rationalize" do
end
it "raises ArgumentError when passed more than one argument" do
- -> { Complex(1,0).rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
- -> { Complex(1,0).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
+ lambda { Complex(1,0).rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
+ lambda { Complex(1,0).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/complex/real_spec.rb b/spec/ruby/core/complex/real_spec.rb
index 2ea791c005..1293e02d3c 100644
--- a/spec/ruby/core/complex/real_spec.rb
+++ b/spec/ruby/core/complex/real_spec.rb
@@ -1,12 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/real', __FILE__)
describe "Complex#real" do
- it "returns the real part of self" do
- Complex(1, 0).real.should == 1
- Complex(2, 1).real.should == 2
- Complex(6.7, 8.9).real.should == 6.7
- Complex(bignum_value, 3).real.should == bignum_value
- end
+ it_behaves_like(:complex_real, :real)
end
describe "Complex#real?" do
diff --git a/spec/ruby/core/complex/rect_spec.rb b/spec/ruby/core/complex/rect_spec.rb
index 9e95f3efc2..cf2ff9e83b 100644
--- a/spec/ruby/core/complex/rect_spec.rb
+++ b/spec/ruby/core/complex/rect_spec.rb
@@ -1,10 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rect'
+require File.expand_path('../../../shared/complex/rect', __FILE__)
describe "Complex#rect" do
- it_behaves_like :complex_rect, :rect
+ it_behaves_like(:complex_rect, :rect)
end
describe "Complex.rect" do
- it_behaves_like :complex_rect_class, :rect
+ it_behaves_like(:complex_rect_class, :rect)
end
diff --git a/spec/ruby/core/complex/rectangular_spec.rb b/spec/ruby/core/complex/rectangular_spec.rb
index d4b8ad9782..0eb29c3500 100644
--- a/spec/ruby/core/complex/rectangular_spec.rb
+++ b/spec/ruby/core/complex/rectangular_spec.rb
@@ -1,10 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rect'
+require File.expand_path('../../../shared/complex/rect', __FILE__)
describe "Complex#rectangular" do
- it_behaves_like :complex_rect, :rectangular
+ it_behaves_like(:complex_rect, :rectangular)
end
describe "Complex.rectangular" do
- it_behaves_like :complex_rect_class, :rectangular
+ it_behaves_like(:complex_rect_class, :rectangular)
end
diff --git a/spec/ruby/core/complex/shared/abs.rb b/spec/ruby/core/complex/shared/abs.rb
deleted file mode 100644
index 2299479341..0000000000
--- a/spec/ruby/core/complex/shared/abs.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-describe :complex_abs, shared: true do
- it "returns the modulus: |a + bi| = sqrt((a ^ 2) + (b ^ 2))" do
- Complex(0, 0).send(@method).should == 0
- Complex(3, 4).send(@method).should == 5 # well-known integer case
- Complex(-3, 4).send(@method).should == 5
- Complex(1, -1).send(@method).should be_close(Math.sqrt(2), TOLERANCE)
- Complex(6.5, 0).send(@method).should be_close(6.5, TOLERANCE)
- Complex(0, -7.2).send(@method).should be_close(7.2, TOLERANCE)
- end
-end
diff --git a/spec/ruby/core/complex/shared/divide.rb b/spec/ruby/core/complex/shared/divide.rb
deleted file mode 100644
index a60802c74c..0000000000
--- a/spec/ruby/core/complex/shared/divide.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-describe :complex_divide, shared: true do
- describe "with Complex" do
- it "divides according to the usual rule for complex numbers" do
- a = Complex((1 * 10) - (2 * 20), (1 * 20) + (2 * 10))
- b = Complex(1, 2)
- a.send(@method, b).should == Complex(10, 20)
-
- c = Complex((1.5 * 100.2) - (2.1 * -30.3), (1.5 * -30.3) + (2.1 * 100.2))
- d = Complex(1.5, 2.1)
- # remember the floating-point arithmetic
- c.send(@method, d).should be_close(Complex(100.2, -30.3), TOLERANCE)
- end
- end
-
- describe "with Fixnum" do
- it "divides both parts of the Complex number" do
- Complex(20, 40).send(@method, 2).should == Complex(10, 20)
- Complex(30, 30).send(@method, 10).should == Complex(3, 3)
- end
-
- it "raises a ZeroDivisionError when given zero" do
- -> { Complex(20, 40).send(@method, 0) }.should raise_error(ZeroDivisionError)
- end
-
- it "produces Rational parts" do
- Complex(5, 9).send(@method, 2).should eql(Complex(Rational(5,2), Rational(9,2)))
- end
- end
-
- describe "with Bignum" do
- it "divides both parts of the Complex number" do
- Complex(20, 40).send(@method, 2).should == Complex(10, 20)
- Complex(15, 16).send(@method, 2.0).should be_close(Complex(7.5, 8), TOLERANCE)
- end
- end
-
- describe "with Float" do
- it "divides both parts of the Complex number" do
- Complex(3, 9).send(@method, 1.5).should == Complex(2, 6)
- Complex(15, 16).send(@method, 2.0).should be_close(Complex(7.5, 8), TOLERANCE)
- end
-
- it "returns Complex(Infinity, Infinity) when given zero" do
- Complex(20, 40).send(@method, 0.0).real.infinite?.should == 1
- Complex(20, 40).send(@method, 0.0).imag.infinite?.should == 1
- Complex(-20, 40).send(@method, 0.0).real.infinite?.should == -1
- Complex(-20, 40).send(@method, 0.0).imag.infinite?.should == 1
- end
- end
-
- describe "with Object" do
- it "tries to coerce self into other" do
- value = Complex(3, 9)
-
- obj = mock("Object")
- obj.should_receive(:coerce).with(value).and_return([4, 2])
- value.send(@method, obj).should == 2
- end
- end
-
- describe "with a Numeric which responds to #real? with true" do
- it "returns Complex(real.quo(other), imag.quo(other))" do
- other = mock_numeric('other')
- real = mock_numeric('real')
- imag = mock_numeric('imag')
- other.should_receive(:real?).and_return(true)
- real.should_receive(:quo).with(other).and_return(1)
- imag.should_receive(:quo).with(other).and_return(2)
- Complex(real, imag).send(@method, other).should == Complex(1, 2)
- end
- end
-
- describe "with a Numeric which responds to #real? with false" do
- it "coerces the passed argument to Complex and divides the resulting elements" do
- complex = Complex(3, 0)
- other = mock_numeric('other')
- other.should_receive(:real?).any_number_of_times.and_return(false)
- other.should_receive(:coerce).with(complex).and_return([5, 2])
- complex.send(@method, other).should eql(Rational(5, 2))
- end
- end
-end
diff --git a/spec/ruby/core/complex/shared/image.rb b/spec/ruby/core/complex/shared/image.rb
deleted file mode 100644
index f839dbcaf9..0000000000
--- a/spec/ruby/core/complex/shared/image.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-describe :complex_image, shared: true do
- it "returns the imaginary part of self" do
- Complex(1, 0).send(@method).should == 0
- Complex(2, 1).send(@method).should == 1
- Complex(6.7, 8.9).send(@method).should == 8.9
- Complex(1, bignum_value).send(@method).should == bignum_value
- end
-end
diff --git a/spec/ruby/core/complex/shared/rect.rb b/spec/ruby/core/complex/shared/rect.rb
deleted file mode 100644
index 9f5de1ffeb..0000000000
--- a/spec/ruby/core/complex/shared/rect.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-describe :complex_rect, shared: true do
- before :each do
- @numbers = [
- Complex(1),
- Complex(0, 20),
- Complex(0, 0),
- Complex(0.0),
- Complex(9999999**99),
- Complex(-20),
- Complex.polar(76, 10)
- ]
- end
-
- it "returns an Array" do
- @numbers.each do |number|
- number.send(@method).should be_an_instance_of(Array)
- end
- end
-
- it "returns a two-element Array" do
- @numbers.each do |number|
- number.send(@method).size.should == 2
- end
- end
-
- it "returns the real part of self as the first element" do
- @numbers.each do |number|
- number.send(@method).first.should == number.real
- end
- end
-
- it "returns the imaginary part of self as the last element" do
- @numbers.each do |number|
- number.send(@method).last.should == number.imaginary
- end
- end
-
- it "raises an ArgumentError if given any arguments" do
- @numbers.each do |number|
- -> { number.send(@method, number) }.should raise_error(ArgumentError)
- end
- end
-end
-
-describe :complex_rect_class, shared: true do
- describe "passed a Numeric n which responds to #real? with true" do
- it "returns a Complex with real part n and imaginary part 0" do
- n = mock_numeric('n')
- n.should_receive(:real?).any_number_of_times.and_return(true)
- result = Complex.send(@method, n)
- result.real.should == n
- result.imag.should == 0
- end
- end
-
- describe "passed a Numeric which responds to #real? with false" do
- it "raises TypeError" do
- n = mock_numeric('n')
- n.should_receive(:real?).any_number_of_times.and_return(false)
- -> { Complex.send(@method, n) }.should raise_error(TypeError)
- end
- end
-
- describe "passed Numerics n1 and n2 and at least one responds to #real? with false" do
- [[false, false], [false, true], [true, false]].each do |r1, r2|
- it "raises TypeError" do
- n1 = mock_numeric('n1')
- n2 = mock_numeric('n2')
- n1.should_receive(:real?).any_number_of_times.and_return(r1)
- n2.should_receive(:real?).any_number_of_times.and_return(r2)
- -> { Complex.send(@method, n1, n2) }.should raise_error(TypeError)
- end
- end
- end
-
- describe "passed Numerics n1 and n2 and both respond to #real? with true" do
- it "returns a Complex with real part n1 and imaginary part n2" do
- n1 = mock_numeric('n1')
- n2 = mock_numeric('n2')
- n1.should_receive(:real?).any_number_of_times.and_return(true)
- n2.should_receive(:real?).any_number_of_times.and_return(true)
- result = Complex.send(@method, n1, n2)
- result.real.should == n1
- result.imag.should == n2
- end
- end
-
- describe "passed a non-Numeric" do
- it "raises TypeError" do
- -> { Complex.send(@method, :sym) }.should raise_error(TypeError)
- -> { Complex.send(@method, 0, :sym) }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/complex/spaceship_spec.rb b/spec/ruby/core/complex/spaceship_spec.rb
deleted file mode 100644
index 7b2849a86a..0000000000
--- a/spec/ruby/core/complex/spaceship_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Complex#<=>" do
- ruby_version_is '2.7' do
- it "returns nil if either self or argument has imaginary part" do
- (Complex(5, 1) <=> Complex(2)).should be_nil
- (Complex(1) <=> Complex(2, 1)).should be_nil
- (5 <=> Complex(2, 1)).should be_nil
- end
-
- it "returns nil if argument is not numeric" do
- (Complex(5, 1) <=> "cmp").should be_nil
- (Complex(1) <=> "cmp").should be_nil
- (Complex(1) <=> Object.new).should be_nil
- end
-
- it "returns 0, 1, or -1 if self and argument do not have imaginary part" do
- (Complex(5) <=> Complex(2)).should == 1
- (Complex(2) <=> Complex(3)).should == -1
- (Complex(2) <=> Complex(2)).should == 0
-
- (Complex(5) <=> 2).should == 1
- (Complex(2) <=> 3).should == -1
- (Complex(2) <=> 2).should == 0
- end
- end
-end
diff --git a/spec/ruby/core/complex/to_f_spec.rb b/spec/ruby/core/complex/to_f_spec.rb
index 78e6526491..33342e61cc 100644
--- a/spec/ruby/core/complex/to_f_spec.rb
+++ b/spec/ruby/core/complex/to_f_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Complex#to_f" do
describe "when the imaginary part is Fixnum 0" do
@@ -29,13 +29,13 @@ describe "Complex#to_f" do
describe "when the imaginary part is non-zero" do
it "raises RangeError" do
- -> { Complex(0, 1).to_f }.should raise_error(RangeError)
+ lambda { Complex(0, 1).to_f }.should raise_error(RangeError)
end
end
describe "when the imaginary part is Float 0.0" do
it "raises RangeError" do
- -> { Complex(0, 0.0).to_f }.should raise_error(RangeError)
+ lambda { Complex(0, 0.0).to_f }.should raise_error(RangeError)
end
end
end
diff --git a/spec/ruby/core/complex/to_i_spec.rb b/spec/ruby/core/complex/to_i_spec.rb
index 23134705ba..ea8b199b2e 100644
--- a/spec/ruby/core/complex/to_i_spec.rb
+++ b/spec/ruby/core/complex/to_i_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Complex#to_i" do
describe "when the imaginary part is Fixnum 0" do
@@ -29,13 +29,13 @@ describe "Complex#to_i" do
describe "when the imaginary part is non-zero" do
it "raises RangeError" do
- -> { Complex(0, 1).to_i }.should raise_error(RangeError)
+ lambda { Complex(0, 1).to_i }.should raise_error(RangeError)
end
end
describe "when the imaginary part is Float 0.0" do
it "raises RangeError" do
- -> { Complex(0, 0.0).to_i }.should raise_error(RangeError)
+ lambda { Complex(0, 0.0).to_i }.should raise_error(RangeError)
end
end
end
diff --git a/spec/ruby/core/complex/to_r_spec.rb b/spec/ruby/core/complex/to_r_spec.rb
index 76a69a0b93..92fcdd3862 100644
--- a/spec/ruby/core/complex/to_r_spec.rb
+++ b/spec/ruby/core/complex/to_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Complex#to_r" do
describe "when the imaginary part is Fixnum 0" do
@@ -29,13 +29,13 @@ describe "Complex#to_r" do
describe "when the imaginary part is non-zero" do
it "raises RangeError" do
- -> { Complex(0, 1).to_r }.should raise_error(RangeError)
+ lambda { Complex(0, 1).to_r }.should raise_error(RangeError)
end
end
describe "when the imaginary part is Float 0.0" do
it "raises RangeError" do
- -> { Complex(0, 0.0).to_r }.should raise_error(RangeError)
+ lambda { Complex(0, 0.0).to_r }.should raise_error(RangeError)
end
end
end
diff --git a/spec/ruby/core/complex/to_s_spec.rb b/spec/ruby/core/complex/to_s_spec.rb
index 989a7ae0b7..c398bb000e 100644
--- a/spec/ruby/core/complex/to_s_spec.rb
+++ b/spec/ruby/core/complex/to_s_spec.rb
@@ -1,44 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/complex/to_s', __FILE__)
describe "Complex#to_s" do
- describe "when self's real component is 0" do
- it "returns both the real and imaginary component even when the real is 0" do
- Complex(0, 5).to_s.should == "0+5i"
- Complex(0, -3.2).to_s.should == "0-3.2i"
- end
- end
-
- it "returns self as String" do
- Complex(1, 5).to_s.should == "1+5i"
- Complex(-2.5, 1.5).to_s.should == "-2.5+1.5i"
-
- Complex(1, -5).to_s.should == "1-5i"
- Complex(-2.5, -1.5).to_s.should == "-2.5-1.5i"
-
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
- Complex(1, 0).to_s.should == "1+0i"
- Complex(1, -0).to_s.should == "1+0i"
- end
- end
-
- it "returns 1+0.0i for Complex(1, 0.0)" do
- Complex(1, 0.0).to_s.should == "1+0.0i"
- end
-
- it "returns 1-0.0i for Complex(1, -0.0)" do
- Complex(1, -0.0).to_s.should == "1-0.0i"
- end
-
- it "returns 1+Infinity*i for Complex(1, Infinity)" do
- Complex(1, infinity_value).to_s.should == "1+Infinity*i"
- end
-
- it "returns 1-Infinity*i for Complex(1, -Infinity)" do
- Complex(1, -infinity_value).to_s.should == "1-Infinity*i"
- end
-
- it "returns 1+NaN*i for Complex(1, NaN)" do
- Complex(1, nan_value).to_s.should == "1+NaN*i"
- end
+ it_behaves_like(:complex_to_s, :to_s)
end
diff --git a/spec/ruby/core/complex/uminus_spec.rb b/spec/ruby/core/complex/uminus_spec.rb
index c0184e11de..1bf56e770b 100644
--- a/spec/ruby/core/complex/uminus_spec.rb
+++ b/spec/ruby/core/complex/uminus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Complex#-@" do
it "sends #-@ to the real and imaginary parts and returns a Complex with the resulting respective parts" do
diff --git a/spec/ruby/core/data/constants_spec.rb b/spec/ruby/core/data/constants_spec.rb
deleted file mode 100644
index 000da8fd09..0000000000
--- a/spec/ruby/core/data/constants_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Data" do
- it "is a subclass of Object" do
- suppress_warning do
- Data.superclass.should == Object
- end
- end
-
- ruby_version_is "2.5" do
- before :each do
- @deprecated = Warning[:deprecated]
- Warning[:deprecated] = true
- end
- after :each do
- Warning[:deprecated] = @deprecated
- end
- it "is deprecated" do
- -> { Data }.should complain(/constant ::Data is deprecated/)
- end
- end
-end
diff --git a/spec/ruby/core/dir/chdir_spec.rb b/spec/ruby/core/dir/chdir_spec.rb
index 729ac403e3..f5b0b80d1c 100644
--- a/spec/ruby/core/dir/chdir_spec.rb
+++ b/spec/ruby/core/dir/chdir_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Dir.chdir" do
before :all do
@@ -88,19 +88,19 @@ describe "Dir.chdir" do
end
it "raises an Errno::ENOENT if the directory does not exist" do
- -> { Dir.chdir DirSpecs.nonexistent }.should raise_error(Errno::ENOENT)
- -> { Dir.chdir(DirSpecs.nonexistent) { } }.should raise_error(Errno::ENOENT)
+ lambda { Dir.chdir DirSpecs.nonexistent }.should raise_error(Errno::ENOENT)
+ lambda { Dir.chdir(DirSpecs.nonexistent) { } }.should raise_error(Errno::ENOENT)
end
it "raises an Errno::ENOENT if the original directory no longer exists" do
dir1 = tmp('/testdir1')
dir2 = tmp('/testdir2')
- File.should_not.exist?(dir1)
- File.should_not.exist?(dir2)
+ File.exist?(dir1).should == false
+ File.exist?(dir2).should == false
Dir.mkdir dir1
Dir.mkdir dir2
begin
- -> {
+ lambda {
Dir.chdir dir1 do
Dir.chdir(dir2) { Dir.unlink dir1 }
end
diff --git a/spec/ruby/core/dir/children_spec.rb b/spec/ruby/core/dir/children_spec.rb
index 8f6e62b463..a80e685996 100644
--- a/spec/ruby/core/dir/children_spec.rb
+++ b/spec/ruby/core/dir/children_spec.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
ruby_version_is "2.5" do
describe "Dir.children" do
@@ -43,10 +43,10 @@ ruby_version_is "2.5" do
it "returns children encoded with the filesystem encoding by default" do
# This spec depends on the locale not being US-ASCII because if it is, the
- # children that are not ascii_only? will be BINARY encoded.
+ # children that are not ascii_only? will be ASCII-8BIT encoded.
children = Dir.children(File.join(DirSpecs.mock_dir, 'special')).sort
encoding = Encoding.find("filesystem")
- encoding = Encoding::BINARY if encoding == Encoding::US_ASCII
+ encoding = Encoding::ASCII_8BIT if encoding == Encoding::US_ASCII
platform_is_not :windows do
children.should include("ã“ã‚“ã«ã¡ã¯.txt".force_encoding(encoding))
end
@@ -65,74 +65,8 @@ ruby_version_is "2.5" do
children.first.encoding.should equal(Encoding::EUC_KR)
end
- it "raises a SystemCallError if called with a nonexistent directory" do
- -> { Dir.children DirSpecs.nonexistent }.should raise_error(SystemCallError)
- end
- end
-end
-
-ruby_version_is "2.6" do
- describe "Dir#children" do
- before :all do
- DirSpecs.create_mock_dirs
- end
-
- before :each do
- @internal = Encoding.default_internal
- end
-
- after :all do
- DirSpecs.delete_mock_dirs
- end
-
- after :each do
- Encoding.default_internal = @internal
- @dir.close if @dir
- end
-
- it "returns an Array of filenames in an existing directory including dotfiles" do
- @dir = Dir.new(DirSpecs.mock_dir)
- a = @dir.children.sort
- @dir.close
-
- a.should == DirSpecs.expected_paths - %w[. ..]
-
- @dir = Dir.new("#{DirSpecs.mock_dir}/deeply/nested")
- a = @dir.children.sort
- a.should == %w|.dotfile.ext directory|
- end
-
- it "accepts an options Hash" do
- @dir = Dir.new("#{DirSpecs.mock_dir}/deeply/nested", encoding: "utf-8")
- a = @dir.children.sort
- a.should == %w|.dotfile.ext directory|
- end
-
- it "returns children encoded with the filesystem encoding by default" do
- # This spec depends on the locale not being US-ASCII because if it is, the
- # children that are not ascii_only? will be BINARY encoded.
- @dir = Dir.new(File.join(DirSpecs.mock_dir, 'special'))
- children = @dir.children.sort
- encoding = Encoding.find("filesystem")
- encoding = Encoding::BINARY if encoding == Encoding::US_ASCII
- platform_is_not :windows do
- children.should include("ã“ã‚“ã«ã¡ã¯.txt".force_encoding(encoding))
- end
- children.first.encoding.should equal(Encoding.find("filesystem"))
- end
-
- it "returns children encoded with the specified encoding" do
- path = File.join(DirSpecs.mock_dir, 'special')
- @dir = Dir.new(path, encoding: "euc-jp")
- children = @dir.children.sort
- children.first.encoding.should equal(Encoding::EUC_JP)
- end
-
- it "returns children transcoded to the default internal encoding" do
- Encoding.default_internal = Encoding::EUC_KR
- @dir = Dir.new(File.join(DirSpecs.mock_dir, 'special'))
- children = @dir.children.sort
- children.first.encoding.should equal(Encoding::EUC_KR)
+ it "raises a SystemCallError if called with a nonexistent diretory" do
+ lambda { Dir.children DirSpecs.nonexistent }.should raise_error(SystemCallError)
end
end
end
diff --git a/spec/ruby/core/dir/chroot_spec.rb b/spec/ruby/core/dir/chroot_spec.rb
index a5ca8943fc..23d790c83b 100644
--- a/spec/ruby/core/dir/chroot_spec.rb
+++ b/spec/ruby/core/dir/chroot_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/chroot'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/chroot', __FILE__)
platform_is_not :windows do
as_superuser do
@@ -9,7 +9,7 @@ platform_is_not :windows do
end
end
- platform_is_not :cygwin, :android do
+ platform_is_not :cygwin do
as_user do
describe "Dir.chroot as regular user" do
before :all do
@@ -21,17 +21,17 @@ platform_is_not :windows do
end
it "raises an Errno::EPERM exception if the directory exists" do
- -> { Dir.chroot('.') }.should raise_error(Errno::EPERM)
+ lambda { Dir.chroot('.') }.should raise_error(Errno::EPERM)
end
it "raises a SystemCallError if the directory doesn't exist" do
- -> { Dir.chroot('xgwhwhsjai2222jg') }.should raise_error(SystemCallError)
+ lambda { Dir.chroot('xgwhwhsjai2222jg') }.should raise_error(SystemCallError)
end
it "calls #to_path on non-String argument" do
p = mock('path')
p.should_receive(:to_path).and_return('.')
- -> { Dir.chroot(p) }.should raise_error(Errno::EPERM)
+ lambda { Dir.chroot(p) }.should raise_error(Errno::EPERM)
end
end
end
diff --git a/spec/ruby/core/dir/close_spec.rb b/spec/ruby/core/dir/close_spec.rb
index 5fad5eecfb..7b08ec5ee8 100644
--- a/spec/ruby/core/dir/close_spec.rb
+++ b/spec/ruby/core/dir/close_spec.rb
@@ -1,5 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+ruby_version_is ''...'2.3' do
+ require File.expand_path('../shared/closed', __FILE__)
+end
+
describe "Dir#close" do
before :all do
DirSpecs.create_mock_dirs
@@ -9,11 +13,17 @@ describe "Dir#close" do
DirSpecs.delete_mock_dirs
end
- it "does not raise an IOError even if the Dir instance is closed" do
- dir = Dir.open DirSpecs.mock_dir
- dir.close
- -> {
+ ruby_version_is ''...'2.3' do
+ it_behaves_like :dir_closed, :close
+ end
+
+ ruby_version_is '2.3' do
+ it "does not raise an IOError even if the Dir instance is closed" do
+ dir = Dir.open DirSpecs.mock_dir
dir.close
- }.should_not raise_error(IOError)
+ lambda {
+ dir.close
+ }.should_not raise_error(IOError)
+ end
end
end
diff --git a/spec/ruby/core/dir/delete_spec.rb b/spec/ruby/core/dir/delete_spec.rb
index a0020788ca..5f36956839 100644
--- a/spec/ruby/core/dir/delete_spec.rb
+++ b/spec/ruby/core/dir/delete_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/delete'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/delete', __FILE__)
describe "Dir.delete" do
before :all do
diff --git a/spec/ruby/core/dir/dir_spec.rb b/spec/ruby/core/dir/dir_spec.rb
index 7d55ea26d4..4923445bed 100644
--- a/spec/ruby/core/dir/dir_spec.rb
+++ b/spec/ruby/core/dir/dir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Dir" do
it "includes Enumerable" do
diff --git a/spec/ruby/core/dir/each_child_spec.rb b/spec/ruby/core/dir/each_child_spec.rb
index dcc9a456c7..70f6f63333 100644
--- a/spec/ruby/core/dir/each_child_spec.rb
+++ b/spec/ruby/core/dir/each_child_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
ruby_version_is "2.5" do
describe "Dir.each_child" do
@@ -32,7 +32,7 @@ ruby_version_is "2.5" do
end
it "raises a SystemCallError if passed a nonexistent directory" do
- -> { Dir.each_child(DirSpecs.nonexistent) {} }.should raise_error(SystemCallError)
+ lambda { Dir.each_child(DirSpecs.nonexistent) {} }.should raise_error(SystemCallError)
end
describe "when no block is given" do
@@ -51,55 +51,3 @@ ruby_version_is "2.5" do
end
end
end
-
-ruby_version_is "2.6" do
- describe "Dir#each_child" do
- before :all do
- DirSpecs.create_mock_dirs
- end
-
- after :all do
- DirSpecs.delete_mock_dirs
- end
-
- after :each do
- @dir.close if @dir
- end
-
- it "yields all names in an existing directory to the provided block" do
- a, b = [], []
- @dir = Dir.new(DirSpecs.mock_dir)
- @dir2 = Dir.new("#{DirSpecs.mock_dir}/deeply/nested")
-
- @dir.each_child { |f| a << f }
- @dir2.each_child { |f| b << f }
- @dir2.close
-
- a.sort.should == DirSpecs.expected_paths - %w|. ..|
- b.sort.should == %w|.dotfile.ext directory|
- end
-
- it "returns self when successful" do
- @dir = Dir.new(DirSpecs.mock_dir)
- @dir.each_child { |f| f }.should == @dir
- end
-
- describe "when no block is given" do
- it "returns an Enumerator" do
- @dir = Dir.new(DirSpecs.mock_dir)
-
- @dir.each_child.should be_an_instance_of(Enumerator)
- @dir.each_child.to_a.sort.should == DirSpecs.expected_paths - %w|. ..|
- end
-
- describe "returned Enumerator" do
- describe "size" do
- it "should return nil" do
- @dir = Dir.new(DirSpecs.mock_dir)
- @dir.each_child.size.should == nil
- end
- end
- end
- end
- end
-end
diff --git a/spec/ruby/core/dir/each_spec.rb b/spec/ruby/core/dir/each_spec.rb
index 8c69a7212b..534691ff58 100644
--- a/spec/ruby/core/dir/each_spec.rb
+++ b/spec/ruby/core/dir/each_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/closed'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/closed', __FILE__)
describe "Dir#each" do
before :all do
diff --git a/spec/ruby/core/dir/element_reference_spec.rb b/spec/ruby/core/dir/element_reference_spec.rb
index 092114bed4..de379d75ac 100644
--- a/spec/ruby/core/dir/element_reference_spec.rb
+++ b/spec/ruby/core/dir/element_reference_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/glob'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/glob', __FILE__)
describe "Dir.[]" do
it_behaves_like :dir_glob, :[]
diff --git a/spec/ruby/core/dir/empty_spec.rb b/spec/ruby/core/dir/empty_spec.rb
index 8cc8757798..861a538f84 100644
--- a/spec/ruby/core/dir/empty_spec.rb
+++ b/spec/ruby/core/dir/empty_spec.rb
@@ -1,31 +1,33 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Dir.empty?" do
- before :all do
- @empty_dir = tmp("empty_dir")
- mkdir_p @empty_dir
- end
+ruby_version_is "2.4" do
+ describe "Dir.empty?" do
+ before :all do
+ @empty_dir = tmp("empty_dir")
+ mkdir_p @empty_dir
+ end
- after :all do
- rm_r @empty_dir
- end
+ after :all do
+ rm_r @empty_dir
+ end
- it "returns true for empty directories" do
- result = Dir.empty? @empty_dir
- result.should be_true
- end
+ it "returns true for empty directories" do
+ result = Dir.empty? @empty_dir
+ result.should be_true
+ end
- it "returns false for non-empty directories" do
- result = Dir.empty? __dir__
- result.should be_false
- end
+ it "returns false for non-empty directories" do
+ result = Dir.empty? __dir__
+ result.should be_false
+ end
- it "returns false for a non-directory" do
- result = Dir.empty? __FILE__
- result.should be_false
- end
+ it "returns false for a non-directory" do
+ result = Dir.empty? __FILE__
+ result.should be_false
+ end
- it "raises ENOENT for nonexistent directories" do
- -> { Dir.empty? tmp("nonexistent") }.should raise_error(Errno::ENOENT)
+ it "raises ENOENT for nonexistent directories" do
+ lambda { Dir.empty? tmp("nonexistent") }.should raise_error(Errno::ENOENT)
+ end
end
end
diff --git a/spec/ruby/core/dir/entries_spec.rb b/spec/ruby/core/dir/entries_spec.rb
index 33568b6fc4..8a31ab4b4a 100644
--- a/spec/ruby/core/dir/entries_spec.rb
+++ b/spec/ruby/core/dir/entries_spec.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Dir.entries" do
before :all do
@@ -42,10 +42,10 @@ describe "Dir.entries" do
it "returns entries encoded with the filesystem encoding by default" do
# This spec depends on the locale not being US-ASCII because if it is, the
- # entries that are not ascii_only? will be BINARY encoded.
+ # entries that are not ascii_only? will be ASCII-8BIT encoded.
entries = Dir.entries(File.join(DirSpecs.mock_dir, 'special')).sort
encoding = Encoding.find("filesystem")
- encoding = Encoding::BINARY if encoding == Encoding::US_ASCII
+ encoding = Encoding::ASCII_8BIT if encoding == Encoding::US_ASCII
platform_is_not :windows do
entries.should include("ã“ã‚“ã«ã¡ã¯.txt".force_encoding(encoding))
end
@@ -64,7 +64,7 @@ describe "Dir.entries" do
entries.first.encoding.should equal(Encoding::EUC_KR)
end
- it "raises a SystemCallError if called with a nonexistent directory" do
- -> { Dir.entries DirSpecs.nonexistent }.should raise_error(SystemCallError)
+ it "raises a SystemCallError if called with a nonexistent diretory" do
+ lambda { Dir.entries DirSpecs.nonexistent }.should raise_error(SystemCallError)
end
end
diff --git a/spec/ruby/core/dir/exist_spec.rb b/spec/ruby/core/dir/exist_spec.rb
index 43987b0f32..194284b5a0 100644
--- a/spec/ruby/core/dir/exist_spec.rb
+++ b/spec/ruby/core/dir/exist_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/exist'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/exist', __FILE__)
describe "Dir.exist?" do
before :all do
@@ -11,5 +11,5 @@ describe "Dir.exist?" do
DirSpecs.delete_mock_dirs
end
- it_behaves_like :dir_exist, :exist?
+ it_behaves_like(:dir_exist, :exist?)
end
diff --git a/spec/ruby/core/dir/exists_spec.rb b/spec/ruby/core/dir/exists_spec.rb
index 2c6f145db2..002506a22f 100644
--- a/spec/ruby/core/dir/exists_spec.rb
+++ b/spec/ruby/core/dir/exists_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/exist'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/exist', __FILE__)
describe "Dir.exists?" do
before :all do
@@ -11,5 +11,5 @@ describe "Dir.exists?" do
DirSpecs.delete_mock_dirs
end
- it_behaves_like :dir_exist, :exists?
+ it_behaves_like(:dir_exist, :exists?)
end
diff --git a/spec/ruby/core/dir/fileno_spec.rb b/spec/ruby/core/dir/fileno_spec.rb
index 504e36d44b..cf8b811e3b 100644
--- a/spec/ruby/core/dir/fileno_spec.rb
+++ b/spec/ruby/core/dir/fileno_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
has_dir_fileno = begin
dir = Dir.new('.')
@@ -31,7 +31,7 @@ describe "Dir#fileno" do
end
else
it "raises an error when not implemented on the platform" do
- -> { @dir.fileno }.should raise_error(NotImplementedError)
+ lambda { @dir.fileno }.should raise_error(NotImplementedError)
end
end
end
diff --git a/spec/ruby/core/dir/foreach_spec.rb b/spec/ruby/core/dir/foreach_spec.rb
index 1560b85f8a..e606b4f65c 100644
--- a/spec/ruby/core/dir/foreach_spec.rb
+++ b/spec/ruby/core/dir/foreach_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Dir.foreach" do
before :all do
@@ -31,7 +31,7 @@ describe "Dir.foreach" do
end
it "raises a SystemCallError if passed a nonexistent directory" do
- -> { Dir.foreach(DirSpecs.nonexistent) {} }.should raise_error(SystemCallError)
+ lambda { Dir.foreach(DirSpecs.nonexistent) {} }.should raise_error(SystemCallError)
end
it "returns an Enumerator if no block given" do
diff --git a/spec/ruby/core/dir/getwd_spec.rb b/spec/ruby/core/dir/getwd_spec.rb
index 132634347c..26659ddec7 100644
--- a/spec/ruby/core/dir/getwd_spec.rb
+++ b/spec/ruby/core/dir/getwd_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/pwd'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/pwd', __FILE__)
describe "Dir.getwd" do
before :all do
diff --git a/spec/ruby/core/dir/glob_spec.rb b/spec/ruby/core/dir/glob_spec.rb
index 4b437b0e24..4a9230f8b3 100644
--- a/spec/ruby/core/dir/glob_spec.rb
+++ b/spec/ruby/core/dir/glob_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/glob'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/glob', __FILE__)
describe "Dir.glob" do
it_behaves_like :dir_glob, :glob
@@ -122,18 +122,6 @@ describe "Dir.glob" do
Dir.glob('**/**/**').empty?.should == false
end
- it "handles simple filename patterns" do
- Dir.glob('.dotfile').should == ['.dotfile']
- end
-
- it "handles simple directory patterns" do
- Dir.glob('.dotsubdir/').should == ['.dotsubdir/']
- end
-
- it "handles simple directory patterns applied to non-directories" do
- Dir.glob('nondotfile/').should == []
- end
-
platform_is_not(:windows) do
it "matches the literal character '\\' with option File::FNM_NOESCAPE" do
Dir.mkdir 'foo?bar'
diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb
index cdfc9346dc..6d99678034 100644
--- a/spec/ruby/core/dir/home_spec.rb
+++ b/spec/ruby/core/dir/home_spec.rb
@@ -1,45 +1,26 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Dir.home" do
- before :each do
- @home = ENV['HOME']
- ENV['HOME'] = "/rubyspec_home"
- end
-
- after :each do
- ENV['HOME'] = @home
- end
-
- describe "when called without arguments" do
- it "returns the current user's home directory, reading $HOME first" do
- Dir.home.should == "/rubyspec_home"
- end
-
- it "returns a non-frozen string" do
- Dir.home.frozen?.should == false
- end
- end
-
- describe "when called with the current user name" do
- platform_is :solaris do
- it "returns the named user's home directory from the user database" do
- Dir.home(ENV['USER']).should == `getent passwd #{ENV['USER']}|cut -d: -f6`.chomp
+ it "returns the current user's home directory as a string if called without arguments" do
+ home_directory = ENV['HOME']
+ platform_is :windows do
+ unless home_directory
+ home_directory = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
end
+ home_directory = home_directory.tr('\\', '/').chomp('/')
end
- platform_is_not :windows, :solaris do
- it "returns the named user's home directory, from the user database" do
- Dir.home(ENV['USER']).should == `echo ~#{ENV['USER']}`.chomp
- end
- end
+ Dir.home.should == home_directory
+ end
- it "returns a non-frozen string" do
- Dir.home(ENV['USER']).frozen?.should == false
+ platform_is_not :windows do
+ it "returns the named user's home directory as a string if called with an argument" do
+ Dir.home(ENV['USER']).should == ENV['HOME']
end
end
it "raises an ArgumentError if the named user doesn't exist" do
- -> { Dir.home('geuw2n288dh2k') }.should raise_error(ArgumentError)
+ lambda { Dir.home('geuw2n288dh2k') }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/dir/initialize_spec.rb b/spec/ruby/core/dir/initialize_spec.rb
index 547b7dc18e..b9420647d1 100644
--- a/spec/ruby/core/dir/initialize_spec.rb
+++ b/spec/ruby/core/dir/initialize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Dir#initialize" do
before :each do
diff --git a/spec/ruby/core/dir/inspect_spec.rb b/spec/ruby/core/dir/inspect_spec.rb
index 37338a97d4..01bde8a862 100644
--- a/spec/ruby/core/dir/inspect_spec.rb
+++ b/spec/ruby/core/dir/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Dir#inspect" do
before :each do
diff --git a/spec/ruby/core/dir/mkdir_spec.rb b/spec/ruby/core/dir/mkdir_spec.rb
index c6e2f164e2..7eb8a8fe6c 100644
--- a/spec/ruby/core/dir/mkdir_spec.rb
+++ b/spec/ruby/core/dir/mkdir_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Dir.mkdir" do
before :all do
@@ -14,9 +14,9 @@ describe "Dir.mkdir" do
DirSpecs.clear_dirs
begin
- File.should_not.exist?('nonexisting')
+ File.exist?('nonexisting').should == false
Dir.mkdir 'nonexisting'
- File.should.exist?('nonexisting')
+ File.exist?('nonexisting').should == true
platform_is_not :windows do
Dir.mkdir 'default_perms'
a = File.stat('default_perms').mode
@@ -51,37 +51,35 @@ describe "Dir.mkdir" do
end
it "raises a SystemCallError if any of the directories in the path before the last does not exist" do
- -> { Dir.mkdir "#{DirSpecs.nonexistent}/subdir" }.should raise_error(SystemCallError)
+ lambda { Dir.mkdir "#{DirSpecs.nonexistent}/subdir" }.should raise_error(SystemCallError)
end
it "raises Errno::EEXIST if the specified directory already exists" do
- -> { Dir.mkdir("#{DirSpecs.mock_dir}/dir") }.should raise_error(Errno::EEXIST)
+ lambda { Dir.mkdir("#{DirSpecs.mock_dir}/dir") }.should raise_error(Errno::EEXIST)
end
it "raises Errno::EEXIST if the argument points to the existing file" do
- -> { Dir.mkdir("#{DirSpecs.mock_dir}/file_one.ext") }.should raise_error(Errno::EEXIST)
+ lambda { Dir.mkdir("#{DirSpecs.mock_dir}/file_one.ext") }.should raise_error(Errno::EEXIST)
end
end
# The permissions flag are not supported on Windows as stated in documentation:
# The permissions may be modified by the value of File.umask, and are ignored on NT.
platform_is_not :windows do
- as_user do
- describe "Dir.mkdir" do
- before :each do
- @dir = tmp "noperms"
- end
+ describe "Dir.mkdir" do
+ before :each do
+ @dir = tmp "noperms"
+ end
- after :each do
- File.chmod 0777, @dir
- rm_r @dir
- end
+ after :each do
+ File.chmod 0777, @dir
+ rm_r @dir
+ end
- it "raises a SystemCallError when lacking adequate permissions in the parent dir" do
- Dir.mkdir @dir, 0000
+ it "raises a SystemCallError when lacking adequate permissions in the parent dir" do
+ Dir.mkdir @dir, 0000
- -> { Dir.mkdir "#{@dir}/subdir" }.should raise_error(SystemCallError)
- end
+ lambda { Dir.mkdir "#{@dir}/subdir" }.should raise_error(SystemCallError)
end
end
end
diff --git a/spec/ruby/core/dir/open_spec.rb b/spec/ruby/core/dir/open_spec.rb
index 27f362320b..b3deed47b7 100644
--- a/spec/ruby/core/dir/open_spec.rb
+++ b/spec/ruby/core/dir/open_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/open'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/open', __FILE__)
describe "Dir.open" do
before :all do
diff --git a/spec/ruby/core/dir/path_spec.rb b/spec/ruby/core/dir/path_spec.rb
index b1c24c406b..1601220636 100644
--- a/spec/ruby/core/dir/path_spec.rb
+++ b/spec/ruby/core/dir/path_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/path'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/path', __FILE__)
describe "Dir#path" do
before :all do
@@ -11,5 +11,5 @@ describe "Dir#path" do
DirSpecs.delete_mock_dirs
end
- it_behaves_like :dir_path, :path
+ it_behaves_like(:dir_path, :path)
end
diff --git a/spec/ruby/core/dir/pos_spec.rb b/spec/ruby/core/dir/pos_spec.rb
index b382bff81f..9f05fab250 100644
--- a/spec/ruby/core/dir/pos_spec.rb
+++ b/spec/ruby/core/dir/pos_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/closed'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/closed', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "Dir#pos" do
before :all do
diff --git a/spec/ruby/core/dir/pwd_spec.rb b/spec/ruby/core/dir/pwd_spec.rb
index ad01286c90..4fa86dd6b9 100644
--- a/spec/ruby/core/dir/pwd_spec.rb
+++ b/spec/ruby/core/dir/pwd_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/pwd'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/pwd', __FILE__)
describe "Dir.pwd" do
before :all do
diff --git a/spec/ruby/core/dir/read_spec.rb b/spec/ruby/core/dir/read_spec.rb
index 59de2e81cf..79ed9b8058 100644
--- a/spec/ruby/core/dir/read_spec.rb
+++ b/spec/ruby/core/dir/read_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/closed'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/closed', __FILE__)
describe "Dir#read" do
before :all do
diff --git a/spec/ruby/core/dir/rewind_spec.rb b/spec/ruby/core/dir/rewind_spec.rb
index 220d7f5372..65ffcdf1c3 100644
--- a/spec/ruby/core/dir/rewind_spec.rb
+++ b/spec/ruby/core/dir/rewind_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/closed'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/closed', __FILE__)
describe "Dir#rewind" do
before :all do
diff --git a/spec/ruby/core/dir/rmdir_spec.rb b/spec/ruby/core/dir/rmdir_spec.rb
index 08cd1a5bc6..09499572c0 100644
--- a/spec/ruby/core/dir/rmdir_spec.rb
+++ b/spec/ruby/core/dir/rmdir_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/delete'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/delete', __FILE__)
describe "Dir.rmdir" do
before :all do
diff --git a/spec/ruby/core/dir/seek_spec.rb b/spec/ruby/core/dir/seek_spec.rb
index ed409897cd..b51e554441 100644
--- a/spec/ruby/core/dir/seek_spec.rb
+++ b/spec/ruby/core/dir/seek_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "Dir#seek" do
before :all do
diff --git a/spec/ruby/core/dir/shared/chroot.rb b/spec/ruby/core/dir/shared/chroot.rb
index b14a433670..2ed033dfed 100644
--- a/spec/ruby/core/dir/shared/chroot.rb
+++ b/spec/ruby/core/dir/shared/chroot.rb
@@ -15,8 +15,8 @@ describe :dir_chroot_as_root, shared: true do
end
it "can be used to change the process' root directory" do
- -> { Dir.send(@method, File.dirname(__FILE__)) }.should_not raise_error
- File.should.exist?("/#{File.basename(__FILE__)}")
+ lambda { Dir.send(@method, File.dirname(__FILE__)) }.should_not raise_error
+ File.exist?("/#{File.basename(__FILE__)}").should be_true
end
it "returns 0 if successful" do
@@ -24,13 +24,13 @@ describe :dir_chroot_as_root, shared: true do
end
it "raises an Errno::ENOENT exception if the directory doesn't exist" do
- -> { Dir.send(@method, 'xgwhwhsjai2222jg') }.should raise_error(Errno::ENOENT)
+ lambda { Dir.send(@method, 'xgwhwhsjai2222jg') }.should raise_error(Errno::ENOENT)
end
it "can be escaped from with ../" do
Dir.send(@method, @real_root)
- File.should.exist?(@ref_dir)
- File.should_not.exist?("/#{File.basename(__FILE__)}")
+ File.exist?(@ref_dir).should be_true
+ File.exist?("/#{File.basename(__FILE__)}").should be_false
end
it "calls #to_path on non-String argument" do
diff --git a/spec/ruby/core/dir/shared/closed.rb b/spec/ruby/core/dir/shared/closed.rb
index 17d8332c2a..a1bce06a08 100644
--- a/spec/ruby/core/dir/shared/closed.rb
+++ b/spec/ruby/core/dir/shared/closed.rb
@@ -1,6 +1,6 @@
describe :dir_closed, shared: true do
it "raises an IOError when called on a closed Dir instance" do
- -> {
+ lambda {
dir = Dir.open DirSpecs.mock_dir
dir.close
dir.send(@method) {}
diff --git a/spec/ruby/core/dir/shared/delete.rb b/spec/ruby/core/dir/shared/delete.rb
index 49e88360e8..8db17d985f 100644
--- a/spec/ruby/core/dir/shared/delete.rb
+++ b/spec/ruby/core/dir/shared/delete.rb
@@ -19,7 +19,7 @@ describe :dir_delete, shared: true do
platform_is_not :solaris do
it "raises an Errno::ENOTEMPTY when trying to remove a nonempty directory" do
- -> do
+ lambda do
Dir.send @method, DirSpecs.mock_rmdir("nonempty")
end.should raise_error(Errno::ENOTEMPTY)
end
@@ -27,14 +27,14 @@ describe :dir_delete, shared: true do
platform_is :solaris do
it "raises an Errno::EEXIST when trying to remove a nonempty directory" do
- -> do
+ lambda do
Dir.send @method, DirSpecs.mock_rmdir("nonempty")
end.should raise_error(Errno::EEXIST)
end
end
it "raises an Errno::ENOENT when trying to remove a non-existing directory" do
- -> do
+ lambda do
Dir.send @method, DirSpecs.nonexistent
end.should raise_error(Errno::ENOENT)
end
@@ -42,22 +42,20 @@ describe :dir_delete, shared: true do
it "raises an Errno::ENOTDIR when trying to remove a non-directory" do
file = DirSpecs.mock_rmdir("nonempty/regular")
touch(file)
- -> do
+ lambda do
Dir.send @method, file
end.should raise_error(Errno::ENOTDIR)
end
# this won't work on Windows, since chmod(0000) does not remove all permissions
platform_is_not :windows do
- as_user do
- it "raises an Errno::EACCES if lacking adequate permissions to remove the directory" do
- parent = DirSpecs.mock_rmdir("noperm")
- child = DirSpecs.mock_rmdir("noperm", "child")
- File.chmod(0000, parent)
- -> do
- Dir.send @method, child
- end.should raise_error(Errno::EACCES)
- end
+ it "raises an Errno::EACCES if lacking adequate permissions to remove the directory" do
+ parent = DirSpecs.mock_rmdir("noperm")
+ child = DirSpecs.mock_rmdir("noperm", "child")
+ File.chmod(0000, parent)
+ lambda do
+ Dir.send @method, child
+ end.should raise_error(Errno::EACCES)
end
end
end
diff --git a/spec/ruby/core/dir/shared/exist.rb b/spec/ruby/core/dir/shared/exist.rb
index 765d1b656c..fbd2c9862d 100644
--- a/spec/ruby/core/dir/shared/exist.rb
+++ b/spec/ruby/core/dir/shared/exist.rb
@@ -39,7 +39,7 @@ describe :dir_exist, shared: true do
end
it "returns false if the argument exists but is a file" do
- File.should.exist?(__FILE__)
+ File.exist?(__FILE__).should be_true
Dir.send(@method, __FILE__).should be_false
end
diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb
index b47e23b41c..d2201cd6cd 100644
--- a/spec/ruby/core/dir/shared/glob.rb
+++ b/spec/ruby/core/dir/shared/glob.rb
@@ -11,9 +11,11 @@ describe :dir_glob, shared: true do
DirSpecs.delete_mock_dirs
end
- it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do
- pattern = "file*".force_encoding Encoding::UTF_16BE
- -> { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError)
+ with_feature :encoding do
+ it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do
+ pattern = "file*".force_encoding Encoding::UTF_16BE
+ lambda { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError)
+ end
end
it "calls #to_path to convert a pattern" do
@@ -23,26 +25,9 @@ describe :dir_glob, shared: true do
Dir.send(@method, obj).should == %w[file_one.ext]
end
- ruby_version_is ""..."2.6" do
- it "splits the string on \\0 if there is only one string given" do
- Dir.send(@method, "file_o*\0file_t*").should ==
- %w!file_one.ext file_two.ext!
- end
- end
-
- ruby_version_is "2.6"..."2.7" do
- it "splits the string on \\0 if there is only one string given and warns" do
- -> {
- Dir.send(@method, "file_o*\0file_t*").should ==
- %w!file_one.ext file_two.ext!
- }.should complain(/warning: use glob patterns list instead of nul-separated patterns/)
- end
- end
-
- ruby_version_is "2.7" do
- it "raises an ArgumentError if the string contains \\0" do
- -> {Dir.send(@method, "file_o*\0file_t*")}.should raise_error ArgumentError, /nul-separated/
- end
+ it "splits the string on \\0 if there is only one string given" do
+ Dir.send(@method, "file_o*\0file_t*").should ==
+ %w!file_one.ext file_two.ext!
end
it "matches non-dotfiles with '*'" do
@@ -277,11 +262,11 @@ describe :dir_glob, shared: true do
subdir_two/nondotfile.ext]
end
- it "ignores matching through directories that doesn't exist" do
+ it "ignores matching through directories that doen't exist" do
Dir.send(@method, "deeply/notthere/blah*/whatever").should == []
end
- it "ignores matching only directories under an nonexistent path" do
+ it "ignores matching only directories under an nonexistant path" do
Dir.send(@method, "deeply/notthere/blah/").should == []
end
@@ -290,78 +275,6 @@ describe :dir_glob, shared: true do
Dir.send(@method, "special/ã“ã‚“ã«ã¡ã¯{,.txt}").should == ["special/ã“ã‚“ã«ã¡ã¯.txt"]
end
end
-
- ruby_version_is "2.5" do
- context ":base option passed" do
- before :each do
- @mock_dir = File.expand_path tmp('dir_glob_mock')
-
- %w[
- a/b/x
- a/b/c/y
- a/b/c/d/z
- ].each do |path|
- file = File.join @mock_dir, path
- mkdir_p File.dirname(file)
- touch file
- end
- end
-
- after :each do
- rm_r @mock_dir
- end
-
- it "matches entries only from within the specified directory" do
- path = File.join(@mock_dir, "a/b/c")
- Dir.send(@method, "*", base: path).sort.should == %w( d y )
- end
-
- it "accepts both relative and absolute paths" do
- require 'pathname'
-
- path_abs = File.join(@mock_dir, "a/b/c")
- path_rel = Pathname.new(path_abs).relative_path_from(Pathname.new(Dir.pwd))
-
- result_abs = Dir.send(@method, "*", base: path_abs).sort
- result_rel = Dir.send(@method, "*", base: path_rel).sort
-
- result_abs.should == %w( d y )
- result_rel.should == %w( d y )
- end
-
- it "returns [] if specified path does not exist" do
- path = File.join(@mock_dir, "fake-name")
- File.should_not.exist?(path)
-
- Dir.send(@method, "*", base: path).should == []
- end
-
- it "returns [] if specified path is a file" do
- path = File.join(@mock_dir, "a/b/x")
- File.should.exist?(path)
-
- Dir.send(@method, "*", base: path).should == []
- end
-
- it "raises TypeError when cannot convert value to string" do
- -> {
- Dir.send(@method, "*", base: [])
- }.should raise_error(TypeError)
- end
-
- it "handles '' as current directory path" do
- Dir.chdir @mock_dir do
- Dir.send(@method, "*", base: "").should == %w( a )
- end
- end
-
- it "handles nil as current directory path" do
- Dir.chdir @mock_dir do
- Dir.send(@method, "*", base: nil).should == %w( a )
- end
- end
- end
- end
end
describe :dir_glob_recursive, shared: true do
diff --git a/spec/ruby/core/dir/shared/open.rb b/spec/ruby/core/dir/shared/open.rb
index 76b08dc288..7f4fe5c2a6 100644
--- a/spec/ruby/core/dir/shared/open.rb
+++ b/spec/ruby/core/dir/shared/open.rb
@@ -6,7 +6,7 @@ describe :dir_open, shared: true do
end
it "raises a SystemCallError if the directory does not exist" do
- -> do
+ lambda do
Dir.send @method, DirSpecs.nonexistent
end.should raise_error(SystemCallError)
end
@@ -21,20 +21,20 @@ describe :dir_open, shared: true do
it "closes the Dir instance when the block exits if given a block" do
closed_dir = Dir.send(@method, DirSpecs.mock_dir) { |dir| dir }
- -> { closed_dir.read }.should raise_error(IOError)
+ lambda { closed_dir.read }.should raise_error(IOError)
end
it "closes the Dir instance when the block exits the block even due to an exception" do
closed_dir = nil
- -> do
+ lambda do
Dir.send(@method, DirSpecs.mock_dir) do |dir|
closed_dir = dir
raise "dir specs"
end
end.should raise_error(RuntimeError, "dir specs")
- -> { closed_dir.read }.should raise_error(IOError)
+ lambda { closed_dir.read }.should raise_error(IOError)
end
it "calls #to_path on non-String arguments" do
@@ -52,7 +52,7 @@ describe :dir_open, shared: true do
options = mock("dir_open")
options.should_receive(:to_hash).and_return({ encoding: Encoding::UTF_8 })
- dir = Dir.send(@method, DirSpecs.mock_dir, **options) {|d| d }
+ dir = Dir.send(@method, DirSpecs.mock_dir, options) {|d| d }
dir.should be_kind_of(Dir)
end
@@ -60,14 +60,4 @@ describe :dir_open, shared: true do
dir = Dir.send(@method, DirSpecs.mock_dir, encoding: nil) {|d| d }
dir.should be_kind_of(Dir)
end
-
- platform_is_not :windows do
- it 'sets the close-on-exec flag for the directory file descriptor' do
- Dir.send(@method, DirSpecs.mock_dir) do |dir|
- io = IO.for_fd(dir.fileno)
- io.autoclose = false
- io.close_on_exec?.should == true
- end
- end
- end
end
diff --git a/spec/ruby/core/dir/shared/path.rb b/spec/ruby/core/dir/shared/path.rb
index 494dcca775..829eeb04c2 100644
--- a/spec/ruby/core/dir/shared/path.rb
+++ b/spec/ruby/core/dir/shared/path.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
-require_relative 'closed'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
+require File.expand_path('../closed', __FILE__)
describe :dir_path, shared: true do
it "returns the path that was supplied to .new or .open" do
@@ -18,13 +18,15 @@ describe :dir_path, shared: true do
dir.send(@method).should == DirSpecs.mock_dir
end
- it "returns a String with the same encoding as the argument to .open" do
- path = DirSpecs.mock_dir.force_encoding Encoding::IBM866
- dir = Dir.open path
- begin
- dir.send(@method).encoding.should equal(Encoding::IBM866)
- ensure
- dir.close
+ with_feature :encoding do
+ it "returns a String with the same encoding as the argument to .open" do
+ path = DirSpecs.mock_dir.force_encoding Encoding::IBM866
+ dir = Dir.open path
+ begin
+ dir.send(@method).encoding.should equal(Encoding::IBM866)
+ ensure
+ dir.close
+ end
end
end
end
diff --git a/spec/ruby/core/dir/shared/pwd.rb b/spec/ruby/core/dir/shared/pwd.rb
index 2a8d7fe790..5f041a9d41 100644
--- a/spec/ruby/core/dir/shared/pwd.rb
+++ b/spec/ruby/core/dir/shared/pwd.rb
@@ -1,6 +1,8 @@
describe :dir_pwd, shared: true do
- before :each do
- @fs_encoding = Encoding.find('filesystem')
+ with_feature :encoding do
+ before :each do
+ @fs_encoding = Encoding.find('filesystem')
+ end
end
it "returns the current working directory" do
@@ -34,12 +36,14 @@ describe :dir_pwd, shared: true do
end
end
- it "returns a String with the filesystem encoding" do
- enc = Dir.send(@method).encoding
- if @fs_encoding == Encoding::US_ASCII
- [Encoding::US_ASCII, Encoding::BINARY].should include(enc)
- else
- enc.should equal(@fs_encoding)
+ with_feature :encoding do
+ it "returns a String with the filesystem encoding" do
+ enc = Dir.send(@method).encoding
+ if @fs_encoding == Encoding::US_ASCII
+ [Encoding::US_ASCII, Encoding::ASCII_8BIT].should include(enc)
+ else
+ enc.should equal(@fs_encoding)
+ end
end
end
end
diff --git a/spec/ruby/core/dir/tell_spec.rb b/spec/ruby/core/dir/tell_spec.rb
index af86dc1598..fb9848153d 100644
--- a/spec/ruby/core/dir/tell_spec.rb
+++ b/spec/ruby/core/dir/tell_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/closed'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/closed', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "Dir#tell" do
before :all do
diff --git a/spec/ruby/core/dir/to_path_spec.rb b/spec/ruby/core/dir/to_path_spec.rb
index 77404a3dc8..85609fbfff 100644
--- a/spec/ruby/core/dir/to_path_spec.rb
+++ b/spec/ruby/core/dir/to_path_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/path'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/path', __FILE__)
describe "Dir#to_path" do
before :all do
@@ -11,5 +11,5 @@ describe "Dir#to_path" do
DirSpecs.delete_mock_dirs
end
- it_behaves_like :dir_path, :to_path
+ it_behaves_like(:dir_path, :to_path)
end
diff --git a/spec/ruby/core/dir/unlink_spec.rb b/spec/ruby/core/dir/unlink_spec.rb
index 79027e020c..4459bef56c 100644
--- a/spec/ruby/core/dir/unlink_spec.rb
+++ b/spec/ruby/core/dir/unlink_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/delete'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/delete', __FILE__)
describe "Dir.unlink" do
before :all do
diff --git a/spec/ruby/core/encoding/_dump_spec.rb b/spec/ruby/core/encoding/_dump_spec.rb
index 623fe88ec9..4e8305712e 100644
--- a/spec/ruby/core/encoding/_dump_spec.rb
+++ b/spec/ruby/core/encoding/_dump_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding#_dump" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/encoding/_load_spec.rb b/spec/ruby/core/encoding/_load_spec.rb
index 608098d34b..b8cdbaa32b 100644
--- a/spec/ruby/core/encoding/_load_spec.rb
+++ b/spec/ruby/core/encoding/_load_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding._load" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/encoding/aliases_spec.rb b/spec/ruby/core/encoding/aliases_spec.rb
index 786157981a..327c8fa641 100644
--- a/spec/ruby/core/encoding/aliases_spec.rb
+++ b/spec/ruby/core/encoding/aliases_spec.rb
@@ -1,43 +1,45 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding.aliases" do
- it "returns a Hash" do
- Encoding.aliases.should be_an_instance_of(Hash)
- end
+with_feature :encoding do
+ describe "Encoding.aliases" do
+ it "returns a Hash" do
+ Encoding.aliases.should be_an_instance_of(Hash)
+ end
- it "has Strings as keys" do
- Encoding.aliases.keys.each do |key|
- key.should be_an_instance_of(String)
+ it "has Strings as keys" do
+ Encoding.aliases.keys.each do |key|
+ key.should be_an_instance_of(String)
+ end
end
- end
- it "has Strings as values" do
- Encoding.aliases.values.each do |value|
- value.should be_an_instance_of(String)
+ it "has Strings as values" do
+ Encoding.aliases.values.each do |value|
+ value.should be_an_instance_of(String)
+ end
end
- end
- it "has alias names as its keys" do
- Encoding.aliases.key?('BINARY').should be_true
- Encoding.aliases.key?('ASCII').should be_true
- end
+ it "has alias names as its keys" do
+ Encoding.aliases.key?('BINARY').should be_true
+ Encoding.aliases.key?('ASCII').should be_true
+ end
- it "has the names of the aliased encoding as its values" do
- Encoding.aliases['BINARY'].should == 'ASCII-8BIT'
- Encoding.aliases['ASCII'].should == 'US-ASCII'
- end
+ it "has the names of the aliased encoding as its values" do
+ Encoding.aliases['BINARY'].should == 'ASCII-8BIT'
+ Encoding.aliases['ASCII'].should == 'US-ASCII'
+ end
- it "has an 'external' key with the external default encoding as its value" do
- Encoding.aliases['external'].should == Encoding.default_external.name
- end
+ it "has an 'external' key with the external default encoding as its value" do
+ Encoding.aliases['external'].should == Encoding.default_external.name
+ end
- it "has a 'locale' key and its value equals the name of the encoding found by the locale charmap" do
- Encoding.aliases['locale'].should == Encoding.find(Encoding.locale_charmap).name
- end
+ it "has a 'locale' key and its value equals to the name of the encoding finded by the locale charmap" do
+ Encoding.aliases['locale'].should == Encoding.find(Encoding.locale_charmap).name
+ end
- it "only contains valid aliased encodings" do
- Encoding.aliases.each do |aliased, original|
- Encoding.find(aliased).should == Encoding.find(original)
+ it "only contains valid aliased encodings" do
+ Encoding.aliases.each do |aliased, original|
+ Encoding.find(aliased).should == Encoding.find(original)
+ end
end
end
end
diff --git a/spec/ruby/core/encoding/ascii_compatible_spec.rb b/spec/ruby/core/encoding/ascii_compatible_spec.rb
index 4804300e85..db3c31c9fb 100644
--- a/spec/ruby/core/encoding/ascii_compatible_spec.rb
+++ b/spec/ruby/core/encoding/ascii_compatible_spec.rb
@@ -1,11 +1,13 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding#ascii_compatible?" do
- it "returns true if self represents an ASCII-compatible encoding" do
- Encoding::UTF_8.ascii_compatible?.should be_true
- end
+with_feature :encoding do
+ describe "Encoding#ascii_compatible?" do
+ it "returns true if self represents an ASCII-compatible encoding" do
+ Encoding::UTF_8.ascii_compatible?.should be_true
+ end
- it "returns false if self does not represent an ASCII-compatible encoding" do
- Encoding::UTF_16LE.ascii_compatible?.should be_false
+ it "returns false if self does not represent an ASCII-compatible encoding" do
+ Encoding::UTF_16LE.ascii_compatible?.should be_false
+ end
end
end
diff --git a/spec/ruby/core/encoding/compatible_spec.rb b/spec/ruby/core/encoding/compatible_spec.rb
index dc47a6553a..55e3d0fb4d 100644
--- a/spec/ruby/core/encoding/compatible_spec.rb
+++ b/spec/ruby/core/encoding/compatible_spec.rb
@@ -1,379 +1,381 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-# TODO: add IO
+with_feature :encoding do
+ # TODO: add IO
-describe "Encoding.compatible? String, String" do
- describe "when the first's Encoding is valid US-ASCII" do
- before :each do
- @str = "abc".force_encoding Encoding::US_ASCII
- end
+ describe "Encoding.compatible? String, String" do
+ describe "when the first's Encoding is valid US-ASCII" do
+ before :each do
+ @str = "abc".force_encoding Encoding::US_ASCII
+ end
- it "returns US-ASCII when the second's is US-ASCII" do
- Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::US_ASCII
- end
+ it "returns US-ASCII when the second's is US-ASCII" do
+ Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::US_ASCII
+ end
- it "returns US-ASCII if the second String is BINARY and ASCII only" do
- Encoding.compatible?(@str, "\x7f").should == Encoding::US_ASCII
- end
+ it "returns US-ASCII if the second String is ASCII-8BIT and ASCII only" do
+ Encoding.compatible?(@str, "\x7f").should == Encoding::US_ASCII
+ end
- it "returns BINARY if the second String is BINARY but not ASCII only" do
- Encoding.compatible?(@str, "\xff").should == Encoding::BINARY
- end
+ it "returns ASCII-8BIT if the second String is ASCII-8BIT but not ASCII only" do
+ Encoding.compatible?(@str, "\xff").should == Encoding::ASCII_8BIT
+ end
- it "returns US-ASCII if the second String is UTF-8 and ASCII only" do
- Encoding.compatible?(@str, "\x7f".encode("utf-8")).should == Encoding::US_ASCII
- end
+ it "returns US-ASCII if the second String is UTF-8 and ASCII only" do
+ Encoding.compatible?(@str, "\x7f".encode("utf-8")).should == Encoding::US_ASCII
+ end
- it "returns UTF-8 if the second String is UTF-8 but not ASCII only" do
- Encoding.compatible?(@str, "\u3042".encode("utf-8")).should == Encoding::UTF_8
+ it "returns UTF-8 if the second String is UTF-8 but not ASCII only" do
+ Encoding.compatible?(@str, "\u3042".encode("utf-8")).should == Encoding::UTF_8
+ end
end
- end
- describe "when the first's Encoding is ASCII compatible and ASCII only" do
- it "returns the first's Encoding if the second is ASCII compatible and ASCII only" do
- [ [Encoding, "abc".force_encoding("UTF-8"), "123".force_encoding("Shift_JIS"), Encoding::UTF_8],
- [Encoding, "123".force_encoding("Shift_JIS"), "abc".force_encoding("UTF-8"), Encoding::Shift_JIS]
- ].should be_computed_by(:compatible?)
- end
+ describe "when the first's Encoding is ASCII compatible and ASCII only" do
+ it "returns the first's Encoding if the second is ASCII compatible and ASCII only" do
+ [ [Encoding, "abc".force_encoding("UTF-8"), "123".force_encoding("Shift_JIS"), Encoding::UTF_8],
+ [Encoding, "123".force_encoding("Shift_JIS"), "abc".force_encoding("UTF-8"), Encoding::Shift_JIS]
+ ].should be_computed_by(:compatible?)
+ end
- it "returns the first's Encoding if the second is ASCII compatible and ASCII only" do
- [ [Encoding, "abc".force_encoding("BINARY"), "123".force_encoding("US-ASCII"), Encoding::BINARY],
- [Encoding, "123".force_encoding("US-ASCII"), "abc".force_encoding("BINARY"), Encoding::US_ASCII]
- ].should be_computed_by(:compatible?)
- end
+ it "returns the first's Encoding if the second is ASCII compatible and ASCII only" do
+ [ [Encoding, "abc".force_encoding("ASCII-8BIT"), "123".force_encoding("US-ASCII"), Encoding::ASCII_8BIT],
+ [Encoding, "123".force_encoding("US-ASCII"), "abc".force_encoding("ASCII-8BIT"), Encoding::US_ASCII]
+ ].should be_computed_by(:compatible?)
+ end
- it "returns the second's Encoding if the second is ASCII compatible but not ASCII only" do
- [ [Encoding, "abc".force_encoding("UTF-8"), "\xff".force_encoding("Shift_JIS"), Encoding::Shift_JIS],
- [Encoding, "123".force_encoding("Shift_JIS"), "\xff".force_encoding("UTF-8"), Encoding::UTF_8],
- [Encoding, "abc".force_encoding("BINARY"), "\xff".force_encoding("US-ASCII"), Encoding::US_ASCII],
- [Encoding, "123".force_encoding("US-ASCII"), "\xff".force_encoding("BINARY"), Encoding::BINARY],
- ].should be_computed_by(:compatible?)
- end
+ it "returns the second's Encoding if the second is ASCII compatible but not ASCII only" do
+ [ [Encoding, "abc".force_encoding("UTF-8"), "\xff".force_encoding("Shift_JIS"), Encoding::Shift_JIS],
+ [Encoding, "123".force_encoding("Shift_JIS"), "\xff".force_encoding("UTF-8"), Encoding::UTF_8],
+ [Encoding, "abc".force_encoding("ASCII-8BIT"), "\xff".force_encoding("US-ASCII"), Encoding::US_ASCII],
+ [Encoding, "123".force_encoding("US-ASCII"), "\xff".force_encoding("ASCII-8BIT"), Encoding::ASCII_8BIT],
+ ].should be_computed_by(:compatible?)
+ end
- it "returns nil if the second's Encoding is not ASCII compatible" do
- a = "abc".force_encoding("UTF-8")
- b = "123".force_encoding("UTF-16LE")
- Encoding.compatible?(a, b).should be_nil
+ it "returns nil if the second's Encoding is not ASCII compatible" do
+ a = "abc".force_encoding("UTF-8")
+ b = "123".force_encoding("UTF-16LE")
+ Encoding.compatible?(a, b).should be_nil
+ end
end
- end
- describe "when the first's Encoding is ASCII compatible but not ASCII only" do
- it "returns the first's Encoding if the second's is valid US-ASCII" do
- Encoding.compatible?("\xff", "def".encode("us-ascii")).should == Encoding::BINARY
- end
+ describe "when the first's Encoding is ASCII compatible but not ASCII only" do
+ it "returns the first's Encoding if the second's is valid US-ASCII" do
+ Encoding.compatible?("\xff", "def".encode("us-ascii")).should == Encoding::ASCII_8BIT
+ end
- it "returns the first's Encoding if the second's is UTF-8 and ASCII only" do
- Encoding.compatible?("\xff", "\u{7f}".encode("utf-8")).should == Encoding::BINARY
- end
+ it "returns the first's Encoding if the second's is UTF-8 and ASCII only" do
+ Encoding.compatible?("\xff", "\u{7f}".encode("utf-8")).should == Encoding::ASCII_8BIT
+ end
- it "returns nil if the second encoding is ASCII compatible but neither String's encoding is ASCII only" do
- Encoding.compatible?("\xff", "\u3042".encode("utf-8")).should be_nil
+ it "returns nil if the second encoding is ASCII compatible but neither String's encoding is ASCII only" do
+ Encoding.compatible?("\xff", "\u3042".encode("utf-8")).should be_nil
+ end
end
- end
- describe "when the first's Encoding is not ASCII compatible" do
- before :each do
- @str = "abc".force_encoding Encoding::UTF_7
- end
+ describe "when the first's Encoding is not ASCII compatible" do
+ before :each do
+ @str = "abc".force_encoding Encoding::UTF_7
+ end
- it "returns nil when the second String is US-ASCII" do
- Encoding.compatible?(@str, "def".encode("us-ascii")).should be_nil
- end
+ it "returns nil when the second String is US-ASCII" do
+ Encoding.compatible?(@str, "def".encode("us-ascii")).should be_nil
+ end
- it "returns nil when the second String is BINARY and ASCII only" do
- Encoding.compatible?(@str, "\x7f").should be_nil
- end
+ it "returns nil when the second String is ASCII-8BIT and ASCII only" do
+ Encoding.compatible?(@str, "\x7f").should be_nil
+ end
- it "returns nil when the second String is BINARY but not ASCII only" do
- Encoding.compatible?(@str, "\xff").should be_nil
- end
+ it "returns nil when the second String is ASCII-8BIT but not ASCII only" do
+ Encoding.compatible?(@str, "\xff").should be_nil
+ end
- it "returns the Encoding when the second's Encoding is not ASCII compatible but the same as the first's Encoding" do
- encoding = Encoding.compatible?(@str, "def".force_encoding("utf-7"))
- encoding.should == Encoding::UTF_7
+ it "returns the Encoding when the second's Encoding is not ASCII compatible but the same as the first's Encoding" do
+ encoding = Encoding.compatible?(@str, "def".force_encoding("utf-7"))
+ encoding.should == Encoding::UTF_7
+ end
end
- end
- describe "when the first's Encoding is invalid" do
- before :each do
- @str = "\xff".force_encoding Encoding::UTF_8
- end
+ describe "when the first's Encoding is invalid" do
+ before :each do
+ @str = "\xff".force_encoding Encoding::UTF_8
+ end
- it "returns the first's Encoding when the second's Encoding is US-ASCII" do
- Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::UTF_8
- end
+ it "returns the first's Encoding when the second's Encoding is US-ASCII" do
+ Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::UTF_8
+ end
- it "returns the first's Encoding when the second String is ASCII only" do
- Encoding.compatible?(@str, "\x7f").should == Encoding::UTF_8
- end
+ it "returns the first's Encoding when the second String is ASCII only" do
+ Encoding.compatible?(@str, "\x7f").should == Encoding::UTF_8
+ end
- it "returns nil when the second's Encoding is BINARY but not ASCII only" do
- Encoding.compatible?(@str, "\xff").should be_nil
- end
+ it "returns nil when the second's Encoding is ASCII-8BIT but not ASCII only" do
+ Encoding.compatible?(@str, "\xff").should be_nil
+ end
- it "returns nil when the second's Encoding is invalid and ASCII only" do
- Encoding.compatible?(@str, "\x7f".force_encoding("utf-16be")).should be_nil
- end
+ it "returns nil when the second's Encoding is invalid and ASCII only" do
+ Encoding.compatible?(@str, "\x7f".force_encoding("utf-16be")).should be_nil
+ end
- it "returns nil when the second's Encoding is invalid and not ASCII only" do
- Encoding.compatible?(@str, "\xff".force_encoding("utf-16be")).should be_nil
- end
+ it "returns nil when the second's Encoding is invalid and not ASCII only" do
+ Encoding.compatible?(@str, "\xff".force_encoding("utf-16be")).should be_nil
+ end
- it "returns the Encoding when the second's Encoding is invalid but the same as the first" do
- Encoding.compatible?(@str, @str).should == Encoding::UTF_8
+ it "returns the Encoding when the second's Encoding is invalid but the same as the first" do
+ Encoding.compatible?(@str, @str).should == Encoding::UTF_8
+ end
end
- end
- describe "when the first String is empty and the second is not" do
- describe "and the first's Encoding is ASCII compatible" do
- before :each do
- @str = "".force_encoding("utf-8")
- end
+ describe "when the first String is empty and the second is not" do
+ describe "and the first's Encoding is ASCII compatible" do
+ before :each do
+ @str = "".force_encoding("utf-8")
+ end
- it "returns the first's encoding when the second String is ASCII only" do
- Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::UTF_8
+ it "returns the first's encoding when the second String is ASCII only" do
+ Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::UTF_8
+ end
+
+ it "returns the second's encoding when the second String is not ASCII only" do
+ Encoding.compatible?(@str, "def".encode("utf-32le")).should == Encoding::UTF_32LE
+ end
end
- it "returns the second's encoding when the second String is not ASCII only" do
- Encoding.compatible?(@str, "def".encode("utf-32le")).should == Encoding::UTF_32LE
+ describe "when the first's Encoding is not ASCII compatible" do
+ before :each do
+ @str = "".force_encoding Encoding::UTF_7
+ end
+
+ it "returns the second string's encoding" do
+ Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::US_ASCII
+ end
end
end
- describe "when the first's Encoding is not ASCII compatible" do
+ describe "when the second String is empty" do
before :each do
- @str = "".force_encoding Encoding::UTF_7
+ @str = "abc".force_encoding("utf-7")
end
- it "returns the second string's encoding" do
- Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::US_ASCII
+ it "returns the first Encoding" do
+ Encoding.compatible?(@str, "").should == Encoding::UTF_7
end
end
end
- describe "when the second String is empty" do
- before :each do
- @str = "abc".force_encoding("utf-7")
+ describe "Encoding.compatible? String, Regexp" do
+ it "returns US-ASCII if both are US-ASCII" do
+ str = "abc".force_encoding("us-ascii")
+ Encoding.compatible?(str, /abc/).should == Encoding::US_ASCII
end
- it "returns the first Encoding" do
- Encoding.compatible?(@str, "").should == Encoding::UTF_7
+ it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do
+ [ [Encoding, "abc", Encoding::ASCII_8BIT],
+ [Encoding, "abc".encode("utf-8"), Encoding::UTF_8],
+ [Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP],
+ [Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, /abc/)
end
- end
-end
-describe "Encoding.compatible? String, Regexp" do
- it "returns US-ASCII if both are US-ASCII" do
- str = "abc".force_encoding("us-ascii")
- Encoding.compatible?(str, /abc/).should == Encoding::US_ASCII
+ it "returns the String's Encoding if the String is not ASCII only" do
+ [ [Encoding, "\xff", Encoding::ASCII_8BIT],
+ [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
+ [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
+ [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, /abc/)
+ end
end
- it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do
- [ [Encoding, "abc", Encoding::BINARY],
- [Encoding, "abc".encode("utf-8"), Encoding::UTF_8],
- [Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP],
- [Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, /abc/)
- end
+ describe "Encoding.compatible? String, Symbol" do
+ it "returns US-ASCII if both are ASCII only" do
+ str = "abc".force_encoding("us-ascii")
+ Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
+ end
- it "returns the String's Encoding if the String is not ASCII only" do
- [ [Encoding, "\xff", Encoding::BINARY],
- [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
- [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
- [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, /abc/)
- end
-end
+ it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do
+ [ [Encoding, "abc", Encoding::ASCII_8BIT],
+ [Encoding, "abc".encode("utf-8"), Encoding::UTF_8],
+ [Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP],
+ [Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, :abc)
+ end
-describe "Encoding.compatible? String, Symbol" do
- it "returns US-ASCII if both are ASCII only" do
- str = "abc".force_encoding("us-ascii")
- Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
+ it "returns the String's Encoding if the String is not ASCII only" do
+ [ [Encoding, "\xff", Encoding::ASCII_8BIT],
+ [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
+ [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
+ [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, :abc)
+ end
end
- it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do
- [ [Encoding, "abc", Encoding::BINARY],
- [Encoding, "abc".encode("utf-8"), Encoding::UTF_8],
- [Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP],
- [Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, :abc)
- end
+ describe "Encoding.compatible? String, Encoding" do
+ it "returns nil if the String's encoding is not ASCII compatible" do
+ Encoding.compatible?("abc".encode("utf-32le"), Encoding::US_ASCII).should be_nil
+ end
- it "returns the String's Encoding if the String is not ASCII only" do
- [ [Encoding, "\xff", Encoding::BINARY],
- [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
- [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
- [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, :abc)
- end
-end
+ it "returns nil if the Encoding is not ASCII compatible" do
+ Encoding.compatible?("abc".encode("us-ascii"), Encoding::UTF_32LE).should be_nil
+ end
-describe "Encoding.compatible? String, Encoding" do
- it "returns nil if the String's encoding is not ASCII compatible" do
- Encoding.compatible?("abc".encode("utf-32le"), Encoding::US_ASCII).should be_nil
- end
+ it "returns the String's encoding if the Encoding is US-ASCII" do
+ [ [Encoding, "\xff", Encoding::ASCII_8BIT],
+ [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
+ [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
+ [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, Encoding::US_ASCII)
+ end
- it "returns nil if the Encoding is not ASCII compatible" do
- Encoding.compatible?("abc".encode("us-ascii"), Encoding::UTF_32LE).should be_nil
- end
+ it "returns the Encoding if the String's encoding is ASCII compatible and the String is ASCII only" do
+ str = "abc".encode("utf-8")
- it "returns the String's encoding if the Encoding is US-ASCII" do
- [ [Encoding, "\xff", Encoding::BINARY],
- [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
- [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
- [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, Encoding::US_ASCII)
- end
-
- it "returns the Encoding if the String's encoding is ASCII compatible and the String is ASCII only" do
- str = "abc".encode("utf-8")
+ Encoding.compatible?(str, Encoding::ASCII_8BIT).should == Encoding::ASCII_8BIT
+ Encoding.compatible?(str, Encoding::UTF_8).should == Encoding::UTF_8
+ Encoding.compatible?(str, Encoding::EUC_JP).should == Encoding::EUC_JP
+ Encoding.compatible?(str, Encoding::Shift_JIS).should == Encoding::Shift_JIS
+ end
- Encoding.compatible?(str, Encoding::BINARY).should == Encoding::BINARY
- Encoding.compatible?(str, Encoding::UTF_8).should == Encoding::UTF_8
- Encoding.compatible?(str, Encoding::EUC_JP).should == Encoding::EUC_JP
- Encoding.compatible?(str, Encoding::Shift_JIS).should == Encoding::Shift_JIS
+ it "returns nil if the String's encoding is ASCII compatible but the string is not ASCII only" do
+ Encoding.compatible?("\u3042".encode("utf-8"), Encoding::ASCII_8BIT).should be_nil
+ end
end
- it "returns nil if the String's encoding is ASCII compatible but the string is not ASCII only" do
- Encoding.compatible?("\u3042".encode("utf-8"), Encoding::BINARY).should be_nil
- end
-end
+ describe "Encoding.compatible? Regexp, String" do
+ it "returns US-ASCII if both are US-ASCII" do
+ str = "abc".force_encoding("us-ascii")
+ Encoding.compatible?(/abc/, str).should == Encoding::US_ASCII
+ end
-describe "Encoding.compatible? Regexp, String" do
- it "returns US-ASCII if both are US-ASCII" do
- str = "abc".force_encoding("us-ascii")
- Encoding.compatible?(/abc/, str).should == Encoding::US_ASCII
end
-end
+ describe "Encoding.compatible? Regexp, Regexp" do
+ it "returns US-ASCII if both are US-ASCII" do
+ Encoding.compatible?(/abc/, /def/).should == Encoding::US_ASCII
+ end
-describe "Encoding.compatible? Regexp, Regexp" do
- it "returns US-ASCII if both are US-ASCII" do
- Encoding.compatible?(/abc/, /def/).should == Encoding::US_ASCII
+ it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do
+ [ [Encoding, Regexp.new("\xff"), Encoding::ASCII_8BIT],
+ [Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8],
+ [Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP],
+ [Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, /abc/)
+ end
end
- it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do
- [ [Encoding, Regexp.new("\xff"), Encoding::BINARY],
- [Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8],
- [Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP],
- [Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, /abc/)
- end
-end
+ describe "Encoding.compatible? Regexp, Symbol" do
+ it "returns US-ASCII if both are US-ASCII" do
+ Encoding.compatible?(/abc/, :def).should == Encoding::US_ASCII
+ end
-describe "Encoding.compatible? Regexp, Symbol" do
- it "returns US-ASCII if both are US-ASCII" do
- Encoding.compatible?(/abc/, :def).should == Encoding::US_ASCII
+ it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do
+ [ [Encoding, Regexp.new("\xff"), Encoding::ASCII_8BIT],
+ [Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8],
+ [Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP],
+ [Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, /abc/)
+ end
end
- it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do
- [ [Encoding, Regexp.new("\xff"), Encoding::BINARY],
- [Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8],
- [Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP],
- [Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, /abc/)
+ describe "Encoding.compatible? Symbol, String" do
+ it "returns US-ASCII if both are ASCII only" do
+ str = "abc".force_encoding("us-ascii")
+ Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
+ end
end
-end
-describe "Encoding.compatible? Symbol, String" do
- it "returns US-ASCII if both are ASCII only" do
- str = "abc".force_encoding("us-ascii")
- Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
- end
-end
+ describe "Encoding.compatible? Symbol, Regexp" do
+ it "returns US-ASCII if both are US-ASCII" do
+ Encoding.compatible?(:abc, /def/).should == Encoding::US_ASCII
+ end
-describe "Encoding.compatible? Symbol, Regexp" do
- it "returns US-ASCII if both are US-ASCII" do
- Encoding.compatible?(:abc, /def/).should == Encoding::US_ASCII
- end
+ it "returns the Regexp's Encoding if it is not US-ASCII and not ASCII only" do
+ a = Regexp.new("\xff")
+ b = Regexp.new("\u3042".encode("utf-8"))
+ c = Regexp.new("\xa4\xa2".force_encoding("euc-jp"))
+ d = Regexp.new("\x82\xa0".force_encoding("shift_jis"))
- it "returns the Regexp's Encoding if it is not US-ASCII and not ASCII only" do
- a = Regexp.new("\xff")
- b = Regexp.new("\u3042".encode("utf-8"))
- c = Regexp.new("\xa4\xa2".force_encoding("euc-jp"))
- d = Regexp.new("\x82\xa0".force_encoding("shift_jis"))
-
- [ [Encoding, :abc, a, Encoding::BINARY],
- [Encoding, :abc, b, Encoding::UTF_8],
- [Encoding, :abc, c, Encoding::EUC_JP],
- [Encoding, :abc, d, Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?)
+ [ [Encoding, :abc, a, Encoding::ASCII_8BIT],
+ [Encoding, :abc, b, Encoding::UTF_8],
+ [Encoding, :abc, c, Encoding::EUC_JP],
+ [Encoding, :abc, d, Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?)
+ end
end
-end
-describe "Encoding.compatible? Symbol, Symbol" do
- it "returns US-ASCII if both are US-ASCII" do
- Encoding.compatible?(:abc, :def).should == Encoding::US_ASCII
- end
+ describe "Encoding.compatible? Symbol, Symbol" do
+ it "returns US-ASCII if both are US-ASCII" do
+ Encoding.compatible?(:abc, :def).should == Encoding::US_ASCII
+ end
- it "returns the first's Encoding if it is not ASCII only" do
- [ [Encoding, "\xff".to_sym, Encoding::BINARY],
- [Encoding, "\u3042".encode("utf-8").to_sym, Encoding::UTF_8],
- [Encoding, "\xa4\xa2".force_encoding("euc-jp").to_sym, Encoding::EUC_JP],
- [Encoding, "\x82\xa0".force_encoding("shift_jis").to_sym, Encoding::Shift_JIS],
- ].should be_computed_by(:compatible?, :abc)
+ it "returns the first's Encoding if it is not ASCII only" do
+ [ [Encoding, "\xff".to_sym, Encoding::ASCII_8BIT],
+ [Encoding, "\u3042".encode("utf-8").to_sym, Encoding::UTF_8],
+ [Encoding, "\xa4\xa2".force_encoding("euc-jp").to_sym, Encoding::EUC_JP],
+ [Encoding, "\x82\xa0".force_encoding("shift_jis").to_sym, Encoding::Shift_JIS],
+ ].should be_computed_by(:compatible?, :abc)
+ end
end
-end
-describe "Encoding.compatible? Encoding, Encoding" do
- it "returns nil if one of the encodings is a dummy encoding" do
- [ [Encoding, Encoding::UTF_7, Encoding::US_ASCII, nil],
- [Encoding, Encoding::US_ASCII, Encoding::UTF_7, nil],
- [Encoding, Encoding::EUC_JP, Encoding::UTF_7, nil],
- [Encoding, Encoding::UTF_7, Encoding::EUC_JP, nil],
- [Encoding, Encoding::UTF_7, Encoding::BINARY, nil],
- [Encoding, Encoding::BINARY, Encoding::UTF_7, nil],
- ].should be_computed_by(:compatible?)
- end
+ describe "Encoding.compatible? Encoding, Encoding" do
+ it "returns nil if one of the encodings is a dummy encoding" do
+ [ [Encoding, Encoding::UTF_7, Encoding::US_ASCII, nil],
+ [Encoding, Encoding::US_ASCII, Encoding::UTF_7, nil],
+ [Encoding, Encoding::EUC_JP, Encoding::UTF_7, nil],
+ [Encoding, Encoding::UTF_7, Encoding::EUC_JP, nil],
+ [Encoding, Encoding::UTF_7, Encoding::ASCII_8BIT, nil],
+ [Encoding, Encoding::ASCII_8BIT, Encoding::UTF_7, nil],
+ ].should be_computed_by(:compatible?)
+ end
- it "returns nil if one of the encodings is not US-ASCII" do
- [ [Encoding, Encoding::UTF_8, Encoding::BINARY, nil],
- [Encoding, Encoding::BINARY, Encoding::UTF_8, nil],
- [Encoding, Encoding::BINARY, Encoding::EUC_JP, nil],
- [Encoding, Encoding::Shift_JIS, Encoding::EUC_JP, nil],
- ].should be_computed_by(:compatible?)
- end
+ it "returns nil if one of the encodings is not US-ASCII" do
+ [ [Encoding, Encoding::UTF_8, Encoding::ASCII_8BIT, nil],
+ [Encoding, Encoding::ASCII_8BIT, Encoding::UTF_8, nil],
+ [Encoding, Encoding::ASCII_8BIT, Encoding::EUC_JP, nil],
+ [Encoding, Encoding::Shift_JIS, Encoding::EUC_JP, nil],
+ ].should be_computed_by(:compatible?)
+ end
- it "returns the first if the second is US-ASCII" do
- [ [Encoding, Encoding::UTF_8, Encoding::US_ASCII, Encoding::UTF_8],
- [Encoding, Encoding::EUC_JP, Encoding::US_ASCII, Encoding::EUC_JP],
- [Encoding, Encoding::Shift_JIS, Encoding::US_ASCII, Encoding::Shift_JIS],
- [Encoding, Encoding::BINARY, Encoding::US_ASCII, Encoding::BINARY],
- ].should be_computed_by(:compatible?)
- end
+ it "returns the first if the second is US-ASCII" do
+ [ [Encoding, Encoding::UTF_8, Encoding::US_ASCII, Encoding::UTF_8],
+ [Encoding, Encoding::EUC_JP, Encoding::US_ASCII, Encoding::EUC_JP],
+ [Encoding, Encoding::Shift_JIS, Encoding::US_ASCII, Encoding::Shift_JIS],
+ [Encoding, Encoding::ASCII_8BIT, Encoding::US_ASCII, Encoding::ASCII_8BIT],
+ ].should be_computed_by(:compatible?)
+ end
- it "returns the Encoding if both are the same" do
- [ [Encoding, Encoding::UTF_8, Encoding::UTF_8, Encoding::UTF_8],
- [Encoding, Encoding::US_ASCII, Encoding::US_ASCII, Encoding::US_ASCII],
- [Encoding, Encoding::BINARY, Encoding::BINARY, Encoding::BINARY],
- [Encoding, Encoding::UTF_7, Encoding::UTF_7, Encoding::UTF_7],
- ].should be_computed_by(:compatible?)
+ it "returns the Encoding if both are the same" do
+ [ [Encoding, Encoding::UTF_8, Encoding::UTF_8, Encoding::UTF_8],
+ [Encoding, Encoding::US_ASCII, Encoding::US_ASCII, Encoding::US_ASCII],
+ [Encoding, Encoding::ASCII_8BIT, Encoding::ASCII_8BIT, Encoding::ASCII_8BIT],
+ [Encoding, Encoding::UTF_7, Encoding::UTF_7, Encoding::UTF_7],
+ ].should be_computed_by(:compatible?)
+ end
end
-end
-describe "Encoding.compatible? Object, Object" do
- it "returns nil for Object, String" do
- Encoding.compatible?(Object.new, "abc").should be_nil
- end
+ describe "Encoding.compatible? Object, Object" do
+ it "returns nil for Object, String" do
+ Encoding.compatible?(Object.new, "abc").should be_nil
+ end
- it "returns nil for Object, Regexp" do
- Encoding.compatible?(Object.new, /./).should be_nil
- end
+ it "returns nil for Object, Regexp" do
+ Encoding.compatible?(Object.new, /./).should be_nil
+ end
- it "returns nil for Object, Symbol" do
- Encoding.compatible?(Object.new, :sym).should be_nil
- end
+ it "returns nil for Object, Symbol" do
+ Encoding.compatible?(Object.new, :sym).should be_nil
+ end
- it "returns nil for String, Object" do
- Encoding.compatible?("abc", Object.new).should be_nil
- end
+ it "returns nil for String, Object" do
+ Encoding.compatible?("abc", Object.new).should be_nil
+ end
- it "returns nil for Regexp, Object" do
- Encoding.compatible?(/./, Object.new).should be_nil
- end
+ it "returns nil for Regexp, Object" do
+ Encoding.compatible?(/./, Object.new).should be_nil
+ end
- it "returns nil for Symbol, Object" do
- Encoding.compatible?(:sym, Object.new).should be_nil
+ it "returns nil for Symbol, Object" do
+ Encoding.compatible?(:sym, Object.new).should be_nil
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb b/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb
index 1beb40af3f..329e09cade 100644
--- a/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb
+++ b/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb
@@ -1,37 +1,39 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter.asciicompat_encoding" do
- it "accepts an encoding name as a String argument" do
- -> { Encoding::Converter.asciicompat_encoding('UTF-8') }.
- should_not raise_error
- end
+with_feature :encoding do
+ describe "Encoding::Converter.asciicompat_encoding" do
+ it "accepts an encoding name as a String argument" do
+ lambda { Encoding::Converter.asciicompat_encoding('UTF-8') }.
+ should_not raise_error
+ end
- it "coerces non-String/Encoding objects with #to_str" do
- str = mock('string')
- str.should_receive(:to_str).at_least(1).times.and_return('string')
- Encoding::Converter.asciicompat_encoding(str)
- end
+ it "coerces non-String/Encoding objects with #to_str" do
+ str = mock('string')
+ str.should_receive(:to_str).at_least(1).times.and_return('string')
+ Encoding::Converter.asciicompat_encoding(str)
+ end
- it "accepts an Encoding object as an argument" do
- Encoding::Converter.
- asciicompat_encoding(Encoding.find("ISO-2022-JP")).
- should == Encoding::Converter.asciicompat_encoding("ISO-2022-JP")
- end
+ it "accepts an Encoding object as an argument" do
+ Encoding::Converter.
+ asciicompat_encoding(Encoding.find("ISO-2022-JP")).
+ should == Encoding::Converter.asciicompat_encoding("ISO-2022-JP")
+ end
- it "returns a corresponding ASCII compatible encoding for ASCII-incompatible encodings" do
- Encoding::Converter.asciicompat_encoding('UTF-16BE').should == Encoding::UTF_8
- Encoding::Converter.asciicompat_encoding("ISO-2022-JP").should == Encoding.find("stateless-ISO-2022-JP")
- end
+ it "returns a corresponding ASCII compatible encoding for ASCII-incompatible encodings" do
+ Encoding::Converter.asciicompat_encoding('UTF-16BE').should == Encoding::UTF_8
+ Encoding::Converter.asciicompat_encoding("ISO-2022-JP").should == Encoding.find("stateless-ISO-2022-JP")
+ end
- it "returns nil when the given encoding is ASCII compatible" do
- Encoding::Converter.asciicompat_encoding('ASCII').should be_nil
- Encoding::Converter.asciicompat_encoding('UTF-8').should be_nil
- end
+ it "returns nil when the given encoding is ASCII compatible" do
+ Encoding::Converter.asciicompat_encoding('ASCII').should be_nil
+ Encoding::Converter.asciicompat_encoding('UTF-8').should be_nil
+ end
- it "handles encoding names who resolve to nil encodings" do
- internal = Encoding.default_internal
- Encoding.default_internal = nil
- Encoding::Converter.asciicompat_encoding('internal').should be_nil
- Encoding.default_internal = internal
+ it "handles encoding names who resolve to nil encodings" do
+ internal = Encoding.default_internal
+ Encoding.default_internal = nil
+ Encoding::Converter.asciicompat_encoding('internal').should be_nil
+ Encoding.default_internal = internal
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/constants_spec.rb b/spec/ruby/core/encoding/converter/constants_spec.rb
index 57b6a4d4e7..16eb60b4ab 100644
--- a/spec/ruby/core/encoding/converter/constants_spec.rb
+++ b/spec/ruby/core/encoding/converter/constants_spec.rb
@@ -1,131 +1,133 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter::INVALID_MASK" do
- it "exists" do
- Encoding::Converter.should have_constant(:INVALID_MASK)
- end
+with_feature :encoding do
+ describe "Encoding::Converter::INVALID_MASK" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:INVALID_MASK)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::INVALID_MASK.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::INVALID_MASK.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::INVALID_REPLACE" do
- it "exists" do
- Encoding::Converter.should have_constant(:INVALID_REPLACE)
- end
+ describe "Encoding::Converter::INVALID_REPLACE" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:INVALID_REPLACE)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::INVALID_REPLACE.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::INVALID_REPLACE.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::UNDEF_MASK" do
- it "exists" do
- Encoding::Converter.should have_constant(:UNDEF_MASK)
- end
+ describe "Encoding::Converter::UNDEF_MASK" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:UNDEF_MASK)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::UNDEF_MASK.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::UNDEF_MASK.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::UNDEF_REPLACE" do
- it "exists" do
- Encoding::Converter.should have_constant(:UNDEF_REPLACE)
- end
+ describe "Encoding::Converter::UNDEF_REPLACE" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:UNDEF_REPLACE)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::UNDEF_REPLACE.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::UNDEF_REPLACE.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::UNDEF_HEX_CHARREF" do
- it "exists" do
- Encoding::Converter.should have_constant(:UNDEF_HEX_CHARREF)
- end
+ describe "Encoding::Converter::UNDEF_HEX_CHARREF" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:UNDEF_HEX_CHARREF)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::UNDEF_HEX_CHARREF.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::UNDEF_HEX_CHARREF.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::PARTIAL_INPUT" do
- it "exists" do
- Encoding::Converter.should have_constant(:PARTIAL_INPUT)
- end
+ describe "Encoding::Converter::PARTIAL_INPUT" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:PARTIAL_INPUT)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::PARTIAL_INPUT.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::PARTIAL_INPUT.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::AFTER_OUTPUT" do
- it "exists" do
- Encoding::Converter.should have_constant(:AFTER_OUTPUT)
- end
+ describe "Encoding::Converter::AFTER_OUTPUT" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:AFTER_OUTPUT)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::AFTER_OUTPUT.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::AFTER_OUTPUT.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR" do
- it "exists" do
- Encoding::Converter.should have_constant(:UNIVERSAL_NEWLINE_DECORATOR)
- end
+ describe "Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:UNIVERSAL_NEWLINE_DECORATOR)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::CRLF_NEWLINE_DECORATOR" do
- it "exists" do
- Encoding::Converter.should have_constant(:CRLF_NEWLINE_DECORATOR)
- end
+ describe "Encoding::Converter::CRLF_NEWLINE_DECORATOR" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:CRLF_NEWLINE_DECORATOR)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::CRLF_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::CRLF_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::CR_NEWLINE_DECORATOR" do
- it "exists" do
- Encoding::Converter.should have_constant(:CR_NEWLINE_DECORATOR)
- end
+ describe "Encoding::Converter::CR_NEWLINE_DECORATOR" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:CR_NEWLINE_DECORATOR)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::CR_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::CR_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::XML_TEXT_DECORATOR" do
- it "exists" do
- Encoding::Converter.should have_constant(:XML_TEXT_DECORATOR)
- end
+ describe "Encoding::Converter::XML_TEXT_DECORATOR" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:XML_TEXT_DECORATOR)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::XML_TEXT_DECORATOR.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::XML_TEXT_DECORATOR.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::XML_ATTR_CONTENT_DECORATOR" do
- it "exists" do
- Encoding::Converter.should have_constant(:XML_ATTR_CONTENT_DECORATOR)
- end
+ describe "Encoding::Converter::XML_ATTR_CONTENT_DECORATOR" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:XML_ATTR_CONTENT_DECORATOR)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::XML_ATTR_CONTENT_DECORATOR.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::XML_ATTR_CONTENT_DECORATOR.should be_an_instance_of(Fixnum)
+ end
end
-end
-describe "Encoding::Converter::XML_ATTR_QUOTE_DECORATOR" do
- it "exists" do
- Encoding::Converter.should have_constant(:XML_ATTR_QUOTE_DECORATOR)
- end
+ describe "Encoding::Converter::XML_ATTR_QUOTE_DECORATOR" do
+ it "exists" do
+ Encoding::Converter.should have_constant(:XML_ATTR_QUOTE_DECORATOR)
+ end
- it "has a Fixnum value" do
- Encoding::Converter::XML_ATTR_QUOTE_DECORATOR.should be_an_instance_of(Fixnum)
+ it "has a Fixnum value" do
+ Encoding::Converter::XML_ATTR_QUOTE_DECORATOR.should be_an_instance_of(Fixnum)
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/convert_spec.rb b/spec/ruby/core/encoding/converter/convert_spec.rb
index 95a9e0b758..588d659ceb 100644
--- a/spec/ruby/core/encoding/converter/convert_spec.rb
+++ b/spec/ruby/core/encoding/converter/convert_spec.rb
@@ -1,45 +1,47 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#convert" do
- it "returns a String" do
- ec = Encoding::Converter.new('ascii', 'utf-8')
- ec.convert('glark').should be_an_instance_of(String)
- end
+with_feature :encoding do
+ describe "Encoding::Converter#convert" do
+ it "returns a String" do
+ ec = Encoding::Converter.new('ascii', 'utf-8')
+ ec.convert('glark').should be_an_instance_of(String)
+ end
- it "sets the encoding of the result to the target encoding" do
- ec = Encoding::Converter.new('ascii', 'utf-8')
- str = 'glark'.force_encoding('ascii')
- ec.convert(str).encoding.should == Encoding::UTF_8
- end
+ it "sets the encoding of the result to the target encoding" do
+ ec = Encoding::Converter.new('ascii', 'utf-8')
+ str = 'glark'.force_encoding('ascii')
+ ec.convert(str).encoding.should == Encoding::UTF_8
+ end
- it "transcodes the given String to the target encoding" do
- ec = Encoding::Converter.new("utf-8", "euc-jp")
- ec.convert("\u3042".force_encoding('UTF-8')).should == \
- "\xA4\xA2".force_encoding('EUC-JP')
- end
+ it "transcodes the given String to the target encoding" do
+ ec = Encoding::Converter.new("utf-8", "euc-jp")
+ ec.convert("\u3042".force_encoding('UTF-8')).should == \
+ "\xA4\xA2".force_encoding('EUC-JP')
+ end
- it "allows Strings of different encodings to the source encoding" do
- ec = Encoding::Converter.new('ascii', 'utf-8')
- str = 'glark'.force_encoding('SJIS')
- ec.convert(str).encoding.should == Encoding::UTF_8
- end
+ it "allows Strings of different encodings to the source encoding" do
+ ec = Encoding::Converter.new('ascii', 'utf-8')
+ str = 'glark'.force_encoding('SJIS')
+ ec.convert(str).encoding.should == Encoding::UTF_8
+ end
- it "reuses the given encoding pair if called multiple times" do
- ec = Encoding::Converter.new('ascii', 'SJIS')
- ec.convert('a'.force_encoding('ASCII')).should == 'a'.force_encoding('SJIS')
- ec.convert('b'.force_encoding('ASCII')).should == 'b'.force_encoding('SJIS')
- end
+ it "reuses the given encoding pair if called multiple times" do
+ ec = Encoding::Converter.new('ascii', 'SJIS')
+ ec.convert('a'.force_encoding('ASCII')).should == 'a'.force_encoding('SJIS')
+ ec.convert('b'.force_encoding('ASCII')).should == 'b'.force_encoding('SJIS')
+ end
- it "raises UndefinedConversionError if the String contains characters invalid for the target encoding" do
- ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic'))
- -> { ec.convert("\u{6543}".force_encoding('UTF-8')) }.should \
- raise_error(Encoding::UndefinedConversionError)
- end
+ it "raises UndefinedConversionError if the String contains characters invalid for the target encoding" do
+ ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic'))
+ lambda { ec.convert("\u{6543}".force_encoding('UTF-8')) }.should \
+ raise_error(Encoding::UndefinedConversionError)
+ end
- it "raises an ArgumentError if called on a finished stream" do
- ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic'))
- ec.finish
- -> { ec.convert("\u{65}") }.should raise_error(ArgumentError)
+ it "raises an ArgumentError if called on a finished stream" do
+ ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic'))
+ ec.finish
+ lambda { ec.convert("\u{65}") }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/convpath_spec.rb b/spec/ruby/core/encoding/converter/convpath_spec.rb
index 23f1e5dc33..679b894f58 100644
--- a/spec/ruby/core/encoding/converter/convpath_spec.rb
+++ b/spec/ruby/core/encoding/converter/convpath_spec.rb
@@ -1,24 +1,65 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#convpath" do
- it "returns an Array with a single element if there is a direct converter" do
- cp = Encoding::Converter.new('ASCII', 'UTF-8').convpath
- cp.should == [[Encoding::US_ASCII, Encoding::UTF_8]]
- end
+with_feature :encoding do
+ describe "Encoding::Converter#convpath" do
+ before :all do
+ @perms = Encoding.name_list.permutation(2).map do |pair|
+ Encoding::Converter.new(pair.first, pair.last) rescue nil
+ end.compact.map{|ec| ec.convpath}
+ end
- it "returns multiple encoding pairs when direct conversion is impossible" do
- cp = Encoding::Converter.new('ascii','Big5').convpath
- cp.should == [
- [Encoding::US_ASCII, Encoding::UTF_8],
- [Encoding::UTF_8, Encoding::Big5]
- ]
- end
+ it "returns an Array" do
+ ec = Encoding::Converter.new('ASCII', 'EUC-JP')
+ ec.convpath.should be_an_instance_of(Array)
+ end
+
+ it "returns each encoding pair as a sub-Array" do
+ ec = Encoding::Converter.new('ASCII', 'EUC-JP')
+ ec.convpath.first.should be_an_instance_of(Array)
+ ec.convpath.first.size.should == 2
+ end
+
+ it "returns each encoding as an Encoding object" do
+ ec = Encoding::Converter.new('ASCII', 'EUC-JP')
+ ec.convpath.first.first.should be_an_instance_of(Encoding)
+ ec.convpath.first.last.should be_an_instance_of(Encoding)
+ end
+
+ it "returns multiple encoding pairs when direct conversion is impossible" do
+ ec = Encoding::Converter.new('ascii','Big5')
+ ec.convpath.size.should == 2
+ ec.convpath.first.first.should == Encoding::US_ASCII
+ ec.convpath.first.last.should == ec.convpath.last.first
+ ec.convpath.last.last.should == Encoding::Big5
+ end
+
+ it "sets the last element of each pair to the first element of the next" do
+ @perms.each do |convpath|
+ next if convpath.size == 1
+ convpath.each_with_index do |pair, idx|
+ break if idx == convpath.size - 1
+ pair.last.should == convpath[idx+1].first
+ end
+ end
+ end
+
+ it "only lists a source encoding once" do
+ @perms.each do |convpath|
+ next if convpath.size < 2
+ seen = Hash.new(false)
+ convpath.each_with_index do |pair, idx|
+ seen.key?(pair.first).should be_false if idx > 0
+ seen[pair.first] = true
+ end
+ end
+ end
- it "indicates if crlf_newline conversion would occur" do
- ec = Encoding::Converter.new("ISo-8859-1", "EUC-JP", crlf_newline: true)
- ec.convpath.last.should == "crlf_newline"
+ it "indicates if crlf_newline conversion would occur" do
+ ec = Encoding::Converter.new("ISo-8859-1", "EUC-JP", {crlf_newline: true})
+ ec.convpath.last.should == "crlf_newline"
- ec = Encoding::Converter.new("ASCII", "UTF-8", crlf_newline: false)
- ec.convpath.last.should_not == "crlf_newline"
+ ec = Encoding::Converter.new("ASCII", "UTF-8", {crlf_newline: false})
+ ec.convpath.last.should_not == "crlf_newline"
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/destination_encoding_spec.rb b/spec/ruby/core/encoding/converter/destination_encoding_spec.rb
index 481a857909..830e6d2178 100644
--- a/spec/ruby/core/encoding/converter/destination_encoding_spec.rb
+++ b/spec/ruby/core/encoding/converter/destination_encoding_spec.rb
@@ -1,11 +1,13 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#destination_encoding" do
- it "returns the destination encoding as an Encoding object" do
- ec = Encoding::Converter.new('ASCII','Big5')
- ec.destination_encoding.should == Encoding::BIG5
+with_feature :encoding do
+ describe "Encoding::Converter#destination_encoding" do
+ it "returns the destination encoding as an Encoding object" do
+ ec = Encoding::Converter.new('ASCII','Big5')
+ ec.destination_encoding.should == Encoding::BIG5
- ec = Encoding::Converter.new('SJIS','EUC-JP')
- ec.destination_encoding.should == Encoding::EUC_JP
+ ec = Encoding::Converter.new('SJIS','EUC-JP')
+ ec.destination_encoding.should == Encoding::EUC_JP
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/finish_spec.rb b/spec/ruby/core/encoding/converter/finish_spec.rb
index 11ca7e8510..86097357f4 100644
--- a/spec/ruby/core/encoding/converter/finish_spec.rb
+++ b/spec/ruby/core/encoding/converter/finish_spec.rb
@@ -1,36 +1,38 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#finish" do
- before :each do
- @ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
- end
+with_feature :encoding do
+ describe "Encoding::Converter#finish" do
+ before :each do
+ @ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
+ end
- it "returns a String" do
- @ec.convert('foo')
- @ec.finish.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @ec.convert('foo')
+ @ec.finish.should be_an_instance_of(String)
+ end
- it "returns an empty String if there is nothing more to convert" do
- @ec.convert("glark")
- @ec.finish.should == ""
- end
+ it "returns an empty String if there is nothing more to convert" do
+ @ec.convert("glark")
+ @ec.finish.should == ""
+ end
- it "returns the last part of the converted String if it hasn't already" do
- @ec.convert("\u{9999}").should == "\e$B9a".force_encoding('iso-2022-jp')
- @ec.finish.should == "\e(B".force_encoding('iso-2022-jp')
- end
+ it "returns the last part of the converted String if it hasn't already" do
+ @ec.convert("\u{9999}").should == "\e$B9a".force_encoding('iso-2022-jp')
+ @ec.finish.should == "\e(B".force_encoding('iso-2022-jp')
+ end
- it "returns a String in the destination encoding" do
- @ec.convert("glark")
- @ec.finish.encoding.should == Encoding::ISO2022_JP
- end
+ it "returns a String in the destination encoding" do
+ @ec.convert("glark")
+ @ec.finish.encoding.should == Encoding::ISO2022_JP
+ end
- it "returns an empty String if self was not given anything to convert" do
- @ec.finish.should == ""
- end
+ it "returns an empty String if self was not given anything to convert" do
+ @ec.finish.should == ""
+ end
- it "returns an empty String on subsequent invocations" do
- @ec.finish.should == ""
- @ec.finish.should == ""
+ it "returns an empty String on subsequent invocations" do
+ @ec.finish.should == ""
+ @ec.finish.should == ""
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/insert_output_spec.rb b/spec/ruby/core/encoding/converter/insert_output_spec.rb
index 1346adde1e..bc9a56ba45 100644
--- a/spec/ruby/core/encoding/converter/insert_output_spec.rb
+++ b/spec/ruby/core/encoding/converter/insert_output_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Encoding::Converter#insert_output" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/encoding/converter/inspect_spec.rb b/spec/ruby/core/encoding/converter/inspect_spec.rb
index 3170ee451f..b8216176cf 100644
--- a/spec/ruby/core/encoding/converter/inspect_spec.rb
+++ b/spec/ruby/core/encoding/converter/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Encoding::Converter#inspect" do
it "includes the source and destination encodings in the return value" do
diff --git a/spec/ruby/core/encoding/converter/last_error_spec.rb b/spec/ruby/core/encoding/converter/last_error_spec.rb
index 68567737b7..8465935368 100644
--- a/spec/ruby/core/encoding/converter/last_error_spec.rb
+++ b/spec/ruby/core/encoding/converter/last_error_spec.rb
@@ -1,91 +1,85 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#last_error" do
- it "returns nil when the no conversion has been attempted" do
- ec = Encoding::Converter.new('ascii','utf-8')
- ec.last_error.should be_nil
- end
+with_feature :encoding do
+ describe "Encoding::Converter#last_error" do
+ it "returns nil when the no conversion has been attempted" do
+ ec = Encoding::Converter.new('ascii','utf-8')
+ ec.last_error.should be_nil
+ end
- it "returns nil when the last conversion did not produce an error" do
- ec = Encoding::Converter.new('ascii','utf-8')
- ec.convert('a'.force_encoding('ascii'))
- ec.last_error.should be_nil
- end
+ it "returns nil when the last conversion did not produce an error" do
+ ec = Encoding::Converter.new('ascii','utf-8')
+ ec.convert('a'.force_encoding('ascii'))
+ ec.last_error.should be_nil
+ end
- it "returns nil when #primitive_convert last returned :destination_buffer_full" do
- ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
- ec.primitive_convert("\u{9999}", "", 0, 0, partial_input: false) \
- .should == :destination_buffer_full
- ec.last_error.should be_nil
- end
+ it "returns nil when #primitive_convert last returned :destination_buffer_full" do
+ ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
+ ec.primitive_convert("\u{9999}", "", 0, 0, partial_input: false) \
+ .should == :destination_buffer_full
+ ec.last_error.should be_nil
+ end
- it "returns nil when #primitive_convert last returned :finished" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
- ec.last_error.should be_nil
- end
+ it "returns nil when #primitive_convert last returned :finished" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
+ ec.last_error.should be_nil
+ end
- it "returns nil if the last conversion succeeded but the penultimate failed" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
- ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
- ec.last_error.should be_nil
- end
+ it "returns nil if the last conversion succeeded but the penultimate failed" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
+ ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
+ ec.last_error.should be_nil
+ end
- it "returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :invalid_byte_sequence" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
- ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
- end
+ it "returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :invalid_byte_sequence" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
+ ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
+ end
- it "returns an Encoding::UndefinedConversionError when #primitive_convert last returned :undefined_conversion" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- ec.primitive_convert("\u{9876}","").should == :undefined_conversion
- ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
- end
+ it "returns an Encoding::UndefinedConversionError when #primitive_convert last returned :undefined_conversion" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ ec.primitive_convert("\u{9876}","").should == :undefined_conversion
+ ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
+ end
- it "returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :incomplete_input" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- ec.primitive_convert("\xa4", "", nil, 10).should == :incomplete_input
- ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
- end
+ it "returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :incomplete_input" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ ec.primitive_convert("\xa4", "", nil, 10).should == :incomplete_input
+ ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
+ end
- it "returns an Encoding::InvalidByteSequenceError when the last call to #convert produced one" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- exception = nil
- -> {
- ec.convert("\xf1abcd")
- }.should raise_error(Encoding::InvalidByteSequenceError) { |e|
- exception = e
- }
- ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
- ec.last_error.message.should == exception.message
- end
-
- it "returns an Encoding::UndefinedConversionError when the last call to #convert produced one" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- exception = nil
- -> {
- ec.convert("\u{9899}")
- }.should raise_error(Encoding::UndefinedConversionError) { |e|
- exception = e
- }
- ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
- ec.last_error.message.should == exception.message
- ec.last_error.message.should include "from UTF-8 to ISO-8859-1"
- end
+ it "returns an Encoding::InvalidByteSequenceError when the last call to #convert produced one" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ exception = nil
+ lambda do
+ begin
+ ec.convert("\xf1abcd")
+ rescue Encoding::InvalidByteSequenceError => e
+ exception = e
+ raise e
+ end
+ end.should raise_error(Encoding::InvalidByteSequenceError)
+ ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
+ ec.last_error.message.should == exception.message
+ end
- it "returns the last error of #convert with a message showing the transcoding path" do
- ec = Encoding::Converter.new("iso-8859-1", "Big5")
- exception = nil
- -> {
- ec.convert("\xE9") # é in ISO-8859-1
- }.should raise_error(Encoding::UndefinedConversionError) { |e|
- exception = e
- }
- ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
- ec.last_error.message.should == exception.message
- ec.last_error.message.should include "from ISO-8859-1 to UTF-8 to Big5"
+ it "returns an Encoding::UndefinedConversionError when the last call to #convert produced one" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ exception = nil
+ lambda do
+ begin
+ ec.convert("\u{9899}")
+ rescue Encoding::UndefinedConversionError => e
+ exception = e
+ raise e
+ end
+ end.should raise_error(Encoding::UndefinedConversionError)
+ ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
+ ec.last_error.message.should == exception.message
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/new_spec.rb b/spec/ruby/core/encoding/converter/new_spec.rb
index 9fc97263fe..d228c80a18 100644
--- a/spec/ruby/core/encoding/converter/new_spec.rb
+++ b/spec/ruby/core/encoding/converter/new_spec.rb
@@ -1,118 +1,120 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-
-describe "Encoding::Converter.new" do
- it "accepts a String for the source encoding" do
- conv = Encoding::Converter.new("us-ascii", "utf-8")
- conv.source_encoding.should == Encoding::US_ASCII
- end
-
- it "accepts a String for the destination encoding" do
- conv = Encoding::Converter.new("us-ascii", "utf-8")
- conv.destination_encoding.should == Encoding::UTF_8
- end
-
- it "accepts an Encoding object for the source encoding" do
- conv = Encoding::Converter.new(Encoding::US_ASCII, "utf-8")
- conv.source_encoding.should == Encoding::US_ASCII
- end
-
- it "accepts an Encoding object for the destination encoding" do
- conv = Encoding::Converter.new("us-ascii", Encoding::UTF_8)
- conv.destination_encoding.should == Encoding::UTF_8
- end
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+with_feature :encoding do
+ describe "Encoding::Converter.new" do
+ it "accepts a String for the source encoding" do
+ conv = Encoding::Converter.new("us-ascii", "utf-8")
+ conv.source_encoding.should == Encoding::US_ASCII
+ end
- it "raises an Encoding::ConverterNotFoundError if both encodings are the same" do
- -> do
- Encoding::Converter.new "utf-8", "utf-8"
- end.should raise_error(Encoding::ConverterNotFoundError)
- end
+ it "accepts a String for the destination encoding" do
+ conv = Encoding::Converter.new("us-ascii", "utf-8")
+ conv.destination_encoding.should == Encoding::UTF_8
+ end
- it "calls #to_str to convert the source encoding argument to an encoding name" do
- enc = mock("us-ascii")
- enc.should_receive(:to_str).and_return("us-ascii")
- conv = Encoding::Converter.new(enc, "utf-8")
- conv.source_encoding.should == Encoding::US_ASCII
- end
+ it "accepts an Encoding object for the source encoding" do
+ conv = Encoding::Converter.new(Encoding::US_ASCII, "utf-8")
+ conv.source_encoding.should == Encoding::US_ASCII
+ end
- it "calls #to_str to convert the destination encoding argument to an encoding name" do
- enc = mock("utf-8")
- enc.should_receive(:to_str).and_return("utf-8")
- conv = Encoding::Converter.new("us-ascii", enc)
- conv.destination_encoding.should == Encoding::UTF_8
- end
+ it "accepts an Encoding object for the destination encoding" do
+ conv = Encoding::Converter.new("us-ascii", Encoding::UTF_8)
+ conv.destination_encoding.should == Encoding::UTF_8
+ end
- it "sets replacement from the options Hash" do
- conv = Encoding::Converter.new("us-ascii", "utf-8", replace: "fubar")
- conv.replacement.should == "fubar"
- end
+ it "raises an Encoding::ConverterNotFoundError if both encodings are the same" do
+ lambda do
+ Encoding::Converter.new "utf-8", "utf-8"
+ end.should raise_error(Encoding::ConverterNotFoundError)
+ end
- it "calls #to_hash to convert the options argument to a Hash if not a Fixnum" do
- opts = mock("encoding converter options")
- opts.should_receive(:to_hash).and_return({ replace: "fubar" })
- conv = Encoding::Converter.new("us-ascii", "utf-8", **opts)
- conv.replacement.should == "fubar"
- end
+ it "calls #to_str to convert the source encoding argument to an encoding name" do
+ enc = mock("us-ascii")
+ enc.should_receive(:to_str).and_return("us-ascii")
+ conv = Encoding::Converter.new(enc, "utf-8")
+ conv.source_encoding.should == Encoding::US_ASCII
+ end
- it "calls #to_str to convert the replacement object to a String" do
- obj = mock("encoding converter replacement")
- obj.should_receive(:to_str).and_return("fubar")
- conv = Encoding::Converter.new("us-ascii", "utf-8", replace: obj)
- conv.replacement.should == "fubar"
- end
+ it "calls #to_str to convert the destination encoding argument to an encoding name" do
+ enc = mock("utf-8")
+ enc.should_receive(:to_str).and_return("utf-8")
+ conv = Encoding::Converter.new("us-ascii", enc)
+ conv.destination_encoding.should == Encoding::UTF_8
+ end
- it "raises a TypeError if #to_str does not return a String" do
- obj = mock("encoding converter replacement")
- obj.should_receive(:to_str).and_return(1)
+ it "sets replacement from the options Hash" do
+ conv = Encoding::Converter.new("us-ascii", "utf-8", replace: "fubar")
+ conv.replacement.should == "fubar"
+ end
- -> do
- Encoding::Converter.new("us-ascii", "utf-8", replace: obj)
- end.should raise_error(TypeError)
- end
+ it "calls #to_hash to convert the options argument to a Hash if not a Fixnum" do
+ opts = mock("encoding converter options")
+ opts.should_receive(:to_hash).and_return({ replace: "fubar" })
+ conv = Encoding::Converter.new("us-ascii", "utf-8", opts)
+ conv.replacement.should == "fubar"
+ end
- it "raises a TypeError if passed true for the replacement object" do
- -> do
- Encoding::Converter.new("us-ascii", "utf-8", replace: true)
- end.should raise_error(TypeError)
- end
+ it "calls #to_str to convert the replacement object to a String" do
+ obj = mock("encoding converter replacement")
+ obj.should_receive(:to_str).and_return("fubar")
+ conv = Encoding::Converter.new("us-ascii", "utf-8", replace: obj)
+ conv.replacement.should == "fubar"
+ end
- it "raises a TypeError if passed false for the replacement object" do
- -> do
- Encoding::Converter.new("us-ascii", "utf-8", replace: false)
- end.should raise_error(TypeError)
- end
+ it "raises a TypeError if #to_str does not return a String" do
+ obj = mock("encoding converter replacement")
+ obj.should_receive(:to_str).and_return(1)
- it "raises a TypeError if passed a Fixnum for the replacement object" do
- -> do
- Encoding::Converter.new("us-ascii", "utf-8", replace: 1)
- end.should raise_error(TypeError)
- end
+ lambda do
+ Encoding::Converter.new("us-ascii", "utf-8", replace: obj)
+ end.should raise_error(TypeError)
+ end
- it "accepts an empty String for the replacement object" do
- conv = Encoding::Converter.new("us-ascii", "utf-8", replace: "")
- conv.replacement.should == ""
- end
+ it "raises a TypeError if passed true for the replacement object" do
+ lambda do
+ Encoding::Converter.new("us-ascii", "utf-8", replace: true)
+ end.should raise_error(TypeError)
+ end
- describe "when passed nil for the replacement object" do
- describe "when the destination encoding is not UTF-8" do
- it "sets the replacement String to '?'" do
- conv = Encoding::Converter.new("us-ascii", "binary", replace: nil)
- conv.replacement.should == "?"
- end
+ it "raises a TypeError if passed false for the replacement object" do
+ lambda do
+ Encoding::Converter.new("us-ascii", "utf-8", replace: false)
+ end.should raise_error(TypeError)
+ end
- it "sets the replacement String encoding to US-ASCII" do
- conv = Encoding::Converter.new("us-ascii", "binary", replace: nil)
- conv.replacement.encoding.should == Encoding::US_ASCII
- end
+ it "raises a TypeError if passed a Fixnum for the replacement object" do
+ lambda do
+ Encoding::Converter.new("us-ascii", "utf-8", replace: 1)
+ end.should raise_error(TypeError)
+ end
- it "sets the replacement String to '\\uFFFD'" do
- conv = Encoding::Converter.new("us-ascii", "utf-8", replace: nil)
- conv.replacement.should == "\u{fffd}".force_encoding("utf-8")
- end
+ it "accepts an empty String for the replacement object" do
+ conv = Encoding::Converter.new("us-ascii", "utf-8", replace: "")
+ conv.replacement.should == ""
+ end
- it "sets the replacement String encoding to UTF-8" do
- conv = Encoding::Converter.new("us-ascii", "utf-8", replace: nil)
- conv.replacement.encoding.should == Encoding::UTF_8
+ describe "when passed nil for the replacement object" do
+ describe "when the destination encoding is not UTF-8" do
+ it "sets the replacement String to '?'" do
+ conv = Encoding::Converter.new("us-ascii", "ascii-8bit", replace: nil)
+ conv.replacement.should == "?"
+ end
+
+ it "sets the replacement String encoding to US-ASCII" do
+ conv = Encoding::Converter.new("us-ascii", "ascii-8bit", replace: nil)
+ conv.replacement.encoding.should == Encoding::US_ASCII
+ end
+
+ it "sets the replacement String to '\\uFFFD'" do
+ conv = Encoding::Converter.new("us-ascii", "utf-8", replace: nil)
+ conv.replacement.should == "\u{fffd}".force_encoding("utf-8")
+ end
+
+ it "sets the replacement String encoding to UTF-8" do
+ conv = Encoding::Converter.new("us-ascii", "utf-8", replace: nil)
+ conv.replacement.encoding.should == Encoding::UTF_8
+ end
end
end
end
diff --git a/spec/ruby/core/encoding/converter/primitive_convert_spec.rb b/spec/ruby/core/encoding/converter/primitive_convert_spec.rb
index 802d8e7cb1..ed479c6b13 100644
--- a/spec/ruby/core/encoding/converter/primitive_convert_spec.rb
+++ b/spec/ruby/core/encoding/converter/primitive_convert_spec.rb
@@ -1,211 +1,213 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-
-describe "Encoding::Converter#primitive_convert" do
- before :each do
- @ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- end
-
- it "accepts a nil source buffer" do
- -> { @ec.primitive_convert(nil,"") }.should_not raise_error
- end
-
- it "accepts a String as the source buffer" do
- -> { @ec.primitive_convert("","") }.should_not raise_error
- end
-
- it "accepts nil for the destination byte offset" do
- -> { @ec.primitive_convert("","", nil) }.should_not raise_error
- end
-
- it "accepts an integer for the destination byte offset" do
- -> { @ec.primitive_convert("","a", 1) }.should_not raise_error
- end
-
- it "calls #to_int to convert the destination byte offset" do
- offset = mock("encoding primitive_convert destination byte offset")
- offset.should_receive(:to_int).and_return(2)
- @ec.primitive_convert("abc", result = " ", offset).should == :finished
- result.should == " abc"
- end
-
- it "raises an ArgumentError if the destination byte offset is greater than the bytesize of the destination buffer" do
- -> { @ec.primitive_convert("","am", 0) }.should_not raise_error
- -> { @ec.primitive_convert("","am", 1) }.should_not raise_error
- -> { @ec.primitive_convert("","am", 2) }.should_not raise_error
- -> { @ec.primitive_convert("","am", 3) }.should raise_error(ArgumentError)
- end
-
- it "uses the destination byte offset to determine where to write the result in the destination buffer" do
- dest = "aa"
- @ec.primitive_convert("b",dest, nil, 0)
- dest.should == "aa"
-
- @ec.primitive_convert("b",dest, nil, 1)
- dest.should == "aab"
-
- @ec.primitive_convert("b",dest, nil, 2)
- dest.should == "aabbb"
- end
-
- it "accepts nil for the destination bytesize" do
- -> { @ec.primitive_convert("","", nil, nil) }.should_not raise_error
- end
-
- it "accepts an integer for the destination bytesize" do
- -> { @ec.primitive_convert("","", nil, 0) }.should_not raise_error
- end
-
- it "allows a destination bytesize value greater than the bytesize of the source buffer" do
- -> { @ec.primitive_convert("am","", nil, 3) }.should_not raise_error
- end
-
- it "allows a destination bytesize value less than the bytesize of the source buffer" do
- -> { @ec.primitive_convert("am","", nil, 1) }.should_not raise_error
- end
-
- it "calls #to_int to convert the destination byte size" do
- size = mock("encoding primitive_convert destination byte size")
- size.should_receive(:to_int).and_return(2)
- @ec.primitive_convert("abc", result = " ", 0, size).should == :destination_buffer_full
- result.should == "ab"
- end
-
- it "uses destination bytesize as the maximum bytesize of the destination buffer" do
- dest = ""
- @ec.primitive_convert("glark", dest, nil, 1)
- dest.bytesize.should == 1
- end
-
- it "allows a destination buffer of unlimited size if destination bytesize is nil" do
- source = "glark".force_encoding('utf-8')
- dest = ""
- @ec.primitive_convert("glark", dest, nil, nil)
- dest.bytesize.should == source.bytesize
- end
-
- it "accepts an options hash" do
- @ec.primitive_convert("","",nil,nil, after_output: true).should == :finished
- end
-
- it "sets the destination buffer's encoding to the destination encoding if the conversion succeeded" do
- dest = "".force_encoding('utf-8')
- dest.encoding.should == Encoding::UTF_8
- @ec.primitive_convert("\u{98}",dest).should == :finished
- dest.encoding.should == Encoding::ISO_8859_1
- end
-
- it "sets the destination buffer's encoding to the destination encoding if the conversion failed" do
- dest = "".force_encoding('utf-8')
- dest.encoding.should == Encoding::UTF_8
- @ec.primitive_convert("\u{9878}",dest).should == :undefined_conversion
- dest.encoding.should == Encoding::ISO_8859_1
- end
-
- it "removes the undefined part from the source buffer when returning :undefined_conversion" do
- dest = "".force_encoding('utf-8')
- s = "\u{9878}abcd"
- @ec.primitive_convert(s, dest).should == :undefined_conversion
-
- s.should == "abcd"
- end
-
- it "returns :incomplete_input when source buffer ends unexpectedly and :partial_input isn't specified" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- ec.primitive_convert("\xa4", "", nil, nil, partial_input: false).should == :incomplete_input
- end
-
- it "clears the source buffer when returning :incomplete_input" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- s = "\xa4"
- ec.primitive_convert(s, "").should == :incomplete_input
-
- s.should == ""
- end
-
- it "returns :source_buffer_empty when source buffer ends unexpectedly and :partial_input is true" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- ec.primitive_convert("\xa4", "", nil, nil, partial_input: true).should == :source_buffer_empty
- end
-
- it "clears the source buffer when returning :source_buffer_empty" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- s = "\xa4"
- ec.primitive_convert(s, "", nil, nil, partial_input: true).should == :source_buffer_empty
-
- s.should == ""
- end
-
- it "returns :undefined_conversion when a character in the source buffer is not representable in the output encoding" do
- @ec.primitive_convert("\u{9876}","").should == :undefined_conversion
- end
-
- it "returns :invalid_byte_sequence when an invalid byte sequence was found in the source buffer" do
- @ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
- end
-
- it "removes consumed and erroneous bytes from the source buffer when returning :invalid_byte_sequence" do
- ec = Encoding::Converter.new(Encoding::UTF_8, Encoding::UTF_8_MAC)
- s = "\xC3\xA1\x80\x80\xC3\xA1".force_encoding("utf-8")
- dest = "".force_encoding("utf-8")
- ec.primitive_convert(s, dest)
-
- s.should == "\x80\xC3\xA1".force_encoding("utf-8")
- end
-
- it "returns :finished when the conversion succeeded" do
- @ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
- end
-
- it "clears the source buffer when returning :finished" do
- s = "glark".force_encoding('utf-8')
- @ec.primitive_convert(s, "").should == :finished
-
- s.should == ""
- end
-
- it "returns :destination_buffer_full when the destination buffer is too small" do
- ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
- source = "\u{9999}"
- destination_bytesize = source.bytesize - 1
- ec.primitive_convert(source, "", 0, destination_bytesize) \
- .should == :destination_buffer_full
- source.should == ""
- end
-
- it "clears the source buffer when returning :destination_buffer_full" do
- ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
- s = "\u{9999}"
- destination_bytesize = s.bytesize - 1
- ec.primitive_convert(s, "", 0, destination_bytesize).should == :destination_buffer_full
-
- s.should == ""
- end
-
- it "keeps removing invalid bytes from the source buffer" do
- ec = Encoding::Converter.new(Encoding::UTF_8, Encoding::UTF_8_MAC)
- s = "\x80\x80\x80"
- dest = "".force_encoding(Encoding::UTF_8_MAC)
-
- ec.primitive_convert(s, dest)
- s.should == "\x80\x80"
- ec.primitive_convert(s, dest)
- s.should == "\x80"
- ec.primitive_convert(s, dest)
- s.should == ""
- end
-
- it "reuses read-again bytes after the first error" do
- s = "\xf1abcd"
- dest = ""
-
- @ec.primitive_convert(s, dest).should == :invalid_byte_sequence
- s.should == "bcd"
- @ec.primitive_errinfo[4].should == "a"
-
- @ec.primitive_convert(s, dest).should == :finished
- s.should == ""
-
- dest.should == "abcd"
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+with_feature :encoding do
+ describe "Encoding::Converter#primitive_convert" do
+ before :each do
+ @ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ end
+
+ it "accepts a nil source buffer" do
+ lambda { @ec.primitive_convert(nil,"") }.should_not raise_error
+ end
+
+ it "accepts a String as the source buffer" do
+ lambda { @ec.primitive_convert("","") }.should_not raise_error
+ end
+
+ it "accepts nil for the destination byte offset" do
+ lambda { @ec.primitive_convert("","", nil) }.should_not raise_error
+ end
+
+ it "accepts an integer for the destination byte offset" do
+ lambda { @ec.primitive_convert("","a", 1) }.should_not raise_error
+ end
+
+ it "calls #to_int to convert the destination byte offset" do
+ offset = mock("encoding primitive_convert destination byte offset")
+ offset.should_receive(:to_int).and_return(2)
+ @ec.primitive_convert("abc", result = " ", offset).should == :finished
+ result.should == " abc"
+ end
+
+ it "raises an ArgumentError if the destination byte offset is greater than the bytesize of the destination buffer" do
+ lambda { @ec.primitive_convert("","am", 0) }.should_not raise_error
+ lambda { @ec.primitive_convert("","am", 1) }.should_not raise_error
+ lambda { @ec.primitive_convert("","am", 2) }.should_not raise_error
+ lambda { @ec.primitive_convert("","am", 3) }.should raise_error(ArgumentError)
+ end
+
+ it "uses the destination byte offset to determine where to write the result in the destination buffer" do
+ dest = "aa"
+ @ec.primitive_convert("b",dest, nil, 0)
+ dest.should == "aa"
+
+ @ec.primitive_convert("b",dest, nil, 1)
+ dest.should == "aab"
+
+ @ec.primitive_convert("b",dest, nil, 2)
+ dest.should == "aabbb"
+ end
+
+ it "accepts nil for the destination bytesize" do
+ lambda { @ec.primitive_convert("","", nil, nil) }.should_not raise_error
+ end
+
+ it "accepts an integer for the destination bytesize" do
+ lambda { @ec.primitive_convert("","", nil, 0) }.should_not raise_error
+ end
+
+ it "allows a destination bytesize value greater than the bytesize of the source buffer" do
+ lambda { @ec.primitive_convert("am","", nil, 3) }.should_not raise_error
+ end
+
+ it "allows a destination bytesize value less than the bytesize of the source buffer" do
+ lambda { @ec.primitive_convert("am","", nil, 1) }.should_not raise_error
+ end
+
+ it "calls #to_int to convert the destination byte size" do
+ size = mock("encoding primitive_convert destination byte size")
+ size.should_receive(:to_int).and_return(2)
+ @ec.primitive_convert("abc", result = " ", 0, size).should == :destination_buffer_full
+ result.should == "ab"
+ end
+
+ it "uses destination bytesize as the maximum bytesize of the destination buffer" do
+ dest = ""
+ @ec.primitive_convert("glark", dest, nil, 1)
+ dest.bytesize.should == 1
+ end
+
+ it "allows a destination buffer of unlimited size if destination bytesize is nil" do
+ source = "glark".force_encoding('utf-8')
+ dest = ""
+ @ec.primitive_convert("glark", dest, nil, nil)
+ dest.bytesize.should == source.bytesize
+ end
+
+ it "accepts an options hash" do
+ @ec.primitive_convert("","",nil,nil, {after_output: true}).should == :finished
+ end
+
+ it "sets the destination buffer's encoding to the destination encoding if the conversion succeeded" do
+ dest = "".force_encoding('utf-8')
+ dest.encoding.should == Encoding::UTF_8
+ @ec.primitive_convert("\u{98}",dest).should == :finished
+ dest.encoding.should == Encoding::ISO_8859_1
+ end
+
+ it "sets the destination buffer's encoding to the destination encoding if the conversion failed" do
+ dest = "".force_encoding('utf-8')
+ dest.encoding.should == Encoding::UTF_8
+ @ec.primitive_convert("\u{9878}",dest).should == :undefined_conversion
+ dest.encoding.should == Encoding::ISO_8859_1
+ end
+
+ it "removes the undefined part from the source buffer when returning :undefined_conversion" do
+ dest = "".force_encoding('utf-8')
+ s = "\u{9878}abcd"
+ @ec.primitive_convert(s, dest).should == :undefined_conversion
+
+ s.should == "abcd"
+ end
+
+ it "returns :incomplete_input when source buffer ends unexpectedly and :partial_input isn't specified" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ ec.primitive_convert("\xa4", "", nil, nil, partial_input: false).should == :incomplete_input
+ end
+
+ it "clears the source buffer when returning :incomplete_input" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ s = "\xa4"
+ ec.primitive_convert(s, "").should == :incomplete_input
+
+ s.should == ""
+ end
+
+ it "returns :source_buffer_empty when source buffer ends unexpectedly and :partial_input is true" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ ec.primitive_convert("\xa4", "", nil, nil, partial_input: true).should == :source_buffer_empty
+ end
+
+ it "clears the source buffer when returning :source_buffer_empty" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ s = "\xa4"
+ ec.primitive_convert(s, "", nil, nil, partial_input: true).should == :source_buffer_empty
+
+ s.should == ""
+ end
+
+ it "returns :undefined_conversion when a character in the source buffer is not representable in the output encoding" do
+ @ec.primitive_convert("\u{9876}","").should == :undefined_conversion
+ end
+
+ it "returns :invalid_byte_sequence when an invalid byte sequence was found in the source buffer" do
+ @ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
+ end
+
+ it "removes consumed and erroneous bytes from the source buffer when returning :invalid_byte_sequence" do
+ ec = Encoding::Converter.new(Encoding::UTF_8, Encoding::UTF_8_MAC)
+ s = "\xC3\xA1\x80\x80\xC3\xA1".force_encoding("utf-8")
+ dest = "".force_encoding("utf-8")
+ ec.primitive_convert(s, dest)
+
+ s.should == "\x80\xC3\xA1".force_encoding("utf-8")
+ end
+
+ it "returns :finished when the conversion succeeded" do
+ @ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
+ end
+
+ it "clears the source buffer when returning :finished" do
+ s = "glark".force_encoding('utf-8')
+ @ec.primitive_convert(s, "").should == :finished
+
+ s.should == ""
+ end
+
+ it "returns :destination_buffer_full when the destination buffer is too small" do
+ ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
+ source = "\u{9999}"
+ destination_bytesize = source.bytesize - 1
+ ec.primitive_convert(source, "", 0, destination_bytesize) \
+ .should == :destination_buffer_full
+ source.should == ""
+ end
+
+ it "clears the source buffer when returning :destination_buffer_full" do
+ ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
+ s = "\u{9999}"
+ destination_bytesize = s.bytesize - 1
+ ec.primitive_convert(s, "", 0, destination_bytesize).should == :destination_buffer_full
+
+ s.should == ""
+ end
+
+ it "keeps removing invalid bytes from the source buffer" do
+ ec = Encoding::Converter.new(Encoding::UTF_8, Encoding::UTF_8_MAC)
+ s = "\x80\x80\x80"
+ dest = "".force_encoding(Encoding::UTF_8_MAC)
+
+ ec.primitive_convert(s, dest)
+ s.should == "\x80\x80"
+ ec.primitive_convert(s, dest)
+ s.should == "\x80"
+ ec.primitive_convert(s, dest)
+ s.should == ""
+ end
+
+ it "reuses read-again bytes after the first error" do
+ s = "\xf1abcd"
+ dest = ""
+
+ @ec.primitive_convert(s, dest).should == :invalid_byte_sequence
+ s.should == "bcd"
+ @ec.primitive_errinfo[4].should == "a"
+
+ @ec.primitive_convert(s, dest).should == :finished
+ s.should == ""
+
+ dest.should == "abcd"
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb b/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb
index 1f836b259f..cba654b9fe 100644
--- a/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb
+++ b/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb
@@ -1,68 +1,70 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#primitive_errinfo" do
- it "returns [:source_buffer_empty,nil,nil,nil,nil] when no conversion has been attempted" do
- ec = Encoding::Converter.new('ascii','utf-8')
- ec.primitive_errinfo.should == [:source_buffer_empty, nil, nil, nil, nil]
- end
+with_feature :encoding do
+ describe "Encoding::Converter#primitive_errinfo" do
+ it "returns [:source_buffer_empty,nil,nil,nil,nil] when no conversion has been attempted" do
+ ec = Encoding::Converter.new('ascii','utf-8')
+ ec.primitive_errinfo.should == [:source_buffer_empty, nil, nil, nil, nil]
+ end
- it "returns [:finished,nil,nil,nil,nil] when #primitive_convert last returned :finished" do
- ec = Encoding::Converter.new('ascii','utf-8')
- ec.primitive_convert("a","").should == :finished
- ec.primitive_errinfo.should == [:finished, nil, nil, nil, nil]
- end
+ it "returns [:finished,nil,nil,nil,nil] when #primitive_convert last returned :finished" do
+ ec = Encoding::Converter.new('ascii','utf-8')
+ ec.primitive_convert("a","").should == :finished
+ ec.primitive_errinfo.should == [:finished, nil, nil, nil, nil]
+ end
- it "returns [:source_buffer_empty,nil,nil,nil, nil] when #convert last succeeded" do
- ec = Encoding::Converter.new('ascii','utf-8')
- ec.convert("a".force_encoding('ascii')).should == "a".force_encoding('utf-8')
- ec.primitive_errinfo.should == [:source_buffer_empty, nil, nil, nil, nil]
- end
+ it "returns [:source_buffer_empty,nil,nil,nil, nil] when #convert last succeeded" do
+ ec = Encoding::Converter.new('ascii','utf-8')
+ ec.convert("a".force_encoding('ascii')).should == "a".force_encoding('utf-8')
+ ec.primitive_errinfo.should == [:source_buffer_empty, nil, nil, nil, nil]
+ end
- it "returns [:destination_buffer_full,nil,nil,nil,nil] when #primitive_convert last returned :destination_buffer_full" do
- ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
- ec.primitive_convert("\u{9999}", "", 0, 0, partial_input: false).should == :destination_buffer_full
- ec.primitive_errinfo.should == [:destination_buffer_full, nil, nil, nil, nil]
- end
+ it "returns [:destination_buffer_full,nil,nil,nil,nil] when #primitive_convert last returned :destination_buffer_full" do
+ ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
+ ec.primitive_convert("\u{9999}", "", 0, 0, partial_input: false).should == :destination_buffer_full
+ ec.primitive_errinfo.should == [:destination_buffer_full, nil, nil, nil, nil]
+ end
- it "returns the status of the last primitive conversion, even if it was successful and the previous one wasn't" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
- ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
- ec.primitive_errinfo.should == [:finished, nil, nil, nil, nil]
- end
+ it "returns the status of the last primitive conversion, even if it was successful and the previous one wasn't" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
+ ec.primitive_convert("glark".force_encoding('utf-8'),"").should == :finished
+ ec.primitive_errinfo.should == [:finished, nil, nil, nil, nil]
+ end
- it "returns the state, source encoding, target encoding, and the erroneous bytes when #primitive_convert last returned :undefined_conversion" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- ec.primitive_convert("\u{9876}","").should == :undefined_conversion
- ec.primitive_errinfo.should ==
- [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE9\xA1\xB6", ""]
- end
+ it "returns the state, source encoding, target encoding, and the erroneous bytes when #primitive_convert last returned :undefined_conversion" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ ec.primitive_convert("\u{9876}","").should == :undefined_conversion
+ ec.primitive_errinfo.should ==
+ [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE9\xA1\xB6", ""]
+ end
- it "returns the state, source encoding, target encoding, and erroneous bytes when #primitive_convert last returned :incomplete_input" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- ec.primitive_convert("\xa4", "", nil, 10).should == :incomplete_input
- ec.primitive_errinfo.should == [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""]
- end
+ it "returns the state, source encoding, target encoding, and erroneous bytes when #primitive_convert last returned :incomplete_input" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ ec.primitive_convert("\xa4", "", nil, 10).should == :incomplete_input
+ ec.primitive_errinfo.should == [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""]
+ end
- it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #primitive_convert last returned :invalid_byte_sequence" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
- ec.primitive_errinfo.should ==
- [:invalid_byte_sequence, "UTF-8", "ISO-8859-1", "\xF1", "a"]
- end
+ it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #primitive_convert last returned :invalid_byte_sequence" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ ec.primitive_convert("\xf1abcd","").should == :invalid_byte_sequence
+ ec.primitive_errinfo.should ==
+ [:invalid_byte_sequence, "UTF-8", "ISO-8859-1", "\xF1", "a"]
+ end
- it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #convert last raised InvalidByteSequenceError" do
- ec = Encoding::Converter.new("utf-8", "iso-8859-1")
- -> { ec.convert("\xf1abcd") }.should raise_error(Encoding::InvalidByteSequenceError)
- ec.primitive_errinfo.should ==
- [:invalid_byte_sequence, "UTF-8", "ISO-8859-1", "\xF1", "a"]
- end
+ it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #convert last raised InvalidByteSequenceError" do
+ ec = Encoding::Converter.new("utf-8", "iso-8859-1")
+ lambda { ec.convert("\xf1abcd") }.should raise_error(Encoding::InvalidByteSequenceError)
+ ec.primitive_errinfo.should ==
+ [:invalid_byte_sequence, "UTF-8", "ISO-8859-1", "\xF1", "a"]
+ end
- it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #finish last raised InvalidByteSequenceError" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- ec.convert("\xa4")
- -> { ec.finish }.should raise_error(Encoding::InvalidByteSequenceError)
- ec.primitive_errinfo.should == [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""]
+ it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #finish last raised InvalidByteSequenceError" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ ec.convert("\xa4")
+ lambda { ec.finish }.should raise_error(Encoding::InvalidByteSequenceError)
+ ec.primitive_errinfo.should == [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""]
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/putback_spec.rb b/spec/ruby/core/encoding/converter/putback_spec.rb
index 87495eaf3f..3ed1ad9956 100644
--- a/spec/ruby/core/encoding/converter/putback_spec.rb
+++ b/spec/ruby/core/encoding/converter/putback_spec.rb
@@ -1,47 +1,49 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#putback" do
- before :each do
- @ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- @ret = @ec.primitive_convert(@src="abc\xa1def", @dst="", nil, 10)
- end
+with_feature :encoding do
+ describe "Encoding::Converter#putback" do
+ before :each do
+ @ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ @ret = @ec.primitive_convert(@src="abc\xa1def", @dst="", nil, 10)
+ end
- it "returns a String" do
- @ec.putback.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @ec.putback.should be_an_instance_of(String)
+ end
- it "returns a String in the source encoding" do
- @ec.putback.encoding.should == Encoding::EUC_JP
- end
+ it "returns a String in the source encoding" do
+ @ec.putback.encoding.should == Encoding::EUC_JP
+ end
- it "returns the bytes buffered due to an :invalid_byte_sequence error" do
- @ret.should == :invalid_byte_sequence
- @ec.putback.should == 'd'
- @ec.primitive_errinfo.last.should == 'd'
- end
+ it "returns the bytes buffered due to an :invalid_byte_sequence error" do
+ @ret.should == :invalid_byte_sequence
+ @ec.putback.should == 'd'
+ @ec.primitive_errinfo.last.should == 'd'
+ end
- it "allows conversion to be resumed after an :invalid_byte_sequence" do
- @src = @ec.putback + @src
- @ret = @ec.primitive_convert(@src, @dst, nil, 10)
- @ret.should == :finished
- @dst.should == "abcdef"
- @src.should == ""
- end
+ it "allows conversion to be resumed after an :invalid_byte_sequence" do
+ @src = @ec.putback + @src
+ @ret = @ec.primitive_convert(@src, @dst, nil, 10)
+ @ret.should == :finished
+ @dst.should == "abcdef"
+ @src.should == ""
+ end
- it "returns an empty String when there are no more bytes to put back" do
- @ec.putback
- @ec.putback.should == ""
- end
+ it "returns an empty String when there are no more bytes to put back" do
+ @ec.putback
+ @ec.putback.should == ""
+ end
- it "accepts an integer argument corresponding to the number of bytes to be put back" do
- ec = Encoding::Converter.new("utf-16le", "iso-8859-1")
- src = "\x00\xd8\x61\x00"
- dst = ""
- ec.primitive_convert(src, dst).should == :invalid_byte_sequence
- ec.primitive_errinfo.should == [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"]
- ec.putback(1).should == "\x00".force_encoding("utf-16le")
- ec.putback.should == "a".force_encoding("utf-16le")
- ec.putback.should == ""
+ it "accepts an integer argument corresponding to the number of bytes to be put back" do
+ ec = Encoding::Converter.new("utf-16le", "iso-8859-1")
+ src = "\x00\xd8\x61\x00"
+ dst = ""
+ ec.primitive_convert(src, dst).should == :invalid_byte_sequence
+ ec.primitive_errinfo.should == [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"]
+ ec.putback(1).should == "\x00".force_encoding("utf-16le")
+ ec.putback.should == "a".force_encoding("utf-16le")
+ ec.putback.should == ""
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/replacement_spec.rb b/spec/ruby/core/encoding/converter/replacement_spec.rb
index 5ca42e7e5a..9c25887cd7 100644
--- a/spec/ruby/core/encoding/converter/replacement_spec.rb
+++ b/spec/ruby/core/encoding/converter/replacement_spec.rb
@@ -1,72 +1,74 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#replacement" do
- it "returns '?' in US-ASCII when the destination encoding is not UTF-8" do
- ec = Encoding::Converter.new("utf-8", "us-ascii")
- ec.replacement.should == "?"
- ec.replacement.encoding.should == Encoding::US_ASCII
+with_feature :encoding do
+ describe "Encoding::Converter#replacement" do
+ it "returns '?' in US-ASCII when the destination encoding is not UTF-8" do
+ ec = Encoding::Converter.new("utf-8", "us-ascii")
+ ec.replacement.should == "?"
+ ec.replacement.encoding.should == Encoding::US_ASCII
- ec = Encoding::Converter.new("utf-8", "sjis")
- ec.replacement.should == "?"
- ec.replacement.encoding.should == Encoding::US_ASCII
- end
+ ec = Encoding::Converter.new("utf-8", "sjis")
+ ec.replacement.should == "?"
+ ec.replacement.encoding.should == Encoding::US_ASCII
+ end
- it "returns \\uFFFD when the destination encoding is UTF-8" do
- ec = Encoding::Converter.new("us-ascii", "utf-8")
- ec.replacement.should == "\u{fffd}".force_encoding('utf-8')
- ec.replacement.encoding.should == Encoding::UTF_8
+ it "returns \\uFFFD when the destination encoding is UTF-8" do
+ ec = Encoding::Converter.new("us-ascii", "utf-8")
+ ec.replacement.should == "\u{fffd}".force_encoding('utf-8')
+ ec.replacement.encoding.should == Encoding::UTF_8
+ end
end
-end
-describe "Encoding::Converter#replacement=" do
- it "accepts a String argument" do
- ec = Encoding::Converter.new("utf-8", "us-ascii")
- ec.replacement = "!"
- ec.replacement.should == "!"
- end
+ describe "Encoding::Converter#replacement=" do
+ it "accepts a String argument" do
+ ec = Encoding::Converter.new("utf-8", "us-ascii")
+ ec.replacement = "!"
+ ec.replacement.should == "!"
+ end
- it "accepts a String argument of arbitrary length" do
- ec = Encoding::Converter.new("utf-8", "us-ascii")
- ec.replacement = "?!?" * 9999
- ec.replacement.should == "?!?" * 9999
- end
+ it "accepts a String argument of arbitrary length" do
+ ec = Encoding::Converter.new("utf-8", "us-ascii")
+ ec.replacement = "?!?" * 9999
+ ec.replacement.should == "?!?" * 9999
+ end
- it "raises a TypeError if assigned a non-String argument" do
- ec = Encoding::Converter.new("utf-8", "us-ascii")
- -> { ec.replacement = nil }.should raise_error(TypeError)
- end
+ it "raises a TypeError if assigned a non-String argument" do
+ ec = Encoding::Converter.new("utf-8", "us-ascii")
+ lambda { ec.replacement = nil }.should raise_error(TypeError)
+ end
- it "sets #replacement" do
- ec = Encoding::Converter.new("us-ascii", "utf-8")
- ec.replacement.should == "\u{fffd}".force_encoding('utf-8')
- ec.replacement = '?'.encode('utf-8')
- ec.replacement.should == '?'.force_encoding('utf-8')
- end
+ it "sets #replacement" do
+ ec = Encoding::Converter.new("us-ascii", "utf-8")
+ ec.replacement.should == "\u{fffd}".force_encoding('utf-8')
+ ec.replacement = '?'.encode('utf-8')
+ ec.replacement.should == '?'.force_encoding('utf-8')
+ end
- it "raises an UndefinedConversionError is the argument cannot be converted into the destination encoding" do
- ec = Encoding::Converter.new("sjis", "ascii")
- utf8_q = "\u{986}".force_encoding('utf-8')
- ec.primitive_convert(utf8_q.dup, "").should == :undefined_conversion
- -> { ec.replacement = utf8_q }.should \
- raise_error(Encoding::UndefinedConversionError)
- end
+ it "raises an UndefinedConversionError is the argument cannot be converted into the destination encoding" do
+ ec = Encoding::Converter.new("sjis", "ascii")
+ utf8_q = "\u{986}".force_encoding('utf-8')
+ ec.primitive_convert(utf8_q.dup, "").should == :undefined_conversion
+ lambda { ec.replacement = utf8_q }.should \
+ raise_error(Encoding::UndefinedConversionError)
+ end
- it "does not change the replacement character if the argument cannot be converted into the destination encoding" do
- ec = Encoding::Converter.new("sjis", "ascii")
- utf8_q = "\u{986}".force_encoding('utf-8')
- ec.primitive_convert(utf8_q.dup, "").should == :undefined_conversion
- -> { ec.replacement = utf8_q }.should \
- raise_error(Encoding::UndefinedConversionError)
- ec.replacement.should == "?".force_encoding('us-ascii')
- end
+ it "does not change the replacement character if the argument cannot be converted into the destination encoding" do
+ ec = Encoding::Converter.new("sjis", "ascii")
+ utf8_q = "\u{986}".force_encoding('utf-8')
+ ec.primitive_convert(utf8_q.dup, "").should == :undefined_conversion
+ lambda { ec.replacement = utf8_q }.should \
+ raise_error(Encoding::UndefinedConversionError)
+ ec.replacement.should == "?".force_encoding('us-ascii')
+ end
- it "uses the replacement character" do
- ec = Encoding::Converter.new("utf-8", "us-ascii", :invalid => :replace, :undef => :replace)
- ec.replacement = "!"
- dest = ""
- status = ec.primitive_convert "中文123", dest
+ it "uses the replacement character" do
+ ec = Encoding::Converter.new("utf-8", "us-ascii", :invalid => :replace, :undef => :replace)
+ ec.replacement = "!"
+ dest = ""
+ status = ec.primitive_convert "中文123", dest
- status.should == :finished
- dest.should == "!!123"
+ status.should == :finished
+ dest.should == "!!123"
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/search_convpath_spec.rb b/spec/ruby/core/encoding/converter/search_convpath_spec.rb
index 0882af5539..c04eeb98ad 100644
--- a/spec/ruby/core/encoding/converter/search_convpath_spec.rb
+++ b/spec/ruby/core/encoding/converter/search_convpath_spec.rb
@@ -1,30 +1,73 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter.search_convpath" do
- it "returns an Array with a single element if there is a direct converter" do
- cp = Encoding::Converter.search_convpath('ASCII', 'UTF-8')
- cp.should == [[Encoding::US_ASCII, Encoding::UTF_8]]
- end
+with_feature :encoding do
+ describe "Encoding::Converter.search_convpath" do
+ before :all do
+ @perms = Encoding.name_list.permutation(2).map do |pair|
+ Encoding::Converter.search_convpath(pair.first, pair.last) rescue []
+ end
+ end
- it "returns multiple encoding pairs when direct conversion is impossible" do
- cp = Encoding::Converter.search_convpath('ascii','Big5')
- cp.should == [
- [Encoding::US_ASCII, Encoding::UTF_8],
- [Encoding::UTF_8, Encoding::Big5]
- ]
- end
+ it "returns an Array" do
+ Encoding::Converter.search_convpath('ASCII', 'EUC-JP').\
+ should be_an_instance_of(Array)
+ end
- it "indicates if crlf_newline conversion would occur" do
- cp = Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", crlf_newline: true)
- cp.last.should == "crlf_newline"
+ it "returns each encoding pair as a sub-Array" do
+ cp = Encoding::Converter.search_convpath('ASCII', 'EUC-JP')
+ cp.first.should be_an_instance_of(Array)
+ cp.first.size.should == 2
+ end
- cp = Encoding::Converter.search_convpath("ASCII", "UTF-8", crlf_newline: false)
- cp.last.should_not == "crlf_newline"
- end
+ it "returns each encoding as an Encoding object" do
+ cp = Encoding::Converter.search_convpath('ASCII', 'EUC-JP')
+ cp.first.first.should be_an_instance_of(Encoding)
+ cp.first.last.should be_an_instance_of(Encoding)
+ end
+
+ it "returns multiple encoding pairs when direct conversion is impossible" do
+ cp = Encoding::Converter.search_convpath('ascii','Big5')
+ cp.size.should == 2
+ cp.first.should == [Encoding::US_ASCII, Encoding::UTF_8]
+ cp.last.should == [Encoding::UTF_8, Encoding::Big5]
+ end
+
+ it "sets the last element of each pair to the first element of the next" do
+ @perms.each do |convpath|
+ next if convpath.size == 1
+ convpath.each_with_index do |pair, idx|
+ break if idx == convpath.size - 1
+ pair.last.should == convpath[idx+1].first
+ end
+ end
+ end
+
+ it "only lists a source encoding once" do
+ @perms.each do |convpath|
+ next if convpath.size < 2
+ seen = Hash.new(false)
+ convpath.each_with_index do |pair, idx|
+ seen.key?(pair.first).should be_false if idx > 0
+ seen[pair.first] = true
+ end
+ end
+ end
+
+ it "indicates if crlf_newline conversion would occur" do
+ cp = Encoding::Converter.search_convpath(
+ "ISo-8859-1", "EUC-JP", {crlf_newline: true})
+ cp.last.should == "crlf_newline"
+
+ cp = Encoding::Converter.search_convpath(
+ "ASCII", "UTF-8", {crlf_newline: false})
+ cp.last.should_not == "crlf_newline"
+ end
- it "raises an Encoding::ConverterNotFoundError if no conversion path exists" do
- -> do
- Encoding::Converter.search_convpath(Encoding::BINARY, Encoding::Emacs_Mule)
- end.should raise_error(Encoding::ConverterNotFoundError)
+ it "raises an Encoding::ConverterNotFoundError if no conversion path exists" do
+ lambda do
+ Encoding::Converter.search_convpath(
+ Encoding::ASCII_8BIT, Encoding::Emacs_Mule)
+ end.should raise_error(Encoding::ConverterNotFoundError)
+ end
end
end
diff --git a/spec/ruby/core/encoding/converter/source_encoding_spec.rb b/spec/ruby/core/encoding/converter/source_encoding_spec.rb
index 6196f717bd..acec01502d 100644
--- a/spec/ruby/core/encoding/converter/source_encoding_spec.rb
+++ b/spec/ruby/core/encoding/converter/source_encoding_spec.rb
@@ -1,11 +1,13 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::Converter#source_encoding" do
- it "returns the source encoding as an Encoding object" do
- ec = Encoding::Converter.new('ASCII','Big5')
- ec.source_encoding.should == Encoding::US_ASCII
+with_feature :encoding do
+ describe "Encoding::Converter#source_encoding" do
+ it "returns the source encoding as an Encoding object" do
+ ec = Encoding::Converter.new('ASCII','Big5')
+ ec.source_encoding.should == Encoding::US_ASCII
- ec = Encoding::Converter.new('Shift_JIS','EUC-JP')
- ec.source_encoding.should == Encoding::SHIFT_JIS
+ ec = Encoding::Converter.new('Shift_JIS','EUC-JP')
+ ec.source_encoding.should == Encoding::SHIFT_JIS
+ end
end
end
diff --git a/spec/ruby/core/encoding/default_external_spec.rb b/spec/ruby/core/encoding/default_external_spec.rb
index e2cb9b02f4..2b026c793f 100644
--- a/spec/ruby/core/encoding/default_external_spec.rb
+++ b/spec/ruby/core/encoding/default_external_spec.rb
@@ -1,63 +1,74 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding.default_external" do
- before :each do
- @original_encoding = Encoding.default_external
- end
+with_feature :encoding do
+ describe "Encoding.default_external" do
+ before :each do
+ @original_encoding = Encoding.default_external
+ end
- after :each do
- Encoding.default_external = @original_encoding
- end
+ after :each do
+ Encoding.default_external = @original_encoding
+ end
- it "returns an Encoding object" do
- Encoding.default_external.should be_an_instance_of(Encoding)
- end
+ it "returns an Encoding object" do
+ Encoding.default_external.should be_an_instance_of(Encoding)
+ end
- it "returns the default external encoding" do
- Encoding.default_external = Encoding::SHIFT_JIS
- Encoding.default_external.should == Encoding::SHIFT_JIS
- end
-end
+ it "returns the default external encoding" do
+ Encoding.default_external = Encoding::UTF_8
+ Encoding.default_external.should == Encoding::UTF_8
+ end
-describe "Encoding.default_external=" do
- before :each do
- @original_encoding = Encoding.default_external
- end
+ describe "with command line options" do
+ it "is not changed by the -U option" do
+ result = ruby_exe("print Encoding.default_external", options: '-U')
+ result.should == Encoding.default_external.name
+ end
- after :each do
- Encoding.default_external = @original_encoding
- end
+ it "returns the encoding specified by '-E external'" do
+ result = ruby_exe("print Encoding.default_external", options: '-E euc-jp')
+ result.should == "EUC-JP"
+ end
- it "sets the default external encoding" do
- Encoding.default_external = Encoding::SHIFT_JIS
- Encoding.default_external.should == Encoding::SHIFT_JIS
- Encoding.find('external').should == Encoding::SHIFT_JIS
+ it "returns the encoding specified by '-E external:'" do
+ result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:')
+ result.should == "Shift_JIS"
+ end
+ end
end
- platform_is_not :windows do
- it "also sets the filesystem encoding" do
- Encoding.default_external = Encoding::SHIFT_JIS
- Encoding.find('filesystem').should == Encoding::SHIFT_JIS
+ describe "Encoding.default_external=" do
+ before :each do
+ @original_encoding = Encoding.default_external
end
- end
- it "can accept a name of an encoding as a String" do
- Encoding.default_external = 'Shift_JIS'
- Encoding.default_external.should == Encoding::SHIFT_JIS
- end
+ after :each do
+ Encoding.default_external = @original_encoding
+ end
- it "calls #to_s on arguments that are neither Strings nor Encodings" do
- string = mock('string')
- string.should_receive(:to_str).at_least(1).and_return('US-ASCII')
- Encoding.default_external = string
- Encoding.default_external.should == Encoding::ASCII
- end
+ it "sets the default external encoding" do
+ Encoding.default_external = Encoding::UTF_8
+ Encoding.default_external.should == Encoding::UTF_8
+ end
- it "raises a TypeError unless the argument is an Encoding or convertible to a String" do
- -> { Encoding.default_external = [] }.should raise_error(TypeError)
- end
+ it "can accept a name of an encoding as a String" do
+ Encoding.default_external = 'Shift_JIS'
+ Encoding.default_external.should == Encoding::SHIFT_JIS
+ end
+
+ it "calls #to_s on arguments that are neither Strings nor Encodings" do
+ string = mock('string')
+ string.should_receive(:to_str).at_least(1).and_return('US-ASCII')
+ Encoding.default_external = string
+ Encoding.default_external.should == Encoding::ASCII
+ end
- it "raises an ArgumentError if the argument is nil" do
- -> { Encoding.default_external = nil }.should raise_error(ArgumentError)
+ it "raises a TypeError unless the argument is an Encoding or convertible to a String" do
+ lambda { Encoding.default_external = [] }.should raise_error(TypeError)
+ end
+
+ it "raises an ArgumentError if the argument is nil" do
+ lambda { Encoding.default_external = nil }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/encoding/default_internal_spec.rb b/spec/ruby/core/encoding/default_internal_spec.rb
index 855f4e9f32..3234929eec 100644
--- a/spec/ruby/core/encoding/default_internal_spec.rb
+++ b/spec/ruby/core/encoding/default_internal_spec.rb
@@ -1,74 +1,93 @@
-require_relative '../../spec_helper'
-
-describe "Encoding.default_internal" do
- before :each do
- @original_encoding = Encoding.default_internal
+require File.expand_path('../../../spec_helper', __FILE__)
+
+with_feature :encoding do
+ describe "Encoding.default_internal" do
+ before :each do
+ @original_encoding = Encoding.default_internal
+ end
+
+ after :each do
+ Encoding.default_internal = @original_encoding
+ end
+
+ it "is nil by default" do
+ Encoding.default_internal.should be_nil
+ end
+
+ it "returns an Encoding object if a default internal encoding is set" do
+ Encoding.default_internal = Encoding::ASCII
+ Encoding.default_internal.should be_an_instance_of(Encoding)
+ end
+
+ it "returns nil if no default internal encoding is set" do
+ Encoding.default_internal = nil
+ Encoding.default_internal.should be_nil
+ end
+
+ it "returns the default internal encoding" do
+ Encoding.default_internal = Encoding::ASCII_8BIT
+ Encoding.default_internal.should == Encoding::ASCII_8BIT
+ end
+
+ describe "with command line options" do
+ it "returns Encoding::UTF_8 if ruby was invoked with -U" do
+ ruby_exe("print Encoding.default_internal", options: '-U').
+ should == 'UTF-8'
+ end
+
+ it "uses the encoding specified when ruby is invoked with an '-E :internal' argument" do
+ ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS').
+ should == 'Shift_JIS'
+ end
+
+ it "uses the encoding specified when ruby is invoked with an '-E external:internal' argument" do
+ ruby_exe("print Encoding.default_internal", options: '-E UTF-8:SHIFT_JIS').
+ should == 'Shift_JIS'
+ end
+ end
end
- after :each do
- Encoding.default_internal = @original_encoding
- end
+ describe "Encoding.default_internal=" do
+ before :each do
+ @original_encoding = Encoding.default_internal
+ end
- it "is nil by default" do
- Encoding.default_internal.should be_nil
- end
+ after :each do
+ Encoding.default_internal = @original_encoding
+ end
- it "returns an Encoding object if a default internal encoding is set" do
- Encoding.default_internal = Encoding::ASCII
- Encoding.default_internal.should be_an_instance_of(Encoding)
- end
+ it "sets the default internal encoding" do
+ Encoding.default_internal = Encoding::SHIFT_JIS
+ Encoding.default_internal.should == Encoding::SHIFT_JIS
+ end
- it "returns nil if no default internal encoding is set" do
- Encoding.default_internal = nil
- Encoding.default_internal.should be_nil
- end
+ it "can accept a name of an encoding as a String" do
+ Encoding.default_internal = 'Shift_JIS'
+ Encoding.default_internal.should == Encoding::SHIFT_JIS
+ end
- it "returns the default internal encoding" do
- Encoding.default_internal = Encoding::BINARY
- Encoding.default_internal.should == Encoding::BINARY
- end
-end
+ it "calls #to_str to convert an object to a String" do
+ obj = mock('string')
+ obj.should_receive(:to_str).at_least(1).times.and_return('ascii')
-describe "Encoding.default_internal=" do
- before :each do
- @original_encoding = Encoding.default_internal
- end
+ Encoding.default_internal = obj
+ Encoding.default_internal.should == Encoding::ASCII
+ end
- after :each do
- Encoding.default_internal = @original_encoding
- end
+ it "raises a TypeError if #to_str does not return a String" do
+ obj = mock('string')
+ obj.should_receive(:to_str).at_least(1).times.and_return(1)
- it "sets the default internal encoding" do
- Encoding.default_internal = Encoding::SHIFT_JIS
- Encoding.default_internal.should == Encoding::SHIFT_JIS
- end
+ lambda { Encoding.default_internal = obj }.should raise_error(TypeError)
+ end
- it "can accept a name of an encoding as a String" do
- Encoding.default_internal = 'Shift_JIS'
- Encoding.default_internal.should == Encoding::SHIFT_JIS
- end
-
- it "calls #to_str to convert an object to a String" do
- obj = mock('string')
- obj.should_receive(:to_str).at_least(1).times.and_return('ascii')
-
- Encoding.default_internal = obj
- Encoding.default_internal.should == Encoding::ASCII
- end
-
- it "raises a TypeError if #to_str does not return a String" do
- obj = mock('string')
- obj.should_receive(:to_str).at_least(1).times.and_return(1)
-
- -> { Encoding.default_internal = obj }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed an object not providing #to_str" do
- -> { Encoding.default_internal = mock("encoding") }.should raise_error(TypeError)
- end
+ it "raises a TypeError when passed an object not providing #to_str" do
+ lambda { Encoding.default_internal = mock("encoding") }.should raise_error(TypeError)
+ end
- it "accepts an argument of nil to unset the default internal encoding" do
- Encoding.default_internal = nil
- Encoding.default_internal.should be_nil
+ it "accepts an argument of nil to unset the default internal encoding" do
+ Encoding.default_internal = nil
+ Encoding.default_internal.should be_nil
+ end
end
end
diff --git a/spec/ruby/core/encoding/dummy_spec.rb b/spec/ruby/core/encoding/dummy_spec.rb
index 75ffcd5a4e..7917c71e47 100644
--- a/spec/ruby/core/encoding/dummy_spec.rb
+++ b/spec/ruby/core/encoding/dummy_spec.rb
@@ -1,14 +1,16 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding#dummy?" do
- it "returns false for proper encodings" do
- Encoding::UTF_8.dummy?.should be_false
- Encoding::ASCII.dummy?.should be_false
- end
+with_feature :encoding do
+ describe "Encoding#dummy?" do
+ it "returns false for proper encodings" do
+ Encoding::UTF_8.dummy?.should be_false
+ Encoding::ASCII.dummy?.should be_false
+ end
- it "returns true for dummy encodings" do
- Encoding::ISO_2022_JP.dummy?.should be_true
- Encoding::CP50221.dummy?.should be_true
- Encoding::UTF_7.dummy?.should be_true
+ it "returns true for dummy encodings" do
+ Encoding::ISO_2022_JP.dummy?.should be_true
+ Encoding::CP50221.dummy?.should be_true
+ Encoding::UTF_7.dummy?.should be_true
+ end
end
end
diff --git a/spec/ruby/core/encoding/find_spec.rb b/spec/ruby/core/encoding/find_spec.rb
index 8a0873070f..bd195f6a1a 100644
--- a/spec/ruby/core/encoding/find_spec.rb
+++ b/spec/ruby/core/encoding/find_spec.rb
@@ -1,82 +1,84 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding.find" do
- before :all do
- @encodings = Encoding.aliases.to_a.flatten.uniq
- end
+with_feature :encoding do
+ describe "Encoding.find" do
+ before :all do
+ @encodings = Encoding.aliases.to_a.flatten.uniq
+ end
- it "returns the corresponding Encoding object if given a valid encoding name" do
- @encodings.each do |enc|
- Encoding.find(enc).should be_an_instance_of(Encoding)
+ it "returns the corresponding Encoding object if given a valid encoding name" do
+ @encodings.each do |enc|
+ Encoding.find(enc).should be_an_instance_of(Encoding)
+ end
end
- end
- it "returns the corresponding Encoding object if given a valid alias name" do
- Encoding.aliases.keys.each do |enc_alias|
- Encoding.find(enc_alias).should be_an_instance_of(Encoding)
+ it "returns the corresponding Encoding object if given a valid alias name" do
+ Encoding.aliases.keys.each do |enc_alias|
+ Encoding.find(enc_alias).should be_an_instance_of(Encoding)
+ end
end
- end
- it "raises a TypeError if passed a Symbol" do
- -> { Encoding.find(:"utf-8") }.should raise_error(TypeError)
- end
+ it "raises a TypeError if passed a Symbol" do
+ lambda { Encoding.find(:"utf-8") }.should raise_error(TypeError)
+ end
- it "returns the passed Encoding object" do
- Encoding.find(Encoding::UTF_8).should == Encoding::UTF_8
- end
+ it "returns the passed Encoding object" do
+ Encoding.find(Encoding::UTF_8).should == Encoding::UTF_8
+ end
- it "accepts encoding names as Strings" do
- Encoding.list.each do |enc|
- Encoding.find(enc.name).should == enc
+ it "accepts encoding names as Strings" do
+ Encoding.list.each do |enc|
+ Encoding.find(enc.name).should == enc
+ end
end
- end
- it "accepts any object as encoding name, if it responds to #to_str" do
- obj = Class.new do
- attr_writer :encoding_name
- def to_str; @encoding_name; end
- end.new
+ it "accepts any object as encoding name, if it responds to #to_str" do
+ obj = Class.new do
+ attr_writer :encoding_name
+ def to_str; @encoding_name; end
+ end.new
- Encoding.list.each do |enc|
- obj.encoding_name = enc.name
- Encoding.find(obj).should == enc
+ Encoding.list.each do |enc|
+ obj.encoding_name = enc.name
+ Encoding.find(obj).should == enc
+ end
end
- end
- it "is case insensitive" do
- @encodings.each do |enc|
- Encoding.find(enc.upcase).should == Encoding.find(enc)
+ it "is case insensitive" do
+ @encodings.each do |enc|
+ Encoding.find(enc.upcase).should == Encoding.find(enc)
+ end
end
- end
- it "raises an ArgumentError if the given encoding does not exist" do
- -> { Encoding.find('dh2dh278d') }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError if the given encoding does not exist" do
+ lambda { Encoding.find('dh2dh278d') }.should raise_error(ArgumentError)
+ end
- # Not sure how to do a better test, since locale depends on weird platform-specific stuff
- it "supports the 'locale' encoding alias" do
- enc = Encoding.find('locale')
- enc.should_not == nil
- end
+ # Not sure how to do a better test, since locale depends on weird platform-specific stuff
+ it "supports the 'locale' encoding alias" do
+ enc = Encoding.find('locale')
+ enc.should_not == nil
+ end
- it "returns default external encoding for the 'external' encoding alias" do
- enc = Encoding.find('external')
- enc.should == Encoding.default_external
- end
+ it "returns default external encoding for the 'external' encoding alias" do
+ enc = Encoding.find('external')
+ enc.should == Encoding.default_external
+ end
- it "returns default internal encoding for the 'internal' encoding alias" do
- enc = Encoding.find('internal')
- enc.should == Encoding.default_internal
- end
+ it "returns default internal encoding for the 'internal' encoding alias" do
+ enc = Encoding.find('internal')
+ enc.should == Encoding.default_internal
+ end
- platform_is_not :windows do
- it "uses default external encoding for the 'filesystem' encoding alias" do
- enc = Encoding.find('filesystem')
- enc.should == Encoding.default_external
+ platform_is_not :windows do
+ it "uses default external encoding for the 'filesystem' encoding alias" do
+ enc = Encoding.find('filesystem')
+ enc.should == Encoding.default_external
+ end
end
- end
- platform_is :windows do
- it "needs to be reviewed for spec completeness"
+ platform_is :windows do
+ it "needs to be reviewed for spec completeness"
+ end
end
end
diff --git a/spec/ruby/core/encoding/inspect_spec.rb b/spec/ruby/core/encoding/inspect_spec.rb
index 9a930b2a77..771232e433 100644
--- a/spec/ruby/core/encoding/inspect_spec.rb
+++ b/spec/ruby/core/encoding/inspect_spec.rb
@@ -1,19 +1,21 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding#inspect" do
- it "returns a String" do
- Encoding::UTF_8.inspect.should be_an_instance_of(String)
- end
+with_feature :encoding do
+ describe "Encoding#inspect" do
+ it "returns a String" do
+ Encoding::UTF_8.inspect.should be_an_instance_of(String)
+ end
- it "returns #<Encoding:name> for a non-dummy encoding named 'name'" do
- Encoding.list.to_a.reject {|e| e.dummy? }.each do |enc|
- enc.inspect.should =~ /#<Encoding:#{enc.name}>/
+ it "returns #<Encoding:name> for a non-dummy encoding named 'name'" do
+ Encoding.list.to_a.reject {|e| e.dummy? }.each do |enc|
+ enc.inspect.should =~ /#<Encoding:#{enc.name}>/
+ end
end
- end
- it "returns #<Encoding:name (dummy)> for a dummy encoding named 'name'" do
- Encoding.list.to_a.select {|e| e.dummy? }.each do |enc|
- enc.inspect.should =~ /#<Encoding:#{enc.name} \(dummy\)>/
+ it "returns #<Encoding:name (dummy)> for a dummy encoding named 'name'" do
+ Encoding.list.to_a.select {|e| e.dummy? }.each do |enc|
+ enc.inspect.should =~ /#<Encoding:#{enc.name} \(dummy\)>/
+ end
end
end
end
diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb
index f5fa6f55e3..790dd18655 100644
--- a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb
+++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb
@@ -1,18 +1,20 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::InvalidByteSequenceError#destination_encoding_name" do
- before :each do
- @exception, = EncodingSpecs::InvalidByteSequenceError.exception
- @exception2, = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::InvalidByteSequenceError#destination_encoding_name" do
+ before :each do
+ @exception, = EncodingSpecs::InvalidByteSequenceError.exception
+ @exception2, = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
+ end
- it "returns a String" do
- @exception.destination_encoding_name.should be_an_instance_of(String)
- @exception2.destination_encoding_name.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @exception.destination_encoding_name.should be_an_instance_of(String)
+ @exception2.destination_encoding_name.should be_an_instance_of(String)
+ end
- it "is equal to the destination encoding name of the object that raised it" do
- @exception.destination_encoding_name.should == "ISO-8859-1"
- @exception2.destination_encoding_name.should == "UTF-8"
+ it "is equal to the destination encoding name of the object that raised it" do
+ @exception.destination_encoding_name.should == "ISO-8859-1"
+ @exception2.destination_encoding_name.should == "UTF-8"
+ end
end
end
diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb
index 43be3ddd71..981a62424e 100644
--- a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb
+++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb
@@ -1,18 +1,20 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::InvalidByteSequenceError#destination_encoding" do
- before :each do
- @exception, = EncodingSpecs::InvalidByteSequenceError.exception
- @exception2, = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::InvalidByteSequenceError#destination_encoding" do
+ before :each do
+ @exception, = EncodingSpecs::InvalidByteSequenceError.exception
+ @exception2, = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
+ end
- it "returns an Encoding object" do
- @exception.destination_encoding.should be_an_instance_of(Encoding)
- @exception2.destination_encoding.should be_an_instance_of(Encoding)
- end
+ it "returns an Encoding object" do
+ @exception.destination_encoding.should be_an_instance_of(Encoding)
+ @exception2.destination_encoding.should be_an_instance_of(Encoding)
+ end
- it "is equal to the destination encoding of the object that raised it" do
- @exception.destination_encoding.should == Encoding::ISO_8859_1
- @exception2.destination_encoding.should == Encoding::UTF_8
+ it "is equal to the destination encoding of the object that raised it" do
+ @exception.destination_encoding.should == Encoding::ISO_8859_1
+ @exception2.destination_encoding.should == Encoding::UTF_8
+ end
end
end
diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb
index a8f7354b16..633ad2e1f7 100644
--- a/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb
+++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb
@@ -1,30 +1,32 @@
# -*- encoding: binary -*-
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::InvalidByteSequenceError#error_bytes" do
- before :each do
- @exception, @errinfo = EncodingSpecs::InvalidByteSequenceError.exception
- @exception2, @errinfo2 = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::InvalidByteSequenceError#error_bytes" do
+ before :each do
+ @exception, @errinfo = EncodingSpecs::InvalidByteSequenceError.exception
+ @exception2, @errinfo2 = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
+ end
- it "returns a String" do
- @exception.error_bytes.should be_an_instance_of(String)
- @exception2.error_bytes.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @exception.error_bytes.should be_an_instance_of(String)
+ @exception2.error_bytes.should be_an_instance_of(String)
+ end
- it "returns the bytes that caused the exception" do
- @exception.error_bytes.size.should == 1
- @exception.error_bytes.should == "\xF1"
- @exception.error_bytes.should == @errinfo[-2]
+ it "returns the bytes that caused the exception" do
+ @exception.error_bytes.size.should == 1
+ @exception.error_bytes.should == "\xF1"
+ @exception.error_bytes.should == @errinfo[-2]
- @exception2.error_bytes.size.should == 1
- @exception2.error_bytes.should == "\xA1"
- @exception2.error_bytes.should == @errinfo2[-2]
- end
+ @exception2.error_bytes.size.should == 1
+ @exception2.error_bytes.should == "\xA1"
+ @exception2.error_bytes.should == @errinfo2[-2]
+ end
- it "uses BINARY as the encoding" do
- @exception.error_bytes.encoding.should == Encoding::BINARY
+ it "uses ASCII-8BIT as the encoding" do
+ @exception.error_bytes.encoding.should == Encoding::ASCII_8BIT
- @exception2.error_bytes.encoding.should == Encoding::BINARY
+ @exception2.error_bytes.encoding.should == Encoding::ASCII_8BIT
+ end
end
end
diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb
index e3ef3e4557..c79a6663e2 100644
--- a/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb
+++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb
@@ -1,29 +1,31 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
-describe "Encoding::InvalidByteSequenceError#incomplete_input?" do
+with_feature :encoding do
+ describe "Encoding::InvalidByteSequenceError#incomplete_input?" do
- it "returns nil by default" do
- Encoding::InvalidByteSequenceError.new.incomplete_input?.should be_nil
- end
+ it "returns nil by default" do
+ Encoding::InvalidByteSequenceError.new.incomplete_input?.should be_nil
+ end
- it "returns true if #primitive_convert returned :incomplete_input for the same data" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- ec.primitive_convert("\xA1",'').should == :incomplete_input
- begin
- ec.convert("\xA1")
- rescue Encoding::InvalidByteSequenceError => e
- e.incomplete_input?.should be_true
+ it "returns true if #primitive_convert returned :incomplete_input for the same data" do
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
+ ec.primitive_convert("\xA1",'').should == :incomplete_input
+ begin
+ ec.convert("\xA1")
+ rescue Encoding::InvalidByteSequenceError => e
+ e.incomplete_input?.should be_true
+ end
end
- end
- it "returns false if #primitive_convert returned :invalid_byte_sequence for the same data" do
- ec = Encoding::Converter.new("ascii", "utf-8")
- ec.primitive_convert("\xfffffffff",'').should == :invalid_byte_sequence
- begin
- ec.convert("\xfffffffff")
- rescue Encoding::InvalidByteSequenceError => e
- e.incomplete_input?.should be_false
+ it "returns false if #primitive_convert returned :invalid_byte_sequence for the same data" do
+ ec = Encoding::Converter.new("ascii", "utf-8")
+ ec.primitive_convert("\xfffffffff",'').should == :invalid_byte_sequence
+ begin
+ ec.convert("\xfffffffff")
+ rescue Encoding::InvalidByteSequenceError => e
+ e.incomplete_input?.should be_false
+ end
end
end
end
diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb
index 93823b5db4..31408a4320 100644
--- a/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb
+++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb
@@ -1,30 +1,32 @@
# -*- encoding: binary -*-
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::InvalidByteSequenceError#readagain_bytes" do
- before :each do
- @exception, @errinfo = EncodingSpecs::InvalidByteSequenceError.exception
- @exception2, @errinfo2 = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::InvalidByteSequenceError#readagain_bytes" do
+ before :each do
+ @exception, @errinfo = EncodingSpecs::InvalidByteSequenceError.exception
+ @exception2, @errinfo2 = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
+ end
- it "returns a String" do
- @exception.readagain_bytes.should be_an_instance_of(String)
- @exception2.readagain_bytes.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @exception.readagain_bytes.should be_an_instance_of(String)
+ @exception2.readagain_bytes.should be_an_instance_of(String)
+ end
- it "returns the bytes to be read again" do
- @exception.readagain_bytes.size.should == 1
- @exception.readagain_bytes.should == "a".force_encoding('binary')
- @exception.readagain_bytes.should == @errinfo[-1]
+ it "returns the bytes to be read again" do
+ @exception.readagain_bytes.size.should == 1
+ @exception.readagain_bytes.should == "a".force_encoding('binary')
+ @exception.readagain_bytes.should == @errinfo[-1]
- @exception2.readagain_bytes.size.should == 1
- @exception2.readagain_bytes.should == "\xFF".force_encoding('binary')
- @exception2.readagain_bytes.should == @errinfo2[-1]
- end
+ @exception2.readagain_bytes.size.should == 1
+ @exception2.readagain_bytes.should == "\xFF".force_encoding('binary')
+ @exception2.readagain_bytes.should == @errinfo2[-1]
+ end
- it "uses BINARY as the encoding" do
- @exception.readagain_bytes.encoding.should == Encoding::BINARY
+ it "uses ASCII-8BIT as the encoding" do
+ @exception.readagain_bytes.encoding.should == Encoding::ASCII_8BIT
- @exception2.readagain_bytes.encoding.should == Encoding::BINARY
+ @exception2.readagain_bytes.encoding.should == Encoding::ASCII_8BIT
+ end
end
end
diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb
index bd3a51cbc5..428b292c68 100644
--- a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb
+++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb
@@ -1,28 +1,30 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::UndefinedConversionError#source_encoding_name" do
- before :each do
- @exception, = EncodingSpecs::UndefinedConversionError.exception
- @exception2, = EncodingSpecs::UndefinedConversionErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::UndefinedConversionError#source_encoding_name" do
+ before :each do
+ @exception, = EncodingSpecs::UndefinedConversionError.exception
+ @exception2, = EncodingSpecs::UndefinedConversionErrorIndirect.exception
+ end
- it "returns a String" do
- @exception.source_encoding_name.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @exception.source_encoding_name.should be_an_instance_of(String)
+ end
- it "is equal to the source encoding name of the object that raised it" do
- @exception.source_encoding_name.should == "UTF-8"
- end
+ it "is equal to the source encoding name of the object that raised it" do
+ @exception.source_encoding_name.should == "UTF-8"
+ end
- # The source encoding specified in the Encoding::Converter constructor may
- # differ from the source encoding returned here. What seems to happen is
- # that when transcoding along a path with multiple pairs of encodings, the
- # last one encountered when the error occurred is returned. So in this
- # case, the conversion path is ISO-8859-1 -> UTF-8 -> EUC-JP. The
- # conversion from ISO-8859-1 -> UTF-8 succeeded, but the conversion from
- # UTF-8 to EUC-JP failed. IOW, it failed when the source encoding was
- # UTF-8, so UTF-8 is regarded as the source encoding.
- it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
- @exception2.source_encoding_name.should == 'UTF-8'
+ # The source encoding specified in the Encoding::Converter constructor may
+ # differ from the source encoding returned here. What seems to happen is
+ # that when transcoding along a path with multiple pairs of encodings, the
+ # last one encountered when the error occurred is returned. So in this
+ # case, the conversion path is ISO-8859-1 -> UTF-8 -> EUC-JP. The
+ # conversion from ISO-8859-1 -> UTF-8 succeeded, but the conversion from
+ # UTF-8 to EUC-JP failed. IOW, it failed when the source encoding was
+ # UTF-8, so UTF-8 is regarded as the source encoding.
+ it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
+ @exception2.source_encoding_name.should == 'UTF-8'
+ end
end
end
diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb
index f43d6d5830..09379acc5d 100644
--- a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb
+++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb
@@ -1,33 +1,35 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::InvalidByteSequenceError#source_encoding" do
- before :each do
- @exception, = EncodingSpecs::InvalidByteSequenceError.exception
- @exception2, = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::InvalidByteSequenceError#source_encoding" do
+ before :each do
+ @exception, = EncodingSpecs::InvalidByteSequenceError.exception
+ @exception2, = EncodingSpecs::InvalidByteSequenceErrorIndirect.exception
+ end
- it "returns an Encoding object" do
- @exception.source_encoding.should be_an_instance_of(Encoding)
- @exception2.source_encoding.should be_an_instance_of(Encoding)
- end
+ it "returns an Encoding object" do
+ @exception.source_encoding.should be_an_instance_of(Encoding)
+ @exception2.source_encoding.should be_an_instance_of(Encoding)
+ end
- it "is equal to the source encoding of the object that raised it" do
- @exception.source_encoding.should == Encoding::UTF_8
- end
+ it "is equal to the source encoding of the object that raised it" do
+ @exception.source_encoding.should == Encoding::UTF_8
+ end
- # The source encoding specified in the Encoding::Converter constructor may
- # differ from the source encoding returned here. What seems to happen is
- # that when transcoding along a path with multiple pairs of encodings, the
- # last one encountered when the error occurred is returned. So in this
- # case, the conversion path is EUC-JP -> UTF-8 -> ISO-8859-1. The
- # conversions failed with the first pair of encodings (i.e. transcoding
- # from EUC-JP to UTF-8, so UTF-8 is regarded as the source encoding; if
- # the error had occurred when converting from UTF-8 to ISO-8859-1, UTF-8
- # would have been the source encoding.
+ # The source encoding specified in the Encoding::Converter constructor may
+ # differ from the source encoding returned here. What seems to happen is
+ # that when transcoding along a path with multiple pairs of encodings, the
+ # last one encountered when the error occurred is returned. So in this
+ # case, the conversion path is EUC-JP -> UTF-8 -> ISO-8859-1. The
+ # conversions failed with the first pair of encodings (i.e. transcoding
+ # from EUC-JP to UTF-8, so UTF-8 is regarded as the source encoding; if
+ # the error had occurred when converting from UTF-8 to ISO-8859-1, UTF-8
+ # would have been the source encoding.
- # FIXME: Derive example where the failure occurs at the UTF-8 ->
- # ISO-8859-1 case so as to better illustrate the issue
- it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
- @exception2.source_encoding.should == Encoding::EUC_JP
+ # FIXME: Derive example where the failure occurs at the UTF-8 ->
+ # ISO-8859-1 case so as to better illustrate the issue
+ it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
+ @exception2.source_encoding.should == Encoding::EUC_JP
+ end
end
end
diff --git a/spec/ruby/core/encoding/list_spec.rb b/spec/ruby/core/encoding/list_spec.rb
index 2a2078974e..18488607e5 100644
--- a/spec/ruby/core/encoding/list_spec.rb
+++ b/spec/ruby/core/encoding/list_spec.rb
@@ -1,41 +1,43 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding.list" do
- it "returns an Array" do
- Encoding.list.should be_an_instance_of(Array)
- end
+with_feature :encoding do
+ describe "Encoding.list" do
+ it "returns an Array" do
+ Encoding.list.should be_an_instance_of(Array)
+ end
- it "returns an Array of Encoding objects" do
- Encoding.list.each do |enc|
- enc.should be_an_instance_of(Encoding)
+ it "returns an Array of Encoding objects" do
+ Encoding.list.each do |enc|
+ enc.should be_an_instance_of(Encoding)
+ end
end
- end
- it "returns each encoding only once" do
- orig = Encoding.list.map {|e| e.name}
- orig.should == orig.uniq
- end
+ it "returns each encoding only once" do
+ orig = Encoding.list.map {|e| e.name}
+ orig.should == orig.uniq
+ end
- it "includes the default external encoding" do
- Encoding.list.include?(Encoding.default_external).should be_true
- end
+ it "includes the default external encoding" do
+ Encoding.list.include?(Encoding.default_external).should be_true
+ end
- it "does not include any alias names" do
- Encoding.aliases.keys.each do |enc_alias|
- Encoding.list.include?(enc_alias).should be_false
+ it "does not include any alias names" do
+ Encoding.aliases.keys.each do |enc_alias|
+ Encoding.list.include?(enc_alias).should be_false
+ end
end
- end
- it "includes all aliased encodings" do
- Encoding.aliases.values.each do |enc_alias|
- Encoding.list.include?(Encoding.find(enc_alias)).should be_true
+ it "includes all aliased encodings" do
+ Encoding.aliases.values.each do |enc_alias|
+ Encoding.list.include?(Encoding.find(enc_alias)).should be_true
+ end
end
- end
- it "includes dummy encodings" do
- Encoding.list.select {|e| e.dummy?}.should_not == []
- end
+ it "includes dummy encodings" do
+ Encoding.list.select {|e| e.dummy?}.should_not == []
+ end
- # TODO: Find example that illustrates this
- it "updates the list when #find is used to load a new encoding"
+ # TODO: Find example that illustrates this
+ it "updates the list when #find is used to load a new encoding"
+ end
end
diff --git a/spec/ruby/core/encoding/locale_charmap_spec.rb b/spec/ruby/core/encoding/locale_charmap_spec.rb
index 5963a8beb5..a9f0cd5ee0 100644
--- a/spec/ruby/core/encoding/locale_charmap_spec.rb
+++ b/spec/ruby/core/encoding/locale_charmap_spec.rb
@@ -1,45 +1,47 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding.locale_charmap" do
- it "returns a String" do
- Encoding.locale_charmap.should be_an_instance_of(String)
- end
+with_feature :encoding do
+ describe "Encoding.locale_charmap" do
+ it "returns a String" do
+ Encoding.locale_charmap.should be_an_instance_of(String)
+ end
- # FIXME: Get this working on Windows
- platform_is :linux do
- it "returns a value based on the LC_ALL environment variable" do
- old_lc_all = ENV['LC_ALL']
- ENV['LC_ALL'] = 'C'
- ruby_exe("print Encoding.locale_charmap").should == 'ANSI_X3.4-1968'
- ENV['LC_ALL'] = old_lc_all
+ # FIXME: Get this working on Windows
+ platform_is :linux do
+ it "returns a value based on the LC_ALL environment variable" do
+ old_lc_all = ENV['LC_ALL']
+ ENV['LC_ALL'] = 'C'
+ ruby_exe("print Encoding.locale_charmap").should == 'ANSI_X3.4-1968'
+ ENV['LC_ALL'] = old_lc_all
+ end
end
- end
- platform_is :freebsd, :openbsd, :darwin do
- it "returns a value based on the LC_ALL environment variable" do
- old_lc_all = ENV['LC_ALL']
- ENV['LC_ALL'] = 'C'
- ruby_exe("print Encoding.locale_charmap").should == 'US-ASCII'
- ENV['LC_ALL'] = old_lc_all
+ platform_is :freebsd, :openbsd, :darwin do
+ it "returns a value based on the LC_ALL environment variable" do
+ old_lc_all = ENV['LC_ALL']
+ ENV['LC_ALL'] = 'C'
+ ruby_exe("print Encoding.locale_charmap").should == 'US-ASCII'
+ ENV['LC_ALL'] = old_lc_all
+ end
end
- end
- platform_is :netbsd do
- it "returns a value based on the LC_ALL environment variable" do
- old_lc_all = ENV['LC_ALL']
- ENV['LC_ALL'] = 'C'
- ruby_exe("print Encoding.locale_charmap").should == '646'
- ENV['LC_ALL'] = old_lc_all
+ platform_is :netbsd do
+ it "returns a value based on the LC_ALL environment variable" do
+ old_lc_all = ENV['LC_ALL']
+ ENV['LC_ALL'] = 'C'
+ ruby_exe("print Encoding.locale_charmap").should == '646'
+ ENV['LC_ALL'] = old_lc_all
+ end
end
- end
- platform_is :bsd, :darwin, :linux do
- it "is unaffected by assigning to ENV['LC_ALL'] in the same process" do
- old_charmap = Encoding.locale_charmap
- old_lc_all = ENV['LC_ALL']
- ENV['LC_ALL'] = 'C'
- Encoding.locale_charmap.should == old_charmap
- ENV['LC_ALL'] = old_lc_all
+ platform_is :bsd, :darwin, :linux do
+ it "is unaffected by assigning to ENV['LC_ALL'] in the same process" do
+ old_charmap = Encoding.locale_charmap
+ old_lc_all = ENV['LC_ALL']
+ ENV['LC_ALL'] = 'C'
+ Encoding.locale_charmap.should == old_charmap
+ ENV['LC_ALL'] = old_lc_all
+ end
end
end
end
diff --git a/spec/ruby/core/encoding/name_list_spec.rb b/spec/ruby/core/encoding/name_list_spec.rb
index 836381c4d8..c06ec410ec 100644
--- a/spec/ruby/core/encoding/name_list_spec.rb
+++ b/spec/ruby/core/encoding/name_list_spec.rb
@@ -1,23 +1,25 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding.name_list" do
- it "returns an Array" do
- Encoding.name_list.should be_an_instance_of(Array)
- end
+with_feature :encoding do
+ describe "Encoding.name_list" do
+ it "returns an Array" do
+ Encoding.name_list.should be_an_instance_of(Array)
+ end
- it "returns encoding names as Strings" do
- Encoding.name_list.each {|e| e.should be_an_instance_of(String) }
- end
+ it "returns encoding names as Strings" do
+ Encoding.name_list.each {|e| e.should be_an_instance_of(String) }
+ end
- it "includes all aliases" do
- Encoding.aliases.keys.each do |enc_alias|
- Encoding.name_list.include?(enc_alias).should be_true
+ it "includes all aliases" do
+ Encoding.aliases.keys.each do |enc_alias|
+ Encoding.name_list.include?(enc_alias).should be_true
+ end
end
- end
- it "includes all non-dummy encodings" do
- Encoding.list.each do |enc|
- Encoding.name_list.include?(enc.name).should be_true
+ it "includes all non-dummy encodings" do
+ Encoding.list.each do |enc|
+ Encoding.name_list.include?(enc.name).should be_true
+ end
end
end
end
diff --git a/spec/ruby/core/encoding/name_spec.rb b/spec/ruby/core/encoding/name_spec.rb
index 5eadb1d2f5..4ea89a563a 100644
--- a/spec/ruby/core/encoding/name_spec.rb
+++ b/spec/ruby/core/encoding/name_spec.rb
@@ -1,5 +1,7 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
-describe "Encoding#name" do
- it_behaves_like :encoding_name, :name
+with_feature :encoding do
+ describe "Encoding#name" do
+ it_behaves_like(:encoding_name, :name)
+ end
end
diff --git a/spec/ruby/core/encoding/names_spec.rb b/spec/ruby/core/encoding/names_spec.rb
index 9ded043bbb..3cd741e513 100644
--- a/spec/ruby/core/encoding/names_spec.rb
+++ b/spec/ruby/core/encoding/names_spec.rb
@@ -1,35 +1,37 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding#names" do
- it "returns an Array" do
- Encoding.name_list.each do |name|
- e = Encoding.find(name) or next
- e.names.should be_an_instance_of(Array)
+with_feature :encoding do
+ describe "Encoding#names" do
+ it "returns an Array" do
+ Encoding.name_list.each do |name|
+ e = Encoding.find(name) or next
+ e.names.should be_an_instance_of(Array)
+ end
end
- end
- it "returns names as Strings" do
- Encoding.name_list.each do |name|
- e = Encoding.find(name) or next
- e.names.each do |this_name|
- this_name.should be_an_instance_of(String)
+ it "returns names as Strings" do
+ Encoding.name_list.each do |name|
+ e = Encoding.find(name) or next
+ e.names.each do |this_name|
+ this_name.should be_an_instance_of(String)
+ end
end
end
- end
- it "returns #name as the first value" do
- Encoding.name_list.each do |name|
- e = Encoding.find(name) or next
- e.names.first.should == e.name
+ it "returns #name as the first value" do
+ Encoding.name_list.each do |name|
+ e = Encoding.find(name) or next
+ e.names.first.should == e.name
+ end
end
- end
- it "includes any aliases the encoding has" do
- Encoding.name_list.each do |name|
- e = Encoding.find(name) or next
- aliases = Encoding.aliases.select{|a,n| n == name}.keys
- names = e.names
- aliases.each {|a| names.include?(a).should be_true}
+ it "includes any aliases the encoding has" do
+ Encoding.name_list.each do |name|
+ e = Encoding.find(name) or next
+ aliases = Encoding.aliases.select{|a,n| n == name}.keys
+ names = e.names
+ aliases.each {|a| names.include?(a).should be_true}
+ end
end
end
end
diff --git a/spec/ruby/core/encoding/replicate_spec.rb b/spec/ruby/core/encoding/replicate_spec.rb
index 717e9cea72..5d007dd827 100644
--- a/spec/ruby/core/encoding/replicate_spec.rb
+++ b/spec/ruby/core/encoding/replicate_spec.rb
@@ -1,46 +1,48 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Encoding#replicate" do
- before :all do
- @i = 0
- end
+with_feature :encoding do
+ describe "Encoding#replicate" do
+ before :all do
+ @i = 0
+ end
- before :each do
- @i += 1
- @prefix = "RS#{@i}"
- end
+ before :each do
+ @i += 1
+ @prefix = "RS#{@i}"
+ end
- it "returns a replica of ASCII" do
- name = @prefix + '-ASCII'
- e = Encoding::ASCII.replicate(name)
- e.name.should == name
- "a".force_encoding(e).valid_encoding?.should be_true
- "\x80".force_encoding(e).valid_encoding?.should be_false
- end
+ it "returns a replica of ASCII" do
+ name = @prefix + '-ASCII'
+ e = Encoding::ASCII.replicate(name)
+ e.name.should == name
+ "a".force_encoding(e).valid_encoding?.should be_true
+ "\x80".force_encoding(e).valid_encoding?.should be_false
+ end
- it "returns a replica of UTF-8" do
- name = @prefix + 'UTF-8'
- e = Encoding::UTF_8.replicate(name)
- e.name.should == name
- "a".force_encoding(e).valid_encoding?.should be_true
- "\u3042".force_encoding(e).valid_encoding?.should be_true
- "\x80".force_encoding(e).valid_encoding?.should be_false
- end
+ it "returns a replica of UTF-8" do
+ name = @prefix + 'UTF-8'
+ e = Encoding::UTF_8.replicate(name)
+ e.name.should == name
+ "a".force_encoding(e).valid_encoding?.should be_true
+ "\u3042".force_encoding(e).valid_encoding?.should be_true
+ "\x80".force_encoding(e).valid_encoding?.should be_false
+ end
- it "returns a replica of UTF-16BE" do
- name = @prefix + 'UTF-16-BE'
- e = Encoding::UTF_16BE.replicate(name)
- e.name.should == name
- "a".force_encoding(e).valid_encoding?.should be_false
- "\x30\x42".force_encoding(e).valid_encoding?.should be_true
- "\x80".force_encoding(e).valid_encoding?.should be_false
- end
+ it "returns a replica of UTF-16BE" do
+ name = @prefix + 'UTF-16-BE'
+ e = Encoding::UTF_16BE.replicate(name)
+ e.name.should == name
+ "a".force_encoding(e).valid_encoding?.should be_false
+ "\x30\x42".force_encoding(e).valid_encoding?.should be_true
+ "\x80".force_encoding(e).valid_encoding?.should be_false
+ end
- it "returns a replica of ISO-2022-JP" do
- name = @prefix + 'ISO-2022-JP'
- e = Encoding::ISO_2022_JP.replicate(name)
- e.name.should == name
- e.dummy?.should be_true
+ it "returns a replica of ISO-2022-JP" do
+ name = @prefix + 'ISO-2022-JP'
+ e = Encoding::ISO_2022_JP.replicate(name)
+ e.name.should == name
+ e.dummy?.should be_true
+ end
end
end
diff --git a/spec/ruby/core/encoding/shared/name.rb b/spec/ruby/core/encoding/shared/name.rb
index cd37ea06db..7f85c46764 100644
--- a/spec/ruby/core/encoding/shared/name.rb
+++ b/spec/ruby/core/encoding/shared/name.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :encoding_name, shared: true do
it "returns a String" do
diff --git a/spec/ruby/core/encoding/to_s_spec.rb b/spec/ruby/core/encoding/to_s_spec.rb
index 82d282386b..ddc57e321e 100644
--- a/spec/ruby/core/encoding/to_s_spec.rb
+++ b/spec/ruby/core/encoding/to_s_spec.rb
@@ -1,5 +1,7 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
-describe "Encoding#to_s" do
- it_behaves_like :encoding_name, :to_s
+with_feature :encoding do
+ describe "Encoding#to_s" do
+ it_behaves_like(:encoding_name, :to_s)
+ end
end
diff --git a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb
index 106fc7ecac..2f7f33e45e 100644
--- a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb
+++ b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb
@@ -1,15 +1,17 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::UndefinedConversionError#destination_encoding_name" do
- before :each do
- @exception = EncodingSpecs::UndefinedConversionError.exception
- end
+with_feature :encoding do
+ describe "Encoding::UndefinedConversionError#destination_encoding_name" do
+ before :each do
+ @exception = EncodingSpecs::UndefinedConversionError.exception
+ end
- it "returns a String" do
- @exception.destination_encoding_name.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @exception.destination_encoding_name.should be_an_instance_of(String)
+ end
- it "is equal to the destination encoding name of the object that raised it" do
- @exception.destination_encoding_name.should == "US-ASCII"
+ it "is equal to the destination encoding name of the object that raised it" do
+ @exception.destination_encoding_name.should == "US-ASCII"
+ end
end
end
diff --git a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb
index c6e24732fd..6d4f42c0d8 100644
--- a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb
+++ b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb
@@ -1,15 +1,17 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::UndefinedConversionError#destination_encoding" do
- before :each do
- @exception = EncodingSpecs::UndefinedConversionError.exception
- end
+with_feature :encoding do
+ describe "Encoding::UndefinedConversionError#destination_encoding" do
+ before :each do
+ @exception = EncodingSpecs::UndefinedConversionError.exception
+ end
- it "returns an Encoding object" do
- @exception.destination_encoding.should be_an_instance_of(Encoding)
- end
+ it "returns an Encoding object" do
+ @exception.destination_encoding.should be_an_instance_of(Encoding)
+ end
- it "is equal to the destination encoding of the object that raised it" do
- @exception.destination_encoding.should == Encoding::US_ASCII
+ it "is equal to the destination encoding of the object that raised it" do
+ @exception.destination_encoding.should == Encoding::US_ASCII
+ end
end
end
diff --git a/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb
index 780d81c1ee..7f538a60d6 100644
--- a/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb
+++ b/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb
@@ -1,27 +1,29 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::UndefinedConversionError#error_char" do
- before :each do
- @exception = EncodingSpecs::UndefinedConversionError.exception
- @exception2 = EncodingSpecs::UndefinedConversionErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::UndefinedConversionError#error_char" do
+ before :each do
+ @exception = EncodingSpecs::UndefinedConversionError.exception
+ @exception2 = EncodingSpecs::UndefinedConversionErrorIndirect.exception
+ end
- it "returns a String" do
- @exception.error_char.should be_an_instance_of(String)
- @exception2.error_char.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @exception.error_char.should be_an_instance_of(String)
+ @exception2.error_char.should be_an_instance_of(String)
+ end
- it "returns the one-character String that caused the exception" do
- @exception.error_char.size.should == 1
- @exception.error_char.should == "\u{8765}"
+ it "returns the one-character String that caused the exception" do
+ @exception.error_char.size.should == 1
+ @exception.error_char.should == "\u{8765}"
- @exception2.error_char.size.should == 1
- @exception2.error_char.should == "\u{A0}"
- end
+ @exception2.error_char.size.should == 1
+ @exception2.error_char.should == "\u{A0}"
+ end
- it "uses the source encoding" do
- @exception.error_char.encoding.should == @exception.source_encoding
+ it "uses the source encoding" do
+ @exception.error_char.encoding.should == @exception.source_encoding
- @exception2.error_char.encoding.should == @exception2.source_encoding
+ @exception2.error_char.encoding.should == @exception2.source_encoding
+ end
end
end
diff --git a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb
index 3b697cb82f..742184250f 100644
--- a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb
+++ b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb
@@ -1,28 +1,30 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::UndefinedConversionError#source_encoding_name" do
- before :each do
- @exception = EncodingSpecs::UndefinedConversionError.exception
- @exception2 = EncodingSpecs::UndefinedConversionErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::UndefinedConversionError#source_encoding_name" do
+ before :each do
+ @exception = EncodingSpecs::UndefinedConversionError.exception
+ @exception2 = EncodingSpecs::UndefinedConversionErrorIndirect.exception
+ end
- it "returns a String" do
- @exception.source_encoding_name.should be_an_instance_of(String)
- end
+ it "returns a String" do
+ @exception.source_encoding_name.should be_an_instance_of(String)
+ end
- it "is equal to the source encoding name of the object that raised it" do
- @exception.source_encoding_name.should == "UTF-8"
- end
+ it "is equal to the source encoding name of the object that raised it" do
+ @exception.source_encoding_name.should == "UTF-8"
+ end
- # The source encoding specified in the Encoding::Converter constructor may
- # differ from the source encoding returned here. What seems to happen is
- # that when transcoding along a path with multiple pairs of encodings, the
- # last one encountered when the error occurred is returned. So in this
- # case, the conversion path is ISO-8859-1 -> UTF-8 -> EUC-JP. The
- # conversion from ISO-8859-1 -> UTF-8 succeeded, but the conversion from
- # UTF-8 to EUC-JP failed. IOW, it failed when the source encoding was
- # UTF-8, so UTF-8 is regarded as the source encoding.
- it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
- @exception2.source_encoding_name.should == 'UTF-8'
+ # The source encoding specified in the Encoding::Converter constructor may
+ # differ from the source encoding returned here. What seems to happen is
+ # that when transcoding along a path with multiple pairs of encodings, the
+ # last one encountered when the error occurred is returned. So in this
+ # case, the conversion path is ISO-8859-1 -> UTF-8 -> EUC-JP. The
+ # conversion from ISO-8859-1 -> UTF-8 succeeded, but the conversion from
+ # UTF-8 to EUC-JP failed. IOW, it failed when the source encoding was
+ # UTF-8, so UTF-8 is regarded as the source encoding.
+ it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
+ @exception2.source_encoding_name.should == 'UTF-8'
+ end
end
end
diff --git a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb
index 9101d51e11..0489ad82bf 100644
--- a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb
+++ b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb
@@ -1,29 +1,31 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Encoding::UndefinedConversionError#source_encoding" do
- before :each do
- @exception = EncodingSpecs::UndefinedConversionError.exception
- @exception2 = EncodingSpecs::UndefinedConversionErrorIndirect.exception
- end
+with_feature :encoding do
+ describe "Encoding::UndefinedConversionError#source_encoding" do
+ before :each do
+ @exception = EncodingSpecs::UndefinedConversionError.exception
+ @exception2 = EncodingSpecs::UndefinedConversionErrorIndirect.exception
+ end
- it "returns an Encoding object" do
- @exception.source_encoding.should be_an_instance_of(Encoding)
- @exception2.source_encoding.should be_an_instance_of(Encoding)
- end
+ it "returns an Encoding object" do
+ @exception.source_encoding.should be_an_instance_of(Encoding)
+ @exception2.source_encoding.should be_an_instance_of(Encoding)
+ end
- it "is equal to the source encoding of the object that raised it" do
- @exception.source_encoding.should == Encoding::UTF_8
- end
+ it "is equal to the source encoding of the object that raised it" do
+ @exception.source_encoding.should == Encoding::UTF_8
+ end
- # The source encoding specified in the Encoding::Converter constructor may
- # differ from the source encoding returned here. What seems to happen is
- # that when transcoding along a path with multiple pairs of encodings, the
- # last one encountered when the error occurred is returned. So in this
- # case, the conversion path is ISO-8859-1 -> UTF-8 -> EUC-JP. The
- # conversion from ISO-8859-1 -> UTF-8 succeeded, but the conversion from
- # UTF-8 to EUC-JP failed. IOW, it failed when the source encoding was
- # UTF-8, so UTF-8 is regarded as the source encoding.
- it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
- @exception2.source_encoding.should == Encoding::UTF_8
+ # The source encoding specified in the Encoding::Converter constructor may
+ # differ from the source encoding returned here. What seems to happen is
+ # that when transcoding along a path with multiple pairs of encodings, the
+ # last one encountered when the error occurred is returned. So in this
+ # case, the conversion path is ISO-8859-1 -> UTF-8 -> EUC-JP. The
+ # conversion from ISO-8859-1 -> UTF-8 succeeded, but the conversion from
+ # UTF-8 to EUC-JP failed. IOW, it failed when the source encoding was
+ # UTF-8, so UTF-8 is regarded as the source encoding.
+ it "is equal to the source encoding at the stage of the conversion path where the error occurred" do
+ @exception2.source_encoding.should == Encoding::UTF_8
+ end
end
end
diff --git a/spec/ruby/core/enumerable/all_spec.rb b/spec/ruby/core/enumerable/all_spec.rb
index 8af80896a9..9e40315baa 100644
--- a/spec/ruby/core/enumerable/all_spec.rb
+++ b/spec/ruby/core/enumerable/all_spec.rb
@@ -1,12 +1,13 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#all?" do
+
before :each do
@enum = EnumerableSpecs::Numerous.new
@empty = EnumerableSpecs::Empty.new()
- @enum1 = EnumerableSpecs::Numerous.new(0, 1, 2, -1)
- @enum2 = EnumerableSpecs::Numerous.new(nil, false, true)
+ @enum1 = [0, 1, 2, -1]
+ @enum2 = [nil, false, true]
end
it "always returns true on empty enumeration" do
@@ -20,27 +21,12 @@ describe "Enumerable#all?" do
{}.all? { nil }.should == true
end
- it "raises an ArgumentError when more than 1 argument is provided" do
- -> { @enum.all?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { [].all?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { {}.all?(1, 2, 3) }.should raise_error(ArgumentError)
- end
-
- ruby_version_is ""..."2.5" do
- it "raises an ArgumentError when any arguments provided" do
- -> { @enum.all?(Proc.new {}) }.should raise_error(ArgumentError)
- -> { @enum.all?(nil) }.should raise_error(ArgumentError)
- -> { @empty.all?(1) }.should raise_error(ArgumentError)
- -> { @enum1.all?(1) {} }.should raise_error(ArgumentError)
- end
- end
-
it "does not hide exceptions out of #each" do
- -> {
+ lambda {
EnumerableSpecs::ThrowingEach.new.all?
}.should raise_error(RuntimeError)
- -> {
+ lambda {
EnumerableSpecs::ThrowingEach.new.all? { false }
}.should raise_error(RuntimeError)
end
@@ -68,9 +54,20 @@ describe "Enumerable#all?" do
end
it "gathers whole arrays as elements when each yields multiple" do
+ # This spec doesn't spec what it says it does
multi = EnumerableSpecs::YieldsMultiWithFalse.new
multi.all?.should be_true
end
+
+ ruby_version_is "2.5" do
+ describe "given a pattern argument" do
+ # This spec should be replaced by more extensive ones
+ it "returns true iff all match that pattern" do
+ @enum.all?(Integer).should == true
+ @enum2.all?(NilClass).should == false
+ end
+ end
+ end
end
describe "with block" do
@@ -113,89 +110,21 @@ describe "Enumerable#all?" do
end
it "does not hide exceptions out of the block" do
- -> {
+ lambda {
@enum.all? { raise "from block" }
}.should raise_error(RuntimeError)
end
it "gathers initial args as elements when each yields multiple" do
multi = EnumerableSpecs::YieldsMulti.new
- yielded = []
- multi.all? { |e| yielded << e }.should == true
- yielded.should == [1, 3, 6]
+ multi.all? {|e| !(Array === e) }.should be_true
end
it "yields multiple arguments when each yields multiple" do
multi = EnumerableSpecs::YieldsMulti.new
yielded = []
- multi.all? { |*args| yielded << args }.should == true
- yielded.should == [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
- end
- end
-
- ruby_version_is "2.5" do
- describe 'when given a pattern argument' do
- it "calls `===` on the pattern the return value " do
- pattern = EnumerableSpecs::Pattern.new { |x| x >= 0 }
- @enum1.all?(pattern).should == false
- pattern.yielded.should == [[0], [1], [2], [-1]]
- end
-
- # may raise an exception in future versions
- ruby_version_is ""..."2.6" do
- it "ignores block" do
- @enum2.all?(NilClass) { raise }.should == false
- [1, 2, nil].all?(NilClass) { raise }.should == false
- {a: 1}.all?(Array) { raise }.should == true
- end
- end
-
- it "always returns true on empty enumeration" do
- @empty.all?(Integer).should == true
- [].all?(Integer).should == true
- {}.all?(NilClass).should == true
- end
-
- it "does not hide exceptions out of #each" do
- -> {
- EnumerableSpecs::ThrowingEach.new.all?(Integer)
- }.should raise_error(RuntimeError)
- end
-
- it "returns true if the pattern never returns false or nil" do
- pattern = EnumerableSpecs::Pattern.new { |x| 42 }
- @enum.all?(pattern).should == true
-
- [1, 42, 3].all?(pattern).should == true
-
- pattern = EnumerableSpecs::Pattern.new { |x| Array === x }
- {a: 1, b: 2}.all?(pattern).should == true
- end
-
- it "returns false if the pattern ever returns false or nil" do
- pattern = EnumerableSpecs::Pattern.new { |x| x >= 0 }
- @enum1.all?(pattern).should == false
- pattern.yielded.should == [[0], [1], [2], [-1]]
-
- [1, 2, 3, -1].all?(pattern).should == false
-
- pattern = EnumerableSpecs::Pattern.new { |x| x[1] >= 0 }
- {a: 1, b: -1}.all?(pattern).should == false
- end
-
- it "does not hide exceptions out of pattern#===" do
- pattern = EnumerableSpecs::Pattern.new { raise "from pattern" }
- -> {
- @enum.all?(pattern)
- }.should raise_error(RuntimeError)
- end
-
- it "calls the pattern with gathered array when yielded with multiple arguments" do
- multi = EnumerableSpecs::YieldsMulti.new
- pattern = EnumerableSpecs::Pattern.new { true }
- multi.all?(pattern).should == true
- pattern.yielded.should == [[[1, 2]], [[3, 4, 5]], [[6, 7, 8, 9]]]
- end
+ multi.all? {|e, i| yielded << [e, i] }
+ yielded.should == [[1, 2], [3, 4], [6, 7]]
end
end
end
diff --git a/spec/ruby/core/enumerable/any_spec.rb b/spec/ruby/core/enumerable/any_spec.rb
index c800fe2d4b..edf7e36519 100644
--- a/spec/ruby/core/enumerable/any_spec.rb
+++ b/spec/ruby/core/enumerable/any_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#any?" do
before :each do
@enum = EnumerableSpecs::Numerous.new
- @empty = EnumerableSpecs::Empty.new
- @enum1 = EnumerableSpecs::Numerous.new(0, 1, 2, -1)
- @enum2 = EnumerableSpecs::Numerous.new(nil, false, true)
+ @empty = EnumerableSpecs::Empty.new()
+ @enum1 = [0, 1, 2, -1]
+ @enum2 = [nil, false, true]
end
it "always returns false on empty enumeration" do
@@ -21,26 +21,26 @@ describe "Enumerable#any?" do
end
it "raises an ArgumentError when more than 1 argument is provided" do
- -> { @enum.any?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { [].any?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { {}.any?(1, 2, 3) }.should raise_error(ArgumentError)
+ lambda { @enum.any?(1, 2, 3) }.should raise_error(ArgumentError)
+ lambda { [].any?(1, 2, 3) }.should raise_error(ArgumentError)
+ lambda { {}.any?(1, 2, 3) }.should raise_error(ArgumentError)
end
ruby_version_is ""..."2.5" do
it "raises an ArgumentError when any arguments provided" do
- -> { @enum.any?(Proc.new {}) }.should raise_error(ArgumentError)
- -> { @enum.any?(nil) }.should raise_error(ArgumentError)
- -> { @empty.any?(1) }.should raise_error(ArgumentError)
- -> { @enum1.any?(1) {} }.should raise_error(ArgumentError)
+ lambda { @enum.any?(Proc.new {}) }.should raise_error(ArgumentError)
+ lambda { @enum.any?(nil) }.should raise_error(ArgumentError)
+ lambda { @empty.any?(1) }.should raise_error(ArgumentError)
+ lambda { @enum1.any?(1) {} }.should raise_error(ArgumentError)
end
end
it "does not hide exceptions out of #each" do
- -> {
+ lambda {
EnumerableSpecs::ThrowingEach.new.any?
}.should raise_error(RuntimeError)
- -> {
+ lambda {
EnumerableSpecs::ThrowingEach.new.any? { false }
}.should raise_error(RuntimeError)
end
@@ -86,7 +86,7 @@ describe "Enumerable#any?" do
@enum2.any? { |i| i == nil }.should == true
end
- it "returns false if the block never returns other than false or nil" do
+ it "any? should return false if the block never returns other than false or nil" do
@enum.any? { false }.should == false
@enum.any? { nil }.should == false
@@ -127,41 +127,49 @@ describe "Enumerable#any?" do
end
it "does not hide exceptions out of the block" do
- -> {
+ lambda {
@enum.any? { raise "from block" }
}.should raise_error(RuntimeError)
end
it "gathers initial args as elements when each yields multiple" do
multi = EnumerableSpecs::YieldsMulti.new
- yielded = []
- multi.any? { |e| yielded << e; false }.should == false
- yielded.should == [1, 3, 6]
+ multi.any? {|e| e == 1 }.should be_true
end
it "yields multiple arguments when each yields multiple" do
multi = EnumerableSpecs::YieldsMulti.new
yielded = []
- multi.any? { |*args| yielded << args; false }.should == false
- yielded.should == [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
+ multi.any? {|e, i| yielded << [e, i] }
+ yielded.should == [[1, 2]]
end
+
end
ruby_version_is "2.5" do
describe 'when given a pattern argument' do
+ class EnumerableSpecs::Pattern
+ attr_reader :yielded
+ def initialize(&block)
+ @block = block
+ @yielded = []
+ end
+ def ===(*args)
+ @yielded << args
+ @block.call(*args)
+ end
+ end
+
it "calls `===` on the pattern the return value " do
pattern = EnumerableSpecs::Pattern.new { |x| x == 2 }
@enum1.any?(pattern).should == true
pattern.yielded.should == [[0], [1], [2]]
end
- # may raise an exception in future versions
- ruby_version_is ""..."2.6" do
- it "ignores block" do
- @enum2.any?(NilClass) { raise }.should == true
- [1, 2, nil].any?(NilClass) { raise }.should == true
- {a: 1}.any?(Array) { raise }.should == true
- end
+ it "ignores block" do
+ @enum2.any?(NilClass) { raise }.should == true
+ [1, 2, nil].any?(NilClass) { raise }.should == true
+ {a: 1}.any?(Array) { raise }.should == true
end
it "always returns false on empty enumeration" do
@@ -171,7 +179,7 @@ describe "Enumerable#any?" do
end
it "does not hide exceptions out of #each" do
- -> {
+ lambda {
EnumerableSpecs::ThrowingEach.new.any?(Integer)
}.should raise_error(RuntimeError)
end
@@ -187,7 +195,7 @@ describe "Enumerable#any?" do
{a: 1, b: 2}.any?(pattern).should == true
end
- it "returns false if the block never returns other than false or nil" do
+ it "any? should return false if the block never returns other than false or nil" do
pattern = EnumerableSpecs::Pattern.new { |x| nil }
@enum1.any?(pattern).should == false
pattern.yielded.should == [[0], [1], [2], [-1]]
@@ -196,18 +204,21 @@ describe "Enumerable#any?" do
{a: 1}.any?(pattern).should == false
end
- it "does not hide exceptions out of pattern#===" do
+ it "does not hide exceptions out of the block" do
pattern = EnumerableSpecs::Pattern.new { raise "from pattern" }
- -> {
+ lambda {
@enum.any?(pattern)
}.should raise_error(RuntimeError)
end
it "calls the pattern with gathered array when yielded with multiple arguments" do
- multi = EnumerableSpecs::YieldsMulti.new
pattern = EnumerableSpecs::Pattern.new { false }
- multi.any?(pattern).should == false
- pattern.yielded.should == [[[1, 2]], [[3, 4, 5]], [[6, 7, 8, 9]]]
+ EnumerableSpecs::YieldsMixed2.new.any?(pattern).should == false
+ pattern.yielded.should == EnumerableSpecs::YieldsMixed2.gathered_yields.map { |x| [x] }
+
+ pattern = EnumerableSpecs::Pattern.new { false }
+ {a: 1, b: 2}.any?(pattern).should == false
+ pattern.yielded.should == [[[:a, 1]], [[:b, 2]]]
end
end
end
diff --git a/spec/ruby/core/enumerable/chain_spec.rb b/spec/ruby/core/enumerable/chain_spec.rb
deleted file mode 100644
index 85c0c03603..0000000000
--- a/spec/ruby/core/enumerable/chain_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-ruby_version_is "2.6" do
- describe "Enumerable#chain" do
- before :each do
- ScratchPad.record []
- end
-
- it "returns a chain of self and provided enumerables" do
- one = EnumerableSpecs::Numerous.new(1)
- two = EnumerableSpecs::Numerous.new(2, 3)
- three = EnumerableSpecs::Numerous.new(4, 5, 6)
-
- chain = one.chain(two, three)
-
- chain.each { |item| ScratchPad << item }
- ScratchPad.recorded.should == [1, 2, 3, 4, 5, 6]
- end
-
- it "returns an Enumerator::Chain if given a block" do
- EnumerableSpecs::Numerous.new.chain.should be_an_instance_of(Enumerator::Chain)
- end
- end
-end
diff --git a/spec/ruby/core/enumerable/chunk_spec.rb b/spec/ruby/core/enumerable/chunk_spec.rb
index 548544f4e8..9d658010e1 100644
--- a/spec/ruby/core/enumerable/chunk_spec.rb
+++ b/spec/ruby/core/enumerable/chunk_spec.rb
@@ -1,16 +1,26 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#chunk" do
before do
ScratchPad.record []
end
- it "returns an Enumerator if called without a block" do
- chunk = EnumerableSpecs::Numerous.new(1, 2, 3, 1, 2).chunk
- chunk.should be_an_instance_of(Enumerator)
- result = chunk.with_index {|elt, i| elt - i }.to_a
- result.should == [[1, [1, 2, 3]], [-2, [1, 2]]]
+ ruby_version_is ""..."2.4" do
+ it "raises an ArgumentError if called without a block" do
+ lambda do
+ EnumerableSpecs::Numerous.new.chunk
+ end.should raise_error(ArgumentError)
+ end
+ end
+
+ ruby_version_is "2.4" do
+ it "returns an Enumerator if called without a block" do
+ chunk = EnumerableSpecs::Numerous.new(1, 2, 3, 1, 2).chunk
+ chunk.should be_an_instance_of(Enumerator)
+ result = chunk.with_index {|elt, i| elt - i }.to_a
+ result.should == [[1, [1, 2, 3]], [-2, [1, 2]]]
+ end
end
it "returns an Enumerator if given a block" do
@@ -49,14 +59,37 @@ describe "Enumerable#chunk" do
it "raises a RuntimeError if the block returns a Symbol starting with an underscore other than :_alone or :_separator" do
e = EnumerableSpecs::Numerous.new(1, 2, 3, 2, 1)
- -> { e.chunk { |x| :_arbitrary }.to_a }.should raise_error(RuntimeError)
+ lambda { e.chunk { |x| :_arbitrary }.to_a }.should raise_error(RuntimeError)
end
- it "does not accept arguments" do
- e = EnumerableSpecs::Numerous.new(1, 2, 3)
- -> {
- e.chunk(1) {}
- }.should raise_error(ArgumentError)
+ ruby_version_is ""..."2.3" do
+ describe "with [initial_state]" do
+ it "yields an element and an object value-equal but not identical to the object passed to #chunk" do
+ e = EnumerableSpecs::Numerous.new(1)
+ value = "value"
+
+ e.chunk(value) do |x, v|
+ x.should == 1
+ v.should == value
+ v.should_not equal(value)
+ end.to_a
+ end
+
+ it "does not yield the object passed to #chunk if it is nil" do
+ e = EnumerableSpecs::Numerous.new(1)
+ e.chunk(nil) { |*x| ScratchPad << x }.to_a
+ ScratchPad.recorded.should == [[1]]
+ end
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "does not accept arguments" do
+ e = EnumerableSpecs::Numerous.new(1, 2, 3)
+ lambda {
+ e.chunk(1) {}
+ }.should raise_error(ArgumentError)
+ end
end
it 'returned Enumerator size returns nil' do
diff --git a/spec/ruby/core/enumerable/chunk_while_spec.rb b/spec/ruby/core/enumerable/chunk_while_spec.rb
index 26bcc983db..a5cbdc3348 100644
--- a/spec/ruby/core/enumerable/chunk_while_spec.rb
+++ b/spec/ruby/core/enumerable/chunk_while_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe "Enumerable#chunk_while" do
- before :each do
- ary = [10, 9, 7, 6, 4, 3, 2, 1]
- @enum = EnumerableSpecs::Numerous.new(*ary)
- @result = @enum.chunk_while { |i, j| i - 1 == j }
- @enum_length = ary.length
- end
-
- context "when given a block" do
- it "returns an enumerator" do
- @result.should be_an_instance_of(Enumerator)
+ruby_version_is "2.3" do
+ describe "Enumerable#chunk_while" do
+ before :each do
+ ary = [10, 9, 7, 6, 4, 3, 2, 1]
+ @enum = EnumerableSpecs::Numerous.new(*ary)
+ @result = @enum.chunk_while { |i, j| i - 1 == j }
+ @enum_length = ary.length
end
- it "splits chunks between adjacent elements i and j where the block returns false" do
- @result.to_a.should == [[10, 9], [7, 6], [4, 3, 2, 1]]
- end
+ context "when given a block" do
+ it "returns an enumerator" do
+ @result.should be_an_instance_of(Enumerator)
+ end
- it "calls the block for length of the receiver enumerable minus one times" do
- times_called = 0
- @enum.chunk_while do |i, j|
- times_called += 1
- i - 1 == j
- end.to_a
- times_called.should == (@enum_length - 1)
+ it "splits chunks between adjacent elements i and j where the block returns false" do
+ @result.to_a.should == [[10, 9], [7, 6], [4, 3, 2, 1]]
+ end
+
+ it "calls the block for length of the receiver enumerable minus one times" do
+ times_called = 0
+ @enum.chunk_while do |i, j|
+ times_called += 1
+ i - 1 == j
+ end.to_a
+ times_called.should == (@enum_length - 1)
+ end
end
- end
- context "when not given a block" do
- it "raises an ArgumentError" do
- -> { @enum.chunk_while }.should raise_error(ArgumentError)
+ context "when not given a block" do
+ it "raises an ArgumentError" do
+ lambda { @enum.chunk_while }.should raise_error(ArgumentError)
+ end
end
- end
- context "on a single-element array" do
- it "ignores the block and returns an enumerator that yields [element]" do
- [1].chunk_while {|x| x.even?}.to_a.should == [[1]]
+ context "on a single-element array" do
+ it "ignores the block and returns an enumerator that yields [element]" do
+ [1].chunk_while {|x| x.even?}.to_a.should == [[1]]
+ end
end
end
end
diff --git a/spec/ruby/core/enumerable/collect_concat_spec.rb b/spec/ruby/core/enumerable/collect_concat_spec.rb
index 6e34c9eb93..6f21012060 100644
--- a/spec/ruby/core/enumerable/collect_concat_spec.rb
+++ b/spec/ruby/core/enumerable/collect_concat_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/collect_concat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/collect_concat', __FILE__)
describe "Enumerable#collect_concat" do
- it_behaves_like :enumerable_collect_concat , :collect_concat
+ it_behaves_like(:enumerable_collect_concat , :collect_concat)
end
diff --git a/spec/ruby/core/enumerable/collect_spec.rb b/spec/ruby/core/enumerable/collect_spec.rb
index 1016b67798..a830eef9f7 100644
--- a/spec/ruby/core/enumerable/collect_spec.rb
+++ b/spec/ruby/core/enumerable/collect_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/collect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Enumerable#collect" do
- it_behaves_like :enumerable_collect , :collect
+ it_behaves_like(:enumerable_collect , :collect)
end
diff --git a/spec/ruby/core/enumerable/count_spec.rb b/spec/ruby/core/enumerable/count_spec.rb
index 50a1c8e1a4..9d1e08f3a9 100644
--- a/spec/ruby/core/enumerable/count_spec.rb
+++ b/spec/ruby/core/enumerable/count_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#count" do
before :each do
diff --git a/spec/ruby/core/enumerable/cycle_spec.rb b/spec/ruby/core/enumerable/cycle_spec.rb
index 487086cba3..9089a94963 100644
--- a/spec/ruby/core/enumerable/cycle_spec.rb
+++ b/spec/ruby/core/enumerable/cycle_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorized', __FILE__)
describe "Enumerable#cycle" do
describe "passed no argument or nil" do
@@ -71,12 +71,12 @@ describe "Enumerable#cycle" do
it "raises a TypeError when the passed n cannot be coerced to Integer" do
enum = EnumerableSpecs::Numerous.new
- ->{ enum.cycle("cat"){} }.should raise_error(TypeError)
+ lambda{ enum.cycle("cat"){} }.should raise_error(TypeError)
end
it "raises an ArgumentError if more arguments are passed" do
enum = EnumerableSpecs::Numerous.new
- ->{ enum.cycle(1, 2) {} }.should raise_error(ArgumentError)
+ lambda{ enum.cycle(1, 2) {} }.should raise_error(ArgumentError)
end
it "gathers whole arrays as elements when each yields multiple" do
diff --git a/spec/ruby/core/enumerable/detect_spec.rb b/spec/ruby/core/enumerable/detect_spec.rb
index e912134fed..f69e456052 100644
--- a/spec/ruby/core/enumerable/detect_spec.rb
+++ b/spec/ruby/core/enumerable/detect_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/find'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/find', __FILE__)
describe "Enumerable#detect" do
- it_behaves_like :enumerable_find , :detect
+ it_behaves_like(:enumerable_find , :detect)
end
diff --git a/spec/ruby/core/enumerable/drop_spec.rb b/spec/ruby/core/enumerable/drop_spec.rb
index 423cc0088b..4013a639ce 100644
--- a/spec/ruby/core/enumerable/drop_spec.rb
+++ b/spec/ruby/core/enumerable/drop_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#drop" do
before :each do
@@ -7,13 +7,13 @@ describe "Enumerable#drop" do
end
it "requires exactly one argument" do
- ->{ @enum.drop{} }.should raise_error(ArgumentError)
- ->{ @enum.drop(1, 2){} }.should raise_error(ArgumentError)
+ lambda{ @enum.drop{} }.should raise_error(ArgumentError)
+ lambda{ @enum.drop(1, 2){} }.should raise_error(ArgumentError)
end
describe "passed a number n as an argument" do
it "raises ArgumentError if n < 0" do
- ->{ @enum.drop(-1) }.should raise_error(ArgumentError)
+ lambda{ @enum.drop(-1) }.should raise_error(ArgumentError)
end
it "tries to convert n to an Integer using #to_int" do
@@ -35,8 +35,8 @@ describe "Enumerable#drop" do
end
it "raises a TypeError when the passed n cannot be coerced to Integer" do
- ->{ @enum.drop("hat") }.should raise_error(TypeError)
- ->{ @enum.drop(nil) }.should raise_error(TypeError)
+ lambda{ @enum.drop("hat") }.should raise_error(TypeError)
+ lambda{ @enum.drop(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/enumerable/drop_while_spec.rb b/spec/ruby/core/enumerable/drop_while_spec.rb
index 636c3d284a..731b9588e4 100644
--- a/spec/ruby/core/enumerable/drop_while_spec.rb
+++ b/spec/ruby/core/enumerable/drop_while_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#drop_while" do
before :each do
diff --git a/spec/ruby/core/enumerable/each_cons_spec.rb b/spec/ruby/core/enumerable/each_cons_spec.rb
index 7d44f54f74..6720199bc3 100644
--- a/spec/ruby/core/enumerable/each_cons_spec.rb
+++ b/spec/ruby/core/enumerable/each_cons_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorized', __FILE__)
describe "Enumerable#each_cons" do
before :each do
@@ -15,14 +15,14 @@ describe "Enumerable#each_cons" do
end
it "raises an ArgumentError if there is not a single parameter > 0" do
- ->{ @enum.each_cons(0){} }.should raise_error(ArgumentError)
- ->{ @enum.each_cons(-2){} }.should raise_error(ArgumentError)
- ->{ @enum.each_cons{} }.should raise_error(ArgumentError)
- ->{ @enum.each_cons(2,2){} }.should raise_error(ArgumentError)
- ->{ @enum.each_cons(0) }.should raise_error(ArgumentError)
- ->{ @enum.each_cons(-2) }.should raise_error(ArgumentError)
- ->{ @enum.each_cons }.should raise_error(ArgumentError)
- ->{ @enum.each_cons(2,2) }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons(0){} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons(-2){} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons{} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons(2,2){} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons(0) }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons(-2) }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons }.should raise_error(ArgumentError)
+ lambda{ @enum.each_cons(2,2) }.should raise_error(ArgumentError)
end
it "tries to convert n to an Integer using #to_int" do
diff --git a/spec/ruby/core/enumerable/each_entry_spec.rb b/spec/ruby/core/enumerable/each_entry_spec.rb
index edf00f3137..05d181a998 100644
--- a/spec/ruby/core/enumerable/each_entry_spec.rb
+++ b/spec/ruby/core/enumerable/each_entry_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#each_entry" do
before :each do
@@ -27,8 +27,8 @@ describe "Enumerable#each_entry" do
end
it "raises an ArgumentError when extra arguments" do
- -> { @enum.each_entry("one").to_a }.should raise_error(ArgumentError)
- -> { @enum.each_entry("one"){}.to_a }.should raise_error(ArgumentError)
+ lambda { @enum.each_entry("one").to_a }.should raise_error(ArgumentError)
+ lambda { @enum.each_entry("one"){}.to_a }.should raise_error(ArgumentError)
end
it "passes extra arguments to #each" do
diff --git a/spec/ruby/core/enumerable/each_slice_spec.rb b/spec/ruby/core/enumerable/each_slice_spec.rb
index ab3b79c344..62503fe206 100644
--- a/spec/ruby/core/enumerable/each_slice_spec.rb
+++ b/spec/ruby/core/enumerable/each_slice_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumeratorized', __FILE__)
describe "Enumerable#each_slice" do
before :each do
@@ -15,14 +15,14 @@ describe "Enumerable#each_slice" do
end
it "raises an ArgumentError if there is not a single parameter > 0" do
- ->{ @enum.each_slice(0){} }.should raise_error(ArgumentError)
- ->{ @enum.each_slice(-2){} }.should raise_error(ArgumentError)
- ->{ @enum.each_slice{} }.should raise_error(ArgumentError)
- ->{ @enum.each_slice(2,2){} }.should raise_error(ArgumentError)
- ->{ @enum.each_slice(0) }.should raise_error(ArgumentError)
- ->{ @enum.each_slice(-2) }.should raise_error(ArgumentError)
- ->{ @enum.each_slice }.should raise_error(ArgumentError)
- ->{ @enum.each_slice(2,2) }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice(0){} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice(-2){} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice{} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice(2,2){} }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice(0) }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice(-2) }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice }.should raise_error(ArgumentError)
+ lambda{ @enum.each_slice(2,2) }.should raise_error(ArgumentError)
end
it "tries to convert n to an Integer using #to_int" do
diff --git a/spec/ruby/core/enumerable/each_with_index_spec.rb b/spec/ruby/core/enumerable/each_with_index_spec.rb
index 122e88eab7..9884e71167 100644
--- a/spec/ruby/core/enumerable/each_with_index_spec.rb
+++ b/spec/ruby/core/enumerable/each_with_index_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#each_with_index" do
diff --git a/spec/ruby/core/enumerable/each_with_object_spec.rb b/spec/ruby/core/enumerable/each_with_object_spec.rb
index 35665e7019..13a7c1c66d 100644
--- a/spec/ruby/core/enumerable/each_with_object_spec.rb
+++ b/spec/ruby/core/enumerable/each_with_object_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#each_with_object" do
before :each do
diff --git a/spec/ruby/core/enumerable/entries_spec.rb b/spec/ruby/core/enumerable/entries_spec.rb
index 83232cfa06..94eceee713 100644
--- a/spec/ruby/core/enumerable/entries_spec.rb
+++ b/spec/ruby/core/enumerable/entries_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/entries'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/entries', __FILE__)
describe "Enumerable#entries" do
- it_behaves_like :enumerable_entries , :entries
+ it_behaves_like(:enumerable_entries , :entries)
end
diff --git a/spec/ruby/core/enumerable/filter_map_spec.rb b/spec/ruby/core/enumerable/filter_map_spec.rb
deleted file mode 100644
index 31acc277b4..0000000000
--- a/spec/ruby/core/enumerable/filter_map_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-ruby_version_is '2.7' do
- describe 'Enumerable#filter_map' do
- before :each do
- @numerous = EnumerableSpecs::Numerous.new(*(1..8).to_a)
- end
-
- it 'returns an empty array if there are no elements' do
- EnumerableSpecs::Empty.new.filter_map { true }.should == []
- end
-
- it 'returns an array with truthy results of passing each element to block' do
- @numerous.filter_map { |i| i * 2 if i.even? }.should == [4, 8, 12, 16]
- @numerous.filter_map { |i| i * 2 }.should == [2, 4, 6, 8, 10, 12, 14, 16]
- @numerous.filter_map { 0 }.should == [0, 0, 0, 0, 0, 0, 0, 0]
- @numerous.filter_map { false }.should == []
- @numerous.filter_map { nil }.should == []
- end
-
- it 'returns an enumerator when no block given' do
- @numerous.filter_map.should be_an_instance_of(Enumerator)
- end
- end
-end
diff --git a/spec/ruby/core/enumerable/filter_spec.rb b/spec/ruby/core/enumerable/filter_spec.rb
deleted file mode 100644
index f2dc7a7b71..0000000000
--- a/spec/ruby/core/enumerable/filter_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/find_all'
-
-ruby_version_is "2.6" do
- describe "Enumerable#filter" do
- it_behaves_like(:enumerable_find_all , :filter)
- end
-end
diff --git a/spec/ruby/core/enumerable/find_all_spec.rb b/spec/ruby/core/enumerable/find_all_spec.rb
index ce9058fe77..3d587d7709 100644
--- a/spec/ruby/core/enumerable/find_all_spec.rb
+++ b/spec/ruby/core/enumerable/find_all_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/find_all'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/find_all', __FILE__)
describe "Enumerable#find_all" do
- it_behaves_like :enumerable_find_all , :find_all
+ it_behaves_like(:enumerable_find_all , :find_all)
end
diff --git a/spec/ruby/core/enumerable/find_index_spec.rb b/spec/ruby/core/enumerable/find_index_spec.rb
index 542660fe04..c118a61fcf 100644
--- a/spec/ruby/core/enumerable/find_index_spec.rb
+++ b/spec/ruby/core/enumerable/find_index_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#find_index" do
before :each do
diff --git a/spec/ruby/core/enumerable/find_spec.rb b/spec/ruby/core/enumerable/find_spec.rb
index 25aa3bf103..62e1194537 100644
--- a/spec/ruby/core/enumerable/find_spec.rb
+++ b/spec/ruby/core/enumerable/find_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/find'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/find', __FILE__)
describe "Enumerable#find" do
- it_behaves_like :enumerable_find , :find
+ it_behaves_like(:enumerable_find , :find)
end
diff --git a/spec/ruby/core/enumerable/first_spec.rb b/spec/ruby/core/enumerable/first_spec.rb
index ed1ba599b4..a85550ee3b 100644
--- a/spec/ruby/core/enumerable/first_spec.rb
+++ b/spec/ruby/core/enumerable/first_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/take'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/take', __FILE__)
describe "Enumerable#first" do
it "returns the first element" do
@@ -19,7 +19,7 @@ describe "Enumerable#first" do
it "raises a RangeError when passed a Bignum" do
enum = EnumerableSpecs::Empty.new
- -> { enum.first(bignum_value) }.should raise_error(RangeError)
+ lambda { enum.first(bignum_value) }.should raise_error(RangeError)
end
describe "when passed an argument" do
diff --git a/spec/ruby/core/enumerable/fixtures/classes.rb b/spec/ruby/core/enumerable/fixtures/classes.rb
index 5051196742..26a8aff8e2 100644
--- a/spec/ruby/core/enumerable/fixtures/classes.rb
+++ b/spec/ruby/core/enumerable/fixtures/classes.rb
@@ -118,7 +118,7 @@ module EnumerableSpecs
end
end
- class ArrayConvertible
+ class ArrayConvertable
attr_accessor :called
def initialize(*values)
@values = values
@@ -135,7 +135,7 @@ module EnumerableSpecs
end
end
- class EnumConvertible
+ class EnumConvertable
attr_accessor :called
attr_accessor :sym
def initialize(delegate)
@@ -328,18 +328,4 @@ module EnumerableSpecs
EnumerableMapping.new(self, block)
end
end
-
- class Pattern
- attr_reader :yielded
-
- def initialize(&block)
- @block = block
- @yielded = []
- end
-
- def ===(*args)
- @yielded << args
- @block.call(*args)
- end
- end
end # EnumerableSpecs utility classes
diff --git a/spec/ruby/core/enumerable/flat_map_spec.rb b/spec/ruby/core/enumerable/flat_map_spec.rb
index a294b9ddad..aaddeed05d 100644
--- a/spec/ruby/core/enumerable/flat_map_spec.rb
+++ b/spec/ruby/core/enumerable/flat_map_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/collect_concat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/collect_concat', __FILE__)
describe "Enumerable#flat_map" do
- it_behaves_like :enumerable_collect_concat , :flat_map
+ it_behaves_like(:enumerable_collect_concat , :flat_map)
end
diff --git a/spec/ruby/core/enumerable/grep_spec.rb b/spec/ruby/core/enumerable/grep_spec.rb
index c9c0f34e27..777d5e538e 100644
--- a/spec/ruby/core/enumerable/grep_spec.rb
+++ b/spec/ruby/core/enumerable/grep_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#grep" do
before :each do
@@ -29,28 +29,6 @@ describe "Enumerable#grep" do
ary.grep(/a(b)a/) { $1 }.should == ["b", "b"]
end
- it "sets $~ in the block" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].grep(/b/) { |e|
- e.should == "abc"
- $&.should == "b"
- }
-
- # Set by the failed match of "def"
- $~.should == nil
- end
-
- it "sets $~ to the last match when given no block" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].grep(/b/).should == ["abc"]
-
- # Set by the failed match of "def"
- $~.should == nil
-
- ["abc", "def"].grep(/e/)
- $&.should == "e"
- end
-
describe "with a block" do
before :each do
@numerous = EnumerableSpecs::Numerous.new(*(0..9).to_a)
diff --git a/spec/ruby/core/enumerable/grep_v_spec.rb b/spec/ruby/core/enumerable/grep_v_spec.rb
index 6dec487065..05c43a43ef 100644
--- a/spec/ruby/core/enumerable/grep_v_spec.rb
+++ b/spec/ruby/core/enumerable/grep_v_spec.rb
@@ -1,63 +1,43 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Enumerable#grep_v" do
- before :each do
- @numerous = EnumerableSpecs::Numerous.new(*(0..9).to_a)
- def (@odd_matcher = BasicObject.new).===(obj)
- obj.odd?
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "Enumerable#grep_v" do
+ before :each do
+ @numerous = EnumerableSpecs::Numerous.new(*(0..9).to_a)
+ def (@odd_matcher = BasicObject.new).===(obj)
+ obj.odd?
+ end
end
- end
-
- it "sets $~ in the block" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].grep_v(/e/) { |e|
- e.should == "abc"
- $~.should == nil
- }
-
- # Set by the match of "def"
- $&.should == "e"
- end
-
- it "sets $~ to the last match when given no block" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].grep_v(/e/).should == ["abc"]
-
- # Set by the match of "def"
- $&.should == "e"
- ["abc", "def"].grep_v(/b/)
- $&.should == nil
- end
+ describe "without block" do
+ it "returns an Array of matched elements" do
+ @numerous.grep_v(@odd_matcher).should == [0, 2, 4, 6, 8]
+ end
- describe "without block" do
- it "returns an Array of matched elements" do
- @numerous.grep_v(@odd_matcher).should == [0, 2, 4, 6, 8]
- end
+ it "compares pattern with gathered array when yielded with multiple arguments" do
+ (unmatcher = Object.new).stub!(:===).and_return(false)
+ EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher).should == EnumerableSpecs::YieldsMixed2.gathered_yields
+ end
- it "compares pattern with gathered array when yielded with multiple arguments" do
- (unmatcher = Object.new).stub!(:===).and_return(false)
- EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher).should == EnumerableSpecs::YieldsMixed2.gathered_yields
+ it "raises an ArgumentError when not given a pattern" do
+ -> { @numerous.grep_v }.should raise_error(ArgumentError)
+ end
end
- it "raises an ArgumentError when not given a pattern" do
- -> { @numerous.grep_v }.should raise_error(ArgumentError)
- end
- end
+ describe "with block" do
+ it "returns an Array of matched elements that mapped by the block" do
+ @numerous.grep_v(@odd_matcher) { |n| n * 2 }.should == [0, 4, 8, 12, 16]
+ end
- describe "with block" do
- it "returns an Array of matched elements that mapped by the block" do
- @numerous.grep_v(@odd_matcher) { |n| n * 2 }.should == [0, 4, 8, 12, 16]
- end
-
- it "calls the block with gathered array when yielded with multiple arguments" do
- (unmatcher = Object.new).stub!(:===).and_return(false)
- EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher){ |e| e }.should == EnumerableSpecs::YieldsMixed2.gathered_yields
- end
+ it "calls the block with gathered array when yielded with multiple arguments" do
+ (unmatcher = Object.new).stub!(:===).and_return(false)
+ EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher){ |e| e }.should == EnumerableSpecs::YieldsMixed2.gathered_yields
+ end
- it "raises an ArgumentError when not given a pattern" do
- -> { @numerous.grep_v { |e| e } }.should raise_error(ArgumentError)
+ it "raises an ArgumentError when not given a pattern" do
+ -> { @numerous.grep_v { |e| e } }.should raise_error(ArgumentError)
+ end
end
end
end
diff --git a/spec/ruby/core/enumerable/group_by_spec.rb b/spec/ruby/core/enumerable/group_by_spec.rb
index 52b5a68d64..3513512ebf 100644
--- a/spec/ruby/core/enumerable/group_by_spec.rb
+++ b/spec/ruby/core/enumerable/group_by_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#group_by" do
it "returns a hash with values grouped according to the block" do
@@ -33,14 +33,12 @@ describe "Enumerable#group_by" do
[3, 4, 5] => [[3, 4, 5]] }
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted hash if self is tainted" do
- EnumerableSpecs::Empty.new.taint.group_by {}.tainted?.should be_true
- end
+ it "returns a tainted hash if self is tainted" do
+ EnumerableSpecs::Empty.new.taint.group_by {}.tainted?.should be_true
+ end
- it "returns an untrusted hash if self is untrusted" do
- EnumerableSpecs::Empty.new.untrust.group_by {}.untrusted?.should be_true
- end
+ it "returns an untrusted hash if self is untrusted" do
+ EnumerableSpecs::Empty.new.untrust.group_by {}.untrusted?.should be_true
end
it_behaves_like :enumerable_enumeratorized_with_origin_size, :group_by
diff --git a/spec/ruby/core/enumerable/include_spec.rb b/spec/ruby/core/enumerable/include_spec.rb
index dab1b04451..2cc0b6e83a 100644
--- a/spec/ruby/core/enumerable/include_spec.rb
+++ b/spec/ruby/core/enumerable/include_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
describe "Enumerable#include?" do
- it_behaves_like :enumerable_include, :include?
+ it_behaves_like(:enumerable_include, :include?)
end
diff --git a/spec/ruby/core/enumerable/inject_spec.rb b/spec/ruby/core/enumerable/inject_spec.rb
index e1fe216144..289a451552 100644
--- a/spec/ruby/core/enumerable/inject_spec.rb
+++ b/spec/ruby/core/enumerable/inject_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/inject'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/inject', __FILE__)
describe "Enumerable#inject" do
it_behaves_like :enumerable_inject, :inject
diff --git a/spec/ruby/core/enumerable/lazy_spec.rb b/spec/ruby/core/enumerable/lazy_spec.rb
index 9a9ead81a0..f989fb947e 100644
--- a/spec/ruby/core/enumerable/lazy_spec.rb
+++ b/spec/ruby/core/enumerable/lazy_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#lazy" do
it "returns an instance of Enumerator::Lazy" do
diff --git a/spec/ruby/core/enumerable/map_spec.rb b/spec/ruby/core/enumerable/map_spec.rb
index d65aec238c..b2ddf1eb9d 100644
--- a/spec/ruby/core/enumerable/map_spec.rb
+++ b/spec/ruby/core/enumerable/map_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/collect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Enumerable#map" do
- it_behaves_like :enumerable_collect , :map
+ it_behaves_like(:enumerable_collect , :map)
end
diff --git a/spec/ruby/core/enumerable/max_by_spec.rb b/spec/ruby/core/enumerable/max_by_spec.rb
index ec1738ea3b..4058cf0a40 100644
--- a/spec/ruby/core/enumerable/max_by_spec.rb
+++ b/spec/ruby/core/enumerable/max_by_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#max_by" do
it "returns an enumerator if no block" do
@@ -67,7 +67,7 @@ describe "Enumerable#max_by" do
context "when n is negative" do
it "raises an ArgumentError" do
- -> { @enum.max_by(-1) { |i| i.to_s } }.should raise_error(ArgumentError)
+ lambda { @enum.max_by(-1) { |i| i.to_s } }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/enumerable/max_spec.rb b/spec/ruby/core/enumerable/max_spec.rb
index 0c11ca0969..e283a5d0e2 100644
--- a/spec/ruby/core/enumerable/max_spec.rb
+++ b/spec/ruby/core/enumerable/max_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#max" do
before :each do
@@ -36,16 +36,16 @@ describe "Enumerable#max" do
end
it "raises a NoMethodError for elements without #<=>" do
- -> do
+ lambda do
EnumerableSpecs::EachDefiner.new(BasicObject.new, BasicObject.new).max
end.should raise_error(NoMethodError)
end
it "raises an ArgumentError for incomparable elements" do
- -> do
+ lambda do
EnumerableSpecs::EachDefiner.new(11,"22").max
end.should raise_error(ArgumentError)
- -> do
+ lambda do
EnumerableSpecs::EachDefiner.new(11,12,22,33).max{|a, b| nil}
end.should raise_error(ArgumentError)
end
@@ -106,7 +106,7 @@ describe "Enumerable#max" do
context "that is negative" do
it "raises an ArgumentError" do
- -> { @e_ints.max(-1) }.should raise_error(ArgumentError)
+ lambda { @e_ints.max(-1) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/enumerable/member_spec.rb b/spec/ruby/core/enumerable/member_spec.rb
index 1fe3cebd28..862c949817 100644
--- a/spec/ruby/core/enumerable/member_spec.rb
+++ b/spec/ruby/core/enumerable/member_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
describe "Enumerable#member?" do
- it_behaves_like :enumerable_include, :member?
+ it_behaves_like(:enumerable_include, :member?)
end
diff --git a/spec/ruby/core/enumerable/min_by_spec.rb b/spec/ruby/core/enumerable/min_by_spec.rb
index 3ff87e49d8..24fe995f09 100644
--- a/spec/ruby/core/enumerable/min_by_spec.rb
+++ b/spec/ruby/core/enumerable/min_by_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#min_by" do
it "returns an enumerator if no block" do
@@ -67,7 +67,7 @@ describe "Enumerable#min_by" do
context "when n is negative" do
it "raises an ArgumentError" do
- -> { @enum.min_by(-1) { |i| i.to_s } }.should raise_error(ArgumentError)
+ lambda { @enum.min_by(-1) { |i| i.to_s } }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/enumerable/min_spec.rb b/spec/ruby/core/enumerable/min_spec.rb
index 4b6ae248fa..f56d0420c9 100644
--- a/spec/ruby/core/enumerable/min_spec.rb
+++ b/spec/ruby/core/enumerable/min_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#min" do
before :each do
@@ -36,16 +36,16 @@ describe "Enumerable#min" do
end
it "raises a NoMethodError for elements without #<=>" do
- -> do
+ lambda do
EnumerableSpecs::EachDefiner.new(BasicObject.new, BasicObject.new).min
end.should raise_error(NoMethodError)
end
it "raises an ArgumentError for incomparable elements" do
- -> do
+ lambda do
EnumerableSpecs::EachDefiner.new(11,"22").min
end.should raise_error(ArgumentError)
- -> do
+ lambda do
EnumerableSpecs::EachDefiner.new(11,12,22,33).min{|a, b| nil}
end.should raise_error(ArgumentError)
end
@@ -110,7 +110,7 @@ describe "Enumerable#min" do
context "that is negative" do
it "raises an ArgumentError" do
- -> { @e_ints.min(-1) }.should raise_error(ArgumentError)
+ lambda { @e_ints.min(-1) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/enumerable/minmax_by_spec.rb b/spec/ruby/core/enumerable/minmax_by_spec.rb
index a6a9249270..c92eb381a4 100644
--- a/spec/ruby/core/enumerable/minmax_by_spec.rb
+++ b/spec/ruby/core/enumerable/minmax_by_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#minmax_by" do
it "returns an enumerator if no block" do
diff --git a/spec/ruby/core/enumerable/minmax_spec.rb b/spec/ruby/core/enumerable/minmax_spec.rb
index 29f1ecf82c..10bc9b68e4 100644
--- a/spec/ruby/core/enumerable/minmax_spec.rb
+++ b/spec/ruby/core/enumerable/minmax_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#minmax" do
before :each do
@@ -18,16 +18,16 @@ describe "Enumerable#minmax" do
end
it "raises an ArgumentError when elements are incomparable" do
- -> do
+ lambda do
EnumerableSpecs::Numerous.new(11,"22").minmax
end.should raise_error(ArgumentError)
- -> do
+ lambda do
EnumerableSpecs::Numerous.new(11,12,22,33).minmax{|a, b| nil}
end.should raise_error(ArgumentError)
end
it "raises a NoMethodError for elements without #<=>" do
- -> do
+ lambda do
EnumerableSpecs::Numerous.new(BasicObject.new, BasicObject.new).minmax
end.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/enumerable/none_spec.rb b/spec/ruby/core/enumerable/none_spec.rb
index 7c17e58a13..89472d6ee1 100644
--- a/spec/ruby/core/enumerable/none_spec.rb
+++ b/spec/ruby/core/enumerable/none_spec.rb
@@ -1,167 +1,68 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#none?" do
- before :each do
- @empty = EnumerableSpecs::Empty.new
- @enum = EnumerableSpecs::Numerous.new
- @enum1 = EnumerableSpecs::Numerous.new(0, 1, 2, -1)
- @enum2 = EnumerableSpecs::Numerous.new(nil, false, true)
+ it "returns true if none of the elements in self are true" do
+ e = EnumerableSpecs::Numerous.new(false, nil, false)
+ e.none?.should be_true
end
- it "always returns true on empty enumeration" do
- @empty.none?.should == true
- @empty.none? { true }.should == true
+ it "returns false if at least one of the elements in self are true" do
+ e = EnumerableSpecs::Numerous.new(false, nil, true, false)
+ e.none?.should be_false
end
- it "raises an ArgumentError when more than 1 argument is provided" do
- -> { @enum.none?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { [].none?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { {}.none?(1, 2, 3) }.should raise_error(ArgumentError)
+ it "gathers whole arrays as elements when each yields multiple" do
+ # This spec doesn't spec what it says it does
+ multi = EnumerableSpecs::YieldsMultiWithFalse.new
+ multi.none?.should be_false
end
- ruby_version_is ""..."2.5" do
- it "raises an ArgumentError when any arguments provided" do
- -> { @enum.none?(Proc.new {}) }.should raise_error(ArgumentError)
- -> { @enum.none?(nil) }.should raise_error(ArgumentError)
- -> { @empty.none?(1) }.should raise_error(ArgumentError)
- -> { @enum.none?(1) {} }.should raise_error(ArgumentError)
+ ruby_version_is "2.5" do
+ describe "given a pattern argument" do
+ # This spec should be replaced by more extensive ones
+ it "returns true iff none match that pattern" do
+ EnumerableSpecs::Numerous.new.none?(Float).should == true
+ [nil, false, true].none?(NilClass).should == false
+ end
end
end
+end
- it "does not hide exceptions out of #each" do
- -> {
- EnumerableSpecs::ThrowingEach.new.none?
- }.should raise_error(RuntimeError)
-
- -> {
- EnumerableSpecs::ThrowingEach.new.none? { false }
- }.should raise_error(RuntimeError)
+describe "Enumerable#none? with a block" do
+ before :each do
+ @e = EnumerableSpecs::Numerous.new(1,1,2,3,4)
end
- describe "with no block" do
- it "returns true if none of the elements in self are true" do
- e = EnumerableSpecs::Numerous.new(false, nil, false)
- e.none?.should be_true
- end
-
- it "returns false if at least one of the elements in self are true" do
- e = EnumerableSpecs::Numerous.new(false, nil, true, false)
- e.none?.should be_false
- end
-
- it "gathers whole arrays as elements when each yields multiple" do
- multi = EnumerableSpecs::YieldsMultiWithFalse.new
- multi.none?.should be_false
- end
+ it "passes each element to the block in turn until it returns true" do
+ acc = []
+ @e.none? {|e| acc << e; false }
+ acc.should == [1,1,2,3,4]
end
- describe "with a block" do
- before :each do
- @e = EnumerableSpecs::Numerous.new(1,1,2,3,4)
- end
-
- it "passes each element to the block in turn until it returns true" do
- acc = []
- @e.none? {|e| acc << e; false }
- acc.should == [1,1,2,3,4]
- end
-
- it "stops passing elements to the block when it returns true" do
- acc = []
- @e.none? {|e| acc << e; e == 3 ? true : false }
- acc.should == [1,1,2,3]
- end
-
- it "returns true if the block never returns true" do
- @e.none? {|e| false }.should be_true
- end
-
- it "returns false if the block ever returns true" do
- @e.none? {|e| e == 3 ? true : false }.should be_false
- end
-
- it "does not hide exceptions out of the block" do
- -> {
- @enum.none? { raise "from block" }
- }.should raise_error(RuntimeError)
- end
-
- it "gathers initial args as elements when each yields multiple" do
- multi = EnumerableSpecs::YieldsMulti.new
- yielded = []
- multi.none? { |e| yielded << e; false }
- yielded.should == [1, 3, 6]
- end
-
- it "yields multiple arguments when each yields multiple" do
- multi = EnumerableSpecs::YieldsMulti.new
- yielded = []
- multi.none? { |*args| yielded << args; false }
- yielded.should == [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
- end
+ it "stops passing elements to the block when it returns true" do
+ acc = []
+ @e.none? {|e| acc << e; e == 3 ? true : false }
+ acc.should == [1,1,2,3]
end
- ruby_version_is "2.5" do
- describe 'when given a pattern argument' do
- it "calls `===` on the pattern the return value " do
- pattern = EnumerableSpecs::Pattern.new { |x| x == 3 }
- @enum1.none?(pattern).should == true
- pattern.yielded.should == [[0], [1], [2], [-1]]
- end
-
- # may raise an exception in future versions
- ruby_version_is ""..."2.6" do
- it "ignores block" do
- @enum2.none?(Integer) { raise }.should == true
- [1, 2, nil].none?(TrueClass) { raise }.should == true
- {a: 1}.none?(Hash) { raise }.should == true
- end
- end
-
- it "always returns true on empty enumeration" do
- @empty.none?(Integer).should == true
- [].none?(Integer).should == true
- {}.none?(NilClass).should == true
- end
-
- it "does not hide exceptions out of #each" do
- -> {
- EnumerableSpecs::ThrowingEach.new.none?(Integer)
- }.should raise_error(RuntimeError)
- end
-
- it "returns true if the pattern never returns a truthy value" do
- @enum2.none?(Integer).should == true
- pattern = EnumerableSpecs::Pattern.new { |x| nil }
- @enum.none?(pattern).should == true
-
- [1, 42, 3].none?(pattern).should == true
- {a: 1, b: 2}.none?(pattern).should == true
- end
-
- it "returns false if the pattern ever returns other than false or nil" do
- pattern = EnumerableSpecs::Pattern.new { |x| x < 0 }
- @enum1.none?(pattern).should == false
- pattern.yielded.should == [[0], [1], [2], [-1]]
+ it "returns true if the block never returns true" do
+ @e.none? {|e| false }.should be_true
+ end
- [1, 2, 3, -1].none?(pattern).should == false
- {a: 1}.none?(Array).should == false
- end
+ it "returns false if the block ever returns true" do
+ @e.none? {|e| e == 3 ? true : false }.should be_false
+ end
- it "does not hide exceptions out of pattern#===" do
- pattern = EnumerableSpecs::Pattern.new { raise "from pattern" }
- -> {
- @enum.none?(pattern)
- }.should raise_error(RuntimeError)
- end
+ it "gathers initial args as elements when each yields multiple" do
+ multi = EnumerableSpecs::YieldsMulti.new
+ multi.none? {|e| e == [1, 2] }.should be_true
+ end
- it "calls the pattern with gathered array when yielded with multiple arguments" do
- multi = EnumerableSpecs::YieldsMulti.new
- pattern = EnumerableSpecs::Pattern.new { false }
- multi.none?(pattern).should == true
- pattern.yielded.should == [[[1, 2]], [[3, 4, 5]], [[6, 7, 8, 9]]]
- end
- end
+ it "yields multiple arguments when each yields multiple" do
+ multi = EnumerableSpecs::YieldsMulti.new
+ yielded = []
+ multi.none? {|e, i| yielded << [e, i] }
+ yielded.should == [[1, 2]]
end
end
diff --git a/spec/ruby/core/enumerable/one_spec.rb b/spec/ruby/core/enumerable/one_spec.rb
index 2ae8b3efa4..5f118e3323 100644
--- a/spec/ruby/core/enumerable/one_spec.rb
+++ b/spec/ruby/core/enumerable/one_spec.rb
@@ -1,64 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#one?" do
- before :each do
- @empty = EnumerableSpecs::Empty.new
- @enum = EnumerableSpecs::Numerous.new
- @enum1 = EnumerableSpecs::Numerous.new(0, 1, 2, -1)
- @enum2 = EnumerableSpecs::Numerous.new(nil, false, true)
- end
-
- it "always returns false on empty enumeration" do
- @empty.one?.should == false
- @empty.one? { true }.should == false
- end
-
- it "raises an ArgumentError when more than 1 argument is provided" do
- -> { @enum.one?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { [].one?(1, 2, 3) }.should raise_error(ArgumentError)
- -> { {}.one?(1, 2, 3) }.should raise_error(ArgumentError)
- end
-
- ruby_version_is ""..."2.5" do
- it "raises an ArgumentError when any arguments provided" do
- -> { @enum.one?(Proc.new {}) }.should raise_error(ArgumentError)
- -> { @enum.one?(nil) }.should raise_error(ArgumentError)
- -> { @empty.one?(1) }.should raise_error(ArgumentError)
- -> { @enum.one?(1) {} }.should raise_error(ArgumentError)
- end
- end
-
- it "does not hide exceptions out of #each" do
- -> {
- EnumerableSpecs::ThrowingEach.new.one?
- }.should raise_error(RuntimeError)
-
- -> {
- EnumerableSpecs::ThrowingEach.new.one? { false }
- }.should raise_error(RuntimeError)
- end
-
- describe "with no block" do
- it "returns true if only one element evaluates to true" do
- [false, nil, true].one?.should be_true
- end
-
- it "returns false if two elements evaluate to true" do
- [false, :value, nil, true].one?.should be_false
- end
-
- it "returns false if all elements evaluate to false" do
- [false, nil, false].one?.should be_false
- end
-
- it "gathers whole arrays as elements when each yields multiple" do
- multi = EnumerableSpecs::YieldsMultiWithSingleTrue.new
- multi.one?.should be_false
- end
- end
-
- describe "with a block" do
+ describe "when passed a block" do
it "returns true if block returns true once" do
[:a, :b, :c].one? { |s| s == :a }.should be_true
end
@@ -71,99 +15,46 @@ describe "Enumerable#one?" do
[:a, :b, :c].one? { |s| s == :d }.should be_false
end
- it "does not hide exceptions out of the block" do
- -> {
- @enum.one? { raise "from block" }
- }.should raise_error(RuntimeError)
- end
-
it "gathers initial args as elements when each yields multiple" do
+ # This spec doesn't spec what it says it does
multi = EnumerableSpecs::YieldsMulti.new
- yielded = []
- multi.one? { |e| yielded << e; false }.should == false
- yielded.should == [1, 3, 6]
+ multi.one? {|e| e == 1 }.should be_true
end
it "yields multiple arguments when each yields multiple" do
multi = EnumerableSpecs::YieldsMulti.new
yielded = []
- multi.one? { |*args| yielded << args; false }.should == false
- yielded.should == [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
+ multi.one? {|e, i| yielded << [e, i] }
+ yielded.should == [[1, 2], [3, 4]]
end
- end
-
-
- ruby_version_is "2.5" do
- describe 'when given a pattern argument' do
- it "calls `===` on the pattern the return value " do
- pattern = EnumerableSpecs::Pattern.new { |x| x == 1 }
- @enum1.one?(pattern).should == true
- pattern.yielded.should == [[0], [1], [2], [-1]]
- end
- # may raise an exception in future versions
- ruby_version_is ""..."2.6" do
- it "ignores block" do
- @enum2.one?(NilClass) { raise }.should == true
- [1, 2, nil].one?(NilClass) { raise }.should == true
- {a: 1}.one?(Array) { raise }.should == true
+ ruby_version_is "2.5" do
+ describe "given a pattern argument" do
+ # This spec should be replaced by more extensive ones
+ it "returns true iff none match that pattern" do
+ EnumerableSpecs::Numerous.new.one?(Integer).should == false
+ [nil, false, true].one?(NilClass).should == true
end
end
+ end
+ end
- it "always returns false on empty enumeration" do
- @empty.one?(Integer).should == false
- [].one?(Integer).should == false
- {}.one?(NilClass).should == false
- end
-
- it "does not hide exceptions out of #each" do
- -> {
- EnumerableSpecs::ThrowingEach.new.one?(Integer)
- }.should raise_error(RuntimeError)
- end
-
- it "returns true if the pattern returns a truthy value only once" do
- @enum2.one?(NilClass).should == true
- pattern = EnumerableSpecs::Pattern.new { |x| x == 2 }
- @enum1.one?(pattern).should == true
-
- [1, 2, 42, 3].one?(pattern).should == true
-
- pattern = EnumerableSpecs::Pattern.new { |x| x == [:b, 2] }
- {a: 1, b: 2}.one?(pattern).should == true
- end
-
- it "returns false if the pattern returns a truthy value more than once" do
- pattern = EnumerableSpecs::Pattern.new { |x| !x }
- @enum2.one?(pattern).should == false
- pattern.yielded.should == [[nil], [false]]
-
- [1, 2, 3].one?(Integer).should == false
- {a: 1, b: 2}.one?(Array).should == false
- end
-
- it "returns false if the pattern never returns a truthy value" do
- pattern = EnumerableSpecs::Pattern.new { |x| nil }
- @enum1.one?(pattern).should == false
- pattern.yielded.should == [[0], [1], [2], [-1]]
+ describe "when not passed a block" do
+ it "returns true if only one element evaluates to true" do
+ [false, nil, true].one?.should be_true
+ end
- [1, 2, 3].one?(pattern).should == false
- {a: 1}.one?(pattern).should == false
- end
+ it "returns false if two elements evaluate to true" do
+ [false, :value, nil, true].one?.should be_false
+ end
- it "does not hide exceptions out of pattern#===" do
- pattern = EnumerableSpecs::Pattern.new { raise "from pattern" }
- -> {
- @enum.one?(pattern)
- }.should raise_error(RuntimeError)
- end
+ it "returns false if all elements evaluate to false" do
+ [false, nil, false].one?.should be_false
+ end
- it "calls the pattern with gathered array when yielded with multiple arguments" do
- multi = EnumerableSpecs::YieldsMulti.new
- pattern = EnumerableSpecs::Pattern.new { false }
- multi.one?(pattern).should == false
- pattern.yielded.should == [[[1, 2]], [[3, 4, 5]], [[6, 7, 8, 9]]]
- end
+ it "gathers whole arrays as elements when each yields multiple" do
+ multi = EnumerableSpecs::YieldsMultiWithSingleTrue.new
+ multi.one?.should be_false
end
end
end
diff --git a/spec/ruby/core/enumerable/partition_spec.rb b/spec/ruby/core/enumerable/partition_spec.rb
index d3d220b4b4..4319a9328f 100644
--- a/spec/ruby/core/enumerable/partition_spec.rb
+++ b/spec/ruby/core/enumerable/partition_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#partition" do
it "returns two arrays, the first containing elements for which the block is true, the second containing the rest" do
diff --git a/spec/ruby/core/enumerable/reduce_spec.rb b/spec/ruby/core/enumerable/reduce_spec.rb
index bc8691c1b0..8afecb2a8e 100644
--- a/spec/ruby/core/enumerable/reduce_spec.rb
+++ b/spec/ruby/core/enumerable/reduce_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/inject'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/inject', __FILE__)
describe "Enumerable#reduce" do
it_behaves_like :enumerable_inject, :reduce
diff --git a/spec/ruby/core/enumerable/reject_spec.rb b/spec/ruby/core/enumerable/reject_spec.rb
index 0d86b49ea2..3dbfb07067 100644
--- a/spec/ruby/core/enumerable/reject_spec.rb
+++ b/spec/ruby/core/enumerable/reject_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#reject" do
it "returns an array of the elements for which block is false" do
diff --git a/spec/ruby/core/enumerable/reverse_each_spec.rb b/spec/ruby/core/enumerable/reverse_each_spec.rb
index 2b1c233488..62c3c0daef 100644
--- a/spec/ruby/core/enumerable/reverse_each_spec.rb
+++ b/spec/ruby/core/enumerable/reverse_each_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#reverse_each" do
it "traverses enum in reverse order and pass each element to block" do
diff --git a/spec/ruby/core/enumerable/select_spec.rb b/spec/ruby/core/enumerable/select_spec.rb
index 11168eb42e..b4da35c754 100644
--- a/spec/ruby/core/enumerable/select_spec.rb
+++ b/spec/ruby/core/enumerable/select_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/find_all'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/find_all', __FILE__)
describe "Enumerable#select" do
- it_behaves_like :enumerable_find_all , :select
+ it_behaves_like(:enumerable_find_all , :select)
end
diff --git a/spec/ruby/core/enumerable/shared/collect.rb b/spec/ruby/core/enumerable/shared/collect.rb
index 05e94777c7..f66c539904 100644
--- a/spec/ruby/core/enumerable/shared/collect.rb
+++ b/spec/ruby/core/enumerable/shared/collect.rb
@@ -1,4 +1,4 @@
-require_relative 'enumerable_enumeratorized'
+require File.expand_path('../enumerable_enumeratorized', __FILE__)
describe :enumerable_collect, shared: true do
before :each do
@@ -22,12 +22,6 @@ describe :enumerable_collect, shared: true do
multi.send(@method) {|e| e}.should == [1,3,6]
end
- it "only yields increasing values for a Range" do
- (1..0).send(@method) { |x| x }.should == []
- (1..1).send(@method) { |x| x }.should == [1]
- (1..2).send(@method) { |x| x }.should == [1, 2]
- end
-
it "returns an enumerator when no block given" do
enum = EnumerableSpecs::Numerous.new.send(@method)
enum.should be_an_instance_of(Enumerator)
diff --git a/spec/ruby/core/enumerable/shared/collect_concat.rb b/spec/ruby/core/enumerable/shared/collect_concat.rb
index ddd431baeb..54e10692eb 100644
--- a/spec/ruby/core/enumerable/shared/collect_concat.rb
+++ b/spec/ruby/core/enumerable/shared/collect_concat.rb
@@ -1,4 +1,4 @@
-require_relative 'enumerable_enumeratorized'
+require File.expand_path('../enumerable_enumeratorized', __FILE__)
describe :enumerable_collect_concat, shared: true do
it "yields elements to the block and flattens one level" do
@@ -41,7 +41,7 @@ describe :enumerable_collect_concat, shared: true do
obj = mock("to_ary defined")
obj.should_receive(:to_ary).and_return("array")
- -> { [1, obj, 3].send(@method) { |i| i } }.should raise_error(TypeError)
+ lambda { [1, obj, 3].send(@method) { |i| i } }.should raise_error(TypeError)
end
it "returns an enumerator when no block given" do
diff --git a/spec/ruby/core/enumerable/shared/entries.rb b/spec/ruby/core/enumerable/shared/entries.rb
index 590ce73bcf..f52844cb45 100644
--- a/spec/ruby/core/enumerable/shared/entries.rb
+++ b/spec/ruby/core/enumerable/shared/entries.rb
@@ -14,13 +14,11 @@ describe :enumerable_entries, shared: true do
count.arguments_passed.should == [:hello, "world"]
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted array if self is tainted" do
- EnumerableSpecs::Empty.new.taint.send(@method).tainted?.should be_true
- end
+ it "returns a tainted array if self is tainted" do
+ EnumerableSpecs::Empty.new.taint.send(@method).tainted?.should be_true
+ end
- it "returns an untrusted array if self is untrusted" do
- EnumerableSpecs::Empty.new.untrust.send(@method).untrusted?.should be_true
- end
+ it "returns an untrusted array if self is untrusted" do
+ EnumerableSpecs::Empty.new.untrust.send(@method).untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/enumerable/shared/enumerable_enumeratorized.rb b/spec/ruby/core/enumerable/shared/enumerable_enumeratorized.rb
index e2bbe18eda..b03ce9ed4e 100644
--- a/spec/ruby/core/enumerable/shared/enumerable_enumeratorized.rb
+++ b/spec/ruby/core/enumerable/shared/enumerable_enumeratorized.rb
@@ -1,4 +1,4 @@
-require_relative 'enumeratorized'
+require File.expand_path('../enumeratorized', __FILE__)
describe :enumerable_enumeratorized_with_unknown_size, shared: true do
describe "Enumerable with size" do
diff --git a/spec/ruby/core/enumerable/shared/find.rb b/spec/ruby/core/enumerable/shared/find.rb
index 61d63ba3d5..4cbbf07be0 100644
--- a/spec/ruby/core/enumerable/shared/find.rb
+++ b/spec/ruby/core/enumerable/shared/find.rb
@@ -1,4 +1,4 @@
-require_relative 'enumerable_enumeratorized'
+require File.expand_path('../enumerable_enumeratorized', __FILE__)
describe :enumerable_find, shared: true do
# #detect and #find are aliases, so we only need one function
@@ -29,30 +29,26 @@ describe :enumerable_find, shared: true do
end
it "returns the value of the ifnone proc if the block is false" do
- fail_proc = -> { "cheeseburgers" }
+ fail_proc = lambda { "cheeseburgers" }
@numerous.send(@method, fail_proc) {|e| false }.should == "cheeseburgers"
end
it "doesn't call the ifnone proc if an element is found" do
- fail_proc = -> { raise "This shouldn't have been called" }
+ fail_proc = lambda { raise "This shouldn't have been called" }
@numerous.send(@method, fail_proc) {|e| e == @elements.first }.should == 2
end
it "calls the ifnone proc only once when the block is false" do
times = 0
- fail_proc = -> { times += 1; raise if times > 1; "cheeseburgers" }
+ fail_proc = lambda { times += 1; raise if times > 1; "cheeseburgers" }
@numerous.send(@method, fail_proc) {|e| false }.should == "cheeseburgers"
end
it "calls the ifnone proc when there are no elements" do
- fail_proc = -> { "yay" }
+ fail_proc = lambda { "yay" }
@empty.send(@method, fail_proc) {|e| true}.should == "yay"
end
- it "ignores the ifnone argument when nil" do
- @numerous.send(@method, nil) {|e| false }.should == nil
- end
-
it "passes through the values yielded by #each_with_index" do
[:a, :b].each_with_index.send(@method) { |x, i| ScratchPad << [x, i]; nil }
ScratchPad.recorded.should == [[:a, 0], [:b, 1]]
@@ -64,7 +60,7 @@ describe :enumerable_find, shared: true do
it "passes the ifnone proc to the enumerator" do
times = 0
- fail_proc = -> { times += 1; raise if times > 1; "cheeseburgers" }
+ fail_proc = lambda { times += 1; raise if times > 1; "cheeseburgers" }
@numerous.send(@method, fail_proc).each {|e| false }.should == "cheeseburgers"
end
diff --git a/spec/ruby/core/enumerable/shared/find_all.rb b/spec/ruby/core/enumerable/shared/find_all.rb
index 1bbe71f372..3e15c68e9f 100644
--- a/spec/ruby/core/enumerable/shared/find_all.rb
+++ b/spec/ruby/core/enumerable/shared/find_all.rb
@@ -1,4 +1,4 @@
-require_relative 'enumerable_enumeratorized'
+require File.expand_path('../enumerable_enumeratorized', __FILE__)
describe :enumerable_find_all, shared: true do
before :each do
diff --git a/spec/ruby/core/enumerable/shared/take.rb b/spec/ruby/core/enumerable/shared/take.rb
index ce2ace20fa..bf2536acda 100644
--- a/spec/ruby/core/enumerable/shared/take.rb
+++ b/spec/ruby/core/enumerable/shared/take.rb
@@ -25,7 +25,7 @@ describe :enumerable_take, shared: true do
end
it "raises an ArgumentError when count is negative" do
- -> { @enum.send(@method, -1) }.should raise_error(ArgumentError)
+ lambda { @enum.send(@method, -1) }.should raise_error(ArgumentError)
end
it "returns the entire array when count > length" do
@@ -40,11 +40,11 @@ describe :enumerable_take, shared: true do
end
it "raises a TypeError if the passed argument is not numeric" do
- -> { @enum.send(@method, nil) }.should raise_error(TypeError)
- -> { @enum.send(@method, "a") }.should raise_error(TypeError)
+ lambda { @enum.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @enum.send(@method, "a") }.should raise_error(TypeError)
obj = mock("nonnumeric")
- -> { @enum.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @enum.send(@method, obj) }.should raise_error(TypeError)
end
it "gathers whole arrays as elements when each yields multiple" do
diff --git a/spec/ruby/core/enumerable/slice_after_spec.rb b/spec/ruby/core/enumerable/slice_after_spec.rb
index 0e46688db1..a199b9f1ed 100644
--- a/spec/ruby/core/enumerable/slice_after_spec.rb
+++ b/spec/ruby/core/enumerable/slice_after_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#slice_after" do
before :each do
@@ -41,14 +41,14 @@ describe "Enumerable#slice_after" do
describe "and an argument" do
it "raises an ArgumentError" do
- -> { @enum.slice_after(42) { |i| i == 6 } }.should raise_error(ArgumentError)
+ lambda { @enum.slice_after(42) { |i| i == 6 } }.should raise_error(ArgumentError)
end
end
end
it "raises an ArgumentError when given an incorrect number of arguments" do
- -> { @enum.slice_after("one", "two") }.should raise_error(ArgumentError)
- -> { @enum.slice_after }.should raise_error(ArgumentError)
+ lambda { @enum.slice_after("one", "two") }.should raise_error(ArgumentError)
+ lambda { @enum.slice_after }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/enumerable/slice_before_spec.rb b/spec/ruby/core/enumerable/slice_before_spec.rb
index f9b33f7b28..1594372d32 100644
--- a/spec/ruby/core/enumerable/slice_before_spec.rb
+++ b/spec/ruby/core/enumerable/slice_before_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#slice_before" do
before :each do
@@ -40,16 +40,39 @@ describe "Enumerable#slice_before" do
end
end
- it "does not accept arguments" do
- -> {
- @enum.slice_before(1) {}
- }.should raise_error(ArgumentError)
+ ruby_version_is ""..."2.3" do
+ describe "and an argument" do
+ it "calls the block with a copy of that argument" do
+ arg = [:foo]
+ first = nil
+ e = @enum.slice_before(arg) do |i, init|
+ init.should == arg
+ init.should_not equal(arg)
+ first = init
+ i == 6 || i == 2
+ end
+ e.should be_an_instance_of(Enumerator)
+ e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]]
+ e = @enum.slice_before(arg) do |i, init|
+ init.should_not equal(first)
+ end
+ e.to_a
+ end
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "does not accept arguments" do
+ lambda {
+ @enum.slice_before(1) {}
+ }.should raise_error(ArgumentError)
+ end
end
end
it "raises an ArgumentError when given an incorrect number of arguments" do
- -> { @enum.slice_before("one", "two") }.should raise_error(ArgumentError)
- -> { @enum.slice_before }.should raise_error(ArgumentError)
+ lambda { @enum.slice_before("one", "two") }.should raise_error(ArgumentError)
+ lambda { @enum.slice_before }.should raise_error(ArgumentError)
end
describe "when an iterator method yields more than one value" do
diff --git a/spec/ruby/core/enumerable/slice_when_spec.rb b/spec/ruby/core/enumerable/slice_when_spec.rb
index 6b8ea0923e..593e623b1b 100644
--- a/spec/ruby/core/enumerable/slice_when_spec.rb
+++ b/spec/ruby/core/enumerable/slice_when_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#slice_when" do
before :each do
@@ -39,7 +39,7 @@ describe "Enumerable#slice_when" do
context "when not given a block" do
it "raises an ArgumentError" do
- -> { @enum.slice_when }.should raise_error(ArgumentError)
+ lambda { @enum.slice_when }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/enumerable/sort_by_spec.rb b/spec/ruby/core/enumerable/sort_by_spec.rb
index 8fdd923fb4..f7df8659a8 100644
--- a/spec/ruby/core/enumerable/sort_by_spec.rb
+++ b/spec/ruby/core/enumerable/sort_by_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#sort_by" do
it "returns an array of elements ordered by the result of block" do
@@ -32,12 +32,5 @@ describe "Enumerable#sort_by" do
b.sort_by{ |x| -x }.should == [3, 2, 1]
end
- it "calls #each to iterate over the elements to be sorted" do
- b = EnumerableSpecs::Numerous.new( 1, 2, 3 )
- b.should_receive(:each).once.and_yield(1).and_yield(2).and_yield(3)
- b.should_not_receive :map
- b.sort_by { |x| -x }.should == [3, 2, 1]
- end
-
it_behaves_like :enumerable_enumeratorized_with_origin_size, :sort_by
end
diff --git a/spec/ruby/core/enumerable/sort_spec.rb b/spec/ruby/core/enumerable/sort_spec.rb
index cff1a59986..a39fa7ed34 100644
--- a/spec/ruby/core/enumerable/sort_spec.rb
+++ b/spec/ruby/core/enumerable/sort_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#sort" do
it "sorts by the natural order as defined by <=>" do
@@ -14,7 +14,7 @@ describe "Enumerable#sort" do
end
it "raises a NoMethodError if elements do not define <=>" do
- -> do
+ lambda do
EnumerableSpecs::Numerous.new(BasicObject.new, BasicObject.new, BasicObject.new).sort
end.should raise_error(NoMethodError)
end
@@ -33,14 +33,14 @@ describe "Enumerable#sort" do
EnumerableSpecs::Numerous.new.sort { |n, m|
EnumerableSpecs::ComparableWithFixnum.new(-(n+m) * (n <=> m))
}.should == [6, 5, 4, 3, 2, 1]
- -> {
+ lambda {
EnumerableSpecs::Numerous.new.sort { |n, m| (n <=> m).to_s }
}.should raise_error(ArgumentError)
end
it "raises an error if objects can't be compared" do
a=EnumerableSpecs::Numerous.new(EnumerableSpecs::Uncomparable.new, EnumerableSpecs::Uncomparable.new)
- -> {a.sort}.should raise_error(ArgumentError)
+ lambda {a.sort}.should raise_error(ArgumentError)
end
it "gathers whole arrays as elements when each yields multiple" do
diff --git a/spec/ruby/core/enumerable/sum_spec.rb b/spec/ruby/core/enumerable/sum_spec.rb
index c9d7017b45..4881039a8d 100644
--- a/spec/ruby/core/enumerable/sum_spec.rb
+++ b/spec/ruby/core/enumerable/sum_spec.rb
@@ -1,28 +1,30 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe 'Enumerable#sum' do
- before :each do
- @enum = Object.new.to_enum
- class << @enum
- def each
- yield 0
- yield(-1)
- yield 2
- yield 2/3r
+ruby_version_is '2.4' do
+ describe 'Enumerable#sum' do
+ before :each do
+ @enum = Object.new.to_enum
+ class << @enum
+ def each
+ yield 0
+ yield(-1)
+ yield 2
+ yield 2/3r
+ end
end
end
- end
- it 'returns amount of the elements with taking an argument as the initial value' do
- @enum.sum(10).should == 35/3r
- end
+ it 'returns amount of the elements with taking an argument as the initial value' do
+ @enum.sum(10).should == 35/3r
+ end
- it 'gives 0 as a default argument' do
- @enum.sum.should == 5/3r
- end
+ it 'gives 0 as a default argument' do
+ @enum.sum.should == 5/3r
+ end
- it 'takes a block to transform the elements' do
- @enum.sum { |element| element * 2 }.should == 10/3r
+ it 'takes a block to transform the elements' do
+ @enum.sum { |element| element * 2 }.should == 10/3r
+ end
end
end
diff --git a/spec/ruby/core/enumerable/take_spec.rb b/spec/ruby/core/enumerable/take_spec.rb
index 41a7438330..71bf77050c 100644
--- a/spec/ruby/core/enumerable/take_spec.rb
+++ b/spec/ruby/core/enumerable/take_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/take'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/take', __FILE__)
describe "Enumerable#take" do
it "requires an argument" do
- ->{ EnumerableSpecs::Numerous.new.take}.should raise_error(ArgumentError)
+ lambda{ EnumerableSpecs::Numerous.new.take}.should raise_error(ArgumentError)
end
describe "when passed an argument" do
diff --git a/spec/ruby/core/enumerable/take_while_spec.rb b/spec/ruby/core/enumerable/take_while_spec.rb
index 26db39ac4b..990d16209a 100644
--- a/spec/ruby/core/enumerable/take_while_spec.rb
+++ b/spec/ruby/core/enumerable/take_while_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/enumerable_enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/enumerable_enumeratorized', __FILE__)
describe "Enumerable#take_while" do
before :each do
diff --git a/spec/ruby/core/enumerable/tally_spec.rb b/spec/ruby/core/enumerable/tally_spec.rb
deleted file mode 100644
index 363b3def21..0000000000
--- a/spec/ruby/core/enumerable/tally_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-ruby_version_is "2.7" do
- describe "Enumerable#tally" do
- before :each do
- ScratchPad.record []
- end
-
- it "returns a hash with counts according to the value" do
- enum = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz')
- enum.tally.should == { 'foo' => 2, 'bar' => 1, 'baz' => 1}
- end
-
- it "returns a hash without default" do
- hash = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz').tally
- hash.default_proc.should be_nil
- hash.default.should be_nil
- end
-
- it "returns an empty hash for empty enumerables" do
- EnumerableSpecs::Empty.new.tally.should == {}
- end
-
- it "counts values as gathered array when yielded with multiple arguments" do
- EnumerableSpecs::YieldsMixed2.new.tally.should == EnumerableSpecs::YieldsMixed2.gathered_yields.group_by(&:itself).transform_values(&:size)
- end
-
- it "does not call given block" do
- enum = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz')
- enum.tally { |v| ScratchPad << v }
- ScratchPad.recorded.should == []
- end
- end
-end
diff --git a/spec/ruby/core/enumerable/to_a_spec.rb b/spec/ruby/core/enumerable/to_a_spec.rb
index 0f3060dc48..b14a3c7a1a 100644
--- a/spec/ruby/core/enumerable/to_a_spec.rb
+++ b/spec/ruby/core/enumerable/to_a_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/entries'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/entries', __FILE__)
describe "Enumerable#to_a" do
- it_behaves_like :enumerable_entries , :to_a
+ it_behaves_like(:enumerable_entries , :to_a)
end
diff --git a/spec/ruby/core/enumerable/to_h_spec.rb b/spec/ruby/core/enumerable/to_h_spec.rb
index 63bfdf19af..b5b301b882 100644
--- a/spec/ruby/core/enumerable/to_h_spec.rb
+++ b/spec/ruby/core/enumerable/to_h_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#to_h" do
it "converts empty enumerable to empty hash" do
@@ -36,55 +36,11 @@ describe "Enumerable#to_h" do
it "raises TypeError if an element is not an array" do
enum = EnumerableSpecs::EachDefiner.new(:x)
- -> { enum.to_h }.should raise_error(TypeError)
+ lambda { enum.to_h }.should raise_error(TypeError)
end
it "raises ArgumentError if an element is not a [key, value] pair" do
enum = EnumerableSpecs::EachDefiner.new([:x])
- -> { enum.to_h }.should raise_error(ArgumentError)
- end
-
- ruby_version_is "2.6" do
- context "with block" do
- before do
- @enum = EnumerableSpecs::EachDefiner.new(:a, :b)
- end
-
- it "converts [key, value] pairs returned by the block to a hash" do
- @enum.to_h { |k| [k, k.to_s] }.should == { a: 'a', b: 'b' }
- end
-
- it "raises ArgumentError if block returns longer or shorter array" do
- -> do
- @enum.to_h { |k| [k, k.to_s, 1] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
-
- -> do
- @enum.to_h { |k| [k] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
- end
-
- it "raises TypeError if block returns something other than Array" do
- -> do
- @enum.to_h { |k| "not-array" }
- end.should raise_error(TypeError, /wrong element type String/)
- end
-
- it "coerces returned pair to Array with #to_ary" do
- x = mock('x')
- x.stub!(:to_ary).and_return([:b, 'b'])
-
- @enum.to_h { |k| x }.should == { :b => 'b' }
- end
-
- it "does not coerce returned pair to Array with #to_a" do
- x = mock('x')
- x.stub!(:to_a).and_return([:b, 'b'])
-
- -> do
- @enum.to_h { |k| x }
- end.should raise_error(TypeError, /wrong element type MockObject/)
- end
- end
+ lambda { enum.to_h }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/enumerable/uniq_spec.rb b/spec/ruby/core/enumerable/uniq_spec.rb
index 82c041d4ef..5ca7556aed 100644
--- a/spec/ruby/core/enumerable/uniq_spec.rb
+++ b/spec/ruby/core/enumerable/uniq_spec.rb
@@ -1,67 +1,37 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe 'Enumerable#uniq' do
- it 'returns an array that contains only unique elements' do
- [0, 1, 2, 3].to_enum.uniq { |n| n.even? }.should == [0, 1]
- end
-
- it "uses eql? semantics" do
- [1.0, 1].to_enum.uniq.should == [1.0, 1]
- end
-
- it "compares elements first with hash" do
- x = mock('0')
- x.should_receive(:hash).at_least(1).and_return(0)
- y = mock('0')
- y.should_receive(:hash).at_least(1).and_return(0)
-
- [x, y].to_enum.uniq.should == [x, y]
- end
-
- it "does not compare elements with different hash codes via eql?" do
- x = mock('0')
- x.should_not_receive(:eql?)
- y = mock('1')
- y.should_not_receive(:eql?)
-
- x.should_receive(:hash).at_least(1).and_return(0)
- y.should_receive(:hash).at_least(1).and_return(1)
-
- [x, y].to_enum.uniq.should == [x, y]
- end
-
- ruby_version_is '2.7' do
- it "compares elements with matching hash codes with #eql?" do
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
-
- def obj.eql?(o)
- false
- end
+ruby_version_is '2.4' do
+ describe 'Enumerable#uniq' do
+ it 'returns an array that contains only unique elements' do
+ [0, 1, 2, 3].to_enum.uniq { |n| n.even? }.should == [0, 1]
+ end
- obj
- end
+ it "uses eql? semantics" do
+ [1.0, 1].to_enum.uniq.should == [1.0, 1]
+ end
- a.uniq.should == a
+ it "compares elements first with hash" do
+ x = mock('0')
+ x.should_receive(:hash).at_least(1).and_return(0)
+ y = mock('0')
+ y.should_receive(:hash).at_least(1).and_return(0)
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
+ [x, y].to_enum.uniq.should == [x, y]
+ end
- def obj.eql?(o)
- true
- end
+ it "does not compare elements with different hash codes via eql?" do
+ x = mock('0')
+ x.should_not_receive(:eql?)
+ y = mock('1')
+ y.should_not_receive(:eql?)
- obj
- end
+ x.should_receive(:hash).at_least(1).and_return(0)
+ y.should_receive(:hash).at_least(1).and_return(1)
- a.to_enum.uniq.size.should == 1
+ [x, y].to_enum.uniq.should == [x, y]
end
- end
- ruby_version_is ''...'2.7' do
it "compares elements with matching hash codes with #eql?" do
a = Array.new(2) do
obj = mock('0')
@@ -101,22 +71,24 @@ describe 'Enumerable#uniq' do
a[0].tainted?.should == true
a[1].tainted?.should == true
end
- end
- context 'when yielded with multiple arguments' do
- before :each do
- @enum = Object.new.to_enum
- class << @enum
- def each
- yield 0, 'foo'
- yield 1, 'FOO'
- yield 2, 'bar'
+ context 'when yielded with multiple arguments' do
+ before :each do
+ @enum = Object.new.to_enum
+ class << @enum
+ def each
+ yield 0, 'foo'
+ yield 1, 'FOO'
+ yield 2, 'bar'
+ end
end
end
- end
- it 'returns all yield arguments as an array' do
- @enum.uniq { |_, label| label.downcase }.should == [[0, 'foo'], [2, 'bar']]
+ ruby_bug '#13669', ''...'2.5' do
+ it 'returns all yield arguments as an array' do
+ @enum.uniq { |_, label| label.downcase }.should == [[0, 'foo'], [2, 'bar']]
+ end
+ end
end
end
end
diff --git a/spec/ruby/core/enumerable/zip_spec.rb b/spec/ruby/core/enumerable/zip_spec.rb
index 9ec15aa030..2d090f335c 100644
--- a/spec/ruby/core/enumerable/zip_spec.rb
+++ b/spec/ruby/core/enumerable/zip_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerable#zip" do
@@ -21,16 +21,16 @@ describe "Enumerable#zip" do
end
it "converts arguments to arrays using #to_ary" do
- convertible = EnumerableSpecs::ArrayConvertible.new(4,5,6)
- EnumerableSpecs::Numerous.new(1,2,3).zip(convertible).should == [[1,4],[2,5],[3,6]]
- convertible.called.should == :to_ary
+ convertable = EnumerableSpecs::ArrayConvertable.new(4,5,6)
+ EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
+ convertable.called.should == :to_ary
end
it "converts arguments to enums using #to_enum" do
- convertible = EnumerableSpecs::EnumConvertible.new(4..6)
- EnumerableSpecs::Numerous.new(1,2,3).zip(convertible).should == [[1,4],[2,5],[3,6]]
- convertible.called.should == :to_enum
- convertible.sym.should == :each
+ convertable = EnumerableSpecs::EnumConvertable.new(4..6)
+ EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
+ convertable.called.should == :to_enum
+ convertable.sym.should == :each
end
it "gathers whole arrays as elements when each yields multiple" do
@@ -39,3 +39,4 @@ describe "Enumerable#zip" do
end
end
+
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb
deleted file mode 100644
index c8d91ebaec..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#begin" do
- it "returns the begin of the sequence" do
- 1.step(10).begin.should == 1
- (1..10).step.begin.should == 1
- (1...10).step.begin.should == 1
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb
deleted file mode 100644
index d7edf3a21f..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#each" do
- before :each do
- ScratchPad.record []
- @seq = 1.step(10, 4)
- end
-
- it "calls given block on each item of the sequence" do
- @seq.each { |item| ScratchPad << item }
- ScratchPad.recorded.should == [1, 5, 9]
- end
-
- it "returns self" do
- @seq.each { |item| }.should equal(@seq)
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb
deleted file mode 100644
index 5a436e8167..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#end" do
- it "returns the end of the sequence" do
- 1.step(10).end.should == 10
- (1..10).step.end.should == 10
- (1...10).step(17).end.should == 10
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb
deleted file mode 100644
index 7895f98047..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#==" do
- it "returns true if begin, end, step and exclude_end? are equal" do
- 1.step(10).should == 1.step(10)
- 1.step(10, 5).should == 1.step(10, 5)
-
- (1..10).step.should == (1..10).step
- (1...10).step(8).should == (1...10).step(8)
-
- # both have exclude_end? == false
- (1..10).step(100).should == 1.step(10, 100)
-
- ((1..10).step == (1..11).step).should == false
- ((1..10).step == (1...10).step).should == false
- ((1..10).step == (1..10).step(2)).should == false
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb
deleted file mode 100644
index 8ce0ce0cd9..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#exclude_end?" do
- context "when created using Numeric#step" do
- it "always returns false" do
- 1.step(10).exclude_end?.should == false
- 10.step(1).exclude_end?.should == false
- end
- end
-
- context "when created using Range#step" do
- it "mirrors range.exclude_end?" do
- (1...10).step.exclude_end?.should == true
- (1..10).step.exclude_end?.should == false
- end
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb
deleted file mode 100644
index 43c520d1f0..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#first" do
- it "returns the first element of the sequence" do
- 1.step(10).first.should == 1
- (1..10).step.first.should == 1
- (1...10).step.first.should == 1
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb
deleted file mode 100644
index 236f845f41..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#hash" do
- it "is based on begin, end, step and exclude_end?" do
- 1.step(10).hash.should be_an_instance_of(Integer)
-
- 1.step(10).hash.should == 1.step(10).hash
- 1.step(10, 5).hash.should == 1.step(10, 5).hash
-
- (1..10).step.hash.should == (1..10).step.hash
- (1...10).step(8).hash.should == (1...10).step(8).hash
-
- # both have exclude_end? == false
- (1..10).step(100).hash.should == 1.step(10, 100).hash
-
- ((1..10).step.hash == (1..11).step.hash).should == false
- ((1..10).step.hash == (1...10).step.hash).should == false
- ((1..10).step.hash == (1..10).step(2).hash).should == false
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb
deleted file mode 100644
index 21e64a6b58..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#inspect" do
- context 'when Numeric#step is used' do
- it "returns '(begin.step(end{, step}))'" do
- 1.step(10).inspect.should == "(1.step(10))"
- 1.step(10, 3).inspect.should == "(1.step(10, 3))"
- end
- end
-
- context 'when Range#step is used' do
- it "returns '((range).step{(step)})'" do
- (1..10).step.inspect.should == "((1..10).step)"
- (1..10).step(3).inspect.should == "((1..10).step(3))"
-
- (1...10).step.inspect.should == "((1...10).step)"
- (1...10).step(3).inspect.should == "((1...10).step(3))"
- end
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb
deleted file mode 100644
index ebb20090fc..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#last" do
- it "returns the last element of the sequence" do
- 1.step(10).last.should == 10
- (1..10).step.last.should == 10
- (1...10).step(4).last.should == 9
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb
deleted file mode 100644
index 7227581fb9..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence.new" do
- it "is not defined" do
- -> {
- Enumerator::ArithmeticSequence.new
- }.should raise_error(NoMethodError)
- end
- end
-
- describe "Enumerator::ArithmeticSequence.allocate" do
- it "is not defined" do
- -> {
- Enumerator::ArithmeticSequence.allocate
- }.should raise_error(TypeError, 'allocator undefined for Enumerator::ArithmeticSequence')
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb
deleted file mode 100644
index 00403b0238..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#size" do
- context "for finite sequence" do
- it "returns the number of elements in this arithmetic sequence" do
- 1.step(10).size.should == 10
- (1...10).step.size.should == 9
- end
- end
-
- context "for infinite sequence" do
- it "returns Infinity" do
- 1.step(Float::INFINITY).size.should == Float::INFINITY
- (1..Float::INFINITY).step.size.should == Float::INFINITY
- end
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb
deleted file mode 100644
index 20a5cb6e7b..0000000000
--- a/spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::ArithmeticSequence#step" do
- it "returns the original value given to step method" do
- (1..10).step.step.should == 1
- (1..10).step(3).step.should == 3
- (1..10).step(0).step.should == 0
-
- 1.step(10).step.should == 1
- 1.step(10, 3).step.should == 3
- 1.step(10, 0).step.should == 0
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/chain/each_spec.rb b/spec/ruby/core/enumerator/chain/each_spec.rb
deleted file mode 100644
index ab4d355f22..0000000000
--- a/spec/ruby/core/enumerator/chain/each_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../../enumerable/fixtures/classes'
-
-ruby_version_is "2.6" do
- describe "Enumerator::Chain#each" do
- it "calls each on its constituents as needed" do
- a = EnumerableSpecs::EachCounter.new(:a, :b)
- b = EnumerableSpecs::EachCounter.new(:c, :d)
-
- ScratchPad.record []
- Enumerator::Chain.new(a, b).each do |elem|
- ScratchPad << elem << b.times_yielded
- end
- ScratchPad.recorded.should == [:a, 0, :b, 0, :c, 1, :d, 2]
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/chain/initialize_spec.rb b/spec/ruby/core/enumerator/chain/initialize_spec.rb
deleted file mode 100644
index e5aa32fd02..0000000000
--- a/spec/ruby/core/enumerator/chain/initialize_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::Chain#initialize" do
- before :each do
- @uninitialized = Enumerator::Chain.allocate
- end
-
- it "is a private method" do
- Enumerator::Chain.should have_private_instance_method(:initialize, false)
- end
-
- it "returns self" do
- @uninitialized.send(:initialize).should equal(@uninitialized)
- end
-
- it "accepts many arguments" do
- @uninitialized.send(:initialize, 0..1, 2..3, 4..5).should equal(@uninitialized)
- end
-
- it "accepts arguments that are not Enumerable nor responding to :each" do
- @uninitialized.send(:initialize, Object.new).should equal(@uninitialized)
- end
-
- describe "on frozen instance" do
- it "raises a RuntimeError" do
- -> {
- @uninitialized.freeze.send(:initialize)
- }.should raise_error(RuntimeError)
- end
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/chain/inspect_spec.rb b/spec/ruby/core/enumerator/chain/inspect_spec.rb
deleted file mode 100644
index a644d88c6f..0000000000
--- a/spec/ruby/core/enumerator/chain/inspect_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::Chain#inspect" do
- it "shows a representation of the Enumerator" do
- Enumerator::Chain.new.inspect.should == "#<Enumerator::Chain: []>"
- Enumerator::Chain.new(1..2, 3..4).inspect.should == "#<Enumerator::Chain: [1..2, 3..4]>"
- end
-
- it "calls inspect on its chain elements" do
- obj = mock('inspect')
- obj.should_receive(:inspect).and_return('some desc')
- Enumerator::Chain.new(obj).inspect.should == "#<Enumerator::Chain: [some desc]>"
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/chain/rewind_spec.rb b/spec/ruby/core/enumerator/chain/rewind_spec.rb
deleted file mode 100644
index 951b364f07..0000000000
--- a/spec/ruby/core/enumerator/chain/rewind_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator::Chain#rewind" do
- before(:each) do
- @obj = mock('obj')
- @obj.should_receive(:each).any_number_of_times.and_yield
- @second = mock('obj')
- @second.should_receive(:each).any_number_of_times.and_yield
- @enum = Enumerator::Chain.new(@obj, @second)
- end
-
- it "returns self" do
- @enum.rewind.should equal @enum
- end
-
- it "does nothing if receiver has not been iterated" do
- @obj.should_not_receive(:rewind)
- @obj.respond_to?(:rewind).should == true # sanity check
- @enum.rewind
- end
-
- it "does nothing on objects that don't respond_to rewind" do
- @obj.respond_to?(:rewind).should == false # sanity check
- @enum.each {}
- @enum.rewind
- end
-
- it "calls_rewind its objects" do
- @obj.should_receive(:rewind)
- @enum.each {}
- @enum.rewind
- end
-
- it "calls_rewind in reverse order" do
- @obj.should_not_receive(:rewind)
- @second.should_receive(:rewind).and_raise(RuntimeError)
- @enum.each {}
- -> { @enum.rewind }.should raise_error(RuntimeError)
- end
-
- it "calls rewind only for objects that have actually been iterated on" do
- @obj = mock('obj')
- @obj.should_receive(:each).any_number_of_times.and_raise(RuntimeError)
- @enum = Enumerator::Chain.new(@obj, @second)
-
- @obj.should_receive(:rewind)
- @second.should_not_receive(:rewind)
- -> { @enum.each {} }.should raise_error(RuntimeError)
- @enum.rewind
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/chain/size_spec.rb b/spec/ruby/core/enumerator/chain/size_spec.rb
deleted file mode 100644
index 42c31ac10b..0000000000
--- a/spec/ruby/core/enumerator/chain/size_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../../enumerable/fixtures/classes'
-
-ruby_version_is "2.6" do
- describe "Enumerator::Chain#size" do
- it "returns the sum of the sizes of the elements" do
- a = mock('size')
- a.should_receive(:size).and_return(40)
- Enumerator::Chain.new(a, [:a, :b]).size.should == 42
- end
-
- it "returns nil or Infinity for the first element of such a size" do
- [nil, Float::INFINITY].each do |special|
- a = mock('size')
- a.should_receive(:size).and_return(40)
- b = mock('special')
- b.should_receive(:size).and_return(special)
- c = mock('not called')
- c.should_not_receive(:size)
- Enumerator::Chain.new(a, b, c).size.should == special
- end
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/each_spec.rb b/spec/ruby/core/enumerator/each_spec.rb
index d88c09cdb5..a6ecf2af2d 100644
--- a/spec/ruby/core/enumerator/each_spec.rb
+++ b/spec/ruby/core/enumerator/each_spec.rb
@@ -1,89 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../shared/enumerator/each', __FILE__)
describe "Enumerator#each" do
- before :each do
- object_each_with_arguments = Object.new
- def object_each_with_arguments.each_with_arguments(arg, *args)
- yield arg, *args
- :method_returned
- end
-
- @enum_with_arguments = object_each_with_arguments.to_enum(:each_with_arguments, :arg0, :arg1, :arg2)
-
- @enum_with_yielder = Enumerator.new {|y| y.yield :ok}
- end
-
- it "yields each element of self to the given block" do
- acc = []
- [1,2,3].to_enum.each {|e| acc << e }
- acc.should == [1,2,3]
- end
-
- it "calls #each on the object given in the constructor by default" do
- each = mock('each')
- each.should_receive(:each)
- each.to_enum.each {|e| e }
- end
-
- it "calls #each on the underlying object until it's exhausted" do
- each = mock('each')
- each.should_receive(:each).and_yield(1).and_yield(2).and_yield(3)
- acc = []
- each.to_enum.each {|e| acc << e }
- acc.should == [1,2,3]
- end
-
- it "calls the method given in the constructor instead of #each" do
- each = mock('peach')
- each.should_receive(:peach)
- each.to_enum(:peach).each {|e| e }
- end
-
- it "calls the method given in the constructor until it's exhausted" do
- each = mock('each')
- each.should_receive(:each).and_yield(1).and_yield(2).and_yield(3)
- acc = []
- each.to_enum.each {|e| acc << e }
- acc.should == [1,2,3]
- end
-
- it "raises a NoMethodError if the object doesn't respond to #each" do
- enum = Object.new.to_enum
- -> do
- enum.each { |e| e }
- end.should raise_error(NoMethodError)
- end
-
- it "returns self if not given arguments and not given a block" do
- @enum_with_arguments.each.should equal(@enum_with_arguments)
-
- @enum_with_yielder.each.should equal(@enum_with_yielder)
- end
-
- it "returns the same value from receiver.each if block is given" do
- @enum_with_arguments.each {}.should equal(:method_returned)
- end
-
- it "passes given arguments at initialized to receiver.each" do
- @enum_with_arguments.each.to_a.should == [[:arg0, :arg1, :arg2]]
- end
-
- it "requires multiple arguments" do
- Enumerator.instance_method(:each).arity.should < 0
- end
-
- it "appends given arguments to receiver.each" do
- @enum_with_arguments.each(:each0, :each1).to_a.should == [[:arg0, :arg1, :arg2, :each0, :each1]]
- @enum_with_arguments.each(:each2, :each3).to_a.should == [[:arg0, :arg1, :arg2, :each2, :each3]]
- end
-
- it "returns the same value from receiver.each if block and arguments are given" do
- @enum_with_arguments.each(:each1, :each2) {}.should equal(:method_returned)
- end
-
- it "returns new Enumerator if given arguments but not given a block" do
- ret = @enum_with_arguments.each 1
- ret.should be_an_instance_of(Enumerator)
- ret.should_not equal(@enum_with_arguments)
- end
+ it_behaves_like(:enum_each, :each)
end
diff --git a/spec/ruby/core/enumerator/each_with_index_spec.rb b/spec/ruby/core/enumerator/each_with_index_spec.rb
index 96e53a2804..c8cb0bd496 100644
--- a/spec/ruby/core/enumerator/each_with_index_spec.rb
+++ b/spec/ruby/core/enumerator/each_with_index_spec.rb
@@ -1,20 +1,20 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/enumerator/with_index'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/with_index', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Enumerator#each_with_index" do
- it_behaves_like :enum_with_index, :each_with_index
- it_behaves_like :enumeratorized_with_origin_size, :each_with_index, [1,2,3].select
+ it_behaves_like(:enum_with_index, :each_with_index)
+ it_behaves_like(:enumeratorized_with_origin_size, :each_with_index, [1,2,3].select)
it "returns a new Enumerator when no block is given" do
enum1 = [1,2,3].select
enum2 = enum1.each_with_index
enum2.should be_an_instance_of(Enumerator)
- enum1.should_not == enum2
+ enum1.should_not === enum2
end
it "raises an ArgumentError if passed extra arguments" do
- -> do
+ lambda do
[1].to_enum.each_with_index(:glark)
end.should raise_error(ArgumentError)
end
@@ -28,7 +28,9 @@ describe "Enumerator#each_with_index" do
it "returns the iterator's return value" do
[1,2,3].select.with_index { |a,b| false }.should == []
end
+end
+describe "Enumerator#each_with_index" do
it "returns the correct value if chained with itself" do
[:a].each_with_index.each_with_index.to_a.should == [[[:a,0],0]]
[:a].each.with_index.with_index.to_a.should == [[[:a,0],0]]
diff --git a/spec/ruby/core/enumerator/each_with_object_spec.rb b/spec/ruby/core/enumerator/each_with_object_spec.rb
index 68524dc74a..ec461e2425 100644
--- a/spec/ruby/core/enumerator/each_with_object_spec.rb
+++ b/spec/ruby/core/enumerator/each_with_object_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/enumerator/with_object'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/with_object', __FILE__)
describe "Enumerator#each_with_object" do
it_behaves_like :enum_with_object, :each_with_object
diff --git a/spec/ruby/core/enumerator/enum_for_spec.rb b/spec/ruby/core/enumerator/enum_for_spec.rb
index fd33f463bf..43c11e5a39 100644
--- a/spec/ruby/core/enumerator/enum_for_spec.rb
+++ b/spec/ruby/core/enumerator/enum_for_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/enumerator/enum_for'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/enum_for', __FILE__)
describe "Enumerator#enum_for" do
it_behaves_like :enum_for, :enum_for
diff --git a/spec/ruby/core/enumerator/enumerator_spec.rb b/spec/ruby/core/enumerator/enumerator_spec.rb
index 7a263336cb..2d5213edd9 100644
--- a/spec/ruby/core/enumerator/enumerator_spec.rb
+++ b/spec/ruby/core/enumerator/enumerator_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator" do
it "includes Enumerable" do
diff --git a/spec/ruby/core/enumerator/feed_spec.rb b/spec/ruby/core/enumerator/feed_spec.rb
index e387c6cd39..32ea77a30d 100644
--- a/spec/ruby/core/enumerator/feed_spec.rb
+++ b/spec/ruby/core/enumerator/feed_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Enumerator#feed" do
before :each do
@@ -39,14 +39,14 @@ describe "Enumerator#feed" do
it "raises a TypeError if called more than once without advancing the enumerator" do
@enum.feed :a
@enum.next
- -> { @enum.feed :b }.should raise_error(TypeError)
+ lambda { @enum.feed :b }.should raise_error(TypeError)
end
it "sets the return value of Yielder#yield" do
enum = Enumerator.new { |y| ScratchPad << y.yield }
enum.next
enum.feed :a
- -> { enum.next }.should raise_error(StopIteration)
+ lambda { enum.next }.should raise_error(StopIteration)
ScratchPad.recorded.should == [:a]
end
end
diff --git a/spec/ruby/core/enumerator/first_spec.rb b/spec/ruby/core/enumerator/first_spec.rb
index 458080bb31..ba3b0df492 100644
--- a/spec/ruby/core/enumerator/first_spec.rb
+++ b/spec/ruby/core/enumerator/first_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator#first" do
it "returns arrays correctly when calling #first (2376)" do
diff --git a/spec/ruby/core/enumerator/generator/each_spec.rb b/spec/ruby/core/enumerator/generator/each_spec.rb
index a43805dd16..06395d0aa0 100644
--- a/spec/ruby/core/enumerator/generator/each_spec.rb
+++ b/spec/ruby/core/enumerator/generator/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Enumerator::Generator#each" do
before :each do
@@ -21,7 +21,7 @@ describe "Enumerator::Generator#each" do
end
it "raises a LocalJumpError if no block given" do
- -> { @generator.each }.should raise_error(LocalJumpError)
+ lambda { @generator.each }.should raise_error(LocalJumpError)
end
it "returns the block returned value" do
diff --git a/spec/ruby/core/enumerator/generator/initialize_spec.rb b/spec/ruby/core/enumerator/generator/initialize_spec.rb
index f75c7d6f26..85b0e04354 100644
--- a/spec/ruby/core/enumerator/generator/initialize_spec.rb
+++ b/spec/ruby/core/enumerator/generator/initialize_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Enumerator::Generator#initialize" do
before :each do
@@ -18,7 +18,7 @@ describe "Enumerator::Generator#initialize" do
describe "on frozen instance" do
it "raises a RuntimeError" do
- -> {
+ lambda {
@uninitialized.freeze.send(:initialize) {}
}.should raise_error(RuntimeError)
end
diff --git a/spec/ruby/core/enumerator/initialize_spec.rb b/spec/ruby/core/enumerator/initialize_spec.rb
index 53bf5d4ef2..58f8a5e865 100644
--- a/spec/ruby/core/enumerator/initialize_spec.rb
+++ b/spec/ruby/core/enumerator/initialize_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: us-ascii -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator#initialize" do
before :each do
@@ -48,12 +48,12 @@ describe "Enumerator#initialize" do
end
it "sets size to the given size if the given size is a Proc" do
- @uninitialized.send(:initialize, -> { 200 }) {}.size.should == 200
+ @uninitialized.send(:initialize, lambda { 200 }) {}.size.should == 200
end
describe "on frozen instance" do
it "raises a RuntimeError" do
- -> {
+ lambda {
@uninitialized.freeze.send(:initialize) {}
}.should raise_error(RuntimeError)
end
diff --git a/spec/ruby/core/enumerator/inject_spec.rb b/spec/ruby/core/enumerator/inject_spec.rb
new file mode 100644
index 0000000000..64085a03c5
--- /dev/null
+++ b/spec/ruby/core/enumerator/inject_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../shared/enumerator/each', __FILE__)
+
+describe "Enumerator#inject" do
+ it_behaves_like(:enum_each, :each)
+
+ it "works when chained against each_with_index" do
+ passed_values = []
+ [:a].each_with_index.inject(0) do |accumulator,value|
+ passed_values << value
+ accumulator + 1
+ end.should == 1
+ passed_values.should == [[:a,0]]
+ end
+
+end
diff --git a/spec/ruby/core/enumerator/inspect_spec.rb b/spec/ruby/core/enumerator/inspect_spec.rb
index 3bcf07e754..b708256247 100644
--- a/spec/ruby/core/enumerator/inspect_spec.rb
+++ b/spec/ruby/core/enumerator/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator#inspect" do
describe "shows a representation of the Enumerator" do
diff --git a/spec/ruby/core/enumerator/lazy/chunk_spec.rb b/spec/ruby/core/enumerator/lazy/chunk_spec.rb
deleted file mode 100644
index 87d2b0c206..0000000000
--- a/spec/ruby/core/enumerator/lazy/chunk_spec.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- encoding: us-ascii -*-
-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Enumerator::Lazy#chunk" do
-
- before :each do
- @yieldsmixed = EnumeratorLazySpecs::YieldsMixed.new.to_enum.lazy
- @eventsmixed = EnumeratorLazySpecs::EventsMixed.new.to_enum.lazy
- ScratchPad.record []
- end
-
- after :each do
- ScratchPad.clear
- end
-
- it "returns a new instance of Enumerator::Lazy" do
- ret = @yieldsmixed.chunk {}
- ret.should be_an_instance_of(Enumerator::Lazy)
- ret.should_not equal(@yieldsmixed)
- end
-
- it "sets #size to nil" do
- Enumerator::Lazy.new(Object.new, 100) {}.chunk { |v| v }.size.should == nil
- end
-
- it "returns an Enumerator if called without a block" do
- chunk = @yieldsmixed.chunk
- chunk.should be_an_instance_of(Enumerator::Lazy)
-
- res = chunk.each { |v| true }.force
- res.should == [[true, EnumeratorLazySpecs::YieldsMixed.gathered_yields]]
- end
-
- describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
- it "stops after specified times" do
- first_two = (0..Float::INFINITY).lazy.chunk { |n| n.even? }.first(2)
- first_two.should == [[true, [0]], [false, [1]]]
- end
- end
-
- it "calls the block with gathered values when yield with multiple arguments" do
- yields = []
- @yieldsmixed.chunk { |v| yields << v; true }.force
- yields.should == EnumeratorLazySpecs::YieldsMixed.gathered_yields
- end
-
- describe "on a nested Lazy" do
- it "sets #size to nil" do
- Enumerator::Lazy.new(Object.new, 100) {}.take(20).chunk { |v| v }.size.should == nil
- end
-
- describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
- it "stops after specified times" do
- remains_lazy = (0..Float::INFINITY).lazy.chunk { |n| n }
- remains_lazy.chunk { |n| n }.first(2).size.should == 2
- end
- end
- end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.chunk { |n| n.even? }.first(100).should ==
- s.first(100).chunk { |n| n.even? }.to_a
- end
-end
diff --git a/spec/ruby/core/enumerator/lazy/chunk_while_spec.rb b/spec/ruby/core/enumerator/lazy/chunk_while_spec.rb
deleted file mode 100644
index d555089872..0000000000
--- a/spec/ruby/core/enumerator/lazy/chunk_while_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../../spec_helper'
-
-describe "Enumerator::Lazy#chunk_while" do
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.chunk_while { |a, b| false }.first(100).should ==
- s.first(100).chunk_while { |a, b| false }.to_a
- end
-end
diff --git a/spec/ruby/core/enumerator/lazy/collect_concat_spec.rb b/spec/ruby/core/enumerator/lazy/collect_concat_spec.rb
index 8765bb2190..8c19dcbbf9 100644
--- a/spec/ruby/core/enumerator/lazy/collect_concat_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/collect_concat_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/collect_concat'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/collect_concat', __FILE__)
describe "Enumerator::Lazy#collect_concat" do
it_behaves_like :enumerator_lazy_collect_concat, :collect_concat
diff --git a/spec/ruby/core/enumerator/lazy/collect_spec.rb b/spec/ruby/core/enumerator/lazy/collect_spec.rb
index 14b79ce16d..764b8af36d 100644
--- a/spec/ruby/core/enumerator/lazy/collect_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/collect_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/collect'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Enumerator::Lazy#collect" do
it_behaves_like :enumerator_lazy_collect, :collect
diff --git a/spec/ruby/core/enumerator/lazy/drop_spec.rb b/spec/ruby/core/enumerator/lazy/drop_spec.rb
index 822b8034fb..eb65bb246b 100644
--- a/spec/ruby/core/enumerator/lazy/drop_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/drop_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#drop" do
before :each do
@@ -49,10 +49,4 @@ describe "Enumerator::Lazy#drop" do
end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.drop(100).first(100).should ==
- s.first(200).drop(100)
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/drop_while_spec.rb b/spec/ruby/core/enumerator/lazy/drop_while_spec.rb
index 4f6e366f88..a08644a20c 100644
--- a/spec/ruby/core/enumerator/lazy/drop_while_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/drop_while_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#drop_while" do
before :each do
@@ -40,7 +40,7 @@ describe "Enumerator::Lazy#drop_while" do
end
it "raises an ArgumentError when not given a block" do
- -> { @yieldsmixed.drop_while }.should raise_error(ArgumentError)
+ lambda { @yieldsmixed.drop_while }.should raise_error(ArgumentError)
end
describe "on a nested Lazy" do
@@ -57,10 +57,4 @@ describe "Enumerator::Lazy#drop_while" do
end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.drop_while { |n| n < 100 }.first(100).should ==
- s.first(200).drop_while { |n| n < 100 }
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/enum_for_spec.rb b/spec/ruby/core/enumerator/lazy/enum_for_spec.rb
index 7e7783f6f1..b2ef2c881e 100644
--- a/spec/ruby/core/enumerator/lazy/enum_for_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/enum_for_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/to_enum'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_enum', __FILE__)
describe "Enumerator::Lazy#enum_for" do
it_behaves_like :enumerator_lazy_to_enum, :enum_for
diff --git a/spec/ruby/core/enumerator/lazy/filter_spec.rb b/spec/ruby/core/enumerator/lazy/filter_spec.rb
deleted file mode 100644
index 2ababa69cc..0000000000
--- a/spec/ruby/core/enumerator/lazy/filter_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/select'
-
-ruby_version_is "2.6" do
- describe "Enumerator::Lazy#filter" do
- it_behaves_like :enumerator_lazy_select, :filter
- end
-end
diff --git a/spec/ruby/core/enumerator/lazy/find_all_spec.rb b/spec/ruby/core/enumerator/lazy/find_all_spec.rb
index 8b05c53803..ab2e69c857 100644
--- a/spec/ruby/core/enumerator/lazy/find_all_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/find_all_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/select'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/select', __FILE__)
describe "Enumerator::Lazy#find_all" do
it_behaves_like :enumerator_lazy_select, :find_all
diff --git a/spec/ruby/core/enumerator/lazy/flat_map_spec.rb b/spec/ruby/core/enumerator/lazy/flat_map_spec.rb
index 5dcaa8bfa1..b7fba5e81c 100644
--- a/spec/ruby/core/enumerator/lazy/flat_map_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/flat_map_spec.rb
@@ -1,16 +1,8 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/collect_concat'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/collect_concat', __FILE__)
describe "Enumerator::Lazy#flat_map" do
it_behaves_like :enumerator_lazy_collect_concat, :flat_map
-
- it "properly unwraps nested yields" do
- s = Enumerator.new do |y| loop do y << [1, 2] end end
-
- expected = s.take(3).flat_map { |x| x }.to_a
- actual = s.lazy.take(3).flat_map{ |x| x }.force
- actual.should == expected
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/force_spec.rb b/spec/ruby/core/enumerator/lazy/force_spec.rb
index a7fa029135..1a218c1b0f 100644
--- a/spec/ruby/core/enumerator/lazy/force_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/force_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#force" do
before :each do
@@ -27,10 +27,4 @@ describe "Enumerator::Lazy#force" do
ScratchPad.recorded.should == [:before_yield]
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.take(100).force.should ==
- s.take(100)
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/grep_spec.rb b/spec/ruby/core/enumerator/lazy/grep_spec.rb
index e67686c9a3..372be80d61 100644
--- a/spec/ruby/core/enumerator/lazy/grep_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/grep_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#grep" do
before :each do
@@ -33,39 +33,6 @@ describe "Enumerator::Lazy#grep" do
Enumerator::Lazy.new(Object.new, 100) {}.grep(Object).size.should == nil
end
- it "sets $~ in the block" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].lazy.grep(/b/) { |e|
- e.should == "abc"
- $&.should == "b"
- }.force
-
- # Set by the failed match of "def"
- $~.should == nil
- end
-
- it "sets $~ in the next block with each" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].lazy.grep(/b/).each { |e|
- e.should == "abc"
- $&.should == "b"
- }
-
- # Set by the failed match of "def"
- $~.should == nil
- end
-
- it "sets $~ in the next block with map" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].lazy.grep(/b/).map { |e|
- e.should == "abc"
- $&.should == "b"
- }.force
-
- # Set by the failed match of "def"
- $~.should == nil
- end
-
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
it "stops after specified times when not given a block" do
(0..Float::INFINITY).lazy.grep(Integer).first(3).should == [0, 1, 2]
@@ -112,10 +79,4 @@ describe "Enumerator::Lazy#grep" do
end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.grep(Numeric).first(100).should ==
- s.first(100).grep(Numeric)
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/grep_v_spec.rb b/spec/ruby/core/enumerator/lazy/grep_v_spec.rb
index 67173021bb..123cbae58c 100644
--- a/spec/ruby/core/enumerator/lazy/grep_v_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/grep_v_spec.rb
@@ -1,123 +1,86 @@
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Enumerator::Lazy#grep_v" do
- before(:each) do
- @yieldsmixed = EnumeratorLazySpecs::YieldsMixed.new.to_enum.lazy
- @eventsmixed = EnumeratorLazySpecs::EventsMixed.new.to_enum.lazy
- ScratchPad.record []
- end
-
- after(:each) do
- ScratchPad.clear
- end
-
- it "requires an argument" do
- Enumerator::Lazy.instance_method(:grep_v).arity.should == 1
- end
-
- it "returns a new instance of Enumerator::Lazy" do
- ret = @yieldsmixed.grep_v(Object) {}
- ret.should be_an_instance_of(Enumerator::Lazy)
- ret.should_not equal(@yieldsmixed)
-
- ret = @yieldsmixed.grep_v(Object)
- ret.should be_an_instance_of(Enumerator::Lazy)
- ret.should_not equal(@yieldsmixed)
- end
-
- it "sets #size to nil" do
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object) {}.size.should == nil
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).size.should == nil
- end
-
- it "sets $~ in the block" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].lazy.grep_v(/e/) { |e|
- e.should == "abc"
- $~.should == nil
- }.force
-
- # Set by the match of "def"
- $&.should == "e"
- end
-
- it "sets $~ in the next block with each" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].lazy.grep_v(/e/).each { |e|
- e.should == "abc"
- $~.should == nil
- }
-
- # Set by the match of "def"
- $&.should == "e"
- end
-
- it "sets $~ in the next block with map" do
- "z" =~ /z/ # Reset $~
- ["abc", "def"].lazy.grep_v(/e/).map { |e|
- e.should == "abc"
- $~.should == nil
- }.force
-
- # Set by the match of "def"
- $&.should == "e"
- end
-
- describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
- it "stops after specified times when not given a block" do
- (0..Float::INFINITY).lazy.grep_v(3..5).first(3).should == [0, 1, 2]
-
- @eventsmixed.grep_v(Symbol).first(1)
- ScratchPad.recorded.should == [:before_yield]
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "Enumerator::Lazy#grep_v" do
+ before(:each) do
+ @yieldsmixed = EnumeratorLazySpecs::YieldsMixed.new.to_enum.lazy
+ @eventsmixed = EnumeratorLazySpecs::EventsMixed.new.to_enum.lazy
+ ScratchPad.record []
end
- it "stops after specified times when given a block" do
- (0..Float::INFINITY).lazy.grep_v(4..8, &:succ).first(3).should == [1, 2, 3]
+ after(:each) do
+ ScratchPad.clear
+ end
- @eventsmixed.grep_v(Symbol) {}.first(1)
- ScratchPad.recorded.should == [:before_yield]
+ it "requires an argument" do
+ Enumerator::Lazy.instance_method(:grep_v).arity.should == 1
end
- end
- it "calls the block with a gathered array when yield with multiple arguments" do
- yields = []
- @yieldsmixed.grep_v(Array) { |v| yields << v }.force
- yields.should == EnumeratorLazySpecs::YieldsMixed.gathered_non_array_yields
+ it "returns a new instance of Enumerator::Lazy" do
+ ret = @yieldsmixed.grep_v(Object) {}
+ ret.should be_an_instance_of(Enumerator::Lazy)
+ ret.should_not equal(@yieldsmixed)
- @yieldsmixed.grep_v(Array).force.should == yields
- end
+ ret = @yieldsmixed.grep_v(Object)
+ ret.should be_an_instance_of(Enumerator::Lazy)
+ ret.should_not equal(@yieldsmixed)
+ end
- describe "on a nested Lazy" do
it "sets #size to nil" do
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object) {}.size.should == nil
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object).size.should == nil
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object) {}.size.should == nil
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).size.should == nil
end
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
it "stops after specified times when not given a block" do
- (0..Float::INFINITY).lazy.grep_v(3..5).grep_v(6..10).first(3).should == [0, 1, 2]
+ (0..Float::INFINITY).lazy.grep_v(3..5).first(3).should == [0, 1, 2]
- @eventsmixed.grep_v(Symbol).grep_v(String).first(1)
+ @eventsmixed.grep_v(Symbol).first(1)
ScratchPad.recorded.should == [:before_yield]
end
it "stops after specified times when given a block" do
- (0..Float::INFINITY).lazy
- .grep_v(1..2) { |n| n > 3 ? n : false }
- .grep_v(false) { |n| n.even? ? n : false }
- .first(3)
- .should == [4, false, 6]
+ (0..Float::INFINITY).lazy.grep_v(4..8, &:succ).first(3).should == [1, 2, 3]
- @eventsmixed.grep_v(Symbol) {}.grep_v(String) {}.first(1)
+ @eventsmixed.grep_v(Symbol) {}.first(1)
ScratchPad.recorded.should == [:before_yield]
end
end
- end
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.grep_v(String).first(100).should ==
- s.first(100).grep_v(String)
+ it "calls the block with a gathered array when yield with multiple arguments" do
+ yields = []
+ @yieldsmixed.grep_v(Array) { |v| yields << v }.force
+ yields.should == EnumeratorLazySpecs::YieldsMixed.gathered_non_array_yields
+
+ @yieldsmixed.grep_v(Array).force.should == yields
+ end
+
+ describe "on a nested Lazy" do
+ it "sets #size to nil" do
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object) {}.size.should == nil
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object).size.should == nil
+ end
+
+ describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
+ it "stops after specified times when not given a block" do
+ (0..Float::INFINITY).lazy.grep_v(3..5).grep_v(6..10).first(3).should == [0, 1, 2]
+
+ @eventsmixed.grep_v(Symbol).grep_v(String).first(1)
+ ScratchPad.recorded.should == [:before_yield]
+ end
+
+ it "stops after specified times when given a block" do
+ (0..Float::INFINITY).lazy
+ .grep_v(1..2) { |n| n > 3 ? n : false }
+ .grep_v(false) { |n| n.even? ? n : false }
+ .first(3)
+ .should == [4, false, 6]
+
+ @eventsmixed.grep_v(Symbol) {}.grep_v(String) {}.first(1)
+ ScratchPad.recorded.should == [:before_yield]
+ end
+ end
+ end
end
end
diff --git a/spec/ruby/core/enumerator/lazy/initialize_spec.rb b/spec/ruby/core/enumerator/lazy/initialize_spec.rb
index 88c66530b9..47eeafb5cf 100644
--- a/spec/ruby/core/enumerator/lazy/initialize_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/initialize_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Enumerator::Lazy#initialize" do
before :each do
@@ -48,16 +48,16 @@ describe "Enumerator::Lazy#initialize" do
end
it "sets given size to own size if the given size is a Proc" do
- @uninitialized.send(:initialize, @receiver, -> { 200 }) {}.size.should == 200
+ @uninitialized.send(:initialize, @receiver, lambda { 200 }) {}.size.should == 200
end
it "raises an ArgumentError when block is not given" do
- -> { @uninitialized.send :initialize, @receiver }.should raise_error(ArgumentError)
+ lambda { @uninitialized.send :initialize, @receiver }.should raise_error(ArgumentError)
end
describe "on frozen instance" do
it "raises a RuntimeError" do
- -> { @uninitialized.freeze.send(:initialize, @receiver) {} }.should raise_error(RuntimeError)
+ lambda { @uninitialized.freeze.send(:initialize, @receiver) {} }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/enumerator/lazy/lazy_spec.rb b/spec/ruby/core/enumerator/lazy/lazy_spec.rb
index cde9b31066..a82a1af271 100644
--- a/spec/ruby/core/enumerator/lazy/lazy_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/lazy_spec.rb
@@ -1,23 +1,11 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Enumerator::Lazy" do
it "is a subclass of Enumerator" do
Enumerator::Lazy.superclass.should equal(Enumerator)
end
-
- it "defines lazy versions of a whitelist of Enumerator methods" do
- lazy_methods = [
- :chunk, :collect, :collect_concat, :drop, :drop_while, :enum_for,
- :find_all, :flat_map, :force, :grep, :grep_v, :lazy, :map, :reject,
- :select, :slice_after, :slice_before, :slice_when, :take, :take_while,
- :to_enum, :zip
- ]
- lazy_methods += [:chunk_while, :uniq]
-
- Enumerator::Lazy.instance_methods(false).should include(*lazy_methods)
- end
end
describe "Enumerator::Lazy#lazy" do
diff --git a/spec/ruby/core/enumerator/lazy/map_spec.rb b/spec/ruby/core/enumerator/lazy/map_spec.rb
index 5cb998f5f7..8ff2573fe5 100644
--- a/spec/ruby/core/enumerator/lazy/map_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/map_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/collect'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Enumerator::Lazy#map" do
it_behaves_like :enumerator_lazy_collect, :map
diff --git a/spec/ruby/core/enumerator/lazy/reject_spec.rb b/spec/ruby/core/enumerator/lazy/reject_spec.rb
index 0e1632d667..317e927f02 100644
--- a/spec/ruby/core/enumerator/lazy/reject_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/reject_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#reject" do
before :each do
@@ -33,18 +33,6 @@ describe "Enumerator::Lazy#reject" do
end
end
- it "lets exceptions raised in the block go through" do
- lazy = 10.times.lazy.map do |i|
- raise "foo"
- end
-
- lazy = lazy.reject(&:nil?)
-
- -> {
- lazy.first
- }.should raise_error(RuntimeError, "foo")
- end
-
it "calls the block with a gathered array when yield with multiple arguments" do
yields = []
@yieldsmixed.reject { |v| yields << v }.force
@@ -52,7 +40,7 @@ describe "Enumerator::Lazy#reject" do
end
it "raises an ArgumentError when not given a block" do
- -> { @yieldsmixed.reject }.should raise_error(ArgumentError)
+ lambda { @yieldsmixed.reject }.should raise_error(ArgumentError)
end
describe "on a nested Lazy" do
@@ -69,10 +57,4 @@ describe "Enumerator::Lazy#reject" do
end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.reject { |n| false }.first(100).should ==
- s.first(100).reject { |n| false }
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/select_spec.rb b/spec/ruby/core/enumerator/lazy/select_spec.rb
index 3773d8f0a8..ba5823c7ad 100644
--- a/spec/ruby/core/enumerator/lazy/select_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/select_spec.rb
@@ -1,47 +1,8 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/select'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/select', __FILE__)
describe "Enumerator::Lazy#select" do
it_behaves_like :enumerator_lazy_select, :select
-
- it "doesn't pre-evaluate the next element" do
- eval_count = 0
- enum = %w[Text1 Text2 Text3].lazy.select do
- eval_count += 1
- true
- end
-
- eval_count.should == 0
- enum.next
- eval_count.should == 1
- end
-
- it "doesn't over-evaluate when peeked" do
- eval_count = 0
- enum = %w[Text1 Text2 Text3].lazy.select do
- eval_count += 1
- true
- end
-
- eval_count.should == 0
- enum.peek
- enum.peek
- eval_count.should == 1
- end
-
- it "doesn't re-evaluate after peek" do
- eval_count = 0
- enum = %w[Text1 Text2 Text3].lazy.select do
- eval_count += 1
- true
- end
-
- eval_count.should == 0
- enum.peek
- eval_count.should == 1
- enum.next
- eval_count.should == 1
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/shared/collect.rb b/spec/ruby/core/enumerator/lazy/shared/collect.rb
index 5690255a0c..c892784bc2 100644
--- a/spec/ruby/core/enumerator/lazy/shared/collect.rb
+++ b/spec/ruby/core/enumerator/lazy/shared/collect.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :enumerator_lazy_collect, shared: true do
before :each do
@@ -53,10 +53,4 @@ describe :enumerator_lazy_collect, shared: true do
end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.send(@method) { |n| n }.first(100).should ==
- s.first(100).send(@method) { |n| n }.to_a
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb b/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb
index 00d7941a61..69bc10c1a4 100644
--- a/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb
+++ b/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :enumerator_lazy_collect_concat, shared: true do
before :each do
@@ -46,7 +46,7 @@ describe :enumerator_lazy_collect_concat, shared: true do
end
it "raises an ArgumentError when not given a block" do
- -> { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
+ lambda { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
end
describe "on a nested Lazy" do
@@ -69,10 +69,4 @@ describe :enumerator_lazy_collect_concat, shared: true do
end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.send(@method) { |n| [-n, +n] }.first(200).should ==
- s.first(100).send(@method) { |n| [-n, +n] }.to_a
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/shared/select.rb b/spec/ruby/core/enumerator/lazy/shared/select.rb
index 50a00bcbf4..546256360e 100644
--- a/spec/ruby/core/enumerator/lazy/shared/select.rb
+++ b/spec/ruby/core/enumerator/lazy/shared/select.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :enumerator_lazy_select, shared: true do
before :each do
@@ -40,7 +40,7 @@ describe :enumerator_lazy_select, shared: true do
end
it "raises an ArgumentError when not given a block" do
- -> { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
+ lambda { @yieldsmixed.send(@method) }.should raise_error(ArgumentError)
end
describe "on a nested Lazy" do
@@ -57,10 +57,4 @@ describe :enumerator_lazy_select, shared: true do
end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.send(@method) { |n| true }.first(100).should ==
- s.first(100).send(@method) { |n| true }
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/shared/to_enum.rb b/spec/ruby/core/enumerator/lazy/shared/to_enum.rb
index 0c91ea55b9..5e6935b45a 100644
--- a/spec/ruby/core/enumerator/lazy/shared/to_enum.rb
+++ b/spec/ruby/core/enumerator/lazy/shared/to_enum.rb
@@ -1,6 +1,6 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
describe :enumerator_lazy_to_enum, shared: true do
before :each do
@@ -43,13 +43,8 @@ describe :enumerator_lazy_to_enum, shared: true do
each_entry: [],
each_cons: [2]
}.each_pair do |method, args|
+ @infinite.method(method).owner.should_not equal(Enumerator::Lazy)
@infinite.send(method, *args).should be_an_instance_of(Enumerator::Lazy)
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.send(@method, :with_index).first(100).should ==
- s.first(100).to_enum.send(@method, :with_index).to_a
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/slice_after_spec.rb b/spec/ruby/core/enumerator/lazy/slice_after_spec.rb
deleted file mode 100644
index 438df8d550..0000000000
--- a/spec/ruby/core/enumerator/lazy/slice_after_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../../spec_helper'
-
-describe "Enumerator::Lazy#slice_after" do
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.slice_after { |n| true }.first(100).should ==
- s.first(100).slice_after { |n| true }.to_a
- end
-end
diff --git a/spec/ruby/core/enumerator/lazy/slice_before_spec.rb b/spec/ruby/core/enumerator/lazy/slice_before_spec.rb
deleted file mode 100644
index 6c8660c1a1..0000000000
--- a/spec/ruby/core/enumerator/lazy/slice_before_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../../spec_helper'
-
-describe "Enumerator::Lazy#slice_before" do
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.slice_before { |n| true }.first(100).should ==
- s.first(100).slice_before { |n| true }.to_a
- end
-end
diff --git a/spec/ruby/core/enumerator/lazy/slice_when_spec.rb b/spec/ruby/core/enumerator/lazy/slice_when_spec.rb
deleted file mode 100644
index e7673def47..0000000000
--- a/spec/ruby/core/enumerator/lazy/slice_when_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../../spec_helper'
-
-describe "Enumerator::Lazy#slice_when" do
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.slice_when { |a, b| true }.first(100).should ==
- s.first(100).slice_when { |a, b| true }.to_a
- end
-end
diff --git a/spec/ruby/core/enumerator/lazy/take_spec.rb b/spec/ruby/core/enumerator/lazy/take_spec.rb
index 9fc17e969f..5ef732237d 100644
--- a/spec/ruby/core/enumerator/lazy/take_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/take_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#take" do
before :each do
diff --git a/spec/ruby/core/enumerator/lazy/take_while_spec.rb b/spec/ruby/core/enumerator/lazy/take_while_spec.rb
index bcea0b1419..8647dfcaf0 100644
--- a/spec/ruby/core/enumerator/lazy/take_while_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/take_while_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#take_while" do
before :each do
@@ -40,7 +40,7 @@ describe "Enumerator::Lazy#take_while" do
end
it "raises an ArgumentError when not given a block" do
- -> { @yieldsmixed.take_while }.should raise_error(ArgumentError)
+ lambda { @yieldsmixed.take_while }.should raise_error(ArgumentError)
end
describe "on a nested Lazy" do
diff --git a/spec/ruby/core/enumerator/lazy/to_enum_spec.rb b/spec/ruby/core/enumerator/lazy/to_enum_spec.rb
index 210e5294b7..e0966037ab 100644
--- a/spec/ruby/core/enumerator/lazy/to_enum_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/to_enum_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'shared/to_enum'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_enum', __FILE__)
describe "Enumerator::Lazy#to_enum" do
it_behaves_like :enumerator_lazy_to_enum, :to_enum
diff --git a/spec/ruby/core/enumerator/lazy/uniq_spec.rb b/spec/ruby/core/enumerator/lazy/uniq_spec.rb
index ce67ace5ab..391d2f6839 100644
--- a/spec/ruby/core/enumerator/lazy/uniq_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/uniq_spec.rb
@@ -1,74 +1,70 @@
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe 'Enumerator::Lazy#uniq' do
- context 'without block' do
- before :each do
- @lazy = [0, 1, 0, 1].to_enum.lazy.uniq
- end
+ruby_version_is '2.4' do
+ describe 'Enumerator::Lazy#uniq' do
+ context 'without block' do
+ before :each do
+ @lazy = [0, 1, 0, 1].to_enum.lazy.uniq
+ end
- it 'returns a lazy enumerator' do
- @lazy.should be_an_instance_of(Enumerator::Lazy)
- @lazy.force.should == [0, 1]
- end
+ it 'returns a lazy enumerator' do
+ @lazy.should be_an_instance_of(Enumerator::Lazy)
+ @lazy.force.should == [0, 1]
+ end
- it 'return same value after rewind' do
- @lazy.force.should == [0, 1]
- @lazy.force.should == [0, 1]
- end
+ it 'return same value after rewind' do
+ @lazy.force.should == [0, 1]
+ @lazy.force.should == [0, 1]
+ end
- it 'sets the size to nil' do
- @lazy.size.should == nil
+ it 'sets the size to nil' do
+ @lazy.size.should == nil
+ end
end
- end
- context 'when yielded with an argument' do
- before :each do
- @lazy = [0, 1, 2, 3].to_enum.lazy.uniq(&:even?)
- end
+ context 'when yielded with an argument' do
+ before :each do
+ @lazy = [0, 1, 2, 3].to_enum.lazy.uniq(&:even?)
+ end
- it 'returns a lazy enumerator' do
- @lazy.should be_an_instance_of(Enumerator::Lazy)
- @lazy.force.should == [0, 1]
- end
+ it 'returns a lazy enumerator' do
+ @lazy.should be_an_instance_of(Enumerator::Lazy)
+ @lazy.force.should == [0, 1]
+ end
- it 'return same value after rewind' do
- @lazy.force.should == [0, 1]
- @lazy.force.should == [0, 1]
- end
+ it 'return same value after rewind' do
+ @lazy.force.should == [0, 1]
+ @lazy.force.should == [0, 1]
+ end
- it 'sets the size to nil' do
- @lazy.size.should == nil
+ it 'sets the size to nil' do
+ @lazy.size.should == nil
+ end
end
- end
- context 'when yielded with multiple arguments' do
- before :each do
- enum = Object.new.to_enum
- class << enum
- def each
- yield 0, 'foo'
- yield 1, 'FOO'
- yield 2, 'bar'
+ context 'when yielded with multiple arguments' do
+ before :each do
+ enum = Object.new.to_enum
+ class << enum
+ def each
+ yield 0, 'foo'
+ yield 1, 'FOO'
+ yield 2, 'bar'
+ end
end
+ @lazy = enum.lazy
end
- @lazy = enum.lazy
- end
- it 'return same value after rewind' do
- enum = @lazy.uniq { |_, label| label.downcase }
- enum.force.should == [[0, 'foo'], [2, 'bar']]
- enum.force.should == [[0, 'foo'], [2, 'bar']]
- end
+ it 'return same value after rewind' do
+ enum = @lazy.uniq { |_, label| label.downcase }
+ enum.force.should == [[0, 'foo'], [2, 'bar']]
+ enum.force.should == [[0, 'foo'], [2, 'bar']]
+ end
- it 'returns all yield arguments as an array' do
- @lazy.uniq { |_, label| label.downcase }.force.should == [[0, 'foo'], [2, 'bar']]
+ it 'returns all yield arguments as an array' do
+ @lazy.uniq { |_, label| label.downcase }.force.should == [[0, 'foo'], [2, 'bar']]
+ end
end
end
-
- it "works with an infinite enumerable" do
- s = 0..Float::INFINITY
- s.lazy.uniq.first(100).should ==
- s.first(100).uniq
- end
end
diff --git a/spec/ruby/core/enumerator/lazy/zip_spec.rb b/spec/ruby/core/enumerator/lazy/zip_spec.rb
index 5a828c1dcc..9c728364ce 100644
--- a/spec/ruby/core/enumerator/lazy/zip_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/zip_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Enumerator::Lazy#zip" do
before :each do
@@ -44,7 +44,7 @@ describe "Enumerator::Lazy#zip" do
end
it "raises a TypeError if arguments contain non-list object" do
- -> { @yieldsmixed.zip [], Object.new, [] }.should raise_error(TypeError)
+ lambda { @yieldsmixed.zip [], Object.new, [] }.should raise_error(TypeError)
end
describe "on a nested Lazy" do
@@ -71,16 +71,4 @@ describe "Enumerator::Lazy#zip" do
end
end
end
-
- it "works with an infinite enumerable and an array" do
- s = 0..Float::INFINITY
- s.lazy.zip(0..1000).first(100).should ==
- s.first(100).zip(0..100)
- end
-
- it "works with two infinite enumerables" do
- s = 0..Float::INFINITY
- s.lazy.zip(s).first(100).should ==
- s.first(100).zip(s)
- end
end
diff --git a/spec/ruby/core/enumerator/new_spec.rb b/spec/ruby/core/enumerator/new_spec.rb
index 170809dbc1..e8e0572a40 100644
--- a/spec/ruby/core/enumerator/new_spec.rb
+++ b/spec/ruby/core/enumerator/new_spec.rb
@@ -1,41 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/new', __FILE__)
describe "Enumerator.new" do
- it "creates a new custom enumerator with the given object, iterator and arguments" do
- enum = Enumerator.new(1, :upto, 3)
- enum.should be_an_instance_of(Enumerator)
- end
-
- it "creates a new custom enumerator that responds to #each" do
- enum = Enumerator.new(1, :upto, 3)
- enum.respond_to?(:each).should == true
- end
-
- it "creates a new custom enumerator that runs correctly" do
- Enumerator.new(1, :upto, 3).map{|x|x}.should == [1,2,3]
- end
-
- it "aliases the second argument to :each" do
- Enumerator.new(1..2).to_a.should == Enumerator.new(1..2, :each).to_a
- end
-
- it "doesn't check for the presence of the iterator method" do
- Enumerator.new(nil).should be_an_instance_of(Enumerator)
- end
-
- it "uses the latest define iterator method" do
- class StrangeEach
- def each
- yield :foo
- end
- end
- enum = Enumerator.new(StrangeEach.new)
- enum.to_a.should == [:foo]
- class StrangeEach
- def each
- yield :bar
- end
- end
- enum.to_a.should == [:bar]
- end
+ it_behaves_like(:enum_new, :new)
end
diff --git a/spec/ruby/core/enumerator/next_spec.rb b/spec/ruby/core/enumerator/next_spec.rb
index 3e9ed8b015..6b3309a2bc 100644
--- a/spec/ruby/core/enumerator/next_spec.rb
+++ b/spec/ruby/core/enumerator/next_spec.rb
@@ -1,27 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/next', __FILE__)
describe "Enumerator#next" do
- before :each do
- @enum = 1.upto(3)
- end
-
- it "returns the next element of the enumeration" do
- @enum.next.should == 1
- @enum.next.should == 2
- @enum.next.should == 3
- end
-
- it "raises a StopIteration exception at the end of the stream" do
- 3.times { @enum.next }
- -> { @enum.next }.should raise_error(StopIteration)
- end
-
- it "cannot be called again until the enumerator is rewound" do
- 3.times { @enum.next }
- -> { @enum.next }.should raise_error(StopIteration)
- -> { @enum.next }.should raise_error(StopIteration)
- -> { @enum.next }.should raise_error(StopIteration)
- @enum.rewind
- @enum.next.should == 1
- end
+ it_behaves_like(:enum_next,:next)
end
diff --git a/spec/ruby/core/enumerator/next_values_spec.rb b/spec/ruby/core/enumerator/next_values_spec.rb
index 201b5d323f..2c4b23dc8d 100644
--- a/spec/ruby/core/enumerator/next_values_spec.rb
+++ b/spec/ruby/core/enumerator/next_values_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator#next_values" do
before :each do
@@ -50,6 +50,6 @@ describe "Enumerator#next_values" do
it "raises StopIteration if called on a finished enumerator" do
7.times { @e.next }
- -> { @e.next_values }.should raise_error(StopIteration)
+ lambda { @e.next_values }.should raise_error(StopIteration)
end
end
diff --git a/spec/ruby/core/enumerator/peek_spec.rb b/spec/ruby/core/enumerator/peek_spec.rb
index 2334385437..26ac85161b 100644
--- a/spec/ruby/core/enumerator/peek_spec.rb
+++ b/spec/ruby/core/enumerator/peek_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator#peek" do
before :each do
@@ -31,6 +31,6 @@ describe "Enumerator#peek" do
it "raises StopIteration if called on a finished enumerator" do
5.times { @e.next }
- -> { @e.peek }.should raise_error(StopIteration)
+ lambda { @e.peek }.should raise_error(StopIteration)
end
end
diff --git a/spec/ruby/core/enumerator/peek_values_spec.rb b/spec/ruby/core/enumerator/peek_values_spec.rb
index 7865546515..ecc4758854 100644
--- a/spec/ruby/core/enumerator/peek_values_spec.rb
+++ b/spec/ruby/core/enumerator/peek_values_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator#peek_values" do
before :each do
@@ -52,6 +52,6 @@ describe "Enumerator#peek_values" do
it "raises StopIteration if called on a finished enumerator" do
7.times { @e.next }
- -> { @e.peek_values }.should raise_error(StopIteration)
+ lambda { @e.peek_values }.should raise_error(StopIteration)
end
end
diff --git a/spec/ruby/core/enumerator/plus_spec.rb b/spec/ruby/core/enumerator/plus_spec.rb
deleted file mode 100644
index c9bae08b04..0000000000
--- a/spec/ruby/core/enumerator/plus_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Enumerator#+" do
- before :each do
- ScratchPad.record []
- end
-
- it "returns a chain of self and provided enumerators" do
- one = Enumerator.new { |y| y << 1 }
- two = Enumerator.new { |y| y << 2 }
- three = Enumerator.new { |y| y << 3 }
-
- chain = one + two + three
-
- chain.should be_an_instance_of(Enumerator::Chain)
- chain.each { |item| ScratchPad << item }
- ScratchPad.recorded.should == [1, 2, 3]
- end
-
- it "calls #each on each argument" do
- enum = Enumerator.new { |y| y << "one" }
-
- obj1 = mock("obj1")
- obj1.should_receive(:each).once.and_yield("two")
-
- obj2 = mock("obj2")
- obj2.should_receive(:each).once.and_yield("three")
-
- chain = enum + obj1 + obj2
- chain.each { |item| ScratchPad << item }
- ScratchPad.recorded.should == ["one", "two", "three"]
- end
- end
-end
diff --git a/spec/ruby/core/enumerator/rewind_spec.rb b/spec/ruby/core/enumerator/rewind_spec.rb
index a105f2c619..666136d74a 100644
--- a/spec/ruby/core/enumerator/rewind_spec.rb
+++ b/spec/ruby/core/enumerator/rewind_spec.rb
@@ -1,41 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/rewind', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Enumerator#rewind" do
- before :each do
- @enum = 1.upto(3)
- end
-
- it "resets the enumerator to its initial state" do
- @enum.next.should == 1
- @enum.next.should == 2
- @enum.rewind
- @enum.next.should == 1
- end
-
- it "returns self" do
- @enum.rewind.should == @enum
- end
-
- it "has no effect on a new enumerator" do
- @enum.rewind
- @enum.next.should == 1
- end
-
- it "has no effect if called multiple, consecutive times" do
- @enum.next.should == 1
- @enum.rewind
- @enum.rewind
- @enum.next.should == 1
- end
-
- it "works with peek to reset the position" do
- @enum.next
- @enum.next
- @enum.rewind
- @enum.next
- @enum.peek.should == 2
- end
+ it_behaves_like(:enum_rewind, :rewind)
it "calls the enclosed object's rewind method if one exists" do
obj = mock('rewinder')
@@ -49,7 +17,7 @@ describe "Enumerator#rewind" do
obj = mock('rewinder')
enum = obj.to_enum
obj.should_receive(:each).at_most(1)
- -> { enum.rewind.should == enum }.should_not raise_error
+ lambda { enum.rewind.should == enum }.should_not raise_error
end
end
diff --git a/spec/ruby/core/enumerator/size_spec.rb b/spec/ruby/core/enumerator/size_spec.rb
index 6accd26a4e..ef7940dc16 100644
--- a/spec/ruby/core/enumerator/size_spec.rb
+++ b/spec/ruby/core/enumerator/size_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Enumerator#size" do
it "returns same value if set size is an Integer" do
@@ -11,7 +11,7 @@ describe "Enumerator#size" do
it "returns returning value from size.call if set size is a Proc" do
base_size = 100
- enum = Enumerator.new(-> { base_size + 1 }) {}
+ enum = Enumerator.new(lambda { base_size + 1 }) {}
base_size = 200
enum.size.should == 201
base_size = 300
diff --git a/spec/ruby/core/enumerator/to_enum_spec.rb b/spec/ruby/core/enumerator/to_enum_spec.rb
index cadfcf6314..a719e62212 100644
--- a/spec/ruby/core/enumerator/to_enum_spec.rb
+++ b/spec/ruby/core/enumerator/to_enum_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/enumerator/enum_for'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/enum_for', __FILE__)
describe "Enumerator#to_enum" do
it_behaves_like :enum_for, :enum_for
diff --git a/spec/ruby/core/enumerator/with_index_spec.rb b/spec/ruby/core/enumerator/with_index_spec.rb
index ac37cee508..3d0ec0a298 100644
--- a/spec/ruby/core/enumerator/with_index_spec.rb
+++ b/spec/ruby/core/enumerator/with_index_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/enumerator/with_index'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/with_index', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Enumerator#with_index" do
- it_behaves_like :enum_with_index, :with_index
- it_behaves_like :enumeratorized_with_origin_size, :with_index, [1,2,3].select
+ it_behaves_like(:enum_with_index, :with_index)
+ it_behaves_like(:enumeratorized_with_origin_size, :with_index, [1,2,3].select)
it "returns a new Enumerator when no block is given" do
enum1 = [1,2,3].select
@@ -14,13 +14,13 @@ describe "Enumerator#with_index" do
end
it "accepts an optional argument when given a block" do
- -> do
+ lambda do
@enum.with_index(1) { |f| f}
end.should_not raise_error(ArgumentError)
end
it "accepts an optional argument when not given a block" do
- -> do
+ lambda do
@enum.with_index(1)
end.should_not raise_error(ArgumentError)
end
@@ -36,7 +36,7 @@ describe "Enumerator#with_index" do
end
it "raises a TypeError when the argument cannot be converted to numeric" do
- -> do
+ lambda do
@enum.with_index('1') {|*i| i}
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/enumerator/with_object_spec.rb b/spec/ruby/core/enumerator/with_object_spec.rb
index e7ba83fd9f..a7bd74220c 100644
--- a/spec/ruby/core/enumerator/with_object_spec.rb
+++ b/spec/ruby/core/enumerator/with_object_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/enumerator/with_object'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/enumerator/with_object', __FILE__)
describe "Enumerator#with_object" do
it_behaves_like :enum_with_object, :with_object
diff --git a/spec/ruby/core/enumerator/yielder/append_spec.rb b/spec/ruby/core/enumerator/yielder/append_spec.rb
index dac66585a5..d2313b01f4 100644
--- a/spec/ruby/core/enumerator/yielder/append_spec.rb
+++ b/spec/ruby/core/enumerator/yielder/append_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Enumerator::Yielder#<<" do
# TODO: There's some common behavior between yield and <<; move to a shared spec
@@ -21,4 +21,15 @@ describe "Enumerator::Yielder#<<" do
y = Enumerator::Yielder.new {|x| x + 1}
(y << 1).should equal(y)
end
+
+ it "requires multiple arguments" do
+ Enumerator::Yielder.instance_method(:<<).arity.should < 0
+ end
+
+ it "yields with passed arguments" do
+ yields = []
+ y = Enumerator::Yielder.new {|*args| yields << args }
+ y.<<(1, 2)
+ yields.should == [[1, 2]]
+ end
end
diff --git a/spec/ruby/core/enumerator/yielder/initialize_spec.rb b/spec/ruby/core/enumerator/yielder/initialize_spec.rb
index 5a6eee2d0f..095b6a64c6 100644
--- a/spec/ruby/core/enumerator/yielder/initialize_spec.rb
+++ b/spec/ruby/core/enumerator/yielder/initialize_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: us-ascii -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Enumerator::Yielder#initialize" do
before :each do
diff --git a/spec/ruby/core/enumerator/yielder/yield_spec.rb b/spec/ruby/core/enumerator/yielder/yield_spec.rb
index 58fc8e007a..be904afef1 100644
--- a/spec/ruby/core/enumerator/yielder/yield_spec.rb
+++ b/spec/ruby/core/enumerator/yielder/yield_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Enumerator::Yielder#yield" do
it "yields the value to the block" do
@@ -9,13 +9,6 @@ describe "Enumerator::Yielder#yield" do
ary.should == [1]
end
- it "yields with passed arguments" do
- yields = []
- y = Enumerator::Yielder.new {|*args| yields << args }
- y.yield 1, 2
- yields.should == [[1, 2]]
- end
-
it "returns the result of the block for the given value" do
y = Enumerator::Yielder.new {|x| x + 1}
y.yield(1).should == 2
diff --git a/spec/ruby/core/env/assoc_spec.rb b/spec/ruby/core/env/assoc_spec.rb
index c7a388db75..fb10a52b3c 100644
--- a/spec/ruby/core/env/assoc_spec.rb
+++ b/spec/ruby/core/env/assoc_spec.rb
@@ -1,12 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.assoc" do
- before :each do
- @foo = ENV["foo"]
- end
-
after :each do
- ENV["foo"] = @foo
+ ENV.delete("foo")
end
it "returns an array of the key and value of the environment variable with the given key" do
@@ -24,8 +20,4 @@ describe "ENV.assoc" do
k.should_receive(:to_str).and_return("foo")
ENV.assoc(k).should == ["foo", "bar"]
end
-
- it "raises TypeError if the argument is not a String and does not respond to #to_str" do
- -> { ENV.assoc(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
- end
end
diff --git a/spec/ruby/core/env/clear_spec.rb b/spec/ruby/core/env/clear_spec.rb
index 48b034ba1d..c184926cc2 100644
--- a/spec/ruby/core/env/clear_spec.rb
+++ b/spec/ruby/core/env/clear_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.clear" do
it "deletes all environment variables" do
orig = ENV.to_hash
begin
- ENV.clear.should equal(ENV)
+ ENV.clear
# This used 'env' the helper before. That shells out to 'env' which
# itself sets up certain environment variables before it runs, because
diff --git a/spec/ruby/core/env/delete_if_spec.rb b/spec/ruby/core/env/delete_if_spec.rb
index d2de51c225..9a8220ae7d 100644
--- a/spec/ruby/core/env/delete_if_spec.rb
+++ b/spec/ruby/core/env/delete_if_spec.rb
@@ -1,32 +1,15 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "ENV.delete_if" do
- before :each do
- @foo = ENV["foo"]
- @bar = ENV["bar"]
-
- ENV["foo"] = "0"
- ENV["bar"] = "1"
- end
-
- after :each do
- ENV["foo"] = @foo
- ENV["bar"] = @bar
- end
-
it "deletes pairs if the block returns true" do
- ENV.delete_if { |k, v| ["foo", "bar"].include?(k) }
+ ENV["foo"] = "bar"
+ ENV.delete_if { |k, v| k == "foo" }
ENV["foo"].should == nil
- ENV["bar"].should == nil
- end
-
- it "returns ENV when block given" do
- ENV.delete_if { |k, v| ["foo", "bar"].include?(k) }.should equal(ENV)
end
it "returns ENV even if nothing deleted" do
- ENV.delete_if { false }.should equal(ENV)
+ ENV.delete_if { false }.should_not == nil
end
it "returns an Enumerator if no block given" do
@@ -34,20 +17,10 @@ describe "ENV.delete_if" do
end
it "deletes pairs through enumerator" do
+ ENV["foo"] = "bar"
enum = ENV.delete_if
- enum.each { |k, v| ["foo", "bar"].include?(k) }
+ enum.each { |k, v| k == "foo" }
ENV["foo"].should == nil
- ENV["bar"].should == nil
- end
-
- it "returns ENV from enumerator" do
- enum = ENV.delete_if
- enum.each { |k, v| ["foo", "bar"].include?(k) }.should equal(ENV)
- end
-
- it "returns ENV from enumerator even if nothing deleted" do
- enum = ENV.delete_if
- enum.each { false }.should equal(ENV)
end
it_behaves_like :enumeratorized_with_origin_size, :delete_if, ENV
diff --git a/spec/ruby/core/env/delete_spec.rb b/spec/ruby/core/env/delete_spec.rb
index f11860b21d..e02adf963f 100644
--- a/spec/ruby/core/env/delete_spec.rb
+++ b/spec/ruby/core/env/delete_spec.rb
@@ -1,11 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.delete" do
- before :each do
- @saved_foo = ENV["foo"]
- end
after :each do
- ENV["foo"] = @saved_foo
+ ENV.delete("foo")
end
it "removes the variable from the environment" do
@@ -19,24 +16,9 @@ describe "ENV.delete" do
ENV.delete("foo").should == "bar"
end
- it "returns nil if the named environment variable does not exist and no block given" do
- ENV.delete("foo")
- ENV.delete("foo").should == nil
- end
-
it "yields the name to the given block if the named environment variable does not exist" do
ENV.delete("foo")
ENV.delete("foo") { |name| ScratchPad.record name }
ScratchPad.recorded.should == "foo"
end
-
- it "does not evaluate the block if the environment variable exists" do
- ENV["foo"] = "bar"
- ENV.delete("foo") { |name| fail "Should not happen" }
- ENV["foo"].should == nil
- end
-
- it "raises TypeError if the argument is not a String and does not respond to #to_str" do
- -> { ENV.delete(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
- end
end
diff --git a/spec/ruby/core/env/each_key_spec.rb b/spec/ruby/core/env/each_key_spec.rb
index 0efcb09900..82721cdb96 100644
--- a/spec/ruby/core/env/each_key_spec.rb
+++ b/spec/ruby/core/env/each_key_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "ENV.each_key" do
@@ -10,7 +10,7 @@ describe "ENV.each_key" do
ENV.clear
ENV["1"] = "3"
ENV["2"] = "4"
- ENV.each_key { |k| e << k }.should equal(ENV)
+ ENV.each_key { |k| e << k }
e.should include("1")
e.should include("2")
ensure
@@ -19,9 +19,7 @@ describe "ENV.each_key" do
end
it "returns an Enumerator if called without a block" do
- enum = ENV.each_key
- enum.should be_an_instance_of(Enumerator)
- enum.to_a.should == ENV.keys
+ ENV.each_key.should be_an_instance_of(Enumerator)
end
it "returns keys in the locale encoding" do
diff --git a/spec/ruby/core/env/each_pair_spec.rb b/spec/ruby/core/env/each_pair_spec.rb
index 2d7ed5faa0..255ccd86c5 100644
--- a/spec/ruby/core/env/each_pair_spec.rb
+++ b/spec/ruby/core/env/each_pair_spec.rb
@@ -1,6 +1,6 @@
-require_relative 'spec_helper'
-require_relative 'shared/each'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each.rb', __FILE__)
describe "ENV.each_pair" do
- it_behaves_like :env_each, :each_pair
+ it_behaves_like(:env_each, :each_pair)
end
diff --git a/spec/ruby/core/env/each_spec.rb b/spec/ruby/core/env/each_spec.rb
index d1e06f55b6..2424c5e4e0 100644
--- a/spec/ruby/core/env/each_spec.rb
+++ b/spec/ruby/core/env/each_spec.rb
@@ -1,6 +1,6 @@
-require_relative 'spec_helper'
-require_relative 'shared/each'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/each.rb', __FILE__)
describe "ENV.each" do
- it_behaves_like :env_each, :each
+ it_behaves_like(:env_each, :each)
end
diff --git a/spec/ruby/core/env/each_value_spec.rb b/spec/ruby/core/env/each_value_spec.rb
index cc3c9ebfb8..070a1d2cb9 100644
--- a/spec/ruby/core/env/each_value_spec.rb
+++ b/spec/ruby/core/env/each_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "ENV.each_value" do
@@ -10,7 +10,7 @@ describe "ENV.each_value" do
ENV.clear
ENV["1"] = "3"
ENV["2"] = "4"
- ENV.each_value { |v| e << v }.should equal(ENV)
+ ENV.each_value { |v| e << v }
e.should include("3")
e.should include("4")
ensure
@@ -19,14 +19,12 @@ describe "ENV.each_value" do
end
it "returns an Enumerator if called without a block" do
- enum = ENV.each_value
- enum.should be_an_instance_of(Enumerator)
- enum.to_a.should == ENV.values
+ ENV.each_value.should be_an_instance_of(Enumerator)
end
it "uses the locale encoding" do
ENV.each_value do |value|
- value.should.be_locale_env
+ value.encoding.should == Encoding.find('locale')
end
end
diff --git a/spec/ruby/core/env/element_reference_spec.rb b/spec/ruby/core/env/element_reference_spec.rb
index 7d2a2d78e3..2e6402dd28 100644
--- a/spec/ruby/core/env/element_reference_spec.rb
+++ b/spec/ruby/core/env/element_reference_spec.rb
@@ -1,5 +1,5 @@
-# -*- encoding: binary -*-
-require_relative '../../spec_helper'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.[]" do
before :each do
@@ -19,17 +19,6 @@ describe "ENV.[]" do
ENV[@variable].frozen?.should == true
end
- it "coerces a non-string name with #to_str" do
- ENV[@variable] = "bar"
- k = mock('key')
- k.should_receive(:to_str).and_return(@variable)
- ENV[k].should == "bar"
- end
-
- it "raises TypeError if the argument is not a String and does not respond to #to_str" do
- -> { ENV[Object.new] }.should raise_error(TypeError, "no implicit conversion of Object into String")
- end
-
platform_is :windows do
it "looks up values case-insensitively" do
ENV[@variable] = "bar"
@@ -38,38 +27,40 @@ describe "ENV.[]" do
end
end
-describe "ENV.[]" do
- before :each do
- @variable = "env_element_reference_encoding_specs"
+with_feature :encoding do
+ describe "ENV.[]" do
+ before :each do
+ @variable = "env_element_reference_encoding_specs"
- @external = Encoding.default_external
- @internal = Encoding.default_internal
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- Encoding.default_external = Encoding::BINARY
- end
+ Encoding.default_external = Encoding::ASCII_8BIT
+ end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
- ENV.delete @variable
- end
+ ENV.delete @variable
+ end
- it "uses the locale encoding if Encoding.default_internal is nil" do
- Encoding.default_internal = nil
+ it "uses the locale encoding if Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
- locale = Encoding.find('locale')
- locale = Encoding::BINARY if locale == Encoding::US_ASCII
- ENV[@variable] = "\xC3\xB8"
- ENV[@variable].encoding.should == locale
- end
+ locale = Encoding.find('locale')
+ locale = Encoding::ASCII_8BIT if locale == Encoding::US_ASCII
+ ENV[@variable] = "\xC3\xB8"
+ ENV[@variable].encoding.should == locale
+ end
- it "transcodes from the locale encoding to Encoding.default_internal if set" do
- # We cannot reliably know the locale encoding, so we merely check that
- # the result string has the expected encoding.
- ENV[@variable] = ""
- Encoding.default_internal = Encoding::IBM437
+ it "transcodes from the locale encoding to Encoding.default_internal if set" do
+ # We cannot reliably know the locale encoding, so we merely check that
+ # the result string has the expected encoding.
+ ENV[@variable] = ""
+ Encoding.default_internal = Encoding::IBM437
- ENV[@variable].encoding.should equal(Encoding::IBM437)
+ ENV[@variable].encoding.should equal(Encoding::IBM437)
+ end
end
end
diff --git a/spec/ruby/core/env/element_set_spec.rb b/spec/ruby/core/env/element_set_spec.rb
index 26dfee1ade..a80cd0c51e 100644
--- a/spec/ruby/core/env/element_set_spec.rb
+++ b/spec/ruby/core/env/element_set_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/store'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/store.rb', __FILE__)
describe "ENV.[]=" do
- it_behaves_like :env_store, :[]=
+ it_behaves_like(:env_store, :[]=)
end
diff --git a/spec/ruby/core/env/empty_spec.rb b/spec/ruby/core/env/empty_spec.rb
index 7ef17d244f..fa02985a6e 100644
--- a/spec/ruby/core/env/empty_spec.rb
+++ b/spec/ruby/core/env/empty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.empty?" do
diff --git a/spec/ruby/core/env/fetch_spec.rb b/spec/ruby/core/env/fetch_spec.rb
index ef8f0a4ed3..708ee91c39 100644
--- a/spec/ruby/core/env/fetch_spec.rb
+++ b/spec/ruby/core/env/fetch_spec.rb
@@ -1,62 +1,35 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/hash/key_error'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.fetch" do
- before :each do
- @foo_saved = ENV.delete("foo")
- end
- after :each do
- ENV["foo"] = @saved_foo
- end
-
it "returns a value" do
ENV["foo"] = "bar"
ENV.fetch("foo").should == "bar"
+ ENV.delete "foo"
end
it "raises a TypeError if the key is not a String" do
- -> { ENV.fetch Object.new }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ lambda { ENV.fetch :should_never_be_set }.should raise_error(TypeError)
end
- context "when the key is not found" do
- it_behaves_like :key_error, -> obj, key { obj.fetch(key) }, ENV
-
- it "formats the object with #inspect in the KeyError message" do
- -> {
- ENV.fetch('foo')
- }.should raise_error(KeyError, 'key not found: "foo"')
- end
+ it "raises a KeyError if the key is not found" do
+ lambda { ENV.fetch "should_never_be_set" }.should raise_error(KeyError)
end
it "provides the given default parameter" do
- ENV.fetch("foo", "default").should == "default"
- end
-
- it "does not insist that the default be a String" do
- ENV.fetch("foo", :default).should == :default
+ ENV.fetch("should_never_be_set", "default").should == "default"
end
it "provides a default value from a block" do
- ENV.fetch("foo") { |k| "wanted #{k}" }.should == "wanted foo"
- end
-
- it "does not insist that the block return a String" do
- ENV.fetch("foo") { |k| k.to_sym }.should == :foo
+ ENV.fetch("should_never_be_set") { |k| "wanted #{k}" }.should == "wanted should_never_be_set"
end
it "warns on block and default parameter given" do
- -> do
- ENV.fetch("foo", "default") { "bar" }.should == "bar"
+ lambda do
+ ENV.fetch("should_never_be_set", "default") { 1 }.should == 1
end.should complain(/block supersedes default value argument/)
end
- it "does not evaluate the block when key found" do
- ENV["foo"] = "bar"
- ENV.fetch("foo") { fail "should not get here"}.should == "bar"
- end
-
it "uses the locale encoding" do
- ENV["foo"] = "bar"
- ENV.fetch("foo").encoding.should == Encoding.find('locale')
+ ENV.fetch(ENV.keys.first).encoding.should == Encoding.find('locale')
end
end
diff --git a/spec/ruby/core/env/filter_spec.rb b/spec/ruby/core/env/filter_spec.rb
deleted file mode 100644
index ba18a3b33b..0000000000
--- a/spec/ruby/core/env/filter_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
-require_relative 'shared/select'
-
-ruby_version_is "2.6" do
- describe "ENV.filter!" do
- it_behaves_like :env_select!, :filter!
- it_behaves_like :enumeratorized_with_origin_size, :filter!, ENV
- end
-
- describe "ENV.filter" do
- it_behaves_like :env_select, :filter
- it_behaves_like :enumeratorized_with_origin_size, :filter, ENV
- end
-end
diff --git a/spec/ruby/core/env/has_key_spec.rb b/spec/ruby/core/env/has_key_spec.rb
index 798668105d..8da2d94265 100644
--- a/spec/ruby/core/env/has_key_spec.rb
+++ b/spec/ruby/core/env/has_key_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include.rb', __FILE__)
describe "ENV.has_key?" do
- it_behaves_like :env_include, :has_key?
+ it_behaves_like(:env_include, :has_key?)
end
diff --git a/spec/ruby/core/env/has_value_spec.rb b/spec/ruby/core/env/has_value_spec.rb
index a2bf3eb877..76980a8df4 100644
--- a/spec/ruby/core/env/has_value_spec.rb
+++ b/spec/ruby/core/env/has_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/value.rb', __FILE__)
describe "ENV.has_value?" do
- it_behaves_like :env_value, :has_value?
+ it_behaves_like(:env_value, :has_value?)
end
diff --git a/spec/ruby/core/env/include_spec.rb b/spec/ruby/core/env/include_spec.rb
index 3975f095ac..4a716fee85 100644
--- a/spec/ruby/core/env/include_spec.rb
+++ b/spec/ruby/core/env/include_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include.rb', __FILE__)
describe "ENV.include?" do
- it_behaves_like :env_include, :include?
+ it_behaves_like(:env_include, :include?)
end
diff --git a/spec/ruby/core/env/index_spec.rb b/spec/ruby/core/env/index_spec.rb
index 2457b65cc6..95009b3558 100644
--- a/spec/ruby/core/env/index_spec.rb
+++ b/spec/ruby/core/env/index_spec.rb
@@ -1,14 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/key'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/key.rb', __FILE__)
-ruby_version_is ""..."2.7" do
- describe "ENV.index" do
- it_behaves_like :env_key, :index
-
- it "warns about deprecation" do
- -> do
- ENV.index("foo")
- end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
- end
- end
+describe "ENV.index" do
+ it_behaves_like(:env_key, :index)
end
diff --git a/spec/ruby/core/env/indexes_spec.rb b/spec/ruby/core/env/indexes_spec.rb
index e724feaa39..14fb93ef07 100644
--- a/spec/ruby/core/env/indexes_spec.rb
+++ b/spec/ruby/core/env/indexes_spec.rb
@@ -1 +1 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
diff --git a/spec/ruby/core/env/indices_spec.rb b/spec/ruby/core/env/indices_spec.rb
index e724feaa39..14fb93ef07 100644
--- a/spec/ruby/core/env/indices_spec.rb
+++ b/spec/ruby/core/env/indices_spec.rb
@@ -1 +1 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
diff --git a/spec/ruby/core/env/inspect_spec.rb b/spec/ruby/core/env/inspect_spec.rb
index 3c611c24a1..9c4273e188 100644
--- a/spec/ruby/core/env/inspect_spec.rb
+++ b/spec/ruby/core/env/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.inspect" do
diff --git a/spec/ruby/core/env/invert_spec.rb b/spec/ruby/core/env/invert_spec.rb
index c095374d95..42170230db 100644
--- a/spec/ruby/core/env/invert_spec.rb
+++ b/spec/ruby/core/env/invert_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.invert" do
before :each do
diff --git a/spec/ruby/core/env/keep_if_spec.rb b/spec/ruby/core/env/keep_if_spec.rb
index 64b6a207d0..c5bbc3dc05 100644
--- a/spec/ruby/core/env/keep_if_spec.rb
+++ b/spec/ruby/core/env/keep_if_spec.rb
@@ -1,32 +1,22 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "ENV.keep_if" do
before :each do
- @foo = ENV["foo"]
- @bar = ENV["bar"]
-
- ENV["foo"] = "0"
- ENV["bar"] = "1"
+ ENV["foo"] = "bar"
end
after :each do
- ENV["foo"] = @foo
- ENV["bar"] = @bar
+ ENV.delete "foo"
end
it "deletes pairs if the block returns false" do
- ENV.keep_if { |k, v| !["foo", "bar"].include?(k) }
+ ENV.keep_if { |k, v| k != "foo" }
ENV["foo"].should == nil
- ENV["bar"].should == nil
- end
-
- it "returns ENV when block given" do
- ENV.keep_if { |k, v| !["foo", "bar"].include?(k) }.should equal(ENV)
end
it "returns ENV even if nothing deleted" do
- ENV.keep_if { true }.should equal(ENV)
+ ENV.keep_if { true }.should_not == nil
end
it "returns an Enumerator if no block given" do
@@ -35,19 +25,8 @@ describe "ENV.keep_if" do
it "deletes pairs through enumerator" do
enum = ENV.keep_if
- enum.each { |k, v| !["foo", "bar"].include?(k) }
+ enum.each { |k, v| k != "foo" }
ENV["foo"].should == nil
- ENV["bar"].should == nil
- end
-
- it "returns ENV from enumerator" do
- enum = ENV.keep_if
- enum.each { |k, v| !["foo", "bar"].include?(k) }.should equal(ENV)
- end
-
- it "returns ENV from enumerator even if nothing deleted" do
- enum = ENV.keep_if
- enum.each { true }.should equal(ENV)
end
it_behaves_like :enumeratorized_with_origin_size, :keep_if, ENV
diff --git a/spec/ruby/core/env/key_spec.rb b/spec/ruby/core/env/key_spec.rb
index 82cfbefa39..b653b1b1a5 100644
--- a/spec/ruby/core/env/key_spec.rb
+++ b/spec/ruby/core/env/key_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
-require_relative 'shared/key'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include.rb', __FILE__)
+require File.expand_path('../shared/key.rb', __FILE__)
describe "ENV.key?" do
- it_behaves_like :env_include, :key?
+ it_behaves_like(:env_include, :key?)
end
describe "ENV.key" do
- it_behaves_like :env_key, :key
+ it_behaves_like(:env_key, :key)
end
diff --git a/spec/ruby/core/env/keys_spec.rb b/spec/ruby/core/env/keys_spec.rb
index b074a8f7c7..d79919b79d 100644
--- a/spec/ruby/core/env/keys_spec.rb
+++ b/spec/ruby/core/env/keys_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.keys" do
- it "returns an array of the keys" do
- ENV.keys.should == ENV.to_hash.keys
+ it "returns all the keys" do
+ ENV.keys.sort.should == ENV.to_hash.keys.sort
end
it "returns the keys in the locale encoding" do
diff --git a/spec/ruby/core/env/length_spec.rb b/spec/ruby/core/env/length_spec.rb
index 536af9edf5..83d1b58c74 100644
--- a/spec/ruby/core/env/length_spec.rb
+++ b/spec/ruby/core/env/length_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length.rb', __FILE__)
describe "ENV.length" do
- it_behaves_like :env_length, :length
+ it_behaves_like(:env_length, :length)
end
diff --git a/spec/ruby/core/env/member_spec.rb b/spec/ruby/core/env/member_spec.rb
index 9119022ae5..25aa71e973 100644
--- a/spec/ruby/core/env/member_spec.rb
+++ b/spec/ruby/core/env/member_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include.rb', __FILE__)
describe "ENV.member?" do
- it_behaves_like :env_include, :member?
+ it_behaves_like(:env_include, :member?)
end
diff --git a/spec/ruby/core/env/merge_spec.rb b/spec/ruby/core/env/merge_spec.rb
deleted file mode 100644
index b418cd11f4..0000000000
--- a/spec/ruby/core/env/merge_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/update'
-
-ruby_version_is "2.7" do
- describe "ENV.merge!" do
- it_behaves_like :env_update, :merge!
- end
-end
diff --git a/spec/ruby/core/env/rassoc_spec.rb b/spec/ruby/core/env/rassoc_spec.rb
index ab9fe68088..3a86e7e158 100644
--- a/spec/ruby/core/env/rassoc_spec.rb
+++ b/spec/ruby/core/env/rassoc_spec.rb
@@ -1,14 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.rassoc" do
- before :each do
- @foo = ENV["foo"]
- @baz = ENV["baz"]
- end
-
after :each do
- ENV["foo"] = @foo
- ENV["baz"] = @baz
+ ENV.delete("foo")
end
it "returns an array of the key and value of the environment variable with the given value" do
@@ -16,15 +10,6 @@ describe "ENV.rassoc" do
ENV.rassoc("bar").should == ["foo", "bar"]
end
- it "returns a single array even if there are multiple such environment variables" do
- ENV["foo"] = "bar"
- ENV["baz"] = "bar"
- [
- ["foo", "bar"],
- ["baz", "bar"],
- ].should include(ENV.rassoc("bar"))
- end
-
it "returns nil if no environment variable with the given value exists" do
ENV.rassoc("bar").should == nil
end
@@ -35,8 +20,4 @@ describe "ENV.rassoc" do
v.should_receive(:to_str).and_return("bar")
ENV.rassoc(v).should == ["foo", "bar"]
end
-
- it "returns nil if the argument is not a String and does not respond to #to_str" do
- ENV.rassoc(Object.new).should == nil
- end
end
diff --git a/spec/ruby/core/env/rehash_spec.rb b/spec/ruby/core/env/rehash_spec.rb
index 3782e4b727..14fb93ef07 100644
--- a/spec/ruby/core/env/rehash_spec.rb
+++ b/spec/ruby/core/env/rehash_spec.rb
@@ -1,7 +1 @@
-require_relative '../../spec_helper'
-
-describe "ENV.rehash" do
- it "returns nil" do
- ENV.rehash.should == nil
- end
-end
+require File.expand_path('../../../spec_helper', __FILE__)
diff --git a/spec/ruby/core/env/reject_spec.rb b/spec/ruby/core/env/reject_spec.rb
index 6a9794925d..0da84425b6 100644
--- a/spec/ruby/core/env/reject_spec.rb
+++ b/spec/ruby/core/env/reject_spec.rb
@@ -1,15 +1,7 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "ENV.reject!" do
- before :each do
- @foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"] = @foo
- end
-
it "rejects entries based on key" do
ENV["foo"] = "bar"
ENV.reject! { |k, v| k == "foo" }
@@ -25,23 +17,19 @@ describe "ENV.reject!" do
it "returns itself or nil" do
ENV.reject! { false }.should == nil
ENV["foo"] = "bar"
- ENV.reject! { |k, v| k == "foo" }.should equal(ENV)
+ ENV.reject! { |k, v| k == "foo" }.should == ENV
ENV["foo"].should == nil
end
it "returns an Enumerator if called without a block" do
- ENV["foo"] = "bar"
- enum = ENV.reject!
- enum.should be_an_instance_of(Enumerator)
- enum.each { |k, v| k == "foo" }.should equal(ENV)
- ENV["foo"].should == nil
+ ENV.reject!.should be_an_instance_of(Enumerator)
end
it "doesn't raise if empty" do
orig = ENV.to_hash
begin
ENV.clear
- -> { ENV.reject! }.should_not raise_error(LocalJumpError)
+ lambda { ENV.reject! }.should_not raise_error(LocalJumpError)
ensure
ENV.replace orig
end
@@ -51,14 +39,6 @@ describe "ENV.reject!" do
end
describe "ENV.reject" do
- before :each do
- @foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"] = @foo
- end
-
it "rejects entries based on key" do
ENV["foo"] = "bar"
e = ENV.reject { |k, v| k == "foo" }
@@ -80,18 +60,14 @@ describe "ENV.reject" do
end
it "returns an Enumerator if called without a block" do
- ENV["foo"] = "bar"
- enum = ENV.reject
- enum.should be_an_instance_of(Enumerator)
- enum.each { |k, v| k == "foo"}
- ENV["foo"] = nil
+ ENV.reject.should be_an_instance_of(Enumerator)
end
it "doesn't raise if empty" do
orig = ENV.to_hash
begin
ENV.clear
- -> { ENV.reject }.should_not raise_error(LocalJumpError)
+ lambda { ENV.reject }.should_not raise_error(LocalJumpError)
ensure
ENV.replace orig
end
diff --git a/spec/ruby/core/env/replace_spec.rb b/spec/ruby/core/env/replace_spec.rb
index 9fc67643d1..0c11e173ac 100644
--- a/spec/ruby/core/env/replace_spec.rb
+++ b/spec/ruby/core/env/replace_spec.rb
@@ -1,51 +1,15 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.replace" do
- before :each do
- @orig = ENV.to_hash
- ENV.delete("foo")
- end
-
- after :each do
- ENV.replace(@orig)
- end
it "replaces ENV with a Hash" do
- ENV.replace("foo" => "0", "bar" => "1").should equal(ENV)
- ENV.size.should == 2
- ENV["foo"].should == "0"
- ENV["bar"].should == "1"
- end
-
- it "raises TypeError if the argument is not a Hash" do
- -> { ENV.replace(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into Hash")
- ENV.to_hash.should == @orig
- end
-
- it "raises TypeError if a key is not a String" do
- -> { ENV.replace(Object.new => "0") }.should raise_error(TypeError, "no implicit conversion of Object into String")
- ENV.to_hash.should == @orig
- end
-
- it "raises TypeError if a value is not a String" do
- -> { ENV.replace("foo" => Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
- ENV.to_hash.should == @orig
- end
-
- it "raises Errno::EINVAL when the key contains the '=' character" do
- -> { ENV.replace("foo=" =>"bar") }.should raise_error(Errno::EINVAL)
- end
-
- it "raises Errno::EINVAL when the key is an empty string" do
- -> { ENV.replace("" => "bar") }.should raise_error(Errno::EINVAL)
- end
-
- it "does not accept good data preceding an error" do
- -> { ENV.replace("foo" => "1", Object.new => Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ ENV["foo"] = "bar"
+ e = ENV.reject { |k, v| k == "foo" }
+ e["baz"] = "bam"
+ ENV.replace e
+ ENV["foo"].should == nil
+ ENV["baz"].should == "bam"
+ ENV.delete "baz"
end
- it "does not accept good data following an error" do
- -> { ENV.replace(Object.new => Object.new, "foo" => "0") }.should raise_error(TypeError, "no implicit conversion of Object into String")
- ENV.to_hash.should == @orig
- end
end
diff --git a/spec/ruby/core/env/select_spec.rb b/spec/ruby/core/env/select_spec.rb
index c3a76f4434..8261ff593a 100644
--- a/spec/ruby/core/env/select_spec.rb
+++ b/spec/ruby/core/env/select_spec.rb
@@ -1,13 +1,39 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
-require_relative 'shared/select'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "ENV.select!" do
- it_behaves_like :env_select!, :select!
+ it "removes environment variables for which the block returns true" do
+ ENV["foo"] = "bar"
+ ENV.select! { |k, v| k != "foo" }
+ ENV["foo"].should == nil
+ end
+
+ it "returns self if any changes were made" do
+ ENV["foo"] = "bar"
+ ENV.select! { |k, v| k != "foo" }.should == ENV
+ end
+
+ it "returns nil if no changes were made" do
+ ENV.select! { true }.should == nil
+ end
+
+ it "returns an Enumerator if called without a block" do
+ ENV.select!.should be_an_instance_of(Enumerator)
+ end
+
it_behaves_like :enumeratorized_with_origin_size, :select!, ENV
end
describe "ENV.select" do
- it_behaves_like :env_select, :select
+ it "returns a Hash of names and values for which block return true" do
+ ENV["foo"] = "bar"
+ ENV.select { |k, v| k == "foo" }.should == {"foo" => "bar"}
+ ENV.delete "foo"
+ end
+
+ it "returns an Enumerator when no block is given" do
+ ENV.select.should be_an_instance_of(Enumerator)
+ end
+
it_behaves_like :enumeratorized_with_origin_size, :select, ENV
end
diff --git a/spec/ruby/core/env/shared/each.rb b/spec/ruby/core/env/shared/each.rb
index d901b854c4..494fd5cee1 100644
--- a/spec/ruby/core/env/shared/each.rb
+++ b/spec/ruby/core/env/shared/each.rb
@@ -1,4 +1,4 @@
-require_relative '../../enumerable/shared/enumeratorized'
+require File.expand_path('../../../enumerable/shared/enumeratorized', __FILE__)
describe :env_each, shared: true do
it "returns each pair" do
@@ -8,7 +8,7 @@ describe :env_each, shared: true do
ENV.clear
ENV["foo"] = "bar"
ENV["baz"] = "boo"
- ENV.send(@method) { |k, v| e << [k, v] }.should equal(ENV)
+ ENV.send(@method) { |k, v| e << [k, v] }
e.should include(["foo", "bar"])
e.should include(["baz", "boo"])
ensure
@@ -17,11 +17,7 @@ describe :env_each, shared: true do
end
it "returns an Enumerator if called without a block" do
- enum = ENV.send(@method)
- enum.should be_an_instance_of(Enumerator)
- enum.each do |name, value|
- ENV[name].should == value
- end
+ ENV.send(@method).should be_an_instance_of(Enumerator)
end
before :all do
@@ -29,35 +25,39 @@ describe :env_each, shared: true do
end
it_should_behave_like :enumeratorized_with_origin_size
- describe "with encoding" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
+ with_feature :encoding do
+ describe "with encoding" do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- Encoding.default_external = Encoding::BINARY
- end
+ Encoding.default_external = Encoding::ASCII_8BIT
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
+ @locale_encoding = Encoding.find "locale"
+ end
- it "uses the locale encoding when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+ end
+
+ it "uses the locale encoding when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
- ENV.send(@method) do |key, value|
- key.should.be_locale_env
- value.should.be_locale_env
+ ENV.send(@method) do |key, value|
+ key.encoding.should equal(@locale_encoding)
+ value.encoding.should equal(@locale_encoding)
+ end
end
- end
- it "transcodes from the locale encoding to Encoding.default_internal if set" do
- Encoding.default_internal = internal = Encoding::IBM437
+ it "transcodes from the locale encoding to Encoding.default_internal if set" do
+ Encoding.default_internal = internal = Encoding::IBM437
- ENV.send(@method) do |key, value|
- key.encoding.should equal(internal)
- if value.ascii_only?
- value.encoding.should equal(internal)
+ ENV.send(@method) do |key, value|
+ key.encoding.should equal(internal)
+ if value.ascii_only?
+ value.encoding.should equal(internal)
+ end
end
end
end
diff --git a/spec/ruby/core/env/shared/include.rb b/spec/ruby/core/env/shared/include.rb
index 3efcd523d6..8d8311dcf2 100644
--- a/spec/ruby/core/env/shared/include.rb
+++ b/spec/ruby/core/env/shared/include.rb
@@ -1,23 +1,11 @@
describe :env_include, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- end
-
it "returns true if ENV has the key" do
ENV["foo"] = "bar"
ENV.send(@method, "foo").should == true
+ ENV.delete "foo"
end
it "returns false if ENV doesn't include the key" do
- ENV.delete("foo")
- ENV.send(@method, "foo").should == false
- end
-
- it "raises TypeError if the argument is not a String and does not respond to #to_str" do
- -> { ENV.send(@method, Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ ENV.send(@method, "should_never_be_set").should == false
end
end
diff --git a/spec/ruby/core/env/shared/key.rb b/spec/ruby/core/env/shared/key.rb
index fcb3a9b8c5..5e6c21840f 100644
--- a/spec/ruby/core/env/shared/key.rb
+++ b/spec/ruby/core/env/shared/key.rb
@@ -1,23 +1,15 @@
describe :env_key, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- end
+ it "needs to be reviewed for completeness"
it "returns the index associated with the passed value" do
ENV["foo"] = "bar"
ENV.send(@method, "bar").should == "foo"
+ ENV.delete "foo"
end
it "returns nil if the passed value is not found" do
- ENV.delete("foo")
- ENV.send(@method, "foo").should be_nil
- end
-
- it "raises TypeError if the argument is not a String and does not respond to #to_str" do
- -> { ENV.send(@method, Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ ENV.send(@method, "should_never_be_set").should be_nil
end
end
+
+
diff --git a/spec/ruby/core/env/shared/select.rb b/spec/ruby/core/env/shared/select.rb
deleted file mode 100644
index 75ba112a32..0000000000
--- a/spec/ruby/core/env/shared/select.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-describe :env_select, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- end
-
- it "returns a Hash of names and values for which block return true" do
- ENV["foo"] = "bar"
- (ENV.send(@method) { |k, v| k == "foo" }).should == { "foo" => "bar" }
- end
-
- it "returns an Enumerator when no block is given" do
- enum = ENV.send(@method)
- enum.should be_an_instance_of(Enumerator)
- end
-
- it "selects via the enumerator" do
- enum = ENV.send(@method)
- ENV["foo"] = "bar"
- enum.each { |k, v| k == "foo" }.should == { "foo" => "bar"}
- end
-end
-
-describe :env_select!, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- end
-
- it "removes environment variables for which the block returns true" do
- ENV["foo"] = "bar"
- ENV.send(@method) { |k, v| k != "foo" }
- ENV["foo"].should == nil
- end
-
- it "returns self if any changes were made" do
- ENV["foo"] = "bar"
- (ENV.send(@method) { |k, v| k != "foo" }).should == ENV
- end
-
- it "returns nil if no changes were made" do
- (ENV.send(@method) { true }).should == nil
- end
-
- it "returns an Enumerator if called without a block" do
- ENV.send(@method).should be_an_instance_of(Enumerator)
- end
-
- it "selects via the enumerator" do
- enum = ENV.send(@method)
- ENV["foo"] = "bar"
- enum.each { |k, v| k != "foo" }
- ENV["foo"].should == nil
- end
-end
diff --git a/spec/ruby/core/env/shared/store.rb b/spec/ruby/core/env/shared/store.rb
index d6265c66a5..4949ca8c73 100644
--- a/spec/ruby/core/env/shared/store.rb
+++ b/spec/ruby/core/env/shared/store.rb
@@ -1,10 +1,6 @@
describe :env_store, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- end
-
after :each do
- ENV["foo"] = @saved_foo
+ ENV.delete("foo")
end
it "sets the environment variable to the given value" do
@@ -38,19 +34,19 @@ describe :env_store, shared: true do
end
it "raises TypeError when the key is not coercible to String" do
- -> { ENV.send(@method, Object.new, "bar") }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ lambda { ENV.send(@method, Object.new, "bar") }.should raise_error(TypeError)
end
it "raises TypeError when the value is not coercible to String" do
- -> { ENV.send(@method, "foo", Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ lambda { ENV.send(@method, "foo", Object.new) }.should raise_error(TypeError)
end
it "raises Errno::EINVAL when the key contains the '=' character" do
- -> { ENV.send(@method, "foo=", "bar") }.should raise_error(Errno::EINVAL)
+ lambda { ENV.send(@method, "foo=", "bar") }.should raise_error(Errno::EINVAL)
end
it "raises Errno::EINVAL when the key is an empty string" do
- -> { ENV.send(@method, "", "bar") }.should raise_error(Errno::EINVAL)
+ lambda { ENV.send(@method, "", "bar") }.should raise_error(Errno::EINVAL)
end
it "does nothing when the key is not a valid environment variable key and the value is nil" do
diff --git a/spec/ruby/core/env/shared/to_hash.rb b/spec/ruby/core/env/shared/to_hash.rb
index a0d4d7ce69..3bfbc415f7 100644
--- a/spec/ruby/core/env/shared/to_hash.rb
+++ b/spec/ruby/core/env/shared/to_hash.rb
@@ -1,33 +1,22 @@
describe :env_to_hash, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"]= @saved_foo
- end
-
it "returns the ENV as a hash" do
ENV["foo"] = "bar"
h = ENV.send(@method)
h.should be_an_instance_of(Hash)
h["foo"].should == "bar"
+ ENV.delete "foo"
end
it "uses the locale encoding for keys" do
- ENV.send(@method).keys.each {|k| k.should.be_locale_env }
+ ENV.send(@method).keys.all? {|k| k.encoding == Encoding.find('locale') }.should be_true
end
it "uses the locale encoding for values" do
- ENV.send(@method).values.each {|k| k.should.be_locale_env }
+ ENV.send(@method).values.all? {|v| v.encoding == Encoding.find('locale') }.should be_true
end
it "duplicates the ENV when converting to a Hash" do
h = ENV.send(@method)
- h.should_not equal ENV
- h.size.should == ENV.size
- h.each_pair do |k, v|
- ENV[k].should == v
- end
+ h.object_id.should_not == ENV.object_id
end
end
diff --git a/spec/ruby/core/env/shared/update.rb b/spec/ruby/core/env/shared/update.rb
deleted file mode 100644
index 129a56544c..0000000000
--- a/spec/ruby/core/env/shared/update.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-describe :env_update, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- @saved_bar = ENV["bar"]
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- ENV["bar"] = @saved_bar
- end
-
- it "adds the parameter hash to ENV, returning ENV" do
- ENV.send(@method, "foo" => "0", "bar" => "1").should equal(ENV)
- ENV["foo"].should == "0"
- ENV["bar"].should == "1"
- end
-
- it "returns ENV when no block given" do
- ENV.send(@method, {"foo" => "0", "bar" => "1"}).should equal(ENV)
- end
-
- it "yields key, the old value and the new value when replacing an entry" do
- ENV.send @method, {"foo" => "0", "bar" => "3"}
- a = []
- ENV.send @method, {"foo" => "1", "bar" => "4"} do |key, old, new|
- a << [key, old, new]
- new
- end
- a[0].should == ["foo", "0", "1"]
- a[1].should == ["bar", "3", "4"]
- end
-
- it "yields key, the old value and the new value when replacing an entry" do
- ENV.send @method, {"foo" => "0", "bar" => "3"}
- ENV.send @method, {"foo" => "1", "bar" => "4"} do |key, old, new|
- (new.to_i + 1).to_s
- end
- ENV["foo"].should == "2"
- ENV["bar"].should == "5"
- end
-
- ruby_version_is "2.7" do
- # BUG: https://bugs.ruby-lang.org/issues/16192
- it "does not evaluate the block when the name is new" do
- ENV.delete("bar")
- ENV.send @method, {"foo" => "0"}
- ENV.send(@method, "bar" => "1") { |key, old, new| fail "Should not get here" }
- ENV["bar"].should == "1"
- end
-
- # BUG: https://bugs.ruby-lang.org/issues/16192
- it "does not use the block's return value as the value when the name is new" do
- ENV.delete("bar")
- ENV.send @method, {"foo" => "0"}
- ENV.send(@method, "bar" => "1") { |key, old, new| "Should not use this value" }
- ENV["foo"].should == "0"
- ENV["bar"].should == "1"
- end
- end
-
- it "returns ENV when block given" do
- ENV.send(@method, {"foo" => "0", "bar" => "1"}){}.should equal(ENV)
- end
-
- it "raises TypeError when a name is not coercible to String" do
- -> { ENV.send @method, Object.new => "0" }.should raise_error(TypeError, "no implicit conversion of Object into String")
- end
-
- it "raises TypeError when a value is not coercible to String" do
- -> { ENV.send @method, "foo" => Object.new }.should raise_error(TypeError, "no implicit conversion of Object into String")
- end
-
- it "raises Errno::EINVAL when a name contains the '=' character" do
- -> { ENV.send(@method, "foo=" => "bar") }.should raise_error(Errno::EINVAL)
- end
-
- it "raises Errno::EINVAL when a name is an empty string" do
- -> { ENV.send(@method, "" => "bar") }.should raise_error(Errno::EINVAL)
- end
-
- it "updates good data preceding an error" do
- ENV["foo"] = "0"
- begin
- ENV.send @method, {"foo" => "2", Object.new => "1"}
- rescue TypeError
- ensure
- ENV["foo"].should == "2"
- end
- end
-
- it "does not update good data following an error" do
- ENV["foo"] = "0"
- begin
- ENV.send @method, {Object.new => "1", "foo" => "2"}
- rescue TypeError
- ensure
- ENV["foo"].should == "0"
- end
- end
-end
diff --git a/spec/ruby/core/env/shared/value.rb b/spec/ruby/core/env/shared/value.rb
index bef96b5fef..d9ee90f12d 100644
--- a/spec/ruby/core/env/shared/value.rb
+++ b/spec/ruby/core/env/shared/value.rb
@@ -1,22 +1,11 @@
describe :env_value, shared: true do
- before :each do
- @saved_foo = ENV["foo"]
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- end
-
it "returns true if ENV has the value" do
ENV["foo"] = "bar"
ENV.send(@method, "bar").should == true
+ ENV["foo"] = nil
end
it "returns false if ENV doesn't have the value" do
- ENV.send(@method, "foo").should == false
- end
-
- it "returns nil if the argument is not a String and does not respond to #to_str" do
- ENV.send(@method, Object.new).should == nil
+ ENV.send(@method, "this_value_should_never_exist").should == false
end
end
diff --git a/spec/ruby/core/env/shift_spec.rb b/spec/ruby/core/env/shift_spec.rb
index c03b5d50c5..bae6a17ba0 100644
--- a/spec/ruby/core/env/shift_spec.rb
+++ b/spec/ruby/core/env/shift_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.shift" do
it "returns a pair and deletes it" do
@@ -24,34 +24,36 @@ describe "ENV.shift" do
end
end
-describe "ENV.shift" do
- before :each do
- @orig = ENV.to_hash
- @external = Encoding.default_external
- @internal = Encoding.default_internal
+with_feature :encoding do
+ describe "ENV.shift" do
+ before :each do
+ @orig = ENV.to_hash
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- Encoding.default_external = Encoding::BINARY
- end
+ Encoding.default_external = Encoding::ASCII_8BIT
+ end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- ENV.replace @orig
- end
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+ ENV.replace @orig
+ end
- it "uses the locale encoding if Encoding.default_internal is nil" do
- Encoding.default_internal = nil
+ it "uses the locale encoding if Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
- pair = ENV.shift
- pair.first.encoding.should equal(Encoding.find("locale"))
- pair.last.encoding.should equal(Encoding.find("locale"))
- end
+ pair = ENV.shift
+ pair.first.encoding.should equal(Encoding.find("locale"))
+ pair.last.encoding.should equal(Encoding.find("locale"))
+ end
- it "transcodes from the locale encoding to Encoding.default_internal if set" do
- Encoding.default_internal = Encoding::IBM437
+ it "transcodes from the locale encoding to Encoding.default_internal if set" do
+ Encoding.default_internal = Encoding::IBM437
- pair = ENV.shift
- pair.first.encoding.should equal(Encoding::IBM437)
- pair.last.encoding.should equal(Encoding::IBM437)
+ pair = ENV.shift
+ pair.first.encoding.should equal(Encoding::IBM437)
+ pair.last.encoding.should equal(Encoding::IBM437)
+ end
end
end
diff --git a/spec/ruby/core/env/size_spec.rb b/spec/ruby/core/env/size_spec.rb
index f050e9e5a9..882ceac485 100644
--- a/spec/ruby/core/env/size_spec.rb
+++ b/spec/ruby/core/env/size_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length.rb', __FILE__)
describe "ENV.size" do
- it_behaves_like :env_length, :size
+ it_behaves_like(:env_length, :size)
end
diff --git a/spec/ruby/core/env/slice_spec.rb b/spec/ruby/core/env/slice_spec.rb
deleted file mode 100644
index 1ac8a303f8..0000000000
--- a/spec/ruby/core/env/slice_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "ENV.slice" do
- before :each do
- @saved_foo = ENV["foo"]
- @saved_bar = ENV["bar"]
- ENV["foo"] = "0"
- ENV["bar"] = "1"
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- ENV["bar"] = @saved_bar
- end
-
- it "returns a hash of the given environment variable names and their values" do
- ENV.slice("foo", "bar").should == {"foo" => "0", "bar" => "1"}
- end
-
- it "ignores each String that is not an environment variable name" do
- ENV.slice("foo", "boo", "bar").should == {"foo" => "0", "bar" => "1"}
- end
-
- it "raises TypeError if any argument is not a String and does not respond to #to_str" do
- -> { ENV.slice(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
- end
- end
-end
diff --git a/spec/ruby/core/env/spec_helper.rb b/spec/ruby/core/env/spec_helper.rb
deleted file mode 100644
index 470ffa58bc..0000000000
--- a/spec/ruby/core/env/spec_helper.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../spec_helper'
-
-locale_env_matcher = Class.new do
- def initialize(name = 'locale')
- encoding = Encoding.find(name)
- @encodings = (encoding = Encoding::US_ASCII) ?
- [encoding, Encoding::ASCII_8BIT] : [encoding]
- end
-
- def matches?(actual)
- @actual = actual = actual.encoding
- @encodings.include?(actual)
- end
-
- def failure_message
- ["Expected #{@actual} to be #{@encodings.join(' or ')}"]
- end
-
- def negative_failure_message
- ["Expected #{@actual} not to be #{@encodings.join(' or ')}"]
- end
-end
-
-String.__send__(:define_method, :be_locale_env) do |expected = 'locale'|
- locale_env_matcher.new(expected)
-end
diff --git a/spec/ruby/core/env/store_spec.rb b/spec/ruby/core/env/store_spec.rb
index b4700e0a96..1ee5ce020e 100644
--- a/spec/ruby/core/env/store_spec.rb
+++ b/spec/ruby/core/env/store_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/store'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/store.rb', __FILE__)
describe "ENV.store" do
- it_behaves_like :env_store, :store
+ it_behaves_like(:env_store, :store)
end
diff --git a/spec/ruby/core/env/to_a_spec.rb b/spec/ruby/core/env/to_a_spec.rb
index 39e3877b48..ffb66b8767 100644
--- a/spec/ruby/core/env/to_a_spec.rb
+++ b/spec/ruby/core/env/to_a_spec.rb
@@ -1,18 +1,19 @@
-require_relative 'spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.to_a" do
it "returns the ENV as an array" do
+ ENV["foo"] = "bar"
a = ENV.to_a
a.is_a?(Array).should == true
- a.size.should == ENV.size
- ENV.each_pair { |k, v| a.should include([k, v])}
+ a.find { |e| e.first == "foo" }.should == ["foo", "bar"]
+ ENV.delete "foo"
end
it "returns the entries in the locale encoding" do
ENV.to_a.each do |key, value|
- key.should.be_locale_env
- value.should.be_locale_env
+ key.encoding.should == Encoding.find('locale')
+ value.encoding.should == Encoding.find('locale')
end
end
end
diff --git a/spec/ruby/core/env/to_h_spec.rb b/spec/ruby/core/env/to_h_spec.rb
index 65cdb59951..d0fef5382b 100644
--- a/spec/ruby/core/env/to_h_spec.rb
+++ b/spec/ruby/core/env/to_h_spec.rb
@@ -1,60 +1,6 @@
-require_relative 'spec_helper'
-require_relative 'shared/to_hash'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_hash.rb', __FILE__)
-describe "ENV.to_h" do
- it_behaves_like :env_to_hash, :to_h
-
- ruby_version_is "2.6" do
- context "with block" do
- before do
- @orig_hash = ENV.to_hash
- end
-
- after do
- ENV.replace @orig_hash
- end
-
- it "converts [key, value] pairs returned by the block to a hash" do
- ENV.replace("a" => "b", "c" => "d")
- ENV.to_h { |k, v| [k, v.upcase] }.should == { 'a' => "B", 'c' => "D" }
- end
-
- it "does not require the array elements to be strings" do
- ENV.replace("a" => "b", "c" => "d")
- ENV.to_h { |k, v| [k.to_sym, v.to_sym] }.should == { :a => :b, :c => :d }
- end
-
- it "raises ArgumentError if block returns longer or shorter array" do
- -> do
- ENV.to_h { |k, v| [k, v.upcase, 1] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
-
- -> do
- ENV.to_h { |k, v| [k] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
- end
-
- it "raises TypeError if block returns something other than Array" do
- -> do
- ENV.to_h { |k, v| "not-array" }
- end.should raise_error(TypeError, /wrong element type String/)
- end
-
- it "coerces returned pair to Array with #to_ary" do
- x = mock('x')
- x.stub!(:to_ary).and_return([:b, 'b'])
-
- ENV.to_h { |k| x }.should == { :b => 'b' }
- end
-
- it "does not coerce returned pair to Array with #to_a" do
- x = mock('x')
- x.stub!(:to_a).and_return([:b, 'b'])
-
- -> do
- ENV.to_h { |k| x }
- end.should raise_error(TypeError, /wrong element type MockObject/)
- end
- end
- end
+describe "ENV.to_hash" do
+ it_behaves_like(:env_to_hash, :to_h)
end
diff --git a/spec/ruby/core/env/to_hash_spec.rb b/spec/ruby/core/env/to_hash_spec.rb
index 306572c353..3362fa9307 100644
--- a/spec/ruby/core/env/to_hash_spec.rb
+++ b/spec/ruby/core/env/to_hash_spec.rb
@@ -1,6 +1,6 @@
-require_relative 'spec_helper'
-require_relative 'shared/to_hash'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_hash.rb', __FILE__)
describe "ENV.to_hash" do
- it_behaves_like :env_to_hash, :to_hash
+ it_behaves_like(:env_to_hash, :to_hash)
end
diff --git a/spec/ruby/core/env/to_s_spec.rb b/spec/ruby/core/env/to_s_spec.rb
index 0bd92cf217..10aca09723 100644
--- a/spec/ruby/core/env/to_s_spec.rb
+++ b/spec/ruby/core/env/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.to_s" do
it "returns \"ENV\"" do
diff --git a/spec/ruby/core/env/update_spec.rb b/spec/ruby/core/env/update_spec.rb
index 95a8a2eb49..7ebfbb313d 100644
--- a/spec/ruby/core/env/update_spec.rb
+++ b/spec/ruby/core/env/update_spec.rb
@@ -1,6 +1,25 @@
-require_relative '../../spec_helper'
-require_relative 'shared/update'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.update" do
- it_behaves_like :env_update, :update
+
+ it "adds the parameter hash to ENV" do
+ ENV["foo"].should == nil
+ ENV.update "foo" => "bar"
+ ENV["foo"].should == "bar"
+ ENV.delete "foo"
+ end
+
+ it "yields key, the old value and the new value when replacing entries" do
+ ENV.update "foo" => "bar"
+ ENV["foo"].should == "bar"
+ ENV.update("foo" => "boo") do |key, old, new|
+ key.should == "foo"
+ old.should == "bar"
+ new.should == "boo"
+ "rab"
+ end
+ ENV["foo"].should == "rab"
+ ENV.delete "foo"
+ end
+
end
diff --git a/spec/ruby/core/env/value_spec.rb b/spec/ruby/core/env/value_spec.rb
index 906e86ab39..c7eb7c5376 100644
--- a/spec/ruby/core/env/value_spec.rb
+++ b/spec/ruby/core/env/value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/value.rb', __FILE__)
describe "ENV.value?" do
- it_behaves_like :env_value, :value?
+ it_behaves_like(:env_value, :value?)
end
diff --git a/spec/ruby/core/env/values_at_spec.rb b/spec/ruby/core/env/values_at_spec.rb
index ee970e5f65..efc7de2a05 100644
--- a/spec/ruby/core/env/values_at_spec.rb
+++ b/spec/ruby/core/env/values_at_spec.rb
@@ -1,37 +1,17 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.values_at" do
- before :each do
- @saved_foo = ENV["foo"]
- @saved_bar = ENV["bar"]
- end
-
- after :each do
- ENV["foo"] = @saved_foo
- ENV["bar"] = @saved_bar
- end
- it "returns an array of the values corresponding to the given keys" do
+ it "returns an array of the values referenced by the parameters as keys" do
ENV["foo"] = "oof"
ENV["bar"] = "rab"
- ENV.values_at("bar", "foo").should == ["rab", "oof"]
- end
-
- it "returns an empty array if no keys specified" do
ENV.values_at.should == []
- end
-
- it "returns nil for each key that is not a name" do
- ENV["foo"] = "oof"
- ENV["bar"] = "rab"
- ENV.values_at("x", "bar", "y", "foo", "z").should == [nil, "rab", nil, "oof", nil]
+ ENV.values_at("bar", "foo").should == ["rab", "oof"]
+ ENV.delete "foo"
+ ENV.delete "bar"
end
it "uses the locale encoding" do
ENV.values_at(ENV.keys.first).first.encoding.should == Encoding.find('locale')
end
-
- it "raises TypeError when a key is not coercible to String" do
- -> { ENV.values_at("foo", Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
- end
end
diff --git a/spec/ruby/core/env/values_spec.rb b/spec/ruby/core/env/values_spec.rb
index 71bc877d31..3a620bdb8b 100644
--- a/spec/ruby/core/env/values_spec.rb
+++ b/spec/ruby/core/env/values_spec.rb
@@ -1,14 +1,21 @@
-require_relative 'spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ENV.values" do
it "returns an array of the values" do
- ENV.values.should == ENV.to_hash.values
+ orig = ENV.to_hash
+ begin
+ ENV.replace "a" => "b", "c" => "d"
+ a = ENV.values
+ a.sort.should == ["b", "d"]
+ ensure
+ ENV.replace orig
+ end
end
it "uses the locale encoding" do
ENV.values.each do |value|
- value.should.be_locale_env
+ value.encoding.should == Encoding.find('locale')
end
end
end
diff --git a/spec/ruby/core/exception/args_spec.rb b/spec/ruby/core/exception/args_spec.rb
new file mode 100644
index 0000000000..410e21edfb
--- /dev/null
+++ b/spec/ruby/core/exception/args_spec.rb
@@ -0,0 +1,5 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "NoMethodError#args" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/exception/arguments_spec.rb b/spec/ruby/core/exception/arguments_spec.rb
new file mode 100644
index 0000000000..47c4339e2d
--- /dev/null
+++ b/spec/ruby/core/exception/arguments_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "ArgumentError" do
+ it "is a subclass of StandardError" do
+ StandardError.should be_ancestor_of(ArgumentError)
+ end
+
+ it "gives its own class name as message if it has no message" do
+ ArgumentError.new.message.should == "ArgumentError"
+ end
+end
diff --git a/spec/ruby/core/exception/backtrace_locations_spec.rb b/spec/ruby/core/exception/backtrace_locations_spec.rb
deleted file mode 100644
index 86eb9d3413..0000000000
--- a/spec/ruby/core/exception/backtrace_locations_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-
-describe "Exception#backtrace_locations" do
- before :each do
- @backtrace = ExceptionSpecs::Backtrace.backtrace_locations
- end
-
- it "returns nil if no backtrace was set" do
- Exception.new.backtrace_locations.should be_nil
- end
-
- it "returns an Array" do
- @backtrace.should be_an_instance_of(Array)
- end
-
- it "sets each element to a Thread::Backtrace::Location" do
- @backtrace.each {|l| l.should be_an_instance_of(Thread::Backtrace::Location)}
- end
-
- it "produces a backtrace for an exception captured using $!" do
- exception = begin
- raise
- rescue RuntimeError
- $!
- end
-
- exception.backtrace_locations.first.path.should =~ /backtrace_locations_spec/
- end
-
- it "returns an Array that can be updated" do
- begin
- raise
- rescue RuntimeError => e
- e.backtrace_locations.unshift "backtrace first"
- e.backtrace_locations[0].should == "backtrace first"
- end
- end
-end
diff --git a/spec/ruby/core/exception/backtrace_spec.rb b/spec/ruby/core/exception/backtrace_spec.rb
index 2d6825180a..2d115e9b2f 100644
--- a/spec/ruby/core/exception/backtrace_spec.rb
+++ b/spec/ruby/core/exception/backtrace_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Exception#backtrace" do
before :each do
@@ -47,7 +47,7 @@ describe "Exception#backtrace" do
end
end
- it "captures the backtrace for an exception into $!" do
+ it "produces a backtrace for an exception captured using $!" do
exception = begin
raise
rescue RuntimeError
@@ -57,16 +57,6 @@ describe "Exception#backtrace" do
exception.backtrace.first.should =~ /backtrace_spec/
end
- it "captures the backtrace for an exception into $@" do
- backtrace = begin
- raise
- rescue RuntimeError
- $@
- end
-
- backtrace.first.should =~ /backtrace_spec/
- end
-
it "returns an Array that can be updated" do
begin
raise
@@ -75,19 +65,4 @@ describe "Exception#backtrace" do
e.backtrace[0].should == "backtrace first"
end
end
-
- it "returns the same array after duping" do
- begin
- raise
- rescue RuntimeError => err
- bt = err.backtrace
- err.dup.backtrace.should equal(bt)
-
- new_bt = ['hi']
- err.set_backtrace new_bt
-
- err.backtrace.should == new_bt
- err.dup.backtrace.should equal(new_bt)
- end
- end
end
diff --git a/spec/ruby/core/exception/case_compare_spec.rb b/spec/ruby/core/exception/case_compare_spec.rb
index 87b9dee3ca..7592564855 100644
--- a/spec/ruby/core/exception/case_compare_spec.rb
+++ b/spec/ruby/core/exception/case_compare_spec.rb
@@ -1,39 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SystemCallError.===" do
- before :all do
- @example_errno_class = Errno::EINVAL
- @example_errno = @example_errno_class::Errno
- end
-
- it "returns true for an instance of the same class" do
- Errno::EINVAL.should === Errno::EINVAL.new
- end
-
- it "returns true if errnos same" do
- e = SystemCallError.new('foo', @example_errno)
- @example_errno_class.===(e).should == true
- end
-
- it "returns false if errnos different" do
- e = SystemCallError.new('foo', @example_errno + 1)
- @example_errno_class.===(e).should == false
- end
-
- it "returns false if arg is not kind of SystemCallError" do
- e = Object.new
- @example_errno_class.===(e).should == false
- end
-
- it "returns true if receiver is generic and arg is kind of SystemCallError" do
- unknown_error_number = Errno.constants.size
- e = SystemCallError.new('foo', @example_errno)
- SystemCallError.===(e).should == true
- end
-
- it "returns false if receiver is generic and arg is not kind of SystemCallError" do
- unknown_error_number = Errno.constants.size
- e = Object.new
- SystemCallError.===(e).should == false
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/cause_spec.rb b/spec/ruby/core/exception/cause_spec.rb
index cf4aaeb188..a1aa39ae34 100644
--- a/spec/ruby/core/exception/cause_spec.rb
+++ b/spec/ruby/core/exception/cause_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Exception#cause" do
it "returns the active exception when an exception is raised" do
@@ -16,41 +16,4 @@ describe "Exception#cause" do
end
end
end
-
- it "is set for user errors caused by internal errors" do
- -> {
- begin
- 1 / 0
- rescue
- raise "foo"
- end
- }.should raise_error(RuntimeError) { |e|
- e.cause.should be_kind_of(ZeroDivisionError)
- }
- end
-
- it "is set for internal errors caused by user errors" do
- cause = RuntimeError.new "cause"
- -> {
- begin
- raise cause
- rescue
- 1 / 0
- end
- }.should raise_error(ZeroDivisionError) { |e|
- e.cause.should equal(cause)
- }
- end
-
- it "is not set to the exception itself when it is re-raised" do
- -> {
- begin
- raise RuntimeError
- rescue RuntimeError => e
- raise e
- end
- }.should raise_error(RuntimeError) { |e|
- e.cause.should == nil
- }
- end
end
diff --git a/spec/ruby/core/exception/destination_encoding_name_spec.rb b/spec/ruby/core/exception/destination_encoding_name_spec.rb
index a9e6474974..d6a01c3220 100644
--- a/spec/ruby/core/exception/destination_encoding_name_spec.rb
+++ b/spec/ruby/core/exception/destination_encoding_name_spec.rb
@@ -1,23 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::UndefinedConversionError#destination_encoding_name" do
- it "returns the destination encoding name" do
- ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
- begin
- ec.convert("\xa0")
- rescue Encoding::UndefinedConversionError => e
- e.destination_encoding_name.should == "EUC-JP"
- end
- end
+ it "needs to be reviewed for spec completeness"
end
describe "Encoding::InvalidByteSequenceError#destination_encoding_name" do
- it "returns the destination encoding name" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- begin
- ec.convert("\xa0")
- rescue Encoding::InvalidByteSequenceError => e
- e.destination_encoding_name.should == "UTF-8"
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/destination_encoding_spec.rb b/spec/ruby/core/exception/destination_encoding_spec.rb
index 5709c31e55..09064a01f3 100644
--- a/spec/ruby/core/exception/destination_encoding_spec.rb
+++ b/spec/ruby/core/exception/destination_encoding_spec.rb
@@ -1,23 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::UndefinedConversionError#destination_encoding" do
- it "returns the destination encoding" do
- ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
- begin
- ec.convert("\xa0")
- rescue Encoding::UndefinedConversionError => e
- e.destination_encoding.should == Encoding::EUC_JP
- end
- end
+ it "needs to be reviewed for spec completeness"
end
describe "Encoding::InvalidByteSequenceError#destination_encoding" do
- it "returns the destination encoding" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- begin
- ec.convert("\xa0")
- rescue Encoding::InvalidByteSequenceError => e
- e.destination_encoding.should == Encoding::UTF_8
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/dup_spec.rb b/spec/ruby/core/exception/dup_spec.rb
deleted file mode 100644
index edd54bfb37..0000000000
--- a/spec/ruby/core/exception/dup_spec.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-
-describe "Exception#dup" do
- before :each do
- @obj = ExceptionSpecs::InitializeException.new("my exception")
- end
-
- it "calls #initialize_copy on the new instance" do
- dup = @obj.dup
- ScratchPad.recorded.should_not == @obj.object_id
- ScratchPad.recorded.should == dup.object_id
- end
-
- it "copies instance variables" do
- dup = @obj.dup
- dup.ivar.should == 1
- end
-
- it "does not copy singleton methods" do
- def @obj.special() :the_one end
- dup = @obj.dup
- -> { dup.special }.should raise_error(NameError)
- end
-
- it "does not copy modules included in the singleton class" do
- class << @obj
- include ExceptionSpecs::ExceptionModule
- end
-
- dup = @obj.dup
- -> { dup.repr }.should raise_error(NameError)
- end
-
- it "does not copy constants defined in the singleton class" do
- class << @obj
- CLONE = :clone
- end
-
- dup = @obj.dup
- -> { class << dup; CLONE; end }.should raise_error(NameError)
- end
-
- it "does copy the message" do
- @obj.dup.message.should == @obj.message
- end
-
- it "does copy the backtrace" do
- begin
- # Explicitly raise so a backtrace is associated with the exception.
- # It's tempting to call `set_backtrace` instead, but that complicates
- # the test because it might affect other state (e.g., instance variables)
- # on some implementations.
- raise ExceptionSpecs::InitializeException.new("my exception")
- rescue => e
- @obj = e
- end
-
- @obj.dup.backtrace.should == @obj.backtrace
- end
-
- it "does copy the cause" do
- begin
- raise StandardError, "the cause"
- rescue StandardError => cause
- begin
- raise RuntimeError, "the consequence"
- rescue RuntimeError => e
- e.cause.should equal(cause)
- e.dup.cause.should equal(cause)
- end
- end
- end
-end
diff --git a/spec/ruby/core/exception/equal_value_spec.rb b/spec/ruby/core/exception/equal_value_spec.rb
index 7f2065511a..3aad809377 100644
--- a/spec/ruby/core/exception/equal_value_spec.rb
+++ b/spec/ruby/core/exception/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Exception#==" do
it "returns true if both exceptions are the same object" do
diff --git a/spec/ruby/core/exception/errno_spec.rb b/spec/ruby/core/exception/errno_spec.rb
index 9e0bf0086a..f7f5b45d8a 100644
--- a/spec/ruby/core/exception/errno_spec.rb
+++ b/spec/ruby/core/exception/errno_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "SystemCallError#errno" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/error_bytes_spec.rb b/spec/ruby/core/exception/error_bytes_spec.rb
index 66dd4b62c1..e5027d0cf3 100644
--- a/spec/ruby/core/exception/error_bytes_spec.rb
+++ b/spec/ruby/core/exception/error_bytes_spec.rb
@@ -1,12 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::InvalidByteSequenceError#error_bytes" do
- it "returns the error bytes" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- begin
- ec.convert("\xa0")
- rescue Encoding::InvalidByteSequenceError => e
- e.error_bytes.should == "\xA0".force_encoding("ASCII-8BIT")
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/error_char_spec.rb b/spec/ruby/core/exception/error_char_spec.rb
index f95ae2a6ce..8842424e90 100644
--- a/spec/ruby/core/exception/error_char_spec.rb
+++ b/spec/ruby/core/exception/error_char_spec.rb
@@ -1,12 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::UndefinedConversionError#error_char" do
- it "returns the error char" do
- ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
- begin
- ec.convert("\xa0")
- rescue Encoding::UndefinedConversionError => e
- e.error_char.should == "\u00A0"
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/exception_spec.rb b/spec/ruby/core/exception/exception_spec.rb
index d6f5283bd9..afa482b9d7 100644
--- a/spec/ruby/core/exception/exception_spec.rb
+++ b/spec/ruby/core/exception/exception_spec.rb
@@ -1,9 +1,51 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/new'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "Exception.exception" do
- it_behaves_like :exception_new, :exception
+ it_behaves_like(:exception_new, :exception)
+end
+
+describe "Exception" do
+ it "is a Class" do
+ Exception.should be_kind_of(Class)
+ end
+
+ it "is a superclass of NoMemoryError" do
+ Exception.should be_ancestor_of(NoMemoryError)
+ end
+
+ it "is a superclass of ScriptError" do
+ Exception.should be_ancestor_of(ScriptError)
+ end
+
+ it "is a superclass of SignalException" do
+ Exception.should be_ancestor_of(SignalException)
+ end
+
+ it "is a superclass of Interrupt" do
+ SignalException.should be_ancestor_of(Interrupt)
+ end
+
+ it "is a superclass of StandardError" do
+ Exception.should be_ancestor_of(StandardError)
+ end
+
+ it "is a superclass of SystemExit" do
+ Exception.should be_ancestor_of(SystemExit)
+ end
+
+ it "is a superclass of SystemStackError" do
+ Exception.should be_ancestor_of(SystemStackError)
+ end
+
+ it "is a superclass of SecurityError" do
+ Exception.should be_ancestor_of(SecurityError)
+ end
+
+ it "is a superclass of EncodingError" do
+ Exception.should be_ancestor_of(EncodingError)
+ end
end
describe "Exception#exception" do
@@ -24,34 +66,6 @@ describe "Exception#exception" do
e2.message.should == "message"
end
- it "when raised will be rescued as the new exception" do
- begin
- begin
- raised_first = StandardError.new('first')
- raise raised_first
- rescue => caught_first
- raised_second = raised_first.exception('second')
- raise raised_second
- end
- rescue => caught_second
- end
-
- raised_first.should == caught_first
- raised_second.should == caught_second
- end
-
- it "captures an exception into $!" do
- exception = begin
- raise
- rescue RuntimeError
- $!
- end
-
- exception.class.should == RuntimeError
- exception.message.should == ""
- exception.backtrace.first.should =~ /exception_spec/
- end
-
class CustomArgumentError < StandardError
attr_reader :val
def initialize(val)
diff --git a/spec/ruby/core/exception/exit_value_spec.rb b/spec/ruby/core/exception/exit_value_spec.rb
index 43de56af8b..daa5eb0b94 100644
--- a/spec/ruby/core/exception/exit_value_spec.rb
+++ b/spec/ruby/core/exception/exit_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "LocalJumpError#exit_value" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/fixtures/common.rb b/spec/ruby/core/exception/fixtures/common.rb
index 0ffb3ed855..51dd0bf9ed 100644
--- a/spec/ruby/core/exception/fixtures/common.rb
+++ b/spec/ruby/core/exception/fixtures/common.rb
@@ -4,19 +4,11 @@ module ExceptionSpecs
class Backtrace
def self.backtrace
begin
- raise # If you move this line, update backtrace_spec.rb
+ raise # Do not move this line or update backtrace_spec.rb
rescue RuntimeError => e
e.backtrace
end
end
-
- def self.backtrace_locations
- begin
- raise
- rescue RuntimeError => e
- e.backtrace_locations
- end
- end
end
class UnExceptional < Exception
@@ -46,26 +38,6 @@ module ExceptionSpecs
""
end
end
-
- class InitializeException < StandardError
- attr_reader :ivar
-
- def initialize(message = nil)
- super
- @ivar = 1
- end
-
- def initialize_copy(other)
- super
- ScratchPad.record object_id
- end
- end
-
- module ExceptionModule
- def repr
- 1
- end
- end
end
module NoMethodErrorSpecs
@@ -81,9 +53,6 @@ module NoMethodErrorSpecs
end
class NoMethodErrorD; end
-
- class InstanceException < Exception
- end
end
class NameErrorSpecs
diff --git a/spec/ruby/core/exception/frozen_error_spec.rb b/spec/ruby/core/exception/frozen_error_spec.rb
deleted file mode 100644
index 1b5ea71148..0000000000
--- a/spec/ruby/core/exception/frozen_error_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "FrozenError" do
- ruby_version_is "2.5" do
- it "is a subclass of RuntimeError" do
- RuntimeError.should be_ancestor_of(FrozenError)
- end
- end
-end
-
-describe "FrozenError.new" do
- ruby_version_is "2.7" do
- it "should take optional receiver argument" do
- o = Object.new
- FrozenError.new("msg", receiver: o).receiver.should equal(o)
- end
- end
-end
-
-describe "FrozenError#receiver" do
- ruby_version_is "2.7" do
- it "should return frozen object that modification was attempted on" do
- o = Object.new.freeze
- begin
- def o.x; end
- rescue => e
- e.should be_kind_of(FrozenError)
- e.receiver.should equal(o)
- else
- raise
- end
- end
- end
-end
diff --git a/spec/ruby/core/exception/full_message_spec.rb b/spec/ruby/core/exception/full_message_spec.rb
deleted file mode 100644
index 3df2d47f61..0000000000
--- a/spec/ruby/core/exception/full_message_spec.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.5" do
- describe "Exception#full_message" do
- it "returns formatted string of exception using the same format that is used to print an uncaught exceptions to stderr" do
- e = RuntimeError.new("Some runtime error")
- e.set_backtrace(["a.rb:1", "b.rb:2"])
-
- full_message = e.full_message
- full_message.should include "RuntimeError"
- full_message.should include "Some runtime error"
- full_message.should include "a.rb:1"
- full_message.should include "b.rb:2"
- end
-
- ruby_version_is "2.5.1" do
- it "supports :highlight option and adds escape sequences to highlight some strings" do
- e = RuntimeError.new("Some runtime error")
-
- full_message = e.full_message(highlight: true, order: :bottom)
- full_message.should include "\e[1mTraceback\e[m (most recent call last)"
- full_message.should include "\e[1mSome runtime error (\e[1;4mRuntimeError\e[m\e[1m)"
-
- full_message = e.full_message(highlight: false, order: :bottom)
- full_message.should include "Traceback (most recent call last)"
- full_message.should include "Some runtime error (RuntimeError)"
- end
-
- it "supports :order option and places the error message and the backtrace at the top or the bottom" do
- e = RuntimeError.new("Some runtime error")
- e.set_backtrace(["a.rb:1", "b.rb:2"])
-
- e.full_message(order: :top, highlight: false).should =~ /a.rb:1.*b.rb:2/m
- e.full_message(order: :bottom, highlight: false).should =~ /b.rb:2.*a.rb:1/m
- end
-
- it "shows the caller if the exception has no backtrace" do
- e = RuntimeError.new("Some runtime error")
- e.backtrace.should == nil
- full_message = e.full_message(highlight: false, order: :top)
- full_message.should include("#{__FILE__}:#{__LINE__-1}:in `")
- full_message.should include("': Some runtime error (RuntimeError)\n")
- end
-
- it "shows the exception class at the end of the first line of the message when the message contains multiple lines" do
- begin
- line = __LINE__; raise "first line\nsecond line"
- rescue => e
- full_message = e.full_message(highlight: false, order: :top).lines
- full_message[0].should include("#{__FILE__}:#{line}:in `")
- full_message[0].should include(": first line (RuntimeError)\n")
- full_message[1].should == "second line\n"
- end
- end
- end
-
- ruby_version_is "2.6" do
- it "contains cause of exception" do
- begin
- begin
- raise 'the cause'
- rescue
- raise 'main exception'
- end
- rescue => e
- exception = e
- end
-
- exception.full_message.should include "main exception"
- exception.full_message.should include "the cause"
- end
-
- it 'contains all the chain of exceptions' do
- begin
- begin
- begin
- raise 'origin exception'
- rescue
- raise 'intermediate exception'
- end
- rescue
- raise 'last exception'
- end
- rescue => e
- exception = e
- end
-
- exception.full_message.should include "last exception"
- exception.full_message.should include "intermediate exception"
- exception.full_message.should include "origin exception"
- end
- end
- end
-end
diff --git a/spec/ruby/core/exception/hierarchy_spec.rb b/spec/ruby/core/exception/hierarchy_spec.rb
deleted file mode 100644
index e52811c761..0000000000
--- a/spec/ruby/core/exception/hierarchy_spec.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Exception" do
- it "has the right class hierarchy" do
- hierarchy = {
- Exception => {
- NoMemoryError => nil,
- ScriptError => {
- LoadError => nil,
- NotImplementedError => nil,
- SyntaxError => nil,
- },
- SecurityError => nil,
- SignalException => {
- Interrupt => nil,
- },
- StandardError => {
- ArgumentError => {
- UncaughtThrowError => nil,
- },
- EncodingError => nil,
- FiberError => nil,
- IOError => {
- EOFError => nil,
- },
- IndexError => {
- KeyError => nil,
- StopIteration => {
- ClosedQueueError => nil,
- },
- },
- LocalJumpError => nil,
- NameError => {
- NoMethodError => nil,
- },
- RangeError => {
- FloatDomainError => nil,
- },
- RegexpError => nil,
- RuntimeError => nil,
- SystemCallError => nil,
- ThreadError => nil,
- TypeError => nil,
- ZeroDivisionError => nil,
- },
- SystemExit => nil,
- SystemStackError => nil,
- },
- }
- ruby_version_is "2.5" do
- hierarchy[Exception][StandardError][RuntimeError] = {FrozenError => nil}
- end
- traverse = -> parent_class, parent_subclass_hash {
- parent_subclass_hash.each do |child_class, child_subclass_hash|
- child_class.class.should == Class
- child_class.superclass.should == parent_class
- traverse.call(child_class, child_subclass_hash) if child_subclass_hash
- end
- }
- traverse.call(Object, hierarchy)
- end
-end
diff --git a/spec/ruby/core/exception/incomplete_input_spec.rb b/spec/ruby/core/exception/incomplete_input_spec.rb
index b033b33f56..a64d4be3f3 100644
--- a/spec/ruby/core/exception/incomplete_input_spec.rb
+++ b/spec/ruby/core/exception/incomplete_input_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::InvalidByteSequenceError#incomplete_input?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/initialize_spec.rb b/spec/ruby/core/exception/initialize_spec.rb
index e724feaa39..14fb93ef07 100644
--- a/spec/ruby/core/exception/initialize_spec.rb
+++ b/spec/ruby/core/exception/initialize_spec.rb
@@ -1 +1 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
diff --git a/spec/ruby/core/exception/inspect_spec.rb b/spec/ruby/core/exception/inspect_spec.rb
index 6f380a36c7..5b06ffee71 100644
--- a/spec/ruby/core/exception/inspect_spec.rb
+++ b/spec/ruby/core/exception/inspect_spec.rb
@@ -1,15 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Exception#inspect" do
it "returns '#<Exception: Exception>' when no message given" do
Exception.new.inspect.should == "#<Exception: Exception>"
end
- it "keeps message encoding" do
- Exception.new('å').inspect.should == "#<Exception: å>"
- end
-
it "includes #to_s when the result is non-empty" do
ExceptionSpecs::OverrideToS.new.inspect.should == "#<ExceptionSpecs::OverrideToS: this is from #to_s>"
end
diff --git a/spec/ruby/core/exception/interrupt_spec.rb b/spec/ruby/core/exception/interrupt_spec.rb
index 14f294bec6..ef24743936 100644
--- a/spec/ruby/core/exception/interrupt_spec.rb
+++ b/spec/ruby/core/exception/interrupt_spec.rb
@@ -1,4 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Interrupt" do
+ it "is a subclass of SignalException" do
+ Interrupt.superclass.should == SignalException
+ end
+end
describe "Interrupt.new" do
it "returns an instance of interrupt with no message given" do
@@ -14,7 +20,7 @@ describe "Interrupt.new" do
end
end
-describe "rescuing Interrupt" do
+describe "rescueing Interrupt" do
before do
@original_sigint_proc = Signal.trap(:INT, :SIG_DFL)
end
diff --git a/spec/ruby/core/exception/io_error_spec.rb b/spec/ruby/core/exception/io_error_spec.rb
index 8dc10cc6ce..0971be332f 100644
--- a/spec/ruby/core/exception/io_error_spec.rb
+++ b/spec/ruby/core/exception/io_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IOError" do
it "is a superclass of EOFError" do
diff --git a/spec/ruby/core/exception/key_error_spec.rb b/spec/ruby/core/exception/key_error_spec.rb
deleted file mode 100644
index ad280279d8..0000000000
--- a/spec/ruby/core/exception/key_error_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "KeyError" do
- ruby_version_is "2.6" do
- it "accepts :receiver and :key options" do
- receiver = mock("receiver")
- key = mock("key")
-
- error = KeyError.new(receiver: receiver, key: key)
-
- error.receiver.should == receiver
- error.key.should == key
- end
- end
-end
diff --git a/spec/ruby/core/exception/load_error_spec.rb b/spec/ruby/core/exception/load_error_spec.rb
index 0056403e58..2999c66117 100644
--- a/spec/ruby/core/exception/load_error_spec.rb
+++ b/spec/ruby/core/exception/load_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "LoadError#path" do
before :each do
diff --git a/spec/ruby/core/exception/message_spec.rb b/spec/ruby/core/exception/message_spec.rb
index 8d7476126e..7eee6d99de 100644
--- a/spec/ruby/core/exception/message_spec.rb
+++ b/spec/ruby/core/exception/message_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Exception#message" do
it "returns the class name if there is no message" do
diff --git a/spec/ruby/core/exception/name_error_spec.rb b/spec/ruby/core/exception/name_error_spec.rb
index d0a810029b..e5b19d6219 100644
--- a/spec/ruby/core/exception/name_error_spec.rb
+++ b/spec/ruby/core/exception/name_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NameError" do
it "is a superclass of NoMethodError" do
@@ -10,15 +10,4 @@ describe "NameError.new" do
it "should take optional name argument" do
NameError.new("msg","name").name.should == "name"
end
-
- ruby_version_is "2.6" do
- it "accepts a :receiver keyword argument" do
- receiver = mock("receiver")
-
- error = NameError.new("msg", :name, receiver: receiver)
-
- error.receiver.should == receiver
- error.name.should == :name
- end
- end
end
diff --git a/spec/ruby/core/exception/name_spec.rb b/spec/ruby/core/exception/name_spec.rb
index d1def51f24..e8a3c011d2 100644
--- a/spec/ruby/core/exception/name_spec.rb
+++ b/spec/ruby/core/exception/name_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NameError#name" do
it "returns a method name as a symbol" do
@@ -27,19 +27,35 @@ describe "NameError#name" do
}.should raise_error(NameError) { |e| e.name.should == :@@doesnt_exist }
end
- it "returns the first argument passed to the method when a NameError is raised from #instance_variable_get" do
- invalid_ivar_name = "invalid_ivar_name"
+ ruby_version_is ""..."2.3" do
+ it "always returns a symbol when a NameError is raised from #instance_variable_get" do
+ -> {
+ Object.new.instance_variable_get("invalid_ivar_name")
+ }.should raise_error(NameError) { |e| e.name.should == :invalid_ivar_name }
+ end
- -> {
- Object.new.instance_variable_get(invalid_ivar_name)
- }.should raise_error(NameError) {|e| e.name.should equal(invalid_ivar_name) }
+ it "always returns a symbol when a NameError is raised from #class_variable_get" do
+ -> {
+ Object.class_variable_get("invalid_cvar_name")
+ }.should raise_error(NameError) { |e| e.name.should == :invalid_cvar_name }
+ end
end
- it "returns the first argument passed to the method when a NameError is raised from #class_variable_get" do
- invalid_cvar_name = "invalid_cvar_name"
+ ruby_version_is "2.3" do
+ it "returns the first argument passed to the method when a NameError is raised from #instance_variable_get" do
+ invalid_ivar_name = "invalid_ivar_name"
- -> {
- Object.class_variable_get(invalid_cvar_name)
- }.should raise_error(NameError) {|e| e.name.should equal(invalid_cvar_name) }
+ -> {
+ Object.new.instance_variable_get(invalid_ivar_name)
+ }.should raise_error(NameError) {|e| e.name.should equal(invalid_ivar_name) }
+ end
+
+ it "returns the first argument passed to the method when a NameError is raised from #class_variable_get" do
+ invalid_cvar_name = "invalid_cvar_name"
+
+ -> {
+ Object.class_variable_get(invalid_cvar_name)
+ }.should raise_error(NameError) {|e| e.name.should equal(invalid_cvar_name) }
+ end
end
end
diff --git a/spec/ruby/core/exception/new_spec.rb b/spec/ruby/core/exception/new_spec.rb
index 100dbb0a24..61d35a1dfa 100644
--- a/spec/ruby/core/exception/new_spec.rb
+++ b/spec/ruby/core/exception/new_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/new'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "Exception.new" do
- it_behaves_like :exception_new, :new
+ it_behaves_like(:exception_new, :new)
end
diff --git a/spec/ruby/core/exception/no_method_error_spec.rb b/spec/ruby/core/exception/no_method_error_spec.rb
index 28c3549562..cf3fe58b1d 100644
--- a/spec/ruby/core/exception/no_method_error_spec.rb
+++ b/spec/ruby/core/exception/no_method_error_spec.rb
@@ -1,25 +1,14 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "NoMethodError.new" do
it "allows passing method args" do
- NoMethodError.new("msg", "name", ["args"]).args.should == ["args"]
+ NoMethodError.new("msg","name","args").args.should == "args"
end
it "does not require a name" do
NoMethodError.new("msg").message.should == "msg"
end
-
- ruby_version_is "2.6" do
- it "accepts a :receiver keyword argument" do
- receiver = mock("receiver")
-
- error = NoMethodError.new("msg", :name, receiver: receiver)
-
- error.receiver.should == receiver
- error.name.should == :name
- end
- end
end
describe "NoMethodError#args" do
@@ -37,7 +26,7 @@ describe "NoMethodError#args" do
NoMethodErrorSpecs::NoMethodErrorB.new.foo(1,a)
rescue Exception => e
e.args.should == [1,a]
- e.args[1].should equal a
+ e.args[1].object_id.should == a.object_id
end
end
end
@@ -67,40 +56,4 @@ describe "NoMethodError#message" do
e.message.match(/private method/).should_not == nil
end
end
-
- it "calls receiver.inspect only when calling Exception#message" do
- ScratchPad.record []
- test_class = Class.new do
- def inspect
- ScratchPad << :inspect_called
- "<inspect>"
- end
- end
- instance = test_class.new
- begin
- instance.bar
- rescue Exception => e
- e.name.should == :bar
- ScratchPad.recorded.should == []
- e.message.should =~ /undefined method.+\bbar\b/
- ScratchPad.recorded.should == [:inspect_called]
- end
- end
-
- it "fallbacks to a simpler representation of the receiver when receiver.inspect raises an exception" do
- test_class = Class.new do
- def inspect
- raise NoMethodErrorSpecs::InstanceException
- end
- end
- instance = test_class.new
- begin
- instance.bar
- rescue Exception => e
- e.name.should == :bar
- message = e.message
- message.should =~ /undefined method.+\bbar\b/
- message.should include test_class.inspect
- end
- end
end
diff --git a/spec/ruby/core/exception/range_error_spec.rb b/spec/ruby/core/exception/range_error_spec.rb
index 7cfbd0f1ec..9c0462bbf7 100644
--- a/spec/ruby/core/exception/range_error_spec.rb
+++ b/spec/ruby/core/exception/range_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "RangeError" do
it "is a superclass of FloatDomainError" do
diff --git a/spec/ruby/core/exception/readagain_bytes_spec.rb b/spec/ruby/core/exception/readagain_bytes_spec.rb
index 0f1e24f1cf..30efb67686 100644
--- a/spec/ruby/core/exception/readagain_bytes_spec.rb
+++ b/spec/ruby/core/exception/readagain_bytes_spec.rb
@@ -1,12 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::InvalidByteSequenceError#readagain_bytes" do
- it "returns the next byte" do
- begin
- "abc\xa4def".encode("ISO-8859-1", "EUC-JP")
- rescue Encoding::InvalidByteSequenceError => e
- e.error_bytes.should == "\xA4".force_encoding("ASCII-8BIT")
- e.readagain_bytes.should == 'd'
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/reason_spec.rb b/spec/ruby/core/exception/reason_spec.rb
index 6f18aaae13..fad4d47c64 100644
--- a/spec/ruby/core/exception/reason_spec.rb
+++ b/spec/ruby/core/exception/reason_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "LocalJumpError#reason" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/receiver_spec.rb b/spec/ruby/core/exception/receiver_spec.rb
index 7c57d63c3e..83f8d5927c 100644
--- a/spec/ruby/core/exception/receiver_spec.rb
+++ b/spec/ruby/core/exception/receiver_spec.rb
@@ -1,60 +1,62 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
-describe "NameError#receiver" do
- class ::ReceiverClass
- def call_undefined_class_variable; @@doesnt_exist end
- end
+ruby_version_is "2.3" do
+ describe "NameError#receiver" do
+ class ::ReceiverClass
+ def call_undefined_class_variable; @@doesnt_exist end
+ end
- it "returns the object that raised the exception" do
- receiver = Object.new
+ it "returns the object that raised the exception" do
+ receiver = Object.new
- -> {
- receiver.doesnt_exist
- }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
- end
+ -> {
+ receiver.doesnt_exist
+ }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
+ end
- it "returns the Object class when an undefined constant is called without namespace" do
- -> {
- DoesntExist
- }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
- end
+ it "returns the Object class when an undefined constant is called without namespace" do
+ -> {
+ DoesntExist
+ }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
+ end
- it "returns a class when an undefined constant is called" do
- -> {
- NameErrorSpecs::ReceiverClass::DoesntExist
- }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
- end
+ it "returns a class when an undefined constant is called" do
+ -> {
+ NameErrorSpecs::ReceiverClass::DoesntExist
+ }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
+ end
- it "returns the Object class when an undefined class variable is called" do
- -> {
+ it "returns the Object class when an undefined class variable is called" do
-> {
- @@doesnt_exist
- }.should complain(/class variable access from toplevel/)
- }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
- end
+ -> {
+ @@doesnt_exist
+ }.should complain(/class variable access from toplevel/)
+ }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
+ end
- it "returns a class when an undefined class variable is called in a subclass' namespace" do
- -> {
- NameErrorSpecs::ReceiverClass.new.call_undefined_class_variable
- }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
- end
+ it "returns a class when an undefined class variable is called in a subclass' namespace" do
+ -> {
+ NameErrorSpecs::ReceiverClass.new.call_undefined_class_variable
+ }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
+ end
- it "returns the receiver when raised from #instance_variable_get" do
- receiver = Object.new
+ it "returns the receiver when raised from #instance_variable_get" do
+ receiver = Object.new
- -> {
- receiver.instance_variable_get("invalid_ivar_name")
- }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
- end
+ -> {
+ receiver.instance_variable_get("invalid_ivar_name")
+ }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
+ end
- it "returns the receiver when raised from #class_variable_get" do
- -> {
- Object.class_variable_get("invalid_cvar_name")
- }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
- end
+ it "returns the receiver when raised from #class_variable_get" do
+ -> {
+ Object.class_variable_get("invalid_cvar_name")
+ }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
+ end
- it "raises an ArgumentError when the receiver is none" do
- -> { NameError.new.receiver }.should raise_error(ArgumentError)
+ it "raises an ArgumentError when the receiver is none" do
+ -> { NameError.new.receiver }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/exception/result_spec.rb b/spec/ruby/core/exception/result_spec.rb
index 5ba26ebab1..350c071f60 100644
--- a/spec/ruby/core/exception/result_spec.rb
+++ b/spec/ruby/core/exception/result_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "StopIteration" do
it "is a subclass of IndexError" do
@@ -20,7 +20,7 @@ describe "StopIteration#result" do
it "returns the method-returned-object from an Enumerator" do
@enum.next
@enum.next
- -> { @enum.next }.should(
+ lambda { @enum.next }.should(
raise_error(StopIteration) do |error|
error.result.should equal(:method_returned)
end
diff --git a/spec/ruby/core/exception/script_error_spec.rb b/spec/ruby/core/exception/script_error_spec.rb
new file mode 100644
index 0000000000..5ca0333261
--- /dev/null
+++ b/spec/ruby/core/exception/script_error_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "ScriptError" do
+ it "is a superclass of LoadError" do
+ ScriptError.should be_ancestor_of(LoadError)
+ end
+
+ it "is a superclass of NotImplementedError" do
+ ScriptError.should be_ancestor_of(NotImplementedError)
+ end
+
+ it "is a superclass of SyntaxError" do
+ ScriptError.should be_ancestor_of(SyntaxError)
+ end
+end
diff --git a/spec/ruby/core/exception/set_backtrace_spec.rb b/spec/ruby/core/exception/set_backtrace_spec.rb
index ba2e1bf7aa..db58a193ef 100644
--- a/spec/ruby/core/exception/set_backtrace_spec.rb
+++ b/spec/ruby/core/exception/set_backtrace_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Exception#set_backtrace" do
it "accepts an Array of Strings" do
@@ -36,21 +36,21 @@ describe "Exception#set_backtrace" do
it "raises a TypeError when passed a Symbol" do
err = RuntimeError.new
- -> { err.set_backtrace :unhappy }.should raise_error(TypeError)
+ lambda { err.set_backtrace :unhappy }.should raise_error(TypeError)
end
it "raises a TypeError when the Array contains a Symbol" do
err = RuntimeError.new
- -> { err.set_backtrace ["String", :unhappy] }.should raise_error(TypeError)
+ lambda { err.set_backtrace ["String", :unhappy] }.should raise_error(TypeError)
end
it "raises a TypeError when the array contains nil" do
err = Exception.new
- -> { err.set_backtrace ["String", nil] }.should raise_error(TypeError)
+ lambda { err.set_backtrace ["String", nil] }.should raise_error(TypeError)
end
it "raises a TypeError when the argument is a nested array" do
err = Exception.new
- -> { err.set_backtrace ["String", ["String"]] }.should raise_error(TypeError)
+ lambda { err.set_backtrace ["String", ["String"]] }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/exception/signal_exception_spec.rb b/spec/ruby/core/exception/signal_exception_spec.rb
index e494e18cde..3b2d1aad61 100644
--- a/spec/ruby/core/exception/signal_exception_spec.rb
+++ b/spec/ruby/core/exception/signal_exception_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SignalException.new" do
it "takes a signal number as the first argument" do
@@ -9,7 +9,7 @@ describe "SignalException.new" do
end
it "raises an exception with an invalid signal number" do
- -> { SignalException.new(100000) }.should raise_error(ArgumentError)
+ lambda { SignalException.new(100000) }.should raise_error(ArgumentError)
end
it "takes a signal name without SIG prefix as the first argument" do
@@ -27,13 +27,7 @@ describe "SignalException.new" do
end
it "raises an exception with an invalid signal name" do
- -> { SignalException.new("NONEXISTENT") }.should raise_error(ArgumentError)
- end
-
- ruby_version_is "2.6" do
- it "raises an exception with an invalid first argument type" do
- -> { SignalException.new(Object.new) }.should raise_error(ArgumentError)
- end
+ lambda { SignalException.new("NONEXISTANT") }.should raise_error(ArgumentError)
end
it "takes a signal symbol without SIG prefix as the first argument" do
@@ -51,7 +45,7 @@ describe "SignalException.new" do
end
it "raises an exception with an invalid signal name" do
- -> { SignalException.new(:NONEXISTENT) }.should raise_error(ArgumentError)
+ lambda { SignalException.new(:NONEXISTANT) }.should raise_error(ArgumentError)
end
it "takes an optional message argument with a signal number" do
@@ -62,11 +56,11 @@ describe "SignalException.new" do
end
it "raises an exception for an optional argument with a signal name" do
- -> { SignalException.new("INT","name") }.should raise_error(ArgumentError)
+ lambda { SignalException.new("INT","name") }.should raise_error(ArgumentError)
end
end
-describe "rescuing SignalException" do
+describe "rescueing SignalException" do
it "raises a SignalException when sent a signal" do
begin
Process.kill :TERM, Process.pid
@@ -78,48 +72,3 @@ describe "rescuing SignalException" do
end
end
end
-
-describe "SignalException" do
- it "can be rescued" do
- ruby_exe(<<-RUBY)
- begin
- raise SignalException, 'SIGKILL'
- rescue SignalException
- exit(0)
- end
- exit(1)
- RUBY
-
- $?.exitstatus.should == 0
- end
-
- platform_is_not :windows do
- it "runs after at_exit" do
- output = ruby_exe(<<-RUBY)
- at_exit do
- puts "hello"
- $stdout.flush
- end
-
- raise SignalException, 'SIGKILL'
- RUBY
-
- $?.termsig.should == Signal.list.fetch("KILL")
- output.should == "hello\n"
- end
-
- it "cannot be trapped with Signal.trap" do
- ruby_exe(<<-RUBY)
- Signal.trap("PROF") {}
- raise(SignalException, "PROF")
- RUBY
-
- $?.termsig.should == Signal.list.fetch("PROF")
- end
-
- it "self-signals for USR1" do
- ruby_exe("raise(SignalException, 'USR1')")
- $?.termsig.should == Signal.list.fetch('USR1')
- end
- end
-end
diff --git a/spec/ruby/core/exception/signm_spec.rb b/spec/ruby/core/exception/signm_spec.rb
index 8e3adcddae..e205b79e19 100644
--- a/spec/ruby/core/exception/signm_spec.rb
+++ b/spec/ruby/core/exception/signm_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SignalException#signm" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/signo_spec.rb b/spec/ruby/core/exception/signo_spec.rb
index 2d04cd7805..08c85274ca 100644
--- a/spec/ruby/core/exception/signo_spec.rb
+++ b/spec/ruby/core/exception/signo_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SignalException#signo" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/source_encoding_name_spec.rb b/spec/ruby/core/exception/source_encoding_name_spec.rb
index 6f5dbd01aa..5796072121 100644
--- a/spec/ruby/core/exception/source_encoding_name_spec.rb
+++ b/spec/ruby/core/exception/source_encoding_name_spec.rb
@@ -1,23 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::UndefinedConversionError#source_encoding_name" do
- it "returns the source encoding name" do
- ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
- begin
- ec.convert("\xa0")
- rescue Encoding::UndefinedConversionError => e
- e.source_encoding_name.should == "UTF-8"
- end
- end
+ it "needs to be reviewed for spec completeness"
end
describe "Encoding::InvalidByteSequenceError#source_encoding_name" do
- it "returns the source encoding name" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- begin
- ec.convert("\xa0")
- rescue Encoding::InvalidByteSequenceError => e
- e.source_encoding_name.should == "EUC-JP"
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/source_encoding_spec.rb b/spec/ruby/core/exception/source_encoding_spec.rb
index fac38e75f4..796bec88f6 100644
--- a/spec/ruby/core/exception/source_encoding_spec.rb
+++ b/spec/ruby/core/exception/source_encoding_spec.rb
@@ -1,23 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Encoding::UndefinedConversionError#source_encoding" do
- it "returns the source encoding" do
- ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
- begin
- ec.convert("\xa0")
- rescue Encoding::UndefinedConversionError => e
- e.source_encoding.should == Encoding::UTF_8
- end
- end
+ it "needs to be reviewed for spec completeness"
end
describe "Encoding::InvalidByteSequenceError#source_encoding" do
- it "returns the source encoding" do
- ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
- begin
- ec.convert("\xa0")
- rescue Encoding::InvalidByteSequenceError => e
- e.source_encoding.should == Encoding::EUC_JP
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/standard_error_spec.rb b/spec/ruby/core/exception/standard_error_spec.rb
index 17e98ce7f0..9b3af4b322 100644
--- a/spec/ruby/core/exception/standard_error_spec.rb
+++ b/spec/ruby/core/exception/standard_error_spec.rb
@@ -1,23 +1,50 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "StandardError" do
- it "rescues StandardError" do
- begin
- raise StandardError
- rescue => exception
- exception.class.should == StandardError
- end
+ it "is a superclass of ArgumentError" do
+ StandardError.should be_ancestor_of(ArgumentError)
end
- it "rescues subclass of StandardError" do
- begin
- raise RuntimeError
- rescue => exception
- exception.class.should == RuntimeError
- end
+ it "is a superclass of IOError" do
+ StandardError.should be_ancestor_of(IOError)
end
- it "does not rescue superclass of StandardError" do
- -> { begin; raise Exception; rescue; end }.should raise_error(Exception)
+ it "is a superclass of IndexError" do
+ StandardError.should be_ancestor_of(IndexError)
+ end
+
+ it "is a superclass of LocalJumpError" do
+ StandardError.should be_ancestor_of(LocalJumpError)
+ end
+
+ it "is a superclass of NameError" do
+ StandardError.should be_ancestor_of(NameError)
+ end
+
+ it "is a superclass of RangeError" do
+ StandardError.should be_ancestor_of(RangeError)
+ end
+
+ it "is a superclass of RegexpError" do
+ StandardError.should be_ancestor_of(RegexpError)
+ end
+
+ it "is a superclass of RuntimeError" do
+ StandardError.should be_ancestor_of(RuntimeError)
+ end
+
+ it "is a superclass of SystemCallError" do
+ StandardError.should be_ancestor_of(SystemCallError.new("").class)
+ end
+ it "is a superclass of ThreadError" do
+ StandardError.should be_ancestor_of(ThreadError)
+ end
+
+ it "is a superclass of TypeError" do
+ StandardError.should be_ancestor_of(TypeError)
+ end
+
+ it "is a superclass of ZeroDivisionError" do
+ StandardError.should be_ancestor_of(ZeroDivisionError)
end
end
diff --git a/spec/ruby/core/exception/status_spec.rb b/spec/ruby/core/exception/status_spec.rb
index 1609bff3a5..e648dc0adc 100644
--- a/spec/ruby/core/exception/status_spec.rb
+++ b/spec/ruby/core/exception/status_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SystemExit#status" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/success_spec.rb b/spec/ruby/core/exception/success_spec.rb
index 82e3df92c6..d9b69b4f45 100644
--- a/spec/ruby/core/exception/success_spec.rb
+++ b/spec/ruby/core/exception/success_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SystemExit#success?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/exception/system_call_error_spec.rb b/spec/ruby/core/exception/system_call_error_spec.rb
index c510ae440f..edcc8d3734 100644
--- a/spec/ruby/core/exception/system_call_error_spec.rb
+++ b/spec/ruby/core/exception/system_call_error_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "SystemCallError" do
before :each do
@@ -20,82 +20,41 @@ describe "SystemCallError" do
end
describe "SystemCallError.new" do
- before :all do
- @example_errno = Errno::EINVAL::Errno
- @example_errno_class = Errno::EINVAL
- @last_known_errno = Errno.constants.size - 1
- @unknown_errno = Errno.constants.size
- end
-
it "requires at least one argument" do
- -> { SystemCallError.new }.should raise_error(ArgumentError)
+ lambda { SystemCallError.new }.should raise_error(ArgumentError)
end
it "accepts single Fixnum argument as errno" do
SystemCallError.new(-2**24).errno.should == -2**24
- SystemCallError.new(-1).errno.should == -1
- SystemCallError.new(0).errno.should == 0
- SystemCallError.new(@last_known_errno).errno.should == @last_known_errno
- SystemCallError.new(@unknown_errno).errno.should == @unknown_errno
+ SystemCallError.new(42).errno.should == 42
SystemCallError.new(2**24).errno.should == 2**24
end
- it "constructs a SystemCallError for an unknown error number" do
- SystemCallError.new(-2**24).should be_an_instance_of(SystemCallError)
- SystemCallError.new(-1).should be_an_instance_of(SystemCallError)
- SystemCallError.new(@unknown_errno).should be_an_instance_of(SystemCallError)
- SystemCallError.new(2**24).should be_an_instance_of(SystemCallError)
- end
-
it "constructs the appropriate Errno class" do
- e = SystemCallError.new(@example_errno)
- e.should be_kind_of(SystemCallError)
- e.should be_an_instance_of(@example_errno_class)
+ # EINVAL should be more or less mortable across the platforms,
+ # so let's use it then.
+ SystemCallError.new(22).should be_kind_of(SystemCallError)
+ SystemCallError.new(22).should be_an_instance_of(Errno::EINVAL)
+ SystemCallError.new(2**28).should be_an_instance_of(SystemCallError)
end
it "accepts an optional custom message preceding the errno" do
- exc = SystemCallError.new("custom message", @example_errno)
- exc.should be_an_instance_of(@example_errno_class)
- exc.errno.should == @example_errno
- exc.message.should == 'Invalid argument - custom message'
+ exc = SystemCallError.new("custom message", 22)
+ exc.should be_an_instance_of(Errno::EINVAL)
+ exc.errno.should == 22
+ exc.message.should == "Invalid argument - custom message"
end
it "accepts an optional third argument specifying the location" do
- exc = SystemCallError.new("custom message", @example_errno, "location")
- exc.should be_an_instance_of(@example_errno_class)
- exc.errno.should == @example_errno
- exc.message.should == 'Invalid argument @ location - custom message'
- end
-
- it "coerces location if it is not a String" do
- e = SystemCallError.new('foo', 1, :not_a_string)
- e.message.should =~ /@ not_a_string - foo/
+ exc = SystemCallError.new("custom message", 22, "location")
+ exc.should be_an_instance_of(Errno::EINVAL)
+ exc.errno.should == 22
+ exc.message.should == "Invalid argument @ location - custom message"
end
it "returns an arity of -1 for the initialize method" do
SystemCallError.instance_method(:initialize).arity.should == -1
end
-
- it "converts to Integer if errno is a Float" do
- SystemCallError.new('foo', 2.0).should == SystemCallError.new('foo', 2)
- SystemCallError.new('foo', 2.9).should == SystemCallError.new('foo', 2)
- end
-
- it "converts to Integer if errno is a Complex convertible to Integer" do
- SystemCallError.new('foo', Complex(2.9, 0)).should == SystemCallError.new('foo', 2)
- end
-
- it "raises TypeError if message is not a String" do
- -> { SystemCallError.new(:foo, 1) }.should raise_error(TypeError, /no implicit conversion of Symbol into String/)
- end
-
- it "raises TypeError if errno is not an Integer" do
- -> { SystemCallError.new('foo', 'bar') }.should raise_error(TypeError, /no implicit conversion of String into Integer/)
- end
-
- it "raises RangeError if errno is a Complex not convertible to Integer" do
- -> { SystemCallError.new('foo', Complex(2.9, 1)) }.should raise_error(RangeError, /can't convert/)
- end
end
describe "SystemCallError#errno" do
diff --git a/spec/ruby/core/exception/system_stack_error_spec.rb b/spec/ruby/core/exception/system_stack_error_spec.rb
index 0343d2da59..acd56c0a0f 100644
--- a/spec/ruby/core/exception/system_stack_error_spec.rb
+++ b/spec/ruby/core/exception/system_stack_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SystemStackError" do
it "is a subclass of Exception" do
diff --git a/spec/ruby/core/exception/to_s_spec.rb b/spec/ruby/core/exception/to_s_spec.rb
index 4c4c7ab432..83234bfe23 100644
--- a/spec/ruby/core/exception/to_s_spec.rb
+++ b/spec/ruby/core/exception/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Exception#to_s" do
it "returns the self's name if no message is set" do
@@ -19,19 +19,5 @@ describe "Exception#to_s" do
end
describe "NameError#to_s" do
- it "raises its own message for an undefined variable" do
- begin
- puts not_defined
- rescue => exception
- exception.message.should =~ /undefined local variable or method `not_defined'/
- end
- end
-
- it "raises its own message for an undefined constant" do
- begin
- puts NotDefined
- rescue => exception
- exception.message.should =~ /uninitialized constant NotDefined/
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/exception/uncaught_throw_error_spec.rb b/spec/ruby/core/exception/uncaught_throw_error_spec.rb
index 57f391d755..3ed166af5b 100644
--- a/spec/ruby/core/exception/uncaught_throw_error_spec.rb
+++ b/spec/ruby/core/exception/uncaught_throw_error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "UncaughtThrowError" do
it "is a subclass of ArgumentError" do
@@ -16,3 +16,4 @@ describe "UncaughtThrowError#tag" do
end
end
end
+
diff --git a/spec/ruby/core/false/and_spec.rb b/spec/ruby/core/false/and_spec.rb
index 0b02ae62c5..a949c02503 100644
--- a/spec/ruby/core/false/and_spec.rb
+++ b/spec/ruby/core/false/and_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FalseClass#&" do
it "returns false" do
diff --git a/spec/ruby/core/false/dup_spec.rb b/spec/ruby/core/false/dup_spec.rb
index 1a569a2f4f..b04e641a41 100644
--- a/spec/ruby/core/false/dup_spec.rb
+++ b/spec/ruby/core/false/dup_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "FalseClass#dup" do
- it "returns self" do
- false.dup.should equal(false)
+ruby_version_is '2.4' do
+ describe "FalseClass#dup" do
+ it "returns self" do
+ false.dup.should equal(false)
+ end
end
end
diff --git a/spec/ruby/core/false/falseclass_spec.rb b/spec/ruby/core/false/falseclass_spec.rb
index c018ef2421..e91682c94c 100644
--- a/spec/ruby/core/false/falseclass_spec.rb
+++ b/spec/ruby/core/false/falseclass_spec.rb
@@ -1,14 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FalseClass" do
it ".allocate raises a TypeError" do
- -> do
+ lambda do
FalseClass.allocate
end.should raise_error(TypeError)
end
it ".new is undefined" do
- -> do
+ lambda do
FalseClass.new
end.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/false/inspect_spec.rb b/spec/ruby/core/false/inspect_spec.rb
index 4cbb55d434..f3bb6645bf 100644
--- a/spec/ruby/core/false/inspect_spec.rb
+++ b/spec/ruby/core/false/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FalseClass#inspect" do
it "returns the string 'false'" do
diff --git a/spec/ruby/core/false/or_spec.rb b/spec/ruby/core/false/or_spec.rb
index f3ee1a3439..e2f4dbd90b 100644
--- a/spec/ruby/core/false/or_spec.rb
+++ b/spec/ruby/core/false/or_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FalseClass#|" do
it "returns false if other is nil or false, otherwise true" do
diff --git a/spec/ruby/core/false/to_s_spec.rb b/spec/ruby/core/false/to_s_spec.rb
index c996d87000..bb2bdb65af 100644
--- a/spec/ruby/core/false/to_s_spec.rb
+++ b/spec/ruby/core/false/to_s_spec.rb
@@ -1,17 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FalseClass#to_s" do
it "returns the string 'false'" do
false.to_s.should == "false"
end
-
- ruby_version_is "2.7" do
- it "returns a frozen string" do
- false.to_s.frozen?.should == true
- end
-
- it "always returns the same string" do
- false.to_s.should equal(false.to_s)
- end
- end
end
diff --git a/spec/ruby/core/false/xor_spec.rb b/spec/ruby/core/false/xor_spec.rb
index 1b87b9f412..3e5c452f9b 100644
--- a/spec/ruby/core/false/xor_spec.rb
+++ b/spec/ruby/core/false/xor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FalseClass#^" do
it "returns false if other is nil or false, otherwise true" do
diff --git a/spec/ruby/core/fiber/new_spec.rb b/spec/ruby/core/fiber/new_spec.rb
index b43c1386be..a3361acc65 100644
--- a/spec/ruby/core/fiber/new_spec.rb
+++ b/spec/ruby/core/fiber/new_spec.rb
@@ -1,39 +1,41 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Fiber.new" do
- it "creates a fiber from the given block" do
- fiber = Fiber.new {}
- fiber.resume
- fiber.should be_an_instance_of(Fiber)
- end
+with_feature :fiber do
+ describe "Fiber.new" do
+ it "creates a fiber from the given block" do
+ fiber = Fiber.new {}
+ fiber.resume
+ fiber.should be_an_instance_of(Fiber)
+ end
- it "creates a fiber from a subclass" do
- class MyFiber < Fiber
+ it "creates a fiber from a subclass" do
+ class MyFiber < Fiber
+ end
+ fiber = MyFiber.new {}
+ fiber.resume
+ fiber.should be_an_instance_of(MyFiber)
end
- fiber = MyFiber.new {}
- fiber.resume
- fiber.should be_an_instance_of(MyFiber)
- end
- it "raises an ArgumentError if called without a block" do
- -> { Fiber.new }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError if called without a block" do
+ lambda { Fiber.new }.should raise_error(ArgumentError)
+ end
- it "does not invoke the block" do
- invoked = false
- fiber = Fiber.new { invoked = true }
- invoked.should be_false
- fiber.resume
- end
+ it "does not invoke the block" do
+ invoked = false
+ fiber = Fiber.new { invoked = true }
+ invoked.should be_false
+ fiber.resume
+ end
- it "closes over lexical environments" do
- o = Object.new
- def o.f
- a = 1
- f = Fiber.new { a = 2 }
- f.resume
- a
+ it "closes over lexical environments" do
+ o = Object.new
+ def o.f
+ a = 1
+ f = Fiber.new { a = 2 }
+ f.resume
+ a
+ end
+ o.f.should == 2
end
- o.f.should == 2
end
end
diff --git a/spec/ruby/core/fiber/resume_spec.rb b/spec/ruby/core/fiber/resume_spec.rb
index 97495c5059..3fd3aed8fa 100644
--- a/spec/ruby/core/fiber/resume_spec.rb
+++ b/spec/ruby/core/fiber/resume_spec.rb
@@ -1,48 +1,54 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/fiber/resume'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/fiber/resume', __FILE__)
-describe "Fiber#resume" do
- it_behaves_like :fiber_resume, :resume
-end
-
-describe "Fiber#resume" do
- it "raises a FiberError if the Fiber tries to resume itself" do
- fiber = Fiber.new { fiber.resume }
- -> { fiber.resume }.should raise_error(FiberError, /double resume/)
- end
-
- it "returns control to the calling Fiber if called from one" do
- fiber1 = Fiber.new { :fiber1 }
- fiber2 = Fiber.new { fiber1.resume; :fiber2 }
- fiber2.resume.should == :fiber2
+with_feature :fiber do
+ describe "Fiber#resume" do
+ it_behaves_like :fiber_resume, :resume
end
- # Redmine #595
- it "executes the ensure clause" do
- code = <<-RUBY
- f = Fiber.new do
- begin
- Fiber.yield
- ensure
- puts "ensure executed"
+ describe "Fiber#resume" do
+ it "returns control to the calling Fiber if called from one" do
+ fiber1 = Fiber.new { :fiber1 }
+ fiber2 = Fiber.new { fiber1.resume; :fiber2 }
+ fiber2.resume.should == :fiber2
+ end
+
+ with_feature :fork do
+ # Redmine #595
+ it "executes the ensure clause" do
+ rd, wr = IO.pipe
+
+ pid = Kernel::fork do
+ rd.close
+ f = Fiber.new do
+ begin
+ Fiber.yield
+ ensure
+ wr.write "executed"
+ end
+ end
+
+ # The apparent issue is that when Fiber.yield executes, control
+ # "leaves" the "ensure block" and so the ensure clause should run. But
+ # control really does NOT leave the ensure block when Fiber.yield
+ # executes. It merely pauses there. To require ensure to run when a
+ # Fiber is suspended then makes ensure-in-a-Fiber-context different
+ # than ensure-in-a-Thread-context and this would be very confusing.
+ f.resume
+
+ # When we execute the second #resume call, the ensure block DOES exit,
+ # the ensure clause runs. This is Ruby behavior as of 2.3.1.
+ f.resume
+
+ exit 0
end
- end
-
- # The apparent issue is that when Fiber.yield executes, control
- # "leaves" the "ensure block" and so the ensure clause should run. But
- # control really does NOT leave the ensure block when Fiber.yield
- # executes. It merely pauses there. To require ensure to run when a
- # Fiber is suspended then makes ensure-in-a-Fiber-context different
- # than ensure-in-a-Thread-context and this would be very confusing.
- f.resume
- # When we execute the second #resume call, the ensure block DOES exit,
- # the ensure clause runs.
- f.resume
+ wr.close
+ Process.waitpid pid
- exit 0
- RUBY
-
- ruby_exe(code).should == "ensure executed\n"
+ rd.read.should == "executed"
+ rd.close
+ end
+ end
end
end
diff --git a/spec/ruby/core/fiber/yield_spec.rb b/spec/ruby/core/fiber/yield_spec.rb
index b010912c87..e433da0aa9 100644
--- a/spec/ruby/core/fiber/yield_spec.rb
+++ b/spec/ruby/core/fiber/yield_spec.rb
@@ -1,49 +1,51 @@
-require_relative '../../spec_helper'
-
-describe "Fiber.yield" do
- it "passes control to the Fiber's caller" do
- step = 0
- fiber = Fiber.new { step = 1; Fiber.yield; step = 2; Fiber.yield; step = 3 }
- fiber.resume
- step.should == 1
- fiber.resume
- step.should == 2
- end
+require File.expand_path('../../../spec_helper', __FILE__)
+
+with_feature :fiber do
+ describe "Fiber.yield" do
+ it "passes control to the Fiber's caller" do
+ step = 0
+ fiber = Fiber.new { step = 1; Fiber.yield; step = 2; Fiber.yield; step = 3 }
+ fiber.resume
+ step.should == 1
+ fiber.resume
+ step.should == 2
+ end
- it "returns its arguments to the caller" do
- fiber = Fiber.new { true; Fiber.yield :glark; true }
- fiber.resume.should == :glark
- fiber.resume
- end
+ it "returns its arguments to the caller" do
+ fiber = Fiber.new { true; Fiber.yield :glark; true }
+ fiber.resume.should == :glark
+ fiber.resume
+ end
- it "returns nil to the caller if given no arguments" do
- fiber = Fiber.new { true; Fiber.yield; true }
- fiber.resume.should be_nil
- fiber.resume
- end
+ it "returns nil to the caller if given no arguments" do
+ fiber = Fiber.new { true; Fiber.yield; true }
+ fiber.resume.should be_nil
+ fiber.resume
+ end
- it "returns to the Fiber the value of the #resume call that invoked it" do
- fiber = Fiber.new { Fiber.yield.should == :caller }
- fiber.resume
- fiber.resume :caller
- end
+ it "returns to the Fiber the value of the #resume call that invoked it" do
+ fiber = Fiber.new { Fiber.yield.should == :caller }
+ fiber.resume
+ fiber.resume :caller
+ end
+
+ it "does not propagate or reraise a rescued exception" do
+ fiber = Fiber.new do
+ begin
+ raise "an error in a Fiber"
+ rescue
+ Fiber.yield :first
+ end
- it "does not propagate or reraise a rescued exception" do
- fiber = Fiber.new do
- begin
- raise "an error in a Fiber"
- rescue
- Fiber.yield :first
+ :second
end
- :second
+ fiber.resume.should == :first
+ fiber.resume.should == :second
end
- fiber.resume.should == :first
- fiber.resume.should == :second
- end
-
- it "raises a FiberError if called from the root Fiber" do
- ->{ Fiber.yield }.should raise_error(FiberError)
+ it "raises a FiberError if called from the root Fiber" do
+ lambda{ Fiber.yield }.should raise_error(FiberError)
+ end
end
end
diff --git a/spec/ruby/core/file/absolute_path_spec.rb b/spec/ruby/core/file/absolute_path_spec.rb
index 52839cf1cc..b1f4f05aee 100644
--- a/spec/ruby/core/file/absolute_path_spec.rb
+++ b/spec/ruby/core/file/absolute_path_spec.rb
@@ -1,57 +1,4 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.7" do
- describe "File.absolute_path?" do
- before :each do
- @abs = File.expand_path(__FILE__)
- end
-
- it "returns true if it's an absolute pathname" do
- File.absolute_path?(@abs).should be_true
- end
-
- it "returns false if it's a relative path" do
- File.absolute_path?(File.basename(__FILE__)).should be_false
- end
-
- it "returns false if it's a tricky relative path" do
- File.absolute_path?("C:foo\\bar").should be_false
- end
-
- it "does not expand '~' to a home directory." do
- File.absolute_path?('~').should be_false
- end
-
- it "does not expand '~user' to a home directory." do
- path = File.dirname(@abs)
- Dir.chdir(path) do
- File.absolute_path?('~user').should be_false
- end
- end
-
- it "calls #to_path on its argument" do
- mock = mock_to_path(File.expand_path(__FILE__))
-
- File.absolute_path?(mock).should be_true
- end
-
- platform_is_not :windows do
- it "takes into consideration the platform's root" do
- File.absolute_path?("C:\\foo\\bar").should be_false
- File.absolute_path?("C:/foo/bar").should be_false
- File.absolute_path?("/foo/bar\\baz").should be_true
- end
- end
-
- platform_is :windows do
- it "takes into consideration the platform path separator(s)" do
- File.absolute_path?("C:\\foo\\bar").should be_true
- File.absolute_path?("C:/foo/bar").should be_true
- File.absolute_path?("/foo/bar\\baz").should be_false
- end
- end
- end
-end
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.absolute_path" do
before :each do
diff --git a/spec/ruby/core/file/atime_spec.rb b/spec/ruby/core/file/atime_spec.rb
index 02e8412722..76e7fbd62a 100644
--- a/spec/ruby/core/file/atime_spec.rb
+++ b/spec/ruby/core/file/atime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.atime" do
before :each do
@@ -15,7 +15,7 @@ describe "File.atime" do
File.atime(@file).should be_kind_of(Time)
end
- guard -> { platform_is :linux or (platform_is :windows and ruby_version_is '2.5') } do
+ platform_is :linux do
## NOTE also that some Linux systems disable atime (e.g. via mount params) for better filesystem speed.
it "returns the last access time for the named file with microseconds" do
supports_subseconds = Integer(`stat -c%x '#{__FILE__}'`[/\.(\d+)/, 1], 10)
@@ -30,7 +30,7 @@ describe "File.atime" do
end
it "raises an Errno::ENOENT exception if the file is not found" do
- -> { File.atime('a_fake_file') }.should raise_error(Errno::ENOENT)
+ lambda { File.atime('a_fake_file') }.should raise_error(Errno::ENOENT)
end
it "accepts an object that has a #to_path method" do
diff --git a/spec/ruby/core/file/basename_spec.rb b/spec/ruby/core/file/basename_spec.rb
index 6d7e432086..4cf26062d3 100644
--- a/spec/ruby/core/file/basename_spec.rb
+++ b/spec/ruby/core/file/basename_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
# TODO: Fix these
describe "File.basename" do
@@ -105,10 +105,10 @@ describe "File.basename" do
end
it "raises a TypeError if the arguments are not String types" do
- -> { File.basename(nil) }.should raise_error(TypeError)
- -> { File.basename(1) }.should raise_error(TypeError)
- -> { File.basename("bar.txt", 1) }.should raise_error(TypeError)
- -> { File.basename(true) }.should raise_error(TypeError)
+ lambda { File.basename(nil) }.should raise_error(TypeError)
+ lambda { File.basename(1) }.should raise_error(TypeError)
+ lambda { File.basename("bar.txt", 1) }.should raise_error(TypeError)
+ lambda { File.basename(true) }.should raise_error(TypeError)
end
it "accepts an object that has a #to_path method" do
@@ -116,7 +116,7 @@ describe "File.basename" do
end
it "raises an ArgumentError if passed more than two arguments" do
- -> { File.basename('bar.txt', '.txt', '.txt') }.should raise_error(ArgumentError)
+ lambda { File.basename('bar.txt', '.txt', '.txt') }.should raise_error(ArgumentError)
end
# specific to MS Windows
@@ -153,16 +153,18 @@ describe "File.basename" do
end
end
+ with_feature :encoding do
- it "returns the extension for a multibyte filename" do
- File.basename('/path/ОфиÑ.m4a').should == "ОфиÑ.m4a"
- end
+ it "returns the extension for a multibyte filename" do
+ File.basename('/path/ОфиÑ.m4a').should == "ОфиÑ.m4a"
+ end
- it "returns the basename with the same encoding as the original" do
- basename = File.basename('C:/Users/Scuby Pagrubý'.encode(Encoding::Windows_1250))
- basename.should == 'Scuby Pagrubý'.encode(Encoding::Windows_1250)
- basename.encoding.should == Encoding::Windows_1250
- end
+ it "returns the basename with the same encoding as the original" do
+ basename = File.basename('C:/Users/Scuby Pagrubý'.encode(Encoding::Windows_1250))
+ basename.should == 'Scuby Pagrubý'.encode(Encoding::Windows_1250)
+ basename.encoding.should == Encoding::Windows_1250
+ end
+ end
end
diff --git a/spec/ruby/core/file/birthtime_spec.rb b/spec/ruby/core/file/birthtime_spec.rb
index 755601df64..9720ede834 100644
--- a/spec/ruby/core/file/birthtime_spec.rb
+++ b/spec/ruby/core/file/birthtime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.birthtime" do
before :each do
@@ -20,17 +20,15 @@ describe "File.birthtime" do
end
it "raises an Errno::ENOENT exception if the file is not found" do
- -> { File.birthtime('bogus') }.should raise_error(Errno::ENOENT)
+ lambda { File.birthtime('bogus') }.should raise_error(Errno::ENOENT)
end
end
- platform_is :openbsd do
+ platform_is :linux, :openbsd do
it "raises an NotImplementedError" do
- -> { File.birthtime(@file) }.should raise_error(NotImplementedError)
+ lambda { File.birthtime(@file) }.should raise_error(NotImplementedError)
end
end
-
- # TODO: depends on Linux kernel version
end
describe "File#birthtime" do
@@ -50,11 +48,9 @@ describe "File#birthtime" do
end
end
- platform_is :openbsd do
+ platform_is :linux, :openbsd do
it "raises an NotImplementedError" do
- -> { @file.birthtime }.should raise_error(NotImplementedError)
+ lambda { @file.birthtime }.should raise_error(NotImplementedError)
end
end
-
- # TODO: depends on Linux kernel version
end
diff --git a/spec/ruby/core/file/blockdev_spec.rb b/spec/ruby/core/file/blockdev_spec.rb
index 9ba9afc251..f5e03d1ade 100644
--- a/spec/ruby/core/file/blockdev_spec.rb
+++ b/spec/ruby/core/file/blockdev_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/blockdev'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/blockdev', __FILE__)
describe "File.blockdev?" do
it_behaves_like :file_blockdev, :blockdev?, File
diff --git a/spec/ruby/core/file/chardev_spec.rb b/spec/ruby/core/file/chardev_spec.rb
index 1fc932ee4e..963823a206 100644
--- a/spec/ruby/core/file/chardev_spec.rb
+++ b/spec/ruby/core/file/chardev_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/chardev'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/chardev', __FILE__)
describe "File.chardev?" do
it_behaves_like :file_chardev, :chardev?, File
diff --git a/spec/ruby/core/file/chmod_spec.rb b/spec/ruby/core/file/chmod_spec.rb
index 5ca15c9748..8590f3008d 100644
--- a/spec/ruby/core/file/chmod_spec.rb
+++ b/spec/ruby/core/file/chmod_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File#chmod" do
before :each do
@@ -15,11 +15,38 @@ describe "File#chmod" do
@file.chmod(0755).should == 0
end
- it "raises RangeError with too large values" do
- -> { @file.chmod(2**64) }.should raise_error(RangeError)
- -> { @file.chmod(-2**63 - 1) }.should raise_error(RangeError)
+ platform_is_not :freebsd, :netbsd, :openbsd do
+ it "always succeeds with any numeric values" do
+ vals = [-2**30, -2**16, -2**8, -2, -1,
+ -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
+ vals.each { |v|
+ lambda { @file.chmod(v) }.should_not raise_error
+ }
+ end
+ end
+
+ # -256, -2 and -1 raise Errno::E079 on FreeBSD
+ # -256, -2 and -1 raise Errno::EFTYPE on NetBSD
+ platform_is :freebsd, :netbsd do
+ it "always succeeds with any numeric values" do
+ vals = [-2**30, -2**16, #-2**8, -2, -1,
+ -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
+ vals.each { |v|
+ lambda { @file.chmod(v) }.should_not raise_error
+ }
+ end
end
+ # -256, -2 and -1 raise Errno::EINVAL on OpenBSD
+ platform_is :openbsd do
+ it "always succeeds with any numeric values" do
+ vals = [#-2**30, -2**16, -2**8, -2, -1,
+ -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8]#, 2**16, 2**30
+ vals.each { |v|
+ lambda { @file.chmod(v) }.should_not raise_error
+ }
+ end
+ end
it "invokes to_int on non-integer argument" do
mode = File.stat(@filename).mode
(obj = mock('mode')).should_receive(:to_int).and_return(mode)
@@ -44,39 +71,37 @@ describe "File#chmod" do
end
platform_is_not :windows do
- as_user do
- it "with '0222' makes file writable but not readable or executable" do
- @file.chmod(0222)
- File.readable?(@filename).should == false
- File.writable?(@filename).should == true
- File.executable?(@filename).should == false
- end
-
- it "with '0444' makes file readable but not writable or executable" do
- @file.chmod(0444)
- File.readable?(@filename).should == true
- File.writable?(@filename).should == false
- File.executable?(@filename).should == false
- end
-
- it "with '0666' makes file readable and writable but not executable" do
- @file.chmod(0666)
- File.readable?(@filename).should == true
- File.writable?(@filename).should == true
- File.executable?(@filename).should == false
- end
-
- it "with '0111' makes file executable but not readable or writable" do
- @file.chmod(0111)
- File.readable?(@filename).should == false
- File.writable?(@filename).should == false
- File.executable?(@filename).should == true
- end
-
- it "modifies the permission bits of the files specified" do
- @file.chmod(0755)
- File.stat(@filename).mode.should == 33261
- end
+ it "with '0222' makes file writable but not readable or executable" do
+ @file.chmod(0222)
+ File.readable?(@filename).should == false
+ File.writable?(@filename).should == true
+ File.executable?(@filename).should == false
+ end
+
+ it "with '0444' makes file readable but not writable or executable" do
+ @file.chmod(0444)
+ File.readable?(@filename).should == true
+ File.writable?(@filename).should == false
+ File.executable?(@filename).should == false
+ end
+
+ it "with '0666' makes file readable and writable but not executable" do
+ @file.chmod(0666)
+ File.readable?(@filename).should == true
+ File.writable?(@filename).should == true
+ File.executable?(@filename).should == false
+ end
+
+ it "with '0111' makes file executable but not readable or writable" do
+ @file.chmod(0111)
+ File.readable?(@filename).should == false
+ File.writable?(@filename).should == false
+ File.executable?(@filename).should == true
+ end
+
+ it "modifies the permission bits of the files specified" do
+ @file.chmod(0755)
+ File.stat(@filename).mode.should == 33261
end
end
end
@@ -96,21 +121,54 @@ describe "File.chmod" do
@count.should == 1
end
- it "raises RangeError with too large values" do
- -> { File.chmod(2**64, @file) }.should raise_error(RangeError)
- -> { File.chmod(-2**63 - 1, @file) }.should raise_error(RangeError)
+ platform_is_not :freebsd, :netbsd, :openbsd do
+ it "always succeeds with any numeric values" do
+ vals = [-2**30, -2**16, -2**8, -2, -1,
+ -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
+ vals.each { |v|
+ lambda { File.chmod(v, @file) }.should_not raise_error
+ }
+ end
+ end
+
+ # -256, -2 and -1 raise Errno::E079 on FreeBSD
+ # -256, -2 and -1 raise Errno::EFTYPE on NetBSD
+ platform_is :freebsd, :netbsd do
+ it "always succeeds with any numeric values" do
+ vals = [-2**30, -2**16, #-2**8, -2, -1,
+ -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
+ vals.each { |v|
+ lambda { File.chmod(v, @file) }.should_not raise_error
+ }
+ end
+ end
+
+ platform_is :openbsd do
+ it "succeeds with valid values" do
+ vals = [-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8]
+ vals.each { |v|
+ lambda { File.chmod(v, @file) }.should_not raise_error
+ }
+ end
+
+ it "fails with invalid values" do
+ vals = [-2**30, -2**16, -2**8, -2, -1, 2**16, 2**30]
+ vals.each { |v|
+ lambda { File.chmod(v, @file) }.should raise_error(Errno::EINVAL)
+ }
+ end
end
it "accepts an object that has a #to_path method" do
File.chmod(0, mock_to_path(@file))
end
- it "throws a TypeError if the given path is not coercible into a string" do
- -> { File.chmod(0, []) }.should raise_error(TypeError)
+ it "throws a TypeError if the given path is not coercable into a string" do
+ lambda { File.chmod(0, []) }.should raise_error(TypeError)
end
it "raises an error for a non existent path" do
- -> {
+ lambda {
File.chmod(0644, "#{@file}.not.existing")
}.should raise_error(Errno::ENOENT)
end
@@ -146,20 +204,18 @@ describe "File.chmod" do
end
platform_is_not :windows do
- as_user do
- it "with '0222' makes file writable but not readable or executable" do
- File.chmod(0222, @file)
- File.readable?(@file).should == false
- File.writable?(@file).should == true
- File.executable?(@file).should == false
- end
-
- it "with '0444' makes file readable but not writable or executable" do
- File.chmod(0444, @file)
- File.readable?(@file).should == true
- File.writable?(@file).should == false
- File.executable?(@file).should == false
- end
+ it "with '0222' makes file writable but not readable or executable" do
+ File.chmod(0222, @file)
+ File.readable?(@file).should == false
+ File.writable?(@file).should == true
+ File.executable?(@file).should == false
+ end
+
+ it "with '0444' makes file readable but not writable or executable" do
+ File.chmod(0444, @file)
+ File.readable?(@file).should == true
+ File.writable?(@file).should == false
+ File.executable?(@file).should == false
end
it "with '0666' makes file readable and writable but not executable" do
@@ -169,13 +225,11 @@ describe "File.chmod" do
File.executable?(@file).should == false
end
- as_user do
- it "with '0111' makes file executable but not readable or writable" do
- File.chmod(0111, @file)
- File.readable?(@file).should == false
- File.writable?(@file).should == false
- File.executable?(@file).should == true
- end
+ it "with '0111' makes file executable but not readable or writable" do
+ File.chmod(0111, @file)
+ File.readable?(@file).should == false
+ File.writable?(@file).should == false
+ File.executable?(@file).should == true
end
it "modifies the permission bits of the files specified" do
diff --git a/spec/ruby/core/file/chown_spec.rb b/spec/ruby/core/file/chown_spec.rb
index 8cc8f0d04b..6266e12bfd 100644
--- a/spec/ruby/core/file/chown_spec.rb
+++ b/spec/ruby/core/file/chown_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.chown" do
before :each do
@@ -66,7 +66,7 @@ describe "File.chown" do
platform_is_not :windows do
it "raises an error for a non existent path" do
- -> {
+ lambda {
File.chown(nil, nil, "#{@fname}_not_existing")
}.should raise_error(Errno::ENOENT)
end
@@ -142,3 +142,11 @@ describe "File#chown" do
@file.chown(nil, nil).should == 0
end
end
+
+describe "File.chown" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "File#chown" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/file/constants/constants_spec.rb b/spec/ruby/core/file/constants/constants_spec.rb
index 86946822c5..3b2f67cc30 100644
--- a/spec/ruby/core/file/constants/constants_spec.rb
+++ b/spec/ruby/core/file/constants/constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
["APPEND", "CREAT", "EXCL", "FNM_CASEFOLD",
"FNM_DOTMATCH", "FNM_EXTGLOB", "FNM_NOESCAPE", "FNM_PATHNAME",
diff --git a/spec/ruby/core/file/constants_spec.rb b/spec/ruby/core/file/constants_spec.rb
index 5f058a7f40..0379149a18 100644
--- a/spec/ruby/core/file/constants_spec.rb
+++ b/spec/ruby/core/file/constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
# TODO: migrate these to constants/constants_spec.rb
diff --git a/spec/ruby/core/file/ctime_spec.rb b/spec/ruby/core/file/ctime_spec.rb
index 68a9fa43cb..c39775fcdd 100644
--- a/spec/ruby/core/file/ctime_spec.rb
+++ b/spec/ruby/core/file/ctime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.ctime" do
before :each do
@@ -14,7 +14,7 @@ describe "File.ctime" do
File.ctime(@file).should be_kind_of(Time)
end
- guard -> { platform_is :linux or (platform_is :windows and ruby_version_is '2.5') } do
+ platform_is :linux do
it "returns the change time for the named file (the time at which directory information about the file was changed, not the file itself) with microseconds." do
supports_subseconds = Integer(`stat -c%z '#{__FILE__}'`[/\.(\d+)/, 1], 10)
if supports_subseconds != 0
@@ -30,7 +30,7 @@ describe "File.ctime" do
end
it "raises an Errno::ENOENT exception if the file is not found" do
- -> { File.ctime('bogus') }.should raise_error(Errno::ENOENT)
+ lambda { File.ctime('bogus') }.should raise_error(Errno::ENOENT)
end
end
diff --git a/spec/ruby/core/file/delete_spec.rb b/spec/ruby/core/file/delete_spec.rb
index 4098499942..2e903806d7 100644
--- a/spec/ruby/core/file/delete_spec.rb
+++ b/spec/ruby/core/file/delete_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/unlink'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/unlink', __FILE__)
describe "File.delete" do
- it_behaves_like :file_unlink, :delete
+ it_behaves_like(:file_unlink, :delete)
end
diff --git a/spec/ruby/core/file/directory_spec.rb b/spec/ruby/core/file/directory_spec.rb
index 8014a7a03d..d8e8b25121 100644
--- a/spec/ruby/core/file/directory_spec.rb
+++ b/spec/ruby/core/file/directory_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/directory'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/directory', __FILE__)
describe "File.directory?" do
it_behaves_like :file_directory, :directory?, File
diff --git a/spec/ruby/core/file/dirname_spec.rb b/spec/ruby/core/file/dirname_spec.rb
index 2ef04a7b64..f56f0806df 100644
--- a/spec/ruby/core/file/dirname_spec.rb
+++ b/spec/ruby/core/file/dirname_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.dirname" do
it "returns all the components of filename except the last one" do
@@ -72,10 +72,10 @@ describe "File.dirname" do
end
it "raises a TypeError if not passed a String type" do
- -> { File.dirname(nil) }.should raise_error(TypeError)
- -> { File.dirname(0) }.should raise_error(TypeError)
- -> { File.dirname(true) }.should raise_error(TypeError)
- -> { File.dirname(false) }.should raise_error(TypeError)
+ lambda { File.dirname(nil) }.should raise_error(TypeError)
+ lambda { File.dirname(0) }.should raise_error(TypeError)
+ lambda { File.dirname(true) }.should raise_error(TypeError)
+ lambda { File.dirname(false) }.should raise_error(TypeError)
end
# Windows specific tests
diff --git a/spec/ruby/core/file/empty_spec.rb b/spec/ruby/core/file/empty_spec.rb
index 77f132303e..766aa95e46 100644
--- a/spec/ruby/core/file/empty_spec.rb
+++ b/spec/ruby/core/file/empty_spec.rb
@@ -1,13 +1,15 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/zero'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/zero', __FILE__)
describe "File.empty?" do
- it_behaves_like :file_zero, :empty?, File
- it_behaves_like :file_zero_missing, :empty?, File
+ ruby_version_is "2.4" do
+ it_behaves_like :file_zero, :empty?, File
+ it_behaves_like :file_zero_missing, :empty?, File
- platform_is :solaris do
- it "returns false for /dev/null" do
- File.empty?('/dev/null').should == true
+ platform_is :solaris do
+ it "returns false for /dev/null" do
+ File.empty?('/dev/null').should == true
+ end
end
end
end
diff --git a/spec/ruby/core/file/executable_real_spec.rb b/spec/ruby/core/file/executable_real_spec.rb
index 0cb848b201..24d6824169 100644
--- a/spec/ruby/core/file/executable_real_spec.rb
+++ b/spec/ruby/core/file/executable_real_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/executable_real'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/executable_real', __FILE__)
describe "File.executable_real?" do
it_behaves_like :file_executable_real, :executable_real?, File
diff --git a/spec/ruby/core/file/executable_spec.rb b/spec/ruby/core/file/executable_spec.rb
index 1dbb3b233d..82d6a81a0d 100644
--- a/spec/ruby/core/file/executable_spec.rb
+++ b/spec/ruby/core/file/executable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/executable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/executable', __FILE__)
describe "File.executable?" do
it_behaves_like :file_executable, :executable?, File
diff --git a/spec/ruby/core/file/exist_spec.rb b/spec/ruby/core/file/exist_spec.rb
index ddb5febcba..29a410c125 100644
--- a/spec/ruby/core/file/exist_spec.rb
+++ b/spec/ruby/core/file/exist_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/exist'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/exist', __FILE__)
describe "File.exist?" do
- it_behaves_like :file_exist, :exist?, File
+ it_behaves_like(:file_exist, :exist?, File)
end
diff --git a/spec/ruby/core/file/exists_spec.rb b/spec/ruby/core/file/exists_spec.rb
index 31d0e4dd1e..70ebd12d86 100644
--- a/spec/ruby/core/file/exists_spec.rb
+++ b/spec/ruby/core/file/exists_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/exist'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/exist', __FILE__)
describe "File.exists?" do
- it_behaves_like :file_exist, :exists?, File
+ it_behaves_like(:file_exist, :exists?, File)
end
diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb
index 88078645ab..c57f323c4c 100644
--- a/spec/ruby/core/file/expand_path_spec.rb
+++ b/spec/ruby/core/file/expand_path_spec.rb
@@ -1,8 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require 'etc'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "File.expand_path" do
before :each do
@@ -19,12 +18,14 @@ describe "File.expand_path" do
end
end
- before :each do
- @external = Encoding.default_external
- end
+ with_feature :encoding do
+ before :each do
+ @external = Encoding.default_external
+ end
- after :each do
- Encoding.default_external = @external
+ after :each do
+ Encoding.default_external = @external
+ end
end
it "converts a pathname to an absolute pathname" do
@@ -55,10 +56,39 @@ describe "File.expand_path" do
File.expand_path(".", "#{@rootdir}").should == "#{@rootdir}"
end
+ # FIXME: do not use conditionals like this around #it blocks
+ unless not home = ENV['HOME']
+ platform_is_not :windows do
+ it "converts a pathname to an absolute pathname, using ~ (home) as base" do
+ File.expand_path('~').should == home
+ File.expand_path('~', '/tmp/gumby/ddd').should == home
+ File.expand_path('~/a', '/tmp/gumby/ddd').should == File.join(home, 'a')
+ end
+
+ it "does not return a frozen string" do
+ File.expand_path('~').frozen?.should == false
+ File.expand_path('~', '/tmp/gumby/ddd').frozen?.should == false
+ File.expand_path('~/a', '/tmp/gumby/ddd').frozen?.should == false
+ end
+ end
+ platform_is :windows do
+ it "converts a pathname to an absolute pathname, using ~ (home) as base" do
+ File.expand_path('~').should == home.tr("\\", '/')
+ File.expand_path('~', '/tmp/gumby/ddd').should == home.tr("\\", '/')
+ File.expand_path('~/a', '/tmp/gumby/ddd').should == File.join(home.tr("\\", '/'), 'a')
+ end
+
+ it "does not return a frozen string" do
+ File.expand_path('~').frozen?.should == false
+ File.expand_path('~', '/tmp/gumby/ddd').frozen?.should == false
+ File.expand_path('~/a', '/tmp/gumby/ddd').frozen?.should == false
+ end
+ end
+ end
+
platform_is_not :windows do
before do
- @var_home = ENV['HOME'].chomp('/')
- @db_home = Dir.home(ENV['USER'])
+ @home = ENV['HOME'].chomp('/')
end
# FIXME: these are insane!
@@ -70,17 +100,17 @@ describe "File.expand_path" do
File.expand_path("../bin", "x/../tmp").should == File.join(@base, 'bin')
end
- it "expand_path for common unix path gives a full path" do
+ it "expand_path for commoms unix path give a full path" do
File.expand_path('/tmp/').should =='/tmp'
File.expand_path('/tmp/../../../tmp').should == '/tmp'
File.expand_path('').should == Dir.pwd
File.expand_path('./////').should == Dir.pwd
File.expand_path('.').should == Dir.pwd
File.expand_path(Dir.pwd).should == Dir.pwd
- File.expand_path('~/').should == @var_home
- File.expand_path('~/..badfilename').should == "#{@var_home}/..badfilename"
- File.expand_path('~/a','~/b').should == "#{@var_home}/a"
- File.expand_path('..').should == File.dirname(Dir.pwd)
+ File.expand_path('~/').should == @home
+ File.expand_path('~/..badfilename').should == "#{@home}/..badfilename"
+ File.expand_path('..').should == Dir.pwd.split('/')[0...-1].join("/")
+ File.expand_path('~/a','~/b').should == "#{@home}/a"
end
it "does not replace multiple '/' at the beginning of the path" do
@@ -92,15 +122,12 @@ describe "File.expand_path" do
end
it "raises an ArgumentError if the path is not valid" do
- -> { File.expand_path("~a_not_existing_user") }.should raise_error(ArgumentError)
+ lambda { File.expand_path("~a_not_existing_user") }.should raise_error(ArgumentError)
end
it "expands ~ENV['USER'] to the user's home directory" do
- File.expand_path("~#{ENV['USER']}").should == @db_home
- end
-
- it "expands ~ENV['USER']/a to a in the user's home directory" do
- File.expand_path("~#{ENV['USER']}/a").should == "#{@db_home}/a"
+ File.expand_path("~#{ENV['USER']}").should == @home
+ File.expand_path("~#{ENV['USER']}/a").should == "#{@home}/a"
end
it "does not expand ~ENV['USER'] when it's not at the start" do
@@ -108,7 +135,7 @@ describe "File.expand_path" do
end
it "expands ../foo with ~/dir as base dir to /path/to/user/home/foo" do
- File.expand_path('../foo', '~/dir').should == "#{@var_home}/foo"
+ File.expand_path('../foo', '~/dir').should == "#{@home}/foo"
end
end
@@ -117,9 +144,9 @@ describe "File.expand_path" do
end
it "raises a TypeError if not passed a String type" do
- -> { File.expand_path(1) }.should raise_error(TypeError)
- -> { File.expand_path(nil) }.should raise_error(TypeError)
- -> { File.expand_path(true) }.should raise_error(TypeError)
+ lambda { File.expand_path(1) }.should raise_error(TypeError)
+ lambda { File.expand_path(nil) }.should raise_error(TypeError)
+ lambda { File.expand_path(true) }.should raise_error(TypeError)
end
platform_is_not :windows do
@@ -134,32 +161,34 @@ describe "File.expand_path" do
end
end
- it "returns a String in the same encoding as the argument" do
- Encoding.default_external = Encoding::SHIFT_JIS
+ with_feature :encoding do
+ it "returns a String in the same encoding as the argument" do
+ Encoding.default_external = Encoding::SHIFT_JIS
- path = "./a".force_encoding Encoding::CP1251
- File.expand_path(path).encoding.should equal(Encoding::CP1251)
+ path = "./a".force_encoding Encoding::CP1251
+ File.expand_path(path).encoding.should equal(Encoding::CP1251)
- weird_path = [222, 173, 190, 175].pack('C*')
- File.expand_path(weird_path).encoding.should equal(Encoding::BINARY)
- end
+ weird_path = [222, 173, 190, 175].pack('C*')
+ File.expand_path(weird_path).encoding.should equal(Encoding::ASCII_8BIT)
+ end
- platform_is_not :windows do
- it "expands a path when the default external encoding is BINARY" do
- Encoding.default_external = Encoding::BINARY
- path_8bit = [222, 173, 190, 175].pack('C*')
- File.expand_path( path_8bit, @rootdir).should == "#{@rootdir}" + path_8bit
+ platform_is_not :windows do
+ it "expands a path when the default external encoding is ASCII-8BIT" do
+ Encoding.default_external = Encoding::ASCII_8BIT
+ path_8bit = [222, 173, 190, 175].pack('C*')
+ File.expand_path( path_8bit, @rootdir).should == "#{@rootdir}" + path_8bit
+ end
end
- end
- it "expands a path with multi-byte characters" do
- File.expand_path("Ångström").should == "#{@base}/Ångström"
- end
+ it "expands a path with multi-byte characters" do
+ File.expand_path("Ångström").should == "#{@base}/Ångström"
+ end
- platform_is_not :windows do
- it "raises an Encoding::CompatibilityError if the external encoding is not compatible" do
- Encoding.default_external = Encoding::UTF_16BE
- -> { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError)
+ platform_is_not :windows do
+ it "raises an Encoding::CompatibilityError if the external encoding is not compatible" do
+ Encoding.default_external = Encoding::UTF_16BE
+ lambda { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError)
+ end
end
end
@@ -184,32 +213,6 @@ describe "File.expand_path" do
end
platform_is_not :windows do
- describe "File.expand_path when HOME is set" do
- before :each do
- @home = ENV["HOME"]
- ENV["HOME"] = "/rubyspec_home"
- end
-
- after :each do
- ENV["HOME"] = @home
- end
-
- it "converts a pathname to an absolute pathname, using ~ (home) as base" do
- home = "/rubyspec_home"
- File.expand_path('~').should == home
- File.expand_path('~', '/tmp/gumby/ddd').should == home
- File.expand_path('~/a', '/tmp/gumby/ddd').should == File.join(home, 'a')
- end
-
- it "does not return a frozen string" do
- home = "/rubyspec_home"
- File.expand_path('~').frozen?.should == false
- File.expand_path('~', '/tmp/gumby/ddd').frozen?.should == false
- File.expand_path('~/a', '/tmp/gumby/ddd').frozen?.should == false
- end
- end
-
-
describe "File.expand_path when HOME is not set" do
before :each do
@home = ENV["HOME"]
@@ -219,47 +222,21 @@ platform_is_not :windows do
ENV["HOME"] = @home
end
- guard -> {
- # We need to check if getlogin(3) returns non-NULL,
- # as MRI only checks getlogin(3) for expanding '~' if $HOME is not set.
- user = ENV.delete("USER")
- begin
- Etc.getlogin != nil
- rescue
- false
- ensure
- ENV["USER"] = user
- end
- } do
- it "uses the user database when passed '~' if HOME is nil" do
+ ruby_version_is ''...'2.4' do
+ it "raises an ArgumentError when passed '~' if HOME is nil" do
ENV.delete "HOME"
- File.directory?(File.expand_path("~")).should == true
+ lambda { File.expand_path("~") }.should raise_error(ArgumentError)
end
- it "uses the user database when passed '~/' if HOME is nil" do
+ it "raises an ArgumentError when passed '~/' if HOME is nil" do
ENV.delete "HOME"
- File.directory?(File.expand_path("~/")).should == true
+ lambda { File.expand_path("~/") }.should raise_error(ArgumentError)
end
end
it "raises an ArgumentError when passed '~' if HOME == ''" do
ENV["HOME"] = ""
- -> { File.expand_path("~") }.should raise_error(ArgumentError)
- end
- end
-
- describe "File.expand_path with a non-absolute HOME" do
- before :each do
- @home = ENV["HOME"]
- end
-
- after :each do
- ENV["HOME"] = @home
- end
-
- it "raises an ArgumentError" do
- ENV["HOME"] = "non-absolute"
- -> { File.expand_path("~") }.should raise_error(ArgumentError, 'non-absolute home')
+ lambda { File.expand_path("~") }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/file/extname_spec.rb b/spec/ruby/core/file/extname_spec.rb
index e9b53bc24d..fedd4fc89f 100644
--- a/spec/ruby/core/file/extname_spec.rb
+++ b/spec/ruby/core/file/extname_spec.rb
@@ -1,8 +1,8 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.extname" do
- it "returns the extension (the portion of file name in path after the period)" do
+ it "returns the extension (the portion of file name in path after the period)." do
File.extname("foo.rb").should == ".rb"
File.extname("/foo/bar.rb").should == ".rb"
File.extname("/foo.rb/bar.c").should == ".c"
@@ -12,7 +12,7 @@ describe "File.extname" do
File.extname(".app.conf").should == ".conf"
end
- it "returns the extension for edge cases" do
+ it "returns the extension (the portion of file name in path after the period).(edge cases)" do
File.extname("").should == ""
File.extname(".").should == ""
File.extname("/").should == ""
@@ -20,22 +20,8 @@ describe "File.extname" do
File.extname("..").should == ""
File.extname("...").should == ""
File.extname("....").should == ""
- end
-
- describe "for a filename ending with a dot" do
- guard -> { platform_is :windows or ruby_version_is ""..."2.7" } do
- it "returns ''" do
- File.extname(".foo.").should == ""
- File.extname("foo.").should == ""
- end
- end
-
- guard -> { platform_is_not :windows and ruby_version_is "2.7" } do
- it "returns '.'" do
- File.extname(".foo.").should == "."
- File.extname("foo.").should == "."
- end
- end
+ File.extname(".foo.").should == ""
+ File.extname("foo.").should == ""
end
it "returns only the last extension of a file with several dots" do
@@ -47,20 +33,22 @@ describe "File.extname" do
end
it "raises a TypeError if not passed a String type" do
- -> { File.extname(nil) }.should raise_error(TypeError)
- -> { File.extname(0) }.should raise_error(TypeError)
- -> { File.extname(true) }.should raise_error(TypeError)
- -> { File.extname(false) }.should raise_error(TypeError)
+ lambda { File.extname(nil) }.should raise_error(TypeError)
+ lambda { File.extname(0) }.should raise_error(TypeError)
+ lambda { File.extname(true) }.should raise_error(TypeError)
+ lambda { File.extname(false) }.should raise_error(TypeError)
end
it "raises an ArgumentError if not passed one argument" do
- -> { File.extname }.should raise_error(ArgumentError)
- -> { File.extname("foo.bar", "foo.baz") }.should raise_error(ArgumentError)
+ lambda { File.extname }.should raise_error(ArgumentError)
+ lambda { File.extname("foo.bar", "foo.baz") }.should raise_error(ArgumentError)
end
+ with_feature :encoding do
- it "returns the extension for a multibyte filename" do
- File.extname('ИмÑ.m4a').should == ".m4a"
- end
+ it "returns the extension for a multibyte filename" do
+ File.extname('ИмÑ.m4a').should == ".m4a"
+ end
+ end
end
diff --git a/spec/ruby/core/file/file_spec.rb b/spec/ruby/core/file/file_spec.rb
index 8a9dfd5fe2..99eaacd086 100644
--- a/spec/ruby/core/file/file_spec.rb
+++ b/spec/ruby/core/file/file_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/file'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/file', __FILE__)
describe "File" do
it "includes Enumerable" do
diff --git a/spec/ruby/core/file/fixtures/file_types.rb b/spec/ruby/core/file/fixtures/file_types.rb
index 109bcfe42e..36a5ff1a95 100644
--- a/spec/ruby/core/file/fixtures/file_types.rb
+++ b/spec/ruby/core/file/fixtures/file_types.rb
@@ -5,11 +5,17 @@ module FileSpecs
@file = tmp("test.txt")
@dir = Dir.pwd
@fifo = tmp("test_fifo")
- @link = tmp("test_link")
platform_is_not :windows do
- @block = `find /dev /devices -type b 2>/dev/null`.split("\n").first
- @char = `{ tty || find /dev /devices -type c; } 2>/dev/null`.split("\n").last
+ @block = `find /dev /devices -type b 2> /dev/null`.split("\n").first
+ @char = `find /dev /devices -type c 2> /dev/null`.split("\n").last
+
+ %w[/dev /usr/bin /usr/local/bin].each do |dir|
+ links = `find #{dir} -type l 2> /dev/null`.split("\n")
+ next if links.empty?
+ @link = links.first
+ break
+ end
end
@configured = true
@@ -26,41 +32,33 @@ module FileSpecs
yield @dir
end
+ # TODO: need a platform-independent helper here
def self.fifo
- File.mkfifo(@fifo)
+ system "mkfifo #{@fifo} 2> /dev/null"
yield @fifo
ensure
rm_r @fifo
end
def self.block_device
- raise "Could not find a block device" unless @block
yield @block
end
def self.character_device
- raise "Could not find a character device" unless @char
yield @char
end
def self.symlink
- touch(@file)
- File.symlink(@file, @link)
yield @link
- ensure
- rm_r @file, @link
end
def self.socket
- require_relative '../../../library/socket/fixtures/classes.rb'
-
- name = SocketSpecs.socket_path
+ require 'socket'
+ name = tmp("ftype_socket.socket")
+ rm_r name
socket = UNIXServer.new name
- begin
- yield name
- ensure
- socket.close
- rm_r name
- end
+ yield name
+ socket.close
+ rm_r name
end
end
diff --git a/spec/ruby/core/file/flock_spec.rb b/spec/ruby/core/file/flock_spec.rb
index 751e99d994..e14d4252d4 100644
--- a/spec/ruby/core/file/flock_spec.rb
+++ b/spec/ruby/core/file/flock_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File#flock" do
before :each do
@@ -92,13 +92,13 @@ platform_is :solaris do
end
it "fails with EBADF acquiring exclusive lock on read-only File" do
- -> do
+ lambda do
@read_file.flock File::LOCK_EX
end.should raise_error(Errno::EBADF)
end
it "fails with EBADF acquiring shared lock on read-only File" do
- -> do
+ lambda do
@write_file.flock File::LOCK_SH
end.should raise_error(Errno::EBADF)
end
diff --git a/spec/ruby/core/file/fnmatch_spec.rb b/spec/ruby/core/file/fnmatch_spec.rb
index a1b7fa12b3..8a4caacfb8 100644
--- a/spec/ruby/core/file/fnmatch_spec.rb
+++ b/spec/ruby/core/file/fnmatch_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/fnmatch'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/fnmatch', __FILE__)
describe "File.fnmatch" do
- it_behaves_like :file_fnmatch, :fnmatch
+ it_behaves_like(:file_fnmatch, :fnmatch)
end
describe "File.fnmatch?" do
- it_behaves_like :file_fnmatch, :fnmatch?
+ it_behaves_like(:file_fnmatch, :fnmatch?)
end
diff --git a/spec/ruby/core/file/ftype_spec.rb b/spec/ruby/core/file/ftype_spec.rb
index 8ff70baa80..7c010b3e9c 100644
--- a/spec/ruby/core/file/ftype_spec.rb
+++ b/spec/ruby/core/file/ftype_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/file_types'
+require "#{File.dirname(__FILE__)}/../../spec_helper"
+require "#{File.dirname(__FILE__)}/fixtures/file_types"
describe "File.ftype" do
before :all do
@@ -7,14 +7,13 @@ describe "File.ftype" do
end
it "raises ArgumentError if not given exactly one filename" do
- -> { File.ftype }.should raise_error(ArgumentError)
- -> { File.ftype('blah', 'bleh') }.should raise_error(ArgumentError)
+ lambda { File.ftype }.should raise_error(ArgumentError)
+ lambda { File.ftype('blah', 'bleh') }.should raise_error(ArgumentError)
end
it "raises Errno::ENOENT if the file is not valid" do
- -> {
- File.ftype("/#{$$}#{Time.now.to_f}")
- }.should raise_error(Errno::ENOENT)
+ l = lambda { File.ftype("/#{$$}#{Time.now.to_f}") }
+ l.should raise_error(Errno::ENOENT)
end
it "returns a String" do
diff --git a/spec/ruby/core/file/grpowned_spec.rb b/spec/ruby/core/file/grpowned_spec.rb
index 8ddac5237c..0b5514d7ca 100644
--- a/spec/ruby/core/file/grpowned_spec.rb
+++ b/spec/ruby/core/file/grpowned_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/grpowned'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/grpowned', __FILE__)
describe "File.grpowned?" do
it_behaves_like :file_grpowned, :grpowned?, File
diff --git a/spec/ruby/core/file/identical_spec.rb b/spec/ruby/core/file/identical_spec.rb
index bbeaef24d2..303337b62d 100644
--- a/spec/ruby/core/file/identical_spec.rb
+++ b/spec/ruby/core/file/identical_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/identical'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/identical', __FILE__)
describe "File.identical?" do
it_behaves_like :file_identical, :identical?, File
diff --git a/spec/ruby/core/file/initialize_spec.rb b/spec/ruby/core/file/initialize_spec.rb
index 9a76a95260..269e13b3ca 100644
--- a/spec/ruby/core/file/initialize_spec.rb
+++ b/spec/ruby/core/file/initialize_spec.rb
@@ -1,4 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "File#initialize" do
+ it "needs to be reviewed for spec completeness"
+end
describe "File#initialize" do
after :each do
diff --git a/spec/ruby/core/file/inspect_spec.rb b/spec/ruby/core/file/inspect_spec.rb
index 148e789c62..a059fa2c48 100644
--- a/spec/ruby/core/file/inspect_spec.rb
+++ b/spec/ruby/core/file/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File#inspect" do
before :each do
diff --git a/spec/ruby/core/file/join_spec.rb b/spec/ruby/core/file/join_spec.rb
index f1eab02de0..7c5955d03b 100644
--- a/spec/ruby/core/file/join_spec.rb
+++ b/spec/ruby/core/file/join_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.join" do
# see [ruby-core:46804] for the 4 following rules
@@ -104,15 +104,15 @@ describe "File.join" do
it "raises an ArgumentError if passed a recursive array" do
a = ["a"]
a << a
- -> { File.join a }.should raise_error(ArgumentError)
+ lambda { File.join a }.should raise_error(ArgumentError)
end
it "raises a TypeError exception when args are nil" do
- -> { File.join nil }.should raise_error(TypeError)
+ lambda { File.join nil }.should raise_error(TypeError)
end
it "calls #to_str" do
- -> { File.join(mock('x')) }.should raise_error(TypeError)
+ lambda { File.join(mock('x')) }.should raise_error(TypeError)
bin = mock("bin")
bin.should_receive(:to_str).exactly(:twice).and_return("bin")
@@ -129,7 +129,7 @@ describe "File.join" do
end
it "calls #to_path" do
- -> { File.join(mock('x')) }.should raise_error(TypeError)
+ lambda { File.join(mock('x')) }.should raise_error(TypeError)
bin = mock("bin")
bin.should_receive(:to_path).exactly(:twice).and_return("bin")
diff --git a/spec/ruby/core/file/lchmod_spec.rb b/spec/ruby/core/file/lchmod_spec.rb
index 6a28bdc16d..2ce265841e 100644
--- a/spec/ruby/core/file/lchmod_spec.rb
+++ b/spec/ruby/core/file/lchmod_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.lchmod" do
- guard -> { File.respond_to?(:lchmod) } do
+ platform_is_not :linux, :windows, :openbsd, :solaris, :aix do
before :each do
@fname = tmp('file_chmod_test')
@lname = @fname + '.lnk'
@@ -30,9 +30,13 @@ describe "File.lchmod" do
end
end
- guard_not -> { File.respond_to?(:lchmod) } do
+ platform_is :linux, :openbsd, :aix do
+ it "returns false from #respond_to?" do
+ File.respond_to?(:lchmod).should be_false
+ end
+
it "raises a NotImplementedError when called" do
- -> { File.lchmod 0, "foo" }.should raise_error(NotImplementedError)
+ lambda { File.lchmod 0 }.should raise_error(NotImplementedError)
end
end
end
diff --git a/spec/ruby/core/file/lchown_spec.rb b/spec/ruby/core/file/lchown_spec.rb
index 8d95d287ba..814b0bf534 100644
--- a/spec/ruby/core/file/lchown_spec.rb
+++ b/spec/ruby/core/file/lchown_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
as_superuser do
describe "File.lchown" do
@@ -57,3 +57,7 @@ as_superuser do
end
end
end
+
+describe "File.lchown" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/file/link_spec.rb b/spec/ruby/core/file/link_spec.rb
index cc63c76aa3..69d1459672 100644
--- a/spec/ruby/core/file/link_spec.rb
+++ b/spec/ruby/core/file/link_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.link" do
before :each do
@@ -16,24 +16,24 @@ describe "File.link" do
platform_is_not :windows do
it "link a file with another" do
File.link(@file, @link).should == 0
- File.should.exist?(@link)
+ File.exist?(@link).should == true
File.identical?(@file, @link).should == true
end
it "raises an Errno::EEXIST if the target already exists" do
File.link(@file, @link)
- -> { File.link(@file, @link) }.should raise_error(Errno::EEXIST)
+ lambda { File.link(@file, @link) }.should raise_error(Errno::EEXIST)
end
it "raises an ArgumentError if not passed two arguments" do
- -> { File.link }.should raise_error(ArgumentError)
- -> { File.link(@file) }.should raise_error(ArgumentError)
- -> { File.link(@file, @link, @file) }.should raise_error(ArgumentError)
+ lambda { File.link }.should raise_error(ArgumentError)
+ lambda { File.link(@file) }.should raise_error(ArgumentError)
+ lambda { File.link(@file, @link, @file) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed String types" do
- -> { File.link(@file, nil) }.should raise_error(TypeError)
- -> { File.link(@file, 1) }.should raise_error(TypeError)
+ lambda { File.link(@file, nil) }.should raise_error(TypeError)
+ lambda { File.link(@file, 1) }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/core/file/lstat_spec.rb b/spec/ruby/core/file/lstat_spec.rb
index 918ed02163..6657bfa00e 100644
--- a/spec/ruby/core/file/lstat_spec.rb
+++ b/spec/ruby/core/file/lstat_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/stat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/stat', __FILE__)
describe "File.lstat" do
it_behaves_like :file_stat, :lstat
diff --git a/spec/ruby/core/file/lutime_spec.rb b/spec/ruby/core/file/lutime_spec.rb
deleted file mode 100644
index 7449bc4389..0000000000
--- a/spec/ruby/core/file/lutime_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.5" do
- describe "File.lutime" do
- platform_is_not :windows do
- before :each do
- @atime = Time.utc(2000)
- @mtime = Time.utc(2001)
- @file = tmp("specs_lutime_file")
- @symlink = tmp("specs_lutime_symlink")
- touch @file
- File.symlink(@file, @symlink)
- end
-
- after :each do
- rm_r @file, @symlink
- end
-
- it "sets the access and modification time for a regular file" do
- File.lutime(@atime, @mtime, @file)
- stat = File.stat(@file)
- stat.atime.should == @atime
- stat.mtime.should === @mtime
- end
-
- it "sets the access and modification time for a symlink" do
- original = File.stat(@file)
-
- File.lutime(@atime, @mtime, @symlink)
- stat = File.lstat(@symlink)
- stat.atime.should == @atime
- stat.mtime.should === @mtime
-
- file = File.stat(@file)
- file.atime.should == original.atime
- file.mtime.should == original.mtime
- end
- end
- end
-end
diff --git a/spec/ruby/core/file/mkfifo_spec.rb b/spec/ruby/core/file/mkfifo_spec.rb
index 19298c967c..ad6e804b99 100644
--- a/spec/ruby/core/file/mkfifo_spec.rb
+++ b/spec/ruby/core/file/mkfifo_spec.rb
@@ -1,51 +1,53 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "File.mkfifo" do
- platform_is_not :windows do
- before do
- @path = tmp('fifo')
- end
+ruby_version_is "2.3" do
+ describe "File.mkfifo" do
+ platform_is_not :windows do
+ before do
+ @path = tmp('fifo')
+ end
- after do
- rm_r(@path)
- end
+ after do
+ rm_r(@path)
+ end
- context "when path passed responds to :to_path" do
- it "creates a FIFO file at the path specified" do
- File.mkfifo(@path)
- File.ftype(@path).should == "fifo"
+ context "when path passed responds to :to_path" do
+ it "creates a FIFO file at the path specified" do
+ File.mkfifo(@path)
+ File.ftype(@path).should == "fifo"
+ end
end
- end
- context "when path passed is not a String value" do
- it "raises a TypeError" do
- -> { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError)
+ context "when path passed is not a String value" do
+ it "raises a TypeError" do
+ lambda { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError)
+ end
end
- end
- context "when path does not exist" do
- it "raises an Errno::ENOENT exception" do
- -> { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT)
+ context "when path does not exist" do
+ it "raises an Errno::ENOENT exception" do
+ lambda { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT)
+ end
end
- end
- it "creates a FIFO file at the passed path" do
- File.mkfifo(@path.to_s)
- File.ftype(@path).should == "fifo"
- end
+ it "creates a FIFO file at the passed path" do
+ File.mkfifo(@path.to_s)
+ File.ftype(@path).should == "fifo"
+ end
- it "creates a FIFO file with passed mode & ~umask" do
- File.mkfifo(@path, 0755)
- File.stat(@path).mode.should == 010755 & ~File.umask
- end
+ it "creates a FIFO file with passed mode & ~umask" do
+ File.mkfifo(@path, 0755)
+ File.stat(@path).mode.should == 010755 & ~File.umask
+ end
- it "creates a FIFO file with a default mode of 0666 & ~umask" do
- File.mkfifo(@path)
- File.stat(@path).mode.should == 010666 & ~File.umask
- end
+ it "creates a FIFO file with a default mode of 0666 & ~umask" do
+ File.mkfifo(@path)
+ File.stat(@path).mode.should == 010666 & ~File.umask
+ end
- it "returns 0 after creating the FIFO file" do
- File.mkfifo(@path).should == 0
+ it "returns 0 after creating the FIFO file" do
+ File.mkfifo(@path).should == 0
+ end
end
end
end
diff --git a/spec/ruby/core/file/mtime_spec.rb b/spec/ruby/core/file/mtime_spec.rb
index 1941e2ff85..56b7e4464e 100644
--- a/spec/ruby/core/file/mtime_spec.rb
+++ b/spec/ruby/core/file/mtime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.mtime" do
before :each do
@@ -12,10 +12,10 @@ describe "File.mtime" do
it "returns the modification Time of the file" do
File.mtime(@filename).should be_kind_of(Time)
- File.mtime(@filename).should be_close(@mtime, TIME_TOLERANCE)
+ File.mtime(@filename).should be_close(@mtime, 2.0)
end
- guard -> { platform_is :linux or (platform_is :windows and ruby_version_is '2.5') } do
+ platform_is :linux do
it "returns the modification Time of the file with microseconds" do
supports_subseconds = Integer(`stat -c%y '#{__FILE__}'`[/\.(\d+)/, 1], 10)
if supports_subseconds != 0
@@ -29,7 +29,7 @@ describe "File.mtime" do
end
it "raises an Errno::ENOENT exception if the file is not found" do
- -> { File.mtime('bogus') }.should raise_error(Errno::ENOENT)
+ lambda { File.mtime('bogus') }.should raise_error(Errno::ENOENT)
end
end
diff --git a/spec/ruby/core/file/new_spec.rb b/spec/ruby/core/file/new_spec.rb
index 004f78503a..3c72ac48e5 100644
--- a/spec/ruby/core/file/new_spec.rb
+++ b/spec/ruby/core/file/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/open'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/open', __FILE__)
describe "File.new" do
before :each do
@@ -17,13 +17,13 @@ describe "File.new" do
it "returns a new File with mode string" do
@fh = File.new(@file, 'w')
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "returns a new File with mode num" do
@fh = File.new(@file, @flags)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "returns a new File with modus num and permissions" do
@@ -34,21 +34,21 @@ describe "File.new" do
platform_is_not :windows do
File.stat(@file).mode.to_s(8).should == "100744"
end
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do
- # it should be possible to write to such a file via returned descriptor,
+ # it should be possible to write to such a file via returned descriptior,
# even though the file permissions are r-r-r.
rm_r @file
begin
f = File.new(@file, "w", 0444)
- -> { f.puts("test") }.should_not raise_error(IOError)
+ lambda { f.puts("test") }.should_not raise_error(IOError)
ensure
f.close
end
- File.should.exist?(@file)
+ File.exist?(@file).should == true
File.read(@file).should == "test\n"
end
@@ -75,81 +75,81 @@ describe "File.new" do
fh_copy = File.new(@fh.fileno)
fh_copy.autoclose = false
fh_copy.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "creates a new file when use File::EXCL mode" do
@fh = File.new(@file, File::EXCL)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "raises an Errorno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL" do
- -> { @fh = File.new(@file, File::CREAT|File::EXCL) }.should raise_error(Errno::EEXIST)
+ lambda { @fh = File.new(@file, File::CREAT|File::EXCL) }.should raise_error(Errno::EEXIST)
end
it "creates a new file when use File::WRONLY|File::APPEND mode" do
@fh = File.new(@file, File::WRONLY|File::APPEND)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "returns a new File when use File::APPEND mode" do
@fh = File.new(@file, File::APPEND)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "returns a new File when use File::RDONLY|File::APPEND mode" do
@fh = File.new(@file, File::RDONLY|File::APPEND)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "returns a new File when use File::RDONLY|File::WRONLY mode" do
@fh = File.new(@file, File::RDONLY|File::WRONLY)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "creates a new file when use File::WRONLY|File::TRUNC mode" do
@fh = File.new(@file, File::WRONLY|File::TRUNC)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "coerces filename using to_str" do
name = mock("file")
name.should_receive(:to_str).and_return(@file)
@fh = File.new(name, "w")
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "coerces filename using #to_path" do
name = mock("file")
name.should_receive(:to_path).and_return(@file)
@fh = File.new(name, "w")
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "raises a TypeError if the first parameter can't be coerced to a string" do
- -> { File.new(true) }.should raise_error(TypeError)
- -> { File.new(false) }.should raise_error(TypeError)
+ lambda { File.new(true) }.should raise_error(TypeError)
+ lambda { File.new(false) }.should raise_error(TypeError)
end
it "raises a TypeError if the first parameter is nil" do
- -> { File.new(nil) }.should raise_error(TypeError)
+ lambda { File.new(nil) }.should raise_error(TypeError)
end
it "raises an Errno::EBADF if the first parameter is an invalid file descriptor" do
- -> { File.new(-1) }.should raise_error(Errno::EBADF)
+ lambda { File.new(-1) }.should raise_error(Errno::EBADF)
end
platform_is_not :windows do
it "can't alter mode or permissions when opening a file" do
@fh = File.new(@file)
- -> {
+ lambda {
f = File.new(@fh.fileno, @flags)
f.autoclose = false
}.should raise_error(Errno::EINVAL)
diff --git a/spec/ruby/core/file/null_spec.rb b/spec/ruby/core/file/null_spec.rb
index 355b72b799..b9dd6b658b 100644
--- a/spec/ruby/core/file/null_spec.rb
+++ b/spec/ruby/core/file/null_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File::NULL" do
platform_is :windows do
diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb
index e3c5618795..440921a796 100644
--- a/spec/ruby/core/file/open_spec.rb
+++ b/spec/ruby/core/file/open_spec.rb
@@ -1,8 +1,8 @@
# encoding: utf-8
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'shared/open'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/open', __FILE__)
describe "File.open" do
before :all do
@@ -38,7 +38,7 @@ describe "File.open" do
end
it "propagates non-StandardErrors produced by close" do
- -> {
+ lambda {
File.open(@file, 'r') { |f| FileSpecs.make_closer f, Exception }
}.should raise_error(Exception)
@@ -46,7 +46,7 @@ describe "File.open" do
end
it "propagates StandardErrors produced by close" do
- -> {
+ lambda {
File.open(@file, 'r') { |f| FileSpecs.make_closer f, StandardError }
}.should raise_error(StandardError)
@@ -63,40 +63,40 @@ describe "File.open" do
it "opens the file (basic case)" do
@fh = File.open(@file)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens the file with unicode characters" do
@fh = File.open(@unicode_path, "w")
@fh.should be_kind_of(File)
- File.should.exist?(@unicode_path)
+ File.exist?(@unicode_path).should == true
end
it "opens a file when called with a block" do
File.open(@file) { |fh| }
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens with mode string" do
@fh = File.open(@file, 'w')
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file with mode string and block" do
File.open(@file, 'w') { |fh| }
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file with mode num" do
@fh = File.open(@file, @flags)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file with mode num and block" do
File.open(@file, 'w') { |fh| }
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file with mode and permission as nil" do
@@ -113,7 +113,7 @@ describe "File.open" do
platform_is_not :windows do
@fh.lstat.mode.to_s(8).should == "100744"
end
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
# For this test we delete the file first to reset the perms
@@ -124,11 +124,11 @@ describe "File.open" do
platform_is_not :windows do
File.stat(@file).mode.to_s(8).should == "100755"
end
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "creates the file and returns writable descriptor when called with 'w' mode and r-o permissions" do
- # it should be possible to write to such a file via returned descriptor,
+ # it should be possible to write to such a file via returned descriptior,
# even though the file permissions are r-r-r.
File.open(@file, "w", 0444) { |f| f.write("test") }
@@ -147,13 +147,11 @@ describe "File.open" do
end
platform_is_not :windows do
- as_user do
- it "creates a new write-only file when invoked with 'w' and '0222'" do
- rm_r @file
- File.open(@file, 'w', 0222) {}
- File.readable?(@file).should == false
- File.writable?(@file).should == true
- end
+ it "creates a new write-only file when invoked with 'w' and '0222'" do
+ rm_r @file
+ File.open(@file, 'w', 0222) {}
+ File.readable?(@file).should == false
+ File.writable?(@file).should == true
end
end
@@ -162,68 +160,83 @@ describe "File.open" do
fh_copy = File.open(@fh.fileno)
fh_copy.autoclose = false
fh_copy.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
+ end
+
+ it "opens a file with a file descriptor d and a block" do
+ @fh = File.open(@file)
+ @fh.should be_kind_of(File)
+
+ lambda {
+ File.open(@fh.fileno) do |fh|
+ @fd = fh.fileno
+ @fh.close
+ end
+ }.should raise_error(Errno::EBADF)
+ lambda { File.open(@fd) }.should raise_error(Errno::EBADF)
+
+ File.exist?(@file).should == true
end
it "opens a file that no exists when use File::WRONLY mode" do
- -> { File.open(@nonexistent, File::WRONLY) }.should raise_error(Errno::ENOENT)
+ lambda { File.open(@nonexistent, File::WRONLY) }.should raise_error(Errno::ENOENT)
end
it "opens a file that no exists when use File::RDONLY mode" do
- -> { File.open(@nonexistent, File::RDONLY) }.should raise_error(Errno::ENOENT)
+ lambda { File.open(@nonexistent, File::RDONLY) }.should raise_error(Errno::ENOENT)
end
it "opens a file that no exists when use 'r' mode" do
- -> { File.open(@nonexistent, 'r') }.should raise_error(Errno::ENOENT)
+ lambda { File.open(@nonexistent, 'r') }.should raise_error(Errno::ENOENT)
end
it "opens a file that no exists when use File::EXCL mode" do
- -> { File.open(@nonexistent, File::EXCL) }.should raise_error(Errno::ENOENT)
+ lambda { File.open(@nonexistent, File::EXCL) }.should raise_error(Errno::ENOENT)
end
it "opens a file that no exists when use File::NONBLOCK mode" do
- -> { File.open(@nonexistent, File::NONBLOCK) }.should raise_error(Errno::ENOENT)
+ lambda { File.open(@nonexistent, File::NONBLOCK) }.should raise_error(Errno::ENOENT)
end
platform_is_not :openbsd, :windows do
it "opens a file that no exists when use File::TRUNC mode" do
- -> { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::ENOENT)
+ lambda { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::ENOENT)
end
end
platform_is :openbsd, :windows do
it "does not open a file that does no exists when using File::TRUNC mode" do
- -> { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::EINVAL)
+ lambda { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::EINVAL)
end
end
platform_is_not :windows do
it "opens a file that no exists when use File::NOCTTY mode" do
- -> { File.open(@nonexistent, File::NOCTTY) }.should raise_error(Errno::ENOENT)
+ lambda { File.open(@nonexistent, File::NOCTTY) }.should raise_error(Errno::ENOENT)
end
end
it "opens a file that no exists when use File::CREAT mode" do
@fh = File.open(@nonexistent, File::CREAT) { |f| f }
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file that no exists when use 'a' mode" do
@fh = File.open(@nonexistent, 'a') { |f| f }
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file that no exists when use 'w' mode" do
@fh = File.open(@nonexistent, 'w') { |f| f }
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
- # Check the grants associated to the different open modes combinations.
+ # Check the grants associated to the differents open modes combinations.
it "raises an ArgumentError exception when call with an unknown mode" do
- -> { File.open(@file, "q") }.should raise_error(ArgumentError)
+ lambda { File.open(@file, "q") }.should raise_error(ArgumentError)
end
it "can read in a block when call open with RDONLY mode" do
@@ -240,13 +253,13 @@ describe "File.open" do
it "raises an IO exception when write in a block opened with RDONLY mode" do
File.open(@file, File::RDONLY) do |f|
- -> { f.puts "writing ..." }.should raise_error(IOError)
+ lambda { f.puts "writing ..." }.should raise_error(IOError)
end
end
it "raises an IO exception when write in a block opened with 'r' mode" do
File.open(@file, "r") do |f|
- -> { f.puts "writing ..." }.should raise_error(IOError)
+ lambda { f.puts "writing ..." }.should raise_error(IOError)
end
end
@@ -257,7 +270,7 @@ describe "File.open" do
end
it "can't read in a block when call open with File::WRONLY||File::RDONLY mode" do
- -> {
+ lambda {
File.open(@file, File::WRONLY|File::RDONLY ) do |f|
f.gets.should == nil
end
@@ -278,44 +291,44 @@ describe "File.open" do
it "raises an IOError when read in a block opened with WRONLY mode" do
File.open(@file, File::WRONLY) do |f|
- -> { f.gets }.should raise_error(IOError)
+ lambda { f.gets }.should raise_error(IOError)
end
end
it "raises an IOError when read in a block opened with 'w' mode" do
File.open(@file, "w") do |f|
- -> { f.gets }.should raise_error(IOError)
+ lambda { f.gets }.should raise_error(IOError)
end
end
it "raises an IOError when read in a block opened with 'a' mode" do
File.open(@file, "a") do |f|
- -> { f.gets }.should raise_error(IOError)
+ lambda { f.gets }.should raise_error(IOError)
end
end
it "raises an IOError when read in a block opened with 'a' mode" do
File.open(@file, "a") do |f|
f.puts("writing").should == nil
- -> { f.gets }.should raise_error(IOError)
+ lambda { f.gets }.should raise_error(IOError)
end
end
it "raises an IOError when read in a block opened with 'a' mode" do
File.open(@file, File::WRONLY|File::APPEND ) do |f|
- -> { f.gets }.should raise_error(IOError)
+ lambda { f.gets }.should raise_error(IOError)
end
end
it "raises an IOError when read in a block opened with File::WRONLY|File::APPEND mode" do
File.open(@file, File::WRONLY|File::APPEND ) do |f|
f.puts("writing").should == nil
- -> { f.gets }.should raise_error(IOError)
+ lambda { f.gets }.should raise_error(IOError)
end
end
it "raises an IOError when read in a block opened with File::RDONLY|File::APPEND mode" do
- -> {
+ lambda {
File.open(@file, File::RDONLY|File::APPEND ) do |f|
f.puts("writing")
end
@@ -332,7 +345,7 @@ describe "File.open" do
end
it "can't read in a block when call open with File::EXCL mode" do
- -> {
+ lambda {
File.open(@file, File::EXCL) do |f|
f.puts("writing").should == nil
end
@@ -355,7 +368,7 @@ describe "File.open" do
end
it "raises an Errorno::EEXIST if the file exists when open with File::CREAT|File::EXCL" do
- -> {
+ lambda {
File.open(@file, File::CREAT|File::EXCL) do |f|
f.puts("writing")
end
@@ -365,7 +378,7 @@ describe "File.open" do
it "creates a new file when use File::WRONLY|File::APPEND mode" do
@fh = File.open(@file, File::WRONLY|File::APPEND)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file when use File::WRONLY|File::APPEND mode" do
@@ -382,7 +395,7 @@ describe "File.open" do
end
it "raises an IOError if the file exists when open with File::RDONLY|File::APPEND" do
- -> {
+ lambda {
File.open(@file, File::RDONLY|File::APPEND) do |f|
f.puts("writing").should == nil
end
@@ -408,7 +421,7 @@ describe "File.open" do
begin
@fh = File.open(@file, File::WRONLY|File::TRUNC)
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
ensure
fh1.close
end
@@ -416,7 +429,7 @@ describe "File.open" do
platform_is_not :openbsd, :windows do
it "can't write in a block when call open with File::TRUNC mode" do
- -> {
+ lambda {
File.open(@file, File::TRUNC) do |f|
f.puts("writing")
end
@@ -424,7 +437,7 @@ describe "File.open" do
end
it "raises an Errorno::EEXIST if the file exists when open with File::RDONLY|File::TRUNC" do
- -> {
+ lambda {
File.open(@file, File::RDONLY|File::TRUNC) do |f|
f.puts("writing").should == nil
end
@@ -434,7 +447,7 @@ describe "File.open" do
platform_is :openbsd, :windows do
it "can't write in a block when call open with File::TRUNC mode" do
- -> {
+ lambda {
File.open(@file, File::TRUNC) do |f|
f.puts("writing")
end
@@ -442,7 +455,7 @@ describe "File.open" do
end
it "raises an Errorno::EEXIST if the file exists when open with File::RDONLY|File::TRUNC" do
- -> {
+ lambda {
File.open(@file, File::RDONLY|File::TRUNC) do |f|
f.puts("writing").should == nil
end
@@ -451,33 +464,29 @@ describe "File.open" do
end
platform_is_not :windows do
- as_user do
- it "raises an Errno::EACCES when opening non-permitted file" do
- @fh = File.open(@file, "w")
- @fh.chmod(000)
- -> { fh1 = File.open(@file); fh1.close }.should raise_error(Errno::EACCES)
- end
+ it "raises an Errno::EACCES when opening non-permitted file" do
+ @fh = File.open(@file, "w")
+ @fh.chmod(000)
+ lambda { fh1 = File.open(@file); fh1.close }.should raise_error(Errno::EACCES)
end
end
- as_user do
- it "raises an Errno::EACCES when opening read-only file" do
- @fh = File.open(@file, "w")
- @fh.chmod(0444)
- -> { File.open(@file, "w") }.should raise_error(Errno::EACCES)
- end
+ it "raises an Errno::EACCES when opening read-only file" do
+ @fh = File.open(@file, "w")
+ @fh.chmod(0444)
+ lambda { File.open(@file, "w") }.should raise_error(Errno::EACCES)
end
it "opens a file for binary read" do
@fh = File.open(@file, "rb")
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file for binary write" do
@fh = File.open(@file, "wb")
@fh.should be_kind_of(File)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "opens a file for read-write and truncate the file" do
@@ -509,52 +518,54 @@ describe "File.open" do
File.size(@file).should == 0
end
- platform_is :linux do
- guard -> { defined?(File::TMPFILE) } do
- it "creates an unnamed temporary file with File::TMPFILE" do
- dir = tmp("tmpfilespec")
- mkdir_p dir
- begin
- Dir["#{dir}/*"].should == []
- File.open(dir, "r+", flags: File::TMPFILE) do |io|
- io.write("ruby")
- io.flush
- io.rewind
- io.read.should == "ruby"
+ ruby_version_is "2.3" do
+ platform_is :linux do
+ if defined?(File::TMPFILE)
+ it "creates an unnamed temporary file with File::TMPFILE" do
+ dir = tmp("tmpfilespec")
+ mkdir_p dir
+ begin
Dir["#{dir}/*"].should == []
+ File.open(dir, "r+", flags: File::TMPFILE) do |io|
+ io.write("ruby")
+ io.flush
+ io.rewind
+ io.read.should == "ruby"
+ Dir["#{dir}/*"].should == []
+ end
+ rescue Errno::EOPNOTSUPP, Errno::EINVAL
+ # EOPNOTSUPP: no support from the filesystem
+ # EINVAL: presumably bug in glibc
+ 1.should == 1
+ ensure
+ rm_r dir
end
- rescue Errno::EOPNOTSUPP
- skip "no support from the filesystem"
- rescue Errno::EINVAL, Errno::EISDIR
- skip "presumably bug in glibc"
- ensure
- rm_r dir
end
end
end
end
it "raises a TypeError if passed a filename that is not a String or Integer type" do
- -> { File.open(true) }.should raise_error(TypeError)
- -> { File.open(false) }.should raise_error(TypeError)
- -> { File.open(nil) }.should raise_error(TypeError)
+ lambda { File.open(true) }.should raise_error(TypeError)
+ lambda { File.open(false) }.should raise_error(TypeError)
+ lambda { File.open(nil) }.should raise_error(TypeError)
end
it "raises a SystemCallError if passed an invalid Integer type" do
- -> { File.open(-1) }.should raise_error(SystemCallError)
+ lambda { File.open(-1) }.should raise_error(SystemCallError)
end
it "raises an ArgumentError if passed the wrong number of arguments" do
- -> { File.open(@file, File::CREAT, 0755, 'test') }.should raise_error(ArgumentError)
+ lambda { File.open(@file, File::CREAT, 0755, 'test') }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if passed an invalid string for mode" do
- -> { File.open(@file, 'fake') }.should raise_error(ArgumentError)
+ lambda { File.open(@file, 'fake') }.should raise_error(ArgumentError)
end
- it "defaults external_encoding to BINARY for binary modes" do
- File.open(@file, 'rb') {|f| f.external_encoding.should == Encoding::BINARY}
- File.open(@file, 'wb+') {|f| f.external_encoding.should == Encoding::BINARY}
+ it "defaults external_encoding to ASCII-8BIT for binary modes" do
+ File.open(@file, 'rb') {|f| f.external_encoding.should == Encoding::ASCII_8BIT}
+ File.open(@file, 'wb+') {|f| f.external_encoding.should == Encoding::ASCII_8BIT}
end
it "uses the second argument as an options Hash" do
@@ -566,30 +577,32 @@ describe "File.open" do
options = mock("file open options")
options.should_receive(:to_hash).and_return({ mode: "r" })
- @fh = File.open(@file, **options)
+ @fh = File.open(@file, options)
end
- it "accepts extra flags as a keyword argument and combine with a string mode" do
- -> {
- File.open(@file, "w", flags: File::EXCL) { }
- }.should raise_error(Errno::EEXIST)
+ ruby_version_is "2.3" do
+ it "accepts extra flags as a keyword argument and combine with a string mode" do
+ lambda {
+ File.open(@file, "w", flags: File::EXCL) { }
+ }.should raise_error(Errno::EEXIST)
- -> {
- File.open(@file, mode: "w", flags: File::EXCL) { }
- }.should raise_error(Errno::EEXIST)
- end
+ lambda {
+ File.open(@file, mode: "w", flags: File::EXCL) { }
+ }.should raise_error(Errno::EEXIST)
+ end
- it "accepts extra flags as a keyword argument and combine with an integer mode" do
- -> {
- File.open(@file, File::WRONLY | File::CREAT, flags: File::EXCL) { }
- }.should raise_error(Errno::EEXIST)
+ it "accepts extra flags as a keyword argument and combine with an integer mode" do
+ lambda {
+ File.open(@file, File::WRONLY | File::CREAT, flags: File::EXCL) { }
+ }.should raise_error(Errno::EEXIST)
+ end
end
platform_is_not :windows do
describe "on a FIFO" do
before :each do
@fifo = tmp("File_open_fifo")
- File.mkfifo(@fifo)
+ system "mkfifo #{@fifo}"
end
after :each do
@@ -623,48 +636,13 @@ describe "File.open" do
end
end
- ruby_version_is "2.5" do
- it "raises ArgumentError if mixing :newline and binary mode" do
- -> {
- File.open(@file, "rb", newline: :universal) {}
- }.should raise_error(ArgumentError, "newline decorator with binary mode")
- end
- end
-
- ruby_version_is "2.6" do
- context "'x' flag" do
- before :each do
- @xfile = tmp("x-flag")
- rm_r @xfile
- end
-
- after :each do
- rm_r @xfile
- end
-
- it "does nothing if the file doesn't exist" do
- File.open(@xfile, "wx") { |f| f.write("content") }
- File.read(@xfile).should == "content"
- end
-
- it "throws a Errno::EEXIST error if the file exists" do
- touch @xfile
- -> { File.open(@xfile, "wx") }.should raise_error(Errno::EEXIST)
- end
-
- it "can't be used with 'r' and 'a' flags" do
- -> { File.open(@xfile, "rx") }.should raise_error(ArgumentError, 'invalid access mode rx')
- -> { File.open(@xfile, "ax") }.should raise_error(ArgumentError, 'invalid access mode ax')
- end
- end
- end
end
describe "File.open when passed a file descriptor" do
before do
@content = "File#open when passed a file descriptor"
@name = tmp("file_open_with_fd.txt")
- @fd = new_fd @name, "w:utf-8"
+ @fd = new_fd @name, fmode("w:utf-8")
@file = nil
end
diff --git a/spec/ruby/core/file/owned_spec.rb b/spec/ruby/core/file/owned_spec.rb
index 06d6796da9..d19e9cb278 100644
--- a/spec/ruby/core/file/owned_spec.rb
+++ b/spec/ruby/core/file/owned_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/owned'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/owned', __FILE__)
describe "File.owned?" do
it_behaves_like :file_owned, :owned?, File
@@ -24,11 +24,9 @@ describe "File.owned?" do
end
platform_is_not :windows do
- as_user do
- it "returns false when the file is not owned by the user" do
- system_file = '/etc/passwd'
- File.owned?(system_file).should == false
- end
+ it "returns false when the file is not owned by the user" do
+ system_file = '/etc/passwd'
+ File.owned?(system_file).should == false
end
end
diff --git a/spec/ruby/core/file/path_spec.rb b/spec/ruby/core/file/path_spec.rb
index dfa0c4ec02..5004e128cd 100644
--- a/spec/ruby/core/file/path_spec.rb
+++ b/spec/ruby/core/file/path_spec.rb
@@ -1,11 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/path'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File#path" do
- it_behaves_like :file_path, :path
-end
-
-describe "File.path" do
before :each do
@name = tmp("file_path")
end
@@ -14,27 +9,21 @@ describe "File.path" do
rm_r @name
end
- it "returns the string argument without any change" do
- File.path("abc").should == "abc"
- File.path("./abc").should == "./abc"
- File.path("../abc").should == "../abc"
- File.path("/./a/../bc").should == "/./a/../bc"
+ it "returns the pathname used to create file as a string" do
+ File.open(@name,'w') { |file| file.path.should == @name }
end
+end
- it "returns path for File argument" do
- File.open(@name, "w") do |f|
- File.path(f).should == @name
- end
+describe "File.path" do
+ before :each do
+ @name = tmp("file_path")
end
- it "returns path for Pathname argument" do
- require "pathname"
- File.path(Pathname.new(@name)).should == @name
+ after :each do
+ rm_r @name
end
- it "calls #to_path for non-string argument and returns result" do
- path = mock("path")
- path.should_receive(:to_path).and_return("abc")
- File.path(path).should == "abc"
+ it "returns the full path for the given file" do
+ File.path(@name).should == @name
end
end
diff --git a/spec/ruby/core/file/pipe_spec.rb b/spec/ruby/core/file/pipe_spec.rb
index 01d72dbe85..ca7392b8ee 100644
--- a/spec/ruby/core/file/pipe_spec.rb
+++ b/spec/ruby/core/file/pipe_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/pipe'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/pipe', __FILE__)
describe "File.pipe?" do
it_behaves_like :file_pipe, :pipe?, File
@@ -22,7 +22,7 @@ describe "File.pipe?" do
platform_is_not :windows do
it "returns true if the file is a pipe" do
filename = tmp("i_am_a_pipe")
- File.mkfifo(filename)
+ system "mkfifo #{filename}"
File.pipe?(filename).should == true
diff --git a/spec/ruby/core/file/printf_spec.rb b/spec/ruby/core/file/printf_spec.rb
index 2530419fc7..8423c010ab 100644
--- a/spec/ruby/core/file/printf_spec.rb
+++ b/spec/ruby/core/file/printf_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative '../kernel/shared/sprintf'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../kernel/shared/sprintf', __FILE__)
describe "File#printf" do
- it_behaves_like :kernel_sprintf, -> format, *args {
+ it_behaves_like :kernel_sprintf, -> (format, *args) {
begin
@filename = tmp("printf.txt")
diff --git a/spec/ruby/core/file/read_spec.rb b/spec/ruby/core/file/read_spec.rb
index 67a3325cbd..fdbbf58a1c 100644
--- a/spec/ruby/core/file/read_spec.rb
+++ b/spec/ruby/core/file/read_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/read'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/read', __FILE__)
describe "File.read" do
it_behaves_like :file_read_directory, :read, File
diff --git a/spec/ruby/core/file/readable_real_spec.rb b/spec/ruby/core/file/readable_real_spec.rb
index 524466cd96..5fca968611 100644
--- a/spec/ruby/core/file/readable_real_spec.rb
+++ b/spec/ruby/core/file/readable_real_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/readable_real'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/readable_real', __FILE__)
describe "File.readable_real?" do
it_behaves_like :file_readable_real, :readable_real?, File
diff --git a/spec/ruby/core/file/readable_spec.rb b/spec/ruby/core/file/readable_spec.rb
index ed75a23f39..3307e5e30f 100644
--- a/spec/ruby/core/file/readable_spec.rb
+++ b/spec/ruby/core/file/readable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/readable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/readable', __FILE__)
describe "File.readable?" do
it_behaves_like :file_readable, :readable?, File
diff --git a/spec/ruby/core/file/readlink_spec.rb b/spec/ruby/core/file/readlink_spec.rb
index 20741ba121..b529cd1355 100644
--- a/spec/ruby/core/file/readlink_spec.rb
+++ b/spec/ruby/core/file/readlink_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.readlink" do
# symlink/readlink are not supported on Windows
@@ -26,12 +26,12 @@ describe "File.readlink" do
it "raises an Errno::ENOENT if there is no such file" do
# TODO: missing_file
- -> { File.readlink("/this/surely/does/not/exist") }.should raise_error(Errno::ENOENT)
+ lambda { File.readlink("/this/surely/doesnt/exist") }.should raise_error(Errno::ENOENT)
end
it "raises an Errno::EINVAL if called with a normal file" do
touch @file
- -> { File.readlink(@file) }.should raise_error(Errno::EINVAL)
+ lambda { File.readlink(@file) }.should raise_error(Errno::EINVAL)
end
end
diff --git a/spec/ruby/core/file/realdirpath_spec.rb b/spec/ruby/core/file/realdirpath_spec.rb
index 74053afce3..06900ad461 100644
--- a/spec/ruby/core/file/realdirpath_spec.rb
+++ b/spec/ruby/core/file/realdirpath_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
describe "File.realdirpath" do
@@ -61,7 +61,7 @@ platform_is_not :windows do
it "raises an Errno::ELOOP if the symlink points to itself" do
File.unlink @link
File.symlink(@link, @link)
- -> { File.realdirpath(@link) }.should raise_error(Errno::ELOOP)
+ lambda { File.realdirpath(@link) }.should raise_error(Errno::ELOOP)
end
it "returns the real (absolute) pathname if the file is absent" do
@@ -69,7 +69,7 @@ platform_is_not :windows do
end
it "raises Errno::ENOENT if the directory is absent" do
- -> { File.realdirpath(@fake_file_in_fake_dir) }.should raise_error(Errno::ENOENT)
+ lambda { File.realdirpath(@fake_file_in_fake_dir) }.should raise_error(Errno::ENOENT)
end
it "returns the real (absolute) pathname if the symlink points to an absent file" do
@@ -77,7 +77,7 @@ platform_is_not :windows do
end
it "raises Errno::ENOENT if the symlink points to an absent directory" do
- -> { File.realdirpath(@fake_link_to_fake_dir) }.should raise_error(Errno::ENOENT)
+ lambda { File.realdirpath(@fake_link_to_fake_dir) }.should raise_error(Errno::ENOENT)
end
end
end
diff --git a/spec/ruby/core/file/realpath_spec.rb b/spec/ruby/core/file/realpath_spec.rb
index 0c5d19287a..49aed7b88c 100644
--- a/spec/ruby/core/file/realpath_spec.rb
+++ b/spec/ruby/core/file/realpath_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
describe "File.realpath" do
@@ -57,15 +57,15 @@ platform_is_not :windows do
it "raises an Errno::ELOOP if the symlink points to itself" do
File.unlink @link
File.symlink(@link, @link)
- -> { File.realpath(@link) }.should raise_error(Errno::ELOOP)
+ lambda { File.realpath(@link) }.should raise_error(Errno::ELOOP)
end
it "raises Errno::ENOENT if the file is absent" do
- -> { File.realpath(@fake_file) }.should raise_error(Errno::ENOENT)
+ lambda { File.realpath(@fake_file) }.should raise_error(Errno::ENOENT)
end
it "raises Errno::ENOENT if the symlink points to an absent file" do
- -> { File.realpath(@fake_link) }.should raise_error(Errno::ENOENT)
+ lambda { File.realpath(@fake_link) }.should raise_error(Errno::ENOENT)
end
end
end
diff --git a/spec/ruby/core/file/rename_spec.rb b/spec/ruby/core/file/rename_spec.rb
index f2c18d4905..a62ba809bd 100644
--- a/spec/ruby/core/file/rename_spec.rb
+++ b/spec/ruby/core/file/rename_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.rename" do
before :each do
@@ -14,24 +14,24 @@ describe "File.rename" do
end
it "renames a file" do
- File.should.exist?(@old)
- File.should_not.exist?(@new)
+ File.exist?(@old).should == true
+ File.exist?(@new).should == false
File.rename(@old, @new)
- File.should_not.exist?(@old)
- File.should.exist?(@new)
+ File.exist?(@old).should == false
+ File.exist?(@new).should == true
end
it "raises an Errno::ENOENT if the source does not exist" do
rm_r @old
- -> { File.rename(@old, @new) }.should raise_error(Errno::ENOENT)
+ lambda { File.rename(@old, @new) }.should raise_error(Errno::ENOENT)
end
it "raises an ArgumentError if not passed two arguments" do
- -> { File.rename }.should raise_error(ArgumentError)
- -> { File.rename(@file) }.should raise_error(ArgumentError)
+ lambda { File.rename }.should raise_error(ArgumentError)
+ lambda { File.rename(@file) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed String types" do
- -> { File.rename(1, 2) }.should raise_error(TypeError)
+ lambda { File.rename(1, 2) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/file/reopen_spec.rb b/spec/ruby/core/file/reopen_spec.rb
index 858d424c67..2493829740 100644
--- a/spec/ruby/core/file/reopen_spec.rb
+++ b/spec/ruby/core/file/reopen_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File#reopen" do
before :each do
@@ -25,7 +25,7 @@ describe "File#reopen" do
@file.read.should == @content_b
end
- it "calls #to_path to convert an Object" do
+ it "calls #to_path to convern an Object" do
@file = File.new(@name_a).reopen(mock_to_path(@name_b), "r")
@file.read.should == @content_b
end
diff --git a/spec/ruby/core/file/setgid_spec.rb b/spec/ruby/core/file/setgid_spec.rb
index f5df5390f5..dc63329cc3 100644
--- a/spec/ruby/core/file/setgid_spec.rb
+++ b/spec/ruby/core/file/setgid_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/setgid'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/setgid', __FILE__)
describe "File.setgid?" do
it_behaves_like :file_setgid, :setgid?, File
diff --git a/spec/ruby/core/file/setuid_spec.rb b/spec/ruby/core/file/setuid_spec.rb
index 281ef01ab9..dcd1d3aed1 100644
--- a/spec/ruby/core/file/setuid_spec.rb
+++ b/spec/ruby/core/file/setuid_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/setuid'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/setuid', __FILE__)
describe "File.setuid?" do
it_behaves_like :file_setuid, :setuid?, File
diff --git a/spec/ruby/core/file/shared/fnmatch.rb b/spec/ruby/core/file/shared/fnmatch.rb
index a8488fd30a..9b423ae47e 100644
--- a/spec/ruby/core/file/shared/fnmatch.rb
+++ b/spec/ruby/core/file/shared/fnmatch.rb
@@ -87,7 +87,7 @@ describe :file_fnmatch, shared: true do
File.send(@method, '[a-z]', 'D', File::FNM_CASEFOLD).should == true
end
- it "does not match characters outside of the range of the bracket expression" do
+ it "does not match characters outside of the range of the bracket expresion" do
File.send(@method, 'ca[x-z]', 'cat').should == false
File.send(@method, '/ca[s][s-t]/rul[a-b]/[z]he/[x-Z]orld', '/cats/rule/the/World').should == false
end
@@ -218,21 +218,21 @@ describe :file_fnmatch, shared: true do
end
it "raises a TypeError if the first and second arguments are not string-like" do
- -> { File.send(@method, nil, nil, 0, 0) }.should raise_error(ArgumentError)
- -> { File.send(@method, 1, 'some/thing') }.should raise_error(TypeError)
- -> { File.send(@method, 'some/thing', 1) }.should raise_error(TypeError)
- -> { File.send(@method, 1, 1) }.should raise_error(TypeError)
+ lambda { File.send(@method, nil, nil, 0, 0) }.should raise_error(ArgumentError)
+ lambda { File.send(@method, 1, 'some/thing') }.should raise_error(TypeError)
+ lambda { File.send(@method, 'some/thing', 1) }.should raise_error(TypeError)
+ lambda { File.send(@method, 1, 1) }.should raise_error(TypeError)
end
it "raises a TypeError if the third argument is not an Integer" do
- -> { File.send(@method, "*/place", "path/to/file", "flags") }.should raise_error(TypeError)
- -> { File.send(@method, "*/place", "path/to/file", nil) }.should raise_error(TypeError)
+ lambda { File.send(@method, "*/place", "path/to/file", "flags") }.should raise_error(TypeError)
+ lambda { File.send(@method, "*/place", "path/to/file", nil) }.should raise_error(TypeError)
end
it "does not raise a TypeError if the third argument can be coerced to an Integer" do
flags = mock("flags")
flags.should_receive(:to_int).and_return(10)
- -> { File.send(@method, "*/place", "path/to/file", flags) }.should_not raise_error
+ lambda { File.send(@method, "*/place", "path/to/file", flags) }.should_not raise_error
end
it "matches multibyte characters" do
diff --git a/spec/ruby/core/file/shared/open.rb b/spec/ruby/core/file/shared/open.rb
index 677a82a351..0ca1bc74db 100644
--- a/spec/ruby/core/file/shared/open.rb
+++ b/spec/ruby/core/file/shared/open.rb
@@ -1,4 +1,4 @@
-require_relative '../../dir/fixtures/common'
+require File.expand_path('../../../dir/fixtures/common', __FILE__)
describe :open_directory, shared: true do
it "opens directories" do
diff --git a/spec/ruby/core/file/shared/path.rb b/spec/ruby/core/file/shared/path.rb
deleted file mode 100644
index cfd119f799..0000000000
--- a/spec/ruby/core/file/shared/path.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-describe :file_path, shared: true do
- before :each do
- @name = "file_to_path"
- @path = tmp(@name)
- touch @path
- end
-
- after :each do
- @file.close if @file and !@file.closed?
- rm_r @path
- end
-
- it "returns a String" do
- @file = File.new @path
- @file.send(@method).should be_an_instance_of(String)
- end
-
- it "calls to_str on argument and returns exact value" do
- path = mock('path')
- path.should_receive(:to_str).and_return(@path)
- @file = File.new path
- @file.send(@method).should == @path
- end
-
- it "does not normalise the path it returns" do
- Dir.chdir(tmp("")) do
- unorm = "./#{@name}"
- @file = File.new unorm
- @file.send(@method).should == unorm
- end
- end
-
- it "does not canonicalize the path it returns" do
- dir = File.basename tmp("")
- path = "#{tmp("")}../#{dir}/#{@name}"
- @file = File.new path
- @file.send(@method).should == path
- end
-
- it "does not absolute-ise the path it returns" do
- Dir.chdir(tmp("")) do
- @file = File.new @name
- @file.send(@method).should == @name
- end
- end
-
- it "preserves the encoding of the path" do
- path = @path.force_encoding("euc-jp")
- @file = File.new path
- @file.send(@method).encoding.should == Encoding.find("euc-jp")
- end
-
- ruby_version_is "2.5" do
- platform_is :linux do
- guard -> { defined?(File::TMPFILE) } do
- before :each do
- @dir = tmp("tmpfilespec")
- mkdir_p @dir
- end
-
- after :each do
- rm_r @dir
- end
-
- it "raises IOError if file was opened with File::TMPFILE" do
- begin
- File.open(@dir, File::RDWR | File::TMPFILE) do |f|
- -> { f.send(@method) }.should raise_error(IOError)
- end
- rescue Errno::EOPNOTSUPP, Errno::EINVAL, Errno::EISDIR
- skip "no support from the filesystem"
- end
- end
- end
- end
- end
-end
diff --git a/spec/ruby/core/file/shared/read.rb b/spec/ruby/core/file/shared/read.rb
index a2d479966d..e37523c244 100644
--- a/spec/ruby/core/file/shared/read.rb
+++ b/spec/ruby/core/file/shared/read.rb
@@ -1,15 +1,15 @@
-require_relative '../../dir/fixtures/common'
+require File.expand_path('../../../dir/fixtures/common', __FILE__)
describe :file_read_directory, shared: true do
platform_is :darwin, :linux, :openbsd, :windows do
it "raises an Errno::EISDIR when passed a path that is a directory" do
- -> { @object.send(@method, ".") }.should raise_error(Errno::EISDIR)
+ lambda { @object.send(@method, ".") }.should raise_error(Errno::EISDIR)
end
end
platform_is :freebsd, :netbsd do
it "does not raises any exception when passed a path that is a directory" do
- -> { @object.send(@method, ".") }.should_not raise_error
+ lambda { @object.send(@method, ".") }.should_not raise_error
end
end
end
diff --git a/spec/ruby/core/file/shared/stat.rb b/spec/ruby/core/file/shared/stat.rb
index fdaf97ea61..aac710dd2f 100644
--- a/spec/ruby/core/file/shared/stat.rb
+++ b/spec/ruby/core/file/shared/stat.rb
@@ -25,7 +25,7 @@ describe :file_stat, shared: true do
end
it "raises an Errno::ENOENT if the file does not exist" do
- -> {
+ lambda {
File.send(@method, "fake_file")
}.should raise_error(Errno::ENOENT)
end
diff --git a/spec/ruby/core/file/shared/unlink.rb b/spec/ruby/core/file/shared/unlink.rb
index e339e93271..7b0413b76b 100644
--- a/spec/ruby/core/file/shared/unlink.rb
+++ b/spec/ruby/core/file/shared/unlink.rb
@@ -21,21 +21,21 @@ describe :file_unlink, shared: true do
it "deletes a single file" do
File.send(@method, @file1).should == 1
- File.should_not.exist?(@file1)
+ File.exist?(@file1).should == false
end
it "deletes multiple files" do
File.send(@method, @file1, @file2).should == 2
- File.should_not.exist?(@file1)
- File.should_not.exist?(@file2)
+ File.exist?(@file1).should == false
+ File.exist?(@file2).should == false
end
it "raises a TypeError if not passed a String type" do
- -> { File.send(@method, 1) }.should raise_error(TypeError)
+ lambda { File.send(@method, 1) }.should raise_error(TypeError)
end
it "raises an Errno::ENOENT when the given file doesn't exist" do
- -> { File.send(@method, 'bogus') }.should raise_error(Errno::ENOENT)
+ lambda { File.send(@method, 'bogus') }.should raise_error(Errno::ENOENT)
end
it "coerces a given parameter into a string if possible" do
@@ -48,14 +48,16 @@ describe :file_unlink, shared: true do
File.send(@method, mock_to_path(@file1)).should == 1
end
- platform_is :windows do
- it "allows deleting an open file with File::SHARE_DELETE" do
- path = tmp("share_delete.txt")
- File.open(path, mode: File::CREAT | File::WRONLY | File::BINARY | File::SHARE_DELETE) do |f|
- File.should.exist?(path)
- File.send(@method, path)
+ ruby_version_is "2.3" do
+ platform_is :windows do
+ it "allows deleting an open file with File::SHARE_DELETE" do
+ path = tmp("share_delete.txt")
+ File.open(path, mode: File::CREAT | File::WRONLY | File::BINARY | File::SHARE_DELETE) do |f|
+ File.exist?(path).should be_true
+ File.send(@method, path)
+ end
+ File.exist?(path).should be_false
end
- File.should_not.exist?(path)
end
end
end
diff --git a/spec/ruby/core/file/size_spec.rb b/spec/ruby/core/file/size_spec.rb
index a2bf408da1..73c8192b18 100644
--- a/spec/ruby/core/file/size_spec.rb
+++ b/spec/ruby/core/file/size_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/size'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/size', __FILE__)
describe "File.size?" do
it_behaves_like :file_size, :size?, File
@@ -81,7 +81,7 @@ describe "File#size" do
it "raises an IOError on a closed file" do
@file.close
- -> { @file.size }.should raise_error(IOError)
+ lambda { @file.size }.should raise_error(IOError)
end
platform_is_not :windows do
diff --git a/spec/ruby/core/file/socket_spec.rb b/spec/ruby/core/file/socket_spec.rb
index 5d12e21f55..80f33f4b19 100644
--- a/spec/ruby/core/file/socket_spec.rb
+++ b/spec/ruby/core/file/socket_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/socket'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/socket', __FILE__)
require 'socket'
describe "File.socket?" do
diff --git a/spec/ruby/core/file/split_spec.rb b/spec/ruby/core/file/split_spec.rb
index 7b958621b9..2479d4b949 100644
--- a/spec/ruby/core/file/split_spec.rb
+++ b/spec/ruby/core/file/split_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.split" do
before :each do
@@ -44,18 +44,17 @@ describe "File.split" do
end
it "raises an ArgumentError when not passed a single argument" do
- -> { File.split }.should raise_error(ArgumentError)
- -> { File.split('string', 'another string') }.should raise_error(ArgumentError)
+ lambda { File.split }.should raise_error(ArgumentError)
+ lambda { File.split('string', 'another string') }.should raise_error(ArgumentError)
end
it "raises a TypeError if the argument is not a String type" do
- -> { File.split(1) }.should raise_error(TypeError)
+ lambda { File.split(1) }.should raise_error(TypeError)
end
it "coerces the argument with to_str if it is not a String type" do
- obj = mock("str")
- obj.should_receive(:to_str).and_return("/one/two/three")
- File.split(obj).should == ["/one/two", "three"]
+ class C; def to_str; "/rubinius/better/than/ruby"; end; end
+ File.split(C.new).should == ["/rubinius/better/than", "ruby"]
end
it "accepts an object that has a #to_path method" do
diff --git a/spec/ruby/core/file/stat/atime_spec.rb b/spec/ruby/core/file/stat/atime_spec.rb
index 9f1111ced1..575c98ce44 100644
--- a/spec/ruby/core/file/stat/atime_spec.rb
+++ b/spec/ruby/core/file/stat/atime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#atime" do
before :each do
diff --git a/spec/ruby/core/file/stat/birthtime_spec.rb b/spec/ruby/core/file/stat/birthtime_spec.rb
index a727bbe566..c2ccc319f1 100644
--- a/spec/ruby/core/file/stat/birthtime_spec.rb
+++ b/spec/ruby/core/file/stat/birthtime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#birthtime" do
before :each do
@@ -21,7 +21,7 @@ describe "File::Stat#birthtime" do
platform_is :linux, :openbsd do
it "raises an NotImplementedError" do
st = File.stat(@file)
- -> { st.birthtime }.should raise_error(NotImplementedError)
+ lambda { st.birthtime }.should raise_error(NotImplementedError)
end
end
end
diff --git a/spec/ruby/core/file/stat/blksize_spec.rb b/spec/ruby/core/file/stat/blksize_spec.rb
index 4d85b05e4d..4399e6b4bb 100644
--- a/spec/ruby/core/file/stat/blksize_spec.rb
+++ b/spec/ruby/core/file/stat/blksize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#blksize" do
before :each do
diff --git a/spec/ruby/core/file/stat/blockdev_spec.rb b/spec/ruby/core/file/stat/blockdev_spec.rb
index f986c18125..440291f130 100644
--- a/spec/ruby/core/file/stat/blockdev_spec.rb
+++ b/spec/ruby/core/file/stat/blockdev_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/blockdev'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/blockdev', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#blockdev?" do
it_behaves_like :file_blockdev, :blockdev?, FileStat
diff --git a/spec/ruby/core/file/stat/blocks_spec.rb b/spec/ruby/core/file/stat/blocks_spec.rb
index f3f903d0f7..e84e822a27 100644
--- a/spec/ruby/core/file/stat/blocks_spec.rb
+++ b/spec/ruby/core/file/stat/blocks_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#blocks" do
before :each do
diff --git a/spec/ruby/core/file/stat/chardev_spec.rb b/spec/ruby/core/file/stat/chardev_spec.rb
index 622fb2052d..25c8c877f7 100644
--- a/spec/ruby/core/file/stat/chardev_spec.rb
+++ b/spec/ruby/core/file/stat/chardev_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/chardev'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/chardev', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#chardev?" do
it_behaves_like :file_chardev, :chardev?, FileStat
diff --git a/spec/ruby/core/file/stat/comparison_spec.rb b/spec/ruby/core/file/stat/comparison_spec.rb
index faa3b6bf62..a70a083ab2 100644
--- a/spec/ruby/core/file/stat/comparison_spec.rb
+++ b/spec/ruby/core/file/stat/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#<=>" do
before :each do
diff --git a/spec/ruby/core/file/stat/ctime_spec.rb b/spec/ruby/core/file/stat/ctime_spec.rb
index fd50487a0a..2f82dfdab6 100644
--- a/spec/ruby/core/file/stat/ctime_spec.rb
+++ b/spec/ruby/core/file/stat/ctime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#ctime" do
before :each do
diff --git a/spec/ruby/core/file/stat/dev_major_spec.rb b/spec/ruby/core/file/stat/dev_major_spec.rb
index 4966d609e2..0b00fc4d36 100644
--- a/spec/ruby/core/file/stat/dev_major_spec.rb
+++ b/spec/ruby/core/file/stat/dev_major_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#dev_major" do
before :each do
diff --git a/spec/ruby/core/file/stat/dev_minor_spec.rb b/spec/ruby/core/file/stat/dev_minor_spec.rb
index ea79c12b99..0475e3be81 100644
--- a/spec/ruby/core/file/stat/dev_minor_spec.rb
+++ b/spec/ruby/core/file/stat/dev_minor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#dev_minor" do
before :each do
diff --git a/spec/ruby/core/file/stat/dev_spec.rb b/spec/ruby/core/file/stat/dev_spec.rb
index e953fcaa58..3cdc704fd7 100644
--- a/spec/ruby/core/file/stat/dev_spec.rb
+++ b/spec/ruby/core/file/stat/dev_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#dev" do
before :each do
diff --git a/spec/ruby/core/file/stat/directory_spec.rb b/spec/ruby/core/file/stat/directory_spec.rb
index c03610388b..5ead2dca49 100644
--- a/spec/ruby/core/file/stat/directory_spec.rb
+++ b/spec/ruby/core/file/stat/directory_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/directory'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/directory', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#directory?" do
it_behaves_like :file_directory, :directory?, FileStat
diff --git a/spec/ruby/core/file/stat/executable_real_spec.rb b/spec/ruby/core/file/stat/executable_real_spec.rb
index 23bffe89c5..11de0a5b39 100644
--- a/spec/ruby/core/file/stat/executable_real_spec.rb
+++ b/spec/ruby/core/file/stat/executable_real_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/executable_real'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/executable_real', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#executable_real?" do
it_behaves_like :file_executable_real, :executable_real?, FileStat
diff --git a/spec/ruby/core/file/stat/executable_spec.rb b/spec/ruby/core/file/stat/executable_spec.rb
index 422975d14b..e3b1093056 100644
--- a/spec/ruby/core/file/stat/executable_spec.rb
+++ b/spec/ruby/core/file/stat/executable_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/executable'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/executable', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#executable?" do
it_behaves_like :file_executable, :executable?, FileStat
diff --git a/spec/ruby/core/file/stat/file_spec.rb b/spec/ruby/core/file/stat/file_spec.rb
index d141536b4b..da79dddb00 100644
--- a/spec/ruby/core/file/stat/file_spec.rb
+++ b/spec/ruby/core/file/stat/file_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/file'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/file', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#file?" do
it_behaves_like :file_file, :file?, FileStat
diff --git a/spec/ruby/core/file/stat/ftype_spec.rb b/spec/ruby/core/file/stat/ftype_spec.rb
index eb892eae5f..588c371c39 100644
--- a/spec/ruby/core/file/stat/ftype_spec.rb
+++ b/spec/ruby/core/file/stat/ftype_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/file_types'
+require "#{File.dirname(__FILE__)}/../../../spec_helper"
+require "#{File.dirname(__FILE__)}/../fixtures/file_types"
describe "File::Stat#ftype" do
before :all do
@@ -55,6 +55,10 @@ describe "File::Stat#ftype" do
end
end
+ # This will silently not execute the block if no socket
+ # can be found. However, if you are running X, there is
+ # a good chance that if nothing else, at least the X
+ # Server socket exists.
it "returns 'socket' when the file is a socket" do
FileSpecs.socket do |socket|
File.lstat(socket).ftype.should == 'socket'
diff --git a/spec/ruby/core/file/stat/gid_spec.rb b/spec/ruby/core/file/stat/gid_spec.rb
index 3bba65bc82..27356b6401 100644
--- a/spec/ruby/core/file/stat/gid_spec.rb
+++ b/spec/ruby/core/file/stat/gid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#gid" do
before :each do
diff --git a/spec/ruby/core/file/stat/grpowned_spec.rb b/spec/ruby/core/file/stat/grpowned_spec.rb
index e7278e229b..07a52876d0 100644
--- a/spec/ruby/core/file/stat/grpowned_spec.rb
+++ b/spec/ruby/core/file/stat/grpowned_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/grpowned'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/grpowned', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#grpowned?" do
it_behaves_like :file_grpowned, :grpowned?, FileStat
diff --git a/spec/ruby/core/file/stat/ino_spec.rb b/spec/ruby/core/file/stat/ino_spec.rb
index 42370aecb7..0339dee54f 100644
--- a/spec/ruby/core/file/stat/ino_spec.rb
+++ b/spec/ruby/core/file/stat/ino_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#ino" do
before :each do
@@ -19,10 +19,20 @@ describe "File::Stat#ino" do
end
platform_is :windows do
- it "returns BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low of a File::Stat object" do
- st = File.stat(@file)
- st.ino.should be_kind_of(Integer)
- st.ino.should > 0
+ ruby_version_is ""..."2.3" do
+ it "returns 0" do
+ st = File.stat(@file)
+ st.ino.should be_kind_of(Integer)
+ st.ino.should == 0
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "returns BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low of a File::Stat object" do
+ st = File.stat(@file)
+ st.ino.should be_kind_of(Integer)
+ st.ino.should > 0
+ end
end
end
end
diff --git a/spec/ruby/core/file/stat/inspect_spec.rb b/spec/ruby/core/file/stat/inspect_spec.rb
index 1613b427d0..ec99ab16a8 100644
--- a/spec/ruby/core/file/stat/inspect_spec.rb
+++ b/spec/ruby/core/file/stat/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#inspect" do
@@ -15,10 +15,10 @@ describe "File::Stat#inspect" do
st = File.stat(@file)
expected = "#<File::Stat dev=0x#{st.dev.to_s(16)}, ino=#{st.ino}, mode=#{sprintf("%07o", st.mode)}, nlink=#{st.nlink}"
expected << ", uid=#{st.uid}, gid=#{st.gid}, rdev=0x#{st.rdev.to_s(16)}, size=#{st.size}, blksize=#{st.blksize.inspect}"
- expected << ", blocks=#{st.blocks.inspect}, atime=#{st.atime.inspect}, mtime=#{st.mtime.inspect}, ctime=#{st.ctime.inspect}"
+ expected << ", blocks=#{st.blocks.inspect}, atime=#{st.atime}, mtime=#{st.mtime}, ctime=#{st.ctime}"
platform_is :netbsd, :freebsd, :darwin do
# Windows has File.birthtime but it's not here since already shown by ctime.
- expected << ", birthtime=#{st.birthtime.inspect}"
+ expected << ", birthtime=#{st.birthtime}"
end
expected << ">"
st.inspect.should == expected
diff --git a/spec/ruby/core/file/stat/mode_spec.rb b/spec/ruby/core/file/stat/mode_spec.rb
index c85fb85a58..1c895bf0ce 100644
--- a/spec/ruby/core/file/stat/mode_spec.rb
+++ b/spec/ruby/core/file/stat/mode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#mode" do
before :each do
diff --git a/spec/ruby/core/file/stat/mtime_spec.rb b/spec/ruby/core/file/stat/mtime_spec.rb
index 08a2b83463..9dd20dfd65 100644
--- a/spec/ruby/core/file/stat/mtime_spec.rb
+++ b/spec/ruby/core/file/stat/mtime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#mtime" do
before :each do
diff --git a/spec/ruby/core/file/stat/new_spec.rb b/spec/ruby/core/file/stat/new_spec.rb
index c0d9432ac8..4579c4a807 100644
--- a/spec/ruby/core/file/stat/new_spec.rb
+++ b/spec/ruby/core/file/stat/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#initialize" do
@@ -13,7 +13,7 @@ describe "File::Stat#initialize" do
end
it "raises an exception if the file doesn't exist" do
- -> {
+ lambda {
File::Stat.new(tmp("i_am_a_dummy_file_that_doesnt_exist"))
}.should raise_error(Errno::ENOENT)
end
diff --git a/spec/ruby/core/file/stat/nlink_spec.rb b/spec/ruby/core/file/stat/nlink_spec.rb
index 2dd0bff124..e857b07fd1 100644
--- a/spec/ruby/core/file/stat/nlink_spec.rb
+++ b/spec/ruby/core/file/stat/nlink_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#nlink" do
before :each do
diff --git a/spec/ruby/core/file/stat/owned_spec.rb b/spec/ruby/core/file/stat/owned_spec.rb
index 6f0c250f88..4c4d843bbe 100644
--- a/spec/ruby/core/file/stat/owned_spec.rb
+++ b/spec/ruby/core/file/stat/owned_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/owned'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/owned', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#owned?" do
it_behaves_like :file_owned, :owned?, FileStat
@@ -22,12 +22,10 @@ describe "File::Stat#owned?" do
end
platform_is_not :windows do
- as_user do
- it "returns false if the file is not owned by the user" do
- system_file = '/etc/passwd'
- st = File.stat(system_file)
- st.owned?.should == false
- end
+ it "returns false if the file is not owned by the user" do
+ system_file = '/etc/passwd'
+ st = File.stat(system_file)
+ st.owned?.should == false
end
end
end
diff --git a/spec/ruby/core/file/stat/pipe_spec.rb b/spec/ruby/core/file/stat/pipe_spec.rb
index 7abb6c742a..e4c0b559bb 100644
--- a/spec/ruby/core/file/stat/pipe_spec.rb
+++ b/spec/ruby/core/file/stat/pipe_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/pipe'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/pipe', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#pipe?" do
it_behaves_like :file_pipe, :pipe?, FileStat
@@ -20,7 +20,7 @@ describe "File::Stat#pipe?" do
platform_is_not :windows do
it "returns true if the file is a pipe" do
filename = tmp("i_am_a_pipe")
- File.mkfifo(filename)
+ system "mkfifo #{filename}"
st = File.stat(filename)
st.pipe?.should == true
diff --git a/spec/ruby/core/file/stat/rdev_major_spec.rb b/spec/ruby/core/file/stat/rdev_major_spec.rb
index f8a8d1b107..f9d514fbc0 100644
--- a/spec/ruby/core/file/stat/rdev_major_spec.rb
+++ b/spec/ruby/core/file/stat/rdev_major_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#rdev_major" do
before :each do
diff --git a/spec/ruby/core/file/stat/rdev_minor_spec.rb b/spec/ruby/core/file/stat/rdev_minor_spec.rb
index dc30c1f56c..67399c5e68 100644
--- a/spec/ruby/core/file/stat/rdev_minor_spec.rb
+++ b/spec/ruby/core/file/stat/rdev_minor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#rdev_minor" do
before :each do
diff --git a/spec/ruby/core/file/stat/rdev_spec.rb b/spec/ruby/core/file/stat/rdev_spec.rb
index 9e1aee692d..12f97fb044 100644
--- a/spec/ruby/core/file/stat/rdev_spec.rb
+++ b/spec/ruby/core/file/stat/rdev_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#rdev" do
before :each do
diff --git a/spec/ruby/core/file/stat/readable_real_spec.rb b/spec/ruby/core/file/stat/readable_real_spec.rb
index f138fd7b00..49412f1df2 100644
--- a/spec/ruby/core/file/stat/readable_real_spec.rb
+++ b/spec/ruby/core/file/stat/readable_real_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/readable_real'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/readable_real', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#readable_real?" do
it_behaves_like :file_readable_real, :readable_real?, FileStat
diff --git a/spec/ruby/core/file/stat/readable_spec.rb b/spec/ruby/core/file/stat/readable_spec.rb
index e99e48feed..3d81975309 100644
--- a/spec/ruby/core/file/stat/readable_spec.rb
+++ b/spec/ruby/core/file/stat/readable_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/readable'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/readable', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#readable?" do
it_behaves_like :file_readable, :readable?, FileStat
diff --git a/spec/ruby/core/file/stat/setgid_spec.rb b/spec/ruby/core/file/stat/setgid_spec.rb
index c0748ede57..318a72b437 100644
--- a/spec/ruby/core/file/stat/setgid_spec.rb
+++ b/spec/ruby/core/file/stat/setgid_spec.rb
@@ -1,7 +1,11 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/setgid'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/setgid', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#setgid?" do
it_behaves_like :file_setgid, :setgid?, FileStat
end
+
+describe "File::Stat#setgid?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/file/stat/setuid_spec.rb b/spec/ruby/core/file/stat/setuid_spec.rb
index 6408120fc4..5057af0ccc 100644
--- a/spec/ruby/core/file/stat/setuid_spec.rb
+++ b/spec/ruby/core/file/stat/setuid_spec.rb
@@ -1,7 +1,11 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/setuid'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/setuid', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#setuid?" do
it_behaves_like :file_setuid, :setuid?, FileStat
end
+
+describe "File::Stat#setuid?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/file/stat/size_spec.rb b/spec/ruby/core/file/stat/size_spec.rb
index 4b4f57f8c8..84db12d591 100644
--- a/spec/ruby/core/file/stat/size_spec.rb
+++ b/spec/ruby/core/file/stat/size_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/size'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/size', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat.size?" do
it_behaves_like :file_size, :size?, FileStat
diff --git a/spec/ruby/core/file/stat/socket_spec.rb b/spec/ruby/core/file/stat/socket_spec.rb
index 09740be110..b25d9314f9 100644
--- a/spec/ruby/core/file/stat/socket_spec.rb
+++ b/spec/ruby/core/file/stat/socket_spec.rb
@@ -1,7 +1,11 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/socket'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/socket', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#socket?" do
it_behaves_like :file_socket, :socket?, FileStat
end
+
+describe "File::Stat#socket?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/file/stat/sticky_spec.rb b/spec/ruby/core/file/stat/sticky_spec.rb
index 7083e644e9..c2fefbe106 100644
--- a/spec/ruby/core/file/stat/sticky_spec.rb
+++ b/spec/ruby/core/file/stat/sticky_spec.rb
@@ -1,7 +1,11 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/sticky'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/sticky', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#sticky?" do
it_behaves_like :file_sticky, :sticky?, FileStat
end
+
+describe "File::Stat#sticky?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/file/stat/symlink_spec.rb b/spec/ruby/core/file/stat/symlink_spec.rb
index 0def832a4c..579c1de0ad 100644
--- a/spec/ruby/core/file/stat/symlink_spec.rb
+++ b/spec/ruby/core/file/stat/symlink_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/symlink'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/symlink', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#symlink?" do
it_behaves_like :file_symlink, :symlink?, FileStat
diff --git a/spec/ruby/core/file/stat/uid_spec.rb b/spec/ruby/core/file/stat/uid_spec.rb
index b97147db21..75be97c234 100644
--- a/spec/ruby/core/file/stat/uid_spec.rb
+++ b/spec/ruby/core/file/stat/uid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#uid" do
before :each do
diff --git a/spec/ruby/core/file/stat/world_readable_spec.rb b/spec/ruby/core/file/stat/world_readable_spec.rb
index d94a02205e..178e39a1ea 100644
--- a/spec/ruby/core/file/stat/world_readable_spec.rb
+++ b/spec/ruby/core/file/stat/world_readable_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/world_readable'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/world_readable', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat.world_readable?" do
- it_behaves_like :file_world_readable, :world_readable?, FileStat
+ it_behaves_like(:file_world_readable, :world_readable?, FileStat)
end
describe "File::Stat#world_readable?" do
diff --git a/spec/ruby/core/file/stat/world_writable_spec.rb b/spec/ruby/core/file/stat/world_writable_spec.rb
index 8100008344..73a7c6d3ed 100644
--- a/spec/ruby/core/file/stat/world_writable_spec.rb
+++ b/spec/ruby/core/file/stat/world_writable_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/world_writable'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/world_writable', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat.world_writable?" do
- it_behaves_like :file_world_writable, :world_writable?, FileStat
+ it_behaves_like(:file_world_writable, :world_writable?, FileStat)
end
describe "File::Stat#world_writable?" do
diff --git a/spec/ruby/core/file/stat/writable_real_spec.rb b/spec/ruby/core/file/stat/writable_real_spec.rb
index 4c9e78eb70..e069db507b 100644
--- a/spec/ruby/core/file/stat/writable_real_spec.rb
+++ b/spec/ruby/core/file/stat/writable_real_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/writable_real'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/writable_real', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#writable_real?" do
it_behaves_like :file_writable_real, :writable_real?, FileStat
diff --git a/spec/ruby/core/file/stat/writable_spec.rb b/spec/ruby/core/file/stat/writable_spec.rb
index 551268751f..b720e59f81 100644
--- a/spec/ruby/core/file/stat/writable_spec.rb
+++ b/spec/ruby/core/file/stat/writable_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/writable'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/writable', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#writable?" do
it_behaves_like :file_writable, :writable?, FileStat
diff --git a/spec/ruby/core/file/stat/zero_spec.rb b/spec/ruby/core/file/stat/zero_spec.rb
index 74facac66a..127c706b90 100644
--- a/spec/ruby/core/file/stat/zero_spec.rb
+++ b/spec/ruby/core/file/stat/zero_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../../../shared/file/zero'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../shared/file/zero', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#zero?" do
it_behaves_like :file_zero, :zero?, FileStat
diff --git a/spec/ruby/core/file/stat_spec.rb b/spec/ruby/core/file/stat_spec.rb
index 31f9dc58af..1ea003142e 100644
--- a/spec/ruby/core/file/stat_spec.rb
+++ b/spec/ruby/core/file/stat_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/stat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/stat', __FILE__)
describe "File.stat" do
it_behaves_like :file_stat, :stat
diff --git a/spec/ruby/core/file/sticky_spec.rb b/spec/ruby/core/file/sticky_spec.rb
index 5f7b2d93eb..d01e2b6818 100644
--- a/spec/ruby/core/file/sticky_spec.rb
+++ b/spec/ruby/core/file/sticky_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/sticky'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/sticky', __FILE__)
describe "File.sticky?" do
it_behaves_like :file_sticky, :sticky?, File
@@ -35,7 +35,7 @@ describe "File.sticky?" do
end
platform_is :bsd do
- # FreeBSD and NetBSD can't set sticky bit to a normal file
+ # FreeBSD and NetBSD can't set stiky bit to a normal file
it "cannot set sticky bit to a normal file" do
filename = tmp("i_exist")
touch(filename)
diff --git a/spec/ruby/core/file/symlink_spec.rb b/spec/ruby/core/file/symlink_spec.rb
index 0e8b0a5a20..2426b8c9a7 100644
--- a/spec/ruby/core/file/symlink_spec.rb
+++ b/spec/ruby/core/file/symlink_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/symlink'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/symlink', __FILE__)
describe "File.symlink" do
before :each do
@@ -32,18 +32,18 @@ describe "File.symlink" do
it "raises an Errno::EEXIST if the target already exists" do
File.symlink(@file, @link)
- -> { File.symlink(@file, @link) }.should raise_error(Errno::EEXIST)
+ lambda { File.symlink(@file, @link) }.should raise_error(Errno::EEXIST)
end
it "raises an ArgumentError if not called with two arguments" do
- -> { File.symlink }.should raise_error(ArgumentError)
- -> { File.symlink(@file) }.should raise_error(ArgumentError)
+ lambda { File.symlink }.should raise_error(ArgumentError)
+ lambda { File.symlink(@file) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not called with String types" do
- -> { File.symlink(@file, nil) }.should raise_error(TypeError)
- -> { File.symlink(@file, 1) }.should raise_error(TypeError)
- -> { File.symlink(1, 1) }.should raise_error(TypeError)
+ lambda { File.symlink(@file, nil) }.should raise_error(TypeError)
+ lambda { File.symlink(@file, 1) }.should raise_error(TypeError)
+ lambda { File.symlink(1, 1) }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/core/file/to_path_spec.rb b/spec/ruby/core/file/to_path_spec.rb
index 6d168a065c..3dc801cc27 100644
--- a/spec/ruby/core/file/to_path_spec.rb
+++ b/spec/ruby/core/file/to_path_spec.rb
@@ -1,6 +1,49 @@
-require_relative '../../spec_helper'
-require_relative 'shared/path'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File#to_path" do
- it_behaves_like :file_path, :to_path
+ before :each do
+ @name = "file_to_path"
+ @path = tmp(@name)
+ touch @path
+ end
+
+ after :each do
+ @file.close if @file and !@file.closed?
+ rm_r @path
+ end
+
+ it "returns a String" do
+ @file = File.new @path
+ @file.to_path.should be_an_instance_of(String)
+ end
+
+ it "does not normalise the path it returns" do
+ Dir.chdir(tmp("")) do
+ unorm = "./#{@name}"
+ @file = File.new unorm
+ @file.to_path.should == unorm
+ end
+ end
+
+ it "does not canonicalize the path it returns" do
+ dir = File.basename tmp("")
+ path = "#{tmp("")}../#{dir}/#{@name}"
+ @file = File.new path
+ @file.to_path.should == path
+ end
+
+ it "does not absolute-ise the path it returns" do
+ Dir.chdir(tmp("")) do
+ @file = File.new @name
+ @file.to_path.should == @name
+ end
+ end
+
+ with_feature :encoding do
+ it "preserves the encoding of the path" do
+ path = @path.force_encoding("euc-jp")
+ @file = File.new path
+ @file.to_path.encoding.should == Encoding.find("euc-jp")
+ end
+ end
end
diff --git a/spec/ruby/core/file/truncate_spec.rb b/spec/ruby/core/file/truncate_spec.rb
index 43b86b7382..a120c610b8 100644
--- a/spec/ruby/core/file/truncate_spec.rb
+++ b/spec/ruby/core/file/truncate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.truncate" do
before :each do
@@ -54,29 +54,29 @@ describe "File.truncate" do
rm_r not_existing_file
begin
- -> { File.truncate(not_existing_file, 5) }.should raise_error(Errno::ENOENT)
+ lambda { File.truncate(not_existing_file, 5) }.should raise_error(Errno::ENOENT)
ensure
rm_r not_existing_file
end
end
it "raises an ArgumentError if not passed two arguments" do
- -> { File.truncate }.should raise_error(ArgumentError)
- -> { File.truncate(@name) }.should raise_error(ArgumentError)
+ lambda { File.truncate }.should raise_error(ArgumentError)
+ lambda { File.truncate(@name) }.should raise_error(ArgumentError)
end
platform_is_not :netbsd, :openbsd do
it "raises an Errno::EINVAL if the length argument is not valid" do
- -> { File.truncate(@name, -1) }.should raise_error(Errno::EINVAL) # May fail
+ lambda { File.truncate(@name, -1) }.should raise_error(Errno::EINVAL) # May fail
end
end
it "raises a TypeError if not passed a String type for the first argument" do
- -> { File.truncate(1, 1) }.should raise_error(TypeError)
+ lambda { File.truncate(1, 1) }.should raise_error(TypeError)
end
it "raises a TypeError if not passed an Integer type for the second argument" do
- -> { File.truncate(@name, nil) }.should raise_error(TypeError)
+ lambda { File.truncate(@name, nil) }.should raise_error(TypeError)
end
it "accepts an object that has a #to_path method" do
@@ -149,29 +149,29 @@ describe "File#truncate" do
end
it "raises an ArgumentError if not passed one argument" do
- -> { @file.truncate }.should raise_error(ArgumentError)
- -> { @file.truncate(1) }.should_not raise_error(ArgumentError)
+ lambda { @file.truncate }.should raise_error(ArgumentError)
+ lambda { @file.truncate(1) }.should_not raise_error(ArgumentError)
end
platform_is_not :netbsd do
it "raises an Errno::EINVAL if the length argument is not valid" do
- -> { @file.truncate(-1) }.should raise_error(Errno::EINVAL) # May fail
+ lambda { @file.truncate(-1) }.should raise_error(Errno::EINVAL) # May fail
end
end
it "raises an IOError if file is closed" do
@file.close
@file.closed?.should == true
- -> { @file.truncate(42) }.should raise_error(IOError)
+ lambda { @file.truncate(42) }.should raise_error(IOError)
end
it "raises an IOError if file is not opened for writing" do
File.open(@name, 'r') do |file|
- -> { file.truncate(42) }.should raise_error(IOError)
+ lambda { file.truncate(42) }.should raise_error(IOError)
end
end
it "raises a TypeError if not passed an Integer type for the for the argument" do
- -> { @file.truncate(nil) }.should raise_error(TypeError)
+ lambda { @file.truncate(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/file/umask_spec.rb b/spec/ruby/core/file/umask_spec.rb
index 2640e3c316..2286bf064f 100644
--- a/spec/ruby/core/file/umask_spec.rb
+++ b/spec/ruby/core/file/umask_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.umask" do
before :each do
@@ -30,6 +30,18 @@ describe "File.umask" do
end
end
+ it "always succeeds with any integer values" do
+ vals = [-2**30, -2**16, -2**8, -2,
+ -1.5, -1, 0.5, 0, 1, 2, 7.77777, 16, 32, 64, 2**8, 2**16, 2**30]
+ vals.each { |v|
+ lambda { File.umask(v) }.should_not raise_error
+ }
+ end
+
+ it "raises ArgumentError when more than one argument is provided" do
+ lambda { File.umask(022, 022) }.should raise_error(ArgumentError)
+ end
+
platform_is :windows do
it "returns the current umask value for this process (basic)" do
File.umask.should == 0
@@ -45,13 +57,4 @@ describe "File.umask" do
File.umask.should == 0
end
end
-
- it "raises RangeError with too large values" do
- -> { File.umask(2**64) }.should raise_error(RangeError)
- -> { File.umask(-2**63 - 1) }.should raise_error(RangeError)
- end
-
- it "raises ArgumentError when more than one argument is provided" do
- -> { File.umask(022, 022) }.should raise_error(ArgumentError)
- end
end
diff --git a/spec/ruby/core/file/unlink_spec.rb b/spec/ruby/core/file/unlink_spec.rb
index 28872d55ed..a1e96aef6a 100644
--- a/spec/ruby/core/file/unlink_spec.rb
+++ b/spec/ruby/core/file/unlink_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/unlink'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/unlink', __FILE__)
describe "File.unlink" do
- it_behaves_like :file_unlink, :unlink
+ it_behaves_like(:file_unlink, :unlink)
end
diff --git a/spec/ruby/core/file/utime_spec.rb b/spec/ruby/core/file/utime_spec.rb
index 9c198af18b..e586029715 100644
--- a/spec/ruby/core/file/utime_spec.rb
+++ b/spec/ruby/core/file/utime_spec.rb
@@ -1,11 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "File.utime" do
-
- before :all do
- @time_is_float = /mswin|mingw/ =~ RUBY_PLATFORM && RUBY_VERSION >= '2.5'
- end
-
before :each do
@atime = Time.now
@mtime = Time.now
@@ -21,64 +16,31 @@ describe "File.utime" do
it "sets the access and modification time of each file" do
File.utime(@atime, @mtime, @file1, @file2)
- if @time_is_float
- File.atime(@file1).should be_close(@atime, 0.0001)
- File.mtime(@file1).should be_close(@mtime, 0.0001)
- File.atime(@file2).should be_close(@atime, 0.0001)
- File.mtime(@file2).should be_close(@mtime, 0.0001)
- else
- File.atime(@file1).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
- File.mtime(@file1).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
- File.atime(@file2).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
- File.mtime(@file2).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
- end
+ File.atime(@file1).to_i.should be_close(@atime.to_i, 2)
+ File.mtime(@file1).to_i.should be_close(@mtime.to_i, 2)
+ File.atime(@file2).to_i.should be_close(@atime.to_i, 2)
+ File.mtime(@file2).to_i.should be_close(@mtime.to_i, 2)
end
it "uses the current times if two nil values are passed" do
- tn = Time.now
File.utime(nil, nil, @file1, @file2)
- if @time_is_float
- File.atime(@file1).should be_close(tn, 0.050)
- File.mtime(@file1).should be_close(tn, 0.050)
- File.atime(@file2).should be_close(tn, 0.050)
- File.mtime(@file2).should be_close(tn, 0.050)
- else
- File.atime(@file1).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
- File.mtime(@file1).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
- File.atime(@file2).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
- File.mtime(@file2).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
- end
+ File.atime(@file1).to_i.should be_close(Time.now.to_i, 2)
+ File.mtime(@file1).to_i.should be_close(Time.now.to_i, 2)
+ File.atime(@file2).to_i.should be_close(Time.now.to_i, 2)
+ File.mtime(@file2).to_i.should be_close(Time.now.to_i, 2)
end
it "accepts an object that has a #to_path method" do
File.utime(@atime, @mtime, mock_to_path(@file1), mock_to_path(@file2))
end
- it "accepts numeric atime and mtime arguments" do
- if @time_is_float
- File.utime(@atime.to_f, @mtime.to_f, @file1, @file2)
- File.atime(@file1).should be_close(@atime, 0.0001)
- File.mtime(@file1).should be_close(@mtime, 0.0001)
- File.atime(@file2).should be_close(@atime, 0.0001)
- File.mtime(@file2).should be_close(@mtime, 0.0001)
- else
- File.utime(@atime.to_i, @mtime.to_i, @file1, @file2)
- File.atime(@file1).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
- File.mtime(@file1).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
- File.atime(@file2).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
- File.mtime(@file2).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
- end
- end
-
platform_is :linux do
platform_is wordsize: 64 do
- it "allows Time instances in the far future to set mtime and atime (but some filesystems limit it up to 2446-05-10)" do
- # https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Inode_Timestamps
- # "Therefore, timestamps should not overflow until May 2446."
+ it "allows Time instances in the far future to set mtime and atime" do
time = Time.at(1<<44)
File.utime(time, time, @file1)
- [559444, 2446].should.include? File.atime(@file1).year
- [559444, 2446].should.include? File.mtime(@file1).year
+ File.atime(@file1).year.should == 559444
+ File.mtime(@file1).year.should == 559444
end
end
end
diff --git a/spec/ruby/core/file/world_readable_spec.rb b/spec/ruby/core/file/world_readable_spec.rb
index 11b8e67d0b..a130f0d115 100644
--- a/spec/ruby/core/file/world_readable_spec.rb
+++ b/spec/ruby/core/file/world_readable_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/world_readable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/world_readable', __FILE__)
describe "File.world_readable?" do
- it_behaves_like :file_world_readable, :world_readable?, File
+ it_behaves_like(:file_world_readable, :world_readable?, File)
it "returns nil if the file does not exist" do
file = rand.to_s + $$.to_s
- File.should_not.exist?(file)
+ File.exist?(file).should be_false
File.world_readable?(file).should be_nil
end
end
diff --git a/spec/ruby/core/file/world_writable_spec.rb b/spec/ruby/core/file/world_writable_spec.rb
index d378cf2eb9..5a39643ef9 100644
--- a/spec/ruby/core/file/world_writable_spec.rb
+++ b/spec/ruby/core/file/world_writable_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/world_writable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/world_writable', __FILE__)
describe "File.world_writable?" do
- it_behaves_like :file_world_writable, :world_writable?, File
+ it_behaves_like(:file_world_writable, :world_writable?, File)
it "returns nil if the file does not exist" do
file = rand.to_s + $$.to_s
- File.should_not.exist?(file)
+ File.exist?(file).should be_false
File.world_writable?(file).should be_nil
end
end
diff --git a/spec/ruby/core/file/writable_real_spec.rb b/spec/ruby/core/file/writable_real_spec.rb
index bea4c4c262..36f576e222 100644
--- a/spec/ruby/core/file/writable_real_spec.rb
+++ b/spec/ruby/core/file/writable_real_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/writable_real'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/writable_real', __FILE__)
describe "File.writable_real?" do
it_behaves_like :file_writable_real, :writable_real?, File
diff --git a/spec/ruby/core/file/writable_spec.rb b/spec/ruby/core/file/writable_spec.rb
index 519837b0d1..4f6213ec77 100644
--- a/spec/ruby/core/file/writable_spec.rb
+++ b/spec/ruby/core/file/writable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/writable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/writable', __FILE__)
describe "File.writable?" do
it_behaves_like :file_writable, :writable?, File
diff --git a/spec/ruby/core/file/zero_spec.rb b/spec/ruby/core/file/zero_spec.rb
index 63dd85ee46..0fc087faff 100644
--- a/spec/ruby/core/file/zero_spec.rb
+++ b/spec/ruby/core/file/zero_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/zero'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/zero', __FILE__)
describe "File.zero?" do
it_behaves_like :file_zero, :zero?, File
diff --git a/spec/ruby/core/filetest/blockdev_spec.rb b/spec/ruby/core/filetest/blockdev_spec.rb
index 4f32991c4a..13bc98b483 100644
--- a/spec/ruby/core/filetest/blockdev_spec.rb
+++ b/spec/ruby/core/filetest/blockdev_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/blockdev'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/blockdev', __FILE__)
describe "FileTest.blockdev?" do
it_behaves_like :file_blockdev, :blockdev?, FileTest
diff --git a/spec/ruby/core/filetest/chardev_spec.rb b/spec/ruby/core/filetest/chardev_spec.rb
index 59c48bb2d5..c126c81658 100644
--- a/spec/ruby/core/filetest/chardev_spec.rb
+++ b/spec/ruby/core/filetest/chardev_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/chardev'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/chardev', __FILE__)
describe "FileTest.chardev?" do
it_behaves_like :file_chardev, :chardev?, FileTest
diff --git a/spec/ruby/core/filetest/directory_spec.rb b/spec/ruby/core/filetest/directory_spec.rb
index 8f9d0e3901..e6f1ae51d2 100644
--- a/spec/ruby/core/filetest/directory_spec.rb
+++ b/spec/ruby/core/filetest/directory_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/directory'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/directory', __FILE__)
describe "FileTest.directory?" do
it_behaves_like :file_directory, :directory?, FileTest
diff --git a/spec/ruby/core/filetest/executable_real_spec.rb b/spec/ruby/core/filetest/executable_real_spec.rb
index da65245785..37511e6c88 100644
--- a/spec/ruby/core/filetest/executable_real_spec.rb
+++ b/spec/ruby/core/filetest/executable_real_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/executable_real'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/executable_real', __FILE__)
describe "FileTest.executable_real?" do
it_behaves_like :file_executable_real, :executable_real?, FileTest
diff --git a/spec/ruby/core/filetest/executable_spec.rb b/spec/ruby/core/filetest/executable_spec.rb
index 03056669f6..477e989423 100644
--- a/spec/ruby/core/filetest/executable_spec.rb
+++ b/spec/ruby/core/filetest/executable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/executable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/executable', __FILE__)
describe "FileTest.executable?" do
it_behaves_like :file_executable, :executable?, FileTest
diff --git a/spec/ruby/core/filetest/exist_spec.rb b/spec/ruby/core/filetest/exist_spec.rb
index 4d14bea231..b375d3a4b1 100644
--- a/spec/ruby/core/filetest/exist_spec.rb
+++ b/spec/ruby/core/filetest/exist_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/exist'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/exist', __FILE__)
describe "FileTest.exist?" do
it_behaves_like :file_exist, :exist?, FileTest
diff --git a/spec/ruby/core/filetest/exists_spec.rb b/spec/ruby/core/filetest/exists_spec.rb
index d090d7d740..09d4ca1a83 100644
--- a/spec/ruby/core/filetest/exists_spec.rb
+++ b/spec/ruby/core/filetest/exists_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/exist'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/exist', __FILE__)
describe "FileTest.exists?" do
it_behaves_like :file_exist, :exists?, FileTest
diff --git a/spec/ruby/core/filetest/file_spec.rb b/spec/ruby/core/filetest/file_spec.rb
index 0c0cb82f96..887dc1da88 100644
--- a/spec/ruby/core/filetest/file_spec.rb
+++ b/spec/ruby/core/filetest/file_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/file'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/file', __FILE__)
describe "File.file?" do
it_behaves_like :file_file, :file?, File
diff --git a/spec/ruby/core/filetest/grpowned_spec.rb b/spec/ruby/core/filetest/grpowned_spec.rb
index d073cb9770..950671aae9 100644
--- a/spec/ruby/core/filetest/grpowned_spec.rb
+++ b/spec/ruby/core/filetest/grpowned_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/grpowned'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/grpowned', __FILE__)
describe "FileTest.grpowned?" do
it_behaves_like :file_grpowned, :grpowned?, FileTest
diff --git a/spec/ruby/core/filetest/identical_spec.rb b/spec/ruby/core/filetest/identical_spec.rb
index b00c5b75e8..cb4bc82873 100644
--- a/spec/ruby/core/filetest/identical_spec.rb
+++ b/spec/ruby/core/filetest/identical_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/identical'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/identical', __FILE__)
describe "FileTest.identical?" do
it_behaves_like :file_identical, :identical?, FileTest
diff --git a/spec/ruby/core/filetest/owned_spec.rb b/spec/ruby/core/filetest/owned_spec.rb
index b26165f98d..8483f2af21 100644
--- a/spec/ruby/core/filetest/owned_spec.rb
+++ b/spec/ruby/core/filetest/owned_spec.rb
@@ -1,6 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/owned'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/owned', __FILE__)
describe "FileTest.owned?" do
it_behaves_like :file_owned, :owned?, FileTest
end
+
+describe "FileTest.owned?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/filetest/pipe_spec.rb b/spec/ruby/core/filetest/pipe_spec.rb
index 8ce67568fb..0147dae820 100644
--- a/spec/ruby/core/filetest/pipe_spec.rb
+++ b/spec/ruby/core/filetest/pipe_spec.rb
@@ -1,6 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/pipe'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/pipe', __FILE__)
describe "FileTest.pipe?" do
it_behaves_like :file_pipe, :pipe?, FileTest
end
+
+describe "FileTest.pipe?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/filetest/readable_real_spec.rb b/spec/ruby/core/filetest/readable_real_spec.rb
index 82c62fe8f0..62ac972834 100644
--- a/spec/ruby/core/filetest/readable_real_spec.rb
+++ b/spec/ruby/core/filetest/readable_real_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/readable_real'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/readable_real', __FILE__)
describe "FileTest.readable_real?" do
it_behaves_like :file_readable_real, :readable_real?, FileTest
diff --git a/spec/ruby/core/filetest/readable_spec.rb b/spec/ruby/core/filetest/readable_spec.rb
index 039ca56ca3..086a9e5819 100644
--- a/spec/ruby/core/filetest/readable_spec.rb
+++ b/spec/ruby/core/filetest/readable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/readable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/readable', __FILE__)
describe "FileTest.readable?" do
it_behaves_like :file_readable, :readable?, FileTest
diff --git a/spec/ruby/core/filetest/setgid_spec.rb b/spec/ruby/core/filetest/setgid_spec.rb
index c83ffccb2a..f6e3f5b979 100644
--- a/spec/ruby/core/filetest/setgid_spec.rb
+++ b/spec/ruby/core/filetest/setgid_spec.rb
@@ -1,6 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/setgid'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/setgid', __FILE__)
describe "FileTest.setgid?" do
it_behaves_like :file_setgid, :setgid?, FileTest
end
+
+describe "FileTest.setgid?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/filetest/setuid_spec.rb b/spec/ruby/core/filetest/setuid_spec.rb
index 1c1fd2efe4..f077ec5b65 100644
--- a/spec/ruby/core/filetest/setuid_spec.rb
+++ b/spec/ruby/core/filetest/setuid_spec.rb
@@ -1,6 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/setuid'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/setuid', __FILE__)
describe "FileTest.setuid?" do
it_behaves_like :file_setuid, :setuid?, FileTest
end
+
+describe "FileTest.setuid?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/filetest/size_spec.rb b/spec/ruby/core/filetest/size_spec.rb
index dc3ddb127f..398a8e69b8 100644
--- a/spec/ruby/core/filetest/size_spec.rb
+++ b/spec/ruby/core/filetest/size_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/size'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/size', __FILE__)
describe "FileTest.size?" do
it_behaves_like :file_size, :size?, FileTest
diff --git a/spec/ruby/core/filetest/socket_spec.rb b/spec/ruby/core/filetest/socket_spec.rb
index 63a6a31ecb..debe032ada 100644
--- a/spec/ruby/core/filetest/socket_spec.rb
+++ b/spec/ruby/core/filetest/socket_spec.rb
@@ -1,6 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/socket'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/socket', __FILE__)
describe "FileTest.socket?" do
it_behaves_like :file_socket, :socket?, FileTest
end
+
+describe "FileTest.socket?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/filetest/sticky_spec.rb b/spec/ruby/core/filetest/sticky_spec.rb
index 8b776b6672..ca38a45c9d 100644
--- a/spec/ruby/core/filetest/sticky_spec.rb
+++ b/spec/ruby/core/filetest/sticky_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/sticky'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/sticky', __FILE__)
describe "FileTest.sticky?" do
it_behaves_like :file_sticky, :sticky?, FileTest
diff --git a/spec/ruby/core/filetest/symlink_spec.rb b/spec/ruby/core/filetest/symlink_spec.rb
index 41c924dc1a..0812b09f5a 100644
--- a/spec/ruby/core/filetest/symlink_spec.rb
+++ b/spec/ruby/core/filetest/symlink_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/symlink'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/symlink', __FILE__)
describe "FileTest.symlink?" do
it_behaves_like :file_symlink, :symlink?, FileTest
diff --git a/spec/ruby/core/filetest/world_readable_spec.rb b/spec/ruby/core/filetest/world_readable_spec.rb
index 72abdd9e03..ef84c1ad01 100644
--- a/spec/ruby/core/filetest/world_readable_spec.rb
+++ b/spec/ruby/core/filetest/world_readable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FileTest.world_readable?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/filetest/world_writable_spec.rb b/spec/ruby/core/filetest/world_writable_spec.rb
index 533f698fd3..2803f3576a 100644
--- a/spec/ruby/core/filetest/world_writable_spec.rb
+++ b/spec/ruby/core/filetest/world_writable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "FileTest.world_writable?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/filetest/writable_real_spec.rb b/spec/ruby/core/filetest/writable_real_spec.rb
index 64abe4cd3f..83194f8173 100644
--- a/spec/ruby/core/filetest/writable_real_spec.rb
+++ b/spec/ruby/core/filetest/writable_real_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/writable_real'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/writable_real', __FILE__)
describe "FileTest.writable_real?" do
it_behaves_like :file_writable_real, :writable_real?, FileTest
diff --git a/spec/ruby/core/filetest/writable_spec.rb b/spec/ruby/core/filetest/writable_spec.rb
index e921a5887b..9064f1b16d 100644
--- a/spec/ruby/core/filetest/writable_spec.rb
+++ b/spec/ruby/core/filetest/writable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/writable'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/writable', __FILE__)
describe "FileTest.writable?" do
it_behaves_like :file_writable, :writable?, FileTest
diff --git a/spec/ruby/core/filetest/zero_spec.rb b/spec/ruby/core/filetest/zero_spec.rb
index dd6a164ec9..46b1842d55 100644
--- a/spec/ruby/core/filetest/zero_spec.rb
+++ b/spec/ruby/core/filetest/zero_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/file/zero'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/file/zero', __FILE__)
describe "FileTest.zero?" do
it_behaves_like :file_zero, :zero?, FileTest
diff --git a/spec/ruby/core/fixnum/abs_spec.rb b/spec/ruby/core/fixnum/abs_spec.rb
new file mode 100644
index 0000000000..5e6a7de891
--- /dev/null
+++ b/spec/ruby/core/fixnum/abs_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/abs', __FILE__)
+
+describe "Fixnum#abs" do
+ it_behaves_like :fixnum_abs, :abs
+end
+
diff --git a/spec/ruby/core/fixnum/bit_and_spec.rb b/spec/ruby/core/fixnum/bit_and_spec.rb
new file mode 100644
index 0000000000..9586075039
--- /dev/null
+++ b/spec/ruby/core/fixnum/bit_and_spec.rb
@@ -0,0 +1,46 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#&" do
+ it "returns self bitwise AND other" do
+ (256 & 16).should == 0
+ (2010 & 5).should == 0
+ (65535 & 1).should == 1
+ (0xffff & bignum_value + 0xffff_ffff).should == 65535
+ end
+
+ it "returns self bitwise AND other when one operand is negative" do
+ ((1 << 33) & -1).should == (1 << 33)
+ (-1 & (1 << 33)).should == (1 << 33)
+
+ ((-(1<<33)-1) & 5).should == 5
+ (5 & (-(1<<33)-1)).should == 5
+ end
+
+ it "returns self bitwise AND other when both operands are negative" do
+ (-5 & -1).should == -5
+ (-3 & -4).should == -4
+ (-12 & -13).should == -16
+ (-13 & -12).should == -16
+ end
+
+ it "returns self bitwise AND a Bignum" do
+ (-1 & 2**64).should == 18446744073709551616
+ end
+
+ it "coerces the rhs and calls #coerce" do
+ obj = mock("fixnum bit and")
+ obj.should_receive(:coerce).with(6).and_return([3, 6])
+ (6 & obj).should == 2
+ end
+
+ it "raises a TypeError when passed a Float" do
+ lambda { (3 & 3.4) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError and does not call #to_int when defined on an object" do
+ obj = mock("fixnum bit and")
+ obj.should_not_receive(:to_int)
+
+ lambda { 3 & obj }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/bit_length_spec.rb b/spec/ruby/core/fixnum/bit_length_spec.rb
new file mode 100644
index 0000000000..8c9f69b7d7
--- /dev/null
+++ b/spec/ruby/core/fixnum/bit_length_spec.rb
@@ -0,0 +1,42 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#bit_length" do
+ it "returns the position of the leftmost bit of a positive number" do
+ 0.bit_length.should == 0
+ 1.bit_length.should == 1
+ 2.bit_length.should == 2
+ 3.bit_length.should == 2
+ 4.bit_length.should == 3
+ n = fixnum_max.bit_length
+ fixnum_max[n].should == 0
+ fixnum_max[n-1].should == 1
+
+ 0.bit_length.should == 0
+ 1.bit_length.should == 1
+ 0xff.bit_length.should == 8
+ 0x100.bit_length.should == 9
+ (2**12-1).bit_length.should == 12
+ (2**12).bit_length.should == 13
+ (2**12+1).bit_length.should == 13
+ end
+
+ it "returns the position of the leftmost 0 bit of a negative number" do
+ -1.bit_length.should == 0
+ -2.bit_length.should == 1
+ -3.bit_length.should == 2
+ -4.bit_length.should == 2
+ -5.bit_length.should == 3
+ n = fixnum_min.bit_length
+ fixnum_min[n].should == 1
+ fixnum_min[n-1].should == 0
+
+ (-2**12-1).bit_length.should == 13
+ (-2**12).bit_length.should == 12
+ (-2**12+1).bit_length.should == 12
+ -0x101.bit_length.should == 9
+ -0x100.bit_length.should == 8
+ -0xff.bit_length.should == 8
+ -2.bit_length.should == 1
+ -1.bit_length.should == 0
+ end
+end
diff --git a/spec/ruby/core/fixnum/bit_or_spec.rb b/spec/ruby/core/fixnum/bit_or_spec.rb
new file mode 100644
index 0000000000..cd1865ffe9
--- /dev/null
+++ b/spec/ruby/core/fixnum/bit_or_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#|" do
+ it "returns self bitwise OR other" do
+ (1 | 0).should == 1
+ (5 | 4).should == 5
+ (5 | 6).should == 7
+ (248 | 4096).should == 4344
+ (0xffff | bignum_value + 0xf0f0).should == 0x8000_0000_0000_ffff
+ end
+
+ it "returns self bitwise OR a Bignum" do
+ (-1 | 2**64).should == -1
+ end
+
+ it "raises a TypeError when passed a Float" do
+ lambda { (3 | 3.4) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError and does not call #to_int when defined on an object" do
+ obj = mock("fixnum bit or")
+ obj.should_not_receive(:to_int)
+
+ lambda { 3 | obj }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/bit_xor_spec.rb b/spec/ruby/core/fixnum/bit_xor_spec.rb
new file mode 100644
index 0000000000..38a90a4dfa
--- /dev/null
+++ b/spec/ruby/core/fixnum/bit_xor_spec.rb
@@ -0,0 +1,24 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#^" do
+ it "returns self bitwise EXCLUSIVE OR other" do
+ (3 ^ 5).should == 6
+ (-2 ^ -255).should == 255
+ (5 ^ bignum_value + 0xffff_ffff).should == 0x8000_0000_ffff_fffa
+ end
+
+ it "returns self bitwise EXCLUSIVE OR a Bignum" do
+ (-1 ^ 2**64).should == -18446744073709551617
+ end
+
+ it "raises a TypeError when passed a Float" do
+ lambda { (3 ^ 3.4) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError and does not call #to_int when defined on an object" do
+ obj = mock("fixnum bit xor")
+ obj.should_not_receive(:to_int)
+
+ lambda { 3 ^ obj }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/case_compare_spec.rb b/spec/ruby/core/fixnum/case_compare_spec.rb
new file mode 100644
index 0000000000..53bfc38eb8
--- /dev/null
+++ b/spec/ruby/core/fixnum/case_compare_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
+
+describe "Fixnum#===" do
+ it_behaves_like :fixnum_equal, :===
+end
diff --git a/spec/ruby/core/fixnum/coerce_spec.rb b/spec/ruby/core/fixnum/coerce_spec.rb
new file mode 100644
index 0000000000..3ca7cb2df4
--- /dev/null
+++ b/spec/ruby/core/fixnum/coerce_spec.rb
@@ -0,0 +1,39 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#coerce when given a Fixnum" do
+ it "returns an array containing two Fixnums" do
+ 1.coerce(2).should == [2, 1]
+ 1.coerce(2).map { |i| i.class }.should == [Fixnum, Fixnum]
+ end
+end
+
+describe "Fixnum#coerce when given a String" do
+ it "raises an ArgumentError when trying to coerce with a non-number String" do
+ lambda { 1.coerce(":)") }.should raise_error(ArgumentError)
+ end
+
+ it "returns an array containing two Floats" do
+ 1.coerce("2").should == [2.0, 1.0]
+ 1.coerce("-2").should == [-2.0, 1.0]
+ end
+end
+
+describe "Fixnum#coerce" do
+ it "raises a TypeError when trying to coerce with nil" do
+ lambda { 1.coerce(nil) }.should raise_error(TypeError)
+ end
+
+ it "tries to convert the given Object into a Float by using #to_f" do
+ (obj = mock('1.0')).should_receive(:to_f).and_return(1.0)
+ 2.coerce(obj).should == [1.0, 2.0]
+
+ (obj = mock('0')).should_receive(:to_f).and_return('0')
+ lambda { 2.coerce(obj).should == [1.0, 2.0] }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when given an Object that does not respond to #to_f" do
+ lambda { 1.coerce(mock('x')) }.should raise_error(TypeError)
+ lambda { 1.coerce(1..4) }.should raise_error(TypeError)
+ lambda { 1.coerce(:test) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/comparison_spec.rb b/spec/ruby/core/fixnum/comparison_spec.rb
new file mode 100644
index 0000000000..4c932d213d
--- /dev/null
+++ b/spec/ruby/core/fixnum/comparison_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#<=>" do
+ it "returns -1 when self is less than the given argument" do
+ (-3 <=> -1).should == -1
+ (-5 <=> 10).should == -1
+ (-5 <=> -4.5).should == -1
+ end
+
+ it "returns 0 when self is equal to the given argument" do
+ (0 <=> 0).should == 0
+ (954 <=> 954).should == 0
+ (954 <=> 954.0).should == 0
+ end
+
+ it "returns 1 when self is greater than the given argument" do
+ (496 <=> 5).should == 1
+ (200 <=> 100).should == 1
+ (51 <=> 50.5).should == 1
+ end
+
+ it "returns nil when the given argument is not an Integer" do
+ (3 <=> mock('x')).should == nil
+ (3 <=> 'test').should == nil
+ end
+end
diff --git a/spec/ruby/core/fixnum/complement_spec.rb b/spec/ruby/core/fixnum/complement_spec.rb
new file mode 100644
index 0000000000..06692579c5
--- /dev/null
+++ b/spec/ruby/core/fixnum/complement_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#~" do
+ it "returns self with each bit flipped" do
+ (~0).should == -1
+ (~1221).should == -1222
+ (~-2).should == 1
+ (~-599).should == 598
+ end
+end
diff --git a/spec/ruby/core/fixnum/div_spec.rb b/spec/ruby/core/fixnum/div_spec.rb
new file mode 100644
index 0000000000..be9b498508
--- /dev/null
+++ b/spec/ruby/core/fixnum/div_spec.rb
@@ -0,0 +1,44 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#div with a Fixnum" do
+ it "returns self divided by the given argument as an Integer" do
+ 2.div(2).should == 1
+ 1.div(2).should == 0
+ 5.div(2).should == 2
+ end
+end
+
+describe "Fixnum#div" do
+ it "rounds towards -inf" do
+ 8192.div(10).should == 819
+ 8192.div(-10).should == -820
+ (-8192).div(10).should == -820
+ (-8192).div(-10).should == 819
+ end
+
+ it "coerces self and the given argument to Floats and returns self divided by other as Fixnum" do
+ 1.div(0.2).should == 5
+ 1.div(0.16).should == 6
+ 1.div(0.169).should == 5
+ -1.div(50.4).should == -1
+ 1.div(bignum_value).should == 0
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
+ lambda { 0.div(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { 10.div(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { -10.div(0.0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0" do
+ lambda { 13.div(0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13.div(obj)
+ }.should raise_error(TypeError)
+ lambda { 5.div("2") }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/divide_spec.rb b/spec/ruby/core/fixnum/divide_spec.rb
new file mode 100644
index 0000000000..1e7c17e58f
--- /dev/null
+++ b/spec/ruby/core/fixnum/divide_spec.rb
@@ -0,0 +1,35 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#/" do
+ it "returns self divided by the given argument" do
+ (2 / 2).should == 1
+ (3 / 2).should == 1
+ end
+
+ it "supports dividing negative numbers" do
+ (-1 / 10).should == -1
+ end
+
+ it "raises a ZeroDivisionError if the given argument is zero and not a Float" do
+ lambda { 1 / 0 }.should raise_error(ZeroDivisionError)
+ end
+
+ it "does NOT raise ZeroDivisionError if the given argument is zero and is a Float" do
+ (1 / 0.0).to_s.should == 'Infinity'
+ (-1 / 0.0).to_s.should == '-Infinity'
+ end
+
+ it "coerces fixnum and return self divided by other" do
+ (-1 / 50.4).should be_close(-0.0198412698412698, TOLERANCE)
+ (1 / bignum_value).should == 0
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13 / obj
+ }.should raise_error(TypeError)
+ lambda { 13 / "10" }.should raise_error(TypeError)
+ lambda { 13 / :symbol }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/divmod_spec.rb b/spec/ruby/core/fixnum/divmod_spec.rb
new file mode 100644
index 0000000000..21c9afe315
--- /dev/null
+++ b/spec/ruby/core/fixnum/divmod_spec.rb
@@ -0,0 +1,35 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#divmod" do
+ it "returns an Array containing quotient and modulus obtained from dividing self by the given argument" do
+ 13.divmod(4).should == [3, 1]
+ 4.divmod(13).should == [0, 4]
+
+ 13.divmod(4.0).should == [3, 1]
+ 4.divmod(13.0).should == [0, 4]
+
+ 1.divmod(2.0).should == [0, 1.0]
+ 200.divmod(bignum_value).should == [0, 200]
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0" do
+ lambda { 13.divmod(0) }.should raise_error(ZeroDivisionError)
+ lambda { 0.divmod(0) }.should raise_error(ZeroDivisionError)
+ lambda { -10.divmod(0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
+ lambda { 0.divmod(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { 10.divmod(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { -10.divmod(0.0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13.divmod(obj)
+ }.should raise_error(TypeError)
+ lambda { 13.divmod("10") }.should raise_error(TypeError)
+ lambda { 13.divmod(:symbol) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/element_reference_spec.rb b/spec/ruby/core/fixnum/element_reference_spec.rb
new file mode 100644
index 0000000000..736e8a549b
--- /dev/null
+++ b/spec/ruby/core/fixnum/element_reference_spec.rb
@@ -0,0 +1,80 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#[]" do
+ it "behaves like (n >> b) & 1" do
+ 0b101[1].should == 0
+ 0b101[2].should == 1
+ end
+
+ it "returns 1 if the nth bit is set" do
+ 15[1].should == 1
+ end
+
+ it "returns 1 if the nth bit is set (in two's-complement representation)" do
+ (-1)[1].should == 1
+ end
+
+ it "returns 0 if the nth bit is not set" do
+ 8[2].should == 0
+ end
+
+ it "returns 0 if the nth bit is not set (in two's-complement representation)" do
+ (-2)[0].should == 0
+ end
+
+ it "returns 0 if the nth bit is greater than the most significant bit" do
+ 2[3].should == 0
+ end
+
+ it "returns 1 if self is negative and the nth bit is greater than the most significant bit" do
+ (-1)[3].should == 1
+ end
+
+ it "returns 0 when passed a negative argument" do
+ 3[-1].should == 0
+ (-1)[-1].should == 0
+ end
+
+ it "calls #to_int to convert the argument to an Integer and returns 1 if the nth bit is set" do
+ obj = mock('1')
+ obj.should_receive(:to_int).and_return(1)
+
+ 2[obj].should == 1
+ end
+
+ it "calls #to_int to convert the argument to an Integer and returns 0 if the nth bit is set" do
+ obj = mock('0')
+ obj.should_receive(:to_int).and_return(0)
+
+ 2[obj].should == 0
+ end
+
+ it "accepts a Float argument and returns 0 if the bit at the truncated value is not set" do
+ 13[1.3].should == 0
+ end
+
+ it "accepts a Float argument and returns 1 if the bit at the truncated value is set" do
+ 13[2.1].should == 1
+ end
+
+ it "raises a TypeError when passed a String" do
+ lambda { 3["3"] }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when #to_int does not return an Integer" do
+ obj = mock('asdf')
+ obj.should_receive(:to_int).and_return("asdf")
+ lambda { 3[obj] }.should raise_error(TypeError)
+ end
+
+ it "calls #to_int to coerce a String to a Bignum and returns 0" do
+ obj = mock('bignum value')
+ obj.should_receive(:to_int).and_return(bignum_value)
+
+ 3[obj].should == 0
+ end
+
+ it "returns 0 when passed a Float in the range of a Bignum" do
+ 3[bignum_value.to_f].should == 0
+ end
+end
diff --git a/spec/ruby/core/fixnum/equal_value_spec.rb b/spec/ruby/core/fixnum/equal_value_spec.rb
new file mode 100644
index 0000000000..3a9ef93d24
--- /dev/null
+++ b/spec/ruby/core/fixnum/equal_value_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
+
+describe "Fixnum#==" do
+ it_behaves_like :fixnum_equal, :==
+end
diff --git a/spec/ruby/core/fixnum/even_spec.rb b/spec/ruby/core/fixnum/even_spec.rb
new file mode 100644
index 0000000000..1cafb7d3a0
--- /dev/null
+++ b/spec/ruby/core/fixnum/even_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#even?" do
+ it "is true for zero" do
+ 0.even?.should be_true
+ end
+
+ it "is true for even positive Fixnums" do
+ 4.even?.should be_true
+ end
+
+ it "is true for even negative Fixnums" do
+ (-4).even?.should be_true
+ end
+
+ it "is false for odd positive Fixnums" do
+ 5.even?.should be_false
+ end
+
+ it "is false for odd negative Fixnums" do
+ (-5).even?.should be_false
+ end
+end
diff --git a/spec/ruby/core/fixnum/exponent_spec.rb b/spec/ruby/core/fixnum/exponent_spec.rb
new file mode 100644
index 0000000000..f3e7349ace
--- /dev/null
+++ b/spec/ruby/core/fixnum/exponent_spec.rb
@@ -0,0 +1,76 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#**" do
+ it "returns self raised to the given power" do
+ (2 ** 0).should eql 1
+ (2 ** 1).should eql 2
+ (2 ** 2).should eql 4
+
+ (9 ** 0.5).should eql 3.0
+ (5 ** -1).to_f.to_s.should == '0.2'
+
+ (2 ** 40).should eql 1099511627776
+ end
+
+ it "overflows the answer to a bignum transparantly" do
+ (2 ** 29).should eql 536870912
+ (2 ** 30).should eql 1073741824
+ (2 ** 31).should eql 2147483648
+ (2 ** 32).should eql 4294967296
+
+ (2 ** 61).should eql 2305843009213693952
+ (2 ** 62).should eql 4611686018427387904
+ (2 ** 63).should eql 9223372036854775808
+ (2 ** 64).should eql 18446744073709551616
+ (8 ** 23).should eql 590295810358705651712
+ end
+
+ it "raises negative numbers to the given power" do
+ ((-2) ** 29).should eql(-536870912)
+ ((-2) ** 30).should eql(1073741824)
+ ((-2) ** 31).should eql(-2147483648)
+ ((-2) ** 32).should eql(4294967296)
+
+ ((-2) ** 61).should eql(-2305843009213693952)
+ ((-2) ** 62).should eql(4611686018427387904)
+ ((-2) ** 63).should eql(-9223372036854775808)
+ ((-2) ** 64).should eql(18446744073709551616)
+ end
+
+ it "can raise 1 to a Bignum safely" do
+ big = bignum_value(4611686018427387904)
+ (1 ** big).should eql 1
+ end
+
+ it "can raise -1 to a Bignum safely" do
+ ((-1) ** bignum_value(0)).should eql(1)
+ ((-1) ** bignum_value(1)).should eql(-1)
+ end
+
+ it "switches to a Float when the number is too big" do
+ big = bignum_value(4611686018427387904)
+ flt = (2 ** big)
+ flt.should be_kind_of(Float)
+ flt.infinite?.should == 1
+ end
+
+ conflicts_with :Rational do
+ it "raises a ZeroDivisionError for 0**-1" do
+ lambda { (0**-1) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13 ** obj
+ }.should raise_error(TypeError)
+ lambda { 13 ** "10" }.should raise_error(TypeError)
+ lambda { 13 ** :symbol }.should raise_error(TypeError)
+ end
+ end
+
+ it "returns a complex number when negative and raised to a fractional power" do
+ ((-8) ** (1.0/3)) .should be_close(Complex(1, 1.73205), TOLERANCE)
+ ((-8) ** Rational(1,3)).should be_close(Complex(1, 1.73205), TOLERANCE)
+ end
+end
diff --git a/spec/ruby/core/fixnum/fdiv_spec.rb b/spec/ruby/core/fixnum/fdiv_spec.rb
new file mode 100644
index 0000000000..bb5f09c333
--- /dev/null
+++ b/spec/ruby/core/fixnum/fdiv_spec.rb
@@ -0,0 +1,49 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#fdiv" do
+ it "performs floating-point division between self and a Fixnum" do
+ 8.fdiv(7).should be_close(1.14285714285714, TOLERANCE)
+ end
+
+ it "performs floating-point division between self and a Bignum" do
+ 8.fdiv(bignum_value).should be_close(8.673617379884035e-19, TOLERANCE)
+ end
+
+ it "performs floating-point division between self and a Float" do
+ 8.fdiv(9.0).should be_close(0.888888888888889, TOLERANCE)
+ end
+
+ it "returns NaN when the argument is NaN" do
+ -1.fdiv(nan_value).nan?.should be_true
+ 1.fdiv(nan_value).nan?.should be_true
+ end
+
+ it "returns Infinity when the argument is 0" do
+ 1.fdiv(0).infinite?.should == 1
+ end
+
+ it "returns -Infinity when the argument is 0 and self is negative" do
+ -1.fdiv(0).infinite?.should == -1
+ end
+
+ it "returns Infinity when the argument is 0.0" do
+ 1.fdiv(0.0).infinite?.should == 1
+ end
+
+ it "returns -Infinity when the argument is 0.0 and self is negative" do
+ -1.fdiv(0.0).infinite?.should == -1
+ end
+
+ it "raises a TypeError when argument isn't numeric" do
+ lambda { 1.fdiv(mock('non-numeric')) }.should raise_error(TypeError)
+ end
+
+ it "raises an ArgumentError when passed multiple arguments" do
+ lambda { 1.fdiv(6,0.2) }.should raise_error(ArgumentError)
+ end
+
+ it "follows the coercion protocol" do
+ (obj = mock('10')).should_receive(:coerce).with(1).and_return([1, 10])
+ 1.fdiv(obj).should == 0.1
+ end
+end
diff --git a/spec/ruby/core/fixnum/fixnum_spec.rb b/spec/ruby/core/fixnum/fixnum_spec.rb
new file mode 100644
index 0000000000..7f72f95e94
--- /dev/null
+++ b/spec/ruby/core/fixnum/fixnum_spec.rb
@@ -0,0 +1,31 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum" do
+ it "includes Comparable" do
+ Fixnum.include?(Comparable).should == true
+ end
+
+ it ".allocate raises a TypeError" do
+ lambda do
+ Fixnum.allocate
+ end.should raise_error(TypeError)
+ end
+
+ it ".new is undefined" do
+ lambda do
+ Fixnum.new
+ end.should raise_error(NoMethodError)
+ end
+
+ ruby_version_is '2.4' do
+ it "is unified into Integer" do
+ Fixnum.should equal(Integer)
+ end
+
+ it "is deprecated" do
+ -> {
+ Fixnum
+ }.should complain(/constant ::Fixnum is deprecated/)
+ end
+ end
+end
diff --git a/spec/ruby/core/fixnum/gt_spec.rb b/spec/ruby/core/fixnum/gt_spec.rb
new file mode 100644
index 0000000000..2fe70304ae
--- /dev/null
+++ b/spec/ruby/core/fixnum/gt_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#>" do
+ it "returns true if self is greater than the given argument" do
+ (13 > 2).should == true
+ (-500 > -600).should == true
+
+ (1 > 5).should == false
+ (5 > 5).should == false
+
+ (900 > bignum_value).should == false
+ (5 > 4.999).should == true
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { 5 > "4" }.should raise_error(ArgumentError)
+ lambda { 5 > mock('x') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/gte_spec.rb b/spec/ruby/core/fixnum/gte_spec.rb
new file mode 100644
index 0000000000..1d5c2b70f8
--- /dev/null
+++ b/spec/ruby/core/fixnum/gte_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#>=" do
+ it "returns true if self is greater than or equal to the given argument" do
+ (13 >= 2).should == true
+ (-500 >= -600).should == true
+
+ (1 >= 5).should == false
+ (2 >= 2).should == true
+ (5 >= 5).should == true
+
+ (900 >= bignum_value).should == false
+ (5 >= 4.999).should == true
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { 5 >= "4" }.should raise_error(ArgumentError)
+ lambda { 5 >= mock('x') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/hash_spec.rb b/spec/ruby/core/fixnum/hash_spec.rb
new file mode 100644
index 0000000000..de2996a7c6
--- /dev/null
+++ b/spec/ruby/core/fixnum/hash_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#hash" do
+ it "is provided" do
+ 1.respond_to?(:hash).should == true
+ end
+
+ it "is stable" do
+ 1.hash.should == 1.hash
+ end
+end
diff --git a/spec/ruby/core/fixnum/left_shift_spec.rb b/spec/ruby/core/fixnum/left_shift_spec.rb
new file mode 100644
index 0000000000..8eb5e424ff
--- /dev/null
+++ b/spec/ruby/core/fixnum/left_shift_spec.rb
@@ -0,0 +1,91 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#<< with n << m" do
+ it "returns n shifted left m bits when n > 0, m > 0" do
+ (1 << 1).should == 2
+ end
+
+ it "returns n shifted left m bits when n < 0, m > 0" do
+ (-1 << 1).should == -2
+ (-7 << 1).should == -14
+ (-42 << 2).should == -168
+ end
+
+ it "returns n shifted right m bits when n > 0, m < 0" do
+ (2 << -1).should == 1
+ end
+
+ it "returns n shifted right m bits when n < 0, m < 0" do
+ (-2 << -1).should == -1
+ end
+
+ it "returns 0 when n == 0" do
+ (0 << 1).should == 0
+ end
+
+ it "returns n when n > 0, m == 0" do
+ (1 << 0).should == 1
+ end
+
+ it "returns n when n < 0, m == 0" do
+ (-1 << 0).should == -1
+ end
+
+ it "returns 0 when n > 0, m < 0 and n < 2**-m" do
+ (3 << -2).should == 0
+ (7 << -3).should == 0
+ (127 << -7).should == 0
+
+ # To make sure the exponent is not truncated
+ (7 << -32).should == 0
+ (7 << -64).should == 0
+ end
+
+ it "returns -1 when n < 0, m < 0 and n > -(2**-m)" do
+ (-3 << -2).should == -1
+ (-7 << -3).should == -1
+ (-127 << -7).should == -1
+
+ # To make sure the exponent is not truncated
+ (-7 << -32).should == -1
+ (-7 << -64).should == -1
+ end
+
+ it "returns 0 when m < 0 and m is a Bignum" do
+ (3 << -bignum_value).should == 0
+ end
+
+ it "returns a Bignum == fixnum_max * 2 when fixnum_max << 1 and n > 0" do
+ result = fixnum_max << 1
+ result.should be_an_instance_of(Bignum)
+ result.should == fixnum_max * 2
+ end
+
+ it "returns a Bignum == fixnum_min * 2 when fixnum_min << 1 and n < 0" do
+ result = fixnum_min << 1
+ result.should be_an_instance_of(Bignum)
+ result.should == fixnum_min * 2
+ end
+
+ it "calls #to_int to convert the argument to an Integer" do
+ obj = mock("4")
+ obj.should_receive(:to_int).and_return(4)
+
+ (3 << obj).should == 48
+ end
+
+ it "raises a TypeError when #to_int does not return an Integer" do
+ obj = mock("a string")
+ obj.should_receive(:to_int).and_return("asdf")
+
+ lambda { 3 << obj }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed nil" do
+ lambda { 3 << nil }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed a String" do
+ lambda { 3 << "4" }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/lt_spec.rb b/spec/ruby/core/fixnum/lt_spec.rb
new file mode 100644
index 0000000000..0bedf428b2
--- /dev/null
+++ b/spec/ruby/core/fixnum/lt_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#<" do
+ it "returns true if self is less than the given argument" do
+ (2 < 13).should == true
+ (-600 < -500).should == true
+
+ (5 < 1).should == false
+ (5 < 5).should == false
+
+ (900 < bignum_value).should == true
+ (5 < 4.999).should == false
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { 5 < "4" }.should raise_error(ArgumentError)
+ lambda { 5 < mock('x') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/lte_spec.rb b/spec/ruby/core/fixnum/lte_spec.rb
new file mode 100644
index 0000000000..b9e5810d26
--- /dev/null
+++ b/spec/ruby/core/fixnum/lte_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#<=" do
+ it "returns true if self is less than or equal to other" do
+ (2 <= 13).should == true
+ (-600 <= -500).should == true
+
+ (5 <= 1).should == false
+ (5 <= 5).should == true
+ (-2 <= -2).should == true
+
+ (900 <= bignum_value).should == true
+ (5 <= 4.999).should == false
+ end
+
+ it "raises an ArgumentError when given a non-Integer" do
+ lambda { 5 <= "4" }.should raise_error(ArgumentError)
+ lambda { 5 <= mock('x') }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/magnitude_spec.rb b/spec/ruby/core/fixnum/magnitude_spec.rb
new file mode 100644
index 0000000000..dc250eba19
--- /dev/null
+++ b/spec/ruby/core/fixnum/magnitude_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/abs', __FILE__)
+
+describe "Fixnum#magnitude" do
+ it_behaves_like :fixnum_abs, :magnitude
+end
diff --git a/spec/ruby/core/fixnum/minus_spec.rb b/spec/ruby/core/fixnum/minus_spec.rb
new file mode 100644
index 0000000000..de3af05179
--- /dev/null
+++ b/spec/ruby/core/fixnum/minus_spec.rb
@@ -0,0 +1,29 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#-" do
+ it "returns self minus the given Integer" do
+ (5 - 10).should == -5
+ (9237212 - 5_280).should == 9231932
+
+ (781 - 0.5).should == 780.5
+ (2_560_496 - bignum_value).should == -9223372036852215312
+ end
+
+ it "returns a Bignum only if the result is too large to be a Fixnum" do
+ (5 - 10).should be_an_instance_of Fixnum
+ (-1 - bignum_value).should be_an_instance_of Bignum
+
+ bignum_zero = bignum_value.coerce(0).first
+ (1 - bignum_zero).should be_an_instance_of Fixnum
+ (fixnum_min - 1).should be_an_instance_of(Bignum)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13 - obj
+ }.should raise_error(TypeError)
+ lambda { 13 - "10" }.should raise_error(TypeError)
+ lambda { 13 - :symbol }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/modulo_spec.rb b/spec/ruby/core/fixnum/modulo_spec.rb
new file mode 100644
index 0000000000..19d3291a11
--- /dev/null
+++ b/spec/ruby/core/fixnum/modulo_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/modulo', __FILE__)
+
+describe "Fixnum#%" do
+ it_behaves_like(:fixnum_modulo, :%)
+end
+
+describe "Fixnum#modulo" do
+ it_behaves_like(:fixnum_modulo, :modulo)
+end
diff --git a/spec/ruby/core/fixnum/multiply_spec.rb b/spec/ruby/core/fixnum/multiply_spec.rb
new file mode 100644
index 0000000000..2eabd7b632
--- /dev/null
+++ b/spec/ruby/core/fixnum/multiply_spec.rb
@@ -0,0 +1,27 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#*" do
+ it "returns self multiplied by the given Integer" do
+ (4923 * 2).should == 9846
+ (1342177 * 800).should == 1073741600
+ (65536 * 65536).should == 4294967296
+
+ (256 * bignum_value).should == 2361183241434822606848
+ (6712 * 0.25).should == 1678.0
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13 * obj
+ }.should raise_error(TypeError)
+ lambda { 13 * "10" }.should raise_error(TypeError)
+ lambda { 13 * :symbol }.should raise_error(TypeError)
+ end
+
+ it "overflows to Bignum when the result does not fit in Fixnum" do
+ (fixnum_max * fixnum_max).should be_kind_of(Bignum)
+ (fixnum_max * fixnum_min).should be_kind_of(Bignum)
+ end
+
+end
diff --git a/spec/ruby/core/fixnum/odd_spec.rb b/spec/ruby/core/fixnum/odd_spec.rb
new file mode 100644
index 0000000000..3cf6bf45ed
--- /dev/null
+++ b/spec/ruby/core/fixnum/odd_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#odd?" do
+ it "is false for zero" do
+ 0.odd?.should be_false
+ end
+
+ it "is false for even positive Fixnums" do
+ 4.odd?.should be_false
+ end
+
+ it "is false for even negative Fixnums" do
+ (-4).odd?.should be_false
+ end
+
+ it "is true for odd positive Fixnums" do
+ 5.odd?.should be_true
+ end
+
+ it "is true for odd negative Fixnums" do
+ (-5).odd?.should be_true
+ end
+end
diff --git a/spec/ruby/core/fixnum/plus_spec.rb b/spec/ruby/core/fixnum/plus_spec.rb
new file mode 100644
index 0000000000..4754bfeaf8
--- /dev/null
+++ b/spec/ruby/core/fixnum/plus_spec.rb
@@ -0,0 +1,29 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#+" do
+ it "returns self plus the given Integer" do
+ (491 + 2).should == 493
+ (90210 + 10).should == 90220
+
+ (9 + bignum_value).should == 9223372036854775817
+ (1001 + 5.219).should == 1006.219
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13 + obj
+ }.should raise_error(TypeError)
+ lambda { 13 + "10" }.should raise_error(TypeError)
+ lambda { 13 + :symbol }.should raise_error(TypeError)
+ end
+
+ it "overflows to Bignum when the result does not fit in Fixnum" do
+ (5 + 10).should be_an_instance_of Fixnum
+ (1 + bignum_value).should be_an_instance_of Bignum
+
+ bignum_zero = bignum_value.coerce(0).first
+ (1 + bignum_zero).should be_an_instance_of Fixnum
+ (fixnum_max + 1).should be_an_instance_of(Bignum)
+ end
+end
diff --git a/spec/ruby/core/fixnum/right_shift_spec.rb b/spec/ruby/core/fixnum/right_shift_spec.rb
new file mode 100644
index 0000000000..9a221ddbe7
--- /dev/null
+++ b/spec/ruby/core/fixnum/right_shift_spec.rb
@@ -0,0 +1,91 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#>> with n >> m" do
+ it "returns n shifted right m bits when n > 0, m > 0" do
+ (2 >> 1).should == 1
+ end
+
+ it "returns n shifted right m bits when n < 0, m > 0" do
+ (-2 >> 1).should == -1
+ (-7 >> 1).should == -4
+ (-42 >> 2).should == -11
+ end
+
+ it "returns n shifted left m bits when n > 0, m < 0" do
+ (1 >> -1).should == 2
+ end
+
+ it "returns n shifted left m bits when n < 0, m < 0" do
+ (-1 >> -1).should == -2
+ end
+
+ it "returns 0 when n == 0" do
+ (0 >> 1).should == 0
+ end
+
+ it "returns n when n > 0, m == 0" do
+ (1 >> 0).should == 1
+ end
+
+ it "returns n when n < 0, m == 0" do
+ (-1 >> 0).should == -1
+ end
+
+ it "returns 0 when n > 0, m > 0 and n < 2**m" do
+ (3 >> 2).should == 0
+ (7 >> 3).should == 0
+ (127 >> 7).should == 0
+
+ # To make sure the exponent is not truncated
+ (7 >> 32).should == 0
+ (7 >> 64).should == 0
+ end
+
+ it "returns -1 when n < 0, m > 0 and n > -(2**m)" do
+ (-3 >> 2).should == -1
+ (-7 >> 3).should == -1
+ (-127 >> 7).should == -1
+
+ # To make sure the exponent is not truncated
+ (-7 >> 32).should == -1
+ (-7 >> 64).should == -1
+ end
+
+ it "returns 0 when m is a Bignum" do
+ (3 >> bignum_value).should == 0
+ end
+
+ it "returns a Bignum == fixnum_max * 2 when fixnum_max >> -1 and n > 0" do
+ result = fixnum_max >> -1
+ result.should be_an_instance_of(Bignum)
+ result.should == fixnum_max * 2
+ end
+
+ it "returns a Bignum == fixnum_min * 2 when fixnum_min >> -1 and n < 0" do
+ result = fixnum_min >> -1
+ result.should be_an_instance_of(Bignum)
+ result.should == fixnum_min * 2
+ end
+
+ it "calls #to_int to convert the argument to an Integer" do
+ obj = mock("2")
+ obj.should_receive(:to_int).and_return(2)
+
+ (8 >> obj).should == 2
+ end
+
+ it "raises a TypeError when #to_int does not return an Integer" do
+ obj = mock("a string")
+ obj.should_receive(:to_int).and_return("asdf")
+
+ lambda { 3 >> obj }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed nil" do
+ lambda { 3 >> nil }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed a String" do
+ lambda { 3 >> "4" }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/shared/abs.rb b/spec/ruby/core/fixnum/shared/abs.rb
new file mode 100644
index 0000000000..511ec5221b
--- /dev/null
+++ b/spec/ruby/core/fixnum/shared/abs.rb
@@ -0,0 +1,9 @@
+describe :fixnum_abs, shared: true do
+ it "returns self's absolute value" do
+ { 0 => [0, -0, +0], 2 => [2, -2, +2], 100 => [100, -100, +100] }.each do |key, values|
+ values.each do |value|
+ value.send(@method).should == key
+ end
+ end
+ end
+end
diff --git a/spec/ruby/core/fixnum/shared/equal.rb b/spec/ruby/core/fixnum/shared/equal.rb
new file mode 100644
index 0000000000..01c763f316
--- /dev/null
+++ b/spec/ruby/core/fixnum/shared/equal.rb
@@ -0,0 +1,24 @@
+describe :fixnum_equal, shared: true do
+ it "returns true if self has the same value as other" do
+ 1.send(@method, 1).should == true
+ 9.send(@method, 5).should == false
+
+ # Actually, these call Float#==, Bignum#== etc.
+ 9.send(@method, 9.0).should == true
+ 9.send(@method, 9.01).should == false
+
+ 10.send(@method, bignum_value).should == false
+ end
+
+ it "calls 'other == self' if the given argument is not a Fixnum" do
+ 1.send(@method, '*').should == false
+
+ obj = mock('one other')
+ obj.should_receive(:==).any_number_of_times.and_return(false)
+ 1.send(@method, obj).should == false
+
+ obj = mock('another')
+ obj.should_receive(:==).any_number_of_times.and_return(true)
+ 2.send(@method, obj).should == true
+ end
+end
diff --git a/spec/ruby/core/fixnum/shared/modulo.rb b/spec/ruby/core/fixnum/shared/modulo.rb
new file mode 100644
index 0000000000..a2f9a2691d
--- /dev/null
+++ b/spec/ruby/core/fixnum/shared/modulo.rb
@@ -0,0 +1,42 @@
+describe :fixnum_modulo, shared: true do
+ it "returns the modulus obtained from dividing self by the given argument" do
+ 13.send(@method, 4).should == 1
+ 4.send(@method, 13).should == 4
+
+ 13.send(@method, 4.0).should == 1
+ 4.send(@method, 13.0).should == 4
+
+ (-200).send(@method, 256).should == 56
+ (-1000).send(@method, 512).should == 24
+
+ (-200).send(@method, -256).should == -200
+ (-1000).send(@method, -512).should == -488
+
+ (200).send(@method, -256).should == -56
+ (1000).send(@method, -512).should == -24
+
+ 1.send(@method, 2.0).should == 1.0
+ 200.send(@method, bignum_value).should == 200
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0" do
+ lambda { 13.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ lambda { 0.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ lambda { -10.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
+ lambda { 0.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
+ lambda { 10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
+ lambda { -10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
+ 13.send(@method, obj)
+ }.should raise_error(TypeError)
+ lambda { 13.send(@method, "10") }.should raise_error(TypeError)
+ lambda { 13.send(@method, :symbol) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/fixnum/size_spec.rb b/spec/ruby/core/fixnum/size_spec.rb
new file mode 100644
index 0000000000..f973d446ed
--- /dev/null
+++ b/spec/ruby/core/fixnum/size_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#size" do
+ platform_is wordsize: 32 do
+ it "returns the number of bytes in the machine representation of self" do
+ -1.size.should == 4
+ 0.size.should == 4
+ 4091.size.should == 4
+ end
+ end
+
+ platform_is wordsize: 64 do
+ it "returns the number of bytes in the machine representation of self" do
+ -1.size.should == 8
+ 0.size.should == 8
+ 4091.size.should == 8
+ end
+ end
+end
diff --git a/spec/ruby/core/fixnum/succ_spec.rb b/spec/ruby/core/fixnum/succ_spec.rb
new file mode 100644
index 0000000000..50dd8c9481
--- /dev/null
+++ b/spec/ruby/core/fixnum/succ_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#succ" do
+ it "returns the next larger positive Fixnum" do
+ 2.succ.should == 3
+ end
+
+ it "returns the next larger negative Fixnum" do
+ (-2).succ.should == -1
+ end
+
+ it "overflows a Fixnum to a Bignum" do
+ fixnum_max.succ.should == (fixnum_max + 1)
+ end
+end
diff --git a/spec/ruby/core/fixnum/to_f_spec.rb b/spec/ruby/core/fixnum/to_f_spec.rb
new file mode 100644
index 0000000000..1d66348a5a
--- /dev/null
+++ b/spec/ruby/core/fixnum/to_f_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#to_f" do
+ it "returns self converted to a Float" do
+ 0.to_f.should == 0.0
+ -500.to_f.should == -500.0
+ 9_641_278.to_f.should == 9641278.0
+ end
+end
diff --git a/spec/ruby/core/fixnum/to_s_spec.rb b/spec/ruby/core/fixnum/to_s_spec.rb
new file mode 100644
index 0000000000..4a6649237b
--- /dev/null
+++ b/spec/ruby/core/fixnum/to_s_spec.rb
@@ -0,0 +1,50 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#to_s when given a base" do
+ it "returns self converted to a String in the given base" do
+ 12345.to_s(2).should == "11000000111001"
+ 12345.to_s(8).should == "30071"
+ 12345.to_s(10).should == "12345"
+ 12345.to_s(16).should == "3039"
+ 95.to_s(16).should == "5f"
+ 12345.to_s(36).should == "9ix"
+ end
+
+ it "raises an ArgumentError if the base is less than 2 or higher than 36" do
+ lambda { 123.to_s(-1) }.should raise_error(ArgumentError)
+ lambda { 123.to_s(0) }.should raise_error(ArgumentError)
+ lambda { 123.to_s(1) }.should raise_error(ArgumentError)
+ lambda { 123.to_s(37) }.should raise_error(ArgumentError)
+ end
+end
+
+describe "Fixnum#to_s when no base given" do
+ it "returns self converted to a String using base 10" do
+ 255.to_s.should == '255'
+ 3.to_s.should == '3'
+ 0.to_s.should == '0'
+ -9002.to_s.should == '-9002'
+ end
+end
+
+with_feature :encoding do
+ describe "Fixnum#to_s" do
+ before :each do
+ @internal = Encoding.default_internal
+ end
+
+ after :each do
+ Encoding.default_internal = @internal
+ end
+
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ 1.to_s.encoding.should equal(Encoding::US_ASCII)
+ end
+
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
+ Encoding.default_internal = Encoding::IBM437
+ 1.to_s.encoding.should equal(Encoding::US_ASCII)
+ end
+ end
+end
diff --git a/spec/ruby/core/fixnum/uminus_spec.rb b/spec/ruby/core/fixnum/uminus_spec.rb
new file mode 100644
index 0000000000..ac676400d1
--- /dev/null
+++ b/spec/ruby/core/fixnum/uminus_spec.rb
@@ -0,0 +1,16 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#-@" do
+ it "returns self as a negative value" do
+ 2.send(:-@).should == -2
+ -2.should == -2
+ -268435455.should == -268435455
+ (--5).should == 5
+ -8.send(:-@).should == 8
+ end
+
+ it "negates self at Fixnum/Bignum boundaries" do
+ fixnum_max.send(:-@).should == (0 - fixnum_max)
+ fixnum_min.send(:-@).should == (0 - fixnum_min)
+ end
+end
diff --git a/spec/ruby/core/fixnum/zero_spec.rb b/spec/ruby/core/fixnum/zero_spec.rb
new file mode 100644
index 0000000000..e155f9f5e6
--- /dev/null
+++ b/spec/ruby/core/fixnum/zero_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Fixnum#zero?" do
+ it "returns true if self is 0" do
+ 0.zero?.should == true
+ -1.zero?.should == false
+ 1.zero?.should == false
+ end
+end
diff --git a/spec/ruby/core/float/abs_spec.rb b/spec/ruby/core/float/abs_spec.rb
index a08601926d..3ff2e4369b 100644
--- a/spec/ruby/core/float/abs_spec.rb
+++ b/spec/ruby/core/float/abs_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/abs'
+require File.expand_path('../shared/abs', __FILE__)
describe "Float#abs" do
- it_behaves_like :float_abs, :abs
+ it_behaves_like(:float_abs, :abs)
end
diff --git a/spec/ruby/core/float/angle_spec.rb b/spec/ruby/core/float/angle_spec.rb
index c07249aa97..2a5d40ad30 100644
--- a/spec/ruby/core/float/angle_spec.rb
+++ b/spec/ruby/core/float/angle_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../shared/complex/float/arg', __FILE__)
describe "Float#angle" do
it_behaves_like :float_arg, :angle
diff --git a/spec/ruby/core/float/arg_spec.rb b/spec/ruby/core/float/arg_spec.rb
index d3a50668f8..20a8ac0a63 100644
--- a/spec/ruby/core/float/arg_spec.rb
+++ b/spec/ruby/core/float/arg_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../shared/complex/float/arg', __FILE__)
describe "Float#arg" do
it_behaves_like :float_arg, :arg
diff --git a/spec/ruby/core/float/case_compare_spec.rb b/spec/ruby/core/float/case_compare_spec.rb
index b902fbea18..c2ad2941e0 100644
--- a/spec/ruby/core/float/case_compare_spec.rb
+++ b/spec/ruby/core/float/case_compare_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
describe "Float#===" do
it_behaves_like :float_equal, :===
diff --git a/spec/ruby/core/float/ceil_spec.rb b/spec/ruby/core/float/ceil_spec.rb
index 7fc18d304c..f1d9dcd823 100644
--- a/spec/ruby/core/float/ceil_spec.rb
+++ b/spec/ruby/core/float/ceil_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#ceil" do
it "returns the smallest Integer greater than or equal to self" do
@@ -11,11 +11,13 @@ describe "Float#ceil" do
+9223372036854775808.1.ceil.should eql(+9223372036854775808)
end
- it "returns the smallest number greater than or equal to self with an optionally given precision" do
- 2.1679.ceil(0).should eql(3)
- 214.94.ceil(-1).should eql(220)
- 7.0.ceil(1).should eql(7.0)
- -1.234.ceil(2).should eql(-1.23)
- 5.123812.ceil(4).should eql(5.1239)
+ ruby_version_is "2.4" do
+ it "returns the smallest number greater than or equal to self with an optionally given precision" do
+ 2.1679.ceil(0).should eql(3)
+ 214.94.ceil(-1).should eql(220)
+ 7.0.ceil(1).should eql(7.0)
+ -1.234.ceil(2).should eql(-1.23)
+ 5.123812.ceil(4).should eql(5.1239)
+ end
end
end
diff --git a/spec/ruby/core/float/coerce_spec.rb b/spec/ruby/core/float/coerce_spec.rb
index ea108f3303..90475f2680 100644
--- a/spec/ruby/core/float/coerce_spec.rb
+++ b/spec/ruby/core/float/coerce_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#coerce" do
it "returns [other, self] both as Floats" do
diff --git a/spec/ruby/core/float/comparison_spec.rb b/spec/ruby/core/float/comparison_spec.rb
index 2dc993a176..49c3debbe1 100644
--- a/spec/ruby/core/float/comparison_spec.rb
+++ b/spec/ruby/core/float/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#<=>" do
it "returns -1, 0, 1 when self is less than, equal, or greater than other" do
@@ -16,45 +16,13 @@ describe "Float#<=>" do
(1.0 <=> "1").should be_nil
end
- it "compares using #coerce when argument is not a Float" do
- klass = Class.new do
- attr_reader :call_count
- def coerce(other)
- @call_count ||= 0
- @call_count += 1
- [other, 42.0]
- end
- end
-
- coercible = klass.new
- (2.33 <=> coercible).should == -1
- (42.0 <=> coercible).should == 0
- (43.0 <=> coercible).should == 1
- coercible.call_count.should == 3
- end
-
- ruby_version_is "2.5" do
- it "raises TypeError when #coerce misbehaves" do
- klass = Class.new do
- def coerce(other)
- :incorrect
- end
- end
-
- bad_coercible = klass.new
- -> {
- 4.2 <=> bad_coercible
- }.should raise_error(TypeError, "coerce must return [x, y]")
- end
- end
-
# The 4 tests below are taken from matz's revision 23730 for Ruby trunk
#
it "returns 1 when self is Infinity and other is a Bignum" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end
- it "returns -1 when self is negative and other is Infinity" do
+ it "returns -1 when self is negative and other is Infinty" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end
diff --git a/spec/ruby/core/float/constants_spec.rb b/spec/ruby/core/float/constants_spec.rb
index 497e0ae188..31930b125a 100644
--- a/spec/ruby/core/float/constants_spec.rb
+++ b/spec/ruby/core/float/constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float constant" do
it "DIG is 15" do
diff --git a/spec/ruby/core/float/denominator_spec.rb b/spec/ruby/core/float/denominator_spec.rb
index 6f4fcfcf23..56f5d288cf 100644
--- a/spec/ruby/core/float/denominator_spec.rb
+++ b/spec/ruby/core/float/denominator_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#denominator" do
before :each do
diff --git a/spec/ruby/core/float/divide_spec.rb b/spec/ruby/core/float/divide_spec.rb
index d8f71a6b98..0acd7b20b4 100644
--- a/spec/ruby/core/float/divide_spec.rb
+++ b/spec/ruby/core/float/divide_spec.rb
@@ -1,10 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/coerce'
-require_relative 'shared/arithmetic_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/coerce.rb', __FILE__)
describe "Float#/" do
- it_behaves_like :float_arithmetic_exception_in_coerce, :/
-
it "returns self divided by other" do
(5.75 / -2).should be_close(-2.875,TOLERANCE)
(451.0 / 9.3).should be_close(48.494623655914,TOLERANCE)
@@ -33,7 +30,7 @@ describe "Float#/" do
end
it "raises a TypeError when given a non-Numeric" do
- -> { 13.0 / "10" }.should raise_error(TypeError)
- -> { 13.0 / :symbol }.should raise_error(TypeError)
+ lambda { 13.0 / "10" }.should raise_error(TypeError)
+ lambda { 13.0 / :symbol }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/float/divmod_spec.rb b/spec/ruby/core/float/divmod_spec.rb
index ec55dd3681..174f142c86 100644
--- a/spec/ruby/core/float/divmod_spec.rb
+++ b/spec/ruby/core/float/divmod_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#divmod" do
it "returns an [quotient, modulus] from dividing self by other" do
@@ -18,22 +18,22 @@ describe "Float#divmod" do
# Behaviour established as correct in r23953
it "raises a FloatDomainError if self is NaN" do
- -> { nan_value.divmod(1) }.should raise_error(FloatDomainError)
+ lambda { nan_value.divmod(1) }.should raise_error(FloatDomainError)
end
# Behaviour established as correct in r23953
it "raises a FloatDomainError if other is NaN" do
- -> { 1.divmod(nan_value) }.should raise_error(FloatDomainError)
+ lambda { 1.divmod(nan_value) }.should raise_error(FloatDomainError)
end
# Behaviour established as correct in r23953
it "raises a FloatDomainError if self is Infinity" do
- -> { infinity_value.divmod(1) }.should raise_error(FloatDomainError)
+ lambda { infinity_value.divmod(1) }.should raise_error(FloatDomainError)
end
it "raises a ZeroDivisionError if other is zero" do
- -> { 1.0.divmod(0) }.should raise_error(ZeroDivisionError)
- -> { 1.0.divmod(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { 1.0.divmod(0) }.should raise_error(ZeroDivisionError)
+ lambda { 1.0.divmod(0.0) }.should raise_error(ZeroDivisionError)
end
# redmine #5276"
diff --git a/spec/ruby/core/float/dup_spec.rb b/spec/ruby/core/float/dup_spec.rb
index 294da8e2bc..775dc2913c 100644
--- a/spec/ruby/core/float/dup_spec.rb
+++ b/spec/ruby/core/float/dup_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Float#dup" do
- it "returns self" do
- float = 2.4
- float.dup.should equal(float)
+ruby_version_is '2.4' do
+ describe "Float#dup" do
+ it "returns self" do
+ float = 2.4
+ float.dup.should equal(float)
+ end
end
end
diff --git a/spec/ruby/core/float/eql_spec.rb b/spec/ruby/core/float/eql_spec.rb
index 6b5f91db33..7c4eef8523 100644
--- a/spec/ruby/core/float/eql_spec.rb
+++ b/spec/ruby/core/float/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#eql?" do
it "returns true if other is a Float equal to self" do
diff --git a/spec/ruby/core/float/equal_value_spec.rb b/spec/ruby/core/float/equal_value_spec.rb
index 03eea5108e..19ef01fc1c 100644
--- a/spec/ruby/core/float/equal_value_spec.rb
+++ b/spec/ruby/core/float/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
describe "Float#==" do
it_behaves_like :float_equal, :==
diff --git a/spec/ruby/core/float/exponent_spec.rb b/spec/ruby/core/float/exponent_spec.rb
index a4c03469a7..5cbba43a27 100644
--- a/spec/ruby/core/float/exponent_spec.rb
+++ b/spec/ruby/core/float/exponent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#**" do
it "returns self raise to the other power" do
diff --git a/spec/ruby/core/float/fdiv_spec.rb b/spec/ruby/core/float/fdiv_spec.rb
index be25ee283b..632dd0f293 100644
--- a/spec/ruby/core/float/fdiv_spec.rb
+++ b/spec/ruby/core/float/fdiv_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quo', __FILE__)
describe "Float#fdiv" do
it_behaves_like :float_quo, :fdiv
diff --git a/spec/ruby/core/float/finite_spec.rb b/spec/ruby/core/float/finite_spec.rb
index c5fb3df849..d6a161d4e3 100644
--- a/spec/ruby/core/float/finite_spec.rb
+++ b/spec/ruby/core/float/finite_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#finite?" do
it "returns true for finite values" do
diff --git a/spec/ruby/core/float/fixtures/classes.rb b/spec/ruby/core/float/fixtures/classes.rb
deleted file mode 100644
index 2d80184e7d..0000000000
--- a/spec/ruby/core/float/fixtures/classes.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module FloatSpecs
- class CoerceError < StandardError
- end
-end
diff --git a/spec/ruby/core/float/float_spec.rb b/spec/ruby/core/float/float_spec.rb
index 263ae82079..f2931d184c 100644
--- a/spec/ruby/core/float/float_spec.rb
+++ b/spec/ruby/core/float/float_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float" do
it "includes Comparable" do
@@ -6,13 +6,13 @@ describe "Float" do
end
it ".allocate raises a TypeError" do
- -> do
+ lambda do
Float.allocate
end.should raise_error(TypeError)
end
it ".new is undefined" do
- -> do
+ lambda do
Float.new
end.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/float/floor_spec.rb b/spec/ruby/core/float/floor_spec.rb
index 046216d36d..6da5d5c5ee 100644
--- a/spec/ruby/core/float/floor_spec.rb
+++ b/spec/ruby/core/float/floor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#floor" do
it "returns the largest Integer less than or equal to self" do
@@ -11,11 +11,13 @@ describe "Float#floor" do
+9223372036854775808.1.floor.should eql(+9223372036854775808)
end
- it "returns the largest number less than or equal to self with an optionally given precision" do
- 2.1679.floor(0).should eql(2)
- 214.94.floor(-1).should eql(210)
- 7.0.floor(1).should eql(7.0)
- -1.234.floor(2).should eql(-1.24)
- 5.123812.floor(4).should eql(5.1238)
+ ruby_version_is "2.4" do
+ it "returns the largest number less than or equal to self with an optionally given precision" do
+ 2.1679.floor(0).should eql(2)
+ 214.94.floor(-1).should eql(210)
+ 7.0.floor(1).should eql(7.0)
+ -1.234.floor(2).should eql(-1.24)
+ 5.123812.floor(4).should eql(5.1238)
+ end
end
end
diff --git a/spec/ruby/core/float/gt_spec.rb b/spec/ruby/core/float/gt_spec.rb
index 0d73f1c3df..9725c6acd7 100644
--- a/spec/ruby/core/float/gt_spec.rb
+++ b/spec/ruby/core/float/gt_spec.rb
@@ -1,9 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#>" do
- it_behaves_like :float_comparison_exception_in_coerce, :>
-
it "returns true if self is greater than other" do
(1.5 > 1).should == true
(2.5 > 3).should == false
@@ -11,7 +8,7 @@ describe "Float#>" do
end
it "raises an ArgumentError when given a non-Numeric" do
- -> { 5.0 > "4" }.should raise_error(ArgumentError)
- -> { 5.0 > mock('x') }.should raise_error(ArgumentError)
+ lambda { 5.0 > "4" }.should raise_error(ArgumentError)
+ lambda { 5.0 > mock('x') }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/float/gte_spec.rb b/spec/ruby/core/float/gte_spec.rb
index 98ec60b70b..2c14651dd7 100644
--- a/spec/ruby/core/float/gte_spec.rb
+++ b/spec/ruby/core/float/gte_spec.rb
@@ -1,9 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#>=" do
- it_behaves_like :float_comparison_exception_in_coerce, :>=
-
it "returns true if self is greater than or equal to other" do
(5.2 >= 5.2).should == true
(9.71 >= 1).should == true
@@ -11,7 +8,7 @@ describe "Float#>=" do
end
it "raises an ArgumentError when given a non-Numeric" do
- -> { 5.0 >= "4" }.should raise_error(ArgumentError)
- -> { 5.0 >= mock('x') }.should raise_error(ArgumentError)
+ lambda { 5.0 >= "4" }.should raise_error(ArgumentError)
+ lambda { 5.0 >= mock('x') }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/float/hash_spec.rb b/spec/ruby/core/float/hash_spec.rb
index 5f77e3b4a1..c638e99347 100644
--- a/spec/ruby/core/float/hash_spec.rb
+++ b/spec/ruby/core/float/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#hash" do
it "is provided" do
diff --git a/spec/ruby/core/float/infinite_spec.rb b/spec/ruby/core/float/infinite_spec.rb
index 901c2738aa..4e31effab7 100644
--- a/spec/ruby/core/float/infinite_spec.rb
+++ b/spec/ruby/core/float/infinite_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#infinite?" do
it "returns nil for finite values" do
diff --git a/spec/ruby/core/float/lt_spec.rb b/spec/ruby/core/float/lt_spec.rb
index c01b6e0e02..e2e43b0fb7 100644
--- a/spec/ruby/core/float/lt_spec.rb
+++ b/spec/ruby/core/float/lt_spec.rb
@@ -1,9 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#<" do
- it_behaves_like :float_comparison_exception_in_coerce, :<
-
it "returns true if self is less than other" do
(71.3 < 91.8).should == true
(192.6 < -500).should == false
@@ -11,7 +8,7 @@ describe "Float#<" do
end
it "raises an ArgumentError when given a non-Numeric" do
- -> { 5.0 < "4" }.should raise_error(ArgumentError)
- -> { 5.0 < mock('x') }.should raise_error(ArgumentError)
+ lambda { 5.0 < "4" }.should raise_error(ArgumentError)
+ lambda { 5.0 < mock('x') }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/float/lte_spec.rb b/spec/ruby/core/float/lte_spec.rb
index 66f2ddc2c7..e2e44b2257 100644
--- a/spec/ruby/core/float/lte_spec.rb
+++ b/spec/ruby/core/float/lte_spec.rb
@@ -1,9 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#<=" do
- it_behaves_like :float_comparison_exception_in_coerce, :>=
-
it "returns true if self is less than or equal to other" do
(2.0 <= 3.14159).should == true
(-2.7183 <= -24).should == false
@@ -12,7 +9,7 @@ describe "Float#<=" do
end
it "raises an ArgumentError when given a non-Numeric" do
- -> { 5.0 <= "4" }.should raise_error(ArgumentError)
- -> { 5.0 <= mock('x') }.should raise_error(ArgumentError)
+ lambda { 5.0 <= "4" }.should raise_error(ArgumentError)
+ lambda { 5.0 <= mock('x') }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/float/magnitude_spec.rb b/spec/ruby/core/float/magnitude_spec.rb
index db577c15c5..042356f4c4 100644
--- a/spec/ruby/core/float/magnitude_spec.rb
+++ b/spec/ruby/core/float/magnitude_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'shared/abs'
+require File.expand_path('../shared/abs', __FILE__)
describe "Float#magnitude" do
- it_behaves_like :float_abs, :magnitude
+ it_behaves_like(:float_abs, :magnitude)
end
diff --git a/spec/ruby/core/float/minus_spec.rb b/spec/ruby/core/float/minus_spec.rb
index 5626cbdac2..d5c0d863ed 100644
--- a/spec/ruby/core/float/minus_spec.rb
+++ b/spec/ruby/core/float/minus_spec.rb
@@ -1,9 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arithmetic_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#-" do
- it_behaves_like :float_arithmetic_exception_in_coerce, :-
-
it "returns self minus other" do
(9_237_212.5280 - 5_280).should be_close(9231932.528, TOLERANCE)
(2_560_496.1691 - bignum_value).should be_close(-9223372036852215808.000, TOLERANCE)
diff --git a/spec/ruby/core/float/modulo_spec.rb b/spec/ruby/core/float/modulo_spec.rb
index 8ae80a0b05..f29e3870da 100644
--- a/spec/ruby/core/float/modulo_spec.rb
+++ b/spec/ruby/core/float/modulo_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/modulo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/modulo', __FILE__)
describe "Float#%" do
- it_behaves_like :float_modulo, :%
+ it_behaves_like(:float_modulo, :%)
end
describe "Float#modulo" do
- it_behaves_like :float_modulo, :modulo
+ it_behaves_like(:float_modulo, :modulo)
end
diff --git a/spec/ruby/core/float/multiply_spec.rb b/spec/ruby/core/float/multiply_spec.rb
index eca0b52c4f..14680534c4 100644
--- a/spec/ruby/core/float/multiply_spec.rb
+++ b/spec/ruby/core/float/multiply_spec.rb
@@ -1,9 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arithmetic_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#*" do
- it_behaves_like :float_arithmetic_exception_in_coerce, :*
-
it "returns self multiplied by other" do
(4923.98221 * 2).should be_close(9847.96442, TOLERANCE)
(6712.5 * 0.25).should be_close(1678.125, TOLERANCE)
@@ -11,7 +8,7 @@ describe "Float#*" do
end
it "raises a TypeError when given a non-Numeric" do
- -> { 13.0 * "10" }.should raise_error(TypeError)
- -> { 13.0 * :symbol }.should raise_error(TypeError)
+ lambda { 13.0 * "10" }.should raise_error(TypeError)
+ lambda { 13.0 * :symbol }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/float/nan_spec.rb b/spec/ruby/core/float/nan_spec.rb
index d09d25153c..95a61d8872 100644
--- a/spec/ruby/core/float/nan_spec.rb
+++ b/spec/ruby/core/float/nan_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#nan?" do
it "returns true if self is not a valid IEEE floating-point number" do
diff --git a/spec/ruby/core/float/next_float_spec.rb b/spec/ruby/core/float/next_float_spec.rb
index 2f0eff605a..d5a7748a06 100644
--- a/spec/ruby/core/float/next_float_spec.rb
+++ b/spec/ruby/core/float/next_float_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#next_float" do
it "returns a float the smallest possible step greater than the receiver" do
diff --git a/spec/ruby/core/float/numerator_spec.rb b/spec/ruby/core/float/numerator_spec.rb
index 7832e8f056..9644d01c23 100644
--- a/spec/ruby/core/float/numerator_spec.rb
+++ b/spec/ruby/core/float/numerator_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#numerator" do
before :all do
diff --git a/spec/ruby/core/float/phase_spec.rb b/spec/ruby/core/float/phase_spec.rb
index 2aa84024b4..95d0053816 100644
--- a/spec/ruby/core/float/phase_spec.rb
+++ b/spec/ruby/core/float/phase_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../shared/complex/float/arg', __FILE__)
describe "Float#phase" do
it_behaves_like :float_arg, :phase
diff --git a/spec/ruby/core/float/plus_spec.rb b/spec/ruby/core/float/plus_spec.rb
index 06b136a06b..a49124d303 100644
--- a/spec/ruby/core/float/plus_spec.rb
+++ b/spec/ruby/core/float/plus_spec.rb
@@ -1,9 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arithmetic_exception_in_coerce'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#+" do
- it_behaves_like :float_arithmetic_exception_in_coerce, :+
-
it "returns self plus other" do
(491.213 + 2).should be_close(493.213, TOLERANCE)
(9.99 + bignum_value).should be_close(9223372036854775808.000, TOLERANCE)
diff --git a/spec/ruby/core/float/prev_float_spec.rb b/spec/ruby/core/float/prev_float_spec.rb
index 40fcc25a6d..e07d78c44c 100644
--- a/spec/ruby/core/float/prev_float_spec.rb
+++ b/spec/ruby/core/float/prev_float_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#prev_float" do
it "returns a float the smallest possible step smaller than the receiver" do
diff --git a/spec/ruby/core/float/quo_spec.rb b/spec/ruby/core/float/quo_spec.rb
index b5c64f9d87..dcda8f5f3b 100644
--- a/spec/ruby/core/float/quo_spec.rb
+++ b/spec/ruby/core/float/quo_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quo', __FILE__)
describe "Float#quo" do
it_behaves_like :float_quo, :quo
diff --git a/spec/ruby/core/float/rationalize_spec.rb b/spec/ruby/core/float/rationalize_spec.rb
index 0c5bef7ac4..541080c48b 100644
--- a/spec/ruby/core/float/rationalize_spec.rb
+++ b/spec/ruby/core/float/rationalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#rationalize" do
it "returns self as a simplified Rational with no argument" do
@@ -29,15 +29,15 @@ describe "Float#rationalize" do
end
it "raises a FloatDomainError for Infinity" do
- -> {infinity_value.rationalize}.should raise_error(FloatDomainError)
+ lambda {infinity_value.rationalize}.should raise_error(FloatDomainError)
end
it "raises a FloatDomainError for NaN" do
- -> { nan_value.rationalize }.should raise_error(FloatDomainError)
+ lambda { nan_value.rationalize }.should raise_error(FloatDomainError)
end
it "raises ArgumentError when passed more than one argument" do
- -> { 0.3.rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
- -> { 0.3.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
+ lambda { 0.3.rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
+ lambda { 0.3.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/float/round_spec.rb b/spec/ruby/core/float/round_spec.rb
index e143682362..56668d5856 100644
--- a/spec/ruby/core/float/round_spec.rb
+++ b/spec/ruby/core/float/round_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#round" do
it "returns the nearest Integer" do
@@ -10,15 +10,17 @@ describe "Float#round" do
0.0.round.should == 0
end
- it "returns the nearest Integer for Float near the limit" do
- 0.49999999999999994.round.should == 0
- -0.49999999999999994.round.should == 0
+ platform_is_not :mingw32 do
+ it "returns the nearest Integer for Float near the limit" do
+ 0.49999999999999994.round.should == 0
+ -0.49999999999999994.round.should == 0
+ end
end
it "raises FloatDomainError for exceptional values" do
- -> { (+infinity_value).round }.should raise_error(FloatDomainError)
- -> { (-infinity_value).round }.should raise_error(FloatDomainError)
- -> { nan_value.round }.should raise_error(FloatDomainError)
+ lambda { (+infinity_value).round }.should raise_error(FloatDomainError)
+ lambda { (-infinity_value).round }.should raise_error(FloatDomainError)
+ lambda { nan_value.round }.should raise_error(FloatDomainError)
end
it "rounds self to an optionally given precision" do
@@ -30,25 +32,25 @@ describe "Float#round" do
12.345678.round(3.999).should == 12.346
end
- it "returns zero when passed a negative argument with magnitude greater than magnitude of the whole number portion of the Float" do
+ it "returns zero when passed a negative argument with magitude greater the magitude of the whole number portion of the Float" do
0.8346268.round(-1).should eql(0)
end
it "raises a TypeError when its argument can not be converted to an Integer" do
- -> { 1.0.round("4") }.should raise_error(TypeError)
- -> { 1.0.round(nil) }.should raise_error(TypeError)
+ lambda { 1.0.round("4") }.should raise_error(TypeError)
+ lambda { 1.0.round(nil) }.should raise_error(TypeError)
end
it "raises FloatDomainError for exceptional values when passed a non-positive precision" do
- -> { Float::INFINITY.round( 0) }.should raise_error(FloatDomainError)
- -> { Float::INFINITY.round(-2) }.should raise_error(FloatDomainError)
- -> { (-Float::INFINITY).round( 0) }.should raise_error(FloatDomainError)
- -> { (-Float::INFINITY).round(-2) }.should raise_error(FloatDomainError)
+ lambda { Float::INFINITY.round( 0) }.should raise_error(FloatDomainError)
+ lambda { Float::INFINITY.round(-2) }.should raise_error(FloatDomainError)
+ lambda { (-Float::INFINITY).round( 0) }.should raise_error(FloatDomainError)
+ lambda { (-Float::INFINITY).round(-2) }.should raise_error(FloatDomainError)
end
it "raises RangeError for NAN when passed a non-positive precision" do
- -> { Float::NAN.round(0) }.should raise_error(RangeError)
- -> { Float::NAN.round(-2) }.should raise_error(RangeError)
+ lambda { Float::NAN.round(0) }.should raise_error(RangeError)
+ lambda { Float::NAN.round(-2) }.should raise_error(RangeError)
end
it "returns self for exceptional values when passed a non-negative precision" do
@@ -83,35 +85,17 @@ describe "Float#round" do
-2.4e200.round(-200).should eql( -2 * 10 ** 200 )
end
- it "returns different rounded values depending on the half option" do
- 2.5.round(half: nil).should eql(3)
- 2.5.round(half: :up).should eql(3)
- 2.5.round(half: :down).should eql(2)
- 2.5.round(half: :even).should eql(2)
- 3.5.round(half: nil).should eql(4)
- 3.5.round(half: :up).should eql(4)
- 3.5.round(half: :down).should eql(3)
- 3.5.round(half: :even).should eql(4)
- (-2.5).round(half: nil).should eql(-3)
- (-2.5).round(half: :up).should eql(-3)
- (-2.5).round(half: :down).should eql(-2)
- (-2.5).round(half: :even).should eql(-2)
- end
-
- it "rounds self to an optionally given precision with a half option" do
- 5.55.round(1, half: nil).should eql(5.6)
- 5.55.round(1, half: :up).should eql(5.6)
- 5.55.round(1, half: :down).should eql(5.5)
- 5.55.round(1, half: :even).should eql(5.6)
- end
-
- it "raises FloatDomainError for exceptional values with a half option" do
- -> { (+infinity_value).round(half: :up) }.should raise_error(FloatDomainError)
- -> { (-infinity_value).round(half: :down) }.should raise_error(FloatDomainError)
- -> { nan_value.round(half: :even) }.should raise_error(FloatDomainError)
- end
-
- it "raise for a non-existent round mode" do
- -> { 14.2.round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
+ ruby_version_is "2.4" do
+ it "returns different rounded values depending on the half option" do
+ 2.5.round(half: :up).should eql(3)
+ 2.5.round(half: :down).should eql(2)
+ 2.5.round(half: :even).should eql(2)
+ 3.5.round(half: :up).should eql(4)
+ 3.5.round(half: :down).should eql(3)
+ 3.5.round(half: :even).should eql(4)
+ (-2.5).round(half: :up).should eql(-3)
+ (-2.5).round(half: :down).should eql(-2)
+ (-2.5).round(half: :even).should eql(-2)
+ end
end
end
diff --git a/spec/ruby/core/float/shared/abs.rb b/spec/ruby/core/float/shared/abs.rb
index 607983322d..c59198bfe2 100644
--- a/spec/ruby/core/float/shared/abs.rb
+++ b/spec/ruby/core/float/shared/abs.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :float_abs, shared: true do
it "returns the absolute value" do
diff --git a/spec/ruby/core/float/shared/arg.rb b/spec/ruby/core/float/shared/arg.rb
deleted file mode 100644
index 136cf19ec8..0000000000
--- a/spec/ruby/core/float/shared/arg.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-describe :float_arg, shared: true do
- it "returns NaN if NaN" do
- f = nan_value
- f.send(@method).nan?.should be_true
- end
-
- it "returns self if NaN" do
- f = nan_value
- f.send(@method).should equal(f)
- end
-
- it "returns 0 if positive" do
- 1.0.send(@method).should == 0
- end
-
- it "returns 0 if +0.0" do
- 0.0.send(@method).should == 0
- end
-
- it "returns 0 if +Infinity" do
- infinity_value.send(@method).should == 0
- end
-
- it "returns Pi if negative" do
- (-1.0).send(@method).should == Math::PI
- end
-
- # This was established in r23960
- it "returns Pi if -0.0" do
- (-0.0).send(@method).should == Math::PI
- end
-
- it "returns Pi if -Infinity" do
- (-infinity_value).send(@method).should == Math::PI
- end
-end
diff --git a/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb b/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb
deleted file mode 100644
index 19a02572d8..0000000000
--- a/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :float_arithmetic_exception_in_coerce, shared: true do
- ruby_version_is ""..."2.5" do
- it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
-
- # e.g. 1.0 > b
- -> { 1.0.send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Float/)
- end
-
- it "does not rescue Exception and StandardError siblings raised in other#coerce" do
- [Exception, NoMemoryError].each do |exception|
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(exception)
-
- # e.g. 1.0 > b
- -> { 1.0.send(@method, b) }.should raise_error(exception)
- end
- end
- end
-
- ruby_version_is "2.5" do
- it "does not rescue exception raised in other#coerce" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
-
- # e.g. 1.0 > b
- -> { 1.0.send(@method, b) }.should raise_error(FloatSpecs::CoerceError)
- end
- end
-end
diff --git a/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb b/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb
deleted file mode 100644
index f8ded53644..0000000000
--- a/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :float_comparison_exception_in_coerce, shared: true do
- ruby_version_is ""..."2.5" do
- it "rescues exception (StandardError and subclasses) raised in other#coerce and raises ArgumentError" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
-
- # e.g. 1.0 > b
- -> {
- -> { 1.0.send(@method, b) }.should raise_error(ArgumentError, /comparison of Float with MockObject failed/)
- }.should complain(/Numerical comparison operators will no more rescue exceptions of #coerce/)
- end
-
- it "does not rescue Exception and StandardError siblings raised in other#coerce" do
- [Exception, NoMemoryError].each do |exception|
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(exception)
-
- # e.g. 1.0 > b
- -> { 1.0.send(@method, b) }.should raise_error(exception)
- end
- end
- end
-
- ruby_version_is "2.5" do
- it "does not rescue exception raised in other#coerce" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
-
- # e.g. 1.0 > b
- -> { 1.0.send(@method, b) }.should raise_error(FloatSpecs::CoerceError)
- end
- end
-end
diff --git a/spec/ruby/core/float/shared/modulo.rb b/spec/ruby/core/float/shared/modulo.rb
index 6700bd4f4e..6c423a3a28 100644
--- a/spec/ruby/core/float/shared/modulo.rb
+++ b/spec/ruby/core/float/shared/modulo.rb
@@ -42,7 +42,7 @@ describe :float_modulo, shared: true do
end
it "raises a ZeroDivisionError if other is zero" do
- -> { 1.0.send(@method, 0) }.should raise_error(ZeroDivisionError)
- -> { 1.0.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
+ lambda { 1.0.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ lambda { 1.0.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/core/float/shared/quo.rb b/spec/ruby/core/float/shared/quo.rb
index 3487824f70..afc921a2c1 100644
--- a/spec/ruby/core/float/shared/quo.rb
+++ b/spec/ruby/core/float/shared/quo.rb
@@ -50,10 +50,10 @@ describe :float_quo, shared: true do
end
it "raises a TypeError when argument isn't numeric" do
- -> { 27292.2.send(@method, mock('non-numeric')) }.should raise_error(TypeError)
+ lambda { 27292.2.send(@method, mock('non-numeric')) }.should raise_error(TypeError)
end
it "raises an ArgumentError when passed multiple arguments" do
- -> { 272.221.send(@method, 6,0.2) }.should raise_error(ArgumentError)
+ lambda { 272.221.send(@method, 6,0.2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/float/to_f_spec.rb b/spec/ruby/core/float/to_f_spec.rb
index 6677556cd9..02666ae7d7 100644
--- a/spec/ruby/core/float/to_f_spec.rb
+++ b/spec/ruby/core/float/to_f_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#to_f" do
it "returns self" do
diff --git a/spec/ruby/core/float/to_i_spec.rb b/spec/ruby/core/float/to_i_spec.rb
index 91d84c5fa3..5bf5a1b42a 100644
--- a/spec/ruby/core/float/to_i_spec.rb
+++ b/spec/ruby/core/float/to_i_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
describe "Float#to_i" do
- it_behaves_like :float_to_i, :to_i
+ it_behaves_like(:float_to_i, :to_i)
end
diff --git a/spec/ruby/core/float/to_int_spec.rb b/spec/ruby/core/float/to_int_spec.rb
index 084a58b431..ba31ebc168 100644
--- a/spec/ruby/core/float/to_int_spec.rb
+++ b/spec/ruby/core/float/to_int_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
describe "Float#to_int" do
- it_behaves_like :float_to_i, :to_int
+ it_behaves_like(:float_to_i, :to_int)
end
diff --git a/spec/ruby/core/float/to_r_spec.rb b/spec/ruby/core/float/to_r_spec.rb
index 907ff08f27..a0f5cd9700 100644
--- a/spec/ruby/core/float/to_r_spec.rb
+++ b/spec/ruby/core/float/to_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#to_r" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/float/to_s_spec.rb b/spec/ruby/core/float/to_s_spec.rb
index ad04bc4fb6..e76cfc1b7e 100644
--- a/spec/ruby/core/float/to_s_spec.rb
+++ b/spec/ruby/core/float/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#to_s" do
it "returns 'NaN' for NaN" do
@@ -75,11 +75,11 @@ describe "Float#to_s" do
-10000000000000000.0.to_s.should == "-1.0e+16"
end
- it "uses e format for a positive value with whole part having 17 significant figures" do
+ it "uses non-e format for a positive value with whole part having 17 significant figures" do
1000000000000000.0.to_s.should == "1.0e+15"
end
- it "uses e format for a negative value with whole part having 17 significant figures" do
+ it "uses non-e format for a negative value with whole part having 17 significant figures" do
-1000000000000000.0.to_s.should == "-1.0e+15"
end
@@ -95,216 +95,26 @@ describe "Float#to_s" do
it "outputs the minimal, unique form to represent the value" do
0.56.to_s.should == "0.56"
end
+end
- describe "matches" do
- it "random examples in all ranges" do
- # 50.times do
- # bytes = (0...8).map { rand(256) }
- # string = bytes.pack('C8')
- # float = string.unpack('D').first
- # puts "#{'%.20g' % float}.to_s.should == #{float.to_s.inspect}"
- # end
-
- 2.5540217314354050325e+163.to_s.should == "2.554021731435405e+163"
- 2.5492588360356597544e-172.to_s.should == "2.5492588360356598e-172"
- 1.742770260934704852e-82.to_s.should == "1.7427702609347049e-82"
- 6.2108093676180883209e-104.to_s.should == "6.210809367618088e-104"
- -3.3448803488331067402e-143.to_s.should == "-3.3448803488331067e-143"
- -2.2740074343500832557e-168.to_s.should == "-2.2740074343500833e-168"
- 7.0587971678048535732e+191.to_s.should == "7.058797167804854e+191"
- -284438.88327586348169.to_s.should == "-284438.8832758635"
- 3.953272468476091301e+105.to_s.should == "3.9532724684760913e+105"
- -3.6361359552959847853e+100.to_s.should == "-3.636135955295985e+100"
- -1.3222325865575206185e-31.to_s.should == "-1.3222325865575206e-31"
- 1.1440138916932761366e+130.to_s.should == "1.1440138916932761e+130"
- 4.8750891560387561157e-286.to_s.should == "4.875089156038756e-286"
- 5.6101113356591453525e-257.to_s.should == "5.610111335659145e-257"
- -3.829644279545809575e-100.to_s.should == "-3.8296442795458096e-100"
- 1.5342839401396406117e-194.to_s.should == "1.5342839401396406e-194"
- 2.2284972755169921402e-144.to_s.should == "2.228497275516992e-144"
- 2.1825655917065601737e-61.to_s.should == "2.1825655917065602e-61"
- -2.6672271363524338322e-62.to_s.should == "-2.667227136352434e-62"
- -1.9257995160119059415e+21.to_s.should == "-1.925799516011906e+21"
- -8.9096732962887121718e-198.to_s.should == "-8.909673296288712e-198"
- 2.0202075376548644959e-90.to_s.should == "2.0202075376548645e-90"
- -7.7341602581786258961e-266.to_s.should == "-7.734160258178626e-266"
- 3.5134482598733635046e+98.to_s.should == "3.5134482598733635e+98"
- -2.124411722371029134e+154.to_s.should == "-2.124411722371029e+154"
- -4.573908787355718687e+110.to_s.should == "-4.573908787355719e+110"
- -1.9344425934170969879e-232.to_s.should == "-1.934442593417097e-232"
- -1.3274227399979271095e+171.to_s.should == "-1.3274227399979271e+171"
- 9.3495270482104442383e-283.to_s.should == "9.349527048210444e-283"
- -4.2046059371986483233e+307.to_s.should == "-4.2046059371986483e+307"
- 3.6133547278583543004e-117.to_s.should == "3.613354727858354e-117"
- 4.9247416523566613499e-08.to_s.should == "4.9247416523566613e-08"
- 1.6936145488250064007e-71.to_s.should == "1.6936145488250064e-71"
- 2.4455483206829433098e+96.to_s.should == "2.4455483206829433e+96"
- 7.9797449851436455384e+124.to_s.should == "7.979744985143646e+124"
- -1.3873689634457876774e-129.to_s.should == "-1.3873689634457877e-129"
- 3.9761102037533483075e+284.to_s.should == "3.976110203753348e+284"
- -4.2819791952139402486e-303.to_s.should == "-4.28197919521394e-303"
- -5.7981017546689831298e-116.to_s.should == "-5.798101754668983e-116"
- -3.953266497860534199e-28.to_s.should == "-3.953266497860534e-28"
- -2.0659852720290440959e-243.to_s.should == "-2.065985272029044e-243"
- 8.9670488995878688018e-05.to_s.should == "8.967048899587869e-05"
- -1.2317943708113061768e-98.to_s.should == "-1.2317943708113062e-98"
- -3.8930768307633080463e+248.to_s.should == "-3.893076830763308e+248"
- 6.5854032671803925627e-239.to_s.should == "6.5854032671803926e-239"
- 4.6257022188980878952e+177.to_s.should == "4.625702218898088e+177"
- -1.9397155125507235603e-187.to_s.should == "-1.9397155125507236e-187"
- 8.5752156951245705056e+117.to_s.should == "8.57521569512457e+117"
- -2.4784875958162501671e-132.to_s.should == "-2.4784875958162502e-132"
- -4.4125691841230058457e-203.to_s.should == "-4.412569184123006e-203"
+with_feature :encoding do
+ describe "Float#to_s" do
+ before :each do
+ @internal = Encoding.default_internal
end
- it "random examples in human ranges" do
- # 50.times do
- # formatted = ''
- # rand(1..3).times do
- # formatted << rand(10).to_s
- # end
- # formatted << '.'
- # rand(1..9).times do
- # formatted << rand(10).to_s
- # end
- # float = formatted.to_f
- # puts "#{'%.20f' % float}.to_s.should == #{float.to_s.inspect}"
- # end
-
- 5.17869899999999994122.to_s.should == "5.178699"
- 905.62695729999995819526.to_s.should == "905.6269573"
- 62.75999999999999801048.to_s.should == "62.76"
- 6.93856795800000014651.to_s.should == "6.938567958"
- 4.95999999999999996447.to_s.should == "4.96"
- 32.77993899999999882766.to_s.should == "32.779939"
- 544.12756779999995160324.to_s.should == "544.1275678"
- 66.25801119999999855281.to_s.should == "66.2580112"
- 7.90000000000000035527.to_s.should == "7.9"
- 5.93100000000000004974.to_s.should == "5.931"
- 5.21229313600000043749.to_s.should == "5.212293136"
- 503.44173809000000119340.to_s.should == "503.44173809"
- 79.26000000000000511591.to_s.should == "79.26"
- 8.51524999999999998579.to_s.should == "8.51525"
- 174.00000000000000000000.to_s.should == "174.0"
- 50.39580000000000126192.to_s.should == "50.3958"
- 35.28999999999999914735.to_s.should == "35.29"
- 5.43136675399999990788.to_s.should == "5.431366754"
- 654.07680000000004838512.to_s.should == "654.0768"
- 6.07423700000000010846.to_s.should == "6.074237"
- 102.25779799999999397642.to_s.should == "102.257798"
- 5.08129999999999970584.to_s.should == "5.0813"
- 6.00000000000000000000.to_s.should == "6.0"
- 8.30000000000000071054.to_s.should == "8.3"
- 32.68345999999999662577.to_s.should == "32.68346"
- 581.11170000000004165486.to_s.should == "581.1117"
- 76.31342999999999676675.to_s.should == "76.31343"
- 438.30826000000001840817.to_s.should == "438.30826"
- 482.06631994000002805478.to_s.should == "482.06631994"
- 55.92721026899999969828.to_s.should == "55.927210269"
- 4.00000000000000000000.to_s.should == "4.0"
- 55.86693999999999959982.to_s.should == "55.86694"
- 787.98299999999994724931.to_s.should == "787.983"
- 5.73810511000000023074.to_s.should == "5.73810511"
- 74.51926810000000500622.to_s.should == "74.5192681"
- 892.89999999999997726263.to_s.should == "892.9"
- 68.27299999999999613465.to_s.should == "68.273"
- 904.10000000000002273737.to_s.should == "904.1"
- 5.23200000000000020606.to_s.should == "5.232"
- 4.09628000000000014325.to_s.should == "4.09628"
- 46.05152633699999853434.to_s.should == "46.051526337"
- 142.12884990599999923688.to_s.should == "142.128849906"
- 3.83057023500000015659.to_s.should == "3.830570235"
- 11.81684594699999912848.to_s.should == "11.816845947"
- 80.50000000000000000000.to_s.should == "80.5"
- 382.18215010000000120272.to_s.should == "382.1821501"
- 55.38444606899999911320.to_s.should == "55.384446069"
- 5.78000000000000024869.to_s.should == "5.78"
- 2.88244999999999995666.to_s.should == "2.88245"
- 43.27709999999999723741.to_s.should == "43.2771"
+ after :each do
+ Encoding.default_internal = @internal
end
- it "random values from divisions" do
- (1.0 / 7).to_s.should == "0.14285714285714285"
-
- # 50.times do
- # a = rand(10)
- # b = rand(10)
- # c = rand(10)
- # d = rand(10)
- # expression = "#{a}.#{b} / #{c}.#{d}"
- # puts " (#{expression}).to_s.should == #{eval(expression).to_s.inspect}"
- # end
-
- (1.1 / 7.1).to_s.should == "0.15492957746478875"
- (6.5 / 8.8).to_s.should == "0.7386363636363635"
- (4.8 / 4.3).to_s.should == "1.1162790697674418"
- (4.0 / 1.9).to_s.should == "2.1052631578947367"
- (9.1 / 0.8).to_s.should == "11.374999999999998"
- (5.3 / 7.5).to_s.should == "0.7066666666666667"
- (2.8 / 1.8).to_s.should == "1.5555555555555554"
- (2.1 / 2.5).to_s.should == "0.8400000000000001"
- (3.5 / 6.0).to_s.should == "0.5833333333333334"
- (4.6 / 0.3).to_s.should == "15.333333333333332"
- (0.6 / 2.4).to_s.should == "0.25"
- (1.3 / 9.1).to_s.should == "0.14285714285714288"
- (0.3 / 5.0).to_s.should == "0.06"
- (5.0 / 4.2).to_s.should == "1.1904761904761905"
- (3.0 / 2.0).to_s.should == "1.5"
- (6.3 / 2.0).to_s.should == "3.15"
- (5.4 / 6.0).to_s.should == "0.9"
- (9.6 / 8.1).to_s.should == "1.1851851851851851"
- (8.7 / 1.6).to_s.should == "5.437499999999999"
- (1.9 / 7.8).to_s.should == "0.24358974358974358"
- (0.5 / 2.1).to_s.should == "0.23809523809523808"
- (9.3 / 5.8).to_s.should == "1.6034482758620692"
- (2.7 / 8.0).to_s.should == "0.3375"
- (9.7 / 7.8).to_s.should == "1.2435897435897436"
- (8.1 / 2.4).to_s.should == "3.375"
- (7.7 / 2.7).to_s.should == "2.8518518518518516"
- (7.9 / 1.7).to_s.should == "4.647058823529412"
- (6.5 / 8.2).to_s.should == "0.7926829268292683"
- (7.8 / 9.6).to_s.should == "0.8125"
- (2.2 / 4.6).to_s.should == "0.47826086956521746"
- (0.0 / 1.0).to_s.should == "0.0"
- (8.3 / 2.9).to_s.should == "2.8620689655172415"
- (3.1 / 6.1).to_s.should == "0.5081967213114754"
- (2.8 / 7.8).to_s.should == "0.358974358974359"
- (8.0 / 0.1).to_s.should == "80.0"
- (1.7 / 6.4).to_s.should == "0.265625"
- (1.8 / 5.4).to_s.should == "0.3333333333333333"
- (8.0 / 5.8).to_s.should == "1.3793103448275863"
- (5.2 / 4.1).to_s.should == "1.2682926829268295"
- (9.8 / 5.8).to_s.should == "1.6896551724137934"
- (5.4 / 9.5).to_s.should == "0.5684210526315789"
- (8.4 / 4.9).to_s.should == "1.7142857142857142"
- (1.7 / 3.5).to_s.should == "0.4857142857142857"
- (1.2 / 5.1).to_s.should == "0.23529411764705882"
- (1.4 / 2.0).to_s.should == "0.7"
- (4.8 / 8.0).to_s.should == "0.6"
- (9.0 / 2.5).to_s.should == "3.6"
- (0.2 / 0.6).to_s.should == "0.33333333333333337"
- (7.8 / 5.2).to_s.should == "1.5"
- (9.5 / 5.5).to_s.should == "1.7272727272727273"
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ 1.23.to_s.encoding.should equal(Encoding::US_ASCII)
end
- end
-end
-describe "Float#to_s" do
- before :each do
- @internal = Encoding.default_internal
- end
-
- after :each do
- Encoding.default_internal = @internal
- end
-
- it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- 1.23.to_s.encoding.should equal(Encoding::US_ASCII)
- end
-
- it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
- Encoding.default_internal = Encoding::IBM437
- 5.47.to_s.encoding.should equal(Encoding::US_ASCII)
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
+ Encoding.default_internal = Encoding::IBM437
+ 5.47.to_s.encoding.should equal(Encoding::US_ASCII)
+ end
end
end
diff --git a/spec/ruby/core/float/truncate_spec.rb b/spec/ruby/core/float/truncate_spec.rb
index 2c80145f9f..7feeb81735 100644
--- a/spec/ruby/core/float/truncate_spec.rb
+++ b/spec/ruby/core/float/truncate_spec.rb
@@ -1,14 +1,16 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
describe "Float#truncate" do
- it_behaves_like :float_to_i, :truncate
+ it_behaves_like(:float_to_i, :truncate)
- it "returns self truncated to an optionally given precision" do
- 2.1679.truncate(0).should eql(2)
- 7.1.truncate(1).should eql(7.1)
- 214.94.truncate(-1).should eql(210)
- -1.234.truncate(2).should eql(-1.23)
- 5.123812.truncate(4).should eql(5.1238)
+ ruby_version_is "2.4" do
+ it "returns self truncated to an optionally given precision" do
+ 2.1679.truncate(0).should eql(2)
+ 7.1.truncate(1).should eql(7.1)
+ 214.94.truncate(-1).should eql(210)
+ -1.234.truncate(2).should eql(-1.23)
+ 5.123812.truncate(4).should eql(5.1238)
+ end
end
end
diff --git a/spec/ruby/core/float/uminus_spec.rb b/spec/ruby/core/float/uminus_spec.rb
index e676a26ada..70e2ff0580 100644
--- a/spec/ruby/core/float/uminus_spec.rb
+++ b/spec/ruby/core/float/uminus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#-@" do
it "negates self" do
diff --git a/spec/ruby/core/float/uplus_spec.rb b/spec/ruby/core/float/uplus_spec.rb
index 936123558c..75f18191dd 100644
--- a/spec/ruby/core/float/uplus_spec.rb
+++ b/spec/ruby/core/float/uplus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#+@" do
it "returns the same value with same sign (twos complement)" do
diff --git a/spec/ruby/core/float/zero_spec.rb b/spec/ruby/core/float/zero_spec.rb
index e70edc422a..3a67551a07 100644
--- a/spec/ruby/core/float/zero_spec.rb
+++ b/spec/ruby/core/float/zero_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Float#zero?" do
it "returns true if self is 0.0" do
diff --git a/spec/ruby/core/gc/count_spec.rb b/spec/ruby/core/gc/count_spec.rb
index af2fbbe713..3caa2c9aac 100644
--- a/spec/ruby/core/gc/count_spec.rb
+++ b/spec/ruby/core/gc/count_spec.rb
@@ -1,17 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "GC.count" do
it "returns an integer" do
GC.count.should be_kind_of(Integer)
end
-
- it "increases as collections are run" do
- count_before = GC.count
- i = 0
- while GC.count <= count_before and i < 10
- GC.start
- i += 1
- end
- GC.count.should > count_before
- end
end
diff --git a/spec/ruby/core/gc/disable_spec.rb b/spec/ruby/core/gc/disable_spec.rb
index b0221d8520..9a8a8f23e9 100644
--- a/spec/ruby/core/gc/disable_spec.rb
+++ b/spec/ruby/core/gc/disable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "GC.disable" do
after :each do
diff --git a/spec/ruby/core/gc/enable_spec.rb b/spec/ruby/core/gc/enable_spec.rb
index eb8d572f46..d3581ad4d8 100644
--- a/spec/ruby/core/gc/enable_spec.rb
+++ b/spec/ruby/core/gc/enable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "GC.enable" do
diff --git a/spec/ruby/core/gc/garbage_collect_spec.rb b/spec/ruby/core/gc/garbage_collect_spec.rb
index f67f0486c8..2b47fdf927 100644
--- a/spec/ruby/core/gc/garbage_collect_spec.rb
+++ b/spec/ruby/core/gc/garbage_collect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "GC#garbage_collect" do
diff --git a/spec/ruby/core/gc/profiler/clear_spec.rb b/spec/ruby/core/gc/profiler/clear_spec.rb
index 95c3d4ed65..47a52a5800 100644
--- a/spec/ruby/core/gc/profiler/clear_spec.rb
+++ b/spec/ruby/core/gc/profiler/clear_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "GC::Profiler.clear" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/gc/profiler/disable_spec.rb b/spec/ruby/core/gc/profiler/disable_spec.rb
index 321a207deb..9b8cedb1d5 100644
--- a/spec/ruby/core/gc/profiler/disable_spec.rb
+++ b/spec/ruby/core/gc/profiler/disable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "GC::Profiler.disable" do
before do
diff --git a/spec/ruby/core/gc/profiler/enable_spec.rb b/spec/ruby/core/gc/profiler/enable_spec.rb
index 1594511675..49e6fc09e0 100644
--- a/spec/ruby/core/gc/profiler/enable_spec.rb
+++ b/spec/ruby/core/gc/profiler/enable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "GC::Profiler.enable" do
diff --git a/spec/ruby/core/gc/profiler/enabled_spec.rb b/spec/ruby/core/gc/profiler/enabled_spec.rb
index 23677be555..12cf3173f4 100644
--- a/spec/ruby/core/gc/profiler/enabled_spec.rb
+++ b/spec/ruby/core/gc/profiler/enabled_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "GC::Profiler.enabled?" do
before do
diff --git a/spec/ruby/core/gc/profiler/report_spec.rb b/spec/ruby/core/gc/profiler/report_spec.rb
index 732b1d0f51..52e5e154ce 100644
--- a/spec/ruby/core/gc/profiler/report_spec.rb
+++ b/spec/ruby/core/gc/profiler/report_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "GC::Profiler.report" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/gc/profiler/result_spec.rb b/spec/ruby/core/gc/profiler/result_spec.rb
index 2ab46a8371..395cf18400 100644
--- a/spec/ruby/core/gc/profiler/result_spec.rb
+++ b/spec/ruby/core/gc/profiler/result_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "GC::Profiler.result" do
it "returns a string" do
diff --git a/spec/ruby/core/gc/profiler/total_time_spec.rb b/spec/ruby/core/gc/profiler/total_time_spec.rb
index 7709f168dd..60fe8f182e 100644
--- a/spec/ruby/core/gc/profiler/total_time_spec.rb
+++ b/spec/ruby/core/gc/profiler/total_time_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "GC::Profiler.total_time" do
it "returns an float" do
diff --git a/spec/ruby/core/gc/start_spec.rb b/spec/ruby/core/gc/start_spec.rb
index fb6820db14..dd24b5d6c6 100644
--- a/spec/ruby/core/gc/start_spec.rb
+++ b/spec/ruby/core/gc/start_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "GC.start" do
it "always returns nil" do
diff --git a/spec/ruby/core/gc/stat_spec.rb b/spec/ruby/core/gc/stat_spec.rb
deleted file mode 100644
index 51bd00c7c7..0000000000
--- a/spec/ruby/core/gc/stat_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "GC.stat" do
- it "supports access by key" do
- keys = [:heap_free_slots, :total_allocated_objects, :count]
- keys.each do |key|
- GC.stat(key).should be_kind_of(Integer)
- end
- end
-
- it "returns hash of values" do
- stat = GC.stat
- stat.should be_kind_of(Hash)
- stat.keys.should include(:count)
- end
-end
diff --git a/spec/ruby/core/gc/stress_spec.rb b/spec/ruby/core/gc/stress_spec.rb
index ca62c0cb4e..5730848895 100644
--- a/spec/ruby/core/gc/stress_spec.rb
+++ b/spec/ruby/core/gc/stress_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "GC.stress" do
after :each do
diff --git a/spec/ruby/core/hash/allocate_spec.rb b/spec/ruby/core/hash/allocate_spec.rb
index 93420de866..d607f235bd 100644
--- a/spec/ruby/core/hash/allocate_spec.rb
+++ b/spec/ruby/core/hash/allocate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Hash.allocate" do
it "returns an instance of Hash" do
diff --git a/spec/ruby/core/hash/any_spec.rb b/spec/ruby/core/hash/any_spec.rb
index bd33e8cd8f..ab8d320c18 100644
--- a/spec/ruby/core/hash/any_spec.rb
+++ b/spec/ruby/core/hash/any_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Hash#any?" do
describe 'with no block given' do
diff --git a/spec/ruby/core/hash/assoc_spec.rb b/spec/ruby/core/hash/assoc_spec.rb
index 64442918d1..0b10720b6f 100644
--- a/spec/ruby/core/hash/assoc_spec.rb
+++ b/spec/ruby/core/hash/assoc_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Hash#assoc" do
before :each do
diff --git a/spec/ruby/core/hash/clear_spec.rb b/spec/ruby/core/hash/clear_spec.rb
index e7816acbbc..ea8235451a 100644
--- a/spec/ruby/core/hash/clear_spec.rb
+++ b/spec/ruby/core/hash/clear_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#clear" do
it "removes all key, value pairs" do
@@ -25,8 +25,8 @@ describe "Hash#clear" do
h.default_proc.should_not == nil
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.clear }.should raise_error(frozen_error_class)
- -> { HashSpecs.empty_frozen_hash.clear }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.clear }.should raise_error(RuntimeError)
+ lambda { HashSpecs.empty_frozen_hash.clear }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/clone_spec.rb b/spec/ruby/core/hash/clone_spec.rb
index 6c96fc0c67..188ae1c807 100644
--- a/spec/ruby/core/hash/clone_spec.rb
+++ b/spec/ruby/core/hash/clone_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Hash#clone" do
it "copies instance variable but not the objects they refer to" do
@@ -7,6 +7,7 @@ describe "Hash#clone" do
clone = hash.clone
clone.should == hash
- clone.should_not equal hash
+ clone.object_id.should_not == hash.object_id
end
end
+
diff --git a/spec/ruby/core/hash/compact_spec.rb b/spec/ruby/core/hash/compact_spec.rb
index ec9d4b5d79..d9ef8a2987 100644
--- a/spec/ruby/core/hash/compact_spec.rb
+++ b/spec/ruby/core/hash/compact_spec.rb
@@ -1,59 +1,61 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Hash#compact" do
- before :each do
- @hash = { truthy: true, false: false, nil: nil, nil => true }
- @initial_pairs = @hash.dup
- @compact = { truthy: true, false: false, nil => true }
- end
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
- it "returns new object that rejects pair has nil value" do
- ret = @hash.compact
- ret.should_not equal(@hash)
- ret.should == @compact
- end
+ruby_version_is "2.4" do
+ describe "Hash#compact" do
+ before :each do
+ @hash = { truthy: true, false: false, nil: nil, nil => true }
+ @initial_pairs = @hash.dup
+ @compact = { truthy: true, false: false, nil => true }
+ end
- it "keeps own pairs" do
- @hash.compact
- @hash.should == @initial_pairs
- end
-end
+ it "returns new object that rejects pair has nil value" do
+ ret = @hash.compact
+ ret.should_not equal(@hash)
+ ret.should == @compact
+ end
-describe "Hash#compact!" do
- before :each do
- @hash = { truthy: true, false: false, nil: nil, nil => true }
- @initial_pairs = @hash.dup
- @compact = { truthy: true, false: false, nil => true }
+ it "keeps own pairs" do
+ @hash.compact
+ @hash.should == @initial_pairs
+ end
end
- it "returns self" do
- @hash.compact!.should equal(@hash)
- end
+ describe "Hash#compact!" do
+ before :each do
+ @hash = { truthy: true, false: false, nil: nil, nil => true }
+ @initial_pairs = @hash.dup
+ @compact = { truthy: true, false: false, nil => true }
+ end
- it "rejects own pair has nil value" do
- @hash.compact!
- @hash.should == @compact
- end
+ it "returns self" do
+ @hash.compact!.should equal(@hash)
+ end
- context "when each pair does not have nil value" do
- before :each do
+ it "rejects own pair has nil value" do
@hash.compact!
+ @hash.should == @compact
end
- it "returns nil" do
- @hash.compact!.should be_nil
- end
- end
+ context "when each pair does not have nil value" do
+ before :each do
+ @hash.compact!
+ end
- describe "on frozen instance" do
- before :each do
- @hash.freeze
+ it "returns nil" do
+ @hash.compact!.should be_nil
+ end
end
- it "keeps pairs and raises a #{frozen_error_class}" do
- ->{ @hash.compact! }.should raise_error(frozen_error_class)
- @hash.should == @initial_pairs
+ describe "on frozen instance" do
+ before :each do
+ @hash.freeze
+ end
+
+ it "keeps pairs and raises a RuntimeError" do
+ ->{ @hash.compact! }.should raise_error(RuntimeError)
+ @hash.should == @initial_pairs
+ end
end
end
end
diff --git a/spec/ruby/core/hash/compare_by_identity_spec.rb b/spec/ruby/core/hash/compare_by_identity_spec.rb
index 0658b4954a..a518e0cdb3 100644
--- a/spec/ruby/core/hash/compare_by_identity_spec.rb
+++ b/spec/ruby/core/hash/compare_by_identity_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#compare_by_identity" do
before :each do
@@ -80,9 +80,9 @@ describe "Hash#compare_by_identity" do
@h[o].should == :o
end
- it "raises a #{frozen_error_class} on frozen hashes" do
+ it "raises a RuntimeError on frozen hashes" do
@h = @h.freeze
- -> { @h.compare_by_identity }.should raise_error(frozen_error_class)
+ lambda { @h.compare_by_identity }.should raise_error(RuntimeError)
end
# Behaviour confirmed in bug #1871
@@ -105,14 +105,16 @@ describe "Hash#compare_by_identity" do
@idh[foo] = true
@idh[foo] = true
@idh.size.should == 1
- @idh.keys.first.should equal foo
+ @idh.keys.first.object_id.should == foo.object_id
end
- it "gives different identity for string literals" do
- @idh['foo'] = 1
- @idh['foo'] = 2
- @idh.values.should == [1, 2]
- @idh.size.should == 2
+ ruby_bug "#12855", "2.2.0"..."2.4.1" do
+ it "gives different identity for string literals" do
+ @idh['foo'] = 1
+ @idh['foo'] = 2
+ @idh.values.should == [1, 2]
+ @idh.size.should == 2
+ end
end
end
diff --git a/spec/ruby/core/hash/constructor_spec.rb b/spec/ruby/core/hash/constructor_spec.rb
index ad67274802..0f582d91de 100644
--- a/spec/ruby/core/hash/constructor_spec.rb
+++ b/spec/ruby/core/hash/constructor_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash.[]" do
describe "passed zero arguments" do
@@ -42,30 +42,17 @@ describe "Hash.[]" do
Hash[ary].should == { a: :b }
end
- ruby_version_is "" ... "2.7" do
- it "ignores elements that are not arrays" do
- -> {
- Hash[[:a]].should == {}
- }.should complain(/ignoring wrong elements/)
- -> {
- Hash[[:nil]].should == {}
- }.should complain(/ignoring wrong elements/)
- end
- end
-
- ruby_version_is "2.7" do
- it "raises for elements that are not arrays" do
- -> {
- Hash[[:a]].should == {}
- }.should raise_error(ArgumentError)
- -> {
- Hash[[:nil]].should == {}
- }.should raise_error(ArgumentError)
- end
+ it "ignores elements that are not arrays" do
+ -> {
+ Hash[[:a]].should == {}
+ }.should complain(/ignoring wrong elements/)
+ -> {
+ Hash[[:nil]].should == {}
+ }.should complain(/ignoring wrong elements/)
end
it "raises an ArgumentError for arrays of more than 2 elements" do
- ->{ Hash[[[:a, :b, :c]]].should == {} }.should raise_error(ArgumentError)
+ lambda{ Hash[[[:a, :b, :c]]].should == {} }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed a list of value-invalid-pairs in an array" do
@@ -89,8 +76,8 @@ describe "Hash.[]" do
end
it "raises an ArgumentError when passed an odd number of arguments" do
- -> { Hash[1, 2, 3] }.should raise_error(ArgumentError)
- -> { Hash[1, 2, { 3 => 4 }] }.should raise_error(ArgumentError)
+ lambda { Hash[1, 2, 3] }.should raise_error(ArgumentError)
+ lambda { Hash[1, 2, { 3 => 4 }] }.should raise_error(ArgumentError)
end
it "calls to_hash" do
diff --git a/spec/ruby/core/hash/default_proc_spec.rb b/spec/ruby/core/hash/default_proc_spec.rb
index 83ad98e5b6..0bd20d43af 100644
--- a/spec/ruby/core/hash/default_proc_spec.rb
+++ b/spec/ruby/core/hash/default_proc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#default_proc" do
it "returns the block passed to Hash.new" do
@@ -37,7 +37,7 @@ describe "Hash#default_proc=" do
end
it "raises an error if passed stuff not convertible to procs" do
- ->{{}.default_proc = 42}.should raise_error(TypeError)
+ lambda{{}.default_proc = 42}.should raise_error(TypeError)
end
it "returns the passed Proc" do
@@ -58,23 +58,23 @@ describe "Hash#default_proc=" do
it "accepts a lambda with an arity of 2" do
h = {}
- -> do
- h.default_proc = -> a, b { }
+ lambda do
+ h.default_proc = lambda {|a,b| }
end.should_not raise_error(TypeError)
end
it "raises a TypeError if passed a lambda with an arity other than 2" do
h = {}
- -> do
- h.default_proc = -> a { }
+ lambda do
+ h.default_proc = lambda {|a| }
end.should raise_error(TypeError)
- -> do
- h.default_proc = -> a, b, c { }
+ lambda do
+ h.default_proc = lambda {|a,b,c| }
end.should raise_error(TypeError)
end
- it "raises a #{frozen_error_class} if self is frozen" do
- -> { {}.freeze.default_proc = Proc.new {} }.should raise_error(frozen_error_class)
- -> { {}.freeze.default_proc = nil }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ lambda { {}.freeze.default_proc = Proc.new {} }.should raise_error(RuntimeError)
+ lambda { {}.freeze.default_proc = nil }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/default_spec.rb b/spec/ruby/core/hash/default_spec.rb
index 6cad65bb62..6c1c7377b7 100644
--- a/spec/ruby/core/hash/default_spec.rb
+++ b/spec/ruby/core/hash/default_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#default" do
it "returns the default value" do
@@ -30,7 +30,7 @@ describe "Hash#default=" do
end
it "unsets the default proc" do
- [99, nil, -> { 6 }].each do |default|
+ [99, nil, lambda { 6 }].each do |default|
h = Hash.new { 5 }
h.default_proc.should_not == nil
h.default = default
@@ -39,8 +39,8 @@ describe "Hash#default=" do
end
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.default = nil }.should raise_error(frozen_error_class)
- -> { HashSpecs.empty_frozen_hash.default = nil }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.default = nil }.should raise_error(RuntimeError)
+ lambda { HashSpecs.empty_frozen_hash.default = nil }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/delete_if_spec.rb b/spec/ruby/core/hash/delete_if_spec.rb
index 345a24a726..d739e4fbab 100644
--- a/spec/ruby/core/hash/delete_if_spec.rb
+++ b/spec/ruby/core/hash/delete_if_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#delete_if" do
it "yields two arguments: key and value" do
@@ -34,11 +34,11 @@ describe "Hash#delete_if" do
each_pairs.should == delete_pairs
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.delete_if { false } }.should raise_error(frozen_error_class)
- -> { HashSpecs.empty_frozen_hash.delete_if { true } }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.delete_if { false } }.should raise_error(RuntimeError)
+ lambda { HashSpecs.empty_frozen_hash.delete_if { true } }.should raise_error(RuntimeError)
end
- it_behaves_like :hash_iteration_no_block, :delete_if
- it_behaves_like :enumeratorized_with_origin_size, :delete_if, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_iteration_no_block, :delete_if)
+ it_behaves_like(:enumeratorized_with_origin_size, :delete_if, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/delete_spec.rb b/spec/ruby/core/hash/delete_spec.rb
index a69815c1d9..a41fad3586 100644
--- a/spec/ruby/core/hash/delete_spec.rb
+++ b/spec/ruby/core/hash/delete_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#delete" do
it "removes the entry and returns the deleted value" do
@@ -37,8 +37,8 @@ describe "Hash#delete" do
{ key => 5 }.delete(key).should == 5
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.delete("foo") }.should raise_error(frozen_error_class)
- -> { HashSpecs.empty_frozen_hash.delete("foo") }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.delete("foo") }.should raise_error(RuntimeError)
+ lambda { HashSpecs.empty_frozen_hash.delete("foo") }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/dig_spec.rb b/spec/ruby/core/hash/dig_spec.rb
index aa0ecadd2f..237c407e91 100644
--- a/spec/ruby/core/hash/dig_spec.rb
+++ b/spec/ruby/core/hash/dig_spec.rb
@@ -1,66 +1,68 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Hash#dig" do
+ruby_version_is '2.3' do
+ describe "Hash#dig" do
- it "returns #[] with one arg" do
- h = { 0 => false, a: 1 }
- h.dig(:a).should == 1
- h.dig(0).should be_false
- h.dig(1).should be_nil
- end
+ it "returns #[] with one arg" do
+ h = { 0 => false, a: 1 }
+ h.dig(:a).should == 1
+ h.dig(0).should be_false
+ h.dig(1).should be_nil
+ end
- it "returns the nested value specified by the sequence of keys" do
- h = { foo: { bar: { baz: 1 } } }
- h.dig(:foo, :bar, :baz).should == 1
- h.dig(:foo, :bar, :nope).should be_nil
- h.dig(:foo, :baz).should be_nil
- h.dig(:bar, :baz, :foo).should be_nil
- end
+ it "returns the nested value specified by the sequence of keys" do
+ h = { foo: { bar: { baz: 1 } } }
+ h.dig(:foo, :bar, :baz).should == 1
+ h.dig(:foo, :bar, :nope).should be_nil
+ h.dig(:foo, :baz).should be_nil
+ h.dig(:bar, :baz, :foo).should be_nil
+ end
- it "returns the nested value specified if the sequence includes an index" do
- h = { foo: [1, 2, 3] }
- h.dig(:foo, 2).should == 3
- end
+ it "returns the nested value specified if the sequence includes an index" do
+ h = { foo: [1, 2, 3] }
+ h.dig(:foo, 2).should == 3
+ end
- it "returns nil if any intermediate step is nil" do
- h = { foo: { bar: { baz: 1 } } }
- h.dig(:foo, :zot, :xyz).should == nil
- end
+ it "returns nil if any intermediate step is nil" do
+ h = { foo: { bar: { baz: 1 } } }
+ h.dig(:foo, :zot, :xyz).should == nil
+ end
- it "raises an ArgumentError if no arguments provided" do
- -> { { the: 'borg' }.dig() }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError if no arguments provided" do
+ lambda { { the: 'borg' }.dig() }.should raise_error(ArgumentError)
+ end
- it "handles type-mixed deep digging" do
- h = {}
- h[:foo] = [ { bar: [ 1 ] }, [ obj = Object.new, 'str' ] ]
- def obj.dig(*args); [ 42 ] end
+ it "handles type-mixed deep digging" do
+ h = {}
+ h[:foo] = [ { bar: [ 1 ] }, [ obj = Object.new, 'str' ] ]
+ def obj.dig(*args); [ 42 ] end
- h.dig(:foo, 0, :bar).should == [ 1 ]
- h.dig(:foo, 0, :bar, 0).should == 1
- h.dig(:foo, 1, 1).should == 'str'
- # MRI does not recurse values returned from `obj.dig`
- h.dig(:foo, 1, 0, 0).should == [ 42 ]
- h.dig(:foo, 1, 0, 0, 10).should == [ 42 ]
- end
+ h.dig(:foo, 0, :bar).should == [ 1 ]
+ h.dig(:foo, 0, :bar, 0).should == 1
+ h.dig(:foo, 1, 1).should == 'str'
+ # MRI does not recurse values returned from `obj.dig`
+ h.dig(:foo, 1, 0, 0).should == [ 42 ]
+ h.dig(:foo, 1, 0, 0, 10).should == [ 42 ]
+ end
- it "raises TypeError if an intermediate element does not respond to #dig" do
- h = {}
- h[:foo] = [ { bar: [ 1 ] }, [ nil, 'str' ] ]
- -> { h.dig(:foo, 0, :bar, 0, 0) }.should raise_error(TypeError)
- -> { h.dig(:foo, 1, 1, 0) }.should raise_error(TypeError)
- end
+ it "raises TypeError if an intermediate element does not respond to #dig" do
+ h = {}
+ h[:foo] = [ { bar: [ 1 ] }, [ nil, 'str' ] ]
+ lambda { h.dig(:foo, 0, :bar, 0, 0) }.should raise_error(TypeError)
+ lambda { h.dig(:foo, 1, 1, 0) }.should raise_error(TypeError)
+ end
- it "calls #dig on the result of #[] with the remaining arguments" do
- h = { foo: { bar: { baz: 42 } } }
- h[:foo].should_receive(:dig).with(:bar, :baz).and_return(42)
- h.dig(:foo, :bar, :baz).should == 42
- end
+ it "calls #dig on the result of #[] with the remaining arguments" do
+ h = { foo: { bar: { baz: 42 } } }
+ h[:foo].should_receive(:dig).with(:bar, :baz).and_return(42)
+ h.dig(:foo, :bar, :baz).should == 42
+ end
- it "respects Hash's default" do
- default = {bar: 42}
- h = Hash.new(default)
- h.dig(:foo).should equal default
- h.dig(:foo, :bar).should == 42
+ it "respects Hash's default" do
+ default = {bar: 42}
+ h = Hash.new(default)
+ h.dig(:foo).should equal default
+ h.dig(:foo, :bar).should == 42
+ end
end
end
diff --git a/spec/ruby/core/hash/each_key_spec.rb b/spec/ruby/core/hash/each_key_spec.rb
index c84dd696d5..4a4078a594 100644
--- a/spec/ruby/core/hash/each_key_spec.rb
+++ b/spec/ruby/core/hash/each_key_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#each_key" do
it "calls block once for each key, passing key" do
@@ -18,6 +18,6 @@ describe "Hash#each_key" do
keys.should == h.keys
end
- it_behaves_like :hash_iteration_no_block, :each_key
- it_behaves_like :enumeratorized_with_origin_size, :each_key, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_iteration_no_block, :each_key)
+ it_behaves_like(:enumeratorized_with_origin_size, :each_key, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/each_pair_spec.rb b/spec/ruby/core/hash/each_pair_spec.rb
index eb6656681d..285ca01b26 100644
--- a/spec/ruby/core/hash/each_pair_spec.rb
+++ b/spec/ruby/core/hash/each_pair_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative 'shared/each'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../shared/each', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#each_pair" do
- it_behaves_like :hash_each, :each_pair
- it_behaves_like :hash_iteration_no_block, :each_pair
- it_behaves_like :enumeratorized_with_origin_size, :each_pair, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_each, :each_pair)
+ it_behaves_like(:hash_iteration_no_block, :each_pair)
+ it_behaves_like(:enumeratorized_with_origin_size, :each_pair, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/each_spec.rb b/spec/ruby/core/hash/each_spec.rb
index f0de0bdee5..676fd284b9 100644
--- a/spec/ruby/core/hash/each_spec.rb
+++ b/spec/ruby/core/hash/each_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative 'shared/each'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../shared/each', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#each" do
- it_behaves_like :hash_each, :each
- it_behaves_like :hash_iteration_no_block, :each
- it_behaves_like :enumeratorized_with_origin_size, :each, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_each, :each)
+ it_behaves_like(:hash_iteration_no_block, :each)
+ it_behaves_like(:enumeratorized_with_origin_size, :each, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/each_value_spec.rb b/spec/ruby/core/hash/each_value_spec.rb
index 19b076730d..d3b2b8692e 100644
--- a/spec/ruby/core/hash/each_value_spec.rb
+++ b/spec/ruby/core/hash/each_value_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#each_value" do
it "calls block once for each key, passing value" do
@@ -18,6 +18,6 @@ describe "Hash#each_value" do
values.should == h.values
end
- it_behaves_like :hash_iteration_no_block, :each_value
- it_behaves_like :enumeratorized_with_origin_size, :each_value, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_iteration_no_block, :each_value)
+ it_behaves_like(:enumeratorized_with_origin_size, :each_value, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/element_reference_spec.rb b/spec/ruby/core/hash/element_reference_spec.rb
index 2eb65d3789..b5ca56e84b 100644
--- a/spec/ruby/core/hash/element_reference_spec.rb
+++ b/spec/ruby/core/hash/element_reference_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#[]" do
it "returns the value for key" do
diff --git a/spec/ruby/core/hash/element_set_spec.rb b/spec/ruby/core/hash/element_set_spec.rb
index 67c5a04d73..a2d67c7f22 100644
--- a/spec/ruby/core/hash/element_set_spec.rb
+++ b/spec/ruby/core/hash/element_set_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/store'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/store', __FILE__)
describe "Hash#[]=" do
- it_behaves_like :hash_store, :[]=
+ it_behaves_like(:hash_store, :[]=)
end
diff --git a/spec/ruby/core/hash/empty_spec.rb b/spec/ruby/core/hash/empty_spec.rb
index e9be44bab0..84464f34e1 100644
--- a/spec/ruby/core/hash/empty_spec.rb
+++ b/spec/ruby/core/hash/empty_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#empty?" do
it "returns true if the hash has no entries" do
diff --git a/spec/ruby/core/hash/eql_spec.rb b/spec/ruby/core/hash/eql_spec.rb
index 9013e12ffd..3e22bf1c67 100644
--- a/spec/ruby/core/hash/eql_spec.rb
+++ b/spec/ruby/core/hash/eql_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "Hash#eql?" do
it_behaves_like :hash_eql, :eql?
diff --git a/spec/ruby/core/hash/equal_value_spec.rb b/spec/ruby/core/hash/equal_value_spec.rb
index ae13a42679..76e4d796aa 100644
--- a/spec/ruby/core/hash/equal_value_spec.rb
+++ b/spec/ruby/core/hash/equal_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "Hash#==" do
it_behaves_like :hash_eql, :==
diff --git a/spec/ruby/core/hash/fetch_spec.rb b/spec/ruby/core/hash/fetch_spec.rb
index 753167f709..5e701b1162 100644
--- a/spec/ruby/core/hash/fetch_spec.rb
+++ b/spec/ruby/core/hash/fetch_spec.rb
@@ -1,25 +1,17 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/hash/key_error'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#fetch" do
- context "when the key is not found" do
- it_behaves_like :key_error, -> obj, key { obj.fetch(key) }, Hash.new(a: 5)
- it_behaves_like :key_error, -> obj, key { obj.fetch(key) }, {}
- it_behaves_like :key_error, -> obj, key { obj.fetch(key) }, Hash.new { 5 }
- it_behaves_like :key_error, -> obj, key { obj.fetch(key) }, Hash.new(5)
-
- it "formats the object with #inspect in the KeyError message" do
- -> {
- {}.fetch('foo')
- }.should raise_error(KeyError, 'key not found: "foo"')
- end
- end
-
it "returns the value for key" do
{ a: 1, b: -1 }.fetch(:b).should == -1
end
+ it "raises a KeyError if key is not found" do
+ lambda { {}.fetch(:a) }.should raise_error(KeyError)
+ lambda { Hash.new(5).fetch(:a) }.should raise_error(KeyError)
+ lambda { Hash.new { 5 }.fetch(:a) }.should raise_error(KeyError)
+ end
+
it "returns default if key is not found when passed a default" do
{}.fetch(:a, nil).should == nil
{}.fetch(:a, 'not here!').should == "not here!"
@@ -31,14 +23,14 @@ describe "Hash#fetch" do
end
it "gives precedence to the default block over the default argument when passed both" do
- -> {
+ lambda {
@result = {}.fetch(9, :foo) { |i| i * i }
}.should complain(/block supersedes default value argument/)
@result.should == 81
end
it "raises an ArgumentError when not passed one or two arguments" do
- -> { {}.fetch() }.should raise_error(ArgumentError)
- -> { {}.fetch(1, 2, 3) }.should raise_error(ArgumentError)
+ lambda { {}.fetch() }.should raise_error(ArgumentError)
+ lambda { {}.fetch(1, 2, 3) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/hash/fetch_values_spec.rb b/spec/ruby/core/hash/fetch_values_spec.rb
index af3673f6ef..d6e47d5885 100644
--- a/spec/ruby/core/hash/fetch_values_spec.rb
+++ b/spec/ruby/core/hash/fetch_values_spec.rb
@@ -1,35 +1,35 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/hash/key_error'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe "Hash#fetch_values" do
- before :each do
- @hash = { a: 1, b: 2, c: 3 }
- end
-
- describe "with matched keys" do
- it "returns the values for keys" do
- @hash.fetch_values(:a).should == [1]
- @hash.fetch_values(:a, :c).should == [1, 3]
+ruby_version_is "2.3" do
+ describe "Hash#fetch_values" do
+ before :each do
+ @hash = { a: 1, b: 2, c: 3 }
end
- it "returns the values for keys ordered in the order of the requested keys" do
- @hash.fetch_values(:c, :a).should == [3, 1]
+ describe "with matched keys" do
+ it "returns the values for keys" do
+ @hash.fetch_values(:a).should == [1]
+ @hash.fetch_values(:a, :c).should == [1, 3]
+ end
end
- end
- describe "with unmatched keys" do
- it_behaves_like :key_error, -> obj, key { obj.fetch_values(key) }, Hash.new(a: 5)
+ describe "with unmatched keys" do
+ it "raises a KeyError" do
+ ->{ @hash.fetch_values :z }.should raise_error(KeyError)
+ ->{ @hash.fetch_values :a, :z }.should raise_error(KeyError)
+ end
- it "returns the default value from block" do
- @hash.fetch_values(:z) { |key| "`#{key}' is not found" }.should == ["`z' is not found"]
- @hash.fetch_values(:a, :z) { |key| "`#{key}' is not found" }.should == [1, "`z' is not found"]
+ it "returns the default value from block" do
+ @hash.fetch_values(:z) { |key| "`#{key}' is not found" }.should == ["`z' is not found"]
+ @hash.fetch_values(:a, :z) { |key| "`#{key}' is not found" }.should == [1, "`z' is not found"]
+ end
end
- end
- describe "without keys" do
- it "returns an empty Array" do
- @hash.fetch_values.should == []
+ describe "without keys" do
+ it "returns an empty Array" do
+ @hash.fetch_values.should == []
+ end
end
end
end
diff --git a/spec/ruby/core/hash/filter_spec.rb b/spec/ruby/core/hash/filter_spec.rb
deleted file mode 100644
index 4382c94e62..0000000000
--- a/spec/ruby/core/hash/filter_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
-
-ruby_version_is "2.6" do
- describe "Hash#filter" do
- it_behaves_like :hash_select, :filter
- end
-
- describe "Hash#filter!" do
- it_behaves_like :hash_select!, :filter!
- end
-end
diff --git a/spec/ruby/core/hash/fixtures/classes.rb b/spec/ruby/core/hash/fixtures/classes.rb
index ae907aaff6..3d3df576cf 100644
--- a/spec/ruby/core/hash/fixtures/classes.rb
+++ b/spec/ruby/core/hash/fixtures/classes.rb
@@ -17,13 +17,6 @@ module HashSpecs
end
end
- class SubHashSettingInInitialize < Hash
- def initialize(*args, &block)
- self[:foo] = :bar
- super(*args, &block)
- end
- end
-
class DefaultHash < Hash
def default(key)
100
diff --git a/spec/ruby/core/hash/flatten_spec.rb b/spec/ruby/core/hash/flatten_spec.rb
index 825da15bfc..60762f864d 100644
--- a/spec/ruby/core/hash/flatten_spec.rb
+++ b/spec/ruby/core/hash/flatten_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Hash#flatten" do
@@ -55,7 +55,7 @@ describe "Hash#flatten" do
end
it "raises a TypeError if given a non-Integer argument" do
- -> do
+ lambda do
@h.flatten(Object.new)
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/hash/gt_spec.rb b/spec/ruby/core/hash/gt_spec.rb
index cd541d4d83..35bf52bf64 100644
--- a/spec/ruby/core/hash/gt_spec.rb
+++ b/spec/ruby/core/hash/gt_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison'
-require_relative 'shared/greater_than'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/comparison', __FILE__)
+require File.expand_path('../shared/greater_than', __FILE__)
-describe "Hash#>" do
- it_behaves_like :hash_comparison, :>
- it_behaves_like :hash_greater_than, :>
+ruby_version_is "2.3" do
+ describe "Hash#>" do
+ it_behaves_like :hash_comparison, :>
+ it_behaves_like :hash_greater_than, :>
- it "returns false if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h > h).should be_false
+ it "returns false if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h > h).should be_false
+ end
end
-end
-describe "Hash#>" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+ describe "Hash#>" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is smaller than argument" do
- (@hash > @bigger).should == false
- (@unrelated > @bigger).should == false
- end
+ it "returns false when receiver size is smaller than argument" do
+ (@hash > @bigger).should == false
+ (@unrelated > @bigger).should == false
+ end
- it "returns false when receiver size is the same as argument" do
- (@hash > @hash).should == false
- (@hash > @unrelated).should == false
- (@unrelated > @hash).should == false
- end
+ it "returns false when receiver size is the same as argument" do
+ (@hash > @hash).should == false
+ (@hash > @unrelated).should == false
+ (@unrelated > @hash).should == false
+ end
- it "returns true when argument is a subset of receiver" do
- (@bigger > @hash).should == true
- end
+ it "returns true when argument is a subset of receiver" do
+ (@bigger > @hash).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash > @similar).should == false
- (@similar > @hash).should == false
+ it "returns false when keys match but values don't" do
+ (@hash > @similar).should == false
+ (@similar > @hash).should == false
+ end
end
end
diff --git a/spec/ruby/core/hash/gte_spec.rb b/spec/ruby/core/hash/gte_spec.rb
index 99b89e7217..5453440ed6 100644
--- a/spec/ruby/core/hash/gte_spec.rb
+++ b/spec/ruby/core/hash/gte_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison'
-require_relative 'shared/greater_than'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/comparison', __FILE__)
+require File.expand_path('../shared/greater_than', __FILE__)
-describe "Hash#>=" do
- it_behaves_like :hash_comparison, :>=
- it_behaves_like :hash_greater_than, :>=
+ruby_version_is "2.3" do
+ describe "Hash#>=" do
+ it_behaves_like :hash_comparison, :>=
+ it_behaves_like :hash_greater_than, :>=
- it "returns true if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h >= h).should be_true
+ it "returns true if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h >= h).should be_true
+ end
end
-end
-describe "Hash#>=" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+ describe "Hash#>=" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is smaller than argument" do
- (@hash >= @bigger).should == false
- (@unrelated >= @bigger).should == false
- end
+ it "returns false when receiver size is smaller than argument" do
+ (@hash >= @bigger).should == false
+ (@unrelated >= @bigger).should == false
+ end
- it "returns false when argument is not a subset or not equals to receiver" do
- (@hash >= @unrelated).should == false
- (@unrelated >= @hash).should == false
- end
+ it "returns false when argument is not a subset or not equals to receiver" do
+ (@hash >= @unrelated).should == false
+ (@unrelated >= @hash).should == false
+ end
- it "returns true when argument is a subset of receiver or equals to receiver" do
- (@bigger >= @hash).should == true
- (@hash >= @hash).should == true
- end
+ it "returns true when argument is a subset of receiver or equals to receiver" do
+ (@bigger >= @hash).should == true
+ (@hash >= @hash).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash >= @similar).should == false
- (@similar >= @hash).should == false
+ it "returns false when keys match but values don't" do
+ (@hash >= @similar).should == false
+ (@similar >= @hash).should == false
+ end
end
end
diff --git a/spec/ruby/core/hash/has_key_spec.rb b/spec/ruby/core/hash/has_key_spec.rb
index 4af53579e5..1d2aa279f1 100644
--- a/spec/ruby/core/hash/has_key_spec.rb
+++ b/spec/ruby/core/hash/has_key_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/key'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/key', __FILE__)
describe "Hash#has_key?" do
- it_behaves_like :hash_key_p, :has_key?
+ it_behaves_like(:hash_key_p, :has_key?)
end
+
diff --git a/spec/ruby/core/hash/has_value_spec.rb b/spec/ruby/core/hash/has_value_spec.rb
index 39f1627fd3..dc8fdf9b69 100644
--- a/spec/ruby/core/hash/has_value_spec.rb
+++ b/spec/ruby/core/hash/has_value_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/value', __FILE__)
describe "Hash#has_value?" do
- it_behaves_like :hash_value_p, :has_value?
+ it_behaves_like(:hash_value_p, :has_value?)
end
+
diff --git a/spec/ruby/core/hash/hash_spec.rb b/spec/ruby/core/hash/hash_spec.rb
index 3649d4d8de..9d1e984c60 100644
--- a/spec/ruby/core/hash/hash_spec.rb
+++ b/spec/ruby/core/hash/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Hash" do
it "includes Enumerable" do
@@ -11,14 +11,6 @@ describe "Hash#hash" do
{ 0=>2, 11=>1 }.hash.should == { 11=>1, 0=>2 }.hash
end
- it "returns a value in which element values do not cancel each other out" do
- { a: 2, b: 2 }.hash.should_not == { a: 7, b: 7 }.hash
- end
-
- it "returns a value in which element keys and values do not cancel each other out" do
- { :a => :a }.hash.should_not == { :b => :b }.hash
- end
-
it "generates a hash for recursive hash structures" do
h = {}
h[:a] = h
diff --git a/spec/ruby/core/hash/include_spec.rb b/spec/ruby/core/hash/include_spec.rb
index f3959dc589..8731673c19 100644
--- a/spec/ruby/core/hash/include_spec.rb
+++ b/spec/ruby/core/hash/include_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/key'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/key', __FILE__)
describe "Hash#include?" do
- it_behaves_like :hash_key_p, :include?
+ it_behaves_like(:hash_key_p, :include?)
end
diff --git a/spec/ruby/core/hash/index_spec.rb b/spec/ruby/core/hash/index_spec.rb
index 2b52c69949..28e64f4eb8 100644
--- a/spec/ruby/core/hash/index_spec.rb
+++ b/spec/ruby/core/hash/index_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/index'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/index', __FILE__)
describe "Hash#index" do
it_behaves_like :hash_index, :index
diff --git a/spec/ruby/core/hash/initialize_spec.rb b/spec/ruby/core/hash/initialize_spec.rb
index 00e1174ec8..aa943d333d 100644
--- a/spec/ruby/core/hash/initialize_spec.rb
+++ b/spec/ruby/core/hash/initialize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#initialize" do
it "is private" do
@@ -9,53 +9,32 @@ describe "Hash#initialize" do
it "can be used to reset default_proc" do
h = { "foo" => 1, "bar" => 2 }
h.default_proc.should == nil
- h.send(:initialize) { |_, k| k * 2 }
+ h.instance_eval { initialize { |_, k| k * 2 } }
h.default_proc.should_not == nil
h["a"].should == "aa"
end
- it "can be used to reset the default value" do
- h = {}
- h.default = 42
- h.default.should == 42
- h.send(:initialize, 1)
- h.default.should == 1
- h.send(:initialize)
- h.default.should == nil
- end
-
it "receives the arguments passed to Hash#new" do
HashSpecs::NewHash.new(:one, :two)[0].should == :one
HashSpecs::NewHash.new(:one, :two)[1].should == :two
end
- it "does not change the storage, only the default value or proc" do
- h = HashSpecs::SubHashSettingInInitialize.new
- h.to_a.should == [[:foo, :bar]]
-
- h = HashSpecs::SubHashSettingInInitialize.new(:default)
- h.to_a.should == [[:foo, :bar]]
-
- h = HashSpecs::SubHashSettingInInitialize.new { :default_block }
- h.to_a.should == [[:foo, :bar]]
- end
-
it "returns self" do
h = Hash.new
h.send(:initialize).should equal(h)
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- block = -> { HashSpecs.frozen_hash.instance_eval { initialize() }}
- block.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ block = lambda { HashSpecs.frozen_hash.instance_eval { initialize() }}
+ block.should raise_error(RuntimeError)
- block = -> { HashSpecs.frozen_hash.instance_eval { initialize(nil) } }
- block.should raise_error(frozen_error_class)
+ block = lambda { HashSpecs.frozen_hash.instance_eval { initialize(nil) } }
+ block.should raise_error(RuntimeError)
- block = -> { HashSpecs.frozen_hash.instance_eval { initialize(5) } }
- block.should raise_error(frozen_error_class)
+ block = lambda { HashSpecs.frozen_hash.instance_eval { initialize(5) } }
+ block.should raise_error(RuntimeError)
- block = -> { HashSpecs.frozen_hash.instance_eval { initialize { 5 } } }
- block.should raise_error(frozen_error_class)
+ block = lambda { HashSpecs.frozen_hash.instance_eval { initialize { 5 } } }
+ block.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/inspect_spec.rb b/spec/ruby/core/hash/inspect_spec.rb
index f41ebb70a6..b8c42cf269 100644
--- a/spec/ruby/core/hash/inspect_spec.rb
+++ b/spec/ruby/core/hash/inspect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "Hash#inspect" do
it_behaves_like :hash_to_s, :inspect
diff --git a/spec/ruby/core/hash/invert_spec.rb b/spec/ruby/core/hash/invert_spec.rb
index 73377a9e97..bc2bf711f7 100644
--- a/spec/ruby/core/hash/invert_spec.rb
+++ b/spec/ruby/core/hash/invert_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#invert" do
it "returns a new hash where keys are values and vice versa" do
diff --git a/spec/ruby/core/hash/keep_if_spec.rb b/spec/ruby/core/hash/keep_if_spec.rb
index 278eafc969..6b3a1925d3 100644
--- a/spec/ruby/core/hash/keep_if_spec.rb
+++ b/spec/ruby/core/hash/keep_if_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#keep_if" do
it "yields two arguments: key and value" do
@@ -27,11 +27,11 @@ describe "Hash#keep_if" do
h.keep_if { true }.should equal(h)
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.keep_if { true } }.should raise_error(frozen_error_class)
- -> { HashSpecs.empty_frozen_hash.keep_if { false } }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.keep_if { true } }.should raise_error(RuntimeError)
+ lambda { HashSpecs.empty_frozen_hash.keep_if { false } }.should raise_error(RuntimeError)
end
- it_behaves_like :hash_iteration_no_block, :keep_if
- it_behaves_like :enumeratorized_with_origin_size, :keep_if, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_iteration_no_block, :keep_if)
+ it_behaves_like(:enumeratorized_with_origin_size, :keep_if, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/key_spec.rb b/spec/ruby/core/hash/key_spec.rb
index 73eecbc98e..dc78174641 100644
--- a/spec/ruby/core/hash/key_spec.rb
+++ b/spec/ruby/core/hash/key_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/key'
-require_relative 'shared/index'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/key', __FILE__)
+require File.expand_path('../shared/index', __FILE__)
describe "Hash#key?" do
- it_behaves_like :hash_key_p, :key?
+ it_behaves_like(:hash_key_p, :key?)
end
describe "Hash#key" do
- it_behaves_like :hash_index, :key
+ it_behaves_like(:hash_index, :key)
end
diff --git a/spec/ruby/core/hash/keys_spec.rb b/spec/ruby/core/hash/keys_spec.rb
index 9a067085e5..bc7855f73b 100644
--- a/spec/ruby/core/hash/keys_spec.rb
+++ b/spec/ruby/core/hash/keys_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#keys" do
diff --git a/spec/ruby/core/hash/length_spec.rb b/spec/ruby/core/hash/length_spec.rb
index d0af0945df..90751402eb 100644
--- a/spec/ruby/core/hash/length_spec.rb
+++ b/spec/ruby/core/hash/length_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Hash#length" do
- it_behaves_like :hash_length, :length
+ it_behaves_like(:hash_length, :length)
end
diff --git a/spec/ruby/core/hash/lt_spec.rb b/spec/ruby/core/hash/lt_spec.rb
index 2219615880..c32af32017 100644
--- a/spec/ruby/core/hash/lt_spec.rb
+++ b/spec/ruby/core/hash/lt_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison'
-require_relative 'shared/less_than'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/comparison', __FILE__)
+require File.expand_path('../shared/less_than', __FILE__)
-describe "Hash#<" do
- it_behaves_like :hash_comparison, :<
- it_behaves_like :hash_less_than, :<
+ruby_version_is "2.3" do
+ describe "Hash#<" do
+ it_behaves_like :hash_comparison, :<
+ it_behaves_like :hash_less_than, :<
- it "returns false if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h < h).should be_false
+ it "returns false if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h < h).should be_false
+ end
end
-end
-describe "Hash#<" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+ describe "Hash#<" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is larger than argument" do
- (@bigger < @hash).should == false
- (@bigger < @unrelated).should == false
- end
+ it "returns false when receiver size is larger than argument" do
+ (@bigger < @hash).should == false
+ (@bigger < @unrelated).should == false
+ end
- it "returns false when receiver size is the same as argument" do
- (@hash < @hash).should == false
- (@hash < @unrelated).should == false
- (@unrelated < @hash).should == false
- end
+ it "returns false when receiver size is the same as argument" do
+ (@hash < @hash).should == false
+ (@hash < @unrelated).should == false
+ (@unrelated < @hash).should == false
+ end
- it "returns true when receiver is a subset of argument" do
- (@hash < @bigger).should == true
- end
+ it "returns true when receiver is a subset of argument" do
+ (@hash < @bigger).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash < @similar).should == false
- (@similar < @hash).should == false
+ it "returns false when keys match but values don't" do
+ (@hash < @similar).should == false
+ (@similar < @hash).should == false
+ end
end
end
diff --git a/spec/ruby/core/hash/lte_spec.rb b/spec/ruby/core/hash/lte_spec.rb
index a166e5bca4..1a6926a44a 100644
--- a/spec/ruby/core/hash/lte_spec.rb
+++ b/spec/ruby/core/hash/lte_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison'
-require_relative 'shared/less_than'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/comparison', __FILE__)
+require File.expand_path('../shared/less_than', __FILE__)
-describe "Hash#<=" do
- it_behaves_like :hash_comparison, :<=
- it_behaves_like :hash_less_than, :<=
+ruby_version_is "2.3" do
+ describe "Hash#<=" do
+ it_behaves_like :hash_comparison, :<=
+ it_behaves_like :hash_less_than, :<=
- it "returns true if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h <= h).should be_true
+ it "returns true if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h <= h).should be_true
+ end
end
-end
-describe "Hash#<=" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+ describe "Hash#<=" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is larger than argument" do
- (@bigger <= @hash).should == false
- (@bigger <= @unrelated).should == false
- end
+ it "returns false when receiver size is larger than argument" do
+ (@bigger <= @hash).should == false
+ (@bigger <= @unrelated).should == false
+ end
- it "returns false when receiver size is the same as argument" do
- (@hash <= @unrelated).should == false
- (@unrelated <= @hash).should == false
- end
+ it "returns false when receiver size is the same as argument" do
+ (@hash <= @unrelated).should == false
+ (@unrelated <= @hash).should == false
+ end
- it "returns true when receiver is a subset of argument or equals to argument" do
- (@hash <= @bigger).should == true
- (@hash <= @hash).should == true
- end
+ it "returns true when receiver is a subset of argument or equals to argument" do
+ (@hash <= @bigger).should == true
+ (@hash <= @hash).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash <= @similar).should == false
- (@similar <= @hash).should == false
+ it "returns false when keys match but values don't" do
+ (@hash <= @similar).should == false
+ (@similar <= @hash).should == false
+ end
end
end
diff --git a/spec/ruby/core/hash/member_spec.rb b/spec/ruby/core/hash/member_spec.rb
index 37c0414559..376bb4c006 100644
--- a/spec/ruby/core/hash/member_spec.rb
+++ b/spec/ruby/core/hash/member_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/key'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/key', __FILE__)
describe "Hash#member?" do
- it_behaves_like :hash_key_p, :member?
+ it_behaves_like(:hash_key_p, :member?)
end
diff --git a/spec/ruby/core/hash/merge_spec.rb b/spec/ruby/core/hash/merge_spec.rb
index 91ded30eb7..21401ffd08 100644
--- a/spec/ruby/core/hash/merge_spec.rb
+++ b/spec/ruby/core/hash/merge_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative 'shared/update'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Hash#merge" do
it "returns a new hash by combining self with the contents of other" do
@@ -28,7 +28,7 @@ describe "Hash#merge" do
r = h1.merge(h2) { |k,x,y| "#{k}:#{x+2*y}" }
r.should == { a: "a:-2", b: "b:9", c: -3, d: 5 }
- -> {
+ lambda {
h1.merge(h2) { |k, x, y| raise(IndexError) }
}.should raise_error(IndexError)
@@ -63,40 +63,15 @@ describe "Hash#merge" do
merge_pairs.should == each_pairs
end
- it "preserves the order of merged elements" do
- h1 = { 1 => 2, 3 => 4, 5 => 6 }
- h2 = { 1 => 7 }
- merge_pairs = []
- h1.merge(h2).each_pair { |k, v| merge_pairs << [k, v] }
- merge_pairs.should == [[1,7], [3, 4], [5, 6]]
- end
-
- it "preserves the order of merged elements for large hashes" do
- h1 = {}
- h2 = {}
- merge_pairs = []
- expected_pairs = []
- (1..100).each { |x| h1[x] = x; h2[101 - x] = x; expected_pairs << [x, 101 - x] }
- h1.merge(h2).each_pair { |k, v| merge_pairs << [k, v] }
- merge_pairs.should == expected_pairs
- end
-
- ruby_version_is "2.6" do
- it "accepts multiple hashes" do
- result = { a: 1 }.merge({ b: 2 }, { c: 3 }, { d: 4 })
- result.should == { a: 1, b: 2, c: 3, d: 4 }
- end
-
- it "accepts zero arguments and returns a copy of self" do
- hash = { a: 1 }
- merged = hash.merge
-
- merged.should eql(hash)
- merged.should_not equal(hash)
- end
- end
end
describe "Hash#merge!" do
- it_behaves_like :hash_update, :merge!
+ it_behaves_like(:hash_update, :merge!)
+
+ it "does not raise an exception if changing the value of an existing key during iteration" do
+ hash = {1 => 2, 3 => 4, 5 => 6}
+ hash2 = {1 => :foo, 3 => :bar}
+ hash.each { hash.merge!(hash2) }
+ hash.should == {1 => :foo, 3 => :bar, 5 => 6}
+ end
end
diff --git a/spec/ruby/core/hash/new_spec.rb b/spec/ruby/core/hash/new_spec.rb
index 6054b69bdd..c31cc2abf4 100644
--- a/spec/ruby/core/hash/new_spec.rb
+++ b/spec/ruby/core/hash/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash.new" do
it "creates an empty Hash if passed no arguments" do
@@ -26,11 +26,11 @@ describe "Hash.new" do
end
it "raises an ArgumentError if more than one argument is passed" do
- -> { Hash.new(5,6) }.should raise_error(ArgumentError)
+ lambda { Hash.new(5,6) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if passed both default argument and default block" do
- -> { Hash.new(5) { 0 } }.should raise_error(ArgumentError)
- -> { Hash.new(nil) { 0 } }.should raise_error(ArgumentError)
+ lambda { Hash.new(5) { 0 } }.should raise_error(ArgumentError)
+ lambda { Hash.new(nil) { 0 } }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/hash/rassoc_spec.rb b/spec/ruby/core/hash/rassoc_spec.rb
index f3b2a6de20..79c633f95e 100644
--- a/spec/ruby/core/hash/rassoc_spec.rb
+++ b/spec/ruby/core/hash/rassoc_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Hash#rassoc" do
before :each do
diff --git a/spec/ruby/core/hash/rehash_spec.rb b/spec/ruby/core/hash/rehash_spec.rb
index 587935fc43..09315737b6 100644
--- a/spec/ruby/core/hash/rehash_spec.rb
+++ b/spec/ruby/core/hash/rehash_spec.rb
@@ -1,31 +1,22 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#rehash" do
- it "reorganizes the Hash by recomputing all key hash codes" do
- k1 = Object.new
- k2 = Object.new
- def k1.hash; 0; end
- def k2.hash; 1; end
-
+ it "reorganizes the hash by recomputing all key hash codes" do
+ k1 = [1]
+ k2 = [2]
h = {}
- h[k1] = :v1
- h[k2] = :v2
-
- def k1.hash; 1; end
+ h[k1] = 0
+ h[k2] = 1
- # The key should no longer be found as the #hash changed.
- # Hash values 0 and 1 should not conflict, even with 1-bit stored hash.
+ k1 << 2
h.key?(k1).should == false
-
h.keys.include?(k1).should == true
h.rehash.should equal(h)
h.key?(k1).should == true
- h[k1].should == :v1
- end
+ h[k1].should == 0
- it "calls #hash for each key" do
k1 = mock('k1')
k2 = mock('k2')
v1 = mock('v1')
@@ -44,23 +35,8 @@ describe "Hash#rehash" do
h[k2].should == v2
end
- it "removes duplicate keys" do
- a = [1,2]
- b = [1]
-
- h = {}
- h[a] = true
- h[b] = true
- b << 2
- h.size.should == 2
- h.keys.should == [a, b]
- h.rehash
- h.size.should == 1
- h.keys.should == [a]
- end
-
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.rehash }.should raise_error(frozen_error_class)
- -> { HashSpecs.empty_frozen_hash.rehash }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.rehash }.should raise_error(RuntimeError)
+ lambda { HashSpecs.empty_frozen_hash.rehash }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/reject_spec.rb b/spec/ruby/core/hash/reject_spec.rb
index 1051ebd76c..21dd7425aa 100644
--- a/spec/ruby/core/hash/reject_spec.rb
+++ b/spec/ruby/core/hash/reject_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/iteration'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#reject" do
it "returns a new hash removing keys for which the block yields true" do
@@ -32,11 +32,9 @@ describe "Hash#reject" do
HashSpecs::MyHash[1 => 2, 3 => 4].reject { true }.should be_kind_of(Hash)
end
- ruby_version_is ''...'2.7' do
- it "does not taint the resulting hash" do
- h = { a: 1 }.taint
- h.reject {false}.tainted?.should == false
- end
+ it "does not taint the resulting hash" do
+ h = { a: 1 }.taint
+ h.reject {false}.tainted?.should == false
end
end
@@ -51,8 +49,8 @@ describe "Hash#reject" do
reject_pairs.should == reject_bang_pairs
end
- it_behaves_like :hash_iteration_no_block, :reject
- it_behaves_like :enumeratorized_with_origin_size, :reject, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_iteration_no_block, :reject)
+ it_behaves_like(:enumeratorized_with_origin_size, :reject, { 1 => 2, 3 => 4, 5 => 6 })
end
describe "Hash#reject!" do
@@ -89,14 +87,14 @@ describe "Hash#reject!" do
reject_bang_pairs.should == delete_if_pairs
end
- it "raises a #{frozen_error_class} if called on a frozen instance that is modified" do
- -> { HashSpecs.empty_frozen_hash.reject! { true } }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance that is modified" do
+ lambda { HashSpecs.empty_frozen_hash.reject! { true } }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} if called on a frozen instance that would not be modified" do
- -> { HashSpecs.frozen_hash.reject! { false } }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance that would not be modified" do
+ lambda { HashSpecs.frozen_hash.reject! { false } }.should raise_error(RuntimeError)
end
- it_behaves_like :hash_iteration_no_block, :reject!
- it_behaves_like :enumeratorized_with_origin_size, :reject!, { 1 => 2, 3 => 4, 5 => 6 }
+ it_behaves_like(:hash_iteration_no_block, :reject!)
+ it_behaves_like(:enumeratorized_with_origin_size, :reject!, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/replace_spec.rb b/spec/ruby/core/hash/replace_spec.rb
index 92b2118fd3..61b3164355 100644
--- a/spec/ruby/core/hash/replace_spec.rb
+++ b/spec/ruby/core/hash/replace_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/replace'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/replace', __FILE__)
describe "Hash#replace" do
- it_behaves_like :hash_replace, :replace
+ it_behaves_like(:hash_replace, :replace)
end
diff --git a/spec/ruby/core/hash/select_spec.rb b/spec/ruby/core/hash/select_spec.rb
index 38b0180b0e..449607b606 100644
--- a/spec/ruby/core/hash/select_spec.rb
+++ b/spec/ruby/core/hash/select_spec.rb
@@ -1,10 +1,83 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Hash#select" do
- it_behaves_like :hash_select, :select
+ before :each do
+ @hsh = { 1 => 2, 3 => 4, 5 => 6 }
+ @empty = {}
+ end
+
+ it "yields two arguments: key and value" do
+ all_args = []
+ { 1 => 2, 3 => 4 }.select { |*args| all_args << args }
+ all_args.sort.should == [[1, 2], [3, 4]]
+ end
+
+ it "returns a Hash of entries for which block is true" do
+ a_pairs = { 'a' => 9, 'c' => 4, 'b' => 5, 'd' => 2 }.select { |k,v| v % 2 == 0 }
+ a_pairs.should be_an_instance_of(Hash)
+ a_pairs.sort.should == [['c', 4], ['d', 2]]
+ end
+
+ it "processes entries with the same order as reject" do
+ h = { a: 9, c: 4, b: 5, d: 2 }
+
+ select_pairs = []
+ reject_pairs = []
+ h.dup.select { |*pair| select_pairs << pair }
+ h.reject { |*pair| reject_pairs << pair }
+
+ select_pairs.should == reject_pairs
+ end
+
+ it "returns an Enumerator when called on a non-empty hash without a block" do
+ @hsh.select.should be_an_instance_of(Enumerator)
+ end
+
+ it "returns an Enumerator when called on an empty hash without a block" do
+ @empty.select.should be_an_instance_of(Enumerator)
+ end
+
+ it_behaves_like(:hash_iteration_no_block, :select)
+ it_behaves_like(:enumeratorized_with_origin_size, :select, { 1 => 2, 3 => 4, 5 => 6 })
end
describe "Hash#select!" do
- it_behaves_like :hash_select!, :select!
+ before :each do
+ @hsh = { 1 => 2, 3 => 4, 5 => 6 }
+ @empty = {}
+ end
+
+ it "is equivalent to keep_if if changes are made" do
+ h = { a: 2 }
+ h.select! { |k,v| v <= 1 }.should equal h
+
+ h = { 1 => 2, 3 => 4 }
+ all_args_select = []
+ h.dup.select! { |*args| all_args_select << args }
+ all_args_select.should == [[1, 2], [3, 4]]
+ end
+
+ it "removes all entries if the block is false" do
+ h = { a: 1, b: 2, c: 3 }
+ h.select! { |k,v| false }.should equal(h)
+ h.should == {}
+ end
+
+ it "returns nil if no changes were made" do
+ { a: 1 }.select! { |k,v| v <= 1 }.should == nil
+ end
+
+ it "raises a RuntimeError if called on an empty frozen instance" do
+ lambda { HashSpecs.empty_frozen_hash.select! { false } }.should raise_error(RuntimeError)
+ end
+
+ it "raises a RuntimeError if called on a frozen instance that would not be modified" do
+ lambda { HashSpecs.frozen_hash.select! { true } }.should raise_error(RuntimeError)
+ end
+
+ it_behaves_like(:hash_iteration_no_block, :select!)
+ it_behaves_like(:enumeratorized_with_origin_size, :select!, { 1 => 2, 3 => 4, 5 => 6 })
end
diff --git a/spec/ruby/core/hash/shared/comparison.rb b/spec/ruby/core/hash/shared/comparison.rb
index 07564e4cec..bbb9bfd6ad 100644
--- a/spec/ruby/core/hash/shared/comparison.rb
+++ b/spec/ruby/core/hash/shared/comparison.rb
@@ -1,8 +1,8 @@
describe :hash_comparison, shared: true do
it "raises a TypeError if the right operand is not a hash" do
- -> { { a: 1 }.send(@method, 1) }.should raise_error(TypeError)
- -> { { a: 1 }.send(@method, nil) }.should raise_error(TypeError)
- -> { { a: 1 }.send(@method, []) }.should raise_error(TypeError)
+ lambda { { a: 1 }.send(@method, 1) }.should raise_error(TypeError)
+ lambda { { a: 1 }.send(@method, nil) }.should raise_error(TypeError)
+ lambda { { a: 1 }.send(@method, []) }.should raise_error(TypeError)
end
it "returns false if both hashes have the same keys but different values" do
diff --git a/spec/ruby/core/hash/shared/each.rb b/spec/ruby/core/hash/shared/each.rb
index d1f2e5f672..bf4c569cfc 100644
--- a/spec/ruby/core/hash/shared/each.rb
+++ b/spec/ruby/core/hash/shared/each.rb
@@ -1,6 +1,4 @@
describe :hash_each, shared: true do
-
- # This is inconsistent with below, MRI checks the block arity in rb_hash_each_pair()
it "yields a [[key, value]] Array for each pair to a block expecting |*args|" do
all_args = []
{ 1 => 2, 3 => 4 }.send(@method) { |*args| all_args << args }
@@ -21,21 +19,6 @@ describe :hash_each, shared: true do
ary.sort.should == ["a", "b", "c"]
end
- it "yields 2 values and not an Array of 2 elements when given a callable of arity 2" do
- obj = Object.new
- def obj.foo(key, value)
- ScratchPad << key << value
- end
-
- ScratchPad.record([])
- { "a" => 1 }.send(@method, &obj.method(:foo))
- ScratchPad.recorded.should == ["a", 1]
-
- ScratchPad.record([])
- { "a" => 1 }.send(@method, &-> key, value { ScratchPad << key << value })
- ScratchPad.recorded.should == ["a", 1]
- end
-
it "uses the same order as keys() and values()" do
h = { a: 1, b: 2, c: 3, d: 5 }
keys = []
diff --git a/spec/ruby/core/hash/shared/eql.rb b/spec/ruby/core/hash/shared/eql.rb
index d8c33179fc..1aed5f51fb 100644
--- a/spec/ruby/core/hash/shared/eql.rb
+++ b/spec/ruby/core/hash/shared/eql.rb
@@ -149,80 +149,46 @@ describe :hash_eql_additional, shared: true do
h.send(@method, HashSpecs::MyHash[h]).should be_true
end
- ruby_version_is '2.7' do
- # Why isn't this true of eql? too ?
- it "compares keys with matching hash codes via eql?" do
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
-
- def obj.eql?(o)
- return true if self.equal?(o)
- false
- end
-
- obj
+ # Why isn't this true of eql? too ?
+ it "compares keys with matching hash codes via eql?" do
+ a = Array.new(2) do
+ obj = mock('0')
+ obj.should_receive(:hash).at_least(1).and_return(0)
+
+ # It's undefined whether the impl does a[0].eql?(a[1]) or
+ # a[1].eql?(a[0]) so we taint both.
+ def obj.eql?(o)
+ return true if self.equal?(o)
+ taint
+ o.taint
+ false
end
- { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_false
-
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
-
- def obj.eql?(o)
- true
- end
-
- obj
- end
-
- { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_true
+ obj
end
- end
- ruby_version_is ''...'2.7' do
- # Why isn't this true of eql? too ?
- it "compares keys with matching hash codes via eql?" do
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
+ { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_false
+ a[0].tainted?.should be_true
+ a[1].tainted?.should be_true
- # It's undefined whether the impl does a[0].eql?(a[1]) or
- # a[1].eql?(a[0]) so we taint both.
- def obj.eql?(o)
- return true if self.equal?(o)
- taint
- o.taint
- false
- end
+ a = Array.new(2) do
+ obj = mock('0')
+ obj.should_receive(:hash).at_least(1).and_return(0)
- obj
+ def obj.eql?(o)
+ # It's undefined whether the impl does a[0].send(@method, a[1]) or
+ # a[1].send(@method, a[0]) so we taint both.
+ taint
+ o.taint
+ true
end
- { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_false
- a[0].tainted?.should be_true
- a[1].tainted?.should be_true
-
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
-
- def obj.eql?(o)
- # It's undefined whether the impl does a[0].send(@method, a[1]) or
- # a[1].send(@method, a[0]) so we taint both.
- taint
- o.taint
- true
- end
-
- obj
- end
-
- { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_true
- a[0].tainted?.should be_true
- a[1].tainted?.should be_true
+ obj
end
+
+ { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_true
+ a[0].tainted?.should be_true
+ a[1].tainted?.should be_true
end
it "compares the values in self to values in other hash" do
diff --git a/spec/ruby/core/hash/shared/index.rb b/spec/ruby/core/hash/shared/index.rb
index 4858ba85f5..9aa1b2a46f 100644
--- a/spec/ruby/core/hash/shared/index.rb
+++ b/spec/ruby/core/hash/shared/index.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :hash_index, shared: true do
it "returns the corresponding key for value" do
diff --git a/spec/ruby/core/hash/shared/replace.rb b/spec/ruby/core/hash/shared/replace.rb
index b3d098763b..463c861395 100644
--- a/spec/ruby/core/hash/shared/replace.rb
+++ b/spec/ruby/core/hash/shared/replace.rb
@@ -32,20 +32,20 @@ describe :hash_replace, shared: true do
hash_a.default(5).should == 10
hash_a = Hash.new { |h, k| k * 5 }
- hash_b = Hash.new(-> { raise "Should not invoke lambda" })
+ hash_b = Hash.new(lambda { raise "Should not invoke lambda" })
hash_a.send(@method, hash_b)
hash_a.default.should == hash_b.default
end
- it "raises a #{frozen_error_class} if called on a frozen instance that would not be modified" do
- -> do
+ it "raises a RuntimeError if called on a frozen instance that would not be modified" do
+ lambda do
HashSpecs.frozen_hash.send(@method, HashSpecs.frozen_hash)
- end.should raise_error(frozen_error_class)
+ end.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} if called on a frozen instance that is modified" do
- -> do
+ it "raises a RuntimeError if called on a frozen instance that is modified" do
+ lambda do
HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash)
- end.should raise_error(frozen_error_class)
+ end.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/shared/select.rb b/spec/ruby/core/hash/shared/select.rb
deleted file mode 100644
index bb781817cb..0000000000
--- a/spec/ruby/core/hash/shared/select.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/iteration'
-require_relative '../../enumerable/shared/enumeratorized'
-
-describe :hash_select, shared: true do
- before :each do
- @hsh = { 1 => 2, 3 => 4, 5 => 6 }
- @empty = {}
- end
-
- it "yields two arguments: key and value" do
- all_args = []
- { 1 => 2, 3 => 4 }.send(@method) { |*args| all_args << args }
- all_args.sort.should == [[1, 2], [3, 4]]
- end
-
- it "returns a Hash of entries for which block is true" do
- a_pairs = { 'a' => 9, 'c' => 4, 'b' => 5, 'd' => 2 }.send(@method) { |k,v| v % 2 == 0 }
- a_pairs.should be_an_instance_of(Hash)
- a_pairs.sort.should == [['c', 4], ['d', 2]]
- end
-
- it "processes entries with the same order as reject" do
- h = { a: 9, c: 4, b: 5, d: 2 }
-
- select_pairs = []
- reject_pairs = []
- h.dup.send(@method) { |*pair| select_pairs << pair }
- h.reject { |*pair| reject_pairs << pair }
-
- select_pairs.should == reject_pairs
- end
-
- it "returns an Enumerator when called on a non-empty hash without a block" do
- @hsh.send(@method).should be_an_instance_of(Enumerator)
- end
-
- it "returns an Enumerator when called on an empty hash without a block" do
- @empty.send(@method).should be_an_instance_of(Enumerator)
- end
-
- it_should_behave_like :hash_iteration_no_block
-
- before :each do
- @object = { 1 => 2, 3 => 4, 5 => 6 }
- end
- it_should_behave_like :enumeratorized_with_origin_size
-end
-
-describe :hash_select!, shared: true do
- before :each do
- @hsh = { 1 => 2, 3 => 4, 5 => 6 }
- @empty = {}
- end
-
- it "is equivalent to keep_if if changes are made" do
- h = { a: 2 }
- h.send(@method) { |k,v| v <= 1 }.should equal h
-
- h = { 1 => 2, 3 => 4 }
- all_args_select = []
- h.dup.send(@method) { |*args| all_args_select << args }
- all_args_select.should == [[1, 2], [3, 4]]
- end
-
- it "removes all entries if the block is false" do
- h = { a: 1, b: 2, c: 3 }
- h.send(@method) { |k,v| false }.should equal(h)
- h.should == {}
- end
-
- it "returns nil if no changes were made" do
- { a: 1 }.send(@method) { |k,v| v <= 1 }.should == nil
- end
-
- it "raises a #{frozen_error_class} if called on an empty frozen instance" do
- -> { HashSpecs.empty_frozen_hash.send(@method) { false } }.should raise_error(frozen_error_class)
- end
-
- it "raises a #{frozen_error_class} if called on a frozen instance that would not be modified" do
- -> { HashSpecs.frozen_hash.send(@method) { true } }.should raise_error(frozen_error_class)
- end
-
- it_should_behave_like :hash_iteration_no_block
-
- before :each do
- @object = { 1 => 2, 3 => 4, 5 => 6 }
- end
- it_should_behave_like :enumeratorized_with_origin_size
-end
diff --git a/spec/ruby/core/hash/shared/store.rb b/spec/ruby/core/hash/shared/store.rb
index ff40bef3ef..b43dcbc93e 100644
--- a/spec/ruby/core/hash/shared/store.rb
+++ b/spec/ruby/core/hash/shared/store.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :hash_store, shared: true do
it "associates the key with the value and return the value" do
@@ -86,8 +86,8 @@ describe :hash_store, shared: true do
h.keys.last.should_not equal(key2)
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.send(@method, 1, 2) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.send(@method, 1, 2) }.should raise_error(RuntimeError)
end
it "does not raise an exception if changing the value of an existing key during iteration" do
diff --git a/spec/ruby/core/hash/shared/to_s.rb b/spec/ruby/core/hash/shared/to_s.rb
index b0e3705d01..0afe605826 100644
--- a/spec/ruby/core/hash/shared/to_s.rb
+++ b/spec/ruby/core/hash/shared/to_s.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :hash_to_s, shared: true do
@@ -61,7 +61,7 @@ describe :hash_to_s, shared: true do
obj.should_receive(:inspect).and_return(obj)
obj.should_receive(:to_s).and_raise(Exception)
- -> { { a: obj }.send(@method) }.should raise_error(Exception)
+ lambda { { a: obj }.send(@method) }.should raise_error(Exception)
end
it "handles hashes with recursive values" do
@@ -77,22 +77,33 @@ describe :hash_to_s, shared: true do
y.send(@method).should == "{1=>{0=>{...}}}"
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted string if self is tainted and not empty" do
- {}.taint.send(@method).tainted?.should be_false
- { nil => nil }.taint.send(@method).tainted?.should be_true
- end
+ it "returns a tainted string if self is tainted and not empty" do
+ {}.taint.send(@method).tainted?.should be_false
+ { nil => nil }.taint.send(@method).tainted?.should be_true
+ end
+
+ it "returns an untrusted string if self is untrusted and not empty" do
+ {}.untrust.send(@method).untrusted?.should be_false
+ { nil => nil }.untrust.send(@method).untrusted?.should be_true
+ end
+
+ ruby_version_is ''...'2.3' do
+ it "raises if inspected result is not default external encoding" do
+ utf_16be = mock("utf_16be")
+ utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
- it "returns an untrusted string if self is untrusted and not empty" do
- {}.untrust.send(@method).untrusted?.should be_false
- { nil => nil }.untrust.send(@method).untrusted?.should be_true
+ lambda {
+ {a: utf_16be}.send(@method)
+ }.should raise_error(Encoding::CompatibilityError)
end
end
- it "does not raise if inspected result is not default external encoding" do
- utf_16be = mock("utf_16be")
- utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
+ ruby_version_is '2.3' do
+ it "does not raise if inspected result is not default external encoding" do
+ utf_16be = mock("utf_16be")
+ utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
- {a: utf_16be}.send(@method).should == '{:a=>"utf_16be \u3042"}'
+ {a: utf_16be}.send(@method).should == '{:a=>"utf_16be \u3042"}'
+ end
end
end
diff --git a/spec/ruby/core/hash/shared/update.rb b/spec/ruby/core/hash/shared/update.rb
index 3af41c450a..b1e3793028 100644
--- a/spec/ruby/core/hash/shared/update.rb
+++ b/spec/ruby/core/hash/shared/update.rb
@@ -34,10 +34,10 @@ describe :hash_update, shared: true do
merge_bang_pairs.should == merge_pairs
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> do
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda do
HashSpecs.frozen_hash.send(@method, 1 => 2)
- end.should raise_error(frozen_error_class)
+ end.should raise_error(RuntimeError)
end
it "checks frozen status before coercing an object with #to_hash" do
@@ -47,32 +47,13 @@ describe :hash_update, shared: true do
def obj.to_hash() raise Exception, "should not receive #to_hash" end
obj.freeze
- -> { HashSpecs.frozen_hash.send(@method, obj) }.should raise_error(frozen_error_class)
+ lambda { HashSpecs.frozen_hash.send(@method, obj) }.should raise_error(RuntimeError)
end
# see redmine #1571
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
- -> do
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
+ lambda do
HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash)
- end.should raise_error(frozen_error_class)
- end
-
- it "does not raise an exception if changing the value of an existing key during iteration" do
- hash = {1 => 2, 3 => 4, 5 => 6}
- hash2 = {1 => :foo, 3 => :bar}
- hash.each { hash.send(@method, hash2) }
- hash.should == {1 => :foo, 3 => :bar, 5 => 6}
- end
-
- ruby_version_is "2.6" do
- it "accepts multiple hashes" do
- result = { a: 1 }.send(@method, { b: 2 }, { c: 3 }, { d: 4 })
- result.should == { a: 1, b: 2, c: 3, d: 4 }
- end
-
- it "accepts zero arguments" do
- hash = { a: 1 }
- hash.send(@method).should eql(hash)
- end
+ end.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/shift_spec.rb b/spec/ruby/core/hash/shift_spec.rb
index d9f121e38b..3991da9656 100644
--- a/spec/ruby/core/hash/shift_spec.rb
+++ b/spec/ruby/core/hash/shift_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#shift" do
it "removes a pair from hash and return it" do
@@ -57,23 +57,8 @@ describe "Hash#shift" do
h.should == {:c => 3}
end
- it "raises a #{frozen_error_class} if called on a frozen instance" do
- -> { HashSpecs.frozen_hash.shift }.should raise_error(frozen_error_class)
- -> { HashSpecs.empty_frozen_hash.shift }.should raise_error(frozen_error_class)
- end
-
- it "works when the hash is at capacity" do
- # We try a wide range of sizes in hopes that this will cover all implementations' base Hash size.
- results = []
- 1.upto(100) do |n|
- h = {}
- n.times do |i|
- h[i] = i
- end
- h.shift
- results << h.size
- end
-
- results.should == 0.upto(99).to_a
+ it "raises a RuntimeError if called on a frozen instance" do
+ lambda { HashSpecs.frozen_hash.shift }.should raise_error(RuntimeError)
+ lambda { HashSpecs.empty_frozen_hash.shift }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/size_spec.rb b/spec/ruby/core/hash/size_spec.rb
index 1e8abd8d97..71660af038 100644
--- a/spec/ruby/core/hash/size_spec.rb
+++ b/spec/ruby/core/hash/size_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Hash#size" do
- it_behaves_like :hash_length, :size
+ it_behaves_like(:hash_length, :size)
end
diff --git a/spec/ruby/core/hash/slice_spec.rb b/spec/ruby/core/hash/slice_spec.rb
index f7717c9404..15c9c815ff 100644
--- a/spec/ruby/core/hash/slice_spec.rb
+++ b/spec/ruby/core/hash/slice_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
ruby_version_is "2.5" do
describe "Hash#slice" do
@@ -6,11 +6,10 @@ ruby_version_is "2.5" do
@hash = { a: 1, b: 2, c: 3 }
end
- it "returns a new empty hash without arguments" do
+ it "returns new hash" do
ret = @hash.slice
ret.should_not equal(@hash)
ret.should be_an_instance_of(Hash)
- ret.should == {}
end
it "returns the requested subset" do
@@ -28,28 +27,10 @@ ruby_version_is "2.5" do
it "returns a Hash instance, even on subclasses" do
klass = Class.new(Hash)
h = klass.new
- h[:bar] = 12
h[:foo] = 42
r = h.slice(:foo)
r.should == {foo: 42}
r.class.should == Hash
end
-
- it "uses the regular Hash#[] method, even on subclasses that override it" do
- ScratchPad.record []
- klass = Class.new(Hash) do
- def [](value)
- ScratchPad << :used_subclassed_operator
- super
- end
- end
-
- h = klass.new
- h[:bar] = 12
- h[:foo] = 42
- h.slice(:foo)
-
- ScratchPad.recorded.should == []
- end
end
end
diff --git a/spec/ruby/core/hash/sort_spec.rb b/spec/ruby/core/hash/sort_spec.rb
index 26058c845e..06235f7609 100644
--- a/spec/ruby/core/hash/sort_spec.rb
+++ b/spec/ruby/core/hash/sort_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#sort" do
it "converts self to a nested array of [key, value] arrays and sort with Array#sort" do
diff --git a/spec/ruby/core/hash/store_spec.rb b/spec/ruby/core/hash/store_spec.rb
index 7e975380ec..45ea8da896 100644
--- a/spec/ruby/core/hash/store_spec.rb
+++ b/spec/ruby/core/hash/store_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/store'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/store', __FILE__)
describe "Hash#store" do
- it_behaves_like :hash_store, :store
+ it_behaves_like(:hash_store, :store)
end
diff --git a/spec/ruby/core/hash/to_a_spec.rb b/spec/ruby/core/hash/to_a_spec.rb
index 46f871389a..76ca721038 100644
--- a/spec/ruby/core/hash/to_a_spec.rb
+++ b/spec/ruby/core/hash/to_a_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#to_a" do
it "returns a list of [key, value] pairs with same order as each()" do
@@ -27,13 +27,11 @@ describe "Hash#to_a" do
ent.should == pairs
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted array if self is tainted" do
- {}.taint.to_a.tainted?.should be_true
- end
+ it "returns a tainted array if self is tainted" do
+ {}.taint.to_a.tainted?.should be_true
+ end
- it "returns an untrusted array if self is untrusted" do
- {}.untrust.to_a.untrusted?.should be_true
- end
+ it "returns an untrusted array if self is untrusted" do
+ {}.untrust.to_a.untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/hash/to_h_spec.rb b/spec/ruby/core/hash/to_h_spec.rb
index d6eaac9f33..366fd58e8a 100644
--- a/spec/ruby/core/hash/to_h_spec.rb
+++ b/spec/ruby/core/hash/to_h_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#to_h" do
it "returns self for Hash instances" do
@@ -31,44 +31,4 @@ describe "Hash#to_h" do
@h[42].should == 84
end
end
-
- ruby_version_is "2.6" do
- context "with block" do
- it "converts [key, value] pairs returned by the block to a hash" do
- { a: 1, b: 2 }.to_h { |k, v| [k.to_s, v*v]}.should == { "a" => 1, "b" => 4 }
- end
-
- it "raises ArgumentError if block returns longer or shorter array" do
- -> do
- { a: 1, b: 2 }.to_h { |k, v| [k.to_s, v*v, 1] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
-
- -> do
- { a: 1, b: 2 }.to_h { |k, v| [k] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
- end
-
- it "raises TypeError if block returns something other than Array" do
- -> do
- { a: 1, b: 2 }.to_h { |k, v| "not-array" }
- end.should raise_error(TypeError, /wrong element type String/)
- end
-
- it "coerces returned pair to Array with #to_ary" do
- x = mock('x')
- x.stub!(:to_ary).and_return([:b, 'b'])
-
- { a: 1 }.to_h { |k| x }.should == { :b => 'b' }
- end
-
- it "does not coerce returned pair to Array with #to_a" do
- x = mock('x')
- x.stub!(:to_a).and_return([:b, 'b'])
-
- -> do
- { a: 1 }.to_h { |k| x }
- end.should raise_error(TypeError, /wrong element type MockObject/)
- end
- end
- end
end
diff --git a/spec/ruby/core/hash/to_hash_spec.rb b/spec/ruby/core/hash/to_hash_spec.rb
index f479fa1fb2..5a173c2ab5 100644
--- a/spec/ruby/core/hash/to_hash_spec.rb
+++ b/spec/ruby/core/hash/to_hash_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#to_hash" do
it "returns self for Hash instances" do
diff --git a/spec/ruby/core/hash/to_proc_spec.rb b/spec/ruby/core/hash/to_proc_spec.rb
index 3e7e57d11f..b486d188b7 100644
--- a/spec/ruby/core/hash/to_proc_spec.rb
+++ b/spec/ruby/core/hash/to_proc_spec.rb
@@ -1,87 +1,89 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Hash#to_proc" do
- before :each do
- @key = Object.new
- @value = Object.new
- @hash = { @key => @value }
- @default = Object.new
- @unstored = Object.new
- end
-
- it "returns an instance of Proc" do
- @hash.to_proc.should be_an_instance_of Proc
- end
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
- describe "the returned proc" do
+ruby_version_is "2.3" do
+ describe "Hash#to_proc" do
before :each do
- @proc = @hash.to_proc
+ @key = Object.new
+ @value = Object.new
+ @hash = { @key => @value }
+ @default = Object.new
+ @unstored = Object.new
end
- it "is not a lambda" do
- @proc.lambda?.should == false
+ it "returns an instance of Proc" do
+ @hash.to_proc.should be_an_instance_of Proc
end
- it "raises ArgumentError if not passed exactly one argument" do
- -> {
- @proc.call
- }.should raise_error(ArgumentError)
-
- -> {
- @proc.call 1, 2
- }.should raise_error(ArgumentError)
- end
-
- context "with a stored key" do
- it "returns the paired value" do
- @proc.call(@key).should equal(@value)
+ describe "the returned proc" do
+ before :each do
+ @proc = @hash.to_proc
end
- end
- context "passed as a block" do
- it "retrieves the hash's values" do
- [@key].map(&@proc)[0].should equal(@value)
+ it "is not a lambda" do
+ @proc.lambda?.should == false
end
- context "to instance_exec" do
- it "always retrieves the original hash's values" do
- hash = {foo: 1, bar: 2}
- proc = hash.to_proc
+ it "raises ArgumentError if not passed exactly one argument" do
+ lambda {
+ @proc.call
+ }.should raise_error(ArgumentError)
- hash.instance_exec(:foo, &proc).should == 1
+ lambda {
+ @proc.call 1, 2
+ }.should raise_error(ArgumentError)
+ end
- hash2 = {quux: 1}
- hash2.instance_exec(:foo, &proc).should == 1
+ context "with a stored key" do
+ it "returns the paired value" do
+ @proc.call(@key).should equal(@value)
end
end
- end
- context "with no stored key" do
- it "returns nil" do
- @proc.call(@unstored).should be_nil
+ context "passed as a block" do
+ it "retrieves the hash's values" do
+ [@key].map(&@proc)[0].should equal(@value)
+ end
+
+ context "to instance_exec" do
+ it "always retrieves the original hash's values" do
+ hash = {foo: 1, bar: 2}
+ proc = hash.to_proc
+
+ hash.instance_exec(:foo, &proc).should == 1
+
+ hash2 = {quux: 1}
+ hash2.instance_exec(:foo, &proc).should == 1
+ end
+ end
end
- context "when the hash has a default value" do
- before :each do
- @hash.default = @default
+ context "with no stored key" do
+ it "returns nil" do
+ @proc.call(@unstored).should be_nil
end
- it "returns the default value" do
- @proc.call(@unstored).should equal(@default)
+ context "when the hash has a default value" do
+ before :each do
+ @hash.default = @default
+ end
+
+ it "returns the default value" do
+ @proc.call(@unstored).should equal(@default)
+ end
end
- end
- context "when the hash has a default proc" do
- it "returns an evaluated value from the default proc" do
- @hash.default_proc = -> hash, called_with { [hash.keys, called_with] }
- @proc.call(@unstored).should == [[@key], @unstored]
+ context "when the hash has a default proc" do
+ it "returns an evaluated value from the default proc" do
+ @hash.default_proc = -> hash, called_with { [hash.keys, called_with] }
+ @proc.call(@unstored).should == [[@key], @unstored]
+ end
end
end
- end
- it "raises an ArgumentError when calling #call on the Proc with no arguments" do
- -> { @hash.to_proc.call }.should raise_error(ArgumentError)
+ it "raises an ArgumentError when calling #call on the Proc with no arguments" do
+ lambda { @hash.to_proc.call }.should raise_error(ArgumentError)
+ end
end
end
end
diff --git a/spec/ruby/core/hash/to_s_spec.rb b/spec/ruby/core/hash/to_s_spec.rb
index e52b09962e..803b1d6236 100644
--- a/spec/ruby/core/hash/to_s_spec.rb
+++ b/spec/ruby/core/hash/to_s_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "Hash#to_s" do
it_behaves_like :hash_to_s, :to_s
diff --git a/spec/ruby/core/hash/transform_keys_spec.rb b/spec/ruby/core/hash/transform_keys_spec.rb
index 32ac89b765..cf42f17e51 100644
--- a/spec/ruby/core/hash/transform_keys_spec.rb
+++ b/spec/ruby/core/hash/transform_keys_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
ruby_version_is "2.5" do
describe "Hash#transform_keys" do
@@ -60,39 +60,17 @@ ruby_version_is "2.5" do
@hash.should == { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 }
end
- # https://bugs.ruby-lang.org/issues/14380
- ruby_version_is ""..."2.5.1" do
- it "does not prevent conflicts between new keys and old ones" do
- @hash.transform_keys!(&:succ)
- @hash.should == { e: 1 }
- end
+ it "prevents conflicts between new keys and old ones" do
+ @hash.transform_keys!(&:succ)
+ @hash.should == { b: 1, c: 2, d: 3, e: 4 }
end
- ruby_version_is "2.5.1" do
- it "prevents conflicts between new keys and old ones" do
- @hash.transform_keys!(&:succ)
- @hash.should == { b: 1, c: 2, d: 3, e: 4 }
- end
- end
-
- ruby_version_is ""..."2.5.1" do
- it "partially modifies the contents if we broke from the block" do
- @hash.transform_keys! do |v|
- break if v == :c
- v.succ
- end
- @hash.should == { c: 1, d: 4 }
- end
- end
-
- ruby_version_is "2.5.1" do
- it "returns the processed keys if we broke from the block" do
- @hash.transform_keys! do |v|
- break if v == :c
- v.succ
- end
- @hash.should == { b: 1, c: 2 }
+ it "partially modifies the contents if we broke from the block" do
+ @hash.transform_keys! do |v|
+ break if v == :c
+ v.succ
end
+ @hash.should == { b: 1, c: 2 }
end
it "keeps later pair if new keys conflict" do
@@ -113,12 +91,12 @@ ruby_version_is "2.5" do
@hash.freeze
end
- it "raises a #{frozen_error_class} on an empty hash" do
- ->{ {}.freeze.transform_keys!(&:upcase) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on an empty hash" do
+ ->{ {}.freeze.transform_keys!(&:upcase) }.should raise_error(RuntimeError)
end
- it "keeps pairs and raises a #{frozen_error_class}" do
- ->{ @hash.transform_keys!(&:upcase) }.should raise_error(frozen_error_class)
+ it "keeps pairs and raises a RuntimeError" do
+ ->{ @hash.transform_keys!(&:upcase) }.should raise_error(RuntimeError)
@hash.should == @initial_pairs
end
diff --git a/spec/ruby/core/hash/transform_values_spec.rb b/spec/ruby/core/hash/transform_values_spec.rb
index 8b53b7a522..a9098a9f2d 100644
--- a/spec/ruby/core/hash/transform_values_spec.rb
+++ b/spec/ruby/core/hash/transform_values_spec.rb
@@ -1,96 +1,98 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Hash#transform_values" do
- before :each do
- @hash = { a: 1, b: 2, c: 3 }
- end
-
- it "returns new hash" do
- ret = @hash.transform_values(&:succ)
- ret.should_not equal(@hash)
- ret.should be_an_instance_of(Hash)
- end
-
- it "sets the result as transformed values with the given block" do
- @hash.transform_values(&:succ).should == { a: 2, b: 3, c: 4 }
- end
+ruby_version_is "2.4" do
+ describe "Hash#transform_values" do
+ before :each do
+ @hash = { a: 1, b: 2, c: 3 }
+ end
- it "makes both hashes to share keys" do
- key = [1, 2, 3]
- new_hash = { key => 1 }.transform_values(&:succ)
- new_hash[key].should == 2
- new_hash.keys[0].should equal(key)
- end
+ it "returns new hash" do
+ ret = @hash.transform_values(&:succ)
+ ret.should_not equal(@hash)
+ ret.should be_an_instance_of(Hash)
+ end
- context "when no block is given" do
- it "returns a sized Enumerator" do
- enumerator = @hash.transform_values
- enumerator.should be_an_instance_of(Enumerator)
- enumerator.size.should == @hash.size
- enumerator.each(&:succ).should == { a: 2, b: 3, c: 4 }
+ it "sets the result as transformed values with the given block" do
+ @hash.transform_values(&:succ).should == { a: 2, b: 3, c: 4 }
end
- end
- it "returns a Hash instance, even on subclasses" do
- klass = Class.new(Hash)
- h = klass.new
- h[:foo] = 42
- r = h.transform_values{|v| 2 * v}
- r[:foo].should == 84
- r.class.should == Hash
- end
-end
+ it "makes both hashes to share keys" do
+ key = [1, 2, 3]
+ new_hash = { key => 1 }.transform_values(&:succ)
+ new_hash[key].should == 2
+ new_hash.keys[0].should equal(key)
+ end
-describe "Hash#transform_values!" do
- before :each do
- @hash = { a: 1, b: 2, c: 3 }
- @initial_pairs = @hash.dup
- end
+ context "when no block is given" do
+ it "returns a sized Enumerator" do
+ enumerator = @hash.transform_values
+ enumerator.should be_an_instance_of(Enumerator)
+ enumerator.size.should == @hash.size
+ enumerator.each(&:succ).should == { a: 2, b: 3, c: 4 }
+ end
+ end
- it "returns self" do
- @hash.transform_values!(&:succ).should equal(@hash)
+ it "returns a Hash instance, even on subclasses" do
+ klass = Class.new(Hash)
+ h = klass.new
+ h[:foo] = 42
+ r = h.transform_values{|v| 2 * v}
+ r[:foo].should == 84
+ r.class.should == Hash
+ end
end
- it "updates self as transformed values with the given block" do
- @hash.transform_values!(&:succ)
- @hash.should == { a: 2, b: 3, c: 4 }
- end
+ describe "Hash#transform_values!" do
+ before :each do
+ @hash = { a: 1, b: 2, c: 3 }
+ @initial_pairs = @hash.dup
+ end
- it "partially modifies the contents if we broke from the block" do
- @hash.transform_values! do |v|
- break if v == 3
- 100 + v
+ it "returns self" do
+ @hash.transform_values!(&:succ).should equal(@hash)
end
- @hash.should == { a: 101, b: 102, c: 3}
- end
- context "when no block is given" do
- it "returns a sized Enumerator" do
- enumerator = @hash.transform_values!
- enumerator.should be_an_instance_of(Enumerator)
- enumerator.size.should == @hash.size
- enumerator.each(&:succ)
+ it "updates self as transformed values with the given block" do
+ @hash.transform_values!(&:succ)
@hash.should == { a: 2, b: 3, c: 4 }
end
- end
- describe "on frozen instance" do
- before :each do
- @hash.freeze
+ it "partially modifies the contents if we broke from the block" do
+ @hash.transform_values! do |v|
+ break if v == 3
+ 100 + v
+ end
+ @hash.should == { a: 101, b: 102, c: 3}
end
- it "raises a #{frozen_error_class} on an empty hash" do
- ->{ {}.freeze.transform_values!(&:succ) }.should raise_error(frozen_error_class)
+ context "when no block is given" do
+ it "returns a sized Enumerator" do
+ enumerator = @hash.transform_values!
+ enumerator.should be_an_instance_of(Enumerator)
+ enumerator.size.should == @hash.size
+ enumerator.each(&:succ)
+ @hash.should == { a: 2, b: 3, c: 4 }
+ end
end
- it "keeps pairs and raises a #{frozen_error_class}" do
- ->{ @hash.transform_values!(&:succ) }.should raise_error(frozen_error_class)
- @hash.should == @initial_pairs
- end
+ describe "on frozen instance" do
+ before :each do
+ @hash.freeze
+ end
- context "when no block is given" do
- it "does not raise an exception" do
- @hash.transform_values!.should be_an_instance_of(Enumerator)
+ it "raises a RuntimeError on an empty hash" do
+ ->{ {}.freeze.transform_values!(&:succ) }.should raise_error(RuntimeError)
+ end
+
+ it "keeps pairs and raises a RuntimeError" do
+ ->{ @hash.transform_values!(&:succ) }.should raise_error(RuntimeError)
+ @hash.should == @initial_pairs
+ end
+
+ context "when no block is given" do
+ it "does not raise an exception" do
+ @hash.transform_values!.should be_an_instance_of(Enumerator)
+ end
end
end
end
diff --git a/spec/ruby/core/hash/try_convert_spec.rb b/spec/ruby/core/hash/try_convert_spec.rb
index 44195c5010..818b08fb32 100644
--- a/spec/ruby/core/hash/try_convert_spec.rb
+++ b/spec/ruby/core/hash/try_convert_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash.try_convert" do
it "returns the argument if it's a Hash" do
@@ -39,12 +39,12 @@ describe "Hash.try_convert" do
it "sends #to_hash to the argument and raises TypeError if it's not a kind of Hash" do
obj = mock("to_hash")
obj.should_receive(:to_hash).and_return(Object.new)
- -> { Hash.try_convert obj }.should raise_error(TypeError)
+ lambda { Hash.try_convert obj }.should raise_error(TypeError)
end
it "does not rescue exceptions raised by #to_hash" do
obj = mock("to_hash")
obj.should_receive(:to_hash).and_raise(RuntimeError)
- -> { Hash.try_convert obj }.should raise_error(RuntimeError)
+ lambda { Hash.try_convert obj }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/hash/update_spec.rb b/spec/ruby/core/hash/update_spec.rb
index 0975045ad1..6cfedea271 100644
--- a/spec/ruby/core/hash/update_spec.rb
+++ b/spec/ruby/core/hash/update_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/update'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Hash#update" do
- it_behaves_like :hash_update, :update
+ it_behaves_like(:hash_update, :update)
end
diff --git a/spec/ruby/core/hash/value_spec.rb b/spec/ruby/core/hash/value_spec.rb
index 0ab16a5d1b..acfe1968d5 100644
--- a/spec/ruby/core/hash/value_spec.rb
+++ b/spec/ruby/core/hash/value_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/value', __FILE__)
describe "Hash#value?" do
- it_behaves_like :hash_value_p, :value?
+ it_behaves_like(:hash_value_p, :value?)
end
+
diff --git a/spec/ruby/core/hash/values_at_spec.rb b/spec/ruby/core/hash/values_at_spec.rb
index b620a279ba..7c39e9b573 100644
--- a/spec/ruby/core/hash/values_at_spec.rb
+++ b/spec/ruby/core/hash/values_at_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/values_at'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/values_at', __FILE__)
describe "Hash#values_at" do
- it_behaves_like :hash_values_at, :values_at
+ it_behaves_like(:hash_values_at, :values_at)
end
diff --git a/spec/ruby/core/hash/values_spec.rb b/spec/ruby/core/hash/values_spec.rb
index 9f2a481a48..4ce2f3f5f0 100644
--- a/spec/ruby/core/hash/values_spec.rb
+++ b/spec/ruby/core/hash/values_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Hash#values" do
it "returns an array of values" do
diff --git a/spec/ruby/core/integer/abs_spec.rb b/spec/ruby/core/integer/abs_spec.rb
deleted file mode 100644
index c40356db12..0000000000
--- a/spec/ruby/core/integer/abs_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/abs'
-
-describe "Integer#abs" do
- it_behaves_like :integer_abs, :abs
-end
diff --git a/spec/ruby/core/integer/allbits_spec.rb b/spec/ruby/core/integer/allbits_spec.rb
index f4a6fe9905..54c99265ba 100644
--- a/spec/ruby/core/integer/allbits_spec.rb
+++ b/spec/ruby/core/integer/allbits_spec.rb
@@ -1,39 +1,37 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-ruby_version_is '2.5' do
- describe "Integer#allbits?" do
- it "returns true iff all the bits of the argument are set in the receiver" do
- 42.allbits?(42).should == true
- 0b1010_1010.allbits?(0b1000_0010).should == true
- 0b1010_1010.allbits?(0b1000_0001).should == false
- 0b1000_0010.allbits?(0b1010_1010).should == false
- (0b1010_1010 | bignum_value).allbits?(0b1000_0010 | bignum_value).should == true
- (0b1010_1010 | bignum_value).allbits?(0b1000_0001 | bignum_value).should == false
- (0b1000_0010 | bignum_value).allbits?(0b1010_1010 | bignum_value).should == false
- end
+describe "Integer#allbits?" do
+ it "returns true iff all the bits of the argument are set in the receiver" do
+ 42.allbits?(42).should == true
+ 0b1010_1010.allbits?(0b1000_0010).should == true
+ 0b1010_1010.allbits?(0b1000_0001).should == false
+ 0b1000_0010.allbits?(0b1010_1010).should == false
+ (0b1010_1010 | bignum_value).allbits?(0b1000_0010 | bignum_value).should == true
+ (0b1010_1010 | bignum_value).allbits?(0b1000_0001 | bignum_value).should == false
+ (0b1000_0010 | bignum_value).allbits?(0b1010_1010 | bignum_value).should == false
+ end
- it "handles negative values using two's complement notation" do
- (~0b1).allbits?(42).should == true
- (-42).allbits?(-42).should == true
- (~0b1010_1010).allbits?(~0b1110_1011).should == true
- (~0b1010_1010).allbits?(~0b1000_0010).should == false
- (~(0b1010_1010 | bignum_value)).allbits?(~(0b1110_1011 | bignum_value)).should == true
- (~(0b1010_1010 | bignum_value)).allbits?(~(0b1000_0010 | bignum_value)).should == false
- end
+ it "handles negative values using two's complement notation" do
+ (~0b1).allbits?(42).should == true
+ (-42).allbits?(-42).should == true
+ (~0b1010_1010).allbits?(~0b1110_1011).should == true
+ (~0b1010_1010).allbits?(~0b1000_0010).should == false
+ (~(0b1010_1010 | bignum_value)).allbits?(~(0b1110_1011 | bignum_value)).should == true
+ (~(0b1010_1010 | bignum_value)).allbits?(~(0b1000_0010 | bignum_value)).should == false
+ end
- it "coerces the rhs using to_int" do
- obj = mock("the int 0b10")
- obj.should_receive(:to_int).and_return(0b10)
- 0b110.allbits?(obj).should == true
- end
+ it "coerces the rhs using to_int" do
+ obj = mock("the int 0b10")
+ obj.should_receive(:to_int).and_return(0b10)
+ 0b110.allbits?(obj).should == true
+ end
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
- 13.allbits?(obj)
- }.should raise_error(TypeError)
- -> { 13.allbits?("10") }.should raise_error(TypeError)
- -> { 13.allbits?(:symbol) }.should raise_error(TypeError)
- end
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
+ 13.allbits?(obj)
+ }.should raise_error(TypeError)
+ lambda { 13.allbits?("10") }.should raise_error(TypeError)
+ lambda { 13.allbits?(:symbol) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/anybits_spec.rb b/spec/ruby/core/integer/anybits_spec.rb
index 91f349258a..409e2e65c5 100644
--- a/spec/ruby/core/integer/anybits_spec.rb
+++ b/spec/ruby/core/integer/anybits_spec.rb
@@ -1,38 +1,36 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-ruby_version_is '2.5' do
- describe "Integer#anybits?" do
- it "returns true iff all the bits of the argument are set in the receiver" do
- 42.anybits?(42).should == true
- 0b1010_1010.anybits?(0b1000_0010).should == true
- 0b1010_1010.anybits?(0b1000_0001).should == true
- 0b1000_0010.anybits?(0b0010_1100).should == false
- different_bignum = (2 * bignum_value) & (~bignum_value)
- (0b1010_1010 | different_bignum).anybits?(0b1000_0010 | bignum_value).should == true
- (0b1010_1010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == true
- (0b1000_0010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == false
- end
+describe "Integer#anybits?" do
+ it "returns true iff all the bits of the argument are set in the receiver" do
+ 42.anybits?(42).should == true
+ 0b1010_1010.anybits?(0b1000_0010).should == true
+ 0b1010_1010.anybits?(0b1000_0001).should == true
+ 0b1000_0010.anybits?(0b0010_1100).should == false
+ different_bignum = (2 * bignum_value) & (~bignum_value)
+ (0b1010_1010 | different_bignum).anybits?(0b1000_0010 | bignum_value).should == true
+ (0b1010_1010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == true
+ (0b1000_0010 | different_bignum).anybits?(0b0010_1100 | bignum_value).should == false
+ end
- it "handles negative values using two's complement notation" do
- (~42).anybits?(42).should == false
- (-42).anybits?(-42).should == true
- (~0b100).anybits?(~0b1).should == true
- (~(0b100 | bignum_value)).anybits?(~(0b1 | bignum_value)).should == true
- end
+ it "handles negative values using two's complement notation" do
+ (~42).anybits?(42).should == false
+ (-42).anybits?(-42).should == true
+ (~0b100).anybits?(~0b1).should == true
+ (~(0b100 | bignum_value)).anybits?(~(0b1 | bignum_value)).should == true
+ end
- it "coerces the rhs using to_int" do
- obj = mock("the int 0b10")
- obj.should_receive(:to_int).and_return(0b10)
- 0b110.anybits?(obj).should == true
- end
+ it "coerces the rhs using to_int" do
+ obj = mock("the int 0b10")
+ obj.should_receive(:to_int).and_return(0b10)
+ 0b110.anybits?(obj).should == true
+ end
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
- 13.anybits?(obj)
- }.should raise_error(TypeError)
- -> { 13.anybits?("10") }.should raise_error(TypeError)
- -> { 13.anybits?(:symbol) }.should raise_error(TypeError)
- end
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
+ 13.anybits?(obj)
+ }.should raise_error(TypeError)
+ lambda { 13.anybits?("10") }.should raise_error(TypeError)
+ lambda { 13.anybits?(:symbol) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/bit_and_spec.rb b/spec/ruby/core/integer/bit_and_spec.rb
deleted file mode 100644
index 15a8026855..0000000000
--- a/spec/ruby/core/integer/bit_and_spec.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#&" do
- context "fixnum" do
- it "returns self bitwise AND other" do
- (256 & 16).should == 0
- (2010 & 5).should == 0
- (65535 & 1).should == 1
- (0xffff & bignum_value + 0xffff_ffff).should == 65535
- end
-
- it "returns self bitwise AND other when one operand is negative" do
- ((1 << 33) & -1).should == (1 << 33)
- (-1 & (1 << 33)).should == (1 << 33)
-
- ((-(1<<33)-1) & 5).should == 5
- (5 & (-(1<<33)-1)).should == 5
- end
-
- it "returns self bitwise AND other when both operands are negative" do
- (-5 & -1).should == -5
- (-3 & -4).should == -4
- (-12 & -13).should == -16
- (-13 & -12).should == -16
- end
-
- it "returns self bitwise AND a bignum" do
- (-1 & 2**64).should == 18446744073709551616
- end
-
- it "coerces the rhs and calls #coerce" do
- obj = mock("fixnum bit and")
- obj.should_receive(:coerce).with(6).and_return([3, 6])
- (6 & obj).should == 2
- end
-
- it "raises a TypeError when passed a Float" do
- -> { (3 & 3.4) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError and does not call #to_int when defined on an object" do
- obj = mock("fixnum bit and")
- obj.should_not_receive(:to_int)
-
- -> { 3 & obj }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(5)
- end
-
- it "returns self bitwise AND other" do
- @bignum = bignum_value(5)
- (@bignum & 3).should == 1
- (@bignum & 52).should == 4
- (@bignum & bignum_value(9921)).should == 9223372036854775809
-
- ((2*bignum_value) & 1).should == 0
- ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616
- end
-
- it "returns self bitwise AND other when one operand is negative" do
- ((2*bignum_value) & -1).should == (2*bignum_value)
- ((4*bignum_value) & -1).should == (4*bignum_value)
- (@bignum & -0xffffffffffffff5).should == 9223372036854775809
- (@bignum & -@bignum).should == 1
- (@bignum & -0x8000000000000000).should == 9223372036854775808
- end
-
- it "returns self bitwise AND other when both operands are negative" do
- (-@bignum & -0x4000000000000005).should == -13835058055282163717
- (-@bignum & -@bignum).should == -9223372036854775813
- (-@bignum & -0x4000000000000000).should == -13835058055282163712
- end
-
- it "returns self bitwise AND other when both are negative and a multiple in bitsize of Fixnum::MIN" do
- val = - ((1 << 93) - 1)
- (val & val).should == val
-
- val = - ((1 << 126) - 1)
- (val & val).should == val
- end
-
- it "raises a TypeError when passed a Float" do
- -> { (@bignum & 3.4) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError and does not call #to_int when defined on an object" do
- obj = mock("bignum bit and")
- obj.should_not_receive(:to_int)
-
- -> { @bignum & obj }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/bit_length_spec.rb b/spec/ruby/core/integer/bit_length_spec.rb
deleted file mode 100644
index 827007b7e0..0000000000
--- a/spec/ruby/core/integer/bit_length_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#bit_length" do
- context "fixnum" do
- it "returns the position of the leftmost bit of a positive number" do
- 0.bit_length.should == 0
- 1.bit_length.should == 1
- 2.bit_length.should == 2
- 3.bit_length.should == 2
- 4.bit_length.should == 3
- n = fixnum_max.bit_length
- fixnum_max[n].should == 0
- fixnum_max[n - 1].should == 1
-
- 0.bit_length.should == 0
- 1.bit_length.should == 1
- 0xff.bit_length.should == 8
- 0x100.bit_length.should == 9
- (2**12 - 1).bit_length.should == 12
- (2**12).bit_length.should == 13
- (2**12 + 1).bit_length.should == 13
- end
-
- it "returns the position of the leftmost 0 bit of a negative number" do
- -1.bit_length.should == 0
- -2.bit_length.should == 1
- -3.bit_length.should == 2
- -4.bit_length.should == 2
- -5.bit_length.should == 3
- n = fixnum_min.bit_length
- fixnum_min[n].should == 1
- fixnum_min[n - 1].should == 0
-
- (-2**12 - 1).bit_length.should == 13
- (-2**12).bit_length.should == 12
- (-2**12 + 1).bit_length.should == 12
- -0x101.bit_length.should == 9
- -0x100.bit_length.should == 8
- -0xff.bit_length.should == 8
- -2.bit_length.should == 1
- -1.bit_length.should == 0
- end
- end
-
- context "bignum" do
- it "returns the position of the leftmost bit of a positive number" do
- (2**1000-1).bit_length.should == 1000
- (2**1000).bit_length.should == 1001
- (2**1000+1).bit_length.should == 1001
-
- (2**10000-1).bit_length.should == 10000
- (2**10000).bit_length.should == 10001
- (2**10000+1).bit_length.should == 10001
-
- (1 << 100).bit_length.should == 101
- (1 << 100).succ.bit_length.should == 101
- (1 << 100).pred.bit_length.should == 100
- (1 << 10000).bit_length.should == 10001
- end
-
- it "returns the position of the leftmost 0 bit of a negative number" do
- (-2**10000-1).bit_length.should == 10001
- (-2**10000).bit_length.should == 10000
- (-2**10000+1).bit_length.should == 10000
-
- (-2**1000-1).bit_length.should == 1001
- (-2**1000).bit_length.should == 1000
- (-2**1000+1).bit_length.should == 1000
-
- ((-1 << 100)-1).bit_length.should == 101
- ((-1 << 100)-1).succ.bit_length.should == 100
- ((-1 << 100)-1).pred.bit_length.should == 101
- ((-1 << 10000)-1).bit_length.should == 10001
- end
- end
-end
diff --git a/spec/ruby/core/integer/bit_or_spec.rb b/spec/ruby/core/integer/bit_or_spec.rb
deleted file mode 100644
index e486eeec10..0000000000
--- a/spec/ruby/core/integer/bit_or_spec.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#|" do
- context "fixnum" do
- it "returns self bitwise OR other" do
- (1 | 0).should == 1
- (5 | 4).should == 5
- (5 | 6).should == 7
- (248 | 4096).should == 4344
- (0xffff | bignum_value + 0xf0f0).should == 0x8000_0000_0000_ffff
- end
-
- it "returns self bitwise OR a bignum" do
- (-1 | 2**64).should == -1
- end
-
- it "raises a TypeError when passed a Float" do
- -> { (3 | 3.4) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError and does not call #to_int when defined on an object" do
- obj = mock("integer bit or")
- obj.should_not_receive(:to_int)
-
- -> { 3 | obj }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(11)
- end
-
- it "returns self bitwise OR other" do
- (@bignum | 2).should == 9223372036854775819
- (@bignum | 9).should == 9223372036854775819
- (@bignum | bignum_value).should == 9223372036854775819
- end
-
- it "returns self bitwise OR other when one operand is negative" do
- (@bignum | -0x40000000000000000).should == -64563604257983430645
- (@bignum | -@bignum).should == -1
- (@bignum | -0x8000000000000000).should == -9223372036854775797
- end
-
- it "returns self bitwise OR other when both operands are negative" do
- (-@bignum | -0x4000000000000005).should == -1
- (-@bignum | -@bignum).should == -9223372036854775819
- (-@bignum | -0x4000000000000000).should == -11
- end
-
- it "raises a TypeError when passed a Float" do
- not_supported_on :opal do
- -> {
- bignum_value | bignum_value(0xffff).to_f
- }.should raise_error(TypeError)
- end
- -> { @bignum | 9.9 }.should raise_error(TypeError)
- end
-
- it "raises a TypeError and does not call #to_int when defined on an object" do
- obj = mock("bignum bit or")
- obj.should_not_receive(:to_int)
-
- -> { @bignum | obj }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/bit_xor_spec.rb b/spec/ruby/core/integer/bit_xor_spec.rb
deleted file mode 100644
index ac8826a52f..0000000000
--- a/spec/ruby/core/integer/bit_xor_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#^" do
- context "fixnum" do
- it "returns self bitwise EXCLUSIVE OR other" do
- (3 ^ 5).should == 6
- (-2 ^ -255).should == 255
- (5 ^ bignum_value + 0xffff_ffff).should == 0x8000_0000_ffff_fffa
- end
-
- it "returns self bitwise EXCLUSIVE OR a bignum" do
- (-1 ^ 2**64).should == -18446744073709551617
- end
-
- it "raises a TypeError when passed a Float" do
- -> { (3 ^ 3.4) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError and does not call #to_int when defined on an object" do
- obj = mock("integer bit xor")
- obj.should_not_receive(:to_int)
-
- -> { 3 ^ obj }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(18)
- end
-
- it "returns self bitwise EXCLUSIVE OR other" do
- (@bignum ^ 2).should == 9223372036854775824
- (@bignum ^ @bignum).should == 0
- (@bignum ^ 14).should == 9223372036854775836
- end
-
- it "returns self bitwise EXCLUSIVE OR other when one operand is negative" do
- (@bignum ^ -0x40000000000000000).should == -64563604257983430638
- (@bignum ^ -@bignum).should == -4
- (@bignum ^ -0x8000000000000000).should == -18446744073709551598
- end
-
- it "returns self bitwise EXCLUSIVE OR other when both operands are negative" do
- (-@bignum ^ -0x40000000000000000).should == 64563604257983430638
- (-@bignum ^ -@bignum).should == 0
- (-@bignum ^ -0x4000000000000000).should == 13835058055282163694
- end
-
- it "returns self bitwise EXCLUSIVE OR other when all bits are 1 and other value is negative" do
- (9903520314283042199192993791 ^ -1).should == -9903520314283042199192993792
- (784637716923335095479473677900958302012794430558004314111 ^ -1).should ==
- -784637716923335095479473677900958302012794430558004314112
- end
-
- it "raises a TypeError when passed a Float" do
- not_supported_on :opal do
- -> {
- bignum_value ^ bignum_value(0xffff).to_f
- }.should raise_error(TypeError)
- end
- -> { @bignum ^ 14.5 }.should raise_error(TypeError)
- end
-
- it "raises a TypeError and does not call #to_int when defined on an object" do
- obj = mock("bignum bit xor")
- obj.should_not_receive(:to_int)
-
- -> { @bignum ^ obj }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/case_compare_spec.rb b/spec/ruby/core/integer/case_compare_spec.rb
deleted file mode 100644
index e5dde2c64a..0000000000
--- a/spec/ruby/core/integer/case_compare_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal'
-
-describe "Integer#===" do
- it_behaves_like :integer_equal, :===
-end
diff --git a/spec/ruby/core/integer/ceil_spec.rb b/spec/ruby/core/integer/ceil_spec.rb
index 13bdaf838d..31c56f378d 100644
--- a/spec/ruby/core/integer/ceil_spec.rb
+++ b/spec/ruby/core/integer/ceil_spec.rb
@@ -1,19 +1,21 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
-require_relative 'shared/integer_rounding'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
+require File.expand_path('../shared/integer_rounding', __FILE__)
describe "Integer#ceil" do
- it_behaves_like :integer_to_i, :ceil
- it_behaves_like :integer_rounding_positive_precision, :ceil
+ it_behaves_like(:integer_to_i, :ceil)
+ it_behaves_like(:integer_rounding_positive_precision, :ceil)
- context "precision argument specified as part of the ceil method is negative" do
- it "returns the smallest integer greater than self with at least precision.abs trailing zeros" do
- 18.ceil(-1).should eql(20)
- 18.ceil(-2).should eql(100)
- 18.ceil(-3).should eql(1000)
- -1832.ceil(-1).should eql(-1830)
- -1832.ceil(-2).should eql(-1800)
- -1832.ceil(-3).should eql(-1000)
+ ruby_version_is "2.4" do
+ context "precision argument specified as part of the ceil method is negative" do
+ it "returns the smallest integer greater than self with at least precision.abs trailing zeros" do
+ 18.ceil(-1).should eql(20)
+ 18.ceil(-2).should eql(100)
+ 18.ceil(-3).should eql(1000)
+ -1832.ceil(-1).should eql(-1830)
+ -1832.ceil(-2).should eql(-1800)
+ -1832.ceil(-3).should eql(-1000)
+ end
end
end
end
diff --git a/spec/ruby/core/integer/chr_spec.rb b/spec/ruby/core/integer/chr_spec.rb
index a8755eeb84..50a678608e 100644
--- a/spec/ruby/core/integer/chr_spec.rb
+++ b/spec/ruby/core/integer/chr_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#chr without argument" do
it "returns a String" do
@@ -10,8 +10,8 @@ describe "Integer#chr without argument" do
end
it "raises a RangeError is self is less than 0" do
- -> { -1.chr }.should raise_error(RangeError)
- -> { -bignum_value.chr }.should raise_error(RangeError)
+ lambda { -1.chr }.should raise_error(RangeError)
+ lambda { -bignum_value.chr }.should raise_error(RangeError)
end
describe "when Encoding.default_internal is nil" do
@@ -30,9 +30,9 @@ describe "Integer#chr without argument" do
end
describe "and self is between 128 and 255 (inclusive)" do
- it "returns a binary String" do
+ it "returns an ASCII-8BIT String" do
(128..255).each do |c|
- c.chr.encoding.should == Encoding::BINARY
+ c.chr.encoding.should == Encoding::ASCII_8BIT
end
end
@@ -44,8 +44,8 @@ describe "Integer#chr without argument" do
end
it "raises a RangeError is self is greater than 255" do
- -> { 256.chr }.should raise_error(RangeError)
- -> { bignum_value.chr }.should raise_error(RangeError)
+ lambda { 256.chr }.should raise_error(RangeError)
+ lambda { bignum_value.chr }.should raise_error(RangeError)
end
end
@@ -81,13 +81,13 @@ describe "Integer#chr without argument" do
end
describe "and self is between 128 and 255 (inclusive)" do
- it "returns a binary String" do
+ it "returns an ASCII-8BIT String" do
(128..255).each do |c|
Encoding.default_internal = Encoding::UTF_8
- c.chr.encoding.should == Encoding::BINARY
+ c.chr.encoding.should == Encoding::ASCII_8BIT
Encoding.default_internal = Encoding::SHIFT_JIS
- c.chr.encoding.should == Encoding::BINARY
+ c.chr.encoding.should == Encoding::ASCII_8BIT
end
end
@@ -126,14 +126,14 @@ describe "Integer#chr without argument" do
# #5864
it "raises RangeError if self is invalid as a codepoint in the default internal encoding" do
[ [0x0100, "US-ASCII"],
- [0x0100, "BINARY"],
+ [0x0100, "ASCII-8BIT"],
[0x0100, "EUC-JP"],
[0xA1A0, "EUC-JP"],
[0x0100, "ISO-8859-9"],
[620, "TIS-620"]
].each do |integer, encoding_name|
Encoding.default_internal = Encoding.find(encoding_name)
- -> { integer.chr }.should raise_error(RangeError)
+ lambda { integer.chr }.should raise_error(RangeError)
end
end
end
@@ -150,7 +150,7 @@ describe "Integer#chr with an encoding argument" do
end
it "accepts a String as an argument" do
- -> { 0xA4A2.chr('euc-jp') }.should_not raise_error
+ lambda { 0xA4A2.chr('euc-jp') }.should_not raise_error
end
it "converts a String to an Encoding as Encoding.find does" do
@@ -161,22 +161,18 @@ describe "Integer#chr with an encoding argument" do
# http://redmine.ruby-lang.org/issues/4869
it "raises a RangeError is self is less than 0" do
- -> { -1.chr(Encoding::UTF_8) }.should raise_error(RangeError)
- -> { -bignum_value.chr(Encoding::EUC_JP) }.should raise_error(RangeError)
- end
-
- it "raises a RangeError if self is too large" do
- -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError)
+ lambda { -1.chr(Encoding::UTF_8) }.should raise_error(RangeError)
+ lambda { -bignum_value.chr(Encoding::EUC_JP) }.should raise_error(RangeError)
end
it "returns a String with the specified encoding" do
0x0000.chr(Encoding::US_ASCII).encoding.should == Encoding::US_ASCII
0x007F.chr(Encoding::US_ASCII).encoding.should == Encoding::US_ASCII
- 0x0000.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
- 0x007F.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
- 0x0080.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
- 0x00FF.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
+ 0x0000.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
+ 0x007F.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
+ 0x0080.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
+ 0x00FF.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
0x0000.chr(Encoding::UTF_8).encoding.should == Encoding::UTF_8
0x007F.chr(Encoding::UTF_8).encoding.should == Encoding::UTF_8
@@ -197,10 +193,10 @@ describe "Integer#chr with an encoding argument" do
0x0000.chr(Encoding::US_ASCII).bytes.to_a.should == [0x00]
0x007F.chr(Encoding::US_ASCII).bytes.to_a.should == [0x7F]
- 0x0000.chr(Encoding::BINARY).bytes.to_a.should == [0x00]
- 0x007F.chr(Encoding::BINARY).bytes.to_a.should == [0x7F]
- 0x0080.chr(Encoding::BINARY).bytes.to_a.should == [0x80]
- 0x00FF.chr(Encoding::BINARY).bytes.to_a.should == [0xFF]
+ 0x0000.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x00]
+ 0x007F.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x7F]
+ 0x0080.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x80]
+ 0x00FF.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0xFF]
0x0000.chr(Encoding::UTF_8).bytes.to_a.should == [0x00]
0x007F.chr(Encoding::UTF_8).bytes.to_a.should == [0x7F]
@@ -220,7 +216,7 @@ describe "Integer#chr with an encoding argument" do
# #5864
it "raises RangeError if self is invalid as a codepoint in the specified encoding" do
[ [0x80, "US-ASCII"],
- [0x0100, "BINARY"],
+ [0x0100, "ASCII-8BIT"],
[0x0100, "EUC-JP"],
[0xA1A0, "EUC-JP"],
[0xA1, "EUC-JP"],
@@ -237,7 +233,7 @@ describe "Integer#chr with an encoding argument" do
[0xDC00, "UTF-16"],
[0xDFFF, "UTF-16"],
].each do |integer, encoding_name|
- -> { integer.chr(encoding_name) }.should raise_error(RangeError)
+ lambda { integer.chr(encoding_name) }.should raise_error(RangeError)
end
end
end
diff --git a/spec/ruby/core/integer/coerce_spec.rb b/spec/ruby/core/integer/coerce_spec.rb
deleted file mode 100644
index 9a19baf2ea..0000000000
--- a/spec/ruby/core/integer/coerce_spec.rb
+++ /dev/null
@@ -1,104 +0,0 @@
-require_relative '../../spec_helper'
-
-require 'bigdecimal'
-
-describe "Integer#coerce" do
- context "fixnum" do
- describe "when given a Fixnum" do
- it "returns an array containing two Fixnums" do
- 1.coerce(2).should == [2, 1]
- 1.coerce(2).map { |i| i.class }.should == [Fixnum, Fixnum]
- end
- end
-
- describe "when given a String" do
- it "raises an ArgumentError when trying to coerce with a non-number String" do
- -> { 1.coerce(":)") }.should raise_error(ArgumentError)
- end
-
- it "returns an array containing two Floats" do
- 1.coerce("2").should == [2.0, 1.0]
- 1.coerce("-2").should == [-2.0, 1.0]
- end
- end
-
- it "raises a TypeError when trying to coerce with nil" do
- -> { 1.coerce(nil) }.should raise_error(TypeError)
- end
-
- it "tries to convert the given Object into a Float by using #to_f" do
- (obj = mock('1.0')).should_receive(:to_f).and_return(1.0)
- 2.coerce(obj).should == [1.0, 2.0]
-
- (obj = mock('0')).should_receive(:to_f).and_return('0')
- -> { 2.coerce(obj).should == [1.0, 2.0] }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when given an Object that does not respond to #to_f" do
- -> { 1.coerce(mock('x')) }.should raise_error(TypeError)
- -> { 1.coerce(1..4) }.should raise_error(TypeError)
- -> { 1.coerce(:test) }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- it "coerces other to a Bignum and returns [other, self] when passed a Fixnum" do
- a = bignum_value
- ary = a.coerce(2)
-
- ary[0].should be_kind_of(Bignum)
- ary[1].should be_kind_of(Bignum)
- ary.should == [2, a]
- end
-
- it "returns [other, self] when passed a Bignum" do
- a = bignum_value
- b = bignum_value
- ary = a.coerce(b)
-
- ary[0].should be_kind_of(Bignum)
- ary[1].should be_kind_of(Bignum)
- ary.should == [b, a]
- end
-
- it "raises a TypeError when not passed a Fixnum or Bignum" do
- a = bignum_value
-
- -> { a.coerce(nil) }.should raise_error(TypeError)
- -> { a.coerce(mock('str')) }.should raise_error(TypeError)
- -> { a.coerce(1..4) }.should raise_error(TypeError)
- -> { a.coerce(:test) }.should raise_error(TypeError)
- end
-
- it "coerces both values to Floats and returns [other, self] when passed a Float" do
- a = bignum_value
- a.coerce(1.2).should == [1.2, a.to_f]
- end
-
- it "coerces both values to Floats and returns [other, self] when passed a String" do
- a = bignum_value
- a.coerce("123").should == [123.0, a.to_f]
- end
-
- it "calls #to_f to coerce other to a Float" do
- b = mock("bignum value")
- b.should_receive(:to_f).and_return(1.2)
-
- a = bignum_value
- ary = a.coerce(b)
-
- ary.should == [1.2, a.to_f]
- end
- end
-
- context "bigdecimal" do
- it "produces Floats" do
- x, y = 3.coerce(BigDecimal("3.4"))
- x.class.should == Float
- x.should == 3.4
- y.class.should == Float
- y.should == 3.0
- end
- end
-
-end
diff --git a/spec/ruby/core/integer/comparison_spec.rb b/spec/ruby/core/integer/comparison_spec.rb
deleted file mode 100644
index 2ff557c7c6..0000000000
--- a/spec/ruby/core/integer/comparison_spec.rb
+++ /dev/null
@@ -1,189 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#<=>" do
- context "fixnum" do
- it "returns -1 when self is less than the given argument" do
- (-3 <=> -1).should == -1
- (-5 <=> 10).should == -1
- (-5 <=> -4.5).should == -1
- end
-
- it "returns 0 when self is equal to the given argument" do
- (0 <=> 0).should == 0
- (954 <=> 954).should == 0
- (954 <=> 954.0).should == 0
- end
-
- it "returns 1 when self is greater than the given argument" do
- (496 <=> 5).should == 1
- (200 <=> 100).should == 1
- (51 <=> 50.5).should == 1
- end
-
- it "returns nil when the given argument is not an Integer" do
- (3 <=> mock('x')).should == nil
- (3 <=> 'test').should == nil
- end
- end
-
- context "bignum" do
- describe "with a Fixnum" do
- it "returns -1 when other is larger" do
- (-bignum_value <=> 2).should == -1
- end
-
- it "returns 1 when other is smaller" do
- (bignum_value <=> 2).should == 1
- end
- end
-
- describe "with a Bignum" do
- describe "when other is negative" do
- it "returns -1 when self is negative and other is larger" do
- (-bignum_value(42) <=> -bignum_value).should == -1
- end
-
- it "returns 0 when other is equal" do
- (-bignum_value <=> -bignum_value).should == 0
- end
-
- it "returns 1 when self is negative and other is smaller" do
- (-bignum_value <=> -bignum_value(94)).should == 1
- end
-
- it "returns 1 when self is positive" do
- (bignum_value <=> -bignum_value).should == 1
- end
- end
-
- describe "when other is positive" do
- it "returns -1 when self is negative" do
- (-bignum_value <=> bignum_value).should == -1
- end
-
- it "returns -1 when self is positive and other is larger" do
- (bignum_value <=> bignum_value(38)).should == -1
- end
-
- it "returns 0 when other is equal" do
- (bignum_value <=> bignum_value).should == 0
- end
-
- it "returns 1 when other is smaller" do
- (bignum_value(56) <=> bignum_value).should == 1
- end
- end
- end
-
- describe "with a Float" do
- describe "when other is negative" do
- it "returns -1 when self is negative and other is larger" do
- (-bignum_value(0xffff) <=> -bignum_value.to_f).should == -1
- end
-
- it "returns 0 when other is equal" do
- (-bignum_value <=> -bignum_value.to_f).should == 0
- end
-
- it "returns 1 when self is negative and other is smaller" do
- (-bignum_value <=> -bignum_value(0xffef).to_f).should == 1
- end
-
- it "returns 1 when self is positive" do
- (bignum_value <=> -bignum_value.to_f).should == 1
- end
- end
-
- describe "when other is positive" do
- it "returns -1 when self is negative" do
- (-bignum_value <=> bignum_value.to_f).should == -1
- end
-
- it "returns -1 when self is positive and other is larger" do
- (bignum_value <=> bignum_value(0xfffe).to_f).should == -1
- end
-
- it "returns 0 when other is equal" do
- (bignum_value <=> bignum_value.to_f).should == 0
- end
-
- it "returns 1 when other is smaller" do
- (bignum_value(0xfeff) <=> bignum_value.to_f).should == 1
- end
- end
- end
-
- describe "with an Object" do
- before :each do
- @big = bignum_value
- @num = mock("value for Bignum#<=>")
- end
-
- it "calls #coerce on other" do
- @num.should_receive(:coerce).with(@big).and_return([@big.to_f, 2.5])
- @big <=> @num
- end
-
- ruby_version_is ""..."2.5" do
- it "returns nil if #coerce raises an exception" do
- @num.should_receive(:coerce).with(@big).and_raise(RuntimeError)
- -> {
- @result = (@big <=> @num)
- }.should complain(/Numerical comparison operators will no more rescue exceptions/)
- @result.should be_nil
- end
- end
-
- ruby_version_is "2.5" do
- it "lets the exception go through if #coerce raises an exception" do
- @num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error"))
- -> {
- @big <=> @num
- }.should raise_error(RuntimeError, "my error")
- end
- end
-
- it "raises an exception if #coerce raises a non-StandardError exception" do
- @num.should_receive(:coerce).with(@big).and_raise(Exception)
- -> { @big <=> @num }.should raise_error(Exception)
- end
-
- it "returns nil if #coerce does not return an Array" do
- @num.should_receive(:coerce).with(@big).and_return(nil)
- (@big <=> @num).should be_nil
- end
-
- it "returns -1 if the coerced value is larger" do
- @num.should_receive(:coerce).with(@big).and_return([@big, bignum_value(10)])
- (@big <=> @num).should == -1
- end
-
- it "returns 0 if the coerced value is equal" do
- @num.should_receive(:coerce).with(@big).and_return([@big, bignum_value])
- (@big <=> @num).should == 0
- end
-
- it "returns 1 if the coerced value is smaller" do
- @num.should_receive(:coerce).with(@big).and_return([@big, 22])
- (@big <=> @num).should == 1
- end
- end
-
- # The tests below are taken from matz's revision 23730 for Ruby trunk
- it "returns 1 when self is Infinity and other is a Bignum" do
- (infinity_value <=> Float::MAX.to_i*2).should == 1
- end
-
- it "returns -1 when self is negative and other is Infinity" do
- (-Float::MAX.to_i*2 <=> infinity_value).should == -1
- end
-
- it "returns 1 when self is negative and other is -Infinity" do
- (-Float::MAX.to_i*2 <=> -infinity_value).should == 1
- end
-
- it "returns -1 when self is -Infinity and other is negative" do
- (-infinity_value <=> -Float::MAX.to_i*2).should == -1
- end
- end
-end
diff --git a/spec/ruby/core/integer/complement_spec.rb b/spec/ruby/core/integer/complement_spec.rb
deleted file mode 100644
index eafa5c263f..0000000000
--- a/spec/ruby/core/integer/complement_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#~" do
- context "fixnum" do
- it "returns self with each bit flipped" do
- (~0).should == -1
- (~1221).should == -1222
- (~-2).should == 1
- (~-599).should == 598
- end
- end
-
- context "bignum" do
- it "returns self with each bit flipped" do
- (~bignum_value(48)).should == -9223372036854775857
- (~(-bignum_value(21))).should == 9223372036854775828
- (~bignum_value(1)).should == -9223372036854775810
- end
- end
-end
diff --git a/spec/ruby/core/integer/constants_spec.rb b/spec/ruby/core/integer/constants_spec.rb
deleted file mode 100644
index cdb7537392..0000000000
--- a/spec/ruby/core/integer/constants_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is ""..."2.7" do
- describe "Fixnum" do
- it "is unified into Integer" do
- suppress_warning do
- Fixnum.should equal(Integer)
- end
- end
-
- it "is deprecated" do
- -> { Fixnum }.should complain(/constant ::Fixnum is deprecated/)
- end
- end
-
- describe "Bignum" do
- it "is unified into Integer" do
- suppress_warning do
- Bignum.should equal(Integer)
- end
- end
-
- it "is deprecated" do
- -> { Bignum }.should complain(/constant ::Bignum is deprecated/)
- end
- end
-end
diff --git a/spec/ruby/core/integer/denominator_spec.rb b/spec/ruby/core/integer/denominator_spec.rb
index c1477d0757..6d080ac81f 100644
--- a/spec/ruby/core/integer/denominator_spec.rb
+++ b/spec/ruby/core/integer/denominator_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#denominator" do
# The Numeric child classes override this method, so their behaviour is
diff --git a/spec/ruby/core/integer/digits_spec.rb b/spec/ruby/core/integer/digits_spec.rb
index 4a8e33980c..3546a654eb 100644
--- a/spec/ruby/core/integer/digits_spec.rb
+++ b/spec/ruby/core/integer/digits_spec.rb
@@ -1,32 +1,34 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Integer#digits" do
- it "returns an array of place values in base-10 by default" do
- 12345.digits.should == [5,4,3,2,1]
- end
+ruby_version_is "2.4" do
+ describe "Integer#digits" do
+ it "returns an array of place values in base-10 by default" do
+ 12345.digits.should == [5,4,3,2,1]
+ end
- it "returns digits by place value of a given radix" do
- 12345.digits(7).should == [4,6,6,0,5]
- end
+ it "returns digits by place value of a given radix" do
+ 12345.digits(7).should == [4,6,6,0,5]
+ end
- it "converts the radix with #to_int" do
- 12345.digits(mock_int(2)).should == [1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1]
- end
+ it "converts the radix with #to_int" do
+ 12345.digits(mock_int(2)).should == [1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1]
+ end
- it "returns [0] when called on 0, regardless of base" do
- 0.digits.should == [0]
- 0.digits(7).should == [0]
- end
+ it "returns [0] when called on 0, regardless of base" do
+ 0.digits.should == [0]
+ 0.digits(7).should == [0]
+ end
- it "raises ArgumentError when calling with a radix less than 2" do
- -> { 12345.digits(1) }.should raise_error(ArgumentError)
- end
+ it "raises ArgumentError when calling with a radix less than 2" do
+ lambda { 12345.digits(1) }.should raise_error(ArgumentError)
+ end
- it "raises ArgumentError when calling with a negative radix" do
- -> { 12345.digits(-2) }.should raise_error(ArgumentError)
- end
+ it "raises ArgumentError when calling with a negative radix" do
+ lambda { 12345.digits(-2) }.should raise_error(ArgumentError)
+ end
- it "raises Math::DomainError when calling digits on a negative number" do
- -> { -12345.digits(7) }.should raise_error(Math::DomainError)
+ it "raises Math::DomainError when calling digits on a negative number" do
+ lambda { -12345.digits(7) }.should raise_error(Math::DomainError)
+ end
end
end
diff --git a/spec/ruby/core/integer/div_spec.rb b/spec/ruby/core/integer/div_spec.rb
deleted file mode 100644
index 087d012fe0..0000000000
--- a/spec/ruby/core/integer/div_spec.rb
+++ /dev/null
@@ -1,146 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#div" do
- context "fixnum" do
- it "returns self divided by the given argument as an Integer" do
- 2.div(2).should == 1
- 1.div(2).should == 0
- 5.div(2).should == 2
- end
-
- it "rounds towards -inf" do
- 8192.div(10).should == 819
- 8192.div(-10).should == -820
- (-8192).div(10).should == -820
- (-8192).div(-10).should == 819
- end
-
- it "means (x / y).floor" do
- 5.div(2).should == (5 / 2).floor
- 5.div(2.0).should == (5 / 2.0).floor
- 5.div(-2).should == (5 / -2).floor
-
- 5.div(100).should == (5 / 100).floor
- 5.div(100.0).should == (5 / 100.0).floor
- 5.div(-100).should == (5 / -100).floor
- end
-
- it "calls #coerce and #div if argument responds to #coerce" do
- x = mock("x")
- y = mock("y")
- result = mock("result")
-
- y.should_receive(:coerce).and_return([x, y])
- x.should_receive(:div).with(y).and_return(result)
-
- 10.div(y).should == result
- end
-
- it "coerces self and the given argument to Floats and returns self divided by other as Fixnum" do
- 1.div(0.2).should == 5
- 1.div(0.16).should == 6
- 1.div(0.169).should == 5
- -1.div(50.4).should == -1
- 1.div(bignum_value).should == 0
- 1.div(Rational(1, 5)).should == 5
- end
-
- it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
- -> { 0.div(0.0) }.should raise_error(ZeroDivisionError)
- -> { 10.div(0.0) }.should raise_error(ZeroDivisionError)
- -> { -10.div(0.0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a ZeroDivisionError when the given argument is 0 and not a Float" do
- -> { 13.div(0) }.should raise_error(ZeroDivisionError)
- -> { 13.div(-0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a TypeError when given a non-numeric argument" do
- -> { 13.div(mock('10')) }.should raise_error(TypeError)
- -> { 5.div("2") }.should raise_error(TypeError)
- -> { 5.div(:"2") }.should raise_error(TypeError)
- -> { 5.div([]) }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(88)
- end
-
- it "returns self divided by other" do
- @bignum.div(4).should == 2305843009213693974
- @bignum.div(Rational(4, 1)).should == 2305843009213693974
- @bignum.div(bignum_value(2)).should == 1
-
- (-(10**50)).div(-(10**40 + 1)).should == 9999999999
- (10**50).div(10**40 + 1).should == 9999999999
-
- (-10**50).div(10**40 + 1).should == -10000000000
- (10**50).div(-(10**40 + 1)).should == -10000000000
- end
-
- it "handles fixnum_min / -1" do
- (fixnum_min / -1).should == -fixnum_min
- (fixnum_min / -1).should > 0
-
- int_min = -2147483648
- (int_min / -1).should == 2147483648
- end
-
- it "calls #coerce and #div if argument responds to #coerce" do
- x = mock("x")
- y = mock("y")
- result = mock("result")
-
- y.should_receive(:coerce).and_return([x, y])
- x.should_receive(:div).with(y).and_return(result)
-
- @bignum.div(y).should == result
- end
-
- it "means (x / y).floor" do
- @bignum.div(2).should == (@bignum / 2).floor
- @bignum.div(-2).should == (@bignum / -2).floor
-
- @bignum.div(@bignum+1).should == (@bignum / (@bignum+1)).floor
- @bignum.div(-(@bignum+1)).should == (@bignum / -(@bignum+1)).floor
-
- @bignum.div(2.0).should == (@bignum / 2.0).floor
- @bignum.div(100.0).should == (@bignum / 100.0).floor
- end
-
- it "looses precision if passed Float argument" do
- @bignum.div(1).should_not == @bignum.div(1.0)
- @bignum.div(4).should_not == @bignum.div(4.0)
- @bignum.div(21).should_not == @bignum.div(21.0)
- end
-
- it "raises a TypeError when given a non-numeric" do
- -> { @bignum.div(mock("10")) }.should raise_error(TypeError)
- -> { @bignum.div("2") }.should raise_error(TypeError)
- -> { @bignum.div(:symbol) }.should raise_error(TypeError)
- end
-
- it "returns a result of integer division of self by a float argument" do
- @bignum.div(4294967295.5).should eql(2147483648)
- not_supported_on :opal do
- @bignum.div(4294967295.0).should eql(2147483648)
- @bignum.div(bignum_value(88).to_f).should eql(1)
- @bignum.div(-bignum_value(88).to_f).should eql(-1)
- end
- end
-
- # #5490
- it "raises ZeroDivisionError if the argument is 0 and is a Float" do
- -> { @bignum.div(0.0) }.should raise_error(ZeroDivisionError)
- -> { @bignum.div(-0.0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises ZeroDivisionError if the argument is 0 and is not a Float" do
- -> { @bignum.div(0) }.should raise_error(ZeroDivisionError)
- -> { @bignum.div(-0) }.should raise_error(ZeroDivisionError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/divide_spec.rb b/spec/ruby/core/integer/divide_spec.rb
deleted file mode 100644
index a32d68c229..0000000000
--- a/spec/ruby/core/integer/divide_spec.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arithmetic_coerce'
-
-describe "Integer#/" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :/
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :/
- end
-
- context "fixnum" do
- it "returns self divided by the given argument" do
- (2 / 2).should == 1
- (3 / 2).should == 1
- end
-
- it "supports dividing negative numbers" do
- (-1 / 10).should == -1
- end
-
- it "returns result the same class as the argument" do
- (3 / 2).should == 1
- (3 / 2.0).should == 1.5
- (3 / Rational(2, 1)).should == Rational(3, 2)
- end
-
- it "raises a ZeroDivisionError if the given argument is zero and not a Float" do
- -> { 1 / 0 }.should raise_error(ZeroDivisionError)
- end
-
- it "does NOT raise ZeroDivisionError if the given argument is zero and is a Float" do
- (1 / 0.0).to_s.should == 'Infinity'
- (-1 / 0.0).to_s.should == '-Infinity'
- end
-
- it "coerces fixnum and return self divided by other" do
- (-1 / 50.4).should be_close(-0.0198412698412698, TOLERANCE)
- (1 / bignum_value).should == 0
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> { 13 / mock('10') }.should raise_error(TypeError)
- -> { 13 / "10" }.should raise_error(TypeError)
- -> { 13 / :symbol }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(88)
- end
-
- it "returns self divided by other" do
- (@bignum / 4).should == 2305843009213693974
-
- (@bignum / bignum_value(2)).should == 1
-
- (-(10**50) / -(10**40 + 1)).should == 9999999999
- ((10**50) / (10**40 + 1)).should == 9999999999
-
- ((-10**50) / (10**40 + 1)).should == -10000000000
- ((10**50) / -(10**40 + 1)).should == -10000000000
- end
-
- it "returns self divided by Float" do
- not_supported_on :opal do
- (bignum_value(88) / 4294967295.0).should be_close(2147483648.5, TOLERANCE)
- end
- (bignum_value(88) / 4294967295.5).should be_close(2147483648.25, TOLERANCE)
- end
-
- it "returns result the same class as the argument" do
- (@bignum / 4).should == 2305843009213693974
- (@bignum / 4.0).should be_close(2305843009213693974, TOLERANCE)
- (@bignum / Rational(4, 1)).should == Rational(2305843009213693974, 1)
- end
-
- it "does NOT raise ZeroDivisionError if other is zero and is a Float" do
- (bignum_value / 0.0).to_s.should == 'Infinity'
- (bignum_value / -0.0).to_s.should == '-Infinity'
- end
-
- it "raises a ZeroDivisionError if other is zero and not a Float" do
- -> { @bignum / 0 }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a TypeError when given a non-numeric" do
- -> { @bignum / mock('10') }.should raise_error(TypeError)
- -> { @bignum / "2" }.should raise_error(TypeError)
- -> { @bignum / :symbol }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/divmod_spec.rb b/spec/ruby/core/integer/divmod_spec.rb
deleted file mode 100644
index d88925caad..0000000000
--- a/spec/ruby/core/integer/divmod_spec.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#divmod" do
- context "fixnum" do
- it "returns an Array containing quotient and modulus obtained from dividing self by the given argument" do
- 13.divmod(4).should == [3, 1]
- 4.divmod(13).should == [0, 4]
-
- 13.divmod(4.0).should == [3, 1]
- 4.divmod(13.0).should == [0, 4]
-
- 1.divmod(2.0).should == [0, 1.0]
- 200.divmod(bignum_value).should == [0, 200]
- end
-
- it "raises a ZeroDivisionError when the given argument is 0" do
- -> { 13.divmod(0) }.should raise_error(ZeroDivisionError)
- -> { 0.divmod(0) }.should raise_error(ZeroDivisionError)
- -> { -10.divmod(0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
- -> { 0.divmod(0.0) }.should raise_error(ZeroDivisionError)
- -> { 10.divmod(0.0) }.should raise_error(ZeroDivisionError)
- -> { -10.divmod(0.0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
- 13.divmod(obj)
- }.should raise_error(TypeError)
- -> { 13.divmod("10") }.should raise_error(TypeError)
- -> { 13.divmod(:symbol) }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(55)
- end
-
- # Based on MRI's test/test_integer.rb (test_divmod),
- # MRI maintains the following property:
- # if q, r = a.divmod(b) ==>
- # assert(0 < b ? (0 <= r && r < b) : (b < r && r <= 0))
- # So, r is always between 0 and b.
- it "returns an Array containing quotient and modulus obtained from dividing self by the given argument" do
- @bignum.divmod(4).should == [2305843009213693965, 3]
- @bignum.divmod(13).should == [709490156681136604, 11]
-
- @bignum.divmod(4.5).should == [2049638230412172288, 3.5]
-
- not_supported_on :opal do
- @bignum.divmod(4.0).should == [2305843009213693952, 0.0]
- @bignum.divmod(13.0).should == [709490156681136640, 8.0]
-
- @bignum.divmod(2.0).should == [4611686018427387904, 0.0]
- end
-
- @bignum.divmod(bignum_value).should == [1, 55]
-
- (-(10**50)).divmod(-(10**40 + 1)).should == [9999999999, -9999999999999999999999999999990000000001]
- (10**50).divmod(10**40 + 1).should == [9999999999, 9999999999999999999999999999990000000001]
-
- (-10**50).divmod(10**40 + 1).should == [-10000000000, 10000000000]
- (10**50).divmod(-(10**40 + 1)).should == [-10000000000, -10000000000]
- end
-
- describe "with q = floor(x/y), a = q*b + r," do
- it "returns [q,r] when a < 0, b > 0 and |a| < b" do
- a = -@bignum + 1
- b = @bignum
- a.divmod(b).should == [-1, 1]
- end
-
- it "returns [q,r] when a > 0, b < 0 and a > |b|" do
- b = -@bignum + 1
- a = @bignum
- a.divmod(b).should == [-2, -@bignum + 2]
- end
-
- it "returns [q,r] when a > 0, b < 0 and a < |b|" do
- a = @bignum - 1
- b = -@bignum
- a.divmod(b).should == [-1, -1]
- end
-
- it "returns [q,r] when a < 0, b < 0 and |a| < |b|" do
- a = -@bignum + 1
- b = -@bignum
- a.divmod(b).should == [0, -@bignum + 1]
- end
- end
-
- it "raises a ZeroDivisionError when the given argument is 0" do
- -> { @bignum.divmod(0) }.should raise_error(ZeroDivisionError)
- -> { (-@bignum).divmod(0) }.should raise_error(ZeroDivisionError)
- end
-
- # Behaviour established as correct in r23953
- it "raises a FloatDomainError if other is NaN" do
- -> { @bignum.divmod(nan_value) }.should raise_error(FloatDomainError)
- end
-
- it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
- -> { @bignum.divmod(0.0) }.should raise_error(ZeroDivisionError)
- -> { (-@bignum).divmod(0.0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a TypeError when the given argument is not an Integer" do
- -> { @bignum.divmod(mock('10')) }.should raise_error(TypeError)
- -> { @bignum.divmod("10") }.should raise_error(TypeError)
- -> { @bignum.divmod(:symbol) }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/downto_spec.rb b/spec/ruby/core/integer/downto_spec.rb
index af7a7e36b9..6b7b353760 100644
--- a/spec/ruby/core/integer/downto_spec.rb
+++ b/spec/ruby/core/integer/downto_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#downto [stop] when self and stop are Fixnums" do
it "does not yield when stop is greater than self" do
@@ -27,8 +27,8 @@ describe "Integer#downto [stop] when self and stop are Fixnums" do
end
it "raises an ArgumentError for invalid endpoints" do
- -> {1.downto("A") {|x| p x } }.should raise_error(ArgumentError)
- -> {1.downto(nil) {|x| p x } }.should raise_error(ArgumentError)
+ lambda {1.downto("A") {|x| p x } }.should raise_error(ArgumentError)
+ lambda {1.downto(nil) {|x| p x } }.should raise_error(ArgumentError)
end
describe "when no block is given" do
@@ -45,9 +45,9 @@ describe "Integer#downto [stop] when self and stop are Fixnums" do
describe "size" do
it "raises an ArgumentError for invalid endpoints" do
enum = 1.downto("A")
- -> { enum.size }.should raise_error(ArgumentError)
+ lambda { enum.size }.should raise_error(ArgumentError)
enum = 1.downto(nil)
- -> { enum.size }.should raise_error(ArgumentError)
+ lambda { enum.size }.should raise_error(ArgumentError)
end
it "returns self - stop + 1" do
diff --git a/spec/ruby/core/integer/dup_spec.rb b/spec/ruby/core/integer/dup_spec.rb
index 7f4d512465..f46bdf89bd 100644
--- a/spec/ruby/core/integer/dup_spec.rb
+++ b/spec/ruby/core/integer/dup_spec.rb
@@ -1,13 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Integer#dup" do
- it "returns self for small integers" do
- integer = 1_000
- integer.dup.should equal(integer)
- end
-
- it "returns self for large integers" do
- integer = 4_611_686_018_427_387_905
- integer.dup.should equal(integer)
+ruby_version_is '2.4' do
+ describe "Integer#dup" do
+ it "returns self" do
+ int = 2
+ int.dup.should equal(int)
+ end
end
end
diff --git a/spec/ruby/core/integer/element_reference_spec.rb b/spec/ruby/core/integer/element_reference_spec.rb
deleted file mode 100644
index 99283fac34..0000000000
--- a/spec/ruby/core/integer/element_reference_spec.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#[]" do
- context "fixnum" do
- it "behaves like (n >> b) & 1" do
- 0b101[1].should == 0
- 0b101[2].should == 1
- end
-
- it "returns 1 if the nth bit is set" do
- 15[1].should == 1
- end
-
- it "returns 1 if the nth bit is set (in two's-complement representation)" do
- (-1)[1].should == 1
- end
-
- it "returns 0 if the nth bit is not set" do
- 8[2].should == 0
- end
-
- it "returns 0 if the nth bit is not set (in two's-complement representation)" do
- (-2)[0].should == 0
- end
-
- it "returns 0 if the nth bit is greater than the most significant bit" do
- 2[3].should == 0
- end
-
- it "returns 1 if self is negative and the nth bit is greater than the most significant bit" do
- (-1)[3].should == 1
- end
-
- it "returns 0 when passed a negative argument" do
- 3[-1].should == 0
- (-1)[-1].should == 0
- end
-
- it "calls #to_int to convert the argument to an Integer and returns 1 if the nth bit is set" do
- obj = mock('1')
- obj.should_receive(:to_int).and_return(1)
-
- 2[obj].should == 1
- end
-
- it "calls #to_int to convert the argument to an Integer and returns 0 if the nth bit is set" do
- obj = mock('0')
- obj.should_receive(:to_int).and_return(0)
-
- 2[obj].should == 0
- end
-
- it "accepts a Float argument and returns 0 if the bit at the truncated value is not set" do
- 13[1.3].should == 0
- end
-
- it "accepts a Float argument and returns 1 if the bit at the truncated value is set" do
- 13[2.1].should == 1
- end
-
- it "raises a TypeError when passed a String" do
- -> { 3["3"] }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when #to_int does not return an Integer" do
- obj = mock('asdf')
- obj.should_receive(:to_int).and_return("asdf")
- -> { 3[obj] }.should raise_error(TypeError)
- end
-
- it "calls #to_int to coerce a String to a Bignum and returns 0" do
- obj = mock('bignum value')
- obj.should_receive(:to_int).and_return(bignum_value)
-
- 3[obj].should == 0
- end
-
- it "returns 0 when passed a Float in the range of a Bignum" do
- 3[bignum_value.to_f].should == 0
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(4996)
- end
-
- it "returns the nth bit in the binary representation of self" do
- @bignum[2].should == 1
- @bignum[9.2].should == 1
- @bignum[21].should == 0
- @bignum[0xffffffff].should == 0
- @bignum[-0xffffffff].should == 0
- end
-
- it "tries to convert the given argument to an Integer using #to_int" do
- @bignum[1.3].should == @bignum[1]
-
- (obj = mock('2')).should_receive(:to_int).at_least(1).and_return(2)
- @bignum[obj].should == 1
- end
-
- it "raises a TypeError when the given argument can't be converted to Integer" do
- obj = mock('asdf')
- -> { @bignum[obj] }.should raise_error(TypeError)
-
- obj.should_receive(:to_int).and_return("asdf")
- -> { @bignum[obj] }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/equal_value_spec.rb b/spec/ruby/core/integer/equal_value_spec.rb
deleted file mode 100644
index 67a73713af..0000000000
--- a/spec/ruby/core/integer/equal_value_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal'
-
-describe "Integer#==" do
- it_behaves_like :integer_equal, :==
-end
diff --git a/spec/ruby/core/integer/even_spec.rb b/spec/ruby/core/integer/even_spec.rb
index a314cc6b19..c14cf84947 100644
--- a/spec/ruby/core/integer/even_spec.rb
+++ b/spec/ruby/core/integer/even_spec.rb
@@ -1,40 +1,20 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#even?" do
- context "fixnum" do
- it "returns true for a Fixnum when it is an even number" do
- (-2).even?.should be_true
- (-1).even?.should be_false
+ it "returns true for a Fixnum when it is an even number" do
+ (-2).even?.should be_true
+ (-1).even?.should be_false
- 0.even?.should be_true
- 1.even?.should be_false
- 2.even?.should be_true
- end
-
- it "returns true for a Bignum when it is an even number" do
- bignum_value(0).even?.should be_true
- bignum_value(1).even?.should be_false
-
- (-bignum_value(0)).even?.should be_true
- (-bignum_value(1)).even?.should be_false
- end
+ 0.even?.should be_true
+ 1.even?.should be_false
+ 2.even?.should be_true
end
- context "bignum" do
- it "returns true if self is even and positive" do
- (10000**10).even?.should be_true
- end
-
- it "returns true if self is even and negative" do
- (-10000**10).even?.should be_true
- end
-
- it "returns false if self is odd and positive" do
- (9879**976).even?.should be_false
- end
+ it "returns true for a Bignum when it is an even number" do
+ bignum_value(0).even?.should be_true
+ bignum_value(1).even?.should be_false
- it "returns false if self is odd and negative" do
- (-9879**976).even?.should be_false
- end
+ (-bignum_value(0)).even?.should be_true
+ (-bignum_value(1)).even?.should be_false
end
end
diff --git a/spec/ruby/core/integer/exponent_spec.rb b/spec/ruby/core/integer/exponent_spec.rb
deleted file mode 100644
index c610661aff..0000000000
--- a/spec/ruby/core/integer/exponent_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/exponent'
-
-describe "Integer#**" do
- it_behaves_like :integer_exponent, :**
-end
diff --git a/spec/ruby/core/integer/fdiv_spec.rb b/spec/ruby/core/integer/fdiv_spec.rb
deleted file mode 100644
index 6de170278f..0000000000
--- a/spec/ruby/core/integer/fdiv_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#fdiv" do
- it "performs floating-point division between self and a fixnum" do
- 8.fdiv(7).should be_close(1.14285714285714, TOLERANCE)
- end
-
- it "performs floating-point division between self and a bignum" do
- 8.fdiv(bignum_value).should be_close(8.673617379884035e-19, TOLERANCE)
- end
-
- it "performs floating-point division between self and a Float" do
- 8.fdiv(9.0).should be_close(0.888888888888889, TOLERANCE)
- end
-
- it "returns NaN when the argument is NaN" do
- -1.fdiv(nan_value).nan?.should be_true
- 1.fdiv(nan_value).nan?.should be_true
- end
-
- it "returns Infinity when the argument is 0" do
- 1.fdiv(0).infinite?.should == 1
- end
-
- it "returns -Infinity when the argument is 0 and self is negative" do
- -1.fdiv(0).infinite?.should == -1
- end
-
- it "returns Infinity when the argument is 0.0" do
- 1.fdiv(0.0).infinite?.should == 1
- end
-
- it "returns -Infinity when the argument is 0.0 and self is negative" do
- -1.fdiv(0.0).infinite?.should == -1
- end
-
- it "raises a TypeError when argument isn't numeric" do
- -> { 1.fdiv(mock('non-numeric')) }.should raise_error(TypeError)
- end
-
- it "raises an ArgumentError when passed multiple arguments" do
- -> { 1.fdiv(6,0.2) }.should raise_error(ArgumentError)
- end
-
- it "follows the coercion protocol" do
- (obj = mock('10')).should_receive(:coerce).with(1).and_return([1, 10])
- 1.fdiv(obj).should == 0.1
- end
-end
diff --git a/spec/ruby/core/integer/fixtures/classes.rb b/spec/ruby/core/integer/fixtures/classes.rb
deleted file mode 100644
index 6ebfbd1565..0000000000
--- a/spec/ruby/core/integer/fixtures/classes.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module IntegerSpecs
- class CoerceError < StandardError
- end
-end
diff --git a/spec/ruby/core/integer/floor_spec.rb b/spec/ruby/core/integer/floor_spec.rb
index aaa816fdc5..9babcd9a3e 100644
--- a/spec/ruby/core/integer/floor_spec.rb
+++ b/spec/ruby/core/integer/floor_spec.rb
@@ -1,19 +1,21 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
-require_relative 'shared/integer_rounding'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
+require File.expand_path('../shared/integer_rounding', __FILE__)
describe "Integer#floor" do
- it_behaves_like :integer_to_i, :floor
- it_behaves_like :integer_rounding_positive_precision, :floor
+ it_behaves_like(:integer_to_i, :floor)
+ it_behaves_like(:integer_rounding_positive_precision, :floor)
- context "precision argument specified as part of the floor method is negative" do
- it "returns the largest integer less than self with at least precision.abs trailing zeros" do
- 1832.floor(-1).should eql(1830)
- 1832.floor(-2).should eql(1800)
- 1832.floor(-3).should eql(1000)
- -1832.floor(-1).should eql(-1840)
- -1832.floor(-2).should eql(-1900)
- -1832.floor(-3).should eql(-2000)
+ ruby_version_is "2.4" do
+ context "precision argument specified as part of the floor method is negative" do
+ it "returns the largest integer less than self with at least precision.abs trailing zeros" do
+ 1832.floor(-1).should eql(1830)
+ 1832.floor(-2).should eql(1800)
+ 1832.floor(-3).should eql(1000)
+ -1832.floor(-1).should eql(-1840)
+ -1832.floor(-2).should eql(-1900)
+ -1832.floor(-3).should eql(-2000)
+ end
end
end
end
diff --git a/spec/ruby/core/integer/gcd_spec.rb b/spec/ruby/core/integer/gcd_spec.rb
index 8aa654a16a..5428c94ad1 100644
--- a/spec/ruby/core/integer/gcd_spec.rb
+++ b/spec/ruby/core/integer/gcd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#gcd" do
it "returns self if equal to the argument" do
@@ -43,27 +43,16 @@ describe "Integer#gcd" do
bignum.gcd(99).should == 99
end
- it "doesn't cause an integer overflow" do
- [2 ** (1.size * 8 - 2), 0x8000000000000000].each do |max|
- [max - 1, max, max + 1].each do |num|
- num.gcd(num).should == num
- (-num).gcd(num).should == num
- (-num).gcd(-num).should == num
- num.gcd(-num).should == num
- end
- end
- end
-
it "raises an ArgumentError if not given an argument" do
- -> { 12.gcd }.should raise_error(ArgumentError)
+ lambda { 12.gcd }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if given more than one argument" do
- -> { 12.gcd(30, 20) }.should raise_error(ArgumentError)
+ lambda { 12.gcd(30, 20) }.should raise_error(ArgumentError)
end
it "raises a TypeError unless the argument is an Integer" do
- -> { 39.gcd(3.8) }.should raise_error(TypeError)
- -> { 45872.gcd([]) }.should raise_error(TypeError)
+ lambda { 39.gcd(3.8) }.should raise_error(TypeError)
+ lambda { 45872.gcd([]) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/gcdlcm_spec.rb b/spec/ruby/core/integer/gcdlcm_spec.rb
index 5b3669e62a..86968499b0 100644
--- a/spec/ruby/core/integer/gcdlcm_spec.rb
+++ b/spec/ruby/core/integer/gcdlcm_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#gcdlcm" do
it "returns [self, self] if self is equal to the argument" do
@@ -39,15 +39,15 @@ describe "Integer#gcdlcm" do
end
it "raises an ArgumentError if not given an argument" do
- -> { 12.gcdlcm }.should raise_error(ArgumentError)
+ lambda { 12.gcdlcm }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if given more than one argument" do
- -> { 12.gcdlcm(30, 20) }.should raise_error(ArgumentError)
+ lambda { 12.gcdlcm(30, 20) }.should raise_error(ArgumentError)
end
it "raises a TypeError unless the argument is an Integer" do
- -> { 39.gcdlcm(3.8) }.should raise_error(TypeError)
- -> { 45872.gcdlcm([]) }.should raise_error(TypeError)
+ lambda { 39.gcdlcm(3.8) }.should raise_error(TypeError)
+ lambda { 45872.gcdlcm([]) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/gt_spec.rb b/spec/ruby/core/integer/gt_spec.rb
deleted file mode 100644
index 428a6f6888..0000000000
--- a/spec/ruby/core/integer/gt_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_coerce'
-
-describe "Integer#>" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :>
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :>
- end
-
- context "fixnum" do
- it "returns true if self is greater than the given argument" do
- (13 > 2).should == true
- (-500 > -600).should == true
-
- (1 > 5).should == false
- (5 > 5).should == false
-
- (900 > bignum_value).should == false
- (5 > 4.999).should == true
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { 5 > "4" }.should raise_error(ArgumentError)
- -> { 5 > mock('x') }.should raise_error(ArgumentError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(732)
- end
-
- it "returns true if self is greater than the given argument" do
- (@bignum > (@bignum - 1)).should == true
- (@bignum > 14.6).should == true
- (@bignum > 10).should == true
-
- (@bignum > (@bignum + 500)).should == false
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { @bignum > "4" }.should raise_error(ArgumentError)
- -> { @bignum > mock('str') }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/gte_spec.rb b/spec/ruby/core/integer/gte_spec.rb
deleted file mode 100644
index ce1385c360..0000000000
--- a/spec/ruby/core/integer/gte_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_coerce'
-
-describe "Integer#>=" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :>=
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :>=
- end
-
- context "fixnum" do
- it "returns true if self is greater than or equal to the given argument" do
- (13 >= 2).should == true
- (-500 >= -600).should == true
-
- (1 >= 5).should == false
- (2 >= 2).should == true
- (5 >= 5).should == true
-
- (900 >= bignum_value).should == false
- (5 >= 4.999).should == true
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { 5 >= "4" }.should raise_error(ArgumentError)
- -> { 5 >= mock('x') }.should raise_error(ArgumentError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(14)
- end
-
- it "returns true if self is greater than or equal to other" do
- (@bignum >= @bignum).should == true
- (@bignum >= (@bignum + 2)).should == false
- (@bignum >= 5664.2).should == true
- (@bignum >= 4).should == true
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { @bignum >= "4" }.should raise_error(ArgumentError)
- -> { @bignum >= mock('str') }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/integer_spec.rb b/spec/ruby/core/integer/integer_spec.rb
index f8067cda06..393f072563 100644
--- a/spec/ruby/core/integer/integer_spec.rb
+++ b/spec/ruby/core/integer/integer_spec.rb
@@ -1,13 +1,15 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer" do
it "includes Comparable" do
Integer.include?(Comparable).should == true
end
- it "is the class of both small and large integers" do
- 42.class.should equal(Integer)
- bignum_value.class.should equal(Integer)
+ ruby_version_is "2.4" do
+ it "is the class of both small and large integers" do
+ 42.class.should equal(Integer)
+ bignum_value.class.should equal(Integer)
+ end
end
end
diff --git a/spec/ruby/core/integer/lcm_spec.rb b/spec/ruby/core/integer/lcm_spec.rb
index 77d3ad3488..ddf25d3853 100644
--- a/spec/ruby/core/integer/lcm_spec.rb
+++ b/spec/ruby/core/integer/lcm_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#lcm" do
it "returns self if equal to the argument" do
@@ -44,15 +44,15 @@ describe "Integer#lcm" do
end
it "raises an ArgumentError if not given an argument" do
- -> { 12.lcm }.should raise_error(ArgumentError)
+ lambda { 12.lcm }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if given more than one argument" do
- -> { 12.lcm(30, 20) }.should raise_error(ArgumentError)
+ lambda { 12.lcm(30, 20) }.should raise_error(ArgumentError)
end
it "raises a TypeError unless the argument is an Integer" do
- -> { 39.lcm(3.8) }.should raise_error(TypeError)
- -> { 45872.lcm([]) }.should raise_error(TypeError)
+ lambda { 39.lcm(3.8) }.should raise_error(TypeError)
+ lambda { 45872.lcm([]) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/left_shift_spec.rb b/spec/ruby/core/integer/left_shift_spec.rb
deleted file mode 100644
index 4b5ef9386e..0000000000
--- a/spec/ruby/core/integer/left_shift_spec.rb
+++ /dev/null
@@ -1,165 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#<< (with n << m)" do
- context "fixnum" do
- it "returns n shifted left m bits when n > 0, m > 0" do
- (1 << 1).should == 2
- end
-
- it "returns n shifted left m bits when n < 0, m > 0" do
- (-1 << 1).should == -2
- (-7 << 1).should == -14
- (-42 << 2).should == -168
- end
-
- it "returns n shifted right m bits when n > 0, m < 0" do
- (2 << -1).should == 1
- end
-
- it "returns n shifted right m bits when n < 0, m < 0" do
- (-2 << -1).should == -1
- end
-
- it "returns 0 when n == 0" do
- (0 << 1).should == 0
- end
-
- it "returns n when n > 0, m == 0" do
- (1 << 0).should == 1
- end
-
- it "returns n when n < 0, m == 0" do
- (-1 << 0).should == -1
- end
-
- it "returns 0 when n > 0, m < 0 and n < 2**-m" do
- (3 << -2).should == 0
- (7 << -3).should == 0
- (127 << -7).should == 0
-
- # To make sure the exponent is not truncated
- (7 << -32).should == 0
- (7 << -64).should == 0
- end
-
- it "returns -1 when n < 0, m < 0 and n > -(2**-m)" do
- (-3 << -2).should == -1
- (-7 << -3).should == -1
- (-127 << -7).should == -1
-
- # To make sure the exponent is not truncated
- (-7 << -32).should == -1
- (-7 << -64).should == -1
- end
-
- it "returns 0 when m < 0 and m is a Bignum" do
- (3 << -bignum_value).should == 0
- end
-
- it "returns an Bignum == fixnum_max * 2 when fixnum_max << 1 and n > 0" do
- result = fixnum_max << 1
- result.should be_an_instance_of(Bignum)
- result.should == fixnum_max * 2
- end
-
- it "returns an Bignum == fixnum_min * 2 when fixnum_min << 1 and n < 0" do
- result = fixnum_min << 1
- result.should be_an_instance_of(Bignum)
- result.should == fixnum_min * 2
- end
-
- it "calls #to_int to convert the argument to an Integer" do
- obj = mock("4")
- obj.should_receive(:to_int).and_return(4)
-
- (3 << obj).should == 48
- end
-
- it "raises a TypeError when #to_int does not return an Integer" do
- obj = mock("a string")
- obj.should_receive(:to_int).and_return("asdf")
-
- -> { 3 << obj }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed nil" do
- -> { 3 << nil }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed a String" do
- -> { 3 << "4" }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value * 16
- end
-
- it "returns n shifted left m bits when n > 0, m > 0" do
- (@bignum << 4).should == 2361183241434822606848
- end
-
- it "returns n shifted left m bits when n < 0, m > 0" do
- (-@bignum << 9).should == -75557863725914323419136
- end
-
- it "returns n shifted right m bits when n > 0, m < 0" do
- (@bignum << -1).should == 73786976294838206464
- end
-
- it "returns n shifted right m bits when n < 0, m < 0" do
- (-@bignum << -2).should == -36893488147419103232
- end
-
- it "returns n when n > 0, m == 0" do
- (@bignum << 0).should == @bignum
- end
-
- it "returns n when n < 0, m == 0" do
- (-@bignum << 0).should == -@bignum
- end
-
- it "returns 0 when m < 0 and m == p where 2**p > n >= 2**(p-1)" do
- (@bignum << -68).should == 0
- end
-
- it "returns 0 when m < 0 and m is a Bignum" do
- (@bignum << -bignum_value).should == 0
- end
-
- it "returns a Fixnum == fixnum_max when (fixnum_max * 2) << -1 and n > 0" do
- result = (fixnum_max * 2) << -1
- result.should be_an_instance_of(Fixnum)
- result.should == fixnum_max
- end
-
- it "returns a Fixnum == fixnum_min when (fixnum_min * 2) << -1 and n < 0" do
- result = (fixnum_min * 2) << -1
- result.should be_an_instance_of(Fixnum)
- result.should == fixnum_min
- end
-
- it "calls #to_int to convert the argument to an Integer" do
- obj = mock("4")
- obj.should_receive(:to_int).and_return(4)
-
- (@bignum << obj).should == 2361183241434822606848
- end
-
- it "raises a TypeError when #to_int does not return an Integer" do
- obj = mock("a string")
- obj.should_receive(:to_int).and_return("asdf")
-
- -> { @bignum << obj }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed nil" do
- -> { @bignum << nil }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed a String" do
- -> { @bignum << "4" }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/lt_spec.rb b/spec/ruby/core/integer/lt_spec.rb
deleted file mode 100644
index dfe2d9e369..0000000000
--- a/spec/ruby/core/integer/lt_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_coerce'
-
-describe "Integer#<" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :<
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :<
- end
-
- context "fixnum" do
- it "returns true if self is less than the given argument" do
- (2 < 13).should == true
- (-600 < -500).should == true
-
- (5 < 1).should == false
- (5 < 5).should == false
-
- (900 < bignum_value).should == true
- (5 < 4.999).should == false
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { 5 < "4" }.should raise_error(ArgumentError)
- -> { 5 < mock('x') }.should raise_error(ArgumentError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(32)
- end
-
- it "returns true if self is less than the given argument" do
- (@bignum < @bignum + 1).should == true
- (-@bignum < -(@bignum - 1)).should == true
-
- (@bignum < 1).should == false
- (@bignum < 5).should == false
-
- (@bignum < 4.999).should == false
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { @bignum < "4" }.should raise_error(ArgumentError)
- -> { @bignum < mock('str') }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/lte_spec.rb b/spec/ruby/core/integer/lte_spec.rb
deleted file mode 100644
index 3d843a5dd9..0000000000
--- a/spec/ruby/core/integer/lte_spec.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/comparison_coerce'
-
-describe "Integer#<=" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_comparison_coerce_rescue, :<=
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_comparison_coerce_not_rescue, :<=
- end
-
- context "fixnum" do
- it "returns true if self is less than or equal to other" do
- (2 <= 13).should == true
- (-600 <= -500).should == true
-
- (5 <= 1).should == false
- (5 <= 5).should == true
- (-2 <= -2).should == true
-
- (900 <= bignum_value).should == true
- (5 <= 4.999).should == false
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { 5 <= "4" }.should raise_error(ArgumentError)
- -> { 5 <= mock('x') }.should raise_error(ArgumentError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(39)
- end
-
- it "returns true if self is less than or equal to other" do
- (@bignum <= @bignum).should == true
- (-@bignum <= -(@bignum - 1)).should == true
-
- (@bignum <= 4.999).should == false
- end
-
- it "returns false if compares with near float" do
- (@bignum <= (@bignum + 0.0)).should == false
- (@bignum <= (@bignum + 0.5)).should == false
- end
-
- it "raises an ArgumentError when given a non-Integer" do
- -> { @bignum <= "4" }.should raise_error(ArgumentError)
- -> { @bignum <= mock('str') }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/magnitude_spec.rb b/spec/ruby/core/integer/magnitude_spec.rb
deleted file mode 100644
index 48cf1a8534..0000000000
--- a/spec/ruby/core/integer/magnitude_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/abs'
-
-describe "Integer#magnitude" do
- it_behaves_like :integer_abs, :magnitude
-end
diff --git a/spec/ruby/core/integer/minus_spec.rb b/spec/ruby/core/integer/minus_spec.rb
deleted file mode 100644
index 34dd36c1a7..0000000000
--- a/spec/ruby/core/integer/minus_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arithmetic_coerce'
-
-describe "Integer#-" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :-
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :-
- end
-
- context "fixnum" do
- it "returns self minus the given Integer" do
- (5 - 10).should == -5
- (9237212 - 5_280).should == 9231932
-
- (781 - 0.5).should == 780.5
- (2_560_496 - bignum_value).should == -9223372036852215312
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
- 13 - obj
- }.should raise_error(TypeError)
- -> { 13 - "10" }.should raise_error(TypeError)
- -> { 13 - :symbol }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(314)
- end
-
- it "returns self minus the given Integer" do
- (@bignum - 9).should == 9223372036854776113
- (@bignum - 12.57).should be_close(9223372036854776109.43, TOLERANCE)
- (@bignum - bignum_value(42)).should == 272
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> { @bignum - mock('10') }.should raise_error(TypeError)
- -> { @bignum - "10" }.should raise_error(TypeError)
- -> { @bignum - :symbol }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/modulo_spec.rb b/spec/ruby/core/integer/modulo_spec.rb
deleted file mode 100644
index e263338e38..0000000000
--- a/spec/ruby/core/integer/modulo_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/modulo'
-
-describe "Integer#%" do
- it_behaves_like :integer_modulo, :%
-end
-
-describe "Integer#modulo" do
- it_behaves_like :integer_modulo, :modulo
-end
diff --git a/spec/ruby/core/integer/multiply_spec.rb b/spec/ruby/core/integer/multiply_spec.rb
deleted file mode 100644
index 919786cbcc..0000000000
--- a/spec/ruby/core/integer/multiply_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arithmetic_coerce'
-
-describe "Integer#*" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :*
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :*
- end
-
- context "fixnum" do
- it "returns self multiplied by the given Integer" do
- (4923 * 2).should == 9846
- (1342177 * 800).should == 1073741600
- (65536 * 65536).should == 4294967296
-
- (256 * bignum_value).should == 2361183241434822606848
- (6712 * 0.25).should == 1678.0
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
- 13 * obj
- }.should raise_error(TypeError)
- -> { 13 * "10" }.should raise_error(TypeError)
- -> { 13 * :symbol }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(772)
- end
-
- it "returns self multiplied by the given Integer" do
- (@bignum * (1/bignum_value(0xffff).to_f)).should be_close(1.0, TOLERANCE)
- (@bignum * (1/bignum_value(0xffff).to_f)).should be_close(1.0, TOLERANCE)
- (@bignum * 10).should == 92233720368547765800
- (@bignum * (@bignum - 40)).should == 85070591730234629737795195287525433200
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> { @bignum * mock('10') }.should raise_error(TypeError)
- -> { @bignum * "10" }.should raise_error(TypeError)
- -> { @bignum * :symbol }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/next_spec.rb b/spec/ruby/core/integer/next_spec.rb
index 63c4e67893..a34db0a6f6 100644
--- a/spec/ruby/core/integer/next_spec.rb
+++ b/spec/ruby/core/integer/next_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/next'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/next', __FILE__)
describe "Integer#next" do
- it_behaves_like :integer_next, :next
+ it_behaves_like(:integer_next, :next)
end
diff --git a/spec/ruby/core/integer/nobits_spec.rb b/spec/ruby/core/integer/nobits_spec.rb
index af3b9e7db0..5b5d82a040 100644
--- a/spec/ruby/core/integer/nobits_spec.rb
+++ b/spec/ruby/core/integer/nobits_spec.rb
@@ -1,38 +1,36 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-ruby_version_is '2.5' do
- describe "Integer#nobits?" do
- it "returns true iff all no bits of the argument are set in the receiver" do
- 42.nobits?(42).should == false
- 0b1010_1010.nobits?(0b1000_0010).should == false
- 0b1010_1010.nobits?(0b1000_0001).should == false
- 0b0100_0101.nobits?(0b1010_1010).should == true
- different_bignum = (2 * bignum_value) & (~bignum_value)
- (0b1010_1010 | different_bignum).nobits?(0b1000_0010 | bignum_value).should == false
- (0b1010_1010 | different_bignum).nobits?(0b1000_0001 | bignum_value).should == false
- (0b0100_0101 | different_bignum).nobits?(0b1010_1010 | bignum_value).should == true
- end
+describe "Integer#nobits?" do
+ it "returns true iff all no bits of the argument are set in the receiver" do
+ 42.nobits?(42).should == false
+ 0b1010_1010.nobits?(0b1000_0010).should == false
+ 0b1010_1010.nobits?(0b1000_0001).should == false
+ 0b0100_0101.nobits?(0b1010_1010).should == true
+ different_bignum = (2 * bignum_value) & (~bignum_value)
+ (0b1010_1010 | different_bignum).nobits?(0b1000_0010 | bignum_value).should == false
+ (0b1010_1010 | different_bignum).nobits?(0b1000_0001 | bignum_value).should == false
+ (0b0100_0101 | different_bignum).nobits?(0b1010_1010 | bignum_value).should == true
+ end
- it "handles negative values using two's complement notation" do
- (~0b1101).nobits?(0b1101).should == true
- (-42).nobits?(-42).should == false
- (~0b1101).nobits?(~0b10).should == false
- (~(0b1101 | bignum_value)).nobits?(~(0b10 | bignum_value)).should == false
- end
+ it "handles negative values using two's complement notation" do
+ (~0b1101).nobits?(0b1101).should == true
+ (-42).nobits?(-42).should == false
+ (~0b1101).nobits?(~0b10).should == false
+ (~(0b1101 | bignum_value)).nobits?(~(0b10 | bignum_value)).should == false
+ end
- it "coerces the rhs using to_int" do
- obj = mock("the int 0b10")
- obj.should_receive(:to_int).and_return(0b10)
- 0b110.nobits?(obj).should == false
- end
+ it "coerces the rhs using to_int" do
+ obj = mock("the int 0b10")
+ obj.should_receive(:to_int).and_return(0b10)
+ 0b110.nobits?(obj).should == false
+ end
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
- 13.nobits?(obj)
- }.should raise_error(TypeError)
- -> { 13.nobits?("10") }.should raise_error(TypeError)
- -> { 13.nobits?(:symbol) }.should raise_error(TypeError)
- end
+ it "raises a TypeError when given a non-Integer" do
+ lambda {
+ (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10])
+ 13.nobits?(obj)
+ }.should raise_error(TypeError)
+ lambda { 13.nobits?("10") }.should raise_error(TypeError)
+ lambda { 13.nobits?(:symbol) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/integer/numerator_spec.rb b/spec/ruby/core/integer/numerator_spec.rb
index f4149d770e..12550b9a31 100644
--- a/spec/ruby/core/integer/numerator_spec.rb
+++ b/spec/ruby/core/integer/numerator_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#numerator" do
before :all do
diff --git a/spec/ruby/core/integer/odd_spec.rb b/spec/ruby/core/integer/odd_spec.rb
index dd779fa44b..2aa76d054a 100644
--- a/spec/ruby/core/integer/odd_spec.rb
+++ b/spec/ruby/core/integer/odd_spec.rb
@@ -1,38 +1,18 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#odd?" do
- context "fixnum" do
- it "returns true when self is an odd number" do
- (-2).odd?.should be_false
- (-1).odd?.should be_true
+ it "returns true when self is an odd number" do
+ (-2).odd?.should be_false
+ (-1).odd?.should be_true
- 0.odd?.should be_false
- 1.odd?.should be_true
- 2.odd?.should be_false
+ 0.odd?.should be_false
+ 1.odd?.should be_true
+ 2.odd?.should be_false
- bignum_value(0).odd?.should be_false
- bignum_value(1).odd?.should be_true
+ bignum_value(0).odd?.should be_false
+ bignum_value(1).odd?.should be_true
- (-bignum_value(0)).odd?.should be_false
- (-bignum_value(1)).odd?.should be_true
- end
- end
-
- context "bignum" do
- it "returns true if self is odd and positive" do
- (987279**19).odd?.should be_true
- end
-
- it "returns true if self is odd and negative" do
- (-9873389**97).odd?.should be_true
- end
-
- it "returns false if self is even and positive" do
- (10000000**10).odd?.should be_false
- end
-
- it "returns false if self is even and negative" do
- (-1000000**100).odd?.should be_false
- end
+ (-bignum_value(0)).odd?.should be_false
+ (-bignum_value(1)).odd?.should be_true
end
end
diff --git a/spec/ruby/core/integer/ord_spec.rb b/spec/ruby/core/integer/ord_spec.rb
index bcb57bea98..5941f513fd 100644
--- a/spec/ruby/core/integer/ord_spec.rb
+++ b/spec/ruby/core/integer/ord_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#ord" do
it "returns self" do
diff --git a/spec/ruby/core/integer/plus_spec.rb b/spec/ruby/core/integer/plus_spec.rb
deleted file mode 100644
index 7e919a16db..0000000000
--- a/spec/ruby/core/integer/plus_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arithmetic_coerce'
-
-describe "Integer#+" do
- ruby_version_is "2.4"..."2.5" do
- it_behaves_like :integer_arithmetic_coerce_rescue, :+
- end
-
- ruby_version_is "2.5" do
- it_behaves_like :integer_arithmetic_coerce_not_rescue, :+
- end
-
- context "fixnum" do
- it "returns self plus the given Integer" do
- (491 + 2).should == 493
- (90210 + 10).should == 90220
-
- (9 + bignum_value).should == 9223372036854775817
- (1001 + 5.219).should == 1006.219
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
- 13 + obj
- }.should raise_error(TypeError)
- -> { 13 + "10" }.should raise_error(TypeError)
- -> { 13 + :symbol }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(76)
- end
-
- it "returns self plus the given Integer" do
- (@bignum + 4).should == 9223372036854775888
- (@bignum + 4.2).should be_close(9223372036854775888.2, TOLERANCE)
- (@bignum + bignum_value(3)).should == 18446744073709551695
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> { @bignum + mock('10') }.should raise_error(TypeError)
- -> { @bignum + "10" }.should raise_error(TypeError)
- -> { @bignum + :symbol}.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/pow_spec.rb b/spec/ruby/core/integer/pow_spec.rb
deleted file mode 100644
index ed14c40a27..0000000000
--- a/spec/ruby/core/integer/pow_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/exponent'
-
-ruby_version_is "2.5" do
- describe "Integer#pow" do
- context "one argument is passed" do
- it_behaves_like :integer_exponent, :pow
- end
-
- context "two arguments are passed" do
- it "returns modulo of self raised to the given power" do
- 2.pow(5, 12).should == 8
- 2.pow(6, 13).should == 12
- 2.pow(7, 14).should == 2
- 2.pow(8, 15).should == 1
- end
-
- it "works well with bignums" do
- 2.pow(61, 5843009213693951).should eql 3697379018277258
- 2.pow(62, 5843009213693952).should eql 1551748822859776
- 2.pow(63, 5843009213693953).should eql 3103497645717974
- 2.pow(64, 5843009213693954).should eql 363986077738838
- end
-
- it "handles sign like #divmod does" do
- 2.pow(5, 12).should == 8
- 2.pow(5, -12).should == -4
- -2.pow(5, 12).should == 4
- -2.pow(5, -12).should == -8
- end
-
- it "ensures all arguments are integers" do
- -> { 2.pow(5, 12.0) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/)
- -> { 2.pow(5, Rational(12, 1)) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/)
- end
-
- it "raises TypeError for non-numeric value" do
- -> { 2.pow(5, "12") }.should raise_error(TypeError)
- -> { 2.pow(5, []) }.should raise_error(TypeError)
- -> { 2.pow(5, nil) }.should raise_error(TypeError)
- end
-
- it "raises a ZeroDivisionError when the given argument is 0" do
- -> { 2.pow(5, 0) }.should raise_error(ZeroDivisionError)
- end
- end
- end
-end
diff --git a/spec/ruby/core/integer/pred_spec.rb b/spec/ruby/core/integer/pred_spec.rb
index 86750ebfd1..8b16a7ae03 100644
--- a/spec/ruby/core/integer/pred_spec.rb
+++ b/spec/ruby/core/integer/pred_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#pred" do
it "returns the Integer equal to self - 1" do
diff --git a/spec/ruby/core/integer/rationalize_spec.rb b/spec/ruby/core/integer/rationalize_spec.rb
index 09d741af33..1ff4cfa454 100644
--- a/spec/ruby/core/integer/rationalize_spec.rb
+++ b/spec/ruby/core/integer/rationalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#rationalize" do
before :all do
@@ -33,7 +33,7 @@ describe "Integer#rationalize" do
end
it "raises ArgumentError when passed more than one argument" do
- -> { 1.rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
- -> { 1.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
+ lambda { 1.rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
+ lambda { 1.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/integer/remainder_spec.rb b/spec/ruby/core/integer/remainder_spec.rb
deleted file mode 100644
index cd10dad6f2..0000000000
--- a/spec/ruby/core/integer/remainder_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#remainder" do
- context "fixnum" do
- it "returns the remainder of dividing self by other" do
- 5.remainder(3).should == 2
- 5.remainder(3.0).should == 2.0
- 5.remainder(Rational(3, 1)).should == Rational(2, 1)
- end
-
- it "means x-y*(x/y).truncate" do
- 5.remainder(3).should == 2
- 5.remainder(3.3).should be_close(1.7, TOLERANCE)
- 5.remainder(3.7).should be_close(1.3, TOLERANCE)
- end
-
- it "keeps sign of self" do
- 5.remainder( 3).should == 2
- 5.remainder(-3).should == 2
- -5.remainder( 3).should == -2
- -5.remainder(-3).should == -2
- end
-
- it "raises TypeError if passed non-numeric argument" do
- -> { 5.remainder("3") }.should raise_error(TypeError)
- -> { 5.remainder(:"3") }.should raise_error(TypeError)
- -> { 5.remainder([]) }.should raise_error(TypeError)
- -> { 5.remainder(nil) }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- it "returns the remainder of dividing self by other" do
- a = bignum_value(79)
- a.remainder(2).should == 1
- a.remainder(97.345).should be_close(46.5674996147722, TOLERANCE)
- a.remainder(bignum_value).should == 79
- end
-
- it "raises a ZeroDivisionError if other is zero and not a Float" do
- -> { bignum_value(66).remainder(0) }.should raise_error(ZeroDivisionError)
- end
-
- it "does raises ZeroDivisionError if other is zero and a Float" do
- a = bignum_value(7)
- b = bignum_value(32)
- -> { a.remainder(0.0) }.should raise_error(ZeroDivisionError)
- -> { b.remainder(-0.0) }.should raise_error(ZeroDivisionError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/right_shift_spec.rb b/spec/ruby/core/integer/right_shift_spec.rb
deleted file mode 100644
index 3eeaf3eb2f..0000000000
--- a/spec/ruby/core/integer/right_shift_spec.rb
+++ /dev/null
@@ -1,191 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#>> (with n >> m)" do
- context "fixnum" do
- it "returns n shifted right m bits when n > 0, m > 0" do
- (2 >> 1).should == 1
- end
-
- it "returns n shifted right m bits when n < 0, m > 0" do
- (-2 >> 1).should == -1
- (-7 >> 1).should == -4
- (-42 >> 2).should == -11
- end
-
- it "returns n shifted left m bits when n > 0, m < 0" do
- (1 >> -1).should == 2
- end
-
- it "returns n shifted left m bits when n < 0, m < 0" do
- (-1 >> -1).should == -2
- end
-
- it "returns 0 when n == 0" do
- (0 >> 1).should == 0
- end
-
- it "returns n when n > 0, m == 0" do
- (1 >> 0).should == 1
- end
-
- it "returns n when n < 0, m == 0" do
- (-1 >> 0).should == -1
- end
-
- it "returns 0 when n > 0, m > 0 and n < 2**m" do
- (3 >> 2).should == 0
- (7 >> 3).should == 0
- (127 >> 7).should == 0
-
- # To make sure the exponent is not truncated
- (7 >> 32).should == 0
- (7 >> 64).should == 0
- end
-
- it "returns -1 when n < 0, m > 0 and n > -(2**m)" do
- (-3 >> 2).should == -1
- (-7 >> 3).should == -1
- (-127 >> 7).should == -1
-
- # To make sure the exponent is not truncated
- (-7 >> 32).should == -1
- (-7 >> 64).should == -1
- end
-
- it "returns 0 when m is a bignum" do
- (3 >> bignum_value).should == 0
- end
-
- it "returns an Bignum == fixnum_max * 2 when fixnum_max >> -1 and n > 0" do
- result = fixnum_max >> -1
- result.should be_an_instance_of(Bignum)
- result.should == fixnum_max * 2
- end
-
- it "returns an Bignum == fixnum_min * 2 when fixnum_min >> -1 and n < 0" do
- result = fixnum_min >> -1
- result.should be_an_instance_of(Bignum)
- result.should == fixnum_min * 2
- end
-
- it "calls #to_int to convert the argument to an Integer" do
- obj = mock("2")
- obj.should_receive(:to_int).and_return(2)
-
- (8 >> obj).should == 2
- end
-
- it "raises a TypeError when #to_int does not return an Integer" do
- obj = mock("a string")
- obj.should_receive(:to_int).and_return("asdf")
-
- -> { 3 >> obj }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed nil" do
- -> { 3 >> nil }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed a String" do
- -> { 3 >> "4" }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value * 16
- end
-
- it "returns n shifted right m bits when n > 0, m > 0" do
- (@bignum >> 1).should == 73786976294838206464
- end
-
- it "returns n shifted right m bits when n < 0, m > 0" do
- (-@bignum >> 2).should == -36893488147419103232
- end
-
- it "respects twos complement signed shifting" do
- # This explicit left hand value is important because it is the
- # exact bit pattern that matters, so it's important it's right
- # here to show the significance.
- #
-
- (-42949672980000000000000 >> 14).should == -2621440001220703125
- (-42949672980000000000001 >> 14).should == -2621440001220703126
- # Note the off by one -------------------- ^^^^^^^^^^^^^^^^^^^^
- # This is because even though we discard the lowest bit, in twos
- # complement it would influence the bits to the left of it.
-
- (-42949672980000000000000 >> 15).should == -1310720000610351563
- (-42949672980000000000001 >> 15).should == -1310720000610351563
-
- (-0xfffffffffffffffff >> 32).should == -68719476736
- end
-
- it "respects twos complement signed shifting for very large values" do
- giant = 42949672980000000000000000000000000000000000000000000000000000000000000000000000000000000000
- neg = -giant
-
- (giant >> 84).should == 2220446050284288846538547929770901490087453566957265138626098632812
- (neg >> 84).should == -2220446050284288846538547929770901490087453566957265138626098632813
- end
-
- it "returns n shifted left m bits when n > 0, m < 0" do
- (@bignum >> -2).should == 590295810358705651712
- end
-
- it "returns n shifted left m bits when n < 0, m < 0" do
- (-@bignum >> -3).should == -1180591620717411303424
- end
-
- it "returns n when n > 0, m == 0" do
- (@bignum >> 0).should == @bignum
- end
-
- it "returns n when n < 0, m == 0" do
- (-@bignum >> 0).should == -@bignum
- end
-
- it "returns 0 when m > 0 and m == p where 2**p > n >= 2**(p-1)" do
- (@bignum >> 68).should == 0
- end
-
- it "returns 0 when m is a Bignum" do
- (@bignum >> bignum_value).should == 0
- end
-
- it "returns a Fixnum == fixnum_max when (fixnum_max * 2) >> 1 and n > 0" do
- result = (fixnum_max * 2) >> 1
- result.should be_an_instance_of(Fixnum)
- result.should == fixnum_max
- end
-
- it "returns a Fixnum == fixnum_min when (fixnum_min * 2) >> 1 and n < 0" do
- result = (fixnum_min * 2) >> 1
- result.should be_an_instance_of(Fixnum)
- result.should == fixnum_min
- end
-
- it "calls #to_int to convert the argument to an Integer" do
- obj = mock("2")
- obj.should_receive(:to_int).and_return(2)
-
- (@bignum >> obj).should == 36893488147419103232
- end
-
- it "raises a TypeError when #to_int does not return an Integer" do
- obj = mock("a string")
- obj.should_receive(:to_int).and_return("asdf")
-
- -> { @bignum >> obj }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed nil" do
- -> { @bignum >> nil }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed a String" do
- -> { @bignum >> "4" }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/round_spec.rb b/spec/ruby/core/integer/round_spec.rb
index feb6d475d3..5a46e6cba6 100644
--- a/spec/ruby/core/integer/round_spec.rb
+++ b/spec/ruby/core/integer/round_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
-require_relative 'shared/integer_rounding'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
+require File.expand_path('../shared/integer_rounding', __FILE__)
describe "Integer#round" do
- it_behaves_like :integer_to_i, :round
- it_behaves_like :integer_rounding_positive_precision, :round
+ it_behaves_like(:integer_to_i, :round)
+ it_behaves_like(:integer_rounding_positive_precision, :round)
ruby_version_is ""..."2.5" do # Not just since 2.4
it "rounds itself as a float if passed a positive precision" do
@@ -31,24 +31,24 @@ describe "Integer#round" do
platform_is_not wordsize: 32 do
it "raises a RangeError when passed a big negative value" do
- -> { 42.round(fixnum_min) }.should raise_error(RangeError)
+ lambda { 42.round(fixnum_min) }.should raise_error(RangeError)
end
end
it "raises a RangeError when passed Float::INFINITY" do
- -> { 42.round(Float::INFINITY) }.should raise_error(RangeError)
+ lambda { 42.round(Float::INFINITY) }.should raise_error(RangeError)
end
it "raises a RangeError when passed a beyond signed int" do
- -> { 42.round(1<<31) }.should raise_error(RangeError)
+ lambda { 42.round(1<<31) }.should raise_error(RangeError)
end
it "raises a TypeError when passed a String" do
- -> { 42.round("4") }.should raise_error(TypeError)
+ lambda { 42.round("4") }.should raise_error(TypeError)
end
it "raises a TypeError when its argument cannot be converted to an Integer" do
- -> { 42.round(nil) }.should raise_error(TypeError)
+ lambda { 42.round(nil) }.should raise_error(TypeError)
end
it "calls #to_int on the argument to convert it to an Integer" do
@@ -60,22 +60,21 @@ describe "Integer#round" do
it "raises a TypeError when #to_int does not return an Integer" do
obj = mock("Object")
obj.stub!(:to_int).and_return([])
- -> { 42.round(obj) }.should raise_error(TypeError)
+ lambda { 42.round(obj) }.should raise_error(TypeError)
end
- it "returns different rounded values depending on the half option" do
- 25.round(-1, half: :up).should eql(30)
- 25.round(-1, half: :down).should eql(20)
- 25.round(-1, half: :even).should eql(20)
- 25.round(-1, half: nil).should eql(30)
- 35.round(-1, half: :up).should eql(40)
- 35.round(-1, half: :down).should eql(30)
- 35.round(-1, half: :even).should eql(40)
- 35.round(-1, half: nil).should eql(40)
- (-25).round(-1, half: :up).should eql(-30)
- (-25).round(-1, half: :down).should eql(-20)
- (-25).round(-1, half: :even).should eql(-20)
- (-25).round(-1, half: nil).should eql(-30)
+ ruby_version_is "2.4" do
+ it "returns different rounded values depending on the half option" do
+ 25.round(-1, half: :up).should eql(30)
+ 25.round(-1, half: :down).should eql(20)
+ 25.round(-1, half: :even).should eql(20)
+ 35.round(-1, half: :up).should eql(40)
+ 35.round(-1, half: :down).should eql(30)
+ 35.round(-1, half: :even).should eql(40)
+ (-25).round(-1, half: :up).should eql(-30)
+ (-25).round(-1, half: :down).should eql(-20)
+ (-25).round(-1, half: :even).should eql(-20)
+ end
end
ruby_version_is "2.4"..."2.5" do
@@ -93,9 +92,4 @@ describe "Integer#round" do
35.round(1, half: :even).should eql(35)
end
end
-
- it "raises ArgumentError for an unknown rounding mode" do
- -> { 42.round(-1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/)
- -> { 42.round(1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/)
- end
end
diff --git a/spec/ruby/core/integer/shared/abs.rb b/spec/ruby/core/integer/shared/abs.rb
deleted file mode 100644
index 946aa21864..0000000000
--- a/spec/ruby/core/integer/shared/abs.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-describe :integer_abs, shared: true do
- context "fixnum" do
- it "returns self's absolute fixnum value" do
- { 0 => [0, -0, +0], 2 => [2, -2, +2], 100 => [100, -100, +100] }.each do |key, values|
- values.each do |value|
- value.send(@method).should == key
- end
- end
- end
- end
-
- context "bignum" do
- it "returns the absolute bignum value" do
- bignum_value(39).send(@method).should == 9223372036854775847
- (-bignum_value(18)).send(@method).should == 9223372036854775826
- end
- end
-end
diff --git a/spec/ruby/core/integer/shared/arithmetic_coerce.rb b/spec/ruby/core/integer/shared/arithmetic_coerce.rb
deleted file mode 100644
index 4c0cbcb999..0000000000
--- a/spec/ruby/core/integer/shared/arithmetic_coerce.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :integer_arithmetic_coerce_rescue, shared: true do
- it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError)
-
- # e.g. 1 + b
- -> { 1.send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Integer/)
- end
-
- it "does not rescue Exception and StandardError siblings raised in other#coerce" do
- [Exception, NoMemoryError].each do |exception|
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(exception)
-
- # e.g. 1 + b
- -> { 1.send(@method, b) }.should raise_error(exception)
- end
- end
-end
-
-describe :integer_arithmetic_coerce_not_rescue, shared: true do
- it "does not rescue exception raised in other#coerce" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError)
-
- # e.g. 1 + b
- -> { 1.send(@method, b) }.should raise_error(IntegerSpecs::CoerceError)
- end
-end
diff --git a/spec/ruby/core/integer/shared/comparison_coerce.rb b/spec/ruby/core/integer/shared/comparison_coerce.rb
deleted file mode 100644
index 50437f77f5..0000000000
--- a/spec/ruby/core/integer/shared/comparison_coerce.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :integer_comparison_coerce_rescue, shared: true do
- it "rescues exception (StandardError and subclasses) raised in other#coerce and raises ArgumentError" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError)
-
- # e.g. 1 > b
- -> {
- -> { 1.send(@method, b) }.should raise_error(ArgumentError, /comparison of Integer with MockObject failed/)
- }.should complain(/Numerical comparison operators will no more rescue exceptions of #coerce/)
- end
-
- it "does not rescue Exception and StandardError siblings raised in other#coerce" do
- [Exception, NoMemoryError].each do |exception|
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(exception)
-
- # e.g. 1 > b
- -> { 1.send(@method, b) }.should raise_error(exception)
- end
- end
-end
-
-describe :integer_comparison_coerce_not_rescue, shared: true do
- it "does not rescue exception raised in other#coerce" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError)
-
- # e.g. 1 > b
- -> { 1.send(@method, b) }.should raise_error(IntegerSpecs::CoerceError)
- end
-end
diff --git a/spec/ruby/core/integer/shared/equal.rb b/spec/ruby/core/integer/shared/equal.rb
deleted file mode 100644
index 03416b60f5..0000000000
--- a/spec/ruby/core/integer/shared/equal.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-describe :integer_equal, shared: true do
- context "fixnum" do
- it "returns true if self has the same value as other" do
- 1.send(@method, 1).should == true
- 9.send(@method, 5).should == false
-
- # Actually, these call Float#==, Bignum#== etc.
- 9.send(@method, 9.0).should == true
- 9.send(@method, 9.01).should == false
-
- 10.send(@method, bignum_value).should == false
- end
-
- it "calls 'other == self' if the given argument is not a Integer" do
- 1.send(@method, '*').should == false
-
- obj = mock('one other')
- obj.should_receive(:==).any_number_of_times.and_return(false)
- 1.send(@method, obj).should == false
-
- obj = mock('another')
- obj.should_receive(:==).any_number_of_times.and_return(true)
- 2.send(@method, obj).should == true
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value
- end
-
- it "returns true if self has the same value as the given argument" do
- @bignum.send(@method, @bignum).should == true
- @bignum.send(@method, @bignum.to_f).should == true
-
- @bignum.send(@method, @bignum + 1).should == false
- (@bignum + 1).send(@method, @bignum).should == false
-
- @bignum.send(@method, 9).should == false
- @bignum.send(@method, 9.01).should == false
-
- @bignum.send(@method, bignum_value(10)).should == false
- end
-
- it "calls 'other == self' if the given argument is not an Integer" do
- obj = mock('not integer')
- obj.should_receive(:==).and_return(true)
- @bignum.send(@method, obj).should == true
- end
-
- it "returns the result of 'other == self' as a boolean" do
- obj = mock('not integer')
- obj.should_receive(:==).exactly(2).times.and_return("woot", nil)
- @bignum.send(@method, obj).should == true
- @bignum.send(@method, obj).should == false
- end
- end
-end
diff --git a/spec/ruby/core/integer/shared/exponent.rb b/spec/ruby/core/integer/shared/exponent.rb
deleted file mode 100644
index f292cc2448..0000000000
--- a/spec/ruby/core/integer/shared/exponent.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-describe :integer_exponent, shared: true do
- context "fixnum" do
- it "returns self raised to the given power" do
- 2.send(@method, 0).should eql 1
- 2.send(@method, 1).should eql 2
- 2.send(@method, 2).should eql 4
-
- 9.send(@method, 0.5).should eql 3.0
- 9.send(@method, Rational(1, 2)).should eql 3.0
- 5.send(@method, -1).to_f.to_s.should == '0.2'
-
- 2.send(@method, 40).should eql 1099511627776
- end
-
- it "overflows the answer to a bignum transparently" do
- 2.send(@method, 29).should eql 536870912
- 2.send(@method, 30).should eql 1073741824
- 2.send(@method, 31).should eql 2147483648
- 2.send(@method, 32).should eql 4294967296
-
- 2.send(@method, 61).should eql 2305843009213693952
- 2.send(@method, 62).should eql 4611686018427387904
- 2.send(@method, 63).should eql 9223372036854775808
- 2.send(@method, 64).should eql 18446744073709551616
- 8.send(@method, 23).should eql 590295810358705651712
- end
-
- it "raises negative numbers to the given power" do
- (-2).send(@method, 29).should eql(-536870912)
- (-2).send(@method, 30).should eql(1073741824)
- (-2).send(@method, 31).should eql(-2147483648)
- (-2).send(@method, 32).should eql(4294967296)
-
- (-2).send(@method, 61).should eql(-2305843009213693952)
- (-2).send(@method, 62).should eql(4611686018427387904)
- (-2).send(@method, 63).should eql(-9223372036854775808)
- (-2).send(@method, 64).should eql(18446744073709551616)
- end
-
- it "can raise 1 to a bignum safely" do
- 1.send(@method, 4611686018427387904).should eql 1
- end
-
- it "can raise -1 to a bignum safely" do
- (-1).send(@method, 4611686018427387904).should eql(1)
- (-1).send(@method, 4611686018427387905).should eql(-1)
- end
-
- it "returns Float::INFINITY when the number is too big" do
- 2.send(@method, 427387904).should == Float::INFINITY
- end
-
- it "raises a ZeroDivisionError for 0 ** -1" do
- -> { 0.send(@method, -1) }.should raise_error(ZeroDivisionError)
- -> { 0.send(@method, Rational(-1, 1)) }.should raise_error(ZeroDivisionError)
- end
-
- it "returns Float::INFINITY for 0 ** -1.0" do
- 0.send(@method, -1.0).should == Float::INFINITY
- end
-
- it "raises a TypeError when given a non-numeric power" do
- -> { 13.send(@method, "10") }.should raise_error(TypeError)
- -> { 13.send(@method, :symbol) }.should raise_error(TypeError)
- -> { 13.send(@method, nil) }.should raise_error(TypeError)
- end
-
- it "coerces power and calls #**" do
- num_2 = mock("2")
- num_13 = mock("13")
- num_2.should_receive(:coerce).with(13).and_return([num_13, num_2])
- num_13.should_receive(:**).with(num_2).and_return(169)
-
- 13.send(@method, num_2).should == 169
- end
-
- it "returns Float when power is Float" do
- 2.send(@method, 2.0).should == 4.0
- end
-
- it "returns Rational when power is Rational" do
- 2.send(@method, Rational(2, 1)).should == Rational(4, 1)
- end
-
- it "returns a complex number when negative and raised to a fractional power" do
- (-8).send(@method, 1.0/3) .should be_close(Complex(1, 1.73205), TOLERANCE)
- (-8).send(@method, Rational(1, 3)).should be_close(Complex(1, 1.73205), TOLERANCE)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value(47)
- end
-
- it "returns self raised to other power" do
- (@bignum.send(@method, 4)).should == 7237005577332262361485077344629993318496048279512298547155833600056910050625
- (@bignum.send(@method, 1.2)).should be_close(57262152889751597425762.57804, TOLERANCE)
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> { @bignum.send(@method, mock('10')) }.should raise_error(TypeError)
- -> { @bignum.send(@method, "10") }.should raise_error(TypeError)
- -> { @bignum.send(@method, :symbol) }.should raise_error(TypeError)
- end
-
- it "switch to a Float when the values is too big" do
- flt = @bignum.send(@method, @bignum)
- flt.should be_kind_of(Float)
- flt.infinite?.should == 1
- end
-
- it "returns a complex number when negative and raised to a fractional power" do
- ((-@bignum).send(@method, (1.0/3))) .should be_close(Complex(1048576,1816186.907597341), TOLERANCE)
- ((-@bignum).send(@method, Rational(1,3))).should be_close(Complex(1048576,1816186.907597341), TOLERANCE)
- end
- end
-end
diff --git a/spec/ruby/core/integer/shared/integer_rounding.rb b/spec/ruby/core/integer/shared/integer_rounding.rb
index 3fb6e830ef..ecbda1bb4a 100644
--- a/spec/ruby/core/integer/shared/integer_rounding.rb
+++ b/spec/ruby/core/integer/shared/integer_rounding.rb
@@ -5,9 +5,11 @@ describe :integer_rounding_positive_precision, shared: true do
end
end
- it "returns self if passed a precision of zero" do
- [2, -4, 10**70, -10**100].each do |v|
- v.send(@method, 0).should eql(v)
+ ruby_version_is "2.4" do
+ it "returns self if passed a precision of zero" do
+ [2, -4, 10**70, -10**100].each do |v|
+ v.send(@method, 0).should eql(v)
+ end
end
end
diff --git a/spec/ruby/core/integer/shared/modulo.rb b/spec/ruby/core/integer/shared/modulo.rb
deleted file mode 100644
index b06d81e17d..0000000000
--- a/spec/ruby/core/integer/shared/modulo.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-describe :integer_modulo, shared: true do
- context "fixnum" do
- it "returns the modulus obtained from dividing self by the given argument" do
- 13.send(@method, 4).should == 1
- 4.send(@method, 13).should == 4
-
- 13.send(@method, 4.0).should == 1
- 4.send(@method, 13.0).should == 4
-
- (-200).send(@method, 256).should == 56
- (-1000).send(@method, 512).should == 24
-
- (-200).send(@method, -256).should == -200
- (-1000).send(@method, -512).should == -488
-
- (200).send(@method, -256).should == -56
- (1000).send(@method, -512).should == -24
-
- 1.send(@method, 2.0).should == 1.0
- 200.send(@method, bignum_value).should == 200
- end
-
- it "raises a ZeroDivisionError when the given argument is 0" do
- -> { 13.send(@method, 0) }.should raise_error(ZeroDivisionError)
- -> { 0.send(@method, 0) }.should raise_error(ZeroDivisionError)
- -> { -10.send(@method, 0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
- -> { 0.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
- -> { 10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
- -> { -10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> {
- (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
- 13.send(@method, obj)
- }.should raise_error(TypeError)
- -> { 13.send(@method, "10") }.should raise_error(TypeError)
- -> { 13.send(@method, :symbol) }.should raise_error(TypeError)
- end
- end
-
- context "bignum" do
- before :each do
- @bignum = bignum_value
- end
-
- it "returns the modulus obtained from dividing self by the given argument" do
- @bignum.send(@method, 5).should == 3
- @bignum.send(@method, -5).should == -2
- @bignum.send(@method, -100).should == -92
- @bignum.send(@method, 2.22).should be_close(0.780180180180252, TOLERANCE)
- @bignum.send(@method, bignum_value(10)).should == 9223372036854775808
- end
-
- it "raises a ZeroDivisionError when the given argument is 0" do
- -> { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError)
- -> { (-@bignum).send(@method, 0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
- -> { @bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
- -> { -@bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
- end
-
- it "raises a TypeError when given a non-Integer" do
- -> { @bignum.send(@method, mock('10')) }.should raise_error(TypeError)
- -> { @bignum.send(@method, "10") }.should raise_error(TypeError)
- -> { @bignum.send(@method, :symbol) }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/integer/size_spec.rb b/spec/ruby/core/integer/size_spec.rb
deleted file mode 100644
index a134e82384..0000000000
--- a/spec/ruby/core/integer/size_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#size" do
- platform_is wordsize: 32 do
- it "returns the number of bytes in the machine representation of self" do
- -1.size.should == 4
- 0.size.should == 4
- 4091.size.should == 4
- end
- end
-
- platform_is wordsize: 64 do
- it "returns the number of bytes in the machine representation of self" do
- -1.size.should == 8
- 0.size.should == 8
- 4091.size.should == 8
- end
- end
-
- context "bignum" do
- it "returns the number of bytes required to hold the unsigned bignum data" do
- # that is, n such that 256 * n <= val.abs < 256 * (n+1)
- (256**7).size.should == 8
- (256**8).size.should == 9
- (256**9).size.should == 10
- (256**10).size.should == 11
- (256**10-1).size.should == 10
- (256**11).size.should == 12
- (256**12).size.should == 13
- (256**20-1).size.should == 20
- (256**40-1).size.should == 40
- end
- end
-end
diff --git a/spec/ruby/core/integer/sqrt_spec.rb b/spec/ruby/core/integer/sqrt_spec.rb
index e56da058a0..b7d9ef441b 100644
--- a/spec/ruby/core/integer/sqrt_spec.rb
+++ b/spec/ruby/core/integer/sqrt_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
ruby_version_is "2.5" do
describe "Integer.sqrt" do
@@ -15,7 +15,7 @@ ruby_version_is "2.5" do
end
it "raises a Math::DomainError if the argument is negative" do
- -> { Integer.sqrt(-4) }.should raise_error(Math::DomainError)
+ lambda { Integer.sqrt(-4) }.should raise_error(Math::DomainError)
end
it "accepts any argument that can be coerced to Integer" do
@@ -27,7 +27,7 @@ ruby_version_is "2.5" do
end
it "raises a TypeError if the argument cannot be coerced to Integer" do
- -> { Integer.sqrt("test") }.should raise_error(TypeError)
+ lambda { Integer.sqrt("test") }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/core/integer/succ_spec.rb b/spec/ruby/core/integer/succ_spec.rb
index 9ae9a14fe7..a1405684fc 100644
--- a/spec/ruby/core/integer/succ_spec.rb
+++ b/spec/ruby/core/integer/succ_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/next'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/next', __FILE__)
describe "Integer#succ" do
- it_behaves_like :integer_next, :succ
+ it_behaves_like(:integer_next, :succ)
end
diff --git a/spec/ruby/core/integer/times_spec.rb b/spec/ruby/core/integer/times_spec.rb
index 356340592b..d426bc008c 100644
--- a/spec/ruby/core/integer/times_spec.rb
+++ b/spec/ruby/core/integer/times_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#times" do
it "returns self" do
diff --git a/spec/ruby/core/integer/to_f_spec.rb b/spec/ruby/core/integer/to_f_spec.rb
deleted file mode 100644
index 06092eaa92..0000000000
--- a/spec/ruby/core/integer/to_f_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#to_f" do
- context "fixnum" do
- it "returns self converted to a Float" do
- 0.to_f.should == 0.0
- -500.to_f.should == -500.0
- 9_641_278.to_f.should == 9641278.0
- end
- end
-
- context "bignum" do
- it "returns self converted to a Float" do
- bignum_value(0x4000_0aa0_0bb0_0000).to_f.should eql(13_835_069_737_789_292_544.00)
- bignum_value(0x8000_0000_0000_0ccc).to_f.should eql(18_446_744_073_709_555_712.00)
- (-bignum_value(99)).to_f.should eql(-9_223_372_036_854_775_808.00)
- end
-
- it "converts number close to Float::MAX without exceeding MAX or producing NaN" do
- (10**308).to_f.should == 10.0 ** 308
- end
- end
-end
diff --git a/spec/ruby/core/integer/to_i_spec.rb b/spec/ruby/core/integer/to_i_spec.rb
index 1a8e477b3c..1e6f21f191 100644
--- a/spec/ruby/core/integer/to_i_spec.rb
+++ b/spec/ruby/core/integer/to_i_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
describe "Integer#to_i" do
- it_behaves_like :integer_to_i, :to_i
+ it_behaves_like(:integer_to_i, :to_i)
end
diff --git a/spec/ruby/core/integer/to_int_spec.rb b/spec/ruby/core/integer/to_int_spec.rb
index 4b7eccad3a..5e87c86ccd 100644
--- a/spec/ruby/core/integer/to_int_spec.rb
+++ b/spec/ruby/core/integer/to_int_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
describe "Integer#to_int" do
- it_behaves_like :integer_to_i, :to_int
+ it_behaves_like(:integer_to_i, :to_int)
end
diff --git a/spec/ruby/core/integer/to_r_spec.rb b/spec/ruby/core/integer/to_r_spec.rb
index 4a40575b7f..0eb158b100 100644
--- a/spec/ruby/core/integer/to_r_spec.rb
+++ b/spec/ruby/core/integer/to_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#to_r" do
it "returns a Rational object" do
@@ -20,7 +20,7 @@ describe "Integer#to_r" do
end
it "raises an ArgumentError if given any arguments" do
- -> { 287.to_r(2) }.should raise_error(ArgumentError)
- -> { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError)
+ lambda { 287.to_r(2) }.should raise_error(ArgumentError)
+ lambda { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/integer/to_s_spec.rb b/spec/ruby/core/integer/to_s_spec.rb
deleted file mode 100644
index 7988bfde7a..0000000000
--- a/spec/ruby/core/integer/to_s_spec.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#to_s" do
- context "fixnum" do
- context "when given a base" do
- it "returns self converted to a String in the given base" do
- 12345.to_s(2).should == "11000000111001"
- 12345.to_s(8).should == "30071"
- 12345.to_s(10).should == "12345"
- 12345.to_s(16).should == "3039"
- 95.to_s(16).should == "5f"
- 12345.to_s(36).should == "9ix"
- end
-
- it "raises an ArgumentError if the base is less than 2 or higher than 36" do
- -> { 123.to_s(-1) }.should raise_error(ArgumentError)
- -> { 123.to_s(0) }.should raise_error(ArgumentError)
- -> { 123.to_s(1) }.should raise_error(ArgumentError)
- -> { 123.to_s(37) }.should raise_error(ArgumentError)
- end
- end
-
- context "when no base given" do
- it "returns self converted to a String using base 10" do
- 255.to_s.should == '255'
- 3.to_s.should == '3'
- 0.to_s.should == '0'
- -9002.to_s.should == '-9002'
- end
- end
-
- before :each do
- @internal = Encoding.default_internal
- end
-
- after :each do
- Encoding.default_internal = @internal
- end
-
- it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- 1.to_s.encoding.should equal(Encoding::US_ASCII)
- end
-
- it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
- Encoding.default_internal = Encoding::IBM437
- 1.to_s.encoding.should equal(Encoding::US_ASCII)
- end
- end
-
- context "bignum" do
- describe "when given a base" do
- it "returns self converted to a String using the given base" do
- a = 2**64
- a.to_s(2).should == "10000000000000000000000000000000000000000000000000000000000000000"
- a.to_s(8).should == "2000000000000000000000"
- a.to_s(16).should == "10000000000000000"
- a.to_s(32).should == "g000000000000"
- end
-
- it "raises an ArgumentError if the base is less than 2 or higher than 36" do
- -> { 123.to_s(-1) }.should raise_error(ArgumentError)
- -> { 123.to_s(0) }.should raise_error(ArgumentError)
- -> { 123.to_s(1) }.should raise_error(ArgumentError)
- -> { 123.to_s(37) }.should raise_error(ArgumentError)
- end
- end
-
- describe "when given no base" do
- it "returns self converted to a String using base 10" do
- bignum_value(9).to_s.should == "9223372036854775817"
- bignum_value.to_s.should == "9223372036854775808"
- (-bignum_value(675)).to_s.should == "-9223372036854776483"
- end
- end
-
- before :each do
- @internal = Encoding.default_internal
- end
-
- after :each do
- Encoding.default_internal = @internal
- end
-
- it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- bignum_value.to_s.encoding.should equal(Encoding::US_ASCII)
- end
-
- it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
- Encoding.default_internal = Encoding::IBM437
- bignum_value.to_s.encoding.should equal(Encoding::US_ASCII)
- end
- end
-end
diff --git a/spec/ruby/core/integer/truncate_spec.rb b/spec/ruby/core/integer/truncate_spec.rb
index db16e74be4..429ab1a312 100644
--- a/spec/ruby/core/integer/truncate_spec.rb
+++ b/spec/ruby/core/integer/truncate_spec.rb
@@ -1,19 +1,21 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
-require_relative 'shared/integer_rounding'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
+require File.expand_path('../shared/integer_rounding', __FILE__)
describe "Integer#truncate" do
- it_behaves_like :integer_to_i, :truncate
- it_behaves_like :integer_rounding_positive_precision, :truncate
+ it_behaves_like(:integer_to_i, :truncate)
+ it_behaves_like(:integer_rounding_positive_precision, :truncate)
- context "precision argument specified as part of the truncate method is negative" do
- it "returns an integer with at least precision.abs trailing zeros" do
- 1832.truncate(-1).should eql(1830)
- 1832.truncate(-2).should eql(1800)
- 1832.truncate(-3).should eql(1000)
- -1832.truncate(-1).should eql(-1830)
- -1832.truncate(-2).should eql(-1800)
- -1832.truncate(-3).should eql(-1000)
+ ruby_version_is "2.4" do
+ context "precision argument specified as part of the truncate method is negative" do
+ it "returns an integer with at least precision.abs trailing zeros" do
+ 1832.truncate(-1).should eql(1830)
+ 1832.truncate(-2).should eql(1800)
+ 1832.truncate(-3).should eql(1000)
+ -1832.truncate(-1).should eql(-1830)
+ -1832.truncate(-2).should eql(-1800)
+ -1832.truncate(-3).should eql(-1000)
+ end
end
end
end
diff --git a/spec/ruby/core/integer/uminus_spec.rb b/spec/ruby/core/integer/uminus_spec.rb
deleted file mode 100644
index b6b110dec4..0000000000
--- a/spec/ruby/core/integer/uminus_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Integer#-@" do
- context "fixnum" do
- it "returns self as a negative value" do
- 2.send(:-@).should == -2
- -2.should == -2
- -268435455.should == -268435455
- (--5).should == 5
- -8.send(:-@).should == 8
- end
-
- it "negates self at Fixnum/Bignum boundaries" do
- (-fixnum_max).should == (0 - fixnum_max)
- (-fixnum_max).should < 0
- (-fixnum_min).should == (0 - fixnum_min)
- (-fixnum_min).should > 0
- end
- end
-
- context "bignum" do
- it "returns self as a negative value" do
- bignum_value.send(:-@).should == -9223372036854775808
- (-bignum_value).send(:-@).should == 9223372036854775808
-
- bignum_value(921).send(:-@).should == -9223372036854776729
- (-bignum_value(921).send(:-@)).should == 9223372036854776729
- end
- end
-end
diff --git a/spec/ruby/core/integer/upto_spec.rb b/spec/ruby/core/integer/upto_spec.rb
index 6049eb173e..405f8e4817 100644
--- a/spec/ruby/core/integer/upto_spec.rb
+++ b/spec/ruby/core/integer/upto_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Integer#upto [stop] when self and stop are Fixnums" do
it "does not yield when stop is less than self" do
@@ -27,8 +27,8 @@ describe "Integer#upto [stop] when self and stop are Fixnums" do
end
it "raises an ArgumentError for non-numeric endpoints" do
- -> { 1.upto("A") {|x| p x} }.should raise_error(ArgumentError)
- -> { 1.upto(nil) {|x| p x} }.should raise_error(ArgumentError)
+ lambda { 1.upto("A") {|x| p x} }.should raise_error(ArgumentError)
+ lambda { 1.upto(nil) {|x| p x} }.should raise_error(ArgumentError)
end
describe "when no block is given" do
@@ -45,9 +45,9 @@ describe "Integer#upto [stop] when self and stop are Fixnums" do
describe "size" do
it "raises an ArgumentError for non-numeric endpoints" do
enum = 1.upto("A")
- -> { enum.size }.should raise_error(ArgumentError)
+ lambda { enum.size }.should raise_error(ArgumentError)
enum = 1.upto(nil)
- -> { enum.size }.should raise_error(ArgumentError)
+ lambda { enum.size }.should raise_error(ArgumentError)
end
it "returns stop - self + 1" do
diff --git a/spec/ruby/core/io/advise_spec.rb b/spec/ruby/core/io/advise_spec.rb
index 0a845487e2..44cd32df94 100644
--- a/spec/ruby/core/io/advise_spec.rb
+++ b/spec/ruby/core/io/advise_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#advise" do
before :each do
@@ -12,37 +12,37 @@ describe "IO#advise" do
end
it "raises a TypeError if advise is not a Symbol" do
- -> {
+ lambda {
@io.advise("normal")
}.should raise_error(TypeError)
end
it "raises a TypeError if offset cannot be coerced to an Integer" do
- -> {
+ lambda {
@io.advise(:normal, "wat")
}.should raise_error(TypeError)
end
it "raises a TypeError if len cannot be coerced to an Integer" do
- -> {
+ lambda {
@io.advise(:normal, 0, "wat")
}.should raise_error(TypeError)
end
it "raises a RangeError if offset is too big" do
- -> {
+ lambda {
@io.advise(:normal, 10 ** 32)
}.should raise_error(RangeError)
end
it "raises a RangeError if len is too big" do
- -> {
+ lambda {
@io.advise(:normal, 0, 10 ** 32)
}.should raise_error(RangeError)
end
it "raises a NotImplementedError if advise is not recognized" do
- ->{
+ lambda{
@io.advise(:foo)
}.should raise_error(NotImplementedError)
end
@@ -82,7 +82,8 @@ describe "IO#advise" do
`uname -r`.chomp
end
if (uname.split('.').map(&:to_i) <=> [3,6]) < 0
- skip "[ruby-core:65355] tmpfs is not supported"
+ # [ruby-core:65355] tmpfs is not supported
+ 1.should == 1
else
@io.advise(:willneed).should be_nil
end
@@ -91,6 +92,6 @@ describe "IO#advise" do
it "raises an IOError if the stream is closed" do
@io.close
- -> { @io.advise(:normal) }.should raise_error(IOError)
+ lambda { @io.advise(:normal) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/binmode_spec.rb b/spec/ruby/core/io/binmode_spec.rb
index b698777cad..f437c8a4a4 100644
--- a/spec/ruby/core/io/binmode_spec.rb
+++ b/spec/ruby/core/io/binmode_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#binmode" do
before :each do
@@ -17,7 +17,7 @@ describe "IO#binmode" do
end
it "raises an IOError on closed stream" do
- -> { IOSpecs.closed_io.binmode }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.binmode }.should raise_error(IOError)
end
it "sets external encoding to binary" do
diff --git a/spec/ruby/core/io/binread_spec.rb b/spec/ruby/core/io/binread_spec.rb
index a3f752d8f9..b592639f9d 100644
--- a/spec/ruby/core/io/binread_spec.rb
+++ b/spec/ruby/core/io/binread_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO.binread" do
before :each do
@@ -28,20 +28,22 @@ describe "IO.binread" do
IO.binread(@fname, 5, 3).should == @contents.slice(3, 5)
end
- it "returns a String in BINARY encoding" do
- IO.binread(@fname).encoding.should == Encoding::BINARY
+ it "returns a String in ASCII-8BIT encoding" do
+ IO.binread(@fname).encoding.should == Encoding::ASCII_8BIT
end
- it "returns a String in BINARY encoding regardless of Encoding.default_internal" do
+ it "returns a String in ASCII-8BIT encoding regardless of Encoding.default_internal" do
Encoding.default_internal = Encoding::EUC_JP
- IO.binread(@fname).encoding.should == Encoding::BINARY
+ IO.binread(@fname).encoding.should == Encoding::ASCII_8BIT
end
it "raises an ArgumentError when not passed a valid length" do
- -> { IO.binread @fname, -1 }.should raise_error(ArgumentError)
+ lambda { IO.binread @fname, -1 }.should raise_error(ArgumentError)
end
- it "raises an Errno::EINVAL when not passed a valid offset" do
- -> { IO.binread @fname, 0, -1 }.should raise_error(Errno::EINVAL)
+ ruby_version_is "2.3" do # MRI leaks the fd on older versions
+ it "raises an Errno::EINVAL when not passed a valid offset" do
+ lambda { IO.binread @fname, 0, -1 }.should raise_error(Errno::EINVAL)
+ end
end
end
diff --git a/spec/ruby/core/io/binwrite_spec.rb b/spec/ruby/core/io/binwrite_spec.rb
index 8ebc86a52e..ec964d07a8 100644
--- a/spec/ruby/core/io/binwrite_spec.rb
+++ b/spec/ruby/core/io/binwrite_spec.rb
@@ -1,6 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/binwrite'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/binwrite', __FILE__)
describe "IO.binwrite" do
it_behaves_like :io_binwrite, :binwrite
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/io/bytes_spec.rb b/spec/ruby/core/io/bytes_spec.rb
index feeb493566..3eb51883c4 100644
--- a/spec/ruby/core/io/bytes_spec.rb
+++ b/spec/ruby/core/io/bytes_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#bytes" do
before :each do
@@ -31,13 +31,13 @@ describe "IO#bytes" do
it "raises an IOError on closed stream" do
enum = IOSpecs.closed_io.bytes
- -> { enum.first }.should raise_error(IOError)
+ lambda { enum.first }.should raise_error(IOError)
end
it "raises an IOError on an enumerator for a stream that has been closed" do
enum = @io.bytes
enum.first.should == 86
@io.close
- -> { enum.first }.should raise_error(IOError)
+ lambda { enum.first }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/chars_spec.rb b/spec/ruby/core/io/chars_spec.rb
index cd5dbbce4f..e38160274f 100644
--- a/spec/ruby/core/io/chars_spec.rb
+++ b/spec/ruby/core/io/chars_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/chars'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/chars', __FILE__)
describe "IO#chars" do
it_behaves_like :io_chars, :chars
diff --git a/spec/ruby/core/io/close_on_exec_spec.rb b/spec/ruby/core/io/close_on_exec_spec.rb
index f837bb56af..057a9a1c20 100644
--- a/spec/ruby/core/io/close_on_exec_spec.rb
+++ b/spec/ruby/core/io/close_on_exec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO#close_on_exec=" do
before :each do
@@ -11,7 +11,17 @@ describe "IO#close_on_exec=" do
rm_r @name
end
- guard -> { platform_is_not :windows } do
+ guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
+ it "returns false from #respond_to?" do
+ @io.respond_to?(:close_on_exec=).should be_false
+ end
+
+ it "raises a NotImplementedError when called" do
+ lambda { @io.close_on_exec = true }.should raise_error(NotImplementedError)
+ end
+ end
+
+ guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
it "sets the close-on-exec flag if true" do
@io.close_on_exec = true
@io.close_on_exec?.should == true
@@ -42,7 +52,7 @@ describe "IO#close_on_exec=" do
it "raises IOError if called on a closed IO" do
@io.close
- -> { @io.close_on_exec = true }.should raise_error(IOError)
+ lambda { @io.close_on_exec = true }.should raise_error(IOError)
end
it "returns nil" do
@@ -62,7 +72,17 @@ describe "IO#close_on_exec?" do
rm_r @name
end
- guard -> { platform_is_not :windows } do
+ guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
+ it "returns false from #respond_to?" do
+ @io.respond_to?(:close_on_exec?).should be_false
+ end
+
+ it "raises a NotImplementedError when called" do
+ lambda { @io.close_on_exec? }.should raise_error(NotImplementedError)
+ end
+ end
+
+ guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
it "returns true by default" do
@io.close_on_exec?.should == true
end
@@ -74,7 +94,7 @@ describe "IO#close_on_exec?" do
it "raises IOError if called on a closed IO" do
@io.close
- -> { @io.close_on_exec? }.should raise_error(IOError)
+ lambda { @io.close_on_exec? }.should raise_error(IOError)
end
end
end
diff --git a/spec/ruby/core/io/close_read_spec.rb b/spec/ruby/core/io/close_read_spec.rb
index 6fa4fc8ff8..b5aba57795 100644
--- a/spec/ruby/core/io/close_read_spec.rb
+++ b/spec/ruby/core/io/close_read_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#close_read" do
@@ -16,26 +16,36 @@ describe "IO#close_read" do
it "closes the read end of a duplex I/O stream" do
@io.close_read
- -> { @io.read }.should raise_error(IOError)
+ lambda { @io.read }.should raise_error(IOError)
end
- it "does nothing on subsequent invocations" do
- @io.close_read
+ ruby_version_is ''...'2.3' do
+ it "raises an IOError on subsequent invocations" do
+ @io.close_read
+
+ lambda { @io.close_read }.should raise_error(IOError)
+ end
+ end
+
+ ruby_version_is '2.3' do
+ it "does nothing on subsequent invocations" do
+ @io.close_read
- @io.close_read.should be_nil
+ @io.close_read.should be_nil
+ end
end
it "allows subsequent invocation of close" do
@io.close_read
- -> { @io.close }.should_not raise_error
+ lambda { @io.close }.should_not raise_error
end
it "raises an IOError if the stream is writable and not duplexed" do
io = File.open @path, 'w'
begin
- -> { io.close_read }.should raise_error(IOError)
+ lambda { io.close_read }.should raise_error(IOError)
ensure
io.close unless io.closed?
end
@@ -52,9 +62,19 @@ describe "IO#close_read" do
io.closed?.should == true
end
- it "does nothing on closed stream" do
- @io.close
+ ruby_version_is ''...'2.3' do
+ it "raises IOError on closed stream" do
+ @io.close
- @io.close_read.should be_nil
+ lambda { @io.close_read }.should raise_error(IOError)
+ end
+ end
+
+ ruby_version_is '2.3' do
+ it "does nothing on closed stream" do
+ @io.close
+
+ @io.close_read.should be_nil
+ end
end
end
diff --git a/spec/ruby/core/io/close_spec.rb b/spec/ruby/core/io/close_spec.rb
index 21bba32cd8..0e51ec23d2 100644
--- a/spec/ruby/core/io/close_spec.rb
+++ b/spec/ruby/core/io/close_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#close" do
before :each do
@@ -23,42 +23,26 @@ describe "IO#close" do
it "raises an IOError reading from a closed IO" do
@io.close
- -> { @io.read }.should raise_error(IOError)
+ lambda { @io.read }.should raise_error(IOError)
end
it "raises an IOError writing to a closed IO" do
@io.close
- -> { @io.write "data" }.should raise_error(IOError)
+ lambda { @io.write "data" }.should raise_error(IOError)
end
- it 'does not close the stream if autoclose is false' do
- other_io = IO.new(@io.fileno)
- other_io.autoclose = false
- other_io.close
- -> { @io.write "data" }.should_not raise_error(IOError)
+ ruby_version_is ''...'2.3' do
+ it "raises an IOError if closed" do
+ @io.close
+ lambda { @io.close }.should raise_error(IOError)
+ end
end
- it "does nothing if already closed" do
- @io.close
+ ruby_version_is "2.3" do
+ it "does nothing if already closed" do
+ @io.close
- @io.close.should be_nil
- end
-
- ruby_version_is '2.5' do
- it 'raises an IOError with a clear message' do
- read_io, write_io = IO.pipe
- going_to_read = false
- thread = Thread.new do
- -> do
- going_to_read = true
- read_io.read
- end.should raise_error(IOError, 'stream closed in another thread')
- end
-
- Thread.pass until going_to_read && thread.stop?
- read_io.close
- thread.join
- write_io.close
+ @io.close.should be_nil
end
end
end
@@ -72,7 +56,7 @@ describe "IO#close on an IO.popen stream" do
io.close
- -> { io.pid }.should raise_error(IOError)
+ lambda { io.pid }.should raise_error(IOError)
end
it "sets $?" do
@@ -95,3 +79,4 @@ describe "IO#close on an IO.popen stream" do
end
end
+
diff --git a/spec/ruby/core/io/close_write_spec.rb b/spec/ruby/core/io/close_write_spec.rb
index 75e1577654..c901aac499 100644
--- a/spec/ruby/core/io/close_write_spec.rb
+++ b/spec/ruby/core/io/close_write_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#close_write" do
before :each do
@@ -15,26 +15,36 @@ describe "IO#close_write" do
it "closes the write end of a duplex I/O stream" do
@io.close_write
- -> { @io.write "attempt to write" }.should raise_error(IOError)
+ lambda { @io.write "attempt to write" }.should raise_error(IOError)
end
- it "does nothing on subsequent invocations" do
- @io.close_write
+ ruby_version_is ''...'2.3' do
+ it "raises an IOError on subsequent invocations" do
+ @io.close_write
+
+ lambda { @io.close_write }.should raise_error(IOError)
+ end
+ end
+
+ ruby_version_is '2.3' do
+ it "does nothing on subsequent invocations" do
+ @io.close_write
- @io.close_write.should be_nil
+ @io.close_write.should be_nil
+ end
end
it "allows subsequent invocation of close" do
@io.close_write
- -> { @io.close }.should_not raise_error
+ lambda { @io.close }.should_not raise_error
end
it "raises an IOError if the stream is readable and not duplexed" do
io = File.open @path, 'w+'
begin
- -> { io.close_write }.should raise_error(IOError)
+ lambda { io.close_write }.should raise_error(IOError)
ensure
io.close unless io.closed?
end
@@ -56,9 +66,19 @@ describe "IO#close_write" do
@io.read.should == "12345\n"
end
- it "does nothing on closed stream" do
- @io.close
+ ruby_version_is ''...'2.3' do
+ it "raises IOError on closed stream" do
+ @io.close
- @io.close_write.should be_nil
+ lambda { @io.close_write }.should raise_error(IOError)
+ end
+ end
+
+ ruby_version_is '2.3' do
+ it "does nothing on closed stream" do
+ @io.close
+
+ @io.close_write.should be_nil
+ end
end
end
diff --git a/spec/ruby/core/io/closed_spec.rb b/spec/ruby/core/io/closed_spec.rb
index 7316546a0d..80562885a7 100644
--- a/spec/ruby/core/io/closed_spec.rb
+++ b/spec/ruby/core/io/closed_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#closed?" do
before :each do
diff --git a/spec/ruby/core/io/codepoints_spec.rb b/spec/ruby/core/io/codepoints_spec.rb
index 915d99c027..6e6b9613b5 100644
--- a/spec/ruby/core/io/codepoints_spec.rb
+++ b/spec/ruby/core/io/codepoints_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/codepoints'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/codepoints', __FILE__)
# See redmine #1667
describe "IO#codepoints" do
- it_behaves_like :io_codepoints, :codepoints
+ it_behaves_like(:io_codepoints, :codepoints)
end
describe "IO#codepoints" do
diff --git a/spec/ruby/core/io/constants_spec.rb b/spec/ruby/core/io/constants_spec.rb
index f9dccd08b9..0a2ea70560 100644
--- a/spec/ruby/core/io/constants_spec.rb
+++ b/spec/ruby/core/io/constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO::SEEK_SET" do
it "is defined" do
diff --git a/spec/ruby/core/io/copy_stream_spec.rb b/spec/ruby/core/io/copy_stream_spec.rb
index c541e96e14..344746fac3 100644
--- a/spec/ruby/core/io/copy_stream_spec.rb
+++ b/spec/ruby/core/io/copy_stream_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :io_copy_stream_to_file, shared: true do
it "copies the entire IO contents to the file" do
@@ -31,7 +31,7 @@ describe :io_copy_stream_to_file, shared: true do
obj = mock("io_copy_stream_to")
obj.should_receive(:to_path).and_return(1)
- -> { IO.copy_stream(@object.from, obj) }.should raise_error(TypeError)
+ lambda { IO.copy_stream(@object.from, obj) }.should raise_error(TypeError)
end
end
@@ -71,7 +71,7 @@ describe :io_copy_stream_to_io, shared: true do
it "raises an IOError if the destination IO is not open for writing" do
@to_io.close
@to_io = new_io @to_name, "r"
- -> { IO.copy_stream @object.from, @to_io }.should raise_error(IOError)
+ lambda { IO.copy_stream @object.from, @to_io }.should raise_error(IOError)
end
it "does not close the destination IO" do
@@ -125,7 +125,7 @@ describe "IO.copy_stream" do
it "raises an IOError if the source IO is not open for reading" do
@from_io.close
@from_io = new_io @from_bigfile, "a"
- -> { IO.copy_stream @from_io, @to_name }.should raise_error(IOError)
+ lambda { IO.copy_stream @from_io, @to_name }.should raise_error(IOError)
end
it "does not close the source IO" do
@@ -183,7 +183,7 @@ describe "IO.copy_stream" do
obj = mock("io_copy_stream_from")
obj.should_receive(:to_path).and_return(1)
- -> { IO.copy_stream(obj, @to_name) }.should raise_error(TypeError)
+ lambda { IO.copy_stream(obj, @to_name) }.should raise_error(TypeError)
end
describe "to a file name" do
@@ -222,7 +222,7 @@ describe "IO.copy_stream" do
platform_is_not :windows do
it "raises an error when an offset is specified" do
- -> { IO.copy_stream(@from_io, @to_name, 8, 4) }.should raise_error(Errno::ESPIPE)
+ lambda { IO.copy_stream(@from_io, @to_name, 8, 4) }.should raise_error(Errno::ESPIPE)
end
end
diff --git a/spec/ruby/core/io/dup_spec.rb b/spec/ruby/core/io/dup_spec.rb
index de32c5e347..a90b04aa5d 100644
--- a/spec/ruby/core/io/dup_spec.rb
+++ b/spec/ruby/core/io/dup_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#dup" do
before :each do
- @file = tmp("spec_io_dup")
+ @file = tmp("rubinius_spec_io_dup_#{$$}_#{Time.now.to_f}")
@f = File.open @file, 'w+'
@i = @f.dup
@@ -49,7 +49,7 @@ end
it "allows closing the new IO without affecting the original" do
@i.close
- -> { @f.gets }.should_not raise_error(Exception)
+ lambda { @f.gets }.should_not raise_error(Exception)
@i.closed?.should == true
@f.closed?.should == false
@@ -57,31 +57,13 @@ end
it "allows closing the original IO without affecting the new one" do
@f.close
- -> { @i.gets }.should_not raise_error(Exception)
+ lambda { @i.gets }.should_not raise_error(Exception)
@i.closed?.should == false
@f.closed?.should == true
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.dup }.should raise_error(IOError)
- end
-
- it "always sets the close-on-exec flag for the new IO object" do
- @f.close_on_exec = true
- dup = @f.dup
- begin
- dup.close_on_exec?.should == true
- ensure
- dup.close
- end
-
- @f.close_on_exec = false
- dup = @f.dup
- begin
- dup.close_on_exec?.should == true
- ensure
- dup.close
- end
+ lambda { IOSpecs.closed_io.dup }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/each_byte_spec.rb b/spec/ruby/core/io/each_byte_spec.rb
index ea618e8c0c..0dc535a159 100644
--- a/spec/ruby/core/io/each_byte_spec.rb
+++ b/spec/ruby/core/io/each_byte_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#each_byte" do
before :each do
@@ -12,7 +12,7 @@ describe "IO#each_byte" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.each_byte {} }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.each_byte {} }.should raise_error(IOError)
end
it "yields each byte" do
diff --git a/spec/ruby/core/io/each_char_spec.rb b/spec/ruby/core/io/each_char_spec.rb
index 5d460a1e7c..69c6739920 100644
--- a/spec/ruby/core/io/each_char_spec.rb
+++ b/spec/ruby/core/io/each_char_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/chars'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/chars', __FILE__)
describe "IO#each_char" do
it_behaves_like :io_chars, :each_char
diff --git a/spec/ruby/core/io/each_codepoint_spec.rb b/spec/ruby/core/io/each_codepoint_spec.rb
index cddc6b4662..eb16e004fa 100644
--- a/spec/ruby/core/io/each_codepoint_spec.rb
+++ b/spec/ruby/core/io/each_codepoint_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/codepoints'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/codepoints', __FILE__)
# See redmine #1667
describe "IO#each_codepoint" do
- it_behaves_like :io_codepoints, :codepoints
+ it_behaves_like(:io_codepoints, :codepoints)
end
describe "IO#each_codepoint" do
@@ -37,7 +37,9 @@ describe "IO#each_codepoint" do
@io.close if @io
end
- it "raises an exception at incomplete character before EOF when conversion takes place" do
- -> { @io.each_codepoint {} }.should raise_error(ArgumentError)
+ ruby_version_is "2.3" do # earlier versions stay blocked
+ it "raises an exception at incomplete character before EOF when conversion takes place" do
+ lambda { @io.each_codepoint {} }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/io/each_line_spec.rb b/spec/ruby/core/io/each_line_spec.rb
index 58d26b325d..d4d8af7902 100644
--- a/spec/ruby/core/io/each_line_spec.rb
+++ b/spec/ruby/core/io/each_line_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/each'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each', __FILE__)
describe "IO#each_line" do
it_behaves_like :io_each, :each_line
diff --git a/spec/ruby/core/io/each_spec.rb b/spec/ruby/core/io/each_spec.rb
index 91ecbd19c8..4d6aa50fb2 100644
--- a/spec/ruby/core/io/each_spec.rb
+++ b/spec/ruby/core/io/each_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/each'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each', __FILE__)
describe "IO#each" do
it_behaves_like :io_each, :each
diff --git a/spec/ruby/core/io/eof_spec.rb b/spec/ruby/core/io/eof_spec.rb
index 8fd3c37132..a2c5e563f0 100644
--- a/spec/ruby/core/io/eof_spec.rb
+++ b/spec/ruby/core/io/eof_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#eof?" do
before :each do
@@ -16,7 +16,7 @@ describe "IO#eof?" do
end
it "raises IOError on stream not opened for reading" do
- -> do
+ lambda do
File.open(@name, "w") { |f| f.eof? }
end.should raise_error(IOError)
end
@@ -67,12 +67,12 @@ describe "IO#eof?" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.eof? }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.eof? }.should raise_error(IOError)
end
it "raises IOError on stream closed for reading by close_read" do
@io.close_read
- -> { @io.eof? }.should raise_error(IOError)
+ lambda { @io.eof? }.should raise_error(IOError)
end
it "returns true on one-byte stream after single-byte read" do
diff --git a/spec/ruby/core/io/external_encoding_spec.rb b/spec/ruby/core/io/external_encoding_spec.rb
index 9666974647..ec85eba2ee 100644
--- a/spec/ruby/core/io/external_encoding_spec.rb
+++ b/spec/ruby/core/io/external_encoding_spec.rb
@@ -1,216 +1,218 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe :io_external_encoding_write, shared: true do
- describe "when Encoding.default_internal is nil" do
- before :each do
- Encoding.default_internal = nil
- end
-
- it "returns nil" do
- @io = new_io @name, @object
- Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should be_nil
- end
-
- it "returns the external encoding specified when the instance was created" do
- @io = new_io @name, "#{@object}:ibm866"
- Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::IBM866)
- end
-
- it "returns the encoding set by #set_encoding" do
- @io = new_io @name, "#{@object}:ibm866"
- @io.set_encoding Encoding::EUC_JP, nil
- @io.external_encoding.should equal(Encoding::EUC_JP)
- end
- end
-
- describe "when Encoding.default_external != Encoding.default_internal" do
- before :each do
- Encoding.default_external = Encoding::IBM437
- Encoding.default_internal = Encoding::IBM866
- end
-
- it "returns the value of Encoding.default_external when the instance was created" do
- @io = new_io @name, @object
- Encoding.default_external = Encoding::UTF_8
- @io.external_encoding.should equal(Encoding::IBM437)
- end
-
- it "returns the external encoding specified when the instance was created" do
- @io = new_io @name, "#{@object}:ibm866"
- Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::IBM866)
- end
-
- it "returns the encoding set by #set_encoding" do
- @io = new_io @name, "#{@object}:ibm866"
- @io.set_encoding Encoding::EUC_JP, nil
- @io.external_encoding.should equal(Encoding::EUC_JP)
- end
- end
-
- describe "when Encoding.default_external == Encoding.default_internal" do
- before :each do
- Encoding.default_external = Encoding::IBM866
- Encoding.default_internal = Encoding::IBM866
- end
-
- it "returns the value of Encoding.default_external when the instance was created" do
- @io = new_io @name, @object
- Encoding.default_external = Encoding::UTF_8
- @io.external_encoding.should equal(Encoding::IBM866)
- end
-
- it "returns the external encoding specified when the instance was created" do
- @io = new_io @name, "#{@object}:ibm866"
- Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::IBM866)
- end
-
- it "returns the encoding set by #set_encoding" do
- @io = new_io @name, "#{@object}:ibm866"
- @io.set_encoding Encoding::EUC_JP, nil
- @io.external_encoding.should equal(Encoding::EUC_JP)
- end
- end
-end
-
-describe "IO#external_encoding" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
-
- @name = tmp("io_external_encoding")
- touch(@name)
- end
-
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
-
- @io.close if @io
- rm_r @name
- end
-
- describe "with 'r' mode" do
+with_feature :encoding do
+ describe :io_external_encoding_write, shared: true do
describe "when Encoding.default_internal is nil" do
before :each do
Encoding.default_internal = nil
- Encoding.default_external = Encoding::IBM866
end
- it "returns Encoding.default_external if the external encoding is not set" do
- @io = new_io @name, "r"
- @io.external_encoding.should equal(Encoding::IBM866)
- end
-
- it "returns Encoding.default_external when that encoding is changed after the instance is created" do
- @io = new_io @name, "r"
+ it "returns nil" do
+ @io = new_io @name, @object
Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::IBM437)
+ @io.external_encoding.should be_nil
end
it "returns the external encoding specified when the instance was created" do
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, "#{@object}:ibm866"
Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::UTF_8)
+ @io.external_encoding.should equal(Encoding::IBM866)
end
it "returns the encoding set by #set_encoding" do
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, "#{@object}:ibm866"
@io.set_encoding Encoding::EUC_JP, nil
@io.external_encoding.should equal(Encoding::EUC_JP)
end
end
- describe "when Encoding.default_external == Encoding.default_internal" do
+ describe "when Encoding.default_external != Encoding.default_internal" do
before :each do
- Encoding.default_external = Encoding::IBM866
+ Encoding.default_external = Encoding::IBM437
Encoding.default_internal = Encoding::IBM866
end
it "returns the value of Encoding.default_external when the instance was created" do
- @io = new_io @name, "r"
- Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::IBM866)
+ @io = new_io @name, @object
+ Encoding.default_external = Encoding::UTF_8
+ @io.external_encoding.should equal(Encoding::IBM437)
end
it "returns the external encoding specified when the instance was created" do
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, "#{@object}:ibm866"
Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::UTF_8)
+ @io.external_encoding.should equal(Encoding::IBM866)
end
it "returns the encoding set by #set_encoding" do
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, "#{@object}:ibm866"
@io.set_encoding Encoding::EUC_JP, nil
@io.external_encoding.should equal(Encoding::EUC_JP)
end
end
- describe "when Encoding.default_external != Encoding.default_internal" do
+ describe "when Encoding.default_external == Encoding.default_internal" do
before :each do
- Encoding.default_external = Encoding::IBM437
+ Encoding.default_external = Encoding::IBM866
Encoding.default_internal = Encoding::IBM866
end
+ it "returns the value of Encoding.default_external when the instance was created" do
+ @io = new_io @name, @object
+ Encoding.default_external = Encoding::UTF_8
+ @io.external_encoding.should equal(Encoding::IBM866)
+ end
it "returns the external encoding specified when the instance was created" do
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, "#{@object}:ibm866"
Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::UTF_8)
+ @io.external_encoding.should equal(Encoding::IBM866)
end
it "returns the encoding set by #set_encoding" do
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, "#{@object}:ibm866"
@io.set_encoding Encoding::EUC_JP, nil
@io.external_encoding.should equal(Encoding::EUC_JP)
end
end
end
- describe "with 'rb' mode" do
- it "returns Encoding::BINARY" do
- @io = new_io @name, "rb"
- @io.external_encoding.should equal(Encoding::BINARY)
- end
+ describe "IO#external_encoding" do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
+
+ @name = tmp("io_external_encoding")
+ touch(@name)
+ end
+
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+
+ @io.close if @io
+ rm_r @name
+ end
+
+ describe "with 'r' mode" do
+ describe "when Encoding.default_internal is nil" do
+ before :each do
+ Encoding.default_internal = nil
+ Encoding.default_external = Encoding::IBM866
+ end
+
+ it "returns Encoding.default_external if the external encoding is not set" do
+ @io = new_io @name, "r"
+ @io.external_encoding.should equal(Encoding::IBM866)
+ end
+
+ it "returns Encoding.default_external when that encoding is changed after the instance is created" do
+ @io = new_io @name, "r"
+ Encoding.default_external = Encoding::IBM437
+ @io.external_encoding.should equal(Encoding::IBM437)
+ end
+
+ it "returns the external encoding specified when the instance was created" do
+ @io = new_io @name, "r:utf-8"
+ Encoding.default_external = Encoding::IBM437
+ @io.external_encoding.should equal(Encoding::UTF_8)
+ end
+
+ it "returns the encoding set by #set_encoding" do
+ @io = new_io @name, "r:utf-8"
+ @io.set_encoding Encoding::EUC_JP, nil
+ @io.external_encoding.should equal(Encoding::EUC_JP)
+ end
+ end
+
+ describe "when Encoding.default_external == Encoding.default_internal" do
+ before :each do
+ Encoding.default_external = Encoding::IBM866
+ Encoding.default_internal = Encoding::IBM866
+ end
+
+ it "returns the value of Encoding.default_external when the instance was created" do
+ @io = new_io @name, "r"
+ Encoding.default_external = Encoding::IBM437
+ @io.external_encoding.should equal(Encoding::IBM866)
+ end
+
+ it "returns the external encoding specified when the instance was created" do
+ @io = new_io @name, "r:utf-8"
+ Encoding.default_external = Encoding::IBM437
+ @io.external_encoding.should equal(Encoding::UTF_8)
+ end
+
+ it "returns the encoding set by #set_encoding" do
+ @io = new_io @name, "r:utf-8"
+ @io.set_encoding Encoding::EUC_JP, nil
+ @io.external_encoding.should equal(Encoding::EUC_JP)
+ end
+ end
+
+ describe "when Encoding.default_external != Encoding.default_internal" do
+ before :each do
+ Encoding.default_external = Encoding::IBM437
+ Encoding.default_internal = Encoding::IBM866
+ end
+
- it "returns the external encoding specified by the mode argument" do
- @io = new_io @name, "rb:ibm437"
- @io.external_encoding.should equal(Encoding::IBM437)
+ it "returns the external encoding specified when the instance was created" do
+ @io = new_io @name, "r:utf-8"
+ Encoding.default_external = Encoding::IBM437
+ @io.external_encoding.should equal(Encoding::UTF_8)
+ end
+
+ it "returns the encoding set by #set_encoding" do
+ @io = new_io @name, "r:utf-8"
+ @io.set_encoding Encoding::EUC_JP, nil
+ @io.external_encoding.should equal(Encoding::EUC_JP)
+ end
+ end
end
- end
- describe "with 'r+' mode" do
- it_behaves_like :io_external_encoding_write, nil, "r+"
- end
+ describe "with 'rb' mode" do
+ it "returns Encoding::ASCII_8BIT" do
+ @io = new_io @name, "rb"
+ @io.external_encoding.should equal(Encoding::ASCII_8BIT)
+ end
- describe "with 'w' mode" do
- it_behaves_like :io_external_encoding_write, nil, "w"
- end
+ it "returns the external encoding specified by the mode argument" do
+ @io = new_io @name, "rb:ibm437"
+ @io.external_encoding.should equal(Encoding::IBM437)
+ end
+ end
- describe "with 'wb' mode" do
- it "returns Encoding::BINARY" do
- @io = new_io @name, "wb"
- @io.external_encoding.should equal(Encoding::BINARY)
+ describe "with 'r+' mode" do
+ it_behaves_like :io_external_encoding_write, nil, "r+"
end
- it "returns the external encoding specified by the mode argument" do
- @io = new_io @name, "wb:ibm437"
- @io.external_encoding.should equal(Encoding::IBM437)
+ describe "with 'w' mode" do
+ it_behaves_like :io_external_encoding_write, nil, "w"
end
- end
- describe "with 'w+' mode" do
- it_behaves_like :io_external_encoding_write, nil, "w+"
- end
+ describe "with 'wb' mode" do
+ it "returns Encoding::ASCII_8BIT" do
+ @io = new_io @name, "wb"
+ @io.external_encoding.should equal(Encoding::ASCII_8BIT)
+ end
- describe "with 'a' mode" do
- it_behaves_like :io_external_encoding_write, nil, "a"
- end
+ it "returns the external encoding specified by the mode argument" do
+ @io = new_io @name, "wb:ibm437"
+ @io.external_encoding.should equal(Encoding::IBM437)
+ end
+ end
- describe "with 'a+' mode" do
- it_behaves_like :io_external_encoding_write, nil, "a+"
+ describe "with 'w+' mode" do
+ it_behaves_like :io_external_encoding_write, nil, "w+"
+ end
+
+ describe "with 'a' mode" do
+ it_behaves_like :io_external_encoding_write, nil, "a"
+ end
+
+ describe "with 'a+' mode" do
+ it_behaves_like :io_external_encoding_write, nil, "a+"
+ end
end
end
diff --git a/spec/ruby/core/io/fcntl_spec.rb b/spec/ruby/core/io/fcntl_spec.rb
index 30b4876fe3..0e20f50f60 100644
--- a/spec/ruby/core/io/fcntl_spec.rb
+++ b/spec/ruby/core/io/fcntl_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#fcntl" do
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.fcntl(5, 5) }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.fcntl(5, 5) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/fdatasync_spec.rb b/spec/ruby/core/io/fdatasync_spec.rb
index 6242258ea0..9bcbbda336 100644
--- a/spec/ruby/core/io/fdatasync_spec.rb
+++ b/spec/ruby/core/io/fdatasync_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO#fdatasync" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/io/fileno_spec.rb b/spec/ruby/core/io/fileno_spec.rb
index 647609bf42..259ac38073 100644
--- a/spec/ruby/core/io/fileno_spec.rb
+++ b/spec/ruby/core/io/fileno_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#fileno" do
it "returns the numeric file descriptor of the given IO object" do
@@ -7,6 +7,6 @@ describe "IO#fileno" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.fileno }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.fileno }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/fixtures/classes.rb b/spec/ruby/core/io/fixtures/classes.rb
index 460dd62387..a771e3d929 100644
--- a/spec/ruby/core/io/fixtures/classes.rb
+++ b/spec/ruby/core/io/fixtures/classes.rb
@@ -118,10 +118,10 @@ module IOSpecs
# Creates an IO instance for an existing fixture file. The
# file should obviously not be deleted.
- def self.io_fixture(name, mode = "r:utf-8")
+ def self.io_fixture(name, options_or_mode="r:utf-8")
path = fixture __FILE__, name
name = path if File.exist? path
- new_io(name, mode)
+ new_io name, options_or_mode
end
# Returns a closed instance of IO that was opened to reference
diff --git a/spec/ruby/core/io/flush_spec.rb b/spec/ruby/core/io/flush_spec.rb
index 34cf42c425..c877650ecd 100644
--- a/spec/ruby/core/io/flush_spec.rb
+++ b/spec/ruby/core/io/flush_spec.rb
@@ -1,37 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#flush" do
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.flush }.should raise_error(IOError)
- end
-
- describe "on a pipe" do
- before :each do
- @r, @w = IO.pipe
- end
-
- after :each do
- @r.close
- begin
- @w.close
- rescue Errno::EPIPE
- end
- end
-
- # [ruby-core:90895] MJIT worker may leave fd open in a forked child.
- # For instance, MJIT creates a worker before @r.close with fork(), @r.close happens,
- # and the MJIT worker keeps the pipe open until the worker execve().
- # TODO: consider acquiring GVL from MJIT worker.
- guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do
- it "raises Errno::EPIPE if sync=false and the read end is closed" do
- @w.sync = false
- @w.write "foo"
- @r.close
-
- -> { @w.flush }.should raise_error(Errno::EPIPE, /Broken pipe/)
- -> { @w.close }.should raise_error(Errno::EPIPE, /Broken pipe/)
- end
- end
+ lambda { IOSpecs.closed_io.flush }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/for_fd_spec.rb b/spec/ruby/core/io/for_fd_spec.rb
index 2d86361b73..b4abc1f87c 100644
--- a/spec/ruby/core/io/for_fd_spec.rb
+++ b/spec/ruby/core/io/for_fd_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/new'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "IO.for_fd" do
it_behaves_like :io_new, :for_fd
diff --git a/spec/ruby/core/io/foreach_spec.rb b/spec/ruby/core/io/foreach_spec.rb
index c2276cf544..f5fa1459e9 100644
--- a/spec/ruby/core/io/foreach_spec.rb
+++ b/spec/ruby/core/io/foreach_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/readlines'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/readlines', __FILE__)
describe "IO.foreach" do
before :each do
@@ -24,7 +24,7 @@ describe "IO.foreach" do
ScratchPad.recorded.should == ["hello\n", "line2\n"]
end
- platform_is_not :windows do
+ with_feature :fork do
it "gets data from a fork when passed -" do
parent_pid = $$
diff --git a/spec/ruby/core/io/fsync_spec.rb b/spec/ruby/core/io/fsync_spec.rb
index 6e6123de94..7816ecc42b 100644
--- a/spec/ruby/core/io/fsync_spec.rb
+++ b/spec/ruby/core/io/fsync_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#fsync" do
before :each do
@@ -12,7 +12,7 @@ describe "IO#fsync" do
end
it "raises an IOError on closed stream" do
- -> { IOSpecs.closed_io.fsync }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.fsync }.should raise_error(IOError)
end
it "writes the buffered data to permanent storage" do
diff --git a/spec/ruby/core/io/getbyte_spec.rb b/spec/ruby/core/io/getbyte_spec.rb
index 6ba8f0a3e0..cb8929890f 100644
--- a/spec/ruby/core/io/getbyte_spec.rb
+++ b/spec/ruby/core/io/getbyte_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#getbyte" do
before :each do
@@ -23,7 +23,7 @@ describe "IO#getbyte" do
end
it "raises an IOError on closed stream" do
- -> { IOSpecs.closed_io.getbyte }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.getbyte }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/getc_spec.rb b/spec/ruby/core/io/getc_spec.rb
index 3949b5cb28..dfff1a9583 100644
--- a/spec/ruby/core/io/getc_spec.rb
+++ b/spec/ruby/core/io/getc_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#getc" do
before :each do
@@ -23,7 +23,7 @@ describe "IO#getc" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.getc }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.getc }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/gets_spec.rb b/spec/ruby/core/io/gets_spec.rb
index 39b2108476..6e0518b512 100644
--- a/spec/ruby/core/io/gets_spec.rb
+++ b/spec/ruby/core/io/gets_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/gets_ascii'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/gets_ascii', __FILE__)
describe "IO#gets" do
it_behaves_like :io_gets_ascii, :gets
@@ -30,7 +30,7 @@ describe "IO#gets" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.gets }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.gets }.should raise_error(IOError)
end
describe "with no separator" do
@@ -38,11 +38,9 @@ describe "IO#gets" do
IOSpecs.lines.each { |line| line.should == @io.gets }
end
- ruby_version_is ''...'2.7' do
- it "returns tainted strings" do
- while line = @io.gets
- line.tainted?.should == true
- end
+ it "returns tainted strings" do
+ while line = @io.gets
+ line.tainted?.should == true
end
end
@@ -64,11 +62,9 @@ describe "IO#gets" do
@io.gets(nil).should == IOSpecs.lines.join("")
end
- ruby_version_is ''...'2.7' do
- it "returns tainted strings" do
- while line = @io.gets(nil)
- line.tainted?.should == true
- end
+ it "returns tainted strings" do
+ while line = @io.gets(nil)
+ line.tainted?.should == true
end
end
@@ -100,11 +96,9 @@ describe "IO#gets" do
@io.gets.should == IOSpecs.lines[4]
end
- ruby_version_is ''...'2.7' do
- it "returns tainted strings" do
- while line = @io.gets("")
- line.tainted?.should == true
- end
+ it "returns tainted strings" do
+ while line = @io.gets("")
+ line.tainted?.should == true
end
end
@@ -126,11 +120,9 @@ describe "IO#gets" do
@io.gets("la linea").should == "Voici la ligne une.\nQui \303\250 la linea"
end
- ruby_version_is ''...'2.7' do
- it "returns tainted strings" do
- while line = @io.gets("la")
- line.tainted?.should == true
- end
+ it "returns tainted strings" do
+ while line = @io.gets("la")
+ line.tainted?.should == true
end
end
@@ -147,9 +139,11 @@ describe "IO#gets" do
end
end
- describe "when passed chomp" do
- it "returns the first line without a trailing newline character" do
- @io.gets(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
+ ruby_version_is "2.4" do
+ describe "when passed chomp" do
+ it "returns the first line without a trailing newline character" do
+ @io.gets(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
+ end
end
end
end
@@ -164,11 +158,11 @@ describe "IO#gets" do
end
it "raises an IOError if the stream is opened for append only" do
- -> { File.open(@name, "a:utf-8") { |f| f.gets } }.should raise_error(IOError)
+ lambda { File.open(@name, fmode("a:utf-8")) { |f| f.gets } }.should raise_error(IOError)
end
it "raises an IOError if the stream is opened for writing only" do
- -> { File.open(@name, "w:utf-8") { |f| f.gets } }.should raise_error(IOError)
+ lambda { File.open(@name, fmode("w:utf-8")) { |f| f.gets } }.should raise_error(IOError)
end
end
@@ -176,7 +170,7 @@ describe "IO#gets" do
before :each do
@name = tmp("io_gets")
touch(@name) { |f| f.write "one\n\ntwo\n\nthree\nfour\n" }
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, fmode("r:utf-8")
end
after :each do
@@ -240,7 +234,7 @@ describe "IO#gets" do
# create data "æœæ—¥" + "\xE3\x81" * 100 to avoid utf-8 conflicts
data = "æœæ—¥" + ([227,129].pack('C*') * 100).force_encoding('utf-8')
touch(@name) { |f| f.write data }
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, fmode("r:utf-8")
end
after :each do
@@ -303,25 +297,25 @@ describe "IO#gets" do
end
it "overwrites the default external encoding with the IO object's own external encoding" do
- Encoding.default_external = Encoding::BINARY
+ Encoding.default_external = Encoding::ASCII_8BIT
Encoding.default_internal = Encoding::UTF_8
@io = new_io @name, 'r'
@io.set_encoding Encoding::IBM866
@io.gets.encoding.should == Encoding::UTF_8
end
- it "ignores the internal encoding if the default external encoding is BINARY" do
- Encoding.default_external = Encoding::BINARY
+ it "ignores the internal encoding if the default external encoding is ASCII-8BIT" do
+ Encoding.default_external = Encoding::ASCII_8BIT
Encoding.default_internal = Encoding::UTF_8
@io = new_io @name, 'r'
- @io.gets.encoding.should == Encoding::BINARY
+ @io.gets.encoding.should == Encoding::ASCII_8BIT
end
- it "transcodes to internal encoding if the IO object's external encoding is BINARY" do
- Encoding.default_external = Encoding::BINARY
+ it "transcodes to internal encoding if the IO object's external encoding is ASCII-8BIT" do
+ Encoding.default_external = Encoding::ASCII_8BIT
Encoding.default_internal = Encoding::UTF_8
@io = new_io @name, 'r'
- @io.set_encoding Encoding::BINARY, Encoding::UTF_8
+ @io.set_encoding Encoding::ASCII_8BIT, Encoding::UTF_8
@io.gets.encoding.should == Encoding::UTF_8
end
end
diff --git a/spec/ruby/core/io/initialize_spec.rb b/spec/ruby/core/io/initialize_spec.rb
index c0d84765a8..4731257625 100644
--- a/spec/ruby/core/io/initialize_spec.rb
+++ b/spec/ruby/core/io/initialize_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#initialize" do
before :each do
@name = tmp("io_initialize.txt")
- @io = IO.new(new_fd(@name))
+ @io = new_io @name
@fd = @io.fileno
end
@@ -17,6 +17,8 @@ describe "IO#initialize" do
fd = new_fd @name, "r:utf-8"
@io.send :initialize, fd, 'r'
@io.fileno.should == fd
+ # initialize has closed the old descriptor
+ lambda { IO.for_fd(@fd).close }.should raise_error(Errno::EBADF)
end
it "calls #to_int to coerce the object passed as an fd" do
@@ -25,25 +27,27 @@ describe "IO#initialize" do
obj.should_receive(:to_int).and_return(fd)
@io.send :initialize, obj, 'r'
@io.fileno.should == fd
+ # initialize has closed the old descriptor
+ lambda { IO.for_fd(@fd).close }.should raise_error(Errno::EBADF)
end
it "raises a TypeError when passed an IO" do
- -> { @io.send :initialize, STDOUT, 'w' }.should raise_error(TypeError)
+ lambda { @io.send :initialize, STDOUT, 'w' }.should raise_error(TypeError)
end
it "raises a TypeError when passed nil" do
- -> { @io.send :initialize, nil, 'w' }.should raise_error(TypeError)
+ lambda { @io.send :initialize, nil, 'w' }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- -> { @io.send :initialize, "4", 'w' }.should raise_error(TypeError)
+ lambda { @io.send :initialize, "4", 'w' }.should raise_error(TypeError)
end
it "raises IOError on closed stream" do
- -> { @io.send :initialize, IOSpecs.closed_io.fileno }.should raise_error(IOError)
+ lambda { @io.send :initialize, IOSpecs.closed_io.fileno }.should raise_error(IOError)
end
it "raises an Errno::EBADF when given an invalid file descriptor" do
- -> { @io.send :initialize, -1, 'w' }.should raise_error(Errno::EBADF)
+ lambda { @io.send :initialize, -1, 'w' }.should raise_error(Errno::EBADF)
end
end
diff --git a/spec/ruby/core/io/inspect_spec.rb b/spec/ruby/core/io/inspect_spec.rb
index c653c307c4..1c6bf99b44 100644
--- a/spec/ruby/core/io/inspect_spec.rb
+++ b/spec/ruby/core/io/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO#inspect" do
after :each do
diff --git a/spec/ruby/core/io/internal_encoding_spec.rb b/spec/ruby/core/io/internal_encoding_spec.rb
index 10ebf28707..7578559838 100644
--- a/spec/ruby/core/io/internal_encoding_spec.rb
+++ b/spec/ruby/core/io/internal_encoding_spec.rb
@@ -1,138 +1,140 @@
-require_relative '../../spec_helper'
-
-describe :io_internal_encoding, shared: true do
- describe "when Encoding.default_internal is not set" do
- before :each do
- Encoding.default_internal = nil
- end
-
- it "returns nil if the internal encoding is not set" do
- @io = new_io @name, @object
- @io.internal_encoding.should be_nil
- end
-
- it "returns nil if Encoding.default_internal is changed after the instance is created" do
- @io = new_io @name, @object
- Encoding.default_internal = Encoding::IBM437
- @io.internal_encoding.should be_nil
- end
-
- it "returns the value set when the instance was created" do
- @io = new_io @name, "#{@object}:utf-8:euc-jp"
- Encoding.default_internal = Encoding::IBM437
- @io.internal_encoding.should equal(Encoding::EUC_JP)
- end
-
- it "returns the value set by #set_encoding" do
- @io = new_io @name, @object
- @io.set_encoding(Encoding::US_ASCII, Encoding::IBM437)
- @io.internal_encoding.should equal(Encoding::IBM437)
+require File.expand_path('../../../spec_helper', __FILE__)
+
+with_feature :encoding do
+ describe :io_internal_encoding, shared: true do
+ describe "when Encoding.default_internal is not set" do
+ before :each do
+ Encoding.default_internal = nil
+ end
+
+ it "returns nil if the internal encoding is not set" do
+ @io = new_io @name, @object
+ @io.internal_encoding.should be_nil
+ end
+
+ it "returns nil if Encoding.default_internal is changed after the instance is created" do
+ @io = new_io @name, @object
+ Encoding.default_internal = Encoding::IBM437
+ @io.internal_encoding.should be_nil
+ end
+
+ it "returns the value set when the instance was created" do
+ @io = new_io @name, "#{@object}:utf-8:euc-jp"
+ Encoding.default_internal = Encoding::IBM437
+ @io.internal_encoding.should equal(Encoding::EUC_JP)
+ end
+
+ it "returns the value set by #set_encoding" do
+ @io = new_io @name, @object
+ @io.set_encoding(Encoding::US_ASCII, Encoding::IBM437)
+ @io.internal_encoding.should equal(Encoding::IBM437)
+ end
+ end
+
+ describe "when Encoding.default_internal == Encoding.default_external" do
+ before :each do
+ Encoding.default_external = Encoding::IBM866
+ Encoding.default_internal = Encoding::IBM866
+ end
+
+ it "returns nil" do
+ @io = new_io @name, @object
+ @io.internal_encoding.should be_nil
+ end
+
+ it "returns nil regardless of Encoding.default_internal changes" do
+ @io = new_io @name, @object
+ Encoding.default_internal = Encoding::IBM437
+ @io.internal_encoding.should be_nil
+ end
+ end
+
+ describe "when Encoding.default_internal != Encoding.default_external" do
+ before :each do
+ Encoding.default_external = Encoding::IBM437
+ Encoding.default_internal = Encoding::IBM866
+ end
+
+ it "returns the value of Encoding.default_internal when the instance was created if the internal encoding is not set" do
+ @io = new_io @name, @object
+ @io.internal_encoding.should equal(Encoding::IBM866)
+ end
+
+ it "does not change when Encoding.default_internal is changed" do
+ @io = new_io @name, @object
+ Encoding.default_internal = Encoding::IBM437
+ @io.internal_encoding.should equal(Encoding::IBM866)
+ end
+
+ it "returns the internal encoding set when the instance was created" do
+ @io = new_io @name, "#{@object}:utf-8:euc-jp"
+ @io.internal_encoding.should equal(Encoding::EUC_JP)
+ end
+
+ it "does not change when set and Encoding.default_internal is changed" do
+ @io = new_io @name, "#{@object}:utf-8:euc-jp"
+ Encoding.default_internal = Encoding::IBM437
+ @io.internal_encoding.should equal(Encoding::EUC_JP)
+ end
+
+ it "returns the value set by #set_encoding" do
+ @io = new_io @name, @object
+ @io.set_encoding(Encoding::US_ASCII, Encoding::IBM437)
+ @io.internal_encoding.should equal(Encoding::IBM437)
+ end
+
+ it "returns nil when Encoding.default_external is ASCII-8BIT and the internal encoding is not set" do
+ Encoding.default_external = Encoding::ASCII_8BIT
+ @io = new_io @name, @object
+ @io.internal_encoding.should be_nil
+ end
+
+ it "returns nil when the external encoding is ASCII-8BIT and the internal encoding is not set" do
+ @io = new_io @name, "#{@object}:ascii-8bit"
+ @io.internal_encoding.should be_nil
+ end
end
end
- describe "when Encoding.default_internal == Encoding.default_external" do
+ describe "IO#internal_encoding" do
before :each do
- Encoding.default_external = Encoding::IBM866
- Encoding.default_internal = Encoding::IBM866
- end
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- it "returns nil" do
- @io = new_io @name, @object
- @io.internal_encoding.should be_nil
+ @name = tmp("io_internal_encoding")
+ touch(@name)
end
- it "returns nil regardless of Encoding.default_internal changes" do
- @io = new_io @name, @object
- Encoding.default_internal = Encoding::IBM437
- @io.internal_encoding.should be_nil
- end
- end
+ after :each do
+ @io.close if @io
+ rm_r @name
- describe "when Encoding.default_internal != Encoding.default_external" do
- before :each do
- Encoding.default_external = Encoding::IBM437
- Encoding.default_internal = Encoding::IBM866
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
end
- it "returns the value of Encoding.default_internal when the instance was created if the internal encoding is not set" do
- @io = new_io @name, @object
- @io.internal_encoding.should equal(Encoding::IBM866)
+ describe "with 'r' mode" do
+ it_behaves_like :io_internal_encoding, nil, "r"
end
- it "does not change when Encoding.default_internal is changed" do
- @io = new_io @name, @object
- Encoding.default_internal = Encoding::IBM437
- @io.internal_encoding.should equal(Encoding::IBM866)
+ describe "with 'r+' mode" do
+ it_behaves_like :io_internal_encoding, nil, "r+"
end
- it "returns the internal encoding set when the instance was created" do
- @io = new_io @name, "#{@object}:utf-8:euc-jp"
- @io.internal_encoding.should equal(Encoding::EUC_JP)
+ describe "with 'w' mode" do
+ it_behaves_like :io_internal_encoding, nil, "w"
end
- it "does not change when set and Encoding.default_internal is changed" do
- @io = new_io @name, "#{@object}:utf-8:euc-jp"
- Encoding.default_internal = Encoding::IBM437
- @io.internal_encoding.should equal(Encoding::EUC_JP)
+ describe "with 'w+' mode" do
+ it_behaves_like :io_internal_encoding, nil, "w+"
end
- it "returns the value set by #set_encoding" do
- @io = new_io @name, @object
- @io.set_encoding(Encoding::US_ASCII, Encoding::IBM437)
- @io.internal_encoding.should equal(Encoding::IBM437)
+ describe "with 'a' mode" do
+ it_behaves_like :io_internal_encoding, nil, "a"
end
- it "returns nil when Encoding.default_external is BINARY and the internal encoding is not set" do
- Encoding.default_external = Encoding::BINARY
- @io = new_io @name, @object
- @io.internal_encoding.should be_nil
+ describe "with 'a+' mode" do
+ it_behaves_like :io_internal_encoding, nil, "a+"
end
-
- it "returns nil when the external encoding is BINARY and the internal encoding is not set" do
- @io = new_io @name, "#{@object}:binary"
- @io.internal_encoding.should be_nil
- end
- end
-end
-
-describe "IO#internal_encoding" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
-
- @name = tmp("io_internal_encoding")
- touch(@name)
- end
-
- after :each do
- @io.close if @io
- rm_r @name
-
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
-
- describe "with 'r' mode" do
- it_behaves_like :io_internal_encoding, nil, "r"
- end
-
- describe "with 'r+' mode" do
- it_behaves_like :io_internal_encoding, nil, "r+"
- end
-
- describe "with 'w' mode" do
- it_behaves_like :io_internal_encoding, nil, "w"
- end
-
- describe "with 'w+' mode" do
- it_behaves_like :io_internal_encoding, nil, "w+"
- end
-
- describe "with 'a' mode" do
- it_behaves_like :io_internal_encoding, nil, "a"
- end
-
- describe "with 'a+' mode" do
- it_behaves_like :io_internal_encoding, nil, "a+"
end
end
diff --git a/spec/ruby/core/io/io_spec.rb b/spec/ruby/core/io/io_spec.rb
index 0feb1a8774..e196628ef0 100644
--- a/spec/ruby/core/io/io_spec.rb
+++ b/spec/ruby/core/io/io_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO" do
it "includes File::Constants" do
diff --git a/spec/ruby/core/io/ioctl_spec.rb b/spec/ruby/core/io/ioctl_spec.rb
index e819a217a8..3b2d271c0c 100644
--- a/spec/ruby/core/io/ioctl_spec.rb
+++ b/spec/ruby/core/io/ioctl_spec.rb
@@ -1,15 +1,15 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#ioctl" do
platform_is_not :windows do
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.ioctl(5, 5) }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.ioctl(5, 5) }.should raise_error(IOError)
end
end
platform_is :linux do
- guard -> { RUBY_PLATFORM.include?("86") } do # x86 / x86_64
+ platform_is "86" do # x86 / x86_64
it "resizes an empty String to match the output size" do
File.open(__FILE__, 'r') do |f|
buffer = ''
@@ -22,7 +22,7 @@ describe "IO#ioctl" do
it "raises an Errno error when ioctl fails" do
File.open(__FILE__, 'r') do |f|
- -> {
+ lambda {
# TIOCGWINSZ in /usr/include/asm-generic/ioctls.h
f.ioctl 0x5413, nil
}.should raise_error(Errno::ENOTTY)
diff --git a/spec/ruby/core/io/isatty_spec.rb b/spec/ruby/core/io/isatty_spec.rb
index 3b6c69b190..87172dddd7 100644
--- a/spec/ruby/core/io/isatty_spec.rb
+++ b/spec/ruby/core/io/isatty_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/tty'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/tty', __FILE__)
describe "IO#isatty" do
it_behaves_like :io_tty, :isatty
diff --git a/spec/ruby/core/io/lineno_spec.rb b/spec/ruby/core/io/lineno_spec.rb
index 3d1b2275cc..4fddbf135c 100644
--- a/spec/ruby/core/io/lineno_spec.rb
+++ b/spec/ruby/core/io/lineno_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#lineno" do
before :each do
@@ -11,7 +11,7 @@ describe "IO#lineno" do
end
it "raises an IOError on a closed stream" do
- -> { IOSpecs.closed_io.lineno }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.lineno }.should raise_error(IOError)
end
it "returns the current line number" do
@@ -37,7 +37,7 @@ describe "IO#lineno=" do
end
it "raises an IOError on a closed stream" do
- -> { IOSpecs.closed_io.lineno = 5 }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.lineno = 5 }.should raise_error(IOError)
end
it "calls #to_int on a non-numeric argument" do
@@ -57,7 +57,7 @@ describe "IO#lineno=" do
end
it "raises TypeError on nil argument" do
- -> { @io.lineno = nil }.should raise_error(TypeError)
+ lambda { @io.lineno = nil }.should raise_error(TypeError)
end
it "sets the current line number to the given value" do
diff --git a/spec/ruby/core/io/lines_spec.rb b/spec/ruby/core/io/lines_spec.rb
index a8b8023a2a..90ddc4e4cf 100644
--- a/spec/ruby/core/io/lines_spec.rb
+++ b/spec/ruby/core/io/lines_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#lines" do
before :each do
diff --git a/spec/ruby/core/io/new_spec.rb b/spec/ruby/core/io/new_spec.rb
index 3597098caf..ce922a4856 100644
--- a/spec/ruby/core/io/new_spec.rb
+++ b/spec/ruby/core/io/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/new'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "IO.new" do
it_behaves_like :io_new, :new
diff --git a/spec/ruby/core/io/open_spec.rb b/spec/ruby/core/io/open_spec.rb
index 94df5a5ef6..f87ee6c7c2 100644
--- a/spec/ruby/core/io/open_spec.rb
+++ b/spec/ruby/core/io/open_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/new'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "IO.open" do
it_behaves_like :io_new, :open
@@ -38,7 +38,7 @@ describe "IO.open" do
end
it "propagates an exception raised by #close that is not a StandardError" do
- -> do
+ lambda do
IO.open(@fd, "w") do |io|
IOSpecs.io_mock(io, :close) do
super()
@@ -51,7 +51,7 @@ describe "IO.open" do
end
it "propagates an exception raised by #close that is a StandardError" do
- -> do
+ lambda do
IO.open(@fd, "w") do |io|
IOSpecs.io_mock(io, :close) do
super()
diff --git a/spec/ruby/core/io/output_spec.rb b/spec/ruby/core/io/output_spec.rb
index 2aafb305f4..2d52315430 100644
--- a/spec/ruby/core/io/output_spec.rb
+++ b/spec/ruby/core/io/output_spec.rb
@@ -1,26 +1,26 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#<<" do
it "writes an object to the IO stream" do
- -> {
+ lambda {
$stderr << "Oh noes, an error!"
}.should output_to_fd("Oh noes, an error!", $stderr)
end
it "calls #to_s on the object to print it" do
- -> {
+ lambda {
$stderr << 1337
}.should output_to_fd("1337", $stderr)
end
it "raises an error if the stream is closed" do
io = IOSpecs.closed_io
- -> { io << "test" }.should raise_error(IOError)
+ lambda { io << "test" }.should raise_error(IOError)
end
it "returns self" do
- -> {
+ lambda {
($stderr << "to_stderr").should == $stderr
}.should output(nil, "to_stderr")
end
diff --git a/spec/ruby/core/io/pid_spec.rb b/spec/ruby/core/io/pid_spec.rb
index bc09fe7c3b..a4f6bbfcf8 100644
--- a/spec/ruby/core/io/pid_spec.rb
+++ b/spec/ruby/core/io/pid_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "IO#pid" do
before :each do
@@ -30,6 +30,6 @@ describe "IO#pid" do
it "raises an IOError on closed stream" do
@io.close
- -> { @io.pid }.should raise_error(IOError)
+ lambda { @io.pid }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/pipe_spec.rb b/spec/ruby/core/io/pipe_spec.rb
index a7dcb7fab8..b4984fdeb7 100644
--- a/spec/ruby/core/io/pipe_spec.rb
+++ b/spec/ruby/core/io/pipe_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO.pipe" do
after :each do
@@ -50,7 +50,7 @@ describe "IO.pipe" do
it "closes both IO objects when the block raises" do
r = w = nil
- -> do
+ lambda do
IO.pipe do |_r, _w|
r = _r
w = _w
@@ -179,7 +179,7 @@ describe "IO.pipe" do
it "calls #to_hash to convert an options argument" do
options = mock("io pipe encoding options")
options.should_receive(:to_hash).and_return({ invalid: :replace })
- IO.pipe("UTF-8", "ISO-8859-1", **options) { |r, w| }
+ IO.pipe("UTF-8", "ISO-8859-1", options) { |r, w| }
end
it "calls #to_str to convert the first argument to a String" do
diff --git a/spec/ruby/core/io/popen_spec.rb b/spec/ruby/core/io/popen_spec.rb
index 4f873e61cd..808dff7260 100644
--- a/spec/ruby/core/io/popen_spec.rb
+++ b/spec/ruby/core/io/popen_spec.rb
@@ -1,22 +1,13 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../process/fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO.popen" do
- ProcessSpecs.use_system_ruby(self)
-
before :each do
- @fname = tmp("IO_popen_spec")
@io = nil
- @var = "$FOO"
- platform_is :windows do
- @var = "%FOO%"
- end
end
after :each do
- @io.close if @io and !@io.closed?
- rm_r @fname
+ @io.close if @io
end
it "returns an open IO" do
@@ -25,15 +16,27 @@ describe "IO.popen" do
end
it "reads a read-only pipe" do
- @io = IO.popen('echo foo', "r")
+ @io = IO.popen(ruby_cmd('puts "foo"'), "r")
@io.read.should == "foo\n"
end
it "raises IOError when writing a read-only pipe" do
- @io = IO.popen('echo foo', "r")
- -> { @io.write('bar') }.should raise_error(IOError)
+ @io = IO.popen(ruby_cmd('puts "foo"'), "r")
+ lambda { @io.write('bar') }.should raise_error(IOError)
@io.read.should == "foo\n"
end
+end
+
+describe "IO.popen" do
+ before :each do
+ @fname = tmp("IO_popen_spec")
+ @io = nil
+ end
+
+ after :each do
+ @io.close if @io and !@io.closed?
+ rm_r @fname
+ end
it "sees an infinitely looping subprocess exit when read pipe is closed" do
io = IO.popen ruby_cmd('r = loop{puts "y"; 0} rescue 1; exit r'), 'r'
@@ -52,7 +55,7 @@ describe "IO.popen" do
it "raises IOError when reading a write-only pipe" do
@io = IO.popen(ruby_cmd('IO.copy_stream(STDIN,STDOUT)'), "w")
- -> { @io.read }.should raise_error(IOError)
+ lambda { @io.read }.should raise_error(IOError)
end
it "reads and writes a read/write pipe" do
@@ -94,6 +97,16 @@ describe "IO.popen" do
mode.should_receive(:to_str).and_return("r")
@io = IO.popen(ruby_cmd('exit 0'), mode)
end
+end
+
+describe "IO.popen" do
+ before :each do
+ @io = nil
+ end
+
+ after :each do
+ @io.close if @io
+ end
describe "with a block" do
it "yields an open IO to the block" do
@@ -123,7 +136,7 @@ describe "IO.popen" do
end
end
- platform_is_not :windows do
+ with_feature :fork do
it "starts returns a forked process if the command is -" do
io = IO.popen("-")
@@ -140,31 +153,33 @@ describe "IO.popen" do
end
end
- it "has the given external encoding" do
- @io = IO.popen(ruby_cmd('exit'), external_encoding: Encoding::EUC_JP)
- @io.external_encoding.should == Encoding::EUC_JP
- end
+ with_feature :encoding do
+ it "has the given external encoding" do
+ @io = IO.popen(ruby_cmd('exit'), external_encoding: Encoding::EUC_JP)
+ @io.external_encoding.should == Encoding::EUC_JP
+ end
- it "has the given internal encoding" do
- @io = IO.popen(ruby_cmd('exit'), internal_encoding: Encoding::EUC_JP)
- @io.internal_encoding.should == Encoding::EUC_JP
- end
+ it "has the given internal encoding" do
+ @io = IO.popen(ruby_cmd('exit'), internal_encoding: Encoding::EUC_JP)
+ @io.internal_encoding.should == Encoding::EUC_JP
+ end
- it "sets the internal encoding to nil if it's the same as the external encoding" do
- @io = IO.popen(ruby_cmd('exit'), external_encoding: Encoding::EUC_JP,
- internal_encoding: Encoding::EUC_JP)
- @io.internal_encoding.should be_nil
+ it "sets the internal encoding to nil if it's the same as the external encoding" do
+ @io = IO.popen(ruby_cmd('exit'), external_encoding: Encoding::EUC_JP,
+ internal_encoding: Encoding::EUC_JP)
+ @io.internal_encoding.should be_nil
+ end
end
context "with a leading ENV Hash" do
it "accepts a single String command" do
- IO.popen({"FOO" => "bar"}, "echo #{@var}") do |io|
+ IO.popen({"FOO" => "bar"}, ruby_cmd('puts ENV["FOO"]')) do |io|
io.read.should == "bar\n"
end
end
it "accepts a single String command, and an IO mode" do
- IO.popen({"FOO" => "bar"}, "echo #{@var}", "r") do |io|
+ IO.popen({"FOO" => "bar"}, ruby_cmd('puts ENV["FOO"]'), "r") do |io|
io.read.should == "bar\n"
end
end
diff --git a/spec/ruby/core/io/pos_spec.rb b/spec/ruby/core/io/pos_spec.rb
index e6cda2643d..300925a284 100644
--- a/spec/ruby/core/io/pos_spec.rb
+++ b/spec/ruby/core/io/pos_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "IO#pos" do
it_behaves_like :io_pos, :pos
@@ -9,3 +9,4 @@ end
describe "IO#pos=" do
it_behaves_like :io_set_pos, :pos=
end
+
diff --git a/spec/ruby/core/io/pread_spec.rb b/spec/ruby/core/io/pread_spec.rb
deleted file mode 100644
index bfe6472fef..0000000000
--- a/spec/ruby/core/io/pread_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-
-ruby_version_is "2.5" do
- platform_is_not :windows do
- describe "IO#pread" do
- before :each do
- @fname = tmp("io_pread.txt")
- @contents = "1234567890"
- touch(@fname) { |f| f.write @contents }
- @file = File.open(@fname, "r+")
- end
-
- after :each do
- @file.close
- rm_r @fname
- end
-
- it "accepts a length, and an offset" do
- @file.pread(4, 0).should == "1234"
- @file.pread(3, 4).should == "567"
- end
-
- it "accepts a length, an offset, and an output buffer" do
- buffer = "foo"
- @file.pread(3, 4, buffer)
- buffer.should == "567"
- end
-
- it "does not advance the file pointer" do
- @file.pread(4, 0).should == "1234"
- @file.read.should == "1234567890"
- end
-
- it "raises EOFError if end-of-file is reached" do
- -> { @file.pread(1, 10) }.should raise_error(EOFError)
- end
-
- it "raises IOError when file is not open in read mode" do
- File.open(@fname, "w") do |file|
- -> { file.pread(1, 1) }.should raise_error(IOError)
- end
- end
-
- it "raises IOError when file is closed" do
- file = File.open(@fname, "r+")
- file.close
- -> { file.pread(1, 1) }.should raise_error(IOError)
- end
- end
- end
-end
diff --git a/spec/ruby/core/io/print_spec.rb b/spec/ruby/core/io/print_spec.rb
index 2021cd5420..e852757385 100644
--- a/spec/ruby/core/io/print_spec.rb
+++ b/spec/ruby/core/io/print_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe IO, "#print" do
before :each do
@@ -48,6 +48,7 @@ describe IO, "#print" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.print("stuff") }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.print("stuff") }.should raise_error(IOError)
end
end
+
diff --git a/spec/ruby/core/io/printf_spec.rb b/spec/ruby/core/io/printf_spec.rb
index baa00f14ce..34be4c8e79 100644
--- a/spec/ruby/core/io/printf_spec.rb
+++ b/spec/ruby/core/io/printf_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#printf" do
before :each do
@@ -27,6 +27,6 @@ describe "IO#printf" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.printf("stuff") }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.printf("stuff") }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/putc_spec.rb b/spec/ruby/core/io/putc_spec.rb
index 73473ad821..9803d0c1a1 100644
--- a/spec/ruby/core/io/putc_spec.rb
+++ b/spec/ruby/core/io/putc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/io/putc'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/io/putc', __FILE__)
describe "IO#putc" do
before :each do
diff --git a/spec/ruby/core/io/puts_spec.rb b/spec/ruby/core/io/puts_spec.rb
index 3e4b877b7f..51240eed73 100644
--- a/spec/ruby/core/io/puts_spec.rb
+++ b/spec/ruby/core/io/puts_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#puts" do
before :each do
@@ -25,7 +25,7 @@ describe "IO#puts" do
end
it "writes just a newline when given just a newline" do
- -> { $stdout.puts "\n" }.should output_to_fd("\n", STDOUT)
+ lambda { $stdout.puts "\n" }.should output_to_fd("\n", STDOUT)
end
it "writes empty string with a newline when given nil as an arg" do
@@ -111,29 +111,31 @@ describe "IO#puts" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.puts("stuff") }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.puts("stuff") }.should raise_error(IOError)
end
- it "writes crlf when IO is opened with newline: :crlf" do
- File.open(@name, 'wt', newline: :crlf) do |file|
- file.puts
+ with_feature :encoding do
+ it "writes crlf when IO is opened with newline: :crlf" do
+ File.open(@name, 'wt', newline: :crlf) do |file|
+ file.puts
+ end
+ File.binread(@name).should == "\r\n"
end
- File.binread(@name).should == "\r\n"
- end
- it "writes cr when IO is opened with newline: :cr" do
- File.open(@name, 'wt', newline: :cr) do |file|
- file.puts
+ it "writes cr when IO is opened with newline: :cr" do
+ File.open(@name, 'wt', newline: :cr) do |file|
+ file.puts
+ end
+ File.binread(@name).should == "\r"
end
- File.binread(@name).should == "\r"
- end
- platform_is_not :windows do # https://bugs.ruby-lang.org/issues/12436
- it "writes lf when IO is opened with newline: :lf" do
- File.open(@name, 'wt', newline: :lf) do |file|
- file.puts
+ platform_is_not :windows do # https://bugs.ruby-lang.org/issues/12436
+ it "writes lf when IO is opened with newline: :lf" do
+ File.open(@name, 'wt', newline: :lf) do |file|
+ file.puts
+ end
+ File.binread(@name).should == "\n"
end
- File.binread(@name).should == "\n"
end
end
end
diff --git a/spec/ruby/core/io/pwrite_spec.rb b/spec/ruby/core/io/pwrite_spec.rb
deleted file mode 100644
index 929ed08698..0000000000
--- a/spec/ruby/core/io/pwrite_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-
-ruby_version_is "2.5" do
- platform_is_not :windows do
- describe "IO#pwrite" do
- before :each do
- @fname = tmp("io_pwrite.txt")
- @file = File.open(@fname, "w+")
- end
-
- after :each do
- @file.close
- rm_r @fname
- end
-
- it "returns the number of bytes written" do
- @file.pwrite("foo", 0).should == 3
- end
-
- it "accepts a string and an offset" do
- @file.pwrite("foo", 2)
- @file.pread(3, 2).should == "foo"
- end
-
- it "does not advance the pointer in the file" do
- @file.pwrite("bar", 3)
- @file.write("foo")
- @file.pread(6, 0).should == "foobar"
- end
-
- it "raises IOError when file is not open in write mode" do
- File.open(@fname, "r") do |file|
- -> { file.pwrite("foo", 1) }.should raise_error(IOError)
- end
- end
-
- it "raises IOError when file is closed" do
- file = File.open(@fname, "w+")
- file.close
- -> { file.pwrite("foo", 1) }.should raise_error(IOError)
- end
- end
- end
-end
diff --git a/spec/ruby/core/io/read_nonblock_spec.rb b/spec/ruby/core/io/read_nonblock_spec.rb
index 63ccab5a44..69ddc3848d 100644
--- a/spec/ruby/core/io/read_nonblock_spec.rb
+++ b/spec/ruby/core/io/read_nonblock_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#read_nonblock" do
before :each do
@@ -12,7 +12,7 @@ describe "IO#read_nonblock" do
end
it "raises an exception extending IO::WaitReadable when there is no data" do
- -> { @read.read_nonblock(5) }.should raise_error(IO::WaitReadable) { |e|
+ lambda { @read.read_nonblock(5) }.should raise_error(IO::WaitReadable) { |e|
platform_is_not :windows do
e.should be_kind_of(Errno::EAGAIN)
end
@@ -22,21 +22,23 @@ describe "IO#read_nonblock" do
}
end
- context "when exception option is set to false" do
- context "when there is no data" do
- it "returns :wait_readable" do
- @read.read_nonblock(5, exception: false).should == :wait_readable
+ ruby_version_is "2.3" do
+ context "when exception option is set to false" do
+ context "when there is no data" do
+ it "returns :wait_readable" do
+ @read.read_nonblock(5, exception: false).should == :wait_readable
+ end
end
- end
- context "when the end is reached" do
- it "returns nil" do
- @write << "hello"
- @write.close
+ context "when the end is reached" do
+ it "returns nil" do
+ @write << "hello"
+ @write.close
- @read.read_nonblock(5)
+ @read.read_nonblock(5)
- @read.read_nonblock(5, exception: false).should be_nil
+ @read.read_nonblock(5, exception: false).should be_nil
+ end
end
end
end
@@ -44,6 +46,7 @@ describe "IO#read_nonblock" do
platform_is_not :windows do
it 'sets the IO in nonblock mode' do
require 'io/nonblock'
+ @read.nonblock?.should == false
@write.write "abc"
@read.read_nonblock(1).should == "a"
@read.nonblock?.should == true
@@ -77,15 +80,8 @@ describe "IO#read_nonblock" do
buffer.should == "1"
end
- it "returns the passed buffer" do
- buffer = ""
- @write.write("1")
- output = @read.read_nonblock(1, buffer)
- output.should equal(buffer)
- end
-
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.read_nonblock(5) }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.read_nonblock(5) }.should raise_error(IOError)
end
it "raises EOFError when the end is reached" do
@@ -94,6 +90,6 @@ describe "IO#read_nonblock" do
@read.read_nonblock(5)
- -> { @read.read_nonblock(5) }.should raise_error(EOFError)
+ lambda { @read.read_nonblock(5) }.should raise_error(EOFError)
end
end
diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb
index 1e9a8d2a4f..223e3cde06 100644
--- a/spec/ruby/core/io/read_spec.rb
+++ b/spec/ruby/core/io/read_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO.read" do
before :each do
@@ -24,35 +24,31 @@ describe "IO.read" do
end
it "accepts an empty options Hash" do
- IO.read(@fname, **{}).should == @contents
- end
-
- it "accepts a length, and empty options Hash" do
- IO.read(@fname, 3, **{}).should == @contents[0, 3]
+ IO.read(@fname, {}).should == @contents
end
it "accepts a length, offset, and empty options Hash" do
- IO.read(@fname, 3, 0, **{}).should == @contents[0, 3]
+ IO.read(@fname, 3, 0, {}).should == @contents[0, 3]
end
it "raises an IOError if the options Hash specifies write mode" do
- -> { IO.read(@fname, 3, 0, mode: "w") }.should raise_error(IOError)
+ lambda { IO.read(@fname, 3, 0, {mode: "w"}) }.should raise_error(IOError)
end
it "raises an IOError if the options Hash specifies append only mode" do
- -> { IO.read(@fname, mode: "a") }.should raise_error(IOError)
+ lambda { IO.read(@fname, {mode: "a"}) }.should raise_error(IOError)
end
it "reads the file if the options Hash includes read mode" do
- IO.read(@fname, mode: "r").should == @contents
+ IO.read(@fname, {mode: "r"}).should == @contents
end
it "reads the file if the options Hash includes read/write mode" do
- IO.read(@fname, mode: "r+").should == @contents
+ IO.read(@fname, {mode: "r+"}).should == @contents
end
it "reads the file if the options Hash includes read/write append mode" do
- IO.read(@fname, mode: "a+").should == @contents
+ IO.read(@fname, {mode: "a+"}).should == @contents
end
it "treats second nil argument as no length limit" do
@@ -79,30 +75,32 @@ describe "IO.read" do
it "raises an Errno::ENOENT when the requested file does not exist" do
rm_r @fname
- -> { IO.read @fname }.should raise_error(Errno::ENOENT)
+ lambda { IO.read @fname }.should raise_error(Errno::ENOENT)
end
it "raises a TypeError when not passed a String type" do
- -> { IO.read nil }.should raise_error(TypeError)
+ lambda { IO.read nil }.should raise_error(TypeError)
end
it "raises an ArgumentError when not passed a valid length" do
- -> { IO.read @fname, -1 }.should raise_error(ArgumentError)
+ lambda { IO.read @fname, -1 }.should raise_error(ArgumentError)
end
it "raises an Errno::EINVAL when not passed a valid offset" do
- -> { IO.read @fname, 0, -1 }.should raise_error(Errno::EINVAL)
- -> { IO.read @fname, -1, -1 }.should raise_error(Errno::EINVAL)
+ lambda { IO.read @fname, 0, -1 }.should raise_error(Errno::EINVAL)
+ lambda { IO.read @fname, -1, -1 }.should raise_error(Errno::EINVAL)
end
- it "uses the external encoding specified via the :external_encoding option" do
- str = IO.read(@fname, external_encoding: Encoding::ISO_8859_1)
- str.encoding.should == Encoding::ISO_8859_1
- end
+ with_feature :encoding do
+ it "uses the external encoding specified via the :external_encoding option" do
+ str = IO.read(@fname, external_encoding: Encoding::ISO_8859_1)
+ str.encoding.should == Encoding::ISO_8859_1
+ end
- it "uses the external encoding specified via the :encoding option" do
- str = IO.read(@fname, encoding: Encoding::ISO_8859_1)
- str.encoding.should == Encoding::ISO_8859_1
+ it "uses the external encoding specified via the :encoding option" do
+ str = IO.read(@fname, encoding: Encoding::ISO_8859_1)
+ str.encoding.should == Encoding::ISO_8859_1
+ end
end
end
@@ -115,7 +113,7 @@ describe "IO.read from a pipe" do
IO.read(cmd).should == "hello\n"
end
- platform_is_not :windows do
+ with_feature :fork do
it "opens a pipe to a fork if the rest is -" do
str = IO.read("|-")
if str # parent
@@ -137,7 +135,7 @@ describe "IO.read from a pipe" do
platform_is_not :windows do
it "raises Errno::ESPIPE if passed an offset" do
- -> {
+ lambda {
IO.read("|sh -c 'echo hello'", 1, 1)
}.should raise_error(Errno::ESPIPE)
end
@@ -148,7 +146,7 @@ quarantine! do # The process tried to write to a nonexistent pipe.
# TODO: It should raise Errno::ESPIPE on Windows as well
# once https://bugs.ruby-lang.org/issues/12230 is fixed.
it "raises Errno::EINVAL if passed an offset" do
- -> {
+ lambda {
IO.read("|cmd.exe /C echo hello", 1, 1)
}.should raise_error(Errno::EINVAL)
end
@@ -259,7 +257,7 @@ describe "IO#read" do
it "returns the given buffer" do
buf = ""
- @io.read(nil, buf).should equal buf
+ @io.read(nil, buf).object_id.should == buf.object_id
end
it "coerces the second argument to string and uses it as a buffer" do
@@ -267,7 +265,7 @@ describe "IO#read" do
obj = mock("buff")
obj.should_receive(:to_str).any_number_of_times.and_return(buf)
- @io.read(15, obj).should_not equal obj
+ @io.read(15, obj).object_id.should_not == obj.object_id
buf.should == @contents
end
@@ -301,7 +299,7 @@ describe "IO#read" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.read }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.read }.should raise_error(IOError)
end
@@ -380,16 +378,16 @@ describe "IO#read in binary mode" do
result = File.open(@name, "rb") { |f| f.read }.chomp
- result.encoding.should == Encoding::BINARY
+ result.encoding.should == Encoding::ASCII_8BIT
xE2 = [226].pack('C*')
- result.should == ("abc" + xE2 + "def").force_encoding(Encoding::BINARY)
+ result.should == ("abc" + xE2 + "def").force_encoding(Encoding::ASCII_8BIT)
end
it "does not transcode file contents when an internal encoding is specified" do
result = File.open(@name, "r:binary:utf-8") { |f| f.read }.chomp
- result.encoding.should == Encoding::BINARY
+ result.encoding.should == Encoding::ASCII_8BIT
xE2 = [226].pack('C*')
- result.should == ("abc" + xE2 + "def").force_encoding(Encoding::BINARY)
+ result.should == ("abc" + xE2 + "def").force_encoding(Encoding::ASCII_8BIT)
end
end
@@ -420,167 +418,169 @@ describe "IO.read with BOM" do
it "reads a file without a bom" do
name = fixture __FILE__, "no_bom_UTF-8.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("binary").should == "UTF-8\n"
+ result.force_encoding("ascii-8bit").should == "UTF-8\n"
end
it "reads a file with a utf-8 bom" do
name = fixture __FILE__, "bom_UTF-8.txt"
result = File.read(name, mode: "rb:BOM|utf-16le")
- result.force_encoding("binary").should == "UTF-8\n"
+ result.force_encoding("ascii-8bit").should == "UTF-8\n"
end
it "reads a file with a utf-16le bom" do
name = fixture __FILE__, "bom_UTF-16LE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("binary").should == "U\x00T\x00F\x00-\x001\x006\x00L\x00E\x00\n\x00"
+ result.force_encoding("ascii-8bit").should == "U\x00T\x00F\x00-\x001\x006\x00L\x00E\x00\n\x00"
end
it "reads a file with a utf-16be bom" do
name = fixture __FILE__, "bom_UTF-16BE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("binary").should == "\x00U\x00T\x00F\x00-\x001\x006\x00B\x00E\x00\n"
+ result.force_encoding("ascii-8bit").should == "\x00U\x00T\x00F\x00-\x001\x006\x00B\x00E\x00\n"
end
it "reads a file with a utf-32le bom" do
name = fixture __FILE__, "bom_UTF-32LE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("binary").should == "U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00L\x00\x00\x00E\x00\x00\x00\n\x00\x00\x00"
+ result.force_encoding("ascii-8bit").should == "U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00L\x00\x00\x00E\x00\x00\x00\n\x00\x00\x00"
end
it "reads a file with a utf-32be bom" do
name = fixture __FILE__, "bom_UTF-32BE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("binary").should == "\x00\x00\x00U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00B\x00\x00\x00E\x00\x00\x00\n"
+ result.force_encoding("ascii-8bit").should == "\x00\x00\x00U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00B\x00\x00\x00E\x00\x00\x00\n"
end
end
-describe :io_read_internal_encoding, shared: true do
- it "returns a transcoded String" do
- @io.read.should == "ã‚りãŒã¨ã†\n"
- end
-
- it "sets the String encoding to the internal encoding" do
- @io.read.encoding.should equal(Encoding::UTF_8)
- end
-
- describe "when passed nil for limit" do
- it "sets the buffer to a transcoded String" do
- result = @io.read(nil, buf = "")
- buf.should equal(result)
- buf.should == "ã‚りãŒã¨ã†\n"
+with_feature :encoding do
+ describe :io_read_internal_encoding, shared: true do
+ it "returns a transcoded String" do
+ @io.read.should == "ã‚りãŒã¨ã†\n"
end
- it "sets the buffer's encoding to the internal encoding" do
- buf = "".force_encoding Encoding::ISO_8859_1
- @io.read(nil, buf)
- buf.encoding.should equal(Encoding::UTF_8)
+ it "sets the String encoding to the internal encoding" do
+ @io.read.encoding.should equal(Encoding::UTF_8)
end
- end
-end
-
-describe :io_read_size_internal_encoding, shared: true do
- it "reads bytes when passed a size" do
- @io.read(2).should == [164, 162].pack('C*').force_encoding(Encoding::BINARY)
- end
-
- it "returns a String in BINARY when passed a size" do
- @io.read(4).encoding.should equal(Encoding::BINARY)
- end
- it "does not change the buffer's encoding when passed a limit" do
- buf = "".force_encoding Encoding::ISO_8859_1
- @io.read(4, buf)
- buf.should == [164, 162, 164, 234].pack('C*').force_encoding(Encoding::ISO_8859_1)
- buf.encoding.should equal(Encoding::ISO_8859_1)
- end
-
- it "truncates the buffer but does not change the buffer's encoding when no data remains" do
- buf = "abc".force_encoding Encoding::ISO_8859_1
- @io.read
+ describe "when passed nil for limit" do
+ it "sets the buffer to a transcoded String" do
+ result = @io.read(nil, buf = "")
+ buf.should equal(result)
+ buf.should == "ã‚りãŒã¨ã†\n"
+ end
- @io.read(1, buf).should be_nil
- buf.size.should == 0
- buf.encoding.should equal(Encoding::ISO_8859_1)
+ it "sets the buffer's encoding to the internal encoding" do
+ buf = "".force_encoding Encoding::ISO_8859_1
+ @io.read(nil, buf)
+ buf.encoding.should equal(Encoding::UTF_8)
+ end
+ end
end
-end
-describe "IO#read" do
- describe "when IO#external_encoding and IO#internal_encoding are nil" do
- before :each do
- @name = tmp("io_read.txt")
- touch(@name) { |f| f.write "\x00\x01\x02" }
- @io = new_io @name, "r+"
+ describe :io_read_size_internal_encoding, shared: true do
+ it "reads bytes when passed a size" do
+ @io.read(2).should == [164, 162].pack('C*').force_encoding(Encoding::ASCII_8BIT)
end
- after :each do
- @io.close if @io
- rm_r @name
+ it "returns a String in ASCII-8BIT when passed a size" do
+ @io.read(4).encoding.should equal(Encoding::ASCII_8BIT)
end
- it "sets the String encoding to Encoding.default_external" do
- @io.read.encoding.should equal(Encoding.default_external)
+ it "does not change the buffer's encoding when passed a limit" do
+ buf = "".force_encoding Encoding::ISO_8859_1
+ @io.read(4, buf)
+ buf.should == [164, 162, 164, 234].pack('C*').force_encoding(Encoding::ISO_8859_1)
+ buf.encoding.should equal(Encoding::ISO_8859_1)
end
- end
- describe "with internal encoding" do
- after :each do
- @io.close if @io
+ it "trucates the buffer but does not change the buffer's encoding when no data remains" do
+ buf = "abc".force_encoding Encoding::ISO_8859_1
+ @io.read
+
+ @io.read(1, buf).should be_nil
+ buf.size.should == 0
+ buf.encoding.should equal(Encoding::ISO_8859_1)
end
+ end
- describe "not specified" do
+ describe "IO#read" do
+ describe "when IO#external_encoding and IO#internal_encoding are nil" do
before :each do
- @io = IOSpecs.io_fixture "read_euc_jp.txt", "r:euc-jp"
+ @name = tmp("io_read.txt")
+ touch(@name) { |f| f.write "\x00\x01\x02" }
+ @io = new_io @name, "r+"
end
- it "does not transcode the String" do
- @io.read.should == ("ã‚りãŒã¨ã†\n").encode(Encoding::EUC_JP)
+ after :each do
+ @io.close if @io
+ rm_r @name
end
- it "sets the String encoding to the external encoding" do
- @io.read.encoding.should equal(Encoding::EUC_JP)
+ it "sets the String encoding to Encoding.default_external" do
+ @io.read.encoding.should equal(Encoding.default_external)
end
-
- it_behaves_like :io_read_size_internal_encoding, nil
end
- describe "specified by open mode" do
- before :each do
- @io = IOSpecs.io_fixture "read_euc_jp.txt", "r:euc-jp:utf-8"
+ describe "with internal encoding" do
+ after :each do
+ @io.close if @io
end
- it_behaves_like :io_read_internal_encoding, nil
- it_behaves_like :io_read_size_internal_encoding, nil
- end
+ describe "not specified" do
+ before :each do
+ @io = IOSpecs.io_fixture "read_euc_jp.txt", "r:euc-jp"
+ end
- describe "specified by mode: option" do
- before :each do
- @io = IOSpecs.io_fixture "read_euc_jp.txt", mode: "r:euc-jp:utf-8"
+ it "does not transcode the String" do
+ @io.read.should == ("ã‚りãŒã¨ã†\n").encode(Encoding::EUC_JP)
+ end
+
+ it "sets the String encoding to the external encoding" do
+ @io.read.encoding.should equal(Encoding::EUC_JP)
+ end
+
+ it_behaves_like :io_read_size_internal_encoding, nil
end
- it_behaves_like :io_read_internal_encoding, nil
- it_behaves_like :io_read_size_internal_encoding, nil
- end
+ describe "specified by open mode" do
+ before :each do
+ @io = IOSpecs.io_fixture "read_euc_jp.txt", "r:euc-jp:utf-8"
+ end
- describe "specified by internal_encoding: option" do
- before :each do
- options = { mode: "r",
- internal_encoding: "utf-8",
- external_encoding: "euc-jp" }
- @io = IOSpecs.io_fixture "read_euc_jp.txt", options
+ it_behaves_like :io_read_internal_encoding, nil
+ it_behaves_like :io_read_size_internal_encoding, nil
end
- it_behaves_like :io_read_internal_encoding, nil
- it_behaves_like :io_read_size_internal_encoding, nil
- end
+ describe "specified by mode: option" do
+ before :each do
+ @io = IOSpecs.io_fixture "read_euc_jp.txt", mode: "r:euc-jp:utf-8"
+ end
- describe "specified by encoding: option" do
- before :each do
- options = { mode: "r", encoding: "euc-jp:utf-8" }
- @io = IOSpecs.io_fixture "read_euc_jp.txt", options
+ it_behaves_like :io_read_internal_encoding, nil
+ it_behaves_like :io_read_size_internal_encoding, nil
end
- it_behaves_like :io_read_internal_encoding, nil
- it_behaves_like :io_read_size_internal_encoding, nil
+ describe "specified by internal_encoding: option" do
+ before :each do
+ options = { mode: "r",
+ internal_encoding: "utf-8",
+ external_encoding: "euc-jp" }
+ @io = IOSpecs.io_fixture "read_euc_jp.txt", options
+ end
+
+ it_behaves_like :io_read_internal_encoding, nil
+ it_behaves_like :io_read_size_internal_encoding, nil
+ end
+
+ describe "specified by encoding: option" do
+ before :each do
+ options = { mode: "r", encoding: "euc-jp:utf-8" }
+ @io = IOSpecs.io_fixture "read_euc_jp.txt", options
+ end
+
+ it_behaves_like :io_read_internal_encoding, nil
+ it_behaves_like :io_read_size_internal_encoding, nil
+ end
end
end
end
diff --git a/spec/ruby/core/io/readbyte_spec.rb b/spec/ruby/core/io/readbyte_spec.rb
index 14426c28ac..1cc588eea5 100644
--- a/spec/ruby/core/io/readbyte_spec.rb
+++ b/spec/ruby/core/io/readbyte_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO#readbyte" do
before :each do
@@ -17,8 +17,10 @@ describe "IO#readbyte" do
it "raises EOFError on EOF" do
@io.seek(999999)
- -> do
+ lambda do
@io.readbyte
end.should raise_error EOFError
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/io/readchar_spec.rb b/spec/ruby/core/io/readchar_spec.rb
index b5f762a846..6771fcab59 100644
--- a/spec/ruby/core/io/readchar_spec.rb
+++ b/spec/ruby/core/io/readchar_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#readchar" do
before :each do
@@ -21,11 +21,11 @@ describe "IO#readchar" do
it "raises an EOFError when invoked at the end of the stream" do
@io.read
- -> { @io.readchar }.should raise_error(EOFError)
+ lambda { @io.readchar }.should raise_error(EOFError)
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.readchar }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.readchar }.should raise_error(IOError)
end
end
@@ -39,6 +39,6 @@ describe "IO#readchar" do
end
it "raises EOFError on empty stream" do
- -> { @io.readchar }.should raise_error(EOFError)
+ lambda { @io.readchar }.should raise_error(EOFError)
end
end
diff --git a/spec/ruby/core/io/readline_spec.rb b/spec/ruby/core/io/readline_spec.rb
index 7cb1601816..a1cddafe5c 100644
--- a/spec/ruby/core/io/readline_spec.rb
+++ b/spec/ruby/core/io/readline_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#readline" do
before :each do
@@ -29,11 +29,11 @@ describe "IO#readline" do
it "raises EOFError on end of stream" do
IOSpecs.lines.length.times { @io.readline }
- -> { @io.readline }.should raise_error(EOFError)
+ lambda { @io.readline }.should raise_error(EOFError)
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.readline }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.readline }.should raise_error(IOError)
end
it "assigns the returned line to $_" do
@@ -43,9 +43,11 @@ describe "IO#readline" do
end
end
- describe "when passed chomp" do
- it "returns the first line without a trailing newline character" do
- @io.readline(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
+ ruby_version_is "2.4" do
+ describe "when passed chomp" do
+ it "returns the first line without a trailing newline character" do
+ @io.readline(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
+ end
end
end
end
diff --git a/spec/ruby/core/io/readlines_spec.rb b/spec/ruby/core/io/readlines_spec.rb
index 0d4f002972..22ba844b52 100644
--- a/spec/ruby/core/io/readlines_spec.rb
+++ b/spec/ruby/core/io/readlines_spec.rb
@@ -1,23 +1,23 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/readlines'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/readlines', __FILE__)
describe "IO#readlines" do
before :each do
@io = IOSpecs.io_fixture "lines.txt"
- @orig_extenc = Encoding.default_external
+ @orig_exteenc = Encoding.default_external
Encoding.default_external = Encoding::UTF_8
end
after :each do
@io.close unless @io.closed?
- Encoding.default_external = @orig_extenc
+ Encoding.default_external = @orig_exteenc
end
it "raises an IOError if the stream is closed" do
@io.close
- -> { @io.readlines }.should raise_error(IOError)
+ lambda { @io.readlines }.should raise_error(IOError)
end
describe "when passed no arguments" do
@@ -112,7 +112,7 @@ describe "IO#readlines" do
lines.should == ["hello\n", "line2\n"]
end
- platform_is_not :windows do
+ with_feature :fork do
it "gets data from a fork when passed -" do
lines = IO.readlines("|-")
@@ -138,14 +138,14 @@ describe "IO#readlines" do
end
it "raises an IOError if the stream is opened for append only" do
- -> do
- File.open(@name, "a:utf-8") { |f| f.readlines }
+ lambda do
+ File.open(@name, fmode("a:utf-8")) { |f| f.readlines }
end.should raise_error(IOError)
end
it "raises an IOError if the stream is opened for write only" do
- -> do
- File.open(@name, "w:utf-8") { |f| f.readlines }
+ lambda do
+ File.open(@name, fmode("w:utf-8")) { |f| f.readlines }
end.should raise_error(IOError)
end
end
@@ -201,10 +201,10 @@ describe "IO.readlines" do
lines.all? { |s| s.encoding == Encoding::UTF_16 }.should be_true
end
- it "ignores the default internal encoding if the external encoding is BINARY" do
- Encoding.default_external = Encoding::BINARY
+ it "ignores the default internal encoding if the external encoding is ASCII-8BIT" do
+ Encoding.default_external = Encoding::ASCII_8BIT
Encoding.default_internal = Encoding::UTF_8
lines = IO.readlines(@name)
- lines.all? { |s| s.encoding == Encoding::BINARY }.should be_true
+ lines.all? { |s| s.encoding == Encoding::ASCII_8BIT }.should be_true
end
end
diff --git a/spec/ruby/core/io/readpartial_spec.rb b/spec/ruby/core/io/readpartial_spec.rb
index 2b33a0d5b1..16cb08dada 100644
--- a/spec/ruby/core/io/readpartial_spec.rb
+++ b/spec/ruby/core/io/readpartial_spec.rb
@@ -1,6 +1,6 @@
-# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#readpartial" do
before :each do
@@ -15,10 +15,10 @@ describe "IO#readpartial" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.readpartial(10) }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.readpartial(10) }.should raise_error(IOError)
@rd.close
- -> { @rd.readpartial(10) }.should raise_error(IOError)
+ lambda { @rd.readpartial(10) }.should raise_error(IOError)
end
it "reads at most the specified number of bytes" do
@@ -70,23 +70,23 @@ describe "IO#readpartial" do
@wr.write("abc")
@wr.close
@rd.readpartial(10).should == 'abc'
- -> { @rd.readpartial(10) }.should raise_error(EOFError)
+ lambda { @rd.readpartial(10) }.should raise_error(EOFError)
end
it "discards the existing buffer content upon error" do
buffer = 'hello'
@wr.close
- -> { @rd.readpartial(1, buffer) }.should raise_error(EOFError)
+ lambda { @rd.readpartial(1, buffer) }.should raise_error(EOFError)
buffer.should be_empty
end
it "raises IOError if the stream is closed" do
@wr.close
- -> { @rd.readpartial(1) }.should raise_error(IOError)
+ lambda { @rd.readpartial(1) }.should raise_error(IOError)
end
it "raises ArgumentError if the negative argument is provided" do
- -> { @rd.readpartial(-1) }.should raise_error(ArgumentError)
+ lambda { @rd.readpartial(-1) }.should raise_error(ArgumentError)
end
it "immediately returns an empty string if the length argument is 0" do
diff --git a/spec/ruby/core/io/reopen_spec.rb b/spec/ruby/core/io/reopen_spec.rb
index faef80f513..63020d5f3e 100644
--- a/spec/ruby/core/io/reopen_spec.rb
+++ b/spec/ruby/core/io/reopen_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'fcntl'
@@ -33,29 +33,29 @@ describe "IO#reopen" do
it "raises an IOError if the object returned by #to_io is closed" do
obj = mock("io")
obj.should_receive(:to_io).and_return(IOSpecs.closed_io)
- -> { @io.reopen obj }.should raise_error(IOError)
+ lambda { @io.reopen obj }.should raise_error(IOError)
end
it "raises a TypeError if #to_io does not return an IO instance" do
obj = mock("io")
obj.should_receive(:to_io).and_return("something else")
- -> { @io.reopen obj }.should raise_error(TypeError)
+ lambda { @io.reopen obj }.should raise_error(TypeError)
end
it "raises an IOError when called on a closed stream with an object" do
@io.close
obj = mock("io")
obj.should_not_receive(:to_io)
- -> { @io.reopen(STDOUT) }.should raise_error(IOError)
+ lambda { @io.reopen(STDOUT) }.should raise_error(IOError)
end
it "raises an IOError if the IO argument is closed" do
- -> { @io.reopen(IOSpecs.closed_io) }.should raise_error(IOError)
+ lambda { @io.reopen(IOSpecs.closed_io) }.should raise_error(IOError)
end
it "raises an IOError when called on a closed stream with an IO" do
@io.close
- -> { @io.reopen(STDOUT) }.should raise_error(IOError)
+ lambda { @io.reopen(STDOUT) }.should raise_error(IOError)
end
end
@@ -145,30 +145,31 @@ describe "IO#reopen with a String" do
File.read(@other_name).should == "new data"
end
- it "always resets the close-on-exec flag to true on non-STDIO objects" do
+ it "closes the file descriptor obtained by opening the new file" do
@io = new_io @name, "w"
- @io.close_on_exec = true
- @io.reopen @other_name
- @io.close_on_exec?.should == true
+ @other_io = File.open @other_name, "w"
+ max = @other_io.fileno
+ @other_io.close
- @io.close_on_exec = false
@io.reopen @other_name
- @io.close_on_exec?.should == true
+
+ @other_io = File.open @other_name, "w"
+ @other_io.fileno.should == max
end
it "creates the file if it doesn't exist if the IO is opened in write mode" do
@io = new_io @name, "w"
@io.reopen(@other_name)
- File.should.exist?(@other_name)
+ File.exist?(@other_name).should be_true
end
it "creates the file if it doesn't exist if the IO is opened in write mode" do
@io = new_io @name, "a"
@io.reopen(@other_name)
- File.should.exist?(@other_name)
+ File.exist?(@other_name).should be_true
end
end
@@ -188,7 +189,7 @@ describe "IO#reopen with a String" do
it "raises an Errno::ENOENT if the file does not exist and the IO is not opened in write mode" do
@io = new_io @name, "r"
- -> { @io.reopen(@other_name) }.should raise_error(Errno::ENOENT)
+ lambda { @io.reopen(@other_name) }.should raise_error(Errno::ENOENT)
end
end
@@ -230,7 +231,7 @@ describe "IO#reopen with an IO" do
end
@io = new_io @name
- @other_io = IO.new(new_fd(@other_name, "r"), "r")
+ @other_io = new_io @other_name, "r"
end
after :each do
@@ -289,18 +290,6 @@ describe "IO#reopen with an IO" do
File.read(@other_name).should == "io data"
end
- it "always resets the close-on-exec flag to true on non-STDIO objects" do
- @other_io.close_on_exec = true
- @io.close_on_exec = true
- @io.reopen @other_io
- @io.close_on_exec?.should == true
-
- @other_io.close_on_exec = false
- @io.close_on_exec = false
- @io.reopen @other_io
- @io.close_on_exec?.should == true
- end
-
it "may change the class of the instance" do
@io.reopen @other_io
@io.should be_an_instance_of(File)
diff --git a/spec/ruby/core/io/rewind_spec.rb b/spec/ruby/core/io/rewind_spec.rb
index 954d56d30c..ecf8a71891 100644
--- a/spec/ruby/core/io/rewind_spec.rb
+++ b/spec/ruby/core/io/rewind_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#rewind" do
before :each do
@@ -33,6 +33,6 @@ describe "IO#rewind" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.rewind }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.rewind }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/seek_spec.rb b/spec/ruby/core/io/seek_spec.rb
index 7e9c308272..f7e138cbe9 100644
--- a/spec/ruby/core/io/seek_spec.rb
+++ b/spec/ruby/core/io/seek_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "IO#seek" do
it_behaves_like :io_set_pos, :seek
@@ -17,7 +17,7 @@ describe "IO#seek" do
end
it "moves the read position relative to the current position with SEEK_CUR" do
- -> { @io.seek(-1) }.should raise_error(Errno::EINVAL)
+ lambda { @io.seek(-1) }.should raise_error(Errno::EINVAL)
@io.seek(10, IO::SEEK_CUR)
@io.readline.should == "igne une.\n"
@io.seek(-5, IO::SEEK_CUR)
diff --git a/spec/ruby/core/io/select_spec.rb b/spec/ruby/core/io/select_spec.rb
index 4603c1fbbc..7e51cd37d4 100644
--- a/spec/ruby/core/io/select_spec.rb
+++ b/spec/ruby/core/io/select_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO.select" do
before :each do
@@ -16,10 +16,8 @@ describe "IO.select" do
it "returns immediately all objects that are ready for I/O when timeout is 0" do
@wr.syswrite("be ready")
- IO.pipe do |_, wr|
- result = IO.select [@rd], [wr], nil, 0
- result.should == [[@rd], [wr], []]
- end
+ result = IO.select [@rd], [@wr], nil, 0
+ result.should == [[@rd], [@wr], []]
end
it "returns nil after timeout if there are no objects ready for I/O" do
@@ -72,36 +70,34 @@ describe "IO.select" do
obj.should_receive(:to_io).at_least(1).and_return(@rd)
IO.select([obj]).should == [[obj], [], []]
- IO.pipe do |_, wr|
- obj = mock("write_io")
- obj.should_receive(:to_io).at_least(1).and_return(wr)
- IO.select(nil, [obj]).should == [[], [obj], []]
- end
+ obj = mock("write_io")
+ obj.should_receive(:to_io).at_least(1).and_return(@wr)
+ IO.select(nil, [obj]).should == [[], [obj], []]
end
it "raises TypeError if supplied objects are not IO" do
- -> { IO.select([Object.new]) }.should raise_error(TypeError)
- -> { IO.select(nil, [Object.new]) }.should raise_error(TypeError)
+ lambda { IO.select([Object.new]) }.should raise_error(TypeError)
+ lambda { IO.select(nil, [Object.new]) }.should raise_error(TypeError)
obj = mock("io")
obj.should_receive(:to_io).any_number_of_times.and_return(nil)
- -> { IO.select([obj]) }.should raise_error(TypeError)
- -> { IO.select(nil, [obj]) }.should raise_error(TypeError)
+ lambda { IO.select([obj]) }.should raise_error(TypeError)
+ lambda { IO.select(nil, [obj]) }.should raise_error(TypeError)
end
it "raises a TypeError if the specified timeout value is not Numeric" do
- -> { IO.select([@rd], nil, nil, Object.new) }.should raise_error(TypeError)
+ lambda { IO.select([@rd], nil, nil, Object.new) }.should raise_error(TypeError)
end
it "raises TypeError if the first three arguments are not Arrays" do
- -> { IO.select(Object.new)}.should raise_error(TypeError)
- -> { IO.select(nil, Object.new)}.should raise_error(TypeError)
- -> { IO.select(nil, nil, Object.new)}.should raise_error(TypeError)
+ lambda { IO.select(Object.new)}.should raise_error(TypeError)
+ lambda { IO.select(nil, Object.new)}.should raise_error(TypeError)
+ lambda { IO.select(nil, nil, Object.new)}.should raise_error(TypeError)
end
it "raises an ArgumentError when passed a negative timeout" do
- -> { IO.select(nil, nil, nil, -5)}.should raise_error(ArgumentError)
+ lambda { IO.select(nil, nil, nil, -5)}.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/io/set_encoding_spec.rb b/spec/ruby/core/io/set_encoding_spec.rb
index 5aec6a96c3..1d6e2a8f3b 100644
--- a/spec/ruby/core/io/set_encoding_spec.rb
+++ b/spec/ruby/core/io/set_encoding_spec.rb
@@ -1,191 +1,193 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe :io_set_encoding_write, shared: true do
- it "sets the encodings to nil" do
- @io = new_io @name, "#{@object}:ibm437:ibm866"
- @io.set_encoding nil, nil
+with_feature :encoding do
+ describe :io_set_encoding_write, shared: true do
+ it "sets the encodings to nil" do
+ @io = new_io @name, "#{@object}:ibm437:ibm866"
+ @io.set_encoding nil, nil
- @io.external_encoding.should be_nil
- @io.internal_encoding.should be_nil
- end
+ @io.external_encoding.should be_nil
+ @io.internal_encoding.should be_nil
+ end
- it "prevents the encodings from changing when Encoding defaults are changed" do
- @io = new_io @name, "#{@object}:utf-8:us-ascii"
- @io.set_encoding nil, nil
+ it "prevents the encodings from changing when Encoding defaults are changed" do
+ @io = new_io @name, "#{@object}:utf-8:us-ascii"
+ @io.set_encoding nil, nil
- Encoding.default_external = Encoding::IBM437
- Encoding.default_internal = Encoding::IBM866
+ Encoding.default_external = Encoding::IBM437
+ Encoding.default_internal = Encoding::IBM866
- @io.external_encoding.should be_nil
- @io.internal_encoding.should be_nil
- end
+ @io.external_encoding.should be_nil
+ @io.internal_encoding.should be_nil
+ end
- it "sets the encodings to the current Encoding defaults" do
- @io = new_io @name, @object
+ it "sets the encodings to the current Encoding defaults" do
+ @io = new_io @name, @object
- Encoding.default_external = Encoding::IBM437
- Encoding.default_internal = Encoding::IBM866
+ Encoding.default_external = Encoding::IBM437
+ Encoding.default_internal = Encoding::IBM866
- @io.set_encoding nil, nil
+ @io.set_encoding nil, nil
- @io.external_encoding.should == Encoding::IBM437
- @io.internal_encoding.should == Encoding::IBM866
+ @io.external_encoding.should == Encoding::IBM437
+ @io.internal_encoding.should == Encoding::IBM866
+ end
end
-end
-describe "IO#set_encoding when passed nil, nil" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
+ describe "IO#set_encoding when passed nil, nil" do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- Encoding.default_external = Encoding::UTF_8
- Encoding.default_internal = nil
+ Encoding.default_external = Encoding::UTF_8
+ Encoding.default_internal = nil
- @name = tmp('io_set_encoding.txt')
- touch(@name)
- end
+ @name = tmp('io_set_encoding.txt')
+ touch(@name)
+ end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
- @io.close if @io and not @io.closed?
- rm_r @name
- end
+ @io.close if @io and not @io.closed?
+ rm_r @name
+ end
- describe "with 'r' mode" do
- it "sets the encodings to the current Encoding defaults" do
- @io = new_io @name, "r"
+ describe "with 'r' mode" do
+ it "sets the encodings to the current Encoding defaults" do
+ @io = new_io @name, "r"
- Encoding.default_external = Encoding::IBM437
- Encoding.default_internal = Encoding::IBM866
+ Encoding.default_external = Encoding::IBM437
+ Encoding.default_internal = Encoding::IBM866
- @io.set_encoding nil, nil
- @io.external_encoding.should equal(Encoding::IBM437)
- @io.internal_encoding.should equal(Encoding::IBM866)
- end
+ @io.set_encoding nil, nil
+ @io.external_encoding.should equal(Encoding::IBM437)
+ @io.internal_encoding.should equal(Encoding::IBM866)
+ end
- it "prevents the #internal_encoding from changing when Encoding.default_internal is changed" do
- @io = new_io @name, "r"
- @io.set_encoding nil, nil
+ it "prevents the #internal_encoding from changing when Encoding.default_internal is changed" do
+ @io = new_io @name, "r"
+ @io.set_encoding nil, nil
- Encoding.default_internal = Encoding::IBM437
+ Encoding.default_internal = Encoding::IBM437
- @io.internal_encoding.should be_nil
- end
+ @io.internal_encoding.should be_nil
+ end
- it "allows the #external_encoding to change when Encoding.default_external is changed" do
- @io = new_io @name, "r"
- @io.set_encoding nil, nil
+ it "allows the #external_encoding to change when Encoding.default_external is changed" do
+ @io = new_io @name, "r"
+ @io.set_encoding nil, nil
- Encoding.default_external = Encoding::IBM437
+ Encoding.default_external = Encoding::IBM437
- @io.external_encoding.should equal(Encoding::IBM437)
+ @io.external_encoding.should equal(Encoding::IBM437)
+ end
end
- end
- describe "with 'rb' mode" do
- it "returns Encoding.default_external" do
- @io = new_io @name, "rb"
- @io.external_encoding.should equal(Encoding::BINARY)
+ describe "with 'rb' mode" do
+ it "returns Encoding.default_external" do
+ @io = new_io @name, "rb"
+ @io.external_encoding.should equal(Encoding::ASCII_8BIT)
- @io.set_encoding nil, nil
- @io.external_encoding.should equal(Encoding.default_external)
+ @io.set_encoding nil, nil
+ @io.external_encoding.should equal(Encoding.default_external)
+ end
end
- end
- describe "with 'r+' mode" do
- it_behaves_like :io_set_encoding_write, nil, "r+"
- end
+ describe "with 'r+' mode" do
+ it_behaves_like :io_set_encoding_write, nil, "r+"
+ end
- describe "with 'w' mode" do
- it_behaves_like :io_set_encoding_write, nil, "w"
- end
+ describe "with 'w' mode" do
+ it_behaves_like :io_set_encoding_write, nil, "w"
+ end
- describe "with 'w+' mode" do
- it_behaves_like :io_set_encoding_write, nil, "w+"
- end
+ describe "with 'w+' mode" do
+ it_behaves_like :io_set_encoding_write, nil, "w+"
+ end
- describe "with 'a' mode" do
- it_behaves_like :io_set_encoding_write, nil, "a"
- end
+ describe "with 'a' mode" do
+ it_behaves_like :io_set_encoding_write, nil, "a"
+ end
- describe "with 'a+' mode" do
- it_behaves_like :io_set_encoding_write, nil, "a+"
+ describe "with 'a+' mode" do
+ it_behaves_like :io_set_encoding_write, nil, "a+"
+ end
end
-end
-describe "IO#set_encoding" do
- before :each do
- @name = tmp('io_set_encoding.txt')
- touch(@name)
- @io = new_io @name
- end
+ describe "IO#set_encoding" do
+ before :each do
+ @name = tmp('io_set_encoding.txt')
+ touch(@name)
+ @io = new_io @name
+ end
- after :each do
- @io.close unless @io.closed?
- rm_r @name
- end
+ after :each do
+ @io.close unless @io.closed?
+ rm_r @name
+ end
- it "returns self" do
- @io.set_encoding(Encoding::UTF_8).should equal(@io)
- end
+ it "returns self" do
+ @io.set_encoding(Encoding::UTF_8).should equal(@io)
+ end
- it "sets the external encoding when passed an Encoding argument" do
- @io.set_encoding(Encoding::UTF_8)
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should be_nil
- end
+ it "sets the external encoding when passed an Encoding argument" do
+ @io.set_encoding(Encoding::UTF_8)
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should be_nil
+ end
- it "sets the external and internal encoding when passed two Encoding arguments" do
- @io.set_encoding(Encoding::UTF_8, Encoding::UTF_16BE)
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should == Encoding::UTF_16BE
- end
+ it "sets the external and internal encoding when passed two Encoding arguments" do
+ @io.set_encoding(Encoding::UTF_8, Encoding::UTF_16BE)
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should == Encoding::UTF_16BE
+ end
- it "sets the external encoding when passed the name of an Encoding" do
- @io.set_encoding("utf-8")
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should be_nil
- end
+ it "sets the external encoding when passed the name of an Encoding" do
+ @io.set_encoding("utf-8")
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should be_nil
+ end
- it "ignores the internal encoding if the same as external when passed Encoding objects" do
- @io.set_encoding(Encoding::UTF_8, Encoding::UTF_8)
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should be_nil
- end
+ it "ignores the internal encoding if the same as external when passed Encoding objects" do
+ @io.set_encoding(Encoding::UTF_8, Encoding::UTF_8)
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should be_nil
+ end
- it "ignores the internal encoding if the same as external when passed encoding names separated by ':'" do
- @io.set_encoding("utf-8:utf-8")
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should be_nil
- end
+ it "ignores the internal encoding if the same as external when passed encoding names separanted by ':'" do
+ @io.set_encoding("utf-8:utf-8")
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should be_nil
+ end
- it "sets the external and internal encoding when passed the names of Encodings separated by ':'" do
- @io.set_encoding("utf-8:utf-16be")
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should == Encoding::UTF_16BE
- end
+ it "sets the external and internal encoding when passed the names of Encodings separated by ':'" do
+ @io.set_encoding("utf-8:utf-16be")
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should == Encoding::UTF_16BE
+ end
- it "sets the external and internal encoding when passed two String arguments" do
- @io.set_encoding("utf-8", "utf-16be")
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should == Encoding::UTF_16BE
- end
+ it "sets the external and internal encoding when passed two String arguments" do
+ @io.set_encoding("utf-8", "utf-16be")
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should == Encoding::UTF_16BE
+ end
- it "calls #to_str to convert an abject to a String" do
- obj = mock("io_set_encoding")
- obj.should_receive(:to_str).and_return("utf-8:utf-16be")
- @io.set_encoding(obj)
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should == Encoding::UTF_16BE
- end
+ it "calls #to_str to convert an abject to a String" do
+ obj = mock("io_set_encoding")
+ obj.should_receive(:to_str).and_return("utf-8:utf-16be")
+ @io.set_encoding(obj)
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should == Encoding::UTF_16BE
+ end
- it "calls #to_str to convert the second argument to a String" do
- obj = mock("io_set_encoding")
- obj.should_receive(:to_str).at_least(1).times.and_return("utf-16be")
- @io.set_encoding(Encoding::UTF_8, obj)
- @io.external_encoding.should == Encoding::UTF_8
- @io.internal_encoding.should == Encoding::UTF_16BE
+ it "calls #to_str to convert the second argument to a String" do
+ obj = mock("io_set_encoding")
+ obj.should_receive(:to_str).at_least(1).times.and_return("utf-16be")
+ @io.set_encoding(Encoding::UTF_8, obj)
+ @io.external_encoding.should == Encoding::UTF_8
+ @io.internal_encoding.should == Encoding::UTF_16BE
+ end
end
end
diff --git a/spec/ruby/core/io/shared/binwrite.rb b/spec/ruby/core/io/shared/binwrite.rb
index 3649bb47ff..67f0fd5c86 100644
--- a/spec/ruby/core/io/shared/binwrite.rb
+++ b/spec/ruby/core/io/shared/binwrite.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :io_binwrite, shared: true do
before :each do
@@ -24,9 +24,9 @@ describe :io_binwrite, shared: true do
it "creates a file if missing" do
fn = @filename + "xxx"
begin
- File.should_not.exist?(fn)
+ File.exist?(fn).should be_false
IO.send(@method, fn, "test")
- File.should.exist?(fn)
+ File.exist?(fn).should be_true
ensure
rm_r fn
end
@@ -35,9 +35,9 @@ describe :io_binwrite, shared: true do
it "creates file if missing even if offset given" do
fn = @filename + "xxx"
begin
- File.should_not.exist?(fn)
+ File.exist?(fn).should be_false
IO.send(@method, fn, "test", 0)
- File.should.exist?(fn)
+ File.exist?(fn).should be_true
ensure
rm_r fn
end
@@ -56,7 +56,7 @@ describe :io_binwrite, shared: true do
end
it "doesn't truncate and writes at the given offset after passing empty opts" do
- IO.send(@method, @filename, "hello world!", 1, **{})
+ IO.send(@method, @filename, "hello world!", 1, {})
File.read(@filename).should == "0hello world!34567890123456789"
end
@@ -68,11 +68,11 @@ describe :io_binwrite, shared: true do
end
it "raises an error if readonly mode is specified" do
- -> { IO.send(@method, @filename, "abcde", mode: "r") }.should raise_error(IOError)
+ lambda { IO.send(@method, @filename, "abcde", mode: "r") }.should raise_error(IOError)
end
it "truncates if empty :opts provided and offset skipped" do
- IO.send(@method, @filename, "hello, world!", **{})
+ IO.send(@method, @filename, "hello, world!", {})
File.read(@filename).should == "hello, world!"
end
end
diff --git a/spec/ruby/core/io/shared/chars.rb b/spec/ruby/core/io/shared/chars.rb
index 266566f221..7f2edd2b6d 100644
--- a/spec/ruby/core/io/shared/chars.rb
+++ b/spec/ruby/core/io/shared/chars.rb
@@ -46,11 +46,11 @@ describe :io_chars, shared: true do
end
it "raises an IOError when an enumerator created on a closed stream is accessed" do
- -> { IOSpecs.closed_io.send(@method).first }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send(@method).first }.should raise_error(IOError)
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/shared/codepoints.rb b/spec/ruby/core/io/shared/codepoints.rb
index 6872846c1a..3bb3dce939 100644
--- a/spec/ruby/core/io/shared/codepoints.rb
+++ b/spec/ruby/core/io/shared/codepoints.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :io_codepoints, shared: true do
before :each do
@@ -39,7 +39,7 @@ describe :io_codepoints, shared: true do
it "raises an error if reading invalid sequence" do
@io.pos = 60 # inside of a multibyte sequence
- -> { @enum.first }.should raise_error(ArgumentError)
+ lambda { @enum.first }.should raise_error(ArgumentError)
end
it "does not change $_" do
@@ -49,6 +49,6 @@ describe :io_codepoints, shared: true do
end
it "raises an IOError when self is not readable" do
- -> { IOSpecs.closed_io.send(@method).to_a }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send(@method).to_a }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/shared/each.rb b/spec/ruby/core/io/shared/each.rb
index 0b2dfa3548..4ef8a54147 100644
--- a/spec/ruby/core/io/shared/each.rb
+++ b/spec/ruby/core/io/shared/each.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :io_each, shared: true do
before :each do
@@ -38,7 +38,7 @@ describe :io_each, shared: true do
end
it "raises an IOError when self is not readable" do
- -> { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError)
end
it "makes line count accessible via lineno" do
@@ -74,7 +74,7 @@ describe :io_each, shared: true do
describe "when limit is 0" do
it "raises an ArgumentError" do
# must pass block so Enumerator is evaluated and raises
- -> { @io.send(@method, 0){} }.should raise_error(ArgumentError)
+ lambda { @io.send(@method, 0){} }.should raise_error(ArgumentError)
end
end
end
@@ -156,10 +156,12 @@ describe :io_each, shared: true do
end
end
- describe "when passed chomp" do
- it "yields each line without trailing newline characters to the passed block" do
- @io.send(@method, chomp: true) { |s| ScratchPad << s }
- ScratchPad.recorded.should == IOSpecs.lines_without_newline_characters
+ ruby_version_is "2.4" do
+ describe "when passed chomp" do
+ it "yields each line without trailing newline characters to the passed block" do
+ @io.send(@method, chomp: true) { |s| ScratchPad << s }
+ ScratchPad.recorded.should == IOSpecs.lines_without_newline_characters
+ end
end
end
end
diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb
index a7b4fc1cbe..12f889f646 100644
--- a/spec/ruby/core/io/shared/new.rb
+++ b/spec/ruby/core/io/shared/new.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
# This group of specs may ONLY contain specs that do successfully create
# an IO instance from the file descriptor returned by #new_fd helper.
@@ -24,34 +24,34 @@ describe :io_new, shared: true do
end
it "creates an IO instance when STDOUT is closed" do
- suppress_warning do
- stdout = STDOUT
- stdout_file = tmp("stdout.txt")
-
- begin
- @io = IO.send(@method, @fd, "w")
- @io.should be_an_instance_of(IO)
- ensure
- STDOUT = stdout
- rm_r stdout_file
- end
+ verbose, $VERBOSE = $VERBOSE, nil
+ stdout = STDOUT
+ stdout_file = tmp("stdout.txt")
+
+ begin
+ @io = IO.send(@method, @fd, "w")
+ @io.should be_an_instance_of(IO)
+ ensure
+ STDOUT = stdout
+ $VERBOSE = verbose
+ rm_r stdout_file
end
end
it "creates an IO instance when STDERR is closed" do
- suppress_warning do
- stderr = STDERR
- stderr_file = tmp("stderr.txt")
- STDERR = new_io stderr_file
- STDERR.close
-
- begin
- @io = IO.send(@method, @fd, "w")
- @io.should be_an_instance_of(IO)
- ensure
- STDERR = stderr
- rm_r stderr_file
- end
+ verbose, $VERBOSE = $VERBOSE, nil
+ stderr = STDERR
+ stderr_file = tmp("stderr.txt")
+ STDERR = new_io stderr_file
+ STDERR.close
+
+ begin
+ @io = IO.send(@method, @fd, "w")
+ @io.should be_an_instance_of(IO)
+ ensure
+ STDERR = stderr
+ $VERBOSE = verbose
+ rm_r stderr_file
end
end
@@ -89,59 +89,59 @@ describe :io_new, shared: true do
end
it "uses the external encoding specified via the :external_encoding option" do
- @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8')
+ @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8'})
@io.external_encoding.to_s.should == 'UTF-8'
end
it "uses the internal encoding specified via the :internal_encoding option" do
- @io = IO.send(@method, @fd, 'w', internal_encoding: 'ibm866')
+ @io = IO.send(@method, @fd, 'w', {internal_encoding: 'ibm866'})
@io.internal_encoding.to_s.should == 'IBM866'
end
it "uses the colon-separated encodings specified via the :encoding option" do
- @io = IO.send(@method, @fd, 'w', encoding: 'utf-8:ISO-8859-1')
+ @io = IO.send(@method, @fd, 'w', {encoding: 'utf-8:ISO-8859-1'})
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == 'ISO-8859-1'
end
it "uses the :encoding option as the external encoding when only one is given" do
- @io = IO.send(@method, @fd, 'w', encoding: 'ISO-8859-1')
+ @io = IO.send(@method, @fd, 'w', {encoding: 'ISO-8859-1'})
@io.external_encoding.to_s.should == 'ISO-8859-1'
end
it "uses the :encoding options as the external encoding when it's an Encoding object" do
- @io = IO.send(@method, @fd, 'w', encoding: Encoding::ISO_8859_1)
+ @io = IO.send(@method, @fd, 'w', {encoding: Encoding::ISO_8859_1})
@io.external_encoding.should == Encoding::ISO_8859_1
end
it "ignores the :encoding option when the :external_encoding option is present" do
- -> {
- @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', encoding: 'iso-8859-1:iso-8859-1')
+ lambda {
+ @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', encoding: 'iso-8859-1:iso-8859-1'})
}.should complain(/Ignoring encoding parameter/)
@io.external_encoding.to_s.should == 'UTF-8'
end
it "ignores the :encoding option when the :internal_encoding option is present" do
- -> {
- @io = IO.send(@method, @fd, 'w', internal_encoding: 'ibm866', encoding: 'iso-8859-1:iso-8859-1')
+ lambda {
+ @io = IO.send(@method, @fd, 'w', {internal_encoding: 'ibm866', encoding: 'iso-8859-1:iso-8859-1'})
}.should complain(/Ignoring encoding parameter/)
@io.internal_encoding.to_s.should == 'IBM866'
end
it "uses the encoding specified via the :mode option hash" do
- @io = IO.send(@method, @fd, mode: 'w:utf-8:ISO-8859-1')
+ @io = IO.send(@method, @fd, {mode: 'w:utf-8:ISO-8859-1'})
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == 'ISO-8859-1'
end
it "ignores the :internal_encoding option when the same as the external encoding" do
- @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', internal_encoding: 'utf-8')
+ @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', internal_encoding: 'utf-8'})
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == ''
end
it "sets internal encoding to nil when passed '-'" do
- @io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', internal_encoding: '-')
+ @io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', internal_encoding: '-'})
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == ''
end
@@ -157,24 +157,24 @@ describe :io_new, shared: true do
end
it "sets binmode from :binmode option" do
- @io = IO.send(@method, @fd, 'w', binmode: true)
+ @io = IO.send(@method, @fd, 'w', {binmode: true})
@io.binmode?.should == true
end
it "does not set binmode from false :binmode" do
- @io = IO.send(@method, @fd, 'w', binmode: false)
+ @io = IO.send(@method, @fd, 'w', {binmode: false})
@io.binmode?.should == false
end
it "sets external encoding to binary with binmode in mode string" do
@io = IO.send(@method, @fd, 'wb')
- @io.external_encoding.should == Encoding::BINARY
+ @io.external_encoding.to_s.should == 'ASCII-8BIT'
end
# #5917
it "sets external encoding to binary with :binmode option" do
- @io = IO.send(@method, @fd, 'w', binmode: true)
- @io.external_encoding.should == Encoding::BINARY
+ @io = IO.send(@method, @fd, 'w', {binmode: true})
+ @io.external_encoding.to_s.should == 'ASCII-8BIT'
end
it "does not use binary encoding when mode encoding is specified" do
@@ -198,9 +198,7 @@ describe :io_new, shared: true do
end
it "accepts nil options" do
- @io = suppress_keyword_warning do
- IO.send(@method, @fd, 'w', nil)
- end
+ @io = IO.send(@method, @fd, 'w', nil)
@io.write("foo").should == 3
end
@@ -249,13 +247,13 @@ describe :io_new, shared: true do
it "coerces options as third argument with #to_hash" do
options = mock("options")
options.should_receive(:to_hash).and_return({})
- @io = IO.send(@method, @fd, 'w', **options)
+ @io = IO.send(@method, @fd, 'w', options)
end
it "coerces options as second argument with #to_hash" do
options = mock("options")
options.should_receive(:to_hash).and_return({})
- @io = IO.send(@method, @fd, **options)
+ @io = IO.send(@method, @fd, options)
end
it "accepts an :autoclose option" do
@@ -284,99 +282,97 @@ describe :io_new_errors, shared: true do
end
it "raises an Errno::EBADF if the file descriptor is not valid" do
- -> { IO.send(@method, -1, "w") }.should raise_error(Errno::EBADF)
+ lambda { IO.send(@method, -1, "w") }.should raise_error(Errno::EBADF)
end
it "raises an IOError if passed a closed stream" do
- -> { IO.send(@method, IOSpecs.closed_io.fileno, 'w') }.should raise_error(IOError)
+ lambda { IO.send(@method, IOSpecs.closed_io.fileno, 'w') }.should raise_error(IOError)
end
platform_is_not :windows do
it "raises an Errno::EINVAL if the new mode is not compatible with the descriptor's current mode" do
- -> { IO.send(@method, @fd, "r") }.should raise_error(Errno::EINVAL)
+ lambda { IO.send(@method, @fd, "r") }.should raise_error(Errno::EINVAL)
end
end
it "raises ArgumentError if passed an empty mode string" do
- -> { IO.send(@method, @fd, "") }.should raise_error(ArgumentError)
+ lambda { IO.send(@method, @fd, "") }.should raise_error(ArgumentError)
end
it "raises an error if passed modes two ways" do
- -> {
+ lambda {
IO.send(@method, @fd, "w", mode: "w")
}.should raise_error(ArgumentError)
end
it "raises an error if passed encodings two ways" do
- -> {
- @io = IO.send(@method, @fd, 'w:ISO-8859-1', encoding: 'ISO-8859-1')
+ lambda {
+ @io = IO.send(@method, @fd, 'w:ISO-8859-1', {encoding: 'ISO-8859-1'})
}.should raise_error(ArgumentError)
- -> {
- @io = IO.send(@method, @fd, 'w:ISO-8859-1', external_encoding: 'ISO-8859-1')
+ lambda {
+ @io = IO.send(@method, @fd, 'w:ISO-8859-1', {external_encoding: 'ISO-8859-1'})
}.should raise_error(ArgumentError)
- -> {
- @io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1')
+ lambda {
+ @io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', {internal_encoding: 'ISO-8859-1'})
}.should raise_error(ArgumentError)
end
it "raises an error if passed matching binary/text mode two ways" do
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wb", binmode: true)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wt", textmode: true)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wb", textmode: false)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wt", binmode: false)
}.should raise_error(ArgumentError)
end
it "raises an error if passed conflicting binary/text mode two ways" do
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wb", binmode: false)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wt", textmode: false)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wb", textmode: true)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, "wt", binmode: true)
}.should raise_error(ArgumentError)
end
it "raises an error when trying to set both binmode and textmode" do
- -> {
+ lambda {
@io = IO.send(@method, @fd, "w", textmode: true, binmode: true)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, File::Constants::WRONLY, textmode: true, binmode: true)
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if not passed a hash or nil for options" do
- -> {
+ lambda {
@io = IO.send(@method, @fd, 'w', false)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, false, false)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@io = IO.send(@method, @fd, nil, false)
}.should raise_error(ArgumentError)
end
it "raises TypeError if passed a hash for mode and nil for options" do
- -> {
- suppress_keyword_warning do
- @io = IO.send(@method, @fd, {mode: 'w'}, nil)
- end
+ lambda {
+ @io = IO.send(@method, @fd, {mode: 'w'}, nil)
}.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/io/shared/pos.rb b/spec/ruby/core/io/shared/pos.rb
index fb6d8087bc..fef7ab2bf7 100644
--- a/spec/ruby/core/io/shared/pos.rb
+++ b/spec/ruby/core/io/shared/pos.rb
@@ -19,7 +19,7 @@ describe :io_pos, shared: true do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send(@method) }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send(@method) }.should raise_error(IOError)
end
it "resets #eof?" do
@@ -62,11 +62,11 @@ describe :io_set_pos, shared: true do
it "does not accept Bignums that don't fit in a C long" do
File.open @fname do |io|
- -> { io.send @method, 2**128 }.should raise_error(RangeError)
+ lambda { io.send @method, 2**128 }.should raise_error(RangeError)
end
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send @method, 0 }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send @method, 0 }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb
index de803f42e5..f545d8876a 100644
--- a/spec/ruby/core/io/shared/readlines.rb
+++ b/spec/ruby/core/io/shared/readlines.rb
@@ -1,11 +1,11 @@
describe :io_readlines, shared: true do
it "raises TypeError if the first parameter is nil" do
- -> { IO.send(@method, nil, &@object) }.should raise_error(TypeError)
+ lambda { IO.send(@method, nil, &@object) }.should raise_error(TypeError)
end
it "raises an Errno::ENOENT if the file does not exist" do
name = tmp("nonexistent.txt")
- -> { IO.send(@method, name, &@object) }.should raise_error(Errno::ENOENT)
+ lambda { IO.send(@method, name, &@object) }.should raise_error(Errno::ENOENT)
end
it "yields a single string with entire content when the separator is nil" do
@@ -18,9 +18,11 @@ describe :io_readlines, shared: true do
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_empty_separator
end
- it "yields a sequence of lines without trailing newline characters when chomp is passed" do
- result = IO.send(@method, @name, chomp: true, &@object)
- (result ? result : ScratchPad.recorded).should == IOSpecs.lines_without_newline_characters
+ ruby_version_is "2.4" do
+ it "yields a sequence of lines without trailing newline characters when chomp is passed" do
+ result = IO.send(@method, @name, chomp: true, &@object)
+ (result ? result : ScratchPad.recorded).should == IOSpecs.lines_without_newline_characters
+ end
end
end
@@ -98,7 +100,7 @@ describe :io_readlines_options_19, shared: true do
describe "when passed name, object, object" do
describe "when the first object is a Fixnum" do
it "uses the second object as an options Hash" do
- -> do
+ lambda do
IO.send(@method, @filename, 10, mode: "w", &@object)
end.should raise_error(IOError)
end
@@ -106,8 +108,8 @@ describe :io_readlines_options_19, shared: true do
it "calls #to_hash to convert the second object to a Hash" do
options = mock("io readlines options Hash")
options.should_receive(:to_hash).and_return({ mode: "w" })
- -> do
- IO.send(@method, @filename, 10, **options, &@object)
+ lambda do
+ IO.send(@method, @filename, 10, options, &@object)
end.should raise_error(IOError)
end
end
@@ -126,7 +128,7 @@ describe :io_readlines_options_19, shared: true do
end
it "uses the second object as an options Hash" do
- -> do
+ lambda do
IO.send(@method, @filename, " ", mode: "w", &@object)
end.should raise_error(IOError)
end
@@ -134,8 +136,8 @@ describe :io_readlines_options_19, shared: true do
it "calls #to_hash to convert the second object to a Hash" do
options = mock("io readlines options Hash")
options.should_receive(:to_hash).and_return({ mode: "w" })
- -> do
- IO.send(@method, @filename, " ", **options, &@object)
+ lambda do
+ IO.send(@method, @filename, " ", options, &@object)
end.should raise_error(IOError)
end
end
@@ -161,7 +163,7 @@ describe :io_readlines_options_19, shared: true do
end
it "uses the second object as an options Hash" do
- -> do
+ lambda do
IO.send(@method, @filename, " ", mode: "w", &@object)
end.should raise_error(IOError)
end
@@ -169,8 +171,8 @@ describe :io_readlines_options_19, shared: true do
it "calls #to_hash to convert the second object to a Hash" do
options = mock("io readlines options Hash")
options.should_receive(:to_hash).and_return({ mode: "w" })
- -> do
- IO.send(@method, @filename, " ", **options, &@object)
+ lambda do
+ IO.send(@method, @filename, " ", options, &@object)
end.should raise_error(IOError)
end
end
@@ -201,8 +203,8 @@ describe :io_readlines_options_19, shared: true do
it "calls #to_hash to convert the options object" do
options = mock("io readlines options Hash")
options.should_receive(:to_hash).and_return({ mode: "w" })
- -> do
- IO.send(@method, @filename, " ", 10, **options, &@object)
+ lambda do
+ IO.send(@method, @filename, " ", 10, options, &@object)
end.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/shared/tty.rb b/spec/ruby/core/io/shared/tty.rb
index 89ac08ec86..eddc5d15af 100644
--- a/spec/ruby/core/io/shared/tty.rb
+++ b/spec/ruby/core/io/shared/tty.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :io_tty, shared: true do
platform_is_not :windows do
@@ -7,7 +7,8 @@ describe :io_tty, shared: true do
# check to enabled tty
File.open('/dev/tty') {}
rescue Errno::ENXIO
- skip "workaround for not configured environment like OS X"
+ # workaround for not configured environment like OS X
+ 1.should == 1
else
File.open('/dev/tty') { |f| f.send(@method) }.should == true
end
@@ -19,6 +20,6 @@ describe :io_tty, shared: true do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send @method }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send @method }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/shared/write.rb b/spec/ruby/core/io/shared/write.rb
index 270b84ac39..fd4b0af30e 100644
--- a/spec/ruby/core/io/shared/write.rb
+++ b/spec/ruby/core/io/shared/write.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :io_write, shared: true do
before :each do
@@ -23,7 +23,7 @@ describe :io_write, shared: true do
end
it "checks if the file is writable if writing more than zero bytes" do
- -> { @readonly_file.send(@method, "abcde") }.should raise_error(IOError)
+ lambda { @readonly_file.send(@method, "abcde") }.should raise_error(IOError)
end
it "returns the number of bytes written" do
@@ -50,7 +50,7 @@ describe :io_write, shared: true do
it "does not warn if called after IO#read" do
@file.read(5)
- -> { @file.send(@method, "fghij") }.should_not complain
+ lambda { @file.send(@method, "fghij") }.should_not complain
end
it "writes to the current position after IO#read" do
@@ -66,44 +66,7 @@ describe :io_write, shared: true do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.send(@method, "hello") }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.send(@method, "hello") }.should raise_error(IOError)
end
- it "does not modify the passed argument" do
- File.open(@filename, "w") do |f|
- f.set_encoding(Encoding::IBM437)
- # A character whose codepoint differs between UTF-8 and IBM437
- f.write "Æ’".freeze
- end
-
- File.binread(@filename).bytes.should == [159]
- end
-
- describe "on a pipe" do
- before :each do
- @r, @w = IO.pipe
- end
-
- after :each do
- @r.close
- @w.close
- end
-
- it "writes the given String to the pipe" do
- @w.send(@method, "foo")
- @w.close
- @r.read.should == "foo"
- end
-
- # [ruby-core:90895] MJIT worker may leave fd open in a forked child.
- # For instance, MJIT creates a worker before @r.close with fork(), @r.close happens,
- # and the MJIT worker keeps the pipe open until the worker execve().
- # TODO: consider acquiring GVL from MJIT worker.
- guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do
- it "raises Errno::EPIPE if the read end is closed and does not die from SIGPIPE" do
- @r.close
- -> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/)
- end
- end
- end
end
diff --git a/spec/ruby/core/io/stat_spec.rb b/spec/ruby/core/io/stat_spec.rb
index 58eba02b8f..d59535843a 100644
--- a/spec/ruby/core/io/stat_spec.rb
+++ b/spec/ruby/core/io/stat_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#stat" do
before :each do
@@ -11,7 +11,7 @@ describe "IO#stat" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.stat }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.stat }.should raise_error(IOError)
end
it "returns a File::Stat object for the stream" do
diff --git a/spec/ruby/core/io/sync_spec.rb b/spec/ruby/core/io/sync_spec.rb
index 993b7ee244..5cd873d799 100644
--- a/spec/ruby/core/io/sync_spec.rb
+++ b/spec/ruby/core/io/sync_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#sync=" do
before :each do
@@ -27,7 +27,7 @@ describe "IO#sync=" do
end
it "raises an IOError on closed stream" do
- -> { IOSpecs.closed_io.sync = true }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.sync = true }.should raise_error(IOError)
end
end
@@ -45,7 +45,7 @@ describe "IO#sync" do
end
it "raises an IOError on closed stream" do
- -> { IOSpecs.closed_io.sync }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.sync }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/sysopen_spec.rb b/spec/ruby/core/io/sysopen_spec.rb
index 4607d13687..f6d37de364 100644
--- a/spec/ruby/core/io/sysopen_spec.rb
+++ b/spec/ruby/core/io/sysopen_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO.sysopen" do
before :each do
@@ -33,7 +33,7 @@ describe "IO.sysopen" do
end
it "accepts a mode as second argument" do
- -> { @fd = IO.sysopen(@filename, "w") }.should_not raise_error
+ lambda { @fd = IO.sysopen(@filename, "w") }.should_not raise_error
@fd.should_not equal(0)
end
diff --git a/spec/ruby/core/io/sysread_spec.rb b/spec/ruby/core/io/sysread_spec.rb
index 024200efea..bedcc31169 100644
--- a/spec/ruby/core/io/sysread_spec.rb
+++ b/spec/ruby/core/io/sysread_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#sysread on a file" do
before :each do
@@ -58,13 +58,13 @@ describe "IO#sysread on a file" do
it "does not raise error if called after IO#read followed by IO#write" do
@file.read(5)
@file.write("abcde")
- -> { @file.sysread(5) }.should_not raise_error(IOError)
+ lambda { @file.sysread(5) }.should_not raise_error(IOError)
end
it "does not raise error if called after IO#read followed by IO#syswrite" do
@file.read(5)
@file.syswrite("abcde")
- -> { @file.sysread(5) }.should_not raise_error(IOError)
+ lambda { @file.sysread(5) }.should_not raise_error(IOError)
end
it "reads updated content after the flushed buffered IO#write" do
@@ -77,7 +77,7 @@ describe "IO#sysread on a file" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.sysread(5) }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.sysread(5) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/sysseek_spec.rb b/spec/ruby/core/io/sysseek_spec.rb
index df894734e3..bcce968c7d 100644
--- a/spec/ruby/core/io/sysseek_spec.rb
+++ b/spec/ruby/core/io/sysseek_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "IO#sysseek" do
it_behaves_like :io_set_pos, :seek
@@ -23,7 +23,7 @@ describe "IO#sysseek" do
it "raises an error when called after buffered reads" do
@io.readline
- -> { @io.sysseek(-5, IO::SEEK_CUR) }.should raise_error(IOError)
+ lambda { @io.sysseek(-5, IO::SEEK_CUR) }.should raise_error(IOError)
end
it "moves the read position relative to the start with SEEK_SET" do
@@ -36,7 +36,7 @@ describe "IO#sysseek" do
# this is the safest way of checking the EOF when
# sys-* methods are invoked
- -> { @io.sysread(1) }.should raise_error(EOFError)
+ lambda { @io.sysread(1) }.should raise_error(EOFError)
@io.sysseek(-25, IO::SEEK_END)
@io.sysread(7).should == "cinco.\n"
diff --git a/spec/ruby/core/io/syswrite_spec.rb b/spec/ruby/core/io/syswrite_spec.rb
index a28cc62174..879423de2e 100644
--- a/spec/ruby/core/io/syswrite_spec.rb
+++ b/spec/ruby/core/io/syswrite_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/write'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/write', __FILE__)
describe "IO#syswrite on a file" do
before :each do
@@ -31,13 +31,13 @@ describe "IO#syswrite on a file" do
it "warns if called immediately after a buffered IO#write" do
@file.write("abcde")
- -> { @file.syswrite("fghij") }.should complain(/syswrite/)
+ lambda { @file.syswrite("fghij") }.should complain(/syswrite/)
end
it "does not warn if called after IO#write with intervening IO#sysread" do
@file.syswrite("abcde")
@file.sysread(5)
- -> { @file.syswrite("fghij") }.should_not complain
+ lambda { @file.syswrite("fghij") }.should_not complain
end
it "writes to the actual file position when called after buffered IO#read" do
@@ -49,23 +49,6 @@ describe "IO#syswrite on a file" do
end
end
-describe "IO#syswrite on a pipe" do
- it "returns the written bytes if the fd is in nonblock mode and write would block" do
- require 'io/nonblock'
- r, w = IO.pipe
- begin
- w.nonblock = true
- larger_than_pipe_capacity = 2 * 1024 * 1024
- written = w.syswrite("a"*larger_than_pipe_capacity)
- written.should > 0
- written.should < larger_than_pipe_capacity
- ensure
- w.close
- r.close
- end
- end
-end
-
describe "IO#syswrite" do
it_behaves_like :io_write, :syswrite
end
diff --git a/spec/ruby/core/io/tell_spec.rb b/spec/ruby/core/io/tell_spec.rb
index 0d6c6b02d3..d2f523cf10 100644
--- a/spec/ruby/core/io/tell_spec.rb
+++ b/spec/ruby/core/io/tell_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/pos', __FILE__)
describe "IO#tell" do
- it_behaves_like :io_pos, :tell
+ it_behaves_like(:io_pos, :tell)
end
diff --git a/spec/ruby/core/io/to_i_spec.rb b/spec/ruby/core/io/to_i_spec.rb
index acf138c663..bbe656cdcc 100644
--- a/spec/ruby/core/io/to_i_spec.rb
+++ b/spec/ruby/core/io/to_i_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#to_i" do
it "returns the numeric file descriptor of the given IO object" do
@@ -7,6 +7,6 @@ describe "IO#to_i" do
end
it "raises IOError on closed stream" do
- -> { IOSpecs.closed_io.to_i }.should raise_error(IOError)
+ lambda { IOSpecs.closed_io.to_i }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/to_io_spec.rb b/spec/ruby/core/io/to_io_spec.rb
index 55a0977740..76ebefb38f 100644
--- a/spec/ruby/core/io/to_io_spec.rb
+++ b/spec/ruby/core/io/to_io_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#to_io" do
before :each do
diff --git a/spec/ruby/core/io/try_convert_spec.rb b/spec/ruby/core/io/try_convert_spec.rb
index 5fbd10b6fa..0326982ff1 100644
--- a/spec/ruby/core/io/try_convert_spec.rb
+++ b/spec/ruby/core/io/try_convert_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO.try_convert" do
before :each do
@@ -38,12 +38,12 @@ describe "IO.try_convert" do
it "raises a TypeError if the object does not return an IO from #to_io" do
obj = mock("io")
obj.should_receive(:to_io).and_return("io")
- -> { IO.try_convert(obj) }.should raise_error(TypeError)
+ lambda { IO.try_convert(obj) }.should raise_error(TypeError)
end
it "propagates an exception raised by #to_io" do
obj = mock("io")
obj.should_receive(:to_io).and_raise(TypeError.new)
- ->{ IO.try_convert(obj) }.should raise_error(TypeError)
+ lambda{ IO.try_convert(obj) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/io/tty_spec.rb b/spec/ruby/core/io/tty_spec.rb
index 3b76c6d2b8..3c1449b030 100644
--- a/spec/ruby/core/io/tty_spec.rb
+++ b/spec/ruby/core/io/tty_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/tty'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/tty', __FILE__)
describe "IO#tty?" do
it_behaves_like :io_tty, :tty?
diff --git a/spec/ruby/core/io/ungetbyte_spec.rb b/spec/ruby/core/io/ungetbyte_spec.rb
index 1971dee534..ee334b469b 100644
--- a/spec/ruby/core/io/ungetbyte_spec.rb
+++ b/spec/ruby/core/io/ungetbyte_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "IO#ungetbyte" do
before :each do
@@ -36,38 +36,13 @@ describe "IO#ungetbyte" do
@io.getbyte.should == 97
end
- ruby_version_is ''...'2.6' do
- it "puts back one byte for a Fixnum argument..." do
- @io.ungetbyte(4095).should be_nil
- @io.getbyte.should == 255
- end
-
- it "... but not for Bignum argument (eh?)" do
- -> {
- @io.ungetbyte(0x4f7574206f6620636861722072616e6765)
- }.should raise_error(TypeError)
- end
- end
-
- ruby_version_is '2.6'...'2.6.1' do
- it "is an RangeError if the integer is not in 8bit" do
- for i in [4095, 0x4f7574206f6620636861722072616e6765] do
- -> { @io.ungetbyte(i) }.should raise_error(RangeError)
- end
- end
- end
-
- ruby_version_is '2.6.1' do
- it "never raises RangeError" do
- for i in [4095, 0x4f7574206f6620636861722072616e67ff] do
- @io.ungetbyte(i).should be_nil
- @io.getbyte.should == 255
- end
- end
+ it "puts back one byte for an Integer argument" do
+ @io.ungetbyte(4095).should be_nil
+ @io.getbyte.should == 255
end
it "raises an IOError if the IO is closed" do
@io.close
- -> { @io.ungetbyte(42) }.should raise_error(IOError)
+ lambda { @io.ungetbyte(42) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/ungetc_spec.rb b/spec/ruby/core/io/ungetc_spec.rb
index 34d4caf745..ce4cc9d346 100644
--- a/spec/ruby/core/io/ungetc_spec.rb
+++ b/spec/ruby/core/io/ungetc_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "IO#ungetc" do
before :each do
@@ -31,22 +31,6 @@ describe "IO#ungetc" do
@io.getc.should == ?c
end
- it "interprets the codepoint in the external encoding" do
- @io.set_encoding(Encoding::UTF_8)
- @io.ungetc(233)
- c = @io.getc
- c.encoding.should == Encoding::UTF_8
- c.should == "é"
- c.bytes.should == [195, 169]
-
- @io.set_encoding(Encoding::IBM437)
- @io.ungetc(130)
- c = @io.getc
- c.encoding.should == Encoding::IBM437
- c.bytes.should == [130]
- c.encode(Encoding::UTF_8).should == "é"
- end
-
it "pushes back one character when invoked at the end of the stream" do
# read entire content
@io.read
@@ -100,7 +84,7 @@ describe "IO#ungetc" do
it "makes subsequent unbuffered operations to raise IOError" do
@io.getc
@io.ungetc(100)
- -> { @io.sysread(1) }.should raise_error(IOError)
+ lambda { @io.sysread(1) }.should raise_error(IOError)
end
it "does not affect the stream and returns nil when passed nil" do
@@ -130,6 +114,6 @@ describe "IO#ungetc" do
it "raises IOError on closed stream" do
@io.getc
@io.close
- -> { @io.ungetc(100) }.should raise_error(IOError)
+ lambda { @io.ungetc(100) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/core/io/write_nonblock_spec.rb b/spec/ruby/core/io/write_nonblock_spec.rb
index 5474e5c6ce..751a36aade 100644
--- a/spec/ruby/core/io/write_nonblock_spec.rb
+++ b/spec/ruby/core/io/write_nonblock_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/write'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/write', __FILE__)
# See https://bugs.ruby-lang.org/issues/5954#note-5
platform_is_not :windows do
@@ -32,7 +32,7 @@ platform_is_not :windows do
end
it "checks if the file is writable if writing zero bytes" do
- -> {
+ lambda {
@readonly_file.write_nonblock("")
}.should raise_error(IOError)
end
@@ -54,7 +54,7 @@ describe 'IO#write_nonblock' do
end
it "raises an exception extending IO::WaitWritable when the write would block" do
- -> {
+ lambda {
loop { @write.write_nonblock('a' * 10_000) }
}.should raise_error(IO::WaitWritable) { |e|
platform_is_not :windows do
@@ -66,18 +66,19 @@ describe 'IO#write_nonblock' do
}
end
- context "when exception option is set to false" do
- it "returns :wait_writable when the operation would block" do
- loop {
- break if @write.write_nonblock("a" * 10_000, exception: false) == :wait_writable
- }
- @write.write_nonblock("a" * 10_000, exception: false).should == :wait_writable
+ ruby_version_is "2.3" do
+ context "when exception option is set to false" do
+ it "returns :wait_writable when the operation would block" do
+ loop { break if @write.write_nonblock("a" * 10_000, exception: false) == :wait_writable }
+ 1.should == 1
+ end
end
end
platform_is_not :windows do
it 'sets the IO in nonblock mode' do
require 'io/nonblock'
+ @write.nonblock?.should == false
@write.write_nonblock('a')
@write.nonblock?.should == true
end
diff --git a/spec/ruby/core/io/write_spec.rb b/spec/ruby/core/io/write_spec.rb
index b28b582019..1011efe8d5 100644
--- a/spec/ruby/core/io/write_spec.rb
+++ b/spec/ruby/core/io/write_spec.rb
@@ -1,8 +1,8 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/write'
-require_relative 'shared/binwrite'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/write', __FILE__)
+require File.expand_path('../shared/binwrite', __FILE__)
describe "IO#write on a file" do
before :each do
@@ -21,56 +21,58 @@ describe "IO#write on a file" do
end
it "does not check if the file is writable if writing zero bytes" do
- -> { @readonly_file.write("") }.should_not raise_error
+ lambda { @readonly_file.write("") }.should_not raise_error
end
it "returns a length of 0 when writing a blank string" do
@file.write('').should == 0
end
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
+ with_feature :encoding do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
- Encoding.default_external = Encoding::UTF_8
- end
+ Encoding.default_external = Encoding::UTF_8
+ end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+ end
- it "returns the number of bytes written" do
- @file.write("hellø").should == 6
- end
+ it "returns the number of bytes written" do
+ @file.write("hellø").should == 6
+ end
- it "uses the encoding from the given option for non-ascii encoding" do
- File.open(@filename, "w", encoding: Encoding::UTF_32LE) do |file|
- file.write("hi").should == 8
+ it "uses the encoding from the given option for non-ascii encoding" do
+ File.open(@filename, "w", encoding: Encoding::UTF_32LE) do |file|
+ file.write("hi").should == 8
+ end
+ File.binread(@filename).should == "h\u0000\u0000\u0000i\u0000\u0000\u0000"
end
- File.binread(@filename).should == "h\u0000\u0000\u0000i\u0000\u0000\u0000"
- end
- it "uses an :open_args option" do
- IO.write(@filename, 'hi', open_args: ["w", nil, {encoding: Encoding::UTF_32LE}]).should == 8
- end
+ it "uses an :open_args option" do
+ IO.write(@filename, 'hi', open_args: ["w", nil, {encoding: Encoding::UTF_32LE}]).should == 8
+ end
- it "raises a invalid byte sequence error if invalid bytes are being written" do
- # pack "\xFEhi" to avoid utf-8 conflict
- xFEhi = ([254].pack('C*') + 'hi').force_encoding('utf-8')
- File.open(@filename, "w", encoding: Encoding::US_ASCII) do |file|
- -> { file.write(xFEhi) }.should raise_error(Encoding::InvalidByteSequenceError)
+ it "raises a invalid byte sequence error if invalid bytes are being written" do
+ # pack "\xFEhi" to avoid utf-8 conflict
+ xFEhi = ([254].pack('C*') + 'hi').force_encoding('utf-8')
+ File.open(@filename, "w", encoding: Encoding::US_ASCII) do |file|
+ lambda { file.write(xFEhi) }.should raise_error(Encoding::InvalidByteSequenceError)
+ end
end
- end
- it "writes binary data if no encoding is given" do
- File.open(@filename, "w") do |file|
- file.write('Hëllö'.encode('ISO-8859-1'))
+ it "writes binary data if no encoding is given" do
+ File.open(@filename, "w") do |file|
+ file.write('Hëllö'.encode('ISO-8859-1'))
+ end
+ ë = ([235].pack('U')).encode('ISO-8859-1')
+ ö = ([246].pack('U')).encode('ISO-8859-1')
+ res = "H#{ë}ll#{ö}"
+ File.binread(@filename).should == res.force_encoding(Encoding::ASCII_8BIT)
end
- ë = ([235].pack('U')).encode('ISO-8859-1')
- ö = ([246].pack('U')).encode('ISO-8859-1')
- res = "H#{ë}ll#{ö}"
- File.binread(@filename).should == res.force_encoding(Encoding::BINARY)
end
end
@@ -94,14 +96,14 @@ describe "IO.write" do
IO.write(@filename, 'Hëllö'.encode('ISO-8859-1'))
xEB = [235].pack('C*')
xF6 = [246].pack('C*')
- File.binread(@filename).should == ("H" + xEB + "ll" + xF6).force_encoding(Encoding::BINARY)
+ File.binread(@filename).should == ("H" + xEB + "ll" + xF6).force_encoding(Encoding::ASCII_8BIT)
end
platform_is_not :windows do
describe "on a FIFO" do
before :each do
@fifo = tmp("File_open_fifo")
- File.mkfifo(@fifo)
+ system "mkfifo #{@fifo}"
end
after :each do
@@ -125,17 +127,6 @@ end
describe "IO#write" do
it_behaves_like :io_write, :write
-
- ruby_version_is "2.5" do
- it "accepts multiple arguments" do
- IO.pipe do |r, w|
- w.write("foo", "bar")
- w.close
-
- r.read.should == "foobar"
- end
- end
- end
end
platform_is :windows do
diff --git a/spec/ruby/core/kernel/Array_spec.rb b/spec/ruby/core/kernel/Array_spec.rb
index b4a8bb7599..6031a828f6 100644
--- a/spec/ruby/core/kernel/Array_spec.rb
+++ b/spec/ruby/core/kernel/Array_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel" do
it "has private instance method Array()" do
@@ -77,14 +77,14 @@ describe :kernel_Array, shared: true do
obj = mock("Array() string")
obj.should_receive(:to_ary).and_return("string")
- -> { @object.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_a does not return an Array" do
obj = mock("Array() string")
obj.should_receive(:to_a).and_return("string")
- -> { @object.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/Complex_spec.rb b/spec/ruby/core/kernel/Complex_spec.rb
index 37f9843931..b156cc4549 100644
--- a/spec/ruby/core/kernel/Complex_spec.rb
+++ b/spec/ruby/core/kernel/Complex_spec.rb
@@ -1,187 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/Complex', __FILE__)
describe "Kernel.Complex()" do
- describe "when passed [Complex, Complex]" do
- it "returns a new Complex number based on the two given numbers" do
- Complex(Complex(3, 4), Complex(5, 6)).should == Complex(3 - 6, 4 + 5)
- Complex(Complex(1.5, 2), Complex(-5, 6.3)).should == Complex(1.5 - 6.3, 2 - 5)
- end
- end
-
- describe "when passed [Complex]" do
- it "returns the passed Complex number" do
- Complex(Complex(1, 2)).should == Complex(1, 2)
- Complex(Complex(-3.4, bignum_value)).should == Complex(-3.4, bignum_value)
- end
- end
-
- describe "when passed [Integer, Integer]" do
- it "returns a new Complex number" do
- Complex(1, 2).should be_an_instance_of(Complex)
- Complex(1, 2).real.should == 1
- Complex(1, 2).imag.should == 2
-
- Complex(-3, -5).should be_an_instance_of(Complex)
- Complex(-3, -5).real.should == -3
- Complex(-3, -5).imag.should == -5
-
- Complex(3.5, -4.5).should be_an_instance_of(Complex)
- Complex(3.5, -4.5).real.should == 3.5
- Complex(3.5, -4.5).imag.should == -4.5
-
- Complex(bignum_value, 30).should be_an_instance_of(Complex)
- Complex(bignum_value, 30).real.should == bignum_value
- Complex(bignum_value, 30).imag.should == 30
- end
- end
-
- describe "when passed [Integer/Float]" do
- it "returns a new Complex number with 0 as the imaginary component" do
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
- Complex(1).should be_an_instance_of(Complex)
- Complex(1).imag.should == 0
- Complex(1).real.should == 1
-
- Complex(-3).should be_an_instance_of(Complex)
- Complex(-3).imag.should == 0
- Complex(-3).real.should == -3
-
- Complex(-4.5).should be_an_instance_of(Complex)
- Complex(-4.5).imag.should == 0
- Complex(-4.5).real.should == -4.5
-
- Complex(bignum_value).should be_an_instance_of(Complex)
- Complex(bignum_value).imag.should == 0
- Complex(bignum_value).real.should == bignum_value
- end
- end
- end
-
- describe "when passed a String" do
- it "needs to be reviewed for spec completeness"
- end
-
- describe "when passed an Object which responds to #to_c" do
- it "returns the passed argument" do
- obj = Object.new; def obj.to_c; 1i end
- Complex(obj).should == Complex(0, 1)
- end
- end
-
- describe "when passed a Numeric which responds to #real? with false" do
- it "returns the passed argument" do
- n = mock_numeric("unreal")
- n.should_receive(:real?).any_number_of_times.and_return(false)
- Complex(n).should equal(n)
- end
- end
-
- describe "when passed a Numeric which responds to #real? with true" do
- it "returns a Complex with the passed argument as the real component and 0 as the imaginary component" do
- n = mock_numeric("real")
- n.should_receive(:real?).any_number_of_times.and_return(true)
- result = Complex(n)
- result.real.should equal(n)
- result.imag.should equal(0)
- end
- end
-
- describe "when passed Numerics n1 and n2 and at least one responds to #real? with false" do
- [[false, false], [false, true], [true, false]].each do |r1, r2|
- it "returns n1 + n2 * Complex(0, 1)" do
- n1 = mock_numeric("n1")
- n2 = mock_numeric("n2")
- n3 = mock_numeric("n3")
- n4 = mock_numeric("n4")
- n1.should_receive(:real?).any_number_of_times.and_return(r1)
- n2.should_receive(:real?).any_number_of_times.and_return(r2)
- n2.should_receive(:*).with(Complex(0, 1)).and_return(n3)
- n1.should_receive(:+).with(n3).and_return(n4)
- Complex(n1, n2).should equal(n4)
- end
- end
- end
-
- describe "when passed two Numerics and both respond to #real? with true" do
- it "returns a Complex with the passed arguments as real and imaginary components respectively" do
- n1 = mock_numeric("n1")
- n2 = mock_numeric("n2")
- n1.should_receive(:real?).any_number_of_times.and_return(true)
- n2.should_receive(:real?).any_number_of_times.and_return(true)
- result = Complex(n1, n2)
- result.real.should equal(n1)
- result.imag.should equal(n2)
- end
- end
-
- describe "when passed a single non-Numeric" do
- it "coerces the passed argument using #to_c" do
- n = mock("n")
- c = Complex(0, 0)
- n.should_receive(:to_c).and_return(c)
- Complex(n).should equal(c)
- end
- end
-
- describe "when passed a non-Numeric second argument" do
- it "raises TypeError" do
- -> { Complex(:sym, :sym) }.should raise_error(TypeError)
- -> { Complex(0, :sym) }.should raise_error(TypeError)
- end
- end
-
- describe "when passed nil" do
- it "raises TypeError" do
- -> { Complex(nil) }.should raise_error(TypeError, "can't convert nil into Complex")
- -> { Complex(0, nil) }.should raise_error(TypeError, "can't convert nil into Complex")
- -> { Complex(nil, 0) }.should raise_error(TypeError, "can't convert nil into Complex")
- end
- end
-
- ruby_version_is "2.6" do
- describe "when passed exception: false" do
- describe "and [Numeric]" do
- it "returns a complex number" do
- Complex("123", exception: false).should == Complex(123)
- end
- end
-
- describe "and [non-Numeric]" do
- it "swallows an error" do
- Complex(:sym, exception: false).should == nil
- end
- end
-
- describe "and [non-Numeric, Numeric] argument" do
- it "throws a TypeError" do
- -> { Complex(:sym, 0, exception: false) }.should raise_error(TypeError, "not a real")
- end
- end
-
- describe "and [anything, non-Numeric] argument" do
- it "swallows an error" do
- Complex("a", :sym, exception: false).should == nil
- Complex(:sym, :sym, exception: false).should == nil
- Complex(0, :sym, exception: false).should == nil
- end
- end
-
- describe "and non-numeric String arguments" do
- it "swallows an error" do
- Complex("a", "b", exception: false).should == nil
- Complex("a", 0, exception: false).should == nil
- Complex(0, "b", exception: false).should == nil
- end
- end
-
- describe "and nil arguments" do
- it "swallows an error" do
- Complex(nil, exception: false).should == nil
- Complex(0, nil, exception: false).should == nil
- Complex(nil, 0, exception: false).should == nil
- end
- end
- end
- end
+ it_behaves_like :kernel_Complex, :Complex
end
diff --git a/spec/ruby/core/kernel/Float_spec.rb b/spec/ruby/core/kernel/Float_spec.rb
index 6580c38137..ee20190094 100644
--- a/spec/ruby/core/kernel/Float_spec.rb
+++ b/spec/ruby/core/kernel/Float_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_float, shared: true do
it "returns the identical Float for numeric Floats" do
float = 1.12
float2 = @object.send(:Float, float)
float2.should == float
- float2.should equal float
+ float2.object_id.should == float.object_id
end
it "returns a Float for Fixnums" do
@@ -22,7 +22,7 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError for nil" do
- -> { @object.send(:Float, nil) }.should raise_error(TypeError)
+ lambda { @object.send(:Float, nil) }.should raise_error(TypeError)
end
it "returns the identical NaN for NaN" do
@@ -51,24 +51,24 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError for a String of word characters" do
- -> { @object.send(:Float, "float") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "float") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are two decimal points in the String" do
- -> { @object.send(:Float, "10.0.0") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "10.0.0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String of numbers followed by word characters" do
- -> { @object.send(:Float, "10D") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "10D") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String of word characters followed by numbers" do
- -> { @object.send(:Float, "D10") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "D10") }.should raise_error(ArgumentError)
end
it "is strict about the string form even across newlines" do
- -> { @object.send(:Float, "not a number\n10") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "10\nnot a number") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "not a number\n10") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "10\nnot a number") }.should raise_error(ArgumentError)
end
it "converts String subclasses to floats without calling #to_f" do
@@ -90,17 +90,17 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if a + or - is embedded in a String" do
- -> { @object.send(:Float, "1+1") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "1-1") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "1+1") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "1-1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if a String has a trailing + or -" do
- -> { @object.send(:Float, "11+") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "11-") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "11+") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "11-") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with a leading _" do
- -> { @object.send(:Float, "_1") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "_1") }.should raise_error(ArgumentError)
end
it "returns a value for a String with an embedded _" do
@@ -108,31 +108,31 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError for a String with a trailing _" do
- -> { @object.send(:Float, "10_") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "10_") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String of \\0" do
- -> { @object.send(:Float, "\0") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with a leading \\0" do
- -> { @object.send(:Float, "\01") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "\01") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with an embedded \\0" do
- -> { @object.send(:Float, "1\01") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "1\01") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with a trailing \\0" do
- -> { @object.send(:Float, "1\0") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "1\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String that is just an empty space" do
- -> { @object.send(:Float, " ") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, " ") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String that with an embedded space" do
- -> { @object.send(:Float, "1 2") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "1 2") }.should raise_error(ArgumentError)
end
it "returns a value for a String with a leading space" do
@@ -153,11 +153,11 @@ describe :kernel_float, shared: true do
%w(e E).each do |e|
it "raises an ArgumentError if #{e} is the trailing character" do
- -> { @object.send(:Float, "2#{e}") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "2#{e}") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if #{e} is the leading character" do
- -> { @object.send(:Float, "#{e}2") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "#{e}2") }.should raise_error(ArgumentError)
end
it "returns Infinity for '2#{e}1000'" do
@@ -175,18 +175,18 @@ describe :kernel_float, shared: true do
end
it "raises an exception if a space is embedded on either side of the '#{e}'" do
- -> { @object.send(:Float, "2 0#{e}100") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "20#{e}1 00") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "2 0#{e}100") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "20#{e}1 00") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a leading _ on either side of the '#{e}'" do
- -> { @object.send(:Float, "_20#{e}100") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "20#{e}_100") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "_20#{e}100") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "20#{e}_100") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a trailing _ on either side of the '#{e}'" do
- -> { @object.send(:Float, "20_#{e}100") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "20#{e}100_") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "20_#{e}100") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "20#{e}100_") }.should raise_error(ArgumentError)
end
it "allows decimal points on the left side of the '#{e}'" do
@@ -194,7 +194,7 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if there's a decimal point on the right side of the '#{e}'" do
- -> { @object.send(:Float, "20#{e}2.0") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "20#{e}2.0") }.should raise_error(ArgumentError)
end
end
@@ -209,11 +209,11 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if #{p} is the trailing character" do
- -> { @object.send(:Float, "0x1#{p}") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x1#{p}") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if #{p} is the leading character" do
- -> { @object.send(:Float, "0x#{p}1") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x#{p}1") }.should raise_error(ArgumentError)
end
it "returns Infinity for '0x1#{p}10000'" do
@@ -231,18 +231,18 @@ describe :kernel_float, shared: true do
end
it "raises an exception if a space is embedded on either side of the '#{p}'" do
- -> { @object.send(:Float, "0x1 0#{p}10") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "0x10#{p}1 0") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x1 0#{p}10") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x10#{p}1 0") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a leading _ on either side of the '#{p}'" do
- -> { @object.send(:Float, "0x_10#{p}10") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "0x10#{p}_10") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x_10#{p}10") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x10#{p}_10") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a trailing _ on either side of the '#{p}'" do
- -> { @object.send(:Float, "0x10_#{p}10") }.should raise_error(ArgumentError)
- -> { @object.send(:Float, "0x10#{p}10_") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x10_#{p}10") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x10#{p}10_") }.should raise_error(ArgumentError)
end
it "allows hexadecimal points on the left side of the '#{p}'" do
@@ -250,7 +250,7 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if there's a decimal point on the right side of the '#{p}'" do
- -> { @object.send(:Float, "0x1#{p}1.0") }.should raise_error(ArgumentError)
+ lambda { @object.send(:Float, "0x1#{p}1.0") }.should raise_error(ArgumentError)
end
end
end
@@ -282,47 +282,22 @@ describe :kernel_float, shared: true do
end
it "raises a TypeError if #to_f is not provided" do
- -> { @object.send(:Float, mock('x')) }.should raise_error(TypeError)
+ lambda { @object.send(:Float, mock('x')) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_f returns a String" do
(obj = mock('ha!')).should_receive(:to_f).once.and_return('ha!')
- -> { @object.send(:Float, obj) }.should raise_error(TypeError)
+ lambda { @object.send(:Float, obj) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_f returns an Integer" do
(obj = mock('123')).should_receive(:to_f).once.and_return(123)
- -> { @object.send(:Float, obj) }.should raise_error(TypeError)
+ lambda { @object.send(:Float, obj) }.should raise_error(TypeError)
end
it "raises a RangeError when passed a Complex argument" do
c = Complex(2, 3)
- -> { @object.send(:Float, c) }.should raise_error(RangeError)
- end
-
- ruby_version_is "2.6" do
- describe "when passed exception: false" do
- describe "and valid input" do
- it "returns a Float number" do
- @object.send(:Float, 1, exception: false).should == 1.0
- @object.send(:Float, "1", exception: false).should == 1.0
- @object.send(:Float, "1.23", exception: false).should == 1.23
- end
- end
-
- describe "and invalid input" do
- it "swallows an error" do
- @object.send(:Float, "abc", exception: false).should == nil
- @object.send(:Float, :sym, exception: false).should == nil
- end
- end
-
- describe "and nil" do
- it "swallows it" do
- @object.send(:Float, nil, exception: false).should == nil
- end
- end
- end
+ lambda { @object.send(:Float, c) }.should raise_error(RangeError)
end
end
diff --git a/spec/ruby/core/kernel/Hash_spec.rb b/spec/ruby/core/kernel/Hash_spec.rb
index cbe098a8ac..8d51316c75 100644
--- a/spec/ruby/core/kernel/Hash_spec.rb
+++ b/spec/ruby/core/kernel/Hash_spec.rb
@@ -1,14 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#hash" do
- it "is provided" do
- 1.respond_to?(:hash).should == true
- end
-
- it "is stable" do
- 1.hash.should == 1.hash
- end
+ it "needs to be reviewed for spec completeness"
end
describe "Kernel" do
@@ -43,14 +37,14 @@ describe :kernel_Hash, shared: true do
end
it "raises a TypeError if it doesn't respond to #to_hash" do
- -> { @object.send(@method, mock("")) }.should raise_error(TypeError)
+ lambda { @object.send(@method, mock("")) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_hash does not return an Hash" do
obj = mock("Hash() string")
obj.should_receive(:to_hash).and_return("string")
- -> { @object.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/Integer_spec.rb b/spec/ruby/core/kernel/Integer_spec.rb
index 59b41d37e6..1e95fc9151 100644
--- a/spec/ruby/core/kernel/Integer_spec.rb
+++ b/spec/ruby/core/kernel/Integer_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_integer, shared: true do
it "returns a Bignum for a Bignum" do
@@ -10,33 +10,15 @@ describe :kernel_integer, shared: true do
Integer(100).should == 100
end
- ruby_version_is ""..."2.6" do
- it "uncritically return the value of to_int even if it is not an Integer" do
- obj = mock("object")
- obj.should_receive(:to_int).and_return("1")
- obj.should_not_receive(:to_i)
- Integer(obj).should == "1"
- end
- end
-
- ruby_version_is "2.6" do
- it "raises a TypeError when to_int returns not-an-Integer object and to_i returns nil" do
- obj = mock("object")
- obj.should_receive(:to_int).and_return("1")
- obj.should_receive(:to_i).and_return(nil)
- -> { Integer(obj) }.should raise_error(TypeError)
- end
-
- it "return a result of to_i when to_int does not return an Integer" do
- obj = mock("object")
- obj.should_receive(:to_int).and_return("1")
- obj.should_receive(:to_i).and_return(42)
- Integer(obj).should == 42
- end
+ it "uncritically return the value of to_int even if it is not an Integer" do
+ obj = mock("object")
+ obj.should_receive(:to_int).and_return("1")
+ obj.should_not_receive(:to_i)
+ Integer(obj).should == "1"
end
it "raises a TypeError when passed nil" do
- -> { Integer(nil) }.should raise_error(TypeError)
+ lambda { Integer(nil) }.should raise_error(TypeError)
end
it "returns a Fixnum or Bignum object" do
@@ -63,9 +45,9 @@ describe :kernel_integer, shared: true do
it "returns the value of to_int if the result is a Bignum" do
obj = mock("object")
- obj.should_receive(:to_int).and_return(2 * 10**100)
+ obj.should_receive(:to_int).and_return(2e100)
obj.should_not_receive(:to_i)
- Integer(obj).should == 2 * 10**100
+ Integer(obj).should == 2e100
end
it "calls to_i on an object whose to_int returns nil" do
@@ -78,101 +60,44 @@ describe :kernel_integer, shared: true do
it "raises a TypeError if to_i returns a value that is not an Integer" do
obj = mock("object")
obj.should_receive(:to_i).and_return("1")
- -> { Integer(obj) }.should raise_error(TypeError)
+ lambda { Integer(obj) }.should raise_error(TypeError)
end
it "raises a TypeError if no to_int or to_i methods exist" do
obj = mock("object")
- -> { Integer(obj) }.should raise_error(TypeError)
+ lambda { Integer(obj) }.should raise_error(TypeError)
end
it "raises a TypeError if to_int returns nil and no to_i exists" do
obj = mock("object")
obj.should_receive(:to_i).and_return(nil)
- -> { Integer(obj) }.should raise_error(TypeError)
+ lambda { Integer(obj) }.should raise_error(TypeError)
end
it "raises a FloatDomainError when passed NaN" do
- -> { Integer(nan_value) }.should raise_error(FloatDomainError)
+ lambda { Integer(nan_value) }.should raise_error(FloatDomainError)
end
it "raises a FloatDomainError when passed Infinity" do
- -> { Integer(infinity_value) }.should raise_error(FloatDomainError)
- end
-
- ruby_version_is "2.6" do
- describe "when passed exception: false" do
- describe "and to_i returns a value that is not an Integer" do
- it "swallows an error" do
- obj = mock("object")
- obj.should_receive(:to_i).and_return("1")
- Integer(obj, exception: false).should == nil
- end
- end
-
- describe "and no to_int or to_i methods exist" do
- it "swallows an error" do
- obj = mock("object")
- Integer(obj, exception: false).should == nil
- end
- end
-
- describe "and to_int returns nil and no to_i exists" do
- it "swallows an error" do
- obj = mock("object")
- obj.should_receive(:to_i).and_return(nil)
- Integer(obj, exception: false).should == nil
- end
- end
-
- describe "and passed NaN" do
- it "swallows an error" do
- Integer(nan_value, exception: false).should == nil
- end
- end
-
- describe "and passed Infinity" do
- it "swallows an error" do
- Integer(infinity_value, exception: false).should == nil
- end
- end
-
- describe "and passed nil" do
- it "swallows an error" do
- Integer(nil, exception: false).should == nil
- end
- end
-
- describe "and passed a String that contains numbers" do
- it "normally parses it and returns an Integer" do
- Integer("42", exception: false).should == 42
- end
- end
-
- describe "and passed a String that can't be converted to an Integer" do
- it "swallows an error" do
- Integer("abc", exception: false).should == nil
- end
- end
- end
+ lambda { Integer(infinity_value) }.should raise_error(FloatDomainError)
end
end
describe "Integer() given a String", shared: true do
it "raises an ArgumentError if the String is a null byte" do
- -> { Integer("\0") }.should raise_error(ArgumentError)
+ lambda { Integer("\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String starts with a null byte" do
- -> { Integer("\01") }.should raise_error(ArgumentError)
+ lambda { Integer("\01") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String ends with a null byte" do
- -> { Integer("1\0") }.should raise_error(ArgumentError)
+ lambda { Integer("1\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String contains a null byte" do
- -> { Integer("1\01") }.should raise_error(ArgumentError)
+ lambda { Integer("1\01") }.should raise_error(ArgumentError)
end
it "ignores leading whitespace" do
@@ -188,13 +113,13 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there are leading _s" do
- -> { Integer("_1") }.should raise_error(ArgumentError)
- -> { Integer("___1") }.should raise_error(ArgumentError)
+ lambda { Integer("_1") }.should raise_error(ArgumentError)
+ lambda { Integer("___1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing _s" do
- -> { Integer("1_") }.should raise_error(ArgumentError)
- -> { Integer("1___") }.should raise_error(ArgumentError)
+ lambda { Integer("1_") }.should raise_error(ArgumentError)
+ lambda { Integer("1___") }.should raise_error(ArgumentError)
end
it "ignores an embedded _" do
@@ -202,8 +127,8 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there are multiple embedded _s" do
- -> { Integer("1__1") }.should raise_error(ArgumentError)
- -> { Integer("1___1") }.should raise_error(ArgumentError)
+ lambda { Integer("1__1") }.should raise_error(ArgumentError)
+ lambda { Integer("1___1") }.should raise_error(ArgumentError)
end
it "ignores a single leading +" do
@@ -211,17 +136,17 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there is a space between the + and number" do
- -> { Integer("+ 1") }.should raise_error(ArgumentError)
+ lambda { Integer("+ 1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are multiple leading +s" do
- -> { Integer("++1") }.should raise_error(ArgumentError)
- -> { Integer("+++1") }.should raise_error(ArgumentError)
+ lambda { Integer("++1") }.should raise_error(ArgumentError)
+ lambda { Integer("+++1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing +s" do
- -> { Integer("1+") }.should raise_error(ArgumentError)
- -> { Integer("1+++") }.should raise_error(ArgumentError)
+ lambda { Integer("1+") }.should raise_error(ArgumentError)
+ lambda { Integer("1+++") }.should raise_error(ArgumentError)
end
it "makes the number negative if there's a leading -" do
@@ -229,49 +154,21 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there are multiple leading -s" do
- -> { Integer("--1") }.should raise_error(ArgumentError)
- -> { Integer("---1") }.should raise_error(ArgumentError)
+ lambda { Integer("--1") }.should raise_error(ArgumentError)
+ lambda { Integer("---1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing -s" do
- -> { Integer("1-") }.should raise_error(ArgumentError)
- -> { Integer("1---") }.should raise_error(ArgumentError)
+ lambda { Integer("1-") }.should raise_error(ArgumentError)
+ lambda { Integer("1---") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there is a period" do
- -> { Integer("0.0") }.should raise_error(ArgumentError)
+ lambda { Integer("0.0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for an empty String" do
- -> { Integer("") }.should raise_error(ArgumentError)
- end
-
- ruby_version_is "2.6" do
- describe "when passed exception: false" do
- describe "and multiple leading -s" do
- it "swallows an error" do
- Integer("---1", exception: false).should == nil
- end
- end
-
- describe "and multiple trailing -s" do
- it "swallows an error" do
- Integer("1---", exception: false).should == nil
- end
- end
-
- describe "and an argument that contains a period" do
- it "swallows an error" do
- Integer("0.0", exception: false).should == nil
- end
- end
-
- describe "and an empty string" do
- it "swallows an error" do
- Integer("", exception: false).should == nil
- end
- end
- end
+ lambda { Integer("") }.should raise_error(ArgumentError)
end
it "parses the value as 0 if the string consists of a single zero character" do
@@ -295,7 +192,7 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as hex" do
- -> { Integer("0#{x}g") }.should raise_error(ArgumentError)
+ lambda { Integer("0#{x}g") }.should raise_error(ArgumentError)
end
end
@@ -316,7 +213,7 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as binary" do
- -> { Integer("0#{b}2") }.should raise_error(ArgumentError)
+ lambda { Integer("0#{b}2") }.should raise_error(ArgumentError)
end
end
@@ -337,7 +234,7 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as octal" do
- -> { Integer("0#{o}9") }.should raise_error(ArgumentError)
+ lambda { Integer("0#{o}9") }.should raise_error(ArgumentError)
end
end
@@ -358,26 +255,26 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as decimal" do
- -> { Integer("0#{d}a") }.should raise_error(ArgumentError)
+ lambda { Integer("0#{d}a") }.should raise_error(ArgumentError)
end
end
end
describe "Integer() given a String and base", shared: true do
it "raises an ArgumentError if the String is a null byte" do
- -> { Integer("\0", 2) }.should raise_error(ArgumentError)
+ lambda { Integer("\0", 2) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String starts with a null byte" do
- -> { Integer("\01", 3) }.should raise_error(ArgumentError)
+ lambda { Integer("\01", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String ends with a null byte" do
- -> { Integer("1\0", 4) }.should raise_error(ArgumentError)
+ lambda { Integer("1\0", 4) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String contains a null byte" do
- -> { Integer("1\01", 5) }.should raise_error(ArgumentError)
+ lambda { Integer("1\01", 5) }.should raise_error(ArgumentError)
end
it "ignores leading whitespace" do
@@ -393,13 +290,13 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there are leading _s" do
- -> { Integer("_1", 7) }.should raise_error(ArgumentError)
- -> { Integer("___1", 7) }.should raise_error(ArgumentError)
+ lambda { Integer("_1", 7) }.should raise_error(ArgumentError)
+ lambda { Integer("___1", 7) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing _s" do
- -> { Integer("1_", 12) }.should raise_error(ArgumentError)
- -> { Integer("1___", 12) }.should raise_error(ArgumentError)
+ lambda { Integer("1_", 12) }.should raise_error(ArgumentError)
+ lambda { Integer("1___", 12) }.should raise_error(ArgumentError)
end
it "ignores an embedded _" do
@@ -407,8 +304,8 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there are multiple embedded _s" do
- -> { Integer("1__1", 4) }.should raise_error(ArgumentError)
- -> { Integer("1___1", 4) }.should raise_error(ArgumentError)
+ lambda { Integer("1__1", 4) }.should raise_error(ArgumentError)
+ lambda { Integer("1___1", 4) }.should raise_error(ArgumentError)
end
it "ignores a single leading +" do
@@ -416,17 +313,17 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there is a space between the + and number" do
- -> { Integer("+ 1", 3) }.should raise_error(ArgumentError)
+ lambda { Integer("+ 1", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are multiple leading +s" do
- -> { Integer("++1", 3) }.should raise_error(ArgumentError)
- -> { Integer("+++1", 3) }.should raise_error(ArgumentError)
+ lambda { Integer("++1", 3) }.should raise_error(ArgumentError)
+ lambda { Integer("+++1", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing +s" do
- -> { Integer("1+", 3) }.should raise_error(ArgumentError)
- -> { Integer("1+++", 12) }.should raise_error(ArgumentError)
+ lambda { Integer("1+", 3) }.should raise_error(ArgumentError)
+ lambda { Integer("1+++", 12) }.should raise_error(ArgumentError)
end
it "makes the number negative if there's a leading -" do
@@ -434,29 +331,29 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there are multiple leading -s" do
- -> { Integer("--1", 9) }.should raise_error(ArgumentError)
- -> { Integer("---1", 9) }.should raise_error(ArgumentError)
+ lambda { Integer("--1", 9) }.should raise_error(ArgumentError)
+ lambda { Integer("---1", 9) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing -s" do
- -> { Integer("1-", 12) }.should raise_error(ArgumentError)
- -> { Integer("1---", 12) }.should raise_error(ArgumentError)
+ lambda { Integer("1-", 12) }.should raise_error(ArgumentError)
+ lambda { Integer("1---", 12) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there is a period" do
- -> { Integer("0.0", 3) }.should raise_error(ArgumentError)
+ lambda { Integer("0.0", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for an empty String" do
- -> { Integer("", 12) }.should raise_error(ArgumentError)
+ lambda { Integer("", 12) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a base of 1" do
- -> { Integer("1", 1) }.should raise_error(ArgumentError)
+ lambda { Integer("1", 1) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a base of 37" do
- -> { Integer("1", 37) }.should raise_error(ArgumentError)
+ lambda { Integer("1", 37) }.should raise_error(ArgumentError)
end
it "accepts wholly lowercase alphabetic strings for bases > 10" do
@@ -484,8 +381,8 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError for letters invalid in the given base" do
- -> { Integer('z',19) }.should raise_error(ArgumentError)
- -> { Integer('c00o',2) }.should raise_error(ArgumentError)
+ lambda { Integer('z',19) }.should raise_error(ArgumentError)
+ lambda { Integer('c00o',2) }.should raise_error(ArgumentError)
end
%w(x X).each do |x|
@@ -506,12 +403,12 @@ describe "Integer() given a String and base", shared: true do
2.upto(15) do |base|
it "raises an ArgumentError if the number begins with 0#{x} and the base is #{base}" do
- -> { Integer("0#{x}1", base) }.should raise_error(ArgumentError)
+ lambda { Integer("0#{x}1", base) }.should raise_error(ArgumentError)
end
end
it "raises an ArgumentError if the number cannot be parsed as hex and the base is 16" do
- -> { Integer("0#{x}g", 16) }.should raise_error(ArgumentError)
+ lambda { Integer("0#{x}g", 16) }.should raise_error(ArgumentError)
end
end
@@ -532,7 +429,7 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as binary and the base is 2" do
- -> { Integer("0#{b}2", 2) }.should raise_error(ArgumentError)
+ lambda { Integer("0#{b}2", 2) }.should raise_error(ArgumentError)
end
end
@@ -553,12 +450,12 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as octal and the base is 8" do
- -> { Integer("0#{o}9", 8) }.should raise_error(ArgumentError)
+ lambda { Integer("0#{o}9", 8) }.should raise_error(ArgumentError)
end
2.upto(7) do |base|
it "raises an ArgumentError if the number begins with 0#{o} and the base is #{base}" do
- -> { Integer("0#{o}1", base) }.should raise_error(ArgumentError)
+ lambda { Integer("0#{o}1", base) }.should raise_error(ArgumentError)
end
end
end
@@ -580,35 +477,17 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as decimal and the base is 10" do
- -> { Integer("0#{d}a", 10) }.should raise_error(ArgumentError)
+ lambda { Integer("0#{d}a", 10) }.should raise_error(ArgumentError)
end
2.upto(9) do |base|
it "raises an ArgumentError if the number begins with 0#{d} and the base is #{base}" do
- -> { Integer("0#{d}1", base) }.should raise_error(ArgumentError)
+ lambda { Integer("0#{d}1", base) }.should raise_error(ArgumentError)
end
end
it "raises an ArgumentError if a base is given for a non-String value" do
- -> { Integer(98, 15) }.should raise_error(ArgumentError)
- end
- end
-
- ruby_version_is "2.6" do
- describe "when passed exception: false" do
- describe "and valid argument" do
- it "returns an Integer number" do
- Integer("100", 10, exception: false).should == 100
- Integer("100", 2, exception: false).should == 4
- end
- end
-
- describe "and invalid argument" do
- it "swallows an error" do
- Integer("999", 2, exception: false).should == nil
- Integer("abc", 10, exception: false).should == nil
- end
- end
+ lambda { Integer(98, 15) }.should raise_error(ArgumentError)
end
end
end
@@ -616,176 +495,176 @@ end
describe :kernel_Integer, shared: true do
it "raises an ArgumentError when the String contains digits out of range of radix 2" do
str = "23456789abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 2) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 2) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 3" do
str = "3456789abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 3) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 4" do
str = "456789abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 4) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 4) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 5" do
str = "56789abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 5) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 5) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 6" do
str = "6789abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 6) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 6) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 7" do
str = "789abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 7) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 7) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 8" do
str = "89abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 8) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 8) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 9" do
str = "9abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 9) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 9) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 10" do
str = "abcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 10) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 10) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 11" do
str = "bcdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 11) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 11) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 12" do
str = "cdefghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 12) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 12) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 13" do
str = "defghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 13) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 13) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 14" do
str = "efghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 14) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 14) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 15" do
str = "fghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 15) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 15) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 16" do
str = "ghijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 16) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 16) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 17" do
str = "hijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 17) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 17) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 18" do
str = "ijklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 18) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 18) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 19" do
str = "jklmnopqrstuvwxyz"
- -> { @object.send(@method, str, 19) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 19) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 20" do
str = "klmnopqrstuvwxyz"
- -> { @object.send(@method, str, 20) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 20) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 21" do
str = "lmnopqrstuvwxyz"
- -> { @object.send(@method, str, 21) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 21) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 22" do
str = "mnopqrstuvwxyz"
- -> { @object.send(@method, str, 22) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 22) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 23" do
str = "nopqrstuvwxyz"
- -> { @object.send(@method, str, 23) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 23) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 24" do
str = "opqrstuvwxyz"
- -> { @object.send(@method, str, 24) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 24) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 25" do
str = "pqrstuvwxyz"
- -> { @object.send(@method, str, 25) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 25) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 26" do
str = "qrstuvwxyz"
- -> { @object.send(@method, str, 26) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 26) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 27" do
str = "rstuvwxyz"
- -> { @object.send(@method, str, 27) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 27) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 28" do
str = "stuvwxyz"
- -> { @object.send(@method, str, 28) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 28) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 29" do
str = "tuvwxyz"
- -> { @object.send(@method, str, 29) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 29) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 30" do
str = "uvwxyz"
- -> { @object.send(@method, str, 30) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 30) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 31" do
str = "vwxyz"
- -> { @object.send(@method, str, 31) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 31) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 32" do
str = "wxyz"
- -> { @object.send(@method, str, 32) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 32) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 33" do
str = "xyz"
- -> { @object.send(@method, str, 33) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 33) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 34" do
str = "yz"
- -> { @object.send(@method, str, 34) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 34) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 35" do
str = "z"
- -> { @object.send(@method, str, 35) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, str, 35) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 36" do
- -> { @object.send(@method, "{", 36) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, "{", 36) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/kernel/Rational_spec.rb b/spec/ruby/core/kernel/Rational_spec.rb
index 2d1051db7f..38f1da6333 100644
--- a/spec/ruby/core/kernel/Rational_spec.rb
+++ b/spec/ruby/core/kernel/Rational_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/rational/Rational'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/rational/Rational', __FILE__)
describe "Kernel.Rational" do
it_behaves_like :kernel_Rational, :Rational
diff --git a/spec/ruby/core/kernel/String_spec.rb b/spec/ruby/core/kernel/String_spec.rb
index 47ee797be5..b24bc798e5 100644
--- a/spec/ruby/core/kernel/String_spec.rb
+++ b/spec/ruby/core/kernel/String_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_String, shared: true do
it "converts nil to a String" do
@@ -32,7 +32,7 @@ describe :kernel_String, shared: true do
undef_method :to_s
end
- -> { @object.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
# #5158
@@ -44,7 +44,7 @@ describe :kernel_String, shared: true do
end
end
- -> { @object.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_s is not defined, even though #respond_to?(:to_s) returns true" do
@@ -57,7 +57,7 @@ describe :kernel_String, shared: true do
end
end
- -> { @object.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "calls #to_s if #respond_to?(:to_s) returns true" do
@@ -74,7 +74,7 @@ describe :kernel_String, shared: true do
it "raises a TypeError if #to_s does not return a String" do
(obj = mock('123')).should_receive(:to_s).and_return(123)
- -> { @object.send(@method, obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "returns the same object if it is already a String" do
diff --git a/spec/ruby/core/kernel/__callee___spec.rb b/spec/ruby/core/kernel/__callee___spec.rb
index 3059ea8b57..91cc4cdafa 100644
--- a/spec/ruby/core/kernel/__callee___spec.rb
+++ b/spec/ruby/core/kernel/__callee___spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/__callee__'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/__callee__', __FILE__)
describe "Kernel.__callee__" do
it "returns the current method, even when aliased" do
diff --git a/spec/ruby/core/kernel/__dir___spec.rb b/spec/ruby/core/kernel/__dir___spec.rb
index 3c34277277..395d30f494 100644
--- a/spec/ruby/core/kernel/__dir___spec.rb
+++ b/spec/ruby/core/kernel/__dir___spec.rb
@@ -1,17 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Kernel#__dir__" do
it "returns the real name of the directory containing the currently-executing file" do
__dir__.should == File.realpath(File.dirname(__FILE__))
end
- context "when used in eval with a given filename" do
- it "returns File.dirname(filename)" do
- eval("__dir__", nil, "foo.rb").should == "."
- eval("__dir__", nil, "foo/bar.rb").should == "foo"
- end
- end
-
context "when used in eval with top level binding" do
it "returns the real name of the directory containing the currently-executing file" do
eval("__dir__", binding).should == File.realpath(File.dirname(__FILE__))
diff --git a/spec/ruby/core/kernel/__method___spec.rb b/spec/ruby/core/kernel/__method___spec.rb
index 578d25640d..936a6b2f00 100644
--- a/spec/ruby/core/kernel/__method___spec.rb
+++ b/spec/ruby/core/kernel/__method___spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/__method__'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/__method__', __FILE__)
describe "Kernel.__method__" do
it "returns the current method, even when aliased" do
diff --git a/spec/ruby/core/kernel/abort_spec.rb b/spec/ruby/core/kernel/abort_spec.rb
index f8152718c5..eb9c1c30c7 100644
--- a/spec/ruby/core/kernel/abort_spec.rb
+++ b/spec/ruby/core/kernel/abort_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/process/abort'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/process/abort', __FILE__)
describe "Kernel#abort" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/at_exit_spec.rb b/spec/ruby/core/kernel/at_exit_spec.rb
index 21149f965b..9fcb99148c 100644
--- a/spec/ruby/core/kernel/at_exit_spec.rb
+++ b/spec/ruby/core/kernel/at_exit_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.at_exit" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/autoload_spec.rb b/spec/ruby/core/kernel/autoload_spec.rb
index 68732a69ef..b2aab5a895 100644
--- a/spec/ruby/core/kernel/autoload_spec.rb
+++ b/spec/ruby/core/kernel/autoload_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# These specs only illustrate the basic autoload cases
# and where toplevel autoload behaves differently from
@@ -7,7 +7,7 @@ require_relative 'fixtures/classes'
autoload :KSAutoloadA, "autoload_a.rb"
autoload :KSAutoloadB, fixture(__FILE__, "autoload_b.rb")
-autoload :KSAutoloadCallsRequire, "main_autoload_not_exist.rb"
+autoload :KSAutoloadC, fixture(__FILE__, "autoload_c.rb")
def check_autoload(const)
autoload? const
@@ -42,11 +42,10 @@ describe "Kernel#autoload" do
KSAutoloadB.loaded.should == :ksautoload_b
end
- it "calls main.require(path) to load the file" do
- main = TOPLEVEL_BINDING.eval("self")
- main.should_receive(:require).with("main_autoload_not_exist.rb")
- # The constant won't be defined since require is mocked to do nothing
- -> { KSAutoloadCallsRequire }.should raise_error(NameError)
+ it "does not call Kernel.require or Kernel.load to load the file" do
+ Kernel.should_not_receive(:require)
+ Kernel.should_not_receive(:load)
+ KSAutoloadC.loaded.should == :ksautoload_c
end
it "can autoload in instance_eval" do
@@ -57,29 +56,10 @@ describe "Kernel#autoload" do
end
describe "when Object is frozen" do
- it "raises a #{frozen_error_class} before defining the constant" do
+ it "raises a FrozenError before defining the constant" do
ruby_exe(fixture(__FILE__, "autoload_frozen.rb")).should == "#{frozen_error_class} - nil"
end
end
-
- describe "when called from included module's method" do
- before :all do
- @path = fixture(__FILE__, "autoload_from_included_module.rb")
- KernelSpecs::AutoloadMethodIncluder.new.setup_autoload(@path)
- end
-
- it "setups the autoload on the included module" do
- KernelSpecs::AutoloadMethod.autoload?(:AutoloadFromIncludedModule).should == @path
- end
-
- it "the autoload is reachable from the class too" do
- KernelSpecs::AutoloadMethodIncluder.autoload?(:AutoloadFromIncludedModule).should == @path
- end
-
- it "the autoload relative to the included module works" do
- KernelSpecs::AutoloadMethod::AutoloadFromIncludedModule.loaded.should == :autoload_from_included_module
- end
- end
end
describe "Kernel#autoload?" do
@@ -127,25 +107,6 @@ describe "Kernel.autoload" do
p.should_receive(:to_path).and_return @non_existent
Kernel.autoload :KSAutoloadAA, p
end
-
- describe "when called from included module's method" do
- before :all do
- @path = fixture(__FILE__, "autoload_from_included_module2.rb")
- KernelSpecs::AutoloadMethodIncluder2.new.setup_autoload(@path)
- end
-
- it "setups the autoload on the included module" do
- KernelSpecs::AutoloadMethod2.autoload?(:AutoloadFromIncludedModule2).should == @path
- end
-
- it "the autoload is reachable from the class too" do
- KernelSpecs::AutoloadMethodIncluder2.autoload?(:AutoloadFromIncludedModule2).should == @path
- end
-
- it "the autoload relative to the included module works" do
- KernelSpecs::AutoloadMethod2::AutoloadFromIncludedModule2.loaded.should == :autoload_from_included_module2
- end
- end
end
describe "Kernel.autoload?" do
diff --git a/spec/ruby/core/kernel/backtick_spec.rb b/spec/ruby/core/kernel/backtick_spec.rb
index 5ab0fb0eea..eb25750bc2 100644
--- a/spec/ruby/core/kernel/backtick_spec.rb
+++ b/spec/ruby/core/kernel/backtick_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#`" do
before :each do
@@ -21,7 +21,7 @@ describe "Kernel#`" do
it "lets the standard error stream pass through to the inherited stderr" do
cmd = ruby_cmd('STDERR.print "error stream"')
- -> {
+ lambda {
`#{cmd}`.should == ""
}.should output_to_fd("error stream", STDERR)
end
@@ -32,7 +32,7 @@ describe "Kernel#`" do
end
it "raises an Errno::ENOENT if the command is not executable" do
- -> { `nonexistent_command` }.should raise_error(Errno::ENOENT)
+ lambda { `nonexistent_command` }.should raise_error(Errno::ENOENT)
end
platform_is_not :windows do
diff --git a/spec/ruby/core/kernel/binding_spec.rb b/spec/ruby/core/kernel/binding_spec.rb
index f1c9c6ec9f..0b33c86d3c 100644
--- a/spec/ruby/core/kernel/binding_spec.rb
+++ b/spec/ruby/core/kernel/binding_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.binding" do
it "returns a binding for the caller" do
@@ -35,7 +35,7 @@ describe "Kernel#binding" do
end
it "raises a NameError on undefined variable" do
- -> { eval("a_fake_variable", @b1) }.should raise_error(NameError)
+ lambda { eval("a_fake_variable", @b1) }.should raise_error(NameError)
end
it "uses the closure's self as self in the binding" do
diff --git a/spec/ruby/core/kernel/block_given_spec.rb b/spec/ruby/core/kernel/block_given_spec.rb
index b00bfabfc3..9454c938ae 100644
--- a/spec/ruby/core/kernel/block_given_spec.rb
+++ b/spec/ruby/core/kernel/block_given_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_block_given, shared: true do
it "returns true if and only if a block is supplied" do
diff --git a/spec/ruby/core/kernel/caller_locations_spec.rb b/spec/ruby/core/kernel/caller_locations_spec.rb
index 4de6c2ffd6..69993c3ec0 100644
--- a/spec/ruby/core/kernel/caller_locations_spec.rb
+++ b/spec/ruby/core/kernel/caller_locations_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/caller_locations'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/caller_locations', __FILE__)
describe 'Kernel#caller_locations' do
it 'is a private method' do
@@ -13,7 +13,7 @@ describe 'Kernel#caller_locations' do
it 'returns an Array of caller locations using a custom offset' do
locations = KernelSpecs::CallerLocationsTest.locations(2)
- locations[0].absolute_path.should.end_with?('mspec.rb')
+ locations[0].absolute_path.end_with?('mspec.rb').should == true
end
it 'returns an Array of caller locations using a custom limit' do
diff --git a/spec/ruby/core/kernel/caller_spec.rb b/spec/ruby/core/kernel/caller_spec.rb
index 8469319c94..d9be29a8db 100644
--- a/spec/ruby/core/kernel/caller_spec.rb
+++ b/spec/ruby/core/kernel/caller_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/caller'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/caller', __FILE__)
describe 'Kernel#caller' do
it 'is a private method' do
@@ -34,13 +34,4 @@ describe 'Kernel#caller' do
locations[0].should include("#{__FILE__}:#{line}:in")
end
-
- it "returns an Array with the block given to #at_exit at the base of the stack" do
- path = fixture(__FILE__, "caller_at_exit.rb")
- lines = ruby_exe(path).lines
- lines.should == [
- "#{path}:6:in `foo'\n",
- "#{path}:2:in `block in <main>'\n"
- ]
- end
end
diff --git a/spec/ruby/core/kernel/case_compare_spec.rb b/spec/ruby/core/kernel/case_compare_spec.rb
index b8d30960e8..5332aa7647 100644
--- a/spec/ruby/core/kernel/case_compare_spec.rb
+++ b/spec/ruby/core/kernel/case_compare_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
module Specs
diff --git a/spec/ruby/core/kernel/catch_spec.rb b/spec/ruby/core/kernel/catch_spec.rb
index 4060172429..35a4860f38 100644
--- a/spec/ruby/core/kernel/catch_spec.rb
+++ b/spec/ruby/core/kernel/catch_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.catch" do
before :each do
@@ -31,11 +31,11 @@ describe "Kernel.catch" do
end
it "raises an ArgumentError if a Symbol is thrown for a String catch value" do
- -> { catch("exit") { throw :exit } }.should raise_error(ArgumentError)
+ lambda { catch("exit") { throw :exit } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if a String with different identity is thrown" do
- -> { catch("exit") { throw "exit" } }.should raise_error(ArgumentError)
+ lambda { catch("exit") { throw "exit" } }.should raise_error(ArgumentError)
end
it "catches a Symbol when thrown a matching Symbol" do
@@ -116,7 +116,7 @@ describe "Kernel.catch" do
end
it "raises LocalJumpError if no block is given" do
- -> { catch :blah }.should raise_error(LocalJumpError)
+ lambda { catch :blah }.should raise_error(LocalJumpError)
end
end
diff --git a/spec/ruby/core/kernel/chomp_spec.rb b/spec/ruby/core/kernel/chomp_spec.rb
index d30e77c35a..524a4c8b1d 100644
--- a/spec/ruby/core/kernel/chomp_spec.rb
+++ b/spec/ruby/core/kernel/chomp_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_chomp, shared: true do
it "removes the final newline of $_" do
@@ -40,26 +40,28 @@ describe "Kernel#chomp" do
it_behaves_like :kernel_chomp_private, :chomp
end
-describe :kernel_chomp_encoded, shared: true do
- before :each do
- @external = Encoding.default_external
- Encoding.default_external = Encoding::UTF_8
- end
+with_feature :encoding do
+ describe :kernel_chomp_encoded, shared: true do
+ before :each do
+ @external = Encoding.default_external
+ Encoding.default_external = Encoding::UTF_8
+ end
- after :each do
- Encoding.default_external = @external
- end
+ after :each do
+ Encoding.default_external = @external
+ end
- it "removes the final carriage return, newline from a multi-byte $_" do
- script = fixture __FILE__, "#{@method}.rb"
- KernelSpecs.run_with_dash_n(script).should == "ã‚れ"
+ it "removes the final carriage return, newline from a multi-byte $_" do
+ script = fixture __FILE__, "#{@method}.rb"
+ KernelSpecs.run_with_dash_n(script).should == "ã‚れ"
+ end
end
-end
-describe "Kernel.chomp" do
- it_behaves_like :kernel_chomp_encoded, "chomp"
-end
+ describe "Kernel.chomp" do
+ it_behaves_like :kernel_chomp_encoded, "chomp"
+ end
-describe "Kernel#chomp" do
- it_behaves_like :kernel_chomp_encoded, "chomp_f"
+ describe "Kernel#chomp" do
+ it_behaves_like :kernel_chomp_encoded, "chomp_f"
+ end
end
diff --git a/spec/ruby/core/kernel/chop_spec.rb b/spec/ruby/core/kernel/chop_spec.rb
index 9b91c011bc..5106fefee8 100644
--- a/spec/ruby/core/kernel/chop_spec.rb
+++ b/spec/ruby/core/kernel/chop_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_chop, shared: true do
it "removes the final character of $_" do
@@ -28,26 +28,28 @@ describe "Kernel#chop" do
it_behaves_like :kernel_chop, "chop"
end
-describe :kernel_chop_encoded, shared: true do
- before :each do
- @external = Encoding.default_external
- Encoding.default_external = Encoding::UTF_8
+with_feature :encoding do
+ describe :kernel_chop_encoded, shared: true do
+ before :each do
+ @external = Encoding.default_external
+ Encoding.default_external = Encoding::UTF_8
+ end
+
+ after :each do
+ Encoding.default_external = @external
+ end
+
+ it "removes the final multi-byte character from $_" do
+ script = fixture __FILE__, "#{@method}.rb"
+ KernelSpecs.run_with_dash_n(script).should == "ã‚"
+ end
end
- after :each do
- Encoding.default_external = @external
+ describe "Kernel.chop" do
+ it_behaves_like :kernel_chop_encoded, "chop"
end
- it "removes the final multi-byte character from $_" do
- script = fixture __FILE__, "#{@method}.rb"
- KernelSpecs.run_with_dash_n(script).should == "ã‚"
+ describe "Kernel#chop" do
+ it_behaves_like :kernel_chop_encoded, "chop_f"
end
end
-
-describe "Kernel.chop" do
- it_behaves_like :kernel_chop_encoded, "chop"
-end
-
-describe "Kernel#chop" do
- it_behaves_like :kernel_chop_encoded, "chop_f"
-end
diff --git a/spec/ruby/core/kernel/class_spec.rb b/spec/ruby/core/kernel/class_spec.rb
index 4d3b4e549b..0d7b40c366 100644
--- a/spec/ruby/core/kernel/class_spec.rb
+++ b/spec/ruby/core/kernel/class_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#class" do
it "returns the class of the object" do
diff --git a/spec/ruby/core/kernel/clone_spec.rb b/spec/ruby/core/kernel/clone_spec.rb
index f20ea618b5..48b3c24c7f 100644
--- a/spec/ruby/core/kernel/clone_spec.rb
+++ b/spec/ruby/core/kernel/clone_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/dup_clone'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/dup_clone', __FILE__)
describe "Kernel#clone" do
it_behaves_like :kernel_dup_clone, :clone
@@ -37,12 +37,14 @@ describe "Kernel#clone" do
o3.frozen?.should == true
end
- it 'takes an option to copy freeze state or not' do
- @obj.clone(freeze: true).frozen?.should == false
- @obj.clone(freeze: false).frozen?.should == false
- @obj.freeze
- @obj.clone(freeze: true).frozen?.should == true
- @obj.clone(freeze: false).frozen?.should == false
+ ruby_version_is '2.4' do
+ it 'takes an option to copy freeze state or not' do
+ @obj.clone(freeze: true).frozen?.should == false
+ @obj.clone(freeze: false).frozen?.should == false
+ @obj.freeze
+ @obj.clone(freeze: true).frozen?.should == true
+ @obj.clone(freeze: false).frozen?.should == false
+ end
end
it "copies instance variables" do
@@ -108,15 +110,9 @@ describe "Kernel#clone" do
cloned.bar.should == ['a']
end
- it 'copies frozen?' do
- o = ''.freeze.clone
+ it 'copies frozen? and tainted?' do
+ o = ''.taint.freeze.clone
o.frozen?.should be_true
- end
-
- ruby_version_is ''...'2.7' do
- it 'copies tainted?' do
- o = ''.taint.clone
- o.tainted?.should be_true
- end
+ o.tainted?.should be_true
end
end
diff --git a/spec/ruby/core/kernel/comparison_spec.rb b/spec/ruby/core/kernel/comparison_spec.rb
index affdc5c00d..2aa4358600 100644
--- a/spec/ruby/core/kernel/comparison_spec.rb
+++ b/spec/ruby/core/kernel/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Kernel#<=>" do
it "returns 0 if self" do
diff --git a/spec/ruby/core/kernel/define_singleton_method_spec.rb b/spec/ruby/core/kernel/define_singleton_method_spec.rb
index dc77c3e6f8..de6f7fc286 100644
--- a/spec/ruby/core/kernel/define_singleton_method_spec.rb
+++ b/spec/ruby/core/kernel/define_singleton_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#define_singleton_method" do
describe "when given an UnboundMethod" do
@@ -21,7 +21,7 @@ describe "Kernel#define_singleton_method" do
um = KernelSpecs::Parent.method(:parent_class_method).unbind
KernelSpecs::Child.send :define_singleton_method, :child_class_method, um
KernelSpecs::Child.child_class_method.should == :foo
- ->{KernelSpecs::Parent.child_class_method}.should raise_error(NoMethodError)
+ lambda{KernelSpecs::Parent.child_class_method}.should raise_error(NoMethodError)
end
it "will raise when attempting to define an object's singleton method from another object's singleton method" do
@@ -33,7 +33,7 @@ describe "Kernel#define_singleton_method" do
end
end
um = p.method(:singleton_method).unbind
- ->{ other.send :define_singleton_method, :other_singleton_method, um }.should raise_error(TypeError)
+ lambda{ other.send :define_singleton_method, :other_singleton_method, um }.should raise_error(TypeError)
end
end
@@ -41,7 +41,7 @@ describe "Kernel#define_singleton_method" do
it "defines a new method with the given name and the given block as body in self" do
class DefineSingletonMethodSpecClass
define_singleton_method(:block_test1) { self }
- define_singleton_method(:block_test2, &-> { self })
+ define_singleton_method(:block_test2, &lambda { self })
end
o = DefineSingletonMethodSpecClass
@@ -50,11 +50,11 @@ describe "Kernel#define_singleton_method" do
end
it "raises a TypeError when the given method is no Method/Proc" do
- -> {
+ lambda {
Class.new { define_singleton_method(:test, "self") }
}.should raise_error(TypeError)
- -> {
+ lambda {
Class.new { define_singleton_method(:test, 1234) }
}.should raise_error(TypeError)
end
@@ -63,7 +63,7 @@ describe "Kernel#define_singleton_method" do
obj = Object.new
obj.define_singleton_method(:test) { "world!" }
obj.test.should == "world!"
- -> {
+ lambda {
Object.new.test
}.should raise_error(NoMethodError)
end
@@ -81,19 +81,21 @@ describe "Kernel#define_singleton_method" do
it "raises an ArgumentError when no block is given" do
obj = Object.new
- -> {
+ lambda {
obj.define_singleton_method(:test)
}.should raise_error(ArgumentError)
end
- it "does not use the caller block when no block is given" do
- o = Object.new
- def o.define(name)
- define_singleton_method(name)
- end
+ ruby_version_is "2.3" do
+ it "does not use the caller block when no block is given" do
+ o = Object.new
+ def o.define(name)
+ define_singleton_method(name)
+ end
- -> {
- o.define(:foo) { raise "not used" }
- }.should raise_error(ArgumentError)
+ lambda {
+ o.define(:foo) { raise "not used" }
+ }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/kernel/display_spec.rb b/spec/ruby/core/kernel/display_spec.rb
index 9d429a9fac..e771e14cdb 100644
--- a/spec/ruby/core/kernel/display_spec.rb
+++ b/spec/ruby/core/kernel/display_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#display" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/kernel/dup_spec.rb b/spec/ruby/core/kernel/dup_spec.rb
index fe0a269d69..af7e924a66 100644
--- a/spec/ruby/core/kernel/dup_spec.rb
+++ b/spec/ruby/core/kernel/dup_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/dup_clone'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/dup_clone', __FILE__)
describe "Kernel#dup" do
it_behaves_like :kernel_dup_clone, :dup
@@ -44,7 +44,7 @@ describe "Kernel#dup" do
it "does not copy singleton methods" do
def @obj.special() :the_one end
dup = @obj.dup
- -> { dup.special }.should raise_error(NameError)
+ lambda { dup.special }.should raise_error(NameError)
end
it "does not copy modules included in the singleton class" do
@@ -53,7 +53,7 @@ describe "Kernel#dup" do
end
dup = @obj.dup
- -> { dup.repr }.should raise_error(NameError)
+ lambda { dup.repr }.should raise_error(NameError)
end
it "does not copy constants defined in the singleton class" do
@@ -62,6 +62,6 @@ describe "Kernel#dup" do
end
dup = @obj.dup
- -> { class << dup; CLONE; end }.should raise_error(NameError)
+ lambda { class << dup; CLONE; end }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/kernel/enum_for_spec.rb b/spec/ruby/core/kernel/enum_for_spec.rb
index 0092e20468..819140e0e4 100644
--- a/spec/ruby/core/kernel/enum_for_spec.rb
+++ b/spec/ruby/core/kernel/enum_for_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Kernel#enum_for" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/kernel/eql_spec.rb b/spec/ruby/core/kernel/eql_spec.rb
index e62a601a79..39c9fea7eb 100644
--- a/spec/ruby/core/kernel/eql_spec.rb
+++ b/spec/ruby/core/kernel/eql_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/kernel/equal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/kernel/equal', __FILE__)
describe "Kernel#eql?" do
it "is a public instance method" do
@@ -8,3 +8,4 @@ describe "Kernel#eql?" do
it_behaves_like :object_equal, :eql?
end
+
diff --git a/spec/ruby/core/kernel/equal_value_spec.rb b/spec/ruby/core/kernel/equal_value_spec.rb
index 2be151263d..a66493f283 100644
--- a/spec/ruby/core/kernel/equal_value_spec.rb
+++ b/spec/ruby/core/kernel/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#==" do
it "returns true only if obj and other are the same object" do
diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb
index 340ba23f2a..96fc0f5b71 100644
--- a/spec/ruby/core/kernel/eval_spec.rb
+++ b/spec/ruby/core/kernel/eval_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
EvalSpecs::A.new.c
@@ -24,7 +24,7 @@ describe "Kernel#eval" do
EvalSpecs::A::B.name.should == "EvalSpecs::A::B"
end
- it "evaluates such that constants are scoped to the class of the eval" do
+ it "evaluates such that consts are scoped to the class of the eval" do
EvalSpecs::A::C.name.should == "EvalSpecs::A::C"
end
@@ -76,12 +76,12 @@ describe "Kernel#eval" do
x = 1
bind = proc {}
- -> { eval("x", bind) }.should raise_error(TypeError)
+ lambda { eval("x", bind) }.should raise_error(TypeError)
end
it "does not make Proc locals visible to evaluated code" do
bind = proc { inner = 4 }
- -> { eval("inner", bind.binding) }.should raise_error(NameError)
+ lambda { eval("inner", bind.binding) }.should raise_error(NameError)
end
# REWRITE ME: This obscures the real behavior of where locals are stored
@@ -134,7 +134,7 @@ describe "Kernel#eval" do
it "includes file and line information in syntax error" do
expected = 'speccing.rb'
- -> {
+ lambda {
eval('if true',TOPLEVEL_BINDING, expected)
}.should raise_error(SyntaxError) { |e|
e.message.should =~ /#{expected}:1:.+/
@@ -143,7 +143,7 @@ describe "Kernel#eval" do
it "evaluates string with given filename and negative linenumber" do
expected_file = 'speccing.rb'
- -> {
+ lambda {
eval('if true',TOPLEVEL_BINDING, expected_file, -100)
}.should raise_error(SyntaxError) { |e|
e.message.should =~ /#{expected_file}:-100:.+/
@@ -161,11 +161,11 @@ describe "Kernel#eval" do
it "uses the filename of the binding if none is provided" do
eval("__FILE__").should == "(eval)"
- suppress_warning {eval("__FILE__", binding)}.should == __FILE__
+ eval("__FILE__", binding).should == __FILE__
eval("__FILE__", binding, "success").should == "success"
- suppress_warning {eval("eval '__FILE__', binding")}.should == "(eval)"
- suppress_warning {eval("eval '__FILE__', binding", binding)}.should == __FILE__
- suppress_warning {eval("eval '__FILE__', binding", binding, 'success')}.should == 'success'
+ eval("eval '__FILE__', binding").should == "(eval)"
+ eval("eval '__FILE__', binding", binding).should == __FILE__
+ eval("eval '__FILE__', binding", binding, 'success').should == 'success'
end
# Found via Rubinius bug github:#149
@@ -195,13 +195,13 @@ describe "Kernel#eval" do
end
it "does not pass the block to the method being eval'ed" do
- -> {
+ lambda {
eval('KernelSpecs::EvalTest.call_yield') { "content" }
}.should raise_error(LocalJumpError)
end
it "returns from the scope calling #eval when evaluating 'return'" do
- -> { eval("return :eval") }.call.should == :eval
+ lambda { eval("return :eval") }.call.should == :eval
end
it "unwinds through a Proc-style closure and returns from a lambda-style closure in the closure chain" do
@@ -213,150 +213,4 @@ describe "Kernel#eval" do
code = fixture __FILE__, "eval_return_without_lambda.rb"
ruby_exe(code).chomp.should == "a,b,c,e,LocalJumpError,f"
end
-
- # See language/magic_comment_spec.rb for more magic comments specs
- describe "with a magic encoding comment" do
- it "uses the magic comment encoding for the encoding of literal strings" do
- code = "# encoding: UTF-8\n'é'.encoding".b
- code.encoding.should == Encoding::BINARY
- eval(code).should == Encoding::UTF_8
- end
-
- it "uses the magic comment encoding for parsing constants" do
- code = <<CODE.b
-# encoding: UTF-8
-class EvalSpecs
- VÏ€ = 3.14
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should include(:"VÏ€")
- EvalSpecs::VÏ€.should == 3.14
- end
-
- it "allows an emacs-style magic comment encoding" do
- code = <<CODE.b
-# -*- encoding: UTF-8 -*-
-class EvalSpecs
-VÏ€emacs = 3.14
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should include(:"VÏ€emacs")
- EvalSpecs::VÏ€emacs.should == 3.14
- end
-
- it "allows spaces before the magic encoding comment" do
- code = <<CODE.b
-\t \t # encoding: UTF-8
-class EvalSpecs
- VÏ€spaces = 3.14
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should include(:"VÏ€spaces")
- EvalSpecs::VÏ€spaces.should == 3.14
- end
-
- it "allows a shebang line before the magic encoding comment" do
- code = <<CODE.b
-#!/usr/bin/env ruby
-# encoding: UTF-8
-class EvalSpecs
- VÏ€shebang = 3.14
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should include(:"VÏ€shebang")
- EvalSpecs::VÏ€shebang.should == 3.14
- end
-
- it "allows a shebang line and some spaces before the magic encoding comment" do
- code = <<CODE.b
-#!/usr/bin/env ruby
- # encoding: UTF-8
-class EvalSpecs
- VÏ€shebang_spaces = 3.14
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should include(:"VÏ€shebang_spaces")
- EvalSpecs::VÏ€shebang_spaces.should == 3.14
- end
-
- it "allows a magic encoding comment and a subsequent frozen_string_literal magic comment" do
- # Make sure frozen_string_literal is not default true
- eval("'foo'".b).frozen?.should be_false
-
- code = <<CODE.b
-# encoding: UTF-8
-# frozen_string_literal: true
-class EvalSpecs
- VÏ€string = "frozen"
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should include(:"VÏ€string")
- EvalSpecs::VÏ€string.should == "frozen"
- EvalSpecs::VÏ€string.encoding.should == Encoding::UTF_8
- EvalSpecs::VÏ€string.frozen?.should be_true
- end
-
- it "allows a magic encoding comment and a frozen_string_literal magic comment on the same line in emacs style" do
- code = <<CODE.b
-# -*- encoding: UTF-8; frozen_string_literal: true -*-
-class EvalSpecs
-VÏ€same_line = "frozen"
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should include(:"VÏ€same_line")
- EvalSpecs::VÏ€same_line.should == "frozen"
- EvalSpecs::VÏ€same_line.encoding.should == Encoding::UTF_8
- EvalSpecs::VÏ€same_line.frozen?.should be_true
- end
-
- it "ignores the magic encoding comment if it is after a frozen_string_literal magic comment" do
- code = <<CODE.b
-# frozen_string_literal: true
-# encoding: UTF-8
-class EvalSpecs
- VÏ€frozen_first = "frozen"
-end
-CODE
- code.encoding.should == Encoding::BINARY
- eval(code)
- EvalSpecs.constants(false).should_not include(:"VÏ€frozen_first")
- binary_constant = "VÏ€frozen_first".b.to_sym
- EvalSpecs.constants(false).should include(binary_constant)
- value = EvalSpecs.const_get(binary_constant)
- value.should == "frozen"
- value.encoding.should == Encoding::BINARY
- value.frozen?.should be_true
- end
-
- it "ignores the frozen_string_literal magic comment if it appears after a token and warns if $VERBOSE is true" do
- code = <<CODE
-some_token_before_magic_comment = :anything
-# frozen_string_literal: true
-class EvalSpecs
- VÏ€string_not_frozen = "not frozen"
-end
-CODE
- -> { eval(code) }.should complain(/warning: `frozen_string_literal' is ignored after any tokens/, verbose: true)
- EvalSpecs::VÏ€string_not_frozen.frozen?.should be_false
- EvalSpecs.send :remove_const, :VÏ€string_not_frozen
-
- -> { eval(code) }.should_not complain(verbose: false)
- EvalSpecs::VÏ€string_not_frozen.frozen?.should be_false
- EvalSpecs.send :remove_const, :VÏ€string_not_frozen
- end
- end
end
diff --git a/spec/ruby/core/kernel/exec_spec.rb b/spec/ruby/core/kernel/exec_spec.rb
index 1b4a7ae6f4..3a7b656914 100644
--- a/spec/ruby/core/kernel/exec_spec.rb
+++ b/spec/ruby/core/kernel/exec_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#exec" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/exit_spec.rb b/spec/ruby/core/kernel/exit_spec.rb
index f168cb375e..61a6670cfd 100644
--- a/spec/ruby/core/kernel/exit_spec.rb
+++ b/spec/ruby/core/kernel/exit_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/process/exit'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/process/exit', __FILE__)
describe "Kernel#exit" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/extend_spec.rb b/spec/ruby/core/kernel/extend_spec.rb
index 9f98b3681f..482eef32e9 100644
--- a/spec/ruby/core/kernel/extend_spec.rb
+++ b/spec/ruby/core/kernel/extend_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
module KernelSpecs::M
def self.extend_object(o)
@@ -46,20 +46,20 @@ describe "Kernel#extend" do
end
it "makes the class a kind_of? the argument" do
- c = Class.new do
+ class C
extend KernelSpecs::M
end
- (c.kind_of? KernelSpecs::M).should == true
+ (C.kind_of? KernelSpecs::M).should == true
end
it "raises an ArgumentError when no arguments given" do
- -> { Object.new.extend }.should raise_error(ArgumentError)
+ lambda { Object.new.extend }.should raise_error(ArgumentError)
end
it "raises a TypeError when the argument is not a Module" do
o = mock('o')
klass = Class.new
- -> { o.extend(klass) }.should raise_error(TypeError)
+ lambda { o.extend(klass) }.should raise_error(TypeError)
end
describe "on frozen instance" do
@@ -69,11 +69,11 @@ describe "Kernel#extend" do
end
it "raises an ArgumentError when no arguments given" do
- -> { @frozen.extend }.should raise_error(ArgumentError)
+ lambda { @frozen.extend }.should raise_error(ArgumentError)
end
- it "raises a #{frozen_error_class}" do
- -> { @frozen.extend @module }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError" do
+ lambda { @frozen.extend @module }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/kernel/fail_spec.rb b/spec/ruby/core/kernel/fail_spec.rb
index fab622037e..9f3601c233 100644
--- a/spec/ruby/core/kernel/fail_spec.rb
+++ b/spec/ruby/core/kernel/fail_spec.rb
@@ -1,30 +1,31 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe "Kernel#fail" do
+describe "Kernel.fail" do
it "is a private method" do
Kernel.should have_private_instance_method(:fail)
end
it "raises a RuntimeError" do
- -> { fail }.should raise_error(RuntimeError)
+ lambda { fail }.should raise_error(RuntimeError)
end
it "accepts an Object with an exception method returning an Exception" do
- obj = Object.new
- def obj.exception(msg)
- StandardError.new msg
+ class Boring
+ def self.exception(msg)
+ StandardError.new msg
+ end
end
- -> { fail obj, "..." }.should raise_error(StandardError, "...")
+ lambda { fail Boring, "..." }.should raise_error(StandardError)
end
it "instantiates the specified exception class" do
- error_class = Class.new(RuntimeError)
- -> { fail error_class }.should raise_error(error_class)
+ class LittleBunnyFooFoo < RuntimeError; end
+ lambda { fail LittleBunnyFooFoo }.should raise_error(LittleBunnyFooFoo)
end
it "uses the specified message" do
- -> {
+ lambda {
begin
fail "the duck is not irish."
rescue => e
@@ -37,6 +38,6 @@ describe "Kernel#fail" do
end
end
-describe "Kernel.fail" do
+describe "Kernel#fail" do
it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/kernel/fixtures/autoload_c.rb b/spec/ruby/core/kernel/fixtures/autoload_c.rb
new file mode 100644
index 0000000000..4569b23669
--- /dev/null
+++ b/spec/ruby/core/kernel/fixtures/autoload_c.rb
@@ -0,0 +1,5 @@
+module KSAutoloadC
+ def self.loaded
+ :ksautoload_c
+ end
+end
diff --git a/spec/ruby/core/kernel/fixtures/autoload_from_included_module.rb b/spec/ruby/core/kernel/fixtures/autoload_from_included_module.rb
deleted file mode 100644
index f5bedc6992..0000000000
--- a/spec/ruby/core/kernel/fixtures/autoload_from_included_module.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module KernelSpecs
- module AutoloadMethod
- module AutoloadFromIncludedModule
- def self.loaded
- :autoload_from_included_module
- end
- end
- end
-end
diff --git a/spec/ruby/core/kernel/fixtures/autoload_from_included_module2.rb b/spec/ruby/core/kernel/fixtures/autoload_from_included_module2.rb
deleted file mode 100644
index f4f1cfbf7c..0000000000
--- a/spec/ruby/core/kernel/fixtures/autoload_from_included_module2.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module KernelSpecs
- module AutoloadMethod2
- module AutoloadFromIncludedModule2
- def self.loaded
- :autoload_from_included_module2
- end
- end
- end
-end
diff --git a/spec/ruby/core/kernel/fixtures/caller_at_exit.rb b/spec/ruby/core/kernel/fixtures/caller_at_exit.rb
deleted file mode 100644
index ca9d808597..0000000000
--- a/spec/ruby/core/kernel/fixtures/caller_at_exit.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-at_exit {
- foo
-}
-
-def foo
- puts caller(0)
-end
diff --git a/spec/ruby/core/kernel/fixtures/classes.rb b/spec/ruby/core/kernel/fixtures/classes.rb
index 2f2bbf1b23..afa2bec12f 100644
--- a/spec/ruby/core/kernel/fixtures/classes.rb
+++ b/spec/ruby/core/kernel/fixtures/classes.rb
@@ -68,7 +68,6 @@ module KernelSpecs
module SomeOtherModule; end
module AncestorModule; end
module MyModule; end
- module MyPrependedModule; end
module MyExtensionModule; end
class AncestorClass < String
@@ -81,8 +80,6 @@ module KernelSpecs
class KindaClass < AncestorClass
include MyModule
- prepend MyPrependedModule
-
def initialize
self.extend MyExtensionModule
end
@@ -328,7 +325,7 @@ module KernelSpecs
def inner
b = mp { return :good }
- pr = -> x { x.call }
+ pr = lambda { |x| x.call }
pr.call(b)
@@ -337,28 +334,6 @@ module KernelSpecs
end
end
- module LambdaSpecs
- module ZSuper
- def lambda
- super
- end
- end
-
- class ForwardBlockWithZSuper
- prepend(ZSuper)
- end
-
- module Ampersand
- def lambda(&block)
- super(&block)
- end
- end
-
- class SuperAmpersand
- prepend(Ampersand)
- end
- end
-
class RespondViaMissing
def respond_to_missing?(method, priv=false)
case method
@@ -403,63 +378,6 @@ module KernelSpecs
[3, 4]
end
end
-
- module AutoloadMethod
- def setup_autoload(file)
- autoload :AutoloadFromIncludedModule, file
- end
- end
-
- class AutoloadMethodIncluder
- include AutoloadMethod
- end
-
- module AutoloadMethod2
- def setup_autoload(file)
- Kernel.autoload :AutoloadFromIncludedModule2, file
- end
- end
-
- class AutoloadMethodIncluder2
- include AutoloadMethod2
- end
-
- class WarnInNestedCall
- def f4(s = "", n)
- f3(s, n)
- end
-
- def f3(s, n)
- f2(s, n)
- end
-
- def f2(s, n)
- f1(s, n)
- end
-
- def f1(s, n)
- warn(s, uplevel: n)
- end
-
- def warn_call_lineno; method(:f1).source_location[1] + 1; end
- def f1_call_lineno; method(:f2).source_location[1] + 1; end
- def f2_call_lineno; method(:f3).source_location[1] + 1; end
- def f3_call_lineno; method(:f4).source_location[1] + 1; end
- end
-
- CustomRangeInteger = Struct.new(:value) do
- def to_int; value; end
- def <=>(other); to_int <=> other.to_int; end
- def -(other); self.class.new(to_int - other.to_int); end
- def +(other); self.class.new(to_int + other.to_int); end
- end
-
- CustomRangeFloat = Struct.new(:value) do
- def to_f; value; end
- def <=>(other); to_f <=> other.to_f; end
- def -(other); to_f - other.to_f; end
- def +(other); self.class.new(to_f + other.to_f); end
- end
end
class EvalSpecs
@@ -490,3 +408,12 @@ class EvalSpecs
return f
end
end
+
+# for Kernel#sleep to have Channel in it's specs
+# TODO: switch directly to queue for both Kernel#sleep and Thread specs?
+unless defined? Channel
+ require 'thread'
+ class Channel < Queue
+ alias receive shift
+ end
+end
diff --git a/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb b/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb
index 9e2d045bf3..a48b5685f3 100644
--- a/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb
+++ b/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb
@@ -1,5 +1,5 @@
print "a,"
-x = -> do
+x = lambda do
print "b,"
Proc.new do
print "c,"
diff --git a/spec/ruby/core/kernel/fixtures/singleton_methods.rb b/spec/ruby/core/kernel/fixtures/singleton_methods.rb
deleted file mode 100644
index 32ea0adf89..0000000000
--- a/spec/ruby/core/kernel/fixtures/singleton_methods.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module SingletonMethodsSpecs
- module Prepended
- def mspec_test_kernel_singleton_methods
- end
- public :mspec_test_kernel_singleton_methods
- end
-
- ::Module.prepend Prepended
-
- module SelfExtending
- extend self
- end
-end
diff --git a/spec/ruby/core/kernel/fork_spec.rb b/spec/ruby/core/kernel/fork_spec.rb
index b37f9980e0..8919d0914d 100644
--- a/spec/ruby/core/kernel/fork_spec.rb
+++ b/spec/ruby/core/kernel/fork_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/process/fork'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/process/fork', __FILE__)
describe "Kernel#fork" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/format_spec.rb b/spec/ruby/core/kernel/format_spec.rb
index 72fd40b952..c73d5f0efb 100644
--- a/spec/ruby/core/kernel/format_spec.rb
+++ b/spec/ruby/core/kernel/format_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#format" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/freeze_spec.rb b/spec/ruby/core/kernel/freeze_spec.rb
index 214b619f9f..cf16512094 100644
--- a/spec/ruby/core/kernel/freeze_spec.rb
+++ b/spec/ruby/core/kernel/freeze_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#freeze" do
it "prevents self from being further modified" do
@@ -74,12 +74,12 @@ describe "Kernel#freeze" do
def mutate; @foo = 1; end
end.new
o.freeze
- -> {o.mutate}.should raise_error(RuntimeError)
+ lambda {o.mutate}.should raise_error(RuntimeError)
end
it "causes instance_variable_set to raise RuntimeError" do
o = Object.new
o.freeze
- -> {o.instance_variable_set(:@foo, 1)}.should raise_error(RuntimeError)
+ lambda {o.instance_variable_set(:@foo, 1)}.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/kernel/frozen_spec.rb b/spec/ruby/core/kernel/frozen_spec.rb
index 5887ed75ba..fad1971985 100644
--- a/spec/ruby/core/kernel/frozen_spec.rb
+++ b/spec/ruby/core/kernel/frozen_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#frozen?" do
it "returns true if self is frozen" do
diff --git a/spec/ruby/core/kernel/gets_spec.rb b/spec/ruby/core/kernel/gets_spec.rb
index 104613dbfa..c775b2b7a4 100644
--- a/spec/ruby/core/kernel/gets_spec.rb
+++ b/spec/ruby/core/kernel/gets_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#gets" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/global_variables_spec.rb b/spec/ruby/core/kernel/global_variables_spec.rb
index 8bce8e25b7..739b800938 100644
--- a/spec/ruby/core/kernel/global_variables_spec.rb
+++ b/spec/ruby/core/kernel/global_variables_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.global_variables" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/gsub_spec.rb b/spec/ruby/core/kernel/gsub_spec.rb
index a0cb9f2a70..005ed0063d 100644
--- a/spec/ruby/core/kernel/gsub_spec.rb
+++ b/spec/ruby/core/kernel/gsub_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# FIXME: These methods exist only when the -n or -p option is passed to
# ruby, but we currently don't have a way of specifying that.
@@ -10,7 +10,7 @@ ruby_version_is ""..."1.9" do
end
it "raises a TypeError if $_ is not a String" do
- -> {
+ lambda {
$_ = 123
gsub(/./, "!")
}.should raise_error(TypeError)
diff --git a/spec/ruby/core/kernel/inspect_spec.rb b/spec/ruby/core/kernel/inspect_spec.rb
index a946d032db..92129ebbc5 100644
--- a/spec/ruby/core/kernel/inspect_spec.rb
+++ b/spec/ruby/core/kernel/inspect_spec.rb
@@ -1,19 +1,17 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#inspect" do
it "returns a String" do
Object.new.inspect.should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted string if self is tainted" do
- Object.new.taint.inspect.tainted?.should be_true
- end
+ it "returns a tainted string if self is tainted" do
+ Object.new.taint.inspect.tainted?.should be_true
+ end
- it "returns an untrusted string if self is untrusted" do
- Object.new.untrust.inspect.untrusted?.should be_true
- end
+ it "returns an untrusted string if self is untrusted" do
+ Object.new.untrust.inspect.untrusted?.should be_true
end
it "does not call #to_s if it is defined" do
diff --git a/spec/ruby/core/kernel/instance_of_spec.rb b/spec/ruby/core/kernel/instance_of_spec.rb
index 40e856b0d9..4801a1ff96 100644
--- a/spec/ruby/core/kernel/instance_of_spec.rb
+++ b/spec/ruby/core/kernel/instance_of_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe Kernel, "#instance_of?" do
before :each do
@@ -33,8 +33,8 @@ describe Kernel, "#instance_of?" do
end
it "raises a TypeError if given an object that is not a Class nor a Module" do
- -> { @o.instance_of?(Object.new) }.should raise_error(TypeError)
- -> { @o.instance_of?('KernelSpecs::InstanceClass') }.should raise_error(TypeError)
- -> { @o.instance_of?(1) }.should raise_error(TypeError)
+ lambda { @o.instance_of?(Object.new) }.should raise_error(TypeError)
+ lambda { @o.instance_of?('KernelSpecs::InstanceClass') }.should raise_error(TypeError)
+ lambda { @o.instance_of?(1) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/instance_variable_defined_spec.rb b/spec/ruby/core/kernel/instance_variable_defined_spec.rb
index 2ebb582b43..969d36c731 100644
--- a/spec/ruby/core/kernel/instance_variable_defined_spec.rb
+++ b/spec/ruby/core/kernel/instance_variable_defined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#instance_variable_defined?" do
before do
@@ -27,7 +27,7 @@ describe "Kernel#instance_variable_defined?" do
end
it "raises a TypeError if passed an Object not defining #to_str" do
- -> do
+ lambda do
obj = mock("kernel instance_variable_defined?")
@instance.instance_variable_defined? obj
end.should raise_error(TypeError)
diff --git a/spec/ruby/core/kernel/instance_variable_get_spec.rb b/spec/ruby/core/kernel/instance_variable_get_spec.rb
index 84d3188f07..0c564f11b6 100644
--- a/spec/ruby/core/kernel/instance_variable_get_spec.rb
+++ b/spec/ruby/core/kernel/instance_variable_get_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#instance_variable_get" do
before :each do
@@ -24,25 +24,25 @@ describe "Kernel#instance_variable_get" do
end
it "raises a TypeError when the passed argument does not respond to #to_str" do
- -> { @obj.instance_variable_get(Object.new) }.should raise_error(TypeError)
+ lambda { @obj.instance_variable_get(Object.new) }.should raise_error(TypeError)
end
it "raises a TypeError when the passed argument can't be converted to a String" do
obj = mock("to_str")
obj.stub!(:to_str).and_return(123)
- -> { @obj.instance_variable_get(obj) }.should raise_error(TypeError)
+ lambda { @obj.instance_variable_get(obj) }.should raise_error(TypeError)
end
it "raises a NameError when the conversion result does not start with an '@'" do
obj = mock("to_str")
obj.stub!(:to_str).and_return("test")
- -> { @obj.instance_variable_get(obj) }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get(obj) }.should raise_error(NameError)
end
it "raises a NameError when passed just '@'" do
obj = mock("to_str")
obj.stub!(:to_str).and_return('@')
- -> { @obj.instance_variable_get(obj) }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get(obj) }.should raise_error(NameError)
end
end
@@ -57,15 +57,15 @@ describe "Kernel#instance_variable_get when passed Symbol" do
end
it "raises a NameError when passed :@ as an instance variable name" do
- -> { @obj.instance_variable_get(:"@") }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get(:"@") }.should raise_error(NameError)
end
it "raises a NameError when the passed Symbol does not start with an '@'" do
- -> { @obj.instance_variable_get(:test) }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get(:test) }.should raise_error(NameError)
end
it "raises a NameError when the passed Symbol is an invalid instance variable name" do
- -> { @obj.instance_variable_get(:"@0") }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get(:"@0") }.should raise_error(NameError)
end
end
@@ -80,15 +80,15 @@ describe "Kernel#instance_variable_get when passed String" do
end
it "raises a NameError when the passed String does not start with an '@'" do
- -> { @obj.instance_variable_get("test") }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get("test") }.should raise_error(NameError)
end
it "raises a NameError when the passed String is an invalid instance variable name" do
- -> { @obj.instance_variable_get("@0") }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get("@0") }.should raise_error(NameError)
end
it "raises a NameError when passed '@' as an instance variable name" do
- -> { @obj.instance_variable_get("@") }.should raise_error(NameError)
+ lambda { @obj.instance_variable_get("@") }.should raise_error(NameError)
end
end
@@ -99,7 +99,7 @@ describe "Kernel#instance_variable_get when passed Fixnum" do
end
it "raises a TypeError" do
- -> { @obj.instance_variable_get(10) }.should raise_error(TypeError)
- -> { @obj.instance_variable_get(-10) }.should raise_error(TypeError)
+ lambda { @obj.instance_variable_get(10) }.should raise_error(TypeError)
+ lambda { @obj.instance_variable_get(-10) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/instance_variable_set_spec.rb b/spec/ruby/core/kernel/instance_variable_set_spec.rb
index c5a4085530..bac1bb5f99 100644
--- a/spec/ruby/core/kernel/instance_variable_set_spec.rb
+++ b/spec/ruby/core/kernel/instance_variable_set_spec.rb
@@ -1,43 +1,43 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#instance_variable_set" do
it "sets the value of the specified instance variable" do
- dog = Class.new do
+ class Dog
def initialize(p1, p2)
@a, @b = p1, p2
end
end
- dog.new('cat', 99).instance_variable_set(:@a, 'dog').should == "dog"
+ Dog.new('cat', 99).instance_variable_set(:@a, 'dog').should == "dog"
end
it "sets the value of the instance variable when no instance variables exist yet" do
- no_variables = Class.new
- no_variables.new.instance_variable_set(:@a, "new").should == "new"
+ class NoVariables; end
+ NoVariables.new.instance_variable_set(:@a, "new").should == "new"
end
it "raises a NameError exception if the argument is not of form '@x'" do
- no_dog = Class.new
- -> { no_dog.new.instance_variable_set(:c, "cat") }.should raise_error(NameError)
+ class NoDog; end
+ lambda { NoDog.new.instance_variable_set(:c, "cat") }.should raise_error(NameError)
end
it "raises a NameError exception if the argument is an invalid instance variable name" do
- digit_dog = Class.new
- -> { digit_dog.new.instance_variable_set(:"@0", "cat") }.should raise_error(NameError)
+ class DigitDog; end
+ lambda { DigitDog.new.instance_variable_set(:"@0", "cat") }.should raise_error(NameError)
end
it "raises a NameError when the argument is '@'" do
- dog_at = Class.new
- -> { dog_at.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError)
+ class DogAt; end
+ lambda { DogAt.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError)
end
it "raises a TypeError if the instance variable name is a Fixnum" do
- -> { "".instance_variable_set(1, 2) }.should raise_error(TypeError)
+ lambda { "".instance_variable_set(1, 2) }.should raise_error(TypeError)
end
it "raises a TypeError if the instance variable name is an object that does not respond to to_str" do
class KernelSpecs::A; end
- -> { "".instance_variable_set(KernelSpecs::A.new, 3) }.should raise_error(TypeError)
+ lambda { "".instance_variable_set(KernelSpecs::A.new, 3) }.should raise_error(TypeError)
end
it "raises a NameError if the passed object, when coerced with to_str, does not start with @" do
@@ -46,11 +46,11 @@ describe "Kernel#instance_variable_set" do
":c"
end
end
- -> { "".instance_variable_set(KernelSpecs::B.new, 4) }.should raise_error(NameError)
+ lambda { "".instance_variable_set(KernelSpecs::B.new, 4) }.should raise_error(NameError)
end
it "raises a NameError if pass an object that cannot be a symbol" do
- -> { "".instance_variable_set(:c, 1) }.should raise_error(NameError)
+ lambda { "".instance_variable_set(:c, 1) }.should raise_error(NameError)
end
it "accepts as instance variable name any instance of a class that responds to to_str" do
@@ -78,16 +78,16 @@ describe "Kernel#instance_variable_set" do
end
it "keeps stored object after any exceptions" do
- -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(Exception)
+ lambda { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(Exception)
@frozen.ivar.should equal(:origin)
end
- it "raises a #{frozen_error_class} when passed replacement is identical to stored object" do
- -> { @frozen.instance_variable_set(:@ivar, :origin) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed replacement is identical to stored object" do
+ lambda { @frozen.instance_variable_set(:@ivar, :origin) }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when passed replacement is different from stored object" do
- -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed replacement is different from stored object" do
+ lambda { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/kernel/instance_variables_spec.rb b/spec/ruby/core/kernel/instance_variables_spec.rb
index b6d6e27772..f744ee3c7a 100644
--- a/spec/ruby/core/kernel/instance_variables_spec.rb
+++ b/spec/ruby/core/kernel/instance_variables_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#instance_variables" do
describe "immediate values" do
@@ -9,7 +9,7 @@ describe "Kernel#instance_variables" do
it "returns the correct array if an instance variable is added" do
a = 0
- ->{ a.instance_variable_set("@test", 1) }.should raise_error(RuntimeError)
+ lambda{ a.instance_variable_set("@test", 1) }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/kernel/is_a_spec.rb b/spec/ruby/core/kernel/is_a_spec.rb
index dc69766f83..c67c6552a0 100644
--- a/spec/ruby/core/kernel/is_a_spec.rb
+++ b/spec/ruby/core/kernel/is_a_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/kind_of'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/kind_of', __FILE__)
describe "Kernel#is_a?" do
- it_behaves_like :kernel_kind_of , :is_a?
+ it_behaves_like(:kernel_kind_of , :is_a?)
end
diff --git a/spec/ruby/core/kernel/iterator_spec.rb b/spec/ruby/core/kernel/iterator_spec.rb
index 7fbdade9dc..e85f0dc612 100644
--- a/spec/ruby/core/kernel/iterator_spec.rb
+++ b/spec/ruby/core/kernel/iterator_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#iterator?" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/itself_spec.rb b/spec/ruby/core/kernel/itself_spec.rb
index c906d7c3e8..722d75d718 100644
--- a/spec/ruby/core/kernel/itself_spec.rb
+++ b/spec/ruby/core/kernel/itself_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#itself" do
it "returns the receiver itself" do
diff --git a/spec/ruby/core/kernel/kind_of_spec.rb b/spec/ruby/core/kernel/kind_of_spec.rb
index 734035620c..56a54ec859 100644
--- a/spec/ruby/core/kernel/kind_of_spec.rb
+++ b/spec/ruby/core/kernel/kind_of_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/kind_of'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/kind_of', __FILE__)
describe "Kernel#kind_of?" do
- it_behaves_like :kernel_kind_of , :kind_of?
+ it_behaves_like(:kernel_kind_of , :kind_of?)
end
diff --git a/spec/ruby/core/kernel/lambda_spec.rb b/spec/ruby/core/kernel/lambda_spec.rb
index 5c30511270..8fa0075675 100644
--- a/spec/ruby/core/kernel/lambda_spec.rb
+++ b/spec/ruby/core/kernel/lambda_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/lambda'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/lambda', __FILE__)
# The functionality of lambdas is specified in core/proc
describe "Kernel.lambda" do
- it_behaves_like :kernel_lambda, :lambda
+ it_behaves_like(:kernel_lambda, :lambda)
it "is a private method" do
Kernel.should have_private_instance_method(:lambda)
@@ -16,50 +16,13 @@ describe "Kernel.lambda" do
l.lambda?.should be_true
end
- it "creates a lambda-style Proc if given a literal block via #send" do
- l = send(:lambda) { 42 }
- l.lambda?.should be_true
- end
-
- it "creates a lambda-style Proc if given a literal block via #__send__" do
- l = __send__(:lambda) { 42 }
- l.lambda?.should be_true
- end
-
- it "creates a lambda-style Proc if given a literal block via Kernel.public_send" do
- l = Kernel.public_send(:lambda) { 42 }
- l.lambda?.should be_true
- end
-
- it "returns the passed Proc if given an existing Proc" do
+ it "returned the passed Proc if given an existing Proc" do
some_proc = proc {}
l = lambda(&some_proc)
l.should equal(some_proc)
l.lambda?.should be_false
end
- it "creates a lambda-style Proc when called with zsuper" do
- l = KernelSpecs::LambdaSpecs::ForwardBlockWithZSuper.new.lambda { 42 }
- l.lambda?.should be_true
- l.call.should == 42
-
- lambda { l.call(:extra) }.should raise_error(ArgumentError)
- end
-
- it "returns the passed Proc if given an existing Proc through super" do
- some_proc = proc { }
- l = KernelSpecs::LambdaSpecs::SuperAmpersand.new.lambda(&some_proc)
- l.should equal(some_proc)
- l.lambda?.should be_false
- end
-
- it "does not create lambda-style Procs when captured with #method" do
- kernel_lambda = method(:lambda)
- l = kernel_lambda.call { 42 }
- l.lambda?.should be_false
- l.call(:extra).should == 42
- end
-
it "checks the arity of the call when no args are specified" do
l = lambda { :called }
l.call.should == :called
@@ -120,3 +83,4 @@ describe "Kernel.lambda" do
KernelSpecs::Lambda.new.outer.should == :good
end
end
+
diff --git a/spec/ruby/core/kernel/load_spec.rb b/spec/ruby/core/kernel/load_spec.rb
index a165cc4acd..36cc07e38a 100644
--- a/spec/ruby/core/kernel/load_spec.rb
+++ b/spec/ruby/core/kernel/load_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/code_loading'
-require_relative 'shared/load'
-require_relative 'shared/require'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/code_loading', __FILE__)
+require File.expand_path('../shared/load', __FILE__)
+require File.expand_path('../shared/require', __FILE__)
describe "Kernel#load" do
before :each do
diff --git a/spec/ruby/core/kernel/local_variables_spec.rb b/spec/ruby/core/kernel/local_variables_spec.rb
index f6f1e15f52..7e8b364b4f 100644
--- a/spec/ruby/core/kernel/local_variables_spec.rb
+++ b/spec/ruby/core/kernel/local_variables_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#local_variables" do
after :each do
@@ -34,15 +34,4 @@ describe "Kernel#local_variables" do
ScratchPad.recorded.should include(:a, :b)
ScratchPad.recorded.length.should == 2
end
-
- it "includes only unique variable names" do
- def local_var_method
- a = 1
- 1.times do |;a|
- return local_variables
- end
- end
-
- local_var_method.should == [:a]
- end
end
diff --git a/spec/ruby/core/kernel/loop_spec.rb b/spec/ruby/core/kernel/loop_spec.rb
index 7c76c7d28e..f23e3afb02 100644
--- a/spec/ruby/core/kernel/loop_spec.rb
+++ b/spec/ruby/core/kernel/loop_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.loop" do
it "is a private method" do
@@ -55,16 +55,18 @@ describe "Kernel.loop" do
end
it "does not rescue other errors" do
- ->{ loop do raise StandardError end }.should raise_error( StandardError )
+ lambda{ loop do raise StandardError end }.should raise_error( StandardError )
end
- it "returns StopIteration#result, the result value of a finished iterator" do
- e = Enumerator.new { |y|
- y << 1
- y << 2
- :stopped
- }
- loop { e.next }.should == :stopped
+ ruby_version_is "2.3" do
+ it "returns StopIteration#result, the result value of a finished iterator" do
+ e = Enumerator.new { |y|
+ y << 1
+ y << 2
+ :stopped
+ }
+ loop { e.next }.should == :stopped
+ end
end
describe "when no block is given" do
diff --git a/spec/ruby/core/kernel/match_spec.rb b/spec/ruby/core/kernel/match_spec.rb
index 687cd68da4..8a117ed497 100644
--- a/spec/ruby/core/kernel/match_spec.rb
+++ b/spec/ruby/core/kernel/match_spec.rb
@@ -1,24 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Kernel#=~" do
it "returns nil matching any object" do
o = Object.new
- suppress_warning do
- (o =~ /Object/).should be_nil
- (o =~ 'Object').should be_nil
- (o =~ Object).should be_nil
- (o =~ Object.new).should be_nil
- (o =~ nil).should be_nil
- (o =~ true).should be_nil
- end
- end
-
- ruby_version_is "2.6"..."2.7" do
- it "is deprecated" do
- -> do
- Object.new =~ /regexp/
- end.should complain(/deprecated Object#=~ is called on Object/, verbose: true)
- end
+ (o =~ /Object/).should be_nil
+ (o =~ 'Object').should be_nil
+ (o =~ Object).should be_nil
+ (o =~ Object.new).should be_nil
+ (o =~ nil).should be_nil
+ (o =~ true).should be_nil
end
end
diff --git a/spec/ruby/core/kernel/method_spec.rb b/spec/ruby/core/kernel/method_spec.rb
index 25c6691e10..09a3f940ca 100644
--- a/spec/ruby/core/kernel/method_spec.rb
+++ b/spec/ruby/core/kernel/method_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'shared/method'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/method', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#method" do
- it_behaves_like :kernel_method, :method
+ it_behaves_like(:kernel_method, :method)
before :each do
@obj = KernelSpecs::A.new
diff --git a/spec/ruby/core/kernel/methods_spec.rb b/spec/ruby/core/kernel/methods_spec.rb
index fb7a7e8be9..5dfb17d4cb 100644
--- a/spec/ruby/core/kernel/methods_spec.rb
+++ b/spec/ruby/core/kernel/methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../fixtures/reflection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
# TODO: rewrite
describe "Kernel#methods" do
diff --git a/spec/ruby/core/kernel/nil_spec.rb b/spec/ruby/core/kernel/nil_spec.rb
index b63705f7bc..0b5e34f7f1 100644
--- a/spec/ruby/core/kernel/nil_spec.rb
+++ b/spec/ruby/core/kernel/nil_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#nil?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/kernel/not_match_spec.rb b/spec/ruby/core/kernel/not_match_spec.rb
index 906f18df2c..42bd45c106 100644
--- a/spec/ruby/core/kernel/not_match_spec.rb
+++ b/spec/ruby/core/kernel/not_match_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#!~" do
class KernelSpecs::NotMatch
diff --git a/spec/ruby/core/kernel/object_id_spec.rb b/spec/ruby/core/kernel/object_id_spec.rb
index ef9e80c831..0a12415a40 100644
--- a/spec/ruby/core/kernel/object_id_spec.rb
+++ b/spec/ruby/core/kernel/object_id_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/kernel/object_id'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/kernel/object_id', __FILE__)
describe "Kernel#object_id" do
it_behaves_like :object_id, :object_id, Object
diff --git a/spec/ruby/core/kernel/open_spec.rb b/spec/ruby/core/kernel/open_spec.rb
index 981b5291b3..ff56dfa03b 100644
--- a/spec/ruby/core/kernel/open_spec.rb
+++ b/spec/ruby/core/kernel/open_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#open" do
@@ -45,10 +45,8 @@ describe "Kernel#open" do
end
it "opens an io for writing" do
- -> do
- bytes = open("|cat", "w") { |io| io.write(".") }
- bytes.should == 1
- end.should output_to_fd(".")
+ bytes = open("|cat", "w") { |io| io.write(".") }
+ bytes.should == 1
end
end
@@ -70,7 +68,7 @@ describe "Kernel#open" do
end
it "raises an ArgumentError if not passed one argument" do
- -> { open }.should raise_error(ArgumentError)
+ lambda { open }.should raise_error(ArgumentError)
end
describe "when given an object that responds to to_open" do
@@ -129,9 +127,9 @@ describe "Kernel#open" do
it "raises a TypeError if passed a non-String that does not respond to #to_open" do
obj = mock('non-fileish')
- -> { open(obj) }.should raise_error(TypeError)
- -> { open(nil) }.should raise_error(TypeError)
- -> { open(7) }.should raise_error(TypeError)
+ lambda { open(obj) }.should raise_error(TypeError)
+ lambda { open(nil) }.should raise_error(TypeError)
+ lambda { open(7) }.should raise_error(TypeError)
end
it "accepts nil for mode and permission" do
diff --git a/spec/ruby/core/kernel/p_spec.rb b/spec/ruby/core/kernel/p_spec.rb
index 798bd47b34..c451f5952a 100644
--- a/spec/ruby/core/kernel/p_spec.rb
+++ b/spec/ruby/core/kernel/p_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#p" do
before :all do
@@ -7,9 +7,7 @@ describe "Kernel#p" do
end
after :each do
- suppress_warning {
- $/, $\, $, = @rs_f, @rs_b, @rs_c
- }
+ $/, $\, $, = @rs_f, @rs_b, @rs_c
end
it "is a private method" do
@@ -42,34 +40,32 @@ describe "Kernel#p" do
o = mock("Inspector Gadget")
o.should_receive(:inspect).any_number_of_times.and_return "Next time, Gadget, NEXT TIME!"
- -> { p(o) }.should output("Next time, Gadget, NEXT TIME!\n")
- -> { p(*[o]) }.should output("Next time, Gadget, NEXT TIME!\n")
- -> { p(*[o, o]) }.should output("Next time, Gadget, NEXT TIME!\nNext time, Gadget, NEXT TIME!\n")
- -> { p([o])}.should output("[#{o.inspect}]\n")
+ lambda { p(o) }.should output("Next time, Gadget, NEXT TIME!\n")
+ lambda { p(*[o]) }.should output("Next time, Gadget, NEXT TIME!\n")
+ lambda { p(*[o, o]) }.should output("Next time, Gadget, NEXT TIME!\nNext time, Gadget, NEXT TIME!\n")
+ lambda { p([o])}.should output("[#{o.inspect}]\n")
end
it "is not affected by setting $\\, $/ or $," do
o = mock("Inspector Gadget")
o.should_receive(:inspect).any_number_of_times.and_return "Next time, Gadget, NEXT TIME!"
- suppress_warning {
- $, = " *helicopter sound*\n"
- }
- -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
+ $, = " *helicopter sound*\n"
+ lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
$\ = " *helicopter sound*\n"
- -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
+ lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
$/ = " *helicopter sound*\n"
- -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
+ lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
end
it "prints nothing if no argument is given" do
- -> { p }.should output("")
+ lambda { p }.should output("")
end
it "prints nothing if called splatting an empty Array" do
- -> { p(*[]) }.should output("")
+ lambda { p(*[]) }.should output("")
end
=begin Not sure how to spec this, but wanted to note the behavior here
diff --git a/spec/ruby/core/kernel/pp_spec.rb b/spec/ruby/core/kernel/pp_spec.rb
deleted file mode 100644
index e19dc64caf..0000000000
--- a/spec/ruby/core/kernel/pp_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.5" do
- describe "Kernel#pp" do
- it "lazily loads the 'pp' library and delegates the call to that library" do
- # Run in child process to ensure 'pp' hasn't been loaded yet.
- output = ruby_exe("pp [1, 2, 3]")
- output.should == "[1, 2, 3]\n"
- end
- end
-end
diff --git a/spec/ruby/core/kernel/print_spec.rb b/spec/ruby/core/kernel/print_spec.rb
index c8c4453d1e..3b642538cb 100644
--- a/spec/ruby/core/kernel/print_spec.rb
+++ b/spec/ruby/core/kernel/print_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#print" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/printf_spec.rb b/spec/ruby/core/kernel/printf_spec.rb
index 5d68c0a13c..ed134027c0 100644
--- a/spec/ruby/core/kernel/printf_spec.rb
+++ b/spec/ruby/core/kernel/printf_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/sprintf'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/sprintf', __FILE__)
require "stringio"
describe "Kernel#printf" do
@@ -36,7 +36,7 @@ describe "Kernel.printf" do
describe "formatting" do
context "io is specified" do
- it_behaves_like :kernel_sprintf, -> format, *args {
+ it_behaves_like :kernel_sprintf, -> (format, *args) {
io = StringIO.new
printf(io, format, *args)
io.string
@@ -44,7 +44,7 @@ describe "Kernel.printf" do
end
context "io is not specified" do
- it_behaves_like :kernel_sprintf, -> format, *args {
+ it_behaves_like :kernel_sprintf, -> (format, *args) {
stdout = $stdout
begin
@@ -58,3 +58,4 @@ describe "Kernel.printf" do
end
end
end
+
diff --git a/spec/ruby/core/kernel/private_methods_spec.rb b/spec/ruby/core/kernel/private_methods_spec.rb
index 041634d1e5..d0603c72b8 100644
--- a/spec/ruby/core/kernel/private_methods_spec.rb
+++ b/spec/ruby/core/kernel/private_methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../fixtures/reflection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
# TODO: rewrite
describe "Kernel#private_methods" do
diff --git a/spec/ruby/core/kernel/proc_spec.rb b/spec/ruby/core/kernel/proc_spec.rb
index 7854af44d0..4e4854f97d 100644
--- a/spec/ruby/core/kernel/proc_spec.rb
+++ b/spec/ruby/core/kernel/proc_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/lambda'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/lambda', __FILE__)
# The functionality of Proc objects is specified in core/proc
@@ -15,14 +15,14 @@ describe "Kernel.proc" do
end
it "returned the passed Proc if given an existing Proc" do
- some_lambda = -> {}
+ some_lambda = lambda {}
some_lambda.lambda?.should be_true
l = proc(&some_lambda)
l.should equal(some_lambda)
l.lambda?.should be_true
end
- it_behaves_like :kernel_lambda, :proc
+ it_behaves_like(:kernel_lambda, :proc)
it "returns from the creation site of the proc, not just the proc itself" do
@reached_end_of_method = nil
@@ -36,35 +36,15 @@ describe "Kernel.proc" do
end
describe "Kernel#proc" do
- ruby_version_is ""..."2.7" do
- it "uses the implicit block from an enclosing method" do
- def some_method
- proc
- end
-
- prc = some_method { "hello" }
-
- prc.call.should == "hello"
- end
- end
-
- ruby_version_is "2.7" do
- before :each do
- @deprecated = Warning[:deprecated]
- Warning[:deprecated] = true
- end
- after :each do
- Warning[:deprecated] = @deprecated
+ it "uses the implicit block from an enclosing method" do
+ def some_method
+ proc
end
- it "can be created when called with no block" do
- def some_method
- proc
- end
+ prc = some_method { "hello" }
- -> {
- some_method { "hello" }
- }.should complain(/Capturing the given block using Kernel#proc is deprecated/)
- end
+ prc.call.should == "hello"
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/kernel/protected_methods_spec.rb b/spec/ruby/core/kernel/protected_methods_spec.rb
index d3334e886b..2e09cead53 100644
--- a/spec/ruby/core/kernel/protected_methods_spec.rb
+++ b/spec/ruby/core/kernel/protected_methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../fixtures/reflection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
# TODO: rewrite
diff --git a/spec/ruby/core/kernel/public_method_spec.rb b/spec/ruby/core/kernel/public_method_spec.rb
index c5d54c777e..f1cc168420 100644
--- a/spec/ruby/core/kernel/public_method_spec.rb
+++ b/spec/ruby/core/kernel/public_method_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/method'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/method', __FILE__)
describe "Kernel#public_method" do
- it_behaves_like :kernel_method, :public_method
+ it_behaves_like(:kernel_method, :public_method)
before :each do
@obj = KernelSpecs::A.new
@@ -11,21 +11,21 @@ describe "Kernel#public_method" do
it "raises a NameError when called on a private method" do
@obj.send(:private_method).should == :private_method
- -> do
+ lambda do
@obj.public_method(:private_method)
end.should raise_error(NameError)
end
it "raises a NameError when called on a protected method" do
@obj.send(:protected_method).should == :protected_method
- -> {
+ lambda {
@obj.public_method(:protected_method)
}.should raise_error(NameError)
end
it "raises a NameError if we only repond_to_missing? method, true" do
obj = KernelSpecs::RespondViaMissing.new
- -> do
+ lambda do
obj.public_method(:handled_privately)
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/kernel/public_methods_spec.rb b/spec/ruby/core/kernel/public_methods_spec.rb
index a5512784fb..b72775483c 100644
--- a/spec/ruby/core/kernel/public_methods_spec.rb
+++ b/spec/ruby/core/kernel/public_methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../fixtures/reflection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
# TODO: rewrite
describe "Kernel#public_methods" do
diff --git a/spec/ruby/core/kernel/public_send_spec.rb b/spec/ruby/core/kernel/public_send_spec.rb
index 6b942a2e4b..2eabbc7dc9 100644
--- a/spec/ruby/core/kernel/public_send_spec.rb
+++ b/spec/ruby/core/kernel/public_send_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/basicobject/send'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/basicobject/send', __FILE__)
describe "Kernel#public_send" do
it "invokes the named public method" do
@@ -29,7 +29,7 @@ describe "Kernel#public_send" do
'done'
end
end
- -> { KernelSpecs::Foo.new.public_send(:bar)}.should raise_error(NoMethodError)
+ lambda { KernelSpecs::Foo.new.public_send(:bar)}.should raise_error(NoMethodError)
end
it "raises a NoMethodError if the named method is private" do
@@ -39,7 +39,7 @@ describe "Kernel#public_send" do
'done2'
end
end
- -> {
+ lambda {
KernelSpecs::Foo.new.public_send(:bar)
}.should raise_error(NoMethodError)
end
@@ -70,11 +70,11 @@ describe "Kernel#public_send" do
end
it "raises a NoMethodError if the method is protected" do
- -> { @receiver.call_protected_method }.should raise_error(NoMethodError)
+ lambda { @receiver.call_protected_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError if the method is private" do
- -> { @receiver.call_private_method }.should raise_error(NoMethodError)
+ lambda { @receiver.call_private_method }.should raise_error(NoMethodError)
end
end
@@ -86,7 +86,7 @@ describe "Kernel#public_send" do
end
alias :aka :bar
end
- -> {
+ lambda {
KernelSpecs::Foo.new.public_send(:aka)
}.should raise_error(NoMethodError)
end
@@ -99,10 +99,10 @@ describe "Kernel#public_send" do
end
alias :aka :bar
end
- -> {
+ lambda {
KernelSpecs::Foo.new.public_send(:aka)
}.should raise_error(NoMethodError)
end
- it_behaves_like :basicobject_send, :public_send
+ it_behaves_like(:basicobject_send, :public_send)
end
diff --git a/spec/ruby/core/kernel/putc_spec.rb b/spec/ruby/core/kernel/putc_spec.rb
index 74bd3765db..1f5e9b6d63 100644
--- a/spec/ruby/core/kernel/putc_spec.rb
+++ b/spec/ruby/core/kernel/putc_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/io/putc'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/io/putc', __FILE__)
describe "Kernel#putc" do
it "is a private instance method" do
diff --git a/spec/ruby/core/kernel/puts_spec.rb b/spec/ruby/core/kernel/puts_spec.rb
index 6eb38e8fcf..c5297f1cb2 100644
--- a/spec/ruby/core/kernel/puts_spec.rb
+++ b/spec/ruby/core/kernel/puts_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#puts" do
before :each do
diff --git a/spec/ruby/core/kernel/raise_spec.rb b/spec/ruby/core/kernel/raise_spec.rb
index bf26560246..6efffd9366 100644
--- a/spec/ruby/core/kernel/raise_spec.rb
+++ b/spec/ruby/core/kernel/raise_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/kernel/raise'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/kernel/raise', __FILE__)
describe "Kernel#raise" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/rand_spec.rb b/spec/ruby/core/kernel/rand_spec.rb
index a82b4fba74..f52b5f75b5 100644
--- a/spec/ruby/core/kernel/rand_spec.rb
+++ b/spec/ruby/core/kernel/rand_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.rand" do
it "is a private method" do
@@ -132,22 +132,6 @@ describe "Kernel.rand" do
it "returns the range start/end when Integer range is 0" do
rand(42..42).should eql(42)
end
-
- it "supports custom object types" do
- rand(KernelSpecs::CustomRangeInteger.new(1)..KernelSpecs::CustomRangeInteger.new(42)).should be_an_instance_of(KernelSpecs::CustomRangeInteger)
- rand(KernelSpecs::CustomRangeFloat.new(1.0)..KernelSpecs::CustomRangeFloat.new(42.0)).should be_an_instance_of(KernelSpecs::CustomRangeFloat)
- rand(Time.now..Time.now).should be_an_instance_of(Time)
- end
-
- it "is random on boot" do
- results = 2.times.map {
- out = ruby_exe('p rand', options: '--disable-gems')
- Float(out)
- }
- results.size.should == 2
- # this is technically flaky, but very unlikely in a good distribution
- results[0].should_not == results[1]
- end
end
describe "Kernel#rand" do
diff --git a/spec/ruby/core/kernel/readline_spec.rb b/spec/ruby/core/kernel/readline_spec.rb
index dce7b03dc8..c69eee0726 100644
--- a/spec/ruby/core/kernel/readline_spec.rb
+++ b/spec/ruby/core/kernel/readline_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#readline" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/readlines_spec.rb b/spec/ruby/core/kernel/readlines_spec.rb
index 2b6d65fff2..d5e07f8f75 100644
--- a/spec/ruby/core/kernel/readlines_spec.rb
+++ b/spec/ruby/core/kernel/readlines_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#readlines" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/remove_instance_variable_spec.rb b/spec/ruby/core/kernel/remove_instance_variable_spec.rb
index e90efc8aed..6a9f78b9bc 100644
--- a/spec/ruby/core/kernel/remove_instance_variable_spec.rb
+++ b/spec/ruby/core/kernel/remove_instance_variable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_remove_instance_variable, shared: true do
it "returns the instance variable's value" do
@@ -23,19 +23,19 @@ describe "Kernel#remove_instance_variable" do
end
it "raises a NameError if the instance variable is not defined" do
- -> do
+ lambda do
@instance.send :remove_instance_variable, :@unknown
end.should raise_error(NameError)
end
it "raises a NameError if the argument is not a valid instance variable name" do
- -> do
+ lambda do
@instance.send :remove_instance_variable, :"@0"
end.should raise_error(NameError)
end
it "raises a TypeError if passed an Object not defining #to_str" do
- -> do
+ lambda do
obj = mock("kernel remove_instance_variable")
@instance.send :remove_instance_variable, obj
end.should raise_error(TypeError)
diff --git a/spec/ruby/core/kernel/require_relative_spec.rb b/spec/ruby/core/kernel/require_relative_spec.rb
index b292a46c63..04cf5444d2 100644
--- a/spec/ruby/core/kernel/require_relative_spec.rb
+++ b/spec/ruby/core/kernel/require_relative_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/code_loading'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/code_loading', __FILE__)
describe "Kernel#require_relative with a relative path" do
+ it "needs to be reviewed for spec completeness"
+
before :each do
CodeLoadingSpecs.spec_setup
@dir = "../../fixtures/code"
@@ -38,66 +40,24 @@ describe "Kernel#require_relative with a relative path" do
ScratchPad.recorded.should == [:loaded]
end
- describe "in an #instance_eval with a" do
-
- it "synthetic file base name loads a file base name relative to the working directory" do
- Dir.chdir @abs_dir do
- Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "foo.rb").should be_true
- end
- ScratchPad.recorded.should == [:loaded]
- end
-
- it "synthetic file path loads a relative path relative to the working directory plus the directory of the synthetic path" do
- Dir.chdir @abs_dir do
- Object.new.instance_eval("require_relative(File.join('..', #{File.basename(@path).inspect}))", "bar/foo.rb").should be_true
- end
- ScratchPad.recorded.should == [:loaded]
- end
-
- platform_is_not :windows do
- it "synthetic relative file path with a Windows path separator specified loads a relative path relative to the working directory" do
- Dir.chdir @abs_dir do
- Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "bar\\foo.rb").should be_true
- end
- ScratchPad.recorded.should == [:loaded]
- end
- end
-
- it "absolute file path loads a path relative to the absolute path" do
- Object.new.instance_eval("require_relative(#{@path.inspect})", __FILE__).should be_true
- ScratchPad.recorded.should == [:loaded]
- end
-
- it "absolute file path loads a path relative to the root directory" do
- root = @abs_path
- until File.dirname(root) == root
- root = File.dirname(root)
- end
- root_relative = @abs_path[root.size..-1]
- Object.new.instance_eval("require_relative(#{root_relative.inspect})", "/").should be_true
- ScratchPad.recorded.should == [:loaded]
- end
-
- end
-
it "loads a file defining many methods" do
require_relative("#{@dir}/methods_fixture.rb").should be_true
ScratchPad.recorded.should == [:loaded]
end
it "raises a LoadError if the file does not exist" do
- -> { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
+ lambda { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
it "raises a LoadError if basepath does not exist" do
- -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
+ lambda { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
end
it "stores the missing path in a LoadError object" do
path = "#{@dir}/nonexistent.rb"
- -> {
+ lambda {
require_relative(path)
}.should(raise_error(LoadError) { |e|
e.path.should == File.expand_path(path, @abs_dir)
@@ -112,9 +72,9 @@ describe "Kernel#require_relative with a relative path" do
end
it "raises a TypeError if argument does not respond to #to_str" do
- -> { require_relative(nil) }.should raise_error(TypeError)
- -> { require_relative(42) }.should raise_error(TypeError)
- -> {
+ lambda { require_relative(nil) }.should raise_error(TypeError)
+ lambda { require_relative(42) }.should raise_error(TypeError)
+ lambda {
require_relative([@path,@path])
}.should raise_error(TypeError)
end
@@ -122,13 +82,13 @@ describe "Kernel#require_relative with a relative path" do
it "raises a TypeError if passed an object that has #to_s but not #to_str" do
name = mock("load_fixture.rb mock")
name.stub!(:to_s).and_return(@path)
- -> { require_relative(name) }.should raise_error(TypeError)
+ lambda { require_relative(name) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_str does not return a String" do
name = mock("#to_str returns nil")
name.should_receive(:to_str).at_least(1).times.and_return(nil)
- -> { require_relative(name) }.should raise_error(TypeError)
+ lambda { require_relative(name) }.should raise_error(TypeError)
end
it "calls #to_path on non-String objects" do
@@ -197,49 +157,9 @@ describe "Kernel#require_relative with a relative path" do
$LOADED_FEATURES.should include(@abs_path)
end
- platform_is_not :windows do
- describe "with symlinks" do
- before :each do
- @symlink_to_code_dir = tmp("codesymlink")
- File.symlink(CODE_LOADING_DIR, @symlink_to_code_dir)
- @symlink_basename = File.basename(@symlink_to_code_dir)
- @requiring_file = tmp("requiring")
- end
-
- after :each do
- rm_r @symlink_to_code_dir, @requiring_file
- end
-
- it "does not canonicalize the path and stores a path with symlinks" do
- symlink_path = "#{@symlink_basename}/load_fixture.rb"
- absolute_path = "#{tmp("")}#{symlink_path}"
- canonical_path = "#{CODE_LOADING_DIR}/load_fixture.rb"
- touch(@requiring_file) { |f|
- f.puts "require_relative #{symlink_path.inspect}"
- }
- load(@requiring_file)
- ScratchPad.recorded.should == [:loaded]
-
- features = $LOADED_FEATURES.select { |path| path.end_with?('load_fixture.rb') }
- features.should include(absolute_path)
- features.should_not include(canonical_path)
- end
-
- it "stores the same path that __FILE__ returns in the required file" do
- symlink_path = "#{@symlink_basename}/load_fixture_and__FILE__.rb"
- touch(@requiring_file) { |f|
- f.puts "require_relative #{symlink_path.inspect}"
- }
- load(@requiring_file)
- loaded_feature = $LOADED_FEATURES.last
- ScratchPad.recorded.should == [loaded_feature]
- end
- end
- end
-
it "does not store the path if the load fails" do
saved_loaded_features = $LOADED_FEATURES.dup
- -> { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
+ lambda { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
$LOADED_FEATURES.should == saved_loaded_features
end
@@ -265,6 +185,8 @@ describe "Kernel#require_relative with a relative path" do
end
describe "Kernel#require_relative with an absolute path" do
+ it "needs to be reviewed for spec completeness"
+
before :each do
CodeLoadingSpecs.spec_setup
@dir = File.expand_path "../../fixtures/code", File.dirname(__FILE__)
@@ -288,18 +210,18 @@ describe "Kernel#require_relative with an absolute path" do
end
it "raises a LoadError if the file does not exist" do
- -> { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
+ lambda { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
it "raises a LoadError if basepath does not exist" do
- -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
+ lambda { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
end
it "stores the missing path in a LoadError object" do
path = "#{@dir}/nonexistent.rb"
- -> {
+ lambda {
require_relative(path)
}.should(raise_error(LoadError) { |e|
e.path.should == File.expand_path(path, @abs_dir)
@@ -314,9 +236,9 @@ describe "Kernel#require_relative with an absolute path" do
end
it "raises a TypeError if argument does not respond to #to_str" do
- -> { require_relative(nil) }.should raise_error(TypeError)
- -> { require_relative(42) }.should raise_error(TypeError)
- -> {
+ lambda { require_relative(nil) }.should raise_error(TypeError)
+ lambda { require_relative(42) }.should raise_error(TypeError)
+ lambda {
require_relative([@path,@path])
}.should raise_error(TypeError)
end
@@ -324,13 +246,13 @@ describe "Kernel#require_relative with an absolute path" do
it "raises a TypeError if passed an object that has #to_s but not #to_str" do
name = mock("load_fixture.rb mock")
name.stub!(:to_s).and_return(@path)
- -> { require_relative(name) }.should raise_error(TypeError)
+ lambda { require_relative(name) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_str does not return a String" do
name = mock("#to_str returns nil")
name.should_receive(:to_str).at_least(1).times.and_return(nil)
- -> { require_relative(name) }.should raise_error(TypeError)
+ lambda { require_relative(name) }.should raise_error(TypeError)
end
it "calls #to_path on non-String objects" do
@@ -401,7 +323,7 @@ describe "Kernel#require_relative with an absolute path" do
it "does not store the path if the load fails" do
saved_loaded_features = $LOADED_FEATURES.dup
- -> { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
+ lambda { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
$LOADED_FEATURES.should == saved_loaded_features
end
diff --git a/spec/ruby/core/kernel/require_spec.rb b/spec/ruby/core/kernel/require_spec.rb
index dc3da4b7e6..75cea7565e 100644
--- a/spec/ruby/core/kernel/require_spec.rb
+++ b/spec/ruby/core/kernel/require_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/code_loading'
-require_relative 'shared/require'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/code_loading', __FILE__)
+require File.expand_path('../shared/require', __FILE__)
describe "Kernel#require" do
before :each do
@@ -17,6 +17,7 @@ describe "Kernel#require" do
end
it_behaves_like :kernel_require_basic, :require, CodeLoadingSpecs::Method.new
+
it_behaves_like :kernel_require, :require, CodeLoadingSpecs::Method.new
end
@@ -30,5 +31,6 @@ describe "Kernel.require" do
end
it_behaves_like :kernel_require_basic, :require, Kernel
+
it_behaves_like :kernel_require, :require, Kernel
end
diff --git a/spec/ruby/core/kernel/respond_to_missing_spec.rb b/spec/ruby/core/kernel/respond_to_missing_spec.rb
index cc82031e26..f116f19dbd 100644
--- a/spec/ruby/core/kernel/respond_to_missing_spec.rb
+++ b/spec/ruby/core/kernel/respond_to_missing_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#respond_to_missing?" do
before :each do
diff --git a/spec/ruby/core/kernel/respond_to_spec.rb b/spec/ruby/core/kernel/respond_to_spec.rb
index e7efc9f275..aa4379277b 100644
--- a/spec/ruby/core/kernel/respond_to_spec.rb
+++ b/spec/ruby/core/kernel/respond_to_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#respond_to?" do
before :each do
@@ -25,7 +25,7 @@ describe "Kernel#respond_to?" do
end
it "throws a type error if argument can't be coerced into a Symbol" do
- -> { @a.respond_to?(Object.new) }.should raise_error(TypeError)
+ lambda { @a.respond_to?(Object.new) }.should raise_error(TypeError)
end
it "returns false if obj responds to the given protected method" do
@@ -61,7 +61,7 @@ describe "Kernel#respond_to?" do
it "does not change method visibility when finding private method" do
KernelSpecs::VisibilityChange.respond_to?(:new, false).should == false
KernelSpecs::VisibilityChange.respond_to?(:new, true).should == true
- -> { KernelSpecs::VisibilityChange.new }.should raise_error(NoMethodError)
+ lambda { KernelSpecs::VisibilityChange.new }.should raise_error(NoMethodError)
end
it "indicates if an object responds to a particular message" do
diff --git a/spec/ruby/core/kernel/select_spec.rb b/spec/ruby/core/kernel/select_spec.rb
index e0d82f3079..c37c621ae7 100644
--- a/spec/ruby/core/kernel/select_spec.rb
+++ b/spec/ruby/core/kernel/select_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#select" do
it "is a private method" do
@@ -8,6 +8,8 @@ describe "Kernel#select" do
end
describe "Kernel.select" do
+ it "needs to be reviewed for spec completeness"
+
it 'does not block when timeout is 0' do
IO.pipe do |read, write|
IO.select([read], [], [], 0).should == nil
diff --git a/spec/ruby/core/kernel/send_spec.rb b/spec/ruby/core/kernel/send_spec.rb
index 9a4d261964..8afd16e97c 100644
--- a/spec/ruby/core/kernel/send_spec.rb
+++ b/spec/ruby/core/kernel/send_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/basicobject/send'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/basicobject/send', __FILE__)
describe "Kernel#send" do
it "invokes the named public method" do
@@ -64,5 +64,5 @@ describe "Kernel#send" do
KernelSpecs::Foo.new.send(:aka).should == 'done2'
end
- it_behaves_like :basicobject_send, :send
+ it_behaves_like(:basicobject_send, :send)
end
diff --git a/spec/ruby/core/kernel/set_trace_func_spec.rb b/spec/ruby/core/kernel/set_trace_func_spec.rb
index 1f43e7a009..5dafa8b5d3 100644
--- a/spec/ruby/core/kernel/set_trace_func_spec.rb
+++ b/spec/ruby/core/kernel/set_trace_func_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#set_trace_func" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/shared/dup_clone.rb b/spec/ruby/core/kernel/shared/dup_clone.rb
index a52ccab359..116989958b 100644
--- a/spec/ruby/core/kernel/shared/dup_clone.rb
+++ b/spec/ruby/core/kernel/shared/dup_clone.rb
@@ -52,16 +52,14 @@ describe :kernel_dup_clone, shared: true do
o2.original.should equal(o)
end
- ruby_version_is ''...'2.7' do
- it "preserves tainted state from the original" do
- o = ObjectSpecDupInitCopy.new
- o2 = o.send(@method)
- o.taint
- o3 = o.send(@method)
-
- o2.tainted?.should == false
- o3.tainted?.should == true
- end
+ it "preserves tainted state from the original" do
+ o = ObjectSpecDupInitCopy.new
+ o2 = o.send(@method)
+ o.taint
+ o3 = o.send(@method)
+
+ o2.tainted?.should == false
+ o3.tainted?.should == true
end
it "does not preserve the object_id" do
@@ -71,47 +69,69 @@ describe :kernel_dup_clone, shared: true do
o2.object_id.should_not == old_object_id
end
- ruby_version_is ''...'2.7' do
- it "preserves untrusted state from the original" do
- o = ObjectSpecDupInitCopy.new
- o2 = o.send(@method)
- o.untrust
- o3 = o.send(@method)
+ it "preserves untrusted state from the original" do
+ o = ObjectSpecDupInitCopy.new
+ o2 = o.send(@method)
+ o.untrust
+ o3 = o.send(@method)
- o2.untrusted?.should == false
- o3.untrusted?.should == true
- end
+ o2.untrusted?.should == false
+ o3.untrusted?.should == true
end
- it "returns nil for NilClass" do
- nil.send(@method).should == nil
- end
+ ruby_version_is ''...'2.4' do
+ it "raises a TypeError for NilClass" do
+ lambda { nil.send(@method) }.should raise_error(TypeError)
+ end
- it "returns true for TrueClass" do
- true.send(@method).should == true
- end
+ it "raises a TypeError for TrueClass" do
+ lambda { true.send(@method) }.should raise_error(TypeError)
+ end
- it "returns false for FalseClass" do
- false.send(@method).should == false
- end
+ it "raises a TypeError for FalseClass" do
+ lambda { false.send(@method) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError for Fixnum" do
+ lambda { 1.send(@method) }.should raise_error(TypeError)
+ end
- it "returns the same Integer for Integer" do
- 1.send(@method).should == 1
+ it "raises a TypeError for Symbol" do
+ lambda { :my_symbol.send(@method) }.should raise_error(TypeError)
+ end
end
- it "returns the same Symbol for Symbol" do
- :my_symbol.send(@method).should == :my_symbol
+ ruby_version_is '2.4' do
+ it "returns nil for NilClass" do
+ nil.send(@method).should == nil
+ end
+
+ it "returns true for TrueClass" do
+ true.send(@method).should == true
+ end
+
+ it "returns false for FalseClass" do
+ false.send(@method).should == false
+ end
+
+ it "returns the same Integer for Integer" do
+ 1.send(@method).should == 1
+ end
+
+ it "returns the same Symbol for Symbol" do
+ :my_symbol.send(@method).should == :my_symbol
+ end
end
ruby_version_is ''...'2.5' do
it "raises a TypeError for Complex" do
c = Complex(1.3, 3.1)
- -> { c.send(@method) }.should raise_error(TypeError)
+ lambda { c.send(@method) }.should raise_error(TypeError)
end
it "raises a TypeError for Rational" do
r = Rational(1, 3)
- -> { r.send(@method) }.should raise_error(TypeError)
+ lambda { r.send(@method) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/shared/kind_of.rb b/spec/ruby/core/kernel/shared/kind_of.rb
index aef6f1c1d8..e99f46aa14 100644
--- a/spec/ruby/core/kernel/shared/kind_of.rb
+++ b/spec/ruby/core/kernel/shared/kind_of.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :kernel_kind_of, shared: true do
before :each do
@@ -31,25 +31,14 @@ describe :kernel_kind_of, shared: true do
@o.send(@method, KernelSpecs::MyExtensionModule).should == true
end
- it "returns true if given a Module that object has been prepended with" do
- @o.send(@method, KernelSpecs::MyPrependedModule).should == true
- end
-
- it "returns false if given a Module not included nor prepended in object's class nor ancestors" do
+ it "returns false if given a Module not included in object's class nor ancestors" do
@o.send(@method, KernelSpecs::SomeOtherModule).should == false
end
it "raises a TypeError if given an object that is not a Class nor a Module" do
- -> { @o.send(@method, 1) }.should raise_error(TypeError)
- -> { @o.send(@method, 'KindaClass') }.should raise_error(TypeError)
- -> { @o.send(@method, :KindaClass) }.should raise_error(TypeError)
- -> { @o.send(@method, Object.new) }.should raise_error(TypeError)
- end
-
- it "does not take into account `class` method overriding" do
- def @o.class; Integer; end
-
- @o.send(@method, Integer).should == false
- @o.send(@method, KernelSpecs::KindaClass).should == true
+ lambda { @o.send(@method, 1) }.should raise_error(TypeError)
+ lambda { @o.send(@method, 'KindaClass') }.should raise_error(TypeError)
+ lambda { @o.send(@method, :KindaClass) }.should raise_error(TypeError)
+ lambda { @o.send(@method, Object.new) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/shared/lambda.rb b/spec/ruby/core/kernel/shared/lambda.rb
index c7180e1442..bebb111c43 100644
--- a/spec/ruby/core/kernel/shared/lambda.rb
+++ b/spec/ruby/core/kernel/shared/lambda.rb
@@ -4,6 +4,6 @@ describe :kernel_lambda, shared: true do
end
it "raises an ArgumentError when no block is given" do
- -> { send(@method) }.should raise_error(ArgumentError)
+ lambda { send(@method) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/kernel/shared/load.rb b/spec/ruby/core/kernel/shared/load.rb
index 120619abef..0ce7d58d2c 100644
--- a/spec/ruby/core/kernel/shared/load.rb
+++ b/spec/ruby/core/kernel/shared/load.rb
@@ -1,5 +1,3 @@
-main = self
-
describe :kernel_load, shared: true do
before :each do
CodeLoadingSpecs.spec_setup
@@ -32,8 +30,9 @@ describe :kernel_load, shared: true do
it "loads a file that recursively requires itself" do
path = File.expand_path "recursive_require_fixture.rb", CODE_LOADING_DIR
-> {
+ $VERBOSE = true
@object.load(path).should be_true
- }.should complain(/circular require considered harmful/, verbose: true)
+ }.should complain(/circular require considered harmful/)
ScratchPad.recorded.should == [:loaded, :loaded]
end
@@ -83,7 +82,7 @@ describe :kernel_load, shared: true do
it "raises a LoadError if passed a non-extensioned path that does not exist but a .rb extensioned path does exist" do
path = File.expand_path "load_ext_fixture", CODE_LOADING_DIR
- -> { @object.load(path) }.should raise_error(LoadError)
+ lambda { @object.load(path) }.should raise_error(LoadError)
end
describe "when passed true for 'wrap'" do
@@ -97,45 +96,13 @@ describe :kernel_load, shared: true do
@object.load(path, true)
Object.const_defined?(:LoadSpecWrap).should be_false
-
- wrap_module = ScratchPad.recorded[1]
- wrap_module.should be_an_instance_of(Module)
end
it "allows referencing outside namespaces" do
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
@object.load(path, true)
- ScratchPad.recorded[0].should equal(String)
- end
-
- it "sets self as a copy of the top-level main" do
- path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
- @object.load(path, true)
-
- top_level = ScratchPad.recorded[2]
- top_level.to_s.should == "main"
- top_level.method(:to_s).owner.should == top_level.singleton_class
- top_level.should_not equal(main)
- top_level.should be_an_instance_of(Object)
- end
-
- it "includes modules included in main's singleton class in self's class" do
- mod = Module.new
- main.extend(mod)
-
- main_ancestors = main.singleton_class.ancestors[1..-1]
- main_ancestors.first.should == mod
-
- path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
- @object.load(path, true)
-
- top_level = ScratchPad.recorded[2]
- top_level_ancestors = top_level.singleton_class.ancestors[-main_ancestors.size..-1]
- top_level_ancestors.should == main_ancestors
-
- wrap_module = ScratchPad.recorded[1]
- top_level.singleton_class.ancestors.should == [top_level.singleton_class, wrap_module, *main_ancestors]
+ ScratchPad.recorded.first.should be_an_instance_of(Class)
end
describe "with top-level methods" do
@@ -149,7 +116,7 @@ describe :kernel_load, shared: true do
end
it "does not pollute the receiver" do
- -> { @object.send(:top_level_method) }.should raise_error(NameError)
+ lambda { @object.send(:top_level_method) }.should raise_error(NameError)
end
end
end
diff --git a/spec/ruby/core/kernel/shared/method.rb b/spec/ruby/core/kernel/shared/method.rb
index 3418966b1b..1566c6ab09 100644
--- a/spec/ruby/core/kernel/shared/method.rb
+++ b/spec/ruby/core/kernel/shared/method.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :kernel_method, shared: true do
it "returns a method object for a valid method" do
@@ -23,14 +23,14 @@ describe :kernel_method, shared: true do
it "raises a NameError for an invalid method name" do
class KernelSpecs::Foo; def bar; 'done'; end; end
- -> {
+ lambda {
KernelSpecs::Foo.new.send(@method, :invalid_and_silly_method_name)
}.should raise_error(NameError)
end
it "raises a NameError for an invalid singleton method name" do
class KernelSpecs::Foo; def self.bar; 'done'; end; end
- -> { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
+ lambda { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
end
it "changes the method called for super on a target aliased method" do
diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb
index 52089f22fe..3296c7f42a 100644
--- a/spec/ruby/core/kernel/shared/require.rb
+++ b/spec/ruby/core/kernel/shared/require.rb
@@ -20,30 +20,28 @@ describe :kernel_require_basic, shared: true do
it "raises a LoadError if the file does not exist" do
path = File.expand_path "nonexistent.rb", CODE_LOADING_DIR
- File.should_not.exist?(path)
- -> { @object.send(@method, path) }.should raise_error(LoadError)
+ File.exist?(path).should be_false
+ lambda { @object.send(@method, path) }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
# Can't make a file unreadable on these platforms
platform_is_not :windows, :cygwin do
- as_user do
- describe "with an unreadable file" do
- before :each do
- @path = tmp("unreadable_file.rb")
- touch @path
- File.chmod 0000, @path
- end
-
- after :each do
- File.chmod 0666, @path
- rm_r @path
- end
-
- it "raises a LoadError" do
- File.should.exist?(@path)
- -> { @object.send(@method, @path) }.should raise_error(LoadError)
- end
+ describe "with an unreadable file" do
+ before :each do
+ @path = tmp("unreadable_file.rb")
+ touch @path
+ File.chmod 0000, @path
+ end
+
+ after :each do
+ File.chmod 0666, @path
+ rm_r @path
+ end
+
+ it "raises a LoadError" do
+ File.exist?(@path).should be_true
+ lambda { @object.send(@method, @path) }.should raise_error(LoadError)
end
end
end
@@ -57,19 +55,19 @@ describe :kernel_require_basic, shared: true do
end
it "raises a TypeError if passed nil" do
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if passed a Fixnum" do
- -> { @object.send(@method, 42) }.should raise_error(TypeError)
+ lambda { @object.send(@method, 42) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an Array" do
- -> { @object.send(@method, []) }.should raise_error(TypeError)
+ lambda { @object.send(@method, []) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not provide #to_str" do
- -> { @object.send(@method, mock("not a filename")) }.should raise_error(TypeError)
+ lambda { @object.send(@method, mock("not a filename")) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that has #to_s but not #to_str" do
@@ -77,14 +75,14 @@ describe :kernel_require_basic, shared: true do
name.stub!(:to_s).and_return("load_fixture.rb")
$LOAD_PATH << "."
Dir.chdir CODE_LOADING_DIR do
- -> { @object.send(@method, name) }.should raise_error(TypeError)
+ lambda { @object.send(@method, name) }.should raise_error(TypeError)
end
end
it "raises a TypeError if #to_str does not return a String" do
name = mock("#to_str returns nil")
name.should_receive(:to_str).at_least(1).times.and_return(nil)
- -> { @object.send(@method, name) }.should raise_error(TypeError)
+ lambda { @object.send(@method, name) }.should raise_error(TypeError)
end
it "calls #to_path on non-String objects" do
@@ -163,14 +161,14 @@ describe :kernel_require_basic, shared: true do
it "does not require file twice after $LOAD_PATH change" do
$LOAD_PATH << CODE_LOADING_DIR
@object.require("load_fixture.rb").should be_true
- $LOAD_PATH.push CODE_LOADING_DIR + "/gem"
+ $LOAD_PATH.unshift CODE_LOADING_DIR + "/gem"
@object.require("load_fixture.rb").should be_false
ScratchPad.recorded.should == [:loaded]
end
it "does not resolve a ./ relative path against $LOAD_PATH entries" do
$LOAD_PATH << CODE_LOADING_DIR
- -> do
+ lambda do
@object.send(@method, "./load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@@ -178,7 +176,7 @@ describe :kernel_require_basic, shared: true do
it "does not resolve a ../ relative path against $LOAD_PATH entries" do
$LOAD_PATH << CODE_LOADING_DIR
- -> do
+ lambda do
@object.send(@method, "../code/load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@@ -208,14 +206,14 @@ describe :kernel_require, shared: true do
# intentional for security reasons.
it "does not load a bare filename unless the current working directory is in $LOAD_PATH" do
Dir.chdir CODE_LOADING_DIR do
- -> { @object.require("load_fixture.rb") }.should raise_error(LoadError)
+ lambda { @object.require("load_fixture.rb") }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
end
it "does not load a relative path unless the current working directory is in $LOAD_PATH" do
Dir.chdir File.dirname(CODE_LOADING_DIR) do
- -> do
+ lambda do
@object.require("code/load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@@ -225,8 +223,9 @@ describe :kernel_require, shared: true do
it "loads a file that recursively requires itself" do
path = File.expand_path "recursive_require_fixture.rb", CODE_LOADING_DIR
-> {
+ $VERBOSE = true
@object.require(path).should be_true
- }.should complain(/circular require considered harmful/, verbose: true)
+ }.should complain(/circular require considered harmful/)
ScratchPad.recorded.should == [:loaded]
end
end
@@ -247,7 +246,7 @@ describe :kernel_require, shared: true do
describe "(file extensions)" do
it "loads a .rb extensioned file when passed a non-extensioned path" do
path = File.expand_path "load_fixture", CODE_LOADING_DIR
- File.should.exist?(path)
+ File.exist?(path).should be_true
@object.require(path).should be_true
ScratchPad.recorded.should == [:loaded]
end
@@ -271,7 +270,7 @@ describe :kernel_require, shared: true do
it "loads a .rb extensioned file when passed a non-.rb extensioned path" do
path = File.expand_path "load_fixture.ext", CODE_LOADING_DIR
- File.should.exist?(path)
+ File.exist?(path).should be_true
@object.require(path).should be_true
ScratchPad.recorded.should == [:loaded]
end
@@ -304,84 +303,10 @@ describe :kernel_require, shared: true do
$LOADED_FEATURES.should include(@path)
end
- platform_is_not :windows do
- describe "with symlinks" do
- before :each do
- @symlink_to_code_dir = tmp("codesymlink")
- File.symlink(CODE_LOADING_DIR, @symlink_to_code_dir)
-
- $LOAD_PATH.delete(CODE_LOADING_DIR)
- $LOAD_PATH.unshift(@symlink_to_code_dir)
- end
-
- after :each do
- rm_r @symlink_to_code_dir
- end
-
- it "does not canonicalize the path and stores a path with symlinks" do
- symlink_path = "#{@symlink_to_code_dir}/load_fixture.rb"
- canonical_path = "#{CODE_LOADING_DIR}/load_fixture.rb"
- @object.require(symlink_path).should be_true
- ScratchPad.recorded.should == [:loaded]
-
- features = $LOADED_FEATURES.select { |path| path.end_with?('load_fixture.rb') }
- features.should include(symlink_path)
- features.should_not include(canonical_path)
- end
-
- it "stores the same path that __FILE__ returns in the required file" do
- symlink_path = "#{@symlink_to_code_dir}/load_fixture_and__FILE__.rb"
- @object.require(symlink_path).should be_true
- loaded_feature = $LOADED_FEATURES.last
- ScratchPad.recorded.should == [loaded_feature]
- end
- end
-
- describe "with symlinks in the required feature and $LOAD_PATH" do
- before :each do
- @dir = tmp("realdir")
- mkdir_p @dir
- @file = "#{@dir}/realfile.rb"
- touch(@file) { |f| f.puts 'ScratchPad << __FILE__' }
-
- @symlink_to_dir = tmp("symdir").freeze
- File.symlink(@dir, @symlink_to_dir)
- @symlink_to_file = "#{@dir}/symfile.rb"
- File.symlink("realfile.rb", @symlink_to_file)
- end
-
- after :each do
- rm_r @dir, @symlink_to_dir
- end
-
- ruby_version_is ""..."2.4.4" do
- it "canonicalizes neither the entry in $LOAD_PATH nor the filename passed to #require" do
- $LOAD_PATH.unshift(@symlink_to_dir)
- @object.require("symfile").should be_true
- loaded_feature = "#{@symlink_to_dir}/symfile.rb"
- ScratchPad.recorded.should == [loaded_feature]
- $".last.should == loaded_feature
- $LOAD_PATH[0].should == @symlink_to_dir
- end
- end
-
- ruby_version_is "2.4.4" do
- it "canonicalizes the entry in $LOAD_PATH but not the filename passed to #require" do
- $LOAD_PATH.unshift(@symlink_to_dir)
- @object.require("symfile").should be_true
- loaded_feature = "#{@dir}/symfile.rb"
- ScratchPad.recorded.should == [loaded_feature]
- $".last.should == loaded_feature
- $LOAD_PATH[0].should == @symlink_to_dir
- end
- end
- end
- end
-
it "does not store the path if the load fails" do
$LOAD_PATH << CODE_LOADING_DIR
saved_loaded_features = $LOADED_FEATURES.dup
- -> { @object.require("raise_fixture.rb") }.should raise_error(RuntimeError)
+ lambda { @object.require("raise_fixture.rb") }.should raise_error(RuntimeError)
$LOADED_FEATURES.should == saved_loaded_features
end
@@ -490,7 +415,7 @@ describe :kernel_require, shared: true do
$LOADED_FEATURES.should include(@path)
end
- it "expands absolute paths containing .." do
+ it "canonicalizes non-unique absolute paths" do
path = File.join CODE_LOADING_DIR, "..", "code", "load_fixture.rb"
@object.require(path).should be_true
$LOADED_FEATURES.should include(@path)
@@ -527,7 +452,21 @@ describe :kernel_require, shared: true do
ScratchPad.recorded.should == []
end
- ruby_version_is ""..."2.5" do
+ ruby_version_is "2.2"..."2.3" do
+ it "complex, enumerator, rational and unicode_normalize are already required" do
+ provided = %w[complex enumerator rational unicode_normalize]
+ features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
+ provided.each { |feature|
+ features.should =~ /\b#{feature}\.(rb|so)$/
+ }
+
+ code = provided.map { |f| "puts require #{f.inspect}\n" }.join
+ required = ruby_exe(code, options: '--disable-gems')
+ required.should == "false\n" * provided.size
+ end
+ end
+
+ ruby_version_is "2.3"..."2.5" do
it "complex, enumerator, rational, thread and unicode_normalize are already required" do
provided = %w[complex enumerator rational thread unicode_normalize]
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
@@ -553,15 +492,6 @@ describe :kernel_require, shared: true do
required = ruby_exe(code, options: '--disable-gems')
required.should == "false\n" * provided.size
end
-
- it "unicode_normalize is part of core and not $LOADED_FEATURES" do
- features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
- features.lines.each { |feature|
- feature.should_not include("unicode_normalize")
- }
-
- -> { @object.require("unicode_normalize") }.should raise_error(LoadError)
- end
end
end
@@ -683,7 +613,7 @@ describe :kernel_require, shared: true do
Thread.current[:wait_for] = t2
Thread.current[:con_raise] = true
- -> {
+ lambda {
@object.require(@path)
}.should raise_error(RuntimeError)
@@ -724,7 +654,7 @@ describe :kernel_require, shared: true do
t1 = Thread.new do
Thread.current[:con_raise] = true
- -> {
+ lambda {
@object.require(@path)
}.should raise_error(RuntimeError)
@@ -764,7 +694,7 @@ describe :kernel_require, shared: true do
it "stores the missing path in a LoadError object" do
path = "abcd1234"
- -> {
+ lambda {
@object.send(@method, path)
}.should raise_error(LoadError) { |e|
e.path.should == path
diff --git a/spec/ruby/core/kernel/shared/sprintf.rb b/spec/ruby/core/kernel/shared/sprintf.rb
index 9899684284..e595a06640 100644
--- a/spec/ruby/core/kernel/shared/sprintf.rb
+++ b/spec/ruby/core/kernel/shared/sprintf.rb
@@ -1,5 +1,3 @@
-require_relative '../../../shared/hash/key_error'
-
describe :kernel_sprintf, shared: true do
def format(*args)
@method.call(*args)
@@ -31,7 +29,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises TypeError exception if cannot convert to Integer" do
- -> {
+ -> () {
format("%b", Object.new)
}.should raise_error(TypeError)
end
@@ -120,7 +118,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises TypeError exception if cannot convert to Float" do
- -> {
+ -> () {
format("%f", Object.new)
}.should raise_error(TypeError)
end
@@ -296,13 +294,13 @@ describe :kernel_sprintf, shared: true do
end
it "raises ArgumentError if argument is a string of several characters" do
- -> {
+ -> () {
format("%c", "abc")
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if argument is an empty string" do
- -> {
+ -> () {
format("%c", "")
}.should raise_error(ArgumentError)
end
@@ -338,7 +336,7 @@ describe :kernel_sprintf, shared: true do
"abc"
end
- -> {
+ -> () {
format("%s", obj)
}.should raise_error(NoMethodError)
end
@@ -461,7 +459,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises exception if argument number is bigger than actual arguments list" do
- -> {
+ -> () {
format("%4$d", 1, 2, 3)
}.should raise_error(ArgumentError)
end
@@ -472,7 +470,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises ArgumentError exception when absolute and relative argument numbers are mixed" do
- -> {
+ -> () {
format("%1$d %d", 1, 2)
}.should raise_error(ArgumentError)
end
@@ -722,7 +720,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises ArgumentError when is mixed with width" do
- -> {
+ -> () {
format("%*10d", 10, 112)
}.should raise_error(ArgumentError)
end
@@ -821,10 +819,16 @@ describe :kernel_sprintf, shared: true do
end
it "cannot be mixed with unnamed style" do
- -> {
+ -> () {
format("%d %<foo>d", 1, foo: "123")
}.should raise_error(ArgumentError)
end
+
+ it "raises KeyError when there is no matching key" do
+ -> () {
+ format("%<foo>s", {})
+ }.should raise_error(KeyError)
+ end
end
describe "%{name} style" do
@@ -841,13 +845,13 @@ describe :kernel_sprintf, shared: true do
end
it "cannot be mixed with unnamed style" do
- -> {
+ -> () {
format("%d %{foo}", 1, foo: "123")
}.should raise_error(ArgumentError)
end
it "raises KeyError when there is no matching key" do
- -> {
+ -> () {
format("%{foo}", {})
}.should raise_error(KeyError)
end
@@ -864,14 +868,4 @@ describe :kernel_sprintf, shared: true do
end
end
end
-
- describe "faulty key" do
- before :all do
- @base_method = @method
- end
-
- it_behaves_like :key_error, -> obj, key {
- @base_method.call("%<#{key}>s", obj)
- }, { foooo: 1 }
- end
end
diff --git a/spec/ruby/core/kernel/shared/sprintf_encoding.rb b/spec/ruby/core/kernel/shared/sprintf_encoding.rb
index c3d62bf3bb..a92f3c10cd 100644
--- a/spec/ruby/core/kernel/shared/sprintf_encoding.rb
+++ b/spec/ruby/core/kernel/shared/sprintf_encoding.rb
@@ -21,7 +21,7 @@ describe :kernel_sprintf_encoding, shared: true do
string = "Ä %s".encode('windows-1252')
argument = "Ђ".encode('windows-1251')
- -> {
+ -> () {
format(string, argument)
}.should raise_error(Encoding::CompatibilityError)
end
diff --git a/spec/ruby/core/kernel/shared/then.rb b/spec/ruby/core/kernel/shared/then.rb
deleted file mode 100644
index b52075371f..0000000000
--- a/spec/ruby/core/kernel/shared/then.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-describe :kernel_then, shared: true do
- it "yields self" do
- object = Object.new
- object.send(@method) { |o| o.should equal object }
- end
-
- it "returns the block return value" do
- object = Object.new
- object.send(@method) { 42 }.should equal 42
- end
-
- it "returns a sized Enumerator when no block given" do
- object = Object.new
- enum = object.send(@method)
- enum.should be_an_instance_of Enumerator
- enum.size.should equal 1
- enum.peek.should equal object
- enum.first.should equal object
- end
-end
diff --git a/spec/ruby/core/kernel/singleton_class_spec.rb b/spec/ruby/core/kernel/singleton_class_spec.rb
index 5dbb4f8c05..b5e0703905 100644
--- a/spec/ruby/core/kernel/singleton_class_spec.rb
+++ b/spec/ruby/core/kernel/singleton_class_spec.rb
@@ -18,10 +18,10 @@ describe "Kernel#singleton_class" do
end
it "raises TypeError for Fixnum" do
- -> { 123.singleton_class }.should raise_error(TypeError)
+ lambda { 123.singleton_class }.should raise_error(TypeError)
end
it "raises TypeError for Symbol" do
- -> { :foo.singleton_class }.should raise_error(TypeError)
+ lambda { :foo.singleton_class }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/singleton_method_spec.rb b/spec/ruby/core/kernel/singleton_method_spec.rb
index 0bdf125ad8..77022b40c2 100644
--- a/spec/ruby/core/kernel/singleton_method_spec.rb
+++ b/spec/ruby/core/kernel/singleton_method_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Kernel#singleton_method" do
it "find a method defined on the singleton class" do
diff --git a/spec/ruby/core/kernel/singleton_methods_spec.rb b/spec/ruby/core/kernel/singleton_methods_spec.rb
index a127a439de..596e5ddad2 100644
--- a/spec/ruby/core/kernel/singleton_methods_spec.rb
+++ b/spec/ruby/core/kernel/singleton_methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/reflection'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_singleton_methods, shared: true do
it "returns an empty Array for an object with no singleton methods" do
@@ -36,23 +36,10 @@ describe :kernel_singleton_methods_modules, shared: true do
it "does not return any included methods for a class including a module" do
ReflectSpecs::D.singleton_methods(*@object).should include(:ds_pro, :ds_pub)
end
-
- it "for a module does not return methods in a module prepended to Module itself" do
- require_relative 'fixtures/singleton_methods'
- mod = SingletonMethodsSpecs::SelfExtending
- mod.method(:mspec_test_kernel_singleton_methods).owner.should == SingletonMethodsSpecs::Prepended
-
- ancestors = mod.singleton_class.ancestors
- ancestors[0...2].should == [ mod.singleton_class, mod ]
- ancestors.should include(SingletonMethodsSpecs::Prepended)
-
- # Do not search prepended modules of `Module`, as that's a non-singleton class
- mod.singleton_methods.should == []
- end
end
describe :kernel_singleton_methods_supers, shared: true do
- it "returns the names of singleton methods for an object extended with a module" do
+ it "returns the names of singleton methods for an object extented with a module" do
ReflectSpecs.oe.singleton_methods(*@object).should include(:m_pro, :m_pub)
end
@@ -62,11 +49,11 @@ describe :kernel_singleton_methods_supers, shared: true do
r.should == [:pro, :pub]
end
- it "returns the names of singleton methods for an object extended with two modules" do
+ it "returns the names of singleton methods for an object extented with two modules" do
ReflectSpecs.oee.singleton_methods(*@object).should include(:m_pro, :m_pub, :n_pro, :n_pub)
end
- it "returns the names of singleton methods for an object extended with a module including a module" do
+ it "returns the names of singleton methods for an object extented with a module including a module" do
ReflectSpecs.oei.singleton_methods(*@object).should include(:n_pro, :n_pub, :m_pro, :m_pub)
end
@@ -112,7 +99,7 @@ describe :kernel_singleton_methods_private_supers, shared: true do
ReflectSpecs.oee.singleton_methods(*@object).should_not include(:m_pri)
end
- it "does not return private singleton methods for an object extended with a module including a module" do
+ it "does not return private singleton methods for an object extented with a module including a module" do
ReflectSpecs.oei.singleton_methods(*@object).should_not include(:n_pri, :m_pri)
end
@@ -158,6 +145,7 @@ describe "Kernel#singleton_methods" do
it_behaves_like :kernel_singleton_methods_supers, nil, true
it_behaves_like :kernel_singleton_methods_modules, nil, true
it_behaves_like :kernel_singleton_methods_private_supers, nil, true
+
end
describe "when passed false" do
@@ -165,11 +153,11 @@ describe "Kernel#singleton_methods" do
it_behaves_like :kernel_singleton_methods_modules, nil, false
it_behaves_like :kernel_singleton_methods_private_supers, nil, false
- it "returns an empty Array for an object extended with a module" do
+ it "returns an empty Array for an object extented with a module" do
ReflectSpecs.oe.singleton_methods(false).should == []
end
- it "returns an empty Array for an object extended with two modules" do
+ it "returns an empty Array for an object extented with two modules" do
ReflectSpecs.oee.singleton_methods(false).should == []
end
diff --git a/spec/ruby/core/kernel/sleep_spec.rb b/spec/ruby/core/kernel/sleep_spec.rb
index 387dc4787b..bcb0060aa3 100644
--- a/spec/ruby/core/kernel/sleep_spec.rb
+++ b/spec/ruby/core/kernel/sleep_spec.rb
@@ -1,38 +1,34 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#sleep" do
it "is a private method" do
Kernel.should have_private_instance_method(:sleep)
end
- it "returns an Integer" do
- sleep(0.001).should be_kind_of(Integer)
- end
-
it "accepts a Float" do
- sleep(0.001).should >= 0
+ sleep(0.1).should be_close(0, 2)
end
it "accepts a Fixnum" do
- sleep(0).should >= 0
+ sleep(0).should be_close(0, 2)
end
it "accepts a Rational" do
- sleep(Rational(1, 999)).should >= 0
+ sleep(Rational(1, 9)).should be_close(0, 2)
end
it "raises an ArgumentError when passed a negative duration" do
- -> { sleep(-0.1) }.should raise_error(ArgumentError)
- -> { sleep(-1) }.should raise_error(ArgumentError)
+ lambda { sleep(-0.1) }.should raise_error(ArgumentError)
+ lambda { sleep(-1) }.should raise_error(ArgumentError)
end
it "raises a TypeError when passed nil" do
- -> { sleep(nil) }.should raise_error(TypeError)
+ lambda { sleep(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- -> { sleep('2') }.should raise_error(TypeError)
+ lambda { sleep('2') }.should raise_error(TypeError)
end
it "pauses execution indefinitely if not given a duration" do
diff --git a/spec/ruby/core/kernel/spawn_spec.rb b/spec/ruby/core/kernel/spawn_spec.rb
index ba05b629d5..ad937b17dd 100644
--- a/spec/ruby/core/kernel/spawn_spec.rb
+++ b/spec/ruby/core/kernel/spawn_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# These specs only run a basic usage of #spawn.
# Process.spawn has more complete specs and they are not
@@ -10,7 +10,7 @@ describe "Kernel#spawn" do
end
it "executes the given command" do
- -> {
+ lambda {
Process.wait spawn("echo spawn")
}.should output_to_fd("spawn\n")
end
@@ -18,7 +18,7 @@ end
describe "Kernel.spawn" do
it "executes the given command" do
- -> {
+ lambda {
Process.wait Kernel.spawn("echo spawn")
}.should output_to_fd("spawn\n")
end
diff --git a/spec/ruby/core/kernel/sprintf_spec.rb b/spec/ruby/core/kernel/sprintf_spec.rb
index 7adf71be76..a89b253803 100644
--- a/spec/ruby/core/kernel/sprintf_spec.rb
+++ b/spec/ruby/core/kernel/sprintf_spec.rb
@@ -1,24 +1,24 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/sprintf'
-require_relative 'shared/sprintf_encoding'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/sprintf', __FILE__)
+require File.expand_path('../shared/sprintf_encoding', __FILE__)
describe "Kernel#sprintf" do
- it_behaves_like :kernel_sprintf, -> format, *args {
+ it_behaves_like :kernel_sprintf, -> (format, *args) {
sprintf(format, *args)
}
- it_behaves_like :kernel_sprintf_encoding, -> format, *args {
+ it_behaves_like :kernel_sprintf_encoding, -> (format, *args) {
sprintf(format, *args)
}
end
describe "Kernel.sprintf" do
- it_behaves_like :kernel_sprintf, -> format, *args {
+ it_behaves_like :kernel_sprintf, -> (format, *args) {
Kernel.sprintf(format, *args)
}
- it_behaves_like :kernel_sprintf_encoding, -> format, *args {
+ it_behaves_like :kernel_sprintf_encoding, -> (format, *args) {
Kernel.sprintf(format, *args)
}
end
diff --git a/spec/ruby/core/kernel/srand_spec.rb b/spec/ruby/core/kernel/srand_spec.rb
index 5454aae8cf..33f99f5ac4 100644
--- a/spec/ruby/core/kernel/srand_spec.rb
+++ b/spec/ruby/core/kernel/srand_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.srand" do
it "is a private method" do
@@ -19,7 +19,7 @@ describe "Kernel.srand" do
end
it "defaults number to a random value" do
- -> { srand }.should_not raise_error
+ lambda { srand }.should_not raise_error
srand.should_not == 0
end
@@ -48,11 +48,11 @@ describe "Kernel.srand" do
end
it "raises a TypeError when passed nil" do
- -> { srand(nil) }.should raise_error(TypeError)
+ lambda { srand(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- -> { srand("7") }.should raise_error(TypeError)
+ lambda { srand("7") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/sub_spec.rb b/spec/ruby/core/kernel/sub_spec.rb
index 9130bd159c..78e5eec4a8 100644
--- a/spec/ruby/core/kernel/sub_spec.rb
+++ b/spec/ruby/core/kernel/sub_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# FIXME: These methods exist only when the -n or -p option is passed to
# ruby, but we currently don't have a way of specifying that.
diff --git a/spec/ruby/core/kernel/syscall_spec.rb b/spec/ruby/core/kernel/syscall_spec.rb
index 32d07b3ae2..bcea833f1f 100644
--- a/spec/ruby/core/kernel/syscall_spec.rb
+++ b/spec/ruby/core/kernel/syscall_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#syscall" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/system_spec.rb b/spec/ruby/core/kernel/system_spec.rb
index 96c0496dd6..aee75441a2 100644
--- a/spec/ruby/core/kernel/system_spec.rb
+++ b/spec/ruby/core/kernel/system_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :kernel_system, shared: true do
it "executes the specified command in a subprocess" do
- -> { @object.system("echo a") }.should output_to_fd("a\n")
+ lambda { @object.system("echo a") }.should output_to_fd("a\n")
$?.should be_an_instance_of Process::Status
$?.success?.should == true
@@ -25,16 +25,6 @@ describe :kernel_system, shared: true do
$?.exitstatus.should == 1
end
- ruby_version_is "2.6" do
- it "raises RuntimeError when `exception: true` is given and the command exits with a non-zero exit status" do
- -> { @object.system(ruby_cmd('exit 1'), exception: true) }.should raise_error(RuntimeError)
- end
-
- it "raises Errno::ENOENT when `exception: true` is given and the specified command does not exist" do
- -> { @object.system('feature_14386', exception: true) }.should raise_error(Errno::ENOENT)
- end
- end
-
it "returns nil when command execution fails" do
@object.system("sad").should be_nil
@@ -44,7 +34,7 @@ describe :kernel_system, shared: true do
end
it "does not write to stderr when command execution fails" do
- -> { @object.system("sad") }.should output_to_fd("", STDERR)
+ lambda { @object.system("sad") }.should output_to_fd("", STDERR)
end
platform_is_not :windows do
@@ -57,12 +47,12 @@ describe :kernel_system, shared: true do
end
it "executes with `sh` if the command contains shell characters" do
- -> { @object.system("echo $0") }.should output_to_fd("sh\n")
+ lambda { @object.system("echo $0") }.should output_to_fd("sh\n")
end
it "ignores SHELL env var and always uses `sh`" do
ENV['SHELL'] = "/bin/fakeshell"
- -> { @object.system("echo $0") }.should output_to_fd("sh\n")
+ lambda { @object.system("echo $0") }.should output_to_fd("sh\n")
end
end
@@ -79,19 +69,19 @@ describe :kernel_system, shared: true do
end
it "expands shell variables when given a single string argument" do
- -> { @object.system("echo #{@shell_var}") }.should output_to_fd("foo\n")
+ lambda { @object.system("echo #{@shell_var}") }.should output_to_fd("foo\n")
end
platform_is_not :windows do
it "does not expand shell variables when given multiples arguments" do
- -> { @object.system("echo", @shell_var) }.should output_to_fd("#{@shell_var}\n")
+ lambda { @object.system("echo", @shell_var) }.should output_to_fd("#{@shell_var}\n")
end
end
platform_is :windows do
it "does expand shell variables when given multiples arguments" do
# See https://bugs.ruby-lang.org/issues/12231
- -> { @object.system("echo", @shell_var) }.should output_to_fd("foo\n")
+ lambda { @object.system("echo", @shell_var) }.should output_to_fd("foo\n")
end
end
diff --git a/spec/ruby/core/kernel/taint_spec.rb b/spec/ruby/core/kernel/taint_spec.rb
index 6de009a46c..0c2fb3286b 100644
--- a/spec/ruby/core/kernel/taint_spec.rb
+++ b/spec/ruby/core/kernel/taint_spec.rb
@@ -1,47 +1,45 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#taint" do
- ruby_version_is ''...'2.7' do
- it "returns self" do
- o = Object.new
- o.taint.should equal(o)
- end
-
- it "sets the tainted bit" do
- o = Object.new
- o.taint
- o.tainted?.should == true
- end
+ it "returns self" do
+ o = Object.new
+ o.taint.should equal(o)
+ end
- it "raises #{frozen_error_class} on an untainted, frozen object" do
- o = Object.new.freeze
- -> { o.taint }.should raise_error(frozen_error_class)
- end
+ it "sets the tainted bit" do
+ o = Object.new
+ o.taint
+ o.tainted?.should == true
+ end
- it "does not raise an error on a tainted, frozen object" do
- o = Object.new.taint.freeze
- o.taint.should equal(o)
- end
+ it "raises RuntimeError on an untainted, frozen object" do
+ o = Object.new.freeze
+ lambda { o.taint }.should raise_error(RuntimeError)
+ end
- it "has no effect on immediate values" do
- [nil, true, false].each do |v|
- v.taint
- v.tainted?.should == false
- end
- end
+ it "does not raise an error on a tainted, frozen object" do
+ o = Object.new.taint.freeze
+ o.taint.should equal(o)
+ end
- it "no raises a RuntimeError on symbols" do
- v = :sym
- -> { v.taint }.should_not raise_error(RuntimeError)
+ it "has no effect on immediate values" do
+ [nil, true, false].each do |v|
+ v.taint
v.tainted?.should == false
end
+ end
- it "no raises error on fixnum values" do
- [1].each do |v|
- -> { v.taint }.should_not raise_error(RuntimeError)
- v.tainted?.should == false
- end
+ it "no raises a RuntimeError on symbols" do
+ v = :sym
+ lambda { v.taint }.should_not raise_error(RuntimeError)
+ v.tainted?.should == false
+ end
+
+ it "no raises error on fixnum values" do
+ [1].each do |v|
+ lambda { v.taint }.should_not raise_error(RuntimeError)
+ v.tainted?.should == false
end
end
end
diff --git a/spec/ruby/core/kernel/tainted_spec.rb b/spec/ruby/core/kernel/tainted_spec.rb
index 72ce346dda..efb31be9d8 100644
--- a/spec/ruby/core/kernel/tainted_spec.rb
+++ b/spec/ruby/core/kernel/tainted_spec.rb
@@ -1,14 +1,12 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#tainted?" do
- ruby_version_is ''...'2.7' do
- it "returns true if Object is tainted" do
- o = mock('o')
- p = mock('p')
- p.taint
- o.tainted?.should == false
- p.tainted?.should == true
- end
+ it "returns true if Object is tainted" do
+ o = mock('o')
+ p = mock('p')
+ p.taint
+ o.tainted?.should == false
+ p.tainted?.should == true
end
end
diff --git a/spec/ruby/core/kernel/tap_spec.rb b/spec/ruby/core/kernel/tap_spec.rb
index f7720a6dc7..312a34426c 100644
--- a/spec/ruby/core/kernel/tap_spec.rb
+++ b/spec/ruby/core/kernel/tap_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#tap" do
it "always yields self and returns self" do
@@ -8,6 +8,6 @@ describe "Kernel#tap" do
end
it "raises a LocalJumpError when no block given" do
- -> { 3.tap }.should raise_error(LocalJumpError)
+ lambda { 3.tap }.should raise_error(LocalJumpError)
end
end
diff --git a/spec/ruby/core/kernel/test_spec.rb b/spec/ruby/core/kernel/test_spec.rb
index abb365aed2..43e3a963e3 100644
--- a/spec/ruby/core/kernel/test_spec.rb
+++ b/spec/ruby/core/kernel/test_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#test" do
before :all do
diff --git a/spec/ruby/core/kernel/then_spec.rb b/spec/ruby/core/kernel/then_spec.rb
deleted file mode 100644
index fa896b52b1..0000000000
--- a/spec/ruby/core/kernel/then_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/then'
-
-ruby_version_is "2.6" do
- describe "Kernel#then" do
- it_behaves_like :kernel_then, :then
- end
-end
diff --git a/spec/ruby/core/kernel/throw_spec.rb b/spec/ruby/core/kernel/throw_spec.rb
index 64bfccb413..3f8d272d6d 100644
--- a/spec/ruby/core/kernel/throw_spec.rb
+++ b/spec/ruby/core/kernel/throw_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel.throw" do
it "transfers control to the end of the active catch block waiting for symbol" do
@@ -10,7 +10,7 @@ describe "Kernel.throw" do
end.should be_nil
end
- it "transfers control to the innermost catch block waiting for the same symbol" do
+ it "transfers control to the innermost catch block waiting for the same sympol" do
one = two = three = 0
catch :duplicate do
catch :duplicate do
@@ -42,21 +42,21 @@ describe "Kernel.throw" do
end
it "raises an ArgumentError if there is no catch block for the symbol" do
- -> { throw :blah }.should raise_error(ArgumentError)
+ lambda { throw :blah }.should raise_error(ArgumentError)
end
it "raises an UncaughtThrowError if there is no catch block for the symbol" do
- -> { throw :blah }.should raise_error(UncaughtThrowError)
+ lambda { throw :blah }.should raise_error(UncaughtThrowError)
end
it "raises ArgumentError if 3 or more arguments provided" do
- -> {
+ lambda {
catch :blah do
throw :blah, :return_value, 2
end
}.should raise_error(ArgumentError)
- -> {
+ lambda {
catch :blah do
throw :blah, :return_value, 2, 3, 4, 5
end
@@ -64,7 +64,7 @@ describe "Kernel.throw" do
end
it "can throw an object" do
- -> {
+ lambda {
obj = Object.new
catch obj do
throw obj
diff --git a/spec/ruby/core/kernel/to_enum_spec.rb b/spec/ruby/core/kernel/to_enum_spec.rb
index 9d9945450f..9fb228f318 100644
--- a/spec/ruby/core/kernel/to_enum_spec.rb
+++ b/spec/ruby/core/kernel/to_enum_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Kernel#to_enum" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/kernel/to_s_spec.rb b/spec/ruby/core/kernel/to_s_spec.rb
index 64b40f46e5..c6fcca54a2 100644
--- a/spec/ruby/core/kernel/to_s_spec.rb
+++ b/spec/ruby/core/kernel/to_s_spec.rb
@@ -1,18 +1,16 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#to_s" do
it "returns a String containing the name of self's class" do
Object.new.to_s.should =~ /Object/
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted result if self is tainted" do
- Object.new.taint.to_s.tainted?.should be_true
- end
+ it "returns a tainted result if self is tainted" do
+ Object.new.taint.to_s.tainted?.should be_true
+ end
- it "returns an untrusted result if self is untrusted" do
- Object.new.untrust.to_s.untrusted?.should be_true
- end
+ it "returns an untrusted result if self is untrusted" do
+ Object.new.untrust.to_s.untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/kernel/trace_var_spec.rb b/spec/ruby/core/kernel/trace_var_spec.rb
index 3c84aa5e60..07e02feb72 100644
--- a/spec/ruby/core/kernel/trace_var_spec.rb
+++ b/spec/ruby/core/kernel/trace_var_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#trace_var" do
before :each do
@@ -47,7 +47,7 @@ describe "Kernel#trace_var" do
end
it "raises ArgumentError if no block or proc is provided" do
- -> do
+ lambda do
trace_var :$Kernel_trace_var_global
end.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/kernel/trap_spec.rb b/spec/ruby/core/kernel/trap_spec.rb
index 465aacb0fb..98f386dc85 100644
--- a/spec/ruby/core/kernel/trap_spec.rb
+++ b/spec/ruby/core/kernel/trap_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#trap" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/trust_spec.rb b/spec/ruby/core/kernel/trust_spec.rb
index 13f085f420..a9fda5c5c6 100644
--- a/spec/ruby/core/kernel/trust_spec.rb
+++ b/spec/ruby/core/kernel/trust_spec.rb
@@ -1,27 +1,25 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#trust" do
- ruby_version_is ''...'2.7' do
- it "returns self" do
- o = Object.new
- o.trust.should equal(o)
- end
+ it "returns self" do
+ o = Object.new
+ o.trust.should equal(o)
+ end
- it "clears the untrusted bit" do
- o = Object.new.untrust
- o.trust
- o.untrusted?.should == false
- end
+ it "clears the untrusted bit" do
+ o = Object.new.untrust
+ o.trust
+ o.untrusted?.should == false
+ end
- it "raises #{frozen_error_class} on an untrusted, frozen object" do
- o = Object.new.untrust.freeze
- -> { o.trust }.should raise_error(frozen_error_class)
- end
+ it "raises RuntimeError on an untrusted, frozen object" do
+ o = Object.new.untrust.freeze
+ lambda { o.trust }.should raise_error(RuntimeError)
+ end
- it "does not raise an error on a trusted, frozen object" do
- o = Object.new.freeze
- o.trust.should equal(o)
- end
+ it "does not raise an error on a trusted, frozen object" do
+ o = Object.new.freeze
+ o.trust.should equal(o)
end
end
diff --git a/spec/ruby/core/kernel/untaint_spec.rb b/spec/ruby/core/kernel/untaint_spec.rb
index 58485fcc58..5abe5d63fc 100644
--- a/spec/ruby/core/kernel/untaint_spec.rb
+++ b/spec/ruby/core/kernel/untaint_spec.rb
@@ -1,27 +1,25 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#untaint" do
- ruby_version_is ''...'2.7' do
- it "returns self" do
- o = Object.new
- o.untaint.should equal(o)
- end
+ it "returns self" do
+ o = Object.new
+ o.untaint.should equal(o)
+ end
- it "clears the tainted bit" do
- o = Object.new.taint
- o.untaint
- o.tainted?.should == false
- end
+ it "clears the tainted bit" do
+ o = Object.new.taint
+ o.untaint
+ o.tainted?.should == false
+ end
- it "raises #{frozen_error_class} on a tainted, frozen object" do
- o = Object.new.taint.freeze
- -> { o.untaint }.should raise_error(frozen_error_class)
- end
+ it "raises RuntimeError on a tainted, frozen object" do
+ o = Object.new.taint.freeze
+ lambda { o.untaint }.should raise_error(RuntimeError)
+ end
- it "does not raise an error on an untainted, frozen object" do
- o = Object.new.freeze
- o.untaint.should equal(o)
- end
+ it "does not raise an error on an untainted, frozen object" do
+ o = Object.new.freeze
+ o.untaint.should equal(o)
end
end
diff --git a/spec/ruby/core/kernel/untrace_var_spec.rb b/spec/ruby/core/kernel/untrace_var_spec.rb
index 1925a3a836..3af1348ffd 100644
--- a/spec/ruby/core/kernel/untrace_var_spec.rb
+++ b/spec/ruby/core/kernel/untrace_var_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#untrace_var" do
it "is a private method" do
diff --git a/spec/ruby/core/kernel/untrust_spec.rb b/spec/ruby/core/kernel/untrust_spec.rb
index c6eb79af1c..280a465807 100644
--- a/spec/ruby/core/kernel/untrust_spec.rb
+++ b/spec/ruby/core/kernel/untrust_spec.rb
@@ -1,27 +1,25 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#untrust" do
- ruby_version_is ''...'2.7' do
- it "returns self" do
- o = Object.new
- o.untrust.should equal(o)
- end
+ it "returns self" do
+ o = Object.new
+ o.untrust.should equal(o)
+ end
- it "sets the untrusted bit" do
- o = Object.new
- o.untrust
- o.untrusted?.should == true
- end
+ it "sets the untrusted bit" do
+ o = Object.new
+ o.untrust
+ o.untrusted?.should == true
+ end
- it "raises #{frozen_error_class} on a trusted, frozen object" do
- o = Object.new.freeze
- -> { o.untrust }.should raise_error(frozen_error_class)
- end
+ it "raises RuntimeError on a trusted, frozen object" do
+ o = Object.new.freeze
+ lambda { o.untrust }.should raise_error(RuntimeError)
+ end
- it "does not raise an error on an untrusted, frozen object" do
- o = Object.new.untrust.freeze
- o.untrust.should equal(o)
- end
+ it "does not raise an error on an untrusted, frozen object" do
+ o = Object.new.untrust.freeze
+ o.untrust.should equal(o)
end
end
diff --git a/spec/ruby/core/kernel/untrusted_spec.rb b/spec/ruby/core/kernel/untrusted_spec.rb
index ccebfe38be..43c4c0aa18 100644
--- a/spec/ruby/core/kernel/untrusted_spec.rb
+++ b/spec/ruby/core/kernel/untrusted_spec.rb
@@ -1,30 +1,28 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#untrusted?" do
- ruby_version_is ''...'2.7' do
- it "returns the untrusted status of an object" do
- o = mock('o')
- o.untrusted?.should == false
- o.untrust
- o.untrusted?.should == true
- end
+ it "returns the untrusted status of an object" do
+ o = mock('o')
+ o.untrusted?.should == false
+ o.untrust
+ o.untrusted?.should == true
+ end
- it "has no effect on immediate values" do
- a = nil
- b = true
- c = false
- a.untrust
- b.untrust
- c.untrust
- a.untrusted?.should == false
- b.untrusted?.should == false
- c.untrusted?.should == false
- end
+ it "has no effect on immediate values" do
+ a = nil
+ b = true
+ c = false
+ a.untrust
+ b.untrust
+ c.untrust
+ a.untrusted?.should == false
+ b.untrusted?.should == false
+ c.untrusted?.should == false
+ end
- it "has effect on immediate values" do
- d = 1
- -> { d.untrust }.should_not raise_error(RuntimeError)
- end
+ it "has effect on immediate values" do
+ d = 1
+ lambda { d.untrust }.should_not raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/kernel/warn_spec.rb b/spec/ruby/core/kernel/warn_spec.rb
index 2a404a2a35..c44116dc21 100644
--- a/spec/ruby/core/kernel/warn_spec.rb
+++ b/spec/ruby/core/kernel/warn_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Kernel#warn" do
before :each do
@@ -21,136 +21,59 @@ describe "Kernel#warn" do
end
it "does not append line-end if last character is line-end" do
- -> {
+ lambda {
$VERBOSE = true
warn("this is some simple text with line-end\n")
}.should output(nil, "this is some simple text with line-end\n")
end
it "calls #write on $stderr if $VERBOSE is true" do
- -> {
+ lambda {
$VERBOSE = true
warn("this is some simple text")
}.should output(nil, "this is some simple text\n")
end
it "calls #write on $stderr if $VERBOSE is false" do
- -> {
+ lambda {
$VERBOSE = false
warn("this is some simple text")
}.should output(nil, "this is some simple text\n")
end
it "does not call #write on $stderr if $VERBOSE is nil" do
- -> {
+ lambda {
$VERBOSE = nil
warn("this is some simple text")
}.should output(nil, "")
end
it "writes each argument on a line when passed multiple arguments" do
- -> {
+ lambda {
$VERBOSE = true
warn("line 1", "line 2")
}.should output(nil, "line 1\nline 2\n")
end
it "writes each array element on a line when passes an array" do
- -> {
+ lambda {
$VERBOSE = true
warn(["line 1", "line 2"])
}.should output(nil, "line 1\nline 2\n")
end
it "does not write strings when passed no arguments" do
- -> {
+ lambda {
$VERBOSE = true
warn
}.should output("", "")
end
it "writes the default record separator and NOT $/ to $stderr after the warning message" do
- -> {
+ lambda {
$VERBOSE = true
$/ = 'rs'
warn("")
}.should output(nil, /\n/)
end
-
- it "writes to_s representation if passed a non-string" do
- obj = mock("obj")
- obj.should_receive(:to_s).and_return("to_s called")
- -> {
- $VERBOSE = true
- warn(obj)
- }.should output(nil, "to_s called\n")
- end
-
- ruby_version_is "2.5" do
- describe ":uplevel keyword argument" do
- before :each do
- $VERBOSE = true
- end
-
- it "prepends a message with specified line from the backtrace" do
- w = KernelSpecs::WarnInNestedCall.new
-
- -> { w.f4("foo", 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: foo|)
- -> { w.f4("foo", 1) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f1_call_lineno}: warning: foo|)
- -> { w.f4("foo", 2) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f2_call_lineno}: warning: foo|)
- -> { w.f4("foo", 3) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f3_call_lineno}: warning: foo|)
- end
-
- it "converts first arg using to_s" do
- w = KernelSpecs::WarnInNestedCall.new
-
- -> { w.f4(false, 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: false|)
- -> { w.f4(nil, 1) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f1_call_lineno}: warning: |)
- obj = mock("obj")
- obj.should_receive(:to_s).and_return("to_s called")
- -> { w.f4(obj, 2) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f2_call_lineno}: warning: to_s called|)
- end
-
- it "does not prepend caller information if line number is too big" do
- w = KernelSpecs::WarnInNestedCall.new
- -> { w.f4("foo", 100) }.should output(nil, "warning: foo\n")
- end
-
- it "prepends even if a message is empty or nil" do
- w = KernelSpecs::WarnInNestedCall.new
-
- -> { w.f4("", 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: \n$|)
- -> { w.f4(nil, 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: \n$|)
- end
-
- it "converts value to Integer" do
- w = KernelSpecs::WarnInNestedCall.new
-
- -> { w.f4(0.1) }.should output(nil, %r|classes.rb:#{w.warn_call_lineno}:|)
- -> { w.f4(Rational(1, 2)) }.should output(nil, %r|classes.rb:#{w.warn_call_lineno}:|)
- end
-
- it "raises ArgumentError if passed negative value" do
- -> { warn "", uplevel: -2 }.should raise_error(ArgumentError)
- -> { warn "", uplevel: -100 }.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError if passed -1" do
- -> { warn "", uplevel: -1 }.should raise_error(ArgumentError)
- end
-
- it "raises TypeError if passed not Integer" do
- -> { warn "", uplevel: "" }.should raise_error(TypeError)
- -> { warn "", uplevel: [] }.should raise_error(TypeError)
- -> { warn "", uplevel: {} }.should raise_error(TypeError)
- -> { warn "", uplevel: Object.new }.should raise_error(TypeError)
- end
- end
-
- it "treats empty hash as no keyword argument" do
- h = {}
- -> { warn(**h) }.should_not complain(verbose: true)
- -> { warn('foo', **h) }.should complain("foo\n")
- end
- end
end
diff --git a/spec/ruby/core/kernel/yield_self_spec.rb b/spec/ruby/core/kernel/yield_self_spec.rb
index affedae144..817c01f288 100644
--- a/spec/ruby/core/kernel/yield_self_spec.rb
+++ b/spec/ruby/core/kernel/yield_self_spec.rb
@@ -1,8 +1,26 @@
-require_relative '../../spec_helper'
-require_relative 'shared/then'
+require File.expand_path('../../../spec_helper', __FILE__)
-ruby_version_is "2.5" do
+has_yield_self = VersionGuard.new("2.5").match? || PlatformGuard.implementation?(:truffleruby)
+
+if has_yield_self
describe "Kernel#yield_self" do
- it_behaves_like :kernel_then, :yield_self
+ it "yields self" do
+ object = Object.new
+ object.yield_self { |o| o.should equal object }
+ end
+
+ it "returns the block return value" do
+ object = Object.new
+ object.yield_self { 42 }.should equal 42
+ end
+
+ it "returns a sized Enumerator when no block given" do
+ object = Object.new
+ enum = object.yield_self
+ enum.should be_an_instance_of Enumerator
+ enum.size.should equal 1
+ enum.peek.should equal object
+ enum.first.should equal object
+ end
end
end
diff --git a/spec/ruby/core/main/define_method_spec.rb b/spec/ruby/core/main/define_method_spec.rb
index d85c5e8119..741e0624f8 100644
--- a/spec/ruby/core/main/define_method_spec.rb
+++ b/spec/ruby/core/main/define_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
script_binding = binding
diff --git a/spec/ruby/core/main/include_spec.rb b/spec/ruby/core/main/include_spec.rb
index 9f5a5f54ea..1973bc8229 100644
--- a/spec/ruby/core/main/include_spec.rb
+++ b/spec/ruby/core/main/include_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "main#include" do
it "includes the given Module in Object" do
diff --git a/spec/ruby/core/main/private_spec.rb b/spec/ruby/core/main/private_spec.rb
index e34e0c7b7b..7e0a4ed57d 100644
--- a/spec/ruby/core/main/private_spec.rb
+++ b/spec/ruby/core/main/private_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "main#private" do
after :each do
@@ -16,7 +16,7 @@ describe "main#private" do
end
it "raises a NameError when given an undefined name" do
- -> do
+ lambda do
eval "private :main_undefined_method", TOPLEVEL_BINDING
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/main/public_spec.rb b/spec/ruby/core/main/public_spec.rb
index afe25c705a..6906faee04 100644
--- a/spec/ruby/core/main/public_spec.rb
+++ b/spec/ruby/core/main/public_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "main#public" do
after :each do
@@ -16,7 +16,7 @@ describe "main#public" do
end
it "raises a NameError when given an undefined name" do
- -> do
+ lambda do
eval "public :main_undefined_method", TOPLEVEL_BINDING
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/main/to_s_spec.rb b/spec/ruby/core/main/to_s_spec.rb
index 642cfa4433..dd5a02b0ae 100644
--- a/spec/ruby/core/main/to_s_spec.rb
+++ b/spec/ruby/core/main/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "main#to_s" do
it "returns 'main'" do
diff --git a/spec/ruby/core/main/using_spec.rb b/spec/ruby/core/main/using_spec.rb
index f9f709f7dc..108cc50dad 100644
--- a/spec/ruby/core/main/using_spec.rb
+++ b/spec/ruby/core/main/using_spec.rb
@@ -1,132 +1,135 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "main.using" do
- it "requires one Module argument" do
- -> do
- eval('using', TOPLEVEL_BINDING)
- end.should raise_error(ArgumentError)
-
- -> do
- eval('using "foo"', TOPLEVEL_BINDING)
- end.should raise_error(TypeError)
- end
+require File.expand_path('../../../spec_helper', __FILE__)
- it "uses refinements from the given module only in the target file" do
- require_relative 'fixtures/string_refinement'
- load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
- MainSpecs::DATA[:in_module].should == 'foo'
- MainSpecs::DATA[:toplevel].should == 'foo'
- -> do
- 'hello'.foo
- end.should raise_error(NoMethodError)
- end
+ruby_version_is "2.0.0" do
+ require File.expand_path('../fixtures/classes', __FILE__)
- it "uses refinements from the given module for method calls in the target file" do
- require_relative 'fixtures/string_refinement'
- load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
- -> do
- 'hello'.foo
- end.should raise_error(NoMethodError)
- MainSpecs.call_foo('hello').should == 'foo'
- end
+ describe "main.using" do
+ it "requires one Module argument" do
+ lambda do
+ eval('using', TOPLEVEL_BINDING)
+ end.should raise_error(ArgumentError)
- it "uses refinements from the given module in the eval string" do
- cls = MainSpecs::DATA[:cls] = Class.new {def foo; 'foo'; end}
- MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'bar'; end
- end
+ lambda do
+ eval('using "foo"', TOPLEVEL_BINDING)
+ end.should raise_error(TypeError)
end
- eval(<<-EOS, TOPLEVEL_BINDING).should == 'bar'
- using MainSpecs::DATA[:mod]
- MainSpecs::DATA[:cls].new.foo
- EOS
- end
- it "does not affect methods defined before it is called" do
- cls = Class.new {def foo; 'foo'; end}
- MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'bar'; end
- end
+ it "uses refinements from the given module only in the target file" do
+ require File.expand_path('../fixtures/string_refinement', __FILE__)
+ load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
+ MainSpecs::DATA[:in_module].should == 'foo'
+ MainSpecs::DATA[:toplevel].should == 'foo'
+ lambda do
+ 'hello'.foo
+ end.should raise_error(NoMethodError)
end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- x = MainSpecs::DATA[:x]
- def x.before_using(obj)
- obj.foo
- end
- using MainSpecs::DATA[:mod]
- def x.after_using(obj)
- obj.foo
- end
- EOS
- obj = cls.new
- x.before_using(obj).should == 'foo'
- x.after_using(obj).should == 'bar'
- end
+ it "uses refinements from the given module for method calls in the target file" do
+ require File.expand_path('../fixtures/string_refinement', __FILE__)
+ load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
+ lambda do
+ 'hello'.foo
+ end.should raise_error(NoMethodError)
+ MainSpecs.call_foo('hello').should == 'foo'
+ end
- it "propagates refinements added to existing modules after it is called" do
- cls = Class.new {def foo; 'foo'; end}
- mod = MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'quux'; end
+ it "uses refinements from the given module in the eval string" do
+ cls = MainSpecs::DATA[:cls] = Class.new {def foo; 'foo'; end}
+ MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'bar'; end
+ end
end
+ eval(<<-EOS, TOPLEVEL_BINDING).should == 'bar'
+ using MainSpecs::DATA[:mod]
+ MainSpecs::DATA[:cls].new.foo
+ EOS
end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- using MainSpecs::DATA[:mod]
- x = MainSpecs::DATA[:x]
- def x.call_foo(obj)
- obj.foo
- end
- def x.call_bar(obj)
- obj.bar
+
+ it "does not affect methods defined before it is called" do
+ cls = Class.new {def foo; 'foo'; end}
+ MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'bar'; end
+ end
end
- EOS
+ x = MainSpecs::DATA[:x] = Object.new
+ eval <<-EOS, TOPLEVEL_BINDING
+ x = MainSpecs::DATA[:x]
+ def x.before_using(obj)
+ obj.foo
+ end
+ using MainSpecs::DATA[:mod]
+ def x.after_using(obj)
+ obj.foo
+ end
+ EOS
- obj = cls.new
- x.call_foo(obj).should == 'quux'
+ obj = cls.new
+ x.before_using(obj).should == 'foo'
+ x.after_using(obj).should == 'bar'
+ end
- mod.module_eval do
- refine(cls) do
- def bar; 'quux'; end
+ it "propagates refinements added to existing modules after it is called" do
+ cls = Class.new {def foo; 'foo'; end}
+ mod = MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'quux'; end
+ end
end
- end
+ x = MainSpecs::DATA[:x] = Object.new
+ eval <<-EOS, TOPLEVEL_BINDING
+ using MainSpecs::DATA[:mod]
+ x = MainSpecs::DATA[:x]
+ def x.call_foo(obj)
+ obj.foo
+ end
+ def x.call_bar(obj)
+ obj.bar
+ end
+ EOS
- x.call_bar(obj).should == 'quux'
- end
+ obj = cls.new
+ x.call_foo(obj).should == 'quux'
- it "does not propagate refinements of new modules added after it is called" do
- cls = Class.new {def foo; 'foo'; end}
- cls2 = Class.new {def bar; 'bar'; end}
- mod = MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'quux'; end
+ mod.module_eval do
+ refine(cls) do
+ def bar; 'quux'; end
+ end
end
+
+ x.call_bar(obj).should == 'quux'
end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- using MainSpecs::DATA[:mod]
- x = MainSpecs::DATA[:x]
- def x.call_foo(obj)
- obj.foo
- end
- def x.call_bar(obj)
- obj.bar
+
+ it "does not propagate refinements of new modules added after it is called" do
+ cls = Class.new {def foo; 'foo'; end}
+ cls2 = Class.new {def bar; 'bar'; end}
+ mod = MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'quux'; end
+ end
end
- EOS
+ x = MainSpecs::DATA[:x] = Object.new
+ eval <<-EOS, TOPLEVEL_BINDING
+ using MainSpecs::DATA[:mod]
+ x = MainSpecs::DATA[:x]
+ def x.call_foo(obj)
+ obj.foo
+ end
+ def x.call_bar(obj)
+ obj.bar
+ end
+ EOS
- x.call_foo(cls.new).should == 'quux'
+ x.call_foo(cls.new).should == 'quux'
- mod.module_eval do
- refine(cls2) do
- def bar; 'quux'; end
+ mod.module_eval do
+ refine(cls2) do
+ def bar; 'quux'; end
+ end
end
- end
- x.call_bar(cls2.new).should == 'bar'
+ x.call_bar(cls2.new).should == 'bar'
+ end
end
end
diff --git a/spec/ruby/core/marshal/dump_spec.rb b/spec/ruby/core/marshal/dump_spec.rb
index fc78ca4ff9..393b8a93f4 100644
--- a/spec/ruby/core/marshal/dump_spec.rb
+++ b/spec/ruby/core/marshal/dump_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/marshal_data'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/marshal_data', __FILE__)
describe "Marshal.dump" do
it "dumps nil" do
@@ -63,10 +63,6 @@ describe "Marshal.dump" do
"\x04\bI:\b\xE2\x86\x92\x06:\x06ET"],
[Marshal, s.encode("utf-16").to_sym,
"\x04\bI:\t\xFE\xFF!\x92\x06:\rencoding\"\vUTF-16"],
- [Marshal, s.encode("utf-16le").to_sym,
- "\x04\bI:\a\x92!\x06:\rencoding\"\rUTF-16LE"],
- [Marshal, s.encode("utf-16be").to_sym,
- "\x04\bI:\a!\x92\x06:\rencoding\"\rUTF-16BE"],
[Marshal, s.encode("euc-jp").to_sym,
"\x04\bI:\a\xA2\xAA\x06:\rencoding\"\vEUC-JP"],
[Marshal, s.encode("sjis").to_sym,
@@ -78,6 +74,20 @@ describe "Marshal.dump" do
s = "\u2192".force_encoding("binary").to_sym
Marshal.dump(s).should == "\x04\b:\b\xE2\x86\x92"
end
+
+ end
+
+ it "dumps an extended_object" do
+ Marshal.dump(Object.new.extend(Meths)).should == "\x04\be:\nMethso:\vObject\x00"
+ end
+
+ it "dumps an object that has had an ivar added and removed as though the ivar never was set" do
+ obj = Object.new
+ initial = Marshal.dump(obj)
+ obj.instance_variable_set(:@ivar, 1)
+ Marshal.dump(obj).should == "\004\bo:\vObject\006:\n@ivari\006"
+ obj.send :remove_instance_variable, :@ivar
+ Marshal.dump(obj).should == initial
end
describe "with an object responding to #marshal_dump" do
@@ -99,7 +109,7 @@ describe "Marshal.dump" do
it "raises a TypeError if _dump returns a non-string" do
m = mock("marshaled")
m.should_receive(:_dump).and_return(0)
- -> { Marshal.dump(m) }.should raise_error(TypeError)
+ lambda { Marshal.dump(m) }.should raise_error(TypeError)
end
it "favors marshal_dump over _dump" do
@@ -124,11 +134,11 @@ describe "Marshal.dump" do
end
it "raises TypeError with an anonymous Class" do
- -> { Marshal.dump(Class.new) }.should raise_error(TypeError)
+ lambda { Marshal.dump(Class.new) }.should raise_error(TypeError)
end
it "raises TypeError with a singleton Class" do
- -> { Marshal.dump(class << self; self end) }.should raise_error(TypeError)
+ lambda { Marshal.dump(class << self; self end) }.should raise_error(TypeError)
end
end
@@ -138,7 +148,7 @@ describe "Marshal.dump" do
end
it "raises TypeError with an anonymous Module" do
- -> { Marshal.dump(Module.new) }.should raise_error(TypeError)
+ lambda { Marshal.dump(Module.new) }.should raise_error(TypeError)
end
end
@@ -204,24 +214,26 @@ describe "Marshal.dump" do
Marshal.dump(str.force_encoding("binary")).should == "\x04\bI\"\x00\x06:\t@foo\"\bbar"
end
- it "dumps a US-ASCII String" do
- str = "abc".force_encoding("us-ascii")
- Marshal.dump(str).should == "\x04\bI\"\babc\x06:\x06EF"
- end
+ with_feature :encoding do
+ it "dumps a US-ASCII String" do
+ str = "abc".force_encoding("us-ascii")
+ Marshal.dump(str).should == "\x04\bI\"\babc\x06:\x06EF"
+ end
- it "dumps a UTF-8 String" do
- str = "\x6d\xc3\xb6\x68\x72\x65".force_encoding("utf-8")
- Marshal.dump(str).should == "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET"
- end
+ it "dumps a UTF-8 String" do
+ str = "\x6d\xc3\xb6\x68\x72\x65".force_encoding("utf-8")
+ Marshal.dump(str).should == "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET"
+ end
- it "dumps a String in another encoding" do
- str = "\x6d\x00\xf6\x00\x68\x00\x72\x00\x65\x00".force_encoding("utf-16le")
- result = "\x04\bI\"\x0Fm\x00\xF6\x00h\x00r\x00e\x00\x06:\rencoding\"\rUTF-16LE"
- Marshal.dump(str).should == result
- end
+ it "dumps a String in another encoding" do
+ str = "\x6d\x00\xf6\x00\x68\x00\x72\x00\x65\x00".force_encoding("utf-16le")
+ result = "\x04\bI\"\x0Fm\x00\xF6\x00h\x00r\x00e\x00\x06:\rencoding\"\rUTF-16LE"
+ Marshal.dump(str).should == result
+ end
- it "dumps multiple strings using symlinks for the :E (encoding) symbol" do
- Marshal.dump(["".encode("us-ascii"), "".encode("utf-8")]).should == "\x04\b[\aI\"\x00\x06:\x06EFI\"\x00\x06;\x00T"
+ it "dumps multiple strings using symlinks for the :E (encoding) symbol" do
+ Marshal.dump(["".encode("us-ascii"), "".encode("utf-8")]).should == "\x04\b[\aI\"\x00\x06:\x06EFI\"\x00\x06;\x00T"
+ end
end
end
@@ -308,7 +320,7 @@ describe "Marshal.dump" do
end
it "raises a TypeError with hash having default proc" do
- -> { Marshal.dump(Hash.new {}) }.should raise_error(TypeError)
+ lambda { Marshal.dump(Hash.new {}) }.should raise_error(TypeError)
end
it "dumps a Hash with instance variables" do
@@ -364,13 +376,6 @@ describe "Marshal.dump" do
Marshal.dump(obj).should == "\004\bo:\vObject\006:\n@ivari\006"
end
- it "dumps an Object with a non-US-ASCII instance variable" do
- obj = Object.new
- ivar = "@é".force_encoding(Encoding::UTF_8).to_sym
- obj.instance_variable_set(ivar, 1)
- Marshal.dump(obj).should == "\x04\bo:\vObject\x06I:\b@\xC3\xA9\x06:\x06ETi\x06"
- end
-
it "dumps an Object that has had an instance variable added and removed as though it was never set" do
obj = Object.new
obj.instance_variable_set(:@ivar, 1)
@@ -387,7 +392,7 @@ describe "Marshal.dump" do
it "raises if an Object has a singleton class and singleton methods" do
obj = Object.new
def obj.foo; end
- -> {
+ lambda {
Marshal.dump(obj)
}.should raise_error(TypeError, "singleton can't be dumped")
end
@@ -449,13 +454,14 @@ describe "Marshal.dump" do
zone = ":\tzoneI\"\bAST\x06:\x06EF" # Last is 'F' (US-ASCII)
[ "#{base}#{offset}#{zone}", "#{base}#{zone}#{offset}" ].should include(dump)
end
- end
- it "dumps the zone, but not the offset if zone is UTC" do
- dump = Marshal.dump(@utc)
- zone = ":\tzoneI\"\bUTC\x06:\x06EF" # Last is 'F' (US-ASCII)
- dump.should == "\x04\bIu:\tTime\r#{@utc_dump}\x06#{zone}"
+ it "dumps the zone, but not the offset if zone is UTC" do
+ dump = Marshal.dump(@utc)
+ zone = ":\tzoneI\"\bUTC\x06:\x06EF" # Last is 'F' (US-ASCII)
+ dump.should == "\x04\bIu:\tTime\r#{@utc_dump}\x06#{zone}"
+ end
end
+
end
describe "with an Exception" do
@@ -472,30 +478,6 @@ describe "Marshal.dump" do
obj.set_backtrace(["foo/bar.rb:10"])
Marshal.dump(obj).should == "\x04\bo:\x0EException\a:\tmesg\"\bfoo:\abt[\x06\"\x12foo/bar.rb:10"
end
-
- it "dumps instance variables if they exist" do
- obj = Exception.new("foo")
- obj.instance_variable_set(:@ivar, 1)
- Marshal.dump(obj).should == "\x04\bo:\x0EException\b:\tmesg\"\bfoo:\abt0:\n@ivari\x06"
- end
-
- it "dumps the cause for the exception" do
- exc = nil
- begin
- raise StandardError, "the cause"
- rescue StandardError => cause
- begin
- raise RuntimeError, "the consequence"
- rescue RuntimeError => e
- e.cause.should equal(cause)
- exc = e
- end
- end
-
- reloaded = Marshal.load(Marshal.dump(exc))
- reloaded.cause.should be_an_instance_of(StandardError)
- reloaded.cause.message.should == "the cause"
- end
end
it "dumps subsequent appearances of a symbol as a link" do
@@ -515,10 +497,10 @@ describe "Marshal.dump" do
it "raises an ArgumentError when the recursion limit is exceeded" do
h = {'one' => {'two' => {'three' => 0}}}
- -> { Marshal.dump(h, 3) }.should raise_error(ArgumentError)
- -> { Marshal.dump([h], 4) }.should raise_error(ArgumentError)
- -> { Marshal.dump([], 0) }.should raise_error(ArgumentError)
- -> { Marshal.dump([[[]]], 1) }.should raise_error(ArgumentError)
+ lambda { Marshal.dump(h, 3) }.should raise_error(ArgumentError)
+ lambda { Marshal.dump([h], 4) }.should raise_error(ArgumentError)
+ lambda { Marshal.dump([], 0) }.should raise_error(ArgumentError)
+ lambda { Marshal.dump([[[]]], 1) }.should raise_error(ArgumentError)
end
it "ignores the recursion limit if the limit is negative" do
@@ -541,75 +523,60 @@ describe "Marshal.dump" do
it "raises an Error when the IO-Object does not respond to #write" do
obj = mock('test')
- -> { Marshal.dump("test", obj) }.should raise_error(TypeError)
+ lambda { Marshal.dump("test", obj) }.should raise_error(TypeError)
end
+ with_feature :encoding do
- it "calls binmode when it's defined" do
- obj = mock('test')
- obj.should_receive(:write).at_least(1)
- obj.should_receive(:binmode).at_least(1)
- Marshal.dump("test", obj)
- end
-
-
- end
-
- describe "when passed a StringIO" do
-
- it "should raise an error" do
- require "stringio"
+ it "calls binmode when it's defined" do
+ obj = mock('test')
+ obj.should_receive(:write).at_least(1)
+ obj.should_receive(:binmode).at_least(1)
+ Marshal.dump("test", obj)
+ end
- -> { Marshal.dump(StringIO.new) }.should raise_error(TypeError)
end
end
it "raises a TypeError if marshalling a Method instance" do
- -> { Marshal.dump(Marshal.method(:dump)) }.should raise_error(TypeError)
+ lambda { Marshal.dump(Marshal.method(:dump)) }.should raise_error(TypeError)
end
it "raises a TypeError if marshalling a Proc" do
- -> { Marshal.dump(proc {}) }.should raise_error(TypeError)
+ lambda { Marshal.dump(proc {}) }.should raise_error(TypeError)
end
it "raises a TypeError if dumping a IO/File instance" do
- -> { Marshal.dump(STDIN) }.should raise_error(TypeError)
- -> { File.open(__FILE__) { |f| Marshal.dump(f) } }.should raise_error(TypeError)
+ lambda { Marshal.dump(STDIN) }.should raise_error(TypeError)
+ lambda { File.open(__FILE__) { |f| Marshal.dump(f) } }.should raise_error(TypeError)
end
it "raises a TypeError if dumping a MatchData instance" do
- -> { Marshal.dump(/(.)/.match("foo")) }.should raise_error(TypeError)
+ lambda { Marshal.dump(/(.)/.match("foo")) }.should raise_error(TypeError)
end
- it "raises a TypeError if dumping a Mutex instance" do
- m = Mutex.new
- -> { Marshal.dump(m) }.should raise_error(TypeError)
+ it "returns an untainted string if object is untainted" do
+ Marshal.dump(Object.new).tainted?.should be_false
end
- ruby_version_is ''...'2.7' do
- it "returns an untainted string if object is untainted" do
- Marshal.dump(Object.new).tainted?.should be_false
- end
-
- it "returns a tainted string if object is tainted" do
- Marshal.dump(Object.new.taint).tainted?.should be_true
- end
+ it "returns a tainted string if object is tainted" do
+ Marshal.dump(Object.new.taint).tainted?.should be_true
+ end
- it "returns a tainted string if nested object is tainted" do
- Marshal.dump([[Object.new.taint]]).tainted?.should be_true
- end
+ it "returns a tainted string if nested object is tainted" do
+ Marshal.dump([[Object.new.taint]]).tainted?.should be_true
+ end
- it "returns a trusted string if object is trusted" do
- Marshal.dump(Object.new).untrusted?.should be_false
- end
+ it "returns a trusted string if object is trusted" do
+ Marshal.dump(Object.new).untrusted?.should be_false
+ end
- it "returns an untrusted string if object is untrusted" do
- Marshal.dump(Object.new.untrust).untrusted?.should be_true
- end
+ it "returns an untrusted string if object is untrusted" do
+ Marshal.dump(Object.new.untrust).untrusted?.should be_true
+ end
- it "returns an untrusted string if nested object is untrusted" do
- Marshal.dump([[Object.new.untrust]]).untrusted?.should be_true
- end
+ it "returns an untrusted string if nested object is untrusted" do
+ Marshal.dump([[Object.new.untrust]]).untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/marshal/float_spec.rb b/spec/ruby/core/marshal/float_spec.rb
index 5793bbd564..0bdde3ccc1 100644
--- a/spec/ruby/core/marshal/float_spec.rb
+++ b/spec/ruby/core/marshal/float_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Marshal.dump with Float" do
it "represents NaN" do
diff --git a/spec/ruby/core/marshal/load_spec.rb b/spec/ruby/core/marshal/load_spec.rb
index a5bdfbf520..53d60f0619 100644
--- a/spec/ruby/core/marshal/load_spec.rb
+++ b/spec/ruby/core/marshal/load_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/load'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/load', __FILE__)
describe "Marshal.load" do
it_behaves_like :marshal_load, :load
diff --git a/spec/ruby/core/marshal/major_version_spec.rb b/spec/ruby/core/marshal/major_version_spec.rb
index 931f1f6c27..6984e22b19 100644
--- a/spec/ruby/core/marshal/major_version_spec.rb
+++ b/spec/ruby/core/marshal/major_version_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Marshal::MAJOR_VERSION" do
it "is 4" do
diff --git a/spec/ruby/core/marshal/minor_version_spec.rb b/spec/ruby/core/marshal/minor_version_spec.rb
index f19210c4e1..cfedcb62b2 100644
--- a/spec/ruby/core/marshal/minor_version_spec.rb
+++ b/spec/ruby/core/marshal/minor_version_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Marshal::MINOR_VERSION" do
it "is 8" do
diff --git a/spec/ruby/core/marshal/restore_spec.rb b/spec/ruby/core/marshal/restore_spec.rb
index 7e75d7dea6..3e84a1780c 100644
--- a/spec/ruby/core/marshal/restore_spec.rb
+++ b/spec/ruby/core/marshal/restore_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/load'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/load', __FILE__)
describe "Marshal.restore" do
it_behaves_like :marshal_load, :restore
diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb
index 7901c8773b..e642f1a66e 100644
--- a/spec/ruby/core/marshal/shared/load.rb
+++ b/spec/ruby/core/marshal/shared/load.rb
@@ -1,5 +1,5 @@
# -*- encoding: binary -*-
-require_relative '../fixtures/marshal_data'
+require File.expand_path('../../fixtures/marshal_data', __FILE__)
require 'stringio'
describe :marshal_load, shared: true do
@@ -9,7 +9,7 @@ describe :marshal_load, shared: true do
it "raises an ArgumentError when the dumped data is truncated" do
obj = {first: 1, second: 2, third: 3}
- -> { Marshal.send(@method, Marshal.dump(obj)[0, 5]) }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, Marshal.dump(obj)[0, 5]) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the dumped class is missing" do
@@ -17,28 +17,10 @@ describe :marshal_load, shared: true do
kaboom = Marshal.dump(KaBoom.new)
Object.send(:remove_const, :KaBoom)
- -> { Marshal.send(@method, kaboom) }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, kaboom) }.should raise_error(ArgumentError)
end
describe "when called with a proc" do
- ruby_bug "#18141", ""..."3.1" do
- it "call the proc with fully initialized strings" do
- utf8_string = "foo".encode(Encoding::UTF_8)
- Marshal.send(@method, Marshal.dump(utf8_string), proc { |arg|
- if arg.is_a?(String)
- arg.should == utf8_string
- arg.encoding.should == Encoding::UTF_8
- end
- arg
- })
- end
-
- it "no longer mutate the object after it was passed to the proc" do
- string = Marshal.load(Marshal.dump("foo"), :freeze.to_proc)
- string.should.frozen?
- end
- end
-
it "returns the value of the proc" do
Marshal.send(@method, Marshal.dump([1,2]), proc { [3,4] }).should == [3,4]
end
@@ -54,29 +36,27 @@ describe :marshal_load, shared: true do
ret.size.should == 3
end
- ruby_bug "#18141", ""..."3.1" do
- it "loads an Array with proc" do
- arr = []
- s = 'hi'
- s.instance_variable_set(:@foo, 5)
- st = Struct.new("Brittle", :a).new
- st.instance_variable_set(:@clue, 'none')
- st.a = 0.0
- h = Hash.new('def')
- h['nine'] = 9
- a = [:a, :b, :c]
- a.instance_variable_set(:@two, 2)
- obj = [s, 10, s, s, st, a]
- obj.instance_variable_set(:@zoo, 'ant')
- proc = Proc.new { |o| arr << o; o}
-
- Marshal.send(@method, "\x04\bI[\vI\"\ahi\a:\x06EF:\t@fooi\ni\x0F@\x06@\x06IS:\x14Struct::Brittle\x06:\x06af\x060\x06:\n@clueI\"\tnone\x06;\x00FI[\b;\b:\x06b:\x06c\x06:\t@twoi\a\x06:\t@zooI\"\bant\x06;\x00F", proc)
-
- arr.should == [false, 5, "hi", 10, "hi", "hi", 0.0, st, false, "none",
- :b, :c, a, 2, ["hi", 10, "hi", "hi", st, [:a, :b, :c]], false, "ant"]
-
- Struct.send(:remove_const, :Brittle)
- end
+ it "loads an Array with proc" do
+ arr = []
+ s = 'hi'
+ s.instance_variable_set(:@foo, 5)
+ st = Struct.new("Brittle", :a).new
+ st.instance_variable_set(:@clue, 'none')
+ st.a = 0.0
+ h = Hash.new('def')
+ h['nine'] = 9
+ a = [:a, :b, :c]
+ a.instance_variable_set(:@two, 2)
+ obj = [s, 10, s, s, st, a]
+ obj.instance_variable_set(:@zoo, 'ant')
+ proc = Proc.new { |o| arr << o; o}
+
+ Marshal.send(@method, "\x04\bI[\vI\"\ahi\a:\x06EF:\t@fooi\ni\x0F@\x06@\x06IS:\x14Struct::Brittle\x06:\x06af\x060\x06:\n@clueI\"\tnone\x06;\x00FI[\b;\b:\x06b:\x06c\x06:\t@twoi\a\x06:\t@zooI\"\bant\x06;\x00F", proc)
+
+ arr.should == ["hi", false, 5, 10, "hi", "hi", 0.0, st, "none", false,
+ :b, :c, a, 2, ["hi", 10, "hi", "hi", st, [:a, :b, :c]], "ant", false]
+
+ Struct.send(:remove_const, :Brittle)
end
end
@@ -182,109 +162,107 @@ describe :marshal_load, shared: true do
marshal_data[0] = (Marshal::MAJOR_VERSION).chr
marshal_data[1] = (Marshal::MINOR_VERSION + 1).chr
- -> { Marshal.send(@method, marshal_data) }.should raise_error(TypeError)
+ lambda { Marshal.send(@method, marshal_data) }.should raise_error(TypeError)
marshal_data = '\xff\xff'
marshal_data[0] = (Marshal::MAJOR_VERSION - 1).chr
marshal_data[1] = (Marshal::MINOR_VERSION).chr
- -> { Marshal.send(@method, marshal_data) }.should raise_error(TypeError)
+ lambda { Marshal.send(@method, marshal_data) }.should raise_error(TypeError)
end
it "raises EOFError on loading an empty file" do
temp_file = tmp("marshal.rubyspec.tmp.#{Process.pid}")
file = File.new(temp_file, "w+")
begin
- -> { Marshal.send(@method, file) }.should raise_error(EOFError)
+ lambda { Marshal.send(@method, file) }.should raise_error(EOFError)
ensure
file.close
rm_r temp_file
end
end
- ruby_version_is ''...'2.7' do
- it "returns an untainted object if source is untainted" do
- x = Object.new
- y = Marshal.send(@method, Marshal.dump(x))
- y.tainted?.should be_false
- end
-
- describe "when source is tainted" do
- it "returns a tainted object" do
- x = Object.new
- x.taint
- s = Marshal.dump(x)
- y = Marshal.send(@method, s)
- y.tainted?.should be_true
-
- # note that round-trip via Marshal does not preserve
- # the taintedness at each level of the nested structure
- y = Marshal.send(@method, Marshal.dump([[x]]))
- y.tainted?.should be_true
- y.first.tainted?.should be_true
- y.first.first.tainted?.should be_true
- end
-
- it "does not taint Symbols" do
- x = [:x]
- y = Marshal.send(@method, Marshal.dump(x).taint)
- y.tainted?.should be_true
- y.first.tainted?.should be_false
- end
-
- it "does not taint Fixnums" do
- x = [1]
- y = Marshal.send(@method, Marshal.dump(x).taint)
- y.tainted?.should be_true
- y.first.tainted?.should be_false
- end
-
- it "does not taint Bignums" do
- x = [bignum_value]
- y = Marshal.send(@method, Marshal.dump(x).taint)
- y.tainted?.should be_true
- y.first.tainted?.should be_false
- end
-
- it "does not taint Floats" do
- x = [1.2]
- y = Marshal.send(@method, Marshal.dump(x).taint)
- y.tainted?.should be_true
- y.first.tainted?.should be_false
- end
- end
+ it "returns an untainted object if source is untainted" do
+ x = Object.new
+ y = Marshal.send(@method, Marshal.dump(x))
+ y.tainted?.should be_false
+ end
- it "preserves taintedness of nested structure" do
+ describe "when source is tainted" do
+ it "returns a tainted object" do
x = Object.new
- a = [[x]]
x.taint
- y = Marshal.send(@method, Marshal.dump(a))
+ s = Marshal.dump(x)
+ y = Marshal.send(@method, s)
+ y.tainted?.should be_true
+
+ # note that round-trip via Marshal does not preserve
+ # the taintedness at each level of the nested structure
+ y = Marshal.send(@method, Marshal.dump([[x]]))
y.tainted?.should be_true
y.first.tainted?.should be_true
y.first.first.tainted?.should be_true
end
- it "returns a trusted object if source is trusted" do
- x = Object.new
- y = Marshal.send(@method, Marshal.dump(x))
- y.untrusted?.should be_false
+ it "does not taint Symbols" do
+ x = [:x]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
end
- it "returns an untrusted object if source is untrusted" do
- x = Object.new
- x.untrust
- y = Marshal.send(@method, Marshal.dump(x))
- y.untrusted?.should be_true
+ it "does not taint Fixnums" do
+ x = [1]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
+ end
- # note that round-trip via Marshal does not preserve
- # the untrustedness at each level of the nested structure
- y = Marshal.send(@method, Marshal.dump([[x]]))
- y.untrusted?.should be_true
- y.first.untrusted?.should be_true
- y.first.first.untrusted?.should be_true
+ it "does not taint Bignums" do
+ x = [bignum_value]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
+ end
+
+ it "does not taint Floats" do
+ x = [1.2]
+ y = Marshal.send(@method, Marshal.dump(x).taint)
+ y.tainted?.should be_true
+ y.first.tainted?.should be_false
end
end
+ it "preserves taintedness of nested structure" do
+ x = Object.new
+ a = [[x]]
+ x.taint
+ y = Marshal.send(@method, Marshal.dump(a))
+ y.tainted?.should be_true
+ y.first.tainted?.should be_true
+ y.first.first.tainted?.should be_true
+ end
+
+ it "returns a trusted object if source is trusted" do
+ x = Object.new
+ y = Marshal.send(@method, Marshal.dump(x))
+ y.untrusted?.should be_false
+ end
+
+ it "returns an untrusted object if source is untrusted" do
+ x = Object.new
+ x.untrust
+ y = Marshal.send(@method, Marshal.dump(x))
+ y.untrusted?.should be_true
+
+ # note that round-trip via Marshal does not preserve
+ # the untrustedness at each level of the nested structure
+ y = Marshal.send(@method, Marshal.dump([[x]]))
+ y.untrusted?.should be_true
+ y.first.untrusted?.should be_true
+ y.first.first.untrusted?.should be_true
+ end
+
# Note: Ruby 1.9 should be compatible with older marshal format
MarshalSpec::DATA.each do |description, (object, marshal, attributes)|
it "loads a #{description}" do
@@ -374,54 +352,6 @@ describe :marshal_load, shared: true do
end
end
- describe "for a Symbol" do
- it "loads a Symbol" do
- sym = Marshal.send(@method, "\004\b:\vsymbol")
- sym.should == :symbol
- sym.encoding.should == Encoding::US_ASCII
- end
-
- it "loads a big Symbol" do
- sym = ('big' * 100).to_sym
- Marshal.send(@method, "\004\b:\002,\001#{'big' * 100}").should == sym
- end
-
- it "loads an encoded Symbol" do
- s = "\u2192"
-
- sym = Marshal.send(@method, "\x04\bI:\b\xE2\x86\x92\x06:\x06ET")
- sym.should == s.encode("utf-8").to_sym
- sym.encoding.should == Encoding::UTF_8
-
- sym = Marshal.send(@method, "\x04\bI:\t\xFE\xFF!\x92\x06:\rencoding\"\vUTF-16")
- sym.should == s.encode("utf-16").to_sym
- sym.encoding.should == Encoding::UTF_16
-
- sym = Marshal.send(@method, "\x04\bI:\a\x92!\x06:\rencoding\"\rUTF-16LE")
- sym.should == s.encode("utf-16le").to_sym
- sym.encoding.should == Encoding::UTF_16LE
-
- sym = Marshal.send(@method, "\x04\bI:\a!\x92\x06:\rencoding\"\rUTF-16BE")
- sym.should == s.encode("utf-16be").to_sym
- sym.encoding.should == Encoding::UTF_16BE
-
- sym = Marshal.send(@method, "\x04\bI:\a\xA2\xAA\x06:\rencoding\"\vEUC-JP")
- sym.should == s.encode("euc-jp").to_sym
- sym.encoding.should == Encoding::EUC_JP
-
- sym = Marshal.send(@method, "\x04\bI:\a\x81\xA8\x06:\rencoding\"\x10Windows-31J")
- sym.should == s.encode("sjis").to_sym
- sym.encoding.should == Encoding::SJIS
- end
-
- it "loads a binary encoded Symbol" do
- s = "\u2192".force_encoding("binary").to_sym
- sym = Marshal.send(@method, "\x04\b:\b\xE2\x86\x92")
- sym.should == s
- sym.encoding.should == Encoding::BINARY
- end
- end
-
describe "for a String" do
it "loads a string having ivar with ref to self" do
obj = 'hi'
@@ -444,36 +374,38 @@ describe :marshal_load, shared: true do
str.should be_an_instance_of(UserCustomConstructorString)
end
- it "loads a US-ASCII String" do
- str = "abc".force_encoding("us-ascii")
- data = "\x04\bI\"\babc\x06:\x06EF"
- result = Marshal.send(@method, data)
- result.should == str
- result.encoding.should equal(Encoding::US_ASCII)
- end
+ with_feature :encoding do
+ it "loads a US-ASCII String" do
+ str = "abc".force_encoding("us-ascii")
+ data = "\x04\bI\"\babc\x06:\x06EF"
+ result = Marshal.send(@method, data)
+ result.should == str
+ result.encoding.should equal(Encoding::US_ASCII)
+ end
- it "loads a UTF-8 String" do
- str = "\x6d\xc3\xb6\x68\x72\x65".force_encoding("utf-8")
- data = "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET"
- result = Marshal.send(@method, data)
- result.should == str
- result.encoding.should equal(Encoding::UTF_8)
- end
+ it "loads a UTF-8 String" do
+ str = "\x6d\xc3\xb6\x68\x72\x65".force_encoding("utf-8")
+ data = "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET"
+ result = Marshal.send(@method, data)
+ result.should == str
+ result.encoding.should equal(Encoding::UTF_8)
+ end
- it "loads a String in another encoding" do
- str = "\x6d\x00\xf6\x00\x68\x00\x72\x00\x65\x00".force_encoding("utf-16le")
- data = "\x04\bI\"\x0Fm\x00\xF6\x00h\x00r\x00e\x00\x06:\rencoding\"\rUTF-16LE"
- result = Marshal.send(@method, data)
- result.should == str
- result.encoding.should equal(Encoding::UTF_16LE)
- end
+ it "loads a String in another encoding" do
+ str = "\x6d\x00\xf6\x00\x68\x00\x72\x00\x65\x00".force_encoding("utf-16le")
+ data = "\x04\bI\"\x0Fm\x00\xF6\x00h\x00r\x00e\x00\x06:\rencoding\"\rUTF-16LE"
+ result = Marshal.send(@method, data)
+ result.should == str
+ result.encoding.should equal(Encoding::UTF_16LE)
+ end
- it "loads a String as BINARY if no encoding is specified at the end" do
- str = "\xC3\xB8".force_encoding("BINARY")
- data = "\x04\b\"\a\xC3\xB8".force_encoding("UTF-8")
- result = Marshal.send(@method, data)
- result.encoding.should == Encoding::BINARY
- result.should == str
+ it "loads a String as ASCII-8BIT if no encoding is specified at the end" do
+ str = "\xC3\xB8".force_encoding("ASCII-8BIT")
+ data = "\x04\b\"\a\xC3\xB8".force_encoding("UTF-8")
+ result = Marshal.send(@method, data)
+ result.encoding.should == Encoding::ASCII_8BIT
+ result.should == str
+ end
end
end
@@ -551,76 +483,42 @@ describe :marshal_load, shared: true do
loaded.message.should == obj.message
loaded.backtrace.should == obj.backtrace
end
-
- it "loads an marshalled exception with ivars" do
- s = 'hi'
- arr = [:so, :so, s, s]
- obj = Exception.new("foo")
- obj.instance_variable_set :@arr, arr
-
- loaded = Marshal.send(@method, "\x04\bo:\x0EException\b:\tmesg\"\bfoo:\abt0:\t@arr[\t:\aso;\t\"\ahi@\b")
- new_arr = loaded.instance_variable_get :@arr
-
- loaded.message.should == obj.message
- new_arr.should == arr
- end
end
- describe "for an Object" do
- it "loads an object" do
- Marshal.send(@method, "\004\bo:\vObject\000").should be_kind_of(Object)
- end
-
- it "loads an extended Object" do
- obj = Object.new.extend(Meths)
+ describe "for a user Class" do
+ it "loads a user-marshaled extended object" do
+ obj = UserMarshal.new.extend(Meths)
- new_obj = Marshal.send(@method, "\004\be:\nMethso:\vObject\000")
+ new_obj = Marshal.send(@method, "\004\bU:\020UserMarshal\"\nstuff")
- new_obj.class.should == obj.class
+ new_obj.should == obj
new_obj_metaclass_ancestors = class << new_obj; ancestors; end
- new_obj_metaclass_ancestors[@num_self_class, 2].should == [Meths, Object]
+ new_obj_metaclass_ancestors[@num_self_class].should == UserMarshal
end
- it "loads an object having ivar" do
- s = 'hi'
- arr = [:so, :so, s, s]
- obj = Object.new
- obj.instance_variable_set :@str, arr
-
- new_obj = Marshal.send(@method, "\004\bo:\vObject\006:\t@str[\t:\aso;\a\"\ahi@\a")
- new_str = new_obj.instance_variable_get :@str
-
- new_str.should == arr
+ it "loads a user_object" do
+ UserObject.new
+ Marshal.send(@method, "\004\bo:\017UserObject\000").should be_kind_of(UserObject)
end
- it "loads an Object with a non-US-ASCII instance variable" do
- ivar = "@é".force_encoding(Encoding::UTF_8).to_sym
- obj = Marshal.send(@method, "\x04\bo:\vObject\x06I:\b@\xC3\xA9\x06:\x06ETi\x06")
- obj.instance_variables.should == [ivar]
- obj.instance_variables[0].encoding.should == Encoding::UTF_8
- obj.instance_variable_get(ivar).should == 1
+ it "loads an object" do
+ Marshal.send(@method, "\004\bo:\vObject\000").should be_kind_of(Object)
end
it "raises ArgumentError if the object from an 'o' stream is not dumpable as 'o' type user class" do
- -> do
+ lambda do
Marshal.send(@method, "\x04\bo:\tFile\001\001:\001\005@path\"\x10/etc/passwd")
end.should raise_error(ArgumentError)
end
- end
- describe "for a user object" do
- it "loads a user-marshaled extended object" do
- obj = UserMarshal.new.extend(Meths)
+ it "loads an extended Object" do
+ obj = Object.new.extend(Meths)
- new_obj = Marshal.send(@method, "\004\bU:\020UserMarshal\"\nstuff")
+ new_obj = Marshal.send(@method, "\004\be:\nMethso:\vObject\000")
- new_obj.should == obj
+ new_obj.class.should == obj.class
new_obj_metaclass_ancestors = class << new_obj; ancestors; end
- new_obj_metaclass_ancestors[@num_self_class].should == UserMarshal
- end
-
- it "loads a UserObject" do
- Marshal.send(@method, "\004\bo:\017UserObject\000").should be_kind_of(UserObject)
+ new_obj_metaclass_ancestors[@num_self_class, 2].should == [Meths, Object]
end
describe "that extends a core type other than Object or BasicObject" do
@@ -633,12 +531,24 @@ describe :marshal_load, shared: true do
data = Marshal.dump(MarshalSpec::SwappedClass.new)
MarshalSpec.set_swapped_class(Class.new(Array))
- -> { Marshal.send(@method, data) }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, data) }.should raise_error(ArgumentError)
MarshalSpec.set_swapped_class(Class.new)
- -> { Marshal.send(@method, data) }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, data) }.should raise_error(ArgumentError)
end
end
+
+ it "loads an object having ivar" do
+ s = 'hi'
+ arr = [:so, :so, s, s]
+ obj = Object.new
+ obj.instance_variable_set :@str, arr
+
+ new_obj = Marshal.send(@method, "\004\bo:\vObject\006:\t@str[\t:\aso;\a\"\ahi@\a")
+ new_str = new_obj.instance_variable_get :@str
+
+ new_str.should == arr
+ end
end
describe "for a Regexp" do
@@ -737,7 +647,7 @@ describe :marshal_load, shared: true do
"\004\bi\004\0",
"\004\bi\004\0\0",
"\004\bi\004\0\0\0"].each do |invalid|
- -> { Marshal.send(@method, invalid) }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, invalid) }.should raise_error(ArgumentError)
end
end
@@ -834,11 +744,11 @@ describe :marshal_load, shared: true do
end
it "raises ArgumentError if given the name of a non-Module" do
- -> { Marshal.send(@method, "\x04\bc\vKernel") }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, "\x04\bc\vKernel") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if given a nonexistent class" do
- -> { Marshal.send(@method, "\x04\bc\vStrung") }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, "\x04\bc\vStrung") }.should raise_error(ArgumentError)
end
end
@@ -848,7 +758,7 @@ describe :marshal_load, shared: true do
end
it "raises ArgumentError if given the name of a non-Class" do
- -> { Marshal.send(@method, "\x04\bm\vString") }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, "\x04\bm\vString") }.should raise_error(ArgumentError)
end
it "loads an old module" do
@@ -887,13 +797,13 @@ describe :marshal_load, shared: true do
data = "\x04\bd:\x1AUnloadableDumpableDirI\"\x06.\x06:\x06ET"
- -> { Marshal.send(@method, data) }.should raise_error(TypeError)
+ lambda { Marshal.send(@method, data) }.should raise_error(TypeError)
end
it "raises ArgumentError when the local class is a regular object" do
data = "\004\bd:\020UserDefined\0"
- -> { Marshal.send(@method, data) }.should raise_error(ArgumentError)
+ lambda { Marshal.send(@method, data) }.should raise_error(ArgumentError)
end
end
@@ -906,7 +816,7 @@ describe :marshal_load, shared: true do
it "raises an ArgumentError" do
message = "undefined class/module NamespaceTest::SameName"
- -> { Marshal.send(@method, @data) }.should raise_error(ArgumentError, message)
+ lambda { Marshal.send(@method, @data) }.should raise_error(ArgumentError, message)
end
end
@@ -915,6 +825,6 @@ describe :marshal_load, shared: true do
@data = Marshal.dump(NamespaceTest::KaBoom.new)
NamespaceTest.send(:remove_const, :KaBoom)
- -> { Marshal.send(@method, @data) }.should raise_error(ArgumentError, /NamespaceTest::KaBoom/)
+ lambda { Marshal.send(@method, @data) }.should raise_error(ArgumentError, /NamespaceTest::KaBoom/)
end
end
diff --git a/spec/ruby/core/matchdata/allocate_spec.rb b/spec/ruby/core/matchdata/allocate_spec.rb
deleted file mode 100644
index 9f3ada4018..0000000000
--- a/spec/ruby/core/matchdata/allocate_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "MatchData.allocate" do
- ruby_version_is "2.7" do
- it "is undefined" do
- # https://bugs.ruby-lang.org/issues/16294
- -> { MatchData.allocate }.should raise_error(NoMethodError)
- end
- end
-end
diff --git a/spec/ruby/core/matchdata/begin_spec.rb b/spec/ruby/core/matchdata/begin_spec.rb
index 85c454da56..b3d042066d 100644
--- a/spec/ruby/core/matchdata/begin_spec.rb
+++ b/spec/ruby/core/matchdata/begin_spec.rb
@@ -1,104 +1,30 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#begin" do
- context "when passed an integer argument" do
- it "returns the character offset of the start of the nth element" do
- match_data = /(.)(.)(\d+)(\d)/.match("THX1138.")
- match_data.begin(0).should == 1
- match_data.begin(2).should == 2
- end
-
- it "returns nil when the nth match isn't found" do
- match_data = /something is( not)? (right)/.match("something is right")
- match_data.begin(1).should be_nil
- end
-
- it "returns the character offset for multi-byte strings" do
- match_data = /(.)(.)(\d+)(\d)/.match("TñX1138.")
- match_data.begin(0).should == 1
- match_data.begin(2).should == 2
- end
-
- not_supported_on :opal do
- it "returns the character offset for multi-byte strings with unicode regexp" do
- match_data = /(.)(.)(\d+)(\d)/u.match("TñX1138.")
- match_data.begin(0).should == 1
- match_data.begin(2).should == 2
- end
- end
-
- it "tries to convert the passed argument to an Integer using #to_int" do
- obj = mock('to_int')
- obj.should_receive(:to_int).and_return(2)
-
- match_data = /(.)(.)(\d+)(\d)/.match("THX1138.")
- match_data.begin(obj).should == 2
- end
+ it "returns the offset of the start of the nth element" do
+ match_data = /(.)(.)(\d+)(\d)/.match("THX1138.")
+ match_data.begin(0).should == 1
+ match_data.begin(2).should == 2
end
- context "when passed a String argument" do
- it "return the character offset of the start of the named capture" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.begin("a").should == 1
- match_data.begin("b").should == 3
- end
-
- it "returns the character offset for multi byte strings" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("TñX1138.")
- match_data.begin("a").should == 1
- match_data.begin("b").should == 3
- end
-
- not_supported_on :opal do
- it "returns the character offset for multi byte strings with unicode regexp" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/u.match("TñX1138.")
- match_data.begin("a").should == 1
- match_data.begin("b").should == 3
- end
- end
-
- it "returns the character offset for the farthest match when multiple named captures use the same name" do
- match_data = /(?<a>.)(.)(?<a>\d+)(\d)/.match("THX1138.")
- match_data.begin("a").should == 3
- end
-
- it "returns the character offset for multi-byte names" do
- match_data = /(?<æ>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.begin("æ").should == 1
- end
+ it "returns nil when the nth match isn't found" do
+ match_data = /something is( not)? (right)/.match("something is right")
+ match_data.begin(1).should be_nil
end
- context "when passed a Symbol argument" do
- it "return the character offset of the start of the named capture" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.begin(:a).should == 1
- match_data.begin(:b).should == 3
- end
-
- it "returns the character offset for multi byte strings" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("TñX1138.")
- match_data.begin(:a).should == 1
- match_data.begin(:b).should == 3
- end
-
- not_supported_on :opal do
- it "returns the character offset for multi byte strings with unicode regexp" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/u.match("TñX1138.")
- match_data.begin(:a).should == 1
- match_data.begin(:b).should == 3
- end
- end
-
- it "returns the character offset for the farthest match when multiple named captures use the same name" do
- match_data = /(?<a>.)(.)(?<a>\d+)(\d)/.match("THX1138.")
- match_data.begin(:a).should == 3
- end
+ it "returns the offset for multi byte strings" do
+ match_data = /(.)(.)(\d+)(\d)/.match("TñX1138.")
+ match_data.begin(0).should == 1
+ match_data.begin(2).should == 2
+ end
- it "returns the character offset for multi-byte names" do
- match_data = /(?<æ>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.begin(:æ).should == 1
+ not_supported_on :opal do
+ it "returns the offset for multi byte strings with unicode regexp" do
+ match_data = /(.)(.)(\d+)(\d)/u.match("TñX1138.")
+ match_data.begin(0).should == 1
+ match_data.begin(2).should == 2
end
end
end
diff --git a/spec/ruby/core/matchdata/captures_spec.rb b/spec/ruby/core/matchdata/captures_spec.rb
index 8c0d2978b7..2a83b26cd4 100644
--- a/spec/ruby/core/matchdata/captures_spec.rb
+++ b/spec/ruby/core/matchdata/captures_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#captures" do
it "returns an array of the match captures" do
diff --git a/spec/ruby/core/matchdata/dup_spec.rb b/spec/ruby/core/matchdata/dup_spec.rb
deleted file mode 100644
index 70877f07eb..0000000000
--- a/spec/ruby/core/matchdata/dup_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "MatchData#dup" do
- it "duplicates the match data" do
- original = /ll/.match("hello")
- original.instance_variable_set(:@custom_ivar, 42)
- duplicate = original.dup
-
- duplicate.instance_variable_get(:@custom_ivar).should == 42
- original.regexp.should == duplicate.regexp
- original.string.should == duplicate.string
- original.offset(0).should == duplicate.offset(0)
- end
-end
diff --git a/spec/ruby/core/matchdata/element_reference_spec.rb b/spec/ruby/core/matchdata/element_reference_spec.rb
index 26550ac94d..17d16a5526 100644
--- a/spec/ruby/core/matchdata/element_reference_spec.rb
+++ b/spec/ruby/core/matchdata/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#[]" do
it "acts as normal array indexing [index]" do
@@ -71,12 +71,12 @@ describe "MatchData#[Symbol]" do
it "raises an IndexError if there is no named match corresponding to the Symbol" do
md = 'haystack'.match(/(?<t>t(?<a>ack))/)
- -> { md[:baz] }.should raise_error(IndexError, /baz/)
+ lambda { md[:baz] }.should raise_error(IndexError, /baz/)
end
it "raises an IndexError if there is no named match corresponding to the String" do
md = 'haystack'.match(/(?<t>t(?<a>ack))/)
- -> { md['baz'] }.should raise_error(IndexError, /baz/)
+ lambda { md['baz'] }.should raise_error(IndexError, /baz/)
end
it "returns matches in the String's encoding" do
diff --git a/spec/ruby/core/matchdata/end_spec.rb b/spec/ruby/core/matchdata/end_spec.rb
index d01b0a8b30..4e74492105 100644
--- a/spec/ruby/core/matchdata/end_spec.rb
+++ b/spec/ruby/core/matchdata/end_spec.rb
@@ -1,104 +1,30 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#end" do
- context "when passed an integer argument" do
- it "returns the character offset of the end of the nth element" do
- match_data = /(.)(.)(\d+)(\d)/.match("THX1138.")
- match_data.end(0).should == 7
- match_data.end(2).should == 3
- end
-
- it "returns nil when the nth match isn't found" do
- match_data = /something is( not)? (right)/.match("something is right")
- match_data.end(1).should be_nil
- end
-
- it "returns the character offset for multi-byte strings" do
- match_data = /(.)(.)(\d+)(\d)/.match("TñX1138.")
- match_data.end(0).should == 7
- match_data.end(2).should == 3
- end
-
- not_supported_on :opal do
- it "returns the character offset for multi-byte strings with unicode regexp" do
- match_data = /(.)(.)(\d+)(\d)/u.match("TñX1138.")
- match_data.end(0).should == 7
- match_data.end(2).should == 3
- end
- end
-
- it "tries to convert the passed argument to an Integer using #to_int" do
- obj = mock('to_int')
- obj.should_receive(:to_int).and_return(2)
-
- match_data = /(.)(.)(\d+)(\d)/.match("THX1138.")
- match_data.end(obj).should == 3
- end
+ it "returns the offset of the end of the nth element" do
+ match_data = /(.)(.)(\d+)(\d)/.match("THX1138.")
+ match_data.end(0).should == 7
+ match_data.end(2).should == 3
end
- context "when passed a String argument" do
- it "return the character offset of the start of the named capture" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.end("a").should == 2
- match_data.end("b").should == 6
- end
-
- it "returns the character offset for multi byte strings" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("TñX1138.")
- match_data.end("a").should == 2
- match_data.end("b").should == 6
- end
-
- not_supported_on :opal do
- it "returns the character offset for multi byte strings with unicode regexp" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/u.match("TñX1138.")
- match_data.end("a").should == 2
- match_data.end("b").should == 6
- end
- end
-
- it "returns the character offset for the farthest match when multiple named captures use the same name" do
- match_data = /(?<a>.)(.)(?<a>\d+)(\d)/.match("THX1138.")
- match_data.end("a").should == 6
- end
-
- it "returns the character offset for multi-byte names" do
- match_data = /(?<æ>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.end("æ").should == 2
- end
+ it "returns nil when the nth match isn't found" do
+ match_data = /something is( not)? (right)/.match("something is right")
+ match_data.end(1).should be_nil
end
- context "when passed a Symbol argument" do
- it "return the character offset of the start of the named capture" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.end(:a).should == 2
- match_data.end(:b).should == 6
- end
-
- it "returns the character offset for multi byte strings" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/.match("TñX1138.")
- match_data.end(:a).should == 2
- match_data.end(:b).should == 6
- end
-
- not_supported_on :opal do
- it "returns the character offset for multi byte strings with unicode regexp" do
- match_data = /(?<a>.)(.)(?<b>\d+)(\d)/u.match("TñX1138.")
- match_data.end(:a).should == 2
- match_data.end(:b).should == 6
- end
- end
-
- it "returns the character offset for the farthest match when multiple named captures use the same name" do
- match_data = /(?<a>.)(.)(?<a>\d+)(\d)/.match("THX1138.")
- match_data.end(:a).should == 6
- end
+ it "returns the offset for multi byte strings" do
+ match_data = /(.)(.)(\d+)(\d)/.match("TñX1138.")
+ match_data.end(0).should == 7
+ match_data.end(2).should == 3
+ end
- it "returns the character offset for multi-byte names" do
- match_data = /(?<æ>.)(.)(?<b>\d+)(\d)/.match("THX1138.")
- match_data.end(:æ).should == 2
+ not_supported_on :opal do
+ it "returns the offset for multi byte strings with unicode regexp" do
+ match_data = /(.)(.)(\d+)(\d)/u.match("TñX1138.")
+ match_data.end(0).should == 7
+ match_data.end(2).should == 3
end
end
end
diff --git a/spec/ruby/core/matchdata/eql_spec.rb b/spec/ruby/core/matchdata/eql_spec.rb
index 1d9666ebe1..192acbcd13 100644
--- a/spec/ruby/core/matchdata/eql_spec.rb
+++ b/spec/ruby/core/matchdata/eql_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "MatchData#eql?" do
- it_behaves_like :matchdata_eql, :eql?
+ it_behaves_like(:matchdata_eql, :eql?)
end
diff --git a/spec/ruby/core/matchdata/equal_value_spec.rb b/spec/ruby/core/matchdata/equal_value_spec.rb
index a58f1277e4..0d33d0acf2 100644
--- a/spec/ruby/core/matchdata/equal_value_spec.rb
+++ b/spec/ruby/core/matchdata/equal_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "MatchData#==" do
- it_behaves_like :matchdata_eql, :==
+ it_behaves_like(:matchdata_eql, :==)
end
diff --git a/spec/ruby/core/matchdata/hash_spec.rb b/spec/ruby/core/matchdata/hash_spec.rb
index cef18fdd20..1d5c8a203f 100644
--- a/spec/ruby/core/matchdata/hash_spec.rb
+++ b/spec/ruby/core/matchdata/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#hash" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/matchdata/inspect_spec.rb b/spec/ruby/core/matchdata/inspect_spec.rb
index 5315257677..3cf968b6f5 100644
--- a/spec/ruby/core/matchdata/inspect_spec.rb
+++ b/spec/ruby/core/matchdata/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#inspect" do
before :each do
@@ -14,10 +14,4 @@ describe "MatchData#inspect" do
# it makes perfect sense. See JRUBY-4558 for example.
@match_data.inspect.should == '#<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">'
end
-
- it "returns a human readable representation of named captures" do
- match_data = "abc def ghi".match(/(?<first>\w+)\s+(?<last>\w+)\s+(\w+)/)
-
- match_data.inspect.should == '#<MatchData "abc def ghi" first:"abc" last:"def">'
- end
end
diff --git a/spec/ruby/core/matchdata/length_spec.rb b/spec/ruby/core/matchdata/length_spec.rb
index 39df36df4b..75cf607598 100644
--- a/spec/ruby/core/matchdata/length_spec.rb
+++ b/spec/ruby/core/matchdata/length_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "MatchData#length" do
- it_behaves_like :matchdata_length, :length
+ it_behaves_like(:matchdata_length, :length)
end
diff --git a/spec/ruby/core/matchdata/named_captures_spec.rb b/spec/ruby/core/matchdata/named_captures_spec.rb
index 9b1e324a24..cc3aaa2b45 100644
--- a/spec/ruby/core/matchdata/named_captures_spec.rb
+++ b/spec/ruby/core/matchdata/named_captures_spec.rb
@@ -1,15 +1,13 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe 'MatchData#named_captures' do
- it 'returns a Hash that has captured name and the matched string pairs' do
- /(?<a>.)(?<b>.)?/.match('0').named_captures.should == { 'a' => '0', 'b' => nil }
- end
-
- it 'prefers later captures' do
- /\A(?<a>.)(?<b>.)(?<b>.)(?<a>.)\z/.match('0123').named_captures.should == { 'a' => '3', 'b' => '2' }
- end
+ruby_version_is '2.4' do
+ describe 'MatchData#named_captures' do
+ it 'returns a Hash that has captured name and the matched string pairs' do
+ /(?<a>.)(?<b>.)?/.match('0').named_captures.should == { 'a' => '0', 'b' => nil }
+ end
- it 'returns the latest matched capture, even if a later one that does not match exists' do
- /\A(?<a>.)(?<b>.)(?<b>.)(?<a>.)?\z/.match('012').named_captures.should == { 'a' => '0', 'b' => '2' }
+ it 'prefers later captures' do
+ /\A(?<a>.)(?<b>.)(?<b>.)(?<a>.)\z/.match('0123').named_captures.should == { 'a' => '3', 'b' => '2' }
+ end
end
end
diff --git a/spec/ruby/core/matchdata/names_spec.rb b/spec/ruby/core/matchdata/names_spec.rb
index 25ca06ced9..e298c85593 100644
--- a/spec/ruby/core/matchdata/names_spec.rb
+++ b/spec/ruby/core/matchdata/names_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#names" do
it "returns an Array" do
diff --git a/spec/ruby/core/matchdata/offset_spec.rb b/spec/ruby/core/matchdata/offset_spec.rb
index 1ccb54b7a7..6ddb56c1a7 100644
--- a/spec/ruby/core/matchdata/offset_spec.rb
+++ b/spec/ruby/core/matchdata/offset_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#offset" do
it "returns a two element array with the begin and end of the nth match" do
diff --git a/spec/ruby/core/matchdata/post_match_spec.rb b/spec/ruby/core/matchdata/post_match_spec.rb
index 4ae51f107e..670e0887ab 100644
--- a/spec/ruby/core/matchdata/post_match_spec.rb
+++ b/spec/ruby/core/matchdata/post_match_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#post_match" do
it "returns the string after the match equiv. special var $'" do
@@ -6,31 +6,31 @@ describe "MatchData#post_match" do
$'.should == ': The Movie'
end
- ruby_version_is ''...'2.7' do
- it "keeps taint status from the source string" do
- str = "THX1138: The Movie"
- str.taint
- res = /(.)(.)(\d+)(\d)/.match(str).post_match
- res.tainted?.should be_true
- $'.tainted?.should be_true
- end
-
- it "keeps untrusted status from the source string" do
- str = "THX1138: The Movie"
- str.untrust
- res = /(.)(.)(\d+)(\d)/.match(str).post_match
- res.untrusted?.should be_true
- $'.untrusted?.should be_true
- end
+ it "keeps taint status from the source string" do
+ str = "THX1138: The Movie"
+ str.taint
+ res = /(.)(.)(\d+)(\d)/.match(str).post_match
+ res.tainted?.should be_true
+ $'.tainted?.should be_true
end
- it "sets the encoding to the encoding of the source String" do
- str = "abc".force_encoding Encoding::EUC_JP
- str.match(/b/).post_match.encoding.should equal(Encoding::EUC_JP)
+ it "keeps untrusted status from the source string" do
+ str = "THX1138: The Movie"
+ str.untrust
+ res = /(.)(.)(\d+)(\d)/.match(str).post_match
+ res.untrusted?.should be_true
+ $'.untrusted?.should be_true
end
- it "sets an empty result to the encoding of the source String" do
- str = "abc".force_encoding Encoding::ISO_8859_1
- str.match(/c/).post_match.encoding.should equal(Encoding::ISO_8859_1)
+ with_feature :encoding do
+ it "sets the encoding to the encoding of the source String" do
+ str = "abc".force_encoding Encoding::EUC_JP
+ str.match(/b/).post_match.encoding.should equal(Encoding::EUC_JP)
+ end
+
+ it "sets an empty result to the encoding of the source String" do
+ str = "abc".force_encoding Encoding::ISO_8859_1
+ str.match(/c/).post_match.encoding.should equal(Encoding::ISO_8859_1)
+ end
end
end
diff --git a/spec/ruby/core/matchdata/pre_match_spec.rb b/spec/ruby/core/matchdata/pre_match_spec.rb
index 824612c84c..1f1f9daec6 100644
--- a/spec/ruby/core/matchdata/pre_match_spec.rb
+++ b/spec/ruby/core/matchdata/pre_match_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#pre_match" do
it "returns the string before the match, equiv. special var $`" do
@@ -6,31 +6,31 @@ describe "MatchData#pre_match" do
$`.should == 'T'
end
- ruby_version_is ''...'2.7' do
- it "keeps taint status from the source string" do
- str = "THX1138: The Movie"
- str.taint
- res = /(.)(.)(\d+)(\d)/.match(str).pre_match
- res.tainted?.should be_true
- $`.tainted?.should be_true
- end
-
- it "keeps untrusted status from the source string" do
- str = "THX1138: The Movie"
- str.untrust
- res = /(.)(.)(\d+)(\d)/.match(str).pre_match
- res.untrusted?.should be_true
- $`.untrusted?.should be_true
- end
+ it "keeps taint status from the source string" do
+ str = "THX1138: The Movie"
+ str.taint
+ res = /(.)(.)(\d+)(\d)/.match(str).pre_match
+ res.tainted?.should be_true
+ $`.tainted?.should be_true
end
- it "sets the encoding to the encoding of the source String" do
- str = "abc".force_encoding Encoding::EUC_JP
- str.match(/b/).pre_match.encoding.should equal(Encoding::EUC_JP)
+ it "keeps untrusted status from the source string" do
+ str = "THX1138: The Movie"
+ str.untrust
+ res = /(.)(.)(\d+)(\d)/.match(str).pre_match
+ res.untrusted?.should be_true
+ $`.untrusted?.should be_true
end
- it "sets an empty result to the encoding of the source String" do
- str = "abc".force_encoding Encoding::ISO_8859_1
- str.match(/a/).pre_match.encoding.should equal(Encoding::ISO_8859_1)
+ with_feature :encoding do
+ it "sets the encoding to the encoding of the source String" do
+ str = "abc".force_encoding Encoding::EUC_JP
+ str.match(/b/).pre_match.encoding.should equal(Encoding::EUC_JP)
+ end
+
+ it "sets an empty result to the encoding of the source String" do
+ str = "abc".force_encoding Encoding::ISO_8859_1
+ str.match(/a/).pre_match.encoding.should equal(Encoding::ISO_8859_1)
+ end
end
end
diff --git a/spec/ruby/core/matchdata/regexp_spec.rb b/spec/ruby/core/matchdata/regexp_spec.rb
index 099b59c559..2fdca34c30 100644
--- a/spec/ruby/core/matchdata/regexp_spec.rb
+++ b/spec/ruby/core/matchdata/regexp_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#regexp" do
it "returns a Regexp object" do
@@ -10,15 +10,4 @@ describe "MatchData#regexp" do
m = 'haystack'.match(/hay/)
m.regexp.should == /hay/
end
-
- it "returns the same Regexp used to match" do
- r = /hay/
- m = 'haystack'.match(r)
- m.regexp.object_id.should == r.object_id
- end
-
- it "returns a Regexp for the result of gsub(String)" do
- 'he[[o'.gsub('[', ']')
- $~.regexp.should == /\[/
- end
end
diff --git a/spec/ruby/core/matchdata/shared/eql.rb b/spec/ruby/core/matchdata/shared/eql.rb
index e021baa178..098d82db5b 100644
--- a/spec/ruby/core/matchdata/shared/eql.rb
+++ b/spec/ruby/core/matchdata/shared/eql.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :matchdata_eql, shared: true do
it "returns true if both operands have equal target strings, patterns, and match positions" do
diff --git a/spec/ruby/core/matchdata/size_spec.rb b/spec/ruby/core/matchdata/size_spec.rb
index b4965db3b8..e043f51870 100644
--- a/spec/ruby/core/matchdata/size_spec.rb
+++ b/spec/ruby/core/matchdata/size_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "MatchData#size" do
- it_behaves_like :matchdata_length, :size
+ it_behaves_like(:matchdata_length, :size)
end
diff --git a/spec/ruby/core/matchdata/string_spec.rb b/spec/ruby/core/matchdata/string_spec.rb
index db0d5dfbdc..793684d36a 100644
--- a/spec/ruby/core/matchdata/string_spec.rb
+++ b/spec/ruby/core/matchdata/string_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#string" do
it "returns a copy of the match string" do
@@ -11,15 +11,4 @@ describe "MatchData#string" do
str.should == "THX1138."
str.frozen?.should == true
end
-
- it "returns the same frozen string for every call" do
- md = /(.)(.)(\d+)(\d)/.match("THX1138.")
- md.string.should equal(md.string)
- end
-
- it "returns a frozen copy of the matched string for gsub(String)" do
- 'he[[o'.gsub!('[', ']')
- $~.string.should == 'he[[o'
- $~.string.frozen?.should == true
- end
end
diff --git a/spec/ruby/core/matchdata/to_a_spec.rb b/spec/ruby/core/matchdata/to_a_spec.rb
index 6231d096fb..592a68db0e 100644
--- a/spec/ruby/core/matchdata/to_a_spec.rb
+++ b/spec/ruby/core/matchdata/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#to_a" do
it "returns an array of matches" do
diff --git a/spec/ruby/core/matchdata/to_s_spec.rb b/spec/ruby/core/matchdata/to_s_spec.rb
index 9e213bb342..3eb3b92533 100644
--- a/spec/ruby/core/matchdata/to_s_spec.rb
+++ b/spec/ruby/core/matchdata/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#to_s" do
it "returns the entire matched string" do
diff --git a/spec/ruby/core/matchdata/values_at_spec.rb b/spec/ruby/core/matchdata/values_at_spec.rb
index 8f7fdf557c..0b2727e001 100644
--- a/spec/ruby/core/matchdata/values_at_spec.rb
+++ b/spec/ruby/core/matchdata/values_at_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "MatchData#values_at" do
it "returns an array of the matching value" do
@@ -11,11 +11,13 @@ describe "MatchData#values_at" do
end
end
- it 'slices captures with the given names' do
- /(?<a>.)(?<b>.)(?<c>.)/.match('012').values_at(:c, :a).should == ['2', '0']
- end
+ ruby_version_is '2.4' do
+ it 'slices captures with the given names' do
+ /(?<a>.)(?<b>.)(?<c>.)/.match('012').values_at(:c, :a).should == ['2', '0']
+ end
- it 'takes names and indices' do
- /\A(?<a>.)(?<b>.)\z/.match('01').values_at(0, 1, 2, :a, :b).should == ['01', '0', '1', '0', '1']
+ it 'takes names and indices' do
+ /\A(?<a>.)(?<b>.)\z/.match('01').values_at(0, 1, 2, :a, :b).should == ['01', '0', '1', '0', '1']
+ end
end
end
diff --git a/spec/ruby/core/math/acos_spec.rb b/spec/ruby/core/math/acos_spec.rb
index 8b321ab29b..b0fd9baa91 100644
--- a/spec/ruby/core/math/acos_spec.rb
+++ b/spec/ruby/core/math/acos_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# arccosine : (-1.0, 1.0) --> (0, PI)
describe "Math.acos" do
@@ -20,16 +20,18 @@ describe "Math.acos" do
Math.acos(0.75).should be_close(0.722734247813416, TOLERANCE)
end
- it "raises an Math::DomainError if the argument is greater than 1.0" do
- -> { Math.acos(1.0001) }.should raise_error(Math::DomainError)
- end
+ conflicts_with :Complex do
+ it "raises an Errno::EDOM if the argument is greater than 1.0" do
+ lambda { Math.acos(1.0001) }.should raise_error(Errno::EDOM)
+ end
- it "raises an Math::DomainError if the argument is less than -1.0" do
- -> { Math.acos(-1.0001) }.should raise_error(Math::DomainError)
+ it "raises an Errno::EDOM if the argument is less than -1.0" do
+ lambda { Math.acos(-1.0001) }.should raise_error(Errno::EDOM)
+ end
end
it "raises a TypeError if the string argument cannot be coerced with Float()" do
- -> { Math.acos("test") }.should raise_error(TypeError)
+ lambda { Math.acos("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -37,11 +39,11 @@ describe "Math.acos" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.acos(MathSpecs::UserClass.new) }.should raise_error(TypeError)
+ lambda { Math.acos(MathSpecs::UserClass.new) }.should raise_error(TypeError)
end
it "raises a TypeError if the argument is nil" do
- -> { Math.acos(nil) }.should raise_error(TypeError)
+ lambda { Math.acos(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/acosh_spec.rb b/spec/ruby/core/math/acosh_spec.rb
index 6707de95d3..272bfaf6a9 100644
--- a/spec/ruby/core/math/acosh_spec.rb
+++ b/spec/ruby/core/math/acosh_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.acosh" do
it "returns a float" do
@@ -11,14 +11,16 @@ describe "Math.acosh" do
Math.acosh(1.0).should be_close(0.0, TOLERANCE)
end
- it "raises Math::DomainError if the passed argument is less than -1.0 or greater than 1.0" do
- -> { Math.acosh(1.0 - TOLERANCE) }.should raise_error(Math::DomainError)
- -> { Math.acosh(0) }.should raise_error(Math::DomainError)
- -> { Math.acosh(-1.0) }.should raise_error(Math::DomainError)
+ conflicts_with :Complex do
+ it "raises Errno::EDOM if the passed argument is less than -1.0 or greater than 1.0" do
+ lambda { Math.acosh(1.0 - TOLERANCE) }.should raise_error(Errno::EDOM)
+ lambda { Math.acosh(0) }.should raise_error(Errno::EDOM)
+ lambda { Math.acosh(-1.0) }.should raise_error(Errno::EDOM)
+ end
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.acosh("test") }.should raise_error(TypeError)
+ lambda { Math.acosh("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -26,7 +28,7 @@ describe "Math.acosh" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.acosh(nil) }.should raise_error(TypeError)
+ lambda { Math.acosh(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/asin_spec.rb b/spec/ruby/core/math/asin_spec.rb
index 3a674a1147..ef3426bceb 100644
--- a/spec/ruby/core/math/asin_spec.rb
+++ b/spec/ruby/core/math/asin_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# arcsine : (-1.0, 1.0) --> (-PI/2, PI/2)
describe "Math.asin" do
@@ -16,16 +16,18 @@ describe "Math.asin" do
Math.asin(0.75).should be_close(0.8480620789814816,TOLERANCE)
end
- it "raises an Math::DomainError if the argument is greater than 1.0" do
- -> { Math.asin(1.0001) }.should raise_error( Math::DomainError)
- end
+ conflicts_with :Complex do
+ it "raises an Errno::EDOM if the argument is greater than 1.0" do
+ lambda { Math.asin(1.0001) }.should raise_error( Errno::EDOM)
+ end
- it "raises an Math::DomainError if the argument is less than -1.0" do
- -> { Math.asin(-1.0001) }.should raise_error( Math::DomainError)
+ it "raises an Errno::EDOM if the argument is less than -1.0" do
+ lambda { Math.asin(-1.0001) }.should raise_error( Errno::EDOM)
+ end
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.asin("test") }.should raise_error(TypeError)
+ lambda { Math.asin("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -33,7 +35,7 @@ describe "Math.asin" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.asin(nil) }.should raise_error(TypeError)
+ lambda { Math.asin(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/asinh_spec.rb b/spec/ruby/core/math/asinh_spec.rb
index ff8210df0a..0761285806 100644
--- a/spec/ruby/core/math/asinh_spec.rb
+++ b/spec/ruby/core/math/asinh_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.asinh" do
it "returns a float" do
@@ -19,7 +19,7 @@ describe "Math.asinh" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.asinh("test") }.should raise_error(TypeError)
+ lambda { Math.asinh("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -27,7 +27,7 @@ describe "Math.asinh" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.asinh(nil) }.should raise_error(TypeError)
+ lambda { Math.asinh(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/atan2_spec.rb b/spec/ruby/core/math/atan2_spec.rb
index d4ef369d2a..ef8f9bb78f 100644
--- a/spec/ruby/core/math/atan2_spec.rb
+++ b/spec/ruby/core/math/atan2_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.atan2" do
it "returns a float" do
@@ -14,15 +14,15 @@ describe "Math.atan2" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.atan2(1.0, "test") }.should raise_error(TypeError)
- -> { Math.atan2("test", 0.0) }.should raise_error(TypeError)
- -> { Math.atan2("test", "this") }.should raise_error(TypeError)
+ lambda { Math.atan2(1.0, "test") }.should raise_error(TypeError)
+ lambda { Math.atan2("test", 0.0) }.should raise_error(TypeError)
+ lambda { Math.atan2("test", "this") }.should raise_error(TypeError)
end
it "raises a TypeError if the argument is nil" do
- -> { Math.atan2(nil, 1.0) }.should raise_error(TypeError)
- -> { Math.atan2(-1.0, nil) }.should raise_error(TypeError)
- -> { Math.atan2(nil, nil) }.should raise_error(TypeError)
+ lambda { Math.atan2(nil, 1.0) }.should raise_error(TypeError)
+ lambda { Math.atan2(-1.0, nil) }.should raise_error(TypeError)
+ lambda { Math.atan2(nil, nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/atan_spec.rb b/spec/ruby/core/math/atan_spec.rb
index 15edf68c05..6787479cd9 100644
--- a/spec/ruby/core/math/atan_spec.rb
+++ b/spec/ruby/core/math/atan_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# arctangent : (-Inf, Inf) --> (-PI/2, PI/2)
describe "Math.atan" do
@@ -17,7 +17,7 @@ describe "Math.atan" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.atan("test") }.should raise_error(TypeError)
+ lambda { Math.atan("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -25,7 +25,7 @@ describe "Math.atan" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.atan(nil) }.should raise_error(TypeError)
+ lambda { Math.atan(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/atanh_spec.rb b/spec/ruby/core/math/atanh_spec.rb
index 21fb209941..ce947ceab4 100644
--- a/spec/ruby/core/math/atanh_spec.rb
+++ b/spec/ruby/core/math/atanh_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/math/common'
-require_relative '../../shared/math/atanh'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/math/common', __FILE__)
+require File.expand_path('../../../shared/math/atanh', __FILE__)
describe "Math.atanh" do
it_behaves_like :math_atanh_base, :atanh, Math
diff --git a/spec/ruby/core/math/cbrt_spec.rb b/spec/ruby/core/math/cbrt_spec.rb
index 01cf923c71..0b608151ab 100644
--- a/spec/ruby/core/math/cbrt_spec.rb
+++ b/spec/ruby/core/math/cbrt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.cbrt" do
it "returns a float" do
@@ -14,11 +14,11 @@ describe "Math.cbrt" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.cbrt("foobar") }.should raise_error(TypeError)
+ lambda { Math.cbrt("foobar") }.should raise_error(TypeError)
end
it "raises a TypeError if the argument is nil" do
- -> { Math.cbrt(nil) }.should raise_error(TypeError)
+ lambda { Math.cbrt(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/constants_spec.rb b/spec/ruby/core/math/constants_spec.rb
index b500b21a79..8c1b33223e 100644
--- a/spec/ruby/core/math/constants_spec.rb
+++ b/spec/ruby/core/math/constants_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math::PI" do
it "approximates the value of pi" do
diff --git a/spec/ruby/core/math/cos_spec.rb b/spec/ruby/core/math/cos_spec.rb
index 3ba7a54c38..59b23b198b 100644
--- a/spec/ruby/core/math/cos_spec.rb
+++ b/spec/ruby/core/math/cos_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# cosine : (-Inf, Inf) --> (-1.0, 1.0)
describe "Math.cos" do
@@ -17,7 +17,7 @@ describe "Math.cos" do
it "raises a TypeError unless the argument is Numeric and has #to_f" do
- -> { Math.cos("test") }.should raise_error(TypeError)
+ lambda { Math.cos("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -25,7 +25,7 @@ describe "Math.cos" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.cos(nil) }.should raise_error(TypeError)
+ lambda { Math.cos(nil) }.should raise_error(TypeError)
end
it "coerces its argument with #to_f" do
diff --git a/spec/ruby/core/math/cosh_spec.rb b/spec/ruby/core/math/cosh_spec.rb
index 049e117e56..561c3cd312 100644
--- a/spec/ruby/core/math/cosh_spec.rb
+++ b/spec/ruby/core/math/cosh_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.cosh" do
it "returns a float" do
@@ -14,7 +14,7 @@ describe "Math.cosh" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.cosh("test") }.should raise_error(TypeError)
+ lambda { Math.cosh("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -22,7 +22,7 @@ describe "Math.cosh" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.cosh(nil) }.should raise_error(TypeError)
+ lambda { Math.cosh(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/erf_spec.rb b/spec/ruby/core/math/erf_spec.rb
index b4e6248e43..1ea5693dfe 100644
--- a/spec/ruby/core/math/erf_spec.rb
+++ b/spec/ruby/core/math/erf_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# erf method is the "error function" encountered in integrating the normal
# distribution (which is a normalized form of the Gaussian function).
@@ -21,7 +21,7 @@ describe "Math.erf" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.erf("test") }.should raise_error(TypeError)
+ lambda { Math.erf("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -29,7 +29,7 @@ describe "Math.erf" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.erf(nil) }.should raise_error(TypeError)
+ lambda { Math.erf(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/erfc_spec.rb b/spec/ruby/core/math/erfc_spec.rb
index e465f5cf58..21c9e246ff 100644
--- a/spec/ruby/core/math/erfc_spec.rb
+++ b/spec/ruby/core/math/erfc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# erfc is the complementary error function
describe "Math.erfc" do
@@ -20,7 +20,7 @@ describe "Math.erfc" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.erfc("test") }.should raise_error(TypeError)
+ lambda { Math.erfc("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -28,7 +28,7 @@ describe "Math.erfc" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.erfc(nil) }.should raise_error(TypeError)
+ lambda { Math.erfc(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/exp_spec.rb b/spec/ruby/core/math/exp_spec.rb
index 36eb49a8c7..a727404462 100644
--- a/spec/ruby/core/math/exp_spec.rb
+++ b/spec/ruby/core/math/exp_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.exp" do
it "returns a float" do
@@ -14,7 +14,7 @@ describe "Math.exp" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.exp("test") }.should raise_error(TypeError)
+ lambda { Math.exp("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -22,7 +22,7 @@ describe "Math.exp" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.exp(nil) }.should raise_error(TypeError)
+ lambda { Math.exp(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/frexp_spec.rb b/spec/ruby/core/math/frexp_spec.rb
index 7dfb493d20..4c529b0911 100644
--- a/spec/ruby/core/math/frexp_spec.rb
+++ b/spec/ruby/core/math/frexp_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.frexp" do
it "returns the normalized fraction and exponent" do
@@ -9,7 +9,7 @@ describe "Math.frexp" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.frexp("test") }.should raise_error(TypeError)
+ lambda { Math.frexp("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -18,7 +18,7 @@ describe "Math.frexp" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.frexp(nil) }.should raise_error(TypeError)
+ lambda { Math.frexp(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/gamma_spec.rb b/spec/ruby/core/math/gamma_spec.rb
index 386162a087..eb26f25bfe 100644
--- a/spec/ruby/core/math/gamma_spec.rb
+++ b/spec/ruby/core/math/gamma_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Math.gamma" do
it "returns +infinity given 0" do
@@ -51,7 +51,7 @@ describe "Math.gamma" do
end
it "raises Math::DomainError given -1" do
- -> { Math.gamma(-1) }.should raise_error(Math::DomainError)
+ lambda { Math.gamma(-1) }.should raise_error(Math::DomainError)
end
# See https://bugs.ruby-lang.org/issues/10642
@@ -60,7 +60,7 @@ describe "Math.gamma" do
end
it "raises Math::DomainError given negative infinity" do
- -> { Math.gamma(-Float::INFINITY) }.should raise_error(Math::DomainError)
+ lambda { Math.gamma(-Float::INFINITY) }.should raise_error(Math::DomainError)
end
it "returns NaN given NaN" do
diff --git a/spec/ruby/core/math/hypot_spec.rb b/spec/ruby/core/math/hypot_spec.rb
index 3e0ce74597..f693a719f3 100644
--- a/spec/ruby/core/math/hypot_spec.rb
+++ b/spec/ruby/core/math/hypot_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.hypot" do
it "returns a float" do
@@ -16,7 +16,7 @@ describe "Math.hypot" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.hypot("test", "this") }.should raise_error(TypeError)
+ lambda { Math.hypot("test", "this") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -26,7 +26,7 @@ describe "Math.hypot" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.hypot(nil, nil) }.should raise_error(TypeError)
+ lambda { Math.hypot(nil, nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/ldexp_spec.rb b/spec/ruby/core/math/ldexp_spec.rb
index fb7799cf26..360f5c5e2a 100644
--- a/spec/ruby/core/math/ldexp_spec.rb
+++ b/spec/ruby/core/math/ldexp_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.ldexp" do
it "returns a float" do
@@ -15,7 +15,7 @@ describe "Math.ldexp" do
end
it "raises a TypeError if the first argument cannot be coerced with Float()" do
- -> { Math.ldexp("test", 2) }.should raise_error(TypeError)
+ lambda { Math.ldexp("test", 2) }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -23,19 +23,19 @@ describe "Math.ldexp" do
end
it "raises RangeError if NaN is given as the second arg" do
- -> { Math.ldexp(0, nan_value) }.should raise_error(RangeError)
+ lambda { Math.ldexp(0, nan_value) }.should raise_error(RangeError)
end
it "raises a TypeError if the second argument cannot be coerced with Integer()" do
- -> { Math.ldexp(3.2, "this") }.should raise_error(TypeError)
+ lambda { Math.ldexp(3.2, "this") }.should raise_error(TypeError)
end
it "raises a TypeError if the first argument is nil" do
- -> { Math.ldexp(nil, 2) }.should raise_error(TypeError)
+ lambda { Math.ldexp(nil, 2) }.should raise_error(TypeError)
end
it "raises a TypeError if the second argument is nil" do
- -> { Math.ldexp(3.1, nil) }.should raise_error(TypeError)
+ lambda { Math.ldexp(3.1, nil) }.should raise_error(TypeError)
end
it "accepts any first argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/lgamma_spec.rb b/spec/ruby/core/math/lgamma_spec.rb
index 33e7836448..885a1b252c 100644
--- a/spec/ruby/core/math/lgamma_spec.rb
+++ b/spec/ruby/core/math/lgamma_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Math.lgamma" do
it "returns [Infinity, 1] when passed 0" do
@@ -11,8 +11,10 @@ describe "Math.lgamma" do
end
end
- it "returns [Infinity, -1] when passed -0.0" do
- Math.lgamma(-0.0).should == [infinity_value, -1]
+ ruby_version_is "2.4" do
+ it "returns [Infinity, -1] when passed -0.0" do
+ Math.lgamma(-0.0).should == [infinity_value, -1]
+ end
end
it "returns [log(sqrt(PI)), 1] when passed 0.5" do
@@ -40,7 +42,7 @@ describe "Math.lgamma" do
end
it "raises Math::DomainError when passed -Infinity" do
- -> { Math.lgamma(-infinity_value) }.should raise_error(Math::DomainError)
+ lambda { Math.lgamma(-infinity_value) }.should raise_error(Math::DomainError)
end
it "returns [Infinity, 1] when passed Infinity" do
diff --git a/spec/ruby/core/math/log10_spec.rb b/spec/ruby/core/math/log10_spec.rb
index c4daedcd5c..8164b9994d 100644
--- a/spec/ruby/core/math/log10_spec.rb
+++ b/spec/ruby/core/math/log10_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# The common logarithm, having base 10
describe "Math.log10" do
@@ -15,12 +15,14 @@ describe "Math.log10" do
Math.log10(10e15).should be_close(16.0, TOLERANCE)
end
- it "raises an Math::DomainError if the argument is less than 0" do
- -> { Math.log10(-1e-15) }.should raise_error(Math::DomainError)
+ conflicts_with :Complex do
+ it "raises an Errno::EDOM if the argument is less than 0" do
+ lambda { Math.log10(-1e-15) }.should raise_error( Errno::EDOM)
+ end
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.log10("test") }.should raise_error(TypeError)
+ lambda { Math.log10("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -28,7 +30,7 @@ describe "Math.log10" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.log10(nil) }.should raise_error(TypeError)
+ lambda { Math.log10(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/log2_spec.rb b/spec/ruby/core/math/log2_spec.rb
index 1594f2d7af..387f05ca9f 100644
--- a/spec/ruby/core/math/log2_spec.rb
+++ b/spec/ruby/core/math/log2_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.log2" do
it "returns a float" do
@@ -16,15 +16,15 @@ describe "Math.log2" do
end
it "raises an Errno::EDOM if the argument is less than 0" do
- -> { Math.log2(-1e-15) }.should raise_error( Math::DomainError)
+ lambda { Math.log2(-1e-15) }.should raise_error( Math::DomainError)
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.log2("test") }.should raise_error(TypeError)
+ lambda { Math.log2("test") }.should raise_error(TypeError)
end
it "raises a TypeError if passed a numerical argument as a string" do
- -> { Math.log2("1.0") }.should raise_error(TypeError)
+ lambda { Math.log2("1.0") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -32,7 +32,7 @@ describe "Math.log2" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.log2(nil) }.should raise_error(TypeError)
+ lambda { Math.log2(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/log_spec.rb b/spec/ruby/core/math/log_spec.rb
index 6c5036ba81..9bcccb55e2 100644
--- a/spec/ruby/core/math/log_spec.rb
+++ b/spec/ruby/core/math/log_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# The natural logarithm, having base Math::E
describe "Math.log" do
@@ -15,16 +15,18 @@ describe "Math.log" do
Math.log(10e15).should be_close(36.8413614879047, TOLERANCE)
end
- it "raises an Math::DomainError if the argument is less than 0" do
- -> { Math.log(-1e-15) }.should raise_error(Math::DomainError)
+ conflicts_with :Complex do
+ it "raises an Errno::EDOM if the argument is less than 0" do
+ lambda { Math.log(-1e-15) }.should raise_error(Errno::EDOM)
+ end
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.log("test") }.should raise_error(TypeError)
+ lambda { Math.log("test") }.should raise_error(TypeError)
end
it "raises a TypeError for numerical values passed as string" do
- -> { Math.log("10") }.should raise_error(TypeError)
+ lambda { Math.log("10") }.should raise_error(TypeError)
end
it "accepts a second argument for the base" do
@@ -33,8 +35,8 @@ describe "Math.log" do
end
it "raises a TypeError when the numerical base cannot be coerced to a float" do
- -> { Math.log(10, "2") }.should raise_error(TypeError)
- -> { Math.log(10, nil) }.should raise_error(TypeError)
+ lambda { Math.log(10, "2") }.should raise_error(TypeError)
+ lambda { Math.log(10, nil) }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -42,7 +44,7 @@ describe "Math.log" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.log(nil) }.should raise_error(TypeError)
+ lambda { Math.log(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/sin_spec.rb b/spec/ruby/core/math/sin_spec.rb
index 8e944bc95f..d8f134e609 100644
--- a/spec/ruby/core/math/sin_spec.rb
+++ b/spec/ruby/core/math/sin_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# sine : (-Inf, Inf) --> (-1.0, 1.0)
describe "Math.sin" do
@@ -16,7 +16,7 @@ describe "Math.sin" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.sin("test") }.should raise_error(TypeError)
+ lambda { Math.sin("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -24,7 +24,7 @@ describe "Math.sin" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.sin(nil) }.should raise_error(TypeError)
+ lambda { Math.sin(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/sinh_spec.rb b/spec/ruby/core/math/sinh_spec.rb
index 027c2395a7..daa7d30733 100644
--- a/spec/ruby/core/math/sinh_spec.rb
+++ b/spec/ruby/core/math/sinh_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.sinh" do
it "returns a float" do
@@ -14,7 +14,7 @@ describe "Math.sinh" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.sinh("test") }.should raise_error(TypeError)
+ lambda { Math.sinh("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -22,7 +22,7 @@ describe "Math.sinh" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.sinh(nil) }.should raise_error(TypeError)
+ lambda { Math.sinh(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/sqrt_spec.rb b/spec/ruby/core/math/sqrt_spec.rb
index 779aea2a0a..03891b951a 100644
--- a/spec/ruby/core/math/sqrt_spec.rb
+++ b/spec/ruby/core/math/sqrt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.sqrt" do
it "returns a float" do
@@ -13,7 +13,7 @@ describe "Math.sqrt" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.sqrt("test") }.should raise_error(TypeError)
+ lambda { Math.sqrt("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -21,7 +21,7 @@ describe "Math.sqrt" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.sqrt(nil) }.should raise_error(TypeError)
+ lambda { Math.sqrt(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/tan_spec.rb b/spec/ruby/core/math/tan_spec.rb
index c7b188cd81..0318ef8a14 100644
--- a/spec/ruby/core/math/tan_spec.rb
+++ b/spec/ruby/core/math/tan_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.tan" do
it "returns a float" do
@@ -13,13 +13,13 @@ describe "Math.tan" do
Math.tan(-9.65).should be_close(-0.229109052606441, TOLERANCE)
end
- it "returns NaN if called with +-Infinity" do
+ it "returns NaN if called with +-Infinitty" do
Math.tan(infinity_value).nan?.should == true
Math.tan(-infinity_value).nan?.should == true
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.tan("test") }.should raise_error(TypeError)
+ lambda { Math.tan("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -27,7 +27,7 @@ describe "Math.tan" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.tan(nil) }.should raise_error(TypeError)
+ lambda { Math.tan(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/math/tanh_spec.rb b/spec/ruby/core/math/tanh_spec.rb
index 568f8dfa77..8f39dc948b 100644
--- a/spec/ruby/core/math/tanh_spec.rb
+++ b/spec/ruby/core/math/tanh_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Math.tanh" do
it "returns a float" do
@@ -16,7 +16,7 @@ describe "Math.tanh" do
end
it "raises a TypeError if the argument cannot be coerced with Float()" do
- -> { Math.tanh("test") }.should raise_error(TypeError)
+ lambda { Math.tanh("test") }.should raise_error(TypeError)
end
it "returns NaN given NaN" do
@@ -24,7 +24,7 @@ describe "Math.tanh" do
end
it "raises a TypeError if the argument is nil" do
- -> { Math.tanh(nil) }.should raise_error(TypeError)
+ lambda { Math.tanh(nil) }.should raise_error(TypeError)
end
it "accepts any argument that can be coerced with Float()" do
diff --git a/spec/ruby/core/method/arity_spec.rb b/spec/ruby/core/method/arity_spec.rb
index 4bb821735a..32a50a0999 100644
--- a/spec/ruby/core/method/arity_spec.rb
+++ b/spec/ruby/core/method/arity_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#arity" do
SpecEvaluate.desc = "for method definition"
diff --git a/spec/ruby/core/method/call_spec.rb b/spec/ruby/core/method/call_spec.rb
index 6d997325fa..1a90028176 100644
--- a/spec/ruby/core/method/call_spec.rb
+++ b/spec/ruby/core/method/call_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/call'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/call', __FILE__)
describe "Method#call" do
- it_behaves_like :method_call, :call
+ it_behaves_like(:method_call, :call)
end
diff --git a/spec/ruby/core/method/case_compare_spec.rb b/spec/ruby/core/method/case_compare_spec.rb
deleted file mode 100644
index 17785b5c1d..0000000000
--- a/spec/ruby/core/method/case_compare_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/call'
-
-ruby_version_is "2.5" do
- describe "Method#===" do
- it_behaves_like :method_call, :===
- end
-end
diff --git a/spec/ruby/core/method/clone_spec.rb b/spec/ruby/core/method/clone_spec.rb
index 3fe4000fb7..e3b40254f8 100644
--- a/spec/ruby/core/method/clone_spec.rb
+++ b/spec/ruby/core/method/clone_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#clone" do
it "returns a copy of the method" do
diff --git a/spec/ruby/core/method/compose_spec.rb b/spec/ruby/core/method/compose_spec.rb
deleted file mode 100644
index aa0aded775..0000000000
--- a/spec/ruby/core/method/compose_spec.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../proc/shared/compose'
-
-ruby_version_is "2.6" do
- describe "Method#<<" do
- it "returns a Proc that is the composition of self and the passed Proc" do
- succ = MethodSpecs::Composition.new.method(:succ)
- upcase = proc { |s| s.upcase }
-
- (succ << upcase).call('Ruby').should == "RUBZ"
- end
-
- it "calls passed Proc with arguments and then calls self with result" do
- pow_2_proc = proc { |x| x * x }
- double_proc = proc { |x| x + x }
-
- pow_2_method = MethodSpecs::Composition.new.method(:pow_2)
- double_method = MethodSpecs::Composition.new.method(:double)
-
- (pow_2_method << double_proc).call(2).should == 16
- (double_method << pow_2_proc).call(2).should == 8
- end
-
- it "accepts any callable object" do
- inc = MethodSpecs::Composition.new.method(:inc)
-
- double = Object.new
- def double.call(n); n * 2; end
-
- (inc << double).call(3).should == 7
- end
-
- it_behaves_like :proc_compose, :<<, -> { MethodSpecs::Composition.new.method(:upcase) }
-
- describe "composition" do
- it "is a lambda" do
- pow_2 = MethodSpecs::Composition.new.method(:pow_2)
- double = proc { |x| x + x }
-
- (pow_2 << double).is_a?(Proc).should == true
- (pow_2 << double).lambda?.should == true
- end
-
- it "may accept multiple arguments" do
- inc = MethodSpecs::Composition.new.method(:inc)
- mul = proc { |n, m| n * m }
-
- (inc << mul).call(2, 3).should == 7
- end
- end
- end
-
- describe "Method#>>" do
- it "returns a Proc that is the composition of self and the passed Proc" do
- upcase = proc { |s| s.upcase }
- succ = MethodSpecs::Composition.new.method(:succ)
-
- (succ >> upcase).call('Ruby').should == "RUBZ"
- end
-
- it "calls passed Proc with arguments and then calls self with result" do
- pow_2_proc = proc { |x| x * x }
- double_proc = proc { |x| x + x }
-
- pow_2_method = MethodSpecs::Composition.new.method(:pow_2)
- double_method = MethodSpecs::Composition.new.method(:double)
-
- (pow_2_method >> double_proc).call(2).should == 8
- (double_method >> pow_2_proc).call(2).should == 16
- end
-
- it "accepts any callable object" do
- inc = MethodSpecs::Composition.new.method(:inc)
-
- double = Object.new
- def double.call(n); n * 2; end
-
- (inc >> double).call(3).should == 8
- end
-
- it_behaves_like :proc_compose, :>>, -> { MethodSpecs::Composition.new.method(:upcase) }
-
- describe "composition" do
- it "is a lambda" do
- pow_2 = MethodSpecs::Composition.new.method(:pow_2)
- double = proc { |x| x + x }
-
- (pow_2 >> double).is_a?(Proc).should == true
- (pow_2 >> double).lambda?.should == true
- end
-
- it "may accept multiple arguments" do
- mul = MethodSpecs::Composition.new.method(:mul)
- inc = proc { |n| n + 1 }
-
- (mul >> inc).call(2, 3).should == 7
- end
- end
- end
-end
diff --git a/spec/ruby/core/method/curry_spec.rb b/spec/ruby/core/method/curry_spec.rb
index 219de0f6b5..977f7766d0 100644
--- a/spec/ruby/core/method/curry_spec.rb
+++ b/spec/ruby/core/method/curry_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#curry" do
it "returns a curried proc" do
@@ -23,14 +23,14 @@ describe "Method#curry" do
end
it "raises ArgumentError when the method requires less arguments than the given arity" do
- -> { @obj.method(:zero).curry(1) }.should raise_error(ArgumentError)
- -> { @obj.method(:one_req_one_opt).curry(3) }.should raise_error(ArgumentError)
- -> { @obj.method(:two_req_one_opt_with_block).curry(4) }.should raise_error(ArgumentError)
+ lambda { @obj.method(:zero).curry(1) }.should raise_error(ArgumentError)
+ lambda { @obj.method(:one_req_one_opt).curry(3) }.should raise_error(ArgumentError)
+ lambda { @obj.method(:two_req_one_opt_with_block).curry(4) }.should raise_error(ArgumentError)
end
it "raises ArgumentError when the method requires more arguments than the given arity" do
- -> { @obj.method(:two_req_with_splat).curry(1) }.should raise_error(ArgumentError)
- -> { @obj.method(:one_req).curry(0) }.should raise_error(ArgumentError)
+ lambda { @obj.method(:two_req_with_splat).curry(1) }.should raise_error(ArgumentError)
+ lambda { @obj.method(:one_req).curry(0) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/method/element_reference_spec.rb b/spec/ruby/core/method/element_reference_spec.rb
index aa6c54d1cb..0be47afede 100644
--- a/spec/ruby/core/method/element_reference_spec.rb
+++ b/spec/ruby/core/method/element_reference_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/call'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/call', __FILE__)
describe "Method#[]" do
- it_behaves_like :method_call, :[]
+ it_behaves_like(:method_call, :[])
end
diff --git a/spec/ruby/core/method/eql_spec.rb b/spec/ruby/core/method/eql_spec.rb
index b97c9e4db0..f8914e1d12 100644
--- a/spec/ruby/core/method/eql_spec.rb
+++ b/spec/ruby/core/method/eql_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "Method#eql?" do
- it_behaves_like :method_equal, :eql?
+ it_behaves_like(:method_equal, :eql?)
end
diff --git a/spec/ruby/core/method/equal_value_spec.rb b/spec/ruby/core/method/equal_value_spec.rb
index 0431d0c5f6..365e0ac424 100644
--- a/spec/ruby/core/method/equal_value_spec.rb
+++ b/spec/ruby/core/method/equal_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "Method#==" do
- it_behaves_like :method_equal, :==
+ it_behaves_like(:method_equal, :==)
end
diff --git a/spec/ruby/core/method/fixtures/classes.rb b/spec/ruby/core/method/fixtures/classes.rb
index f3b7ff921c..142cbd1bec 100644
--- a/spec/ruby/core/method/fixtures/classes.rb
+++ b/spec/ruby/core/method/fixtures/classes.rb
@@ -26,7 +26,6 @@ module MethodSpecs
end
alias bar foo
- alias baz bar
def same_as_foo
true
@@ -182,29 +181,4 @@ module MethodSpecs
end
end
- class Composition
- def upcase(s)
- s.upcase
- end
-
- def succ(s)
- s.succ
- end
-
- def pow_2(n)
- n * n
- end
-
- def double(n)
- n + n
- end
-
- def inc(n)
- n + 1
- end
-
- def mul(n, m)
- n * m
- end
- end
end
diff --git a/spec/ruby/core/method/hash_spec.rb b/spec/ruby/core/method/hash_spec.rb
index d6c8440acc..67bc4c16ac 100644
--- a/spec/ruby/core/method/hash_spec.rb
+++ b/spec/ruby/core/method/hash_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#hash" do
+ it "needs to be reviewed for spec completeness"
+
it "returns the same value for user methods that are eql?" do
obj = MethodSpecs::Methods.new
obj.method(:foo).hash.should == obj.method(:bar).hash
diff --git a/spec/ruby/core/method/inspect_spec.rb b/spec/ruby/core/method/inspect_spec.rb
index e0fe1afdd0..bfb61daf53 100644
--- a/spec/ruby/core/method/inspect_spec.rb
+++ b/spec/ruby/core/method/inspect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "Method#inspect" do
- it_behaves_like :method_to_s, :inspect
+ it_behaves_like(:method_to_s, :inspect)
end
diff --git a/spec/ruby/core/method/name_spec.rb b/spec/ruby/core/method/name_spec.rb
index de390c6f52..ebc5f856d1 100644
--- a/spec/ruby/core/method/name_spec.rb
+++ b/spec/ruby/core/method/name_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#name" do
it "returns the name of the method" do
diff --git a/spec/ruby/core/method/original_name_spec.rb b/spec/ruby/core/method/original_name_spec.rb
deleted file mode 100644
index 676fdaedb4..0000000000
--- a/spec/ruby/core/method/original_name_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Method#original_name" do
- it "returns the name of the method" do
- "abc".method(:upcase).original_name.should == :upcase
- end
-
- it "returns the original name when aliased" do
- obj = MethodSpecs::Methods.new
- obj.method(:foo).original_name.should == :foo
- obj.method(:bar).original_name.should == :foo
- obj.method(:bar).unbind.bind(obj).original_name.should == :foo
- end
-
- it "returns the original name even when aliased twice" do
- obj = MethodSpecs::Methods.new
- obj.method(:foo).original_name.should == :foo
- obj.method(:baz).original_name.should == :foo
- obj.method(:baz).unbind.bind(obj).original_name.should == :foo
- end
-end
diff --git a/spec/ruby/core/method/owner_spec.rb b/spec/ruby/core/method/owner_spec.rb
index ca5dff7295..3378b7bd1f 100644
--- a/spec/ruby/core/method/owner_spec.rb
+++ b/spec/ruby/core/method/owner_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#owner" do
it "returns the owner of the method" do
diff --git a/spec/ruby/core/method/parameters_spec.rb b/spec/ruby/core/method/parameters_spec.rb
index 3fdaf9ce6f..8808bf40b4 100644
--- a/spec/ruby/core/method/parameters_spec.rb
+++ b/spec/ruby/core/method/parameters_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#parameters" do
class MethodSpecs::Methods
@@ -12,7 +12,7 @@ describe "Method#parameters" do
def one_splat_two_req(*a,b,c); end
def one_splat_one_req_with_block(*a,b,&blk); end
- def one_opt_with_stabby(a=-> b { true }); end
+ def one_opt_with_stabby(a=->(b){true}); end
def one_unnamed_splat(*); end
@@ -241,21 +241,4 @@ describe "Method#parameters" do
m = MethodSpecs::Methods.new
m.method(:writer=).parameters.should == [[:req]]
end
-
- it "returns [[:rest]] for core methods with variable-length argument lists" do
- # delete! takes rest args
- "foo".method(:delete!).parameters.should == [[:rest]]
- end
-
- it "returns [[:rest]] or [[:opt]] for core methods with optional arguments" do
- # pop takes 1 optional argument
- [
- [[:rest]],
- [[:opt]]
- ].should include([].method(:pop).parameters)
- end
-
- it "returns [[:req]] for each parameter for core methods with fixed-length argument lists" do
- "foo".method(:+).parameters.should == [[:req]]
- end
end
diff --git a/spec/ruby/core/method/receiver_spec.rb b/spec/ruby/core/method/receiver_spec.rb
index 2b2e11dd2e..2c56ab2239 100644
--- a/spec/ruby/core/method/receiver_spec.rb
+++ b/spec/ruby/core/method/receiver_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#receiver" do
it "returns the receiver of the method" do
diff --git a/spec/ruby/core/method/shared/call.rb b/spec/ruby/core/method/shared/call.rb
index f26e373695..f178b9da7d 100644
--- a/spec/ruby/core/method/shared/call.rb
+++ b/spec/ruby/core/method/shared/call.rb
@@ -9,10 +9,10 @@ describe :method_call, shared: true do
end
it "raises an ArgumentError when given incorrect number of arguments" do
- -> {
+ lambda {
MethodSpecs::Methods.new.method(:two_req).send(@method, 1, 2, 3)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
MethodSpecs::Methods.new.method(:two_req).send(@method, 1)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/method/shared/eql.rb b/spec/ruby/core/method/shared/eql.rb
index 5c720cbac1..8cff45760b 100644
--- a/spec/ruby/core/method/shared/eql.rb
+++ b/spec/ruby/core/method/shared/eql.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :method_equal, shared: true do
before :each do
diff --git a/spec/ruby/core/method/shared/to_s.rb b/spec/ruby/core/method/shared/to_s.rb
index 373398a785..239974c8e3 100644
--- a/spec/ruby/core/method/shared/to_s.rb
+++ b/spec/ruby/core/method/shared/to_s.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require "#{File.dirname __FILE__}/../../../spec_helper"
+require "#{File.dirname __FILE__}/../fixtures/classes"
describe :method_to_s, shared: true do
before :each do
diff --git a/spec/ruby/core/method/source_location_spec.rb b/spec/ruby/core/method/source_location_spec.rb
index dd81b02c77..2ba2fdf5e9 100644
--- a/spec/ruby/core/method/source_location_spec.rb
+++ b/spec/ruby/core/method/source_location_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#source_location" do
before :each do
@@ -13,7 +13,7 @@ describe "Method#source_location" do
it "sets the first value to the path of the file in which the method was defined" do
file = @method.source_location.first
file.should be_an_instance_of(String)
- file.should == File.realpath('../fixtures/classes.rb', __FILE__)
+ file.should == File.dirname(__FILE__) + '/fixtures/classes.rb'
end
it "sets the last value to a Fixnum representing the line on which the method was defined" do
diff --git a/spec/ruby/core/method/super_method_spec.rb b/spec/ruby/core/method/super_method_spec.rb
index e5d8b87a06..cbc595b572 100644
--- a/spec/ruby/core/method/super_method_spec.rb
+++ b/spec/ruby/core/method/super_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#super_method" do
it "returns the method that would be called by super in the method" do
diff --git a/spec/ruby/core/method/to_proc_spec.rb b/spec/ruby/core/method/to_proc_spec.rb
index 29b7bec2b3..5a754f8597 100644
--- a/spec/ruby/core/method/to_proc_spec.rb
+++ b/spec/ruby/core/method/to_proc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#to_proc" do
before :each do
@@ -55,10 +55,6 @@ describe "Method#to_proc" do
x.baz(1,2,3,&m).should == [1,2,3]
end
- it "returns a proc whose binding has the same receiver as the method" do
- @meth.receiver.should == @meth.to_proc.binding.receiver
- end
-
# #5926
it "returns a proc that can receive a block" do
x = Object.new
@@ -90,15 +86,4 @@ describe "Method#to_proc" do
array.each(&obj)
ScratchPad.recorded.should == [[1, 2]]
end
-
- it "returns a proc that properly invokes module methods with super" do
- m1 = Module.new { def foo(ary); ary << :m1; end; }
- m2 = Module.new { def foo(ary = []); super(ary); ary << :m2; end; }
- c2 = Class.new do
- include m1
- include m2
- end
-
- c2.new.method(:foo).to_proc.call.should == %i[m1 m2]
- end
end
diff --git a/spec/ruby/core/method/to_s_spec.rb b/spec/ruby/core/method/to_s_spec.rb
index 9f19011302..1bf341f2a6 100644
--- a/spec/ruby/core/method/to_s_spec.rb
+++ b/spec/ruby/core/method/to_s_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "Method#to_s" do
- it_behaves_like :method_to_s, :to_s
+ it_behaves_like(:method_to_s, :to_s)
end
diff --git a/spec/ruby/core/method/unbind_spec.rb b/spec/ruby/core/method/unbind_spec.rb
index 3d36c6d675..cb0dc65a75 100644
--- a/spec/ruby/core/method/unbind_spec.rb
+++ b/spec/ruby/core/method/unbind_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Method#unbind" do
before :each do
diff --git a/spec/ruby/core/module/alias_method_spec.rb b/spec/ruby/core/module/alias_method_spec.rb
index 662e91011f..d3c0529418 100644
--- a/spec/ruby/core/module/alias_method_spec.rb
+++ b/spec/ruby/core/module/alias_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#alias_method" do
before :each do
@@ -14,7 +14,7 @@ describe "Module#alias_method" do
@object.double(12).should == @object.public_two(12)
end
- it "creates methods that are == to each other" do
+ it "creates methods that are == to eachother" do
@class.make_alias :uno, :public_one
@object.method(:uno).should == @object.method(:public_one)
end
@@ -28,12 +28,12 @@ describe "Module#alias_method" do
it "retains method visibility" do
@class.make_alias :private_ichi, :private_one
- -> { @object.private_one }.should raise_error(NameError)
- -> { @object.private_ichi }.should raise_error(NameError)
+ lambda { @object.private_one }.should raise_error(NameError)
+ lambda { @object.private_ichi }.should raise_error(NameError)
@class.make_alias :public_ichi, :public_one
@object.public_ichi.should == @object.public_one
@class.make_alias :protected_ichi, :protected_one
- -> { @object.protected_ichi }.should raise_error(NameError)
+ lambda { @object.protected_ichi }.should raise_error(NameError)
end
it "handles aliasing a stub that changes visibility" do
@@ -43,15 +43,15 @@ describe "Module#alias_method" do
end
it "fails if origin method not found" do
- -> { @class.make_alias :ni, :san }.should raise_error(NameError) { |e|
+ lambda { @class.make_alias :ni, :san }.should raise_error(NameError) { |e|
# a NameError and not a NoMethodError
e.class.should == NameError
}
end
- it "raises #{frozen_error_class} if frozen" do
+ it "raises RuntimeError if frozen" do
@class.freeze
- -> { @class.make_alias :uno, :public_one }.should raise_error(frozen_error_class)
+ lambda { @class.make_alias :uno, :public_one }.should raise_error(RuntimeError)
end
it "converts the names using #to_str" do
@@ -66,12 +66,12 @@ describe "Module#alias_method" do
end
it "raises a TypeError when the given name can't be converted using to_str" do
- -> { @class.make_alias mock('x'), :public_one }.should raise_error(TypeError)
+ lambda { @class.make_alias mock('x'), :public_one }.should raise_error(TypeError)
end
ruby_version_is ''...'2.5' do
it "is a private method" do
- -> { @class.alias_method :ichi, :public_one }.should raise_error(NoMethodError)
+ lambda { @class.alias_method :ichi, :public_one }.should raise_error(NoMethodError)
end
end
ruby_version_is '2.5' do
@@ -90,7 +90,7 @@ describe "Module#alias_method" do
it "works on private module methods in a module that has been reopened" do
ModuleSpecs::ReopeningModule.foo.should == true
- -> { ModuleSpecs::ReopeningModule.foo2 }.should_not raise_error(NoMethodError)
+ lambda { ModuleSpecs::ReopeningModule.foo2 }.should_not raise_error(NoMethodError)
end
it "accesses a method defined on Object from Kernel" do
diff --git a/spec/ruby/core/module/allocate_spec.rb b/spec/ruby/core/module/allocate_spec.rb
index 3b2c4119c3..306426881a 100644
--- a/spec/ruby/core/module/allocate_spec.rb
+++ b/spec/ruby/core/module/allocate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module.allocate" do
it "returns an instance of Module" do
diff --git a/spec/ruby/core/module/ancestors_spec.rb b/spec/ruby/core/module/ancestors_spec.rb
index 5e4c196206..1cd537f7a0 100644
--- a/spec/ruby/core/module/ancestors_spec.rb
+++ b/spec/ruby/core/module/ancestors_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#ancestors" do
it "returns a list of modules included in self (including self)" do
diff --git a/spec/ruby/core/module/append_features_spec.rb b/spec/ruby/core/module/append_features_spec.rb
index 8fb3febc04..ceb8c3f8eb 100644
--- a/spec/ruby/core/module/append_features_spec.rb
+++ b/spec/ruby/core/module/append_features_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#append_features" do
it "is a private method" do
@@ -12,7 +12,7 @@ describe "Module#append_features" do
end
it "raises a TypeError if calling after rebinded to Class" do
- -> {
+ lambda {
Module.instance_method(:append_features).bind(Class.new).call Module.new
}.should raise_error(TypeError)
end
@@ -37,28 +37,26 @@ describe "Module#append_features" do
end
it "raises an ArgumentError on a cyclic include" do
- -> {
+ lambda {
ModuleSpecs::CyclicAppendA.send(:append_features, ModuleSpecs::CyclicAppendA)
}.should raise_error(ArgumentError)
- -> {
+ lambda {
ModuleSpecs::CyclicAppendB.send(:append_features, ModuleSpecs::CyclicAppendA)
}.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "copies own tainted status to the given module" do
- other = Module.new
- Module.new.taint.send :append_features, other
- other.tainted?.should be_true
- end
+ it "copies own tainted status to the given module" do
+ other = Module.new
+ Module.new.taint.send :append_features, other
+ other.tainted?.should be_true
+ end
- it "copies own untrusted status to the given module" do
- other = Module.new
- Module.new.untrust.send :append_features, other
- other.untrusted?.should be_true
- end
+ it "copies own untrusted status to the given module" do
+ other = Module.new
+ Module.new.untrust.send :append_features, other
+ other.untrusted?.should be_true
end
describe "when other is frozen" do
@@ -67,8 +65,8 @@ describe "Module#append_features" do
@other = Module.new.freeze
end
- it "raises a #{frozen_error_class} before appending self" do
- -> { @receiver.send(:append_features, @other) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError before appending self" do
+ lambda { @receiver.send(:append_features, @other) }.should raise_error(RuntimeError)
@other.ancestors.should_not include(@receiver)
end
end
diff --git a/spec/ruby/core/module/attr_accessor_spec.rb b/spec/ruby/core/module/attr_accessor_spec.rb
index ce95ccd487..c6f7aad6af 100644
--- a/spec/ruby/core/module/attr_accessor_spec.rb
+++ b/spec/ruby/core/module/attr_accessor_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#attr_accessor" do
it "creates a getter and setter for each given attribute name" do
@@ -33,7 +33,7 @@ describe "Module#attr_accessor" do
attr_accessor :spec_attr_accessor
end
- -> { true.spec_attr_accessor = "a" }.should raise_error(RuntimeError)
+ lambda { true.spec_attr_accessor = "a" }.should raise_error(RuntimeError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -48,9 +48,9 @@ describe "Module#attr_accessor" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('o')
- -> { Class.new { attr_accessor o } }.should raise_error(TypeError)
+ lambda { Class.new { attr_accessor o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- -> { Class.new { attr_accessor o } }.should raise_error(TypeError)
+ lambda { Class.new { attr_accessor o } }.should raise_error(TypeError)
end
it "applies current visibility to methods created" do
@@ -59,8 +59,8 @@ describe "Module#attr_accessor" do
attr_accessor :foo
end
- -> { c.new.foo }.should raise_error(NoMethodError)
- -> { c.new.foo=1 }.should raise_error(NoMethodError)
+ lambda { c.new.foo }.should raise_error(NoMethodError)
+ lambda { c.new.foo=1 }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
diff --git a/spec/ruby/core/module/attr_reader_spec.rb b/spec/ruby/core/module/attr_reader_spec.rb
index 082bc03b60..65cafdba9f 100644
--- a/spec/ruby/core/module/attr_reader_spec.rb
+++ b/spec/ruby/core/module/attr_reader_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#attr_reader" do
it "creates a getter for each given attribute name" do
@@ -29,7 +29,7 @@ describe "Module#attr_reader" do
attr_reader :spec_attr_reader
end
- -> { true.instance_variable_set("@spec_attr_reader", "a") }.should raise_error(RuntimeError)
+ lambda { true.instance_variable_set("@spec_attr_reader", "a") }.should raise_error(RuntimeError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -44,9 +44,9 @@ describe "Module#attr_reader" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('o')
- -> { Class.new { attr_reader o } }.should raise_error(TypeError)
+ lambda { Class.new { attr_reader o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- -> { Class.new { attr_reader o } }.should raise_error(TypeError)
+ lambda { Class.new { attr_reader o } }.should raise_error(TypeError)
end
it "applies current visibility to methods created" do
@@ -55,7 +55,7 @@ describe "Module#attr_reader" do
attr_reader :foo
end
- -> { c.new.foo }.should raise_error(NoMethodError)
+ lambda { c.new.foo }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
diff --git a/spec/ruby/core/module/attr_spec.rb b/spec/ruby/core/module/attr_spec.rb
index 20316a3d39..7128c610fe 100644
--- a/spec/ruby/core/module/attr_spec.rb
+++ b/spec/ruby/core/module/attr_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#attr" do
before :each do
@@ -54,7 +54,7 @@ describe "Module#attr" do
o.attr3 = "test3 updated"
end
- it "creates a getter and setter for the given attribute name if called with and without writable is true" do
+ it "creates a getter and setter for the given attribute name if called with and without writeable is true" do
c = Class.new do
attr :attr, true
attr :attr
@@ -89,8 +89,8 @@ describe "Module#attr" do
attr :foo, true
end
- -> { c.new.foo }.should raise_error(NoMethodError)
- -> { c.new.foo=1 }.should raise_error(NoMethodError)
+ lambda { c.new.foo }.should raise_error(NoMethodError)
+ lambda { c.new.foo=1 }.should raise_error(NoMethodError)
end
it "creates a getter but no setter for all given attribute names" do
@@ -120,8 +120,8 @@ describe "Module#attr" do
attr :foo, :bar
end
- -> { c.new.foo }.should raise_error(NoMethodError)
- -> { c.new.bar }.should raise_error(NoMethodError)
+ lambda { c.new.foo }.should raise_error(NoMethodError)
+ lambda { c.new.bar }.should raise_error(NoMethodError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -131,15 +131,16 @@ describe "Module#attr" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('o')
- -> { Class.new { attr o } }.should raise_error(TypeError)
+ lambda { Class.new { attr o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- -> { Class.new { attr o } }.should raise_error(TypeError)
+ lambda { Class.new { attr o } }.should raise_error(TypeError)
end
it "with a boolean argument emits a warning when $VERBOSE is true" do
- -> {
+ lambda {
+ $VERBOSE = true
Class.new { attr :foo, true }
- }.should complain(/boolean argument is obsoleted/, verbose: true)
+ }.should complain(/boolean argument is obsoleted/)
end
ruby_version_is ''...'2.5' do
diff --git a/spec/ruby/core/module/attr_writer_spec.rb b/spec/ruby/core/module/attr_writer_spec.rb
index 3b110cecf7..5979e3891b 100644
--- a/spec/ruby/core/module/attr_writer_spec.rb
+++ b/spec/ruby/core/module/attr_writer_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#attr_writer" do
it "creates a setter for each given attribute name" do
@@ -29,7 +29,7 @@ describe "Module#attr_writer" do
attr_writer :spec_attr_writer
end
- -> { true.spec_attr_writer = "a" }.should raise_error(RuntimeError)
+ lambda { true.spec_attr_writer = "a" }.should raise_error(RuntimeError)
end
it "converts non string/symbol/fixnum names to strings using to_str" do
@@ -44,9 +44,9 @@ describe "Module#attr_writer" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
o = mock('test1')
- -> { Class.new { attr_writer o } }.should raise_error(TypeError)
+ lambda { Class.new { attr_writer o } }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- -> { Class.new { attr_writer o } }.should raise_error(TypeError)
+ lambda { Class.new { attr_writer o } }.should raise_error(TypeError)
end
it "applies current visibility to methods created" do
@@ -55,7 +55,7 @@ describe "Module#attr_writer" do
attr_writer :foo
end
- -> { c.new.foo=1 }.should raise_error(NoMethodError)
+ lambda { c.new.foo=1 }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb
index 9964602347..a72ae7735b 100644
--- a/spec/ruby/core/module/autoload_spec.rb
+++ b/spec/ruby/core/module/autoload_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'thread'
describe "Module#autoload?" do
@@ -11,50 +11,22 @@ describe "Module#autoload?" do
it "returns nil if no file has been registered for a constant" do
ModuleSpecs::Autoload.autoload?(:Manualload).should be_nil
end
-
- it "returns the name of the file that will be autoloaded if an ancestor defined that autoload" do
- ModuleSpecs::Autoload::Parent.autoload :AnotherAutoload, "another_autoload.rb"
- ModuleSpecs::Autoload::Child.autoload?(:AnotherAutoload).should == "another_autoload.rb"
- end
-
- ruby_version_is "2.7" do
- it "returns nil if an ancestor defined that autoload but recursion is disabled" do
- ModuleSpecs::Autoload::Parent.autoload :InheritedAutoload, "inherited_autoload.rb"
- ModuleSpecs::Autoload::Child.autoload?(:InheritedAutoload, false).should be_nil
- end
-
- it "returns the name of the file that will be loaded if recursion is disabled but the autoload is defined on the class itself" do
- ModuleSpecs::Autoload::Child.autoload :ChildAutoload, "child_autoload.rb"
- ModuleSpecs::Autoload::Child.autoload?(:ChildAutoload, false).should == "child_autoload.rb"
- end
- end
end
describe "Module#autoload" do
before :all do
@non_existent = fixture __FILE__, "no_autoload.rb"
-
- # Require RubyGems eagerly, to ensure #require is already the RubyGems
- # version, before starting #autoload specs which snapshot #require, and
- # could end up redefining #require as the original core Kernel#require.
- begin
- require "rubygems"
- rescue LoadError
- end
end
before :each do
@loaded_features = $".dup
+ @frozen_module = Module.new.freeze
ScratchPad.clear
- @remove = []
end
after :each do
$".replace @loaded_features
- @remove.each { |const|
- ModuleSpecs::Autoload.send :remove_const, const
- }
end
it "registers a file to load the first time the named constant is accessed" do
@@ -67,29 +39,16 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.should have_constant(:B)
end
- it "can be overridden with a second autoload on the same constant" do
- ModuleSpecs::Autoload.autoload :Overridden, @non_existent
- @remove << :Overridden
- ModuleSpecs::Autoload.autoload?(:Overridden).should == @non_existent
-
- path = fixture(__FILE__, "autoload_overridden.rb")
- ModuleSpecs::Autoload.autoload :Overridden, path
- ModuleSpecs::Autoload.autoload?(:Overridden).should == path
-
- ModuleSpecs::Autoload::Overridden.should == :overridden
- end
-
it "loads the registered constant when it is accessed" do
ModuleSpecs::Autoload.should_not have_constant(:X)
ModuleSpecs::Autoload.autoload :X, fixture(__FILE__, "autoload_x.rb")
- @remove << :X
ModuleSpecs::Autoload::X.should == :x
+ ModuleSpecs::Autoload.send(:remove_const, :X)
end
it "loads the registered constant into a dynamically created class" do
cls = Class.new { autoload :C, fixture(__FILE__, "autoload_c.rb") }
ModuleSpecs::Autoload::DynClass = cls
- @remove << :DynClass
ScratchPad.recorded.should be_nil
ModuleSpecs::Autoload::DynClass::C.new.loaded.should == :dynclass_c
@@ -99,7 +58,6 @@ describe "Module#autoload" do
it "loads the registered constant into a dynamically created module" do
mod = Module.new { autoload :D, fixture(__FILE__, "autoload_d.rb") }
ModuleSpecs::Autoload::DynModule = mod
- @remove << :DynModule
ScratchPad.recorded.should be_nil
ModuleSpecs::Autoload::DynModule::D.new.loaded.should == :dynmodule_d
@@ -137,7 +95,6 @@ describe "Module#autoload" do
it "does not load the file when the constant is already set" do
ModuleSpecs::Autoload.autoload :I, fixture(__FILE__, "autoload_i.rb")
- @remove << :I
ModuleSpecs::Autoload.const_set :I, 3
ModuleSpecs::Autoload::I.should == 3
ScratchPad.recorded.should be_nil
@@ -148,18 +105,9 @@ describe "Module#autoload" do
ModuleSpecs::Autoload::J.should == :autoload_j
end
- it "calls main.require(path) to load the file" do
- ModuleSpecs::Autoload.autoload :ModuleAutoloadCallsRequire, "module_autoload_not_exist.rb"
- main = TOPLEVEL_BINDING.eval("self")
- main.should_receive(:require).with("module_autoload_not_exist.rb")
- # The constant won't be defined since require is mocked to do nothing
- -> { ModuleSpecs::Autoload::ModuleAutoloadCallsRequire }.should raise_error(NameError)
- end
-
it "does not load the file if the file is manually required" do
filename = fixture(__FILE__, "autoload_k.rb")
ModuleSpecs::Autoload.autoload :KHash, filename
- @remove << :KHash
require filename
ScratchPad.recorded.should == :loaded
@@ -179,8 +127,8 @@ describe "Module#autoload" do
ScratchPad.clear
ModuleSpecs::Autoload.autoload :S, filename
- @remove << :S
ModuleSpecs::Autoload.autoload?(:S).should be_nil
+ ModuleSpecs::Autoload.send(:remove_const, :S)
end
it "retains the autoload even if the request to require fails" do
@@ -189,7 +137,7 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.autoload :NotThere, filename
ModuleSpecs::Autoload.autoload?(:NotThere).should == filename
- -> {
+ lambda {
require filename
}.should raise_error(LoadError)
@@ -210,241 +158,28 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.use_ex1.should == :good
end
- describe "interacting with defined?" do
- it "does not load the file when referring to the constant in defined?" do
- module ModuleSpecs::Autoload::Dog
- autoload :R, fixture(__FILE__, "autoload_exception.rb")
- end
-
- defined?(ModuleSpecs::Autoload::Dog::R).should == "constant"
- ScratchPad.recorded.should be_nil
-
- ModuleSpecs::Autoload::Dog.should have_constant(:R)
- end
-
- it "loads an autoloaded parent when referencing a nested constant" do
- module ModuleSpecs::Autoload
- autoload :GoodParent, fixture(__FILE__, "autoload_nested.rb")
- end
- @remove << :GoodParent
-
- defined?(ModuleSpecs::Autoload::GoodParent::Nested).should == 'constant'
- ScratchPad.recorded.should == :loaded
- end
-
- it "returns nil when it fails to load an autoloaded parent when referencing a nested constant" do
- module ModuleSpecs::Autoload
- autoload :BadParent, fixture(__FILE__, "autoload_exception.rb")
- end
-
- defined?(ModuleSpecs::Autoload::BadParent::Nested).should be_nil
- ScratchPad.recorded.should == :exception
- end
- end
-
- describe "the autoload is triggered when the same file is required directly" do
- before :each do
- module ModuleSpecs::Autoload
- autoload :RequiredDirectly, fixture(__FILE__, "autoload_required_directly.rb")
- end
- @remove << :RequiredDirectly
- @path = fixture(__FILE__, "autoload_required_directly.rb")
- @check = -> {
- [
- defined?(ModuleSpecs::Autoload::RequiredDirectly),
- ModuleSpecs::Autoload.autoload?(:RequiredDirectly)
- ]
- }
- ScratchPad.record @check
- end
-
- it "with a full path" do
- @check.call.should == ["constant", @path]
- require @path
- ScratchPad.recorded.should == [nil, nil]
- @check.call.should == ["constant", nil]
- end
-
- it "with a relative path" do
- @check.call.should == ["constant", @path]
- $:.push File.dirname(@path)
- begin
- require "autoload_required_directly.rb"
- ensure
- $:.pop
- end
- ScratchPad.recorded.should == [nil, nil]
- @check.call.should == ["constant", nil]
- end
-
- it "in a nested require" do
- nested = fixture(__FILE__, "autoload_required_directly_nested.rb")
- nested_require = -> {
- result = nil
- ScratchPad.record -> {
- result = @check.call
- }
- require nested
- result
- }
- ScratchPad.record nested_require
-
- @check.call.should == ["constant", @path]
- require @path
- ScratchPad.recorded.should == [nil, nil]
- @check.call.should == ["constant", nil]
- end
- end
-
- describe "after the autoload is triggered by require" do
- before :each do
- @path = tmp("autoload.rb")
- end
-
- after :each do
- rm_r @path
- end
-
- it "the mapping feature to autoload is removed, and a new autoload with the same path is considered" do
- ModuleSpecs::Autoload.autoload :RequireMapping1, @path
- touch(@path) { |f| f.puts "ModuleSpecs::Autoload::RequireMapping1 = 1" }
- ModuleSpecs::Autoload::RequireMapping1.should == 1
-
- $LOADED_FEATURES.delete(@path)
- ModuleSpecs::Autoload.autoload :RequireMapping2, @path[0...-3]
- @remove << :RequireMapping2
- touch(@path) { |f| f.puts "ModuleSpecs::Autoload::RequireMapping2 = 2" }
- ModuleSpecs::Autoload::RequireMapping2.should == 2
- end
- end
-
- describe "during the autoload before the constant is assigned" do
- before :each do
- @path = fixture(__FILE__, "autoload_during_autoload.rb")
- ModuleSpecs::Autoload.autoload :DuringAutoload, @path
- @remove << :DuringAutoload
- raise unless ModuleSpecs::Autoload.autoload?(:DuringAutoload) == @path
- end
-
- def check_before_during_thread_after(&check)
- before = check.call
- to_autoload_thread, from_autoload_thread = Queue.new, Queue.new
- ScratchPad.record -> {
- from_autoload_thread.push check.call
- to_autoload_thread.pop
- }
- t = Thread.new {
- in_loading_thread = from_autoload_thread.pop
- in_other_thread = check.call
- to_autoload_thread.push :done
- [in_loading_thread, in_other_thread]
- }
- in_loading_thread, in_other_thread = nil
- begin
- ModuleSpecs::Autoload::DuringAutoload
- ensure
- in_loading_thread, in_other_thread = t.value
- end
- after = check.call
- [before, in_loading_thread, in_other_thread, after]
- end
-
- it "returns nil in autoload thread and 'constant' otherwise for defined?" do
- results = check_before_during_thread_after {
- defined?(ModuleSpecs::Autoload::DuringAutoload)
- }
- results.should == ['constant', nil, 'constant', 'constant']
- end
-
- it "keeps the constant in Module#constants" do
- results = check_before_during_thread_after {
- ModuleSpecs::Autoload.constants(false).include?(:DuringAutoload)
- }
- results.should == [true, true, true, true]
- end
-
- it "returns false in autoload thread and true otherwise for Module#const_defined?" do
- results = check_before_during_thread_after {
- ModuleSpecs::Autoload.const_defined?(:DuringAutoload, false)
- }
- results.should == [true, false, true, true]
- end
-
- it "returns nil in autoload thread and returns the path in other threads for Module#autoload?" do
- results = check_before_during_thread_after {
- ModuleSpecs::Autoload.autoload?(:DuringAutoload)
- }
- results.should == [@path, nil, @path, nil]
+ it "does not load the file when referring to the constant in defined?" do
+ module ModuleSpecs::Autoload::Q
+ autoload :R, fixture(__FILE__, "autoload.rb")
+ defined?(R).should == "constant"
end
+ ModuleSpecs::Autoload::Q.should have_constant(:R)
end
- it "does not remove the constant from Module#constants if load fails and keeps it as an autoload" do
+ it "does not remove the constant from the constant table if load fails" do
ModuleSpecs::Autoload.autoload :Fail, @non_existent
-
- ModuleSpecs::Autoload.const_defined?(:Fail).should == true
ModuleSpecs::Autoload.should have_constant(:Fail)
- ModuleSpecs::Autoload.autoload?(:Fail).should == @non_existent
-
- -> { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
+ lambda { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
ModuleSpecs::Autoload.should have_constant(:Fail)
- ModuleSpecs::Autoload.const_defined?(:Fail).should == true
- ModuleSpecs::Autoload.autoload?(:Fail).should == @non_existent
-
- -> { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
- end
-
- it "does not remove the constant from Module#constants if load raises a RuntimeError and keeps it as an autoload" do
- path = fixture(__FILE__, "autoload_raise.rb")
- ScratchPad.record []
- ModuleSpecs::Autoload.autoload :Raise, path
-
- ModuleSpecs::Autoload.const_defined?(:Raise).should == true
- ModuleSpecs::Autoload.should have_constant(:Raise)
- ModuleSpecs::Autoload.autoload?(:Raise).should == path
-
- -> { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError)
- ScratchPad.recorded.should == [:raise]
-
- ModuleSpecs::Autoload.should have_constant(:Raise)
- ModuleSpecs::Autoload.const_defined?(:Raise).should == true
- ModuleSpecs::Autoload.autoload?(:Raise).should == path
-
- -> { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError)
- ScratchPad.recorded.should == [:raise, :raise]
end
- it "does not remove the constant from Module#constants if the loaded file does not define it, but leaves it as 'undefined'" do
- path = fixture(__FILE__, "autoload_o.rb")
- ScratchPad.record []
- ModuleSpecs::Autoload.autoload :O, path
-
- ModuleSpecs::Autoload.const_defined?(:O).should == true
+ it "does not remove the constant from the constant table if the loaded files does not define it" do
+ ModuleSpecs::Autoload.autoload :O, fixture(__FILE__, "autoload_o.rb")
ModuleSpecs::Autoload.should have_constant(:O)
- ModuleSpecs::Autoload.autoload?(:O).should == path
-
- -> { ModuleSpecs::Autoload::O }.should raise_error(NameError)
+ lambda { ModuleSpecs::Autoload::O }.should raise_error(NameError)
ModuleSpecs::Autoload.should have_constant(:O)
- ModuleSpecs::Autoload.const_defined?(:O).should == false
- ModuleSpecs::Autoload.autoload?(:O).should == nil
- -> { ModuleSpecs::Autoload.const_get(:O) }.should raise_error(NameError)
- end
-
- it "does not try to load the file again if the loaded file did not define the constant" do
- path = fixture(__FILE__, "autoload_o.rb")
- ScratchPad.record []
- ModuleSpecs::Autoload.autoload :NotDefinedByFile, path
-
- -> { ModuleSpecs::Autoload::NotDefinedByFile }.should raise_error(NameError)
- ScratchPad.recorded.should == [:loaded]
- -> { ModuleSpecs::Autoload::NotDefinedByFile }.should raise_error(NameError)
- ScratchPad.recorded.should == [:loaded]
-
- Thread.new {
- -> { ModuleSpecs::Autoload::NotDefinedByFile }.should raise_error(NameError)
- }.join
- ScratchPad.recorded.should == [:loaded]
end
it "returns 'constant' on referring the constant with defined?()" do
@@ -466,9 +201,6 @@ describe "Module#autoload" do
it "does not load the file when accessing the constants table of the module" do
ModuleSpecs::Autoload.autoload :P, @non_existent
ModuleSpecs::Autoload.const_defined?(:P).should be_true
- ruby_bug "[Bug #15780]", ""..."2.7" do
- ModuleSpecs::Autoload.const_defined?("P").should be_true
- end
end
it "loads the file when opening a module that is the autoloaded constant" do
@@ -479,147 +211,43 @@ describe "Module#autoload" do
X = get_value
end
end
- @remove << :U
ModuleSpecs::Autoload::U::V::X.should == :autoload_uvx
end
- it "loads the file that defines subclass XX::CS_CONST_AUTOLOAD < CS_CONST_AUTOLOAD and CS_CONST_AUTOLOAD is a top level constant" do
+ it "loads the file that defines subclass XX::YY < YY and YY is a top level constant" do
+
module ModuleSpecs::Autoload::XX
- autoload :CS_CONST_AUTOLOAD, fixture(__FILE__, "autoload_subclass.rb")
+ autoload :YY, fixture(__FILE__, "autoload_subclass.rb")
end
- ModuleSpecs::Autoload::XX::CS_CONST_AUTOLOAD.superclass.should == CS_CONST_AUTOLOAD
+ ModuleSpecs::Autoload::XX::YY.superclass.should == YY
end
- describe "after autoloading searches for the constant like the original lookup" do
- it "in lexical scopes if both declared and defined in parent" do
- module ModuleSpecs::Autoload
- ScratchPad.record -> {
- DeclaredAndDefinedInParent = :declared_and_defined_in_parent
- }
- autoload :DeclaredAndDefinedInParent, fixture(__FILE__, "autoload_callback.rb")
- class LexicalScope
- DeclaredAndDefinedInParent.should == :declared_and_defined_in_parent
-
- # The constant is really in Autoload, not Autoload::LexicalScope
- self.should_not have_constant(:DeclaredAndDefinedInParent)
- -> { const_get(:DeclaredAndDefinedInParent) }.should raise_error(NameError)
- end
- DeclaredAndDefinedInParent.should == :declared_and_defined_in_parent
- end
- end
-
- it "in lexical scopes if declared in parent and defined in current" do
- module ModuleSpecs::Autoload
- ScratchPad.record -> {
- class LexicalScope
- DeclaredInParentDefinedInCurrent = :declared_in_parent_defined_in_current
- end
- }
- autoload :DeclaredInParentDefinedInCurrent, fixture(__FILE__, "autoload_callback.rb")
-
- class LexicalScope
- DeclaredInParentDefinedInCurrent.should == :declared_in_parent_defined_in_current
- LexicalScope::DeclaredInParentDefinedInCurrent.should == :declared_in_parent_defined_in_current
- end
-
- # Basically, the parent autoload constant remains in a "undefined" state
- self.autoload?(:DeclaredInParentDefinedInCurrent).should == nil
- const_defined?(:DeclaredInParentDefinedInCurrent).should == false
- self.should have_constant(:DeclaredInParentDefinedInCurrent)
- -> { DeclaredInParentDefinedInCurrent }.should raise_error(NameError)
-
- ModuleSpecs::Autoload::LexicalScope.send(:remove_const, :DeclaredInParentDefinedInCurrent)
- end
- end
-
- it "and fails when finding the undefined autoload constant in the current scope when declared in current and defined in parent" do
- @remove << :DeclaredInCurrentDefinedInParent
- module ModuleSpecs::Autoload
- ScratchPad.record -> {
- DeclaredInCurrentDefinedInParent = :declared_in_current_defined_in_parent
- }
-
- class LexicalScope
- autoload :DeclaredInCurrentDefinedInParent, fixture(__FILE__, "autoload_callback.rb")
- -> { DeclaredInCurrentDefinedInParent }.should raise_error(NameError)
- # Basically, the autoload constant remains in a "undefined" state
- self.autoload?(:DeclaredInCurrentDefinedInParent).should == nil
- const_defined?(:DeclaredInCurrentDefinedInParent).should == false
- self.should have_constant(:DeclaredInCurrentDefinedInParent)
- -> { const_get(:DeclaredInCurrentDefinedInParent) }.should raise_error(NameError)
- end
-
- DeclaredInCurrentDefinedInParent.should == :declared_in_current_defined_in_parent
- end
- end
-
- it "in the included modules" do
- @remove << :DefinedInIncludedModule
- module ModuleSpecs::Autoload
- ScratchPad.record -> {
- module DefinedInIncludedModule
- Incl = :defined_in_included_module
- end
- include DefinedInIncludedModule
- }
- autoload :Incl, fixture(__FILE__, "autoload_callback.rb")
- Incl.should == :defined_in_included_module
- end
- end
-
- it "in the included modules of the superclass" do
- @remove << :DefinedInSuperclassIncludedModule
- module ModuleSpecs::Autoload
- class LookupAfterAutoloadSuper
- end
- class LookupAfterAutoloadChild < LookupAfterAutoloadSuper
- end
-
- ScratchPad.record -> {
- module DefinedInSuperclassIncludedModule
- InclS = :defined_in_superclass_included_module
- end
- LookupAfterAutoloadSuper.include DefinedInSuperclassIncludedModule
- }
- class LookupAfterAutoloadChild
- autoload :InclS, fixture(__FILE__, "autoload_callback.rb")
- InclS.should == :defined_in_superclass_included_module
+ it "looks up the constant in the scope where it is referred" do
+ module ModuleSpecs
+ module Autoload
+ autoload :QQ, fixture(__FILE__, "autoload_scope.rb")
+ class PP
+ QQ.new.should be_kind_of(ModuleSpecs::Autoload::PP::QQ)
end
end
end
+ end
- it "in the prepended modules" do
- @remove << :DefinedInPrependedModule
- module ModuleSpecs::Autoload
- ScratchPad.record -> {
- module DefinedInPrependedModule
- Prep = :defined_in_prepended_module
- end
- include DefinedInPrependedModule
- }
- autoload :Prep, fixture(__FILE__, "autoload_callback.rb")
- Prep.should == :defined_in_prepended_module
- end
- end
-
- it "in a meta class scope" do
- module ModuleSpecs::Autoload
- ScratchPad.record -> {
- class MetaScope
- end
- }
- autoload :MetaScope, fixture(__FILE__, "autoload_callback.rb")
+ it "looks up the constant when in a meta class scope" do
+ module ModuleSpecs
+ module Autoload
+ autoload :R, fixture(__FILE__, "autoload_r.rb")
class << self
def r
- MetaScope.new
+ R.new
end
end
end
- ModuleSpecs::Autoload.r.should be_kind_of(ModuleSpecs::Autoload::MetaScope)
end
+ ModuleSpecs::Autoload.r.should be_kind_of(ModuleSpecs::Autoload::R)
end
# [ruby-core:19127] [ruby-core:29941]
@@ -632,45 +260,10 @@ describe "Module#autoload" do
end
end
end
- @remove << :W
ModuleSpecs::Autoload::W::Y.should be_kind_of(Class)
ScratchPad.recorded.should == :loaded
- end
-
- it "does not call #require a second time and does not warn if already loading the same feature with #require" do
- main = TOPLEVEL_BINDING.eval("self")
- main.should_not_receive(:require)
-
- module ModuleSpecs::Autoload
- autoload :AutoloadDuringRequire, fixture(__FILE__, "autoload_during_require.rb")
- end
-
- -> {
- Kernel.require fixture(__FILE__, "autoload_during_require.rb")
- }.should_not complain(verbose: true)
- ModuleSpecs::Autoload::AutoloadDuringRequire.should be_kind_of(Class)
- end
-
- it "does not call #require a second time and does not warn if feature sets and trigger autoload on itself" do
- main = TOPLEVEL_BINDING.eval("self")
- main.should_not_receive(:require)
-
- -> {
- Kernel.require fixture(__FILE__, "autoload_self_during_require.rb")
- }.should_not complain(verbose: true)
- ModuleSpecs::Autoload::AutoloadSelfDuringRequire.should be_kind_of(Class)
- end
-
- it "handles multiple autoloads in the same file" do
- $LOAD_PATH.unshift(File.expand_path('../fixtures/multi', __FILE__))
- begin
- require 'foo/bar_baz'
- ModuleSpecs::Autoload::Foo::Bar.should be_kind_of(Class)
- ModuleSpecs::Autoload::Foo::Baz.should be_kind_of(Class)
- ensure
- $LOAD_PATH.shift
- end
+ ModuleSpecs::Autoload::W.send(:remove_const, :Y)
end
it "calls #to_path on non-string filenames" do
@@ -680,27 +273,26 @@ describe "Module#autoload" do
end
it "raises an ArgumentError when an empty filename is given" do
- -> { ModuleSpecs.autoload :A, "" }.should raise_error(ArgumentError)
+ lambda { ModuleSpecs.autoload :A, "" }.should raise_error(ArgumentError)
end
it "raises a NameError when the constant name starts with a lower case letter" do
- -> { ModuleSpecs.autoload "a", @non_existent }.should raise_error(NameError)
+ lambda { ModuleSpecs.autoload "a", @non_existent }.should raise_error(NameError)
end
it "raises a NameError when the constant name starts with a number" do
- -> { ModuleSpecs.autoload "1two", @non_existent }.should raise_error(NameError)
+ lambda { ModuleSpecs.autoload "1two", @non_existent }.should raise_error(NameError)
end
it "raises a NameError when the constant name has a space in it" do
- -> { ModuleSpecs.autoload "a name", @non_existent }.should raise_error(NameError)
+ lambda { ModuleSpecs.autoload "a name", @non_existent }.should raise_error(NameError)
end
it "shares the autoload request across dup'ed copies of modules" do
require fixture(__FILE__, "autoload_s.rb")
- @remove << :S
filename = fixture(__FILE__, "autoload_t.rb")
mod1 = Module.new { autoload :T, filename }
- -> {
+ lambda {
ModuleSpecs::Autoload::S = mod1
}.should complain(/already initialized constant/)
mod2 = mod1.dup
@@ -709,7 +301,7 @@ describe "Module#autoload" do
mod2.autoload?(:T).should == filename
mod1::T.should == :autoload_t
- -> { mod2::T }.should raise_error(NameError)
+ lambda { mod2::T }.should raise_error(NameError)
end
it "raises a TypeError if opening a class with a different superclass than the class defined in the autoload file" do
@@ -717,30 +309,29 @@ describe "Module#autoload" do
class ModuleSpecs::Autoload::ZZ
end
- -> do
+ lambda do
class ModuleSpecs::Autoload::Z < ModuleSpecs::Autoload::ZZ
end
end.should raise_error(TypeError)
end
- it "raises a TypeError if not passed a String or object responding to #to_path for the filename" do
+ it "raises a TypeError if not passed a String or object respodning to #to_path for the filename" do
name = mock("autoload_name.rb")
- -> { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)
end
it "calls #to_path on non-String filename arguments" do
name = mock("autoload_name.rb")
name.should_receive(:to_path).and_return("autoload_name.rb")
- -> { ModuleSpecs::Autoload.autoload :Str, name }.should_not raise_error
+ lambda { ModuleSpecs::Autoload.autoload :Str, name }.should_not raise_error
end
describe "on a frozen module" do
- it "raises a #{frozen_error_class} before setting the name" do
- frozen_module = Module.new.freeze
- -> { frozen_module.autoload :Foo, @non_existent }.should raise_error(frozen_error_class)
- frozen_module.should_not have_constant(:Foo)
+ it "raises a RuntimeError before setting the name" do
+ lambda { @frozen_module.autoload :Foo, @non_existent }.should raise_error(RuntimeError)
+ @frozen_module.should_not have_constant(:Foo)
end
end
@@ -763,7 +354,6 @@ describe "Module#autoload" do
describe "(concurrently)" do
it "blocks a second thread while a first is doing the autoload" do
ModuleSpecs::Autoload.autoload :Concur, fixture(__FILE__, "autoload_concur.rb")
- @remove << :Concur
start = false
@@ -806,53 +396,56 @@ describe "Module#autoload" do
t2_val.should == t1_val
t2_exc.should be_nil
+
+ ModuleSpecs::Autoload.send(:remove_const, :Concur)
end
- # https://bugs.ruby-lang.org/issues/10892
- it "blocks others threads while doing an autoload" do
- file_path = fixture(__FILE__, "repeated_concurrent_autoload.rb")
- autoload_path = file_path.sub(/\.rb\Z/, '')
- mod_count = 30
- thread_count = 16
-
- mod_names = []
- mod_count.times do |i|
- mod_name = :"Mod#{i}"
- Object.autoload mod_name, autoload_path
- mod_names << mod_name
- end
+ ruby_bug "#10892", ""..."2.3" do
+ it "blocks others threads while doing an autoload" do
+ file_path = fixture(__FILE__, "repeated_concurrent_autoload.rb")
+ autoload_path = file_path.sub(/\.rb\Z/, '')
+ mod_count = 30
+ thread_count = 16
- barrier = ModuleSpecs::CyclicBarrier.new thread_count
- ScratchPad.record ModuleSpecs::ThreadSafeCounter.new
+ mod_names = []
+ mod_count.times do |i|
+ mod_name = :"Mod#{i}"
+ Object.autoload mod_name, autoload_path
+ mod_names << mod_name
+ end
- threads = (1..thread_count).map do
- Thread.new do
- mod_names.each do |mod_name|
- break false unless barrier.enabled?
-
- was_last_one_in = barrier.await # wait for all threads to finish the iteration
- # clean up so we can autoload the same file again
- $LOADED_FEATURES.delete(file_path) if was_last_one_in && $LOADED_FEATURES.include?(file_path)
- barrier.await # get ready for race
-
- begin
- Object.const_get(mod_name).foo
- rescue NoMethodError
- barrier.disable!
- break false
+ barrier = ModuleSpecs::CyclicBarrier.new thread_count
+ ScratchPad.record ModuleSpecs::ThreadSafeCounter.new
+
+ threads = (1..thread_count).map do
+ Thread.new do
+ mod_names.each do |mod_name|
+ break false unless barrier.enabled?
+
+ was_last_one_in = barrier.await # wait for all threads to finish the iteration
+ # clean up so we can autoload the same file again
+ $LOADED_FEATURES.delete(file_path) if was_last_one_in && $LOADED_FEATURES.include?(file_path)
+ barrier.await # get ready for race
+
+ begin
+ Object.const_get(mod_name).foo
+ rescue NoMethodError
+ barrier.disable!
+ break false
+ end
end
end
end
- end
- # check that no thread got a NoMethodError because of partially loaded module
- threads.all? {|t| t.value}.should be_true
+ # check that no thread got a NoMethodError because of partially loaded module
+ threads.all? {|t| t.value}.should be_true
- # check that the autoloaded file was evaled exactly once
- ScratchPad.recorded.get.should == mod_count
+ # check that the autoloaded file was evaled exactly once
+ ScratchPad.recorded.get.should == mod_count
- mod_names.each do |mod_name|
- Object.send(:remove_const, mod_name)
+ mod_names.each do |mod_name|
+ Object.send(:remove_const, mod_name)
+ end
end
end
diff --git a/spec/ruby/core/module/case_compare_spec.rb b/spec/ruby/core/module/case_compare_spec.rb
index 49ac359f6f..92f2c2065b 100644
--- a/spec/ruby/core/module/case_compare_spec.rb
+++ b/spec/ruby/core/module/case_compare_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#===" do
it "returns true when the given Object is an instance of self or of self's descendants" do
diff --git a/spec/ruby/core/module/class_eval_spec.rb b/spec/ruby/core/module/class_eval_spec.rb
index c6665d5aff..90deef9c2f 100644
--- a/spec/ruby/core/module/class_eval_spec.rb
+++ b/spec/ruby/core/module/class_eval_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/class_eval'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/class_eval', __FILE__)
describe "Module#class_eval" do
it_behaves_like :module_class_eval, :class_eval
diff --git a/spec/ruby/core/module/class_exec_spec.rb b/spec/ruby/core/module/class_exec_spec.rb
index 4acd0169ad..f9c12cfa48 100644
--- a/spec/ruby/core/module/class_exec_spec.rb
+++ b/spec/ruby/core/module/class_exec_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/class_exec'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/class_exec', __FILE__)
describe "Module#class_exec" do
it_behaves_like :module_class_exec, :class_exec
diff --git a/spec/ruby/core/module/class_variable_defined_spec.rb b/spec/ruby/core/module/class_variable_defined_spec.rb
index f867d383c3..d47329455f 100644
--- a/spec/ruby/core/module/class_variable_defined_spec.rb
+++ b/spec/ruby/core/module/class_variable_defined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#class_variable_defined?" do
it "returns true if a class variable with the given name is defined in self" do
@@ -42,11 +42,11 @@ describe "Module#class_variable_defined?" do
it "raises a NameError when the given name is not allowed" do
c = Class.new
- -> {
+ lambda {
c.class_variable_defined?(:invalid_name)
}.should raise_error(NameError)
- -> {
+ lambda {
c.class_variable_defined?("@invalid_name")
}.should raise_error(NameError)
end
@@ -60,12 +60,12 @@ describe "Module#class_variable_defined?" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
c = Class.new { class_variable_set :@@class_var, "test" }
o = mock('123')
- -> {
+ lambda {
c.class_variable_defined?(o)
}.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- -> {
+ lambda {
c.class_variable_defined?(o)
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/class_variable_get_spec.rb b/spec/ruby/core/module/class_variable_get_spec.rb
index 79d22a506b..7068801cc0 100644
--- a/spec/ruby/core/module/class_variable_get_spec.rb
+++ b/spec/ruby/core/module/class_variable_get_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#class_variable_get" do
it "returns the value of the class variable with the given name" do
@@ -15,14 +15,14 @@ describe "Module#class_variable_get" do
it "raises a NameError for a class variable named '@@'" do
c = Class.new
- -> { c.send(:class_variable_get, "@@") }.should raise_error(NameError)
- -> { c.send(:class_variable_get, :"@@") }.should raise_error(NameError)
+ lambda { c.send(:class_variable_get, "@@") }.should raise_error(NameError)
+ lambda { c.send(:class_variable_get, :"@@") }.should raise_error(NameError)
end
it "raises a NameError for a class variables with the given name defined in an extended module" do
c = Class.new
c.extend ModuleSpecs::MVars
- -> {
+ lambda {
c.send(:class_variable_get, "@@mvar")
}.should raise_error(NameError)
end
@@ -49,15 +49,15 @@ describe "Module#class_variable_get" do
it "raises a NameError when an uninitialized class variable is accessed" do
c = Class.new
[:@@no_class_var, "@@no_class_var"].each do |cvar|
- -> { c.send(:class_variable_get, cvar) }.should raise_error(NameError)
+ lambda { c.send(:class_variable_get, cvar) }.should raise_error(NameError)
end
end
it "raises a NameError when the given name is not allowed" do
c = Class.new
- -> { c.send(:class_variable_get, :invalid_name) }.should raise_error(NameError)
- -> { c.send(:class_variable_get, "@invalid_name") }.should raise_error(NameError)
+ lambda { c.send(:class_variable_get, :invalid_name) }.should raise_error(NameError)
+ lambda { c.send(:class_variable_get, "@invalid_name") }.should raise_error(NameError)
end
it "converts a non string/symbol/fixnum name to string using to_str" do
@@ -69,8 +69,8 @@ describe "Module#class_variable_get" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
c = Class.new { class_variable_set :@@class_var, "test" }
o = mock('123')
- -> { c.send(:class_variable_get, o) }.should raise_error(TypeError)
+ lambda { c.send(:class_variable_get, o) }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- -> { c.send(:class_variable_get, o) }.should raise_error(TypeError)
+ lambda { c.send(:class_variable_get, o) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/class_variable_set_spec.rb b/spec/ruby/core/module/class_variable_set_spec.rb
index 204bbaf75e..6d36298f5f 100644
--- a/spec/ruby/core/module/class_variable_set_spec.rb
+++ b/spec/ruby/core/module/class_variable_set_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#class_variable_set" do
it "sets the class variable with the given name to the given value" do
@@ -25,22 +25,22 @@ describe "Module#class_variable_set" do
c.send(:class_variable_get, "@@mvar").should == :new_mvar
end
- it "raises a #{frozen_error_class} when self is frozen" do
- -> {
+ it "raises a RuntimeError when self is frozen" do
+ lambda {
Class.new.freeze.send(:class_variable_set, :@@test, "test")
- }.should raise_error(frozen_error_class)
- -> {
+ }.should raise_error(RuntimeError)
+ lambda {
Module.new.freeze.send(:class_variable_set, :@@test, "test")
- }.should raise_error(frozen_error_class)
+ }.should raise_error(RuntimeError)
end
it "raises a NameError when the given name is not allowed" do
c = Class.new
- -> {
+ lambda {
c.send(:class_variable_set, :invalid_name, "test")
}.should raise_error(NameError)
- -> {
+ lambda {
c.send(:class_variable_set, "@invalid_name", "test")
}.should raise_error(NameError)
end
@@ -55,8 +55,8 @@ describe "Module#class_variable_set" do
it "raises a TypeError when the given names can't be converted to strings using to_str" do
c = Class.new { class_variable_set :@@class_var, "test" }
o = mock('123')
- -> { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
+ lambda { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- -> { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
+ lambda { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/class_variables_spec.rb b/spec/ruby/core/module/class_variables_spec.rb
index fd7aa93aa8..066052cd01 100644
--- a/spec/ruby/core/module/class_variables_spec.rb
+++ b/spec/ruby/core/module/class_variables_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#class_variables" do
it "returns an Array with the names of class variables of self" do
diff --git a/spec/ruby/core/module/comparison_spec.rb b/spec/ruby/core/module/comparison_spec.rb
index 86ee5db22a..e7608d64b9 100644
--- a/spec/ruby/core/module/comparison_spec.rb
+++ b/spec/ruby/core/module/comparison_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#<=>" do
it "returns -1 if self is a subclass of or includes the given module" do
@@ -16,7 +16,7 @@ describe "Module#<=>" do
(ModuleSpecs::Super <=> ModuleSpecs::Super).should == 0
end
- it "returns +1 if self is a superclass of or included by the given module" do
+ it "returns +1 if self is a superclas of or included by the given module" do
(ModuleSpecs::Parent <=> ModuleSpecs::Child).should == +1
(ModuleSpecs::Basic <=> ModuleSpecs::Child).should == +1
(ModuleSpecs::Super <=> ModuleSpecs::Child).should == +1
diff --git a/spec/ruby/core/module/const_defined_spec.rb b/spec/ruby/core/module/const_defined_spec.rb
index 0673adca3d..0789a03e1c 100644
--- a/spec/ruby/core/module/const_defined_spec.rb
+++ b/spec/ruby/core/module/const_defined_spec.rb
@@ -1,8 +1,8 @@
# encoding: utf-8
-require_relative '../../spec_helper'
-require_relative '../../fixtures/constants'
-require_relative 'fixtures/constant_unicode'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/constants', __FILE__)
+require File.expand_path('../fixtures/constant_unicode', __FILE__)
describe "Module#const_defined?" do
it "returns true if the given Symbol names a constant defined in the receiver" do
@@ -105,19 +105,19 @@ describe "Module#const_defined?" do
end
it "raises a NameError if the name does not start with a capital letter" do
- -> { ConstantSpecs.const_defined? "name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_defined? "name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with '_'" do
- -> { ConstantSpecs.const_defined? "__CONSTX__" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_defined? "__CONSTX__" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with '@'" do
- -> { ConstantSpecs.const_defined? "@Name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_defined? "@Name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with '!'" do
- -> { ConstantSpecs.const_defined? "!Name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_defined? "!Name" }.should raise_error(NameError)
end
it "returns true or false for the nested name" do
@@ -130,15 +130,15 @@ describe "Module#const_defined?" do
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
ConstantSpecs.const_defined?("CS_CONSTX").should == false
- -> { ConstantSpecs.const_defined? "Name=" }.should raise_error(NameError)
- -> { ConstantSpecs.const_defined? "Name?" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_defined? "Name=" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_defined? "Name?" }.should raise_error(NameError)
end
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- -> { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
+ lambda { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- -> { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
+ lambda { ConstantSpecs.const_defined? name }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/const_get_spec.rb b/spec/ruby/core/module/const_get_spec.rb
index 0a6702903f..6f8d5d930f 100644
--- a/spec/ruby/core/module/const_get_spec.rb
+++ b/spec/ruby/core/module/const_get_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/constants'
-require_relative 'fixtures/constants_autoload'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/constants', __FILE__)
describe "Module#const_get" do
it "accepts a String or Symbol name" do
@@ -9,28 +8,28 @@ describe "Module#const_get" do
end
it "raises a NameError if no constant is defined in the search path" do
- -> { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError)
end
it "raises a NameError with the not found constant symbol" do
- error_inspection = -> e { e.name.should == :CS_CONSTX }
- -> { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError, &error_inspection)
+ error_inspection = lambda { |e| e.name.should == :CS_CONSTX }
+ lambda { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError, &error_inspection)
end
it "raises a NameError if the name does not start with a capital letter" do
- -> { ConstantSpecs.const_get "name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get "name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with a non-alphabetic character" do
- -> { ConstantSpecs.const_get "__CONSTX__" }.should raise_error(NameError)
- -> { ConstantSpecs.const_get "@CS_CONST1" }.should raise_error(NameError)
- -> { ConstantSpecs.const_get "!CS_CONST1" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get "__CONSTX__" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get "@CS_CONST1" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get "!CS_CONST1" }.should raise_error(NameError)
end
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
Object.const_get("CS_CONST1").should == :const1
- -> { ConstantSpecs.const_get "CS_CONST1=" }.should raise_error(NameError)
- -> { ConstantSpecs.const_get "CS_CONST1?" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get "CS_CONST1=" }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get "CS_CONST1?" }.should raise_error(NameError)
end
it "calls #to_str to convert the given name to a String" do
@@ -41,10 +40,10 @@ describe "Module#const_get" do
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- -> { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
+ lambda { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- -> { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
+ lambda { ConstantSpecs.const_get(name) }.should raise_error(TypeError)
end
it "calls #const_missing on the receiver if unable to locate the constant" do
@@ -53,21 +52,21 @@ describe "Module#const_get" do
end
it "does not search the singleton class of a Class or Module" do
- -> do
+ lambda do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST14)
end.should raise_error(NameError)
- -> { ConstantSpecs.const_get(:CS_CONST14) }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get(:CS_CONST14) }.should raise_error(NameError)
end
it "does not search the containing scope" do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST20).should == :const20_2
- -> do
+ lambda do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST5)
end.should raise_error(NameError)
end
- it "raises a NameError if the constant is defined in the receiver's superclass and the inherit flag is false" do
- -> do
+ it "raises a NameError if the constant is defined in the receiver's supperclass and the inherit flag is false" do
+ lambda do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST4, false)
end.should raise_error(NameError)
end
@@ -77,13 +76,13 @@ describe "Module#const_get" do
end
it "raises a NameError when the receiver is a Module, the constant is defined at toplevel and the inherit flag is false" do
- -> do
+ lambda do
ConstantSpecs::ModuleA.const_get(:CS_CONST1, false)
end.should raise_error(NameError)
end
it "raises a NameError when the receiver is a Class, the constant is defined at toplevel and the inherit flag is false" do
- -> do
+ lambda do
ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST1, false)
end.should raise_error(NameError)
end
@@ -96,42 +95,22 @@ describe "Module#const_get" do
ConstantSpecs.const_get("ClassA::CS_CONST10").should == :const10_10
end
- it "raises a NameError if the name includes two successive scope separators" do
- -> { ConstantSpecs.const_get("ClassA::::CS_CONST10") }.should raise_error(NameError)
- end
-
it "raises a NameError if only '::' is passed" do
- -> { ConstantSpecs.const_get("::") }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get("::") }.should raise_error(NameError)
end
it "raises a NameError if a Symbol has a toplevel scope qualifier" do
- -> { ConstantSpecs.const_get(:'::CS_CONST1') }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get(:'::CS_CONST1') }.should raise_error(NameError)
end
it "raises a NameError if a Symbol is a scoped constant name" do
- -> { ConstantSpecs.const_get(:'ClassA::CS_CONST10') }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_get(:'ClassA::CS_CONST10') }.should raise_error(NameError)
end
it "does read private constants" do
ConstantSpecs.const_get(:CS_PRIVATE).should == :cs_private
end
- it 'does autoload a constant' do
- Object.const_get('CSAutoloadA').name.should == 'CSAutoloadA'
- end
-
- it 'does autoload a constant with a toplevel scope qualifier' do
- Object.const_get('::CSAutoloadB').name.should == 'CSAutoloadB'
- end
-
- it 'does autoload a module and resolve a constant within' do
- Object.const_get('CSAutoloadC::CONST').should == 7
- end
-
- it 'does autoload a non-toplevel module' do
- Object.const_get('CSAutoloadD::InnerModule').name.should == 'CSAutoloadD::InnerModule'
- end
-
describe "with statically assigned constants" do
it "searches the immediate class or module first" do
ConstantSpecs::ClassA.const_get(:CS_CONST10).should == :const10_10
@@ -220,7 +199,7 @@ describe "Module#const_get" do
ConstantSpecs::ClassB::CS_CONST309 = :const309_1
ConstantSpecs::ClassB.const_get(:CS_CONST309).should == :const309_1
- -> {
+ lambda {
ConstantSpecs::ClassB::CS_CONST309 = :const309_2
}.should complain(/already initialized constant/)
ConstantSpecs::ClassB.const_get(:CS_CONST309).should == :const309_2
diff --git a/spec/ruby/core/module/const_missing_spec.rb b/spec/ruby/core/module/const_missing_spec.rb
index 742218281c..24f2b49edc 100644
--- a/spec/ruby/core/module/const_missing_spec.rb
+++ b/spec/ruby/core/module/const_missing_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/constants'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/constants', __FILE__)
describe "Module#const_missing" do
it "is called when an undefined constant is referenced via literal form" do
@@ -11,7 +11,7 @@ describe "Module#const_missing" do
end
it "raises NameError and includes the name of the value that wasn't found" do
- -> {
+ lambda {
ConstantSpecs.const_missing("HelloMissing")
}.should raise_error(NameError, /ConstantSpecs::HelloMissing/)
end
@@ -24,13 +24,4 @@ describe "Module#const_missing" do
end
end
- it "is called regardless of visibility" do
- klass = Class.new do
- def self.const_missing(name)
- "Found:#{name}"
- end
- private_class_method :const_missing
- end
- klass::Hello.should == 'Found:Hello'
- end
end
diff --git a/spec/ruby/core/module/const_set_spec.rb b/spec/ruby/core/module/const_set_spec.rb
index 1b8b86dd04..6f4f6f980f 100644
--- a/spec/ruby/core/module/const_set_spec.rb
+++ b/spec/ruby/core/module/const_set_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/constants'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/constants', __FILE__)
describe "Module#const_set" do
it "sets the constant specified by a String or Symbol to the given value" do
@@ -41,20 +41,20 @@ describe "Module#const_set" do
end
it "raises a NameError if the name does not start with a capital letter" do
- -> { ConstantSpecs.const_set "name", 1 }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_set "name", 1 }.should raise_error(NameError)
end
it "raises a NameError if the name starts with a non-alphabetic character" do
- -> { ConstantSpecs.const_set "__CONSTX__", 1 }.should raise_error(NameError)
- -> { ConstantSpecs.const_set "@Name", 1 }.should raise_error(NameError)
- -> { ConstantSpecs.const_set "!Name", 1 }.should raise_error(NameError)
- -> { ConstantSpecs.const_set "::Name", 1 }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_set "__CONSTX__", 1 }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_set "@Name", 1 }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_set "!Name", 1 }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_set "::Name", 1 }.should raise_error(NameError)
end
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
ConstantSpecs.const_set("CS_CONST404", :const404).should == :const404
- -> { ConstantSpecs.const_set "Name=", 1 }.should raise_error(NameError)
- -> { ConstantSpecs.const_set "Name?", 1 }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_set "Name=", 1 }.should raise_error(NameError)
+ lambda { ConstantSpecs.const_set "Name?", 1 }.should raise_error(NameError)
end
it "calls #to_str to convert the given name to a String" do
@@ -66,57 +66,10 @@ describe "Module#const_set" do
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- -> { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
+ lambda { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- -> { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
- end
-
- describe "when overwriting an existing constant" do
- it "warns if the previous value was a normal value" do
- mod = Module.new
- mod.const_set :Foo, 42
- -> {
- mod.const_set :Foo, 1
- }.should complain(/already initialized constant/)
- mod.const_get(:Foo).should == 1
- end
-
- it "does not warn if the previous value was an autoload" do
- mod = Module.new
- mod.autoload :Foo, "not-existing"
- -> {
- mod.const_set :Foo, 1
- }.should_not complain
- mod.const_get(:Foo).should == 1
- end
-
- it "does not warn if the previous value was undefined" do
- path = fixture(__FILE__, "autoload_o.rb")
- ScratchPad.record []
- mod = Module.new
-
- mod.autoload :Foo, path
- -> { mod::Foo }.should raise_error(NameError)
-
- mod.should have_constant(:Foo)
- mod.const_defined?(:Foo).should == false
- mod.autoload?(:Foo).should == nil
-
- -> {
- mod.const_set :Foo, 1
- }.should_not complain
- mod.const_get(:Foo).should == 1
- end
-
- it "does not warn if the new value is an autoload" do
- mod = Module.new
- mod.const_set :Foo, 42
- -> {
- mod.autoload :Foo, "not-existing"
- }.should_not complain
- mod.const_get(:Foo).should == 42
- end
+ lambda { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError)
end
describe "on a frozen module" do
@@ -125,8 +78,8 @@ describe "Module#const_set" do
@name = :Foo
end
- it "raises a #{frozen_error_class} before setting the name" do
- -> { @frozen.const_set @name, nil }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError before setting the name" do
+ lambda { @frozen.const_set @name, nil }.should raise_error(RuntimeError)
@frozen.should_not have_constant(@name)
end
end
diff --git a/spec/ruby/core/module/constants_spec.rb b/spec/ruby/core/module/constants_spec.rb
index 4538e828dd..c331482bfb 100644
--- a/spec/ruby/core/module/constants_spec.rb
+++ b/spec/ruby/core/module/constants_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/constants'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/constants', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module.constants" do
it "returns an array of the names of all toplevel constants" do
diff --git a/spec/ruby/core/module/define_method_spec.rb b/spec/ruby/core/module/define_method_spec.rb
index 29394e5b92..64ac5306f0 100644
--- a/spec/ruby/core/module/define_method_spec.rb
+++ b/spec/ruby/core/module/define_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
class DefineMethodSpecClass
end
@@ -12,7 +12,7 @@ describe "passed { |a, b = 1| } creates a method that" do
end
it "raises an ArgumentError when passed zero arguments" do
- -> { @klass.new.m }.should raise_error(ArgumentError)
+ lambda { @klass.new.m }.should raise_error(ArgumentError)
end
it "has a default value for b when passed one argument" do
@@ -24,7 +24,7 @@ describe "passed { |a, b = 1| } creates a method that" do
end
it "raises an ArgumentError when passed three arguments" do
- -> { @klass.new.m(1, 2, 3) }.should raise_error(ArgumentError)
+ lambda { @klass.new.m(1, 2, 3) }.should raise_error(ArgumentError)
end
end
@@ -83,7 +83,7 @@ describe "Module#define_method when given an UnboundMethod" do
define_method :piggy, instance_method(:ziggy)
end
- -> { foo.new.ziggy }.should raise_error(NoMethodError)
+ lambda { foo.new.ziggy }.should raise_error(NoMethodError)
foo.new.piggy.should == 'piggy'
end
end
@@ -194,7 +194,7 @@ describe "Module#define_method" do
it "defines a new method with the given name and the given block as body in self" do
class DefineMethodSpecClass
define_method(:block_test1) { self }
- define_method(:block_test2, &-> { self })
+ define_method(:block_test2, &lambda { self })
end
o = DefineMethodSpecClass.new
@@ -203,36 +203,38 @@ describe "Module#define_method" do
end
it "raises a TypeError when the given method is no Method/Proc" do
- -> {
+ lambda {
Class.new { define_method(:test, "self") }
}.should raise_error(TypeError)
- -> {
+ lambda {
Class.new { define_method(:test, 1234) }
}.should raise_error(TypeError)
- -> {
+ lambda {
Class.new { define_method(:test, nil) }
}.should raise_error(TypeError)
end
it "raises an ArgumentError when no block is given" do
- -> {
+ lambda {
Class.new { define_method(:test) }
}.should raise_error(ArgumentError)
end
- it "does not use the caller block when no block is given" do
- o = Object.new
- def o.define(name)
- self.class.class_eval do
- define_method(name)
+ ruby_version_is "2.3" do
+ it "does not use the caller block when no block is given" do
+ o = Object.new
+ def o.define(name)
+ self.class.class_eval do
+ define_method(name)
+ end
end
- end
- -> {
- o.define(:foo) { raise "not used" }
- }.should raise_error(ArgumentError)
+ lambda {
+ o.define(:foo) { raise "not used" }
+ }.should raise_error(ArgumentError)
+ end
end
it "does not change the arity check style of the original proc" do
@@ -242,13 +244,13 @@ describe "Module#define_method" do
end
obj = DefineMethodSpecClass.new
- -> { obj.proc_style_test :arg }.should raise_error(ArgumentError)
+ lambda { obj.proc_style_test :arg }.should raise_error(ArgumentError)
end
- it "raises a #{frozen_error_class} if frozen" do
- -> {
+ it "raises a RuntimeError if frozen" do
+ lambda {
Class.new { freeze; define_method(:foo) {} }
- }.should raise_error(frozen_error_class)
+ }.should raise_error(RuntimeError)
end
it "accepts a Method (still bound)" do
@@ -267,7 +269,7 @@ describe "Module#define_method" do
c = klass.new
c.data = :bar
c.other_inspect.should == "data is bar"
- ->{o.other_inspect}.should raise_error(NoMethodError)
+ lambda{o.other_inspect}.should raise_error(NoMethodError)
end
it "raises a TypeError when a Method from a singleton class is defined on another class" do
@@ -279,9 +281,9 @@ describe "Module#define_method" do
end
m = c.method(:foo)
- -> {
+ lambda {
Class.new { define_method :bar, m }
- }.should raise_error(TypeError, /can't bind singleton method to a different class/)
+ }.should raise_error(TypeError)
end
it "raises a TypeError when a Method from one class is defined on an unrelated class" do
@@ -291,7 +293,7 @@ describe "Module#define_method" do
end
m = c.new.method(:foo)
- -> {
+ lambda {
Class.new { define_method :bar, m }
}.should raise_error(TypeError)
end
@@ -305,7 +307,7 @@ describe "Module#define_method" do
o = DefineMethodSpecClass.new
DefineMethodSpecClass.send(:undef_method, :accessor_method)
- -> { o.accessor_method }.should raise_error(NoMethodError)
+ lambda { o.accessor_method }.should raise_error(NoMethodError)
DefineMethodSpecClass.send(:define_method, :accessor_method, m)
@@ -396,42 +398,20 @@ describe "Module#define_method" do
klass.new.should respond_to(:bar)
end
-
- it "allows an UnboundMethod of a Kernel method retrieved from Object to defined on a BasicObject subclass" do
- klass = Class.new(BasicObject) do
- define_method :instance_of?, ::Object.instance_method(:instance_of?)
- end
- klass.new.instance_of?(klass).should == true
- end
-
it "raises a TypeError when an UnboundMethod from a child class is defined on a parent class" do
- -> {
+ lambda {
ParentClass = Class.new { define_method(:foo) { :bar } }
ChildClass = Class.new(ParentClass) { define_method(:foo) { :baz } }
ParentClass.send :define_method, :foo, ChildClass.instance_method(:foo)
- }.should raise_error(TypeError, /bind argument must be a subclass of ChildClass/)
+ }.should raise_error(TypeError)
end
it "raises a TypeError when an UnboundMethod from one class is defined on an unrelated class" do
- -> {
+ lambda {
DestinationClass = Class.new {
define_method :bar, ModuleSpecs::InstanceMeth.instance_method(:foo)
}
- }.should raise_error(TypeError, /bind argument must be a subclass of ModuleSpecs::InstanceMeth/)
- end
-
- it "raises a TypeError when an UnboundMethod from a singleton class is defined on another class" do
- c = Class.new do
- class << self
- def foo
- end
- end
- end
- m = c.method(:foo).unbind
-
- -> {
- Class.new { define_method :bar, m }
- }.should raise_error(TypeError, /can't bind singleton method to a different class/)
+ }.should raise_error(TypeError)
end
end
@@ -448,11 +428,11 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed one argument" do
- -> { @klass.new.m 1 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed two arguments" do
- -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
end
end
@@ -468,11 +448,11 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed one argument" do
- -> { @klass.new.m 1 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed two arguments" do
- -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
end
end
@@ -484,15 +464,15 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- -> { @klass.new.m }.should raise_error(ArgumentError)
+ lambda { @klass.new.m }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed zero arguments and a block" do
- -> { @klass.new.m { :computed } }.should raise_error(ArgumentError)
+ lambda { @klass.new.m { :computed } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed two arguments" do
- -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1, 2 }.should raise_error(ArgumentError)
end
it "receives the value passed as the argument when passed one argument" do
@@ -529,7 +509,7 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- -> { @klass.new.m }.should raise_error(ArgumentError)
+ lambda { @klass.new.m }.should raise_error(ArgumentError)
end
it "returns the value computed by the block when passed one argument" do
@@ -557,19 +537,19 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- -> { @klass.new.m }.should raise_error(ArgumentError)
+ lambda { @klass.new.m }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument" do
- -> { @klass.new.m 1 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument and a block" do
- -> { @klass.new.m(1) { } }.should raise_error(ArgumentError)
+ lambda { @klass.new.m(1) { } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed three arguments" do
- -> { @klass.new.m 1, 2, 3 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1, 2, 3 }.should raise_error(ArgumentError)
end
end
@@ -581,15 +561,15 @@ describe "Module#define_method" do
end
it "raises an ArgumentError when passed zero arguments" do
- -> { @klass.new.m }.should raise_error(ArgumentError)
+ lambda { @klass.new.m }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument" do
- -> { @klass.new.m 1 }.should raise_error(ArgumentError)
+ lambda { @klass.new.m 1 }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed one argument and a block" do
- -> { @klass.new.m(1) { } }.should raise_error(ArgumentError)
+ lambda { @klass.new.m(1) { } }.should raise_error(ArgumentError)
end
it "receives an empty array as the third argument when passed two arguments" do
@@ -651,28 +631,3 @@ describe "Method#define_method when passed an UnboundMethod object" do
@obj.method(:n).parameters.should == @obj.method(:m).parameters
end
end
-
-describe "Method#define_method when passed a Proc object" do
- describe "and a method is defined inside" do
- it "defines the nested method in the default definee where the Proc was created" do
- prc = nil
- t = Class.new do
- prc = -> {
- def nested_method_in_proc_for_define_method
- 42
- end
- }
- end
-
- c = Class.new do
- define_method(:test, prc)
- end
-
- o = c.new
- o.test
- o.should_not have_method :nested_method_in_proc_for_define_method
-
- t.new.nested_method_in_proc_for_define_method.should == 42
- end
- end
-end
diff --git a/spec/ruby/core/module/define_singleton_method_spec.rb b/spec/ruby/core/module/define_singleton_method_spec.rb
index eb5cb89ed1..0841d5d7e2 100644
--- a/spec/ruby/core/module/define_singleton_method_spec.rb
+++ b/spec/ruby/core/module/define_singleton_method_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module#define_singleton_method" do
it "defines the given method as an class method with the given name in self" do
@@ -6,10 +6,12 @@ describe "Module#define_singleton_method" do
define_singleton_method :a do
42
end
- define_singleton_method(:b, -> x { 2*x })
+ define_singleton_method(:b, lambda {|x| 2*x })
end
klass.a.should == 42
klass.b(10).should == 20
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/module/deprecate_constant_spec.rb b/spec/ruby/core/module/deprecate_constant_spec.rb
index 6a8086bc8f..8c7a170f1c 100644
--- a/spec/ruby/core/module/deprecate_constant_spec.rb
+++ b/spec/ruby/core/module/deprecate_constant_spec.rb
@@ -1,60 +1,52 @@
-require_relative '../../spec_helper'
-
-describe "Module#deprecate_constant" do
- before :each do
- @module = Module.new
- @value = :value
- @module::PUBLIC1 = @value
- @module::PUBLIC2 = @value
- @module::PRIVATE = @value
- @module.private_constant :PRIVATE
- @module.deprecate_constant :PRIVATE
- @pattern = /deprecated/
- if Warning.respond_to?(:[])
- @deprecated = Warning[:deprecated]
- Warning[:deprecated] = true
+require File.expand_path('../../../spec_helper', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "Module#deprecate_constant" do
+ before :each do
+ @module = Module.new
+ @value = :value
+ @module::PUBLIC1 = @value
+ @module::PUBLIC2 = @value
+ @module::PRIVATE = @value
+ @module.private_constant :PRIVATE
+ @module.deprecate_constant :PRIVATE
+ @pattern = /deprecated/
end
- end
-
- after :each do
- if Warning.respond_to?(:[])
- Warning[:deprecated] = @deprecated
- end
- end
- describe "when accessing the deprecated module" do
- it "passes the accessing" do
- @module.deprecate_constant :PUBLIC1
+ describe "when accessing the deprecated module" do
+ it "passes the accessing" do
+ @module.deprecate_constant :PUBLIC1
- value = nil
- -> {
- value = @module::PUBLIC1
- }.should complain(@pattern)
- value.should equal(@value)
+ value = nil
+ lambda {
+ value = @module::PUBLIC1
+ }.should complain(@pattern)
+ value.should equal(@value)
- -> { @module::PRIVATE }.should raise_error(NameError)
- end
+ lambda { @module::PRIVATE }.should raise_error(NameError)
+ end
- it "warns with a message" do
- @module.deprecate_constant :PUBLIC1
+ it "warns with a message" do
+ @module.deprecate_constant :PUBLIC1
- -> { @module::PUBLIC1 }.should complain(@pattern)
- -> { @module.const_get :PRIVATE }.should complain(@pattern)
+ lambda { @module::PUBLIC1 }.should complain(@pattern)
+ lambda { @module.const_get :PRIVATE }.should complain(@pattern)
+ end
end
- end
- it "accepts multiple symbols and strings as constant names" do
- @module.deprecate_constant "PUBLIC1", :PUBLIC2
+ it "accepts multiple symbols and strings as constant names" do
+ @module.deprecate_constant "PUBLIC1", :PUBLIC2
- -> { @module::PUBLIC1 }.should complain(@pattern)
- -> { @module::PUBLIC2 }.should complain(@pattern)
- end
+ lambda { @module::PUBLIC1 }.should complain(@pattern)
+ lambda { @module::PUBLIC2 }.should complain(@pattern)
+ end
- it "returns self" do
- @module.deprecate_constant(:PUBLIC1).should equal(@module)
- end
+ it "returns self" do
+ @module.deprecate_constant(:PUBLIC1).should equal(@module)
+ end
- it "raises a NameError when given an undefined name" do
- -> { @module.deprecate_constant :UNDEFINED }.should raise_error(NameError)
+ it "raises a NameError when given an undefined name" do
+ lambda { @module.deprecate_constant :UNDEFINED }.should raise_error(NameError)
+ end
end
end
diff --git a/spec/ruby/core/module/eql_spec.rb b/spec/ruby/core/module/eql_spec.rb
index 76bb271d8d..f8878d7f4e 100644
--- a/spec/ruby/core/module/eql_spec.rb
+++ b/spec/ruby/core/module/eql_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Module#eql?" do
- it_behaves_like :module_equal, :eql?
+ it_behaves_like(:module_equal, :eql?)
end
diff --git a/spec/ruby/core/module/equal_spec.rb b/spec/ruby/core/module/equal_spec.rb
index 01ab06152d..bc70a6277a 100644
--- a/spec/ruby/core/module/equal_spec.rb
+++ b/spec/ruby/core/module/equal_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Module#equal?" do
- it_behaves_like :module_equal, :equal?
+ it_behaves_like(:module_equal, :equal?)
end
diff --git a/spec/ruby/core/module/equal_value_spec.rb b/spec/ruby/core/module/equal_value_spec.rb
index a7191cd755..12494477f9 100644
--- a/spec/ruby/core/module/equal_value_spec.rb
+++ b/spec/ruby/core/module/equal_value_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Module#==" do
- it_behaves_like :module_equal, :==
+ it_behaves_like(:module_equal, :==)
end
diff --git a/spec/ruby/core/module/extend_object_spec.rb b/spec/ruby/core/module/extend_object_spec.rb
index e66b87efef..73c1623dce 100644
--- a/spec/ruby/core/module/extend_object_spec.rb
+++ b/spec/ruby/core/module/extend_object_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#extend_object" do
before :each do
@@ -16,7 +16,7 @@ describe "Module#extend_object" do
end
it "raises a TypeError if calling after rebinded to Class" do
- -> {
+ lambda {
Module.instance_method(:extend_object).bind(Class.new).call Object.new
}.should raise_error(TypeError)
end
@@ -42,18 +42,16 @@ describe "Module#extend_object" do
ScratchPad.recorded.should == :extended
end
- ruby_version_is ''...'2.7' do
- it "does not copy own tainted status to the given object" do
- other = Object.new
- Module.new.taint.send :extend_object, other
- other.tainted?.should be_false
- end
+ it "does not copy own tainted status to the given object" do
+ other = Object.new
+ Module.new.taint.send :extend_object, other
+ other.tainted?.should be_false
+ end
- it "does not copy own untrusted status to the given object" do
- other = Object.new
- Module.new.untrust.send :extend_object, other
- other.untrusted?.should be_false
- end
+ it "does not copy own untrusted status to the given object" do
+ other = Object.new
+ Module.new.untrust.send :extend_object, other
+ other.untrusted?.should be_false
end
describe "when given a frozen object" do
@@ -63,7 +61,7 @@ describe "Module#extend_object" do
end
it "raises a RuntimeError before extending the object" do
- -> { @receiver.send(:extend_object, @object) }.should raise_error(RuntimeError)
+ lambda { @receiver.send(:extend_object, @object) }.should raise_error(RuntimeError)
@object.should_not be_kind_of(@receiver)
end
end
diff --git a/spec/ruby/core/module/extended_spec.rb b/spec/ruby/core/module/extended_spec.rb
index c6300ffa0b..0a62dd9850 100644
--- a/spec/ruby/core/module/extended_spec.rb
+++ b/spec/ruby/core/module/extended_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#extended" do
it "is called when an object gets extended with self" do
diff --git a/spec/ruby/core/module/fixtures/autoload_callback.rb b/spec/ruby/core/module/fixtures/autoload_callback.rb
deleted file mode 100644
index 51d53eb580..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_callback.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-block = ScratchPad.recorded
-block.call
diff --git a/spec/ruby/core/module/fixtures/autoload_during_autoload.rb b/spec/ruby/core/module/fixtures/autoload_during_autoload.rb
deleted file mode 100644
index 5202bd8b23..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_during_autoload.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-block = ScratchPad.recorded
-ScratchPad.record(block.call)
-
-module ModuleSpecs::Autoload
- class DuringAutoload
- end
-end
diff --git a/spec/ruby/core/module/fixtures/autoload_during_require.rb b/spec/ruby/core/module/fixtures/autoload_during_require.rb
deleted file mode 100644
index 6fd81592e3..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_during_require.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module ModuleSpecs::Autoload
- class AutoloadDuringRequire
- end
-end
diff --git a/spec/ruby/core/module/fixtures/autoload_exception.rb b/spec/ruby/core/module/fixtures/autoload_exception.rb
deleted file mode 100644
index 09acf9f537..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_exception.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-ScratchPad.record(:exception)
-
-raise 'intentional error to test failure conditions during autoloading'
diff --git a/spec/ruby/core/module/fixtures/autoload_nested.rb b/spec/ruby/core/module/fixtures/autoload_nested.rb
deleted file mode 100644
index 073cec0dce..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_nested.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module ModuleSpecs::Autoload
- module GoodParent
- class Nested
- end
- end
-end
-
-ScratchPad.record(:loaded)
diff --git a/spec/ruby/core/module/fixtures/autoload_o.rb b/spec/ruby/core/module/fixtures/autoload_o.rb
index 7d88f969b2..6d54ddaf12 100644
--- a/spec/ruby/core/module/fixtures/autoload_o.rb
+++ b/spec/ruby/core/module/fixtures/autoload_o.rb
@@ -1,2 +1 @@
# does not define ModuleSpecs::Autoload::O
-ScratchPad << :loaded
diff --git a/spec/ruby/core/module/fixtures/autoload_overridden.rb b/spec/ruby/core/module/fixtures/autoload_overridden.rb
deleted file mode 100644
index 7062bcfabc..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_overridden.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module ModuleSpecs::Autoload
- Overridden = :overridden
-end
diff --git a/spec/ruby/core/module/fixtures/autoload_raise.rb b/spec/ruby/core/module/fixtures/autoload_raise.rb
deleted file mode 100644
index f6051e3ba2..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_raise.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-ScratchPad << :raise
-raise "exception during autoload"
diff --git a/spec/ruby/core/module/fixtures/autoload_required_directly.rb b/spec/ruby/core/module/fixtures/autoload_required_directly.rb
deleted file mode 100644
index bed60a71ec..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_required_directly.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-block = ScratchPad.recorded
-ScratchPad.record(block.call)
-
-module ModuleSpecs::Autoload
- class RequiredDirectly
- end
-end
diff --git a/spec/ruby/core/module/fixtures/autoload_required_directly_nested.rb b/spec/ruby/core/module/fixtures/autoload_required_directly_nested.rb
deleted file mode 100644
index a9f11c2188..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_required_directly_nested.rb
+++ /dev/null
@@ -1 +0,0 @@
-ScratchPad.recorded.call
diff --git a/spec/ruby/core/module/fixtures/autoload_scope.rb b/spec/ruby/core/module/fixtures/autoload_scope.rb
new file mode 100644
index 0000000000..04193687b5
--- /dev/null
+++ b/spec/ruby/core/module/fixtures/autoload_scope.rb
@@ -0,0 +1,8 @@
+module ModuleSpecs
+ module Autoload
+ class PP
+ class QQ
+ end
+ end
+ end
+end
diff --git a/spec/ruby/core/module/fixtures/autoload_self_during_require.rb b/spec/ruby/core/module/fixtures/autoload_self_during_require.rb
deleted file mode 100644
index f4a514a807..0000000000
--- a/spec/ruby/core/module/fixtures/autoload_self_during_require.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module ModuleSpecs::Autoload
- autoload :AutoloadSelfDuringRequire, __FILE__
- class AutoloadSelfDuringRequire
- end
-end
diff --git a/spec/ruby/core/module/fixtures/autoload_subclass.rb b/spec/ruby/core/module/fixtures/autoload_subclass.rb
index 8027fa3fcd..569972118c 100644
--- a/spec/ruby/core/module/fixtures/autoload_subclass.rb
+++ b/spec/ruby/core/module/fixtures/autoload_subclass.rb
@@ -1,10 +1,10 @@
-class CS_CONST_AUTOLOAD
+class YY
end
module ModuleSpecs
module Autoload
module XX
- class CS_CONST_AUTOLOAD < CS_CONST_AUTOLOAD
+ class YY < YY
end
end
end
diff --git a/spec/ruby/core/module/fixtures/classes.rb b/spec/ruby/core/module/fixtures/classes.rb
index 40777cdbbd..f93c39683e 100644
--- a/spec/ruby/core/module/fixtures/classes.rb
+++ b/spec/ruby/core/module/fixtures/classes.rb
@@ -6,9 +6,6 @@ module ModuleSpecs
CONST = :plain_constant
- class NamedClass
- end
-
module PrivConstModule
PRIVATE_CONSTANT = 1
private_constant :PRIVATE_CONSTANT
@@ -389,12 +386,6 @@ module ModuleSpecs
end
end
- class Parent
- end
-
- class Child < Parent
- end
-
module FromThread
module A
autoload :B, fixture(__FILE__, "autoload_empty.rb")
diff --git a/spec/ruby/core/module/fixtures/constants_autoload.rb b/spec/ruby/core/module/fixtures/constants_autoload.rb
deleted file mode 100644
index 8e9aa8de0c..0000000000
--- a/spec/ruby/core/module/fixtures/constants_autoload.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-autoload :CSAutoloadA, fixture(__FILE__, 'constants_autoload_a.rb')
-autoload :CSAutoloadB, fixture(__FILE__, 'constants_autoload_b.rb')
-autoload :CSAutoloadC, fixture(__FILE__, 'constants_autoload_c.rb')
-module CSAutoloadD
- autoload :InnerModule, fixture(__FILE__, 'constants_autoload_d.rb')
-end
diff --git a/spec/ruby/core/module/fixtures/constants_autoload_a.rb b/spec/ruby/core/module/fixtures/constants_autoload_a.rb
deleted file mode 100644
index 48d3b63681..0000000000
--- a/spec/ruby/core/module/fixtures/constants_autoload_a.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module CSAutoloadA
-end
diff --git a/spec/ruby/core/module/fixtures/constants_autoload_b.rb b/spec/ruby/core/module/fixtures/constants_autoload_b.rb
deleted file mode 100644
index 29cd742d03..0000000000
--- a/spec/ruby/core/module/fixtures/constants_autoload_b.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module CSAutoloadB
-end
diff --git a/spec/ruby/core/module/fixtures/constants_autoload_c.rb b/spec/ruby/core/module/fixtures/constants_autoload_c.rb
deleted file mode 100644
index 9d6a6bf4d7..0000000000
--- a/spec/ruby/core/module/fixtures/constants_autoload_c.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module CSAutoloadC
- CONST = 7
-end
diff --git a/spec/ruby/core/module/fixtures/constants_autoload_d.rb b/spec/ruby/core/module/fixtures/constants_autoload_d.rb
deleted file mode 100644
index 52d550bab0..0000000000
--- a/spec/ruby/core/module/fixtures/constants_autoload_d.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module CSAutoloadD
- module InnerModule
- end
-end
diff --git a/spec/ruby/core/module/fixtures/multi/foo.rb b/spec/ruby/core/module/fixtures/multi/foo.rb
deleted file mode 100644
index 549996f08f..0000000000
--- a/spec/ruby/core/module/fixtures/multi/foo.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module ModuleSpecs::Autoload
- module Foo
- autoload :Bar, 'foo/bar_baz'
- autoload :Baz, 'foo/bar_baz'
- end
-end
diff --git a/spec/ruby/core/module/fixtures/multi/foo/bar_baz.rb b/spec/ruby/core/module/fixtures/multi/foo/bar_baz.rb
deleted file mode 100644
index 53d3849e1f..0000000000
--- a/spec/ruby/core/module/fixtures/multi/foo/bar_baz.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'foo'
-
-module ModuleSpecs::Autoload
- module Foo
- class Bar
- end
-
- class Baz
- end
- end
-end
diff --git a/spec/ruby/core/module/freeze_spec.rb b/spec/ruby/core/module/freeze_spec.rb
index fd76141431..07a0ee0837 100644
--- a/spec/ruby/core/module/freeze_spec.rb
+++ b/spec/ruby/core/module/freeze_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#freeze" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/module/gt_spec.rb b/spec/ruby/core/module/gt_spec.rb
index b8a73c9ff9..73a6c80b69 100644
--- a/spec/ruby/core/module/gt_spec.rb
+++ b/spec/ruby/core/module/gt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#>" do
it "returns false if self is a subclass of or includes the given module" do
@@ -31,6 +31,6 @@ describe "Module#>" do
end
it "raises a TypeError if the argument is not a class/module" do
- -> { ModuleSpecs::Parent > mock('x') }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Parent > mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/gte_spec.rb b/spec/ruby/core/module/gte_spec.rb
index 18c60ba586..84758e2df6 100644
--- a/spec/ruby/core/module/gte_spec.rb
+++ b/spec/ruby/core/module/gte_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#>=" do
it "returns true if self is a superclass of, the same as or included by given module" do
@@ -28,6 +28,6 @@ describe "Module#>=" do
end
it "raises a TypeError if the argument is not a class/module" do
- -> { ModuleSpecs::Parent >= mock('x') }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Parent >= mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/include_spec.rb b/spec/ruby/core/module/include_spec.rb
index e7f99a5981..e5d19fc820 100644
--- a/spec/ruby/core/module/include_spec.rb
+++ b/spec/ruby/core/module/include_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#include" do
it "is a public method" do
@@ -40,11 +40,11 @@ describe "Module#include" do
end
it "raises a TypeError when the argument is not a Module" do
- -> { ModuleSpecs::Basic.include(Class.new) }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Basic.include(Class.new) }.should raise_error(TypeError)
end
it "does not raise a TypeError when the argument is an instance of a subclass of Module" do
- -> { ModuleSpecs::SubclassSpec.include(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
+ lambda { ModuleSpecs::SubclassSpec.include(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
end
it "imports constants to modules and classes" do
@@ -158,19 +158,31 @@ describe "Module#include" do
end
it "detects cyclic includes" do
- -> {
+ lambda {
module ModuleSpecs::M
include ModuleSpecs::M
end
}.should raise_error(ArgumentError)
end
- it "doesn't accept no-arguments" do
- -> {
- Module.new do
- include
- end
- }.should raise_error(ArgumentError)
+ ruby_version_is ''...'2.4' do
+ it "accepts no-arguments" do
+ lambda {
+ Module.new do
+ include
+ end
+ }.should_not raise_error
+ end
+ end
+
+ ruby_version_is '2.4' do
+ it "doesn't accept no-arguments" do
+ lambda {
+ Module.new do
+ include
+ end
+ }.should raise_error(ArgumentError)
+ end
end
it "returns the class it's included into" do
@@ -252,7 +264,7 @@ describe "Module#include?" do
end
it "raises a TypeError when no module was given" do
- -> { ModuleSpecs::Child.include?("Test") }.should raise_error(TypeError)
- -> { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Child.include?("Test") }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/included_modules_spec.rb b/spec/ruby/core/module/included_modules_spec.rb
index 40e20953f4..ff2dc434dd 100644
--- a/spec/ruby/core/module/included_modules_spec.rb
+++ b/spec/ruby/core/module/included_modules_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#included_modules" do
it "returns a list of modules included in self" do
diff --git a/spec/ruby/core/module/included_spec.rb b/spec/ruby/core/module/included_spec.rb
index f8dbad1d31..39a08b6ed8 100644
--- a/spec/ruby/core/module/included_spec.rb
+++ b/spec/ruby/core/module/included_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#included" do
it "is invoked when self is included in another module or class" do
diff --git a/spec/ruby/core/module/initialize_copy_spec.rb b/spec/ruby/core/module/initialize_copy_spec.rb
index 7ae48f85a9..85f1bbeb17 100644
--- a/spec/ruby/core/module/initialize_copy_spec.rb
+++ b/spec/ruby/core/module/initialize_copy_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module#initialize_copy" do
it "should retain singleton methods when duped" do
@@ -7,12 +7,4 @@ describe "Module#initialize_copy" do
end
mod.dup.methods(false).should == [:hello]
end
-
- # jruby/jruby#5245, https://bugs.ruby-lang.org/issues/3461
- it "should produce a duped module with inspectable class methods" do
- mod = Module.new
- def mod.hello
- end
- mod.dup.method(:hello).inspect.should =~ /Module.*hello/
- end
end
diff --git a/spec/ruby/core/module/initialize_spec.rb b/spec/ruby/core/module/initialize_spec.rb
index 99e41e4619..b32e0f5d2a 100644
--- a/spec/ruby/core/module/initialize_spec.rb
+++ b/spec/ruby/core/module/initialize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#initialize" do
it "accepts a block" do
diff --git a/spec/ruby/core/module/instance_method_spec.rb b/spec/ruby/core/module/instance_method_spec.rb
index b4d6a0d8c8..82e397b4bc 100644
--- a/spec/ruby/core/module/instance_method_spec.rb
+++ b/spec/ruby/core/module/instance_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#instance_method" do
before :all do
@@ -52,13 +52,13 @@ describe "Module#instance_method" do
end
it "raises a TypeError if not passed a symbol" do
- -> { Object.instance_method([]) }.should raise_error(TypeError)
- -> { Object.instance_method(0) }.should raise_error(TypeError)
+ lambda { Object.instance_method([]) }.should raise_error(TypeError)
+ lambda { Object.instance_method(0) }.should raise_error(TypeError)
end
it "raises a TypeError if the given name is not a string/symbol" do
- -> { Object.instance_method(nil) }.should raise_error(TypeError)
- -> { Object.instance_method(mock('x')) }.should raise_error(TypeError)
+ lambda { Object.instance_method(nil) }.should raise_error(TypeError)
+ lambda { Object.instance_method(mock('x')) }.should raise_error(TypeError)
end
it "raises a NameError if the method has been undefined" do
@@ -66,13 +66,13 @@ describe "Module#instance_method" do
child.send :undef_method, :foo
um = ModuleSpecs::InstanceMeth.instance_method(:foo)
um.should == @parent_um
- -> do
+ lambda do
child.instance_method(:foo)
end.should raise_error(NameError)
end
it "raises a NameError if the method does not exist" do
- -> { Object.instance_method(:missing) }.should raise_error(NameError)
+ lambda { Object.instance_method(:missing) }.should raise_error(NameError)
end
it "sets the NameError#name attribute to the name of the missing method" do
diff --git a/spec/ruby/core/module/instance_methods_spec.rb b/spec/ruby/core/module/instance_methods_spec.rb
index d2d38cdda2..289879cdbc 100644
--- a/spec/ruby/core/module/instance_methods_spec.rb
+++ b/spec/ruby/core/module/instance_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#instance_methods" do
it "does not return methods undefined in a superclass" do
diff --git a/spec/ruby/core/module/lt_spec.rb b/spec/ruby/core/module/lt_spec.rb
index d7771e07a8..ce0d25b5a2 100644
--- a/spec/ruby/core/module/lt_spec.rb
+++ b/spec/ruby/core/module/lt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#<" do
it "returns true if self is a subclass of or includes the given module" do
@@ -31,6 +31,6 @@ describe "Module#<" do
end
it "raises a TypeError if the argument is not a class/module" do
- -> { ModuleSpecs::Parent < mock('x') }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Parent < mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/lte_spec.rb b/spec/ruby/core/module/lte_spec.rb
index 7a0e8496b8..8a699b4714 100644
--- a/spec/ruby/core/module/lte_spec.rb
+++ b/spec/ruby/core/module/lte_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#<=" do
it "returns true if self is a subclass of, the same as or includes the given module" do
@@ -28,6 +28,6 @@ describe "Module#<=" do
end
it "raises a TypeError if the argument is not a class/module" do
- -> { ModuleSpecs::Parent <= mock('x') }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Parent <= mock('x') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/module/method_added_spec.rb b/spec/ruby/core/module/method_added_spec.rb
index e1b1eda430..643291be17 100644
--- a/spec/ruby/core/module/method_added_spec.rb
+++ b/spec/ruby/core/module/method_added_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#method_added" do
it "is a private instance method" do
diff --git a/spec/ruby/core/module/method_defined_spec.rb b/spec/ruby/core/module/method_defined_spec.rb
index c2a8702d97..d6206fa57e 100644
--- a/spec/ruby/core/module/method_defined_spec.rb
+++ b/spec/ruby/core/module/method_defined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#method_defined?" do
it "returns true if a public or private method with the given name is defined in self, self's ancestors or one of self's included modules" do
@@ -34,10 +34,10 @@ describe "Module#method_defined?" do
c = Class.new
o = mock('123')
- -> { c.method_defined?(o) }.should raise_error(TypeError)
+ lambda { c.method_defined?(o) }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- -> { c.method_defined?(o) }.should raise_error(TypeError)
+ lambda { c.method_defined?(o) }.should raise_error(TypeError)
end
it "converts the given name to a string using to_str" do
@@ -46,55 +46,4 @@ describe "Module#method_defined?" do
c.method_defined?(o).should == true
end
-
- ruby_version_is "2.6" do
- # works as method_defined?(method_name)
- describe "when passed true as a second optional argument" do
- it "performs a lookup in ancestors" do
- ModuleSpecs::Child.method_defined?(:public_child, true).should == true
- ModuleSpecs::Child.method_defined?(:protected_child, true).should == true
- ModuleSpecs::Child.method_defined?(:accessor_method, true).should == true
- ModuleSpecs::Child.method_defined?(:private_child, true).should == false
-
- # Defined in Parent
- ModuleSpecs::Child.method_defined?(:public_parent, true).should == true
- ModuleSpecs::Child.method_defined?(:protected_parent, true).should == true
- ModuleSpecs::Child.method_defined?(:private_parent, true).should == false
-
- # Defined in Module
- ModuleSpecs::Child.method_defined?(:public_module, true).should == true
- ModuleSpecs::Child.method_defined?(:protected_module, true).should == true
- ModuleSpecs::Child.method_defined?(:private_module, true).should == false
-
- # Defined in SuperModule
- ModuleSpecs::Child.method_defined?(:public_super_module, true).should == true
- ModuleSpecs::Child.method_defined?(:protected_super_module, true).should == true
- ModuleSpecs::Child.method_defined?(:private_super_module, true).should == false
- end
- end
-
- describe "when passed false as a second optional argument" do
- it "checks only the class itself" do
- ModuleSpecs::Child.method_defined?(:public_child, false).should == true
- ModuleSpecs::Child.method_defined?(:protected_child, false).should == true
- ModuleSpecs::Child.method_defined?(:accessor_method, false).should == true
- ModuleSpecs::Child.method_defined?(:private_child, false).should == false
-
- # Defined in Parent
- ModuleSpecs::Child.method_defined?(:public_parent, false).should == false
- ModuleSpecs::Child.method_defined?(:protected_parent, false).should == false
- ModuleSpecs::Child.method_defined?(:private_parent, false).should == false
-
- # Defined in Module
- ModuleSpecs::Child.method_defined?(:public_module, false).should == false
- ModuleSpecs::Child.method_defined?(:protected_module, false).should == false
- ModuleSpecs::Child.method_defined?(:private_module, false).should == false
-
- # Defined in SuperModule
- ModuleSpecs::Child.method_defined?(:public_super_module, false).should == false
- ModuleSpecs::Child.method_defined?(:protected_super_module, false).should == false
- ModuleSpecs::Child.method_defined?(:private_super_module, false).should == false
- end
- end
- end
end
diff --git a/spec/ruby/core/module/method_removed_spec.rb b/spec/ruby/core/module/method_removed_spec.rb
index 9b39eb77a6..4c1443cfaa 100644
--- a/spec/ruby/core/module/method_removed_spec.rb
+++ b/spec/ruby/core/module/method_removed_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#method_removed" do
it "is a private instance method" do
diff --git a/spec/ruby/core/module/method_undefined_spec.rb b/spec/ruby/core/module/method_undefined_spec.rb
index a94388fe0a..65001b9421 100644
--- a/spec/ruby/core/module/method_undefined_spec.rb
+++ b/spec/ruby/core/module/method_undefined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#method_undefined" do
it "is a private instance method" do
diff --git a/spec/ruby/core/module/module_eval_spec.rb b/spec/ruby/core/module/module_eval_spec.rb
index e9e9fda28d..2bef0e9abf 100644
--- a/spec/ruby/core/module/module_eval_spec.rb
+++ b/spec/ruby/core/module/module_eval_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/class_eval'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/class_eval', __FILE__)
describe "Module#module_eval" do
it_behaves_like :module_class_eval, :module_eval
diff --git a/spec/ruby/core/module/module_exec_spec.rb b/spec/ruby/core/module/module_exec_spec.rb
index 47cdf7ef52..77d74a083b 100644
--- a/spec/ruby/core/module/module_exec_spec.rb
+++ b/spec/ruby/core/module/module_exec_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/class_exec'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/class_exec', __FILE__)
describe "Module#module_exec" do
it_behaves_like :module_class_exec, :module_exec
diff --git a/spec/ruby/core/module/module_function_spec.rb b/spec/ruby/core/module/module_function_spec.rb
index 407237d48f..61509c8d03 100644
--- a/spec/ruby/core/module/module_function_spec.rb
+++ b/spec/ruby/core/module/module_function_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#module_function" do
it "is a private method" do
@@ -12,11 +12,11 @@ describe "Module#module_function" do
end
it "raises a TypeError if calling after rebinded to Class" do
- -> {
+ lambda {
Module.instance_method(:module_function).bind(Class.new).call
}.should raise_error(TypeError)
- -> {
+ lambda {
Module.instance_method(:module_function).bind(Class.new).call :foo
}.should raise_error(TypeError)
end
@@ -87,7 +87,7 @@ describe "Module#module_function with specific method names" do
o.respond_to?(:test).should == false
m.should have_private_instance_method(:test)
o.send(:test).should == "hello"
- -> { o.test }.should raise_error(NoMethodError)
+ lambda { o.test }.should raise_error(NoMethodError)
end
it "makes the new Module methods public" do
@@ -116,10 +116,10 @@ describe "Module#module_function with specific method names" do
it "raises a TypeError when the given names can't be converted to string using to_str" do
o = mock('123')
- -> { Module.new { module_function(o) } }.should raise_error(TypeError)
+ lambda { Module.new { module_function(o) } }.should raise_error(TypeError)
o.should_receive(:to_str).and_return(123)
- -> { Module.new { module_function(o) } }.should raise_error(TypeError)
+ lambda { Module.new { module_function(o) } }.should raise_error(TypeError)
end
it "can make accessible private methods" do # JRUBY-4214
diff --git a/spec/ruby/core/module/name_spec.rb b/spec/ruby/core/module/name_spec.rb
index 36a91f5be5..0727278591 100644
--- a/spec/ruby/core/module/name_spec.rb
+++ b/spec/ruby/core/module/name_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/module'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/module', __FILE__)
describe "Module#name" do
it "is nil for an anonymous module" do
@@ -15,34 +15,7 @@ describe "Module#name" do
it "is not nil for a nested module created with the module keyword" do
m = Module.new
module m::N; end
- m::N.name.should =~ /\A#<Module:0x[0-9a-f]+>::N\z/
- end
-
- it "changes when the module is reachable through a constant path" do
- m = Module.new
- module m::N; end
- m::N.name.should =~ /\A#<Module:0x\h+>::N\z/
- ModuleSpecs::Anonymous::WasAnnon = m::N
- m::N.name.should == "ModuleSpecs::Anonymous::WasAnnon"
- end
-
- it "is set after it is removed from a constant" do
- module ModuleSpecs
- module ModuleToRemove
- end
-
- mod = ModuleToRemove
- remove_const(:ModuleToRemove)
- mod.name.should == "ModuleSpecs::ModuleToRemove"
- end
- end
-
- it "is set after it is removed from a constant under an anonymous module" do
- m = Module.new
- module m::Child; end
- child = m::Child
- m.send(:remove_const, :Child)
- child.name.should =~ /\A#<Module:0x\h+>::Child\z/
+ m::N.name.should =~ /#<Module:0x[0-9a-f]+>::N/
end
it "is set when opened with the module keyword" do
@@ -67,15 +40,6 @@ describe "Module#name" do
m.name.should == "ModuleSpecs::Anonymous::B"
end
- it "is not modified when assigned to a different anonymous module" do
- m = Module.new
- module m::M; end
- first_name = m::M.name.dup
- module m::N; end
- m::N::F = m::M
- m::M.name.should == first_name
- end
-
# http://bugs.ruby-lang.org/issues/6067
it "is set with a conditional assignment to a nested constant" do
eval("ModuleSpecs::Anonymous::F ||= Module.new")
@@ -101,28 +65,4 @@ describe "Module#name" do
ModuleSpecs::Anonymous::E = m
m::N.name.should == "ModuleSpecs::Anonymous::E::N"
end
-
- ruby_version_is ""..."2.7" do
- it "returns a mutable string" do
- ModuleSpecs.name.frozen?.should be_false
- end
-
- it "returns a mutable string that when mutated does not modify the original module name" do
- ModuleSpecs.name << "foo"
-
- ModuleSpecs.name.should == "ModuleSpecs"
- end
- end
-
- ruby_version_is "2.7" do
- it "returns a frozen String" do
- ModuleSpecs.name.frozen?.should == true
- end
-
- it "always returns the same String for a given Module" do
- s1 = ModuleSpecs.name
- s2 = ModuleSpecs.name
- s1.should equal(s2)
- end
- end
end
diff --git a/spec/ruby/core/module/nesting_spec.rb b/spec/ruby/core/module/nesting_spec.rb
index d0611b3efe..0a86e5b8fc 100644
--- a/spec/ruby/core/module/nesting_spec.rb
+++ b/spec/ruby/core/module/nesting_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module::Nesting" do
diff --git a/spec/ruby/core/module/new_spec.rb b/spec/ruby/core/module/new_spec.rb
index da7f3b8720..21d3f954fa 100644
--- a/spec/ruby/core/module/new_spec.rb
+++ b/spec/ruby/core/module/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module.new" do
it "creates a new anonymous Module" do
diff --git a/spec/ruby/core/module/prepend_features_spec.rb b/spec/ruby/core/module/prepend_features_spec.rb
index 2d1fa713b7..6f341804d1 100644
--- a/spec/ruby/core/module/prepend_features_spec.rb
+++ b/spec/ruby/core/module/prepend_features_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#prepend_features" do
it "is a private method" do
@@ -23,23 +23,21 @@ describe "Module#prepend_features" do
end
it "raises an ArgumentError on a cyclic prepend" do
- -> {
+ lambda {
ModuleSpecs::CyclicPrepend.send(:prepend_features, ModuleSpecs::CyclicPrepend)
}.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "copies own tainted status to the given module" do
- other = Module.new
- Module.new.taint.send :prepend_features, other
- other.tainted?.should be_true
- end
+ it "copies own tainted status to the given module" do
+ other = Module.new
+ Module.new.taint.send :prepend_features, other
+ other.tainted?.should be_true
+ end
- it "copies own untrusted status to the given module" do
- other = Module.new
- Module.new.untrust.send :prepend_features, other
- other.untrusted?.should be_true
- end
+ it "copies own untrusted status to the given module" do
+ other = Module.new
+ Module.new.untrust.send :prepend_features, other
+ other.untrusted?.should be_true
end
it "clears caches of the given module" do
@@ -70,7 +68,7 @@ describe "Module#prepend_features" do
end
it "raises a TypeError if calling after rebinded to Class" do
- -> {
+ lambda {
Module.instance_method(:prepend_features).bind(Class.new).call Module.new
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/prepend_spec.rb b/spec/ruby/core/module/prepend_spec.rb
index e143f51673..c0cce616a2 100644
--- a/spec/ruby/core/module/prepend_spec.rb
+++ b/spec/ruby/core/module/prepend_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#prepend" do
it "is a public method" do
@@ -37,11 +37,11 @@ describe "Module#prepend" do
end
it "raises a TypeError when the argument is not a Module" do
- -> { ModuleSpecs::Basic.prepend(Class.new) }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Basic.prepend(Class.new) }.should raise_error(TypeError)
end
it "does not raise a TypeError when the argument is an instance of a subclass of Module" do
- -> { ModuleSpecs::SubclassSpec.prepend(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
+ lambda { ModuleSpecs::SubclassSpec.prepend(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
end
it "imports constants" do
@@ -104,18 +104,6 @@ describe "Module#prepend" do
c.new.alias.should == :m
end
- it "reports the class for the owner of an aliased method on the class" do
- m = Module.new
- c = Class.new { prepend(m); def meth; :c end; alias_method :alias, :meth }
- c.instance_method(:alias).owner.should == c
- end
-
- it "reports the class for the owner of a method aliased from the prepended module" do
- m = Module.new { def meth; :m end }
- c = Class.new { prepend(m); alias_method :alias, :meth }
- c.instance_method(:alias).owner.should == c
- end
-
it "sees an instance of a prepended class as kind of the prepended module" do
m = Module.new
c = Class.new { prepend(m) }
@@ -204,7 +192,7 @@ describe "Module#prepend" do
super << :class
end
end
- -> { c.new.chain }.should raise_error(NoMethodError)
+ lambda { c.new.chain }.should raise_error(NoMethodError)
end
it "calls prepended after prepend_features" do
@@ -224,19 +212,31 @@ describe "Module#prepend" do
end
it "detects cyclic prepends" do
- -> {
+ lambda {
module ModuleSpecs::P
prepend ModuleSpecs::P
end
}.should raise_error(ArgumentError)
end
- it "doesn't accept no-arguments" do
- -> {
- Module.new do
- prepend
- end
- }.should raise_error(ArgumentError)
+ ruby_version_is ''...'2.4' do
+ it "accepts no-arguments" do
+ lambda {
+ Module.new do
+ prepend
+ end
+ }.should_not raise_error
+ end
+ end
+
+ ruby_version_is '2.4' do
+ it "doesn't accept no-arguments" do
+ lambda {
+ Module.new do
+ prepend
+ end
+ }.should raise_error(ArgumentError)
+ end
end
it "returns the class it's included into" do
diff --git a/spec/ruby/core/module/prepended_spec.rb b/spec/ruby/core/module/prepended_spec.rb
index bd95d8fd05..ed8e473941 100644
--- a/spec/ruby/core/module/prepended_spec.rb
+++ b/spec/ruby/core/module/prepended_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: us-ascii -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module#prepended" do
before :each do
diff --git a/spec/ruby/core/module/private_class_method_spec.rb b/spec/ruby/core/module/private_class_method_spec.rb
index e35b50d986..ec10bcbf87 100644
--- a/spec/ruby/core/module/private_class_method_spec.rb
+++ b/spec/ruby/core/module/private_class_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#private_class_method" do
before :each do
@@ -22,11 +22,11 @@ describe "Module#private_class_method" do
it "makes an existing class method private" do
ModuleSpecs::Parent.private_method_1.should == nil
ModuleSpecs::Parent.private_class_method :private_method_1
- -> { ModuleSpecs::Parent.private_method_1 }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Parent.private_method_1 }.should raise_error(NoMethodError)
# Technically above we're testing the Singleton classes, class method(right?).
# Try a "real" class method set private.
- -> { ModuleSpecs::Parent.private_method }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Parent.private_method }.should raise_error(NoMethodError)
end
it "makes an existing class method private up the inheritance tree" do
@@ -34,8 +34,8 @@ describe "Module#private_class_method" do
ModuleSpecs::Child.private_method_1.should == nil
ModuleSpecs::Child.private_class_method :private_method_1
- -> { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
- -> { ModuleSpecs::Child.private_method }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Child.private_method }.should raise_error(NoMethodError)
end
it "accepts more than one method at a time" do
@@ -44,12 +44,12 @@ describe "Module#private_class_method" do
ModuleSpecs::Child.private_class_method :private_method_1, :private_method_2
- -> { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
- -> { ModuleSpecs::Child.private_method_2 }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Child.private_method_2 }.should raise_error(NoMethodError)
end
it "raises a NameError if class method doesn't exist" do
- -> do
+ lambda do
ModuleSpecs.private_class_method :no_method_here
end.should raise_error(NameError)
end
@@ -59,11 +59,11 @@ describe "Module#private_class_method" do
def self.foo() "foo" end
private_class_method :foo
end
- -> { c.foo }.should raise_error(NoMethodError)
+ lambda { c.foo }.should raise_error(NoMethodError)
end
it "raises a NameError when the given name is not a method" do
- -> do
+ lambda do
Class.new do
private_class_method :foo
end
@@ -71,7 +71,7 @@ describe "Module#private_class_method" do
end
it "raises a NameError when the given name is an instance method" do
- -> do
+ lambda do
Class.new do
def foo() "foo" end
private_class_method :foo
diff --git a/spec/ruby/core/module/private_constant_spec.rb b/spec/ruby/core/module/private_constant_spec.rb
index 3a91b3c3cd..af0b1facdd 100644
--- a/spec/ruby/core/module/private_constant_spec.rb
+++ b/spec/ruby/core/module/private_constant_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module#private_constant" do
it "can only be passed constant names defined in the target (self) module" do
@@ -6,7 +6,7 @@ describe "Module#private_constant" do
cls1.const_set :Foo, true
cls2 = Class.new(cls1)
- -> do
+ lambda do
cls2.send :private_constant, :Foo
end.should raise_error(NameError)
end
@@ -16,7 +16,7 @@ describe "Module#private_constant" do
cls.const_set :Foo, true
cls.send :private_constant, "Foo"
- -> { cls::Foo }.should raise_error(NameError)
+ lambda { cls::Foo }.should raise_error(NameError)
end
it "accepts multiple names" do
@@ -26,7 +26,7 @@ describe "Module#private_constant" do
mod.send :private_constant, :Foo, :Bar
- -> {mod::Foo}.should raise_error(NameError)
- -> {mod::Bar}.should raise_error(NameError)
+ lambda {mod::Foo}.should raise_error(NameError)
+ lambda {mod::Bar}.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/module/private_instance_methods_spec.rb b/spec/ruby/core/module/private_instance_methods_spec.rb
index cce0f001bf..f5c4c3a0f9 100644
--- a/spec/ruby/core/module/private_instance_methods_spec.rb
+++ b/spec/ruby/core/module/private_instance_methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../fixtures/reflection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
# TODO: rewrite
describe "Module#private_instance_methods" do
diff --git a/spec/ruby/core/module/private_method_defined_spec.rb b/spec/ruby/core/module/private_method_defined_spec.rb
index 515542d9df..b3e1814056 100644
--- a/spec/ruby/core/module/private_method_defined_spec.rb
+++ b/spec/ruby/core/module/private_method_defined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#private_method_defined?" do
it "returns true if the named private method is defined by module or its ancestors" do
@@ -32,25 +32,25 @@ describe "Module#private_method_defined?" do
end
it "raises a TypeError if passed a Fixnum" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.private_method_defined?(1)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.private_method_defined?(nil)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed false" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.private_method_defined?(false)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not defined #to_str" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.private_method_defined?(mock('x'))
end.should raise_error(TypeError)
end
@@ -59,7 +59,7 @@ describe "Module#private_method_defined?" do
sym = mock('symbol')
def sym.to_sym() :private_3 end
- -> do
+ lambda do
ModuleSpecs::CountsMixin.private_method_defined?(sym)
end.should raise_error(TypeError)
end
@@ -69,54 +69,4 @@ describe "Module#private_method_defined?" do
def str.to_str() 'private_3' end
ModuleSpecs::CountsMixin.private_method_defined?(str).should == true
end
-
- ruby_version_is "2.6" do
- describe "when passed true as a second optional argument" do
- it "performs a lookup in ancestors" do
- ModuleSpecs::Child.private_method_defined?(:public_child, true).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_child, true).should == false
- ModuleSpecs::Child.private_method_defined?(:accessor_method, true).should == false
- ModuleSpecs::Child.private_method_defined?(:private_child, true).should == true
-
- # Defined in Parent
- ModuleSpecs::Child.private_method_defined?(:public_parent, true).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_parent, true).should == false
- ModuleSpecs::Child.private_method_defined?(:private_parent, true).should == true
-
- # Defined in Module
- ModuleSpecs::Child.private_method_defined?(:public_module, true).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_module, true).should == false
- ModuleSpecs::Child.private_method_defined?(:private_module, true).should == true
-
- # Defined in SuperModule
- ModuleSpecs::Child.private_method_defined?(:public_super_module, true).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_super_module, true).should == false
- ModuleSpecs::Child.private_method_defined?(:private_super_module, true).should == true
- end
- end
-
- describe "when passed false as a second optional argument" do
- it "checks only the class itself" do
- ModuleSpecs::Child.private_method_defined?(:public_child, false).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_child, false).should == false
- ModuleSpecs::Child.private_method_defined?(:accessor_method, false).should == false
- ModuleSpecs::Child.private_method_defined?(:private_child, false).should == true
-
- # Defined in Parent
- ModuleSpecs::Child.private_method_defined?(:public_parent, false).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_parent, false).should == false
- ModuleSpecs::Child.private_method_defined?(:private_parent, false).should == false
-
- # Defined in Module
- ModuleSpecs::Child.private_method_defined?(:public_module, false).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_module, false).should == false
- ModuleSpecs::Child.private_method_defined?(:private_module, false).should == false
-
- # Defined in SuperModule
- ModuleSpecs::Child.private_method_defined?(:public_super_module, false).should == false
- ModuleSpecs::Child.private_method_defined?(:protected_super_module, false).should == false
- ModuleSpecs::Child.private_method_defined?(:private_super_module, false).should == false
- end
- end
- end
end
diff --git a/spec/ruby/core/module/private_spec.rb b/spec/ruby/core/module/private_spec.rb
index e893c24f38..07b8f4c781 100644
--- a/spec/ruby/core/module/private_spec.rb
+++ b/spec/ruby/core/module/private_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_visibility'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_visibility', __FILE__)
describe "Module#private" do
it_behaves_like :set_visibility, :private
@@ -17,7 +17,7 @@ describe "Module#private" do
private :foo
end
- -> { obj.foo }.should raise_error(NoMethodError)
+ lambda { obj.foo }.should raise_error(NoMethodError)
end
it "makes a public Object instance method private in a new module" do
@@ -47,7 +47,7 @@ describe "Module#private" do
end
it "raises a NameError when given an undefined name" do
- -> do
+ lambda do
Module.new.send(:private, :undefined)
end.should raise_error(NameError)
end
@@ -67,7 +67,7 @@ describe "Module#private" do
end
base.new.wrapped.should == 1
- -> do
+ lambda do
klass.new.wrapped
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/protected_instance_methods_spec.rb b/spec/ruby/core/module/protected_instance_methods_spec.rb
index 78ce7e788f..d5c9e5cd33 100644
--- a/spec/ruby/core/module/protected_instance_methods_spec.rb
+++ b/spec/ruby/core/module/protected_instance_methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../fixtures/reflection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
# TODO: rewrite
describe "Module#protected_instance_methods" do
diff --git a/spec/ruby/core/module/protected_method_defined_spec.rb b/spec/ruby/core/module/protected_method_defined_spec.rb
index 7be7bdd3c9..af08efae81 100644
--- a/spec/ruby/core/module/protected_method_defined_spec.rb
+++ b/spec/ruby/core/module/protected_method_defined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#protected_method_defined?" do
it "returns true if the named protected method is defined by module or its ancestors" do
@@ -32,25 +32,25 @@ describe "Module#protected_method_defined?" do
end
it "raises a TypeError if passed a Fixnum" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.protected_method_defined?(1)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.protected_method_defined?(nil)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed false" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.protected_method_defined?(false)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not defined #to_str" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.protected_method_defined?(mock('x'))
end.should raise_error(TypeError)
end
@@ -59,7 +59,7 @@ describe "Module#protected_method_defined?" do
sym = mock('symbol')
def sym.to_sym() :protected_3 end
- -> do
+ lambda do
ModuleSpecs::CountsMixin.protected_method_defined?(sym)
end.should raise_error(TypeError)
end
@@ -69,54 +69,4 @@ describe "Module#protected_method_defined?" do
str.should_receive(:to_str).and_return("protected_3")
ModuleSpecs::CountsMixin.protected_method_defined?(str).should == true
end
-
- ruby_version_is "2.6" do
- describe "when passed true as a second optional argument" do
- it "performs a lookup in ancestors" do
- ModuleSpecs::Child.protected_method_defined?(:public_child, true).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_child, true).should == true
- ModuleSpecs::Child.protected_method_defined?(:accessor_method, true).should == false
- ModuleSpecs::Child.protected_method_defined?(:private_child, true).should == false
-
- # Defined in Parent
- ModuleSpecs::Child.protected_method_defined?(:public_parent, true).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_parent, true).should == true
- ModuleSpecs::Child.protected_method_defined?(:private_parent, true).should == false
-
- # Defined in Module
- ModuleSpecs::Child.protected_method_defined?(:public_module, true).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_module, true).should == true
- ModuleSpecs::Child.protected_method_defined?(:private_module, true).should == false
-
- # Defined in SuperModule
- ModuleSpecs::Child.protected_method_defined?(:public_super_module, true).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_super_module, true).should == true
- ModuleSpecs::Child.protected_method_defined?(:private_super_module, true).should == false
- end
- end
-
- describe "when passed false as a second optional argument" do
- it "checks only the class itself" do
- ModuleSpecs::Child.protected_method_defined?(:public_child, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_child, false).should == true
- ModuleSpecs::Child.protected_method_defined?(:accessor_method, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:private_child, false).should == false
-
- # Defined in Parent
- ModuleSpecs::Child.protected_method_defined?(:public_parent, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_parent, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:private_parent, false).should == false
-
- # Defined in Module
- ModuleSpecs::Child.protected_method_defined?(:public_module, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_module, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:private_module, false).should == false
-
- # Defined in SuperModule
- ModuleSpecs::Child.protected_method_defined?(:public_super_module, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:protected_super_module, false).should == false
- ModuleSpecs::Child.protected_method_defined?(:private_super_module, false).should == false
- end
- end
- end
end
diff --git a/spec/ruby/core/module/protected_spec.rb b/spec/ruby/core/module/protected_spec.rb
index aa04a42fb8..7e77138c12 100644
--- a/spec/ruby/core/module/protected_spec.rb
+++ b/spec/ruby/core/module/protected_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_visibility'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_visibility', __FILE__)
describe "Module#protected" do
before :each do
@@ -18,7 +18,7 @@ describe "Module#protected" do
protected :protected_method_1
end
- -> { ModuleSpecs::Parent.protected_method_1 }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Parent.protected_method_1 }.should raise_error(NoMethodError)
end
it "makes a public Object instance method protected in a new module" do
@@ -48,8 +48,9 @@ describe "Module#protected" do
end
it "raises a NameError when given an undefined name" do
- -> do
+ lambda do
Module.new.send(:protected, :undefined)
end.should raise_error(NameError)
end
end
+
diff --git a/spec/ruby/core/module/public_class_method_spec.rb b/spec/ruby/core/module/public_class_method_spec.rb
index c09cc64863..2c909b1223 100644
--- a/spec/ruby/core/module/public_class_method_spec.rb
+++ b/spec/ruby/core/module/public_class_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#public_class_method" do
before :each do
@@ -18,7 +18,7 @@ describe "Module#public_class_method" do
end
it "makes an existing class method public" do
- -> { ModuleSpecs::Parent.public_method_1 }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Parent.public_method_1 }.should raise_error(NoMethodError)
ModuleSpecs::Parent.public_class_method :public_method_1
ModuleSpecs::Parent.public_method_1.should == nil
@@ -29,7 +29,7 @@ describe "Module#public_class_method" do
it "makes an existing class method public up the inheritance tree" do
ModuleSpecs::Child.private_class_method :public_method_1
- -> { ModuleSpecs::Child.public_method_1 }.should raise_error(NoMethodError)
+ lambda { ModuleSpecs::Child.public_method_1 }.should raise_error(NoMethodError)
ModuleSpecs::Child.public_class_method :public_method_1
ModuleSpecs::Child.public_method_1.should == nil
@@ -37,8 +37,8 @@ describe "Module#public_class_method" do
end
it "accepts more than one method at a time" do
- -> { ModuleSpecs::Parent.public_method_1 }.should raise_error(NameError)
- -> { ModuleSpecs::Parent.public_method_2 }.should raise_error(NameError)
+ lambda { ModuleSpecs::Parent.public_method_1 }.should raise_error(NameError)
+ lambda { ModuleSpecs::Parent.public_method_2 }.should raise_error(NameError)
ModuleSpecs::Child.public_class_method :public_method_1, :public_method_2
@@ -47,7 +47,7 @@ describe "Module#public_class_method" do
end
it "raises a NameError if class method doesn't exist" do
- -> do
+ lambda do
ModuleSpecs.public_class_method :no_method_here
end.should raise_error(NameError)
end
@@ -62,7 +62,7 @@ describe "Module#public_class_method" do
end
it "raises a NameError when the given name is not a method" do
- -> do
+ lambda do
Class.new do
public_class_method :foo
end
@@ -70,7 +70,7 @@ describe "Module#public_class_method" do
end
it "raises a NameError when the given name is an instance method" do
- -> do
+ lambda do
Class.new do
def foo() "foo" end
public_class_method :foo
diff --git a/spec/ruby/core/module/public_constant_spec.rb b/spec/ruby/core/module/public_constant_spec.rb
index e624d45fd2..cbf51a6df6 100644
--- a/spec/ruby/core/module/public_constant_spec.rb
+++ b/spec/ruby/core/module/public_constant_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module#public_constant" do
it "can only be passed constant names defined in the target (self) module" do
@@ -6,7 +6,7 @@ describe "Module#public_constant" do
cls1.const_set :Foo, true
cls2 = Class.new(cls1)
- -> do
+ lambda do
cls2.send :public_constant, :Foo
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/public_instance_method_spec.rb b/spec/ruby/core/module/public_instance_method_spec.rb
index ba19ad0404..c1e94c5fed 100644
--- a/spec/ruby/core/module/public_instance_method_spec.rb
+++ b/spec/ruby/core/module/public_instance_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#public_instance_method" do
it "is a public method" do
@@ -28,29 +28,29 @@ describe "Module#public_instance_method" do
end
it "raises a TypeError when given a name is not Symbol or String" do
- -> { Module.new.public_instance_method(nil) }.should raise_error(TypeError)
+ lambda { Module.new.public_instance_method(nil) }.should raise_error(TypeError)
end
it "raises a NameError when given a protected method name" do
- -> do
+ lambda do
ModuleSpecs::Basic.public_instance_method(:protected_module)
end.should raise_error(NameError)
end
it "raises a NameError if the method is private" do
- -> do
+ lambda do
ModuleSpecs::Basic.public_instance_method(:private_module)
end.should raise_error(NameError)
end
it "raises a NameError if the method has been undefined" do
- -> do
+ lambda do
ModuleSpecs::Parent.public_instance_method(:undefed_method)
end.should raise_error(NameError)
end
it "raises a NameError if the method does not exist" do
- -> do
+ lambda do
Module.new.public_instance_method(:missing)
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/public_instance_methods_spec.rb b/spec/ruby/core/module/public_instance_methods_spec.rb
index ae7d9b5ffb..14453109c3 100644
--- a/spec/ruby/core/module/public_instance_methods_spec.rb
+++ b/spec/ruby/core/module/public_instance_methods_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../fixtures/reflection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../fixtures/reflection', __FILE__)
# TODO: rewrite
diff --git a/spec/ruby/core/module/public_method_defined_spec.rb b/spec/ruby/core/module/public_method_defined_spec.rb
index d2fcfd1e72..329778ac15 100644
--- a/spec/ruby/core/module/public_method_defined_spec.rb
+++ b/spec/ruby/core/module/public_method_defined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#public_method_defined?" do
it "returns true if the named public method is defined by module or its ancestors" do
@@ -32,25 +32,25 @@ describe "Module#public_method_defined?" do
end
it "raises a TypeError if passed a Fixnum" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.public_method_defined?(1)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed nil" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.public_method_defined?(nil)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed false" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.public_method_defined?(false)
end.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not defined #to_str" do
- -> do
+ lambda do
ModuleSpecs::CountsMixin.public_method_defined?(mock('x'))
end.should raise_error(TypeError)
end
@@ -59,7 +59,7 @@ describe "Module#public_method_defined?" do
sym = mock('symbol')
def sym.to_sym() :public_3 end
- -> do
+ lambda do
ModuleSpecs::CountsMixin.public_method_defined?(sym)
end.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/module/public_spec.rb b/spec/ruby/core/module/public_spec.rb
index e7059f6aa6..8507689752 100644
--- a/spec/ruby/core/module/public_spec.rb
+++ b/spec/ruby/core/module/public_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_visibility'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_visibility', __FILE__)
describe "Module#public" do
it_behaves_like :set_visibility, :public
@@ -37,7 +37,7 @@ describe "Module#public" do
end
it "raises a NameError when given an undefined name" do
- -> do
+ lambda do
Module.new.send(:public, :undefined)
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb
index 66c19ddb66..ca7db0c2b6 100644
--- a/spec/ruby/core/module/refine_spec.rb
+++ b/spec/ruby/core/module/refine_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/refine'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/refine', __FILE__)
describe "Module#refine" do
it "runs its block in an anonymous module" do
@@ -59,7 +59,7 @@ describe "Module#refine" do
end
it "raises ArgumentError if not passed an argument" do
- -> do
+ lambda do
Module.new do
refine {}
end
@@ -67,28 +67,42 @@ describe "Module#refine" do
end
it "raises TypeError if not passed a class" do
- -> do
+ lambda do
Module.new do
refine("foo") {}
end
end.should raise_error(TypeError)
end
- it "accepts a module as argument" do
- inner_self = nil
- Module.new do
- refine(Enumerable) do
- def blah
+ ruby_version_is "" ... "2.4" do
+ it "raises TypeError if passed a module" do
+ lambda do
+ Module.new do
+ refine(Enumerable) {}
end
- inner_self = self
- end
+ end.should raise_error(TypeError)
end
+ end
- inner_self.public_instance_methods.should include(:blah)
+ quarantine! do # https://bugs.ruby-lang.org/issues/14070
+ ruby_version_is "2.4" do
+ it "accepts a module as argument" do
+ inner_self = nil
+ Module.new do
+ refine(Enumerable) do
+ def blah
+ end
+ inner_self = self
+ end
+ end
+
+ inner_self.public_instance_methods.should include(:blah)
+ end
+ end
end
it "raises ArgumentError if not given a block" do
- -> do
+ lambda do
Module.new do
refine String
end
@@ -109,7 +123,7 @@ describe "Module#refine" do
it "doesn't apply refinements outside the refine block" do
Module.new do
refine(String) {def foo; "foo"; end}
- -> {
+ -> () {
"hello".foo
}.should raise_error(NoMethodError)
end
@@ -120,7 +134,7 @@ describe "Module#refine" do
refine(String) {def foo; 'foo'; end}
end
- -> {"hello".foo}.should raise_error(NoMethodError)
+ lambda {"hello".foo}.should raise_error(NoMethodError)
end
# When defining multiple refinements in the same module,
@@ -177,7 +191,7 @@ describe "Module#refine" do
result = nil
- -> {
+ -> () {
Module.new do
using refinery_integer
using refinery_array
@@ -307,58 +321,60 @@ describe "Module#refine" do
end
context "for methods accessed indirectly" do
- it "is honored by Kernel#send" do
- refinement = Module.new do
- refine ModuleSpecs::ClassWithFoo do
- def foo; "foo from refinement"; end
+ ruby_version_is "" ... "2.4" do
+ it "is not honored by Kernel#send" do
+ refinement = Module.new do
+ refine ModuleSpecs::ClassWithFoo do
+ def foo; "foo from refinement"; end
+ end
end
- end
- result = nil
- Module.new do
- using refinement
- result = ModuleSpecs::ClassWithFoo.new.send :foo
+ result = nil
+ Module.new do
+ using refinement
+ result = ModuleSpecs::ClassWithFoo.new.send :foo
+ end
+
+ result.should == "foo"
end
- result.should == "foo from refinement"
- end
+ it "is not honored by BasicObject#__send__" do
+ refinement = Module.new do
+ refine ModuleSpecs::ClassWithFoo do
+ def foo; "foo from refinement"; end
+ end
+ end
- it "is honored by BasicObject#__send__" do
- refinement = Module.new do
- refine ModuleSpecs::ClassWithFoo do
- def foo; "foo from refinement"; end
+ result = nil
+ Module.new do
+ using refinement
+ result = ModuleSpecs::ClassWithFoo.new.__send__ :foo
end
- end
- result = nil
- Module.new do
- using refinement
- result = ModuleSpecs::ClassWithFoo.new.__send__ :foo
+ result.should == "foo"
end
- result.should == "foo from refinement"
- end
-
- it "is honored by Symbol#to_proc" do
- refinement = Module.new do
- refine Integer do
- def to_s
- "(#{super})"
+ it "is not honored by Symbol#to_proc" do
+ refinement = Module.new do
+ refine Integer do
+ def to_s
+ "(#{super})"
+ end
end
end
- end
- result = nil
- Module.new do
- using refinement
- result = [1, 2, 3].map(&:to_s)
- end
+ result = nil
+ Module.new do
+ using refinement
+ result = [1, 2, 3].map(&:to_s)
+ end
- result.should == ["(1)", "(2)", "(3)"]
+ result.should == ["1", "2", "3"]
+ end
end
- ruby_version_is "" ... "2.6" do
- it "is not honored by Kernel#public_send" do
+ ruby_version_is "2.4" do
+ it "is honored by Kernel#send" do
refinement = Module.new do
refine ModuleSpecs::ClassWithFoo do
def foo; "foo from refinement"; end
@@ -368,15 +384,13 @@ describe "Module#refine" do
result = nil
Module.new do
using refinement
- result = ModuleSpecs::ClassWithFoo.new.public_send :foo
+ result = ModuleSpecs::ClassWithFoo.new.send :foo
end
- result.should == "foo"
+ result.should == "foo from refinement"
end
- end
- ruby_version_is "2.6" do
- it "is honored by Kernel#public_send" do
+ it "is honored by BasicObject#__send__" do
refinement = Module.new do
refine ModuleSpecs::ClassWithFoo do
def foo; "foo from refinement"; end
@@ -386,11 +400,29 @@ describe "Module#refine" do
result = nil
Module.new do
using refinement
- result = ModuleSpecs::ClassWithFoo.new.public_send :foo
+ result = ModuleSpecs::ClassWithFoo.new.__send__ :foo
end
result.should == "foo from refinement"
end
+
+ it "is honored by Symbol#to_proc" do
+ refinement = Module.new do
+ refine Integer do
+ def to_s
+ "(#{super})"
+ end
+ end
+ end
+
+ result = nil
+ Module.new do
+ using refinement
+ result = [1, 2, 3].map(&:to_s)
+ end
+
+ result.should == ["(1)", "(2)", "(3)"]
+ end
end
ruby_version_is "" ... "2.5" do
@@ -458,155 +490,37 @@ describe "Module#refine" do
result.should == "hello from refinement"
end
- ruby_version_is "" ... "2.7" do
- it "is not honored by Kernel#method" do
- klass = Class.new
- refinement = Module.new do
- refine klass do
- def foo; end
- end
- end
-
- -> {
- Module.new do
- using refinement
- klass.new.method(:foo)
- end
- }.should raise_error(NameError, /undefined method `foo'/)
- end
- end
-
- ruby_version_is "2.7" do
- it "is honored by Kernel#method" do
- klass = Class.new
- refinement = Module.new do
- refine klass do
- def foo; end
- end
- end
-
- result = nil
- Module.new do
- using refinement
- result = klass.new.method(:foo).class
- end
-
- result.should == Method
- end
- end
-
- ruby_version_is "" ... "2.7" do
- it "is not honored by Kernel#instance_method" do
- klass = Class.new
- refinement = Module.new do
- refine klass do
- def foo; end
- end
- end
-
- -> {
- Module.new do
- using refinement
- klass.instance_method(:foo)
- end
- }.should raise_error(NameError, /undefined method `foo'/)
- end
- end
-
- ruby_version_is "2.7" do
- it "is honored by Kernel#method" do
- klass = Class.new
- refinement = Module.new do
- refine klass do
- def foo; end
- end
- end
-
- result = nil
- Module.new do
- using refinement
- result = klass.instance_method(:foo).class
+ it "is not honored by Kernel#method" do
+ klass = Class.new
+ refinement = Module.new do
+ refine klass do
+ def foo; end
end
-
- result.should == UnboundMethod
end
- end
- ruby_version_is "" ... "2.6" do
- it "is not honored by Kernel#respond_to?" do
- klass = Class.new
- refinement = Module.new do
- refine klass do
- def foo; end
- end
- end
-
- result = nil
+ -> {
Module.new do
using refinement
- result = klass.new.respond_to?(:foo)
+ klass.new.method(:foo)
end
-
- result.should == false
- end
+ }.should raise_error(NameError, /undefined method `foo'/)
end
- ruby_version_is "2.6" do
- it "is honored by Kernel#respond_to?" do
- klass = Class.new
- refinement = Module.new do
- refine klass do
- def foo; end
- end
- end
-
- result = nil
- Module.new do
- using refinement
- result = klass.new.respond_to?(:foo)
+ it "is not honored by Kernel#respond_to?" do
+ klass = Class.new
+ refinement = Module.new do
+ refine klass do
+ def foo; end
end
-
- result.should == true
end
- end
-
- ruby_version_is ""..."2.6" do
- it "is not honored by &" do
- refinement = Module.new do
- refine String do
- def to_proc(*args)
- -> * { 'foo' }
- end
- end
- end
- -> do
- Module.new do
- using refinement
- ["hola"].map(&"upcase")
- end
- end.should raise_error(TypeError, /wrong argument type String \(expected Proc\)/)
+ result = nil
+ Module.new do
+ using refinement
+ result = klass.new.respond_to?(:foo)
end
- end
- ruby_version_is "2.6" do
- it "is honored by &" do
- refinement = Module.new do
- refine String do
- def to_proc(*args)
- -> * { 'foo' }
- end
- end
- end
-
- result = nil
- Module.new do
- using refinement
- result = ["hola"].map(&"upcase")
- end
-
- result.should == ['foo']
- end
+ result.should == false
end
end
@@ -680,30 +594,6 @@ describe "Module#refine" do
end
end
- it 'and alias aliases a method within a refinement module, but not outside it' do
- Module.new do
- using Module.new {
- refine Array do
- alias :orig_count :count
- end
- }
- [1,2].orig_count.should == 2
- end
- -> { [1,2].orig_count }.should raise_error(NoMethodError)
- end
-
- it 'and alias_method aliases a method within a refinement module, but not outside it' do
- Module.new do
- using Module.new {
- refine Array do
- alias_method :orig_count, :count
- end
- }
- [1,2].orig_count.should == 2
- end
- -> { [1,2].orig_count }.should raise_error(NoMethodError)
- end
-
# Refinements are inherited by module inclusion.
# That is, using activates all refinements in the ancestors of the specified module.
# Refinements in a descendant have priority over refinements in an ancestor.
@@ -764,19 +654,4 @@ describe "Module#refine" do
result.should == "hello from refinement"
end
end
-
- it 'does not list methods defined only in refinement' do
- refine_object = Module.new do
- refine Object do
- def refinement_only_method
- end
- end
- end
- spec = self
- klass = Class.new { instance_methods.should_not spec.send(:include, :refinement_only_method) }
- instance = klass.new
- instance.methods.should_not include :refinement_only_method
- instance.respond_to?(:refinement_only_method).should == false
- -> { instance.method :refinement_only_method }.should raise_error(NameError)
- end
end
diff --git a/spec/ruby/core/module/remove_class_variable_spec.rb b/spec/ruby/core/module/remove_class_variable_spec.rb
index ab9514adf6..adf2c1d1f8 100644
--- a/spec/ruby/core/module/remove_class_variable_spec.rb
+++ b/spec/ruby/core/module/remove_class_variable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#remove_class_variable" do
it "removes class variable" do
@@ -23,19 +23,19 @@ describe "Module#remove_class_variable" do
it "raises a NameError when removing class variable declared in included module" do
c = ModuleSpecs::RemoveClassVariable.new { include ModuleSpecs::MVars.dup }
- -> { c.send(:remove_class_variable, :@@mvar) }.should raise_error(NameError)
+ lambda { c.send(:remove_class_variable, :@@mvar) }.should raise_error(NameError)
end
it "raises a NameError when passed a symbol with one leading @" do
- -> { ModuleSpecs::MVars.send(:remove_class_variable, :@mvar) }.should raise_error(NameError)
+ lambda { ModuleSpecs::MVars.send(:remove_class_variable, :@mvar) }.should raise_error(NameError)
end
it "raises a NameError when passed a symbol with no leading @" do
- -> { ModuleSpecs::MVars.send(:remove_class_variable, :mvar) }.should raise_error(NameError)
+ lambda { ModuleSpecs::MVars.send(:remove_class_variable, :mvar) }.should raise_error(NameError)
end
it "raises a NameError when an uninitialized class variable is given" do
- -> { ModuleSpecs::MVars.send(:remove_class_variable, :@@nonexisting_class_variable) }.should raise_error(NameError)
+ lambda { ModuleSpecs::MVars.send(:remove_class_variable, :@@nonexisting_class_variable) }.should raise_error(NameError)
end
it "is public" do
diff --git a/spec/ruby/core/module/remove_const_spec.rb b/spec/ruby/core/module/remove_const_spec.rb
index 20eb2dc3ed..0c1b87598e 100644
--- a/spec/ruby/core/module/remove_const_spec.rb
+++ b/spec/ruby/core/module/remove_const_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/constants'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/constants', __FILE__)
describe "Module#remove_const" do
it "removes the constant specified by a String or Symbol from the receiver's constant table" do
@@ -7,13 +7,13 @@ describe "Module#remove_const" do
ConstantSpecs::ModuleM::CS_CONST252.should == :const252
ConstantSpecs::ModuleM.send :remove_const, :CS_CONST252
- -> { ConstantSpecs::ModuleM::CS_CONST252 }.should raise_error(NameError)
+ lambda { ConstantSpecs::ModuleM::CS_CONST252 }.should raise_error(NameError)
ConstantSpecs::ModuleM::CS_CONST253 = :const253
ConstantSpecs::ModuleM::CS_CONST253.should == :const253
ConstantSpecs::ModuleM.send :remove_const, "CS_CONST253"
- -> { ConstantSpecs::ModuleM::CS_CONST253 }.should raise_error(NameError)
+ lambda { ConstantSpecs::ModuleM::CS_CONST253 }.should raise_error(NameError)
end
it "returns the value of the removed constant" do
@@ -23,7 +23,7 @@ describe "Module#remove_const" do
it "raises a NameError and does not call #const_missing if the constant is not defined" do
ConstantSpecs.should_not_receive(:const_missing)
- -> { ConstantSpecs.send(:remove_const, :Nonexistent) }.should raise_error(NameError)
+ lambda { ConstantSpecs.send(:remove_const, :Nonexistent) }.should raise_error(NameError)
end
it "raises a NameError and does not call #const_missing if the constant is not defined directly in the module" do
@@ -32,7 +32,7 @@ describe "Module#remove_const" do
ConstantSpecs::ContainerA::CS_CONST255.should == :const255
ConstantSpecs::ContainerA.should_not_receive(:const_missing)
- -> do
+ lambda do
ConstantSpecs::ContainerA.send :remove_const, :CS_CONST255
end.should raise_error(NameError)
ensure
@@ -41,21 +41,21 @@ describe "Module#remove_const" do
end
it "raises a NameError if the name does not start with a capital letter" do
- -> { ConstantSpecs.send :remove_const, "name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.send :remove_const, "name" }.should raise_error(NameError)
end
it "raises a NameError if the name starts with a non-alphabetic character" do
- -> { ConstantSpecs.send :remove_const, "__CONSTX__" }.should raise_error(NameError)
- -> { ConstantSpecs.send :remove_const, "@Name" }.should raise_error(NameError)
- -> { ConstantSpecs.send :remove_const, "!Name" }.should raise_error(NameError)
- -> { ConstantSpecs.send :remove_const, "::Name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.send :remove_const, "__CONSTX__" }.should raise_error(NameError)
+ lambda { ConstantSpecs.send :remove_const, "@Name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.send :remove_const, "!Name" }.should raise_error(NameError)
+ lambda { ConstantSpecs.send :remove_const, "::Name" }.should raise_error(NameError)
end
it "raises a NameError if the name contains non-alphabetic characters except '_'" do
ConstantSpecs::ModuleM::CS_CONST256 = :const256
ConstantSpecs::ModuleM.send :remove_const, "CS_CONST256"
- -> { ConstantSpecs.send :remove_const, "Name=" }.should raise_error(NameError)
- -> { ConstantSpecs.send :remove_const, "Name?" }.should raise_error(NameError)
+ lambda { ConstantSpecs.send :remove_const, "Name=" }.should raise_error(NameError)
+ lambda { ConstantSpecs.send :remove_const, "Name?" }.should raise_error(NameError)
end
it "calls #to_str to convert the given name to a String" do
@@ -67,10 +67,10 @@ describe "Module#remove_const" do
it "raises a TypeError if conversion to a String by calling #to_str fails" do
name = mock('123')
- -> { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
+ lambda { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
name.should_receive(:to_str).and_return(123)
- -> { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
+ lambda { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError)
end
it "is a private method" do
diff --git a/spec/ruby/core/module/remove_method_spec.rb b/spec/ruby/core/module/remove_method_spec.rb
index ba08cc9b44..d82e0c65ca 100644
--- a/spec/ruby/core/module/remove_method_spec.rb
+++ b/spec/ruby/core/module/remove_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
module ModuleSpecs
class Parent
@@ -77,19 +77,19 @@ describe "Module#remove_method" do
end
it "raises a NameError when attempting to remove method further up the inheritance tree" do
- Class.new(ModuleSpecs::Second) do
- -> {
+ lambda {
+ class Third < ModuleSpecs::Second
remove_method :method_to_remove
- }.should raise_error(NameError)
- end
+ end
+ }.should raise_error(NameError)
end
it "raises a NameError when attempting to remove a missing method" do
- Class.new(ModuleSpecs::Second) do
- -> {
+ lambda {
+ class Third < ModuleSpecs::Second
remove_method :blah
- }.should raise_error(NameError)
- end
+ end
+ }.should raise_error(NameError)
end
describe "on frozen instance" do
@@ -97,16 +97,16 @@ describe "Module#remove_method" do
@frozen = @module.dup.freeze
end
- it "raises a #{frozen_error_class} when passed a name" do
- -> { @frozen.send :remove_method, :method_to_remove }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed a name" do
+ lambda { @frozen.send :remove_method, :method_to_remove }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when passed a missing name" do
- -> { @frozen.send :remove_method, :not_exist }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed a missing name" do
+ lambda { @frozen.send :remove_method, :not_exist }.should raise_error(RuntimeError)
end
it "raises a TypeError when passed a not name" do
- -> { @frozen.send :remove_method, Object.new }.should raise_error(TypeError)
+ lambda { @frozen.send :remove_method, Object.new }.should raise_error(TypeError)
end
it "does not raise exceptions when no arguments given" do
diff --git a/spec/ruby/core/module/shared/class_eval.rb b/spec/ruby/core/module/shared/class_eval.rb
index 08f8ff7597..6bb9668fee 100644
--- a/spec/ruby/core/module/shared/class_eval.rb
+++ b/spec/ruby/core/module/shared/class_eval.rb
@@ -14,7 +14,7 @@ describe :module_class_eval, shared: true do
'foo'
end
end
- -> {42.foo}.should raise_error(NoMethodError)
+ lambda {42.foo}.should raise_error(NoMethodError)
end
it "resolves constants in the caller scope" do
@@ -59,7 +59,7 @@ describe :module_class_eval, shared: true do
it "raises a TypeError when the given filename can't be converted to string using to_str" do
(file = mock('123')).should_receive(:to_str).and_return(123)
- -> { ModuleSpecs.send(@method, "1+1", file) }.should raise_error(TypeError)
+ lambda { ModuleSpecs.send(@method, "1+1", file) }.should raise_error(TypeError)
end
it "converts non string eval-string to string using to_str" do
@@ -69,24 +69,24 @@ describe :module_class_eval, shared: true do
it "raises a TypeError when the given eval-string can't be converted to string using to_str" do
o = mock('x')
- -> { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
+ lambda { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
(o = mock('123')).should_receive(:to_str).and_return(123)
- -> { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
+ lambda { ModuleSpecs.send(@method, o) }.should raise_error(TypeError)
end
it "raises an ArgumentError when no arguments and no block are given" do
- -> { ModuleSpecs.send(@method) }.should raise_error(ArgumentError)
+ lambda { ModuleSpecs.send(@method) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when more than 3 arguments are given" do
- -> {
+ lambda {
ModuleSpecs.send(@method, "1 + 1", "some file", 0, "bogus")
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError when a block and normal arguments are given" do
- -> {
+ lambda {
ModuleSpecs.send(@method, "1 + 1") { 1 + 1 }
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/module/shared/class_exec.rb b/spec/ruby/core/module/shared/class_exec.rb
index c7a9e5297f..c5c18b0a34 100644
--- a/spec/ruby/core/module/shared/class_exec.rb
+++ b/spec/ruby/core/module/shared/class_exec.rb
@@ -5,7 +5,7 @@ describe :module_class_exec, shared: true do
'foo'
end
end
- -> {42.foo}.should raise_error(NoMethodError)
+ lambda {42.foo}.should raise_error(NoMethodError)
end
it "defines method in the receiver's scope" do
@@ -19,7 +19,7 @@ describe :module_class_exec, shared: true do
end
it "raises a LocalJumpError when no block is given" do
- -> { ModuleSpecs::Subclass.send(@method) }.should raise_error(LocalJumpError)
+ lambda { ModuleSpecs::Subclass.send(@method) }.should raise_error(LocalJumpError)
end
it "passes arguments to the block" do
diff --git a/spec/ruby/core/module/shared/set_visibility.rb b/spec/ruby/core/module/shared/set_visibility.rb
index a04b1a54a0..c39d59e05d 100644
--- a/spec/ruby/core/module/shared/set_visibility.rb
+++ b/spec/ruby/core/module/shared/set_visibility.rb
@@ -5,23 +5,6 @@ describe :set_visibility, shared: true do
Module.should have_private_instance_method(@method, false)
end
- describe "with argument" do
- it "does not clone method from the ancestor when setting to the same visibility in a child" do
- visibility = @method
- parent = Module.new {
- def test_method; end
- send(visibility, :test_method)
- }
-
- child = Module.new {
- include parent
- send(visibility, :test_method)
- }
-
- child.should_not send(:"have_#{visibility}_instance_method", :test_method, false)
- end
- end
-
describe "without arguments" do
it "sets visibility to following method definitions" do
visibility = @method
diff --git a/spec/ruby/core/module/singleton_class_spec.rb b/spec/ruby/core/module/singleton_class_spec.rb
index b9f78eeb21..177dfc224f 100644
--- a/spec/ruby/core/module/singleton_class_spec.rb
+++ b/spec/ruby/core/module/singleton_class_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module#singleton_class?" do
it "returns true for singleton classes" do
diff --git a/spec/ruby/core/module/to_s_spec.rb b/spec/ruby/core/module/to_s_spec.rb
index 29f6ecf726..de924a8739 100644
--- a/spec/ruby/core/module/to_s_spec.rb
+++ b/spec/ruby/core/module/to_s_spec.rb
@@ -1,45 +1,18 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#to_s" do
- it 'returns the name of the module if it has a name' do
- Enumerable.to_s.should == 'Enumerable'
- String.to_s.should == 'String'
- end
-
it "returns the full constant path leading to the module" do
ModuleSpecs::LookupMod.to_s.should == "ModuleSpecs::LookupMod"
end
it "works with an anonymous module" do
m = Module.new
- m.to_s.should =~ /\A#<Module:0x\h+>\z/
+ m.to_s.should =~ /#<Module:0x[0-9a-f]+>/
end
it "works with an anonymous class" do
c = Class.new
- c.to_s.should =~ /\A#<Class:0x\h+>\z/
- end
-
- it 'for the singleton class of an object of an anonymous class' do
- klass = Class.new
- obj = klass.new
- sclass = obj.singleton_class
- sclass.to_s.should == "#<Class:#{obj}>"
- sclass.to_s.should =~ /\A#<Class:#<#{klass}:0x\h+>>\z/
- sclass.to_s.should =~ /\A#<Class:#<#<Class:0x\h+>:0x\h+>>\z/
- end
-
- it 'for a singleton class of a module includes the module name' do
- ModuleSpecs.singleton_class.to_s.should == '#<Class:ModuleSpecs>'
- end
-
- it 'for a metaclass includes the class name' do
- ModuleSpecs::NamedClass.singleton_class.to_s.should == '#<Class:ModuleSpecs::NamedClass>'
- end
-
- it 'for objects includes class name and object ID' do
- obj = ModuleSpecs::NamedClass.new
- obj.singleton_class.to_s.should =~ /\A#<Class:#<ModuleSpecs::NamedClass:0x\h+>>\z/
+ c.to_s.should =~ /#<Class:0x[0-9a-f]+>/
end
end
diff --git a/spec/ruby/core/module/undef_method_spec.rb b/spec/ruby/core/module/undef_method_spec.rb
index b101778962..54c3d37c7f 100644
--- a/spec/ruby/core/module/undef_method_spec.rb
+++ b/spec/ruby/core/module/undef_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
module ModuleSpecs
class Parent
@@ -41,8 +41,8 @@ describe "Module#undef_method" do
x = klass.new
klass.send(:undef_method, :method_to_undef, :another_method_to_undef)
- -> { x.method_to_undef }.should raise_error(NoMethodError)
- -> { x.another_method_to_undef }.should raise_error(NoMethodError)
+ lambda { x.method_to_undef }.should raise_error(NoMethodError)
+ lambda { x.another_method_to_undef }.should raise_error(NoMethodError)
end
it "does not undef any instance methods when argument not given" do
@@ -56,37 +56,8 @@ describe "Module#undef_method" do
@module.send(:undef_method, :method_to_undef).should equal(@module)
end
- it "raises a NameError when passed a missing name for a module" do
- -> { @module.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method `not_exist' for module `#{@module}'/) { |e|
- # a NameError and not a NoMethodError
- e.class.should == NameError
- }
- end
-
- it "raises a NameError when passed a missing name for a class" do
- klass = Class.new
- -> { klass.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method `not_exist' for class `#{klass}'/) { |e|
- # a NameError and not a NoMethodError
- e.class.should == NameError
- }
- end
-
- it "raises a NameError when passed a missing name for a singleton class" do
- klass = Class.new
- obj = klass.new
- sclass = obj.singleton_class
-
- -> { sclass.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method `not_exist' for class `#{sclass}'/) { |e|
- e.message.should include('`#<Class:#<#<Class:')
-
- # a NameError and not a NoMethodError
- e.class.should == NameError
- }
- end
-
- it "raises a NameError when passed a missing name for a metaclass" do
- klass = String.singleton_class
- -> { klass.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method `not_exist' for class `String'/) { |e|
+ it "raises a NameError when passed a missing name" do
+ lambda { @module.send :undef_method, :not_exist }.should raise_error(NameError) { |e|
# a NameError and not a NoMethodError
e.class.should == NameError
}
@@ -97,16 +68,16 @@ describe "Module#undef_method" do
@frozen = @module.dup.freeze
end
- it "raises a #{frozen_error_class} when passed a name" do
- -> { @frozen.send :undef_method, :method_to_undef }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed a name" do
+ lambda { @frozen.send :undef_method, :method_to_undef }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when passed a missing name" do
- -> { @frozen.send :undef_method, :not_exist }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed a missing name" do
+ lambda { @frozen.send :undef_method, :not_exist }.should raise_error(RuntimeError)
end
it "raises a TypeError when passed a not name" do
- -> { @frozen.send :undef_method, Object.new }.should raise_error(TypeError)
+ lambda { @frozen.send :undef_method, Object.new }.should raise_error(TypeError)
end
it "does not raise exceptions when no arguments given" do
@@ -127,7 +98,7 @@ describe "Module#undef_method with symbol" do
klass.send :undef_method, :method_to_undef
- -> { x.method_to_undef }.should raise_error(NoMethodError)
+ lambda { x.method_to_undef }.should raise_error(NoMethodError)
end
it "removes a method defined in a super class" do
@@ -137,7 +108,7 @@ describe "Module#undef_method with symbol" do
child_class.send :undef_method, :method_to_undef
- -> { child.method_to_undef }.should raise_error(NoMethodError)
+ lambda { child.method_to_undef }.should raise_error(NoMethodError)
end
it "does not remove a method defined in a super class when removed from a subclass" do
@@ -163,7 +134,7 @@ describe "Module#undef_method with string" do
klass.send :undef_method, 'another_method_to_undef'
- -> { x.another_method_to_undef }.should raise_error(NoMethodError)
+ lambda { x.another_method_to_undef }.should raise_error(NoMethodError)
end
it "removes a method defined in a super class" do
@@ -173,7 +144,7 @@ describe "Module#undef_method with string" do
child_class.send :undef_method, 'another_method_to_undef'
- -> { child.another_method_to_undef }.should raise_error(NoMethodError)
+ lambda { child.another_method_to_undef }.should raise_error(NoMethodError)
end
it "does not remove a method defined in a super class when removed from a subclass" do
diff --git a/spec/ruby/core/module/using_spec.rb b/spec/ruby/core/module/using_spec.rb
index 533d87d080..2e7e15b748 100644
--- a/spec/ruby/core/module/using_spec.rb
+++ b/spec/ruby/core/module/using_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Module#using" do
it "imports class refinements from module into the current class/module" do
@@ -24,7 +24,7 @@ describe "Module#using" do
end
end
- -> {
+ -> () {
Module.new do
using refinement
end
@@ -34,7 +34,7 @@ describe "Module#using" do
it "accepts module without refinements" do
mod = Module.new
- -> {
+ -> () {
Module.new do
using mod
end
@@ -44,7 +44,7 @@ describe "Module#using" do
it "does not accept class" do
klass = Class.new
- -> {
+ -> () {
Module.new do
using klass
end
@@ -52,7 +52,7 @@ describe "Module#using" do
end
it "raises TypeError if passed something other than module" do
- -> {
+ -> () {
Module.new do
using "foo"
end
@@ -93,7 +93,7 @@ describe "Module#using" do
end
end
- -> {
+ -> () {
mod.foo
}.should raise_error(RuntimeError, /Module#using is not permitted in methods/)
end
diff --git a/spec/ruby/core/mutex/lock_spec.rb b/spec/ruby/core/mutex/lock_spec.rb
index 7a39817b11..b5c2b168e8 100644
--- a/spec/ruby/core/mutex/lock_spec.rb
+++ b/spec/ruby/core/mutex/lock_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Mutex#lock" do
before :each do
@@ -11,15 +11,22 @@ describe "Mutex#lock" do
m.unlock
end
- it "blocks the caller if already locked" do
+ it "waits if the lock is not available" do
m = Mutex.new
+
m.lock
- -> { m.lock }.should block_caller
- end
- it "does not block the caller if not locked" do
- m = Mutex.new
- -> { m.lock }.should_not block_caller
+ th = Thread.new do
+ m.lock
+ ScratchPad.record :after_lock
+ end
+
+ Thread.pass while th.status and th.status != "sleep"
+
+ ScratchPad.recorded.should be_nil
+ m.unlock
+ th.join
+ ScratchPad.recorded.should == :after_lock
end
# Unable to find a specific ticket but behavior change may be
diff --git a/spec/ruby/core/mutex/locked_spec.rb b/spec/ruby/core/mutex/locked_spec.rb
index 1bf3ed6394..7b92534be4 100644
--- a/spec/ruby/core/mutex/locked_spec.rb
+++ b/spec/ruby/core/mutex/locked_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Mutex#locked?" do
it "returns true if locked" do
diff --git a/spec/ruby/core/mutex/owned_spec.rb b/spec/ruby/core/mutex/owned_spec.rb
index e66062534e..2e1c3f2481 100644
--- a/spec/ruby/core/mutex/owned_spec.rb
+++ b/spec/ruby/core/mutex/owned_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Mutex#owned?" do
describe "when unlocked" do
diff --git a/spec/ruby/core/mutex/sleep_spec.rb b/spec/ruby/core/mutex/sleep_spec.rb
index f5e0d53036..ab49ccfd7d 100644
--- a/spec/ruby/core/mutex/sleep_spec.rb
+++ b/spec/ruby/core/mutex/sleep_spec.rb
@@ -1,35 +1,35 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Mutex#sleep" do
describe "when not locked by the current thread" do
it "raises a ThreadError" do
m = Mutex.new
- -> { m.sleep }.should raise_error(ThreadError)
+ lambda { m.sleep }.should raise_error(ThreadError)
end
it "raises an ArgumentError if passed a negative duration" do
m = Mutex.new
- -> { m.sleep(-0.1) }.should raise_error(ArgumentError)
- -> { m.sleep(-1) }.should raise_error(ArgumentError)
+ lambda { m.sleep(-0.1) }.should raise_error(ArgumentError)
+ lambda { m.sleep(-1) }.should raise_error(ArgumentError)
end
end
it "raises an ArgumentError if passed a negative duration" do
m = Mutex.new
m.lock
- -> { m.sleep(-0.1) }.should raise_error(ArgumentError)
- -> { m.sleep(-1) }.should raise_error(ArgumentError)
+ lambda { m.sleep(-0.1) }.should raise_error(ArgumentError)
+ lambda { m.sleep(-1) }.should raise_error(ArgumentError)
end
it "pauses execution for approximately the duration requested" do
m = Mutex.new
m.lock
- duration = 0.001
+ duration = 0.1
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
m.sleep duration
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- (now - start).should >= 0
- (now - start).should < (duration + TIME_TOLERANCE)
+ (now - start).should > 0
+ (now - start).should < 2.0
end
it "unlocks the mutex while sleeping" do
@@ -46,7 +46,7 @@ describe "Mutex#sleep" do
it "relocks the mutex when woken" do
m = Mutex.new
m.lock
- m.sleep(0.001)
+ m.sleep(0.01)
m.locked?.should be_true
end
@@ -71,7 +71,7 @@ describe "Mutex#sleep" do
it "returns the rounded number of seconds asleep" do
m = Mutex.new
m.lock
- m.sleep(0.001).should be_kind_of(Integer)
+ m.sleep(0.01).should be_kind_of(Integer)
end
it "wakes up when requesting sleep times near or equal to zero" do
diff --git a/spec/ruby/core/mutex/synchronize_spec.rb b/spec/ruby/core/mutex/synchronize_spec.rb
index 7942885197..ec64aa60fa 100644
--- a/spec/ruby/core/mutex/synchronize_spec.rb
+++ b/spec/ruby/core/mutex/synchronize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Mutex#synchronize" do
it "wraps the lock/unlock pair in an ensure" do
@@ -8,7 +8,7 @@ describe "Mutex#synchronize" do
synchronized = false
th = Thread.new do
- -> do
+ lambda do
m1.synchronize do
synchronized = true
m2.lock
@@ -24,43 +24,4 @@ describe "Mutex#synchronize" do
th.join
m1.locked?.should be_false
end
-
- it "blocks the caller if already locked" do
- m = Mutex.new
- m.lock
- -> { m.synchronize { } }.should block_caller
- end
-
- it "does not block the caller if not locked" do
- m = Mutex.new
- -> { m.synchronize { } }.should_not block_caller
- end
-
- it "blocks the caller if another thread is also in the synchronize block" do
- m = Mutex.new
- q1 = Queue.new
- q2 = Queue.new
-
- t = Thread.new {
- m.synchronize {
- q1.push :ready
- q2.pop
- }
- }
-
- q1.pop.should == :ready
-
- -> { m.synchronize { } }.should block_caller
-
- q2.push :done
- t.join
- end
-
- it "is not recursive" do
- m = Mutex.new
-
- m.synchronize do
- -> { m.synchronize { } }.should raise_error(ThreadError)
- end
- end
end
diff --git a/spec/ruby/core/mutex/try_lock_spec.rb b/spec/ruby/core/mutex/try_lock_spec.rb
index 8d521f4c6b..3e875ff9ec 100644
--- a/spec/ruby/core/mutex/try_lock_spec.rb
+++ b/spec/ruby/core/mutex/try_lock_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Mutex#try_lock" do
describe "when unlocked" do
diff --git a/spec/ruby/core/mutex/unlock_spec.rb b/spec/ruby/core/mutex/unlock_spec.rb
index c9c3bfe14f..4601fde634 100644
--- a/spec/ruby/core/mutex/unlock_spec.rb
+++ b/spec/ruby/core/mutex/unlock_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Mutex#unlock" do
it "raises ThreadError unless Mutex is locked" do
mutex = Mutex.new
- -> { mutex.unlock }.should raise_error(ThreadError)
+ lambda { mutex.unlock }.should raise_error(ThreadError)
end
it "raises ThreadError unless thread owns Mutex" do
@@ -19,7 +19,7 @@ describe "Mutex#unlock" do
Thread.pass until mutex.locked?
Thread.pass while th.status and th.status != "sleep"
- -> { mutex.unlock }.should raise_error(ThreadError)
+ lambda { mutex.unlock }.should raise_error(ThreadError)
wait.unlock
th.join
@@ -33,6 +33,6 @@ describe "Mutex#unlock" do
th.join
- -> { mutex.unlock }.should raise_error(ThreadError)
+ lambda { mutex.unlock }.should raise_error(ThreadError)
end
end
diff --git a/spec/ruby/core/nil/and_spec.rb b/spec/ruby/core/nil/and_spec.rb
index cd25aff1de..96e0472661 100644
--- a/spec/ruby/core/nil/and_spec.rb
+++ b/spec/ruby/core/nil/and_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#&" do
it "returns false" do
diff --git a/spec/ruby/core/nil/dup_spec.rb b/spec/ruby/core/nil/dup_spec.rb
index 0324b3f1f4..10b1209736 100644
--- a/spec/ruby/core/nil/dup_spec.rb
+++ b/spec/ruby/core/nil/dup_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "NilClass#dup" do
- it "returns self" do
- nil.dup.should equal(nil)
+ruby_version_is '2.4' do
+ describe "NilClass#dup" do
+ it "returns self" do
+ nil.dup.should equal(nil)
+ end
end
end
diff --git a/spec/ruby/core/nil/inspect_spec.rb b/spec/ruby/core/nil/inspect_spec.rb
index 1babc3d062..f7a5e7d1af 100644
--- a/spec/ruby/core/nil/inspect_spec.rb
+++ b/spec/ruby/core/nil/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#inspect" do
it "returns the string 'nil'" do
diff --git a/spec/ruby/core/nil/match_spec.rb b/spec/ruby/core/nil/match_spec.rb
deleted file mode 100644
index 3f69312bfe..0000000000
--- a/spec/ruby/core/nil/match_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "NilClass#=~" do
- it "returns nil matching any object" do
- o = Object.new
-
- suppress_warning do
- (o =~ /Object/).should be_nil
- (o =~ 'Object').should be_nil
- (o =~ Object).should be_nil
- (o =~ Object.new).should be_nil
- (o =~ nil).should be_nil
- (o =~ false).should be_nil
- (o =~ true).should be_nil
- end
- end
- end
-end
diff --git a/spec/ruby/core/nil/nil_spec.rb b/spec/ruby/core/nil/nil_spec.rb
index 47db0c5cf0..8369b21a66 100644
--- a/spec/ruby/core/nil/nil_spec.rb
+++ b/spec/ruby/core/nil/nil_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#nil?" do
it "returns true" do
diff --git a/spec/ruby/core/nil/nilclass_spec.rb b/spec/ruby/core/nil/nilclass_spec.rb
index 7f6d8af25d..3f28cde0bd 100644
--- a/spec/ruby/core/nil/nilclass_spec.rb
+++ b/spec/ruby/core/nil/nilclass_spec.rb
@@ -1,14 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass" do
it ".allocate raises a TypeError" do
- -> do
+ lambda do
NilClass.allocate
end.should raise_error(TypeError)
end
it ".new is undefined" do
- -> do
+ lambda do
NilClass.new
end.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/nil/or_spec.rb b/spec/ruby/core/nil/or_spec.rb
index 473a833d71..2c5811b8c2 100644
--- a/spec/ruby/core/nil/or_spec.rb
+++ b/spec/ruby/core/nil/or_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#|" do
it "returns false if other is nil or false, otherwise true" do
diff --git a/spec/ruby/core/nil/rationalize_spec.rb b/spec/ruby/core/nil/rationalize_spec.rb
index 84d6e6f056..1292cfd250 100644
--- a/spec/ruby/core/nil/rationalize_spec.rb
+++ b/spec/ruby/core/nil/rationalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#rationalize" do
it "returns 0/1" do
@@ -10,7 +10,7 @@ describe "NilClass#rationalize" do
end
it "raises ArgumentError when passed more than one argument" do
- -> { nil.rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
- -> { nil.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
+ lambda { nil.rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
+ lambda { nil.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/nil/to_a_spec.rb b/spec/ruby/core/nil/to_a_spec.rb
index b8b339e330..6febd88c40 100644
--- a/spec/ruby/core/nil/to_a_spec.rb
+++ b/spec/ruby/core/nil/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#to_a" do
it "returns an empty array" do
diff --git a/spec/ruby/core/nil/to_c_spec.rb b/spec/ruby/core/nil/to_c_spec.rb
index e0052be5bd..5b768b4afc 100644
--- a/spec/ruby/core/nil/to_c_spec.rb
+++ b/spec/ruby/core/nil/to_c_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#to_c" do
it "returns Complex(0, 0)" do
diff --git a/spec/ruby/core/nil/to_f_spec.rb b/spec/ruby/core/nil/to_f_spec.rb
index a5f24ba3bf..d4890cd42b 100644
--- a/spec/ruby/core/nil/to_f_spec.rb
+++ b/spec/ruby/core/nil/to_f_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#to_f" do
it "returns 0.0" do
diff --git a/spec/ruby/core/nil/to_h_spec.rb b/spec/ruby/core/nil/to_h_spec.rb
index 5c8d5dc25a..5300802d19 100644
--- a/spec/ruby/core/nil/to_h_spec.rb
+++ b/spec/ruby/core/nil/to_h_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#to_h" do
it "returns an empty hash" do
diff --git a/spec/ruby/core/nil/to_i_spec.rb b/spec/ruby/core/nil/to_i_spec.rb
index 099792ef68..91282822a8 100644
--- a/spec/ruby/core/nil/to_i_spec.rb
+++ b/spec/ruby/core/nil/to_i_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#to_i" do
it "returns 0" do
diff --git a/spec/ruby/core/nil/to_r_spec.rb b/spec/ruby/core/nil/to_r_spec.rb
index 8be43baf00..efbd2f5540 100644
--- a/spec/ruby/core/nil/to_r_spec.rb
+++ b/spec/ruby/core/nil/to_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#to_r" do
it "returns 0/1" do
diff --git a/spec/ruby/core/nil/to_s_spec.rb b/spec/ruby/core/nil/to_s_spec.rb
index 4b61f589f7..935bb63a9b 100644
--- a/spec/ruby/core/nil/to_s_spec.rb
+++ b/spec/ruby/core/nil/to_s_spec.rb
@@ -1,17 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#to_s" do
it "returns the string ''" do
nil.to_s.should == ""
end
-
- ruby_version_is "2.7" do
- it "returns a frozen string" do
- nil.to_s.frozen?.should == true
- end
-
- it "always returns the same string" do
- nil.to_s.should equal(nil.to_s)
- end
- end
end
diff --git a/spec/ruby/core/nil/xor_spec.rb b/spec/ruby/core/nil/xor_spec.rb
index b45da9d443..7f2131e795 100644
--- a/spec/ruby/core/nil/xor_spec.rb
+++ b/spec/ruby/core/nil/xor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "NilClass#^" do
it "returns false if other is nil or false, otherwise true" do
diff --git a/spec/ruby/core/numeric/abs2_spec.rb b/spec/ruby/core/numeric/abs2_spec.rb
index 0e60cd0ae7..f1094845fb 100644
--- a/spec/ruby/core/numeric/abs2_spec.rb
+++ b/spec/ruby/core/numeric/abs2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Numeric#abs2" do
before :each do
diff --git a/spec/ruby/core/numeric/abs_spec.rb b/spec/ruby/core/numeric/abs_spec.rb
index 8bec50e337..4aa25359a2 100644
--- a/spec/ruby/core/numeric/abs_spec.rb
+++ b/spec/ruby/core/numeric/abs_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/abs'
+require File.expand_path('../shared/abs', __FILE__)
describe "Numeric#abs" do
- it_behaves_like :numeric_abs, :abs
+ it_behaves_like(:numeric_abs, :abs)
end
diff --git a/spec/ruby/core/numeric/angle_spec.rb b/spec/ruby/core/numeric/angle_spec.rb
index bb38165777..d7134168b3 100644
--- a/spec/ruby/core/numeric/angle_spec.rb
+++ b/spec/ruby/core/numeric/angle_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/arg', __FILE__)
describe "Numeric#angle" do
- it_behaves_like :numeric_arg, :angle
+ it_behaves_like(:numeric_arg, :angle)
end
diff --git a/spec/ruby/core/numeric/arg_spec.rb b/spec/ruby/core/numeric/arg_spec.rb
index ba3b57c687..0729a29226 100644
--- a/spec/ruby/core/numeric/arg_spec.rb
+++ b/spec/ruby/core/numeric/arg_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/arg', __FILE__)
describe "Numeric#arg" do
- it_behaves_like :numeric_arg, :arg
+ it_behaves_like(:numeric_arg, :arg)
end
diff --git a/spec/ruby/core/numeric/ceil_spec.rb b/spec/ruby/core/numeric/ceil_spec.rb
index 00c856e79b..6e7d8211fb 100644
--- a/spec/ruby/core/numeric/ceil_spec.rb
+++ b/spec/ruby/core/numeric/ceil_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#ceil" do
it "converts self to a Float (using #to_f) and returns the #ceil'ed result" do
diff --git a/spec/ruby/core/numeric/coerce_spec.rb b/spec/ruby/core/numeric/coerce_spec.rb
index 4c4416d30b..820d900dd5 100644
--- a/spec/ruby/core/numeric/coerce_spec.rb
+++ b/spec/ruby/core/numeric/coerce_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#coerce" do
before :each do
@@ -25,35 +25,52 @@ describe "Numeric#coerce" do
class << a; true; end
# watch it explode
- -> { a.coerce(b) }.should raise_error(TypeError)
+ lambda { a.coerce(b) }.should raise_error(TypeError)
end
end
- it "returns [other.to_f, self.to_f] if self and other are instances of different classes" do
- @obj.coerce(2.5).should == [2.5, 10.5]
- @obj.coerce(3).should == [3.0, 10.5]
- @obj.coerce("4.4").should == [4.4, 10.5]
- @obj.coerce(bignum_value).should == [bignum_value.to_f, 10.5]
+ it "calls #to_f to convert other if self responds to #to_f" do
+ # Do not use NumericSpecs::Subclass here, because coerce checks the classes of the receiver
+ # and arguments before calling #to_f.
+ other = mock("numeric")
+ lambda { @obj.coerce(other) }.should raise_error(TypeError)
end
- it "raise TypeError if they are instances of different classes and other does not respond to #to_f" do
- other = mock("numeric")
- -> { @obj.coerce(other) }.should raise_error(TypeError)
+ it "returns [other.to_f, self.to_f] if self and other are instances of different classes" do
+ result = @obj.coerce(2.5)
+ result.should == [2.5, 10.5]
+ result.first.should be_kind_of(Float)
+ result.last.should be_kind_of(Float)
+
+ result = @obj.coerce(3)
+ result.should == [3.0, 10.5]
+ result.first.should be_kind_of(Float)
+ result.last.should be_kind_of(Float)
+
+ result = @obj.coerce("4.4")
+ result.should == [4.4, 10.5]
+ result.first.should be_kind_of(Float)
+ result.last.should be_kind_of(Float)
+
+ result = @obj.coerce(bignum_value)
+ result.should == [bignum_value.to_f, 10.5]
+ result.first.should be_kind_of(Float)
+ result.last.should be_kind_of(Float)
end
it "raises a TypeError when passed nil" do
- -> { @obj.coerce(nil) }.should raise_error(TypeError)
+ lambda { @obj.coerce(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a boolean" do
- -> { @obj.coerce(false) }.should raise_error(TypeError)
+ lambda { @obj.coerce(false) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a Symbol" do
- -> { @obj.coerce(:symbol) }.should raise_error(TypeError)
+ lambda { @obj.coerce(:symbol) }.should raise_error(TypeError)
end
- it "raises an ArgumentError when passed a non-numeric String" do
- -> { @obj.coerce("test") }.should raise_error(ArgumentError)
+ it "raises an ArgumentError when passed a String" do
+ lambda { @obj.coerce("test") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/numeric/comparison_spec.rb b/spec/ruby/core/numeric/comparison_spec.rb
index 4b4d52501a..59676c01ad 100644
--- a/spec/ruby/core/numeric/comparison_spec.rb
+++ b/spec/ruby/core/numeric/comparison_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#<=>" do
before :each do
diff --git a/spec/ruby/core/numeric/conj_spec.rb b/spec/ruby/core/numeric/conj_spec.rb
index 7d4777ca60..8fa0fd9457 100644
--- a/spec/ruby/core/numeric/conj_spec.rb
+++ b/spec/ruby/core/numeric/conj_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/conj'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/conj', __FILE__)
describe "Numeric#conj" do
- it_behaves_like :numeric_conj, :conj
+ it_behaves_like(:numeric_conj, :conj)
end
diff --git a/spec/ruby/core/numeric/conjugate_spec.rb b/spec/ruby/core/numeric/conjugate_spec.rb
index 99854766e7..f7e095514e 100644
--- a/spec/ruby/core/numeric/conjugate_spec.rb
+++ b/spec/ruby/core/numeric/conjugate_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/conj'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/conj', __FILE__)
describe "Numeric#conjugate" do
- it_behaves_like :numeric_conj, :conjugate
+ it_behaves_like(:numeric_conj, :conjugate)
end
diff --git a/spec/ruby/core/numeric/denominator_spec.rb b/spec/ruby/core/numeric/denominator_spec.rb
index 34729446a2..3ae4530c18 100644
--- a/spec/ruby/core/numeric/denominator_spec.rb
+++ b/spec/ruby/core/numeric/denominator_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Numeric#denominator" do
# The Numeric child classes override this method, so their behaviour is
diff --git a/spec/ruby/core/numeric/div_spec.rb b/spec/ruby/core/numeric/div_spec.rb
index 53917b84c9..f3f82c3ca4 100644
--- a/spec/ruby/core/numeric/div_spec.rb
+++ b/spec/ruby/core/numeric/div_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#div" do
before :each do
@@ -15,8 +15,8 @@ describe "Numeric#div" do
end
it "raises ZeroDivisionError for 0" do
- -> { @obj.div(0) }.should raise_error(ZeroDivisionError)
- -> { @obj.div(0.0) }.should raise_error(ZeroDivisionError)
- -> { @obj.div(Complex(0,0)) }.should raise_error(ZeroDivisionError)
+ lambda { @obj.div(0) }.should raise_error(ZeroDivisionError)
+ lambda { @obj.div(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { @obj.div(Complex(0,0)) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/core/numeric/divmod_spec.rb b/spec/ruby/core/numeric/divmod_spec.rb
index 8d5259bbcd..5de2d86c77 100644
--- a/spec/ruby/core/numeric/divmod_spec.rb
+++ b/spec/ruby/core/numeric/divmod_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#divmod" do
before :each do
diff --git a/spec/ruby/core/numeric/eql_spec.rb b/spec/ruby/core/numeric/eql_spec.rb
index b33e00e51f..367a298a74 100644
--- a/spec/ruby/core/numeric/eql_spec.rb
+++ b/spec/ruby/core/numeric/eql_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#eql?" do
before :each do
diff --git a/spec/ruby/core/numeric/fdiv_spec.rb b/spec/ruby/core/numeric/fdiv_spec.rb
index 907e5d343c..4b27382012 100644
--- a/spec/ruby/core/numeric/fdiv_spec.rb
+++ b/spec/ruby/core/numeric/fdiv_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quo', __FILE__)
describe "Numeric#fdiv" do
it "coerces self with #to_f" do
diff --git a/spec/ruby/core/numeric/finite_spec.rb b/spec/ruby/core/numeric/finite_spec.rb
index 05b5eebbd6..9fb2252845 100644
--- a/spec/ruby/core/numeric/finite_spec.rb
+++ b/spec/ruby/core/numeric/finite_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Numeric#finite?" do
- it "returns true by default" do
- o = mock_numeric("finite")
- o.finite?.should be_true
+ruby_version_is "2.4" do
+ describe "Numeric#finite?" do
+ it "returns true by default" do
+ o = mock_numeric("finite")
+ o.finite?.should be_true
+ end
end
end
diff --git a/spec/ruby/core/numeric/floor_spec.rb b/spec/ruby/core/numeric/floor_spec.rb
index 80a4868e4d..c68ed0423a 100644
--- a/spec/ruby/core/numeric/floor_spec.rb
+++ b/spec/ruby/core/numeric/floor_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#floor" do
before :each do
diff --git a/spec/ruby/core/numeric/i_spec.rb b/spec/ruby/core/numeric/i_spec.rb
index 621ecc09ec..fae4fefe3d 100644
--- a/spec/ruby/core/numeric/i_spec.rb
+++ b/spec/ruby/core/numeric/i_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Numeric#i" do
it "returns a Complex object" do
diff --git a/spec/ruby/core/numeric/imag_spec.rb b/spec/ruby/core/numeric/imag_spec.rb
index b9e343cee9..a80e42d265 100644
--- a/spec/ruby/core/numeric/imag_spec.rb
+++ b/spec/ruby/core/numeric/imag_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/imag'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/imag', __FILE__)
describe "Numeric#imag" do
- it_behaves_like :numeric_imag, :imag
+ it_behaves_like(:numeric_imag, :imag)
end
diff --git a/spec/ruby/core/numeric/imaginary_spec.rb b/spec/ruby/core/numeric/imaginary_spec.rb
index ec708cb505..41226569b3 100644
--- a/spec/ruby/core/numeric/imaginary_spec.rb
+++ b/spec/ruby/core/numeric/imaginary_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/imag'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/imag', __FILE__)
describe "Numeric#imaginary" do
- it_behaves_like :numeric_imag, :imaginary
+ it_behaves_like(:numeric_imag, :imaginary)
end
diff --git a/spec/ruby/core/numeric/infinite_spec.rb b/spec/ruby/core/numeric/infinite_spec.rb
index 3ea7825c8c..a527cb4370 100644
--- a/spec/ruby/core/numeric/infinite_spec.rb
+++ b/spec/ruby/core/numeric/infinite_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Numeric#infinite?" do
- it "returns nil by default" do
- o = mock_numeric("infinite")
- o.infinite?.should == nil
+ruby_version_is "2.4" do
+ describe "Numeric#infinite?" do
+ it "returns nil by default" do
+ o = mock_numeric("infinite")
+ o.infinite?.should == nil
+ end
end
end
diff --git a/spec/ruby/core/numeric/integer_spec.rb b/spec/ruby/core/numeric/integer_spec.rb
index 5d4bf00360..acff8eb830 100644
--- a/spec/ruby/core/numeric/integer_spec.rb
+++ b/spec/ruby/core/numeric/integer_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#integer?" do
it "returns false" do
diff --git a/spec/ruby/core/numeric/magnitude_spec.rb b/spec/ruby/core/numeric/magnitude_spec.rb
index 7a3290b036..947ee69730 100644
--- a/spec/ruby/core/numeric/magnitude_spec.rb
+++ b/spec/ruby/core/numeric/magnitude_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'shared/abs'
+require File.expand_path('../shared/abs', __FILE__)
describe "Numeric#magnitude" do
- it_behaves_like :numeric_abs, :magnitude
+ it_behaves_like(:numeric_abs, :magnitude)
end
diff --git a/spec/ruby/core/numeric/modulo_spec.rb b/spec/ruby/core/numeric/modulo_spec.rb
index e3dc7e56f3..a6ea7a8f14 100644
--- a/spec/ruby/core/numeric/modulo_spec.rb
+++ b/spec/ruby/core/numeric/modulo_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe :numeric_modulo_19, shared: true do
it "returns self - other * self.div(other)" do
diff --git a/spec/ruby/core/numeric/negative_spec.rb b/spec/ruby/core/numeric/negative_spec.rb
index da464a9094..27e5c65fe3 100644
--- a/spec/ruby/core/numeric/negative_spec.rb
+++ b/spec/ruby/core/numeric/negative_spec.rb
@@ -1,41 +1,43 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe "Numeric#negative?" do
- describe "on positive numbers" do
- it "returns false" do
- 1.negative?.should be_false
- 0.1.negative?.should be_false
+ruby_version_is "2.3" do
+ describe "Numeric#negative?" do
+ describe "on positive numbers" do
+ it "returns false" do
+ 1.negative?.should be_false
+ 0.1.negative?.should be_false
+ end
end
- end
- describe "on zero" do
- it "returns false" do
- 0.negative?.should be_false
- 0.0.negative?.should be_false
+ describe "on zero" do
+ it "returns false" do
+ 0.negative?.should be_false
+ 0.0.negative?.should be_false
+ end
end
- end
- describe "on negative numbers" do
- it "returns true" do
- -1.negative?.should be_true
- -0.1.negative?.should be_true
+ describe "on negative numbers" do
+ it "returns true" do
+ -1.negative?.should be_true
+ -0.1.negative?.should be_true
+ end
end
end
-end
-describe "Numeric#negative?" do
- before(:each) do
- @obj = NumericSpecs::Subclass.new
- end
+ describe "Numeric#negative?" do
+ before(:each) do
+ @obj = NumericSpecs::Subclass.new
+ end
- it "returns true if self is less than 0" do
- @obj.should_receive(:<).with(0).and_return(true)
- @obj.negative?.should == true
- end
+ it "returns true if self is less than 0" do
+ @obj.should_receive(:<).with(0).and_return(true)
+ @obj.negative?.should == true
+ end
- it "returns false if self is greater than 0" do
- @obj.should_receive(:<).with(0).and_return(false)
- @obj.negative?.should == false
+ it "returns false if self is greater than 0" do
+ @obj.should_receive(:<).with(0).and_return(false)
+ @obj.negative?.should == false
+ end
end
end
diff --git a/spec/ruby/core/numeric/nonzero_spec.rb b/spec/ruby/core/numeric/nonzero_spec.rb
index 464ed4f4f8..55b7880d0e 100644
--- a/spec/ruby/core/numeric/nonzero_spec.rb
+++ b/spec/ruby/core/numeric/nonzero_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#nonzero?" do
before :each do
diff --git a/spec/ruby/core/numeric/numerator_spec.rb b/spec/ruby/core/numeric/numerator_spec.rb
index 668df8b797..4a20f8792a 100644
--- a/spec/ruby/core/numeric/numerator_spec.rb
+++ b/spec/ruby/core/numeric/numerator_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Numeric#numerator" do
before :all do
diff --git a/spec/ruby/core/numeric/numeric_spec.rb b/spec/ruby/core/numeric/numeric_spec.rb
index 2bcf2a1175..9429ab55a0 100644
--- a/spec/ruby/core/numeric/numeric_spec.rb
+++ b/spec/ruby/core/numeric/numeric_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Numeric" do
it "includes Comparable" do
diff --git a/spec/ruby/core/numeric/phase_spec.rb b/spec/ruby/core/numeric/phase_spec.rb
index bc1995303f..7c408db83b 100644
--- a/spec/ruby/core/numeric/phase_spec.rb
+++ b/spec/ruby/core/numeric/phase_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/arg'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/arg', __FILE__)
describe "Numeric#phase" do
- it_behaves_like :numeric_arg, :phase
+ it_behaves_like(:numeric_arg, :phase)
end
diff --git a/spec/ruby/core/numeric/polar_spec.rb b/spec/ruby/core/numeric/polar_spec.rb
index b594e408b2..5492483215 100644
--- a/spec/ruby/core/numeric/polar_spec.rb
+++ b/spec/ruby/core/numeric/polar_spec.rb
@@ -1,50 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/polar', __FILE__)
describe "Numeric#polar" do
- before :each do
- @pos_numbers = [
- 1,
- 3898172610**9,
- 987.18273,
- Float::MAX,
- Rational(13,7),
- infinity_value,
- ]
- @neg_numbers = @pos_numbers.map {|n| -n}
- @numbers = @pos_numbers + @neg_numbers
- @numbers.push(0, 0.0)
- end
-
- it "returns a two-element Array" do
- @numbers.each do |number|
- number.polar.should be_an_instance_of(Array)
- number.polar.size.should == 2
- end
- end
-
- it "sets the first value to the absolute value of self" do
- @numbers.each do |number|
- number.polar.first.should == number.abs
- end
- end
-
- it "sets the last value to 0 if self is positive" do
- (@numbers - @neg_numbers).each do |number|
- number.should >= 0
- number.polar.last.should == 0
- end
- end
-
- it "sets the last value to Pi if self is negative" do
- @neg_numbers.each do |number|
- number.should < 0
- number.polar.last.should == Math::PI
- end
- end
-
- it "returns [NaN, NaN] if self is NaN" do
- nan_value.polar.size.should == 2
- nan_value.polar.first.nan?.should be_true
- nan_value.polar.last.nan?.should be_true
- end
+ it_behaves_like(:numeric_polar, :polar)
end
diff --git a/spec/ruby/core/numeric/positive_spec.rb b/spec/ruby/core/numeric/positive_spec.rb
index 8f98fbfa26..516de7db89 100644
--- a/spec/ruby/core/numeric/positive_spec.rb
+++ b/spec/ruby/core/numeric/positive_spec.rb
@@ -1,41 +1,43 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe "Numeric#positive?" do
- describe "on positive numbers" do
- it "returns true" do
- 1.positive?.should be_true
- 0.1.positive?.should be_true
+ruby_version_is "2.3" do
+ describe "Numeric#positive?" do
+ describe "on positive numbers" do
+ it "returns true" do
+ 1.positive?.should be_true
+ 0.1.positive?.should be_true
+ end
end
- end
- describe "on zero" do
- it "returns false" do
- 0.positive?.should be_false
- 0.0.positive?.should be_false
+ describe "on zero" do
+ it "returns false" do
+ 0.positive?.should be_false
+ 0.0.positive?.should be_false
+ end
end
- end
- describe "on negative numbers" do
- it "returns false" do
- -1.positive?.should be_false
- -0.1.positive?.should be_false
+ describe "on negative numbers" do
+ it "returns false" do
+ -1.positive?.should be_false
+ -0.1.positive?.should be_false
+ end
end
end
-end
-describe "Numeric#positive?" do
- before(:each) do
- @obj = NumericSpecs::Subclass.new
- end
+ describe "Numeric#positive?" do
+ before(:each) do
+ @obj = NumericSpecs::Subclass.new
+ end
- it "returns true if self is greater than 0" do
- @obj.should_receive(:>).with(0).and_return(true)
- @obj.positive?.should == true
- end
+ it "returns true if self is greater than 0" do
+ @obj.should_receive(:>).with(0).and_return(true)
+ @obj.positive?.should == true
+ end
- it "returns false if self is less than 0" do
- @obj.should_receive(:>).with(0).and_return(false)
- @obj.positive?.should == false
+ it "returns false if self is less than 0" do
+ @obj.should_receive(:>).with(0).and_return(false)
+ @obj.positive?.should == false
+ end
end
end
diff --git a/spec/ruby/core/numeric/quo_spec.rb b/spec/ruby/core/numeric/quo_spec.rb
index 5c952b11a9..24c752aac1 100644
--- a/spec/ruby/core/numeric/quo_spec.rb
+++ b/spec/ruby/core/numeric/quo_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/quo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/quo', __FILE__)
describe "Numeric#quo" do
it "returns the result of self divided by the given Integer as a Rational" do
@@ -16,11 +16,11 @@ describe "Numeric#quo" do
end
it "raises a ZeroDivisionError when the given Integer is 0" do
- -> { 0.quo(0) }.should raise_error(ZeroDivisionError)
- -> { 10.quo(0) }.should raise_error(ZeroDivisionError)
- -> { -10.quo(0) }.should raise_error(ZeroDivisionError)
- -> { bignum_value.quo(0) }.should raise_error(ZeroDivisionError)
- -> { -bignum_value.quo(0) }.should raise_error(ZeroDivisionError)
+ lambda { 0.quo(0) }.should raise_error(ZeroDivisionError)
+ lambda { 10.quo(0) }.should raise_error(ZeroDivisionError)
+ lambda { -10.quo(0) }.should raise_error(ZeroDivisionError)
+ lambda { bignum_value.quo(0) }.should raise_error(ZeroDivisionError)
+ lambda { -bignum_value.quo(0) }.should raise_error(ZeroDivisionError)
end
it "calls #to_r to convert the object to a Rational" do
@@ -34,16 +34,16 @@ describe "Numeric#quo" do
obj = NumericSpecs::Subclass.new
obj.should_receive(:to_r).and_return(1)
- -> { obj.quo(19) }.should raise_error(TypeError)
+ lambda { obj.quo(19) }.should raise_error(TypeError)
end
it "raises a TypeError when given a non-Integer" do
- -> {
+ lambda {
(obj = mock('x')).should_not_receive(:to_int)
13.quo(obj)
}.should raise_error(TypeError)
- -> { 13.quo("10") }.should raise_error(TypeError)
- -> { 13.quo(:symbol) }.should raise_error(TypeError)
+ lambda { 13.quo("10") }.should raise_error(TypeError)
+ lambda { 13.quo(:symbol) }.should raise_error(TypeError)
end
it "returns the result of calling self#/ with other" do
diff --git a/spec/ruby/core/numeric/real_spec.rb b/spec/ruby/core/numeric/real_spec.rb
index caa8dcec6d..3e34410155 100644
--- a/spec/ruby/core/numeric/real_spec.rb
+++ b/spec/ruby/core/numeric/real_spec.rb
@@ -1,33 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/complex/numeric/real', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#real" do
- before :each do
- @numbers = [
- 20, # Integer
- 398.72, # Float
- Rational(3, 4), # Rational
- bignum_value, # Bignum
- infinity_value,
- nan_value
- ].map{ |n| [n, -n] }.flatten
- end
-
- it "returns self" do
- @numbers.each do |number|
- if number.to_f.nan?
- number.real.nan?.should be_true
- else
- number.real.should == number
- end
- end
- end
-
- it "raises an ArgumentError if given any arguments" do
- @numbers.each do |number|
- -> { number.real(number) }.should raise_error(ArgumentError)
- end
- end
+ it_behaves_like(:numeric_real, :real)
end
describe "Numeric#real?" do
diff --git a/spec/ruby/core/numeric/rect_spec.rb b/spec/ruby/core/numeric/rect_spec.rb
index 79a144c5a4..88d5ee3881 100644
--- a/spec/ruby/core/numeric/rect_spec.rb
+++ b/spec/ruby/core/numeric/rect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rect', __FILE__)
describe "Numeric#rect" do
- it_behaves_like :numeric_rect, :rect
+ it_behaves_like(:numeric_rect, :rect)
end
diff --git a/spec/ruby/core/numeric/rectangular_spec.rb b/spec/ruby/core/numeric/rectangular_spec.rb
index 2c68985a16..b34100ca74 100644
--- a/spec/ruby/core/numeric/rectangular_spec.rb
+++ b/spec/ruby/core/numeric/rectangular_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rect', __FILE__)
describe "Numeric#rectangular" do
- it_behaves_like :numeric_rect, :rectangular
+ it_behaves_like(:numeric_rect, :rectangular)
end
diff --git a/spec/ruby/core/numeric/remainder_spec.rb b/spec/ruby/core/numeric/remainder_spec.rb
index 1e2f5f3a96..6d26d39669 100644
--- a/spec/ruby/core/numeric/remainder_spec.rb
+++ b/spec/ruby/core/numeric/remainder_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#remainder" do
before :each do
diff --git a/spec/ruby/core/numeric/round_spec.rb b/spec/ruby/core/numeric/round_spec.rb
index 47c5837693..6e79decfa0 100644
--- a/spec/ruby/core/numeric/round_spec.rb
+++ b/spec/ruby/core/numeric/round_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#round" do
before :each do
diff --git a/spec/ruby/core/numeric/shared/abs.rb b/spec/ruby/core/numeric/shared/abs.rb
index c3dadccfd6..406c9f3981 100644
--- a/spec/ruby/core/numeric/shared/abs.rb
+++ b/spec/ruby/core/numeric/shared/abs.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :numeric_abs, shared: true do
before :each do
diff --git a/spec/ruby/core/numeric/shared/arg.rb b/spec/ruby/core/numeric/shared/arg.rb
deleted file mode 100644
index c8e7ad8333..0000000000
--- a/spec/ruby/core/numeric/shared/arg.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../../../spec_helper'
-
-describe :numeric_arg, shared: true do
- before :each do
- @numbers = [
- 20,
- Rational(3, 4),
- bignum_value,
- infinity_value
- ]
- end
-
- it "returns 0 if positive" do
- @numbers.each do |number|
- number.send(@method).should == 0
- end
- end
-
- it "returns Pi if negative" do
- @numbers.each do |number|
- (0-number).send(@method).should == Math::PI
- end
- end
-
- describe "with a Numeric subclass" do
- it "returns 0 if self#<(0) returns false" do
- numeric = mock_numeric('positive')
- numeric.should_receive(:<).with(0).and_return(false)
- numeric.send(@method).should == 0
- end
-
- it "returns Pi if self#<(0) returns true" do
- numeric = mock_numeric('positive')
- numeric.should_receive(:<).with(0).and_return(true)
- numeric.send(@method).should == Math::PI
- end
- end
-end
diff --git a/spec/ruby/core/numeric/shared/conj.rb b/spec/ruby/core/numeric/shared/conj.rb
deleted file mode 100644
index 6d5197ecab..0000000000
--- a/spec/ruby/core/numeric/shared/conj.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-describe :numeric_conj, shared: true do
- before :each do
- @numbers = [
- 20, # Integer
- 398.72, # Float
- Rational(3, 4), # Rational
- bignum_value,
- infinity_value,
- nan_value
- ]
- end
-
- it "returns self" do
- @numbers.each do |number|
- number.send(@method).should equal(number)
- end
- end
-end
diff --git a/spec/ruby/core/numeric/shared/imag.rb b/spec/ruby/core/numeric/shared/imag.rb
deleted file mode 100644
index ac2da40a3b..0000000000
--- a/spec/ruby/core/numeric/shared/imag.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-describe :numeric_imag, shared: true do
- before :each do
- @numbers = [
- 20, # Integer
- 398.72, # Float
- Rational(3, 4), # Rational
- bignum_value, # Bignum
- infinity_value,
- nan_value
- ].map{|n| [n,-n]}.flatten
- end
-
- it "returns 0" do
- @numbers.each do |number|
- number.send(@method).should == 0
- end
- end
-
- it "raises an ArgumentError if given any arguments" do
- @numbers.each do |number|
- -> { number.send(@method, number) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/core/numeric/shared/rect.rb b/spec/ruby/core/numeric/shared/rect.rb
index 9cde19a398..cda5fede7f 100644
--- a/spec/ruby/core/numeric/shared/rect.rb
+++ b/spec/ruby/core/numeric/shared/rect.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :numeric_rect, shared: true do
before :each do
@@ -42,7 +42,7 @@ describe :numeric_rect, shared: true do
it "raises an ArgumentError if given any arguments" do
@numbers.each do |number|
- -> { number.send(@method, number) }.should raise_error(ArgumentError)
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/numeric/shared/step.rb b/spec/ruby/core/numeric/shared/step.rb
index 364d4769ad..3072830534 100644
--- a/spec/ruby/core/numeric/shared/step.rb
+++ b/spec/ruby/core/numeric/shared/step.rb
@@ -1,64 +1,56 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
# Describes Numeric#step shared specs between different argument styles.
-# To be able to do it, the @step ivar must contain a Proc that transforms
+# To be able to do it, the @step_args var must contain a Proc that transforms
# the step call arguments passed as positional arguments to the style of
# arguments pretended to test.
describe :numeric_step, :shared => true do
before :each do
ScratchPad.record []
- @prc = -> x { ScratchPad << x }
+ @prc = lambda { |x| ScratchPad << x }
end
it "defaults to step = 1" do
- @step.call(1, 5, &@prc)
+ 1.send(@method, *@step_args.call(5), &@prc)
ScratchPad.recorded.should eql [1, 2, 3, 4, 5]
end
- it "defaults to an infinite limit with a step size of 1 for Integers" do
- 1.step.first(5).should == [1, 2, 3, 4, 5]
- end
-
- it "defaults to an infinite limit with a step size of 1.0 for Floats" do
- 1.0.step.first(5).should == [1.0, 2.0, 3.0, 4.0, 5.0]
- end
-
describe "when self, stop and step are Fixnums" do
it "yields only Fixnums" do
- @step.call(1, 5, 1) { |x| x.should be_an_instance_of(Fixnum) }
+ 1.send(@method, *@step_args.call(5, 1)) { |x| x.should be_an_instance_of(Fixnum) }
end
describe "with a positive step" do
it "yields while increasing self by step until stop is reached" do
- @step.call(1, 5, 1, &@prc)
+ 1.send(@method, *@step_args.call(5, 1), &@prc)
ScratchPad.recorded.should eql [1, 2, 3, 4, 5]
end
it "yields once when self equals stop" do
- @step.call(1, 1, 1, &@prc)
+ 1.send(@method, *@step_args.call(1, 1), &@prc)
ScratchPad.recorded.should eql [1]
end
it "does not yield when self is greater than stop" do
- @step.call(2, 1, 1, &@prc)
+ 2.send(@method, *@step_args.call(1, 1), &@prc)
ScratchPad.recorded.should eql []
end
end
describe "with a negative step" do
it "yields while decreasing self by step until stop is reached" do
- @step.call(5, 1, -1, &@prc)
+ 5.send(@method, *@step_args.call(1, -1), &@prc)
ScratchPad.recorded.should eql [5, 4, 3, 2, 1]
end
it "yields once when self equals stop" do
- @step.call(5, 5, -1, &@prc)
+ 5.send(@method, *@step_args.call(5, -1), &@prc)
ScratchPad.recorded.should eql [5]
end
it "does not yield when self is less than stop" do
- @step.call(1, 5, -1, &@prc)
+ 1.send(@method, *@step_args.call(5, -1), &@prc)
ScratchPad.recorded.should == []
end
end
@@ -66,157 +58,156 @@ describe :numeric_step, :shared => true do
describe "when at least one of self, stop or step is a Float" do
it "yields Floats even if only self is a Float" do
- @step.call(1.5, 5, 1) { |x| x.should be_an_instance_of(Float) }
+ 1.5.send(@method, *@step_args.call(5, 1)) { |x| x.should be_an_instance_of(Float) }
end
it "yields Floats even if only stop is a Float" do
- @step.call(1, 5.0, 1) { |x| x.should be_an_instance_of(Float) }
+ 1.send(@method, *@step_args.call(5.0, 1)) { |x| x.should be_an_instance_of(Float) }
end
it "yields Floats even if only step is a Float" do
- @step.call(1, 5, 1.0) { |x| x.should be_an_instance_of(Float) }
+ 1.send(@method, *@step_args.call(5, 1.0)) { |x| x.should be_an_instance_of(Float) }
end
describe "with a positive step" do
it "yields while increasing self by step while < stop" do
- @step.call(1.5, 5, 1, &@prc)
+ 1.5.send(@method, *@step_args.call(5, 1), &@prc)
ScratchPad.recorded.should eql [1.5, 2.5, 3.5, 4.5]
end
it "yields once when self equals stop" do
- @step.call(1.5, 1.5, 1, &@prc)
+ 1.5.send(@method, *@step_args.call(1.5, 1), &@prc)
ScratchPad.recorded.should eql [1.5]
end
it "does not yield when self is greater than stop" do
- @step.call(2.5, 1.5, 1, &@prc)
+ 2.5.send(@method, *@step_args.call(1.5, 1), &@prc)
ScratchPad.recorded.should == []
end
it "is careful about not yielding a value greater than limit" do
# As 9*1.3+1.0 == 12.700000000000001 > 12.7, we test:
- @step.call(1.0, 12.7, 1.3, &@prc)
+ 1.0.send(@method, *@step_args.call(12.7, 1.3), &@prc)
ScratchPad.recorded.should eql [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7]
end
end
describe "with a negative step" do
it "yields while decreasing self by step while self > stop" do
- @step.call(5, 1.5, -1, &@prc)
+ 5.send(@method, *@step_args.call(1.5, -1), &@prc)
ScratchPad.recorded.should eql [5.0, 4.0, 3.0, 2.0]
end
it "yields once when self equals stop" do
- @step.call(1.5, 1.5, -1, &@prc)
+ 1.5.send(@method, *@step_args.call(1.5, -1), &@prc)
ScratchPad.recorded.should eql [1.5]
end
it "does not yield when self is less than stop" do
- @step.call(1, 5, -1.5, &@prc)
+ 1.send(@method, *@step_args.call(5, -1.5), &@prc)
ScratchPad.recorded.should == []
end
it "is careful about not yielding a value smaller than limit" do
# As -9*1.3-1.0 == -12.700000000000001 < -12.7, we test:
- @step.call(-1.0, -12.7, -1.3, &@prc)
+ -1.0.send(@method, *@step_args.call(-12.7, -1.3), &@prc)
ScratchPad.recorded.should eql [-1.0, -2.3, -3.6, -4.9, -6.2, -7.5, -8.8, -10.1, -11.4, -12.7]
end
end
describe "with a positive Infinity step" do
it "yields once if self < stop" do
- @step.call(42, 100, infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(100, infinity_value), &@prc)
ScratchPad.recorded.should eql [42.0]
end
it "yields once when stop is Infinity" do
- @step.call(42, infinity_value, infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(infinity_value, infinity_value), &@prc)
ScratchPad.recorded.should eql [42.0]
end
it "yields once when self equals stop" do
- @step.call(42, 42, infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(42, infinity_value), &@prc)
ScratchPad.recorded.should eql [42.0]
end
it "yields once when self and stop are Infinity" do
- # @step.call(infinity_value, infinity_value, infinity_value, &@prc)
- @step.call(infinity_value, infinity_value, infinity_value, &@prc)
+ (infinity_value).send(@method, *@step_args.call(infinity_value, infinity_value), &@prc)
ScratchPad.recorded.should == [infinity_value]
end
it "does not yield when self > stop" do
- @step.call(100, 42, infinity_value, &@prc)
+ 100.send(@method, *@step_args.call(42, infinity_value), &@prc)
ScratchPad.recorded.should == []
end
it "does not yield when stop is -Infinity" do
- @step.call(42, -infinity_value, infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(-infinity_value, infinity_value), &@prc)
ScratchPad.recorded.should == []
end
end
describe "with a negative Infinity step" do
it "yields once if self > stop" do
- @step.call(42, 6, -infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(6, -infinity_value), &@prc)
ScratchPad.recorded.should eql [42.0]
end
it "yields once if stop is -Infinity" do
- @step.call(42, -infinity_value, -infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(-infinity_value, -infinity_value), &@prc)
ScratchPad.recorded.should eql [42.0]
end
it "yields once when self equals stop" do
- @step.call(42, 42, -infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(42, -infinity_value), &@prc)
ScratchPad.recorded.should eql [42.0]
end
it "yields once when self and stop are Infinity" do
- @step.call(infinity_value, infinity_value, -infinity_value, &@prc)
+ (infinity_value).send(@method, *@step_args.call(infinity_value, -infinity_value), &@prc)
ScratchPad.recorded.should == [infinity_value]
end
it "does not yield when self > stop" do
- @step.call(42, 100, -infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(100, -infinity_value), &@prc)
ScratchPad.recorded.should == []
end
it "does not yield when stop is Infinity" do
- @step.call(42, infinity_value, -infinity_value, &@prc)
+ 42.send(@method, *@step_args.call(infinity_value, -infinity_value), &@prc)
ScratchPad.recorded.should == []
end
end
describe "with a Infinity stop and a positive step" do
it "does not yield when self is infinity" do
- @step.call(infinity_value, infinity_value, 1, &@prc)
+ (infinity_value).send(@method, *@step_args.call(infinity_value, 1), &@prc)
ScratchPad.recorded.should == []
end
end
describe "with a Infinity stop and a negative step" do
it "does not yield when self is negative infinity" do
- @step.call(-infinity_value, infinity_value, -1, &@prc)
+ (-infinity_value).send(@method, *@step_args.call(infinity_value, -1), &@prc)
ScratchPad.recorded.should == []
end
it "does not yield when self is positive infinity" do
- @step.call(infinity_value, infinity_value, -1, &@prc)
+ infinity_value.send(@method, *@step_args.call(infinity_value, -1), &@prc)
ScratchPad.recorded.should == []
end
end
describe "with a negative Infinity stop and a positive step" do
it "does not yield when self is negative infinity" do
- @step.call(-infinity_value, -infinity_value, 1, &@prc)
+ (-infinity_value).send(@method, *@step_args.call(-infinity_value, 1), &@prc)
ScratchPad.recorded.should == []
end
end
describe "with a negative Infinity stop and a negative step" do
it "does not yield when self is negative infinity" do
- @step.call(-infinity_value, -infinity_value, -1, &@prc)
+ (-infinity_value).send(@method, *@step_args.call(-infinity_value, -1), &@prc)
ScratchPad.recorded.should == []
end
end
@@ -225,6 +216,9 @@ describe :numeric_step, :shared => true do
describe "when step is a String" do
error = nil
+ ruby_version_is ""..."2.4" do
+ error = ArgumentError
+ end
ruby_version_is "2.4"..."2.5" do
error = TypeError
end
@@ -234,67 +228,62 @@ describe :numeric_step, :shared => true do
describe "with self and stop as Fixnums" do
it "raises an #{error} when step is a numeric representation" do
- -> { @step.call(1, 5, "1") {} }.should raise_error(error)
- -> { @step.call(1, 5, "0.1") {} }.should raise_error(error)
- -> { @step.call(1, 5, "1/3") {} }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "1")) {} }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "0.1")) {} }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "1/3")) {} }.should raise_error(error)
end
it "raises an #{error} with step as an alphanumeric string" do
- -> { @step.call(1, 5, "foo") {} }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "foo")) {} }.should raise_error(error)
end
end
describe "with self and stop as Floats" do
it "raises an #{error} when step is a numeric representation" do
- -> { @step.call(1.1, 5.1, "1") {} }.should raise_error(error)
- -> { @step.call(1.1, 5.1, "0.1") {} }.should raise_error(error)
- -> { @step.call(1.1, 5.1, "1/3") {} }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "1")) {} }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "0.1")) {} }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "1/3")) {} }.should raise_error(error)
end
it "raises an #{error} with step as an alphanumeric string" do
- -> { @step.call(1.1, 5.1, "foo") {} }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "foo")) {} }.should raise_error(error)
end
end
end
it "does not rescue ArgumentError exceptions" do
- -> { @step.call(1, 2) { raise ArgumentError, "" }}.should raise_error(ArgumentError)
+ lambda { 1.send(@method, *@step_args.call(2)) { raise ArgumentError, "" }}.should raise_error(ArgumentError)
end
it "does not rescue TypeError exceptions" do
- -> { @step.call(1, 2) { raise TypeError, "" } }.should raise_error(TypeError)
+ lambda { 1.send(@method, *@step_args.call(2)) { raise TypeError, "" } }.should raise_error(TypeError)
end
describe "when no block is given" do
- step_enum_class = Enumerator
- ruby_version_is "2.6" do
- step_enum_class = Enumerator::ArithmeticSequence
- end
-
- it "returns an #{step_enum_class} when step is 0" do
- @step.call(1, 2, 0).should be_an_instance_of(step_enum_class)
+ it "returns an Enumerator when step is 0" do
+ 1.send(@method, *@step_args.call(2, 0)).should be_an_instance_of(Enumerator)
end
- it "returns an #{step_enum_class} when not passed a block and self > stop" do
- @step.call(1, 0, 2).should be_an_instance_of(step_enum_class)
+ it "returns an Enumerator when not passed a block and self > stop" do
+ 1.send(@method, *@step_args.call(0, 2)).should be_an_instance_of(Enumerator)
end
- it "returns an #{step_enum_class} when not passed a block and self < stop" do
- @step.call(1, 2, 3).should be_an_instance_of(step_enum_class)
+ it "returns an Enumerator when not passed a block and self < stop" do
+ 1.send(@method, *@step_args.call(2, 3)).should be_an_instance_of(Enumerator)
end
- it "returns an #{step_enum_class} that uses the given step" do
- @step.call(0, 5, 2).to_a.should eql [0, 2, 4]
+ it "returns an Enumerator that uses the given step" do
+ 0.send(@method, *@step_args.call(5, 2)).to_a.should eql [0, 2, 4]
end
describe "when step is a String" do
describe "with self and stop as Fixnums" do
it "returns an Enumerator" do
- @step.call(1, 5, "foo").should be_an_instance_of(Enumerator)
+ 1.send(@method, *@step_args.call(5, "foo")).should be_an_instance_of(Enumerator)
end
end
describe "with self and stop as Floats" do
it "returns an Enumerator" do
- @step.call(1.1, 5.1, "foo").should be_an_instance_of(Enumerator)
+ 1.1.send(@method, *@step_args.call(5.1, "foo")).should be_an_instance_of(Enumerator)
end
end
end
@@ -303,6 +292,9 @@ describe :numeric_step, :shared => true do
describe "size" do
describe "when step is a String" do
error = nil
+ ruby_version_is ""..."2.4" do
+ error = ArgumentError
+ end
ruby_version_is "2.4"..."2.5" do
error = TypeError
end
@@ -312,119 +304,119 @@ describe :numeric_step, :shared => true do
describe "with self and stop as Fixnums" do
it "raises an #{error} when step is a numeric representation" do
- -> { @step.call(1, 5, "1").size }.should raise_error(error)
- -> { @step.call(1, 5, "0.1").size }.should raise_error(error)
- -> { @step.call(1, 5, "1/3").size }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "1")).size }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "0.1")).size }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "1/3")).size }.should raise_error(error)
end
it "raises an #{error} with step as an alphanumeric string" do
- -> { @step.call(1, 5, "foo").size }.should raise_error(error)
+ lambda { 1.send(@method, *@step_args.call(5, "foo")).size }.should raise_error(error)
end
end
describe "with self and stop as Floats" do
it "raises an #{error} when step is a numeric representation" do
- -> { @step.call(1.1, 5.1, "1").size }.should raise_error(error)
- -> { @step.call(1.1, 5.1, "0.1").size }.should raise_error(error)
- -> { @step.call(1.1, 5.1, "1/3").size }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "1")).size }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "0.1")).size }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "1/3")).size }.should raise_error(error)
end
it "raises an #{error} with step as an alphanumeric string" do
- -> { @step.call(1.1, 5.1, "foo").size }.should raise_error(error)
+ lambda { 1.1.send(@method, *@step_args.call(5.1, "foo")).size }.should raise_error(error)
end
end
end
describe "when self, stop and step are Fixnums and step is positive" do
it "returns the difference between self and stop divided by the number of steps" do
- @step.call(5, 10, 11).size.should == 1
- @step.call(5, 10, 6).size.should == 1
- @step.call(5, 10, 5).size.should == 2
- @step.call(5, 10, 4).size.should == 2
- @step.call(5, 10, 2).size.should == 3
- @step.call(5, 10, 1).size.should == 6
- @step.call(5, 10).size.should == 6
- @step.call(10, 10, 1).size.should == 1
+ 5.send(@method, *@step_args.call(10, 11)).size.should == 1
+ 5.send(@method, *@step_args.call(10, 6)).size.should == 1
+ 5.send(@method, *@step_args.call(10, 5)).size.should == 2
+ 5.send(@method, *@step_args.call(10, 4)).size.should == 2
+ 5.send(@method, *@step_args.call(10, 2)).size.should == 3
+ 5.send(@method, *@step_args.call(10, 1)).size.should == 6
+ 5.send(@method, *@step_args.call(10)).size.should == 6
+ 10.send(@method, *@step_args.call(10, 1)).size.should == 1
end
it "returns 0 if value > limit" do
- @step.call(11, 10, 1).size.should == 0
+ 11.send(@method, *@step_args.call(10, 1)).size.should == 0
end
end
describe "when self, stop and step are Fixnums and step is negative" do
it "returns the difference between self and stop divided by the number of steps" do
- @step.call(10, 5, -11).size.should == 1
- @step.call(10, 5, -6).size.should == 1
- @step.call(10, 5, -5).size.should == 2
- @step.call(10, 5, -4).size.should == 2
- @step.call(10, 5, -2).size.should == 3
- @step.call(10, 5, -1).size.should == 6
- @step.call(10, 10, -1).size.should == 1
+ 10.send(@method, *@step_args.call(5, -11)).size.should == 1
+ 10.send(@method, *@step_args.call(5, -6)).size.should == 1
+ 10.send(@method, *@step_args.call(5, -5)).size.should == 2
+ 10.send(@method, *@step_args.call(5, -4)).size.should == 2
+ 10.send(@method, *@step_args.call(5, -2)).size.should == 3
+ 10.send(@method, *@step_args.call(5, -1)).size.should == 6
+ 10.send(@method, *@step_args.call(10, -1)).size.should == 1
end
it "returns 0 if value < limit" do
- @step.call(10, 11, -1).size.should == 0
+ 10.send(@method, *@step_args.call(11, -1)).size.should == 0
end
end
describe "when self, stop or step is a Float" do
describe "and step is positive" do
it "returns the difference between self and stop divided by the number of steps" do
- @step.call(5, 10, 11.0).size.should == 1
- @step.call(5, 10, 6.0).size.should == 1
- @step.call(5, 10, 5.0).size.should == 2
- @step.call(5, 10, 4.0).size.should == 2
- @step.call(5, 10, 2.0).size.should == 3
- @step.call(5, 10, 0.5).size.should == 11
- @step.call(5, 10, 1.0).size.should == 6
- @step.call(5, 10.5).size.should == 6
- @step.call(10, 10, 1.0).size.should == 1
+ 5.send(@method, *@step_args.call(10, 11.0)).size.should == 1
+ 5.send(@method, *@step_args.call(10, 6.0)).size.should == 1
+ 5.send(@method, *@step_args.call(10, 5.0)).size.should == 2
+ 5.send(@method, *@step_args.call(10, 4.0)).size.should == 2
+ 5.send(@method, *@step_args.call(10, 2.0)).size.should == 3
+ 5.send(@method, *@step_args.call(10, 0.5)).size.should == 11
+ 5.send(@method, *@step_args.call(10, 1.0)).size.should == 6
+ 5.send(@method, *@step_args.call(10.5)).size.should == 6
+ 10.send(@method, *@step_args.call(10, 1.0)).size.should == 1
end
it "returns 0 if value > limit" do
- @step.call(10, 5.5).size.should == 0
- @step.call(11, 10, 1.0).size.should == 0
- @step.call(11, 10, 1.5).size.should == 0
- @step.call(10, 5, infinity_value).size.should == 0
+ 10.send(@method, *@step_args.call(5.5)).size.should == 0
+ 11.send(@method, *@step_args.call(10, 1.0)).size.should == 0
+ 11.send(@method, *@step_args.call(10, 1.5)).size.should == 0
+ 10.send(@method, *@step_args.call(5, infinity_value)).size.should == 0
end
it "returns 1 if step is infinity_value" do
- @step.call(5, 10, infinity_value).size.should == 1
+ 5.send(@method, *@step_args.call(10, infinity_value)).size.should == 1
end
end
describe "and step is negative" do
it "returns the difference between self and stop divided by the number of steps" do
- @step.call(10, 5, -11.0).size.should == 1
- @step.call(10, 5, -6.0).size.should == 1
- @step.call(10, 5, -5.0).size.should == 2
- @step.call(10, 5, -4.0).size.should == 2
- @step.call(10, 5, -2.0).size.should == 3
- @step.call(10, 5, -0.5).size.should == 11
- @step.call(10, 5, -1.0).size.should == 6
- @step.call(10, 10, -1.0).size.should == 1
+ 10.send(@method, *@step_args.call(5, -11.0)).size.should == 1
+ 10.send(@method, *@step_args.call(5, -6.0)).size.should == 1
+ 10.send(@method, *@step_args.call(5, -5.0)).size.should == 2
+ 10.send(@method, *@step_args.call(5, -4.0)).size.should == 2
+ 10.send(@method, *@step_args.call(5, -2.0)).size.should == 3
+ 10.send(@method, *@step_args.call(5, -0.5)).size.should == 11
+ 10.send(@method, *@step_args.call(5, -1.0)).size.should == 6
+ 10.send(@method, *@step_args.call(10, -1.0)).size.should == 1
end
it "returns 0 if value < limit" do
- @step.call(10, 11, -1.0).size.should == 0
- @step.call(10, 11, -1.5).size.should == 0
- @step.call(5, 10, -infinity_value).size.should == 0
+ 10.send(@method, *@step_args.call(11, -1.0)).size.should == 0
+ 10.send(@method, *@step_args.call(11, -1.5)).size.should == 0
+ 5.send(@method, *@step_args.call(10, -infinity_value)).size.should == 0
end
it "returns 1 if step is infinity_value" do
- @step.call(10, 5, -infinity_value).size.should == 1
+ 10.send(@method, *@step_args.call(5, -infinity_value)).size.should == 1
end
end
end
describe "when stop is not passed" do
it "returns infinity_value" do
- @step.call(1).size.should == infinity_value
+ 1.send(@method, *@step_args.call()).size.should == infinity_value
end
end
describe "when stop is nil" do
it "returns infinity_value" do
- @step.call(1, nil, 5).size.should == infinity_value
+ 1.send(@method, *@step_args.call(nil, 5)).size.should == infinity_value
end
end
end
diff --git a/spec/ruby/core/numeric/singleton_method_added_spec.rb b/spec/ruby/core/numeric/singleton_method_added_spec.rb
index 2091398e5d..a650d286f2 100644
--- a/spec/ruby/core/numeric/singleton_method_added_spec.rb
+++ b/spec/ruby/core/numeric/singleton_method_added_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#singleton_method_added" do
before :all do
@@ -18,22 +18,22 @@ describe "Numeric#singleton_method_added" do
end
it "raises a TypeError when trying to define a singleton method on a Numeric" do
- -> do
+ lambda do
a = NumericSpecs::Subclass.new
def a.test; end
end.should raise_error(TypeError)
- -> do
+ lambda do
a = 1
def a.test; end
end.should raise_error(TypeError)
- -> do
+ lambda do
a = 1.5
def a.test; end
end.should raise_error(TypeError)
- -> do
+ lambda do
a = bignum_value
def a.test; end
end.should raise_error(TypeError)
diff --git a/spec/ruby/core/numeric/step_spec.rb b/spec/ruby/core/numeric/step_spec.rb
index e9067864c8..256c150d4e 100644
--- a/spec/ruby/core/numeric/step_spec.rb
+++ b/spec/ruby/core/numeric/step_spec.rb
@@ -1,82 +1,45 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/step'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/step', __FILE__)
describe "Numeric#step" do
describe 'with positional args' do
it "raises an ArgumentError when step is 0" do
- -> { 1.step(5, 0) {} }.should raise_error(ArgumentError)
+ lambda { 1.step(5, 0) {} }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when step is 0.0" do
- -> { 1.step(2, 0.0) {} }.should raise_error(ArgumentError)
+ lambda { 1.step(2, 0.0) {} }.should raise_error(ArgumentError)
end
before :all do
# This lambda definition limits to return the arguments it receives.
# It's needed to test numeric_step behaviour with positional arguments.
- @step = -> receiver, *args, &block { receiver.step(*args, &block) }
+ @step_args = ->(*args) { args }
end
+
it_behaves_like :numeric_step, :step
describe "when no block is given" do
- step_enum_class = Enumerator
- ruby_version_is "2.6" do
- step_enum_class = Enumerator::ArithmeticSequence
- end
-
- it "returns an #{step_enum_class} when step is 0" do
- 1.step(5, 0).should be_an_instance_of(step_enum_class)
+ it "returns an Enumerator when step is 0" do
+ 1.step(5, 0).should be_an_instance_of(Enumerator)
end
- it "returns an #{step_enum_class} when step is 0.0" do
- 1.step(2, 0.0).should be_an_instance_of(step_enum_class)
+ it "returns an Enumerator when step is 0.0" do
+ 1.step(2, 0.0).should be_an_instance_of(Enumerator)
end
- describe "returned #{step_enum_class}" do
+ describe "returned Enumerator" do
describe "size" do
- ruby_version_is ""..."2.6" do
- it "raises an ArgumentError when step is 0" do
- enum = 1.step(5, 0)
- -> { enum.size }.should raise_error(ArgumentError)
- end
-
- it "raises an ArgumentError when step is 0.0" do
- enum = 1.step(2, 0.0)
- -> { enum.size }.should raise_error(ArgumentError)
- end
- end
-
- ruby_version_is "2.6" do
- it "is infinity when step is 0" do
- enum = 1.step(5, 0)
- enum.size.should == Float::INFINITY
- end
-
- it "is infinity when step is 0.0" do
- enum = 1.step(2, 0.0)
- enum.size.should == Float::INFINITY
- end
+ it "raises an ArgumentError when step is 0" do
+ enum = 1.step(5, 0)
+ lambda { enum.size }.should raise_error(ArgumentError)
end
- it "defaults to an infinite size" do
- enum = 1.step
- enum.size.should == Float::INFINITY
- end
- end
-
- describe "type" do
- ruby_version_is ""..."2.6" do
- it "returns an instance of Enumerator" do
- 1.step(10).class.should == Enumerator
- end
- end
-
- ruby_version_is "2.6" do
- it "returns an instance of Enumerator::ArithmeticSequence" do
- 1.step(10).class.should == Enumerator::ArithmeticSequence
- end
+ it "raises an ArgumentError when step is 0.0" do
+ enum = 1.step(2, 0.0)
+ lambda { enum.size }.should raise_error(ArgumentError)
end
end
end
@@ -86,11 +49,11 @@ describe "Numeric#step" do
describe 'with keyword arguments' do
it "doesn't raise an error when step is 0" do
- -> { 1.step(to: 5, by: 0) { break } }.should_not raise_error
+ lambda { 1.step(to: 5, by: 0) { break } }.should_not raise_error
end
it "doesn't raise an error when step is 0.0" do
- -> { 1.step(to: 2, by: 0.0) { break } }.should_not raise_error
+ lambda { 1.step(to: 2, by: 0.0) { break } }.should_not raise_error
end
it "should loop over self when step is 0 or 0.0" do
@@ -118,7 +81,7 @@ describe "Numeric#step" do
1.step(to: Float::INFINITY, by: 42).size.should == infinity_value
end
- it "should return infinity_value when descending towards a limit of -Float::INFINITY" do
+ it "should return infinity_value when decending towards a limit of -Float::INFINITY" do
1.step(to: -Float::INFINITY, by: -42).size.should == infinity_value
end
@@ -134,12 +97,13 @@ describe "Numeric#step" do
end
before :all do
- # This lambda transforms a positional step method args into keyword arguments.
+ # This lambda transforms a positional step method args into
+ # keyword arguments.
# It's needed to test numeric_step behaviour with keyword arguments.
- @step = -> receiver, *args, &block do
- kw_args = { to: args[0] }
+ @step_args = ->(*args) do
+ kw_args = {to: args[0]}
kw_args[:by] = args[1] if args.size == 2
- receiver.step(**kw_args, &block)
+ [kw_args]
end
end
it_behaves_like :numeric_step, :step
@@ -147,19 +111,19 @@ describe "Numeric#step" do
describe 'with mixed arguments' do
it "doesn't raise an error when step is 0" do
- -> { 1.step(5, by: 0) { break } }.should_not raise_error
+ lambda { 1.step(5, by: 0) { break } }.should_not raise_error
end
it "doesn't raise an error when step is 0.0" do
- -> { 1.step(2, by: 0.0) { break } }.should_not raise_error
+ lambda { 1.step(2, by: 0.0) { break } }.should_not raise_error
end
it "raises a ArgumentError when limit and to are defined" do
- -> { 1.step(5, 1, to: 5) { break } }.should raise_error(ArgumentError)
+ lambda { 1.step(5, 1, to: 5) { break } }.should raise_error(ArgumentError)
end
it "raises a ArgumentError when step and by are defined" do
- -> { 1.step(5, 1, by: 5) { break } }.should raise_error(ArgumentError)
+ lambda { 1.step(5, 1, by: 5) { break } }.should raise_error(ArgumentError)
end
it "should loop over self when step is 0 or 0.0" do
@@ -181,17 +145,16 @@ describe "Numeric#step" do
end
end
end
-
before :all do
# This lambda definition transforms a positional step method args into
# a mix of positional and keyword arguments.
# It's needed to test numeric_step behaviour with positional mixed with
# keyword arguments.
- @step = -> receiver, *args, &block do
+ @step_args = ->(*args) do
if args.size == 2
- receiver.step(args[0], by: args[1], &block)
+ [args[0], {by: args[1]}]
else
- receiver.step(*args, &block)
+ args
end
end
end
diff --git a/spec/ruby/core/numeric/to_c_spec.rb b/spec/ruby/core/numeric/to_c_spec.rb
index 75245a612e..38452231b0 100644
--- a/spec/ruby/core/numeric/to_c_spec.rb
+++ b/spec/ruby/core/numeric/to_c_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Numeric#to_c" do
before :all do
diff --git a/spec/ruby/core/numeric/to_int_spec.rb b/spec/ruby/core/numeric/to_int_spec.rb
index 3cc39a6d40..4f1df3e042 100644
--- a/spec/ruby/core/numeric/to_int_spec.rb
+++ b/spec/ruby/core/numeric/to_int_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#to_int" do
it "returns self#to_i" do
diff --git a/spec/ruby/core/numeric/truncate_spec.rb b/spec/ruby/core/numeric/truncate_spec.rb
index f1592334c5..f1a2d4de64 100644
--- a/spec/ruby/core/numeric/truncate_spec.rb
+++ b/spec/ruby/core/numeric/truncate_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#truncate" do
before :each do
diff --git a/spec/ruby/core/numeric/uminus_spec.rb b/spec/ruby/core/numeric/uminus_spec.rb
index 39065fa392..7385f5f599 100644
--- a/spec/ruby/core/numeric/uminus_spec.rb
+++ b/spec/ruby/core/numeric/uminus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Numeric#-@" do
it "returns the same value with opposite sign (integers)" do
diff --git a/spec/ruby/core/numeric/uplus_spec.rb b/spec/ruby/core/numeric/uplus_spec.rb
index 88cf5e037b..557142295a 100644
--- a/spec/ruby/core/numeric/uplus_spec.rb
+++ b/spec/ruby/core/numeric/uplus_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#+@" do
it "returns self" do
diff --git a/spec/ruby/core/numeric/zero_spec.rb b/spec/ruby/core/numeric/zero_spec.rb
index 9de71d1dc9..d46e8807ea 100644
--- a/spec/ruby/core/numeric/zero_spec.rb
+++ b/spec/ruby/core/numeric/zero_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Numeric#zero?" do
before :each do
diff --git a/spec/ruby/core/objectspace/_id2ref_spec.rb b/spec/ruby/core/objectspace/_id2ref_spec.rb
index 1d8ad02deb..6e0b6e03fb 100644
--- a/spec/ruby/core/objectspace/_id2ref_spec.rb
+++ b/spec/ruby/core/objectspace/_id2ref_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace._id2ref" do
it "converts an object id to a reference to the object" do
diff --git a/spec/ruby/core/objectspace/add_finalizer_spec.rb b/spec/ruby/core/objectspace/add_finalizer_spec.rb
index 3540ac0413..2d529f2d6c 100644
--- a/spec/ruby/core/objectspace/add_finalizer_spec.rb
+++ b/spec/ruby/core/objectspace/add_finalizer_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace.add_finalizer" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/objectspace/call_finalizer_spec.rb b/spec/ruby/core/objectspace/call_finalizer_spec.rb
index 6dce92ddd6..bb7cee68a4 100644
--- a/spec/ruby/core/objectspace/call_finalizer_spec.rb
+++ b/spec/ruby/core/objectspace/call_finalizer_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace.call_finalizer" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/objectspace/count_objects_spec.rb b/spec/ruby/core/objectspace/count_objects_spec.rb
index e9831a3a42..3e77d562a8 100644
--- a/spec/ruby/core/objectspace/count_objects_spec.rb
+++ b/spec/ruby/core/objectspace/count_objects_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace.count_objects" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/objectspace/define_finalizer_spec.rb b/spec/ruby/core/objectspace/define_finalizer_spec.rb
index 3f7b1ae576..969e8b16b0 100644
--- a/spec/ruby/core/objectspace/define_finalizer_spec.rb
+++ b/spec/ruby/core/objectspace/define_finalizer_spec.rb
@@ -1,17 +1,19 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# NOTE: A call to define_finalizer does not guarantee that the
# passed proc or callable will be called at any particular time.
+# It is highly questionable whether these aspects of ObjectSpace
+# should be spec'd at all.
describe "ObjectSpace.define_finalizer" do
it "raises an ArgumentError if the action does not respond to call" do
- -> {
+ lambda {
ObjectSpace.define_finalizer("", mock("ObjectSpace.define_finalizer no #call"))
}.should raise_error(ArgumentError)
end
it "accepts an object and a proc" do
- handler = -> obj { obj }
+ handler = lambda { |obj| obj }
ObjectSpace.define_finalizer("garbage", handler).should == [0, handler]
end
@@ -22,47 +24,78 @@ describe "ObjectSpace.define_finalizer" do
end
it "raises ArgumentError trying to define a finalizer on a non-reference" do
- -> {
+ lambda {
ObjectSpace.define_finalizer(:blah) { 1 }
}.should raise_error(ArgumentError)
end
# see [ruby-core:24095]
- it "calls finalizer on process termination" do
- code = <<-RUBY
- def scoped
- Proc.new { puts "finalized" }
+ with_feature :fork do
+ it "calls finalizer on process termination" do
+ rd, wr = IO.pipe
+ pid = Process.fork do
+ rd.close
+ handler = ObjectSpaceFixtures.scoped(wr)
+ obj = "Test"
+ ObjectSpace.define_finalizer(obj, handler)
+ exit 0
end
- handler = scoped
- obj = "Test"
- ObjectSpace.define_finalizer(obj, handler)
- exit 0
- RUBY
- ruby_exe(code).should == "finalized\n"
- end
+ wr.close
+ begin
+ rd.read.should == "finalized"
+ ensure
+ rd.close
+ Process.wait pid
+ end
+ end
- it "calls finalizer at exit even if it is self-referencing" do
- code = <<-RUBY
- obj = "Test"
- handler = Proc.new { puts "finalized" }
- ObjectSpace.define_finalizer(obj, handler)
- exit 0
- RUBY
+ it "calls finalizer at exit even if it is self-referencing" do
+ rd, wr = IO.pipe
+ pid = Process.fork do
+ rd.close
+ obj = "Test"
+ handler = Proc.new { wr.write "finalized"; wr.close }
+ ObjectSpace.define_finalizer(obj, handler)
+ exit 0
+ end
- ruby_exe(code).should == "finalized\n"
- end
+ wr.close
+ begin
+ rd.read.should == "finalized"
+ ensure
+ rd.close
+ Process.wait pid
+ end
+ end
- it "allows multiple finalizers with different 'callables' to be defined" do
- code = <<-RUBY
- obj = Object.new
+ # These specs are defined under the fork specs because there is no
+ # deterministic way to force finalizers to be run, except process exit, so
+ # we rely on that.
+ it "allows multiple finalizers with different 'callables' to be defined" do
+ rd1, wr1 = IO.pipe
+ rd2, wr2 = IO.pipe
+
+ pid = Kernel::fork do
+ rd1.close
+ rd2.close
+ obj = mock("ObjectSpace.define_finalizer multiple")
+
+ ObjectSpace.define_finalizer(obj, Proc.new { wr1.write "finalized1"; wr1.close })
+ ObjectSpace.define_finalizer(obj, Proc.new { wr2.write "finalized2"; wr2.close })
+
+ exit 0
+ end
- ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized1\n" })
- ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized2\n" })
+ wr1.close
+ wr2.close
- exit 0
- RUBY
+ rd1.read.should == "finalized1"
+ rd2.read.should == "finalized2"
- ruby_exe(code).lines.sort.should == ["finalized1\n", "finalized2\n"]
+ rd1.close
+ rd2.close
+ Process.wait pid
+ end
end
end
diff --git a/spec/ruby/core/objectspace/each_object_spec.rb b/spec/ruby/core/objectspace/each_object_spec.rb
index 09a582afaf..604b45cb34 100644
--- a/spec/ruby/core/objectspace/each_object_spec.rb
+++ b/spec/ruby/core/objectspace/each_object_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "ObjectSpace.each_object" do
it "calls the block once for each living, non-immediate object in the Ruby process" do
@@ -184,9 +184,18 @@ describe "ObjectSpace.each_object" do
hidden.should == nil
end
- it "walks singleton classes" do
- @sclass.should be_kind_of(@meta)
- ObjectSpace.each_object(@meta).to_a.should include(@sclass)
+ ruby_version_is ""..."2.3" do
+ it "does not walk singleton classes" do
+ @sclass.should be_kind_of(@meta)
+ ObjectSpace.each_object(@meta).to_a.should_not include(@sclass)
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "walks singleton classes" do
+ @sclass.should be_kind_of(@meta)
+ ObjectSpace.each_object(@meta).to_a.should include(@sclass)
+ end
end
end
@@ -201,8 +210,11 @@ describe "ObjectSpace.each_object" do
expected = [ a, b, c, d ]
- expected << c_sclass
- c_sclass.should be_kind_of(a.singleton_class)
+ # singleton classes should be walked only on >= 2.3
+ ruby_version_is "2.3" do
+ expected << c_sclass
+ c_sclass.should be_kind_of(a.singleton_class)
+ end
b.extend Enumerable # included modules should not be walked
diff --git a/spec/ruby/core/objectspace/finalizers_spec.rb b/spec/ruby/core/objectspace/finalizers_spec.rb
index e7f20fc8a0..8d5f6cc029 100644
--- a/spec/ruby/core/objectspace/finalizers_spec.rb
+++ b/spec/ruby/core/objectspace/finalizers_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace.finalizers" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/objectspace/fixtures/classes.rb b/spec/ruby/core/objectspace/fixtures/classes.rb
index 612156c180..9a4b0aa865 100644
--- a/spec/ruby/core/objectspace/fixtures/classes.rb
+++ b/spec/ruby/core/objectspace/fixtures/classes.rb
@@ -24,7 +24,7 @@ module ObjectSpaceFixtures
end
def self.define_finalizer
- handler = -> obj { ScratchPad.record :finalized }
+ handler = lambda { |obj| ScratchPad.record :finalized }
ObjectSpace.define_finalizer "#{rand 5}", handler
end
diff --git a/spec/ruby/core/objectspace/garbage_collect_spec.rb b/spec/ruby/core/objectspace/garbage_collect_spec.rb
index 1aec3ea072..aa7e233b25 100644
--- a/spec/ruby/core/objectspace/garbage_collect_spec.rb
+++ b/spec/ruby/core/objectspace/garbage_collect_spec.rb
@@ -1,17 +1,17 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace.garbage_collect" do
it "can be invoked without any exceptions" do
- -> { ObjectSpace.garbage_collect }.should_not raise_error
+ lambda { ObjectSpace.garbage_collect }.should_not raise_error
end
it "doesn't accept any arguments" do
- -> { ObjectSpace.garbage_collect(1) }.should raise_error(ArgumentError)
+ lambda { ObjectSpace.garbage_collect(1) }.should raise_error(ArgumentError)
end
it "ignores the supplied block" do
- -> { ObjectSpace.garbage_collect {} }.should_not raise_error
+ lambda { ObjectSpace.garbage_collect {} }.should_not raise_error
end
it "always returns nil" do
diff --git a/spec/ruby/core/objectspace/remove_finalizer_spec.rb b/spec/ruby/core/objectspace/remove_finalizer_spec.rb
index 0b2b8cf16b..3053c31511 100644
--- a/spec/ruby/core/objectspace/remove_finalizer_spec.rb
+++ b/spec/ruby/core/objectspace/remove_finalizer_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace.remove_finalizer" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/objectspace/undefine_finalizer_spec.rb b/spec/ruby/core/objectspace/undefine_finalizer_spec.rb
index 11d43121f8..98f521db98 100644
--- a/spec/ruby/core/objectspace/undefine_finalizer_spec.rb
+++ b/spec/ruby/core/objectspace/undefine_finalizer_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ObjectSpace.undefine_finalizer" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/proc/allocate_spec.rb b/spec/ruby/core/proc/allocate_spec.rb
index 54e1b69df9..6bfb94dbc2 100644
--- a/spec/ruby/core/proc/allocate_spec.rb
+++ b/spec/ruby/core/proc/allocate_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc.allocate" do
it "raises a TypeError" do
- -> {
+ lambda {
Proc.allocate
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/proc/arity_spec.rb b/spec/ruby/core/proc/arity_spec.rb
index f7cb5ad0f8..251710a663 100644
--- a/spec/ruby/core/proc/arity_spec.rb
+++ b/spec/ruby/core/proc/arity_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc#arity" do
SpecEvaluate.desc = "for definition"
diff --git a/spec/ruby/core/proc/binding_spec.rb b/spec/ruby/core/proc/binding_spec.rb
index 86ab6bd400..05cc68217e 100644
--- a/spec/ruby/core/proc/binding_spec.rb
+++ b/spec/ruby/core/proc/binding_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc#binding" do
it "returns a Binding instance" do
- [Proc.new{}, -> {}, proc {}].each { |p|
+ [Proc.new{}, lambda {}, proc {}].each { |p|
p.binding.should be_kind_of(Binding)
}
end
@@ -10,7 +10,7 @@ describe "Proc#binding" do
it "returns the binding associated with self" do
obj = mock('binding')
def obj.test_binding(some, params)
- -> {}
+ lambda {}
end
lambdas_binding = obj.test_binding(1, 2).binding
diff --git a/spec/ruby/core/proc/block_pass_spec.rb b/spec/ruby/core/proc/block_pass_spec.rb
index 99255139d4..e956885654 100644
--- a/spec/ruby/core/proc/block_pass_spec.rb
+++ b/spec/ruby/core/proc/block_pass_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc as a block pass argument" do
def revivify(&b)
@@ -8,36 +8,34 @@ describe "Proc as a block pass argument" do
it "remains the same object if re-vivified by the target method" do
p = Proc.new {}
p2 = revivify(&p)
- p.should equal p2
+ p.object_id.should == p2.object_id
p.should == p2
end
it "remains the same object if reconstructed with Proc.new" do
p = Proc.new {}
p2 = Proc.new(&p)
- p.should equal p2
+ p.object_id.should == p2.object_id
p.should == p2
end
end
-ruby_version_is ""..."2.7" do
- describe "Proc as an implicit block pass argument" do
- def revivify
- Proc.new
- end
+describe "Proc as an implicit block pass argument" do
+ def revivify
+ Proc.new
+ end
- it "remains the same object if re-vivified by the target method" do
- p = Proc.new {}
- p2 = revivify(&p)
- p.should equal p2
- p.should == p2
- end
+ it "remains the same object if re-vivified by the target method" do
+ p = Proc.new {}
+ p2 = revivify(&p)
+ p.object_id.should == p2.object_id
+ p.should == p2
+ end
- it "remains the same object if reconstructed with Proc.new" do
- p = Proc.new {}
- p2 = Proc.new(&p)
- p.should equal p2
- p.should == p2
- end
+ it "remains the same object if reconstructed with Proc.new" do
+ p = Proc.new {}
+ p2 = Proc.new(&p)
+ p.object_id.should == p2.object_id
+ p.should == p2
end
end
diff --git a/spec/ruby/core/proc/call_spec.rb b/spec/ruby/core/proc/call_spec.rb
index 6ec2fc8682..1c28eae9b0 100644
--- a/spec/ruby/core/proc/call_spec.rb
+++ b/spec/ruby/core/proc/call_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/call'
-require_relative 'shared/call_arguments'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/call', __FILE__)
+require File.expand_path('../shared/call_arguments', __FILE__)
describe "Proc#call" do
it_behaves_like :proc_call, :call
diff --git a/spec/ruby/core/proc/case_compare_spec.rb b/spec/ruby/core/proc/case_compare_spec.rb
index f11513cdb9..55760c4ff3 100644
--- a/spec/ruby/core/proc/case_compare_spec.rb
+++ b/spec/ruby/core/proc/case_compare_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/call'
-require_relative 'shared/call_arguments'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/call', __FILE__)
+require File.expand_path('../shared/call_arguments', __FILE__)
describe "Proc#===" do
it_behaves_like :proc_call, :===
diff --git a/spec/ruby/core/proc/clone_spec.rb b/spec/ruby/core/proc/clone_spec.rb
index a1a1292654..0f0806645b 100644
--- a/spec/ruby/core/proc/clone_spec.rb
+++ b/spec/ruby/core/proc/clone_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/dup'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/dup', __FILE__)
describe "Proc#clone" do
- it_behaves_like :proc_dup, :clone
+ it_behaves_like(:proc_dup, :clone)
end
diff --git a/spec/ruby/core/proc/compose_spec.rb b/spec/ruby/core/proc/compose_spec.rb
deleted file mode 100644
index ef9c125ae9..0000000000
--- a/spec/ruby/core/proc/compose_spec.rb
+++ /dev/null
@@ -1,156 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/compose'
-
-ruby_version_is "2.6" do
- describe "Proc#<<" do
- it "returns a Proc that is the composition of self and the passed Proc" do
- upcase = proc { |s| s.upcase }
- succ = proc { |s| s.succ }
-
- (succ << upcase).call('Ruby').should == "RUBZ"
- end
-
- it "calls passed Proc with arguments and then calls self with result" do
- f = proc { |x| x * x }
- g = proc { |x| x + x }
-
- (f << g).call(2).should == 16
- (g << f).call(2).should == 8
- end
-
- it "accepts any callable object" do
- inc = proc { |n| n + 1 }
-
- double = Object.new
- def double.call(n); n * 2; end
-
- (inc << double).call(3).should == 7
- end
-
- it_behaves_like :proc_compose, :<<, -> { proc { |s| s.upcase } }
-
- describe "composition" do
- it "is a Proc" do
- f = proc { |x| x * x }
- g = proc { |x| x + x }
-
- (f << g).is_a?(Proc).should == true
- (f << g).lambda?.should == false
- end
-
- ruby_version_is(''...'2.8') do
- it "is a Proc when other is lambda" do
- f = proc { |x| x * x }
- g = -> x { x + x }
-
- (f << g).is_a?(Proc).should == true
- (f << g).lambda?.should == false
- end
-
- it "is a lambda when self is lambda" do
- f = -> x { x * x }
- g = proc { |x| x + x }
-
- (f << g).is_a?(Proc).should == true
- (f << g).lambda?.should == true
- end
- end
-
- ruby_version_is('2.8') do
- it "is a lambda when parameter is lambda" do
- f = -> x { x * x }
- g = proc { |x| x + x }
- lambda_proc = -> x { x }
-
- (f << g).is_a?(Proc).should == true
- (f << g).lambda?.should == false
- (f << lambda_proc).lambda?.should == true
- end
- end
-
- it "may accept multiple arguments" do
- inc = proc { |n| n + 1 }
- mul = proc { |n, m| n * m }
-
- (inc << mul).call(2, 3).should == 7
- end
-
- it "passes blocks to the second proc" do
- ScratchPad.record []
- one = proc { |&arg| arg.call :one if arg }
- two = proc { |&arg| arg.call :two if arg }
- (one << two).call { |x| ScratchPad << x }
- ScratchPad.recorded.should == [:two]
- end
- end
- end
-
- describe "Proc#>>" do
- it "returns a Proc that is the composition of self and the passed Proc" do
- upcase = proc { |s| s.upcase }
- succ = proc { |s| s.succ }
-
- (succ >> upcase).call('Ruby').should == "RUBZ"
- end
-
- it "calls passed Proc with arguments and then calls self with result" do
- f = proc { |x| x * x }
- g = proc { |x| x + x }
-
- (f >> g).call(2).should == 8
- (g >> f).call(2).should == 16
- end
-
- it "accepts any callable object" do
- inc = proc { |n| n + 1 }
-
- double = Object.new
- def double.call(n); n * 2; end
-
- (inc >> double).call(3).should == 8
- end
-
- it_behaves_like :proc_compose, :>>, -> { proc { |s| s.upcase } }
-
- describe "composition" do
- it "is a Proc" do
- f = proc { |x| x * x }
- g = proc { |x| x + x }
-
- (f >> g).is_a?(Proc).should == true
- (f >> g).lambda?.should == false
- end
-
- it "is a Proc when other is lambda" do
- f = proc { |x| x * x }
- g = -> x { x + x }
-
- (f >> g).is_a?(Proc).should == true
- (f >> g).lambda?.should == false
- end
-
- it "is a lambda when self is lambda" do
- f = -> x { x * x }
- g = proc { |x| x + x }
-
- (f >> g).is_a?(Proc).should == true
- (f >> g).lambda?.should == true
- end
-
- it "may accept multiple arguments" do
- inc = proc { |n| n + 1 }
- mul = proc { |n, m| n * m }
-
- (mul >> inc).call(2, 3).should == 7
- end
-
- it "passes blocks to the first proc" do
- ScratchPad.record []
- one = proc { |&arg| arg.call :one if arg }
- two = proc { |&arg| arg.call :two if arg }
- (one >> two).call { |x| ScratchPad << x }
- ScratchPad.recorded.should == [:one]
- end
- end
- end
-end
diff --git a/spec/ruby/core/proc/curry_spec.rb b/spec/ruby/core/proc/curry_spec.rb
index 24df2a8a72..a294606957 100644
--- a/spec/ruby/core/proc/curry_spec.rb
+++ b/spec/ruby/core/proc/curry_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc#curry" do
before :each do
@proc_add = Proc.new {|x,y,z| (x||0) + (y||0) + (z||0) }
- @lambda_add = -> x, y, z { (x||0) + (y||0) + (z||0) }
+ @lambda_add = lambda {|x,y,z| (x||0) + (y||0) + (z||0) }
end
it "returns a Proc when called on a proc" do
@@ -12,7 +12,7 @@ describe "Proc#curry" do
end
it "returns a Proc when called on a lambda" do
- p = -> { true }
+ p = lambda { true }
p.curry.should be_an_instance_of(Proc)
end
@@ -36,10 +36,10 @@ describe "Proc#curry" do
it "can be called multiple times on the same Proc" do
@proc_add.curry
- -> { @proc_add.curry }.should_not raise_error
+ lambda { @proc_add.curry }.should_not raise_error
@lambda_add.curry
- -> { @lambda_add.curry }.should_not raise_error
+ lambda { @lambda_add.curry }.should_not raise_error
end
it "can be passed superfluous arguments if created from a proc" do
@@ -49,19 +49,19 @@ describe "Proc#curry" do
end
it "raises an ArgumentError if passed superfluous arguments when created from a lambda" do
- -> { @lambda_add.curry[1,2,3,4] }.should raise_error(ArgumentError)
- -> { @lambda_add.curry[1,2].curry[3,4,5,6] }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry[1,2,3,4] }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry[1,2].curry[3,4,5,6] }.should raise_error(ArgumentError)
end
it "returns Procs with arities of -1" do
@proc_add.curry.arity.should == -1
@lambda_add.curry.arity.should == -1
- l = -> *a { }
+ l = lambda { |*a| }
l.curry.arity.should == -1
end
it "produces Procs that raise ArgumentError for #binding" do
- -> do
+ lambda do
@proc_add.curry.binding
end.should raise_error(ArgumentError)
end
@@ -81,7 +81,7 @@ describe "Proc#curry" do
end
it "combines arguments and calculates incoming arity accurately for successively currying" do
- l = -> a, b, c { a+b+c }
+ l = lambda{|a,b,c| a+b+c }
l1 = l.curry.call(1)
# the l1 currying seems unnecessary, but it triggered the original issue
l2 = l1.curry.call(2)
@@ -93,13 +93,13 @@ end
describe "Proc#curry with arity argument" do
before :each do
- @proc_add = proc { |x,y,z| (x||0) + (y||0) + (z||0) }
- @lambda_add = -> x, y, z { (x||0) + (y||0) + (z||0) }
+ @proc_add = proc {|x,y,z| (x||0) + (y||0) + (z||0) }
+ @lambda_add = lambda {|x,y,z| (x||0) + (y||0) + (z||0) }
end
it "accepts an optional Integer argument for the arity" do
- -> { @proc_add.curry(3) }.should_not raise_error
- -> { @lambda_add.curry(3) }.should_not raise_error
+ lambda { @proc_add.curry(3) }.should_not raise_error
+ lambda { @lambda_add.curry(3) }.should_not raise_error
end
it "returns a Proc when called on a proc" do
@@ -117,22 +117,22 @@ describe "Proc#curry with arity argument" do
end
it "raises an ArgumentError if called on a lambda that requires more than _arity_ arguments" do
- -> { @lambda_add.curry(2) }.should raise_error(ArgumentError)
- -> { -> x, y, z, *more{}.curry(2) }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry(2) }.should raise_error(ArgumentError)
+ lambda { lambda{|x, y, z, *more|}.curry(2) }.should raise_error(ArgumentError)
end
it 'returns a Proc if called on a lambda that requires fewer than _arity_ arguments but may take more' do
- -> a, b, c, d=nil, e=nil {}.curry(4).should be_an_instance_of(Proc)
- -> a, b, c, d=nil, *e {}.curry(4).should be_an_instance_of(Proc)
- -> a, b, c, *d {}.curry(4).should be_an_instance_of(Proc)
+ lambda{|a, b, c, d=nil, e=nil|}.curry(4).should be_an_instance_of(Proc)
+ lambda{|a, b, c, d=nil, *e|}.curry(4).should be_an_instance_of(Proc)
+ lambda{|a, b, c, *d|}.curry(4).should be_an_instance_of(Proc)
end
it "raises an ArgumentError if called on a lambda that requires fewer than _arity_ arguments" do
- -> { @lambda_add.curry(4) }.should raise_error(ArgumentError)
- -> { -> { true }.curry(1) }.should raise_error(ArgumentError)
- -> { -> a, b=nil {}.curry(5) }.should raise_error(ArgumentError)
- -> { -> a, &b {}.curry(2) }.should raise_error(ArgumentError)
- -> { -> a, b=nil, &c {}.curry(3) }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry(4) }.should raise_error(ArgumentError)
+ lambda { lambda { true }.curry(1) }.should raise_error(ArgumentError)
+ lambda { lambda {|a, b=nil|}.curry(5) }.should raise_error(ArgumentError)
+ lambda { lambda {|a, &b|}.curry(2) }.should raise_error(ArgumentError)
+ lambda { lambda {|a, b=nil, &c|}.curry(3) }.should raise_error(ArgumentError)
end
it "calls the curried proc with the arguments if _arity_ arguments have been given" do
@@ -152,29 +152,29 @@ describe "Proc#curry with arity argument" do
it "can be specified multiple times on the same Proc" do
@proc_add.curry(2)
- -> { @proc_add.curry(1) }.should_not raise_error
+ lambda { @proc_add.curry(1) }.should_not raise_error
@lambda_add.curry(3)
- -> { @lambda_add.curry(3) }.should_not raise_error
+ lambda { @lambda_add.curry(3) }.should_not raise_error
end
it "can be passed more than _arity_ arguments if created from a proc" do
- -> { @proc_add.curry(3)[1,2,3,4].should == 6 }.should_not
+ lambda { @proc_add.curry(3)[1,2,3,4].should == 6 }.should_not
raise_error(ArgumentError)
- -> { @proc_add.curry(1)[1,2].curry(3)[3,4,5,6].should == 6 }.should_not
+ lambda { @proc_add.curry(1)[1,2].curry(3)[3,4,5,6].should == 6 }.should_not
raise_error(ArgumentError)
end
it "raises an ArgumentError if passed more than _arity_ arguments when created from a lambda" do
- -> { @lambda_add.curry(3)[1,2,3,4] }.should raise_error(ArgumentError)
- -> { @lambda_add.curry(1)[1,2].curry(3)[3,4,5,6] }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry(3)[1,2,3,4] }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry(1)[1,2].curry(3)[3,4,5,6] }.should raise_error(ArgumentError)
end
it "returns Procs with arities of -1 regardless of the value of _arity_" do
@proc_add.curry(1).arity.should == -1
@proc_add.curry(2).arity.should == -1
@lambda_add.curry(3).arity.should == -1
- l = -> *a { }
+ l = lambda { |*a| }
l.curry(3).arity.should == -1
end
end
diff --git a/spec/ruby/core/proc/dup_spec.rb b/spec/ruby/core/proc/dup_spec.rb
index 6da2f3080c..ea3fe8aac9 100644
--- a/spec/ruby/core/proc/dup_spec.rb
+++ b/spec/ruby/core/proc/dup_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/dup'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/dup', __FILE__)
describe "Proc#dup" do
- it_behaves_like :proc_dup, :dup
+ it_behaves_like(:proc_dup, :dup)
end
diff --git a/spec/ruby/core/proc/element_reference_spec.rb b/spec/ruby/core/proc/element_reference_spec.rb
index 9077e44c34..f3dec21253 100644
--- a/spec/ruby/core/proc/element_reference_spec.rb
+++ b/spec/ruby/core/proc/element_reference_spec.rb
@@ -1,8 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/call'
-require_relative 'shared/call_arguments'
-require_relative 'fixtures/proc_aref'
-require_relative 'fixtures/proc_aref_frozen'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/call', __FILE__)
+require File.expand_path('../shared/call_arguments', __FILE__)
describe "Proc#[]" do
it_behaves_like :proc_call, :[]
@@ -16,12 +14,3 @@ end
describe "Proc#call on a Proc created with Kernel#lambda or Kernel#proc" do
it_behaves_like :proc_call_on_proc_or_lambda, :call
end
-
-describe "Proc#[] with frozen_string_literals" do
- it "doesn't duplicate frozen strings" do
- ProcArefSpecs.aref.frozen?.should be_false
- ProcArefSpecs.aref_freeze.frozen?.should be_true
- ProcArefFrozenSpecs.aref.frozen?.should be_true
- ProcArefFrozenSpecs.aref_freeze.frozen?.should be_true
- end
-end
diff --git a/spec/ruby/core/proc/eql_spec.rb b/spec/ruby/core/proc/eql_spec.rb
index a3c5a5658d..e0cc80bb48 100644
--- a/spec/ruby/core/proc/eql_spec.rb
+++ b/spec/ruby/core/proc/eql_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
describe "Proc#eql?" do
- it_behaves_like :proc_equal_undefined, :eql?
+ it_behaves_like(:proc_equal_undefined, :eql?)
end
diff --git a/spec/ruby/core/proc/equal_value_spec.rb b/spec/ruby/core/proc/equal_value_spec.rb
index 1b6ac792cf..e50ea1a53b 100644
--- a/spec/ruby/core/proc/equal_value_spec.rb
+++ b/spec/ruby/core/proc/equal_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal', __FILE__)
describe "Proc#==" do
- it_behaves_like :proc_equal_undefined, :==
+ it_behaves_like(:proc_equal_undefined, :==)
end
diff --git a/spec/ruby/core/proc/fixtures/proc_aref.rb b/spec/ruby/core/proc/fixtures/proc_aref.rb
deleted file mode 100644
index a305667797..0000000000
--- a/spec/ruby/core/proc/fixtures/proc_aref.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module ProcArefSpecs
- def self.aref
- proc {|a| a }["sometext"]
- end
-
- def self.aref_freeze
- proc {|a| a }["sometext".freeze]
- end
-end
diff --git a/spec/ruby/core/proc/fixtures/proc_aref_frozen.rb b/spec/ruby/core/proc/fixtures/proc_aref_frozen.rb
deleted file mode 100644
index 50a330ba4f..0000000000
--- a/spec/ruby/core/proc/fixtures/proc_aref_frozen.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-module ProcArefFrozenSpecs
- def self.aref
- proc {|a| a }["sometext"]
- end
-
- def self.aref_freeze
- proc {|a| a }["sometext".freeze]
- end
-end
diff --git a/spec/ruby/core/proc/fixtures/source_location.rb b/spec/ruby/core/proc/fixtures/source_location.rb
index 688dac1e22..468262e02a 100644
--- a/spec/ruby/core/proc/fixtures/source_location.rb
+++ b/spec/ruby/core/proc/fixtures/source_location.rb
@@ -5,7 +5,7 @@ module ProcSpecs
end
def self.my_lambda
- -> { true }
+ lambda { true }
end
def self.my_proc_new
@@ -24,7 +24,7 @@ module ProcSpecs
end
def self.my_multiline_lambda
- -> do
+ lambda do
'a'.upcase
1 + 22
end
@@ -43,7 +43,7 @@ module ProcSpecs
end
def self.my_detached_lambda
- body = -> { true }
+ body = lambda { true }
lambda(&body)
end
diff --git a/spec/ruby/core/proc/hash_spec.rb b/spec/ruby/core/proc/hash_spec.rb
index d780c1ceb0..1f5b6d5aa1 100644
--- a/spec/ruby/core/proc/hash_spec.rb
+++ b/spec/ruby/core/proc/hash_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc#hash" do
it "is provided" do
proc {}.respond_to?(:hash).should be_true
- -> {}.respond_to?(:hash).should be_true
+ lambda {}.respond_to?(:hash).should be_true
end
it "returns an Integer" do
diff --git a/spec/ruby/core/proc/inspect_spec.rb b/spec/ruby/core/proc/inspect_spec.rb
index f53d34116f..860647baa7 100644
--- a/spec/ruby/core/proc/inspect_spec.rb
+++ b/spec/ruby/core/proc/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "Proc#inspect" do
it_behaves_like :proc_to_s, :inspect
diff --git a/spec/ruby/core/proc/lambda_spec.rb b/spec/ruby/core/proc/lambda_spec.rb
index fe2ceb4279..33c9ebdd55 100644
--- a/spec/ruby/core/proc/lambda_spec.rb
+++ b/spec/ruby/core/proc/lambda_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Proc#lambda?" do
it "returns true if the Proc was created from a block with the lambda keyword" do
- -> {}.lambda?.should be_true
+ lambda {}.lambda?.should be_true
end
it "returns false if the Proc was created from a block with the proc keyword" do
@@ -15,17 +15,17 @@ describe "Proc#lambda?" do
end
it "is preserved when passing a Proc with & to the lambda keyword" do
- lambda(&->{}).lambda?.should be_true
+ lambda(&lambda{}).lambda?.should be_true
lambda(&proc{}).lambda?.should be_false
end
it "is preserved when passing a Proc with & to the proc keyword" do
- proc(&->{}).lambda?.should be_true
+ proc(&lambda{}).lambda?.should be_true
proc(&proc{}).lambda?.should be_false
end
it "is preserved when passing a Proc with & to Proc.new" do
- Proc.new(&->{}).lambda?.should be_true
+ Proc.new(&lambda{}).lambda?.should be_true
Proc.new(&proc{}).lambda?.should be_false
end
@@ -34,7 +34,7 @@ describe "Proc#lambda?" do
end
it "is preserved when the Proc was passed using &" do
- ProcSpecs.new_proc_from_amp(&->{}).lambda?.should be_true
+ ProcSpecs.new_proc_from_amp(&lambda{}).lambda?.should be_true
ProcSpecs.new_proc_from_amp(&proc{}).lambda?.should be_false
ProcSpecs.new_proc_from_amp(&Proc.new{}).lambda?.should be_false
end
@@ -47,13 +47,13 @@ describe "Proc#lambda?" do
# [ruby-core:24127]
it "is preserved when a Proc is curried" do
- ->{}.curry.lambda?.should be_true
+ lambda{}.curry.lambda?.should be_true
proc{}.curry.lambda?.should be_false
Proc.new{}.curry.lambda?.should be_false
end
it "is preserved when a curried Proc is called without enough arguments" do
- -> x, y{}.curry.call(42).lambda?.should be_true
+ lambda{|x,y|}.curry.call(42).lambda?.should be_true
proc{|x,y|}.curry.call(42).lambda?.should be_false
Proc.new{|x,y|}.curry.call(42).lambda?.should be_false
end
diff --git a/spec/ruby/core/proc/new_spec.rb b/spec/ruby/core/proc/new_spec.rb
index 8faf142614..5dc0061a47 100644
--- a/spec/ruby/core/proc/new_spec.rb
+++ b/spec/ruby/core/proc/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Proc.new with an associated block" do
it "returns a proc that represents the block" do
@@ -71,7 +71,7 @@ describe "Proc.new with an associated block" do
end
res = some_method()
- -> { res.call }.should raise_error(LocalJumpError)
+ lambda { res.call }.should raise_error(LocalJumpError)
end
it "returns from within enclosing method when 'return' is used in the block" do
@@ -95,18 +95,16 @@ describe "Proc.new with an associated block" do
obj.second.should == 2
end
- ruby_version_is ""..."2.7" do
- it "returns a new Proc instance from the block passed to the containing method" do
- prc = ProcSpecs.new_proc_in_method { "hello" }
- prc.should be_an_instance_of(Proc)
- prc.call.should == "hello"
- end
+ it "returns a new Proc instance from the block passed to the containing method" do
+ prc = ProcSpecs.new_proc_in_method { "hello" }
+ prc.should be_an_instance_of(Proc)
+ prc.call.should == "hello"
+ end
- it "returns a new Proc instance from the block passed to the containing method" do
- prc = ProcSpecs.new_proc_subclass_in_method { "hello" }
- prc.should be_an_instance_of(ProcSpecs::ProcSubclass)
- prc.call.should == "hello"
- end
+ it "returns a new Proc instance from the block passed to the containing method" do
+ prc = ProcSpecs.new_proc_subclass_in_method { "hello" }
+ prc.should be_an_instance_of(ProcSpecs::ProcSubclass)
+ prc.call.should == "hello"
end
end
@@ -169,66 +167,24 @@ end
describe "Proc.new without a block" do
it "raises an ArgumentError" do
- -> { Proc.new }.should raise_error(ArgumentError)
+ lambda { Proc.new }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if invoked from within a method with no block" do
- -> { ProcSpecs.new_proc_in_method }.should raise_error(ArgumentError)
+ lambda { ProcSpecs.new_proc_in_method }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if invoked on a subclass from within a method with no block" do
- -> { ProcSpecs.new_proc_subclass_in_method }.should raise_error(ArgumentError)
+ lambda { ProcSpecs.new_proc_subclass_in_method }.should raise_error(ArgumentError)
end
- ruby_version_is ""..."2.7" do
- it "uses the implicit block from an enclosing method" do
- def some_method
- Proc.new
- end
-
- prc = some_method { "hello" }
-
- prc.call.should == "hello"
- end
-
- it "uses the implicit block from an enclosing method when called inside a block" do
- def some_method
- proc do |&block|
- Proc.new
- end.call { "failing" }
- end
- prc = some_method { "hello" }
-
- prc.call.should == "hello"
- end
- end
-
- ruby_version_is "2.7" do
- before :each do
- @deprecated = Warning[:deprecated]
- Warning[:deprecated] = true
- end
- after :each do
- Warning[:deprecated] = @deprecated
- end
-
- it "can be created if invoked from within a method with a block" do
- -> { ProcSpecs.new_proc_in_method { "hello" } }.should complain(/Capturing the given block using Proc.new is deprecated/)
- end
-
- it "can be created if invoked on a subclass from within a method with a block" do
- -> { ProcSpecs.new_proc_subclass_in_method { "hello" } }.should complain(/Capturing the given block using Proc.new is deprecated/)
+ it "uses the implicit block from an enclosing method" do
+ def some_method
+ Proc.new
end
+ prc = some_method { "hello" }
- it "can be create when called with no block" do
- def some_method
- Proc.new
- end
-
- -> {
- some_method { "hello" }
- }.should complain(/Capturing the given block using Proc.new is deprecated/)
- end
+ prc.call.should == "hello"
end
end
diff --git a/spec/ruby/core/proc/parameters_spec.rb b/spec/ruby/core/proc/parameters_spec.rb
index 2bc5f1325c..3ba8a0cc32 100644
--- a/spec/ruby/core/proc/parameters_spec.rb
+++ b/spec/ruby/core/proc/parameters_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc#parameters" do
it "returns an empty Array for a proc expecting no parameters" do
@@ -25,17 +25,17 @@ describe "Proc#parameters" do
end
it "regards parameters with default values as optional" do
- -> x=1 { }.parameters.first.first.should == :opt
+ lambda {|x=1| }.parameters.first.first.should == :opt
proc {|x=1| }.parameters.first.first.should == :opt
end
it "sets the first element of each sub-Array to :req for required arguments" do
- -> x, y=[] { }.parameters.first.first.should == :req
- -> y, *x { }.parameters.first.first.should == :req
+ lambda {|x,y=[]| }.parameters.first.first.should == :req
+ lambda {|y,*x| }.parameters.first.first.should == :req
end
it "regards named parameters in lambdas as required" do
- -> x { }.parameters.first.first.should == :req
+ lambda {|x| }.parameters.first.first.should == :req
end
it "regards keyword parameters in lambdas as required" do
@@ -43,32 +43,32 @@ describe "Proc#parameters" do
end
it "sets the first element of each sub-Array to :rest for parameters prefixed with asterisks" do
- -> *x { }.parameters.first.first.should == :rest
- -> x, *y { }.parameters.last.first.should == :rest
+ lambda {|*x| }.parameters.first.first.should == :rest
+ lambda {|x,*y| }.parameters.last.first.should == :rest
proc {|*x| }.parameters.first.first.should == :rest
proc {|x,*y| }.parameters.last.first.should == :rest
end
it "sets the first element of each sub-Array to :keyrest for parameters prefixed with double asterisks" do
- -> **x { }.parameters.first.first.should == :keyrest
- -> x, **y { }.parameters.last.first.should == :keyrest
+ lambda {|**x| }.parameters.first.first.should == :keyrest
+ lambda {|x,**y| }.parameters.last.first.should == :keyrest
proc {|**x| }.parameters.first.first.should == :keyrest
proc {|x,**y| }.parameters.last.first.should == :keyrest
end
it "sets the first element of each sub-Array to :block for parameters prefixed with ampersands" do
- ->&x { }.parameters.first.first.should == :block
- -> x, &y { }.parameters.last.first.should == :block
+ lambda {|&x| }.parameters.first.first.should == :block
+ lambda {|x,&y| }.parameters.last.first.should == :block
proc {|&x| }.parameters.first.first.should == :block
proc {|x,&y| }.parameters.last.first.should == :block
end
it "sets the second element of each sub-Array to the name of the argument" do
- -> x { }.parameters.first.last.should == :x
- -> x=Math::PI { }.parameters.first.last.should == :x
- -> an_argument, glark, &foo { }.parameters[1].last.should == :glark
- -> *rest { }.parameters.first.last.should == :rest
- ->&block { }.parameters.first.last.should == :block
+ lambda {|x| }.parameters.first.last.should == :x
+ lambda {|x=Math::PI| }.parameters.first.last.should == :x
+ lambda {|an_argument, glark, &foo| }.parameters[1].last.should == :glark
+ lambda {|*rest| }.parameters.first.last.should == :rest
+ lambda {|&block| }.parameters.first.last.should == :block
proc {|x| }.parameters.first.last.should == :x
proc {|x=Math::PI| }.parameters.first.last.should == :x
proc {|an_argument, glark, &foo| }.parameters[1].last.should == :glark
@@ -77,15 +77,15 @@ describe "Proc#parameters" do
end
it "ignores unnamed rest args" do
- -> x {}.parameters.should == [[:req, :x]]
+ lambda {|x,|}.parameters.should == [[:req, :x]]
end
it "adds nameless rest arg for \"star\" argument" do
- -> x, * {}.parameters.should == [[:req, :x], [:rest]]
+ lambda {|x,*|}.parameters.should == [[:req, :x], [:rest]]
end
it "does not add locals as block options with a block and splat" do
- -> *args, &blk do
+ lambda do |*args, &blk|
local_is_not_parameter = {}
end.parameters.should == [[:rest, :args], [:block, :blk]]
proc do |*args, &blk|
diff --git a/spec/ruby/core/proc/shared/call.rb b/spec/ruby/core/proc/shared/call.rb
index c30ea84b23..11355537b0 100644
--- a/spec/ruby/core/proc/shared/call.rb
+++ b/spec/ruby/core/proc/shared/call.rb
@@ -1,9 +1,9 @@
-require_relative '../fixtures/common'
+require File.expand_path('../../fixtures/common', __FILE__)
describe :proc_call, shared: true do
it "invokes self" do
Proc.new { "test!" }.send(@method).should == "test!"
- -> { "test!" }.send(@method).should == "test!"
+ lambda { "test!" }.send(@method).should == "test!"
proc { "test!" }.send(@method).should == "test!"
end
@@ -12,9 +12,9 @@ describe :proc_call, shared: true do
Proc.new { |*args| args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4]
Proc.new { |_, *args| args }.send(@method, 1, 2, 3).should == [2, 3]
- -> a, b { a + b }.send(@method, 1, 2).should == 3
- -> *args { args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4]
- -> _, *args { args }.send(@method, 1, 2, 3).should == [2, 3]
+ lambda { |a, b| a + b }.send(@method, 1, 2).should == 3
+ lambda { |*args| args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4]
+ lambda { |_, *args| args }.send(@method, 1, 2, 3).should == [2, 3]
proc { |a, b| a + b }.send(@method, 1, 2).should == 3
proc { |*args| args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4]
@@ -65,28 +65,28 @@ describe :proc_call_on_proc_or_lambda, shared: true do
end
it "raises an ArgumentError on excess arguments when self is a lambda" do
- -> {
- -> x { x }.send(@method, 1, 2)
+ lambda {
+ lambda {|x| x}.send(@method, 1, 2)
}.should raise_error(ArgumentError)
- -> {
- -> x { x }.send(@method, 1, 2, 3)
+ lambda {
+ lambda {|x| x}.send(@method, 1, 2, 3)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError on missing arguments when self is a lambda" do
- -> {
- -> x { x }.send(@method)
+ lambda {
+ lambda {|x| x}.send(@method)
}.should raise_error(ArgumentError)
- -> {
- -> x, y { [x,y] }.send(@method, 1)
+ lambda {
+ lambda {|x,y| [x,y]}.send(@method, 1)
}.should raise_error(ArgumentError)
end
it "treats a single Array argument as a single argument when self is a lambda" do
- -> a { a }.send(@method, [1, 2]).should == [1, 2]
- -> a, b { [a, b] }.send(@method, [1, 2], 3).should == [[1,2], 3]
+ lambda { |a| a }.send(@method, [1, 2]).should == [1, 2]
+ lambda { |a, b| [a, b] }.send(@method, [1, 2], 3).should == [[1,2], 3]
end
it "treats a single Array argument as a single argument when self is a proc" do
diff --git a/spec/ruby/core/proc/shared/call_arguments.rb b/spec/ruby/core/proc/shared/call_arguments.rb
index ef6ec04620..2e510b194e 100644
--- a/spec/ruby/core/proc/shared/call_arguments.rb
+++ b/spec/ruby/core/proc/shared/call_arguments.rb
@@ -1,29 +1,7 @@
describe :proc_call_block_args, shared: true do
it "can receive block arguments" do
Proc.new {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
- ->&b { b.send(@method)}.send(@method) {1 + 1}.should == 2
+ lambda {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
proc {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
end
-
- it "yields to the block given at declaration and not to the block argument" do
- proc_creator = Object.new
- def proc_creator.create
- Proc.new do |&b|
- yield
- end
- end
- a_proc = proc_creator.create { 7 }
- a_proc.send(@method) { 3 }.should == 7
- end
-
- it "can call its block argument declared with a block argument" do
- proc_creator = Object.new
- def proc_creator.create(method_name)
- Proc.new do |&b|
- yield + b.send(method_name)
- end
- end
- a_proc = proc_creator.create(@method) { 7 }
- a_proc.call { 3 }.should == 10
- end
end
diff --git a/spec/ruby/core/proc/shared/compose.rb b/spec/ruby/core/proc/shared/compose.rb
deleted file mode 100644
index 64338cada8..0000000000
--- a/spec/ruby/core/proc/shared/compose.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-describe :proc_compose, shared: true do
- ruby_version_is "2.6"..."2.7" do
- it "raises NoMethodError when called if passed not callable object" do
- not_callable = Object.new
- composed = @object.call.send(@method, not_callable)
-
- -> {
- composed.call('a')
- }.should raise_error(NoMethodError, /undefined method `call' for/)
-
- end
-
- it "when called does not try to coerce argument with #to_proc" do
- succ = Object.new
- def succ.to_proc(s); s.succ; end
-
- composed = @object.call.send(@method, succ)
-
- -> {
- composed.call('a')
- }.should raise_error(NoMethodError, /undefined method `call' for/)
- end
- end
-
- ruby_version_is "2.7" do # https://bugs.ruby-lang.org/issues/15428
- it "raises TypeError if passed not callable object" do
- lhs = @object.call
- not_callable = Object.new
-
- -> {
- lhs.send(@method, not_callable)
- }.should raise_error(TypeError, "callable object is expected")
-
- end
-
- it "does not try to coerce argument with #to_proc" do
- lhs = @object.call
-
- succ = Object.new
- def succ.to_proc(s); s.succ; end
-
- -> {
- lhs.send(@method, succ)
- }.should raise_error(TypeError, "callable object is expected")
- end
- end
-end
diff --git a/spec/ruby/core/proc/shared/dup.rb b/spec/ruby/core/proc/shared/dup.rb
index eda1d6929d..fb6fff299d 100644
--- a/spec/ruby/core/proc/shared/dup.rb
+++ b/spec/ruby/core/proc/shared/dup.rb
@@ -1,6 +1,6 @@
describe :proc_dup, shared: true do
it "returns a copy of self" do
- a = -> { "hello" }
+ a = lambda { "hello" }
b = a.send(@method)
a.should_not equal(b)
diff --git a/spec/ruby/core/proc/shared/equal.rb b/spec/ruby/core/proc/shared/equal.rb
index 46a1894424..c2735ffb2f 100644
--- a/spec/ruby/core/proc/shared/equal.rb
+++ b/spec/ruby/core/proc/shared/equal.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe :proc_equal, shared: true do
it "is a public method" do
@@ -13,7 +13,7 @@ describe :proc_equal, shared: true do
p = Proc.new { :foo }
p.send(@method, p).should be_true
- p = -> { :foo }
+ p = lambda { :foo }
p.send(@method, p).should be_true
end
@@ -24,7 +24,7 @@ describe :proc_equal, shared: true do
p = Proc.new { :foo }
p.send(@method, p.dup).should be_true
- p = -> { :foo }
+ p = lambda { :foo }
p.send(@method, p.dup).should be_true
end
@@ -43,18 +43,18 @@ describe :proc_equal, shared: true do
end
it "returns true if both lambdas with the same body and environment" do
- x = -> { :foo }
- x2 = -> { :foo }
+ x = lambda { :foo }
+ x2 = lambda { :foo }
x.send(@method, x2).should be_true
end
it "returns true if both different kinds of procs with the same body and env" do
- p = -> { :foo }
+ p = lambda { :foo }
p2 = proc { :foo }
p.send(@method, p2).should be_true
x = proc { :bar }
- x2 = -> { :bar }
+ x2 = lambda { :bar }
x.send(@method, x2).should be_true
end
@@ -65,7 +65,7 @@ describe :proc_equal, shared: true do
p = Proc.new { :foo }
p.send(@method, Object.new).should be_false
- p = -> { :foo }
+ p = lambda { :foo }
p.send(@method, :foo).should be_false
end
@@ -76,8 +76,8 @@ describe :proc_equal, shared: true do
end
it "returns false if self and other are both lambdas but have different bodies" do
- p = -> { :foo }
- p2 = -> { :bar }
+ p = lambda { :foo }
+ p2 = lambda { :bar }
p.send(@method, p2).should be_false
end
end
@@ -94,7 +94,7 @@ describe :proc_equal_undefined, shared: true do
p = Proc.new { :foo }
p.send(@method, p.dup).should be_false
- p = -> { :foo }
+ p = lambda { :foo }
p.send(@method, p.dup).should be_false
end
end
diff --git a/spec/ruby/core/proc/shared/to_s.rb b/spec/ruby/core/proc/shared/to_s.rb
index 8b9c83927f..c3f82a73f3 100644
--- a/spec/ruby/core/proc/shared/to_s.rb
+++ b/spec/ruby/core/proc/shared/to_s.rb
@@ -1,57 +1,27 @@
describe :proc_to_s, shared: true do
- sep = ruby_version_is("2.7") ? " " : "@"
-
describe "for a proc created with Proc.new" do
- it "returns a description including file and line number" do
- Proc.new { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)#{sep}#{Regexp.escape __FILE__}:#{__LINE__ }>$/
- end
-
- it "has a binary encoding" do
- Proc.new { "hello" }.send(@method).encoding.should == Encoding::BINARY
+ it "returns a description optionally including file and line number" do
+ Proc.new { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:4)?>$/
end
end
describe "for a proc created with lambda" do
- it "returns a description including '(lambda)' and including file and line number" do
- -> { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)#{sep}#{Regexp.escape __FILE__}:#{__LINE__ } \(lambda\)>$/
- end
-
- it "has a binary encoding" do
- -> { "hello" }.send(@method).encoding.should == Encoding::BINARY
+ it "returns a description including '(lambda)' and optionally including file and line number" do
+ lambda { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:10)? \(lambda\)>$/
end
end
describe "for a proc created with proc" do
- it "returns a description including file and line number" do
- proc { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)#{sep}#{Regexp.escape __FILE__}:#{__LINE__ }>$/
- end
-
- it "has a binary encoding" do
- proc { "hello" }.send(@method).encoding.should == Encoding::BINARY
+ it "returns a description optionally including file and line number" do
+ proc { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:16)?>$/
end
end
describe "for a proc created with UnboundMethod#to_proc" do
it "returns a description including '(lambda)' and optionally including file and line number" do
def hello; end
- method("hello").to_proc.send(@method).should =~ /^#<Proc:([^ ]*?)(#{sep}#{Regexp.escape __FILE__}:#{__LINE__ })? \(lambda\)>$/
- end
-
- it "has a binary encoding" do
- def hello; end
- method("hello").to_proc.send(@method).encoding.should == Encoding::BINARY
- end
- end
-
- describe "for a proc created with Symbol#to_proc" do
- it "returns a description including '(&:symbol)'" do
- proc = :foobar.to_proc
- proc.send(@method).should =~ /^#<Proc:0x\h+\(&:foobar\)>$/
- end
- it "has a binary encoding" do
- proc = :foobar.to_proc
- proc.send(@method).encoding.should == Encoding::BINARY
+ method("hello").to_proc.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:22)? \(lambda\)>$/
end
end
end
diff --git a/spec/ruby/core/proc/source_location_spec.rb b/spec/ruby/core/proc/source_location_spec.rb
index b5b8178df2..311d13c050 100644
--- a/spec/ruby/core/proc/source_location_spec.rb
+++ b/spec/ruby/core/proc/source_location_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/source_location'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/source_location', __FILE__)
describe "Proc#source_location" do
before :each do
@@ -19,19 +19,19 @@ describe "Proc#source_location" do
it "sets the first value to the path of the file in which the proc was defined" do
file = @proc.source_location.first
file.should be_an_instance_of(String)
- file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
+ file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
file = @proc_new.source_location.first
file.should be_an_instance_of(String)
- file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
+ file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
file = @lambda.source_location.first
file.should be_an_instance_of(String)
- file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
+ file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
file = @method.source_location.first
file.should be_an_instance_of(String)
- file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
+ file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
end
it "sets the last value to a Fixnum representing the line on which the proc was defined" do
@@ -55,7 +55,7 @@ describe "Proc#source_location" do
it "works even if the proc was created on the same line" do
proc { true }.source_location.should == [__FILE__, __LINE__]
Proc.new { true }.source_location.should == [__FILE__, __LINE__]
- -> { true }.source_location.should == [__FILE__, __LINE__]
+ lambda { true }.source_location.should == [__FILE__, __LINE__]
end
it "returns the first line of a multi-line proc (i.e. the line containing 'proc do')" do
@@ -69,18 +69,4 @@ describe "Proc#source_location" do
ProcSpecs::SourceLocation.my_detached_proc_new.source_location.last.should == 51
ProcSpecs::SourceLocation.my_detached_lambda.source_location.last.should == 46
end
-
- it "returns the same value for a proc-ified method as the method reports" do
- method = ProcSpecs::SourceLocation.method(:my_proc)
- proc = method.to_proc
-
- method.source_location.should == proc.source_location
- end
-
- it "returns nil for a core method that has been proc-ified" do
- method = [].method(:<<)
- proc = method.to_proc
-
- proc.source_location.should == nil
- end
end
diff --git a/spec/ruby/core/proc/to_proc_spec.rb b/spec/ruby/core/proc/to_proc_spec.rb
index ffaa34929b..e5637c9f41 100644
--- a/spec/ruby/core/proc/to_proc_spec.rb
+++ b/spec/ruby/core/proc/to_proc_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Proc#to_proc" do
it "returns self" do
- [Proc.new {}, -> {}, proc {}].each { |p|
+ [Proc.new {}, lambda {}, proc {}].each { |p|
p.to_proc.should equal(p)
}
end
diff --git a/spec/ruby/core/proc/to_s_spec.rb b/spec/ruby/core/proc/to_s_spec.rb
index 5e9c46b6b8..e0b248c369 100644
--- a/spec/ruby/core/proc/to_s_spec.rb
+++ b/spec/ruby/core/proc/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "Proc#to_s" do
it_behaves_like :proc_to_s, :to_s
diff --git a/spec/ruby/core/proc/yield_spec.rb b/spec/ruby/core/proc/yield_spec.rb
index 365d5b04bd..930e44ea78 100644
--- a/spec/ruby/core/proc/yield_spec.rb
+++ b/spec/ruby/core/proc/yield_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/call'
-require_relative 'shared/call_arguments'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/call', __FILE__)
+require File.expand_path('../shared/call_arguments', __FILE__)
describe "Proc#yield" do
it_behaves_like :proc_call, :yield
diff --git a/spec/ruby/core/process/abort_spec.rb b/spec/ruby/core/process/abort_spec.rb
index 1b6ad1da43..f7113c8b7e 100644
--- a/spec/ruby/core/process/abort_spec.rb
+++ b/spec/ruby/core/process/abort_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/process/abort'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/process/abort', __FILE__)
describe "Process.abort" do
it_behaves_like :process_abort, :abort, Process
diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb
deleted file mode 100644
index 85aa2b25f1..0000000000
--- a/spec/ruby/core/process/clock_getres_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Process.clock_getres" do
- # These are documented
-
- it "with :GETTIMEOFDAY_BASED_CLOCK_REALTIME reports 1 microsecond" do
- Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME, :nanosecond).should == 1_000
- end
-
- it "with :TIME_BASED_CLOCK_REALTIME reports 1 second" do
- Process.clock_getres(:TIME_BASED_CLOCK_REALTIME, :nanosecond).should == 1_000_000_000
- end
-
- platform_is_not :windows do
- it "with :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID reports 1 microsecond" do
- Process.clock_getres(:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID, :nanosecond).should == 1_000
- end
- end
-
- # These are observed
-
- platform_is :linux, :darwin, :windows do
- it "with Process::CLOCK_REALTIME reports at least 10 millisecond" do
- Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 10_000_000
- end
- end
-
- platform_is :linux, :darwin, :windows do
- it "with Process::CLOCK_MONOTONIC reports at least 10 millisecond" do
- Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 10_000_000
- end
- end
-end
diff --git a/spec/ruby/core/process/clock_gettime_spec.rb b/spec/ruby/core/process/clock_gettime_spec.rb
deleted file mode 100644
index 59e1406e02..0000000000
--- a/spec/ruby/core/process/clock_gettime_spec.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/clocks'
-
-describe "Process.clock_gettime" do
- ProcessSpecs.clock_constants.each do |name, value|
- it "can be called with Process::#{name}" do
- Process.clock_gettime(value).should be_an_instance_of(Float)
- end
- end
-
- describe 'time units' do
- it 'handles a fixed set of time units' do
- [:nanosecond, :microsecond, :millisecond, :second].each do |unit|
- Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should be_kind_of(Integer)
- end
-
- [:float_microsecond, :float_millisecond, :float_second].each do |unit|
- Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should be_an_instance_of(Float)
- end
- end
-
- it 'raises an ArgumentError for an invalid time unit' do
- -> { Process.clock_gettime(Process::CLOCK_MONOTONIC, :bad) }.should raise_error(ArgumentError)
- end
-
- it 'defaults to :float_second' do
- t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
-
- t1.should be_an_instance_of(Float)
- t2.should be_an_instance_of(Float)
- t2.should be_close(t1, TIME_TOLERANCE)
- end
-
- it 'uses the default time unit (:float_second) when passed nil' do
- t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, nil)
- t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
-
- t1.should be_an_instance_of(Float)
- t2.should be_an_instance_of(Float)
- t2.should be_close(t1, TIME_TOLERANCE)
- end
- end
-
- describe "supports the platform clocks mentioned in the documentation" do
- it "CLOCK_REALTIME" do
- Process.clock_gettime(Process::CLOCK_REALTIME).should be_an_instance_of(Float)
- end
-
- it "CLOCK_MONOTONIC" do
- Process.clock_gettime(Process::CLOCK_MONOTONIC).should be_an_instance_of(Float)
- end
-
- # These specs need macOS 10.12+ / darwin 16+
- guard_not -> { platform_is_not(:darwin) or RUBY_PLATFORM[/darwin\d+/].to_i >= 16 } do
- platform_is :linux, :openbsd, :darwin do
- it "CLOCK_PROCESS_CPUTIME_ID" do
- Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID).should be_an_instance_of(Float)
- end
- end
-
- platform_is :linux, :freebsd, :openbsd, :darwin do
- it "CLOCK_THREAD_CPUTIME_ID" do
- Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID).should be_an_instance_of(Float)
- end
- end
-
- platform_is :freebsd, :openbsd do
- it "CLOCK_VIRTUAL" do
- Process.clock_gettime(Process::CLOCK_VIRTUAL).should be_an_instance_of(Float)
- end
-
- it "CLOCK_PROF" do
- Process.clock_gettime(Process::CLOCK_PROF).should be_an_instance_of(Float)
- end
-
- it "CLOCK_UPTIME" do
- Process.clock_gettime(Process::CLOCK_UPTIME).should be_an_instance_of(Float)
- end
- end
-
- platform_is :linux, :darwin do
- it "CLOCK_MONOTONIC_RAW" do
- Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW).should be_an_instance_of(Float)
- end
- end
-
- platform_is :darwin do
- it "CLOCK_MONOTONIC_RAW_APPROX" do
- Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW_APPROX).should be_an_instance_of(Float)
- end
-
- it "CLOCK_UPTIME_RAW and CLOCK_UPTIME_RAW_APPROX" do
- Process.clock_gettime(Process::CLOCK_UPTIME_RAW).should be_an_instance_of(Float)
- Process.clock_gettime(Process::CLOCK_UPTIME_RAW_APPROX).should be_an_instance_of(Float)
- end
- end
-
- platform_is :freebsd do
- it "CLOCK_REALTIME_FAST and CLOCK_REALTIME_PRECISE" do
- Process.clock_gettime(Process::CLOCK_REALTIME_FAST).should be_an_instance_of(Float)
- Process.clock_gettime(Process::CLOCK_REALTIME_PRECISE).should be_an_instance_of(Float)
- end
-
- it "CLOCK_MONOTONIC_FAST and CLOCK_MONOTONIC_PRECISE" do
- Process.clock_gettime(Process::CLOCK_MONOTONIC_FAST).should be_an_instance_of(Float)
- Process.clock_gettime(Process::CLOCK_MONOTONIC_PRECISE).should be_an_instance_of(Float)
- end
-
- it "CLOCK_UPTIME_FAST and CLOCK_UPTIME_PRECISE" do
- Process.clock_gettime(Process::CLOCK_UPTIME_FAST).should be_an_instance_of(Float)
- Process.clock_gettime(Process::CLOCK_UPTIME_PRECISE).should be_an_instance_of(Float)
- end
-
- it "CLOCK_SECOND" do
- Process.clock_gettime(Process::CLOCK_SECOND).should be_an_instance_of(Float)
- end
- end
-
- platform_is :linux do
- it "CLOCK_REALTIME_COARSE and CLOCK_REALTIME_ALARM" do
- Process.clock_gettime(Process::CLOCK_REALTIME_COARSE).should be_an_instance_of(Float)
- Process.clock_gettime(Process::CLOCK_REALTIME_ALARM).should be_an_instance_of(Float)
- end
-
- it "CLOCK_MONOTONIC_COARSE" do
- Process.clock_gettime(Process::CLOCK_MONOTONIC_COARSE).should be_an_instance_of(Float)
- end
-
- it "CLOCK_BOOTTIME and CLOCK_BOOTTIME_ALARM" do
- Process.clock_gettime(Process::CLOCK_BOOTTIME).should be_an_instance_of(Float)
- Process.clock_gettime(Process::CLOCK_BOOTTIME_ALARM).should be_an_instance_of(Float)
- end
- end
- end
- end
-end
diff --git a/spec/ruby/core/process/daemon_spec.rb b/spec/ruby/core/process/daemon_spec.rb
index 70ffd1b320..f68ddfe253 100644
--- a/spec/ruby/core/process/daemon_spec.rb
+++ b/spec/ruby/core/process/daemon_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
platform_is_not :windows do
describe :process_daemon_keep_stdio_open_false, shared: true do
@@ -86,6 +86,10 @@ platform_is_not :windows do
@daemon.invoke("stay_in_dir", [true]).should == @invoke_dir
end
+ it "does not change to the root directory if the first argument is non-false" do
+ @daemon.invoke("stay_in_dir", [:yes]).should == @invoke_dir
+ end
+
describe "when the second argument is not given" do
it_behaves_like :process_daemon_keep_stdio_open_false, nil, [false]
end
@@ -101,13 +105,17 @@ platform_is_not :windows do
describe "when the second argument is true" do
it_behaves_like :process_daemon_keep_stdio_open_true, nil, [false, true]
end
+
+ describe "when the second argument is non-false" do
+ it_behaves_like :process_daemon_keep_stdio_open_true, nil, [false, :yes]
+ end
end
end
platform_is :windows do
describe "Process.daemon" do
it "raises a NotImplementedError" do
- -> {
+ lambda {
Process.daemon
}.should raise_error(NotImplementedError)
end
diff --git a/spec/ruby/core/process/detach_spec.rb b/spec/ruby/core/process/detach_spec.rb
index 1c27ed9c2c..7a38e290ce 100644
--- a/spec/ruby/core/process/detach_spec.rb
+++ b/spec/ruby/core/process/detach_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.detach" do
platform_is_not :windows do
@@ -23,7 +23,7 @@ describe "Process.detach" do
it "reaps the child process's status automatically" do
pid = Process.fork { Process.exit! }
Process.detach(pid).join
- -> { Process.waitpid(pid) }.should raise_error(Errno::ECHILD)
+ lambda { Process.waitpid(pid) }.should raise_error(Errno::ECHILD)
end
end
diff --git a/spec/ruby/core/process/egid_spec.rb b/spec/ruby/core/process/egid_spec.rb
index 24dda43804..316343944c 100644
--- a/spec/ruby/core/process/egid_spec.rb
+++ b/spec/ruby/core/process/egid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.egid" do
it "returns the effective group ID for this process" do
diff --git a/spec/ruby/core/process/euid_spec.rb b/spec/ruby/core/process/euid_spec.rb
index 7bbacfadfd..1855ef66f5 100644
--- a/spec/ruby/core/process/euid_spec.rb
+++ b/spec/ruby/core/process/euid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.euid" do
it "returns the effective user ID for this process" do
@@ -18,27 +18,40 @@ describe "Process.euid=" do
platform_is_not :windows do
it "raises TypeError if not passed an Integer" do
- -> { Process.euid = Object.new }.should raise_error(TypeError)
+ lambda { Process.euid = Object.new }.should raise_error(TypeError)
end
as_user do
it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id" do
- -> { (Process.euid = 0)}.should raise_error(Errno::EPERM)
+ lambda { (Process.euid = 0)}.should raise_error(Errno::EPERM)
end
it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id from username" do
- -> { Process.euid = "root" }.should raise_error(Errno::EPERM)
+ lambda { Process.euid = "root" }.should raise_error(Errno::EPERM)
end
end
as_superuser do
describe "if run by a superuser" do
- it "sets the effective user id for the current process if run by a superuser" do
- code = <<-RUBY
- Process.euid = 1
- puts Process.euid
- RUBY
- ruby_exe(code).should == "1\n"
+ with_feature :fork do
+ it "sets the effective user id for the current process if run by a superuser" do
+ read, write = IO.pipe
+ pid = Process.fork do
+ begin
+ read.close
+ Process.euid = 1
+ write << Process.euid
+ write.close
+ rescue Exception => e
+ write << e << e.backtrace
+ end
+ Process.exit!
+ end
+ write.close
+ euid = read.gets
+ euid.should == "1"
+ Process.wait pid
+ end
end
end
end
diff --git a/spec/ruby/core/process/exec_spec.rb b/spec/ruby/core/process/exec_spec.rb
index 5a6e3fc1a4..b4eddf526e 100644
--- a/spec/ruby/core/process/exec_spec.rb
+++ b/spec/ruby/core/process/exec_spec.rb
@@ -1,28 +1,28 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.exec" do
it "raises Errno::ENOENT for an empty string" do
- -> { Process.exec "" }.should raise_error(Errno::ENOENT)
+ lambda { Process.exec "" }.should raise_error(Errno::ENOENT)
end
it "raises Errno::ENOENT for a command which does not exist" do
- -> { Process.exec "bogus-noent-script.sh" }.should raise_error(Errno::ENOENT)
+ lambda { Process.exec "bogus-noent-script.sh" }.should raise_error(Errno::ENOENT)
end
it "raises an ArgumentError if the command includes a null byte" do
- -> { Process.exec "\000" }.should raise_error(ArgumentError)
+ lambda { Process.exec "\000" }.should raise_error(ArgumentError)
end
unless File.executable?(__FILE__) # Some FS (e.g. vboxfs) locate all files executable
platform_is_not :windows do
it "raises Errno::EACCES when the file does not have execute permissions" do
- -> { Process.exec __FILE__ }.should raise_error(Errno::EACCES)
+ lambda { Process.exec __FILE__ }.should raise_error(Errno::EACCES)
end
end
platform_is :windows do
it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do
- -> { Process.exec __FILE__ }.should raise_error(SystemCallError) { |e|
+ lambda { Process.exec __FILE__ }.should raise_error(SystemCallError) { |e|
[Errno::EACCES, Errno::ENOEXEC].should include(e.class)
}
end
@@ -31,13 +31,13 @@ describe "Process.exec" do
platform_is_not :openbsd do
it "raises Errno::EACCES when passed a directory" do
- -> { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EACCES)
+ lambda { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EACCES)
end
end
platform_is :openbsd do
it "raises Errno::EISDIR when passed a directory" do
- -> { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EISDIR)
+ lambda { Process.exec File.dirname(__FILE__) }.should raise_error(Errno::EISDIR)
end
end
@@ -179,9 +179,9 @@ describe "Process.exec" do
end
it "raises an ArgumentError if the Array does not have exactly two elements" do
- -> { Process.exec([]) }.should raise_error(ArgumentError)
- -> { Process.exec([:a]) }.should raise_error(ArgumentError)
- -> { Process.exec([:a, :b, :c]) }.should raise_error(ArgumentError)
+ lambda { Process.exec([]) }.should raise_error(ArgumentError)
+ lambda { Process.exec([:a]) }.should raise_error(ArgumentError)
+ lambda { Process.exec([:a, :b, :c]) }.should raise_error(ArgumentError)
end
end
@@ -200,9 +200,9 @@ describe "Process.exec" do
it "maps the key to a file descriptor in the child that inherits the file descriptor from the parent specified by the value" do
map_fd_fixture = fixture __FILE__, "map_fd.rb"
cmd = <<-EOC
- f = File.open(#{@name.inspect}, "w+")
+ f = File.open("#{@name}", "w+")
child_fd = f.fileno + 1
- File.open(#{@child_fd_file.inspect}, "w") { |io| io.print child_fd }
+ File.open("#{@child_fd_file}", "w") { |io| io.print child_fd }
Process.exec "#{ruby_cmd(map_fd_fixture)} \#{child_fd}", { child_fd => f }
EOC
@@ -212,35 +212,6 @@ describe "Process.exec" do
File.read(@name).should == "writing to fd: #{child_fd}"
end
-
- it "lets the process after exec have specified file descriptor despite close_on_exec" do
- map_fd_fixture = fixture __FILE__, "map_fd.rb"
- cmd = <<-EOC
- f = File.open(#{@name.inspect}, 'w+')
- puts(f.fileno, f.close_on_exec?)
- STDOUT.flush
- Process.exec("#{ruby_cmd(map_fd_fixture)} \#{f.fileno}", f.fileno => f.fileno)
- EOC
-
- output = ruby_exe(cmd, escape: true)
- child_fd, close_on_exec = output.split
-
- child_fd.to_i.should > STDERR.fileno
- close_on_exec.should == 'true'
- File.read(@name).should == "writing to fd: #{child_fd}"
- end
-
- it "sets close_on_exec to false on specified fd even when it fails" do
- cmd = <<-EOC
- f = File.open(#{__FILE__.inspect}, 'r')
- puts(f.close_on_exec?)
- Process.exec('/', f.fileno => f.fileno) rescue nil
- puts(f.close_on_exec?)
- EOC
-
- output = ruby_exe(cmd, escape: true)
- output.split.should == ['true', 'false']
- end
end
end
end
diff --git a/spec/ruby/core/process/exit_spec.rb b/spec/ruby/core/process/exit_spec.rb
index 70d79d789d..7cbd0c363e 100644
--- a/spec/ruby/core/process/exit_spec.rb
+++ b/spec/ruby/core/process/exit_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/process/exit'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/process/exit', __FILE__)
describe "Process.exit" do
it_behaves_like :process_exit, :exit, Process
diff --git a/spec/ruby/core/process/fixtures/clocks.rb b/spec/ruby/core/process/fixtures/clocks.rb
deleted file mode 100644
index f043f6ac1f..0000000000
--- a/spec/ruby/core/process/fixtures/clocks.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-module ProcessSpecs
- def self.clock_constants
- clocks = []
-
- platform_is_not :windows, :solaris do
- clocks += Process.constants.select { |c| c.to_s.start_with?('CLOCK_') }
-
- # These require CAP_WAKE_ALARM and are not documented in
- # Process#clock_gettime. They return EINVAL if the permission
- # is not granted.
- clocks -= [:CLOCK_BOOTTIME_ALARM, :CLOCK_REALTIME_ALARM]
- end
-
- clocks.sort.map { |c|
- [c, Process.const_get(c)]
- }
- end
-end
diff --git a/spec/ruby/core/process/fixtures/common.rb b/spec/ruby/core/process/fixtures/common.rb
index f49513d262..bdbf1e654b 100644
--- a/spec/ruby/core/process/fixtures/common.rb
+++ b/spec/ruby/core/process/fixtures/common.rb
@@ -3,15 +3,11 @@ module ProcessSpecs
if defined?(MSpecScript::SYSTEM_RUBY)
context.send(:before, :all) do
@ruby = ::RUBY_EXE
- suppress_warning {
- Object.const_set(:RUBY_EXE, MSpecScript::SYSTEM_RUBY)
- }
+ Object.const_set(:RUBY_EXE, MSpecScript::SYSTEM_RUBY)
end
context.send(:after, :all) do
- suppress_warning {
- Object.const_set(:RUBY_EXE, @ruby)
- }
+ Object.const_set(:RUBY_EXE, @ruby)
end
end
end
diff --git a/spec/ruby/core/process/fixtures/in.txt b/spec/ruby/core/process/fixtures/in.txt
deleted file mode 100644
index cf52303bdc..0000000000
--- a/spec/ruby/core/process/fixtures/in.txt
+++ /dev/null
@@ -1 +0,0 @@
-stdin
diff --git a/spec/ruby/core/process/fixtures/map_fd.rb b/spec/ruby/core/process/fixtures/map_fd.rb
index 3ed887486b..fc542625b0 100644
--- a/spec/ruby/core/process/fixtures/map_fd.rb
+++ b/spec/ruby/core/process/fixtures/map_fd.rb
@@ -1,7 +1,6 @@
fd = ARGV.shift.to_i
-f = File.for_fd(fd)
-f.autoclose = false
+f = File.for_fd fd
begin
f.write "writing to fd: #{fd}"
ensure
diff --git a/spec/ruby/core/process/fork_spec.rb b/spec/ruby/core/process/fork_spec.rb
index a4f765247d..2de2231dc5 100644
--- a/spec/ruby/core/process/fork_spec.rb
+++ b/spec/ruby/core/process/fork_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/process/fork'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/process/fork', __FILE__)
describe "Process.fork" do
it_behaves_like :process_fork, :fork, Process
diff --git a/spec/ruby/core/process/getpgid_spec.rb b/spec/ruby/core/process/getpgid_spec.rb
index c1dd007b16..b92fb15152 100644
--- a/spec/ruby/core/process/getpgid_spec.rb
+++ b/spec/ruby/core/process/getpgid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.getpgid" do
platform_is_not :windows do
diff --git a/spec/ruby/core/process/getpgrp_spec.rb b/spec/ruby/core/process/getpgrp_spec.rb
index e1d1c5f92d..9643a16b2a 100644
--- a/spec/ruby/core/process/getpgrp_spec.rb
+++ b/spec/ruby/core/process/getpgrp_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
# see setpgrp_spec.rb
diff --git a/spec/ruby/core/process/getpriority_spec.rb b/spec/ruby/core/process/getpriority_spec.rb
index 4b66e18679..68307b9bd5 100644
--- a/spec/ruby/core/process/getpriority_spec.rb
+++ b/spec/ruby/core/process/getpriority_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.getpriority" do
platform_is_not :windows do
diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb
index f77a61a475..7924d43081 100644
--- a/spec/ruby/core/process/getrlimit_spec.rb
+++ b/spec/ruby/core/process/getrlimit_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is :aix do
# In AIX, if getrlimit(2) is called multiple times with RLIMIT_DATA,
- # the first call and the subsequent calls return slightly different
+ # the first call and the subequent calls return slightly different
# values of rlim_cur, even if the process does nothing between
# the calls. This behavior causes some of the tests in this spec
# to fail, so call Process.getrlimit(:DATA) once and discard the result.
@@ -36,33 +36,33 @@ platform_is_not :windows do
obj = mock("process getrlimit integer")
obj.should_receive(:to_int).and_return(nil)
- -> { Process.getrlimit(obj) }.should raise_error(TypeError)
+ lambda { Process.getrlimit(obj) }.should raise_error(TypeError)
end
end
context "when passed a Symbol" do
- it "coerces the short name into the full RLIMIT_ prefixed name" do
- Process.constants.grep(/\ARLIMIT_/) do |fullname|
- short = fullname[/\ARLIMIT_(.+)/, 1]
+ Process.constants.grep(/\ARLIMIT_/) do |fullname|
+ short = $'
+ it "coerces :#{short} into #{fullname}" do
Process.getrlimit(short.to_sym).should == Process.getrlimit(Process.const_get(fullname))
end
end
it "raises ArgumentError when passed an unknown resource" do
- -> { Process.getrlimit(:FOO) }.should raise_error(ArgumentError)
+ lambda { Process.getrlimit(:FOO) }.should raise_error(ArgumentError)
end
end
context "when passed a String" do
- it "coerces the short name into the full RLIMIT_ prefixed name" do
- Process.constants.grep(/\ARLIMIT_/) do |fullname|
- short = fullname[/\ARLIMIT_(.+)/, 1]
+ Process.constants.grep(/\ARLIMIT_/) do |fullname|
+ short = $'
+ it "coerces '#{short}' into #{fullname}" do
Process.getrlimit(short).should == Process.getrlimit(Process.const_get(fullname))
end
end
it "raises ArgumentError when passed an unknown resource" do
- -> { Process.getrlimit("FOO") }.should raise_error(ArgumentError)
+ lambda { Process.getrlimit("FOO") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/process/gid/change_privilege_spec.rb b/spec/ruby/core/process/gid/change_privilege_spec.rb
index 4ada277514..9670e4970f 100644
--- a/spec/ruby/core/process/gid/change_privilege_spec.rb
+++ b/spec/ruby/core/process/gid/change_privilege_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.change_privilege" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid/eid_spec.rb b/spec/ruby/core/process/gid/eid_spec.rb
index 3f2186bb6a..6d6a672fea 100644
--- a/spec/ruby/core/process/gid/eid_spec.rb
+++ b/spec/ruby/core/process/gid/eid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.eid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid/grant_privilege_spec.rb b/spec/ruby/core/process/gid/grant_privilege_spec.rb
index 10da7f8a26..27373c7113 100644
--- a/spec/ruby/core/process/gid/grant_privilege_spec.rb
+++ b/spec/ruby/core/process/gid/grant_privilege_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.grant_privilege" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid/re_exchange_spec.rb b/spec/ruby/core/process/gid/re_exchange_spec.rb
index 9642c81c5b..4f3a242680 100644
--- a/spec/ruby/core/process/gid/re_exchange_spec.rb
+++ b/spec/ruby/core/process/gid/re_exchange_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.re_exchange" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid/re_exchangeable_spec.rb b/spec/ruby/core/process/gid/re_exchangeable_spec.rb
index 1c38f903d5..1fc5298f26 100644
--- a/spec/ruby/core/process/gid/re_exchangeable_spec.rb
+++ b/spec/ruby/core/process/gid/re_exchangeable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.re_exchangeable?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid/rid_spec.rb b/spec/ruby/core/process/gid/rid_spec.rb
index ad66c94e72..fb5c51e412 100644
--- a/spec/ruby/core/process/gid/rid_spec.rb
+++ b/spec/ruby/core/process/gid/rid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.rid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid/sid_available_spec.rb b/spec/ruby/core/process/gid/sid_available_spec.rb
index 8d86b3e9d2..59b2c3ae1e 100644
--- a/spec/ruby/core/process/gid/sid_available_spec.rb
+++ b/spec/ruby/core/process/gid/sid_available_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.sid_available?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid/switch_spec.rb b/spec/ruby/core/process/gid/switch_spec.rb
index b162f1e782..7ae6dae9a7 100644
--- a/spec/ruby/core/process/gid/switch_spec.rb
+++ b/spec/ruby/core/process/gid/switch_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::GID.switch" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/gid_spec.rb b/spec/ruby/core/process/gid_spec.rb
index 07221da420..c39c60a95f 100644
--- a/spec/ruby/core/process/gid_spec.rb
+++ b/spec/ruby/core/process/gid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.gid" do
platform_is_not :windows do
diff --git a/spec/ruby/core/process/groups_spec.rb b/spec/ruby/core/process/groups_spec.rb
index cbbe4fed25..2e12aa350c 100644
--- a/spec/ruby/core/process/groups_spec.rb
+++ b/spec/ruby/core/process/groups_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.groups" do
platform_is_not :windows do
@@ -6,15 +6,15 @@ describe "Process.groups" do
groups = `id -G`.scan(/\d+/).map { |i| i.to_i }
gid = Process.gid
- expected = (groups.sort - [gid]).uniq.sort
- actual = (Process.groups - [gid]).uniq.sort
+ expected = (groups.sort - [gid]).sort
+ actual = (Process.groups - [gid]).sort
actual.should == expected
end
end
end
describe "Process.groups=" do
- platform_is_not :windows, :android do
+ platform_is_not :windows do
as_superuser do
it "sets the list of gids of groups in the supplemental group access list" do
groups = Process.groups
@@ -46,15 +46,16 @@ describe "Process.groups=" do
Process.groups.should == [ Process.gid ]
supplementary = groups - [ Process.gid ]
if supplementary.length > 0
- -> { Process.groups = supplementary }.should raise_error(Errno::EPERM)
+ lambda { Process.groups = supplementary }.should raise_error(Errno::EPERM)
end
end
end
platform_is_not :aix do
it "raises Errno::EPERM" do
- -> {
- Process.groups = [0]
+ groups = Process.groups
+ lambda {
+ Process.groups = groups
}.should raise_error(Errno::EPERM)
end
end
diff --git a/spec/ruby/core/process/initgroups_spec.rb b/spec/ruby/core/process/initgroups_spec.rb
index ffc7f282b6..084c52652c 100644
--- a/spec/ruby/core/process/initgroups_spec.rb
+++ b/spec/ruby/core/process/initgroups_spec.rb
@@ -1,21 +1,19 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.initgroups" do
- platform_is_not :windows, :android do
- as_user do
- it "initializes the supplemental group access list" do
- name = `id -un`.strip
- groups = Process.groups
- gid = groups.max.to_i + 1
- augmented_groups = `id -G`.scan(/\d+/).map {|i| i.to_i} << gid
- if Process.uid == 0
- Process.groups = []
- Process.initgroups(name, gid).sort.should == augmented_groups.sort
- Process.groups.sort.should == augmented_groups.sort
- Process.groups = groups
- else
- -> { Process.initgroups(name, gid) }.should raise_error(Errno::EPERM)
- end
+ platform_is_not :windows do
+ it "initializes the supplemental group access list" do
+ name = `id -un`.strip
+ groups = Process.groups
+ gid = groups.max.to_i + 1
+ augmented_groups = `id -G`.scan(/\d+/).map {|i| i.to_i} << gid
+ if Process.uid == 0
+ Process.groups = []
+ Process.initgroups(name, gid).sort.should == augmented_groups.sort
+ Process.groups.sort.should == augmented_groups.sort
+ Process.groups = groups
+ else
+ lambda { Process.initgroups(name, gid) }.should raise_error(Errno::EPERM)
end
end
end
diff --git a/spec/ruby/core/process/kill_spec.rb b/spec/ruby/core/process/kill_spec.rb
index 4bd64a1fe8..4316daf374 100644
--- a/spec/ruby/core/process/kill_spec.rb
+++ b/spec/ruby/core/process/kill_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Process.kill" do
ProcessSpecs.use_system_ruby(self)
@@ -9,32 +9,28 @@ describe "Process.kill" do
end
it "raises an ArgumentError for unknown signals" do
- -> { Process.kill("FOO", @pid) }.should raise_error(ArgumentError)
+ lambda { Process.kill("FOO", @pid) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if passed a lowercase signal name" do
- -> { Process.kill("term", @pid) }.should raise_error(ArgumentError)
+ lambda { Process.kill("term", @pid) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if signal is not a Fixnum or String" do
signal = mock("process kill signal")
signal.should_not_receive(:to_int)
- -> { Process.kill(signal, @pid) }.should raise_error(ArgumentError)
+ lambda { Process.kill(signal, @pid) }.should raise_error(ArgumentError)
end
it "raises Errno::ESRCH if the process does not exist" do
pid = Process.spawn(*ruby_exe, "-e", "sleep 10")
Process.kill("SIGKILL", pid)
Process.wait(pid)
- -> {
+ lambda {
Process.kill("SIGKILL", pid)
}.should raise_error(Errno::ESRCH)
end
-
- it "checks for existence and permissions to signal a process, but does not actually signal it, when using signal 0" do
- Process.kill(0, @pid).should == 1
- end
end
platform_is_not :windows do
@@ -69,7 +65,7 @@ platform_is_not :windows do
@sp.result.should == "signaled"
end
- it "accepts an Integer as a signal value" do
+ it "acceps an Integer as a signal value" do
Process.kill(15, @sp.pid)
@sp.result.should == "signaled"
end
diff --git a/spec/ruby/core/process/last_status_spec.rb b/spec/ruby/core/process/last_status_spec.rb
deleted file mode 100644
index 3898dd6b95..0000000000
--- a/spec/ruby/core/process/last_status_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is '2.5' do
- describe 'Process#last_status' do
- it 'returns the status of the last executed child process in the current thread' do
- pid = Process.wait Process.spawn("exit 0")
- Process.last_status.pid.should == pid
- end
-
- it 'returns nil if no child process has been ever executed in the current thread' do
- Thread.new do
- Process.last_status.should == nil
- end.join
- end
-
- it 'raises an ArgumentError if any arguments are provided' do
- -> { Process.last_status(1) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/core/process/maxgroups_spec.rb b/spec/ruby/core/process/maxgroups_spec.rb
index 362f788ab2..8a40a1aba6 100644
--- a/spec/ruby/core/process/maxgroups_spec.rb
+++ b/spec/ruby/core/process/maxgroups_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
describe "Process.maxgroups" do
diff --git a/spec/ruby/core/process/pid_spec.rb b/spec/ruby/core/process/pid_spec.rb
index c5947ab50d..114b20f11f 100644
--- a/spec/ruby/core/process/pid_spec.rb
+++ b/spec/ruby/core/process/pid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.pid" do
it "returns the process id of this process" do
diff --git a/spec/ruby/core/process/ppid_spec.rb b/spec/ruby/core/process/ppid_spec.rb
index 47c32a8591..ec6ce865ee 100644
--- a/spec/ruby/core/process/ppid_spec.rb
+++ b/spec/ruby/core/process/ppid_spec.rb
@@ -1,9 +1,23 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.ppid" do
- platform_is_not :windows do
+ with_feature :fork do
it "returns the process id of the parent of this process" do
- ruby_exe("puts Process.ppid").should == "#{Process.pid}\n"
+
+ read, write = IO.pipe
+
+ child_pid = Process.fork {
+ read.close
+ write << "#{Process.ppid}\n"
+ write.close
+ exit!
+ }
+
+ write.close
+ pid = read.gets
+ read.close
+ Process.wait(child_pid)
+ pid.to_i.should == Process.pid
end
end
end
diff --git a/spec/ruby/core/process/set_proctitle_spec.rb b/spec/ruby/core/process/set_proctitle_spec.rb
index d022f2021c..e004f8efc9 100644
--- a/spec/ruby/core/process/set_proctitle_spec.rb
+++ b/spec/ruby/core/process/set_proctitle_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
# Note that there's no way to get the current process title defined as a spec
# somewhere. Process.setproctitle explicitly does not change `$0` so the only
diff --git a/spec/ruby/core/process/setpgid_spec.rb b/spec/ruby/core/process/setpgid_spec.rb
index be724e9007..bd1596d0eb 100644
--- a/spec/ruby/core/process/setpgid_spec.rb
+++ b/spec/ruby/core/process/setpgid_spec.rb
@@ -1,8 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.setpgid" do
- platform_is_not :windows do
- # Must use fork as setpgid(2) gives EACCESS after execve()
+ with_feature :fork do
it "sets the process group id of the specified process" do
rd, wr = IO.pipe
diff --git a/spec/ruby/core/process/setpgrp_spec.rb b/spec/ruby/core/process/setpgrp_spec.rb
index 800668008d..8e72795f96 100644
--- a/spec/ruby/core/process/setpgrp_spec.rb
+++ b/spec/ruby/core/process/setpgrp_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
# TODO: put these in the right files.
describe "Process.setpgrp and Process.getpgrp" do
diff --git a/spec/ruby/core/process/setpriority_spec.rb b/spec/ruby/core/process/setpriority_spec.rb
index 4d60973429..7b437a547a 100644
--- a/spec/ruby/core/process/setpriority_spec.rb
+++ b/spec/ruby/core/process/setpriority_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.setpriority" do
platform_is_not :windows do
@@ -29,32 +29,13 @@ describe "Process.setpriority" do
end
as_superuser do
- guard -> {
- prio = Process.getpriority(Process::PRIO_USER, 0)
- # The nice value is a value in the range -20 to 19.
- # This test tries to change the nice value to +-1, so it cannot run if prio == -20 || prio == 19.
- if -20 < prio && prio < 19
- begin
- # Check if we can lower the nice value or not.
- #
- # We are not always able to do it even as a root.
- # Docker container is not always able to do it depending upon the configuration,
- # which cannot know from the container itself.
- Process.setpriority(Process::PRIO_USER, 0, prio - 1)
- Process.setpriority(Process::PRIO_USER, 0, prio)
- true
- rescue Errno::EACCES
- false
- end
- end
- } do
- it "sets the scheduling priority for a specified user" do
- prio = Process.getpriority(Process::PRIO_USER, 0)
- Process.setpriority(Process::PRIO_USER, 0, prio + 1).should == 0
- Process.getpriority(Process::PRIO_USER, 0).should == (prio + 1)
- Process.setpriority(Process::PRIO_USER, 0, prio).should == 0
- end
+ it "sets the scheduling priority for a specified user" do
+ p = Process.getpriority(Process::PRIO_USER, 0)
+ Process.setpriority(Process::PRIO_USER, 0, p + 1).should == 0
+ Process.getpriority(Process::PRIO_USER, 0).should == (p + 1)
+ Process.setpriority(Process::PRIO_USER, 0, p).should == 0
end
end
end
+
end
diff --git a/spec/ruby/core/process/setrlimit_spec.rb b/spec/ruby/core/process/setrlimit_spec.rb
index 8bc035a4f1..5d137ca6c1 100644
--- a/spec/ruby/core/process/setrlimit_spec.rb
+++ b/spec/ruby/core/process/setrlimit_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
describe "Process.setrlimit" do
@@ -16,7 +16,7 @@ platform_is_not :windows do
obj = mock("process getrlimit integer")
obj.should_receive(:to_int).and_return(nil)
- -> { Process.setrlimit(obj, @limit, @max) }.should raise_error(TypeError)
+ lambda { Process.setrlimit(obj, @limit, @max) }.should raise_error(TypeError)
end
it "calls #to_int to convert the soft limit to an Integer" do
@@ -27,7 +27,7 @@ platform_is_not :windows do
obj = mock("process getrlimit integer")
obj.should_receive(:to_int).and_return(nil)
- -> { Process.setrlimit(@resource, obj, @max) }.should raise_error(TypeError)
+ lambda { Process.setrlimit(@resource, obj, @max) }.should raise_error(TypeError)
end
it "calls #to_int to convert the hard limit to an Integer" do
@@ -38,7 +38,7 @@ platform_is_not :windows do
obj = mock("process getrlimit integer")
obj.should_receive(:to_int).and_return(nil)
- -> { Process.setrlimit(@resource, @limit, obj) }.should raise_error(TypeError)
+ lambda { Process.setrlimit(@resource, @limit, obj) }.should raise_error(TypeError)
end
end
@@ -100,7 +100,7 @@ platform_is_not :windows do
Process.setrlimit(:RTPRIO, *Process.getrlimit(Process::RLIMIT_RTPRIO)).should be_nil
end
- guard -> { defined?(Process::RLIMIT_RTTIME) } do
+ if defined?(Process::RLIMIT_RTTIME)
it "coerces :RTTIME into RLIMIT_RTTIME" do
Process.setrlimit(:RTTIME, *Process.getrlimit(Process::RLIMIT_RTTIME)).should be_nil
end
@@ -120,7 +120,7 @@ platform_is_not :windows do
end
it "raises ArgumentError when passed an unknown resource" do
- -> { Process.setrlimit(:FOO, 1, 1) }.should raise_error(ArgumentError)
+ lambda { Process.setrlimit(:FOO, 1, 1) }.should raise_error(ArgumentError)
end
end
@@ -182,7 +182,7 @@ platform_is_not :windows do
Process.setrlimit("RTPRIO", *Process.getrlimit(Process::RLIMIT_RTPRIO)).should be_nil
end
- guard -> { defined?(Process::RLIMIT_RTTIME) } do
+ if defined?(Process::RLIMIT_RTTIME)
it "coerces 'RTTIME' into RLIMIT_RTTIME" do
Process.setrlimit("RTTIME", *Process.getrlimit(Process::RLIMIT_RTTIME)).should be_nil
end
@@ -202,7 +202,7 @@ platform_is_not :windows do
end
it "raises ArgumentError when passed an unknown resource" do
- -> { Process.setrlimit("FOO", 1, 1) }.should raise_error(ArgumentError)
+ lambda { Process.setrlimit("FOO", 1, 1) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/process/setsid_spec.rb b/spec/ruby/core/process/setsid_spec.rb
index c83f912066..5f060ef218 100644
--- a/spec/ruby/core/process/setsid_spec.rb
+++ b/spec/ruby/core/process/setsid_spec.rb
@@ -1,16 +1,37 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.setsid" do
- platform_is_not :windows do
+ with_feature :fork do
it "establishes this process as a new session and process group leader" do
- sid = Process.getsid
+ read, write = IO.pipe
+ read2, write2 = IO.pipe
+ pid = Process.fork {
+ begin
+ read.close
+ write2.close
+ pgid = Process.setsid
+ write << pgid
+ write.close
+ read2.gets
+ rescue Exception => e
+ write << e << e.backtrace
+ end
+ Process.exit!
+ }
+ write.close
+ read2.close
+ pgid_child = Integer(read.gets)
+ read.close
+ platform_is_not :aix, :openbsd do
+ # AIX does not allow Process.getsid(pid)
+ # if pid is in a different session.
+ pgid = Process.getsid(pid)
+ pgid_child.should == pgid
+ end
+ write2.close
+ Process.wait pid
- out = ruby_exe("p Process.getsid; p Process.setsid; p Process.getsid").lines
- out[0].should == "#{sid}\n"
- out[1].should == out[2]
- out[2].should_not == "#{sid}\n"
-
- sid.should == Process.getsid
+ pgid_child.should_not == Process.getsid
end
end
end
diff --git a/spec/ruby/core/process/spawn_spec.rb b/spec/ruby/core/process/spawn_spec.rb
index 06ad9a2518..9e34713757 100644
--- a/spec/ruby/core/process/spawn_spec.rb
+++ b/spec/ruby/core/process/spawn_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
newline = "\n"
platform_is :windows do
@@ -7,25 +7,27 @@ platform_is :windows do
end
describe :process_spawn_does_not_close_std_streams, shared: true do
- it "does not close STDIN" do
- code = "puts STDIN.read"
- cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
- ruby_exe(cmd, args: "< #{fixture(__FILE__, "in.txt")} > #{@name}")
- File.binread(@name).should == %[stdin#{newline}]
- end
+ platform_is_not :windows do
+ it "does not close STDIN" do
+ code = "STDOUT.puts STDIN.read(0).inspect"
+ cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
+ ruby_exe(cmd, args: "> #{@output}")
+ File.binread(@output).should == %[""#{newline}]
+ end
- it "does not close STDOUT" do
- code = "STDOUT.puts 'hello'"
- cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
- ruby_exe(cmd, args: "> #{@name}")
- File.binread(@name).should == "hello#{newline}"
- end
+ it "does not close STDOUT" do
+ code = "STDOUT.puts 'hello'"
+ cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
+ ruby_exe(cmd, args: "> #{@output}")
+ File.binread(@output).should == "hello#{newline}"
+ end
- it "does not close STDERR" do
- code = "STDERR.puts 'hello'"
- cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
- ruby_exe(cmd, args: "2> #{@name}")
- File.binread(@name).should =~ /hello#{newline}/
+ it "does not close STDERR" do
+ code = "STDERR.puts 'hello'"
+ cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
+ ruby_exe(cmd, args: "2> #{@output}")
+ File.binread(@output).should == "hello#{newline}"
+ end
end
end
@@ -45,7 +47,7 @@ describe "Process.spawn" do
end
it "executes the given command" do
- -> { Process.wait Process.spawn("echo spawn") }.should output_to_fd("spawn\n")
+ lambda { Process.wait Process.spawn("echo spawn") }.should output_to_fd("spawn\n")
end
it "returns the process ID of the new process as a Fixnum" do
@@ -67,43 +69,43 @@ describe "Process.spawn" do
describe "with a single argument" do
platform_is_not :windows do
it "subjects the specified command to shell expansion" do
- -> { Process.wait Process.spawn("echo *") }.should_not output_to_fd("*\n")
+ lambda { Process.wait Process.spawn("echo *") }.should_not output_to_fd("*\n")
end
it "creates an argument array with shell parsing semantics for whitespace" do
- -> { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n")
+ lambda { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n")
end
end
platform_is :windows do
# There is no shell expansion on Windows
it "does not subject the specified command to shell expansion on Windows" do
- -> { Process.wait Process.spawn("echo *") }.should output_to_fd("*\n")
+ lambda { Process.wait Process.spawn("echo *") }.should output_to_fd("*\n")
end
it "does not create an argument array with shell parsing semantics for whitespace on Windows" do
- -> { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n")
+ lambda { Process.wait Process.spawn("echo a b c d") }.should output_to_fd("a b c d\n")
end
end
it "calls #to_str to convert the argument to a String" do
o = mock("to_str")
o.should_receive(:to_str).and_return("echo foo")
- -> { Process.wait Process.spawn(o) }.should output_to_fd("foo\n")
+ lambda { Process.wait Process.spawn(o) }.should output_to_fd("foo\n")
end
it "raises an ArgumentError if the command includes a null byte" do
- -> { Process.spawn "\000" }.should raise_error(ArgumentError)
+ lambda { Process.spawn "\000" }.should raise_error(ArgumentError)
end
it "raises a TypeError if the argument does not respond to #to_str" do
- -> { Process.spawn :echo }.should raise_error(TypeError)
+ lambda { Process.spawn :echo }.should raise_error(TypeError)
end
end
describe "with multiple arguments" do
it "does not subject the arguments to shell expansion" do
- -> { Process.wait Process.spawn("echo", "*") }.should output_to_fd("*\n")
+ lambda { Process.wait Process.spawn("echo", "*") }.should output_to_fd("*\n")
end
it "preserves whitespace in passed arguments" do
@@ -112,36 +114,36 @@ describe "Process.spawn" do
# The echo command on Windows takes quotes literally
out = "\"a b c d\"\n"
end
- -> { Process.wait Process.spawn("echo", "a b c d") }.should output_to_fd(out)
+ lambda { Process.wait Process.spawn("echo", "a b c d") }.should output_to_fd(out)
end
it "calls #to_str to convert the arguments to Strings" do
o = mock("to_str")
o.should_receive(:to_str).and_return("foo")
- -> { Process.wait Process.spawn("echo", o) }.should output_to_fd("foo\n")
+ lambda { Process.wait Process.spawn("echo", o) }.should output_to_fd("foo\n")
end
it "raises an ArgumentError if an argument includes a null byte" do
- -> { Process.spawn "echo", "\000" }.should raise_error(ArgumentError)
+ lambda { Process.spawn "echo", "\000" }.should raise_error(ArgumentError)
end
it "raises a TypeError if an argument does not respond to #to_str" do
- -> { Process.spawn "echo", :foo }.should raise_error(TypeError)
+ lambda { Process.spawn "echo", :foo }.should raise_error(TypeError)
end
end
describe "with a command array" do
it "uses the first element as the command name and the second as the argv[0] value" do
platform_is_not :windows do
- -> { Process.wait Process.spawn(["/bin/sh", "argv_zero"], "-c", "echo $0") }.should output_to_fd("argv_zero\n")
+ lambda { Process.wait Process.spawn(["/bin/sh", "argv_zero"], "-c", "echo $0") }.should output_to_fd("argv_zero\n")
end
platform_is :windows do
- -> { Process.wait Process.spawn(["cmd.exe", "/C"], "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n")
+ lambda { Process.wait Process.spawn(["cmd.exe", "/C"], "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n")
end
end
it "does not subject the arguments to shell expansion" do
- -> { Process.wait Process.spawn(["echo", "echo"], "*") }.should output_to_fd("*\n")
+ lambda { Process.wait Process.spawn(["echo", "echo"], "*") }.should output_to_fd("*\n")
end
it "preserves whitespace in passed arguments" do
@@ -150,47 +152,47 @@ describe "Process.spawn" do
# The echo command on Windows takes quotes literally
out = "\"a b c d\"\n"
end
- -> { Process.wait Process.spawn(["echo", "echo"], "a b c d") }.should output_to_fd(out)
+ lambda { Process.wait Process.spawn(["echo", "echo"], "a b c d") }.should output_to_fd(out)
end
it "calls #to_ary to convert the argument to an Array" do
o = mock("to_ary")
platform_is_not :windows do
o.should_receive(:to_ary).and_return(["/bin/sh", "argv_zero"])
- -> { Process.wait Process.spawn(o, "-c", "echo $0") }.should output_to_fd("argv_zero\n")
+ lambda { Process.wait Process.spawn(o, "-c", "echo $0") }.should output_to_fd("argv_zero\n")
end
platform_is :windows do
o.should_receive(:to_ary).and_return(["cmd.exe", "/C"])
- -> { Process.wait Process.spawn(o, "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n")
+ lambda { Process.wait Process.spawn(o, "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n")
end
end
it "calls #to_str to convert the first element to a String" do
o = mock("to_str")
o.should_receive(:to_str).and_return("echo")
- -> { Process.wait Process.spawn([o, "echo"], "foo") }.should output_to_fd("foo\n")
+ lambda { Process.wait Process.spawn([o, "echo"], "foo") }.should output_to_fd("foo\n")
end
it "calls #to_str to convert the second element to a String" do
o = mock("to_str")
o.should_receive(:to_str).and_return("echo")
- -> { Process.wait Process.spawn(["echo", o], "foo") }.should output_to_fd("foo\n")
+ lambda { Process.wait Process.spawn(["echo", o], "foo") }.should output_to_fd("foo\n")
end
it "raises an ArgumentError if the Array does not have exactly two elements" do
- -> { Process.spawn([]) }.should raise_error(ArgumentError)
- -> { Process.spawn([:a]) }.should raise_error(ArgumentError)
- -> { Process.spawn([:a, :b, :c]) }.should raise_error(ArgumentError)
+ lambda { Process.spawn([]) }.should raise_error(ArgumentError)
+ lambda { Process.spawn([:a]) }.should raise_error(ArgumentError)
+ lambda { Process.spawn([:a, :b, :c]) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the Strings in the Array include a null byte" do
- -> { Process.spawn ["\000", "echo"] }.should raise_error(ArgumentError)
- -> { Process.spawn ["echo", "\000"] }.should raise_error(ArgumentError)
+ lambda { Process.spawn ["\000", "echo"] }.should raise_error(ArgumentError)
+ lambda { Process.spawn ["echo", "\000"] }.should raise_error(ArgumentError)
end
it "raises a TypeError if an element in the Array does not respond to #to_str" do
- -> { Process.spawn ["echo", :echo] }.should raise_error(TypeError)
- -> { Process.spawn [:echo, "echo"] }.should raise_error(TypeError)
+ lambda { Process.spawn ["echo", :echo] }.should raise_error(TypeError)
+ lambda { Process.spawn [:echo, "echo"] }.should raise_error(TypeError)
end
end
@@ -238,19 +240,19 @@ describe "Process.spawn" do
end
it "raises an ArgumentError if an environment key includes an equals sign" do
- -> do
+ lambda do
Process.spawn({"FOO=" => "BAR"}, "echo #{@var}>#{@name}")
end.should raise_error(ArgumentError)
end
it "raises an ArgumentError if an environment key includes a null byte" do
- -> do
+ lambda do
Process.spawn({"\000" => "BAR"}, "echo #{@var}>#{@name}")
end.should raise_error(ArgumentError)
end
it "raises an ArgumentError if an environment value includes a null byte" do
- -> do
+ lambda do
Process.spawn({"FOO" => "\000"}, "echo #{@var}>#{@name}")
end.should raise_error(ArgumentError)
end
@@ -294,25 +296,25 @@ describe "Process.spawn" do
platform_is_not :windows do
it "joins the current process group by default" do
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"))
end.should output_to_fd(Process.getpgid(Process.pid).to_s)
end
it "joins the current process if pgroup: false" do
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: false)
end.should output_to_fd(Process.getpgid(Process.pid).to_s)
end
it "joins the current process if pgroup: nil" do
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: nil)
end.should output_to_fd(Process.getpgid(Process.pid).to_s)
end
it "joins a new process group if pgroup: true" do
- process = -> do
+ process = lambda do
Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: true)
end
@@ -321,7 +323,7 @@ describe "Process.spawn" do
end
it "joins a new process group if pgroup: 0" do
- process = -> do
+ process = lambda do
Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: 0)
end
@@ -331,33 +333,23 @@ describe "Process.spawn" do
it "joins the specified process group if pgroup: pgid" do
pgid = Process.getpgid(Process.pid)
- # The process group is not available on all platforms.
- # See "man proc" - /proc/[pid]/stat - (5) pgrp
- # In Travis arm64 environment, the value is 0.
- #
- # $ cat /proc/[pid]/stat
- # 19179 (ruby) S 19160 0 0 ...
- unless pgid.zero?
- -> do
- Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: pgid)
- end.should output_to_fd(pgid.to_s)
- else
- skip "The process group is not available."
- end
+ lambda do
+ Process.wait Process.spawn(ruby_cmd("print Process.getpgid(Process.pid)"), pgroup: pgid)
+ end.should output_to_fd(pgid.to_s)
end
it "raises an ArgumentError if given a negative :pgroup option" do
- -> { Process.spawn("echo", pgroup: -1) }.should raise_error(ArgumentError)
+ lambda { Process.spawn("echo", pgroup: -1) }.should raise_error(ArgumentError)
end
it "raises a TypeError if given a symbol as :pgroup option" do
- -> { Process.spawn("echo", pgroup: :true) }.should raise_error(TypeError)
+ lambda { Process.spawn("echo", pgroup: :true) }.should raise_error(TypeError)
end
end
platform_is :windows do
it "raises an ArgumentError if given :pgroup option" do
- -> { Process.spawn("echo", pgroup: false) }.should raise_error(ArgumentError)
+ lambda { Process.spawn("echo", pgroup: false) }.should raise_error(ArgumentError)
end
end
@@ -368,7 +360,7 @@ describe "Process.spawn" do
# :chdir
it "uses the current working directory as its working directory" do
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print Dir.pwd"))
end.should output_to_fd(Dir.pwd)
end
@@ -384,7 +376,7 @@ describe "Process.spawn" do
end
it "changes to the directory passed for :chdir" do
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print Dir.pwd"), chdir: @dir)
end.should output_to_fd(@dir)
end
@@ -393,67 +385,23 @@ describe "Process.spawn" do
dir = mock("spawn_to_path")
dir.should_receive(:to_path).and_return(@dir)
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print Dir.pwd"), chdir: dir)
end.should output_to_fd(@dir)
end
end
- # chdir
-
- platform_is :linux do
- describe "inside Dir.chdir" do
- def child_pids(pid)
- `pgrep -P #{pid}`.lines.map { |child| Integer(child) }
- end
-
- it "does not create extra process without chdir" do
- pid = Process.spawn("sleep 10")
- begin
- child_pids(pid).size.should == 0
- ensure
- Process.kill("TERM", pid)
- Process.wait(pid)
- end
- end
-
- it "kills extra chdir processes" do
- pid = nil
- Dir.chdir("/tmp") do
- pid = Process.spawn("sleep 10")
- end
-
- children = child_pids(pid)
- children.size.should <= 1
-
- Process.kill("TERM", pid)
- Process.wait(pid)
-
- if children.size > 0
- # wait a bit for children to die
- sleep(1)
-
- children.each do |child|
- -> do
- Process.kill("TERM", child)
- end.should raise_error(Errno::ESRCH)
- end
- end
- end
- end
- end
-
# :umask
it "uses the current umask by default" do
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print File.umask"))
end.should output_to_fd(File.umask.to_s)
end
platform_is_not :windows do
it "sets the umask if given the :umask option" do
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print File.umask"), umask: 146)
end.should output_to_fd("146")
end
@@ -461,9 +409,9 @@ describe "Process.spawn" do
# redirection
- it "redirects STDOUT to the given file descriptor if out: Fixnum" do
+ it "redirects STDOUT to the given file descriptior if out: Fixnum" do
File.open(@name, 'w') do |file|
- -> do
+ lambda do
Process.wait Process.spawn("echo glark", out: file.fileno)
end.should output_to_fd("glark\n", file)
end
@@ -471,7 +419,7 @@ describe "Process.spawn" do
it "redirects STDOUT to the given file if out: IO" do
File.open(@name, 'w') do |file|
- -> do
+ lambda do
Process.wait Process.spawn("echo glark", out: file)
end.should output_to_fd("glark\n", file)
end
@@ -487,9 +435,9 @@ describe "Process.spawn" do
File.read(@name).should == "glark\n"
end
- it "redirects STDERR to the given file descriptor if err: Fixnum" do
+ it "redirects STDERR to the given file descriptior if err: Fixnum" do
File.open(@name, 'w') do |file|
- -> do
+ lambda do
Process.wait Process.spawn("echo glark>&2", err: file.fileno)
end.should output_to_fd("glark\n", file)
end
@@ -497,7 +445,7 @@ describe "Process.spawn" do
it "redirects STDERR to the given file descriptor if err: IO" do
File.open(@name, 'w') do |file|
- -> do
+ lambda do
Process.wait Process.spawn("echo glark>&2", err: file)
end.should output_to_fd("glark\n", file)
end
@@ -510,15 +458,15 @@ describe "Process.spawn" do
it "redirects STDERR to child STDOUT if :err => [:child, :out]" do
File.open(@name, 'w') do |file|
- -> do
+ lambda do
Process.wait Process.spawn("echo glark>&2", :out => file, :err => [:child, :out])
end.should output_to_fd("glark\n", file)
end
end
- it "redirects both STDERR and STDOUT to the given file descriptor" do
+ it "redirects both STDERR and STDOUT to the given file descriptior" do
File.open(@name, 'w') do |file|
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print(:glark); STDOUT.flush; STDERR.print(:bang)"),
[:out, :err] => file.fileno)
end.should output_to_fd("glarkbang", file)
@@ -527,7 +475,7 @@ describe "Process.spawn" do
it "redirects both STDERR and STDOUT to the given IO" do
File.open(@name, 'w') do |file|
- -> do
+ lambda do
Process.wait Process.spawn(ruby_cmd("print(:glark); STDOUT.flush; STDERR.print(:bang)"),
[:out, :err] => file)
end.should output_to_fd("glarkbang", file)
@@ -540,131 +488,107 @@ describe "Process.spawn" do
File.read(@name).should == "glarkbang"
end
- # :close_others
+ context "when passed close_others: true" do
+ before :each do
+ @output = tmp("spawn_close_others_true")
+ @options = { close_others: true }
+ end
- platform_is_not :windows do
- context "defaults :close_others to" do
- ruby_version_is ""..."2.6" do
- it "true" do
- IO.pipe do |r, w|
- w.close_on_exec = false
- code = "begin; IO.new(#{w.fileno}).close; rescue Errno::EBADF; puts 'not inherited'; end"
- Process.wait Process.spawn(ruby_cmd(code), :out => @name)
- File.read(@name).should == "not inherited\n"
- end
- end
- end
+ after :each do
+ rm_r @output
+ end
- ruby_version_is "2.6" do
- it "false" do
- IO.pipe do |r, w|
- w.close_on_exec = false
- code = "io = IO.new(#{w.fileno}); io.puts('inherited'); io.close"
- pid = Process.spawn(ruby_cmd(code))
- w.close
- Process.wait(pid)
- r.read.should == "inherited\n"
- end
+ it "closes file descriptors >= 3 in the child process" do
+ IO.pipe do |r, w|
+ begin
+ pid = Process.spawn(ruby_cmd("while File.exist? '#{@name}'; sleep 0.1; end"), @options)
+ w.close
+ lambda { r.read_nonblock(1) }.should raise_error(EOFError)
+ ensure
+ rm_r @name
+ Process.wait(pid) if pid
end
end
end
- context "when passed close_others: true" do
- before :each do
- @options = { close_others: true }
- end
-
- it "closes file descriptors >= 3 in the child process even if fds are set close_on_exec=false" do
- touch @name
- IO.pipe do |r, w|
- r.close_on_exec = false
- w.close_on_exec = false
-
- begin
- pid = Process.spawn(ruby_cmd("while File.exist? '#{@name}'; sleep 0.1; end"), @options)
- w.close
- r.read(1).should == nil
- ensure
- rm_r @name
- Process.wait(pid) if pid
- end
- end
- end
+ it_should_behave_like :process_spawn_does_not_close_std_streams
+ end
- it_should_behave_like :process_spawn_does_not_close_std_streams
+ context "when passed close_others: false" do
+ before :each do
+ @output = tmp("spawn_close_others_false")
+ @options = { close_others: false }
end
- context "when passed close_others: false" do
- before :each do
- @options = { close_others: false }
- end
+ after :each do
+ rm_r @output
+ end
- it "closes file descriptors >= 3 in the child process because they are set close_on_exec by default" do
- touch @name
- IO.pipe do |r, w|
- begin
- pid = Process.spawn(ruby_cmd("while File.exist? '#{@name}'; sleep 0.1; end"), @options)
- w.close
- r.read(1).should == nil
- ensure
- rm_r @name
- Process.wait(pid) if pid
- end
+ it "closes file descriptors >= 3 in the child process because they are set close_on_exec by default" do
+ IO.pipe do |r, w|
+ begin
+ pid = Process.spawn(ruby_cmd("while File.exist? '#{@name}'; sleep 0.1; end"), @options)
+ w.close
+ lambda { r.read_nonblock(1) }.should raise_error(EOFError)
+ ensure
+ rm_r @name
+ Process.wait(pid) if pid
end
end
+ end
+ platform_is_not :windows do
it "does not close file descriptors >= 3 in the child process if fds are set close_on_exec=false" do
IO.pipe do |r, w|
r.close_on_exec = false
w.close_on_exec = false
-
- code = "fd = IO.for_fd(#{w.fileno}); fd.autoclose = false; fd.write 'abc'; fd.close"
- pid = Process.spawn(ruby_cmd(code), @options)
begin
+ pid = Process.spawn(ruby_cmd("while File.exist? '#{@name}'; sleep 0.1; end"), @options)
w.close
- r.read.should == 'abc'
+ lambda { r.read_nonblock(1) }.should raise_error(Errno::EAGAIN)
ensure
- Process.wait(pid)
+ rm_r @name
+ Process.wait(pid) if pid
end
end
end
-
- it_should_behave_like :process_spawn_does_not_close_std_streams
end
+
+ it_should_behave_like :process_spawn_does_not_close_std_streams
end
# error handling
it "raises an ArgumentError if passed no command arguments" do
- -> { Process.spawn }.should raise_error(ArgumentError)
+ lambda { Process.spawn }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if passed env or options but no command arguments" do
- -> { Process.spawn({}) }.should raise_error(ArgumentError)
+ lambda { Process.spawn({}) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if passed env and options but no command arguments" do
- -> { Process.spawn({}, {}) }.should raise_error(ArgumentError)
+ lambda { Process.spawn({}, {}) }.should raise_error(ArgumentError)
end
it "raises an Errno::ENOENT for an empty string" do
- -> { Process.spawn "" }.should raise_error(Errno::ENOENT)
+ lambda { Process.spawn "" }.should raise_error(Errno::ENOENT)
end
it "raises an Errno::ENOENT if the command does not exist" do
- -> { Process.spawn "nonesuch" }.should raise_error(Errno::ENOENT)
+ lambda { Process.spawn "nonesuch" }.should raise_error(Errno::ENOENT)
end
unless File.executable?(__FILE__) # Some FS (e.g. vboxfs) locate all files executable
platform_is_not :windows do
it "raises an Errno::EACCES when the file does not have execute permissions" do
- -> { Process.spawn __FILE__ }.should raise_error(Errno::EACCES)
+ lambda { Process.spawn __FILE__ }.should raise_error(Errno::EACCES)
end
end
platform_is :windows do
it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do
- -> { Process.spawn __FILE__ }.should raise_error(SystemCallError) { |e|
+ lambda { Process.spawn __FILE__ }.should raise_error(SystemCallError) { |e|
[Errno::EACCES, Errno::ENOEXEC].should include(e.class)
}
end
@@ -672,20 +596,20 @@ describe "Process.spawn" do
end
it "raises an Errno::EACCES or Errno::EISDIR when passed a directory" do
- -> { Process.spawn File.dirname(__FILE__) }.should raise_error(SystemCallError) { |e|
+ lambda { Process.spawn File.dirname(__FILE__) }.should raise_error(SystemCallError) { |e|
[Errno::EACCES, Errno::EISDIR].should include(e.class)
}
end
it "raises an ArgumentError when passed a string key in options" do
- -> { Process.spawn("echo", "chdir" => Dir.pwd) }.should raise_error(ArgumentError)
+ lambda { Process.spawn("echo", "chdir" => Dir.pwd) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed an unknown option key" do
- -> { Process.spawn("echo", nonesuch: :foo) }.should raise_error(ArgumentError)
+ lambda { Process.spawn("echo", nonesuch: :foo) }.should raise_error(ArgumentError)
end
- platform_is_not :windows, :aix do
+ platform_is_not :windows do
describe "with Integer option keys" do
before :each do
@name = tmp("spawn_fd_map.txt")
@@ -699,7 +623,7 @@ describe "Process.spawn" do
end
it "maps the key to a file descriptor in the child that inherits the file descriptor from the parent specified by the value" do
- child_fd = find_unused_fd
+ child_fd = @io.fileno + 1
args = ruby_cmd(fixture(__FILE__, "map_fd.rb"), args: [child_fd.to_s])
pid = Process.spawn(*args, { child_fd => @io })
Process.waitpid pid
diff --git a/spec/ruby/core/process/status/bit_and_spec.rb b/spec/ruby/core/process/status/bit_and_spec.rb
index 97f768fdc1..963d2c6c26 100644
--- a/spec/ruby/core/process/status/bit_and_spec.rb
+++ b/spec/ruby/core/process/status/bit_and_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#&" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/status/coredump_spec.rb b/spec/ruby/core/process/status/coredump_spec.rb
index fbbaf926f7..8988cff9e1 100644
--- a/spec/ruby/core/process/status/coredump_spec.rb
+++ b/spec/ruby/core/process/status/coredump_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#coredump?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/status/equal_value_spec.rb b/spec/ruby/core/process/status/equal_value_spec.rb
index 444ce1775b..1eaaf82273 100644
--- a/spec/ruby/core/process/status/equal_value_spec.rb
+++ b/spec/ruby/core/process/status/equal_value_spec.rb
@@ -1,15 +1,5 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#==" do
- it "returns true when compared to the integer status of an exited child" do
- ruby_exe("exit(29)")
- $?.to_i.should == $?
- $?.should == $?.to_i
- end
-
- it "returns true when compared to the integer status of a terminated child" do
- ruby_exe("Process.kill(:KILL, $$); exit(29)")
- $?.to_i.should == $?
- $?.should == $?.to_i
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/process/status/exited_spec.rb b/spec/ruby/core/process/status/exited_spec.rb
index 0ae3f9e7ae..79863360c5 100644
--- a/spec/ruby/core/process/status/exited_spec.rb
+++ b/spec/ruby/core/process/status/exited_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#exited?" do
diff --git a/spec/ruby/core/process/status/exitstatus_spec.rb b/spec/ruby/core/process/status/exitstatus_spec.rb
index d6c6965b9e..57baf77724 100644
--- a/spec/ruby/core/process/status/exitstatus_spec.rb
+++ b/spec/ruby/core/process/status/exitstatus_spec.rb
@@ -1,6 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#exitstatus" do
+
before :each do
ruby_exe("exit(42)")
end
@@ -9,17 +10,4 @@ describe "Process::Status#exitstatus" do
$?.exitstatus.should == 42
end
- describe "for a child that raised SignalException" do
- before :each do
- ruby_exe("Process.kill(:KILL, $$); exit(42)")
- end
-
- platform_is_not :windows do
- # The exitstatus is not set in these cases. See the termsig_spec
- # for info on where the signal number (SIGTERM) is available.
- it "returns nil" do
- $?.exitstatus.should == nil
- end
- end
- end
end
diff --git a/spec/ruby/core/process/status/inspect_spec.rb b/spec/ruby/core/process/status/inspect_spec.rb
index 03f0479f2c..f3e7d8c9ab 100644
--- a/spec/ruby/core/process/status/inspect_spec.rb
+++ b/spec/ruby/core/process/status/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#inspect" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/status/pid_spec.rb b/spec/ruby/core/process/status/pid_spec.rb
index 9965fc3bdf..3389c242ff 100644
--- a/spec/ruby/core/process/status/pid_spec.rb
+++ b/spec/ruby/core/process/status/pid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
platform_is_not :windows do
describe "Process::Status#pid" do
diff --git a/spec/ruby/core/process/status/right_shift_spec.rb b/spec/ruby/core/process/status/right_shift_spec.rb
index e9dda437e8..5786d4163c 100644
--- a/spec/ruby/core/process/status/right_shift_spec.rb
+++ b/spec/ruby/core/process/status/right_shift_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#>>" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/status/signaled_spec.rb b/spec/ruby/core/process/status/signaled_spec.rb
index f23c95025f..0f80a525c9 100644
--- a/spec/ruby/core/process/status/signaled_spec.rb
+++ b/spec/ruby/core/process/status/signaled_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#signaled?" do
diff --git a/spec/ruby/core/process/status/stopped_spec.rb b/spec/ruby/core/process/status/stopped_spec.rb
index bebd441d6f..e984cefaf7 100644
--- a/spec/ruby/core/process/status/stopped_spec.rb
+++ b/spec/ruby/core/process/status/stopped_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#stopped?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/status/stopsig_spec.rb b/spec/ruby/core/process/status/stopsig_spec.rb
index b2a7c5d9e2..95fc5b0e77 100644
--- a/spec/ruby/core/process/status/stopsig_spec.rb
+++ b/spec/ruby/core/process/status/stopsig_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#stopsig" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/status/success_spec.rb b/spec/ruby/core/process/status/success_spec.rb
index 28a1721800..e589d3f819 100644
--- a/spec/ruby/core/process/status/success_spec.rb
+++ b/spec/ruby/core/process/status/success_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#success?" do
diff --git a/spec/ruby/core/process/status/termsig_spec.rb b/spec/ruby/core/process/status/termsig_spec.rb
index 204708bc1b..d4f55e2521 100644
--- a/spec/ruby/core/process/status/termsig_spec.rb
+++ b/spec/ruby/core/process/status/termsig_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#termsig" do
+
describe "for a child that exited normally" do
+
before :each do
ruby_exe("exit(0)")
end
@@ -11,33 +13,27 @@ describe "Process::Status#termsig" do
end
end
- describe "for a child that raised SignalException" do
- before :each do
- ruby_exe("raise SignalException, 'SIGTERM'")
- end
-
- platform_is_not :windows do
- it "returns the signal" do
- $?.termsig.should == Signal.list["TERM"]
- end
- end
- end
-
describe "for a child that was sent a signal" do
+
before :each do
ruby_exe("Process.kill(:KILL, $$); exit(42)")
end
platform_is_not :windows do
+
it "returns the signal" do
$?.termsig.should == Signal.list["KILL"]
end
+
end
platform_is :windows do
+
it "always returns nil" do
$?.termsig.should be_nil
end
+
end
+
end
end
diff --git a/spec/ruby/core/process/status/to_i_spec.rb b/spec/ruby/core/process/status/to_i_spec.rb
index a284f64f86..c45724552e 100644
--- a/spec/ruby/core/process/status/to_i_spec.rb
+++ b/spec/ruby/core/process/status/to_i_spec.rb
@@ -1,13 +1,5 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#to_i" do
- it "returns an integer when the child exits" do
- ruby_exe('exit 48')
- $?.to_i.should be_an_instance_of(Integer)
- end
-
- it "returns an integer when the child is signaled" do
- ruby_exe('raise SignalException, "TERM"')
- $?.to_i.should be_an_instance_of(Integer)
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/process/status/to_int_spec.rb b/spec/ruby/core/process/status/to_int_spec.rb
index fb596c1bfb..8c988d7e19 100644
--- a/spec/ruby/core/process/status/to_int_spec.rb
+++ b/spec/ruby/core/process/status/to_int_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#to_int" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/status/to_s_spec.rb b/spec/ruby/core/process/status/to_s_spec.rb
index 5c0d4cd30c..ac87f4712a 100644
--- a/spec/ruby/core/process/status/to_s_spec.rb
+++ b/spec/ruby/core/process/status/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Status#to_s" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/getegid_spec.rb b/spec/ruby/core/process/sys/getegid_spec.rb
index 5b8588f147..c21b890519 100644
--- a/spec/ruby/core/process/sys/getegid_spec.rb
+++ b/spec/ruby/core/process/sys/getegid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.getegid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/geteuid_spec.rb b/spec/ruby/core/process/sys/geteuid_spec.rb
index 0ce7fc5459..85c8d6e1bb 100644
--- a/spec/ruby/core/process/sys/geteuid_spec.rb
+++ b/spec/ruby/core/process/sys/geteuid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.geteuid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/getgid_spec.rb b/spec/ruby/core/process/sys/getgid_spec.rb
index 05c0fd4c0b..945d3340f7 100644
--- a/spec/ruby/core/process/sys/getgid_spec.rb
+++ b/spec/ruby/core/process/sys/getgid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.getgid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/getuid_spec.rb b/spec/ruby/core/process/sys/getuid_spec.rb
index 56bcef01cc..ead6e3044f 100644
--- a/spec/ruby/core/process/sys/getuid_spec.rb
+++ b/spec/ruby/core/process/sys/getuid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.getuid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/issetugid_spec.rb b/spec/ruby/core/process/sys/issetugid_spec.rb
index 4fc7dc3bc6..2919c351a7 100644
--- a/spec/ruby/core/process/sys/issetugid_spec.rb
+++ b/spec/ruby/core/process/sys/issetugid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.issetugid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setegid_spec.rb b/spec/ruby/core/process/sys/setegid_spec.rb
index 8f20330b94..edc0d59da4 100644
--- a/spec/ruby/core/process/sys/setegid_spec.rb
+++ b/spec/ruby/core/process/sys/setegid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setegid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/seteuid_spec.rb b/spec/ruby/core/process/sys/seteuid_spec.rb
index 57d3a4800d..70cc78bec4 100644
--- a/spec/ruby/core/process/sys/seteuid_spec.rb
+++ b/spec/ruby/core/process/sys/seteuid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.seteuid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setgid_spec.rb b/spec/ruby/core/process/sys/setgid_spec.rb
index cc712e0102..25272b1eec 100644
--- a/spec/ruby/core/process/sys/setgid_spec.rb
+++ b/spec/ruby/core/process/sys/setgid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setgid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setregid_spec.rb b/spec/ruby/core/process/sys/setregid_spec.rb
index 57d491a707..18a5834c80 100644
--- a/spec/ruby/core/process/sys/setregid_spec.rb
+++ b/spec/ruby/core/process/sys/setregid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setregid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setresgid_spec.rb b/spec/ruby/core/process/sys/setresgid_spec.rb
index 9be06612c1..9f1736b460 100644
--- a/spec/ruby/core/process/sys/setresgid_spec.rb
+++ b/spec/ruby/core/process/sys/setresgid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setresgid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setresuid_spec.rb b/spec/ruby/core/process/sys/setresuid_spec.rb
index 1092b349cb..94c892bfdf 100644
--- a/spec/ruby/core/process/sys/setresuid_spec.rb
+++ b/spec/ruby/core/process/sys/setresuid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setresuid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setreuid_spec.rb b/spec/ruby/core/process/sys/setreuid_spec.rb
index f3451c63c8..72a8e61e7a 100644
--- a/spec/ruby/core/process/sys/setreuid_spec.rb
+++ b/spec/ruby/core/process/sys/setreuid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setreuid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setrgid_spec.rb b/spec/ruby/core/process/sys/setrgid_spec.rb
index 27eea2ed86..ae820c98b8 100644
--- a/spec/ruby/core/process/sys/setrgid_spec.rb
+++ b/spec/ruby/core/process/sys/setrgid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setrgid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setruid_spec.rb b/spec/ruby/core/process/sys/setruid_spec.rb
index 9dbd84bf68..4f40f6666a 100644
--- a/spec/ruby/core/process/sys/setruid_spec.rb
+++ b/spec/ruby/core/process/sys/setruid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setruid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/sys/setuid_spec.rb b/spec/ruby/core/process/sys/setuid_spec.rb
index e06c3588a5..13bf072ad1 100644
--- a/spec/ruby/core/process/sys/setuid_spec.rb
+++ b/spec/ruby/core/process/sys/setuid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::Sys.setuid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/times_spec.rb b/spec/ruby/core/process/times_spec.rb
index 35a7f5b34c..01a5595ef9 100644
--- a/spec/ruby/core/process/times_spec.rb
+++ b/spec/ruby/core/process/times_spec.rb
@@ -1,30 +1,27 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.times" do
- it "returns a Process::Tms" do
- Process.times.should be_kind_of(Process::Tms)
+ it "returns a Struct::Tms" do
+ Process.times.should be_kind_of(Struct::Tms)
end
it "returns current cpu times" do
t = Process.times
- user = t.utime
- 1 until Process.times.utime > user
- Process.times.utime.should > user
- end
-
- ruby_version_is "2.5" do
- platform_is_not :windows do
- it "uses getrusage when available to improve precision beyond milliseconds" do
- times = 1000.times.map { Process.clock_gettime(:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) }
- if times.count { |t| !('%.6f' % t).end_with?('000') } == 0
- skip "getrusage is not supported on this environment"
- end
+ # Do busy work for a wall-clock interval.
+ start = Time.now
+ 1 until (Time.now - start) > 0.5
- times = 1000.times.map { Process.times }
- times.count { |t| !('%.6f' % t.utime).end_with?('000') }.should > 0
- times.count { |t| !('%.6f' % t.stime).end_with?('000') }.should > 0
- end
- end
+ # Ensure times is larger. NOTE that there is no
+ # guarantee of an upper bound since anything may be
+ # happening at the OS level, so we ONLY check that at
+ # least an interval has elapsed. Also, we are assuming
+ # there is a correlation between wall clock time and
+ # process time. In practice, there is an observed
+ # discrepancy often 10% or greater. In other words,
+ # this is a very fuzzy test.
+ t2 = Process.times
+ diff = (t2.utime + t2.stime) - (t.utime + t.stime)
+ diff.should > 0
end
end
diff --git a/spec/ruby/core/process/uid/change_privilege_spec.rb b/spec/ruby/core/process/uid/change_privilege_spec.rb
index e4b552dd94..91a38bfcdf 100644
--- a/spec/ruby/core/process/uid/change_privilege_spec.rb
+++ b/spec/ruby/core/process/uid/change_privilege_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.change_privilege" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid/eid_spec.rb b/spec/ruby/core/process/uid/eid_spec.rb
index f0bb9ce762..39fcd13d93 100644
--- a/spec/ruby/core/process/uid/eid_spec.rb
+++ b/spec/ruby/core/process/uid/eid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.eid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid/grant_privilege_spec.rb b/spec/ruby/core/process/uid/grant_privilege_spec.rb
index 2b8a5c9102..c4d3443de8 100644
--- a/spec/ruby/core/process/uid/grant_privilege_spec.rb
+++ b/spec/ruby/core/process/uid/grant_privilege_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.grant_privilege" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid/re_exchange_spec.rb b/spec/ruby/core/process/uid/re_exchange_spec.rb
index c0f10f33c4..2f9b0d6a87 100644
--- a/spec/ruby/core/process/uid/re_exchange_spec.rb
+++ b/spec/ruby/core/process/uid/re_exchange_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.re_exchange" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid/re_exchangeable_spec.rb b/spec/ruby/core/process/uid/re_exchangeable_spec.rb
index 8200d7ecb7..63f45fa662 100644
--- a/spec/ruby/core/process/uid/re_exchangeable_spec.rb
+++ b/spec/ruby/core/process/uid/re_exchangeable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.re_exchangeable?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid/rid_spec.rb b/spec/ruby/core/process/uid/rid_spec.rb
index e865cbfef6..cdfe08e3be 100644
--- a/spec/ruby/core/process/uid/rid_spec.rb
+++ b/spec/ruby/core/process/uid/rid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.rid" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid/sid_available_spec.rb b/spec/ruby/core/process/uid/sid_available_spec.rb
index be7912eb68..5d51366dd4 100644
--- a/spec/ruby/core/process/uid/sid_available_spec.rb
+++ b/spec/ruby/core/process/uid/sid_available_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.sid_available?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid/switch_spec.rb b/spec/ruby/core/process/uid/switch_spec.rb
index 4191b97db4..6747ee4f43 100644
--- a/spec/ruby/core/process/uid/switch_spec.rb
+++ b/spec/ruby/core/process/uid/switch_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Process::UID.switch" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/uid_spec.rb b/spec/ruby/core/process/uid_spec.rb
index a068b1a2c1..1b561f47e0 100644
--- a/spec/ruby/core/process/uid_spec.rb
+++ b/spec/ruby/core/process/uid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.uid" do
platform_is_not :windows do
@@ -18,40 +18,67 @@ describe "Process.uid" do
end
describe "Process.uid=" do
+
platform_is_not :windows do
it "raises TypeError if not passed an Integer" do
- -> { Process.uid = Object.new }.should raise_error(TypeError)
+ lambda { Process.uid = Object.new }.should raise_error(TypeError)
end
as_user do
it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id" do
- -> { (Process.uid = 0)}.should raise_error(Errno::EPERM)
+ lambda { (Process.uid = 0)}.should raise_error(Errno::EPERM)
end
it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id from username" do
- -> { Process.uid = "root" }.should raise_error(Errno::EPERM)
+ lambda { Process.uid = "root" }.should raise_error(Errno::EPERM)
end
end
as_superuser do
describe "if run by a superuser" do
- it "sets the real user id for the current process" do
- code = <<-RUBY
- Process.uid = 1
- puts Process.uid
- RUBY
- ruby_exe(code).should == "1\n"
- end
+ with_feature :fork do
+ it "sets the real user id for the current process" do
+ read, write = IO.pipe
+ pid = Process.fork do
+ begin
+ read.close
+ Process.uid = 1
+ write << Process.uid
+ write.close
+ rescue Exception => e
+ write << e << e.backtrace
+ end
+ Process.exit!
+ end
+ write.close
+ uid = read.gets
+ uid.should == "1"
+ Process.wait pid
+ end
- it "sets the real user id if preceded by Process.euid=id" do
- code = <<-RUBY
- Process.euid = 1
- Process.uid = 1
- puts Process.uid
- RUBY
- ruby_exe(code).should == "1\n"
+ it "sets the real user id if preceded by Process.euid=id" do
+ read, write = IO.pipe
+ pid = Process.fork do
+ begin
+ read.close
+ Process.euid = 1
+ Process.uid = 1
+ write << Process.uid
+ write.close
+ rescue Exception => e
+ write << e << e.backtrace
+ end
+ Process.exit!
+ end
+ write.close
+ uid = read.gets
+ uid.should == "1"
+ Process.wait pid
+ end
end
end
end
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/process/wait2_spec.rb b/spec/ruby/core/process/wait2_spec.rb
index 6eb7fc6d06..d1f3a47b7f 100644
--- a/spec/ruby/core/process/wait2_spec.rb
+++ b/spec/ruby/core/process/wait2_spec.rb
@@ -1,18 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.wait2" do
before :all do
# HACK: this kludge is temporarily necessary because some
# misbehaving spec somewhere else does not clear processes
- # Note: background processes are unavoidable with MJIT,
- # but we shouldn't reap them from Ruby-space
begin
Process.wait(-1, Process::WNOHANG)
$stderr.puts "Leaked process before wait2 specs! Waiting for it"
leaked = Process.waitall
- $stderr.puts "leaked before wait2 specs: #{leaked}" unless leaked.empty?
- # Ruby-space should not see PIDs used by mjit
- leaked.should be_empty
+ $stderr.puts "leaked before wait2 specs: #{leaked}"
rescue Errno::ECHILD # No child processes
rescue NotImplementedError
end
@@ -30,7 +26,7 @@ describe "Process.wait2" do
end
it "raises a StandardError if no child processes exist" do
- -> { Process.wait2 }.should raise_error(Errno::ECHILD)
- -> { Process.wait2 }.should raise_error(StandardError)
+ lambda { Process.wait2 }.should raise_error(Errno::ECHILD)
+ lambda { Process.wait2 }.should raise_error(StandardError)
end
end
diff --git a/spec/ruby/core/process/wait_spec.rb b/spec/ruby/core/process/wait_spec.rb
index f393a99e0f..8111621695 100644
--- a/spec/ruby/core/process/wait_spec.rb
+++ b/spec/ruby/core/process/wait_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "Process.wait" do
ProcessSpecs.use_system_ruby(self)
@@ -8,18 +8,16 @@ describe "Process.wait" do
begin
leaked = Process.waitall
puts "leaked before wait specs: #{leaked}" unless leaked.empty?
- # Ruby-space should not see PIDs used by mjit
- leaked.should be_empty
rescue NotImplementedError
end
end
it "raises an Errno::ECHILD if there are no child processes" do
- -> { Process.wait }.should raise_error(Errno::ECHILD)
+ lambda { Process.wait }.should raise_error(Errno::ECHILD)
end
platform_is_not :windows do
- it "returns its child pid" do
+ it "returns its childs pid" do
pid = Process.spawn(ruby_cmd('exit'))
Process.wait.should == pid
end
@@ -34,7 +32,7 @@ describe "Process.wait" do
it "waits for any child process if no pid is given" do
pid = Process.spawn(ruby_cmd('exit'))
Process.wait.should == pid
- -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
+ lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
end
it "waits for a specific child if a pid is given" do
@@ -42,14 +40,14 @@ describe "Process.wait" do
pid2 = Process.spawn(ruby_cmd('exit'))
Process.wait(pid2).should == pid2
Process.wait(pid1).should == pid1
- -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH)
- -> { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH)
+ lambda { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH)
+ lambda { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH)
end
it "coerces the pid to an Integer" do
pid1 = Process.spawn(ruby_cmd('exit'))
Process.wait(mock_int(pid1)).should == pid1
- -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH)
+ lambda { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH)
end
# This spec is probably system-dependent.
@@ -86,7 +84,7 @@ describe "Process.wait" do
it "always accepts flags=0" do
pid = Process.spawn(ruby_cmd('exit'))
Process.wait(-1, 0).should == pid
- -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
+ lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
end
end
end
diff --git a/spec/ruby/core/process/waitall_spec.rb b/spec/ruby/core/process/waitall_spec.rb
index 6cf4e32bc9..e1fc38d2bc 100644
--- a/spec/ruby/core/process/waitall_spec.rb
+++ b/spec/ruby/core/process/waitall_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.waitall" do
before :all do
@@ -13,7 +13,7 @@ describe "Process.waitall" do
end
it "takes no arguments" do
- -> { Process.waitall(0) }.should raise_error(ArgumentError)
+ lambda { Process.waitall(0) }.should raise_error(ArgumentError)
end
platform_is_not :windows do
@@ -24,7 +24,7 @@ describe "Process.waitall" do
pids << Process.fork { Process.exit! 0 }
Process.waitall
pids.each { |pid|
- -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
+ lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
}
end
diff --git a/spec/ruby/core/process/waitpid2_spec.rb b/spec/ruby/core/process/waitpid2_spec.rb
index 45513af667..303c59fda3 100644
--- a/spec/ruby/core/process/waitpid2_spec.rb
+++ b/spec/ruby/core/process/waitpid2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.waitpid2" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/process/waitpid_spec.rb b/spec/ruby/core/process/waitpid_spec.rb
index f7cf1a45a8..c95e8d59dd 100644
--- a/spec/ruby/core/process/waitpid_spec.rb
+++ b/spec/ruby/core/process/waitpid_spec.rb
@@ -1,6 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Process.waitpid" do
+ it "needs to be reviewed for spec completeness"
+
it "returns nil when the process has not yet completed and WNOHANG is specified" do
pid = spawn("sleep 5")
begin
diff --git a/spec/ruby/core/queue/append_spec.rb b/spec/ruby/core/queue/append_spec.rb
deleted file mode 100644
index 34165a7506..0000000000
--- a/spec/ruby/core/queue/append_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/enque'
-
-describe "Queue#<<" do
- it_behaves_like :queue_enq, :<<, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/clear_spec.rb b/spec/ruby/core/queue/clear_spec.rb
deleted file mode 100644
index 3245e4cb83..0000000000
--- a/spec/ruby/core/queue/clear_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/clear'
-
-describe "Queue#clear" do
- it_behaves_like :queue_clear, :clear, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/close_spec.rb b/spec/ruby/core/queue/close_spec.rb
deleted file mode 100644
index c0d774cd74..0000000000
--- a/spec/ruby/core/queue/close_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/close'
-
-describe "Queue#close" do
- it_behaves_like :queue_close, :close, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/closed_spec.rb b/spec/ruby/core/queue/closed_spec.rb
deleted file mode 100644
index 10d552996d..0000000000
--- a/spec/ruby/core/queue/closed_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/closed'
-
-describe "Queue#closed?" do
- it_behaves_like :queue_closed?, :closed?, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/deq_spec.rb b/spec/ruby/core/queue/deq_spec.rb
deleted file mode 100644
index 9510978eac..0000000000
--- a/spec/ruby/core/queue/deq_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/deque'
-
-describe "Queue#deq" do
- it_behaves_like :queue_deq, :deq, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/empty_spec.rb b/spec/ruby/core/queue/empty_spec.rb
deleted file mode 100644
index 55ca777466..0000000000
--- a/spec/ruby/core/queue/empty_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/empty'
-
-describe "Queue#empty?" do
- it_behaves_like :queue_empty?, :empty?, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/enq_spec.rb b/spec/ruby/core/queue/enq_spec.rb
deleted file mode 100644
index c69c496fbc..0000000000
--- a/spec/ruby/core/queue/enq_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/enque'
-
-describe "Queue#enq" do
- it_behaves_like :queue_enq, :enq, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/length_spec.rb b/spec/ruby/core/queue/length_spec.rb
deleted file mode 100644
index 25399b2b76..0000000000
--- a/spec/ruby/core/queue/length_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/length'
-
-describe "Queue#length" do
- it_behaves_like :queue_length, :length, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/num_waiting_spec.rb b/spec/ruby/core/queue/num_waiting_spec.rb
deleted file mode 100644
index edc0c37a82..0000000000
--- a/spec/ruby/core/queue/num_waiting_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/num_waiting'
-
-describe "Queue#num_waiting" do
- it_behaves_like :queue_num_waiting, :num_waiting, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/pop_spec.rb b/spec/ruby/core/queue/pop_spec.rb
deleted file mode 100644
index 1ce9231685..0000000000
--- a/spec/ruby/core/queue/pop_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/deque'
-
-describe "Queue#pop" do
- it_behaves_like :queue_deq, :pop, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/push_spec.rb b/spec/ruby/core/queue/push_spec.rb
deleted file mode 100644
index e936f9d282..0000000000
--- a/spec/ruby/core/queue/push_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/enque'
-
-describe "Queue#push" do
- it_behaves_like :queue_enq, :push, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/shift_spec.rb b/spec/ruby/core/queue/shift_spec.rb
deleted file mode 100644
index f84058e1df..0000000000
--- a/spec/ruby/core/queue/shift_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/deque'
-
-describe "Queue#shift" do
- it_behaves_like :queue_deq, :shift, -> { Queue.new }
-end
diff --git a/spec/ruby/core/queue/size_spec.rb b/spec/ruby/core/queue/size_spec.rb
deleted file mode 100644
index f528dfe797..0000000000
--- a/spec/ruby/core/queue/size_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/length'
-
-describe "Queue#size" do
- it_behaves_like :queue_length, :size, -> { Queue.new }
-end
diff --git a/spec/ruby/core/random/bytes_spec.rb b/spec/ruby/core/random/bytes_spec.rb
index 2caf18fbd0..d954261329 100644
--- a/spec/ruby/core/random/bytes_spec.rb
+++ b/spec/ruby/core/random/bytes_spec.rb
@@ -1,9 +1,18 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/bytes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Random#bytes" do
- it_behaves_like :random_bytes, :bytes, Random.new
+ it "returns a String" do
+ Random.new.bytes(1).should be_an_instance_of(String)
+ end
+
+ it "returns a String of the length given as argument" do
+ Random.new.bytes(15).length.should == 15
+ end
+
+ it "returns an ASCII-8BIT String" do
+ Random.new.bytes(15).encoding.should == Encoding::ASCII_8BIT
+ end
it "returns the same output for a given seed" do
Random.new(33).bytes(2).should == Random.new(33).bytes(2)
@@ -23,10 +32,8 @@ describe "Random#bytes" do
rnd.bytes(1000) # skip some
rnd.bytes(2).should == "\x17\x12"
end
-end
-ruby_version_is "2.6" do
- describe "Random.bytes" do
- it_behaves_like :random_bytes, :bytes, Random
+ it "returns a random binary String" do
+ Random.new.bytes(12).should_not == Random.new.bytes(12)
end
end
diff --git a/spec/ruby/core/random/default_spec.rb b/spec/ruby/core/random/default_spec.rb
index 1d8b1ce5ee..51a76c01ce 100644
--- a/spec/ruby/core/random/default_spec.rb
+++ b/spec/ruby/core/random/default_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Random::DEFAULT" do
it "returns a Random instance" do
diff --git a/spec/ruby/core/random/equal_value_spec.rb b/spec/ruby/core/random/equal_value_spec.rb
index 5f470d6a4c..738f549f1d 100644
--- a/spec/ruby/core/random/equal_value_spec.rb
+++ b/spec/ruby/core/random/equal_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Random#==" do
it "returns true if the two objects have the same state" do
diff --git a/spec/ruby/core/random/fixtures/classes.rb b/spec/ruby/core/random/fixtures/classes.rb
deleted file mode 100644
index 9c8d113e24..0000000000
--- a/spec/ruby/core/random/fixtures/classes.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module RandomSpecs
- CustomRangeInteger = Struct.new(:value) do
- def to_int; value; end
- def <=>(other); to_int <=> other.to_int; end
- def -(other); self.class.new(to_int - other.to_int); end
- def +(other); self.class.new(to_int + other.to_int); end
- end
-
- CustomRangeFloat = Struct.new(:value) do
- def to_f; value; end
- def <=>(other); to_f <=> other.to_f; end
- def -(other); to_f - other.to_f; end
- def +(other); self.class.new(to_f + other.to_f); end
- end
-end
diff --git a/spec/ruby/core/random/new_seed_spec.rb b/spec/ruby/core/random/new_seed_spec.rb
index 4b34e871a2..a8efaee2b1 100644
--- a/spec/ruby/core/random/new_seed_spec.rb
+++ b/spec/ruby/core/random/new_seed_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Random.new_seed" do
it "returns a Bignum" do
diff --git a/spec/ruby/core/random/new_spec.rb b/spec/ruby/core/random/new_spec.rb
index 07d7b439ca..8160f44d79 100644
--- a/spec/ruby/core/random/new_spec.rb
+++ b/spec/ruby/core/random/new_spec.rb
@@ -30,7 +30,7 @@ describe "Random.new" do
end
it "raises a RangeError if passed a Complex (with imaginary part) seed value as an argument" do
- -> do
+ lambda do
Random.new(Complex(20,2))
end.should raise_error(RangeError)
end
diff --git a/spec/ruby/core/random/rand_spec.rb b/spec/ruby/core/random/rand_spec.rb
index 0e423301f8..e0cb133abd 100644
--- a/spec/ruby/core/random/rand_spec.rb
+++ b/spec/ruby/core/random/rand_spec.rb
@@ -1,10 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/rand'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Random.rand" do
- it_behaves_like :random_number, :rand, Random.new
- it_behaves_like :random_number, :rand, Random
+ it "returns a Float if no max argument is passed" do
+ Random.rand.should be_kind_of(Float)
+ end
it "returns a Float >= 0 if no max argument is passed" do
floats = 200.times.map { Random.rand }
@@ -24,6 +23,10 @@ describe "Random.rand" do
floats_a.should == floats_b
end
+ it "returns an Integer if an Integer argument is passed" do
+ Random.rand(20).should be_kind_of(Integer)
+ end
+
it "returns an Integer >= 0 if an Integer argument is passed" do
ints = 200.times.map { Random.rand(34) }
ints.min.should >= 0
@@ -80,13 +83,13 @@ describe "Random#rand with Fixnum" do
end
it "raises an ArgumentError when the argument is 0" do
- -> do
+ lambda do
Random.new.rand(0)
end.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the argument is negative" do
- -> do
+ lambda do
Random.new.rand(-12)
end.should raise_error(ArgumentError)
end
@@ -119,7 +122,7 @@ describe "Random#rand with Bignum" do
end
it "raises an ArgumentError when the argument is negative" do
- -> do
+ lambda do
Random.new.rand(-bignum_value)
end.should raise_error(ArgumentError)
end
@@ -151,7 +154,7 @@ describe "Random#rand with Float" do
end
it "raises an ArgumentError when the argument is negative" do
- -> do
+ lambda do
Random.new.rand(-1.234567)
end.should raise_error(ArgumentError)
end
@@ -162,12 +165,6 @@ describe "Random#rand with Range" do
Random.new.rand(20..43).should be_an_instance_of(Fixnum)
end
- it "supports custom object types" do
- rand(RandomSpecs::CustomRangeInteger.new(1)..RandomSpecs::CustomRangeInteger.new(42)).should be_an_instance_of(RandomSpecs::CustomRangeInteger)
- rand(RandomSpecs::CustomRangeFloat.new(1.0)..RandomSpecs::CustomRangeFloat.new(42.0)).should be_an_instance_of(RandomSpecs::CustomRangeFloat)
- rand(Time.now..Time.now).should be_an_instance_of(Time)
- end
-
it "returns an object that is a member of the Range" do
prng = Random.new
r = 20..30
@@ -206,13 +203,13 @@ describe "Random#rand with Range" do
end
it "raises an ArgumentError when the startpoint lacks #+ and #- methods" do
- -> do
+ lambda do
Random.new.rand(Object.new..67)
end.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the endpoint lacks #+ and #- methods" do
- -> do
+ lambda do
Random.new.rand(68..Object.new)
end.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/random/random_number_spec.rb b/spec/ruby/core/random/random_number_spec.rb
deleted file mode 100644
index 60a80ae1b9..0000000000
--- a/spec/ruby/core/random/random_number_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rand'
-
-describe "Random.random_number" do
- it_behaves_like :random_number, :random_number, Random.new
-
- ruby_version_is "2.6" do
- it_behaves_like :random_number, :random_number, Random
- end
-end
diff --git a/spec/ruby/core/random/raw_seed_spec.rb b/spec/ruby/core/random/raw_seed_spec.rb
index c1a1eb1f42..881cceada9 100644
--- a/spec/ruby/core/random/raw_seed_spec.rb
+++ b/spec/ruby/core/random/raw_seed_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/urandom'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/urandom', __FILE__)
ruby_version_is "2.5" do
describe "Random.urandom" do
diff --git a/spec/ruby/core/random/seed_spec.rb b/spec/ruby/core/random/seed_spec.rb
index bf4524fdd9..5acb068efe 100644
--- a/spec/ruby/core/random/seed_spec.rb
+++ b/spec/ruby/core/random/seed_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Random#seed" do
it "returns an Integer" do
diff --git a/spec/ruby/core/random/shared/bytes.rb b/spec/ruby/core/random/shared/bytes.rb
deleted file mode 100644
index 9afad3b7f8..0000000000
--- a/spec/ruby/core/random/shared/bytes.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-describe :random_bytes, shared: true do
- it "returns a String" do
- @object.send(@method, 1).should be_an_instance_of(String)
- end
-
- it "returns a String of the length given as argument" do
- @object.send(@method, 15).length.should == 15
- end
-
- it "returns a binary String" do
- @object.send(@method, 15).encoding.should == Encoding::BINARY
- end
-
- it "returns a random binary String" do
- @object.send(@method, 12).should_not == @object.send(@method, 12)
- end
-end
diff --git a/spec/ruby/core/random/shared/rand.rb b/spec/ruby/core/random/shared/rand.rb
deleted file mode 100644
index d3b24b8851..0000000000
--- a/spec/ruby/core/random/shared/rand.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-describe :random_number, shared: true do
- it "returns a Float if no max argument is passed" do
- @object.send(@method).should be_kind_of(Float)
- end
-
- it "returns an Integer if an Integer argument is passed" do
- @object.send(@method, 20).should be_kind_of(Integer)
- end
-end
diff --git a/spec/ruby/core/random/shared/urandom.rb b/spec/ruby/core/random/shared/urandom.rb
index 159716075c..f50d30c9de 100644
--- a/spec/ruby/core/random/shared/urandom.rb
+++ b/spec/ruby/core/random/shared/urandom.rb
@@ -8,13 +8,13 @@ describe :random_urandom, shared: true do
end
it "raises an ArgumentError on a negative size" do
- -> {
+ lambda {
Random.send(@method, -1)
}.should raise_error(ArgumentError)
end
- it "returns a binary String" do
- Random.send(@method, 15).encoding.should == Encoding::BINARY
+ it "returns an ASCII-8BIT String" do
+ Random.send(@method, 15).encoding.should == Encoding::ASCII_8BIT
end
it "returns a random binary String" do
diff --git a/spec/ruby/core/random/srand_spec.rb b/spec/ruby/core/random/srand_spec.rb
index 1ef8e32cfb..8ce863f5a9 100644
--- a/spec/ruby/core/random/srand_spec.rb
+++ b/spec/ruby/core/random/srand_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Random.srand" do
it "returns an arbitrary seed if .srand wasn't called previously with an argument and no argument is supplied this time" do
diff --git a/spec/ruby/core/random/urandom_spec.rb b/spec/ruby/core/random/urandom_spec.rb
index e27f83cdcd..1cc0103e35 100644
--- a/spec/ruby/core/random/urandom_spec.rb
+++ b/spec/ruby/core/random/urandom_spec.rb
@@ -1,8 +1,8 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/urandom'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/urandom', __FILE__)
-ruby_version_is ""..."2.5" do
+ruby_version_is "2.3"..."2.5" do
describe "Random.raw_seed" do
it_behaves_like :random_urandom, :raw_seed
end
diff --git a/spec/ruby/core/range/begin_spec.rb b/spec/ruby/core/range/begin_spec.rb
index ab82b45b7e..090ae0a24b 100644
--- a/spec/ruby/core/range/begin_spec.rb
+++ b/spec/ruby/core/range/begin_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/begin'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/begin', __FILE__)
describe "Range#begin" do
- it_behaves_like :range_begin, :begin
+ it_behaves_like(:range_begin, :begin)
end
diff --git a/spec/ruby/core/range/bsearch_spec.rb b/spec/ruby/core/range/bsearch_spec.rb
index 009cafb00e..a10dcea61e 100644
--- a/spec/ruby/core/range/bsearch_spec.rb
+++ b/spec/ruby/core/range/bsearch_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Range#bsearch" do
it "returns an Enumerator when not passed a block" do
@@ -9,22 +9,22 @@ describe "Range#bsearch" do
it_behaves_like :enumeratorized_with_unknown_size, :bsearch, (1..3)
it "raises a TypeError if the block returns an Object" do
- -> { (0..1).bsearch { Object.new } }.should raise_error(TypeError)
+ lambda { (0..1).bsearch { Object.new } }.should raise_error(TypeError)
end
it "raises a TypeError if the block returns a String" do
- -> { (0..1).bsearch { "1" } }.should raise_error(TypeError)
+ lambda { (0..1).bsearch { "1" } }.should raise_error(TypeError)
end
it "raises a TypeError if the Range has Object values" do
value = mock("range bsearch")
r = Range.new value, value
- -> { r.bsearch { true } }.should raise_error(TypeError)
+ lambda { r.bsearch { true } }.should raise_error(TypeError)
end
it "raises a TypeError if the Range has String values" do
- -> { ("a".."e").bsearch { true } }.should raise_error(TypeError)
+ lambda { ("a".."e").bsearch { true } }.should raise_error(TypeError)
end
context "with Integer values" do
diff --git a/spec/ruby/core/range/case_compare_spec.rb b/spec/ruby/core/range/case_compare_spec.rb
index 0ca03f6a35..cada3b7cd5 100644
--- a/spec/ruby/core/range/case_compare_spec.rb
+++ b/spec/ruby/core/range/case_compare_spec.rb
@@ -1,28 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/cover_and_include'
-require_relative 'shared/cover'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/cover_and_include', __FILE__)
+require File.expand_path('../shared/cover', __FILE__)
describe "Range#===" do
- ruby_version_is ""..."2.6" do
- it "returns the result of calling #include? on self" do
- range = 0...10
- range.should_receive(:include?).with(2).and_return(:true)
- (range === 2).should == :true
- end
-
- it "requires #succ method to be implemented" do
- range = RangeSpecs::WithoutSucc.new(0)..RangeSpecs::WithoutSucc.new(10)
-
- -> do
- range === RangeSpecs::WithoutSucc.new(2)
- end.should raise_error(TypeError, /can't iterate from/)
- end
- end
-
- ruby_version_is "2.6" do
- it "returns the result of calling #cover? on self" do
- range = RangeSpecs::WithoutSucc.new(0)..RangeSpecs::WithoutSucc.new(10)
- (range === RangeSpecs::WithoutSucc.new(2)).should == true
- end
+ it "returns the result of calling #include? on self" do
+ range = 0...10
+ range.should_receive(:include?).with(2).and_return(:true)
+ (range === 2).should == :true
end
end
diff --git a/spec/ruby/core/range/cover_spec.rb b/spec/ruby/core/range/cover_spec.rb
index 29c0e0bfa8..9c8b914d6d 100644
--- a/spec/ruby/core/range/cover_spec.rb
+++ b/spec/ruby/core/range/cover_spec.rb
@@ -1,7 +1,7 @@
-# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/cover_and_include'
-require_relative 'shared/cover'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/cover_and_include', __FILE__)
+require File.expand_path('../shared/cover', __FILE__)
describe "Range#cover?" do
it_behaves_like :range_cover_and_include, :cover?
diff --git a/spec/ruby/core/range/dup_spec.rb b/spec/ruby/core/range/dup_spec.rb
index d1c029c6b7..cdb792c97f 100644
--- a/spec/ruby/core/range/dup_spec.rb
+++ b/spec/ruby/core/range/dup_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#dup" do
it "duplicates the range" do
diff --git a/spec/ruby/core/range/each_spec.rb b/spec/ruby/core/range/each_spec.rb
index 110b0602d0..4520f3cde6 100644
--- a/spec/ruby/core/range/each_spec.rb
+++ b/spec/ruby/core/range/each_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Range#each" do
it "passes each element to the given block by using #succ" do
@@ -33,12 +33,12 @@ describe "Range#each" do
end
it "raises a TypeError if the first element does not respond to #succ" do
- -> { (0.5..2.4).each { |i| i } }.should raise_error(TypeError)
+ lambda { (0.5..2.4).each { |i| i } }.should raise_error(TypeError)
b = mock('x')
(a = mock('1')).should_receive(:<=>).with(b).and_return(1)
- -> { (a..b).each { |i| i } }.should raise_error(TypeError)
+ lambda { (a..b).each { |i| i } }.should raise_error(TypeError)
end
it "returns self" do
@@ -54,7 +54,7 @@ describe "Range#each" do
it "raises a TypeError if the first element is a Time object" do
t = Time.now
- -> { (t..t+1).each { |i| i } }.should raise_error(TypeError)
+ lambda { (t..t+1).each { |i| i } }.should raise_error(TypeError)
end
it "passes each Symbol element by using #succ" do
diff --git a/spec/ruby/core/range/end_spec.rb b/spec/ruby/core/range/end_spec.rb
index 9e5e6f7d43..128f44c309 100644
--- a/spec/ruby/core/range/end_spec.rb
+++ b/spec/ruby/core/range/end_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/end'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/end', __FILE__)
describe "Range#end" do
- it_behaves_like :range_end, :end
+ it_behaves_like(:range_end, :end)
end
diff --git a/spec/ruby/core/range/eql_spec.rb b/spec/ruby/core/range/eql_spec.rb
index fa6c71840e..2d495ee175 100644
--- a/spec/ruby/core/range/eql_spec.rb
+++ b/spec/ruby/core/range/eql_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Range#eql?" do
- it_behaves_like :range_eql, :eql?
+ it_behaves_like(:range_eql, :eql?)
it "returns false if the endpoints are not eql?" do
- (0..1).should_not eql(0..1.0)
+ (0..1).send(@method, 0..1.0).should == false
end
end
diff --git a/spec/ruby/core/range/equal_value_spec.rb b/spec/ruby/core/range/equal_value_spec.rb
index 889557fc2a..488fe73c55 100644
--- a/spec/ruby/core/range/equal_value_spec.rb
+++ b/spec/ruby/core/range/equal_value_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Range#==" do
- it_behaves_like :range_eql, :==
+ it_behaves_like(:range_eql, :==)
it "returns true if the endpoints are ==" do
- (0..1).should == (0..1.0)
+ (0..1).send(@method, 0..1.0).should == true
end
end
diff --git a/spec/ruby/core/range/exclude_end_spec.rb b/spec/ruby/core/range/exclude_end_spec.rb
index a209603d18..5bbdaa25a7 100644
--- a/spec/ruby/core/range/exclude_end_spec.rb
+++ b/spec/ruby/core/range/exclude_end_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#exclude_end?" do
it "returns false if the range does not exclude the end value" do
diff --git a/spec/ruby/core/range/first_spec.rb b/spec/ruby/core/range/first_spec.rb
index 5f073b48ee..7cd3781d34 100644
--- a/spec/ruby/core/range/first_spec.rb
+++ b/spec/ruby/core/range/first_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/begin'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/begin', __FILE__)
describe "Range#first" do
- it_behaves_like :range_begin, :first
+ it_behaves_like(:range_begin, :first)
it "returns the specified number of elements from the beginning" do
(0..2).first(2).should == [0, 1]
@@ -21,7 +21,7 @@ describe "Range#first" do
end
it "raises an ArgumentError when count is negative" do
- -> { (0..2).first(-1) }.should raise_error(ArgumentError)
+ lambda { (0..2).first(-1) }.should raise_error(ArgumentError)
end
it "calls #to_int to convert the argument" do
@@ -32,7 +32,7 @@ describe "Range#first" do
it "raises a TypeError if #to_int does not return an Integer" do
obj = mock("to_int")
obj.should_receive(:to_int).and_return("1")
- -> { (2..3).first(obj) }.should raise_error(TypeError)
+ lambda { (2..3).first(obj) }.should raise_error(TypeError)
end
it "truncates the value when passed a Float" do
@@ -40,10 +40,10 @@ describe "Range#first" do
end
it "raises a TypeError when passed nil" do
- -> { (2..3).first(nil) }.should raise_error(TypeError)
+ lambda { (2..3).first(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- -> { (2..3).first("1") }.should raise_error(TypeError)
+ lambda { (2..3).first("1") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/range/fixtures/classes.rb b/spec/ruby/core/range/fixtures/classes.rb
index 3a1df010b2..de46d7d4a9 100644
--- a/spec/ruby/core/range/fixtures/classes.rb
+++ b/spec/ruby/core/range/fixtures/classes.rb
@@ -40,28 +40,6 @@ module RangeSpecs
end
end
- class WithoutSucc
- include Comparable
- attr_reader :n
-
- def initialize(n)
- @n = n
- end
-
- def eql?(other)
- inspect.eql? other.inspect
- end
- alias :== :eql?
-
- def inspect
- "WithoutSucc(#{@n})"
- end
-
- def <=>(other)
- @n <=> other.n
- end
- end
-
class Xs < Custom # represent a string of 'x's
def succ
Xs.new(@length + 1)
@@ -84,7 +62,4 @@ module RangeSpecs
class MyRange < Range
end
-
- class ComparisonError < RuntimeError
- end
end
diff --git a/spec/ruby/core/range/hash_spec.rb b/spec/ruby/core/range/hash_spec.rb
index 90aeee7890..dcac523487 100644
--- a/spec/ruby/core/range/hash_spec.rb
+++ b/spec/ruby/core/range/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#hash" do
it "is provided" do
diff --git a/spec/ruby/core/range/include_spec.rb b/spec/ruby/core/range/include_spec.rb
index b2c7a54545..2d7450f8ae 100644
--- a/spec/ruby/core/range/include_spec.rb
+++ b/spec/ruby/core/range/include_spec.rb
@@ -1,8 +1,8 @@
-# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/cover_and_include'
-require_relative 'shared/include'
-require_relative 'shared/cover'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/cover_and_include', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
+require File.expand_path('../shared/cover', __FILE__)
describe "Range#include?" do
it_behaves_like :range_cover_and_include, :include?
diff --git a/spec/ruby/core/range/initialize_spec.rb b/spec/ruby/core/range/initialize_spec.rb
index 8caf12baa2..457f048f8a 100644
--- a/spec/ruby/core/range/initialize_spec.rb
+++ b/spec/ruby/core/range/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#initialize" do
before do
@@ -10,32 +10,32 @@ describe "Range#initialize" do
end
it "initializes correctly the Range object when given 2 arguments" do
- -> { @range.send(:initialize, 0, 1) }.should_not raise_error
+ lambda { @range.send(:initialize, 0, 1) }.should_not raise_error
end
it "initializes correctly the Range object when given 3 arguments" do
- -> { @range.send(:initialize, 0, 1, true) }.should_not raise_error
+ lambda { @range.send(:initialize, 0, 1, true) }.should_not raise_error
end
it "raises an ArgumentError if passed without or with only one argument" do
- -> { @range.send(:initialize) }.should raise_error(ArgumentError)
- -> { @range.send(:initialize, 1) }.should raise_error(ArgumentError)
+ lambda { @range.send(:initialize) }.should raise_error(ArgumentError)
+ lambda { @range.send(:initialize, 1) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if passed with four or more arguments" do
- -> { @range.send(:initialize, 1, 3, 5, 7) }.should raise_error(ArgumentError)
- -> { @range.send(:initialize, 1, 3, 5, 7, 9) }.should raise_error(ArgumentError)
+ lambda { @range.send(:initialize, 1, 3, 5, 7) }.should raise_error(ArgumentError)
+ lambda { @range.send(:initialize, 1, 3, 5, 7, 9) }.should raise_error(ArgumentError)
end
it "raises a NameError if called on an already initialized Range" do
- -> { (0..1).send(:initialize, 1, 3) }.should raise_error(NameError)
- -> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(NameError)
+ lambda { (0..1).send(:initialize, 1, 3) }.should raise_error(NameError)
+ lambda { (0..1).send(:initialize, 1, 3, true) }.should raise_error(NameError)
end
it "raises an ArgumentError if arguments don't respond to <=>" do
o1 = Object.new
o2 = Object.new
- -> { @range.send(:initialize, o1, o2) }.should raise_error(ArgumentError)
+ lambda { @range.send(:initialize, o1, o2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/range/inspect_spec.rb b/spec/ruby/core/range/inspect_spec.rb
index 837f7e69ab..8f5de933d3 100644
--- a/spec/ruby/core/range/inspect_spec.rb
+++ b/spec/ruby/core/range/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#inspect" do
it "provides a printable form, using #inspect to convert the start and end objects" do
@@ -12,17 +12,15 @@ describe "Range#inspect" do
(0.5..2.4).inspect.should == "0.5..2.4"
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted string if either end is tainted" do
- (("a".taint)..."c").inspect.tainted?.should be_true
- ("a"...("c".taint)).inspect.tainted?.should be_true
- ("a"..."c").taint.inspect.tainted?.should be_true
- end
+ it "returns a tainted string if either end is tainted" do
+ (("a".taint)..."c").inspect.tainted?.should be_true
+ ("a"...("c".taint)).inspect.tainted?.should be_true
+ ("a"..."c").taint.inspect.tainted?.should be_true
+ end
- it "returns a untrusted string if either end is untrusted" do
- (("a".untrust)..."c").inspect.untrusted?.should be_true
- ("a"...("c".untrust)).inspect.untrusted?.should be_true
- ("a"..."c").untrust.inspect.untrusted?.should be_true
- end
+ it "returns a untrusted string if either end is untrusted" do
+ (("a".untrust)..."c").inspect.untrusted?.should be_true
+ ("a"...("c".untrust)).inspect.untrusted?.should be_true
+ ("a"..."c").untrust.inspect.untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/range/last_spec.rb b/spec/ruby/core/range/last_spec.rb
index c7e629e62c..581e04f785 100644
--- a/spec/ruby/core/range/last_spec.rb
+++ b/spec/ruby/core/range/last_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/end'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/end', __FILE__)
describe "Range#last" do
- it_behaves_like :range_end, :last
+ it_behaves_like(:range_end, :last)
it "returns the specified number of elements from the end" do
(1..5).last(3).should == [3, 4, 5]
@@ -21,7 +21,7 @@ describe "Range#last" do
end
it "raises an ArgumentError when count is negative" do
- -> { (0..2).last(-1) }.should raise_error(ArgumentError)
+ lambda { (0..2).last(-1) }.should raise_error(ArgumentError)
end
it "calls #to_int to convert the argument" do
@@ -32,7 +32,7 @@ describe "Range#last" do
it "raises a TypeError if #to_int does not return an Integer" do
obj = mock("to_int")
obj.should_receive(:to_int).and_return("1")
- -> { (2..3).last(obj) }.should raise_error(TypeError)
+ lambda { (2..3).last(obj) }.should raise_error(TypeError)
end
it "truncates the value when passed a Float" do
@@ -40,10 +40,10 @@ describe "Range#last" do
end
it "raises a TypeError when passed nil" do
- -> { (2..3).last(nil) }.should raise_error(TypeError)
+ lambda { (2..3).last(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- -> { (2..3).last("1") }.should raise_error(TypeError)
+ lambda { (2..3).last("1") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/range/max_spec.rb b/spec/ruby/core/range/max_spec.rb
index faac0a2032..66e40bce1a 100644
--- a/spec/ruby/core/range/max_spec.rb
+++ b/spec/ruby/core/range/max_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#max" do
it "returns the maximum value in the range when called with no arguments" do
@@ -14,7 +14,7 @@ describe "Range#max" do
end
it "raises TypeError when called on an exclusive range and a non Integer value" do
- -> { (303.20...908.1111).max }.should raise_error(TypeError)
+ lambda { (303.20...908.1111).max }.should raise_error(TypeError)
end
it "returns nil when the endpoint is less than the start point" do
@@ -43,7 +43,7 @@ describe "Range#max" do
it "raises TypeError when called on a Time...Time(excluded end point)" do
time_start = Time.now
time_end = Time.now + 1.0
- -> { (time_start...time_end).max }.should raise_error(TypeError)
+ lambda { (time_start...time_end).max }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/range/member_spec.rb b/spec/ruby/core/range/member_spec.rb
index ab61f92951..afcca9bf19 100644
--- a/spec/ruby/core/range/member_spec.rb
+++ b/spec/ruby/core/range/member_spec.rb
@@ -1,8 +1,8 @@
-# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/cover_and_include'
-require_relative 'shared/include'
-require_relative 'shared/cover'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/cover_and_include', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
+require File.expand_path('../shared/cover', __FILE__)
describe "Range#member?" do
it_behaves_like :range_cover_and_include, :member?
diff --git a/spec/ruby/core/range/min_spec.rb b/spec/ruby/core/range/min_spec.rb
index 424bd1dc87..b6eebd8c35 100644
--- a/spec/ruby/core/range/min_spec.rb
+++ b/spec/ruby/core/range/min_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#min" do
it "returns the minimum value in the range when called with no arguments" do
diff --git a/spec/ruby/core/range/new_spec.rb b/spec/ruby/core/range/new_spec.rb
index 9ed2b65d5a..f0d24e4aeb 100644
--- a/spec/ruby/core/range/new_spec.rb
+++ b/spec/ruby/core/range/new_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range.new" do
it "constructs a range using the given start and end" do
@@ -25,63 +24,11 @@ describe "Range.new" do
end
it "raises an ArgumentError when the given start and end can't be compared by using #<=>" do
- -> { Range.new(1, mock('x')) }.should raise_error(ArgumentError)
- -> { Range.new(mock('x'), mock('y')) }.should raise_error(ArgumentError)
+ lambda { Range.new(1, mock('x')) }.should raise_error(ArgumentError)
+ lambda { Range.new(mock('x'), mock('y')) }.should raise_error(ArgumentError)
b = mock('x')
(a = mock('nil')).should_receive(:<=>).with(b).and_return(nil)
- -> { Range.new(a, b) }.should raise_error(ArgumentError)
- end
-
- ruby_version_is "2.5" do
- it "does not rescue exception raised in #<=> when compares the given start and end" do
- b = mock('a')
- a = mock('b')
- a.should_receive(:<=>).with(b).and_raise(RangeSpecs::ComparisonError)
-
- -> { Range.new(a, b) }.should raise_error(RangeSpecs::ComparisonError)
- end
- end
-
- describe "beginless/endless range" do
- ruby_version_is ""..."2.7" do
- it "does not allow range without left boundary" do
- -> { Range.new(nil, 1) }.should raise_error(ArgumentError, /bad value for range/)
- end
- end
-
- ruby_version_is "2.7" do
- it "allows beginless left boundary" do
- range = Range.new(nil, 1)
- range.begin.should == nil
- end
-
- it "distinguishes ranges with included and excluded right boundary" do
- range_exclude = Range.new(nil, 1, true)
- range_include = Range.new(nil, 1, false)
-
- range_exclude.should_not == range_include
- end
- end
-
- ruby_version_is ""..."2.6" do
- it "does not allow range without right boundary" do
- -> { Range.new(1, nil) }.should raise_error(ArgumentError, /bad value for range/)
- end
- end
-
- ruby_version_is "2.6" do
- it "allows endless right boundary" do
- range = Range.new(1, nil)
- range.end.should == nil
- end
-
- it "distinguishes ranges with included and excluded right boundary" do
- range_exclude = Range.new(1, nil, true)
- range_include = Range.new(1, nil, false)
-
- range_exclude.should_not == range_include
- end
- end
+ lambda { Range.new(a, b) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/range/percent_spec.rb b/spec/ruby/core/range/percent_spec.rb
deleted file mode 100644
index 41badd4f72..0000000000
--- a/spec/ruby/core/range/percent_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.6" do
- describe "Range#%" do
- it "works as a Range#step" do
- aseq = (1..10) % 2
- aseq.class.should == Enumerator::ArithmeticSequence
- aseq.begin.should == 1
- aseq.end.should == 10
- aseq.step.should == 2
- aseq.to_a.should == [1, 3, 5, 7, 9]
- end
-
- it "produces an arithmetic sequence with a percent sign in #inspect" do
- ((1..10) % 2).inspect.should == "((1..10).%(2))"
- end
- end
-end
diff --git a/spec/ruby/core/range/range_spec.rb b/spec/ruby/core/range/range_spec.rb
index 8e9433f8c1..ca6da29e47 100644
--- a/spec/ruby/core/range/range_spec.rb
+++ b/spec/ruby/core/range/range_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range" do
it "includes Enumerable" do
diff --git a/spec/ruby/core/range/shared/cover.rb b/spec/ruby/core/range/shared/cover.rb
index 33d416fef5..1d9c008a87 100644
--- a/spec/ruby/core/range/shared/cover.rb
+++ b/spec/ruby/core/range/shared/cover.rb
@@ -1,6 +1,6 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :range_cover, shared: true do
it "uses the range element's <=> to make the comparison" do
@@ -90,64 +90,4 @@ describe :range_cover, shared: true do
end
end
end
-
- ruby_version_is "2.6" do
- context "range argument" do
- it "accepts range argument" do
- (0..10).send(@method, (3..7)).should be_true
- (0..10).send(@method, (3..15)).should be_false
- (0..10).send(@method, (-2..7)).should be_false
-
- (1.1..7.9).send(@method, (2.5..6.5)).should be_true
- (1.1..7.9).send(@method, (2.5..8.5)).should be_false
- (1.1..7.9).send(@method, (0.5..6.5)).should be_false
-
- ('c'..'i').send(@method, ('d'..'f')).should be_true
- ('c'..'i').send(@method, ('d'..'z')).should be_false
- ('c'..'i').send(@method, ('a'..'f')).should be_false
-
- range_10_100 = RangeSpecs::TenfoldSucc.new(10)..RangeSpecs::TenfoldSucc.new(100)
- range_20_90 = RangeSpecs::TenfoldSucc.new(20)..RangeSpecs::TenfoldSucc.new(90)
- range_20_110 = RangeSpecs::TenfoldSucc.new(20)..RangeSpecs::TenfoldSucc.new(110)
- range_0_90 = RangeSpecs::TenfoldSucc.new(0)..RangeSpecs::TenfoldSucc.new(90)
-
- range_10_100.send(@method, range_20_90).should be_true
- range_10_100.send(@method, range_20_110).should be_false
- range_10_100.send(@method, range_0_90).should be_false
- end
-
- it "supports boundaries of different comparable types" do
- (0..10).send(@method, (3.1..7.9)).should be_true
- (0..10).send(@method, (3.1..15.9)).should be_false
- (0..10).send(@method, (-2.1..7.9)).should be_false
- end
-
- it "returns false if types are not comparable" do
- (0..10).send(@method, ('a'..'z')).should be_false
- (0..10).send(@method, (RangeSpecs::TenfoldSucc.new(0)..RangeSpecs::TenfoldSucc.new(100))).should be_false
- end
-
- it "honors exclusion of right boundary (:exclude_end option)" do
- # Integer
- (0..10).send(@method, (0..10)).should be_true
- (0...10).send(@method, (0...10)).should be_true
-
- (0..10).send(@method, (0...10)).should be_true
- (0...10).send(@method, (0..10)).should be_false
-
- (0...11).send(@method, (0..10)).should be_true
- (0..10).send(@method, (0...11)).should be_true
-
- # Float
- (0..10.1).send(@method, (0..10.1)).should be_true
- (0...10.1).send(@method, (0...10.1)).should be_true
-
- (0..10.1).send(@method, (0...10.1)).should be_true
- (0...10.1).send(@method, (0..10.1)).should be_false
-
- (0...11.1).send(@method, (0..10.1)).should be_true
- (0..10.1).send(@method, (0...11.1)).should be_false
- end
- end
- end
end
diff --git a/spec/ruby/core/range/shared/cover_and_include.rb b/spec/ruby/core/range/shared/cover_and_include.rb
index a19e2c6ead..4222424571 100644
--- a/spec/ruby/core/range/shared/cover_and_include.rb
+++ b/spec/ruby/core/range/shared/cover_and_include.rb
@@ -1,5 +1,5 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :range_cover_and_include, shared: true do
it "returns true if other is an element of self" do
@@ -29,8 +29,8 @@ describe :range_cover_and_include, shared: true do
end
it "raises an ArgumentError without exactly one argument" do
- ->{ (1..2).send(@method) }.should raise_error(ArgumentError)
- ->{ (1..2).send(@method, 1, 2) }.should raise_error(ArgumentError)
+ lambda{ (1..2).send(@method) }.should raise_error(ArgumentError)
+ lambda{ (1..2).send(@method, 1, 2) }.should raise_error(ArgumentError)
end
it "returns true if argument is equal to the first value of the range" do
diff --git a/spec/ruby/core/range/shared/equal_value.rb b/spec/ruby/core/range/shared/equal_value.rb
index 9d8bb13351..0bdcf65c3f 100644
--- a/spec/ruby/core/range/shared/equal_value.rb
+++ b/spec/ruby/core/range/shared/equal_value.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :range_eql, shared: true do
it "returns true if other has same begin, end, and exclude_end? values" do
diff --git a/spec/ruby/core/range/shared/include.rb b/spec/ruby/core/range/shared/include.rb
index c6c5c2becf..44fd86f067 100644
--- a/spec/ruby/core/range/shared/include.rb
+++ b/spec/ruby/core/range/shared/include.rb
@@ -1,6 +1,6 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :range_include, shared: true do
describe "on string elements" do
diff --git a/spec/ruby/core/range/size_spec.rb b/spec/ruby/core/range/size_spec.rb
index 09759940dd..ecf0ecf606 100644
--- a/spec/ruby/core/range/size_spec.rb
+++ b/spec/ruby/core/range/size_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#size" do
it "returns the number of elements in the range" do
diff --git a/spec/ruby/core/range/step_spec.rb b/spec/ruby/core/range/step_spec.rb
index d564e4a5cd..b5bce66861 100644
--- a/spec/ruby/core/range/step_spec.rb
+++ b/spec/ruby/core/range/step_spec.rb
@@ -1,10 +1,16 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#step" do
before :each do
ScratchPad.record []
end
+ it "returns an enumerator when no block is given" do
+ enum = (1..10).step(4)
+ enum.should be_an_instance_of(Enumerator)
+ enum.to_a.should eql([1, 5, 9])
+ end
+
it "returns self" do
r = 1..2
r.step { }.should equal(r)
@@ -12,7 +18,7 @@ describe "Range#step" do
it "raises TypeError if step" do
obj = mock("mock")
- -> { (1..10).step(obj) { } }.should raise_error(TypeError)
+ lambda { (1..10).step(obj) { } }.should raise_error(TypeError)
end
it "calls #to_int to coerce step to an Integer" do
@@ -26,14 +32,14 @@ describe "Range#step" do
it "raises a TypeError if step does not respond to #to_int" do
obj = mock("Range#step non-integer")
- -> { (1..2).step(obj) { } }.should raise_error(TypeError)
+ lambda { (1..2).step(obj) { } }.should raise_error(TypeError)
end
it "raises a TypeError if #to_int does not return an Integer" do
obj = mock("Range#step non-integer")
obj.should_receive(:to_int).and_return("1")
- -> { (1..2).step(obj) { } }.should raise_error(TypeError)
+ lambda { (1..2).step(obj) { } }.should raise_error(TypeError)
end
it "coerces the argument to integer by invoking to_int" do
@@ -47,19 +53,19 @@ describe "Range#step" do
obj = mock("Range#step non-comparable")
obj.should_receive(:<=>).with(obj).and_return(1)
- -> { (obj..obj).step { |x| x } }.should raise_error(TypeError)
+ lambda { (obj..obj).step { |x| x } }.should raise_error(TypeError)
end
it "raises an ArgumentError if step is 0" do
- -> { (-1..1).step(0) { |x| x } }.should raise_error(ArgumentError)
+ lambda { (-1..1).step(0) { |x| x } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if step is 0.0" do
- -> { (-1..1).step(0.0) { |x| x } }.should raise_error(ArgumentError)
+ lambda { (-1..1).step(0.0) { |x| x } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if step is negative" do
- -> { (-1..1).step(-2) { |x| x } }.should raise_error(ArgumentError)
+ lambda { (-1..1).step(-2) { |x| x } }.should raise_error(ArgumentError)
end
describe "with inclusive end" do
@@ -102,15 +108,6 @@ describe "Range#step" do
ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 6.4, 1.0, 2.3, 3.6,
4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7])
end
-
- it "handles infinite values at either end" do
- (-Float::INFINITY..0.0).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 }
- ScratchPad.recorded.should eql([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY])
-
- ScratchPad.record []
- (0.0..Float::INFINITY).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 }
- ScratchPad.recorded.should eql([0.0, 2.0, 4.0])
- end
end
describe "and Integer, Float values" do
@@ -159,7 +156,7 @@ describe "Range#step" do
end
it "raises a TypeError when passed a Float step" do
- -> { ("A".."G").step(2.0) { } }.should raise_error(TypeError)
+ lambda { ("A".."G").step(2.0) { } }.should raise_error(TypeError)
end
it "calls #succ on begin and each element returned by #succ" do
@@ -212,15 +209,6 @@ describe "Range#step" do
(1.0...55.6).step(18.2) { |x| ScratchPad << x }
ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 1.0, 19.2, 37.4])
end
-
- it "handles infinite values at either end" do
- (-Float::INFINITY...0.0).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 }
- ScratchPad.recorded.should eql([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY])
-
- ScratchPad.record []
- (0.0...Float::INFINITY).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 }
- ScratchPad.recorded.should eql([0.0, 2.0, 4.0])
- end
end
describe "and Integer, Float values" do
@@ -269,7 +257,7 @@ describe "Range#step" do
end
it "raises a TypeError when passed a Float step" do
- -> { ("A"..."G").step(2.0) { } }.should raise_error(TypeError)
+ lambda { ("A"..."G").step(2.0) { } }.should raise_error(TypeError)
end
end
end
@@ -280,7 +268,7 @@ describe "Range#step" do
it "raises a TypeError if step does not respond to #to_int" do
obj = mock("Range#step non-integer")
enum = (1..2).step(obj)
- -> { enum.size }.should raise_error(TypeError)
+ lambda { enum.size }.should raise_error(TypeError)
end
it "raises a TypeError if #to_int does not return an Integer" do
@@ -288,31 +276,22 @@ describe "Range#step" do
obj.should_receive(:to_int).and_return("1")
enum = (1..2).step(obj)
- -> { enum.size }.should raise_error(TypeError)
+ lambda { enum.size }.should raise_error(TypeError)
end
- ruby_version_is ""..."2.6" do
- it "raises an ArgumentError if step is 0" do
- enum = (-1..1).step(0)
- -> { enum.size }.should raise_error(ArgumentError)
- end
-
- it "raises an ArgumentError if step is 0.0" do
- enum = (-1..1).step(0.0)
- -> { enum.size }.should raise_error(ArgumentError)
- end
-
- it "raises an ArgumentError if step is negative" do
- enum = (-1..1).step(-2)
- -> { enum.size }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError if step is 0" do
+ enum = (-1..1).step(0)
+ lambda { enum.size }.should raise_error(ArgumentError)
end
- ruby_version_is "2.6" do
- it "returns Float::INFINITY for zero step" do
- (-1..1).step(0).size.should == Float::INFINITY
- (-1..1).step(0.0).size.should == Float::INFINITY
- end
+ it "raises an ArgumentError if step is 0.0" do
+ enum = (-1..1).step(0.0)
+ lambda { enum.size }.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError if step is negative" do
+ enum = (-1..1).step(-2)
+ lambda { enum.size }.should raise_error(ArgumentError)
end
it "returns the ceil of range size divided by the number of steps" do
@@ -328,13 +307,6 @@ describe "Range#step" do
(-5...5).step(2).size.should == 5
end
- ruby_version_is "2.6" do
- it "returns the ceil of range size divided by the number of steps even if step is negative" do
- (-1..1).step(-1).size.should == 0
- (1..-1).step(-1).size.should == 3
- end
- end
-
it "returns the correct number of steps when one of the arguments is a float" do
(-1..1.0).step(0.5).size.should == 5
(-1.0...1.0).step(0.5).size.should == 4
@@ -366,32 +338,10 @@ describe "Range#step" do
obj = mock("Range#step non-comparable")
obj.should_receive(:<=>).with(obj).and_return(1)
enum = (obj..obj).step
- -> { enum.size }.should_not raise_error
+ lambda { enum.size }.should_not raise_error
enum.size.should == nil
end
end
-
- describe "type" do
- ruby_version_is ""..."2.6" do
- it "returns an instance of Enumerator" do
- (1..10).step.class.should == Enumerator
- end
- end
-
- ruby_version_is "2.6" do
- context "when both begin and end are numerics" do
- it "returns an instance of Enumerator::ArithmeticSequence" do
- (1..10).step.class.should == Enumerator::ArithmeticSequence
- end
- end
-
- context "when begin and end are not numerics" do
- it "returns an instance of Enumerator" do
- ("a".."z").step.class.should == Enumerator
- end
- end
- end
- end
end
end
end
diff --git a/spec/ruby/core/range/to_a_spec.rb b/spec/ruby/core/range/to_a_spec.rb
index 15f0b44a9c..d1b838295b 100644
--- a/spec/ruby/core/range/to_a_spec.rb
+++ b/spec/ruby/core/range/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#to_a" do
it "converts self to an array" do
@@ -6,7 +6,7 @@ describe "Range#to_a" do
('A'..'D').to_a.should == ['A','B','C','D']
('A'...'D').to_a.should == ['A','B','C']
(0xfffd...0xffff).to_a.should == [0xfffd,0xfffe]
- -> { (0.5..2.4).to_a }.should raise_error(TypeError)
+ lambda { (0.5..2.4).to_a }.should raise_error(TypeError)
end
it "returns empty array for descending-ordered" do
diff --git a/spec/ruby/core/range/to_s_spec.rb b/spec/ruby/core/range/to_s_spec.rb
index 7392aa9890..b59849fc57 100644
--- a/spec/ruby/core/range/to_s_spec.rb
+++ b/spec/ruby/core/range/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Range#to_s" do
it "provides a printable form of self" do
@@ -11,17 +11,15 @@ describe "Range#to_s" do
(0.5..2.4).to_s.should == "0.5..2.4"
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted string if either end is tainted" do
- (("a".taint)..."c").to_s.tainted?.should be_true
- ("a"...("c".taint)).to_s.tainted?.should be_true
- ("a"..."c").taint.to_s.tainted?.should be_true
- end
+ it "returns a tainted string if either end is tainted" do
+ (("a".taint)..."c").to_s.tainted?.should be_true
+ ("a"...("c".taint)).to_s.tainted?.should be_true
+ ("a"..."c").taint.to_s.tainted?.should be_true
+ end
- it "returns a untrusted string if either end is untrusted" do
- (("a".untrust)..."c").to_s.untrusted?.should be_true
- ("a"...("c".untrust)).to_s.untrusted?.should be_true
- ("a"..."c").untrust.to_s.untrusted?.should be_true
- end
+ it "returns a untrusted string if either end is untrusted" do
+ (("a".untrust)..."c").to_s.untrusted?.should be_true
+ ("a"...("c".untrust)).to_s.untrusted?.should be_true
+ ("a"..."c").untrust.to_s.untrusted?.should be_true
end
end
diff --git a/spec/ruby/core/rational/abs_spec.rb b/spec/ruby/core/rational/abs_spec.rb
index aed7713058..b04cbd2020 100644
--- a/spec/ruby/core/rational/abs_spec.rb
+++ b/spec/ruby/core/rational/abs_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/abs'
+require File.expand_path('../../../shared/rational/abs', __FILE__)
describe "Rational#abs" do
- it_behaves_like :rational_abs, :abs
+ it_behaves_like(:rational_abs, :abs)
end
diff --git a/spec/ruby/core/rational/ceil_spec.rb b/spec/ruby/core/rational/ceil_spec.rb
index 5b0ca4a9d6..e7aca07d33 100644
--- a/spec/ruby/core/rational/ceil_spec.rb
+++ b/spec/ruby/core/rational/ceil_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/ceil'
+require File.expand_path('../../../shared/rational/ceil', __FILE__)
describe "Rational#ceil" do
- it_behaves_like :rational_ceil, :ceil
+ it_behaves_like(:rational_ceil, :ceil)
end
diff --git a/spec/ruby/core/rational/coerce_spec.rb b/spec/ruby/core/rational/coerce_spec.rb
index 3f78f0bcd6..2cfe1db415 100644
--- a/spec/ruby/core/rational/coerce_spec.rb
+++ b/spec/ruby/core/rational/coerce_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/coerce'
+require File.expand_path('../../../shared/rational/coerce', __FILE__)
describe "Rational#coerce" do
- it_behaves_like :rational_coerce, :coerce
+ it_behaves_like(:rational_coerce, :coerce)
end
diff --git a/spec/ruby/core/rational/comparison_spec.rb b/spec/ruby/core/rational/comparison_spec.rb
index b2784f3e7d..47e3ab043d 100644
--- a/spec/ruby/core/rational/comparison_spec.rb
+++ b/spec/ruby/core/rational/comparison_spec.rb
@@ -1,22 +1,21 @@
-require_relative '../../shared/rational/comparison'
+require File.expand_path('../../../shared/rational/comparison', __FILE__)
describe "Rational#<=> when passed a Rational object" do
- it_behaves_like :rational_cmp_rat, :<=>
+ it_behaves_like(:rational_cmp_rat, :<=>)
end
describe "Rational#<=> when passed a Integer object" do
- it_behaves_like :rational_cmp_int, :<=>
+ it_behaves_like(:rational_cmp_int, :<=>)
end
describe "Rational#<=> when passed a Float object" do
- it_behaves_like :rational_cmp_float, :<=>
+ it_behaves_like(:rational_cmp_float, :<=>)
end
describe "Rational#<=> when passed an Object that responds to #coerce" do
- it_behaves_like :rational_cmp_coerce, :<=>
- it_behaves_like :rational_cmp_coerce_exception, :<=>
+ it_behaves_like(:rational_cmp_coerce, :<=>)
end
describe "Rational#<=> when passed a non-Numeric Object that doesn't respond to #coerce" do
- it_behaves_like :rational_cmp_other, :<=>
+ it_behaves_like(:rational_cmp_other, :<=>)
end
diff --git a/spec/ruby/core/rational/denominator_spec.rb b/spec/ruby/core/rational/denominator_spec.rb
index 6214b40587..ac2795ded1 100644
--- a/spec/ruby/core/rational/denominator_spec.rb
+++ b/spec/ruby/core/rational/denominator_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/denominator'
+require File.expand_path('../../../shared/rational/denominator', __FILE__)
describe "Rational#denominator" do
- it_behaves_like :rational_denominator, :denominator
+ it_behaves_like(:rational_denominator, :denominator)
end
diff --git a/spec/ruby/core/rational/div_spec.rb b/spec/ruby/core/rational/div_spec.rb
index 1cd8606b90..1fd304b646 100644
--- a/spec/ruby/core/rational/div_spec.rb
+++ b/spec/ruby/core/rational/div_spec.rb
@@ -1,17 +1,17 @@
-require_relative '../../shared/rational/div'
+require File.expand_path('../../../shared/rational/div', __FILE__)
describe "Rational#div" do
- it_behaves_like :rational_div, :div
+ it_behaves_like(:rational_div, :div)
end
describe "Rational#div passed a Rational" do
- it_behaves_like :rational_div_rat, :div
+ it_behaves_like(:rational_div_rat, :div)
end
describe "Rational#div passed an Integer" do
- it_behaves_like :rational_div_int, :div
+ it_behaves_like(:rational_div_int, :div)
end
describe "Rational#div passed a Float" do
- it_behaves_like :rational_div_float, :div
+ it_behaves_like(:rational_div_float, :div)
end
diff --git a/spec/ruby/core/rational/divide_spec.rb b/spec/ruby/core/rational/divide_spec.rb
index d8e3a44dc2..75e447878c 100644
--- a/spec/ruby/core/rational/divide_spec.rb
+++ b/spec/ruby/core/rational/divide_spec.rb
@@ -1,19 +1,17 @@
-require_relative '../../shared/rational/divide'
-require_relative '../../shared/rational/arithmetic_exception_in_coerce'
+require File.expand_path('../../../shared/rational/divide', __FILE__)
describe "Rational#/" do
- it_behaves_like :rational_divide, :/
- it_behaves_like :rational_arithmetic_exception_in_coerce, :/
+ it_behaves_like(:rational_divide, :/)
end
describe "Rational#/ when passed an Integer" do
- it_behaves_like :rational_divide_int, :/
+ it_behaves_like(:rational_divide_int, :/)
end
describe "Rational#/ when passed a Rational" do
- it_behaves_like :rational_divide_rat, :/
+ it_behaves_like(:rational_divide_rat, :/)
end
describe "Rational#/ when passed a Float" do
- it_behaves_like :rational_divide_float, :/
+ it_behaves_like(:rational_divide_float, :/)
end
diff --git a/spec/ruby/core/rational/divmod_spec.rb b/spec/ruby/core/rational/divmod_spec.rb
index 6be1f8bd73..ee03c9498a 100644
--- a/spec/ruby/core/rational/divmod_spec.rb
+++ b/spec/ruby/core/rational/divmod_spec.rb
@@ -1,13 +1,13 @@
-require_relative '../../shared/rational/divmod'
+require File.expand_path('../../../shared/rational/divmod', __FILE__)
describe "Rational#divmod when passed a Rational" do
- it_behaves_like :rational_divmod_rat, :divmod
+ it_behaves_like(:rational_divmod_rat, :divmod)
end
describe "Rational#divmod when passed an Integer" do
- it_behaves_like :rational_divmod_int, :divmod
+ it_behaves_like(:rational_divmod_int, :divmod)
end
describe "Rational#divmod when passed a Float" do
- it_behaves_like :rational_divmod_float, :divmod
+ it_behaves_like(:rational_divmod_float, :divmod)
end
diff --git a/spec/ruby/core/rational/equal_value_spec.rb b/spec/ruby/core/rational/equal_value_spec.rb
index 8e7acb1354..708eccf6d1 100644
--- a/spec/ruby/core/rational/equal_value_spec.rb
+++ b/spec/ruby/core/rational/equal_value_spec.rb
@@ -1,17 +1,17 @@
-require_relative '../../shared/rational/equal_value'
+require File.expand_path('../../../shared/rational/equal_value', __FILE__)
describe "Rational#==" do
- it_behaves_like :rational_equal_value, :==
+ it_behaves_like(:rational_equal_value, :==)
end
describe "Rational#== when passed a Rational" do
- it_behaves_like :rational_equal_value_rat, :==
+ it_behaves_like(:rational_equal_value_rat, :==)
end
describe "Rational#== when passed a Float" do
- it_behaves_like :rational_equal_value_float, :==
+ it_behaves_like(:rational_equal_value_float, :==)
end
describe "Rational#== when passed an Integer" do
- it_behaves_like :rational_equal_value_int, :==
+ it_behaves_like(:rational_equal_value_int, :==)
end
diff --git a/spec/ruby/core/rational/exponent_spec.rb b/spec/ruby/core/rational/exponent_spec.rb
index 622cf22782..e4810d1b41 100644
--- a/spec/ruby/core/rational/exponent_spec.rb
+++ b/spec/ruby/core/rational/exponent_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/exponent'
+require File.expand_path('../../../shared/rational/exponent', __FILE__)
describe "Rational#**" do
- it_behaves_like :rational_exponent, :**
+ it_behaves_like(:rational_exponent, :**)
end
diff --git a/spec/ruby/core/rational/fdiv_spec.rb b/spec/ruby/core/rational/fdiv_spec.rb
index bfb321abaa..15b4ed0619 100644
--- a/spec/ruby/core/rational/fdiv_spec.rb
+++ b/spec/ruby/core/rational/fdiv_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/fdiv'
+require File.expand_path('../../../shared/rational/fdiv', __FILE__)
describe "Rational#fdiv" do
- it_behaves_like :rational_fdiv, :fdiv
+ it_behaves_like(:rational_fdiv, :fdiv)
end
diff --git a/spec/ruby/core/rational/floor_spec.rb b/spec/ruby/core/rational/floor_spec.rb
index 752a2d8815..485abcf58f 100644
--- a/spec/ruby/core/rational/floor_spec.rb
+++ b/spec/ruby/core/rational/floor_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/floor'
+require File.expand_path('../../../shared/rational/floor', __FILE__)
describe "Rational#floor" do
- it_behaves_like :rational_floor, :floor
+ it_behaves_like(:rational_floor, :floor)
end
diff --git a/spec/ruby/core/rational/hash_spec.rb b/spec/ruby/core/rational/hash_spec.rb
index 84cd31518a..a17572d57e 100644
--- a/spec/ruby/core/rational/hash_spec.rb
+++ b/spec/ruby/core/rational/hash_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/hash'
+require File.expand_path('../../../shared/rational/hash', __FILE__)
describe "Rational#hash" do
- it_behaves_like :rational_hash, :hash
+ it_behaves_like(:rational_hash, :hash)
end
diff --git a/spec/ruby/core/rational/inspect_spec.rb b/spec/ruby/core/rational/inspect_spec.rb
index ef337ef0ce..452cf9c5ae 100644
--- a/spec/ruby/core/rational/inspect_spec.rb
+++ b/spec/ruby/core/rational/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/inspect'
+require File.expand_path('../../../shared/rational/inspect', __FILE__)
describe "Rational#inspect" do
- it_behaves_like :rational_inspect, :inspect
+ it_behaves_like(:rational_inspect, :inspect)
end
diff --git a/spec/ruby/core/rational/integer_spec.rb b/spec/ruby/core/rational/integer_spec.rb
index 0f9a3bdead..451e42ee14 100644
--- a/spec/ruby/core/rational/integer_spec.rb
+++ b/spec/ruby/core/rational/integer_spec.rb
@@ -1,9 +1,6 @@
describe "Rational#integer?" do
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
- it "returns false for a rational with a numerator and no denominator" do
- Rational(20).integer?.should be_false
- end
+ it "returns false for a rational with a numerator and no denominator" do
+ Rational(20).integer?.should be_false
end
it "returns false for a rational with a numerator and a denominator" do
diff --git a/spec/ruby/core/rational/magnitude_spec.rb b/spec/ruby/core/rational/magnitude_spec.rb
index 878fc8f879..288b9a3fa3 100644
--- a/spec/ruby/core/rational/magnitude_spec.rb
+++ b/spec/ruby/core/rational/magnitude_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/abs'
+require File.expand_path('../../../shared/rational/abs', __FILE__)
describe "Rational#abs" do
- it_behaves_like :rational_abs, :magnitude
+ it_behaves_like(:rational_abs, :magnitude)
end
diff --git a/spec/ruby/core/rational/marshal_dump_spec.rb b/spec/ruby/core/rational/marshal_dump_spec.rb
index 17a6107cd5..46e9267ebd 100644
--- a/spec/ruby/core/rational/marshal_dump_spec.rb
+++ b/spec/ruby/core/rational/marshal_dump_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Rational#marshal_dump" do
it "is a private method" do
diff --git a/spec/ruby/core/rational/minus_spec.rb b/spec/ruby/core/rational/minus_spec.rb
index 9e0f81556b..9e28cb1c4f 100644
--- a/spec/ruby/core/rational/minus_spec.rb
+++ b/spec/ruby/core/rational/minus_spec.rb
@@ -1,7 +1,5 @@
-require_relative '../../shared/rational/minus'
-require_relative '../../shared/rational/arithmetic_exception_in_coerce'
+require File.expand_path('../../../shared/rational/minus', __FILE__)
describe "Rational#-" do
- it_behaves_like :rational_minus, :-
- it_behaves_like :rational_arithmetic_exception_in_coerce, :-
+ it_behaves_like(:rational_minus, :-)
end
diff --git a/spec/ruby/core/rational/modulo_spec.rb b/spec/ruby/core/rational/modulo_spec.rb
index c43f7788e3..81e7c13797 100644
--- a/spec/ruby/core/rational/modulo_spec.rb
+++ b/spec/ruby/core/rational/modulo_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/modulo'
+require File.expand_path('../../../shared/rational/modulo', __FILE__)
describe "Rational#%" do
- it_behaves_like :rational_modulo, :%
+ it_behaves_like(:rational_modulo, :%)
end
diff --git a/spec/ruby/core/rational/multiply_spec.rb b/spec/ruby/core/rational/multiply_spec.rb
index ea644074e9..c45491fde3 100644
--- a/spec/ruby/core/rational/multiply_spec.rb
+++ b/spec/ruby/core/rational/multiply_spec.rb
@@ -1,19 +1,17 @@
-require_relative '../../shared/rational/multiply'
-require_relative '../../shared/rational/arithmetic_exception_in_coerce'
+require File.expand_path('../../../shared/rational/multiply', __FILE__)
describe "Rational#*" do
- it_behaves_like :rational_multiply, :*
- it_behaves_like :rational_arithmetic_exception_in_coerce, :*
+ it_behaves_like(:rational_multiply, :*)
end
describe "Rational#* passed a Rational" do
- it_behaves_like :rational_multiply_rat, :*
+ it_behaves_like(:rational_multiply_rat, :*)
end
describe "Rational#* passed a Float" do
- it_behaves_like :rational_multiply_float, :*
+ it_behaves_like(:rational_multiply_float, :*)
end
describe "Rational#* passed an Integer" do
- it_behaves_like :rational_multiply_int, :*
+ it_behaves_like(:rational_multiply_int, :*)
end
diff --git a/spec/ruby/core/rational/numerator_spec.rb b/spec/ruby/core/rational/numerator_spec.rb
index 85b2ed9e86..ac6591291d 100644
--- a/spec/ruby/core/rational/numerator_spec.rb
+++ b/spec/ruby/core/rational/numerator_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/numerator'
+require File.expand_path('../../../shared/rational/numerator', __FILE__)
describe "Rational#numerator" do
- it_behaves_like :rational_numerator, :numerator
+ it_behaves_like(:rational_numerator, :numerator)
end
diff --git a/spec/ruby/core/rational/plus_spec.rb b/spec/ruby/core/rational/plus_spec.rb
index e7ef3a8f92..b82c44bbad 100644
--- a/spec/ruby/core/rational/plus_spec.rb
+++ b/spec/ruby/core/rational/plus_spec.rb
@@ -1,18 +1,16 @@
-require_relative '../../shared/rational/plus'
-require_relative '../../shared/rational/arithmetic_exception_in_coerce'
+require File.expand_path('../../../shared/rational/plus', __FILE__)
describe "Rational#+" do
- it_behaves_like :rational_plus, :+
- it_behaves_like :rational_arithmetic_exception_in_coerce, :+
+ it_behaves_like(:rational_plus, :+)
end
describe "Rational#+ with a Rational" do
- it_behaves_like :rational_plus_rat, :+
+ it_behaves_like(:rational_plus_rat, :+)
end
describe "Rational#+ with a Float" do
- it_behaves_like :rational_plus_float, :+
+ it_behaves_like(:rational_plus_float, :+)
end
describe "Rational#+ with an Integer" do
- it_behaves_like :rational_plus_int, :+
+ it_behaves_like(:rational_plus_int, :+)
end
diff --git a/spec/ruby/core/rational/quo_spec.rb b/spec/ruby/core/rational/quo_spec.rb
index 119aca1955..f4d04d5f6f 100644
--- a/spec/ruby/core/rational/quo_spec.rb
+++ b/spec/ruby/core/rational/quo_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/divide'
+require File.expand_path('../../../shared/rational/divide', __FILE__)
describe "Rational#quo" do
- it_behaves_like :rational_divide, :quo
+ it_behaves_like(:rational_divide, :quo)
end
diff --git a/spec/ruby/core/rational/rational_spec.rb b/spec/ruby/core/rational/rational_spec.rb
index 704e49354e..fc3108c11b 100644
--- a/spec/ruby/core/rational/rational_spec.rb
+++ b/spec/ruby/core/rational/rational_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Rational" do
it "includes Comparable" do
diff --git a/spec/ruby/core/rational/rationalize_spec.rb b/spec/ruby/core/rational/rationalize_spec.rb
index 3db027d446..053e245cff 100644
--- a/spec/ruby/core/rational/rationalize_spec.rb
+++ b/spec/ruby/core/rational/rationalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Rational#rationalize" do
it "returns self with no argument" do
@@ -30,7 +30,7 @@ describe "Rational#rationalize" do
end
it "raises ArgumentError when passed more than one argument" do
- -> { Rational(1,1).rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
- -> { Rational(1,1).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
+ lambda { Rational(1,1).rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
+ lambda { Rational(1,1).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/rational/remainder_spec.rb b/spec/ruby/core/rational/remainder_spec.rb
index 0f9442f6f5..1de276548f 100644
--- a/spec/ruby/core/rational/remainder_spec.rb
+++ b/spec/ruby/core/rational/remainder_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/remainder'
+require File.expand_path('../../../shared/rational/remainder', __FILE__)
describe "Rational#remainder" do
- it_behaves_like :rational_remainder, :remainder
+ it_behaves_like(:rational_remainder, :remainder)
end
diff --git a/spec/ruby/core/rational/round_spec.rb b/spec/ruby/core/rational/round_spec.rb
index 36614a552d..2b432f3234 100644
--- a/spec/ruby/core/rational/round_spec.rb
+++ b/spec/ruby/core/rational/round_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/rational/round'
+require File.expand_path('../../../shared/rational/round', __FILE__)
describe "Rational#round" do
- it_behaves_like :rational_round, :round
+ it_behaves_like(:rational_round, :round)
end
diff --git a/spec/ruby/core/rational/to_f_spec.rb b/spec/ruby/core/rational/to_f_spec.rb
index 15bf1e88dc..92ff2444b4 100644
--- a/spec/ruby/core/rational/to_f_spec.rb
+++ b/spec/ruby/core/rational/to_f_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/to_f'
+require File.expand_path('../../../shared/rational/to_f', __FILE__)
describe "Rational#to_f" do
- it_behaves_like :rational_to_f, :to_f
+ it_behaves_like(:rational_to_f, :to_f)
end
diff --git a/spec/ruby/core/rational/to_i_spec.rb b/spec/ruby/core/rational/to_i_spec.rb
index 3deb3664e1..fda6b06e96 100644
--- a/spec/ruby/core/rational/to_i_spec.rb
+++ b/spec/ruby/core/rational/to_i_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/to_i'
+require File.expand_path('../../../shared/rational/to_i', __FILE__)
describe "Rational#to_i" do
- it_behaves_like :rational_to_i, :to_i
+ it_behaves_like(:rational_to_i, :to_i)
end
diff --git a/spec/ruby/core/rational/to_r_spec.rb b/spec/ruby/core/rational/to_r_spec.rb
index cc704c965e..6e44cf1b23 100644
--- a/spec/ruby/core/rational/to_r_spec.rb
+++ b/spec/ruby/core/rational/to_r_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../shared/rational/to_r'
+require File.expand_path('../../../shared/rational/to_r', __FILE__)
describe "Rational#to_r" do
- it_behaves_like :rational_to_r, :to_r
+ it_behaves_like(:rational_to_r, :to_r)
it "raises TypeError trying to convert BasicObject" do
obj = BasicObject.new
- -> { Rational(obj) }.should raise_error(TypeError)
+ lambda { Rational(obj) }.should raise_error(TypeError)
end
it "works when a BasicObject has to_r" do
@@ -15,6 +15,6 @@ describe "Rational#to_r" do
it "fails when a BasicObject's to_r does not return a Rational" do
obj = BasicObject.new; def obj.to_r; 1 end
- -> { Rational(obj) }.should raise_error(TypeError)
+ lambda { Rational(obj) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/rational/to_s_spec.rb b/spec/ruby/core/rational/to_s_spec.rb
index c5c419787c..7d1702b8fa 100644
--- a/spec/ruby/core/rational/to_s_spec.rb
+++ b/spec/ruby/core/rational/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/to_s'
+require File.expand_path('../../../shared/rational/to_s', __FILE__)
describe "Rational#to_s" do
- it_behaves_like :rational_to_s, :to_s
+ it_behaves_like(:rational_to_s, :to_s)
end
diff --git a/spec/ruby/core/rational/truncate_spec.rb b/spec/ruby/core/rational/truncate_spec.rb
index 4e72339752..000db73357 100644
--- a/spec/ruby/core/rational/truncate_spec.rb
+++ b/spec/ruby/core/rational/truncate_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../shared/rational/truncate'
+require File.expand_path('../../../shared/rational/truncate', __FILE__)
describe "Rational#truncate" do
- it_behaves_like :rational_truncate, :truncate
+ it_behaves_like(:rational_truncate, :truncate)
end
diff --git a/spec/ruby/core/regexp/case_compare_spec.rb b/spec/ruby/core/regexp/case_compare_spec.rb
index a621713f6f..84ac957d12 100644
--- a/spec/ruby/core/regexp/case_compare_spec.rb
+++ b/spec/ruby/core/regexp/case_compare_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#===" do
it "is true if there is a match" do
@@ -17,7 +17,7 @@ describe "Regexp#===" do
(/a/ === :b).should be_false
end
- # mirroring https://github.com/ruby/ruby/blob/master/test/ruby/test_regexp.rb
+ # mirroring https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb
it "returns false if the other value cannot be coerced to a string" do
(/abc/ === nil).should be_false
(/abc/ === /abc/).should be_false
diff --git a/spec/ruby/core/regexp/casefold_spec.rb b/spec/ruby/core/regexp/casefold_spec.rb
index d84a2d63c9..55efcaa765 100644
--- a/spec/ruby/core/regexp/casefold_spec.rb
+++ b/spec/ruby/core/regexp/casefold_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#casefold?" do
it "returns the value of the case-insensitive flag" do
diff --git a/spec/ruby/core/regexp/compile_spec.rb b/spec/ruby/core/regexp/compile_spec.rb
index 329cb4f753..530816e07c 100644
--- a/spec/ruby/core/regexp/compile_spec.rb
+++ b/spec/ruby/core/regexp/compile_spec.rb
@@ -1,15 +1,18 @@
-require_relative '../../spec_helper'
-require_relative 'shared/new'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new_ascii', __FILE__)
+require File.expand_path('../shared/new_ascii_8bit', __FILE__)
describe "Regexp.compile" do
- it_behaves_like :regexp_new, :compile
+ it_behaves_like :regexp_new_ascii, :compile
+ it_behaves_like :regexp_new_ascii_8bit, :compile
end
describe "Regexp.compile given a String" do
- it_behaves_like :regexp_new_string, :compile
- it_behaves_like :regexp_new_string_binary, :compile
+ it_behaves_like :regexp_new_string_ascii, :compile
+ it_behaves_like :regexp_new_string_ascii_8bit, :compile
end
describe "Regexp.compile given a Regexp" do
- it_behaves_like :regexp_new_regexp, :compile
+ it_behaves_like :regexp_new_regexp_ascii, :compile
+ it_behaves_like :regexp_new_regexp_ascii_8bit, :compile
end
diff --git a/spec/ruby/core/regexp/encoding_spec.rb b/spec/ruby/core/regexp/encoding_spec.rb
index dfc835b4e4..c30519c9d7 100644
--- a/spec/ruby/core/regexp/encoding_spec.rb
+++ b/spec/ruby/core/regexp/encoding_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#encoding" do
it "returns an Encoding object" do
@@ -14,8 +14,8 @@ describe "Regexp#encoding" do
/ASCII/n.encoding.should == Encoding::US_ASCII
end
- it "returns BINARY if the 'n' modifier is supplied and non-US-ASCII characters are present" do
- /\xc2\xa1/n.encoding.should == Encoding::BINARY
+ it "returns ASCII-8BIT if the 'n' modifier is supplied and non-US-ASCII characters are present" do
+ /\xc2\xa1/n.encoding.should == Encoding::ASCII_8BIT
end
it "defaults to UTF-8 if \\u escapes appear" do
@@ -55,8 +55,4 @@ describe "Regexp#encoding" do
/foo/.encoding.should_not == Encoding::EUC_JP
Encoding.default_internal = old_internal
end
-
- it "allows otherwise invalid characters if NOENCODING is specified" do
- Regexp.new('([\x00-\xFF])', Regexp::IGNORECASE | Regexp::NOENCODING).encoding.should == Encoding::BINARY
- end
end
diff --git a/spec/ruby/core/regexp/eql_spec.rb b/spec/ruby/core/regexp/eql_spec.rb
index bd5ae43eb2..7288ff45fe 100644
--- a/spec/ruby/core/regexp/eql_spec.rb
+++ b/spec/ruby/core/regexp/eql_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Regexp#eql?" do
it_behaves_like :regexp_eql, :eql?
diff --git a/spec/ruby/core/regexp/equal_value_spec.rb b/spec/ruby/core/regexp/equal_value_spec.rb
index 5455a30598..4ddaec8e4e 100644
--- a/spec/ruby/core/regexp/equal_value_spec.rb
+++ b/spec/ruby/core/regexp/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Regexp#==" do
it_behaves_like :regexp_eql, :==
diff --git a/spec/ruby/core/regexp/escape_spec.rb b/spec/ruby/core/regexp/escape_spec.rb
index 6b06ab1cbc..56b6cc5059 100644
--- a/spec/ruby/core/regexp/escape_spec.rb
+++ b/spec/ruby/core/regexp/escape_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quote'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quote', __FILE__)
describe "Regexp.escape" do
it_behaves_like :regexp_quote, :escape
diff --git a/spec/ruby/core/regexp/fixed_encoding_spec.rb b/spec/ruby/core/regexp/fixed_encoding_spec.rb
index 29d0a22c53..8a11de9575 100644
--- a/spec/ruby/core/regexp/fixed_encoding_spec.rb
+++ b/spec/ruby/core/regexp/fixed_encoding_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#fixed_encoding?" do
it "returns false by default" do
diff --git a/spec/ruby/core/regexp/hash_spec.rb b/spec/ruby/core/regexp/hash_spec.rb
index 2d42e288e6..77b79b1ce5 100644
--- a/spec/ruby/core/regexp/hash_spec.rb
+++ b/spec/ruby/core/regexp/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#hash" do
it "is provided" do
diff --git a/spec/ruby/core/regexp/initialize_spec.rb b/spec/ruby/core/regexp/initialize_spec.rb
index 36fd5c7bf2..3c32f97a31 100644
--- a/spec/ruby/core/regexp/initialize_spec.rb
+++ b/spec/ruby/core/regexp/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#initialize" do
it "is a private method" do
@@ -6,10 +6,10 @@ describe "Regexp#initialize" do
end
it "raises a SecurityError on a Regexp literal" do
- -> { //.send(:initialize, "") }.should raise_error(SecurityError)
+ lambda { //.send(:initialize, "") }.should raise_error(SecurityError)
end
it "raises a TypeError on an initialized non-literal Regexp" do
- -> { Regexp.new("").send(:initialize, "") }.should raise_error(TypeError)
+ lambda { Regexp.new("").send(:initialize, "") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/regexp/inspect_spec.rb b/spec/ruby/core/regexp/inspect_spec.rb
index f4e39234f5..a2855cae5b 100644
--- a/spec/ruby/core/regexp/inspect_spec.rb
+++ b/spec/ruby/core/regexp/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#inspect" do
it "returns a formatted string that would eval to the same regexp" do
diff --git a/spec/ruby/core/regexp/last_match_spec.rb b/spec/ruby/core/regexp/last_match_spec.rb
index ed496b7941..4673554f91 100644
--- a/spec/ruby/core/regexp/last_match_spec.rb
+++ b/spec/ruby/core/regexp/last_match_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp.last_match" do
it "returns MatchData instance when not passed arguments" do
diff --git a/spec/ruby/core/regexp/match_spec.rb b/spec/ruby/core/regexp/match_spec.rb
index 80dbfb4c10..872c3ff59e 100644
--- a/spec/ruby/core/regexp/match_spec.rb
+++ b/spec/ruby/core/regexp/match_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :regexp_match, shared: true do
it "returns nil if there is no match" do
@@ -12,7 +12,7 @@ describe :regexp_match, shared: true do
end
describe "Regexp#=~" do
- it_behaves_like :regexp_match, :=~
+ it_behaves_like(:regexp_match, :=~)
it "returns the index of the first character of the matching region" do
(/(.)(.)(.)/ =~ "abc").should == 0
@@ -24,7 +24,7 @@ describe "Regexp#=~" do
end
describe "Regexp#match" do
- it_behaves_like :regexp_match, :match
+ it_behaves_like(:regexp_match, :match)
it "returns a MatchData object" do
/(.)(.)(.)/.match("abc").should be_kind_of(MatchData)
@@ -35,11 +35,7 @@ describe "Regexp#match" do
end
it "raises a TypeError on an uninitialized Regexp" do
- -> { Regexp.allocate.match('foo') }.should raise_error(TypeError)
- end
-
- it "raises TypeError on an uninitialized Regexp" do
- -> { Regexp.allocate.match('foo'.encode("UTF-16LE")) }.should raise_error(TypeError)
+ lambda { Regexp.allocate.match('foo') }.should raise_error(TypeError)
end
describe "with [string, position]" do
@@ -48,13 +44,15 @@ describe "Regexp#match" do
/(.).(.)/.match("01234", 1).captures.should == ["1", "3"]
end
- it "uses the start as a character offset" do
- /(.).(.)/.match("零一二三四", 1).captures.should == ["一", "三"]
- end
+ with_feature :encoding do
+ it "uses the start as a character offset" do
+ /(.).(.)/.match("零一二三四", 1).captures.should == ["一", "三"]
+ end
- it "raises an ArgumentError for an invalid encoding" do
- x96 = ([150].pack('C')).force_encoding('utf-8')
- -> { /(.).(.)/.match("Hello, #{x96} world!", 1) }.should raise_error(ArgumentError)
+ it "raises an ArgumentError for an invalid encoding" do
+ x96 = ([150].pack('C')).force_encoding('utf-8')
+ lambda { /(.).(.)/.match("Hello, #{x96} world!", 1) }.should raise_error(ArgumentError)
+ end
end
end
@@ -63,13 +61,15 @@ describe "Regexp#match" do
/(.).(.)/.match("01234", -4).captures.should == ["1", "3"]
end
- it "uses the start as a character offset" do
- /(.).(.)/.match("零一二三四", -4).captures.should == ["一", "三"]
- end
+ with_feature :encoding do
+ it "uses the start as a character offset" do
+ /(.).(.)/.match("零一二三四", -4).captures.should == ["一", "三"]
+ end
- it "raises an ArgumentError for an invalid encoding" do
- x96 = ([150].pack('C')).force_encoding('utf-8')
- -> { /(.).(.)/.match("Hello, #{x96} world!", -1) }.should raise_error(ArgumentError)
+ it "raises an ArgumentError for an invalid encoding" do
+ x96 = ([150].pack('C')).force_encoding('utf-8')
+ lambda { /(.).(.)/.match("Hello, #{x96} world!", -1) }.should raise_error(ArgumentError)
+ end
end
end
@@ -100,41 +100,43 @@ describe "Regexp#match" do
$~.should be_nil
end
- it "raises TypeError when the given argument cannot be coerced to String" do
+ it "raises TypeError when the given argument cannot be coarce to String" do
f = 1
- -> { /foo/.match(f)[0] }.should raise_error(TypeError)
+ lambda { /foo/.match(f)[0] }.should raise_error(TypeError)
end
it "raises TypeError when the given argument is an Exception" do
f = Exception.new("foo")
- -> { /foo/.match(f)[0] }.should raise_error(TypeError)
+ lambda { /foo/.match(f)[0] }.should raise_error(TypeError)
end
end
-describe "Regexp#match?" do
- before :each do
- # Resetting Regexp.last_match
- /DONTMATCH/.match ''
- end
+ruby_version_is "2.4" do
+ describe "Regexp#match?" do
+ before :each do
+ # Resetting Regexp.last_match
+ /DONTMATCH/.match ''
+ end
- context "when matches the given value" do
- it "returns true but does not set Regexp.last_match" do
- /string/i.match?('string').should be_true
- Regexp.last_match.should be_nil
+ context "when matches the given value" do
+ it "returns true but does not set Regexp.last_match" do
+ /string/i.match?('string').should be_true
+ Regexp.last_match.should be_nil
+ end
end
- end
- it "returns false when does not match the given value" do
- /STRING/.match?('string').should be_false
- end
+ it "returns false when does not match the given value" do
+ /STRING/.match?('string').should be_false
+ end
- it "takes matching position as the 2nd argument" do
- /str/i.match?('string', 0).should be_true
- /str/i.match?('string', 1).should be_false
- end
+ it "takes matching position as the 2nd argument" do
+ /str/i.match?('string', 0).should be_true
+ /str/i.match?('string', 1).should be_false
+ end
- it "returns false when given nil" do
- /./.match?(nil).should be_false
+ it "returns false when given nil" do
+ /./.match?(nil).should be_false
+ end
end
end
diff --git a/spec/ruby/core/regexp/named_captures_spec.rb b/spec/ruby/core/regexp/named_captures_spec.rb
index 1a68d7877b..c495d00a35 100644
--- a/spec/ruby/core/regexp/named_captures_spec.rb
+++ b/spec/ruby/core/regexp/named_captures_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#named_captures" do
it "returns a Hash" do
diff --git a/spec/ruby/core/regexp/names_spec.rb b/spec/ruby/core/regexp/names_spec.rb
index 099768fd26..bbd994d993 100644
--- a/spec/ruby/core/regexp/names_spec.rb
+++ b/spec/ruby/core/regexp/names_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#names" do
it "returns an Array" do
diff --git a/spec/ruby/core/regexp/new_spec.rb b/spec/ruby/core/regexp/new_spec.rb
index d2d867b3d3..c9581e661f 100644
--- a/spec/ruby/core/regexp/new_spec.rb
+++ b/spec/ruby/core/regexp/new_spec.rb
@@ -1,27 +1,30 @@
-require_relative '../../spec_helper'
-require_relative 'shared/new'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new_ascii', __FILE__)
+require File.expand_path('../shared/new_ascii_8bit', __FILE__)
describe "Regexp.new" do
- it_behaves_like :regexp_new, :new
+ it_behaves_like :regexp_new_ascii, :new
+ it_behaves_like :regexp_new_ascii_8bit, :new
end
describe "Regexp.new given a String" do
- it_behaves_like :regexp_new_string, :new
+ it_behaves_like :regexp_new_string_ascii, :new
+ it_behaves_like :regexp_new_string_ascii_8bit, :new
end
describe "Regexp.new given a Regexp" do
- it_behaves_like :regexp_new_regexp, :new
- it_behaves_like :regexp_new_string_binary, :compile
+ it_behaves_like :regexp_new_regexp_ascii, :new
+ it_behaves_like :regexp_new_regexp_ascii_8bit, :new
end
describe "Regexp.new given a Fixnum" do
it "raises a TypeError" do
- -> { Regexp.new(1) }.should raise_error(TypeError)
+ lambda { Regexp.new(1) }.should raise_error(TypeError)
end
end
describe "Regexp.new given a Float" do
it "raises a TypeError" do
- -> { Regexp.new(1.0) }.should raise_error(TypeError)
+ lambda { Regexp.new(1.0) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/regexp/options_spec.rb b/spec/ruby/core/regexp/options_spec.rb
index fb4853a014..10aeeac919 100644
--- a/spec/ruby/core/regexp/options_spec.rb
+++ b/spec/ruby/core/regexp/options_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#options" do
it "returns a Fixnum bitvector of regexp options for the Regexp object" do
@@ -29,7 +29,7 @@ describe "Regexp#options" do
end
it "raises a TypeError on an uninitialized Regexp" do
- -> { Regexp.allocate.options }.should raise_error(TypeError)
+ lambda { Regexp.allocate.options }.should raise_error(TypeError)
end
it "includes Regexp::FIXEDENCODING for a Regexp literal with the 'u' option" do
diff --git a/spec/ruby/core/regexp/quote_spec.rb b/spec/ruby/core/regexp/quote_spec.rb
index 370ab13e30..a38903ef15 100644
--- a/spec/ruby/core/regexp/quote_spec.rb
+++ b/spec/ruby/core/regexp/quote_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quote'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quote', __FILE__)
describe "Regexp.quote" do
it_behaves_like :regexp_quote, :quote
diff --git a/spec/ruby/core/regexp/shared/new.rb b/spec/ruby/core/regexp/shared/new.rb
deleted file mode 100644
index bb5df7bc2e..0000000000
--- a/spec/ruby/core/regexp/shared/new.rb
+++ /dev/null
@@ -1,505 +0,0 @@
-# -*- encoding: binary -*-
-
-describe :regexp_new, shared: true do
- it "requires one argument and creates a new regular expression object" do
- Regexp.send(@method, '').is_a?(Regexp).should == true
- end
-
- it "works by default for subclasses with overridden #initialize" do
- class RegexpSpecsSubclass < Regexp
- def initialize(*args)
- super
- @args = args
- end
-
- attr_accessor :args
- end
-
- class RegexpSpecsSubclassTwo < Regexp; end
-
- RegexpSpecsSubclass.send(@method, "hi").should be_kind_of(RegexpSpecsSubclass)
- RegexpSpecsSubclass.send(@method, "hi").args.first.should == "hi"
-
- RegexpSpecsSubclassTwo.send(@method, "hi").should be_kind_of(RegexpSpecsSubclassTwo)
- end
-end
-
-describe :regexp_new_string, shared: true do
- it "uses the String argument as an unescaped literal to construct a Regexp object" do
- Regexp.send(@method, "^hi{2,3}fo.o$").should == /^hi{2,3}fo.o$/
- end
-
- it "raises a RegexpError when passed an incorrect regexp" do
- -> { Regexp.send(@method, "^[$", 0) }.should raise_error(RegexpError)
- end
-
- it "does not set Regexp options if only given one argument" do
- r = Regexp.send(@method, 'Hi')
- (r.options & Regexp::IGNORECASE).should == 0
- (r.options & Regexp::MULTILINE).should == 0
- not_supported_on :opal do
- (r.options & Regexp::EXTENDED).should == 0
- end
- end
-
- it "does not set Regexp options if second argument is nil or false" do
- r = Regexp.send(@method, 'Hi', nil)
- (r.options & Regexp::IGNORECASE).should == 0
- (r.options & Regexp::MULTILINE).should == 0
- not_supported_on :opal do
- (r.options & Regexp::EXTENDED).should == 0
- end
-
- r = Regexp.send(@method, 'Hi', false)
- (r.options & Regexp::IGNORECASE).should == 0
- (r.options & Regexp::MULTILINE).should == 0
- not_supported_on :opal do
- (r.options & Regexp::EXTENDED).should == 0
- end
- end
-
- it "sets options from second argument if it is one of the Fixnum option constants" do
- r = Regexp.send(@method, 'Hi', Regexp::IGNORECASE)
- (r.options & Regexp::IGNORECASE).should_not == 0
- (r.options & Regexp::MULTILINE).should == 0
- not_supported_on :opal do
- (r.options & Regexp::EXTENDED).should == 0
- end
-
- r = Regexp.send(@method, 'Hi', Regexp::MULTILINE)
- (r.options & Regexp::IGNORECASE).should == 0
- (r.options & Regexp::MULTILINE).should_not == 0
- not_supported_on :opal do
- (r.options & Regexp::EXTENDED).should == 0
- end
-
- not_supported_on :opal do
- r = Regexp.send(@method, 'Hi', Regexp::EXTENDED)
- (r.options & Regexp::IGNORECASE).should == 0
- (r.options & Regexp::MULTILINE).should == 0
- (r.options & Regexp::EXTENDED).should_not == 1
- end
- end
-
- it "accepts a Fixnum of two or more options ORed together as the second argument" do
- r = Regexp.send(@method, 'Hi', Regexp::IGNORECASE | Regexp::EXTENDED)
- (r.options & Regexp::IGNORECASE).should_not == 0
- (r.options & Regexp::MULTILINE).should == 0
- (r.options & Regexp::EXTENDED).should_not == 0
- end
-
- it "treats any non-Fixnum, non-nil, non-false second argument as IGNORECASE" do
- r = Regexp.send(@method, 'Hi', Object.new)
- (r.options & Regexp::IGNORECASE).should_not == 0
- (r.options & Regexp::MULTILINE).should == 0
- not_supported_on :opal do
- (r.options & Regexp::EXTENDED).should == 0
- end
- end
-
- it "ignores the third argument if it is 'e' or 'euc' (case-insensitive)" do
- -> {
- Regexp.send(@method, 'Hi', nil, 'e').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'euc').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'E').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'EUC').encoding.should == Encoding::US_ASCII
- }.should complain(/encoding option is ignored/)
- end
-
- it "ignores the third argument if it is 's' or 'sjis' (case-insensitive)" do
- -> {
- Regexp.send(@method, 'Hi', nil, 's').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'sjis').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'S').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'SJIS').encoding.should == Encoding::US_ASCII
- }.should complain(/encoding option is ignored/)
- end
-
- it "ignores the third argument if it is 'u' or 'utf8' (case-insensitive)" do
- -> {
- Regexp.send(@method, 'Hi', nil, 'u').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'utf8').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'U').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'UTF8').encoding.should == Encoding::US_ASCII
- }.should complain(/encoding option is ignored/)
- end
-
- it "uses US_ASCII encoding if third argument is 'n' or 'none' (case insensitive) and only ascii characters" do
- Regexp.send(@method, 'Hi', nil, 'n').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'none').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'N').encoding.should == Encoding::US_ASCII
- Regexp.send(@method, 'Hi', nil, 'NONE').encoding.should == Encoding::US_ASCII
- end
-
- it "uses ASCII_8BIT encoding if third argument is 'n' or 'none' (case insensitive) and non-ascii characters" do
- a = "(?:[\x8E\xA1-\xFE])"
- str = "\A(?:#{a}|x*)\z"
-
- Regexp.send(@method, str, nil, 'N').encoding.should == Encoding::BINARY
- Regexp.send(@method, str, nil, 'n').encoding.should == Encoding::BINARY
- Regexp.send(@method, str, nil, 'none').encoding.should == Encoding::BINARY
- Regexp.send(@method, str, nil, 'NONE').encoding.should == Encoding::BINARY
- end
-
- describe "with escaped characters" do
- it "raises a Regexp error if there is a trailing backslash" do
- -> { Regexp.send(@method, "\\") }.should raise_error(RegexpError)
- end
-
- it "does not raise a Regexp error if there is an escaped trailing backslash" do
- -> { Regexp.send(@method, "\\\\") }.should_not raise_error(RegexpError)
- end
-
- it "accepts a backspace followed by a character" do
- Regexp.send(@method, "\\N").should == /#{"\x5c"+"N"}/
- end
-
- it "accepts a one-digit octal value" do
- Regexp.send(@method, "\0").should == /#{"\x00"}/
- end
-
- it "accepts a two-digit octal value" do
- Regexp.send(@method, "\11").should == /#{"\x09"}/
- end
-
- it "accepts a one-digit hexadecimal value" do
- Regexp.send(@method, "\x9n").should == /#{"\x09n"}/
- end
-
- it "accepts a two-digit hexadecimal value" do
- Regexp.send(@method, "\x23").should == /#{"\x23"}/
- end
-
- it "interprets a digit following a two-digit hexadecimal value as a character" do
- Regexp.send(@method, "\x420").should == /#{"\x420"}/
- end
-
- it "raises a RegexpError if \\x is not followed by any hexadecimal digits" do
- -> { Regexp.send(@method, "\\" + "xn") }.should raise_error(RegexpError)
- end
-
- it "accepts an escaped string interpolation" do
- Regexp.send(@method, "\#{abc}").should == /#{"\#{abc}"}/
- end
-
- it "accepts '\\n'" do
- Regexp.send(@method, "\n").should == /#{"\x0a"}/
- end
-
- it "accepts '\\t'" do
- Regexp.send(@method, "\t").should == /#{"\x09"}/
- end
-
- it "accepts '\\r'" do
- Regexp.send(@method, "\r").should == /#{"\x0d"}/
- end
-
- it "accepts '\\f'" do
- Regexp.send(@method, "\f").should == /#{"\x0c"}/
- end
-
- it "accepts '\\v'" do
- Regexp.send(@method, "\v").should == /#{"\x0b"}/
- end
-
- it "accepts '\\a'" do
- Regexp.send(@method, "\a").should == /#{"\x07"}/
- end
-
- it "accepts '\\e'" do
- Regexp.send(@method, "\e").should == /#{"\x1b"}/
- end
-
- it "accepts '\\C-\\n'" do
- Regexp.send(@method, "\C-\n").should == /#{"\x0a"}/
- end
-
- it "accepts '\\C-\\t'" do
- Regexp.send(@method, "\C-\t").should == /#{"\x09"}/
- end
-
- it "accepts '\\C-\\r'" do
- Regexp.send(@method, "\C-\r").should == /#{"\x0d"}/
- end
-
- it "accepts '\\C-\\f'" do
- Regexp.send(@method, "\C-\f").should == /#{"\x0c"}/
- end
-
- it "accepts '\\C-\\v'" do
- Regexp.send(@method, "\C-\v").should == /#{"\x0b"}/
- end
-
- it "accepts '\\C-\\a'" do
- Regexp.send(@method, "\C-\a").should == /#{"\x07"}/
- end
-
- it "accepts '\\C-\\e'" do
- Regexp.send(@method, "\C-\e").should == /#{"\x1b"}/
- end
-
- it "accepts multiple consecutive '\\' characters" do
- Regexp.send(@method, "\\\\\\N").should == /#{"\\\\\\"+"N"}/
- end
-
- it "accepts characters and escaped octal digits" do
- Regexp.send(@method, "abc\076").should == /#{"abc\x3e"}/
- end
-
- it "accepts escaped octal digits and characters" do
- Regexp.send(@method, "\076abc").should == /#{"\x3eabc"}/
- end
-
- it "accepts characters and escaped hexadecimal digits" do
- Regexp.send(@method, "abc\x42").should == /#{"abc\x42"}/
- end
-
- it "accepts escaped hexadecimal digits and characters" do
- Regexp.send(@method, "\x3eabc").should == /#{"\x3eabc"}/
- end
-
- it "accepts escaped hexadecimal and octal digits" do
- Regexp.send(@method, "\061\x42").should == /#{"\x31\x42"}/
- end
-
- it "accepts \\u{H} for a single Unicode codepoint" do
- Regexp.send(@method, "\u{f}").should == /#{"\x0f"}/
- end
-
- it "accepts \\u{HH} for a single Unicode codepoint" do
- Regexp.send(@method, "\u{7f}").should == /#{"\x7f"}/
- end
-
- it "accepts \\u{HHH} for a single Unicode codepoint" do
- Regexp.send(@method, "\u{07f}").should == /#{"\x7f"}/
- end
-
- it "accepts \\u{HHHH} for a single Unicode codepoint" do
- Regexp.send(@method, "\u{0000}").should == /#{"\x00"}/
- end
-
- it "accepts \\u{HHHHH} for a single Unicode codepoint" do
- Regexp.send(@method, "\u{00001}").should == /#{"\x01"}/
- end
-
- it "accepts \\u{HHHHHH} for a single Unicode codepoint" do
- Regexp.send(@method, "\u{000000}").should == /#{"\x00"}/
- end
-
- it "accepts characters followed by \\u{HHHH}" do
- Regexp.send(@method, "abc\u{3042}").should == /#{"abc\u3042"}/
- end
-
- it "accepts \\u{HHHH} followed by characters" do
- Regexp.send(@method, "\u{3042}abc").should == /#{"\u3042abc"}/
- end
-
- it "accepts escaped hexadecimal digits followed by \\u{HHHH}" do
- Regexp.send(@method, "\x42\u{3042}").should == /#{"\x42\u3042"}/
- end
-
- it "accepts escaped octal digits followed by \\u{HHHH}" do
- Regexp.send(@method, "\056\u{3042}").should == /#{"\x2e\u3042"}/
- end
-
- it "accepts a combination of escaped octal and hexadecimal digits and \\u{HHHH}" do
- Regexp.send(@method, "\056\x42\u{3042}\x52\076").should == /#{"\x2e\x42\u3042\x52\x3e"}/
- end
-
- it "accepts \\uHHHH for a single Unicode codepoint" do
- Regexp.send(@method, "\u3042").should == /#{"\u3042"}/
- end
-
- it "accepts characters followed by \\uHHHH" do
- Regexp.send(@method, "abc\u3042").should == /#{"abc\u3042"}/
- end
-
- it "accepts \\uHHHH followed by characters" do
- Regexp.send(@method, "\u3042abc").should == /#{"\u3042abc"}/
- end
-
- it "accepts escaped hexadecimal digits followed by \\uHHHH" do
- Regexp.send(@method, "\x42\u3042").should == /#{"\x42\u3042"}/
- end
-
- it "accepts escaped octal digits followed by \\uHHHH" do
- Regexp.send(@method, "\056\u3042").should == /#{"\x2e\u3042"}/
- end
-
- it "accepts a combination of escaped octal and hexadecimal digits and \\uHHHH" do
- Regexp.send(@method, "\056\x42\u3042\x52\076").should == /#{"\x2e\x42\u3042\x52\x3e"}/
- end
-
- it "raises a RegexpError if less than four digits are given for \\uHHHH" do
- -> { Regexp.send(@method, "\\" + "u304") }.should raise_error(RegexpError)
- end
-
- it "raises a RegexpError if the \\u{} escape is empty" do
- -> { Regexp.send(@method, "\\" + "u{}") }.should raise_error(RegexpError)
- end
-
- it "raises a RegexpError if more than six hexadecimal digits are given" do
- -> { Regexp.send(@method, "\\" + "u{0ffffff}") }.should raise_error(RegexpError)
- end
-
- it "returns a Regexp with US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do
- Regexp.send(@method, "abc").encoding.should == Encoding::US_ASCII
- end
-
- it "returns a Regexp with source String having US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do
- Regexp.send(@method, "abc").source.encoding.should == Encoding::US_ASCII
- end
-
- it "returns a Regexp with US-ASCII encoding if UTF-8 escape sequences using only 7-bit ASCII are present" do
- Regexp.send(@method, "\u{61}").encoding.should == Encoding::US_ASCII
- end
-
- it "returns a Regexp with source String having US-ASCII encoding if UTF-8 escape sequences using only 7-bit ASCII are present" do
- Regexp.send(@method, "\u{61}").source.encoding.should == Encoding::US_ASCII
- end
-
- it "returns a Regexp with UTF-8 encoding if any UTF-8 escape sequences outside 7-bit ASCII are present" do
- Regexp.send(@method, "\u{ff}").encoding.should == Encoding::UTF_8
- end
-
- it "returns a Regexp with source String having UTF-8 encoding if any UTF-8 escape sequences outside 7-bit ASCII are present" do
- Regexp.send(@method, "\u{ff}").source.encoding.should == Encoding::UTF_8
- end
-
- it "returns a Regexp with the input String's encoding" do
- str = "\x82\xa0".force_encoding(Encoding::Shift_JIS)
- Regexp.send(@method, str).encoding.should == Encoding::Shift_JIS
- end
-
- it "returns a Regexp with source String having the input String's encoding" do
- str = "\x82\xa0".force_encoding(Encoding::Shift_JIS)
- Regexp.send(@method, str).source.encoding.should == Encoding::Shift_JIS
- end
- end
-end
-
-describe :regexp_new_string_binary, shared: true do
- describe "with escaped characters" do
- it "accepts a three-digit octal value" do
- Regexp.send(@method, "\315").should == /#{"\xcd"}/
- end
-
- it "interprets a digit following a three-digit octal value as a character" do
- Regexp.send(@method, "\3762").should == /#{"\xfe2"}/
- end
-
- it "accepts '\\M-\\n'" do
- Regexp.send(@method, "\M-\n").should == /#{"\x8a"}/
- end
-
- it "accepts '\\M-\\t'" do
- Regexp.send(@method, "\M-\t").should == /#{"\x89"}/
- end
-
- it "accepts '\\M-\\r'" do
- Regexp.send(@method, "\M-\r").should == /#{"\x8d"}/
- end
-
- it "accepts '\\M-\\f'" do
- Regexp.send(@method, "\M-\f").should == /#{"\x8c"}/
- end
-
- it "accepts '\\M-\\v'" do
- Regexp.send(@method, "\M-\v").should == /#{"\x8b"}/
- end
-
- it "accepts '\\M-\\a'" do
- Regexp.send(@method, "\M-\a").should == /#{"\x87"}/
- end
-
- it "accepts '\\M-\\e'" do
- Regexp.send(@method, "\M-\e").should == /#{"\x9b"}/
- end
-
- it "accepts '\\M-\\C-\\n'" do
- Regexp.send(@method, "\M-\C-\n").should == /#{"\x8a"}/
- end
-
- it "accepts '\\M-\\C-\\t'" do
- Regexp.send(@method, "\M-\C-\t").should == /#{"\x89"}/
- end
-
- it "accepts '\\M-\\C-\\r'" do
- Regexp.send(@method, "\M-\C-\r").should == /#{"\x8d"}/
- end
-
- it "accepts '\\M-\\C-\\f'" do
- Regexp.send(@method, "\M-\C-\f").should == /#{"\x8c"}/
- end
-
- it "accepts '\\M-\\C-\\v'" do
- Regexp.send(@method, "\M-\C-\v").should == /#{"\x8b"}/
- end
-
- it "accepts '\\M-\\C-\\a'" do
- Regexp.send(@method, "\M-\C-\a").should == /#{"\x87"}/
- end
-
- it "accepts '\\M-\\C-\\e'" do
- Regexp.send(@method, "\M-\C-\e").should == /#{"\x9b"}/
- end
- end
-end
-
-describe :regexp_new_regexp, shared: true do
- it "uses the argument as a literal to construct a Regexp object" do
- Regexp.send(@method, /^hi{2,3}fo.o$/).should == /^hi{2,3}fo.o$/
- end
-
- it "preserves any options given in the Regexp literal" do
- (Regexp.send(@method, /Hi/i).options & Regexp::IGNORECASE).should_not == 0
- (Regexp.send(@method, /Hi/m).options & Regexp::MULTILINE).should_not == 0
- not_supported_on :opal do
- (Regexp.send(@method, /Hi/x).options & Regexp::EXTENDED).should_not == 0
- end
-
- not_supported_on :opal do
- r = Regexp.send @method, /Hi/imx
- (r.options & Regexp::IGNORECASE).should_not == 0
- (r.options & Regexp::MULTILINE).should_not == 0
- (r.options & Regexp::EXTENDED).should_not == 0
- end
-
- r = Regexp.send @method, /Hi/
- (r.options & Regexp::IGNORECASE).should == 0
- (r.options & Regexp::MULTILINE).should == 0
- not_supported_on :opal do
- (r.options & Regexp::EXTENDED).should == 0
- end
- end
-
- it "does not honour options given as additional arguments" do
- r = nil
- -> {
- r = Regexp.send @method, /hi/, Regexp::IGNORECASE
- }.should complain(/flags ignored/)
- (r.options & Regexp::IGNORECASE).should == 0
- end
-
- not_supported_on :opal do
- it "sets the encoding to UTF-8 if the Regexp literal has the 'u' option" do
- Regexp.send(@method, /Hi/u).encoding.should == Encoding::UTF_8
- end
-
- it "sets the encoding to EUC-JP if the Regexp literal has the 'e' option" do
- Regexp.send(@method, /Hi/e).encoding.should == Encoding::EUC_JP
- end
-
- it "sets the encoding to Windows-31J if the Regexp literal has the 's' option" do
- Regexp.send(@method, /Hi/s).encoding.should == Encoding::Windows_31J
- end
-
- it "sets the encoding to US-ASCII if the Regexp literal has the 'n' option and the source String is ASCII only" do
- Regexp.send(@method, /Hi/n).encoding.should == Encoding::US_ASCII
- end
-
- it "sets the encoding to source String's encoding if the Regexp literal has the 'n' option and the source String is not ASCII only" do
- Regexp.send(@method, Regexp.new("\\xff", nil, 'n')).encoding.should == Encoding::BINARY
- end
- end
-end
diff --git a/spec/ruby/core/regexp/shared/new_ascii.rb b/spec/ruby/core/regexp/shared/new_ascii.rb
new file mode 100644
index 0000000000..98c458312e
--- /dev/null
+++ b/spec/ruby/core/regexp/shared/new_ascii.rb
@@ -0,0 +1,464 @@
+# -*- encoding: binary -*-
+describe :regexp_new_ascii, shared: true do
+ it "requires one argument and creates a new regular expression object" do
+ Regexp.send(@method, '').is_a?(Regexp).should == true
+ end
+
+ it "works by default for subclasses with overridden #initialize" do
+ class RegexpSpecsSubclass < Regexp
+ def initialize(*args)
+ super
+ @args = args
+ end
+
+ attr_accessor :args
+ end
+
+ class RegexpSpecsSubclassTwo < Regexp; end
+
+ RegexpSpecsSubclass.send(@method, "hi").should be_kind_of(RegexpSpecsSubclass)
+ RegexpSpecsSubclass.send(@method, "hi").args.first.should == "hi"
+
+ RegexpSpecsSubclassTwo.send(@method, "hi").should be_kind_of(RegexpSpecsSubclassTwo)
+ end
+end
+
+describe :regexp_new_string_ascii, shared: true do
+ it "uses the String argument as an unescaped literal to construct a Regexp object" do
+ Regexp.send(@method, "^hi{2,3}fo.o$").should == /^hi{2,3}fo.o$/
+ end
+
+ it "raises a RegexpError when passed an incorrect regexp" do
+ lambda { Regexp.send(@method, "^[$", 0) }.should raise_error(RegexpError)
+ end
+
+ it "does not set Regexp options if only given one argument" do
+ r = Regexp.send(@method, 'Hi')
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "does not set Regexp options if second argument is nil or false" do
+ r = Regexp.send(@method, 'Hi', nil)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+
+ r = Regexp.send(@method, 'Hi', false)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "sets options from second argument if it is one of the Fixnum option constants" do
+ r = Regexp.send(@method, 'Hi', Regexp::IGNORECASE)
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+
+ r = Regexp.send(@method, 'Hi', Regexp::MULTILINE)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should_not == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+
+ not_supported_on :opal do
+ r = Regexp.send(@method, 'Hi', Regexp::EXTENDED)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ (r.options & Regexp::EXTENDED).should_not == 1
+ end
+ end
+
+ it "accepts a Fixnum of two or more options ORed together as the second argument" do
+ r = Regexp.send(@method, 'Hi', Regexp::IGNORECASE | Regexp::EXTENDED)
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ (r.options & Regexp::EXTENDED).should_not == 0
+ end
+
+ it "treats any non-Fixnum, non-nil, non-false second argument as IGNORECASE" do
+ r = Regexp.send(@method, 'Hi', Object.new)
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "ignores the third argument if it is 'e' or 'euc' (case-insensitive)" do
+ lambda {
+ Regexp.send(@method, 'Hi', nil, 'e').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'euc').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'E').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'EUC').encoding.should == Encoding::US_ASCII
+ }.should complain(/encoding option is ignored/)
+ end
+
+ it "ignores the third argument if it is 's' or 'sjis' (case-insensitive)" do
+ lambda {
+ Regexp.send(@method, 'Hi', nil, 's').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'sjis').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'S').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'SJIS').encoding.should == Encoding::US_ASCII
+ }.should complain(/encoding option is ignored/)
+ end
+
+ it "ignores the third argument if it is 'u' or 'utf8' (case-insensitive)" do
+ lambda {
+ Regexp.send(@method, 'Hi', nil, 'u').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'utf8').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'U').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'UTF8').encoding.should == Encoding::US_ASCII
+ }.should complain(/encoding option is ignored/)
+ end
+
+ it "uses US_ASCII encoding if third argument is 'n' or 'none' (case insensitive) and only ascii characters" do
+ Regexp.send(@method, 'Hi', nil, 'n').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'none').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'N').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'NONE').encoding.should == Encoding::US_ASCII
+ end
+
+ it "uses ASCII_8BIT encoding if third argument is 'n' or 'none' (case insensitive) and non-ascii characters" do
+ a = "(?:[\x8E\xA1-\xFE])"
+ str = "\A(?:#{a}|x*)\z"
+
+ Regexp.send(@method, str, nil, 'N').encoding.should == Encoding::ASCII_8BIT
+ Regexp.send(@method, str, nil, 'n').encoding.should == Encoding::ASCII_8BIT
+ Regexp.send(@method, str, nil, 'none').encoding.should == Encoding::ASCII_8BIT
+ Regexp.send(@method, str, nil, 'NONE').encoding.should == Encoding::ASCII_8BIT
+ end
+
+ describe "with escaped characters" do
+ it "raises a Regexp error if there is a trailing backslash" do
+ lambda { Regexp.send(@method, "\\") }.should raise_error(RegexpError)
+ end
+
+ it "does not raise a Regexp error if there is an escaped trailing backslash" do
+ lambda { Regexp.send(@method, "\\\\") }.should_not raise_error(RegexpError)
+ end
+
+ it "accepts a backspace followed by a character" do
+ Regexp.send(@method, "\\N").should == /#{"\x5c"+"N"}/
+ end
+
+ it "accepts a one-digit octal value" do
+ Regexp.send(@method, "\0").should == /#{"\x00"}/
+ end
+
+ it "accepts a two-digit octal value" do
+ Regexp.send(@method, "\11").should == /#{"\x09"}/
+ end
+
+ it "accepts a one-digit hexadecimal value" do
+ Regexp.send(@method, "\x9n").should == /#{"\x09n"}/
+ end
+
+ it "accepts a two-digit hexadecimal value" do
+ Regexp.send(@method, "\x23").should == /#{"\x23"}/
+ end
+
+ it "interprets a digit following a two-digit hexadecimal value as a character" do
+ Regexp.send(@method, "\x420").should == /#{"\x420"}/
+ end
+
+ it "raises a RegexpError if \\x is not followed by any hexadecimal digits" do
+ lambda { Regexp.send(@method, "\\" + "xn") }.should raise_error(RegexpError)
+ end
+
+ it "accepts an escaped string interpolation" do
+ Regexp.send(@method, "\#{abc}").should == /#{"\#{abc}"}/
+ end
+
+ it "accepts '\\n'" do
+ Regexp.send(@method, "\n").should == /#{"\x0a"}/
+ end
+
+ it "accepts '\\t'" do
+ Regexp.send(@method, "\t").should == /#{"\x09"}/
+ end
+
+ it "accepts '\\r'" do
+ Regexp.send(@method, "\r").should == /#{"\x0d"}/
+ end
+
+ it "accepts '\\f'" do
+ Regexp.send(@method, "\f").should == /#{"\x0c"}/
+ end
+
+ it "accepts '\\v'" do
+ Regexp.send(@method, "\v").should == /#{"\x0b"}/
+ end
+
+ it "accepts '\\a'" do
+ Regexp.send(@method, "\a").should == /#{"\x07"}/
+ end
+
+ it "accepts '\\e'" do
+ Regexp.send(@method, "\e").should == /#{"\x1b"}/
+ end
+
+ it "accepts '\\C-\\n'" do
+ Regexp.send(@method, "\C-\n").should == /#{"\x0a"}/
+ end
+
+ it "accepts '\\C-\\t'" do
+ Regexp.send(@method, "\C-\t").should == /#{"\x09"}/
+ end
+
+ it "accepts '\\C-\\r'" do
+ Regexp.send(@method, "\C-\r").should == /#{"\x0d"}/
+ end
+
+ it "accepts '\\C-\\f'" do
+ Regexp.send(@method, "\C-\f").should == /#{"\x0c"}/
+ end
+
+ it "accepts '\\C-\\v'" do
+ Regexp.send(@method, "\C-\v").should == /#{"\x0b"}/
+ end
+
+ it "accepts '\\C-\\a'" do
+ Regexp.send(@method, "\C-\a").should == /#{"\x07"}/
+ end
+
+ it "accepts '\\C-\\e'" do
+ Regexp.send(@method, "\C-\e").should == /#{"\x1b"}/
+ end
+
+ it "accepts '\\c\\n'" do
+ Regexp.send(@method, "\C-\n").should == /#{"\x0a"}/
+ end
+
+ it "accepts '\\c\\t'" do
+ Regexp.send(@method, "\C-\t").should == /#{"\x09"}/
+ end
+
+ it "accepts '\\c\\r'" do
+ Regexp.send(@method, "\C-\r").should == /#{"\x0d"}/
+ end
+
+ it "accepts '\\c\\f'" do
+ Regexp.send(@method, "\C-\f").should == /#{"\x0c"}/
+ end
+
+ it "accepts '\\c\\v'" do
+ Regexp.send(@method, "\C-\v").should == /#{"\x0b"}/
+ end
+
+ it "accepts '\\c\\a'" do
+ Regexp.send(@method, "\C-\a").should == /#{"\x07"}/
+ end
+
+ it "accepts '\\c\\e'" do
+ Regexp.send(@method, "\C-\e").should == /#{"\x1b"}/
+ end
+
+ it "accepts multiple consecutive '\\' characters" do
+ Regexp.send(@method, "\\\\\\N").should == /#{"\\\\\\"+"N"}/
+ end
+
+ it "accepts characters and escaped octal digits" do
+ Regexp.send(@method, "abc\076").should == /#{"abc\x3e"}/
+ end
+
+ it "accepts escaped octal digits and characters" do
+ Regexp.send(@method, "\076abc").should == /#{"\x3eabc"}/
+ end
+
+ it "accepts characters and escaped hexadecimal digits" do
+ Regexp.send(@method, "abc\x42").should == /#{"abc\x42"}/
+ end
+
+ it "accepts escaped hexadecimal digits and characters" do
+ Regexp.send(@method, "\x3eabc").should == /#{"\x3eabc"}/
+ end
+
+ it "accepts escaped hexadecimal and octal digits" do
+ Regexp.send(@method, "\061\x42").should == /#{"\x31\x42"}/
+ end
+
+ it "accepts \\u{H} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{f}").should == /#{"\x0f"}/
+ end
+
+ it "accepts \\u{HH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{7f}").should == /#{"\x7f"}/
+ end
+
+ it "accepts \\u{HHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{07f}").should == /#{"\x7f"}/
+ end
+
+ it "accepts \\u{HHHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{0000}").should == /#{"\x00"}/
+ end
+
+ it "accepts \\u{HHHHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{00001}").should == /#{"\x01"}/
+ end
+
+ it "accepts \\u{HHHHHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{000000}").should == /#{"\x00"}/
+ end
+
+ it "accepts characters followed by \\u{HHHH}" do
+ Regexp.send(@method, "abc\u{3042}").should == /#{"abc\u3042"}/
+ end
+
+ it "accepts \\u{HHHH} followed by characters" do
+ Regexp.send(@method, "\u{3042}abc").should == /#{"\u3042abc"}/
+ end
+
+ it "accepts escaped hexadecimal digits followed by \\u{HHHH}" do
+ Regexp.send(@method, "\x42\u{3042}").should == /#{"\x42\u3042"}/
+ end
+
+ it "accepts escaped octal digits followed by \\u{HHHH}" do
+ Regexp.send(@method, "\056\u{3042}").should == /#{"\x2e\u3042"}/
+ end
+
+ it "accepts a combination of escaped octal and hexadecimal digits and \\u{HHHH}" do
+ Regexp.send(@method, "\056\x42\u{3042}\x52\076").should == /#{"\x2e\x42\u3042\x52\x3e"}/
+ end
+
+ it "accepts \\uHHHH for a single Unicode codepoint" do
+ Regexp.send(@method, "\u3042").should == /#{"\u3042"}/
+ end
+
+ it "accepts characters followed by \\uHHHH" do
+ Regexp.send(@method, "abc\u3042").should == /#{"abc\u3042"}/
+ end
+
+ it "accepts \\uHHHH followed by characters" do
+ Regexp.send(@method, "\u3042abc").should == /#{"\u3042abc"}/
+ end
+
+ it "accepts escaped hexadecimal digits followed by \\uHHHH" do
+ Regexp.send(@method, "\x42\u3042").should == /#{"\x42\u3042"}/
+ end
+
+ it "accepts escaped octal digits followed by \\uHHHH" do
+ Regexp.send(@method, "\056\u3042").should == /#{"\x2e\u3042"}/
+ end
+
+ it "accepts a combination of escaped octal and hexadecimal digits and \\uHHHH" do
+ Regexp.send(@method, "\056\x42\u3042\x52\076").should == /#{"\x2e\x42\u3042\x52\x3e"}/
+ end
+
+ it "raises a RegexpError if less than four digits are given for \\uHHHH" do
+ lambda { Regexp.send(@method, "\\" + "u304") }.should raise_error(RegexpError)
+ end
+
+ it "raises a RegexpError if the \\u{} escape is empty" do
+ lambda { Regexp.send(@method, "\\" + "u{}") }.should raise_error(RegexpError)
+ end
+
+ it "raises a RegexpError if more than six hexadecimal digits are given" do
+ lambda { Regexp.send(@method, "\\" + "u{0ffffff}") }.should raise_error(RegexpError)
+ end
+
+ it "returns a Regexp with US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do
+ Regexp.send(@method, "abc").encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with source String having US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do
+ Regexp.send(@method, "abc").source.encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with US-ASCII encoding if UTF-8 escape sequences using only 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{61}").encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with source String having US-ASCII encoding if UTF-8 escape sequences using only 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{61}").source.encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with UTF-8 encoding if any UTF-8 escape sequences outside 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{ff}").encoding.should == Encoding::UTF_8
+ end
+
+ it "returns a Regexp with source String having UTF-8 encoding if any UTF-8 escape sequences outside 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{ff}").source.encoding.should == Encoding::UTF_8
+ end
+
+ it "returns a Regexp with the input String's encoding" do
+ str = "\x82\xa0".force_encoding(Encoding::Shift_JIS)
+ Regexp.send(@method, str).encoding.should == Encoding::Shift_JIS
+ end
+
+ it "returns a Regexp with source String having the input String's encoding" do
+ str = "\x82\xa0".force_encoding(Encoding::Shift_JIS)
+ Regexp.send(@method, str).source.encoding.should == Encoding::Shift_JIS
+ end
+ end
+end
+
+describe :regexp_new_regexp_ascii, shared: true do
+ it "uses the argument as a literal to construct a Regexp object" do
+ Regexp.send(@method, /^hi{2,3}fo.o$/).should == /^hi{2,3}fo.o$/
+ end
+
+ it "preserves any options given in the Regexp literal" do
+ (Regexp.send(@method, /Hi/i).options & Regexp::IGNORECASE).should_not == 0
+ (Regexp.send(@method, /Hi/m).options & Regexp::MULTILINE).should_not == 0
+ not_supported_on :opal do
+ (Regexp.send(@method, /Hi/x).options & Regexp::EXTENDED).should_not == 0
+ end
+
+ not_supported_on :opal do
+ r = Regexp.send @method, /Hi/imx
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should_not == 0
+ (r.options & Regexp::EXTENDED).should_not == 0
+ end
+
+ r = Regexp.send @method, /Hi/
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "does not honour options given as additional arguments" do
+ r = nil
+ lambda {
+ r = Regexp.send @method, /hi/, Regexp::IGNORECASE
+ }.should complain(/flags ignored/)
+ (r.options & Regexp::IGNORECASE).should == 0
+ end
+
+ not_supported_on :opal do
+ it "sets the encoding to UTF-8 if the Regexp literal has the 'u' option" do
+ Regexp.send(@method, /Hi/u).encoding.should == Encoding::UTF_8
+ end
+
+ it "sets the encoding to EUC-JP if the Regexp literal has the 'e' option" do
+ Regexp.send(@method, /Hi/e).encoding.should == Encoding::EUC_JP
+ end
+
+ it "sets the encoding to Windows-31J if the Regexp literal has the 's' option" do
+ Regexp.send(@method, /Hi/s).encoding.should == Encoding::Windows_31J
+ end
+
+ it "sets the encoding to US-ASCII if the Regexp literal has the 'n' option and the source String is ASCII only" do
+ Regexp.send(@method, /Hi/n).encoding.should == Encoding::US_ASCII
+ end
+
+ it "sets the encoding to source String's encoding if the Regexp literal has the 'n' option and the source String is not ASCII only" do
+ Regexp.send(@method, Regexp.new("\\xff", nil, 'n')).encoding.should == Encoding::ASCII_8BIT
+ end
+ end
+end
diff --git a/spec/ruby/core/regexp/shared/new_ascii_8bit.rb b/spec/ruby/core/regexp/shared/new_ascii_8bit.rb
new file mode 100644
index 0000000000..5110a08380
--- /dev/null
+++ b/spec/ruby/core/regexp/shared/new_ascii_8bit.rb
@@ -0,0 +1,553 @@
+# -*- encoding: ascii-8bit -*-
+
+describe :regexp_new_ascii_8bit, shared: true do
+ it "requires one argument and creates a new regular expression object" do
+ Regexp.send(@method, '').is_a?(Regexp).should == true
+ end
+
+ it "works by default for subclasses with overridden #initialize" do
+ class RegexpSpecsSubclass < Regexp
+ def initialize(*args)
+ super
+ @args = args
+ end
+
+ attr_accessor :args
+ end
+
+ class RegexpSpecsSubclassTwo < Regexp; end
+
+ RegexpSpecsSubclass.send(@method, "hi").should be_kind_of(RegexpSpecsSubclass)
+ RegexpSpecsSubclass.send(@method, "hi").args.first.should == "hi"
+
+ RegexpSpecsSubclassTwo.send(@method, "hi").should be_kind_of(RegexpSpecsSubclassTwo)
+ end
+end
+
+describe :regexp_new_string_ascii_8bit, shared: true do
+ it "uses the String argument as an unescaped literal to construct a Regexp object" do
+ Regexp.send(@method, "^hi{2,3}fo.o$").should == /^hi{2,3}fo.o$/
+ end
+
+ it "raises a RegexpError when passed an incorrect regexp" do
+ lambda { Regexp.send(@method, "^[$", 0) }.should raise_error(RegexpError)
+ end
+
+ it "does not set Regexp options if only given one argument" do
+ r = Regexp.send(@method, 'Hi')
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "does not set Regexp options if second argument is nil or false" do
+ r = Regexp.send(@method, 'Hi', nil)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+
+ r = Regexp.send(@method, 'Hi', false)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "sets options from second argument if it is one of the Fixnum option constants" do
+ r = Regexp.send(@method, 'Hi', Regexp::IGNORECASE)
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+
+ r = Regexp.send(@method, 'Hi', Regexp::MULTILINE)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should_not == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+
+ not_supported_on :opal do
+ r = Regexp.send(@method, 'Hi', Regexp::EXTENDED)
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ (r.options & Regexp::EXTENDED).should_not == 1
+ end
+ end
+
+ it "accepts a Fixnum of two or more options ORed together as the second argument" do
+ r = Regexp.send(@method, 'Hi', Regexp::IGNORECASE | Regexp::EXTENDED)
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ (r.options & Regexp::EXTENDED).should_not == 0
+ end
+
+ it "treats any non-Fixnum, non-nil, non-false second argument as IGNORECASE" do
+ r = Regexp.send(@method, 'Hi', Object.new)
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "ignores the third argument if it is 'e' or 'euc' (case-insensitive)" do
+ lambda {
+ Regexp.send(@method, 'Hi', nil, 'e').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'euc').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'E').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'EUC').encoding.should == Encoding::US_ASCII
+ }.should complain(/encoding option is ignored/)
+ end
+
+ it "ignores the third argument if it is 's' or 'sjis' (case-insensitive)" do
+ lambda {
+ Regexp.send(@method, 'Hi', nil, 's').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'sjis').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'S').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'SJIS').encoding.should == Encoding::US_ASCII
+ }.should complain(/encoding option is ignored/)
+ end
+
+ it "ignores the third argument if it is 'u' or 'utf8' (case-insensitive)" do
+ lambda {
+ Regexp.send(@method, 'Hi', nil, 'u').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'utf8').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'U').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'UTF8').encoding.should == Encoding::US_ASCII
+ }.should complain(/encoding option is ignored/)
+ end
+
+ it "uses US_ASCII encoding if third argument is 'n' or 'none' (case insensitive) and only ascii characters" do
+ Regexp.send(@method, 'Hi', nil, 'n').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'none').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'N').encoding.should == Encoding::US_ASCII
+ Regexp.send(@method, 'Hi', nil, 'NONE').encoding.should == Encoding::US_ASCII
+ end
+
+ it "uses ASCII_8BIT encoding if third argument is 'n' or 'none' (case insensitive) and non-ascii characters" do
+ a = "(?:[\x8E\xA1-\xFE])"
+ str = "\A(?:#{a}|x*)\z"
+
+ Regexp.send(@method, str, nil, 'N').encoding.should == Encoding::ASCII_8BIT
+ Regexp.send(@method, str, nil, 'n').encoding.should == Encoding::ASCII_8BIT
+ Regexp.send(@method, str, nil, 'none').encoding.should == Encoding::ASCII_8BIT
+ Regexp.send(@method, str, nil, 'NONE').encoding.should == Encoding::ASCII_8BIT
+ end
+
+ describe "with escaped characters" do
+ it "raises a Regexp error if there is a trailing backslash" do
+ lambda { Regexp.send(@method, "\\") }.should raise_error(RegexpError)
+ end
+
+ it "accepts a backspace followed by a character" do
+ Regexp.send(@method, "\\N").should == /#{"\x5c"+"N"}/
+ end
+
+ it "accepts a one-digit octal value" do
+ Regexp.send(@method, "\0").should == /#{"\x00"}/
+ end
+
+ it "accepts a two-digit octal value" do
+ Regexp.send(@method, "\11").should == /#{"\x09"}/
+ end
+
+ it "accepts a three-digit octal value" do
+ Regexp.send(@method, "\315").should == /#{"\xcd"}/
+ end
+
+ it "interprets a digit following a three-digit octal value as a character" do
+ Regexp.send(@method, "\3762").should == /#{"\xfe2"}/
+ end
+
+ it "accepts a one-digit hexadecimal value" do
+ Regexp.send(@method, "\x9n").should == /#{"\x09n"}/
+ end
+
+ it "accepts a two-digit hexadecimal value" do
+ Regexp.send(@method, "\x23").should == /#{"\x23"}/
+ end
+
+ it "interprets a digit following a two-digit hexadecimal value as a character" do
+ Regexp.send(@method, "\x420").should == /#{"\x420"}/
+ end
+
+ it "raises a RegexpError if \\x is not followed by any hexadecimal digits" do
+ lambda { Regexp.send(@method, "\\" + "xn") }.should raise_error(RegexpError)
+ end
+
+ it "accepts an escaped string interpolation" do
+ Regexp.send(@method, "\#{abc}").should == /#{"\#{abc}"}/
+ end
+
+ it "accepts '\\n'" do
+ Regexp.send(@method, "\n").should == /#{"\x0a"}/
+ end
+
+ it "accepts '\\t'" do
+ Regexp.send(@method, "\t").should == /#{"\x09"}/
+ end
+
+ it "accepts '\\r'" do
+ Regexp.send(@method, "\r").should == /#{"\x0d"}/
+ end
+
+ it "accepts '\\f'" do
+ Regexp.send(@method, "\f").should == /#{"\x0c"}/
+ end
+
+ it "accepts '\\v'" do
+ Regexp.send(@method, "\v").should == /#{"\x0b"}/
+ end
+
+ it "accepts '\\a'" do
+ Regexp.send(@method, "\a").should == /#{"\x07"}/
+ end
+
+ it "accepts '\\e'" do
+ Regexp.send(@method, "\e").should == /#{"\x1b"}/
+ end
+
+ it "accepts '\\C-\\n'" do
+ Regexp.send(@method, "\C-\n").should == /#{"\x0a"}/
+ end
+
+ it "accepts '\\C-\\t'" do
+ Regexp.send(@method, "\C-\t").should == /#{"\x09"}/
+ end
+
+ it "accepts '\\C-\\r'" do
+ Regexp.send(@method, "\C-\r").should == /#{"\x0d"}/
+ end
+
+ it "accepts '\\C-\\f'" do
+ Regexp.send(@method, "\C-\f").should == /#{"\x0c"}/
+ end
+
+ it "accepts '\\C-\\v'" do
+ Regexp.send(@method, "\C-\v").should == /#{"\x0b"}/
+ end
+
+ it "accepts '\\C-\\a'" do
+ Regexp.send(@method, "\C-\a").should == /#{"\x07"}/
+ end
+
+ it "accepts '\\C-\\e'" do
+ Regexp.send(@method, "\C-\e").should == /#{"\x1b"}/
+ end
+
+ it "accepts '\\c\\n'" do
+ Regexp.send(@method, "\C-\n").should == /#{"\x0a"}/
+ end
+
+ it "accepts '\\c\\t'" do
+ Regexp.send(@method, "\C-\t").should == /#{"\x09"}/
+ end
+
+ it "accepts '\\c\\r'" do
+ Regexp.send(@method, "\C-\r").should == /#{"\x0d"}/
+ end
+
+ it "accepts '\\c\\f'" do
+ Regexp.send(@method, "\C-\f").should == /#{"\x0c"}/
+ end
+
+ it "accepts '\\c\\v'" do
+ Regexp.send(@method, "\C-\v").should == /#{"\x0b"}/
+ end
+
+ it "accepts '\\c\\a'" do
+ Regexp.send(@method, "\C-\a").should == /#{"\x07"}/
+ end
+
+ it "accepts '\\c\\e'" do
+ Regexp.send(@method, "\C-\e").should == /#{"\x1b"}/
+ end
+
+ it "accepts '\\M-\\n'" do
+ Regexp.send(@method, "\M-\n").should == /#{"\x8a"}/
+ end
+
+ it "accepts '\\M-\\t'" do
+ Regexp.send(@method, "\M-\t").should == /#{"\x89"}/
+ end
+
+ it "accepts '\\M-\\r'" do
+ Regexp.send(@method, "\M-\r").should == /#{"\x8d"}/
+ end
+
+ it "accepts '\\M-\\f'" do
+ Regexp.send(@method, "\M-\f").should == /#{"\x8c"}/
+ end
+
+ it "accepts '\\M-\\v'" do
+ Regexp.send(@method, "\M-\v").should == /#{"\x8b"}/
+ end
+
+ it "accepts '\\M-\\a'" do
+ Regexp.send(@method, "\M-\a").should == /#{"\x87"}/
+ end
+
+ it "accepts '\\M-\\e'" do
+ Regexp.send(@method, "\M-\e").should == /#{"\x9b"}/
+ end
+
+ it "accepts '\\M-\\C-\\n'" do
+ Regexp.send(@method, "\M-\n").should == /#{"\x8a"}/
+ end
+
+ it "accepts '\\M-\\C-\\t'" do
+ Regexp.send(@method, "\M-\t").should == /#{"\x89"}/
+ end
+
+ it "accepts '\\M-\\C-\\r'" do
+ Regexp.send(@method, "\M-\r").should == /#{"\x8d"}/
+ end
+
+ it "accepts '\\M-\\C-\\f'" do
+ Regexp.send(@method, "\M-\f").should == /#{"\x8c"}/
+ end
+
+ it "accepts '\\M-\\C-\\v'" do
+ Regexp.send(@method, "\M-\v").should == /#{"\x8b"}/
+ end
+
+ it "accepts '\\M-\\C-\\a'" do
+ Regexp.send(@method, "\M-\a").should == /#{"\x87"}/
+ end
+
+ it "accepts '\\M-\\C-\\e'" do
+ Regexp.send(@method, "\M-\e").should == /#{"\x9b"}/
+ end
+
+ it "accepts '\\M-\\c\\n'" do
+ Regexp.send(@method, "\M-\n").should == /#{"\x8a"}/
+ end
+
+ it "accepts '\\M-\\c\\t'" do
+ Regexp.send(@method, "\M-\t").should == /#{"\x89"}/
+ end
+
+ it "accepts '\\M-\\c\\r'" do
+ Regexp.send(@method, "\M-\r").should == /#{"\x8d"}/
+ end
+
+ it "accepts '\\M-\\c\\f'" do
+ Regexp.send(@method, "\M-\f").should == /#{"\x8c"}/
+ end
+
+ it "accepts '\\M-\\c\\v'" do
+ Regexp.send(@method, "\M-\v").should == /#{"\x8b"}/
+ end
+
+ it "accepts '\\M-\\c\\a'" do
+ Regexp.send(@method, "\M-\a").should == /#{"\x87"}/
+ end
+
+ it "accepts '\\M-\\c\\e'" do
+ Regexp.send(@method, "\M-\e").should == /#{"\x9b"}/
+ end
+
+ it "accepts multiple consecutive '\\' characters" do
+ Regexp.send(@method, "\\\\\\N").should == /#{"\\\\\\"+"N"}/
+ end
+
+ it "accepts characters and escaped octal digits" do
+ Regexp.send(@method, "abc\076").should == /#{"abc\x3e"}/
+ end
+
+ it "accepts escaped octal digits and characters" do
+ Regexp.send(@method, "\076abc").should == /#{"\x3eabc"}/
+ end
+
+ it "accepts characters and escaped hexadecimal digits" do
+ Regexp.send(@method, "abc\x42").should == /#{"abc\x42"}/
+ end
+
+ it "accepts escaped hexadecimal digits and characters" do
+ Regexp.send(@method, "\x3eabc").should == /#{"\x3eabc"}/
+ end
+
+ it "accepts escaped hexadecimal and octal digits" do
+ Regexp.send(@method, "\061\x42").should == /#{"\x31\x42"}/
+ end
+
+ it "accepts \\u{H} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{f}").should == /#{"\x0f"}/
+ end
+
+ it "accepts \\u{HH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{7f}").should == /#{"\x7f"}/
+ end
+
+ it "accepts \\u{HHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{07f}").should == /#{"\x7f"}/
+ end
+
+ it "accepts \\u{HHHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{0000}").should == /#{"\x00"}/
+ end
+
+ it "accepts \\u{HHHHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{00001}").should == /#{"\x01"}/
+ end
+
+ it "accepts \\u{HHHHHH} for a single Unicode codepoint" do
+ Regexp.send(@method, "\u{000000}").should == /#{"\x00"}/
+ end
+
+ it "accepts characters followed by \\u{HHHH}" do
+ Regexp.send(@method, "abc\u{3042}").should == /#{"abc\u3042"}/
+ end
+
+ it "accepts \\u{HHHH} followed by characters" do
+ Regexp.send(@method, "\u{3042}abc").should == /#{"\u3042abc"}/
+ end
+
+ it "accepts escaped hexadecimal digits followed by \\u{HHHH}" do
+ Regexp.send(@method, "\x42\u{3042}").should == /#{"\x42\u3042"}/
+ end
+
+ it "accepts escaped octal digits followed by \\u{HHHH}" do
+ Regexp.send(@method, "\056\u{3042}").should == /#{"\x2e\u3042"}/
+ end
+
+ it "accepts a combination of escaped octal and hexadecimal digits and \\u{HHHH}" do
+ Regexp.send(@method, "\056\x42\u{3042}\x52\076").should == /#{"\x2e\x42\u3042\x52\x3e"}/
+ end
+
+ it "accepts \\uHHHH for a single Unicode codepoint" do
+ Regexp.send(@method, "\u3042").should == /#{"\u3042"}/
+ end
+
+ it "accepts characters followed by \\uHHHH" do
+ Regexp.send(@method, "abc\u3042").should == /#{"abc\u3042"}/
+ end
+
+ it "accepts \\uHHHH followed by characters" do
+ Regexp.send(@method, "\u3042abc").should == /#{"\u3042abc"}/
+ end
+
+ it "accepts escaped hexadecimal digits followed by \\uHHHH" do
+ Regexp.send(@method, "\x42\u3042").should == /#{"\x42\u3042"}/
+ end
+
+ it "accepts escaped octal digits followed by \\uHHHH" do
+ Regexp.send(@method, "\056\u3042").should == /#{"\x2e\u3042"}/
+ end
+
+ it "accepts a combination of escaped octal and hexadecimal digits and \\uHHHH" do
+ Regexp.send(@method, "\056\x42\u3042\x52\076").should == /#{"\x2e\x42\u3042\x52\x3e"}/
+ end
+
+ it "raises a RegexpError if less than four digits are given for \\uHHHH" do
+ lambda { Regexp.send(@method, "\\" + "u304") }.should raise_error(RegexpError)
+ end
+
+ it "raises a RegexpError if the \\u{} escape is empty" do
+ lambda { Regexp.send(@method, "\\" + "u{}") }.should raise_error(RegexpError)
+ end
+
+ it "raises a RegexpError if more than six hexadecimal digits are given" do
+ lambda { Regexp.send(@method, "\\" + "u{0ffffff}") }.should raise_error(RegexpError)
+ end
+
+ it "returns a Regexp with US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do
+ Regexp.send(@method, "abc").encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with source String having US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do
+ Regexp.send(@method, "abc").source.encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with US-ASCII encoding if UTF-8 escape sequences using only 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{61}").encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with source String having US-ASCII encoding if UTF-8 escape sequences using only 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{61}").source.encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns a Regexp with UTF-8 encoding if any UTF-8 escape sequences outside 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{ff}").encoding.should == Encoding::UTF_8
+ end
+
+ it "returns a Regexp with source String having UTF-8 encoding if any UTF-8 escape sequences outside 7-bit ASCII are present" do
+ Regexp.send(@method, "\u{ff}").source.encoding.should == Encoding::UTF_8
+ end
+
+ it "returns a Regexp with the input String's encoding" do
+ str = "\x82\xa0".force_encoding(Encoding::Shift_JIS)
+ Regexp.send(@method, str).encoding.should == Encoding::Shift_JIS
+ end
+
+ it "returns a Regexp with source String having the input String's encoding" do
+ str = "\x82\xa0".force_encoding(Encoding::Shift_JIS)
+ Regexp.send(@method, str).source.encoding.should == Encoding::Shift_JIS
+ end
+ end
+end
+
+describe :regexp_new_regexp_ascii_8bit, shared: true do
+ it "uses the argument as a literal to construct a Regexp object" do
+ Regexp.send(@method, /^hi{2,3}fo.o$/).should == /^hi{2,3}fo.o$/
+ end
+
+ it "preserves any options given in the Regexp literal" do
+ (Regexp.send(@method, /Hi/i).options & Regexp::IGNORECASE).should_not == 0
+ (Regexp.send(@method, /Hi/m).options & Regexp::MULTILINE).should_not == 0
+ not_supported_on :opal do
+ (Regexp.send(@method, /Hi/x).options & Regexp::EXTENDED).should_not == 0
+ end
+
+ not_supported_on :opal do
+ r = Regexp.send @method, /Hi/imx
+ (r.options & Regexp::IGNORECASE).should_not == 0
+ (r.options & Regexp::MULTILINE).should_not == 0
+ (r.options & Regexp::EXTENDED).should_not == 0
+ end
+
+ r = Regexp.send @method, /Hi/
+ (r.options & Regexp::IGNORECASE).should == 0
+ (r.options & Regexp::MULTILINE).should == 0
+ not_supported_on :opal do
+ (r.options & Regexp::EXTENDED).should == 0
+ end
+ end
+
+ it "does not honour options given as additional arguments" do
+ r = nil
+ lambda {
+ r = Regexp.send @method, /hi/, Regexp::IGNORECASE
+ }.should complain(/flags ignored/)
+ (r.options & Regexp::IGNORECASE).should == 0
+ end
+
+ not_supported_on :opal do
+ it "sets the encoding to UTF-8 if the Regexp literal has the 'u' option" do
+ Regexp.send(@method, /Hi/u).encoding.should == Encoding::UTF_8
+ end
+
+ it "sets the encoding to EUC-JP if the Regexp literal has the 'e' option" do
+ Regexp.send(@method, /Hi/e).encoding.should == Encoding::EUC_JP
+ end
+
+ it "sets the encoding to Windows-31J if the Regexp literal has the 's' option" do
+ Regexp.send(@method, /Hi/s).encoding.should == Encoding::Windows_31J
+ end
+
+ it "sets the encoding to US-ASCII if the Regexp literal has the 'n' option and the source String is ASCII only" do
+ Regexp.send(@method, /Hi/n).encoding.should == Encoding::US_ASCII
+ end
+
+ it "sets the encoding to source String's encoding if the Regexp literal has the 'n' option and the source String is not ASCII only" do
+ Regexp.send(@method, Regexp.new("\\xff", nil, 'n')).encoding.should == Encoding::ASCII_8BIT
+ end
+ end
+end
diff --git a/spec/ruby/core/regexp/shared/quote.rb b/spec/ruby/core/regexp/shared/quote.rb
index a55adb5bf2..016cb0b164 100644
--- a/spec/ruby/core/regexp/shared/quote.rb
+++ b/spec/ruby/core/regexp/shared/quote.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
describe :regexp_quote, shared: true do
it "escapes any characters with special meaning in a regular expression" do
@@ -23,9 +23,9 @@ describe :regexp_quote, shared: true do
Regexp.send(@method, str).encoding.should == Encoding::UTF_8
end
- it "sets the encoding of the result to BINARY if any non-US-ASCII characters are present in an input String with invalid encoding" do
+ it "sets the encoding of the result to ASCII-8BIT if any non-US-ASCII characters are present in an input String with invalid encoding" do
str = "\xff".force_encoding "us-ascii"
str.valid_encoding?.should be_false
- Regexp.send(@method, "\xff").encoding.should == Encoding::BINARY
+ Regexp.send(@method, "\xff").encoding.should == Encoding::ASCII_8BIT
end
end
diff --git a/spec/ruby/core/regexp/source_spec.rb b/spec/ruby/core/regexp/source_spec.rb
index 709fee49b3..3960a09395 100644
--- a/spec/ruby/core/regexp/source_spec.rb
+++ b/spec/ruby/core/regexp/source_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#source" do
it "returns the original string of the pattern" do
diff --git a/spec/ruby/core/regexp/to_s_spec.rb b/spec/ruby/core/regexp/to_s_spec.rb
index 798eaee6c2..a23fd78975 100644
--- a/spec/ruby/core/regexp/to_s_spec.rb
+++ b/spec/ruby/core/regexp/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp#to_s" do
not_supported_on :opal do
diff --git a/spec/ruby/core/regexp/try_convert_spec.rb b/spec/ruby/core/regexp/try_convert_spec.rb
index be567e2130..e782fc07fb 100644
--- a/spec/ruby/core/regexp/try_convert_spec.rb
+++ b/spec/ruby/core/regexp/try_convert_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp.try_convert" do
not_supported_on :opal do
diff --git a/spec/ruby/core/regexp/union_spec.rb b/spec/ruby/core/regexp/union_spec.rb
index 81a31d89b3..0f62747753 100644
--- a/spec/ruby/core/regexp/union_spec.rb
+++ b/spec/ruby/core/regexp/union_spec.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Regexp.union" do
it "returns /(?!)/ when passed no arguments" do
@@ -52,83 +52,83 @@ describe "Regexp.union" do
end
it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Strings" do
- -> {
+ lambda {
Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-16BE"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Regexps" do
- -> {
+ lambda {
Regexp.union(Regexp.new("a".encode("UTF-16LE")),
Regexp.new("b".encode("UTF-16BE")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include conflicting fixed encoding Regexps" do
- -> {
+ lambda {
Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING),
Regexp.new("b".encode("US-ASCII"), Regexp::FIXEDENCODING))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include a fixed encoding Regexp and a String containing non-ASCII-compatible characters in a different encoding" do
- -> {
+ lambda {
Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING),
"\u00A9".encode("ISO-8859-1"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include a String containing non-ASCII-compatible characters and a fixed encoding Regexp in a different encoding" do
- -> {
+ lambda {
Regexp.union("\u00A9".encode("ISO-8859-1"),
Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only String" do
- -> {
+ lambda {
Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-8"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only String" do
- -> {
+ lambda {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), "b".encode("UTF-8"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only Regexp" do
- -> {
+ lambda {
Regexp.union("a".encode("UTF-16LE"), Regexp.new("b".encode("UTF-8")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only Regexp" do
- -> {
+ lambda {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("b".encode("UTF-8")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and a String containing non-ASCII-compatible characters in a different encoding" do
- -> {
+ lambda {
Regexp.union("a".encode("UTF-16LE"), "\u00A9".encode("ISO-8859-1"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a String containing non-ASCII-compatible characters in a different encoding" do
- -> {
+ lambda {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), "\u00A9".encode("ISO-8859-1"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and a Regexp containing non-ASCII-compatible characters in a different encoding" do
- -> {
+ lambda {
Regexp.union("a".encode("UTF-16LE"), Regexp.new("\u00A9".encode("ISO-8859-1")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a Regexp containing non-ASCII-compatible characters in a different encoding" do
- -> {
+ lambda {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("\u00A9".encode("ISO-8859-1")))
}.should raise_error(ArgumentError)
end
@@ -144,6 +144,6 @@ describe "Regexp.union" do
not_supported_on :opal do
Regexp.union([/dogs/, /cats/i]).should == /(?-mix:dogs)|(?i-mx:cats)/
end
- ->{Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i])}.should raise_error(TypeError)
+ lambda{Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i])}.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/signal/fixtures/trap_all.rb b/spec/ruby/core/signal/fixtures/trap_all.rb
deleted file mode 100644
index afa00b498d..0000000000
--- a/spec/ruby/core/signal/fixtures/trap_all.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-cannot_be_trapped = %w[KILL STOP] # See man 2 signal
-
-(Signal.list.keys - cannot_be_trapped).each do |signal|
- begin
- Signal.trap(signal, -> {})
- rescue ArgumentError => e
- unless /can't trap reserved signal|Signal already used by VM or OS/ =~ e.message
- raise e
- end
- else
- Signal.trap(signal, "DEFAULT")
- end
-end
-
-puts "OK"
diff --git a/spec/ruby/core/signal/list_spec.rb b/spec/ruby/core/signal/list_spec.rb
index 56ad6828fe..510b671337 100644
--- a/spec/ruby/core/signal/list_spec.rb
+++ b/spec/ruby/core/signal/list_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Signal.list" do
RUBY_SIGNALS = %w{
@@ -61,8 +61,4 @@ describe "Signal.list" do
it "includes the EXIT key with a value of zero" do
Signal.list["EXIT"].should == 0
end
-
- it "includes the KILL key with a value of nine" do
- Signal.list["KILL"].should == 9
- end
end
diff --git a/spec/ruby/core/signal/signame_spec.rb b/spec/ruby/core/signal/signame_spec.rb
index b66de9fc85..1874a67933 100644
--- a/spec/ruby/core/signal/signame_spec.rb
+++ b/spec/ruby/core/signal/signame_spec.rb
@@ -1,22 +1,23 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Signal.signame" do
it "takes a signal name with a well known signal number" do
Signal.signame(0).should == "EXIT"
end
- it "returns nil if the argument is an invalid signal number" do
- Signal.signame(-1).should == nil
+ ruby_version_is "2.0"..."2.3" do
+ it "raises an ArgumentError if the argument is an invalid signal number" do
+ lambda { Signal.signame(-1) }.should raise_error(ArgumentError)
+ end
end
- it "raises a TypeError when the passed argument can't be coerced to Integer" do
- -> { Signal.signame("hello") }.should raise_error(TypeError)
+ ruby_version_is "2.3" do
+ it "returns nil if the argument is an invalid signal number" do
+ Signal.signame(-1).should == nil
+ end
end
- platform_is_not :windows do
- it "the original should take precedence over alias when looked up by number" do
- Signal.signame(Signal.list["ABRT"]).should == "ABRT"
- Signal.signame(Signal.list["CHLD"]).should == "CHLD"
- end
+ it "raises a TypeError when the passed argument can't be coerced to Integer" do
+ lambda { Signal.signame("hello") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/signal/trap_spec.rb b/spec/ruby/core/signal/trap_spec.rb
index 91ce1f1348..787de1735c 100644
--- a/spec/ruby/core/signal/trap_spec.rb
+++ b/spec/ruby/core/signal/trap_spec.rb
@@ -1,10 +1,11 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
describe "Signal.trap" do
before :each do
ScratchPad.clear
- @proc = -> {}
+
+ @proc = lambda { ScratchPad.record :proc_trap }
@saved_trap = Signal.trap(:HUP, @proc)
end
@@ -47,54 +48,29 @@ platform_is_not :windows do
ScratchPad.recorded.should be_true
end
- it "registers an handler doing nothing with :IGNORE" do
- Signal.trap :HUP, :IGNORE
- Process.kill(:HUP, Process.pid).should == 1
- end
-
it "ignores the signal when passed nil" do
Signal.trap :HUP, nil
Signal.trap(:HUP, @saved_trap).should be_nil
end
- it "accepts :DEFAULT in place of a proc" do
+ it "accepts 'DEFAULT' as a symbol in place of a proc" do
Signal.trap :HUP, :DEFAULT
- Signal.trap(:HUP, @saved_trap).should == "DEFAULT"
+ Signal.trap(:HUP, :DEFAULT).should == "DEFAULT"
end
- it "accepts :SIG_DFL in place of a proc" do
+ it "accepts 'SIG_DFL' as a symbol in place of a proc" do
Signal.trap :HUP, :SIG_DFL
- Signal.trap(:HUP, @saved_trap).should == "DEFAULT"
+ Signal.trap(:HUP, :SIG_DFL).should == "DEFAULT"
end
- it "accepts :SIG_IGN in place of a proc" do
+ it "accepts 'SIG_IGN' as a symbol in place of a proc" do
Signal.trap :HUP, :SIG_IGN
- Signal.trap(:HUP, @saved_trap).should == "IGNORE"
+ Signal.trap(:HUP, :SIG_IGN).should == "IGNORE"
end
- it "accepts :IGNORE in place of a proc" do
+ it "accepts 'IGNORE' as a symbol in place of a proc" do
Signal.trap :HUP, :IGNORE
- Signal.trap(:HUP, @saved_trap).should == "IGNORE"
- end
-
- it "accepts 'SIG_DFL' in place of a proc" do
- Signal.trap :HUP, "SIG_DFL"
- Signal.trap(:HUP, @saved_trap).should == "DEFAULT"
- end
-
- it "accepts 'DEFAULT' in place of a proc" do
- Signal.trap :HUP, "DEFAULT"
- Signal.trap(:HUP, @saved_trap).should == "DEFAULT"
- end
-
- it "accepts 'SIG_IGN' in place of a proc" do
- Signal.trap :HUP, "SIG_IGN"
- Signal.trap(:HUP, @saved_trap).should == "IGNORE"
- end
-
- it "accepts 'IGNORE' in place of a proc" do
- Signal.trap :HUP, "IGNORE"
- Signal.trap(:HUP, @saved_trap).should == "IGNORE"
+ Signal.trap(:HUP, :IGNORE).should == "IGNORE"
end
it "accepts long names as Strings" do
@@ -102,7 +78,7 @@ platform_is_not :windows do
Signal.trap("SIGHUP", @saved_trap).should equal(@proc)
end
- it "accepts short names as Strings" do
+ it "acceps short names as Strings" do
Signal.trap "HUP", @proc
Signal.trap("HUP", @saved_trap).should equal(@proc)
end
@@ -116,48 +92,25 @@ platform_is_not :windows do
Signal.trap :HUP, @proc
Signal.trap(:HUP, @saved_trap).should equal(@proc)
end
- end
-
- describe "Signal.trap" do
- # See man 2 signal
- %w[KILL STOP].each do |signal|
- it "raises ArgumentError or Errno::EINVAL for SIG#{signal}" do
- -> {
- trap(signal, -> {})
- }.should raise_error(StandardError) { |e|
- [ArgumentError, Errno::EINVAL].should include(e.class)
- e.message.should =~ /Invalid argument|Signal already used by VM or OS/
- }
- end
- end
- it "allows to register a handler for all known signals, except reserved signals for which it raises ArgumentError" do
- out = ruby_exe(fixture(__FILE__, "trap_all.rb"), args: "2>&1")
- out.should == "OK\n"
- $?.exitstatus.should == 0
+ it "accepts 'SIG_DFL' in place of a proc" do
+ Signal.trap :HUP, "SIG_DFL"
+ Signal.trap(:HUP, @saved_trap).should == "DEFAULT"
end
- it "returns 'DEFAULT' for the initial SIGINT handler" do
- ruby_exe('print trap(:INT) { abort }').should == 'DEFAULT'
+ it "accepts 'DEFAULT' in place of a proc" do
+ Signal.trap :HUP, "DEFAULT"
+ Signal.trap(:HUP, @saved_trap).should == "DEFAULT"
end
- it "returns SYSTEM_DEFAULT if passed DEFAULT and no handler was ever set" do
- Signal.trap("PROF", "DEFAULT").should == "SYSTEM_DEFAULT"
+ it "accepts 'SIG_IGN' in place of a proc" do
+ Signal.trap :HUP, "SIG_IGN"
+ Signal.trap(:HUP, "SIG_IGN").should == "IGNORE"
end
- it "accepts 'SYSTEM_DEFAULT' and uses the OS handler for SIGPIPE" do
- code = <<-RUBY
- p Signal.trap('PIPE', 'SYSTEM_DEFAULT')
- r, w = IO.pipe
- r.close
- loop { w.write("a"*1024) }
- RUBY
- out = ruby_exe(code)
- status = $?
- out.should == "nil\n"
- status.signaled?.should == true
- status.termsig.should be_kind_of(Integer)
- Signal.signame(status.termsig).should == "PIPE"
+ it "accepts 'IGNORE' in place of a proc" do
+ Signal.trap :HUP, "IGNORE"
+ Signal.trap(:HUP, "IGNORE").should == "IGNORE"
end
end
end
diff --git a/spec/ruby/core/sizedqueue/append_spec.rb b/spec/ruby/core/sizedqueue/append_spec.rb
deleted file mode 100644
index ca79068930..0000000000
--- a/spec/ruby/core/sizedqueue/append_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/enque'
-require_relative '../../shared/sizedqueue/enque'
-
-describe "SizedQueue#<<" do
- it_behaves_like :queue_enq, :<<, -> { SizedQueue.new(10) }
-end
-
-describe "SizedQueue#<<" do
- it_behaves_like :sizedqueue_enq, :<<, -> n { SizedQueue.new(n) }
-end
diff --git a/spec/ruby/core/sizedqueue/clear_spec.rb b/spec/ruby/core/sizedqueue/clear_spec.rb
deleted file mode 100644
index abae01c6c0..0000000000
--- a/spec/ruby/core/sizedqueue/clear_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/clear'
-
-describe "SizedQueue#clear" do
- it_behaves_like :queue_clear, :clear, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/close_spec.rb b/spec/ruby/core/sizedqueue/close_spec.rb
deleted file mode 100644
index 0e0af851cb..0000000000
--- a/spec/ruby/core/sizedqueue/close_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/close'
-
-describe "SizedQueue#close" do
- it_behaves_like :queue_close, :close, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/closed_spec.rb b/spec/ruby/core/sizedqueue/closed_spec.rb
deleted file mode 100644
index 4b90da1faa..0000000000
--- a/spec/ruby/core/sizedqueue/closed_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/closed'
-
-describe "SizedQueue#closed?" do
- it_behaves_like :queue_closed?, :closed?, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/deq_spec.rb b/spec/ruby/core/sizedqueue/deq_spec.rb
deleted file mode 100644
index 5e1bd9f746..0000000000
--- a/spec/ruby/core/sizedqueue/deq_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/deque'
-
-describe "SizedQueue#deq" do
- it_behaves_like :queue_deq, :deq, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/empty_spec.rb b/spec/ruby/core/sizedqueue/empty_spec.rb
deleted file mode 100644
index 9b0d4ff013..0000000000
--- a/spec/ruby/core/sizedqueue/empty_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/empty'
-
-describe "SizedQueue#empty?" do
- it_behaves_like :queue_empty?, :empty?, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/enq_spec.rb b/spec/ruby/core/sizedqueue/enq_spec.rb
deleted file mode 100644
index 3821afac95..0000000000
--- a/spec/ruby/core/sizedqueue/enq_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/enque'
-require_relative '../../shared/sizedqueue/enque'
-
-describe "SizedQueue#enq" do
- it_behaves_like :queue_enq, :enq, -> { SizedQueue.new(10) }
-end
-
-describe "SizedQueue#enq" do
- it_behaves_like :sizedqueue_enq, :enq, -> n { SizedQueue.new(n) }
-end
diff --git a/spec/ruby/core/sizedqueue/length_spec.rb b/spec/ruby/core/sizedqueue/length_spec.rb
deleted file mode 100644
index b93e7f8997..0000000000
--- a/spec/ruby/core/sizedqueue/length_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/length'
-
-describe "SizedQueue#length" do
- it_behaves_like :queue_length, :length, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/max_spec.rb b/spec/ruby/core/sizedqueue/max_spec.rb
deleted file mode 100644
index cbabb5dc10..0000000000
--- a/spec/ruby/core/sizedqueue/max_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/sizedqueue/max'
-
-describe "SizedQueue#max" do
- it_behaves_like :sizedqueue_max, :max, -> n { SizedQueue.new(n) }
-end
-
-describe "SizedQueue#max=" do
- it_behaves_like :sizedqueue_max=, :max=, -> n { SizedQueue.new(n) }
-end
diff --git a/spec/ruby/core/sizedqueue/new_spec.rb b/spec/ruby/core/sizedqueue/new_spec.rb
deleted file mode 100644
index d5704732c3..0000000000
--- a/spec/ruby/core/sizedqueue/new_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/sizedqueue/new'
-
-describe "SizedQueue.new" do
- it_behaves_like :sizedqueue_new, :new, -> *n { SizedQueue.new(*n) }
-end
diff --git a/spec/ruby/core/sizedqueue/num_waiting_spec.rb b/spec/ruby/core/sizedqueue/num_waiting_spec.rb
deleted file mode 100644
index 9aef25e33d..0000000000
--- a/spec/ruby/core/sizedqueue/num_waiting_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/sizedqueue/num_waiting'
-
-describe "SizedQueue#num_waiting" do
- it_behaves_like :sizedqueue_num_waiting, :new, -> n { SizedQueue.new(n) }
-end
diff --git a/spec/ruby/core/sizedqueue/pop_spec.rb b/spec/ruby/core/sizedqueue/pop_spec.rb
deleted file mode 100644
index a0cf6f509c..0000000000
--- a/spec/ruby/core/sizedqueue/pop_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/deque'
-
-describe "SizedQueue#pop" do
- it_behaves_like :queue_deq, :pop, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/push_spec.rb b/spec/ruby/core/sizedqueue/push_spec.rb
deleted file mode 100644
index bba9be9e3f..0000000000
--- a/spec/ruby/core/sizedqueue/push_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/enque'
-require_relative '../../shared/sizedqueue/enque'
-
-describe "SizedQueue#push" do
- it_behaves_like :queue_enq, :push, -> { SizedQueue.new(10) }
-end
-
-describe "SizedQueue#push" do
- it_behaves_like :sizedqueue_enq, :push, -> n { SizedQueue.new(n) }
-end
diff --git a/spec/ruby/core/sizedqueue/shift_spec.rb b/spec/ruby/core/sizedqueue/shift_spec.rb
deleted file mode 100644
index 5138e68258..0000000000
--- a/spec/ruby/core/sizedqueue/shift_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/deque'
-
-describe "SizedQueue#shift" do
- it_behaves_like :queue_deq, :shift, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/sizedqueue/size_spec.rb b/spec/ruby/core/sizedqueue/size_spec.rb
deleted file mode 100644
index dfa76faabe..0000000000
--- a/spec/ruby/core/sizedqueue/size_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/queue/length'
-
-describe "SizedQueue#size" do
- it_behaves_like :queue_length, :size, -> { SizedQueue.new(10) }
-end
diff --git a/spec/ruby/core/string/allocate_spec.rb b/spec/ruby/core/string/allocate_spec.rb
index 5b36b4fd05..9048815c5d 100644
--- a/spec/ruby/core/string/allocate_spec.rb
+++ b/spec/ruby/core/string/allocate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String.allocate" do
it "returns an instance of String" do
diff --git a/spec/ruby/core/string/append_spec.rb b/spec/ruby/core/string/append_spec.rb
index 1e1667f617..87b2dca725 100644
--- a/spec/ruby/core/string/append_spec.rb
+++ b/spec/ruby/core/string/append_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/concat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/concat', __FILE__)
describe "String#<<" do
it_behaves_like :string_concat, :<<
diff --git a/spec/ruby/core/string/ascii_only_spec.rb b/spec/ruby/core/string/ascii_only_spec.rb
index c7e02fd874..1bf9cfa4a1 100644
--- a/spec/ruby/core/string/ascii_only_spec.rb
+++ b/spec/ruby/core/string/ascii_only_spec.rb
@@ -1,83 +1,85 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
-describe "String#ascii_only?" do
- describe "with ASCII only characters" do
- it "returns true if the encoding is UTF-8" do
- [ ["hello", true],
- ["hello".encode('UTF-8'), true],
- ["hello".force_encoding('UTF-8'), true],
- ].should be_computed_by(:ascii_only?)
- end
+with_feature :encoding do
+ describe "String#ascii_only?" do
+ describe "with ASCII only characters" do
+ it "returns true if the encoding is UTF-8" do
+ [ ["hello", true],
+ ["hello".encode('UTF-8'), true],
+ ["hello".force_encoding('UTF-8'), true],
+ ].should be_computed_by(:ascii_only?)
+ end
- it "returns true if the encoding is US-ASCII" do
- "hello".force_encoding(Encoding::US_ASCII).ascii_only?.should be_true
- "hello".encode(Encoding::US_ASCII).ascii_only?.should be_true
- end
+ it "returns true if the encoding is US-ASCII" do
+ "hello".force_encoding(Encoding::US_ASCII).ascii_only?.should be_true
+ "hello".encode(Encoding::US_ASCII).ascii_only?.should be_true
+ end
- it "returns true for all single-character UTF-8 Strings" do
- 0.upto(127) do |n|
- n.chr.ascii_only?.should be_true
+ it "returns true for all single-character UTF-8 Strings" do
+ 0.upto(127) do |n|
+ n.chr.ascii_only?.should be_true
+ end
end
end
- end
- describe "with non-ASCII only characters" do
- it "returns false if the encoding is BINARY" do
- chr = 128.chr
- chr.encoding.should == Encoding::BINARY
- chr.ascii_only?.should be_false
- end
+ describe "with non-ASCII only characters" do
+ it "returns false if the encoding is ASCII-8BIT" do
+ chr = 128.chr
+ chr.encoding.should == Encoding::ASCII_8BIT
+ chr.ascii_only?.should be_false
+ end
- it "returns false if the String contains any non-ASCII characters" do
- [ ["\u{6666}", false],
- ["hello, \u{6666}", false],
- ["\u{6666}".encode('UTF-8'), false],
- ["\u{6666}".force_encoding('UTF-8'), false],
- ].should be_computed_by(:ascii_only?)
- end
+ it "returns false if the String contains any non-ASCII characters" do
+ [ ["\u{6666}", false],
+ ["hello, \u{6666}", false],
+ ["\u{6666}".encode('UTF-8'), false],
+ ["\u{6666}".force_encoding('UTF-8'), false],
+ ].should be_computed_by(:ascii_only?)
+ end
- it "returns false if the encoding is US-ASCII" do
- [ ["\u{6666}".force_encoding(Encoding::US_ASCII), false],
- ["hello, \u{6666}".force_encoding(Encoding::US_ASCII), false],
- ].should be_computed_by(:ascii_only?)
+ it "returns false if the encoding is US-ASCII" do
+ [ ["\u{6666}".force_encoding(Encoding::US_ASCII), false],
+ ["hello, \u{6666}".force_encoding(Encoding::US_ASCII), false],
+ ].should be_computed_by(:ascii_only?)
+ end
end
- end
- it "returns true for the empty String with an ASCII-compatible encoding" do
- "".ascii_only?.should be_true
- "".encode('UTF-8').ascii_only?.should be_true
- end
+ it "returns true for the empty String with an ASCII-compatible encoding" do
+ "".ascii_only?.should be_true
+ "".encode('UTF-8').ascii_only?.should be_true
+ end
- it "returns false for the empty String with a non-ASCII-compatible encoding" do
- "".force_encoding('UTF-16LE').ascii_only?.should be_false
- "".encode('UTF-16BE').ascii_only?.should be_false
- end
+ it "returns false for the empty String with a non-ASCII-compatible encoding" do
+ "".force_encoding('UTF-16LE').ascii_only?.should be_false
+ "".encode('UTF-16BE').ascii_only?.should be_false
+ end
- it "returns false for a non-empty String with non-ASCII-compatible encoding" do
- "\x78\x00".force_encoding("UTF-16LE").ascii_only?.should be_false
- end
+ it "returns false for a non-empty String with non-ASCII-compatible encoding" do
+ "\x78\x00".force_encoding("UTF-16LE").ascii_only?.should be_false
+ end
- it "returns false when interpolating non ascii strings" do
- base = "EU currency is"
- base.force_encoding(Encoding::US_ASCII)
- euro = "\u20AC"
- interp = "#{base} #{euro}"
- euro.ascii_only?.should be_false
- base.ascii_only?.should be_true
- interp.ascii_only?.should be_false
- end
+ it "returns false when interpolating non ascii strings" do
+ base = "EU currency is"
+ base.force_encoding(Encoding::US_ASCII)
+ euro = "\u20AC"
+ interp = "#{base} #{euro}"
+ euro.ascii_only?.should be_false
+ base.ascii_only?.should be_true
+ interp.ascii_only?.should be_false
+ end
- it "returns false after appending non ASCII characters to an empty String" do
- ("" << "λ").ascii_only?.should be_false
- end
+ it "returns false after appending non ASCII characters to an empty String" do
+ ("" << "λ").ascii_only?.should be_false
+ end
- it "returns false when concatenating an ASCII and non-ASCII String" do
- "".concat("λ").ascii_only?.should be_false
- end
+ it "returns false when concatenating an ASCII and non-ASCII String" do
+ "".concat("λ").ascii_only?.should be_false
+ end
- it "returns false when replacing an ASCII String with a non-ASCII String" do
- "".replace("λ").ascii_only?.should be_false
+ it "returns false when replacing an ASCII String with a non-ASCII String" do
+ "".replace("λ").ascii_only?.should be_false
+ end
end
end
diff --git a/spec/ruby/core/string/b_spec.rb b/spec/ruby/core/string/b_spec.rb
index b2e3d326ba..89fcedf7c4 100644
--- a/spec/ruby/core/string/b_spec.rb
+++ b/spec/ruby/core/string/b_spec.rb
@@ -1,19 +1,19 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#b" do
- it "returns a binary encoded string" do
- "Hello".b.should == "Hello".force_encoding(Encoding::BINARY)
- "ã“ã‚“ã¡ã«ã¯".b.should == "ã“ã‚“ã¡ã«ã¯".force_encoding(Encoding::BINARY)
- end
+ with_feature :encoding do
+ it "returns an ASCII-8BIT encoded string" do
+ "Hello".b.should == "Hello".force_encoding(Encoding::ASCII_8BIT)
+ "ã“ã‚“ã¡ã«ã¯".b.should == "ã“ã‚“ã¡ã«ã¯".force_encoding(Encoding::ASCII_8BIT)
+ end
- it "returns new string without modifying self" do
- str = "ã“ã‚“ã¡ã«ã¯"
- str.b.should_not equal(str)
- str.should == "ã“ã‚“ã¡ã«ã¯"
- end
+ it "returns new string without modifying self" do
+ str = "ã“ã‚“ã¡ã«ã¯"
+ str.b.should_not equal(str)
+ str.should == "ã“ã‚“ã¡ã«ã¯"
+ end
- ruby_version_is ''...'2.7' do
it "copies own tainted/untrusted status to the returning value" do
utf_8 = "ã“ã‚“ã¡ã«ã¯".taint.untrust
ret = utf_8.b
diff --git a/spec/ruby/core/string/bytes_spec.rb b/spec/ruby/core/string/bytes_spec.rb
index 96f1ae9cf2..b1f5ba412f 100644
--- a/spec/ruby/core/string/bytes_spec.rb
+++ b/spec/ruby/core/string/bytes_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#bytes" do
before :each do
@@ -36,20 +36,22 @@ describe "String#bytes" do
end
end
-describe "String#bytes" do
- before :each do
- @utf8 = "æ±äº¬"
- @ascii = 'Tokyo'
- @utf8_ascii = @utf8 + @ascii
- end
+with_feature :encoding do
+ describe "String#bytes" do
+ before :each do
+ @utf8 = "æ±äº¬"
+ @ascii = 'Tokyo'
+ @utf8_ascii = @utf8 + @ascii
+ end
- it "agrees with #getbyte" do
- @utf8_ascii.bytes.to_a.each_with_index do |byte,index|
- byte.should == @utf8_ascii.getbyte(index)
+ it "agrees with #getbyte" do
+ @utf8_ascii.bytes.to_a.each_with_index do |byte,index|
+ byte.should == @utf8_ascii.getbyte(index)
+ end
end
- end
- it "is unaffected by #force_encoding" do
- @utf8.force_encoding('ASCII').bytes.to_a.should == @utf8.bytes.to_a
+ it "is unaffected by #force_encoding" do
+ @utf8.force_encoding('ASCII').bytes.to_a.should == @utf8.bytes.to_a
+ end
end
end
diff --git a/spec/ruby/core/string/bytesize_spec.rb b/spec/ruby/core/string/bytesize_spec.rb
index b8b07cfbec..51da179da8 100644
--- a/spec/ruby/core/string/bytesize_spec.rb
+++ b/spec/ruby/core/string/bytesize_spec.rb
@@ -1,33 +1,37 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
-describe "#String#bytesize" do
- it "returns the length of self in bytes" do
- "hello".bytesize.should == 5
- " ".bytesize.should == 1
- end
+with_feature :encoding do
+ describe "#String#bytesize" do
+ it "needs to be reviewed for spec completeness"
- it "works with strings containing single UTF-8 characters" do
- "\u{6666}".bytesize.should == 3
- end
+ it "returns the length of self in bytes" do
+ "hello".bytesize.should == 5
+ " ".bytesize.should == 1
+ end
- it "works with pseudo-ASCII strings containing single UTF-8 characters" do
- "\u{6666}".force_encoding('ASCII').bytesize.should == 3
- end
+ it "works with strings containing single UTF-8 characters" do
+ "\u{6666}".bytesize.should == 3
+ end
- it "works with strings containing UTF-8 characters" do
- "c \u{6666}".force_encoding('UTF-8').bytesize.should == 5
- "c \u{6666}".bytesize.should == 5
- end
+ it "works with pseudo-ASCII strings containing single UTF-8 characters" do
+ "\u{6666}".force_encoding('ASCII').bytesize.should == 3
+ end
- it "works with pseudo-ASCII strings containing UTF-8 characters" do
- "c \u{6666}".force_encoding('ASCII').bytesize.should == 5
- end
+ it "works with strings containing UTF-8 characters" do
+ "c \u{6666}".force_encoding('UTF-8').bytesize.should == 5
+ "c \u{6666}".bytesize.should == 5
+ end
+
+ it "works with pseudo-ASCII strings containing UTF-8 characters" do
+ "c \u{6666}".force_encoding('ASCII').bytesize.should == 5
+ end
- it "returns 0 for the empty string" do
- "".bytesize.should == 0
- "".force_encoding('ASCII').bytesize.should == 0
- "".force_encoding('UTF-8').bytesize.should == 0
+ it "returns 0 for the empty string" do
+ "".bytesize.should == 0
+ "".force_encoding('ASCII').bytesize.should == 0
+ "".force_encoding('UTF-8').bytesize.should == 0
+ end
end
end
diff --git a/spec/ruby/core/string/byteslice_spec.rb b/spec/ruby/core/string/byteslice_spec.rb
index a49da040eb..263810971e 100644
--- a/spec/ruby/core/string/byteslice_spec.rb
+++ b/spec/ruby/core/string/byteslice_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/slice'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/slice.rb', __FILE__)
describe "String#byteslice" do
it "needs to reviewed for spec completeness"
@@ -17,11 +17,13 @@ describe "String#byteslice with Range" do
it_behaves_like :string_slice_range, :byteslice
end
-describe "String#byteslice on on non ASCII strings" do
- it "returns byteslice of unicode strings" do
- "\u3042".byteslice(1).should == "\x81".force_encoding("UTF-8")
- "\u3042".byteslice(1, 2).should == "\x81\x82".force_encoding("UTF-8")
- "\u3042".byteslice(1..2).should == "\x81\x82".force_encoding("UTF-8")
- "\u3042".byteslice(-1).should == "\x82".force_encoding("UTF-8")
+with_feature :encoding do
+ describe "String#byteslice on on non ASCII strings" do
+ it "returns byteslice of unicode strings" do
+ "\u3042".byteslice(1).should == "\x81".force_encoding("UTF-8")
+ "\u3042".byteslice(1, 2).should == "\x81\x82".force_encoding("UTF-8")
+ "\u3042".byteslice(1..2).should == "\x81\x82".force_encoding("UTF-8")
+ "\u3042".byteslice(-1).should == "\x82".force_encoding("UTF-8")
+ end
end
end
diff --git a/spec/ruby/core/string/capitalize_spec.rb b/spec/ruby/core/string/capitalize_spec.rb
index 41dd63f63e..497e1453cd 100644
--- a/spec/ruby/core/string/capitalize_spec.rb
+++ b/spec/ruby/core/string/capitalize_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#capitalize" do
it "returns a copy of self with the first character converted to uppercase and the remainder to lowercase" do
@@ -12,74 +12,25 @@ describe "String#capitalize" do
"123ABC".capitalize.should == "123abc"
end
- ruby_version_is ''...'2.7' do
- it "taints resulting string when self is tainted" do
- "".taint.capitalize.tainted?.should == true
- "hello".taint.capitalize.tainted?.should == true
- end
+ it "taints resulting string when self is tainted" do
+ "".taint.capitalize.tainted?.should == true
+ "hello".taint.capitalize.tainted?.should == true
end
- describe "full Unicode case mapping" do
- it "works for all of Unicode with no option" do
- "äöÜ".capitalize.should == "Äöü"
- end
-
- it "only capitalizes the first resulting character when upcasing a character produces a multi-character sequence" do
- "ß".capitalize.should == "Ss"
- end
-
- it "updates string metadata" do
- capitalized = "ßeT".capitalize
-
- capitalized.should == "Sset"
- capitalized.size.should == 4
- capitalized.bytesize.should == 4
- capitalized.ascii_only?.should be_true
+ ruby_version_is ''...'2.4' do
+ it "is locale insensitive (only upcases a-z and only downcases A-Z)" do
+ "ÄÖÜ".capitalize.should == "ÄÖÜ"
+ "ärger".capitalize.should == "ärger"
+ "BÄR".capitalize.should == "BÄr"
end
end
- describe "ASCII-only case mapping" do
- it "does not capitalize non-ASCII characters" do
- "ßet".capitalize(:ascii).should == "ßet"
- end
- end
-
- describe "full Unicode case mapping adapted for Turkic languages" do
- it "capitalizes ASCII characters according to Turkic semantics" do
- "iSa".capitalize(:turkic).should == "İsa"
- end
-
- it "allows Lithuanian as an extra option" do
- "iSa".capitalize(:turkic, :lithuanian).should == "İsa"
- end
-
- it "does not allow any other additional option" do
- -> { "iSa".capitalize(:turkic, :ascii) }.should raise_error(ArgumentError)
+ ruby_version_is '2.4' do
+ it "works for all of Unicode" do
+ "äöü".capitalize.should == "Äöü"
end
end
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- "iß".capitalize(:lithuanian).should == "Iß"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- "iß".capitalize(:lithuanian, :turkic).should == "İß"
- end
-
- it "does not allow any other additional option" do
- -> { "iß".capitalize(:lithuanian, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- it "does not allow the :fold option for upcasing" do
- -> { "abc".capitalize(:fold) }.should raise_error(ArgumentError)
- end
-
- it "does not allow invalid options" do
- -> { "abc".capitalize(:invalid_option) }.should raise_error(ArgumentError)
- end
-
it "returns subclass instances when called on a subclass" do
StringSpecs::MyString.new("hello").capitalize.should be_an_instance_of(StringSpecs::MyString)
StringSpecs::MyString.new("Hello").capitalize.should be_an_instance_of(StringSpecs::MyString)
@@ -93,80 +44,12 @@ describe "String#capitalize!" do
a.should == "Hello"
end
- describe "full Unicode case mapping" do
- it "modifies self in place for all of Unicode with no option" do
- a = "äöÜ"
- a.capitalize!
+ ruby_version_is '2.4' do
+ it "capitalizes self in place for all of Unicode" do
+ a = "äöü"
+ a.capitalize!.should equal(a)
a.should == "Äöü"
end
-
- it "only capitalizes the first resulting character when upcasing a character produces a multi-character sequence" do
- a = "ß"
- a.capitalize!
- a.should == "Ss"
- end
-
- it "updates string metadata" do
- capitalized = "ßeT"
- capitalized.capitalize!
-
- capitalized.should == "Sset"
- capitalized.size.should == 4
- capitalized.bytesize.should == 4
- capitalized.ascii_only?.should be_true
- end
- end
-
- describe "modifies self in place for ASCII-only case mapping" do
- it "does not capitalize non-ASCII characters" do
- a = "ßet"
- a.capitalize!(:ascii)
- a.should == "ßet"
- end
- end
-
- describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do
- it "capitalizes ASCII characters according to Turkic semantics" do
- a = "iSa"
- a.capitalize!(:turkic)
- a.should == "İsa"
- end
-
- it "allows Lithuanian as an extra option" do
- a = "iSa"
- a.capitalize!(:turkic, :lithuanian)
- a.should == "İsa"
- end
-
- it "does not allow any other additional option" do
- -> { a = "iSa"; a.capitalize!(:turkic, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- describe "modifies self in place for full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- a = "iß"
- a.capitalize!(:lithuanian)
- a.should == "Iß"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- a = "iß"
- a.capitalize!(:lithuanian, :turkic)
- a.should == "İß"
- end
-
- it "does not allow any other additional option" do
- -> { a = "iß"; a.capitalize!(:lithuanian, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- it "does not allow the :fold option for upcasing" do
- -> { a = "abc"; a.capitalize!(:fold) }.should raise_error(ArgumentError)
- end
-
- it "does not allow invalid options" do
- -> { a = "abc"; a.capitalize!(:invalid_option) }.should raise_error(ArgumentError)
end
it "returns nil when no changes are made" do
@@ -178,10 +61,10 @@ describe "String#capitalize!" do
"H".capitalize!.should == nil
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
["", "Hello", "hello"].each do |a|
a.freeze
- -> { a.capitalize! }.should raise_error(frozen_error_class)
+ lambda { a.capitalize! }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/string/case_compare_spec.rb b/spec/ruby/core/string/case_compare_spec.rb
index b83d1adb91..930f5bea90 100644
--- a/spec/ruby/core/string/case_compare_spec.rb
+++ b/spec/ruby/core/string/case_compare_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "String#===" do
- it_behaves_like :string_eql_value, :===
- it_behaves_like :string_equal_value, :===
+ it_behaves_like(:string_eql_value, :===)
+ it_behaves_like(:string_equal_value, :===)
end
diff --git a/spec/ruby/core/string/casecmp_spec.rb b/spec/ruby/core/string/casecmp_spec.rb
index 01b22e8f13..c77d97815c 100644
--- a/spec/ruby/core/string/casecmp_spec.rb
+++ b/spec/ruby/core/string/casecmp_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#casecmp independent of case" do
it "returns -1 when less than other" do
@@ -27,7 +27,7 @@ describe "String#casecmp independent of case" do
ruby_version_is ""..."2.5" do
it "raises a TypeError if other can't be converted to a string" do
- -> { "abc".casecmp(mock('abc')) }.should raise_error(TypeError)
+ lambda { "abc".casecmp(mock('abc')) }.should raise_error(TypeError)
end
end
@@ -37,10 +37,6 @@ describe "String#casecmp independent of case" do
end
end
- it "returns nil if incompatible encodings" do
- "ã‚れ".casecmp("れ".encode(Encoding::EUC_JP)).should be_nil
- end
-
describe "in UTF-8 mode" do
describe "for non-ASCII characters" do
before :each do
@@ -100,10 +96,6 @@ describe "String#casecmp independent of case" do
it "returns 1 when numerically greater than other" do
@lower_a_tilde.casecmp(@upper_a_tilde).should == 1
end
-
- it "does not case fold" do
- "ß".casecmp("ss").should == 1
- end
end
describe "when comparing a subclass instance" do
@@ -127,84 +119,66 @@ describe "String#casecmp independent of case" do
end
end
-describe 'String#casecmp? independent of case' do
- it 'returns true when equal to other' do
- 'abc'.casecmp?('abc').should == true
- 'abc'.casecmp?('ABC').should == true
- end
-
- it 'returns false when not equal to other' do
- 'abc'.casecmp?('DEF').should == false
- 'abc'.casecmp?('def').should == false
- end
-
- it "tries to convert other to string using to_str" do
- other = mock('x')
- other.should_receive(:to_str).and_return("abc")
-
- "abc".casecmp?(other).should == true
- end
-
- it "returns nil if incompatible encodings" do
- "ã‚れ".casecmp?("れ".encode(Encoding::EUC_JP)).should be_nil
- end
-
- describe 'for UNICODE characters' do
- it 'returns true when downcase(:fold) on unicode' do
- 'äöü'.casecmp?('ÄÖÜ').should == true
- end
- end
-
- describe "when comparing a subclass instance" do
+ruby_version_is "2.4" do
+ describe 'String#casecmp? independent of case' do
it 'returns true when equal to other' do
- a = StringSpecs::MyString.new "a"
- 'a'.casecmp?(a).should == true
- 'A'.casecmp?(a).should == true
+ 'abc'.casecmp?('abc').should == true
+ 'abc'.casecmp?('ABC').should == true
end
it 'returns false when not equal to other' do
- b = StringSpecs::MyString.new "a"
- 'b'.casecmp?(b).should == false
- 'B'.casecmp?(b).should == false
+ 'abc'.casecmp?('DEF').should == false
+ 'abc'.casecmp?('def').should == false
end
- end
- describe "in UTF-8 mode" do
- describe "for non-ASCII characters" do
- before :each do
- @upper_a_tilde = "Ã"
- @lower_a_tilde = "ã"
- @upper_a_umlaut = "Ä"
- @lower_a_umlaut = "ä"
- end
+ it "tries to convert other to string using to_str" do
+ other = mock('x')
+ other.should_receive(:to_str).and_return("abc")
+
+ "abc".casecmp?(other).should == true
+ end
- it "returns true when they are the same with normalized case" do
- @upper_a_tilde.casecmp?(@lower_a_tilde).should == true
+ describe 'for UNICODE characters' do
+ it 'returns true when downcase(:fold) on unicode' do
+ 'äöü'.casecmp?('ÄÖÜ').should == true
end
+ end
- it "returns false when they are unrelated" do
- @upper_a_tilde.casecmp?(@upper_a_umlaut).should == false
+ describe "when comparing a subclass instance" do
+ it 'returns true when equal to other' do
+ a = StringSpecs::MyString.new "a"
+ 'a'.casecmp?(a).should == true
+ 'A'.casecmp?(a).should == true
end
- it "returns true when they have the same bytes" do
- @upper_a_tilde.casecmp?(@upper_a_tilde).should == true
+ it 'returns false when not equal to other' do
+ b = StringSpecs::MyString.new "a"
+ 'b'.casecmp?(b).should == false
+ 'B'.casecmp?(b).should == false
end
end
- end
- it "case folds" do
- "ß".casecmp?("ss").should be_true
- end
+ describe "in UTF-8 mode" do
+ describe "for non-ASCII characters" do
+ before :each do
+ @upper_a_tilde = "Ã"
+ @lower_a_tilde = "ã"
+ @upper_a_umlaut = "Ä"
+ @lower_a_umlaut = "ä"
+ end
- ruby_version_is "2.4"..."2.5" do
- it "raises a TypeError if other can't be converted to a string" do
- -> { "abc".casecmp?(mock('abc')) }.should raise_error(TypeError)
- end
- end
+ it "returns true when they are the same with normalized case" do
+ @upper_a_tilde.casecmp?(@lower_a_tilde).should == true
+ end
- ruby_version_is "2.5" do
- it "returns nil if other can't be converted to a string" do
- "abc".casecmp?(mock('abc')).should be_nil
+ it "returns false when they are unrelated" do
+ @upper_a_tilde.casecmp?(@upper_a_umlaut).should == false
+ end
+
+ it "returns true when they have the same bytes" do
+ @upper_a_tilde.casecmp?(@upper_a_tilde).should == true
+ end
+ end
end
end
end
diff --git a/spec/ruby/core/string/center_spec.rb b/spec/ruby/core/string/center_spec.rb
index 0284fc28dc..4a40ef88bf 100644
--- a/spec/ruby/core/string/center_spec.rb
+++ b/spec/ruby/core/string/center_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#center with length, padding" do
it "returns a new string of specified length with self centered and padded with padstr" do
@@ -47,14 +47,12 @@ describe "String#center with length, padding" do
"radiology".center(8, '-').should == "radiology"
end
- ruby_version_is ''...'2.7' do
- it "taints result when self or padstr is tainted" do
- "x".taint.center(4).tainted?.should == true
- "x".taint.center(0).tainted?.should == true
- "".taint.center(0).tainted?.should == true
- "x".taint.center(4, "*").tainted?.should == true
- "x".center(4, "*".taint).tainted?.should == true
- end
+ it "taints result when self or padstr is tainted" do
+ "x".taint.center(4).tainted?.should == true
+ "x".taint.center(0).tainted?.should == true
+ "".taint.center(0).tainted?.should == true
+ "x".taint.center(4, "*").tainted?.should == true
+ "x".center(4, "*".taint).tainted?.should == true
end
it "calls #to_int to convert length to an integer" do
@@ -67,10 +65,10 @@ describe "String#center with length, padding" do
end
it "raises a TypeError when length can't be converted to an integer" do
- -> { "hello".center("x") }.should raise_error(TypeError)
- -> { "hello".center("x", "y") }.should raise_error(TypeError)
- -> { "hello".center([]) }.should raise_error(TypeError)
- -> { "hello".center(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".center("x") }.should raise_error(TypeError)
+ lambda { "hello".center("x", "y") }.should raise_error(TypeError)
+ lambda { "hello".center([]) }.should raise_error(TypeError)
+ lambda { "hello".center(mock('x')) }.should raise_error(TypeError)
end
it "calls #to_str to convert padstr to a String" do
@@ -81,14 +79,14 @@ describe "String#center with length, padding" do
end
it "raises a TypeError when padstr can't be converted to a string" do
- -> { "hello".center(20, 100) }.should raise_error(TypeError)
- -> { "hello".center(20, []) }.should raise_error(TypeError)
- -> { "hello".center(20, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".center(20, 100) }.should raise_error(TypeError)
+ lambda { "hello".center(20, []) }.should raise_error(TypeError)
+ lambda { "hello".center(20, mock('x')) }.should raise_error(TypeError)
end
it "raises an ArgumentError if padstr is empty" do
- -> { "hello".center(10, "") }.should raise_error(ArgumentError)
- -> { "hello".center(0, "") }.should raise_error(ArgumentError)
+ lambda { "hello".center(10, "") }.should raise_error(ArgumentError)
+ lambda { "hello".center(0, "") }.should raise_error(ArgumentError)
end
it "returns subclass instances when called on subclasses" do
@@ -100,36 +98,36 @@ describe "String#center with length, padding" do
"foo".center(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do
- "hello".center(4, 'X'.taint).tainted?.should be_false
- "hello".center(5, 'X'.taint).tainted?.should be_false
- "hello".center(6, 'X'.taint).tainted?.should be_true
- end
- end
-
- describe "with width" do
- it "returns a String in the same encoding as the original" do
- str = "abc".force_encoding Encoding::IBM437
- result = str.center 6
- result.should == " abc "
- result.encoding.should equal(Encoding::IBM437)
- end
+ it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do
+ "hello".center(4, 'X'.taint).tainted?.should be_false
+ "hello".center(5, 'X'.taint).tainted?.should be_false
+ "hello".center(6, 'X'.taint).tainted?.should be_true
end
- describe "with width, pattern" do
- it "returns a String in the compatible encoding" do
- str = "abc".force_encoding Encoding::IBM437
- result = str.center 6, "ã‚"
- result.should == "ã‚abcã‚ã‚"
- result.encoding.should equal(Encoding::UTF_8)
+ with_feature :encoding do
+ describe "with width" do
+ it "returns a String in the same encoding as the original" do
+ str = "abc".force_encoding Encoding::IBM437
+ result = str.center 6
+ result.should == " abc "
+ result.encoding.should equal(Encoding::IBM437)
+ end
end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- pat = "ã‚¢".encode Encoding::EUC_JP
- -> do
- "ã‚れ".center 5, pat
- end.should raise_error(Encoding::CompatibilityError)
+ describe "with width, pattern" do
+ it "returns a String in the compatible encoding" do
+ str = "abc".force_encoding Encoding::IBM437
+ result = str.center 6, "ã‚"
+ result.should == "ã‚abcã‚ã‚"
+ result.encoding.should equal(Encoding::UTF_8)
+ end
+
+ it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
+ pat = "ã‚¢".encode Encoding::EUC_JP
+ lambda do
+ "ã‚れ".center 5, pat
+ end.should raise_error(Encoding::CompatibilityError)
+ end
end
end
end
diff --git a/spec/ruby/core/string/chars_spec.rb b/spec/ruby/core/string/chars_spec.rb
index e4f26bc0cc..75cef89be1 100644
--- a/spec/ruby/core/string/chars_spec.rb
+++ b/spec/ruby/core/string/chars_spec.rb
@@ -1,10 +1,11 @@
-require_relative 'shared/chars'
-require_relative 'shared/each_char_without_block'
+require File.expand_path('../shared/chars', __FILE__)
+require File.expand_path('../shared/each_char_without_block', __FILE__)
describe "String#chars" do
- it_behaves_like :string_chars, :chars
+ it_behaves_like(:string_chars, :chars)
it "returns an array when no block given" do
- "hello".chars.should == ['h', 'e', 'l', 'l', 'o']
+ ary = "hello".send(@method)
+ ary.should == ['h', 'e', 'l', 'l', 'o']
end
end
diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb
index 20a0925959..5daa8c5a40 100644
--- a/spec/ruby/core/string/chomp_spec.rb
+++ b/spec/ruby/core/string/chomp_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#chomp" do
describe "when passed no argument" do
@@ -30,7 +30,7 @@ describe "String#chomp" do
"abc\r\r".chomp.should == "abc\r"
end
- it "removes one trailing carriage return, newline pair" do
+ it "removes one trailing carrige return, newline pair" do
"abc\r\n\r\n".chomp.should == "abc\r\n"
end
@@ -38,10 +38,8 @@ describe "String#chomp" do
"".chomp.should == ""
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc".taint.chomp.tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc".taint.chomp.tainted?.should be_true
end
it "returns subclass instances when called on a subclass" do
@@ -65,10 +63,8 @@ describe "String#chomp" do
str.chomp(nil).should_not equal(str)
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc".taint.chomp(nil).tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc".taint.chomp(nil).tainted?.should be_true
end
it "returns an empty String when self is empty" do
@@ -97,10 +93,8 @@ describe "String#chomp" do
"abc\r\n\r\n\r\n".chomp("").should == "abc"
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc".taint.chomp("").tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc".taint.chomp("").tainted?.should be_true
end
it "returns an empty String when self is empty" do
@@ -117,14 +111,12 @@ describe "String#chomp" do
"abc\r\r".chomp("\n").should == "abc\r"
end
- it "removes one trailing carriage return, newline pair" do
+ it "removes one trailing carrige return, newline pair" do
"abc\r\n\r\n".chomp("\n").should == "abc\r\n"
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc".taint.chomp("\n").tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc".taint.chomp("\n").tainted?.should be_true
end
it "returns an empty String when self is empty" do
@@ -142,7 +134,7 @@ describe "String#chomp" do
it "raises a TypeError if #to_str does not return a String" do
arg = mock("string chomp")
arg.should_receive(:to_str).and_return(1)
- -> { "abc".chomp(arg) }.should raise_error(TypeError)
+ lambda { "abc".chomp(arg) }.should raise_error(TypeError)
end
end
@@ -159,18 +151,12 @@ describe "String#chomp" do
"".chomp("abc").should == ""
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc".taint.chomp("abc").tainted?.should be_true
- end
-
- it "does not taint the result when the argument is tainted" do
- "abc".chomp("abc".taint).tainted?.should be_false
- end
+ it "taints the result if self is tainted" do
+ "abc".taint.chomp("abc").tainted?.should be_true
end
- it "returns an empty String when the argument equals self" do
- "abc".chomp("abc").should == ""
+ it "does not taint the result when the argument is tainted" do
+ "abc".chomp("abc".taint).tainted?.should be_false
end
end
end
@@ -203,7 +189,7 @@ describe "String#chomp!" do
"abc\r\r".chomp!.should == "abc\r"
end
- it "removes one trailing carriage return, newline pair" do
+ it "removes one trailing carrige return, newline pair" do
"abc\r\n\r\n".chomp!.should == "abc\r\n"
end
@@ -211,10 +197,8 @@ describe "String#chomp!" do
"".chomp!.should be_nil
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc\n".taint.chomp!.tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc\n".taint.chomp!.tainted?.should be_true
end
it "returns subclass instances when called on a subclass" do
@@ -259,10 +243,8 @@ describe "String#chomp!" do
"abc\r\n\r\n\r\n".chomp!("").should == "abc"
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc\n".taint.chomp!("").tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc\n".taint.chomp!("").tainted?.should be_true
end
it "returns nil when self is empty" do
@@ -279,14 +261,12 @@ describe "String#chomp!" do
"abc\r\r".chomp!("\n").should == "abc\r"
end
- it "removes one trailing carriage return, newline pair" do
+ it "removes one trailing carrige return, newline pair" do
"abc\r\n\r\n".chomp!("\n").should == "abc\r\n"
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc\n".taint.chomp!("\n").tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc\n".taint.chomp!("\n").tainted?.should be_true
end
it "returns nil when self is empty" do
@@ -304,7 +284,7 @@ describe "String#chomp!" do
it "raises a TypeError if #to_str does not return a String" do
arg = mock("string chomp")
arg.should_receive(:to_str).and_return(1)
- -> { "abc".chomp!(arg) }.should raise_error(TypeError)
+ lambda { "abc".chomp!(arg) }.should raise_error(TypeError)
end
end
@@ -321,87 +301,87 @@ describe "String#chomp!" do
"".chomp!("abc").should be_nil
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "abc".taint.chomp!("abc").tainted?.should be_true
- end
+ it "taints the result if self is tainted" do
+ "abc".taint.chomp!("abc").tainted?.should be_true
+ end
- it "does not taint the result when the argument is tainted" do
- "abc".chomp!("abc".taint).tainted?.should be_false
- end
+ it "does not taint the result when the argument is tainted" do
+ "abc".chomp!("abc".taint).tainted?.should be_false
end
end
- it "raises a #{frozen_error_class} on a frozen instance when it is modified" do
+ it "raises a RuntimeError on a frozen instance when it is modified" do
a = "string\n\r"
a.freeze
- -> { a.chomp! }.should raise_error(frozen_error_class)
+ lambda { a.chomp! }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on a frozen instance when it would not be modified" do
+ it "raises a RuntimeError on a frozen instance when it would not be modified" do
a = "string\n\r"
a.freeze
- -> { a.chomp!(nil) }.should raise_error(frozen_error_class)
- -> { a.chomp!("x") }.should raise_error(frozen_error_class)
+ lambda { a.chomp!(nil) }.should raise_error(RuntimeError)
+ lambda { a.chomp!("x") }.should raise_error(RuntimeError)
end
end
-describe "String#chomp" do
- before :each do
- @before_separator = $/
- end
+with_feature :encoding do
+ describe "String#chomp" do
+ before :each do
+ @before_separator = $/
+ end
- after :each do
- $/ = @before_separator
- end
+ after :each do
+ $/ = @before_separator
+ end
- it "does not modify a multi-byte character" do
- "ã‚れ".chomp.should == "ã‚れ"
- end
+ it "does not modify a multi-byte character" do
+ "ã‚れ".chomp.should == "ã‚れ"
+ end
- it "removes the final carriage return, newline from a multibyte String" do
- "ã‚れ\r\n".chomp.should == "ã‚れ"
- end
+ it "removes the final carriage return, newline from a multibyte String" do
+ "ã‚れ\r\n".chomp.should == "ã‚れ"
+ end
- it "removes the final carriage return, newline from a non-ASCII String" do
- str = "abc\r\n".encode "utf-32be"
- str.chomp.should == "abc".encode("utf-32be")
- end
+ it "removes the final carriage return, newline from a non-ASCII String" do
+ str = "abc\r\n".encode "utf-32be"
+ str.chomp.should == "abc".encode("utf-32be")
+ end
- it "removes the final carriage return, newline from a non-ASCII String when the record separator is changed" do
- $/ = "\n".encode("utf-8")
- str = "abc\r\n".encode "utf-32be"
- str.chomp.should == "abc".encode("utf-32be")
+ it "removes the final carriage return, newline from a non-ASCII String when the record separator is changed" do
+ $/ = "\n".encode("utf-8")
+ str = "abc\r\n".encode "utf-32be"
+ str.chomp.should == "abc".encode("utf-32be")
+ end
end
-end
-describe "String#chomp!" do
- before :each do
- @before_separator = $/
- end
+ describe "String#chomp!" do
+ before :each do
+ @before_separator = $/
+ end
- after :each do
- $/ = @before_separator
- end
+ after :each do
+ $/ = @before_separator
+ end
- it "returns nil when the String is not modified" do
- "ã‚れ".chomp!.should be_nil
- end
+ it "returns nil when the String is not modified" do
+ "ã‚れ".chomp!.should be_nil
+ end
- it "removes the final carriage return, newline from a multibyte String" do
- "ã‚れ\r\n".chomp!.should == "ã‚れ"
- end
+ it "removes the final carriage return, newline from a multibyte String" do
+ "ã‚れ\r\n".chomp!.should == "ã‚れ"
+ end
- it "removes the final carriage return, newline from a non-ASCII String" do
- str = "abc\r\n".encode "utf-32be"
- str.chomp!.should == "abc".encode("utf-32be")
- end
+ it "removes the final carriage return, newline from a non-ASCII String" do
+ str = "abc\r\n".encode "utf-32be"
+ str.chomp!.should == "abc".encode("utf-32be")
+ end
- it "removes the final carriage return, newline from a non-ASCII String when the record separator is changed" do
- $/ = "\n".encode("utf-8")
- str = "abc\r\n".encode "utf-32be"
- str.chomp!.should == "abc".encode("utf-32be")
+ it "removes the final carriage return, newline from a non-ASCII String when the record separator is changed" do
+ $/ = "\n".encode("utf-8")
+ str = "abc\r\n".encode "utf-32be"
+ str.chomp!.should == "abc".encode("utf-32be")
+ end
end
end
diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb
index 9e893c3bea..4e9a39f866 100644
--- a/spec/ruby/core/string/chop_spec.rb
+++ b/spec/ruby/core/string/chop_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#chop" do
it "removes the final character" do
@@ -19,7 +19,7 @@ describe "String#chop" do
"abc\r\n".chop.should == "abc"
end
- it "removes the carriage return, newline if they are the only characters" do
+ it "removes the carrige return, newline if they are the only characters" do
"\r\n".chop.should == ""
end
@@ -27,17 +27,19 @@ describe "String#chop" do
"abc\r\n\r\n".chop.should == "abc\r\n"
end
- it "removes a multi-byte character" do
- "ã‚れ".chop.should == "ã‚"
- end
+ with_feature :encoding do
+ it "removes a multi-byte character" do
+ "ã‚れ".chop.should == "ã‚"
+ end
- it "removes the final carriage return, newline from a multibyte String" do
- "ã‚れ\r\n".chop.should == "ã‚れ"
- end
+ it "removes the final carriage return, newline from a multibyte String" do
+ "ã‚れ\r\n".chop.should == "ã‚れ"
+ end
- it "removes the final carriage return, newline from a non-ASCII String" do
- str = "abc\r\n".encode "utf-32be"
- str.chop.should == "abc".encode("utf-32be")
+ it "removes the final carriage return, newline from a non-ASCII String" do
+ str = "abc\r\n".encode "utf-32be"
+ str.chop.should == "abc".encode("utf-32be")
+ end
end
it "returns an empty string when applied to an empty string" do
@@ -49,16 +51,14 @@ describe "String#chop" do
s.chop.should_not equal(s)
end
- ruby_version_is ''...'2.7' do
- it "taints result when self is tainted" do
- "hello".taint.chop.tainted?.should == true
- "".taint.chop.tainted?.should == true
- end
+ it "taints result when self is tainted" do
+ "hello".taint.chop.tainted?.should == true
+ "".taint.chop.tainted?.should == true
+ end
- it "untrusts result when self is untrusted" do
- "hello".untrust.chop.untrusted?.should == true
- "".untrust.chop.untrusted?.should == true
- end
+ it "untrusts result when self is untrusted" do
+ "hello".untrust.chop.untrusted?.should == true
+ "".untrust.chop.untrusted?.should == true
end
it "returns subclass instances when called on a subclass" do
@@ -83,7 +83,7 @@ describe "String#chop!" do
"abc\r\n".chop!.should == "abc"
end
- it "removes the carriage return, newline if they are the only characters" do
+ it "removes the carrige return, newline if they are the only characters" do
"\r\n".chop!.should == ""
end
@@ -91,17 +91,19 @@ describe "String#chop!" do
"abc\r\n\r\n".chop!.should == "abc\r\n"
end
- it "removes a multi-byte character" do
- "ã‚れ".chop!.should == "ã‚"
- end
+ with_feature :encoding do
+ it "removes a multi-byte character" do
+ "ã‚れ".chop!.should == "ã‚"
+ end
- it "removes the final carriage return, newline from a multibyte String" do
- "ã‚れ\r\n".chop!.should == "ã‚れ"
- end
+ it "removes the final carriage return, newline from a multibyte String" do
+ "ã‚れ\r\n".chop!.should == "ã‚れ"
+ end
- it "removes the final carriage return, newline from a non-ASCII String" do
- str = "abc\r\n".encode "utf-32be"
- str.chop!.should == "abc".encode("utf-32be")
+ it "removes the final carriage return, newline from a non-ASCII String" do
+ str = "abc\r\n".encode "utf-32be"
+ str.chop!.should == "abc".encode("utf-32be")
+ end
end
it "returns self if modifications were made" do
@@ -113,14 +115,14 @@ describe "String#chop!" do
"".chop!.should be_nil
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> { "string\n\r".freeze.chop! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda { "string\n\r".freeze.chop! }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
a = ""
a.freeze
- -> { a.chop! }.should raise_error(frozen_error_class)
+ lambda { a.chop! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/chr_spec.rb b/spec/ruby/core/string/chr_spec.rb
index 9ed29542e6..c7834b78b7 100644
--- a/spec/ruby/core/string/chr_spec.rb
+++ b/spec/ruby/core/string/chr_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
-
-describe "String#chr" do
- it "returns a copy of self" do
- s = 'e'
- s.should_not equal s.chr
- end
-
- it "returns a String" do
- 'glark'.chr.should be_an_instance_of(String)
- end
-
- it "returns an empty String if self is an empty String" do
- "".chr.should == ""
- end
-
- it "returns a 1-character String" do
- "glark".chr.size.should == 1
- end
-
- it "returns the character at the start of the String" do
- "Goodbye, world".chr.should == "G"
- end
-
- it "returns a String in the same encoding as self" do
- "\x24".encode(Encoding::US_ASCII).chr.encoding.should == Encoding::US_ASCII
- end
-
- it "understands multi-byte characters" do
- s = "\u{9879}"
- s.bytesize.should == 3
- s.chr.should == s
- end
-
- it "understands Strings that contain a mixture of character widths" do
- three = "\u{8082}"
- three.bytesize.should == 3
- four = "\u{77082}"
- four.bytesize.should == 4
- "#{three}#{four}".chr.should == three
+require File.expand_path('../../../spec_helper', __FILE__)
+
+with_feature :encoding do
+ describe "String#chr" do
+ it "returns a copy of self" do
+ s = 'e'
+ s.object_id.should_not == s.chr.object_id
+ end
+
+ it "returns a String" do
+ 'glark'.chr.should be_an_instance_of(String)
+ end
+
+ it "returns an empty String if self is an empty String" do
+ "".chr.should == ""
+ end
+
+ it "returns a 1-character String" do
+ "glark".chr.size.should == 1
+ end
+
+ it "returns the character at the start of the String" do
+ "Goodbye, world".chr.should == "G"
+ end
+
+ it "returns a String in the same encoding as self" do
+ "\x24".encode(Encoding::US_ASCII).chr.encoding.should == Encoding::US_ASCII
+ end
+
+ it "understands multi-byte characters" do
+ s = "\u{9879}"
+ s.bytesize.should == 3
+ s.chr.should == s
+ end
+
+ it "understands Strings that contain a mixture of character widths" do
+ three = "\u{8082}"
+ three.bytesize.should == 3
+ four = "\u{77082}"
+ four.bytesize.should == 4
+ "#{three}#{four}".chr.should == three
+ end
end
end
diff --git a/spec/ruby/core/string/clear_spec.rb b/spec/ruby/core/string/clear_spec.rb
index 0b5b8e6998..6a8b6018d0 100644
--- a/spec/ruby/core/string/clear_spec.rb
+++ b/spec/ruby/core/string/clear_spec.rb
@@ -1,37 +1,39 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "String#clear" do
- before :each do
- @s = "Jolene"
- end
+with_feature :encoding do
+ describe "String#clear" do
+ before :each do
+ @s = "Jolene"
+ end
- it "sets self equal to the empty String" do
- @s.clear
- @s.should == ""
- end
+ it "sets self equal to the empty String" do
+ @s.clear
+ @s.should == ""
+ end
- it "returns self after emptying it" do
- cleared = @s.clear
- cleared.should == ""
- cleared.should equal @s
- end
+ it "returns self after emptying it" do
+ cleared = @s.clear
+ cleared.should == ""
+ cleared.object_id.should == @s.object_id
+ end
- it "preserves its encoding" do
- @s.encode!(Encoding::SHIFT_JIS)
- @s.encoding.should == Encoding::SHIFT_JIS
- @s.clear.encoding.should == Encoding::SHIFT_JIS
- @s.encoding.should == Encoding::SHIFT_JIS
- end
+ it "preserves its encoding" do
+ @s.encode!(Encoding::SHIFT_JIS)
+ @s.encoding.should == Encoding::SHIFT_JIS
+ @s.clear.encoding.should == Encoding::SHIFT_JIS
+ @s.encoding.should == Encoding::SHIFT_JIS
+ end
- it "works with multibyte Strings" do
- s = "\u{9765}\u{876}"
- s.clear
- s.should == ""
- end
+ it "works with multibyte Strings" do
+ s = "\u{9765}\u{876}"
+ s.clear
+ s.should == ""
+ end
- it "raises a #{frozen_error_class} if self is frozen" do
- @s.freeze
- -> { @s.clear }.should raise_error(frozen_error_class)
- -> { "".freeze.clear }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ @s.freeze
+ lambda { @s.clear }.should raise_error(RuntimeError)
+ lambda { "".freeze.clear }.should raise_error(RuntimeError)
+ end
end
end
diff --git a/spec/ruby/core/string/clone_spec.rb b/spec/ruby/core/string/clone_spec.rb
index f8d40423f0..3940858e53 100644
--- a/spec/ruby/core/string/clone_spec.rb
+++ b/spec/ruby/core/string/clone_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "String#clone" do
before :each do
@@ -55,3 +55,4 @@ describe "String#clone" do
clone.should == "string"
end
end
+
diff --git a/spec/ruby/core/string/codepoints_spec.rb b/spec/ruby/core/string/codepoints_spec.rb
index 0b6cde82f7..6304513583 100644
--- a/spec/ruby/core/string/codepoints_spec.rb
+++ b/spec/ruby/core/string/codepoints_spec.rb
@@ -1,18 +1,20 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/codepoints'
-require_relative 'shared/each_codepoint_without_block'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/codepoints', __FILE__)
+require File.expand_path('../shared/each_codepoint_without_block', __FILE__)
-describe "String#codepoints" do
- it_behaves_like :string_codepoints, :codepoints
+with_feature :encoding do
+ describe "String#codepoints" do
+ it_behaves_like(:string_codepoints, :codepoints)
- it "returns an Array when no block is given" do
- "abc".codepoints.should == [?a.ord, ?b.ord, ?c.ord]
- end
+ it "returns an Array when no block is given" do
+ "abc".send(@method).should == [?a.ord, ?b.ord, ?c.ord]
+ end
- it "raises an ArgumentError when no block is given if self has an invalid encoding" do
- s = "\xDF".force_encoding(Encoding::UTF_8)
- s.valid_encoding?.should be_false
- -> { s.codepoints }.should raise_error(ArgumentError)
+ it "raises an ArgumentError when no block is given if self has an invalid encoding" do
+ s = "\xDF".force_encoding(Encoding::UTF_8)
+ s.valid_encoding?.should be_false
+ lambda {s.send(@method)}.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/string/comparison_spec.rb b/spec/ruby/core/string/comparison_spec.rb
index 01199274b6..5a0e7fabc3 100644
--- a/spec/ruby/core/string/comparison_spec.rb
+++ b/spec/ruby/core/string/comparison_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#<=> with String" do
it "compares individual characters based on their ascii value" do
diff --git a/spec/ruby/core/string/concat_spec.rb b/spec/ruby/core/string/concat_spec.rb
index 5f6daadad7..939be5ed0a 100644
--- a/spec/ruby/core/string/concat_spec.rb
+++ b/spec/ruby/core/string/concat_spec.rb
@@ -1,26 +1,28 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/concat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/concat', __FILE__)
describe "String#concat" do
it_behaves_like :string_concat, :concat
it_behaves_like :string_concat_encoding, :concat
- it "takes multiple arguments" do
- str = "hello "
- str.concat "wo", "", "rld"
- str.should == "hello world"
- end
+ ruby_version_is "2.4" do
+ it "takes multiple arguments" do
+ str = "hello "
+ str.concat "wo", "", "rld"
+ str.should == "hello world"
+ end
- it "concatenates the initial value when given arguments contain 2 self" do
- str = "hello"
- str.concat str, str
- str.should == "hellohellohello"
- end
+ it "concatenates the initial value when given arguments contain 2 self" do
+ str = "hello"
+ str.concat str, str
+ str.should == "hellohellohello"
+ end
- it "returns self when given no arguments" do
- str = "hello"
- str.concat.should equal(str)
- str.should == "hello"
+ it "returns self when given no arguments" do
+ str = "hello"
+ str.concat.should equal(str)
+ str.should == "hello"
+ end
end
end
diff --git a/spec/ruby/core/string/count_spec.rb b/spec/ruby/core/string/count_spec.rb
index 06ba5a4f0e..3afb79a9fc 100644
--- a/spec/ruby/core/string/count_spec.rb
+++ b/spec/ruby/core/string/count_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#count" do
it "counts occurrences of chars from the intersection of the specified sets" do
@@ -23,7 +23,7 @@ describe "String#count" do
end
it "raises an ArgumentError when given no arguments" do
- -> { "hell yeah".count }.should raise_error(ArgumentError)
+ lambda { "hell yeah".count }.should raise_error(ArgumentError)
end
it "negates sets starting with ^" do
@@ -76,8 +76,8 @@ describe "String#count" do
it "raises if the given sequences are invalid" do
s = "hel-[()]-lo012^"
- -> { s.count("h-e") }.should raise_error(ArgumentError)
- -> { s.count("^h-e") }.should raise_error(ArgumentError)
+ lambda { s.count("h-e") }.should raise_error(ArgumentError)
+ lambda { s.count("^h-e") }.should raise_error(ArgumentError)
end
it 'returns the number of occurrences of a multi-byte character' do
@@ -98,8 +98,8 @@ describe "String#count" do
end
it "raises a TypeError when a set arg can't be converted to a string" do
- -> { "hello world".count(100) }.should raise_error(TypeError)
- -> { "hello world".count([]) }.should raise_error(TypeError)
- -> { "hello world".count(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello world".count(100) }.should raise_error(TypeError)
+ lambda { "hello world".count([]) }.should raise_error(TypeError)
+ lambda { "hello world".count(mock('x')) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb
index 6a9a4ae235..d3bf5ec732 100644
--- a/spec/ruby/core/string/crypt_spec.rb
+++ b/spec/ruby/core/string/crypt_spec.rb
@@ -1,122 +1,75 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#crypt" do
- platform_is :openbsd do
- it "returns a cryptographic hash of self by applying the bcrypt algorithm with the specified salt" do
- "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should == "$2a$04$0WVaz0pV3jzfZ5G5tpmHWuBQGbkjzgtSc3gJbmdy0GAGMa45MFM2."
-
- # Only uses first 72 characters of string
- ("12345678"*9).crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should == "$2a$04$0WVaz0pV3jzfZ5G5tpmHWukj/ORBnsMjCGpST/zCJnAypc7eAbutK"
- ("12345678"*10).crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should == "$2a$04$0WVaz0pV3jzfZ5G5tpmHWukj/ORBnsMjCGpST/zCJnAypc7eAbutK"
-
- # Only uses first 29 characters of salt
- "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWuB").should == "$2a$04$0WVaz0pV3jzfZ5G5tpmHWuBQGbkjzgtSc3gJbmdy0GAGMa45MFM2."
- end
-
- it "raises Errno::EINVAL when the salt is shorter than 29 characters" do
- -> { "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHW") }.should raise_error(Errno::EINVAL)
- end
-
- it "calls #to_str to converts the salt arg to a String" do
- obj = mock('$2a$04$0WVaz0pV3jzfZ5G5tpmHWu')
- obj.should_receive(:to_str).and_return("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")
-
- "mypassword".crypt(obj).should == "$2a$04$0WVaz0pV3jzfZ5G5tpmHWuBQGbkjzgtSc3gJbmdy0GAGMa45MFM2."
- end
-
- ruby_version_is ''...'2.7' do
- it "taints the result if either salt or self is tainted" do
- tainted_salt = "$2a$04$0WVaz0pV3jzfZ5G5tpmHWu"
- tainted_str = "mypassword"
-
- tainted_salt.taint
- tainted_str.taint
-
- "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").tainted?.should == false
- tainted_str.crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").tainted?.should == true
- "mypassword".crypt(tainted_salt).tainted?.should == true
- tainted_str.crypt(tainted_salt).tainted?.should == true
- end
- end
-
- it "doesn't return subclass instances" do
- StringSpecs::MyString.new("mypassword").crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should be_an_instance_of(String)
- "mypassword".crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should be_an_instance_of(String)
- StringSpecs::MyString.new("mypassword").crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should be_an_instance_of(String)
- end
+ # Note: MRI's documentation just says that the C stdlib function crypt() is
+ # called.
+ #
+ # I'm not sure if crypt() is guaranteed to produce the same result across
+ # different platforms. It seems that there is one standard UNIX implementation
+ # of crypt(), but that alternative implementations are possible. See
+ # http://www.unix.org.ua/orelly/networking/puis/ch08_06.htm
+ it "returns a cryptographic hash of self by applying the UNIX crypt algorithm with the specified salt" do
+ "".crypt("aa").should == "aaQSqAReePlq6"
+ "nutmeg".crypt("Mi").should == "MiqkFWCm1fNJI"
+ "ellen1".crypt("ri").should == "ri79kNd7V6.Sk"
+ "Sharon".crypt("./").should == "./UY9Q7TvYJDg"
+ "norahs".crypt("am").should == "amfIADT2iqjA."
+ "norahs".crypt("7a").should == "7azfT5tIdyh0I"
+
+ # Only uses first 8 chars of string
+ "01234567".crypt("aa").should == "aa4c4gpuvCkSE"
+ "012345678".crypt("aa").should == "aa4c4gpuvCkSE"
+ "0123456789".crypt("aa").should == "aa4c4gpuvCkSE"
+
+ # Only uses first 2 chars of salt
+ "hello world".crypt("aa").should == "aayPz4hyPS1wI"
+ "hello world".crypt("aab").should == "aayPz4hyPS1wI"
+ "hello world".crypt("aabc").should == "aayPz4hyPS1wI"
end
- platform_is_not :openbsd do
- # Note: MRI's documentation just says that the C stdlib function crypt() is
- # called.
- #
- # I'm not sure if crypt() is guaranteed to produce the same result across
- # different platforms. It seems that there is one standard UNIX implementation
- # of crypt(), but that alternative implementations are possible. See
- # http://www.unix.org.ua/orelly/networking/puis/ch08_06.htm
- it "returns a cryptographic hash of self by applying the UNIX crypt algorithm with the specified salt" do
- "".crypt("aa").should == "aaQSqAReePlq6"
- "nutmeg".crypt("Mi").should == "MiqkFWCm1fNJI"
- "ellen1".crypt("ri").should == "ri79kNd7V6.Sk"
- "Sharon".crypt("./").should == "./UY9Q7TvYJDg"
- "norahs".crypt("am").should == "amfIADT2iqjA."
- "norahs".crypt("7a").should == "7azfT5tIdyh0I"
-
- # Only uses first 8 chars of string
- "01234567".crypt("aa").should == "aa4c4gpuvCkSE"
- "012345678".crypt("aa").should == "aa4c4gpuvCkSE"
- "0123456789".crypt("aa").should == "aa4c4gpuvCkSE"
-
- # Only uses first 2 chars of salt
- "hello world".crypt("aa").should == "aayPz4hyPS1wI"
- "hello world".crypt("aab").should == "aayPz4hyPS1wI"
- "hello world".crypt("aabc").should == "aayPz4hyPS1wI"
- end
+ it "raises an ArgumentError when the salt is shorter than two characters" do
+ lambda { "hello".crypt("") }.should raise_error(ArgumentError)
+ lambda { "hello".crypt("f") }.should raise_error(ArgumentError)
+ lambda { "hello".crypt("\x00\x00") }.should raise_error(ArgumentError)
+ lambda { "hello".crypt("\x00a") }.should raise_error(ArgumentError)
+ lambda { "hello".crypt("a\x00") }.should raise_error(ArgumentError)
+ end
+ ruby_version_is "2.3" do
it "raises an ArgumentError when the string contains NUL character" do
- -> { "poison\0null".crypt("aa") }.should raise_error(ArgumentError)
+ lambda { "poison\0null".crypt("aa") }.should raise_error(ArgumentError)
end
+ end
- it "calls #to_str to converts the salt arg to a String" do
- obj = mock('aa')
- obj.should_receive(:to_str).and_return("aa")
-
- "".crypt(obj).should == "aaQSqAReePlq6"
- end
+ it "calls #to_str to converts the salt arg to a String" do
+ obj = mock('aa')
+ obj.should_receive(:to_str).and_return("aa")
- ruby_version_is ''...'2.7' do
- it "taints the result if either salt or self is tainted" do
- tainted_salt = "aa"
- tainted_str = "hello"
+ "".crypt(obj).should == "aaQSqAReePlq6"
+ end
- tainted_salt.taint
- tainted_str.taint
+ it "raises a type error when the salt arg can't be converted to a string" do
+ lambda { "".crypt(5) }.should raise_error(TypeError)
+ lambda { "".crypt(mock('x')) }.should raise_error(TypeError)
+ end
- "hello".crypt("aa").tainted?.should == false
- tainted_str.crypt("aa").tainted?.should == true
- "hello".crypt(tainted_salt).tainted?.should == true
- tainted_str.crypt(tainted_salt).tainted?.should == true
- end
- end
+ it "taints the result if either salt or self is tainted" do
+ tainted_salt = "aa"
+ tainted_str = "hello"
- it "doesn't return subclass instances" do
- StringSpecs::MyString.new("hello").crypt("aa").should be_an_instance_of(String)
- "hello".crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String)
- StringSpecs::MyString.new("hello").crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String)
- end
+ tainted_salt.taint
+ tainted_str.taint
- it "raises an ArgumentError when the salt is shorter than two characters" do
- -> { "hello".crypt("") }.should raise_error(ArgumentError)
- -> { "hello".crypt("f") }.should raise_error(ArgumentError)
- -> { "hello".crypt("\x00\x00") }.should raise_error(ArgumentError)
- -> { "hello".crypt("\x00a") }.should raise_error(ArgumentError)
- -> { "hello".crypt("a\x00") }.should raise_error(ArgumentError)
- end
+ "hello".crypt("aa").tainted?.should == false
+ tainted_str.crypt("aa").tainted?.should == true
+ "hello".crypt(tainted_salt).tainted?.should == true
+ tainted_str.crypt(tainted_salt).tainted?.should == true
end
- it "raises a type error when the salt arg can't be converted to a string" do
- -> { "".crypt(5) }.should raise_error(TypeError)
- -> { "".crypt(mock('x')) }.should raise_error(TypeError)
+ it "doesn't return subclass instances" do
+ StringSpecs::MyString.new("hello").crypt("aa").should be_an_instance_of(String)
+ "hello".crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String)
+ StringSpecs::MyString.new("hello").crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String)
end
end
diff --git a/spec/ruby/core/string/delete_prefix_spec.rb b/spec/ruby/core/string/delete_prefix_spec.rb
index 92c301b44a..94d486eace 100644
--- a/spec/ruby/core/string/delete_prefix_spec.rb
+++ b/spec/ruby/core/string/delete_prefix_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
ruby_version_is '2.5' do
describe "String#delete_prefix" do
@@ -22,11 +22,9 @@ ruby_version_is '2.5' do
r.should == s
end
- ruby_version_is ''...'2.7' do
- it "taints resulting strings when other is tainted" do
- 'hello'.taint.delete_prefix('hell').tainted?.should == true
- 'hello'.taint.delete_prefix('').tainted?.should == true
- end
+ it "taints resulting strings when other is tainted" do
+ 'hello'.taint.delete_prefix('hell').tainted?.should == true
+ 'hello'.taint.delete_prefix('').tainted?.should == true
end
it "doesn't set $~" do
@@ -74,10 +72,10 @@ ruby_version_is '2.5' do
'hello'.delete_prefix!(o).should == 'o'
end
- it "raises a #{frozen_error_class} when self is frozen" do
- -> { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(frozen_error_class)
- -> { 'hello'.freeze.delete_prefix!('') }.should raise_error(frozen_error_class)
- -> { ''.freeze.delete_prefix!('') }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when self is frozen" do
+ lambda { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(RuntimeError)
+ lambda { 'hello'.freeze.delete_prefix!('') }.should raise_error(RuntimeError)
+ lambda { ''.freeze.delete_prefix!('') }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/string/delete_spec.rb b/spec/ruby/core/string/delete_spec.rb
index 130228041e..536d4a95af 100644
--- a/spec/ruby/core/string/delete_spec.rb
+++ b/spec/ruby/core/string/delete_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#delete" do
it "returns a new string with the chars from the intersection of sets removed" do
@@ -14,7 +14,7 @@ describe "String#delete" do
end
it "raises an ArgumentError when given no arguments" do
- -> { "hell yeah".delete }.should raise_error(ArgumentError)
+ lambda { "hell yeah".delete }.should raise_error(ArgumentError)
end
it "negates sets starting with ^" do
@@ -62,19 +62,17 @@ describe "String#delete" do
not_supported_on :opal do
xFF = [0xFF].pack('C')
range = "\x00 - #{xFF}".force_encoding('utf-8')
- -> { "hello".delete(range).should == "" }.should raise_error(ArgumentError)
+ lambda { "hello".delete(range).should == "" }.should raise_error(ArgumentError)
end
- -> { "hello".delete("h-e") }.should raise_error(ArgumentError)
- -> { "hello".delete("^h-e") }.should raise_error(ArgumentError)
+ lambda { "hello".delete("h-e") }.should raise_error(ArgumentError)
+ lambda { "hello".delete("^h-e") }.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "taints result when self is tainted" do
- "hello".taint.delete("e").tainted?.should == true
- "hello".taint.delete("a-z").tainted?.should == true
+ it "taints result when self is tainted" do
+ "hello".taint.delete("e").tainted?.should == true
+ "hello".taint.delete("a-z").tainted?.should == true
- "hello".delete("e".taint).tainted?.should == false
- end
+ "hello".delete("e".taint).tainted?.should == false
end
it "tries to convert each set arg to a string using to_str" do
@@ -88,9 +86,9 @@ describe "String#delete" do
end
it "raises a TypeError when one set arg can't be converted to a string" do
- -> { "hello world".delete(100) }.should raise_error(TypeError)
- -> { "hello world".delete([]) }.should raise_error(TypeError)
- -> { "hello world".delete(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello world".delete(100) }.should raise_error(TypeError)
+ lambda { "hello world".delete([]) }.should raise_error(TypeError)
+ lambda { "hello world".delete(mock('x')) }.should raise_error(TypeError)
end
it "returns subclass instances when called on a subclass" do
@@ -111,11 +109,11 @@ describe "String#delete!" do
a.should == "hello"
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
a = "hello"
a.freeze
- -> { a.delete!("") }.should raise_error(frozen_error_class)
- -> { a.delete!("aeiou", "^e") }.should raise_error(frozen_error_class)
+ lambda { a.delete!("") }.should raise_error(RuntimeError)
+ lambda { a.delete!("aeiou", "^e") }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/delete_suffix_spec.rb b/spec/ruby/core/string/delete_suffix_spec.rb
index edc0f73158..49689a8da1 100644
--- a/spec/ruby/core/string/delete_suffix_spec.rb
+++ b/spec/ruby/core/string/delete_suffix_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
ruby_version_is '2.5' do
describe "String#delete_suffix" do
@@ -22,11 +22,9 @@ ruby_version_is '2.5' do
r.should == s
end
- ruby_version_is ''...'2.7' do
- it "taints resulting strings when other is tainted" do
- 'hello'.taint.delete_suffix('ello').tainted?.should == true
- 'hello'.taint.delete_suffix('').tainted?.should == true
- end
+ it "taints resulting strings when other is tainted" do
+ 'hello'.taint.delete_suffix('ello').tainted?.should == true
+ 'hello'.taint.delete_suffix('').tainted?.should == true
end
it "doesn't set $~" do
@@ -74,10 +72,10 @@ ruby_version_is '2.5' do
'hello'.delete_suffix!(o).should == 'h'
end
- it "raises a #{frozen_error_class} when self is frozen" do
- -> { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(frozen_error_class)
- -> { 'hello'.freeze.delete_suffix!('') }.should raise_error(frozen_error_class)
- -> { ''.freeze.delete_suffix!('') }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when self is frozen" do
+ lambda { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(RuntimeError)
+ lambda { 'hello'.freeze.delete_suffix!('') }.should raise_error(RuntimeError)
+ lambda { ''.freeze.delete_suffix!('') }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb
index 84e94ee104..f591c0fa09 100644
--- a/spec/ruby/core/string/downcase_spec.rb
+++ b/spec/ruby/core/string/downcase_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#downcase" do
it "returns a copy of self with all uppercase letters downcased" do
@@ -8,72 +8,30 @@ describe "String#downcase" do
"hello".downcase.should == "hello"
end
- describe "full Unicode case mapping" do
- it "works for all of Unicode with no option" do
- "ÄÖÜ".downcase.should == "äöü"
- end
+ ruby_version_is ''...'2.4' do
+ it "is locale insensitive (only replaces A-Z)" do
+ "ÄÖÜ".downcase.should == "ÄÖÜ"
- it "updates string metadata" do
- downcased = "\u{212A}ING".downcase
+ str = Array.new(256) { |c| c.chr }.join
+ expected = Array.new(256) do |i|
+ c = i.chr
+ c.between?("A", "Z") ? c.downcase : c
+ end.join
- downcased.should == "king"
- downcased.size.should == 4
- downcased.bytesize.should == 4
- downcased.ascii_only?.should be_true
+ str.downcase.should == expected
end
end
- describe "ASCII-only case mapping" do
- it "does not downcase non-ASCII characters" do
- "Câ„«R".downcase(:ascii).should == "câ„«r"
- end
- end
-
- describe "full Unicode case mapping adapted for Turkic languages" do
- it "downcases characters according to Turkic semantics" do
- "İ".downcase(:turkic).should == "i"
- end
-
- it "allows Lithuanian as an extra option" do
- "İ".downcase(:turkic, :lithuanian).should == "i"
- end
-
- it "does not allow any other additional option" do
- -> { "İ".downcase(:turkic, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- "İS".downcase(:lithuanian).should == "i\u{307}s"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- "İS".downcase(:lithuanian, :turkic).should == "is"
- end
-
- it "does not allow any other additional option" do
- -> { "İS".downcase(:lithuanian, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- describe "case folding" do
- it "case folds special characters" do
- "ß".downcase.should == "ß"
- "ß".downcase(:fold).should == "ss"
+ ruby_version_is '2.4' do
+ it "works for all of Unicode" do
+ "ÄÖÜ".downcase.should == "äöü"
end
end
- it "does not allow invalid options" do
- -> { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError)
- end
-
- ruby_version_is ''...'2.7' do
- it "taints result when self is tainted" do
- "".taint.downcase.tainted?.should == true
- "x".taint.downcase.tainted?.should == true
- "X".taint.downcase.tainted?.should == true
- end
+ it "taints result when self is tainted" do
+ "".taint.downcase.tainted?.should == true
+ "x".taint.downcase.tainted?.should == true
+ "X".taint.downcase.tainted?.should == true
end
it "returns a subclass instance for subclasses" do
@@ -88,81 +46,12 @@ describe "String#downcase!" do
a.should == "hello"
end
- describe "full Unicode case mapping" do
- it "modifies self in place for all of Unicode with no option" do
+ ruby_version_is '2.4' do
+ it "modifies self in place for all of Unicode" do
a = "ÄÖÜ"
- a.downcase!
+ a.downcase!.should equal(a)
a.should == "äöü"
end
-
- it "updates string metadata" do
- downcased = "\u{212A}ING"
- downcased.downcase!
-
- downcased.should == "king"
- downcased.size.should == 4
- downcased.bytesize.should == 4
- downcased.ascii_only?.should be_true
- end
- end
-
- describe "ASCII-only case mapping" do
- it "does not downcase non-ASCII characters" do
- a = "Câ„«R"
- a.downcase!(:ascii)
- a.should == "câ„«r"
- end
- end
-
- describe "full Unicode case mapping adapted for Turkic languages" do
- it "downcases characters according to Turkic semantics" do
- a = "İ"
- a.downcase!(:turkic)
- a.should == "i"
- end
-
- it "allows Lithuanian as an extra option" do
- a = "İ"
- a.downcase!(:turkic, :lithuanian)
- a.should == "i"
- end
-
- it "does not allow any other additional option" do
- -> { a = "İ"; a.downcase!(:turkic, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- a = "İS"
- a.downcase!(:lithuanian)
- a.should == "i\u{307}s"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- a = "İS"
- a.downcase!(:lithuanian, :turkic)
- a.should == "is"
- end
-
- it "does not allow any other additional option" do
- -> { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- describe "case folding" do
- it "case folds special characters" do
- a = "ß"
- a.downcase!
- a.should == "ß"
-
- a.downcase!(:fold)
- a.should == "ss"
- end
- end
-
- it "does not allow invalid options" do
- -> { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError)
end
it "returns nil if no modifications were made" do
@@ -171,12 +60,14 @@ describe "String#downcase!" do
a.should == "hello"
end
- it "raises a #{frozen_error_class} when self is frozen" do
- -> { "HeLlo".freeze.downcase! }.should raise_error(frozen_error_class)
- -> { "hello".freeze.downcase! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when self is frozen" do
+ lambda { "HeLlo".freeze.downcase! }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.downcase! }.should raise_error(RuntimeError)
end
- it "sets the result String encoding to the source String encoding" do
- "ABC".downcase.encoding.should equal(Encoding::UTF_8)
+ with_feature :encoding do
+ it "sets the result String encoding to the source String encoding" do
+ "ABC".downcase.encoding.should equal(Encoding::UTF_8)
+ end
end
end
diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb
index 260ee37adb..db743ad08f 100644
--- a/spec/ruby/core/string/dump_spec.rb
+++ b/spec/ruby/core/string/dump_spec.rb
@@ -1,32 +1,22 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "String#dump" do
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "foo".taint.dump.tainted?.should == true
- "foo\n".taint.dump.tainted?.should == true
- end
-
- it "untrusts the result if self is untrusted" do
- "foo".untrust.dump.untrusted?.should == true
- "foo\n".untrust.dump.untrusted?.should == true
- end
+ it "taints the result if self is tainted" do
+ "foo".taint.dump.tainted?.should == true
+ "foo\n".taint.dump.tainted?.should == true
end
- it "does not take into account if a string is frozen" do
- "foo".freeze.dump.frozen?.should == false
+ it "untrusts the result if self is untrusted" do
+ "foo".untrust.dump.untrusted?.should == true
+ "foo\n".untrust.dump.untrusted?.should == true
end
it "returns a subclass instance" do
StringSpecs::MyString.new.dump.should be_an_instance_of(StringSpecs::MyString)
end
- it "wraps string with \"" do
- "foo".dump.should == '"foo"'
- end
-
it "returns a string with special characters replaced with \\<char> notation" do
[ ["\a", '"\\a"'],
["\b", '"\\b"'],
@@ -45,11 +35,10 @@ describe "String#dump" do
].should be_computed_by(:dump)
end
- it "returns a string with \\#<char> when # is followed by $, @, @@, {" do
- [ ["\#$PATH", '"\\#$PATH"'],
- ["\#@a", '"\\#@a"'],
- ["\#@@a", '"\\#@@a"'],
- ["\#{a}", '"\\#{a}"']
+ it "returns a string with \\#<char> when # is followed by $, @, {" do
+ [ ["\#$", '"\\#$"'],
+ ["\#@", '"\\#@"'],
+ ["\#{", '"\\#{"']
].should be_computed_by(:dump)
end
@@ -354,49 +343,82 @@ describe "String#dump" do
].should be_computed_by(:dump)
end
- it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with upper-case hex digits" do
- [ [0200.chr('utf-8'), '"\u0080"'],
- [0201.chr('utf-8'), '"\u0081"'],
- [0202.chr('utf-8'), '"\u0082"'],
- [0203.chr('utf-8'), '"\u0083"'],
- [0204.chr('utf-8'), '"\u0084"'],
- [0206.chr('utf-8'), '"\u0086"'],
- [0207.chr('utf-8'), '"\u0087"'],
- [0210.chr('utf-8'), '"\u0088"'],
- [0211.chr('utf-8'), '"\u0089"'],
- [0212.chr('utf-8'), '"\u008A"'],
- [0213.chr('utf-8'), '"\u008B"'],
- [0214.chr('utf-8'), '"\u008C"'],
- [0215.chr('utf-8'), '"\u008D"'],
- [0216.chr('utf-8'), '"\u008E"'],
- [0217.chr('utf-8'), '"\u008F"'],
- [0220.chr('utf-8'), '"\u0090"'],
- [0221.chr('utf-8'), '"\u0091"'],
- [0222.chr('utf-8'), '"\u0092"'],
- [0223.chr('utf-8'), '"\u0093"'],
- [0224.chr('utf-8'), '"\u0094"'],
- [0225.chr('utf-8'), '"\u0095"'],
- [0226.chr('utf-8'), '"\u0096"'],
- [0227.chr('utf-8'), '"\u0097"'],
- [0230.chr('utf-8'), '"\u0098"'],
- [0231.chr('utf-8'), '"\u0099"'],
- [0232.chr('utf-8'), '"\u009A"'],
- [0233.chr('utf-8'), '"\u009B"'],
- [0234.chr('utf-8'), '"\u009C"'],
- [0235.chr('utf-8'), '"\u009D"'],
- [0236.chr('utf-8'), '"\u009E"'],
- [0237.chr('utf-8'), '"\u009F"'],
- ].should be_computed_by(:dump)
+ ruby_version_is ''...'2.4' do
+ it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do
+ [ [0200.chr('utf-8'), '"\u{80}"'],
+ [0201.chr('utf-8'), '"\u{81}"'],
+ [0202.chr('utf-8'), '"\u{82}"'],
+ [0203.chr('utf-8'), '"\u{83}"'],
+ [0204.chr('utf-8'), '"\u{84}"'],
+ [0206.chr('utf-8'), '"\u{86}"'],
+ [0207.chr('utf-8'), '"\u{87}"'],
+ [0210.chr('utf-8'), '"\u{88}"'],
+ [0211.chr('utf-8'), '"\u{89}"'],
+ [0212.chr('utf-8'), '"\u{8a}"'],
+ [0213.chr('utf-8'), '"\u{8b}"'],
+ [0214.chr('utf-8'), '"\u{8c}"'],
+ [0215.chr('utf-8'), '"\u{8d}"'],
+ [0216.chr('utf-8'), '"\u{8e}"'],
+ [0217.chr('utf-8'), '"\u{8f}"'],
+ [0220.chr('utf-8'), '"\u{90}"'],
+ [0221.chr('utf-8'), '"\u{91}"'],
+ [0222.chr('utf-8'), '"\u{92}"'],
+ [0223.chr('utf-8'), '"\u{93}"'],
+ [0224.chr('utf-8'), '"\u{94}"'],
+ [0225.chr('utf-8'), '"\u{95}"'],
+ [0226.chr('utf-8'), '"\u{96}"'],
+ [0227.chr('utf-8'), '"\u{97}"'],
+ [0230.chr('utf-8'), '"\u{98}"'],
+ [0231.chr('utf-8'), '"\u{99}"'],
+ [0232.chr('utf-8'), '"\u{9a}"'],
+ [0233.chr('utf-8'), '"\u{9b}"'],
+ [0234.chr('utf-8'), '"\u{9c}"'],
+ [0235.chr('utf-8'), '"\u{9d}"'],
+ [0236.chr('utf-8'), '"\u{9e}"'],
+ [0237.chr('utf-8'), '"\u{9f}"'],
+ ].should be_computed_by(:dump)
+ end
end
- it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do
- "\u{876}".encode('utf-16be').dump.should.end_with?(".force_encoding(\"UTF-16BE\")")
- "\u{876}".encode('utf-16le').dump.should.end_with?(".force_encoding(\"UTF-16LE\")")
+ ruby_version_is '2.4' do
+ it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do
+ [ [0200.chr('utf-8'), '"\u0080"'],
+ [0201.chr('utf-8'), '"\u0081"'],
+ [0202.chr('utf-8'), '"\u0082"'],
+ [0203.chr('utf-8'), '"\u0083"'],
+ [0204.chr('utf-8'), '"\u0084"'],
+ [0206.chr('utf-8'), '"\u0086"'],
+ [0207.chr('utf-8'), '"\u0087"'],
+ [0210.chr('utf-8'), '"\u0088"'],
+ [0211.chr('utf-8'), '"\u0089"'],
+ [0212.chr('utf-8'), '"\u008A"'],
+ [0213.chr('utf-8'), '"\u008B"'],
+ [0214.chr('utf-8'), '"\u008C"'],
+ [0215.chr('utf-8'), '"\u008D"'],
+ [0216.chr('utf-8'), '"\u008E"'],
+ [0217.chr('utf-8'), '"\u008F"'],
+ [0220.chr('utf-8'), '"\u0090"'],
+ [0221.chr('utf-8'), '"\u0091"'],
+ [0222.chr('utf-8'), '"\u0092"'],
+ [0223.chr('utf-8'), '"\u0093"'],
+ [0224.chr('utf-8'), '"\u0094"'],
+ [0225.chr('utf-8'), '"\u0095"'],
+ [0226.chr('utf-8'), '"\u0096"'],
+ [0227.chr('utf-8'), '"\u0097"'],
+ [0230.chr('utf-8'), '"\u0098"'],
+ [0231.chr('utf-8'), '"\u0099"'],
+ [0232.chr('utf-8'), '"\u009A"'],
+ [0233.chr('utf-8'), '"\u009B"'],
+ [0234.chr('utf-8'), '"\u009C"'],
+ [0235.chr('utf-8'), '"\u009D"'],
+ [0236.chr('utf-8'), '"\u009E"'],
+ [0237.chr('utf-8'), '"\u009F"'],
+ ].should be_computed_by(:dump)
+ end
end
- it "keeps origin encoding" do
- "foo".encode("ISO-8859-1").dump.encoding.should == Encoding::ISO_8859_1
- "foo".encode('windows-1251').dump.encoding.should == Encoding::Windows_1251
- 1.chr.dump.encoding.should == Encoding::US_ASCII
+ it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do
+ "\u{876}".encode('utf-16be').dump.should == "\"\\bv\".force_encoding(\"UTF-16BE\")"
+ "\u{876}".encode('utf-16le').dump.should == "\"v\\b\".force_encoding(\"UTF-16LE\")"
end
end
diff --git a/spec/ruby/core/string/dup_spec.rb b/spec/ruby/core/string/dup_spec.rb
index d650788210..81fb1308cc 100644
--- a/spec/ruby/core/string/dup_spec.rb
+++ b/spec/ruby/core/string/dup_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "String#dup" do
before :each do
@@ -21,7 +21,7 @@ describe "String#dup" do
it "does not copy singleton methods" do
def @obj.special() :the_one end
dup = @obj.dup
- -> { dup.special }.should raise_error(NameError)
+ lambda { dup.special }.should raise_error(NameError)
end
it "does not copy modules included in the singleton class" do
@@ -30,7 +30,7 @@ describe "String#dup" do
end
dup = @obj.dup
- -> { dup.repr }.should raise_error(NameError)
+ lambda { dup.repr }.should raise_error(NameError)
end
it "does not copy constants defined in the singleton class" do
@@ -39,7 +39,7 @@ describe "String#dup" do
end
dup = @obj.dup
- -> { class << dup; CLONE; end }.should raise_error(NameError)
+ lambda { class << dup; CLONE; end }.should raise_error(NameError)
end
it "does not modify the original string when changing dupped string" do
diff --git a/spec/ruby/core/string/each_byte_spec.rb b/spec/ruby/core/string/each_byte_spec.rb
index e04dca807f..2282cd6d7a 100644
--- a/spec/ruby/core/string/each_byte_spec.rb
+++ b/spec/ruby/core/string/each_byte_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#each_byte" do
it "passes each byte in self to the given block" do
diff --git a/spec/ruby/core/string/each_char_spec.rb b/spec/ruby/core/string/each_char_spec.rb
index aff98c0a5c..3233c7609d 100644
--- a/spec/ruby/core/string/each_char_spec.rb
+++ b/spec/ruby/core/string/each_char_spec.rb
@@ -1,7 +1,7 @@
-require_relative 'shared/chars'
-require_relative 'shared/each_char_without_block'
+require File.expand_path('../shared/chars', __FILE__)
+require File.expand_path('../shared/each_char_without_block', __FILE__)
describe "String#each_char" do
- it_behaves_like :string_chars, :each_char
- it_behaves_like :string_each_char_without_block, :each_char
+ it_behaves_like(:string_chars, :each_char)
+ it_behaves_like(:string_each_char_without_block, :each_char)
end
diff --git a/spec/ruby/core/string/each_codepoint_spec.rb b/spec/ruby/core/string/each_codepoint_spec.rb
index c11cb1beae..4e910f44b5 100644
--- a/spec/ruby/core/string/each_codepoint_spec.rb
+++ b/spec/ruby/core/string/each_codepoint_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/codepoints'
-require_relative 'shared/each_codepoint_without_block'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/codepoints', __FILE__)
+require File.expand_path('../shared/each_codepoint_without_block', __FILE__)
-describe "String#each_codepoint" do
- it_behaves_like :string_codepoints, :each_codepoint
- it_behaves_like :string_each_codepoint_without_block, :each_codepoint
+with_feature :encoding do
+ describe "String#each_codepoint" do
+ it_behaves_like(:string_codepoints, :each_codepoint)
+ it_behaves_like(:string_each_codepoint_without_block, :each_codepoint)
+ end
end
diff --git a/spec/ruby/core/string/each_grapheme_cluster_spec.rb b/spec/ruby/core/string/each_grapheme_cluster_spec.rb
deleted file mode 100644
index 5367f84887..0000000000
--- a/spec/ruby/core/string/each_grapheme_cluster_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative 'shared/chars'
-require_relative 'shared/grapheme_clusters'
-require_relative 'shared/each_char_without_block'
-
-ruby_version_is "2.5" do
- describe "String#each_grapheme_cluster" do
- it_behaves_like :string_chars, :each_grapheme_cluster
- it_behaves_like :string_grapheme_clusters, :each_grapheme_cluster
- it_behaves_like :string_each_char_without_block, :each_grapheme_cluster
- end
-end
diff --git a/spec/ruby/core/string/each_line_spec.rb b/spec/ruby/core/string/each_line_spec.rb
index 90fc920bf1..865ae264d6 100644
--- a/spec/ruby/core/string/each_line_spec.rb
+++ b/spec/ruby/core/string/each_line_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_line'
-require_relative 'shared/each_line_without_block'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_line', __FILE__)
+require File.expand_path('../shared/each_line_without_block', __FILE__)
describe "String#each_line" do
- it_behaves_like :string_each_line, :each_line
- it_behaves_like :string_each_line_without_block, :each_line
+ it_behaves_like(:string_each_line, :each_line)
+ it_behaves_like(:string_each_line_without_block, :each_line)
end
diff --git a/spec/ruby/core/string/element_reference_spec.rb b/spec/ruby/core/string/element_reference_spec.rb
index f6e1750c93..785bbdaf80 100644
--- a/spec/ruby/core/string/element_reference_spec.rb
+++ b/spec/ruby/core/string/element_reference_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/slice'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/slice.rb', __FILE__)
describe "String#[]" do
it_behaves_like :string_slice, :[]
diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb
index 608efc23b3..fea03607f2 100644
--- a/spec/ruby/core/string/element_set_spec.rb
+++ b/spec/ruby/core/string/element_set_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
# TODO: Add missing String#[]= specs:
# String#[re, idx] = obj
@@ -14,31 +14,29 @@ describe "String#[]= with Fixnum index" do
a.should == "bamelo"
end
- ruby_version_is ''...'2.7' do
- it "taints self if other_str is tainted" do
- a = "hello"
- a[0] = "".taint
- a.tainted?.should == true
+ it "taints self if other_str is tainted" do
+ a = "hello"
+ a[0] = "".taint
+ a.tainted?.should == true
- a = "hello"
- a[0] = "x".taint
- a.tainted?.should == true
- end
+ a = "hello"
+ a[0] = "x".taint
+ a.tainted?.should == true
end
it "raises an IndexError without changing self if idx is outside of self" do
str = "hello"
- -> { str[20] = "bam" }.should raise_error(IndexError)
+ lambda { str[20] = "bam" }.should raise_error(IndexError)
str.should == "hello"
- -> { str[-20] = "bam" }.should raise_error(IndexError)
+ lambda { str[-20] = "bam" }.should raise_error(IndexError)
str.should == "hello"
- -> { ""[-1] = "bam" }.should raise_error(IndexError)
+ lambda { ""[-1] = "bam" }.should raise_error(IndexError)
end
- # Behaviour is verified by matz in
+ # Behaviour verfieid correct by matz in
# http://redmine.ruby-lang.org/issues/show/1750
it "allows assignment to the zero'th element of an empty String" do
str = ""
@@ -48,15 +46,15 @@ describe "String#[]= with Fixnum index" do
it "raises IndexError if the string index doesn't match a position in the string" do
str = "hello"
- -> { str['y'] = "bam" }.should raise_error(IndexError)
+ lambda { str['y'] = "bam" }.should raise_error(IndexError)
str.should == "hello"
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
a = "hello"
a.freeze
- -> { a[0] = "bam" }.should raise_error(frozen_error_class)
+ lambda { a[0] = "bam" }.should raise_error(RuntimeError)
end
it "calls to_int on index" do
@@ -80,71 +78,73 @@ describe "String#[]= with Fixnum index" do
end
it "raises a TypeError if other_str can't be converted to a String" do
- -> { "test"[1] = [] }.should raise_error(TypeError)
- -> { "test"[1] = mock('x') }.should raise_error(TypeError)
- -> { "test"[1] = nil }.should raise_error(TypeError)
+ lambda { "test"[1] = [] }.should raise_error(TypeError)
+ lambda { "test"[1] = mock('x') }.should raise_error(TypeError)
+ lambda { "test"[1] = nil }.should raise_error(TypeError)
end
- it "raises a TypeError if passed a Fixnum replacement" do
- -> { "abc"[1] = 65 }.should raise_error(TypeError)
- end
+ with_feature :encoding do
+ it "raises a TypeError if passed a Fixnum replacement" do
+ lambda { "abc"[1] = 65 }.should raise_error(TypeError)
+ end
- it "raises an IndexError if the index is greater than character size" do
- -> { "ã‚れ"[4] = "a" }.should raise_error(IndexError)
- end
+ it "raises an IndexError if the index is greater than character size" do
+ lambda { "ã‚れ"[4] = "a" }.should raise_error(IndexError)
+ end
- it "calls #to_int to convert the index" do
- index = mock("string element set")
- index.should_receive(:to_int).and_return(1)
+ it "calls #to_int to convert the index" do
+ index = mock("string element set")
+ index.should_receive(:to_int).and_return(1)
- str = "ã‚れ"
- str[index] = "a"
- str.should == "ã‚a"
- end
+ str = "ã‚れ"
+ str[index] = "a"
+ str.should == "ã‚a"
+ end
- it "raises a TypeError if #to_int does not return an Fixnum" do
- index = mock("string element set")
- index.should_receive(:to_int).and_return('1')
+ it "raises a TypeError if #to_int does not return an Fixnum" do
+ index = mock("string element set")
+ index.should_receive(:to_int).and_return('1')
- -> { "abc"[index] = "d" }.should raise_error(TypeError)
- end
+ lambda { "abc"[index] = "d" }.should raise_error(TypeError)
+ end
- it "raises an IndexError if #to_int returns a value out of range" do
- index = mock("string element set")
- index.should_receive(:to_int).and_return(4)
+ it "raises an IndexError if #to_int returns a value out of range" do
+ index = mock("string element set")
+ index.should_receive(:to_int).and_return(4)
- -> { "ab"[index] = "c" }.should raise_error(IndexError)
- end
+ lambda { "ab"[index] = "c" }.should raise_error(IndexError)
+ end
- it "replaces a character with a multibyte character" do
- str = "ã‚りãŒã¨u"
- str[4] = "ã†"
- str.should == "ã‚りãŒã¨ã†"
- end
+ it "replaces a character with a multibyte character" do
+ str = "ã‚りãŒã¨u"
+ str[4] = "ã†"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "replaces a multibyte character with a character" do
- str = "ã‚りãŒã¨ã†"
- str[4] = "u"
- str.should == "ã‚りãŒã¨u"
- end
+ it "replaces a multibyte character with a character" do
+ str = "ã‚りãŒã¨ã†"
+ str[4] = "u"
+ str.should == "ã‚りãŒã¨u"
+ end
- it "replaces a multibyte character with a multibyte character" do
- str = "ã‚りãŒã¨ãŠ"
- str[4] = "ã†"
- str.should == "ã‚りãŒã¨ã†"
- end
+ it "replaces a multibyte character with a multibyte character" do
+ str = "ã‚りãŒã¨ãŠ"
+ str[4] = "ã†"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "encodes the String in an encoding compatible with the replacement" do
- str = " ".force_encoding Encoding::US_ASCII
- rep = [160].pack('C').force_encoding Encoding::BINARY
- str[0] = rep
- str.encoding.should equal(Encoding::BINARY)
- end
+ it "encodes the String in an encoding compatible with the replacement" do
+ str = " ".force_encoding Encoding::US_ASCII
+ rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT
+ str[0] = rep
+ str.encoding.should equal(Encoding::ASCII_8BIT)
+ end
- it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
- str = "ã‚れ"
- rep = "ãŒ".encode Encoding::EUC_JP
- -> { str[0] = rep }.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
+ str = "ã‚れ"
+ rep = "ãŒ".encode Encoding::EUC_JP
+ lambda { str[0] = rep }.should raise_error(Encoding::CompatibilityError)
+ end
end
end
@@ -169,38 +169,40 @@ describe "String#[]= with String index" do
it "raises an IndexError if the search String is not found" do
str = "abcde"
- -> { str["g"] = "h" }.should raise_error(IndexError)
+ lambda { str["g"] = "h" }.should raise_error(IndexError)
end
- it "replaces characters with a multibyte character" do
- str = "ã‚りgaã¨ã†"
- str["ga"] = "ãŒ"
- str.should == "ã‚りãŒã¨ã†"
- end
+ with_feature :encoding do
+ it "replaces characters with a multibyte character" do
+ str = "ã‚りgaã¨ã†"
+ str["ga"] = "ãŒ"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "replaces multibyte characters with characters" do
- str = "ã‚りãŒã¨ã†"
- str["ãŒ"] = "ga"
- str.should == "ã‚りgaã¨ã†"
- end
+ it "replaces multibyte characters with characters" do
+ str = "ã‚りãŒã¨ã†"
+ str["ãŒ"] = "ga"
+ str.should == "ã‚りgaã¨ã†"
+ end
- it "replaces multibyte characters with multibyte characters" do
- str = "ã‚りãŒã¨ã†"
- str["ãŒ"] = "ã‹"
- str.should == "ã‚りã‹ã¨ã†"
- end
+ it "replaces multibyte characters with multibyte characters" do
+ str = "ã‚りãŒã¨ã†"
+ str["ãŒ"] = "ã‹"
+ str.should == "ã‚りã‹ã¨ã†"
+ end
- it "encodes the String in an encoding compatible with the replacement" do
- str = " ".force_encoding Encoding::US_ASCII
- rep = [160].pack('C').force_encoding Encoding::BINARY
- str[" "] = rep
- str.encoding.should equal(Encoding::BINARY)
- end
+ it "encodes the String in an encoding compatible with the replacement" do
+ str = " ".force_encoding Encoding::US_ASCII
+ rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT
+ str[" "] = rep
+ str.encoding.should equal(Encoding::ASCII_8BIT)
+ end
- it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
- str = "ã‚れ"
- rep = "ãŒ".encode Encoding::EUC_JP
- -> { str["れ"] = rep }.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
+ str = "ã‚れ"
+ rep = "ãŒ".encode Encoding::EUC_JP
+ lambda { str["れ"] = rep }.should raise_error(Encoding::CompatibilityError)
+ end
end
end
@@ -213,7 +215,7 @@ describe "String#[]= with a Regexp index" do
it "raises IndexError if the regexp index doesn't match a position in the string" do
str = "hello"
- -> { str[/y/] = "bam" }.should raise_error(IndexError)
+ lambda { str[/y/] = "bam" }.should raise_error(IndexError)
str.should == "hello"
end
@@ -230,7 +232,7 @@ describe "String#[]= with a Regexp index" do
rep = mock("string element set regexp")
rep.should_not_receive(:to_str)
- -> { "abc"[/def/] = rep }.should raise_error(IndexError)
+ lambda { "abc"[/def/] = rep }.should raise_error(IndexError)
end
describe "with 3 arguments" do
@@ -247,7 +249,7 @@ describe "String#[]= with a Regexp index" do
ref = mock("string element set regexp ref")
ref.should_receive(:to_int).and_return(nil)
- -> { "abc"[/a(b)/, ref] = "x" }.should raise_error(TypeError)
+ lambda { "abc"[/a(b)/, ref] = "x" }.should raise_error(TypeError)
end
it "uses the 2nd of 3 arguments as which capture should be replaced" do
@@ -266,54 +268,56 @@ describe "String#[]= with a Regexp index" do
rep = mock("string element set regexp")
rep.should_not_receive(:to_str)
- -> { "abc"[/a(b)/, 2] = rep }.should raise_error(IndexError)
+ lambda { "abc"[/a(b)/, 2] = rep }.should raise_error(IndexError)
end
it "raises IndexError if the specified capture isn't available" do
str = "aaa bbb ccc"
- -> { str[/a (bbb) c/, 2] = "ddd" }.should raise_error(IndexError)
- -> { str[/a (bbb) c/, -2] = "ddd" }.should raise_error(IndexError)
+ lambda { str[/a (bbb) c/, 2] = "ddd" }.should raise_error(IndexError)
+ lambda { str[/a (bbb) c/, -2] = "ddd" }.should raise_error(IndexError)
end
describe "when the optional capture does not match" do
it "raises an IndexError before setting the replacement" do
str1 = "a b c"
str2 = str1.dup
- -> { str2[/a (b) (Z)?/, 2] = "d" }.should raise_error(IndexError)
+ lambda { str2[/a (b) (Z)?/, 2] = "d" }.should raise_error(IndexError)
str2.should == str1
end
end
end
- it "replaces characters with a multibyte character" do
- str = "ã‚りgaã¨ã†"
- str[/ga/] = "ãŒ"
- str.should == "ã‚りãŒã¨ã†"
- end
+ with_feature :encoding do
+ it "replaces characters with a multibyte character" do
+ str = "ã‚りgaã¨ã†"
+ str[/ga/] = "ãŒ"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "replaces multibyte characters with characters" do
- str = "ã‚りãŒã¨ã†"
- str[/ãŒ/] = "ga"
- str.should == "ã‚りgaã¨ã†"
- end
+ it "replaces multibyte characters with characters" do
+ str = "ã‚りãŒã¨ã†"
+ str[/ãŒ/] = "ga"
+ str.should == "ã‚りgaã¨ã†"
+ end
- it "replaces multibyte characters with multibyte characters" do
- str = "ã‚りãŒã¨ã†"
- str[/ãŒ/] = "ã‹"
- str.should == "ã‚りã‹ã¨ã†"
- end
+ it "replaces multibyte characters with multibyte characters" do
+ str = "ã‚りãŒã¨ã†"
+ str[/ãŒ/] = "ã‹"
+ str.should == "ã‚りã‹ã¨ã†"
+ end
- it "encodes the String in an encoding compatible with the replacement" do
- str = " ".force_encoding Encoding::US_ASCII
- rep = [160].pack('C').force_encoding Encoding::BINARY
- str[/ /] = rep
- str.encoding.should equal(Encoding::BINARY)
- end
+ it "encodes the String in an encoding compatible with the replacement" do
+ str = " ".force_encoding Encoding::US_ASCII
+ rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT
+ str[/ /] = rep
+ str.encoding.should equal(Encoding::ASCII_8BIT)
+ end
- it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
- str = "ã‚れ"
- rep = "ãŒ".encode Encoding::EUC_JP
- -> { str[/れ/] = rep }.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
+ str = "ã‚れ"
+ rep = "ãŒ".encode Encoding::EUC_JP
+ lambda { str[/れ/] = rep }.should raise_error(Encoding::CompatibilityError)
+ end
end
end
@@ -363,11 +367,11 @@ describe "String#[]= with a Range index" do
end
it "raises a RangeError if negative Range begin is out of range" do
- -> { "abc"[-4..-2] = "x" }.should raise_error(RangeError)
+ lambda { "abc"[-4..-2] = "x" }.should raise_error(RangeError)
end
it "raises a RangeError if positive Range begin is greater than String size" do
- -> { "abc"[4..2] = "x" }.should raise_error(RangeError)
+ lambda { "abc"[4..2] = "x" }.should raise_error(RangeError)
end
it "uses the Range end as an index rather than a count" do
@@ -388,53 +392,55 @@ describe "String#[]= with a Range index" do
str.should == "abcxd"
end
- it "replaces characters with a multibyte character" do
- str = "ã‚りgaã¨ã†"
- str[2..3] = "ãŒ"
- str.should == "ã‚りãŒã¨ã†"
- end
+ with_feature :encoding do
+ it "replaces characters with a multibyte character" do
+ str = "ã‚りgaã¨ã†"
+ str[2..3] = "ãŒ"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "replaces multibyte characters with characters" do
- str = "ã‚りãŒã¨ã†"
- str[2...3] = "ga"
- str.should == "ã‚りgaã¨ã†"
- end
+ it "replaces multibyte characters with characters" do
+ str = "ã‚りãŒã¨ã†"
+ str[2...3] = "ga"
+ str.should == "ã‚りgaã¨ã†"
+ end
- it "replaces multibyte characters by negative indexes" do
- str = "ã‚りãŒã¨ã†"
- str[-3...-2] = "ga"
- str.should == "ã‚りgaã¨ã†"
- end
+ it "replaces multibyte characters by negative indexes" do
+ str = "ã‚りãŒã¨ã†"
+ str[-3...-2] = "ga"
+ str.should == "ã‚りgaã¨ã†"
+ end
- it "replaces multibyte characters with multibyte characters" do
- str = "ã‚りãŒã¨ã†"
- str[2..2] = "ã‹"
- str.should == "ã‚りã‹ã¨ã†"
- end
+ it "replaces multibyte characters with multibyte characters" do
+ str = "ã‚りãŒã¨ã†"
+ str[2..2] = "ã‹"
+ str.should == "ã‚りã‹ã¨ã†"
+ end
- it "deletes a multibyte character" do
- str = "ã‚りã¨ã†"
- str[2..3] = ""
- str.should == "ã‚り"
- end
+ it "deletes a multibyte character" do
+ str = "ã‚りã¨ã†"
+ str[2..3] = ""
+ str.should == "ã‚り"
+ end
- it "inserts a multibyte character" do
- str = "ã‚りã¨ã†"
- str[2...2] = "ãŒ"
- str.should == "ã‚りãŒã¨ã†"
- end
+ it "inserts a multibyte character" do
+ str = "ã‚りã¨ã†"
+ str[2...2] = "ãŒ"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "encodes the String in an encoding compatible with the replacement" do
- str = " ".force_encoding Encoding::US_ASCII
- rep = [160].pack('C').force_encoding Encoding::BINARY
- str[0..1] = rep
- str.encoding.should equal(Encoding::BINARY)
- end
+ it "encodes the String in an encoding compatible with the replacement" do
+ str = " ".force_encoding Encoding::US_ASCII
+ rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT
+ str[0..1] = rep
+ str.encoding.should equal(Encoding::ASCII_8BIT)
+ end
- it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
- str = "ã‚れ"
- rep = "ãŒ".encode Encoding::EUC_JP
- -> { str[0..1] = rep }.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
+ str = "ã‚れ"
+ rep = "ãŒ".encode Encoding::EUC_JP
+ lambda { str[0..1] = rep }.should raise_error(Encoding::CompatibilityError)
+ end
end
end
@@ -487,16 +493,14 @@ describe "String#[]= with Fixnum index, count" do
a.should == "hellobob"
end
- ruby_version_is ''...'2.7' do
- it "taints self if other_str is tainted" do
- a = "hello"
- a[0, 0] = "".taint
- a.tainted?.should == true
+ it "taints self if other_str is tainted" do
+ a = "hello"
+ a[0, 0] = "".taint
+ a.tainted?.should == true
- a = "hello"
- a[1, 4] = "x".taint
- a.tainted?.should == true
- end
+ a = "hello"
+ a[1, 4] = "x".taint
+ a.tainted?.should == true
end
it "calls #to_int to convert the index and count objects" do
@@ -515,14 +519,14 @@ describe "String#[]= with Fixnum index, count" do
index = mock("string element set index")
index.should_receive(:to_int).and_return("1")
- -> { "abc"[index, 2] = "xyz" }.should raise_error(TypeError)
+ lambda { "abc"[index, 2] = "xyz" }.should raise_error(TypeError)
end
it "raises a TypeError if #to_int for count does not return an Integer" do
count = mock("string element set count")
count.should_receive(:to_int).and_return("1")
- -> { "abc"[1, count] = "xyz" }.should raise_error(TypeError)
+ lambda { "abc"[1, count] = "xyz" }.should raise_error(TypeError)
end
it "calls #to_str to convert the replacement object" do
@@ -538,69 +542,71 @@ describe "String#[]= with Fixnum index, count" do
r = mock("string element set replacement")
r.should_receive(:to_str).and_return(nil)
- -> { "abc"[1, 1] = r }.should raise_error(TypeError)
+ lambda { "abc"[1, 1] = r }.should raise_error(TypeError)
end
it "raises an IndexError if |idx| is greater than the length of the string" do
- -> { "hello"[6, 0] = "bob" }.should raise_error(IndexError)
- -> { "hello"[-6, 0] = "bob" }.should raise_error(IndexError)
+ lambda { "hello"[6, 0] = "bob" }.should raise_error(IndexError)
+ lambda { "hello"[-6, 0] = "bob" }.should raise_error(IndexError)
end
it "raises an IndexError if count < 0" do
- -> { "hello"[0, -1] = "bob" }.should raise_error(IndexError)
- -> { "hello"[1, -1] = "bob" }.should raise_error(IndexError)
+ lambda { "hello"[0, -1] = "bob" }.should raise_error(IndexError)
+ lambda { "hello"[1, -1] = "bob" }.should raise_error(IndexError)
end
it "raises a TypeError if other_str is a type other than String" do
- -> { "hello"[0, 2] = nil }.should raise_error(TypeError)
- -> { "hello"[0, 2] = [] }.should raise_error(TypeError)
- -> { "hello"[0, 2] = 33 }.should raise_error(TypeError)
+ lambda { "hello"[0, 2] = nil }.should raise_error(TypeError)
+ lambda { "hello"[0, 2] = [] }.should raise_error(TypeError)
+ lambda { "hello"[0, 2] = 33 }.should raise_error(TypeError)
end
- it "replaces characters with a multibyte character" do
- str = "ã‚りgaã¨ã†"
- str[2, 2] = "ãŒ"
- str.should == "ã‚りãŒã¨ã†"
- end
+ with_feature :encoding do
+ it "replaces characters with a multibyte character" do
+ str = "ã‚りgaã¨ã†"
+ str[2, 2] = "ãŒ"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "replaces multibyte characters with characters" do
- str = "ã‚りãŒã¨ã†"
- str[2, 1] = "ga"
- str.should == "ã‚りgaã¨ã†"
- end
+ it "replaces multibyte characters with characters" do
+ str = "ã‚りãŒã¨ã†"
+ str[2, 1] = "ga"
+ str.should == "ã‚りgaã¨ã†"
+ end
- it "replaces multibyte characters with multibyte characters" do
- str = "ã‚りãŒã¨ã†"
- str[2, 1] = "ã‹"
- str.should == "ã‚りã‹ã¨ã†"
- end
+ it "replaces multibyte characters with multibyte characters" do
+ str = "ã‚りãŒã¨ã†"
+ str[2, 1] = "ã‹"
+ str.should == "ã‚りã‹ã¨ã†"
+ end
- it "deletes a multibyte character" do
- str = "ã‚りã¨ã†"
- str[2, 2] = ""
- str.should == "ã‚り"
- end
+ it "deletes a multibyte character" do
+ str = "ã‚りã¨ã†"
+ str[2, 2] = ""
+ str.should == "ã‚り"
+ end
- it "inserts a multibyte character" do
- str = "ã‚りã¨ã†"
- str[2, 0] = "ãŒ"
- str.should == "ã‚りãŒã¨ã†"
- end
+ it "inserts a multibyte character" do
+ str = "ã‚りã¨ã†"
+ str[2, 0] = "ãŒ"
+ str.should == "ã‚りãŒã¨ã†"
+ end
- it "raises an IndexError if the character index is out of range of a multibyte String" do
- -> { "ã‚れ"[3, 0] = "り" }.should raise_error(IndexError)
- end
+ it "raises an IndexError if the character index is out of range of a multibyte String" do
+ lambda { "ã‚れ"[3, 0] = "り" }.should raise_error(IndexError)
+ end
- it "encodes the String in an encoding compatible with the replacement" do
- str = " ".force_encoding Encoding::US_ASCII
- rep = [160].pack('C').force_encoding Encoding::BINARY
- str[0, 1] = rep
- str.encoding.should equal(Encoding::BINARY)
- end
+ it "encodes the String in an encoding compatible with the replacement" do
+ str = " ".force_encoding Encoding::US_ASCII
+ rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT
+ str[0, 1] = rep
+ str.encoding.should equal(Encoding::ASCII_8BIT)
+ end
- it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
- str = "ã‚れ"
- rep = "ãŒ".encode Encoding::EUC_JP
- -> { str[0, 1] = rep }.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do
+ str = "ã‚れ"
+ rep = "ãŒ".encode Encoding::EUC_JP
+ lambda { str[0, 1] = rep }.should raise_error(Encoding::CompatibilityError)
+ end
end
end
diff --git a/spec/ruby/core/string/empty_spec.rb b/spec/ruby/core/string/empty_spec.rb
index fb52070723..c13e1145e4 100644
--- a/spec/ruby/core/string/empty_spec.rb
+++ b/spec/ruby/core/string/empty_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#empty?" do
it "returns true if the string has a length of zero" do
diff --git a/spec/ruby/core/string/encode_spec.rb b/spec/ruby/core/string/encode_spec.rb
index 1c0c939358..d051dd58c9 100644
--- a/spec/ruby/core/string/encode_spec.rb
+++ b/spec/ruby/core/string/encode_spec.rb
@@ -1,163 +1,159 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'shared/encode'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/encode', __FILE__)
-describe "String#encode" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
- end
+with_feature :encoding do
+ describe "String#encode" do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
+ end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+ end
- it_behaves_like :string_encode, :encode
+ it_behaves_like :string_encode, :encode
- describe "when passed no options" do
- it "returns a copy when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- str = "ã‚"
- str.encode.should_not equal(str)
- end
+ describe "when passed no options" do
+ it "returns a copy when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ str = "ã‚"
+ str.encode.should_not equal(str)
+ end
- it "returns a copy for a ASCII-only String when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- str = "abc"
- str.encode.should_not equal(str)
- end
+ it "returns a copy for a ASCII-only String when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ str = "abc"
+ str.encode.should_not equal(str)
+ end
- it "encodes an ascii substring of a binary string to UTF-8" do
- x82 = [0x82].pack('C')
- str = "#{x82}foo".force_encoding("binary")[1..-1].encode("utf-8")
- str.should == "foo".force_encoding("utf-8")
- str.encoding.should equal(Encoding::UTF_8)
+ it "encodes an ascii substring of a binary string to UTF-8" do
+ x82 = [0x82].pack('C')
+ str = "#{x82}foo".force_encoding("ascii-8bit")[1..-1].encode("utf-8")
+ str.should == "foo".force_encoding("utf-8")
+ str.encoding.should equal(Encoding::UTF_8)
+ end
end
- end
- describe "when passed to encoding" do
- it "returns a copy when passed the same encoding as the String" do
- str = "ã‚"
- str.encode(Encoding::UTF_8).should_not equal(str)
- end
+ describe "when passed to encoding" do
+ it "returns a copy when passed the same encoding as the String" do
+ str = "ã‚"
+ str.encode(Encoding::UTF_8).should_not equal(str)
+ end
- it "round trips a String" do
- str = "abc def".force_encoding Encoding::US_ASCII
- str.encode("utf-32be").encode("ascii").should == "abc def"
+ it "round trips a String" do
+ str = "abc def".force_encoding Encoding::US_ASCII
+ str.encode("utf-32be").encode("ascii").should == "abc def"
+ end
end
- end
- describe "when passed options" do
- it "returns a copy when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- str = "ã‚"
- str.encode(invalid: :replace).should_not equal(str)
- end
+ describe "when passed options" do
+ it "returns a copy when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ str = "ã‚"
+ str.encode(invalid: :replace).should_not equal(str)
+ end
- it "normalizes newlines" do
- "\r\nfoo".encode(universal_newline: true).should == "\nfoo"
+ it "normalizes newlines" do
+ "\r\nfoo".encode(universal_newline: true).should == "\nfoo"
- "\rfoo".encode(universal_newline: true).should == "\nfoo"
+ "\rfoo".encode(universal_newline: true).should == "\nfoo"
+ end
end
- it "replaces invalid encoding" do
- encoded = "ã¡\xE3\x81\xFF".encode("UTF-16LE", invalid: :replace, replace: "?")
- encoded.should == "\u3061??".encode("UTF-16LE")
- encoded.encode("UTF-8").should == "ã¡??"
- end
- end
+ describe "when passed to, from" do
+ it "returns a copy in the destination encoding when both encodings are the same" do
+ str = "ã‚"
+ str.force_encoding("ascii-8bit")
+ encoded = str.encode("utf-8", "utf-8")
- describe "when passed to, from" do
- it "returns a copy in the destination encoding when both encodings are the same" do
- str = "ã‚"
- str.force_encoding("binary")
- encoded = str.encode("utf-8", "utf-8")
+ encoded.should_not equal(str)
+ encoded.encoding.should == Encoding::UTF_8
+ end
- encoded.should_not equal(str)
- encoded.encoding.should == Encoding::UTF_8
+ it "returns the transcoded string" do
+ str = "\x00\x00\x00\x1F"
+ str.encode(Encoding::UTF_8, Encoding::UTF_16BE).should == "\u0000\u001f"
+ end
end
- it "returns the transcoded string" do
- str = "\x00\x00\x00\x1F"
- str.encode(Encoding::UTF_8, Encoding::UTF_16BE).should == "\u0000\u001f"
+ describe "when passed to, options" do
+ it "returns a copy when the destination encoding is the same as the String encoding" do
+ str = "ã‚"
+ str.encode(Encoding::UTF_8, undef: :replace).should_not equal(str)
+ end
end
- end
- describe "when passed to, options" do
- it "returns a copy when the destination encoding is the same as the String encoding" do
- str = "ã‚"
- str.encode(Encoding::UTF_8, undef: :replace).should_not equal(str)
+ describe "when passed to, from, options" do
+ it "returns a copy when both encodings are the same" do
+ str = "ã‚"
+ str.encode("utf-8", "utf-8", invalid: :replace).should_not equal(str)
+ end
end
end
- describe "when passed to, from, options" do
- it "returns a copy when both encodings are the same" do
- str = "ã‚"
- str.encode("utf-8", "utf-8", invalid: :replace).should_not equal(str)
+ describe "String#encode!" do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
end
- end
-end
-
-describe "String#encode!" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
- end
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
-
- it_behaves_like :string_encode, :encode!
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
+ end
- it "raises a #{frozen_error_class} when called on a frozen String" do
- -> { "foo".freeze.encode!("euc-jp") }.should raise_error(frozen_error_class)
- end
+ it_behaves_like :string_encode, :encode!
- # http://redmine.ruby-lang.org/issues/show/1836
- it "raises a #{frozen_error_class} when called on a frozen String when it's a no-op" do
- -> { "foo".freeze.encode!("utf-8") }.should raise_error(frozen_error_class)
- end
+ it "raises a RuntimeError when called on a frozen String" do
+ lambda { "foo".freeze.encode!("euc-jp") }.should raise_error(RuntimeError)
+ end
- describe "when passed no options" do
- it "returns self when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- str = "ã‚"
- str.encode!.should equal(str)
+ # http://redmine.ruby-lang.org/issues/show/1836
+ it "raises a RuntimeError when called on a frozen String when it's a no-op" do
+ lambda { "foo".freeze.encode!("utf-8") }.should raise_error(RuntimeError)
end
- it "returns self for a ASCII-only String when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- str = "abc"
- str.encode!.should equal(str)
+ describe "when passed no options" do
+ it "returns self when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ str = "ã‚"
+ str.encode!.should equal(str)
+ end
+
+ it "returns self for a ASCII-only String when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ str = "abc"
+ str.encode!.should equal(str)
+ end
end
- end
- describe "when passed options" do
- it "returns self for ASCII-only String when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- str = "abc"
- str.encode!(invalid: :replace).should equal(str)
+ describe "when passed options" do
+ it "returns self for ASCII-only String when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ str = "abc"
+ str.encode!(invalid: :replace).should equal(str)
+ end
end
- end
- describe "when passed to encoding" do
- it "returns self" do
- str = "abc"
- result = str.encode!(Encoding::BINARY)
- result.encoding.should equal(Encoding::BINARY)
- result.should equal(str)
+ describe "when passed to encoding" do
+ it "returns self" do
+ str = "abc"
+ result = str.encode!(Encoding::BINARY)
+ result.encoding.should equal(Encoding::BINARY)
+ result.should equal(str)
+ end
end
- end
- describe "when passed to, from" do
- it "returns self" do
- str = "ã‚ã‚"
- result = str.encode!("euc-jp", "utf-8")
- result.encoding.should equal(Encoding::EUC_JP)
- result.should equal(str)
+ describe "when passed to, from" do
+ it "returns self" do
+ str = "ã‚ã‚"
+ result = str.encode!("euc-jp", "utf-8")
+ result.encoding.should equal(Encoding::EUC_JP)
+ result.should equal(str)
+ end
end
end
end
diff --git a/spec/ruby/core/string/encoding_spec.rb b/spec/ruby/core/string/encoding_spec.rb
index 4d17a39f29..9c655757a8 100644
--- a/spec/ruby/core/string/encoding_spec.rb
+++ b/spec/ruby/core/string/encoding_spec.rb
@@ -1,187 +1,189 @@
# -*- encoding: us-ascii -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/iso-8859-9-encoding'
-
-describe "String#encoding" do
- it "returns an Encoding object" do
- String.new.encoding.should be_an_instance_of(Encoding)
- end
-
- it "is equal to the source encoding by default" do
- s = StringSpecs::ISO88599Encoding.new
- s.cedilla.encoding.should == s.source_encoding
- end
-
- it "returns the given encoding if #force_encoding has been called" do
- "a".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- end
-
- it "returns the given encoding if #encode!has been called" do
- "a".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- end
-end
-
-describe "String#encoding for US-ASCII Strings" do
- it "returns US-ASCII if self is US-ASCII" do
- "a".encoding.should == Encoding::US_ASCII
- end
-
- it "returns US-ASCII if self is US-ASCII only, despite the default internal encoding being different" do
- default_internal = Encoding.default_internal
- Encoding.default_internal = Encoding::UTF_8
- "a".encoding.should == Encoding::US_ASCII
- Encoding.default_internal = default_internal
- end
-
- it "returns US-ASCII if self is US-ASCII only, despite the default external encoding being different" do
- default_external = Encoding.default_external
- Encoding.default_external = Encoding::UTF_8
- "a".encoding.should == Encoding::US_ASCII
- Encoding.default_external = default_external
- end
-
- it "returns US-ASCII if self is US-ASCII only, despite the default internal and external encodings being different" do
- default_internal = Encoding.default_internal
- default_external = Encoding.default_external
- Encoding.default_internal = Encoding::UTF_8
- Encoding.default_external = Encoding::UTF_8
- "a".encoding.should == Encoding::US_ASCII
- Encoding.default_external = default_external
- Encoding.default_internal = default_internal
- end
-
- it "returns US-ASCII if self is US-ASCII only, despite the default encodings being different" do
- default_internal = Encoding.default_internal
- default_external = Encoding.default_external
- Encoding.default_internal = Encoding::UTF_8
- Encoding.default_external = Encoding::UTF_8
- "a".encoding.should == Encoding::US_ASCII
- Encoding.default_external = default_external
- Encoding.default_internal = default_internal
- end
-
-end
-
-describe "String#encoding for Strings with \\u escapes" do
- it "returns UTF-8" do
- "\u{4040}".encoding.should == Encoding::UTF_8
- end
-
- it "returns US-ASCII if self is US-ASCII only" do
- s = "\u{40}"
- s.ascii_only?.should be_true
- s.encoding.should == Encoding::US_ASCII
- end
-
- it "returns UTF-8 if self isn't US-ASCII only" do
- s = "\u{4076}\u{619}"
- s.ascii_only?.should be_false
- s.encoding.should == Encoding::UTF_8
- end
-
- it "is not affected by the default internal encoding" do
- default_internal = Encoding.default_internal
- Encoding.default_internal = Encoding::ISO_8859_15
- "\u{5050}".encoding.should == Encoding::UTF_8
- "\u{50}".encoding.should == Encoding::US_ASCII
- Encoding.default_internal = default_internal
- end
-
- it "is not affected by the default external encoding" do
- default_external = Encoding.default_external
- Encoding.default_external = Encoding::SHIFT_JIS
- "\u{50}".encoding.should == Encoding::US_ASCII
- "\u{5050}".encoding.should == Encoding::UTF_8
- Encoding.default_external = default_external
- end
-
- it "is not affected by both the default internal and external encoding being set at the same time" do
- default_internal = Encoding.default_internal
- default_external = Encoding.default_external
- Encoding.default_internal = Encoding::EUC_JP
- Encoding.default_external = Encoding::SHIFT_JIS
- "\u{50}".encoding.should == Encoding::US_ASCII
- "\u{507}".encoding.should == Encoding::UTF_8
- Encoding.default_external = default_external
- Encoding.default_internal = default_internal
- end
-
- it "returns the given encoding if #force_encoding has been called" do
- "\u{20}".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- "\u{2020}".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- end
-
- it "returns the given encoding if #encode!has been called" do
- "\u{20}".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- "\u{2020}".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- end
-end
-
-describe "String#encoding for Strings with \\x escapes" do
-
- it "returns US-ASCII if self is US-ASCII only" do
- s = "\x61"
- s.ascii_only?.should be_true
- s.encoding.should == Encoding::US_ASCII
- end
-
- it "returns BINARY when an escape creates a byte with the 8th bit set if the source encoding is US-ASCII" do
- __ENCODING__.should == Encoding::US_ASCII
- str = " "
- str.encoding.should == Encoding::US_ASCII
- str += [0xDF].pack('C')
- str.ascii_only?.should be_false
- str.encoding.should == Encoding::BINARY
- end
-
- # TODO: Deal with case when the byte in question isn't valid in the source
- # encoding?
- it "returns the source encoding when an escape creates a byte with the 8th bit set if the source encoding isn't US-ASCII" do
- fixture = StringSpecs::ISO88599Encoding.new
- fixture.source_encoding.should == Encoding::ISO8859_9
- fixture.x_escape.ascii_only?.should be_false
- fixture.x_escape.encoding.should == Encoding::ISO8859_9
- end
-
- it "is not affected by the default internal encoding" do
- default_internal = Encoding.default_internal
- Encoding.default_internal = Encoding::ISO_8859_15
- "\x50".encoding.should == Encoding::US_ASCII
- "\x50".encoding.should == Encoding::US_ASCII
- Encoding.default_internal = default_internal
- end
-
- it "is not affected by the default external encoding" do
- default_external = Encoding.default_external
- Encoding.default_external = Encoding::SHIFT_JIS
- "\x50".encoding.should == Encoding::US_ASCII
- [0xD4].pack('C').encoding.should == Encoding::BINARY
- Encoding.default_external = default_external
- end
-
- it "is not affected by both the default internal and external encoding being set at the same time" do
- default_internal = Encoding.default_internal
- default_external = Encoding.default_external
- Encoding.default_internal = Encoding::EUC_JP
- Encoding.default_external = Encoding::SHIFT_JIS
- x50 = "\x50"
- x50.encoding.should == Encoding::US_ASCII
- [0xD4].pack('C').encoding.should == Encoding::BINARY
- Encoding.default_external = default_external
- Encoding.default_internal = default_internal
- end
-
- it "returns the given encoding if #force_encoding has been called" do
- x50 = "\x50"
- x50.force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- xD4 = [212].pack('C')
- xD4.force_encoding(Encoding::ISO_8859_9).encoding.should == Encoding::ISO_8859_9
- end
-
- it "returns the given encoding if #encode!has been called" do
- x50 = "\x50"
- x50.encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
- x00 = "x\00"
- x00.encode!(Encoding::UTF_8).encoding.should == Encoding::UTF_8
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/iso-8859-9-encoding', __FILE__)
+
+with_feature :encoding do
+ describe "String#encoding" do
+ it "returns an Encoding object" do
+ String.new.encoding.should be_an_instance_of(Encoding)
+ end
+
+ it "is equal to the source encoding by default" do
+ s = StringSpecs::ISO88599Encoding.new
+ s.cedilla.encoding.should == s.source_encoding
+ end
+
+ it "returns the given encoding if #force_encoding has been called" do
+ "a".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ end
+
+ it "returns the given encoding if #encode!has been called" do
+ "a".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ end
+ end
+
+ describe "String#encoding for US-ASCII Strings" do
+ it "returns US-ASCII if self is US-ASCII" do
+ "a".encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns US-ASCII if self is US-ASCII only, despite the default internal encoding being different" do
+ default_internal = Encoding.default_internal
+ Encoding.default_internal = Encoding::UTF_8
+ "a".encoding.should == Encoding::US_ASCII
+ Encoding.default_internal = default_internal
+ end
+
+ it "returns US-ASCII if self is US-ASCII only, despite the default external encoding being different" do
+ default_external = Encoding.default_external
+ Encoding.default_external = Encoding::UTF_8
+ "a".encoding.should == Encoding::US_ASCII
+ Encoding.default_external = default_external
+ end
+
+ it "returns US-ASCII if self is US-ASCII only, despite the default internal and external encodings being different" do
+ default_internal = Encoding.default_internal
+ default_external = Encoding.default_external
+ Encoding.default_internal = Encoding::UTF_8
+ Encoding.default_external = Encoding::UTF_8
+ "a".encoding.should == Encoding::US_ASCII
+ Encoding.default_external = default_external
+ Encoding.default_internal = default_internal
+ end
+
+ it "returns US-ASCII if self is US-ASCII only, despite the default encodings being different" do
+ default_internal = Encoding.default_internal
+ default_external = Encoding.default_external
+ Encoding.default_internal = Encoding::UTF_8
+ Encoding.default_external = Encoding::UTF_8
+ "a".encoding.should == Encoding::US_ASCII
+ Encoding.default_external = default_external
+ Encoding.default_internal = default_internal
+ end
+
+ end
+
+ describe "String#encoding for Strings with \\u escapes" do
+ it "returns UTF-8" do
+ "\u{4040}".encoding.should == Encoding::UTF_8
+ end
+
+ it "returns US-ASCII if self is US-ASCII only" do
+ s = "\u{40}"
+ s.ascii_only?.should be_true
+ s.encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns UTF-8 if self isn't US-ASCII only" do
+ s = "\u{4076}\u{619}"
+ s.ascii_only?.should be_false
+ s.encoding.should == Encoding::UTF_8
+ end
+
+ it "is not affected by the default internal encoding" do
+ default_internal = Encoding.default_internal
+ Encoding.default_internal = Encoding::ISO_8859_15
+ "\u{5050}".encoding.should == Encoding::UTF_8
+ "\u{50}".encoding.should == Encoding::US_ASCII
+ Encoding.default_internal = default_internal
+ end
+
+ it "is not affected by the default external encoding" do
+ default_external = Encoding.default_external
+ Encoding.default_external = Encoding::SHIFT_JIS
+ "\u{50}".encoding.should == Encoding::US_ASCII
+ "\u{5050}".encoding.should == Encoding::UTF_8
+ Encoding.default_external = default_external
+ end
+
+ it "is not affected by both the default internal and external encoding being set at the same time" do
+ default_internal = Encoding.default_internal
+ default_external = Encoding.default_external
+ Encoding.default_internal = Encoding::EUC_JP
+ Encoding.default_external = Encoding::SHIFT_JIS
+ "\u{50}".encoding.should == Encoding::US_ASCII
+ "\u{507}".encoding.should == Encoding::UTF_8
+ Encoding.default_external = default_external
+ Encoding.default_internal = default_internal
+ end
+
+ it "returns the given encoding if #force_encoding has been called" do
+ "\u{20}".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ "\u{2020}".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ end
+
+ it "returns the given encoding if #encode!has been called" do
+ "\u{20}".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ "\u{2020}".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ end
+ end
+
+ describe "String#encoding for Strings with \\x escapes" do
+
+ it "returns US-ASCII if self is US-ASCII only" do
+ s = "\x61"
+ s.ascii_only?.should be_true
+ s.encoding.should == Encoding::US_ASCII
+ end
+
+ it "returns ASCII-8BIT when an escape creates a byte with the 8th bit set if the source encoding is US-ASCII" do
+ __ENCODING__.should == Encoding::US_ASCII
+ str = " "
+ str.encoding.should == Encoding::US_ASCII
+ str += [0xDF].pack('C')
+ str.ascii_only?.should be_false
+ str.encoding.should == Encoding::ASCII_8BIT
+ end
+
+ # TODO: Deal with case when the byte in question isn't valid in the source
+ # encoding?
+ it "returns the source encoding when an escape creates a byte with the 8th bit set if the source encoding isn't US-ASCII" do
+ fixture = StringSpecs::ISO88599Encoding.new
+ fixture.source_encoding.should == Encoding::ISO8859_9
+ fixture.x_escape.ascii_only?.should be_false
+ fixture.x_escape.encoding.should == Encoding::ISO8859_9
+ end
+
+ it "is not affected by the default internal encoding" do
+ default_internal = Encoding.default_internal
+ Encoding.default_internal = Encoding::ISO_8859_15
+ "\x50".encoding.should == Encoding::US_ASCII
+ "\x50".encoding.should == Encoding::US_ASCII
+ Encoding.default_internal = default_internal
+ end
+
+ it "is not affected by the default external encoding" do
+ default_external = Encoding.default_external
+ Encoding.default_external = Encoding::SHIFT_JIS
+ "\x50".encoding.should == Encoding::US_ASCII
+ [0xD4].pack('C').encoding.should == Encoding::ASCII_8BIT
+ Encoding.default_external = default_external
+ end
+
+ it "is not affected by both the default internal and external encoding being set at the same time" do
+ default_internal = Encoding.default_internal
+ default_external = Encoding.default_external
+ Encoding.default_internal = Encoding::EUC_JP
+ Encoding.default_external = Encoding::SHIFT_JIS
+ x50 = "\x50"
+ x50.encoding.should == Encoding::US_ASCII
+ [0xD4].pack('C').encoding.should == Encoding::ASCII_8BIT
+ Encoding.default_external = default_external
+ Encoding.default_internal = default_internal
+ end
+
+ it "returns the given encoding if #force_encoding has been called" do
+ x50 = "\x50"
+ x50.force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ xD4 = [212].pack('C')
+ xD4.force_encoding(Encoding::ISO_8859_9).encoding.should == Encoding::ISO_8859_9
+ end
+
+ it "returns the given encoding if #encode!has been called" do
+ x50 = "\x50"
+ x50.encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
+ x00 = "x\00"
+ x00.encode!(Encoding::UTF_8).encoding.should == Encoding::UTF_8
+ end
end
end
diff --git a/spec/ruby/core/string/end_with_spec.rb b/spec/ruby/core/string/end_with_spec.rb
index 9ced0ca3d2..2c3ff07272 100644
--- a/spec/ruby/core/string/end_with_spec.rb
+++ b/spec/ruby/core/string/end_with_spec.rb
@@ -1,56 +1,50 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#end_with?" do
it "returns true only if ends match" do
s = "hello"
- s.should.end_with?('o')
- s.should.end_with?('llo')
+ s.end_with?('o').should be_true
+ s.end_with?('llo').should be_true
end
it 'returns false if the end does not match' do
s = 'hello'
- s.should_not.end_with?('ll')
+ s.end_with?('ll').should be_false
end
it "returns true if the search string is empty" do
- "hello".should.end_with?("")
- "".should.end_with?("")
+ "hello".end_with?("").should be_true
+ "".end_with?("").should be_true
end
it "returns true only if any ending match" do
- "hello".should.end_with?('x', 'y', 'llo', 'z')
+ "hello".end_with?('x', 'y', 'llo', 'z').should be_true
end
it "converts its argument using :to_str" do
s = "hello"
find = mock('o')
find.should_receive(:to_str).and_return("o")
- s.should.end_with?(find)
+ s.end_with?(find).should be_true
end
it "ignores arguments not convertible to string" do
- "hello".should_not.end_with?()
- -> { "hello".end_with?(1) }.should raise_error(TypeError)
- -> { "hello".end_with?(["o"]) }.should raise_error(TypeError)
- -> { "hello".end_with?(1, nil, "o") }.should raise_error(TypeError)
+ "hello".end_with?().should be_false
+ lambda { "hello".end_with?(1) }.should raise_error(TypeError)
+ lambda { "hello".end_with?(["o"]) }.should raise_error(TypeError)
+ lambda { "hello".end_with?(1, nil, "o") }.should raise_error(TypeError)
end
it "uses only the needed arguments" do
find = mock('h')
find.should_not_receive(:to_str)
- "hello".should.end_with?("o",find)
+ "hello".end_with?("o",find).should be_true
end
it "works for multibyte strings" do
- "céréale".should.end_with?("réale")
+ "céréale".end_with?("réale").should be_true
end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- pat = "ã‚¢".encode Encoding::EUC_JP
- -> do
- "ã‚れ".end_with?(pat)
- end.should raise_error(Encoding::CompatibilityError)
- end
end
diff --git a/spec/ruby/core/string/eql_spec.rb b/spec/ruby/core/string/eql_spec.rb
index 397974d9fb..df094e122f 100644
--- a/spec/ruby/core/string/eql_spec.rb
+++ b/spec/ruby/core/string/eql_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
describe "String#eql?" do
- it_behaves_like :string_eql_value, :eql?
+ it_behaves_like(:string_eql_value, :eql?)
describe "when given a non-String" do
it "returns false" do
diff --git a/spec/ruby/core/string/equal_value_spec.rb b/spec/ruby/core/string/equal_value_spec.rb
index b9c9c372f8..bf252d6d30 100644
--- a/spec/ruby/core/string/equal_value_spec.rb
+++ b/spec/ruby/core/string/equal_value_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "String#==" do
- it_behaves_like :string_eql_value, :==
- it_behaves_like :string_equal_value, :==
+ it_behaves_like(:string_eql_value, :==)
+ it_behaves_like(:string_equal_value, :==)
end
diff --git a/spec/ruby/core/string/fixtures/classes.rb b/spec/ruby/core/string/fixtures/classes.rb
index 1cc7600abb..6af106f9d3 100644
--- a/spec/ruby/core/string/fixtures/classes.rb
+++ b/spec/ruby/core/string/fixtures/classes.rb
@@ -4,7 +4,7 @@ class Object
def unpack_format(count=nil, repeat=nil)
format = "#{instance_variable_get(:@method)}#{count}"
format *= repeat if repeat
- format.dup # because it may then become tainted
+ format
end
end
diff --git a/spec/ruby/core/string/force_encoding_spec.rb b/spec/ruby/core/string/force_encoding_spec.rb
index 56d9b1e9bc..d163c75ac3 100644
--- a/spec/ruby/core/string/force_encoding_spec.rb
+++ b/spec/ruby/core/string/force_encoding_spec.rb
@@ -1,71 +1,53 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "String#force_encoding" do
- it "accepts a String as the name of an Encoding" do
- "abc".force_encoding('shift_jis').encoding.should == Encoding::Shift_JIS
- end
-
- describe "with a special encoding name" do
- before :each do
- @original_encoding = Encoding.default_internal
+with_feature :encoding do
+ describe "String#force_encoding" do
+ it "accepts a String as the name of an Encoding" do
+ "abc".force_encoding('shift_jis').encoding.should == Encoding::Shift_JIS
end
- after :each do
- Encoding.default_internal = @original_encoding
+ it "accepts an Encoding instance" do
+ "abc".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::Shift_JIS
end
- it "accepts valid special encoding names" do
- Encoding.default_internal = "US-ASCII"
- "abc".force_encoding("internal").encoding.should == Encoding::US_ASCII
- end
+ it "calls #to_str to convert an object to an encoding name" do
+ obj = mock("force_encoding")
+ obj.should_receive(:to_str).and_return("utf-8")
- it "defaults to BINARY if special encoding name is not set" do
- Encoding.default_internal = nil
- "abc".force_encoding("internal").encoding.should == Encoding::BINARY
+ "abc".force_encoding(obj).encoding.should == Encoding::UTF_8
end
- end
-
- it "accepts an Encoding instance" do
- "abc".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::Shift_JIS
- end
-
- it "calls #to_str to convert an object to an encoding name" do
- obj = mock("force_encoding")
- obj.should_receive(:to_str).and_return("utf-8")
- "abc".force_encoding(obj).encoding.should == Encoding::UTF_8
- end
+ it "raises a TypeError if #to_str does not return a String" do
+ obj = mock("force_encoding")
+ obj.should_receive(:to_str).and_return(1)
- it "raises a TypeError if #to_str does not return a String" do
- obj = mock("force_encoding")
- obj.should_receive(:to_str).and_return(1)
-
- -> { "abc".force_encoding(obj) }.should raise_error(TypeError)
- end
+ lambda { "abc".force_encoding(obj) }.should raise_error(TypeError)
+ end
- it "raises a TypeError if passed nil" do
- -> { "abc".force_encoding(nil) }.should raise_error(TypeError)
- end
+ it "raises a TypeError if passed nil" do
+ lambda { "abc".force_encoding(nil) }.should raise_error(TypeError)
+ end
- it "returns self" do
- str = "abc"
- str.force_encoding('utf-8').should equal(str)
- end
+ it "returns self" do
+ str = "abc"
+ str.force_encoding('utf-8').should equal(str)
+ end
- it "sets the encoding even if the String contents are invalid in that encoding" do
- str = "\u{9765}"
- str.force_encoding('euc-jp')
- str.encoding.should == Encoding::EUC_JP
- str.valid_encoding?.should be_false
- end
+ it "sets the encoding even if the String contents are invalid in that encoding" do
+ str = "\u{9765}"
+ str.force_encoding('euc-jp')
+ str.encoding.should == Encoding::EUC_JP
+ str.valid_encoding?.should be_false
+ end
- it "does not transcode self" do
- str = "\u{8612}"
- str.dup.force_encoding('utf-16le').should_not == str.encode('utf-16le')
- end
+ it "does not transcode self" do
+ str = "\u{8612}"
+ str.dup.force_encoding('utf-16le').should_not == str.encode('utf-16le')
+ end
- it "raises a #{frozen_error_class} if self is frozen" do
- str = "abcd".freeze
- -> { str.force_encoding(str.encoding) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ str = "abcd".freeze
+ lambda { str.force_encoding(str.encoding) }.should raise_error(RuntimeError)
+ end
end
end
diff --git a/spec/ruby/core/string/freeze_spec.rb b/spec/ruby/core/string/freeze_spec.rb
index 04d1e9513c..bd7c2fbc73 100644
--- a/spec/ruby/core/string/freeze_spec.rb
+++ b/spec/ruby/core/string/freeze_spec.rb
@@ -1,13 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#freeze" do
it "produces the same object whenever called on an instance of a literal in the source" do
- "abc".freeze.should equal "abc".freeze
+ ids = Array.new(2) { "abc".freeze.object_id }
+ ids.first.should == ids.last
end
it "doesn't produce the same object for different instances of literals in the source" do
- "abc".should_not equal "abc"
+ "abc".object_id.should_not == "abc".object_id
end
it "being a special form doesn't change the value of defined?" do
diff --git a/spec/ruby/core/string/getbyte_spec.rb b/spec/ruby/core/string/getbyte_spec.rb
index 27b7d826ea..b46ab1ab64 100644
--- a/spec/ruby/core/string/getbyte_spec.rb
+++ b/spec/ruby/core/string/getbyte_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#getbyte" do
it "returns an Integer if given a valid index" do
@@ -59,11 +59,11 @@ describe "String#getbyte" do
end
it "raises an ArgumentError unless given one argument" do
- -> { "glark".getbyte }.should raise_error(ArgumentError)
- -> { "food".getbyte(0,0) }.should raise_error(ArgumentError)
+ lambda { "glark".getbyte }.should raise_error(ArgumentError)
+ lambda { "food".getbyte(0,0) }.should raise_error(ArgumentError)
end
it "raises a TypeError unless its argument can be coerced into an Integer" do
- -> { "a".getbyte('a') }.should raise_error(TypeError)
+ lambda { "a".getbyte('a') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/string/grapheme_clusters_spec.rb b/spec/ruby/core/string/grapheme_clusters_spec.rb
deleted file mode 100644
index 0cba0e4216..0000000000
--- a/spec/ruby/core/string/grapheme_clusters_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative 'shared/chars'
-require_relative 'shared/grapheme_clusters'
-
-ruby_version_is "2.5" do
- describe "String#grapheme_clusters" do
- it_behaves_like :string_chars, :grapheme_clusters
- it_behaves_like :string_grapheme_clusters, :grapheme_clusters
-
- it "returns an array when no block given" do
- string = "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}"
- string.grapheme_clusters.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"]
-
- end
- end
-end
diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb
index f1d2d5ac06..026b037b6c 100644
--- a/spec/ruby/core/string/gsub_spec.rb
+++ b/spec/ruby/core/string/gsub_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe :string_gsub_named_capture, shared: true do
it "replaces \\k named backreferences with the regexp's corresponding capture" do
@@ -160,26 +160,24 @@ describe "String#gsub with pattern and replacement" do
it_behaves_like :string_gsub_named_capture, :gsub
- ruby_version_is ''...'2.7' do
- it "taints the result if the original string or replacement is tainted" do
- hello = "hello"
- hello_t = "hello"
- a = "a"
- a_t = "a"
- empty = ""
- empty_t = ""
+ it "taints the result if the original string or replacement is tainted" do
+ hello = "hello"
+ hello_t = "hello"
+ a = "a"
+ a_t = "a"
+ empty = ""
+ empty_t = ""
- hello_t.taint; a_t.taint; empty_t.taint
+ hello_t.taint; a_t.taint; empty_t.taint
- hello_t.gsub(/./, a).tainted?.should == true
- hello_t.gsub(/./, empty).tainted?.should == true
+ hello_t.gsub(/./, a).tainted?.should == true
+ hello_t.gsub(/./, empty).tainted?.should == true
- hello.gsub(/./, a_t).tainted?.should == true
- hello.gsub(/./, empty_t).tainted?.should == true
- hello.gsub(//, empty_t).tainted?.should == true
+ hello.gsub(/./, a_t).tainted?.should == true
+ hello.gsub(/./, empty_t).tainted?.should == true
+ hello.gsub(//, empty_t).tainted?.should == true
- hello.gsub(//.taint, "foo").tainted?.should == false
- end
+ hello.gsub(//.taint, "foo").tainted?.should == false
end
it "handles pattern collapse" do
@@ -188,26 +186,24 @@ describe "String#gsub with pattern and replacement" do
str.gsub(reg, ".").should == ".ã“.ã«.ã¡.ã‚."
end
- ruby_version_is ''...'2.7' do
- it "untrusts the result if the original string or replacement is untrusted" do
- hello = "hello"
- hello_t = "hello"
- a = "a"
- a_t = "a"
- empty = ""
- empty_t = ""
+ it "untrusts the result if the original string or replacement is untrusted" do
+ hello = "hello"
+ hello_t = "hello"
+ a = "a"
+ a_t = "a"
+ empty = ""
+ empty_t = ""
- hello_t.untrust; a_t.untrust; empty_t.untrust
+ hello_t.untrust; a_t.untrust; empty_t.untrust
- hello_t.gsub(/./, a).untrusted?.should == true
- hello_t.gsub(/./, empty).untrusted?.should == true
+ hello_t.gsub(/./, a).untrusted?.should == true
+ hello_t.gsub(/./, empty).untrusted?.should == true
- hello.gsub(/./, a_t).untrusted?.should == true
- hello.gsub(/./, empty_t).untrusted?.should == true
- hello.gsub(//, empty_t).untrusted?.should == true
+ hello.gsub(/./, a_t).untrusted?.should == true
+ hello.gsub(/./, empty_t).untrusted?.should == true
+ hello.gsub(//, empty_t).untrusted?.should == true
- hello.gsub(//.untrust, "foo").untrusted?.should == false
- end
+ hello.gsub(//.untrust, "foo").untrusted?.should == false
end
it "tries to convert pattern to a string using to_str" do
@@ -218,9 +214,9 @@ describe "String#gsub with pattern and replacement" do
end
it "raises a TypeError when pattern can't be converted to a string" do
- -> { "hello".gsub([], "x") }.should raise_error(TypeError)
- -> { "hello".gsub(Object.new, "x") }.should raise_error(TypeError)
- -> { "hello".gsub(nil, "x") }.should raise_error(TypeError)
+ lambda { "hello".gsub([], "x") }.should raise_error(TypeError)
+ lambda { "hello".gsub(Object.new, "x") }.should raise_error(TypeError)
+ lambda { "hello".gsub(nil, "x") }.should raise_error(TypeError)
end
it "tries to convert replacement to a string using to_str" do
@@ -231,9 +227,9 @@ describe "String#gsub with pattern and replacement" do
end
it "raises a TypeError when replacement can't be converted to a string" do
- -> { "hello".gsub(/[aeiou]/, []) }.should raise_error(TypeError)
- -> { "hello".gsub(/[aeiou]/, Object.new) }.should raise_error(TypeError)
- -> { "hello".gsub(/[aeiou]/, nil) }.should raise_error(TypeError)
+ lambda { "hello".gsub(/[aeiou]/, []) }.should raise_error(TypeError)
+ lambda { "hello".gsub(/[aeiou]/, Object.new) }.should raise_error(TypeError)
+ lambda { "hello".gsub(/[aeiou]/, nil) }.should raise_error(TypeError)
end
it "returns subclass instances when called on a subclass" do
@@ -302,7 +298,7 @@ describe "String#gsub with pattern and Hash" do
it "uses the hash's value set from default_proc for missing keys" do
hsh = {}
- hsh.default_proc = -> k, v { 'lamb' }
+ hsh.default_proc = lambda { |k,v| 'lamb' }
"food!".gsub(/./, hsh).should == "lamblamblamblamblamb"
end
@@ -326,27 +322,26 @@ describe "String#gsub with pattern and Hash" do
"hello".gsub(/(.+)/, 'hello' => repl ).should == repl
end
- ruby_version_is ''...'2.7' do
- it "untrusts the result if the original string is untrusted" do
- str = "Ghana".untrust
- str.gsub(/[Aa]na/, 'ana' => '').untrusted?.should be_true
- end
+ it "untrusts the result if the original string is untrusted" do
+ str = "Ghana".untrust
+ str.gsub(/[Aa]na/, 'ana' => '').untrusted?.should be_true
+ end
- it "untrusts the result if a hash value is untrusted" do
- str = "Ghana"
- str.gsub(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
- end
+ it "untrusts the result if a hash value is untrusted" do
+ str = "Ghana"
+ str.gsub(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
+ end
- it "taints the result if the original string is tainted" do
- str = "Ghana".taint
- str.gsub(/[Aa]na/, 'ana' => '').tainted?.should be_true
- end
+ it "taints the result if the original string is tainted" do
+ str = "Ghana".taint
+ str.gsub(/[Aa]na/, 'ana' => '').tainted?.should be_true
+ end
- it "taints the result if a hash value is tainted" do
- str = "Ghana"
- str.gsub(/a$/, 'a' => 'di'.taint).tainted?.should be_true
- end
+ it "taints the result if a hash value is tainted" do
+ str = "Ghana"
+ str.gsub(/a$/, 'a' => 'di'.taint).tainted?.should be_true
end
+
end
describe "String#gsub! with pattern and Hash" do
@@ -392,7 +387,7 @@ describe "String#gsub! with pattern and Hash" do
it "uses the hash's value set from default_proc for missing keys" do
hsh = {}
- hsh.default_proc = -> k, v { 'lamb' }
+ hsh.default_proc = lambda { |k,v| 'lamb' }
"food!".gsub!(/./, hsh).should == "lamblamblamblamblamb"
end
@@ -416,27 +411,26 @@ describe "String#gsub! with pattern and Hash" do
"hello".gsub!(/(.+)/, 'hello' => repl ).should == repl
end
- ruby_version_is ''...'2.7' do
- it "keeps untrusted state" do
- str = "Ghana".untrust
- str.gsub!(/[Aa]na/, 'ana' => '').untrusted?.should be_true
- end
+ it "keeps untrusted state" do
+ str = "Ghana".untrust
+ str.gsub!(/[Aa]na/, 'ana' => '').untrusted?.should be_true
+ end
- it "untrusts self if a hash value is untrusted" do
- str = "Ghana"
- str.gsub!(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
- end
+ it "untrusts self if a hash value is untrusted" do
+ str = "Ghana"
+ str.gsub!(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
+ end
- it "keeps tainted state" do
- str = "Ghana".taint
- str.gsub!(/[Aa]na/, 'ana' => '').tainted?.should be_true
- end
+ it "keeps tainted state" do
+ str = "Ghana".taint
+ str.gsub!(/[Aa]na/, 'ana' => '').tainted?.should be_true
+ end
- it "taints self if a hash value is tainted" do
- str = "Ghana"
- str.gsub!(/a$/, 'a' => 'di'.taint).tainted?.should be_true
- end
+ it "taints self if a hash value is tainted" do
+ str = "Ghana"
+ str.gsub!(/a$/, 'a' => 'di'.taint).tainted?.should be_true
end
+
end
describe "String#gsub with pattern and block" do
@@ -510,42 +504,40 @@ describe "String#gsub with pattern and block" do
"hello".gsub(/.+/) { obj }.should == "ok"
end
- ruby_version_is ''...'2.7' do
- it "untrusts the result if the original string or replacement is untrusted" do
- hello = "hello"
- hello_t = "hello"
- a = "a"
- a_t = "a"
- empty = ""
- empty_t = ""
+ it "untrusts the result if the original string or replacement is untrusted" do
+ hello = "hello"
+ hello_t = "hello"
+ a = "a"
+ a_t = "a"
+ empty = ""
+ empty_t = ""
- hello_t.untrust; a_t.untrust; empty_t.untrust
+ hello_t.untrust; a_t.untrust; empty_t.untrust
- hello_t.gsub(/./) { a }.untrusted?.should == true
- hello_t.gsub(/./) { empty }.untrusted?.should == true
+ hello_t.gsub(/./) { a }.untrusted?.should == true
+ hello_t.gsub(/./) { empty }.untrusted?.should == true
- hello.gsub(/./) { a_t }.untrusted?.should == true
- hello.gsub(/./) { empty_t }.untrusted?.should == true
- hello.gsub(//) { empty_t }.untrusted?.should == true
+ hello.gsub(/./) { a_t }.untrusted?.should == true
+ hello.gsub(/./) { empty_t }.untrusted?.should == true
+ hello.gsub(//) { empty_t }.untrusted?.should == true
- hello.gsub(//.untrust) { "foo" }.untrusted?.should == false
- end
+ hello.gsub(//.untrust) { "foo" }.untrusted?.should == false
end
it "uses the compatible encoding if they are compatible" do
s = "hello"
s2 = "#{195.chr}#{192.chr}#{195.chr}"
- s.gsub(/l/) { |bar| 195.chr }.encoding.should == Encoding::BINARY
- s2.gsub("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::BINARY
+ s.gsub(/l/) { |bar| 195.chr }.encoding.should == Encoding::ASCII_8BIT
+ s2.gsub("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::ASCII_8BIT
end
it "raises an Encoding::CompatibilityError if the encodings are not compatible" do
s = "hllëllo"
s2 = "hellö"
- -> { s.gsub(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
- -> { s2.gsub(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
+ lambda { s.gsub(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
+ lambda { s2.gsub(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
end
it "replaces the incompatible part properly even if the encodings are not compatible" do
@@ -557,7 +549,7 @@ describe "String#gsub with pattern and block" do
not_supported_on :opal do
it "raises an ArgumentError if encoding is not valid" do
x92 = [0x92].pack('C').force_encoding('utf-8')
- -> { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError)
+ lambda { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError)
end
end
end
@@ -591,18 +583,16 @@ describe "String#gsub! with pattern and replacement" do
a.should == "*¿** **é*?*"
end
- ruby_version_is ''...'2.7' do
- it "taints self if replacement is tainted" do
- a = "hello"
- a.gsub!(/./.taint, "foo").tainted?.should == false
- a.gsub!(/./, "foo".taint).tainted?.should == true
- end
+ it "taints self if replacement is tainted" do
+ a = "hello"
+ a.gsub!(/./.taint, "foo").tainted?.should == false
+ a.gsub!(/./, "foo".taint).tainted?.should == true
+ end
- it "untrusts self if replacement is untrusted" do
- a = "hello"
- a.gsub!(/./.untrust, "foo").untrusted?.should == false
- a.gsub!(/./, "foo".untrust).untrusted?.should == true
- end
+ it "untrusts self if replacement is untrusted" do
+ a = "hello"
+ a.gsub!(/./.untrust, "foo").untrusted?.should == false
+ a.gsub!(/./, "foo".untrust).untrusted?.should == true
end
it "returns nil if no modifications were made" do
@@ -613,13 +603,13 @@ describe "String#gsub! with pattern and replacement" do
end
# See [ruby-core:23666]
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
s = "hello"
s.freeze
- -> { s.gsub!(/ROAR/, "x") }.should raise_error(frozen_error_class)
- -> { s.gsub!(/e/, "e") }.should raise_error(frozen_error_class)
- -> { s.gsub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class)
+ lambda { s.gsub!(/ROAR/, "x") }.should raise_error(RuntimeError)
+ lambda { s.gsub!(/e/, "e") }.should raise_error(RuntimeError)
+ lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
end
end
@@ -630,18 +620,16 @@ describe "String#gsub! with pattern and block" do
a.should == "h*ll*"
end
- ruby_version_is ''...'2.7' do
- it "taints self if block's result is tainted" do
- a = "hello"
- a.gsub!(/./.taint) { "foo" }.tainted?.should == false
- a.gsub!(/./) { "foo".taint }.tainted?.should == true
- end
+ it "taints self if block's result is tainted" do
+ a = "hello"
+ a.gsub!(/./.taint) { "foo" }.tainted?.should == false
+ a.gsub!(/./) { "foo".taint }.tainted?.should == true
+ end
- it "untrusts self if block's result is untrusted" do
- a = "hello"
- a.gsub!(/./.untrust) { "foo" }.untrusted?.should == false
- a.gsub!(/./) { "foo".untrust }.untrusted?.should == true
- end
+ it "untrusts self if block's result is untrusted" do
+ a = "hello"
+ a.gsub!(/./.untrust) { "foo" }.untrusted?.should == false
+ a.gsub!(/./) { "foo".untrust }.untrusted?.should == true
end
it "returns nil if no modifications were made" do
@@ -652,29 +640,29 @@ describe "String#gsub! with pattern and block" do
end
# See [ruby-core:23663]
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
s = "hello"
s.freeze
- -> { s.gsub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class)
- -> { s.gsub!(/e/) { "e" } }.should raise_error(frozen_error_class)
- -> { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class)
+ lambda { s.gsub!(/ROAR/) { "x" } }.should raise_error(RuntimeError)
+ lambda { s.gsub!(/e/) { "e" } }.should raise_error(RuntimeError)
+ lambda { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(RuntimeError)
end
it "uses the compatible encoding if they are compatible" do
s = "hello"
s2 = "#{195.chr}#{192.chr}#{195.chr}"
- s.gsub!(/l/) { |bar| 195.chr }.encoding.should == Encoding::BINARY
- s2.gsub!("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::BINARY
+ s.gsub!(/l/) { |bar| 195.chr }.encoding.should == Encoding::ASCII_8BIT
+ s2.gsub!("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::ASCII_8BIT
end
it "raises an Encoding::CompatibilityError if the encodings are not compatible" do
s = "hllëllo"
s2 = "hellö"
- -> { s.gsub!(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
- -> { s2.gsub!(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
+ lambda { s.gsub!(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
+ lambda { s2.gsub!(/l/) { |bar| "РуÑÑкий".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError)
end
it "replaces the incompatible part properly even if the encodings are not compatible" do
@@ -686,7 +674,7 @@ describe "String#gsub! with pattern and block" do
not_supported_on :opal do
it "raises an ArgumentError if encoding is not valid" do
x92 = [0x92].pack('C').force_encoding('utf-8')
- -> { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError)
+ lambda { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/string/hash_spec.rb b/spec/ruby/core/string/hash_spec.rb
index 0b26214b55..255168cebd 100644
--- a/spec/ruby/core/string/hash_spec.rb
+++ b/spec/ruby/core/string/hash_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#hash" do
it "returns a hash based on a string's length and content" do
diff --git a/spec/ruby/core/string/hex_spec.rb b/spec/ruby/core/string/hex_spec.rb
index 364e915681..8a9257c310 100644
--- a/spec/ruby/core/string/hex_spec.rb
+++ b/spec/ruby/core/string/hex_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
# TODO: Move actual results to String#to_int() and spec in terms of it
describe "String#hex" do
diff --git a/spec/ruby/core/string/include_spec.rb b/spec/ruby/core/string/include_spec.rb
index e32eb17c29..d7780de602 100644
--- a/spec/ruby/core/string/include_spec.rb
+++ b/spec/ruby/core/string/include_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#include? with String" do
it "returns true if self contains other_str" do
@@ -21,14 +21,14 @@ describe "String#include? with String" do
end
it "raises a TypeError if other can't be converted to string" do
- -> { "hello".include?([]) }.should raise_error(TypeError)
- -> { "hello".include?('h'.ord) }.should raise_error(TypeError)
- -> { "hello".include?(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".include?([]) }.should raise_error(TypeError)
+ lambda { "hello".include?('h'.ord) }.should raise_error(TypeError)
+ lambda { "hello".include?(mock('x')) }.should raise_error(TypeError)
end
it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
pat = "ã‚¢".encode Encoding::EUC_JP
- -> do
+ lambda do
"ã‚れ".include?(pat)
end.should raise_error(Encoding::CompatibilityError)
end
diff --git a/spec/ruby/core/string/index_spec.rb b/spec/ruby/core/string/index_spec.rb
index ca62911db0..7889f69c5d 100644
--- a/spec/ruby/core/string/index_spec.rb
+++ b/spec/ruby/core/string/index_spec.rb
@@ -1,18 +1,18 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#index" do
it "raises a TypeError if passed nil" do
- -> { "abc".index nil }.should raise_error(TypeError)
+ lambda { "abc".index nil }.should raise_error(TypeError)
end
it "raises a TypeError if passed a boolean" do
- -> { "abc".index true }.should raise_error(TypeError)
+ lambda { "abc".index true }.should raise_error(TypeError)
end
it "raises a TypeError if passed a Symbol" do
- -> { "abc".index :a }.should raise_error(TypeError)
+ lambda { "abc".index :a }.should raise_error(TypeError)
end
it "calls #to_str to convert the first argument" do
@@ -28,7 +28,7 @@ describe "String#index" do
end
it "raises a TypeError if passed a Fixnum" do
- -> { "abc".index 97 }.should raise_error(TypeError)
+ lambda { "abc".index 97 }.should raise_error(TypeError)
end
end
@@ -140,23 +140,25 @@ describe "String#index with String" do
"I’ve got a multibyte character.\n".index("\n\n").should == nil
end
- it "returns the character index of a multibyte character" do
- "ã‚りãŒã¨ã†".index("ãŒ").should == 2
- end
+ with_feature :encoding do
+ it "returns the character index of a multibyte character" do
+ "ã‚りãŒã¨ã†".index("ãŒ").should == 2
+ end
- it "returns the character index after offset" do
- "ã‚れã‚れ".index("ã‚", 1).should == 2
- end
+ it "returns the character index after offset" do
+ "ã‚れã‚れ".index("ã‚", 1).should == 2
+ end
- it "returns the character index after a partial first match" do
- "</</h".index("</h").should == 2
- end
+ it "returns the character index after a partial first match" do
+ "</</h".index("</h").should == 2
+ end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- char = "れ".encode Encoding::EUC_JP
- -> do
- "ã‚れ".index char
- end.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
+ char = "れ".encode Encoding::EUC_JP
+ lambda do
+ "ã‚れ".index char
+ end.should raise_error(Encoding::CompatibilityError)
+ end
end
end
@@ -291,22 +293,24 @@ describe "String#index with Regexp" do
"RWOARW".index(/R./, obj).should == 4
end
- it "returns the character index of a multibyte character" do
- "ã‚りãŒã¨ã†".index(/ãŒ/).should == 2
- end
+ with_feature :encoding do
+ it "returns the character index of a multibyte character" do
+ "ã‚りãŒã¨ã†".index(/ãŒ/).should == 2
+ end
- it "returns the character index after offset" do
- "ã‚れã‚れ".index(/ã‚/, 1).should == 2
- end
+ it "returns the character index after offset" do
+ "ã‚れã‚れ".index(/ã‚/, 1).should == 2
+ end
- it "treats the offset as a character index" do
- "ã‚れã‚ã‚れ".index(/ã‚/, 3).should == 3
- end
+ it "treats the offset as a character index" do
+ "ã‚れã‚ã‚れ".index(/ã‚/, 3).should == 3
+ end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- re = Regexp.new "れ".encode(Encoding::EUC_JP)
- -> do
- "ã‚れ".index re
- end.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
+ re = Regexp.new "れ".encode(Encoding::EUC_JP)
+ lambda do
+ "ã‚れ".index re
+ end.should raise_error(Encoding::CompatibilityError)
+ end
end
end
diff --git a/spec/ruby/core/string/initialize_spec.rb b/spec/ruby/core/string/initialize_spec.rb
index 08734cc916..cbb281c8d5 100644
--- a/spec/ruby/core/string/initialize_spec.rb
+++ b/spec/ruby/core/string/initialize_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/replace'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/replace', __FILE__)
describe "String#initialize" do
it "is a private method" do
diff --git a/spec/ruby/core/string/insert_spec.rb b/spec/ruby/core/string/insert_spec.rb
index de7c12423a..c207fcc13b 100644
--- a/spec/ruby/core/string/insert_spec.rb
+++ b/spec/ruby/core/string/insert_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#insert with index, other" do
it "inserts other before the character at the given index" do
@@ -23,8 +23,8 @@ describe "String#insert with index, other" do
end
it "raises an IndexError if the index is beyond string" do
- -> { "abcd".insert(5, 'X') }.should raise_error(IndexError)
- -> { "abcd".insert(-6, 'X') }.should raise_error(IndexError)
+ lambda { "abcd".insert(5, 'X') }.should raise_error(IndexError)
+ lambda { "abcd".insert(-6, 'X') }.should raise_error(IndexError)
end
it "converts index to an integer using to_int" do
@@ -41,44 +41,44 @@ describe "String#insert with index, other" do
"abcd".insert(-3, other).should == "abXYZcd"
end
- ruby_version_is ''...'2.7' do
- it "taints self if string to insert is tainted" do
- str = "abcd"
- str.insert(0, "T".taint).tainted?.should == true
+ it "taints self if string to insert is tainted" do
+ str = "abcd"
+ str.insert(0, "T".taint).tainted?.should == true
- str = "abcd"
- other = mock('T')
- def other.to_str() "T".taint end
- str.insert(0, other).tainted?.should == true
- end
+ str = "abcd"
+ other = mock('T')
+ def other.to_str() "T".taint end
+ str.insert(0, other).tainted?.should == true
end
it "raises a TypeError if other can't be converted to string" do
- -> { "abcd".insert(-6, Object.new)}.should raise_error(TypeError)
- -> { "abcd".insert(-6, []) }.should raise_error(TypeError)
- -> { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError)
+ lambda { "abcd".insert(-6, Object.new)}.should raise_error(TypeError)
+ lambda { "abcd".insert(-6, []) }.should raise_error(TypeError)
+ lambda { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError)
end
- it "raises a #{frozen_error_class} if self is frozen" do
+ it "raises a RuntimeError if self is frozen" do
str = "abcd".freeze
- -> { str.insert(4, '') }.should raise_error(frozen_error_class)
- -> { str.insert(4, 'X') }.should raise_error(frozen_error_class)
+ lambda { str.insert(4, '') }.should raise_error(RuntimeError)
+ lambda { str.insert(4, 'X') }.should raise_error(RuntimeError)
end
- it "inserts a character into a multibyte encoded string" do
- "ã‚りãŒã¨ã†".insert(1, 'ü').should == "ã‚üりãŒã¨ã†"
- end
+ with_feature :encoding do
+ it "inserts a character into a multibyte encoded string" do
+ "ã‚りãŒã¨ã†".insert(1, 'ü').should == "ã‚üりãŒã¨ã†"
+ end
- it "returns a String in the compatible encoding" do
- str = "".force_encoding(Encoding::US_ASCII)
- str.insert(0, "ã‚りãŒã¨ã†")
- str.encoding.should == Encoding::UTF_8
- end
+ it "returns a String in the compatible encoding" do
+ str = "".force_encoding(Encoding::US_ASCII)
+ str.insert(0, "ã‚りãŒã¨ã†")
+ str.encoding.should == Encoding::UTF_8
+ end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- pat = "ã‚¢".encode Encoding::EUC_JP
- -> do
- "ã‚れ".insert 0, pat
- end.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
+ pat = "ã‚¢".encode Encoding::EUC_JP
+ lambda do
+ "ã‚れ".insert 0, pat
+ end.should raise_error(Encoding::CompatibilityError)
+ end
end
end
diff --git a/spec/ruby/core/string/inspect_spec.rb b/spec/ruby/core/string/inspect_spec.rb
index 8ddbae132a..a3e18c0ee3 100644
--- a/spec/ruby/core/string/inspect_spec.rb
+++ b/spec/ruby/core/string/inspect_spec.rb
@@ -1,18 +1,16 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#inspect" do
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "foo".taint.inspect.tainted?.should == true
- "foo\n".taint.inspect.tainted?.should == true
- end
+ it "taints the result if self is tainted" do
+ "foo".taint.inspect.tainted?.should == true
+ "foo\n".taint.inspect.tainted?.should == true
+ end
- it "untrusts the result if self is untrusted" do
- "foo".untrust.inspect.untrusted?.should == true
- "foo\n".untrust.inspect.untrusted?.should == true
- end
+ it "untrusts the result if self is untrusted" do
+ "foo".untrust.inspect.untrusted?.should == true
+ "foo\n".untrust.inspect.untrusted?.should == true
end
it "does not return a subclass instance" do
@@ -491,12 +489,4 @@ describe "String#inspect" do
].should be_computed_by(:inspect)
end
end
-
- describe "when the string's encoding is different than the result's encoding" do
- describe "and the string's encoding is ASCII-compatible but the characters are non-ASCII" do
- it "returns a string with the non-ASCII characters replaced by \\x notation" do
- "\u{3042}".encode("EUC-JP").inspect.should == '"\\x{A4A2}"'
- end
- end
- end
end
diff --git a/spec/ruby/core/string/intern_spec.rb b/spec/ruby/core/string/intern_spec.rb
index cd7dad4359..71f3633920 100644
--- a/spec/ruby/core/string/intern_spec.rb
+++ b/spec/ruby/core/string/intern_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_sym'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/to_sym.rb', __FILE__)
describe "String#intern" do
- it_behaves_like :string_to_sym, :intern
+ it_behaves_like(:string_to_sym, :intern)
end
diff --git a/spec/ruby/core/string/length_spec.rb b/spec/ruby/core/string/length_spec.rb
index 98cee1f03d..5f51f6bc01 100644
--- a/spec/ruby/core/string/length_spec.rb
+++ b/spec/ruby/core/string/length_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "String#length" do
- it_behaves_like :string_length, :length
+ it_behaves_like(:string_length, :length)
end
diff --git a/spec/ruby/core/string/lines_spec.rb b/spec/ruby/core/string/lines_spec.rb
index ad4b119074..e5f24816af 100644
--- a/spec/ruby/core/string/lines_spec.rb
+++ b/spec/ruby/core/string/lines_spec.rb
@@ -1,20 +1,22 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_line'
-require_relative 'shared/each_line_without_block'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_line', __FILE__)
+require File.expand_path('../shared/each_line_without_block', __FILE__)
describe "String#lines" do
- it_behaves_like :string_each_line, :lines
+ it_behaves_like(:string_each_line, :lines)
it "returns an array when no block given" do
- ary = "hello world".lines(' ')
+ ary = "hello world".send(@method, ' ')
ary.should == ["hello ", "world"]
end
- context "when `chomp` keyword argument is passed" do
- it "removes new line characters" do
- "hello \nworld\n".lines(chomp: true).should == ["hello ", "world"]
- "hello \r\nworld\r\n".lines(chomp: true).should == ["hello ", "world"]
+ ruby_version_is '2.4' do
+ context "when `chomp` keyword argument is passed" do
+ it "removes new line characters" do
+ "hello \nworld\n".lines(chomp: true).should == ["hello ", "world"]
+ "hello \r\nworld\r\n".lines(chomp: true).should == ["hello ", "world"]
+ end
end
end
end
diff --git a/spec/ruby/core/string/ljust_spec.rb b/spec/ruby/core/string/ljust_spec.rb
index f377e39775..f66fb0c573 100644
--- a/spec/ruby/core/string/ljust_spec.rb
+++ b/spec/ruby/core/string/ljust_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#ljust with length, padding" do
it "returns a new string of specified length with self left justified and padded with padstr" do
@@ -31,14 +31,12 @@ describe "String#ljust with length, padding" do
"radiology".ljust(8, '-').should == "radiology"
end
- ruby_version_is ''...'2.7' do
- it "taints result when self or padstr is tainted" do
- "x".taint.ljust(4).tainted?.should == true
- "x".taint.ljust(0).tainted?.should == true
- "".taint.ljust(0).tainted?.should == true
- "x".taint.ljust(4, "*").tainted?.should == true
- "x".ljust(4, "*".taint).tainted?.should == true
- end
+ it "taints result when self or padstr is tainted" do
+ "x".taint.ljust(4).tainted?.should == true
+ "x".taint.ljust(0).tainted?.should == true
+ "".taint.ljust(0).tainted?.should == true
+ "x".taint.ljust(4, "*").tainted?.should == true
+ "x".ljust(4, "*".taint).tainted?.should == true
end
it "tries to convert length to an integer using to_int" do
@@ -51,10 +49,10 @@ describe "String#ljust with length, padding" do
end
it "raises a TypeError when length can't be converted to an integer" do
- -> { "hello".ljust("x") }.should raise_error(TypeError)
- -> { "hello".ljust("x", "y") }.should raise_error(TypeError)
- -> { "hello".ljust([]) }.should raise_error(TypeError)
- -> { "hello".ljust(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".ljust("x") }.should raise_error(TypeError)
+ lambda { "hello".ljust("x", "y") }.should raise_error(TypeError)
+ lambda { "hello".ljust([]) }.should raise_error(TypeError)
+ lambda { "hello".ljust(mock('x')) }.should raise_error(TypeError)
end
it "tries to convert padstr to a string using to_str" do
@@ -65,13 +63,13 @@ describe "String#ljust with length, padding" do
end
it "raises a TypeError when padstr can't be converted" do
- -> { "hello".ljust(20, []) }.should raise_error(TypeError)
- -> { "hello".ljust(20, Object.new)}.should raise_error(TypeError)
- -> { "hello".ljust(20, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".ljust(20, []) }.should raise_error(TypeError)
+ lambda { "hello".ljust(20, Object.new)}.should raise_error(TypeError)
+ lambda { "hello".ljust(20, mock('x')) }.should raise_error(TypeError)
end
it "raises an ArgumentError when padstr is empty" do
- -> { "hello".ljust(10, '') }.should raise_error(ArgumentError)
+ lambda { "hello".ljust(10, '') }.should raise_error(ArgumentError)
end
it "returns subclass instances when called on subclasses" do
@@ -83,36 +81,36 @@ describe "String#ljust with length, padding" do
"foo".ljust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do
- "hello".ljust(4, 'X'.taint).tainted?.should be_false
- "hello".ljust(5, 'X'.taint).tainted?.should be_false
- "hello".ljust(6, 'X'.taint).tainted?.should be_true
- end
- end
-
- describe "with width" do
- it "returns a String in the same encoding as the original" do
- str = "abc".force_encoding Encoding::IBM437
- result = str.ljust 5
- result.should == "abc "
- result.encoding.should equal(Encoding::IBM437)
- end
+ it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do
+ "hello".ljust(4, 'X'.taint).tainted?.should be_false
+ "hello".ljust(5, 'X'.taint).tainted?.should be_false
+ "hello".ljust(6, 'X'.taint).tainted?.should be_true
end
- describe "with width, pattern" do
- it "returns a String in the compatible encoding" do
- str = "abc".force_encoding Encoding::IBM437
- result = str.ljust 5, "ã‚"
- result.should == "abcã‚ã‚"
- result.encoding.should equal(Encoding::UTF_8)
+ with_feature :encoding do
+ describe "with width" do
+ it "returns a String in the same encoding as the original" do
+ str = "abc".force_encoding Encoding::IBM437
+ result = str.ljust 5
+ result.should == "abc "
+ result.encoding.should equal(Encoding::IBM437)
+ end
end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- pat = "ã‚¢".encode Encoding::EUC_JP
- -> do
- "ã‚れ".ljust 5, pat
- end.should raise_error(Encoding::CompatibilityError)
+ describe "with width, pattern" do
+ it "returns a String in the compatible encoding" do
+ str = "abc".force_encoding Encoding::IBM437
+ result = str.ljust 5, "ã‚"
+ result.should == "abcã‚ã‚"
+ result.encoding.should equal(Encoding::UTF_8)
+ end
+
+ it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
+ pat = "ã‚¢".encode Encoding::EUC_JP
+ lambda do
+ "ã‚れ".ljust 5, pat
+ end.should raise_error(Encoding::CompatibilityError)
+ end
end
end
end
diff --git a/spec/ruby/core/string/lstrip_spec.rb b/spec/ruby/core/string/lstrip_spec.rb
index b1a4e8541f..7ef94be567 100644
--- a/spec/ruby/core/string/lstrip_spec.rb
+++ b/spec/ruby/core/string/lstrip_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#lstrip" do
it "returns a copy of self with leading whitespace removed" do
@@ -14,12 +14,10 @@ describe "String#lstrip" do
"\x00hello".lstrip.should == "\x00hello"
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self is tainted" do
- "".taint.lstrip.tainted?.should == true
- "ok".taint.lstrip.tainted?.should == true
- " ok".taint.lstrip.tainted?.should == true
- end
+ it "taints the result when self is tainted" do
+ "".taint.lstrip.tainted?.should == true
+ "ok".taint.lstrip.tainted?.should == true
+ " ok".taint.lstrip.tainted?.should == true
end
end
@@ -40,13 +38,13 @@ describe "String#lstrip!" do
a.should == "hello"
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> { " hello ".freeze.lstrip! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda { " hello ".freeze.lstrip! }.should raise_error(RuntimeError)
end
# see [ruby-core:23657]
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
- -> { "hello".freeze.lstrip! }.should raise_error(frozen_error_class)
- -> { "".freeze.lstrip! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
+ lambda { "hello".freeze.lstrip! }.should raise_error(RuntimeError)
+ lambda { "".freeze.lstrip! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/match_spec.rb b/spec/ruby/core/string/match_spec.rb
index 78b94baa44..94e28e7297 100644
--- a/spec/ruby/core/string/match_spec.rb
+++ b/spec/ruby/core/string/match_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe :string_match_escaped_literal, shared: true do
not_supported_on :opal do
@@ -19,8 +19,8 @@ describe "String#=~" do
end
it "raises a TypeError if a obj is a string" do
- -> { "some string" =~ "another string" }.should raise_error(TypeError)
- -> { "a" =~ StringSpecs::MyString.new("b") }.should raise_error(TypeError)
+ lambda { "some string" =~ "another string" }.should raise_error(TypeError)
+ lambda { "a" =~ StringSpecs::MyString.new("b") }.should raise_error(TypeError)
end
it "invokes obj.=~ with self if obj is neither a string nor regexp" do
@@ -43,8 +43,10 @@ describe "String#=~" do
$~.should == nil
end
- it "returns the character index of a found match" do
- ("ã“ã«ã¡ã‚" =~ /ã«/).should == 1
+ with_feature :encoding do
+ it "returns the character index of a found match" do
+ ("ã“ã«ã¡ã‚" =~ /ã«/).should == 1
+ end
end
end
@@ -62,8 +64,10 @@ describe "String#match" do
"01234".match(/(.).(.)/, 1).captures.should == ["1", "3"]
end
- it "uses the start as a character offset" do
- "零一二三四".match(/(.).(.)/, 1).captures.should == ["一", "三"]
+ with_feature :encoding do
+ it "uses the start as a character offset" do
+ "零一二三四".match(/(.).(.)/, 1).captures.should == ["一", "三"]
+ end
end
end
@@ -72,8 +76,10 @@ describe "String#match" do
"01234".match(/(.).(.)/, -4).captures.should == ["1", "3"]
end
- it "uses the start as a character offset" do
- "零一二三四".match(/(.).(.)/, -4).captures.should == ["一", "三"]
+ with_feature :encoding do
+ it "uses the start as a character offset" do
+ "零一二三四".match(/(.).(.)/, -4).captures.should == ["一", "三"]
+ end
end
end
end
@@ -107,9 +113,9 @@ describe "String#match" do
end
it "raises a TypeError if pattern is not a regexp or a string" do
- -> { 'hello'.match(10) }.should raise_error(TypeError)
+ lambda { 'hello'.match(10) }.should raise_error(TypeError)
not_supported_on :opal do
- -> { 'hello'.match(:ell) }.should raise_error(TypeError)
+ lambda { 'hello'.match(:ell) }.should raise_error(TypeError)
end
end
@@ -143,25 +149,27 @@ describe "String#match" do
end
end
-describe "String#match?" do
- before :each do
- # Resetting Regexp.last_match
- /DONTMATCH/.match ''
- end
+ruby_version_is "2.4" do
+ describe "String#match?" do
+ before :each do
+ # Resetting Regexp.last_match
+ /DONTMATCH/.match ''
+ end
- context "when matches the given regex" do
- it "returns true but does not set Regexp.last_match" do
- 'string'.match?(/string/i).should be_true
- Regexp.last_match.should be_nil
+ context "when matches the given regex" do
+ it "returns true but does not set Regexp.last_match" do
+ 'string'.match?(/string/i).should be_true
+ Regexp.last_match.should be_nil
+ end
end
- end
- it "returns false when does not match the given regex" do
- 'string'.match?(/STRING/).should be_false
- end
+ it "returns false when does not match the given regex" do
+ 'string'.match?(/STRING/).should be_false
+ end
- it "takes matching position as the 2nd argument" do
- 'string'.match?(/str/i, 0).should be_true
- 'string'.match?(/str/i, 1).should be_false
+ it "takes matching position as the 2nd argument" do
+ 'string'.match?(/str/i, 0).should be_true
+ 'string'.match?(/str/i, 1).should be_false
+ end
end
end
diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb
index a16112bf44..4f26ac5033 100644
--- a/spec/ruby/core/string/modulo_spec.rb
+++ b/spec/ruby/core/string/modulo_spec.rb
@@ -1,12 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/hash/key_error'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#%" do
- context "when key is missing from passed-in hash" do
- it_behaves_like :key_error, -> obj, key { "%{#{key}}" % obj }, { a: 5 }
- end
-
it "formats multiple expressions" do
("%b %x %d %s" % [10, 10, 10, 10]).should == "1010 a 10 10"
end
@@ -19,23 +14,6 @@ describe "String#%" do
("%d%% %s" % [10, "of chickens!"]).should == "10% of chickens!"
end
- describe "output's encoding" do
- it "is the same as the format string if passed value is encoding-compatible" do
- [Encoding::BINARY, Encoding::US_ASCII, Encoding::UTF_8, Encoding::SHIFT_JIS].each do |encoding|
- ("hello %s!".encode(encoding) % "world").encoding.should == encoding
- end
- end
-
- it "negotiates a compatible encoding if necessary" do
- ("hello %s" % 195.chr).encoding.should == Encoding::BINARY
- ("hello %s".encode("shift_jis") % "wörld").encoding.should == Encoding::UTF_8
- end
-
- it "raises if a compatible encoding can't be found" do
- -> { "hello %s".encode("utf-8") % "world".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError)
- end
- end
-
ruby_version_is ""..."2.5" do
it "formats single % character at the end as literal %" do
("%" % []).should == "%"
@@ -45,8 +23,8 @@ describe "String#%" do
ruby_version_is "2.5" do
it "raises an error if single % appears at the end" do
- -> { ("%" % []) }.should raise_error(ArgumentError)
- -> { ("foo%" % [])}.should raise_error(ArgumentError)
+ lambda { ("%" % []) }.should raise_error(ArgumentError)
+ lambda { ("foo%" % [])}.should raise_error(ArgumentError)
end
end
@@ -63,18 +41,18 @@ describe "String#%" do
end
it "raises an error if single % appears anywhere else" do
- -> { (" % " % []) }.should raise_error(ArgumentError)
- -> { ("foo%quux" % []) }.should raise_error(ArgumentError)
+ lambda { (" % " % []) }.should raise_error(ArgumentError)
+ lambda { ("foo%quux" % []) }.should raise_error(ArgumentError)
end
it "raises an error if NULL or \\n appear anywhere else in the format string" do
begin
old_debug, $DEBUG = $DEBUG, false
- -> { "%.\n3f" % 1.2 }.should raise_error(ArgumentError)
- -> { "%.3\nf" % 1.2 }.should raise_error(ArgumentError)
- -> { "%.\03f" % 1.2 }.should raise_error(ArgumentError)
- -> { "%.3\0f" % 1.2 }.should raise_error(ArgumentError)
+ lambda { "%.\n3f" % 1.2 }.should raise_error(ArgumentError)
+ lambda { "%.3\nf" % 1.2 }.should raise_error(ArgumentError)
+ lambda { "%.\03f" % 1.2 }.should raise_error(ArgumentError)
+ lambda { "%.3\0f" % 1.2 }.should raise_error(ArgumentError)
ensure
$DEBUG = old_debug
end
@@ -99,8 +77,8 @@ describe "String#%" do
s = $stderr
$stderr = IOStub.new
- -> { "" % [1, 2, 3] }.should raise_error(ArgumentError)
- -> { "%s" % [1, 2, 3] }.should raise_error(ArgumentError)
+ lambda { "" % [1, 2, 3] }.should raise_error(ArgumentError)
+ lambda { "%s" % [1, 2, 3] }.should raise_error(ArgumentError)
ensure
$DEBUG = old_debug
$stderr = s
@@ -125,21 +103,21 @@ describe "String#%" do
end
it "raises an ArgumentError when given invalid argument specifiers" do
- -> { "%1" % [] }.should raise_error(ArgumentError)
- -> { "%+" % [] }.should raise_error(ArgumentError)
- -> { "%-" % [] }.should raise_error(ArgumentError)
- -> { "%#" % [] }.should raise_error(ArgumentError)
- -> { "%0" % [] }.should raise_error(ArgumentError)
- -> { "%*" % [] }.should raise_error(ArgumentError)
- -> { "%." % [] }.should raise_error(ArgumentError)
- -> { "%_" % [] }.should raise_error(ArgumentError)
- -> { "%0$s" % "x" }.should raise_error(ArgumentError)
- -> { "%*0$s" % [5, "x"] }.should raise_error(ArgumentError)
- -> { "%*1$.*0$1$s" % [1, 2, 3] }.should raise_error(ArgumentError)
+ lambda { "%1" % [] }.should raise_error(ArgumentError)
+ lambda { "%+" % [] }.should raise_error(ArgumentError)
+ lambda { "%-" % [] }.should raise_error(ArgumentError)
+ lambda { "%#" % [] }.should raise_error(ArgumentError)
+ lambda { "%0" % [] }.should raise_error(ArgumentError)
+ lambda { "%*" % [] }.should raise_error(ArgumentError)
+ lambda { "%." % [] }.should raise_error(ArgumentError)
+ lambda { "%_" % [] }.should raise_error(ArgumentError)
+ lambda { "%0$s" % "x" }.should raise_error(ArgumentError)
+ lambda { "%*0$s" % [5, "x"] }.should raise_error(ArgumentError)
+ lambda { "%*1$.*0$1$s" % [1, 2, 3] }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when multiple positional argument tokens are given for one format specifier" do
- -> { "%1$1$s" % "foo" }.should raise_error(ArgumentError)
+ lambda { "%1$1$s" % "foo" }.should raise_error(ArgumentError)
end
it "respects positional arguments and precision tokens given for one format specifier" do
@@ -155,36 +133,36 @@ describe "String#%" do
end
it "raises an ArgumentError when multiple width star tokens are given for one format specifier" do
- -> { "%**s" % [5, 5, 5] }.should raise_error(ArgumentError)
+ lambda { "%**s" % [5, 5, 5] }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when a width star token is seen after a width token" do
- -> { "%5*s" % [5, 5] }.should raise_error(ArgumentError)
+ lambda { "%5*s" % [5, 5] }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when multiple precision tokens are given" do
- -> { "%.5.5s" % 5 }.should raise_error(ArgumentError)
- -> { "%.5.*s" % [5, 5] }.should raise_error(ArgumentError)
- -> { "%.*.5s" % [5, 5] }.should raise_error(ArgumentError)
+ lambda { "%.5.5s" % 5 }.should raise_error(ArgumentError)
+ lambda { "%.5.*s" % [5, 5] }.should raise_error(ArgumentError)
+ lambda { "%.*.5s" % [5, 5] }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when there are less arguments than format specifiers" do
("foo" % []).should == "foo"
- -> { "%s" % [] }.should raise_error(ArgumentError)
- -> { "%s %s" % [1] }.should raise_error(ArgumentError)
+ lambda { "%s" % [] }.should raise_error(ArgumentError)
+ lambda { "%s %s" % [1] }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when absolute and relative argument numbers are mixed" do
- -> { "%s %1$s" % "foo" }.should raise_error(ArgumentError)
- -> { "%1$s %s" % "foo" }.should raise_error(ArgumentError)
+ lambda { "%s %1$s" % "foo" }.should raise_error(ArgumentError)
+ lambda { "%1$s %s" % "foo" }.should raise_error(ArgumentError)
- -> { "%s %2$s" % ["foo", "bar"] }.should raise_error(ArgumentError)
- -> { "%2$s %s" % ["foo", "bar"] }.should raise_error(ArgumentError)
+ lambda { "%s %2$s" % ["foo", "bar"] }.should raise_error(ArgumentError)
+ lambda { "%2$s %s" % ["foo", "bar"] }.should raise_error(ArgumentError)
- -> { "%*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
- -> { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
- -> { "%*2$.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
- -> { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
+ lambda { "%*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
+ lambda { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
+ lambda { "%*2$.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
+ lambda { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError)
end
it "allows reuse of the one argument multiple via absolute argument numbers" do
@@ -193,13 +171,13 @@ describe "String#%" do
end
it "always interprets an array argument as a list of argument parameters" do
- -> { "%p" % [] }.should raise_error(ArgumentError)
+ lambda { "%p" % [] }.should raise_error(ArgumentError)
("%p" % [1]).should == "1"
("%p %p" % [1, 2]).should == "1 2"
end
it "always interprets an array subclass argument as a list of argument parameters" do
- -> { "%p" % StringSpecs::MyArray[] }.should raise_error(ArgumentError)
+ lambda { "%p" % StringSpecs::MyArray[] }.should raise_error(ArgumentError)
("%p" % StringSpecs::MyArray[1]).should == "1"
("%p %p" % StringSpecs::MyArray[1, 2]).should == "1 2"
end
@@ -270,7 +248,7 @@ describe "String#%" do
x = mock("string modulo to_ary")
x.should_receive(:to_ary).and_return("x")
- -> { "%s" % x }.should raise_error(TypeError)
+ lambda { "%s" % x }.should raise_error(TypeError)
end
it "tries to convert the argument to Array by calling #to_ary" do
@@ -297,26 +275,24 @@ describe "String#%" do
end
end
- ruby_version_is ''...'2.7' do
- it "always taints the result when the format string is tainted" do
- universal = mock('0')
- def universal.to_int() 0 end
- def universal.to_str() "0" end
- def universal.to_f() 0.0 end
-
- [
- "", "foo",
- "%b", "%B", "%c", "%d", "%e", "%E",
- "%f", "%g", "%G", "%i", "%o", "%p",
- "%s", "%u", "%x", "%X"
- ].each do |format|
- subcls_format = StringSpecs::MyString.new(format)
- subcls_format.taint
- format.taint
-
- (format % universal).tainted?.should == true
- (subcls_format % universal).tainted?.should == true
- end
+ it "always taints the result when the format string is tainted" do
+ universal = mock('0')
+ def universal.to_int() 0 end
+ def universal.to_str() "0" end
+ def universal.to_f() 0.0 end
+
+ [
+ "", "foo",
+ "%b", "%B", "%c", "%d", "%e", "%E",
+ "%f", "%g", "%G", "%i", "%o", "%p",
+ "%s", "%u", "%x", "%X"
+ ].each do |format|
+ subcls_format = StringSpecs::MyString.new(format)
+ subcls_format.taint
+ format.taint
+
+ (format % universal).tainted?.should == true
+ (subcls_format % universal).tainted?.should == true
end
end
@@ -379,7 +355,7 @@ describe "String#%" do
("%*c" % [10, 3]).should == " \003"
("%c" % 42).should == "*"
- -> { "%c" % Object }.should raise_error(TypeError)
+ lambda { "%c" % Object }.should raise_error(TypeError)
end
it "supports single character strings as argument for %c" do
@@ -387,7 +363,7 @@ describe "String#%" do
end
it "raises an exception for multiple character strings as argument for %c" do
- -> { "%c" % 'AA' }.should raise_error(ArgumentError)
+ lambda { "%c" % 'AA' }.should raise_error(ArgumentError)
end
it "calls to_str on argument for %c formats" do
@@ -573,18 +549,16 @@ describe "String#%" do
# ("%p" % obj).should == "obj"
end
- ruby_version_is ''...'2.7' do
- it "taints result for %p when argument.inspect is tainted" do
- obj = mock('x')
- def obj.inspect() "x".taint end
+ it "taints result for %p when argument.inspect is tainted" do
+ obj = mock('x')
+ def obj.inspect() "x".taint end
- ("%p" % obj).tainted?.should == true
+ ("%p" % obj).tainted?.should == true
- obj = mock('x'); obj.taint
- def obj.inspect() "x" end
+ obj = mock('x'); obj.taint
+ def obj.inspect() "x" end
- ("%p" % obj).tainted?.should == false
- end
+ ("%p" % obj).tainted?.should == false
end
it "supports string formats using %s" do
@@ -615,17 +589,15 @@ describe "String#%" do
# ("%s" % obj).should == "obj"
end
- ruby_version_is ''...'2.7' do
- it "taints result for %s when argument is tainted" do
- ("%s" % "x".taint).tainted?.should == true
- ("%s" % mock('x').taint).tainted?.should == true
- end
+ it "taints result for %s when argument is tainted" do
+ ("%s" % "x".taint).tainted?.should == true
+ ("%s" % mock('x').taint).tainted?.should == true
end
# MRI crashes on this one.
# See http://groups.google.com/group/ruby-core-google/t/c285c18cd94c216d
it "raises an ArgumentError for huge precisions for %s" do
- block = -> { "%.25555555555555555555555555555555555555s" % "hello world" }
+ block = lambda { "%.25555555555555555555555555555555555555s" % "hello world" }
block.should raise_error(ArgumentError)
end
@@ -718,19 +690,19 @@ describe "String#%" do
(format % "0b1101").should == (format % Kernel.Integer("0b1101"))
(format % "0b1101_0000").should == (format % Kernel.Integer("0b1101_0000"))
(format % "0777").should == (format % Kernel.Integer("0777"))
- -> {
+ lambda {
# see [ruby-core:14139] for more details
(format % "0777").should == (format % Kernel.Integer("0777"))
}.should_not raise_error(ArgumentError)
- -> { format % "0__7_7_7" }.should raise_error(ArgumentError)
+ lambda { format % "0__7_7_7" }.should raise_error(ArgumentError)
- -> { format % "" }.should raise_error(ArgumentError)
- -> { format % "x" }.should raise_error(ArgumentError)
- -> { format % "5x" }.should raise_error(ArgumentError)
- -> { format % "08" }.should raise_error(ArgumentError)
- -> { format % "0b2" }.should raise_error(ArgumentError)
- -> { format % "123__456" }.should raise_error(ArgumentError)
+ lambda { format % "" }.should raise_error(ArgumentError)
+ lambda { format % "x" }.should raise_error(ArgumentError)
+ lambda { format % "5x" }.should raise_error(ArgumentError)
+ lambda { format % "08" }.should raise_error(ArgumentError)
+ lambda { format % "0b2" }.should raise_error(ArgumentError)
+ lambda { format % "123__456" }.should raise_error(ArgumentError)
obj = mock('5')
obj.should_receive(:to_i).and_return(5)
@@ -763,15 +735,15 @@ describe "String#%" do
(format % "0777").should == (format % 777)
- -> { format % "" }.should raise_error(ArgumentError)
- -> { format % "x" }.should raise_error(ArgumentError)
- -> { format % "." }.should raise_error(ArgumentError)
- -> { format % "10." }.should raise_error(ArgumentError)
- -> { format % "5x" }.should raise_error(ArgumentError)
- -> { format % "0b1" }.should raise_error(ArgumentError)
- -> { format % "10e10.5" }.should raise_error(ArgumentError)
- -> { format % "10__10" }.should raise_error(ArgumentError)
- -> { format % "10.10__10" }.should raise_error(ArgumentError)
+ lambda { format % "" }.should raise_error(ArgumentError)
+ lambda { format % "x" }.should raise_error(ArgumentError)
+ lambda { format % "." }.should raise_error(ArgumentError)
+ lambda { format % "10." }.should raise_error(ArgumentError)
+ lambda { format % "5x" }.should raise_error(ArgumentError)
+ lambda { format % "0b1" }.should raise_error(ArgumentError)
+ lambda { format % "10e10.5" }.should raise_error(ArgumentError)
+ lambda { format % "10__10" }.should raise_error(ArgumentError)
+ lambda { format % "10.10__10" }.should raise_error(ArgumentError)
obj = mock('5.0')
obj.should_receive(:to_f).and_return(5.0)
@@ -782,10 +754,8 @@ describe "String#%" do
(format % "0xA").should == (format % 0xA)
end
- ruby_version_is ''...'2.7' do
- it "doesn't taint the result for #{format} when argument is tainted" do
- (format % "5".taint).tainted?.should == false
- end
+ it "doesn't taint the result for #{format} when argument is tainted" do
+ (format % "5".taint).tainted?.should == false
end
end
@@ -794,8 +764,12 @@ describe "String#%" do
("%{foo}bar" % {foo: 'oof'}).should == "oofbar"
end
+ it "raises KeyError if key is missing from passed-in hash" do
+ lambda {"%{foo}" % {}}.should raise_error(KeyError)
+ end
+
it "should raise ArgumentError if no hash given" do
- -> {"%{foo}" % []}.should raise_error(ArgumentError)
+ lambda {"%{foo}" % []}.should raise_error(ArgumentError)
end
end
@@ -805,11 +779,11 @@ describe "String#%" do
end
it "raises KeyError if key is missing from passed-in hash" do
- -> {"%<foo>d" % {}}.should raise_error(KeyError)
+ lambda {"%<foo>d" % {}}.should raise_error(KeyError)
end
it "should raise ArgumentError if no hash given" do
- -> {"%<foo>" % []}.should raise_error(ArgumentError)
+ lambda {"%<foo>" % []}.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/string/multiply_spec.rb b/spec/ruby/core/string/multiply_spec.rb
index c15f670c46..d932ebeb8e 100644
--- a/spec/ruby/core/string/multiply_spec.rb
+++ b/spec/ruby/core/string/multiply_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/string/times'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../../../shared/string/times', __FILE__)
describe "String#*" do
- it_behaves_like :string_times, :*, -> str, times { str * times }
+ it_behaves_like :string_times, :*, ->(str, times) { str * times }
end
diff --git a/spec/ruby/core/string/new_spec.rb b/spec/ruby/core/string/new_spec.rb
index ca678f5323..b429ac48d2 100644
--- a/spec/ruby/core/string/new_spec.rb
+++ b/spec/ruby/core/string/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "String.new" do
it "returns an instance of String" do
@@ -7,15 +7,19 @@ describe "String.new" do
str.should be_an_instance_of(String)
end
- it "accepts an encoding argument" do
- xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding 'utf-8'
- str = String.new(xA4xA2, encoding: 'euc-jp')
- str.encoding.should == Encoding::EUC_JP
+ ruby_version_is "2.3" do
+ it "accepts an encoding argument" do
+ xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding 'utf-8'
+ str = String.new(xA4xA2, encoding: 'euc-jp')
+ str.encoding.should == Encoding::EUC_JP
+ end
end
- it "accepts a capacity argument" do
- String.new("", capacity: 100_000).should == ""
- String.new("abc", capacity: 100_000).should == "abc"
+ ruby_version_is "2.4" do
+ it "accepts a capacity argument" do
+ String.new("", capacity: 100_000).should == ""
+ String.new("abc", capacity: 100_000).should == "abc"
+ end
end
it "returns a fully-formed String" do
@@ -51,8 +55,8 @@ describe "String.new" do
end
it "raises TypeError on inconvertible object" do
- -> { String.new 5 }.should raise_error(TypeError)
- -> { String.new nil }.should raise_error(TypeError)
+ lambda { String.new 5 }.should raise_error(TypeError)
+ lambda { String.new nil }.should raise_error(TypeError)
end
it "returns a binary String" do
diff --git a/spec/ruby/core/string/next_spec.rb b/spec/ruby/core/string/next_spec.rb
index fcd3e5ef90..6b4a98d993 100644
--- a/spec/ruby/core/string/next_spec.rb
+++ b/spec/ruby/core/string/next_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/succ'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/succ.rb', __FILE__)
describe "String#next" do
- it_behaves_like :string_succ, :next
+ it_behaves_like(:string_succ, :next)
end
describe "String#next!" do
- it_behaves_like :string_succ_bang, :"next!"
+ it_behaves_like(:string_succ_bang, :"next!")
end
diff --git a/spec/ruby/core/string/oct_spec.rb b/spec/ruby/core/string/oct_spec.rb
index 7637692217..7cdbabc436 100644
--- a/spec/ruby/core/string/oct_spec.rb
+++ b/spec/ruby/core/string/oct_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
# Note: We can't completely spec this in terms of to_int() because hex()
# allows the base to be changed by a base specifier in the string.
diff --git a/spec/ruby/core/string/ord_spec.rb b/spec/ruby/core/string/ord_spec.rb
index 0f5a3f6a37..64466fde58 100644
--- a/spec/ruby/core/string/ord_spec.rb
+++ b/spec/ruby/core/string/ord_spec.rb
@@ -1,28 +1,30 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "String#ord" do
- it "returns a Fixnum" do
- 'a'.ord.should be_an_instance_of(Fixnum)
- end
+with_feature :encoding do
+ describe "String#ord" do
+ it "returns a Fixnum" do
+ 'a'.ord.should be_an_instance_of(Fixnum)
+ end
- it "returns the codepoint of the first character in the String" do
- 'a'.ord.should == 97
- end
+ it "returns the codepoint of the first character in the String" do
+ 'a'.ord.should == 97
+ end
- it "ignores subsequent characters" do
- "\u{287}a".ord.should == "\u{287}".ord
- end
+ it "ignores subsequent characters" do
+ "\u{287}a".ord.should == "\u{287}".ord
+ end
- it "understands multibyte characters" do
- "\u{9879}".ord.should == 39033
- end
+ it "understands multibyte characters" do
+ "\u{9879}".ord.should == 39033
+ end
- it "is equivalent to #codepoints.first" do
- "\u{981}\u{982}".ord.should == "\u{981}\u{982}".codepoints.first
- end
+ it "is equivalent to #codepoints.first" do
+ "\u{981}\u{982}".ord.should == "\u{981}\u{982}".codepoints.first
+ end
- it "raises an ArgumentError if called on an empty String" do
- -> { ''.ord }.should raise_error(ArgumentError)
+ it "raises an ArgumentError if called on an empty String" do
+ lambda { ''.ord }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/string/partition_spec.rb b/spec/ruby/core/string/partition_spec.rb
index 996368d6a4..04f49db1b1 100644
--- a/spec/ruby/core/string/partition_spec.rb
+++ b/spec/ruby/core/string/partition_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#partition with String" do
it "returns an array of substrings based on splitting on the given string" do
@@ -28,8 +28,8 @@ describe "String#partition with String" do
end
it "raises an error if not convertible to string" do
- ->{ "hello".partition(5) }.should raise_error(TypeError)
- ->{ "hello".partition(nil) }.should raise_error(TypeError)
+ lambda{ "hello".partition(5) }.should raise_error(TypeError)
+ lambda{ "hello".partition(nil) }.should raise_error(TypeError)
end
it "takes precedence over a given block" do
diff --git a/spec/ruby/core/string/percent_spec.rb b/spec/ruby/core/string/percent_spec.rb
index e3460522b1..5eeb98c217 100644
--- a/spec/ruby/core/string/percent_spec.rb
+++ b/spec/ruby/core/string/percent_spec.rb
@@ -1,13 +1,14 @@
-require_relative '../../spec_helper'
-require_relative '../kernel/shared/sprintf'
-require_relative '../kernel/shared/sprintf_encoding'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../kernel/shared/sprintf', __FILE__)
+require File.expand_path('../../kernel/shared/sprintf_encoding', __FILE__)
describe "String#%" do
- it_behaves_like :kernel_sprintf, -> format, *args {
+ it_behaves_like :kernel_sprintf, -> (format, *args) {
format % args
}
- it_behaves_like :kernel_sprintf_encoding, -> format, *args {
+ it_behaves_like :kernel_sprintf_encoding, -> (format, *args) {
format % args
}
end
+
diff --git a/spec/ruby/core/string/plus_spec.rb b/spec/ruby/core/string/plus_spec.rb
index 9f0db6427c..addc8873eb 100644
--- a/spec/ruby/core/string/plus_spec.rb
+++ b/spec/ruby/core/string/plus_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/concat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/concat', __FILE__)
describe "String#+" do
it "returns a new string containing the given string concatenated to self" do
@@ -18,8 +18,8 @@ describe "String#+" do
end
it "raises a TypeError when given any object that fails #to_str" do
- -> { "" + Object.new }.should raise_error(TypeError)
- -> { "" + 65 }.should raise_error(TypeError)
+ lambda { "" + Object.new }.should raise_error(TypeError)
+ lambda { "" + 65 }.should raise_error(TypeError)
end
it "doesn't return subclass instances" do
@@ -32,15 +32,13 @@ describe "String#+" do
("hello" + StringSpecs::MyString.new("")).should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self or other is tainted" do
- strs = ["", "OK", StringSpecs::MyString.new(""), StringSpecs::MyString.new("OK")]
- strs += strs.map { |s| s.dup.taint }
+ it "taints the result when self or other is tainted" do
+ strs = ["", "OK", StringSpecs::MyString.new(""), StringSpecs::MyString.new("OK")]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- strs.each do |other|
- (str + other).tainted?.should == (str.tainted? | other.tainted?)
- end
+ strs.each do |str|
+ strs.each do |other|
+ (str + other).tainted?.should == (str.tainted? | other.tainted?)
end
end
end
diff --git a/spec/ruby/core/string/prepend_spec.rb b/spec/ruby/core/string/prepend_spec.rb
index c20c5a9e59..17e97fd844 100644
--- a/spec/ruby/core/string/prepend_spec.rb
+++ b/spec/ruby/core/string/prepend_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#prepend" do
it "prepends the given argument to self and returns self" do
@@ -16,16 +16,16 @@ describe "String#prepend" do
end
it "raises a TypeError if the given argument can't be converted to a String" do
- -> { "hello ".prepend [] }.should raise_error(TypeError)
- -> { 'hello '.prepend mock('x') }.should raise_error(TypeError)
+ lambda { "hello ".prepend [] }.should raise_error(TypeError)
+ lambda { 'hello '.prepend mock('x') }.should raise_error(TypeError)
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
a = "hello"
a.freeze
- -> { a.prepend "" }.should raise_error(frozen_error_class)
- -> { a.prepend "test" }.should raise_error(frozen_error_class)
+ lambda { a.prepend "" }.should raise_error(RuntimeError)
+ lambda { a.prepend "test" }.should raise_error(RuntimeError)
end
it "works when given a subclass instance" do
@@ -34,31 +34,31 @@ describe "String#prepend" do
a.should == "hello world"
end
- ruby_version_is ''...'2.7' do
- it "taints self if other is tainted" do
- x = "x"
- x.prepend("".taint).tainted?.should be_true
+ it "taints self if other is tainted" do
+ x = "x"
+ x.prepend("".taint).tainted?.should be_true
- x = "x"
- x.prepend("y".taint).tainted?.should be_true
- end
+ x = "x"
+ x.prepend("y".taint).tainted?.should be_true
end
- it "takes multiple arguments" do
- str = " world"
- str.prepend "he", "", "llo"
- str.should == "hello world"
- end
+ ruby_version_is "2.4" do
+ it "takes multiple arguments" do
+ str = " world"
+ str.prepend "he", "", "llo"
+ str.should == "hello world"
+ end
- it "prepends the initial value when given arguments contain 2 self" do
- str = "hello"
- str.prepend str, str
- str.should == "hellohellohello"
- end
+ it "prepends the initial value when given arguments contain 2 self" do
+ str = "hello"
+ str.prepend str, str
+ str.should == "hellohellohello"
+ end
- it "returns self when given no arguments" do
- str = "hello"
- str.prepend.should equal(str)
- str.should == "hello"
+ it "returns self when given no arguments" do
+ str = "hello"
+ str.prepend.should equal(str)
+ str.should == "hello"
+ end
end
end
diff --git a/spec/ruby/core/string/replace_spec.rb b/spec/ruby/core/string/replace_spec.rb
index ef9bab4f3c..0f59a9a1ab 100644
--- a/spec/ruby/core/string/replace_spec.rb
+++ b/spec/ruby/core/string/replace_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/replace'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/replace', __FILE__)
describe "String#replace" do
it_behaves_like :string_replace, :replace
diff --git a/spec/ruby/core/string/reverse_spec.rb b/spec/ruby/core/string/reverse_spec.rb
index eef46063a5..c37e815ba3 100644
--- a/spec/ruby/core/string/reverse_spec.rb
+++ b/spec/ruby/core/string/reverse_spec.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#reverse" do
it "returns a new string with the characters of self in reverse order" do
@@ -10,15 +10,15 @@ describe "String#reverse" do
"".reverse.should == ""
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- "".taint.reverse.tainted?.should == true
- "m".taint.reverse.tainted?.should == true
- end
+ it "taints the result if self is tainted" do
+ "".taint.reverse.tainted?.should == true
+ "m".taint.reverse.tainted?.should == true
end
- it "reverses a string with multi byte characters" do
- "微軟正黑體".reverse.should == "體黑正軟微"
+ with_feature :encoding do
+ it "reverses a string with multi byte characters" do
+ "微軟正黑體".reverse.should == "體黑正軟微"
+ end
end
end
@@ -32,19 +32,21 @@ describe "String#reverse!" do
"".reverse!.should == ""
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> { "anna".freeze.reverse! }.should raise_error(frozen_error_class)
- -> { "hello".freeze.reverse! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda { "anna".freeze.reverse! }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.reverse! }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
- -> { "".freeze.reverse! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
+ lambda { "".freeze.reverse! }.should raise_error(RuntimeError)
end
- it "reverses a string with multi byte characters" do
- str = "微軟正黑體"
- str.reverse!
- str.should == "體黑正軟微"
+ with_feature :encoding do
+ it "reverses a string with multi byte characters" do
+ str = "微軟正黑體"
+ str.reverse!
+ str.should == "體黑正軟微"
+ end
end
end
diff --git a/spec/ruby/core/string/rindex_spec.rb b/spec/ruby/core/string/rindex_spec.rb
index e021486bc2..7085914189 100644
--- a/spec/ruby/core/string/rindex_spec.rb
+++ b/spec/ruby/core/string/rindex_spec.rb
@@ -1,20 +1,20 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'fixtures/utf-8-encoding'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../fixtures/utf-8-encoding.rb', __FILE__)
describe "String#rindex with object" do
it "raises a TypeError if obj isn't a String, Fixnum or Regexp" do
not_supported_on :opal do
- -> { "hello".rindex(:sym) }.should raise_error(TypeError)
+ lambda { "hello".rindex(:sym) }.should raise_error(TypeError)
end
- -> { "hello".rindex(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".rindex(mock('x')) }.should raise_error(TypeError)
end
it "doesn't try to convert obj to an integer via to_int" do
obj = mock('x')
obj.should_not_receive(:to_int)
- -> { "hello".rindex(obj) }.should raise_error(TypeError)
+ lambda { "hello".rindex(obj) }.should raise_error(TypeError)
end
it "tries to convert obj to a string via to_str" do
@@ -190,7 +190,7 @@ describe "String#rindex with String" do
end
it "raises a TypeError when given offset is nil" do
- -> { "str".rindex("st", nil) }.should raise_error(TypeError)
+ lambda { "str".rindex("st", nil) }.should raise_error(TypeError)
end
end
@@ -344,23 +344,25 @@ describe "String#rindex with Regexp" do
end
it "raises a TypeError when given offset is nil" do
- -> { "str".rindex(/../, nil) }.should raise_error(TypeError)
+ lambda { "str".rindex(/../, nil) }.should raise_error(TypeError)
end
- it "returns the reverse character index of a multibyte character" do
- "ã‚りãŒã‚ŠãŒã¨ã†".rindex("ãŒ").should == 4
- "ã‚りãŒã‚ŠãŒã¨ã†".rindex(/ãŒ/).should == 4
- end
+ with_feature :encoding do
+ it "returns the reverse character index of a multibyte character" do
+ "ã‚りãŒã‚ŠãŒã¨ã†".rindex("ãŒ").should == 4
+ "ã‚りãŒã‚ŠãŒã¨ã†".rindex(/ãŒ/).should == 4
+ end
- it "returns the character index before the finish" do
- "ã‚りãŒã‚ŠãŒã¨ã†".rindex("ãŒ", 3).should == 2
- "ã‚りãŒã‚ŠãŒã¨ã†".rindex(/ãŒ/, 3).should == 2
- end
+ it "returns the character index before the finish" do
+ "ã‚りãŒã‚ŠãŒã¨ã†".rindex("ãŒ", 3).should == 2
+ "ã‚りãŒã‚ŠãŒã¨ã†".rindex(/ãŒ/, 3).should == 2
+ end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- re = Regexp.new "れ".encode(Encoding::EUC_JP)
- -> do
- "ã‚れ".rindex re
- end.should raise_error(Encoding::CompatibilityError)
+ it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
+ re = Regexp.new "れ".encode(Encoding::EUC_JP)
+ lambda do
+ "ã‚れ".rindex re
+ end.should raise_error(Encoding::CompatibilityError)
+ end
end
end
diff --git a/spec/ruby/core/string/rjust_spec.rb b/spec/ruby/core/string/rjust_spec.rb
index 9285ecb6a7..85cb1fe213 100644
--- a/spec/ruby/core/string/rjust_spec.rb
+++ b/spec/ruby/core/string/rjust_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#rjust with length, padding" do
it "returns a new string of specified length with self right justified and padded with padstr" do
@@ -31,14 +31,12 @@ describe "String#rjust with length, padding" do
"radiology".rjust(8, '-').should == "radiology"
end
- ruby_version_is ''...'2.7' do
- it "taints result when self or padstr is tainted" do
- "x".taint.rjust(4).tainted?.should == true
- "x".taint.rjust(0).tainted?.should == true
- "".taint.rjust(0).tainted?.should == true
- "x".taint.rjust(4, "*").tainted?.should == true
- "x".rjust(4, "*".taint).tainted?.should == true
- end
+ it "taints result when self or padstr is tainted" do
+ "x".taint.rjust(4).tainted?.should == true
+ "x".taint.rjust(0).tainted?.should == true
+ "".taint.rjust(0).tainted?.should == true
+ "x".taint.rjust(4, "*").tainted?.should == true
+ "x".rjust(4, "*".taint).tainted?.should == true
end
it "tries to convert length to an integer using to_int" do
@@ -51,10 +49,10 @@ describe "String#rjust with length, padding" do
end
it "raises a TypeError when length can't be converted to an integer" do
- -> { "hello".rjust("x") }.should raise_error(TypeError)
- -> { "hello".rjust("x", "y") }.should raise_error(TypeError)
- -> { "hello".rjust([]) }.should raise_error(TypeError)
- -> { "hello".rjust(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".rjust("x") }.should raise_error(TypeError)
+ lambda { "hello".rjust("x", "y") }.should raise_error(TypeError)
+ lambda { "hello".rjust([]) }.should raise_error(TypeError)
+ lambda { "hello".rjust(mock('x')) }.should raise_error(TypeError)
end
it "tries to convert padstr to a string using to_str" do
@@ -65,13 +63,13 @@ describe "String#rjust with length, padding" do
end
it "raises a TypeError when padstr can't be converted" do
- -> { "hello".rjust(20, []) }.should raise_error(TypeError)
- -> { "hello".rjust(20, Object.new)}.should raise_error(TypeError)
- -> { "hello".rjust(20, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".rjust(20, []) }.should raise_error(TypeError)
+ lambda { "hello".rjust(20, Object.new)}.should raise_error(TypeError)
+ lambda { "hello".rjust(20, mock('x')) }.should raise_error(TypeError)
end
it "raises an ArgumentError when padstr is empty" do
- -> { "hello".rjust(10, '') }.should raise_error(ArgumentError)
+ lambda { "hello".rjust(10, '') }.should raise_error(ArgumentError)
end
it "returns subclass instances when called on subclasses" do
@@ -83,36 +81,36 @@ describe "String#rjust with length, padding" do
"foo".rjust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do
- "hello".rjust(4, 'X'.taint).tainted?.should be_false
- "hello".rjust(5, 'X'.taint).tainted?.should be_false
- "hello".rjust(6, 'X'.taint).tainted?.should be_true
- end
- end
-
- describe "with width" do
- it "returns a String in the same encoding as the original" do
- str = "abc".force_encoding Encoding::IBM437
- result = str.rjust 5
- result.should == " abc"
- result.encoding.should equal(Encoding::IBM437)
- end
+ it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do
+ "hello".rjust(4, 'X'.taint).tainted?.should be_false
+ "hello".rjust(5, 'X'.taint).tainted?.should be_false
+ "hello".rjust(6, 'X'.taint).tainted?.should be_true
end
- describe "with width, pattern" do
- it "returns a String in the compatible encoding" do
- str = "abc".force_encoding Encoding::IBM437
- result = str.rjust 5, "ã‚"
- result.should == "ã‚ã‚abc"
- result.encoding.should equal(Encoding::UTF_8)
+ with_feature :encoding do
+ describe "with width" do
+ it "returns a String in the same encoding as the original" do
+ str = "abc".force_encoding Encoding::IBM437
+ result = str.rjust 5
+ result.should == " abc"
+ result.encoding.should equal(Encoding::IBM437)
+ end
end
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
- pat = "ã‚¢".encode Encoding::EUC_JP
- -> do
- "ã‚れ".rjust 5, pat
- end.should raise_error(Encoding::CompatibilityError)
+ describe "with width, pattern" do
+ it "returns a String in the compatible encoding" do
+ str = "abc".force_encoding Encoding::IBM437
+ result = str.rjust 5, "ã‚"
+ result.should == "ã‚ã‚abc"
+ result.encoding.should equal(Encoding::UTF_8)
+ end
+
+ it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
+ pat = "ã‚¢".encode Encoding::EUC_JP
+ lambda do
+ "ã‚れ".rjust 5, pat
+ end.should raise_error(Encoding::CompatibilityError)
+ end
end
end
end
diff --git a/spec/ruby/core/string/rpartition_spec.rb b/spec/ruby/core/string/rpartition_spec.rb
index c6428636f6..c58d96f298 100644
--- a/spec/ruby/core/string/rpartition_spec.rb
+++ b/spec/ruby/core/string/rpartition_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#rpartition with String" do
it "returns an array of substrings based on splitting on the given string" do
@@ -27,7 +27,7 @@ describe "String#rpartition with String" do
end
it "raises an error if not convertible to string" do
- ->{ "hello".rpartition(5) }.should raise_error(TypeError)
- ->{ "hello".rpartition(nil) }.should raise_error(TypeError)
+ lambda{ "hello".rpartition(5) }.should raise_error(TypeError)
+ lambda{ "hello".rpartition(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/string/rstrip_spec.rb b/spec/ruby/core/string/rstrip_spec.rb
index 9482765e89..9dd686ce55 100644
--- a/spec/ruby/core/string/rstrip_spec.rb
+++ b/spec/ruby/core/string/rstrip_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#rstrip" do
it "returns a copy of self with trailing whitespace removed" do
@@ -14,12 +14,10 @@ describe "String#rstrip" do
"\x00 \x00hello\x00 \x00".rstrip.should == "\x00 \x00hello"
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self is tainted" do
- "".taint.rstrip.tainted?.should == true
- "ok".taint.rstrip.tainted?.should == true
- "ok ".taint.rstrip.tainted?.should == true
- end
+ it "taints the result when self is tainted" do
+ "".taint.rstrip.tainted?.should == true
+ "ok".taint.rstrip.tainted?.should == true
+ "ok ".taint.rstrip.tainted?.should == true
end
end
@@ -42,13 +40,13 @@ describe "String#rstrip!" do
a.should == "hello"
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> { " hello ".freeze.rstrip! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda { " hello ".freeze.rstrip! }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
- -> { "hello".freeze.rstrip! }.should raise_error(frozen_error_class)
- -> { "".freeze.rstrip! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
+ lambda { "hello".freeze.rstrip! }.should raise_error(RuntimeError)
+ lambda { "".freeze.rstrip! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/scan_spec.rb b/spec/ruby/core/string/scan_spec.rb
index 024e97022a..f09daa1b74 100644
--- a/spec/ruby/core/string/scan_spec.rb
+++ b/spec/ruby/core/string/scan_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#scan" do
it "returns an array containing all matches" do
@@ -58,38 +58,31 @@ describe "String#scan" do
end
it "raises a TypeError if pattern isn't a Regexp and can't be converted to a String" do
- -> { "cruel world".scan(5) }.should raise_error(TypeError)
+ lambda { "cruel world".scan(5) }.should raise_error(TypeError)
not_supported_on :opal do
- -> { "cruel world".scan(:test) }.should raise_error(TypeError)
+ lambda { "cruel world".scan(:test) }.should raise_error(TypeError)
end
- -> { "cruel world".scan(mock('x')) }.should raise_error(TypeError)
+ lambda { "cruel world".scan(mock('x')) }.should raise_error(TypeError)
end
- ruby_version_is ''...'2.7' do
- it "taints the results if the String argument is tainted" do
- a = "hello hello hello".scan("hello".taint)
- a.each { |m| m.tainted?.should be_true }
- end
-
- it "taints the results when passed a String argument if self is tainted" do
- a = "hello hello hello".taint.scan("hello")
- a.each { |m| m.tainted?.should be_true }
- end
+ it "taints the results if the String argument is tainted" do
+ a = "hello hello hello".scan("hello".taint)
+ a.each { |m| m.tainted?.should be_true }
+ end
- it "taints the results if the Regexp argument is tainted" do
- a = "hello".scan(/./.taint)
- a.each { |m| m.tainted?.should be_true }
- end
+ it "taints the results when passed a String argument if self is tainted" do
+ a = "hello hello hello".taint.scan("hello")
+ a.each { |m| m.tainted?.should be_true }
+ end
- it "taints the results when passed a Regexp argument if self is tainted" do
- a = "hello".taint.scan(/./)
- a.each { |m| m.tainted?.should be_true }
- end
+ it "taints the results if the Regexp argument is tainted" do
+ a = "hello".scan(/./.taint)
+ a.each { |m| m.tainted?.should be_true }
end
- # jruby/jruby#5513
- it "does not raise any errors when passed a multi-byte string" do
- "ã‚ã‚ã‚aaaã‚ã‚ã‚".scan("ã‚ã‚ã‚").should == ["ã‚ã‚ã‚", "ã‚ã‚ã‚"]
+ it "taints the results when passed a Regexp argument if self is tainted" do
+ a = "hello".taint.scan(/./)
+ a.each { |m| m.tainted?.should be_true }
end
end
@@ -173,22 +166,20 @@ describe "String#scan with pattern and block" do
$~.should == nil
end
- ruby_version_is ''...'2.7' do
- it "taints the results if the String argument is tainted" do
- "hello hello hello".scan("hello".taint).each { |m| m.tainted?.should be_true }
- end
+ it "taints the results if the String argument is tainted" do
+ "hello hello hello".scan("hello".taint).each { |m| m.tainted?.should be_true }
+ end
- it "taints the results when passed a String argument if self is tainted" do
- "hello hello hello".taint.scan("hello").each { |m| m.tainted?.should be_true }
- end
+ it "taints the results when passed a String argument if self is tainted" do
+ "hello hello hello".taint.scan("hello").each { |m| m.tainted?.should be_true }
+ end
- it "taints the results if the Regexp argument is tainted" do
- "hello".scan(/./.taint).each { |m| m.tainted?.should be_true }
- end
+ it "taints the results if the Regexp argument is tainted" do
+ "hello".scan(/./.taint).each { |m| m.tainted?.should be_true }
+ end
- it "taints the results when passed a Regexp argument if self is tainted" do
- "hello".taint.scan(/./).each { |m| m.tainted?.should be_true }
- end
+ it "taints the results when passed a Regexp argument if self is tainted" do
+ "hello".taint.scan(/./).each { |m| m.tainted?.should be_true }
end
it "passes block arguments as individual arguments when blocks are provided" do
diff --git a/spec/ruby/core/string/scrub_spec.rb b/spec/ruby/core/string/scrub_spec.rb
index 390035ef30..815eb0fbb7 100644
--- a/spec/ruby/core/string/scrub_spec.rb
+++ b/spec/ruby/core/string/scrub_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path("../../../spec_helper", __FILE__)
describe "String#scrub with a default replacement" do
it "returns self for valid strings" do
@@ -47,14 +47,14 @@ describe "String#scrub with a custom replacement" do
it "raises ArgumentError for replacements with an invalid encoding" do
x81 = [0x81].pack('C').force_encoding('utf-8')
xE4 = [0xE4].pack('C').force_encoding('utf-8')
- block = -> { "foo#{x81}".scrub(xE4) }
+ block = lambda { "foo#{x81}".scrub(xE4) }
block.should raise_error(ArgumentError)
end
it "raises TypeError when a non String replacement is given" do
x81 = [0x81].pack('C').force_encoding('utf-8')
- block = -> { "foo#{x81}".scrub(1) }
+ block = lambda { "foo#{x81}".scrub(1) }
block.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/string/setbyte_spec.rb b/spec/ruby/core/string/setbyte_spec.rb
index 6912b1b66f..6373d74be1 100644
--- a/spec/ruby/core/string/setbyte_spec.rb
+++ b/spec/ruby/core/string/setbyte_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#setbyte" do
it "returns an Integer" do
@@ -51,11 +51,11 @@ describe "String#setbyte" do
end
it "raises an IndexError if the index is greater than the String bytesize" do
- -> { "?".setbyte(1, 97) }.should raise_error(IndexError)
+ lambda { "?".setbyte(1, 97) }.should raise_error(IndexError)
end
- it "raises an IndexError if the negative index is greater magnitude than the String bytesize" do
- -> { "???".setbyte(-5, 97) }.should raise_error(IndexError)
+ it "raises an IndexError if the nexgative index is greater magnitude than the String bytesize" do
+ lambda { "???".setbyte(-5, 97) }.should raise_error(IndexError)
end
it "sets a byte at an index greater than String size" do
@@ -75,14 +75,14 @@ describe "String#setbyte" do
str1.should_not == "ledgehog"
end
- it "raises a #{frozen_error_class} if self is frozen" do
+ it "raises a RuntimeError if self is frozen" do
str = "cold".freeze
str.frozen?.should be_true
- -> { str.setbyte(3,96) }.should raise_error(frozen_error_class)
+ lambda { str.setbyte(3,96) }.should raise_error(RuntimeError)
end
it "raises a TypeError unless the second argument is an Integer" do
- -> { "a".setbyte(0,'a') }.should raise_error(TypeError)
+ lambda { "a".setbyte(0,'a') }.should raise_error(TypeError)
end
it "calls #to_int to convert the index" do
diff --git a/spec/ruby/core/string/shared/chars.rb b/spec/ruby/core/string/shared/chars.rb
index 9c7a4deb8b..c1cf324dc5 100644
--- a/spec/ruby/core/string/shared/chars.rb
+++ b/spec/ruby/core/string/shared/chars.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :string_chars, shared: true do
it "passes each char in self to the given block" do
@@ -20,51 +20,51 @@ describe :string_chars, shared: true do
["\303\207", "\342\210\202", "\303\251", "\306\222", "g"]
end
- it "returns characters in the same encoding as self" do
- "&%".force_encoding('Shift_JIS').send(@method).to_a.all? {|c| c.encoding.name.should == 'Shift_JIS'}
- "&%".encode('BINARY').send(@method).to_a.all? {|c| c.encoding.should == Encoding::BINARY }
- end
+ with_feature :encoding do
+ it "returns characters in the same encoding as self" do
+ "&%".force_encoding('Shift_JIS').send(@method).to_a.all? {|c| c.encoding.name.should == 'Shift_JIS'}
+ "&%".encode('ASCII-8BIT').send(@method).to_a.all? {|c| c.encoding.name.should == 'ASCII-8BIT'}
+ end
- it "works with multibyte characters" do
- s = "\u{8987}".force_encoding("UTF-8")
- s.bytesize.should == 3
- s.send(@method).to_a.should == [s]
- end
+ it "works with multibyte characters" do
+ s = "\u{8987}".force_encoding("UTF-8")
+ s.bytesize.should == 3
+ s.send(@method).to_a.should == [s]
+ end
- it "works if the String's contents is invalid for its encoding" do
- xA4 = [0xA4].pack('C')
- xA4.force_encoding('UTF-8')
- xA4.valid_encoding?.should be_false
- xA4.send(@method).to_a.should == [xA4.force_encoding("UTF-8")]
- end
+ it "works if the String's contents is invalid for its encoding" do
+ xA4 = [0xA4].pack('C')
+ xA4.force_encoding('UTF-8')
+ xA4.valid_encoding?.should be_false
+ xA4.send(@method).to_a.should == [xA4.force_encoding("UTF-8")]
+ end
- it "returns a different character if the String is transcoded" do
- s = "\u{20AC}".force_encoding('UTF-8')
- s.encode('UTF-8').send(@method).to_a.should == ["\u{20AC}".force_encoding('UTF-8')]
- s.encode('iso-8859-15').send(@method).to_a.should == [[0xA4].pack('C').force_encoding('iso-8859-15')]
- s.encode('iso-8859-15').encode('UTF-8').send(@method).to_a.should == ["\u{20AC}".force_encoding('UTF-8')]
- end
+ it "returns a different character if the String is transcoded" do
+ s = "\u{20AC}".force_encoding('UTF-8')
+ s.encode('UTF-8').send(@method).to_a.should == ["\u{20AC}".force_encoding('UTF-8')]
+ s.encode('iso-8859-15').send(@method).to_a.should == [[0xA4].pack('C').force_encoding('iso-8859-15')]
+ s.encode('iso-8859-15').encode('UTF-8').send(@method).to_a.should == ["\u{20AC}".force_encoding('UTF-8')]
+ end
- it "uses the String's encoding to determine what characters it contains" do
- s = "\u{24B62}"
+ it "uses the String's encoding to determine what characters it contains" do
+ s = "\u{24B62}"
- s.force_encoding('UTF-8').send(@method).to_a.should == [
- s.force_encoding('UTF-8')
- ]
- s.force_encoding('BINARY').send(@method).to_a.should == [
- [0xF0].pack('C').force_encoding('BINARY'),
- [0xA4].pack('C').force_encoding('BINARY'),
- [0xAD].pack('C').force_encoding('BINARY'),
- [0xA2].pack('C').force_encoding('BINARY')
- ]
- s.force_encoding('SJIS').send(@method).to_a.should == [
- [0xF0,0xA4].pack('CC').force_encoding('SJIS'),
- [0xAD].pack('C').force_encoding('SJIS'),
- [0xA2].pack('C').force_encoding('SJIS')
- ]
- end
+ s.force_encoding('UTF-8').send(@method).to_a.should == [
+ s.force_encoding('UTF-8')
+ ]
+ s.force_encoding('BINARY').send(@method).to_a.should == [
+ [0xF0].pack('C').force_encoding('BINARY'),
+ [0xA4].pack('C').force_encoding('BINARY'),
+ [0xAD].pack('C').force_encoding('BINARY'),
+ [0xA2].pack('C').force_encoding('BINARY')
+ ]
+ s.force_encoding('SJIS').send(@method).to_a.should == [
+ [0xF0,0xA4].pack('CC').force_encoding('SJIS'),
+ [0xAD].pack('C').force_encoding('SJIS'),
+ [0xA2].pack('C').force_encoding('SJIS')
+ ]
+ end
- ruby_version_is ''...'2.7' do
it "taints resulting strings when self is tainted" do
str = "hello"
diff --git a/spec/ruby/core/string/shared/codepoints.rb b/spec/ruby/core/string/shared/codepoints.rb
index e94a57f48e..68f82b4468 100644
--- a/spec/ruby/core/string/shared/codepoints.rb
+++ b/spec/ruby/core/string/shared/codepoints.rb
@@ -1,15 +1,9 @@
# -*- encoding: binary -*-
describe :string_codepoints, shared: true do
- it "returns self" do
- s = "foo"
- result = s.send(@method) {}
- result.should equal s
- end
-
it "raises an ArgumentError when self has an invalid encoding and a method is called on the returned Enumerator" do
s = "\xDF".force_encoding(Encoding::UTF_8)
s.valid_encoding?.should be_false
- -> { s.send(@method).to_a }.should raise_error(ArgumentError)
+ lambda { s.send(@method).to_a }.should raise_error(ArgumentError)
end
it "yields each codepoint to the block if one is given" do
@@ -23,16 +17,16 @@ describe :string_codepoints, shared: true do
it "raises an ArgumentError if self's encoding is invalid and a block is given" do
s = "\xDF".force_encoding(Encoding::UTF_8)
s.valid_encoding?.should be_false
- -> { s.send(@method) { } }.should raise_error(ArgumentError)
+ lambda { s.send(@method) { } }.should raise_error(ArgumentError)
end
- it "yields codepoints as Fixnums" do
+ it "returns codepoints as Fixnums" do
"glark\u{20}".send(@method).to_a.each do |codepoint|
codepoint.should be_an_instance_of(Fixnum)
end
end
- it "yields one codepoint for each character" do
+ it "returns one codepoint for each character" do
s = "\u{9876}\u{28}\u{1987}"
s.send(@method).to_a.size.should == s.chars.to_a.size
end
@@ -43,7 +37,7 @@ describe :string_codepoints, shared: true do
s.send(@method).to_a.should == [38937]
end
- it "yields the codepoints corresponding to the character's position in the String's encoding" do
+ it "returns the codepoint corresponding to the character's position in the String's encoding" do
"\u{787}".send(@method).to_a.should == [1927]
end
@@ -54,7 +48,7 @@ describe :string_codepoints, shared: true do
s.should == s2
end
- it "is synonymous with #bytes for Strings which are single-byte optimizable" do
+ it "is synonymous with #bytes for Strings which are single-byte optimisable" do
s = "(){}".encode('ascii')
s.ascii_only?.should be_true
s.send(@method).to_a.should == s.bytes.to_a
diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb
index 435158496e..7da995fdc7 100644
--- a/spec/ruby/core/string/shared/concat.rb
+++ b/spec/ruby/core/string/shared/concat.rb
@@ -13,16 +13,16 @@ describe :string_concat, shared: true do
end
it "raises a TypeError if the given argument can't be converted to a String" do
- -> { 'hello '.send(@method, []) }.should raise_error(TypeError)
- -> { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError)
+ lambda { 'hello '.send(@method, []) }.should raise_error(TypeError)
+ lambda { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError)
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
a = "hello"
a.freeze
- -> { a.send(@method, "") }.should raise_error(frozen_error_class)
- -> { a.send(@method, "test") }.should raise_error(frozen_error_class)
+ lambda { a.send(@method, "") }.should raise_error(RuntimeError)
+ lambda { a.send(@method, "test") }.should raise_error(RuntimeError)
end
it "returns a String when given a subclass instance" do
@@ -39,20 +39,18 @@ describe :string_concat, shared: true do
str.should be_an_instance_of(StringSpecs::MyString)
end
- ruby_version_is ''...'2.7' do
- it "taints self if other is tainted" do
- "x".send(@method, "".taint).tainted?.should == true
- "x".send(@method, "y".taint).tainted?.should == true
- end
+ it "taints self if other is tainted" do
+ "x".send(@method, "".taint).tainted?.should == true
+ "x".send(@method, "y".taint).tainted?.should == true
+ end
- it "untrusts self if other is untrusted" do
- "x".send(@method, "".untrust).untrusted?.should == true
- "x".send(@method, "y".untrust).untrusted?.should == true
- end
+ it "untrusts self if other is untrusted" do
+ "x".send(@method, "".untrust).untrusted?.should == true
+ "x".send(@method, "y".untrust).untrusted?.should == true
end
describe "with Integer" do
- it "concatenates the argument interpreted as a codepoint" do
+ it "concatencates the argument interpreted as a codepoint" do
b = "".send(@method, 33)
b.should == "!"
@@ -62,39 +60,39 @@ describe :string_concat, shared: true do
end
# #5855
- it "returns a BINARY string if self is US-ASCII and the argument is between 128-255 (inclusive)" do
+ it "returns a ASCII-8BIT string if self is US-ASCII and the argument is between 128-255 (inclusive)" do
a = ("".encode(Encoding::US_ASCII).send(@method, 128))
- a.encoding.should == Encoding::BINARY
+ a.encoding.should == Encoding::ASCII_8BIT
a.should == 128.chr
a = ("".encode(Encoding::US_ASCII).send(@method, 255))
- a.encoding.should == Encoding::BINARY
+ a.encoding.should == Encoding::ASCII_8BIT
a.should == 255.chr
end
it "raises RangeError if the argument is an invalid codepoint for self's encoding" do
- -> { "".encode(Encoding::US_ASCII).send(@method, 256) }.should raise_error(RangeError)
- -> { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should raise_error(RangeError)
+ lambda { "".encode(Encoding::US_ASCII).send(@method, 256) }.should raise_error(RangeError)
+ lambda { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should raise_error(RangeError)
end
it "raises RangeError if the argument is negative" do
- -> { "".send(@method, -200) }.should raise_error(RangeError)
- -> { "".send(@method, -bignum_value) }.should raise_error(RangeError)
+ lambda { "".send(@method, -200) }.should raise_error(RangeError)
+ lambda { "".send(@method, -bignum_value) }.should raise_error(RangeError)
end
it "doesn't call to_int on its argument" do
x = mock('x')
x.should_not_receive(:to_int)
- -> { "".send(@method, x) }.should raise_error(TypeError)
+ lambda { "".send(@method, x) }.should raise_error(TypeError)
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
a = "hello"
a.freeze
- -> { a.send(@method, 0) }.should raise_error(frozen_error_class)
- -> { a.send(@method, 33) }.should raise_error(frozen_error_class)
+ lambda { a.send(@method, 0) }.should raise_error(RuntimeError)
+ lambda { a.send(@method, 33) }.should raise_error(RuntimeError)
end
end
end
@@ -114,7 +112,7 @@ describe :string_concat_encoding, shared: true do
end
it "raises Encoding::CompatibilityError if neither are empty" do
- -> { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should raise_error(Encoding::CompatibilityError)
+ lambda { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should raise_error(Encoding::CompatibilityError)
end
end
@@ -132,7 +130,7 @@ describe :string_concat_encoding, shared: true do
end
it "raises Encoding::CompatibilityError if neither are empty" do
- -> { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError)
+ lambda { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError)
end
end
@@ -150,13 +148,13 @@ describe :string_concat_encoding, shared: true do
end
it "raises Encoding::CompatibilityError if neither are ASCII-only" do
- -> { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should raise_error(Encoding::CompatibilityError)
+ lambda { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should raise_error(Encoding::CompatibilityError)
end
end
- describe "when self is BINARY and argument is US-ASCII" do
- it "uses BINARY encoding" do
- "abc".encode("BINARY").send(@method, "123".encode("US-ASCII")).encoding.should == Encoding::BINARY
+ describe "when self is ASCII-8BIT and argument is US-ASCII" do
+ it "uses ASCII-8BIT encoding" do
+ "abc".encode("ASCII-8BIT").send(@method, "123".encode("US-ASCII")).encoding.should == Encoding::ASCII_8BIT
end
end
end
diff --git a/spec/ruby/core/string/shared/each_char_without_block.rb b/spec/ruby/core/string/shared/each_char_without_block.rb
index 397100ce0e..40808cfd9f 100644
--- a/spec/ruby/core/string/shared/each_char_without_block.rb
+++ b/spec/ruby/core/string/shared/each_char_without_block.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :string_each_char_without_block, shared: true do
describe "when no block is given" do
diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb
index 843b123f57..dee741e270 100644
--- a/spec/ruby/core/string/shared/each_line.rb
+++ b/spec/ruby/core/string/shared/each_line.rb
@@ -27,25 +27,10 @@ describe :string_each_line, shared: true do
c.should == ["hello\n", "\n", "\n", "world"]
end
- it "splits strings containing multibyte characters" do
- s = <<~EOS
- foo
- 🤡🤡🤡🤡🤡🤡🤡
- bar
- baz
- EOS
+ it "taints substrings that are passed to the block if self is tainted" do
+ "one\ntwo\r\nthree".taint.send(@method) { |s| s.tainted?.should == true }
- b = []
- s.send(@method) { |part| b << part }
- b.should == ["foo\n", "🤡🤡🤡🤡🤡🤡🤡\n", "bar\n", "baz\n"]
- end
-
- ruby_version_is ''...'2.7' do
- it "taints substrings that are passed to the block if self is tainted" do
- "one\ntwo\r\nthree".taint.send(@method) { |s| s.tainted?.should == true }
-
- "x.y.".send(@method, ".".taint) { |s| s.tainted?.should == false }
- end
+ "x.y.".send(@method, ".".taint) { |s| s.tainted?.should == false }
end
it "passes self as a whole to the block if the separator is nil" do
@@ -66,8 +51,9 @@ describe :string_each_line, shared: true do
end
end
+quarantine! do # Currently fails on Travis
ruby_version_is '2.5' do
- it "yields paragraphs (broken by 2 or more successive newlines) when passed '' and replaces multiple newlines with only two ones" do
+ it "yields paragraphs (broken by 2 or more successive newlines) when passed ''" do
a = []
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n"]
@@ -77,6 +63,7 @@ describe :string_each_line, shared: true do
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n", "dog"]
end
end
+end
describe "uses $/" do
before :each do
@@ -135,8 +122,8 @@ describe :string_each_line, shared: true do
end
it "raises a TypeError when the separator can't be converted to a string" do
- -> { "hello world".send(@method, false) {} }.should raise_error(TypeError)
- -> { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError)
+ lambda { "hello world".send(@method, false) {} }.should raise_error(TypeError)
+ lambda { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError)
end
it "accepts a string separator" do
@@ -144,35 +131,20 @@ describe :string_each_line, shared: true do
end
it "raises a TypeError when the separator is a symbol" do
- -> { "hello world".send(@method, :o).to_a }.should raise_error(TypeError)
+ lambda { "hello world".send(@method, :o).to_a }.should raise_error(TypeError)
end
- context "when `chomp` keyword argument is passed" do
- it "removes new line characters when separator is not specified" do
- a = []
- "hello \nworld\n".send(@method, chomp: true) { |s| a << s }
- a.should == ["hello ", "world"]
-
- a = []
- "hello \r\nworld\r\n".send(@method, chomp: true) { |s| a << s }
- a.should == ["hello ", "world"]
- end
-
- it "removes only specified separator" do
- a = []
- "hello world".send(@method, ' ', chomp: true) { |s| a << s }
- a.should == ["hello", "world"]
- end
+ ruby_version_is '2.4' do
+ context "when `chomp` keyword argument is passed" do
+ it "removes new line characters" do
+ a = []
+ "hello \nworld\n".send(@method, chomp: true) { |s| a << s }
+ a.should == ["hello ", "world"]
- # https://bugs.ruby-lang.org/issues/14257
- it "ignores new line characters when separator is specified" do
- a = []
- "hello\n world\n".send(@method, ' ', chomp: true) { |s| a << s }
- a.should == ["hello\n", "world\n"]
-
- a = []
- "hello\r\n world\r\n".send(@method, ' ', chomp: true) { |s| a << s }
- a.should == ["hello\r\n", "world\r\n"]
+ a = []
+ "hello \r\nworld\r\n".send(@method, chomp: true) { |s| a << s }
+ a.should == ["hello ", "world"]
+ end
end
end
end
diff --git a/spec/ruby/core/string/shared/encode.rb b/spec/ruby/core/string/shared/encode.rb
index a73de5b943..71d46b1bd3 100644
--- a/spec/ruby/core/string/shared/encode.rb
+++ b/spec/ruby/core/string/shared/encode.rb
@@ -8,20 +8,20 @@ describe :string_encode, shared: true do
end
it "transcodes a 7-bit String despite no generic converting being available" do
- -> do
- Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY
+ lambda do
+ Encoding::Converter.new Encoding::Emacs_Mule, Encoding::ASCII_8BIT
end.should raise_error(Encoding::ConverterNotFoundError)
Encoding.default_internal = Encoding::Emacs_Mule
- str = "\x79".force_encoding Encoding::BINARY
+ str = "\x79".force_encoding Encoding::ASCII_8BIT
- str.send(@method).should == "y".force_encoding(Encoding::BINARY)
+ str.send(@method).should == "y".force_encoding(Encoding::ASCII_8BIT)
end
it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do
Encoding.default_internal = Encoding::Emacs_Mule
- str = [0x80].pack('C').force_encoding Encoding::BINARY
- -> { str.send(@method) }.should raise_error(Encoding::ConverterNotFoundError)
+ str = [0x80].pack('C').force_encoding Encoding::ASCII_8BIT
+ lambda { str.send(@method) }.should raise_error(Encoding::ConverterNotFoundError)
end
end
@@ -51,23 +51,23 @@ describe :string_encode, shared: true do
end
it "transcodes a 7-bit String despite no generic converting being available" do
- -> do
- Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY
+ lambda do
+ Encoding::Converter.new Encoding::Emacs_Mule, Encoding::ASCII_8BIT
end.should raise_error(Encoding::ConverterNotFoundError)
- str = "\x79".force_encoding Encoding::BINARY
- str.send(@method, Encoding::Emacs_Mule).should == "y".force_encoding(Encoding::BINARY)
+ str = "\x79".force_encoding Encoding::ASCII_8BIT
+ str.send(@method, Encoding::Emacs_Mule).should == "y".force_encoding(Encoding::ASCII_8BIT)
end
it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do
- str = [0x80].pack('C').force_encoding Encoding::BINARY
- -> do
+ str = [0x80].pack('C').force_encoding Encoding::ASCII_8BIT
+ lambda do
str.send(@method, Encoding::Emacs_Mule)
end.should raise_error(Encoding::ConverterNotFoundError)
end
it "raises an Encoding::ConverterNotFoundError for an invalid encoding" do
- -> do
+ lambda do
"abc".send(@method, "xyz")
end.should raise_error(Encoding::ConverterNotFoundError)
end
@@ -83,7 +83,7 @@ describe :string_encode, shared: true do
options = mock("string encode options")
options.should_receive(:to_hash).and_return({ undef: :replace })
- result = "ã‚\ufffdã‚".send(@method, **options)
+ result = "ã‚\ufffdã‚".send(@method, options)
result.should == "ã‚\ufffdã‚"
end
@@ -95,8 +95,8 @@ describe :string_encode, shared: true do
it "raises an Encoding::ConverterNotFoundError when no conversion is possible despite 'invalid: :replace, undef: :replace'" do
Encoding.default_internal = Encoding::Emacs_Mule
- str = [0x80].pack('C').force_encoding Encoding::BINARY
- -> do
+ str = [0x80].pack('C').force_encoding Encoding::ASCII_8BIT
+ lambda do
str.send(@method, invalid: :replace, undef: :replace)
end.should raise_error(Encoding::ConverterNotFoundError)
end
@@ -145,7 +145,7 @@ describe :string_encode, shared: true do
options = mock("string encode options")
options.should_receive(:to_hash).and_return({ undef: :replace })
- result = "ã‚?ã‚".send(@method, Encoding::EUC_JP, **options)
+ result = "ã‚?ã‚".send(@method, Encoding::EUC_JP, options)
xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding('utf-8')
result.should == "#{xA4xA2}?#{xA4xA2}".force_encoding("euc-jp")
end
@@ -153,7 +153,7 @@ describe :string_encode, shared: true do
describe "when passed to, from, options" do
it "replaces undefined characters in the destination encoding" do
- str = "ã‚?ã‚".force_encoding Encoding::BINARY
+ str = "ã‚?ã‚".force_encoding Encoding::ASCII_8BIT
result = str.send(@method, "euc-jp", "utf-8", undef: :replace)
xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding('utf-8')
result.should == "#{xA4xA2}?#{xA4xA2}".force_encoding("euc-jp")
@@ -161,7 +161,7 @@ describe :string_encode, shared: true do
it "replaces invalid characters in the destination encoding" do
xFF = [0xFF].pack('C').force_encoding('utf-8')
- str = "ab#{xFF}c".force_encoding Encoding::BINARY
+ str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT
str.send(@method, "iso-8859-1", "utf-8", invalid: :replace).should == "ab?c"
end
@@ -170,7 +170,7 @@ describe :string_encode, shared: true do
to.should_receive(:to_str).and_return("iso-8859-1")
xFF = [0xFF].pack('C').force_encoding('utf-8')
- str = "ab#{xFF}c".force_encoding Encoding::BINARY
+ str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT
str.send(@method, to, "utf-8", invalid: :replace).should == "ab?c"
end
@@ -179,7 +179,7 @@ describe :string_encode, shared: true do
from.should_receive(:to_str).and_return("utf-8")
xFF = [0xFF].pack('C').force_encoding('utf-8')
- str = "ab#{xFF}c".force_encoding Encoding::BINARY
+ str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT
str.send(@method, "iso-8859-1", from, invalid: :replace).should == "ab?c"
end
@@ -188,8 +188,8 @@ describe :string_encode, shared: true do
options.should_receive(:to_hash).and_return({ invalid: :replace })
xFF = [0xFF].pack('C').force_encoding('utf-8')
- str = "ab#{xFF}c".force_encoding Encoding::BINARY
- str.send(@method, "iso-8859-1", "utf-8", **options).should == "ab?c"
+ str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT
+ str.send(@method, "iso-8859-1", "utf-8", options).should == "ab?c"
end
end
@@ -242,6 +242,6 @@ describe :string_encode, shared: true do
end
it "raises ArgumentError if the value of the :xml option is not :text or :attr" do
- -> { ''.send(@method, "UTF-8", xml: :other) }.should raise_error(ArgumentError)
+ lambda { ''.send(@method, "UTF-8", xml: :other) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/string/shared/eql.rb b/spec/ruby/core/string/shared/eql.rb
index 85b861f4f1..92dfa91923 100644
--- a/spec/ruby/core/string/shared/eql.rb
+++ b/spec/ruby/core/string/shared/eql.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :string_eql_value, shared: true do
it "returns true if self <=> string returns 0" do
diff --git a/spec/ruby/core/string/shared/equal_value.rb b/spec/ruby/core/string/shared/equal_value.rb
index fccafb5821..6df76478c7 100644
--- a/spec/ruby/core/string/shared/equal_value.rb
+++ b/spec/ruby/core/string/shared/equal_value.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :string_equal_value, shared: true do
it "returns false if obj does not respond to to_str" do
@@ -17,7 +17,7 @@ describe :string_equal_value, shared: true do
# not call it.
obj.stub!(:to_str)
- # Don't use @method for :== in `obj.should_receive(:==)`
+ # Don't use @method for :== in `obj.should_recerive(:==)`
obj.should_receive(:==).and_return(true)
'hello'.send(@method, obj).should be_true
diff --git a/spec/ruby/core/string/shared/grapheme_clusters.rb b/spec/ruby/core/string/shared/grapheme_clusters.rb
deleted file mode 100644
index 8b666868b1..0000000000
--- a/spec/ruby/core/string/shared/grapheme_clusters.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-
-describe :string_grapheme_clusters, shared: true do
- it "passes each grapheme cluster in self to the given block" do
- a = []
- # test string: abc[rainbow flag emoji][paw prints]
- "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}".send(@method) { |c| a << c }
- a.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"]
- end
-
- it "returns self" do
- s = StringSpecs::MyString.new "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}"
- s.send(@method) {}.should equal(s)
- end
-end
diff --git a/spec/ruby/core/string/shared/length.rb b/spec/ruby/core/string/shared/length.rb
index f387fb251c..0e6e66ee1c 100644
--- a/spec/ruby/core/string/shared/length.rb
+++ b/spec/ruby/core/string/shared/length.rb
@@ -10,17 +10,19 @@ describe :string_length, shared: true do
"four".send(@method).should == 4
end
- it "returns the length of a string in different encodings" do
- utf8_str = 'ã“ã«ã¡ã‚' * 100
- utf8_str.size.should == 400
- utf8_str.encode(Encoding::UTF_32BE).size.should == 400
- utf8_str.encode(Encoding::SHIFT_JIS).size.should == 400
- end
+ with_feature :encoding do
+ it "returns the length of a string in different encodings" do
+ utf8_str = 'ã“ã«ã¡ã‚' * 100
+ utf8_str.size.should == 400
+ utf8_str.encode(Encoding::UTF_32BE).size.should == 400
+ utf8_str.encode(Encoding::SHIFT_JIS).size.should == 400
+ end
- it "returns the length of the new self after encoding is changed" do
- str = 'ã“ã«ã¡ã‚'
- str.send(@method)
+ it "returns the length of the new self after encoding is changed" do
+ str = 'ã“ã«ã¡ã‚'
+ str.send(@method)
- str.force_encoding('BINARY').send(@method).should == 12
+ str.force_encoding('ASCII-8BIT').send(@method).should == 12
+ end
end
end
diff --git a/spec/ruby/core/string/shared/replace.rb b/spec/ruby/core/string/shared/replace.rb
index 620021eb92..9f5446fbbe 100644
--- a/spec/ruby/core/string/shared/replace.rb
+++ b/spec/ruby/core/string/shared/replace.rb
@@ -10,34 +10,32 @@ describe :string_replace, shared: true do
a.should == "another string"
end
- ruby_version_is ''...'2.7' do
- it "taints self if other is tainted" do
- a = ""
- b = "".taint
- a.send(@method, b)
- a.tainted?.should == true
- end
+ it "taints self if other is tainted" do
+ a = ""
+ b = "".taint
+ a.send(@method, b)
+ a.tainted?.should == true
+ end
- it "does not untaint self if other is untainted" do
- a = "".taint
- b = ""
- a.send(@method, b)
- a.tainted?.should == true
- end
+ it "does not untaint self if other is untainted" do
+ a = "".taint
+ b = ""
+ a.send(@method, b)
+ a.tainted?.should == true
+ end
- it "untrusts self if other is untrusted" do
- a = ""
- b = "".untrust
- a.send(@method, b)
- a.untrusted?.should == true
- end
+ it "untrusts self if other is untrusted" do
+ a = ""
+ b = "".untrust
+ a.send(@method, b)
+ a.untrusted?.should == true
+ end
- it "does not trust self if other is trusted" do
- a = "".untrust
- b = ""
- a.send(@method, b)
- a.untrusted?.should == true
- end
+ it "does not trust self if other is trusted" do
+ a = "".untrust
+ b = ""
+ a.send(@method, b)
+ a.untrusted?.should == true
end
it "replaces the encoding of self with that of other" do
@@ -59,19 +57,19 @@ describe :string_replace, shared: true do
end
it "raises a TypeError if other can't be converted to string" do
- -> { "hello".send(@method, 123) }.should raise_error(TypeError)
- -> { "hello".send(@method, []) }.should raise_error(TypeError)
- -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, 123) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, []) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, mock('x')) }.should raise_error(TypeError)
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
+ it "raises a RuntimeError on a frozen instance that is modified" do
a = "hello".freeze
- -> { a.send(@method, "world") }.should raise_error(frozen_error_class)
+ lambda { a.send(@method, "world") }.should raise_error(RuntimeError)
end
# see [ruby-core:23666]
- it "raises a #{frozen_error_class} on a frozen instance when self-replacing" do
+ it "raises a RuntimeError on a frozen instance when self-replacing" do
a = "hello".freeze
- -> { a.send(@method, a) }.should raise_error(frozen_error_class)
+ lambda { a.send(@method, a) }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb
index b192005369..697fa2e530 100644
--- a/spec/ruby/core/string/shared/slice.rb
+++ b/spec/ruby/core/string/shared/slice.rb
@@ -21,17 +21,17 @@ describe :string_slice, shared: true do
end
it "raises a TypeError if the given index is nil" do
- -> { "hello".send(@method, nil) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the given index can't be converted to an Integer" do
- -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError)
- -> { "hello".send(@method, {}) }.should raise_error(TypeError)
- -> { "hello".send(@method, []) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, {}) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, []) }.should raise_error(TypeError)
end
it "raises a RangeError if the index is too big" do
- -> { "hello".send(@method, bignum_value) }.should raise_error(RangeError)
+ lambda { "hello".send(@method, bignum_value) }.should raise_error(RangeError)
end
end
@@ -80,15 +80,13 @@ describe :string_slice_index_length, shared: true do
"hello there".send(@method, -3,2).should == "er"
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self is tainted" do
- str = "hello world"
- str.taint
+ it "always taints resulting strings when self is tainted" do
+ str = "hello world"
+ str.taint
- str.send(@method, 0,0).tainted?.should == true
- str.send(@method, 0,1).tainted?.should == true
- str.send(@method, 2,1).tainted?.should == true
- end
+ str.send(@method, 0,0).tainted?.should == true
+ str.send(@method, 0,1).tainted?.should == true
+ str.send(@method, 2,1).tainted?.should == true
end
it "returns a string with the same encoding" do
@@ -142,23 +140,23 @@ describe :string_slice_index_length, shared: true do
end
it "raises a TypeError when idx or length can't be converted to an integer" do
- -> { "hello".send(@method, mock('x'), 0) }.should raise_error(TypeError)
- -> { "hello".send(@method, 0, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, mock('x'), 0) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, 0, mock('x')) }.should raise_error(TypeError)
# I'm deliberately including this here.
# It means that str.send(@method, other, idx) isn't supported.
- -> { "hello".send(@method, "", 0) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, "", 0) }.should raise_error(TypeError)
end
it "raises a TypeError when the given index or the given length is nil" do
- -> { "hello".send(@method, 1, nil) }.should raise_error(TypeError)
- -> { "hello".send(@method, nil, 1) }.should raise_error(TypeError)
- -> { "hello".send(@method, nil, nil) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, 1, nil) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, nil, 1) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, nil, nil) }.should raise_error(TypeError)
end
it "raises a RangeError if the index or length is too big" do
- -> { "hello".send(@method, bignum_value, 1) }.should raise_error(RangeError)
- -> { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError)
+ lambda { "hello".send(@method, bignum_value, 1) }.should raise_error(RangeError)
+ lambda { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError)
end
it "returns subclass instances" do
@@ -236,18 +234,16 @@ describe :string_slice_range, shared: true do
"x".send(@method, 1...-1).should == ""
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self is tainted" do
- str = "hello world"
- str.taint
+ it "always taints resulting strings when self is tainted" do
+ str = "hello world"
+ str.taint
- str.send(@method, 0..0).tainted?.should == true
- str.send(@method, 0...0).tainted?.should == true
- str.send(@method, 0..1).tainted?.should == true
- str.send(@method, 0...1).tainted?.should == true
- str.send(@method, 2..3).tainted?.should == true
- str.send(@method, 2..0).tainted?.should == true
- end
+ str.send(@method, 0..0).tainted?.should == true
+ str.send(@method, 0...0).tainted?.should == true
+ str.send(@method, 0..1).tainted?.should == true
+ str.send(@method, 0...1).tainted?.should == true
+ str.send(@method, 2..3).tainted?.should == true
+ str.send(@method, 2..0).tainted?.should == true
end
it "returns subclass instances" do
@@ -306,25 +302,23 @@ describe :string_slice_regexp, shared: true do
end
not_supported_on :opal do
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self or regexp is tainted" do
- strs = ["hello world"]
- strs += strs.map { |s| s.dup.taint }
+ it "always taints resulting strings when self or regexp is tainted" do
+ strs = ["hello world"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str.send(@method, //).tainted?.should == str.tainted?
- str.send(@method, /hello/).tainted?.should == str.tainted?
+ strs.each do |str|
+ str.send(@method, //).tainted?.should == str.tainted?
+ str.send(@method, /hello/).tainted?.should == str.tainted?
- tainted_re = /./
- tainted_re.taint
+ tainted_re = /./
+ tainted_re.taint
- str.send(@method, tainted_re).tainted?.should == true
- end
+ str.send(@method, tainted_re).tainted?.should == true
end
+ end
- it "returns an untrusted string if the regexp is untrusted" do
- "hello".send(@method, /./.untrust).untrusted?.should be_true
- end
+ it "returns an untrusted string if the regexp is untrusted" do
+ "hello".send(@method, /./.untrust).untrusted?.should be_true
end
end
@@ -358,33 +352,31 @@ describe :string_slice_regexp_index, shared: true do
"har".send(@method, /(.)(.)(.)/, -3).should == "h"
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self or regexp is tainted" do
- strs = ["hello world"]
- strs += strs.map { |s| s.dup.taint }
+ it "always taints resulting strings when self or regexp is tainted" do
+ strs = ["hello world"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str.send(@method, //, 0).tainted?.should == str.tainted?
- str.send(@method, /hello/, 0).tainted?.should == str.tainted?
+ strs.each do |str|
+ str.send(@method, //, 0).tainted?.should == str.tainted?
+ str.send(@method, /hello/, 0).tainted?.should == str.tainted?
- str.send(@method, /(.)(.)(.)/, 0).tainted?.should == str.tainted?
- str.send(@method, /(.)(.)(.)/, 1).tainted?.should == str.tainted?
- str.send(@method, /(.)(.)(.)/, -1).tainted?.should == str.tainted?
- str.send(@method, /(.)(.)(.)/, -2).tainted?.should == str.tainted?
+ str.send(@method, /(.)(.)(.)/, 0).tainted?.should == str.tainted?
+ str.send(@method, /(.)(.)(.)/, 1).tainted?.should == str.tainted?
+ str.send(@method, /(.)(.)(.)/, -1).tainted?.should == str.tainted?
+ str.send(@method, /(.)(.)(.)/, -2).tainted?.should == str.tainted?
- tainted_re = /(.)(.)(.)/
- tainted_re.taint
+ tainted_re = /(.)(.)(.)/
+ tainted_re.taint
- str.send(@method, tainted_re, 0).tainted?.should == true
- str.send(@method, tainted_re, 1).tainted?.should == true
- str.send(@method, tainted_re, -1).tainted?.should == true
- end
+ str.send(@method, tainted_re, 0).tainted?.should == true
+ str.send(@method, tainted_re, 1).tainted?.should == true
+ str.send(@method, tainted_re, -1).tainted?.should == true
end
+ end
- not_supported_on :opal do
- it "returns an untrusted string if the regexp is untrusted" do
- "hello".send(@method, /(.)/.untrust, 1).untrusted?.should be_true
- end
+ not_supported_on :opal do
+ it "returns an untrusted string if the regexp is untrusted" do
+ "hello".send(@method, /(.)/.untrust, 1).untrusted?.should be_true
end
end
@@ -407,13 +399,13 @@ describe :string_slice_regexp_index, shared: true do
end
it "raises a TypeError when the given index can't be converted to Integer" do
- -> { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should raise_error(TypeError)
- -> { "hello".send(@method, /(.)(.)(.)/, {}) }.should raise_error(TypeError)
- -> { "hello".send(@method, /(.)(.)(.)/, []) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, /(.)(.)(.)/, {}) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, /(.)(.)(.)/, []) }.should raise_error(TypeError)
end
it "raises a TypeError when the given index is nil" do
- -> { "hello".send(@method, /(.)(.)(.)/, nil) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, /(.)(.)(.)/, nil) }.should raise_error(TypeError)
end
it "returns subclass instances" do
@@ -440,17 +432,15 @@ describe :string_slice_string, shared: true do
"hello there".send(@method, s).should == s
end
- ruby_version_is ''...'2.7' do
- it "taints resulting strings when other is tainted" do
- strs = ["", "hello world", "hello"]
- strs += strs.map { |s| s.dup.taint }
+ it "taints resulting strings when other is tainted" do
+ strs = ["", "hello world", "hello"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- strs.each do |other|
- r = str.send(@method, other)
+ strs.each do |str|
+ strs.each do |other|
+ r = str.send(@method, other)
- r.tainted?.should == !r.nil? & other.tainted?
- end
+ r.tainted?.should == !r.nil? & other.tainted?
end
end
end
@@ -470,7 +460,7 @@ describe :string_slice_string, shared: true do
o = mock('x')
o.should_not_receive(:to_str)
- -> { "hello".send(@method, o) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, o) }.should raise_error(TypeError)
end
it "returns a subclass instance when given a subclass instance" do
@@ -503,27 +493,25 @@ describe :string_slice_regexp_group, shared: true do
"hello there".send(@method, /(?<g>h(?<g>.))/, 'g').should == "e"
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self or regexp is tainted" do
- strs = ["hello world"]
- strs += strs.map { |s| s.dup.taint }
+ it "always taints resulting strings when self or regexp is tainted" do
+ strs = ["hello world"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str.send(@method, /(?<hi>hello)/, 'hi').tainted?.should == str.tainted?
+ strs.each do |str|
+ str.send(@method, /(?<hi>hello)/, 'hi').tainted?.should == str.tainted?
- str.send(@method, /(?<g>(.)(.)(.))/, 'g').tainted?.should == str.tainted?
- str.send(@method, /(?<h>.)(.)(.)/, 'h').tainted?.should == str.tainted?
- str.send(@method, /(.)(?<a>.)(.)/, 'a').tainted?.should == str.tainted?
- str.send(@method, /(.)(.)(?<r>.)/, 'r').tainted?.should == str.tainted?
- str.send(@method, /(?<h>.)(?<a>.)(?<r>.)/, 'r').tainted?.should == str.tainted?
+ str.send(@method, /(?<g>(.)(.)(.))/, 'g').tainted?.should == str.tainted?
+ str.send(@method, /(?<h>.)(.)(.)/, 'h').tainted?.should == str.tainted?
+ str.send(@method, /(.)(?<a>.)(.)/, 'a').tainted?.should == str.tainted?
+ str.send(@method, /(.)(.)(?<r>.)/, 'r').tainted?.should == str.tainted?
+ str.send(@method, /(?<h>.)(?<a>.)(?<r>.)/, 'r').tainted?.should == str.tainted?
- tainted_re = /(?<a>.)(?<b>.)(?<c>.)/
- tainted_re.taint
+ tainted_re = /(?<a>.)(?<b>.)(?<c>.)/
+ tainted_re.taint
- str.send(@method, tainted_re, 'a').tainted?.should be_true
- str.send(@method, tainted_re, 'b').tainted?.should be_true
- str.send(@method, tainted_re, 'c').tainted?.should be_true
- end
+ str.send(@method, tainted_re, 'a').tainted?.should be_true
+ str.send(@method, tainted_re, 'b').tainted?.should be_true
+ str.send(@method, tainted_re, 'c').tainted?.should be_true
end
end
@@ -532,19 +520,19 @@ describe :string_slice_regexp_group, shared: true do
end
it "raises an IndexError if there is no capture for the given name" do
- -> do
+ lambda do
"hello there".send(@method, /[aeiou](.)\1/, 'non')
end.should raise_error(IndexError)
end
it "raises a TypeError when the given name is not a String" do
- -> { "hello".send(@method, /(?<q>.)/, mock('x')) }.should raise_error(TypeError)
- -> { "hello".send(@method, /(?<q>.)/, {}) }.should raise_error(TypeError)
- -> { "hello".send(@method, /(?<q>.)/, []) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, /(?<q>.)/, mock('x')) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, /(?<q>.)/, {}) }.should raise_error(TypeError)
+ lambda { "hello".send(@method, /(?<q>.)/, []) }.should raise_error(TypeError)
end
it "raises an IndexError when given the empty String as a group name" do
- -> { "hello".send(@method, /(?<q>)/, '') }.should raise_error(IndexError)
+ lambda { "hello".send(@method, /(?<q>)/, '') }.should raise_error(IndexError)
end
it "returns subclass instances" do
@@ -564,6 +552,6 @@ end
describe :string_slice_symbol, shared: true do
it "raises TypeError" do
- -> { 'hello'.send(@method, :hello) }.should raise_error(TypeError)
+ lambda { 'hello'.send(@method, :hello) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb
index 80e4659102..4854cb7146 100644
--- a/spec/ruby/core/string/shared/succ.rb
+++ b/spec/ruby/core/string/shared/succ.rb
@@ -65,11 +65,9 @@ describe :string_succ, shared: true do
StringSpecs::MyString.new("z").send(@method).should be_an_instance_of(StringSpecs::MyString)
end
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- ["", "a", "z", "Z", "9", "\xFF", "\xFF\xFF"].each do |s|
- s.taint.send(@method).tainted?.should == true
- end
+ it "taints the result if self is tainted" do
+ ["", "a", "z", "Z", "9", "\xFF", "\xFF\xFF"].each do |s|
+ s.taint.send(@method).tainted?.should == true
end
end
end
@@ -83,8 +81,8 @@ describe :string_succ_bang, shared: true do
end
end
- it "raises a #{frozen_error_class} if self is frozen" do
- -> { "".freeze.send(@method) }.should raise_error(frozen_error_class)
- -> { "abcd".freeze.send(@method) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "".freeze.send(@method) }.should raise_error(RuntimeError)
+ lambda { "abcd".freeze.send(@method) }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/shared/to_s.rb b/spec/ruby/core/string/shared/to_s.rb
index 36283be4d0..a5a13e4f26 100644
--- a/spec/ruby/core/string/shared/to_s.rb
+++ b/spec/ruby/core/string/shared/to_s.rb
@@ -11,10 +11,8 @@ describe :string_to_s, shared: true do
s.should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self is tainted" do
- "x".taint.send(@method).tainted?.should == true
- StringSpecs::MyString.new("x").taint.send(@method).tainted?.should == true
- end
+ it "taints the result when self is tainted" do
+ "x".taint.send(@method).tainted?.should == true
+ StringSpecs::MyString.new("x").taint.send(@method).tainted?.should == true
end
end
diff --git a/spec/ruby/core/string/size_spec.rb b/spec/ruby/core/string/size_spec.rb
index 9e1f40c5ae..b3172453ea 100644
--- a/spec/ruby/core/string/size_spec.rb
+++ b/spec/ruby/core/string/size_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "String#size" do
- it_behaves_like :string_length, :size
+ it_behaves_like(:string_length, :size)
end
diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb
index f9f4938af3..8018cc2140 100644
--- a/spec/ruby/core/string/slice_spec.rb
+++ b/spec/ruby/core/string/slice_spec.rb
@@ -1,8 +1,8 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/slice'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/slice.rb', __FILE__)
describe "String#slice" do
it_behaves_like :string_slice, :slice
@@ -53,10 +53,10 @@ describe "String#slice! with index" do
a.should == "hello"
end
- it "raises a #{frozen_error_class} if self is frozen" do
- -> { "hello".freeze.slice!(1) }.should raise_error(frozen_error_class)
- -> { "hello".freeze.slice!(10) }.should raise_error(frozen_error_class)
- -> { "".freeze.slice!(0) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1) }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.slice!(10) }.should raise_error(RuntimeError)
+ lambda { "".freeze.slice!(0) }.should raise_error(RuntimeError)
end
it "calls to_int on index" do
@@ -72,13 +72,15 @@ describe "String#slice! with index" do
"hello".slice!(obj).should == ?e
end
+ with_feature :encoding do
- it "returns the character given by the character index" do
- "hellö there".slice!(1).should == "e"
- "hellö there".slice!(4).should == "ö"
- "hellö there".slice!(6).should == "t"
- end
+ it "returns the character given by the character index" do
+ "hellö there".send(@method, 1).should == "e"
+ "hellö there".send(@method, 4).should == "ö"
+ "hellö there".send(@method, 6).should == "t"
+ end
+ end
end
describe "String#slice! with index, length" do
@@ -94,14 +96,12 @@ describe "String#slice! with index, length" do
a.should == "h"
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self is tainted" do
- str = "hello world"
- str.taint
+ it "always taints resulting strings when self is tainted" do
+ str = "hello world"
+ str.taint
- str.slice!(0, 0).tainted?.should == true
- str.slice!(2, 1).tainted?.should == true
- end
+ str.slice!(0, 0).tainted?.should == true
+ str.slice!(2, 1).tainted?.should == true
end
it "returns nil if the given position is out of self" do
@@ -119,14 +119,14 @@ describe "String#slice! with index, length" do
a.should == "hello"
end
- it "raises a #{frozen_error_class} if self is frozen" do
- -> { "hello".freeze.slice!(1, 2) }.should raise_error(frozen_error_class)
- -> { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class)
- -> { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class)
- -> { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class)
- -> { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class)
- -> { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class)
- -> { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1, 2) }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.slice!(10, 3) }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(RuntimeError)
+ lambda { "hello".freeze.slice!(4, -3) }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.slice!(10, 3) }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(RuntimeError)
+ lambda { "hello".freeze.slice!(4, -3) }.should raise_error(RuntimeError)
end
it "calls to_int on idx and length" do
@@ -148,17 +148,19 @@ describe "String#slice! with index, length" do
s.slice!(0, 4).should be_an_instance_of(StringSpecs::MyString)
end
+ with_feature :encoding do
- it "returns the substring given by the character offsets" do
- "hellö there".slice!(1,0).should == ""
- "hellö there".slice!(1,3).should == "ell"
- "hellö there".slice!(1,6).should == "ellö t"
- "hellö there".slice!(1,9).should == "ellö ther"
- end
+ it "returns the substring given by the character offsets" do
+ "hellö there".send(@method, 1,0).should == ""
+ "hellö there".send(@method, 1,3).should == "ell"
+ "hellö there".send(@method, 1,6).should == "ellö t"
+ "hellö there".send(@method, 1,9).should == "ellö ther"
+ end
- it "treats invalid bytes as single bytes" do
- xE6xCB = [0xE6,0xCB].pack('CC').force_encoding('utf-8')
- "a#{xE6xCB}b".slice!(1, 2).should == xE6xCB
+ it "treats invalid bytes as single bytes" do
+ xE6xCB = [0xE6,0xCB].pack('CC').force_encoding('utf-8')
+ "a#{xE6xCB}b".send(@method, 1, 2).should == xE6xCB
+ end
end
end
@@ -186,14 +188,12 @@ describe "String#slice! Range" do
b.should == "hello"
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self is tainted" do
- str = "hello world"
- str.taint
+ it "always taints resulting strings when self is tainted" do
+ str = "hello world"
+ str.taint
- str.slice!(0..0).tainted?.should == true
- str.slice!(2..3).tainted?.should == true
- end
+ str.slice!(0..0).tainted?.should == true
+ str.slice!(2..3).tainted?.should == true
end
it "returns subclass instances" do
@@ -236,25 +236,27 @@ describe "String#slice! Range" do
a.slice!(range_incl).should == "OO"
end
+ with_feature :encoding do
- it "returns the substring given by the character offsets of the range" do
- "hellö there".slice!(1..1).should == "e"
- "hellö there".slice!(1..3).should == "ell"
- "hellö there".slice!(1...3).should == "el"
- "hellö there".slice!(-4..-2).should == "her"
- "hellö there".slice!(-4...-2).should == "he"
- "hellö there".slice!(5..-1).should == " there"
- "hellö there".slice!(5...-1).should == " ther"
- end
+ it "returns the substring given by the character offsets of the range" do
+ "hellö there".send(@method, 1..1).should == "e"
+ "hellö there".send(@method, 1..3).should == "ell"
+ "hellö there".send(@method, 1...3).should == "el"
+ "hellö there".send(@method, -4..-2).should == "her"
+ "hellö there".send(@method, -4...-2).should == "he"
+ "hellö there".send(@method, 5..-1).should == " there"
+ "hellö there".send(@method, 5...-1).should == " ther"
+ end
+ end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> { "hello".freeze.slice!(1..3) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda { "hello".freeze.slice!(1..3) }.should raise_error(RuntimeError)
end
# see redmine #1551
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
- -> { "hello".freeze.slice!(10..20)}.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
+ lambda { "hello".freeze.slice!(10..20)}.should raise_error(RuntimeError)
end
end
@@ -275,28 +277,26 @@ describe "String#slice! with Regexp" do
s.should == "this is a string"
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self or regexp is tainted" do
- strs = ["hello world"]
- strs += strs.map { |s| s.dup.taint }
+ it "always taints resulting strings when self or regexp is tainted" do
+ strs = ["hello world"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str = str.dup
- str.slice!(//).tainted?.should == str.tainted?
- str.slice!(/hello/).tainted?.should == str.tainted?
+ strs.each do |str|
+ str = str.dup
+ str.slice!(//).tainted?.should == str.tainted?
+ str.slice!(/hello/).tainted?.should == str.tainted?
- tainted_re = /./
- tainted_re.taint
+ tainted_re = /./
+ tainted_re.taint
- str.slice!(tainted_re).tainted?.should == true
- end
+ str.slice!(tainted_re).tainted?.should == true
end
+ end
- it "doesn't taint self when regexp is tainted" do
- s = "hello"
- s.slice!(/./.taint)
- s.tainted?.should == false
- end
+ it "doesn't taint self when regexp is tainted" do
+ s = "hello"
+ s.slice!(/./.taint)
+ s.tainted?.should == false
end
it "returns subclass instances" do
@@ -305,9 +305,11 @@ describe "String#slice! with Regexp" do
s.slice!(/../).should be_an_instance_of(StringSpecs::MyString)
end
- it "returns the matching portion of self with a multi byte character" do
- "hëllo there".slice!(/[ë](.)\1/).should == "ëll"
- "".slice!(//).should == ""
+ with_feature :encoding do
+ it "returns the matching portion of self with a multi byte character" do
+ "hëllo there".send(@method, /[ë](.)\1/).should == "ëll"
+ "".send(@method, //).should == ""
+ end
end
it "sets $~ to MatchData when there is a match and nil when there's none" do
@@ -318,12 +320,12 @@ describe "String#slice! with Regexp" do
$~.should == nil
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
- -> { "this is a string".freeze.slice!(/zzz/) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
+ lambda { "this is a string".freeze.slice!(/zzz/) }.should raise_error(RuntimeError)
end
end
@@ -336,28 +338,26 @@ describe "String#slice! with Regexp, index" do
str.should == "ho here"
end
- ruby_version_is ''...'2.7' do
- it "always taints resulting strings when self or regexp is tainted" do
- strs = ["hello world"]
- strs += strs.map { |s| s.dup.taint }
+ it "always taints resulting strings when self or regexp is tainted" do
+ strs = ["hello world"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str = str.dup
- str.slice!(//, 0).tainted?.should == str.tainted?
- str.slice!(/hello/, 0).tainted?.should == str.tainted?
+ strs.each do |str|
+ str = str.dup
+ str.slice!(//, 0).tainted?.should == str.tainted?
+ str.slice!(/hello/, 0).tainted?.should == str.tainted?
- tainted_re = /(.)(.)(.)/
- tainted_re.taint
+ tainted_re = /(.)(.)(.)/
+ tainted_re.taint
- str.slice!(tainted_re, 1).tainted?.should == true
- end
+ str.slice!(tainted_re, 1).tainted?.should == true
end
+ end
- it "doesn't taint self when regexp is tainted" do
- s = "hello"
- s.slice!(/(.)(.)/.taint, 1)
- s.tainted?.should == false
- end
+ it "doesn't taint self when regexp is tainted" do
+ s = "hello"
+ s.slice!(/(.)(.)/.taint, 1)
+ s.tainted?.should == false
end
it "returns nil if there was no match" do
@@ -389,14 +389,16 @@ describe "String#slice! with Regexp, index" do
s.slice!(/(.)(.)/, 1).should be_an_instance_of(StringSpecs::MyString)
end
- it "returns the encoding aware capture for the given index" do
- "hår".slice!(/(.)(.)(.)/, 0).should == "hår"
- "hår".slice!(/(.)(.)(.)/, 1).should == "h"
- "hår".slice!(/(.)(.)(.)/, 2).should == "å"
- "hår".slice!(/(.)(.)(.)/, 3).should == "r"
- "hår".slice!(/(.)(.)(.)/, -1).should == "r"
- "hår".slice!(/(.)(.)(.)/, -2).should == "å"
- "hår".slice!(/(.)(.)(.)/, -3).should == "h"
+ with_feature :encoding do
+ it "returns the encoding aware capture for the given index" do
+ "hår".send(@method, /(.)(.)(.)/, 0).should == "hår"
+ "hår".send(@method, /(.)(.)(.)/, 1).should == "h"
+ "hår".send(@method, /(.)(.)(.)/, 2).should == "å"
+ "hår".send(@method, /(.)(.)(.)/, 3).should == "r"
+ "hår".send(@method, /(.)(.)(.)/, -1).should == "r"
+ "hår".send(@method, /(.)(.)(.)/, -2).should == "å"
+ "hår".send(@method, /(.)(.)(.)/, -3).should == "h"
+ end
end
it "sets $~ to MatchData when there is a match and nil when there's none" do
@@ -410,10 +412,10 @@ describe "String#slice! with Regexp, index" do
$~.should == nil
end
- it "raises a #{frozen_error_class} if self is frozen" do
- -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class)
- -> { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(frozen_error_class)
- -> { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(RuntimeError)
+ lambda { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(RuntimeError)
+ lambda { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(RuntimeError)
end
end
@@ -424,19 +426,17 @@ describe "String#slice! with String" do
c.should == "he hello"
end
- ruby_version_is ''...'2.7' do
- it "taints resulting strings when other is tainted" do
- strs = ["", "hello world", "hello"]
- strs += strs.map { |s| s.dup.taint }
+ it "taints resulting strings when other is tainted" do
+ strs = ["", "hello world", "hello"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str = str.dup
- strs.each do |other|
- other = other.dup
- r = str.slice!(other)
+ strs.each do |str|
+ str = str.dup
+ strs.each do |other|
+ other = other.dup
+ r = str.slice!(other)
- r.tainted?.should == !r.nil? & other.tainted?
- end
+ r.tainted?.should == !r.nil? & other.tainted?
end
end
end
@@ -458,7 +458,7 @@ describe "String#slice! with String" do
o = mock('x')
o.should_not_receive(:to_str)
- -> { "hello".slice!(o) }.should raise_error(TypeError)
+ lambda { "hello".slice!(o) }.should raise_error(TypeError)
end
it "returns a subclass instance when given a subclass instance" do
@@ -468,9 +468,9 @@ describe "String#slice! with String" do
r.should be_an_instance_of(StringSpecs::MyString)
end
- it "raises a #{frozen_error_class} if self is frozen" do
- -> { "hello hello".freeze.slice!('llo') }.should raise_error(frozen_error_class)
- -> { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class)
- -> { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "hello hello".freeze.slice!('llo') }.should raise_error(RuntimeError)
+ lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(RuntimeError)
+ lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb
index cfb030ad8d..1a4128f828 100644
--- a/spec/ruby/core/string/split_spec.rb
+++ b/spec/ruby/core/string/split_spec.rb
@@ -1,19 +1,21 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#split with String" do
- it "throws an ArgumentError if the pattern is not a valid string" do
- str = 'проверка'
- broken_str = 'проверка'
- broken_str.force_encoding('binary')
- broken_str.chop!
- broken_str.force_encoding('utf-8')
- -> { str.split(broken_str) }.should raise_error(ArgumentError)
- end
+ with_feature :encoding do
+ it "throws an ArgumentError if the pattern is not a valid string" do
+ str = 'проверка'
+ broken_str = 'проверка'
+ broken_str.force_encoding('binary')
+ broken_str.chop!
+ broken_str.force_encoding('utf-8')
+ lambda { str.split(broken_str) }.should raise_error(ArgumentError)
+ end
- it "splits on multibyte characters" do
- "ã‚りãŒã‚ŠãŒã¨ã†".split("ãŒ").should == ["ã‚り", "り", "ã¨ã†"]
+ it "splits on multibyte characters" do
+ "ã‚りãŒã‚ŠãŒã¨ã†".split("ãŒ").should == ["ã‚り", "り", "ã¨ã†"]
+ end
end
it "returns an array of substrings based on splitting on the given string" do
@@ -63,26 +65,25 @@ describe "String#split with String" do
end
it "defaults to $; when string isn't given or nil" do
- suppress_warning do
+ begin
old_fs = $;
- begin
- [",", ":", "", "XY", nil].each do |fs|
- $; = fs
- ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
- expected = str.split(fs || " ")
+ [",", ":", "", "XY", nil].each do |fs|
+ $; = fs
- str.split(nil).should == expected
- str.split.should == expected
+ ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
+ expected = str.split(fs || " ")
- str.split(nil, -1).should == str.split(fs || " ", -1)
- str.split(nil, 0).should == str.split(fs || " ", 0)
- str.split(nil, 2).should == str.split(fs || " ", 2)
- end
+ str.split(nil).should == expected
+ str.split.should == expected
+
+ str.split(nil, -1).should == str.split(fs || " ", -1)
+ str.split(nil, 0).should == str.split(fs || " ", 0)
+ str.split(nil, 2).should == str.split(fs || " ", 2)
end
- ensure
- $; = old_fs
end
+ ensure
+ $; = old_fs
end
end
@@ -165,18 +166,16 @@ describe "String#split with String" do
s.split(':').first.should == 'silly'
end
- ruby_version_is ''...'2.7' do
- it "taints the resulting strings if self is tainted" do
- ["", "x.y.z.", " x y "].each do |str|
- ["", ".", " "].each do |pat|
- [-1, 0, 1, 2].each do |limit|
- str.dup.taint.split(pat).each do |x|
- x.tainted?.should == true
- end
+ it "taints the resulting strings if self is tainted" do
+ ["", "x.y.z.", " x y "].each do |str|
+ ["", ".", " "].each do |pat|
+ [-1, 0, 1, 2].each do |limit|
+ str.dup.taint.split(pat).each do |x|
+ x.tainted?.should == true
+ end
- str.split(pat.dup.taint).each do |x|
- x.tainted?.should == false
- end
+ str.split(pat.dup.taint).each do |x|
+ x.tainted?.should == false
end
end
end
@@ -239,26 +238,25 @@ describe "String#split with Regexp" do
end
it "defaults to $; when regexp isn't given or nil" do
- suppress_warning do
+ begin
old_fs = $;
- begin
- [/,/, /:/, //, /XY/, /./].each do |fs|
- $; = fs
- ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
- expected = str.split(fs)
+ [/,/, /:/, //, /XY/, /./].each do |fs|
+ $; = fs
- str.split(nil).should == expected
- str.split.should == expected
+ ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
+ expected = str.split(fs)
- str.split(nil, -1).should == str.split(fs, -1)
- str.split(nil, 0).should == str.split(fs, 0)
- str.split(nil, 2).should == str.split(fs, 2)
- end
+ str.split(nil).should == expected
+ str.split.should == expected
+
+ str.split(nil, -1).should == str.split(fs, -1)
+ str.split(nil, 0).should == str.split(fs, 0)
+ str.split(nil, 2).should == str.split(fs, 2)
end
- ensure
- $; = old_fs
end
+ ensure
+ $; = old_fs
end
end
@@ -318,8 +316,8 @@ describe "String#split with Regexp" do
end
it "returns a type error if limit can't be converted to an integer" do
- -> {"1.2.3.4".split(".", "three")}.should raise_error(TypeError)
- -> {"1.2.3.4".split(".", nil) }.should raise_error(TypeError)
+ lambda {"1.2.3.4".split(".", "three")}.should raise_error(TypeError)
+ lambda {"1.2.3.4".split(".", nil) }.should raise_error(TypeError)
end
it "doesn't set $~" do
@@ -357,31 +355,29 @@ describe "String#split with Regexp" do
s.split(/:/).first.should == 'silly'
end
- ruby_version_is ''...'2.7' do
- it "taints the resulting strings if self is tainted" do
- ["", "x:y:z:", " x y "].each do |str|
- [//, /:/, /\s+/].each do |pat|
- [-1, 0, 1, 2].each do |limit|
- str.dup.taint.split(pat, limit).each do |x|
- # See the spec below for why the conditional is here
- x.tainted?.should be_true unless x.empty?
- end
+ it "taints the resulting strings if self is tainted" do
+ ["", "x:y:z:", " x y "].each do |str|
+ [//, /:/, /\s+/].each do |pat|
+ [-1, 0, 1, 2].each do |limit|
+ str.dup.taint.split(pat, limit).each do |x|
+ # See the spec below for why the conditional is here
+ x.tainted?.should be_true unless x.empty?
end
end
end
end
+ end
- it "taints an empty string if self is tainted" do
- ":".taint.split(//, -1).last.tainted?.should be_true
- end
+ it "taints an empty string if self is tainted" do
+ ":".taint.split(//, -1).last.tainted?.should be_true
+ end
- it "doesn't taints the resulting strings if the Regexp is tainted" do
- ["", "x:y:z:", " x y "].each do |str|
- [//, /:/, /\s+/].each do |pat|
- [-1, 0, 1, 2].each do |limit|
- str.split(pat.dup.taint, limit).each do |x|
- x.tainted?.should be_false
- end
+ it "doesn't taints the resulting strings if the Regexp is tainted" do
+ ["", "x:y:z:", " x y "].each do |str|
+ [//, /:/, /\s+/].each do |pat|
+ [-1, 0, 1, 2].each do |limit|
+ str.split(pat.dup.taint, limit).each do |x|
+ x.tainted?.should be_false
end
end
end
@@ -404,30 +400,6 @@ describe "String#split with Regexp" do
broken_str.force_encoding('binary')
broken_str.chop!
broken_str.force_encoding('utf-8')
- ->{ broken_str.split(/\r\n|\r|\n/) }.should raise_error(ArgumentError)
- end
-
- ruby_version_is "2.6" do
- it "yields each split substrings if a block is given" do
- a = []
- returned_object = "chunky bacon".split(" ") { |str| a << str.capitalize }
-
- returned_object.should == "chunky bacon"
- a.should == ["Chunky", "Bacon"]
- end
-
- describe "for a String subclass" do
- it "yields instances of the same subclass" do
- a = []
- StringSpecs::MyString.new("a|b").split("|") { |str| a << str }
- first, last = a
-
- first.should be_an_instance_of(StringSpecs::MyString)
- first.should == "a"
-
- last.should be_an_instance_of(StringSpecs::MyString)
- last.should == "b"
- end
- end
+ lambda{ broken_str.split(/\r\n|\r|\n/) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/string/squeeze_spec.rb b/spec/ruby/core/string/squeeze_spec.rb
index 2e96684b9d..d6b3fb6de6 100644
--- a/spec/ruby/core/string/squeeze_spec.rb
+++ b/spec/ruby/core/string/squeeze_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
# TODO: rewrite all these specs
@@ -50,18 +50,16 @@ describe "String#squeeze" do
it "raises an ArgumentError when the parameter is out of sequence" do
s = "--subbookkeeper--"
- -> { s.squeeze("e-b") }.should raise_error(ArgumentError)
- -> { s.squeeze("^e-b") }.should raise_error(ArgumentError)
+ lambda { s.squeeze("e-b") }.should raise_error(ArgumentError)
+ lambda { s.squeeze("^e-b") }.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self is tainted" do
- "hello".taint.squeeze("e").tainted?.should == true
- "hello".taint.squeeze("a-z").tainted?.should == true
+ it "taints the result when self is tainted" do
+ "hello".taint.squeeze("e").tainted?.should == true
+ "hello".taint.squeeze("a-z").tainted?.should == true
- "hello".squeeze("e".taint).tainted?.should == false
- "hello".squeeze("l".taint).tainted?.should == false
- end
+ "hello".squeeze("e".taint).tainted?.should == false
+ "hello".squeeze("l".taint).tainted?.should == false
end
it "tries to convert each set arg to a string using to_str" do
@@ -75,9 +73,9 @@ describe "String#squeeze" do
end
it "raises a TypeError when one set arg can't be converted to a string" do
- -> { "hello world".squeeze([]) }.should raise_error(TypeError)
- -> { "hello world".squeeze(Object.new)}.should raise_error(TypeError)
- -> { "hello world".squeeze(mock('x')) }.should raise_error(TypeError)
+ lambda { "hello world".squeeze([]) }.should raise_error(TypeError)
+ lambda { "hello world".squeeze(Object.new)}.should raise_error(TypeError)
+ lambda { "hello world".squeeze(mock('x')) }.should raise_error(TypeError)
end
it "returns subclass instances when called on a subclass" do
@@ -101,15 +99,15 @@ describe "String#squeeze!" do
it "raises an ArgumentError when the parameter is out of sequence" do
s = "--subbookkeeper--"
- -> { s.squeeze!("e-b") }.should raise_error(ArgumentError)
- -> { s.squeeze!("^e-b") }.should raise_error(ArgumentError)
+ lambda { s.squeeze!("e-b") }.should raise_error(ArgumentError)
+ lambda { s.squeeze!("^e-b") }.should raise_error(ArgumentError)
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
a = "yellow moon"
a.freeze
- -> { a.squeeze!("") }.should raise_error(frozen_error_class)
- -> { a.squeeze! }.should raise_error(frozen_error_class)
+ lambda { a.squeeze!("") }.should raise_error(RuntimeError)
+ lambda { a.squeeze! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/start_with_spec.rb b/spec/ruby/core/string/start_with_spec.rb
index 1000db180c..1b27fdaed7 100644
--- a/spec/ruby/core/string/start_with_spec.rb
+++ b/spec/ruby/core/string/start_with_spec.rb
@@ -1,76 +1,45 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#start_with?" do
it "returns true only if beginning match" do
s = "hello"
- s.should.start_with?('h')
- s.should.start_with?('hel')
- s.should_not.start_with?('el')
+ s.start_with?('h').should be_true
+ s.start_with?('hel').should be_true
+ s.start_with?('el').should be_false
end
it "returns true only if any beginning match" do
- "hello".should.start_with?('x', 'y', 'he', 'z')
+ "hello".start_with?('x', 'y', 'he', 'z').should be_true
end
it "returns true if the search string is empty" do
- "hello".should.start_with?("")
- "".should.start_with?("")
+ "hello".start_with?("").should be_true
+ "".start_with?("").should be_true
end
it "converts its argument using :to_str" do
s = "hello"
find = mock('h')
find.should_receive(:to_str).and_return("h")
- s.should.start_with?(find)
+ s.start_with?(find).should be_true
end
it "ignores arguments not convertible to string" do
- "hello".should_not.start_with?()
- -> { "hello".start_with?(1) }.should raise_error(TypeError)
- -> { "hello".start_with?(["h"]) }.should raise_error(TypeError)
- -> { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError)
+ "hello".start_with?().should be_false
+ lambda { "hello".start_with?(1) }.should raise_error(TypeError)
+ lambda { "hello".start_with?(["h"]) }.should raise_error(TypeError)
+ lambda { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError)
end
it "uses only the needed arguments" do
find = mock('h')
find.should_not_receive(:to_str)
- "hello".should.start_with?("h",find)
+ "hello".start_with?("h",find).should be_true
end
it "works for multibyte strings" do
- "céréale".should.start_with?("cér")
- end
-
- ruby_version_is "2.5" do
- it "supports regexps" do
- regexp = /[h1]/
- "hello".should.start_with?(regexp)
- "1337".should.start_with?(regexp)
- "foxes are 1337".should_not.start_with?(regexp)
- "chunky\n12bacon".should_not.start_with?(/12/)
- end
-
- it "supports regexps with ^ and $ modifiers" do
- regexp1 = /^\d{2}/
- regexp2 = /\d{2}$/
- "12test".should.start_with?(regexp1)
- "test12".should_not.start_with?(regexp1)
- "12test".should_not.start_with?(regexp2)
- "test12".should_not.start_with?(regexp2)
- end
-
- it "sets Regexp.last_match if it returns true" do
- regexp = /test-(\d+)/
- "test-1337".start_with?(regexp).should be_true
- Regexp.last_match.should_not be_nil
- Regexp.last_match[1].should == "1337"
- $1.should == "1337"
-
- "test-asdf".start_with?(regexp).should be_false
- Regexp.last_match.should be_nil
- $1.should be_nil
- end
+ "céréale".start_with?("cér").should be_true
end
end
diff --git a/spec/ruby/core/string/string_spec.rb b/spec/ruby/core/string/string_spec.rb
index cdefbbecbd..37a858acae 100644
--- a/spec/ruby/core/string/string_spec.rb
+++ b/spec/ruby/core/string/string_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String" do
it "includes Comparable" do
diff --git a/spec/ruby/core/string/strip_spec.rb b/spec/ruby/core/string/strip_spec.rb
index 728b3104fa..747fd8cdf2 100644
--- a/spec/ruby/core/string/strip_spec.rb
+++ b/spec/ruby/core/string/strip_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#strip" do
it "returns a new string with leading and trailing whitespace removed" do
@@ -13,12 +13,10 @@ describe "String#strip" do
" \x00 goodbye \x00 ".strip.should == "\x00 goodbye"
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self is tainted" do
- "".taint.strip.tainted?.should == true
- "ok".taint.strip.tainted?.should == true
- " ok ".taint.strip.tainted?.should == true
- end
+ it "taints the result when self is tainted" do
+ "".taint.strip.tainted?.should == true
+ "ok".taint.strip.tainted?.should == true
+ " ok ".taint.strip.tainted?.should == true
end
end
@@ -50,13 +48,13 @@ describe "String#strip!" do
a.should == "\x00 goodbye"
end
- it "raises a #{frozen_error_class} on a frozen instance that is modified" do
- -> { " hello ".freeze.strip! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that is modified" do
+ lambda { " hello ".freeze.strip! }.should raise_error(RuntimeError)
end
# see #1552
- it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
- -> {"hello".freeze.strip! }.should raise_error(frozen_error_class)
- -> {"".freeze.strip! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError on a frozen instance that would not be modified" do
+ lambda {"hello".freeze.strip! }.should raise_error(RuntimeError)
+ lambda {"".freeze.strip! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/sub_spec.rb b/spec/ruby/core/string/sub_spec.rb
index 2a859c2fc7..deaa7e27f1 100644
--- a/spec/ruby/core/string/sub_spec.rb
+++ b/spec/ruby/core/string/sub_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#sub with pattern, replacement" do
it "returns a copy of self when no modification is made" do
@@ -137,26 +137,24 @@ describe "String#sub with pattern, replacement" do
"hello".sub(/./, 'hah\\').should == 'hah\\ello'
end
- ruby_version_is ''...'2.7' do
- it "taints the result if the original string or replacement is tainted" do
- hello = "hello"
- hello_t = "hello"
- a = "a"
- a_t = "a"
- empty = ""
- empty_t = ""
+ it "taints the result if the original string or replacement is tainted" do
+ hello = "hello"
+ hello_t = "hello"
+ a = "a"
+ a_t = "a"
+ empty = ""
+ empty_t = ""
- hello_t.taint; a_t.taint; empty_t.taint
+ hello_t.taint; a_t.taint; empty_t.taint
- hello_t.sub(/./, a).tainted?.should == true
- hello_t.sub(/./, empty).tainted?.should == true
+ hello_t.sub(/./, a).tainted?.should == true
+ hello_t.sub(/./, empty).tainted?.should == true
- hello.sub(/./, a_t).tainted?.should == true
- hello.sub(/./, empty_t).tainted?.should == true
- hello.sub(//, empty_t).tainted?.should == true
+ hello.sub(/./, a_t).tainted?.should == true
+ hello.sub(/./, empty_t).tainted?.should == true
+ hello.sub(//, empty_t).tainted?.should == true
- hello.sub(//.taint, "foo").tainted?.should == false
- end
+ hello.sub(//.taint, "foo").tainted?.should == false
end
it "tries to convert pattern to a string using to_str" do
@@ -168,16 +166,16 @@ describe "String#sub with pattern, replacement" do
not_supported_on :opal do
it "raises a TypeError when pattern is a Symbol" do
- -> { "hello".sub(:woot, "x") }.should raise_error(TypeError)
+ lambda { "hello".sub(:woot, "x") }.should raise_error(TypeError)
end
end
it "raises a TypeError when pattern is an Array" do
- -> { "hello".sub([], "x") }.should raise_error(TypeError)
+ lambda { "hello".sub([], "x") }.should raise_error(TypeError)
end
it "raises a TypeError when pattern can't be converted to a string" do
- -> { "hello".sub(Object.new, nil) }.should raise_error(TypeError)
+ lambda { "hello".sub(Object.new, nil) }.should raise_error(TypeError)
end
it "tries to convert replacement to a string using to_str" do
@@ -188,8 +186,8 @@ describe "String#sub with pattern, replacement" do
end
it "raises a TypeError when replacement can't be converted to a string" do
- -> { "hello".sub(/[aeiou]/, []) }.should raise_error(TypeError)
- -> { "hello".sub(/[aeiou]/, 99) }.should raise_error(TypeError)
+ lambda { "hello".sub(/[aeiou]/, []) }.should raise_error(TypeError)
+ lambda { "hello".sub(/[aeiou]/, 99) }.should raise_error(TypeError)
end
it "returns subclass instances when called on a subclass" do
@@ -287,26 +285,24 @@ describe "String#sub with pattern and block" do
"hello".sub(/.+/) { obj }.should == "ok"
end
- ruby_version_is ''...'2.7' do
- it "taints the result if the original string or replacement is tainted" do
- hello = "hello"
- hello_t = "hello"
- a = "a"
- a_t = "a"
- empty = ""
- empty_t = ""
+ it "taints the result if the original string or replacement is tainted" do
+ hello = "hello"
+ hello_t = "hello"
+ a = "a"
+ a_t = "a"
+ empty = ""
+ empty_t = ""
- hello_t.taint; a_t.taint; empty_t.taint
+ hello_t.taint; a_t.taint; empty_t.taint
- hello_t.sub(/./) { a }.tainted?.should == true
- hello_t.sub(/./) { empty }.tainted?.should == true
+ hello_t.sub(/./) { a }.tainted?.should == true
+ hello_t.sub(/./) { empty }.tainted?.should == true
- hello.sub(/./) { a_t }.tainted?.should == true
- hello.sub(/./) { empty_t }.tainted?.should == true
- hello.sub(//) { empty_t }.tainted?.should == true
+ hello.sub(/./) { a_t }.tainted?.should == true
+ hello.sub(/./) { empty_t }.tainted?.should == true
+ hello.sub(//) { empty_t }.tainted?.should == true
- hello.sub(//.taint) { "foo" }.tainted?.should == false
- end
+ hello.sub(//.taint) { "foo" }.tainted?.should == false
end
end
@@ -317,12 +313,10 @@ describe "String#sub! with pattern, replacement" do
a.should == "h*llo"
end
- ruby_version_is ''...'2.7' do
- it "taints self if replacement is tainted" do
- a = "hello"
- a.sub!(/./.taint, "foo").tainted?.should == false
- a.sub!(/./, "foo".taint).tainted?.should == true
- end
+ it "taints self if replacement is tainted" do
+ a = "hello"
+ a.sub!(/./.taint, "foo").tainted?.should == false
+ a.sub!(/./, "foo".taint).tainted?.should == true
end
it "returns nil if no modifications were made" do
@@ -332,13 +326,13 @@ describe "String#sub! with pattern, replacement" do
a.should == "hello"
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
s = "hello"
s.freeze
- -> { s.sub!(/ROAR/, "x") }.should raise_error(frozen_error_class)
- -> { s.sub!(/e/, "e") }.should raise_error(frozen_error_class)
- -> { s.sub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class)
+ lambda { s.sub!(/ROAR/, "x") }.should raise_error(RuntimeError)
+ lambda { s.sub!(/e/, "e") }.should raise_error(RuntimeError)
+ lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
end
end
@@ -367,12 +361,10 @@ describe "String#sub! with pattern and block" do
offsets.should == [[1, 2]]
end
- ruby_version_is ''...'2.7' do
- it "taints self if block's result is tainted" do
- a = "hello"
- a.sub!(/./.taint) { "foo" }.tainted?.should == false
- a.sub!(/./) { "foo".taint }.tainted?.should == true
- end
+ it "taints self if block's result is tainted" do
+ a = "hello"
+ a.sub!(/./.taint) { "foo" }.tainted?.should == false
+ a.sub!(/./) { "foo".taint }.tainted?.should == true
end
it "returns nil if no modifications were made" do
@@ -384,16 +376,16 @@ describe "String#sub! with pattern and block" do
it "raises a RuntimeError if the string is modified while substituting" do
str = "hello"
- -> { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError)
+ lambda { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
s = "hello"
s.freeze
- -> { s.sub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class)
- -> { s.sub!(/e/) { "e" } }.should raise_error(frozen_error_class)
- -> { s.sub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class)
+ lambda { s.sub!(/ROAR/) { "x" } }.should raise_error(RuntimeError)
+ lambda { s.sub!(/e/) { "e" } }.should raise_error(RuntimeError)
+ lambda { s.sub!(/[aeiou]/) { '*' } }.should raise_error(RuntimeError)
end
end
@@ -436,7 +428,7 @@ describe "String#sub with pattern and Hash" do
it "uses the hash's value set from default_proc for missing keys" do
hsh = {}
- hsh.default_proc = -> k, v { 'lamb' }
+ hsh.default_proc = lambda { |k,v| 'lamb' }
"food!".sub(/./, hsh).should == "lambood!"
end
@@ -460,26 +452,24 @@ describe "String#sub with pattern and Hash" do
"hello".sub(/(.+)/, 'hello' => repl ).should == repl
end
- ruby_version_is ''...'2.7' do
- it "untrusts the result if the original string is untrusted" do
- str = "Ghana".untrust
- str.sub(/[Aa]na/, 'ana' => '').untrusted?.should be_true
- end
+ it "untrusts the result if the original string is untrusted" do
+ str = "Ghana".untrust
+ str.sub(/[Aa]na/, 'ana' => '').untrusted?.should be_true
+ end
- it "untrusts the result if a hash value is untrusted" do
- str = "Ghana"
- str.sub(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
- end
+ it "untrusts the result if a hash value is untrusted" do
+ str = "Ghana"
+ str.sub(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
+ end
- it "taints the result if the original string is tainted" do
- str = "Ghana".taint
- str.sub(/[Aa]na/, 'ana' => '').tainted?.should be_true
- end
+ it "taints the result if the original string is tainted" do
+ str = "Ghana".taint
+ str.sub(/[Aa]na/, 'ana' => '').tainted?.should be_true
+ end
- it "taints the result if a hash value is tainted" do
- str = "Ghana"
- str.sub(/a$/, 'a' => 'di'.taint).tainted?.should be_true
- end
+ it "taints the result if a hash value is tainted" do
+ str = "Ghana"
+ str.sub(/a$/, 'a' => 'di'.taint).tainted?.should be_true
end
end
@@ -523,7 +513,7 @@ describe "String#sub! with pattern and Hash" do
it "uses the hash's value set from default_proc for missing keys" do
hsh = {}
- hsh.default_proc = -> k, v { 'lamb' }
+ hsh.default_proc = lambda { |k,v| 'lamb' }
"food!".sub!(/./, hsh).should == "lambood!"
end
@@ -547,37 +537,35 @@ describe "String#sub! with pattern and Hash" do
"hello".sub!(/(.+)/, 'hello' => repl ).should == repl
end
- ruby_version_is ''...'2.7' do
- it "keeps untrusted state" do
- str = "Ghana".untrust
- str.sub!(/[Aa]na/, 'ana' => '').untrusted?.should be_true
- end
+ it "keeps untrusted state" do
+ str = "Ghana".untrust
+ str.sub!(/[Aa]na/, 'ana' => '').untrusted?.should be_true
+ end
- it "untrusts self if a hash value is untrusted" do
- str = "Ghana"
- str.sub!(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
- end
+ it "untrusts self if a hash value is untrusted" do
+ str = "Ghana"
+ str.sub!(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true
+ end
- it "keeps tainted state" do
- str = "Ghana".taint
- str.sub!(/[Aa]na/, 'ana' => '').tainted?.should be_true
- end
+ it "keeps tainted state" do
+ str = "Ghana".taint
+ str.sub!(/[Aa]na/, 'ana' => '').tainted?.should be_true
+ end
- it "taints self if a hash value is tainted" do
- str = "Ghana"
- str.sub!(/a$/, 'a' => 'di'.taint).tainted?.should be_true
- end
+ it "taints self if a hash value is tainted" do
+ str = "Ghana"
+ str.sub!(/a$/, 'a' => 'di'.taint).tainted?.should be_true
end
end
describe "String#sub with pattern and without replacement and block" do
it "raises a ArgumentError" do
- -> { "abca".sub(/a/) }.should raise_error(ArgumentError)
+ lambda { "abca".sub(/a/) }.should raise_error(ArgumentError)
end
end
describe "String#sub! with pattern and without replacement and block" do
it "raises a ArgumentError" do
- -> { "abca".sub!(/a/) }.should raise_error(ArgumentError)
+ lambda { "abca".sub!(/a/) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/string/succ_spec.rb b/spec/ruby/core/string/succ_spec.rb
index 65047e0aa2..311453702d 100644
--- a/spec/ruby/core/string/succ_spec.rb
+++ b/spec/ruby/core/string/succ_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/succ'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/succ.rb', __FILE__)
describe "String#succ" do
- it_behaves_like :string_succ, :succ
+ it_behaves_like(:string_succ, :succ)
end
describe "String#succ!" do
- it_behaves_like :string_succ_bang, :"succ!"
+ it_behaves_like(:string_succ_bang, :"succ!")
end
diff --git a/spec/ruby/core/string/sum_spec.rb b/spec/ruby/core/string/sum_spec.rb
index c283b7c254..2d68668f49 100644
--- a/spec/ruby/core/string/sum_spec.rb
+++ b/spec/ruby/core/string/sum_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#sum" do
it "returns a basic n-bit checksum of the characters in self" do
diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb
index c1a1608a81..c2b583acab 100644
--- a/spec/ruby/core/string/swapcase_spec.rb
+++ b/spec/ruby/core/string/swapcase_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#swapcase" do
it "returns a new string with all uppercase chars from self converted to lowercase and vice versa" do
@@ -9,70 +9,25 @@ describe "String#swapcase" do
"+++---111222???".swapcase.should == "+++---111222???"
end
- ruby_version_is ''...'2.7' do
- it "taints resulting string when self is tainted" do
- "".taint.swapcase.tainted?.should == true
- "hello".taint.swapcase.tainted?.should == true
- end
- end
-
- describe "full Unicode case mapping" do
- it "works for all of Unicode with no option" do
- "äÖü".swapcase.should == "ÄöÜ"
- end
-
- it "updates string metadata" do
- swapcased = "Aßet".swapcase
-
- swapcased.should == "aSSET"
- swapcased.size.should == 5
- swapcased.bytesize.should == 5
- swapcased.ascii_only?.should be_true
- end
- end
-
- describe "ASCII-only case mapping" do
- it "does not swapcase non-ASCII characters" do
- "aßet".swapcase(:ascii).should == "AßET"
- end
+ it "taints resulting string when self is tainted" do
+ "".taint.swapcase.tainted?.should == true
+ "hello".taint.swapcase.tainted?.should == true
end
- describe "full Unicode case mapping adapted for Turkic languages" do
- it "swaps case of ASCII characters according to Turkic semantics" do
- "aiS".swapcase(:turkic).should == "Aİs"
- end
-
- it "allows Lithuanian as an extra option" do
- "aiS".swapcase(:turkic, :lithuanian).should == "Aİs"
- end
-
- it "does not allow any other additional option" do
- -> { "aiS".swapcase(:turkic, :ascii) }.should raise_error(ArgumentError)
+ ruby_version_is ''...'2.4' do
+ it "is locale insensitive (only upcases a-z and only downcases A-Z)" do
+ "ÄÖÜ".swapcase.should == "ÄÖÜ"
+ "ärger".swapcase.should == "äRGER"
+ "BÄR".swapcase.should == "bÄr"
end
end
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- "Iß".swapcase(:lithuanian).should == "iSS"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- "iS".swapcase(:lithuanian, :turkic).should == "İs"
- end
-
- it "does not allow any other additional option" do
- -> { "aiS".swapcase(:lithuanian, :ascii) }.should raise_error(ArgumentError)
+ ruby_version_is '2.4' do
+ it "works for all of Unicode" do
+ "äÖü".swapcase.should == "ÄöÜ"
end
end
- it "does not allow the :fold option for upcasing" do
- -> { "abc".swapcase(:fold) }.should raise_error(ArgumentError)
- end
-
- it "does not allow invalid options" do
- -> { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError)
- end
-
it "returns subclass instances when called on a subclass" do
StringSpecs::MyString.new("").swapcase.should be_an_instance_of(StringSpecs::MyString)
StringSpecs::MyString.new("hello").swapcase.should be_an_instance_of(StringSpecs::MyString)
@@ -86,74 +41,12 @@ describe "String#swapcase!" do
a.should == "CyBeR_pUnK11"
end
- describe "full Unicode case mapping" do
- it "modifies self in place for all of Unicode with no option" do
+ ruby_version_is '2.4' do
+ it "modifies self in place for all of Unicode" do
a = "äÖü"
- a.swapcase!
+ a.swapcase!.should equal(a)
a.should == "ÄöÜ"
end
-
- it "updates string metadata" do
- swapcased = "Aßet"
- swapcased.swapcase!
-
- swapcased.should == "aSSET"
- swapcased.size.should == 5
- swapcased.bytesize.should == 5
- swapcased.ascii_only?.should be_true
- end
- end
-
- describe "modifies self in place for ASCII-only case mapping" do
- it "does not swapcase non-ASCII characters" do
- a = "aßet"
- a.swapcase!(:ascii)
- a.should == "AßET"
- end
- end
-
- describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do
- it "swaps case of ASCII characters according to Turkic semantics" do
- a = "aiS"
- a.swapcase!(:turkic)
- a.should == "Aİs"
- end
-
- it "allows Lithuanian as an extra option" do
- a = "aiS"
- a.swapcase!(:turkic, :lithuanian)
- a.should == "Aİs"
- end
-
- it "does not allow any other additional option" do
- -> { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- a = "Iß"
- a.swapcase!(:lithuanian)
- a.should == "iSS"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- a = "iS"
- a.swapcase!(:lithuanian, :turkic)
- a.should == "İs"
- end
-
- it "does not allow any other additional option" do
- -> { a = "aiS"; a.swapcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- it "does not allow the :fold option for upcasing" do
- -> { a = "abc"; a.swapcase!(:fold) }.should raise_error(ArgumentError)
- end
-
- it "does not allow invalid options" do
- -> { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError)
end
it "returns nil if no modifications were made" do
@@ -164,10 +57,10 @@ describe "String#swapcase!" do
"".swapcase!.should == nil
end
- it "raises a #{frozen_error_class} when self is frozen" do
+ it "raises a RuntimeError when self is frozen" do
["", "hello"].each do |a|
a.freeze
- -> { a.swapcase! }.should raise_error(frozen_error_class)
+ lambda { a.swapcase! }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/string/to_c_spec.rb b/spec/ruby/core/string/to_c_spec.rb
index 9c84b14f4d..da353e18d5 100644
--- a/spec/ruby/core/string/to_c_spec.rb
+++ b/spec/ruby/core/string/to_c_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#to_c" do
it "returns a Complex object" do
diff --git a/spec/ruby/core/string/to_f_spec.rb b/spec/ruby/core/string/to_f_spec.rb
index cf64ecfc5d..8454651ab2 100644
--- a/spec/ruby/core/string/to_f_spec.rb
+++ b/spec/ruby/core/string/to_f_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
# src.scan(/[+-]?[\d_]+\.[\d_]+(e[+-]?[\d_]+)?\b|[+-]?[\d_]+e[+-]?[\d_]+\b/i)
@@ -12,7 +12,6 @@ describe "String#to_f" do
".5".to_f.should == 0.5
".5e1".to_f.should == 5.0
- "5.".to_f.should == 5.0
"5e".to_f.should == 5.0
"5E".to_f.should == 5.0
end
diff --git a/spec/ruby/core/string/to_i_spec.rb b/spec/ruby/core/string/to_i_spec.rb
index a37be47778..be0f67a46a 100644
--- a/spec/ruby/core/string/to_i_spec.rb
+++ b/spec/ruby/core/string/to_i_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#to_i" do
it "returns 0 for strings with leading underscores" do
@@ -126,9 +126,9 @@ describe "String#to_i" do
end
it "raises an ArgumentError for illegal bases (1, < 0 or > 36)" do
- -> { "".to_i(1) }.should raise_error(ArgumentError)
- -> { "".to_i(-1) }.should raise_error(ArgumentError)
- -> { "".to_i(37) }.should raise_error(ArgumentError)
+ lambda { "".to_i(1) }.should raise_error(ArgumentError)
+ lambda { "".to_i(-1) }.should raise_error(ArgumentError)
+ lambda { "".to_i(37) }.should raise_error(ArgumentError)
end
it "returns a Fixnum for long strings with trailing spaces" do
diff --git a/spec/ruby/core/string/to_r_spec.rb b/spec/ruby/core/string/to_r_spec.rb
index 7e1d635d3b..7fa16f6f49 100644
--- a/spec/ruby/core/string/to_r_spec.rb
+++ b/spec/ruby/core/string/to_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#to_r" do
it "returns a Rational object" do
@@ -29,7 +29,7 @@ describe "String#to_r" do
"a1765, ".to_r.should_not == Rational(1765, 1)
end
- it "treats leading hyphen as minus signs" do
+ it "treats leading hypens as minus signs" do
"-20".to_r.should == Rational(-20, 1)
end
diff --git a/spec/ruby/core/string/to_s_spec.rb b/spec/ruby/core/string/to_s_spec.rb
index e5872745a8..b483b1b138 100644
--- a/spec/ruby/core/string/to_s_spec.rb
+++ b/spec/ruby/core/string/to_s_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/to_s.rb', __FILE__)
describe "String#to_s" do
- it_behaves_like :string_to_s, :to_s
+ it_behaves_like(:string_to_s, :to_s)
end
diff --git a/spec/ruby/core/string/to_str_spec.rb b/spec/ruby/core/string/to_str_spec.rb
index e24262a7ae..fb1260a687 100644
--- a/spec/ruby/core/string/to_str_spec.rb
+++ b/spec/ruby/core/string/to_str_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/to_s.rb', __FILE__)
describe "String#to_str" do
- it_behaves_like :string_to_s, :to_str
+ it_behaves_like(:string_to_s, :to_str)
end
diff --git a/spec/ruby/core/string/to_sym_spec.rb b/spec/ruby/core/string/to_sym_spec.rb
index f9135211ce..7659f266cd 100644
--- a/spec/ruby/core/string/to_sym_spec.rb
+++ b/spec/ruby/core/string/to_sym_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_sym'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
+require File.expand_path('../shared/to_sym.rb', __FILE__)
describe "String#to_sym" do
- it_behaves_like :string_to_sym, :to_sym
+ it_behaves_like(:string_to_sym, :to_sym)
end
diff --git a/spec/ruby/core/string/tr_s_spec.rb b/spec/ruby/core/string/tr_s_spec.rb
index a05e421e99..ea2ffa71b9 100644
--- a/spec/ruby/core/string/tr_s_spec.rb
+++ b/spec/ruby/core/string/tr_s_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#tr_s" do
it "returns a string processed according to tr with newly duplicate characters removed" do
@@ -49,59 +49,59 @@ describe "String#tr_s" do
StringSpecs::MyString.new("hello").tr_s("e", "a").should be_an_instance_of(StringSpecs::MyString)
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self is tainted" do
- ["h", "hello"].each do |str|
- tainted_str = str.dup.taint
+ it "taints the result when self is tainted" do
+ ["h", "hello"].each do |str|
+ tainted_str = str.dup.taint
- tainted_str.tr_s("e", "a").tainted?.should == true
+ tainted_str.tr_s("e", "a").tainted?.should == true
- str.tr_s("e".taint, "a").tainted?.should == false
- str.tr_s("e", "a".taint).tainted?.should == false
- end
+ str.tr_s("e".taint, "a").tainted?.should == false
+ str.tr_s("e", "a".taint).tainted?.should == false
end
end
- # http://redmine.ruby-lang.org/issues/show/1839
- it "can replace a 7-bit ASCII character with a multibyte one" do
- a = "uber"
- a.encoding.should == Encoding::UTF_8
- b = a.tr_s("u","ü")
- b.should == "über"
- b.encoding.should == Encoding::UTF_8
- end
+ with_feature :encoding do
+ # http://redmine.ruby-lang.org/issues/show/1839
+ it "can replace a 7-bit ASCII character with a multibyte one" do
+ a = "uber"
+ a.encoding.should == Encoding::UTF_8
+ b = a.tr_s("u","ü")
+ b.should == "über"
+ b.encoding.should == Encoding::UTF_8
+ end
- it "can replace multiple 7-bit ASCII characters with a multibyte one" do
- a = "uuuber"
- a.encoding.should == Encoding::UTF_8
- b = a.tr_s("u","ü")
- b.should == "über"
- b.encoding.should == Encoding::UTF_8
- end
+ it "can replace multiple 7-bit ASCII characters with a multibyte one" do
+ a = "uuuber"
+ a.encoding.should == Encoding::UTF_8
+ b = a.tr_s("u","ü")
+ b.should == "über"
+ b.encoding.should == Encoding::UTF_8
+ end
- it "can replace a multibyte character with a single byte one" do
- a = "über"
- a.encoding.should == Encoding::UTF_8
- b = a.tr_s("ü","u")
- b.should == "uber"
- b.encoding.should == Encoding::UTF_8
- end
+ it "can replace a multibyte character with a single byte one" do
+ a = "über"
+ a.encoding.should == Encoding::UTF_8
+ b = a.tr_s("ü","u")
+ b.should == "uber"
+ b.encoding.should == Encoding::UTF_8
+ end
- it "can replace multiple multibyte characters with a single byte one" do
- a = "üüüber"
- a.encoding.should == Encoding::UTF_8
- b = a.tr_s("ü","u")
- b.should == "uber"
- b.encoding.should == Encoding::UTF_8
- end
+ it "can replace multiple multibyte characters with a single byte one" do
+ a = "üüüber"
+ a.encoding.should == Encoding::UTF_8
+ b = a.tr_s("ü","u")
+ b.should == "uber"
+ b.encoding.should == Encoding::UTF_8
+ end
- it "does not replace a multibyte character where part of the bytes match the tr string" do
- str = "æ¤Žåæ·±å¤"
- a = "\u0080\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008E\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009E\u009F"
- b = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“â€â€¢â€“—˜™š›œžŸ"
- str.tr_s(a, b).should == "æ¤Žåæ·±å¤"
- end
+ it "does not replace a multibyte character where part of the bytes match the tr string" do
+ str = "æ¤Žåæ·±å¤"
+ a = "\u0080\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008E\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009E\u009F"
+ b = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“â€â€¢â€“—˜™š›œžŸ"
+ str.tr_s(a, b).should == "æ¤Žåæ·±å¤"
+ end
+ end
end
@@ -127,10 +127,10 @@ describe "String#tr_s!" do
s.should == "hello"
end
- it "raises a #{frozen_error_class} if self is frozen" do
+ it "raises a RuntimeError if self is frozen" do
s = "hello".freeze
- -> { s.tr_s!("el", "ar") }.should raise_error(frozen_error_class)
- -> { s.tr_s!("l", "r") }.should raise_error(frozen_error_class)
- -> { s.tr_s!("", "") }.should raise_error(frozen_error_class)
+ lambda { s.tr_s!("el", "ar") }.should raise_error(RuntimeError)
+ lambda { s.tr_s!("l", "r") }.should raise_error(RuntimeError)
+ lambda { s.tr_s!("", "") }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/tr_spec.rb b/spec/ruby/core/string/tr_spec.rb
index ae826fd79b..16d2d318e1 100644
--- a/spec/ruby/core/string/tr_spec.rb
+++ b/spec/ruby/core/string/tr_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#tr" do
it "returns a new string with the characters from from_string replaced by the ones in to_string" do
@@ -22,11 +22,11 @@ describe "String#tr" do
end
it "raises an ArgumentError a descending range in the replacement as containing just the start character" do
- -> { "hello".tr("a-y", "z-b") }.should raise_error(ArgumentError)
+ lambda { "hello".tr("a-y", "z-b") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError a descending range in the source as empty" do
- -> { "hello".tr("l-a", "z") }.should raise_error(ArgumentError)
+ lambda { "hello".tr("l-a", "z") }.should raise_error(ArgumentError)
end
it "translates chars not in from_string when it starts with a ^" do
@@ -61,43 +61,43 @@ describe "String#tr" do
StringSpecs::MyString.new("hello").tr("e", "a").should be_an_instance_of(StringSpecs::MyString)
end
- ruby_version_is ''...'2.7' do
- it "taints the result when self is tainted" do
- ["h", "hello"].each do |str|
- tainted_str = str.dup.taint
+ it "taints the result when self is tainted" do
+ ["h", "hello"].each do |str|
+ tainted_str = str.dup.taint
- tainted_str.tr("e", "a").tainted?.should == true
+ tainted_str.tr("e", "a").tainted?.should == true
- str.tr("e".taint, "a").tainted?.should == false
- str.tr("e", "a".taint).tainted?.should == false
- end
+ str.tr("e".taint, "a").tainted?.should == false
+ str.tr("e", "a".taint).tainted?.should == false
end
end
- # http://redmine.ruby-lang.org/issues/show/1839
- it "can replace a 7-bit ASCII character with a multibyte one" do
- a = "uber"
- a.encoding.should == Encoding::UTF_8
- b = a.tr("u","ü")
- b.should == "über"
- b.encoding.should == Encoding::UTF_8
- end
+ with_feature :encoding do
+ # http://redmine.ruby-lang.org/issues/show/1839
+ it "can replace a 7-bit ASCII character with a multibyte one" do
+ a = "uber"
+ a.encoding.should == Encoding::UTF_8
+ b = a.tr("u","ü")
+ b.should == "über"
+ b.encoding.should == Encoding::UTF_8
+ end
- it "can replace a multibyte character with a single byte one" do
- a = "über"
- a.encoding.should == Encoding::UTF_8
- b = a.tr("ü","u")
- b.should == "uber"
- b.encoding.should == Encoding::UTF_8
- end
+ it "can replace a multibyte character with a single byte one" do
+ a = "über"
+ a.encoding.should == Encoding::UTF_8
+ b = a.tr("ü","u")
+ b.should == "uber"
+ b.encoding.should == Encoding::UTF_8
+ end
- it "does not replace a multibyte character where part of the bytes match the tr string" do
- str = "æ¤Žåæ·±å¤"
- a = "\u0080\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008E\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009E\u009F"
- b = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“â€â€¢â€“—˜™š›œžŸ"
- str.tr(a, b).should == "æ¤Žåæ·±å¤"
- end
+ it "does not replace a multibyte character where part of the bytes match the tr string" do
+ str = "æ¤Žåæ·±å¤"
+ a = "\u0080\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008E\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009E\u009F"
+ b = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“â€â€¢â€“—˜™š›œžŸ"
+ str.tr(a, b).should == "æ¤Žåæ·±å¤"
+ end
+ end
end
describe "String#tr!" do
@@ -122,10 +122,10 @@ describe "String#tr!" do
s.should == "hello"
end
- it "raises a #{frozen_error_class} if self is frozen" do
+ it "raises a RuntimeError if self is frozen" do
s = "abcdefghijklmnopqR".freeze
- -> { s.tr!("cdefg", "12") }.should raise_error(frozen_error_class)
- -> { s.tr!("R", "S") }.should raise_error(frozen_error_class)
- -> { s.tr!("", "") }.should raise_error(frozen_error_class)
+ lambda { s.tr!("cdefg", "12") }.should raise_error(RuntimeError)
+ lambda { s.tr!("R", "S") }.should raise_error(RuntimeError)
+ lambda { s.tr!("", "") }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/try_convert_spec.rb b/spec/ruby/core/string/try_convert_spec.rb
index 84415c4a75..ce12839c59 100644
--- a/spec/ruby/core/string/try_convert_spec.rb
+++ b/spec/ruby/core/string/try_convert_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "String.try_convert" do
it "returns the argument if it's a String" do
@@ -39,12 +39,12 @@ describe "String.try_convert" do
it "sends #to_str to the argument and raises TypeError if it's not a kind of String" do
obj = mock("to_str")
obj.should_receive(:to_str).and_return(Object.new)
- -> { String.try_convert obj }.should raise_error(TypeError)
+ lambda { String.try_convert obj }.should raise_error(TypeError)
end
it "does not rescue exceptions raised by #to_str" do
obj = mock("to_str")
obj.should_receive(:to_str).and_raise(RuntimeError)
- -> { String.try_convert obj }.should raise_error(RuntimeError)
+ lambda { String.try_convert obj }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/uminus_spec.rb b/spec/ruby/core/string/uminus_spec.rb
index dace04846c..53e73b7e67 100644
--- a/spec/ruby/core/string/uminus_spec.rb
+++ b/spec/ruby/core/string/uminus_spec.rb
@@ -1,74 +1,21 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe 'String#-@' do
- it 'returns self if the String is frozen' do
- input = 'foo'.freeze
- output = -input
+ruby_version_is "2.3" do
+ describe 'String#-@' do
+ it 'returns self if the String is frozen' do
+ input = 'foo'.freeze
+ output = -input
- output.should equal(input)
- output.frozen?.should == true
- end
-
- it 'returns a frozen copy if the String is not frozen' do
- input = 'foo'
- output = -input
-
- output.frozen?.should == true
- output.should_not equal(input)
- output.should == 'foo'
- end
-
- ruby_version_is "2.5" do
- it "returns the same object for equal unfrozen strings" do
- origin = "this is a string"
- dynamic = %w(this is a string).join(' ')
-
- origin.should_not equal(dynamic)
- (-origin).should equal(-dynamic)
- end
-
- it "returns the same object when it's called on the same String literal" do
- (-"unfrozen string").should equal(-"unfrozen string")
- (-"unfrozen string").should_not equal(-"another unfrozen string")
+ output.equal?(input).should == true
+ output.frozen?.should == true
end
- end
-
- ruby_version_is "2.5"..."2.6" do
- it "does not deduplicate already frozen strings" do
- dynamic = %w(this string is frozen).join(' ').freeze
-
- dynamic.should_not equal("this string is frozen".freeze)
-
- (-dynamic).should_not equal("this string is frozen".freeze)
- (-dynamic).should_not equal(-"this string is frozen".freeze)
- (-dynamic).should == "this string is frozen"
- end
-
- it "does not deduplicate tainted strings" do
- dynamic = %w(this string is frozen).join(' ')
- dynamic.taint
- (-dynamic).should_not equal("this string is frozen".freeze)
- (-dynamic).should_not equal(-"this string is frozen".freeze)
- (-dynamic).should == "this string is frozen"
- end
-
- it "does not deduplicate strings with additional instance variables" do
- dynamic = %w(this string is frozen).join(' ')
- dynamic.instance_variable_set(:@foo, :bar)
- (-dynamic).should_not equal("this string is frozen".freeze)
- (-dynamic).should_not equal(-"this string is frozen".freeze)
- (-dynamic).should == "this string is frozen"
- end
- end
-
- ruby_version_is "2.6" do
- it "deduplicates frozen strings" do
- dynamic = %w(this string is frozen).join(' ').freeze
- dynamic.should_not equal("this string is frozen".freeze)
+ it 'returns a frozen copy if the String is not frozen' do
+ input = 'foo'
+ output = -input
- (-dynamic).should equal("this string is frozen".freeze)
- (-dynamic).should equal(-"this string is frozen".freeze)
+ output.frozen?.should == true
+ output.should == 'foo'
end
end
end
diff --git a/spec/ruby/core/string/undump_spec.rb b/spec/ruby/core/string/undump_spec.rb
deleted file mode 100644
index d45c4bae1b..0000000000
--- a/spec/ruby/core/string/undump_spec.rb
+++ /dev/null
@@ -1,453 +0,0 @@
-# encoding: utf-8
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-ruby_version_is '2.5' do
- describe "String#undump" do
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- '"foo"'.taint.undump.tainted?.should == true
- end
-
- it "untrusts the result if self is untrusted" do
- '"foo"'.untrust.undump.untrusted?.should == true
- end
- end
-
- it "does not take into account if a string is frozen" do
- '"foo"'.freeze.undump.frozen?.should == false
- end
-
- it "always returns String instance" do
- StringSpecs::MyString.new('"foo"').undump.should be_an_instance_of(String)
- end
-
- it "strips outer \"" do
- '"foo"'.undump.should == 'foo'
- end
-
- it "returns a string with special characters in \\<char> notation replaced with the characters" do
- [ ['"\\a"', "\a"],
- ['"\\b"', "\b"],
- ['"\\t"', "\t"],
- ['"\\n"', "\n"],
- ['"\\v"', "\v"],
- ['"\\f"', "\f"],
- ['"\\r"', "\r"],
- ['"\\e"', "\e"]
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with unescaped sequences \" and \\" do
- [ ['"\\""' , "\""],
- ['"\\\\"', "\\"]
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with unescaped sequences \\#<char> when # is followed by $, @, {" do
- [ ['"\\#$PATH"', "\#$PATH"],
- ['"\\#@a"', "\#@a"],
- ['"\\#@@a"', "\#@@a"],
- ['"\\#{a}"', "\#{a}"]
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with # not escaped when followed by any other character" do
- [ ['"#"', '#'],
- ['"#1"', '#1']
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with printable non-alphanumeric characters" do
- [ ['" "', ' '],
- ['"!"', '!'],
- ['"$"', '$'],
- ['"%"', '%'],
- ['"&"', '&'],
- ['"\'"', '\''],
- ['"("', '('],
- ['")"', ')'],
- ['"*"', '*'],
- ['"+"', '+'],
- ['","', ','],
- ['"-"', '-'],
- ['"."', '.'],
- ['"/"', '/'],
- ['":"', ':'],
- ['";"', ';'],
- ['"<"', '<'],
- ['"="', '='],
- ['">"', '>'],
- ['"?"', '?'],
- ['"@"', '@'],
- ['"["', '['],
- ['"]"', ']'],
- ['"^"', '^'],
- ['"_"', '_'],
- ['"`"', '`'],
- ['"{"', '{'],
- ['"|"', '|'],
- ['"}"', '}'],
- ['"~"', '~']
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with numeric characters unescaped" do
- [ ['"0"', "0"],
- ['"1"', "1"],
- ['"2"', "2"],
- ['"3"', "3"],
- ['"4"', "4"],
- ['"5"', "5"],
- ['"6"', "6"],
- ['"7"', "7"],
- ['"8"', "8"],
- ['"9"', "9"],
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with upper-case alpha characters unescaped" do
- [ ['"A"', 'A'],
- ['"B"', 'B'],
- ['"C"', 'C'],
- ['"D"', 'D'],
- ['"E"', 'E'],
- ['"F"', 'F'],
- ['"G"', 'G'],
- ['"H"', 'H'],
- ['"I"', 'I'],
- ['"J"', 'J'],
- ['"K"', 'K'],
- ['"L"', 'L'],
- ['"M"', 'M'],
- ['"N"', 'N'],
- ['"O"', 'O'],
- ['"P"', 'P'],
- ['"Q"', 'Q'],
- ['"R"', 'R'],
- ['"S"', 'S'],
- ['"T"', 'T'],
- ['"U"', 'U'],
- ['"V"', 'V'],
- ['"W"', 'W'],
- ['"X"', 'X'],
- ['"Y"', 'Y'],
- ['"Z"', 'Z']
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with lower-case alpha characters unescaped" do
- [ ['"a"', 'a'],
- ['"b"', 'b'],
- ['"c"', 'c'],
- ['"d"', 'd'],
- ['"e"', 'e'],
- ['"f"', 'f'],
- ['"g"', 'g'],
- ['"h"', 'h'],
- ['"i"', 'i'],
- ['"j"', 'j'],
- ['"k"', 'k'],
- ['"l"', 'l'],
- ['"m"', 'm'],
- ['"n"', 'n'],
- ['"o"', 'o'],
- ['"p"', 'p'],
- ['"q"', 'q'],
- ['"r"', 'r'],
- ['"s"', 's'],
- ['"t"', 't'],
- ['"u"', 'u'],
- ['"v"', 'v'],
- ['"w"', 'w'],
- ['"x"', 'x'],
- ['"y"', 'y'],
- ['"z"', 'z']
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with \\x notation replaced with non-printing ASCII character" do
- [ ['"\\x00"', 0000.chr.force_encoding('utf-8')],
- ['"\\x01"', 0001.chr.force_encoding('utf-8')],
- ['"\\x02"', 0002.chr.force_encoding('utf-8')],
- ['"\\x03"', 0003.chr.force_encoding('utf-8')],
- ['"\\x04"', 0004.chr.force_encoding('utf-8')],
- ['"\\x05"', 0005.chr.force_encoding('utf-8')],
- ['"\\x06"', 0006.chr.force_encoding('utf-8')],
- ['"\\x0E"', 0016.chr.force_encoding('utf-8')],
- ['"\\x0F"', 0017.chr.force_encoding('utf-8')],
- ['"\\x10"', 0020.chr.force_encoding('utf-8')],
- ['"\\x11"', 0021.chr.force_encoding('utf-8')],
- ['"\\x12"', 0022.chr.force_encoding('utf-8')],
- ['"\\x13"', 0023.chr.force_encoding('utf-8')],
- ['"\\x14"', 0024.chr.force_encoding('utf-8')],
- ['"\\x15"', 0025.chr.force_encoding('utf-8')],
- ['"\\x16"', 0026.chr.force_encoding('utf-8')],
- ['"\\x17"', 0027.chr.force_encoding('utf-8')],
- ['"\\x18"', 0030.chr.force_encoding('utf-8')],
- ['"\\x19"', 0031.chr.force_encoding('utf-8')],
- ['"\\x1A"', 0032.chr.force_encoding('utf-8')],
- ['"\\x1C"', 0034.chr.force_encoding('utf-8')],
- ['"\\x1D"', 0035.chr.force_encoding('utf-8')],
- ['"\\x1E"', 0036.chr.force_encoding('utf-8')],
- ['"\\x1F"', 0037.chr.force_encoding('utf-8')],
- ['"\\x7F"', 0177.chr.force_encoding('utf-8')],
- ['"\\x80"', 0200.chr.force_encoding('utf-8')],
- ['"\\x81"', 0201.chr.force_encoding('utf-8')],
- ['"\\x82"', 0202.chr.force_encoding('utf-8')],
- ['"\\x83"', 0203.chr.force_encoding('utf-8')],
- ['"\\x84"', 0204.chr.force_encoding('utf-8')],
- ['"\\x85"', 0205.chr.force_encoding('utf-8')],
- ['"\\x86"', 0206.chr.force_encoding('utf-8')],
- ['"\\x87"', 0207.chr.force_encoding('utf-8')],
- ['"\\x88"', 0210.chr.force_encoding('utf-8')],
- ['"\\x89"', 0211.chr.force_encoding('utf-8')],
- ['"\\x8A"', 0212.chr.force_encoding('utf-8')],
- ['"\\x8B"', 0213.chr.force_encoding('utf-8')],
- ['"\\x8C"', 0214.chr.force_encoding('utf-8')],
- ['"\\x8D"', 0215.chr.force_encoding('utf-8')],
- ['"\\x8E"', 0216.chr.force_encoding('utf-8')],
- ['"\\x8F"', 0217.chr.force_encoding('utf-8')],
- ['"\\x90"', 0220.chr.force_encoding('utf-8')],
- ['"\\x91"', 0221.chr.force_encoding('utf-8')],
- ['"\\x92"', 0222.chr.force_encoding('utf-8')],
- ['"\\x93"', 0223.chr.force_encoding('utf-8')],
- ['"\\x94"', 0224.chr.force_encoding('utf-8')],
- ['"\\x95"', 0225.chr.force_encoding('utf-8')],
- ['"\\x96"', 0226.chr.force_encoding('utf-8')],
- ['"\\x97"', 0227.chr.force_encoding('utf-8')],
- ['"\\x98"', 0230.chr.force_encoding('utf-8')],
- ['"\\x99"', 0231.chr.force_encoding('utf-8')],
- ['"\\x9A"', 0232.chr.force_encoding('utf-8')],
- ['"\\x9B"', 0233.chr.force_encoding('utf-8')],
- ['"\\x9C"', 0234.chr.force_encoding('utf-8')],
- ['"\\x9D"', 0235.chr.force_encoding('utf-8')],
- ['"\\x9E"', 0236.chr.force_encoding('utf-8')],
- ['"\\x9F"', 0237.chr.force_encoding('utf-8')],
- ['"\\xA0"', 0240.chr.force_encoding('utf-8')],
- ['"\\xA1"', 0241.chr.force_encoding('utf-8')],
- ['"\\xA2"', 0242.chr.force_encoding('utf-8')],
- ['"\\xA3"', 0243.chr.force_encoding('utf-8')],
- ['"\\xA4"', 0244.chr.force_encoding('utf-8')],
- ['"\\xA5"', 0245.chr.force_encoding('utf-8')],
- ['"\\xA6"', 0246.chr.force_encoding('utf-8')],
- ['"\\xA7"', 0247.chr.force_encoding('utf-8')],
- ['"\\xA8"', 0250.chr.force_encoding('utf-8')],
- ['"\\xA9"', 0251.chr.force_encoding('utf-8')],
- ['"\\xAA"', 0252.chr.force_encoding('utf-8')],
- ['"\\xAB"', 0253.chr.force_encoding('utf-8')],
- ['"\\xAC"', 0254.chr.force_encoding('utf-8')],
- ['"\\xAD"', 0255.chr.force_encoding('utf-8')],
- ['"\\xAE"', 0256.chr.force_encoding('utf-8')],
- ['"\\xAF"', 0257.chr.force_encoding('utf-8')],
- ['"\\xB0"', 0260.chr.force_encoding('utf-8')],
- ['"\\xB1"', 0261.chr.force_encoding('utf-8')],
- ['"\\xB2"', 0262.chr.force_encoding('utf-8')],
- ['"\\xB3"', 0263.chr.force_encoding('utf-8')],
- ['"\\xB4"', 0264.chr.force_encoding('utf-8')],
- ['"\\xB5"', 0265.chr.force_encoding('utf-8')],
- ['"\\xB6"', 0266.chr.force_encoding('utf-8')],
- ['"\\xB7"', 0267.chr.force_encoding('utf-8')],
- ['"\\xB8"', 0270.chr.force_encoding('utf-8')],
- ['"\\xB9"', 0271.chr.force_encoding('utf-8')],
- ['"\\xBA"', 0272.chr.force_encoding('utf-8')],
- ['"\\xBB"', 0273.chr.force_encoding('utf-8')],
- ['"\\xBC"', 0274.chr.force_encoding('utf-8')],
- ['"\\xBD"', 0275.chr.force_encoding('utf-8')],
- ['"\\xBE"', 0276.chr.force_encoding('utf-8')],
- ['"\\xBF"', 0277.chr.force_encoding('utf-8')],
- ['"\\xC0"', 0300.chr.force_encoding('utf-8')],
- ['"\\xC1"', 0301.chr.force_encoding('utf-8')],
- ['"\\xC2"', 0302.chr.force_encoding('utf-8')],
- ['"\\xC3"', 0303.chr.force_encoding('utf-8')],
- ['"\\xC4"', 0304.chr.force_encoding('utf-8')],
- ['"\\xC5"', 0305.chr.force_encoding('utf-8')],
- ['"\\xC6"', 0306.chr.force_encoding('utf-8')],
- ['"\\xC7"', 0307.chr.force_encoding('utf-8')],
- ['"\\xC8"', 0310.chr.force_encoding('utf-8')],
- ['"\\xC9"', 0311.chr.force_encoding('utf-8')],
- ['"\\xCA"', 0312.chr.force_encoding('utf-8')],
- ['"\\xCB"', 0313.chr.force_encoding('utf-8')],
- ['"\\xCC"', 0314.chr.force_encoding('utf-8')],
- ['"\\xCD"', 0315.chr.force_encoding('utf-8')],
- ['"\\xCE"', 0316.chr.force_encoding('utf-8')],
- ['"\\xCF"', 0317.chr.force_encoding('utf-8')],
- ['"\\xD0"', 0320.chr.force_encoding('utf-8')],
- ['"\\xD1"', 0321.chr.force_encoding('utf-8')],
- ['"\\xD2"', 0322.chr.force_encoding('utf-8')],
- ['"\\xD3"', 0323.chr.force_encoding('utf-8')],
- ['"\\xD4"', 0324.chr.force_encoding('utf-8')],
- ['"\\xD5"', 0325.chr.force_encoding('utf-8')],
- ['"\\xD6"', 0326.chr.force_encoding('utf-8')],
- ['"\\xD7"', 0327.chr.force_encoding('utf-8')],
- ['"\\xD8"', 0330.chr.force_encoding('utf-8')],
- ['"\\xD9"', 0331.chr.force_encoding('utf-8')],
- ['"\\xDA"', 0332.chr.force_encoding('utf-8')],
- ['"\\xDB"', 0333.chr.force_encoding('utf-8')],
- ['"\\xDC"', 0334.chr.force_encoding('utf-8')],
- ['"\\xDD"', 0335.chr.force_encoding('utf-8')],
- ['"\\xDE"', 0336.chr.force_encoding('utf-8')],
- ['"\\xDF"', 0337.chr.force_encoding('utf-8')],
- ['"\\xE0"', 0340.chr.force_encoding('utf-8')],
- ['"\\xE1"', 0341.chr.force_encoding('utf-8')],
- ['"\\xE2"', 0342.chr.force_encoding('utf-8')],
- ['"\\xE3"', 0343.chr.force_encoding('utf-8')],
- ['"\\xE4"', 0344.chr.force_encoding('utf-8')],
- ['"\\xE5"', 0345.chr.force_encoding('utf-8')],
- ['"\\xE6"', 0346.chr.force_encoding('utf-8')],
- ['"\\xE7"', 0347.chr.force_encoding('utf-8')],
- ['"\\xE8"', 0350.chr.force_encoding('utf-8')],
- ['"\\xE9"', 0351.chr.force_encoding('utf-8')],
- ['"\\xEA"', 0352.chr.force_encoding('utf-8')],
- ['"\\xEB"', 0353.chr.force_encoding('utf-8')],
- ['"\\xEC"', 0354.chr.force_encoding('utf-8')],
- ['"\\xED"', 0355.chr.force_encoding('utf-8')],
- ['"\\xEE"', 0356.chr.force_encoding('utf-8')],
- ['"\\xEF"', 0357.chr.force_encoding('utf-8')],
- ['"\\xF0"', 0360.chr.force_encoding('utf-8')],
- ['"\\xF1"', 0361.chr.force_encoding('utf-8')],
- ['"\\xF2"', 0362.chr.force_encoding('utf-8')],
- ['"\\xF3"', 0363.chr.force_encoding('utf-8')],
- ['"\\xF4"', 0364.chr.force_encoding('utf-8')],
- ['"\\xF5"', 0365.chr.force_encoding('utf-8')],
- ['"\\xF6"', 0366.chr.force_encoding('utf-8')],
- ['"\\xF7"', 0367.chr.force_encoding('utf-8')],
- ['"\\xF8"', 0370.chr.force_encoding('utf-8')],
- ['"\\xF9"', 0371.chr.force_encoding('utf-8')],
- ['"\\xFA"', 0372.chr.force_encoding('utf-8')],
- ['"\\xFB"', 0373.chr.force_encoding('utf-8')],
- ['"\\xFC"', 0374.chr.force_encoding('utf-8')],
- ['"\\xFD"', 0375.chr.force_encoding('utf-8')],
- ['"\\xFE"', 0376.chr.force_encoding('utf-8')],
- ['"\\xFF"', 0377.chr.force_encoding('utf-8')]
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with \\u{} notation replaced with multi-byte UTF-8 characters" do
- [ ['"\u{80}"', 0200.chr('utf-8')],
- ['"\u{81}"', 0201.chr('utf-8')],
- ['"\u{82}"', 0202.chr('utf-8')],
- ['"\u{83}"', 0203.chr('utf-8')],
- ['"\u{84}"', 0204.chr('utf-8')],
- ['"\u{86}"', 0206.chr('utf-8')],
- ['"\u{87}"', 0207.chr('utf-8')],
- ['"\u{88}"', 0210.chr('utf-8')],
- ['"\u{89}"', 0211.chr('utf-8')],
- ['"\u{8a}"', 0212.chr('utf-8')],
- ['"\u{8b}"', 0213.chr('utf-8')],
- ['"\u{8c}"', 0214.chr('utf-8')],
- ['"\u{8d}"', 0215.chr('utf-8')],
- ['"\u{8e}"', 0216.chr('utf-8')],
- ['"\u{8f}"', 0217.chr('utf-8')],
- ['"\u{90}"', 0220.chr('utf-8')],
- ['"\u{91}"', 0221.chr('utf-8')],
- ['"\u{92}"', 0222.chr('utf-8')],
- ['"\u{93}"', 0223.chr('utf-8')],
- ['"\u{94}"', 0224.chr('utf-8')],
- ['"\u{95}"', 0225.chr('utf-8')],
- ['"\u{96}"', 0226.chr('utf-8')],
- ['"\u{97}"', 0227.chr('utf-8')],
- ['"\u{98}"', 0230.chr('utf-8')],
- ['"\u{99}"', 0231.chr('utf-8')],
- ['"\u{9a}"', 0232.chr('utf-8')],
- ['"\u{9b}"', 0233.chr('utf-8')],
- ['"\u{9c}"', 0234.chr('utf-8')],
- ['"\u{9d}"', 0235.chr('utf-8')],
- ['"\u{9e}"', 0236.chr('utf-8')],
- ['"\u{9f}"', 0237.chr('utf-8')],
- ].should be_computed_by(:undump)
- end
-
- it "returns a string with \\uXXXX notation replaced with multi-byte UTF-8 characters" do
- [ ['"\u0080"', 0200.chr('utf-8')],
- ['"\u0081"', 0201.chr('utf-8')],
- ['"\u0082"', 0202.chr('utf-8')],
- ['"\u0083"', 0203.chr('utf-8')],
- ['"\u0084"', 0204.chr('utf-8')],
- ['"\u0086"', 0206.chr('utf-8')],
- ['"\u0087"', 0207.chr('utf-8')],
- ['"\u0088"', 0210.chr('utf-8')],
- ['"\u0089"', 0211.chr('utf-8')],
- ['"\u008a"', 0212.chr('utf-8')],
- ['"\u008b"', 0213.chr('utf-8')],
- ['"\u008c"', 0214.chr('utf-8')],
- ['"\u008d"', 0215.chr('utf-8')],
- ['"\u008e"', 0216.chr('utf-8')],
- ['"\u008f"', 0217.chr('utf-8')],
- ['"\u0090"', 0220.chr('utf-8')],
- ['"\u0091"', 0221.chr('utf-8')],
- ['"\u0092"', 0222.chr('utf-8')],
- ['"\u0093"', 0223.chr('utf-8')],
- ['"\u0094"', 0224.chr('utf-8')],
- ['"\u0095"', 0225.chr('utf-8')],
- ['"\u0096"', 0226.chr('utf-8')],
- ['"\u0097"', 0227.chr('utf-8')],
- ['"\u0098"', 0230.chr('utf-8')],
- ['"\u0099"', 0231.chr('utf-8')],
- ['"\u009a"', 0232.chr('utf-8')],
- ['"\u009b"', 0233.chr('utf-8')],
- ['"\u009c"', 0234.chr('utf-8')],
- ['"\u009d"', 0235.chr('utf-8')],
- ['"\u009e"', 0236.chr('utf-8')],
- ['"\u009f"', 0237.chr('utf-8')],
- ].should be_computed_by(:undump)
- end
-
- it "undumps correctly string produced from non ASCII-compatible one" do
- s = "\u{876}".encode('utf-16be')
- s.dump.undump.should == s
-
- '"\\bv".force_encoding("UTF-16BE")'.undump.should == "\u0876".encode('utf-16be')
- end
-
- it "keeps origin encoding" do
- '"foo"'.encode("ISO-8859-1").undump.encoding.should == Encoding::ISO_8859_1
- '"foo"'.encode('windows-1251').undump.encoding.should == Encoding::Windows_1251
- end
-
- describe "Limitations" do
- it "cannot undump non ASCII-compatible string" do
- -> { '"foo"'.encode('utf-16le').undump }.should raise_error(Encoding::CompatibilityError)
- end
- end
-
- describe "invalid dump" do
- it "raises RuntimeError exception if wrapping \" are missing" do
- -> { 'foo'.undump }.should raise_error(RuntimeError, /invalid dumped string/)
- -> { '"foo'.undump }.should raise_error(RuntimeError, /unterminated dumped string/)
- -> { 'foo"'.undump }.should raise_error(RuntimeError, /invalid dumped string/)
- -> { "'foo'".undump }.should raise_error(RuntimeError, /invalid dumped string/)
- end
-
- it "raises RuntimeError if there is incorrect \\x sequence" do
- -> { '"\x"'.undump }.should raise_error(RuntimeError, /invalid hex escape/)
- -> { '"\\x3y"'.undump }.should raise_error(RuntimeError, /invalid hex escape/)
- end
-
- it "raises RuntimeError in there is incorrect \\u sequence" do
- -> { '"\\u"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/)
- -> { '"\\u{"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/)
- -> { '"\\u{3042"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/)
- -> { '"\\u"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/)
- end
-
- it "raises RuntimeError if there is malformed dump of non ASCII-compatible string" do
- -> { '"".force_encoding("BINARY"'.undump }.should raise_error(RuntimeError, /invalid dumped string/)
- -> { '"".force_encoding("Unknown")'.undump }.should raise_error(RuntimeError, /dumped string has unknown encoding name/)
- -> { '"".force_encoding()'.undump }.should raise_error(RuntimeError, /invalid dumped string/)
- end
-
- it "raises RuntimeError if string contains \0 character" do
- -> { "\"foo\0\"".undump }.should raise_error(RuntimeError, /string contains null byte/)
- end
-
- it "raises RuntimeError if string contains non ASCII character" do
- -> { "\"\u3042\"".undump }.should raise_error(RuntimeError, /non-ASCII character detected/)
- end
-
- it "raises RuntimeError if there are some excessive \"" do
- -> { '" "" "'.undump }.should raise_error(RuntimeError, /invalid dumped string/)
- end
- end
- end
-end
diff --git a/spec/ruby/core/string/unicode_normalize_spec.rb b/spec/ruby/core/string/unicode_normalize_spec.rb
index 6de7533fc7..138c0455fd 100644
--- a/spec/ruby/core/string/unicode_normalize_spec.rb
+++ b/spec/ruby/core/string/unicode_normalize_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
# Examples taken from http://www.unicode.org/reports/tr15/#Norm_Forms
@@ -48,13 +48,13 @@ describe "String#unicode_normalize" do
end
it "raises an Encoding::CompatibilityError if string is not in an unicode encoding" do
- -> do
+ lambda do
[0xE0].pack('C').force_encoding("ISO-8859-1").unicode_normalize(:nfd)
end.should raise_error(Encoding::CompatibilityError)
end
it "raises an ArgumentError if the specified form is invalid" do
- -> {
+ lambda {
@angstrom.unicode_normalize(:invalid_form)
}.should raise_error(ArgumentError)
end
@@ -101,14 +101,14 @@ describe "String#unicode_normalize!" do
end
it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do
- -> {
+ lambda {
[0xE0].pack('C').force_encoding("ISO-8859-1").unicode_normalize!
}.should raise_error(Encoding::CompatibilityError)
end
it "raises an ArgumentError if the specified form is invalid" do
ohm = "\u2126"
- -> {
+ lambda {
ohm.unicode_normalize!(:invalid_form)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/string/unicode_normalized_spec.rb b/spec/ruby/core/string/unicode_normalized_spec.rb
index 25c810a98f..dc5e2742e4 100644
--- a/spec/ruby/core/string/unicode_normalized_spec.rb
+++ b/spec/ruby/core/string/unicode_normalized_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "String#unicode_normalized?" do
before :each do
@@ -37,11 +37,11 @@ describe "String#unicode_normalized?" do
end
it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do
- -> { @nfc_normalized_str.force_encoding("ISO-8859-1").unicode_normalized? }.should raise_error(Encoding::CompatibilityError)
+ lambda { @nfc_normalized_str.force_encoding("ISO-8859-1").unicode_normalized? }.should raise_error(Encoding::CompatibilityError)
end
it "raises an ArgumentError if the specified form is invalid" do
- -> { @nfc_normalized_str.unicode_normalized?(:invalid_form) }.should raise_error(ArgumentError)
+ lambda { @nfc_normalized_str.unicode_normalized?(:invalid_form) }.should raise_error(ArgumentError)
end
it "returns true if str is in Unicode normalization form (nfc)" do
diff --git a/spec/ruby/core/string/unpack/a_spec.rb b/spec/ruby/core/string/unpack/a_spec.rb
index 2d83b4c824..18882c91a6 100644
--- a/spec/ruby/core/string/unpack/a_spec.rb
+++ b/spec/ruby/core/string/unpack/a_spec.rb
@@ -1,16 +1,14 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/string'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/string', __FILE__)
describe "String#unpack with format 'A'" do
it_behaves_like :string_unpack_basic, 'A'
it_behaves_like :string_unpack_no_platform, 'A'
it_behaves_like :string_unpack_string, 'A'
it_behaves_like :string_unpack_Aa, 'A'
- it_behaves_like :string_unpack_taint, 'A'
it "removes trailing space and NULL bytes from the decoded string" do
[ ["a\x00 b \x00", ["a\x00 b", ""]],
@@ -32,7 +30,7 @@ describe "String#unpack with format 'A'" do
it "decodes into raw (ascii) string values" do
str = "str".force_encoding('UTF-8').unpack("A*")[0]
- str.encoding.should == Encoding::BINARY
+ str.encoding.name.should == 'ASCII-8BIT'
end
end
@@ -42,7 +40,6 @@ describe "String#unpack with format 'a'" do
it_behaves_like :string_unpack_no_platform, 'a'
it_behaves_like :string_unpack_string, 'a'
it_behaves_like :string_unpack_Aa, 'a'
- it_behaves_like :string_unpack_taint, 'a'
it "does not remove trailing whitespace or NULL bytes from the decoded string" do
[ ["a\x00 b \x00", ["a\x00 b \x00"]],
@@ -60,7 +57,7 @@ describe "String#unpack with format 'a'" do
it "decodes into raw (ascii) string values" do
str = "".unpack("a*")[0]
- str.encoding.should == Encoding::BINARY
+ str.encoding.name.should == 'ASCII-8BIT'
end
end
diff --git a/spec/ruby/core/string/unpack/at_spec.rb b/spec/ruby/core/string/unpack/at_spec.rb
index 70b2389d69..70cbebd2ba 100644
--- a/spec/ruby/core/string/unpack/at_spec.rb
+++ b/spec/ruby/core/string/unpack/at_spec.rb
@@ -1,7 +1,7 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "String#unpack with format '@'" do
it_behaves_like :string_unpack_basic, '@'
@@ -24,6 +24,6 @@ describe "String#unpack with format '@'" do
end
it "raises an ArgumentError if the count exceeds the size of the String" do
- -> { "\x01\x02\x03\x04".unpack("C2@5C") }.should raise_error(ArgumentError)
+ lambda { "\x01\x02\x03\x04".unpack("C2@5C") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/string/unpack/b_spec.rb b/spec/ruby/core/string/unpack/b_spec.rb
index 1a838d6c7c..fa632e6526 100644
--- a/spec/ruby/core/string/unpack/b_spec.rb
+++ b/spec/ruby/core/string/unpack/b_spec.rb
@@ -1,13 +1,11 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "String#unpack with format 'B'" do
it_behaves_like :string_unpack_basic, 'B'
it_behaves_like :string_unpack_no_platform, 'B'
- it_behaves_like :string_unpack_taint, 'B'
it "decodes one bit from each byte for each format character starting with the most significant bit" do
[ ["\x00", "B", ["0"]],
@@ -98,7 +96,6 @@ end
describe "String#unpack with format 'b'" do
it_behaves_like :string_unpack_basic, 'b'
it_behaves_like :string_unpack_no_platform, 'b'
- it_behaves_like :string_unpack_taint, 'b'
it "decodes one bit from each byte for each format character starting with the least significant bit" do
[ ["\x00", "b", ["0"]],
diff --git a/spec/ruby/core/string/unpack/c_spec.rb b/spec/ruby/core/string/unpack/c_spec.rb
index ed8caa4895..36de462cac 100644
--- a/spec/ruby/core/string/unpack/c_spec.rb
+++ b/spec/ruby/core/string/unpack/c_spec.rb
@@ -1,7 +1,7 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe :string_unpack_8bit, shared: true do
it "decodes one byte for a single format character" do
@@ -20,7 +20,7 @@ describe :string_unpack_8bit, shared: true do
"abc".unpack(unpack_format('*')).should == [97, 98, 99]
end
- it "decodes the remaining bytes when passed the '*' modifier after another directive" do
+ it "decodes the remaining bytes when passed the '*' modifer after another directive" do
"abc".unpack(unpack_format()+unpack_format('*')).should == [97, 98, 99]
end
diff --git a/spec/ruby/core/string/unpack/comment_spec.rb b/spec/ruby/core/string/unpack/comment_spec.rb
index e18a53df3c..884960b337 100644
--- a/spec/ruby/core/string/unpack/comment_spec.rb
+++ b/spec/ruby/core/string/unpack/comment_spec.rb
@@ -1,6 +1,6 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "String#unpack" do
it "ignores directives text from '#' to the first newline" do
diff --git a/spec/ruby/core/string/unpack/d_spec.rb b/spec/ruby/core/string/unpack/d_spec.rb
index 0e4f57ec04..db4638f8ef 100644
--- a/spec/ruby/core/string/unpack/d_spec.rb
+++ b/spec/ruby/core/string/unpack/d_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
little_endian do
describe "String#unpack with format 'D'" do
diff --git a/spec/ruby/core/string/unpack/e_spec.rb b/spec/ruby/core/string/unpack/e_spec.rb
index c958be1c8b..cb74c00206 100644
--- a/spec/ruby/core/string/unpack/e_spec.rb
+++ b/spec/ruby/core/string/unpack/e_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
describe "String#unpack with format 'E'" do
it_behaves_like :string_unpack_basic, 'E'
diff --git a/spec/ruby/core/string/unpack/f_spec.rb b/spec/ruby/core/string/unpack/f_spec.rb
index ec8b9d435e..60dad46703 100644
--- a/spec/ruby/core/string/unpack/f_spec.rb
+++ b/spec/ruby/core/string/unpack/f_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
little_endian do
describe "String#unpack with format 'F'" do
diff --git a/spec/ruby/core/string/unpack/g_spec.rb b/spec/ruby/core/string/unpack/g_spec.rb
index ffc423b152..f5bec1534e 100644
--- a/spec/ruby/core/string/unpack/g_spec.rb
+++ b/spec/ruby/core/string/unpack/g_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/float'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/float', __FILE__)
describe "String#unpack with format 'G'" do
it_behaves_like :string_unpack_basic, 'G'
diff --git a/spec/ruby/core/string/unpack/h_spec.rb b/spec/ruby/core/string/unpack/h_spec.rb
index f2f5dcf396..00d6d68eee 100644
--- a/spec/ruby/core/string/unpack/h_spec.rb
+++ b/spec/ruby/core/string/unpack/h_spec.rb
@@ -1,13 +1,11 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "String#unpack with format 'H'" do
it_behaves_like :string_unpack_basic, 'H'
it_behaves_like :string_unpack_no_platform, 'H'
- it_behaves_like :string_unpack_taint, 'H'
it "decodes one nibble from each byte for each format character starting with the most significant bit" do
[ ["\x8f", "H", ["8"]],
@@ -63,16 +61,11 @@ describe "String#unpack with format 'H'" do
it "ignores spaces between directives" do
"\x01\x10".unpack("H H").should == ["0", "1"]
end
-
- it "should make strings with US_ASCII encoding" do
- "\x01".unpack("H")[0].encoding.should == Encoding::US_ASCII
- end
end
describe "String#unpack with format 'h'" do
it_behaves_like :string_unpack_basic, 'h'
it_behaves_like :string_unpack_no_platform, 'h'
- it_behaves_like :string_unpack_taint, 'h'
it "decodes one nibble from each byte for each format character starting with the least significant bit" do
[ ["\x8f", "h", ["f"]],
@@ -128,8 +121,4 @@ describe "String#unpack with format 'h'" do
it "ignores spaces between directives" do
"\x01\x10".unpack("h h").should == ["1", "0"]
end
-
- it "should make strings with US_ASCII encoding" do
- "\x01".unpack("h")[0].encoding.should == Encoding::US_ASCII
- end
end
diff --git a/spec/ruby/core/string/unpack/i_spec.rb b/spec/ruby/core/string/unpack/i_spec.rb
index b4bbba1923..f3183afe99 100644
--- a/spec/ruby/core/string/unpack/i_spec.rb
+++ b/spec/ruby/core/string/unpack/i_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "String#unpack with format 'I'" do
describe "with modifier '<'" do
diff --git a/spec/ruby/core/string/unpack/j_spec.rb b/spec/ruby/core/string/unpack/j_spec.rb
index 3c2baad642..49c460aeb3 100644
--- a/spec/ruby/core/string/unpack/j_spec.rb
+++ b/spec/ruby/core/string/unpack/j_spec.rb
@@ -1,272 +1,277 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/integer'
-
-platform_is pointer_size: 64 do
- little_endian do
- describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_le, 'J_'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J_'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
+
+ruby_version_is '2.3' do
+ # To handle the special case of x64-mingw32
+ pointer_size = RUBY_PLATFORM =~ /\bx64\b/ ? 64 : 1.size * 8
+
+ if pointer_size == 64 then
+ little_endian do
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'J_'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'J!'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J!'
+ end
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_le, 'J!'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J!'
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'j_'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'j!'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j!'
+ end
end
end
- describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_le, 'j_'
- it_behaves_like :string_unpack_64bit_le_signed, 'j_'
+ big_endian do
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'J_'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'J!'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J!'
+ end
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_le, 'j!'
- it_behaves_like :string_unpack_64bit_le_signed, 'j!'
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'j_'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'j!'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j!'
+ end
end
end
- end
- big_endian do
describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_be, 'J_'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J_'
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_64bit_le, 'J<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J<'
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_be, 'J!'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J!'
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_64bit_be, 'J>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J>'
end
- end
- describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_be, 'j_'
- it_behaves_like :string_unpack_64bit_be_signed, 'j_'
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'J<_'
+ it_behaves_like :string_unpack_64bit_le, 'J_<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J<_'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J_<'
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_be, 'j!'
- it_behaves_like :string_unpack_64bit_be_signed, 'j!'
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'J<!'
+ it_behaves_like :string_unpack_64bit_le, 'J!<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J<!'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J!<'
end
- end
- end
- describe "String#unpack with format 'J'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_64bit_le, 'J<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J<'
- end
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'J>_'
+ it_behaves_like :string_unpack_64bit_be, 'J_>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J>_'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J_>'
+ end
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_64bit_be, 'J>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J>'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'J>!'
+ it_behaves_like :string_unpack_64bit_be, 'J!>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J>!'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J!>'
+ end
end
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_64bit_le, 'J<_'
- it_behaves_like :string_unpack_64bit_le, 'J_<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J<_'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J_<'
- end
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_64bit_le, 'j<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j<'
+ end
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_64bit_le, 'J<!'
- it_behaves_like :string_unpack_64bit_le, 'J!<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J<!'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J!<'
- end
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_64bit_be, 'j>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j>'
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_64bit_be, 'J>_'
- it_behaves_like :string_unpack_64bit_be, 'J_>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J>_'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J_>'
- end
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'j<_'
+ it_behaves_like :string_unpack_64bit_le, 'j_<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j<_'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j_<'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_64bit_be, 'J>!'
- it_behaves_like :string_unpack_64bit_be, 'J!>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J>!'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J!>'
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'j<!'
+ it_behaves_like :string_unpack_64bit_le, 'j!<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j<!'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'j>_'
+ it_behaves_like :string_unpack_64bit_be, 'j_>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j>_'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'j>!'
+ it_behaves_like :string_unpack_64bit_be, 'j!>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j>!'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j!>'
+ end
end
end
- describe "String#unpack with format 'j'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_64bit_le, 'j<'
- it_behaves_like :string_unpack_64bit_le_signed, 'j<'
- end
+ if pointer_size == 32 then
+ little_endian do
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'J_'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J_'
+ end
+
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'J!'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J!'
+ end
+ end
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_64bit_be, 'j>'
- it_behaves_like :string_unpack_64bit_be_signed, 'j>'
- end
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'j_'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j_'
+ end
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_64bit_le, 'j<_'
- it_behaves_like :string_unpack_64bit_le, 'j_<'
- it_behaves_like :string_unpack_64bit_le_signed, 'j<_'
- it_behaves_like :string_unpack_64bit_le_signed, 'j_<'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'j!'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j!'
+ end
+ end
end
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_64bit_le, 'j<!'
- it_behaves_like :string_unpack_64bit_le, 'j!<'
- it_behaves_like :string_unpack_64bit_le_signed, 'j<!'
- it_behaves_like :string_unpack_64bit_le_signed, 'j!<'
- end
+ big_endian do
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'J_'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J_'
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_64bit_be, 'j>_'
- it_behaves_like :string_unpack_64bit_be, 'j_>'
- it_behaves_like :string_unpack_64bit_be_signed, 'j>_'
- it_behaves_like :string_unpack_64bit_be_signed, 'j_>'
- end
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'J!'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J!'
+ end
+ end
+
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'j_'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j_'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_64bit_be, 'j>!'
- it_behaves_like :string_unpack_64bit_be, 'j!>'
- it_behaves_like :string_unpack_64bit_be_signed, 'j>!'
- it_behaves_like :string_unpack_64bit_be_signed, 'j!>'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'j!'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j!'
+ end
+ end
end
- end
-end
-platform_is pointer_size: 32 do
- little_endian do
describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_le, 'J_'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J_'
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_32bit_le, 'J<'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J<'
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_le, 'J!'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J!'
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_32bit_be, 'J>'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J>'
end
- end
- describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_le, 'j_'
- it_behaves_like :string_unpack_32bit_le_signed, 'j_'
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'J<_'
+ it_behaves_like :string_unpack_32bit_le, 'J_<'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J<_'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J_<'
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_le, 'j!'
- it_behaves_like :string_unpack_32bit_le_signed, 'j!'
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'J<!'
+ it_behaves_like :string_unpack_32bit_le, 'J!<'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J<!'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J!<'
end
- end
- end
- big_endian do
- describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_be, 'J_'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J_'
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'J>_'
+ it_behaves_like :string_unpack_32bit_be, 'J_>'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J>_'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J_>'
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_be, 'J!'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J!'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'J>!'
+ it_behaves_like :string_unpack_32bit_be, 'J!>'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J>!'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J!>'
end
end
describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_be, 'j_'
- it_behaves_like :string_unpack_32bit_be_signed, 'j_'
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_32bit_le, 'j<'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j<'
end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_be, 'j!'
- it_behaves_like :string_unpack_32bit_be_signed, 'j!'
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_32bit_be, 'j>'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j>'
end
- end
- end
-
- describe "String#unpack with format 'J'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_32bit_le, 'J<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J<'
- end
-
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_32bit_be, 'J>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J>'
- end
-
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_32bit_le, 'J<_'
- it_behaves_like :string_unpack_32bit_le, 'J_<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J<_'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_32bit_le, 'J<!'
- it_behaves_like :string_unpack_32bit_le, 'J!<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J<!'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_32bit_be, 'J>_'
- it_behaves_like :string_unpack_32bit_be, 'J_>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J>_'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J_>'
- end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_32bit_be, 'J>!'
- it_behaves_like :string_unpack_32bit_be, 'J!>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J>!'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J!>'
- end
- end
-
- describe "String#unpack with format 'j'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_32bit_le, 'j<'
- it_behaves_like :string_unpack_32bit_le_signed, 'j<'
- end
-
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_32bit_be, 'j>'
- it_behaves_like :string_unpack_32bit_be_signed, 'j>'
- end
-
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_32bit_le, 'j<_'
- it_behaves_like :string_unpack_32bit_le, 'j_<'
- it_behaves_like :string_unpack_32bit_le_signed, 'j<_'
- it_behaves_like :string_unpack_32bit_le_signed, 'j_<'
- end
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'j<_'
+ it_behaves_like :string_unpack_32bit_le, 'j_<'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j<_'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j_<'
+ end
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_32bit_le, 'j<!'
- it_behaves_like :string_unpack_32bit_le, 'j!<'
- it_behaves_like :string_unpack_32bit_le_signed, 'j<!'
- it_behaves_like :string_unpack_32bit_le_signed, 'j!<'
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'j<!'
+ it_behaves_like :string_unpack_32bit_le, 'j!<'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j<!'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j!<'
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_32bit_be, 'j>_'
- it_behaves_like :string_unpack_32bit_be, 'j_>'
- it_behaves_like :string_unpack_32bit_be_signed, 'j>_'
- it_behaves_like :string_unpack_32bit_be_signed, 'j_>'
- end
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'j>_'
+ it_behaves_like :string_unpack_32bit_be, 'j_>'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j>_'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j_>'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_32bit_be, 'j>!'
- it_behaves_like :string_unpack_32bit_be, 'j!>'
- it_behaves_like :string_unpack_32bit_be_signed, 'j>!'
- it_behaves_like :string_unpack_32bit_be_signed, 'j!>'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'j>!'
+ it_behaves_like :string_unpack_32bit_be, 'j!>'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j>!'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j!>'
+ end
end
end
end
diff --git a/spec/ruby/core/string/unpack/l_spec.rb b/spec/ruby/core/string/unpack/l_spec.rb
index 18bb68b8d0..11f0648fc7 100644
--- a/spec/ruby/core/string/unpack/l_spec.rb
+++ b/spec/ruby/core/string/unpack/l_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "String#unpack with format 'L'" do
describe "with modifier '<'" do
@@ -14,7 +14,7 @@ describe "String#unpack with format 'L'" do
it_behaves_like :string_unpack_32bit_be_unsigned, 'L>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'L<_'
it_behaves_like :string_unpack_32bit_le, 'L_<'
@@ -44,7 +44,7 @@ describe "String#unpack with format 'L'" do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_64bit_le, 'L<_'
it_behaves_like :string_unpack_64bit_le, 'L_<'
@@ -86,7 +86,7 @@ describe "String#unpack with format 'l'" do
it_behaves_like :string_unpack_32bit_be_signed, 'l>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'l<_'
it_behaves_like :string_unpack_32bit_le, 'l_<'
@@ -116,7 +116,7 @@ describe "String#unpack with format 'l'" do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_64bit_le, 'l<_'
it_behaves_like :string_unpack_64bit_le, 'l_<'
@@ -160,7 +160,7 @@ little_endian do
it_behaves_like :string_unpack_32bit_le_signed, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_le, 'L_'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L_'
@@ -182,7 +182,7 @@ little_endian do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_64bit_le, 'L_'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L_'
@@ -218,7 +218,7 @@ big_endian do
it_behaves_like :string_unpack_32bit_be_signed, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_be, 'L_'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L_'
@@ -240,7 +240,7 @@ big_endian do
end
end
- platform_is wordsize: 64 do
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_64bit_be, 'L_'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L_'
diff --git a/spec/ruby/core/string/unpack/m_spec.rb b/spec/ruby/core/string/unpack/m_spec.rb
index 96841f24cb..104f282fed 100644
--- a/spec/ruby/core/string/unpack/m_spec.rb
+++ b/spec/ruby/core/string/unpack/m_spec.rb
@@ -1,13 +1,11 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "String#unpack with format 'M'" do
it_behaves_like :string_unpack_basic, 'M'
it_behaves_like :string_unpack_no_platform, 'M'
- it_behaves_like :string_unpack_taint, 'M'
it "decodes an empty string" do
"".unpack("M").should == [""]
@@ -102,7 +100,6 @@ end
describe "String#unpack with format 'm'" do
it_behaves_like :string_unpack_basic, 'm'
it_behaves_like :string_unpack_no_platform, 'm'
- it_behaves_like :string_unpack_taint, 'm'
it "decodes an empty string" do
"".unpack("m").should == [""]
diff --git a/spec/ruby/core/string/unpack/n_spec.rb b/spec/ruby/core/string/unpack/n_spec.rb
index 09173f4fcb..6e85346338 100644
--- a/spec/ruby/core/string/unpack/n_spec.rb
+++ b/spec/ruby/core/string/unpack/n_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "String#unpack with format 'N'" do
it_behaves_like :string_unpack_basic, 'N'
diff --git a/spec/ruby/core/string/unpack/p_spec.rb b/spec/ruby/core/string/unpack/p_spec.rb
index 3e187d674f..7c9a502a15 100644
--- a/spec/ruby/core/string/unpack/p_spec.rb
+++ b/spec/ruby/core/string/unpack/p_spec.rb
@@ -1,56 +1,21 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/taint'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "String#unpack with format 'P'" do
it_behaves_like :string_unpack_basic, 'P'
- it_behaves_like :string_unpack_taint, 'P'
- it "round-trips a string through pack and unpack" do
- ["hello"].pack("P").unpack("P5").should == ["hello"]
- end
-
- it "cannot unpack a string except from the same object that created it, or a duplicate of it" do
- packed = ["hello"].pack("P")
- packed.unpack("P5").should == ["hello"]
- packed.dup.unpack("P5").should == ["hello"]
- -> { packed.to_sym.to_s.unpack("P5") }.should raise_error(ArgumentError, /no associated pointer/)
- end
-
- ruby_version_is ''...'2.7' do
- it "taints the unpacked string" do
- ["hello"].pack("P").unpack("P5").first.tainted?.should be_true
- end
- end
-
- it "reads as many characters as specified" do
- ["hello"].pack("P").unpack("P1").should == ["h"]
- end
-
- it "reads only as far as a NUL character" do
- ["hello"].pack("P").unpack("P10").should == ["hello"]
+ it "returns a random object after consuming a size-of a machine word bytes" do
+ str = "\0" * 1.size
+ str.unpack("P").should be_kind_of(Object)
end
end
describe "String#unpack with format 'p'" do
it_behaves_like :string_unpack_basic, 'p'
- it_behaves_like :string_unpack_taint, 'p'
-
- it "round-trips a string through pack and unpack" do
- ["hello"].pack("p").unpack("p").should == ["hello"]
- end
-
- it "cannot unpack a string except from the same object that created it, or a duplicate of it" do
- packed = ["hello"].pack("p")
- packed.unpack("p").should == ["hello"]
- packed.dup.unpack("p").should == ["hello"]
- -> { packed.to_sym.to_s.unpack("p") }.should raise_error(ArgumentError, /no associated pointer/)
- end
- ruby_version_is ''...'2.7' do
- it "taints the unpacked string" do
- ["hello"].pack("p").unpack("p").first.tainted?.should be_true
- end
+ it "returns a random object after consuming a size-of a machine word bytes" do
+ str = "\0" * 1.size
+ str.unpack("p").should be_kind_of(Object)
end
end
diff --git a/spec/ruby/core/string/unpack/percent_spec.rb b/spec/ruby/core/string/unpack/percent_spec.rb
index 0e27663195..38cf81b037 100644
--- a/spec/ruby/core/string/unpack/percent_spec.rb
+++ b/spec/ruby/core/string/unpack/percent_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "String#unpack with format '%'" do
it "raises an Argument Error" do
- -> { "abc".unpack("%") }.should raise_error(ArgumentError)
+ lambda { "abc".unpack("%") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/string/unpack/q_spec.rb b/spec/ruby/core/string/unpack/q_spec.rb
index 2f667d6c4d..91e65a9405 100644
--- a/spec/ruby/core/string/unpack/q_spec.rb
+++ b/spec/ruby/core/string/unpack/q_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "String#unpack with format 'Q'" do
describe "with modifier '<'" do
diff --git a/spec/ruby/core/string/unpack/s_spec.rb b/spec/ruby/core/string/unpack/s_spec.rb
index d331fd720e..c6b079b0a6 100644
--- a/spec/ruby/core/string/unpack/s_spec.rb
+++ b/spec/ruby/core/string/unpack/s_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "String#unpack with format 'S'" do
describe "with modifier '<'" do
diff --git a/spec/ruby/core/string/unpack/shared/basic.rb b/spec/ruby/core/string/unpack/shared/basic.rb
index 332e39d8d1..0ecbf615af 100644
--- a/spec/ruby/core/string/unpack/shared/basic.rb
+++ b/spec/ruby/core/string/unpack/shared/basic.rb
@@ -10,20 +10,20 @@ describe :string_unpack_basic, shared: true do
end
it "raises a TypeError when passed nil" do
- -> { "abc".unpack(nil) }.should raise_error(TypeError)
+ lambda { "abc".unpack(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed an Integer" do
- -> { "abc".unpack(1) }.should raise_error(TypeError)
+ lambda { "abc".unpack(1) }.should raise_error(TypeError)
end
end
describe :string_unpack_no_platform, shared: true do
it "raises an ArgumentError when the format modifier is '_'" do
- -> { "abcdefgh".unpack(unpack_format("_")) }.should raise_error(ArgumentError)
+ lambda { "abcdefgh".unpack(unpack_format("_")) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the format modifier is '!'" do
- -> { "abcdefgh".unpack(unpack_format("!")) }.should raise_error(ArgumentError)
+ lambda { "abcdefgh".unpack(unpack_format("!")) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/string/unpack/shared/float.rb b/spec/ruby/core/string/unpack/shared/float.rb
index 99bd8a3401..208dc357af 100644
--- a/spec/ruby/core/string/unpack/shared/float.rb
+++ b/spec/ruby/core/string/unpack/shared/float.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
describe :string_unpack_float_le, shared: true do
it "decodes one float for a single format character" do
diff --git a/spec/ruby/core/string/unpack/shared/integer.rb b/spec/ruby/core/string/unpack/shared/integer.rb
index cbaa743683..03dfb5c682 100644
--- a/spec/ruby/core/string/unpack/shared/integer.rb
+++ b/spec/ruby/core/string/unpack/shared/integer.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
describe :string_unpack_16bit_le, shared: true do
it "decodes one short for a single format character" do
diff --git a/spec/ruby/core/string/unpack/shared/taint.rb b/spec/ruby/core/string/unpack/shared/taint.rb
deleted file mode 100644
index 061a3e26ad..0000000000
--- a/spec/ruby/core/string/unpack/shared/taint.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-describe :string_unpack_taint, shared: true do
- ruby_version_is ''...'2.7' do
- it "does not taint returned arrays if given an untainted format string" do
- "".unpack(unpack_format(2)).tainted?.should be_false
- end
-
- it "does not taint returned arrays if given a tainted format string" do
- format_string = unpack_format(2).dup
- format_string.taint
- "".unpack(format_string).tainted?.should be_false
- end
-
- it "does not taint returned strings if given an untainted format string" do
- "".unpack(unpack_format(2)).any?(&:tainted?).should be_false
- end
-
- it "does not taint returned strings if given a tainted format string" do
- format_string = unpack_format(2).dup
- format_string.taint
- "".unpack(format_string).any?(&:tainted?).should be_false
- end
-
- it "does not taint returned arrays if given an untainted packed string" do
- "".unpack(unpack_format(2)).tainted?.should be_false
- end
-
- it "does not taint returned arrays if given a tainted packed string" do
- packed_string = ""
- packed_string.taint
- packed_string.unpack(unpack_format(2)).tainted?.should be_false
- end
-
- it "does not taint returned strings if given an untainted packed string" do
- "".unpack(unpack_format(2)).any?(&:tainted?).should be_false
- end
-
- it "taints returned strings if given a tainted packed string" do
- packed_string = ""
- packed_string.taint
- packed_string.unpack(unpack_format(2)).all?(&:tainted?).should be_true
- end
-
- it "does not untrust returned arrays if given an untrusted format string" do
- "".unpack(unpack_format(2)).untrusted?.should be_false
- end
-
- it "does not untrust returned arrays if given a untrusted format string" do
- format_string = unpack_format(2).dup
- format_string.untrust
- "".unpack(format_string).untrusted?.should be_false
- end
-
- it "does not untrust returned strings if given an untainted format string" do
- "".unpack(unpack_format(2)).any?(&:untrusted?).should be_false
- end
-
- it "does not untrust returned strings if given a untrusted format string" do
- format_string = unpack_format(2).dup
- format_string.untrust
- "".unpack(format_string).any?(&:untrusted?).should be_false
- end
-
- it "does not untrust returned arrays if given an trusted packed string" do
- "".unpack(unpack_format(2)).untrusted?.should be_false
- end
-
- it "does not untrust returned arrays if given a untrusted packed string" do
- packed_string = ""
- packed_string.untrust
- packed_string.unpack(unpack_format(2)).untrusted?.should be_false
- end
-
- it "does not untrust returned strings if given an trusted packed string" do
- "".unpack(unpack_format(2)).any?(&:untrusted?).should be_false
- end
-
- it "untrusts returned strings if given a untrusted packed string" do
- packed_string = ""
- packed_string.untrust
- packed_string.unpack(unpack_format(2)).all?(&:untrusted?).should be_true
- end
- end
-end
diff --git a/spec/ruby/core/string/unpack/u_spec.rb b/spec/ruby/core/string/unpack/u_spec.rb
index 7845e6d5f2..0765da8d96 100644
--- a/spec/ruby/core/string/unpack/u_spec.rb
+++ b/spec/ruby/core/string/unpack/u_spec.rb
@@ -1,29 +1,26 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/unicode'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/unicode', __FILE__)
describe "String#unpack with format 'U'" do
it_behaves_like :string_unpack_basic, 'U'
it_behaves_like :string_unpack_no_platform, 'U'
it_behaves_like :string_unpack_unicode, 'U'
- it_behaves_like :string_unpack_taint, 'U'
it "raises ArgumentError on a malformed byte sequence" do
- -> { "\xE3".unpack('U') }.should raise_error(ArgumentError)
+ lambda { "\xE3".unpack('U') }.should raise_error(ArgumentError)
end
it "raises ArgumentError on a malformed byte sequence and doesn't continue when used with the * modifier" do
- -> { "\xE3".unpack('U*') }.should raise_error(ArgumentError)
+ lambda { "\xE3".unpack('U*') }.should raise_error(ArgumentError)
end
end
describe "String#unpack with format 'u'" do
it_behaves_like :string_unpack_basic, 'u'
it_behaves_like :string_unpack_no_platform, 'u'
- it_behaves_like :string_unpack_taint, 'u'
it "decodes an empty string as an empty string" do
"".unpack("u").should == [""]
@@ -31,10 +28,10 @@ describe "String#unpack with format 'u'" do
it "decodes into raw (ascii) string values" do
str = "".unpack("u")[0]
- str.encoding.should == Encoding::BINARY
+ str.encoding.name.should == 'ASCII-8BIT'
str = "1".force_encoding('UTF-8').unpack("u")[0]
- str.encoding.should == Encoding::BINARY
+ str.encoding.name.should == 'ASCII-8BIT'
end
it "decodes the complete string ignoring newlines when given a single directive" do
diff --git a/spec/ruby/core/string/unpack/v_spec.rb b/spec/ruby/core/string/unpack/v_spec.rb
index 929e8712cb..33cf23c68b 100644
--- a/spec/ruby/core/string/unpack/v_spec.rb
+++ b/spec/ruby/core/string/unpack/v_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/integer'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/integer', __FILE__)
describe "String#unpack with format 'V'" do
it_behaves_like :string_unpack_basic, 'V'
diff --git a/spec/ruby/core/string/unpack/w_spec.rb b/spec/ruby/core/string/unpack/w_spec.rb
index 166ae58869..22f5980a46 100644
--- a/spec/ruby/core/string/unpack/w_spec.rb
+++ b/spec/ruby/core/string/unpack/w_spec.rb
@@ -1,7 +1,7 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "String#unpack with directive 'w'" do
it_behaves_like :string_unpack_basic, 'w'
diff --git a/spec/ruby/core/string/unpack/x_spec.rb b/spec/ruby/core/string/unpack/x_spec.rb
index 5e248de77e..e765472413 100644
--- a/spec/ruby/core/string/unpack/x_spec.rb
+++ b/spec/ruby/core/string/unpack/x_spec.rb
@@ -1,7 +1,7 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
describe "String#unpack with format 'X'" do
it_behaves_like :string_unpack_basic, 'X'
@@ -24,11 +24,11 @@ describe "String#unpack with format 'X'" do
end
it "raises an ArgumentError when passed the '*' modifier if the remaining bytes exceed the bytes from the index to the start of the String" do
- -> { "abcd".unpack("CX*C") }.should raise_error(ArgumentError)
+ lambda { "abcd".unpack("CX*C") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the count exceeds the bytes from current index to the start of the String" do
- -> { "\x01\x02\x03\x04".unpack("C3X4C") }.should raise_error(ArgumentError)
+ lambda { "\x01\x02\x03\x04".unpack("C3X4C") }.should raise_error(ArgumentError)
end
end
@@ -57,6 +57,6 @@ describe "String#unpack with format 'x'" do
end
it "raises an ArgumentError if the count exceeds the size of the String" do
- -> { "\x01\x02\x03\x04".unpack("C2x3C") }.should raise_error(ArgumentError)
+ lambda { "\x01\x02\x03\x04".unpack("C2x3C") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/string/unpack/z_spec.rb b/spec/ruby/core/string/unpack/z_spec.rb
index 552851ce04..7c3d167ac2 100644
--- a/spec/ruby/core/string/unpack/z_spec.rb
+++ b/spec/ruby/core/string/unpack/z_spec.rb
@@ -1,15 +1,13 @@
-# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/basic'
-require_relative 'shared/string'
-require_relative 'shared/taint'
+# -*- encoding: ascii-8bit -*-
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/basic', __FILE__)
+require File.expand_path('../shared/string', __FILE__)
describe "String#unpack with format 'Z'" do
it_behaves_like :string_unpack_basic, 'Z'
it_behaves_like :string_unpack_no_platform, 'Z'
it_behaves_like :string_unpack_string, 'Z'
- it_behaves_like :string_unpack_taint, 'Z'
it "stops decoding at NULL bytes when passed the '*' modifier" do
"a\x00\x00 b \x00c".unpack('Z*Z*Z*Z*').should == ["a", "", " b ", "c"]
diff --git a/spec/ruby/core/string/unpack1_spec.rb b/spec/ruby/core/string/unpack1_spec.rb
index 5fe81733fb..6941bc1173 100644
--- a/spec/ruby/core/string/unpack1_spec.rb
+++ b/spec/ruby/core/string/unpack1_spec.rb
@@ -1,10 +1,12 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "String#unpack1" do
- it "returns the first value of #unpack" do
- "ABCD".unpack1('x3C').should == "ABCD".unpack('x3C')[0]
- "\u{3042 3044 3046}".unpack1("U*").should == 0x3042
- "aG9nZWZ1Z2E=".unpack1("m").should == "hogefuga"
- "A".unpack1("B*").should == "01000001"
+ruby_version_is "2.4" do
+ describe "String#unpack1" do
+ it "returns the first value of #unpack" do
+ "ABCD".unpack1('x3C').should == "ABCD".unpack('x3C')[0]
+ "\u{3042 3044 3046}".unpack1("U*").should == 0x3042
+ "aG9nZWZ1Z2E=".unpack1("m").should == "hogefuga"
+ "A".unpack1("B*").should == "01000001"
+ end
end
end
diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb
index eb7d708fe0..0094380664 100644
--- a/spec/ruby/core/string/upcase_spec.rb
+++ b/spec/ruby/core/string/upcase_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#upcase" do
it "returns a copy of self with all lowercase letters upcased" do
@@ -8,69 +8,30 @@ describe "String#upcase" do
"hello".upcase.should == "HELLO"
end
- describe "full Unicode case mapping" do
- it "works for all of Unicode with no option" do
- "äöü".upcase.should == "ÄÖÜ"
- end
-
- it "updates string metadata" do
- upcased = "aßet".upcase
-
- upcased.should == "ASSET"
- upcased.size.should == 5
- upcased.bytesize.should == 5
- upcased.ascii_only?.should be_true
- end
- end
+ ruby_version_is ''...'2.4' do
+ it "is locale insensitive (only replaces a-z)" do
+ "äöü".upcase.should == "äöü"
- describe "ASCII-only case mapping" do
- it "does not upcase non-ASCII characters" do
- "aßet".upcase(:ascii).should == "AßET"
- end
- end
-
- describe "full Unicode case mapping adapted for Turkic languages" do
- it "upcases ASCII characters according to Turkic semantics" do
- "i".upcase(:turkic).should == "İ"
- end
-
- it "allows Lithuanian as an extra option" do
- "i".upcase(:turkic, :lithuanian).should == "İ"
- end
+ str = Array.new(256) { |c| c.chr }.join
+ expected = Array.new(256) do |i|
+ c = i.chr
+ c.between?("a", "z") ? c.upcase : c
+ end.join
- it "does not allow any other additional option" do
- -> { "i".upcase(:turkic, :ascii) }.should raise_error(ArgumentError)
+ str.upcase.should == expected
end
end
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- "iß".upcase(:lithuanian).should == "ISS"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- "iß".upcase(:lithuanian, :turkic).should == "İSS"
- end
-
- it "does not allow any other additional option" do
- -> { "iß".upcase(:lithuanian, :ascii) }.should raise_error(ArgumentError)
+ ruby_version_is '2.4' do
+ it "works for all of Unicode" do
+ "äöü".upcase.should == "ÄÖÜ"
end
end
- it "does not allow the :fold option for upcasing" do
- -> { "abc".upcase(:fold) }.should raise_error(ArgumentError)
- end
-
- it "does not allow invalid options" do
- -> { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError)
- end
-
- ruby_version_is ''...'2.7' do
- it "taints result when self is tainted" do
- "".taint.upcase.tainted?.should == true
- "X".taint.upcase.tainted?.should == true
- "x".taint.upcase.tainted?.should == true
- end
+ it "taints result when self is tainted" do
+ "".taint.upcase.tainted?.should == true
+ "X".taint.upcase.tainted?.should == true
+ "x".taint.upcase.tainted?.should == true
end
it "returns a subclass instance for subclasses" do
@@ -85,74 +46,13 @@ describe "String#upcase!" do
a.should == "HELLO"
end
- describe "full Unicode case mapping" do
- it "modifies self in place for all of Unicode with no option" do
+
+ ruby_version_is '2.4' do
+ it "modifies self in place for all of Unicode" do
a = "äöü"
- a.upcase!
+ a.upcase!.should equal(a)
a.should == "ÄÖÜ"
end
-
- it "updates string metadata for self" do
- upcased = "aßet"
- upcased.upcase!
-
- upcased.should == "ASSET"
- upcased.size.should == 5
- upcased.bytesize.should == 5
- upcased.ascii_only?.should be_true
- end
- end
-
- describe "modifies self in place for ASCII-only case mapping" do
- it "does not upcase non-ASCII characters" do
- a = "aßet"
- a.upcase!(:ascii)
- a.should == "AßET"
- end
- end
-
- describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do
- it "upcases ASCII characters according to Turkic semantics" do
- a = "i"
- a.upcase!(:turkic)
- a.should == "İ"
- end
-
- it "allows Lithuanian as an extra option" do
- a = "i"
- a.upcase!(:turkic, :lithuanian)
- a.should == "İ"
- end
-
- it "does not allow any other additional option" do
- -> { a = "i"; a.upcase!(:turkic, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- describe "modifies self in place for full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- a = "iß"
- a.upcase!(:lithuanian)
- a.should == "ISS"
- end
-
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- a = "iß"
- a.upcase!(:lithuanian, :turkic)
- a.should == "İSS"
- end
-
- it "does not allow any other additional option" do
- -> { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError)
- end
- end
-
- it "does not allow the :fold option for upcasing" do
- -> { a = "abc"; a.upcase!(:fold) }.should raise_error(ArgumentError)
- end
-
- it "does not allow invalid options" do
- -> { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError)
end
it "returns nil if no modifications were made" do
@@ -161,8 +61,8 @@ describe "String#upcase!" do
a.should == "HELLO"
end
- it "raises a #{frozen_error_class} when self is frozen" do
- -> { "HeLlo".freeze.upcase! }.should raise_error(frozen_error_class)
- -> { "HELLO".freeze.upcase! }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when self is frozen" do
+ lambda { "HeLlo".freeze.upcase! }.should raise_error(RuntimeError)
+ lambda { "HELLO".freeze.upcase! }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/string/uplus_spec.rb b/spec/ruby/core/string/uplus_spec.rb
index a7402b4549..eafa721903 100644
--- a/spec/ruby/core/string/uplus_spec.rb
+++ b/spec/ruby/core/string/uplus_spec.rb
@@ -1,22 +1,24 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe 'String#+@' do
- it 'returns an unfrozen copy of a frozen String' do
- input = 'foo'.freeze
- output = +input
+ruby_version_is "2.3" do
+ describe 'String#+@' do
+ it 'returns an unfrozen copy of a frozen String' do
+ input = 'foo'.freeze
+ output = +input
- output.frozen?.should == false
- output.should == 'foo'
- end
+ output.frozen?.should == false
+ output.should == 'foo'
+ end
- it 'returns self if the String is not frozen' do
- input = 'foo'
- output = +input
+ it 'returns self if the String is not frozen' do
+ input = 'foo'
+ output = +input
- output.equal?(input).should == true
- end
+ output.equal?(input).should == true
+ end
- it 'returns mutable copy despite freeze-magic-comment in file' do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment.rb")).should == 'mutable'
+ it 'returns mutable copy despite freeze-magic-comment in file' do
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment.rb")).should == 'mutable'
+ end
end
end
diff --git a/spec/ruby/core/string/upto_spec.rb b/spec/ruby/core/string/upto_spec.rb
index b988613a80..6b998eed3c 100644
--- a/spec/ruby/core/string/upto_spec.rb
+++ b/spec/ruby/core/string/upto_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes.rb', __FILE__)
describe "String#upto" do
it "passes successive values, starting at self and ending at other_string, to the block" do
@@ -8,7 +8,7 @@ describe "String#upto" do
a.should == ["*+", "*,", "*-", "*.", "*/", "*0", "*1", "*2", "*3"]
end
- it "calls the block once even when start equals stop" do
+ it "calls the block once even when start eqals stop" do
a = []
"abc".upto("abc") { |s| a << s }
a.should == ["abc"]
@@ -53,13 +53,13 @@ describe "String#upto" do
end
it "raises a TypeError if other can't be converted to a string" do
- -> { "abc".upto(123) { } }.should raise_error(TypeError)
- -> { "abc".upto(mock('x')){ } }.should raise_error(TypeError)
+ lambda { "abc".upto(123) { } }.should raise_error(TypeError)
+ lambda { "abc".upto(mock('x')){ } }.should raise_error(TypeError)
end
it "does not work with symbols" do
- -> { "a".upto(:c).to_a }.should raise_error(TypeError)
+ lambda { "a".upto(:c).to_a }.should raise_error(TypeError)
end
it "returns non-alphabetic characters in the ASCII range for single letters" do
diff --git a/spec/ruby/core/string/valid_encoding_spec.rb b/spec/ruby/core/string/valid_encoding_spec.rb
index 09916df079..ddd0fe52a2 100644
--- a/spec/ruby/core/string/valid_encoding_spec.rb
+++ b/spec/ruby/core/string/valid_encoding_spec.rb
@@ -1,127 +1,129 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "String#valid_encoding?" do
- it "returns true if the String's encoding is valid" do
- "a".valid_encoding?.should be_true
- "\u{8365}\u{221}".valid_encoding?.should be_true
- end
+with_feature :encoding do
+ describe "String#valid_encoding?" do
+ it "returns true if the String's encoding is valid" do
+ "a".valid_encoding?.should be_true
+ "\u{8365}\u{221}".valid_encoding?.should be_true
+ end
- it "returns true if self is valid in the current encoding and other encodings" do
- str = "\x77"
- str.force_encoding('utf-8').valid_encoding?.should be_true
- str.force_encoding('binary').valid_encoding?.should be_true
- end
+ it "returns true if self is valid in the current encoding and other encodings" do
+ str = "\x77"
+ str.force_encoding('utf-8').valid_encoding?.should be_true
+ str.force_encoding('ascii-8bit').valid_encoding?.should be_true
+ end
- it "returns true for all encodings self is valid in" do
- str = "\u{6754}"
- str.force_encoding('BINARY').valid_encoding?.should be_true
- str.force_encoding('UTF-8').valid_encoding?.should be_true
- str.force_encoding('US-ASCII').valid_encoding?.should be_false
- str.force_encoding('Big5').valid_encoding?.should be_false
- str.force_encoding('CP949').valid_encoding?.should be_false
- str.force_encoding('Emacs-Mule').valid_encoding?.should be_false
- str.force_encoding('EUC-JP').valid_encoding?.should be_false
- str.force_encoding('EUC-KR').valid_encoding?.should be_false
- str.force_encoding('EUC-TW').valid_encoding?.should be_false
- str.force_encoding('GB18030').valid_encoding?.should be_false
- str.force_encoding('GBK').valid_encoding?.should be_false
- str.force_encoding('ISO-8859-1').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-2').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-3').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-4').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-5').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-6').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-7').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-8').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-9').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-10').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-11').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-13').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-14').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-15').valid_encoding?.should be_true
- str.force_encoding('ISO-8859-16').valid_encoding?.should be_true
- str.force_encoding('KOI8-R').valid_encoding?.should be_true
- str.force_encoding('KOI8-U').valid_encoding?.should be_true
- str.force_encoding('Shift_JIS').valid_encoding?.should be_false
- str.force_encoding('UTF-16BE').valid_encoding?.should be_false
- str.force_encoding('UTF-16LE').valid_encoding?.should be_false
- str.force_encoding('UTF-32BE').valid_encoding?.should be_false
- str.force_encoding('UTF-32LE').valid_encoding?.should be_false
- str.force_encoding('Windows-1251').valid_encoding?.should be_true
- str.force_encoding('IBM437').valid_encoding?.should be_true
- str.force_encoding('IBM737').valid_encoding?.should be_true
- str.force_encoding('IBM775').valid_encoding?.should be_true
- str.force_encoding('CP850').valid_encoding?.should be_true
- str.force_encoding('IBM852').valid_encoding?.should be_true
- str.force_encoding('CP852').valid_encoding?.should be_true
- str.force_encoding('IBM855').valid_encoding?.should be_true
- str.force_encoding('CP855').valid_encoding?.should be_true
- str.force_encoding('IBM857').valid_encoding?.should be_true
- str.force_encoding('IBM860').valid_encoding?.should be_true
- str.force_encoding('IBM861').valid_encoding?.should be_true
- str.force_encoding('IBM862').valid_encoding?.should be_true
- str.force_encoding('IBM863').valid_encoding?.should be_true
- str.force_encoding('IBM864').valid_encoding?.should be_true
- str.force_encoding('IBM865').valid_encoding?.should be_true
- str.force_encoding('IBM866').valid_encoding?.should be_true
- str.force_encoding('IBM869').valid_encoding?.should be_true
- str.force_encoding('Windows-1258').valid_encoding?.should be_true
- str.force_encoding('GB1988').valid_encoding?.should be_true
- str.force_encoding('macCentEuro').valid_encoding?.should be_true
- str.force_encoding('macCroatian').valid_encoding?.should be_true
- str.force_encoding('macCyrillic').valid_encoding?.should be_true
- str.force_encoding('macGreek').valid_encoding?.should be_true
- str.force_encoding('macIceland').valid_encoding?.should be_true
- str.force_encoding('macRoman').valid_encoding?.should be_true
- str.force_encoding('macRomania').valid_encoding?.should be_true
- str.force_encoding('macThai').valid_encoding?.should be_true
- str.force_encoding('macTurkish').valid_encoding?.should be_true
- str.force_encoding('macUkraine').valid_encoding?.should be_true
- str.force_encoding('stateless-ISO-2022-JP').valid_encoding?.should be_false
- str.force_encoding('eucJP-ms').valid_encoding?.should be_false
- str.force_encoding('CP51932').valid_encoding?.should be_false
- str.force_encoding('GB2312').valid_encoding?.should be_false
- str.force_encoding('GB12345').valid_encoding?.should be_false
- str.force_encoding('ISO-2022-JP').valid_encoding?.should be_true
- str.force_encoding('ISO-2022-JP-2').valid_encoding?.should be_true
- str.force_encoding('CP50221').valid_encoding?.should be_true
- str.force_encoding('Windows-1252').valid_encoding?.should be_true
- str.force_encoding('Windows-1250').valid_encoding?.should be_true
- str.force_encoding('Windows-1256').valid_encoding?.should be_true
- str.force_encoding('Windows-1253').valid_encoding?.should be_true
- str.force_encoding('Windows-1255').valid_encoding?.should be_true
- str.force_encoding('Windows-1254').valid_encoding?.should be_true
- str.force_encoding('TIS-620').valid_encoding?.should be_true
- str.force_encoding('Windows-874').valid_encoding?.should be_true
- str.force_encoding('Windows-1257').valid_encoding?.should be_true
- str.force_encoding('Windows-31J').valid_encoding?.should be_false
- str.force_encoding('MacJapanese').valid_encoding?.should be_false
- str.force_encoding('UTF-7').valid_encoding?.should be_true
- str.force_encoding('UTF8-MAC').valid_encoding?.should be_true
- end
+ it "returns true for all encodings self is valid in" do
+ str = "\u{6754}"
+ str.force_encoding('ASCII-8BIT').valid_encoding?.should be_true
+ str.force_encoding('UTF-8').valid_encoding?.should be_true
+ str.force_encoding('US-ASCII').valid_encoding?.should be_false
+ str.force_encoding('Big5').valid_encoding?.should be_false
+ str.force_encoding('CP949').valid_encoding?.should be_false
+ str.force_encoding('Emacs-Mule').valid_encoding?.should be_false
+ str.force_encoding('EUC-JP').valid_encoding?.should be_false
+ str.force_encoding('EUC-KR').valid_encoding?.should be_false
+ str.force_encoding('EUC-TW').valid_encoding?.should be_false
+ str.force_encoding('GB18030').valid_encoding?.should be_false
+ str.force_encoding('GBK').valid_encoding?.should be_false
+ str.force_encoding('ISO-8859-1').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-2').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-3').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-4').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-5').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-6').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-7').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-8').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-9').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-10').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-11').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-13').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-14').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-15').valid_encoding?.should be_true
+ str.force_encoding('ISO-8859-16').valid_encoding?.should be_true
+ str.force_encoding('KOI8-R').valid_encoding?.should be_true
+ str.force_encoding('KOI8-U').valid_encoding?.should be_true
+ str.force_encoding('Shift_JIS').valid_encoding?.should be_false
+ str.force_encoding('UTF-16BE').valid_encoding?.should be_false
+ str.force_encoding('UTF-16LE').valid_encoding?.should be_false
+ str.force_encoding('UTF-32BE').valid_encoding?.should be_false
+ str.force_encoding('UTF-32LE').valid_encoding?.should be_false
+ str.force_encoding('Windows-1251').valid_encoding?.should be_true
+ str.force_encoding('IBM437').valid_encoding?.should be_true
+ str.force_encoding('IBM737').valid_encoding?.should be_true
+ str.force_encoding('IBM775').valid_encoding?.should be_true
+ str.force_encoding('CP850').valid_encoding?.should be_true
+ str.force_encoding('IBM852').valid_encoding?.should be_true
+ str.force_encoding('CP852').valid_encoding?.should be_true
+ str.force_encoding('IBM855').valid_encoding?.should be_true
+ str.force_encoding('CP855').valid_encoding?.should be_true
+ str.force_encoding('IBM857').valid_encoding?.should be_true
+ str.force_encoding('IBM860').valid_encoding?.should be_true
+ str.force_encoding('IBM861').valid_encoding?.should be_true
+ str.force_encoding('IBM862').valid_encoding?.should be_true
+ str.force_encoding('IBM863').valid_encoding?.should be_true
+ str.force_encoding('IBM864').valid_encoding?.should be_true
+ str.force_encoding('IBM865').valid_encoding?.should be_true
+ str.force_encoding('IBM866').valid_encoding?.should be_true
+ str.force_encoding('IBM869').valid_encoding?.should be_true
+ str.force_encoding('Windows-1258').valid_encoding?.should be_true
+ str.force_encoding('GB1988').valid_encoding?.should be_true
+ str.force_encoding('macCentEuro').valid_encoding?.should be_true
+ str.force_encoding('macCroatian').valid_encoding?.should be_true
+ str.force_encoding('macCyrillic').valid_encoding?.should be_true
+ str.force_encoding('macGreek').valid_encoding?.should be_true
+ str.force_encoding('macIceland').valid_encoding?.should be_true
+ str.force_encoding('macRoman').valid_encoding?.should be_true
+ str.force_encoding('macRomania').valid_encoding?.should be_true
+ str.force_encoding('macThai').valid_encoding?.should be_true
+ str.force_encoding('macTurkish').valid_encoding?.should be_true
+ str.force_encoding('macUkraine').valid_encoding?.should be_true
+ str.force_encoding('stateless-ISO-2022-JP').valid_encoding?.should be_false
+ str.force_encoding('eucJP-ms').valid_encoding?.should be_false
+ str.force_encoding('CP51932').valid_encoding?.should be_false
+ str.force_encoding('GB2312').valid_encoding?.should be_false
+ str.force_encoding('GB12345').valid_encoding?.should be_false
+ str.force_encoding('ISO-2022-JP').valid_encoding?.should be_true
+ str.force_encoding('ISO-2022-JP-2').valid_encoding?.should be_true
+ str.force_encoding('CP50221').valid_encoding?.should be_true
+ str.force_encoding('Windows-1252').valid_encoding?.should be_true
+ str.force_encoding('Windows-1250').valid_encoding?.should be_true
+ str.force_encoding('Windows-1256').valid_encoding?.should be_true
+ str.force_encoding('Windows-1253').valid_encoding?.should be_true
+ str.force_encoding('Windows-1255').valid_encoding?.should be_true
+ str.force_encoding('Windows-1254').valid_encoding?.should be_true
+ str.force_encoding('TIS-620').valid_encoding?.should be_true
+ str.force_encoding('Windows-874').valid_encoding?.should be_true
+ str.force_encoding('Windows-1257').valid_encoding?.should be_true
+ str.force_encoding('Windows-31J').valid_encoding?.should be_false
+ str.force_encoding('MacJapanese').valid_encoding?.should be_false
+ str.force_encoding('UTF-7').valid_encoding?.should be_true
+ str.force_encoding('UTF8-MAC').valid_encoding?.should be_true
+ end
- it "returns false if self is valid in one encoding, but invalid in the one it's tagged with" do
- str = "\u{8765}"
- str.valid_encoding?.should be_true
- str = str.force_encoding('ascii')
- str.valid_encoding?.should be_false
- end
+ it "returns false if self is valid in one encoding, but invalid in the one it's tagged with" do
+ str = "\u{8765}"
+ str.valid_encoding?.should be_true
+ str = str.force_encoding('ascii')
+ str.valid_encoding?.should be_false
+ end
- it "returns false if self contains a character invalid in the associated encoding" do
- "abc#{[0x80].pack('C')}".force_encoding('ascii').valid_encoding?.should be_false
- end
+ it "returns false if self contains a character invalid in the associated encoding" do
+ "abc#{[0x80].pack('C')}".force_encoding('ascii').valid_encoding?.should be_false
+ end
- it "returns false if a valid String had an invalid character appended to it" do
- str = "a"
- str.valid_encoding?.should be_true
- str << [0xDD].pack('C').force_encoding('utf-8')
- str.valid_encoding?.should be_false
- end
+ it "returns false if a valid String had an invalid character appended to it" do
+ str = "a"
+ str.valid_encoding?.should be_true
+ str << [0xDD].pack('C').force_encoding('utf-8')
+ str.valid_encoding?.should be_false
+ end
- it "returns true if an invalid string is appended another invalid one but both make a valid string" do
- str = [0xD0].pack('C').force_encoding('utf-8')
- str.valid_encoding?.should be_false
- str << [0xBF].pack('C').force_encoding('utf-8')
- str.valid_encoding?.should be_true
+ it "returns true if an invalid string is appended another invalid one but both make a valid string" do
+ str = [0xD0].pack('C').force_encoding('utf-8')
+ str.valid_encoding?.should be_false
+ str << [0xBF].pack('C').force_encoding('utf-8')
+ str.valid_encoding?.should be_true
+ end
end
end
diff --git a/spec/ruby/core/struct/clone_spec.rb b/spec/ruby/core/struct/clone_spec.rb
deleted file mode 100644
index 40c4d52d57..0000000000
--- a/spec/ruby/core/struct/clone_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/dup'
-
-describe "Struct-based class#clone" do
- it_behaves_like :struct_dup, :clone
-end
diff --git a/spec/ruby/core/struct/dig_spec.rb b/spec/ruby/core/struct/dig_spec.rb
index 4e39e5a4ef..c222eec9e4 100644
--- a/spec/ruby/core/struct/dig_spec.rb
+++ b/spec/ruby/core/struct/dig_spec.rb
@@ -1,42 +1,44 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Struct#dig" do
- before(:each) do
- @klass = Struct.new(:a)
- @instance = @klass.new(@klass.new({ b: [1, 2, 3] }))
- end
+ruby_version_is "2.3" do
+ describe "Struct#dig" do
+ before(:each) do
+ @klass = Struct.new(:a)
+ @instance = @klass.new(@klass.new({ b: [1, 2, 3] }))
+ end
- it "returns the nested value specified by the sequence of keys" do
- @instance.dig(:a, :a).should == { b: [1, 2, 3] }
- end
+ it "returns the nested value specified by the sequence of keys" do
+ @instance.dig(:a, :a).should == { b: [1, 2, 3] }
+ end
- it "returns the nested value specified if the sequence includes an index" do
- @instance.dig(:a, :a, :b, 0).should == 1
- end
+ it "returns the nested value specified if the sequence includes an index" do
+ @instance.dig(:a, :a, :b, 0).should == 1
+ end
- it "returns nil if any intermediate step is nil" do
- @instance.dig(:b, 0).should == nil
- end
+ it "returns nil if any intermediate step is nil" do
+ @instance.dig(:b, 0).should == nil
+ end
- it "raises a TypeError if any intermediate step does not respond to #dig" do
- instance = @klass.new(1)
- -> {
- instance.dig(:a, 3)
- }.should raise_error(TypeError)
- end
+ it "raises a TypeError if any intermediate step does not respond to #dig" do
+ instance = @klass.new(1)
+ lambda {
+ instance.dig(:a, 3)
+ }.should raise_error(TypeError)
+ end
- it "raises an ArgumentError if no arguments provided" do
- -> { @instance.dig }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError if no arguments provided" do
+ lambda { @instance.dig }.should raise_error(ArgumentError)
+ end
- it "calls #dig on any intermediate step with the rest of the sequence as arguments" do
- obj = Object.new
- instance = @klass.new(obj)
+ it "calls #dig on any intermediate step with the rest of the sequence as arguments" do
+ obj = Object.new
+ instance = @klass.new(obj)
- def obj.dig(*args)
- {dug: args}
- end
+ def obj.dig(*args)
+ {dug: args}
+ end
- instance.dig(:a, :bar, :baz).should == { dug: [:bar, :baz] }
+ instance.dig(:a, :bar, :baz).should == { dug: [:bar, :baz] }
+ end
end
end
diff --git a/spec/ruby/core/struct/dup_spec.rb b/spec/ruby/core/struct/dup_spec.rb
index 8b50c39014..d1da31d6d5 100644
--- a/spec/ruby/core/struct/dup_spec.rb
+++ b/spec/ruby/core/struct/dup_spec.rb
@@ -1,11 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/dup'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct-based class#dup" do
- it_behaves_like :struct_dup, :dup
-
# From https://github.com/jruby/jruby/issues/3686
it "retains an included module in the ancestor chain for the struct's singleton class" do
klass = Struct.new(:foo)
diff --git a/spec/ruby/core/struct/each_pair_spec.rb b/spec/ruby/core/struct/each_pair_spec.rb
index 1230ca9026..79a962a6ad 100644
--- a/spec/ruby/core/struct/each_pair_spec.rb
+++ b/spec/ruby/core/struct/each_pair_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/accessor'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Struct#each_pair" do
before :each do
diff --git a/spec/ruby/core/struct/each_spec.rb b/spec/ruby/core/struct/each_spec.rb
index 41c0fbd4d0..86302d91c6 100644
--- a/spec/ruby/core/struct/each_spec.rb
+++ b/spec/ruby/core/struct/each_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/accessor'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Struct#each" do
it "passes each value to the given block" do
diff --git a/spec/ruby/core/struct/element_reference_spec.rb b/spec/ruby/core/struct/element_reference_spec.rb
index 0f6d547f66..dc51fbfff1 100644
--- a/spec/ruby/core/struct/element_reference_spec.rb
+++ b/spec/ruby/core/struct/element_reference_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct[]" do
it "is a synonym for new" do
@@ -26,20 +26,20 @@ describe "Struct#[]" do
it "fails when it does not know about the requested attribute" do
car = StructClasses::Car.new('Ford', 'Ranger')
- -> { car[3] }.should raise_error(IndexError)
- -> { car[-4] }.should raise_error(IndexError)
- -> { car[:body] }.should raise_error(NameError)
- -> { car['wheels'] }.should raise_error(NameError)
+ lambda { car[3] }.should raise_error(IndexError)
+ lambda { car[-4] }.should raise_error(IndexError)
+ lambda { car[:body] }.should raise_error(NameError)
+ lambda { car['wheels'] }.should raise_error(NameError)
end
it "fails if passed too many arguments" do
car = StructClasses::Car.new('Ford', 'Ranger')
- -> { car[:make, :model] }.should raise_error(ArgumentError)
+ lambda { car[:make, :model] }.should raise_error(ArgumentError)
end
it "fails if not passed a string, symbol, or integer" do
car = StructClasses::Car.new('Ford', 'Ranger')
- -> { car[Object.new] }.should raise_error(TypeError)
+ lambda { car[Object.new] }.should raise_error(TypeError)
end
it "returns attribute names that contain hyphens" do
diff --git a/spec/ruby/core/struct/element_set_spec.rb b/spec/ruby/core/struct/element_set_spec.rb
index 6ba7b081a9..3d482bdb71 100644
--- a/spec/ruby/core/struct/element_set_spec.rb
+++ b/spec/ruby/core/struct/element_set_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct#[]=" do
it "assigns the passed value" do
@@ -21,9 +21,9 @@ describe "Struct#[]=" do
it "fails when trying to assign attributes which don't exist" do
car = StructClasses::Car.new('Ford', 'Ranger')
- -> { car[:something] = true }.should raise_error(NameError)
- -> { car[3] = true }.should raise_error(IndexError)
- -> { car[-4] = true }.should raise_error(IndexError)
- -> { car[Object.new] = true }.should raise_error(TypeError)
+ lambda { car[:something] = true }.should raise_error(NameError)
+ lambda { car[3] = true }.should raise_error(IndexError)
+ lambda { car[-4] = true }.should raise_error(IndexError)
+ lambda { car[Object.new] = true }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/struct/eql_spec.rb b/spec/ruby/core/struct/eql_spec.rb
index c864b2b943..dfa97811c6 100644
--- a/spec/ruby/core/struct/eql_spec.rb
+++ b/spec/ruby/core/struct/eql_spec.rb
@@ -1,13 +1,13 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Struct#eql?" do
- it_behaves_like :struct_equal_value, :eql?
+ it_behaves_like(:struct_equal_value, :eql?)
it "returns false if any corresponding elements are not #eql?" do
car = StructClasses::Car.new("Honda", "Accord", 1998)
similar_car = StructClasses::Car.new("Honda", "Accord", 1998.0)
- car.should_not eql(similar_car)
+ car.send(@method, similar_car).should be_false
end
end
diff --git a/spec/ruby/core/struct/equal_value_spec.rb b/spec/ruby/core/struct/equal_value_spec.rb
index 0c0f7ba570..a343213417 100644
--- a/spec/ruby/core/struct/equal_value_spec.rb
+++ b/spec/ruby/core/struct/equal_value_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
describe "Struct#==" do
- it_behaves_like :struct_equal_value, :==
+ it_behaves_like(:struct_equal_value, :==)
end
diff --git a/spec/ruby/core/struct/filter_spec.rb b/spec/ruby/core/struct/filter_spec.rb
deleted file mode 100644
index 1105ed064a..0000000000
--- a/spec/ruby/core/struct/filter_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
-require_relative 'shared/accessor'
-require_relative '../enumerable/shared/enumeratorized'
-
-ruby_version_is "2.6" do
- describe "Struct#filter" do
- it_behaves_like :struct_select, :filter
- it_behaves_like :struct_accessor, :filter
- it_behaves_like :enumeratorized_with_origin_size, :filter, Struct.new(:foo).new
- end
-end
diff --git a/spec/ruby/core/struct/hash_spec.rb b/spec/ruby/core/struct/hash_spec.rb
index 71e8ccbd3a..517d3ab44e 100644
--- a/spec/ruby/core/struct/hash_spec.rb
+++ b/spec/ruby/core/struct/hash_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/accessor'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
describe "Struct#hash" do
diff --git a/spec/ruby/core/struct/initialize_spec.rb b/spec/ruby/core/struct/initialize_spec.rb
index e82289071a..989459114a 100644
--- a/spec/ruby/core/struct/initialize_spec.rb
+++ b/spec/ruby/core/struct/initialize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct#initialize" do
diff --git a/spec/ruby/core/struct/inspect_spec.rb b/spec/ruby/core/struct/inspect_spec.rb
index 83e13597ba..94fb71a5f1 100644
--- a/spec/ruby/core/struct/inspect_spec.rb
+++ b/spec/ruby/core/struct/inspect_spec.rb
@@ -1,12 +1,15 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/inspect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "Struct#inspect" do
- it "returns a string representation showing members and values" do
+ it "returns a string representation of some kind" do
car = StructClasses::Car.new('Ford', 'Ranger')
car.inspect.should == '#<struct StructClasses::Car make="Ford", model="Ranger", year=nil>'
+
+ Whiskey = Struct.new(:name, :ounces)
+ Whiskey.new('Jack', 100).inspect.should == '#<struct Whiskey name="Jack", ounces=100>'
end
- it_behaves_like :struct_inspect, :inspect
+ it_behaves_like(:struct_inspect, :inspect)
end
diff --git a/spec/ruby/core/struct/instance_variable_get_spec.rb b/spec/ruby/core/struct/instance_variable_get_spec.rb
deleted file mode 100644
index e4a3ea87dc..0000000000
--- a/spec/ruby/core/struct/instance_variable_get_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Struct#instance_variable_get" do
- it "returns nil for attributes" do
- car = StructClasses::Car.new("Hugo", "Foo", "1972")
- car.instance_variable_get(:@make).should be_nil
- end
-
- it "returns a user value for variables with the same name as attributes" do
- car = StructClasses::Car.new("Hugo", "Foo", "1972")
- car.instance_variable_set :@make, "explicit"
- car.instance_variable_get(:@make).should == "explicit"
- car.make.should == "Hugo"
- end
-end
diff --git a/spec/ruby/core/struct/instance_variables_spec.rb b/spec/ruby/core/struct/instance_variables_spec.rb
index f6d30ea97e..3abb8578a5 100644
--- a/spec/ruby/core/struct/instance_variables_spec.rb
+++ b/spec/ruby/core/struct/instance_variables_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct#instance_variables" do
it "returns an empty array if only attributes are defined" do
diff --git a/spec/ruby/core/struct/length_spec.rb b/spec/ruby/core/struct/length_spec.rb
index 1143676122..067bb08f88 100644
--- a/spec/ruby/core/struct/length_spec.rb
+++ b/spec/ruby/core/struct/length_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/accessor'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
describe "Struct#length" do
it "returns the number of attributes" do
diff --git a/spec/ruby/core/struct/members_spec.rb b/spec/ruby/core/struct/members_spec.rb
index 1f2ff950d9..702e536a55 100644
--- a/spec/ruby/core/struct/members_spec.rb
+++ b/spec/ruby/core/struct/members_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/accessor'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
describe "Struct#members" do
it "returns an array of attribute names" do
diff --git a/spec/ruby/core/struct/new_spec.rb b/spec/ruby/core/struct/new_spec.rb
index 564c49af01..f43e764cb8 100644
--- a/spec/ruby/core/struct/new_spec.rb
+++ b/spec/ruby/core/struct/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct.new" do
it "creates a constant in Struct namespace with string as first argument" do
@@ -13,7 +13,7 @@ describe "Struct.new" do
first.should == Struct::Person
second = nil
- -> {
+ lambda {
second = Struct.new('Person', :hair, :sex)
}.should complain(/redefining constant/)
second.should == Struct::Person
@@ -49,39 +49,35 @@ describe "Struct.new" do
it "fails with invalid constant name as first argument" do
- -> { Struct.new('animal', :name, :legs, :eyeballs) }.should raise_error(NameError)
+ lambda { Struct.new('animal', :name, :legs, :eyeballs) }.should raise_error(NameError)
end
it "raises a TypeError if object doesn't respond to to_sym" do
- -> { Struct.new(:animal, mock('giraffe')) }.should raise_error(TypeError)
- -> { Struct.new(:animal, 1.0) }.should raise_error(TypeError)
- -> { Struct.new(:animal, Time.now) }.should raise_error(TypeError)
- -> { Struct.new(:animal, Class) }.should raise_error(TypeError)
- -> { Struct.new(:animal, nil) }.should raise_error(TypeError)
- -> { Struct.new(:animal, true) }.should raise_error(TypeError)
- -> { Struct.new(:animal, ['chris', 'evan']) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, mock('giraffe')) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, 1.0) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, Time.now) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, Class) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, nil) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, true) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, ['chris', 'evan']) }.should raise_error(TypeError)
end
ruby_version_is ""..."2.5" do
it "raises a TypeError if an argument is a Hash" do
- -> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, { name: 'chris' }) }.should raise_error(TypeError)
end
end
ruby_version_is "2.5" do
it "raises a ArgumentError if passed a Hash with an unknown key" do
- -> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(ArgumentError)
+ lambda { Struct.new(:animal, { name: 'chris' }) }.should raise_error(ArgumentError)
end
end
- it "raises ArgumentError when there is a duplicate member" do
- -> { Struct.new(:foo, :foo) }.should raise_error(ArgumentError, "duplicate member: foo")
- end
-
it "raises a TypeError if object is not a Symbol" do
obj = mock(':ruby')
def obj.to_sym() :ruby end
- -> { Struct.new(:animal, obj) }.should raise_error(TypeError)
+ lambda { Struct.new(:animal, obj) }.should raise_error(TypeError)
end
it "processes passed block with instance_eval" do
@@ -132,86 +128,7 @@ describe "Struct.new" do
end
it "fails with too many arguments" do
- -> { StructClasses::Ruby.new('2.0', 'i686', true) }.should raise_error(ArgumentError)
- end
-
- it "passes a hash as a normal argument" do
- type = Struct.new(:args)
-
- obj = type.new(keyword: :arg)
- obj2 = type.new(*[{keyword: :arg}])
-
- obj.should == obj2
- obj.args.should == {keyword: :arg}
- obj2.args.should == {keyword: :arg}
- end
- end
-
- ruby_version_is "2.5" do
- context "keyword_init: true option" do
- before :all do
- @struct_with_kwa = Struct.new(:name, :legs, keyword_init: true)
- end
-
- it "creates a class that accepts keyword arguments to initialize" do
- obj = @struct_with_kwa.new(name: "elefant", legs: 4)
- obj.name.should == "elefant"
- obj.legs.should == 4
- end
-
- it "raises when there is a duplicate member" do
- -> { Struct.new(:foo, :foo, keyword_init: true) }.should raise_error(ArgumentError, "duplicate member: foo")
- end
-
- describe "new class instantiation" do
- it "accepts arguments as hash as well" do
- obj = @struct_with_kwa.new({name: "elefant", legs: 4})
- obj.name.should == "elefant"
- obj.legs.should == 4
- end
-
- it "allows missing arguments" do
- obj = @struct_with_kwa.new(name: "elefant")
- obj.name.should == "elefant"
- obj.legs.should be_nil
- end
-
- it "allows no arguments" do
- obj = @struct_with_kwa.new
- obj.name.should be_nil
- obj.legs.should be_nil
- end
-
- it "raises ArgumentError when passed not declared keyword argument" do
- -> {
- @struct_with_kwa.new(name: "elefant", legs: 4, foo: "bar")
- }.should raise_error(ArgumentError, /unknown keywords: foo/)
- end
-
- it "raises ArgumentError when passed a list of arguments" do
- -> {
- @struct_with_kwa.new("elefant", 4)
- }.should raise_error(ArgumentError, /wrong number of arguments/)
- end
-
- it "raises ArgumentError when passed a single non-hash argument" do
- -> {
- @struct_with_kwa.new("elefant")
- }.should raise_error(ArgumentError, /wrong number of arguments/)
- end
- end
- end
-
- context "keyword_init: false option" do
- before :all do
- @struct_without_kwa = Struct.new(:name, :legs, keyword_init: false)
- end
-
- it "behaves like it does without :keyword_init option" do
- obj = @struct_without_kwa.new("elefant", 4)
- obj.name.should == "elefant"
- obj.legs.should == 4
- end
+ lambda { StructClasses::Ruby.new('2.0', 'i686', true) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/struct/select_spec.rb b/spec/ruby/core/struct/select_spec.rb
index ee846ec45f..da80eea0e8 100644
--- a/spec/ruby/core/struct/select_spec.rb
+++ b/spec/ruby/core/struct/select_spec.rb
@@ -1,10 +1,30 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
-require_relative 'shared/accessor'
-require_relative '../enumerable/shared/enumeratorized'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
+require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
describe "Struct#select" do
- it_behaves_like :struct_select, :select
+ it "raises an ArgumentError if given any non-block arguments" do
+ lambda { StructClasses::Car.new.select(1) { } }.should raise_error(ArgumentError)
+ end
+
+ it "returns a new array of elements for which block is true" do
+ struct = StructClasses::Car.new("Toyota", "Tercel", "2000")
+ struct.select { |i| i == "2000" }.should == [ "2000" ]
+ end
+
+ it "returns an instance of Array" do
+ struct = StructClasses::Car.new("Ford", "Escort", "1995")
+ struct.select { true }.should be_an_instance_of(Array)
+ end
+
+ describe "without block" do
+ it "returns an instance of Enumerator" do
+ struct = Struct.new(:foo).new
+ struct.select.should be_an_instance_of(Enumerator)
+ end
+ end
+
it_behaves_like :struct_accessor, :select
it_behaves_like :enumeratorized_with_origin_size, :select, Struct.new(:foo).new
end
diff --git a/spec/ruby/core/struct/shared/dup.rb b/spec/ruby/core/struct/shared/dup.rb
deleted file mode 100644
index 994f3f443e..0000000000
--- a/spec/ruby/core/struct/shared/dup.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-describe :struct_dup, shared: true do
- it "duplicates members" do
- klass = Struct.new(:foo, :bar)
- instance = klass.new(14, 2)
- duped = instance.send(@method)
- duped.foo.should == 14
- duped.bar.should == 2
- end
-end
diff --git a/spec/ruby/core/struct/shared/equal_value.rb b/spec/ruby/core/struct/shared/equal_value.rb
index a7e0856df5..711862cb44 100644
--- a/spec/ruby/core/struct/shared/equal_value.rb
+++ b/spec/ruby/core/struct/shared/equal_value.rb
@@ -16,13 +16,6 @@ describe :struct_equal_value, shared: true do
car.send(@method, different_car).should == false
end
- it "returns false if other is of a different class" do
- car = StructClasses::Car.new("Honda", "Accord", "1998")
- klass = Struct.new(:make, :model, :year)
- clone = klass.new("Honda", "Accord", "1998")
- car.send(@method, clone).should == false
- end
-
it "handles recursive structures by returning false if a difference can be found" do
x = StructClasses::Car.new("Honda", "Accord", "1998")
x[:make] = x
diff --git a/spec/ruby/core/struct/shared/select.rb b/spec/ruby/core/struct/shared/select.rb
deleted file mode 100644
index 35abee461b..0000000000
--- a/spec/ruby/core/struct/shared/select.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-
-describe :struct_select, shared: true do
- it "raises an ArgumentError if given any non-block arguments" do
- struct = StructClasses::Car.new
- -> { struct.send(@method, 1) { } }.should raise_error(ArgumentError)
- end
-
- it "returns a new array of elements for which block is true" do
- struct = StructClasses::Car.new("Toyota", "Tercel", "2000")
- struct.send(@method) { |i| i == "2000" }.should == [ "2000" ]
- end
-
- it "returns an instance of Array" do
- struct = StructClasses::Car.new("Ford", "Escort", "1995")
- struct.send(@method) { true }.should be_an_instance_of(Array)
- end
-
- describe "without block" do
- it "returns an instance of Enumerator" do
- struct = Struct.new(:foo).new
- struct.send(@method).should be_an_instance_of(Enumerator)
- end
- end
-end
diff --git a/spec/ruby/core/struct/size_spec.rb b/spec/ruby/core/struct/size_spec.rb
index 09f260cf20..29b1d2bfba 100644
--- a/spec/ruby/core/struct/size_spec.rb
+++ b/spec/ruby/core/struct/size_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/accessor'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
describe "Struct#size" do
it "is a synonym for length" do
diff --git a/spec/ruby/core/struct/struct_spec.rb b/spec/ruby/core/struct/struct_spec.rb
index 8817dc1a58..6c1941aed5 100644
--- a/spec/ruby/core/struct/struct_spec.rb
+++ b/spec/ruby/core/struct/struct_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct" do
it "includes Enumerable" do
@@ -21,7 +21,7 @@ describe "Struct anonymous class instance methods" do
it "reader method should not interfere with undefined methods" do
car = StructClasses::Car.new('Ford', 'Ranger')
- -> { car.something_weird }.should raise_error(NoMethodError)
+ lambda { car.something_weird }.should raise_error(NoMethodError)
end
it "writer method be a synonym for []=" do
diff --git a/spec/ruby/core/struct/tms/cstime_spec.rb b/spec/ruby/core/struct/tms/cstime_spec.rb
new file mode 100644
index 0000000000..839b02b6e9
--- /dev/null
+++ b/spec/ruby/core/struct/tms/cstime_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe "Struct::Tms#cstime" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "Struct::Tms#cstime=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/struct/tms/cutime_spec.rb b/spec/ruby/core/struct/tms/cutime_spec.rb
new file mode 100644
index 0000000000..235f378fab
--- /dev/null
+++ b/spec/ruby/core/struct/tms/cutime_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe "Struct::Tms#cutime" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "Struct::Tms#cutime=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/struct/tms/element_reference_spec.rb b/spec/ruby/core/struct/tms/element_reference_spec.rb
new file mode 100644
index 0000000000..f1735341b4
--- /dev/null
+++ b/spec/ruby/core/struct/tms/element_reference_spec.rb
@@ -0,0 +1,5 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe "Struct::Tms.[]" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/struct/tms/members_spec.rb b/spec/ruby/core/struct/tms/members_spec.rb
new file mode 100644
index 0000000000..ddfca83659
--- /dev/null
+++ b/spec/ruby/core/struct/tms/members_spec.rb
@@ -0,0 +1,5 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe "Struct::Tms.members" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/struct/tms/new_spec.rb b/spec/ruby/core/struct/tms/new_spec.rb
new file mode 100644
index 0000000000..cf7a501aa2
--- /dev/null
+++ b/spec/ruby/core/struct/tms/new_spec.rb
@@ -0,0 +1,5 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe "Struct::Tms.new" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/struct/tms/stime_spec.rb b/spec/ruby/core/struct/tms/stime_spec.rb
new file mode 100644
index 0000000000..f45253cf44
--- /dev/null
+++ b/spec/ruby/core/struct/tms/stime_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe "Struct::Tms#stime" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "Struct::Tms#stime=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/struct/tms/utime_spec.rb b/spec/ruby/core/struct/tms/utime_spec.rb
new file mode 100644
index 0000000000..ea6783a17b
--- /dev/null
+++ b/spec/ruby/core/struct/tms/utime_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe "Struct::Tms#utime" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "Struct::Tms#utime=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/core/struct/to_a_spec.rb b/spec/ruby/core/struct/to_a_spec.rb
index cb61dc45cc..f8e9a3658d 100644
--- a/spec/ruby/core/struct/to_a_spec.rb
+++ b/spec/ruby/core/struct/to_a_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/accessor'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/accessor', __FILE__)
describe "Struct#to_a" do
it "returns the values for this instance as an array" do
diff --git a/spec/ruby/core/struct/to_h_spec.rb b/spec/ruby/core/struct/to_h_spec.rb
index b5f4e40701..6b8037f950 100644
--- a/spec/ruby/core/struct/to_h_spec.rb
+++ b/spec/ruby/core/struct/to_h_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct#to_h" do
it "returns a Hash with members as keys" do
@@ -12,47 +12,4 @@ describe "Struct#to_h" do
car.to_h[:make] = 'Suzuki'
car.make.should == 'Ford'
end
-
- ruby_version_is "2.6" do
- context "with block" do
- it "converts [key, value] pairs returned by the block to a hash" do
- car = StructClasses::Car.new('Ford', 'Ranger')
-
- h = car.to_h { |k, v| [k.to_s, "#{v}".downcase] }
- h.should == { "make" => "ford", "model" => "ranger", "year" => "" }
- end
-
- it "raises ArgumentError if block returns longer or shorter array" do
- -> do
- StructClasses::Car.new.to_h { |k, v| [k.to_s, "#{v}".downcase, 1] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
-
- -> do
- StructClasses::Car.new.to_h { |k, v| [k] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
- end
-
- it "raises TypeError if block returns something other than Array" do
- -> do
- StructClasses::Car.new.to_h { |k, v| "not-array" }
- end.should raise_error(TypeError, /wrong element type String/)
- end
-
- it "coerces returned pair to Array with #to_ary" do
- x = mock('x')
- x.stub!(:to_ary).and_return([:b, 'b'])
-
- StructClasses::Car.new.to_h { |k| x }.should == { :b => 'b' }
- end
-
- it "does not coerce returned pair to Array with #to_a" do
- x = mock('x')
- x.stub!(:to_a).and_return([:b, 'b'])
-
- -> do
- StructClasses::Car.new.to_h { |k| x }
- end.should raise_error(TypeError, /wrong element type MockObject/)
- end
- end
- end
end
diff --git a/spec/ruby/core/struct/to_s_spec.rb b/spec/ruby/core/struct/to_s_spec.rb
index 94c672d3d5..b9fd413093 100644
--- a/spec/ruby/core/struct/to_s_spec.rb
+++ b/spec/ruby/core/struct/to_s_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/inspect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "Struct#to_s" do
it "is a synonym for inspect" do
@@ -8,5 +8,5 @@ describe "Struct#to_s" do
car.inspect.should == car.to_s
end
- it_behaves_like :struct_inspect, :to_s
+ it_behaves_like(:struct_inspect, :to_s)
end
diff --git a/spec/ruby/core/struct/values_at_spec.rb b/spec/ruby/core/struct/values_at_spec.rb
index 7e517cdb4b..58016e2f2a 100644
--- a/spec/ruby/core/struct/values_at_spec.rb
+++ b/spec/ruby/core/struct/values_at_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct#values_at" do
it "returns an array of values" do
@@ -11,6 +11,6 @@ describe "Struct#values_at" do
it "fails when passed unsupported types" do
car = StructClasses::Car.new('Ford', 'Ranger')
- -> { car.values_at('make') }.should raise_error(TypeError)
+ lambda { car.values_at('make') }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/struct/values_spec.rb b/spec/ruby/core/struct/values_spec.rb
index b2d11725b9..0e86d33cb5 100644
--- a/spec/ruby/core/struct/values_spec.rb
+++ b/spec/ruby/core/struct/values_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Struct#values" do
it "is a synonym for to_a" do
diff --git a/spec/ruby/core/symbol/all_symbols_spec.rb b/spec/ruby/core/symbol/all_symbols_spec.rb
index ef2b4f85e6..d18d58ba48 100644
--- a/spec/ruby/core/symbol/all_symbols_spec.rb
+++ b/spec/ruby/core/symbol/all_symbols_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol.all_symbols" do
it "returns an array containing all the Symbols in the symbol table" do
diff --git a/spec/ruby/core/symbol/capitalize_spec.rb b/spec/ruby/core/symbol/capitalize_spec.rb
index a84bcf280a..73850a2a8c 100644
--- a/spec/ruby/core/symbol/capitalize_spec.rb
+++ b/spec/ruby/core/symbol/capitalize_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#capitalize" do
it "returns a Symbol" do
@@ -14,9 +14,18 @@ describe "Symbol#capitalize" do
:"£1.20".capitalize.should == :"£1.20"
end
- it "capitalizes the first character if it is Unicode" do
- :"äöü".capitalize.should == :"Äöü"
- :"aou".capitalize.should == :"Aou"
+ ruby_version_is ''...'2.4' do
+ it "leaves the first character alone if it is not an alphabetical ASCII character" do
+ "\u{00DE}c".to_sym.capitalize.should == :"Þc"
+ "\u{00DF}C".to_sym.capitalize.should == :"ßc"
+ end
+ end
+
+ ruby_version_is '2.4' do
+ it "capitalizes the first character if it is Unicode" do
+ :"äöü".capitalize.should == :"Äöü"
+ :"aou".capitalize.should == :"Aou"
+ end
end
it "converts subsequent uppercase ASCII characters to their lowercase equivalents" do
@@ -31,6 +40,12 @@ describe "Symbol#capitalize" do
:mIxEd.capitalize.should == :Mixed
end
+ ruby_version_is ''...'2.4' do
+ it "leaves uppercase Unicode characters as they were" do
+ "a\u{00DE}c".to_sym.capitalize.should == :"AÞc"
+ end
+ end
+
it "leaves lowercase Unicode characters (except in first position) as they were" do
"a\u{00DF}C".to_sym.capitalize.should == :"Aßc"
end
diff --git a/spec/ruby/core/symbol/case_compare_spec.rb b/spec/ruby/core/symbol/case_compare_spec.rb
index 0c6bc1eda5..5c705c0b04 100644
--- a/spec/ruby/core/symbol/case_compare_spec.rb
+++ b/spec/ruby/core/symbol/case_compare_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#===" do
it "returns true when the argument is a Symbol" do
diff --git a/spec/ruby/core/symbol/casecmp_spec.rb b/spec/ruby/core/symbol/casecmp_spec.rb
index b485101d63..352c5b99cb 100644
--- a/spec/ruby/core/symbol/casecmp_spec.rb
+++ b/spec/ruby/core/symbol/casecmp_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#casecmp with Symbol" do
it "compares symbols without regard to case" do
@@ -73,72 +73,74 @@ describe "Symbol#casecmp" do
end
end
-describe 'Symbol#casecmp?' do
- it "compares symbols without regard to case" do
- :abcdef.casecmp?(:abcde).should == false
- :aBcDeF.casecmp?(:abcdef).should == true
- :abcdef.casecmp?(:abcdefg).should == false
- :abcdef.casecmp?(:ABCDEF).should == true
- end
-
- it "doesn't consider non-ascii characters equal that aren't" do
- # -- Latin-1 --
- upper_a_tilde = "\xC3".b.to_sym
- upper_a_umlaut = "\xC4".b.to_sym
- lower_a_tilde = "\xE3".b.to_sym
- lower_a_umlaut = "\xE4".b.to_sym
-
- lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true
- lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true
- upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true
- upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true
-
- # -- UTF-8 --
- upper_a_tilde = :"Ã"
- lower_a_tilde = :"ã"
- upper_a_umlaut = :"Ä"
- lower_a_umlaut = :"ä"
-
- lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true
- lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true
- upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true
- upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true
- end
-
- it "doesn't do case mapping for non-ascii and non-unicode characters" do
- # -- Latin-1 --
- upper_a_tilde = "\xC3".b.to_sym
- upper_a_umlaut = "\xC4".b.to_sym
- lower_a_tilde = "\xE3".b.to_sym
- lower_a_umlaut = "\xE4".b.to_sym
-
- upper_a_tilde.casecmp?(lower_a_tilde).should == false
- upper_a_umlaut.casecmp?(lower_a_umlaut).should == false
- lower_a_tilde.casecmp?(upper_a_tilde).should == false
- lower_a_umlaut.casecmp?(upper_a_umlaut).should == false
- end
-
- it 'does case mapping for unicode characters' do
- # -- UTF-8 --
- upper_a_tilde = :"Ã"
- lower_a_tilde = :"ã"
- upper_a_umlaut = :"Ä"
- lower_a_umlaut = :"ä"
-
- upper_a_tilde.casecmp?(lower_a_tilde).should == true
- upper_a_umlaut.casecmp?(lower_a_umlaut).should == true
- lower_a_tilde.casecmp?(upper_a_tilde).should == true
- lower_a_umlaut.casecmp?(upper_a_umlaut).should == true
- end
-
- it 'returns nil when comparing characters with different encodings' do
- # -- Latin-1 --
- upper_a_tilde = "\xC3".b.to_sym
-
- # -- UTF-8 --
- lower_a_tilde = :"ã"
-
- upper_a_tilde.casecmp?(lower_a_tilde).should == nil
- lower_a_tilde.casecmp?(upper_a_tilde).should == nil
+ruby_version_is "2.4" do
+ describe 'Symbol#casecmp?' do
+ it "compares symbols without regard to case" do
+ :abcdef.casecmp?(:abcde).should == false
+ :aBcDeF.casecmp?(:abcdef).should == true
+ :abcdef.casecmp?(:abcdefg).should == false
+ :abcdef.casecmp?(:ABCDEF).should == true
+ end
+
+ it "doesn't consider non-ascii characters equal that aren't" do
+ # -- Latin-1 --
+ upper_a_tilde = "\xC3".b.to_sym
+ upper_a_umlaut = "\xC4".b.to_sym
+ lower_a_tilde = "\xE3".b.to_sym
+ lower_a_umlaut = "\xE4".b.to_sym
+
+ lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true
+ lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true
+ upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true
+ upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true
+
+ # -- UTF-8 --
+ upper_a_tilde = :"Ã"
+ lower_a_tilde = :"ã"
+ upper_a_umlaut = :"Ä"
+ lower_a_umlaut = :"ä"
+
+ lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true
+ lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true
+ upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true
+ upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true
+ end
+
+ it "doesn't do case mapping for non-ascii and non-unicode characters" do
+ # -- Latin-1 --
+ upper_a_tilde = "\xC3".b.to_sym
+ upper_a_umlaut = "\xC4".b.to_sym
+ lower_a_tilde = "\xE3".b.to_sym
+ lower_a_umlaut = "\xE4".b.to_sym
+
+ upper_a_tilde.casecmp?(lower_a_tilde).should == false
+ upper_a_umlaut.casecmp?(lower_a_umlaut).should == false
+ lower_a_tilde.casecmp?(upper_a_tilde).should == false
+ lower_a_umlaut.casecmp?(upper_a_umlaut).should == false
+ end
+
+ it 'does case mapping for unicode characters' do
+ # -- UTF-8 --
+ upper_a_tilde = :"Ã"
+ lower_a_tilde = :"ã"
+ upper_a_umlaut = :"Ä"
+ lower_a_umlaut = :"ä"
+
+ upper_a_tilde.casecmp?(lower_a_tilde).should == true
+ upper_a_umlaut.casecmp?(lower_a_umlaut).should == true
+ lower_a_tilde.casecmp?(upper_a_tilde).should == true
+ lower_a_umlaut.casecmp?(upper_a_umlaut).should == true
+ end
+
+ it 'returns nil when comparing characters with different encodings' do
+ # -- Latin-1 --
+ upper_a_tilde = "\xC3".b.to_sym
+
+ # -- UTF-8 --
+ lower_a_tilde = :"ã"
+
+ upper_a_tilde.casecmp?(lower_a_tilde).should == nil
+ lower_a_tilde.casecmp?(upper_a_tilde).should == nil
+ end
end
end
diff --git a/spec/ruby/core/symbol/comparison_spec.rb b/spec/ruby/core/symbol/comparison_spec.rb
index 173a7da625..91edd1f0d9 100644
--- a/spec/ruby/core/symbol/comparison_spec.rb
+++ b/spec/ruby/core/symbol/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#<=> with Symbol" do
it "compares individual characters based on their ascii value" do
diff --git a/spec/ruby/core/symbol/downcase_spec.rb b/spec/ruby/core/symbol/downcase_spec.rb
index 7e94c669cc..6eb19e087a 100644
--- a/spec/ruby/core/symbol/downcase_spec.rb
+++ b/spec/ruby/core/symbol/downcase_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#downcase" do
it "returns a Symbol" do
@@ -14,9 +14,17 @@ describe "Symbol#downcase" do
"\u{E0}Bc".to_sym.downcase.should == :"àbc"
end
- it "uncapitalizes all Unicode characters" do
- "ÄÖÜ".to_sym.downcase.should == :"äöü"
- "AOU".to_sym.downcase.should == :"aou"
+ ruby_version_is ''...'2.4' do
+ it "leaves uppercase Unicode characters as they were" do
+ "\u{DE}Bc".to_sym.downcase.should == :"Þbc"
+ end
+ end
+
+ ruby_version_is '2.4' do
+ it "uncapitalizes all Unicode characters" do
+ "ÄÖÜ".to_sym.downcase.should == :"äöü"
+ "AOU".to_sym.downcase.should == :"aou"
+ end
end
it "leaves non-alphabetic ASCII characters as they were" do
diff --git a/spec/ruby/core/symbol/dup_spec.rb b/spec/ruby/core/symbol/dup_spec.rb
index 8b35917c27..2ca4d84078 100644
--- a/spec/ruby/core/symbol/dup_spec.rb
+++ b/spec/ruby/core/symbol/dup_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "Symbol#dup" do
- it "returns self" do
- :a_symbol.dup.should equal(:a_symbol)
+ruby_version_is '2.4' do
+ describe "Symbol#dup" do
+ it "returns self" do
+ :a_symbol.dup.should equal(:a_symbol)
+ end
end
end
diff --git a/spec/ruby/core/symbol/element_reference_spec.rb b/spec/ruby/core/symbol/element_reference_spec.rb
index df6bc15ddb..4116274ee0 100644
--- a/spec/ruby/core/symbol/element_reference_spec.rb
+++ b/spec/ruby/core/symbol/element_reference_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/slice'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/slice.rb', __FILE__)
describe "Symbol#[]" do
- it_behaves_like :symbol_slice, :[]
+ it_behaves_like(:symbol_slice, :[])
end
diff --git a/spec/ruby/core/symbol/empty_spec.rb b/spec/ruby/core/symbol/empty_spec.rb
index 19c23cfe5f..7be0007355 100644
--- a/spec/ruby/core/symbol/empty_spec.rb
+++ b/spec/ruby/core/symbol/empty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#empty?" do
it "returns true if self is empty" do
diff --git a/spec/ruby/core/symbol/encoding_spec.rb b/spec/ruby/core/symbol/encoding_spec.rb
index 732fd62e26..b6128562b9 100644
--- a/spec/ruby/core/symbol/encoding_spec.rb
+++ b/spec/ruby/core/symbol/encoding_spec.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#encoding for ASCII symbols" do
it "is US-ASCII" do
diff --git a/spec/ruby/core/symbol/equal_value_spec.rb b/spec/ruby/core/symbol/equal_value_spec.rb
index 3fe997d02a..7c305fab39 100644
--- a/spec/ruby/core/symbol/equal_value_spec.rb
+++ b/spec/ruby/core/symbol/equal_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#==" do
it "only returns true when the other is exactly the same symbol" do
diff --git a/spec/ruby/core/symbol/id2name_spec.rb b/spec/ruby/core/symbol/id2name_spec.rb
index 2caa89fc37..932dd7171d 100644
--- a/spec/ruby/core/symbol/id2name_spec.rb
+++ b/spec/ruby/core/symbol/id2name_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/id2name'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/id2name', __FILE__)
describe "Symbol#id2name" do
- it_behaves_like :symbol_id2name, :id2name
+ it_behaves_like(:symbol_id2name, :id2name)
end
diff --git a/spec/ruby/core/symbol/inspect_spec.rb b/spec/ruby/core/symbol/inspect_spec.rb
index 58402ab261..dead6e34fc 100644
--- a/spec/ruby/core/symbol/inspect_spec.rb
+++ b/spec/ruby/core/symbol/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#inspect" do
symbols = {
diff --git a/spec/ruby/core/symbol/intern_spec.rb b/spec/ruby/core/symbol/intern_spec.rb
index ea04b87e8a..c1ac5aeac1 100644
--- a/spec/ruby/core/symbol/intern_spec.rb
+++ b/spec/ruby/core/symbol/intern_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#intern" do
it "returns self" do
diff --git a/spec/ruby/core/symbol/length_spec.rb b/spec/ruby/core/symbol/length_spec.rb
index 27bee575ef..e7e0700d5a 100644
--- a/spec/ruby/core/symbol/length_spec.rb
+++ b/spec/ruby/core/symbol/length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Symbol#length" do
it_behaves_like :symbol_length, :length
diff --git a/spec/ruby/core/symbol/match_spec.rb b/spec/ruby/core/symbol/match_spec.rb
index d37155537b..768e3b00da 100644
--- a/spec/ruby/core/symbol/match_spec.rb
+++ b/spec/ruby/core/symbol/match_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :symbol_match, shared: true do
it "returns the index of the beginning of the match" do
@@ -19,42 +19,52 @@ describe "Symbol#=~" do
it_behaves_like :symbol_match, :=~
end
-describe "Symbol#match" do
- it "returns the MatchData" do
- result = :abc.match(/b/)
- result.should be_kind_of(MatchData)
- result[0].should == 'b'
+ruby_version_is ""..."2.4" do
+ describe "Symbol#match" do
+ it_behaves_like :symbol_match, :match
end
+end
- it "returns nil if there is no match" do
- :a.match(/b/).should be_nil
- end
+ruby_version_is "2.4" do
+ describe "Symbol#match" do
+ it "returns the MatchData" do
+ result = :abc.match(/b/)
+ result.should be_kind_of(MatchData)
+ result[0].should == 'b'
+ end
- it "sets the last match pseudo-variables" do
- :a.match(/(.)/)[0].should == 'a'
- $1.should == "a"
+ it "returns nil if there is no match" do
+ :a.match(/b/).should be_nil
+ end
+
+ it "sets the last match pseudo-variables" do
+ :a.match(/(.)/)[0].should == 'a'
+ $1.should == "a"
+ end
end
end
-describe "Symbol#match?" do
- before :each do
- # Resetting Regexp.last_match
- /DONTMATCH/.match ''
- end
+ruby_version_is "2.4" do
+ describe "Symbol#match?" do
+ before :each do
+ # Resetting Regexp.last_match
+ /DONTMATCH/.match ''
+ end
- context "when matches the given regex" do
- it "returns true but does not set Regexp.last_match" do
- :string.match?(/string/i).should be_true
- Regexp.last_match.should be_nil
+ context "when matches the given regex" do
+ it "returns true but does not set Regexp.last_match" do
+ :string.match?(/string/i).should be_true
+ Regexp.last_match.should be_nil
+ end
end
- end
- it "returns false when does not match the given regex" do
- :string.match?(/STRING/).should be_false
- end
+ it "returns false when does not match the given regex" do
+ :string.match?(/STRING/).should be_false
+ end
- it "takes matching position as the 2nd argument" do
- :string.match?(/str/i, 0).should be_true
- :string.match?(/str/i, 1).should be_false
+ it "takes matching position as the 2nd argument" do
+ :string.match?(/str/i, 0).should be_true
+ :string.match?(/str/i, 1).should be_false
+ end
end
end
diff --git a/spec/ruby/core/symbol/next_spec.rb b/spec/ruby/core/symbol/next_spec.rb
index 97fe913739..65ffbebd40 100644
--- a/spec/ruby/core/symbol/next_spec.rb
+++ b/spec/ruby/core/symbol/next_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/succ'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/succ', __FILE__)
describe "Symbol#next" do
it_behaves_like :symbol_succ, :next
diff --git a/spec/ruby/core/symbol/shared/slice.rb b/spec/ruby/core/symbol/shared/slice.rb
index 3f07f6aedb..d39b02f319 100644
--- a/spec/ruby/core/symbol/shared/slice.rb
+++ b/spec/ruby/core/symbol/shared/slice.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes.rb', __FILE__)
describe :symbol_slice, shared: true do
describe "with an Integer index" do
@@ -74,21 +74,21 @@ describe :symbol_slice, shared: true do
describe "and a nil length" do
it "raises a TypeError" do
- -> { :symbol.send(@method, 1,nil) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, 1,nil) }.should raise_error(TypeError)
end
end
describe "and a length that cannot be converted into an Integer" do
it "raises a TypeError when given an Array" do
- -> { :symbol.send(@method, 1,Array.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, 1,Array.new) }.should raise_error(TypeError)
end
it "raises a TypeError when given an Hash" do
- -> { :symbol.send(@method, 1,Hash.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, 1,Hash.new) }.should raise_error(TypeError)
end
it "raises a TypeError when given an Object" do
- -> { :symbol.send(@method, 1,Object.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, 1,Object.new) }.should raise_error(TypeError)
end
end
end
@@ -101,21 +101,21 @@ describe :symbol_slice, shared: true do
describe "with a nil index" do
it "raises a TypeError" do
- -> { :symbol.send(@method, nil) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, nil) }.should raise_error(TypeError)
end
end
describe "with an index that cannot be converted into an Integer" do
it "raises a TypeError when given an Array" do
- -> { :symbol.send(@method, Array.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, Array.new) }.should raise_error(TypeError)
end
it "raises a TypeError when given an Hash" do
- -> { :symbol.send(@method, Hash.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, Hash.new) }.should raise_error(TypeError)
end
it "raises a TypeError when given an Object" do
- -> { :symbol.send(@method, Object.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, Object.new) }.should raise_error(TypeError)
end
end
@@ -191,14 +191,12 @@ describe :symbol_slice, shared: true do
$~.should be_nil
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted string if the regexp is tainted" do
- :symbol.send(@method, /./.taint).tainted?.should be_true
- end
+ it "returns a tainted string if the regexp is tainted" do
+ :symbol.send(@method, /./.taint).tainted?.should be_true
+ end
- it "returns an untrusted string if the regexp is untrusted" do
- :symbol.send(@method, /./.untrust).untrusted?.should be_true
- end
+ it "returns an untrusted string if the regexp is untrusted" do
+ :symbol.send(@method, /./.untrust).untrusted?.should be_true
end
end
@@ -221,32 +219,30 @@ describe :symbol_slice, shared: true do
:symbol.send(@method, /(sy)(mb)(ol)/, 1.5).should == "sy"
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted string if the regexp is tainted" do
- :symbol.send(@method, /(.)/.taint, 1).tainted?.should be_true
- end
+ it "returns a tainted string if the regexp is tainted" do
+ :symbol.send(@method, /(.)/.taint, 1).tainted?.should be_true
+ end
- it "returns an untrusted string if the regexp is untrusted" do
- :symbol.send(@method, /(.)/.untrust, 1).untrusted?.should be_true
- end
+ it "returns an untrusted string if the regexp is untrusted" do
+ :symbol.send(@method, /(.)/.untrust, 1).untrusted?.should be_true
end
describe "and an index that cannot be converted to an Integer" do
it "raises a TypeError when given an Hash" do
- -> { :symbol.send(@method, /(sy)(mb)(ol)/, Hash.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, /(sy)(mb)(ol)/, Hash.new) }.should raise_error(TypeError)
end
it "raises a TypeError when given an Array" do
- -> { :symbol.send(@method, /(sy)(mb)(ol)/, Array.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, /(sy)(mb)(ol)/, Array.new) }.should raise_error(TypeError)
end
it "raises a TypeError when given an Object" do
- -> { :symbol.send(@method, /(sy)(mb)(ol)/, Object.new) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, /(sy)(mb)(ol)/, Object.new) }.should raise_error(TypeError)
end
end
it "raises a TypeError if the index is nil" do
- -> { :symbol.send(@method, /(sy)(mb)(ol)/, nil) }.should raise_error(TypeError)
+ lambda { :symbol.send(@method, /(sy)(mb)(ol)/, nil) }.should raise_error(TypeError)
end
it "sets $~ to the MatchData if there is a match" do
diff --git a/spec/ruby/core/symbol/shared/succ.rb b/spec/ruby/core/symbol/shared/succ.rb
index dde298207e..0e371490f9 100644
--- a/spec/ruby/core/symbol/shared/succ.rb
+++ b/spec/ruby/core/symbol/shared/succ.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :symbol_succ, shared: true do
it "returns a successor" do
diff --git a/spec/ruby/core/symbol/size_spec.rb b/spec/ruby/core/symbol/size_spec.rb
index 5e2aa8d4d2..a6dfe092ec 100644
--- a/spec/ruby/core/symbol/size_spec.rb
+++ b/spec/ruby/core/symbol/size_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Symbol#size" do
it_behaves_like :symbol_length, :size
diff --git a/spec/ruby/core/symbol/slice_spec.rb b/spec/ruby/core/symbol/slice_spec.rb
index d2421c474c..3c535ac4b0 100644
--- a/spec/ruby/core/symbol/slice_spec.rb
+++ b/spec/ruby/core/symbol/slice_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/slice'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/slice.rb', __FILE__)
describe "Symbol#slice" do
- it_behaves_like :symbol_slice, :slice
+ it_behaves_like(:symbol_slice, :slice)
end
diff --git a/spec/ruby/core/symbol/succ_spec.rb b/spec/ruby/core/symbol/succ_spec.rb
index 694bfff862..21bfb7e4aa 100644
--- a/spec/ruby/core/symbol/succ_spec.rb
+++ b/spec/ruby/core/symbol/succ_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/succ'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/succ', __FILE__)
describe "Symbol#succ" do
it_behaves_like :symbol_succ, :succ
diff --git a/spec/ruby/core/symbol/swapcase_spec.rb b/spec/ruby/core/symbol/swapcase_spec.rb
index 24709cac30..3124f782bc 100644
--- a/spec/ruby/core/symbol/swapcase_spec.rb
+++ b/spec/ruby/core/symbol/swapcase_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#swapcase" do
it "returns a Symbol" do
@@ -18,9 +18,21 @@ describe "Symbol#swapcase" do
:mIxEd.swapcase.should == :MiXeD
end
- it "swaps the case for Unicode characters" do
- "äÖü".to_sym.swapcase.should == :"ÄöÜ"
- "aOu".to_sym.swapcase.should == :"AoU"
+ ruby_version_is ''...'2.4' do
+ it "leaves uppercase Unicode characters as they were" do
+ "\u{00DE}Bc".to_sym.swapcase.should == :"ÞbC"
+ end
+
+ it "leaves lowercase Unicode characters as they were" do
+ "\u{00DF}Bc".to_sym.swapcase.should == :"ßbC"
+ end
+ end
+
+ ruby_version_is '2.4' do
+ it "swaps the case for Unicode characters" do
+ "äÖü".to_sym.swapcase.should == :"ÄöÜ"
+ "aOu".to_sym.swapcase.should == :"AoU"
+ end
end
it "leaves non-alphabetic ASCII characters as they were" do
diff --git a/spec/ruby/core/symbol/symbol_spec.rb b/spec/ruby/core/symbol/symbol_spec.rb
index cefe70bc99..af6b46fed3 100644
--- a/spec/ruby/core/symbol/symbol_spec.rb
+++ b/spec/ruby/core/symbol/symbol_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol" do
it "includes Comparable" do
@@ -6,13 +6,13 @@ describe "Symbol" do
end
it ".allocate raises a TypeError" do
- -> do
+ lambda do
Symbol.allocate
end.should raise_error(TypeError)
end
it ".new is undefined" do
- -> do
+ lambda do
Symbol.new
end.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/symbol/to_proc_spec.rb b/spec/ruby/core/symbol/to_proc_spec.rb
index 60e33d7cb8..be625994d9 100644
--- a/spec/ruby/core/symbol/to_proc_spec.rb
+++ b/spec/ruby/core/symbol/to_proc_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#to_proc" do
it "returns a new Proc" do
@@ -12,22 +12,19 @@ describe "Symbol#to_proc" do
:to_s.to_proc.call(obj).should == "Received #to_s"
end
- it "produces a proc with arity -1" do
- pr = :to_s.to_proc
- pr.arity.should == -1
- end
-
it "raises an ArgumentError when calling #call on the Proc without receiver" do
- -> { :object_id.to_proc.call }.should raise_error(ArgumentError, "no receiver given")
+ lambda { :object_id.to_proc.call }.should raise_error(ArgumentError)
end
it "produces a proc that always returns [[:rest]] for #parameters" do
pr = :to_s.to_proc
pr.parameters.should == [[:rest]]
end
+end
- it "passes along the block passed to Proc#call" do
- klass = Class.new do
+describe "Symbol#to_proc" do
+ before :all do
+ @klass = Class.new do
def m
yield
end
@@ -36,6 +33,9 @@ describe "Symbol#to_proc" do
:m.to_proc.call(self) { :value }
end
end
- klass.new.to_proc.should == :value
+ end
+
+ it "passes along the block passed to Proc#call" do
+ @klass.new.to_proc.should == :value
end
end
diff --git a/spec/ruby/core/symbol/to_s_spec.rb b/spec/ruby/core/symbol/to_s_spec.rb
index cd963faa28..40c13675b3 100644
--- a/spec/ruby/core/symbol/to_s_spec.rb
+++ b/spec/ruby/core/symbol/to_s_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/id2name'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/id2name', __FILE__)
describe "Symbol#to_s" do
- it_behaves_like :symbol_id2name, :to_s
+ it_behaves_like(:symbol_id2name, :to_s)
end
diff --git a/spec/ruby/core/symbol/to_sym_spec.rb b/spec/ruby/core/symbol/to_sym_spec.rb
index e75f3d48a8..7f26684850 100644
--- a/spec/ruby/core/symbol/to_sym_spec.rb
+++ b/spec/ruby/core/symbol/to_sym_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#to_sym" do
it "returns self" do
diff --git a/spec/ruby/core/symbol/upcase_spec.rb b/spec/ruby/core/symbol/upcase_spec.rb
index f704bdcbf3..fe2c88d294 100644
--- a/spec/ruby/core/symbol/upcase_spec.rb
+++ b/spec/ruby/core/symbol/upcase_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Symbol#upcase" do
it "returns a Symbol" do
@@ -10,9 +10,17 @@ describe "Symbol#upcase" do
:lOwEr.upcase.should == :LOWER
end
- it "capitalizes all Unicode characters" do
- "äöü".to_sym.upcase.should == :"ÄÖÜ"
- "aou".to_sym.upcase.should == :"AOU"
+ ruby_version_is ''...'2.4' do
+ it "leaves lowercase Unicode characters as they were" do
+ "\u{E0}Bc".to_sym.upcase.should == :"àBC"
+ end
+ end
+
+ ruby_version_is '2.4' do
+ it "capitalizes all Unicode characters" do
+ "äöü".to_sym.upcase.should == :"ÄÖÜ"
+ "aou".to_sym.upcase.should == :"AOU"
+ end
end
it "leaves non-alphabetic ASCII characters as they were" do
diff --git a/spec/ruby/core/systemexit/initialize_spec.rb b/spec/ruby/core/systemexit/initialize_spec.rb
index 2cebaa7993..bf5c8b7798 100644
--- a/spec/ruby/core/systemexit/initialize_spec.rb
+++ b/spec/ruby/core/systemexit/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SystemExit#initialize" do
it "accepts a status" do
@@ -24,3 +24,4 @@ describe "SystemExit#initialize" do
s.status.should == 0
end
end
+
diff --git a/spec/ruby/core/systemexit/success_spec.rb b/spec/ruby/core/systemexit/success_spec.rb
index 6d36509c80..038a0e7e4d 100644
--- a/spec/ruby/core/systemexit/success_spec.rb
+++ b/spec/ruby/core/systemexit/success_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "SystemExit#success?" do
it "returns true when the status is 0" do
diff --git a/spec/ruby/core/thread/abort_on_exception_spec.rb b/spec/ruby/core/thread/abort_on_exception_spec.rb
index 34b648ca0f..e424b2fd26 100644
--- a/spec/ruby/core/thread/abort_on_exception_spec.rb
+++ b/spec/ruby/core/thread/abort_on_exception_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#abort_on_exception" do
before do
@@ -35,7 +35,7 @@ describe :thread_abort_on_exception, shared: true do
ScratchPad << :before
@thread.abort_on_exception = true if @object
- -> do
+ lambda do
ThreadSpecs.state = :run
# Wait for the main thread to be interrupted
sleep
diff --git a/spec/ruby/core/thread/add_trace_func_spec.rb b/spec/ruby/core/thread/add_trace_func_spec.rb
index 0abae81a78..c2010ef317 100644
--- a/spec/ruby/core/thread/add_trace_func_spec.rb
+++ b/spec/ruby/core/thread/add_trace_func_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread#add_trace_func" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/thread/alive_spec.rb b/spec/ruby/core/thread/alive_spec.rb
index d4ba149d87..c1459ac693 100644
--- a/spec/ruby/core/thread/alive_spec.rb
+++ b/spec/ruby/core/thread/alive_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#alive?" do
it "can check it's own status" do
diff --git a/spec/ruby/core/thread/allocate_spec.rb b/spec/ruby/core/thread/allocate_spec.rb
index cfd556812f..1db05878ba 100644
--- a/spec/ruby/core/thread/allocate_spec.rb
+++ b/spec/ruby/core/thread/allocate_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread.allocate" do
it "raises a TypeError" do
- -> {
+ lambda {
Thread.allocate
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb
index d38659c257..6810bdcd78 100644
--- a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb
+++ b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'Thread::Backtrace::Location#absolute_path' do
before :each do
@@ -9,53 +9,4 @@ describe 'Thread::Backtrace::Location#absolute_path' do
it 'returns the absolute path of the call frame' do
@frame.absolute_path.should == File.realpath(__FILE__)
end
-
- context "when used in eval with a given filename" do
- it "returns filename" do
- code = "caller_locations(0)[0].absolute_path"
- eval(code, nil, "foo.rb").should == "foo.rb"
- eval(code, nil, "foo/bar.rb").should == "foo/bar.rb"
- end
- end
-
- context "when used in #method_added" do
- it "returns the user filename that defined the method" do
- path = fixture(__FILE__, "absolute_path_method_added.rb")
- load path
- locations = ScratchPad.recorded
- locations[0].absolute_path.should == path
- # Make sure it's from the class body, not from the file top-level
- locations[0].label.should include 'MethodAddedAbsolutePath'
- end
- end
-
- platform_is_not :windows do
- before :each do
- @file = fixture(__FILE__, "absolute_path.rb")
- @symlink = tmp("symlink.rb")
- File.symlink(@file, @symlink)
- ScratchPad.record []
- end
-
- after :each do
- rm_r @symlink
- end
-
- it "returns a canonical path without symlinks, even when __FILE__ does not" do
- realpath = File.realpath(@symlink)
- realpath.should_not == @symlink
-
- load @symlink
- ScratchPad.recorded.should == [@symlink, realpath]
- end
-
- it "returns a canonical path without symlinks, even when __FILE__ is removed" do
- realpath = File.realpath(@symlink)
- realpath.should_not == @symlink
-
- ScratchPad << -> { rm_r(@symlink) }
- load @symlink
- ScratchPad.recorded.should == [@symlink, realpath]
- end
- end
end
diff --git a/spec/ruby/core/thread/backtrace/location/base_label_spec.rb b/spec/ruby/core/thread/backtrace/location/base_label_spec.rb
index 139a68e2c8..cba7e3f34c 100644
--- a/spec/ruby/core/thread/backtrace/location/base_label_spec.rb
+++ b/spec/ruby/core/thread/backtrace/location/base_label_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'Thread::Backtrace::Location#base_label' do
before :each do
@@ -9,14 +9,4 @@ describe 'Thread::Backtrace::Location#base_label' do
it 'returns the base label of the call frame' do
@frame.base_label.should == '<top (required)>'
end
-
- describe 'when call frame is inside a block' do
- before :each do
- @frame = ThreadBacktraceLocationSpecs.block_location[0]
- end
-
- it 'returns the name of the method that contains the block' do
- @frame.base_label.should == 'block_location'
- end
- end
end
diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/absolute_path.rb b/spec/ruby/core/thread/backtrace/location/fixtures/absolute_path.rb
deleted file mode 100644
index 875e97ffac..0000000000
--- a/spec/ruby/core/thread/backtrace/location/fixtures/absolute_path.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-action = ScratchPad.recorded.pop
-ScratchPad << __FILE__
-action.call if action
-ScratchPad << caller_locations(0)[0].absolute_path
diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/absolute_path_method_added.rb b/spec/ruby/core/thread/backtrace/location/fixtures/absolute_path_method_added.rb
deleted file mode 100644
index 26d6298a19..0000000000
--- a/spec/ruby/core/thread/backtrace/location/fixtures/absolute_path_method_added.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-module ThreadBacktraceLocationSpecs
- class MethodAddedAbsolutePath
- def self.method_added(name)
- ScratchPad.record caller_locations
- end
-
- def foo
- end
- end
-end
diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/classes.rb b/spec/ruby/core/thread/backtrace/location/fixtures/classes.rb
index e903c3e450..3e42d8cf81 100644
--- a/spec/ruby/core/thread/backtrace/location/fixtures/classes.rb
+++ b/spec/ruby/core/thread/backtrace/location/fixtures/classes.rb
@@ -14,22 +14,4 @@ module ThreadBacktraceLocationSpecs
return caller_locations(0)
end
end
-
- def self.locations_inside_nested_blocks
- first_level_location = nil
- second_level_location = nil
- third_level_location = nil
-
- 1.times do
- first_level_location = locations[0]
- 1.times do
- second_level_location = locations[0]
- 1.times do
- third_level_location = locations[0]
- end
- end
- end
-
- [first_level_location, second_level_location, third_level_location]
- end
end
diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/locations_in_main.rb b/spec/ruby/core/thread/backtrace/location/fixtures/locations_in_main.rb
deleted file mode 100644
index b124c8161c..0000000000
--- a/spec/ruby/core/thread/backtrace/location/fixtures/locations_in_main.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-1.times do
- puts Thread.current.backtrace_locations(1..1)[0].label
-end
-
-require_relative 'locations_in_required'
diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/locations_in_required.rb b/spec/ruby/core/thread/backtrace/location/fixtures/locations_in_required.rb
deleted file mode 100644
index 5f5ed89e98..0000000000
--- a/spec/ruby/core/thread/backtrace/location/fixtures/locations_in_required.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-1.times do
- puts Thread.current.backtrace_locations(1..1)[0].label
-end
diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/main.rb b/spec/ruby/core/thread/backtrace/location/fixtures/main.rb
index bde208a059..d2d14ac957 100644
--- a/spec/ruby/core/thread/backtrace/location/fixtures/main.rb
+++ b/spec/ruby/core/thread/backtrace/location/fixtures/main.rb
@@ -1,5 +1,5 @@
-def backtrace_location_example
+def example
caller_locations[0].path
end
-print backtrace_location_example
+print example
diff --git a/spec/ruby/core/thread/backtrace/location/inspect_spec.rb b/spec/ruby/core/thread/backtrace/location/inspect_spec.rb
index 20e477a5a6..56d440c04a 100644
--- a/spec/ruby/core/thread/backtrace/location/inspect_spec.rb
+++ b/spec/ruby/core/thread/backtrace/location/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'Thread::Backtrace::Location#inspect' do
before :each do
diff --git a/spec/ruby/core/thread/backtrace/location/label_spec.rb b/spec/ruby/core/thread/backtrace/location/label_spec.rb
index 7312d017e5..4e67509d0f 100644
--- a/spec/ruby/core/thread/backtrace/location/label_spec.rb
+++ b/spec/ruby/core/thread/backtrace/location/label_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'Thread::Backtrace::Location#label' do
it 'returns the base label of the call frame' do
@@ -17,21 +17,4 @@ describe 'Thread::Backtrace::Location#label' do
it 'returns the module name for a module location' do
ThreadBacktraceLocationSpecs::MODULE_LOCATION[0].label.should include "ThreadBacktraceLocationSpecs"
end
-
- it 'includes the nesting level of a block as part of the location label' do
- first_level_location, second_level_location, third_level_location =
- ThreadBacktraceLocationSpecs.locations_inside_nested_blocks
-
- first_level_location.label.should == 'block in locations_inside_nested_blocks'
- second_level_location.label.should == 'block (2 levels) in locations_inside_nested_blocks'
- third_level_location.label.should == 'block (3 levels) in locations_inside_nested_blocks'
- end
-
- it 'sets the location label for a top-level block differently depending on it being in the main file or a required file' do
- path = fixture(__FILE__, "locations_in_main.rb")
- main_label, required_label = ruby_exe(path).lines
-
- main_label.should == "block in <main>\n"
- required_label.should == "block in <top (required)>\n"
- end
end
diff --git a/spec/ruby/core/thread/backtrace/location/lineno_spec.rb b/spec/ruby/core/thread/backtrace/location/lineno_spec.rb
index dc93d32d75..7d203008e5 100644
--- a/spec/ruby/core/thread/backtrace/location/lineno_spec.rb
+++ b/spec/ruby/core/thread/backtrace/location/lineno_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'Thread::Backtrace::Location#lineno' do
before :each do
diff --git a/spec/ruby/core/thread/backtrace/location/path_spec.rb b/spec/ruby/core/thread/backtrace/location/path_spec.rb
index b1a3439747..c2f2058990 100644
--- a/spec/ruby/core/thread/backtrace/location/path_spec.rb
+++ b/spec/ruby/core/thread/backtrace/location/path_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'Thread::Backtrace::Location#path' do
context 'outside a main script' do
@@ -56,7 +56,7 @@ describe 'Thread::Backtrace::Location#path' do
end
context 'when the script is outside of the working directory' do
- before :each do
+ before do
@parent_dir = tmp('path_outside_pwd')
@sub_dir = File.join(@parent_dir, 'sub')
@script = File.join(@parent_dir, 'main.rb')
@@ -67,7 +67,9 @@ describe 'Thread::Backtrace::Location#path' do
cp(source, @script)
end
- after :each do
+ after do
+ rm_r(@script)
+ rm_r(@sub_dir)
rm_r(@parent_dir)
end
diff --git a/spec/ruby/core/thread/backtrace/location/to_s_spec.rb b/spec/ruby/core/thread/backtrace/location/to_s_spec.rb
index 5911cdced0..486d7da4c9 100644
--- a/spec/ruby/core/thread/backtrace/location/to_s_spec.rb
+++ b/spec/ruby/core/thread/backtrace/location/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'Thread::Backtrace::Location#to_s' do
before :each do
diff --git a/spec/ruby/core/thread/backtrace_locations_spec.rb b/spec/ruby/core/thread/backtrace_locations_spec.rb
deleted file mode 100644
index 66947f8ea6..0000000000
--- a/spec/ruby/core/thread/backtrace_locations_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Thread#backtrace_locations" do
- it "returns an Array" do
- locations = Thread.current.backtrace_locations
- locations.should be_an_instance_of(Array)
- locations.should_not be_empty
- end
-
- it "sets each element to a Thread::Backtrace::Location" do
- locations = Thread.current.backtrace_locations
- locations.each { |loc| loc.should be_an_instance_of(Thread::Backtrace::Location) }
- end
-
- it "can be called on any Thread" do
- locations = Thread.new { Thread.current.backtrace_locations }.value
- locations.should be_an_instance_of(Array)
- locations.should_not be_empty
- locations.each { |loc| loc.should be_an_instance_of(Thread::Backtrace::Location) }
- end
-
- it "without argument is the same as showing all locations with 0..-1" do
- Thread.current.backtrace_locations.map(&:to_s).should == Thread.current.backtrace_locations(0..-1).map(&:to_s)
- end
-
- it "the first location reports the call to #backtrace_locations" do
- Thread.current.backtrace_locations(0..0)[0].to_s.should == "#{__FILE__ }:#{__LINE__ }:in `backtrace_locations'"
- end
-
- it "[1..-1] is the same as #caller_locations(0..-1) for Thread.current" do
- Thread.current.backtrace_locations(1..-1).map(&:to_s).should == caller_locations(0..-1).map(&:to_s)
- end
-end
diff --git a/spec/ruby/core/thread/backtrace_spec.rb b/spec/ruby/core/thread/backtrace_spec.rb
index 84ed574d5c..a20fdee956 100644
--- a/spec/ruby/core/thread/backtrace_spec.rb
+++ b/spec/ruby/core/thread/backtrace_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread#backtrace" do
it "returns the current backtrace of a thread" do
@@ -24,12 +24,4 @@ describe "Thread#backtrace" do
t.join
t.backtrace.should == nil
end
-
- it "returns an array (which may be empty) immediately after the thread is created" do
- t = Thread.new { sleep }
- backtrace = t.backtrace
- t.kill
- t.join
- backtrace.should be_kind_of(Array)
- end
end
diff --git a/spec/ruby/core/thread/current_spec.rb b/spec/ruby/core/thread/current_spec.rb
index f5ed1d95cd..cc969b71c4 100644
--- a/spec/ruby/core/thread/current_spec.rb
+++ b/spec/ruby/core/thread/current_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread.current" do
it "returns a thread" do
@@ -12,20 +12,4 @@ describe "Thread.current" do
t.value.should equal(t)
Thread.current.should_not equal(t.value)
end
-
- it "returns the correct thread in a Fiber" do
- # This catches a bug where Fibers are running on a thread-pool
- # and Fibers from a different Ruby Thread reuse the same native thread.
- # Caching the Ruby Thread based on the native thread is not correct in that case.
- 2.times do
- t = Thread.new {
- cur = Thread.current
- Fiber.new {
- Thread.current
- }.resume.should equal cur
- cur
- }
- t.value.should equal t
- end
- end
end
diff --git a/spec/ruby/core/thread/element_reference_spec.rb b/spec/ruby/core/thread/element_reference_spec.rb
index 85280cb287..81b11d2c09 100644
--- a/spec/ruby/core/thread/element_reference_spec.rb
+++ b/spec/ruby/core/thread/element_reference_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#[]" do
it "gives access to thread local values" do
@@ -38,7 +38,7 @@ describe "Thread#[]" do
end
it "raises exceptions on the wrong type of keys" do
- -> { Thread.current[nil] }.should raise_error(TypeError)
- -> { Thread.current[5] }.should raise_error(TypeError)
+ lambda { Thread.current[nil] }.should raise_error(TypeError)
+ lambda { Thread.current[5] }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/thread/element_set_spec.rb b/spec/ruby/core/thread/element_set_spec.rb
index d974b5e1c7..ed92a84fa3 100644
--- a/spec/ruby/core/thread/element_set_spec.rb
+++ b/spec/ruby/core/thread/element_set_spec.rb
@@ -1,24 +1,24 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#[]=" do
after :each do
Thread.current[:value] = nil
end
- it "raises a #{frozen_error_class} if the thread is frozen" do
+ it "raises a RuntimeError if the thread is frozen" do
Thread.new do
th = Thread.current
th.freeze
-> {
th[:foo] = "bar"
- }.should raise_error(frozen_error_class, /frozen/)
+ }.should raise_error(RuntimeError, /frozen/)
end.join
end
it "raises exceptions on the wrong type of keys" do
- -> { Thread.current[nil] = true }.should raise_error(TypeError)
- -> { Thread.current[5] = true }.should raise_error(TypeError)
+ lambda { Thread.current[nil] = true }.should raise_error(TypeError)
+ lambda { Thread.current[5] = true }.should raise_error(TypeError)
end
it "is not shared across fibers" do
diff --git a/spec/ruby/core/thread/exclusive_spec.rb b/spec/ruby/core/thread/exclusive_spec.rb
index ca8f105da4..66c87f4713 100644
--- a/spec/ruby/core/thread/exclusive_spec.rb
+++ b/spec/ruby/core/thread/exclusive_spec.rb
@@ -1,13 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread.exclusive" do
before :each do
ScratchPad.clear
- $VERBOSE, @verbose = nil, $VERBOSE
- end
-
- after :each do
- $VERBOSE = @verbose
end
it "yields to the block" do
@@ -19,29 +14,5 @@ describe "Thread.exclusive" do
Thread.exclusive { :result }.should == :result
end
- it "blocks the caller if another thread is also in an exclusive block" do
- m = Mutex.new
- q1 = Queue.new
- q2 = Queue.new
-
- t = Thread.new {
- Thread.exclusive {
- q1.push :ready
- q2.pop
- }
- }
-
- q1.pop.should == :ready
-
- -> { Thread.exclusive { } }.should block_caller
-
- q2.push :done
- t.join
- end
-
- it "is not recursive" do
- Thread.exclusive do
- -> { Thread.exclusive { } }.should raise_error(ThreadError)
- end
- end
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/thread/exit_spec.rb b/spec/ruby/core/thread/exit_spec.rb
index c3f710920e..0fb329e66f 100644
--- a/spec/ruby/core/thread/exit_spec.rb
+++ b/spec/ruby/core/thread/exit_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/exit'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/exit', __FILE__)
describe "Thread#exit!" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/thread/fetch_spec.rb b/spec/ruby/core/thread/fetch_spec.rb
deleted file mode 100644
index d71c938880..0000000000
--- a/spec/ruby/core/thread/fetch_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is '2.5' do
- describe 'Thread#fetch' do
- describe 'with 2 arguments' do
- it 'returns the value of the fiber-local variable if value has been assigned' do
- th = Thread.new { Thread.current[:cat] = 'meow' }
- th.join
- th.fetch(:cat, true).should == 'meow'
- end
-
- it "returns the default value if fiber-local variable hasn't been assigned" do
- th = Thread.new {}
- th.join
- th.fetch(:cat, true).should == true
- end
- end
-
- describe 'with 1 argument' do
- it 'raises a KeyError when the Thread does not have a fiber-local variable of the same name' do
- th = Thread.new {}
- th.join
- -> { th.fetch(:cat) }.should raise_error(KeyError)
- end
-
- it 'returns the value of the fiber-local variable if value has been assigned' do
- th = Thread.new { Thread.current[:cat] = 'meow' }
- th.join
- th.fetch(:cat).should == 'meow'
- end
- end
-
- it 'raises an ArgumentError when not passed one or two arguments' do
- -> { Thread.current.fetch() }.should raise_error(ArgumentError)
- -> { Thread.current.fetch(1, 2, 3) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/core/thread/fixtures/classes.rb b/spec/ruby/core/thread/fixtures/classes.rb
index 23a090feb0..601e515e3e 100644
--- a/spec/ruby/core/thread/fixtures/classes.rb
+++ b/spec/ruby/core/thread/fixtures/classes.rb
@@ -1,3 +1,10 @@
+unless defined? Channel
+ require 'thread'
+ class Channel < Queue
+ alias receive shift
+ end
+end
+
module ThreadSpecs
class SubThread < Thread
@@ -7,12 +14,11 @@ module ThreadSpecs
end
class Status
- attr_reader :thread, :inspect, :status, :to_s
+ attr_reader :thread, :inspect, :status
def initialize(thread)
@thread = thread
@alive = thread.alive?
@inspect = thread.inspect
- @to_s = thread.to_s
@status = thread.status
@stop = thread.stop?
end
@@ -182,7 +188,7 @@ module ThreadSpecs
def self.join_dying_thread_with_outer_ensure(kill_method_name=:kill)
t = dying_thread_with_outer_ensure(kill_method_name) { yield }
- -> { t.join }.should raise_error(RuntimeError, "In dying thread")
+ lambda { t.join }.should raise_error(RuntimeError, "In dying thread")
return t
end
diff --git a/spec/ruby/core/thread/fork_spec.rb b/spec/ruby/core/thread/fork_spec.rb
index a2f4181298..d321230812 100644
--- a/spec/ruby/core/thread/fork_spec.rb
+++ b/spec/ruby/core/thread/fork_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/start'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/start', __FILE__)
describe "Thread.fork" do
describe "Thread.start" do
diff --git a/spec/ruby/core/thread/group_spec.rb b/spec/ruby/core/thread/group_spec.rb
index 59f5ac37c8..aecc1422ba 100644
--- a/spec/ruby/core/thread/group_spec.rb
+++ b/spec/ruby/core/thread/group_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#group" do
it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/thread/initialize_spec.rb b/spec/ruby/core/thread/initialize_spec.rb
index 4fca900cd8..b6345f03de 100644
--- a/spec/ruby/core/thread/initialize_spec.rb
+++ b/spec/ruby/core/thread/initialize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#initialize" do
@@ -15,7 +15,7 @@ describe "Thread#initialize" do
end
it "raises a ThreadError" do
- -> {
+ lambda {
@t.instance_eval do
initialize {}
end
diff --git a/spec/ruby/core/thread/inspect_spec.rb b/spec/ruby/core/thread/inspect_spec.rb
index bd6e0c31fc..95e598eb6a 100644
--- a/spec/ruby/core/thread/inspect_spec.rb
+++ b/spec/ruby/core/thread/inspect_spec.rb
@@ -1,6 +1,44 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#inspect" do
- it_behaves_like :thread_to_s, :inspect
+ it "can check it's own status" do
+ ThreadSpecs.status_of_current_thread.inspect.should include('run')
+ end
+
+ it "describes a running thread" do
+ ThreadSpecs.status_of_running_thread.inspect.should include('run')
+ end
+
+ it "describes a sleeping thread" do
+ ThreadSpecs.status_of_sleeping_thread.inspect.should include('sleep')
+ end
+
+ it "describes a blocked thread" do
+ ThreadSpecs.status_of_blocked_thread.inspect.should include('sleep')
+ end
+
+ it "describes a completed thread" do
+ ThreadSpecs.status_of_completed_thread.inspect.should include('dead')
+ end
+
+ it "describes a killed thread" do
+ ThreadSpecs.status_of_killed_thread.inspect.should include('dead')
+ end
+
+ it "describes a thread with an uncaught exception" do
+ ThreadSpecs.status_of_thread_with_uncaught_exception.inspect.should include('dead')
+ end
+
+ it "describes a dying sleeping thread" do
+ ThreadSpecs.status_of_dying_sleeping_thread.inspect.should include('sleep')
+ end
+
+ it "reports aborting on a killed thread" do
+ ThreadSpecs.status_of_dying_running_thread.inspect.should include('aborting')
+ end
+
+ it "reports aborting on a killed thread after sleep" do
+ ThreadSpecs.status_of_dying_thread_after_sleep.inspect.should include('aborting')
+ end
end
diff --git a/spec/ruby/core/thread/join_spec.rb b/spec/ruby/core/thread/join_spec.rb
index f3c5cdc1ed..249b3d333e 100644
--- a/spec/ruby/core/thread/join_spec.rb
+++ b/spec/ruby/core/thread/join_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#join" do
it "returns the thread when it is finished" do
@@ -19,28 +19,28 @@ describe "Thread#join" do
t.join(0).should equal(t)
t.join(0.0).should equal(t)
t.join(nil).should equal(t)
- -> { t.join(:foo) }.should raise_error TypeError
- -> { t.join("bar") }.should raise_error TypeError
+ lambda { t.join(:foo) }.should raise_error TypeError
+ lambda { t.join("bar") }.should raise_error TypeError
end
it "returns nil if it is not finished when given a timeout" do
- q = Queue.new
- t = Thread.new { q.pop }
+ c = Channel.new
+ t = Thread.new { c.receive }
begin
t.join(0).should == nil
ensure
- q << true
+ c << true
end
t.join.should == t
end
it "accepts a floating point timeout length" do
- q = Queue.new
- t = Thread.new { q.pop }
+ c = Channel.new
+ t = Thread.new { c.receive }
begin
t.join(0.01).should == nil
ensure
- q << true
+ c << true
end
t.join.should == t
end
@@ -50,7 +50,7 @@ describe "Thread#join" do
Thread.current.report_on_exception = false
raise NotImplementedError.new("Just kidding")
}
- -> { t.join }.should raise_error(NotImplementedError)
+ lambda { t.join }.should raise_error(NotImplementedError)
end
it "returns the dead thread" do
@@ -60,6 +60,6 @@ describe "Thread#join" do
it "raises any uncaught exception encountered in ensure block" do
t = ThreadSpecs.dying_thread_ensures { raise NotImplementedError.new("Just kidding") }
- -> { t.join }.should raise_error(NotImplementedError)
+ lambda { t.join }.should raise_error(NotImplementedError)
end
end
diff --git a/spec/ruby/core/thread/key_spec.rb b/spec/ruby/core/thread/key_spec.rb
index 6940cf5f28..d82a21ab39 100644
--- a/spec/ruby/core/thread/key_spec.rb
+++ b/spec/ruby/core/thread/key_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#key?" do
before :each do
@@ -17,8 +17,8 @@ describe "Thread#key?" do
end
it "raises exceptions on the wrong type of keys" do
- -> { Thread.current.key? nil }.should raise_error(TypeError)
- -> { Thread.current.key? 5 }.should raise_error(TypeError)
+ lambda { Thread.current.key? nil }.should raise_error(TypeError)
+ lambda { Thread.current.key? 5 }.should raise_error(TypeError)
end
it "is not shared across fibers" do
diff --git a/spec/ruby/core/thread/keys_spec.rb b/spec/ruby/core/thread/keys_spec.rb
index 15efda51d6..0fc8184e06 100644
--- a/spec/ruby/core/thread/keys_spec.rb
+++ b/spec/ruby/core/thread/keys_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#keys" do
it "returns an array of the names of the thread-local variables as symbols" do
diff --git a/spec/ruby/core/thread/kill_spec.rb b/spec/ruby/core/thread/kill_spec.rb
index f932bf5232..cf71307af5 100644
--- a/spec/ruby/core/thread/kill_spec.rb
+++ b/spec/ruby/core/thread/kill_spec.rb
@@ -1,25 +1,21 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/exit'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/exit', __FILE__)
-# This spec randomly kills mspec worker like: https://ci.appveyor.com/project/ruby/ruby/builds/19473223/job/f69derxnlo09xhuj
-# TODO: Investigate the cause or at least print helpful logs, and remove this `platform_is_not` guard.
-platform_is_not :mingw do
- describe "Thread#kill" do
- it_behaves_like :thread_exit, :kill
- end
+describe "Thread#kill" do
+ it_behaves_like :thread_exit, :kill
+end
- describe "Thread#kill!" do
- it "needs to be reviewed for spec completeness"
- end
+describe "Thread#kill!" do
+ it "needs to be reviewed for spec completeness"
+end
- describe "Thread.kill" do
- it "causes the given thread to exit" do
- thread = Thread.new { sleep }
- Thread.pass while thread.status and thread.status != "sleep"
- Thread.kill(thread).should == thread
- thread.join
- thread.status.should be_false
- end
+describe "Thread.kill" do
+ it "causes the given thread to exit" do
+ thread = Thread.new { sleep }
+ Thread.pass while thread.status and thread.status != "sleep"
+ Thread.kill(thread).should == thread
+ thread.join
+ thread.status.should be_false
end
end
diff --git a/spec/ruby/core/thread/list_spec.rb b/spec/ruby/core/thread/list_spec.rb
index a0bf831856..b8deb98260 100644
--- a/spec/ruby/core/thread/list_spec.rb
+++ b/spec/ruby/core/thread/list_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread.list" do
it "includes the current and main thread" do
@@ -25,31 +25,18 @@ describe "Thread.list" do
end
it "includes waiting threads" do
- q = Queue.new
- t = Thread.new { q.pop }
+ c = Channel.new
+ t = Thread.new { c.receive }
begin
Thread.pass while t.status and t.status != 'sleep'
Thread.list.should include(t)
ensure
- q << nil
+ c << nil
t.join
end
end
+end
- it "returns instances of Thread and not null or nil values" do
- spawner = Thread.new do
- Array.new(100) do
- Thread.new {}
- end
- end
-
- while spawner.alive?
- Thread.list.each { |th|
- th.should be_kind_of(Thread)
- }
- end
-
- threads = spawner.value
- threads.each(&:join)
- end
+describe "Thread.list" do
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/thread/main_spec.rb b/spec/ruby/core/thread/main_spec.rb
index ec91709576..0cada8f59d 100644
--- a/spec/ruby/core/thread/main_spec.rb
+++ b/spec/ruby/core/thread/main_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread.main" do
it "returns the main thread" do
diff --git a/spec/ruby/core/thread/name_spec.rb b/spec/ruby/core/thread/name_spec.rb
index 9b3d2f4b09..0417d7a500 100644
--- a/spec/ruby/core/thread/name_spec.rb
+++ b/spec/ruby/core/thread/name_spec.rb
@@ -1,54 +1,56 @@
-require_relative '../../spec_helper'
-
-describe "Thread#name" do
- before :each do
- @thread = Thread.new {}
- end
-
- after :each do
- @thread.join
- end
-
- it "is nil initially" do
- @thread.name.should == nil
- end
-
- it "returns the thread name" do
- @thread.name = "thread_name"
- @thread.name.should == "thread_name"
- end
-end
-
-describe "Thread#name=" do
- before :each do
- @thread = Thread.new {}
- end
-
- after :each do
- @thread.join
- end
-
- it "can be set to a String" do
- @thread.name = "new thread name"
- @thread.name.should == "new thread name"
- end
-
- it "raises an ArgumentError if the name includes a null byte" do
- -> {
- @thread.name = "new thread\0name"
- }.should raise_error(ArgumentError)
- end
-
- it "can be reset to nil" do
- @thread.name = nil
- @thread.name.should == nil
- end
-
- it "calls #to_str to convert name to String" do
- name = mock("Thread#name")
- name.should_receive(:to_str).and_return("a thread name")
-
- @thread.name = name
- @thread.name.should == "a thread name"
+require File.expand_path('../../../spec_helper', __FILE__)
+
+ruby_version_is '2.3' do
+ describe "Thread#name" do
+ before :each do
+ @thread = Thread.new {}
+ end
+
+ after :each do
+ @thread.join
+ end
+
+ it "is nil initially" do
+ @thread.name.should == nil
+ end
+
+ it "returns the thread name" do
+ @thread.name = "thread_name"
+ @thread.name.should == "thread_name"
+ end
+ end
+
+ describe "Thread#name=" do
+ before :each do
+ @thread = Thread.new {}
+ end
+
+ after :each do
+ @thread.join
+ end
+
+ it "can be set to a String" do
+ @thread.name = "new thread name"
+ @thread.name.should == "new thread name"
+ end
+
+ it "raises an ArgumentError if the name includes a null byte" do
+ lambda {
+ @thread.name = "new thread\0name"
+ }.should raise_error(ArgumentError)
+ end
+
+ it "can be reset to nil" do
+ @thread.name = nil
+ @thread.name.should == nil
+ end
+
+ it "calls #to_str to convert name to String" do
+ name = mock("Thread#name")
+ name.should_receive(:to_str).and_return("a thread name")
+
+ @thread.name = name
+ @thread.name.should == "a thread name"
+ end
end
end
diff --git a/spec/ruby/core/thread/new_spec.rb b/spec/ruby/core/thread/new_spec.rb
index 3a57149381..b1ed5560a1 100644
--- a/spec/ruby/core/thread/new_spec.rb
+++ b/spec/ruby/core/thread/new_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread.new" do
it "creates a thread executing the given block" do
- q = Queue.new
- Thread.new { q << true }.join
- q << false
- q.pop.should == true
+ c = Channel.new
+ Thread.new { c << true }.join
+ c << false
+ c.receive.should == true
end
it "can pass arguments to the thread block" do
@@ -18,7 +18,7 @@ describe "Thread.new" do
end
it "raises an exception when not given a block" do
- -> { Thread.new }.should raise_error(ThreadError)
+ lambda { Thread.new }.should raise_error(ThreadError)
end
it "creates a subclass of thread calls super with a block in initialize" do
@@ -34,7 +34,7 @@ describe "Thread.new" do
end
end
- -> {
+ lambda {
c.new
}.should raise_error(ThreadError)
end
@@ -53,31 +53,4 @@ describe "Thread.new" do
ScratchPad.recorded.should == [:good, :in_thread]
end
- it "releases Mutexes held by the Thread when the Thread finishes" do
- m1 = Mutex.new
- m2 = Mutex.new
- t = Thread.new {
- m1.lock
- m1.locked?.should == true
- m2.lock
- m2.locked?.should == true
- }
- t.join
- m1.locked?.should == false
- m2.locked?.should == false
- end
-
- it "releases Mutexes held by the Thread when the Thread finishes, also with Mutex#synchronize" do
- m = Mutex.new
- t = Thread.new {
- m.synchronize {
- m.unlock
- m.lock
- }
- m.lock
- m.locked?.should == true
- }
- t.join
- m.locked?.should == false
- end
end
diff --git a/spec/ruby/core/thread/pass_spec.rb b/spec/ruby/core/thread/pass_spec.rb
index a5ac11a58c..128de934ac 100644
--- a/spec/ruby/core/thread/pass_spec.rb
+++ b/spec/ruby/core/thread/pass_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread.pass" do
it "returns nil" do
diff --git a/spec/ruby/core/thread/priority_spec.rb b/spec/ruby/core/thread/priority_spec.rb
index e13ad478b5..b986fb7a0d 100644
--- a/spec/ruby/core/thread/priority_spec.rb
+++ b/spec/ruby/core/thread/priority_spec.rb
@@ -1,15 +1,14 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#priority" do
- before :each do
+ before do
@current_priority = Thread.current.priority
ThreadSpecs.clear_state
@thread = Thread.new { Thread.pass until ThreadSpecs.state == :exit }
- Thread.pass until @thread.alive?
end
- after :each do
+ after do
ThreadSpecs.state = :exit
@thread.join
end
@@ -32,14 +31,12 @@ describe "Thread#priority" do
end
describe "Thread#priority=" do
- before :each do
+ before do
ThreadSpecs.clear_state
- @thread = Thread.new { Thread.pass until ThreadSpecs.state == :exit }
- Thread.pass until @thread.alive?
+ @thread = Thread.new {}
end
- after :each do
- ThreadSpecs.state = :exit
+ after do
@thread.join
end
@@ -59,14 +56,13 @@ describe "Thread#priority=" do
describe "when set with a non-integer" do
it "raises a type error" do
- ->{ @thread.priority = Object.new }.should raise_error(TypeError)
+ lambda{ @thread.priority = Object.new }.should raise_error(TypeError)
end
end
it "sets priority even when the thread has died" do
- thread = Thread.new {}
- thread.join
- thread.priority = 3
- thread.priority.should == 3
+ @thread.join
+ @thread.priority = 3
+ @thread.priority.should == 3
end
end
diff --git a/spec/ruby/core/thread/raise_spec.rb b/spec/ruby/core/thread/raise_spec.rb
index 88a96d5f4e..8724d26202 100644
--- a/spec/ruby/core/thread/raise_spec.rb
+++ b/spec/ruby/core/thread/raise_spec.rb
@@ -1,13 +1,13 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../shared/kernel/raise'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../shared/kernel/raise', __FILE__)
describe "Thread#raise" do
- it "ignores dead threads and returns nil" do
+ it "ignores dead threads" do
t = Thread.new { :dead }
Thread.pass while t.alive?
- t.raise("Kill the thread").should == nil
- t.join
+ lambda {t.raise("Kill the thread")}.should_not raise_error
+ lambda {t.value}.should_not raise_error
end
end
@@ -58,7 +58,7 @@ describe "Thread#raise on a sleeping thread" do
ThreadSpecs.spin_until_sleeping(t)
t.raise
- -> { t.value }.should raise_error(RuntimeError)
+ lambda { t.value }.should raise_error(RuntimeError)
end
it "raises a RuntimeError when called with no arguments inside rescue" do
@@ -76,31 +76,7 @@ describe "Thread#raise on a sleeping thread" do
ThreadSpecs.spin_until_sleeping(t)
t.raise
end
- -> { t.value }.should raise_error(RuntimeError)
- end
-
- it "re-raises a previously rescued exception without overwriting the backtrace" do
- t = Thread.new do
- -> { # To make sure there is at least one entry in the call stack
- begin
- sleep
- rescue => e
- e
- end
- }.call
- end
-
- ThreadSpecs.spin_until_sleeping(t)
-
- begin
- initial_raise_line = __LINE__; raise 'raised'
- rescue => raised
- raise_again_line = __LINE__; t.raise raised
- raised_again = t.value
-
- raised_again.backtrace.first.should include("#{__FILE__}:#{initial_raise_line}:")
- raised_again.backtrace.first.should_not include("#{__FILE__}:#{raise_again_line}:")
- end
+ lambda {t.value}.should raise_error(RuntimeError)
end
end
@@ -138,16 +114,13 @@ describe "Thread#raise on a running thread" do
end
it "can go unhandled" do
- q = Queue.new
t = Thread.new do
Thread.current.report_on_exception = false
- q << true
loop { Thread.pass }
end
- q.pop # wait for `report_on_exception = false`.
t.raise
- -> { t.value }.should raise_error(RuntimeError)
+ lambda {t.value}.should raise_error(RuntimeError)
end
it "raises the given argument even when there is an active exception" do
@@ -166,7 +139,7 @@ describe "Thread#raise on a running thread" do
rescue
Thread.pass until raised
t.raise RangeError
- -> { t.value }.should raise_error(RangeError)
+ lambda {t.value}.should raise_error(RangeError)
end
end
@@ -178,7 +151,7 @@ describe "Thread#raise on a running thread" do
1/0
rescue ZeroDivisionError
raised = true
- loop { Thread.pass }
+ loop { }
end
end
begin
@@ -187,7 +160,7 @@ describe "Thread#raise on a running thread" do
Thread.pass until raised
t.raise
end
- -> { t.value }.should raise_error(RuntimeError)
+ lambda {t.value}.should raise_error(RuntimeError)
end
end
@@ -203,6 +176,6 @@ describe "Thread#raise on same thread" do
Thread.current.raise
end
end
- -> { t.value }.should raise_error(RuntimeError)
+ lambda {t.value}.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/thread/report_on_exception_spec.rb b/spec/ruby/core/thread/report_on_exception_spec.rb
index a6042ba759..d8400c080a 100644
--- a/spec/ruby/core/thread/report_on_exception_spec.rb
+++ b/spec/ruby/core/thread/report_on_exception_spec.rb
@@ -1,116 +1,120 @@
-require_relative '../../spec_helper'
-
-describe "Thread.report_on_exception" do
- ruby_version_is "2.4"..."2.5" do
- it "defaults to false" do
- ruby_exe("p Thread.report_on_exception").should == "false\n"
+require File.expand_path('../../../spec_helper', __FILE__)
+
+ruby_version_is "2.4" do
+ describe "Thread.report_on_exception" do
+ ruby_version_is "2.4"..."2.5" do
+ it "defaults to false" do
+ ruby_exe("p Thread.report_on_exception").should == "false\n"
+ end
end
- end
- ruby_version_is "2.5" do
- it "defaults to true" do
- ruby_exe("p Thread.report_on_exception").should == "true\n"
+ ruby_version_is "2.5" do
+ it "defaults to true" do
+ ruby_exe("p Thread.report_on_exception").should == "true\n"
+ end
end
end
-end
-
-describe "Thread.report_on_exception=" do
- before :each do
- @report_on_exception = Thread.report_on_exception
- end
-
- after :each do
- Thread.report_on_exception = @report_on_exception
- end
- it "changes the default value for new threads" do
- Thread.report_on_exception = true
- Thread.report_on_exception.should == true
- t = Thread.new {}
- t.join
- t.report_on_exception.should == true
- end
-end
+ describe "Thread.report_on_exception=" do
+ before :each do
+ @report_on_exception = Thread.report_on_exception
+ end
-describe "Thread#report_on_exception" do
- ruby_version_is "2.5" do
- it "returns true for the main Thread" do
- Thread.current.report_on_exception.should == true
+ after :each do
+ Thread.report_on_exception = @report_on_exception
end
- it "returns true for new Threads" do
- Thread.new { Thread.current.report_on_exception }.value.should == true
+ it "changes the default value for new threads" do
+ Thread.report_on_exception = true
+ Thread.report_on_exception.should == true
+ t = Thread.new {}
+ t.join
+ t.report_on_exception.should == true
end
end
- it "returns whether the Thread will print a backtrace if it exits with an exception" do
- t = Thread.new { Thread.current.report_on_exception = true }
- t.join
- t.report_on_exception.should == true
+ describe "Thread#report_on_exception" do
+ ruby_version_is "2.5" do
+ it "returns true for the main Thread" do
+ Thread.current.report_on_exception.should == true
+ end
- t = Thread.new { Thread.current.report_on_exception = false }
- t.join
- t.report_on_exception.should == false
- end
-end
+ it "returns true for new Threads" do
+ Thread.new { Thread.current.report_on_exception }.value.should == true
+ end
+ end
+
+ it "returns whether the Thread will print a backtrace if it exits with an exception" do
+ t = Thread.new { Thread.current.report_on_exception = true }
+ t.join
+ t.report_on_exception.should == true
-describe "Thread#report_on_exception=" do
- describe "when set to true" do
- it "prints a backtrace on $stderr if it terminates with an exception" do
- t = nil
- -> {
- t = Thread.new {
- Thread.current.report_on_exception = true
- raise RuntimeError, "Thread#report_on_exception specs"
- }
- Thread.pass while t.alive?
- }.should output("", /Thread.+terminated with exception.+Thread#report_on_exception specs/m)
-
- -> {
- t.join
- }.should raise_error(RuntimeError, "Thread#report_on_exception specs")
+ t = Thread.new { Thread.current.report_on_exception = false }
+ t.join
+ t.report_on_exception.should == false
end
end
- describe "when set to false" do
- it "lets the thread terminates silently with an exception" do
- t = nil
- -> {
- t = Thread.new {
- Thread.current.report_on_exception = false
- raise RuntimeError, "Thread#report_on_exception specs"
- }
- Thread.pass while t.alive?
- }.should output("", "")
-
- -> {
- t.join
- }.should raise_error(RuntimeError, "Thread#report_on_exception specs")
+ describe "Thread#report_on_exception=" do
+ describe "when set to true" do
+ it "prints a backtrace on $stderr if it terminates with an exception" do
+ t = nil
+ -> {
+ t = Thread.new {
+ Thread.current.report_on_exception = true
+ raise RuntimeError, "Thread#report_on_exception specs"
+ }
+ Thread.pass while t.alive?
+ }.should output("", /Thread.+terminated with exception.+Thread#report_on_exception specs/m)
+
+ -> {
+ t.join
+ }.should raise_error(RuntimeError, "Thread#report_on_exception specs")
+ end
end
- end
- describe "when used in conjunction with Thread#abort_on_exception" do
- it "first reports then send the exception back to the main Thread" do
- t = nil
- mutex = Mutex.new
- mutex.lock
- -> {
- t = Thread.new {
- Thread.current.abort_on_exception = true
- Thread.current.report_on_exception = true
- mutex.lock
- mutex.unlock
- raise RuntimeError, "Thread#report_on_exception specs"
- }
+ describe "when set to false" do
+ it "lets the thread terminates silently with an exception" do
+ t = nil
+ -> {
+ t = Thread.new {
+ Thread.current.report_on_exception = false
+ raise RuntimeError, "Thread#report_on_exception specs"
+ }
+ Thread.pass while t.alive?
+ }.should output("", "")
-> {
- mutex.sleep(5)
+ t.join
}.should raise_error(RuntimeError, "Thread#report_on_exception specs")
- }.should output("", /Thread.+terminated with exception.+Thread#report_on_exception specs/m)
+ end
+ end
- -> {
- t.join
- }.should raise_error(RuntimeError, "Thread#report_on_exception specs")
+ ruby_bug "#13163", "2.4"..."2.5" do
+ describe "when used in conjunction with Thread#abort_on_exception" do
+ it "first reports then send the exception back to the main Thread" do
+ t = nil
+ mutex = Mutex.new
+ mutex.lock
+ -> {
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ Thread.current.report_on_exception = true
+ mutex.lock
+ mutex.unlock
+ raise RuntimeError, "Thread#report_on_exception specs"
+ }
+
+ -> {
+ mutex.sleep(5)
+ }.should raise_error(RuntimeError, "Thread#report_on_exception specs")
+ }.should output("", /Thread.+terminated with exception.+Thread#report_on_exception specs/m)
+
+ -> {
+ t.join
+ }.should raise_error(RuntimeError, "Thread#report_on_exception specs")
+ end
+ end
end
end
end
diff --git a/spec/ruby/core/thread/run_spec.rb b/spec/ruby/core/thread/run_spec.rb
index f86f793489..26ed9ed961 100644
--- a/spec/ruby/core/thread/run_spec.rb
+++ b/spec/ruby/core/thread/run_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-require_relative 'shared/wakeup'
+require File.expand_path('../shared/wakeup', __FILE__)
describe "Thread#run" do
it_behaves_like :thread_wakeup, :run
end
+
diff --git a/spec/ruby/core/thread/set_trace_func_spec.rb b/spec/ruby/core/thread/set_trace_func_spec.rb
index e5d8298ae0..6dd5448d79 100644
--- a/spec/ruby/core/thread/set_trace_func_spec.rb
+++ b/spec/ruby/core/thread/set_trace_func_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread#set_trace_func" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/thread/shared/exit.rb b/spec/ruby/core/thread/shared/exit.rb
index 40dc478947..0c9198c538 100644
--- a/spec/ruby/core/thread/shared/exit.rb
+++ b/spec/ruby/core/thread/shared/exit.rb
@@ -3,10 +3,6 @@ describe :thread_exit, shared: true do
ScratchPad.clear
end
- # This spec randomly kills mspec worker like: https://ci.appveyor.com/project/ruby/ruby/builds/19390874/job/wv1bsm8skd4e1pxl
- # TODO: Investigate the cause or at least print helpful logs, and remove this `platform_is_not` guard.
- platform_is_not :mingw do
-
it "kills sleeping thread" do
sleeping_thread = Thread.new do
sleep
@@ -80,17 +76,19 @@ describe :thread_exit, shared: true do
ScratchPad.recorded.should == nil
end
- it "kills the entire thread when a fiber is active" do
- t = Thread.new do
- Fiber.new do
- sleep
- end.resume
- ScratchPad.record :fiber_resumed
+ with_feature :fiber do
+ it "kills the entire thread when a fiber is active" do
+ t = Thread.new do
+ Fiber.new do
+ sleep
+ end.resume
+ ScratchPad.record :fiber_resumed
+ end
+ Thread.pass while t.status and t.status != "sleep"
+ t.send(@method)
+ t.join
+ ScratchPad.recorded.should == nil
end
- Thread.pass while t.status and t.status != "sleep"
- t.send(@method)
- t.join
- ScratchPad.recorded.should == nil
end
# This spec is a mess. It fails randomly, it hangs on MRI, it needs to be removed
@@ -116,7 +114,7 @@ describe :thread_exit, shared: true do
it "propagates inner exception to Thread.join if there is an outer ensure clause" do
thread = ThreadSpecs.dying_thread_with_outer_ensure(@method) { }
- -> { thread.join }.should raise_error(RuntimeError, "In dying thread")
+ lambda { thread.join }.should raise_error(RuntimeError, "In dying thread")
end
it "runs all outer ensure clauses even if inner ensure clause raises exception" do
@@ -175,6 +173,4 @@ describe :thread_exit, shared: true do
t.join.should == t
end
end
-
- end # platform_is_not :mingw
end
diff --git a/spec/ruby/core/thread/shared/start.rb b/spec/ruby/core/thread/shared/start.rb
index 2ba926bf00..80ce063a0e 100644
--- a/spec/ruby/core/thread/shared/start.rb
+++ b/spec/ruby/core/thread/shared/start.rb
@@ -4,7 +4,7 @@ describe :thread_start, shared: true do
end
it "raises an ArgumentError if not passed a block" do
- -> {
+ lambda {
Thread.send(@method)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/thread/shared/to_s.rb b/spec/ruby/core/thread/shared/to_s.rb
deleted file mode 100644
index e47426cf3f..0000000000
--- a/spec/ruby/core/thread/shared/to_s.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :thread_to_s, shared: true do
- sep = ruby_version_is("2.7") ? " " : "@"
-
- it "returns a description including file and line number" do
- Thread.new { "hello" }.send(@method).should =~ /^#<Thread:([^ ]*?)#{sep}#{Regexp.escape __FILE__}:#{__LINE__ } \w+>$/
- end
-
- it "has a binary encoding" do
- Thread.new { "hello" }.send(@method).encoding.should == Encoding::BINARY
- end
-
- it "can check it's own status" do
- ThreadSpecs.status_of_current_thread.send(@method).should include('run')
- end
-
- it "describes a running thread" do
- ThreadSpecs.status_of_running_thread.send(@method).should include('run')
- end
-
- it "describes a sleeping thread" do
- ThreadSpecs.status_of_sleeping_thread.send(@method).should include('sleep')
- end
-
- it "describes a blocked thread" do
- ThreadSpecs.status_of_blocked_thread.send(@method).should include('sleep')
- end
-
- it "describes a completed thread" do
- ThreadSpecs.status_of_completed_thread.send(@method).should include('dead')
- end
-
- it "describes a killed thread" do
- ThreadSpecs.status_of_killed_thread.send(@method).should include('dead')
- end
-
- it "describes a thread with an uncaught exception" do
- ThreadSpecs.status_of_thread_with_uncaught_exception.send(@method).should include('dead')
- end
-
- it "describes a dying sleeping thread" do
- ThreadSpecs.status_of_dying_sleeping_thread.send(@method).should include('sleep')
- end
-
- it "reports aborting on a killed thread" do
- ThreadSpecs.status_of_dying_running_thread.send(@method).should include('aborting')
- end
-
- it "reports aborting on a killed thread after sleep" do
- ThreadSpecs.status_of_dying_thread_after_sleep.send(@method).should include('aborting')
- end
-end
diff --git a/spec/ruby/core/thread/shared/wakeup.rb b/spec/ruby/core/thread/shared/wakeup.rb
index f111edf0fd..71838d88e5 100644
--- a/spec/ruby/core/thread/shared/wakeup.rb
+++ b/spec/ruby/core/thread/shared/wakeup.rb
@@ -56,6 +56,6 @@ describe :thread_wakeup, shared: true do
it "raises a ThreadError when trying to wake up a dead thread" do
t = Thread.new { 1 }
t.join
- -> { t.send @method }.should raise_error(ThreadError)
+ lambda { t.send @method }.should raise_error(ThreadError)
end
end
diff --git a/spec/ruby/core/thread/start_spec.rb b/spec/ruby/core/thread/start_spec.rb
index 3dd040f98b..932e782382 100644
--- a/spec/ruby/core/thread/start_spec.rb
+++ b/spec/ruby/core/thread/start_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/start'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/start', __FILE__)
describe "Thread.start" do
describe "Thread.start" do
diff --git a/spec/ruby/core/thread/status_spec.rb b/spec/ruby/core/thread/status_spec.rb
index 4fde663c91..6cfdf0be40 100644
--- a/spec/ruby/core/thread/status_spec.rb
+++ b/spec/ruby/core/thread/status_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#status" do
it "can check it's own status" do
diff --git a/spec/ruby/core/thread/stop_spec.rb b/spec/ruby/core/thread/stop_spec.rb
index 33cf8f7b5c..0bc99487fd 100644
--- a/spec/ruby/core/thread/stop_spec.rb
+++ b/spec/ruby/core/thread/stop_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread.stop" do
it "causes the current thread to sleep indefinitely" do
diff --git a/spec/ruby/core/thread/terminate_spec.rb b/spec/ruby/core/thread/terminate_spec.rb
index cf6cab472b..bb89d87762 100644
--- a/spec/ruby/core/thread/terminate_spec.rb
+++ b/spec/ruby/core/thread/terminate_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/exit'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/exit', __FILE__)
describe "Thread#terminate" do
it_behaves_like :thread_exit, :terminate
diff --git a/spec/ruby/core/thread/thread_variable_get_spec.rb b/spec/ruby/core/thread/thread_variable_get_spec.rb
index 38f90d5830..0e02c30fad 100644
--- a/spec/ruby/core/thread/thread_variable_get_spec.rb
+++ b/spec/ruby/core/thread/thread_variable_get_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread#thread_variable_get" do
before :each do
diff --git a/spec/ruby/core/thread/thread_variable_set_spec.rb b/spec/ruby/core/thread/thread_variable_set_spec.rb
index 1338c306c7..0f55341132 100644
--- a/spec/ruby/core/thread/thread_variable_set_spec.rb
+++ b/spec/ruby/core/thread/thread_variable_set_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread#thread_variable_set" do
before :each do
diff --git a/spec/ruby/core/thread/thread_variable_spec.rb b/spec/ruby/core/thread/thread_variable_spec.rb
index 6bd1950c04..b409b3abfc 100644
--- a/spec/ruby/core/thread/thread_variable_spec.rb
+++ b/spec/ruby/core/thread/thread_variable_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread#thread_variable?" do
before :each do
diff --git a/spec/ruby/core/thread/thread_variables_spec.rb b/spec/ruby/core/thread/thread_variables_spec.rb
index 1bd68b17f1..39299cf20e 100644
--- a/spec/ruby/core/thread/thread_variables_spec.rb
+++ b/spec/ruby/core/thread/thread_variables_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Thread#thread_variables" do
before :each do
diff --git a/spec/ruby/core/thread/to_s_spec.rb b/spec/ruby/core/thread/to_s_spec.rb
deleted file mode 100644
index 85976177dc..0000000000
--- a/spec/ruby/core/thread/to_s_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_s'
-
-ruby_version_is "2.5" do
- describe "Thread#to_s" do
- it_behaves_like :thread_to_s, :to_s
- end
-end
diff --git a/spec/ruby/core/thread/value_spec.rb b/spec/ruby/core/thread/value_spec.rb
index 30e43abd1a..3d900959df 100644
--- a/spec/ruby/core/thread/value_spec.rb
+++ b/spec/ruby/core/thread/value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Thread#value" do
it "returns the result of the block" do
@@ -11,21 +11,11 @@ describe "Thread#value" do
Thread.current.report_on_exception = false
raise "Hello"
}
- -> { t.value }.should raise_error(RuntimeError, "Hello")
+ lambda { t.value }.should raise_error(RuntimeError, "Hello")
end
it "is nil for a killed thread" do
t = Thread.new { Thread.current.exit }
t.value.should == nil
end
-
- it "returns when the thread finished" do
- q = Queue.new
- t = Thread.new {
- q.pop
- }
- -> { t.value }.should block_caller
- q.push :result
- t.value.should == :result
- end
end
diff --git a/spec/ruby/core/thread/wakeup_spec.rb b/spec/ruby/core/thread/wakeup_spec.rb
index da5dfea377..5197a03a35 100644
--- a/spec/ruby/core/thread/wakeup_spec.rb
+++ b/spec/ruby/core/thread/wakeup_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/wakeup'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/wakeup', __FILE__)
describe "Thread#wakeup" do
it_behaves_like :thread_wakeup, :wakeup
diff --git a/spec/ruby/core/threadgroup/add_spec.rb b/spec/ruby/core/threadgroup/add_spec.rb
index 2921c1ab22..3b88d3460e 100644
--- a/spec/ruby/core/threadgroup/add_spec.rb
+++ b/spec/ruby/core/threadgroup/add_spec.rb
@@ -1,39 +1,36 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "ThreadGroup#add" do
before :each do
- @q1, @q2 = Queue.new, Queue.new
- @thread = Thread.new { @q1 << :go; @q2.pop }
- @q1.pop
+ @chan1,@chan2 = Channel.new,Channel.new
+ @thread = Thread.new { @chan1 << :go; @chan2.receive }
+ @chan1.receive
end
after :each do
- @q2 << :done
+ @chan2 << :done
@thread.join
end
- # This spec randomly kills mspec worker like: https://ci.appveyor.com/project/ruby/ruby/build/9806/job/37tx2atojy96227m
- # TODO: Investigate the cause or at least print helpful logs, and remove this `platform_is_not` guard.
- platform_is_not :mingw do
- it "adds the given thread to a group and returns self" do
- @thread.group.should_not == nil
+ it "adds the given thread to a group and returns self" do
+ @thread.group.should_not == nil
- tg = ThreadGroup.new
- tg.add(@thread).should == tg
- @thread.group.should == tg
- tg.list.include?(@thread).should == true
- end
+ tg = ThreadGroup.new
+ tg.add(@thread).should == tg
+ @thread.group.should == tg
+ tg.list.include?(@thread).should == true
+ end
- it "removes itself from any other threadgroup" do
- tg1 = ThreadGroup.new
- tg2 = ThreadGroup.new
+ it "removes itself from any other threadgroup" do
+ tg1 = ThreadGroup.new
+ tg2 = ThreadGroup.new
- tg1.add(@thread)
- @thread.group.should == tg1
- tg2.add(@thread)
- @thread.group.should == tg2
- tg2.list.include?(@thread).should == true
- tg1.list.include?(@thread).should == false
- end
+ tg1.add(@thread)
+ @thread.group.should == tg1
+ tg2.add(@thread)
+ @thread.group.should == tg2
+ tg2.list.include?(@thread).should == true
+ tg1.list.include?(@thread).should == false
end
end
diff --git a/spec/ruby/core/threadgroup/default_spec.rb b/spec/ruby/core/threadgroup/default_spec.rb
index d7d4726cc2..d72b86ed39 100644
--- a/spec/ruby/core/threadgroup/default_spec.rb
+++ b/spec/ruby/core/threadgroup/default_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ThreadGroup::Default" do
it "is a ThreadGroup instance" do
diff --git a/spec/ruby/core/threadgroup/enclose_spec.rb b/spec/ruby/core/threadgroup/enclose_spec.rb
index dd9a7a362d..5827ddb6aa 100644
--- a/spec/ruby/core/threadgroup/enclose_spec.rb
+++ b/spec/ruby/core/threadgroup/enclose_spec.rb
@@ -1,14 +1,15 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "ThreadGroup#enclose" do
before :each do
- @q1, @q2 = Queue.new, Queue.new
- @thread = Thread.new { @q1 << :go; @q2.pop }
- @q1.pop
+ @chan1,@chan2 = Channel.new,Channel.new
+ @thread = Thread.new { @chan1 << :go; @chan2.receive }
+ @chan1.receive
end
after :each do
- @q2 << :done
+ @chan2 << :done
@thread.join
end
@@ -17,7 +18,7 @@ describe "ThreadGroup#enclose" do
default_group = @thread.group
thread_group.add(@thread)
thread_group.enclose
- -> do
+ lambda do
default_group.add(@thread)
end.should raise_error(ThreadError)
end
diff --git a/spec/ruby/core/threadgroup/enclosed_spec.rb b/spec/ruby/core/threadgroup/enclosed_spec.rb
index a734256a64..2c1c79f24a 100644
--- a/spec/ruby/core/threadgroup/enclosed_spec.rb
+++ b/spec/ruby/core/threadgroup/enclosed_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ThreadGroup#enclosed?" do
it "returns false when a ThreadGroup has not been enclosed (default state)" do
diff --git a/spec/ruby/core/threadgroup/fixtures/classes.rb b/spec/ruby/core/threadgroup/fixtures/classes.rb
new file mode 100644
index 0000000000..7dfe5e92d1
--- /dev/null
+++ b/spec/ruby/core/threadgroup/fixtures/classes.rb
@@ -0,0 +1,6 @@
+unless defined? Channel
+ require 'thread'
+ class Channel < Queue
+ alias receive shift
+ end
+end
diff --git a/spec/ruby/core/threadgroup/list_spec.rb b/spec/ruby/core/threadgroup/list_spec.rb
index b2ac64324a..aa7b3f73fa 100644
--- a/spec/ruby/core/threadgroup/list_spec.rb
+++ b/spec/ruby/core/threadgroup/list_spec.rb
@@ -1,16 +1,17 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "ThreadGroup#list" do
it "returns the list of threads in the group" do
- q = Queue.new
- th1 = Thread.new { q << :go; sleep }
- q.pop.should == :go
+ chan = Channel.new
+ th1 = Thread.new { chan << :go; sleep }
+ chan.receive.should == :go
tg = ThreadGroup.new
tg.add(th1)
tg.list.should include(th1)
- th2 = Thread.new { q << :go; sleep }
- q.pop.should == :go
+ th2 = Thread.new { chan << :go; sleep }
+ chan.receive.should == :go
tg.add(th2)
(tg.list & [th1, th2]).should include(th1, th2)
diff --git a/spec/ruby/core/time/_dump_spec.rb b/spec/ruby/core/time/_dump_spec.rb
index 6941a1531f..bec16dab69 100644
--- a/spec/ruby/core/time/_dump_spec.rb
+++ b/spec/ruby/core/time/_dump_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#_dump" do
before :each do
@@ -53,3 +53,4 @@ describe "Time#_dump" do
t.send(:_dump).should == "\364\001\031\200\313\000\020\004"
end
end
+
diff --git a/spec/ruby/core/time/_load_spec.rb b/spec/ruby/core/time/_load_spec.rb
index 152934370f..12fcb219ed 100644
--- a/spec/ruby/core/time/_load_spec.rb
+++ b/spec/ruby/core/time/_load_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time._load" do
it "is a private method" do
@@ -43,10 +43,12 @@ describe "Time._load" do
t.to_s.should == "2010-10-22 16:57:48 UTC"
end
- it "treats the data as binary data" do
- data = "\x04\bu:\tTime\r\fM\x1C\xC0\x00\x00\xD0\xBE"
- data.force_encoding Encoding::UTF_8
- t = Marshal.load(data)
- t.to_s.should == "2013-04-08 12:47:45 UTC"
+ with_feature :encoding do
+ it "treats the data as binary data" do
+ data = "\x04\bu:\tTime\r\fM\x1C\xC0\x00\x00\xD0\xBE"
+ data.force_encoding Encoding::UTF_8
+ t = Marshal.load(data)
+ t.to_s.should == "2013-04-08 12:47:45 UTC"
+ end
end
end
diff --git a/spec/ruby/core/time/asctime_spec.rb b/spec/ruby/core/time/asctime_spec.rb
index a41ee531e4..3303e06f21 100644
--- a/spec/ruby/core/time/asctime_spec.rb
+++ b/spec/ruby/core/time/asctime_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/asctime'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/asctime', __FILE__)
describe "Time#asctime" do
- it_behaves_like :time_asctime, :asctime
+ it_behaves_like(:time_asctime, :asctime)
end
diff --git a/spec/ruby/core/time/at_spec.rb b/spec/ruby/core/time/at_spec.rb
index 368eeb7fca..6883a8d074 100644
--- a/spec/ruby/core/time/at_spec.rb
+++ b/spec/ruby/core/time/at_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time.at" do
describe "passed Numeric" do
@@ -35,7 +34,7 @@ describe "Time.at" do
describe "passed BigDecimal" do
it "doesn't round input value" do
require 'bigdecimal'
- Time.at(BigDecimal('1.1')).to_f.should == 1.1
+ Time.at(BigDecimal.new('1.1')).to_f.should == 1.1
end
end
end
@@ -49,7 +48,7 @@ describe "Time.at" do
it "creates a dup time object with the value given by time" do
t1 = Time.new
t2 = Time.at(t1)
- t1.should_not equal t2
+ t1.object_id.should_not == t2.object_id
end
it "returns a UTC time if the argument is UTC" do
@@ -71,11 +70,11 @@ describe "Time.at" do
describe "passed non-Time, non-Numeric" do
it "raises a TypeError with a String argument" do
- -> { Time.at("0") }.should raise_error(TypeError)
+ lambda { Time.at("0") }.should raise_error(TypeError)
end
it "raises a TypeError with a nil argument" do
- -> { Time.at(nil) }.should raise_error(TypeError)
+ lambda { Time.at(nil) }.should raise_error(TypeError)
end
describe "with an argument that responds to #to_int" do
@@ -127,66 +126,66 @@ describe "Time.at" do
describe "passed [Integer, nil]" do
it "raises a TypeError" do
- -> { Time.at(0, nil) }.should raise_error(TypeError)
+ lambda { Time.at(0, nil) }.should raise_error(TypeError)
end
end
describe "passed [Integer, String]" do
it "raises a TypeError" do
- -> { Time.at(0, "0") }.should raise_error(TypeError)
+ lambda { Time.at(0, "0") }.should raise_error(TypeError)
end
end
describe "passed [Time, Integer]" do
# #8173
it "raises a TypeError" do
- -> { Time.at(Time.now, 500000) }.should raise_error(TypeError)
+ lambda { Time.at(Time.now, 500000) }.should raise_error(TypeError)
end
end
ruby_version_is "2.5" do
describe "passed [Time, Numeric, format]" do
context ":nanosecond format" do
- it "treats second argument as nanoseconds" do
+ it "traits second argument as nanoseconds" do
Time.at(0, 123456789, :nanosecond).nsec.should == 123456789
end
end
context ":nsec format" do
- it "treats second argument as nanoseconds" do
+ it "traits second argument as nanoseconds" do
Time.at(0, 123456789, :nsec).nsec.should == 123456789
end
end
context ":microsecond format" do
- it "treats second argument as microseconds" do
+ it "traits second argument as microseconds" do
Time.at(0, 123456, :microsecond).nsec.should == 123456000
end
end
context ":usec format" do
- it "treats second argument as microseconds" do
+ it "traits second argument as microseconds" do
Time.at(0, 123456, :usec).nsec.should == 123456000
end
end
context ":millisecond format" do
- it "treats second argument as milliseconds" do
+ it "traits second argument as milliseconds" do
Time.at(0, 123, :millisecond).nsec.should == 123000000
end
end
context "not supported format" do
it "raises ArgumentError" do
- -> { Time.at(0, 123456, 2) }.should raise_error(ArgumentError)
- -> { Time.at(0, 123456, nil) }.should raise_error(ArgumentError)
- -> { Time.at(0, 123456, :invalid) }.should raise_error(ArgumentError)
+ ->() { Time.at(0, 123456, 2) }.should raise_error(ArgumentError)
+ ->() { Time.at(0, 123456, nil) }.should raise_error(ArgumentError)
+ ->() { Time.at(0, 123456, :invalid) }.should raise_error(ArgumentError)
end
it "does not try to convert format to Symbol with #to_sym" do
format = "usec"
format.should_not_receive(:to_sym)
- -> { Time.at(0, 123456, format) }.should raise_error(ArgumentError)
+ -> () { Time.at(0, 123456, format) }.should raise_error(ArgumentError)
end
end
@@ -199,56 +198,4 @@ describe "Time.at" do
end
end
end
-
- ruby_version_is "2.6" do
- describe ":in keyword argument" do
- before do
- @epoch_time = Time.now.to_i
- end
-
- it "could be UTC offset as a String in '+HH:MM or '-HH:MM' format" do
- time = Time.at(@epoch_time, in: "+05:00")
-
- time.utc_offset.should == 5*60*60
- time.zone.should == nil
- time.to_i.should == @epoch_time
-
- time = Time.at(@epoch_time, in: "-09:00")
-
- time.utc_offset.should == -9*60*60
- time.zone.should == nil
- time.to_i.should == @epoch_time
- end
-
- it "could be UTC offset as a number of seconds" do
- time = Time.at(@epoch_time, in: 5*60*60)
-
- time.utc_offset.should == 5*60*60
- time.zone.should == nil
- time.to_i.should == @epoch_time
-
- time = Time.at(@epoch_time, in: -9*60*60)
-
- time.utc_offset.should == -9*60*60
- time.zone.should == nil
- time.to_i.should == @epoch_time
- end
-
- it "could be a timezone object" do
- zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo")
- time = Time.at(@epoch_time, in: zone)
-
- time.utc_offset.should == 5*3600+30*60
- time.zone.should == zone
- time.to_i.should == @epoch_time
-
- zone = TimeSpecs::TimezoneWithName.new(name: "PST")
- time = Time.at(@epoch_time, in: zone)
-
- time.utc_offset.should == -9*60*60
- time.zone.should == zone
- time.to_i.should == @epoch_time
- end
- end
- end
end
diff --git a/spec/ruby/core/time/ceil_spec.rb b/spec/ruby/core/time/ceil_spec.rb
deleted file mode 100644
index 29dcec5d72..0000000000
--- a/spec/ruby/core/time/ceil_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.7" do
- describe "Time#ceil" do
- before do
- @time = Time.utc(2010, 3, 30, 5, 43, "25.0123456789".to_r)
- end
-
- it "defaults to ceiling to 0 places" do
- @time.ceil.should == Time.utc(2010, 3, 30, 5, 43, 26.to_r)
- end
-
- it "ceils to 0 decimal places with an explicit argument" do
- @time.ceil(0).should == Time.utc(2010, 3, 30, 5, 43, 26.to_r)
- end
-
- it "ceils to 2 decimal places with an explicit argument" do
- @time.ceil(2).should == Time.utc(2010, 3, 30, 5, 43, "25.02".to_r)
- end
-
- it "ceils to 4 decimal places with an explicit argument" do
- @time.ceil(4).should == Time.utc(2010, 3, 30, 5, 43, "25.0124".to_r)
- end
-
- it "ceils to 7 decimal places with an explicit argument" do
- @time.ceil(7).should == Time.utc(2010, 3, 30, 5, 43, "25.0123457".to_r)
- end
-
- it "returns an instance of Time, even if #ceil is called on a subclass" do
- subclass = Class.new(Time)
- instance = subclass.at(0)
- instance.class.should equal subclass
- instance.ceil.should be_an_instance_of(Time)
- end
-
- it "copies own timezone to the returning value" do
- @time.zone.should == @time.ceil.zone
-
- with_timezone "JST-9" do
- time = Time.at 0, 1
- time.zone.should == time.ceil.zone
- end
- end
- end
-end
diff --git a/spec/ruby/core/time/comparison_spec.rb b/spec/ruby/core/time/comparison_spec.rb
index 5b53c9fb50..c5a5b83d28 100644
--- a/spec/ruby/core/time/comparison_spec.rb
+++ b/spec/ruby/core/time/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#<=>" do
it "returns 1 if the first argument is a point in time after the second argument" do
@@ -45,16 +45,6 @@ describe "Time#<=>" do
(Time.at(100, 0) <=> Time.at(100, Rational(1,1000))).should == -1
end
- it "returns nil when compared to an Integer because Time does not respond to #coerce" do
- time = Time.at(1)
- time.respond_to?(:coerce).should == false
- time.should_receive(:respond_to?).exactly(2).and_return(false)
- -> {
- (time <=> 2).should == nil
- (2 <=> time).should == nil
- }.should_not complain
- end
-
describe "given a non-Time argument" do
it "returns nil if argument <=> self returns nil" do
t = Time.now
diff --git a/spec/ruby/core/time/ctime_spec.rb b/spec/ruby/core/time/ctime_spec.rb
index 57e7cfd9ce..cf9c1ee850 100644
--- a/spec/ruby/core/time/ctime_spec.rb
+++ b/spec/ruby/core/time/ctime_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/asctime'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/asctime', __FILE__)
describe "Time#ctime" do
- it_behaves_like :time_asctime, :ctime
+ it_behaves_like(:time_asctime, :ctime)
end
diff --git a/spec/ruby/core/time/day_spec.rb b/spec/ruby/core/time/day_spec.rb
index 895bcd7a86..8e77446070 100644
--- a/spec/ruby/core/time/day_spec.rb
+++ b/spec/ruby/core/time/day_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/day'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/day', __FILE__)
describe "Time#day" do
- it_behaves_like :time_day, :day
+ it_behaves_like(:time_day, :day)
end
diff --git a/spec/ruby/core/time/dst_spec.rb b/spec/ruby/core/time/dst_spec.rb
index 436240aae5..05a0a213c5 100644
--- a/spec/ruby/core/time/dst_spec.rb
+++ b/spec/ruby/core/time/dst_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/isdst'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/isdst', __FILE__)
describe "Time#dst?" do
- it_behaves_like :time_isdst, :dst?
+ it_behaves_like(:time_isdst, :dst?)
end
diff --git a/spec/ruby/core/time/dup_spec.rb b/spec/ruby/core/time/dup_spec.rb
index ee2ff7dbba..b32ce96d44 100644
--- a/spec/ruby/core/time/dup_spec.rb
+++ b/spec/ruby/core/time/dup_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#dup" do
it "returns a Time object that represents the same time" do
diff --git a/spec/ruby/core/time/eql_spec.rb b/spec/ruby/core/time/eql_spec.rb
index 2ffb4eec96..af96c96cc3 100644
--- a/spec/ruby/core/time/eql_spec.rb
+++ b/spec/ruby/core/time/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#eql?" do
it "returns true if self and other have the same whole number of seconds" do
diff --git a/spec/ruby/core/time/fixtures/classes.rb b/spec/ruby/core/time/fixtures/classes.rb
index 1a9511b261..328f9160f6 100644
--- a/spec/ruby/core/time/fixtures/classes.rb
+++ b/spec/ruby/core/time/fixtures/classes.rb
@@ -9,98 +9,4 @@ module TimeSpecs
end
end
- class Timezone
- def initialize(options)
- @offset = options[:offset]
- end
-
- def local_to_utc(t)
- t - @offset
- end
-
- def utc_to_local(t)
- t + @offset
- end
- end
-
- class TimezoneMethodCallRecorder < Timezone
- def initialize(options, &blk)
- super(options)
- @blk = blk
- end
-
- def local_to_utc(t)
- @blk.call(t)
- super
- end
-
- def utc_to_local(t)
- @blk.call(t)
- super
- end
- end
-
- class TimeLikeArgumentRecorder
- def self.result
- arguments = []
-
- zone = TimeSpecs::TimezoneMethodCallRecorder.new(offset: 0) do |obj|
- arguments << obj
- end
-
- # ensure timezone's methods are called at least once
- Time.new(2000, 1, 1, 12, 0, 0, zone)
-
- return arguments[0]
- end
- end
-
- Z = Struct.new(:offset, :abbr)
- Zone = Struct.new(:std, :dst, :dst_range)
- Zones = {
- "Asia/Colombo" => Zone[Z[5*3600+30*60, "MMT"], nil, nil],
- "Europe/Kiev" => Zone[Z[2*3600, "EET"], Z[3*3600, "EEST"], 4..10],
- "PST" => Zone[Z[(-9*60*60), "PST"], nil, nil],
- }
-
- class TimezoneWithName < Timezone
- attr_reader :name
-
- def initialize(options)
- @name = options[:name]
- @std, @dst, @dst_range = *Zones[@name]
- end
-
- def dst?(t)
- @dst_range&.cover?(t.mon)
- end
-
- def zone(t)
- (dst?(t) ? @dst : @std)
- end
-
- def utc_offset(t)
- zone(t)&.offset || 0
- end
-
- def abbr(t)
- zone(t)&.abbr
- end
-
- def local_to_utc(t)
- t - utc_offset(t)
- end
-
- def utc_to_local(t)
- t + utc_offset(t)
- end
- end
-
- class TimeWithFindTimezone < Time
- def self.find_timezone(name)
- TimezoneWithName.new(name: name.to_s)
- end
- end
-
- TimezoneWithAbbr = TimezoneWithName
end
diff --git a/spec/ruby/core/time/floor_spec.rb b/spec/ruby/core/time/floor_spec.rb
deleted file mode 100644
index 763ed1ba51..0000000000
--- a/spec/ruby/core/time/floor_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.7" do
- describe "Time#floor" do
- before do
- @time = Time.utc(2010, 3, 30, 5, 43, "25.123456789".to_r)
- end
-
- it "defaults to flooring to 0 places" do
- @time.floor.should == Time.utc(2010, 3, 30, 5, 43, 25.to_r)
- end
-
- it "floors to 0 decimal places with an explicit argument" do
- @time.floor(0).should == Time.utc(2010, 3, 30, 5, 43, 25.to_r)
- end
-
- it "floors to 7 decimal places with an explicit argument" do
- @time.floor(7).should == Time.utc(2010, 3, 30, 5, 43, "25.1234567".to_r)
- end
-
- it "returns an instance of Time, even if #floor is called on a subclass" do
- subclass = Class.new(Time)
- instance = subclass.at(0)
- instance.class.should equal subclass
- instance.floor.should be_an_instance_of(Time)
- end
-
- it "copies own timezone to the returning value" do
- @time.zone.should == @time.floor.zone
-
- with_timezone "JST-9" do
- time = Time.at 0, 1
- time.zone.should == time.floor.zone
- end
- end
- end
-end
diff --git a/spec/ruby/core/time/friday_spec.rb b/spec/ruby/core/time/friday_spec.rb
index 27f9e1dbe5..d38a261080 100644
--- a/spec/ruby/core/time/friday_spec.rb
+++ b/spec/ruby/core/time/friday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#friday?" do
it "returns true if time represents Friday" do
diff --git a/spec/ruby/core/time/getgm_spec.rb b/spec/ruby/core/time/getgm_spec.rb
index b5d45b1d9f..f091b5c493 100644
--- a/spec/ruby/core/time/getgm_spec.rb
+++ b/spec/ruby/core/time/getgm_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/getgm'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/getgm', __FILE__)
describe "Time#getgm" do
- it_behaves_like :time_getgm, :getgm
+ it_behaves_like(:time_getgm, :getgm)
end
diff --git a/spec/ruby/core/time/getlocal_spec.rb b/spec/ruby/core/time/getlocal_spec.rb
index 7196577dab..a94d7f751b 100644
--- a/spec/ruby/core/time/getlocal_spec.rb
+++ b/spec/ruby/core/time/getlocal_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#getlocal" do
it "returns a new time which is the local representation of time" do
@@ -77,93 +76,23 @@ describe "Time#getlocal" do
it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do
t = Time.now
- -> { t.getlocal("3600") }.should raise_error(ArgumentError)
+ lambda { t.getlocal("3600") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do
t = Time.now
- -> { t.getlocal("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
+ lambda { t.getlocal("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do
t = Time.new
t.getlocal(-86400 + 1).utc_offset.should == (-86400 + 1)
- -> { t.getlocal(-86400) }.should raise_error(ArgumentError)
+ lambda { t.getlocal(-86400) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do
t = Time.new
t.getlocal(86400 - 1).utc_offset.should == (86400 - 1)
- -> { t.getlocal(86400) }.should raise_error(ArgumentError)
- end
-
- ruby_version_is "2.6" do
- describe "with a timezone argument" do
- it "returns a Time in the timezone" do
- zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
- time = Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone)
-
- time.zone.should == zone
- time.utc_offset.should == 5*3600+30*60
- end
-
- it "accepts timezone argument that must have #local_to_utc and #utc_to_local methods" do
- zone = Object.new
- def zone.utc_to_local(time)
- time
- end
- def zone.local_to_utc(time)
- time
- end
-
- -> {
- Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time)
- }.should_not raise_error
- end
-
- it "raises TypeError if timezone does not implement #utc_to_local method" do
- zone = Object.new
- def zone.local_to_utc(time)
- time
- end
-
- -> {
- Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone)
- }.should raise_error(TypeError, /can't convert \w+ into an exact number/)
- end
-
- it "does not raise exception if timezone does not implement #local_to_utc method" do
- zone = Object.new
- def zone.utc_to_local(time)
- time
- end
-
- -> {
- Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time)
- }.should_not raise_error
- end
-
- context "subject's class implements .find_timezone method" do
- it "calls .find_timezone to build a time object if passed zone name as a timezone argument" do
- time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0).getlocal("Asia/Colombo")
- time.zone.should be_kind_of TimeSpecs::TimezoneWithName
- time.zone.name.should == "Asia/Colombo"
-
- time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0).getlocal("some invalid zone name")
- time.zone.should be_kind_of TimeSpecs::TimezoneWithName
- time.zone.name.should == "some invalid zone name"
- end
-
- it "does not call .find_timezone if passed any not string/numeric/timezone timezone argument" do
- [Object.new, [], {}, :"some zone"].each do |zone|
- time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0)
-
- -> {
- time.getlocal(zone)
- }.should raise_error(TypeError, /can't convert \w+ into an exact number/)
- end
- end
- end
- end
+ lambda { t.getlocal(86400) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/time/getutc_spec.rb b/spec/ruby/core/time/getutc_spec.rb
index 0cd9c17b00..a6e74cfb98 100644
--- a/spec/ruby/core/time/getutc_spec.rb
+++ b/spec/ruby/core/time/getutc_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/getgm'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/getgm', __FILE__)
describe "Time#getutc" do
- it_behaves_like :time_getgm, :getutc
+ it_behaves_like(:time_getgm, :getutc)
end
diff --git a/spec/ruby/core/time/gm_spec.rb b/spec/ruby/core/time/gm_spec.rb
index 26dffbcedc..a6f2858216 100644
--- a/spec/ruby/core/time/gm_spec.rb
+++ b/spec/ruby/core/time/gm_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gm'
-require_relative 'shared/time_params'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gm', __FILE__)
+require File.expand_path('../shared/time_params', __FILE__)
describe "Time.gm" do
- it_behaves_like :time_gm, :gm
- it_behaves_like :time_params, :gm
- it_behaves_like :time_params_10_arg, :gm
- it_behaves_like :time_params_microseconds, :gm
+ it_behaves_like(:time_gm, :gm)
+ it_behaves_like(:time_params, :gm)
+ it_behaves_like(:time_params_10_arg, :gm)
+ it_behaves_like(:time_params_microseconds, :gm)
end
diff --git a/spec/ruby/core/time/gmt_offset_spec.rb b/spec/ruby/core/time/gmt_offset_spec.rb
index df417e6e4e..b7613eed2f 100644
--- a/spec/ruby/core/time/gmt_offset_spec.rb
+++ b/spec/ruby/core/time/gmt_offset_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gmt_offset'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gmt_offset', __FILE__)
describe "Time#gmt_offset" do
- it_behaves_like :time_gmt_offset, :gmt_offset
+ it_behaves_like(:time_gmt_offset, :gmt_offset)
end
diff --git a/spec/ruby/core/time/gmt_spec.rb b/spec/ruby/core/time/gmt_spec.rb
index 7e85749d5b..78ebcd0f5e 100644
--- a/spec/ruby/core/time/gmt_spec.rb
+++ b/spec/ruby/core/time/gmt_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#gmt?" do
it "returns true if time represents a time in UTC (GMT)" do
diff --git a/spec/ruby/core/time/gmtime_spec.rb b/spec/ruby/core/time/gmtime_spec.rb
index d965cd541d..49a1f10479 100644
--- a/spec/ruby/core/time/gmtime_spec.rb
+++ b/spec/ruby/core/time/gmtime_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gmtime'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gmtime', __FILE__)
describe "Time#gmtime" do
- it_behaves_like :time_gmtime, :gmtime
+ it_behaves_like(:time_gmtime, :gmtime)
end
diff --git a/spec/ruby/core/time/gmtoff_spec.rb b/spec/ruby/core/time/gmtoff_spec.rb
index fa28520e9e..505b5d0c1b 100644
--- a/spec/ruby/core/time/gmtoff_spec.rb
+++ b/spec/ruby/core/time/gmtoff_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gmt_offset'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gmt_offset', __FILE__)
describe "Time#gmtoff" do
- it_behaves_like :time_gmt_offset, :gmtoff
+ it_behaves_like(:time_gmt_offset, :gmtoff)
end
diff --git a/spec/ruby/core/time/hash_spec.rb b/spec/ruby/core/time/hash_spec.rb
index 577aaf9b0a..77014c5dc8 100644
--- a/spec/ruby/core/time/hash_spec.rb
+++ b/spec/ruby/core/time/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#hash" do
it "returns a Fixnum" do
diff --git a/spec/ruby/core/time/hour_spec.rb b/spec/ruby/core/time/hour_spec.rb
index ca69c25adb..65a2ae6ad7 100644
--- a/spec/ruby/core/time/hour_spec.rb
+++ b/spec/ruby/core/time/hour_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#hour" do
it "returns the hour of the day (0..23) for a local Time" do
diff --git a/spec/ruby/core/time/inspect_spec.rb b/spec/ruby/core/time/inspect_spec.rb
index 01e1dfdaa6..7f57a2c4cb 100644
--- a/spec/ruby/core/time/inspect_spec.rb
+++ b/spec/ruby/core/time/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/inspect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "Time#inspect" do
it_behaves_like :inspect, :inspect
diff --git a/spec/ruby/core/time/isdst_spec.rb b/spec/ruby/core/time/isdst_spec.rb
index 173230ca07..de71bf68ff 100644
--- a/spec/ruby/core/time/isdst_spec.rb
+++ b/spec/ruby/core/time/isdst_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/isdst'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/isdst', __FILE__)
describe "Time#isdst" do
- it_behaves_like :time_isdst, :isdst
+ it_behaves_like(:time_isdst, :isdst)
end
diff --git a/spec/ruby/core/time/local_spec.rb b/spec/ruby/core/time/local_spec.rb
index 581ed171d5..63c644e4ea 100644
--- a/spec/ruby/core/time/local_spec.rb
+++ b/spec/ruby/core/time/local_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/local'
-require_relative 'shared/time_params'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/local', __FILE__)
+require File.expand_path('../shared/time_params', __FILE__)
describe "Time.local" do
- it_behaves_like :time_local, :local
- it_behaves_like :time_local_10_arg, :local
- it_behaves_like :time_params, :local
- it_behaves_like :time_params_10_arg, :local
- it_behaves_like :time_params_microseconds, :local
+ it_behaves_like(:time_local, :local)
+ it_behaves_like(:time_local_10_arg, :local)
+ it_behaves_like(:time_params, :local)
+ it_behaves_like(:time_params_10_arg, :local)
+ it_behaves_like(:time_params_microseconds, :local)
end
diff --git a/spec/ruby/core/time/localtime_spec.rb b/spec/ruby/core/time/localtime_spec.rb
index 2975e112d0..2fc8a2d56a 100644
--- a/spec/ruby/core/time/localtime_spec.rb
+++ b/spec/ruby/core/time/localtime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#localtime" do
it "converts self to local time, modifying the receiver" do
@@ -32,7 +32,7 @@ describe "Time#localtime" do
it "raises a RuntimeError if the time has a different time zone" do
time = Time.gm(2007, 1, 9, 12, 0, 0)
time.freeze
- -> { time.localtime }.should raise_error(RuntimeError)
+ lambda { time.localtime }.should raise_error(RuntimeError)
end
end
@@ -93,7 +93,7 @@ describe "Time#localtime" do
it "does nothing if already in a local time zone" do
time = with_timezone("America/New_York") do
- Time.new(2005, 2, 27, 22, 50, 0)
+ break Time.new(2005, 2, 27, 22, 50, 0)
end
zone = time.zone
@@ -118,23 +118,23 @@ describe "Time#localtime" do
it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do
t = Time.now
- -> { t.localtime("3600") }.should raise_error(ArgumentError)
+ lambda { t.localtime("3600") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do
t = Time.now
- -> { t.localtime("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
+ lambda { t.localtime("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do
t = Time.new
t.localtime(-86400 + 1).utc_offset.should == (-86400 + 1)
- -> { t.localtime(-86400) }.should raise_error(ArgumentError)
+ lambda { t.localtime(-86400) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do
t = Time.new
t.localtime(86400 - 1).utc_offset.should == (86400 - 1)
- -> { t.localtime(86400) }.should raise_error(ArgumentError)
+ lambda { t.localtime(86400) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/time/mday_spec.rb b/spec/ruby/core/time/mday_spec.rb
index 3c21939890..5fbff299cc 100644
--- a/spec/ruby/core/time/mday_spec.rb
+++ b/spec/ruby/core/time/mday_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/day'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/day', __FILE__)
describe "Time#mday" do
- it_behaves_like :time_day, :mday
+ it_behaves_like(:time_day, :mday)
end
diff --git a/spec/ruby/core/time/min_spec.rb b/spec/ruby/core/time/min_spec.rb
index 7d087d4046..c1c3ebed3b 100644
--- a/spec/ruby/core/time/min_spec.rb
+++ b/spec/ruby/core/time/min_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#min" do
it "returns the minute of the hour (0..59) for a local Time" do
diff --git a/spec/ruby/core/time/minus_spec.rb b/spec/ruby/core/time/minus_spec.rb
index e0fbf94cb0..4e2bb60333 100644
--- a/spec/ruby/core/time/minus_spec.rb
+++ b/spec/ruby/core/time/minus_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#-" do
it "decrements the time by the specified amount" do
@@ -20,18 +19,18 @@ describe "Time#-" do
end
it "raises a TypeError if given argument is a coercible String" do
- -> { Time.now - "1" }.should raise_error(TypeError)
- -> { Time.now - "0.1" }.should raise_error(TypeError)
- -> { Time.now - "1/3" }.should raise_error(TypeError)
+ lambda { Time.now - "1" }.should raise_error(TypeError)
+ lambda { Time.now - "0.1" }.should raise_error(TypeError)
+ lambda { Time.now - "1/3" }.should raise_error(TypeError)
end
it "raises TypeError on argument that can't be coerced" do
- -> { Time.now - Object.new }.should raise_error(TypeError)
- -> { Time.now - "stuff" }.should raise_error(TypeError)
+ lambda { Time.now - Object.new }.should raise_error(TypeError)
+ lambda { Time.now - "stuff" }.should raise_error(TypeError)
end
it "raises TypeError on nil argument" do
- -> { Time.now - nil }.should raise_error(TypeError)
+ lambda { Time.now - nil }.should raise_error(TypeError)
end
it "tracks microseconds" do
@@ -90,25 +89,6 @@ describe "Time#-" do
(Time.new(2012, 1, 1, 0, 0, 0, 3600) - 10).utc_offset.should == 3600
end
- it "preserves time zone" do
- time_with_zone = Time.now.utc
- time_with_zone.zone.should == (time_with_zone - 60*60).zone
-
- time_with_zone = Time.now
- time_with_zone.zone.should == (time_with_zone - 60*60).zone
- end
-
- ruby_version_is "2.6" do
- context "zone is a timezone object" do
- it "preserves time zone" do
- zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
- time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
-
- time.zone.should == zone
- end
- end
- end
-
it "does not return a subclass instance" do
c = Class.new(Time)
x = c.now + 1
diff --git a/spec/ruby/core/time/mktime_spec.rb b/spec/ruby/core/time/mktime_spec.rb
index 78a6a6e772..68ac1b90ac 100644
--- a/spec/ruby/core/time/mktime_spec.rb
+++ b/spec/ruby/core/time/mktime_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/local'
-require_relative 'shared/time_params'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/local', __FILE__)
+require File.expand_path('../shared/time_params', __FILE__)
describe "Time.mktime" do
- it_behaves_like :time_local, :mktime
- it_behaves_like :time_local_10_arg, :mktime
- it_behaves_like :time_params, :mktime
- it_behaves_like :time_params_10_arg, :mktime
- it_behaves_like :time_params_microseconds, :mktime
+ it_behaves_like(:time_local, :mktime)
+ it_behaves_like(:time_local_10_arg, :mktime)
+ it_behaves_like(:time_params, :mktime)
+ it_behaves_like(:time_params_10_arg, :mktime)
+ it_behaves_like(:time_params_microseconds, :mktime)
end
diff --git a/spec/ruby/core/time/mon_spec.rb b/spec/ruby/core/time/mon_spec.rb
index f41b39648b..2408341143 100644
--- a/spec/ruby/core/time/mon_spec.rb
+++ b/spec/ruby/core/time/mon_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/month'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/month', __FILE__)
describe "Time#mon" do
- it_behaves_like :time_month, :mon
+ it_behaves_like(:time_month, :mon)
end
diff --git a/spec/ruby/core/time/monday_spec.rb b/spec/ruby/core/time/monday_spec.rb
index c5c43a5c3e..47b09c9a07 100644
--- a/spec/ruby/core/time/monday_spec.rb
+++ b/spec/ruby/core/time/monday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#monday?" do
it "returns true if time represents Monday" do
diff --git a/spec/ruby/core/time/month_spec.rb b/spec/ruby/core/time/month_spec.rb
index 81e20384ab..6323c6205a 100644
--- a/spec/ruby/core/time/month_spec.rb
+++ b/spec/ruby/core/time/month_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/month'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/month', __FILE__)
describe "Time#month" do
- it_behaves_like :time_month, :month
+ it_behaves_like(:time_month, :month)
end
diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb
index 064e03f056..a92715c81c 100644
--- a/spec/ruby/core/time/new_spec.rb
+++ b/spec/ruby/core/time/new_spec.rb
@@ -1,16 +1,15 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/now'
-require_relative 'shared/local'
-require_relative 'shared/time_params'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/now', __FILE__)
+require File.expand_path('../shared/local', __FILE__)
+require File.expand_path('../shared/time_params', __FILE__)
describe "Time.new" do
- it_behaves_like :time_now, :new
+ it_behaves_like(:time_now, :new)
end
describe "Time.new" do
- it_behaves_like :time_local, :new
- it_behaves_like :time_params, :new
+ it_behaves_like(:time_local, :new)
+ it_behaves_like(:time_params, :new)
end
describe "Time.new with a utc_offset argument" do
@@ -50,14 +49,6 @@ describe "Time.new with a utc_offset argument" do
Time.new(2000, 1, 1, 0, 0, 0, "-04:10").utc_offset.should == -15000
end
- it "returns a Time with a UTC offset specified as +HH:MM:SS" do
- Time.new(2000, 1, 1, 0, 0, 0, "+05:30:37").utc_offset.should == 19837
- end
-
- it "returns a Time with a UTC offset specified as -HH:MM" do
- Time.new(2000, 1, 1, 0, 0, 0, "-04:10:43").utc_offset.should == -15043
- end
-
describe "with an argument that responds to #to_str" do
it "coerces using #to_str" do
o = mock('string')
@@ -76,262 +67,33 @@ describe "Time.new with a utc_offset argument" do
# [Bug #8679], r47676
it "disallows a value for minutes greater than 59" do
- -> {
+ lambda {
Time.new(2000, 1, 1, 0, 0, 0, "+01:60")
}.should raise_error(ArgumentError)
- -> {
+ lambda {
Time.new(2000, 1, 1, 0, 0, 0, "+01:99")
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do
- -> { Time.new(2000, 1, 1, 0, 0, 0, "3600") }.should raise_error(ArgumentError)
+ lambda { Time.new(2000, 1, 1, 0, 0, 0, "3600") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the hour value is greater than 23" do
- -> { Time.new(2000, 1, 1, 0, 0, 0, "+24:00") }.should raise_error(ArgumentError)
+ lambda { Time.new(2000, 1, 1, 0, 0, 0, "+24:00") }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do
- -> { Time.new(2000, 1, 1, 0, 0, 0, "-04:10".encode("UTF-16LE")) }.should raise_error(ArgumentError)
+ lambda { Time.new(2000, 1, 1, 0, 0, 0, "-04:10".encode("UTF-16LE")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do
Time.new(2000, 1, 1, 0, 0, 0, -86400 + 1).utc_offset.should == (-86400 + 1)
- -> { Time.new(2000, 1, 1, 0, 0, 0, -86400) }.should raise_error(ArgumentError)
+ lambda { Time.new(2000, 1, 1, 0, 0, 0, -86400) }.should raise_error(ArgumentError)
end
it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do
Time.new(2000, 1, 1, 0, 0, 0, 86400 - 1).utc_offset.should == (86400 - 1)
- -> { Time.new(2000, 1, 1, 0, 0, 0, 86400) }.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError if the seconds argument is negative" do
- -> { Time.new(2000, 1, 1, 0, 0, -1) }.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError if the utc_offset argument is greater than or equal to 10e9" do
- -> { Time.new(2000, 1, 1, 0, 0, 0, 1000000000) }.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError if the month is greater than 12" do
- # For some reason MRI uses a different message for month in 13-15 and month>=16
- -> { Time.new(2000, 13, 1, 0, 0, 0, "+01:00") }.should raise_error(ArgumentError, /(mon|argument) out of range/)
- -> { Time.new(2000, 16, 1, 0, 0, 0, "+01:00") }.should raise_error(ArgumentError, "argument out of range")
- end
-end
-
-ruby_version_is "2.7" do
- describe "Time.new with a timezone argument" do
- it "returns a Time in the timezone" do
- zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
- time = Time.new(2000, 1, 1, 12, 0, 0, zone)
-
- time.zone.should == zone
- time.utc_offset.should == 5*3600+30*60
- ruby_version_is "2.7" do
- time.wday.should == 6
- time.yday.should == 1
- end
- end
-
- it "accepts timezone argument that must have #local_to_utc and #utc_to_local methods" do
- zone = Object.new
- def zone.utc_to_local(time)
- time
- end
- def zone.local_to_utc(time)
- time
- end
-
- -> {
- Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
- }.should_not raise_error
- end
-
- it "raises TypeError if timezone does not implement #local_to_utc method" do
- zone = Object.new
- def zone.utc_to_local(time)
- time
- end
-
- -> {
- Time.new(2000, 1, 1, 12, 0, 0, zone)
- }.should raise_error(TypeError, /can't convert \w+ into an exact number/)
- end
-
- it "does not raise exception if timezone does not implement #utc_to_local method" do
- zone = Object.new
- def zone.local_to_utc(time)
- time
- end
-
- -> {
- Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
- }.should_not raise_error
- end
-
- # The result also should be a Time or Time-like object (not necessary to be the same class)
- # The zone of the result is just ignored
- describe "returned value by #utc_to_local and #local_to_utc methods" do
- it "could be Time instance" do
- zone = Object.new
- def zone.local_to_utc(t)
- Time.utc(t.year, t.mon, t.day, t.hour - 1, t.min, t.sec)
- end
-
- -> {
- Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
- Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
- }.should_not raise_error
- end
-
- it "could be Time subclass instance" do
- zone = Object.new
- def zone.local_to_utc(t)
- Class.new(Time).utc(t.year, t.mon, t.day, t.hour - 1, t.min, t.sec)
- end
-
- -> {
- Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
- Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
- }.should_not raise_error
- end
-
- it "could be any object with #to_i method" do
- zone = Object.new
- def zone.local_to_utc(time)
- Struct.new(:to_i).new(time.to_i - 60*60)
- end
-
- -> {
- Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time)
- Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60
- }.should_not raise_error
- end
-
- it "could have any #zone and #utc_offset because they are ignored" do
- zone = Object.new
- def zone.local_to_utc(time)
- Struct.new(:to_i, :zone, :utc_offset).new(time.to_i, 'America/New_York', -5*60*60)
- end
- Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 0
-
- zone = Object.new
- def zone.local_to_utc(time)
- Struct.new(:to_i, :zone, :utc_offset).new(time.to_i, 'Asia/Tokyo', 9*60*60)
- end
- Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 0
- end
-
- it "leads to raising Argument error if difference between argument and result is too large" do
- zone = Object.new
- def zone.local_to_utc(t)
- Time.utc(t.year, t.mon, t.day + 1, t.hour, t.min, t.sec)
- end
-
- -> {
- Time.new(2000, 1, 1, 12, 0, 0, zone)
- }.should raise_error(ArgumentError, "utc_offset out of range")
- end
- end
-
- # https://github.com/ruby/ruby/blob/v2_6_0/time.c#L5330
- #
- # Time-like argument to these methods is similar to a Time object in UTC without sub-second;
- # it has attribute readers for the parts, e.g. year, month, and so on, and epoch time readers, to_i
- #
- # The sub-second attributes are fixed as 0, and utc_offset, zone, isdst, and their aliases are same as a Time object in UTC
- describe "Time-like argument of #utc_to_local and #local_to_utc methods" do
- before do
- @obj = TimeSpecs::TimeLikeArgumentRecorder.result
- @obj.should_not == nil
- end
-
- it "implements subset of Time methods" do
- [
- :year, :mon, :month, :mday, :hour, :min, :sec,
- :tv_sec, :tv_usec, :usec, :tv_nsec, :nsec, :subsec,
- :to_i, :to_f, :to_r, :+, :-,
- :isdst, :dst?, :zone, :gmtoff, :gmt_offset, :utc_offset, :utc?, :gmt?,
- :to_s, :inspect, :to_a, :to_time,
- ].each do |name|
- @obj.respond_to?(name).should == true
- end
- end
-
- it "has attribute values the same as a Time object in UTC" do
- @obj.usec.should == 0
- @obj.nsec.should == 0
- @obj.subsec.should == 0
- @obj.tv_usec.should == 0
- @obj.tv_nsec.should == 0
-
- @obj.utc_offset.should == 0
- @obj.zone.should == "UTC"
- @obj.isdst.should == Time.new.utc.isdst
- end
- end
-
- context "#name method" do
- it "uses the optional #name method for marshaling" do
- zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo")
- time = Time.new(2000, 1, 1, 12, 0, 0, zone)
- time_loaded = Marshal.load(Marshal.dump(time))
-
- time_loaded.zone.should == "Asia/Colombo"
- time_loaded.utc_offset.should == 5*3600+30*60
- end
-
- it "cannot marshal Time if #name method isn't implemented" do
- zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
- time = Time.new(2000, 1, 1, 12, 0, 0, zone)
-
- -> {
- Marshal.dump(time)
- }.should raise_error(NoMethodError, /undefined method `name' for/)
- end
- end
-
- it "the #abbr method is used by '%Z' in #strftime" do
- zone = TimeSpecs::TimezoneWithAbbr.new(name: "Asia/Colombo")
- time = Time.new(2000, 1, 1, 12, 0, 0, zone)
-
- time.strftime("%Z").should == "MMT"
- end
-
- # At loading marshaled data, a timezone name will be converted to a timezone object
- # by find_timezone class method, if the method is defined.
- # Similarly, that class method will be called when a timezone argument does not have
- # the necessary methods mentioned above.
- context "subject's class implements .find_timezone method" do
- it "calls .find_timezone to build a time object at loading marshaled data" do
- zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo")
- time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, zone)
- time_loaded = Marshal.load(Marshal.dump(time))
-
- time_loaded.zone.should be_kind_of TimeSpecs::TimezoneWithName
- time_loaded.zone.name.should == "Asia/Colombo"
- time_loaded.utc_offset.should == 5*3600+30*60
- end
-
- it "calls .find_timezone to build a time object if passed zone name as a timezone argument" do
- time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, "Asia/Colombo")
- time.zone.should be_kind_of TimeSpecs::TimezoneWithName
- time.zone.name.should == "Asia/Colombo"
-
- time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, "some invalid zone name")
- time.zone.should be_kind_of TimeSpecs::TimezoneWithName
- time.zone.name.should == "some invalid zone name"
- end
-
- it "does not call .find_timezone if passed any not string/numeric/timezone timezone argument" do
- [Object.new, [], {}, :"some zone"].each do |zone|
- -> {
- TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, zone)
- }.should raise_error(TypeError, /can't convert \w+ into an exact number/)
- end
- end
- end
+ lambda { Time.new(2000, 1, 1, 0, 0, 0, 86400) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/time/now_spec.rb b/spec/ruby/core/time/now_spec.rb
index 7dc7951996..399a1a22e2 100644
--- a/spec/ruby/core/time/now_spec.rb
+++ b/spec/ruby/core/time/now_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/now'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/now', __FILE__)
describe "Time.now" do
- it_behaves_like :time_now, :now
+ it_behaves_like(:time_now, :now)
end
diff --git a/spec/ruby/core/time/nsec_spec.rb b/spec/ruby/core/time/nsec_spec.rb
index 9338eb435a..3a6be1d016 100644
--- a/spec/ruby/core/time/nsec_spec.rb
+++ b/spec/ruby/core/time/nsec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#nsec" do
it "returns 0 for a Time constructed with a whole number of seconds" do
@@ -24,8 +24,4 @@ describe "Time#nsec" do
it "returns the nanoseconds part of a Time constructed with an Rational number of microseconds" do
Time.at(0, Rational(99, 10)).nsec.should == 9900
end
-
- it "returns a positive value for dates before the epoch" do
- Time.utc(1969, 11, 12, 13, 18, 57, 404240).nsec.should == 404240000
- end
end
diff --git a/spec/ruby/core/time/plus_spec.rb b/spec/ruby/core/time/plus_spec.rb
index 0a9984f180..29931f8a87 100644
--- a/spec/ruby/core/time/plus_spec.rb
+++ b/spec/ruby/core/time/plus_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#+" do
it "increments the time by the specified amount" do
@@ -17,9 +16,9 @@ describe "Time#+" do
end
it "raises a TypeError if given argument is a coercible String" do
- -> { Time.now + "1" }.should raise_error(TypeError)
- -> { Time.now + "0.1" }.should raise_error(TypeError)
- -> { Time.now + "1/3" }.should raise_error(TypeError)
+ lambda { Time.now + "1" }.should raise_error(TypeError)
+ lambda { Time.now + "0.1" }.should raise_error(TypeError)
+ lambda { Time.now + "1/3" }.should raise_error(TypeError)
end
it "increments the time by the specified amount as rational numbers" do
@@ -32,8 +31,8 @@ describe "Time#+" do
end
it "raises TypeError on argument that can't be coerced into Rational" do
- -> { Time.now + Object.new }.should raise_error(TypeError)
- -> { Time.now + "stuff" }.should raise_error(TypeError)
+ lambda { Time.now + Object.new }.should raise_error(TypeError)
+ lambda { Time.now + "stuff" }.should raise_error(TypeError)
end
it "returns a UTC time if self is UTC" do
@@ -48,25 +47,6 @@ describe "Time#+" do
(Time.new(2012, 1, 1, 0, 0, 0, 3600) + 10).utc_offset.should == 3600
end
- it "preserves time zone" do
- time_with_zone = Time.now.utc
- time_with_zone.zone.should == (time_with_zone + 60*60).zone
-
- time_with_zone = Time.now
- time_with_zone.zone.should == (time_with_zone + 60*60).zone
- end
-
- ruby_version_is "2.6" do
- context "zone is a timezone object" do
- it "preserves time zone" do
- zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
- time = Time.new(2012, 1, 1, 12, 0, 0, zone) + 60*60
-
- time.zone.should == zone
- end
- end
- end
-
it "does not return a subclass instance" do
c = Class.new(Time)
x = c.now + 1
@@ -74,11 +54,11 @@ describe "Time#+" do
end
it "raises TypeError on Time argument" do
- -> { Time.now + Time.now }.should raise_error(TypeError)
+ lambda { Time.now + Time.now }.should raise_error(TypeError)
end
it "raises TypeError on nil argument" do
- -> { Time.now + nil }.should raise_error(TypeError)
+ lambda { Time.now + nil }.should raise_error(TypeError)
end
#see [ruby-dev:38446]
diff --git a/spec/ruby/core/time/round_spec.rb b/spec/ruby/core/time/round_spec.rb
index 0cbed04ade..97568802b9 100644
--- a/spec/ruby/core/time/round_spec.rb
+++ b/spec/ruby/core/time/round_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#round" do
before do
diff --git a/spec/ruby/core/time/saturday_spec.rb b/spec/ruby/core/time/saturday_spec.rb
index 60ffea4198..0d827a6184 100644
--- a/spec/ruby/core/time/saturday_spec.rb
+++ b/spec/ruby/core/time/saturday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#saturday?" do
it "returns true if time represents Saturday" do
diff --git a/spec/ruby/core/time/sec_spec.rb b/spec/ruby/core/time/sec_spec.rb
index 73fc5ce1fc..e753235b53 100644
--- a/spec/ruby/core/time/sec_spec.rb
+++ b/spec/ruby/core/time/sec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#sec" do
it "returns the second of the minute(0..60) for time" do
diff --git a/spec/ruby/core/time/shared/gm.rb b/spec/ruby/core/time/shared/gm.rb
index 0ee602c837..72012caa66 100644
--- a/spec/ruby/core/time/shared/gm.rb
+++ b/spec/ruby/core/time/shared/gm.rb
@@ -26,45 +26,4 @@ describe :time_gm, shared: true do
time.usec.should == 0
time.nsec.should == 999
end
-
- guard -> {
- with_timezone 'right/UTC' do
- (Time.gm(1972, 6, 30, 23, 59, 59) + 1).sec == 60
- end
- } do
- it "handles real leap seconds in zone 'right/UTC'" do
- with_timezone 'right/UTC' do
- time = Time.send(@method, 1972, 6, 30, 23, 59, 60)
-
- time.sec.should == 60
- time.min.should == 59
- time.hour.should == 23
- time.day.should == 30
- time.month.should == 6
- end
- end
- end
-
- it "handles bad leap seconds by carrying values forward" do
- with_timezone 'UTC' do
- time = Time.send(@method, 2017, 7, 5, 23, 59, 60)
- time.sec.should == 0
- time.min.should == 0
- time.hour.should == 0
- time.day.should == 6
- time.month.should == 7
- end
- end
-
- it "handles a value of 60 for seconds by carrying values forward in zone 'UTC'" do
- with_timezone 'UTC' do
- time = Time.send(@method, 1972, 6, 30, 23, 59, 60)
-
- time.sec.should == 0
- time.min.should == 0
- time.hour.should == 0
- time.day.should == 1
- time.month.should == 7
- end
- end
end
diff --git a/spec/ruby/core/time/shared/gmt_offset.rb b/spec/ruby/core/time/shared/gmt_offset.rb
index 839566c249..cb842be2f3 100644
--- a/spec/ruby/core/time/shared/gmt_offset.rb
+++ b/spec/ruby/core/time/shared/gmt_offset.rb
@@ -5,12 +5,6 @@ describe :time_gmt_offset, shared: true do
end
end
- it "returns 0 when the date is UTC" do
- with_timezone("AST", 3) do
- Time.new.utc.send(@method).should == 0
- end
- end
-
platform_is_not :windows do
it "returns the correct offset for US Eastern time zone around daylight savings time change" do
# "2010-03-14 01:59:59 -0500" + 1 ==> "2010-03-14 03:00:00 -0400"
diff --git a/spec/ruby/core/time/shared/gmtime.rb b/spec/ruby/core/time/shared/gmtime.rb
index 5ed64c2ab6..e684a1fd95 100644
--- a/spec/ruby/core/time/shared/gmtime.rb
+++ b/spec/ruby/core/time/shared/gmtime.rb
@@ -26,7 +26,7 @@ describe :time_gmtime, shared: true do
with_timezone("CST", -6) do
time = Time.now
time.freeze
- -> { time.send(@method) }.should raise_error(RuntimeError)
+ lambda { time.send(@method) }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/core/time/shared/inspect.rb b/spec/ruby/core/time/shared/inspect.rb
index 4133671924..c707382a6e 100644
--- a/spec/ruby/core/time/shared/inspect.rb
+++ b/spec/ruby/core/time/shared/inspect.rb
@@ -15,7 +15,9 @@ describe :inspect, shared: true do
Time.new(2000, 1, 1, 20, 15, 01, 3600).send(@method).should == "2000-01-01 20:15:01 +0100"
end
- it "returns a US-ASCII encoded string" do
- Time.now.send(@method).encoding.should equal(Encoding::US_ASCII)
+ with_feature :encoding do
+ it "returns a US-ASCII encoded string" do
+ Time.now.send(@method).encoding.should equal(Encoding::US_ASCII)
+ end
end
end
diff --git a/spec/ruby/core/time/shared/now.rb b/spec/ruby/core/time/shared/now.rb
index d8e5ac9d50..c35115fcf4 100644
--- a/spec/ruby/core/time/shared/now.rb
+++ b/spec/ruby/core/time/shared/now.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :time_now, shared: true do
it "creates a subclass instance if called on a subclass" do
@@ -8,7 +8,7 @@ describe :time_now, shared: true do
it "sets the current time" do
now = TimeSpecs::MethodHolder.send(@method)
- now.to_f.should be_close(Process.clock_gettime(Process::CLOCK_REALTIME), TIME_TOLERANCE)
+ now.to_f.should be_close(Process.clock_gettime(Process::CLOCK_REALTIME), 10.0)
end
it "uses the local timezone" do
@@ -17,19 +17,4 @@ describe :time_now, shared: true do
now.utc_offset.should == (-8 * 60 * 60)
end
end
-
- guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
- it "has at least microsecond precision" do
- times = []
- 10_000.times do
- times << Time.now.nsec
- end
-
- # The clock should not be less accurate than expected (times should
- # not all be a multiple of the next precision up, assuming precisions
- # are multiples of ten.)
- expected = 1_000
- times.select { |t| t % (expected * 10) == 0 }.size.should_not == times.size
- end
- end
end
diff --git a/spec/ruby/core/time/shared/time_params.rb b/spec/ruby/core/time/shared/time_params.rb
index 63d0dbc120..120d8d3af1 100644
--- a/spec/ruby/core/time/shared/time_params.rb
+++ b/spec/ruby/core/time/shared/time_params.rb
@@ -30,7 +30,7 @@ describe :time_params, shared: true do
end
it "raises a TypeError if the year is nil" do
- -> { Time.send(@method, nil) }.should raise_error(TypeError)
+ lambda { Time.send(@method, nil) }.should raise_error(TypeError)
end
it "accepts nil month, day, hour, minute, and second" do
@@ -145,41 +145,41 @@ describe :time_params, shared: true do
end
it "raises an ArgumentError for out of range month" do
- -> {
+ lambda {
Time.send(@method, 2008, 13, 31, 23, 59, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range day" do
- -> {
+ lambda {
Time.send(@method, 2008, 12, 32, 23, 59, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range hour" do
- -> {
+ lambda {
Time.send(@method, 2008, 12, 31, 25, 59, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range minute" do
- -> {
+ lambda {
Time.send(@method, 2008, 12, 31, 23, 61, 59)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError for out of range second" do
- -> {
+ lambda {
Time.send(@method, 2008, 12, 31, 23, 59, 61)
}.should raise_error(ArgumentError)
end
it "raises ArgumentError when given 9 arguments" do
- -> { Time.send(@method, *[0]*9) }.should raise_error(ArgumentError)
+ lambda { Time.send(@method, *[0]*9) }.should raise_error(ArgumentError)
end
it "raises ArgumentError when given 11 arguments" do
- -> { Time.send(@method, *[0]*11) }.should raise_error(ArgumentError)
+ lambda { Time.send(@method, *[0]*11) }.should raise_error(ArgumentError)
end
it "returns subclass instances" do
@@ -202,23 +202,23 @@ describe :time_params_10_arg, shared: true do
end
it "raises an ArgumentError for out of range values" do
- -> {
+ lambda {
Time.send(@method, 61, 59, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # sec
- -> {
+ lambda {
Time.send(@method, 59, 61, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # min
- -> {
+ lambda {
Time.send(@method, 59, 59, 25, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # hour
- -> {
+ lambda {
Time.send(@method, 59, 59, 23, 32, 12, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # day
- -> {
+ lambda {
Time.send(@method, 59, 59, 23, 31, 13, 2008, :ignored, :ignored, :ignored, :ignored)
}.should raise_error(ArgumentError) # month
end
@@ -230,10 +230,6 @@ describe :time_params_microseconds, shared: true do
t.usec.should == 123
end
- it "raises an ArgumentError for out of range microsecond" do
- -> { Time.send(@method, 2000, 1, 1, 20, 15, 1, 1000000) }.should raise_error(ArgumentError)
- end
-
it "handles fractional microseconds as a Float" do
t = Time.send(@method, 2000, 1, 1, 20, 15, 1, 1.75)
t.usec.should == 1
diff --git a/spec/ruby/core/time/strftime_spec.rb b/spec/ruby/core/time/strftime_spec.rb
index 1bd24b0538..1cb3575eec 100644
--- a/spec/ruby/core/time/strftime_spec.rb
+++ b/spec/ruby/core/time/strftime_spec.rb
@@ -1,19 +1,19 @@
# encoding: utf-8
-require_relative '../../spec_helper'
-require_relative '../../shared/time/strftime_for_date'
-require_relative '../../shared/time/strftime_for_time'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/time/strftime_for_date', __FILE__)
+require File.expand_path('../../../shared/time/strftime_for_time', __FILE__)
describe "Time#strftime" do
before :all do
- @new_date = -> y, m, d { Time.gm(y,m,d) }
- @new_time = -> *args { Time.gm(*args) }
- @new_time_in_zone = -> zone, offset, *args {
+ @new_date = lambda { |y,m,d| Time.gm(y,m,d) }
+ @new_time = lambda { |*args| Time.gm(*args) }
+ @new_time_in_zone = lambda { |zone,offset,*args|
with_timezone(zone, offset) do
Time.new(*args)
end
}
- @new_time_with_offset = -> y, m, d, h, min, s, offset {
+ @new_time_with_offset = lambda { |y,m,d,h,min,s,offset|
Time.new(y,m,d,h,min,s,offset)
}
@@ -25,7 +25,7 @@ describe "Time#strftime" do
# Differences with date
it "requires an argument" do
- -> { @time.strftime }.should raise_error(ArgumentError)
+ lambda { @time.strftime }.should raise_error(ArgumentError)
end
# %Z is zone name or empty for Time
diff --git a/spec/ruby/core/time/subsec_spec.rb b/spec/ruby/core/time/subsec_spec.rb
index 583a26412b..d9d262a513 100644
--- a/spec/ruby/core/time/subsec_spec.rb
+++ b/spec/ruby/core/time/subsec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#subsec" do
it "returns 0 as a Fixnum for a Time with a whole number of seconds" do
diff --git a/spec/ruby/core/time/succ_spec.rb b/spec/ruby/core/time/succ_spec.rb
index e68e64b0cc..6831200741 100644
--- a/spec/ruby/core/time/succ_spec.rb
+++ b/spec/ruby/core/time/succ_spec.rb
@@ -1,39 +1,19 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#succ" do
it "returns a new time one second later than time" do
- suppress_warning {
+ -> {
@result = Time.at(100).succ
- }
-
+ }.should complain(/Time#succ is obsolete/)
@result.should == Time.at(101)
end
it "returns a new instance" do
- time = Time.at(100)
-
- suppress_warning {
- @result = time.succ
- }
-
- @result.should_not equal time
- end
-
- it "is obsolete" do
+ t1 = Time.at(100)
+ t2 = nil
-> {
- Time.at(100).succ
+ t2 = t1.succ
}.should complain(/Time#succ is obsolete/)
- end
-
- ruby_version_is "2.6" do
- context "zone is a timezone object" do
- it "preserves time zone" do
- zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
- time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
-
- time.zone.should == zone
- end
- end
+ t1.object_id.should_not == t2.object_id
end
end
diff --git a/spec/ruby/core/time/sunday_spec.rb b/spec/ruby/core/time/sunday_spec.rb
index 2285583579..823174cf71 100644
--- a/spec/ruby/core/time/sunday_spec.rb
+++ b/spec/ruby/core/time/sunday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#sunday?" do
it "returns true if time represents Sunday" do
diff --git a/spec/ruby/core/time/thursday_spec.rb b/spec/ruby/core/time/thursday_spec.rb
index c82d517519..5788fd9bc7 100644
--- a/spec/ruby/core/time/thursday_spec.rb
+++ b/spec/ruby/core/time/thursday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#thursday?" do
it "returns true if time represents Thursday" do
diff --git a/spec/ruby/core/time/time_spec.rb b/spec/ruby/core/time/time_spec.rb
index b0803a7f21..1c870c8e0f 100644
--- a/spec/ruby/core/time/time_spec.rb
+++ b/spec/ruby/core/time/time_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time" do
it "includes Comparable" do
diff --git a/spec/ruby/core/time/to_a_spec.rb b/spec/ruby/core/time/to_a_spec.rb
index 3728b8c526..a4c4a8fbc9 100644
--- a/spec/ruby/core/time/to_a_spec.rb
+++ b/spec/ruby/core/time/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#to_a" do
platform_is_not :windows do
diff --git a/spec/ruby/core/time/to_f_spec.rb b/spec/ruby/core/time/to_f_spec.rb
index 6101dcf871..d737848b4b 100644
--- a/spec/ruby/core/time/to_f_spec.rb
+++ b/spec/ruby/core/time/to_f_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#to_f" do
it "returns the float number of seconds + usecs since the epoch" do
diff --git a/spec/ruby/core/time/to_i_spec.rb b/spec/ruby/core/time/to_i_spec.rb
index 54929d1e18..1a733f02cf 100644
--- a/spec/ruby/core/time/to_i_spec.rb
+++ b/spec/ruby/core/time/to_i_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
describe "Time#to_i" do
- it_behaves_like :time_to_i, :to_i
+ it_behaves_like(:time_to_i, :to_i)
end
diff --git a/spec/ruby/core/time/to_r_spec.rb b/spec/ruby/core/time/to_r_spec.rb
index 6af2d9b7ea..53e469463a 100644
--- a/spec/ruby/core/time/to_r_spec.rb
+++ b/spec/ruby/core/time/to_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#to_r" do
it "returns the a Rational representing seconds and subseconds since the epoch" do
diff --git a/spec/ruby/core/time/to_s_spec.rb b/spec/ruby/core/time/to_s_spec.rb
index ac6c0908ac..8dc81f60a9 100644
--- a/spec/ruby/core/time/to_s_spec.rb
+++ b/spec/ruby/core/time/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/inspect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "Time#to_s" do
it_behaves_like :inspect, :to_s
diff --git a/spec/ruby/core/time/tuesday_spec.rb b/spec/ruby/core/time/tuesday_spec.rb
index 7abbdc92c0..87c3236eea 100644
--- a/spec/ruby/core/time/tuesday_spec.rb
+++ b/spec/ruby/core/time/tuesday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#tuesday?" do
it "returns true if time represents Tuesday" do
diff --git a/spec/ruby/core/time/tv_nsec_spec.rb b/spec/ruby/core/time/tv_nsec_spec.rb
index feb7998b16..d477f6fbec 100644
--- a/spec/ruby/core/time/tv_nsec_spec.rb
+++ b/spec/ruby/core/time/tv_nsec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#tv_nsec" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/time/tv_sec_spec.rb b/spec/ruby/core/time/tv_sec_spec.rb
index f83e1fbfdd..36f090be7b 100644
--- a/spec/ruby/core/time/tv_sec_spec.rb
+++ b/spec/ruby/core/time/tv_sec_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_i'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_i', __FILE__)
describe "Time#tv_sec" do
- it_behaves_like :time_to_i, :tv_sec
+ it_behaves_like(:time_to_i, :tv_sec)
end
diff --git a/spec/ruby/core/time/tv_usec_spec.rb b/spec/ruby/core/time/tv_usec_spec.rb
index f0de4f4a9c..4a1b87be7a 100644
--- a/spec/ruby/core/time/tv_usec_spec.rb
+++ b/spec/ruby/core/time/tv_usec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#tv_usec" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/time/usec_spec.rb b/spec/ruby/core/time/usec_spec.rb
index 6ea52f5e79..018253ec77 100644
--- a/spec/ruby/core/time/usec_spec.rb
+++ b/spec/ruby/core/time/usec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#usec" do
it "returns 0 for a Time constructed with a whole number of seconds" do
@@ -36,8 +36,4 @@ describe "Time#usec" do
it "returns the microseconds for time created by Time#local" do
Time.local(1,2,3,4,5,Rational(6.78)).usec.should == 780000
end
-
- it "returns a positive value for dates before the epoch" do
- Time.utc(1969, 11, 12, 13, 18, 57, 404240).usec.should == 404240
- end
end
diff --git a/spec/ruby/core/time/utc_offset_spec.rb b/spec/ruby/core/time/utc_offset_spec.rb
index 17c031b8c6..4be885f2e3 100644
--- a/spec/ruby/core/time/utc_offset_spec.rb
+++ b/spec/ruby/core/time/utc_offset_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gmt_offset'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gmt_offset', __FILE__)
describe "Time#utc_offset" do
- it_behaves_like :time_gmt_offset, :utc_offset
+ it_behaves_like(:time_gmt_offset, :utc_offset)
end
diff --git a/spec/ruby/core/time/utc_spec.rb b/spec/ruby/core/time/utc_spec.rb
index 5074c8d54d..f88b9c7cbc 100644
--- a/spec/ruby/core/time/utc_spec.rb
+++ b/spec/ruby/core/time/utc_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/gm'
-require_relative 'shared/gmtime'
-require_relative 'shared/time_params'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/gm', __FILE__)
+require File.expand_path('../shared/gmtime', __FILE__)
+require File.expand_path('../shared/time_params', __FILE__)
describe "Time#utc?" do
it "returns true if time represents a time in UTC (GMT)" do
@@ -10,12 +10,12 @@ describe "Time#utc?" do
end
describe "Time.utc" do
- it_behaves_like :time_gm, :utc
- it_behaves_like :time_params, :utc
- it_behaves_like :time_params_10_arg, :utc
- it_behaves_like :time_params_microseconds, :utc
+ it_behaves_like(:time_gm, :utc)
+ it_behaves_like(:time_params, :utc)
+ it_behaves_like(:time_params_10_arg, :utc)
+ it_behaves_like(:time_params_microseconds, :utc)
end
describe "Time#utc" do
- it_behaves_like :time_gmtime, :utc
+ it_behaves_like(:time_gmtime, :utc)
end
diff --git a/spec/ruby/core/time/wday_spec.rb b/spec/ruby/core/time/wday_spec.rb
index 9f63f67de9..72bc718356 100644
--- a/spec/ruby/core/time/wday_spec.rb
+++ b/spec/ruby/core/time/wday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#wday" do
it "returns an integer representing the day of the week, 0..6, with Sunday being 0" do
diff --git a/spec/ruby/core/time/wednesday_spec.rb b/spec/ruby/core/time/wednesday_spec.rb
index 6a52c3577b..8e836e3e02 100644
--- a/spec/ruby/core/time/wednesday_spec.rb
+++ b/spec/ruby/core/time/wednesday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#wednesday?" do
it "returns true if time represents Wednesday" do
diff --git a/spec/ruby/core/time/yday_spec.rb b/spec/ruby/core/time/yday_spec.rb
index 6ea5ff8f1b..2b7aca1565 100644
--- a/spec/ruby/core/time/yday_spec.rb
+++ b/spec/ruby/core/time/yday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#yday" do
it "returns an integer representing the day of the year, 1..366" do
diff --git a/spec/ruby/core/time/year_spec.rb b/spec/ruby/core/time/year_spec.rb
index d2d50062c5..4e18eb1353 100644
--- a/spec/ruby/core/time/year_spec.rb
+++ b/spec/ruby/core/time/year_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#year" do
it "returns the four digit year for a local Time as an Integer" do
diff --git a/spec/ruby/core/time/zone_spec.rb b/spec/ruby/core/time/zone_spec.rb
index 907ccf9f4b..9c7acd66e3 100644
--- a/spec/ruby/core/time/zone_spec.rb
+++ b/spec/ruby/core/time/zone_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Time#zone" do
platform_is_not :windows do
@@ -52,7 +52,7 @@ describe "Time#zone" do
end
it "doesn't raise errors for a Time with a fixed offset" do
- -> {
+ lambda {
Time.new(2001, 1, 1, 0, 0, 0, "+05:00").zone
}.should_not raise_error
end
diff --git a/spec/ruby/core/tracepoint/binding_spec.rb b/spec/ruby/core/tracepoint/binding_spec.rb
index f37753602e..6d327fb693 100644
--- a/spec/ruby/core/tracepoint/binding_spec.rb
+++ b/spec/ruby/core/tracepoint/binding_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#binding' do
def test
diff --git a/spec/ruby/core/tracepoint/callee_id_spec.rb b/spec/ruby/core/tracepoint/callee_id_spec.rb
index d340290d8b..b7571027d6 100644
--- a/spec/ruby/core/tracepoint/callee_id_spec.rb
+++ b/spec/ruby/core/tracepoint/callee_id_spec.rb
@@ -1,17 +1,20 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
-describe "TracePoint#callee_id" do
- it "returns the called name of the method being called" do
- a = []
- obj = TracePointSpec::ClassWithMethodAlias.new
+ruby_version_is '2.4' do
+ describe "TracePoint#callee_id" do
+ it "returns the called name of the method being called" do
+ a = []
+ obj = TracePointSpec::ClassWithMethodAlias.new
- TracePoint.new(:call) do |tp|
- a << tp.callee_id
- end.enable do
- obj.m_alias
- end
+ TracePoint.new(:call) do |tp|
+ a << tp.callee_id
+ end.enable do
+ obj.m_alias
+ end
- a.should == [:m_alias]
+ a.should == [:m_alias]
+ end
end
end
+
diff --git a/spec/ruby/core/tracepoint/defined_class_spec.rb b/spec/ruby/core/tracepoint/defined_class_spec.rb
index 72536e6a56..c5a93c6e04 100644
--- a/spec/ruby/core/tracepoint/defined_class_spec.rb
+++ b/spec/ruby/core/tracepoint/defined_class_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'TracePoint#defined_class' do
it 'returns class or module of the method being called' do
diff --git a/spec/ruby/core/tracepoint/disable_spec.rb b/spec/ruby/core/tracepoint/disable_spec.rb
index 612ca3c25a..c34eb3ac85 100644
--- a/spec/ruby/core/tracepoint/disable_spec.rb
+++ b/spec/ruby/core/tracepoint/disable_spec.rb
@@ -1,37 +1,34 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#disable' do
+ def test; end
it 'returns true if trace was enabled' do
called = false
- trace = TracePoint.new(:line) do |tp|
+ trace = TracePoint.new(:call) do |tp|
called = true
end
trace.enable
- begin
- line_event = true
- ensure
- ret = trace.disable
- ret.should == true
- end
- called.should == true
+ trace.disable.should be_true
# Check the TracePoint is disabled
called = false
- line_event = true
+ test
called.should == false
end
it 'returns false if trace was disabled' do
- called = false
- trace = TracePoint.new(:line) do |tp|
- called = true
+ event_name, method_name = nil
+ trace = TracePoint.new(:call) do |tp|
+ event_name = tp.event
+ method_name = tp.method_id
end
- line_event = true
- trace.disable.should == false
- line_event = true
- called.should == false
+ trace.disable.should be_false
+ event_name, method_name = nil
+ test
+ method_name.equal?(:test).should be_false
+ event_name.should equal(nil)
end
it 'is disabled within a block & is enabled outside the block' do
@@ -40,34 +37,37 @@ describe 'TracePoint#disable' do
trace.enable
begin
trace.disable { enabled = trace.enabled? }
- enabled.should == false
- trace.enabled?.should == true
+ enabled.should be_false
+ trace.enabled?.should be_true
ensure
trace.disable
end
end
- it 'returns the return value of the block' do
+ it 'is disabled within a block & also returns false when its called with a block' do
trace = TracePoint.new(:line) {}
trace.enable
begin
- trace.disable { 42 }.should == 42
- trace.enabled?.should == true
+ trace.disable { trace.enabled? }.should == false
+ trace.enabled?.should equal(true)
ensure
trace.disable
end
end
- it 'can accept param within a block but it should not yield arguments' do
- trace = TracePoint.new(:line) {}
- trace.enable
- begin
- trace.disable do |*args|
- args.should == []
+ ruby_bug "#14057", "2.0"..."2.5" do
+ it 'can accept param within a block but it should not yield arguments' do
+ event_name = nil
+ trace = TracePoint.new(:line) {}
+ trace.enable
+ begin
+ trace.disable do |*args|
+ args.should == []
+ end
+ trace.enabled?.should be_true
+ ensure
+ trace.disable
end
- trace.enabled?.should == true
- ensure
- trace.disable
end
end
end
diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb
index b0fe38c559..8651c41bad 100644
--- a/spec/ruby/core/tracepoint/enable_spec.rb
+++ b/spec/ruby/core/tracepoint/enable_spec.rb
@@ -1,49 +1,53 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#enable' do
- # def test; end
+ def test; end
describe 'without a block' do
it 'returns true if trace was enabled' do
- called = false
- trace = TracePoint.new(:line) do |tp|
- called = true
+ event_name = nil
+ trace = TracePoint.new(:call) do |tp|
+ event_name = tp.event
end
- line_event = true
- called.should == false
+ test
+ event_name.should == nil
trace.enable
begin
- line_event = true
- called.should == true
+ test
+ event_name.should equal(:call)
ensure
trace.disable
end
end
it 'returns false if trace was disabled' do
- called = false
- trace = TracePoint.new(:line) do |tp|
- called = true
+ event_name, method_name = nil, nil
+ trace = TracePoint.new(:call) do |tp|
+ event_name = tp.event
+ method_name = tp.method_id
end
- trace.enable.should == false
+ trace.enable.should be_false
begin
- line_event = true
- called.should == true
+ event_name.should equal(:call)
+ test
+ method_name.equal?(:test).should be_true
ensure
trace.disable
end
- called = false
- line_event = true
- called.should == false
+ event_name, method_name = nil
+ test
+ method_name.equal?(:test).should be_false
+ event_name.should equal(nil)
- trace.enable.should == false
+ trace.enable.should be_false
begin
- line_event = true
- called.should == true
+ event_name.should equal(:call)
+ test
+ method_name.equal?(:test).should be_true
ensure
trace.disable
end
@@ -58,14 +62,16 @@ describe 'TracePoint#enable' do
end.enable { event_name.should equal(:line) }
end
- it 'can accept arguments within a block but it should not yield arguments' do
- event_name = nil
- trace = TracePoint.new(:line) { |tp| event_name = tp.event }
- trace.enable do |*args|
- event_name.should equal(:line)
- args.should == []
+ ruby_bug "#14057", "2.0"..."2.5" do
+ it 'can accept arguments within a block but it should not yield arguments' do
+ event_name = nil
+ trace = TracePoint.new(:line) { |tp| event_name = tp.event }
+ trace.enable do |*args|
+ event_name.should equal(:line)
+ args.should == []
+ end
+ trace.enabled?.should be_false
end
- trace.enabled?.should == false
end
it 'enables trace object on calling with a block if it was already enabled' do
@@ -80,401 +86,17 @@ describe 'TracePoint#enable' do
end
end
- it 'returns the return value of the block' do
+ it 'returns value returned by the block' do
trace = TracePoint.new(:line) {}
- trace.enable { 42 }.should == 42
+ trace.enable { true; 'test' }.should == 'test'
end
it 'disables the trace object outside the block' do
- called = false
- trace = TracePoint.new(:line) { called = true }
- trace.enable {
- line_event = true
- }
- called.should == true
- trace.enabled?.should == false
- end
- end
-
- ruby_version_is "2.6" do
- describe 'target: option' do
- before :each do
- ScratchPad.record []
- end
-
- it 'enables trace point for specific location' do
- trace = TracePoint.new(:call) do |tp|
- ScratchPad << tp.method_id
- end
-
- obj = Object.new
- def obj.foo; end
- def obj.bar; end
-
- trace.enable(target: obj.method(:foo)) do
- obj.foo
- obj.bar
- end
-
- ScratchPad.recorded.should == [:foo]
- end
-
- it 'traces all the events triggered in specified location' do
- trace = TracePoint.new(:line, :call, :return, :b_call, :b_return) do |tp|
- ScratchPad << tp.event
- end
-
- obj = Object.new
- def obj.foo
- bar
- -> {}.call
- end
- def obj.bar; end
-
- trace.enable(target: obj.method(:foo)) do
- obj.foo
- end
-
- ScratchPad.recorded.uniq.sort.should == [:call, :return, :b_call, :b_return, :line].sort
- end
-
- it 'does not trace events in nested locations' do
- trace = TracePoint.new(:call) do |tp|
- ScratchPad << tp.method_id
- end
-
- obj = Object.new
- def obj.foo
- bar
- end
- def obj.bar
- baz
- end
- def obj.baz
- end
-
- trace.enable(target: obj.method(:foo)) do
- obj.foo
- end
-
- ScratchPad.recorded.should == [:foo]
- end
-
- it "traces some events in nested blocks" do
- klass = Class.new do
- def foo
- 1.times do
- 1.times do
- bar do
- end
- end
- end
- end
-
- def bar(&blk)
- blk.call
- end
- end
-
- trace = TracePoint.new(:b_call) do |tp|
- ScratchPad << tp.lineno
- end
-
- obj = klass.new
- _, lineno = obj.method(:foo).source_location
-
- trace.enable(target: obj.method(:foo)) do
- obj.foo
- end
-
- ScratchPad.recorded.should == (lineno+1..lineno+3).to_a
- end
-
- describe 'option value' do
- it 'accepts Method' do
- trace = TracePoint.new(:call) do |tp|
- ScratchPad << tp.method_id
- end
-
- obj = Object.new
- def obj.foo; end
-
- trace.enable(target: obj.method(:foo)) do
- obj.foo
- end
-
- ScratchPad.recorded.should == [:foo]
- end
-
- it 'accepts UnboundMethod' do
- trace = TracePoint.new(:call) do |tp|
- ScratchPad << tp.method_id
- end
-
- klass = Class.new do
- def foo; end
- end
-
- unbound_method = klass.instance_method(:foo)
- trace.enable(target: unbound_method) do
- klass.new.foo
- end
-
- ScratchPad.recorded.should == [:foo]
- end
-
- it 'accepts Proc' do
- trace = TracePoint.new(:b_call) do |tp|
- ScratchPad << tp.lineno
- end
-
- block = proc {}
- _, lineno = block.source_location
-
- trace.enable(target: block) do
- block.call
- end
-
- ScratchPad.recorded.should == [lineno]
- lineno.should be_kind_of(Integer)
- end
- end
-
- it "raises ArgumentError if target object cannot trigger specified event" do
- trace = TracePoint.new(:call) do |tp|
- ScratchPad << tp.method_id
- end
-
- block = proc {}
-
- -> {
- trace.enable(target: block) do
- block.call # triggers :b_call and :b_return events
- end
- }.should raise_error(ArgumentError, /can not enable any hooks/)
- end
-
- it "raises ArgumentError if passed not Method/UnboundMethod/Proc" do
- trace = TracePoint.new(:call) do |tp|
- end
-
- -> {
- trace.enable(target: Object.new) do
- end
- }.should raise_error(ArgumentError, /specified target is not supported/)
- end
-
- context "nested enabling and disabling" do
- it "raises ArgumentError if trace point already enabled with target is re-enabled with target" do
- trace = TracePoint.new(:b_call) do
- end
-
- -> {
- trace.enable(target: -> {}) do
- trace.enable(target: -> {}) do
- end
- end
- }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
- end
-
- it "raises ArgumentError if trace point already enabled without target is re-enabled with target" do
- trace = TracePoint.new(:b_call) do
- end
-
- -> {
- trace.enable do
- trace.enable(target: -> {}) do
- end
- end
- }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
- end
-
- it "raises ArgumentError if trace point already enabled with target is re-enabled without target" do
- trace = TracePoint.new(:b_call) do
- end
-
- -> {
- trace.enable(target: -> {}) do
- trace.enable do
- end
- end
- }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
- end
-
- it "raises ArgumentError if trace point already enabled with target is disabled with block" do
- trace = TracePoint.new(:b_call) do
- end
-
- -> {
- trace.enable(target: -> {}) do
- trace.disable do
- end
- end
- }.should raise_error(ArgumentError, /can't disable a targett?ing TracePoint in a block/)
- end
-
- it "traces events when trace point with target is enabled in another trace point enabled without target" do
- trace_outer = TracePoint.new(:b_call) do |tp|
- ScratchPad << :outer
- end
-
- trace_inner = TracePoint.new(:b_call) do |tp|
- ScratchPad << :inner
- end
-
- target = -> {}
-
- trace_outer.enable do
- trace_inner.enable(target: target) do
- target.call
- end
- end
-
- ScratchPad.recorded.should == [:outer, :outer, :outer, :inner]
- end
-
- it "traces events when trace point with target is enabled in another trace point enabled with target" do
- trace_outer = TracePoint.new(:b_call) do |tp|
- ScratchPad << :outer
- end
-
- trace_inner = TracePoint.new(:b_call) do |tp|
- ScratchPad << :inner
- end
-
- target = -> {}
-
- trace_outer.enable(target: target) do
- trace_inner.enable(target: target) do
- target.call
- end
- end
-
- ScratchPad.recorded.should == [:inner, :outer]
- end
-
- it "traces events when trace point without target is enabled in another trace point enabled with target" do
- trace_outer = TracePoint.new(:b_call) do |tp|
- ScratchPad << :outer
- end
-
- trace_inner = TracePoint.new(:b_call) do |tp|
- ScratchPad << :inner
- end
-
- target = -> {}
-
- trace_outer.enable(target: target) do
- trace_inner.enable do
- target.call
- end
- end
-
- ScratchPad.recorded.should == [:inner, :inner, :outer]
- end
- end
- end
-
- describe 'target_line: option' do
- before :each do
- ScratchPad.record []
- end
-
- it "traces :line events only on specified line of code" do
- trace = TracePoint.new(:line) do |tp|
- ScratchPad << tp.lineno
- end
-
- target = -> {
- x = 1
- y = 2 # <= this line is target
- z = x + y
- }
- _, lineno = target.source_location
- target_line = lineno + 2
-
- trace.enable(target_line: target_line, target: target) do
- target.call
- end
-
- ScratchPad.recorded.should == [target_line]
- end
-
- it "raises ArgumentError if :target option isn't specified" do
- trace = TracePoint.new(:line) do |tp|
- end
-
- -> {
- trace.enable(target_line: 67) do
- end
- }.should raise_error(ArgumentError, /only target_line is specified/)
- end
-
- it "raises ArgumentError if :line event isn't registered" do
- trace = TracePoint.new(:call) do |tp|
- end
-
- target = -> {
- x = 1
- y = 2 # <= this line is target
- z = x + y
- }
- _, lineno = target.source_location
- target_line = lineno + 2
-
- -> {
- trace.enable(target_line: target_line, target: target) do
- end
- }.should raise_error(ArgumentError, /target_line is specified, but line event is not specified/)
- end
-
- it "raises ArgumentError if :target_line value is out of target code lines range" do
- trace = TracePoint.new(:line) do |tp|
- end
-
- -> {
- trace.enable(target_line: 1, target: -> { }) do
- end
- }.should raise_error(ArgumentError, /can not enable any hooks/)
- end
-
- it "raises TypeError if :target_line value couldn't be coerced to Integer" do
- trace = TracePoint.new(:line) do |tp|
- end
-
- -> {
- trace.enable(target_line: Object.new, target: -> { }) do
- end
- }.should raise_error(TypeError, /no implicit conversion of \w+? into Integer/)
- end
-
- it "raises ArgumentError if :target_line value is negative" do
- trace = TracePoint.new(:line) do |tp|
- end
-
- -> {
- trace.enable(target_line: -2, target: -> { }) do
- end
- }.should raise_error(ArgumentError, /can not enable any hooks/)
- end
-
- it "accepts value that could be coerced to Integer" do
- trace = TracePoint.new(:line) do |tp|
- ScratchPad << tp.lineno
- end
-
- target = -> {
- x = 1 # <= this line is target
- }
- _, lineno = target.source_location
- target_line = lineno + 1
-
- trace.enable(target_line: target_line.to_r, target: target) do
- target.call
- end
-
- ScratchPad.recorded.should == [target_line]
- end
+ event_name = nil
+ trace = TracePoint.new(:line) { |tp|event_name = tp.event }
+ trace.enable { '2 + 2' }
+ event_name.should equal(:line)
+ trace.enabled?.should be_false
end
end
end
diff --git a/spec/ruby/core/tracepoint/enabled_spec.rb b/spec/ruby/core/tracepoint/enabled_spec.rb
index 0167d32fb0..0b5130979f 100644
--- a/spec/ruby/core/tracepoint/enabled_spec.rb
+++ b/spec/ruby/core/tracepoint/enabled_spec.rb
@@ -1,14 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#enabled?' do
it 'returns true when current status of the trace is enable' do
- trace = TracePoint.new(:line) {}
+ trace = TracePoint.new(:call) {}
trace.enable do
- trace.enabled?.should == true
+ trace.enabled?.should be_true
end
end
it 'returns false when current status of the trace is disabled' do
- TracePoint.new(:line) {}.enabled?.should == false
+ TracePoint.new(:call) {}.enabled?.should be_false
end
end
diff --git a/spec/ruby/core/tracepoint/eval_script_spec.rb b/spec/ruby/core/tracepoint/eval_script_spec.rb
deleted file mode 100644
index 1d8e425a9a..0000000000
--- a/spec/ruby/core/tracepoint/eval_script_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-ruby_version_is "2.6" do
- describe "TracePoint#eval_script" do
- it "is the evald source code" do
- ScratchPad.record []
-
- script = <<-CODE
- def foo
- p :hello
- end
- CODE
-
- TracePoint.new(:script_compiled) do |e|
- ScratchPad << e.eval_script
- end.enable do
- eval script
- end
-
- ScratchPad.recorded.should == [script]
- end
- end
-end
diff --git a/spec/ruby/core/tracepoint/event_spec.rb b/spec/ruby/core/tracepoint/event_spec.rb
index 019d0c3253..46bc7a0d50 100644
--- a/spec/ruby/core/tracepoint/event_spec.rb
+++ b/spec/ruby/core/tracepoint/event_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'TracePoint#event' do
it 'returns the type of event' do
diff --git a/spec/ruby/core/tracepoint/inspect_spec.rb b/spec/ruby/core/tracepoint/inspect_spec.rb
index 9ff1653ae8..3902872ab5 100644
--- a/spec/ruby/core/tracepoint/inspect_spec.rb
+++ b/spec/ruby/core/tracepoint/inspect_spec.rb
@@ -1,28 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#inspect' do
it 'returns a string containing a human-readable TracePoint status' do
- TracePoint.new(:line) {}.inspect.should ==
+ TracePoint.new(:call) {}.inspect.should ==
'#<TracePoint:disabled>'
end
-
- it 'returns a String showing the event, path and line' do
- inspect = nil
- line = __LINE__
- TracePoint.new(:line) { |tp| inspect = tp.inspect }.enable do
- inspect.should == "#<TracePoint:line@#{__FILE__}:#{line+2}>"
- end
- end
-
- it 'returns a String showing the event, path and line for a :class event' do
- inspect = nil
- line = __LINE__
- TracePoint.new(:class) { |tp| inspect = tp.inspect }.enable do
- class TracePointSpec::C
- end
- end
-
- inspect.should == "#<TracePoint:class@#{__FILE__}:#{line+2}>"
- end
end
diff --git a/spec/ruby/core/tracepoint/lineno_spec.rb b/spec/ruby/core/tracepoint/lineno_spec.rb
index a4d7e77e8d..49be6f8116 100644
--- a/spec/ruby/core/tracepoint/lineno_spec.rb
+++ b/spec/ruby/core/tracepoint/lineno_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#lineno' do
it 'returns the line number of the event' do
diff --git a/spec/ruby/core/tracepoint/method_id_spec.rb b/spec/ruby/core/tracepoint/method_id_spec.rb
index 82254d1299..4b18ba696d 100644
--- a/spec/ruby/core/tracepoint/method_id_spec.rb
+++ b/spec/ruby/core/tracepoint/method_id_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#method_id' do
def test; end
diff --git a/spec/ruby/core/tracepoint/new_spec.rb b/spec/ruby/core/tracepoint/new_spec.rb
index 916d826fdf..c3f6d60f5c 100644
--- a/spec/ruby/core/tracepoint/new_spec.rb
+++ b/spec/ruby/core/tracepoint/new_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe 'TracePoint.new' do
it 'returns a new TracePoint object, not enabled by default' do
- TracePoint.new(:line) {}.enabled?.should be_false
+ TracePoint.new(:call) {}.enabled?.should be_false
end
it 'includes :line event when event is not specified' do
@@ -23,11 +23,12 @@ describe 'TracePoint.new' do
it 'converts given event name as string into symbol using to_sym' do
event_name = nil
- (o = mock('line')).should_receive(:to_sym).and_return(:line)
+ (o = mock('return')).should_receive(:to_sym).and_return(:return)
- TracePoint.new(o) { |tp| event_name = tp.event }.enable do
- line_event = true
- event_name.should == :line
+ TracePoint.new(o) { |tp| event_name = tp.event}.enable do
+ event_name.should equal(nil)
+ TracePointSpec.test
+ event_name.should equal(:return)
end
end
@@ -55,13 +56,13 @@ describe 'TracePoint.new' do
-> { TracePoint.new(o) {}}.should raise_error(TypeError)
end
- ruby_version_is "2.5" do
+ ruby_bug "#140740", "2.0"..."2.5" do
it 'expects to be called with a block' do
- -> { TracePoint.new(:line) }.should raise_error(ArgumentError, "must be called with a block")
+ -> { TracePoint.new(:line) }.should raise_error(ArgumentError)
end
end
- it "raises a Argument error when the given argument doesn't match an event name" do
- -> { TracePoint.new(:test) }.should raise_error(ArgumentError, "unknown event: test")
+ it "raises a Argument error when the give argument doesn't match an event name" do
+ -> { TracePoint.new(:test) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/tracepoint/parameters_spec.rb b/spec/ruby/core/tracepoint/parameters_spec.rb
deleted file mode 100644
index f901c184f4..0000000000
--- a/spec/ruby/core/tracepoint/parameters_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../spec_helper'
-
-ruby_version_is "2.6" do
- describe 'TracePoint#parameters' do
- it 'returns the parameters of block' do
- f = proc {|x, y, z| }
- parameters = nil
- TracePoint.new(:b_call) {|tp| parameters = tp.parameters }.enable do
- f.call
- parameters.should == [[:opt, :x], [:opt, :y], [:opt, :z]]
- end
- end
-
- it 'returns the parameters of lambda block' do
- f = -> x, y, z { }
- parameters = nil
- TracePoint.new(:b_call) {|tp| parameters = tp.parameters }.enable do
- f.call(1, 2, 3)
- parameters.should == [[:req, :x], [:req, :y], [:req, :z]]
- end
- end
- end
-end
diff --git a/spec/ruby/core/tracepoint/path_spec.rb b/spec/ruby/core/tracepoint/path_spec.rb
index 1e31c1bb68..61592f5106 100644
--- a/spec/ruby/core/tracepoint/path_spec.rb
+++ b/spec/ruby/core/tracepoint/path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#path' do
it 'returns the path of the file being run' do
@@ -11,7 +11,7 @@ describe 'TracePoint#path' do
it 'equals (eval) inside an eval for :end event' do
path = nil
TracePoint.new(:end) { |tp| path = tp.path }.enable do
- eval("module TracePointSpec; end")
+ eval("class A; end")
path.should == '(eval)'
end
end
diff --git a/spec/ruby/core/tracepoint/raised_exception_spec.rb b/spec/ruby/core/tracepoint/raised_exception_spec.rb
index 450717b958..6c81431b25 100644
--- a/spec/ruby/core/tracepoint/raised_exception_spec.rb
+++ b/spec/ruby/core/tracepoint/raised_exception_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#raised_exception' do
it 'returns value from exception raised on the :raise event' do
diff --git a/spec/ruby/core/tracepoint/return_value_spec.rb b/spec/ruby/core/tracepoint/return_value_spec.rb
index f0ed86bd00..c9cfe091cd 100644
--- a/spec/ruby/core/tracepoint/return_value_spec.rb
+++ b/spec/ruby/core/tracepoint/return_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#return_value' do
def test; 'test' end
diff --git a/spec/ruby/core/tracepoint/self_spec.rb b/spec/ruby/core/tracepoint/self_spec.rb
index 8bfd09301e..9d33aa7477 100644
--- a/spec/ruby/core/tracepoint/self_spec.rb
+++ b/spec/ruby/core/tracepoint/self_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint#self' do
it 'return the trace object from event' do
@@ -8,13 +7,4 @@ describe 'TracePoint#self' do
trace.equal?(self).should be_true
end
end
-
- it 'return the class object from a class event' do
- trace = nil
- TracePoint.new(:class) { |tp| trace = tp.self }.enable do
- class TracePointSpec::C
- end
- end
- trace.should equal TracePointSpec::C
- end
end
diff --git a/spec/ruby/core/tracepoint/trace_spec.rb b/spec/ruby/core/tracepoint/trace_spec.rb
index ea6c85bcc5..9279348026 100644
--- a/spec/ruby/core/tracepoint/trace_spec.rb
+++ b/spec/ruby/core/tracepoint/trace_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe 'TracePoint.trace' do
it 'activates the trace automatically' do
- trace = TracePoint.trace(:line) {}
- trace.enabled?.should == true
+ trace = TracePoint.trace(:call) {}
+ trace.enabled?.should be_true
trace.disable
end
end
diff --git a/spec/ruby/core/true/and_spec.rb b/spec/ruby/core/true/and_spec.rb
index 99e69d3ae0..b81b6b36b6 100644
--- a/spec/ruby/core/true/and_spec.rb
+++ b/spec/ruby/core/true/and_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "TrueClass#&" do
it "returns false if other is nil or false, otherwise true" do
diff --git a/spec/ruby/core/true/dup_spec.rb b/spec/ruby/core/true/dup_spec.rb
index 351457ed22..cdf60e5bd6 100644
--- a/spec/ruby/core/true/dup_spec.rb
+++ b/spec/ruby/core/true/dup_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-describe "TrueClass#dup" do
- it "returns self" do
- true.dup.should equal(true)
+ruby_version_is '2.4' do
+ describe "TrueClass#dup" do
+ it "returns self" do
+ true.dup.should equal(true)
+ end
end
end
diff --git a/spec/ruby/core/true/inspect_spec.rb b/spec/ruby/core/true/inspect_spec.rb
index 09d1914856..baf26123c8 100644
--- a/spec/ruby/core/true/inspect_spec.rb
+++ b/spec/ruby/core/true/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "TrueClass#inspect" do
it "returns the string 'true'" do
diff --git a/spec/ruby/core/true/or_spec.rb b/spec/ruby/core/true/or_spec.rb
index 9bf76a62b8..a104551ae8 100644
--- a/spec/ruby/core/true/or_spec.rb
+++ b/spec/ruby/core/true/or_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "TrueClass#|" do
it "returns true" do
diff --git a/spec/ruby/core/true/to_s_spec.rb b/spec/ruby/core/true/to_s_spec.rb
index 68b0052c5d..0e2a807a95 100644
--- a/spec/ruby/core/true/to_s_spec.rb
+++ b/spec/ruby/core/true/to_s_spec.rb
@@ -1,17 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "TrueClass#to_s" do
it "returns the string 'true'" do
true.to_s.should == "true"
end
-
- ruby_version_is "2.7" do
- it "returns a frozen string" do
- true.to_s.frozen?.should == true
- end
-
- it "always returns the same string" do
- true.to_s.should equal(true.to_s)
- end
- end
end
diff --git a/spec/ruby/core/true/trueclass_spec.rb b/spec/ruby/core/true/trueclass_spec.rb
index 02af649d09..8837117d71 100644
--- a/spec/ruby/core/true/trueclass_spec.rb
+++ b/spec/ruby/core/true/trueclass_spec.rb
@@ -1,14 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "TrueClass" do
it ".allocate raises a TypeError" do
- -> do
+ lambda do
TrueClass.allocate
end.should raise_error(TypeError)
end
it ".new is undefined" do
- -> do
+ lambda do
TrueClass.new
end.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/true/xor_spec.rb b/spec/ruby/core/true/xor_spec.rb
index 8f5ecd5075..1d0ad394da 100644
--- a/spec/ruby/core/true/xor_spec.rb
+++ b/spec/ruby/core/true/xor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "TrueClass#^" do
it "returns true if other is nil or false, otherwise false" do
diff --git a/spec/ruby/core/unboundmethod/arity_spec.rb b/spec/ruby/core/unboundmethod/arity_spec.rb
index cd700b9f9b..a804235b70 100644
--- a/spec/ruby/core/unboundmethod/arity_spec.rb
+++ b/spec/ruby/core/unboundmethod/arity_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "UnboundMethod#arity" do
SpecEvaluate.desc = "for method definition"
diff --git a/spec/ruby/core/unboundmethod/bind_call_spec.rb b/spec/ruby/core/unboundmethod/bind_call_spec.rb
deleted file mode 100644
index c5d392156c..0000000000
--- a/spec/ruby/core/unboundmethod/bind_call_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-ruby_version_is '2.7' do
- describe "UnboundMethod#bind_call" do
- before :each do
- @normal_um = UnboundMethodSpecs::Methods.new.method(:foo).unbind
- @parent_um = UnboundMethodSpecs::Parent.new.method(:foo).unbind
- @child1_um = UnboundMethodSpecs::Child1.new.method(:foo).unbind
- @child2_um = UnboundMethodSpecs::Child2.new.method(:foo).unbind
- end
-
- it "raises TypeError if object is not kind_of? the Module the method defined in" do
- -> { @normal_um.bind_call(UnboundMethodSpecs::B.new) }.should raise_error(TypeError)
- end
-
- it "binds and calls the method if object is kind_of the Module the method defined in" do
- @normal_um.bind_call(UnboundMethodSpecs::Methods.new).should == true
- end
-
- it "binds and calls the method on any object when UnboundMethod is unbound from a module" do
- UnboundMethodSpecs::Mod.instance_method(:from_mod).bind_call(Object.new).should == nil
- end
-
- it "binds and calls the method for any object kind_of? the Module the method is defined in" do
- @parent_um.bind_call(UnboundMethodSpecs::Child1.new).should == nil
- @child1_um.bind_call(UnboundMethodSpecs::Parent.new).should == nil
- @child2_um.bind_call(UnboundMethodSpecs::Child1.new).should == nil
- end
-
- it "binds and calls a Kernel method retrieved from Object on BasicObject" do
- Object.instance_method(:instance_of?).bind_call(BasicObject.new, BasicObject).should == true
- end
-
- it "binds and calls a Parent's class method to any Child's class methods" do
- um = UnboundMethodSpecs::Parent.method(:class_method).unbind
- um.bind_call(UnboundMethodSpecs::Child1).should == "I am UnboundMethodSpecs::Child1"
- end
-
- it "will raise when binding a an object singleton's method to another object" do
- other = UnboundMethodSpecs::Parent.new
- p = UnboundMethodSpecs::Parent.new
- class << p
- def singleton_method
- :single
- end
- end
- um = p.method(:singleton_method).unbind
- ->{ um.bind_call(other) }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/core/unboundmethod/bind_spec.rb b/spec/ruby/core/unboundmethod/bind_spec.rb
index 03aaa22e74..3f7a7bf3ac 100644
--- a/spec/ruby/core/unboundmethod/bind_spec.rb
+++ b/spec/ruby/core/unboundmethod/bind_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "UnboundMethod#bind" do
before :each do
@@ -10,7 +10,7 @@ describe "UnboundMethod#bind" do
end
it "raises TypeError if object is not kind_of? the Module the method defined in" do
- -> { @normal_um.bind(UnboundMethodSpecs::B.new) }.should raise_error(TypeError)
+ lambda { @normal_um.bind(UnboundMethodSpecs::B.new) }.should raise_error(TypeError)
end
it "returns Method for any object that is kind_of? the Module method was extracted from" do
@@ -21,21 +21,11 @@ describe "UnboundMethod#bind" do
UnboundMethodSpecs::Mod.instance_method(:from_mod).bind(Object.new).should be_kind_of(Method)
end
- it "the returned Method is equal to the one directly returned by obj.method" do
+ it "returns Method returned for obj is equal to one directly returned by obj.method" do
obj = UnboundMethodSpecs::Methods.new
@normal_um.bind(obj).should == obj.method(:foo)
end
- it "returns Method for any object kind_of? the Module the method is defined in" do
- @parent_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method)
- @child1_um.bind(UnboundMethodSpecs::Parent.new).should be_kind_of(Method)
- @child2_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method)
- end
-
- it "allows binding a Kernel method retrieved from Object on BasicObject" do
- Object.instance_method(:instance_of?).bind(BasicObject.new).call(BasicObject).should == true
- end
-
it "returns a callable method" do
obj = UnboundMethodSpecs::Methods.new
@normal_um.bind(obj).call.should == obj.foo
@@ -56,6 +46,6 @@ describe "UnboundMethod#bind" do
end
end
um = p.method(:singleton_method).unbind
- ->{ um.bind(other) }.should raise_error(TypeError)
+ lambda{ um.bind(other) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/unboundmethod/clone_spec.rb b/spec/ruby/core/unboundmethod/clone_spec.rb
index 098ee61476..2f3fd834ad 100644
--- a/spec/ruby/core/unboundmethod/clone_spec.rb
+++ b/spec/ruby/core/unboundmethod/clone_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "UnboundMethod#clone" do
it "returns a copy of the UnboundMethod" do
diff --git a/spec/ruby/core/unboundmethod/eql_spec.rb b/spec/ruby/core/unboundmethod/eql_spec.rb
index cf2c6b5aae..8e91ef375e 100644
--- a/spec/ruby/core/unboundmethod/eql_spec.rb
+++ b/spec/ruby/core/unboundmethod/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "UnboundMethod#eql?" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/unboundmethod/equal_value_spec.rb b/spec/ruby/core/unboundmethod/equal_value_spec.rb
index 6242b04884..de141254c1 100644
--- a/spec/ruby/core/unboundmethod/equal_value_spec.rb
+++ b/spec/ruby/core/unboundmethod/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
context "Creating UnboundMethods" do
specify "there is no difference between Method#unbind and Module#instance_method" do
diff --git a/spec/ruby/core/unboundmethod/fixtures/classes.rb b/spec/ruby/core/unboundmethod/fixtures/classes.rb
index 46b1c51669..43e21916bf 100644
--- a/spec/ruby/core/unboundmethod/fixtures/classes.rb
+++ b/spec/ruby/core/unboundmethod/fixtures/classes.rb
@@ -34,7 +34,6 @@ module UnboundMethodSpecs
def with_block(&block); end
alias bar foo
- alias baz bar
alias alias_1 foo
alias alias_2 foo
diff --git a/spec/ruby/core/unboundmethod/hash_spec.rb b/spec/ruby/core/unboundmethod/hash_spec.rb
index 12dce0020f..6ba6c04834 100644
--- a/spec/ruby/core/unboundmethod/hash_spec.rb
+++ b/spec/ruby/core/unboundmethod/hash_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "UnboundMethod#hash" do
+ it "needs to be reviewed for spec completeness"
+
it "returns the same value for user methods that are eql?" do
foo, bar = UnboundMethodSpecs::Methods.instance_method(:foo), UnboundMethodSpecs::Methods.instance_method(:bar)
foo.hash.should == bar.hash
diff --git a/spec/ruby/core/unboundmethod/inspect_spec.rb b/spec/ruby/core/unboundmethod/inspect_spec.rb
index cecf542fcd..ffef61a639 100644
--- a/spec/ruby/core/unboundmethod/inspect_spec.rb
+++ b/spec/ruby/core/unboundmethod/inspect_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "UnboundMethod#inspect" do
- it_behaves_like :unboundmethod_to_s, :inspect
+ it_behaves_like(:unboundmethod_to_s, :inspect)
end
diff --git a/spec/ruby/core/unboundmethod/name_spec.rb b/spec/ruby/core/unboundmethod/name_spec.rb
index 4d0fb34fc8..c4602d529a 100644
--- a/spec/ruby/core/unboundmethod/name_spec.rb
+++ b/spec/ruby/core/unboundmethod/name_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "UnboundMethod#name" do
it "returns the name of the method" do
diff --git a/spec/ruby/core/unboundmethod/original_name_spec.rb b/spec/ruby/core/unboundmethod/original_name_spec.rb
deleted file mode 100644
index 7280dcb2b4..0000000000
--- a/spec/ruby/core/unboundmethod/original_name_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "UnboundMethod#original_name" do
- it "returns the name of the method" do
- String.instance_method(:upcase).original_name.should == :upcase
- end
-
- it "returns the original name" do
- obj = UnboundMethodSpecs::Methods.new
- obj.method(:foo).unbind.original_name.should == :foo
- obj.method(:bar).unbind.original_name.should == :foo
- UnboundMethodSpecs::Methods.instance_method(:bar).original_name.should == :foo
- end
-
- it "returns the original name even when aliased twice" do
- obj = UnboundMethodSpecs::Methods.new
- obj.method(:foo).unbind.original_name.should == :foo
- obj.method(:baz).unbind.original_name.should == :foo
- UnboundMethodSpecs::Methods.instance_method(:baz).original_name.should == :foo
- end
-end
diff --git a/spec/ruby/core/unboundmethod/owner_spec.rb b/spec/ruby/core/unboundmethod/owner_spec.rb
index 5f1f4646b3..165b175147 100644
--- a/spec/ruby/core/unboundmethod/owner_spec.rb
+++ b/spec/ruby/core/unboundmethod/owner_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "UnboundMethod#owner" do
it "returns the owner of the method" do
diff --git a/spec/ruby/core/unboundmethod/parameters_spec.rb b/spec/ruby/core/unboundmethod/parameters_spec.rb
index 2a3cb18196..a48c967ea5 100644
--- a/spec/ruby/core/unboundmethod/parameters_spec.rb
+++ b/spec/ruby/core/unboundmethod/parameters_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "UnboundMethod#parameters" do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/core/unboundmethod/shared/to_s.rb b/spec/ruby/core/unboundmethod/shared/to_s.rb
index 3987611d3f..07ba0903e2 100644
--- a/spec/ruby/core/unboundmethod/shared/to_s.rb
+++ b/spec/ruby/core/unboundmethod/shared/to_s.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :unboundmethod_to_s, shared: true do
before :each do
diff --git a/spec/ruby/core/unboundmethod/source_location_spec.rb b/spec/ruby/core/unboundmethod/source_location_spec.rb
index b5e6413816..8b95f0776b 100644
--- a/spec/ruby/core/unboundmethod/source_location_spec.rb
+++ b/spec/ruby/core/unboundmethod/source_location_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "UnboundMethod#source_location" do
before :each do
@@ -9,7 +9,7 @@ describe "UnboundMethod#source_location" do
it "sets the first value to the path of the file in which the method was defined" do
file = @method.source_location.first
file.should be_an_instance_of(String)
- file.should == File.realpath('../fixtures/classes.rb', __FILE__)
+ file.should == File.dirname(__FILE__) + '/fixtures/classes.rb'
end
it "sets the last value to a Fixnum representing the line on which the method was defined" do
diff --git a/spec/ruby/core/unboundmethod/super_method_spec.rb b/spec/ruby/core/unboundmethod/super_method_spec.rb
index c9fa1ec533..49d356fd2b 100644
--- a/spec/ruby/core/unboundmethod/super_method_spec.rb
+++ b/spec/ruby/core/unboundmethod/super_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "UnboundMethod#super_method" do
it "returns the method that would be called by super in the method" do
diff --git a/spec/ruby/core/unboundmethod/to_s_spec.rb b/spec/ruby/core/unboundmethod/to_s_spec.rb
index a508229b49..77e1d713f0 100644
--- a/spec/ruby/core/unboundmethod/to_s_spec.rb
+++ b/spec/ruby/core/unboundmethod/to_s_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/to_s'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
describe "UnboundMethod#to_s" do
- it_behaves_like :unboundmethod_to_s, :to_s
+ it_behaves_like(:unboundmethod_to_s, :to_s)
end
diff --git a/spec/ruby/core/warning/warn_spec.rb b/spec/ruby/core/warning/warn_spec.rb
index 7daf6323c3..44e9eb707b 100644
--- a/spec/ruby/core/warning/warn_spec.rb
+++ b/spec/ruby/core/warning/warn_spec.rb
@@ -1,59 +1,53 @@
-require_relative '../../spec_helper'
+require File.expand_path("../../../spec_helper", __FILE__)
describe "Warning.warn" do
- it "complains" do
- -> {
- Warning.warn("Chunky bacon!")
- }.should complain("Chunky bacon!")
- end
-
- it "does not add a newline" do
- ruby_exe("Warning.warn('test')", args: "2>&1").should == "test"
- end
-
- it "returns nil" do
- ruby_exe("p Warning.warn('test')", args: "2>&1").should == "testnil\n"
- end
+ ruby_version_is "2.4" do
+ it "complains" do
+ -> {
+ Warning.warn("Chunky bacon!")
+ }.should complain("Chunky bacon!")
+ end
- it "extends itself" do
- Warning.singleton_class.ancestors.should include(Warning)
- end
+ it "extends itself" do
+ Warning.singleton_class.ancestors.should include(Warning)
+ end
- it "has Warning as the method owner" do
- ruby_exe("p Warning.method(:warn).owner").should == "Warning\n"
- end
+ it "has Warning as the method owner" do
+ ruby_exe("p Warning.method(:warn).owner").should == "Warning\n"
+ end
- it "can be overridden" do
- code = <<-RUBY
- $stdout.sync = true
- $stderr.sync = true
- def Warning.warn(msg)
- if msg.start_with?("A")
- puts msg.upcase
- else
- super
+ it "can be overridden" do
+ code = <<-RUBY
+ $stdout.sync = true
+ $stderr.sync = true
+ def Warning.warn(msg)
+ if msg.start_with?("A")
+ puts msg.upcase
+ else
+ super
+ end
end
- end
- Warning.warn("A warning!")
- Warning.warn("warning from stderr\n")
- RUBY
- ruby_exe(code, args: "2>&1").should == %Q[A WARNING!\nwarning from stderr\n]
- end
+ Warning.warn("A warning!")
+ Warning.warn("warning from stderr\n")
+ RUBY
+ ruby_exe(code, args: "2>&1").should == %Q[A WARNING!\nwarning from stderr\n]
+ end
- it "is called by parser warnings" do
- Warning.should_receive(:warn)
- verbose = $VERBOSE
- $VERBOSE = false
- begin
- eval "{ key: :value, key: :value2 }"
- ensure
- $VERBOSE = verbose
+ it "is called by parser warnings" do
+ Warning.should_receive(:warn)
+ verbose = $VERBOSE
+ $VERBOSE = false
+ begin
+ eval "{ key: :value, key: :value2 }"
+ ensure
+ $VERBOSE = verbose
+ end
end
end
ruby_version_is "2.5" do
it "is called by Kernel.warn" do
- Warning.should_receive(:warn).with("Chunky bacon!\n")
+ Warning.should_receive(:warn)
verbose = $VERBOSE
$VERBOSE = false
begin
diff --git a/spec/ruby/default.mspec b/spec/ruby/default.mspec
index 6fd6d2bf9c..90f4c1ccaa 100644
--- a/spec/ruby/default.mspec
+++ b/spec/ruby/default.mspec
@@ -29,21 +29,24 @@ class MSpecScript
set :ci_files, get(:files)
# The default implementation to run the specs.
+ # TODO: this needs to be more sophisticated since the
+ # executable is not consistently named.
set :target, 'ruby'
set :backtrace_filter, /mspec\//
set :tags_patterns, [
- [%r(language/), 'tags/language/'],
- [%r(core/), 'tags/core/'],
- [%r(command_line/), 'tags/command_line/'],
- [%r(library/), 'tags/library/'],
- [%r(security/), 'tags/security/'],
- [/_spec\.rb$/, '_tags.txt']
+ [%r(language/), 'tags/1.9/language/'],
+ [%r(core/), 'tags/1.9/core/'],
+ [%r(command_line/), 'tags/1.9/command_line/'],
+ [%r(library/), 'tags/1.9/library/'],
+ [%r(security/), 'tags/1.9/security/'],
+ [/_spec.rb$/, '_tags.txt']
]
- set :toplevel_constants_excludes, [
- /\wSpecs?$/,
- /^CS_CONST/,
- ]
+ # Enable features
+ MSpec.enable_feature :fiber
+ MSpec.enable_feature :fiber_library
+ MSpec.enable_feature :fork if respond_to?(:fork, true)
+ MSpec.enable_feature :encoding
end
diff --git a/spec/ruby/fixtures/class.rb b/spec/ruby/fixtures/class.rb
index 68fbca7ba7..9609eb6f3c 100644
--- a/spec/ruby/fixtures/class.rb
+++ b/spec/ruby/fixtures/class.rb
@@ -1,11 +1,9 @@
module ClassSpecs
def self.sclass_with_block
- eval <<-RUBY
class << self
yield
end
- RUBY
end
def self.sclass_with_return
@@ -112,7 +110,7 @@ module ClassSpecs
class M < L; end
# Can't use a method here because of class definition in method body error
- ANON_CLASS_FOR_NEW = -> do
+ ANON_CLASS_FOR_NEW = lambda do
Class.new do
class NamedInModule
end
diff --git a/spec/ruby/fixtures/code/load_fixture_and__FILE__.rb b/spec/ruby/fixtures/code/load_fixture_and__FILE__.rb
deleted file mode 100644
index 27388c7d8d..0000000000
--- a/spec/ruby/fixtures/code/load_fixture_and__FILE__.rb
+++ /dev/null
@@ -1 +0,0 @@
-ScratchPad << __FILE__
diff --git a/spec/ruby/fixtures/code/recursive_require_fixture.rb b/spec/ruby/fixtures/code/recursive_require_fixture.rb
index ebeba34fce..8842a6ad74 100644
--- a/spec/ruby/fixtures/code/recursive_require_fixture.rb
+++ b/spec/ruby/fixtures/code/recursive_require_fixture.rb
@@ -1,3 +1,3 @@
-require_relative 'recursive_require_fixture'
+require File.expand_path("../recursive_require_fixture.rb", __FILE__)
ScratchPad << :loaded
diff --git a/spec/ruby/fixtures/code/wrap_fixture.rb b/spec/ruby/fixtures/code/wrap_fixture.rb
index 7ddf5a62e0..b83a8970d7 100644
--- a/spec/ruby/fixtures/code/wrap_fixture.rb
+++ b/spec/ruby/fixtures/code/wrap_fixture.rb
@@ -1,9 +1,3 @@
class LoadSpecWrap
- ScratchPad << String
+ ScratchPad << self
end
-
-def load_wrap_specs_top_level_method
-end
-ScratchPad << method(:load_wrap_specs_top_level_method).owner
-
-ScratchPad << self
diff --git a/spec/ruby/fixtures/rational.rb b/spec/ruby/fixtures/rational.rb
index 844d7f9820..d0d05d0437 100644
--- a/spec/ruby/fixtures/rational.rb
+++ b/spec/ruby/fixtures/rational.rb
@@ -8,7 +8,4 @@ module RationalSpecs
@value
end
end
-
- class CoerceError < StandardError
- end
end
diff --git a/spec/ruby/language/BEGIN_spec.rb b/spec/ruby/language/BEGIN_spec.rb
index 58cc2bebfb..c0784971b0 100644
--- a/spec/ruby/language/BEGIN_spec.rb
+++ b/spec/ruby/language/BEGIN_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The BEGIN keyword" do
before :each do
@@ -15,7 +15,7 @@ describe "The BEGIN keyword" do
end
it "must appear in a top-level context" do
- -> { eval "1.times { BEGIN { 1 } }" }.should raise_error(SyntaxError)
+ lambda { eval "1.times { BEGIN { 1 } }" }.should raise_error(SyntaxError)
end
it "runs first in a given code unit" do
diff --git a/spec/ruby/language/alias_spec.rb b/spec/ruby/language/alias_spec.rb
index 79348f70c3..e9f0050e17 100644
--- a/spec/ruby/language/alias_spec.rb
+++ b/spec/ruby/language/alias_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
class AliasObject
attr :foo
@@ -38,14 +38,14 @@ describe "The alias keyword" do
@obj.a.should == 5
end
- it "works with a double quoted symbol on the left-hand side" do
+ it "works with a doubule quoted symbol on the left-hand side" do
@meta.class_eval do
alias :"a" value
end
@obj.a.should == 5
end
- it "works with an interpolated symbol on the left-hand side" do
+ it "works with an interoplated symbol on the left-hand side" do
@meta.class_eval do
alias :"#{'a'}" value
end
@@ -66,14 +66,14 @@ describe "The alias keyword" do
@obj.a.should == 5
end
- it "works with a double quoted symbol on the right-hand side" do
+ it "works with a doubule quoted symbol on the right-hand side" do
@meta.class_eval do
alias a :"value"
end
@obj.a.should == 5
end
- it "works with an interpolated symbol on the right-hand side" do
+ it "works with an interoplated symbol on the right-hand side" do
@meta.class_eval do
alias a :"#{'value'}"
end
@@ -122,7 +122,7 @@ describe "The alias keyword" do
end
@obj.__value.should == 5
- -> { AliasObject.new.__value }.should raise_error(NoMethodError)
+ lambda { AliasObject.new.__value }.should raise_error(NoMethodError)
end
it "operates on the class/module metaclass when used in instance_eval" do
@@ -131,7 +131,7 @@ describe "The alias keyword" do
end
AliasObject.__klass_method.should == 7
- -> { Object.__klass_method }.should raise_error(NoMethodError)
+ lambda { Object.__klass_method }.should raise_error(NoMethodError)
end
it "operates on the class/module metaclass when used in instance_exec" do
@@ -140,7 +140,7 @@ describe "The alias keyword" do
end
AliasObject.__klass_method2.should == 7
- -> { Object.__klass_method2 }.should raise_error(NoMethodError)
+ lambda { Object.__klass_method2 }.should raise_error(NoMethodError)
end
it "operates on methods defined via attr, attr_reader, and attr_accessor" do
@@ -204,7 +204,7 @@ describe "The alias keyword" do
end
it "operates on methods with splat arguments defined in a superclass using text block for class eval" do
- subclass = Class.new(AliasObject)
+ class Sub < AliasObject;end
AliasObject.class_eval <<-code
def test(*args)
4
@@ -215,17 +215,17 @@ describe "The alias keyword" do
alias test_without_check test
alias test test_with_check
code
- subclass.new.test("testing").should == 4
+ Sub.new.test("testing").should == 4
end
it "is not allowed against Fixnum or String instances" do
- -> do
+ lambda do
1.instance_eval do
alias :foo :to_s
end
end.should raise_error(TypeError)
- -> do
+ lambda do
:blah.instance_eval do
alias :foo :to_s
end
@@ -238,21 +238,9 @@ describe "The alias keyword" do
end
it "raises a NameError when passed a missing name" do
- -> { @meta.class_eval { alias undef_method not_exist } }.should raise_error(NameError) { |e|
+ lambda { @meta.class_eval { alias undef_method not_exist } }.should raise_error(NameError) { |e|
# a NameError and not a NoMethodError
e.class.should == NameError
}
end
end
-
-describe "The alias keyword" do
- it "can create a new global variable, synonym of the original" do
- code = '$a = 1; alias $b $a; p [$a, $b]; $b = 2; p [$a, $b]'
- ruby_exe(code).should == "[1, 1]\n[2, 2]\n"
- end
-
- it "can override an existing global variable and make them synonyms" do
- code = '$a = 1; $b = 2; alias $b $a; p [$a, $b]; $b = 3; p [$a, $b]'
- ruby_exe(code).should == "[1, 1]\n[3, 3]\n"
- end
-end
diff --git a/spec/ruby/language/and_spec.rb b/spec/ruby/language/and_spec.rb
index 55a2a3103a..e084fd3cef 100644
--- a/spec/ruby/language/and_spec.rb
+++ b/spec/ruby/language/and_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The '&&' statement" do
diff --git a/spec/ruby/language/array_spec.rb b/spec/ruby/language/array_spec.rb
index 2583cffbf7..c3ed8c14c5 100644
--- a/spec/ruby/language/array_spec.rb
+++ b/spec/ruby/language/array_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/array'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/array', __FILE__)
describe "Array literals" do
it "[] should return a new array populated with the given elements" do
@@ -36,13 +36,6 @@ describe "Array literals" do
[1, *nil, 3].should == [1, 3]
[*nil, *nil, *nil].should == []
end
-
- it "evaluates each argument exactly once" do
- se = ArraySpec::SideEffect.new
- se.array_result(true)
- se.array_result(false)
- se.call_count.should == 4
- end
end
describe "Bareword array literal" do
diff --git a/spec/ruby/language/block_spec.rb b/spec/ruby/language/block_spec.rb
index 6f92383af8..733e90211c 100644
--- a/spec/ruby/language/block_spec.rb
+++ b/spec/ruby/language/block_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/block'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/block', __FILE__)
describe "A block yielded a single" do
before :all do
@@ -36,7 +36,7 @@ describe "A block yielded a single" do
m([1, 2]) { |a=5, b=4, c=3| [a, b, c] }.should == [1, 2, 3]
end
- it "assigns elements to post arguments" do
+ it "assgins elements to post arguments" do
m([1, 2]) { |a=5, b, c, d| [a, b, c, d] }.should == [5, 1, 2, nil]
end
@@ -45,31 +45,25 @@ describe "A block yielded a single" do
end
it "assigns elements to mixed argument types" do
- suppress_keyword_warning do
- result = m([1, 2, 3, {x: 9}]) { |a, b=5, *c, d, e: 2, **k| [a, b, c, d, e, k] }
- result.should == [1, 2, [], 3, 2, {x: 9}]
- end
+ result = m([1, 2, 3, {x: 9}]) { |a, b=5, *c, d, e: 2, **k| [a, b, c, d, e, k] }
+ result.should == [1, 2, [], 3, 2, {x: 9}]
end
it "assigns symbol keys from a Hash to keyword arguments" do
- suppress_keyword_warning do
- result = m(["a" => 1, a: 10]) { |a=nil, **b| [a, b] }
- result.should == [{"a" => 1}, a: 10]
- end
+ result = m(["a" => 1, a: 10]) { |a=nil, **b| [a, b] }
+ result.should == [{"a" => 1}, a: 10]
end
it "assigns symbol keys from a Hash returned by #to_hash to keyword arguments" do
- suppress_keyword_warning do
- obj = mock("coerce block keyword arguments")
- obj.should_receive(:to_hash).and_return({"a" => 1, b: 2})
+ obj = mock("coerce block keyword arguments")
+ obj.should_receive(:to_hash).and_return({"a" => 1, b: 2})
- result = m([obj]) { |a=nil, **b| [a, b] }
- result.should == [{"a" => 1}, b: 2]
- end
+ result = m([obj]) { |a=nil, **b| [a, b] }
+ result.should == [{"a" => 1}, b: 2]
end
- ruby_version_is ""..."2.7" do
- it "calls #to_hash on the argument and uses resulting hash as first argument when optional argument and keyword argument accepted" do
+ ruby_version_is "2.2.1" do # SEGV on MRI 2.2.0
+ it "calls #to_hash on the argument but does not use the result when no keywords are present" do
obj = mock("coerce block keyword arguments")
obj.should_receive(:to_hash).and_return({"a" => 1, "b" => 2})
@@ -78,23 +72,9 @@ describe "A block yielded a single" do
end
end
- ruby_version_is "2.7" do
- it "calls #to_hash on the argument but ignores result when optional argument and keyword argument accepted" do
- obj = mock("coerce block keyword arguments")
- obj.should_receive(:to_hash).and_return({"a" => 1, "b" => 2})
-
- result = m([obj]) { |a=nil, **b| [a, b] }
- result.should == [obj, {}]
- end
- end
-
- describe "when non-symbol keys are in a keyword arguments Hash" do
- it "separates non-symbol keys and symbol keys" do
- suppress_keyword_warning do
- result = m(["a" => 10, b: 2]) { |a=nil, **b| [a, b] }
- result.should == [{"a" => 10}, {b: 2}]
- end
- end
+ it "assigns non-symbol keys to non-keyword arguments" do
+ result = m(["a" => 10, b: 2]) { |a=nil, **b| [a, b] }
+ result.should == [{"a" => 10}, {b: 2}]
end
it "does not treat hashes with string keys as keyword arguments" do
@@ -103,40 +83,34 @@ describe "A block yielded a single" do
end
it "calls #to_hash on the last element if keyword arguments are present" do
- suppress_keyword_warning do
- obj = mock("destructure block keyword arguments")
- obj.should_receive(:to_hash).and_return({x: 9})
+ obj = mock("destructure block keyword arguments")
+ obj.should_receive(:to_hash).and_return({x: 9})
- result = m([1, 2, 3, obj]) { |a, *b, c, **k| [a, b, c, k] }
- result.should == [1, [2], 3, {x: 9}]
- end
+ result = m([1, 2, 3, obj]) { |a, *b, c, **k| [a, b, c, k] }
+ result.should == [1, [2], 3, {x: 9}]
end
it "assigns the last element to a non-keyword argument if #to_hash returns nil" do
- suppress_keyword_warning do
- obj = mock("destructure block keyword arguments")
- obj.should_receive(:to_hash).and_return(nil)
+ obj = mock("destructure block keyword arguments")
+ obj.should_receive(:to_hash).and_return(nil)
- result = m([1, 2, 3, obj]) { |a, *b, c, **k| [a, b, c, k] }
- result.should == [1, [2, 3], obj, {}]
- end
+ result = m([1, 2, 3, obj]) { |a, *b, c, **k| [a, b, c, k] }
+ result.should == [1, [2, 3], obj, {}]
end
it "calls #to_hash on the last element when there are more arguments than parameters" do
- suppress_keyword_warning do
- x = mock("destructure matching block keyword argument")
- x.should_receive(:to_hash).and_return({x: 9})
+ x = mock("destructure matching block keyword argument")
+ x.should_receive(:to_hash).and_return({x: 9})
- result = m([1, 2, 3, {y: 9}, 4, 5, x]) { |a, b=5, c, **k| [a, b, c, k] }
- result.should == [1, 2, 3, {x: 9}]
- end
+ result = m([1, 2, 3, {y: 9}, 4, 5, x]) { |a, b=5, c, **k| [a, b, c, k] }
+ result.should == [1, 2, 3, {x: 9}]
end
it "raises a TypeError if #to_hash does not return a Hash" do
obj = mock("destructure block keyword arguments")
obj.should_receive(:to_hash).and_return(1)
- -> { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(TypeError)
+ lambda { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(TypeError)
end
it "raises the error raised inside #to_hash" do
@@ -144,7 +118,7 @@ describe "A block yielded a single" do
error = RuntimeError.new("error while converting to a hash")
obj.should_receive(:to_hash).and_raise(error)
- -> { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(error)
+ lambda { m([1, 2, 3, obj]) { |a, *b, c, **k| } }.should raise_error(error)
end
it "does not call #to_ary on the Array" do
@@ -195,7 +169,7 @@ describe "A block yielded a single" do
obj = mock("destructure block arguments")
obj.should_receive(:to_ary).and_return(1)
- -> { m(obj) { |a, b| } }.should raise_error(TypeError)
+ lambda { m(obj) { |a, b| } }.should raise_error(TypeError)
end
end
end
@@ -243,12 +217,6 @@ describe "A block" do
it "does not raise an exception when values are yielded" do
@y.s(0) { 1 }.should == 1
end
-
- ruby_version_is "2.5" do
- it "may include a rescue clause" do
- eval("@y.z do raise ArgumentError; rescue ArgumentError; 7; end").should == 7
- end
- end
end
describe "taking || arguments" do
@@ -259,12 +227,6 @@ describe "A block" do
it "does not raise an exception when values are yielded" do
@y.s(0) { || 1 }.should == 1
end
-
- ruby_version_is "2.5" do
- it "may include a rescue clause" do
- eval('@y.z do || raise ArgumentError; rescue ArgumentError; 7; end').should == 7
- end
- end
end
describe "taking |a| arguments" do
@@ -290,16 +252,10 @@ describe "A block" do
it "does not destructure a single Array value" do
@y.s([1, 2]) { |a| a }.should == [1, 2]
end
-
- ruby_version_is "2.5" do
- it "may include a rescue clause" do
- eval('@y.s(1) do |x| raise ArgumentError; rescue ArgumentError; 7; end').should == 7
- end
- end
end
describe "taking |a, b| arguments" do
- it "assigns nil to the arguments when no values are yielded" do
+ it "assgins nil to the arguments when no values are yielded" do
@y.z { |a, b| [a, b] }.should == [nil, nil]
end
@@ -358,14 +314,14 @@ describe "A block" do
obj = mock("block yield to_ary invalid")
obj.should_receive(:to_ary).and_return(1)
- -> { @y.s(obj) { |a, b| } }.should raise_error(TypeError)
+ lambda { @y.s(obj) { |a, b| } }.should raise_error(TypeError)
end
it "raises the original exception if #to_ary raises an exception" do
obj = mock("block yield to_ary raising an exception")
obj.should_receive(:to_ary).and_raise(ZeroDivisionError)
- -> { @y.s(obj) { |a, b| } }.should raise_error(ZeroDivisionError)
+ lambda { @y.s(obj) { |a, b| } }.should raise_error(ZeroDivisionError)
end
end
@@ -422,7 +378,7 @@ describe "A block" do
obj = mock("block yield to_ary invalid")
obj.should_receive(:to_ary).and_return(1)
- -> { @y.s(obj) { |a, *b| } }.should raise_error(TypeError)
+ lambda { @y.s(obj) { |a, *b| } }.should raise_error(TypeError)
end
end
@@ -503,7 +459,7 @@ describe "A block" do
@y.z { |a, | a }.should be_nil
end
- it "assigns the argument a single value yielded" do
+ it "assgins the argument a single value yielded" do
@y.s(1) { |a, | a }.should == 1
end
@@ -547,7 +503,7 @@ describe "A block" do
obj = mock("block yield to_ary invalid")
obj.should_receive(:to_ary).and_return(1)
- -> { @y.s(obj) { |a, | } }.should raise_error(TypeError)
+ lambda { @y.s(obj) { |a, | } }.should raise_error(TypeError)
end
end
@@ -589,7 +545,7 @@ describe "A block" do
obj = mock("block yield to_ary invalid")
obj.should_receive(:to_ary).and_return(1)
- -> { @y.s(obj) { |(a, b)| } }.should raise_error(TypeError)
+ lambda { @y.s(obj) { |(a, b)| } }.should raise_error(TypeError)
end
end
@@ -630,7 +586,7 @@ describe "A block" do
obj = mock("block yield to_ary invalid")
obj.should_receive(:to_ary).and_return(1)
- -> { @y.s(obj) { |(a, b), c| } }.should raise_error(TypeError)
+ lambda { @y.s(obj) { |(a, b), c| } }.should raise_error(TypeError)
end
end
@@ -670,12 +626,6 @@ describe "A block" do
end
end
- describe "taking |*a, b:|" do
- it "merges the hash into the splatted array" do
- @y.k { |*a, b:| [a, b] }.should == [[], true]
- end
- end
-
describe "arguments with _" do
it "extracts arguments with _" do
@y.m([[1, 2, 3], 4]) { |(_, a, _), _| a }.should == 2
@@ -689,9 +639,9 @@ describe "A block" do
describe "taking identically-named arguments" do
it "raises a SyntaxError for standard arguments" do
- -> { eval "lambda { |x,x| }" }.should raise_error(SyntaxError)
- -> { eval "->(x,x) {}" }.should raise_error(SyntaxError)
- -> { eval "Proc.new { |x,x| }" }.should raise_error(SyntaxError)
+ lambda { eval "lambda { |x,x| }" }.should raise_error(SyntaxError)
+ lambda { eval "->(x,x) {}" }.should raise_error(SyntaxError)
+ lambda { eval "Proc.new { |x,x| }" }.should raise_error(SyntaxError)
end
it "accepts unnamed arguments" do
@@ -712,27 +662,27 @@ describe "Block-local variables" do
end
it "can not have the same name as one of the standard parameters" do
- -> { eval "[1].each {|foo; foo| }" }.should raise_error(SyntaxError)
- -> { eval "[1].each {|foo, bar; glark, bar| }" }.should raise_error(SyntaxError)
+ lambda { eval "[1].each {|foo; foo| }" }.should raise_error(SyntaxError)
+ lambda { eval "[1].each {|foo, bar; glark, bar| }" }.should raise_error(SyntaxError)
end
it "can not be prefixed with an asterisk" do
- -> { eval "[1].each {|foo; *bar| }" }.should raise_error(SyntaxError)
- -> do
+ lambda { eval "[1].each {|foo; *bar| }" }.should raise_error(SyntaxError)
+ lambda do
eval "[1].each {|foo, bar; glark, *fnord| }"
end.should raise_error(SyntaxError)
end
it "can not be prefixed with an ampersand" do
- -> { eval "[1].each {|foo; &bar| }" }.should raise_error(SyntaxError)
- -> do
+ lambda { eval "[1].each {|foo; &bar| }" }.should raise_error(SyntaxError)
+ lambda do
eval "[1].each {|foo, bar; glark, &fnord| }"
end.should raise_error(SyntaxError)
end
it "can not be assigned default values" do
- -> { eval "[1].each {|foo; bar=1| }" }.should raise_error(SyntaxError)
- -> do
+ lambda { eval "[1].each {|foo; bar=1| }" }.should raise_error(SyntaxError)
+ lambda do
eval "[1].each {|foo, bar; glark, fnord=:fnord| }"
end.should raise_error(SyntaxError)
end
@@ -743,8 +693,8 @@ describe "Block-local variables" do
end
it "only allow a single semi-colon in the parameter list" do
- -> { eval "[1].each {|foo; bar; glark| }" }.should raise_error(SyntaxError)
- -> { eval "[1].each {|; bar; glark| }" }.should raise_error(SyntaxError)
+ lambda { eval "[1].each {|foo; bar; glark| }" }.should raise_error(SyntaxError)
+ lambda { eval "[1].each {|; bar; glark| }" }.should raise_error(SyntaxError)
end
it "override shadowed variables from the outer scope" do
@@ -807,8 +757,8 @@ describe "Post-args" do
end
it "are required" do
- -> {
- -> *a, b do
+ lambda {
+ lambda do |*a, b|
[a, b]
end.call
}.should raise_error(ArgumentError)
@@ -876,38 +826,20 @@ describe "Post-args" do
end
describe "with a circular argument reference" do
- ruby_version_is ''...'2.7' do
- it "warns and uses a nil value when there is an existing local variable with same name" do
- a = 1
- -> {
- @proc = eval "proc { |a=a| a }"
- }.should complain(/circular argument reference/)
- @proc.call.should == nil
- end
-
- it "warns and uses a nil value when there is an existing method with same name" do
- def a; 1; end
- -> {
- @proc = eval "proc { |a=a| a }"
- }.should complain(/circular argument reference/)
- @proc.call.should == nil
- end
+ it "shadows an existing local with the same name as the argument" do
+ a = 1
+ -> {
+ @proc = eval "proc { |a=a| a }"
+ }.should complain(/circular argument reference/)
+ @proc.call.should == nil
end
- ruby_version_is '2.7' do
- it "raises a SyntaxError if using an existing local with the same name as the argument" do
- a = 1
- -> {
- @proc = eval "proc { |a=a| a }"
- }.should raise_error(SyntaxError)
- end
-
- it "raises a SyntaxError if there is an existing method with the same name as the argument" do
- def a; 1; end
- -> {
- @proc = eval "proc { |a=a| a }"
- }.should raise_error(SyntaxError)
- end
+ it "shadows an existing method with the same name as the argument" do
+ def a; 1; end
+ -> {
+ @proc = eval "proc { |a=a| a }"
+ }.should complain(/circular argument reference/)
+ @proc.call.should == nil
end
it "calls an existing method with the same name as the argument if explicitly using ()" do
diff --git a/spec/ruby/language/break_spec.rb b/spec/ruby/language/break_spec.rb
index 754d5d3c49..09e8ff3d93 100644
--- a/spec/ruby/language/break_spec.rb
+++ b/spec/ruby/language/break_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/break'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/break', __FILE__)
describe "The break statement in a block" do
before :each do
@@ -52,29 +52,29 @@ describe "The break statement in a captured block" do
describe "when the invocation of the scope creating the block is still active" do
it "raises a LocalJumpError when invoking the block from the scope creating the block" do
- -> { @program.break_in_method }.should raise_error(LocalJumpError)
+ lambda { @program.break_in_method }.should raise_error(LocalJumpError)
ScratchPad.recorded.should == [:a, :xa, :d, :b]
end
it "raises a LocalJumpError when invoking the block from a method" do
- -> { @program.break_in_nested_method }.should raise_error(LocalJumpError)
+ lambda { @program.break_in_nested_method }.should raise_error(LocalJumpError)
ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b]
end
it "raises a LocalJumpError when yielding to the block" do
- -> { @program.break_in_yielding_method }.should raise_error(LocalJumpError)
+ lambda { @program.break_in_yielding_method }.should raise_error(LocalJumpError)
ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b]
end
end
describe "from a scope that has returned" do
it "raises a LocalJumpError when calling the block from a method" do
- -> { @program.break_in_method_captured }.should raise_error(LocalJumpError)
+ lambda { @program.break_in_method_captured }.should raise_error(LocalJumpError)
ScratchPad.recorded.should == [:a, :za, :xa, :zd, :zb]
end
it "raises a LocalJumpError when yielding to the block" do
- -> { @program.break_in_yield_captured }.should raise_error(LocalJumpError)
+ lambda { @program.break_in_yield_captured }.should raise_error(LocalJumpError)
ScratchPad.recorded.should == [:a, :za, :xa, :zd, :aa, :zb]
end
end
@@ -100,7 +100,7 @@ describe "The break statement in a lambda" do
end
it "returns from the lambda" do
- l = -> {
+ l = lambda {
ScratchPad << :before
break :foo
ScratchPad << :after
@@ -111,7 +111,7 @@ describe "The break statement in a lambda" do
it "returns from the call site if the lambda is passed as a block" do
def mid(&b)
- -> {
+ lambda {
ScratchPad << :before
b.call
ScratchPad << :unreachable1
@@ -208,7 +208,7 @@ describe "Break inside a while loop" do
it "passes the value returned by a method with omitted parenthesis and passed block" do
obj = BreakSpecs::Block.new
- -> { break obj.method :value do |x| x end }.call.should == :value
+ lambda { break obj.method :value do |x| x end }.call.should == :value
end
end
diff --git a/spec/ruby/language/case_spec.rb b/spec/ruby/language/case_spec.rb
index 1475e20f75..25f5d0efc4 100644
--- a/spec/ruby/language/case_spec.rb
+++ b/spec/ruby/language/case_spec.rb
@@ -1,17 +1,17 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The 'case'-construct" do
it "evaluates the body of the when clause matching the case target expression" do
case 1
- when 2; false
- when 1; true
+ when 2; false
+ when 1; true
end.should == true
end
it "evaluates the body of the when clause whose array expression includes the case target expression" do
case 2
- when 3, 4; false
- when 1, 2; true
+ when 3, 4; false
+ when 1, 2; true
end.should == true
end
@@ -21,7 +21,7 @@ describe "The 'case'-construct" do
def bar; @calls << :bar; end
case true
- when foo, bar;
+ when foo, bar;
end
@calls.should == [:foo, :bar]
@@ -29,31 +29,31 @@ describe "The 'case'-construct" do
it "evaluates the body of the when clause whose range expression includes the case target expression" do
case 5
- when 21..30; false
- when 1..20; true
+ when 21..30; false
+ when 1..20; true
end.should == true
end
it "returns nil when no 'then'-bodies are given" do
case "a"
- when "a"
- when "b"
+ when "a"
+ when "b"
end.should == nil
end
it "evaluates the 'else'-body when no other expression matches" do
case "c"
- when "a"; 'foo'
- when "b"; 'bar'
- else 'zzz'
+ when "a"; 'foo'
+ when "b"; 'bar'
+ else 'zzz'
end.should == 'zzz'
end
it "returns nil when no expression matches and 'else'-body is empty" do
case "c"
- when "a"; "a"
- when "b"; "b"
- else
+ when "a"; "a"
+ when "b"; "b"
+ else
end.should == nil
end
@@ -70,143 +70,105 @@ describe "The 'case'-construct" do
it "returns the statement following 'then'" do
case "a"
- when "a" then 'foo'
- when "b" then 'bar'
+ when "a" then 'foo'
+ when "b" then 'bar'
end.should == 'foo'
end
it "tests classes with case equality" do
case "a"
- when String
- 'foo'
- when Symbol
- 'bar'
+ when String
+ 'foo'
+ when Symbol
+ 'bar'
end.should == 'foo'
end
it "tests with matching regexps" do
case "hello"
- when /abc/; false
- when /^hell/; true
+ when /abc/; false
+ when /^hell/; true
end.should == true
end
- it "tests with matching regexps and sets $~ and captures" do
- case "foo42"
- when /oo(\d+)/
- $~.should be_kind_of(MatchData)
- $1.should == "42"
- else
- flunk
- end
- $~.should be_kind_of(MatchData)
- $1.should == "42"
- end
-
- it "tests with a regexp interpolated within another regexp" do
- digits = '\d+'
- case "foo44"
- when /oo(#{digits})/
- $~.should be_kind_of(MatchData)
- $1.should == "44"
- else
- flunk
- end
- $~.should be_kind_of(MatchData)
- $1.should == "44"
- end
-
- it "tests with a string interpolated in a regexp" do
- digits_regexp = /\d+/
- case "foo43"
- when /oo(#{digits_regexp})/
- $~.should be_kind_of(MatchData)
- $1.should == "43"
- else
- flunk
- end
- $~.should be_kind_of(MatchData)
- $1.should == "43"
- end
-
it "does not test with equality when given classes" do
case :symbol.class
- when Symbol
- "bar"
- when String
- "bar"
- else
- "foo"
+ when Symbol
+ "bar"
+ when String
+ "bar"
+ else
+ "foo"
end.should == "foo"
end
it "takes lists of values" do
case 'z'
- when 'a', 'b', 'c', 'd'
- "foo"
- when 'x', 'y', 'z'
- "bar"
+ when 'a', 'b', 'c', 'd'
+ "foo"
+ when 'x', 'y', 'z'
+ "bar"
end.should == "bar"
case 'b'
- when 'a', 'b', 'c', 'd'
- "foo"
- when 'x', 'y', 'z'
- "bar"
+ when 'a', 'b', 'c', 'd'
+ "foo"
+ when 'x', 'y', 'z'
+ "bar"
end.should == "foo"
end
it "expands arrays to lists of values" do
case 'z'
- when *['a', 'b', 'c', 'd']
- "foo"
- when *['x', 'y', 'z']
- "bar"
+ when *['a', 'b', 'c', 'd']
+ "foo"
+ when *['x', 'y', 'z']
+ "bar"
end.should == "bar"
end
it "takes an expanded array in addition to a list of values" do
case 'f'
- when 'f', *['a', 'b', 'c', 'd']
- "foo"
- when *['x', 'y', 'z']
- "bar"
+ when 'f', *['a', 'b', 'c', 'd']
+ "foo"
+ when *['x', 'y', 'z']
+ "bar"
end.should == "foo"
case 'b'
- when 'f', *['a', 'b', 'c', 'd']
- "foo"
- when *['x', 'y', 'z']
- "bar"
+ when 'f', *['a', 'b', 'c', 'd']
+ "foo"
+ when *['x', 'y', 'z']
+ "bar"
end.should == "foo"
end
it "takes an expanded array before additional listed values" do
case 'f'
- when *['a', 'b', 'c', 'd'], 'f'
- "foo"
- when *['x', 'y', 'z']
- "bar"
+ when *['a', 'b', 'c', 'd'], 'f'
+ "foo"
+ when *['x', 'y', 'z']
+ "bar"
end.should == 'foo'
end
it "expands arrays from variables before additional listed values" do
a = ['a', 'b', 'c']
case 'a'
- when *a, 'd', 'e'
- "foo"
- when 'x'
- "bar"
+ when *a, 'd', 'e'
+ "foo"
+ when 'x'
+ "bar"
end.should == "foo"
end
it "expands arrays from variables before a single additional listed value" do
a = ['a', 'b', 'c']
case 'a'
- when *a, 'd'
- "foo"
- when 'x'
- "bar"
+ when *a, 'd'
+ "foo"
+ when 'x'
+ "bar"
end.should == "foo"
end
@@ -215,10 +177,10 @@ describe "The 'case'-construct" do
b = ['d', 'e', 'f']
case 'f'
- when *a, *b, 'g', 'h'
- "foo"
- when 'x'
- "bar"
+ when *a, *b, 'g', 'h'
+ "foo"
+ when 'x'
+ "bar"
end.should == "foo"
end
@@ -228,47 +190,47 @@ describe "The 'case'-construct" do
b = ['f']
case 'f'
- when 'f', *a|b
- "foo"
- when *['x', 'y', 'z']
- "bar"
+ when 'f', *a|b
+ "foo"
+ when *['x', 'y', 'z']
+ "bar"
end.should == "foo"
end
it "never matches when clauses with no values" do
case nil
- when *[]
- "foo"
+ when *[]
+ "foo"
end.should == nil
end
it "lets you define a method after the case statement" do
case (def foo; 'foo'; end; 'f')
- when 'a'
- 'foo'
- when 'f'
- 'bar'
+ when 'a'
+ 'foo'
+ when 'f'
+ 'bar'
end.should == 'bar'
end
it "raises a SyntaxError when 'else' is used when no 'when' is given" do
- -> {
+ lambda {
eval <<-CODE
case 4
- else
- true
+ else
+ true
end
CODE
}.should raise_error(SyntaxError)
end
it "raises a SyntaxError when 'else' is used before a 'when' was given" do
- -> {
+ lambda {
eval <<-CODE
case 4
- else
- true
- when 4; false
+ else
+ true
+ when 4; false
end
CODE
}.should raise_error(SyntaxError)
@@ -325,56 +287,56 @@ end
describe "The 'case'-construct with no target expression" do
it "evaluates the body of the first clause when at least one of its condition expressions is true" do
case
- when true, false; 'foo'
+ when true, false; 'foo'
end.should == 'foo'
end
it "evaluates the body of the first when clause that is not false/nil" do
case
- when false; 'foo'
- when 2; 'bar'
- when 1 == 1; 'baz'
+ when false; 'foo'
+ when 2; 'bar'
+ when 1 == 1; 'baz'
end.should == 'bar'
case
- when false; 'foo'
- when nil; 'foo'
- when 1 == 1; 'bar'
+ when false; 'foo'
+ when nil; 'foo'
+ when 1 == 1; 'bar'
end.should == 'bar'
end
it "evaluates the body of the else clause if all when clauses are false/nil" do
case
- when false; 'foo'
- when nil; 'foo'
- when 1 == 2; 'bar'
- else 'baz'
+ when false; 'foo'
+ when nil; 'foo'
+ when 1 == 2; 'bar'
+ else 'baz'
end.should == 'baz'
end
it "evaluates multiple conditional expressions as a boolean disjunction" do
case
- when true, false; 'foo'
- else 'bar'
+ when true, false; 'foo'
+ else 'bar'
end.should == 'foo'
case
- when false, true; 'foo'
- else 'bar'
+ when false, true; 'foo'
+ else 'bar'
end.should == 'foo'
end
it "evaluates true as only 'true' when true is the first clause" do
case 1
- when true; "bad"
- when Integer; "good"
+ when true; "bad"
+ when Integer; "good"
end.should == "good"
end
it "evaluates false as only 'false' when false is the first clause" do
case nil
- when false; "bad"
- when nil; "good"
+ when false; "bad"
+ when nil; "good"
end.should == "good"
end
@@ -390,17 +352,17 @@ describe "The 'case'-construct with no target expression" do
a2 = ['b', 'a', 'r']
case 'f'
- when *a1, *['x', 'y', 'z']
- "foo"
- when *a2, *['x', 'y', 'z']
- "bar"
+ when *a1, *['x', 'y', 'z']
+ "foo"
+ when *a2, *['x', 'y', 'z']
+ "bar"
end.should == "foo"
case 'b'
- when *a1, *['x', 'y', 'z']
- "foo"
- when *a2, *['x', 'y', 'z']
- "bar"
+ when *a1, *['x', 'y', 'z']
+ "foo"
+ when *a2, *['x', 'y', 'z']
+ "bar"
end.should == "bar"
end
diff --git a/spec/ruby/language/class_spec.rb b/spec/ruby/language/class_spec.rb
index 88b7a6a74f..ba4af3d880 100644
--- a/spec/ruby/language/class_spec.rb
+++ b/spec/ruby/language/class_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/class'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class', __FILE__)
ClassSpecsNumber = 12
@@ -13,9 +13,11 @@ describe "The class keyword" do
ClassSpecsKeywordWithSemicolon.should be_an_instance_of(Class)
end
- it "does not raise a SyntaxError when opening a class without a semicolon" do
- eval "class ClassSpecsKeywordWithoutSemicolon end"
- ClassSpecsKeywordWithoutSemicolon.should be_an_instance_of(Class)
+ ruby_version_is "2.3" do
+ it "does not raise a SyntaxError when opening a class without a semicolon" do
+ eval "class ClassSpecsKeywordWithoutSemicolon end"
+ ClassSpecsKeywordWithoutSemicolon.should be_an_instance_of(Class)
+ end
end
end
@@ -30,7 +32,7 @@ describe "A class definition" do
end
it "raises TypeError if constant given as class name exists and is not a Module" do
- -> {
+ lambda {
class ClassSpecsNumber
end
}.should raise_error(TypeError)
@@ -38,19 +40,19 @@ describe "A class definition" do
# test case known to be detecting bugs (JRuby, MRI)
it "raises TypeError if the constant qualifying the class is nil" do
- -> {
+ lambda {
class nil::Foo
end
}.should raise_error(TypeError)
end
it "raises TypeError if any constant qualifying the class is not a Module" do
- -> {
+ lambda {
class ClassSpecs::Number::MyClass
end
}.should raise_error(TypeError)
- -> {
+ lambda {
class ClassSpecsNumber::MyClass
end
}.should raise_error(TypeError)
@@ -64,7 +66,7 @@ describe "A class definition" do
module ClassSpecs
class SuperclassResetToSubclass < L
end
- -> {
+ lambda {
class SuperclassResetToSubclass < M
end
}.should raise_error(TypeError, /superclass mismatch/)
@@ -77,7 +79,7 @@ describe "A class definition" do
end
SuperclassReopenedBasicObject.superclass.should == A
- -> {
+ lambda {
class SuperclassReopenedBasicObject < BasicObject
end
}.should raise_error(TypeError, /superclass mismatch/)
@@ -92,7 +94,7 @@ describe "A class definition" do
end
SuperclassReopenedObject.superclass.should == A
- -> {
+ lambda {
class SuperclassReopenedObject < Object
end
}.should raise_error(TypeError, /superclass mismatch/)
@@ -117,7 +119,7 @@ describe "A class definition" do
class NoSuperclassSet
end
- -> {
+ lambda {
class NoSuperclassSet < String
end
}.should raise_error(TypeError, /superclass mismatch/)
@@ -127,7 +129,7 @@ describe "A class definition" do
it "allows using self as the superclass if self is a class" do
ClassSpecs::I::J.superclass.should == ClassSpecs::I
- -> {
+ lambda {
class ShouldNotWork < self; end
}.should raise_error(TypeError)
end
@@ -148,7 +150,7 @@ describe "A class definition" do
it "raises a TypeError if inheriting from a metaclass" do
obj = mock("metaclass super")
meta = obj.singleton_class
- -> { class ClassSpecs::MetaclassSuper < meta; end }.should raise_error(TypeError)
+ lambda { class ClassSpecs::MetaclassSuper < meta; end }.should raise_error(TypeError)
end
it "allows the declaration of class variables in the body" do
@@ -210,16 +212,16 @@ describe "A class definition" do
describe "within a block creates a new class in the lexical scope" do
it "for named classes at the toplevel" do
klass = Class.new do
- class CS_CONST_CLASS_SPECS
+ class Howdy
end
def self.get_class_name
- CS_CONST_CLASS_SPECS.name
+ Howdy.name
end
end
- klass.get_class_name.should == 'CS_CONST_CLASS_SPECS'
- ::CS_CONST_CLASS_SPECS.name.should == 'CS_CONST_CLASS_SPECS'
+ Howdy.name.should == 'Howdy'
+ klass.get_class_name.should == 'Howdy'
end
it "for named classes in a module" do
@@ -274,7 +276,7 @@ describe "A class definition extending an object (sclass)" do
end
it "raises a TypeError when trying to extend numbers" do
- -> {
+ lambda {
eval <<-CODE
class << 1
def xyz
@@ -285,12 +287,8 @@ describe "A class definition extending an object (sclass)" do
}.should raise_error(TypeError)
end
- ruby_version_is ""..."3.0" do
- it "allows accessing the block of the original scope" do
- suppress_warning do
- ClassSpecs.sclass_with_block { 123 }.should == 123
- end
- end
+ it "allows accessing the block of the original scope" do
+ ClassSpecs.sclass_with_block { 123 }.should == 123
end
it "can use return to cause the enclosing method to return" do
@@ -310,11 +308,11 @@ describe "Reopening a class" do
end
it "raises a TypeError when superclasses mismatch" do
- -> { class ClassSpecs::A < Array; end }.should raise_error(TypeError)
+ lambda { class ClassSpecs::A < Array; end }.should raise_error(TypeError)
end
it "adds new methods to subclasses" do
- -> { ClassSpecs::M.m }.should raise_error(NoMethodError)
+ lambda { ClassSpecs::M.m }.should raise_error(NoMethodError)
class ClassSpecs::L
def self.m
1
diff --git a/spec/ruby/language/class_variable_spec.rb b/spec/ruby/language/class_variable_spec.rb
index dffab47a6b..463f731a93 100644
--- a/spec/ruby/language/class_variable_spec.rb
+++ b/spec/ruby/language/class_variable_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/class_variables'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class_variables', __FILE__)
describe "A class variable" do
after :each do
@@ -70,14 +70,14 @@ describe 'A class variable definition' do
c = Class.new(b)
b.class_variable_set(:@@cv, :value)
- -> { a.class_variable_get(:@@cv) }.should raise_error(NameError)
+ lambda { a.class_variable_get(:@@cv) }.should raise_error(NameError)
b.class_variable_get(:@@cv).should == :value
c.class_variable_get(:@@cv).should == :value
# updates the same variable
c.class_variable_set(:@@cv, :next)
- -> { a.class_variable_get(:@@cv) }.should raise_error(NameError)
+ lambda { a.class_variable_get(:@@cv) }.should raise_error(NameError)
b.class_variable_get(:@@cv).should == :next
c.class_variable_get(:@@cv).should == :next
end
diff --git a/spec/ruby/language/constants_spec.rb b/spec/ruby/language/constants_spec.rb
index c4cf940cba..1f1e254fb8 100644
--- a/spec/ruby/language/constants_spec.rb
+++ b/spec/ruby/language/constants_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/constants'
-require_relative 'fixtures/constants_sclass'
-require_relative 'fixtures/constant_visibility'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/constants', __FILE__)
+require File.expand_path('../fixtures/constants_sclass', __FILE__)
+require File.expand_path('../fixtures/constant_visibility', __FILE__)
# Read the documentation in fixtures/constants.rb for the guidelines and
# rationale for the structure and organization of these specs.
@@ -49,10 +49,10 @@ describe "Literal (A::X) constant resolution" do
end
it "does not search the singleton class of the class or module" do
- -> do
+ lambda do
ConstantSpecs::ContainerA::ChildA::CS_CONST14
end.should raise_error(NameError)
- -> { ConstantSpecs::CS_CONST14 }.should raise_error(NameError)
+ lambda { ConstantSpecs::CS_CONST14 }.should raise_error(NameError)
end
end
@@ -112,7 +112,7 @@ describe "Literal (A::X) constant resolution" do
CS_CONST108 = :const108_1
end
- -> do
+ lambda do
ConstantSpecs::ContainerB::ChildB::CS_CONST108
end.should raise_error(NameError)
@@ -122,7 +122,7 @@ describe "Literal (A::X) constant resolution" do
end
end
- -> { ConstantSpecs::CS_CONST108 }.should raise_error(NameError)
+ lambda { ConstantSpecs::CS_CONST108 }.should raise_error(NameError)
end
it "returns the updated value when a constant is reassigned" do
@@ -151,7 +151,7 @@ describe "Literal (A::X) constant resolution" do
end
it "raises a NameError if no constant is defined in the search path" do
- -> { ConstantSpecs::ParentA::CS_CONSTX }.should raise_error(NameError)
+ lambda { ConstantSpecs::ParentA::CS_CONSTX }.should raise_error(NameError)
end
it "sends #const_missing to the original class or module scope" do
@@ -163,10 +163,10 @@ describe "Literal (A::X) constant resolution" do
end
it "raises a TypeError if a non-class or non-module qualifier is given" do
- -> { CS_CONST1::CS_CONST }.should raise_error(TypeError)
- -> { 1::CS_CONST }.should raise_error(TypeError)
- -> { "mod"::CS_CONST }.should raise_error(TypeError)
- -> { false::CS_CONST }.should raise_error(TypeError)
+ lambda { CS_CONST1::CS_CONST }.should raise_error(TypeError)
+ lambda { 1::CS_CONST }.should raise_error(TypeError)
+ lambda { "mod"::CS_CONST }.should raise_error(TypeError)
+ lambda { false::CS_CONST }.should raise_error(TypeError)
end
end
@@ -212,7 +212,7 @@ describe "Constant resolution within methods" do
end
it "does not search the lexical scope of the caller" do
- -> { ConstantSpecs::ClassA.const16 }.should raise_error(NameError)
+ lambda { ConstantSpecs::ClassA.const16 }.should raise_error(NameError)
end
it "searches the lexical scope of a block" do
@@ -225,7 +225,7 @@ describe "Constant resolution within methods" do
end
it "does not search the lexical scope of qualifying modules" do
- -> do
+ lambda do
ConstantSpecs::ContainerA::ChildA.const23
end.should raise_error(NameError)
end
@@ -302,7 +302,7 @@ describe "Constant resolution within methods" do
it "does not search the lexical scope of the caller" do
ConstantSpecs::ClassB::CS_CONST209 = :const209
- -> { ConstantSpecs::ClassB.const209 }.should raise_error(NameError)
+ lambda { ConstantSpecs::ClassB.const209 }.should raise_error(NameError)
end
it "searches the lexical scope of a block" do
@@ -337,14 +337,14 @@ describe "Constant resolution within methods" do
it "does not search the lexical scope of qualifying modules" do
ConstantSpecs::ContainerB::CS_CONST214 = :const214
- -> do
+ lambda do
ConstantSpecs::ContainerB::ChildB.const214
end.should raise_error(NameError)
end
end
it "raises a NameError if no constant is defined in the search path" do
- -> { ConstantSpecs::ParentA.constx }.should raise_error(NameError)
+ lambda { ConstantSpecs::ParentA.constx }.should raise_error(NameError)
end
it "sends #const_missing to the original class or module scope" do
@@ -404,22 +404,24 @@ describe "Constant resolution within a singleton class (class << obj)" do
ConstantSpecs::CS_SINGLETON1.foo.should == 1
end
- it "uses its own namespace for each object" do
- a = ConstantSpecs::CS_SINGLETON2[0].foo
- b = ConstantSpecs::CS_SINGLETON2[1].foo
- [a, b].should == [1, 2]
- end
+ ruby_version_is "2.3" do
+ it "uses its own namespace for each object" do
+ a = ConstantSpecs::CS_SINGLETON2[0].foo
+ b = ConstantSpecs::CS_SINGLETON2[1].foo
+ [a, b].should == [1, 2]
+ end
- it "uses its own namespace for nested modules" do
- a = ConstantSpecs::CS_SINGLETON3[0].x
- b = ConstantSpecs::CS_SINGLETON3[1].x
- a.should_not equal(b)
- end
+ it "uses its own namespace for nested modules" do
+ a = ConstantSpecs::CS_SINGLETON3[0].x
+ b = ConstantSpecs::CS_SINGLETON3[1].x
+ a.should_not equal(b)
+ end
- it "allows nested modules to have proper resolution" do
- a = ConstantSpecs::CS_SINGLETON4_CLASSES[0].new
- b = ConstantSpecs::CS_SINGLETON4_CLASSES[1].new
- [a.foo, b.foo].should == [1, 2]
+ it "allows nested modules to have proper resolution" do
+ a = ConstantSpecs::CS_SINGLETON4_CLASSES[0].new
+ b = ConstantSpecs::CS_SINGLETON4_CLASSES[1].new
+ [a.foo, b.foo].should == [1, 2]
+ end
end
end
@@ -427,7 +429,7 @@ describe "top-level constant lookup" do
context "on a class" do
ruby_version_is "" ... "2.5" do
it "searches Object successfully after searching other scopes" do
- -> {
+ ->() {
String::Hash.should == Hash
}.should complain(/toplevel constant Hash referenced by/)
end
@@ -435,13 +437,13 @@ describe "top-level constant lookup" do
ruby_version_is "2.5" do
it "does not search Object after searching other scopes" do
- -> { String::Hash }.should raise_error(NameError)
+ ->() { String::Hash }.should raise_error(NameError)
end
end
end
it "searches Object unsuccessfully when searches on a module" do
- -> { Enumerable::Hash }.should raise_error(NameError)
+ ->() { Enumerable::Hash }.should raise_error(NameError)
end
end
@@ -455,37 +457,24 @@ describe "Module#private_constant marked constants" do
mod.const_set :Foo, false
}.should complain(/already initialized constant/)
- -> {mod::Foo}.should raise_error(NameError)
- end
-
- ruby_version_is "2.6" do
- it "sends #const_missing to the original class or module" do
- mod = Module.new
- mod.const_set :Foo, true
- mod.send :private_constant, :Foo
- def mod.const_missing(name)
- name == :Foo ? name : super
- end
-
- mod::Foo.should == :Foo
- end
+ lambda {mod::Foo}.should raise_error(NameError)
end
describe "in a module" do
it "cannot be accessed from outside the module" do
- -> do
+ lambda do
ConstantVisibility::PrivConstModule::PRIVATE_CONSTANT_MODULE
end.should raise_error(NameError)
end
it "cannot be reopened as a module from scope where constant would be private" do
- -> do
+ lambda do
module ConstantVisibility::ModuleContainer::PrivateModule; end
end.should raise_error(NameError)
end
it "cannot be reopened as a class from scope where constant would be private" do
- -> do
+ lambda do
class ConstantVisibility::ModuleContainer::PrivateClass; end
end.should raise_error(NameError)
end
@@ -541,19 +530,19 @@ describe "Module#private_constant marked constants" do
describe "in a class" do
it "cannot be accessed from outside the class" do
- -> do
+ lambda do
ConstantVisibility::PrivConstClass::PRIVATE_CONSTANT_CLASS
end.should raise_error(NameError)
end
it "cannot be reopened as a module" do
- -> do
+ lambda do
module ConstantVisibility::ClassContainer::PrivateModule; end
end.should raise_error(NameError)
end
it "cannot be reopened as a class" do
- -> do
+ lambda do
class ConstantVisibility::ClassContainer::PrivateClass; end
end.should raise_error(NameError)
end
@@ -609,7 +598,7 @@ describe "Module#private_constant marked constants" do
describe "in Object" do
it "cannot be accessed using ::Const form" do
- -> do
+ lambda do
::PRIVATE_CONSTANT_IN_OBJECT
end.should raise_error(NameError)
end
@@ -626,40 +615,6 @@ describe "Module#private_constant marked constants" do
defined?(PRIVATE_CONSTANT_IN_OBJECT).should == "constant"
end
end
-
- describe "NameError by #private_constant" do
- it "has :receiver and :name attributes" do
- -> do
- ConstantVisibility::PrivConstClass::PRIVATE_CONSTANT_CLASS
- end.should raise_error(NameError) {|e|
- e.receiver.should == ConstantVisibility::PrivConstClass
- e.name.should == :PRIVATE_CONSTANT_CLASS
- }
-
- -> do
- ConstantVisibility::PrivConstModule::PRIVATE_CONSTANT_MODULE
- end.should raise_error(NameError) {|e|
- e.receiver.should == ConstantVisibility::PrivConstModule
- e.name.should == :PRIVATE_CONSTANT_MODULE
- }
- end
-
- it "has the defined class as the :name attribute" do
- -> do
- ConstantVisibility::PrivConstClassChild::PRIVATE_CONSTANT_CLASS
- end.should raise_error(NameError) {|e|
- e.receiver.should == ConstantVisibility::PrivConstClass
- e.name.should == :PRIVATE_CONSTANT_CLASS
- }
-
- -> do
- ConstantVisibility::PrivConstModuleChild::PRIVATE_CONSTANT_MODULE
- end.should raise_error(NameError) {|e|
- e.receiver.should == ConstantVisibility::PrivConstModule
- e.name.should == :PRIVATE_CONSTANT_MODULE
- }
- end
- end
end
describe "Module#public_constant marked constants" do
@@ -711,35 +666,3 @@ describe "Module#public_constant marked constants" do
end
end
end
-
-describe 'Allowed characters' do
- it 'allows not ASCII characters in the middle of a name' do
- mod = Module.new
- mod.const_set("BBá¼BB", 1)
-
- eval("mod::BBá¼BB").should == 1
- end
-
- it 'does not allow not ASCII characters that cannot be upcased or lowercased at the beginning' do
- -> do
- Module.new.const_set("થBB", 1)
- end.should raise_error(NameError, /wrong constant name/)
- end
-
- ruby_version_is ""..."2.6" do
- it 'does not allow not ASCII upcased characters at the beginning' do
- -> do
- Module.new.const_set("á¼BB", 1)
- end.should raise_error(NameError, /wrong constant name/)
- end
- end
-
- ruby_version_is "2.6" do
- it 'allows not ASCII upcased characters at the beginning' do
- mod = Module.new
- mod.const_set("á¼BB", 1)
-
- eval("mod::á¼BB").should == 1
- end
- end
-end
diff --git a/spec/ruby/language/def_spec.rb b/spec/ruby/language/def_spec.rb
index fc5693a2f0..55ee283b90 100644
--- a/spec/ruby/language/def_spec.rb
+++ b/spec/ruby/language/def_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/def'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/def', __FILE__)
# Language-level method behaviour
describe "Redefining a method" do
@@ -79,18 +79,6 @@ describe "Defining a method" do
end
end
-describe "An instance method" do
- it "raises an error with too few arguments" do
- def foo(a, b); end
- -> { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2)')
- end
-
- it "raises an error with too many arguments" do
- def foo(a); end
- -> { foo 1, 2 }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)')
- end
-end
-
describe "An instance method definition with a splat" do
it "accepts an unnamed '*' argument" do
def foo(*); end;
@@ -113,12 +101,12 @@ describe "An instance method definition with a splat" do
end
it "allows only a single * argument" do
- -> { eval 'def foo(a, *b, *c); end' }.should raise_error(SyntaxError)
+ lambda { eval 'def foo(a, *b, *c); end' }.should raise_error(SyntaxError)
end
it "requires the presence of any arguments that precede the *" do
def foo(a, b, *c); end
- -> { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2+)')
+ lambda { foo 1 }.should raise_error(ArgumentError)
end
end
@@ -151,7 +139,7 @@ describe "An instance method with a default argument" do
def foo(a, b = 2)
[a,b]
end
- -> { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1..2)')
+ lambda { foo }.should raise_error(ArgumentError)
foo(1).should == [1, 2]
end
@@ -159,7 +147,7 @@ describe "An instance method with a default argument" do
def foo(a, b = 2, *c)
[a,b,c]
end
- -> { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1+)')
+ lambda { foo }.should raise_error(ArgumentError)
foo(1).should == [1,2,[]]
end
@@ -177,32 +165,17 @@ describe "An instance method with a default argument" do
foo(2,3,3).should == [2,3,[3]]
end
- ruby_version_is ''...'2.7' do
- it "warns and uses a nil value when there is an existing local method with same name" do
- def bar
- 1
- end
- -> {
- eval "def foo(bar = bar)
- bar
- end"
- }.should complain(/circular argument reference/)
- foo.should == nil
- foo(2).should == 2
- end
- end
-
- ruby_version_is '2.7' do
- it "raises a syntaxError an existing method with the same name as the local variable" do
- def bar
- 1
- end
- -> {
- eval "def foo(bar = bar)
- bar
- end"
- }.should raise_error(SyntaxError)
+ it "shadows an existing method with the same name as the local" do
+ def bar
+ 1
end
+ -> {
+ eval "def foo(bar = bar)
+ bar
+ end"
+ }.should complain(/circular argument reference/)
+ foo.should == nil
+ foo(2).should == 2
end
it "calls a method with the same name as the local when explicitly using ()" do
@@ -261,10 +234,10 @@ describe "A singleton method definition" do
(obj==2).should == 2
end
- it "raises #{frozen_error_class} if frozen" do
+ it "raises RuntimeError if frozen" do
obj = Object.new
obj.freeze
- -> { def obj.foo; end }.should raise_error(frozen_error_class)
+ lambda { def obj.foo; end }.should raise_error(RuntimeError)
end
end
@@ -337,7 +310,7 @@ describe "A method defined with extreme default arguments" do
end
it "may use a lambda as a default" do
- def foo(output = 'a', prc = -> n { output * n })
+ def foo(output = 'a', prc = lambda {|n| output * n})
prc.call(5)
end
foo.should == 'aaaaa'
@@ -383,7 +356,7 @@ describe "A singleton method defined with extreme default arguments" do
it "may use a lambda as a default" do
a = Object.new
- def a.foo(output = 'a', prc = -> n { output * n })
+ def a.foo(output = 'a', prc = lambda {|n| output * n})
prc.call(5)
end
a.foo.should == 'aaaaa'
@@ -399,7 +372,7 @@ describe "A method definition inside a metaclass scope" do
end
DefSpecSingleton.a_class_method.should == DefSpecSingleton
- -> { Object.a_class_method }.should raise_error(NoMethodError)
+ lambda { Object.a_class_method }.should raise_error(NoMethodError)
end
it "can create a singleton method" do
@@ -409,15 +382,15 @@ describe "A method definition inside a metaclass scope" do
end
obj.a_singleton_method.should == obj
- -> { Object.new.a_singleton_method }.should raise_error(NoMethodError)
+ lambda { Object.new.a_singleton_method }.should raise_error(NoMethodError)
end
- it "raises #{frozen_error_class} if frozen" do
+ it "raises RuntimeError if frozen" do
obj = Object.new
obj.freeze
class << obj
- -> { def foo; end }.should raise_error(frozen_error_class)
+ lambda { def foo; end }.should raise_error(RuntimeError)
end
end
end
@@ -453,11 +426,11 @@ describe "A nested method definition" do
end
end
- -> { DefSpecNested.a_class_method }.should raise_error(NoMethodError)
+ lambda { DefSpecNested.a_class_method }.should raise_error(NoMethodError)
DefSpecNested.create_class_method.should == DefSpecNested
DefSpecNested.a_class_method.should == DefSpecNested
- -> { Object.a_class_method }.should raise_error(NoMethodError)
- -> { DefSpecNested.new.a_class_method }.should raise_error(NoMethodError)
+ lambda { Object.a_class_method }.should raise_error(NoMethodError)
+ lambda { DefSpecNested.new.a_class_method }.should raise_error(NoMethodError)
end
it "creates a singleton method when evaluated in the metaclass of an instance" do
@@ -475,7 +448,7 @@ describe "A nested method definition" do
obj.a_singleton_method.should == obj
other = DefSpecNested.new
- -> { other.a_singleton_method }.should raise_error(NoMethodError)
+ lambda { other.a_singleton_method }.should raise_error(NoMethodError)
end
it "creates a method in the surrounding context when evaluated in a def expr.method" do
@@ -515,7 +488,7 @@ describe "A nested method definition" do
DefSpecNested.should_not have_instance_method :body_method
end
- it "creates an instance method inside Class.new" do
+ it "defines methods as public by default" do
cls = Class.new do
def do_def
def new_def
@@ -527,41 +500,6 @@ describe "A nested method definition" do
obj = cls.new
obj.do_def
obj.new_def.should == 1
-
- cls.new.new_def.should == 1
-
- -> { Object.new.new_def }.should raise_error(NoMethodError)
- end
-end
-
-describe "A method definition always resets the visibility to public for nested definitions" do
- it "in Class.new" do
- cls = Class.new do
- private
- def do_def
- def new_def
- 1
- end
- end
- end
-
- obj = cls.new
- -> { obj.do_def }.should raise_error(NoMethodError, /private/)
- obj.send :do_def
- obj.new_def.should == 1
-
- cls.new.new_def.should == 1
-
- -> { Object.new.new_def }.should raise_error(NoMethodError)
- end
-
- it "at the toplevel" do
- obj = Object.new
- -> { obj.toplevel_define_other_method }.should raise_error(NoMethodError, /private/)
- toplevel_define_other_method
- nested_method_in_toplevel_method.should == 42
-
- Object.new.nested_method_in_toplevel_method.should == 42
end
end
@@ -574,7 +512,7 @@ describe "A method definition inside an instance_eval" do
obj.an_instance_eval_method.should == obj
other = Object.new
- -> { other.an_instance_eval_method }.should raise_error(NoMethodError)
+ lambda { other.an_instance_eval_method }.should raise_error(NoMethodError)
end
it "creates a singleton method when evaluated inside a metaclass" do
@@ -587,7 +525,7 @@ describe "A method definition inside an instance_eval" do
obj.a_metaclass_eval_method.should == obj
other = Object.new
- -> { other.a_metaclass_eval_method }.should raise_error(NoMethodError)
+ lambda { other.a_metaclass_eval_method }.should raise_error(NoMethodError)
end
it "creates a class method when the receiver is a class" do
@@ -596,7 +534,7 @@ describe "A method definition inside an instance_eval" do
end
DefSpecNested.an_instance_eval_class_method.should == DefSpecNested
- -> { Object.an_instance_eval_class_method }.should raise_error(NoMethodError)
+ lambda { Object.an_instance_eval_class_method }.should raise_error(NoMethodError)
end
it "creates a class method when the receiver is an anonymous class" do
@@ -608,7 +546,7 @@ describe "A method definition inside an instance_eval" do
end
m.klass_method.should == :test
- -> { Object.klass_method }.should raise_error(NoMethodError)
+ lambda { Object.klass_method }.should raise_error(NoMethodError)
end
it "creates a class method when instance_eval is within class" do
@@ -621,7 +559,7 @@ describe "A method definition inside an instance_eval" do
end
m.klass_method.should == :test
- -> { Object.klass_method }.should raise_error(NoMethodError)
+ lambda { Object.klass_method }.should raise_error(NoMethodError)
end
end
@@ -634,7 +572,7 @@ describe "A method definition inside an instance_exec" do
end
DefSpecNested.an_instance_exec_class_method.should == 1
- -> { Object.an_instance_exec_class_method }.should raise_error(NoMethodError)
+ lambda { Object.an_instance_exec_class_method }.should raise_error(NoMethodError)
end
it "creates a class method when the receiver is an anonymous class" do
@@ -648,7 +586,7 @@ describe "A method definition inside an instance_exec" do
end
m.klass_method.should == 1
- -> { Object.klass_method }.should raise_error(NoMethodError)
+ lambda { Object.klass_method }.should raise_error(NoMethodError)
end
it "creates a class method when instance_exec is within class" do
@@ -663,7 +601,7 @@ describe "A method definition inside an instance_exec" do
end
m.klass_method.should == 2
- -> { Object.klass_method }.should raise_error(NoMethodError)
+ lambda { Object.klass_method }.should raise_error(NoMethodError)
end
end
@@ -683,7 +621,7 @@ describe "A method definition in an eval" do
other = DefSpecNested.new
other.an_eval_instance_method.should == other
- -> { Object.new.an_eval_instance_method }.should raise_error(NoMethodError)
+ lambda { Object.new.an_eval_instance_method }.should raise_error(NoMethodError)
end
it "creates a class method" do
@@ -699,8 +637,8 @@ describe "A method definition in an eval" do
DefSpecNestedB.eval_class_method.should == DefSpecNestedB
DefSpecNestedB.an_eval_class_method.should == DefSpecNestedB
- -> { Object.an_eval_class_method }.should raise_error(NoMethodError)
- -> { DefSpecNestedB.new.an_eval_class_method}.should raise_error(NoMethodError)
+ lambda { Object.an_eval_class_method }.should raise_error(NoMethodError)
+ lambda { DefSpecNestedB.new.an_eval_class_method}.should raise_error(NoMethodError)
end
it "creates a singleton method" do
@@ -718,7 +656,7 @@ describe "A method definition in an eval" do
obj.an_eval_singleton_method.should == obj
other = DefSpecNested.new
- -> { other.an_eval_singleton_method }.should raise_error(NoMethodError)
+ lambda { other.an_eval_singleton_method }.should raise_error(NoMethodError)
end
end
@@ -744,7 +682,7 @@ describe "a method definition that sets more than one default parameter all to t
end
it "only allows overriding the default value of the first such parameter in each set" do
- -> { foo(1,2) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 0..1)')
+ lambda { foo(1,2) }.should raise_error(ArgumentError)
end
def bar(a=b=c=1,d=2)
@@ -755,7 +693,7 @@ describe "a method definition that sets more than one default parameter all to t
bar.should == [1,1,1,2]
bar(3).should == [3,nil,nil,2]
bar(3,4).should == [3,nil,nil,4]
- -> { bar(3,4,5) }.should raise_error(ArgumentError, 'wrong number of arguments (given 3, expected 0..2)')
+ lambda { bar(3,4,5) }.should raise_error(ArgumentError)
end
end
@@ -765,7 +703,7 @@ describe "The def keyword" do
module DefSpecsLambdaVisibility
private
- -> {
+ lambda {
def some_method; end
}.call
end
diff --git a/spec/ruby/language/defined_spec.rb b/spec/ruby/language/defined_spec.rb
index 02c69d27b8..9fe460a9de 100644
--- a/spec/ruby/language/defined_spec.rb
+++ b/spec/ruby/language/defined_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/defined'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/defined', __FILE__)
describe "The defined? keyword for literals" do
it "returns 'self' for self" do
@@ -30,12 +30,12 @@ describe "The defined? keyword for literals" do
end
it "returns nil if one element is not defined" do
- ret = defined?([NonExistentConstant, Array])
+ ret = defined?([NonExistantConstant, Array])
ret.should == nil
end
it "returns nil if all elements are not defined" do
- ret = defined?([NonExistentConstant, AnotherNonExistentConstant])
+ ret = defined?([NonExistantConstant, AnotherNonExistantConstant])
ret.should == nil
end
@@ -505,10 +505,6 @@ describe "The defined? keyword for variables" do
DefinedSpecs::Basic.new.global_variable_read.should be_nil
end
- it "returns 'global-variable' for a global variable that has been assigned nil" do
- DefinedSpecs::Basic.new.global_variable_defined_as_nil.should == "global-variable"
- end
-
# MRI appears to special case defined? for $! and $~ in that it returns
# 'global-variable' even when they are not set (or they are always "set"
# but the value may be nil). In other words, 'defined?($~)' will return
@@ -547,12 +543,16 @@ describe "The defined? keyword for variables" do
defined?($+).should be_nil
end
- it "returns nil for any last match global" do
+ it "returns nil for $1-$9" do
defined?($1).should be_nil
+ defined?($2).should be_nil
+ defined?($3).should be_nil
defined?($4).should be_nil
+ defined?($5).should be_nil
+ defined?($6).should be_nil
defined?($7).should be_nil
- defined?($10).should be_nil
- defined?($200).should be_nil
+ defined?($8).should be_nil
+ defined?($9).should be_nil
end
end
@@ -587,10 +587,13 @@ describe "The defined? keyword for variables" do
end
it "returns nil for non-captures" do
+ defined?($3).should be_nil
defined?($4).should be_nil
+ defined?($5).should be_nil
+ defined?($6).should be_nil
defined?($7).should be_nil
- defined?($10).should be_nil
- defined?($200).should be_nil
+ defined?($8).should be_nil
+ defined?($9).should be_nil
end
end
@@ -619,12 +622,16 @@ describe "The defined? keyword for variables" do
defined?($+).should be_nil
end
- it "returns nil for any last match global" do
+ it "returns nil for $1-$9" do
defined?($1).should be_nil
+ defined?($2).should be_nil
+ defined?($3).should be_nil
defined?($4).should be_nil
+ defined?($5).should be_nil
+ defined?($6).should be_nil
defined?($7).should be_nil
- defined?($10).should be_nil
- defined?($200).should be_nil
+ defined?($8).should be_nil
+ defined?($9).should be_nil
end
end
@@ -659,10 +666,13 @@ describe "The defined? keyword for variables" do
end
it "returns nil for non-captures" do
+ defined?($3).should be_nil
defined?($4).should be_nil
+ defined?($5).should be_nil
+ defined?($6).should be_nil
defined?($7).should be_nil
- defined?($10).should be_nil
- defined?($200).should be_nil
+ defined?($8).should be_nil
+ defined?($9).should be_nil
end
end
it "returns 'global-variable' for a global variable that has been assigned" do
diff --git a/spec/ruby/language/encoding_spec.rb b/spec/ruby/language/encoding_spec.rb
index 5430c9cb98..070fa52bba 100644
--- a/spec/ruby/language/encoding_spec.rb
+++ b/spec/ruby/language/encoding_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: us-ascii -*-
-require_relative '../spec_helper'
-require_relative 'fixtures/coding_us_ascii'
-require_relative 'fixtures/coding_utf_8'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/coding_us_ascii', __FILE__)
+require File.expand_path('../fixtures/coding_utf_8', __FILE__)
describe "The __ENCODING__ pseudo-variable" do
it "is an instance of Encoding" do
@@ -14,14 +14,14 @@ describe "The __ENCODING__ pseudo-variable" do
it "is the evaluated strings's one inside an eval" do
eval("__ENCODING__".force_encoding("US-ASCII")).should == Encoding::US_ASCII
- eval("__ENCODING__".force_encoding("BINARY")).should == Encoding::BINARY
+ eval("__ENCODING__".force_encoding("ASCII-8BIT")).should == Encoding::ASCII_8BIT
end
it "is the encoding specified by a magic comment inside an eval" do
- code = "# encoding: BINARY\n__ENCODING__".force_encoding("US-ASCII")
- eval(code).should == Encoding::BINARY
+ code = "# encoding: ASCII-8BIT\n__ENCODING__".force_encoding("US-ASCII")
+ eval(code).should == Encoding::ASCII_8BIT
- code = "# encoding: us-ascii\n__ENCODING__".force_encoding("BINARY")
+ code = "# encoding: us-ascii\n__ENCODING__".force_encoding("ASCII-8BIT")
eval(code).should == Encoding::US_ASCII
end
@@ -31,6 +31,6 @@ describe "The __ENCODING__ pseudo-variable" do
end
it "raises a SyntaxError if assigned to" do
- -> { eval("__ENCODING__ = 1") }.should raise_error(SyntaxError)
+ lambda { eval("__ENCODING__ = 1") }.should raise_error(SyntaxError)
end
end
diff --git a/spec/ruby/language/ensure_spec.rb b/spec/ruby/language/ensure_spec.rb
index a930bda36b..1d99dcf5f2 100644
--- a/spec/ruby/language/ensure_spec.rb
+++ b/spec/ruby/language/ensure_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/ensure'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/ensure', __FILE__)
describe "An ensure block inside a begin block" do
before :each do
@@ -7,7 +7,7 @@ describe "An ensure block inside a begin block" do
end
it "is executed when an exception is raised in it's corresponding begin block" do
- -> {
+ lambda {
begin
ScratchPad << :begin
raise EnsureSpec::Error
@@ -66,18 +66,6 @@ describe "An ensure block inside a begin block" do
:ensure
end.should == :begin
end
-
- it "sets exception cause if raises exception in block and in ensure" do
- -> {
- begin
- raise "from block"
- ensure
- raise "from ensure"
- end
- }.should raise_error(RuntimeError, "from ensure") do |e|
- e.cause.message.should == "from block"
- end
- end
end
describe "The value of an ensure expression," do
@@ -108,7 +96,7 @@ describe "An ensure block inside a method" do
end
it "is executed when an exception is raised in the method" do
- -> { @obj.raise_in_method_with_ensure }.should raise_error(EnsureSpec::Error)
+ lambda { @obj.raise_in_method_with_ensure }.should raise_error(EnsureSpec::Error)
@obj.executed.should == [:method, :ensure]
end
@@ -129,34 +117,6 @@ describe "An ensure block inside a method" do
it "has an impact on the method's explicit return value" do
@obj.explicit_return_in_method_with_ensure.should == :ensure
end
-
- it "has an impact on the method's explicit return value from rescue if returns explicitly" do
- @obj.explicit_return_in_rescue_and_explicit_return_in_ensure.should == "returned in ensure"
- end
-
- it "has no impact on the method's explicit return value from rescue if returns implicitly" do
- @obj.explicit_return_in_rescue_and_implicit_return_in_ensure.should == "returned in rescue"
- end
-
- it "suppresses exception raised in method if returns value explicitly" do
- @obj.raise_and_explicit_return_in_ensure.should == "returned in ensure"
- end
-
- it "suppresses exception raised in rescue if returns value explicitly" do
- @obj.raise_in_rescue_and_explicit_return_in_ensure.should == "returned in ensure"
- end
-
- it "overrides exception raised in rescue if raises exception itself" do
- -> {
- @obj.raise_in_rescue_and_raise_in_ensure
- }.should raise_error(RuntimeError, "raised in ensure")
- end
-
- it "suppresses exception raised in method if raises exception itself" do
- -> {
- @obj.raise_in_method_and_raise_in_ensure
- }.should raise_error(RuntimeError, "raised in ensure")
- end
end
describe "An ensure block inside a class" do
@@ -165,7 +125,7 @@ describe "An ensure block inside a class" do
end
it "is executed when an exception is raised" do
- -> {
+ lambda {
eval <<-ruby
class EnsureInClassExample
ScratchPad << :class
@@ -240,7 +200,7 @@ end
describe "An ensure block inside {} block" do
it "is not allowed" do
- -> {
+ lambda {
eval <<-ruby
lambda {
raise
@@ -258,7 +218,7 @@ ruby_version_is "2.5" do
end
it "is executed when an exception is raised in it's corresponding begin block" do
- -> {
+ lambda {
eval(<<-ruby).call
lambda do
ScratchPad << :begin
diff --git a/spec/ruby/language/execution_spec.rb b/spec/ruby/language/execution_spec.rb
index 4e0310946d..3e6e7ff48c 100644
--- a/spec/ruby/language/execution_spec.rb
+++ b/spec/ruby/language/execution_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "``" do
it "returns the output of the executed sub-process" do
diff --git a/spec/ruby/language/file_spec.rb b/spec/ruby/language/file_spec.rb
index 729dee1008..409400ca83 100644
--- a/spec/ruby/language/file_spec.rb
+++ b/spec/ruby/language/file_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/code_loading'
-require_relative 'shared/__FILE__'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/code_loading', __FILE__)
+require File.expand_path('../shared/__FILE__', __FILE__)
describe "The __FILE__ pseudo-variable" do
it "raises a SyntaxError if assigned to" do
- -> { eval("__FILE__ = 1") }.should raise_error(SyntaxError)
+ lambda { eval("__FILE__ = 1") }.should raise_error(SyntaxError)
end
it "equals (eval) inside an eval" do
diff --git a/spec/ruby/language/fixtures/array.rb b/spec/ruby/language/fixtures/array.rb
index c1036575ff..4d8ce74ed6 100644
--- a/spec/ruby/language/fixtures/array.rb
+++ b/spec/ruby/language/fixtures/array.rb
@@ -8,25 +8,4 @@ module ArraySpec
[a, b, c, d]
end
end
-
- class SideEffect
- def initialize()
- @call_count = 0
- end
-
- attr_reader :call_count
-
- def array_result(a_number)
- [result(a_number), result(a_number)]
- end
-
- def result(a_number)
- @call_count += 1
- if a_number
- 1
- else
- :thing
- end
- end
- end
end
diff --git a/spec/ruby/language/fixtures/block.rb b/spec/ruby/language/fixtures/block.rb
index 33baac6aeb..9848d18776 100644
--- a/spec/ruby/language/fixtures/block.rb
+++ b/spec/ruby/language/fixtures/block.rb
@@ -15,10 +15,6 @@ module BlockSpecs
def r(a)
yield(*a)
end
-
- def k(*a)
- yield(*a, b: true)
- end
end
# TODO: rewrite all specs that use Yield to use Yielder
diff --git a/spec/ruby/language/fixtures/break.rb b/spec/ruby/language/fixtures/break.rb
index 217c20a2c0..2d07cc3d48 100644
--- a/spec/ruby/language/fixtures/break.rb
+++ b/spec/ruby/language/fixtures/break.rb
@@ -163,7 +163,7 @@ module BreakSpecs
# on the call stack when the lambda is invoked.
def break_in_defining_scope(value=true)
note :a
- note -> {
+ note lambda {
note :b
if value
break :break
@@ -177,7 +177,7 @@ module BreakSpecs
def break_in_nested_scope
note :a
- l = -> do
+ l = lambda do
note :b
break :break
note :c
@@ -197,7 +197,7 @@ module BreakSpecs
def break_in_nested_scope_yield
note :a
- l = -> do
+ l = lambda do
note :b
break :break
note :c
@@ -217,7 +217,7 @@ module BreakSpecs
def break_in_nested_scope_block
note :a
- l = -> do
+ l = lambda do
note :b
break :break
note :c
@@ -251,7 +251,7 @@ module BreakSpecs
# active on the call stack when the lambda is invoked.
def create_lambda
note :la
- l = -> do
+ l = lambda do
note :lb
break :break
note :lc
diff --git a/spec/ruby/language/fixtures/break_lambda_toplevel.rb b/spec/ruby/language/fixtures/break_lambda_toplevel.rb
index da5abbaf00..05af1d3fdc 100644
--- a/spec/ruby/language/fixtures/break_lambda_toplevel.rb
+++ b/spec/ruby/language/fixtures/break_lambda_toplevel.rb
@@ -1,6 +1,6 @@
print "a,"
-print -> {
+print lambda {
print "b,"
break "break,"
print "c,"
diff --git a/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb b/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb
index 3dcee62424..a35cb8a8a1 100644
--- a/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb
+++ b/spec/ruby/language/fixtures/break_lambda_toplevel_block.rb
@@ -1,6 +1,6 @@
print "a,"
-l = -> {
+l = lambda {
print "b,"
break "break,"
print "c,"
diff --git a/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb b/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb
index a5936a3d70..200040d614 100644
--- a/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb
+++ b/spec/ruby/language/fixtures/break_lambda_toplevel_method.rb
@@ -1,6 +1,6 @@
print "a,"
-l = -> {
+l = lambda {
print "b,"
break "break,"
print "c,"
diff --git a/spec/ruby/language/fixtures/bytes_magic_comment.rb b/spec/ruby/language/fixtures/bytes_magic_comment.rb
deleted file mode 100644
index 2bc2bcfb07..0000000000
--- a/spec/ruby/language/fixtures/bytes_magic_comment.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# encoding: big5
-$magic_comment_result = '§A¦n'.bytes.inspect
diff --git a/spec/ruby/language/fixtures/case_magic_comment.rb b/spec/ruby/language/fixtures/case_magic_comment.rb
deleted file mode 100644
index 96f35a7c94..0000000000
--- a/spec/ruby/language/fixtures/case_magic_comment.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# CoDiNg: bIg5
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/def.rb b/spec/ruby/language/fixtures/def.rb
index e07060ed74..81bfce73d0 100644
--- a/spec/ruby/language/fixtures/def.rb
+++ b/spec/ruby/language/fixtures/def.rb
@@ -1,9 +1,3 @@
-def toplevel_define_other_method
- def nested_method_in_toplevel_method
- 42
- end
-end
-
def some_toplevel_method
end
diff --git a/spec/ruby/language/fixtures/defined.rb b/spec/ruby/language/fixtures/defined.rb
index 8b6004c19f..d26e553c4b 100644
--- a/spec/ruby/language/fixtures/defined.rb
+++ b/spec/ruby/language/fixtures/defined.rb
@@ -94,11 +94,6 @@ module DefinedSpecs
defined? $defined_specs_global_variable_defined
end
- def global_variable_defined_as_nil
- $defined_specs_global_variable_defined_as_nil = nil
- defined? $defined_specs_global_variable_defined_as_nil
- end
-
def class_variable_undefined
defined? @@class_variable_undefined
end
diff --git a/spec/ruby/language/fixtures/emacs_magic_comment.rb b/spec/ruby/language/fixtures/emacs_magic_comment.rb
deleted file mode 100644
index 2b09f3e74c..0000000000
--- a/spec/ruby/language/fixtures/emacs_magic_comment.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# -*- encoding: big5 -*-
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/ensure.rb b/spec/ruby/language/fixtures/ensure.rb
index 6047ac5bc0..d1a9da37b8 100644
--- a/spec/ruby/language/fixtures/ensure.rb
+++ b/spec/ruby/language/fixtures/ensure.rb
@@ -40,50 +40,6 @@ module EnsureSpec
ensure
return :ensure
end
-
- def explicit_return_in_rescue_and_explicit_return_in_ensure
- raise
- rescue
- return 2
- ensure
- return "returned in ensure"
- end
-
- def explicit_return_in_rescue_and_implicit_return_in_ensure
- raise
- rescue
- return "returned in rescue"
- ensure
- 3
- end
-
- def raise_and_explicit_return_in_ensure
- raise
- ensure
- return "returned in ensure"
- end
-
- def raise_in_rescue_and_explicit_return_in_ensure
- raise
- rescue
- raise
- ensure
- return "returned in ensure"
- end
-
- def raise_in_rescue_and_raise_in_ensure
- raise
- rescue
- raise "raised in rescue"
- ensure
- raise "raised in ensure"
- end
-
- def raise_in_method_and_raise_in_ensure
- raise
- ensure
- raise "raised in ensure"
- end
end
end
diff --git a/spec/ruby/language/fixtures/for_scope.rb b/spec/ruby/language/fixtures/for_scope.rb
deleted file mode 100644
index 9c44a23a2c..0000000000
--- a/spec/ruby/language/fixtures/for_scope.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module ForSpecs
- class ForInClassMethod
- m = :same_variable_set_outside
-
- def self.foo
- all = []
- for m in [:bar, :baz]
- all << m
- end
- all
- end
-
- READER = -> { m }
- end
-end
diff --git a/spec/ruby/language/fixtures/hash_strings_ascii8bit.rb b/spec/ruby/language/fixtures/hash_strings_ascii8bit.rb
new file mode 100644
index 0000000000..4ac11b9930
--- /dev/null
+++ b/spec/ruby/language/fixtures/hash_strings_ascii8bit.rb
@@ -0,0 +1,7 @@
+# encoding: ascii-8bit
+
+module HashStringsASCII8BIT
+ def self.literal_hash
+ {"foo" => "bar"}
+ end
+end
diff --git a/spec/ruby/language/fixtures/hash_strings_binary.rb b/spec/ruby/language/fixtures/hash_strings_binary.rb
deleted file mode 100644
index 44b99cbf80..0000000000
--- a/spec/ruby/language/fixtures/hash_strings_binary.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# encoding: binary
-
-module HashStringsBinary
- def self.literal_hash
- {"foo" => "bar"}
- end
-end
diff --git a/spec/ruby/language/fixtures/magic_comment.rb b/spec/ruby/language/fixtures/magic_comment.rb
deleted file mode 100644
index 120ef6ff4a..0000000000
--- a/spec/ruby/language/fixtures/magic_comment.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# encoding: big5
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/metaclass.rb b/spec/ruby/language/fixtures/metaclass.rb
index a8f837e701..a1990b9225 100644
--- a/spec/ruby/language/fixtures/metaclass.rb
+++ b/spec/ruby/language/fixtures/metaclass.rb
@@ -31,3 +31,4 @@ module MetaClassSpecs
class D < C; end
end
+
diff --git a/spec/ruby/language/fixtures/no_magic_comment.rb b/spec/ruby/language/fixtures/no_magic_comment.rb
deleted file mode 100644
index 743a0f9503..0000000000
--- a/spec/ruby/language/fixtures/no_magic_comment.rb
+++ /dev/null
@@ -1 +0,0 @@
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/print_magic_comment_result_at_exit.rb b/spec/ruby/language/fixtures/print_magic_comment_result_at_exit.rb
deleted file mode 100644
index aa82cf4471..0000000000
--- a/spec/ruby/language/fixtures/print_magic_comment_result_at_exit.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-at_exit {
- print $magic_comment_result
-}
diff --git a/spec/ruby/language/fixtures/rescue.rb b/spec/ruby/language/fixtures/rescue.rb
index b906e17a2f..3fa5df1eb5 100644
--- a/spec/ruby/language/fixtures/rescue.rb
+++ b/spec/ruby/language/fixtures/rescue.rb
@@ -60,8 +60,4 @@ module RescueSpecs
ScratchPad << :outside_begin
:return_val
end
-
- def self.raise_standard_error
- raise StandardError, "an error occurred"
- end
end
diff --git a/spec/ruby/language/fixtures/second_line_magic_comment.rb b/spec/ruby/language/fixtures/second_line_magic_comment.rb
deleted file mode 100644
index a3dd50393b..0000000000
--- a/spec/ruby/language/fixtures/second_line_magic_comment.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-
-# encoding: big5
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/second_token_magic_comment.rb b/spec/ruby/language/fixtures/second_token_magic_comment.rb
deleted file mode 100644
index 8d443e68f3..0000000000
--- a/spec/ruby/language/fixtures/second_token_magic_comment.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-1 + 1 # encoding: big5
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/send.rb b/spec/ruby/language/fixtures/send.rb
index 918241e171..c3013616b2 100644
--- a/spec/ruby/language/fixtures/send.rb
+++ b/spec/ruby/language/fixtures/send.rb
@@ -53,9 +53,8 @@ module LangSendSpecs
end
class PrivateGetter
- attr_accessor :foo
+ attr_reader :foo
private :foo
- private :foo=
def call_self_foo
self.foo
diff --git a/spec/ruby/language/fixtures/shebang_magic_comment.rb b/spec/ruby/language/fixtures/shebang_magic_comment.rb
deleted file mode 100755
index f8e5e7d8e4..0000000000
--- a/spec/ruby/language/fixtures/shebang_magic_comment.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/ruby
-# encoding: big5
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/super.rb b/spec/ruby/language/fixtures/super.rb
index 6a024cae23..09a454bdf4 100644
--- a/spec/ruby/language/fixtures/super.rb
+++ b/spec/ruby/language/fixtures/super.rb
@@ -1,4 +1,4 @@
-module SuperSpecs
+module Super
module S1
class A
def foo(a)
@@ -282,7 +282,7 @@ module SuperSpecs
#
# When name3 is called then, Alias2 (NOT Alias3) is presented as the
# current module to Alias2#name, so that when super is called,
- # Alias2's superclass is next.
+ # Alias2->superclass is next.
#
# Otherwise, Alias2 is next, which is where name was to begin with,
# causing the wrong #name method to be called.
@@ -377,12 +377,12 @@ module SuperSpecs
end
def b
- block_ref = -> { 15 }
+ block_ref = lambda { 15 }
[super { 14 }, super(&block_ref)]
end
def c
- block_ref = -> { 16 }
+ block_ref = lambda { 16 }
super(&block_ref)
end
end
@@ -455,38 +455,6 @@ module SuperSpecs
end
end
- module ZSuperWithRestReassigned
- class A
- def a(*args)
- args
- end
- end
-
- class B < A
- def a(*args)
- args = ["foo"]
-
- super
- end
- end
- end
-
- module ZSuperWithRestReassignedWithScalar
- class A
- def a(*args)
- args
- end
- end
-
- class B < A
- def a(*args)
- args = "foo"
-
- super
- end
- end
- end
-
module ZSuperWithUnderscores
class A
def m(*args)
diff --git a/spec/ruby/language/fixtures/utf16-be-nobom.rb b/spec/ruby/language/fixtures/utf16-be-nobom.rb
deleted file mode 100644
index 99e2ce8ce8..0000000000
--- a/spec/ruby/language/fixtures/utf16-be-nobom.rb
+++ /dev/null
Binary files differ
diff --git a/spec/ruby/language/fixtures/utf16-le-nobom.rb b/spec/ruby/language/fixtures/utf16-le-nobom.rb
deleted file mode 100644
index 98de9697ca..0000000000
--- a/spec/ruby/language/fixtures/utf16-le-nobom.rb
+++ /dev/null
Binary files differ
diff --git a/spec/ruby/language/fixtures/utf8-bom.rb b/spec/ruby/language/fixtures/utf8-bom.rb
deleted file mode 100644
index 50c223a922..0000000000
--- a/spec/ruby/language/fixtures/utf8-bom.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# encoding: utf-8
-puts 'hello'
diff --git a/spec/ruby/language/fixtures/utf8-nobom.rb b/spec/ruby/language/fixtures/utf8-nobom.rb
deleted file mode 100644
index 75f5563b95..0000000000
--- a/spec/ruby/language/fixtures/utf8-nobom.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# encoding: utf-8
-puts 'hello'
diff --git a/spec/ruby/language/fixtures/vim_magic_comment.rb b/spec/ruby/language/fixtures/vim_magic_comment.rb
deleted file mode 100644
index 60cbe7a3bf..0000000000
--- a/spec/ruby/language/fixtures/vim_magic_comment.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# vim: filetype=ruby, fileencoding=big5, tabsize=3, shiftwidth=3
-$magic_comment_result = __ENCODING__.name
diff --git a/spec/ruby/language/fixtures/yield.rb b/spec/ruby/language/fixtures/yield.rb
index 9f7a2ba238..a195616640 100644
--- a/spec/ruby/language/fixtures/yield.rb
+++ b/spec/ruby/language/fixtures/yield.rb
@@ -21,10 +21,6 @@ module YieldSpecs
yield(*a)
end
- def k(a)
- yield(*a, b: true)
- end
-
def rs(a, b, c)
yield(a, b, *c)
end
diff --git a/spec/ruby/language/for_spec.rb b/spec/ruby/language/for_spec.rb
index 0ad5ea88af..c9d043fa25 100644
--- a/spec/ruby/language/for_spec.rb
+++ b/spec/ruby/language/for_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/for_scope'
+require File.expand_path('../../spec_helper', __FILE__)
# for name[, name]... in expr [do]
# body
@@ -33,13 +32,14 @@ describe "The for expression" do
end
it "iterates over any object responding to 'each'" do
- obj = Object.new
- def obj.each
- (0..10).each { |i| yield i }
+ class XYZ
+ def each
+ (0..10).each { |i| yield i }
+ end
end
j = 0
- for i in obj
+ for i in XYZ.new
j += i
end
j.should == 55
@@ -131,11 +131,6 @@ describe "The for expression" do
a.should == 123
end
- it "does not try to access variables outside the method" do
- ForSpecs::ForInClassMethod.foo.should == [:bar, :baz]
- ForSpecs::ForInClassMethod::READER.call.should == :same_variable_set_outside
- end
-
it "returns expr" do
for i in 1..3; end.should == (1..3)
for i,j in { 1 => 10, 2 => 20 }; end.should == { 1 => 10, 2 => 20 }
diff --git a/spec/ruby/language/hash_spec.rb b/spec/ruby/language/hash_spec.rb
index 6f2e8e5cf0..edd9d4fbb2 100644
--- a/spec/ruby/language/hash_spec.rb
+++ b/spec/ruby/language/hash_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/hash_strings_binary'
-require_relative 'fixtures/hash_strings_utf8'
-require_relative 'fixtures/hash_strings_usascii'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/hash_strings_ascii8bit', __FILE__)
+require File.expand_path('../fixtures/hash_strings_utf8', __FILE__)
+require File.expand_path('../fixtures/hash_strings_usascii', __FILE__)
describe "Hash literal" do
it "{} should return an empty hash" do
@@ -63,7 +63,7 @@ describe "Hash literal" do
end
it "with '==>' in the middle raises SyntaxError" do
- -> { eval("{:a ==> 1}") }.should raise_error(SyntaxError)
+ lambda { eval("{:a ==> 1}") }.should raise_error(SyntaxError)
end
it "constructs a new hash with the given elements" do
@@ -128,34 +128,25 @@ describe "Hash literal" do
{a: 1, **obj, c: 3}.should == {a:1, b: 2, c: 3, d: 4}
end
- ruby_version_is ""..."2.7" do
- it "raises a TypeError if any splatted elements keys are not symbols" do
- h = {1 => 2, b: 3}
- -> { {a: 1, **h} }.should raise_error(TypeError)
- end
- end
-
- ruby_version_is "2.7" do
- it "allows splatted elements keys that are not symbols" do
- h = {1 => 2, b: 3}
- {a: 1, **h}.should == {a: 1, 1 => 2, b: 3}
- end
+ it "raises a TypeError if any splatted elements keys are not symbols" do
+ h = {1 => 2, b: 3}
+ lambda { {a: 1, **h} }.should raise_error(TypeError)
end
it "raises a TypeError if #to_hash does not return a Hash" do
obj = mock("hash splat")
obj.should_receive(:to_hash).and_return(obj)
- -> { {**obj} }.should raise_error(TypeError)
+ lambda { {**obj} }.should raise_error(TypeError)
end
it "does not change encoding of literal string keys during creation" do
- binary_hash = HashStringsBinary.literal_hash
+ ascii8bit_hash = HashStringsASCII8BIT.literal_hash
utf8_hash = HashStringsUTF8.literal_hash
usascii_hash = HashStringsUSASCII.literal_hash
- binary_hash.keys.first.encoding.should == Encoding::BINARY
- binary_hash.keys.first.should == utf8_hash.keys.first
+ ascii8bit_hash.keys.first.encoding.should == Encoding::ASCII_8BIT
+ ascii8bit_hash.keys.first.should == utf8_hash.keys.first
utf8_hash.keys.first.encoding.should == Encoding::UTF_8
utf8_hash.keys.first.should == usascii_hash.keys.first
usascii_hash.keys.first.encoding.should == Encoding::US_ASCII
diff --git a/spec/ruby/language/heredoc_spec.rb b/spec/ruby/language/heredoc_spec.rb
index e7655a9216..a57a7b0bb9 100644
--- a/spec/ruby/language/heredoc_spec.rb
+++ b/spec/ruby/language/heredoc_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: us-ascii -*-
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "Heredoc string" do
@@ -13,7 +13,6 @@ describe "Heredoc string" do
foo bar#{@ip}
HERE
s.should == "foo barxxx\n"
- s.encoding.should == Encoding::US_ASCII
end
it 'allow HEREDOC with <<"identifier", interpolated' do
@@ -21,7 +20,6 @@ HERE
foo bar#{@ip}
HERE
s.should == "foo barxxx\n"
- s.encoding.should == Encoding::US_ASCII
end
it "allows HEREDOC with <<'identifier', no interpolation" do
@@ -29,7 +27,6 @@ HERE
foo bar#{@ip}
HERE
s.should == 'foo bar#{@ip}' + "\n"
- s.encoding.should == Encoding::US_ASCII
end
it "allows HEREDOC with <<-identifier, allowing to indent identifier, interpolated" do
@@ -38,7 +35,6 @@ HERE
HERE
s.should == " foo barxxx\n"
- s.encoding.should == Encoding::US_ASCII
end
it 'allows HEREDOC with <<-"identifier", allowing to indent identifier, interpolated' do
@@ -47,7 +43,6 @@ HERE
HERE
s.should == " foo barxxx\n"
- s.encoding.should == Encoding::US_ASCII
end
it "allows HEREDOC with <<-'identifier', allowing to indent identifier, no interpolation" do
@@ -56,36 +51,37 @@ HERE
HERE
s.should == ' foo bar#{@ip}' + "\n"
- s.encoding.should == Encoding::US_ASCII
end
- it "allows HEREDOC with <<~'identifier', allowing to indent identifier and content" do
- require_relative 'fixtures/squiggly_heredoc'
- SquigglyHeredocSpecs.message.should == "character density, n.:\n The number of very weird people in the office.\n"
- end
-
- it "trims trailing newline character for blank HEREDOC with <<~'identifier'" do
- require_relative 'fixtures/squiggly_heredoc'
- SquigglyHeredocSpecs.blank.should == ""
- end
-
- it 'allows HEREDOC with <<~identifier, interpolated' do
- require_relative 'fixtures/squiggly_heredoc'
- SquigglyHeredocSpecs.unquoted.should == "unquoted interpolated\n"
- end
-
- it 'allows HEREDOC with <<~"identifier", interpolated' do
- require_relative 'fixtures/squiggly_heredoc'
- SquigglyHeredocSpecs.doublequoted.should == "doublequoted interpolated\n"
- end
-
- it "allows HEREDOC with <<~'identifier', no interpolation" do
- require_relative 'fixtures/squiggly_heredoc'
- SquigglyHeredocSpecs.singlequoted.should == "singlequoted \#{\"interpolated\"}\n"
- end
-
- it "selects the least-indented line and removes its indentation from all the lines" do
- require_relative 'fixtures/squiggly_heredoc'
- SquigglyHeredocSpecs.least_indented_on_the_last_line.should == " a\n b\nc\n"
+ ruby_version_is "2.3" do
+ it "allows HEREDOC with <<~'identifier', allowing to indent identifier and content" do
+ require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
+ SquigglyHeredocSpecs.message.should == "character density, n.:\n The number of very weird people in the office.\n"
+ end
+
+ it "trims trailing newline character for blank HEREDOC with <<~'identifier'" do
+ require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
+ SquigglyHeredocSpecs.blank.should == ""
+ end
+
+ it 'allows HEREDOC with <<~identifier, interpolated' do
+ require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
+ SquigglyHeredocSpecs.unquoted.should == "unquoted interpolated\n"
+ end
+
+ it 'allows HEREDOC with <<~"identifier", interpolated' do
+ require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
+ SquigglyHeredocSpecs.doublequoted.should == "doublequoted interpolated\n"
+ end
+
+ it "allows HEREDOC with <<~'identifier', no interpolation" do
+ require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
+ SquigglyHeredocSpecs.singlequoted.should == "singlequoted \#{\"interpolated\"}\n"
+ end
+
+ it "selects the least-indented line and removes its indentation from all the lines" do
+ require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
+ SquigglyHeredocSpecs.least_indented_on_the_last_line.should == " a\n b\nc\n"
+ end
end
end
diff --git a/spec/ruby/language/if_spec.rb b/spec/ruby/language/if_spec.rb
index d1d95c1607..284d852462 100644
--- a/spec/ruby/language/if_spec.rb
+++ b/spec/ruby/language/if_spec.rb
@@ -1,20 +1,22 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The if expression" do
- describe "accepts multiple assignments in conditional expression" do
- before(:each) { ScratchPad.record([]) }
- after(:each) { ScratchPad.clear }
-
- it 'with non-nil values' do
- ary = [1, 2]
- eval "if (a, b = ary); ScratchPad.record [a, b]; end"
- ScratchPad.recorded.should == [1, 2]
- end
-
- it 'with nil values' do
- ary = nil
- eval "if (a, b = ary); else; ScratchPad.record [a, b]; end"
- ScratchPad.recorded.should == [nil, nil]
+ ruby_version_is '2.4' do
+ describe "accepts multiple assignments in conditional expression" do
+ before(:each) { ScratchPad.record([]) }
+ after(:each) { ScratchPad.clear }
+
+ it 'with non-nil values' do
+ ary = [1, 2]
+ eval "if (a, b = ary); ScratchPad.record [a, b]; end"
+ ScratchPad.recorded.should == [1, 2]
+ end
+
+ it 'with nil values' do
+ ary = nil
+ eval "if (a, b = ary); else; ScratchPad.record [a, b]; end"
+ ScratchPad.recorded.should == [nil, nil]
+ end
end
end
diff --git a/spec/ruby/language/lambda_spec.rb b/spec/ruby/language/lambda_spec.rb
index ddd0b574b3..43e2d60ae3 100644
--- a/spec/ruby/language/lambda_spec.rb
+++ b/spec/ruby/language/lambda_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "A lambda literal -> () { }" do
SpecEvaluate.desc = "for definition"
@@ -7,7 +7,7 @@ describe "A lambda literal -> () { }" do
it "returns a Proc object when used in a BasicObject method" do
klass = Class.new(BasicObject) do
def create_lambda
- -> { }
+ -> () { }
end
end
@@ -15,21 +15,11 @@ describe "A lambda literal -> () { }" do
end
it "does not execute the block" do
- -> { fail }.should be_an_instance_of(Proc)
+ ->() { fail }.should be_an_instance_of(Proc)
end
it "returns a lambda" do
- -> { }.lambda?.should be_true
- end
-
- ruby_version_is "2.6" do
- it "may include a rescue clause" do
- eval('-> do raise ArgumentError; rescue ArgumentError; 7; end').should be_an_instance_of(Proc)
- end
-
- it "may include a ensure clause" do
- eval('-> do 1; ensure; 2; end').should be_an_instance_of(Proc)
- end
+ -> () { }.lambda?.should be_true
end
it "has its own scope for local variables" do
@@ -111,7 +101,7 @@ describe "A lambda literal -> () { }" do
@a = -> (a:) { a }
ruby
- -> { @a.() }.should raise_error(ArgumentError)
+ lambda { @a.() }.should raise_error(ArgumentError)
@a.(a: 1).should == 1
end
@@ -129,7 +119,7 @@ describe "A lambda literal -> () { }" do
@a.().should be_nil
@a.(a: 1, b: 2).should be_nil
- -> { @a.(1) }.should raise_error(ArgumentError)
+ lambda { @a.(1) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -153,8 +143,8 @@ describe "A lambda literal -> () { }" do
ruby
@a.(1, 2).should == [1, 2]
- -> { @a.() }.should raise_error(ArgumentError)
- -> { @a.(1) }.should raise_error(ArgumentError)
+ lambda { @a.() }.should raise_error(ArgumentError)
+ lambda { @a.(1) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -186,11 +176,9 @@ describe "A lambda literal -> () { }" do
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
- suppress_keyword_warning do
- h = mock("keyword splat")
- h.should_receive(:to_hash).and_return({a: 1})
- @a.(h).should == {a: 1}
- end
+ h = mock("keyword splat")
+ h.should_receive(:to_hash).and_return({a: 1})
+ @a.(h).should == {a: 1}
end
evaluate <<-ruby do
@@ -267,43 +255,25 @@ describe "A lambda literal -> () { }" do
end
describe "with circular optional argument reference" do
- ruby_version_is ''...'2.7' do
- it "warns and uses a nil value when there is an existing local variable with same name" do
- a = 1
- -> {
- @proc = eval "-> (a=a) { a }"
- }.should complain(/circular argument reference/)
- @proc.call.should == nil
- end
-
- it "warns and uses a nil value when there is an existing method with same name" do
- def a; 1; end
- -> {
- @proc = eval "-> (a=a) { a }"
- }.should complain(/circular argument reference/)
- @proc.call.should == nil
- end
+ it "shadows an existing local with the same name as the argument" do
+ a = 1
+ -> {
+ @proc = eval "-> (a=a) { a }"
+ }.should complain(/circular argument reference/)
+ @proc.call.should == nil
end
- ruby_version_is '2.7' do
- it "raises a SyntaxError if using an existing local with the same name as the argument" do
- a = 1
- -> {
- @proc = eval "-> (a=a) { a }"
- }.should raise_error(SyntaxError)
- end
-
- it "raises a SyntaxError if there is an existing method with the same name as the argument" do
- def a; 1; end
- -> {
- @proc = eval "-> (a=a) { a }"
- }.should raise_error(SyntaxError)
- end
+ it "shadows an existing method with the same name as the argument" do
+ def a; 1; end
+ -> {
+ @proc = eval "-> (a=a) { a }"
+ }.should complain(/circular argument reference/)
+ @proc.call.should == nil
end
it "calls an existing method with the same name as the argument if explicitly using ()" do
def a; 1; end
- -> a=a() { a }.call.should == 1
+ -> (a=a()) { a }.call.should == 1
end
end
end
@@ -335,37 +305,19 @@ describe "A lambda expression 'lambda { ... }'" do
lambda { lambda }.should raise_error(ArgumentError)
end
- ruby_version_is "2.5" do
- it "may include a rescue clause" do
- eval('lambda do raise ArgumentError; rescue ArgumentError; 7; end').should be_an_instance_of(Proc)
- end
- end
-
-
context "with an implicit block" do
before do
def meth; lambda; end
end
- ruby_version_is ""..."2.7" do
- it "can be created" do
- implicit_lambda = nil
- -> {
- implicit_lambda = meth { 1 }
- }.should complain(/tried to create Proc object without a block/)
+ it "can be created" do
+ implicit_lambda = nil
+ -> {
+ implicit_lambda = meth { 1 }
+ }.should complain(/tried to create Proc object without a block/)
- implicit_lambda.lambda?.should be_true
- implicit_lambda.call.should == 1
- end
- end
-
- ruby_version_is "2.7" do
- it "raises ArgumentError" do
- implicit_lambda = nil
- -> {
- meth { 1 }
- }.should raise_error(ArgumentError, /tried to create Proc object without a block/)
- end
+ implicit_lambda.lambda?.should be_true
+ implicit_lambda.call.should == 1
end
end
@@ -540,11 +492,9 @@ describe "A lambda expression 'lambda { ... }'" do
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
- suppress_keyword_warning do
- h = mock("keyword splat")
- h.should_receive(:to_hash).and_return({a: 1})
- @a.(h).should == {a: 1}
- end
+ h = mock("keyword splat")
+ h.should_receive(:to_hash).and_return({a: 1})
+ @a.(h).should == {a: 1}
end
evaluate <<-ruby do
diff --git a/spec/ruby/language/line_spec.rb b/spec/ruby/language/line_spec.rb
index fcadaa71d7..d9fd307dab 100644
--- a/spec/ruby/language/line_spec.rb
+++ b/spec/ruby/language/line_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/code_loading'
-require_relative 'shared/__LINE__'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/code_loading', __FILE__)
+require File.expand_path('../shared/__LINE__', __FILE__)
describe "The __LINE__ pseudo-variable" do
it "raises a SyntaxError if assigned to" do
- -> { eval("__LINE__ = 1") }.should raise_error(SyntaxError)
+ lambda { eval("__LINE__ = 1") }.should raise_error(SyntaxError)
end
before :each do
diff --git a/spec/ruby/language/loop_spec.rb b/spec/ruby/language/loop_spec.rb
index fd17b53910..4e60e0d8e6 100644
--- a/spec/ruby/language/loop_spec.rb
+++ b/spec/ruby/language/loop_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The loop expression" do
it "repeats the given block until a break is called" do
@@ -15,7 +15,7 @@ describe "The loop expression" do
inner_loop = 123
break
end
- -> { inner_loop }.should raise_error(NameError)
+ lambda { inner_loop }.should raise_error(NameError)
end
it "returns the value passed to break if interrupted by break" do
diff --git a/spec/ruby/language/magic_comment_spec.rb b/spec/ruby/language/magic_comment_spec.rb
index f2bf3a08e5..2f6e3b5c3a 100644
--- a/spec/ruby/language/magic_comment_spec.rb
+++ b/spec/ruby/language/magic_comment_spec.rb
@@ -1,92 +1,62 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
-# See core/kernel/eval_spec.rb for more magic comments specs for eval()
-describe :magic_comments, shared: true do
- before :each do
- @default = @method == :locale ? Encoding.find('locale') : Encoding::UTF_8
+describe "Magic comment" do
+ it "is optional" do
+ eval("__ENCODING__").should be_an_instance_of(Encoding)
end
- it "are optional" do
- @object.call('no_magic_comment.rb').should == @default.name
+ it "determines __ENCODING__" do
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::ASCII_8BIT
+# encoding: ASCII-8BIT
+__ENCODING__
+EOS
end
- it "are case-insensitive" do
- @object.call('case_magic_comment.rb').should == Encoding::Big5.name
+ it "is case-insensitive" do
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::ASCII_8BIT
+# CoDiNg: aScIi-8bIt
+__ENCODING__
+EOS
end
it "must be at the first line" do
- @object.call('second_line_magic_comment.rb').should == @default.name
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::US_ASCII
+
+# encoding: ASCII-8BIT
+__ENCODING__
+EOS
end
it "must be the first token of the line" do
- @object.call('second_token_magic_comment.rb').should == @default.name
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::US_ASCII
+1+1 # encoding: ASCII-8BIT
+__ENCODING__
+EOS
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::ASCII_8BIT
+ # encoding: ASCII-8BIT
+__ENCODING__
+EOS
end
it "can be after the shebang" do
- @object.call('shebang_magic_comment.rb').should == Encoding::Big5.name
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::ASCII_8BIT
+#!/usr/bin/ruby -Ku
+# encoding: ASCII-8BIT
+__ENCODING__
+EOS
end
it "can take Emacs style" do
- @object.call('emacs_magic_comment.rb').should == Encoding::Big5.name
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::ASCII_8BIT
+# -*- encoding: ascii-8bit -*-
+__ENCODING__
+EOS
end
it "can take vim style" do
- @object.call('vim_magic_comment.rb').should == Encoding::Big5.name
- end
-
- it "determine __ENCODING__" do
- @object.call('magic_comment.rb').should == Encoding::Big5.name
- end
-
- it "do not cause bytes to be mangled by passing them through the wrong encoding" do
- @object.call('bytes_magic_comment.rb').should == [167, 65, 166, 110].inspect
- end
-end
-
-describe "Magic comments" do
- describe "in stdin" do
- it_behaves_like :magic_comments, :locale, -> file {
- print_at_exit = fixture(__FILE__, "print_magic_comment_result_at_exit.rb")
- ruby_exe(nil, args: "< #{fixture(__FILE__, file)}", options: "-r#{print_at_exit}")
- }
- end
-
- platform_is_not :windows do
- describe "in an -e argument" do
- it_behaves_like :magic_comments, :locale, -> file {
- print_at_exit = fixture(__FILE__, "print_magic_comment_result_at_exit.rb")
- # Use UTF-8, as it is the default source encoding for files
- code = File.read(fixture(__FILE__, file), encoding: 'utf-8')
- IO.popen([*ruby_exe, "-r", print_at_exit, "-e", code], &:read)
- }
- end
- end
-
- describe "in the main file" do
- it_behaves_like :magic_comments, :UTF8, -> file {
- print_at_exit = fixture(__FILE__, "print_magic_comment_result_at_exit.rb")
- ruby_exe(fixture(__FILE__, file), options: "-r#{print_at_exit}")
- }
- end
-
- describe "in a loaded file" do
- it_behaves_like :magic_comments, :UTF8, -> file {
- load fixture(__FILE__, file)
- $magic_comment_result
- }
- end
-
- describe "in a required file" do
- it_behaves_like :magic_comments, :UTF8, -> file {
- require fixture(__FILE__, file)
- $magic_comment_result
- }
- end
-
- describe "in an eval" do
- it_behaves_like :magic_comments, :UTF8, -> file {
- # Use UTF-8, as it is the default source encoding for files
- eval(File.read(fixture(__FILE__, file), encoding: 'utf-8'))
- }
+ eval(<<EOS.force_encoding("US-ASCII")).should == Encoding::ASCII_8BIT
+# vim: filetype=ruby, fileencoding=ascii-8bit, tabsize=3, shiftwidth=3
+__ENCODING__
+EOS
end
end
diff --git a/spec/ruby/language/match_spec.rb b/spec/ruby/language/match_spec.rb
index ebf677cabc..81604e94b2 100644
--- a/spec/ruby/language/match_spec.rb
+++ b/spec/ruby/language/match_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/match_operators'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/match_operators', __FILE__)
describe "The !~ operator" do
before :each do
@@ -48,13 +48,6 @@ describe "The =~ operator with named captures" do
end
end
- describe "on syntax of 'string_literal' =~ /regexp/" do
- it "does not set local variables" do
- 'string literal' =~ /(?<matched>str)(?<unmatched>lit)?/
- local_variables.should == []
- end
- end
-
describe "on syntax of string_variable =~ /regexp/" do
it "does not set local variables" do
@string =~ /(?<matched>foo)(?<unmatched>bar)?/
diff --git a/spec/ruby/language/metaclass_spec.rb b/spec/ruby/language/metaclass_spec.rb
index fc83067977..b3bcd9ef18 100644
--- a/spec/ruby/language/metaclass_spec.rb
+++ b/spec/ruby/language/metaclass_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/class'
-require_relative 'fixtures/metaclass'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class', __FILE__)
+require File.expand_path('../fixtures/metaclass', __FILE__)
describe "self in a metaclass body (class << obj)" do
it "is TrueClass for true" do
@@ -16,11 +16,11 @@ describe "self in a metaclass body (class << obj)" do
end
it "raises a TypeError for numbers" do
- -> { class << 1; self; end }.should raise_error(TypeError)
+ lambda { class << 1; self; end }.should raise_error(TypeError)
end
it "raises a TypeError for symbols" do
- -> { class << :symbol; self; end }.should raise_error(TypeError)
+ lambda { class << :symbol; self; end }.should raise_error(TypeError)
end
it "is a singleton Class instance" do
@@ -64,11 +64,11 @@ describe "A constant on a metaclass" do
class << @object
CONST
end
- -> { CONST }.should raise_error(NameError)
+ lambda { CONST }.should raise_error(NameError)
end
it "cannot be accessed via object::CONST" do
- -> do
+ lambda do
@object::CONST
end.should raise_error(TypeError)
end
@@ -79,7 +79,7 @@ describe "A constant on a metaclass" do
CONST = 100
end
- -> do
+ lambda do
@object::CONST
end.should raise_error(NameError)
end
@@ -96,7 +96,7 @@ describe "A constant on a metaclass" do
it "is not preserved when the object is duped" do
@object = @object.dup
- -> do
+ lambda do
class << @object; CONST; end
end.should raise_error(NameError)
end
diff --git a/spec/ruby/language/method_spec.rb b/spec/ruby/language/method_spec.rb
index 0486025792..ca939dbab6 100644
--- a/spec/ruby/language/method_spec.rb
+++ b/spec/ruby/language/method_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "A method send" do
evaluate <<-ruby do
@@ -40,7 +40,7 @@ describe "A method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { m(*x) }.should raise_error(TypeError)
+ lambda { m(*x) }.should raise_error(TypeError)
end
end
@@ -74,7 +74,7 @@ describe "A method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { m(*x, 2, 3) }.should raise_error(TypeError)
+ lambda { m(*x, 2, 3) }.should raise_error(TypeError)
end
end
@@ -108,7 +108,7 @@ describe "A method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { m(1, *x, 2, 3) }.should raise_error(TypeError)
+ lambda { m(1, *x, 2, 3) }.should raise_error(TypeError)
end
it "copies the splatted array" do
@@ -153,7 +153,7 @@ describe "A method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { m(1, 2, *x) }.should raise_error(TypeError)
+ lambda { m(1, 2, *x) }.should raise_error(TypeError)
end
end
end
@@ -197,7 +197,7 @@ describe "An element assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o[*x] = 1 }.should raise_error(TypeError)
+ lambda { @o[*x] = 1 }.should raise_error(TypeError)
end
end
@@ -235,7 +235,7 @@ describe "An element assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o[*x, 2, 3] = 4 }.should raise_error(TypeError)
+ lambda { @o[*x, 2, 3] = 4 }.should raise_error(TypeError)
end
end
@@ -273,7 +273,7 @@ describe "An element assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o[1, 2, *x, 3] = 4 }.should raise_error(TypeError)
+ lambda { @o[1, 2, *x, 3] = 4 }.should raise_error(TypeError)
end
end
@@ -311,7 +311,7 @@ describe "An element assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o[1, 2, 3, *x] = 4 }.should raise_error(TypeError)
+ lambda { @o[1, 2, 3, *x] = 4 }.should raise_error(TypeError)
end
end
end
@@ -348,7 +348,7 @@ describe "An attribute assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o.send :m=, *x, 1 }.should raise_error(TypeError)
+ lambda { @o.send :m=, *x, 1 }.should raise_error(TypeError)
end
end
@@ -383,7 +383,7 @@ describe "An attribute assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o.send :m=, *x, 2, 3, 4 }.should raise_error(TypeError)
+ lambda { @o.send :m=, *x, 2, 3, 4 }.should raise_error(TypeError)
end
end
@@ -418,7 +418,7 @@ describe "An attribute assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o.send :m=, 1, 2, *x, 3, 4 }.should raise_error(TypeError)
+ lambda { @o.send :m=, 1, 2, *x, 3, 4 }.should raise_error(TypeError)
end
end
@@ -453,7 +453,7 @@ describe "An attribute assignment method send" do
x = mock("splat argument")
x.should_receive(:to_a).and_return(1)
- -> { @o.send :m=, 1, 2, 3, *x, 4 }.should raise_error(TypeError)
+ lambda { @o.send :m=, 1, 2, 3, *x, 4 }.should raise_error(TypeError)
end
end
end
@@ -512,15 +512,6 @@ describe "A method" do
end
evaluate <<-ruby do
- def m() end
- ruby
-
- m().should be_nil
- m(*[]).should be_nil
- m(**{}).should be_nil
- end
-
- evaluate <<-ruby do
def m(*) end
ruby
@@ -536,19 +527,15 @@ describe "A method" do
m().should == []
m(1).should == [1]
m(1, 2, 3).should == [1, 2, 3]
- m(*[]).should == []
- m(**{}).should == []
end
evaluate <<-ruby do
def m(a:) a end
ruby
- -> { m() }.should raise_error(ArgumentError)
+ lambda { m() }.should raise_error(ArgumentError)
m(a: 1).should == 1
- suppress_keyword_warning do
- -> { m("a" => 1, a: 1) }.should raise_error(ArgumentError)
- end
+ lambda { m("a" => 1, a: 1) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -565,7 +552,7 @@ describe "A method" do
m().should be_nil
m(a: 1, b: 2).should be_nil
- -> { m(1) }.should raise_error(ArgumentError)
+ lambda { m(1) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -574,10 +561,7 @@ describe "A method" do
m().should == {}
m(a: 1, b: 2).should == { a: 1, b: 2 }
- m(*[]).should == {}
- m(**{}).should == {}
- m(**{a: 1, b: 2}, **{a: 4, c: 7}).should == { a: 4, b: 2, c: 7 }
- -> { m(2) }.should raise_error(ArgumentError)
+ lambda { m(2) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -616,7 +600,7 @@ describe "A method" do
m(2, 3).should be_nil
m([2, 3, 4], [5, 6]).should be_nil
- -> { m a: 1 }.should raise_error(ArgumentError)
+ lambda { m a: 1 }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -708,9 +692,7 @@ describe "A method" do
ruby
m(1, b: 2).should == [1, 2]
- suppress_keyword_warning do
- -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError)
- end
+ lambda { m("a" => 1, b: 2) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -719,9 +701,7 @@ describe "A method" do
m(2).should == [2, 1]
m(1, b: 2).should == [1, 2]
- suppress_keyword_warning do
- m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, 1]
- end
+ m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, 1]
end
evaluate <<-ruby do
@@ -730,9 +710,7 @@ describe "A method" do
m(1).should == 1
m(1, a: 2, b: 3).should == 1
- suppress_keyword_warning do
- m("a" => 1, b: 2).should == {"a" => 1, b: 2}
- end
+ m("a" => 1, b: 2).should == {"a" => 1, b: 2}
end
evaluate <<-ruby do
@@ -741,9 +719,7 @@ describe "A method" do
m(1).should == [1, {}]
m(1, a: 2, b: 3).should == [1, {a: 2, b: 3}]
- suppress_keyword_warning do
- m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, {}]
- end
+ m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, {}]
end
evaluate <<-ruby do
@@ -818,8 +794,8 @@ describe "A method" do
def m(a=1, (*b), (*c)) [a, b, c] end
ruby
- -> { m() }.should raise_error(ArgumentError)
- -> { m(2) }.should raise_error(ArgumentError)
+ lambda { m() }.should raise_error(ArgumentError)
+ lambda { m(2) }.should raise_error(ArgumentError)
m(2, 3).should == [1, [2], [3]]
m(2, [3, 4], [5, 6]).should == [2, [3, 4], [5, 6]]
end
@@ -860,9 +836,7 @@ describe "A method" do
m(b: 2).should == [1, 2]
m(2, b: 1).should == [2, 1]
- suppress_keyword_warning do
- m("a" => 1, b: 2).should == [{"a" => 1}, 2]
- end
+ m("a" => 1, b: 2).should == [{"a" => 1}, 2]
end
evaluate <<-ruby do
@@ -872,31 +846,16 @@ describe "A method" do
m().should == [1, 2]
m(2).should == [2, 2]
m(b: 3).should == [1, 3]
- suppress_keyword_warning do
- m("a" => 1, b: 2).should == [{"a" => 1}, 2]
- end
- end
-
- ruby_version_is ""..."2.7" do
- evaluate <<-ruby do
- def m(a=1, **) a end
- ruby
-
- m().should == 1
- m(2, a: 1, b: 0).should == 2
- m("a" => 1, a: 2).should == {"a" => 1}
- end
+ m("a" => 1, b: 2).should == [{"a" => 1}, 2]
end
- ruby_version_is "2.7" do
- evaluate <<-ruby do
- def m(a=1, **) a end
- ruby
+ evaluate <<-ruby do
+ def m(a=1, **) a end
+ ruby
- m().should == 1
- m(2, a: 1, b: 0).should == 2
- m("a" => 1, a: 2).should == 1
- end
+ m().should == 1
+ m(2, a: 1, b: 0).should == 2
+ m("a" => 1, a: 2).should == {"a" => 1}
end
evaluate <<-ruby do
@@ -942,9 +901,7 @@ describe "A method" do
m(a: 1).should == 1
m(1, 2, a: 3).should == 3
- suppress_keyword_warning do
- m("a" => 1, a: 2).should == 2
- end
+ m("a" => 1, a: 2).should == 2
end
evaluate <<-ruby do
@@ -953,9 +910,7 @@ describe "A method" do
m(b: 1).should == [[], 1]
m(1, 2, b: 3).should == [[1, 2], 3]
- suppress_keyword_warning do
- m("a" => 1, b: 2).should == [[{"a" => 1}], 2]
- end
+ m("a" => 1, b: 2).should == [[{"a" => 1}], 2]
end
evaluate <<-ruby do
@@ -966,9 +921,7 @@ describe "A method" do
m(1, 2).should == 1
m(a: 2).should == 2
m(1, a: 2).should == 2
- suppress_keyword_warning do
- m("a" => 1, a: 2).should == 2
- end
+ m("a" => 1, a: 2).should == 2
end
evaluate <<-ruby do
@@ -977,9 +930,7 @@ describe "A method" do
m().should == [[], 1]
m(1, 2, 3, b: 4).should == [[1, 2, 3], 4]
- suppress_keyword_warning do
- m("a" => 1, b: 2).should == [[{"a" => 1}], 2]
- end
+ m("a" => 1, b: 2).should == [[{"a" => 1}], 2]
a = mock("splat")
a.should_not_receive(:to_ary)
@@ -996,194 +947,97 @@ describe "A method" do
h = mock("keyword splat")
h.should_receive(:to_hash).and_return({a: 1})
- suppress_keyword_warning do
- m(h).should be_nil
- end
+ m(h).should be_nil
h = mock("keyword splat")
error = RuntimeError.new("error while converting to a hash")
h.should_receive(:to_hash).and_raise(error)
- -> { m(h) }.should raise_error(error)
- end
-
- ruby_version_is ""..."2.7" do
- evaluate <<-ruby do
- def m(*a, **) a end
- ruby
-
- m().should == []
- m(1, 2, 3, a: 4, b: 5).should == [1, 2, 3]
- m("a" => 1, a: 1).should == [{"a" => 1}]
- m(1, **{a: 2}).should == [1]
-
- h = mock("keyword splat")
- h.should_receive(:to_hash)
- -> { m(**h) }.should raise_error(TypeError)
- end
-
- evaluate <<-ruby do
- def m(*, **k) k end
- ruby
-
- m().should == {}
- m(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
- m("a" => 1, a: 1).should == {a: 1}
-
- h = mock("keyword splat")
- h.should_receive(:to_hash).and_return({a: 1})
- m(h).should == {a: 1}
- end
-
- evaluate <<-ruby do
- def m(a = nil, **k) [a, k] end
- ruby
-
- m().should == [nil, {}]
- m("a" => 1).should == [{"a" => 1}, {}]
- m(a: 1).should == [nil, {a: 1}]
- m("a" => 1, a: 1).should == [{"a" => 1}, {a: 1}]
- m({ "a" => 1 }, a: 1).should == [{"a" => 1}, {a: 1}]
- m({a: 1}, {}).should == [{a: 1}, {}]
-
- h = {"a" => 1, b: 2}
- m(h).should == [{"a" => 1}, {b: 2}]
- h.should == {"a" => 1, b: 2}
-
- h = {"a" => 1}
- m(h).first.should == h
-
- h = {}
- r = m(h)
- r.first.should be_nil
- r.last.should == {}
-
- hh = {}
- h = mock("keyword splat empty hash")
- h.should_receive(:to_hash).and_return(hh)
- r = m(h)
- r.first.should be_nil
- r.last.should == {}
-
- h = mock("keyword splat")
- h.should_receive(:to_hash).and_return({"a" => 1, a: 2})
- m(h).should == [{"a" => 1}, {a: 2}]
- end
-
- evaluate <<-ruby do
- def m(*a, **k) [a, k] end
- ruby
-
- m().should == [[], {}]
- m(1).should == [[1], {}]
- m(a: 1, b: 2).should == [[], {a: 1, b: 2}]
- m(1, 2, 3, a: 2).should == [[1, 2, 3], {a: 2}]
-
- m("a" => 1).should == [[{"a" => 1}], {}]
- m(a: 1).should == [[], {a: 1}]
- m("a" => 1, a: 1).should == [[{"a" => 1}], {a: 1}]
- m({ "a" => 1 }, a: 1).should == [[{"a" => 1}], {a: 1}]
- m({a: 1}, {}).should == [[{a: 1}], {}]
- m({a: 1}, {"a" => 1}).should == [[{a: 1}, {"a" => 1}], {}]
-
- bo = BasicObject.new
- def bo.to_a; [1, 2, 3]; end
- def bo.to_hash; {:b => 2, :c => 3}; end
-
- m(*bo, **bo).should == [[1, 2, 3], {:b => 2, :c => 3}]
- end
- end
-
- ruby_version_is "2.7" do
- evaluate <<-ruby do
- def m(*a, **) a end
- ruby
-
- m().should == []
- m(1, 2, 3, a: 4, b: 5).should == [1, 2, 3]
- m("a" => 1, a: 1).should == []
- m(1, **{a: 2}).should == [1]
-
- h = mock("keyword splat")
- h.should_receive(:to_hash)
- -> { m(**h) }.should raise_error(TypeError)
- end
-
- evaluate <<-ruby do
- def m(*, **k) k end
- ruby
-
- m().should == {}
- m(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
- m("a" => 1, a: 1).should == {"a" => 1, a: 1}
-
- h = mock("keyword splat")
- h.should_receive(:to_hash).and_return({a: 1})
- suppress_warning do
- m(h).should == {a: 1}
- end
- end
-
- evaluate <<-ruby do
- def m(a = nil, **k) [a, k] end
- ruby
-
- m().should == [nil, {}]
- m("a" => 1).should == [nil, {"a" => 1}]
- m(a: 1).should == [nil, {a: 1}]
- m("a" => 1, a: 1).should == [nil, {"a" => 1, a: 1}]
- m({ "a" => 1 }, a: 1).should == [{"a" => 1}, {a: 1}]
- suppress_warning do
- m({a: 1}, {}).should == [{a: 1}, {}]
-
- h = {"a" => 1, b: 2}
- m(h).should == [{"a" => 1}, {b: 2}]
- h.should == {"a" => 1, b: 2}
-
- h = {"a" => 1}
- m(h).first.should == h
-
- h = {}
- r = m(h)
- r.first.should be_nil
- r.last.should == {}
-
- hh = {}
- h = mock("keyword splat empty hash")
- h.should_receive(:to_hash).and_return(hh)
- r = m(h)
- r.first.should be_nil
- r.last.should == {}
-
- h = mock("keyword splat")
- h.should_receive(:to_hash).and_return({"a" => 1, a: 2})
- m(h).should == [{"a" => 1}, {a: 2}]
- end
- end
-
- evaluate <<-ruby do
- def m(*a, **k) [a, k] end
- ruby
-
- m().should == [[], {}]
- m(1).should == [[1], {}]
- m(a: 1, b: 2).should == [[], {a: 1, b: 2}]
- m(1, 2, 3, a: 2).should == [[1, 2, 3], {a: 2}]
-
- m("a" => 1).should == [[], {"a" => 1}]
- m(a: 1).should == [[], {a: 1}]
- m("a" => 1, a: 1).should == [[], {"a" => 1, a: 1}]
- m({ "a" => 1 }, a: 1).should == [[{"a" => 1}], {a: 1}]
- suppress_warning do
- m({a: 1}, {}).should == [[{a: 1}], {}]
- end
- m({a: 1}, {"a" => 1}).should == [[{a: 1}, {"a" => 1}], {}]
+ lambda { m(h) }.should raise_error(error)
+ end
+
+ evaluate <<-ruby do
+ def m(*a, **) a end
+ ruby
+
+ m().should == []
+ m(1, 2, 3, a: 4, b: 5).should == [1, 2, 3]
+ m("a" => 1, a: 1).should == [{"a" => 1}]
+ m(1, **{a: 2}).should == [1]
+
+ h = mock("keyword splat")
+ h.should_receive(:to_hash)
+ lambda { m(**h) }.should raise_error(TypeError)
+ end
+
+ evaluate <<-ruby do
+ def m(*, **k) k end
+ ruby
+
+ m().should == {}
+ m(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
+ m("a" => 1, a: 1).should == {a: 1}
+
+ h = mock("keyword splat")
+ h.should_receive(:to_hash).and_return({a: 1})
+ m(h).should == {a: 1}
+ end
+
+ evaluate <<-ruby do
+ def m(a = nil, **k) [a, k] end
+ ruby
+
+ m().should == [nil, {}]
+ m("a" => 1).should == [{"a" => 1}, {}]
+ m(a: 1).should == [nil, {a: 1}]
+ m("a" => 1, a: 1).should == [{"a" => 1}, {a: 1}]
+ m({ "a" => 1 }, a: 1).should == [{"a" => 1}, {a: 1}]
+ m({a: 1}, {}).should == [{a: 1}, {}]
+
+ h = {"a" => 1, b: 2}
+ m(h).should == [{"a" => 1}, {b: 2}]
+ h.should == {"a" => 1, b: 2}
+
+ h = {"a" => 1}
+ m(h).first.should == h
- bo = BasicObject.new
- def bo.to_a; [1, 2, 3]; end
- def bo.to_hash; {:b => 2, :c => 3}; end
+ h = {}
+ r = m(h)
+ r.first.should be_nil
+ r.last.should == {}
- m(*bo, **bo).should == [[1, 2, 3], {:b => 2, :c => 3}]
- end
+ hh = {}
+ h = mock("keyword splat empty hash")
+ h.should_receive(:to_hash).and_return(hh)
+ r = m(h)
+ r.first.should be_nil
+ r.last.should == {}
+
+ h = mock("keyword splat")
+ h.should_receive(:to_hash).and_return({"a" => 1, a: 2})
+ m(h).should == [{"a" => 1}, {a: 2}]
+ end
+
+ evaluate <<-ruby do
+ def m(*a, **k) [a, k] end
+ ruby
+
+ m().should == [[], {}]
+ m(1).should == [[1], {}]
+ m(a: 1, b: 2).should == [[], {a: 1, b: 2}]
+ m(1, 2, 3, a: 2).should == [[1, 2, 3], {a: 2}]
+
+ m("a" => 1).should == [[{"a" => 1}], {}]
+ m(a: 1).should == [[], {a: 1}]
+ m("a" => 1, a: 1).should == [[{"a" => 1}], {a: 1}]
+ m({ "a" => 1 }, a: 1).should == [[{"a" => 1}], {a: 1}]
+ m({a: 1}, {}).should == [[{a: 1}], {}]
+ m({a: 1}, {"a" => 1}).should == [[{a: 1}, {"a" => 1}], {}]
+
+ bo = BasicObject.new
+ def bo.to_a; [1, 2, 3]; end
+ def bo.to_hash; {:b => 2, :c => 3}; end
+
+ m(*bo, **bo).should == [[1, 2, 3], {:b => 2, :c => 3}]
end
evaluate <<-ruby do
@@ -1209,9 +1063,7 @@ describe "A method" do
ruby
m(a: 1, b: 2).should == [1, 2]
- suppress_keyword_warning do
- -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
- end
+ lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -1220,51 +1072,25 @@ describe "A method" do
m(a: 1).should == [1, 1]
m(a: 1, b: 2).should == [1, 2]
- suppress_keyword_warning do
- -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
- end
+ lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- evaluate <<-ruby do
- def m(a:, **) a end
- ruby
-
- m(a: 1).should == 1
- m(a: 1, b: 2).should == 1
- -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
- end
-
- evaluate <<-ruby do
- def m(a:, **k) [a, k] end
- ruby
+ evaluate <<-ruby do
+ def m(a:, **) a end
+ ruby
- m(a: 1).should == [1, {}]
- m(a: 1, b: 2, c: 3).should == [1, {b: 2, c: 3}]
- -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
- end
+ m(a: 1).should == 1
+ m(a: 1, b: 2).should == 1
+ lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
end
- ruby_version_is '2.7' do
- evaluate <<-ruby do
- def m(a:, **) a end
- ruby
-
- m(a: 1).should == 1
- m(a: 1, b: 2).should == 1
- m("a" => 1, a: 1, b: 2).should == 1
- end
-
- evaluate <<-ruby do
- def m(a:, **k) [a, k] end
- ruby
+ evaluate <<-ruby do
+ def m(a:, **k) [a, k] end
+ ruby
- m(a: 1).should == [1, {}]
- m(a: 1, b: 2, c: 3).should == [1, {b: 2, c: 3}]
- suppress_warning do
- m("a" => 1, a: 1, b: 2).should == [1, {"a" => 1, b: 2}]
- end
- end
+ m(a: 1).should == [1, {}]
+ m(a: 1, b: 2, c: 3).should == [1, {b: 2, c: 3}]
+ lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError)
end
evaluate <<-ruby do
@@ -1365,35 +1191,18 @@ describe "A method" do
def m(a, b = nil, c = nil, d, e: nil, **f)
[a, b, c, d, e, f]
end
- ruby
+ ruby
result = m(1, 2)
result.should == [1, nil, nil, 2, nil, {}]
- suppress_warning do
- result = m(1, 2, {foo: :bar})
- result.should == [1, nil, nil, 2, nil, {foo: :bar}]
- end
+ result = m(1, 2, {foo: :bar})
+ result.should == [1, nil, nil, 2, nil, {foo: :bar}]
result = m(1, {foo: :bar})
result.should == [1, nil, nil, {foo: :bar}, nil, {}]
end
end
-
- context "assigns keyword arguments from a passed Hash without modifying it" do
- evaluate <<-ruby do
- def m(a: nil); a; end
- ruby
-
- options = {a: 1}.freeze
- -> do
- suppress_warning do
- m(options).should == 1
- end
- end.should_not raise_error
- options.should == {a: 1}
- end
- end
end
describe "A method call with a space between method name and parentheses" do
@@ -1423,11 +1232,11 @@ describe "A method call with a space between method name and parentheses" do
context "when 2+ arguments provided" do
it "raises a syntax error" do
- -> {
+ lambda {
eval("m (1, 2)")
}.should raise_error(SyntaxError)
- -> {
+ lambda {
eval("m (1, 2, 3)")
}.should raise_error(SyntaxError)
end
diff --git a/spec/ruby/language/module_spec.rb b/spec/ruby/language/module_spec.rb
index 1b41e184bb..d5ca71b3b4 100644
--- a/spec/ruby/language/module_spec.rb
+++ b/spec/ruby/language/module_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/module'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/module', __FILE__)
describe "The module keyword" do
it "creates a new module without semicolon" do
@@ -34,29 +34,29 @@ describe "The module keyword" do
end
it "raises a TypeError if the constant is a Class" do
- -> do
+ lambda do
module ModuleSpecs::Modules::Klass; end
end.should raise_error(TypeError)
end
it "raises a TypeError if the constant is a String" do
- -> { module ModuleSpecs::Modules::A; end }.should raise_error(TypeError)
+ lambda { module ModuleSpecs::Modules::A; end }.should raise_error(TypeError)
end
it "raises a TypeError if the constant is a Fixnum" do
- -> { module ModuleSpecs::Modules::B; end }.should raise_error(TypeError)
+ lambda { module ModuleSpecs::Modules::B; end }.should raise_error(TypeError)
end
it "raises a TypeError if the constant is nil" do
- -> { module ModuleSpecs::Modules::C; end }.should raise_error(TypeError)
+ lambda { module ModuleSpecs::Modules::C; end }.should raise_error(TypeError)
end
it "raises a TypeError if the constant is true" do
- -> { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError)
+ lambda { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError)
end
it "raises a TypeError if the constant is false" do
- -> { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError)
+ lambda { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/language/next_spec.rb b/spec/ruby/language/next_spec.rb
index 6fbfc4a54d..67da5224dc 100644
--- a/spec/ruby/language/next_spec.rb
+++ b/spec/ruby/language/next_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/next'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/next', __FILE__)
describe "The next statement from within the block" do
before :each do
@@ -8,7 +8,7 @@ describe "The next statement from within the block" do
it "ends block execution" do
a = []
- -> {
+ lambda {
a << 1
next
a << 2
@@ -17,15 +17,15 @@ describe "The next statement from within the block" do
end
it "causes block to return nil if invoked without arguments" do
- -> { 123; next; 456 }.call.should == nil
+ lambda { 123; next; 456 }.call.should == nil
end
it "causes block to return nil if invoked with an empty expression" do
- -> { next (); 456 }.call.should be_nil
+ lambda { next (); 456 }.call.should be_nil
end
it "returns the argument passed" do
- -> { 123; next 234; 345 }.call.should == 234
+ lambda { 123; next 234; 345 }.call.should == 234
end
it "returns to the invoking method" do
@@ -102,14 +102,14 @@ describe "The next statement from within the block" do
it "passes the value returned by a method with omitted parenthesis and passed block" do
obj = NextSpecs::Block.new
- -> { next obj.method :value do |x| x end }.call.should == :value
+ lambda { next obj.method :value do |x| x end }.call.should == :value
end
end
describe "The next statement" do
describe "in a method" do
it "is invalid and raises a SyntaxError" do
- -> {
+ lambda {
eval("def m; next; end")
}.should raise_error(SyntaxError)
end
diff --git a/spec/ruby/language/not_spec.rb b/spec/ruby/language/not_spec.rb
index 052af9b256..a0cf6b15a6 100644
--- a/spec/ruby/language/not_spec.rb
+++ b/spec/ruby/language/not_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The not keyword" do
it "negates a `true' value" do
diff --git a/spec/ruby/language/numbers_spec.rb b/spec/ruby/language/numbers_spec.rb
index c82a630632..e8c82f09a7 100644
--- a/spec/ruby/language/numbers_spec.rb
+++ b/spec/ruby/language/numbers_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "A number literal" do
@@ -11,7 +11,7 @@ describe "A number literal" do
end
it "cannot have a leading underscore" do
- -> { eval("_4_2") }.should raise_error(NameError)
+ lambda { eval("_4_2") }.should raise_error(NameError)
end
it "can have a decimal point" do
@@ -20,8 +20,8 @@ describe "A number literal" do
it "must have a digit before the decimal point" do
0.75.should == 0.75
- -> { eval(".75") }.should raise_error(SyntaxError)
- -> { eval("-.75") }.should raise_error(SyntaxError)
+ lambda { eval(".75") }.should raise_error(SyntaxError)
+ lambda { eval("-.75") }.should raise_error(SyntaxError)
end
it "can have an exponent" do
diff --git a/spec/ruby/language/optional_assignments_spec.rb b/spec/ruby/language/optional_assignments_spec.rb
index 3d9e0dbb65..0ab28985ed 100644
--- a/spec/ruby/language/optional_assignments_spec.rb
+++ b/spec/ruby/language/optional_assignments_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe 'Optional variable assignments' do
describe 'using ||=' do
@@ -42,18 +42,6 @@ describe 'Optional variable assignments' do
a.should == 10
end
-
- it 'returns the new value if set to false' do
- a = false
-
- (a ||= 20).should == 20
- end
-
- it 'returns the original value if truthy' do
- a = 10
-
- (a ||= 20).should == 10
- end
end
describe 'using a accessor' do
@@ -101,49 +89,6 @@ describe 'Optional variable assignments' do
@a.b.should == 10
end
-
- it 'returns the new value if set to false' do
- def @a.b=(x)
- :v
- end
-
- @a.b = false
- (@a.b ||= 20).should == 20
- end
-
- it 'returns the original value if truthy' do
- def @a.b=(x)
- @b = x
- :v
- end
-
- @a.b = 10
- (@a.b ||= 20).should == 10
- end
-
- it 'works when writer is private' do
- klass = Class.new do
- def t
- self.b = false
- (self.b ||= 10).should == 10
- (self.b ||= 20).should == 10
- end
-
- def b
- @b
- end
-
- def b=(x)
- @b = x
- :v
- end
-
- private :b=
- end
-
- klass.new.t
- end
-
end
end
@@ -236,82 +181,10 @@ describe 'Optional variable assignments' do
@a.b.should == 20
end
end
-
- describe 'using a #[]' do
- before do
- @a = {}
- klass = Class.new do
- def [](k)
- @hash ||= {}
- @hash[k]
- end
-
- def []=(k, v)
- @hash ||= {}
- @hash[k] = v
- 7
- end
- end
- @b = klass.new
- end
-
- it 'leaves new variable unassigned' do
- @a[:k] &&= 10
-
- @a.key?(:k).should == false
- end
-
- it 'leaves false' do
- @a[:k] = false
- @a[:k] &&= 10
-
- @a[:k].should == false
- end
-
- it 'leaves nil' do
- @a[:k] = nil
- @a[:k] &&= 10
-
- @a[:k].should == nil
- end
-
- it 'does not evaluate the right side when not needed' do
- @a[:k] = nil
- @a[:k] &&= raise('should not be executed')
- @a[:k].should == nil
- end
-
- it 'does re-assign a variable with a truthy value' do
- @a[:k] = 10
- @a[:k] &&= 20
-
- @a[:k].should == 20
- end
-
- it 'does re-assign a variable with a truthy value when using an inline rescue' do
- @a[:k] = 10
- @a[:k] &&= 20 rescue 30
-
- @a[:k].should == 20
- end
-
- it 'returns the assigned value, not the result of the []= method with ||=' do
- (@b[:k] ||= 12).should == 12
- end
-
- it 'returns the assigned value, not the result of the []= method with +=' do
- @b[:k] = 17
- (@b[:k] += 12).should == 29
- end
- end
end
- describe 'using compounded constants' do
- before :each do
- Object.send(:remove_const, :A) if defined? Object::A
- end
-
- after :each do
+ describe 'using compunded constants' do
+ before do
Object.send(:remove_const, :A) if defined? Object::A
end
@@ -335,7 +208,7 @@ describe 'Optional variable assignments' do
end
it 'with &&= assignments will fail with non-existent constants' do
- -> { Object::A &&= 10 }.should raise_error(NameError)
+ lambda { Object::A &&= 10 }.should raise_error(NameError)
end
it 'with operator assignments' do
@@ -347,7 +220,7 @@ describe 'Optional variable assignments' do
end
it 'with operator assignments will fail with non-existent constants' do
- -> { Object::A += 10 }.should raise_error(NameError)
+ lambda { Object::A += 10 }.should raise_error(NameError)
end
end
end
diff --git a/spec/ruby/language/or_spec.rb b/spec/ruby/language/or_spec.rb
index fb75e788f1..150d693996 100644
--- a/spec/ruby/language/or_spec.rb
+++ b/spec/ruby/language/or_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The || operator" do
it "evaluates to true if any of its operands are true" do
@@ -35,15 +35,15 @@ describe "The || operator" do
it "has a higher precedence than 'break' in 'break true || false'" do
# see also 'break true or false' below
- -> { break false || true }.call.should be_true
+ lambda { break false || true }.call.should be_true
end
it "has a higher precedence than 'next' in 'next true || false'" do
- -> { next false || true }.call.should be_true
+ lambda { next false || true }.call.should be_true
end
it "has a higher precedence than 'return' in 'return true || false'" do
- -> { return false || true }.call.should be_true
+ lambda { return false || true }.call.should be_true
end
end
@@ -77,14 +77,14 @@ describe "The or operator" do
it "has a lower precedence than 'break' in 'break true or false'" do
# see also 'break true || false' above
- -> { eval "break true or false" }.should raise_error(SyntaxError, /void value expression/)
+ lambda { eval "break true or false" }.should raise_error(SyntaxError, /void value expression/)
end
it "has a lower precedence than 'next' in 'next true or false'" do
- -> { eval "next true or false" }.should raise_error(SyntaxError, /void value expression/)
+ lambda { eval "next true or false" }.should raise_error(SyntaxError, /void value expression/)
end
it "has a lower precedence than 'return' in 'return true or false'" do
- -> { eval "return true or false" }.should raise_error(SyntaxError, /void value expression/)
+ lambda { eval "return true or false" }.should raise_error(SyntaxError, /void value expression/)
end
end
diff --git a/spec/ruby/language/order_spec.rb b/spec/ruby/language/order_spec.rb
index d550f6b3f4..d02bf04077 100644
--- a/spec/ruby/language/order_spec.rb
+++ b/spec/ruby/language/order_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "A method call" do
before :each do
diff --git a/spec/ruby/language/precedence_spec.rb b/spec/ruby/language/precedence_spec.rb
index 5a3c2861ce..90734022ff 100644
--- a/spec/ruby/language/precedence_spec.rb
+++ b/spec/ruby/language/precedence_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/precedence'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/precedence', __FILE__)
# Specifying the behavior of operators in combination could
# lead to combinatorial explosion. A better way seems to be
@@ -136,7 +136,7 @@ describe "Operators" do
# Guard against the Mathn library
# TODO: Make these specs not rely on specific behaviour / result values
# by using mocks.
- guard -> { !defined?(Math.rsqrt) } do
+ conflicts_with :Prime do
(2*1/2).should_not == 2*(1/2)
end
@@ -253,12 +253,12 @@ describe "Operators" do
end
it "<=> == === != =~ !~ are non-associative" do
- -> { eval("1 <=> 2 <=> 3") }.should raise_error(SyntaxError)
- -> { eval("1 == 2 == 3") }.should raise_error(SyntaxError)
- -> { eval("1 === 2 === 3") }.should raise_error(SyntaxError)
- -> { eval("1 != 2 != 3") }.should raise_error(SyntaxError)
- -> { eval("1 =~ 2 =~ 3") }.should raise_error(SyntaxError)
- -> { eval("1 !~ 2 !~ 3") }.should raise_error(SyntaxError)
+ lambda { eval("1 <=> 2 <=> 3") }.should raise_error(SyntaxError)
+ lambda { eval("1 == 2 == 3") }.should raise_error(SyntaxError)
+ lambda { eval("1 === 2 === 3") }.should raise_error(SyntaxError)
+ lambda { eval("1 != 2 != 3") }.should raise_error(SyntaxError)
+ lambda { eval("1 =~ 2 =~ 3") }.should raise_error(SyntaxError)
+ lambda { eval("1 !~ 2 !~ 3") }.should raise_error(SyntaxError)
end
it "<=> == === != =~ !~ have higher precedence than &&" do
@@ -292,18 +292,19 @@ describe "Operators" do
end
it ".. ... are non-associative" do
- -> { eval("1..2..3") }.should raise_error(SyntaxError)
- -> { eval("1...2...3") }.should raise_error(SyntaxError)
+ lambda { eval("1..2..3") }.should raise_error(SyntaxError)
+ lambda { eval("1...2...3") }.should raise_error(SyntaxError)
end
- it ".. ... have higher precedence than ? :" do
- # Use variables to avoid warnings
- from = 1
- to = 2
- # These are flip-flop, not Range instances
- (from..to ? 3 : 4).should == 3
- (from...to ? 3 : 4).should == 3
- end
+# XXX: this is commented now due to a bug in compiler, which cannot
+# distinguish between range and flip-flop operator so far. zenspider is
+# currently working on a new lexer, which will be able to do that.
+# As soon as it's done, these piece should be reenabled.
+#
+# it ".. ... have higher precedence than ? :" do
+# (1..2 ? 3 : 4).should == 3
+# (1...2 ? 3 : 4).should == 3
+# end
it "? : is right-associative" do
(true ? 2 : 3 ? 4 : 5).should == 2
diff --git a/spec/ruby/language/predefined/data_spec.rb b/spec/ruby/language/predefined/data_spec.rb
index 921d236ee9..f616879527 100644
--- a/spec/ruby/language/predefined/data_spec.rb
+++ b/spec/ruby/language/predefined/data_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "The DATA constant" do
it "exists when the main script contains __END__" do
@@ -23,25 +23,6 @@ describe "The DATA constant" do
str.chomp.should == "data only"
end
- it "returns a File object with the right offset" do
- ruby_exe(fixture(__FILE__, "data_offset.rb")).should == "File\n121\n"
- end
-
- it "is set even if there is no data after __END__" do
- ruby_exe(fixture(__FILE__, "empty_data.rb")).should == "31\n\"\"\n"
- end
-
- it "is set even if there is no newline after __END__" do
- path = tmp("no_newline_data.rb")
- code = File.binread(fixture(__FILE__, "empty_data.rb"))
- touch(path, "wb") { |f| f.write code.chomp }
- begin
- ruby_exe(path).should == "30\n\"\"\n"
- ensure
- rm_r path
- end
- end
-
it "rewinds to the head of the main script" do
ruby_exe(fixture(__FILE__, "data5.rb")).chomp.should == "DATA.rewind"
end
diff --git a/spec/ruby/language/predefined/fixtures/data2.rb b/spec/ruby/language/predefined/fixtures/data2.rb
index a764ca56d1..0f714b06d4 100644
--- a/spec/ruby/language/predefined/fixtures/data2.rb
+++ b/spec/ruby/language/predefined/fixtures/data2.rb
@@ -1,3 +1,4 @@
-require_relative 'data4'
+
+require File.expand_path("../data4.rb", __FILE__)
p Object.const_defined?(:DATA)
diff --git a/spec/ruby/language/predefined/fixtures/data3.rb b/spec/ruby/language/predefined/fixtures/data3.rb
index e37313c68b..6cbf63dae6 100644
--- a/spec/ruby/language/predefined/fixtures/data3.rb
+++ b/spec/ruby/language/predefined/fixtures/data3.rb
@@ -1,4 +1,5 @@
-require_relative 'data4'
+
+require File.expand_path("../data4.rb", __FILE__)
puts DATA.read
diff --git a/spec/ruby/language/predefined/fixtures/data_offset.rb b/spec/ruby/language/predefined/fixtures/data_offset.rb
deleted file mode 100644
index 9829b3f87f..0000000000
--- a/spec/ruby/language/predefined/fixtures/data_offset.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# some comment
-
-foo = <<HEREDOC
-some heredoc to make the
-spec more interesting
-HEREDOC
-
-p DATA.class
-p DATA.pos
-
-__END__
-data offset
diff --git a/spec/ruby/language/predefined/fixtures/empty_data.rb b/spec/ruby/language/predefined/fixtures/empty_data.rb
deleted file mode 100644
index c6d9bc6f1f..0000000000
--- a/spec/ruby/language/predefined/fixtures/empty_data.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-p DATA.pos
-p DATA.read
-__END__
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic.rb
deleted file mode 100644
index f7809109fa..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-p TOPLEVEL_BINDING.local_variables.sort
-TOPLEVEL_BINDING.local_variable_set(:dynamic_set_main, 2)
-p TOPLEVEL_BINDING.local_variables.sort
-main_script = 3
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic_required.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic_required.rb
deleted file mode 100644
index 7ccf329680..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_dynamic_required.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-TOPLEVEL_BINDING.local_variable_set(:dynamic_set_required, 1)
-p TOPLEVEL_BINDING.local_variables
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_id.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_id.rb
deleted file mode 100644
index 3626ea1f10..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_id.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-a = TOPLEVEL_BINDING.object_id
-require_relative 'toplevel_binding_id_required'
-c = eval('TOPLEVEL_BINDING.object_id')
-p [a, $b, c].uniq.size
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_id_required.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_id_required.rb
deleted file mode 100644
index b31b6e32a0..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_id_required.rb
+++ /dev/null
@@ -1 +0,0 @@
-$b = TOPLEVEL_BINDING.object_id
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_required_before.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_required_before.rb
deleted file mode 100644
index 58924a5800..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_required_before.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-required = true
-p [:required_before, TOPLEVEL_BINDING.local_variables]
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_values.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_values.rb
deleted file mode 100644
index 42bd67f347..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_values.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-p TOPLEVEL_BINDING.local_variable_get(:a)
-p TOPLEVEL_BINDING.local_variable_get(:b)
-a = 1
-p TOPLEVEL_BINDING.local_variable_get(:a)
-p TOPLEVEL_BINDING.local_variable_get(:b)
-b = 2
-a = 3
-p TOPLEVEL_BINDING.local_variable_get(:a)
-p TOPLEVEL_BINDING.local_variable_get(:b)
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_variables.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_variables.rb
deleted file mode 100644
index 151f4340ef..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_variables.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-main_script = 1
-require_relative 'toplevel_binding_variables_required'
-eval('eval_var = 3')
-p TOPLEVEL_BINDING.local_variables
diff --git a/spec/ruby/language/predefined/fixtures/toplevel_binding_variables_required.rb b/spec/ruby/language/predefined/fixtures/toplevel_binding_variables_required.rb
deleted file mode 100644
index 614547fe16..0000000000
--- a/spec/ruby/language/predefined/fixtures/toplevel_binding_variables_required.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-required = 2
-p [:required_after, TOPLEVEL_BINDING.local_variables]
diff --git a/spec/ruby/language/predefined/toplevel_binding_spec.rb b/spec/ruby/language/predefined/toplevel_binding_spec.rb
deleted file mode 100644
index 69ac28618c..0000000000
--- a/spec/ruby/language/predefined/toplevel_binding_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "The TOPLEVEL_BINDING constant" do
- it "only includes local variables defined in the main script, not in required files or eval" do
- binding_toplevel_variables = ruby_exe(fixture(__FILE__, "toplevel_binding_variables.rb"))
- binding_toplevel_variables.should == "[:required_after, [:main_script]]\n[:main_script]\n"
- end
-
- it "has no local variables in files required before the main script" do
- required = fixture(__FILE__, 'toplevel_binding_required_before.rb')
- out = ruby_exe("a=1; p TOPLEVEL_BINDING.local_variables.sort; b=2", options: "-r#{required}")
- out.should == "[:required_before, []]\n[:a, :b]\n"
- end
-
- it "merges local variables of the main script with dynamically-defined Binding variables" do
- required = fixture(__FILE__, 'toplevel_binding_dynamic_required.rb')
- out = ruby_exe(fixture(__FILE__, 'toplevel_binding_dynamic.rb'), options: "-r#{required}")
- out.should == <<EOS
-[:dynamic_set_required]
-[:dynamic_set_required, :main_script]
-[:dynamic_set_main, :dynamic_set_required, :main_script]
-EOS
- end
-
- it "gets updated variables values as they are defined and set" do
- out = ruby_exe(fixture(__FILE__, "toplevel_binding_values.rb"))
- out.should == "nil\nnil\n1\nnil\n3\n2\n"
- end
-
- it "is always the same object for all top levels" do
- binding_toplevel_id = ruby_exe(fixture(__FILE__, "toplevel_binding_id.rb"))
- binding_toplevel_id.should == "1\n"
- end
-end
diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb
index cdf2c28dcb..f827fb2eb5 100644
--- a/spec/ruby/language/predefined_spec.rb
+++ b/spec/ruby/language/predefined_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
require 'stringio'
# The following tables are excerpted from Programming Ruby: The Pragmatic Programmer's Guide'
@@ -30,11 +30,11 @@ $` String The string preceding the match in a successful
is local to the current scope. [r/o, thread]
$' String The string following the match in a successful pattern match. This variable
is local to the current scope. [r/o, thread]
-$1 to $<N> String The contents of successive groups matched in a successful pattern match. In
+$1 to $9 String The contents of successive groups matched in a successful pattern match. In
"cat" =~/(c|a)(t|z)/, $1 will be set to “a†and $2 to “tâ€. This variable
is local to the current scope. [r/o, thread]
$~ MatchData An object that encapsulates the results of a successful pattern match. The
- variables $&, $`, $', and $1 to $<N> are all derived from $~. Assigning to $~
+ variables $&, $`, $', and $1 to $9 are all derived from $~. Assigning to $~
changes the values of these derived variables. This variable is local to the
current scope. [thread]
=end
@@ -44,11 +44,11 @@ describe "Predefined global $~" do
it "is set to contain the MatchData object of the last match if successful" do
md = /foo/.match 'foo'
$~.should be_kind_of(MatchData)
- $~.should equal md
+ $~.object_id.should == md.object_id
/bar/ =~ 'bar'
$~.should be_kind_of(MatchData)
- $~.should_not equal md
+ $~.object_id.should_not == md.object_id
end
it "is set to nil if the last match was unsuccessful" do
@@ -92,8 +92,8 @@ describe "Predefined global $~" do
$~ = /foo/.match("foo")
$~.should be_an_instance_of(MatchData)
- -> { $~ = Object.new }.should raise_error(TypeError)
- -> { $~ = 1 }.should raise_error(TypeError)
+ lambda { $~ = Object.new }.should raise_error(TypeError)
+ lambda { $~ = 1 }.should raise_error(TypeError)
end
it "changes the value of derived capture globals when assigned" do
@@ -136,9 +136,11 @@ describe "Predefined global $&" do
$&.should == 'foo'
end
- it "sets the encoding to the encoding of the source String" do
- "abc".force_encoding(Encoding::EUC_JP) =~ /b/
- $&.encoding.should equal(Encoding::EUC_JP)
+ with_feature :encoding do
+ it "sets the encoding to the encoding of the source String" do
+ "abc".force_encoding(Encoding::EUC_JP) =~ /b/
+ $&.encoding.should equal(Encoding::EUC_JP)
+ end
end
end
@@ -149,14 +151,16 @@ describe "Predefined global $`" do
$`.should == 'bar'
end
- it "sets the encoding to the encoding of the source String" do
- "abc".force_encoding(Encoding::EUC_JP) =~ /b/
- $`.encoding.should equal(Encoding::EUC_JP)
- end
+ with_feature :encoding do
+ it "sets the encoding to the encoding of the source String" do
+ "abc".force_encoding(Encoding::EUC_JP) =~ /b/
+ $`.encoding.should equal(Encoding::EUC_JP)
+ end
- it "sets an empty result to the encoding of the source String" do
- "abc".force_encoding(Encoding::ISO_8859_1) =~ /a/
- $`.encoding.should equal(Encoding::ISO_8859_1)
+ it "sets an empty result to the encoding of the source String" do
+ "abc".force_encoding(Encoding::ISO_8859_1) =~ /a/
+ $`.encoding.should equal(Encoding::ISO_8859_1)
+ end
end
end
@@ -167,14 +171,16 @@ describe "Predefined global $'" do
$'.should == 'baz'
end
- it "sets the encoding to the encoding of the source String" do
- "abc".force_encoding(Encoding::EUC_JP) =~ /b/
- $'.encoding.should equal(Encoding::EUC_JP)
- end
+ with_feature :encoding do
+ it "sets the encoding to the encoding of the source String" do
+ "abc".force_encoding(Encoding::EUC_JP) =~ /b/
+ $'.encoding.should equal(Encoding::EUC_JP)
+ end
- it "sets an empty result to the encoding of the source String" do
- "abc".force_encoding(Encoding::ISO_8859_1) =~ /c/
- $'.encoding.should equal(Encoding::ISO_8859_1)
+ it "sets an empty result to the encoding of the source String" do
+ "abc".force_encoding(Encoding::ISO_8859_1) =~ /c/
+ $'.encoding.should equal(Encoding::ISO_8859_1)
+ end
end
end
@@ -190,9 +196,11 @@ describe "Predefined global $+" do
$+.should == 'a'
end
- it "sets the encoding to the encoding of the source String" do
- "abc".force_encoding(Encoding::EUC_JP) =~ /(b)/
- $+.encoding.should equal(Encoding::EUC_JP)
+ with_feature :encoding do
+ it "sets the encoding to the encoding of the source String" do
+ "abc".force_encoding(Encoding::EUC_JP) =~ /(b)/
+ $+.encoding.should equal(Encoding::EUC_JP)
+ end
end
end
@@ -217,9 +225,11 @@ describe "Predefined globals $1..N" do
test("-").should == nil
end
- it "sets the encoding to the encoding of the source String" do
- "abc".force_encoding(Encoding::EUC_JP) =~ /(b)/
- $1.encoding.should equal(Encoding::EUC_JP)
+ with_feature :encoding do
+ it "sets the encoding to the encoding of the source String" do
+ "abc".force_encoding(Encoding::EUC_JP) =~ /(b)/
+ $1.encoding.should equal(Encoding::EUC_JP)
+ end
end
end
@@ -233,12 +243,12 @@ describe "Predefined global $stdout" do
end
it "raises TypeError error if assigned to nil" do
- -> { $stdout = nil }.should raise_error(TypeError)
+ lambda { $stdout = nil }.should raise_error(TypeError)
end
it "raises TypeError error if assigned to object that doesn't respond to #write" do
obj = mock('object')
- -> { $stdout = obj }.should raise_error(TypeError)
+ lambda { $stdout = obj }.should raise_error(TypeError)
obj.stub!(:write)
$stdout = obj
@@ -562,15 +572,15 @@ describe "Predefined global $/" do
obj = mock("$/ value")
obj.should_not_receive(:to_str)
- -> { $/ = obj }.should raise_error(TypeError)
+ lambda { $/ = obj }.should raise_error(TypeError)
end
it "raises a TypeError if assigned a Fixnum" do
- -> { $/ = 1 }.should raise_error(TypeError)
+ lambda { $/ = 1 }.should raise_error(TypeError)
end
it "raises a TypeError if assigned a boolean" do
- -> { $/ = true }.should raise_error(TypeError)
+ lambda { $/ = true }.should raise_error(TypeError)
end
end
@@ -609,15 +619,15 @@ describe "Predefined global $-0" do
obj = mock("$-0 value")
obj.should_not_receive(:to_str)
- -> { $-0 = obj }.should raise_error(TypeError)
+ lambda { $-0 = obj }.should raise_error(TypeError)
end
it "raises a TypeError if assigned a Fixnum" do
- -> { $-0 = 1 }.should raise_error(TypeError)
+ lambda { $-0 = 1 }.should raise_error(TypeError)
end
it "raises a TypeError if assigned a boolean" do
- -> { $-0 = true }.should raise_error(TypeError)
+ lambda { $-0 = true }.should raise_error(TypeError)
end
end
@@ -631,34 +641,7 @@ describe "Predefined global $," do
end
it "raises TypeError if assigned a non-String" do
- -> { $, = Object.new }.should raise_error(TypeError)
- end
-end
-
-describe "Predefined global $." do
- it "can be assigned an Integer" do
- $. = 123
- $..should == 123
- end
-
- it "can be assigned a Float" do
- $. = 123.5
- $..should == 123
- end
-
- it "should call #to_int to convert the object to an Integer" do
- obj = mock("good-value")
- obj.should_receive(:to_int).and_return(321)
-
- $. = obj
- $..should == 321
- end
-
- it "raises TypeError if object can't be converted to an Integer" do
- obj = mock("bad-value")
- obj.should_receive(:to_int).and_return('abc')
-
- -> { $. = obj }.should raise_error(TypeError)
+ lambda { $, = Object.new }.should raise_error(TypeError)
end
end
@@ -771,6 +754,8 @@ __LINE__ String The current line number in the source file. [r/
$LOAD_PATH Array A synonym for $:. [r/o]
$-p Object Set to true if the -p option (which puts an implicit while gets . . . end
loop around your program) is present on the command line. [r/o]
+$SAFE Fixnum The current safe level. This variable’s value may never be
+ reduced by assignment. [thread] (Not implemented in Rubinius)
$VERBOSE Object Set to true if the -v, --version, -W, or -w option is specified on the com-
mand line. Set to false if no option, or -W1 is given. Set to nil if -W0
was specified. Setting this option to true causes the interpreter and some
@@ -800,15 +785,15 @@ describe "Execution variable $:" do
end
it "is read-only" do
- -> {
+ lambda {
$: = []
}.should raise_error(NameError)
- -> {
+ lambda {
$LOAD_PATH = []
}.should raise_error(NameError)
- -> {
+ lambda {
$-I = []
}.should raise_error(NameError)
end
@@ -816,15 +801,15 @@ end
describe "Global variable $\"" do
it "is an alias for $LOADED_FEATURES" do
- $".should equal $LOADED_FEATURES
+ $".object_id.should == $LOADED_FEATURES.object_id
end
it "is read-only" do
- -> {
+ lambda {
$" = []
}.should raise_error(NameError)
- -> {
+ lambda {
$LOADED_FEATURES = []
}.should raise_error(NameError)
end
@@ -832,7 +817,7 @@ end
describe "Global variable $<" do
it "is read-only" do
- -> {
+ lambda {
$< = nil
}.should raise_error(NameError)
end
@@ -840,7 +825,7 @@ end
describe "Global variable $FILENAME" do
it "is read-only" do
- -> {
+ lambda {
$FILENAME = "-"
}.should raise_error(NameError)
end
@@ -848,7 +833,7 @@ end
describe "Global variable $?" do
it "is read-only" do
- -> {
+ lambda {
$? = nil
}.should raise_error(NameError)
end
@@ -861,19 +846,19 @@ end
describe "Global variable $-a" do
it "is read-only" do
- -> { $-a = true }.should raise_error(NameError)
+ lambda { $-a = true }.should raise_error(NameError)
end
end
describe "Global variable $-l" do
it "is read-only" do
- -> { $-l = true }.should raise_error(NameError)
+ lambda { $-l = true }.should raise_error(NameError)
end
end
describe "Global variable $-p" do
it "is read-only" do
- -> { $-p = true }.should raise_error(NameError)
+ lambda { $-p = true }.should raise_error(NameError)
end
end
@@ -972,7 +957,7 @@ describe "Global variable $0" do
end
it "raises a TypeError when not given an object that can be coerced to a String" do
- -> { $0 = nil }.should raise_error(TypeError)
+ lambda { $0 = nil }.should raise_error(TypeError)
end
end
@@ -1014,7 +999,7 @@ describe "The predefined standard object nil" do
end
it "raises a SyntaxError if assigned to" do
- -> { eval("nil = true") }.should raise_error(SyntaxError)
+ lambda { eval("nil = true") }.should raise_error(SyntaxError)
end
end
@@ -1024,7 +1009,7 @@ describe "The predefined standard object true" do
end
it "raises a SyntaxError if assigned to" do
- -> { eval("true = false") }.should raise_error(SyntaxError)
+ lambda { eval("true = false") }.should raise_error(SyntaxError)
end
end
@@ -1034,13 +1019,13 @@ describe "The predefined standard object false" do
end
it "raises a SyntaxError if assigned to" do
- -> { eval("false = nil") }.should raise_error(SyntaxError)
+ lambda { eval("false = nil") }.should raise_error(SyntaxError)
end
end
describe "The self pseudo-variable" do
it "raises a SyntaxError if assigned to" do
- -> { eval("self = 1") }.should raise_error(SyntaxError)
+ lambda { eval("self = 1") }.should raise_error(SyntaxError)
end
end
@@ -1076,33 +1061,44 @@ TRUE TrueClass Synonym for true.
=end
describe "The predefined global constants" do
- before :each do
- @deprecated = Warning[:deprecated]
- Warning[:deprecated] = true
- end
- after :each do
- Warning[:deprecated] = @deprecated
- end
-
- it "includes TRUE" do
- Object.const_defined?(:TRUE).should == true
- -> {
+ ruby_version_is ""..."2.4" do
+ it "includes TRUE" do
+ Object.const_defined?(:TRUE).should == true
TRUE.should equal(true)
- }.should complain(/constant ::TRUE is deprecated/)
- end
+ end
- it "includes FALSE" do
- Object.const_defined?(:FALSE).should == true
- -> {
+ it "includes FALSE" do
+ Object.const_defined?(:FALSE).should == true
FALSE.should equal(false)
- }.should complain(/constant ::FALSE is deprecated/)
- end
+ end
- it "includes NIL" do
- Object.const_defined?(:NIL).should == true
- -> {
+ it "includes NIL" do
+ Object.const_defined?(:NIL).should == true
NIL.should equal(nil)
- }.should complain(/constant ::NIL is deprecated/)
+ end
+ end
+
+ ruby_version_is "2.4" do
+ it "includes TRUE" do
+ Object.const_defined?(:TRUE).should == true
+ -> {
+ TRUE.should equal(true)
+ }.should complain(/constant ::TRUE is deprecated/)
+ end
+
+ it "includes FALSE" do
+ Object.const_defined?(:FALSE).should == true
+ -> {
+ FALSE.should equal(false)
+ }.should complain(/constant ::FALSE is deprecated/)
+ end
+
+ it "includes NIL" do
+ Object.const_defined?(:NIL).should == true
+ -> {
+ NIL.should equal(nil)
+ }.should complain(/constant ::NIL is deprecated/)
+ end
end
it "includes STDIN" do
@@ -1135,108 +1131,110 @@ describe "The predefined global constants" do
end
-describe "The predefined global constant" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
- end
-
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
-
- describe "STDIN" do
- it "has the same external encoding as Encoding.default_external" do
- STDIN.external_encoding.should equal(Encoding.default_external)
+with_feature :encoding do
+ describe "The predefined global constant" do
+ before :each do
+ @external = Encoding.default_external
+ @internal = Encoding.default_internal
end
- it "has the same external encoding as Encoding.default_external when that encoding is changed" do
- Encoding.default_external = Encoding::ISO_8859_16
- STDIN.external_encoding.should equal(Encoding::ISO_8859_16)
+ after :each do
+ Encoding.default_external = @external
+ Encoding.default_internal = @internal
end
- it "has the encodings set by #set_encoding" do
- code = "STDIN.set_encoding Encoding::IBM775, Encoding::IBM866; " \
- "p [STDIN.external_encoding.name, STDIN.internal_encoding.name]"
- ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
- end
+ describe "STDIN" do
+ it "has the same external encoding as Encoding.default_external" do
+ STDIN.external_encoding.should equal(Encoding.default_external)
+ end
- it "retains the encoding set by #set_encoding when Encoding.default_external is changed" do
- code = "STDIN.set_encoding Encoding::IBM775, Encoding::IBM866; " \
- "Encoding.default_external = Encoding::ISO_8859_16;" \
- "p [STDIN.external_encoding.name, STDIN.internal_encoding.name]"
- ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
- end
+ it "has the same external encoding as Encoding.default_external when that encoding is changed" do
+ Encoding.default_external = Encoding::ISO_8859_16
+ STDIN.external_encoding.should equal(Encoding::ISO_8859_16)
+ end
- it "has nil for the internal encoding" do
- STDIN.internal_encoding.should be_nil
- end
+ it "has the encodings set by #set_encoding" do
+ code = "STDIN.set_encoding Encoding::IBM775, Encoding::IBM866; " \
+ "p [STDIN.external_encoding.name, STDIN.internal_encoding.name]"
+ ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
+ end
- it "has nil for the internal encoding despite Encoding.default_internal being changed" do
- Encoding.default_internal = Encoding::IBM437
- STDIN.internal_encoding.should be_nil
- end
- end
+ it "retains the encoding set by #set_encoding when Encoding.default_external is changed" do
+ code = "STDIN.set_encoding Encoding::IBM775, Encoding::IBM866; " \
+ "Encoding.default_external = Encoding::ISO_8859_16;" \
+ "p [STDIN.external_encoding.name, STDIN.internal_encoding.name]"
+ ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
+ end
- describe "STDOUT" do
- it "has nil for the external encoding" do
- STDOUT.external_encoding.should be_nil
- end
+ it "has nil for the internal encoding" do
+ STDIN.internal_encoding.should be_nil
+ end
- it "has nil for the external encoding despite Encoding.default_external being changed" do
- Encoding.default_external = Encoding::ISO_8859_1
- STDOUT.external_encoding.should be_nil
+ it "has nil for the internal encoding despite Encoding.default_internal being changed" do
+ Encoding.default_internal = Encoding::IBM437
+ STDIN.internal_encoding.should be_nil
+ end
end
- it "has the encodings set by #set_encoding" do
- code = "STDOUT.set_encoding Encoding::IBM775, Encoding::IBM866; " \
- "p [STDOUT.external_encoding.name, STDOUT.internal_encoding.name]"
- ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
- end
+ describe "STDOUT" do
+ it "has nil for the external encoding" do
+ STDOUT.external_encoding.should be_nil
+ end
- it "has nil for the internal encoding" do
- STDOUT.internal_encoding.should be_nil
- end
+ it "has nil for the external encoding despite Encoding.default_external being changed" do
+ Encoding.default_external = Encoding::ISO_8859_1
+ STDOUT.external_encoding.should be_nil
+ end
- it "has nil for the internal encoding despite Encoding.default_internal being changed" do
- Encoding.default_internal = Encoding::IBM437
- STDOUT.internal_encoding.should be_nil
- end
- end
+ it "has the encodings set by #set_encoding" do
+ code = "STDOUT.set_encoding Encoding::IBM775, Encoding::IBM866; " \
+ "p [STDOUT.external_encoding.name, STDOUT.internal_encoding.name]"
+ ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
+ end
- describe "STDERR" do
- it "has nil for the external encoding" do
- STDERR.external_encoding.should be_nil
- end
+ it "has nil for the internal encoding" do
+ STDOUT.internal_encoding.should be_nil
+ end
- it "has nil for the external encoding despite Encoding.default_external being changed" do
- Encoding.default_external = Encoding::ISO_8859_1
- STDERR.external_encoding.should be_nil
+ it "has nil for the internal encoding despite Encoding.default_internal being changed" do
+ Encoding.default_internal = Encoding::IBM437
+ STDOUT.internal_encoding.should be_nil
+ end
end
- it "has the encodings set by #set_encoding" do
- code = "STDERR.set_encoding Encoding::IBM775, Encoding::IBM866; " \
- "p [STDERR.external_encoding.name, STDERR.internal_encoding.name]"
- ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
- end
+ describe "STDERR" do
+ it "has nil for the external encoding" do
+ STDERR.external_encoding.should be_nil
+ end
- it "has nil for the internal encoding" do
- STDERR.internal_encoding.should be_nil
- end
+ it "has nil for the external encoding despite Encoding.default_external being changed" do
+ Encoding.default_external = Encoding::ISO_8859_1
+ STDERR.external_encoding.should be_nil
+ end
- it "has nil for the internal encoding despite Encoding.default_internal being changed" do
- Encoding.default_internal = Encoding::IBM437
- STDERR.internal_encoding.should be_nil
+ it "has the encodings set by #set_encoding" do
+ code = "STDERR.set_encoding Encoding::IBM775, Encoding::IBM866; " \
+ "p [STDERR.external_encoding.name, STDERR.internal_encoding.name]"
+ ruby_exe(code).chomp.should == %{["IBM775", "IBM866"]}
+ end
+
+ it "has nil for the internal encoding" do
+ STDERR.internal_encoding.should be_nil
+ end
+
+ it "has nil for the internal encoding despite Encoding.default_internal being changed" do
+ Encoding.default_internal = Encoding::IBM437
+ STDERR.internal_encoding.should be_nil
+ end
end
- end
- describe "ARGV" do
- it "contains Strings encoded in locale Encoding" do
- code = fixture __FILE__, "argv_encoding.rb"
- result = ruby_exe(code, args: "a b")
- encoding = Encoding.default_external
- result.chomp.should == %{["#{encoding}", "#{encoding}"]}
+ describe "ARGV" do
+ it "contains Strings encoded in locale Encoding" do
+ code = fixture __FILE__, "argv_encoding.rb"
+ result = ruby_exe(code, args: "a b")
+ encoding = Encoding.default_external
+ result.chomp.should == %{["#{encoding}", "#{encoding}"]}
+ end
end
end
end
diff --git a/spec/ruby/language/private_spec.rb b/spec/ruby/language/private_spec.rb
index ddf185e6d2..796c0c1711 100644
--- a/spec/ruby/language/private_spec.rb
+++ b/spec/ruby/language/private_spec.rb
@@ -1,15 +1,15 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/private'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/private', __FILE__)
describe "The private keyword" do
it "marks following methods as being private" do
a = Private::A.new
a.methods.should_not include(:bar)
- -> { a.bar }.should raise_error(NoMethodError)
+ lambda { a.bar }.should raise_error(NoMethodError)
b = Private::B.new
b.methods.should_not include(:bar)
- -> { b.bar }.should raise_error(NoMethodError)
+ lambda { b.bar }.should raise_error(NoMethodError)
end
# def expr.meth() methods are always public
@@ -22,7 +22,7 @@ describe "The private keyword" do
c.methods.should include(:baz)
c.baz
Private::B.public_class_method1.should == 1
- -> { Private::B.private_class_method1 }.should raise_error(NoMethodError)
+ lambda { Private::B.private_class_method1 }.should raise_error(NoMethodError)
end
it "is no longer in effect when the class is closed" do
@@ -42,12 +42,12 @@ describe "The private keyword" do
klass.class_eval do
private :foo
end
- -> { f.foo }.should raise_error(NoMethodError)
+ lambda { f.foo }.should raise_error(NoMethodError)
end
- it "changes visibility of previously called methods with same send/call site" do
+ it "changes visiblity of previously called methods with same send/call site" do
g = ::Private::G.new
- -> {
+ lambda {
2.times do
g.foo
module ::Private
@@ -61,7 +61,7 @@ describe "The private keyword" do
it "changes the visibility of the existing method in the subclass" do
::Private::A.new.foo.should == 'foo'
- -> { ::Private::H.new.foo }.should raise_error(NoMethodError)
+ lambda {::Private::H.new.foo}.should raise_error(NoMethodError)
::Private::H.new.send(:foo).should == 'foo'
end
end
diff --git a/spec/ruby/language/proc_spec.rb b/spec/ruby/language/proc_spec.rb
index c44e711d2b..bbef318826 100644
--- a/spec/ruby/language/proc_spec.rb
+++ b/spec/ruby/language/proc_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "A Proc" do
it "captures locals from the surrounding scope" do
@@ -21,7 +21,7 @@ describe "A Proc" do
@l.call.should == 1
end
- it "raises an ArgumentError if a value is passed" do
+ it "raises an ArgumentErro if a value is passed" do
lambda { @l.call(0) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/language/range_spec.rb b/spec/ruby/language/range_spec.rb
deleted file mode 100644
index c720c5b98e..0000000000
--- a/spec/ruby/language/range_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/classes'
-
-describe "Literal Ranges" do
- it "creates range object" do
- (1..10).should == Range.new(1, 10)
- end
-
- it "creates range with excluded right boundary" do
- (1...10).should == Range.new(1, 10, true)
- end
-
- ruby_version_is "2.6" do
- it "creates endless ranges" do
- eval("(1..)").should == Range.new(1, nil)
- eval("(1...)").should == Range.new(1, nil, true)
- end
- end
-end
diff --git a/spec/ruby/language/redo_spec.rb b/spec/ruby/language/redo_spec.rb
index 57532553b3..53fd30b4f2 100644
--- a/spec/ruby/language/redo_spec.rb
+++ b/spec/ruby/language/redo_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The redo statement" do
it "restarts block execution if used within block" do
a = []
- -> {
+ lambda {
a << 1
redo if a.size < 2
a << 2
@@ -58,7 +58,7 @@ describe "The redo statement" do
describe "in a method" do
it "is invalid and raises a SyntaxError" do
- -> {
+ lambda {
eval("def m; redo; end")
}.should raise_error(SyntaxError)
end
diff --git a/spec/ruby/language/regexp/anchors_spec.rb b/spec/ruby/language/regexp/anchors_spec.rb
index 0129e255da..c6a620a221 100644
--- a/spec/ruby/language/regexp/anchors_spec.rb
+++ b/spec/ruby/language/regexp/anchors_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexps with anchors" do
it "supports ^ (line start anchor)" do
diff --git a/spec/ruby/language/regexp/back-references_spec.rb b/spec/ruby/language/regexp/back-references_spec.rb
index 81015ac21e..607f4463fd 100644
--- a/spec/ruby/language/regexp/back-references_spec.rb
+++ b/spec/ruby/language/regexp/back-references_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexps with back-references" do
it "saves match data in the $~ pseudo-global variable" do
@@ -7,7 +7,7 @@ describe "Regexps with back-references" do
$~.to_a.should == ["ll"]
end
- it "saves captures in numbered $[1-N] variables" do
+ it "saves captures in numbered $[1-9] variables" do
"1234567890" =~ /(1)(2)(3)(4)(5)(6)(7)(8)(9)(0)/
$~.to_a.should == ["1234567890", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
$1.should == "1"
@@ -19,7 +19,6 @@ describe "Regexps with back-references" do
$7.should == "7"
$8.should == "8"
$9.should == "9"
- $10.should == "0"
end
it "will not clobber capture variables across threads" do
@@ -46,8 +45,4 @@ describe "Regexps with back-references" do
it "resets nested \<n> backreference before match of outer subexpression" do
/(a\1?){2}/.match("aaaa").to_a.should == ["aa", "a"]
end
-
- it "can match an optional quote, followed by content, followed by a matching quote, as the whole string" do
- /^("|)(.*)\1$/.match('x').to_a.should == ["x", "", "x"]
- end
end
diff --git a/spec/ruby/language/regexp/character_classes_spec.rb b/spec/ruby/language/regexp/character_classes_spec.rb
index 5f4221e213..ce66d8e65f 100644
--- a/spec/ruby/language/regexp/character_classes_spec.rb
+++ b/spec/ruby/language/regexp/character_classes_spec.rb
@@ -1,6 +1,6 @@
# coding: utf-8
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexp with character classes" do
it "supports \\w (word character)" do
@@ -89,7 +89,7 @@ describe "Regexp with character classes" do
/[^[:lower:]A-C]+/.match("abcABCDEF123def").to_a.should == ["DEF123"] # negated character class
/[:alnum:]+/.match("a:l:n:u:m").to_a.should == ["a:l:n:u:m"] # should behave like regular character class composed of the individual letters
/[\[:alnum:]+/.match("[:a:l:n:u:m").to_a.should == ["[:a:l:n:u:m"] # should behave like regular character class composed of the individual letters
- -> { eval('/[[:alpha:]-[:digit:]]/') }.should raise_error(SyntaxError) # can't use character class as a start value of range
+ lambda { eval('/[[:alpha:]-[:digit:]]/') }.should raise_error(SyntaxError) # can't use character class as a start value of range
end
it "matches ASCII characters with [[:ascii:]]" do
@@ -609,23 +609,25 @@ describe "Regexp with character classes" do
"루비(Ruby)".match(/\p{Hangul}+/u).to_a.should == ["루비"]
end
- it "supports \\X (unicode 9.0 with UTR #51 workarounds)" do
- # simple emoji without any fancy modifier or ZWJ
- /\X/.match("\u{1F98A}").to_a.should == ["🦊"]
+ ruby_version_is "2.4" do
+ it "supports \\X (unicode 9.0 with UTR #51 workarounds)" do
+ # simple emoji without any fancy modifier or ZWJ
+ /\X/.match("\u{1F98A}").to_a.should == ["🦊"]
- # skin tone modifier
- /\X/.match("\u{1F918}\u{1F3FD}").to_a.should == ["🤘ðŸ½"]
+ # skin tone modifier
+ /\X/.match("\u{1F918}\u{1F3FD}").to_a.should == ["🤘ðŸ½"]
- # emoji joined with ZWJ
- /\X/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}").to_a.should == ["ðŸ³ï¸â€ðŸŒˆ"]
- /\X/.match("\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}").to_a.should == ["👩â€ðŸ‘©â€ðŸ‘§â€ðŸ‘¦"]
+ # emoji joined with ZWJ
+ /\X/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}").to_a.should == ["ðŸ³ï¸â€ðŸŒˆ"]
+ /\X/.match("\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}").to_a.should == ["👩â€ðŸ‘©â€ðŸ‘§â€ðŸ‘¦"]
- # without the ZWJ
- /\X+/.match("\u{1F3F3}\u{FE0F}\u{1F308}").to_a.should == ["ðŸ³ï¸ðŸŒˆ"]
- /\X+/.match("\u{1F469}\u{1F469}\u{1F467}\u{1F466}").to_a.should == ["👩👩👧👦"]
+ # without the ZWJ
+ /\X+/.match("\u{1F3F3}\u{FE0F}\u{1F308}").to_a.should == ["ðŸ³ï¸ðŸŒˆ"]
+ /\X+/.match("\u{1F469}\u{1F469}\u{1F467}\u{1F466}").to_a.should == ["👩👩👧👦"]
- # both of the ZWJ combined
- /\X+/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}")
- .to_a.should == ["ðŸ³ï¸â€ðŸŒˆðŸ‘©â€ðŸ‘©â€ðŸ‘§â€ðŸ‘¦"]
+ # both of the ZWJ combined
+ /\X+/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}")
+ .to_a.should == ["ðŸ³ï¸â€ðŸŒˆðŸ‘©â€ðŸ‘©â€ðŸ‘§â€ðŸ‘¦"]
+ end
end
end
diff --git a/spec/ruby/language/regexp/encoding_spec.rb b/spec/ruby/language/regexp/encoding_spec.rb
index b8559c6b27..1f62244a28 100644
--- a/spec/ruby/language/regexp/encoding_spec.rb
+++ b/spec/ruby/language/regexp/encoding_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexps with encoding modifiers" do
it "supports /e (EUC encoding)" do
@@ -42,20 +42,16 @@ describe "Regexps with encoding modifiers" do
/./n.encoding.should == Encoding::US_ASCII
end
- it 'uses BINARY when is not initialized' do
- Regexp.allocate.encoding.should == Encoding::BINARY
- end
-
- it 'uses BINARY as /n encoding if not all chars are 7-bit' do
- /\xFF/n.encoding.should == Encoding::BINARY
+ it 'uses ASCII-8BIT as /n encoding if not all chars are 7-bit' do
+ /\xFF/n.encoding.should == Encoding::ASCII_8BIT
end
it 'preserves US-ASCII as /n encoding through interpolation if all chars are 7-bit' do
/.#{/./}/n.encoding.should == Encoding::US_ASCII
end
- it 'preserves BINARY as /n encoding through interpolation if all chars are 7-bit' do
- /\xFF#{/./}/n.encoding.should == Encoding::BINARY
+ it 'preserves ASCII-8BIT as /n encoding through interpolation if all chars are 7-bit' do
+ /\xFF#{/./}/n.encoding.should == Encoding::ASCII_8BIT
end
it "supports /s (Windows_31J encoding)" do
@@ -104,16 +100,4 @@ describe "Regexps with encoding modifiers" do
it "selects last of multiple encoding specifiers" do
/foo/ensuensuens.should == /foo/s
end
-
- it "raises Encoding::CompatibilityError when trying match against different encodings" do
- -> { /\A[[:space:]]*\z/.match(" ".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError)
- end
-
- it "raises Encoding::CompatibilityError when trying match? against different encodings" do
- -> { /\A[[:space:]]*\z/.match?(" ".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError)
- end
-
- it "raises Encoding::CompatibilityError when trying =~ against different encodings" do
- -> { /\A[[:space:]]*\z/ =~ " ".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError)
- end
end
diff --git a/spec/ruby/language/regexp/escapes_spec.rb b/spec/ruby/language/regexp/escapes_spec.rb
index 14e1424d47..50ac22e51e 100644
--- a/spec/ruby/language/regexp/escapes_spec.rb
+++ b/spec/ruby/language/regexp/escapes_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexps with escape characters" do
it "they're supported" do
@@ -48,7 +48,7 @@ describe "Regexps with escape characters" do
/\x0AA/.match("\nA").to_a.should == ["\nA"]
/\xAG/.match("\nG").to_a.should == ["\nG"]
# Non-matches
- -> { eval('/\xG/') }.should raise_error(SyntaxError)
+ lambda { eval('/\xG/') }.should raise_error(SyntaxError)
# \x{7HHHHHHH} wide hexadecimal char (character code point value)
end
@@ -67,11 +67,11 @@ describe "Regexps with escape characters" do
/\cJ/.match("\r").should be_nil
# Parsing precedence
- /\cJ+/.match("\n\n").to_a.should == ["\n\n"] # Quantifiers apply to entire escape sequence
+ /\cJ+/.match("\n\n").to_a.should == ["\n\n"] # Quantifers apply to entire escape sequence
/\\cJ/.match("\\cJ").to_a.should == ["\\cJ"]
- -> { eval('/[abc\x]/') }.should raise_error(SyntaxError) # \x is treated as a escape sequence even inside a character class
+ lambda { eval('/[abc\x]/') }.should raise_error(SyntaxError) # \x is treated as a escape sequence even inside a character class
# Syntax error
- -> { eval('/\c/') }.should raise_error(SyntaxError)
+ lambda { eval('/\c/') }.should raise_error(SyntaxError)
# \cx control char (character code point value)
# \C-x control char (character code point value)
diff --git a/spec/ruby/language/regexp/grouping_spec.rb b/spec/ruby/language/regexp/grouping_spec.rb
index 8806d06746..443cab7ee0 100644
--- a/spec/ruby/language/regexp/grouping_spec.rb
+++ b/spec/ruby/language/regexp/grouping_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexps with grouping" do
it "support ()" do
@@ -12,7 +12,7 @@ describe "Regexps with grouping" do
end
it "raises a SyntaxError when parentheses aren't balanced" do
- -> { eval "/(hay(st)ack/" }.should raise_error(SyntaxError)
+ lambda { eval "/(hay(st)ack/" }.should raise_error(SyntaxError)
end
it "supports (?: ) (non-capturing group)" do
diff --git a/spec/ruby/language/regexp/interpolation_spec.rb b/spec/ruby/language/regexp/interpolation_spec.rb
index ed0b724763..5536c718f1 100644
--- a/spec/ruby/language/regexp/interpolation_spec.rb
+++ b/spec/ruby/language/regexp/interpolation_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexps with interpolation" do
@@ -41,9 +41,9 @@ describe "Regexps with interpolation" do
it "throws RegexpError for malformed interpolation" do
s = ""
- -> { /(#{s}/ }.should raise_error(RegexpError)
+ lambda { /(#{s}/ }.should raise_error(RegexpError)
s = "("
- -> { /#{s}/ }.should raise_error(RegexpError)
+ lambda { /#{s}/ }.should raise_error(RegexpError)
end
it "allows interpolation in extended mode" do
diff --git a/spec/ruby/language/regexp/modifiers_spec.rb b/spec/ruby/language/regexp/modifiers_spec.rb
index 2f5522bc8a..a7052a941c 100644
--- a/spec/ruby/language/regexp/modifiers_spec.rb
+++ b/spec/ruby/language/regexp/modifiers_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Regexps with modifiers" do
+describe "Regexps with modifers" do
it "supports /i (case-insensitive)" do
/foo/i.match("FOO").to_a.should == ["FOO"]
end
@@ -36,12 +36,14 @@ describe "Regexps with modifiers" do
/foo/imox.match("foo").to_a.should == ["foo"]
/foo/imoximox.match("foo").to_a.should == ["foo"]
- -> { eval('/foo/a') }.should raise_error(SyntaxError)
+ lambda { eval('/foo/a') }.should raise_error(SyntaxError)
end
- it "supports (?~) (absent operator)" do
- Regexp.new("(?~foo)").match("hello").to_a.should == ["hello"]
- "foo".scan(Regexp.new("(?~foo)")).should == ["fo","o",""]
+ ruby_version_is "2.4" do
+ it "supports (?~) (absent operator)" do
+ Regexp.new("(?~foo)").match("hello").to_a.should == ["hello"]
+ "foo".scan(Regexp.new("(?~foo)")).should == ["fo","o",""]
+ end
end
it "supports (?imx-imx) (inline modifiers)" do
@@ -76,7 +78,7 @@ describe "Regexps with modifiers" do
/(?i-i)foo/.match("FOO").should be_nil
/(?ii)foo/.match("FOO").to_a.should == ["FOO"]
/(?-)foo/.match("foo").to_a.should == ["foo"]
- -> { eval('/(?o)/') }.should raise_error(SyntaxError)
+ lambda { eval('/(?o)/') }.should raise_error(SyntaxError)
end
it "supports (?imx-imx:expr) (scoped inline modifiers)" do
@@ -96,7 +98,7 @@ describe "Regexps with modifiers" do
/(?i-i:foo)/.match("FOO").should be_nil
/(?ii:foo)/.match("FOO").to_a.should == ["FOO"]
/(?-:)foo/.match("foo").to_a.should == ["foo"]
- -> { eval('/(?o:)/') }.should raise_error(SyntaxError)
+ lambda { eval('/(?o:)/') }.should raise_error(SyntaxError)
end
it "supports . with /m" do
@@ -104,7 +106,7 @@ describe "Regexps with modifiers" do
/./m.match("\n").to_a.should == ["\n"]
end
- it "supports ASCII/Unicode modifiers" do
+ it "supports ASII/Unicode modifiers" do
eval('/(?a)[[:alpha:]]+/').match("a\u3042").to_a.should == ["a"]
eval('/(?d)[[:alpha:]]+/').match("a\u3042").to_a.should == ["a\u3042"]
eval('/(?u)[[:alpha:]]+/').match("a\u3042").to_a.should == ["a\u3042"]
diff --git a/spec/ruby/language/regexp/repetition_spec.rb b/spec/ruby/language/regexp/repetition_spec.rb
index 7bb767ccaf..2fc8a74a47 100644
--- a/spec/ruby/language/regexp/repetition_spec.rb
+++ b/spec/ruby/language/regexp/repetition_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Regexps with repetition" do
it "supports * (0 or more of previous subexpression)" do
@@ -34,11 +34,20 @@ describe "Regexps with repetition" do
/.([0-9]){3,5}?foo/.match("9876543210foo").to_a.should == ["543210foo", "0"]
end
- it "does not treat {m,n}+ as possessive" do
- -> {
+ ruby_version_is ""..."2.4" do
+ it "does not treat {m,n}+ as possessive" do
@regexp = eval "/foo(A{0,1}+)Abar/"
- }.should complain(/nested repeat operator/)
- @regexp.match("fooAAAbar").to_a.should == ["fooAAAbar", "AA"]
+ @regexp.match("fooAAAbar").to_a.should == ["fooAAAbar", "AA"]
+ end
+ end
+
+ ruby_version_is "2.4" do
+ it "does not treat {m,n}+ as possessive" do
+ -> {
+ @regexp = eval "/foo(A{0,1}+)Abar/"
+ }.should complain(/nested repeat operato/)
+ @regexp.match("fooAAAbar").to_a.should == ["fooAAAbar", "AA"]
+ end
end
it "supports ? (0 or 1 of previous subexpression)" do
diff --git a/spec/ruby/language/regexp_spec.rb b/spec/ruby/language/regexp_spec.rb
index 67c7c034e9..d4b0c81128 100644
--- a/spec/ruby/language/regexp_spec.rb
+++ b/spec/ruby/language/regexp_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Literal Regexps" do
it "matches against $_ (last input) in a conditional if no explicit matchee provided" do
@@ -27,7 +27,7 @@ describe "Literal Regexps" do
end
it "throws SyntaxError for malformed literals" do
- -> { eval('/(/') }.should raise_error(SyntaxError)
+ lambda { eval('/(/') }.should raise_error(SyntaxError)
end
#############################################################################
@@ -54,7 +54,7 @@ describe "Literal Regexps" do
it "disallows first part of paired delimiters to be used as non-paired delimiters" do
LanguageSpecs.paired_delimiters.each do |p0, p1|
- -> { eval("%r#{p0} foo #{p0}") }.should raise_error(SyntaxError)
+ lambda { eval("%r#{p0} foo #{p0}") }.should raise_error(SyntaxError)
end
end
@@ -65,11 +65,11 @@ describe "Literal Regexps" do
end
it "disallows alphabets as non-paired delimiter with %r" do
- -> { eval('%ra foo a') }.should raise_error(SyntaxError)
+ lambda { eval('%ra foo a') }.should raise_error(SyntaxError)
end
it "disallows spaces after %r and delimiter" do
- -> { eval('%r !foo!') }.should raise_error(SyntaxError)
+ lambda { eval('%r !foo!') }.should raise_error(SyntaxError)
end
it "allows unescaped / to be used with %r" do
@@ -97,7 +97,7 @@ describe "Literal Regexps" do
it "supports (?> ) (embedded subexpression)" do
/(?>foo)(?>bar)/.match("foobar").to_a.should == ["foobar"]
- /(?>foo*)obar/.match("foooooooobar").should be_nil # it is possessive
+ /(?>foo*)obar/.match("foooooooobar").should be_nil # it is possesive
end
it "supports (?# )" do
@@ -147,31 +147,4 @@ describe "Literal Regexps" do
pattern.should_not =~ 'fooF'
pattern.should_not =~ 'T'
end
-
- escapable_terminators = ['!', '"', '#', '%', '&', "'", ',', '-', ':', ';', '@', '_', '`']
-
- it "supports escaping characters when used as a terminator" do
- escapable_terminators.each do |c|
- ref = "(?-mix:#{c})"
- pattern = eval("%r" + c + "\\" + c + c)
- pattern.to_s.should == ref
- end
- end
-
- it "treats an escaped non-escapable character normally when used as a terminator" do
- all_terminators = [*("!".."/"), *(":".."@"), *("[".."`"), *("{".."~")]
- special_cases = ['(', '{', '[', '<', '\\', '=', '~']
- (all_terminators - special_cases - escapable_terminators).each do |c|
- ref = "(?-mix:\\#{c})"
- pattern = eval("%r" + c + "\\" + c + c)
- pattern.to_s.should == ref
- end
- end
-
- it "support handling unicode 9.0 characters with POSIX bracket expressions" do
- char_lowercase = "\u{104D8}" # OSAGE SMALL LETTER A
- /[[:lower:]]/.match(char_lowercase).to_s.should == char_lowercase
- char_uppercase = "\u{104B0}" # OSAGE CAPITAL LETTER A
- /[[:upper:]]/.match(char_uppercase).to_s.should == char_uppercase
- end
end
diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb
index a912e17431..0dc8894740 100644
--- a/spec/ruby/language/rescue_spec.rb
+++ b/spec/ruby/language/rescue_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/rescue'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/rescue', __FILE__)
class SpecificExampleException < StandardError
end
@@ -54,7 +54,7 @@ describe "The rescue keyword" do
end
it "can rescue multiple raised exceptions with a single rescue block" do
- [->{raise ArbitraryException}, ->{raise SpecificExampleException}].map do |block|
+ [lambda{raise ArbitraryException}, lambda{raise SpecificExampleException}].map do |block|
begin
block.call
rescue SpecificExampleException, ArbitraryException
@@ -72,7 +72,7 @@ describe "The rescue keyword" do
end
caught_it.should be_true
caught = []
- [->{raise ArbitraryException}, ->{raise SpecificExampleException}].each do |block|
+ [lambda{raise ArbitraryException}, lambda{raise SpecificExampleException}].each do |block|
begin
block.call
rescue *exception_list
@@ -94,7 +94,7 @@ describe "The rescue keyword" do
end
caught_it.should be_true
caught = []
- [->{raise ArbitraryException}, ->{raise SpecificExampleException}].each do |block|
+ [lambda{raise ArbitraryException}, lambda{raise SpecificExampleException}].each do |block|
begin
block.call
rescue ArbitraryException, *exception_list
@@ -108,7 +108,7 @@ describe "The rescue keyword" do
end
it "will only rescue the specified exceptions when doing a splat rescue" do
- -> do
+ lambda do
begin
raise OtherCustomException, "not rescued!"
rescue *exception_list
@@ -142,19 +142,6 @@ describe "The rescue keyword" do
ScratchPad.recorded.should == [:standard_error]
end
- it "rescues the exception in the deepest rescue block declared to handle the appropriate exception type" do
- begin
- begin
- RescueSpecs.raise_standard_error
- rescue ArgumentError
- end
- rescue StandardError => e
- e.backtrace.first.should include ":in `raise_standard_error'"
- else
- fail("exception wasn't handled by the correct rescue block")
- end
- end
-
it "will execute an else block only if no exceptions were raised" do
result = begin
ScratchPad << :one
@@ -208,34 +195,18 @@ describe "The rescue keyword" do
ScratchPad.recorded.should == [:one, :else_ran, :ensure_ran, :outside_begin]
end
- ruby_version_is ''...'2.6' do
- it "will execute an else block even without rescue and ensure" do
- -> {
- eval <<-ruby
- begin
- ScratchPad << :begin
- else
- ScratchPad << :else
- end
- ruby
- }.should complain(/else without rescue is useless/)
+ it "will execute an else block even without rescue and ensure" do
+ lambda {
+ eval <<-ruby
+ begin
+ ScratchPad << :begin
+ else
+ ScratchPad << :else
+ end
+ ruby
+ }.should complain(/else without rescue is useless/)
- ScratchPad.recorded.should == [:begin, :else]
- end
- end
-
- ruby_version_is '2.6' do
- it "raises SyntaxError when else is used without rescue and ensure" do
- -> {
- eval <<-ruby
- begin
- ScratchPad << :begin
- else
- ScratchPad << :else
- end
- ruby
- }.should raise_error(SyntaxError, /else without rescue is useless/)
- end
+ ScratchPad.recorded.should == [:begin, :else]
end
it "will not execute an else block if an exception was raised" do
@@ -294,7 +265,7 @@ describe "The rescue keyword" do
end
it "will not rescue errors raised in an else block in the rescue block above it" do
- -> do
+ lambda do
begin
ScratchPad << :one
rescue Exception
@@ -329,7 +300,7 @@ describe "The rescue keyword" do
[ Exception.new, NoMemoryError.new, ScriptError.new, SecurityError.new,
SignalException.new('INT'), SystemExit.new, SystemStackError.new
].each do |exception|
- -> {
+ lambda {
begin
raise exception
rescue
@@ -361,7 +332,7 @@ describe "The rescue keyword" do
it "only accepts Module or Class in rescue clauses" do
rescuer = 42
- -> {
+ lambda {
begin
raise "error"
rescue rescuer
@@ -373,7 +344,7 @@ describe "The rescue keyword" do
it "only accepts Module or Class in splatted rescue clauses" do
rescuer = [42]
- -> {
+ lambda {
begin
raise "error"
rescue *rescuer
@@ -384,23 +355,11 @@ describe "The rescue keyword" do
end
it "evaluates rescue expressions only when needed" do
+ invalid_rescuer = Object.new
begin
- ScratchPad << :foo
- rescue -> { ScratchPad << :bar; StandardError }.call
- end
-
- ScratchPad.recorded.should == [:foo]
- end
-
- it "suppresses exception from block when raises one from rescue expression" do
- -> {
- begin
- raise "from block"
- rescue (raise "from rescue expression")
- end
- }.should raise_error(RuntimeError, "from rescue expression") do |e|
- e.cause.message.should == "from block"
- end
+ :foo
+ rescue invalid_rescuer
+ end.should == :foo
end
it "should splat the handling Error classes" do
@@ -424,7 +383,7 @@ describe "The rescue keyword" do
end
it "does not allow rescue in {} block" do
- -> {
+ lambda {
eval <<-ruby
lambda {
raise SpecificExampleException
@@ -449,14 +408,22 @@ describe "The rescue keyword" do
end
end
- it "allows 'rescue' in method arguments" do
- two = eval '1.+ (raise("Error") rescue 1)'
- two.should == 2
+ ruby_version_is ""..."2.4" do
+ it "fails when using 'rescue' in method arguments" do
+ lambda { eval '1.+ (1 rescue 1)' }.should raise_error(SyntaxError)
+ end
end
- it "requires the 'rescue' in method arguments to be wrapped in parens" do
- -> { eval '1.+(1 rescue 1)' }.should raise_error(SyntaxError)
- eval('1.+((1 rescue 1))').should == 2
+ ruby_version_is "2.4" do
+ it "allows 'rescue' in method arguments" do
+ two = eval '1.+ (raise("Error") rescue 1)'
+ two.should == 2
+ end
+
+ it "requires the 'rescue' in method arguments to be wrapped in parens" do
+ lambda { eval '1.+(1 rescue 1)' }.should raise_error(SyntaxError)
+ eval('1.+((1 rescue 1))').should == 2
+ end
end
describe "inline form" do
@@ -466,7 +433,7 @@ describe "The rescue keyword" do
end
it "doesn't except rescue expression" do
- -> {
+ lambda {
eval <<-ruby
a = 1 rescue RuntimeError 2
ruby
@@ -477,7 +444,7 @@ describe "The rescue keyword" do
a = raise(StandardError) rescue 1
a.should == 1
- -> {
+ lambda {
a = raise(Exception) rescue 1
}.should raise_error(Exception)
end
diff --git a/spec/ruby/language/retry_spec.rb b/spec/ruby/language/retry_spec.rb
index ee5377946f..96e69b763a 100644
--- a/spec/ruby/language/retry_spec.rb
+++ b/spec/ruby/language/retry_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The retry statement" do
it "re-executes the closest block" do
@@ -32,7 +32,7 @@ describe "The retry statement" do
end
it "raises a SyntaxError when used outside of a begin statement" do
- -> { eval 'retry' }.should raise_error(SyntaxError)
+ lambda { eval 'retry' }.should raise_error(SyntaxError)
end
end
diff --git a/spec/ruby/language/return_spec.rb b/spec/ruby/language/return_spec.rb
index 7eef6d06ca..ba4bbfb5f3 100644
--- a/spec/ruby/language/return_spec.rb
+++ b/spec/ruby/language/return_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/return'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/return', __FILE__)
describe "The return keyword" do
it "returns any object directly" do
@@ -159,7 +159,7 @@ describe "The return keyword" do
end
it "executes the ensure clause when begin/ensure are inside a lambda" do
- -> do
+ lambda do
begin
return
ensure
@@ -176,15 +176,15 @@ describe "The return keyword" do
end
it "causes lambda to return nil if invoked without any arguments" do
- -> { return; 456 }.call.should be_nil
+ lambda { return; 456 }.call.should be_nil
end
it "causes lambda to return nil if invoked with an empty expression" do
- -> { return (); 456 }.call.should be_nil
+ lambda { return (); 456 }.call.should be_nil
end
it "causes lambda to return the value passed to return" do
- -> { return 123; 456 }.call.should == 123
+ lambda { return 123; 456 }.call.should == 123
end
it "causes the method that lexically encloses the block to return" do
@@ -362,7 +362,7 @@ describe "The return keyword" do
END_OF_CODE
end
- ruby_bug "#14061", "2.4"..."2.5" do
+ ruby_bug "#14061", "2.4"..."2.6" do
it "fires ensure block before returning while loads file" do
File.write(@filename, <<-END_OF_CODE)
ScratchPad << "before begin"
@@ -413,7 +413,7 @@ describe "The return keyword" do
ruby_version_is ""..."2.5" do
it "is allowed" do
File.write(@filename, <<-END_OF_CODE)
- class ReturnSpecs::A
+ class A
ScratchPad << "before return"
return
@@ -429,7 +429,7 @@ describe "The return keyword" do
ruby_version_is "2.5" do
it "raises a SyntaxError" do
File.write(@filename, <<-END_OF_CODE)
- class ReturnSpecs::A
+ class A
ScratchPad << "before return"
return
@@ -442,22 +442,6 @@ describe "The return keyword" do
end
end
- describe "within a block within a class" do
- ruby_version_is "2.7" do
- it "is not allowed" do
- File.write(@filename, <<-END_OF_CODE)
- class ReturnSpecs::A
- ScratchPad << "before return"
- 1.times { return }
- ScratchPad << "after return"
- end
- END_OF_CODE
-
- -> { load @filename }.should raise_error(LocalJumpError)
- end
- end
- end
-
describe "file loading" do
it "stops file loading and execution" do
File.write(@filename, <<-END_OF_CODE)
@@ -485,25 +469,13 @@ describe "The return keyword" do
end
describe "return with argument" do
- ruby_version_is ""..."2.7" do
- it "does not affect exit status" do
- ruby_exe(<<-END_OF_CODE).should == ""
- return 10
- END_OF_CODE
-
- $?.exitstatus.should == 0
- end
- end
-
- ruby_version_is "2.7" do
- it "warns but does not affect exit status" do
- err = ruby_exe(<<-END_OF_CODE, args: "2>&1")
- return 10
- END_OF_CODE
- $?.exitstatus.should == 0
+ # https://bugs.ruby-lang.org/issues/14062
+ it "does not affect exit status" do
+ ruby_exe(<<-END_OF_CODE).should == ""
+ return 10
+ END_OF_CODE
- err.should =~ /warning: argument of top-level return is ignored/
- end
+ $?.exitstatus.should == 0
end
end
end
diff --git a/spec/ruby/language/safe_navigator_spec.rb b/spec/ruby/language/safe_navigator_spec.rb
index c3aecff2dd..a8b29dc5a3 100644
--- a/spec/ruby/language/safe_navigator_spec.rb
+++ b/spec/ruby/language/safe_navigator_spec.rb
@@ -1,99 +1,101 @@
-require_relative '../spec_helper'
+require File.expand_path("../../spec_helper", __FILE__)
-describe "Safe navigator" do
- it "requires a method name to be provided" do
- -> { eval("obj&. {}") }.should raise_error(SyntaxError)
- end
-
- context "when context is nil" do
- it "always returns nil" do
- eval("nil&.unknown").should == nil
- eval("[][10]&.unknown").should == nil
+ruby_version_is "2.3" do
+ describe "Safe navigator" do
+ it "requires a method name to be provided" do
+ lambda { eval("obj&. {}") }.should raise_error(SyntaxError)
end
- it "can be chained" do
- eval("nil&.one&.two&.three").should == nil
- end
+ context "when context is nil" do
+ it "always returns nil" do
+ eval("nil&.unknown").should == nil
+ eval("[][10]&.unknown").should == nil
+ end
+
+ it "can be chained" do
+ eval("nil&.one&.two&.three").should == nil
+ end
- it "doesn't evaluate arguments" do
- obj = Object.new
- obj.should_not_receive(:m)
- eval("nil&.unknown(obj.m) { obj.m }")
+ it "doesn't evaluate arguments" do
+ obj = Object.new
+ obj.should_not_receive(:m)
+ eval("nil&.unknown(obj.m) { obj.m }")
+ end
end
- end
- context "when context is false" do
- it "calls the method" do
- eval("false&.to_s").should == "false"
+ context "when context is false" do
+ it "calls the method" do
+ eval("false&.to_s").should == "false"
- -> { eval("false&.unknown") }.should raise_error(NoMethodError)
+ lambda { eval("false&.unknown") }.should raise_error(NoMethodError)
+ end
end
- end
- context "when context is truthy" do
- it "calls the method" do
- eval("1&.to_s").should == "1"
+ context "when context is truthy" do
+ it "calls the method" do
+ eval("1&.to_s").should == "1"
- -> { eval("1&.unknown") }.should raise_error(NoMethodError)
+ lambda { eval("1&.unknown") }.should raise_error(NoMethodError)
+ end
end
- end
- it "takes a list of arguments" do
- eval("[1,2,3]&.first(2)").should == [1,2]
- end
+ it "takes a list of arguments" do
+ eval("[1,2,3]&.first(2)").should == [1,2]
+ end
- it "takes a block" do
- eval("[1,2]&.map { |i| i * 2 }").should == [2, 4]
- end
+ it "takes a block" do
+ eval("[1,2]&.map { |i| i * 2 }").should == [2, 4]
+ end
- it "allows assignment methods" do
- klass = Class.new do
- attr_reader :foo
- def foo=(val)
- @foo = val
- 42
+ it "allows assignment methods" do
+ klass = Class.new do
+ attr_reader :foo
+ def foo=(val)
+ @foo = val
+ 42
+ end
end
- end
- obj = klass.new
+ obj = klass.new
- eval("obj&.foo = 3").should == 3
- obj.foo.should == 3
+ eval("obj&.foo = 3").should == 3
+ obj.foo.should == 3
- obj = nil
- eval("obj&.foo = 3").should == nil
- end
+ obj = nil
+ eval("obj&.foo = 3").should == nil
+ end
- it "allows assignment operators" do
- klass = Class.new do
- attr_accessor :m
+ it "allows assignment operators" do
+ klass = Class.new do
+ attr_accessor :m
- def initialize
- @m = 0
+ def initialize
+ @m = 0
+ end
end
- end
- obj = klass.new
+ obj = klass.new
- eval("obj&.m += 3")
- obj.m.should == 3
+ eval("obj&.m += 3")
+ obj.m.should == 3
- obj = nil
- eval("obj&.m += 3").should == nil
- end
+ obj = nil
+ eval("obj&.m += 3").should == nil
+ end
- it "does not call the operator method lazily with an assignment operator" do
- klass = Class.new do
- attr_writer :foo
- def foo
- nil
+ it "does not call the operator method lazily with an assignment operator" do
+ klass = Class.new do
+ attr_writer :foo
+ def foo
+ nil
+ end
end
- end
- obj = klass.new
+ obj = klass.new
- -> {
- eval("obj&.foo += 3")
- }.should raise_error(NoMethodError) { |e|
- e.name.should == :+
- }
+ lambda {
+ eval("obj&.foo += 3")
+ }.should raise_error(NoMethodError) { |e|
+ e.name.should == :+
+ }
+ end
end
end
diff --git a/spec/ruby/language/safe_spec.rb b/spec/ruby/language/safe_spec.rb
deleted file mode 100644
index 53ab4f9561..0000000000
--- a/spec/ruby/language/safe_spec.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-require_relative '../spec_helper'
-
-describe "The $SAFE variable" do
- ruby_version_is ""..."2.7" do
- ruby_version_is "2.6" do
- after :each do
- $SAFE = 0
- end
- end
-
- it "is 0 by default" do
- $SAFE.should == 0
- proc {
- $SAFE.should == 0
- }.call
- end
-
- it "can be set to 0" do
- proc {
- $SAFE = 0
- $SAFE.should == 0
- }.call
- end
-
- it "can be set to 1" do
- proc {
- $SAFE = 1
- $SAFE.should == 1
- }.call
- end
-
- [2, 3, 4].each do |n|
- it "cannot be set to #{n}" do
- -> {
- proc {
- $SAFE = n
- }.call
- }.should raise_error(ArgumentError, /\$SAFE=2 to 4 are obsolete/)
- end
- end
-
- ruby_version_is ""..."2.6" do
- it "cannot be set to values below 0" do
- -> {
- proc {
- $SAFE = -100
- }.call
- }.should raise_error(SecurityError, /tried to downgrade safe level from 0 to -100/)
- end
- end
-
- ruby_version_is "2.6" do
- it "raises ArgumentError when set to values below 0" do
- -> {
- proc {
- $SAFE = -100
- }.call
- }.should raise_error(ArgumentError, "$SAFE should be >= 0")
- end
- end
-
- it "cannot be set to values above 4" do
- -> {
- proc {
- $SAFE = 100
- }.call
- }.should raise_error(ArgumentError, /\$SAFE=2 to 4 are obsolete/)
- end
-
- ruby_version_is ""..."2.6" do
- it "cannot be manually lowered" do
- proc {
- $SAFE = 1
- -> {
- $SAFE = 0
- }.should raise_error(SecurityError, /tried to downgrade safe level from 1 to 0/)
- }.call
- end
-
- it "is automatically lowered when leaving a proc" do
- $SAFE.should == 0
- proc {
- $SAFE = 1
- }.call
- $SAFE.should == 0
- end
-
- it "is automatically lowered when leaving a lambda" do
- $SAFE.should == 0
- -> {
- $SAFE = 1
- }.call
- $SAFE.should == 0
- end
- end
-
- ruby_version_is "2.6" do
- it "can be manually lowered" do
- $SAFE = 1
- $SAFE = 0
- $SAFE.should == 0
- end
-
- it "is not Proc local" do
- $SAFE.should == 0
- proc {
- $SAFE = 1
- }.call
- $SAFE.should == 1
- end
-
- it "is not lambda local" do
- $SAFE.should == 0
- -> {
- $SAFE = 1
- }.call
- $SAFE.should == 1
- end
-
- it "is global like regular global variables" do
- Thread.new { $SAFE }.value.should == 0
- $SAFE = 1
- Thread.new { $SAFE }.value.should == 1
- end
- end
-
- it "can be read when default from Thread#safe_level" do
- Thread.current.safe_level.should == 0
- end
-
- it "can be read when modified from Thread#safe_level" do
- proc {
- $SAFE = 1
- Thread.current.safe_level.should == 1
- }.call
- end
- end
-end
diff --git a/spec/ruby/language/send_spec.rb b/spec/ruby/language/send_spec.rb
index c56d5e8c26..646a700785 100644
--- a/spec/ruby/language/send_spec.rb
+++ b/spec/ruby/language/send_spec.rb
@@ -1,15 +1,15 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/send'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/send', __FILE__)
# Why so many fixed arg tests? JRuby and I assume other Ruby impls have
# separate call paths for simple fixed arity methods. Testing up to five
# will verify special and generic arity code paths for all impls.
#
# Method naming conventions:
-# M - Mandatory Args
+# M - Manditory Args
# O - Optional Arg
# R - Rest Arg
-# Q - Post Mandatory Args
+# Q - Post Manditory Args
specs = LangSendSpecs
@@ -20,7 +20,7 @@ describe "Invoking a method" do
end
it "raises ArgumentError if the method has a positive arity" do
- -> {
+ lambda {
specs.fooM1
}.should raise_error(ArgumentError)
end
@@ -36,7 +36,7 @@ describe "Invoking a method" do
end
it "raises ArgumentError if the methods arity doesn't match" do
- -> {
+ lambda {
specs.fooM1(1,2)
}.should raise_error(ArgumentError)
end
@@ -52,7 +52,7 @@ describe "Invoking a method" do
end
it "raises ArgumentError if extra arguments are passed" do
- -> {
+ lambda {
specs.fooM0O1(2,3)
}.should raise_error(ArgumentError)
end
@@ -64,13 +64,13 @@ describe "Invoking a method" do
end
it "raises an ArgumentError if there are no values for the mandatory args" do
- -> {
+ lambda {
specs.fooM1O1
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError if too many values are passed" do
- -> {
+ lambda {
specs.fooM1O1(1,2,3)
}.should raise_error(ArgumentError)
end
@@ -107,7 +107,7 @@ describe "Invoking a method" do
end
it "raises a SyntaxError with both a literal block and an object as block" do
- -> {
+ lambda {
eval "specs.oneb(10, &l){ 42 }"
}.should raise_error(SyntaxError)
end
@@ -195,20 +195,12 @@ describe "Invoking a method" do
end
it "raises NameError if invoked as a vcall" do
- -> { no_such_method }.should raise_error NameError
- end
-
- it "should omit the method_missing call from the backtrace for NameError" do
- -> { no_such_method }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") }
+ lambda { no_such_method }.should raise_error NameError
end
it "raises NoMethodError if invoked as an unambiguous method call" do
- -> { no_such_method() }.should raise_error NoMethodError
- -> { no_such_method(1,2,3) }.should raise_error NoMethodError
- end
-
- it "should omit the method_missing call from the backtrace for NoMethodError" do
- -> { no_such_method() }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") }
+ lambda { no_such_method() }.should raise_error NoMethodError
+ lambda { no_such_method(1,2,3) }.should raise_error NoMethodError
end
end
@@ -258,20 +250,10 @@ describe "Invoking a private setter method" do
end
describe "Invoking a private getter method" do
- ruby_version_is ""..."2.7" do
- it "does not permit self as a receiver" do
- receiver = LangSendSpecs::PrivateGetter.new
- -> { receiver.call_self_foo }.should raise_error(NoMethodError)
- -> { receiver.call_self_foo_or_equals(6) }.should raise_error(NoMethodError)
- end
- end
-
- ruby_version_is "2.7" do
- it "permits self as a receiver" do
- receiver = LangSendSpecs::PrivateGetter.new
- receiver.call_self_foo_or_equals(6)
- receiver.call_self_foo.should == 6
- end
+ it "does not permit self as a receiver" do
+ receiver = LangSendSpecs::PrivateGetter.new
+ lambda { receiver.call_self_foo }.should raise_error(NoMethodError)
+ lambda { receiver.call_self_foo_or_equals(6) }.should raise_error(NoMethodError)
end
end
@@ -421,29 +403,6 @@ describe "Invoking a method" do
specs.rest_len(0,*a,4,*5,6,7,*c,-1).should == 11
end
- it "expands the Array elements from the splat after executing the arguments and block if no other arguments follow the splat" do
- def self.m(*args, &block)
- [args, block]
- end
-
- args = [1, nil]
- m(*args, &args.pop).should == [[1], nil]
-
- args = [1, nil]
- order = []
- m(*(order << :args; args), &(order << :block; args.pop)).should == [[1], nil]
- order.should == [:args, :block]
- end
-
- it "evaluates the splatted arguments before the block if there are other arguments after the splat" do
- def self.m(*args, &block)
- [args, block]
- end
-
- args = [1, nil]
- m(*args, 2, &args.pop).should == [[1, nil, 2], nil]
- end
-
it "expands an array to arguments grouped in parentheses" do
specs.destructure2([40,2]).should == 42
end
diff --git a/spec/ruby/language/singleton_class_spec.rb b/spec/ruby/language/singleton_class_spec.rb
index df735018af..837f479440 100644
--- a/spec/ruby/language/singleton_class_spec.rb
+++ b/spec/ruby/language/singleton_class_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/class'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class', __FILE__)
describe "A singleton class" do
it "is TrueClass for true" do
@@ -15,11 +15,11 @@ describe "A singleton class" do
end
it "raises a TypeError for Fixnum's" do
- -> { 1.singleton_class }.should raise_error(TypeError)
+ lambda { 1.singleton_class }.should raise_error(TypeError)
end
it "raises a TypeError for symbols" do
- -> { :symbol.singleton_class }.should raise_error(TypeError)
+ lambda { :symbol.singleton_class }.should raise_error(TypeError)
end
it "is a singleton Class instance" do
@@ -74,7 +74,7 @@ describe "A singleton class" do
end
it "doesn't have singleton class" do
- -> { bignum_value.singleton_class.superclass.should == Bignum }.should raise_error(TypeError)
+ lambda { bignum_value.singleton_class.superclass.should == Bignum }.should raise_error(TypeError)
end
end
@@ -112,11 +112,11 @@ describe "A constant on a singleton class" do
class << @object
CONST
end
- -> { CONST }.should raise_error(NameError)
+ lambda { CONST }.should raise_error(NameError)
end
it "cannot be accessed via object::CONST" do
- -> do
+ lambda do
@object::CONST
end.should raise_error(TypeError)
end
@@ -127,7 +127,7 @@ describe "A constant on a singleton class" do
CONST = 100
end
- -> do
+ lambda do
@object::CONST
end.should raise_error(NameError)
end
@@ -143,7 +143,7 @@ describe "A constant on a singleton class" do
it "is not preserved when the object is duped" do
@object = @object.dup
- -> do
+ lambda do
class << @object; CONST; end
end.should raise_error(NameError)
end
@@ -280,13 +280,13 @@ end
describe "Instantiating a singleton class" do
it "raises a TypeError when new is called" do
- -> {
+ lambda {
Object.new.singleton_class.new
}.should raise_error(TypeError)
end
it "raises a TypeError when allocate is called" do
- -> {
+ lambda {
Object.new.singleton_class.allocate
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/language/source_encoding_spec.rb b/spec/ruby/language/source_encoding_spec.rb
deleted file mode 100644
index a0a29f63de..0000000000
--- a/spec/ruby/language/source_encoding_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require_relative '../spec_helper'
-
-describe "Source files" do
-
- describe "encoded in UTF-8 without a BOM" do
- it "can be parsed" do
- ruby_exe(fixture(__FILE__, "utf8-nobom.rb"), args: "2>&1").should == "hello\n"
- end
- end
-
- describe "encoded in UTF-8 with a BOM" do
- it "can be parsed" do
- ruby_exe(fixture(__FILE__, "utf8-bom.rb"), args: "2>&1").should == "hello\n"
- end
- end
-
- describe "encoded in UTF-16 LE without a BOM" do
- it "are parsed because empty as they contain a NUL byte before the encoding comment" do
- ruby_exe(fixture(__FILE__, "utf16-le-nobom.rb"), args: "2>&1").should == ""
- end
- end
-
- describe "encoded in UTF-16 LE with a BOM" do
- it "are invalid because they contain an invalid UTF-8 sequence before the encoding comment" do
- bom = "\xFF\xFE".b
- source = "# encoding: utf-16le\nputs 'hello'\n"
- source = bom + source.bytes.zip([0]*source.bytesize).flatten.pack('C*')
- path = tmp("utf16-le-bom.rb")
-
- touch(path, "wb") { |f| f.write source }
- begin
- ruby_exe(path, args: "2>&1").should =~ /invalid multibyte char/
- ensure
- rm_r path
- end
- end
- end
-
- describe "encoded in UTF-16 BE without a BOM" do
- it "are parsed as empty because they contain a NUL byte before the encoding comment" do
- ruby_exe(fixture(__FILE__, "utf16-be-nobom.rb"), args: "2>&1").should == ""
- end
- end
-
- describe "encoded in UTF-16 BE with a BOM" do
- it "are invalid because they contain an invalid UTF-8 sequence before the encoding comment" do
- bom = "\xFE\xFF".b
- source = "# encoding: utf-16be\nputs 'hello'\n"
- source = bom + ([0]*source.bytesize).zip(source.bytes).flatten.pack('C*')
- path = tmp("utf16-be-bom.rb")
-
- touch(path, "wb") { |f| f.write source }
- begin
- ruby_exe(path, args: "2>&1").should =~ /invalid multibyte char/
- ensure
- rm_r path
- end
- end
- end
-
-end
diff --git a/spec/ruby/language/string_spec.rb b/spec/ruby/language/string_spec.rb
index d0f62ff3c9..dbec2652ed 100644
--- a/spec/ruby/language/string_spec.rb
+++ b/spec/ruby/language/string_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# TODO: rewrite these horrid specs. it "are..." seriously?!
@@ -42,35 +42,24 @@ describe "Ruby character strings" do
"#@ip#@ip".should == 'xxxxxx'
end
- it "don't get confused by partial interpolation character sequences" do
- "#@".should == '#@'
- "#@ ".should == '#@ '
- "#@@".should == '#@@'
- "#@@ ".should == '#@@ '
- "#$ ".should == '#$ '
- "#\$".should == '#$'
- end
-
- ruby_version_is ''...'2.7' do
- it "taints the result of interpolation when an interpolated value is tainted" do
- "#{"".taint}".tainted?.should be_true
+ it "taints the result of interpolation when an interpolated value is tainted" do
+ "#{"".taint}".tainted?.should be_true
- @ip.taint
- "#@ip".tainted?.should be_true
+ @ip.taint
+ "#@ip".tainted?.should be_true
- $ip.taint
- "#$ip".tainted?.should be_true
- end
+ $ip.taint
+ "#$ip".tainted?.should be_true
+ end
- it "untrusts the result of interpolation when an interpolated value is untrusted" do
- "#{"".untrust}".untrusted?.should be_true
+ it "untrusts the result of interpolation when an interpolated value is untrusted" do
+ "#{"".untrust}".untrusted?.should be_true
- @ip.untrust
- "#@ip".untrusted?.should be_true
+ @ip.untrust
+ "#@ip".untrusted?.should be_true
- $ip.untrust
- "#$ip".untrusted?.should be_true
- end
+ $ip.untrust
+ "#$ip".untrusted?.should be_true
end
it "allows using non-alnum characters as string delimiters" do
@@ -197,11 +186,11 @@ describe "Ruby character strings" do
# TODO: spec other source encodings
describe "with ASCII_8BIT source encoding" do
it "produces an ASCII string when escaping ASCII characters via \\u" do
- "\u0000".encoding.should == Encoding::BINARY
+ "\u0000".encoding.should == Encoding::ASCII_8BIT
end
it "produces an ASCII string when escaping ASCII characters via \\u{}" do
- "\u{0000}".encoding.should == Encoding::BINARY
+ "\u{0000}".encoding.should == Encoding::ASCII_8BIT
end
it "produces a UTF-8-encoded string when escaping non-ASCII characters via \\u" do
@@ -235,55 +224,59 @@ describe "Ruby String literals" do
long_string_literals.should == "Beautiful is better than ugly.Explicit is better than implicit."
end
- describe "with a magic frozen comment" do
- it "produce the same object each time" do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment_one_literal.rb")).chomp.should == "true"
- end
+ ruby_version_is "2.3" do
+ describe "with a magic frozen comment" do
+ it "produce the same object each time" do
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment_one_literal.rb")).chomp.should == "true"
+ end
- it "produce the same object for literals with the same content" do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment_two_literals.rb")).chomp.should == "true"
- end
+ it "produce the same object for literals with the same content" do
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment_two_literals.rb")).chomp.should == "true"
+ end
- it "produce the same object for literals with the same content in different files" do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files.rb")).chomp.should == "true"
- end
+ it "produce the same object for literals with the same content in different files" do
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files.rb")).chomp.should == "true"
+ end
- it "produce different objects for literals with the same content in different files if the other file doesn't have the comment" do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == "true"
- end
+ it "produce different objects for literals with the same content in different files if the other file doesn't have the comment" do
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == "true"
+ end
- it "produce different objects for literals with the same content in different files if they have different encodings" do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_diff_enc.rb")).chomp.should == "true"
+ it "produce different objects for literals with the same content in different files if they have different encodings" do
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_diff_enc.rb")).chomp.should == "true"
+ end
end
end
end
-describe "Ruby String interpolation" do
- it "creates a String having an Encoding compatible with all components" do
- a = "\u3042"
- b = "abc".encode("binary")
+with_feature :encoding do
+ describe "Ruby String interpolation" do
+ it "creates a String having an Encoding compatible with all components" do
+ a = "\u3042"
+ b = "abc".encode("ascii-8bit")
- str = "#{a} x #{b}"
+ str = "#{a} x #{b}"
- str.should == "\xe3\x81\x82\x20\x78\x20\x61\x62\x63".force_encoding("utf-8")
- str.encoding.should == Encoding::UTF_8
- end
+ str.should == "\xe3\x81\x82\x20\x78\x20\x61\x62\x63".force_encoding("utf-8")
+ str.encoding.should == Encoding::UTF_8
+ end
- it "creates a String having the Encoding of the components when all are the same Encoding" do
- a = "abc".force_encoding("euc-jp")
- b = "def".force_encoding("euc-jp")
- str = '"#{a} x #{b}"'.force_encoding("euc-jp")
+ it "creates a String having the Encoding of the components when all are the same Encoding" do
+ a = "abc".force_encoding("euc-jp")
+ b = "def".force_encoding("euc-jp")
+ str = '"#{a} x #{b}"'.force_encoding("euc-jp")
- result = eval(str)
- result.should == "\x61\x62\x63\x20\x78\x20\x64\x65\x66".force_encoding("euc-jp")
- result.encoding.should == Encoding::EUC_JP
- end
+ result = eval(str)
+ result.should == "\x61\x62\x63\x20\x78\x20\x64\x65\x66".force_encoding("euc-jp")
+ result.encoding.should == Encoding::EUC_JP
+ end
- it "raises an Encoding::CompatibilityError if the Encodings are not compatible" do
- a = "\u3042"
- b = "\xff".force_encoding "binary"
+ it "raises an Encoding::CompatibilityError if the Encodings are not compatible" do
+ a = "\u3042"
+ b = "\xff".force_encoding "ascii-8bit"
- -> { "#{a} #{b}" }.should raise_error(Encoding::CompatibilityError)
+ lambda { "#{a} #{b}" }.should raise_error(Encoding::CompatibilityError)
+ end
end
end
diff --git a/spec/ruby/language/super_spec.rb b/spec/ruby/language/super_spec.rb
index 66a1ec7592..3d3f5d6f74 100644
--- a/spec/ruby/language/super_spec.rb
+++ b/spec/ruby/language/super_spec.rb
@@ -1,73 +1,73 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/super'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/super', __FILE__)
describe "The super keyword" do
it "calls the method on the calling class" do
- SuperSpecs::S1::A.new.foo([]).should == ["A#foo","A#bar"]
- SuperSpecs::S1::A.new.bar([]).should == ["A#bar"]
- SuperSpecs::S1::B.new.foo([]).should == ["B#foo","A#foo","B#bar","A#bar"]
- SuperSpecs::S1::B.new.bar([]).should == ["B#bar","A#bar"]
+ Super::S1::A.new.foo([]).should == ["A#foo","A#bar"]
+ Super::S1::A.new.bar([]).should == ["A#bar"]
+ Super::S1::B.new.foo([]).should == ["B#foo","A#foo","B#bar","A#bar"]
+ Super::S1::B.new.bar([]).should == ["B#bar","A#bar"]
end
it "searches the full inheritance chain" do
- SuperSpecs::S2::B.new.foo([]).should == ["B#foo","A#baz"]
- SuperSpecs::S2::B.new.baz([]).should == ["A#baz"]
- SuperSpecs::S2::C.new.foo([]).should == ["B#foo","C#baz","A#baz"]
- SuperSpecs::S2::C.new.baz([]).should == ["C#baz","A#baz"]
+ Super::S2::B.new.foo([]).should == ["B#foo","A#baz"]
+ Super::S2::B.new.baz([]).should == ["A#baz"]
+ Super::S2::C.new.foo([]).should == ["B#foo","C#baz","A#baz"]
+ Super::S2::C.new.baz([]).should == ["C#baz","A#baz"]
end
it "searches class methods" do
- SuperSpecs::S3::A.new.foo([]).should == ["A#foo"]
- SuperSpecs::S3::A.foo([]).should == ["A.foo"]
- SuperSpecs::S3::A.bar([]).should == ["A.bar","A.foo"]
- SuperSpecs::S3::B.new.foo([]).should == ["A#foo"]
- SuperSpecs::S3::B.foo([]).should == ["B.foo","A.foo"]
- SuperSpecs::S3::B.bar([]).should == ["B.bar","A.bar","B.foo","A.foo"]
+ Super::S3::A.new.foo([]).should == ["A#foo"]
+ Super::S3::A.foo([]).should == ["A.foo"]
+ Super::S3::A.bar([]).should == ["A.bar","A.foo"]
+ Super::S3::B.new.foo([]).should == ["A#foo"]
+ Super::S3::B.foo([]).should == ["B.foo","A.foo"]
+ Super::S3::B.bar([]).should == ["B.bar","A.bar","B.foo","A.foo"]
end
it "calls the method on the calling class including modules" do
- SuperSpecs::MS1::A.new.foo([]).should == ["ModA#foo","ModA#bar"]
- SuperSpecs::MS1::A.new.bar([]).should == ["ModA#bar"]
- SuperSpecs::MS1::B.new.foo([]).should == ["B#foo","ModA#foo","ModB#bar","ModA#bar"]
- SuperSpecs::MS1::B.new.bar([]).should == ["ModB#bar","ModA#bar"]
+ Super::MS1::A.new.foo([]).should == ["ModA#foo","ModA#bar"]
+ Super::MS1::A.new.bar([]).should == ["ModA#bar"]
+ Super::MS1::B.new.foo([]).should == ["B#foo","ModA#foo","ModB#bar","ModA#bar"]
+ Super::MS1::B.new.bar([]).should == ["ModB#bar","ModA#bar"]
end
it "searches the full inheritance chain including modules" do
- SuperSpecs::MS2::B.new.foo([]).should == ["ModB#foo","A#baz"]
- SuperSpecs::MS2::B.new.baz([]).should == ["A#baz"]
- SuperSpecs::MS2::C.new.baz([]).should == ["C#baz","A#baz"]
- SuperSpecs::MS2::C.new.foo([]).should == ["ModB#foo","C#baz","A#baz"]
+ Super::MS2::B.new.foo([]).should == ["ModB#foo","A#baz"]
+ Super::MS2::B.new.baz([]).should == ["A#baz"]
+ Super::MS2::C.new.baz([]).should == ["C#baz","A#baz"]
+ Super::MS2::C.new.foo([]).should == ["ModB#foo","C#baz","A#baz"]
end
it "can resolve to different methods in an included module method" do
- SuperSpecs::MultiSuperTargets::A.new.foo.should == :BaseA
- SuperSpecs::MultiSuperTargets::B.new.foo.should == :BaseB
+ Super::MultiSuperTargets::A.new.foo.should == :BaseA
+ Super::MultiSuperTargets::B.new.foo.should == :BaseB
end
it "searches class methods including modules" do
- SuperSpecs::MS3::A.new.foo([]).should == ["A#foo"]
- SuperSpecs::MS3::A.foo([]).should == ["ModA#foo"]
- SuperSpecs::MS3::A.bar([]).should == ["ModA#bar","ModA#foo"]
- SuperSpecs::MS3::B.new.foo([]).should == ["A#foo"]
- SuperSpecs::MS3::B.foo([]).should == ["B.foo","ModA#foo"]
- SuperSpecs::MS3::B.bar([]).should == ["B.bar","ModA#bar","B.foo","ModA#foo"]
+ Super::MS3::A.new.foo([]).should == ["A#foo"]
+ Super::MS3::A.foo([]).should == ["ModA#foo"]
+ Super::MS3::A.bar([]).should == ["ModA#bar","ModA#foo"]
+ Super::MS3::B.new.foo([]).should == ["A#foo"]
+ Super::MS3::B.foo([]).should == ["B.foo","ModA#foo"]
+ Super::MS3::B.bar([]).should == ["B.bar","ModA#bar","B.foo","ModA#foo"]
end
it "searches BasicObject from a module for methods defined there" do
- SuperSpecs::IncludesFromBasic.new.__send__(:foobar).should == 43
+ Super::IncludesFromBasic.new.__send__(:foobar).should == 43
end
it "searches BasicObject through another module for methods defined there" do
- SuperSpecs::IncludesIntermediate.new.__send__(:foobar).should == 42
+ Super::IncludesIntermediate.new.__send__(:foobar).should == 42
end
it "calls the correct method when the method visibility is modified" do
- SuperSpecs::MS4::A.new.example.should == 5
+ Super::MS4::A.new.example.should == 5
end
it "calls the correct method when the superclass argument list is different from the subclass" do
- SuperSpecs::S4::A.new.foo([]).should == ["A#foo"]
- SuperSpecs::S4::B.new.foo([],"test").should == ["B#foo(a,test)", "A#foo"]
+ Super::S4::A.new.foo([]).should == ["A#foo"]
+ Super::S4::B.new.foo([],"test").should == ["B#foo(a,test)", "A#foo"]
end
it "raises an error error when super method does not exist" do
@@ -83,8 +83,8 @@ describe "The super keyword" do
end
end
- -> {sub_normal.new.foo}.should raise_error(NoMethodError, /super/)
- -> {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/)
+ lambda {sub_normal.new.foo}.should raise_error(NoMethodError, /super/)
+ lambda {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/)
end
it "uses given block even if arguments are passed explicitly" do
@@ -102,35 +102,16 @@ describe "The super keyword" do
c2.new.m(:dump) { :value }.should == :value
end
- it "uses block argument given to method when used in a block" do
- c1 = Class.new do
- def m
- yield
- end
- end
- c2 = Class.new(c1) do
- def m(v)
- ary = []
- 1.times do
- ary << super()
- end
- ary
- end
- end
-
- c2.new.m(:dump) { :value }.should == [ :value ]
- end
-
it "calls the superclass method when in a block" do
- SuperSpecs::S6.new.here.should == :good
+ Super::S6.new.here.should == :good
end
it "calls the superclass method when initial method is defined_method'd" do
- SuperSpecs::S7.new.here.should == :good
+ Super::S7.new.here.should == :good
end
it "can call through a define_method multiple times (caching check)" do
- obj = SuperSpecs::S7.new
+ obj = Super::S7.new
2.times do
obj.here.should == :good
@@ -169,25 +150,25 @@ describe "The super keyword" do
end
end
- -> { klass.new.a(:a_called) }.should raise_error(RuntimeError)
+ lambda { klass.new.a(:a_called) }.should raise_error(RuntimeError)
end
# Rubinius ticket github#157
it "calls method_missing when a superclass method is not found" do
- SuperSpecs::MM_B.new.is_a?(Hash).should == false
+ Super::MM_B.new.is_a?(Hash).should == false
end
# Rubinius ticket github#180
it "respects the original module a method is aliased from" do
- SuperSpecs::Alias3.new.name3.should == [:alias2, :alias1]
+ Super::Alias3.new.name3.should == [:alias2, :alias1]
end
it "sees the included version of a module a method is alias from" do
- SuperSpecs::AliasWithSuper::Trigger.foo.should == [:b, :a]
+ Super::AliasWithSuper::Trigger.foo.should == [:b, :a]
end
it "find super from a singleton class" do
- obj = SuperSpecs::SingletonCase::Foo.new
+ obj = Super::SingletonCase::Foo.new
def obj.foobar(array)
array << :singleton
super
@@ -196,97 +177,87 @@ describe "The super keyword" do
end
it "finds super on other objects if a singleton class aliased the method" do
- orig_obj = SuperSpecs::SingletonAliasCase::Foo.new
+ orig_obj = Super::SingletonAliasCase::Foo.new
orig_obj.alias_on_singleton
orig_obj.new_foobar([]).should == [:foo, :base]
- SuperSpecs::SingletonAliasCase::Foo.new.foobar([]).should == [:foo, :base]
+ Super::SingletonAliasCase::Foo.new.foobar([]).should == [:foo, :base]
end
it "passes along modified rest args when they weren't originally empty" do
- SuperSpecs::RestArgsWithSuper::B.new.a("bar").should == ["bar", "foo"]
+ Super::RestArgsWithSuper::B.new.a("bar").should == ["bar", "foo"]
end
it "passes along modified rest args when they were originally empty" do
- SuperSpecs::RestArgsWithSuper::B.new.a.should == ["foo"]
- end
-
- # https://bugs.ruby-lang.org/issues/14279
- it "passes along reassigned rest args" do
- SuperSpecs::ZSuperWithRestReassigned::B.new.a("bar").should == ["foo"]
- end
-
- # https://bugs.ruby-lang.org/issues/14279
- it "wraps into array and passes along reassigned rest args with non-array scalar value" do
- SuperSpecs::ZSuperWithRestReassignedWithScalar::B.new.a("bar").should == ["foo"]
+ Super::RestArgsWithSuper::B.new.a.should == ["foo"]
end
it "invokes methods from a chain of anonymous modules" do
- SuperSpecs::AnonymousModuleIncludedTwice.new.a([]).should == ["anon", "anon", "non-anon"]
+ Super::AnonymousModuleIncludedTwice.new.a([]).should == ["anon", "anon", "non-anon"]
end
it "without explicit arguments can accept a block but still pass the original arguments" do
- SuperSpecs::ZSuperWithBlock::B.new.a.should == 14
+ Super::ZSuperWithBlock::B.new.a.should == 14
end
it "passes along block via reference to method expecting a reference" do
- SuperSpecs::ZSuperWithBlock::B.new.b.should == [14, 15]
+ Super::ZSuperWithBlock::B.new.b.should == [14, 15]
end
it "passes along a block via reference to a method that yields" do
- SuperSpecs::ZSuperWithBlock::B.new.c.should == 16
+ Super::ZSuperWithBlock::B.new.c.should == 16
end
it "without explicit arguments passes optional arguments that have a default value" do
- SuperSpecs::ZSuperWithOptional::B.new.m(1, 2).should == 14
+ Super::ZSuperWithOptional::B.new.m(1, 2).should == 14
end
it "without explicit arguments passes optional arguments that have a non-default value" do
- SuperSpecs::ZSuperWithOptional::B.new.m(1, 2, 3).should == 3
+ Super::ZSuperWithOptional::B.new.m(1, 2, 3).should == 3
end
it "without explicit arguments passes optional arguments that have a default value but were modified" do
- SuperSpecs::ZSuperWithOptional::C.new.m(1, 2).should == 100
+ Super::ZSuperWithOptional::C.new.m(1, 2).should == 100
end
it "without explicit arguments passes optional arguments that have a non-default value but were modified" do
- SuperSpecs::ZSuperWithOptional::C.new.m(1, 2, 3).should == 100
+ Super::ZSuperWithOptional::C.new.m(1, 2, 3).should == 100
end
it "without explicit arguments passes rest arguments" do
- SuperSpecs::ZSuperWithRest::B.new.m(1, 2, 3).should == [1, 2, 3]
+ Super::ZSuperWithRest::B.new.m(1, 2, 3).should == [1, 2, 3]
end
it "without explicit arguments passes rest arguments including any modifications" do
- SuperSpecs::ZSuperWithRest::B.new.m_modified(1, 2, 3).should == [1, 14, 3]
+ Super::ZSuperWithRest::B.new.m_modified(1, 2, 3).should == [1, 14, 3]
end
it "without explicit arguments passes arguments and rest arguments" do
- SuperSpecs::ZSuperWithRestAndOthers::B.new.m(1, 2, 3, 4, 5).should == [3, 4, 5]
+ Super::ZSuperWithRestAndOthers::B.new.m(1, 2, 3, 4, 5).should == [3, 4, 5]
end
it "without explicit arguments passes arguments and rest arguments including any modifications" do
- SuperSpecs::ZSuperWithRestAndOthers::B.new.m_modified(1, 2, 3, 4, 5).should == [3, 14, 5]
+ Super::ZSuperWithRestAndOthers::B.new.m_modified(1, 2, 3, 4, 5).should == [3, 14, 5]
end
it "without explicit arguments that are '_'" do
- SuperSpecs::ZSuperWithUnderscores::B.new.m(1, 2).should == [1, 2]
+ Super::ZSuperWithUnderscores::B.new.m(1, 2).should == [1, 2]
end
it "without explicit arguments that are '_' including any modifications" do
- SuperSpecs::ZSuperWithUnderscores::B.new.m_modified(1, 2).should == [14, 2]
+ Super::ZSuperWithUnderscores::B.new.m_modified(1, 2).should == [14, 2]
end
describe 'when using keyword arguments' do
before :each do
- @req = SuperSpecs::Keywords::RequiredArguments.new
- @opts = SuperSpecs::Keywords::OptionalArguments.new
- @etc = SuperSpecs::Keywords::PlaceholderArguments.new
+ @req = Super::Keywords::RequiredArguments.new
+ @opts = Super::Keywords::OptionalArguments.new
+ @etc = Super::Keywords::PlaceholderArguments.new
- @req_and_opts = SuperSpecs::Keywords::RequiredAndOptionalArguments.new
- @req_and_etc = SuperSpecs::Keywords::RequiredAndPlaceholderArguments.new
- @opts_and_etc = SuperSpecs::Keywords::OptionalAndPlaceholderArguments.new
+ @req_and_opts = Super::Keywords::RequiredAndOptionalArguments.new
+ @req_and_etc = Super::Keywords::RequiredAndPlaceholderArguments.new
+ @opts_and_etc = Super::Keywords::OptionalAndPlaceholderArguments.new
- @req_and_opts_and_etc = SuperSpecs::Keywords::RequiredAndOptionalAndPlaceholderArguments.new
+ @req_and_opts_and_etc = Super::Keywords::RequiredAndOptionalAndPlaceholderArguments.new
end
it 'does not pass any arguments to the parent when none are given' do
@@ -322,15 +293,15 @@ describe "The super keyword" do
describe 'when using regular and keyword arguments' do
before :each do
- @req = SuperSpecs::RegularAndKeywords::RequiredArguments.new
- @opts = SuperSpecs::RegularAndKeywords::OptionalArguments.new
- @etc = SuperSpecs::RegularAndKeywords::PlaceholderArguments.new
+ @req = Super::RegularAndKeywords::RequiredArguments.new
+ @opts = Super::RegularAndKeywords::OptionalArguments.new
+ @etc = Super::RegularAndKeywords::PlaceholderArguments.new
- @req_and_opts = SuperSpecs::RegularAndKeywords::RequiredAndOptionalArguments.new
- @req_and_etc = SuperSpecs::RegularAndKeywords::RequiredAndPlaceholderArguments.new
- @opts_and_etc = SuperSpecs::RegularAndKeywords::OptionalAndPlaceholderArguments.new
+ @req_and_opts = Super::RegularAndKeywords::RequiredAndOptionalArguments.new
+ @req_and_etc = Super::RegularAndKeywords::RequiredAndPlaceholderArguments.new
+ @opts_and_etc = Super::RegularAndKeywords::OptionalAndPlaceholderArguments.new
- @req_and_opts_and_etc = SuperSpecs::RegularAndKeywords::RequiredAndOptionalAndPlaceholderArguments.new
+ @req_and_opts_and_etc = Super::RegularAndKeywords::RequiredAndOptionalAndPlaceholderArguments.new
end
it 'passes only required regular arguments to the parent when no optional keyword arguments are given' do
@@ -366,7 +337,7 @@ describe "The super keyword" do
describe 'when using splat and keyword arguments' do
before :each do
- @all = SuperSpecs::SplatAndKeywords::AllArguments.new
+ @all = Super::SplatAndKeywords::AllArguments.new
end
it 'does not pass any arguments to the parent when none are given' do
diff --git a/spec/ruby/language/symbol_spec.rb b/spec/ruby/language/symbol_spec.rb
index d6a41d3059..90540f7d1d 100644
--- a/spec/ruby/language/symbol_spec.rb
+++ b/spec/ruby/language/symbol_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "A Symbol literal" do
it "is a ':' followed by any number of valid characters" do
@@ -38,7 +38,7 @@ describe "A Symbol literal" do
it 'inherits the encoding of the magic comment and can have a binary encoding' do
ruby_exe(fixture(__FILE__, "binary_symbol.rb"))
- .should == "[105, 108, 95, 195, 169, 116, 97, 105, 116]\n#{Encoding::BINARY.name}\n"
+ .should == "[105, 108, 95, 195, 169, 116, 97, 105, 116]\nASCII-8BIT\n"
end
it "may contain '::' in the string" do
diff --git a/spec/ruby/language/throw_spec.rb b/spec/ruby/language/throw_spec.rb
index d723843688..92f699350c 100644
--- a/spec/ruby/language/throw_spec.rb
+++ b/spec/ruby/language/throw_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The throw keyword" do
it "abandons processing" do
@@ -45,7 +45,7 @@ describe "The throw keyword" do
end
it "does not convert strings to a symbol" do
- -> { catch(:exit) { throw "exit" } }.should raise_error(ArgumentError)
+ lambda { catch(:exit) { throw "exit" } }.should raise_error(ArgumentError)
end
it "unwinds stack from within a method" do
@@ -59,13 +59,13 @@ describe "The throw keyword" do
end
it "unwinds stack from within a lambda" do
- c = -> { throw :foo, :msg }
+ c = lambda { throw :foo, :msg }
catch(:foo) { c.call }.should == :msg
end
it "raises an ArgumentError if outside of scope of a matching catch" do
- -> { throw :test, 5 }.should raise_error(ArgumentError)
- -> { catch(:different) { throw :test, 5 } }.should raise_error(ArgumentError)
+ lambda { throw :test, 5 }.should raise_error(ArgumentError)
+ lambda { catch(:different) { throw :test, 5 } }.should raise_error(ArgumentError)
end
it "raises an UncaughtThrowError if used to exit a thread" do
diff --git a/spec/ruby/language/undef_spec.rb b/spec/ruby/language/undef_spec.rb
index 4e473b803f..9e788f2a09 100644
--- a/spec/ruby/language/undef_spec.rb
+++ b/spec/ruby/language/undef_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The undef keyword" do
describe "undefines a method" do
@@ -14,35 +14,35 @@ describe "The undef keyword" do
@undef_class.class_eval do
undef meth
end
- -> { @obj.meth(5) }.should raise_error(NoMethodError)
+ lambda { @obj.meth(5) }.should raise_error(NoMethodError)
end
it "with a simple symbol" do
@undef_class.class_eval do
undef :meth
end
- -> { @obj.meth(5) }.should raise_error(NoMethodError)
+ lambda { @obj.meth(5) }.should raise_error(NoMethodError)
end
it "with a single quoted symbol" do
@undef_class.class_eval do
undef :'meth'
end
- -> { @obj.meth(5) }.should raise_error(NoMethodError)
+ lambda { @obj.meth(5) }.should raise_error(NoMethodError)
end
it "with a double quoted symbol" do
@undef_class.class_eval do
undef :"meth"
end
- -> { @obj.meth(5) }.should raise_error(NoMethodError)
+ lambda { @obj.meth(5) }.should raise_error(NoMethodError)
end
it "with a interpolated symbol" do
@undef_class.class_eval do
undef :"#{'meth'}"
end
- -> { @obj.meth(5) }.should raise_error(NoMethodError)
+ lambda { @obj.meth(5) }.should raise_error(NoMethodError)
end
end
@@ -61,7 +61,7 @@ describe "The undef keyword" do
it "raises a NameError when passed a missing name" do
Class.new do
- -> {
+ lambda {
undef not_exist
}.should raise_error(NameError) { |e|
# a NameError and not a NoMethodError
diff --git a/spec/ruby/language/unless_spec.rb b/spec/ruby/language/unless_spec.rb
index 98acdc083b..681f0adfdd 100644
--- a/spec/ruby/language/unless_spec.rb
+++ b/spec/ruby/language/unless_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The unless expression" do
it "evaluates the unless body when the expression is false" do
diff --git a/spec/ruby/language/until_spec.rb b/spec/ruby/language/until_spec.rb
index 78c289ff56..08898644ce 100644
--- a/spec/ruby/language/until_spec.rb
+++ b/spec/ruby/language/until_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# until bool-expr [do]
# body
@@ -220,7 +220,7 @@ describe "The until modifier with begin .. end block" do
a.should == [0, 1, 2, 4]
end
- it "restart the current iteration without reevaluating condition with redo" do
+ it "restart the current iteration without reevaluting condition with redo" do
a = []
i = 0
j = 0
diff --git a/spec/ruby/language/variables_spec.rb b/spec/ruby/language/variables_spec.rb
index 868603eb88..81ba54840a 100644
--- a/spec/ruby/language/variables_spec.rb
+++ b/spec/ruby/language/variables_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/variables'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/variables', __FILE__)
describe "Multiple assignment" do
context "with a single RHS value" do
@@ -46,7 +46,7 @@ describe "Multiple assignment" do
x = mock("multi-assign single RHS")
x.should_receive(:to_ary).and_return(1)
- -> { a, b, c = x }.should raise_error(TypeError)
+ lambda { a, b, c = x }.should raise_error(TypeError)
end
it "does not call #to_a to convert an Object RHS when assigning a simple MLHS" do
@@ -127,7 +127,7 @@ describe "Multiple assignment" do
x = mock("multi-assign splat")
x.should_receive(:to_ary).and_return(1)
- -> { *a = x }.should raise_error(TypeError)
+ lambda { *a = x }.should raise_error(TypeError)
end
it "does not call #to_ary on an Array subclass" do
@@ -160,7 +160,7 @@ describe "Multiple assignment" do
x = mock("multi-assign splat")
x.should_receive(:to_ary).and_return(1)
- -> { a, *b, c = x }.should raise_error(TypeError)
+ lambda { a, *b, c = x }.should raise_error(TypeError)
end
it "does not call #to_a to convert an Object RHS with a MLHS" do
@@ -256,7 +256,7 @@ describe "Multiple assignment" do
x = mock("multi-assign attributes")
x.should_receive(:m).and_return(y)
- -> { a, b = x.m }.should raise_error(TypeError)
+ lambda { a, b = x.m }.should raise_error(TypeError)
end
it "assigns values from a RHS method call with receiver and arguments" do
@@ -407,7 +407,7 @@ describe "Multiple assignment" do
x = mock("multi-assign RHS splat")
x.should_receive(:to_a).and_return(1)
- -> { *a = *x }.should raise_error(TypeError)
+ lambda { *a = *x }.should raise_error(TypeError)
end
it "does not call #to_ary to convert an Object RHS with a single splat LHS" do
@@ -453,7 +453,7 @@ describe "Multiple assignment" do
x = mock("multi-assign splat")
x.should_receive(:to_a).and_return(1)
- -> { a = *x }.should raise_error(TypeError)
+ lambda { a = *x }.should raise_error(TypeError)
end
it "calls #to_a to convert an Object splat RHS when assigned to a simple MLHS" do
@@ -468,7 +468,7 @@ describe "Multiple assignment" do
x = mock("multi-assign splat")
x.should_receive(:to_a).and_return(1)
- -> { a, b, c = *x }.should raise_error(TypeError)
+ lambda { a, b, c = *x }.should raise_error(TypeError)
end
it "does not call #to_ary to convert an Object splat RHS when assigned to a simple MLHS" do
@@ -491,7 +491,7 @@ describe "Multiple assignment" do
x = mock("multi-assign splat")
x.should_receive(:to_a).and_return(1)
- -> { a, *b, c = *x }.should raise_error(TypeError)
+ lambda { a, *b, c = *x }.should raise_error(TypeError)
end
it "does not call #to_ary to convert an Object RHS with a MLHS" do
@@ -569,7 +569,7 @@ describe "Multiple assignment" do
x = mock("multi-assign splat MRHS")
x.should_receive(:to_a).and_return(1)
- -> { a, *b = 1, *x }.should raise_error(TypeError)
+ lambda { a, *b = 1, *x }.should raise_error(TypeError)
end
it "does not call #to_ary to convert a splatted Object as part of a MRHS with a splat MRHS" do
@@ -592,7 +592,7 @@ describe "Multiple assignment" do
x = mock("multi-assign splat MRHS")
x.should_receive(:to_a).and_return(1)
- -> { a, *b = *x, 1 }.should raise_error(TypeError)
+ lambda { a, *b = *x, 1 }.should raise_error(TypeError)
end
it "does not call #to_ary to convert a splatted Object with a splat MRHS" do
@@ -641,7 +641,7 @@ describe "Multiple assignment" do
x = mock("multi-assign mixed RHS")
x.should_receive(:to_ary).and_return(x)
- -> { a, (b, c), d = 1, x, 3, 4 }.should raise_error(TypeError)
+ lambda { a, (b, c), d = 1, x, 3, 4 }.should raise_error(TypeError)
end
it "calls #to_a to convert a splatted Object value in a MRHS" do
@@ -665,7 +665,7 @@ describe "Multiple assignment" do
x = mock("multi-assign mixed splatted RHS")
x.should_receive(:to_ary).and_return(x)
- -> { a, *b, (c, d) = 1, 2, 3, *x }.should raise_error(TypeError)
+ lambda { a, *b, (c, d) = 1, 2, 3, *x }.should raise_error(TypeError)
end
it "does not call #to_ary to convert an Object when the position receiving the value is a simple variable" do
@@ -758,31 +758,3 @@ describe "A local variable assigned only within a conditional block" do
end
end
end
-
-describe 'Local variable shadowing' do
- ruby_version_is ""..."2.6" do
- it "leads to warning in verbose mode" do
- -> do
- eval <<-CODE
- a = [1, 2, 3]
- a.each { |a| a = 3 }
- CODE
- end.should complain(/shadowing outer local variable/, verbose: true)
- end
- end
-
- ruby_version_is "2.6" do
- it "does not warn in verbose mode" do
- result = nil
-
- -> do
- eval <<-CODE
- a = [1, 2, 3]
- result = a.map { |a| a = 3 }
- CODE
- end.should_not complain(verbose: true)
-
- result.should == [3, 3, 3]
- end
- end
-end
diff --git a/spec/ruby/language/while_spec.rb b/spec/ruby/language/while_spec.rb
index e172453ca6..00e948e41f 100644
--- a/spec/ruby/language/while_spec.rb
+++ b/spec/ruby/language/while_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# while bool-expr [do]
# body
@@ -330,7 +330,7 @@ describe "The while modifier with begin .. end block" do
a.should == [0, 1, 2, 4]
end
- it "restarts the current iteration without reevaluating condition with redo" do
+ it "restarts the current iteration without reevaluting condition with redo" do
a = []
i = 0
j = 0
diff --git a/spec/ruby/language/yield_spec.rb b/spec/ruby/language/yield_spec.rb
index 5fad7cb176..663110cbe6 100644
--- a/spec/ruby/language/yield_spec.rb
+++ b/spec/ruby/language/yield_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'fixtures/yield'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/yield', __FILE__)
# Note that these specs use blocks defined as { |*a| ... } to capture the
# arguments with which the block is invoked. This is slightly confusing
@@ -13,22 +13,18 @@ describe "The yield call" do
describe "taking no arguments" do
it "raises a LocalJumpError when the method is not passed a block" do
- -> { @y.z }.should raise_error(LocalJumpError)
+ lambda { @y.z }.should raise_error(LocalJumpError)
end
it "ignores assignment to the explicit block argument and calls the passed block" do
@y.ze { 42 }.should == 42
end
-
- it "does not pass a named block to the block being yielded to" do
- @y.z() { |&block| block == nil }.should == true
- end
end
describe "taking a single argument" do
describe "when no block is given" do
it "raises a LocalJumpError" do
- -> { @y.s(1) }.should raise_error(LocalJumpError)
+ lambda { @y.s(1) }.should raise_error(LocalJumpError)
end
end
@@ -52,38 +48,40 @@ describe "The yield call" do
describe "yielding to a lambda" do
it "passes an empty Array when the argument is an empty Array" do
- @y.s([], &-> *a { a }).should == [[]]
+ @y.s([], &lambda { |*a| a }).should == [[]]
end
it "passes nil as a value" do
- @y.s(nil, &-> *a { a }).should == [nil]
+ @y.s(nil, &lambda { |*a| a }).should == [nil]
end
it "passes a single value" do
- @y.s(1, &-> *a { a }).should == [1]
+ @y.s(1, &lambda { |*a| a }).should == [1]
end
it "passes a single, multi-value Array" do
- @y.s([1, 2, 3], &-> *a { a }).should == [[1, 2, 3]]
+ @y.s([1, 2, 3], &lambda { |*a| a }).should == [[1, 2, 3]]
end
it "raises an ArgumentError if too few arguments are passed" do
- -> {
- @y.s(1, &-> a, b { [a,b] })
+ lambda {
+ @y.s(1, &lambda { |a,b| [a,b] })
}.should raise_error(ArgumentError)
end
- it "should not destructure an Array into multiple arguments" do
- -> {
- @y.s([1, 2], &-> a, b { [a,b] })
- }.should raise_error(ArgumentError)
+ ruby_bug "#12705", "2.2"..."2.5" do
+ it "should not destructure an Array into multiple arguments" do
+ lambda {
+ @y.s([1, 2], &lambda { |a,b| [a,b] })
+ }.should raise_error(ArgumentError)
+ end
end
end
end
describe "taking multiple arguments" do
it "raises a LocalJumpError when the method is not passed a block" do
- -> { @y.m(1, 2, 3) }.should raise_error(LocalJumpError)
+ lambda { @y.m(1, 2, 3) }.should raise_error(LocalJumpError)
end
it "passes the arguments to the block" do
@@ -95,21 +93,21 @@ describe "The yield call" do
end
it "raises an ArgumentError if too many arguments are passed to a lambda" do
- -> {
- @y.m(1, 2, 3, &-> a { })
+ lambda {
+ @y.m(1, 2, 3, &lambda { |a| })
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError if too few arguments are passed to a lambda" do
- -> {
- @y.m(1, 2, 3, &-> a, b, c, d { })
+ lambda {
+ @y.m(1, 2, 3, &lambda { |a,b,c,d| })
}.should raise_error(ArgumentError)
end
end
describe "taking a single splatted argument" do
it "raises a LocalJumpError when the method is not passed a block" do
- -> { @y.r(0) }.should raise_error(LocalJumpError)
+ lambda { @y.r(0) }.should raise_error(LocalJumpError)
end
it "passes a single value" do
@@ -141,7 +139,7 @@ describe "The yield call" do
describe "taking multiple arguments with a splat" do
it "raises a LocalJumpError when the method is not passed a block" do
- -> { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError)
+ lambda { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError)
end
it "passes the arguments to the block" do
@@ -166,7 +164,7 @@ describe "The yield call" do
describe "taking matching arguments with splats and post args" do
it "raises a LocalJumpError when the method is not passed a block" do
- -> { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError)
+ lambda { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError)
end
it "passes the arguments to the block" do
@@ -174,12 +172,6 @@ describe "The yield call" do
end
end
- describe "taking a splat and a keyword argument" do
- it "passes it as an array of the values and a hash" do
- @y.k([1, 2]) { |*a| a }.should == [1, 2, {:b=>true}]
- end
- end
-
it "uses captured block of a block used in define_method" do
@y.deep(2).should == 4
end
diff --git a/spec/ruby/library/English/English_spec.rb b/spec/ruby/library/English/English_spec.rb
index f6153ec7c9..75a336eba2 100644
--- a/spec/ruby/library/English/English_spec.rb
+++ b/spec/ruby/library/English/English_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'English'
@@ -25,34 +25,34 @@ describe "English" do
it "aliases $FS to $;" do
original = $;
- suppress_warning {$; = ","}
+ $; = ","
$FS.should_not be_nil
$FS.should == $;
- suppress_warning {$; = original}
+ $; = original
end
it "aliases $FIELD_SEPARATOR to $;" do
original = $;
- suppress_warning {$; = ","}
+ $; = ","
$FIELD_SEPARATOR.should_not be_nil
$FIELD_SEPARATOR.should == $;
- suppress_warning {$; = original}
+ $; = original
end
it "aliases $OFS to $," do
original = $,
- suppress_warning {$, = "|"}
+ $, = "|"
$OFS.should_not be_nil
$OFS.should == $,
- suppress_warning {$, = original}
+ $, = original
end
it "aliases $OUTPUT_FIELD_SEPARATOR to $," do
original = $,
- suppress_warning {$, = "|"}
+ $, = "|"
$OUTPUT_FIELD_SEPARATOR.should_not be_nil
$OUTPUT_FIELD_SEPARATOR.should == $,
- suppress_warning {$, = original}
+ $, = original
end
it "aliases $RS to $/" do
diff --git a/spec/ruby/library/abbrev/abbrev_spec.rb b/spec/ruby/library/abbrev/abbrev_spec.rb
index 61b0926597..b2321cc679 100644
--- a/spec/ruby/library/abbrev/abbrev_spec.rb
+++ b/spec/ruby/library/abbrev/abbrev_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'abbrev'
#test both Abbrev.abbrev and Array#abbrev in
#the same manner, as they're more or less aliases
#of one another
-[["Abbrev.abbrev", -> a { Abbrev.abbrev(a)}],
- ["Array#abbrev", -> a { a.abbrev}]
+[["Abbrev.abbrev", lambda {|a| Abbrev.abbrev(a)}],
+ ["Array#abbrev", lambda {|a| a.abbrev}]
].each do |(name, func)|
describe name do
diff --git a/spec/ruby/library/base64/decode64_spec.rb b/spec/ruby/library/base64/decode64_spec.rb
index f6cd26d788..34d5ed6989 100644
--- a/spec/ruby/library/base64/decode64_spec.rb
+++ b/spec/ruby/library/base64/decode64_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'base64'
@@ -6,20 +6,4 @@ describe "Base64#decode64" do
it "returns the Base64-decoded version of the given string" do
Base64.decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n").should == "Send reinforcements"
end
-
- it "returns the Base64-decoded version of the given shared string" do
- Base64.decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==\n".split(" ").last).should == "Send reinforcements"
- end
-
- it "returns the Base64-decoded version of the given string with wrong padding" do
- Base64.decode64("XU2VuZCByZWluZm9yY2VtZW50cw===").should == "]M\x95\xB9\x90\x81\xC9\x95\xA5\xB9\x99\xBD\xC9\x8D\x95\xB5\x95\xB9\xD1\xCC".b
- end
-
- it "returns the Base64-decoded version of the given string that contains an invalid character" do
- Base64.decode64("%3D").should == "\xDC".b
- end
-
- it "returns a binary encoded string" do
- Base64.decode64("SEk=").encoding.should == Encoding::BINARY
- end
end
diff --git a/spec/ruby/library/base64/encode64_spec.rb b/spec/ruby/library/base64/encode64_spec.rb
index 64de6257bc..08df694e54 100644
--- a/spec/ruby/library/base64/encode64_spec.rb
+++ b/spec/ruby/library/base64/encode64_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'base64'
@@ -11,13 +11,4 @@ describe "Base64#encode64" do
it "returns the Base64-encoded version of the given string" do
Base64.encode64('Send reinforcements').should == "U2VuZCByZWluZm9yY2VtZW50cw==\n"
end
-
- it "returns the Base64-encoded version of the given shared string" do
- Base64.encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
- "dG8gbGVhcm4gUnVieQ==\n"
- end
-
- it "returns a US_ASCII encoded string" do
- Base64.encode64("HI").encoding.should == Encoding::US_ASCII
- end
end
diff --git a/spec/ruby/library/base64/strict_decode64_spec.rb b/spec/ruby/library/base64/strict_decode64_spec.rb
deleted file mode 100644
index d258223c82..0000000000
--- a/spec/ruby/library/base64/strict_decode64_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require_relative '../../spec_helper'
-
-require 'base64'
-
-describe "Base64#strict_decode64" do
- it "returns the Base64-decoded version of the given string" do
- Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==").should == "Send reinforcements"
- end
-
- it "returns the Base64-decoded version of the given shared string" do
- Base64.strict_decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==".split(" ").last).should == "Send reinforcements"
- end
-
- it "raises ArgumentError when the given string contains CR" do
- -> do
- Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\r")
- end.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError when the given string contains LF" do
- -> do
- Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n")
- end.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError when the given string has wrong padding" do
- -> do
- Base64.strict_decode64("=U2VuZCByZWluZm9yY2VtZW50cw==")
- end.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError when the given string contains an invalid character" do
- -> do
- Base64.strict_decode64("%3D")
- end.should raise_error(ArgumentError)
- end
-
- it "returns a binary encoded string" do
- Base64.strict_decode64("SEk=").encoding.should == Encoding::BINARY
- end
-end
diff --git a/spec/ruby/library/base64/strict_encode64_spec.rb b/spec/ruby/library/base64/strict_encode64_spec.rb
deleted file mode 100644
index 7cabcf190c..0000000000
--- a/spec/ruby/library/base64/strict_encode64_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../spec_helper'
-
-require 'base64'
-
-describe "Base64#strict_encode64" do
- it "returns the Base64-encoded version of the given string" do
- Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby").should ==
- "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4gUnVieQ=="
- end
-
- it "returns the Base64-encoded version of the given shared string" do
- Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
- "dG8gbGVhcm4gUnVieQ=="
- end
-
- it "returns a US_ASCII encoded string" do
- Base64.strict_encode64("HI").encoding.should == Encoding::US_ASCII
- end
-end
diff --git a/spec/ruby/library/base64/urlsafe_decode64_spec.rb b/spec/ruby/library/base64/urlsafe_decode64_spec.rb
index 1b813ee1b9..bea9a7cefb 100644
--- a/spec/ruby/library/base64/urlsafe_decode64_spec.rb
+++ b/spec/ruby/library/base64/urlsafe_decode64_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'base64'
@@ -13,7 +13,15 @@ describe "Base64#urlsafe_decode64" do
decoded.should == '"Being disintegrated makes me ve-ry an-gry!" <huff, huff>'
end
- it "does not require padding" do
- Base64.urlsafe_decode64("MQ").should == "1"
+ ruby_version_is ""..."2.3" do
+ it "requires padding" do
+ lambda { Base64.urlsafe_decode64("MQ") }.should raise_error(ArgumentError)
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "does not require padding" do
+ Base64.urlsafe_decode64("MQ").should == "1"
+ end
end
end
diff --git a/spec/ruby/library/base64/urlsafe_encode64_spec.rb b/spec/ruby/library/base64/urlsafe_encode64_spec.rb
index de1f235cea..32fce72603 100644
--- a/spec/ruby/library/base64/urlsafe_encode64_spec.rb
+++ b/spec/ruby/library/base64/urlsafe_encode64_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'base64'
@@ -13,8 +13,10 @@ describe "Base64#urlsafe_encode64" do
encoded.should == 'IkJlaW5nIGRpc2ludGVncmF0ZWQgbWFrZXMgbWUgdmUtcnkgYW4tZ3J5ISIgPGh1ZmYsIGh1ZmY-'
end
- it "makes padding optional" do
- Base64.urlsafe_encode64("1", padding: false).should == "MQ"
- Base64.urlsafe_encode64("1").should == "MQ=="
+ ruby_version_is "2.3" do
+ it "makes padding optional" do
+ Base64.urlsafe_encode64("1", padding: false).should == "MQ"
+ Base64.urlsafe_encode64("1").should == "MQ=="
+ end
end
end
diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
deleted file mode 100644
index 179bde1aed..0000000000
--- a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
+++ /dev/null
@@ -1,257 +0,0 @@
-require_relative '../../spec_helper'
-require 'bigdecimal'
-
-describe "BigDecimal" do
- it "is not defined unless it is required" do
- ruby_exe('puts Object.const_defined?(:BigDecimal)').should == "false\n"
- end
-end
-
-describe "Kernel#BigDecimal" do
-
- it "creates a new object of class BigDecimal" do
- BigDecimal("3.14159").should be_kind_of(BigDecimal)
- (0..9).each {|i|
- BigDecimal("1#{i}").should == 10 + i
- BigDecimal("-1#{i}").should == -10 - i
- BigDecimal("1E#{i}").should == 10**i
- BigDecimal("1000000E-#{i}").should == 10**(6-i).to_f
- # ^ to_f to avoid Rational type
- }
- (1..9).each {|i|
- BigDecimal("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i
- BigDecimal("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i
- }
- end
-
- it "BigDecimal(Rational) with bigger-than-double numerator" do
- rational = 99999999999999999999/100r
- rational.numerator.should > 2**64
- BigDecimal(rational, 100).to_s.should == "0.99999999999999999999e18"
- end
-
- it "accepts significant digits >= given precision" do
- BigDecimal("3.1415923", 10).precs[1].should >= 10
- end
-
- it "determines precision from initial value" do
- pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043"
- BigDecimal(pi_string).precs[1].should >= pi_string.size-1
- end
-
- it "ignores leading and trailing whitespace" do
- BigDecimal(" \t\n \r1234\t\r\n ").should == BigDecimal("1234")
- BigDecimal(" \t\n \rNaN \n").nan?.should == true
- BigDecimal(" \t\n \rInfinity \n").infinite?.should == 1
- BigDecimal(" \t\n \r-Infinity \n").infinite?.should == -1
- end
-
- ruby_version_is ""..."2.6" do
- it "ignores trailing garbage" do
- BigDecimal("123E45ruby").should == BigDecimal("123E45")
- BigDecimal("123x45").should == BigDecimal("123")
- BigDecimal("123.4%E5").should == BigDecimal("123.4")
- BigDecimal("1E2E3E4E5E").should == BigDecimal("100")
- end
- end
-
- ruby_version_is "2.6" do
- it "does not ignores trailing garbage" do
- -> { BigDecimal("123E45ruby") }.should raise_error(ArgumentError)
- -> { BigDecimal("123x45") }.should raise_error(ArgumentError)
- -> { BigDecimal("123.4%E5") }.should raise_error(ArgumentError)
- -> { BigDecimal("1E2E3E4E5E") }.should raise_error(ArgumentError)
- end
- end
-
- it "raises ArgumentError for invalid strings" do
- -> { BigDecimal("ruby") }.should raise_error(ArgumentError)
- -> { BigDecimal(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError)
- end
-
- it "allows omitting the integer part" do
- BigDecimal(".123").should == BigDecimal("0.123")
- end
-
- ruby_version_is ""..."2.6" do
- it "allows for underscores in all parts" do
- reference = BigDecimal("12345.67E89")
-
- BigDecimal("12_345.67E89").should == reference
- BigDecimal("1_2_3_4_5_._6____7_E89").should == reference
- BigDecimal("12345_.67E_8__9_").should == reference
- end
- end
-
- ruby_version_is "2.6" do
- it "process underscores as Float()" do
- reference = BigDecimal("12345.67E89")
-
- BigDecimal("12_345.67E89").should == reference
- -> { BigDecimal("1_2_3_4_5_._6____7_E89") }.should raise_error(ArgumentError)
- -> { BigDecimal("12345_.67E_8__9_") }.should raise_error(ArgumentError)
- end
- end
-
- it "accepts NaN and [+-]Infinity" do
- BigDecimal("NaN").nan?.should == true
-
- pos_inf = BigDecimal("Infinity")
- pos_inf.finite?.should == false
- pos_inf.should > 0
- pos_inf.should == BigDecimal("+Infinity")
-
- neg_inf = BigDecimal("-Infinity")
- neg_inf.finite?.should == false
- neg_inf.should < 0
- end
-
- describe "accepts NaN and [+-]Infinity as Float values" do
- it "works without an explicit precision" do
- BigDecimal(Float::NAN).nan?.should == true
-
- pos_inf = BigDecimal(Float::INFINITY)
- pos_inf.finite?.should == false
- pos_inf.should > 0
- pos_inf.should == BigDecimal("+Infinity")
-
- neg_inf = BigDecimal(-Float::INFINITY)
- neg_inf.finite?.should == false
- neg_inf.should < 0
- end
-
- it "works with an explicit precision" do
- BigDecimal(Float::NAN, Float::DIG).nan?.should == true
-
- pos_inf = BigDecimal(Float::INFINITY, Float::DIG)
- pos_inf.finite?.should == false
- pos_inf.should > 0
- pos_inf.should == BigDecimal("+Infinity")
-
- neg_inf = BigDecimal(-Float::INFINITY, Float::DIG)
- neg_inf.finite?.should == false
- neg_inf.should < 0
- end
- end
-
- it "allows for [eEdD] as exponent separator" do
- reference = BigDecimal("12345.67E89")
-
- BigDecimal("12345.67e89").should == reference
- BigDecimal("12345.67E89").should == reference
- BigDecimal("12345.67d89").should == reference
- BigDecimal("12345.67D89").should == reference
- end
-
- it "allows for varying signs" do
- reference = BigDecimal("123.456E1")
-
- BigDecimal("+123.456E1").should == reference
- BigDecimal("-123.456E1").should == -reference
- BigDecimal("123.456E+1").should == reference
- BigDecimal("12345.6E-1").should == reference
- BigDecimal("+123.456E+1").should == reference
- BigDecimal("+12345.6E-1").should == reference
- BigDecimal("-123.456E+1").should == -reference
- BigDecimal("-12345.6E-1").should == -reference
- end
-
- it "raises ArgumentError when Float is used without precision" do
- -> { BigDecimal(1.0) }.should raise_error(ArgumentError)
- end
-
- it "returns appropriate BigDecimal zero for signed zero" do
- BigDecimal(-0.0, Float::DIG).sign.should == -1
- BigDecimal(0.0, Float::DIG).sign.should == 1
- end
-
- it "pre-coerces long integers" do
- BigDecimal(3).add(1 << 50, 3).should == BigDecimal('0.113e16')
- end
-
- describe "when interacting with Rational" do
- before :each do
- @a = BigDecimal('166.666666666')
- @b = Rational(500, 3)
- @c = @a - @b
- end
-
- # Check the input is as we understand it
-
- it "has the LHS print as expected" do
- @a.to_s.should == "0.166666666666e3"
- @a.to_f.to_s.should == "166.666666666"
- Float(@a).to_s.should == "166.666666666"
- end
-
- it "has the RHS print as expected" do
- @b.to_s.should == "500/3"
- @b.to_f.to_s.should == "166.66666666666666"
- Float(@b).to_s.should == "166.66666666666666"
- end
-
- it "has the expected precision on the LHS" do
- @a.precs[0].should == 18
- end
-
- it "has the expected maximum precision on the LHS" do
- @a.precs[1].should == 27
- end
-
- it "produces the expected result when done via Float" do
- (Float(@a) - Float(@b)).to_s.should == "-6.666596163995564e-10"
- end
-
- it "produces the expected result when done via to_f" do
- (@a.to_f - @b.to_f).to_s.should == "-6.666596163995564e-10"
- end
-
- # Check underlying methods work as we understand
-
- it "BigDecimal precision is the number of digits rounded up to a multiple of nine" do
- 1.upto(100) do |n|
- b = BigDecimal('4' * n)
- precs, _ = b.precs
- (precs >= 9).should be_true
- (precs >= n).should be_true
- (precs % 9).should == 0
- end
- BigDecimal('NaN').precs[0].should == 9
- end
-
- it "BigDecimal maximum precision is nine more than precision except for abnormals" do
- 1.upto(100) do |n|
- b = BigDecimal('4' * n)
- precs, max = b.precs
- max.should == precs + 9
- end
- BigDecimal('NaN').precs[1].should == 9
- end
-
- it "BigDecimal(Rational, 18) produces the result we expect" do
- BigDecimal(@b, 18).to_s.should == "0.166666666666666667e3"
- end
-
- it "BigDecimal(Rational, BigDecimal.precs[0]) produces the result we expect" do
- BigDecimal(@b, @a.precs[0]).to_s.should == "0.166666666666666667e3"
- end
-
- # Check the top-level expression works as we expect
-
- it "produces a BigDecimal" do
- @c.class.should == BigDecimal
- end
-
- it "produces the expected result" do
- @c.should == BigDecimal("-0.666667e-9")
- @c.to_s.should == "-0.666667e-9"
- end
-
- it "produces the correct class for other arithmetic operators" do
- (@a + @b).class.should == BigDecimal
- (@a * @b).class.should == BigDecimal
- (@a / @b).class.should == BigDecimal
- (@a % @b).class.should == BigDecimal
- end
- end
-end
diff --git a/spec/ruby/library/bigdecimal/abs_spec.rb b/spec/ruby/library/bigdecimal/abs_spec.rb
index ddd2bae9a9..9027abfb47 100644
--- a/spec/ruby/library/bigdecimal/abs_spec.rb
+++ b/spec/ruby/library/bigdecimal/abs_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#abs" do
diff --git a/spec/ruby/library/bigdecimal/add_spec.rb b/spec/ruby/library/bigdecimal/add_spec.rb
index 5b874687fe..6136c9dccb 100644
--- a/spec/ruby/library/bigdecimal/add_spec.rb
+++ b/spec/ruby/library/bigdecimal/add_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'bigdecimal'
@@ -73,20 +73,6 @@ describe "BigDecimal#add" do
# BigDecimal("0.88").add(0.0, 1).should == BigDecimal("0.9")
# end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@frac_3).and_return([@frac_3, @frac_4])
- @frac_3.add(object, 1).should == BigDecimal("0.1E16")
- end
- end
-
- describe "with Rational" do
- it "produces a BigDecimal" do
- (@three + Rational(500, 2)).should == BigDecimal("0.253e3")
- end
- end
-
it "favors the precision specified in the second argument over the global limit" do
BigDecimalSpecs.with_limit(1) do
BigDecimal('0.888').add(@zero, 3).should == BigDecimal('0.888')
@@ -171,22 +157,22 @@ describe "BigDecimal#add" do
end
it "raises TypeError when adds nil" do
- -> {
+ lambda {
@one.add(nil, 10)
}.should raise_error(TypeError)
- -> {
+ lambda {
@one.add(nil, 0)
}.should raise_error(TypeError)
end
it "raises TypeError when precision parameter is nil" do
- -> {
+ lambda {
@one.add(@one, nil)
}.should raise_error(TypeError)
end
it "raises ArgumentError when precision parameter is negative" do
- -> {
+ lambda {
@one.add(@one, -10)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/bigdecimal/case_compare_spec.rb b/spec/ruby/library/bigdecimal/case_compare_spec.rb
index fac6714356..dcbde80e85 100644
--- a/spec/ruby/library/bigdecimal/case_compare_spec.rb
+++ b/spec/ruby/library/bigdecimal/case_compare_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql.rb', __FILE__)
describe "BigDecimal#===" do
- it_behaves_like :bigdecimal_eql, :===
+ it_behaves_like(:bigdecimal_eql, :===)
end
diff --git a/spec/ruby/library/bigdecimal/ceil_spec.rb b/spec/ruby/library/bigdecimal/ceil_spec.rb
index 60e71b12fb..d8829411b9 100644
--- a/spec/ruby/library/bigdecimal/ceil_spec.rb
+++ b/spec/ruby/library/bigdecimal/ceil_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#ceil" do
@@ -48,9 +48,9 @@ describe "BigDecimal#ceil" do
end
it "raise exception, if self is special value" do
- -> { @infinity.ceil }.should raise_error(FloatDomainError)
- -> { @infinity_neg.ceil }.should raise_error(FloatDomainError)
- -> { @nan.ceil }.should raise_error(FloatDomainError)
+ lambda { @infinity.ceil }.should raise_error(FloatDomainError)
+ lambda { @infinity_neg.ceil }.should raise_error(FloatDomainError)
+ lambda { @nan.ceil }.should raise_error(FloatDomainError)
end
it "returns n digits right of the decimal point if given n > 0" do
diff --git a/spec/ruby/library/bigdecimal/clone_spec.rb b/spec/ruby/library/bigdecimal/clone_spec.rb
deleted file mode 100644
index b3a1c61d6a..0000000000
--- a/spec/ruby/library/bigdecimal/clone_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/clone'
-
-describe "BigDecimal#dup" do
- it_behaves_like :bigdecimal_clone, :clone
-end
diff --git a/spec/ruby/library/bigdecimal/coerce_spec.rb b/spec/ruby/library/bigdecimal/coerce_spec.rb
index 1e5c73f969..1c63ddf2bc 100644
--- a/spec/ruby/library/bigdecimal/coerce_spec.rb
+++ b/spec/ruby/library/bigdecimal/coerce_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#coerce" do
diff --git a/spec/ruby/library/bigdecimal/comparison_spec.rb b/spec/ruby/library/bigdecimal/comparison_spec.rb
index a1e09b601f..c4de8348b2 100644
--- a/spec/ruby/library/bigdecimal/comparison_spec.rb
+++ b/spec/ruby/library/bigdecimal/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#<=>" do
diff --git a/spec/ruby/library/bigdecimal/constants_spec.rb b/spec/ruby/library/bigdecimal/constants_spec.rb
deleted file mode 100644
index 1eb24d85cb..0000000000
--- a/spec/ruby/library/bigdecimal/constants_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require_relative '../../spec_helper'
-require 'bigdecimal'
-
-describe "BigDecimal constants" do
- ruby_version_is "2.5" do
- it "defines a VERSION value" do
- BigDecimal.const_defined?(:VERSION).should be_true
- end
- end
-
- it "has a BASE value" do
- # The actual one is decided based on HAVE_INT64_T in MRI,
- # which is hard to check here.
- [10000, 1000000000].should include(BigDecimal::BASE)
- end
-
- it "has a NaN value" do
- BigDecimal::NAN.nan?.should be_true
- end
-
- it "has an INFINITY value" do
- BigDecimal::INFINITY.infinite?.should == 1
- end
-
- describe "exception-related constants" do
- [
- [:EXCEPTION_ALL, 0xff],
- [:EXCEPTION_INFINITY, 0x01],
- [:EXCEPTION_NaN, 0x02],
- [:EXCEPTION_UNDERFLOW, 0x04],
- [:EXCEPTION_OVERFLOW, 0x01],
- [:EXCEPTION_ZERODIVIDE, 0x10]
- ].each do |const, value|
- it "has a #{const} value" do
- BigDecimal.const_get(const).should == value
- end
- end
- end
-
- describe "rounding-related constants" do
- [
- [:ROUND_MODE, 0x100],
- [:ROUND_UP, 1],
- [:ROUND_DOWN, 2],
- [:ROUND_HALF_UP, 3],
- [:ROUND_HALF_DOWN, 4],
- [:ROUND_CEILING, 5],
- [:ROUND_FLOOR, 6],
- [:ROUND_HALF_EVEN, 7]
- ].each do |const, value|
- it "has a #{const} value" do
- BigDecimal.const_get(const).should == value
- end
- end
- end
-
- describe "sign-related constants" do
- [
- [:SIGN_NaN, 0],
- [:SIGN_POSITIVE_ZERO, 1],
- [:SIGN_NEGATIVE_ZERO, -1],
- [:SIGN_POSITIVE_FINITE, 2],
- [:SIGN_NEGATIVE_FINITE, -2],
- [:SIGN_POSITIVE_INFINITE, 3],
- [:SIGN_NEGATIVE_INFINITE, -3]
- ].each do |const, value|
- it "has a #{const} value" do
- BigDecimal.const_get(const).should == value
- end
- end
- end
-end
diff --git a/spec/ruby/library/bigdecimal/div_spec.rb b/spec/ruby/library/bigdecimal/div_spec.rb
index 0c9eb2ddec..f8f8ac4e5e 100644
--- a/spec/ruby/library/bigdecimal/div_spec.rb
+++ b/spec/ruby/library/bigdecimal/div_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quo', __FILE__)
require 'bigdecimal'
describe "BigDecimal#div with precision set to 0" do
@@ -42,18 +42,10 @@ describe "BigDecimal#div" do
}
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@one).and_return([@one, @two])
- @one.div(object).should == @zero
- end
- end
-
it "raises FloatDomainError if NaN is involved" do
- -> { @one.div(@nan) }.should raise_error(FloatDomainError)
- -> { @nan.div(@one) }.should raise_error(FloatDomainError)
- -> { @nan.div(@nan) }.should raise_error(FloatDomainError)
+ lambda { @one.div(@nan) }.should raise_error(FloatDomainError)
+ lambda { @nan.div(@one) }.should raise_error(FloatDomainError)
+ lambda { @nan.div(@nan) }.should raise_error(FloatDomainError)
end
it "returns 0 if divided by Infinity and no precision given" do
@@ -69,14 +61,14 @@ describe "BigDecimal#div" do
end
it "raises ZeroDivisionError if divided by zero and no precision given" do
- -> { @one.div(@zero) }.should raise_error(ZeroDivisionError)
- -> { @one.div(@zero_plus) }.should raise_error(ZeroDivisionError)
- -> { @one.div(@zero_minus) }.should raise_error(ZeroDivisionError)
-
- -> { @zero.div(@zero) }.should raise_error(ZeroDivisionError)
- -> { @zero_minus.div(@zero_plus) }.should raise_error(ZeroDivisionError)
- -> { @zero_minus.div(@zero_minus) }.should raise_error(ZeroDivisionError)
- -> { @zero_plus.div(@zero_minus) }.should raise_error(ZeroDivisionError)
+ lambda { @one.div(@zero) }.should raise_error(ZeroDivisionError)
+ lambda { @one.div(@zero_plus) }.should raise_error(ZeroDivisionError)
+ lambda { @one.div(@zero_minus) }.should raise_error(ZeroDivisionError)
+
+ lambda { @zero.div(@zero) }.should raise_error(ZeroDivisionError)
+ lambda { @zero_minus.div(@zero_plus) }.should raise_error(ZeroDivisionError)
+ lambda { @zero_minus.div(@zero_minus) }.should raise_error(ZeroDivisionError)
+ lambda { @zero_plus.div(@zero_minus) }.should raise_error(ZeroDivisionError)
end
it "returns NaN if zero is divided by zero" do
@@ -90,9 +82,9 @@ describe "BigDecimal#div" do
end
it "raises FloatDomainError if (+|-) Infinity divided by 1 and no precision given" do
- -> { @infinity_minus.div(@one) }.should raise_error(FloatDomainError)
- -> { @infinity.div(@one) }.should raise_error(FloatDomainError)
- -> { @infinity_minus.div(@one_minus) }.should raise_error(FloatDomainError)
+ lambda { @infinity_minus.div(@one) }.should raise_error(FloatDomainError)
+ lambda { @infinity.div(@one) }.should raise_error(FloatDomainError)
+ lambda { @infinity_minus.div(@one_minus) }.should raise_error(FloatDomainError)
end
it "returns (+|-)Infinity if (+|-)Infinity by 1 and precision given" do
diff --git a/spec/ruby/library/bigdecimal/divide_spec.rb b/spec/ruby/library/bigdecimal/divide_spec.rb
index c62b23557d..4dfe2702bb 100644
--- a/spec/ruby/library/bigdecimal/divide_spec.rb
+++ b/spec/ruby/library/bigdecimal/divide_spec.rb
@@ -1,17 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quo', __FILE__)
require 'bigdecimal'
describe "BigDecimal#/" do
it_behaves_like :bigdecimal_quo, :/, []
-
- before :each do
- @three = BigDecimal("3")
- end
-
- describe "with Rational" do
- it "produces a BigDecimal" do
- (@three / Rational(500, 2)).should == BigDecimal("0.12e-1")
- end
- end
end
diff --git a/spec/ruby/library/bigdecimal/divmod_spec.rb b/spec/ruby/library/bigdecimal/divmod_spec.rb
index ae8b84983a..839a289ab6 100644
--- a/spec/ruby/library/bigdecimal/divmod_spec.rb
+++ b/spec/ruby/library/bigdecimal/divmod_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/modulo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/modulo', __FILE__)
require 'bigdecimal'
module DivmodSpecs
@@ -36,11 +36,11 @@ describe "BigDecimal#mod_part_of_divmod" do
it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod
it "raises ZeroDivisionError if other is zero" do
- bd5667 = BigDecimal("5667.19")
+ bd5667 = BigDecimal.new("5667.19")
- -> { bd5667.mod_part_of_divmod(0) }.should raise_error(ZeroDivisionError)
- -> { bd5667.mod_part_of_divmod(BigDecimal("0")) }.should raise_error(ZeroDivisionError)
- -> { @zero.mod_part_of_divmod(@zero) }.should raise_error(ZeroDivisionError)
+ lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
+ lambda { @zero.send(@method, @zero) }.should raise_error(ZeroDivisionError)
end
end
@@ -96,8 +96,8 @@ describe "BigDecimal#divmod" do
it "can be reversed with * and +" do
# Example taken from BigDecimal documentation
- a = BigDecimal("42")
- b = BigDecimal("9")
+ a = BigDecimal.new("42")
+ b = BigDecimal.new("9")
q, m = a.divmod(b)
c = q * b + m
a.should == c
@@ -140,7 +140,7 @@ describe "BigDecimal#divmod" do
it "raises ZeroDivisionError if the divisor is zero" do
(@special_vals + @regular_vals + @zeroes - [@nan]).each do |val|
@zeroes.each do |zero|
- -> { val.divmod(zero) }.should raise_error(ZeroDivisionError)
+ lambda { val.divmod(zero) }.should raise_error(ZeroDivisionError)
end
end
end
@@ -163,7 +163,7 @@ describe "BigDecimal#divmod" do
end
end
- it "returns an array of two zero if the dividend is zero" do
+ it "returns an array of two zero if the diviend is zero" do
@zeroes.each do |zero|
@regular_vals.each do |val|
zero.divmod(val).should == [@zero, @zero]
@@ -172,7 +172,7 @@ describe "BigDecimal#divmod" do
end
it "raises TypeError if the argument cannot be coerced to BigDecimal" do
- -> {
+ lambda {
@one.divmod('1')
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/library/bigdecimal/double_fig_spec.rb b/spec/ruby/library/bigdecimal/double_fig_spec.rb
index f742d68f87..3ab5c2f207 100644
--- a/spec/ruby/library/bigdecimal/double_fig_spec.rb
+++ b/spec/ruby/library/bigdecimal/double_fig_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal.double_fig" do
diff --git a/spec/ruby/library/bigdecimal/dup_spec.rb b/spec/ruby/library/bigdecimal/dup_spec.rb
deleted file mode 100644
index bfabaf6e8b..0000000000
--- a/spec/ruby/library/bigdecimal/dup_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/clone'
-
-describe "BigDecimal#dup" do
- it_behaves_like :bigdecimal_clone, :dup
-end
diff --git a/spec/ruby/library/bigdecimal/eql_spec.rb b/spec/ruby/library/bigdecimal/eql_spec.rb
index 1be5862751..f3f525a7ba 100644
--- a/spec/ruby/library/bigdecimal/eql_spec.rb
+++ b/spec/ruby/library/bigdecimal/eql_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql.rb', __FILE__)
describe "BigDecimal#eql?" do
- it_behaves_like :bigdecimal_eql, :eql?
+ it_behaves_like(:bigdecimal_eql, :eql?)
end
diff --git a/spec/ruby/library/bigdecimal/equal_value_spec.rb b/spec/ruby/library/bigdecimal/equal_value_spec.rb
index 933060eada..bd07217b98 100644
--- a/spec/ruby/library/bigdecimal/equal_value_spec.rb
+++ b/spec/ruby/library/bigdecimal/equal_value_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eql.rb', __FILE__)
describe "BigDecimal#==" do
- it_behaves_like :bigdecimal_eql, :==
+ it_behaves_like(:bigdecimal_eql, :==)
end
diff --git a/spec/ruby/library/bigdecimal/exponent_spec.rb b/spec/ruby/library/bigdecimal/exponent_spec.rb
index a349ac093f..6bb678d4ed 100644
--- a/spec/ruby/library/bigdecimal/exponent_spec.rb
+++ b/spec/ruby/library/bigdecimal/exponent_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'shared/power'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/power', __FILE__)
require 'bigdecimal'
describe "BigDecimal#**" do
- it_behaves_like :bigdecimal_power, :**
+ it_behaves_like(:bigdecimal_power, :**)
end
describe "BigDecimal#exponent" do
diff --git a/spec/ruby/library/bigdecimal/finite_spec.rb b/spec/ruby/library/bigdecimal/finite_spec.rb
index 6685d589b6..6d6d8398fa 100644
--- a/spec/ruby/library/bigdecimal/finite_spec.rb
+++ b/spec/ruby/library/bigdecimal/finite_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#finite?" do
@@ -32,3 +32,4 @@ describe "BigDecimal#finite?" do
end
end
end
+
diff --git a/spec/ruby/library/bigdecimal/fix_spec.rb b/spec/ruby/library/bigdecimal/fix_spec.rb
index 53b30cbf8b..0a4a98c241 100644
--- a/spec/ruby/library/bigdecimal/fix_spec.rb
+++ b/spec/ruby/library/bigdecimal/fix_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#fix" do
@@ -49,7 +49,7 @@ describe "BigDecimal#fix" do
end
it "does not allow any arguments" do
- -> {
+ lambda {
@mixed.fix(10)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/bigdecimal/floor_spec.rb b/spec/ruby/library/bigdecimal/floor_spec.rb
index a7dfec2c9a..0bae6e4ab0 100644
--- a/spec/ruby/library/bigdecimal/floor_spec.rb
+++ b/spec/ruby/library/bigdecimal/floor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#floor" do
@@ -41,9 +41,9 @@ describe "BigDecimal#floor" do
end
it "raise exception, if self is special value" do
- -> { @infinity.floor }.should raise_error(FloatDomainError)
- -> { @infinity_neg.floor }.should raise_error(FloatDomainError)
- -> { @nan.floor }.should raise_error(FloatDomainError)
+ lambda { @infinity.floor }.should raise_error(FloatDomainError)
+ lambda { @infinity_neg.floor }.should raise_error(FloatDomainError)
+ lambda { @nan.floor }.should raise_error(FloatDomainError)
end
it "returns n digits right of the decimal point if given n > 0" do
diff --git a/spec/ruby/library/bigdecimal/frac_spec.rb b/spec/ruby/library/bigdecimal/frac_spec.rb
index 4a023b4ff6..9a727a70dd 100644
--- a/spec/ruby/library/bigdecimal/frac_spec.rb
+++ b/spec/ruby/library/bigdecimal/frac_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#frac" do
diff --git a/spec/ruby/library/bigdecimal/gt_spec.rb b/spec/ruby/library/bigdecimal/gt_spec.rb
index 4717cfdd9d..2f9ea4fd68 100644
--- a/spec/ruby/library/bigdecimal/gt_spec.rb
+++ b/spec/ruby/library/bigdecimal/gt_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#>" do
@@ -68,13 +68,15 @@ describe "BigDecimal#>" do
(@infinity_neg > @infinity).should == false
end
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val > @float_infinity).should == false
- (@float_infinity > val).should == true
- (val > @float_infinity_neg).should == true
- (@float_infinity_neg > val).should == false
- }
+ ruby_bug "#13674", ""..."2.4" do
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val > @float_infinity).should == false
+ (@float_infinity > val).should == true
+ (val > @float_infinity_neg).should == true
+ (@float_infinity_neg > val).should == false
+ }
+ end
end
it "properly handles NaN values" do
@@ -86,11 +88,11 @@ describe "BigDecimal#>" do
end
it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
- -> {@zero > nil }.should raise_error(ArgumentError)
- -> {@infinity > nil }.should raise_error(ArgumentError)
- -> {@infinity_neg > nil }.should raise_error(ArgumentError)
- -> {@mixed > nil }.should raise_error(ArgumentError)
- -> {@pos_int > nil }.should raise_error(ArgumentError)
- -> {@neg_frac > nil }.should raise_error(ArgumentError)
+ lambda {@zero > nil }.should raise_error(ArgumentError)
+ lambda {@infinity > nil }.should raise_error(ArgumentError)
+ lambda {@infinity_neg > nil }.should raise_error(ArgumentError)
+ lambda {@mixed > nil }.should raise_error(ArgumentError)
+ lambda {@pos_int > nil }.should raise_error(ArgumentError)
+ lambda {@neg_frac > nil }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/bigdecimal/gte_spec.rb b/spec/ruby/library/bigdecimal/gte_spec.rb
index 8dc81707f0..aab5338ad6 100644
--- a/spec/ruby/library/bigdecimal/gte_spec.rb
+++ b/spec/ruby/library/bigdecimal/gte_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#>=" do
@@ -72,13 +72,15 @@ describe "BigDecimal#>=" do
(@infinity_neg >= @infinity).should == false
end
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val >= @float_infinity).should == false
- (@float_infinity >= val).should == true
- (val >= @float_infinity_neg).should == true
- (@float_infinity_neg >= val).should == false
- }
+ ruby_bug "#13674", ""..."2.4" do
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val >= @float_infinity).should == false
+ (@float_infinity >= val).should == true
+ (val >= @float_infinity_neg).should == true
+ (@float_infinity_neg >= val).should == false
+ }
+ end
end
it "properly handles NaN values" do
@@ -90,11 +92,11 @@ describe "BigDecimal#>=" do
end
it "returns nil if the argument is nil" do
- -> {@zero >= nil }.should raise_error(ArgumentError)
- -> {@infinity >= nil }.should raise_error(ArgumentError)
- -> {@infinity_neg >= nil }.should raise_error(ArgumentError)
- -> {@mixed >= nil }.should raise_error(ArgumentError)
- -> {@pos_int >= nil }.should raise_error(ArgumentError)
- -> {@neg_frac >= nil }.should raise_error(ArgumentError)
+ lambda {@zero >= nil }.should raise_error(ArgumentError)
+ lambda {@infinity >= nil }.should raise_error(ArgumentError)
+ lambda {@infinity_neg >= nil }.should raise_error(ArgumentError)
+ lambda {@mixed >= nil }.should raise_error(ArgumentError)
+ lambda {@pos_int >= nil }.should raise_error(ArgumentError)
+ lambda {@neg_frac >= nil }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/bigdecimal/hash_spec.rb b/spec/ruby/library/bigdecimal/hash_spec.rb
deleted file mode 100644
index 7581c90f68..0000000000
--- a/spec/ruby/library/bigdecimal/hash_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../spec_helper'
-require 'bigdecimal'
-
-describe "BidDecimal#hash" do
- describe "two BigDecimal objects with the same value" do
- it "should have the same hash for ordinary values" do
- BigDecimal('1.2920').hash.should == BigDecimal('1.2920').hash
- end
-
- it "should have the same hash for infinite values" do
- BigDecimal("+Infinity").hash.should == BigDecimal("+Infinity").hash
- BigDecimal("-Infinity").hash.should == BigDecimal("-Infinity").hash
- end
-
- it "should have the same hash for NaNs" do
- BigDecimal("NaN").hash.should == BigDecimal("NaN").hash
- end
-
- it "should have the same hash for zero values" do
- BigDecimal("+0").hash.should == BigDecimal("+0").hash
- BigDecimal("-0").hash.should == BigDecimal("-0").hash
- end
- end
-
- describe "two BigDecimal objects with numerically equal values" do
- it "should have the same hash value" do
- BigDecimal("1.2920").hash.should == BigDecimal("1.2920000").hash
- end
- end
-end
diff --git a/spec/ruby/library/bigdecimal/infinite_spec.rb b/spec/ruby/library/bigdecimal/infinite_spec.rb
index 025386107f..b218ee371c 100644
--- a/spec/ruby/library/bigdecimal/infinite_spec.rb
+++ b/spec/ruby/library/bigdecimal/infinite_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#infinite?" do
diff --git a/spec/ruby/library/bigdecimal/inspect_spec.rb b/spec/ruby/library/bigdecimal/inspect_spec.rb
index 7ce47142b2..9831b2be8e 100644
--- a/spec/ruby/library/bigdecimal/inspect_spec.rb
+++ b/spec/ruby/library/bigdecimal/inspect_spec.rb
@@ -1,30 +1,47 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#inspect" do
before :each do
- @bigdec = BigDecimal("1234.5678")
+ @bigdec = BigDecimal.new("1234.5678")
end
it "returns String" do
@bigdec.inspect.kind_of?(String).should == true
end
- it "looks like this" do
- @bigdec.inspect.should == "0.12345678e4"
- end
+ ruby_version_is ""..."2.4" do
+ it "returns String starting with #" do
+ @bigdec.inspect[0].should == ?#
+ end
+
+ it "encloses information in angle brackets" do
+ @bigdec.inspect.should =~ /^.<.*>$/
+ end
+
+ it "is comma separated list of three items" do
+ @bigdec.inspect.should =~ /...*,.*,.*/
+ end
+
+ it "value after first comma is value as string" do
+ @bigdec.inspect.split(",")[1].should == "\'0.12345678E4\'"
+ end
+
+ it "last part is number of significant digits" do
+ signific_string = "#{@bigdec.precs[0]}(#{@bigdec.precs[1]})"
+ @bigdec.inspect.split(",")[2].should == signific_string + ">"
+ end
- it "does not add an exponent for zero values" do
- BigDecimal("0").inspect.should == "0.0"
- BigDecimal("+0").inspect.should == "0.0"
- BigDecimal("-0").inspect.should == "-0.0"
+ it "looks like this" do
+ regex = /^\#\<BigDecimal\:.*,'0\.12345678E4',[0-9]+\([0-9]+\)>$/
+ @bigdec.inspect.should =~ regex
+ end
end
- it "properly cases non-finite values" do
- BigDecimal("NaN").inspect.should == "NaN"
- BigDecimal("Infinity").inspect.should == "Infinity"
- BigDecimal("+Infinity").inspect.should == "Infinity"
- BigDecimal("-Infinity").inspect.should == "-Infinity"
+ ruby_version_is "2.4" do
+ it "looks like this" do
+ @bigdec.inspect.should == "0.12345678e4"
+ end
end
end
diff --git a/spec/ruby/library/bigdecimal/limit_spec.rb b/spec/ruby/library/bigdecimal/limit_spec.rb
index 75cbc8b55c..0c90415aec 100644
--- a/spec/ruby/library/bigdecimal/limit_spec.rb
+++ b/spec/ruby/library/bigdecimal/limit_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'bigdecimal'
describe "BigDecimal.limit" do
@@ -42,14 +42,4 @@ describe "BigDecimal.limit" do
BigDecimal('0.888').div(BigDecimal('3'), 2).should == BigDecimal('0.30')
end
end
-
- it "picks the global precision when limit 0 specified" do
- BigDecimalSpecs.with_limit(3) do
- BigDecimal('0.8888').add(BigDecimal('0'), 0).should == BigDecimal('0.889')
- BigDecimal('0.8888').sub(BigDecimal('0'), 0).should == BigDecimal('0.889')
- BigDecimal('0.888').mult(BigDecimal('3'), 0).should == BigDecimal('2.66')
- BigDecimal('0.8888').div(BigDecimal('3'), 0).should == BigDecimal('0.296')
- end
- end
-
end
diff --git a/spec/ruby/library/bigdecimal/lt_spec.rb b/spec/ruby/library/bigdecimal/lt_spec.rb
index 61f4f19912..089e7aef73 100644
--- a/spec/ruby/library/bigdecimal/lt_spec.rb
+++ b/spec/ruby/library/bigdecimal/lt_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#<" do
@@ -66,13 +66,15 @@ describe "BigDecimal#<" do
(@infinity_neg < @infinity).should == true
end
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val < @float_infinity).should == true
- (@float_infinity < val).should == false
- (val < @float_infinity_neg).should == false
- (@float_infinity_neg < val).should == true
- }
+ ruby_bug "#13674", ""..."2.4" do
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val < @float_infinity).should == true
+ (@float_infinity < val).should == false
+ (val < @float_infinity_neg).should == false
+ (@float_infinity_neg < val).should == true
+ }
+ end
end
it "properly handles NaN values" do
@@ -84,11 +86,11 @@ describe "BigDecimal#<" do
end
it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
- -> {@zero < nil }.should raise_error(ArgumentError)
- -> {@infinity < nil }.should raise_error(ArgumentError)
- -> {@infinity_neg < nil }.should raise_error(ArgumentError)
- -> {@mixed < nil }.should raise_error(ArgumentError)
- -> {@pos_int < nil }.should raise_error(ArgumentError)
- -> {@neg_frac < nil }.should raise_error(ArgumentError)
+ lambda {@zero < nil }.should raise_error(ArgumentError)
+ lambda {@infinity < nil }.should raise_error(ArgumentError)
+ lambda {@infinity_neg < nil }.should raise_error(ArgumentError)
+ lambda {@mixed < nil }.should raise_error(ArgumentError)
+ lambda {@pos_int < nil }.should raise_error(ArgumentError)
+ lambda {@neg_frac < nil }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/bigdecimal/lte_spec.rb b/spec/ruby/library/bigdecimal/lte_spec.rb
index fc632315f8..5cda9842bd 100644
--- a/spec/ruby/library/bigdecimal/lte_spec.rb
+++ b/spec/ruby/library/bigdecimal/lte_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#<=" do
@@ -72,13 +72,15 @@ describe "BigDecimal#<=" do
(@infinity_neg <= @infinity).should == true
end
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val <= @float_infinity).should == true
- (@float_infinity <= val).should == false
- (val <= @float_infinity_neg).should == false
- (@float_infinity_neg <= val).should == true
- }
+ ruby_bug "#13674", ""..."2.4" do
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val <= @float_infinity).should == true
+ (@float_infinity <= val).should == false
+ (val <= @float_infinity_neg).should == false
+ (@float_infinity_neg <= val).should == true
+ }
+ end
end
it "properly handles NaN values" do
@@ -90,11 +92,11 @@ describe "BigDecimal#<=" do
end
it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
- -> {@zero <= nil }.should raise_error(ArgumentError)
- -> {@infinity <= nil }.should raise_error(ArgumentError)
- -> {@infinity_neg <= nil }.should raise_error(ArgumentError)
- -> {@mixed <= nil }.should raise_error(ArgumentError)
- -> {@pos_int <= nil }.should raise_error(ArgumentError)
- -> {@neg_frac <= nil }.should raise_error(ArgumentError)
+ lambda {@zero <= nil }.should raise_error(ArgumentError)
+ lambda {@infinity <= nil }.should raise_error(ArgumentError)
+ lambda {@infinity_neg <= nil }.should raise_error(ArgumentError)
+ lambda {@mixed <= nil }.should raise_error(ArgumentError)
+ lambda {@pos_int <= nil }.should raise_error(ArgumentError)
+ lambda {@neg_frac <= nil }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/bigdecimal/minus_spec.rb b/spec/ruby/library/bigdecimal/minus_spec.rb
index 267a0f7eab..bdd8478465 100644
--- a/spec/ruby/library/bigdecimal/minus_spec.rb
+++ b/spec/ruby/library/bigdecimal/minus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#-" do
@@ -55,12 +55,4 @@ describe "BigDecimal#-" do
(@one_minus - @infinity).should == @infinity_minus
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@one).and_return([@one, BigDecimal("42")])
- (@one - object).should == BigDecimal("-41")
- end
- end
-
end
diff --git a/spec/ruby/library/bigdecimal/mode_spec.rb b/spec/ruby/library/bigdecimal/mode_spec.rb
index f57028ae5d..d88ac61aaf 100644
--- a/spec/ruby/library/bigdecimal/mode_spec.rb
+++ b/spec/ruby/library/bigdecimal/mode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal.mode" do
@@ -24,13 +24,13 @@ describe "BigDecimal.mode" do
it "raise an exception if the flag is true" do
BigDecimal.mode(BigDecimal::EXCEPTION_NaN, true)
- -> { BigDecimal("NaN").add(BigDecimal("1"),0) }.should raise_error(FloatDomainError)
+ lambda { BigDecimal("NaN").add(BigDecimal("1"),0) }.should raise_error(FloatDomainError)
BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, true)
- -> { BigDecimal("0").add(BigDecimal("Infinity"),0) }.should raise_error(FloatDomainError)
+ lambda { BigDecimal("0").add(BigDecimal("Infinity"),0) }.should raise_error(FloatDomainError)
BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, true)
- -> { BigDecimal("1").quo(BigDecimal("0")) }.should raise_error(FloatDomainError)
+ lambda { BigDecimal("1").quo(BigDecimal("0")) }.should raise_error(FloatDomainError)
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true)
- -> { BigDecimal("1E11111111111111111111") }.should raise_error(FloatDomainError)
- -> { (BigDecimal("1E1000000000000000000")**10) }.should raise_error(FloatDomainError)
+ lambda { BigDecimal("1E11111111111111111111") }.should raise_error(FloatDomainError)
+ lambda { (BigDecimal("1E1000000000000000000")**10) }.should raise_error(FloatDomainError)
end
end
diff --git a/spec/ruby/library/bigdecimal/modulo_spec.rb b/spec/ruby/library/bigdecimal/modulo_spec.rb
index 035d31bd98..6feeb685eb 100644
--- a/spec/ruby/library/bigdecimal/modulo_spec.rb
+++ b/spec/ruby/library/bigdecimal/modulo_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../spec_helper'
-require_relative 'shared/modulo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/modulo', __FILE__)
describe "BigDecimal#%" do
- it_behaves_like :bigdecimal_modulo, :%
- it_behaves_like :bigdecimal_modulo_zerodivisionerror, :%
+ it_behaves_like(:bigdecimal_modulo, :%)
+ it_behaves_like(:bigdecimal_modulo_zerodivisionerror, :%)
end
describe "BigDecimal#modulo" do
- it_behaves_like :bigdecimal_modulo, :modulo
- it_behaves_like :bigdecimal_modulo_zerodivisionerror, :modulo
+ it_behaves_like(:bigdecimal_modulo, :modulo)
+ it_behaves_like(:bigdecimal_modulo_zerodivisionerror, :modulo)
end
diff --git a/spec/ruby/library/bigdecimal/mult_spec.rb b/spec/ruby/library/bigdecimal/mult_spec.rb
index b7f8044b0b..a140cf899a 100644
--- a/spec/ruby/library/bigdecimal/mult_spec.rb
+++ b/spec/ruby/library/bigdecimal/mult_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/mult'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/mult', __FILE__)
require 'bigdecimal'
describe "BigDecimal#mult" do
@@ -9,8 +9,7 @@ end
describe "BigDecimal#mult" do
before :each do
@one = BigDecimal "1"
- @e3_minus = BigDecimal("3E-20001")
- @e3_plus = BigDecimal("3E20001")
+ @e3_minus = BigDecimal "3E-20001"
@e = BigDecimal "1.00000000000000000000123456789"
@tolerance = @e.sub @one, 1000
@tolerance2 = BigDecimal "30001E-20005"
@@ -22,11 +21,4 @@ describe "BigDecimal#mult" do
@e3_minus.mult(@one, 1).should be_close(0, @tolerance2)
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@e3_minus).and_return([@e3_minus, @e3_plus])
- @e3_minus.mult(object, 1).should == BigDecimal("9")
- end
- end
end
diff --git a/spec/ruby/library/bigdecimal/multiply_spec.rb b/spec/ruby/library/bigdecimal/multiply_spec.rb
index a8ce1da32e..842e22eaa2 100644
--- a/spec/ruby/library/bigdecimal/multiply_spec.rb
+++ b/spec/ruby/library/bigdecimal/multiply_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/mult'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/mult', __FILE__)
require 'bigdecimal'
describe "BigDecimal#*" do
@@ -8,7 +8,6 @@ end
describe "BigDecimal#*" do
before :each do
- @three = BigDecimal("3")
@e3_minus = BigDecimal("3E-20001")
@e3_plus = BigDecimal("3E20001")
@e = BigDecimal("1.00000000000000000000123456789")
@@ -24,18 +23,4 @@ describe "BigDecimal#*" do
(@e3_minus * @e3_minus).should == BigDecimal("9E-40002")
(@e * @one).should == @e
end
-
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@e3_minus).and_return([@e3_minus, @e3_plus])
- (@e3_minus * object).should == BigDecimal("9")
- end
- end
-
- describe "with Rational" do
- it "produces a BigDecimal" do
- (@three * Rational(500, 2)).should == BigDecimal("0.75e3")
- end
- end
end
diff --git a/spec/ruby/library/bigdecimal/nan_spec.rb b/spec/ruby/library/bigdecimal/nan_spec.rb
index 705492614b..5c291629b3 100644
--- a/spec/ruby/library/bigdecimal/nan_spec.rb
+++ b/spec/ruby/library/bigdecimal/nan_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#nan?" do
diff --git a/spec/ruby/library/bigdecimal/new_spec.rb b/spec/ruby/library/bigdecimal/new_spec.rb
new file mode 100644
index 0000000000..de3aa195ca
--- /dev/null
+++ b/spec/ruby/library/bigdecimal/new_spec.rb
@@ -0,0 +1,109 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'bigdecimal'
+
+describe "BigDecimal.new" do
+
+ it "creates a new object of class BigDecimal" do
+ BigDecimal.new("3.14159").should be_kind_of(BigDecimal)
+ (0..9).each {|i|
+ BigDecimal.new("1#{i}").should == 10 + i
+ BigDecimal.new("-1#{i}").should == -10 - i
+ BigDecimal.new("1E#{i}").should == 10**i
+ BigDecimal.new("1000000E-#{i}").should == 10**(6-i).to_f
+ # ^ to_f to avoid Rational type
+ }
+ (1..9).each {|i|
+ BigDecimal.new("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i
+ BigDecimal.new("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i
+ }
+ end
+
+ it "accepts significant digits >= given precision" do
+ BigDecimal.new("3.1415923", 10).precs[1].should >= 10
+ end
+
+ it "determines precision from initial value" do
+ pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043"
+ BigDecimal.new(pi_string).precs[1].should >= pi_string.size-1
+ end
+
+ it "ignores leading whitespace" do
+ BigDecimal.new(" \t\n \r1234").should == BigDecimal.new("1234")
+ BigDecimal.new(" \t\n \rNaN \n").nan?.should == true
+ BigDecimal.new(" \t\n \rInfinity \n").infinite?.should == 1
+ BigDecimal.new(" \t\n \r-Infinity \n").infinite?.should == -1
+ end
+
+ it "ignores trailing garbage" do
+ BigDecimal.new("123E45ruby").should == BigDecimal.new("123E45")
+ BigDecimal.new("123x45").should == BigDecimal.new("123")
+ BigDecimal.new("123.4%E5").should == BigDecimal.new("123.4")
+ BigDecimal.new("1E2E3E4E5E").should == BigDecimal.new("100")
+ end
+
+ ruby_version_is ""..."2.4" do
+ it "treats invalid strings as 0.0" do
+ BigDecimal.new("ruby").should == BigDecimal.new("0.0")
+ BigDecimal.new(" \t\n \r-\t\t\tInfinity \n").should == BigDecimal.new("0.0")
+ end
+ end
+
+ ruby_version_is "2.4" do
+ it "raises ArgumentError for invalid strings" do
+ lambda { BigDecimal.new("ruby") }.should raise_error(ArgumentError)
+ lambda { BigDecimal.new(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError)
+ end
+ end
+
+ it "allows omitting the integer part" do
+ BigDecimal.new(".123").should == BigDecimal.new("0.123")
+ end
+
+ it "allows for underscores in all parts" do
+ reference = BigDecimal.new("12345.67E89")
+
+ BigDecimal.new("12_345.67E89").should == reference
+ BigDecimal.new("1_2_3_4_5_._6____7_E89").should == reference
+ BigDecimal.new("12345_.67E_8__9_").should == reference
+ end
+
+ it "accepts NaN and [+-]Infinity" do
+ BigDecimal.new("NaN").nan?.should == true
+
+ pos_inf = BigDecimal.new("Infinity")
+ pos_inf.finite?.should == false
+ pos_inf.should > 0
+ pos_inf.should == BigDecimal.new("+Infinity")
+
+ neg_inf = BigDecimal.new("-Infinity")
+ neg_inf.finite?.should == false
+ neg_inf.should < 0
+ end
+
+ it "allows for [eEdD] as exponent separator" do
+ reference = BigDecimal.new("12345.67E89")
+
+ BigDecimal.new("12345.67e89").should == reference
+ BigDecimal.new("12345.67E89").should == reference
+ BigDecimal.new("12345.67d89").should == reference
+ BigDecimal.new("12345.67D89").should == reference
+ end
+
+ it "allows for varying signs" do
+ reference = BigDecimal.new("123.456E1")
+
+ BigDecimal.new("+123.456E1").should == reference
+ BigDecimal.new("-123.456E1").should == -reference
+ BigDecimal.new("123.456E+1").should == reference
+ BigDecimal.new("12345.6E-1").should == reference
+ BigDecimal.new("+123.456E+1").should == reference
+ BigDecimal.new("+12345.6E-1").should == reference
+ BigDecimal.new("-123.456E+1").should == -reference
+ BigDecimal.new("-12345.6E-1").should == -reference
+ end
+
+ it 'raises ArgumentError when Float is used without precision' do
+ lambda { BigDecimal(1.0) }.should raise_error(ArgumentError)
+ end
+
+end
diff --git a/spec/ruby/library/bigdecimal/nonzero_spec.rb b/spec/ruby/library/bigdecimal/nonzero_spec.rb
index f43c4393cd..336c72a6b2 100644
--- a/spec/ruby/library/bigdecimal/nonzero_spec.rb
+++ b/spec/ruby/library/bigdecimal/nonzero_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#nonzero?" do
diff --git a/spec/ruby/library/bigdecimal/plus_spec.rb b/spec/ruby/library/bigdecimal/plus_spec.rb
index cefc43aeaa..72ec282075 100644
--- a/spec/ruby/library/bigdecimal/plus_spec.rb
+++ b/spec/ruby/library/bigdecimal/plus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#+" do
@@ -44,11 +44,4 @@ describe "BigDecimal#+" do
(@infinity + @infinity_minus).nan?.should == true
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@one).and_return([@one, BigDecimal("42")])
- (@one + object).should == BigDecimal("43")
- end
- end
end
diff --git a/spec/ruby/library/bigdecimal/power_spec.rb b/spec/ruby/library/bigdecimal/power_spec.rb
index 63a45a1887..f2b1a9b5c8 100644
--- a/spec/ruby/library/bigdecimal/power_spec.rb
+++ b/spec/ruby/library/bigdecimal/power_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/power'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/power', __FILE__)
describe "BigDecimal#power" do
- it_behaves_like :bigdecimal_power, :power
+ it_behaves_like(:bigdecimal_power, :power)
end
diff --git a/spec/ruby/library/bigdecimal/precs_spec.rb b/spec/ruby/library/bigdecimal/precs_spec.rb
index f9320f2b9e..c7700a3819 100644
--- a/spec/ruby/library/bigdecimal/precs_spec.rb
+++ b/spec/ruby/library/bigdecimal/precs_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#precs" do
@@ -46,3 +46,4 @@ describe "BigDecimal#precs" do
end
end
end
+
diff --git a/spec/ruby/library/bigdecimal/quo_spec.rb b/spec/ruby/library/bigdecimal/quo_spec.rb
index a5c5651778..bc27fd0f5e 100644
--- a/spec/ruby/library/bigdecimal/quo_spec.rb
+++ b/spec/ruby/library/bigdecimal/quo_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/quo'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/quo', __FILE__)
require 'bigdecimal'
describe "BigDecimal#quo" do
@@ -10,3 +10,4 @@ describe "BigDecimal#quo" do
BigDecimal("NaN").quo(BigDecimal("1")).nan?.should == true
end
end
+
diff --git a/spec/ruby/library/bigdecimal/remainder_spec.rb b/spec/ruby/library/bigdecimal/remainder_spec.rb
index 04233edece..796522c5c8 100644
--- a/spec/ruby/library/bigdecimal/remainder_spec.rb
+++ b/spec/ruby/library/bigdecimal/remainder_spec.rb
@@ -1,12 +1,11 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#remainder" do
before :each do
@zero = BigDecimal("0")
- @one = BigDecimal("1")
- @three = BigDecimal("3")
+ @one = BigDecimal("0")
@mixed = BigDecimal("1.23456789")
@pos_int = BigDecimal("2E5555")
@neg_int = BigDecimal("-2E5555")
@@ -72,19 +71,12 @@ describe "BigDecimal#remainder" do
end
it "coerces arguments to BigDecimal if possible" do
- @three.remainder(2).should == @one
+ @one.remainder(2).should == @one
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@three).and_return([@three, 2])
- @three.remainder(object).should == @one
- end
- end
it "raises TypeError if the argument cannot be coerced to BigDecimal" do
- -> {
+ lambda {
@one.remainder('2')
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/library/bigdecimal/round_spec.rb b/spec/ruby/library/bigdecimal/round_spec.rb
index 501a1a7342..6c1987c5d8 100644
--- a/spec/ruby/library/bigdecimal/round_spec.rb
+++ b/spec/ruby/library/bigdecimal/round_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#round" do
@@ -62,173 +62,141 @@ describe "BigDecimal#round" do
@n2_49.round(0).should == @neg_two
end
- ["BigDecimal::ROUND_UP", ":up"].each do |way|
- describe way do
- it "rounds values away from zero" do
- mode = eval(way)
-
- @p1_50.round(0, mode).should == @two
- @p1_51.round(0, mode).should == @two
- @p1_49.round(0, mode).should == @two
- @n1_50.round(0, mode).should == @neg_two
- @n1_51.round(0, mode).should == @neg_two
- @n1_49.round(0, mode).should == @neg_two
-
- @p2_50.round(0, mode).should == @three
- @p2_51.round(0, mode).should == @three
- @p2_49.round(0, mode).should == @three
- @n2_50.round(0, mode).should == @neg_three
- @n2_51.round(0, mode).should == @neg_three
- @n2_49.round(0, mode).should == @neg_three
- end
+ describe "BigDecimal::ROUND_UP" do
+ it "rounds values away from zero" do
+ @p1_50.round(0, BigDecimal::ROUND_UP).should == @two
+ @p1_51.round(0, BigDecimal::ROUND_UP).should == @two
+ @p1_49.round(0, BigDecimal::ROUND_UP).should == @two
+ @n1_50.round(0, BigDecimal::ROUND_UP).should == @neg_two
+ @n1_51.round(0, BigDecimal::ROUND_UP).should == @neg_two
+ @n1_49.round(0, BigDecimal::ROUND_UP).should == @neg_two
+
+ @p2_50.round(0, BigDecimal::ROUND_UP).should == @three
+ @p2_51.round(0, BigDecimal::ROUND_UP).should == @three
+ @p2_49.round(0, BigDecimal::ROUND_UP).should == @three
+ @n2_50.round(0, BigDecimal::ROUND_UP).should == @neg_three
+ @n2_51.round(0, BigDecimal::ROUND_UP).should == @neg_three
+ @n2_49.round(0, BigDecimal::ROUND_UP).should == @neg_three
end
end
- ["BigDecimal::ROUND_DOWN", ":down", ":truncate"].each do |way|
- describe way do
- it "rounds values towards zero" do
- mode = eval(way)
-
- @p1_50.round(0, mode).should == @one
- @p1_51.round(0, mode).should == @one
- @p1_49.round(0, mode).should == @one
- @n1_50.round(0, mode).should == @neg_one
- @n1_51.round(0, mode).should == @neg_one
- @n1_49.round(0, mode).should == @neg_one
-
- @p2_50.round(0, mode).should == @two
- @p2_51.round(0, mode).should == @two
- @p2_49.round(0, mode).should == @two
- @n2_50.round(0, mode).should == @neg_two
- @n2_51.round(0, mode).should == @neg_two
- @n2_49.round(0, mode).should == @neg_two
- end
+ describe "BigDecimal::ROUND_DOWN" do
+ it "rounds values towards zero" do
+ @p1_50.round(0, BigDecimal::ROUND_DOWN).should == @one
+ @p1_51.round(0, BigDecimal::ROUND_DOWN).should == @one
+ @p1_49.round(0, BigDecimal::ROUND_DOWN).should == @one
+ @n1_50.round(0, BigDecimal::ROUND_DOWN).should == @neg_one
+ @n1_51.round(0, BigDecimal::ROUND_DOWN).should == @neg_one
+ @n1_49.round(0, BigDecimal::ROUND_DOWN).should == @neg_one
+
+ @p2_50.round(0, BigDecimal::ROUND_DOWN).should == @two
+ @p2_51.round(0, BigDecimal::ROUND_DOWN).should == @two
+ @p2_49.round(0, BigDecimal::ROUND_DOWN).should == @two
+ @n2_50.round(0, BigDecimal::ROUND_DOWN).should == @neg_two
+ @n2_51.round(0, BigDecimal::ROUND_DOWN).should == @neg_two
+ @n2_49.round(0, BigDecimal::ROUND_DOWN).should == @neg_two
end
end
- ["BigDecimal::ROUND_HALF_UP", ":half_up", ":default"].each do |way|
- describe way do
- it "rounds values >= 5 up, otherwise down" do
- mode = eval(way)
-
- @p1_50.round(0, mode).should == @two
- @p1_51.round(0, mode).should == @two
- @p1_49.round(0, mode).should == @one
- @n1_50.round(0, mode).should == @neg_two
- @n1_51.round(0, mode).should == @neg_two
- @n1_49.round(0, mode).should == @neg_one
-
- @p2_50.round(0, mode).should == @three
- @p2_51.round(0, mode).should == @three
- @p2_49.round(0, mode).should == @two
- @n2_50.round(0, mode).should == @neg_three
- @n2_51.round(0, mode).should == @neg_three
- @n2_49.round(0, mode).should == @neg_two
- end
+ describe "BigDecimal::ROUND_HALF_UP" do
+ it "rounds values >= 5 up, otherwise down" do
+ @p1_50.round(0, BigDecimal::ROUND_HALF_UP).should == @two
+ @p1_51.round(0, BigDecimal::ROUND_HALF_UP).should == @two
+ @p1_49.round(0, BigDecimal::ROUND_HALF_UP).should == @one
+ @n1_50.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_two
+ @n1_51.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_two
+ @n1_49.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_one
+
+ @p2_50.round(0, BigDecimal::ROUND_HALF_UP).should == @three
+ @p2_51.round(0, BigDecimal::ROUND_HALF_UP).should == @three
+ @p2_49.round(0, BigDecimal::ROUND_HALF_UP).should == @two
+ @n2_50.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_three
+ @n2_51.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_three
+ @n2_49.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_two
end
end
- ["BigDecimal::ROUND_HALF_DOWN", ":half_down"].each do |way|
- describe way do
- it "rounds values > 5 up, otherwise down" do
- mode = eval(way)
-
- @p1_50.round(0, mode).should == @one
- @p1_51.round(0, mode).should == @two
- @p1_49.round(0, mode).should == @one
- @n1_50.round(0, mode).should == @neg_one
- @n1_51.round(0, mode).should == @neg_two
- @n1_49.round(0, mode).should == @neg_one
-
- @p2_50.round(0, mode).should == @two
- @p2_51.round(0, mode).should == @three
- @p2_49.round(0, mode).should == @two
- @n2_50.round(0, mode).should == @neg_two
- @n2_51.round(0, mode).should == @neg_three
- @n2_49.round(0, mode).should == @neg_two
- end
+ describe "BigDecimal::ROUND_HALF_DOWN" do
+ it "rounds values > 5 up, otherwise down" do
+ @p1_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @one
+ @p1_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @two
+ @p1_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @one
+ @n1_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_one
+ @n1_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_two
+ @n1_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_one
+
+ @p2_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @two
+ @p2_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @three
+ @p2_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @two
+ @n2_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_two
+ @n2_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_three
+ @n2_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_two
end
end
- ["BigDecimal::ROUND_CEILING", ":ceiling", ":ceil"].each do |way|
- describe way do
- it "rounds values towards +infinity" do
- mode = eval(way)
-
- @p1_50.round(0, mode).should == @two
- @p1_51.round(0, mode).should == @two
- @p1_49.round(0, mode).should == @two
- @n1_50.round(0, mode).should == @neg_one
- @n1_51.round(0, mode).should == @neg_one
- @n1_49.round(0, mode).should == @neg_one
-
- @p2_50.round(0, mode).should == @three
- @p2_51.round(0, mode).should == @three
- @p2_49.round(0, mode).should == @three
- @n2_50.round(0, mode).should == @neg_two
- @n2_51.round(0, mode).should == @neg_two
- @n2_49.round(0, mode).should == @neg_two
- end
+ describe "BigDecimal::ROUND_CEILING" do
+ it "rounds values towards +infinity" do
+ @p1_50.round(0, BigDecimal::ROUND_CEILING).should == @two
+ @p1_51.round(0, BigDecimal::ROUND_CEILING).should == @two
+ @p1_49.round(0, BigDecimal::ROUND_CEILING).should == @two
+ @n1_50.round(0, BigDecimal::ROUND_CEILING).should == @neg_one
+ @n1_51.round(0, BigDecimal::ROUND_CEILING).should == @neg_one
+ @n1_49.round(0, BigDecimal::ROUND_CEILING).should == @neg_one
+
+ @p2_50.round(0, BigDecimal::ROUND_CEILING).should == @three
+ @p2_51.round(0, BigDecimal::ROUND_CEILING).should == @three
+ @p2_49.round(0, BigDecimal::ROUND_CEILING).should == @three
+ @n2_50.round(0, BigDecimal::ROUND_CEILING).should == @neg_two
+ @n2_51.round(0, BigDecimal::ROUND_CEILING).should == @neg_two
+ @n2_49.round(0, BigDecimal::ROUND_CEILING).should == @neg_two
end
end
- ["BigDecimal::ROUND_FLOOR", ":floor"].each do |way|
- describe way do
- it "rounds values towards -infinity" do
- mode = eval(way)
-
- @p1_50.round(0, mode).should == @one
- @p1_51.round(0, mode).should == @one
- @p1_49.round(0, mode).should == @one
- @n1_50.round(0, mode).should == @neg_two
- @n1_51.round(0, mode).should == @neg_two
- @n1_49.round(0, mode).should == @neg_two
-
- @p2_50.round(0, mode).should == @two
- @p2_51.round(0, mode).should == @two
- @p2_49.round(0, mode).should == @two
- @n2_50.round(0, mode).should == @neg_three
- @n2_51.round(0, mode).should == @neg_three
- @n2_49.round(0, mode).should == @neg_three
- end
+ describe "BigDecimal::ROUND_FLOOR" do
+ it "rounds values towards -infinity" do
+ @p1_50.round(0, BigDecimal::ROUND_FLOOR).should == @one
+ @p1_51.round(0, BigDecimal::ROUND_FLOOR).should == @one
+ @p1_49.round(0, BigDecimal::ROUND_FLOOR).should == @one
+ @n1_50.round(0, BigDecimal::ROUND_FLOOR).should == @neg_two
+ @n1_51.round(0, BigDecimal::ROUND_FLOOR).should == @neg_two
+ @n1_49.round(0, BigDecimal::ROUND_FLOOR).should == @neg_two
+
+ @p2_50.round(0, BigDecimal::ROUND_FLOOR).should == @two
+ @p2_51.round(0, BigDecimal::ROUND_FLOOR).should == @two
+ @p2_49.round(0, BigDecimal::ROUND_FLOOR).should == @two
+ @n2_50.round(0, BigDecimal::ROUND_FLOOR).should == @neg_three
+ @n2_51.round(0, BigDecimal::ROUND_FLOOR).should == @neg_three
+ @n2_49.round(0, BigDecimal::ROUND_FLOOR).should == @neg_three
end
end
- ["BigDecimal::ROUND_HALF_EVEN", ":half_even", ":banker"].each do |way|
- describe way do
- it "rounds values > 5 up, < 5 down and == 5 towards even neighbor" do
- mode = eval(way)
-
- @p1_50.round(0, mode).should == @two
- @p1_51.round(0, mode).should == @two
- @p1_49.round(0, mode).should == @one
- @n1_50.round(0, mode).should == @neg_two
- @n1_51.round(0, mode).should == @neg_two
- @n1_49.round(0, mode).should == @neg_one
-
- @p2_50.round(0, mode).should == @two
- @p2_51.round(0, mode).should == @three
- @p2_49.round(0, mode).should == @two
- @n2_50.round(0, mode).should == @neg_two
- @n2_51.round(0, mode).should == @neg_three
- @n2_49.round(0, mode).should == @neg_two
- end
+ describe "BigDecimal::ROUND_HALF_EVEN" do
+ it "rounds values > 5 up, < 5 down and == 5 towards even neighbor" do
+ @p1_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
+ @p1_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
+ @p1_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @one
+ @n1_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
+ @n1_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
+ @n1_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_one
+
+ @p2_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
+ @p2_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @three
+ @p2_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
+ @n2_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
+ @n2_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_three
+ @n2_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
end
end
it 'raise exception, if self is special value' do
- -> { BigDecimal('NaN').round }.should raise_error(FloatDomainError)
- -> { BigDecimal('Infinity').round }.should raise_error(FloatDomainError)
- -> { BigDecimal('-Infinity').round }.should raise_error(FloatDomainError)
+ lambda { BigDecimal('NaN').round }.should raise_error(FloatDomainError)
+ lambda { BigDecimal('Infinity').round }.should raise_error(FloatDomainError)
+ lambda { BigDecimal('-Infinity').round }.should raise_error(FloatDomainError)
end
it 'do not raise exception, if self is special value and precision is given' do
- -> { BigDecimal('NaN').round(2) }.should_not raise_error(FloatDomainError)
- -> { BigDecimal('Infinity').round(2) }.should_not raise_error(FloatDomainError)
- -> { BigDecimal('-Infinity').round(2) }.should_not raise_error(FloatDomainError)
- end
-
- it "raise for a non-existent round mode" do
- -> { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode")
+ lambda { BigDecimal('NaN').round(2) }.should_not raise_error(FloatDomainError)
+ lambda { BigDecimal('Infinity').round(2) }.should_not raise_error(FloatDomainError)
+ lambda { BigDecimal('-Infinity').round(2) }.should_not raise_error(FloatDomainError)
end
end
diff --git a/spec/ruby/library/bigdecimal/shared/clone.rb b/spec/ruby/library/bigdecimal/shared/clone.rb
deleted file mode 100644
index e58df3a94b..0000000000
--- a/spec/ruby/library/bigdecimal/shared/clone.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'bigdecimal'
-
-describe :bigdecimal_clone, shared: true do
- before :each do
- @obj = BigDecimal("1.2345")
- end
-
- ruby_version_is "" ... "2.5" do
- it "copies the BigDecimal's value to a newly allocated object" do
- copy = @obj.public_send(@method)
-
- copy.should_not equal(@obj)
- copy.should == @obj
- end
- end
-
- ruby_version_is "2.5" do
- it "returns self" do
- copy = @obj.public_send(@method)
-
- copy.should equal(@obj)
- end
- end
-end
diff --git a/spec/ruby/library/bigdecimal/shared/eql.rb b/spec/ruby/library/bigdecimal/shared/eql.rb
index 8e3e388bab..eaad272e9a 100644
--- a/spec/ruby/library/bigdecimal/shared/eql.rb
+++ b/spec/ruby/library/bigdecimal/shared/eql.rb
@@ -2,8 +2,8 @@ require 'bigdecimal'
describe :bigdecimal_eql, shared: true do
before :each do
- @bg6543_21 = BigDecimal("6543.21")
- @bg5667_19 = BigDecimal("5667.19")
+ @bg6543_21 = BigDecimal.new("6543.21")
+ @bg5667_19 = BigDecimal.new("5667.19")
@a = BigDecimal("1.0000000000000000000000000000000000000000005")
@b = BigDecimal("1.00000000000000000000000000000000000000000005")
@bigint = BigDecimal("1000.0")
diff --git a/spec/ruby/library/bigdecimal/shared/modulo.rb b/spec/ruby/library/bigdecimal/shared/modulo.rb
index 67c0ecf2fc..78ebe8360d 100644
--- a/spec/ruby/library/bigdecimal/shared/modulo.rb
+++ b/spec/ruby/library/bigdecimal/shared/modulo.rb
@@ -18,8 +18,8 @@ describe :bigdecimal_modulo, shared: true do
end
it "returns self modulo other" do
- bd6543 = BigDecimal("6543.21")
- bd5667 = BigDecimal("5667.19")
+ bd6543 = BigDecimal.new("6543.21")
+ bd5667 = BigDecimal.new("5667.19")
a = BigDecimal("1.0000000000000000000000000000000000000000005")
b = BigDecimal("1.00000000000000000000000000000000000000000005")
@@ -70,15 +70,6 @@ describe :bigdecimal_modulo, shared: true do
res.kind_of?(BigDecimal).should == true
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- bd6543 = BigDecimal("6543.21")
- object = mock("Object")
- object.should_receive(:coerce).with(bd6543).and_return([bd6543, 137])
- bd6543.send(@method, object, *@object).should == BigDecimal("104.21")
- end
- end
-
it "returns NaN if NaN is involved" do
@nan.send(@method, @nan).nan?.should == true
@nan.send(@method, @one).nan?.should == true
@@ -108,7 +99,7 @@ describe :bigdecimal_modulo, shared: true do
end
it "raises TypeError if the argument cannot be coerced to BigDecimal" do
- -> {
+ lambda {
@one.send(@method, '2')
}.should raise_error(TypeError)
end
@@ -116,10 +107,10 @@ end
describe :bigdecimal_modulo_zerodivisionerror, shared: true do
it "raises ZeroDivisionError if other is zero" do
- bd5667 = BigDecimal("5667.19")
+ bd5667 = BigDecimal.new("5667.19")
- -> { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
- -> { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
- -> { @zero.send(@method, @zero) }.should raise_error(ZeroDivisionError)
+ lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
+ lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
+ lambda { @zero.send(@method, @zero) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/library/bigdecimal/shared/quo.rb b/spec/ruby/library/bigdecimal/shared/quo.rb
index 4d6d64b787..cb51c10d71 100644
--- a/spec/ruby/library/bigdecimal/shared/quo.rb
+++ b/spec/ruby/library/bigdecimal/shared/quo.rb
@@ -29,14 +29,6 @@ describe :bigdecimal_quo, shared: true do
@one.send(@method, BigDecimal('2E-5555'), *@object).should == BigDecimal('0.5E5555')
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@one).and_return([@one, @two])
- @one.send(@method, object, *@object).should == BigDecimal("0.5")
- end
- end
-
it "returns 0 if divided by Infinity" do
@zero.send(@method, @infinity, *@object).should == 0
@frac_2.send(@method, @infinity, *@object).should == 0
diff --git a/spec/ruby/library/bigdecimal/shared/to_int.rb b/spec/ruby/library/bigdecimal/shared/to_int.rb
index 02f6092f23..729a25f511 100644
--- a/spec/ruby/library/bigdecimal/shared/to_int.rb
+++ b/spec/ruby/library/bigdecimal/shared/to_int.rb
@@ -2,8 +2,8 @@ require 'bigdecimal'
describe :bigdecimal_to_int , shared: true do
it "raises FloatDomainError if BigDecimal is infinity or NaN" do
- -> { BigDecimal("Infinity").send(@method) }.should raise_error(FloatDomainError)
- -> { BigDecimal("NaN").send(@method) }.should raise_error(FloatDomainError)
+ lambda { BigDecimal("Infinity").send(@method) }.should raise_error(FloatDomainError)
+ lambda { BigDecimal("NaN").send(@method) }.should raise_error(FloatDomainError)
end
it "returns Integer or Bignum otherwise" do
diff --git a/spec/ruby/library/bigdecimal/sign_spec.rb b/spec/ruby/library/bigdecimal/sign_spec.rb
index ae2c28e9fd..85aa74741c 100644
--- a/spec/ruby/library/bigdecimal/sign_spec.rb
+++ b/spec/ruby/library/bigdecimal/sign_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#sign" do
@@ -44,3 +44,4 @@ describe "BigDecimal#sign" do
end
end
+
diff --git a/spec/ruby/library/bigdecimal/split_spec.rb b/spec/ruby/library/bigdecimal/split_spec.rb
index f9b4bab5f7..e2ba955a3b 100644
--- a/spec/ruby/library/bigdecimal/split_spec.rb
+++ b/spec/ruby/library/bigdecimal/split_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#split" do
@@ -84,3 +84,5 @@ describe "BigDecimal#split" do
end
end
+
+
diff --git a/spec/ruby/library/bigdecimal/sqrt_spec.rb b/spec/ruby/library/bigdecimal/sqrt_spec.rb
index d149003b9f..f677192b33 100644
--- a/spec/ruby/library/bigdecimal/sqrt_spec.rb
+++ b/spec/ruby/library/bigdecimal/sqrt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'bigdecimal'
describe "BigDecimal#sqrt" do
@@ -41,37 +41,37 @@ describe "BigDecimal#sqrt" do
end
it "raises ArgumentError when no argument is given" do
- -> {
+ lambda {
@one.sqrt
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if a negative number is given" do
- -> {
+ lambda {
@one.sqrt(-1)
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if 2 arguments are given" do
- -> {
+ lambda {
@one.sqrt(1, 1)
}.should raise_error(ArgumentError)
end
it "raises TypeError if nil is given" do
- -> {
+ lambda {
@one.sqrt(nil)
}.should raise_error(TypeError)
end
it "raises TypeError if a string is given" do
- -> {
+ lambda {
@one.sqrt("stuff")
}.should raise_error(TypeError)
end
it "raises TypeError if a plain Object is given" do
- -> {
+ lambda {
@one.sqrt(Object.new)
}.should raise_error(TypeError)
end
@@ -82,23 +82,23 @@ describe "BigDecimal#sqrt" do
end
it "raises FloatDomainError on negative values" do
- -> {
+ lambda {
BigDecimal('-1').sqrt(10)
}.should raise_error(FloatDomainError)
end
- it "returns positive infinity for infinity" do
+ it "returns positive infitinity for infinity" do
@infinity.sqrt(1).should == @infinity
end
it "raises FloatDomainError for negative infinity" do
- -> {
+ lambda {
@infinity_minus.sqrt(1)
}.should raise_error(FloatDomainError)
end
it "raises FloatDomainError for NaN" do
- -> {
+ lambda {
@nan.sqrt(1)
}.should raise_error(FloatDomainError)
end
diff --git a/spec/ruby/library/bigdecimal/sub_spec.rb b/spec/ruby/library/bigdecimal/sub_spec.rb
index 29ec851193..06ad3b79d2 100644
--- a/spec/ruby/library/bigdecimal/sub_spec.rb
+++ b/spec/ruby/library/bigdecimal/sub_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#sub" do
@@ -7,15 +7,12 @@ describe "BigDecimal#sub" do
@one = BigDecimal("1")
@zero = BigDecimal("0")
@two = BigDecimal("2")
- @three = BigDecimal("3")
@nan = BigDecimal("NaN")
@infinity = BigDecimal("Infinity")
@infinity_minus = BigDecimal("-Infinity")
@one_minus = BigDecimal("-1")
@frac_1 = BigDecimal("1E-99999")
@frac_2 = BigDecimal("0.9E-99999")
- @frac_3 = BigDecimal("12345E10")
- @frac_4 = BigDecimal("98765E10")
end
it "returns a - b with given precision" do
@@ -35,20 +32,6 @@ describe "BigDecimal#sub" do
@frac_1.sub(@frac_1, 1000000).should == @zero
end
- describe "with Object" do
- it "tries to coerce the other operand to self" do
- object = mock("Object")
- object.should_receive(:coerce).with(@frac_3).and_return([@frac_3, @frac_4])
- @frac_3.sub(object, 1).should == BigDecimal("-0.9E15")
- end
- end
-
- describe "with Rational" do
- it "produces a BigDecimal" do
- (@three - Rational(500, 2)).should == BigDecimal('-0.247e3')
- end
- end
-
it "returns NaN if NaN is involved" do
@one.sub(@nan, 1).nan?.should == true
@nan.sub(@one, 1).nan?.should == true
diff --git a/spec/ruby/library/bigdecimal/to_d_spec.rb b/spec/ruby/library/bigdecimal/to_d_spec.rb
deleted file mode 100644
index 50aea99bf7..0000000000
--- a/spec/ruby/library/bigdecimal/to_d_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../spec_helper'
-require 'bigdecimal'
-require 'bigdecimal/util'
-
-describe "Float#to_d" do
- it "returns appropriate BigDecimal zero for signed zero" do
- -0.0.to_d.sign.should == -1
- 0.0.to_d.sign.should == 1
- end
-end
diff --git a/spec/ruby/library/bigdecimal/to_f_spec.rb b/spec/ruby/library/bigdecimal/to_f_spec.rb
index 1cc25d5c40..b490fce4d9 100644
--- a/spec/ruby/library/bigdecimal/to_f_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_f_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#to_f" do
@@ -52,3 +52,4 @@ describe "BigDecimal#to_f" do
@zero_neg.to_f.to_s.should == "-0.0"
end
end
+
diff --git a/spec/ruby/library/bigdecimal/to_i_spec.rb b/spec/ruby/library/bigdecimal/to_i_spec.rb
index 09481fce15..8db69003c5 100644
--- a/spec/ruby/library/bigdecimal/to_i_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_i_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_int'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_int', __FILE__)
require 'bigdecimal'
describe "BigDecimal#to_i" do
- it_behaves_like :bigdecimal_to_int, :to_i
+ it_behaves_like(:bigdecimal_to_int, :to_i)
end
diff --git a/spec/ruby/library/bigdecimal/to_int_spec.rb b/spec/ruby/library/bigdecimal/to_int_spec.rb
index 4df6749845..56a60d4a03 100644
--- a/spec/ruby/library/bigdecimal/to_int_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_int_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/to_int'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_int', __FILE__)
require 'bigdecimal'
describe "BigDecimal#to_int" do
- it_behaves_like :bigdecimal_to_int, :to_int
+ it_behaves_like(:bigdecimal_to_int, :to_int)
end
diff --git a/spec/ruby/library/bigdecimal/to_r_spec.rb b/spec/ruby/library/bigdecimal/to_r_spec.rb
index 91d2b33993..6f6e5a1bea 100644
--- a/spec/ruby/library/bigdecimal/to_r_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#to_r" do
@@ -8,7 +8,7 @@ describe "BigDecimal#to_r" do
end
it "returns a Rational with bignum values" do
- r = BigDecimal("3.141592653589793238462643").to_r
+ r = BigDecimal.new("3.141592653589793238462643").to_r
r.numerator.should eql(3141592653589793238462643)
r.denominator.should eql(1000000000000000000000000)
end
diff --git a/spec/ruby/library/bigdecimal/to_s_spec.rb b/spec/ruby/library/bigdecimal/to_s_spec.rb
index b6154c680d..b97311c800 100644
--- a/spec/ruby/library/bigdecimal/to_s_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#to_s" do
@@ -15,18 +15,12 @@ describe "BigDecimal#to_s" do
@bigneg.to_s.kind_of?(String).should == true
end
- it "the default format looks like 0.xxxxenn" do
- @bigdec.to_s.should =~ /^0\.[0-9]*e[0-9]*$/
- end
-
- it "does not add an exponent for zero values" do
- BigDecimal("0").to_s.should == "0.0"
- BigDecimal("+0").to_s.should == "0.0"
- BigDecimal("-0").to_s.should == "-0.0"
+ it "the default format looks like 0.xxxxEnn" do
+ @bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/i
end
it "takes an optional argument" do
- -> {@bigdec.to_s("F")}.should_not raise_error()
+ lambda {@bigdec.to_s("F")}.should_not raise_error()
end
it "starts with + if + is supplied and value is positive" do
@@ -40,11 +34,11 @@ describe "BigDecimal#to_s" do
@bigdec.to_s(3).should =~ re
str1 = '-123.45678 90123 45678 9'
- BigDecimal("-123.45678901234567890").to_s('5F').should == str1
+ BigDecimal.new("-123.45678901234567890").to_s('5F').should == str1
# trailing zeroes removed
- BigDecimal("1.00000000000").to_s('1F').should == "1.0"
+ BigDecimal.new("1.00000000000").to_s('1F').should == "1.0"
# 0 is treated as no spaces
- BigDecimal("1.2345").to_s('0F').should == "1.2345"
+ BigDecimal.new("1.2345").to_s('0F').should == "1.2345"
end
it "can return a leading space for values > 0" do
@@ -53,15 +47,15 @@ describe "BigDecimal#to_s" do
end
it "removes trailing spaces in floating point notation" do
- BigDecimal('-123.45678901234567890').to_s('F').should == "-123.4567890123456789"
- BigDecimal('1.2500').to_s('F').should == "1.25"
- BigDecimal('0000.00000').to_s('F').should == "0.0"
- BigDecimal('-00.000010000').to_s('F').should == "-0.00001"
- BigDecimal("5.00000E-2").to_s("F").should == "0.05"
+ BigDecimal.new('-123.45678901234567890').to_s('F').should == "-123.4567890123456789"
+ BigDecimal.new('1.2500').to_s('F').should == "1.25"
+ BigDecimal.new('0000.00000').to_s('F').should == "0.0"
+ BigDecimal.new('-00.000010000').to_s('F').should == "-0.00001"
+ BigDecimal.new("5.00000E-2").to_s("F").should == "0.05"
- BigDecimal("500000").to_s("F").should == "500000.0"
- BigDecimal("5E2").to_s("F").should == "500.0"
- BigDecimal("-5E100").to_s("F").should == "-5" + "0" * 100 + ".0"
+ BigDecimal.new("500000").to_s("F").should == "500000.0"
+ BigDecimal.new("5E2").to_s("F").should == "500.0"
+ BigDecimal.new("-5E100").to_s("F").should == "-5" + "0" * 100 + ".0"
end
it "can use engineering notation" do
@@ -69,12 +63,11 @@ describe "BigDecimal#to_s" do
end
it "can use conventional floating point notation" do
- %w[f F].each do |format_char|
- @bigdec.to_s(format_char).should == @bigdec_str
- @bigneg.to_s(format_char).should == @bigneg_str
- str2 = "+123.45678901 23456789"
- BigDecimal('123.45678901234567890').to_s("+8#{format_char}").should == str2
- end
+ @bigdec.to_s("F").should == @bigdec_str
+ @bigneg.to_s("F").should == @bigneg_str
+ str2 = "+123.45678901 23456789"
+ BigDecimal.new('123.45678901234567890').to_s('+8F').should == str2
end
end
+
diff --git a/spec/ruby/library/bigdecimal/truncate_spec.rb b/spec/ruby/library/bigdecimal/truncate_spec.rb
index d3a15f62c7..41f0afc8fa 100644
--- a/spec/ruby/library/bigdecimal/truncate_spec.rb
+++ b/spec/ruby/library/bigdecimal/truncate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#truncate" do
@@ -74,8 +74,8 @@ describe "BigDecimal#truncate" do
end
it "returns the same value if self is special value" do
- -> { @nan.truncate }.should raise_error(FloatDomainError)
- -> { @infinity.truncate }.should raise_error(FloatDomainError)
- -> { @infinity_negative.truncate }.should raise_error(FloatDomainError)
+ lambda { @nan.truncate }.should raise_error(FloatDomainError)
+ lambda { @infinity.truncate }.should raise_error(FloatDomainError)
+ lambda { @infinity_negative.truncate }.should raise_error(FloatDomainError)
end
end
diff --git a/spec/ruby/library/bigdecimal/uminus_spec.rb b/spec/ruby/library/bigdecimal/uminus_spec.rb
index 5e2a786c4c..901f9f59ce 100644
--- a/spec/ruby/library/bigdecimal/uminus_spec.rb
+++ b/spec/ruby/library/bigdecimal/uminus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#-@" do
diff --git a/spec/ruby/library/bigdecimal/uplus_spec.rb b/spec/ruby/library/bigdecimal/uplus_spec.rb
index 77483046b7..00aadc723c 100644
--- a/spec/ruby/library/bigdecimal/uplus_spec.rb
+++ b/spec/ruby/library/bigdecimal/uplus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#+@" do
@@ -15,3 +15,6 @@ describe "BigDecimal#+@" do
fifth.send(:+@).should == fifth
end
end
+
+
+
diff --git a/spec/ruby/library/bigdecimal/util_spec.rb b/spec/ruby/library/bigdecimal/util_spec.rb
deleted file mode 100644
index f41e131144..0000000000
--- a/spec/ruby/library/bigdecimal/util_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require_relative '../../spec_helper'
-require 'bigdecimal'
-require 'bigdecimal/util'
-
-describe "BigDecimal's util method definitions" do
- describe "#to_d" do
- it "should define #to_d on Integer" do
- 42.to_d.should == BigDecimal(42)
- end
-
- it "should define #to_d on Float" do
- 0.5.to_d.should == BigDecimal(0.5, Float::DIG)
- 1.234.to_d(2).should == BigDecimal(1.234, 2)
- end
-
- it "should define #to_d on String" do
- "0.5".to_d.should == BigDecimal(0.5, Float::DIG)
- "45.67 degrees".to_d.should == BigDecimal(45.67, Float::DIG)
- end
-
- it "should define #to_d on BigDecimal" do
- bd = BigDecimal("3.14")
- bd.to_d.should equal(bd)
- end
-
- it "should define #to_d on Rational" do
- Rational(22, 7).to_d(3).should == BigDecimal(3.14, 3)
- end
-
- ruby_version_is "2.6" do
- it "should define #to_d on nil" do
- nil.to_d.should == BigDecimal(0)
- end
- end
- end
-
- describe "#to_digits" do
- it "should define #to_digits on BigDecimal" do
- BigDecimal("3.14").to_digits.should == "3.14"
- end
- end
-end
diff --git a/spec/ruby/library/bigdecimal/ver_spec.rb b/spec/ruby/library/bigdecimal/ver_spec.rb
new file mode 100644
index 0000000000..61b073d8f1
--- /dev/null
+++ b/spec/ruby/library/bigdecimal/ver_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'bigdecimal'
+
+describe "BigDecimal.ver" do
+
+ it "returns the Version number" do
+ lambda {BigDecimal.ver }.should_not raise_error()
+ BigDecimal.ver.should_not == nil
+ end
+
+end
diff --git a/spec/ruby/library/bigdecimal/zero_spec.rb b/spec/ruby/library/bigdecimal/zero_spec.rb
index c5d3acb8c3..7dbb0fa7f0 100644
--- a/spec/ruby/library/bigdecimal/zero_spec.rb
+++ b/spec/ruby/library/bigdecimal/zero_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#zero?" do
@@ -25,3 +25,4 @@ describe "BigDecimal#zero?" do
end
end
+
diff --git a/spec/ruby/library/bigmath/log_spec.rb b/spec/ruby/library/bigmath/log_spec.rb
index 2ffbf8b6b9..126461f0e8 100644
--- a/spec/ruby/library/bigmath/log_spec.rb
+++ b/spec/ruby/library/bigmath/log_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'bigdecimal'
describe "BigDecimal#log" do
diff --git a/spec/ruby/library/cgi/cookie/domain_spec.rb b/spec/ruby/library/cgi/cookie/domain_spec.rb
index 962609ebaf..05137dd4d1 100644
--- a/spec/ruby/library/cgi/cookie/domain_spec.rb
+++ b/spec/ruby/library/cgi/cookie/domain_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#domain" do
diff --git a/spec/ruby/library/cgi/cookie/expires_spec.rb b/spec/ruby/library/cgi/cookie/expires_spec.rb
index c8f26d01cd..89f18fe071 100644
--- a/spec/ruby/library/cgi/cookie/expires_spec.rb
+++ b/spec/ruby/library/cgi/cookie/expires_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#expires" do
diff --git a/spec/ruby/library/cgi/cookie/initialize_spec.rb b/spec/ruby/library/cgi/cookie/initialize_spec.rb
index 4b6e104b10..02f2a8ed2b 100644
--- a/spec/ruby/library/cgi/cookie/initialize_spec.rb
+++ b/spec/ruby/library/cgi/cookie/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#initialize when passed String" do
@@ -120,8 +120,8 @@ describe "CGI::Cookie#initialize when passed Hash" do
end
it "raises a ArgumentError when the passed Hash has no 'name' entry" do
- -> { @cookie.send(:initialize, {}) }.should raise_error(ArgumentError)
- -> { @cookie.send(:initialize, "value" => "test") }.should raise_error(ArgumentError)
+ lambda { @cookie.send(:initialize, {}) }.should raise_error(ArgumentError)
+ lambda { @cookie.send(:initialize, "value" => "test") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/cgi/cookie/name_spec.rb b/spec/ruby/library/cgi/cookie/name_spec.rb
index 14226824c8..8a6be95944 100644
--- a/spec/ruby/library/cgi/cookie/name_spec.rb
+++ b/spec/ruby/library/cgi/cookie/name_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#name" do
diff --git a/spec/ruby/library/cgi/cookie/parse_spec.rb b/spec/ruby/library/cgi/cookie/parse_spec.rb
index 90d2c3d148..6f615c0d23 100644
--- a/spec/ruby/library/cgi/cookie/parse_spec.rb
+++ b/spec/ruby/library/cgi/cookie/parse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie.parse" do
@@ -10,12 +10,25 @@ describe "CGI::Cookie.parse" do
CGI::Cookie.parse("first cookie=one&two;second cookie=three&four").should == expected
end
- it "does not use , for cookie separators" do
- expected = {
- "first cookie" => ["one", "two"],
- "second cookie" => ["three", "four,third_cookie=five", "six"]
- }
- CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
+ ruby_version_is ""..."2.4" do
+ it "uses , for cookie separators" do
+ expected = {
+ "first cookie" => ["one", "two"],
+ "second cookie" => ["three", "four"],
+ "third_cookie" => ["five", "six"]
+ }
+ CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
+ end
+ end
+
+ ruby_version_is "2.4" do
+ it "does not use , for cookie separators" do
+ expected = {
+ "first cookie" => ["one", "two"],
+ "second cookie" => ["three", "four,third_cookie=five", "six"]
+ }
+ CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
+ end
end
it "unescapes the Cookie values" do
diff --git a/spec/ruby/library/cgi/cookie/path_spec.rb b/spec/ruby/library/cgi/cookie/path_spec.rb
index 8a2f05aa50..2a21a55264 100644
--- a/spec/ruby/library/cgi/cookie/path_spec.rb
+++ b/spec/ruby/library/cgi/cookie/path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#path" do
diff --git a/spec/ruby/library/cgi/cookie/secure_spec.rb b/spec/ruby/library/cgi/cookie/secure_spec.rb
index 694bc2eeed..37e9dbfda9 100644
--- a/spec/ruby/library/cgi/cookie/secure_spec.rb
+++ b/spec/ruby/library/cgi/cookie/secure_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#secure" do
diff --git a/spec/ruby/library/cgi/cookie/to_s_spec.rb b/spec/ruby/library/cgi/cookie/to_s_spec.rb
index 978c2d33eb..806071ba69 100644
--- a/spec/ruby/library/cgi/cookie/to_s_spec.rb
+++ b/spec/ruby/library/cgi/cookie/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#to_s" do
diff --git a/spec/ruby/library/cgi/cookie/value_spec.rb b/spec/ruby/library/cgi/cookie/value_spec.rb
index 1d5da3a3ac..81e3daf7de 100644
--- a/spec/ruby/library/cgi/cookie/value_spec.rb
+++ b/spec/ruby/library/cgi/cookie/value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::Cookie#value" do
diff --git a/spec/ruby/library/cgi/escapeElement_spec.rb b/spec/ruby/library/cgi/escapeElement_spec.rb
index 148926c453..18f804c7da 100644
--- a/spec/ruby/library/cgi/escapeElement_spec.rb
+++ b/spec/ruby/library/cgi/escapeElement_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.escapeElement when passed String, elements, ..." do
diff --git a/spec/ruby/library/cgi/escapeHTML_spec.rb b/spec/ruby/library/cgi/escapeHTML_spec.rb
index dcbfebe720..a3267db4a1 100644
--- a/spec/ruby/library/cgi/escapeHTML_spec.rb
+++ b/spec/ruby/library/cgi/escapeHTML_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.escapeHTML" do
diff --git a/spec/ruby/library/cgi/escape_spec.rb b/spec/ruby/library/cgi/escape_spec.rb
index 351bfe1070..cf8861a39f 100644
--- a/spec/ruby/library/cgi/escape_spec.rb
+++ b/spec/ruby/library/cgi/escape_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.escape" do
diff --git a/spec/ruby/library/cgi/htmlextension/a_spec.rb b/spec/ruby/library/cgi/htmlextension/a_spec.rb
index 05b4c2d14c..a4c0ee684c 100644
--- a/spec/ruby/library/cgi/htmlextension/a_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/a_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#a" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/base_spec.rb b/spec/ruby/library/cgi/htmlextension/base_spec.rb
index 877ac321cd..36a8cc55c8 100644
--- a/spec/ruby/library/cgi/htmlextension/base_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/base_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#base" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/blockquote_spec.rb b/spec/ruby/library/cgi/htmlextension/blockquote_spec.rb
index a7b833b1c5..f9848375e8 100644
--- a/spec/ruby/library/cgi/htmlextension/blockquote_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/blockquote_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#blockquote" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/br_spec.rb b/spec/ruby/library/cgi/htmlextension/br_spec.rb
index dfca121884..875d335fe5 100644
--- a/spec/ruby/library/cgi/htmlextension/br_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/br_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#br" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/caption_spec.rb b/spec/ruby/library/cgi/htmlextension/caption_spec.rb
index 16615028b8..a1b5f4d964 100644
--- a/spec/ruby/library/cgi/htmlextension/caption_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/caption_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#caption" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/checkbox_group_spec.rb b/spec/ruby/library/cgi/htmlextension/checkbox_group_spec.rb
index 64f852cc52..f739d92a53 100644
--- a/spec/ruby/library/cgi/htmlextension/checkbox_group_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/checkbox_group_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#checkbox_group" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/checkbox_spec.rb b/spec/ruby/library/cgi/htmlextension/checkbox_spec.rb
index af76fa1da9..3abb3b4a31 100644
--- a/spec/ruby/library/cgi/htmlextension/checkbox_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/checkbox_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#checkbox" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/doctype_spec.rb b/spec/ruby/library/cgi/htmlextension/doctype_spec.rb
index 9a28a8883b..339ef20db9 100644
--- a/spec/ruby/library/cgi/htmlextension/doctype_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/doctype_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#doctype" do
describe "when each HTML generation" do
diff --git a/spec/ruby/library/cgi/htmlextension/file_field_spec.rb b/spec/ruby/library/cgi/htmlextension/file_field_spec.rb
index 2a0632fd58..57d91b5fd9 100644
--- a/spec/ruby/library/cgi/htmlextension/file_field_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/file_field_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#file_field" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/form_spec.rb b/spec/ruby/library/cgi/htmlextension/form_spec.rb
index 8c0ac97735..0389910cd6 100644
--- a/spec/ruby/library/cgi/htmlextension/form_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/form_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#form" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/frame_spec.rb b/spec/ruby/library/cgi/htmlextension/frame_spec.rb
index 2ddd4e1ef0..d433d058e7 100644
--- a/spec/ruby/library/cgi/htmlextension/frame_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/frame_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
require 'cgi'
describe "CGI::HtmlExtension#frame" do
diff --git a/spec/ruby/library/cgi/htmlextension/frameset_spec.rb b/spec/ruby/library/cgi/htmlextension/frameset_spec.rb
index baeb446593..81e92089e4 100644
--- a/spec/ruby/library/cgi/htmlextension/frameset_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/frameset_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
require 'cgi'
describe "CGI::HtmlExtension#frameset" do
diff --git a/spec/ruby/library/cgi/htmlextension/hidden_spec.rb b/spec/ruby/library/cgi/htmlextension/hidden_spec.rb
index 52ebd8c261..dd06dfc354 100644
--- a/spec/ruby/library/cgi/htmlextension/hidden_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/hidden_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#hidden" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/html_spec.rb b/spec/ruby/library/cgi/htmlextension/html_spec.rb
index 5d89c82086..0dfba297d2 100644
--- a/spec/ruby/library/cgi/htmlextension/html_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/html_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#html" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/image_button_spec.rb b/spec/ruby/library/cgi/htmlextension/image_button_spec.rb
index d14bec9ca3..f4e39d8028 100644
--- a/spec/ruby/library/cgi/htmlextension/image_button_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/image_button_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#image_button" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/img_spec.rb b/spec/ruby/library/cgi/htmlextension/img_spec.rb
index 994ae7fedf..8109bcd6c6 100644
--- a/spec/ruby/library/cgi/htmlextension/img_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/img_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#img" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/multipart_form_spec.rb b/spec/ruby/library/cgi/htmlextension/multipart_form_spec.rb
index 0bf2042a33..75d1b54666 100644
--- a/spec/ruby/library/cgi/htmlextension/multipart_form_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/multipart_form_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#multipart_form" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/password_field_spec.rb b/spec/ruby/library/cgi/htmlextension/password_field_spec.rb
index 683bc428ba..bb1181de75 100644
--- a/spec/ruby/library/cgi/htmlextension/password_field_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/password_field_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#password_field" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/popup_menu_spec.rb b/spec/ruby/library/cgi/htmlextension/popup_menu_spec.rb
index 3462be09b0..5e94ec1a3e 100644
--- a/spec/ruby/library/cgi/htmlextension/popup_menu_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/popup_menu_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
-require_relative 'shared/popup_menu'
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../shared/popup_menu', __FILE__)
describe "CGI::HtmlExtension#popup_menu" do
it_behaves_like :cgi_htmlextension_popup_menu, :popup_menu
diff --git a/spec/ruby/library/cgi/htmlextension/radio_button_spec.rb b/spec/ruby/library/cgi/htmlextension/radio_button_spec.rb
index 3dc3c879b5..0ce88f20d7 100644
--- a/spec/ruby/library/cgi/htmlextension/radio_button_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/radio_button_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#radio_button" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb b/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb
index 1bfd43449d..69d3444072 100644
--- a/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/radio_group_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#radio_group" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/reset_spec.rb b/spec/ruby/library/cgi/htmlextension/reset_spec.rb
index 86fa25fc8a..09184347d0 100644
--- a/spec/ruby/library/cgi/htmlextension/reset_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/reset_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#reset" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/scrolling_list_spec.rb b/spec/ruby/library/cgi/htmlextension/scrolling_list_spec.rb
index 4eb0c86c1a..da295278b1 100644
--- a/spec/ruby/library/cgi/htmlextension/scrolling_list_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/scrolling_list_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
require 'cgi'
-require_relative 'shared/popup_menu'
+require File.expand_path('../shared/popup_menu', __FILE__)
describe "CGI::HtmlExtension#scrolling_list" do
it_behaves_like :cgi_htmlextension_popup_menu, :scrolling_list
diff --git a/spec/ruby/library/cgi/htmlextension/submit_spec.rb b/spec/ruby/library/cgi/htmlextension/submit_spec.rb
index 063891b959..8b9d9b02d8 100644
--- a/spec/ruby/library/cgi/htmlextension/submit_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/submit_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#submit" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/text_field_spec.rb b/spec/ruby/library/cgi/htmlextension/text_field_spec.rb
index 44b5a5e69f..b8031d6ff5 100644
--- a/spec/ruby/library/cgi/htmlextension/text_field_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/text_field_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#text_field" do
before :each do
diff --git a/spec/ruby/library/cgi/htmlextension/textarea_spec.rb b/spec/ruby/library/cgi/htmlextension/textarea_spec.rb
index db84a973d2..e47e6ed417 100644
--- a/spec/ruby/library/cgi/htmlextension/textarea_spec.rb
+++ b/spec/ruby/library/cgi/htmlextension/textarea_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'fixtures/common'
+require File.expand_path('../fixtures/common', __FILE__)
describe "CGI::HtmlExtension#textarea" do
before :each do
diff --git a/spec/ruby/library/cgi/http_header_spec.rb b/spec/ruby/library/cgi/http_header_spec.rb
index 4094bebed3..1960d009e4 100644
--- a/spec/ruby/library/cgi/http_header_spec.rb
+++ b/spec/ruby/library/cgi/http_header_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'shared/http_header'
+require File.expand_path('../shared/http_header', __FILE__)
describe "CGI#http_header" do
- it_behaves_like :cgi_http_header, :http_header
+ it_behaves_like(:cgi_http_header, :http_header)
end
diff --git a/spec/ruby/library/cgi/initialize_spec.rb b/spec/ruby/library/cgi/initialize_spec.rb
index f794f157f0..6526aab5e8 100644
--- a/spec/ruby/library/cgi/initialize_spec.rb
+++ b/spec/ruby/library/cgi/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI#initialize" do
diff --git a/spec/ruby/library/cgi/out_spec.rb b/spec/ruby/library/cgi/out_spec.rb
index bc09f5bcbb..05fe2662dc 100644
--- a/spec/ruby/library/cgi/out_spec.rb
+++ b/spec/ruby/library/cgi/out_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI#out" do
@@ -46,6 +46,6 @@ describe "CGI#out when passed no block" do
end
it "raises a LocalJumpError" do
- -> { @cgi.out }.should raise_error(LocalJumpError)
+ lambda { @cgi.out }.should raise_error(LocalJumpError)
end
end
diff --git a/spec/ruby/library/cgi/parse_spec.rb b/spec/ruby/library/cgi/parse_spec.rb
index 04539b1226..8f05c91c7b 100644
--- a/spec/ruby/library/cgi/parse_spec.rb
+++ b/spec/ruby/library/cgi/parse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.parse when passed String" do
diff --git a/spec/ruby/library/cgi/pretty_spec.rb b/spec/ruby/library/cgi/pretty_spec.rb
index a7b7505c15..e09c327ef6 100644
--- a/spec/ruby/library/cgi/pretty_spec.rb
+++ b/spec/ruby/library/cgi/pretty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.pretty when passed html" do
diff --git a/spec/ruby/library/cgi/print_spec.rb b/spec/ruby/library/cgi/print_spec.rb
index 18ab8d673b..0db5efa0dd 100644
--- a/spec/ruby/library/cgi/print_spec.rb
+++ b/spec/ruby/library/cgi/print_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI#print" do
diff --git a/spec/ruby/library/cgi/queryextension/accept_charset_spec.rb b/spec/ruby/library/cgi/queryextension/accept_charset_spec.rb
index 0487569b9c..be340b26f0 100644
--- a/spec/ruby/library/cgi/queryextension/accept_charset_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/accept_charset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#accept_charset" do
diff --git a/spec/ruby/library/cgi/queryextension/accept_encoding_spec.rb b/spec/ruby/library/cgi/queryextension/accept_encoding_spec.rb
index 35ff3c2b30..a828ae7a42 100644
--- a/spec/ruby/library/cgi/queryextension/accept_encoding_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/accept_encoding_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#accept_encoding" do
diff --git a/spec/ruby/library/cgi/queryextension/accept_language_spec.rb b/spec/ruby/library/cgi/queryextension/accept_language_spec.rb
index 4a15d58914..77b4740251 100644
--- a/spec/ruby/library/cgi/queryextension/accept_language_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/accept_language_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#accept_language" do
diff --git a/spec/ruby/library/cgi/queryextension/accept_spec.rb b/spec/ruby/library/cgi/queryextension/accept_spec.rb
index af5209ffbe..0c7aa2ab1f 100644
--- a/spec/ruby/library/cgi/queryextension/accept_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/accept_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#accept" do
diff --git a/spec/ruby/library/cgi/queryextension/auth_type_spec.rb b/spec/ruby/library/cgi/queryextension/auth_type_spec.rb
index 25318269b1..0ec2835053 100644
--- a/spec/ruby/library/cgi/queryextension/auth_type_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/auth_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#auth_type" do
diff --git a/spec/ruby/library/cgi/queryextension/cache_control_spec.rb b/spec/ruby/library/cgi/queryextension/cache_control_spec.rb
index 0471307c22..f1718b0871 100644
--- a/spec/ruby/library/cgi/queryextension/cache_control_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/cache_control_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#cache_control" do
diff --git a/spec/ruby/library/cgi/queryextension/content_length_spec.rb b/spec/ruby/library/cgi/queryextension/content_length_spec.rb
index de823f7119..c9f0708f69 100644
--- a/spec/ruby/library/cgi/queryextension/content_length_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/content_length_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#content_length" do
diff --git a/spec/ruby/library/cgi/queryextension/content_type_spec.rb b/spec/ruby/library/cgi/queryextension/content_type_spec.rb
index 49b8389c87..a65b0a6103 100644
--- a/spec/ruby/library/cgi/queryextension/content_type_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/content_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#content_type" do
diff --git a/spec/ruby/library/cgi/queryextension/cookies_spec.rb b/spec/ruby/library/cgi/queryextension/cookies_spec.rb
index 4befd61ab7..5df457f11c 100644
--- a/spec/ruby/library/cgi/queryextension/cookies_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/cookies_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#cookies" do
diff --git a/spec/ruby/library/cgi/queryextension/element_reference_spec.rb b/spec/ruby/library/cgi/queryextension/element_reference_spec.rb
index 6ac5b46407..4aabfaa277 100644
--- a/spec/ruby/library/cgi/queryextension/element_reference_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#[]" do
diff --git a/spec/ruby/library/cgi/queryextension/from_spec.rb b/spec/ruby/library/cgi/queryextension/from_spec.rb
index 04a992cfc7..aabd9b9bb3 100644
--- a/spec/ruby/library/cgi/queryextension/from_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/from_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#from" do
diff --git a/spec/ruby/library/cgi/queryextension/gateway_interface_spec.rb b/spec/ruby/library/cgi/queryextension/gateway_interface_spec.rb
index 3ead5bd8bf..8b006063d8 100644
--- a/spec/ruby/library/cgi/queryextension/gateway_interface_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/gateway_interface_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#gateway_interface" do
diff --git a/spec/ruby/library/cgi/queryextension/has_key_spec.rb b/spec/ruby/library/cgi/queryextension/has_key_spec.rb
index 525b45b507..86ec3d0a29 100644
--- a/spec/ruby/library/cgi/queryextension/has_key_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/has_key_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'shared/has_key'
+require File.expand_path('../shared/has_key', __FILE__)
describe "CGI::QueryExtension#has_key?" do
it_behaves_like :cgi_query_extension_has_key_p, :has_key?
diff --git a/spec/ruby/library/cgi/queryextension/host_spec.rb b/spec/ruby/library/cgi/queryextension/host_spec.rb
index e820e0afc3..89e2610ba7 100644
--- a/spec/ruby/library/cgi/queryextension/host_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/host_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#host" do
diff --git a/spec/ruby/library/cgi/queryextension/include_spec.rb b/spec/ruby/library/cgi/queryextension/include_spec.rb
index 12365ea284..e8f1bf14ec 100644
--- a/spec/ruby/library/cgi/queryextension/include_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/include_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'shared/has_key'
+require File.expand_path('../shared/has_key', __FILE__)
describe "CGI::QueryExtension#include?" do
it_behaves_like :cgi_query_extension_has_key_p, :include?
diff --git a/spec/ruby/library/cgi/queryextension/key_spec.rb b/spec/ruby/library/cgi/queryextension/key_spec.rb
index d0f1e4cee2..525a0210b2 100644
--- a/spec/ruby/library/cgi/queryextension/key_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/key_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
-require_relative 'shared/has_key'
+require File.expand_path('../shared/has_key', __FILE__)
describe "CGI::QueryExtension#key?" do
it_behaves_like :cgi_query_extension_has_key_p, :key?
diff --git a/spec/ruby/library/cgi/queryextension/keys_spec.rb b/spec/ruby/library/cgi/queryextension/keys_spec.rb
index 14d77180fa..f60b1fb369 100644
--- a/spec/ruby/library/cgi/queryextension/keys_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/keys_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#keys" do
diff --git a/spec/ruby/library/cgi/queryextension/multipart_spec.rb b/spec/ruby/library/cgi/queryextension/multipart_spec.rb
index ced4cb05a1..021c847fa3 100644
--- a/spec/ruby/library/cgi/queryextension/multipart_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/multipart_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
require "stringio"
diff --git a/spec/ruby/library/cgi/queryextension/negotiate_spec.rb b/spec/ruby/library/cgi/queryextension/negotiate_spec.rb
index b6fe036042..503ae583bf 100644
--- a/spec/ruby/library/cgi/queryextension/negotiate_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/negotiate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#negotiate" do
diff --git a/spec/ruby/library/cgi/queryextension/params_spec.rb b/spec/ruby/library/cgi/queryextension/params_spec.rb
index f4449e3c8a..6d47b3eeee 100644
--- a/spec/ruby/library/cgi/queryextension/params_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/params_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#params" do
diff --git a/spec/ruby/library/cgi/queryextension/path_info_spec.rb b/spec/ruby/library/cgi/queryextension/path_info_spec.rb
index 9785df85f1..8c8af27fc9 100644
--- a/spec/ruby/library/cgi/queryextension/path_info_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/path_info_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#path_info" do
diff --git a/spec/ruby/library/cgi/queryextension/path_translated_spec.rb b/spec/ruby/library/cgi/queryextension/path_translated_spec.rb
index 417a749341..6e9db707b3 100644
--- a/spec/ruby/library/cgi/queryextension/path_translated_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/path_translated_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#path_translated" do
diff --git a/spec/ruby/library/cgi/queryextension/pragma_spec.rb b/spec/ruby/library/cgi/queryextension/pragma_spec.rb
index 02d5c91221..c0c7b20514 100644
--- a/spec/ruby/library/cgi/queryextension/pragma_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/pragma_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#pragma" do
diff --git a/spec/ruby/library/cgi/queryextension/query_string_spec.rb b/spec/ruby/library/cgi/queryextension/query_string_spec.rb
index a6b454a7eb..1065bac7ef 100644
--- a/spec/ruby/library/cgi/queryextension/query_string_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/query_string_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#query_string" do
diff --git a/spec/ruby/library/cgi/queryextension/raw_cookie2_spec.rb b/spec/ruby/library/cgi/queryextension/raw_cookie2_spec.rb
index 3d7072e346..84b0e0c0dc 100644
--- a/spec/ruby/library/cgi/queryextension/raw_cookie2_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/raw_cookie2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#raw_cookie2" do
diff --git a/spec/ruby/library/cgi/queryextension/raw_cookie_spec.rb b/spec/ruby/library/cgi/queryextension/raw_cookie_spec.rb
index ede7b9ff87..096bcf9fab 100644
--- a/spec/ruby/library/cgi/queryextension/raw_cookie_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/raw_cookie_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#raw_cookie" do
diff --git a/spec/ruby/library/cgi/queryextension/referer_spec.rb b/spec/ruby/library/cgi/queryextension/referer_spec.rb
index 6cd5dc96f8..d52b3a501a 100644
--- a/spec/ruby/library/cgi/queryextension/referer_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/referer_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#referer" do
diff --git a/spec/ruby/library/cgi/queryextension/remote_addr_spec.rb b/spec/ruby/library/cgi/queryextension/remote_addr_spec.rb
index 0259402b23..dc94e2c953 100644
--- a/spec/ruby/library/cgi/queryextension/remote_addr_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/remote_addr_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#remote_addr" do
diff --git a/spec/ruby/library/cgi/queryextension/remote_host_spec.rb b/spec/ruby/library/cgi/queryextension/remote_host_spec.rb
index cf77e0031b..f62664b9a7 100644
--- a/spec/ruby/library/cgi/queryextension/remote_host_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/remote_host_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#remote_host" do
diff --git a/spec/ruby/library/cgi/queryextension/remote_ident_spec.rb b/spec/ruby/library/cgi/queryextension/remote_ident_spec.rb
index 5b51d6b8ee..3aab059a7e 100644
--- a/spec/ruby/library/cgi/queryextension/remote_ident_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/remote_ident_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#remote_ident" do
diff --git a/spec/ruby/library/cgi/queryextension/remote_user_spec.rb b/spec/ruby/library/cgi/queryextension/remote_user_spec.rb
index 1a93bb6561..5aae6bc755 100644
--- a/spec/ruby/library/cgi/queryextension/remote_user_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/remote_user_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#remote_user" do
diff --git a/spec/ruby/library/cgi/queryextension/request_method_spec.rb b/spec/ruby/library/cgi/queryextension/request_method_spec.rb
index eabdd6998b..7fa85a3b34 100644
--- a/spec/ruby/library/cgi/queryextension/request_method_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/request_method_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#request_method" do
diff --git a/spec/ruby/library/cgi/queryextension/script_name_spec.rb b/spec/ruby/library/cgi/queryextension/script_name_spec.rb
index 341b7b6fea..7509e002d4 100644
--- a/spec/ruby/library/cgi/queryextension/script_name_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/script_name_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#script_name" do
diff --git a/spec/ruby/library/cgi/queryextension/server_name_spec.rb b/spec/ruby/library/cgi/queryextension/server_name_spec.rb
index b12aaf8c5c..acc8f9e4aa 100644
--- a/spec/ruby/library/cgi/queryextension/server_name_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/server_name_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#server_name" do
diff --git a/spec/ruby/library/cgi/queryextension/server_port_spec.rb b/spec/ruby/library/cgi/queryextension/server_port_spec.rb
index 0e688a99bf..adeabfda65 100644
--- a/spec/ruby/library/cgi/queryextension/server_port_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/server_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#server_port" do
diff --git a/spec/ruby/library/cgi/queryextension/server_protocol_spec.rb b/spec/ruby/library/cgi/queryextension/server_protocol_spec.rb
index f9dcf3c5b8..f1285bbd20 100644
--- a/spec/ruby/library/cgi/queryextension/server_protocol_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/server_protocol_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#server_protocol" do
diff --git a/spec/ruby/library/cgi/queryextension/server_software_spec.rb b/spec/ruby/library/cgi/queryextension/server_software_spec.rb
index df349cdf2e..e982a6f31c 100644
--- a/spec/ruby/library/cgi/queryextension/server_software_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/server_software_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#server_software" do
diff --git a/spec/ruby/library/cgi/queryextension/user_agent_spec.rb b/spec/ruby/library/cgi/queryextension/user_agent_spec.rb
index ec5ef187dd..8bbfed17c5 100644
--- a/spec/ruby/library/cgi/queryextension/user_agent_spec.rb
+++ b/spec/ruby/library/cgi/queryextension/user_agent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI::QueryExtension#user_agent" do
diff --git a/spec/ruby/library/cgi/rfc1123_date_spec.rb b/spec/ruby/library/cgi/rfc1123_date_spec.rb
index 6904eeabaa..73e07c6fbd 100644
--- a/spec/ruby/library/cgi/rfc1123_date_spec.rb
+++ b/spec/ruby/library/cgi/rfc1123_date_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
-describe "CGI.rfc1123_date when passed Time" do
+describe "CGI.rfc1123_date when passsed Time" do
it "returns the passed Time formatted in RFC1123 ('Sat, 01 Dec 2007 15:56:42 GMT')" do
input = Time.at(1196524602)
expected = 'Sat, 01 Dec 2007 15:56:42 GMT'
diff --git a/spec/ruby/library/cgi/shared/http_header.rb b/spec/ruby/library/cgi/shared/http_header.rb
index b225b5925e..b6d81d2e0e 100644
--- a/spec/ruby/library/cgi/shared/http_header.rb
+++ b/spec/ruby/library/cgi/shared/http_header.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'cgi'
describe :cgi_http_header, shared: true do
diff --git a/spec/ruby/library/cgi/unescapeElement_spec.rb b/spec/ruby/library/cgi/unescapeElement_spec.rb
index ae4d50b076..cc26f9b484 100644
--- a/spec/ruby/library/cgi/unescapeElement_spec.rb
+++ b/spec/ruby/library/cgi/unescapeElement_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.unescapeElement when passed String, elements, ..." do
diff --git a/spec/ruby/library/cgi/unescapeHTML_spec.rb b/spec/ruby/library/cgi/unescapeHTML_spec.rb
index 46387d4f01..611ce0a6f1 100644
--- a/spec/ruby/library/cgi/unescapeHTML_spec.rb
+++ b/spec/ruby/library/cgi/unescapeHTML_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.unescapeHTML" do
diff --git a/spec/ruby/library/cgi/unescape_spec.rb b/spec/ruby/library/cgi/unescape_spec.rb
index db4834e7e8..8cf988b9dd 100644
--- a/spec/ruby/library/cgi/unescape_spec.rb
+++ b/spec/ruby/library/cgi/unescape_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'cgi'
describe "CGI.unescape" do
diff --git a/spec/ruby/library/cmath/math/acos_spec.rb b/spec/ruby/library/cmath/math/acos_spec.rb
deleted file mode 100644
index 2e9104f835..0000000000
--- a/spec/ruby/library/cmath/math/acos_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/acos'
-
- describe "Math#acos" do
- it_behaves_like :complex_math_acos, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:acos)
- end
- end
-
- describe "Math.acos" do
- it_behaves_like :complex_math_acos, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/acosh_spec.rb b/spec/ruby/library/cmath/math/acosh_spec.rb
deleted file mode 100644
index 809112f6c0..0000000000
--- a/spec/ruby/library/cmath/math/acosh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/acosh'
-
- describe "Math#acosh" do
- it_behaves_like :complex_math_acosh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:acosh)
- end
- end
-
- describe "Math.acosh" do
- it_behaves_like :complex_math_acosh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/asin_spec.rb b/spec/ruby/library/cmath/math/asin_spec.rb
deleted file mode 100644
index 4ac588ebd2..0000000000
--- a/spec/ruby/library/cmath/math/asin_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/asin'
-
- describe "Math#asin" do
- it_behaves_like :complex_math_asin, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:asin)
- end
- end
-
- describe "Math.asin" do
- it_behaves_like :complex_math_asin, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/asinh_spec.rb b/spec/ruby/library/cmath/math/asinh_spec.rb
deleted file mode 100644
index 7d8b397a04..0000000000
--- a/spec/ruby/library/cmath/math/asinh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/asinh'
-
- describe "Math#asinh" do
- it_behaves_like :complex_math_asinh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:asinh)
- end
- end
-
- describe "Math.asinh" do
- it_behaves_like :complex_math_asinh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/atan2_spec.rb b/spec/ruby/library/cmath/math/atan2_spec.rb
deleted file mode 100644
index 1a9b7d7607..0000000000
--- a/spec/ruby/library/cmath/math/atan2_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/atan2'
-
- describe "Math#atan2" do
- it_behaves_like :complex_math_atan2, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:atan2)
- end
- end
-
- describe "Math.atan2" do
- it_behaves_like :complex_math_atan2, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/atan_spec.rb b/spec/ruby/library/cmath/math/atan_spec.rb
deleted file mode 100644
index b0171081a6..0000000000
--- a/spec/ruby/library/cmath/math/atan_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/atan'
-
- describe "Math#atan" do
- it_behaves_like :complex_math_atan, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:atan)
- end
- end
-
- describe "Math.atan" do
- it_behaves_like :complex_math_atan, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/atanh_spec.rb b/spec/ruby/library/cmath/math/atanh_spec.rb
deleted file mode 100644
index 6b22c6c9e4..0000000000
--- a/spec/ruby/library/cmath/math/atanh_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative '../../../fixtures/math/common'
- require_relative '../../../shared/math/atanh'
- require_relative 'shared/atanh'
-
- describe "Math#atanh" do
- it_behaves_like :math_atanh_base, :atanh, IncludesMath.new
- it_behaves_like :complex_math_atanh_complex, :atanh, IncludesMath.new
-
- it_behaves_like :math_atanh_private, :atanh, IncludesMath.new
- end
-
- describe "Math.atanh" do
- it_behaves_like :math_atanh_base, :atanh, CMath
- it_behaves_like :complex_math_atanh_complex, :atanh, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/cos_spec.rb b/spec/ruby/library/cmath/math/cos_spec.rb
deleted file mode 100644
index 3f097bcb3b..0000000000
--- a/spec/ruby/library/cmath/math/cos_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/cos'
-
- describe "Math#cos" do
- it_behaves_like :complex_math_cos, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:cos)
- end
- end
-
- describe "Math.cos" do
- it_behaves_like :complex_math_cos, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/cosh_spec.rb b/spec/ruby/library/cmath/math/cosh_spec.rb
deleted file mode 100644
index 197f899981..0000000000
--- a/spec/ruby/library/cmath/math/cosh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/cosh'
-
- describe "Math#cosh" do
- it_behaves_like :complex_math_cosh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:cosh)
- end
- end
-
- describe "Math.cosh" do
- it_behaves_like :complex_math_cosh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/exp_spec.rb b/spec/ruby/library/cmath/math/exp_spec.rb
deleted file mode 100644
index eef2ec3129..0000000000
--- a/spec/ruby/library/cmath/math/exp_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/exp'
-
- describe "Math#exp" do
- it_behaves_like :complex_math_exp, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:exp)
- end
- end
-
- describe "Math.exp" do
- it_behaves_like :complex_math_exp, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/log10_spec.rb b/spec/ruby/library/cmath/math/log10_spec.rb
deleted file mode 100644
index 603bbb1457..0000000000
--- a/spec/ruby/library/cmath/math/log10_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/log10'
-
- describe "Math#log10" do
- it_behaves_like :complex_math_log10, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:log10)
- end
- end
-
- describe "Math.log10" do
- it_behaves_like :complex_math_log10, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/log_spec.rb b/spec/ruby/library/cmath/math/log_spec.rb
deleted file mode 100644
index b4da781323..0000000000
--- a/spec/ruby/library/cmath/math/log_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/log'
-
- describe "Math#log" do
- it_behaves_like :complex_math_log, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:log)
- end
- end
-
- describe "Math.log" do
- it_behaves_like :complex_math_log, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/acos.rb b/spec/ruby/library/cmath/math/shared/acos.rb
deleted file mode 100644
index 65637fa838..0000000000
--- a/spec/ruby/library/cmath/math/shared/acos.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_acos, shared: true do
- it "returns the arccosine of the passed argument" do
- @object.send(:acos, 1).should be_close(0.0, TOLERANCE)
- @object.send(:acos, 0).should be_close(1.5707963267949, TOLERANCE)
- @object.send(:acos, -1).should be_close(Math::PI,TOLERANCE)
- end
-
- it "returns the arccosine for Complex numbers" do
- @object.send(:acos, Complex(3, 4)).should be_close(Complex(0.93681246115572, -2.30550903124348), TOLERANCE)
- end
-
- it "returns the arccosine for numbers greater than 1.0 as a Complex number" do
- @object.send(:acos, 1.0001).should be_close(Complex(0.0, 0.0141420177752494), TOLERANCE)
- end
-
- it "returns the arccosine for numbers less than -1.0 as a Complex number" do
- @object.send(:acos, -1.0001).should be_close(Complex(3.14159265358979, -0.0141420177752495), TOLERANCE)
- end
-end
-
-describe :complex_math_acos_bang, shared: true do
- it "returns the arccosine of the argument" do
- @object.send(:acos!, 1).should be_close(0.0, TOLERANCE)
- @object.send(:acos!, 0).should be_close(1.5707963267949, TOLERANCE)
- @object.send(:acos!, -1).should be_close(Math::PI,TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:acos!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-
- it "raises an Errno::EDOM for numbers greater than 1.0" do
- -> { @object.send(:acos!, 1.0001) }.should raise_error(Errno::EDOM)
- end
-
- it "raises an Errno::EDOM for numbers less than -1.0" do
- -> { @object.send(:acos!, -1.0001) }.should raise_error(Errno::EDOM)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/acosh.rb b/spec/ruby/library/cmath/math/shared/acosh.rb
deleted file mode 100644
index 285b0b823f..0000000000
--- a/spec/ruby/library/cmath/math/shared/acosh.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_acosh, shared: true do
- it "returns the principle value of the inverse hyperbolic cosine of the argument" do
- @object.send(:acosh, 14.2).should be_close(3.345146999647, TOLERANCE)
- @object.send(:acosh, 1.0).should be_close(0.0, TOLERANCE)
- end
-
- it "returns the principle value of the inverse hyperbolic cosine for numbers less than 1.0 as a Complex number" do
- @object.send(:acosh, 1.0 - TOLERANCE).should be_close(Complex(0.0, 0.00774598605746135), TOLERANCE)
- @object.send(:acosh, 0).should be_close(Complex(0.0, 1.5707963267949), TOLERANCE)
- @object.send(:acosh, -1.0).should be_close(Complex(0.0, 3.14159265358979), TOLERANCE)
- end
-
- it "returns the principle value of the inverse hyperbolic cosine for Complex numbers" do
- @object.send(:acosh, Complex(3, 4))
- @object.send(:acosh, Complex(3, 4)).imaginary.should be_close(0.93681246115572, TOLERANCE)
- @object.send(:acosh, Complex(3, 4)).real.should be_close(2.305509031243477, TOLERANCE)
- end
-end
-
-describe :complex_math_acosh_bang, shared: true do
- it "returns the principle value of the inverse hyperbolic cosine of the argument" do
- @object.send(:acosh!, 14.2).should be_close(3.345146999647, TOLERANCE)
- @object.send(:acosh!, 1.0).should be_close(0.0, TOLERANCE)
- end
-
- it "raises Errno::EDOM for numbers less than 1.0" do
- -> { @object.send(:acosh!, 1.0 - TOLERANCE) }.should raise_error(Errno::EDOM)
- -> { @object.send(:acosh!, 0) }.should raise_error(Errno::EDOM)
- -> { @object.send(:acosh!, -1.0) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:acosh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/asin.rb b/spec/ruby/library/cmath/math/shared/asin.rb
deleted file mode 100644
index 91fed7aa06..0000000000
--- a/spec/ruby/library/cmath/math/shared/asin.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_asin, shared: true do
- it "returns the arcsine of the argument" do
- @object.send(:asin, 1).should be_close(Math::PI/2, TOLERANCE)
- @object.send(:asin, 0).should be_close(0.0, TOLERANCE)
- @object.send(:asin, -1).should be_close(-Math::PI/2, TOLERANCE)
- @object.send(:asin, 0.25).should be_close(0.252680255142079, TOLERANCE)
- @object.send(:asin, 0.50).should be_close(0.523598775598299, TOLERANCE)
- @object.send(:asin, 0.75).should be_close(0.8480620789814816,TOLERANCE)
- end
-
- it "returns the arcsine for Complex numbers" do
- @object.send(:asin, Complex(3, 4)).should be_close(Complex(0.633983865639174, 2.30550903124347), TOLERANCE)
- end
-
- it "returns a Complex number when the argument is greater than 1.0" do
- @object.send(:asin, 1.0001).should be_close(Complex(1.5707963267949, -0.0141420177752494), TOLERANCE)
- end
-
- it "returns a Complex number when the argument is less than -1.0" do
- @object.send(:asin, -1.0001).should be_close(Complex(-1.5707963267949, 0.0141420177752494), TOLERANCE)
- end
-end
-
-describe :complex_math_asin_bang, shared: true do
- it "returns the arcsine of the argument" do
- @object.send(:asin!, 1).should be_close(Math::PI/2, TOLERANCE)
- @object.send(:asin!, 0).should be_close(0.0, TOLERANCE)
- @object.send(:asin!, -1).should be_close(-Math::PI/2, TOLERANCE)
- @object.send(:asin!, 0.25).should be_close(0.252680255142079, TOLERANCE)
- @object.send(:asin!, 0.50).should be_close(0.523598775598299, TOLERANCE)
- @object.send(:asin!, 0.75).should be_close(0.8480620789814816,TOLERANCE)
- end
-
- it "raises an Errno::EDOM if the argument is greater than 1.0" do
- -> { @object.send(:asin!, 1.0001) }.should raise_error( Errno::EDOM)
- end
-
- it "raises an Errno::EDOM if the argument is less than -1.0" do
- -> { @object.send(:asin!, -1.0001) }.should raise_error( Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:asin!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/asinh.rb b/spec/ruby/library/cmath/math/shared/asinh.rb
deleted file mode 100644
index b4ddd3a22e..0000000000
--- a/spec/ruby/library/cmath/math/shared/asinh.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_asinh, shared: true do
- it "returns the inverse hyperbolic sin of the argument" do
- @object.send(:asinh, 1.5).should be_close(1.19476321728711, TOLERANCE)
- @object.send(:asinh, -2.97).should be_close(-1.8089166921397, TOLERANCE)
- @object.send(:asinh, 0.0).should == 0.0
- @object.send(:asinh, -0.0).should == -0.0
- @object.send(:asinh, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
- @object.send(:asinh, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
- end
-
- it "returns the inverse hyperbolic sin for Complex numbers" do
- @object.send(:asinh, Complex(3, 4)).should be_close(Complex(2.29991404087927, 0.917616853351479), TOLERANCE)
- @object.send(:asinh, Complex(3.5, -4)).should be_close(Complex(2.36263337274419, -0.843166327537659), TOLERANCE)
- end
-end
-
-describe :complex_math_asinh_bang, shared: true do
- it "returns the inverse hyperbolic sin of the argument" do
- @object.send(:asinh!, 1.5).should be_close(1.19476321728711, TOLERANCE)
- @object.send(:asinh!, -2.97).should be_close(-1.8089166921397, TOLERANCE)
- @object.send(:asinh!, 0.0).should == 0.0
- @object.send(:asinh!, -0.0).should == -0.0
- @object.send(:asinh!, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
- @object.send(:asinh!, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:asinh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/atan.rb b/spec/ruby/library/cmath/math/shared/atan.rb
deleted file mode 100644
index 63a496e841..0000000000
--- a/spec/ruby/library/cmath/math/shared/atan.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_atan, shared: true do
- it "returns the arctangent of the argument" do
- @object.send(:atan, 1).should be_close(Math::PI/4, TOLERANCE)
- @object.send(:atan, 0).should be_close(0.0, TOLERANCE)
- @object.send(:atan, -1).should be_close(-Math::PI/4, TOLERANCE)
- @object.send(:atan, 0.25).should be_close(0.244978663126864, TOLERANCE)
- @object.send(:atan, 0.50).should be_close(0.463647609000806, TOLERANCE)
- @object.send(:atan, 0.75).should be_close(0.643501108793284, TOLERANCE)
- end
-
- it "returns the arctangent for Complex numbers" do
- @object.send(:atan, Complex(3, 4)).should be_close(Complex(1.44830699523146, 0.158997191679999), TOLERANCE)
- @object.send(:atan, Complex(3.5, -4)).should be_close(Complex(1.44507428165589, -0.140323762363786), TOLERANCE)
- end
-end
-
-describe :complex_math_atan_bang, shared: true do
- it "returns the arctangent of the argument" do
- @object.send(:atan!, 1).should be_close(Math::PI/4, TOLERANCE)
- @object.send(:atan!, 0).should be_close(0.0, TOLERANCE)
- @object.send(:atan!, -1).should be_close(-Math::PI/4, TOLERANCE)
- @object.send(:atan!, 0.25).should be_close(0.244978663126864, TOLERANCE)
- @object.send(:atan!, 0.50).should be_close(0.463647609000806, TOLERANCE)
- @object.send(:atan!, 0.75).should be_close(0.643501108793284, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:atan!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/atan2.rb b/spec/ruby/library/cmath/math/shared/atan2.rb
deleted file mode 100644
index 6d89423924..0000000000
--- a/spec/ruby/library/cmath/math/shared/atan2.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_atan2, shared: true do
- it "returns the arc tangent of the passed arguments" do
- @object.send(:atan2, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
- @object.send(:atan2, 0.0, 1.0).should be_close(0.0, TOLERANCE)
- @object.send(:atan2, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
- @object.send(:atan2, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
- end
-
- it "returns the arc tangent for two Complex numbers" do
- CMath.atan2(Complex(3, 4), Complex(3.5, -4)).should be_close(Complex(-0.641757436698881, 1.10829873031207), TOLERANCE)
- end
-
- it "returns the arc tangent for Complex and real numbers" do
- CMath.atan2(Complex(3, 4), -7).should be_close(Complex(2.61576754731561, -0.494290673139855), TOLERANCE)
- CMath.atan2(5, Complex(3.5, -4)).should be_close(Complex(0.739102348493673, 0.487821626522923), TOLERANCE)
- end
-end
-
-describe :complex_math_atan2_bang, shared: true do
- it "returns the arc tangent of the passed arguments" do
- @object.send(:atan2!, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
- @object.send(:atan2!, 0.0, 1.0).should be_close(0.0, TOLERANCE)
- @object.send(:atan2!, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
- @object.send(:atan2!, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:atan2!, Complex(4, 5), Complex(4, 5)) }.should raise_error(TypeError)
- -> { @object.send(:atan2!, 4, Complex(4, 5)) }.should raise_error(TypeError)
- -> { @object.send(:atan2!, Complex(4, 5), 5) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/atanh.rb b/spec/ruby/library/cmath/math/shared/atanh.rb
deleted file mode 100644
index ae80e61bec..0000000000
--- a/spec/ruby/library/cmath/math/shared/atanh.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_atanh_complex, shared: true do
- it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
- value = Complex(18.36840028483855, 1.5707963267948966)
- @object.send(@method, 1.0 + Float::EPSILON).should be_close(value, TOLERANCE)
-
- value = Complex(0.100335347731076, 1.5707963267949)
- @object.send(@method, 10).should be_close(value, TOLERANCE)
- end
-
- it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
- value = Complex(-18.36840028483855, 1.5707963267948966)
- @object.send(@method, -1.0 - Float::EPSILON).should be_close(value, TOLERANCE)
-
- value = Complex(0.100335347731076, 1.5707963267949)
- @object.send(@method, 10).should be_close(value, TOLERANCE)
- end
-
- it "returns the inverse hyperbolic tangent for Complex numbers" do
- value = Complex(0.117500907311434, 1.40992104959658)
- @object.send(@method, Complex(3, 4)).should be_close(value, TOLERANCE)
- end
-end
-
-describe :complex_math_atanh_no_complex, shared: true do
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:atanh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/cos.rb b/spec/ruby/library/cmath/math/shared/cos.rb
deleted file mode 100644
index 31cb5ab1e5..0000000000
--- a/spec/ruby/library/cmath/math/shared/cos.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_cos, shared: true do
- it "returns the cosine of the argument expressed in radians" do
- @object.send(:cos, CMath::PI).should be_close(-1.0, TOLERANCE)
- @object.send(:cos, 0).should be_close(1.0, TOLERANCE)
- @object.send(:cos, CMath::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos, 2*Math::PI).should be_close(1.0, TOLERANCE)
- end
-
- it "returns the cosine for Complex numbers" do
- @object.send(:cos, Complex(0, CMath::PI)).should be_close(Complex(11.5919532755215, 0.0), TOLERANCE)
- @object.send(:cos, Complex(3, 4)).should be_close(Complex(-27.0349456030742, -3.85115333481178), TOLERANCE)
- end
-end
-
-describe :complex_math_cos_bang, shared: true do
- it "returns the cosine of the argument expressed in radians" do
- @object.send(:cos!, CMath::PI).should be_close(-1.0, TOLERANCE)
- @object.send(:cos!, 0).should be_close(1.0, TOLERANCE)
- @object.send(:cos!, CMath::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos!, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos!, 2*Math::PI).should be_close(1.0, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:cos!, Complex(3, 4)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/cosh.rb b/spec/ruby/library/cmath/math/shared/cosh.rb
deleted file mode 100644
index 7cf561c985..0000000000
--- a/spec/ruby/library/cmath/math/shared/cosh.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_cosh, shared: true do
- it "returns the hyperbolic cosine of the passed argument" do
- @object.send(:cosh, 0.0).should == 1.0
- @object.send(:cosh, -0.0).should == 1.0
- @object.send(:cosh, 1.5).should be_close(2.35240961524325, TOLERANCE)
- @object.send(:cosh, -2.99).should be_close(9.96798496414416, TOLERANCE)
- end
-
- it "returns the hyperbolic cosine for Complex numbers" do
- @object.send(:cosh, Complex(0, CMath::PI)).should be_close(Complex(-1.0, 0.0), TOLERANCE)
- @object.send(:cosh, Complex(3, 4)).should be_close(Complex(-6.58066304055116, -7.58155274274654), TOLERANCE)
- end
-end
-
-describe :complex_math_cosh_bang, shared: true do
- it "returns the hyperbolic cosine of the passed argument" do
- @object.send(:cosh!, 0.0).should == 1.0
- @object.send(:cosh!, -0.0).should == 1.0
- @object.send(:cosh!, 1.5).should be_close(2.35240961524325, TOLERANCE)
- @object.send(:cosh!, -2.99).should be_close(9.96798496414416, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:cosh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/exp.rb b/spec/ruby/library/cmath/math/shared/exp.rb
deleted file mode 100644
index 6715ac63d3..0000000000
--- a/spec/ruby/library/cmath/math/shared/exp.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_exp, shared: true do
- it "returns the base-e exponential of the passed argument" do
- @object.send(:exp, 0.0).should == 1.0
- @object.send(:exp, -0.0).should == 1.0
- @object.send(:exp, -1.8).should be_close(0.165298888221587, TOLERANCE)
- @object.send(:exp, 1.25).should be_close(3.49034295746184, TOLERANCE)
- end
-
- it "returns the base-e exponential for Complex numbers" do
- @object.send(:exp, Complex(0, 0)).should == Complex(1.0, 0.0)
- @object.send(:exp, Complex(1, 3)).should be_close(Complex(-2.69107861381979, 0.383603953541131), TOLERANCE)
- end
-end
-
-describe :complex_math_exp_bang, shared: true do
- it "returns the base-e exponential of the passed argument" do
- @object.send(:exp!, 0.0).should == 1.0
- @object.send(:exp!, -0.0).should == 1.0
- @object.send(:exp!, -1.8).should be_close(0.165298888221587, TOLERANCE)
- @object.send(:exp!, 1.25).should be_close(3.49034295746184, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:exp!, Complex(1, 3)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/log.rb b/spec/ruby/library/cmath/math/shared/log.rb
deleted file mode 100644
index 4b23e8c5f2..0000000000
--- a/spec/ruby/library/cmath/math/shared/log.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_log, shared: true do
- it "returns the natural logarithm of the passed argument" do
- @object.send(:log, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
- @object.send(:log, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
- @object.send(:log, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log, 10).should be_close( 2.30258509299405, TOLERANCE)
- @object.send(:log, 10e15).should be_close(36.8413614879047, TOLERANCE)
- end
-
- it "returns the natural logarithm for Complex numbers" do
- @object.send(:log, Complex(3, 4)).should be_close(Complex(1.6094379124341, 0.927295218001612), TOLERANCE)
- @object.send(:log, Complex(-3, 4)).should be_close(Complex(1.6094379124341, 2.21429743558818), TOLERANCE)
- end
-
- it "returns the natural logarithm for negative numbers as a Complex number" do
- @object.send(:log, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
- @object.send(:log, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
- end
-end
-
-describe :complex_math_log_bang, shared: true do
- it "returns the natural logarithm of the argument" do
- @object.send(:log!, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
- @object.send(:log!, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
- @object.send(:log!, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log!, 10).should be_close( 2.30258509299405, TOLERANCE)
- @object.send(:log!, 10e15).should be_close(36.8413614879047, TOLERANCE)
- end
-
- it "raises an Errno::EDOM if the argument is less than 0" do
- -> { @object.send(:log!, -10) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:log!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/log10.rb b/spec/ruby/library/cmath/math/shared/log10.rb
deleted file mode 100644
index f49934d958..0000000000
--- a/spec/ruby/library/cmath/math/shared/log10.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_log10, shared: true do
- it "returns the base-10 logarithm of the passed argument" do
- @object.send(:log10, 0.0001).should be_close(-4.0, TOLERANCE)
- @object.send(:log10, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
- @object.send(:log10, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log10, 10).should be_close(1.0, TOLERANCE)
- @object.send(:log10, 10e15).should be_close(16.0, TOLERANCE)
- end
-
- it "returns the base-10 logarithm for Complex numbers" do
- @object.send(:log10, Complex(3, 4)).should be_close(Complex(0.698970004336019, 0.402719196273373), TOLERANCE)
- @object.send(:log10, Complex(-3, 4)).should be_close(Complex(0.698970004336019, 0.961657157568468), TOLERANCE)
- end
-
- # BUG: does not work correctly, because Math#log10
- # does not check for negative values
- #it "returns the base-10 logarithm for negative numbers as a Complex number" do
- # @object.send(:log10, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
- # @object.send(:log10, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
- #end
-end
-
-describe :complex_math_log10_bang, shared: true do
- it "returns the base-10 logarithm of the argument" do
- @object.send(:log10!, 0.0001).should be_close(-4.0, TOLERANCE)
- @object.send(:log10!, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
- @object.send(:log10!, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log10!, 10).should be_close(1.0, TOLERANCE)
- @object.send(:log10!, 10e15).should be_close(16.0, TOLERANCE)
- end
-
- it "raises an Errno::EDOM when the passed argument is negative" do
- -> { @object.send(:log10!, -10) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:log10!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/sin.rb b/spec/ruby/library/cmath/math/shared/sin.rb
deleted file mode 100644
index 1cb1b29cda..0000000000
--- a/spec/ruby/library/cmath/math/shared/sin.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_sin, shared: true do
- it "returns the sine of the passed argument expressed in radians" do
- @object.send(:sin, CMath::PI).should be_close(0.0, TOLERANCE)
- @object.send(:sin, 0).should be_close(0.0, TOLERANCE)
- @object.send(:sin, CMath::PI/2).should be_close(1.0, TOLERANCE)
- @object.send(:sin, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
- @object.send(:sin, 2*Math::PI).should be_close(0.0, TOLERANCE)
- end
-
- it "returns the sine for Complex numbers" do
- @object.send(:sin, Complex(0, CMath::PI)).should be_close(Complex(0.0, 11.5487393572577), TOLERANCE)
- @object.send(:sin, Complex(3, 4)).should be_close(Complex(3.85373803791938, -27.0168132580039), TOLERANCE)
- end
-end
-
-describe :complex_math_sin_bang, shared: true do
- it "returns the sine of the passed argument expressed in radians" do
- @object.send(:sin!, CMath::PI).should be_close(0.0, TOLERANCE)
- @object.send(:sin!, 0).should be_close(0.0, TOLERANCE)
- @object.send(:sin!, CMath::PI/2).should be_close(1.0, TOLERANCE)
- @object.send(:sin!, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
- @object.send(:sin!, 2*Math::PI).should be_close(0.0, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:sin!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/sinh.rb b/spec/ruby/library/cmath/math/shared/sinh.rb
deleted file mode 100644
index de80a376da..0000000000
--- a/spec/ruby/library/cmath/math/shared/sinh.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_sinh, shared: true do
- it "returns the hyperbolic sin of the argument" do
- @object.send(:sinh, 0.0).should == 0.0
- @object.send(:sinh, -0.0).should == 0.0
- @object.send(:sinh, 1.5).should be_close(2.12927945509482, TOLERANCE)
- @object.send(:sinh, -2.8).should be_close(-8.19191835423591, TOLERANCE)
- end
-
- it "returns the hyperbolic sin for Complex numbers" do
- @object.send(:sinh, Complex(0, CMath::PI)).should be_close(Complex(-0.0, 1.22464679914735e-16), TOLERANCE)
- @object.send(:sinh, Complex(3, 4)).should be_close(Complex(-6.548120040911, -7.61923172032141), TOLERANCE)
- end
-end
-
-describe :complex_math_sinh_bang, shared: true do
- it "returns the hyperbolic sin of the argument" do
- @object.send(:sinh!, 0.0).should == 0.0
- @object.send(:sinh!, -0.0).should == 0.0
- @object.send(:sinh!, 1.5).should be_close(2.12927945509482, TOLERANCE)
- @object.send(:sinh!, -2.8).should be_close(-8.19191835423591, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:sinh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/sqrt.rb b/spec/ruby/library/cmath/math/shared/sqrt.rb
deleted file mode 100644
index 23b1ba48ff..0000000000
--- a/spec/ruby/library/cmath/math/shared/sqrt.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_sqrt, shared: true do
- it "returns the square root for positive numbers" do
- @object.send(:sqrt, 4).should == 2
- @object.send(:sqrt, 19.36).should == 4.4
- end
-
- it "returns the square root for negative numbers" do
- @object.send(:sqrt, -4).should == Complex(0, 2.0)
- @object.send(:sqrt, -19.36).should == Complex(0, 4.4)
- end
-
- it "returns the square root for Complex numbers" do
- @object.send(:sqrt, Complex(4, 5)).should be_close(Complex(2.2806933416653, 1.09615788950152), TOLERANCE)
- @object.send(:sqrt, Complex(4, -5)).should be_close(Complex(2.2806933416653, -1.09615788950152), TOLERANCE)
- end
-end
-
-describe :complex_math_sqrt_bang, shared: true do
- it "returns the square root for positive numbers" do
- @object.send(:sqrt!, 4).should == 2
- @object.send(:sqrt!, 19.36).should == 4.4
- end
-
- it "raises Errno::EDOM when the passed argument is negative" do
- -> { @object.send(:sqrt!, -4) }.should raise_error(Errno::EDOM)
- -> { @object.send(:sqrt!, -19.36) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:sqrt!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/tan.rb b/spec/ruby/library/cmath/math/shared/tan.rb
deleted file mode 100644
index 9022c84fc9..0000000000
--- a/spec/ruby/library/cmath/math/shared/tan.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_tan, shared: true do
- it "returns the tangent of the argument" do
- @object.send(:tan, 0.0).should == 0.0
- @object.send(:tan, -0.0).should == -0.0
- @object.send(:tan, 4.22).should be_close(1.86406937682395, TOLERANCE)
- @object.send(:tan, -9.65).should be_close(-0.229109052606441, TOLERANCE)
- end
-
- it "returns the tangent for Complex numbers" do
- @object.send(:tan, Complex(0, CMath::PI)).should be_close(Complex(0.0, 0.99627207622075), TOLERANCE)
- @object.send(:tan, Complex(3, 4)).should be_close(Complex(-0.000187346204629452, 0.999355987381473), TOLERANCE)
- end
-end
-
-describe :complex_math_tan_bang, shared: true do
- it "returns the tangent of the argument" do
- @object.send(:tan!, 0.0).should == 0.0
- @object.send(:tan!, -0.0).should == -0.0
- @object.send(:tan!, 4.22).should be_close(1.86406937682395, TOLERANCE)
- @object.send(:tan!, -9.65).should be_close(-0.229109052606441, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:tan!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/tanh.rb b/spec/ruby/library/cmath/math/shared/tanh.rb
deleted file mode 100644
index f2c9a5abb1..0000000000
--- a/spec/ruby/library/cmath/math/shared/tanh.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_tanh, shared: true do
- it "returns the hyperbolic tangent of the argument" do
- @object.send(:tanh, 0.0).should == 0.0
- @object.send(:tanh, -0.0).should == -0.0
- @object.send(:tanh, infinity_value).should == 1.0
- @object.send(:tanh, -infinity_value).should == -1.0
- @object.send(:tanh, 2.5).should be_close(0.98661429815143, TOLERANCE)
- @object.send(:tanh, -4.892).should be_close(-0.999887314427707, TOLERANCE)
- end
-
- it "returns the hyperbolic tangent for Complex numbers" do
- @object.send(:tanh, Complex(0, CMath::PI)).should be_close(Complex(0.0, -1.22464679914735e-16), TOLERANCE)
- @object.send(:tanh, Complex(3, 4)).should be_close(Complex(1.00070953606723, 0.00490825806749599), TOLERANCE)
- end
-end
-
-describe :complex_math_tanh_bang, shared: true do
- it "returns the hyperbolic tangent of the argument" do
- @object.send(:tanh!, 0.0).should == 0.0
- @object.send(:tanh!, -0.0).should == -0.0
- @object.send(:tanh!, infinity_value).should == 1.0
- @object.send(:tanh!, -infinity_value).should == -1.0
- @object.send(:tanh!, 2.5).should be_close(0.98661429815143, TOLERANCE)
- @object.send(:tanh!, -4.892).should be_close(-0.999887314427707, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:tanh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/sin_spec.rb b/spec/ruby/library/cmath/math/sin_spec.rb
deleted file mode 100644
index b7a219fbbd..0000000000
--- a/spec/ruby/library/cmath/math/sin_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/sin'
-
- describe "Math#sin" do
- it_behaves_like :complex_math_sin, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:sin)
- end
- end
-
- describe "Math.sin" do
- it_behaves_like :complex_math_sin, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/sinh_spec.rb b/spec/ruby/library/cmath/math/sinh_spec.rb
deleted file mode 100644
index c6e6a3baf4..0000000000
--- a/spec/ruby/library/cmath/math/sinh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/sinh'
-
- describe "Math#sinh" do
- it_behaves_like :complex_math_sinh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:sinh)
- end
- end
-
- describe "Math.sinh" do
- it_behaves_like :complex_math_sinh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/sqrt_spec.rb b/spec/ruby/library/cmath/math/sqrt_spec.rb
deleted file mode 100644
index 421824f99c..0000000000
--- a/spec/ruby/library/cmath/math/sqrt_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/sqrt'
-
- describe "Math#sqrt" do
- it_behaves_like :complex_math_sqrt, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:sqrt)
- end
- end
-
- describe "Math.sqrt" do
- it_behaves_like :complex_math_sqrt, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/tan_spec.rb b/spec/ruby/library/cmath/math/tan_spec.rb
deleted file mode 100644
index e2acdd8091..0000000000
--- a/spec/ruby/library/cmath/math/tan_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/tan'
-
- describe "Math#tan" do
- it_behaves_like :complex_math_tan, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:tan)
- end
- end
-
- describe "Math.tan" do
- it_behaves_like :complex_math_tan, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/tanh_spec.rb b/spec/ruby/library/cmath/math/tanh_spec.rb
deleted file mode 100644
index 94da20cd51..0000000000
--- a/spec/ruby/library/cmath/math/tanh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/tanh'
-
- describe "Math#tanh" do
- it_behaves_like :complex_math_tanh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:tanh)
- end
- end
-
- describe "Math.tanh" do
- it_behaves_like :complex_math_tanh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/complex/math/acos_spec.rb b/spec/ruby/library/complex/math/acos_spec.rb
new file mode 100644
index 0000000000..84425dbaa1
--- /dev/null
+++ b/spec/ruby/library/complex/math/acos_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/acos', __FILE__)
+
+describe "Math#acos" do
+ it_behaves_like :complex_math_acos, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:acos)
+ end
+end
+
+describe "Math.acos" do
+ it_behaves_like :complex_math_acos, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/acosh_spec.rb b/spec/ruby/library/complex/math/acosh_spec.rb
new file mode 100644
index 0000000000..cda9ce38d6
--- /dev/null
+++ b/spec/ruby/library/complex/math/acosh_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/acosh', __FILE__)
+
+describe "Math#acosh" do
+ it_behaves_like :complex_math_acosh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:acosh)
+ end
+end
+
+describe "Math.acosh" do
+ it_behaves_like :complex_math_acosh, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/asin_spec.rb b/spec/ruby/library/complex/math/asin_spec.rb
new file mode 100644
index 0000000000..aa26bed11d
--- /dev/null
+++ b/spec/ruby/library/complex/math/asin_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/asin', __FILE__)
+
+describe "Math#asin" do
+ it_behaves_like :complex_math_asin, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:asin)
+ end
+end
+
+describe "Math.asin" do
+ it_behaves_like :complex_math_asin, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/asinh_spec.rb b/spec/ruby/library/complex/math/asinh_spec.rb
new file mode 100644
index 0000000000..a1b0816b33
--- /dev/null
+++ b/spec/ruby/library/complex/math/asinh_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/asinh', __FILE__)
+
+describe "Math#asinh" do
+ it_behaves_like :complex_math_asinh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:asinh)
+ end
+end
+
+describe "Math.asinh" do
+ it_behaves_like :complex_math_asinh, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/atan2_spec.rb b/spec/ruby/library/complex/math/atan2_spec.rb
new file mode 100644
index 0000000000..7111b4a8ec
--- /dev/null
+++ b/spec/ruby/library/complex/math/atan2_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/atan2', __FILE__)
+
+describe "Math#atan2" do
+ it_behaves_like :complex_math_atan2, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:atan2)
+ end
+end
+
+describe "Math.atan2" do
+ it_behaves_like :complex_math_atan2, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/atan_spec.rb b/spec/ruby/library/complex/math/atan_spec.rb
new file mode 100644
index 0000000000..6659b309e4
--- /dev/null
+++ b/spec/ruby/library/complex/math/atan_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/atan', __FILE__)
+
+describe "Math#atan" do
+ it_behaves_like :complex_math_atan, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:atan)
+ end
+end
+
+describe "Math.atan" do
+ it_behaves_like :complex_math_atan, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/atanh_spec.rb b/spec/ruby/library/complex/math/atanh_spec.rb
new file mode 100644
index 0000000000..a68674f82c
--- /dev/null
+++ b/spec/ruby/library/complex/math/atanh_spec.rb
@@ -0,0 +1,17 @@
+require 'complex'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../../../fixtures/math/common', __FILE__)
+require File.expand_path('../../../../shared/math/atanh', __FILE__)
+require File.expand_path('../shared/atanh', __FILE__)
+
+describe "Math#atanh" do
+ it_behaves_like :math_atanh_base, :atanh, IncludesMath.new
+ it_behaves_like :complex_math_atanh_complex, :atanh, IncludesMath.new
+
+ it_behaves_like :math_atanh_private, :atanh, IncludesMath.new
+end
+
+describe "Math.atanh" do
+ it_behaves_like :math_atanh_base, :atanh, CMath
+ it_behaves_like :complex_math_atanh_complex, :atanh, CMath
+end
diff --git a/spec/ruby/library/complex/math/cos_spec.rb b/spec/ruby/library/complex/math/cos_spec.rb
new file mode 100644
index 0000000000..4267c601a6
--- /dev/null
+++ b/spec/ruby/library/complex/math/cos_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/cos', __FILE__)
+
+describe "Math#cos" do
+ it_behaves_like :complex_math_cos, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:cos)
+ end
+end
+
+describe "Math.cos" do
+ it_behaves_like :complex_math_cos, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/cosh_spec.rb b/spec/ruby/library/complex/math/cosh_spec.rb
new file mode 100644
index 0000000000..b3aa1bdb69
--- /dev/null
+++ b/spec/ruby/library/complex/math/cosh_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/cosh', __FILE__)
+
+describe "Math#cosh" do
+ it_behaves_like :complex_math_cosh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:cosh)
+ end
+end
+
+describe "Math.cosh" do
+ it_behaves_like :complex_math_cosh, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/exp_spec.rb b/spec/ruby/library/complex/math/exp_spec.rb
new file mode 100644
index 0000000000..df1d12bbb5
--- /dev/null
+++ b/spec/ruby/library/complex/math/exp_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/exp', __FILE__)
+
+describe "Math#exp" do
+ it_behaves_like :complex_math_exp, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:exp)
+ end
+end
+
+describe "Math.exp" do
+ it_behaves_like :complex_math_exp, :_, CMath
+end
diff --git a/spec/ruby/library/cmath/math/fixtures/classes.rb b/spec/ruby/library/complex/math/fixtures/classes.rb
index 443c1a9ace..443c1a9ace 100644
--- a/spec/ruby/library/cmath/math/fixtures/classes.rb
+++ b/spec/ruby/library/complex/math/fixtures/classes.rb
diff --git a/spec/ruby/library/complex/math/log10_spec.rb b/spec/ruby/library/complex/math/log10_spec.rb
new file mode 100644
index 0000000000..c7c5717873
--- /dev/null
+++ b/spec/ruby/library/complex/math/log10_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/log10', __FILE__)
+
+describe "Math#log10" do
+ it_behaves_like :complex_math_log10, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:log10)
+ end
+end
+
+describe "Math.log10" do
+ it_behaves_like :complex_math_log10, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/log_spec.rb b/spec/ruby/library/complex/math/log_spec.rb
new file mode 100644
index 0000000000..f55b406af8
--- /dev/null
+++ b/spec/ruby/library/complex/math/log_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/log', __FILE__)
+
+describe "Math#log" do
+ it_behaves_like :complex_math_log, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:log)
+ end
+end
+
+describe "Math.log" do
+ it_behaves_like :complex_math_log, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/shared/acos.rb b/spec/ruby/library/complex/math/shared/acos.rb
new file mode 100644
index 0000000000..7a9e0fe1b2
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/acos.rb
@@ -0,0 +1,41 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_acos, shared: true do
+ it "returns the arccosine of the passed argument" do
+ @object.send(:acos, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:acos, 0).should be_close(1.5707963267949, TOLERANCE)
+ @object.send(:acos, -1).should be_close(Math::PI,TOLERANCE)
+ end
+
+ it "returns the arccosine for Complex numbers" do
+ @object.send(:acos, Complex(3, 4)).should be_close(Complex(0.93681246115572, -2.30550903124348), TOLERANCE)
+ end
+
+ it "returns the arccosine for numbers greater than 1.0 as a Complex number" do
+ @object.send(:acos, 1.0001).should be_close(Complex(0.0, 0.0141420177752494), TOLERANCE)
+ end
+
+ it "returns the arccosine for numbers less than -1.0 as a Complex number" do
+ @object.send(:acos, -1.0001).should be_close(Complex(3.14159265358979, -0.0141420177752495), TOLERANCE)
+ end
+end
+
+describe :complex_math_acos_bang, shared: true do
+ it "returns the arccosine of the argument" do
+ @object.send(:acos!, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:acos!, 0).should be_close(1.5707963267949, TOLERANCE)
+ @object.send(:acos!, -1).should be_close(Math::PI,TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:acos!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+
+ it "raises an Errno::EDOM for numbers greater than 1.0" do
+ lambda { @object.send(:acos!, 1.0001) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises an Errno::EDOM for numbers less than -1.0" do
+ lambda { @object.send(:acos!, -1.0001) }.should raise_error(Errno::EDOM)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/acosh.rb b/spec/ruby/library/complex/math/shared/acosh.rb
new file mode 100644
index 0000000000..b8be750f13
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/acosh.rb
@@ -0,0 +1,37 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_acosh, shared: true do
+ it "returns the principle value of the inverse hyperbolic cosine of the argument" do
+ @object.send(:acosh, 14.2).should be_close(3.345146999647, TOLERANCE)
+ @object.send(:acosh, 1.0).should be_close(0.0, TOLERANCE)
+ end
+
+ it "returns the principle value of the inverse hyperbolic cosine for numbers less than 1.0 as a Complex number" do
+ @object.send(:acosh, 1.0 - TOLERANCE).should be_close(Complex(0.0, 0.00774598605746135), TOLERANCE)
+ @object.send(:acosh, 0).should be_close(Complex(0.0, 1.5707963267949), TOLERANCE)
+ @object.send(:acosh, -1.0).should be_close(Complex(0.0, 3.14159265358979), TOLERANCE)
+ end
+
+ it "returns the principle value of the inverse hyperbolic cosine for Complex numbers" do
+ @object.send(:acosh, Complex(3, 4))
+ @object.send(:acosh, Complex(3, 4)).imaginary.should be_close(0.93681246115572, TOLERANCE)
+ @object.send(:acosh, Complex(3, 4)).real.should be_close(2.305509031243477, TOLERANCE)
+ end
+end
+
+describe :complex_math_acosh_bang, shared: true do
+ it "returns the principle value of the inverse hyperbolic cosine of the argument" do
+ @object.send(:acosh!, 14.2).should be_close(3.345146999647, TOLERANCE)
+ @object.send(:acosh!, 1.0).should be_close(0.0, TOLERANCE)
+ end
+
+ it "raises Errno::EDOM for numbers less than 1.0" do
+ lambda { @object.send(:acosh!, 1.0 - TOLERANCE) }.should raise_error(Errno::EDOM)
+ lambda { @object.send(:acosh!, 0) }.should raise_error(Errno::EDOM)
+ lambda { @object.send(:acosh!, -1.0) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:acosh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/asin.rb b/spec/ruby/library/complex/math/shared/asin.rb
new file mode 100644
index 0000000000..3b446cbe24
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/asin.rb
@@ -0,0 +1,47 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_asin, shared: true do
+ it "returns the arcsine of the argument" do
+ @object.send(:asin, 1).should be_close(Math::PI/2, TOLERANCE)
+ @object.send(:asin, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:asin, -1).should be_close(-Math::PI/2, TOLERANCE)
+ @object.send(:asin, 0.25).should be_close(0.252680255142079, TOLERANCE)
+ @object.send(:asin, 0.50).should be_close(0.523598775598299, TOLERANCE)
+ @object.send(:asin, 0.75).should be_close(0.8480620789814816,TOLERANCE)
+ end
+
+ it "returns the arcsine for Complex numbers" do
+ @object.send(:asin, Complex(3, 4)).should be_close(Complex(0.633983865639174, 2.30550903124347), TOLERANCE)
+ end
+
+ it "returns a Complex number when the argument is greater than 1.0" do
+ @object.send(:asin, 1.0001).should be_close(Complex(1.5707963267949, -0.0141420177752494), TOLERANCE)
+ end
+
+ it "returns a Complex number when the argument is less than -1.0" do
+ @object.send(:asin, -1.0001).should be_close(Complex(-1.5707963267949, 0.0141420177752494), TOLERANCE)
+ end
+end
+
+describe :complex_math_asin_bang, shared: true do
+ it "returns the arcsine of the argument" do
+ @object.send(:asin!, 1).should be_close(Math::PI/2, TOLERANCE)
+ @object.send(:asin!, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:asin!, -1).should be_close(-Math::PI/2, TOLERANCE)
+ @object.send(:asin!, 0.25).should be_close(0.252680255142079, TOLERANCE)
+ @object.send(:asin!, 0.50).should be_close(0.523598775598299, TOLERANCE)
+ @object.send(:asin!, 0.75).should be_close(0.8480620789814816,TOLERANCE)
+ end
+
+ it "raises an Errno::EDOM if the argument is greater than 1.0" do
+ lambda { @object.send(:asin!, 1.0001) }.should raise_error( Errno::EDOM)
+ end
+
+ it "raises an Errno::EDOM if the argument is less than -1.0" do
+ lambda { @object.send(:asin!, -1.0001) }.should raise_error( Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:asin!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/asinh.rb b/spec/ruby/library/complex/math/shared/asinh.rb
new file mode 100644
index 0000000000..4c2f6c8b5d
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/asinh.rb
@@ -0,0 +1,32 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_asinh, shared: true do
+ it "returns the inverse hyperbolic sin of the argument" do
+ @object.send(:asinh, 1.5).should be_close(1.19476321728711, TOLERANCE)
+ @object.send(:asinh, -2.97).should be_close(-1.8089166921397, TOLERANCE)
+ @object.send(:asinh, 0.0).should == 0.0
+ @object.send(:asinh, -0.0).should == -0.0
+ @object.send(:asinh, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
+ @object.send(:asinh, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
+ end
+
+ it "returns the inverse hyperbolic sin for Complex numbers" do
+ @object.send(:asinh, Complex(3, 4)).should be_close(Complex(2.29991404087927, 0.917616853351479), TOLERANCE)
+ @object.send(:asinh, Complex(3.5, -4)).should be_close(Complex(2.36263337274419, -0.843166327537659), TOLERANCE)
+ end
+end
+
+describe :complex_math_asinh_bang, shared: true do
+ it "returns the inverse hyperbolic sin of the argument" do
+ @object.send(:asinh!, 1.5).should be_close(1.19476321728711, TOLERANCE)
+ @object.send(:asinh!, -2.97).should be_close(-1.8089166921397, TOLERANCE)
+ @object.send(:asinh!, 0.0).should == 0.0
+ @object.send(:asinh!, -0.0).should == -0.0
+ @object.send(:asinh!, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
+ @object.send(:asinh!, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:asinh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/atan.rb b/spec/ruby/library/complex/math/shared/atan.rb
new file mode 100644
index 0000000000..44fa65e1e9
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/atan.rb
@@ -0,0 +1,32 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_atan, shared: true do
+ it "returns the arctangent of the argument" do
+ @object.send(:atan, 1).should be_close(Math::PI/4, TOLERANCE)
+ @object.send(:atan, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan, -1).should be_close(-Math::PI/4, TOLERANCE)
+ @object.send(:atan, 0.25).should be_close(0.244978663126864, TOLERANCE)
+ @object.send(:atan, 0.50).should be_close(0.463647609000806, TOLERANCE)
+ @object.send(:atan, 0.75).should be_close(0.643501108793284, TOLERANCE)
+ end
+
+ it "returns the arctangent for Complex numbers" do
+ @object.send(:atan, Complex(3, 4)).should be_close(Complex(1.44830699523146, 0.158997191679999), TOLERANCE)
+ @object.send(:atan, Complex(3.5, -4)).should be_close(Complex(1.44507428165589, -0.140323762363786), TOLERANCE)
+ end
+end
+
+describe :complex_math_atan_bang, shared: true do
+ it "returns the arctangent of the argument" do
+ @object.send(:atan!, 1).should be_close(Math::PI/4, TOLERANCE)
+ @object.send(:atan!, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan!, -1).should be_close(-Math::PI/4, TOLERANCE)
+ @object.send(:atan!, 0.25).should be_close(0.244978663126864, TOLERANCE)
+ @object.send(:atan!, 0.50).should be_close(0.463647609000806, TOLERANCE)
+ @object.send(:atan!, 0.75).should be_close(0.643501108793284, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:atan!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/atan2.rb b/spec/ruby/library/complex/math/shared/atan2.rb
new file mode 100644
index 0000000000..add1dcd6fa
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/atan2.rb
@@ -0,0 +1,34 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_atan2, shared: true do
+ it "returns the arc tangent of the passed arguments" do
+ @object.send(:atan2, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
+ @object.send(:atan2, 0.0, 1.0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan2, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
+ @object.send(:atan2, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
+ end
+
+ it "returns the arc tangent for two Complex numbers" do
+ CMath.atan2(Complex(3, 4), Complex(3.5, -4)).should be_close(Complex(-0.641757436698881, 1.10829873031207), TOLERANCE)
+ end
+
+ it "returns the arc tangent for Complex and real numbers" do
+ CMath.atan2(Complex(3, 4), -7).should be_close(Complex(2.61576754731561, -0.494290673139855), TOLERANCE)
+ CMath.atan2(5, Complex(3.5, -4)).should be_close(Complex(0.739102348493673, 0.487821626522923), TOLERANCE)
+ end
+end
+
+describe :complex_math_atan2_bang, shared: true do
+ it "returns the arc tangent of the passed arguments" do
+ @object.send(:atan2!, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
+ @object.send(:atan2!, 0.0, 1.0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan2!, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
+ @object.send(:atan2!, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:atan2!, Complex(4, 5), Complex(4, 5)) }.should raise_error(TypeError)
+ lambda { @object.send(:atan2!, 4, Complex(4, 5)) }.should raise_error(TypeError)
+ lambda { @object.send(:atan2!, Complex(4, 5), 5) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/atanh.rb b/spec/ruby/library/complex/math/shared/atanh.rb
new file mode 100644
index 0000000000..4051af081f
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/atanh.rb
@@ -0,0 +1,30 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_atanh_complex, shared: true do
+ it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
+ value = Complex(18.36840028483855, 1.5707963267948966)
+ @object.send(@method, 1.0 + Float::EPSILON).should be_close(value, TOLERANCE)
+
+ value = Complex(0.100335347731076, 1.5707963267949)
+ @object.send(@method, 10).should be_close(value, TOLERANCE)
+ end
+
+ it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
+ value = Complex(-18.36840028483855, 1.5707963267948966)
+ @object.send(@method, -1.0 - Float::EPSILON).should be_close(value, TOLERANCE)
+
+ value = Complex(0.100335347731076, 1.5707963267949)
+ @object.send(@method, 10).should be_close(value, TOLERANCE)
+ end
+
+ it "returns the inverse hyperbolic tangent for Complex numbers" do
+ value = Complex(0.117500907311434, 1.40992104959658)
+ @object.send(@method, Complex(3, 4)).should be_close(value, TOLERANCE)
+ end
+end
+
+describe :complex_math_atanh_no_complex, shared: true do
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:atanh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/cos.rb b/spec/ruby/library/complex/math/shared/cos.rb
new file mode 100644
index 0000000000..ab198e1a3b
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/cos.rb
@@ -0,0 +1,30 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_cos, shared: true do
+ it "returns the cosine of the argument expressed in radians" do
+ @object.send(:cos, CMath::PI).should be_close(-1.0, TOLERANCE)
+ @object.send(:cos, 0).should be_close(1.0, TOLERANCE)
+ @object.send(:cos, CMath::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos, 2*Math::PI).should be_close(1.0, TOLERANCE)
+ end
+
+ it "returns the cosine for Complex numbers" do
+ @object.send(:cos, Complex(0, CMath::PI)).should be_close(Complex(11.5919532755215, 0.0), TOLERANCE)
+ @object.send(:cos, Complex(3, 4)).should be_close(Complex(-27.0349456030742, -3.85115333481178), TOLERANCE)
+ end
+end
+
+describe :complex_math_cos_bang, shared: true do
+ it "returns the cosine of the argument expressed in radians" do
+ @object.send(:cos!, CMath::PI).should be_close(-1.0, TOLERANCE)
+ @object.send(:cos!, 0).should be_close(1.0, TOLERANCE)
+ @object.send(:cos!, CMath::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos!, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos!, 2*Math::PI).should be_close(1.0, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:cos!, Complex(3, 4)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/cosh.rb b/spec/ruby/library/complex/math/shared/cosh.rb
new file mode 100644
index 0000000000..a5f98e4e83
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/cosh.rb
@@ -0,0 +1,28 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_cosh, shared: true do
+ it "returns the hyperbolic cosine of the passed argument" do
+ @object.send(:cosh, 0.0).should == 1.0
+ @object.send(:cosh, -0.0).should == 1.0
+ @object.send(:cosh, 1.5).should be_close(2.35240961524325, TOLERANCE)
+ @object.send(:cosh, -2.99).should be_close(9.96798496414416, TOLERANCE)
+ end
+
+ it "returns the hyperbolic cosine for Complex numbers" do
+ @object.send(:cosh, Complex(0, CMath::PI)).should be_close(Complex(-1.0, 0.0), TOLERANCE)
+ @object.send(:cosh, Complex(3, 4)).should be_close(Complex(-6.58066304055116, -7.58155274274654), TOLERANCE)
+ end
+end
+
+describe :complex_math_cosh_bang, shared: true do
+ it "returns the hyperbolic cosine of the passed argument" do
+ @object.send(:cosh!, 0.0).should == 1.0
+ @object.send(:cosh!, -0.0).should == 1.0
+ @object.send(:cosh!, 1.5).should be_close(2.35240961524325, TOLERANCE)
+ @object.send(:cosh!, -2.99).should be_close(9.96798496414416, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:cosh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/exp.rb b/spec/ruby/library/complex/math/shared/exp.rb
new file mode 100644
index 0000000000..f4e73dfb4d
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/exp.rb
@@ -0,0 +1,28 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_exp, shared: true do
+ it "returns the base-e exponential of the passed argument" do
+ @object.send(:exp, 0.0).should == 1.0
+ @object.send(:exp, -0.0).should == 1.0
+ @object.send(:exp, -1.8).should be_close(0.165298888221587, TOLERANCE)
+ @object.send(:exp, 1.25).should be_close(3.49034295746184, TOLERANCE)
+ end
+
+ it "returns the base-e exponential for Complex numbers" do
+ @object.send(:exp, Complex(0, 0)).should == Complex(1.0, 0.0)
+ @object.send(:exp, Complex(1, 3)).should be_close(Complex(-2.69107861381979, 0.383603953541131), TOLERANCE)
+ end
+end
+
+describe :complex_math_exp_bang, shared: true do
+ it "returns the base-e exponential of the passed argument" do
+ @object.send(:exp!, 0.0).should == 1.0
+ @object.send(:exp!, -0.0).should == 1.0
+ @object.send(:exp!, -1.8).should be_close(0.165298888221587, TOLERANCE)
+ @object.send(:exp!, 1.25).should be_close(3.49034295746184, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:exp!, Complex(1, 3)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/log.rb b/spec/ruby/library/complex/math/shared/log.rb
new file mode 100644
index 0000000000..4e5385748a
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/log.rb
@@ -0,0 +1,39 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_log, shared: true do
+ it "returns the natural logarithm of the passed argument" do
+ @object.send(:log, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
+ @object.send(:log, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
+ @object.send(:log, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log, 10).should be_close( 2.30258509299405, TOLERANCE)
+ @object.send(:log, 10e15).should be_close(36.8413614879047, TOLERANCE)
+ end
+
+ it "returns the natural logarithm for Complex numbers" do
+ @object.send(:log, Complex(3, 4)).should be_close(Complex(1.6094379124341, 0.927295218001612), TOLERANCE)
+ @object.send(:log, Complex(-3, 4)).should be_close(Complex(1.6094379124341, 2.21429743558818), TOLERANCE)
+ end
+
+ it "returns the natural logarithm for negative numbers as a Complex number" do
+ @object.send(:log, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
+ @object.send(:log, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
+ end
+end
+
+describe :complex_math_log_bang, shared: true do
+ it "returns the natural logarithm of the argument" do
+ @object.send(:log!, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
+ @object.send(:log!, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
+ @object.send(:log!, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log!, 10).should be_close( 2.30258509299405, TOLERANCE)
+ @object.send(:log!, 10e15).should be_close(36.8413614879047, TOLERANCE)
+ end
+
+ it "raises an Errno::EDOM if the argument is less than 0" do
+ lambda { @object.send(:log!, -10) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:log!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/log10.rb b/spec/ruby/library/complex/math/shared/log10.rb
new file mode 100644
index 0000000000..13518f243e
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/log10.rb
@@ -0,0 +1,41 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_log10, shared: true do
+ it "returns the base-10 logarithm of the passed argument" do
+ @object.send(:log10, 0.0001).should be_close(-4.0, TOLERANCE)
+ @object.send(:log10, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
+ @object.send(:log10, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log10, 10).should be_close(1.0, TOLERANCE)
+ @object.send(:log10, 10e15).should be_close(16.0, TOLERANCE)
+ end
+
+ it "returns the base-10 logarithm for Complex numbers" do
+ @object.send(:log10, Complex(3, 4)).should be_close(Complex(0.698970004336019, 0.402719196273373), TOLERANCE)
+ @object.send(:log10, Complex(-3, 4)).should be_close(Complex(0.698970004336019, 0.961657157568468), TOLERANCE)
+ end
+
+ # BUG: does not work correctly, because Math#log10
+ # does not check for negative values
+ #it "returns the base-10 logarithm for negative numbers as a Complex number" do
+ # @object.send(:log10, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
+ # @object.send(:log10, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
+ #end
+end
+
+describe :complex_math_log10_bang, shared: true do
+ it "returns the base-10 logarithm of the argument" do
+ @object.send(:log10!, 0.0001).should be_close(-4.0, TOLERANCE)
+ @object.send(:log10!, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
+ @object.send(:log10!, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log10!, 10).should be_close(1.0, TOLERANCE)
+ @object.send(:log10!, 10e15).should be_close(16.0, TOLERANCE)
+ end
+
+ it "raises an Errno::EDOM when the passed argument is negative" do
+ lambda { @object.send(:log10!, -10) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:log10!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/sin.rb b/spec/ruby/library/complex/math/shared/sin.rb
new file mode 100644
index 0000000000..e5b207b456
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/sin.rb
@@ -0,0 +1,30 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_sin, shared: true do
+ it "returns the sine of the passed argument expressed in radians" do
+ @object.send(:sin, CMath::PI).should be_close(0.0, TOLERANCE)
+ @object.send(:sin, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:sin, CMath::PI/2).should be_close(1.0, TOLERANCE)
+ @object.send(:sin, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
+ @object.send(:sin, 2*Math::PI).should be_close(0.0, TOLERANCE)
+ end
+
+ it "returns the sine for Complex numbers" do
+ @object.send(:sin, Complex(0, CMath::PI)).should be_close(Complex(0.0, 11.5487393572577), TOLERANCE)
+ @object.send(:sin, Complex(3, 4)).should be_close(Complex(3.85373803791938, -27.0168132580039), TOLERANCE)
+ end
+end
+
+describe :complex_math_sin_bang, shared: true do
+ it "returns the sine of the passed argument expressed in radians" do
+ @object.send(:sin!, CMath::PI).should be_close(0.0, TOLERANCE)
+ @object.send(:sin!, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:sin!, CMath::PI/2).should be_close(1.0, TOLERANCE)
+ @object.send(:sin!, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
+ @object.send(:sin!, 2*Math::PI).should be_close(0.0, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:sin!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/sinh.rb b/spec/ruby/library/complex/math/shared/sinh.rb
new file mode 100644
index 0000000000..abbe2c6da0
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/sinh.rb
@@ -0,0 +1,28 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_sinh, shared: true do
+ it "returns the hyperbolic sin of the argument" do
+ @object.send(:sinh, 0.0).should == 0.0
+ @object.send(:sinh, -0.0).should == 0.0
+ @object.send(:sinh, 1.5).should be_close(2.12927945509482, TOLERANCE)
+ @object.send(:sinh, -2.8).should be_close(-8.19191835423591, TOLERANCE)
+ end
+
+ it "returns the hyperbolic sin for Complex numbers" do
+ @object.send(:sinh, Complex(0, CMath::PI)).should be_close(Complex(-0.0, 1.22464679914735e-16), TOLERANCE)
+ @object.send(:sinh, Complex(3, 4)).should be_close(Complex(-6.548120040911, -7.61923172032141), TOLERANCE)
+ end
+end
+
+describe :complex_math_sinh_bang, shared: true do
+ it "returns the hyperbolic sin of the argument" do
+ @object.send(:sinh!, 0.0).should == 0.0
+ @object.send(:sinh!, -0.0).should == 0.0
+ @object.send(:sinh!, 1.5).should be_close(2.12927945509482, TOLERANCE)
+ @object.send(:sinh!, -2.8).should be_close(-8.19191835423591, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:sinh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/sqrt.rb b/spec/ruby/library/complex/math/shared/sqrt.rb
new file mode 100644
index 0000000000..5125710119
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/sqrt.rb
@@ -0,0 +1,34 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_sqrt, shared: true do
+ it "returns the square root for positive numbers" do
+ @object.send(:sqrt, 4).should == 2
+ @object.send(:sqrt, 19.36).should == 4.4
+ end
+
+ it "returns the square root for negative numbers" do
+ @object.send(:sqrt, -4).should == Complex(0, 2.0)
+ @object.send(:sqrt, -19.36).should == Complex(0, 4.4)
+ end
+
+ it "returns the square root for Complex numbers" do
+ @object.send(:sqrt, Complex(4, 5)).should be_close(Complex(2.2806933416653, 1.09615788950152), TOLERANCE)
+ @object.send(:sqrt, Complex(4, -5)).should be_close(Complex(2.2806933416653, -1.09615788950152), TOLERANCE)
+ end
+end
+
+describe :complex_math_sqrt_bang, shared: true do
+ it "returns the square root for positive numbers" do
+ @object.send(:sqrt!, 4).should == 2
+ @object.send(:sqrt!, 19.36).should == 4.4
+ end
+
+ it "raises Errno::EDOM when the passed argument is negative" do
+ lambda { @object.send(:sqrt!, -4) }.should raise_error(Errno::EDOM)
+ lambda { @object.send(:sqrt!, -19.36) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:sqrt!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/tan.rb b/spec/ruby/library/complex/math/shared/tan.rb
new file mode 100644
index 0000000000..02a1880d27
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/tan.rb
@@ -0,0 +1,28 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_tan, shared: true do
+ it "returns the tangent of the argument" do
+ @object.send(:tan, 0.0).should == 0.0
+ @object.send(:tan, -0.0).should == -0.0
+ @object.send(:tan, 4.22).should be_close(1.86406937682395, TOLERANCE)
+ @object.send(:tan, -9.65).should be_close(-0.229109052606441, TOLERANCE)
+ end
+
+ it "returns the tangent for Complex numbers" do
+ @object.send(:tan, Complex(0, CMath::PI)).should be_close(Complex(0.0, 0.99627207622075), TOLERANCE)
+ @object.send(:tan, Complex(3, 4)).should be_close(Complex(-0.000187346204629452, 0.999355987381473), TOLERANCE)
+ end
+end
+
+describe :complex_math_tan_bang, shared: true do
+ it "returns the tangent of the argument" do
+ @object.send(:tan!, 0.0).should == 0.0
+ @object.send(:tan!, -0.0).should == -0.0
+ @object.send(:tan!, 4.22).should be_close(1.86406937682395, TOLERANCE)
+ @object.send(:tan!, -9.65).should be_close(-0.229109052606441, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:tan!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/shared/tanh.rb b/spec/ruby/library/complex/math/shared/tanh.rb
new file mode 100644
index 0000000000..a26b1349f6
--- /dev/null
+++ b/spec/ruby/library/complex/math/shared/tanh.rb
@@ -0,0 +1,32 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe :complex_math_tanh, shared: true do
+ it "returns the hyperbolic tangent of the argument" do
+ @object.send(:tanh, 0.0).should == 0.0
+ @object.send(:tanh, -0.0).should == -0.0
+ @object.send(:tanh, infinity_value).should == 1.0
+ @object.send(:tanh, -infinity_value).should == -1.0
+ @object.send(:tanh, 2.5).should be_close(0.98661429815143, TOLERANCE)
+ @object.send(:tanh, -4.892).should be_close(-0.999887314427707, TOLERANCE)
+ end
+
+ it "returns the hyperbolic tangent for Complex numbers" do
+ @object.send(:tanh, Complex(0, CMath::PI)).should be_close(Complex(0.0, -1.22464679914735e-16), TOLERANCE)
+ @object.send(:tanh, Complex(3, 4)).should be_close(Complex(1.00070953606723, 0.00490825806749599), TOLERANCE)
+ end
+end
+
+describe :complex_math_tanh_bang, shared: true do
+ it "returns the hyperbolic tangent of the argument" do
+ @object.send(:tanh!, 0.0).should == 0.0
+ @object.send(:tanh!, -0.0).should == -0.0
+ @object.send(:tanh!, infinity_value).should == 1.0
+ @object.send(:tanh!, -infinity_value).should == -1.0
+ @object.send(:tanh!, 2.5).should be_close(0.98661429815143, TOLERANCE)
+ @object.send(:tanh!, -4.892).should be_close(-0.999887314427707, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ lambda { @object.send(:tanh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/complex/math/sin_spec.rb b/spec/ruby/library/complex/math/sin_spec.rb
new file mode 100644
index 0000000000..bbc36ecaab
--- /dev/null
+++ b/spec/ruby/library/complex/math/sin_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/sin', __FILE__)
+
+describe "Math#sin" do
+ it_behaves_like :complex_math_sin, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:sin)
+ end
+end
+
+describe "Math.sin" do
+ it_behaves_like :complex_math_sin, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/sinh_spec.rb b/spec/ruby/library/complex/math/sinh_spec.rb
new file mode 100644
index 0000000000..25a41fbc45
--- /dev/null
+++ b/spec/ruby/library/complex/math/sinh_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/sinh', __FILE__)
+
+describe "Math#sinh" do
+ it_behaves_like :complex_math_sinh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:sinh)
+ end
+end
+
+describe "Math.sinh" do
+ it_behaves_like :complex_math_sinh, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/sqrt_spec.rb b/spec/ruby/library/complex/math/sqrt_spec.rb
new file mode 100644
index 0000000000..19d58ce373
--- /dev/null
+++ b/spec/ruby/library/complex/math/sqrt_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/sqrt', __FILE__)
+
+describe "Math#sqrt" do
+ it_behaves_like :complex_math_sqrt, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:sqrt)
+ end
+end
+
+describe "Math.sqrt" do
+ it_behaves_like :complex_math_sqrt, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/tan_spec.rb b/spec/ruby/library/complex/math/tan_spec.rb
new file mode 100644
index 0000000000..3c5bc6b129
--- /dev/null
+++ b/spec/ruby/library/complex/math/tan_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/tan', __FILE__)
+
+describe "Math#tan" do
+ it_behaves_like :complex_math_tan, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:tan)
+ end
+end
+
+describe "Math.tan" do
+ it_behaves_like :complex_math_tan, :_, CMath
+end
diff --git a/spec/ruby/library/complex/math/tanh_spec.rb b/spec/ruby/library/complex/math/tanh_spec.rb
new file mode 100644
index 0000000000..f9d99347b8
--- /dev/null
+++ b/spec/ruby/library/complex/math/tanh_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'complex'
+require File.expand_path('../shared/tanh', __FILE__)
+
+describe "Math#tanh" do
+ it_behaves_like :complex_math_tanh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:tanh)
+ end
+end
+
+describe "Math.tanh" do
+ it_behaves_like :complex_math_tanh, :_, CMath
+end
diff --git a/spec/ruby/library/complex/numeric/im_spec.rb b/spec/ruby/library/complex/numeric/im_spec.rb
new file mode 100644
index 0000000000..f76796a947
--- /dev/null
+++ b/spec/ruby/library/complex/numeric/im_spec.rb
@@ -0,0 +1,3 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+require 'complex'
diff --git a/spec/ruby/library/conditionvariable/broadcast_spec.rb b/spec/ruby/library/conditionvariable/broadcast_spec.rb
index a31a0443bd..129b124c1a 100644
--- a/spec/ruby/library/conditionvariable/broadcast_spec.rb
+++ b/spec/ruby/library/conditionvariable/broadcast_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'thread'
describe "ConditionVariable#broadcast" do
diff --git a/spec/ruby/library/conditionvariable/marshal_dump_spec.rb b/spec/ruby/library/conditionvariable/marshal_dump_spec.rb
index f951a13e28..f32b784eaa 100644
--- a/spec/ruby/library/conditionvariable/marshal_dump_spec.rb
+++ b/spec/ruby/library/conditionvariable/marshal_dump_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'thread'
describe "ConditionVariable#marshal_dump" do
diff --git a/spec/ruby/library/conditionvariable/signal_spec.rb b/spec/ruby/library/conditionvariable/signal_spec.rb
index 04b249a6c6..38bee8984b 100644
--- a/spec/ruby/library/conditionvariable/signal_spec.rb
+++ b/spec/ruby/library/conditionvariable/signal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'thread'
describe "ConditionVariable#signal" do
@@ -66,39 +66,4 @@ describe "ConditionVariable#signal" do
# released in the same order
r2.should == r1
end
-
- it "allows control to be passed between a pair of threads" do
- m = Mutex.new
- cv = ConditionVariable.new
- repeats = 100
- in_synchronize = false
-
- t1 = Thread.new do
- m.synchronize do
- in_synchronize = true
- repeats.times do
- cv.wait(m)
- cv.signal
- end
- end
- end
-
- # Make sure t1 is waiting for a signal before launching t2.
- Thread.pass until in_synchronize
- Thread.pass until t1.status == 'sleep'
-
- t2 = Thread.new do
- m.synchronize do
- repeats.times do
- cv.signal
- cv.wait(m)
- end
- end
- end
-
- # Check that both threads terminated without exception
- t1.join
- t2.join
- m.locked?.should == false
- end
end
diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb
index f57ab4c778..ddf6474212 100644
--- a/spec/ruby/library/conditionvariable/wait_spec.rb
+++ b/spec/ruby/library/conditionvariable/wait_spec.rb
@@ -1,16 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'thread'
describe "ConditionVariable#wait" do
- it "calls #sleep on the given object" do
- o = Object.new
- o.should_receive(:sleep).with(1234)
-
- cv = ConditionVariable.new
-
- cv.wait(o, 1234)
- end
-
it "returns self" do
m = Mutex.new
cv = ConditionVariable.new
@@ -31,102 +22,4 @@ describe "ConditionVariable#wait" do
m.synchronize { cv.signal }
th.join
end
-
- it "reacquires the lock even if the thread is killed" do
- m = Mutex.new
- cv = ConditionVariable.new
- in_synchronize = false
- owned = nil
-
- th = Thread.new do
- m.synchronize do
- in_synchronize = true
- begin
- cv.wait(m)
- ensure
- owned = m.owned?
- $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned
- end
- end
- end
-
- # wait for m to acquire the mutex
- Thread.pass until in_synchronize
- # wait until th is sleeping (ie waiting)
- Thread.pass while th.status and th.status != "sleep"
-
- th.kill
- th.join
-
- owned.should == true
- end
-
- ruby_bug '#14999', ''...'2.5' do
- it "reacquires the lock even if the thread is killed after being signaled" do
- m = Mutex.new
- cv = ConditionVariable.new
- in_synchronize = false
- owned = nil
-
- th = Thread.new do
- m.synchronize do
- in_synchronize = true
- begin
- cv.wait(m)
- ensure
- owned = m.owned?
- $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned
- end
- end
- end
-
- # wait for m to acquire the mutex
- Thread.pass until in_synchronize
- # wait until th is sleeping (ie waiting)
- Thread.pass while th.status and th.status != "sleep"
-
- m.synchronize {
- cv.signal
- # Wait that the thread is blocked on acquiring the Mutex
- sleep 0.001
- # Kill the thread, yet the thread should first acquire the Mutex before going on
- th.kill
- }
-
- th.join
- owned.should == true
- end
- end
-
- it "supports multiple Threads waiting on the same ConditionVariable and Mutex" do
- m = Mutex.new
- cv = ConditionVariable.new
- n_threads = 4
- events = []
-
- threads = n_threads.times.map {
- Thread.new {
- m.synchronize {
- events << :t_in_synchronize
- cv.wait(m)
- }
- }
- }
-
- Thread.pass until m.synchronize { events.size } == n_threads
- Thread.pass while threads.any? { |th| th.status and th.status != "sleep" }
- m.synchronize do
- threads.each { |t|
- # Cause interactions with the waiting threads.
- # On TruffleRuby, this causes a safepoint which has interesting
- # interactions with the ConditionVariable.
- bt = t.backtrace
- bt.should be_kind_of(Array)
- bt.size.should >= 2
- }
- end
-
- cv.broadcast
- threads.each(&:join)
- end
end
diff --git a/spec/ruby/library/coverage/fixtures/spec_helper.rb b/spec/ruby/library/coverage/fixtures/spec_helper.rb
new file mode 100644
index 0000000000..19094e5c36
--- /dev/null
+++ b/spec/ruby/library/coverage/fixtures/spec_helper.rb
@@ -0,0 +1,11 @@
+module CoverageSpecs
+ # Clear old results from the result hash
+ # https://bugs.ruby-lang.org/issues/12220
+ def self.filtered_result
+ result = Coverage.result
+ ruby_version_is ""..."2.4" do
+ result = result.reject { |_k, v| v.empty? }
+ end
+ result
+ end
+end
diff --git a/spec/ruby/library/coverage/peek_result_spec.rb b/spec/ruby/library/coverage/peek_result_spec.rb
index 9d7c890faa..44a2e2b83e 100644
--- a/spec/ruby/library/coverage/peek_result_spec.rb
+++ b/spec/ruby/library/coverage/peek_result_spec.rb
@@ -1,64 +1,67 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require fixture __FILE__, 'spec_helper'
require 'coverage'
-describe 'Coverage.peek_result' do
- before :all do
- @class_file = fixture __FILE__, 'some_class.rb'
- @second_class_file = fixture __FILE__, 'second_class.rb'
- end
+ruby_version_is '2.3' do
+ describe 'Coverage.peek_result' do
+ before :all do
+ @class_file = fixture __FILE__, 'some_class.rb'
+ @second_class_file = fixture __FILE__, 'second_class.rb'
+ end
- after :each do
- $LOADED_FEATURES.delete(@class_file)
- $LOADED_FEATURES.delete(@second_class_file)
- end
+ after :each do
+ $LOADED_FEATURES.delete(@class_file)
+ $LOADED_FEATURES.delete(@second_class_file)
+ end
- it 'returns the result so far' do
- Coverage.start
- require @class_file.chomp('.rb')
- result = Coverage.peek_result
- Coverage.result
+ it 'returns the result so far' do
+ Coverage.start
+ require @class_file.chomp('.rb')
+ result = Coverage.peek_result
+ Coverage.result
- result.should == {
- @class_file => [
- nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
- ]
- }
- end
+ result.should == {
+ @class_file => [
+ nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ]
+ }
+ end
- it 'immediate second call returns same result' do
- Coverage.start
- require @class_file.chomp('.rb')
- result1 = Coverage.peek_result
- result2 = Coverage.peek_result
- Coverage.result
+ it 'immediate second call returns same result' do
+ Coverage.start
+ require @class_file.chomp('.rb')
+ result1 = Coverage.peek_result
+ result2 = Coverage.peek_result
+ Coverage.result
- result2.should == result1
- end
+ result2.should == result1
+ end
- it 'second call after require returns accumulated result' do
- Coverage.start
- require @class_file.chomp('.rb')
- Coverage.peek_result
- require @second_class_file.chomp('.rb')
- result = Coverage.peek_result
- Coverage.result
+ it 'second call after require returns accumulated result' do
+ Coverage.start
+ require @class_file.chomp('.rb')
+ Coverage.peek_result
+ require @second_class_file.chomp('.rb')
+ result = Coverage.peek_result
+ Coverage.result
- result.should == {
- @class_file => [
- nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
- ],
- @second_class_file => [
- 1, 1, 0, nil, nil
- ]
- }
- end
+ result.should == {
+ @class_file => [
+ nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ],
+ @second_class_file => [
+ 1, 1, 0, nil, nil
+ ]
+ }
+ end
- it 'call right before Coverage.result should give equal result' do
- Coverage.start
- require @class_file.chomp('.rb')
- result1 = Coverage.peek_result
- result2 = Coverage.result
+ it 'call right before Coverage.result should give equal result' do
+ Coverage.start
+ require @class_file.chomp('.rb')
+ result1 = Coverage.peek_result
+ result2 = Coverage.result
- result1.should == result2
+ result1.should == result2
+ end
end
end
diff --git a/spec/ruby/library/coverage/result_spec.rb b/spec/ruby/library/coverage/result_spec.rb
index 9b84530076..adcc51dc80 100644
--- a/spec/ruby/library/coverage/result_spec.rb
+++ b/spec/ruby/library/coverage/result_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
+require fixture __FILE__, 'spec_helper'
require 'coverage'
describe 'Coverage.result' do
@@ -15,7 +16,7 @@ describe 'Coverage.result' do
it 'gives the covered files as a hash with arrays of count or nil' do
Coverage.start
require @class_file.chomp('.rb')
- result = Coverage.result
+ result = CoverageSpecs.filtered_result
result.should == {
@class_file => [
@@ -26,7 +27,7 @@ describe 'Coverage.result' do
it 'no requires/loads should give empty hash' do
Coverage.start
- result = Coverage.result
+ result = CoverageSpecs.filtered_result
result.should == {}
end
@@ -35,19 +36,18 @@ describe 'Coverage.result' do
Coverage.start
require @class_file.chomp('.rb')
Coverage.result
- -> {
- Coverage.result
- }.should raise_error(RuntimeError, 'coverage measurement is not enabled')
+ -> { Coverage.result }
+ .should raise_error(RuntimeError, 'coverage measurement is not enabled')
end
it 'second run should give same result' do
Coverage.start
load @class_file
- result1 = Coverage.result
+ result1 = CoverageSpecs.filtered_result
Coverage.start
load @class_file
- result2 = Coverage.result
+ result2 = CoverageSpecs.filtered_result
result2.should == result1
end
@@ -58,7 +58,7 @@ describe 'Coverage.result' do
Coverage.result
Coverage.start
- result = Coverage.result
+ result = CoverageSpecs.filtered_result
result.should == {}
end
@@ -66,13 +66,13 @@ describe 'Coverage.result' do
it 'second Coverage.start does nothing' do
Coverage.start
require @config_file.chomp('.rb')
- result = Coverage.result
+ result = CoverageSpecs.filtered_result
result.should == { @config_file => [1, 1, 1] }
end
it 'does not include the file starting coverage since it is not tracked' do
require @config_file.chomp('.rb')
- Coverage.result.should_not include(@config_file)
+ CoverageSpecs.filtered_result.should_not include(@config_file)
end
end
diff --git a/spec/ruby/library/coverage/start_spec.rb b/spec/ruby/library/coverage/start_spec.rb
index ddfad8b47c..6b4ccbb043 100644
--- a/spec/ruby/library/coverage/start_spec.rb
+++ b/spec/ruby/library/coverage/start_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'coverage'
describe 'Coverage.start' do
diff --git a/spec/ruby/library/csv/basicwriter/close_on_terminate_spec.rb b/spec/ruby/library/csv/basicwriter/close_on_terminate_spec.rb
index 599e640624..3a5dc85ed7 100644
--- a/spec/ruby/library/csv/basicwriter/close_on_terminate_spec.rb
+++ b/spec/ruby/library/csv/basicwriter/close_on_terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::BasicWriter#close_on_terminate" do
diff --git a/spec/ruby/library/csv/basicwriter/initialize_spec.rb b/spec/ruby/library/csv/basicwriter/initialize_spec.rb
index 2c13c93f2e..8ccef3fc0d 100644
--- a/spec/ruby/library/csv/basicwriter/initialize_spec.rb
+++ b/spec/ruby/library/csv/basicwriter/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::BasicWriter#initialize" do
diff --git a/spec/ruby/library/csv/basicwriter/terminate_spec.rb b/spec/ruby/library/csv/basicwriter/terminate_spec.rb
index 8c53db3f0b..80581e4d61 100644
--- a/spec/ruby/library/csv/basicwriter/terminate_spec.rb
+++ b/spec/ruby/library/csv/basicwriter/terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::BasicWriter#terminate" do
diff --git a/spec/ruby/library/csv/cell/data_spec.rb b/spec/ruby/library/csv/cell/data_spec.rb
index aa034b0b62..b2be38a5d6 100644
--- a/spec/ruby/library/csv/cell/data_spec.rb
+++ b/spec/ruby/library/csv/cell/data_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Cell#data" do
diff --git a/spec/ruby/library/csv/cell/initialize_spec.rb b/spec/ruby/library/csv/cell/initialize_spec.rb
index c9e506676c..3d10d7ada7 100644
--- a/spec/ruby/library/csv/cell/initialize_spec.rb
+++ b/spec/ruby/library/csv/cell/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Cell#initialize" do
diff --git a/spec/ruby/library/csv/foreach_spec.rb b/spec/ruby/library/csv/foreach_spec.rb
index 36b3cd152f..a967c450bf 100644
--- a/spec/ruby/library/csv/foreach_spec.rb
+++ b/spec/ruby/library/csv/foreach_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
describe "CSV.foreach" do
diff --git a/spec/ruby/library/csv/generate_line_spec.rb b/spec/ruby/library/csv/generate_line_spec.rb
index 656365b109..cc7c8de4f0 100644
--- a/spec/ruby/library/csv/generate_line_spec.rb
+++ b/spec/ruby/library/csv/generate_line_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
describe "CSV.generate_line" do
diff --git a/spec/ruby/library/csv/generate_row_spec.rb b/spec/ruby/library/csv/generate_row_spec.rb
index 79dfc34000..d42c031ab1 100644
--- a/spec/ruby/library/csv/generate_row_spec.rb
+++ b/spec/ruby/library/csv/generate_row_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
describe "CSV.generate_row" do
diff --git a/spec/ruby/library/csv/generate_spec.rb b/spec/ruby/library/csv/generate_spec.rb
index 0a1e3d9604..f583b5f536 100644
--- a/spec/ruby/library/csv/generate_spec.rb
+++ b/spec/ruby/library/csv/generate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
require 'tempfile'
@@ -26,7 +26,7 @@ describe "CSV.generate" do
csv.add_row [1, 2, 3]
csv << [4, 5, 6]
end
- csv_str.should equal str
+ csv_str.object_id.should == str.object_id
str.should == "1,2,3\n4,5,6\n"
end
end
diff --git a/spec/ruby/library/csv/iobuf/close_spec.rb b/spec/ruby/library/csv/iobuf/close_spec.rb
index e2fda86080..d97841ad98 100644
--- a/spec/ruby/library/csv/iobuf/close_spec.rb
+++ b/spec/ruby/library/csv/iobuf/close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOBuf#close" do
diff --git a/spec/ruby/library/csv/iobuf/initialize_spec.rb b/spec/ruby/library/csv/iobuf/initialize_spec.rb
index f08e82548a..5155e9047a 100644
--- a/spec/ruby/library/csv/iobuf/initialize_spec.rb
+++ b/spec/ruby/library/csv/iobuf/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOBuf#initialize" do
diff --git a/spec/ruby/library/csv/iobuf/read_spec.rb b/spec/ruby/library/csv/iobuf/read_spec.rb
index b45334ee2a..0dbcccb7c2 100644
--- a/spec/ruby/library/csv/iobuf/read_spec.rb
+++ b/spec/ruby/library/csv/iobuf/read_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOBuf#read" do
diff --git a/spec/ruby/library/csv/iobuf/terminate_spec.rb b/spec/ruby/library/csv/iobuf/terminate_spec.rb
index 69289e960c..b74108cedc 100644
--- a/spec/ruby/library/csv/iobuf/terminate_spec.rb
+++ b/spec/ruby/library/csv/iobuf/terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOBuf#terminate" do
diff --git a/spec/ruby/library/csv/ioreader/close_on_terminate_spec.rb b/spec/ruby/library/csv/ioreader/close_on_terminate_spec.rb
index 4887ade1a1..75ce325a8b 100644
--- a/spec/ruby/library/csv/ioreader/close_on_terminate_spec.rb
+++ b/spec/ruby/library/csv/ioreader/close_on_terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOReader#close_on_terminate" do
diff --git a/spec/ruby/library/csv/ioreader/get_row_spec.rb b/spec/ruby/library/csv/ioreader/get_row_spec.rb
index 5fd2178b1b..91049f014a 100644
--- a/spec/ruby/library/csv/ioreader/get_row_spec.rb
+++ b/spec/ruby/library/csv/ioreader/get_row_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOReader#get_row" do
diff --git a/spec/ruby/library/csv/ioreader/initialize_spec.rb b/spec/ruby/library/csv/ioreader/initialize_spec.rb
index 4e8c0964df..63a47eff73 100644
--- a/spec/ruby/library/csv/ioreader/initialize_spec.rb
+++ b/spec/ruby/library/csv/ioreader/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOReader#initialize" do
diff --git a/spec/ruby/library/csv/ioreader/terminate_spec.rb b/spec/ruby/library/csv/ioreader/terminate_spec.rb
index 676cd03a0f..95259afd59 100644
--- a/spec/ruby/library/csv/ioreader/terminate_spec.rb
+++ b/spec/ruby/library/csv/ioreader/terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::IOReader#terminate" do
diff --git a/spec/ruby/library/csv/liberal_parsing_spec.rb b/spec/ruby/library/csv/liberal_parsing_spec.rb
index 2929d6e2aa..99cedbcd22 100644
--- a/spec/ruby/library/csv/liberal_parsing_spec.rb
+++ b/spec/ruby/library/csv/liberal_parsing_spec.rb
@@ -1,19 +1,21 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
-describe "CSV#liberal_parsing?" do
- it "returns true if illegal input is handled" do
- csv = CSV.new("", liberal_parsing: true)
- csv.liberal_parsing?.should == true
- end
+ruby_version_is '2.4' do
+ describe "CSV#liberal_parsing?" do
+ it "returns true if illegal input is handled" do
+ csv = CSV.new("", liberal_parsing: true)
+ csv.liberal_parsing?.should == true
+ end
- it "returns false if illegal input is not handled" do
- csv = CSV.new("", liberal_parsing: false)
- csv.liberal_parsing?.should == false
- end
+ it "returns false if illegal input is not handled" do
+ csv = CSV.new("", liberal_parsing: false)
+ csv.liberal_parsing?.should == false
+ end
- it "returns false by default" do
- csv = CSV.new("")
- csv.liberal_parsing?.should == false
+ it "returns false by default" do
+ csv = CSV.new("")
+ csv.liberal_parsing?.should == false
+ end
end
end
diff --git a/spec/ruby/library/csv/open_spec.rb b/spec/ruby/library/csv/open_spec.rb
index 2d310cda3e..e0667921b9 100644
--- a/spec/ruby/library/csv/open_spec.rb
+++ b/spec/ruby/library/csv/open_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
describe "CSV.open" do
diff --git a/spec/ruby/library/csv/parse_spec.rb b/spec/ruby/library/csv/parse_spec.rb
index ef5d4ea3ca..47d7ebbde1 100644
--- a/spec/ruby/library/csv/parse_spec.rb
+++ b/spec/ruby/library/csv/parse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
describe "CSV.parse" do
@@ -85,9 +85,11 @@ describe "CSV.parse" do
}.should raise_error(CSV::MalformedCSVError)
end
- it "handles illegal input with the liberal_parsing option" do
- illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
- result = CSV.parse(illegal_input, liberal_parsing: true)
- result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
+ ruby_version_is '2.4' do
+ it "handles illegal input with the liberal_parsing option" do
+ illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
+ result = CSV.parse(illegal_input, liberal_parsing: true)
+ result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
+ end
end
end
diff --git a/spec/ruby/library/csv/read_spec.rb b/spec/ruby/library/csv/read_spec.rb
index 2e6bb65d56..9bdb214a6a 100644
--- a/spec/ruby/library/csv/read_spec.rb
+++ b/spec/ruby/library/csv/read_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
describe "CSV.read" do
diff --git a/spec/ruby/library/csv/readlines_spec.rb b/spec/ruby/library/csv/readlines_spec.rb
index 14dea34381..452effd343 100644
--- a/spec/ruby/library/csv/readlines_spec.rb
+++ b/spec/ruby/library/csv/readlines_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'csv'
describe "CSV.readlines" do
@@ -26,10 +26,12 @@ describe "CSV#readlines" do
-> { csv.readlines }.should raise_error(CSV::MalformedCSVError)
end
- it "handles illegal input with the liberal_parsing option" do
- illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
- csv = CSV.new(illegal_input, liberal_parsing: true)
- result = csv.readlines
- result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
+ ruby_version_is '2.4' do
+ it "handles illegal input with the liberal_parsing option" do
+ illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
+ csv = CSV.new(illegal_input, liberal_parsing: true)
+ result = csv.readlines
+ result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
+ end
end
end
diff --git a/spec/ruby/library/csv/streambuf/add_buf_spec.rb b/spec/ruby/library/csv/streambuf/add_buf_spec.rb
index 58c530c500..274f40d496 100644
--- a/spec/ruby/library/csv/streambuf/add_buf_spec.rb
+++ b/spec/ruby/library/csv/streambuf/add_buf_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#add_buf" do
diff --git a/spec/ruby/library/csv/streambuf/buf_size_spec.rb b/spec/ruby/library/csv/streambuf/buf_size_spec.rb
index 1793c8b65e..30af8a44c0 100644
--- a/spec/ruby/library/csv/streambuf/buf_size_spec.rb
+++ b/spec/ruby/library/csv/streambuf/buf_size_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#buf_size" do
diff --git a/spec/ruby/library/csv/streambuf/drop_spec.rb b/spec/ruby/library/csv/streambuf/drop_spec.rb
index 448f0a2196..47f32fc8c5 100644
--- a/spec/ruby/library/csv/streambuf/drop_spec.rb
+++ b/spec/ruby/library/csv/streambuf/drop_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#drop" do
diff --git a/spec/ruby/library/csv/streambuf/element_reference_spec.rb b/spec/ruby/library/csv/streambuf/element_reference_spec.rb
index 5a75901830..4e4bab9a1e 100644
--- a/spec/ruby/library/csv/streambuf/element_reference_spec.rb
+++ b/spec/ruby/library/csv/streambuf/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#[]" do
diff --git a/spec/ruby/library/csv/streambuf/get_spec.rb b/spec/ruby/library/csv/streambuf/get_spec.rb
index 2255e55e91..4a8db3a970 100644
--- a/spec/ruby/library/csv/streambuf/get_spec.rb
+++ b/spec/ruby/library/csv/streambuf/get_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#get" do
diff --git a/spec/ruby/library/csv/streambuf/idx_is_eos_spec.rb b/spec/ruby/library/csv/streambuf/idx_is_eos_spec.rb
index 563b8b2d4a..d48e6735f0 100644
--- a/spec/ruby/library/csv/streambuf/idx_is_eos_spec.rb
+++ b/spec/ruby/library/csv/streambuf/idx_is_eos_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#idx_is_eos?" do
diff --git a/spec/ruby/library/csv/streambuf/initialize_spec.rb b/spec/ruby/library/csv/streambuf/initialize_spec.rb
index 1273c98094..0f76220d3d 100644
--- a/spec/ruby/library/csv/streambuf/initialize_spec.rb
+++ b/spec/ruby/library/csv/streambuf/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#initialize" do
diff --git a/spec/ruby/library/csv/streambuf/is_eos_spec.rb b/spec/ruby/library/csv/streambuf/is_eos_spec.rb
index a0a3c1e0b0..30167f30ff 100644
--- a/spec/ruby/library/csv/streambuf/is_eos_spec.rb
+++ b/spec/ruby/library/csv/streambuf/is_eos_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#is_eos?" do
diff --git a/spec/ruby/library/csv/streambuf/read_spec.rb b/spec/ruby/library/csv/streambuf/read_spec.rb
index cf98c53409..b07467bdb7 100644
--- a/spec/ruby/library/csv/streambuf/read_spec.rb
+++ b/spec/ruby/library/csv/streambuf/read_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#read" do
diff --git a/spec/ruby/library/csv/streambuf/rel_buf_spec.rb b/spec/ruby/library/csv/streambuf/rel_buf_spec.rb
index 548e347200..e01dc39cf5 100644
--- a/spec/ruby/library/csv/streambuf/rel_buf_spec.rb
+++ b/spec/ruby/library/csv/streambuf/rel_buf_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#rel_buf" do
diff --git a/spec/ruby/library/csv/streambuf/terminate_spec.rb b/spec/ruby/library/csv/streambuf/terminate_spec.rb
index 247b33184a..0c2bdedf6d 100644
--- a/spec/ruby/library/csv/streambuf/terminate_spec.rb
+++ b/spec/ruby/library/csv/streambuf/terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StreamBuf#terminate" do
diff --git a/spec/ruby/library/csv/stringreader/get_row_spec.rb b/spec/ruby/library/csv/stringreader/get_row_spec.rb
index 5cc3447061..8532fc234c 100644
--- a/spec/ruby/library/csv/stringreader/get_row_spec.rb
+++ b/spec/ruby/library/csv/stringreader/get_row_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StringReader#get_row" do
diff --git a/spec/ruby/library/csv/stringreader/initialize_spec.rb b/spec/ruby/library/csv/stringreader/initialize_spec.rb
index 4e3634847e..5ce8f652da 100644
--- a/spec/ruby/library/csv/stringreader/initialize_spec.rb
+++ b/spec/ruby/library/csv/stringreader/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::StringReader#initialize" do
diff --git a/spec/ruby/library/csv/writer/add_row_spec.rb b/spec/ruby/library/csv/writer/add_row_spec.rb
index 2f074b45db..2ff5bdeee6 100644
--- a/spec/ruby/library/csv/writer/add_row_spec.rb
+++ b/spec/ruby/library/csv/writer/add_row_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Writer#add_row" do
diff --git a/spec/ruby/library/csv/writer/append_spec.rb b/spec/ruby/library/csv/writer/append_spec.rb
index 4e1f6728c2..c6d96c72d6 100644
--- a/spec/ruby/library/csv/writer/append_spec.rb
+++ b/spec/ruby/library/csv/writer/append_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Writer#<<" do
diff --git a/spec/ruby/library/csv/writer/close_spec.rb b/spec/ruby/library/csv/writer/close_spec.rb
index 1a87094bb7..f51b9de73d 100644
--- a/spec/ruby/library/csv/writer/close_spec.rb
+++ b/spec/ruby/library/csv/writer/close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Writer#close" do
diff --git a/spec/ruby/library/csv/writer/create_spec.rb b/spec/ruby/library/csv/writer/create_spec.rb
index a4514d5578..18cff887a6 100644
--- a/spec/ruby/library/csv/writer/create_spec.rb
+++ b/spec/ruby/library/csv/writer/create_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Writer.create" do
diff --git a/spec/ruby/library/csv/writer/generate_spec.rb b/spec/ruby/library/csv/writer/generate_spec.rb
index 6ea9161777..8930e26389 100644
--- a/spec/ruby/library/csv/writer/generate_spec.rb
+++ b/spec/ruby/library/csv/writer/generate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Writer.generate" do
diff --git a/spec/ruby/library/csv/writer/initialize_spec.rb b/spec/ruby/library/csv/writer/initialize_spec.rb
index 6bba8f8d0a..31b7d0fad8 100644
--- a/spec/ruby/library/csv/writer/initialize_spec.rb
+++ b/spec/ruby/library/csv/writer/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Writer#initialize" do
diff --git a/spec/ruby/library/csv/writer/terminate_spec.rb b/spec/ruby/library/csv/writer/terminate_spec.rb
index 77136dd018..9629c672b5 100644
--- a/spec/ruby/library/csv/writer/terminate_spec.rb
+++ b/spec/ruby/library/csv/writer/terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'csv'
describe "CSV::Writer#terminate" do
diff --git a/spec/ruby/library/date/accessor_spec.rb b/spec/ruby/library/date/accessor_spec.rb
index 68a2d9f3de..91e0c3fc88 100644
--- a/spec/ruby/library/date/accessor_spec.rb
+++ b/spec/ruby/library/date/accessor_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#ajd" do
it "determines the Astronomical Julian day" do
diff --git a/spec/ruby/library/date/add_month_spec.rb b/spec/ruby/library/date/add_month_spec.rb
index 40833f6487..46f1915b70 100644
--- a/spec/ruby/library/date/add_month_spec.rb
+++ b/spec/ruby/library/date/add_month_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#>>" do
@@ -21,18 +21,18 @@ describe "Date#>>" do
end
it "raise a TypeError when passed a Symbol" do
- -> { Date.civil(2007,2,27) >> :hello }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) >> :hello }.should raise_error(TypeError)
end
it "raise a TypeError when passed a String" do
- -> { Date.civil(2007,2,27) >> "hello" }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) >> "hello" }.should raise_error(TypeError)
end
it "raise a TypeError when passed a Date" do
- -> { Date.civil(2007,2,27) >> Date.new }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) >> Date.new }.should raise_error(TypeError)
end
it "raise a TypeError when passed an Object" do
- -> { Date.civil(2007,2,27) >> Object.new }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) >> Object.new }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/date/add_spec.rb b/spec/ruby/library/date/add_spec.rb
index 2b9cc62023..022b793318 100644
--- a/spec/ruby/library/date/add_spec.rb
+++ b/spec/ruby/library/date/add_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#+" do
@@ -13,18 +13,18 @@ describe "Date#+" do
end
it "raises a TypeError when passed a Symbol" do
- -> { Date.civil(2007,2,27) + :hello }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) + :hello }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- -> { Date.civil(2007,2,27) + "hello" }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) + "hello" }.should raise_error(TypeError)
end
it "raises a TypeError when passed a Date" do
- -> { Date.civil(2007,2,27) + Date.new }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) + Date.new }.should raise_error(TypeError)
end
it "raises a TypeError when passed an Object" do
- -> { Date.civil(2007,2,27) + Object.new }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) + Object.new }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/date/ajd_spec.rb b/spec/ruby/library/date/ajd_spec.rb
index 10f1302354..fcbcea2426 100644
--- a/spec/ruby/library/date/ajd_spec.rb
+++ b/spec/ruby/library/date/ajd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#ajd" do
diff --git a/spec/ruby/library/date/ajd_to_amjd_spec.rb b/spec/ruby/library/date/ajd_to_amjd_spec.rb
index 948f4c2236..fc6a35d0c6 100644
--- a/spec/ruby/library/date/ajd_to_amjd_spec.rb
+++ b/spec/ruby/library/date/ajd_to_amjd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.ajd_to_amjd" do
diff --git a/spec/ruby/library/date/ajd_to_jd_spec.rb b/spec/ruby/library/date/ajd_to_jd_spec.rb
index e55ce9f4f2..1d8d6d0eb5 100644
--- a/spec/ruby/library/date/ajd_to_jd_spec.rb
+++ b/spec/ruby/library/date/ajd_to_jd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.ajd_to_jd" do
diff --git a/spec/ruby/library/date/amjd_spec.rb b/spec/ruby/library/date/amjd_spec.rb
index ad7bc14965..212871ee18 100644
--- a/spec/ruby/library/date/amjd_spec.rb
+++ b/spec/ruby/library/date/amjd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#amjd" do
diff --git a/spec/ruby/library/date/amjd_to_ajd_spec.rb b/spec/ruby/library/date/amjd_to_ajd_spec.rb
index 66c26a16a8..f45f202a40 100644
--- a/spec/ruby/library/date/amjd_to_ajd_spec.rb
+++ b/spec/ruby/library/date/amjd_to_ajd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.amjd_to_ajd" do
diff --git a/spec/ruby/library/date/append_spec.rb b/spec/ruby/library/date/append_spec.rb
index 4305a00321..d90eff9a7a 100644
--- a/spec/ruby/library/date/append_spec.rb
+++ b/spec/ruby/library/date/append_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#<<" do
diff --git a/spec/ruby/library/date/asctime_spec.rb b/spec/ruby/library/date/asctime_spec.rb
index 67d158cc01..13dede0f05 100644
--- a/spec/ruby/library/date/asctime_spec.rb
+++ b/spec/ruby/library/date/asctime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#asctime" do
diff --git a/spec/ruby/library/date/boat_spec.rb b/spec/ruby/library/date/boat_spec.rb
index e4f1b797fc..3004c6bfbc 100644
--- a/spec/ruby/library/date/boat_spec.rb
+++ b/spec/ruby/library/date/boat_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#<=>" do
diff --git a/spec/ruby/library/date/case_compare_spec.rb b/spec/ruby/library/date/case_compare_spec.rb
index 87d522ee6a..2144a616a3 100644
--- a/spec/ruby/library/date/case_compare_spec.rb
+++ b/spec/ruby/library/date/case_compare_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#===" do
diff --git a/spec/ruby/library/date/civil_spec.rb b/spec/ruby/library/date/civil_spec.rb
index f3537c2f84..36e790aecd 100644
--- a/spec/ruby/library/date/civil_spec.rb
+++ b/spec/ruby/library/date/civil_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'shared/civil'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/civil', __FILE__)
require 'date'
describe "Date#civil" do
- it_behaves_like :date_civil, :civil
+ it_behaves_like(:date_civil, :civil)
end
diff --git a/spec/ruby/library/date/commercial_spec.rb b/spec/ruby/library/date/commercial_spec.rb
index d7fc34d74a..bb6671eda1 100644
--- a/spec/ruby/library/date/commercial_spec.rb
+++ b/spec/ruby/library/date/commercial_spec.rb
@@ -1,10 +1,10 @@
require 'date'
-require_relative '../../spec_helper'
-require_relative 'shared/commercial'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/commercial', __FILE__)
describe "Date#commercial" do
- it_behaves_like :date_commercial, :commercial
+ it_behaves_like(:date_commercial, :commercial)
end
@@ -15,3 +15,4 @@ end
# 17 18 19 20 21 22 23
# 24 25 26 27 28 29 30
# 31
+
diff --git a/spec/ruby/library/date/commercial_to_jd_spec.rb b/spec/ruby/library/date/commercial_to_jd_spec.rb
index 9b77f1229f..61631a7977 100644
--- a/spec/ruby/library/date/commercial_to_jd_spec.rb
+++ b/spec/ruby/library/date/commercial_to_jd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.commercial_to_jd" do
diff --git a/spec/ruby/library/date/comparison_spec.rb b/spec/ruby/library/date/comparison_spec.rb
index 1a94b9dcd2..04bfa2e8f7 100644
--- a/spec/ruby/library/date/comparison_spec.rb
+++ b/spec/ruby/library/date/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#<=>" do
diff --git a/spec/ruby/library/date/constants_spec.rb b/spec/ruby/library/date/constants_spec.rb
index fc1dba4999..ae343f07ec 100644
--- a/spec/ruby/library/date/constants_spec.rb
+++ b/spec/ruby/library/date/constants_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date constants" do
@@ -34,13 +34,13 @@ describe "Date constants" do
it "freezes MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYSNAMES" do
[Date::MONTHNAMES, Date::DAYNAMES, Date::ABBR_MONTHNAMES, Date::ABBR_DAYNAMES].each do |ary|
- -> {
+ lambda {
ary << "Unknown"
- }.should raise_error(frozen_error_class, /frozen/)
+ }.should raise_error(RuntimeError, /frozen/)
ary.compact.each do |name|
- -> {
+ lambda {
name << "modified"
- }.should raise_error(frozen_error_class, /frozen/)
+ }.should raise_error(RuntimeError, /frozen/)
end
end
end
diff --git a/spec/ruby/library/date/conversions_spec.rb b/spec/ruby/library/date/conversions_spec.rb
index a9a320b0fc..c52ade7012 100644
--- a/spec/ruby/library/date/conversions_spec.rb
+++ b/spec/ruby/library/date/conversions_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#new_start" do
diff --git a/spec/ruby/library/date/ctime_spec.rb b/spec/ruby/library/date/ctime_spec.rb
index 3faa7c6380..0f5d594842 100644
--- a/spec/ruby/library/date/ctime_spec.rb
+++ b/spec/ruby/library/date/ctime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#ctime" do
diff --git a/spec/ruby/library/date/cwday_spec.rb b/spec/ruby/library/date/cwday_spec.rb
index c5a39f277f..33ede37b2c 100644
--- a/spec/ruby/library/date/cwday_spec.rb
+++ b/spec/ruby/library/date/cwday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#cwday" do
diff --git a/spec/ruby/library/date/cweek_spec.rb b/spec/ruby/library/date/cweek_spec.rb
index 6f7aab3922..d988bdd9db 100644
--- a/spec/ruby/library/date/cweek_spec.rb
+++ b/spec/ruby/library/date/cweek_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#cweek" do
diff --git a/spec/ruby/library/date/cwyear_spec.rb b/spec/ruby/library/date/cwyear_spec.rb
index a85ee29920..00544927bc 100644
--- a/spec/ruby/library/date/cwyear_spec.rb
+++ b/spec/ruby/library/date/cwyear_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#cwyear" do
diff --git a/spec/ruby/library/date/day_fraction_spec.rb b/spec/ruby/library/date/day_fraction_spec.rb
index 12b873773f..64896a421e 100644
--- a/spec/ruby/library/date/day_fraction_spec.rb
+++ b/spec/ruby/library/date/day_fraction_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#day_fraction" do
diff --git a/spec/ruby/library/date/day_fraction_to_time_spec.rb b/spec/ruby/library/date/day_fraction_to_time_spec.rb
index d4741d65ec..609367371a 100644
--- a/spec/ruby/library/date/day_fraction_to_time_spec.rb
+++ b/spec/ruby/library/date/day_fraction_to_time_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.day_fraction_to_time" do
diff --git a/spec/ruby/library/date/day_spec.rb b/spec/ruby/library/date/day_spec.rb
index bc727c4717..d3561d802d 100644
--- a/spec/ruby/library/date/day_spec.rb
+++ b/spec/ruby/library/date/day_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#day" do
diff --git a/spec/ruby/library/date/downto_spec.rb b/spec/ruby/library/date/downto_spec.rb
index 84c641ee14..ab9bf11952 100644
--- a/spec/ruby/library/date/downto_spec.rb
+++ b/spec/ruby/library/date/downto_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#downto" do
diff --git a/spec/ruby/library/date/england_spec.rb b/spec/ruby/library/date/england_spec.rb
index 2e30530c5a..6c67c6ee86 100644
--- a/spec/ruby/library/date/england_spec.rb
+++ b/spec/ruby/library/date/england_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#england" do
diff --git a/spec/ruby/library/date/eql_spec.rb b/spec/ruby/library/date/eql_spec.rb
index a1819cae3a..efecde8944 100644
--- a/spec/ruby/library/date/eql_spec.rb
+++ b/spec/ruby/library/date/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#eql?" do
diff --git a/spec/ruby/library/date/format/bag/method_missing_spec.rb b/spec/ruby/library/date/format/bag/method_missing_spec.rb
index 03e4fbcd30..529fde05d2 100644
--- a/spec/ruby/library/date/format/bag/method_missing_spec.rb
+++ b/spec/ruby/library/date/format/bag/method_missing_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Format::Bag#method_missing" do
diff --git a/spec/ruby/library/date/format/bag/to_hash_spec.rb b/spec/ruby/library/date/format/bag/to_hash_spec.rb
index 76734624b9..ba9525e5e8 100644
--- a/spec/ruby/library/date/format/bag/to_hash_spec.rb
+++ b/spec/ruby/library/date/format/bag/to_hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Format::Bag#to_hash" do
diff --git a/spec/ruby/library/date/friday_spec.rb b/spec/ruby/library/date/friday_spec.rb
index 3dc040fabe..369b943419 100644
--- a/spec/ruby/library/date/friday_spec.rb
+++ b/spec/ruby/library/date/friday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#friday?" do
diff --git a/spec/ruby/library/date/gregorian_leap_spec.rb b/spec/ruby/library/date/gregorian_leap_spec.rb
index c3d25cf90f..043d57aa93 100644
--- a/spec/ruby/library/date/gregorian_leap_spec.rb
+++ b/spec/ruby/library/date/gregorian_leap_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#gregorian_leap?" do
@@ -13,3 +13,4 @@ describe "Date#gregorian_leap?" do
Date.gregorian_leap?(2002).should be_false
end
end
+
diff --git a/spec/ruby/library/date/gregorian_spec.rb b/spec/ruby/library/date/gregorian_spec.rb
index 8b7033fe75..5d8b38b2d8 100644
--- a/spec/ruby/library/date/gregorian_spec.rb
+++ b/spec/ruby/library/date/gregorian_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#gregorian?" do
diff --git a/spec/ruby/library/date/hash_spec.rb b/spec/ruby/library/date/hash_spec.rb
index 4fb452d486..271d565253 100644
--- a/spec/ruby/library/date/hash_spec.rb
+++ b/spec/ruby/library/date/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#hash" do
diff --git a/spec/ruby/library/date/infinity/abs_spec.rb b/spec/ruby/library/date/infinity/abs_spec.rb
index c08189155d..a1107679f6 100644
--- a/spec/ruby/library/date/infinity/abs_spec.rb
+++ b/spec/ruby/library/date/infinity/abs_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#abs" do
diff --git a/spec/ruby/library/date/infinity/coerce_spec.rb b/spec/ruby/library/date/infinity/coerce_spec.rb
index 75e5ebeab7..e09b948064 100644
--- a/spec/ruby/library/date/infinity/coerce_spec.rb
+++ b/spec/ruby/library/date/infinity/coerce_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#coerce" do
diff --git a/spec/ruby/library/date/infinity/comparison_spec.rb b/spec/ruby/library/date/infinity/comparison_spec.rb
index a9b9d124fd..7bf8fb7b9f 100644
--- a/spec/ruby/library/date/infinity/comparison_spec.rb
+++ b/spec/ruby/library/date/infinity/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#<=>" do
diff --git a/spec/ruby/library/date/infinity/d_spec.rb b/spec/ruby/library/date/infinity/d_spec.rb
index a5bd2427c7..9ef1f71408 100644
--- a/spec/ruby/library/date/infinity/d_spec.rb
+++ b/spec/ruby/library/date/infinity/d_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#d" do
diff --git a/spec/ruby/library/date/infinity/finite_spec.rb b/spec/ruby/library/date/infinity/finite_spec.rb
index 8971c2213e..92806935fc 100644
--- a/spec/ruby/library/date/infinity/finite_spec.rb
+++ b/spec/ruby/library/date/infinity/finite_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#finite?" do
diff --git a/spec/ruby/library/date/infinity/infinite_spec.rb b/spec/ruby/library/date/infinity/infinite_spec.rb
index 848f538672..8c7e0bc86a 100644
--- a/spec/ruby/library/date/infinity/infinite_spec.rb
+++ b/spec/ruby/library/date/infinity/infinite_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#infinite?" do
diff --git a/spec/ruby/library/date/infinity/nan_spec.rb b/spec/ruby/library/date/infinity/nan_spec.rb
index b0f5d8ac7a..19c7ae0af3 100644
--- a/spec/ruby/library/date/infinity/nan_spec.rb
+++ b/spec/ruby/library/date/infinity/nan_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#nan?" do
diff --git a/spec/ruby/library/date/infinity/uminus_spec.rb b/spec/ruby/library/date/infinity/uminus_spec.rb
index 1b1f568103..110e197231 100644
--- a/spec/ruby/library/date/infinity/uminus_spec.rb
+++ b/spec/ruby/library/date/infinity/uminus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#-@" do
diff --git a/spec/ruby/library/date/infinity/uplus_spec.rb b/spec/ruby/library/date/infinity/uplus_spec.rb
index 6a3b2d8442..dfc60b6b61 100644
--- a/spec/ruby/library/date/infinity/uplus_spec.rb
+++ b/spec/ruby/library/date/infinity/uplus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#+@" do
diff --git a/spec/ruby/library/date/infinity/zero_spec.rb b/spec/ruby/library/date/infinity/zero_spec.rb
index 7df5518785..2f4347255b 100644
--- a/spec/ruby/library/date/infinity/zero_spec.rb
+++ b/spec/ruby/library/date/infinity/zero_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'date'
describe "Date::Infinity#zero?" do
diff --git a/spec/ruby/library/date/infinity_spec.rb b/spec/ruby/library/date/infinity_spec.rb
index 81d67ae249..127fb8c2f4 100644
--- a/spec/ruby/library/date/infinity_spec.rb
+++ b/spec/ruby/library/date/infinity_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date::Infinity" do
diff --git a/spec/ruby/library/date/inspect_spec.rb b/spec/ruby/library/date/inspect_spec.rb
index 81c2cc8003..150eb6bf24 100644
--- a/spec/ruby/library/date/inspect_spec.rb
+++ b/spec/ruby/library/date/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#inspect" do
diff --git a/spec/ruby/library/date/iso8601_spec.rb b/spec/ruby/library/date/iso8601_spec.rb
deleted file mode 100644
index 2c698db514..0000000000
--- a/spec/ruby/library/date/iso8601_spec.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require_relative '../../spec_helper'
-require 'date'
-
-describe "Date.iso8601" do
- it "parses YYYY-MM-DD into a Date object" do
- d = Date.iso8601("2018-01-01")
- d.should == Date.civil(2018, 1, 1)
- end
-
- it "parses YYYYMMDD into a Date object" do
- d = Date.iso8601("20180715")
- d.should == Date.civil(2018, 7, 15)
- end
-
- it "parses a negative Date" do
- d = Date.iso8601("-4712-01-01")
- d.should == Date.civil(-4712, 1, 1)
- end
-
- it "parses a Symbol into a Date object" do
- d = Date.iso8601(:'2015-10-15')
- d.should == Date.civil(2015, 10, 15)
- end
-
- it "parses a StringSubclass into a Date object" do
- d = Date.iso8601(Class.new(String).new("-4712-01-01"))
- d.should == Date.civil(-4712, 1, 1)
- end
-
- it "raises an ArgumentError when passed a Symbol without a valid Date" do
- -> { Date.iso8601(:test) }.should raise_error(ArgumentError)
- end
-
- it "raises a TypeError when passed an Object" do
- -> { Date.iso8601(Object.new) }.should raise_error(TypeError)
- end
-end
-
-describe "Date._iso8601" do
- it "returns an empty hash if the argument is a invalid Date" do
- h = Date._iso8601('invalid')
- h.should == {}
- end
-end
diff --git a/spec/ruby/library/date/italy_spec.rb b/spec/ruby/library/date/italy_spec.rb
index 9369b05180..2d251db1b0 100644
--- a/spec/ruby/library/date/italy_spec.rb
+++ b/spec/ruby/library/date/italy_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#italy" do
diff --git a/spec/ruby/library/date/jd_spec.rb b/spec/ruby/library/date/jd_spec.rb
index 336b783e8d..ccf6b93e06 100644
--- a/spec/ruby/library/date/jd_spec.rb
+++ b/spec/ruby/library/date/jd_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/jd'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/jd', __FILE__)
require 'date'
describe "Date#jd" do
diff --git a/spec/ruby/library/date/jd_to_ajd_spec.rb b/spec/ruby/library/date/jd_to_ajd_spec.rb
index f946c46b8a..38a12bd65d 100644
--- a/spec/ruby/library/date/jd_to_ajd_spec.rb
+++ b/spec/ruby/library/date/jd_to_ajd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.jd_to_ajd" do
diff --git a/spec/ruby/library/date/jd_to_civil_spec.rb b/spec/ruby/library/date/jd_to_civil_spec.rb
index 13b6e47ee2..8608de2698 100644
--- a/spec/ruby/library/date/jd_to_civil_spec.rb
+++ b/spec/ruby/library/date/jd_to_civil_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.jd_to_civil" do
diff --git a/spec/ruby/library/date/jd_to_commercial_spec.rb b/spec/ruby/library/date/jd_to_commercial_spec.rb
index 2256b74f2a..97d76130f2 100644
--- a/spec/ruby/library/date/jd_to_commercial_spec.rb
+++ b/spec/ruby/library/date/jd_to_commercial_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.jd_to_commercial" do
diff --git a/spec/ruby/library/date/jd_to_ld_spec.rb b/spec/ruby/library/date/jd_to_ld_spec.rb
index 5954014f85..d27ada6b6c 100644
--- a/spec/ruby/library/date/jd_to_ld_spec.rb
+++ b/spec/ruby/library/date/jd_to_ld_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.jd_to_ld" do
diff --git a/spec/ruby/library/date/jd_to_mjd_spec.rb b/spec/ruby/library/date/jd_to_mjd_spec.rb
index 24eb84e171..064134c7ed 100644
--- a/spec/ruby/library/date/jd_to_mjd_spec.rb
+++ b/spec/ruby/library/date/jd_to_mjd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.jd_to_mjd" do
diff --git a/spec/ruby/library/date/jd_to_ordinal_spec.rb b/spec/ruby/library/date/jd_to_ordinal_spec.rb
index c7c1704948..a5f5c79641 100644
--- a/spec/ruby/library/date/jd_to_ordinal_spec.rb
+++ b/spec/ruby/library/date/jd_to_ordinal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.jd_to_ordinal" do
diff --git a/spec/ruby/library/date/jd_to_wday_spec.rb b/spec/ruby/library/date/jd_to_wday_spec.rb
index 27e00b2044..569a53e409 100644
--- a/spec/ruby/library/date/jd_to_wday_spec.rb
+++ b/spec/ruby/library/date/jd_to_wday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.jd_to_wday" do
diff --git a/spec/ruby/library/date/julian_leap_spec.rb b/spec/ruby/library/date/julian_leap_spec.rb
index 2ef2d65d81..3915f97693 100644
--- a/spec/ruby/library/date/julian_leap_spec.rb
+++ b/spec/ruby/library/date/julian_leap_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.julian_leap?" do
diff --git a/spec/ruby/library/date/julian_spec.rb b/spec/ruby/library/date/julian_spec.rb
index 637a4739e5..8cbe27b881 100644
--- a/spec/ruby/library/date/julian_spec.rb
+++ b/spec/ruby/library/date/julian_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#julian?" do
diff --git a/spec/ruby/library/date/ld_spec.rb b/spec/ruby/library/date/ld_spec.rb
index 73a47d2382..a59b519c04 100644
--- a/spec/ruby/library/date/ld_spec.rb
+++ b/spec/ruby/library/date/ld_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#ld" do
diff --git a/spec/ruby/library/date/ld_to_jd_spec.rb b/spec/ruby/library/date/ld_to_jd_spec.rb
index 37abe01449..7adbbede37 100644
--- a/spec/ruby/library/date/ld_to_jd_spec.rb
+++ b/spec/ruby/library/date/ld_to_jd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.ld_to_jd" do
diff --git a/spec/ruby/library/date/leap_spec.rb b/spec/ruby/library/date/leap_spec.rb
index 674b191c9f..bb8e920a3e 100644
--- a/spec/ruby/library/date/leap_spec.rb
+++ b/spec/ruby/library/date/leap_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#leap?" do
diff --git a/spec/ruby/library/date/mday_spec.rb b/spec/ruby/library/date/mday_spec.rb
index 53f6f98169..8a1d6e8d59 100644
--- a/spec/ruby/library/date/mday_spec.rb
+++ b/spec/ruby/library/date/mday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#mday" do
diff --git a/spec/ruby/library/date/minus_month_spec.rb b/spec/ruby/library/date/minus_month_spec.rb
index 470c4d8a76..51befcc6d4 100644
--- a/spec/ruby/library/date/minus_month_spec.rb
+++ b/spec/ruby/library/date/minus_month_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#<<" do
@@ -13,11 +13,13 @@ describe "Date#<<" do
d.should == Date.civil(2008, 2, 29)
end
- it "raises an error on non numeric parameters" do
- -> { Date.civil(2007,2,27) << :hello }.should raise_error(TypeError)
- -> { Date.civil(2007,2,27) << "hello" }.should raise_error(TypeError)
- -> { Date.civil(2007,2,27) << Date.new }.should raise_error(TypeError)
- -> { Date.civil(2007,2,27) << Object.new }.should raise_error(TypeError)
+ ruby_version_is "2.3" do
+ it "raises an error on non numeric parameters" do
+ lambda { Date.civil(2007,2,27) << :hello }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) << "hello" }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) << Date.new }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) << Object.new }.should raise_error(TypeError)
+ end
end
end
diff --git a/spec/ruby/library/date/minus_spec.rb b/spec/ruby/library/date/minus_spec.rb
index 5a2a29e04a..fd7f3fd14c 100644
--- a/spec/ruby/library/date/minus_spec.rb
+++ b/spec/ruby/library/date/minus_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#-" do
@@ -22,9 +22,9 @@ describe "Date#-" do
end
it "raises an error for non Numeric arguments" do
- -> { Date.civil(2007,2,27) - :hello }.should raise_error(TypeError)
- -> { Date.civil(2007,2,27) - "hello" }.should raise_error(TypeError)
- -> { Date.civil(2007,2,27) - Object.new }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) - :hello }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) - "hello" }.should raise_error(TypeError)
+ lambda { Date.civil(2007,2,27) - Object.new }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/date/mjd_spec.rb b/spec/ruby/library/date/mjd_spec.rb
index 6f03af346b..7de39f0047 100644
--- a/spec/ruby/library/date/mjd_spec.rb
+++ b/spec/ruby/library/date/mjd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#mjd" do
diff --git a/spec/ruby/library/date/mjd_to_jd_spec.rb b/spec/ruby/library/date/mjd_to_jd_spec.rb
index 2009261103..fdda1330e5 100644
--- a/spec/ruby/library/date/mjd_to_jd_spec.rb
+++ b/spec/ruby/library/date/mjd_to_jd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.mjd_to_jd" do
diff --git a/spec/ruby/library/date/mon_spec.rb b/spec/ruby/library/date/mon_spec.rb
index 724e7d6564..c3508b53bf 100644
--- a/spec/ruby/library/date/mon_spec.rb
+++ b/spec/ruby/library/date/mon_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#mon" do
diff --git a/spec/ruby/library/date/monday_spec.rb b/spec/ruby/library/date/monday_spec.rb
index 14a117b73c..f7d968b6d6 100644
--- a/spec/ruby/library/date/monday_spec.rb
+++ b/spec/ruby/library/date/monday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#monday?" do
diff --git a/spec/ruby/library/date/month_spec.rb b/spec/ruby/library/date/month_spec.rb
index e040f9a94c..ea35430d6b 100644
--- a/spec/ruby/library/date/month_spec.rb
+++ b/spec/ruby/library/date/month_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#month" do
diff --git a/spec/ruby/library/date/new_spec.rb b/spec/ruby/library/date/new_spec.rb
index 18120118c0..f468036a01 100644
--- a/spec/ruby/library/date/new_spec.rb
+++ b/spec/ruby/library/date/new_spec.rb
@@ -1,8 +1,8 @@
require 'date'
-require_relative '../../spec_helper'
-require_relative 'shared/civil'
-require_relative 'shared/new_bang'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/civil', __FILE__)
+require File.expand_path('../shared/new_bang', __FILE__)
describe "Date.new" do
- it_behaves_like :date_civil, :new
+ it_behaves_like(:date_civil, :new)
end
diff --git a/spec/ruby/library/date/new_start_spec.rb b/spec/ruby/library/date/new_start_spec.rb
index aef78f2320..94ec6bee46 100644
--- a/spec/ruby/library/date/new_start_spec.rb
+++ b/spec/ruby/library/date/new_start_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#new_start" do
diff --git a/spec/ruby/library/date/next_day_spec.rb b/spec/ruby/library/date/next_day_spec.rb
index 3b066630e7..795bfecf0a 100644
--- a/spec/ruby/library/date/next_day_spec.rb
+++ b/spec/ruby/library/date/next_day_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#next_day" do
diff --git a/spec/ruby/library/date/next_month_spec.rb b/spec/ruby/library/date/next_month_spec.rb
index 6ee664433f..9becd7e37f 100644
--- a/spec/ruby/library/date/next_month_spec.rb
+++ b/spec/ruby/library/date/next_month_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#next_month" do
diff --git a/spec/ruby/library/date/next_spec.rb b/spec/ruby/library/date/next_spec.rb
index 8063d6a2e4..d88d31e974 100644
--- a/spec/ruby/library/date/next_spec.rb
+++ b/spec/ruby/library/date/next_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#next" do
diff --git a/spec/ruby/library/date/next_year_spec.rb b/spec/ruby/library/date/next_year_spec.rb
index dda9a44008..70f2f7ab77 100644
--- a/spec/ruby/library/date/next_year_spec.rb
+++ b/spec/ruby/library/date/next_year_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#next_year" do
diff --git a/spec/ruby/library/date/ordinal_spec.rb b/spec/ruby/library/date/ordinal_spec.rb
index ec490fd49c..a373692a7b 100644
--- a/spec/ruby/library/date/ordinal_spec.rb
+++ b/spec/ruby/library/date/ordinal_spec.rb
@@ -1,7 +1,8 @@
require 'date'
-require_relative '../../spec_helper'
-require_relative 'shared/ordinal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/ordinal', __FILE__)
describe "Date.ordinal" do
it_behaves_like :date_ordinal, :ordinal
end
+
diff --git a/spec/ruby/library/date/ordinal_to_jd_spec.rb b/spec/ruby/library/date/ordinal_to_jd_spec.rb
index 44f4b3321e..0a76c69c00 100644
--- a/spec/ruby/library/date/ordinal_to_jd_spec.rb
+++ b/spec/ruby/library/date/ordinal_to_jd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.ordinal_to_jd" do
diff --git a/spec/ruby/library/date/parse_spec.rb b/spec/ruby/library/date/parse_spec.rb
index 379847a6fd..092c658809 100644
--- a/spec/ruby/library/date/parse_spec.rb
+++ b/spec/ruby/library/date/parse_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/parse'
-require_relative 'shared/parse_us'
-require_relative 'shared/parse_eu'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/parse', __FILE__)
+require File.expand_path('../shared/parse_us', __FILE__)
+require File.expand_path('../shared/parse_eu', __FILE__)
require 'date'
describe "Date#parse" do
@@ -23,7 +23,7 @@ describe "Date#parse" do
# Specs using numbers
it "throws an argument error for a single digit" do
- ->{ Date.parse("1") }.should raise_error(ArgumentError)
+ lambda{ Date.parse("1") }.should raise_error(ArgumentError)
end
it "parses DD as month day number" do
@@ -64,11 +64,6 @@ describe "Date#parse" do
d = Date.parse("19101101")
d.should == Date.civil(1910, 11, 1)
end
-
- it "raises a TypeError trying to parse non-String-like object" do
- -> { Date.parse(1) }.should raise_error(TypeError)
- -> { Date.parse(:invalid) }.should raise_error(TypeError)
- end
end
describe "Date#parse with '.' separator" do
diff --git a/spec/ruby/library/date/plus_spec.rb b/spec/ruby/library/date/plus_spec.rb
index 0cb99fd4ca..e33fb199eb 100644
--- a/spec/ruby/library/date/plus_spec.rb
+++ b/spec/ruby/library/date/plus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#+" do
@@ -15,6 +15,6 @@ describe "Date#+" do
end
it "raises TypeError if argument is not Numeric" do
- -> { Date.today + Date.today }.should raise_error(TypeError)
+ lambda { Date.today + Date.today }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/date/prev_day_spec.rb b/spec/ruby/library/date/prev_day_spec.rb
index cce24da875..149bfe9fa9 100644
--- a/spec/ruby/library/date/prev_day_spec.rb
+++ b/spec/ruby/library/date/prev_day_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#prev_day" do
diff --git a/spec/ruby/library/date/prev_month_spec.rb b/spec/ruby/library/date/prev_month_spec.rb
index 3d0d1d437d..440c17ffc9 100644
--- a/spec/ruby/library/date/prev_month_spec.rb
+++ b/spec/ruby/library/date/prev_month_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#prev_month" do
diff --git a/spec/ruby/library/date/prev_year_spec.rb b/spec/ruby/library/date/prev_year_spec.rb
index ba06dd198b..4f27d1d1f9 100644
--- a/spec/ruby/library/date/prev_year_spec.rb
+++ b/spec/ruby/library/date/prev_year_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#prev_year" do
diff --git a/spec/ruby/library/date/relationship_spec.rb b/spec/ruby/library/date/relationship_spec.rb
index 979516e164..7c09457228 100644
--- a/spec/ruby/library/date/relationship_spec.rb
+++ b/spec/ruby/library/date/relationship_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#===" do
diff --git a/spec/ruby/library/date/rfc3339_spec.rb b/spec/ruby/library/date/rfc3339_spec.rb
deleted file mode 100644
index a8711d47b2..0000000000
--- a/spec/ruby/library/date/rfc3339_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../spec_helper'
-require 'date'
-
-describe "Date.rfc3339" do
- it "needs to be reviewed for spec completeness"
-end
-
-describe "Date._rfc3339" do
- it "returns an empty hash if the argument is a invalid Date" do
- h = Date._rfc3339('invalid')
- h.should == {}
- end
-end
diff --git a/spec/ruby/library/date/right_shift_spec.rb b/spec/ruby/library/date/right_shift_spec.rb
index bd7de0e3d5..3d55e5abed 100644
--- a/spec/ruby/library/date/right_shift_spec.rb
+++ b/spec/ruby/library/date/right_shift_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#>>" do
diff --git a/spec/ruby/library/date/saturday_spec.rb b/spec/ruby/library/date/saturday_spec.rb
index 1527b71d00..1360050a69 100644
--- a/spec/ruby/library/date/saturday_spec.rb
+++ b/spec/ruby/library/date/saturday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#saturday?" do
diff --git a/spec/ruby/library/date/shared/civil.rb b/spec/ruby/library/date/shared/civil.rb
index 4c8ba23622..47dbed49fc 100644
--- a/spec/ruby/library/date/shared/civil.rb
+++ b/spec/ruby/library/date/shared/civil.rb
@@ -36,14 +36,14 @@ describe :date_civil, shared: true do
end
it "doesn't create dates for invalid arguments" do
- -> { Date.send(@method, 2000, 13, 31) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2000, 12, 32) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2000, 2, 30) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 1900, 2, 29) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2000, 2, 29) }.should_not raise_error(ArgumentError)
-
- -> { Date.send(@method, 1582, 10, 14) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 1582, 10, 15) }.should_not raise_error(ArgumentError)
+ lambda { Date.send(@method, 2000, 13, 31) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2000, 12, 32) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2000, 2, 30) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 1900, 2, 29) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2000, 2, 29) }.should_not raise_error(ArgumentError)
+
+ lambda { Date.send(@method, 1582, 10, 14) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 1582, 10, 15) }.should_not raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/date/shared/commercial.rb b/spec/ruby/library/date/shared/commercial.rb
index 39c9af47b6..354a5d5cd0 100644
--- a/spec/ruby/library/date/shared/commercial.rb
+++ b/spec/ruby/library/date/shared/commercial.rb
@@ -25,15 +25,15 @@ describe :date_commercial, shared: true do
end
it "creates only Date objects for valid weeks" do
- -> { Date.send(@method, 2004, 53, 1) }.should_not raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 53, 0) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 53, 8) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 54, 1) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 0, 1) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2004, 53, 1) }.should_not raise_error(ArgumentError)
+ lambda { Date.send(@method, 2004, 53, 0) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2004, 53, 8) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2004, 54, 1) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2004, 0, 1) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2003, 52, 1) }.should_not raise_error(ArgumentError)
- -> { Date.send(@method, 2003, 53, 1) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2003, 52, 0) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2003, 52, 8) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2003, 52, 1) }.should_not raise_error(ArgumentError)
+ lambda { Date.send(@method, 2003, 53, 1) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2003, 52, 0) }.should raise_error(ArgumentError)
+ lambda { Date.send(@method, 2003, 52, 8) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/date/shared/valid_jd.rb b/spec/ruby/library/date/shared/valid_jd.rb
index f6ca3f579d..bd71f5abba 100644
--- a/spec/ruby/library/date/shared/valid_jd.rb
+++ b/spec/ruby/library/date/shared/valid_jd.rb
@@ -1,8 +1,7 @@
describe :date_valid_jd?, shared: true do
- it "returns true if passed a number value" do
+ it "returns true if passed any value other than nil" do
Date.send(@method, -100).should be_true
- Date.send(@method, 100.0).should be_true
- Date.send(@method, 2**100).should be_true
+ Date.send(@method, :number).should be_true
Date.send(@method, Rational(1,2)).should be_true
end
@@ -10,23 +9,7 @@ describe :date_valid_jd?, shared: true do
Date.send(@method, nil).should be_false
end
- ruby_version_is ''...'2.7' do
- it "returns true if passed symbol" do
- Date.send(@method, :number).should be_true
- end
-
- it "returns true if passed false" do
- Date.send(@method, false).should be_true
- end
- end
-
- ruby_version_is '2.7' do
- it "returns false if passed symbol" do
- Date.send(@method, :number).should be_false
- end
-
- it "returns false if passed false" do
- Date.send(@method, false).should be_false
- end
+ it "returns true if passed false" do
+ Date.send(@method, false).should be_true
end
end
diff --git a/spec/ruby/library/date/start_spec.rb b/spec/ruby/library/date/start_spec.rb
index 8ba272a7f3..285037b094 100644
--- a/spec/ruby/library/date/start_spec.rb
+++ b/spec/ruby/library/date/start_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#start" do
diff --git a/spec/ruby/library/date/step_spec.rb b/spec/ruby/library/date/step_spec.rb
index 6bbd671840..249633e807 100644
--- a/spec/ruby/library/date/step_spec.rb
+++ b/spec/ruby/library/date/step_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#step" do
diff --git a/spec/ruby/library/date/strftime_spec.rb b/spec/ruby/library/date/strftime_spec.rb
index 9d298e42e6..81bb162ff7 100644
--- a/spec/ruby/library/date/strftime_spec.rb
+++ b/spec/ruby/library/date/strftime_spec.rb
@@ -1,9 +1,9 @@
require 'date'
-require_relative '../../shared/time/strftime_for_date'
+require File.expand_path('../../../shared/time/strftime_for_date', __FILE__)
describe "Date#strftime" do
before :all do
- @new_date = -> y, m, d { Date.civil(y,m,d) }
+ @new_date = lambda { |y,m,d| Date.civil(y,m,d) }
@date = Date.civil(2000, 4, 9)
end
diff --git a/spec/ruby/library/date/strptime_spec.rb b/spec/ruby/library/date/strptime_spec.rb
index c90721751e..21a73da086 100644
--- a/spec/ruby/library/date/strptime_spec.rb
+++ b/spec/ruby/library/date/strptime_spec.rb
@@ -1,5 +1,5 @@
require 'date'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Date#strptime" do
diff --git a/spec/ruby/library/date/succ_spec.rb b/spec/ruby/library/date/succ_spec.rb
index c4a902aa63..2650810e73 100644
--- a/spec/ruby/library/date/succ_spec.rb
+++ b/spec/ruby/library/date/succ_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#succ" do
diff --git a/spec/ruby/library/date/sunday_spec.rb b/spec/ruby/library/date/sunday_spec.rb
index c3a817fa86..d805006264 100644
--- a/spec/ruby/library/date/sunday_spec.rb
+++ b/spec/ruby/library/date/sunday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#sunday?" do
diff --git a/spec/ruby/library/date/thursday_spec.rb b/spec/ruby/library/date/thursday_spec.rb
index 74b5f40365..a59ca3f6cf 100644
--- a/spec/ruby/library/date/thursday_spec.rb
+++ b/spec/ruby/library/date/thursday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#thursday?" do
diff --git a/spec/ruby/library/date/time_to_day_fraction_spec.rb b/spec/ruby/library/date/time_to_day_fraction_spec.rb
index e59980e036..06d477b601 100644
--- a/spec/ruby/library/date/time_to_day_fraction_spec.rb
+++ b/spec/ruby/library/date/time_to_day_fraction_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.time_to_day_fraction" do
diff --git a/spec/ruby/library/date/to_s_spec.rb b/spec/ruby/library/date/to_s_spec.rb
index fe7cb19a46..a81297d689 100644
--- a/spec/ruby/library/date/to_s_spec.rb
+++ b/spec/ruby/library/date/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#to_s" do
diff --git a/spec/ruby/library/date/today_spec.rb b/spec/ruby/library/date/today_spec.rb
index 7c6ebc9cb4..d487be089f 100644
--- a/spec/ruby/library/date/today_spec.rb
+++ b/spec/ruby/library/date/today_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.today" do
diff --git a/spec/ruby/library/date/tuesday_spec.rb b/spec/ruby/library/date/tuesday_spec.rb
index 052837b54e..10ed6755d1 100644
--- a/spec/ruby/library/date/tuesday_spec.rb
+++ b/spec/ruby/library/date/tuesday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#tuesday?" do
diff --git a/spec/ruby/library/date/upto_spec.rb b/spec/ruby/library/date/upto_spec.rb
index 8745be85b3..c99aabd1d7 100644
--- a/spec/ruby/library/date/upto_spec.rb
+++ b/spec/ruby/library/date/upto_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#upto" do
diff --git a/spec/ruby/library/date/valid_civil_spec.rb b/spec/ruby/library/date/valid_civil_spec.rb
index 00f2c57205..09185674ee 100644
--- a/spec/ruby/library/date/valid_civil_spec.rb
+++ b/spec/ruby/library/date/valid_civil_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/valid_civil'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/valid_civil', __FILE__)
require 'date'
describe "Date#valid_civil?" do
@@ -7,3 +7,4 @@ describe "Date#valid_civil?" do
it_behaves_like :date_valid_civil?, :valid_civil?
end
+
diff --git a/spec/ruby/library/date/valid_commercial_spec.rb b/spec/ruby/library/date/valid_commercial_spec.rb
index 7e96782b6b..187d818233 100644
--- a/spec/ruby/library/date/valid_commercial_spec.rb
+++ b/spec/ruby/library/date/valid_commercial_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'shared/valid_commercial'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/valid_commercial', __FILE__)
require 'date'
describe "Date#valid_commercial?" do
it_behaves_like :date_valid_commercial?, :valid_commercial?
end
+
+
diff --git a/spec/ruby/library/date/valid_date_spec.rb b/spec/ruby/library/date/valid_date_spec.rb
index f12a71d966..ffaf007cd1 100644
--- a/spec/ruby/library/date/valid_date_spec.rb
+++ b/spec/ruby/library/date/valid_date_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/valid_civil'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/valid_civil', __FILE__)
require 'date'
describe "Date#valid_date?" do
diff --git a/spec/ruby/library/date/valid_jd_spec.rb b/spec/ruby/library/date/valid_jd_spec.rb
index aecaaabcf4..9764c02f2b 100644
--- a/spec/ruby/library/date/valid_jd_spec.rb
+++ b/spec/ruby/library/date/valid_jd_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/valid_jd'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/valid_jd', __FILE__)
require 'date'
describe "Date.valid_jd?" do
@@ -7,3 +7,4 @@ describe "Date.valid_jd?" do
it_behaves_like :date_valid_jd?, :valid_jd?
end
+
diff --git a/spec/ruby/library/date/valid_ordinal_spec.rb b/spec/ruby/library/date/valid_ordinal_spec.rb
index 58d548c704..e197bb2051 100644
--- a/spec/ruby/library/date/valid_ordinal_spec.rb
+++ b/spec/ruby/library/date/valid_ordinal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/valid_ordinal'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/valid_ordinal', __FILE__)
require 'date'
describe "Date.valid_ordinal?" do
@@ -7,3 +7,4 @@ describe "Date.valid_ordinal?" do
it_behaves_like :date_valid_ordinal?, :valid_ordinal?
end
+
diff --git a/spec/ruby/library/date/valid_time_spec.rb b/spec/ruby/library/date/valid_time_spec.rb
index 87c239bedb..e96f9041b7 100644
--- a/spec/ruby/library/date/valid_time_spec.rb
+++ b/spec/ruby/library/date/valid_time_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.valid_time?" do
diff --git a/spec/ruby/library/date/wday_spec.rb b/spec/ruby/library/date/wday_spec.rb
index 303905ed35..7303423123 100644
--- a/spec/ruby/library/date/wday_spec.rb
+++ b/spec/ruby/library/date/wday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#wday" do
diff --git a/spec/ruby/library/date/wednesday_spec.rb b/spec/ruby/library/date/wednesday_spec.rb
index e80ec23dd2..99478f21c2 100644
--- a/spec/ruby/library/date/wednesday_spec.rb
+++ b/spec/ruby/library/date/wednesday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#wednesday?" do
diff --git a/spec/ruby/library/date/yday_spec.rb b/spec/ruby/library/date/yday_spec.rb
index cfb174a4c2..92bf616406 100644
--- a/spec/ruby/library/date/yday_spec.rb
+++ b/spec/ruby/library/date/yday_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#yday" do
diff --git a/spec/ruby/library/date/year_spec.rb b/spec/ruby/library/date/year_spec.rb
index 90d14e5a39..4720ddcd9a 100644
--- a/spec/ruby/library/date/year_spec.rb
+++ b/spec/ruby/library/date/year_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#year" do
diff --git a/spec/ruby/library/date/zone_to_diff_spec.rb b/spec/ruby/library/date/zone_to_diff_spec.rb
index 354daaaee4..a39de0b58e 100644
--- a/spec/ruby/library/date/zone_to_diff_spec.rb
+++ b/spec/ruby/library/date/zone_to_diff_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date.zone_to_diff" do
diff --git a/spec/ruby/library/datetime/_strptime_spec.rb b/spec/ruby/library/datetime/_strptime_spec.rb
index abec26ff9f..c8c910618d 100644
--- a/spec/ruby/library/datetime/_strptime_spec.rb
+++ b/spec/ruby/library/datetime/_strptime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime._strptime" do
diff --git a/spec/ruby/library/datetime/add_spec.rb b/spec/ruby/library/datetime/add_spec.rb
deleted file mode 100644
index 20288e2105..0000000000
--- a/spec/ruby/library/datetime/add_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../spec_helper'
-require 'date'
-
-describe "DateTime#+" do
- it "is able to add sub-millisecond precision values" do
- datetime = DateTime.new(2017)
- (datetime + 0.00001001).to_time.usec.should == 864864
- end
-end
diff --git a/spec/ruby/library/datetime/civil_spec.rb b/spec/ruby/library/datetime/civil_spec.rb
index fb6f67f16d..77df021e33 100644
--- a/spec/ruby/library/datetime/civil_spec.rb
+++ b/spec/ruby/library/datetime/civil_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.civil" do
diff --git a/spec/ruby/library/datetime/commercial_spec.rb b/spec/ruby/library/datetime/commercial_spec.rb
index ad97b2a80e..2984dd5334 100644
--- a/spec/ruby/library/datetime/commercial_spec.rb
+++ b/spec/ruby/library/datetime/commercial_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.commercial" do
diff --git a/spec/ruby/library/datetime/hour_spec.rb b/spec/ruby/library/datetime/hour_spec.rb
index 8efd5f92f0..db89016937 100644
--- a/spec/ruby/library/datetime/hour_spec.rb
+++ b/spec/ruby/library/datetime/hour_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#hour" do
@@ -15,27 +15,27 @@ describe "DateTime#hour" do
end
it "raises an error for Rational" do
- -> { new_datetime(hour: 1 + Rational(1,2)) }.should raise_error(ArgumentError)
+ lambda { new_datetime(hour: 1 + Rational(1,2)) }.should raise_error(ArgumentError)
end
it "raises an error for Float" do
- -> { new_datetime(hour: 1.5).hour }.should raise_error(ArgumentError)
+ lambda { new_datetime(hour: 1.5).hour }.should raise_error(ArgumentError)
end
it "raises an error for Rational" do
- -> { new_datetime(day: 1 + Rational(1,2)) }.should raise_error(ArgumentError)
+ lambda { new_datetime(day: 1 + Rational(1,2)) }.should raise_error(ArgumentError)
end
it "raises an error, when the hour is smaller than -24" do
- -> { new_datetime(hour: -25) }.should raise_error(ArgumentError)
+ lambda { new_datetime(hour: -25) }.should raise_error(ArgumentError)
end
it "raises an error, when the hour is larger than 24" do
- -> { new_datetime(hour: 25) }.should raise_error(ArgumentError)
+ lambda { new_datetime(hour: 25) }.should raise_error(ArgumentError)
end
it "raises an error for hour fractions smaller than -24" do
- -> { new_datetime(hour: -24 - Rational(1,2)) }.should(
+ lambda { new_datetime(hour: -24 - Rational(1,2)) }.should(
raise_error(ArgumentError))
end
diff --git a/spec/ruby/library/datetime/httpdate_spec.rb b/spec/ruby/library/datetime/httpdate_spec.rb
index 68e45cbff0..e97fda7fb4 100644
--- a/spec/ruby/library/datetime/httpdate_spec.rb
+++ b/spec/ruby/library/datetime/httpdate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.httpdate" do
diff --git a/spec/ruby/library/datetime/iso8601_spec.rb b/spec/ruby/library/datetime/iso8601_spec.rb
index 457881277a..44887148d3 100644
--- a/spec/ruby/library/datetime/iso8601_spec.rb
+++ b/spec/ruby/library/datetime/iso8601_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.iso8601" do
diff --git a/spec/ruby/library/datetime/jd_spec.rb b/spec/ruby/library/datetime/jd_spec.rb
index 1e783f5af4..e8271089f7 100644
--- a/spec/ruby/library/datetime/jd_spec.rb
+++ b/spec/ruby/library/datetime/jd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.jd" do
diff --git a/spec/ruby/library/datetime/jisx0301_spec.rb b/spec/ruby/library/datetime/jisx0301_spec.rb
index ab26aa2d73..2402a21cb0 100644
--- a/spec/ruby/library/datetime/jisx0301_spec.rb
+++ b/spec/ruby/library/datetime/jisx0301_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.jisx0301" do
diff --git a/spec/ruby/library/datetime/min_spec.rb b/spec/ruby/library/datetime/min_spec.rb
index a1eaa214cb..5f7d7e7810 100644
--- a/spec/ruby/library/datetime/min_spec.rb
+++ b/spec/ruby/library/datetime/min_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/min'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/min', __FILE__)
describe "DateTime.min" do
it_behaves_like :datetime_min, :min
diff --git a/spec/ruby/library/datetime/minute_spec.rb b/spec/ruby/library/datetime/minute_spec.rb
index acdfeda345..3ab01572fe 100644
--- a/spec/ruby/library/datetime/minute_spec.rb
+++ b/spec/ruby/library/datetime/minute_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/min'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/min', __FILE__)
describe "DateTime.minute" do
it_behaves_like :datetime_min, :minute
diff --git a/spec/ruby/library/datetime/new_offset_spec.rb b/spec/ruby/library/datetime/new_offset_spec.rb
index bc0988f32d..b900de6097 100644
--- a/spec/ruby/library/datetime/new_offset_spec.rb
+++ b/spec/ruby/library/datetime/new_offset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#new_offset" do
diff --git a/spec/ruby/library/datetime/new_spec.rb b/spec/ruby/library/datetime/new_spec.rb
index 6a4dced384..14ef329d56 100644
--- a/spec/ruby/library/datetime/new_spec.rb
+++ b/spec/ruby/library/datetime/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.new" do
@@ -47,6 +47,6 @@ describe "DateTime.new" do
end
it "raises an error on invalid arguments" do
- -> { new_datetime(minute: 999) }.should raise_error(ArgumentError)
+ lambda { new_datetime(minute: 999) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/datetime/now_spec.rb b/spec/ruby/library/datetime/now_spec.rb
index 9f22153c15..9118163533 100644
--- a/spec/ruby/library/datetime/now_spec.rb
+++ b/spec/ruby/library/datetime/now_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.now" do
@@ -7,13 +7,13 @@ describe "DateTime.now" do
end
it "sets the current date" do
- (DateTime.now - Date.today).to_f.should be_close(0.0, TIME_TOLERANCE)
+ (DateTime.now - Date.today).to_f.should be_close(0.0, 2.0)
end
it "sets the current time" do
dt = DateTime.now
now = Time.now
- (dt.to_time - now).should be_close(0.0, TIME_TOLERANCE)
+ (dt.to_time - now).should be_close(0.0, 10.0)
end
it "grabs the local timezone" do
diff --git a/spec/ruby/library/datetime/offset_spec.rb b/spec/ruby/library/datetime/offset_spec.rb
index e25e7a0f35..c11d28bad2 100644
--- a/spec/ruby/library/datetime/offset_spec.rb
+++ b/spec/ruby/library/datetime/offset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#offset" do
diff --git a/spec/ruby/library/datetime/ordinal_spec.rb b/spec/ruby/library/datetime/ordinal_spec.rb
index 64b154ee9b..2ada512e05 100644
--- a/spec/ruby/library/datetime/ordinal_spec.rb
+++ b/spec/ruby/library/datetime/ordinal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.ordinal" do
diff --git a/spec/ruby/library/datetime/parse_spec.rb b/spec/ruby/library/datetime/parse_spec.rb
index e9bf4e2ed1..14a68f1499 100644
--- a/spec/ruby/library/datetime/parse_spec.rb
+++ b/spec/ruby/library/datetime/parse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.parse" do
@@ -20,7 +20,7 @@ describe "DateTime.parse" do
# Specs using numbers
it "throws an argument error for a single digit" do
- ->{ DateTime.parse("1") }.should raise_error(ArgumentError)
+ lambda{ DateTime.parse("1") }.should raise_error(ArgumentError)
end
it "parses DD as month day number" do
@@ -54,23 +54,23 @@ describe "DateTime.parse" do
end
it "throws an argument error for invalid month values" do
- ->{DateTime.parse("2012-13-08T15:43:59")}.should raise_error(ArgumentError)
+ lambda{DateTime.parse("2012-13-08T15:43:59")}.should raise_error(ArgumentError)
end
it "throws an argument error for invalid day values" do
- ->{DateTime.parse("2012-12-32T15:43:59")}.should raise_error(ArgumentError)
+ lambda{DateTime.parse("2012-12-32T15:43:59")}.should raise_error(ArgumentError)
end
it "throws an argument error for invalid hour values" do
- ->{DateTime.parse("2012-12-31T25:43:59")}.should raise_error(ArgumentError)
+ lambda{DateTime.parse("2012-12-31T25:43:59")}.should raise_error(ArgumentError)
end
it "throws an argument error for invalid minute values" do
- ->{DateTime.parse("2012-12-31T25:43:59")}.should raise_error(ArgumentError)
+ lambda{DateTime.parse("2012-12-31T25:43:59")}.should raise_error(ArgumentError)
end
it "throws an argument error for invalid second values" do
- ->{DateTime.parse("2012-11-08T15:43:61")}.should raise_error(ArgumentError)
+ lambda{DateTime.parse("2012-11-08T15:43:61")}.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/datetime/rfc2822_spec.rb b/spec/ruby/library/datetime/rfc2822_spec.rb
index 70bfca60b4..3fc4dc14b8 100644
--- a/spec/ruby/library/datetime/rfc2822_spec.rb
+++ b/spec/ruby/library/datetime/rfc2822_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.rfc2822" do
diff --git a/spec/ruby/library/datetime/rfc3339_spec.rb b/spec/ruby/library/datetime/rfc3339_spec.rb
index f870a5f63b..4fea795d9e 100644
--- a/spec/ruby/library/datetime/rfc3339_spec.rb
+++ b/spec/ruby/library/datetime/rfc3339_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.rfc3339" do
diff --git a/spec/ruby/library/datetime/rfc822_spec.rb b/spec/ruby/library/datetime/rfc822_spec.rb
index 0cd0aacc19..f86ee77379 100644
--- a/spec/ruby/library/datetime/rfc822_spec.rb
+++ b/spec/ruby/library/datetime/rfc822_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.rfc822" do
diff --git a/spec/ruby/library/datetime/sec_fraction_spec.rb b/spec/ruby/library/datetime/sec_fraction_spec.rb
index 40383a8ca4..3ed274a5bc 100644
--- a/spec/ruby/library/datetime/sec_fraction_spec.rb
+++ b/spec/ruby/library/datetime/sec_fraction_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#sec_fraction" do
diff --git a/spec/ruby/library/datetime/sec_spec.rb b/spec/ruby/library/datetime/sec_spec.rb
index f681283c8e..c7e9af2650 100644
--- a/spec/ruby/library/datetime/sec_spec.rb
+++ b/spec/ruby/library/datetime/sec_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/sec'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/sec', __FILE__)
describe "DateTime.sec" do
it_behaves_like :datetime_sec, :sec
diff --git a/spec/ruby/library/datetime/second_fraction_spec.rb b/spec/ruby/library/datetime/second_fraction_spec.rb
index d5393149ba..32dc9333f6 100644
--- a/spec/ruby/library/datetime/second_fraction_spec.rb
+++ b/spec/ruby/library/datetime/second_fraction_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#second_fraction" do
diff --git a/spec/ruby/library/datetime/second_spec.rb b/spec/ruby/library/datetime/second_spec.rb
index 545c3f9109..08cdf463f7 100644
--- a/spec/ruby/library/datetime/second_spec.rb
+++ b/spec/ruby/library/datetime/second_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/sec'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/sec', __FILE__)
describe "DateTime#second" do
it_behaves_like :datetime_sec, :second
diff --git a/spec/ruby/library/datetime/shared/min.rb b/spec/ruby/library/datetime/shared/min.rb
index a35b839281..e69d86ab02 100644
--- a/spec/ruby/library/datetime/shared/min.rb
+++ b/spec/ruby/library/datetime/shared/min.rb
@@ -14,27 +14,27 @@ describe :datetime_min, shared: true do
end
it "raises an error for Rational" do
- -> { new_datetime minute: 5 + Rational(1,2) }.should raise_error(ArgumentError)
+ lambda { new_datetime minute: 5 + Rational(1,2) }.should raise_error(ArgumentError)
end
it "raises an error for Float" do
- -> { new_datetime minute: 5.5 }.should raise_error(ArgumentError)
+ lambda { new_datetime minute: 5.5 }.should raise_error(ArgumentError)
end
it "raises an error for Rational" do
- -> { new_datetime(hour: 2 + Rational(1,2)) }.should raise_error(ArgumentError)
+ lambda { new_datetime(hour: 2 + Rational(1,2)) }.should raise_error(ArgumentError)
end
it "raises an error, when the minute is smaller than -60" do
- -> { new_datetime(minute: -61) }.should raise_error(ArgumentError)
+ lambda { new_datetime(minute: -61) }.should raise_error(ArgumentError)
end
it "raises an error, when the minute is greater or equal than 60" do
- -> { new_datetime(minute: 60) }.should raise_error(ArgumentError)
+ lambda { new_datetime(minute: 60) }.should raise_error(ArgumentError)
end
it "raises an error for minute fractions smaller than -60" do
- -> { new_datetime(minute: -60 - Rational(1,2))}.should(
+ lambda { new_datetime(minute: -60 - Rational(1,2))}.should(
raise_error(ArgumentError))
end
end
diff --git a/spec/ruby/library/datetime/shared/sec.rb b/spec/ruby/library/datetime/shared/sec.rb
index 60009213aa..68e8af8e40 100644
--- a/spec/ruby/library/datetime/shared/sec.rb
+++ b/spec/ruby/library/datetime/shared/sec.rb
@@ -23,19 +23,19 @@ describe :datetime_sec, shared: true do
end
it "raises an error when minute is given as a rational" do
- -> { new_datetime(minute: 5 + Rational(1,2)) }.should raise_error(ArgumentError)
+ lambda { new_datetime(minute: 5 + Rational(1,2)) }.should raise_error(ArgumentError)
end
it "raises an error, when the second is smaller than -60" do
- -> { new_datetime(second: -61) }.should raise_error(ArgumentError)
+ lambda { new_datetime(second: -61) }.should raise_error(ArgumentError)
end
it "raises an error, when the second is greater or equal than 60" do
- -> { new_datetime(second: 60) }.should raise_error(ArgumentError)
+ lambda { new_datetime(second: 60) }.should raise_error(ArgumentError)
end
it "raises an error for second fractions smaller than -60" do
- -> { new_datetime(second: -60 - Rational(1,2))}.should(
+ lambda { new_datetime(second: -60 - Rational(1,2))}.should(
raise_error(ArgumentError))
end
diff --git a/spec/ruby/library/datetime/strftime_spec.rb b/spec/ruby/library/datetime/strftime_spec.rb
index 1c925f92eb..37705788a1 100644
--- a/spec/ruby/library/datetime/strftime_spec.rb
+++ b/spec/ruby/library/datetime/strftime_spec.rb
@@ -1,16 +1,16 @@
require 'date'
-require_relative '../../shared/time/strftime_for_date'
-require_relative '../../shared/time/strftime_for_time'
+require File.expand_path('../../../shared/time/strftime_for_date', __FILE__)
+require File.expand_path('../../../shared/time/strftime_for_time', __FILE__)
describe "DateTime#strftime" do
before :all do
- @new_date = -> y, m, d { DateTime.civil(y,m,d) }
- @new_time = -> *args { DateTime.civil(*args) }
- @new_time_in_zone = -> zone, offset, *args {
+ @new_date = lambda { |y,m,d| DateTime.civil(y,m,d) }
+ @new_time = lambda { |*args| DateTime.civil(*args) }
+ @new_time_in_zone = lambda { |zone,offset,*args|
y, m, d, h, min, s = args
DateTime.new(y, m||1, d||1, h||0, min||0, s||0, Rational(offset, 24))
}
- @new_time_with_offset = -> y, m, d, h, min, s, offset {
+ @new_time_with_offset = lambda { |y,m,d,h,min,s,offset|
DateTime.new(y,m,d,h,min,s, Rational(offset, 86_400))
}
diff --git a/spec/ruby/library/datetime/strptime_spec.rb b/spec/ruby/library/datetime/strptime_spec.rb
index d1e83550e4..f3098f6f6b 100644
--- a/spec/ruby/library/datetime/strptime_spec.rb
+++ b/spec/ruby/library/datetime/strptime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.strptime" do
diff --git a/spec/ruby/library/datetime/subtract_spec.rb b/spec/ruby/library/datetime/subtract_spec.rb
deleted file mode 100644
index ba01f4eff6..0000000000
--- a/spec/ruby/library/datetime/subtract_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../spec_helper'
-require 'date'
-
-describe "DateTime#-" do
- it "is able to subtract sub-millisecond precision values" do
- date = DateTime.new(2017)
- diff = Rational(123456789, 24*60*60*1000*1000)
- ((date + diff) - date).should == diff
- (date - (date + diff)).should == -diff
- (date - (date - diff)).should == diff
- ((date - diff) - date).should == -diff
- end
-
- it "correctly calculates sub-millisecond time differences" do #5493
- dt1 = DateTime.new(2018, 1, 1, 0, 0, 30)
- dt2 = DateTime.new(2018, 1, 1, 0, 1, 29.000001)
- ((dt2 - dt1) * 24 * 60 * 60).should == 59.000001
- end
-end
diff --git a/spec/ruby/library/datetime/to_date_spec.rb b/spec/ruby/library/datetime/to_date_spec.rb
index 48c05e7fed..387eda9229 100644
--- a/spec/ruby/library/datetime/to_date_spec.rb
+++ b/spec/ruby/library/datetime/to_date_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#to_date" do
@@ -30,7 +30,7 @@ describe "DateTime#to_date" do
it "maintains the same julian day regardless of local time or zone" do
dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00')
- with_timezone("Pacific/Pago_Pago", -11) do
+ with_timezone("Pactific/Pago_Pago", -11) do
dt.to_date.jd.should == dt.jd
end
end
diff --git a/spec/ruby/library/datetime/to_datetime_spec.rb b/spec/ruby/library/datetime/to_datetime_spec.rb
index 95ee29268f..e4db9558f1 100644
--- a/spec/ruby/library/datetime/to_datetime_spec.rb
+++ b/spec/ruby/library/datetime/to_datetime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#to_datetime" do
diff --git a/spec/ruby/library/datetime/to_s_spec.rb b/spec/ruby/library/datetime/to_s_spec.rb
index 175fb807f4..9d9dfc629f 100644
--- a/spec/ruby/library/datetime/to_s_spec.rb
+++ b/spec/ruby/library/datetime/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#to_s" do
@@ -10,7 +10,7 @@ describe "DateTime#to_s" do
it "maintains timezone regardless of local time" do
dt = DateTime.new(2012, 12, 24, 1, 2, 3, "+03:00")
- with_timezone("Pacific/Pago_Pago", -11) do
+ with_timezone("Pactific/Pago_Pago", -11) do
dt.to_s.should == "2012-12-24T01:02:03+03:00"
end
end
diff --git a/spec/ruby/library/datetime/to_time_spec.rb b/spec/ruby/library/datetime/to_time_spec.rb
index a11b6e30e1..2a016d1528 100644
--- a/spec/ruby/library/datetime/to_time_spec.rb
+++ b/spec/ruby/library/datetime/to_time_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#to_time" do
@@ -18,19 +18,21 @@ describe "DateTime#to_time" do
time.sec.should == 59
end
- it "preserves the same time regardless of local time or zone" do
- date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00')
+ ruby_version_is "2.4" do
+ it "preserves the same time regardless of local time or zone" do
+ date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00')
- with_timezone("Pacific/Pago_Pago", -11) do
- time = date.to_time
+ with_timezone("Pactific/Pago_Pago", -11) do
+ time = date.to_time
- time.utc_offset.should == 3 * 3600
- time.year.should == date.year
- time.mon.should == date.mon
- time.day.should == date.day
- time.hour.should == date.hour
- time.min.should == date.min
- time.sec.should == date.sec
+ time.utc_offset.should == 3 * 3600
+ time.year.should == date.year
+ time.mon.should == date.mon
+ time.day.should == date.day
+ time.hour.should == date.hour
+ time.min.should == date.min
+ time.sec.should == date.sec
+ end
end
end
end
diff --git a/spec/ruby/library/datetime/xmlschema_spec.rb b/spec/ruby/library/datetime/xmlschema_spec.rb
index 42832631ed..5f33d33436 100644
--- a/spec/ruby/library/datetime/xmlschema_spec.rb
+++ b/spec/ruby/library/datetime/xmlschema_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime.xmlschema" do
diff --git a/spec/ruby/library/datetime/zone_spec.rb b/spec/ruby/library/datetime/zone_spec.rb
index b2c10b4b3b..fa8c9a982d 100644
--- a/spec/ruby/library/datetime/zone_spec.rb
+++ b/spec/ruby/library/datetime/zone_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "DateTime#zone" do
diff --git a/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb b/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb
index 16bf8d734c..61680b9d5a 100644
--- a/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb
+++ b/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "DelegateClass.instance_method" do
before :all do
@@ -20,7 +20,7 @@ describe "DelegateClass.instance_method" do
end
it "raises a NameError for a private instance methods of the delegated class" do
- -> {
+ lambda {
@klass.instance_method(:priv)
}.should raise_error(NameError)
end
@@ -44,7 +44,7 @@ describe "DelegateClass.instance_method" do
end
it "raises a NameError for an invalid method name" do
- -> {
+ lambda {
@klass.instance_method(:invalid_and_silly_method_name)
}.should raise_error(NameError)
end
diff --git a/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb
index 6012ff72de..ae329ab8eb 100644
--- a/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb
+++ b/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "DelegateClass.instance_methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb
index 06b2115cc5..d93b6d0e3d 100644
--- a/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb
+++ b/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "DelegateClass.private_instance_methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb
index ac6659ec1e..3ae0270dbd 100644
--- a/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb
+++ b/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "DelegateClass.protected_instance_methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb
index 6c0d9bcab1..e06b55612e 100644
--- a/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb
+++ b/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "DelegateClass.public_instance_methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegator/case_compare_spec.rb b/spec/ruby/library/delegate/delegator/case_compare_spec.rb
index b62397cecf..8bf79c1425 100644
--- a/spec/ruby/library/delegate/delegator/case_compare_spec.rb
+++ b/spec/ruby/library/delegate/delegator/case_compare_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#===" do
it "is delegated" do
diff --git a/spec/ruby/library/delegate/delegator/compare_spec.rb b/spec/ruby/library/delegate/delegator/compare_spec.rb
index 7dee5c2fb5..93431bfeb2 100644
--- a/spec/ruby/library/delegate/delegator/compare_spec.rb
+++ b/spec/ruby/library/delegate/delegator/compare_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#<=>" do
it "is delegated" do
diff --git a/spec/ruby/library/delegate/delegator/complement_spec.rb b/spec/ruby/library/delegate/delegator/complement_spec.rb
index 10cb37c7ea..877a6e99c6 100644
--- a/spec/ruby/library/delegate/delegator/complement_spec.rb
+++ b/spec/ruby/library/delegate/delegator/complement_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#~" do
it "is delegated" do
diff --git a/spec/ruby/library/delegate/delegator/eql_spec.rb b/spec/ruby/library/delegate/delegator/eql_spec.rb
index 3170d5727a..fd6824ec55 100644
--- a/spec/ruby/library/delegate/delegator/eql_spec.rb
+++ b/spec/ruby/library/delegate/delegator/eql_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#eql?" do
ruby_version_is ""..."2.5" do
diff --git a/spec/ruby/library/delegate/delegator/equal_spec.rb b/spec/ruby/library/delegate/delegator/equal_spec.rb
index c8711c74b5..9333d6a303 100644
--- a/spec/ruby/library/delegate/delegator/equal_spec.rb
+++ b/spec/ruby/library/delegate/delegator/equal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#equal?" do
it "returns true only when compared with the delegator" do
diff --git a/spec/ruby/library/delegate/delegator/equal_value_spec.rb b/spec/ruby/library/delegate/delegator/equal_value_spec.rb
index 0c967d5f94..7c965d77d3 100644
--- a/spec/ruby/library/delegate/delegator/equal_value_spec.rb
+++ b/spec/ruby/library/delegate/delegator/equal_value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#==" do
before :all do
diff --git a/spec/ruby/library/delegate/delegator/frozen_spec.rb b/spec/ruby/library/delegate/delegator/frozen_spec.rb
index b3145c54b1..1fb561a349 100644
--- a/spec/ruby/library/delegate/delegator/frozen_spec.rb
+++ b/spec/ruby/library/delegate/delegator/frozen_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator when frozen" do
before :all do
@@ -17,8 +17,8 @@ describe "Delegator when frozen" do
@delegate.frozen?.should be_true
end
- it "is not writable" do
- ->{ @delegate[0] += 2 }.should raise_error( RuntimeError )
+ it "is not writeable" do
+ lambda{ @delegate[0] += 2 }.should raise_error( RuntimeError )
end
it "creates a frozen clone" do
@@ -30,7 +30,7 @@ describe "Delegator when frozen" do
end
it "causes mutative calls to raise RuntimeError" do
- ->{ @delegate.__setobj__("hola!") }.should raise_error( RuntimeError )
+ lambda{ @delegate.__setobj__("hola!") }.should raise_error( RuntimeError )
end
it "returns false if only the delegated object is frozen" do
diff --git a/spec/ruby/library/delegate/delegator/hash_spec.rb b/spec/ruby/library/delegate/delegator/hash_spec.rb
index 132cb91ccc..3719d1b249 100644
--- a/spec/ruby/library/delegate/delegator/hash_spec.rb
+++ b/spec/ruby/library/delegate/delegator/hash_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#hash" do
it "is delegated" do
diff --git a/spec/ruby/library/delegate/delegator/marshal_spec.rb b/spec/ruby/library/delegate/delegator/marshal_spec.rb
index 6c75c8f573..5af32b5754 100644
--- a/spec/ruby/library/delegate/delegator/marshal_spec.rb
+++ b/spec/ruby/library/delegate/delegator/marshal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'delegate'
describe "SimpleDelegator" do
diff --git a/spec/ruby/library/delegate/delegator/method_spec.rb b/spec/ruby/library/delegate/delegator/method_spec.rb
index 81c8eea710..1760eda645 100644
--- a/spec/ruby/library/delegate/delegator/method_spec.rb
+++ b/spec/ruby/library/delegate/delegator/method_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#method" do
before :each do
@@ -14,7 +14,7 @@ describe "Delegator#method" do
end
it "raises a NameError for protected methods of the delegate object" do
- -> {
+ lambda {
-> {
@delegate.method(:prot)
}.should complain(/delegator does not forward private method #prot/)
@@ -22,7 +22,7 @@ describe "Delegator#method" do
end
it "raises a NameError for a private methods of the delegate object" do
- -> {
+ lambda {
-> {
@delegate.method(:priv)
}.should complain(/delegator does not forward private method #priv/)
@@ -48,7 +48,7 @@ describe "Delegator#method" do
end
it "raises a NameError for an invalid method name" do
- -> {
+ lambda {
@delegate.method(:invalid_and_silly_method_name)
}.should raise_error(NameError)
end
@@ -62,7 +62,7 @@ describe "Delegator#method" do
it "raises a NameError if method is no longer valid because object has changed" do
m = @delegate.method(:pub)
@delegate.__setobj__([1,2,3])
- -> {
+ lambda {
m.call
}.should raise_error(NameError)
end
diff --git a/spec/ruby/library/delegate/delegator/methods_spec.rb b/spec/ruby/library/delegate/delegator/methods_spec.rb
index b9942bd230..91a6d68bfa 100644
--- a/spec/ruby/library/delegate/delegator/methods_spec.rb
+++ b/spec/ruby/library/delegate/delegator/methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegator/not_equal_spec.rb b/spec/ruby/library/delegate/delegator/not_equal_spec.rb
index 6f2df21715..c2f91dcfa1 100644
--- a/spec/ruby/library/delegate/delegator/not_equal_spec.rb
+++ b/spec/ruby/library/delegate/delegator/not_equal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#!=" do
before :all do
diff --git a/spec/ruby/library/delegate/delegator/not_spec.rb b/spec/ruby/library/delegate/delegator/not_spec.rb
index 50105181c3..678e07e418 100644
--- a/spec/ruby/library/delegate/delegator/not_spec.rb
+++ b/spec/ruby/library/delegate/delegator/not_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#!" do
it "is delegated" do
diff --git a/spec/ruby/library/delegate/delegator/private_methods_spec.rb b/spec/ruby/library/delegate/delegator/private_methods_spec.rb
index 7724b8d413..557da9bd02 100644
--- a/spec/ruby/library/delegate/delegator/private_methods_spec.rb
+++ b/spec/ruby/library/delegate/delegator/private_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#private_methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegator/protected_methods_spec.rb b/spec/ruby/library/delegate/delegator/protected_methods_spec.rb
index fd7874fb21..5f03575f25 100644
--- a/spec/ruby/library/delegate/delegator/protected_methods_spec.rb
+++ b/spec/ruby/library/delegate/delegator/protected_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#protected_methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegator/public_methods_spec.rb b/spec/ruby/library/delegate/delegator/public_methods_spec.rb
index 18da16a613..4ed626be33 100644
--- a/spec/ruby/library/delegate/delegator/public_methods_spec.rb
+++ b/spec/ruby/library/delegate/delegator/public_methods_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#public_methods" do
before :all do
diff --git a/spec/ruby/library/delegate/delegator/send_spec.rb b/spec/ruby/library/delegate/delegator/send_spec.rb
index 3022c2ce91..b6e66cb74a 100644
--- a/spec/ruby/library/delegate/delegator/send_spec.rb
+++ b/spec/ruby/library/delegate/delegator/send_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "SimpleDelegator.new" do
before :all do
@@ -12,15 +12,15 @@ describe "SimpleDelegator.new" do
end
it "forwards protected method calls" do
- ->{ @delegate.prot }.should raise_error( NoMethodError )
+ lambda{ @delegate.prot }.should raise_error( NoMethodError )
end
it "doesn't forward private method calls" do
- ->{ @delegate.priv }.should raise_error( NoMethodError )
+ lambda{ @delegate.priv }.should raise_error( NoMethodError )
end
it "doesn't forward private method calls even via send or __send__" do
- ->{ @delegate.send(:priv, 42) }.should raise_error( NoMethodError )
- ->{ @delegate.__send__(:priv, 42) }.should raise_error( NoMethodError )
+ lambda{ @delegate.send(:priv, 42) }.should raise_error( NoMethodError )
+ lambda{ @delegate.__send__(:priv, 42) }.should raise_error( NoMethodError )
end
end
diff --git a/spec/ruby/library/delegate/delegator/taint_spec.rb b/spec/ruby/library/delegate/delegator/taint_spec.rb
index b875b5a6b8..f78446d018 100644
--- a/spec/ruby/library/delegate/delegator/taint_spec.rb
+++ b/spec/ruby/library/delegate/delegator/taint_spec.rb
@@ -1,25 +1,23 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#taint" do
before :each do
@delegate = DelegateSpecs::Delegator.new("")
end
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.taint.equal?(@delegate).should be_true
- end
+ it "returns self" do
+ @delegate.taint.equal?(@delegate).should be_true
+ end
- it "taints the delegator" do
- @delegate.__setobj__(nil)
- @delegate.taint
- @delegate.tainted?.should be_true
- end
+ it "taints the delegator" do
+ @delegate.__setobj__(nil)
+ @delegate.taint
+ @delegate.tainted?.should be_true
+ end
- it "taints the delegated object" do
- @delegate.taint
- @delegate.__getobj__.tainted?.should be_true
- end
+ it "taints the delegated object" do
+ @delegate.taint
+ @delegate.__getobj__.tainted?.should be_true
end
end
diff --git a/spec/ruby/library/delegate/delegator/tap_spec.rb b/spec/ruby/library/delegate/delegator/tap_spec.rb
index 34a88fa1d5..1da6d82b01 100644
--- a/spec/ruby/library/delegate/delegator/tap_spec.rb
+++ b/spec/ruby/library/delegate/delegator/tap_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#tap" do
it "yield the delegator object" do
diff --git a/spec/ruby/library/delegate/delegator/trust_spec.rb b/spec/ruby/library/delegate/delegator/trust_spec.rb
index 492f02e27f..182395c26e 100644
--- a/spec/ruby/library/delegate/delegator/trust_spec.rb
+++ b/spec/ruby/library/delegate/delegator/trust_spec.rb
@@ -1,24 +1,22 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#trust" do
before :each do
@delegate = DelegateSpecs::Delegator.new([])
end
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.trust.equal?(@delegate).should be_true
- end
+ it "returns self" do
+ @delegate.trust.equal?(@delegate).should be_true
+ end
- it "trusts the delegator" do
- @delegate.trust
- @delegate.untrusted?.should be_false
- end
+ it "trusts the delegator" do
+ @delegate.trust
+ @delegate.untrusted?.should be_false
+ end
- it "trusts the delegated object" do
- @delegate.trust
- @delegate.__getobj__.untrusted?.should be_false
- end
+ it "trusts the delegated object" do
+ @delegate.trust
+ @delegate.__getobj__.untrusted?.should be_false
end
end
diff --git a/spec/ruby/library/delegate/delegator/untaint_spec.rb b/spec/ruby/library/delegate/delegator/untaint_spec.rb
index 3f8f7721a9..2cce99e206 100644
--- a/spec/ruby/library/delegate/delegator/untaint_spec.rb
+++ b/spec/ruby/library/delegate/delegator/untaint_spec.rb
@@ -1,26 +1,24 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#untaint" do
before :each do
- @delegate = -> { DelegateSpecs::Delegator.new("") }.call
+ @delegate = lambda { DelegateSpecs::Delegator.new("") }.call
end
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.untaint.equal?(@delegate).should be_true
- end
+ it "returns self" do
+ @delegate.untaint.equal?(@delegate).should be_true
+ end
- it "untaints the delegator" do
- @delegate.untaint
- @delegate.tainted?.should be_false
- # No additional meaningful test; that it does or not taint
- # "for real" the delegator has no consequence
- end
+ it "untaints the delegator" do
+ @delegate.untaint
+ @delegate.tainted?.should be_false
+ # No additional meaningful test; that it does or not taint
+ # "for real" the delegator has no consequence
+ end
- it "untaints the delegated object" do
- @delegate.untaint
- @delegate.__getobj__.tainted?.should be_false
- end
+ it "untaints the delegated object" do
+ @delegate.untaint
+ @delegate.__getobj__.tainted?.should be_false
end
end
diff --git a/spec/ruby/library/delegate/delegator/untrust_spec.rb b/spec/ruby/library/delegate/delegator/untrust_spec.rb
index acc91b099a..e2bbf1b294 100644
--- a/spec/ruby/library/delegate/delegator/untrust_spec.rb
+++ b/spec/ruby/library/delegate/delegator/untrust_spec.rb
@@ -1,25 +1,23 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Delegator#untrust" do
before :each do
@delegate = DelegateSpecs::Delegator.new("")
end
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.untrust.equal?(@delegate).should be_true
- end
+ it "returns self" do
+ @delegate.untrust.equal?(@delegate).should be_true
+ end
- it "untrusts the delegator" do
- @delegate.__setobj__(nil)
- @delegate.untrust
- @delegate.untrusted?.should be_true
- end
+ it "untrusts the delegator" do
+ @delegate.__setobj__(nil)
+ @delegate.untrust
+ @delegate.untrusted?.should be_true
+ end
- it "untrusts the delegated object" do
- @delegate.untrust
- @delegate.__getobj__.untrusted?.should be_true
- end
+ it "untrusts the delegated object" do
+ @delegate.untrust
+ @delegate.__getobj__.untrusted?.should be_true
end
end
diff --git a/spec/ruby/library/digest/bubblebabble_spec.rb b/spec/ruby/library/digest/bubblebabble_spec.rb
index e651671108..49cc77e623 100644
--- a/spec/ruby/library/digest/bubblebabble_spec.rb
+++ b/spec/ruby/library/digest/bubblebabble_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'digest/bubblebabble'
describe "Digest.bubblebabble" do
@@ -6,7 +6,7 @@ describe "Digest.bubblebabble" do
Digest.bubblebabble('').should be_an_instance_of(String)
end
- it "returns a String in the Bubble Babble Binary Data Encoding format" do
+ it "returns a String in the The Bubble Babble Binary Data Encoding format" do
Digest.bubblebabble('').should == 'xexax'
Digest.bubblebabble('foo').should == 'xinik-zorox'
Digest.bubblebabble('bar').should == 'ximik-cosex'
@@ -20,10 +20,10 @@ describe "Digest.bubblebabble" do
end
it "raises a TypeError when passed nil" do
- -> { Digest.bubblebabble(nil) }.should raise_error(TypeError)
+ lambda { Digest.bubblebabble(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a Fixnum" do
- -> { Digest.bubblebabble(9001) }.should raise_error(TypeError)
+ lambda { Digest.bubblebabble(9001) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/digest/hexencode_spec.rb b/spec/ruby/library/digest/hexencode_spec.rb
index fcbbf4846a..9e59e69fce 100644
--- a/spec/ruby/library/digest/hexencode_spec.rb
+++ b/spec/ruby/library/digest/hexencode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'digest'
describe "Digest.hexencode" do
@@ -22,10 +22,10 @@ describe "Digest.hexencode" do
end
it "raises a TypeError when passed nil" do
- -> { Digest.hexencode(nil) }.should raise_error(TypeError)
+ lambda { Digest.hexencode(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a Fixnum" do
- -> { Digest.hexencode(9001) }.should raise_error(TypeError)
+ lambda { Digest.hexencode(9001) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/digest/md5/append_spec.rb b/spec/ruby/library/digest/md5/append_spec.rb
index a7f841c883..ad828c83c1 100644
--- a/spec/ruby/library/digest/md5/append_spec.rb
+++ b/spec/ruby/library/digest/md5/append_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::MD5#<<" do
- it_behaves_like :md5_update, :<<
+ it_behaves_like(:md5_update, :<<)
end
diff --git a/spec/ruby/library/digest/md5/block_length_spec.rb b/spec/ruby/library/digest/md5/block_length_spec.rb
index 14fb050abd..acc3108da4 100644
--- a/spec/ruby/library/digest/md5/block_length_spec.rb
+++ b/spec/ruby/library/digest/md5/block_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#block_length" do
@@ -9,3 +9,4 @@ describe "Digest::MD5#block_length" do
end
end
+
diff --git a/spec/ruby/library/digest/md5/digest_bang_spec.rb b/spec/ruby/library/digest/md5/digest_bang_spec.rb
index 7b884a16d9..88b865dcba 100644
--- a/spec/ruby/library/digest/md5/digest_bang_spec.rb
+++ b/spec/ruby/library/digest/md5/digest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#digest!" do
diff --git a/spec/ruby/library/digest/md5/digest_length_spec.rb b/spec/ruby/library/digest/md5/digest_length_spec.rb
index 47e071e329..426e42af76 100644
--- a/spec/ruby/library/digest/md5/digest_length_spec.rb
+++ b/spec/ruby/library/digest/md5/digest_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#digest_length" do
@@ -9,3 +9,4 @@ describe "Digest::MD5#digest_length" do
end
end
+
diff --git a/spec/ruby/library/digest/md5/digest_spec.rb b/spec/ruby/library/digest/md5/digest_spec.rb
index d9bbc45ee2..1568c630aa 100644
--- a/spec/ruby/library/digest/md5/digest_spec.rb
+++ b/spec/ruby/library/digest/md5/digest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#digest" do
diff --git a/spec/ruby/library/digest/md5/equal_spec.rb b/spec/ruby/library/digest/md5/equal_spec.rb
index b0e36564cd..0b776f53c0 100644
--- a/spec/ruby/library/digest/md5/equal_spec.rb
+++ b/spec/ruby/library/digest/md5/equal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#==" do
@@ -35,3 +35,4 @@ describe "Digest::MD5#==" do
end
end
+
diff --git a/spec/ruby/library/digest/md5/file_spec.rb b/spec/ruby/library/digest/md5/file_spec.rb
index 0c8d12cbc9..c7f4328546 100644
--- a/spec/ruby/library/digest/md5/file_spec.rb
+++ b/spec/ruby/library/digest/md5/file_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative '../../../core/file/shared/read'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../../../../core/file/shared/read', __FILE__)
describe "Digest::MD5.file" do
@@ -34,10 +34,10 @@ describe "Digest::MD5.file" do
it_behaves_like :file_read_directory, :file, Digest::MD5
it "raises a Errno::ENOENT when passed a path that does not exist" do
- -> { Digest::MD5.file("") }.should raise_error(Errno::ENOENT)
+ lambda { Digest::MD5.file("") }.should raise_error(Errno::ENOENT)
end
it "raises a TypeError when passed nil" do
- -> { Digest::MD5.file(nil) }.should raise_error(TypeError)
+ lambda { Digest::MD5.file(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/digest/md5/hexdigest_bang_spec.rb b/spec/ruby/library/digest/md5/hexdigest_bang_spec.rb
index a953eb3b4c..fe67136c97 100644
--- a/spec/ruby/library/digest/md5/hexdigest_bang_spec.rb
+++ b/spec/ruby/library/digest/md5/hexdigest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#hexdigest!" do
diff --git a/spec/ruby/library/digest/md5/hexdigest_spec.rb b/spec/ruby/library/digest/md5/hexdigest_spec.rb
index 03ead68b82..9caec29f38 100644
--- a/spec/ruby/library/digest/md5/hexdigest_spec.rb
+++ b/spec/ruby/library/digest/md5/hexdigest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#hexdigest" do
diff --git a/spec/ruby/library/digest/md5/inspect_spec.rb b/spec/ruby/library/digest/md5/inspect_spec.rb
index decc86fba5..e23465337a 100644
--- a/spec/ruby/library/digest/md5/inspect_spec.rb
+++ b/spec/ruby/library/digest/md5/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#inspect" do
@@ -9,3 +9,4 @@ describe "Digest::MD5#inspect" do
end
end
+
diff --git a/spec/ruby/library/digest/md5/length_spec.rb b/spec/ruby/library/digest/md5/length_spec.rb
index b05b2a20fd..13eaf2e8d5 100644
--- a/spec/ruby/library/digest/md5/length_spec.rb
+++ b/spec/ruby/library/digest/md5/length_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::MD5#length" do
it_behaves_like :md5_length, :length
end
+
diff --git a/spec/ruby/library/digest/md5/reset_spec.rb b/spec/ruby/library/digest/md5/reset_spec.rb
index c937844f38..d95ecfaf8c 100644
--- a/spec/ruby/library/digest/md5/reset_spec.rb
+++ b/spec/ruby/library/digest/md5/reset_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#reset" do
@@ -12,3 +12,4 @@ describe "Digest::MD5#reset" do
end
end
+
diff --git a/spec/ruby/library/digest/md5/size_spec.rb b/spec/ruby/library/digest/md5/size_spec.rb
index 22e3272d36..311286e679 100644
--- a/spec/ruby/library/digest/md5/size_spec.rb
+++ b/spec/ruby/library/digest/md5/size_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::MD5#size" do
it_behaves_like :md5_length, :size
end
+
diff --git a/spec/ruby/library/digest/md5/to_s_spec.rb b/spec/ruby/library/digest/md5/to_s_spec.rb
index 78d53d6967..59c17ec821 100644
--- a/spec/ruby/library/digest/md5/to_s_spec.rb
+++ b/spec/ruby/library/digest/md5/to_s_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'digest/md5'
-require_relative 'shared/constants'
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::MD5#to_s" do
diff --git a/spec/ruby/library/digest/md5/update_spec.rb b/spec/ruby/library/digest/md5/update_spec.rb
index 4773db308c..5a271481f7 100644
--- a/spec/ruby/library/digest/md5/update_spec.rb
+++ b/spec/ruby/library/digest/md5/update_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::MD5#update" do
it_behaves_like :md5_update, :update
diff --git a/spec/ruby/library/digest/sha1/digest_spec.rb b/spec/ruby/library/digest/sha1/digest_spec.rb
index 03f805336f..abb4034a69 100644
--- a/spec/ruby/library/digest/sha1/digest_spec.rb
+++ b/spec/ruby/library/digest/sha1/digest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA1#digest" do
diff --git a/spec/ruby/library/digest/sha1/file_spec.rb b/spec/ruby/library/digest/sha1/file_spec.rb
index 9c15f5b02f..2c9fd2cb52 100644
--- a/spec/ruby/library/digest/sha1/file_spec.rb
+++ b/spec/ruby/library/digest/sha1/file_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative '../../../core/file/shared/read'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../../../../core/file/shared/read', __FILE__)
describe "Digest::SHA1.file" do
@@ -34,10 +34,10 @@ describe "Digest::SHA1.file" do
it_behaves_like :file_read_directory, :file, Digest::SHA1
it "raises a Errno::ENOENT when passed a path that does not exist" do
- -> { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT)
+ lambda { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT)
end
it "raises a TypeError when passed nil" do
- -> { Digest::SHA1.file(nil) }.should raise_error(TypeError)
+ lambda { Digest::SHA1.file(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/digest/sha256/append_spec.rb b/spec/ruby/library/digest/sha256/append_spec.rb
index 9ca3496afc..53e623743a 100644
--- a/spec/ruby/library/digest/sha256/append_spec.rb
+++ b/spec/ruby/library/digest/sha256/append_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::SHA256#<<" do
- it_behaves_like :sha256_update, :<<
+ it_behaves_like(:sha256_update, :<<)
end
diff --git a/spec/ruby/library/digest/sha256/block_length_spec.rb b/spec/ruby/library/digest/sha256/block_length_spec.rb
index 1e29e832cf..4fea959da1 100644
--- a/spec/ruby/library/digest/sha256/block_length_spec.rb
+++ b/spec/ruby/library/digest/sha256/block_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#block_length" do
@@ -9,3 +9,4 @@ describe "Digest::SHA256#block_length" do
end
end
+
diff --git a/spec/ruby/library/digest/sha256/digest_bang_spec.rb b/spec/ruby/library/digest/sha256/digest_bang_spec.rb
index 690442221a..b876c2ceed 100644
--- a/spec/ruby/library/digest/sha256/digest_bang_spec.rb
+++ b/spec/ruby/library/digest/sha256/digest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#digest!" do
diff --git a/spec/ruby/library/digest/sha256/digest_length_spec.rb b/spec/ruby/library/digest/sha256/digest_length_spec.rb
index b5c8958e84..f3d0d66877 100644
--- a/spec/ruby/library/digest/sha256/digest_length_spec.rb
+++ b/spec/ruby/library/digest/sha256/digest_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#digest_length" do
@@ -9,3 +9,4 @@ describe "Digest::SHA256#digest_length" do
end
end
+
diff --git a/spec/ruby/library/digest/sha256/digest_spec.rb b/spec/ruby/library/digest/sha256/digest_spec.rb
index 1e79f25627..de30916d57 100644
--- a/spec/ruby/library/digest/sha256/digest_spec.rb
+++ b/spec/ruby/library/digest/sha256/digest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#digest" do
diff --git a/spec/ruby/library/digest/sha256/equal_spec.rb b/spec/ruby/library/digest/sha256/equal_spec.rb
index 84662aa068..7932b6c13d 100644
--- a/spec/ruby/library/digest/sha256/equal_spec.rb
+++ b/spec/ruby/library/digest/sha256/equal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#==" do
@@ -34,3 +34,4 @@ describe "Digest::SHA256#==" do
end
end
+
diff --git a/spec/ruby/library/digest/sha256/file_spec.rb b/spec/ruby/library/digest/sha256/file_spec.rb
index 6103971b5a..a52b7939f3 100644
--- a/spec/ruby/library/digest/sha256/file_spec.rb
+++ b/spec/ruby/library/digest/sha256/file_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative '../../../core/file/shared/read'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../../../../core/file/shared/read', __FILE__)
describe "Digest::SHA256.file" do
@@ -34,10 +34,10 @@ describe "Digest::SHA256.file" do
it_behaves_like :file_read_directory, :file, Digest::SHA256
it "raises a Errno::ENOENT when passed a path that does not exist" do
- -> { Digest::SHA256.file("") }.should raise_error(Errno::ENOENT)
+ lambda { Digest::SHA256.file("") }.should raise_error(Errno::ENOENT)
end
it "raises a TypeError when passed nil" do
- -> { Digest::SHA256.file(nil) }.should raise_error(TypeError)
+ lambda { Digest::SHA256.file(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb b/spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb
index 1acd8043b3..98bf38f773 100644
--- a/spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb
+++ b/spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#hexdigest!" do
diff --git a/spec/ruby/library/digest/sha256/hexdigest_spec.rb b/spec/ruby/library/digest/sha256/hexdigest_spec.rb
index 4f748b33b4..3ee7844a93 100644
--- a/spec/ruby/library/digest/sha256/hexdigest_spec.rb
+++ b/spec/ruby/library/digest/sha256/hexdigest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#hexdigest" do
diff --git a/spec/ruby/library/digest/sha256/inspect_spec.rb b/spec/ruby/library/digest/sha256/inspect_spec.rb
index ed606e4517..5e44b58c63 100644
--- a/spec/ruby/library/digest/sha256/inspect_spec.rb
+++ b/spec/ruby/library/digest/sha256/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#inspect" do
@@ -9,3 +9,4 @@ describe "Digest::SHA256#inspect" do
end
end
+
diff --git a/spec/ruby/library/digest/sha256/length_spec.rb b/spec/ruby/library/digest/sha256/length_spec.rb
index 181ac564ad..6760511093 100644
--- a/spec/ruby/library/digest/sha256/length_spec.rb
+++ b/spec/ruby/library/digest/sha256/length_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::SHA256#length" do
it_behaves_like :sha256_length, :length
end
+
diff --git a/spec/ruby/library/digest/sha256/reset_spec.rb b/spec/ruby/library/digest/sha256/reset_spec.rb
index f0eb4faea6..82bb08d354 100644
--- a/spec/ruby/library/digest/sha256/reset_spec.rb
+++ b/spec/ruby/library/digest/sha256/reset_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#reset" do
@@ -12,3 +12,4 @@ describe "Digest::SHA256#reset" do
end
end
+
diff --git a/spec/ruby/library/digest/sha256/size_spec.rb b/spec/ruby/library/digest/sha256/size_spec.rb
index 1028263342..77db876956 100644
--- a/spec/ruby/library/digest/sha256/size_spec.rb
+++ b/spec/ruby/library/digest/sha256/size_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::SHA256#size" do
it_behaves_like :sha256_length, :size
end
+
diff --git a/spec/ruby/library/digest/sha256/to_s_spec.rb b/spec/ruby/library/digest/sha256/to_s_spec.rb
index 8bedee3f98..b91983d157 100644
--- a/spec/ruby/library/digest/sha256/to_s_spec.rb
+++ b/spec/ruby/library/digest/sha256/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA256#to_s" do
diff --git a/spec/ruby/library/digest/sha256/update_spec.rb b/spec/ruby/library/digest/sha256/update_spec.rb
index 92316eb752..3e3eaf57a3 100644
--- a/spec/ruby/library/digest/sha256/update_spec.rb
+++ b/spec/ruby/library/digest/sha256/update_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::SHA256#update" do
it_behaves_like :sha256_update, :update
diff --git a/spec/ruby/library/digest/sha384/append_spec.rb b/spec/ruby/library/digest/sha384/append_spec.rb
index 2bc0c5b90b..d694812e85 100644
--- a/spec/ruby/library/digest/sha384/append_spec.rb
+++ b/spec/ruby/library/digest/sha384/append_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::SHA384#<<" do
- it_behaves_like :sha384_update, :<<
+ it_behaves_like(:sha384_update, :<<)
end
diff --git a/spec/ruby/library/digest/sha384/block_length_spec.rb b/spec/ruby/library/digest/sha384/block_length_spec.rb
index dff645ffb9..070715b27e 100644
--- a/spec/ruby/library/digest/sha384/block_length_spec.rb
+++ b/spec/ruby/library/digest/sha384/block_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#block_length" do
@@ -9,3 +9,4 @@ describe "Digest::SHA384#block_length" do
end
end
+
diff --git a/spec/ruby/library/digest/sha384/digest_bang_spec.rb b/spec/ruby/library/digest/sha384/digest_bang_spec.rb
index 8711913deb..83b68ae7c2 100644
--- a/spec/ruby/library/digest/sha384/digest_bang_spec.rb
+++ b/spec/ruby/library/digest/sha384/digest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#digest!" do
diff --git a/spec/ruby/library/digest/sha384/digest_length_spec.rb b/spec/ruby/library/digest/sha384/digest_length_spec.rb
index 4067dd34af..a57616b44c 100644
--- a/spec/ruby/library/digest/sha384/digest_length_spec.rb
+++ b/spec/ruby/library/digest/sha384/digest_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#digest_length" do
@@ -9,3 +9,4 @@ describe "Digest::SHA384#digest_length" do
end
end
+
diff --git a/spec/ruby/library/digest/sha384/digest_spec.rb b/spec/ruby/library/digest/sha384/digest_spec.rb
index d0e2825934..3a5cd3a5d7 100644
--- a/spec/ruby/library/digest/sha384/digest_spec.rb
+++ b/spec/ruby/library/digest/sha384/digest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#digest" do
diff --git a/spec/ruby/library/digest/sha384/equal_spec.rb b/spec/ruby/library/digest/sha384/equal_spec.rb
index 5d3483d79a..a54d328edc 100644
--- a/spec/ruby/library/digest/sha384/equal_spec.rb
+++ b/spec/ruby/library/digest/sha384/equal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#==" do
@@ -34,3 +34,4 @@ describe "Digest::SHA384#==" do
end
end
+
diff --git a/spec/ruby/library/digest/sha384/file_spec.rb b/spec/ruby/library/digest/sha384/file_spec.rb
index 8556f10175..7e7c8f9565 100644
--- a/spec/ruby/library/digest/sha384/file_spec.rb
+++ b/spec/ruby/library/digest/sha384/file_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative '../../../core/file/shared/read'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../../../../core/file/shared/read', __FILE__)
describe "Digest::SHA384.file" do
@@ -34,10 +34,10 @@ describe "Digest::SHA384.file" do
it_behaves_like :file_read_directory, :file, Digest::SHA384
it "raises a Errno::ENOENT when passed a path that does not exist" do
- -> { Digest::SHA384.file("") }.should raise_error(Errno::ENOENT)
+ lambda { Digest::SHA384.file("") }.should raise_error(Errno::ENOENT)
end
it "raises a TypeError when passed nil" do
- -> { Digest::SHA384.file(nil) }.should raise_error(TypeError)
+ lambda { Digest::SHA384.file(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb b/spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb
index 8efceec3eb..68da8c7200 100644
--- a/spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb
+++ b/spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#hexdigest!" do
diff --git a/spec/ruby/library/digest/sha384/hexdigest_spec.rb b/spec/ruby/library/digest/sha384/hexdigest_spec.rb
index 07ea05c541..a7724d1663 100644
--- a/spec/ruby/library/digest/sha384/hexdigest_spec.rb
+++ b/spec/ruby/library/digest/sha384/hexdigest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#hexdigest" do
diff --git a/spec/ruby/library/digest/sha384/inspect_spec.rb b/spec/ruby/library/digest/sha384/inspect_spec.rb
index 8f9f946cc5..554a22d135 100644
--- a/spec/ruby/library/digest/sha384/inspect_spec.rb
+++ b/spec/ruby/library/digest/sha384/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#inspect" do
@@ -9,3 +9,4 @@ describe "Digest::SHA384#inspect" do
end
end
+
diff --git a/spec/ruby/library/digest/sha384/length_spec.rb b/spec/ruby/library/digest/sha384/length_spec.rb
index 33fed492ef..63a57ce9ca 100644
--- a/spec/ruby/library/digest/sha384/length_spec.rb
+++ b/spec/ruby/library/digest/sha384/length_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::SHA384#length" do
it_behaves_like :sha384_length, :length
end
+
diff --git a/spec/ruby/library/digest/sha384/reset_spec.rb b/spec/ruby/library/digest/sha384/reset_spec.rb
index 991b90903d..8abe39d7e2 100644
--- a/spec/ruby/library/digest/sha384/reset_spec.rb
+++ b/spec/ruby/library/digest/sha384/reset_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#reset" do
@@ -12,3 +12,4 @@ describe "Digest::SHA384#reset" do
end
end
+
diff --git a/spec/ruby/library/digest/sha384/size_spec.rb b/spec/ruby/library/digest/sha384/size_spec.rb
index 4c3b14f7a0..9aea3ef592 100644
--- a/spec/ruby/library/digest/sha384/size_spec.rb
+++ b/spec/ruby/library/digest/sha384/size_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::SHA384#size" do
it_behaves_like :sha384_length, :size
end
+
diff --git a/spec/ruby/library/digest/sha384/to_s_spec.rb b/spec/ruby/library/digest/sha384/to_s_spec.rb
index 68ea9c013f..f45f2ee915 100644
--- a/spec/ruby/library/digest/sha384/to_s_spec.rb
+++ b/spec/ruby/library/digest/sha384/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA384#to_s" do
diff --git a/spec/ruby/library/digest/sha384/update_spec.rb b/spec/ruby/library/digest/sha384/update_spec.rb
index a1d0dd6068..9917f86b86 100644
--- a/spec/ruby/library/digest/sha384/update_spec.rb
+++ b/spec/ruby/library/digest/sha384/update_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::SHA384#update" do
it_behaves_like :sha384_update, :update
diff --git a/spec/ruby/library/digest/sha512/append_spec.rb b/spec/ruby/library/digest/sha512/append_spec.rb
index e5f84b56f4..642e565bf6 100644
--- a/spec/ruby/library/digest/sha512/append_spec.rb
+++ b/spec/ruby/library/digest/sha512/append_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::SHA512#<<" do
- it_behaves_like :sha512_update, :<<
+ it_behaves_like(:sha512_update, :<<)
end
diff --git a/spec/ruby/library/digest/sha512/block_length_spec.rb b/spec/ruby/library/digest/sha512/block_length_spec.rb
index 947af841dd..95bb98548a 100644
--- a/spec/ruby/library/digest/sha512/block_length_spec.rb
+++ b/spec/ruby/library/digest/sha512/block_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#block_length" do
@@ -9,3 +9,4 @@ describe "Digest::SHA512#block_length" do
end
end
+
diff --git a/spec/ruby/library/digest/sha512/digest_bang_spec.rb b/spec/ruby/library/digest/sha512/digest_bang_spec.rb
index 981570b907..260595152d 100644
--- a/spec/ruby/library/digest/sha512/digest_bang_spec.rb
+++ b/spec/ruby/library/digest/sha512/digest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#digest!" do
diff --git a/spec/ruby/library/digest/sha512/digest_length_spec.rb b/spec/ruby/library/digest/sha512/digest_length_spec.rb
index ff5956dd75..5185b6e906 100644
--- a/spec/ruby/library/digest/sha512/digest_length_spec.rb
+++ b/spec/ruby/library/digest/sha512/digest_length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#digest_length" do
@@ -9,3 +9,4 @@ describe "Digest::SHA512#digest_length" do
end
end
+
diff --git a/spec/ruby/library/digest/sha512/digest_spec.rb b/spec/ruby/library/digest/sha512/digest_spec.rb
index 092efccc62..9f4264579f 100644
--- a/spec/ruby/library/digest/sha512/digest_spec.rb
+++ b/spec/ruby/library/digest/sha512/digest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#digest" do
diff --git a/spec/ruby/library/digest/sha512/equal_spec.rb b/spec/ruby/library/digest/sha512/equal_spec.rb
index 5100ced6e8..ec4c55f118 100644
--- a/spec/ruby/library/digest/sha512/equal_spec.rb
+++ b/spec/ruby/library/digest/sha512/equal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#==" do
@@ -34,3 +34,4 @@ describe "Digest::SHA512#==" do
end
end
+
diff --git a/spec/ruby/library/digest/sha512/file_spec.rb b/spec/ruby/library/digest/sha512/file_spec.rb
index 781ec781e5..365f3625b6 100644
--- a/spec/ruby/library/digest/sha512/file_spec.rb
+++ b/spec/ruby/library/digest/sha512/file_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative '../../../core/file/shared/read'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../../../../core/file/shared/read', __FILE__)
describe "Digest::SHA512.file" do
@@ -34,10 +34,10 @@ describe "Digest::SHA512.file" do
it_behaves_like :file_read_directory, :file, Digest::SHA512
it "raises a Errno::ENOENT when passed a path that does not exist" do
- -> { Digest::SHA512.file("") }.should raise_error(Errno::ENOENT)
+ lambda { Digest::SHA512.file("") }.should raise_error(Errno::ENOENT)
end
it "raises a TypeError when passed nil" do
- -> { Digest::SHA512.file(nil) }.should raise_error(TypeError)
+ lambda { Digest::SHA512.file(nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb b/spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb
index e9b0da6191..6eda150949 100644
--- a/spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb
+++ b/spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#hexdigest!" do
diff --git a/spec/ruby/library/digest/sha512/hexdigest_spec.rb b/spec/ruby/library/digest/sha512/hexdigest_spec.rb
index 6e1dc3c642..405d380490 100644
--- a/spec/ruby/library/digest/sha512/hexdigest_spec.rb
+++ b/spec/ruby/library/digest/sha512/hexdigest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#hexdigest" do
diff --git a/spec/ruby/library/digest/sha512/inspect_spec.rb b/spec/ruby/library/digest/sha512/inspect_spec.rb
index 54a466043a..97806000d2 100644
--- a/spec/ruby/library/digest/sha512/inspect_spec.rb
+++ b/spec/ruby/library/digest/sha512/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#inspect" do
@@ -9,3 +9,4 @@ describe "Digest::SHA512#inspect" do
end
end
+
diff --git a/spec/ruby/library/digest/sha512/length_spec.rb b/spec/ruby/library/digest/sha512/length_spec.rb
index e9fde90577..b0b4d7e56c 100644
--- a/spec/ruby/library/digest/sha512/length_spec.rb
+++ b/spec/ruby/library/digest/sha512/length_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::SHA512#length" do
it_behaves_like :sha512_length, :length
end
+
diff --git a/spec/ruby/library/digest/sha512/reset_spec.rb b/spec/ruby/library/digest/sha512/reset_spec.rb
index 24a936d4ba..b2f28dc670 100644
--- a/spec/ruby/library/digest/sha512/reset_spec.rb
+++ b/spec/ruby/library/digest/sha512/reset_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#reset" do
@@ -12,3 +12,4 @@ describe "Digest::SHA512#reset" do
end
end
+
diff --git a/spec/ruby/library/digest/sha512/size_spec.rb b/spec/ruby/library/digest/sha512/size_spec.rb
index 6d0acdabdb..a882fe55a1 100644
--- a/spec/ruby/library/digest/sha512/size_spec.rb
+++ b/spec/ruby/library/digest/sha512/size_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "Digest::SHA512#size" do
it_behaves_like :sha512_length, :size
end
+
diff --git a/spec/ruby/library/digest/sha512/to_s_spec.rb b/spec/ruby/library/digest/sha512/to_s_spec.rb
index 68d86241c9..b45f553e8c 100644
--- a/spec/ruby/library/digest/sha512/to_s_spec.rb
+++ b/spec/ruby/library/digest/sha512/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
describe "Digest::SHA512#to_s" do
diff --git a/spec/ruby/library/digest/sha512/update_spec.rb b/spec/ruby/library/digest/sha512/update_spec.rb
index 682d3a19bb..3b82f51853 100644
--- a/spec/ruby/library/digest/sha512/update_spec.rb
+++ b/spec/ruby/library/digest/sha512/update_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/constants'
-require_relative 'shared/update'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../shared/update', __FILE__)
describe "Digest::SHA512#update" do
it_behaves_like :sha512_update, :update
diff --git a/spec/ruby/library/drb/start_service_spec.rb b/spec/ruby/library/drb/start_service_spec.rb
index 016c8b2cff..f64021f0bd 100644
--- a/spec/ruby/library/drb/start_service_spec.rb
+++ b/spec/ruby/library/drb/start_service_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/test_server'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/test_server', __FILE__)
require 'drb'
describe "DRb.start_service" do
diff --git a/spec/ruby/library/erb/def_class_spec.rb b/spec/ruby/library/erb/def_class_spec.rb
index 88bd385f4c..ae2dcbd1e4 100644
--- a/spec/ruby/library/erb/def_class_spec.rb
+++ b/spec/ruby/library/erb/def_class_spec.rb
@@ -1,5 +1,5 @@
require 'erb'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB#def_class" do
diff --git a/spec/ruby/library/erb/def_method_spec.rb b/spec/ruby/library/erb/def_method_spec.rb
index 188789a693..e4ddedea4c 100644
--- a/spec/ruby/library/erb/def_method_spec.rb
+++ b/spec/ruby/library/erb/def_method_spec.rb
@@ -1,5 +1,5 @@
require 'erb'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB#def_method" do
diff --git a/spec/ruby/library/erb/def_module_spec.rb b/spec/ruby/library/erb/def_module_spec.rb
index 806e564ef0..ed52fdfc15 100644
--- a/spec/ruby/library/erb/def_module_spec.rb
+++ b/spec/ruby/library/erb/def_module_spec.rb
@@ -1,5 +1,5 @@
require 'erb'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB#def_module" do
diff --git a/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb b/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb
index dc1e044d9c..e1eca2fbef 100644
--- a/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb
+++ b/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb
@@ -1,6 +1,5 @@
require 'erb'
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "ERB::DefMethod.def_erb_method" do
@@ -51,7 +50,7 @@ END
MY_INPUT4_FOR_ERB = input
class MyClass4ForErb
extend ERB::DefMethod
- erb = ERBSpecs.new_erb(MY_INPUT4_FOR_ERB, trim_mode: '<>')
+ erb = ERB.new(MY_INPUT4_FOR_ERB, nil, '<>')
def_erb_method('render()', erb)
def initialize(items)
@items = items
diff --git a/spec/ruby/library/erb/filename_spec.rb b/spec/ruby/library/erb/filename_spec.rb
index 8ecaed7343..4615f5d808 100644
--- a/spec/ruby/library/erb/filename_spec.rb
+++ b/spec/ruby/library/erb/filename_spec.rb
@@ -1,12 +1,12 @@
require 'erb'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB#filename" do
it "raises an exception if there are errors processing content" do
filename = 'foobar.rhtml'
erb = ERB.new('<% if true %>') # will raise SyntaxError
erb.filename = filename
- -> {
+ lambda {
begin
erb.result(binding)
rescue Exception => e
@@ -23,7 +23,7 @@ describe "ERB#filename" do
it "uses '(erb)' as filename when filename is not set" do
erb = ERB.new('<% if true %>') # will raise SyntaxError
- -> {
+ lambda {
begin
erb.result(binding)
rescue Exception => e
diff --git a/spec/ruby/library/erb/fixtures/classes.rb b/spec/ruby/library/erb/fixtures/classes.rb
deleted file mode 100644
index 03da889941..0000000000
--- a/spec/ruby/library/erb/fixtures/classes.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module ERBSpecs
- def self.new_erb(input, trim_mode: nil)
- if ruby_version_is "2.6"
- ERB.new(input, trim_mode: trim_mode)
- else
- ERB.new(input, nil, trim_mode)
- end
- end
-end
diff --git a/spec/ruby/library/erb/new_spec.rb b/spec/ruby/library/erb/new_spec.rb
index 3bb870dd3f..f141f1c00e 100644
--- a/spec/ruby/library/erb/new_spec.rb
+++ b/spec/ruby/library/erb/new_spec.rb
@@ -1,6 +1,5 @@
require 'erb'
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB.new" do
before :all do
@@ -31,30 +30,22 @@ END
it "compiles eRuby script into ruby code when trim mode is 0 or not specified" do
expected = "<ul>\n\n\n\n<li>1</li>\n\n\n\n<li>2</li>\n\n\n\n<li>3</li>\n\n\n</ul>\n"
- [0, nil].each do |trim_mode|
- ERBSpecs.new_erb(@eruby_str, trim_mode: trim_mode).result.should == expected
- end
- end
-
- ruby_version_is "2.6" do
- it "warns invalid trim_mode" do
- -> do
- ERBSpecs.new_erb(@eruby_str, trim_mode: '')
- end.should complain(/Invalid ERB trim mode/)
+ [0, '', nil].each do |trim_mode|
+ ERB.new(@eruby_str, nil, trim_mode).result.should == expected
end
end
it "removes '\n' when trim_mode is 1 or '>'" do
expected = "<ul>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ul>\n"
[1, '>'].each do |trim_mode|
- ERBSpecs.new_erb(@eruby_str, trim_mode: trim_mode).result.should == expected
+ ERB.new(@eruby_str, nil, trim_mode).result.should == expected
end
end
it "removes spaces at beginning of line and '\n' when trim_mode is 2 or '<>'" do
expected = "<ul>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ul>\n"
[2, '<>'].each do |trim_mode|
- ERBSpecs.new_erb(@eruby_str, trim_mode: trim_mode).result.should == expected
+ ERB.new(@eruby_str, nil, trim_mode).result.should == expected
end
end
@@ -70,7 +61,7 @@ END
</ul>
END
- ERBSpecs.new_erb(input, trim_mode: '-').result.should == expected
+ ERB.new(input, nil, '-').result.should == expected
end
@@ -83,24 +74,24 @@ END
</p>
END
- -> {
- ERBSpecs.new_erb(input, trim_mode: '-').result
+ lambda {
+ ERB.new(input, nil, '-').result
}.should raise_error(SyntaxError)
end
it "regards lines starting with '%' as '<% ... %>' when trim_mode is '%'" do
expected = "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n\n</ul>\n%%\n"
- ERBSpecs.new_erb(@eruby_str2, trim_mode: "%").result.should == expected
+ ERB.new(@eruby_str2, nil, "%").result.should == expected
end
it "regards lines starting with '%' as '<% ... %>' and remove \"\\n\" when trim_mode is '%>'" do
expected = "<ul>\n <li>1 <li>2 <li>3 </ul>\n%%\n"
- ERBSpecs.new_erb(@eruby_str2, trim_mode: '%>').result.should == expected
+ ERB.new(@eruby_str2, nil, '%>').result.should == expected
end
it "regard lines starting with '%' as '<% ... %>' and remove \"\\n\" when trim_mode is '%<>'" do
expected = "<ul>\n <li>1\n \n <li>2\n \n <li>3\n \n</ul>\n%%\n"
- ERBSpecs.new_erb(@eruby_str2, trim_mode: '%<>').result.should == expected
+ ERB.new(@eruby_str2, nil, '%<>').result.should == expected
end
@@ -115,18 +106,13 @@ END
%%%
END
- ERBSpecs.new_erb(input, trim_mode: '%-').result.should == expected
+ ERB.new(input, nil, '%-').result.should == expected
end
it "changes '_erbout' variable name in the produced source" do
input = @eruby_str
- if RUBY_VERSION >= '2.6'
- match_erbout = ERB.new(input, trim_mode: nil).src
- match_buf = ERB.new(input, trim_mode: nil, eoutvar: 'buf').src
- else
- match_erbout = ERB.new(input, nil, nil).src
- match_buf = ERB.new(input, nil, nil, 'buf').src
- end
+ match_erbout = ERB.new(input, nil, nil).src
+ match_buf = ERB.new(input, nil, nil, 'buf').src
match_erbout.gsub("_erbout", "buf").should == match_buf
end
@@ -137,12 +123,12 @@ END
<b><%#= item %></b>
<%# end %>
END
- ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n"
- ERBSpecs.new_erb(input, trim_mode: '<>').result.should == "<b></b>\n"
+ ERB.new(input).result.should == "\n<b></b>\n\n"
+ ERB.new(input, nil, '<>').result.should == "<b></b>\n"
end
it "forget local variables defined previous one" do
ERB.new(@eruby_str).result
- ->{ ERB.new("<%= list %>").result }.should raise_error(NameError)
+ lambda{ ERB.new("<%= list %>").result }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/library/erb/result_spec.rb b/spec/ruby/library/erb/result_spec.rb
index a29c1ccedb..d79584b221 100644
--- a/spec/ruby/library/erb/result_spec.rb
+++ b/spec/ruby/library/erb/result_spec.rb
@@ -1,5 +1,5 @@
require 'erb'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB#result" do
@@ -41,7 +41,7 @@ END
it "is not able to h() or u() unless including ERB::Util" do
input = "<%=h '<>' %>"
- -> {
+ lambda {
ERB.new(input).result()
}.should raise_error(NameError)
end
@@ -79,7 +79,7 @@ END
expected = '123'
myerb2.new.main1().should == expected
- -> {
+ lambda {
myerb2.new.main2()
}.should raise_error(NameError)
end
diff --git a/spec/ruby/library/erb/run_spec.rb b/spec/ruby/library/erb/run_spec.rb
index 8c07442d8f..6ad3808a16 100644
--- a/spec/ruby/library/erb/run_spec.rb
+++ b/spec/ruby/library/erb/run_spec.rb
@@ -1,5 +1,5 @@
require 'erb'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB#run" do
# TODO: what is this? why does it not use
@@ -52,7 +52,7 @@ END
it "is not able to h() or u() unless including ERB::Util" do
input = "<%=h '<>' %>"
- -> {
+ lambda {
_steal_stdout { ERB.new(input).run() }
}.should raise_error(NameError)
end
@@ -89,8 +89,9 @@ END
actual = _steal_stdout { myerb2.new.main1() }
actual.should == expected
- -> {
+ lambda {
_steal_stdout { myerb2.new.main2() }
}.should raise_error(NameError)
end
end
+
diff --git a/spec/ruby/library/erb/src_spec.rb b/spec/ruby/library/erb/src_spec.rb
index fc11b7e4b7..cf5b67dcbf 100644
--- a/spec/ruby/library/erb/src_spec.rb
+++ b/spec/ruby/library/erb/src_spec.rb
@@ -1,5 +1,5 @@
require 'erb'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "ERB#src" do
diff --git a/spec/ruby/library/erb/util/h_spec.rb b/spec/ruby/library/erb/util/h_spec.rb
index 6de79cfd92..ba36574433 100644
--- a/spec/ruby/library/erb/util/h_spec.rb
+++ b/spec/ruby/library/erb/util/h_spec.rb
@@ -1,6 +1,6 @@
require 'erb'
-require_relative '../../../spec_helper'
-require_relative 'shared/html_escape'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/html_escape', __FILE__)
describe "ERB::Util.h" do
it_behaves_like :erb_util_html_escape, :h
diff --git a/spec/ruby/library/erb/util/html_escape_spec.rb b/spec/ruby/library/erb/util/html_escape_spec.rb
index 1c15fb8791..9bc9359f2c 100644
--- a/spec/ruby/library/erb/util/html_escape_spec.rb
+++ b/spec/ruby/library/erb/util/html_escape_spec.rb
@@ -1,7 +1,8 @@
require 'erb'
-require_relative '../../../spec_helper'
-require_relative 'shared/html_escape'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/html_escape', __FILE__)
describe "ERB::Util.html_escape" do
it_behaves_like :erb_util_html_escape, :html_escape
end
+
diff --git a/spec/ruby/library/erb/util/u_spec.rb b/spec/ruby/library/erb/util/u_spec.rb
index 2a08451031..9200244c8e 100644
--- a/spec/ruby/library/erb/util/u_spec.rb
+++ b/spec/ruby/library/erb/util/u_spec.rb
@@ -1,7 +1,8 @@
require 'erb'
-require_relative '../../../spec_helper'
-require_relative 'shared/url_encode'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/url_encode', __FILE__)
describe "ERB::Util.u" do
it_behaves_like :erb_util_url_encode, :u
end
+
diff --git a/spec/ruby/library/erb/util/url_encode_spec.rb b/spec/ruby/library/erb/util/url_encode_spec.rb
index 5569a1cc64..303a2e3cd7 100644
--- a/spec/ruby/library/erb/util/url_encode_spec.rb
+++ b/spec/ruby/library/erb/util/url_encode_spec.rb
@@ -1,6 +1,6 @@
require 'erb'
-require_relative '../../../spec_helper'
-require_relative 'shared/url_encode'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/url_encode', __FILE__)
describe "ERB::Util.url_encode" do
it_behaves_like :erb_util_url_encode, :url_encode
diff --git a/spec/ruby/library/etc/confstr_spec.rb b/spec/ruby/library/etc/confstr_spec.rb
deleted file mode 100644
index 0c922a3a77..0000000000
--- a/spec/ruby/library/etc/confstr_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require 'etc'
-
-platform_is_not :windows do
- describe "Etc.confstr" do
- it "returns a String for Etc::CS_PATH" do
- Etc.confstr(Etc::CS_PATH).should be_an_instance_of(String)
- end
-
- it "raises Errno::EINVAL for unknown configuration variables" do
- -> { Etc.confstr(-1) }.should raise_error(Errno::EINVAL)
- end
- end
-end
diff --git a/spec/ruby/library/etc/endgrent_spec.rb b/spec/ruby/library/etc/endgrent_spec.rb
index 88de231d87..95f0dc05e3 100644
--- a/spec/ruby/library/etc/endgrent_spec.rb
+++ b/spec/ruby/library/etc/endgrent_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/windows'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/windows', __FILE__)
require 'etc'
describe "Etc.endgrent" do
- it_behaves_like :etc_on_windows, :endgrent
+ it_behaves_like(:etc_on_windows, :endgrent)
end
diff --git a/spec/ruby/library/etc/endpwent_spec.rb b/spec/ruby/library/etc/endpwent_spec.rb
index e4e564d251..7ce8f1925b 100644
--- a/spec/ruby/library/etc/endpwent_spec.rb
+++ b/spec/ruby/library/etc/endpwent_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/windows'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/windows', __FILE__)
require 'etc'
describe "Etc.endpwent" do
- it_behaves_like :etc_on_windows, :endpwent
+ it_behaves_like(:etc_on_windows, :endpwent)
end
diff --git a/spec/ruby/library/etc/getgrent_spec.rb b/spec/ruby/library/etc/getgrent_spec.rb
index 45a4442262..96225e351a 100644
--- a/spec/ruby/library/etc/getgrent_spec.rb
+++ b/spec/ruby/library/etc/getgrent_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/windows'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/windows', __FILE__)
require 'etc'
describe "Etc.getgrent" do
- it_behaves_like :etc_on_windows, :getgrent
+ it_behaves_like(:etc_on_windows, :getgrent)
end
diff --git a/spec/ruby/library/etc/getgrgid_spec.rb b/spec/ruby/library/etc/getgrgid_spec.rb
index c7bd55b20e..9b6b283d52 100644
--- a/spec/ruby/library/etc/getgrgid_spec.rb
+++ b/spec/ruby/library/etc/getgrgid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
platform_is :windows do
@@ -13,64 +13,58 @@ end
# TODO: verify these on non-windows, non-darwin OS
platform_is_not :windows do
- grpname = nil
- guard -> {
- grpname = IO.popen(%w'id -gn', err: IO::NULL, &:read).chomp
- $?.success?
- } do
- describe "Etc.getgrgid" do
- before :all do
- @gid = `id -g`.strip.to_i
- @name = grpname
- end
+ describe "Etc.getgrgid" do
+ before :all do
+ @gid = `id -g`.strip.to_i
+ @name = `id -gn`.strip
+ end
- it "returns a Etc::Group struct instance for the given user" do
- gr = Etc.getgrgid(@gid)
+ it "returns a Etc::Group struct instance for the given user" do
+ gr = Etc.getgrgid(@gid)
- gr.is_a?(Etc::Group).should == true
- gr.gid.should == @gid
- gr.name.should == @name
- end
+ gr.is_a?(Etc::Group).should == true
+ gr.gid.should == @gid
+ gr.name.should == @name
+ end
- it "returns the Etc::Group for a given gid if it exists" do
- grp = Etc.getgrgid(@gid)
- grp.should be_kind_of(Etc::Group)
- grp.gid.should == @gid
- grp.name.should == @name
- end
+ it "returns the Etc::Group for a given gid if it exists" do
+ grp = Etc.getgrgid(@gid)
+ grp.should be_kind_of(Etc::Group)
+ grp.gid.should == @gid
+ grp.name.should == @name
+ end
- it "uses Process.gid as the default value for the argument" do
- gr = Etc.getgrgid
+ it "uses Process.gid as the default value for the argument" do
+ gr = Etc.getgrgid
- gr.gid.should == @gid
- gr.name.should == @name
- end
+ gr.gid.should == @gid
+ gr.name.should == @name
+ end
- it "returns the Group for a given gid if it exists" do
- grp = Etc.getgrgid(@gid)
- grp.should be_kind_of(Struct::Group)
- grp.gid.should == @gid
- grp.name.should == @name
- end
+ it "returns the Group for a given gid if it exists" do
+ grp = Etc.getgrgid(@gid)
+ grp.should be_kind_of(Struct::Group)
+ grp.gid.should == @gid
+ grp.name.should == @name
+ end
- it "raises if the group does not exist" do
- -> { Etc.getgrgid(9876)}.should raise_error(ArgumentError)
- end
+ it "raises if the group does not exist" do
+ lambda { Etc.getgrgid(9876)}.should raise_error(ArgumentError)
+ end
- it "raises a TypeError if not passed an Integer" do
- -> { Etc.getgrgid("foo") }.should raise_error(TypeError)
- -> { Etc.getgrgid(nil) }.should raise_error(TypeError)
- end
+ it "raises a TypeError if not passed an Integer" do
+ lambda { Etc.getgrgid("foo") }.should raise_error(TypeError)
+ lambda { Etc.getgrgid(nil) }.should raise_error(TypeError)
+ end
- it "can be called safely by multiple threads" do
- 20.times.map do
- Thread.new do
- 100.times do
- Etc.getgrgid(@gid).gid.should == @gid
- end
+ it "can be called safely by multiple threads" do
+ 20.times.map do
+ Thread.new do
+ 100.times do
+ Etc.getgrgid(@gid).gid.should == @gid
end
- end.each(&:join)
- end
+ end
+ end.each(&:join)
end
end
end
diff --git a/spec/ruby/library/etc/getgrnam_spec.rb b/spec/ruby/library/etc/getgrnam_spec.rb
index a7c624efbf..46193f49d6 100644
--- a/spec/ruby/library/etc/getgrnam_spec.rb
+++ b/spec/ruby/library/etc/getgrnam_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
platform_is :windows do
@@ -21,7 +21,7 @@ platform_is_not :windows do
end
it "only accepts strings as argument" do
- -> {
+ lambda {
Etc.getgrnam(123)
Etc.getgrnam(nil)
}.should raise_error(TypeError)
diff --git a/spec/ruby/library/etc/getlogin_spec.rb b/spec/ruby/library/etc/getlogin_spec.rb
index 7a4fd79ae2..43e654bda6 100644
--- a/spec/ruby/library/etc/getlogin_spec.rb
+++ b/spec/ruby/library/etc/getlogin_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
describe "Etc.getlogin" do
@@ -18,12 +18,7 @@ describe "Etc.getlogin" do
else
# Etc.getlogin returns the same result of logname(2)
# if it returns non NULL
- if system("which logname", out: File::NULL, err: File::NULL)
- Etc.getlogin.should == `logname`.chomp
- else
- # fallback to `id` command since `logname` is not available
- Etc.getlogin.should == `id -un`.chomp
- end
+ Etc.getlogin.should == `id -un`.chomp
end
else
# Etc.getlogin may return nil if the login name is not set
diff --git a/spec/ruby/library/etc/getpwent_spec.rb b/spec/ruby/library/etc/getpwent_spec.rb
index 9a911aed8f..1c8057c9e5 100644
--- a/spec/ruby/library/etc/getpwent_spec.rb
+++ b/spec/ruby/library/etc/getpwent_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/windows'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/windows', __FILE__)
require 'etc'
describe "Etc.getpwent" do
- it_behaves_like :etc_on_windows, :getpwent
+ it_behaves_like(:etc_on_windows, :getpwent)
end
diff --git a/spec/ruby/library/etc/getpwnam_spec.rb b/spec/ruby/library/etc/getpwnam_spec.rb
index 3f4416aa9d..8610b5da91 100644
--- a/spec/ruby/library/etc/getpwnam_spec.rb
+++ b/spec/ruby/library/etc/getpwnam_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
platform_is :windows do
@@ -19,7 +19,7 @@ platform_is_not :windows do
end
it "only accepts strings as argument" do
- -> {
+ lambda {
Etc.getpwnam(123)
Etc.getpwnam(nil)
}.should raise_error(TypeError)
diff --git a/spec/ruby/library/etc/getpwuid_spec.rb b/spec/ruby/library/etc/getpwuid_spec.rb
index 5b98f0f8d9..f1c7218c0b 100644
--- a/spec/ruby/library/etc/getpwuid_spec.rb
+++ b/spec/ruby/library/etc/getpwuid_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
platform_is :windows do
@@ -27,7 +27,7 @@ platform_is_not :windows do
end
it "only accepts integers as argument" do
- -> {
+ lambda {
Etc.getpwuid("foo")
Etc.getpwuid(nil)
}.should raise_error(TypeError)
diff --git a/spec/ruby/library/etc/group_spec.rb b/spec/ruby/library/etc/group_spec.rb
index fdd39bda16..8b92cb7bf0 100644
--- a/spec/ruby/library/etc/group_spec.rb
+++ b/spec/ruby/library/etc/group_spec.rb
@@ -1,20 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/windows'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/windows', __FILE__)
require 'etc'
describe "Etc.group" do
- it_behaves_like :etc_on_windows, :group
+ it_behaves_like(:etc_on_windows, :group)
platform_is_not :windows do
- it "returns a Etc::Group struct" do
- group = Etc.group
- begin
- group.should be_an_instance_of(Etc::Group)
- ensure
- Etc.endgrent
- end
- end
-
it "raises a RuntimeError for parallel iteration" do
proc {
Etc.group do | group |
diff --git a/spec/ruby/library/etc/nprocessors_spec.rb b/spec/ruby/library/etc/nprocessors_spec.rb
index ec7ffc81da..2a22aaafdf 100644
--- a/spec/ruby/library/etc/nprocessors_spec.rb
+++ b/spec/ruby/library/etc/nprocessors_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
describe "Etc.nprocessors" do
diff --git a/spec/ruby/library/etc/passwd_spec.rb b/spec/ruby/library/etc/passwd_spec.rb
deleted file mode 100644
index d61dada451..0000000000
--- a/spec/ruby/library/etc/passwd_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require 'etc'
-
-platform_is_not :windows do
- describe "Etc.passwd" do
- it "returns a Etc::Passwd struct" do
- passwd = Etc.passwd
- begin
- passwd.should be_an_instance_of(Etc::Passwd)
- ensure
- Etc.endpwent
- end
- end
- end
-end
diff --git a/spec/ruby/library/etc/struct_group_spec.rb b/spec/ruby/library/etc/struct_group_spec.rb
index 0b50ff578f..c33a177a98 100644
--- a/spec/ruby/library/etc/struct_group_spec.rb
+++ b/spec/ruby/library/etc/struct_group_spec.rb
@@ -1,18 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
describe "Struct::Group" do
platform_is_not :windows do
- grpname = IO.popen(%w'id -gn', err: IO::NULL, &:read)
- next unless $?.success?
- grpname.chomp!
-
before :all do
@g = Etc.getgrgid(`id -g`.strip.to_i)
end
it "returns group name" do
- @g.name.should == grpname
+ @g.name.should == `id -gn`.strip
end
it "returns group password" do
diff --git a/spec/ruby/library/etc/struct_passwd_spec.rb b/spec/ruby/library/etc/struct_passwd_spec.rb
index 93ad9dfa2a..3e4bfee828 100644
--- a/spec/ruby/library/etc/struct_passwd_spec.rb
+++ b/spec/ruby/library/etc/struct_passwd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'
describe "Struct::Passwd" do
diff --git a/spec/ruby/library/etc/sysconf_spec.rb b/spec/ruby/library/etc/sysconf_spec.rb
deleted file mode 100644
index e7d59d1b22..0000000000
--- a/spec/ruby/library/etc/sysconf_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require 'etc'
-
-platform_is_not :windows do
- describe "Etc.sysconf" do
- %w[
- SC_ARG_MAX SC_CHILD_MAX SC_HOST_NAME_MAX SC_LOGIN_NAME_MAX SC_NGROUPS_MAX
- SC_CLK_TCK SC_OPEN_MAX SC_PAGESIZE SC_RE_DUP_MAX SC_STREAM_MAX
- SC_SYMLOOP_MAX SC_TTY_NAME_MAX SC_TZNAME_MAX SC_VERSION
- ].each do |const|
- it "returns the value of POSIX.1 system configuration variable #{const}" do
- var = Etc.const_get(const)
- value = Etc.sysconf(var)
- if value.nil?
- value.should == nil
- else
- value.should be_kind_of(Integer)
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/etc/sysconfdir_spec.rb b/spec/ruby/library/etc/sysconfdir_spec.rb
deleted file mode 100644
index d54299c513..0000000000
--- a/spec/ruby/library/etc/sysconfdir_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require 'etc'
-
-describe "Etc.sysconfdir" do
- it "returns a String" do
- Etc.sysconfdir.should be_an_instance_of(String)
- end
-end
diff --git a/spec/ruby/library/etc/systmpdir_spec.rb b/spec/ruby/library/etc/systmpdir_spec.rb
deleted file mode 100644
index 99c82903f8..0000000000
--- a/spec/ruby/library/etc/systmpdir_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require 'etc'
-
-describe "Etc.systmpdir" do
- it "returns a String" do
- Etc.systmpdir.should be_an_instance_of(String)
- end
-end
diff --git a/spec/ruby/library/expect/expect_spec.rb b/spec/ruby/library/expect/expect_spec.rb
index a7041d42ee..080f3d7af4 100644
--- a/spec/ruby/library/expect/expect_spec.rb
+++ b/spec/ruby/library/expect/expect_spec.rb
@@ -1,5 +1,5 @@
platform_is_not :windows do
- require_relative '../../spec_helper'
+ require File.expand_path('../../../spec_helper', __FILE__)
require 'expect'
describe "IO#expect" do
@@ -37,7 +37,7 @@ platform_is_not :windows do
@write << "prompt> hello"
@read.close
- -> {
+ lambda {
@read.expect("hello")
}.should raise_error(IOError)
end
diff --git a/spec/ruby/library/fiber/alive_spec.rb b/spec/ruby/library/fiber/alive_spec.rb
index 47149d5279..fbd5c4bc1a 100644
--- a/spec/ruby/library/fiber/alive_spec.rb
+++ b/spec/ruby/library/fiber/alive_spec.rb
@@ -1,46 +1,48 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-require 'fiber'
+with_feature :fiber_library do
+ require 'fiber'
-describe "Fiber#alive?" do
- it "returns true for a Fiber that hasn't had #resume called" do
- fiber = Fiber.new { true }
- fiber.alive?.should be_true
- end
+ describe "Fiber#alive?" do
+ it "returns true for a Fiber that hasn't had #resume called" do
+ fiber = Fiber.new { true }
+ fiber.alive?.should be_true
+ end
- # FIXME: Better description?
- it "returns true for a Fiber that's yielded to the caller" do
- fiber = Fiber.new { Fiber.yield }
- fiber.resume
- fiber.alive?.should be_true
- end
+ # FIXME: Better description?
+ it "returns true for a Fiber that's yielded to the caller" do
+ fiber = Fiber.new { Fiber.yield }
+ fiber.resume
+ fiber.alive?.should be_true
+ end
- it "returns true when called from its Fiber" do
- fiber = Fiber.new { fiber.alive?.should be_true }
- fiber.resume
- end
+ it "returns true when called from its Fiber" do
+ fiber = Fiber.new { fiber.alive?.should be_true }
+ fiber.resume
+ end
- it "doesn't invoke the block associated with the Fiber" do
- offthehook = mock('do not call')
- offthehook.should_not_receive(:ring)
- fiber = Fiber.new { offthehook.ring }
- fiber.alive?
- end
+ it "doesn't invoke the block associated with the Fiber" do
+ offthehook = mock('do not call')
+ offthehook.should_not_receive(:ring)
+ fiber = Fiber.new { offthehook.ring }
+ fiber.alive?
+ end
- it "returns false for a Fiber that's dead" do
- fiber = Fiber.new { true }
- fiber.resume
- -> { fiber.resume }.should raise_error(FiberError)
- fiber.alive?.should be_false
- end
+ it "returns false for a Fiber that's dead" do
+ fiber = Fiber.new { true }
+ fiber.resume
+ lambda { fiber.resume }.should raise_error(FiberError)
+ fiber.alive?.should be_false
+ end
- it "always returns false for a dead Fiber" do
- fiber = Fiber.new { true }
- fiber.resume
- -> { fiber.resume }.should raise_error(FiberError)
- fiber.alive?.should be_false
- -> { fiber.resume }.should raise_error(FiberError)
- fiber.alive?.should be_false
- fiber.alive?.should be_false
+ it "always returns false for a dead Fiber" do
+ fiber = Fiber.new { true }
+ fiber.resume
+ lambda { fiber.resume }.should raise_error(FiberError)
+ fiber.alive?.should be_false
+ lambda { fiber.resume }.should raise_error(FiberError)
+ fiber.alive?.should be_false
+ fiber.alive?.should be_false
+ end
end
end
diff --git a/spec/ruby/library/fiber/current_spec.rb b/spec/ruby/library/fiber/current_spec.rb
index 52dff3dea1..fd68cd52ea 100644
--- a/spec/ruby/library/fiber/current_spec.rb
+++ b/spec/ruby/library/fiber/current_spec.rb
@@ -1,51 +1,53 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-require 'fiber'
+with_feature :fiber_library do
+ require 'fiber'
-describe "Fiber.current" do
- it "returns the root Fiber when called outside of a Fiber" do
- root = Fiber.current
- root.should be_an_instance_of(Fiber)
- # We can always transfer to the root Fiber; it will never die
- 5.times do
- root.transfer.should be_nil
- root.alive?.should be_true
+ describe "Fiber.current" do
+ it "returns the root Fiber when called outside of a Fiber" do
+ root = Fiber.current
+ root.should be_an_instance_of(Fiber)
+ # We can always transfer to the root Fiber; it will never die
+ 5.times do
+ root.transfer.should be_nil
+ root.alive?.should be_true
+ end
end
- end
- it "returns the current Fiber when called from a Fiber" do
- fiber = Fiber.new do
- this = Fiber.current
- this.should be_an_instance_of(Fiber)
- this.should == fiber
- this.alive?.should be_true
+ it "returns the current Fiber when called from a Fiber" do
+ fiber = Fiber.new do
+ this = Fiber.current
+ this.should be_an_instance_of(Fiber)
+ this.should == fiber
+ this.alive?.should be_true
+ end
+ fiber.resume
end
- fiber.resume
- end
- it "returns the current Fiber when called from a Fiber that transferred to another" do
- states = []
- fiber = Fiber.new do
- states << :fiber
- this = Fiber.current
- this.should be_an_instance_of(Fiber)
- this.should == fiber
- this.alive?.should be_true
- end
+ it "returns the current Fiber when called from a Fiber that transferred to another" do
+ states = []
+ fiber = Fiber.new do
+ states << :fiber
+ this = Fiber.current
+ this.should be_an_instance_of(Fiber)
+ this.should == fiber
+ this.alive?.should be_true
+ end
- fiber2 = Fiber.new do
- states << :fiber2
- fiber.transfer
- flunk
- end
+ fiber2 = Fiber.new do
+ states << :fiber2
+ fiber.transfer
+ flunk
+ end
- fiber3 = Fiber.new do
- states << :fiber3
- fiber2.transfer
- flunk
- end
+ fiber3 = Fiber.new do
+ states << :fiber3
+ fiber2.transfer
+ flunk
+ end
- fiber3.resume
- states.should == [:fiber3, :fiber2, :fiber]
+ fiber3.resume
+ states.should == [:fiber3, :fiber2, :fiber]
+ end
end
end
diff --git a/spec/ruby/library/fiber/resume_spec.rb b/spec/ruby/library/fiber/resume_spec.rb
index dae717c8a1..389757b7bd 100644
--- a/spec/ruby/library/fiber/resume_spec.rb
+++ b/spec/ruby/library/fiber/resume_spec.rb
@@ -1,12 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
-require 'fiber'
+with_feature :fiber_library do
+ require 'fiber'
-describe "Fiber#resume" do
- it "raises a FiberError if the Fiber has transferred control to another Fiber" do
- fiber1 = Fiber.new { true }
- fiber2 = Fiber.new { fiber1.transfer; Fiber.yield }
- fiber2.resume
- -> { fiber2.resume }.should raise_error(FiberError)
+ describe "Fiber#resume" do
+ it "raises a FiberError if the Fiber has transferred control to another Fiber" do
+ fiber1 = Fiber.new { true }
+ fiber2 = Fiber.new { fiber1.transfer; Fiber.yield }
+ fiber2.resume
+ lambda { fiber2.resume }.should raise_error(FiberError)
+ end
end
end
diff --git a/spec/ruby/library/fiber/transfer_spec.rb b/spec/ruby/library/fiber/transfer_spec.rb
index d13053666c..ad501c1d74 100644
--- a/spec/ruby/library/fiber/transfer_spec.rb
+++ b/spec/ruby/library/fiber/transfer_spec.rb
@@ -1,86 +1,51 @@
-require_relative '../../spec_helper'
-require_relative '../../shared/fiber/resume'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../shared/fiber/resume', __FILE__)
-require 'fiber'
+with_feature :fiber_library do
+ require 'fiber'
-describe "Fiber#transfer" do
- it_behaves_like :fiber_resume, :transfer
-end
-
-describe "Fiber#transfer" do
- it "transfers control from one Fiber to another when called from a Fiber" do
- fiber1 = Fiber.new { :fiber1 }
- fiber2 = Fiber.new { fiber1.transfer; :fiber2 }
- fiber2.resume.should == :fiber1
- end
-
- it "returns to the root Fiber when finished" do
- f1 = Fiber.new { :fiber_1 }
- f2 = Fiber.new { f1.transfer; :fiber_2 }
-
- f2.transfer.should == :fiber_1
- f2.transfer.should == :fiber_2
+ describe "Fiber#transfer" do
+ it_behaves_like :fiber_resume, :transfer
end
- it "can be invoked from the same Fiber it transfers control to" do
- states = []
- fiber = Fiber.new { states << :start; fiber.transfer; states << :end }
- fiber.transfer
- states.should == [:start, :end]
+ describe "Fiber#transfer" do
+ it "transfers control from one Fiber to another when called from a Fiber" do
+ fiber1 = Fiber.new { :fiber1 }
+ fiber2 = Fiber.new { fiber1.transfer; :fiber2 }
+ fiber2.resume.should == :fiber1
+ end
- states = []
- fiber = Fiber.new { states << :start; fiber.transfer; states << :end }
- fiber.resume
- states.should == [:start, :end]
- end
+ it "returns to the root Fiber when finished" do
+ f1 = Fiber.new { :fiber_1 }
+ f2 = Fiber.new { f1.transfer; :fiber_2 }
- it "can transfer control to a Fiber that has transferred to another Fiber" do
- states = []
- fiber1 = Fiber.new { states << :fiber1 }
- fiber2 = Fiber.new { states << :fiber2_start; fiber1.transfer; states << :fiber2_end}
- fiber2.resume.should == [:fiber2_start, :fiber1]
- fiber2.transfer.should == [:fiber2_start, :fiber1, :fiber2_end]
- end
+ f2.transfer.should == :fiber_1
+ f2.transfer.should == :fiber_2
+ end
- it "raises a FiberError when transferring to a Fiber which resumes itself" do
- fiber = Fiber.new { fiber.resume }
- -> { fiber.transfer }.should raise_error(FiberError)
- end
+ it "can be invoked from the same Fiber it transfers control to" do
+ states = []
+ fiber = Fiber.new { states << :start; fiber.transfer; states << :end }
+ fiber.transfer
+ states.should == [:start, :end]
- it "works if Fibers in different Threads each transfer to a Fiber in the same Thread" do
- # This catches a bug where Fibers are running on a thread-pool
- # and Fibers from a different Ruby Thread reuse the same native thread.
- # Caching the Ruby Thread based on the native thread is not correct in that case,
- # and the check for "fiber called across threads" in Fiber#transfer
- # might be incorrect based on that.
- 2.times do
- Thread.new do
- io_fiber = Fiber.new do |calling_fiber|
- calling_fiber.transfer
- end
- io_fiber.transfer(Fiber.current)
- value = Object.new
- io_fiber.transfer(value).should equal value
- end.join
+ states = []
+ fiber = Fiber.new { states << :start; fiber.transfer; states << :end }
+ fiber.resume
+ states.should == [:start, :end]
end
- end
- it "transfers control between a non-main thread's root fiber to a child fiber and back again" do
- states = []
- thread = Thread.new do
- f1 = Fiber.new do |f0|
- states << 0
- value2 = f0.transfer(1)
- states << value2
- 3
- end
+ it "can transfer control to a Fiber that has transferred to another Fiber" do
+ states = []
+ fiber1 = Fiber.new { states << :fiber1 }
+ fiber2 = Fiber.new { states << :fiber2_start; fiber1.transfer; states << :fiber2_end}
+ fiber2.resume.should == [:fiber2_start, :fiber1]
+ fiber2.transfer.should == [:fiber2_start, :fiber1, :fiber2_end]
+ end
- value1 = f1.transfer(Fiber.current)
- states << value1
- value3 = f1.transfer(2)
- states << value3
+ it "raises a FiberError when transferring to a Fiber which resumes itself" do
+ fiber = Fiber.new { fiber.resume }
+ lambda { fiber.transfer }.should raise_error(FiberError)
end
- thread.join
- states.should == [0, 1, 2, 3]
end
end
diff --git a/spec/ruby/library/find/find_spec.rb b/spec/ruby/library/find/find_spec.rb
index 7cd76fa01b..14c9e2926e 100644
--- a/spec/ruby/library/find/find_spec.rb
+++ b/spec/ruby/library/find/find_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
require 'find'
describe "Find.find" do
diff --git a/spec/ruby/library/find/prune_spec.rb b/spec/ruby/library/find/prune_spec.rb
index 25dc2cbf3e..1aef7d3d23 100644
--- a/spec/ruby/library/find/prune_spec.rb
+++ b/spec/ruby/library/find/prune_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'find'
describe "Find.prune" do
diff --git a/spec/ruby/library/getoptlong/each_option_spec.rb b/spec/ruby/library/getoptlong/each_option_spec.rb
index c6d82af86d..c58815bfa9 100644
--- a/spec/ruby/library/getoptlong/each_option_spec.rb
+++ b/spec/ruby/library/getoptlong/each_option_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
-require_relative 'shared/each'
+require File.expand_path('../shared/each', __FILE__)
describe "GetoptLong#each_option" do
- it_behaves_like :getoptlong_each, :each_option
+ it_behaves_like(:getoptlong_each, :each_option)
end
diff --git a/spec/ruby/library/getoptlong/each_spec.rb b/spec/ruby/library/getoptlong/each_spec.rb
index d9022f02af..d09f84a6db 100644
--- a/spec/ruby/library/getoptlong/each_spec.rb
+++ b/spec/ruby/library/getoptlong/each_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
-require_relative 'shared/each'
+require File.expand_path('../shared/each', __FILE__)
describe "GetoptLong#each" do
- it_behaves_like :getoptlong_each, :each
+ it_behaves_like(:getoptlong_each, :each)
end
diff --git a/spec/ruby/library/getoptlong/error_message_spec.rb b/spec/ruby/library/getoptlong/error_message_spec.rb
index 1ed9419f6c..3f44f538c6 100644
--- a/spec/ruby/library/getoptlong/error_message_spec.rb
+++ b/spec/ruby/library/getoptlong/error_message_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
describe "GetoptLong#error_message" do
diff --git a/spec/ruby/library/getoptlong/get_option_spec.rb b/spec/ruby/library/getoptlong/get_option_spec.rb
index 3cb2044379..c56903e68e 100644
--- a/spec/ruby/library/getoptlong/get_option_spec.rb
+++ b/spec/ruby/library/getoptlong/get_option_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
-require_relative 'shared/get'
+require File.expand_path('../shared/get', __FILE__)
describe "GetoptLong#get_option" do
- it_behaves_like :getoptlong_get, :get_option
+ it_behaves_like(:getoptlong_get, :get_option)
end
diff --git a/spec/ruby/library/getoptlong/get_spec.rb b/spec/ruby/library/getoptlong/get_spec.rb
index a8ec586fc9..ba1a1be6ad 100644
--- a/spec/ruby/library/getoptlong/get_spec.rb
+++ b/spec/ruby/library/getoptlong/get_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
-require_relative 'shared/get'
+require File.expand_path('../shared/get', __FILE__)
describe "GetoptLong#get" do
- it_behaves_like :getoptlong_get, :get
+ it_behaves_like(:getoptlong_get, :get)
end
diff --git a/spec/ruby/library/getoptlong/initialize_spec.rb b/spec/ruby/library/getoptlong/initialize_spec.rb
index 782edbd981..6ac46b8b5d 100644
--- a/spec/ruby/library/getoptlong/initialize_spec.rb
+++ b/spec/ruby/library/getoptlong/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
describe "GetoptLong#initialize" do
diff --git a/spec/ruby/library/getoptlong/ordering_spec.rb b/spec/ruby/library/getoptlong/ordering_spec.rb
index 695d1cafa7..e445de2255 100644
--- a/spec/ruby/library/getoptlong/ordering_spec.rb
+++ b/spec/ruby/library/getoptlong/ordering_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
describe "GetoptLong#ordering=" do
@@ -9,7 +9,7 @@ describe "GetoptLong#ordering=" do
opts.quiet = true
opts.get
- -> {
+ lambda {
opts.ordering = GetoptLong::PERMUTE
}.should raise_error(ArgumentError)
end
@@ -18,7 +18,7 @@ describe "GetoptLong#ordering=" do
it "raises an ArgumentError if given an invalid value" do
opts = GetoptLong.new
- -> {
+ lambda {
opts.ordering = 12345
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/getoptlong/set_options_spec.rb b/spec/ruby/library/getoptlong/set_options_spec.rb
index 36b9c579c4..39d6991bf5 100644
--- a/spec/ruby/library/getoptlong/set_options_spec.rb
+++ b/spec/ruby/library/getoptlong/set_options_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
describe "GetoptLong#set_options" do
@@ -39,7 +39,7 @@ describe "GetoptLong#set_options" do
it "raises an ArgumentError if too many argument flags where given" do
argv [] do
- -> {
+ lambda {
@opts.set_options(["--size", GetoptLong::NO_ARGUMENT, GetoptLong::REQUIRED_ARGUMENT])
}.should raise_error(ArgumentError)
end
@@ -48,7 +48,7 @@ describe "GetoptLong#set_options" do
it "raises a RuntimeError if processing has already started" do
argv [] do
@opts.get
- -> {
+ lambda {
@opts.set_options()
}.should raise_error(RuntimeError)
end
@@ -56,7 +56,7 @@ describe "GetoptLong#set_options" do
it "raises an ArgumentError if no argument flag was given" do
argv [] do
- -> {
+ lambda {
@opts.set_options(["--size"])
}.should raise_error(ArgumentError)
end
@@ -64,7 +64,7 @@ describe "GetoptLong#set_options" do
it "raises an ArgumentError if one of the given arguments is not an Array" do
argv [] do
- -> {
+ lambda {
@opts.set_options(
["--size", GetoptLong::REQUIRED_ARGUMENT],
"test")
@@ -74,13 +74,13 @@ describe "GetoptLong#set_options" do
it "raises an ArgumentError if the same option is given twice" do
argv [] do
- -> {
+ lambda {
@opts.set_options(
["--size", GetoptLong::NO_ARGUMENT],
["--size", GetoptLong::OPTIONAL_ARGUMENT])
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@opts.set_options(
["--size", GetoptLong::NO_ARGUMENT],
["-s", "--size", GetoptLong::OPTIONAL_ARGUMENT])
@@ -90,7 +90,7 @@ describe "GetoptLong#set_options" do
it "raises an ArgumentError if the given option is invalid" do
argv [] do
- -> {
+ lambda {
@opts.set_options(["-size", GetoptLong::NO_ARGUMENT])
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/getoptlong/shared/get.rb b/spec/ruby/library/getoptlong/shared/get.rb
index 772a7f6773..91a0fbaacc 100644
--- a/spec/ruby/library/getoptlong/shared/get.rb
+++ b/spec/ruby/library/getoptlong/shared/get.rb
@@ -49,7 +49,7 @@ describe :getoptlong_get, shared: true do
it "raises a if an argument was required, but none given" do
argv [ "--size" ] do
- -> { @opts.send(@method) }.should raise_error(GetoptLong::MissingArgument)
+ lambda { @opts.send(@method) }.should raise_error(GetoptLong::MissingArgument)
end
end
diff --git a/spec/ruby/library/getoptlong/terminate_spec.rb b/spec/ruby/library/getoptlong/terminate_spec.rb
index a12d1df2ef..66d318527b 100644
--- a/spec/ruby/library/getoptlong/terminate_spec.rb
+++ b/spec/ruby/library/getoptlong/terminate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
describe "GetoptLong#terminate" do
@@ -19,7 +19,7 @@ describe "GetoptLong#terminate" do
end
end
- it "returns self when option processing is terminated" do
+ it "returns self when option processsing is terminated" do
@opts.terminate.should == @opts
end
diff --git a/spec/ruby/library/getoptlong/terminated_spec.rb b/spec/ruby/library/getoptlong/terminated_spec.rb
index 01a8feddea..feaf2bc09e 100644
--- a/spec/ruby/library/getoptlong/terminated_spec.rb
+++ b/spec/ruby/library/getoptlong/terminated_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'getoptlong'
describe "GetoptLong#terminated?" do
diff --git a/spec/ruby/library/ipaddr/hton_spec.rb b/spec/ruby/library/ipaddr/hton_spec.rb
index 9c0b821abf..037bb3d328 100644
--- a/spec/ruby/library/ipaddr/hton_spec.rb
+++ b/spec/ruby/library/ipaddr/hton_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ipaddr'
describe "IPAddr#hton" do
diff --git a/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb b/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb
index 9d45055d76..b69be82c13 100644
--- a/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb
+++ b/spec/ruby/library/ipaddr/ipv4_conversion_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ipaddr'
describe "IPAddr#ipv4_compat" do
@@ -42,3 +42,5 @@ describe "IPAddr#ipv4_mapped" do
end
end
+
+
diff --git a/spec/ruby/library/ipaddr/new_spec.rb b/spec/ruby/library/ipaddr/new_spec.rb
index c8c8bc80b3..d0b91af87d 100644
--- a/spec/ruby/library/ipaddr/new_spec.rb
+++ b/spec/ruby/library/ipaddr/new_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ipaddr'
describe "IPAddr#new" do
it "initializes IPAddr" do
- ->{ IPAddr.new("3FFE:505:ffff::/48") }.should_not raise_error
- ->{ IPAddr.new("0:0:0:1::") }.should_not raise_error
- ->{ IPAddr.new("2001:200:300::/48") }.should_not raise_error
+ lambda{ IPAddr.new("3FFE:505:ffff::/48") }.should_not raise_error
+ lambda{ IPAddr.new("0:0:0:1::") }.should_not raise_error
+ lambda{ IPAddr.new("2001:200:300::/48") }.should_not raise_error
end
it "initializes IPAddr ipv6 address with short notation" do
@@ -85,7 +85,7 @@ describe "IPAddr#new" do
["::ffff:192.168.1.2/120", Socket::AF_INET],
["[192.168.1.2]/120"],
].each { |args|
- ->{
+ lambda{
IPAddr.new(*args)
}.should raise_error(ArgumentError)
}
diff --git a/spec/ruby/library/ipaddr/operator_spec.rb b/spec/ruby/library/ipaddr/operator_spec.rb
index f90c56009c..6d884780e3 100644
--- a/spec/ruby/library/ipaddr/operator_spec.rb
+++ b/spec/ruby/library/ipaddr/operator_spec.rb
@@ -1,12 +1,15 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ipaddr'
describe "IPAddr Operator" do
+ IN6MASK32 = "ffff:ffff::"
+ IN6MASK128 = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
+
before do
@in6_addr_any = IPAddr.new()
@a = IPAddr.new("3ffe:505:2::/48")
@b = IPAddr.new("0:0:0:1::")
- @c = IPAddr.new("ffff:ffff::")
+ @c = IPAddr.new(IN6MASK32)
end
it "bitwises or" do
@@ -45,7 +48,7 @@ describe "IPAddr Operator" do
it "inverts" do
a = ~@in6_addr_any
- a.to_s.should == "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
+ a.to_s.should == IN6MASK128
@in6_addr_any.to_s.should == "::"
end
@@ -54,9 +57,11 @@ describe "IPAddr Operator" do
@a.should_not == IPAddr.new("3ffe:505:3::")
end
- # https://bugs.ruby-lang.org/issues/12799
- it "tests for equality correctly if object cannot be converted to IPAddr" do
- IPAddr.new("1.1.1.1").should_not == "sometext"
+ ruby_version_is '2.4' do
+ # https://bugs.ruby-lang.org/issues/12799
+ it "tests for equality correctly if object cannot be converted to IPAddr" do
+ IPAddr.new("1.1.1.1").should_not == "sometext"
+ end
end
it "sets a mask" do
diff --git a/spec/ruby/library/ipaddr/reverse_spec.rb b/spec/ruby/library/ipaddr/reverse_spec.rb
index 6ebb343269..dec5c65178 100644
--- a/spec/ruby/library/ipaddr/reverse_spec.rb
+++ b/spec/ruby/library/ipaddr/reverse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ipaddr'
describe "IPAddr#reverse" do
@@ -11,7 +11,7 @@ end
describe "IPAddr#ip6_arpa" do
it "converts an IPv6 address into the reverse DNS lookup representation according to RFC3172" do
IPAddr.new("3ffe:505:2::f").ip6_arpa.should == "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa"
- ->{
+ lambda{
IPAddr.new("192.168.2.1").ip6_arpa
}.should raise_error(ArgumentError)
end
@@ -20,7 +20,7 @@ end
describe "IPAddr#ip6_int" do
it "converts an IPv6 address into the reverse DNS lookup representation according to RFC1886" do
IPAddr.new("3ffe:505:2::f").ip6_int.should == "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.int"
- ->{
+ lambda{
IPAddr.new("192.168.2.1").ip6_int
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/ipaddr/to_s_spec.rb b/spec/ruby/library/ipaddr/to_s_spec.rb
index 2a9a027909..30e5237436 100644
--- a/spec/ruby/library/ipaddr/to_s_spec.rb
+++ b/spec/ruby/library/ipaddr/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ipaddr'
describe "IPAddr#to_s" do
diff --git a/spec/ruby/library/logger/device/close_spec.rb b/spec/ruby/library/logger/device/close_spec.rb
index d7d107fcce..777b20baf0 100644
--- a/spec/ruby/library/logger/device/close_spec.rb
+++ b/spec/ruby/library/logger/device/close_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger::LogDevice#close" do
before :each do
@@ -15,17 +15,8 @@ describe "Logger::LogDevice#close" do
rm_r @file_path
end
- ruby_version_is ""..."2.7" do
- it "closes the LogDevice's stream" do
- @device.close
- -> { @device.write("Test") }.should complain(/\Alog writing failed\./)
- end
- end
-
- ruby_version_is "2.7" do
- it "closes the LogDevice's stream" do
- @device.close
- -> { @device.write("Test") }.should complain(/\Alog shifting failed\./)
- end
+ it "closes the LogDevice's stream" do
+ @device.close
+ lambda { @device.write("Test") }.should complain(/\Alog writing failed\./)
end
end
diff --git a/spec/ruby/library/logger/device/new_spec.rb b/spec/ruby/library/logger/device/new_spec.rb
index 26a38c2b8c..0e08b743ed 100644
--- a/spec/ruby/library/logger/device/new_spec.rb
+++ b/spec/ruby/library/logger/device/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger::LogDevice#new" do
before :each do
@@ -31,7 +31,7 @@ describe "Logger::LogDevice#new" do
l.write("Test message")
l.close
- File.should.exist?(path)
+ File.exist?(path).should be_true
File.open(path) do |f|
f.readlines.should_not be_empty
end
@@ -40,8 +40,8 @@ describe "Logger::LogDevice#new" do
end
it "receives options via a hash as second argument" do
- -> {
- Logger::LogDevice.new(STDERR, shift_age: 8, shift_size: 10)
- }.should_not raise_error
+ lambda { Logger::LogDevice.new(STDERR,
+ { shift_age: 8, shift_size: 10
+ })}.should_not raise_error
end
end
diff --git a/spec/ruby/library/logger/device/write_spec.rb b/spec/ruby/library/logger/device/write_spec.rb
index 5506bb2c38..e3ddd61b1f 100644
--- a/spec/ruby/library/logger/device/write_spec.rb
+++ b/spec/ruby/library/logger/device/write_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger::LogDevice#write" do
before :each do
@@ -35,17 +35,8 @@ describe "Logger::LogDevice#write" do
rm_r path
end
- ruby_version_is ""..."2.7" do
- it "fails if the device is already closed" do
- @device.close
- -> { @device.write "foo" }.should complain(/\Alog writing failed\./)
- end
- end
-
- ruby_version_is "2.7" do
- it "fails if the device is already closed" do
- @device.close
- -> { @device.write "foo" }.should complain(/\Alog shifting failed\./)
- end
+ it "fails if the device is already closed" do
+ @device.close
+ lambda { @device.write "foo" }.should complain(/\Alog writing failed\./)
end
end
diff --git a/spec/ruby/library/logger/logger/add_spec.rb b/spec/ruby/library/logger/logger/add_spec.rb
index 3f709e18ba..235247e9e8 100644
--- a/spec/ruby/library/logger/logger/add_spec.rb
+++ b/spec/ruby/library/logger/logger/add_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#add" do
before :each do
@@ -52,7 +52,7 @@ describe "Logger#add" do
end
it "receives a block" do
- -> {
+ lambda {
@logger.log(nil, "test", "TestApp") do
1+1
end
@@ -61,7 +61,7 @@ describe "Logger#add" do
it "calls the block if message is nil" do
temp = 0
- -> {
+ lambda {
@logger.log(nil, nil, "TestApp") do
temp = 1+1
end
@@ -71,7 +71,7 @@ describe "Logger#add" do
it "ignores the block if the message is not nil" do
temp = 0
- -> {
+ lambda {
@logger.log(nil, "not nil", "TestApp") do
temp = 1+1
end
diff --git a/spec/ruby/library/logger/logger/close_spec.rb b/spec/ruby/library/logger/logger/close_spec.rb
index 81aac2a6cd..a4c006150b 100644
--- a/spec/ruby/library/logger/logger/close_spec.rb
+++ b/spec/ruby/library/logger/logger/close_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#close" do
before :each do
@@ -15,6 +15,6 @@ describe "Logger#close" do
it "closes the logging device" do
@logger.close
- -> { @logger.add(nil, "Foo") }.should complain(/\Alog writing failed\./)
+ lambda { @logger.add(nil, "Foo") }.should complain(/\Alog writing failed\./)
end
end
diff --git a/spec/ruby/library/logger/logger/datetime_format_spec.rb b/spec/ruby/library/logger/logger/datetime_format_spec.rb
index 582b34bfda..2bc1f867c3 100644
--- a/spec/ruby/library/logger/logger/datetime_format_spec.rb
+++ b/spec/ruby/library/logger/logger/datetime_format_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#datetime_format" do
before :each do
@@ -49,7 +49,7 @@ describe "Logger#datetime_format=" do
end
it "follows the Time#strftime format" do
- -> { @logger.datetime_format = "%Y-%m" }.should_not raise_error
+ lambda { @logger.datetime_format = "%Y-%m" }.should_not raise_error
regex = /\d{4}-\d{2}-\d{2}oo-\w+ar/
@logger.datetime_format = "%Foo-%Bar"
diff --git a/spec/ruby/library/logger/logger/debug_spec.rb b/spec/ruby/library/logger/logger/debug_spec.rb
index d92c339232..2260587b23 100644
--- a/spec/ruby/library/logger/logger/debug_spec.rb
+++ b/spec/ruby/library/logger/logger/debug_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#debug?" do
before :each do
diff --git a/spec/ruby/library/logger/logger/error_spec.rb b/spec/ruby/library/logger/logger/error_spec.rb
index d5d0bd2d2f..e165396bab 100644
--- a/spec/ruby/library/logger/logger/error_spec.rb
+++ b/spec/ruby/library/logger/logger/error_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#error?" do
before :each do
diff --git a/spec/ruby/library/logger/logger/fatal_spec.rb b/spec/ruby/library/logger/logger/fatal_spec.rb
index 42d4341319..ebbe8a04a5 100644
--- a/spec/ruby/library/logger/logger/fatal_spec.rb
+++ b/spec/ruby/library/logger/logger/fatal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#fatal?" do
before :each do
diff --git a/spec/ruby/library/logger/logger/info_spec.rb b/spec/ruby/library/logger/logger/info_spec.rb
index 21eacbbb31..7f299ea0da 100644
--- a/spec/ruby/library/logger/logger/info_spec.rb
+++ b/spec/ruby/library/logger/logger/info_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#info?" do
before :each do
diff --git a/spec/ruby/library/logger/logger/new_spec.rb b/spec/ruby/library/logger/logger/new_spec.rb
index d3100ee2d1..b3eed42f00 100644
--- a/spec/ruby/library/logger/logger/new_spec.rb
+++ b/spec/ruby/library/logger/logger/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#new" do
@@ -15,7 +15,7 @@ describe "Logger#new" do
it "creates a new logger object" do
l = Logger.new(STDERR)
- -> { l.add(Logger::WARN, "Foo") }.should output_to_fd(/Foo/, STDERR)
+ lambda { l.add(Logger::WARN, "Foo") }.should output_to_fd(/Foo/, STDERR)
end
it "receives a logging device as first argument" do
@@ -28,16 +28,16 @@ describe "Logger#new" do
end
it "receives a frequency rotation as second argument" do
- -> { Logger.new(@log_file, "daily") }.should_not raise_error
- -> { Logger.new(@log_file, "weekly") }.should_not raise_error
- -> { Logger.new(@log_file, "monthly") }.should_not raise_error
+ lambda { Logger.new(@log_file, "daily") }.should_not raise_error
+ lambda { Logger.new(@log_file, "weekly") }.should_not raise_error
+ lambda { Logger.new(@log_file, "monthly") }.should_not raise_error
end
it "also receives a number of log files to keep as second argument" do
- -> { Logger.new(@log_file, 1).close }.should_not raise_error
+ lambda { Logger.new(@log_file, 1).close }.should_not raise_error
end
- it "receives a maximum logfile size as third argument" do
+ it "receivs a maximum logfile size as third argument" do
# This should create 2 small log files, logfile_test and logfile_test.0
# in /tmp, each one with a different message.
path = tmp("logfile_test.log")
@@ -46,8 +46,8 @@ describe "Logger#new" do
l.add Logger::WARN, "foo"
l.add Logger::WARN, "bar"
- File.should.exist?(path)
- File.should.exist?(path + ".0")
+ File.exist?(path).should be_true
+ File.exist?(path + ".0").should be_true
# first line will be a comment so we'll have to skip it.
f = File.open(path)
@@ -61,58 +61,60 @@ describe "Logger#new" do
rm_r path, "#{path}.0"
end
- it "receives level symbol as keyword argument" do
- logger = Logger.new(STDERR, level: :info)
- logger.level.should == Logger::INFO
- end
+ ruby_version_is "2.4" do
+ it "receives level symbol as keyword argument" do
+ logger = Logger.new(STDERR, level: :info)
+ logger.level.should == Logger::INFO
+ end
- it "receives level as keyword argument" do
- logger = Logger.new(STDERR, level: Logger::INFO)
- logger.level.should == Logger::INFO
- end
+ it "receives level as keyword argument" do
+ logger = Logger.new(STDERR, level: Logger::INFO)
+ logger.level.should == Logger::INFO
+ end
- it "receives progname as keyword argument" do
- progname = "progname"
+ it "receives progname as keyword argument" do
+ progname = "progname"
- logger = Logger.new(STDERR, progname: progname)
- logger.progname.should == progname
- end
+ logger = Logger.new(STDERR, progname: progname)
+ logger.progname.should == progname
+ end
- it "receives datetime_format as keyword argument" do
- datetime_format = "%H:%M:%S"
+ it "receives datetime_format as keyword argument" do
+ datetime_format = "%H:%M:%S"
- logger = Logger.new(STDERR, datetime_format: datetime_format)
- logger.datetime_format.should == datetime_format
- end
+ logger = Logger.new(STDERR, datetime_format: datetime_format)
+ logger.datetime_format.should == datetime_format
+ end
- it "receives formatter as keyword argument" do
- formatter = Class.new do
- def call(_severity, _time, _progname, _msg); end
- end.new
+ it "receives formatter as keyword argument" do
+ formatter = Class.new do
+ def call(_severity, _time, _progname, _msg); end
+ end.new
- logger = Logger.new(STDERR, formatter: formatter)
- logger.formatter.should == formatter
- end
+ logger = Logger.new(STDERR, formatter: formatter)
+ logger.formatter.should == formatter
+ end
- it "receives shift_period_suffix " do
- shift_period_suffix = "%Y-%m-%d"
- path = tmp("shift_period_suffix_test.log")
- now = Time.now
- tomorrow = Time.at(now.to_i + 60 * 60 * 24)
- logger = Logger.new(path, 'daily', shift_period_suffix: shift_period_suffix)
+ it "receives shift_period_suffix " do
+ shift_period_suffix = "%Y-%m-%d"
+ path = tmp("shift_period_suffix_test.log")
+ now = Time.now
+ tomorrow = Time.at(now.to_i + 60 * 60 * 24)
+ logger = Logger.new(path, 'daily', shift_period_suffix: shift_period_suffix)
- logger.add Logger::INFO, 'message'
+ logger.add Logger::INFO, 'message'
- Time.stub!(:now).and_return(tomorrow)
- logger.add Logger::INFO, 'second message'
+ Time.stub!(:now).and_return(tomorrow)
+ logger.add Logger::INFO, 'second message'
- shifted_path = "#{path}.#{now.strftime(shift_period_suffix)}"
+ shifted_path = "#{path}.#{now.strftime(shift_period_suffix)}"
- File.should.exist?(shifted_path)
+ File.exist?(shifted_path).should == true
- logger.close
+ logger.close
- rm_r path, shifted_path
+ rm_r path, shifted_path
+ end
end
end
diff --git a/spec/ruby/library/logger/logger/unknown_spec.rb b/spec/ruby/library/logger/logger/unknown_spec.rb
index b174b8b2c9..5ef9659a9c 100644
--- a/spec/ruby/library/logger/logger/unknown_spec.rb
+++ b/spec/ruby/library/logger/logger/unknown_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#unknown" do
before :each do
@@ -29,7 +29,7 @@ describe "Logger#unknown" do
end
it "receives empty messages" do
- -> { @logger.unknown("") }.should_not raise_error
+ lambda { @logger.unknown("") }.should_not raise_error
@log_file.rewind
LoggerSpecs.strip_date(@log_file.readlines.first).should == "ANY -- : \n"
end
diff --git a/spec/ruby/library/logger/logger/warn_spec.rb b/spec/ruby/library/logger/logger/warn_spec.rb
index 6617b2b41a..d34f19fb8e 100644
--- a/spec/ruby/library/logger/logger/warn_spec.rb
+++ b/spec/ruby/library/logger/logger/warn_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/common'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/common', __FILE__)
describe "Logger#warn?" do
before :each do
diff --git a/spec/ruby/library/logger/severity_spec.rb b/spec/ruby/library/logger/severity_spec.rb
index e9bc850c33..a4219365dd 100644
--- a/spec/ruby/library/logger/severity_spec.rb
+++ b/spec/ruby/library/logger/severity_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'logger'
describe "Logger::Severity" do
diff --git a/spec/ruby/library/mathn/bignum/exponent_spec.rb b/spec/ruby/library/mathn/bignum/exponent_spec.rb
index ddd19ffdb4..758c2f27fd 100644
--- a/spec/ruby/library/mathn/bignum/exponent_spec.rb
+++ b/spec/ruby/library/mathn/bignum/exponent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
diff --git a/spec/ruby/library/mathn/complex/Complex_spec.rb b/spec/ruby/library/mathn/complex/Complex_spec.rb
index 105902ed5d..93bb3f0c60 100644
--- a/spec/ruby/library/mathn/complex/Complex_spec.rb
+++ b/spec/ruby/library/mathn/complex/Complex_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
diff --git a/spec/ruby/library/mathn/fixnum/exponent_spec.rb b/spec/ruby/library/mathn/fixnum/exponent_spec.rb
index 160bf7f115..d72bc5aa00 100644
--- a/spec/ruby/library/mathn/fixnum/exponent_spec.rb
+++ b/spec/ruby/library/mathn/fixnum/exponent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
diff --git a/spec/ruby/library/mathn/float/exponent_spec.rb b/spec/ruby/library/mathn/float/exponent_spec.rb
index 312119db00..55af43ce5b 100644
--- a/spec/ruby/library/mathn/float/exponent_spec.rb
+++ b/spec/ruby/library/mathn/float/exponent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
diff --git a/spec/ruby/library/mathn/integer/from_prime_division_spec.rb b/spec/ruby/library/mathn/integer/from_prime_division_spec.rb
index df2db6d8c1..47aaf47797 100644
--- a/spec/ruby/library/mathn/integer/from_prime_division_spec.rb
+++ b/spec/ruby/library/mathn/integer/from_prime_division_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
diff --git a/spec/ruby/library/mathn/integer/prime_division_spec.rb b/spec/ruby/library/mathn/integer/prime_division_spec.rb
index fb4a1c3fea..63a5c39733 100644
--- a/spec/ruby/library/mathn/integer/prime_division_spec.rb
+++ b/spec/ruby/library/mathn/integer/prime_division_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
@@ -15,7 +15,7 @@ ruby_version_is ''...'2.5' do
end
it "raises a ZeroDivisionError when is called on zero" do
- -> { 0.prime_division }.should raise_error(ZeroDivisionError)
+ lambda { 0.prime_division }.should raise_error(ZeroDivisionError)
end
end
end
diff --git a/spec/ruby/library/mathn/math/rsqrt_spec.rb b/spec/ruby/library/mathn/math/rsqrt_spec.rb
index 6cb7595afe..a49efa6ff9 100644
--- a/spec/ruby/library/mathn/math/rsqrt_spec.rb
+++ b/spec/ruby/library/mathn/math/rsqrt_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
- require_relative 'shared/rsqrt'
+ require File.expand_path('../shared/rsqrt', __FILE__)
describe "Math#rsqrt" do
it_behaves_like :mathn_math_rsqrt, :_, IncludesMath.new
diff --git a/spec/ruby/library/mathn/math/shared/rsqrt.rb b/spec/ruby/library/mathn/math/shared/rsqrt.rb
index ea3d1b0cfc..68e2f7d02f 100644
--- a/spec/ruby/library/mathn/math/shared/rsqrt.rb
+++ b/spec/ruby/library/mathn/math/shared/rsqrt.rb
@@ -1,5 +1,5 @@
require 'mathn'
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :mathn_math_rsqrt, shared: true do
it "returns the square root for Rational numbers" do
@@ -14,8 +14,8 @@ describe :mathn_math_rsqrt, shared: true do
end
it "raises an Math::DomainError if the argument is a negative number" do
- -> { @object.send(:rsqrt, -1) }.should raise_error(Math::DomainError)
- -> { @object.send(:rsqrt, -4.0) }.should raise_error(Math::DomainError)
- -> { @object.send(:rsqrt, -16/64) }.should raise_error(Math::DomainError)
+ lambda { @object.send(:rsqrt, -1) }.should raise_error(Math::DomainError)
+ lambda { @object.send(:rsqrt, -4.0) }.should raise_error(Math::DomainError)
+ lambda { @object.send(:rsqrt, -16/64) }.should raise_error(Math::DomainError)
end
end
diff --git a/spec/ruby/library/mathn/math/shared/sqrt.rb b/spec/ruby/library/mathn/math/shared/sqrt.rb
index 5e6dae1d4f..6aab25fc5d 100644
--- a/spec/ruby/library/mathn/math/shared/sqrt.rb
+++ b/spec/ruby/library/mathn/math/shared/sqrt.rb
@@ -1,5 +1,5 @@
require 'mathn'
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
describe :mathn_math_sqrt, shared: true do
it "returns the square root for Rational numbers" do
diff --git a/spec/ruby/library/mathn/math/sqrt_spec.rb b/spec/ruby/library/mathn/math/sqrt_spec.rb
index 49cfe3600e..b723360891 100644
--- a/spec/ruby/library/mathn/math/sqrt_spec.rb
+++ b/spec/ruby/library/mathn/math/sqrt_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
- require_relative 'shared/sqrt'
+ require File.expand_path('../shared/sqrt', __FILE__)
describe "Math#rsqrt" do
it_behaves_like :mathn_math_sqrt, :_, IncludesMath.new
diff --git a/spec/ruby/library/mathn/mathn_spec.rb b/spec/ruby/library/mathn/mathn_spec.rb
deleted file mode 100644
index 129c8f3288..0000000000
--- a/spec/ruby/library/mathn/mathn_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "mathn" do
- ruby_version_is "2.5" do
- it "is no longer part of the standard library" do
- -> {
- require "mathn"
- }.should raise_error(LoadError) { |e|
- e.path.should == 'mathn'
- }
- end
- end
-end
diff --git a/spec/ruby/library/mathn/rational/Rational_spec.rb b/spec/ruby/library/mathn/rational/Rational_spec.rb
index 9a34c99751..71433529c5 100644
--- a/spec/ruby/library/mathn/rational/Rational_spec.rb
+++ b/spec/ruby/library/mathn/rational/Rational_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
diff --git a/spec/ruby/library/mathn/rational/inspect_spec.rb b/spec/ruby/library/mathn/rational/inspect_spec.rb
index cbf67ec0f3..ce1205faaa 100644
--- a/spec/ruby/library/mathn/rational/inspect_spec.rb
+++ b/spec/ruby/library/mathn/rational/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
ruby_version_is ''...'2.5' do
require 'mathn'
diff --git a/spec/ruby/library/matrix/I_spec.rb b/spec/ruby/library/matrix/I_spec.rb
index 6eeffe8e98..f83cc3cec4 100644
--- a/spec/ruby/library/matrix/I_spec.rb
+++ b/spec/ruby/library/matrix/I_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/identity'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/identity', __FILE__)
describe "Matrix.I" do
- it_behaves_like :matrix_identity, :I
+ it_behaves_like(:matrix_identity, :I)
end
diff --git a/spec/ruby/library/matrix/antisymmetric_spec.rb b/spec/ruby/library/matrix/antisymmetric_spec.rb
deleted file mode 100644
index 3eb0f8b726..0000000000
--- a/spec/ruby/library/matrix/antisymmetric_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require_relative '../../spec_helper'
-require 'matrix'
-
-ruby_version_is "2.6" do
- describe "Matrix#antisymmetric?" do
- it "returns true for an antisymmetric Matrix" do
- Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should be_true
- end
-
- it "returns true for a 0x0 empty matrix" do
- Matrix.empty.antisymmetric?.should be_true
- end
-
- it "returns false for non-antisymmetric matrices" do
- [
- Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
- Matrix[[1, -2, 3], [2, 0, 6], [-3, -6, 0]], # wrong diagonal element
- Matrix[[0, 2, -3], [2, 0, 6], [-3, 6, 0]] # only signs wrong
- ].each do |matrix|
- matrix.antisymmetric?.should be_false
- end
- end
-
- it "raises an error for rectangular matrices" do
- [
- Matrix[[0], [0]],
- Matrix[[0, 0]],
- Matrix.empty(0, 2),
- Matrix.empty(2, 0),
- ].each do |rectangular_matrix|
- -> {
- rectangular_matrix.antisymmetric?
- }.should raise_error(Matrix::ErrDimensionMismatch)
- end
- end
- end
-end
diff --git a/spec/ruby/library/matrix/build_spec.rb b/spec/ruby/library/matrix/build_spec.rb
index 6d8017a3df..4f80ed2b99 100644
--- a/spec/ruby/library/matrix/build_spec.rb
+++ b/spec/ruby/library/matrix/build_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.build" do
@@ -29,14 +29,14 @@ describe "Matrix.build" do
end
it "requires integers as parameters" do
- -> { Matrix.build("1", "2"){1} }.should raise_error(TypeError)
- -> { Matrix.build(nil, nil){1} }.should raise_error(TypeError)
- -> { Matrix.build(1..2){1} }.should raise_error(TypeError)
+ lambda { Matrix.build("1", "2"){1} }.should raise_error(TypeError)
+ lambda { Matrix.build(nil, nil){1} }.should raise_error(TypeError)
+ lambda { Matrix.build(1..2){1} }.should raise_error(TypeError)
end
it "requires non-negative integers" do
- -> { Matrix.build(-1, 1){1} }.should raise_error(ArgumentError)
- -> { Matrix.build(+1,-1){1} }.should raise_error(ArgumentError)
+ lambda { Matrix.build(-1, 1){1} }.should raise_error(ArgumentError)
+ lambda { Matrix.build(+1,-1){1} }.should raise_error(ArgumentError)
end
it "returns empty Matrix if one argument is zero" do
diff --git a/spec/ruby/library/matrix/clone_spec.rb b/spec/ruby/library/matrix/clone_spec.rb
index 74e5bf157e..8819fc9b40 100644
--- a/spec/ruby/library/matrix/clone_spec.rb
+++ b/spec/ruby/library/matrix/clone_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#clone" do
diff --git a/spec/ruby/library/matrix/coerce_spec.rb b/spec/ruby/library/matrix/coerce_spec.rb
index 280243d372..6e653315a6 100644
--- a/spec/ruby/library/matrix/coerce_spec.rb
+++ b/spec/ruby/library/matrix/coerce_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#coerce" do
+ it "needs to be reviewed for spec completeness"
+
it "allows the division of fixnum by a Matrix " do
(1/Matrix[[0,1],[-1,0]]).should == Matrix[[0,-1],[1,0]]
end
diff --git a/spec/ruby/library/matrix/collect_spec.rb b/spec/ruby/library/matrix/collect_spec.rb
index bba640213b..1830aed103 100644
--- a/spec/ruby/library/matrix/collect_spec.rb
+++ b/spec/ruby/library/matrix/collect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/collect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Matrix#collect" do
- it_behaves_like :collect, :collect
+ it_behaves_like(:collect, :collect)
end
diff --git a/spec/ruby/library/matrix/column_size_spec.rb b/spec/ruby/library/matrix/column_size_spec.rb
index 041914e5b9..b1aae01bbc 100644
--- a/spec/ruby/library/matrix/column_size_spec.rb
+++ b/spec/ruby/library/matrix/column_size_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#column_size" do
diff --git a/spec/ruby/library/matrix/column_spec.rb b/spec/ruby/library/matrix/column_spec.rb
index 1f3c80964a..de84e33e8d 100644
--- a/spec/ruby/library/matrix/column_spec.rb
+++ b/spec/ruby/library/matrix/column_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#column" do
@@ -29,7 +29,7 @@ describe "Matrix#column" do
end
it "never yields when out of bounds" do
- -> { @m.column(3){ raise } }.should_not raise_error
- -> { @m.column(-4){ raise } }.should_not raise_error
+ lambda { @m.column(3){ raise } }.should_not raise_error
+ lambda { @m.column(-4){ raise } }.should_not raise_error
end
end
diff --git a/spec/ruby/library/matrix/column_vector_spec.rb b/spec/ruby/library/matrix/column_vector_spec.rb
index 47e866a8d5..f0cc46d646 100644
--- a/spec/ruby/library/matrix/column_vector_spec.rb
+++ b/spec/ruby/library/matrix/column_vector_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.column_vector" do
diff --git a/spec/ruby/library/matrix/column_vectors_spec.rb b/spec/ruby/library/matrix/column_vectors_spec.rb
index b0cb6f914c..8af64f83c8 100644
--- a/spec/ruby/library/matrix/column_vectors_spec.rb
+++ b/spec/ruby/library/matrix/column_vectors_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#column_vectors" do
diff --git a/spec/ruby/library/matrix/columns_spec.rb b/spec/ruby/library/matrix/columns_spec.rb
index 3095fdd7af..b5fd5633bf 100644
--- a/spec/ruby/library/matrix/columns_spec.rb
+++ b/spec/ruby/library/matrix/columns_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.columns" do
diff --git a/spec/ruby/library/matrix/conj_spec.rb b/spec/ruby/library/matrix/conj_spec.rb
index ecee95c255..33221f7055 100644
--- a/spec/ruby/library/matrix/conj_spec.rb
+++ b/spec/ruby/library/matrix/conj_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/conjugate'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/conjugate', __FILE__)
describe "Matrix#conj" do
- it_behaves_like :matrix_conjugate, :conj
+ it_behaves_like(:matrix_conjugate, :conj)
end
diff --git a/spec/ruby/library/matrix/conjugate_spec.rb b/spec/ruby/library/matrix/conjugate_spec.rb
index 682bd41d94..fd19f7689c 100644
--- a/spec/ruby/library/matrix/conjugate_spec.rb
+++ b/spec/ruby/library/matrix/conjugate_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/conjugate'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/conjugate', __FILE__)
describe "Matrix#conjugate" do
- it_behaves_like :matrix_conjugate, :conjugate
+ it_behaves_like(:matrix_conjugate, :conjugate)
end
diff --git a/spec/ruby/library/matrix/constructor_spec.rb b/spec/ruby/library/matrix/constructor_spec.rb
index 70d77babbb..ae707166cd 100644
--- a/spec/ruby/library/matrix/constructor_spec.rb
+++ b/spec/ruby/library/matrix/constructor_spec.rb
@@ -1,14 +1,14 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.[]" do
it "requires arrays as parameters" do
- -> { Matrix[5] }.should raise_error(TypeError)
- -> { Matrix[nil] }.should raise_error(TypeError)
- -> { Matrix[1..2] }.should raise_error(TypeError)
- -> { Matrix[[1, 2], 3] }.should raise_error(TypeError)
+ lambda { Matrix[5] }.should raise_error(TypeError)
+ lambda { Matrix[nil] }.should raise_error(TypeError)
+ lambda { Matrix[1..2] }.should raise_error(TypeError)
+ lambda { Matrix[[1, 2], 3] }.should raise_error(TypeError)
end
it "creates an empty Matrix with no arguments" do
@@ -18,9 +18,9 @@ describe "Matrix.[]" do
end
it "raises for non-rectangular matrices" do
- ->{ Matrix[ [0], [0,1] ] }.should \
+ lambda{ Matrix[ [0], [0,1] ] }.should \
raise_error(Matrix::ErrDimensionMismatch)
- ->{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \
+ lambda{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \
raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/det_spec.rb b/spec/ruby/library/matrix/det_spec.rb
index aa7086cacf..698de34fd1 100644
--- a/spec/ruby/library/matrix/det_spec.rb
+++ b/spec/ruby/library/matrix/det_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/determinant'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/determinant', __FILE__)
require 'matrix'
describe "Matrix#det" do
- it_behaves_like :determinant, :det
+ it_behaves_like(:determinant, :det)
end
diff --git a/spec/ruby/library/matrix/determinant_spec.rb b/spec/ruby/library/matrix/determinant_spec.rb
index 825c9907b1..9ad34c6fc3 100644
--- a/spec/ruby/library/matrix/determinant_spec.rb
+++ b/spec/ruby/library/matrix/determinant_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/determinant'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/determinant', __FILE__)
require 'matrix'
describe "Matrix#determinant" do
- it_behaves_like :determinant, :determinant
+ it_behaves_like(:determinant, :determinant)
end
diff --git a/spec/ruby/library/matrix/diagonal_spec.rb b/spec/ruby/library/matrix/diagonal_spec.rb
index ef9738e73e..ddf5a8d292 100644
--- a/spec/ruby/library/matrix/diagonal_spec.rb
+++ b/spec/ruby/library/matrix/diagonal_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.diagonal" do
@@ -64,7 +64,7 @@ describe "Matrix.diagonal?" do
Matrix.empty(0, 2),
Matrix.empty(2, 0),
].each do |rectangular_matrix|
- -> {
+ lambda {
rectangular_matrix.diagonal?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/divide_spec.rb b/spec/ruby/library/matrix/divide_spec.rb
index 2e3bb85bf6..b602d7d10f 100644
--- a/spec/ruby/library/matrix/divide_spec.rb
+++ b/spec/ruby/library/matrix/divide_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#/" do
@@ -14,12 +14,13 @@ describe "Matrix#/" do
(@a / @b).should be_close_to_matrix([[2.5, -1.5], [1.5, -0.5]])
end
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
+ conflicts_with :Prime do
it "returns the result of dividing self by a Fixnum" do
(@a / 2).should == Matrix[ [0, 1], [1, 2] ]
end
+ end
+ conflicts_with :Prime do
it "returns the result of dividing self by a Bignum" do
(@a / bignum_value).should == Matrix[ [0, 0], [0, 0] ]
end
@@ -30,7 +31,7 @@ describe "Matrix#/" do
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- -> { @a / Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ lambda { @a / Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
end
it "returns an instance of Matrix" do
@@ -46,9 +47,9 @@ describe "Matrix#/" do
end
it "raises a TypeError if other is of wrong type" do
- -> { @a / nil }.should raise_error(TypeError)
- -> { @a / "a" }.should raise_error(TypeError)
- -> { @a / [ [1, 2] ] }.should raise_error(TypeError)
- -> { @a / Object.new }.should raise_error(TypeError)
+ lambda { @a / nil }.should raise_error(TypeError)
+ lambda { @a / "a" }.should raise_error(TypeError)
+ lambda { @a / [ [1, 2] ] }.should raise_error(TypeError)
+ lambda { @a / Object.new }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/matrix/each_spec.rb b/spec/ruby/library/matrix/each_spec.rb
index f3b0f01867..18875692e6 100644
--- a/spec/ruby/library/matrix/each_spec.rb
+++ b/spec/ruby/library/matrix/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#each" do
@@ -31,13 +31,13 @@ describe "Matrix#each with an argument" do
end
it "raises an ArgumentError for unrecognized argument" do
- -> {
+ lambda {
@m.each("all"){}
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@m.each(nil){}
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@m.each(:left){}
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/matrix/each_with_index_spec.rb b/spec/ruby/library/matrix/each_with_index_spec.rb
index a005b88621..796a6c2a96 100644
--- a/spec/ruby/library/matrix/each_with_index_spec.rb
+++ b/spec/ruby/library/matrix/each_with_index_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#each_with_index" do
@@ -38,13 +38,13 @@ describe "Matrix#each_with_index with an argument" do
end
it "raises an ArgumentError for unrecognized argument" do
- -> {
+ lambda {
@m.each_with_index("all"){}
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@m.each_with_index(nil){}
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@m.each_with_index(:left){}
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb
index 67f9dd1c19..3443eeaaf9 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvalue_matrix" do
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb
index 7552b7616c..c175a29947 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvalues" do
@@ -8,7 +8,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvalues" do
[ Complex(1, -1), Complex(1, 1)]
end
- it "returns an array of real eigenvalues for a symmetric matrix" do
+ it "returns an array of real eigenvalues for a symetric matrix" do
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvalues.sort.map!{|x| x.round(10)}.should ==
[ -1, 3 ]
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb
index 09f229ee15..709ec68d0c 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
@@ -10,7 +10,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
[Complex(0, 1), Complex(0, -1)]]
end
- it "returns an real eigenvector matrix for a symmetric matrix" do
+ it "returns an real eigenvector matrix for a symetric matrix" do
# Fix me: should test for linearity, not for equality
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvector_matrix.should ==
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb
index 2b6ce74ea8..163bebe709 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvectors" do
@@ -11,7 +11,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvectors" do
]
end
- it "returns an array of real eigenvectors for a symmetric matrix" do
+ it "returns an array of real eigenvectors for a symetric matrix" do
# Fix me: should test for linearity, not for equality
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvectors.should ==
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb
index 8438f63133..97d9be8f2d 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb
@@ -1,18 +1,18 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::EigenvalueDecomposition#initialize" do
it "raises an error if argument is not a matrix" do
- -> {
+ lambda {
Matrix::EigenvalueDecomposition.new([[]])
}.should raise_error(TypeError)
- -> {
+ lambda {
Matrix::EigenvalueDecomposition.new(42)
}.should raise_error(TypeError)
end
it "raises an error if matrix is not square" do
- -> {
+ lambda {
Matrix::EigenvalueDecomposition.new(Matrix[[1, 2]])
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb
index 8be41a5720..e9b849eb97 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::EigenvalueDecomposition#to_a" do
diff --git a/spec/ruby/library/matrix/element_reference_spec.rb b/spec/ruby/library/matrix/element_reference_spec.rb
index b950d1c391..f4f63c0f65 100644
--- a/spec/ruby/library/matrix/element_reference_spec.rb
+++ b/spec/ruby/library/matrix/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#[]" do
diff --git a/spec/ruby/library/matrix/empty_spec.rb b/spec/ruby/library/matrix/empty_spec.rb
index 5f294711db..cead6126ff 100644
--- a/spec/ruby/library/matrix/empty_spec.rb
+++ b/spec/ruby/library/matrix/empty_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#empty?" do
@@ -15,7 +15,7 @@ describe "Matrix#empty?" do
end
it "doesn't accept any parameter" do
- ->{
+ lambda{
Matrix[ [1, 2] ].empty?(42)
}.should raise_error(ArgumentError)
end
@@ -38,23 +38,23 @@ describe "Matrix.empty" do
end
it "does not accept more than two parameters" do
- ->{
+ lambda{
Matrix.empty(1, 2, 3)
}.should raise_error(ArgumentError)
end
it "raises an error if both dimensions are > 0" do
- ->{
+ lambda{
Matrix.empty(1, 2)
}.should raise_error(ArgumentError)
end
it "raises an error if any dimension is < 0" do
- ->{
+ lambda{
Matrix.empty(-2, 0)
}.should raise_error(ArgumentError)
- ->{
+ lambda{
Matrix.empty(0, -2)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/matrix/eql_spec.rb b/spec/ruby/library/matrix/eql_spec.rb
index ea26c3320d..e76d26753a 100644
--- a/spec/ruby/library/matrix/eql_spec.rb
+++ b/spec/ruby/library/matrix/eql_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
require 'matrix'
describe "Matrix#eql?" do
- it_behaves_like :equal, :eql?
+ it_behaves_like(:equal, :eql?)
it "returns false if some elements are == but not eql?" do
Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false
diff --git a/spec/ruby/library/matrix/equal_value_spec.rb b/spec/ruby/library/matrix/equal_value_spec.rb
index 10cf1e6c29..e14a38b872 100644
--- a/spec/ruby/library/matrix/equal_value_spec.rb
+++ b/spec/ruby/library/matrix/equal_value_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
-require_relative 'shared/equal_value'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/equal_value', __FILE__)
require 'matrix'
describe "Matrix#==" do
- it_behaves_like :equal, :==
+ it_behaves_like(:equal, :==)
it "returns true if some elements are == but not eql?" do
Matrix[[1, 2],[3, 4]].should == Matrix[[1, 2],[3, 4.0]]
diff --git a/spec/ruby/library/matrix/exponent_spec.rb b/spec/ruby/library/matrix/exponent_spec.rb
index 447c962967..188a1b34d2 100644
--- a/spec/ruby/library/matrix/exponent_spec.rb
+++ b/spec/ruby/library/matrix/exponent_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#**" do
@@ -17,8 +17,8 @@ describe "Matrix#**" do
it "raises a ErrDimensionMismatch for non square matrices" do
m = Matrix[ [1, 1], [1, 2], [2, 3]]
- -> { m ** 3 }.should raise_error(Matrix::ErrDimensionMismatch)
- -> { m ** 0 }.should raise_error(Matrix::ErrDimensionMismatch)
+ lambda { m ** 3 }.should raise_error(Matrix::ErrDimensionMismatch)
+ lambda { m ** 0 }.should raise_error(Matrix::ErrDimensionMismatch)
end
describe "that is <= 0" do
@@ -30,8 +30,8 @@ describe "Matrix#**" do
it "raises a ErrDimensionMismatch for irregular matrices" do
m = Matrix[ [1, 1], [1, 1] ]
- -> { m ** -2 }.should raise_error(Matrix::ErrNotRegular)
- -> { m ** 0 }.should raise_error(Matrix::ErrNotRegular)
+ lambda { m ** -2 }.should raise_error(Matrix::ErrNotRegular)
+ lambda { m ** 0 }.should raise_error(Matrix::ErrNotRegular)
end
end
end
diff --git a/spec/ruby/library/matrix/find_index_spec.rb b/spec/ruby/library/matrix/find_index_spec.rb
index c2bfa6d61a..8ea891644a 100644
--- a/spec/ruby/library/matrix/find_index_spec.rb
+++ b/spec/ruby/library/matrix/find_index_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#find_index without any argument" do
@@ -130,16 +130,16 @@ end
describe "Matrix#find_index with two arguments" do
it "raises an ArgumentError for an unrecognized last argument" do
- -> {
+ lambda {
@m.find_index(1, "all"){}
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@m.find_index(1, nil){}
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@m.find_index(1, :left){}
}.should raise_error(ArgumentError)
- -> {
+ lambda {
@m.find_index(:diagonal, 1){}
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/matrix/hash_spec.rb b/spec/ruby/library/matrix/hash_spec.rb
index fac9a06527..b2e5b579b7 100644
--- a/spec/ruby/library/matrix/hash_spec.rb
+++ b/spec/ruby/library/matrix/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#hash" do
diff --git a/spec/ruby/library/matrix/hermitian_spec.rb b/spec/ruby/library/matrix/hermitian_spec.rb
index 177ca64d83..e108ba1e34 100644
--- a/spec/ruby/library/matrix/hermitian_spec.rb
+++ b/spec/ruby/library/matrix/hermitian_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.hermitian?" do
@@ -21,7 +21,7 @@ describe "Matrix.hermitian?" do
Matrix.empty(0, 2),
Matrix.empty(2, 0),
].each do |rectangular_matrix|
- -> {
+ lambda {
rectangular_matrix.hermitian?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/identity_spec.rb b/spec/ruby/library/matrix/identity_spec.rb
index 646462bc47..bc7df98dde 100644
--- a/spec/ruby/library/matrix/identity_spec.rb
+++ b/spec/ruby/library/matrix/identity_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/identity'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/identity', __FILE__)
describe "Matrix.identity" do
- it_behaves_like :matrix_identity, :identity
+ it_behaves_like(:matrix_identity, :identity)
end
diff --git a/spec/ruby/library/matrix/imag_spec.rb b/spec/ruby/library/matrix/imag_spec.rb
index 1c988753d8..41083879e4 100644
--- a/spec/ruby/library/matrix/imag_spec.rb
+++ b/spec/ruby/library/matrix/imag_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/imaginary'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/imaginary', __FILE__)
describe "Matrix#imag" do
- it_behaves_like :matrix_imaginary, :imag
+ it_behaves_like(:matrix_imaginary, :imag)
end
diff --git a/spec/ruby/library/matrix/imaginary_spec.rb b/spec/ruby/library/matrix/imaginary_spec.rb
index ceae4bbe8d..2a05f1d5c3 100644
--- a/spec/ruby/library/matrix/imaginary_spec.rb
+++ b/spec/ruby/library/matrix/imaginary_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/imaginary'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/imaginary', __FILE__)
describe "Matrix#imaginary" do
- it_behaves_like :matrix_imaginary, :imaginary
+ it_behaves_like(:matrix_imaginary, :imaginary)
end
diff --git a/spec/ruby/library/matrix/inspect_spec.rb b/spec/ruby/library/matrix/inspect_spec.rb
index 508f478252..bf623e1a85 100644
--- a/spec/ruby/library/matrix/inspect_spec.rb
+++ b/spec/ruby/library/matrix/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#inspect" do
diff --git a/spec/ruby/library/matrix/inv_spec.rb b/spec/ruby/library/matrix/inv_spec.rb
index 82879a6d82..0491aa7b07 100644
--- a/spec/ruby/library/matrix/inv_spec.rb
+++ b/spec/ruby/library/matrix/inv_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'shared/inverse'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../shared/inverse', __FILE__)
describe "Matrix#inv" do
- it_behaves_like :inverse, :inv
+ it_behaves_like(:inverse, :inv)
end
diff --git a/spec/ruby/library/matrix/inverse_from_spec.rb b/spec/ruby/library/matrix/inverse_from_spec.rb
index 651d56a244..958b3b7408 100644
--- a/spec/ruby/library/matrix/inverse_from_spec.rb
+++ b/spec/ruby/library/matrix/inverse_from_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#inverse_from" do
diff --git a/spec/ruby/library/matrix/inverse_spec.rb b/spec/ruby/library/matrix/inverse_spec.rb
index fa3fa7de8a..33a1f2f5de 100644
--- a/spec/ruby/library/matrix/inverse_spec.rb
+++ b/spec/ruby/library/matrix/inverse_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'shared/inverse'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../shared/inverse', __FILE__)
describe "Matrix#inverse" do
- it_behaves_like :inverse, :inverse
+ it_behaves_like(:inverse, :inverse)
end
diff --git a/spec/ruby/library/matrix/lower_triangular_spec.rb b/spec/ruby/library/matrix/lower_triangular_spec.rb
index f3aa4501f4..62b3df2104 100644
--- a/spec/ruby/library/matrix/lower_triangular_spec.rb
+++ b/spec/ruby/library/matrix/lower_triangular_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.lower_triangular?" do
diff --git a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb
index 9d733066c1..f73c65ba8f 100644
--- a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::LUPDecomposition#determinant" do
@@ -13,7 +13,7 @@ describe "Matrix::LUPDecomposition#determinant" do
Matrix[[7, 8], [14, 46], [28, 82]],
].each do |m|
lup = m.lup
- -> {
+ lambda {
lup.determinant
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb
index 36afb349e6..953389083f 100644
--- a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb
@@ -1,12 +1,12 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::LUPDecomposition#initialize" do
it "raises an error if argument is not a matrix" do
- -> {
+ lambda {
Matrix::LUPDecomposition.new([[]])
}.should raise_error(TypeError)
- -> {
+ lambda {
Matrix::LUPDecomposition.new(42)
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/l_spec.rb b/spec/ruby/library/matrix/lup_decomposition/l_spec.rb
index 9514ab5d06..c50b5f712e 100644
--- a/spec/ruby/library/matrix/lup_decomposition/l_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/l_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::LUPDecomposition#l" do
diff --git a/spec/ruby/library/matrix/lup_decomposition/p_spec.rb b/spec/ruby/library/matrix/lup_decomposition/p_spec.rb
index c7b5e9196e..837b65a915 100644
--- a/spec/ruby/library/matrix/lup_decomposition/p_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/p_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::LUPDecomposition#p" do
diff --git a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb
index 66242627e9..c4ef42bcea 100644
--- a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::LUPDecomposition#solve" do
@@ -6,7 +6,7 @@ describe "Matrix::LUPDecomposition#solve" do
it "raises an error for singular matrices" do
a = Matrix[[1, 2, 3], [1, 3, 5], [2, 5, 8]]
lu = Matrix::LUPDecomposition.new(a)
- -> {
+ lambda {
lu.solve(a)
}.should raise_error(Matrix::ErrNotRegular)
end
@@ -31,7 +31,7 @@ describe "Matrix::LUPDecomposition#solve" do
it "raises an error when given a matrix of the wrong size" do
values = Matrix[[1, 2, 3, 4], [0, 1, 2, 3]]
- -> {
+ lambda {
@lu.solve(values)
}.should raise_error(Matrix::ErrDimensionMismatch)
end
@@ -44,7 +44,7 @@ describe "Matrix::LUPDecomposition#solve" do
it "raises an error when given a vector of the wrong size" do
values = Vector[14, 55]
- -> {
+ lambda {
@lu.solve(values)
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb b/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb
index 9b1dccbbac..20be26eb9c 100644
--- a/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::LUPDecomposition#to_a" do
diff --git a/spec/ruby/library/matrix/lup_decomposition/u_spec.rb b/spec/ruby/library/matrix/lup_decomposition/u_spec.rb
index ca3dfc1f00..97e8580c58 100644
--- a/spec/ruby/library/matrix/lup_decomposition/u_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/u_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::LUPDecomposition#u" do
diff --git a/spec/ruby/library/matrix/map_spec.rb b/spec/ruby/library/matrix/map_spec.rb
index bc07c48cda..e18ab6eb7a 100644
--- a/spec/ruby/library/matrix/map_spec.rb
+++ b/spec/ruby/library/matrix/map_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/collect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/collect', __FILE__)
describe "Matrix#map" do
- it_behaves_like :collect, :map
+ it_behaves_like(:collect, :map)
end
diff --git a/spec/ruby/library/matrix/minor_spec.rb b/spec/ruby/library/matrix/minor_spec.rb
index 009826c3d6..e02e0de07d 100644
--- a/spec/ruby/library/matrix/minor_spec.rb
+++ b/spec/ruby/library/matrix/minor_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#minor" do
diff --git a/spec/ruby/library/matrix/minus_spec.rb b/spec/ruby/library/matrix/minus_spec.rb
index 95cf4a6072..fe2d716882 100644
--- a/spec/ruby/library/matrix/minus_spec.rb
+++ b/spec/ruby/library/matrix/minus_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#-" do
@@ -17,20 +17,20 @@ describe "Matrix#-" do
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- -> { @a - Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ lambda { @a - Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
end
it "raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type" do
- -> { @a - 2 }.should raise_error(Matrix::ErrOperationNotDefined)
- -> { @a - 1.2 }.should raise_error(Matrix::ErrOperationNotDefined)
- -> { @a - bignum_value }.should raise_error(Matrix::ErrOperationNotDefined)
+ lambda { @a - 2 }.should raise_error(Matrix::ErrOperationNotDefined)
+ lambda { @a - 1.2 }.should raise_error(Matrix::ErrOperationNotDefined)
+ lambda { @a - bignum_value }.should raise_error(Matrix::ErrOperationNotDefined)
end
it "raises a TypeError if other is of wrong type" do
- -> { @a - nil }.should raise_error(TypeError)
- -> { @a - "a" }.should raise_error(TypeError)
- -> { @a - [ [1, 2] ] }.should raise_error(TypeError)
- -> { @a - Object.new }.should raise_error(TypeError)
+ lambda { @a - nil }.should raise_error(TypeError)
+ lambda { @a - "a" }.should raise_error(TypeError)
+ lambda { @a - [ [1, 2] ] }.should raise_error(TypeError)
+ lambda { @a - Object.new }.should raise_error(TypeError)
end
describe "for a subclass of Matrix" do
diff --git a/spec/ruby/library/matrix/multiply_spec.rb b/spec/ruby/library/matrix/multiply_spec.rb
index 585f268931..dae87f5434 100644
--- a/spec/ruby/library/matrix/multiply_spec.rb
+++ b/spec/ruby/library/matrix/multiply_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#*" do
@@ -32,7 +32,7 @@ describe "Matrix#*" do
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- -> { @a * Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ lambda { @a * Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
end
it "returns a zero matrix if (nx0) * (0xn)" do
@@ -52,10 +52,10 @@ describe "Matrix#*" do
end
it "raises a TypeError if other is of wrong type" do
- -> { @a * nil }.should raise_error(TypeError)
- -> { @a * "a" }.should raise_error(TypeError)
- -> { @a * [ [1, 2] ] }.should raise_error(TypeError)
- -> { @a * Object.new }.should raise_error(TypeError)
+ lambda { @a * nil }.should raise_error(TypeError)
+ lambda { @a * "a" }.should raise_error(TypeError)
+ lambda { @a * [ [1, 2] ] }.should raise_error(TypeError)
+ lambda { @a * Object.new }.should raise_error(TypeError)
end
describe "for a subclass of Matrix" do
diff --git a/spec/ruby/library/matrix/new_spec.rb b/spec/ruby/library/matrix/new_spec.rb
index 3005066846..82d2bd88a7 100644
--- a/spec/ruby/library/matrix/new_spec.rb
+++ b/spec/ruby/library/matrix/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.new" do
diff --git a/spec/ruby/library/matrix/normal_spec.rb b/spec/ruby/library/matrix/normal_spec.rb
index ebd73aaf40..5f0b8e6362 100644
--- a/spec/ruby/library/matrix/normal_spec.rb
+++ b/spec/ruby/library/matrix/normal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.normal?" do
@@ -18,7 +18,7 @@ describe "Matrix.normal?" do
Matrix.empty(0, 2),
Matrix.empty(2, 0),
].each do |rectangular_matrix|
- -> {
+ lambda {
rectangular_matrix.normal?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/orthogonal_spec.rb b/spec/ruby/library/matrix/orthogonal_spec.rb
index 07b098a58d..78f5c1be5d 100644
--- a/spec/ruby/library/matrix/orthogonal_spec.rb
+++ b/spec/ruby/library/matrix/orthogonal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.orthogonal?" do
@@ -18,7 +18,7 @@ describe "Matrix.orthogonal?" do
Matrix.empty(0, 2),
Matrix.empty(2, 0),
].each do |rectangular_matrix|
- -> {
+ lambda {
rectangular_matrix.orthogonal?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/permutation_spec.rb b/spec/ruby/library/matrix/permutation_spec.rb
index 825a9d982c..f40de4f58f 100644
--- a/spec/ruby/library/matrix/permutation_spec.rb
+++ b/spec/ruby/library/matrix/permutation_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#permutation?" do
@@ -24,7 +24,7 @@ describe "Matrix#permutation?" do
Matrix.empty(0, 2),
Matrix.empty(2, 0),
].each do |rectangular_matrix|
- -> {
+ lambda {
rectangular_matrix.permutation?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/plus_spec.rb b/spec/ruby/library/matrix/plus_spec.rb
index 2706bad060..59addfdf62 100644
--- a/spec/ruby/library/matrix/plus_spec.rb
+++ b/spec/ruby/library/matrix/plus_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#+" do
@@ -17,20 +17,20 @@ describe "Matrix#+" do
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- -> { @a + Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ lambda { @a + Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
end
it "raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type" do
- -> { @a + 2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
- -> { @a + 1.2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
- -> { @a + bignum_value }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
+ lambda { @a + 2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
+ lambda { @a + 1.2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
+ lambda { @a + bignum_value }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
end
it "raises a TypeError if other is of wrong type" do
- -> { @a + nil }.should raise_error(TypeError)
- -> { @a + "a" }.should raise_error(TypeError)
- -> { @a + [ [1, 2] ] }.should raise_error(TypeError)
- -> { @a + Object.new }.should raise_error(TypeError)
+ lambda { @a + nil }.should raise_error(TypeError)
+ lambda { @a + "a" }.should raise_error(TypeError)
+ lambda { @a + [ [1, 2] ] }.should raise_error(TypeError)
+ lambda { @a + Object.new }.should raise_error(TypeError)
end
describe "for a subclass of Matrix" do
diff --git a/spec/ruby/library/matrix/rank_spec.rb b/spec/ruby/library/matrix/rank_spec.rb
index d4403d23ed..42b6de1ab8 100644
--- a/spec/ruby/library/matrix/rank_spec.rb
+++ b/spec/ruby/library/matrix/rank_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#rank" do
diff --git a/spec/ruby/library/matrix/real_spec.rb b/spec/ruby/library/matrix/real_spec.rb
index 38033c63c8..98da7f8a7c 100644
--- a/spec/ruby/library/matrix/real_spec.rb
+++ b/spec/ruby/library/matrix/real_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#real?" do
@@ -16,8 +16,7 @@ describe "Matrix#real?" do
Matrix[ [Complex(1,1), 2], [3, 4] ].real?.should be_false
end
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
+ conflicts_with :CMath do
it "returns false if one element is a Complex whose imaginary part is 0" do
Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should be_false
end
diff --git a/spec/ruby/library/matrix/rect_spec.rb b/spec/ruby/library/matrix/rect_spec.rb
index 83a0404e47..d0a3b2705b 100644
--- a/spec/ruby/library/matrix/rect_spec.rb
+++ b/spec/ruby/library/matrix/rect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rectangular'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rectangular', __FILE__)
describe "Matrix#rect" do
- it_behaves_like :matrix_rectangular, :rect
+ it_behaves_like(:matrix_rectangular, :rect)
end
diff --git a/spec/ruby/library/matrix/rectangular_spec.rb b/spec/ruby/library/matrix/rectangular_spec.rb
index a235fac640..7af446cb18 100644
--- a/spec/ruby/library/matrix/rectangular_spec.rb
+++ b/spec/ruby/library/matrix/rectangular_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rectangular'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rectangular', __FILE__)
describe "Matrix#rectangular" do
- it_behaves_like :matrix_rectangular, :rectangular
+ it_behaves_like(:matrix_rectangular, :rectangular)
end
diff --git a/spec/ruby/library/matrix/regular_spec.rb b/spec/ruby/library/matrix/regular_spec.rb
index 3699d0ef8b..2f0af99c1e 100644
--- a/spec/ruby/library/matrix/regular_spec.rb
+++ b/spec/ruby/library/matrix/regular_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#regular?" do
@@ -20,11 +20,11 @@ describe "Matrix#regular?" do
end
it "raises an error for rectangular matrices" do
- -> {
+ lambda {
Matrix[[1], [2], [3]].regular?
}.should raise_error(Matrix::ErrDimensionMismatch)
- -> {
+ lambda {
Matrix.empty(3,0).regular?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/round_spec.rb b/spec/ruby/library/matrix/round_spec.rb
index 1dc29df890..f502a35c68 100644
--- a/spec/ruby/library/matrix/round_spec.rb
+++ b/spec/ruby/library/matrix/round_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix#round" do
diff --git a/spec/ruby/library/matrix/row_size_spec.rb b/spec/ruby/library/matrix/row_size_spec.rb
index eb3aef2e2f..ee685ba5fb 100644
--- a/spec/ruby/library/matrix/row_size_spec.rb
+++ b/spec/ruby/library/matrix/row_size_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#row_size" do
diff --git a/spec/ruby/library/matrix/row_spec.rb b/spec/ruby/library/matrix/row_spec.rb
index 00b1f02a8e..e165e48f5f 100644
--- a/spec/ruby/library/matrix/row_spec.rb
+++ b/spec/ruby/library/matrix/row_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#row" do
@@ -30,7 +30,7 @@ describe "Matrix#row" do
end
it "never yields when out of bounds" do
- -> { @m.row(3){ raise } }.should_not raise_error
- -> { @m.row(-4){ raise } }.should_not raise_error
+ lambda { @m.row(3){ raise } }.should_not raise_error
+ lambda { @m.row(-4){ raise } }.should_not raise_error
end
end
diff --git a/spec/ruby/library/matrix/row_vector_spec.rb b/spec/ruby/library/matrix/row_vector_spec.rb
index 341437ee05..60907e9247 100644
--- a/spec/ruby/library/matrix/row_vector_spec.rb
+++ b/spec/ruby/library/matrix/row_vector_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.row_vector" do
diff --git a/spec/ruby/library/matrix/row_vectors_spec.rb b/spec/ruby/library/matrix/row_vectors_spec.rb
index 6f99c439a6..46f97bb748 100644
--- a/spec/ruby/library/matrix/row_vectors_spec.rb
+++ b/spec/ruby/library/matrix/row_vectors_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#row_vectors" do
diff --git a/spec/ruby/library/matrix/rows_spec.rb b/spec/ruby/library/matrix/rows_spec.rb
index 41ba635775..d583a07b30 100644
--- a/spec/ruby/library/matrix/rows_spec.rb
+++ b/spec/ruby/library/matrix/rows_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.rows" do
diff --git a/spec/ruby/library/matrix/scalar/Fail_spec.rb b/spec/ruby/library/matrix/scalar/Fail_spec.rb
index 9d8f9bd5e8..fbd0f3013a 100644
--- a/spec/ruby/library/matrix/scalar/Fail_spec.rb
+++ b/spec/ruby/library/matrix/scalar/Fail_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#Fail" do
diff --git a/spec/ruby/library/matrix/scalar/Raise_spec.rb b/spec/ruby/library/matrix/scalar/Raise_spec.rb
index 27e11c1f77..3e98fcb22a 100644
--- a/spec/ruby/library/matrix/scalar/Raise_spec.rb
+++ b/spec/ruby/library/matrix/scalar/Raise_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#Raise" do
diff --git a/spec/ruby/library/matrix/scalar/divide_spec.rb b/spec/ruby/library/matrix/scalar/divide_spec.rb
index 5d726943fe..6b8e0b6bcc 100644
--- a/spec/ruby/library/matrix/scalar/divide_spec.rb
+++ b/spec/ruby/library/matrix/scalar/divide_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#/" do
diff --git a/spec/ruby/library/matrix/scalar/exponent_spec.rb b/spec/ruby/library/matrix/scalar/exponent_spec.rb
index 8e9ef52ff2..55997793eb 100644
--- a/spec/ruby/library/matrix/scalar/exponent_spec.rb
+++ b/spec/ruby/library/matrix/scalar/exponent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#**" do
diff --git a/spec/ruby/library/matrix/scalar/included_spec.rb b/spec/ruby/library/matrix/scalar/included_spec.rb
index cb3beb2ecd..58ee233eb3 100644
--- a/spec/ruby/library/matrix/scalar/included_spec.rb
+++ b/spec/ruby/library/matrix/scalar/included_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar.included" do
diff --git a/spec/ruby/library/matrix/scalar/initialize_spec.rb b/spec/ruby/library/matrix/scalar/initialize_spec.rb
index 23145ad0de..fd6ef00211 100644
--- a/spec/ruby/library/matrix/scalar/initialize_spec.rb
+++ b/spec/ruby/library/matrix/scalar/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#initialize" do
diff --git a/spec/ruby/library/matrix/scalar/minus_spec.rb b/spec/ruby/library/matrix/scalar/minus_spec.rb
index c727ea1659..19a7b4f1a1 100644
--- a/spec/ruby/library/matrix/scalar/minus_spec.rb
+++ b/spec/ruby/library/matrix/scalar/minus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#-" do
diff --git a/spec/ruby/library/matrix/scalar/multiply_spec.rb b/spec/ruby/library/matrix/scalar/multiply_spec.rb
index 1a2a83d83e..247cc1447c 100644
--- a/spec/ruby/library/matrix/scalar/multiply_spec.rb
+++ b/spec/ruby/library/matrix/scalar/multiply_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#*" do
diff --git a/spec/ruby/library/matrix/scalar/plus_spec.rb b/spec/ruby/library/matrix/scalar/plus_spec.rb
index c94689a702..7cdaa1c7f3 100644
--- a/spec/ruby/library/matrix/scalar/plus_spec.rb
+++ b/spec/ruby/library/matrix/scalar/plus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix::Scalar#+" do
diff --git a/spec/ruby/library/matrix/scalar_spec.rb b/spec/ruby/library/matrix/scalar_spec.rb
index 7fdd64c9d9..3da8771471 100644
--- a/spec/ruby/library/matrix/scalar_spec.rb
+++ b/spec/ruby/library/matrix/scalar_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.scalar" do
diff --git a/spec/ruby/library/matrix/shared/collect.rb b/spec/ruby/library/matrix/shared/collect.rb
index 852f7fd6cf..256cd6a190 100644
--- a/spec/ruby/library/matrix/shared/collect.rb
+++ b/spec/ruby/library/matrix/shared/collect.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :collect, shared: true do
diff --git a/spec/ruby/library/matrix/shared/conjugate.rb b/spec/ruby/library/matrix/shared/conjugate.rb
index d87658f855..180ff4fa98 100644
--- a/spec/ruby/library/matrix/shared/conjugate.rb
+++ b/spec/ruby/library/matrix/shared/conjugate.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :matrix_conjugate, shared: true do
diff --git a/spec/ruby/library/matrix/shared/determinant.rb b/spec/ruby/library/matrix/shared/determinant.rb
index 9e0528c24b..47a58c62a6 100644
--- a/spec/ruby/library/matrix/shared/determinant.rb
+++ b/spec/ruby/library/matrix/shared/determinant.rb
@@ -27,11 +27,11 @@ describe :determinant, shared: true do
end
it "raises an error for rectangular matrices" do
- -> {
+ lambda {
Matrix[[1], [2], [3]].send(@method)
}.should raise_error(Matrix::ErrDimensionMismatch)
- -> {
+ lambda {
Matrix.empty(3,0).send(@method)
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/shared/equal_value.rb b/spec/ruby/library/matrix/shared/equal_value.rb
index 2b2311d49e..e2102e823a 100644
--- a/spec/ruby/library/matrix/shared/equal_value.rb
+++ b/spec/ruby/library/matrix/shared/equal_value.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :equal, shared: true do
diff --git a/spec/ruby/library/matrix/shared/identity.rb b/spec/ruby/library/matrix/shared/identity.rb
index 114f86e7b0..20b35ae8e3 100644
--- a/spec/ruby/library/matrix/shared/identity.rb
+++ b/spec/ruby/library/matrix/shared/identity.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :matrix_identity, shared: true do
diff --git a/spec/ruby/library/matrix/shared/imaginary.rb b/spec/ruby/library/matrix/shared/imaginary.rb
index d28ecc69f1..61a65a62ec 100644
--- a/spec/ruby/library/matrix/shared/imaginary.rb
+++ b/spec/ruby/library/matrix/shared/imaginary.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :matrix_imaginary, shared: true do
diff --git a/spec/ruby/library/matrix/shared/inverse.rb b/spec/ruby/library/matrix/shared/inverse.rb
index c8a6b90da5..c6996df4a3 100644
--- a/spec/ruby/library/matrix/shared/inverse.rb
+++ b/spec/ruby/library/matrix/shared/inverse.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :inverse, shared: true do
@@ -25,7 +25,7 @@ describe :inverse, shared: true do
end
it "raises a ErrDimensionMismatch if the Matrix is not square" do
- ->{
+ lambda{
Matrix[ [1,2,3], [1,2,3] ].send(@method)
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/shared/rectangular.rb b/spec/ruby/library/matrix/shared/rectangular.rb
index 3d9a0dfe8a..4206311586 100644
--- a/spec/ruby/library/matrix/shared/rectangular.rb
+++ b/spec/ruby/library/matrix/shared/rectangular.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :matrix_rectangular, shared: true do
diff --git a/spec/ruby/library/matrix/shared/trace.rb b/spec/ruby/library/matrix/shared/trace.rb
index 57b89863f8..2a42839f5d 100644
--- a/spec/ruby/library/matrix/shared/trace.rb
+++ b/spec/ruby/library/matrix/shared/trace.rb
@@ -6,7 +6,7 @@ describe :trace, shared: true do
end
it "returns the sum of diagonal elements in a rectangular Matrix" do
- ->{ Matrix[[1,2,3], [4,5,6]].trace}.should raise_error(Matrix::ErrDimensionMismatch)
+ lambda{ Matrix[[1,2,3], [4,5,6]].trace}.should raise_error(Matrix::ErrDimensionMismatch)
end
end
diff --git a/spec/ruby/library/matrix/shared/transpose.rb b/spec/ruby/library/matrix/shared/transpose.rb
index 89b1d025be..dba6c71041 100644
--- a/spec/ruby/library/matrix/shared/transpose.rb
+++ b/spec/ruby/library/matrix/shared/transpose.rb
@@ -1,4 +1,4 @@
-require_relative '../fixtures/classes'
+require File.expand_path('../../fixtures/classes', __FILE__)
require 'matrix'
describe :matrix_transpose, shared: true do
diff --git a/spec/ruby/library/matrix/singular_spec.rb b/spec/ruby/library/matrix/singular_spec.rb
index 7bba36a54a..83914befbe 100644
--- a/spec/ruby/library/matrix/singular_spec.rb
+++ b/spec/ruby/library/matrix/singular_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#singular?" do
@@ -19,11 +19,11 @@ describe "Matrix#singular?" do
end
it "raises an error for rectangular matrices" do
- -> {
+ lambda {
Matrix[[1], [2], [3]].singular?
}.should raise_error(Matrix::ErrDimensionMismatch)
- -> {
+ lambda {
Matrix.empty(3,0).singular?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/square_spec.rb b/spec/ruby/library/matrix/square_spec.rb
index 25d2d1ad9c..a117916a4c 100644
--- a/spec/ruby/library/matrix/square_spec.rb
+++ b/spec/ruby/library/matrix/square_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#square?" do
diff --git a/spec/ruby/library/matrix/symmetric_spec.rb b/spec/ruby/library/matrix/symmetric_spec.rb
index 6f2a99276a..c34a323510 100644
--- a/spec/ruby/library/matrix/symmetric_spec.rb
+++ b/spec/ruby/library/matrix/symmetric_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.symmetric?" do
@@ -21,7 +21,7 @@ describe "Matrix.symmetric?" do
Matrix.empty(0, 2),
Matrix.empty(2, 0),
].each do |rectangular_matrix|
- -> {
+ lambda {
rectangular_matrix.symmetric?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/t_spec.rb b/spec/ruby/library/matrix/t_spec.rb
index 6f1a5178e0..1c57c25de3 100644
--- a/spec/ruby/library/matrix/t_spec.rb
+++ b/spec/ruby/library/matrix/t_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/transpose'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/transpose', __FILE__)
describe "Matrix#transpose" do
- it_behaves_like :matrix_transpose, :t
+ it_behaves_like(:matrix_transpose, :t)
end
diff --git a/spec/ruby/library/matrix/to_a_spec.rb b/spec/ruby/library/matrix/to_a_spec.rb
index b5d55c5d67..70db580312 100644
--- a/spec/ruby/library/matrix/to_a_spec.rb
+++ b/spec/ruby/library/matrix/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#to_a" do
diff --git a/spec/ruby/library/matrix/to_s_spec.rb b/spec/ruby/library/matrix/to_s_spec.rb
index f529fe3bcd..eb175d486b 100644
--- a/spec/ruby/library/matrix/to_s_spec.rb
+++ b/spec/ruby/library/matrix/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix#to_s" do
diff --git a/spec/ruby/library/matrix/tr_spec.rb b/spec/ruby/library/matrix/tr_spec.rb
index e17bd790d7..4b07a70203 100644
--- a/spec/ruby/library/matrix/tr_spec.rb
+++ b/spec/ruby/library/matrix/tr_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/trace'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/trace', __FILE__)
require 'matrix'
describe "Matrix#tr" do
- it_behaves_like :trace, :tr
+ it_behaves_like(:trace, :tr)
end
diff --git a/spec/ruby/library/matrix/trace_spec.rb b/spec/ruby/library/matrix/trace_spec.rb
index 290e7cb1f7..08adb256c0 100644
--- a/spec/ruby/library/matrix/trace_spec.rb
+++ b/spec/ruby/library/matrix/trace_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/trace'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/trace', __FILE__)
require 'matrix'
describe "Matrix#trace" do
- it_behaves_like :trace, :trace
+ it_behaves_like(:trace, :trace)
end
diff --git a/spec/ruby/library/matrix/transpose_spec.rb b/spec/ruby/library/matrix/transpose_spec.rb
index 79600dd439..2a30a80efc 100644
--- a/spec/ruby/library/matrix/transpose_spec.rb
+++ b/spec/ruby/library/matrix/transpose_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/transpose'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/transpose', __FILE__)
describe "Matrix#transpose" do
- it_behaves_like :matrix_transpose, :transpose
+ it_behaves_like(:matrix_transpose, :transpose)
end
diff --git a/spec/ruby/library/matrix/unit_spec.rb b/spec/ruby/library/matrix/unit_spec.rb
index 6a41d729c7..058d719043 100644
--- a/spec/ruby/library/matrix/unit_spec.rb
+++ b/spec/ruby/library/matrix/unit_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/identity'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/identity', __FILE__)
describe "Matrix.unit" do
- it_behaves_like :matrix_identity, :unit
+ it_behaves_like(:matrix_identity, :unit)
end
diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb
index 9c2a106ea5..0ea5586a6d 100644
--- a/spec/ruby/library/matrix/unitary_spec.rb
+++ b/spec/ruby/library/matrix/unitary_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.unitary?" do
@@ -20,7 +20,7 @@ describe "Matrix.unitary?" do
Matrix.empty(0, 2),
Matrix.empty(2, 0),
].each do |rectangular_matrix|
- -> {
+ lambda {
rectangular_matrix.unitary?
}.should raise_error(Matrix::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/upper_triangular_spec.rb b/spec/ruby/library/matrix/upper_triangular_spec.rb
index 2514294a80..be88150b85 100644
--- a/spec/ruby/library/matrix/upper_triangular_spec.rb
+++ b/spec/ruby/library/matrix/upper_triangular_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'matrix'
describe "Matrix.upper_triangular?" do
diff --git a/spec/ruby/library/matrix/vector/cross_product_spec.rb b/spec/ruby/library/matrix/vector/cross_product_spec.rb
index c2698ade4c..f26cf585da 100644
--- a/spec/ruby/library/matrix/vector/cross_product_spec.rb
+++ b/spec/ruby/library/matrix/vector/cross_product_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Vector#cross_product" do
@@ -7,7 +7,7 @@ describe "Vector#cross_product" do
end
it "raises an error unless both vectors have dimension 3" do
- -> {
+ lambda {
Vector[1, 2, 3].cross_product(Vector[0, -4])
}.should raise_error(Vector::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/vector/each2_spec.rb b/spec/ruby/library/matrix/vector/each2_spec.rb
index 10d2fc404d..e9d89e21c4 100644
--- a/spec/ruby/library/matrix/vector/each2_spec.rb
+++ b/spec/ruby/library/matrix/vector/each2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Vector.each2" do
@@ -8,8 +8,8 @@ describe "Vector.each2" do
end
it "requires one argument" do
- -> { @v.each2(@v2, @v2){} }.should raise_error(ArgumentError)
- -> { @v.each2(){} }.should raise_error(ArgumentError)
+ lambda { @v.each2(@v2, @v2){} }.should raise_error(ArgumentError)
+ lambda { @v.each2(){} }.should raise_error(ArgumentError)
end
describe "given one argument" do
@@ -20,8 +20,8 @@ describe "Vector.each2" do
end
it "raises a DimensionMismatch error if the Vector size is different" do
- -> { @v.each2(Vector[1,2]){} }.should raise_error(Vector::ErrDimensionMismatch)
- -> { @v.each2(Vector[1,2,3,4]){} }.should raise_error(Vector::ErrDimensionMismatch)
+ lambda { @v.each2(Vector[1,2]){} }.should raise_error(Vector::ErrDimensionMismatch)
+ lambda { @v.each2(Vector[1,2,3,4]){} }.should raise_error(Vector::ErrDimensionMismatch)
end
it "yields arguments in sequence" do
diff --git a/spec/ruby/library/matrix/vector/eql_spec.rb b/spec/ruby/library/matrix/vector/eql_spec.rb
index eb2451b550..6cc69bbf7d 100644
--- a/spec/ruby/library/matrix/vector/eql_spec.rb
+++ b/spec/ruby/library/matrix/vector/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Vector#eql?" do
diff --git a/spec/ruby/library/matrix/vector/inner_product_spec.rb b/spec/ruby/library/matrix/vector/inner_product_spec.rb
index 1cf8771e04..a953598b51 100644
--- a/spec/ruby/library/matrix/vector/inner_product_spec.rb
+++ b/spec/ruby/library/matrix/vector/inner_product_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Vector#inner_product" do
@@ -11,7 +11,7 @@ describe "Vector#inner_product" do
end
it "raises an error for mismatched vectors" do
- -> {
+ lambda {
Vector[1, 2, 3].inner_product(Vector[0, -4])
}.should raise_error(Vector::ErrDimensionMismatch)
end
diff --git a/spec/ruby/library/matrix/vector/normalize_spec.rb b/spec/ruby/library/matrix/vector/normalize_spec.rb
index 527c9260de..14aac1f5e3 100644
--- a/spec/ruby/library/matrix/vector/normalize_spec.rb
+++ b/spec/ruby/library/matrix/vector/normalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'
describe "Vector#normalize" do
@@ -8,10 +8,10 @@ describe "Vector#normalize" do
end
it "raises an error for zero vectors" do
- -> {
+ lambda {
Vector[].normalize
}.should raise_error(Vector::ZeroVectorError)
- -> {
+ lambda {
Vector[0, 0, 0].normalize
}.should raise_error(Vector::ZeroVectorError)
end
diff --git a/spec/ruby/library/matrix/zero_spec.rb b/spec/ruby/library/matrix/zero_spec.rb
index 643c57acba..f83d29e837 100644
--- a/spec/ruby/library/matrix/zero_spec.rb
+++ b/spec/ruby/library/matrix/zero_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
require 'matrix'
describe "Matrix.zero" do
diff --git a/spec/ruby/library/mkmf/mkmf_spec.rb b/spec/ruby/library/mkmf/mkmf_spec.rb
deleted file mode 100644
index 18b090e703..0000000000
--- a/spec/ruby/library/mkmf/mkmf_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require_relative '../../spec_helper'
-
-describe 'mkmf' do
- it 'can be required with --enable-frozen-string-literal' do
- ruby_exe('p MakeMakefile', options: '-rmkmf --enable-frozen-string-literal').should == "MakeMakefile\n"
- end
-end
diff --git a/spec/ruby/library/monitor/mon_initialize_spec.rb b/spec/ruby/library/monitor/mon_initialize_spec.rb
deleted file mode 100644
index e0fe6c2d97..0000000000
--- a/spec/ruby/library/monitor/mon_initialize_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require_relative '../../spec_helper'
-require 'monitor'
-
-describe "MonitorMixin#mon_initialize" do
- it "can be called in initialize_copy to get a new Mutex and used with synchronize" do
- cls = Class.new do
- include MonitorMixin
-
- def initialize(*array)
- mon_initialize
- @array = array
- end
-
- def to_a
- synchronize { @array.dup }
- end
-
- def initialize_copy(other)
- mon_initialize
-
- synchronize do
- @array = other.to_a
- end
- end
- end
-
- instance = cls.new(1, 2, 3)
- copy = instance.dup
- copy.should_not equal(instance)
- end
-end
diff --git a/spec/ruby/library/net/FTPError_spec.rb b/spec/ruby/library/net/FTPError_spec.rb
index 0c31b65dcc..7cc06f681a 100644
--- a/spec/ruby/library/net/FTPError_spec.rb
+++ b/spec/ruby/library/net/FTPError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'net/ftp'
describe "Net::FTPError" do
diff --git a/spec/ruby/library/net/FTPPermError_spec.rb b/spec/ruby/library/net/FTPPermError_spec.rb
index b43e12c503..d9a7189468 100644
--- a/spec/ruby/library/net/FTPPermError_spec.rb
+++ b/spec/ruby/library/net/FTPPermError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'net/ftp'
describe "Net::FTPPermError" do
diff --git a/spec/ruby/library/net/FTPProtoError_spec.rb b/spec/ruby/library/net/FTPProtoError_spec.rb
index e7abbc0dd8..445ba1cd2f 100644
--- a/spec/ruby/library/net/FTPProtoError_spec.rb
+++ b/spec/ruby/library/net/FTPProtoError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'net/ftp'
describe "Net::FTPProtoError" do
diff --git a/spec/ruby/library/net/FTPReplyError_spec.rb b/spec/ruby/library/net/FTPReplyError_spec.rb
index fcc7501fc1..b697f0b95a 100644
--- a/spec/ruby/library/net/FTPReplyError_spec.rb
+++ b/spec/ruby/library/net/FTPReplyError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'net/ftp'
describe "Net::FTPReplyError" do
diff --git a/spec/ruby/library/net/FTPTempError_spec.rb b/spec/ruby/library/net/FTPTempError_spec.rb
index f4b045dfb5..8d74d371da 100644
--- a/spec/ruby/library/net/FTPTempError_spec.rb
+++ b/spec/ruby/library/net/FTPTempError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'net/ftp'
describe "Net::FTPTempError" do
diff --git a/spec/ruby/library/net/ftp/abort_spec.rb b/spec/ruby/library/net/ftp/abort_spec.rb
index 57651468d8..ea47eaf9bf 100644
--- a/spec/ruby/library/net/ftp/abort_spec.rb
+++ b/spec/ruby/library/net/ftp/abort_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#abort" do
before :each do
@@ -18,7 +18,7 @@ describe "Net::FTP#abort" do
end
it "sends the ABOR command to the server" do
- -> { @ftp.abort }.should_not raise_error
+ lambda { @ftp.abort }.should_not raise_error
end
it "ignores the response" do
@@ -32,31 +32,31 @@ describe "Net::FTP#abort" do
it "does not raise any error when the response code is 225" do
@server.should_receive(:abor).and_respond("225 Data connection open; no transfer in progress.")
- -> { @ftp.abort }.should_not raise_error
+ lambda { @ftp.abort }.should_not raise_error
end
it "does not raise any error when the response code is 226" do
@server.should_receive(:abor).and_respond("226 Closing data connection.")
- -> { @ftp.abort }.should_not raise_error
+ lambda { @ftp.abort }.should_not raise_error
end
it "raises a Net::FTPProtoError when the response code is 500" do
@server.should_receive(:abor).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.abort }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)
end
it "raises a Net::FTPProtoError when the response code is 501" do
@server.should_receive(:abor).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.abort }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)
end
it "raises a Net::FTPProtoError when the response code is 502" do
@server.should_receive(:abor).and_respond("502 Command not implemented.")
- -> { @ftp.abort }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)
end
it "raises a Net::FTPProtoError when the response code is 421" do
@server.should_receive(:abor).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.abort }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)
end
end
diff --git a/spec/ruby/library/net/ftp/acct_spec.rb b/spec/ruby/library/net/ftp/acct_spec.rb
index d8068dc81e..e60c6b3088 100644
--- a/spec/ruby/library/net/ftp/acct_spec.rb
+++ b/spec/ruby/library/net/ftp/acct_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#acct" do
before :each do
@@ -28,31 +28,31 @@ describe "Net::FTP#acct" do
it "does not raise any error when the response code is 230" do
@server.should_receive(:acct).and_respond("230 User logged in, proceed.")
- -> { @ftp.acct("my_account") }.should_not raise_error
+ lambda { @ftp.acct("my_account") }.should_not raise_error
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:acct).and_respond("530 Not logged in.")
- -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:acct).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:acct).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 503" do
@server.should_receive(:acct).and_respond("503 Bad sequence of commands.")
- -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:acct).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.acct("my_account") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.acct("my_account") }.should raise_error(Net::FTPTempError)
end
end
diff --git a/spec/ruby/library/net/ftp/binary_spec.rb b/spec/ruby/library/net/ftp/binary_spec.rb
index 60e312a673..6f1a1ab8ba 100644
--- a/spec/ruby/library/net/ftp/binary_spec.rb
+++ b/spec/ruby/library/net/ftp/binary_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#binary" do
it "returns true when self is in binary mode" do
diff --git a/spec/ruby/library/net/ftp/chdir_spec.rb b/spec/ruby/library/net/ftp/chdir_spec.rb
index 4c10fa78b4..f6cfac5b66 100644
--- a/spec/ruby/library/net/ftp/chdir_spec.rb
+++ b/spec/ruby/library/net/ftp/chdir_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#chdir" do
before :each do
@@ -29,32 +29,32 @@ describe "Net::FTP#chdir" do
it "does not raise a Net::FTPPermError when the response code is 500" do
@server.should_receive(:cdup).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.chdir("..") }.should_not raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("..") }.should_not raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:cdup).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:cdup).and_respond("502 Command not implemented.")
- -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:cdup).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.chdir("..") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.chdir("..") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:cdup).and_respond("530 Not logged in.")
- -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:cdup).and_respond("550 Requested action not taken.")
- -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("..") }.should raise_error(Net::FTPPermError)
end
end
@@ -69,31 +69,31 @@ describe "Net::FTP#chdir" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:cwd).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:cwd).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:cwd).and_respond("502 Command not implemented.")
- -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:cwd).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.chdir("test") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.chdir("test") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:cwd).and_respond("530 Not logged in.")
- -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:cwd).and_respond("550 Requested action not taken.")
- -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.chdir("test") }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/close_spec.rb b/spec/ruby/library/net/ftp/close_spec.rb
index 95c72b29ed..0f6866221f 100644
--- a/spec/ruby/library/net/ftp/close_spec.rb
+++ b/spec/ruby/library/net/ftp/close_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#close" do
before :each do
diff --git a/spec/ruby/library/net/ftp/closed_spec.rb b/spec/ruby/library/net/ftp/closed_spec.rb
index 1f3e69b0c1..7b31717c00 100644
--- a/spec/ruby/library/net/ftp/closed_spec.rb
+++ b/spec/ruby/library/net/ftp/closed_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#closed?" do
before :each do
diff --git a/spec/ruby/library/net/ftp/connect_spec.rb b/spec/ruby/library/net/ftp/connect_spec.rb
index 9ee9bcd2c6..f3c1565fc2 100644
--- a/spec/ruby/library/net/ftp/connect_spec.rb
+++ b/spec/ruby/library/net/ftp/connect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
# TODO: Add specs for using the SOCKSSocket
describe "Net::FTP#connect" do
@@ -19,7 +19,7 @@ describe "Net::FTP#connect" do
end
it "tries to connect to the FTP Server on the given host and port" do
- -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error
+ lambda { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error
end
it "returns nil" do
@@ -28,22 +28,22 @@ describe "Net::FTP#connect" do
it "prints a small debug line when in debug mode" do
@ftp.debug_mode = true
- -> { @ftp.connect(@server.hostname, @server.server_port) }.should output(/#{"connect: "}#{@server.hostname}#{", "}#{@server.server_port}#{"\\nget: 220 Dummy FTP Server ready!"}/)
+ lambda { @ftp.connect(@server.hostname, @server.server_port) }.should output(/#{"connect: "}#{@server.hostname}#{", "}#{@server.server_port}#{"\\nget: 220 Dummy FTP Server ready!"}/)
@ftp.debug_mode = false
end
it "does not raise any error when the response code is 220" do
@server.connect_message = "220 Dummy FTP Server ready!"
- -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error
+ lambda { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error
end
it "raises a Net::FTPReplyError when the response code is 120" do
@server.connect_message = "120 Service ready in nnn minutes."
- -> { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPReplyError)
+ lambda { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPReplyError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.connect_message = "421 Service not available, closing control connection."
- -> { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPTempError)
end
end
diff --git a/spec/ruby/library/net/ftp/debug_mode_spec.rb b/spec/ruby/library/net/ftp/debug_mode_spec.rb
index f49da55ed1..c4aa5eee3c 100644
--- a/spec/ruby/library/net/ftp/debug_mode_spec.rb
+++ b/spec/ruby/library/net/ftp/debug_mode_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#debug_mode" do
it "returns true when self is in debug mode" do
diff --git a/spec/ruby/library/net/ftp/default_passive_spec.rb b/spec/ruby/library/net/ftp/default_passive_spec.rb
index 30eb8f9da2..f526373b82 100644
--- a/spec/ruby/library/net/ftp/default_passive_spec.rb
+++ b/spec/ruby/library/net/ftp/default_passive_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
-describe "Net::FTP#default_passive" do
- it "is true by default" do
- ruby_exe(fixture(__FILE__, "default_passive.rb")).should == "true\ntrue\n"
+ruby_version_is "2.3" do
+ describe "Net::FTP#default_passive" do
+ it "is true by default" do
+ ruby_exe(fixture(__FILE__, "default_passive.rb")).should == "true\ntrue\n"
+ end
end
end
diff --git a/spec/ruby/library/net/ftp/delete_spec.rb b/spec/ruby/library/net/ftp/delete_spec.rb
index cf8f9332e2..b20ef32651 100644
--- a/spec/ruby/library/net/ftp/delete_spec.rb
+++ b/spec/ruby/library/net/ftp/delete_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#delete" do
before :each do
@@ -24,36 +24,36 @@ describe "Net::FTP#delete" do
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:dele).and_respond("450 Requested file action not taken.")
- -> { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:dele).and_respond("550 Requested action not taken.")
- -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:dele).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:dele).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:dele).and_respond("502 Command not implemented.")
- -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:dele).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:dele).and_respond("530 Not logged in.")
- -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/dir_spec.rb b/spec/ruby/library/net/ftp/dir_spec.rb
index 47ac7b8d9b..6a2b766ca2 100644
--- a/spec/ruby/library/net/ftp/dir_spec.rb
+++ b/spec/ruby/library/net/ftp/dir_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/list'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/list', __FILE__)
describe "Net::FTP#dir" do
it_behaves_like :net_ftp_list, :dir
diff --git a/spec/ruby/library/net/ftp/fixtures/server.rb b/spec/ruby/library/net/ftp/fixtures/server.rb
index ecbed591d5..65339cfaf9 100644
--- a/spec/ruby/library/net/ftp/fixtures/server.rb
+++ b/spec/ruby/library/net/ftp/fixtures/server.rb
@@ -86,7 +86,7 @@ module NetFTPSpecs
end
def and_respond(text)
- @handlers[@handler_for] = -> s, *args { s.response(text) }
+ @handlers[@handler_for] = lambda { |s, *args| s.response(text) }
end
##
@@ -252,7 +252,7 @@ module NetFTPSpecs
end
end
- @datasocket.close()
+ #@datasocket.close()
self.response("200 OK, Data received. (STOR #{file})")
end
diff --git a/spec/ruby/library/net/ftp/get_spec.rb b/spec/ruby/library/net/ftp/get_spec.rb
index c4672b55a5..59fc45d010 100644
--- a/spec/ruby/library/net/ftp/get_spec.rb
+++ b/spec/ruby/library/net/ftp/get_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/gettextfile'
-require_relative 'shared/getbinaryfile'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/gettextfile', __FILE__)
+require File.expand_path('../shared/getbinaryfile', __FILE__)
describe "Net::FTP#get (binary mode)" do
before :each do
diff --git a/spec/ruby/library/net/ftp/getbinaryfile_spec.rb b/spec/ruby/library/net/ftp/getbinaryfile_spec.rb
index 155851b53c..0f921c8b1d 100644
--- a/spec/ruby/library/net/ftp/getbinaryfile_spec.rb
+++ b/spec/ruby/library/net/ftp/getbinaryfile_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/getbinaryfile'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/getbinaryfile', __FILE__)
describe "Net::FTP#getbinaryfile" do
it_behaves_like :net_ftp_getbinaryfile, :getbinaryfile
diff --git a/spec/ruby/library/net/ftp/getdir_spec.rb b/spec/ruby/library/net/ftp/getdir_spec.rb
index eea35ac130..19ace4dff9 100644
--- a/spec/ruby/library/net/ftp/getdir_spec.rb
+++ b/spec/ruby/library/net/ftp/getdir_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'shared/pwd'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../shared/pwd', __FILE__)
describe "Net::FTP#getdir" do
it_behaves_like :net_ftp_pwd, :getdir
diff --git a/spec/ruby/library/net/ftp/gettextfile_spec.rb b/spec/ruby/library/net/ftp/gettextfile_spec.rb
index 79395ae009..29077df253 100644
--- a/spec/ruby/library/net/ftp/gettextfile_spec.rb
+++ b/spec/ruby/library/net/ftp/gettextfile_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/gettextfile'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/gettextfile', __FILE__)
describe "Net::FTP#gettextfile" do
it_behaves_like :net_ftp_gettextfile, :gettextfile
diff --git a/spec/ruby/library/net/ftp/help_spec.rb b/spec/ruby/library/net/ftp/help_spec.rb
index d2e9fe7ee8..6f5f901024 100644
--- a/spec/ruby/library/net/ftp/help_spec.rb
+++ b/spec/ruby/library/net/ftp/help_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#help" do
def with_connection
@@ -36,31 +36,31 @@ describe "Net::FTP#help" do
it "does not raise any error when the response code is 211" do
@server.should_receive(:help).and_respond("211 System status, or system help reply.")
- -> { @ftp.help }.should_not raise_error
+ lambda { @ftp.help }.should_not raise_error
end
it "does not raise any error when the response code is 214" do
@server.should_receive(:help).and_respond("214 Help message.")
- -> { @ftp.help }.should_not raise_error
+ lambda { @ftp.help }.should_not raise_error
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:help).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.help }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.help }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:help).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.help }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.help }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:help).and_respond("502 Command not implemented.")
- -> { @ftp.help }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.help }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:help).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.help }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.help }.should raise_error(Net::FTPTempError)
end
end
diff --git a/spec/ruby/library/net/ftp/initialize_spec.rb b/spec/ruby/library/net/ftp/initialize_spec.rb
index 507320e494..65105b8831 100644
--- a/spec/ruby/library/net/ftp/initialize_spec.rb
+++ b/spec/ruby/library/net/ftp/initialize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#initialize" do
before :each do
@@ -88,320 +88,4 @@ describe "Net::FTP#initialize" do
@ftp.send(:initialize, "localhost", "rubyspec", "rocks", "account")
end
end
-
- before :each do
- @ftp.stub!(:login)
- end
-
- describe 'when the host' do
- describe 'is set' do
- describe 'and port option' do
- describe 'is set' do
- it 'tries to connect to the host on the specified port' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ port: 8080 })
- @ftp.should_receive(:connect).with('localhost', 8080)
-
- @ftp.send(:initialize, 'localhost', options)
- end
- end
-
- describe 'is not set' do
- it 'tries to connect to the host without a port' do
- @ftp.should_receive(:connect).with("localhost", *@port_args)
-
- @ftp.send(:initialize, 'localhost')
- end
- end
- end
-
- describe 'when the username option' do
- describe 'is set' do
- describe 'and the password option' do
- describe 'is set' do
- describe 'and the account option' do
- describe 'is set' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret', account: 'b' })
- @ftp.should_receive(:login).with('a', 'topsecret', 'b')
-
- @ftp.send(:initialize, 'localhost', options)
- end
- end
-
- describe 'is unset' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret' })
- @ftp.should_receive(:login).with('a', 'topsecret', nil)
-
- @ftp.send(:initialize, 'localhost', options)
- end
- end
- end
- end
-
- describe 'is unset' do
- describe 'and the account option' do
- describe 'is set' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a', account: 'b' })
- @ftp.should_receive(:login).with('a', nil, 'b')
-
- @ftp.send(:initialize, 'localhost', options)
- end
- end
-
- describe 'is unset' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a'})
- @ftp.should_receive(:login).with('a', nil, nil)
-
- @ftp.send(:initialize, 'localhost', options)
- end
- end
- end
- end
- end
- end
-
- describe 'is not set' do
- it 'does not try to log in' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({})
- @ftp.should_not_receive(:login)
-
- @ftp.send(:initialize, 'localhost', options)
- end
- end
- end
- end
-
- describe 'is unset' do
- it 'does not try to connect' do
- @ftp.should_not_receive(:connect)
-
- @ftp.send(:initialize)
- end
-
- it 'does not try to log in' do
- @ftp.should_not_receive(:login)
-
- @ftp.send(:initialize)
- end
- end
- end
-
- describe 'when the passive option' do
- describe 'is set' do
- describe 'to true' do
- it 'sets passive to true' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ passive: true })
-
- @ftp.send(:initialize, nil, options)
- @ftp.passive.should == true
- end
- end
-
- describe 'to false' do
- it 'sets passive to false' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ passive: false })
-
- @ftp.send(:initialize, nil, options)
- @ftp.passive.should == false
- end
- end
- end
-
- describe 'is unset' do
- it 'sets passive to false' do
- @ftp.send(:initialize)
- @ftp.passive.should == false
- end
- end
- end
-
- describe 'when the debug_mode option' do
- describe 'is set' do
- describe 'to true' do
- it 'sets debug_mode to true' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ debug_mode: true })
-
- @ftp.send(:initialize, nil, options)
- @ftp.debug_mode.should == true
- end
- end
-
- describe 'to false' do
- it 'sets debug_mode to false' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ debug_mode: false })
-
- @ftp.send(:initialize, nil, options)
- @ftp.debug_mode.should == false
- end
- end
- end
-
- describe 'is unset' do
- it 'sets debug_mode to false' do
- @ftp.send(:initialize)
- @ftp.debug_mode.should == false
- end
- end
- end
-
- describe 'when the open_timeout option' do
- describe 'is set' do
- it 'sets open_timeout to the specified value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ open_timeout: 42 })
-
- @ftp.send(:initialize, nil, options)
- @ftp.open_timeout.should == 42
- end
- end
-
- describe 'is not set' do
- it 'sets open_timeout to nil' do
- @ftp.send(:initialize)
- @ftp.open_timeout.should == nil
- end
- end
- end
-
- describe 'when the read_timeout option' do
- describe 'is set' do
- it 'sets read_timeout to the specified value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ read_timeout: 100 })
-
- @ftp.send(:initialize, nil, options)
- @ftp.read_timeout.should == 100
- end
- end
-
- describe 'is not set' do
- it 'sets read_timeout to the default value' do
- @ftp.send(:initialize)
- @ftp.read_timeout.should == 60
- end
- end
- end
-
- describe 'when the ssl_handshake_timeout option' do
- describe 'is set' do
- it 'sets ssl_handshake_timeout to the specified value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl_handshake_timeout: 23 })
-
- @ftp.send(:initialize, nil, options)
- @ftp.ssl_handshake_timeout.should == 23
- end
- end
-
- describe 'is not set' do
- it 'sets ssl_handshake_timeout to nil' do
- @ftp.send(:initialize)
- @ftp.ssl_handshake_timeout.should == nil
- end
- end
- end
-
- describe 'when the ssl option' do
- describe 'is set' do
- describe "and the ssl option's value is true" do
- it 'initializes ssl_context to a blank SSLContext object' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: true })
-
- ssl_context = OpenSSL::SSL::SSLContext.allocate
- ssl_context.stub!(:set_params)
-
- OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
- ssl_context.should_receive(:set_params).with({})
-
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@ssl_context).should == ssl_context
- end
- end
-
- describe "and the ssl option's value is a hash" do
- it 'initializes ssl_context to a configured SSLContext object' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: {key: 'value'} })
-
- ssl_context = OpenSSL::SSL::SSLContext.allocate
- ssl_context.stub!(:set_params)
-
- OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
- ssl_context.should_receive(:set_params).with({key: 'value'})
-
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@ssl_context).should == ssl_context
- end
- end
-
- describe 'and private_data_connection' do
- describe 'is set' do
- it 'sets private_data_connection to that value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: true, private_data_connection: 'true' })
-
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@private_data_connection).should == 'true'
- end
- end
-
- describe 'is not set' do
- it 'sets private_data_connection to nil' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: true })
-
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@private_data_connection).should == true
- end
- end
- end
- end
-
- describe 'is not set' do
- it 'sets ssl_context to nil' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({})
-
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@ssl_context).should == nil
- end
-
- describe 'private_data_connection' do
- describe 'is set' do
- it 'raises an ArgumentError' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ private_data_connection: true })
-
- -> {
- @ftp.send(:initialize, nil, options)
- }.should raise_error(ArgumentError, /private_data_connection can be set to true only when ssl is enabled/)
- end
- end
-
- describe 'is not set' do
- it 'sets private_data_connection to false' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({})
-
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@private_data_connection).should == false
- end
- end
- end
- end
- end
end
diff --git a/spec/ruby/library/net/ftp/last_response_code_spec.rb b/spec/ruby/library/net/ftp/last_response_code_spec.rb
index 3eb20f7ad8..77651a9be4 100644
--- a/spec/ruby/library/net/ftp/last_response_code_spec.rb
+++ b/spec/ruby/library/net/ftp/last_response_code_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'shared/last_response_code'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../shared/last_response_code', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#last_response_code" do
it_behaves_like :net_ftp_last_response_code, :last_response_code
diff --git a/spec/ruby/library/net/ftp/last_response_spec.rb b/spec/ruby/library/net/ftp/last_response_spec.rb
index ada665d59c..eb53f92774 100644
--- a/spec/ruby/library/net/ftp/last_response_spec.rb
+++ b/spec/ruby/library/net/ftp/last_response_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#last_response" do
before :each do
diff --git a/spec/ruby/library/net/ftp/lastresp_spec.rb b/spec/ruby/library/net/ftp/lastresp_spec.rb
index 273e216e8b..d2c6f44e48 100644
--- a/spec/ruby/library/net/ftp/lastresp_spec.rb
+++ b/spec/ruby/library/net/ftp/lastresp_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'shared/last_response_code'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../shared/last_response_code', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#lastresp" do
it_behaves_like :net_ftp_last_response_code, :lastresp
diff --git a/spec/ruby/library/net/ftp/list_spec.rb b/spec/ruby/library/net/ftp/list_spec.rb
index 6175172923..41c55c42ac 100644
--- a/spec/ruby/library/net/ftp/list_spec.rb
+++ b/spec/ruby/library/net/ftp/list_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/list'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/list', __FILE__)
describe "Net::FTP#list" do
it_behaves_like :net_ftp_list, :list
diff --git a/spec/ruby/library/net/ftp/login_spec.rb b/spec/ruby/library/net/ftp/login_spec.rb
index 46736851ee..9768d9cf33 100644
--- a/spec/ruby/library/net/ftp/login_spec.rb
+++ b/spec/ruby/library/net/ftp/login_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#login" do
before :each do
@@ -32,7 +32,7 @@ describe "Net::FTP#login" do
it "raises a Net::FTPReplyError when the server requests an account" do
@server.should_receive(:user).and_respond("331 User name okay, need password.")
@server.should_receive(:pass).and_respond("332 Need account for login.")
- -> { @ftp.login }.should raise_error(Net::FTPReplyError)
+ lambda { @ftp.login }.should raise_error(Net::FTPReplyError)
end
end
@@ -44,13 +44,13 @@ describe "Net::FTP#login" do
it "raises a Net::FTPReplyError when the server requests a password, but none was given" do
@server.should_receive(:user).and_respond("331 User name okay, need password.")
- -> { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError)
+ lambda { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError)
end
it "raises a Net::FTPReplyError when the server requests an account, but none was given" do
@server.should_receive(:user).and_respond("331 User name okay, need password.")
@server.should_receive(:pass).and_respond("332 Need account for login.")
- -> { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError)
+ lambda { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError)
end
end
@@ -69,7 +69,7 @@ describe "Net::FTP#login" do
it "raises a Net::FTPReplyError when the server requests an account" do
@server.should_receive(:user).and_respond("331 User name okay, need password.")
@server.should_receive(:pass).and_respond("332 Need account for login.")
- -> { @ftp.login("rubyspec", "rocks") }.should raise_error(Net::FTPReplyError)
+ lambda { @ftp.login("rubyspec", "rocks") }.should raise_error(Net::FTPReplyError)
end
end
@@ -96,27 +96,27 @@ describe "Net::FTP#login" do
describe "when the USER command fails" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:user).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:user).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:user).and_respond("502 Command not implemented.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:user).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:user).and_respond("530 Not logged in.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
end
@@ -127,32 +127,32 @@ describe "Net::FTP#login" do
it "does not raise an Error when the response code is 202" do
@server.should_receive(:pass).and_respond("202 Command not implemented, superfluous at this site.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:pass).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:pass).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:pass).and_respond("502 Command not implemented.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:pass).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:pass).and_respond("530 Not logged in.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
end
@@ -164,32 +164,32 @@ describe "Net::FTP#login" do
it "does not raise an Error when the response code is 202" do
@server.should_receive(:acct).and_respond("202 Command not implemented, superfluous at this site.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:acct).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:acct).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:acct).and_respond("502 Command not implemented.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:acct).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:acct).and_respond("530 Not logged in.")
- -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/ls_spec.rb b/spec/ruby/library/net/ftp/ls_spec.rb
index e729eb9481..f713fb46aa 100644
--- a/spec/ruby/library/net/ftp/ls_spec.rb
+++ b/spec/ruby/library/net/ftp/ls_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/list'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/list', __FILE__)
describe "Net::FTP#ls" do
it_behaves_like :net_ftp_list, :ls
diff --git a/spec/ruby/library/net/ftp/mdtm_spec.rb b/spec/ruby/library/net/ftp/mdtm_spec.rb
index b74cf8d3c7..bbd28d10b1 100644
--- a/spec/ruby/library/net/ftp/mdtm_spec.rb
+++ b/spec/ruby/library/net/ftp/mdtm_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#mdtm" do
before :each do
@@ -28,11 +28,11 @@ describe "Net::FTP#mdtm" do
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:mdtm).and_respond("550 Requested action not taken.")
- -> { @ftp.mdtm("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.mdtm("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:mdtm).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.mdtm("test.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.mdtm("test.file") }.should raise_error(Net::FTPTempError)
end
end
diff --git a/spec/ruby/library/net/ftp/mkdir_spec.rb b/spec/ruby/library/net/ftp/mkdir_spec.rb
index 7dc45b5711..2a7088e5d9 100644
--- a/spec/ruby/library/net/ftp/mkdir_spec.rb
+++ b/spec/ruby/library/net/ftp/mkdir_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#mkdir" do
before :each do
@@ -31,31 +31,31 @@ describe "Net::FTP#mkdir" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:mkd).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:mkd).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:mkd).and_respond("502 Command not implemented.")
- -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:mkd).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:mkd).and_respond("530 Not logged in.")
- -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:mkd).and_respond("550 Requested action not taken.")
- -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/mtime_spec.rb b/spec/ruby/library/net/ftp/mtime_spec.rb
index 0f6cc1ba20..0e76aa079b 100644
--- a/spec/ruby/library/net/ftp/mtime_spec.rb
+++ b/spec/ruby/library/net/ftp/mtime_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#mtime" do
before :each do
@@ -40,11 +40,11 @@ describe "Net::FTP#mtime" do
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:mdtm).and_respond("550 Requested action not taken.")
- -> { @ftp.mtime("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.mtime("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:mdtm).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.mtime("test.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.mtime("test.file") }.should raise_error(Net::FTPTempError)
end
end
diff --git a/spec/ruby/library/net/ftp/nlst_spec.rb b/spec/ruby/library/net/ftp/nlst_spec.rb
index 34384fb8c4..4723e9f6c6 100644
--- a/spec/ruby/library/net/ftp/nlst_spec.rb
+++ b/spec/ruby/library/net/ftp/nlst_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#nlst" do
before :each do
@@ -35,32 +35,32 @@ describe "Net::FTP#nlst" do
describe "when the NLST command fails" do
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:nlst).and_respond("450 Requested file action not taken..")
- -> { @ftp.nlst }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:nlst).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.nlst }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:nlst).and_respond("501 Syntax error, command unrecognized.")
- -> { @ftp.nlst }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:nlst).and_respond("502 Command not implemented.")
- -> { @ftp.nlst }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:nlst).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.nlst }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:nlst).and_respond("530 Not logged in.")
- -> { @ftp.nlst }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
end
end
@@ -68,25 +68,25 @@ describe "Net::FTP#nlst" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.")
@server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.nlst }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.")
@server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.nlst }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.")
@server.should_receive(:port).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.nlst }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:eprt).and_respond("530 Not logged in.")
@server.should_receive(:port).and_respond("530 Not logged in.")
- -> { @ftp.nlst }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/noop_spec.rb b/spec/ruby/library/net/ftp/noop_spec.rb
index 070750ced7..1bc6ccd913 100644
--- a/spec/ruby/library/net/ftp/noop_spec.rb
+++ b/spec/ruby/library/net/ftp/noop_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#noop" do
before :each do
@@ -28,11 +28,11 @@ describe "Net::FTP#noop" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:noop).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.noop }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.noop }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:noop).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.noop }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.noop }.should raise_error(Net::FTPTempError)
end
end
diff --git a/spec/ruby/library/net/ftp/open_spec.rb b/spec/ruby/library/net/ftp/open_spec.rb
index 7be02ff373..b422e64c87 100644
--- a/spec/ruby/library/net/ftp/open_spec.rb
+++ b/spec/ruby/library/net/ftp/open_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP.open" do
before :each do
diff --git a/spec/ruby/library/net/ftp/passive_spec.rb b/spec/ruby/library/net/ftp/passive_spec.rb
index e8db030cbd..fd9a0dffe3 100644
--- a/spec/ruby/library/net/ftp/passive_spec.rb
+++ b/spec/ruby/library/net/ftp/passive_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#passive" do
it "returns true when self is in passive mode" do
@@ -10,8 +10,16 @@ describe "Net::FTP#passive" do
ftp.passive.should be_true
end
- it "is the value of Net::FTP.default_value by default" do
- ruby_exe(fixture(__FILE__, "passive.rb")).should == "true"
+ ruby_version_is ""..."2.3" do
+ it "is false by default" do
+ ruby_exe(fixture(__FILE__, "passive.rb")).should == "false"
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "is the value of Net::FTP.default_value by default" do
+ ruby_exe(fixture(__FILE__, "passive.rb")).should == "true"
+ end
end
end
diff --git a/spec/ruby/library/net/ftp/put_spec.rb b/spec/ruby/library/net/ftp/put_spec.rb
index f1f85b5d05..61a8d00543 100644
--- a/spec/ruby/library/net/ftp/put_spec.rb
+++ b/spec/ruby/library/net/ftp/put_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/puttextfile'
-require_relative 'shared/putbinaryfile'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/puttextfile', __FILE__)
+require File.expand_path('../shared/putbinaryfile', __FILE__)
describe "Net::FTP#put (binary mode)" do
before :each do
diff --git a/spec/ruby/library/net/ftp/putbinaryfile_spec.rb b/spec/ruby/library/net/ftp/putbinaryfile_spec.rb
index cb1c7bef5a..18955409b6 100644
--- a/spec/ruby/library/net/ftp/putbinaryfile_spec.rb
+++ b/spec/ruby/library/net/ftp/putbinaryfile_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/putbinaryfile'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/putbinaryfile', __FILE__)
describe "Net::FTP#putbinaryfile" do
it_behaves_like :net_ftp_putbinaryfile, :putbinaryfile
diff --git a/spec/ruby/library/net/ftp/puttextfile_spec.rb b/spec/ruby/library/net/ftp/puttextfile_spec.rb
index 00a930afd7..2ca6e98c92 100644
--- a/spec/ruby/library/net/ftp/puttextfile_spec.rb
+++ b/spec/ruby/library/net/ftp/puttextfile_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
-require_relative 'shared/puttextfile'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
+require File.expand_path('../shared/puttextfile', __FILE__)
describe "Net::FTP#puttextfile" do
it_behaves_like :net_ftp_puttextfile, :puttextfile
diff --git a/spec/ruby/library/net/ftp/pwd_spec.rb b/spec/ruby/library/net/ftp/pwd_spec.rb
index a3998cc730..d5438d8e56 100644
--- a/spec/ruby/library/net/ftp/pwd_spec.rb
+++ b/spec/ruby/library/net/ftp/pwd_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#pwd" do
before :each do
@@ -28,26 +28,26 @@ describe "Net::FTP#pwd" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:pwd).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.pwd }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:pwd).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.pwd }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:pwd).and_respond("502 Command not implemented.")
- -> { @ftp.pwd }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:pwd).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.pwd }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.pwd }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:pwd).and_respond("550 Requested action not taken.")
- -> { @ftp.pwd }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/quit_spec.rb b/spec/ruby/library/net/ftp/quit_spec.rb
index 8e3cb28b90..c053641939 100644
--- a/spec/ruby/library/net/ftp/quit_spec.rb
+++ b/spec/ruby/library/net/ftp/quit_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#quit" do
before :each do
@@ -22,7 +22,7 @@ describe "Net::FTP#quit" do
@ftp.last_response.should == "221 OK, bye\n"
end
- it "does not close the socket automatically" do
+ it "does not close the socket automagically" do
@ftp.quit
@ftp.closed?.should be_false
end
diff --git a/spec/ruby/library/net/ftp/rename_spec.rb b/spec/ruby/library/net/ftp/rename_spec.rb
index 376b203ac9..0216d2059a 100644
--- a/spec/ruby/library/net/ftp/rename_spec.rb
+++ b/spec/ruby/library/net/ftp/rename_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#rename" do
before :each do
@@ -31,64 +31,64 @@ describe "Net::FTP#rename" do
describe "when the RNFR command fails" do
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:rnfr).and_respond("450 Requested file action not taken.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:rnfr).and_respond("550 Requested action not taken.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:rnfr).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:rnfr).and_respond("502 Command not implemented.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:rnfr).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:rnfr).and_respond("530 Not logged in.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
end
describe "when the RNTO command fails" do
it "raises a Net::FTPPermError when the response code is 532" do
@server.should_receive(:rnfr).and_respond("532 Need account for storing files.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 553" do
@server.should_receive(:rnto).and_respond("553 Requested action not taken.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:rnto).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:rnto).and_respond("502 Command not implemented.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:rnto).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:rnto).and_respond("530 Not logged in.")
- -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/resume_spec.rb b/spec/ruby/library/net/ftp/resume_spec.rb
index 51b1cff2a4..9ec4a921aa 100644
--- a/spec/ruby/library/net/ftp/resume_spec.rb
+++ b/spec/ruby/library/net/ftp/resume_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#resume" do
it "returns true when self is set to resume uploads/downloads" do
diff --git a/spec/ruby/library/net/ftp/retrbinary_spec.rb b/spec/ruby/library/net/ftp/retrbinary_spec.rb
index 30e2484af5..fd7af0b62a 100644
--- a/spec/ruby/library/net/ftp/retrbinary_spec.rb
+++ b/spec/ruby/library/net/ftp/retrbinary_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#retrbinary" do
before :each do
diff --git a/spec/ruby/library/net/ftp/retrlines_spec.rb b/spec/ruby/library/net/ftp/retrlines_spec.rb
index 546df3844e..cb8d48ecf7 100644
--- a/spec/ruby/library/net/ftp/retrlines_spec.rb
+++ b/spec/ruby/library/net/ftp/retrlines_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#retrlines" do
before :each do
diff --git a/spec/ruby/library/net/ftp/return_code_spec.rb b/spec/ruby/library/net/ftp/return_code_spec.rb
index e4b98c8031..64100bc3fc 100644
--- a/spec/ruby/library/net/ftp/return_code_spec.rb
+++ b/spec/ruby/library/net/ftp/return_code_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#return_code" do
before :each do
@@ -7,7 +7,7 @@ describe "Net::FTP#return_code" do
end
it "outputs a warning and returns a newline" do
- -> do
+ lambda do
@ftp.return_code.should == "\n"
end.should complain(/warning: Net::FTP#return_code is obsolete and do nothing/)
end
@@ -19,6 +19,6 @@ describe "Net::FTP#return_code=" do
end
it "outputs a warning" do
- -> { @ftp.return_code = 123 }.should complain(/warning: Net::FTP#return_code= is obsolete and do nothing/)
+ lambda { @ftp.return_code = 123 }.should complain(/warning: Net::FTP#return_code= is obsolete and do nothing/)
end
end
diff --git a/spec/ruby/library/net/ftp/rmdir_spec.rb b/spec/ruby/library/net/ftp/rmdir_spec.rb
index 0515897998..453c7823c4 100644
--- a/spec/ruby/library/net/ftp/rmdir_spec.rb
+++ b/spec/ruby/library/net/ftp/rmdir_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#rmdir" do
before :each do
@@ -28,31 +28,31 @@ describe "Net::FTP#rmdir" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:rmd).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:rmd).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:rmd).and_respond("502 Command not implemented.")
- -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:rmd).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:rmd).and_respond("530 Not logged in.")
- -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:rmd).and_respond("550 Requested action not taken.")
- -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/sendcmd_spec.rb b/spec/ruby/library/net/ftp/sendcmd_spec.rb
index dafa36e032..9bdca621bc 100644
--- a/spec/ruby/library/net/ftp/sendcmd_spec.rb
+++ b/spec/ruby/library/net/ftp/sendcmd_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#sendcmd" do
before :each do
@@ -28,27 +28,27 @@ describe "Net::FTP#sendcmd" do
it "raises no error when the response code is 1xx, 2xx or 3xx" do
@server.should_receive(:help).and_respond("120 Service ready in nnn minutes.")
- -> { @ftp.sendcmd("HELP") }.should_not raise_error
+ lambda { @ftp.sendcmd("HELP") }.should_not raise_error
@server.should_receive(:help).and_respond("200 Command okay.")
- -> { @ftp.sendcmd("HELP") }.should_not raise_error
+ lambda { @ftp.sendcmd("HELP") }.should_not raise_error
@server.should_receive(:help).and_respond("350 Requested file action pending further information.")
- -> { @ftp.sendcmd("HELP") }.should_not raise_error
+ lambda { @ftp.sendcmd("HELP") }.should_not raise_error
end
it "raises a Net::FTPTempError when the response code is 4xx" do
@server.should_receive(:help).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 5xx" do
@server.should_receive(:help).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPProtoError when the response code is not between 1xx-5xx" do
@server.should_receive(:help).and_respond("999 Invalid response.")
- -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPProtoError)
end
end
diff --git a/spec/ruby/library/net/ftp/set_socket_spec.rb b/spec/ruby/library/net/ftp/set_socket_spec.rb
index 7ca3bbbe27..1553445219 100644
--- a/spec/ruby/library/net/ftp/set_socket_spec.rb
+++ b/spec/ruby/library/net/ftp/set_socket_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
describe "Net::FTP#set_socket" do
# TODO: I won't spec this method, as it is not used
# anywhere and it should be private anyway.
- it "needs to be reviewed for spec completeness"
+ #it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/library/net/ftp/shared/getbinaryfile.rb b/spec/ruby/library/net/ftp/shared/getbinaryfile.rb
index f324f5b85d..2252935b2d 100644
--- a/spec/ruby/library/net/ftp/shared/getbinaryfile.rb
+++ b/spec/ruby/library/net/ftp/shared/getbinaryfile.rb
@@ -60,32 +60,32 @@ describe :net_ftp_getbinaryfile, shared: :true do
describe "and the REST command fails" do
it "raises a Net::FTPProtoError when the response code is 550" do
@server.should_receive(:rest).and_respond("Requested action not taken.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:rest).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:rest).and_respond("501 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:rest).and_respond("502 Command not implemented.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:rest).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:rest).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
end
end
@@ -93,32 +93,32 @@ describe :net_ftp_getbinaryfile, shared: :true do
describe "when the RETR command fails" do
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:retr).and_respond("450 Requested file action not taken.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPProtoError when the response code is 550" do
@server.should_receive(:retr).and_respond("Requested action not taken.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:retr).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:retr).and_respond("501 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:retr).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:retr).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
end
@@ -126,25 +126,25 @@ describe :net_ftp_getbinaryfile, shared: :true do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.")
@server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.")
@server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.")
@server.should_receive(:port).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:eprt).and_respond("530 Not logged in.")
@server.should_receive(:port).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/shared/gettextfile.rb b/spec/ruby/library/net/ftp/shared/gettextfile.rb
index 82bec2a4a7..6219581d12 100644
--- a/spec/ruby/library/net/ftp/shared/gettextfile.rb
+++ b/spec/ruby/library/net/ftp/shared/gettextfile.rb
@@ -43,32 +43,32 @@ describe :net_ftp_gettextfile, shared: :true do
describe "when the RETR command fails" do
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:retr).and_respond("450 Requested file action not taken.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPProtoError when the response code is 550" do
@server.should_receive(:retr).and_respond("Requested action not taken.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:retr).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:retr).and_respond("501 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:retr).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:retr).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
end
@@ -76,25 +76,25 @@ describe :net_ftp_gettextfile, shared: :true do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.")
@server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.")
@server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.")
@server.should_receive(:port).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:eprt).and_respond("530 Not logged in.")
@server.should_receive(:port).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/shared/list.rb b/spec/ruby/library/net/ftp/shared/list.rb
index adc3fa59c1..50ca8ad119 100644
--- a/spec/ruby/library/net/ftp/shared/list.rb
+++ b/spec/ruby/library/net/ftp/shared/list.rb
@@ -47,32 +47,32 @@ describe :net_ftp_list, shared: true do
describe "when the LIST command fails" do
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:list).and_respond("450 Requested file action not taken..")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:list).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:list).and_respond("501 Syntax error, command unrecognized.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:list).and_respond("502 Command not implemented.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:list).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:list).and_respond("530 Not logged in.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
end
end
@@ -80,25 +80,25 @@ describe :net_ftp_list, shared: true do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.")
@server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.")
@server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.")
@server.should_receive(:port).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:eprt).and_respond("530 Not logged in.")
@server.should_receive(:port).and_respond("530 Not logged in.")
- -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method) }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/shared/putbinaryfile.rb b/spec/ruby/library/net/ftp/shared/putbinaryfile.rb
index 1163a1cfea..74eaf320ae 100644
--- a/spec/ruby/library/net/ftp/shared/putbinaryfile.rb
+++ b/spec/ruby/library/net/ftp/shared/putbinaryfile.rb
@@ -67,32 +67,32 @@ describe :net_ftp_putbinaryfile, shared: :true do
describe "and the APPE command fails" do
it "raises a Net::FTPProtoError when the response code is 550" do
@server.should_receive(:appe).and_respond("Requested action not taken.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPProtoError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:appe).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:appe).and_respond("501 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:appe).and_respond("502 Command not implemented.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:appe).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:appe).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
end
end
@@ -100,42 +100,42 @@ describe :net_ftp_putbinaryfile, shared: :true do
describe "when the STOR command fails" do
it "raises a Net::FTPPermError when the response code is 532" do
@server.should_receive(:stor).and_respond("532 Need account for storing files.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:stor).and_respond("450 Requested file action not taken.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPTempError when the response code is 452" do
@server.should_receive(:stor).and_respond("452 Requested action not taken.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 553" do
@server.should_receive(:stor).and_respond("553 Requested action not taken.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:stor).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:stor).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:stor).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:stor).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
end
@@ -143,25 +143,25 @@ describe :net_ftp_putbinaryfile, shared: :true do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.")
@server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.")
@server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.")
@server.should_receive(:port).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:eprt).and_respond("530 Not logged in.")
@server.should_receive(:port).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/shared/puttextfile.rb b/spec/ruby/library/net/ftp/shared/puttextfile.rb
index 50e8de28e6..9bfdc7c41e 100644
--- a/spec/ruby/library/net/ftp/shared/puttextfile.rb
+++ b/spec/ruby/library/net/ftp/shared/puttextfile.rb
@@ -53,42 +53,42 @@ describe :net_ftp_puttextfile, shared: true do
describe "when the STOR command fails" do
it "raises a Net::FTPPermError when the response code is 532" do
@server.should_receive(:stor).and_respond("532 Need account for storing files.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 450" do
@server.should_receive(:stor).and_respond("450 Requested file action not taken.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPTempError when the response code is 452" do
@server.should_receive(:stor).and_respond("452 Requested action not taken.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 553" do
@server.should_receive(:stor).and_respond("553 Requested action not taken.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:stor).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:stor).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:stor).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:stor).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
end
@@ -96,25 +96,25 @@ describe :net_ftp_puttextfile, shared: true do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.")
@server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.")
@server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.")
@server.should_receive(:port).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:eprt).and_respond("530 Not logged in.")
@server.should_receive(:port).and_respond("530 Not logged in.")
- -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError)
end
end
end
diff --git a/spec/ruby/library/net/ftp/site_spec.rb b/spec/ruby/library/net/ftp/site_spec.rb
index 4d6a9b4a0c..d02b94e899 100644
--- a/spec/ruby/library/net/ftp/site_spec.rb
+++ b/spec/ruby/library/net/ftp/site_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#site" do
before :each do
@@ -28,26 +28,26 @@ describe "Net::FTP#site" do
it "does not raise an error when the response code is 202" do
@server.should_receive(:site).and_respond("202 Command not implemented, superfluous at this site.")
- -> { @ftp.site("param") }.should_not raise_error
+ lambda { @ftp.site("param") }.should_not raise_error
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:site).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.site("param") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.site("param") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:site).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.site("param") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.site("param") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:site).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.site("param") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.site("param") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:site).and_respond("530 Requested action not taken.")
- -> { @ftp.site("param") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.site("param") }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/size_spec.rb b/spec/ruby/library/net/ftp/size_spec.rb
index 17615079e9..a3d5db50b4 100644
--- a/spec/ruby/library/net/ftp/size_spec.rb
+++ b/spec/ruby/library/net/ftp/size_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#size" do
before :each do
@@ -28,21 +28,21 @@ describe "Net::FTP#size" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:size).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:size).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:size).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.size("test.file") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.size("test.file") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 550" do
@server.should_receive(:size).and_respond("550 Requested action not taken.")
- -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/status_spec.rb b/spec/ruby/library/net/ftp/status_spec.rb
index 6e3840bf93..243d3fc175 100644
--- a/spec/ruby/library/net/ftp/status_spec.rb
+++ b/spec/ruby/library/net/ftp/status_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#status" do
before :each do
@@ -22,8 +22,10 @@ describe "Net::FTP#status" do
@ftp.last_response.should == "211 System status, or system help reply. (STAT)\n"
end
- it "sends the STAT command with an optional parameter to the server" do
- @ftp.status("/pub").should == "211 System status, or system help reply. (STAT /pub)\n"
+ ruby_version_is "2.4" do
+ it "sends the STAT command with an optional parameter to the server" do
+ @ftp.status("/pub").should == "211 System status, or system help reply. (STAT /pub)\n"
+ end
end
it "returns the received information" do
@@ -32,36 +34,36 @@ describe "Net::FTP#status" do
it "does not raise an error when the response code is 212" do
@server.should_receive(:stat).and_respond("212 Directory status.")
- -> { @ftp.status }.should_not raise_error
+ lambda { @ftp.status }.should_not raise_error
end
it "does not raise an error when the response code is 213" do
@server.should_receive(:stat).and_respond("213 File status.")
- -> { @ftp.status }.should_not raise_error
+ lambda { @ftp.status }.should_not raise_error
end
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:stat).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.status }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.status }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:stat).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.status }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.status }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:stat).and_respond("502 Command not implemented.")
- -> { @ftp.status }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.status }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:stat).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.status }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.status }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 530" do
@server.should_receive(:stat).and_respond("530 Requested action not taken.")
- -> { @ftp.status }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.status }.should raise_error(Net::FTPPermError)
end
end
diff --git a/spec/ruby/library/net/ftp/storbinary_spec.rb b/spec/ruby/library/net/ftp/storbinary_spec.rb
index eb65db1e8d..fc7561b5a9 100644
--- a/spec/ruby/library/net/ftp/storbinary_spec.rb
+++ b/spec/ruby/library/net/ftp/storbinary_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#storbinary" do
before :each do
diff --git a/spec/ruby/library/net/ftp/storlines_spec.rb b/spec/ruby/library/net/ftp/storlines_spec.rb
index 4affa37eee..9ea4b83603 100644
--- a/spec/ruby/library/net/ftp/storlines_spec.rb
+++ b/spec/ruby/library/net/ftp/storlines_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#storlines" do
before :each do
diff --git a/spec/ruby/library/net/ftp/system_spec.rb b/spec/ruby/library/net/ftp/system_spec.rb
index 749258622d..603dd09152 100644
--- a/spec/ruby/library/net/ftp/system_spec.rb
+++ b/spec/ruby/library/net/ftp/system_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#system" do
before :each do
@@ -28,21 +28,21 @@ describe "Net::FTP#system" do
it "raises a Net::FTPPermError when the response code is 500" do
@server.should_receive(:syst).and_respond("500 Syntax error, command unrecognized.")
- -> { @ftp.system }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.system }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 501" do
@server.should_receive(:syst).and_respond("501 Syntax error in parameters or arguments.")
- -> { @ftp.system }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.system }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPPermError when the response code is 502" do
@server.should_receive(:syst).and_respond("502 Command not implemented.")
- -> { @ftp.system }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.system }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPTempError when the response code is 421" do
@server.should_receive(:syst).and_respond("421 Service not available, closing control connection.")
- -> { @ftp.system }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.system }.should raise_error(Net::FTPTempError)
end
end
diff --git a/spec/ruby/library/net/ftp/voidcmd_spec.rb b/spec/ruby/library/net/ftp/voidcmd_spec.rb
index 3673c7fd5b..8b3e0c17c9 100644
--- a/spec/ruby/library/net/ftp/voidcmd_spec.rb
+++ b/spec/ruby/library/net/ftp/voidcmd_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#voidcmd" do
before :each do
@@ -19,7 +19,7 @@ describe "Net::FTP#voidcmd" do
it "sends the passed command to the server" do
@server.should_receive(:help).and_respond("2xx Does not raise.")
- -> { @ftp.voidcmd("HELP") }.should_not raise_error
+ lambda { @ftp.voidcmd("HELP") }.should_not raise_error
end
it "returns nil" do
@@ -29,26 +29,26 @@ describe "Net::FTP#voidcmd" do
it "raises a Net::FTPReplyError when the response code is 1xx" do
@server.should_receive(:help).and_respond("1xx Does raise a Net::FTPReplyError.")
- -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError)
+ lambda { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError)
end
it "raises a Net::FTPReplyError when the response code is 3xx" do
@server.should_receive(:help).and_respond("3xx Does raise a Net::FTPReplyError.")
- -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError)
+ lambda { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError)
end
it "raises a Net::FTPTempError when the response code is 4xx" do
@server.should_receive(:help).and_respond("4xx Does raise a Net::FTPTempError.")
- -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPTempError)
+ lambda { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPTempError)
end
it "raises a Net::FTPPermError when the response code is 5xx" do
@server.should_receive(:help).and_respond("5xx Does raise a Net::FTPPermError.")
- -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPPermError)
+ lambda { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPPermError)
end
it "raises a Net::FTPProtoError when the response code is not valid" do
@server.should_receive(:help).and_respond("999 Does raise a Net::FTPProtoError.")
- -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPProtoError)
+ lambda { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPProtoError)
end
end
diff --git a/spec/ruby/library/net/ftp/welcome_spec.rb b/spec/ruby/library/net/ftp/welcome_spec.rb
index a0d7483949..5505623ce3 100644
--- a/spec/ruby/library/net/ftp/welcome_spec.rb
+++ b/spec/ruby/library/net/ftp/welcome_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative 'spec_helper'
-require_relative 'fixtures/server'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/server', __FILE__)
describe "Net::FTP#welcome" do
before :each do
diff --git a/spec/ruby/library/net/http/HTTPBadResponse_spec.rb b/spec/ruby/library/net/http/HTTPBadResponse_spec.rb
index be644968f5..78bb0c8420 100644
--- a/spec/ruby/library/net/http/HTTPBadResponse_spec.rb
+++ b/spec/ruby/library/net/http/HTTPBadResponse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPBadResponse" do
diff --git a/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb b/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb
deleted file mode 100644
index 08347464ec..0000000000
--- a/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../../spec_helper'
-require 'net/http'
-
-ruby_version_is "2.6" do
- describe "Net::HTTPClientException" do
- it "is a subclass of Net::ProtoServerError" do
- Net::HTTPClientException.should < Net::ProtoServerError
- end
-
- it "includes the Net::HTTPExceptions module" do
- Net::HTTPClientException.should < Net::HTTPExceptions
- end
- end
-end
diff --git a/spec/ruby/library/net/http/HTTPError_spec.rb b/spec/ruby/library/net/http/HTTPError_spec.rb
index ab5f491bb7..5fa87f140b 100644
--- a/spec/ruby/library/net/http/HTTPError_spec.rb
+++ b/spec/ruby/library/net/http/HTTPError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPError" do
diff --git a/spec/ruby/library/net/http/HTTPFatalError_spec.rb b/spec/ruby/library/net/http/HTTPFatalError_spec.rb
index 6ab36bff6c..72468faf8d 100644
--- a/spec/ruby/library/net/http/HTTPFatalError_spec.rb
+++ b/spec/ruby/library/net/http/HTTPFatalError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPFatalError" do
diff --git a/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb b/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb
index 38e9454f99..3e7ee24365 100644
--- a/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb
+++ b/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPHeaderSyntaxError" do
diff --git a/spec/ruby/library/net/http/HTTPRetriableError_spec.rb b/spec/ruby/library/net/http/HTTPRetriableError_spec.rb
index 3a4bb9146c..71f6bdb196 100644
--- a/spec/ruby/library/net/http/HTTPRetriableError_spec.rb
+++ b/spec/ruby/library/net/http/HTTPRetriableError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPRetriableError" do
diff --git a/spec/ruby/library/net/http/HTTPServerException_spec.rb b/spec/ruby/library/net/http/HTTPServerException_spec.rb
index b8ac8cac76..35566ab0c5 100644
--- a/spec/ruby/library/net/http/HTTPServerException_spec.rb
+++ b/spec/ruby/library/net/http/HTTPServerException_spec.rb
@@ -1,26 +1,12 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'net/http'
-ruby_version_is ""..."2.6" do
- describe "Net::HTTPServerException" do
- it "is a subclass of Net::ProtoServerError" do
- Net::HTTPServerException.should < Net::ProtoServerError
- end
-
- it "includes the Net::HTTPExceptions module" do
- Net::HTTPServerException.should < Net::HTTPExceptions
- end
+describe "Net::HTTPServerException" do
+ it "is a subclass of Net::ProtoServerError" do
+ Net::HTTPServerException.should < Net::ProtoServerError
end
-end
-
-ruby_version_is "2.6"..."2.7" do
- describe "Net::HTTPServerException" do
- it "is a subclass of Net::ProtoServerError and is warned as deprecated" do
- -> { Net::HTTPServerException.should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
- end
- it "includes the Net::HTTPExceptions module and is warned as deprecated" do
- -> { Net::HTTPServerException.should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
- end
+ it "includes the Net::HTTPExceptions module" do
+ Net::HTTPServerException.should < Net::HTTPExceptions
end
end
diff --git a/spec/ruby/library/net/http/http/Proxy_spec.rb b/spec/ruby/library/net/http/http/Proxy_spec.rb
index f85ccc0ee9..2de3fb2d75 100644
--- a/spec/ruby/library/net/http/http/Proxy_spec.rb
+++ b/spec/ruby/library/net/http/http/Proxy_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.Proxy" do
diff --git a/spec/ruby/library/net/http/http/active_spec.rb b/spec/ruby/library/net/http/http/active_spec.rb
index ef657243ba..28f1872fa9 100644
--- a/spec/ruby/library/net/http/http/active_spec.rb
+++ b/spec/ruby/library/net/http/http/active_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/started'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/started', __FILE__)
describe "Net::HTTP#active?" do
it_behaves_like :net_http_started_p, :active?
diff --git a/spec/ruby/library/net/http/http/address_spec.rb b/spec/ruby/library/net/http/http/address_spec.rb
index 5fce76d767..a0fe28fb9e 100644
--- a/spec/ruby/library/net/http/http/address_spec.rb
+++ b/spec/ruby/library/net/http/http/address_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP#address" do
diff --git a/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb b/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb
index a97b7b6c43..52bede524e 100644
--- a/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb
+++ b/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP#close_on_empty_response" do
diff --git a/spec/ruby/library/net/http/http/copy_spec.rb b/spec/ruby/library/net/http/http/copy_spec.rb
index 5ebfdc334e..c3c5e784b1 100644
--- a/spec/ruby/library/net/http/http/copy_spec.rb
+++ b/spec/ruby/library/net/http/http/copy_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#copy" do
before :each do
diff --git a/spec/ruby/library/net/http/http/default_port_spec.rb b/spec/ruby/library/net/http/http/default_port_spec.rb
index 30db18efae..8d9b3ac64a 100644
--- a/spec/ruby/library/net/http/http/default_port_spec.rb
+++ b/spec/ruby/library/net/http/http/default_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.default_port" do
diff --git a/spec/ruby/library/net/http/http/delete_spec.rb b/spec/ruby/library/net/http/http/delete_spec.rb
index 160c653115..856d3b3af3 100644
--- a/spec/ruby/library/net/http/http/delete_spec.rb
+++ b/spec/ruby/library/net/http/http/delete_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#delete" do
before :each do
diff --git a/spec/ruby/library/net/http/http/finish_spec.rb b/spec/ruby/library/net/http/http/finish_spec.rb
index f98bc7be13..ccc6878961 100644
--- a/spec/ruby/library/net/http/http/finish_spec.rb
+++ b/spec/ruby/library/net/http/http/finish_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#finish" do
before :each do
@@ -23,7 +23,7 @@ describe "Net::HTTP#finish" do
describe "when self has not been started yet" do
it "raises an IOError" do
- -> { @http.finish }.should raise_error(IOError)
+ lambda { @http.finish }.should raise_error(IOError)
end
end
end
diff --git a/spec/ruby/library/net/http/http/get2_spec.rb b/spec/ruby/library/net/http/http/get2_spec.rb
index 71dfc3d39b..2173156adf 100644
--- a/spec/ruby/library/net/http/http/get2_spec.rb
+++ b/spec/ruby/library/net/http/http/get2_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_get'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_get', __FILE__)
describe "Net::HTTP#get2" do
it_behaves_like :net_ftp_request_get, :get2
diff --git a/spec/ruby/library/net/http/http/get_print_spec.rb b/spec/ruby/library/net/http/http/get_print_spec.rb
index f59dd68c81..d91a584aaa 100644
--- a/spec/ruby/library/net/http/http/get_print_spec.rb
+++ b/spec/ruby/library/net/http/http/get_print_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP.get_print" do
before :each do
@@ -14,7 +14,7 @@ describe "Net::HTTP.get_print" do
describe "when passed URI" do
it "it prints the body of the specified uri to $stdout" do
- -> do
+ lambda do
Net::HTTP.get_print URI.parse("http://localhost:#{@port}/")
end.should output(/This is the index page\./)
end
@@ -22,7 +22,7 @@ describe "Net::HTTP.get_print" do
describe "when passed host, path, port" do
it "it prints the body of the specified uri to $stdout" do
- -> do
+ lambda do
Net::HTTP.get_print 'localhost', "/", @port
end.should output(/This is the index page\./)
end
diff --git a/spec/ruby/library/net/http/http/get_response_spec.rb b/spec/ruby/library/net/http/http/get_response_spec.rb
index 941b35e773..fdc1ae1f66 100644
--- a/spec/ruby/library/net/http/http/get_response_spec.rb
+++ b/spec/ruby/library/net/http/http/get_response_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP.get_response" do
before :each do
diff --git a/spec/ruby/library/net/http/http/get_spec.rb b/spec/ruby/library/net/http/http/get_spec.rb
index e6cd50fa27..d434191d2d 100644
--- a/spec/ruby/library/net/http/http/get_spec.rb
+++ b/spec/ruby/library/net/http/http/get_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP.get when passed URI" do
before :each do
@@ -24,72 +24,3 @@ describe "Net::HTTP.get when passed URI" do
end
end
end
-
-quarantine! do # These specs fail frequently with CHECK_LEAKS=true
-describe "Net::HTTP.get" do
- describe "when reading gzipped contents" do
- def start_threads
- require 'zlib'
-
- server = nil
- server_thread = Thread.new do
- server = TCPServer.new("127.0.0.1", 0)
- begin
- c = server.accept
- ensure
- server.close
- end
- c.print "HTTP/1.1 200\r\n"
- c.print "Content-Type: text/plain\r\n"
- c.print "Content-Encoding: gzip\r\n"
- s = StringIO.new
- z = Zlib::GzipWriter.new(s)
- begin
- z.write 'Hello World!'
- ensure
- z.close
- end
- c.print "Content-Length: #{s.length}\r\n\r\n"
- # Write partial gzip content
- c.write s.string.byteslice(0..-2)
- c.flush
- c
- end
- Thread.pass until server && server_thread.stop?
-
- client_thread = Thread.new do
- Thread.current.report_on_exception = false
- Net::HTTP.get("127.0.0.1", '/', server.connect_address.ip_port)
- end
- Thread.pass until client_thread.stop?
-
- [server_thread, client_thread]
- end
-
- it "propagates exceptions interrupting the thread and does not replace it with Zlib::BufError" do
- my_exception = Class.new(RuntimeError)
- server_thread, client_thread = start_threads
- socket = server_thread.value
- begin
- client_thread.raise my_exception, "my exception"
- -> { client_thread.value }.should raise_error(my_exception)
- ensure
- socket.close
- end
- end
-
- ruby_version_is "2.8" do # https://bugs.ruby-lang.org/issues/13882#note-6
- it "lets the kill Thread exception goes through and does not replace it with Zlib::BufError" do
- server_thread, client_thread = start_threads
- socket = server_thread.value
- begin
- client_thread.kill
- client_thread.value.should == nil
- ensure
- socket.close
- end
- end
- end
- end
-end
-end
diff --git a/spec/ruby/library/net/http/http/head2_spec.rb b/spec/ruby/library/net/http/http/head2_spec.rb
index 606798e4af..66d533c84d 100644
--- a/spec/ruby/library/net/http/http/head2_spec.rb
+++ b/spec/ruby/library/net/http/http/head2_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_head'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_head', __FILE__)
describe "Net::HTTP#head2" do
it_behaves_like :net_ftp_request_head, :head2
end
+
diff --git a/spec/ruby/library/net/http/http/head_spec.rb b/spec/ruby/library/net/http/http/head_spec.rb
index 925a8e6043..d0d13a6451 100644
--- a/spec/ruby/library/net/http/http/head_spec.rb
+++ b/spec/ruby/library/net/http/http/head_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#head" do
before :each do
diff --git a/spec/ruby/library/net/http/http/http_default_port_spec.rb b/spec/ruby/library/net/http/http/http_default_port_spec.rb
index cf7f73e630..6b840bbf30 100644
--- a/spec/ruby/library/net/http/http/http_default_port_spec.rb
+++ b/spec/ruby/library/net/http/http/http_default_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.http_default_port" do
diff --git a/spec/ruby/library/net/http/http/https_default_port_spec.rb b/spec/ruby/library/net/http/http/https_default_port_spec.rb
index fbf0bd1abc..bd213f2325 100644
--- a/spec/ruby/library/net/http/http/https_default_port_spec.rb
+++ b/spec/ruby/library/net/http/http/https_default_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.https_default_port" do
diff --git a/spec/ruby/library/net/http/http/initialize_spec.rb b/spec/ruby/library/net/http/http/initialize_spec.rb
index 7683713a0e..0cd59f493d 100644
--- a/spec/ruby/library/net/http/http/initialize_spec.rb
+++ b/spec/ruby/library/net/http/http/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP#initialize" do
diff --git a/spec/ruby/library/net/http/http/inspect_spec.rb b/spec/ruby/library/net/http/http/inspect_spec.rb
index b1e799ca34..7c5d9bf0eb 100644
--- a/spec/ruby/library/net/http/http/inspect_spec.rb
+++ b/spec/ruby/library/net/http/http/inspect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#inspect" do
before :each do
diff --git a/spec/ruby/library/net/http/http/is_version_1_1_spec.rb b/spec/ruby/library/net/http/http/is_version_1_1_spec.rb
index f37695b777..8fa5da6be7 100644
--- a/spec/ruby/library/net/http/http/is_version_1_1_spec.rb
+++ b/spec/ruby/library/net/http/http/is_version_1_1_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'shared/version_1_1'
+require File.expand_path('../shared/version_1_1', __FILE__)
describe "Net::HTTP.is_version_1_1?" do
it_behaves_like :net_http_version_1_1_p, :is_version_1_1?
diff --git a/spec/ruby/library/net/http/http/is_version_1_2_spec.rb b/spec/ruby/library/net/http/http/is_version_1_2_spec.rb
index 82dbdc87aa..344ac7f7c0 100644
--- a/spec/ruby/library/net/http/http/is_version_1_2_spec.rb
+++ b/spec/ruby/library/net/http/http/is_version_1_2_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'shared/version_1_2'
+require File.expand_path('../shared/version_1_2', __FILE__)
describe "Net::HTTP.is_version_1_2?" do
it_behaves_like :net_http_version_1_2_p, :is_version_1_2?
diff --git a/spec/ruby/library/net/http/http/lock_spec.rb b/spec/ruby/library/net/http/http/lock_spec.rb
index bb76607a8b..e44099f9e5 100644
--- a/spec/ruby/library/net/http/http/lock_spec.rb
+++ b/spec/ruby/library/net/http/http/lock_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#lock" do
before :each do
diff --git a/spec/ruby/library/net/http/http/mkcol_spec.rb b/spec/ruby/library/net/http/http/mkcol_spec.rb
index 33017625e2..51b0a5b9c0 100644
--- a/spec/ruby/library/net/http/http/mkcol_spec.rb
+++ b/spec/ruby/library/net/http/http/mkcol_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#mkcol" do
before :each do
diff --git a/spec/ruby/library/net/http/http/move_spec.rb b/spec/ruby/library/net/http/http/move_spec.rb
index 4d6b828150..0aa00195f8 100644
--- a/spec/ruby/library/net/http/http/move_spec.rb
+++ b/spec/ruby/library/net/http/http/move_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#head" do
before :each do
diff --git a/spec/ruby/library/net/http/http/new_spec.rb b/spec/ruby/library/net/http/http/new_spec.rb
index 491d1d01fd..b741eb0a4c 100644
--- a/spec/ruby/library/net/http/http/new_spec.rb
+++ b/spec/ruby/library/net/http/http/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.new" do
diff --git a/spec/ruby/library/net/http/http/newobj_spec.rb b/spec/ruby/library/net/http/http/newobj_spec.rb
index b261dcc5db..88d5881725 100644
--- a/spec/ruby/library/net/http/http/newobj_spec.rb
+++ b/spec/ruby/library/net/http/http/newobj_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.newobj" do
diff --git a/spec/ruby/library/net/http/http/open_timeout_spec.rb b/spec/ruby/library/net/http/http/open_timeout_spec.rb
index 44b33615e6..0142ae6c06 100644
--- a/spec/ruby/library/net/http/http/open_timeout_spec.rb
+++ b/spec/ruby/library/net/http/http/open_timeout_spec.rb
@@ -1,12 +1,23 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP#open_timeout" do
- it "returns the seconds to wait till the connection is open" do
- net = Net::HTTP.new("localhost")
- net.open_timeout.should eql(60)
- net.open_timeout = 10
- net.open_timeout.should eql(10)
+ ruby_version_is ""..."2.3" do
+ it "returns the seconds to wait till the connection is open" do
+ net = Net::HTTP.new("localhost")
+ net.open_timeout.should be_nil
+ net.open_timeout = 10
+ net.open_timeout.should eql(10)
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "returns the seconds to wait till the connection is open" do
+ net = Net::HTTP.new("localhost")
+ net.open_timeout.should eql(60)
+ net.open_timeout = 10
+ net.open_timeout.should eql(10)
+ end
end
end
diff --git a/spec/ruby/library/net/http/http/options_spec.rb b/spec/ruby/library/net/http/http/options_spec.rb
index d798e69197..9c5e810105 100644
--- a/spec/ruby/library/net/http/http/options_spec.rb
+++ b/spec/ruby/library/net/http/http/options_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#options" do
before :each do
diff --git a/spec/ruby/library/net/http/http/port_spec.rb b/spec/ruby/library/net/http/http/port_spec.rb
index 7de295ca75..a916f722bf 100644
--- a/spec/ruby/library/net/http/http/port_spec.rb
+++ b/spec/ruby/library/net/http/http/port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP#port" do
diff --git a/spec/ruby/library/net/http/http/post2_spec.rb b/spec/ruby/library/net/http/http/post2_spec.rb
index eab9a6a1d2..298b2277bc 100644
--- a/spec/ruby/library/net/http/http/post2_spec.rb
+++ b/spec/ruby/library/net/http/http/post2_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_post'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_post', __FILE__)
describe "Net::HTTP#post2" do
it_behaves_like :net_ftp_request_post, :post2
diff --git a/spec/ruby/library/net/http/http/post_form_spec.rb b/spec/ruby/library/net/http/http/post_form_spec.rb
index 891e05e7af..4a5d7ec731 100644
--- a/spec/ruby/library/net/http/http/post_form_spec.rb
+++ b/spec/ruby/library/net/http/http/post_form_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP.post_form when passed URI" do
before :each do
diff --git a/spec/ruby/library/net/http/http/post_spec.rb b/spec/ruby/library/net/http/http/post_spec.rb
index 9f20a03c85..66a00f0670 100644
--- a/spec/ruby/library/net/http/http/post_spec.rb
+++ b/spec/ruby/library/net/http/http/post_spec.rb
@@ -1,40 +1,42 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require 'uri'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
-describe "Net::HTTP.post" do
- before :each do
- NetHTTPSpecs.start_server
- end
+ruby_version_is '2.4' do
+ describe "Net::HTTP.post" do
+ before :each do
+ NetHTTPSpecs.start_server
+ end
- after :each do
- NetHTTPSpecs.stop_server
- end
+ after :each do
+ NetHTTPSpecs.stop_server
+ end
- it "sends post request to the specified URI and returns response" do
- response = Net::HTTP.post(
- URI("http://localhost:#{NetHTTPSpecs.port}/request"),
- '{ "q": "ruby", "max": "50" }',
- "Content-Type" => "application/json")
- response.body.should == "Request type: POST"
- end
+ it "sends post request to the specified URI and returns response" do
+ response = Net::HTTP.post(
+ URI("http://localhost:#{NetHTTPSpecs.port}/request"),
+ '{ "q": "ruby", "max": "50" }',
+ "Content-Type" => "application/json")
+ response.body.should == "Request type: POST"
+ end
- it "returns a Net::HTTPResponse" do
- response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test")
- response.should be_kind_of(Net::HTTPResponse)
- end
+ it "returns a Net::HTTPResponse" do
+ response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test")
+ response.should be_kind_of(Net::HTTPResponse)
+ end
- it "sends Content-Type: application/x-www-form-urlencoded by default" do
- response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
- response.body.should include('"content-type"=>["application/x-www-form-urlencoded"]')
- end
+ it "sends Content-Type: application/x-www-form-urlencoded by default" do
+ response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
+ response.body.should include('"content-type"=>["application/x-www-form-urlencoded"]')
+ end
- it "does not support HTTP Basic Auth" do
- response = Net::HTTP.post(
- URI("http://john:qwerty@localhost:#{NetHTTPSpecs.port}/request/basic_auth"),
- "test=test")
- response.body.should == "username: \npassword: "
+ it "does not support HTTP Basic Auth" do
+ response = Net::HTTP.post(
+ URI("http://john:qwerty@localhost:#{NetHTTPSpecs.port}/request/basic_auth"),
+ "test=test")
+ response.body.should == "username: \npassword: "
+ end
end
end
@@ -72,3 +74,4 @@ describe "Net::HTTP#post" do
end
end
end
+
diff --git a/spec/ruby/library/net/http/http/propfind_spec.rb b/spec/ruby/library/net/http/http/propfind_spec.rb
index 5240171618..c242eeec68 100644
--- a/spec/ruby/library/net/http/http/propfind_spec.rb
+++ b/spec/ruby/library/net/http/http/propfind_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#propfind" do
before :each do
diff --git a/spec/ruby/library/net/http/http/proppatch_spec.rb b/spec/ruby/library/net/http/http/proppatch_spec.rb
index 7a761a9f23..8567f60719 100644
--- a/spec/ruby/library/net/http/http/proppatch_spec.rb
+++ b/spec/ruby/library/net/http/http/proppatch_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#proppatch" do
before :each do
diff --git a/spec/ruby/library/net/http/http/proxy_address_spec.rb b/spec/ruby/library/net/http/http/proxy_address_spec.rb
index 8d152b8d44..85f8dfedb4 100644
--- a/spec/ruby/library/net/http/http/proxy_address_spec.rb
+++ b/spec/ruby/library/net/http/http/proxy_address_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.proxy_address" do
diff --git a/spec/ruby/library/net/http/http/proxy_class_spec.rb b/spec/ruby/library/net/http/http/proxy_class_spec.rb
index 2d32a39f01..30d38a93e7 100644
--- a/spec/ruby/library/net/http/http/proxy_class_spec.rb
+++ b/spec/ruby/library/net/http/http/proxy_class_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.proxy_class?" do
- it "returns true if self is a class created with Net::HTTP.Proxy" do
+ it "returns true if sels is a class created with Net::HTTP.Proxy" do
Net::HTTP.proxy_class?.should be_false
Net::HTTP.Proxy("localhost").proxy_class?.should be_true
end
diff --git a/spec/ruby/library/net/http/http/proxy_pass_spec.rb b/spec/ruby/library/net/http/http/proxy_pass_spec.rb
index 94a0034544..09db6f2877 100644
--- a/spec/ruby/library/net/http/http/proxy_pass_spec.rb
+++ b/spec/ruby/library/net/http/http/proxy_pass_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.proxy_pass" do
diff --git a/spec/ruby/library/net/http/http/proxy_port_spec.rb b/spec/ruby/library/net/http/http/proxy_port_spec.rb
index 339f7ee850..0655232c6b 100644
--- a/spec/ruby/library/net/http/http/proxy_port_spec.rb
+++ b/spec/ruby/library/net/http/http/proxy_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.proxy_port" do
diff --git a/spec/ruby/library/net/http/http/proxy_user_spec.rb b/spec/ruby/library/net/http/http/proxy_user_spec.rb
index 01fda400e9..1beacca642 100644
--- a/spec/ruby/library/net/http/http/proxy_user_spec.rb
+++ b/spec/ruby/library/net/http/http/proxy_user_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.proxy_user" do
diff --git a/spec/ruby/library/net/http/http/put2_spec.rb b/spec/ruby/library/net/http/http/put2_spec.rb
index 0ee3590639..a0e832d170 100644
--- a/spec/ruby/library/net/http/http/put2_spec.rb
+++ b/spec/ruby/library/net/http/http/put2_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_put'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_put', __FILE__)
describe "Net::HTTP#put2" do
it_behaves_like :net_ftp_request_put, :put2
diff --git a/spec/ruby/library/net/http/http/put_spec.rb b/spec/ruby/library/net/http/http/put_spec.rb
index 3ca0d0963e..ab7e794db0 100644
--- a/spec/ruby/library/net/http/http/put_spec.rb
+++ b/spec/ruby/library/net/http/http/put_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#put" do
before :each do
diff --git a/spec/ruby/library/net/http/http/read_timeout_spec.rb b/spec/ruby/library/net/http/http/read_timeout_spec.rb
index e23ee76025..86f2e0246d 100644
--- a/spec/ruby/library/net/http/http/read_timeout_spec.rb
+++ b/spec/ruby/library/net/http/http/read_timeout_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP#read_timeout" do
diff --git a/spec/ruby/library/net/http/http/request_get_spec.rb b/spec/ruby/library/net/http/http/request_get_spec.rb
index f53a2e9d65..33b040c622 100644
--- a/spec/ruby/library/net/http/http/request_get_spec.rb
+++ b/spec/ruby/library/net/http/http/request_get_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_get'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_get', __FILE__)
describe "Net::HTTP#request_get" do
it_behaves_like :net_ftp_request_get, :get2
diff --git a/spec/ruby/library/net/http/http/request_head_spec.rb b/spec/ruby/library/net/http/http/request_head_spec.rb
index dc47557b9d..85ff56dcb5 100644
--- a/spec/ruby/library/net/http/http/request_head_spec.rb
+++ b/spec/ruby/library/net/http/http/request_head_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_head'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_head', __FILE__)
describe "Net::HTTP#request_head" do
it_behaves_like :net_ftp_request_head, :request_head
diff --git a/spec/ruby/library/net/http/http/request_post_spec.rb b/spec/ruby/library/net/http/http/request_post_spec.rb
index 0b408fa84d..937b4d5d59 100644
--- a/spec/ruby/library/net/http/http/request_post_spec.rb
+++ b/spec/ruby/library/net/http/http/request_post_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_post'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_post', __FILE__)
describe "Net::HTTP#request_post" do
it_behaves_like :net_ftp_request_post, :request_post
diff --git a/spec/ruby/library/net/http/http/request_put_spec.rb b/spec/ruby/library/net/http/http/request_put_spec.rb
index 987b52ceb0..c3a4b6d538 100644
--- a/spec/ruby/library/net/http/http/request_put_spec.rb
+++ b/spec/ruby/library/net/http/http/request_put_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/request_put'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/request_put', __FILE__)
describe "Net::HTTP#request_put" do
it_behaves_like :net_ftp_request_put, :request_put
diff --git a/spec/ruby/library/net/http/http/request_spec.rb b/spec/ruby/library/net/http/http/request_spec.rb
index e63dde9c8d..d1c754df8c 100644
--- a/spec/ruby/library/net/http/http/request_spec.rb
+++ b/spec/ruby/library/net/http/http/request_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#request" do
before :each do
diff --git a/spec/ruby/library/net/http/http/request_types_spec.rb b/spec/ruby/library/net/http/http/request_types_spec.rb
index 99d754d3d1..71fe863bb2 100644
--- a/spec/ruby/library/net/http/http/request_types_spec.rb
+++ b/spec/ruby/library/net/http/http/request_types_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP::Get" do
diff --git a/spec/ruby/library/net/http/http/send_request_spec.rb b/spec/ruby/library/net/http/http/send_request_spec.rb
index 03fd32e470..5a704496ec 100644
--- a/spec/ruby/library/net/http/http/send_request_spec.rb
+++ b/spec/ruby/library/net/http/http/send_request_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#send_request" do
before :each do
diff --git a/spec/ruby/library/net/http/http/set_debug_output_spec.rb b/spec/ruby/library/net/http/http/set_debug_output_spec.rb
index 94b6f4499d..820c368cd0 100644
--- a/spec/ruby/library/net/http/http/set_debug_output_spec.rb
+++ b/spec/ruby/library/net/http/http/set_debug_output_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require "stringio"
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#set_debug_output when passed io" do
before :each do
@@ -28,6 +28,6 @@ describe "Net::HTTP#set_debug_output when passed io" do
it "outputs a warning when the connection has already been started" do
@http.start
- -> { @http.set_debug_output(StringIO.new) }.should complain(/Net::HTTP#set_debug_output called after HTTP started/)
+ lambda { @http.set_debug_output(StringIO.new) }.should complain(/Net::HTTP#set_debug_output called after HTTP started/)
end
end
diff --git a/spec/ruby/library/net/http/http/socket_type_spec.rb b/spec/ruby/library/net/http/http/socket_type_spec.rb
index 5c844ddf94..4ec9b68571 100644
--- a/spec/ruby/library/net/http/http/socket_type_spec.rb
+++ b/spec/ruby/library/net/http/http/socket_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP.socket_type" do
diff --git a/spec/ruby/library/net/http/http/start_spec.rb b/spec/ruby/library/net/http/http/start_spec.rb
index a2768eed18..407d57e494 100644
--- a/spec/ruby/library/net/http/http/start_spec.rb
+++ b/spec/ruby/library/net/http/http/start_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP.start" do
before :each do
@@ -81,7 +81,7 @@ describe "Net::HTTP#start" do
describe "when self has already been started" do
it "raises an IOError" do
@http.start
- -> { @http.start }.should raise_error(IOError)
+ lambda { @http.start }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/net/http/http/started_spec.rb b/spec/ruby/library/net/http/http/started_spec.rb
index ea441ed16a..01c17c93c1 100644
--- a/spec/ruby/library/net/http/http/started_spec.rb
+++ b/spec/ruby/library/net/http/http/started_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
-require_relative 'shared/started'
+require File.expand_path('../fixtures/http_server', __FILE__)
+require File.expand_path('../shared/started', __FILE__)
describe "Net::HTTP#started?" do
it_behaves_like :net_http_started_p, :started?
diff --git a/spec/ruby/library/net/http/http/trace_spec.rb b/spec/ruby/library/net/http/http/trace_spec.rb
index 94a1bf6655..6cce15fc09 100644
--- a/spec/ruby/library/net/http/http/trace_spec.rb
+++ b/spec/ruby/library/net/http/http/trace_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#trace" do
before :each do
diff --git a/spec/ruby/library/net/http/http/unlock_spec.rb b/spec/ruby/library/net/http/http/unlock_spec.rb
index a4f1b7a1d1..12df417e1a 100644
--- a/spec/ruby/library/net/http/http/unlock_spec.rb
+++ b/spec/ruby/library/net/http/http/unlock_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/http_server'
+require File.expand_path('../fixtures/http_server', __FILE__)
describe "Net::HTTP#unlock" do
before :each do
diff --git a/spec/ruby/library/net/http/http/use_ssl_spec.rb b/spec/ruby/library/net/http/http/use_ssl_spec.rb
index be1ec7fa25..19d065ed8e 100644
--- a/spec/ruby/library/net/http/http/use_ssl_spec.rb
+++ b/spec/ruby/library/net/http/http/use_ssl_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTP#use_ssl?" do
diff --git a/spec/ruby/library/net/http/http/version_1_1_spec.rb b/spec/ruby/library/net/http/http/version_1_1_spec.rb
index 1c069e9ea6..f13ec9b7f1 100644
--- a/spec/ruby/library/net/http/http/version_1_1_spec.rb
+++ b/spec/ruby/library/net/http/http/version_1_1_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'shared/version_1_1'
+require File.expand_path('../shared/version_1_1', __FILE__)
describe "Net::HTTP.version_1_1?" do
it_behaves_like :net_http_version_1_1_p, :version_1_1?
diff --git a/spec/ruby/library/net/http/http/version_1_2_spec.rb b/spec/ruby/library/net/http/http/version_1_2_spec.rb
index 4e601462c9..63c2112422 100644
--- a/spec/ruby/library/net/http/http/version_1_2_spec.rb
+++ b/spec/ruby/library/net/http/http/version_1_2_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'shared/version_1_2'
+require File.expand_path('../shared/version_1_2', __FILE__)
describe "Net::HTTP.version_1_2" do
it "turns on net/http 1.2 features" do
diff --git a/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb b/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb
index 8e3fd8cc02..8c0c4934f7 100644
--- a/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb
+++ b/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPExceptions#initialize when passed message, response" do
before :each do
diff --git a/spec/ruby/library/net/http/httpexceptions/response_spec.rb b/spec/ruby/library/net/http/httpexceptions/response_spec.rb
index 205b2bc212..becf74bddf 100644
--- a/spec/ruby/library/net/http/httpexceptions/response_spec.rb
+++ b/spec/ruby/library/net/http/httpexceptions/response_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPExceptions#response" do
it "returns self's response" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb
index 7d081939b8..cb3565b899 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPGenericRequest#body_exist?" do
@@ -13,9 +13,10 @@ describe "Net::HTTPGenericRequest#body_exist?" do
describe "when $VERBOSE is true" do
it "emits a warning" do
request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path")
- -> {
+ lambda {
+ $VERBOSE = true
request.body_exist?
- }.should complain(/body_exist\? is obsolete/, verbose: true)
+ }.should complain(/body_exist\? is obsolete/)
end
end
end
diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb
index a215895b57..4aa4fff2bc 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb
index c2a60e6836..df6e02a8c1 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb
index da5b1a63be..b3850d6c74 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require "stringio"
@@ -125,7 +125,7 @@ describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do
"Content-Type" => "text/html")
request.body_stream = StringIO.new("Some Content")
- -> { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should raise_error(ArgumentError)
+ lambda { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb
index 36240949c3..269ce4fe52 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPGenericRequest#inspect" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb
index 3f7c2cbf2b..eef87ff3a7 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPGenericRequest#method" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb
index fc4cf9af53..e48d37b0e9 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPGenericRequest#path" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb
index 50cd1ff637..1e0b3ab028 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPGenericRequest#request_body_permitted?" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb
index 0c4165d0ab..ee5a43e637 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPGenericRequest#response_body_permitted?" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb
index 7494c69173..bff8646d5a 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb
+++ b/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPGenericRequest#set_body_internal when passed string" do
@@ -13,9 +13,9 @@ describe "Net::HTTPGenericRequest#set_body_internal when passed string" do
it "raises an ArgumentError when the body or body_stream of self have already been set" do
@request.body = "Some Content"
- -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError)
+ lambda { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError)
@request.body_stream = "Some Content"
- -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError)
+ lambda { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/net/http/httpheader/add_field_spec.rb b/spec/ruby/library/net/http/httpheader/add_field_spec.rb
index 882d5ac5bb..b736a92694 100644
--- a/spec/ruby/library/net/http/httpheader/add_field_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/add_field_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#add_field when passed key, value" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb b/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb
index fa2a710fe1..b9ed792d46 100644
--- a/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#basic_auth when passed account, password" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb b/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb
index 0dddd3049b..a891c12d80 100644
--- a/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_capitalized'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_capitalized', __FILE__)
describe "Net::HTTPHeader#canonical_each" do
it_behaves_like :net_httpheader_each_capitalized, :canonical_each
diff --git a/spec/ruby/library/net/http/httpheader/chunked_spec.rb b/spec/ruby/library/net/http/httpheader/chunked_spec.rb
index 96b758981b..2b08baf34c 100644
--- a/spec/ruby/library/net/http/httpheader/chunked_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/chunked_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#chunked?" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/content_length_spec.rb b/spec/ruby/library/net/http/httpheader/content_length_spec.rb
index e344817e82..d93eb3a608 100644
--- a/spec/ruby/library/net/http/httpheader/content_length_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/content_length_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#content_length" do
before :each do
@@ -13,7 +13,7 @@ describe "Net::HTTPHeader#content_length" do
it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Length' header entry has an invalid format" do
@headers["Content-Length"] = "invalid"
- -> { @headers.content_length }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.content_length }.should raise_error(Net::HTTPHeaderSyntaxError)
end
it "returns the value of the 'Content-Length' header entry as an Integer" do
diff --git a/spec/ruby/library/net/http/httpheader/content_range_spec.rb b/spec/ruby/library/net/http/httpheader/content_range_spec.rb
index ba75f9a9a1..dc601fb365 100644
--- a/spec/ruby/library/net/http/httpheader/content_range_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/content_range_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#content_range" do
before :each do
@@ -21,12 +21,12 @@ describe "Net::HTTPHeader#content_range" do
it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do
@headers["Content-Range"] = "invalid"
- -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError)
@headers["Content-Range"] = "bytes 123-abc"
- -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError)
@headers["Content-Range"] = "bytes abc-123"
- -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError)
end
end
diff --git a/spec/ruby/library/net/http/httpheader/content_type_spec.rb b/spec/ruby/library/net/http/httpheader/content_type_spec.rb
index 1f8b4ba326..7c3dfba7e7 100644
--- a/spec/ruby/library/net/http/httpheader/content_type_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/content_type_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_content_type'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_content_type', __FILE__)
describe "Net::HTTPHeader#content_type" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/delete_spec.rb b/spec/ruby/library/net/http/httpheader/delete_spec.rb
index 603ae198de..9adbfd7813 100644
--- a/spec/ruby/library/net/http/httpheader/delete_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/delete_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#delete when passed key" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb b/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb
index 1af2c6939c..7adba9dec5 100644
--- a/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#each_capitalized_name" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb b/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb
index 961a2d051f..1dcf18a9d1 100644
--- a/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_capitalized'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_capitalized', __FILE__)
describe "Net::HTTPHeader#each_capitalized" do
it_behaves_like :net_httpheader_each_capitalized, :each_capitalized
end
+
diff --git a/spec/ruby/library/net/http/httpheader/each_header_spec.rb b/spec/ruby/library/net/http/httpheader/each_header_spec.rb
index 19634a001b..00d5894282 100644
--- a/spec/ruby/library/net/http/httpheader/each_header_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/each_header_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_header'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_header', __FILE__)
describe "Net::HTTPHeader#each_header" do
it_behaves_like :net_httpheader_each_header, :each_header
diff --git a/spec/ruby/library/net/http/httpheader/each_key_spec.rb b/spec/ruby/library/net/http/httpheader/each_key_spec.rb
index ebb17d2eac..5c81830be6 100644
--- a/spec/ruby/library/net/http/httpheader/each_key_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/each_key_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_name'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_name', __FILE__)
describe "Net::HTTPHeader#each_key" do
it_behaves_like :net_httpheader_each_name, :each_key
diff --git a/spec/ruby/library/net/http/httpheader/each_name_spec.rb b/spec/ruby/library/net/http/httpheader/each_name_spec.rb
index f4533ebcfb..e785ae249a 100644
--- a/spec/ruby/library/net/http/httpheader/each_name_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/each_name_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_name'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_name', __FILE__)
describe "Net::HTTPHeader#each_name" do
it_behaves_like :net_httpheader_each_name, :each_name
diff --git a/spec/ruby/library/net/http/httpheader/each_spec.rb b/spec/ruby/library/net/http/httpheader/each_spec.rb
index 7ba8434f75..e8fb6713c3 100644
--- a/spec/ruby/library/net/http/httpheader/each_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/each_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/each_header'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each_header', __FILE__)
describe "Net::HTTPHeader#each" do
it_behaves_like :net_httpheader_each_header, :each
diff --git a/spec/ruby/library/net/http/httpheader/each_value_spec.rb b/spec/ruby/library/net/http/httpheader/each_value_spec.rb
index 3224de7703..1adb723a53 100644
--- a/spec/ruby/library/net/http/httpheader/each_value_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/each_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#each_value" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/element_reference_spec.rb b/spec/ruby/library/net/http/httpheader/element_reference_spec.rb
index 4a35e20d20..bfe6b48ad4 100644
--- a/spec/ruby/library/net/http/httpheader/element_reference_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/element_reference_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#[] when passed key" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/element_set_spec.rb b/spec/ruby/library/net/http/httpheader/element_set_spec.rb
index e9ad64fafc..a5a2900e94 100644
--- a/spec/ruby/library/net/http/httpheader/element_set_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/element_set_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#[]= when passed key, value" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/fetch_spec.rb b/spec/ruby/library/net/http/httpheader/fetch_spec.rb
index ea15679acb..7182c4396e 100644
--- a/spec/ruby/library/net/http/httpheader/fetch_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/fetch_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#fetch" do
before :each do
@@ -25,7 +25,7 @@ describe "Net::HTTPHeader#fetch" do
end
it "returns nil when there is no entry for the passed key" do
- -> { @headers.fetch("my-header") }.should raise_error(IndexError)
+ lambda { @headers.fetch("my-header") }.should raise_error(IndexError)
end
end
diff --git a/spec/ruby/library/net/http/httpheader/form_data_spec.rb b/spec/ruby/library/net/http/httpheader/form_data_spec.rb
index 9b29a03159..7781990824 100644
--- a/spec/ruby/library/net/http/httpheader/form_data_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/form_data_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_form_data'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_form_data', __FILE__)
describe "Net::HTTPHeader#form_data=" do
it_behaves_like :net_httpheader_set_form_data, :form_data=
diff --git a/spec/ruby/library/net/http/httpheader/get_fields_spec.rb b/spec/ruby/library/net/http/httpheader/get_fields_spec.rb
index 1b623bf2a3..f7828f752c 100644
--- a/spec/ruby/library/net/http/httpheader/get_fields_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/get_fields_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#get_fields when passed key" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb b/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb
index efc5e7d0b2..ffb56642d4 100644
--- a/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#initialize_http_header when passed Hash" do
before :each do
@@ -14,8 +14,9 @@ describe "Net::HTTPHeader#initialize_http_header when passed Hash" do
end
it "complains about duplicate keys when in verbose mode" do
- -> do
+ lambda do
+ $VERBOSE = true
@headers.initialize_http_header("My-Header" => "test", "my-header" => "another test")
- end.should complain(/duplicated HTTP header/, verbose: true)
+ end.should complain(/duplicated HTTP header/)
end
end
diff --git a/spec/ruby/library/net/http/httpheader/key_spec.rb b/spec/ruby/library/net/http/httpheader/key_spec.rb
index 9099024229..0cb5f711dc 100644
--- a/spec/ruby/library/net/http/httpheader/key_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/key_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#key? when passed key" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/length_spec.rb b/spec/ruby/library/net/http/httpheader/length_spec.rb
index 0d1da149f4..50cb1c1f7f 100644
--- a/spec/ruby/library/net/http/httpheader/length_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/length_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/size'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/size', __FILE__)
describe "Net::HTTPHeader#length" do
it_behaves_like :net_httpheader_size, :length
diff --git a/spec/ruby/library/net/http/httpheader/main_type_spec.rb b/spec/ruby/library/net/http/httpheader/main_type_spec.rb
index 3e18de6b5b..34e2ddbc65 100644
--- a/spec/ruby/library/net/http/httpheader/main_type_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/main_type_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#main_type" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb b/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb
index 8b576ee164..5e7d87af36 100644
--- a/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#proxy_basic_auth when passed account, password" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/range_length_spec.rb b/spec/ruby/library/net/http/httpheader/range_length_spec.rb
index b8fce4f690..ec3b00d805 100644
--- a/spec/ruby/library/net/http/httpheader/range_length_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/range_length_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#range_length" do
before :each do
@@ -21,12 +21,12 @@ describe "Net::HTTPHeader#range_length" do
it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do
@headers["Content-Range"] = "invalid"
- -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError)
@headers["Content-Range"] = "bytes 123-abc"
- -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError)
@headers["Content-Range"] = "bytes abc-123"
- -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError)
end
end
diff --git a/spec/ruby/library/net/http/httpheader/range_spec.rb b/spec/ruby/library/net/http/httpheader/range_spec.rb
index 005177f6be..d71d2ed598 100644
--- a/spec/ruby/library/net/http/httpheader/range_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/range_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_range'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_range', __FILE__)
describe "Net::HTTPHeader#range" do
before :each do
@@ -28,18 +28,18 @@ describe "Net::HTTPHeader#range" do
it "raises a Net::HTTPHeaderSyntaxError when the 'Range' has an invalid format" do
@headers["Range"] = "invalid"
- -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
@headers["Range"] = "bytes 123-abc"
- -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
@headers["Range"] = "bytes abc-123"
- -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
end
it "raises a Net::HTTPHeaderSyntaxError when the 'Range' was not specified" do
@headers["Range"] = "bytes=-"
- -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError)
end
end
diff --git a/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb b/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb
index 125f7a7e0d..b9a62154ad 100644
--- a/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_content_type'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_content_type', __FILE__)
describe "Net::HTTPHeader#set_content_type" do
it_behaves_like :net_httpheader_set_content_type, :set_content_type
diff --git a/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb b/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb
index 14c66ae01c..e675437ba4 100644
--- a/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_form_data'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_form_data', __FILE__)
describe "Net::HTTPHeader#set_form_data" do
it_behaves_like :net_httpheader_set_form_data, :set_form_data
diff --git a/spec/ruby/library/net/http/httpheader/set_range_spec.rb b/spec/ruby/library/net/http/httpheader/set_range_spec.rb
index 85b9c50422..af3f00f99c 100644
--- a/spec/ruby/library/net/http/httpheader/set_range_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/set_range_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/set_range'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/set_range', __FILE__)
describe "Net::HTTPHeader#set_range" do
it_behaves_like :net_httpheader_set_range, :set_range
diff --git a/spec/ruby/library/net/http/httpheader/shared/set_range.rb b/spec/ruby/library/net/http/httpheader/shared/set_range.rb
index 87f51d46f3..6a98edbe10 100644
--- a/spec/ruby/library/net/http/httpheader/shared/set_range.rb
+++ b/spec/ruby/library/net/http/httpheader/shared/set_range.rb
@@ -50,15 +50,15 @@ describe :net_httpheader_set_range, shared: true do
end
it "raises a Net::HTTPHeaderSyntaxError when the first Range element is negative" do
- -> { @headers.send(@method, -10..5) }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.send(@method, -10..5) }.should raise_error(Net::HTTPHeaderSyntaxError)
end
it "raises a Net::HTTPHeaderSyntaxError when the last Range element is negative" do
- -> { @headers.send(@method, 10..-5) }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.send(@method, 10..-5) }.should raise_error(Net::HTTPHeaderSyntaxError)
end
it "raises a Net::HTTPHeaderSyntaxError when the last Range element is smaller than the first" do
- -> { @headers.send(@method, 10..5) }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.send(@method, 10..5) }.should raise_error(Net::HTTPHeaderSyntaxError)
end
end
@@ -75,15 +75,15 @@ describe :net_httpheader_set_range, shared: true do
end
it "raises a Net::HTTPHeaderSyntaxError when start is negative" do
- -> { @headers.send(@method, -10, 5) }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.send(@method, -10, 5) }.should raise_error(Net::HTTPHeaderSyntaxError)
end
it "raises a Net::HTTPHeaderSyntaxError when start + length is negative" do
- -> { @headers.send(@method, 10, -15) }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.send(@method, 10, -15) }.should raise_error(Net::HTTPHeaderSyntaxError)
end
it "raises a Net::HTTPHeaderSyntaxError when length is negative" do
- -> { @headers.send(@method, 10, -4) }.should raise_error(Net::HTTPHeaderSyntaxError)
+ lambda { @headers.send(@method, 10, -4) }.should raise_error(Net::HTTPHeaderSyntaxError)
end
end
end
diff --git a/spec/ruby/library/net/http/httpheader/size_spec.rb b/spec/ruby/library/net/http/httpheader/size_spec.rb
index a7d78f96e0..3ea3969046 100644
--- a/spec/ruby/library/net/http/httpheader/size_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/size_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
-require_relative 'shared/size'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/size', __FILE__)
describe "Net::HTTPHeader#size" do
it_behaves_like :net_httpheader_size, :size
diff --git a/spec/ruby/library/net/http/httpheader/sub_type_spec.rb b/spec/ruby/library/net/http/httpheader/sub_type_spec.rb
index 3c73ca0027..65cae5a3f3 100644
--- a/spec/ruby/library/net/http/httpheader/sub_type_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/sub_type_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#sub_type" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/to_hash_spec.rb b/spec/ruby/library/net/http/httpheader/to_hash_spec.rb
index 8c1d36c30a..4b59c78c90 100644
--- a/spec/ruby/library/net/http/httpheader/to_hash_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/to_hash_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#to_hash" do
before :each do
diff --git a/spec/ruby/library/net/http/httpheader/type_params_spec.rb b/spec/ruby/library/net/http/httpheader/type_params_spec.rb
index e77be7ea85..f4cd54f101 100644
--- a/spec/ruby/library/net/http/httpheader/type_params_spec.rb
+++ b/spec/ruby/library/net/http/httpheader/type_params_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Net::HTTPHeader#type_params" do
before :each do
diff --git a/spec/ruby/library/net/http/httprequest/initialize_spec.rb b/spec/ruby/library/net/http/httprequest/initialize_spec.rb
index 88e9fb1c77..8abbf13c93 100644
--- a/spec/ruby/library/net/http/httprequest/initialize_spec.rb
+++ b/spec/ruby/library/net/http/httprequest/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
module NetHTTPRequestSpecs
diff --git a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb b/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb
index 68a0454f79..9688b0759e 100644
--- a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse.body_permitted?" do
diff --git a/spec/ruby/library/net/http/httpresponse/body_spec.rb b/spec/ruby/library/net/http/httpresponse/body_spec.rb
index 79569441f1..169a6687a2 100644
--- a/spec/ruby/library/net/http/httpresponse/body_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/body_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'shared/body'
+require File.expand_path('../shared/body', __FILE__)
describe "Net::HTTPResponse#body" do
it_behaves_like :net_httpresponse_body, :body
diff --git a/spec/ruby/library/net/http/httpresponse/code_spec.rb b/spec/ruby/library/net/http/httpresponse/code_spec.rb
index 114277cb43..9430af3100 100644
--- a/spec/ruby/library/net/http/httpresponse/code_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/code_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#code" do
diff --git a/spec/ruby/library/net/http/httpresponse/code_type_spec.rb b/spec/ruby/library/net/http/httpresponse/code_type_spec.rb
index fa2d572e9a..899c2ed9bf 100644
--- a/spec/ruby/library/net/http/httpresponse/code_type_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/code_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#code_type" do
diff --git a/spec/ruby/library/net/http/httpresponse/entity_spec.rb b/spec/ruby/library/net/http/httpresponse/entity_spec.rb
index f1639042c1..3b6be5eb00 100644
--- a/spec/ruby/library/net/http/httpresponse/entity_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/entity_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
-require_relative 'shared/body'
+require File.expand_path('../shared/body', __FILE__)
describe "Net::HTTPResponse#entity" do
it_behaves_like :net_httpresponse_body, :entity
diff --git a/spec/ruby/library/net/http/httpresponse/error_spec.rb b/spec/ruby/library/net/http/httpresponse/error_spec.rb
index d2b2f53d89..7b0f61e520 100644
--- a/spec/ruby/library/net/http/httpresponse/error_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/error_spec.rb
@@ -1,29 +1,24 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#error!" do
it "raises self's class 'EXCEPTION_TYPE' Exception" do
res = Net::HTTPUnknownResponse.new("1.0", "???", "test response")
- -> { res.error! }.should raise_error(Net::HTTPError)
+ lambda { res.error! }.should raise_error(Net::HTTPError)
res = Net::HTTPInformation.new("1.0", "1xx", "test response")
- -> { res.error! }.should raise_error(Net::HTTPError)
+ lambda { res.error! }.should raise_error(Net::HTTPError)
res = Net::HTTPSuccess.new("1.0", "2xx", "test response")
- -> { res.error! }.should raise_error(Net::HTTPError)
+ lambda { res.error! }.should raise_error(Net::HTTPError)
res = Net::HTTPRedirection.new("1.0", "3xx", "test response")
- -> { res.error! }.should raise_error(Net::HTTPRetriableError)
+ lambda { res.error! }.should raise_error(Net::HTTPRetriableError)
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
- ruby_version_is ""..."2.6" do
- -> { res.error! }.should raise_error(Net::HTTPServerException)
- end
- ruby_version_is "2.6" do
- -> { res.error! }.should raise_error(Net::HTTPClientException)
- end
+ lambda { res.error! }.should raise_error(Net::HTTPServerException)
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
- -> { res.error! }.should raise_error(Net::HTTPFatalError)
+ lambda { res.error! }.should raise_error(Net::HTTPFatalError)
end
end
diff --git a/spec/ruby/library/net/http/httpresponse/error_type_spec.rb b/spec/ruby/library/net/http/httpresponse/error_type_spec.rb
index 6705f8b1aa..a6b0155998 100644
--- a/spec/ruby/library/net/http/httpresponse/error_type_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/error_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#error_type" do
@@ -16,12 +16,7 @@ describe "Net::HTTPResponse#error_type" do
res.error_type.should == Net::HTTPRetriableError
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
- ruby_version_is ""..."2.6" do
- res.error_type.should == Net::HTTPServerException
- end
- ruby_version_is "2.6" do
- res.error_type.should == Net::HTTPClientException
- end
+ res.error_type.should == Net::HTTPServerException
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
res.error_type.should == Net::HTTPFatalError
diff --git a/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb b/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb
index c0812cd322..e1a48e0c12 100644
--- a/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse.exception_type" do
@@ -7,12 +7,7 @@ describe "Net::HTTPResponse.exception_type" do
Net::HTTPInformation.exception_type.should == Net::HTTPError
Net::HTTPSuccess.exception_type.should == Net::HTTPError
Net::HTTPRedirection.exception_type.should == Net::HTTPRetriableError
- ruby_version_is ""..."2.6" do
- Net::HTTPClientError.exception_type.should == Net::HTTPServerException
- end
- ruby_version_is "2.6" do
- Net::HTTPClientError.exception_type.should == Net::HTTPClientException
- end
+ Net::HTTPClientError.exception_type.should == Net::HTTPServerException
Net::HTTPServerError.exception_type.should == Net::HTTPFatalError
end
end
diff --git a/spec/ruby/library/net/http/httpresponse/header_spec.rb b/spec/ruby/library/net/http/httpresponse/header_spec.rb
index a9615feda8..21e3dec418 100644
--- a/spec/ruby/library/net/http/httpresponse/header_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/header_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#header" do
diff --git a/spec/ruby/library/net/http/httpresponse/http_version_spec.rb b/spec/ruby/library/net/http/httpresponse/http_version_spec.rb
index db85696d77..a1192c1cbe 100644
--- a/spec/ruby/library/net/http/httpresponse/http_version_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/http_version_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#http_version" do
diff --git a/spec/ruby/library/net/http/httpresponse/initialize_spec.rb b/spec/ruby/library/net/http/httpresponse/initialize_spec.rb
index eb77e2e277..dcb6da3afe 100644
--- a/spec/ruby/library/net/http/httpresponse/initialize_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#initialize when passed http_version, response_code, response_message" do
diff --git a/spec/ruby/library/net/http/httpresponse/inspect_spec.rb b/spec/ruby/library/net/http/httpresponse/inspect_spec.rb
index 1e1a2c7cc7..f5463afa96 100644
--- a/spec/ruby/library/net/http/httpresponse/inspect_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpresponse/message_spec.rb b/spec/ruby/library/net/http/httpresponse/message_spec.rb
index ae8e3678a1..57a927aff0 100644
--- a/spec/ruby/library/net/http/httpresponse/message_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/message_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#message" do
diff --git a/spec/ruby/library/net/http/httpresponse/msg_spec.rb b/spec/ruby/library/net/http/httpresponse/msg_spec.rb
index 0e5e7eb4aa..9b19d34234 100644
--- a/spec/ruby/library/net/http/httpresponse/msg_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/msg_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#msg" do
diff --git a/spec/ruby/library/net/http/httpresponse/read_body_spec.rb b/spec/ruby/library/net/http/httpresponse/read_body_spec.rb
index 99d8e5fa88..d71b4144f4 100644
--- a/spec/ruby/library/net/http/httpresponse/read_body_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/read_body_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#read_body" do
@@ -40,7 +40,7 @@ describe "Net::HTTPResponse#read_body" do
it "raises an IOError if called a second time" do
@res.reading_body(@socket, true) do
@res.read_body("")
- -> { @res.read_body("") }.should raise_error(IOError)
+ lambda { @res.read_body("") }.should raise_error(IOError)
end
end
end
@@ -70,16 +70,17 @@ describe "Net::HTTPResponse#read_body" do
it "raises an IOError if called a second time" do
@res.reading_body(@socket, true) do
@res.read_body {}
- -> { @res.read_body {} }.should raise_error(IOError)
+ lambda { @res.read_body {} }.should raise_error(IOError)
end
end
end
describe "when passed buffer and block" do
- it "raises an ArgumentError" do
+ it "rauses an ArgumentError" do
@res.reading_body(@socket, true) do
- -> { @res.read_body("") {} }.should raise_error(ArgumentError)
+ lambda { @res.read_body("") {} }.should raise_error(ArgumentError)
end
end
end
end
+
diff --git a/spec/ruby/library/net/http/httpresponse/read_header_spec.rb b/spec/ruby/library/net/http/httpresponse/read_header_spec.rb
index 6af8c6bd6a..6bbabdfe10 100644
--- a/spec/ruby/library/net/http/httpresponse/read_header_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/read_header_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#read_header" do
diff --git a/spec/ruby/library/net/http/httpresponse/read_new_spec.rb b/spec/ruby/library/net/http/httpresponse/read_new_spec.rb
index 73c7ddc100..e2fb0f1a05 100644
--- a/spec/ruby/library/net/http/httpresponse/read_new_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/read_new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse.read_new" do
diff --git a/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb b/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb
index ebdab891e1..5e53e00adc 100644
--- a/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpresponse/response_spec.rb b/spec/ruby/library/net/http/httpresponse/response_spec.rb
index f6035f3695..826320be9e 100644
--- a/spec/ruby/library/net/http/httpresponse/response_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/response_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#response" do
diff --git a/spec/ruby/library/net/http/httpresponse/value_spec.rb b/spec/ruby/library/net/http/httpresponse/value_spec.rb
index 4a5930d4e5..7e4f7863eb 100644
--- a/spec/ruby/library/net/http/httpresponse/value_spec.rb
+++ b/spec/ruby/library/net/http/httpresponse/value_spec.rb
@@ -1,29 +1,24 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
describe "Net::HTTPResponse#value" do
it "raises an HTTP error for non 2xx HTTP Responses" do
res = Net::HTTPUnknownResponse.new("1.0", "???", "test response")
- -> { res.value }.should raise_error(Net::HTTPError)
+ lambda { res.value }.should raise_error(Net::HTTPError)
res = Net::HTTPInformation.new("1.0", "1xx", "test response")
- -> { res.value }.should raise_error(Net::HTTPError)
+ lambda { res.value }.should raise_error(Net::HTTPError)
res = Net::HTTPSuccess.new("1.0", "2xx", "test response")
- -> { res.value }.should_not raise_error(Net::HTTPError)
+ lambda { res.value }.should_not raise_error(Net::HTTPError)
res = Net::HTTPRedirection.new("1.0", "3xx", "test response")
- -> { res.value }.should raise_error(Net::HTTPRetriableError)
+ lambda { res.value }.should raise_error(Net::HTTPRetriableError)
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
- ruby_version_is ""..."2.6" do
- -> { res.value }.should raise_error(Net::HTTPServerException)
- end
- ruby_version_is "2.6" do
- -> { res.value }.should raise_error(Net::HTTPClientException)
- end
+ lambda { res.value }.should raise_error(Net::HTTPServerException)
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
- -> { res.value }.should raise_error(Net::HTTPFatalError)
+ lambda { res.value }.should raise_error(Net::HTTPFatalError)
end
end
diff --git a/spec/ruby/library/objectspace/memsize_of_spec.rb b/spec/ruby/library/objectspace/memsize_of_spec.rb
deleted file mode 100644
index 06a80d9f9c..0000000000
--- a/spec/ruby/library/objectspace/memsize_of_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../spec_helper'
-require 'objspace'
-
-describe "ObjectSpace.memsize_of" do
- it "returns 0 for true, false and nil" do
- ObjectSpace.memsize_of(true).should == 0
- ObjectSpace.memsize_of(false).should == 0
- ObjectSpace.memsize_of(nil).should == 0
- end
-
- it "returns 0 for small Integers" do
- ObjectSpace.memsize_of(42).should == 0
- end
-
- it "returns an Integer for an Object" do
- obj = Object.new
- ObjectSpace.memsize_of(obj).should be_kind_of(Integer)
- ObjectSpace.memsize_of(obj).should > 0
- end
-
- it "is larger if the Object has more instance variables" do
- obj = Object.new
- before = ObjectSpace.memsize_of(obj)
- 100.times do |i|
- obj.instance_variable_set(:"@foo#{i}", nil)
- end
- after = ObjectSpace.memsize_of(obj)
- after.should > before
- end
-end
diff --git a/spec/ruby/library/objectspace/reachable_objects_from_spec.rb b/spec/ruby/library/objectspace/reachable_objects_from_spec.rb
deleted file mode 100644
index 7e70bc8569..0000000000
--- a/spec/ruby/library/objectspace/reachable_objects_from_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require_relative '../../spec_helper'
-require 'objspace'
-
-describe "ObjectSpace.reachable_objects_from" do
- it "returns nil for true and false" do
- ObjectSpace.reachable_objects_from(true).should == nil
- ObjectSpace.reachable_objects_from(false).should == nil
- end
-
- it "returns nil for nil" do
- ObjectSpace.reachable_objects_from(nil).should == nil
- end
-
- it "returns nil for small Integers" do
- ObjectSpace.reachable_objects_from(42).should == nil
- end
-
- it "enumerates objects directly reachable from a given object" do
- ObjectSpace.reachable_objects_from(['a', 'b', 'c']).should include(Array, 'a', 'b', 'c')
- ObjectSpace.reachable_objects_from(Object.new).should == [Object]
- end
-
- it "finds an object stored in an Array" do
- obj = Object.new
- ary = [obj]
- reachable = ObjectSpace.reachable_objects_from(ary)
- reachable.should include(obj)
- end
-
- it "finds an object stored in a copy-on-write Array" do
- removed = Object.new
- obj = Object.new
- ary = [removed, obj]
- ary.shift
- reachable = ObjectSpace.reachable_objects_from(ary)
- reachable.should include(obj)
- reachable.should_not include(removed)
- end
-
- it "finds an object stored in a Queue" do
- require 'thread'
- o = Object.new
- q = Queue.new
- q << o
-
- reachable = ObjectSpace.reachable_objects_from(q)
- reachable = reachable + reachable.flat_map { |r| ObjectSpace.reachable_objects_from(r) }
- reachable.should include(o)
- end
-
- it "finds an object stored in a SizedQueue" do
- require 'thread'
- o = Object.new
- q = SizedQueue.new(3)
- q << o
-
- reachable = ObjectSpace.reachable_objects_from(q)
- reachable = reachable + reachable.flat_map { |r| ObjectSpace.reachable_objects_from(r) }
- reachable.should include(o)
- end
-end
diff --git a/spec/ruby/library/observer/add_observer_spec.rb b/spec/ruby/library/observer/add_observer_spec.rb
index 5217ae6dc4..7a2d349c85 100644
--- a/spec/ruby/library/observer/add_observer_spec.rb
+++ b/spec/ruby/library/observer/add_observer_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Observer#add_observer" do
diff --git a/spec/ruby/library/observer/count_observers_spec.rb b/spec/ruby/library/observer/count_observers_spec.rb
index c93674196d..68eaccfaaa 100644
--- a/spec/ruby/library/observer/count_observers_spec.rb
+++ b/spec/ruby/library/observer/count_observers_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Observer#count_observers" do
before :each do
diff --git a/spec/ruby/library/observer/delete_observer_spec.rb b/spec/ruby/library/observer/delete_observer_spec.rb
index 52be1a6cba..b9dc95167c 100644
--- a/spec/ruby/library/observer/delete_observer_spec.rb
+++ b/spec/ruby/library/observer/delete_observer_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Observer#delete_observer" do
before :each do
diff --git a/spec/ruby/library/observer/delete_observers_spec.rb b/spec/ruby/library/observer/delete_observers_spec.rb
index 186e93a013..58b10418dd 100644
--- a/spec/ruby/library/observer/delete_observers_spec.rb
+++ b/spec/ruby/library/observer/delete_observers_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Observer#delete_observers" do
before :each do
diff --git a/spec/ruby/library/observer/notify_observers_spec.rb b/spec/ruby/library/observer/notify_observers_spec.rb
index 31f82e9266..cafbdd56e6 100644
--- a/spec/ruby/library/observer/notify_observers_spec.rb
+++ b/spec/ruby/library/observer/notify_observers_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Observer#notify_observers" do
@@ -16,7 +16,7 @@ describe "Observer#notify_observers" do
end
it "verifies observer responds to update" do
- -> {
+ lambda {
@observable.add_observer(@observable)
}.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/library/open3/capture2_spec.rb b/spec/ruby/library/open3/capture2_spec.rb
index f707281d7f..e5bcc67ae0 100644
--- a/spec/ruby/library/open3/capture2_spec.rb
+++ b/spec/ruby/library/open3/capture2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.capture2" do
diff --git a/spec/ruby/library/open3/capture2e_spec.rb b/spec/ruby/library/open3/capture2e_spec.rb
index 7dd42f3491..6254914222 100644
--- a/spec/ruby/library/open3/capture2e_spec.rb
+++ b/spec/ruby/library/open3/capture2e_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.capture2e" do
diff --git a/spec/ruby/library/open3/capture3_spec.rb b/spec/ruby/library/open3/capture3_spec.rb
index 55c858c03f..cbfa023eb5 100644
--- a/spec/ruby/library/open3/capture3_spec.rb
+++ b/spec/ruby/library/open3/capture3_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.capture3" do
diff --git a/spec/ruby/library/open3/pipeline_r_spec.rb b/spec/ruby/library/open3/pipeline_r_spec.rb
index e1b476f856..c5c2f02087 100644
--- a/spec/ruby/library/open3/pipeline_r_spec.rb
+++ b/spec/ruby/library/open3/pipeline_r_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.pipeline_r" do
diff --git a/spec/ruby/library/open3/pipeline_rw_spec.rb b/spec/ruby/library/open3/pipeline_rw_spec.rb
index 8d889a200a..6f9830270b 100644
--- a/spec/ruby/library/open3/pipeline_rw_spec.rb
+++ b/spec/ruby/library/open3/pipeline_rw_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.pipeline_rw" do
diff --git a/spec/ruby/library/open3/pipeline_spec.rb b/spec/ruby/library/open3/pipeline_spec.rb
index 5dc628dcaf..f8ace3d2da 100644
--- a/spec/ruby/library/open3/pipeline_spec.rb
+++ b/spec/ruby/library/open3/pipeline_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.pipeline" do
diff --git a/spec/ruby/library/open3/pipeline_start_spec.rb b/spec/ruby/library/open3/pipeline_start_spec.rb
index af426807fe..76af0b88e5 100644
--- a/spec/ruby/library/open3/pipeline_start_spec.rb
+++ b/spec/ruby/library/open3/pipeline_start_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.pipeline_start" do
diff --git a/spec/ruby/library/open3/pipeline_w_spec.rb b/spec/ruby/library/open3/pipeline_w_spec.rb
index 0c2a3ca4e7..e3336b7fe1 100644
--- a/spec/ruby/library/open3/pipeline_w_spec.rb
+++ b/spec/ruby/library/open3/pipeline_w_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.pipeline_w" do
diff --git a/spec/ruby/library/open3/popen2_spec.rb b/spec/ruby/library/open3/popen2_spec.rb
index a1a251660a..49bab91bef 100644
--- a/spec/ruby/library/open3/popen2_spec.rb
+++ b/spec/ruby/library/open3/popen2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.popen2" do
diff --git a/spec/ruby/library/open3/popen2e_spec.rb b/spec/ruby/library/open3/popen2e_spec.rb
index e65607160c..2361543afa 100644
--- a/spec/ruby/library/open3/popen2e_spec.rb
+++ b/spec/ruby/library/open3/popen2e_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.popen2e" do
diff --git a/spec/ruby/library/open3/popen3_spec.rb b/spec/ruby/library/open3/popen3_spec.rb
index d3103ad3cb..9733ab15cd 100644
--- a/spec/ruby/library/open3/popen3_spec.rb
+++ b/spec/ruby/library/open3/popen3_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'open3'
describe "Open3.popen3" do
@@ -38,4 +38,6 @@ describe "Open3.popen3" do
out.read.should == "foo"
end
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/library/openssl/cipher_spec.rb b/spec/ruby/library/openssl/cipher_spec.rb
index f66f25f9c6..c3eb1280a2 100644
--- a/spec/ruby/library/openssl/cipher_spec.rb
+++ b/spec/ruby/library/openssl/cipher_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/constants'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
require 'openssl'
describe "OpenSSL::Cipher's CipherError" do
diff --git a/spec/ruby/library/openssl/config/freeze_spec.rb b/spec/ruby/library/openssl/config/freeze_spec.rb
index 1876095d9f..b764df4f45 100644
--- a/spec/ruby/library/openssl/config/freeze_spec.rb
+++ b/spec/ruby/library/openssl/config/freeze_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/constants', __FILE__)
require 'openssl'
@@ -8,12 +8,12 @@ describe "OpenSSL::Config#freeze" do
it "freezes" do
c = OpenSSL::Config.new
- -> {
+ lambda {
c['foo'] = [ ['key', 'value'] ]
}.should_not raise_error
c.freeze
c.frozen?.should be_true
- -> {
+ lambda {
c['foo'] = [ ['key', 'value'] ]
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/library/openssl/hmac/digest_spec.rb b/spec/ruby/library/openssl/hmac/digest_spec.rb
index 22bc7023bc..36edee87bd 100644
--- a/spec/ruby/library/openssl/hmac/digest_spec.rb
+++ b/spec/ruby/library/openssl/hmac/digest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/constants', __FILE__)
require 'openssl'
describe "OpenSSL::HMAC.digest" do
diff --git a/spec/ruby/library/openssl/hmac/hexdigest_spec.rb b/spec/ruby/library/openssl/hmac/hexdigest_spec.rb
index 7f73b2db09..b61bcf6a8f 100644
--- a/spec/ruby/library/openssl/hmac/hexdigest_spec.rb
+++ b/spec/ruby/library/openssl/hmac/hexdigest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../shared/constants'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/constants', __FILE__)
require 'openssl'
describe "OpenSSL::HMAC.hexdigest" do
diff --git a/spec/ruby/library/openssl/random/pseudo_bytes_spec.rb b/spec/ruby/library/openssl/random/pseudo_bytes_spec.rb
index c5e450ce3d..83c8cc13c8 100644
--- a/spec/ruby/library/openssl/random/pseudo_bytes_spec.rb
+++ b/spec/ruby/library/openssl/random/pseudo_bytes_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/random_bytes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/random_bytes.rb', __FILE__)
if defined?(OpenSSL::Random.pseudo_bytes)
describe "OpenSSL::Random.pseudo_bytes" do
diff --git a/spec/ruby/library/openssl/random/random_bytes_spec.rb b/spec/ruby/library/openssl/random/random_bytes_spec.rb
index 2678885da4..b8bd209eb0 100644
--- a/spec/ruby/library/openssl/random/random_bytes_spec.rb
+++ b/spec/ruby/library/openssl/random/random_bytes_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/random_bytes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/random_bytes.rb', __FILE__)
describe "OpenSSL::Random.random_bytes" do
it_behaves_like :openssl_random_bytes, :random_bytes
diff --git a/spec/ruby/library/openssl/random/shared/random_bytes.rb b/spec/ruby/library/openssl/random/shared/random_bytes.rb
index 037f10d409..399e40de39 100644
--- a/spec/ruby/library/openssl/random/shared/random_bytes.rb
+++ b/spec/ruby/library/openssl/random/shared/random_bytes.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'openssl'
describe :openssl_random_bytes, shared: true do |cmd|
@@ -22,7 +22,7 @@ describe :openssl_random_bytes, shared: true do |cmd|
end
it "raises ArgumentError on negative arguments" do
- -> {
+ lambda {
OpenSSL::Random.send(@method, -1)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/openssl/x509/name/parse_spec.rb b/spec/ruby/library/openssl/x509/name/parse_spec.rb
index 6624161d83..c42760fdb7 100644
--- a/spec/ruby/library/openssl/x509/name/parse_spec.rb
+++ b/spec/ruby/library/openssl/x509/name/parse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'openssl'
describe "OpenSSL::X509::Name.parse" do
@@ -35,13 +35,13 @@ describe "OpenSSL::X509::Name.parse" do
end
it "raises TypeError if the given string contains no key/value pairs" do
- -> do
+ lambda do
OpenSSL::X509::Name.parse("hello")
end.should raise_error(TypeError)
end
it "raises OpenSSL::X509::NameError if the given string contains invalid keys" do
- -> do
+ lambda do
OpenSSL::X509::Name.parse("hello=goodbye")
end.should raise_error(OpenSSL::X509::NameError)
end
diff --git a/spec/ruby/library/openstruct/delete_field_spec.rb b/spec/ruby/library/openstruct/delete_field_spec.rb
index 9ac80196cc..a565f61b92 100644
--- a/spec/ruby/library/openstruct/delete_field_spec.rb
+++ b/spec/ruby/library/openstruct/delete_field_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ostruct'
describe "OpenStruct#delete_field" do
diff --git a/spec/ruby/library/openstruct/element_reference_spec.rb b/spec/ruby/library/openstruct/element_reference_spec.rb
index c425991b0f..431843547d 100644
--- a/spec/ruby/library/openstruct/element_reference_spec.rb
+++ b/spec/ruby/library/openstruct/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "ostruct"
describe "OpenStruct#[]" do
diff --git a/spec/ruby/library/openstruct/element_set_spec.rb b/spec/ruby/library/openstruct/element_set_spec.rb
index eeb5a8b318..afa65247e4 100644
--- a/spec/ruby/library/openstruct/element_set_spec.rb
+++ b/spec/ruby/library/openstruct/element_set_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "ostruct"
describe "OpenStruct#[]=" do
diff --git a/spec/ruby/library/openstruct/equal_value_spec.rb b/spec/ruby/library/openstruct/equal_value_spec.rb
index 103ac13588..0d2d1d881e 100644
--- a/spec/ruby/library/openstruct/equal_value_spec.rb
+++ b/spec/ruby/library/openstruct/equal_value_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "ostruct"
-require_relative 'fixtures/classes'
+require File.expand_path('../fixtures/classes', __FILE__)
describe "OpenStruct#==" do
before :each do
diff --git a/spec/ruby/library/openstruct/frozen_spec.rb b/spec/ruby/library/openstruct/frozen_spec.rb
index 63767bb54d..26dd556e97 100644
--- a/spec/ruby/library/openstruct/frozen_spec.rb
+++ b/spec/ruby/library/openstruct/frozen_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ostruct'
describe "OpenStruct.new when frozen" do
@@ -14,19 +14,19 @@ describe "OpenStruct.new when frozen" do
@os.name.should == "John Smith"
end
- it "is not writable" do
- ->{ @os.age = 42 }.should raise_error( RuntimeError )
+ it "is not writeable" do
+ lambda{ @os.age = 42 }.should raise_error( RuntimeError )
end
it "cannot create new fields" do
- ->{ @os.state = :new }.should raise_error( RuntimeError )
+ lambda{ @os.state = :new }.should raise_error( RuntimeError )
end
it "creates a frozen clone" do
f = @os.clone
f.age.should == 70
- ->{ f.age = 0 }.should raise_error( RuntimeError )
- ->{ f.state = :newer }.should raise_error( RuntimeError )
+ lambda{ f.age = 0 }.should raise_error( RuntimeError )
+ lambda{ f.state = :newer }.should raise_error( RuntimeError )
end
it "creates an unfrozen dup" do
diff --git a/spec/ruby/library/openstruct/initialize_spec.rb b/spec/ruby/library/openstruct/initialize_spec.rb
index dee5de48c6..b5edde7618 100644
--- a/spec/ruby/library/openstruct/initialize_spec.rb
+++ b/spec/ruby/library/openstruct/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ostruct'
describe "OpenStruct#initialize" do
diff --git a/spec/ruby/library/openstruct/inspect_spec.rb b/spec/ruby/library/openstruct/inspect_spec.rb
index e2fed41528..826437b3c1 100644
--- a/spec/ruby/library/openstruct/inspect_spec.rb
+++ b/spec/ruby/library/openstruct/inspect_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ostruct'
-require_relative 'fixtures/classes'
-require_relative 'shared/inspect'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "OpenStruct#inspect" do
it_behaves_like :ostruct_inspect, :inspect
diff --git a/spec/ruby/library/openstruct/marshal_dump_spec.rb b/spec/ruby/library/openstruct/marshal_dump_spec.rb
index 5c38fd959e..cdc1564699 100644
--- a/spec/ruby/library/openstruct/marshal_dump_spec.rb
+++ b/spec/ruby/library/openstruct/marshal_dump_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "ostruct"
describe "OpenStruct#marshal_dump" do
diff --git a/spec/ruby/library/openstruct/marshal_load_spec.rb b/spec/ruby/library/openstruct/marshal_load_spec.rb
index e07c4cef05..9c89697d8f 100644
--- a/spec/ruby/library/openstruct/marshal_load_spec.rb
+++ b/spec/ruby/library/openstruct/marshal_load_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "ostruct"
describe "OpenStruct#marshal_load when passed [Hash]" do
diff --git a/spec/ruby/library/openstruct/method_missing_spec.rb b/spec/ruby/library/openstruct/method_missing_spec.rb
index 1992b7255c..6051fd48d8 100644
--- a/spec/ruby/library/openstruct/method_missing_spec.rb
+++ b/spec/ruby/library/openstruct/method_missing_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "ostruct"
describe "OpenStruct#method_missing when called with a method name ending in '='" do
@@ -7,12 +7,12 @@ describe "OpenStruct#method_missing when called with a method name ending in '='
end
it "raises an ArgumentError when not passed any additional arguments" do
- -> { @os.method_missing(:test=) }.should raise_error(ArgumentError)
+ lambda { @os.method_missing(:test=) }.should raise_error(ArgumentError)
end
it "raises a TypeError when self is frozen" do
@os.freeze
- -> { @os.method_missing(:test=, "test") }.should raise_error(RuntimeError)
+ lambda { @os.method_missing(:test=, "test") }.should raise_error(RuntimeError)
end
it "creates accessor methods" do
@@ -24,19 +24,17 @@ describe "OpenStruct#method_missing when called with a method name ending in '='
@os.test = "changed"
@os.test.should == "changed"
end
+
+ it "updates the method/value table with the passed method/value" do
+ @os.method_missing(:test=, "test")
+ @os.send(:table)[:test].should == "test"
+ end
end
describe "OpenStruct#method_missing when passed additional arguments" do
- it "raises a NoMethodError when the key does not exist" do
+ it "raises a NoMethodError" do
os = OpenStruct.new
- -> { os.method_missing(:test, 1, 2, 3) }.should raise_error(NoMethodError)
- end
-
- ruby_version_is "2.7" do
- it "raises an ArgumentError when the key exists" do
- os = OpenStruct.new(test: 20)
- -> { os.method_missing(:test, 1, 2, 3) }.should raise_error(ArgumentError)
- end
+ lambda { os.method_missing(:test, 1, 2, 3) }.should raise_error(NoMethodError)
end
end
diff --git a/spec/ruby/library/openstruct/new_spec.rb b/spec/ruby/library/openstruct/new_spec.rb
index 5d2cacea40..ce33634e08 100644
--- a/spec/ruby/library/openstruct/new_spec.rb
+++ b/spec/ruby/library/openstruct/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ostruct'
describe "OpenStruct.new when passed [Hash]" do
diff --git a/spec/ruby/library/openstruct/to_h_spec.rb b/spec/ruby/library/openstruct/to_h_spec.rb
index ebdec16174..f1bffd6fa6 100644
--- a/spec/ruby/library/openstruct/to_h_spec.rb
+++ b/spec/ruby/library/openstruct/to_h_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ostruct'
describe "OpenStruct#to_h" do
@@ -26,45 +26,4 @@ describe "OpenStruct#to_h" do
@to_h[:age] = 71
@os.age.should == 70
end
-
- ruby_version_is "2.6" do
- context "with block" do
- it "converts [key, value] pairs returned by the block to a hash" do
- h = @os.to_h { |k, v| [k.to_s, v*2] }
- h.should == { "name" => "John SmithJohn Smith", "age" => 140, "pension" => 600 }
- end
-
- it "raises ArgumentError if block returns longer or shorter array" do
- -> do
- @os.to_h { |k, v| [k.to_s, v*2, 1] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
-
- -> do
- @os.to_h { |k, v| [k] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
- end
-
- it "raises TypeError if block returns something other than Array" do
- -> do
- @os.to_h { |k, v| "not-array" }
- end.should raise_error(TypeError, /wrong element type String/)
- end
-
- it "coerces returned pair to Array with #to_ary" do
- x = mock('x')
- x.stub!(:to_ary).and_return([:b, 'b'])
-
- @os.to_h { |k| x }.should == { :b => 'b' }
- end
-
- it "does not coerce returned pair to Array with #to_a" do
- x = mock('x')
- x.stub!(:to_a).and_return([:b, 'b'])
-
- -> do
- @os.to_h { |k| x }
- end.should raise_error(TypeError, /wrong element type MockObject/)
- end
- end
- end
end
diff --git a/spec/ruby/library/openstruct/to_s_spec.rb b/spec/ruby/library/openstruct/to_s_spec.rb
index 73d91bf981..8efa3f5aaf 100644
--- a/spec/ruby/library/openstruct/to_s_spec.rb
+++ b/spec/ruby/library/openstruct/to_s_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'ostruct'
-require_relative 'fixtures/classes'
-require_relative 'shared/inspect'
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
describe "OpenStruct#to_s" do
it_behaves_like :ostruct_inspect, :to_s
diff --git a/spec/ruby/library/optionparser/order_spec.rb b/spec/ruby/library/optionparser/order_spec.rb
index e49bd25554..6c6e03ecc8 100644
--- a/spec/ruby/library/optionparser/order_spec.rb
+++ b/spec/ruby/library/optionparser/order_spec.rb
@@ -1,28 +1,32 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'optparse'
describe "OptionParser#order" do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.order %w[--verbose --require optparse], into: options
+ ruby_version_is '2.4' do
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
+ end
+ parser.order %w[--verbose --require optparse], into: options
- options.should == { verbose: true, require: "optparse" }
+ options.should == { verbose: true, require: "optparse" }
+ end
end
end
describe "OptionParser#order!" do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.order! %w[--verbose --require optparse], into: options
+ ruby_version_is '2.4' do
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
+ end
+ parser.order! %w[--verbose --require optparse], into: options
- options.should == { verbose: true, require: "optparse" }
+ options.should == { verbose: true, require: "optparse" }
+ end
end
end
diff --git a/spec/ruby/library/optionparser/parse_spec.rb b/spec/ruby/library/optionparser/parse_spec.rb
index 9511acb1db..f13793773c 100644
--- a/spec/ruby/library/optionparser/parse_spec.rb
+++ b/spec/ruby/library/optionparser/parse_spec.rb
@@ -1,28 +1,32 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'optparse'
describe "OptionParser#parse" do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.parse %w[--verbose --require optparse], into: options
+ ruby_version_is '2.4' do
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
+ end
+ parser.parse %w[--verbose --require optparse], into: options
- options.should == { verbose: true, require: "optparse" }
+ options.should == { verbose: true, require: "optparse" }
+ end
end
end
describe "OptionParser#parse!" do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.parse! %w[--verbose --require optparse], into: options
+ ruby_version_is '2.4' do
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
+ end
+ parser.parse! %w[--verbose --require optparse], into: options
- options.should == { verbose: true, require: "optparse" }
+ options.should == { verbose: true, require: "optparse" }
+ end
end
end
diff --git a/spec/ruby/library/pathname/absolute_spec.rb b/spec/ruby/library/pathname/absolute_spec.rb
index dce3ae72ee..af0639493a 100644
--- a/spec/ruby/library/pathname/absolute_spec.rb
+++ b/spec/ruby/library/pathname/absolute_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#absolute?" do
@@ -20,3 +20,4 @@ describe "Pathname#absolute?" do
end
end
+
diff --git a/spec/ruby/library/pathname/empty_spec.rb b/spec/ruby/library/pathname/empty_spec.rb
index 4deade5b64..e573021491 100644
--- a/spec/ruby/library/pathname/empty_spec.rb
+++ b/spec/ruby/library/pathname/empty_spec.rb
@@ -1,32 +1,34 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
-describe 'Pathname#empty?' do
- before :all do
- @file = tmp 'new_file_path_name.txt'
- touch @file
- @dir = tmp 'new_directory_path_name'
- Dir.mkdir @dir
- end
+ruby_version_is '2.4' do
+ describe 'Pathname#empty?' do
+ before :all do
+ @file = tmp 'new_file_path_name.txt'
+ touch @file
+ @dir = tmp 'new_directory_path_name'
+ Dir.mkdir @dir
+ end
- after :all do
- rm_r @file
- rm_r @dir
- end
+ after :all do
+ rm_r @file
+ rm_r @dir
+ end
- it 'returns true when file is not empty' do
- Pathname.new(__FILE__).empty?.should be_false
- end
+ it 'returns true when file is not empty' do
+ Pathname.new(__FILE__).empty?.should be_false
+ end
- it 'returns false when the directory is not empty' do
- Pathname.new(__dir__).empty?.should be_false
- end
+ it 'returns false when the directory is not empty' do
+ Pathname.new(__dir__).empty?.should be_false
+ end
- it 'return true when file is empty' do
- Pathname.new(@file).empty?.should be_true
- end
+ it 'return true when file is empty' do
+ Pathname.new(@file).empty?.should be_true
+ end
- it 'returns true when directory is empty' do
- Pathname.new(@dir).empty?.should be_true
+ it 'returns true when directory is empty' do
+ Pathname.new(@dir).empty?.should be_true
+ end
end
end
diff --git a/spec/ruby/library/pathname/equal_value_spec.rb b/spec/ruby/library/pathname/equal_value_spec.rb
index 92d4767e76..afcdb08de8 100644
--- a/spec/ruby/library/pathname/equal_value_spec.rb
+++ b/spec/ruby/library/pathname/equal_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#==" do
@@ -12,3 +12,4 @@ describe "Pathname#==" do
end
end
+
diff --git a/spec/ruby/library/pathname/hash_spec.rb b/spec/ruby/library/pathname/hash_spec.rb
index da1b8f4f76..f3201e2f4f 100644
--- a/spec/ruby/library/pathname/hash_spec.rb
+++ b/spec/ruby/library/pathname/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#hash" do
@@ -12,3 +12,4 @@ describe "Pathname#hash" do
end
end
+
diff --git a/spec/ruby/library/pathname/join_spec.rb b/spec/ruby/library/pathname/join_spec.rb
index a0877777fc..8c77bb1f59 100644
--- a/spec/ruby/library/pathname/join_spec.rb
+++ b/spec/ruby/library/pathname/join_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#join" do
diff --git a/spec/ruby/library/pathname/new_spec.rb b/spec/ruby/library/pathname/new_spec.rb
index dcb770149f..a888e98736 100644
--- a/spec/ruby/library/pathname/new_spec.rb
+++ b/spec/ruby/library/pathname/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname.new" do
@@ -7,21 +7,19 @@ describe "Pathname.new" do
end
it "raises an ArgumentError when called with \0" do
- -> { Pathname.new("\0")}.should raise_error(ArgumentError)
+ lambda { Pathname.new("\0")}.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "is tainted if path is tainted" do
- path = '/usr/local/bin'.taint
- Pathname.new(path).tainted?.should == true
- end
+ it "is tainted if path is tainted" do
+ path = '/usr/local/bin'.taint
+ Pathname.new(path).tainted?.should == true
end
it "raises a TypeError if not passed a String type" do
- -> { Pathname.new(nil) }.should raise_error(TypeError)
- -> { Pathname.new(0) }.should raise_error(TypeError)
- -> { Pathname.new(true) }.should raise_error(TypeError)
- -> { Pathname.new(false) }.should raise_error(TypeError)
+ lambda { Pathname.new(nil) }.should raise_error(TypeError)
+ lambda { Pathname.new(0) }.should raise_error(TypeError)
+ lambda { Pathname.new(true) }.should raise_error(TypeError)
+ lambda { Pathname.new(false) }.should raise_error(TypeError)
end
it "initializes with an object with to_path" do
diff --git a/spec/ruby/library/pathname/parent_spec.rb b/spec/ruby/library/pathname/parent_spec.rb
index 3843bb22ed..53d3f1e50e 100644
--- a/spec/ruby/library/pathname/parent_spec.rb
+++ b/spec/ruby/library/pathname/parent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#parent" do
@@ -16,3 +16,4 @@ describe "Pathname#parent" do
end
end
+
diff --git a/spec/ruby/library/pathname/realdirpath_spec.rb b/spec/ruby/library/pathname/realdirpath_spec.rb
index a9e44e354e..f76e37602c 100644
--- a/spec/ruby/library/pathname/realdirpath_spec.rb
+++ b/spec/ruby/library/pathname/realdirpath_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#realdirpath" do
diff --git a/spec/ruby/library/pathname/realpath_spec.rb b/spec/ruby/library/pathname/realpath_spec.rb
index f2c654308e..e1c9eb34ea 100644
--- a/spec/ruby/library/pathname/realpath_spec.rb
+++ b/spec/ruby/library/pathname/realpath_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#realpath" do
diff --git a/spec/ruby/library/pathname/relative_path_from_spec.rb b/spec/ruby/library/pathname/relative_path_from_spec.rb
index abe9c80a45..416eaa1a50 100644
--- a/spec/ruby/library/pathname/relative_path_from_spec.rb
+++ b/spec/ruby/library/pathname/relative_path_from_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#relative_path_from" do
@@ -7,11 +7,11 @@ describe "Pathname#relative_path_from" do
end
it "raises an error when the two paths do not share a common prefix" do
- -> { relative_path_str('/usr', 'foo') }.should raise_error(ArgumentError)
+ lambda { relative_path_str('/usr', 'foo') }.should raise_error(ArgumentError)
end
it "raises an error when the base directory has .." do
- -> { relative_path_str('a', '..') }.should raise_error(ArgumentError)
+ lambda { relative_path_str('a', '..') }.should raise_error(ArgumentError)
end
it "returns a path relative from root" do
diff --git a/spec/ruby/library/pathname/relative_spec.rb b/spec/ruby/library/pathname/relative_spec.rb
index 1a08891e6c..a44d8c5a66 100644
--- a/spec/ruby/library/pathname/relative_spec.rb
+++ b/spec/ruby/library/pathname/relative_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#relative?" do
@@ -20,3 +20,4 @@ describe "Pathname#relative?" do
end
end
+
diff --git a/spec/ruby/library/pathname/root_spec.rb b/spec/ruby/library/pathname/root_spec.rb
index 5fec0ee956..a5efcf69b4 100644
--- a/spec/ruby/library/pathname/root_spec.rb
+++ b/spec/ruby/library/pathname/root_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#root?" do
@@ -24,3 +24,4 @@ describe "Pathname#root?" do
end
end
+
diff --git a/spec/ruby/library/pathname/sub_spec.rb b/spec/ruby/library/pathname/sub_spec.rb
index ad2900f62b..36b6ebb247 100644
--- a/spec/ruby/library/pathname/sub_spec.rb
+++ b/spec/ruby/library/pathname/sub_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'
describe "Pathname#sub" do
@@ -13,3 +13,4 @@ describe "Pathname#sub" do
end
end
+
diff --git a/spec/ruby/library/pp/pp_spec.rb b/spec/ruby/library/pp/pp_spec.rb
index 06b22601d8..3a0135270a 100644
--- a/spec/ruby/library/pp/pp_spec.rb
+++ b/spec/ruby/library/pp/pp_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'pp'
describe "PP.pp" do
it 'works with default arguments' do
array = [1, 2, 3]
- -> {
+ lambda {
PP.pp array
}.should output "[1, 2, 3]\n"
end
@@ -14,10 +14,12 @@ describe "PP.pp" do
array = [1, 2, 3]
other_out = IOStub.new
- -> {
+ lambda {
PP.pp array, other_out
}.should output "" # no output on stdout
other_out.to_s.should == "[1, 2, 3]\n"
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/library/prime/each_spec.rb b/spec/ruby/library/prime/each_spec.rb
index b99cf7cf0e..bccccfdcdc 100644
--- a/spec/ruby/library/prime/each_spec.rb
+++ b/spec/ruby/library/prime/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'prime'
describe :prime_each, shared: true do
diff --git a/spec/ruby/library/prime/instance_spec.rb b/spec/ruby/library/prime/instance_spec.rb
index 5183f36901..64497c1b7c 100644
--- a/spec/ruby/library/prime/instance_spec.rb
+++ b/spec/ruby/library/prime/instance_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'prime'
describe "Prime.instance" do
@@ -12,10 +12,10 @@ describe "Prime.instance" do
end
it "does not complain anything" do
- -> { Prime.instance }.should_not complain
+ lambda { Prime.instance }.should_not complain
end
it "raises a ArgumentError when is called with some arguments" do
- -> { Prime.instance(1) }.should raise_error(ArgumentError)
+ lambda { Prime.instance(1) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/prime/int_from_prime_division_spec.rb b/spec/ruby/library/prime/int_from_prime_division_spec.rb
index 5abb7221df..df98976f5f 100644
--- a/spec/ruby/library/prime/int_from_prime_division_spec.rb
+++ b/spec/ruby/library/prime/int_from_prime_division_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'prime'
describe "Prime.int_from_prime_division" do
diff --git a/spec/ruby/library/prime/integer/each_prime_spec.rb b/spec/ruby/library/prime/integer/each_prime_spec.rb
index a71296b0df..e1b0092762 100644
--- a/spec/ruby/library/prime/integer/each_prime_spec.rb
+++ b/spec/ruby/library/prime/integer/each_prime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'prime'
describe "Integer.each_prime" do
diff --git a/spec/ruby/library/prime/integer/from_prime_division_spec.rb b/spec/ruby/library/prime/integer/from_prime_division_spec.rb
index e0e74fb336..6ef98a2ecf 100644
--- a/spec/ruby/library/prime/integer/from_prime_division_spec.rb
+++ b/spec/ruby/library/prime/integer/from_prime_division_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'prime'
describe "Integer.from_prime_division" do
diff --git a/spec/ruby/library/prime/integer/prime_division_spec.rb b/spec/ruby/library/prime/integer/prime_division_spec.rb
index be03438a6f..db137778ea 100644
--- a/spec/ruby/library/prime/integer/prime_division_spec.rb
+++ b/spec/ruby/library/prime/integer/prime_division_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'prime'
describe "Integer#prime_division" do
@@ -14,6 +14,6 @@ describe "Integer#prime_division" do
-1.prime_division.should == [[-1, 1]]
end
it "raises ZeroDivisionError for 0" do
- -> { 0.prime_division }.should raise_error(ZeroDivisionError)
+ lambda { 0.prime_division }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/library/prime/integer/prime_spec.rb b/spec/ruby/library/prime/integer/prime_spec.rb
index 53de76d5ab..ba869ba60e 100644
--- a/spec/ruby/library/prime/integer/prime_spec.rb
+++ b/spec/ruby/library/prime/integer/prime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'prime'
describe "Integer#prime?" do
diff --git a/spec/ruby/library/prime/next_spec.rb b/spec/ruby/library/prime/next_spec.rb
index 39c4ae16ae..afff353d6e 100644
--- a/spec/ruby/library/prime/next_spec.rb
+++ b/spec/ruby/library/prime/next_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/next'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/next', __FILE__)
require 'prime'
describe "Prime#next" do
diff --git a/spec/ruby/library/prime/prime_division_spec.rb b/spec/ruby/library/prime/prime_division_spec.rb
index 6293478f59..faca8bda02 100644
--- a/spec/ruby/library/prime/prime_division_spec.rb
+++ b/spec/ruby/library/prime/prime_division_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'prime'
describe "Prime.prime_division" do
@@ -20,6 +20,6 @@ describe "Prime.prime_division" do
end
it "raises ZeroDivisionError for 0" do
- -> { Prime.prime_division(0) }.should raise_error(ZeroDivisionError)
+ lambda { Prime.prime_division(0) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/library/prime/prime_spec.rb b/spec/ruby/library/prime/prime_spec.rb
index 0896c7f0f3..7a41496f7f 100644
--- a/spec/ruby/library/prime/prime_spec.rb
+++ b/spec/ruby/library/prime/prime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'prime'
describe "Prime#prime?" do
diff --git a/spec/ruby/library/prime/succ_spec.rb b/spec/ruby/library/prime/succ_spec.rb
index 34c18d2ba0..85d22ee654 100644
--- a/spec/ruby/library/prime/succ_spec.rb
+++ b/spec/ruby/library/prime/succ_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/next'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/next', __FILE__)
require 'prime'
describe "Prime#succ" do
diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb
deleted file mode 100644
index 35b465d106..0000000000
--- a/spec/ruby/library/rbconfig/rbconfig_spec.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require_relative '../../spec_helper'
-require 'rbconfig'
-
-describe 'RbConfig::CONFIG' do
- it 'values are all strings' do
- RbConfig::CONFIG.each do |k, v|
- k.should be_kind_of String
- v.should be_kind_of String
- end
- end
-
- # These directories have no meanings before the installation.
- guard -> { RbConfig::TOPDIR } do
- it "['rubylibdir'] returns the directory containing Ruby standard libraries" do
- rubylibdir = RbConfig::CONFIG['rubylibdir']
- File.directory?(rubylibdir).should == true
- File.should.exist?("#{rubylibdir}/fileutils.rb")
- end
-
- it "['archdir'] returns the directory containing standard libraries C extensions" do
- archdir = RbConfig::CONFIG['archdir']
- File.directory?(archdir).should == true
- File.should.exist?("#{archdir}/etc.#{RbConfig::CONFIG['DLEXT']}")
- end
- end
-
- it "contains no frozen strings even with --enable-frozen-string-literal" do
- ruby_exe(<<-RUBY, options: '--enable-frozen-string-literal').should == "Done\n"
- require 'rbconfig'
- RbConfig::CONFIG.each do |k, v|
- if v.frozen?
- puts "\#{k} Failure"
- end
- end
- puts 'Done'
- RUBY
- end
-end
-
-describe "RbConfig::TOPDIR" do
- it "either returns nil (if not installed) or the prefix" do
- if RbConfig::TOPDIR
- RbConfig::TOPDIR.should == RbConfig::CONFIG["prefix"]
- else
- RbConfig::TOPDIR.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rbconfig/sizeof/limits_spec.rb b/spec/ruby/library/rbconfig/sizeof/limits_spec.rb
deleted file mode 100644
index a026135eee..0000000000
--- a/spec/ruby/library/rbconfig/sizeof/limits_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require_relative '../../../spec_helper'
-require 'rbconfig/sizeof'
-
-ruby_version_is "2.5" do
- describe "RbConfig::LIMITS" do
- it "is a Hash" do
- RbConfig::LIMITS.should be_kind_of(Hash)
- end
-
- it "has string keys and numeric values" do
- RbConfig::LIMITS.each do |key, value|
- key.should be_kind_of String
- value.should be_kind_of Numeric
- end
- end
-
- it "contains FIXNUM_MIN and FIXNUM_MAX" do
- RbConfig::LIMITS["FIXNUM_MIN"].should < 0
- RbConfig::LIMITS["FIXNUM_MAX"].should > 0
- end
-
- it "contains CHAR_MIN and CHAR_MAX" do
- RbConfig::LIMITS["CHAR_MIN"].should <= 0
- RbConfig::LIMITS["CHAR_MAX"].should > 0
- end
-
- it "contains SHRT_MIN and SHRT_MAX" do
- RbConfig::LIMITS["SHRT_MIN"].should == -32768
- RbConfig::LIMITS["SHRT_MAX"].should == 32767
- end
-
- it "contains INT_MIN and INT_MAX" do
- RbConfig::LIMITS["INT_MIN"].should < 0
- RbConfig::LIMITS["INT_MAX"].should > 0
- end
-
- it "contains LONG_MIN and LONG_MAX" do
- RbConfig::LIMITS["LONG_MIN"].should < 0
- RbConfig::LIMITS["LONG_MAX"].should > 0
- end
- end
-end
diff --git a/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb b/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb
deleted file mode 100644
index f2582dc4fd..0000000000
--- a/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../../spec_helper'
-require 'rbconfig/sizeof'
-
-describe "RbConfig::SIZEOF" do
- it "is a Hash" do
- RbConfig::SIZEOF.should be_kind_of(Hash)
- end
-
- it "has string keys and integer values" do
- RbConfig::SIZEOF.each do |key, value|
- key.should be_kind_of String
- value.should be_kind_of Integer
- end
- end
-
- it "contains the sizeof(void*)" do
- (RbConfig::SIZEOF["void*"] * 8).should == PlatformGuard::POINTER_SIZE
- end
-
- it "contains the sizeof(float) and sizeof(double)" do
- RbConfig::SIZEOF["float"].should == 4
- RbConfig::SIZEOF["double"].should == 8
- end
-
- it "contains the size of short, int and long" do
- RbConfig::SIZEOF["short"].should > 0
- RbConfig::SIZEOF["int"].should > 0
- RbConfig::SIZEOF["long"].should > 0
- end
-end
diff --git a/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb b/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb
deleted file mode 100644
index d3df8b7313..0000000000
--- a/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../spec_helper'
-require 'rbconfig'
-
-describe "RbConfig::CONFIG['UNICODE_EMOJI_VERSION']" do
- ruby_version_is "2.6"..."2.6.2" do
- it "is 11.0 for Ruby 2.6.0 and 2.6.1" do
- RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "11.0"
- end
- end
-
- ruby_version_is "2.6.2"..."2.7" do
- it "is 12.0 for Ruby 2.6.2+" do
- RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.0"
- end
- end
-
- ruby_version_is "2.7" do
- it "is 12.1 for Ruby 2.7" do
- RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.1"
- end
- end
-end
diff --git a/spec/ruby/library/rbconfig/unicode_version_spec.rb b/spec/ruby/library/rbconfig/unicode_version_spec.rb
deleted file mode 100644
index 44216700c8..0000000000
--- a/spec/ruby/library/rbconfig/unicode_version_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../spec_helper'
-require 'rbconfig'
-
-describe "RbConfig::CONFIG['UNICODE_VERSION']" do
- ruby_version_is ""..."2.5" do
- it "is 9.0.0 for Ruby 2.4" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "9.0.0"
- end
- end
-
- ruby_version_is "2.5"..."2.6" do
- it "is 10.0.0 for Ruby 2.5" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "10.0.0"
- end
- end
-
- ruby_version_is "2.6"..."2.6.2" do
- it "is 11.0.0 for Ruby 2.6.0 and 2.6.1" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "11.0.0"
- end
- end
-
- ruby_version_is "2.6.2"..."2.6.3" do
- it "is 12.0.0 for Ruby 2.6.2" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "12.0.0"
- end
- end
-
- ruby_version_is "2.6.3" do
- it "is 12.1.0 for Ruby 2.6.3+ and Ruby 2.7" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "12.1.0"
- end
- end
-end
diff --git a/spec/ruby/library/readline/basic_quote_characters_spec.rb b/spec/ruby/library/readline/basic_quote_characters_spec.rb
index 216899d875..7d25df2047 100644
--- a/spec/ruby/library/readline/basic_quote_characters_spec.rb
+++ b/spec/ruby/library/readline/basic_quote_characters_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
platform_is_not :darwin do
with_feature :readline do
diff --git a/spec/ruby/library/readline/basic_word_break_characters_spec.rb b/spec/ruby/library/readline/basic_word_break_characters_spec.rb
index daa0e1cb76..c2ec6cede7 100644
--- a/spec/ruby/library/readline/basic_word_break_characters_spec.rb
+++ b/spec/ruby/library/readline/basic_word_break_characters_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
describe "Readline.basic_word_break_characters" do
diff --git a/spec/ruby/library/readline/completer_quote_characters_spec.rb b/spec/ruby/library/readline/completer_quote_characters_spec.rb
index 86c58f3cf6..a836a0591e 100644
--- a/spec/ruby/library/readline/completer_quote_characters_spec.rb
+++ b/spec/ruby/library/readline/completer_quote_characters_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
describe "Readline.completer_quote_characters" do
diff --git a/spec/ruby/library/readline/completer_word_break_characters_spec.rb b/spec/ruby/library/readline/completer_word_break_characters_spec.rb
index c72f1135c4..2e0cc277a6 100644
--- a/spec/ruby/library/readline/completer_word_break_characters_spec.rb
+++ b/spec/ruby/library/readline/completer_word_break_characters_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
describe "Readline.completer_word_break_characters" do
diff --git a/spec/ruby/library/readline/completion_append_character_spec.rb b/spec/ruby/library/readline/completion_append_character_spec.rb
index 615b523f4e..ee41abea05 100644
--- a/spec/ruby/library/readline/completion_append_character_spec.rb
+++ b/spec/ruby/library/readline/completion_append_character_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
describe "Readline.completion_append_character" do
diff --git a/spec/ruby/library/readline/completion_case_fold_spec.rb b/spec/ruby/library/readline/completion_case_fold_spec.rb
index 966f5d6c79..604460869e 100644
--- a/spec/ruby/library/readline/completion_case_fold_spec.rb
+++ b/spec/ruby/library/readline/completion_case_fold_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
describe "Readline.completion_case_fold" do
diff --git a/spec/ruby/library/readline/completion_proc_spec.rb b/spec/ruby/library/readline/completion_proc_spec.rb
index 2d7a353ec5..e525fbd191 100644
--- a/spec/ruby/library/readline/completion_proc_spec.rb
+++ b/spec/ruby/library/readline/completion_proc_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
describe "Readline.completion_proc" do
@@ -16,7 +16,7 @@ with_feature :readline do
end
it "returns an ArgumentError if not given an Proc or #call" do
- -> { Readline.completion_proc = "test" }.should raise_error(ArgumentError)
+ lambda { Readline.completion_proc = "test" }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/library/readline/constants_spec.rb b/spec/ruby/library/readline/constants_spec.rb
index 8fee274866..226a3509b9 100644
--- a/spec/ruby/library/readline/constants_spec.rb
+++ b/spec/ruby/library/readline/constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
# Note: additional specs for HISTORY are in 'history' subdir.
diff --git a/spec/ruby/library/readline/emacs_editing_mode_spec.rb b/spec/ruby/library/readline/emacs_editing_mode_spec.rb
index f7e8eda982..6c2e84b08f 100644
--- a/spec/ruby/library/readline/emacs_editing_mode_spec.rb
+++ b/spec/ruby/library/readline/emacs_editing_mode_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
platform_is_not :darwin do
with_feature :readline do
diff --git a/spec/ruby/library/readline/filename_quote_characters_spec.rb b/spec/ruby/library/readline/filename_quote_characters_spec.rb
index de8ce700a8..abee5e9700 100644
--- a/spec/ruby/library/readline/filename_quote_characters_spec.rb
+++ b/spec/ruby/library/readline/filename_quote_characters_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
platform_is_not :darwin do
with_feature :readline do
diff --git a/spec/ruby/library/readline/history/append_spec.rb b/spec/ruby/library/readline/history/append_spec.rb
index 5383271374..3ea0bbf57f 100644
--- a/spec/ruby/library/readline/history/append_spec.rb
+++ b/spec/ruby/library/readline/history/append_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.<<" do
@@ -22,7 +22,7 @@ with_feature :readline do
end
it "raises a TypeError when the passed Object can't be converted to a String" do
- -> { Readline::HISTORY << mock("Object") }.should raise_error(TypeError)
+ lambda { Readline::HISTORY << mock("Object") }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/library/readline/history/delete_at_spec.rb b/spec/ruby/library/readline/history/delete_at_spec.rb
index c95a6a865e..38f180ca08 100644
--- a/spec/ruby/library/readline/history/delete_at_spec.rb
+++ b/spec/ruby/library/readline/history/delete_at_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.delete_at" do
@@ -31,17 +31,15 @@ with_feature :readline do
end
it "raises an IndexError when the given index is greater than the history size" do
- -> { Readline::HISTORY.delete_at(10) }.should raise_error(IndexError)
- -> { Readline::HISTORY.delete_at(-10) }.should raise_error(IndexError)
+ lambda { Readline::HISTORY.delete_at(10) }.should raise_error(IndexError)
+ lambda { Readline::HISTORY.delete_at(-10) }.should raise_error(IndexError)
end
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- Readline::HISTORY.push("1", "2", "3")
- Readline::HISTORY.delete_at(0).tainted?.should be_true
- Readline::HISTORY.delete_at(0).tainted?.should be_true
- Readline::HISTORY.delete_at(0).tainted?.should be_true
- end
+ it "taints the returned strings" do
+ Readline::HISTORY.push("1", "2", "3")
+ Readline::HISTORY.delete_at(0).tainted?.should be_true
+ Readline::HISTORY.delete_at(0).tainted?.should be_true
+ Readline::HISTORY.delete_at(0).tainted?.should be_true
end
end
end
diff --git a/spec/ruby/library/readline/history/each_spec.rb b/spec/ruby/library/readline/history/each_spec.rb
index 23387bfc98..5057e04970 100644
--- a/spec/ruby/library/readline/history/each_spec.rb
+++ b/spec/ruby/library/readline/history/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.each" do
@@ -20,11 +20,9 @@ with_feature :readline do
result.should == ["1", "2", "3"]
end
- ruby_version_is ''...'2.7' do
- it "yields tainted Objects" do
- Readline::HISTORY.each do |x|
- x.tainted?.should be_true
- end
+ it "yields tainted Objects" do
+ Readline::HISTORY.each do |x|
+ x.tainted?.should be_true
end
end
end
diff --git a/spec/ruby/library/readline/history/element_reference_spec.rb b/spec/ruby/library/readline/history/element_reference_spec.rb
index dfa5367cad..c656179ddd 100644
--- a/spec/ruby/library/readline/history/element_reference_spec.rb
+++ b/spec/ruby/library/readline/history/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.[]" do
@@ -12,11 +12,9 @@ with_feature :readline do
Readline::HISTORY.pop
end
- ruby_version_is ''...'2.7' do
- it "returns tainted objects" do
- Readline::HISTORY[0].tainted?.should be_true
- Readline::HISTORY[1].tainted?.should be_true
- end
+ it "returns tainted objects" do
+ Readline::HISTORY[0].tainted?.should be_true
+ Readline::HISTORY[1].tainted?.should be_true
end
it "returns the history item at the passed index" do
@@ -30,13 +28,13 @@ with_feature :readline do
end
it "raises an IndexError when there is no item at the passed index" do
- -> { Readline::HISTORY[-10] }.should raise_error(IndexError)
- -> { Readline::HISTORY[-9] }.should raise_error(IndexError)
- -> { Readline::HISTORY[-8] }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[-10] }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[-9] }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[-8] }.should raise_error(IndexError)
- -> { Readline::HISTORY[8] }.should raise_error(IndexError)
- -> { Readline::HISTORY[9] }.should raise_error(IndexError)
- -> { Readline::HISTORY[10] }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[8] }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[9] }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[10] }.should raise_error(IndexError)
end
end
end
diff --git a/spec/ruby/library/readline/history/element_set_spec.rb b/spec/ruby/library/readline/history/element_set_spec.rb
index 776adaacd1..8d6fe196ef 100644
--- a/spec/ruby/library/readline/history/element_set_spec.rb
+++ b/spec/ruby/library/readline/history/element_set_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.[]=" do
@@ -17,7 +17,7 @@ with_feature :readline do
end
it "raises an IndexError when there is no item at the passed positive index" do
- -> { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
end
it "sets the item at the given index" do
@@ -29,7 +29,7 @@ with_feature :readline do
end
it "raises an IndexError when there is no item at the passed negative index" do
- -> { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
+ lambda { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
end
end
end
diff --git a/spec/ruby/library/readline/history/empty_spec.rb b/spec/ruby/library/readline/history/empty_spec.rb
index 31d01d9601..92a4fcd063 100644
--- a/spec/ruby/library/readline/history/empty_spec.rb
+++ b/spec/ruby/library/readline/history/empty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.empty?" do
diff --git a/spec/ruby/library/readline/history/history_spec.rb b/spec/ruby/library/readline/history/history_spec.rb
index 927dd52ebf..dfa6544036 100644
--- a/spec/ruby/library/readline/history/history_spec.rb
+++ b/spec/ruby/library/readline/history/history_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY" do
diff --git a/spec/ruby/library/readline/history/length_spec.rb b/spec/ruby/library/readline/history/length_spec.rb
index 9427d10a00..6700d4f234 100644
--- a/spec/ruby/library/readline/history/length_spec.rb
+++ b/spec/ruby/library/readline/history/length_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
- require_relative 'shared/size'
+ require File.expand_path('../shared/size', __FILE__)
describe "Readline::HISTORY.length" do
it_behaves_like :readline_history_size, :length
diff --git a/spec/ruby/library/readline/history/pop_spec.rb b/spec/ruby/library/readline/history/pop_spec.rb
index e17be666d8..34562dff3b 100644
--- a/spec/ruby/library/readline/history/pop_spec.rb
+++ b/spec/ruby/library/readline/history/pop_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.pop" do
@@ -20,13 +20,11 @@ with_feature :readline do
Readline::HISTORY.size.should == 0
end
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- Readline::HISTORY.push("1", "2", "3")
- Readline::HISTORY.pop.tainted?.should be_true
- Readline::HISTORY.pop.tainted?.should be_true
- Readline::HISTORY.pop.tainted?.should be_true
- end
+ it "taints the returned strings" do
+ Readline::HISTORY.push("1", "2", "3")
+ Readline::HISTORY.pop.tainted?.should be_true
+ Readline::HISTORY.pop.tainted?.should be_true
+ Readline::HISTORY.pop.tainted?.should be_true
end
end
end
diff --git a/spec/ruby/library/readline/history/push_spec.rb b/spec/ruby/library/readline/history/push_spec.rb
index 53505ccba6..b59b17ed03 100644
--- a/spec/ruby/library/readline/history/push_spec.rb
+++ b/spec/ruby/library/readline/history/push_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.push" do
@@ -20,7 +20,7 @@ with_feature :readline do
end
it "raises a TypeError when the passed Object can't be converted to a String" do
- -> { Readline::HISTORY.push(mock("Object")) }.should raise_error(TypeError)
+ lambda { Readline::HISTORY.push(mock("Object")) }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/library/readline/history/shift_spec.rb b/spec/ruby/library/readline/history/shift_spec.rb
index ccd90193fd..3d4782998d 100644
--- a/spec/ruby/library/readline/history/shift_spec.rb
+++ b/spec/ruby/library/readline/history/shift_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.shift" do
@@ -20,13 +20,11 @@ with_feature :readline do
Readline::HISTORY.size.should == 0
end
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- Readline::HISTORY.push("1", "2", "3")
- Readline::HISTORY.shift.tainted?.should be_true
- Readline::HISTORY.shift.tainted?.should be_true
- Readline::HISTORY.shift.tainted?.should be_true
- end
+ it "taints the returned strings" do
+ Readline::HISTORY.push("1", "2", "3")
+ Readline::HISTORY.shift.tainted?.should be_true
+ Readline::HISTORY.shift.tainted?.should be_true
+ Readline::HISTORY.shift.tainted?.should be_true
end
end
end
diff --git a/spec/ruby/library/readline/history/size_spec.rb b/spec/ruby/library/readline/history/size_spec.rb
index c55253ccea..815c68de27 100644
--- a/spec/ruby/library/readline/history/size_spec.rb
+++ b/spec/ruby/library/readline/history/size_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
- require_relative 'shared/size'
+ require File.expand_path('../shared/size', __FILE__)
describe "Readline::HISTORY.size" do
it_behaves_like :readline_history_size, :size
diff --git a/spec/ruby/library/readline/history/to_s_spec.rb b/spec/ruby/library/readline/history/to_s_spec.rb
index ee338f2ab4..30ba5a1249 100644
--- a/spec/ruby/library/readline/history/to_s_spec.rb
+++ b/spec/ruby/library/readline/history/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
with_feature :readline do
describe "Readline::HISTORY.to_s" do
diff --git a/spec/ruby/library/readline/readline_spec.rb b/spec/ruby/library/readline/readline_spec.rb
index 24d2cbbe86..599f84dffd 100644
--- a/spec/ruby/library/readline/readline_spec.rb
+++ b/spec/ruby/library/readline/readline_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
with_feature :readline do
describe "Readline.readline" do
@@ -22,11 +22,9 @@ with_feature :readline do
File.read(@out).should == "test"
end
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- ruby_exe('File.write ARGV[0], Readline.readline.tainted?', @options)
- File.read(@out).should == "true"
- end
+ it "taints the returned strings" do
+ ruby_exe('File.write ARGV[0], Readline.readline.tainted?', @options)
+ File.read(@out).should == "true"
end
end
end
diff --git a/spec/ruby/library/readline/spec_helper.rb b/spec/ruby/library/readline/spec_helper.rb
index 32d820f7ac..04ab0f755f 100644
--- a/spec/ruby/library/readline/spec_helper.rb
+++ b/spec/ruby/library/readline/spec_helper.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
begin
require 'readline'
rescue LoadError
else
- # rb-readline and reline behave quite differently
- unless defined?(RbReadline) or defined?(Reline)
+ # rb-readline behaves quite differently
+ unless defined?(RbReadline)
MSpec.enable_feature :readline
end
end
diff --git a/spec/ruby/library/readline/vi_editing_mode_spec.rb b/spec/ruby/library/readline/vi_editing_mode_spec.rb
index 6622962ceb..db6d4387f8 100644
--- a/spec/ruby/library/readline/vi_editing_mode_spec.rb
+++ b/spec/ruby/library/readline/vi_editing_mode_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
platform_is_not :darwin do
with_feature :readline do
diff --git a/spec/ruby/library/resolv/fixtures/hosts b/spec/ruby/library/resolv/fixtures/hosts
deleted file mode 100644
index a50f3d6a69..0000000000
--- a/spec/ruby/library/resolv/fixtures/hosts
+++ /dev/null
@@ -1 +0,0 @@
-127.0.0.1 localhost localhost4
diff --git a/spec/ruby/library/resolv/get_address_spec.rb b/spec/ruby/library/resolv/get_address_spec.rb
index ecc2cdf7de..cb71bb6ec4 100644
--- a/spec/ruby/library/resolv/get_address_spec.rb
+++ b/spec/ruby/library/resolv/get_address_spec.rb
@@ -1,18 +1,20 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'resolv'
describe "Resolv#getaddress" do
- it "resolves localhost" do
- hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
- res = Resolv.new([hosts])
+ platform_is_not :windows do
+ it "resolves localhost" do
+ res = Resolv.new([Resolv::Hosts.new])
- res.getaddress("localhost").should == "127.0.0.1"
- res.getaddress("localhost4").should == "127.0.0.1"
+ lambda {
+ res.getaddress("localhost")
+ }.should_not raise_error(Resolv::ResolvError)
+ end
end
it "raises ResolvError if the name can not be looked up" do
res = Resolv.new([])
- -> {
+ lambda {
res.getaddress("should.raise.error.")
}.should raise_error(Resolv::ResolvError)
end
diff --git a/spec/ruby/library/resolv/get_addresses_spec.rb b/spec/ruby/library/resolv/get_addresses_spec.rb
index b84f29b7da..2ab3d35eba 100644
--- a/spec/ruby/library/resolv/get_addresses_spec.rb
+++ b/spec/ruby/library/resolv/get_addresses_spec.rb
@@ -1,12 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'resolv'
describe "Resolv#getaddresses" do
- it "resolves localhost" do
- hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
- res = Resolv.new([hosts])
+ platform_is_not :windows do
+ it "resolves localhost" do
+ res = Resolv.new([Resolv::Hosts.new])
- res.getaddresses("localhost").should == ["127.0.0.1"]
- res.getaddresses("localhost4").should == ["127.0.0.1"]
+ addresses = res.getaddresses("localhost")
+ addresses.should_not == nil
+ addresses.size.should > 0
+ end
end
end
diff --git a/spec/ruby/library/resolv/get_name_spec.rb b/spec/ruby/library/resolv/get_name_spec.rb
index 3ef97a2cea..06a27e922a 100644
--- a/spec/ruby/library/resolv/get_name_spec.rb
+++ b/spec/ruby/library/resolv/get_name_spec.rb
@@ -1,17 +1,18 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'resolv'
describe "Resolv#getname" do
- it "resolves 127.0.0.1" do
- hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
- res = Resolv.new([hosts])
-
- res.getname("127.0.0.1").should == "localhost"
+ platform_is_not :windows do
+ it "resolves 127.0.0.1" do
+ lambda {
+ Resolv.getname("127.0.0.1")
+ }.should_not raise_error(Resolv::ResolvError)
+ end
end
it "raises ResolvError when there is no result" do
res = Resolv.new([])
- -> {
+ lambda {
res.getname("should.raise.error")
}.should raise_error(Resolv::ResolvError)
end
diff --git a/spec/ruby/library/resolv/get_names_spec.rb b/spec/ruby/library/resolv/get_names_spec.rb
index c405360615..f2bb08a653 100644
--- a/spec/ruby/library/resolv/get_names_spec.rb
+++ b/spec/ruby/library/resolv/get_names_spec.rb
@@ -1,11 +1,14 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'resolv'
describe "Resolv#getnames" do
- it "resolves 127.0.0.1" do
- hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
- res = Resolv.new([hosts])
+ platform_is_not :windows do
+ it "resolves 127.0.0.1" do
+ res = Resolv.new([Resolv::Hosts.new])
- names = res.getnames("127.0.0.1").should == ["localhost", "localhost4"]
+ names = res.getnames("127.0.0.1")
+ names.should_not == nil
+ names.size.should > 0
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/clone_spec.rb b/spec/ruby/library/rexml/attribute/clone_spec.rb
index 9a4a4079e1..df0d9ca466 100644
--- a/spec/ruby/library/rexml/attribute/clone_spec.rb
+++ b/spec/ruby/library/rexml/attribute/clone_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#clone" do
diff --git a/spec/ruby/library/rexml/attribute/element_spec.rb b/spec/ruby/library/rexml/attribute/element_spec.rb
index 832e7e9a41..c518bb7b55 100644
--- a/spec/ruby/library/rexml/attribute/element_spec.rb
+++ b/spec/ruby/library/rexml/attribute/element_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#element" do
diff --git a/spec/ruby/library/rexml/attribute/equal_value_spec.rb b/spec/ruby/library/rexml/attribute/equal_value_spec.rb
index 8bf2c0a3a1..2a7aa9e87e 100644
--- a/spec/ruby/library/rexml/attribute/equal_value_spec.rb
+++ b/spec/ruby/library/rexml/attribute/equal_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#==" do
diff --git a/spec/ruby/library/rexml/attribute/hash_spec.rb b/spec/ruby/library/rexml/attribute/hash_spec.rb
index dd71b28108..a77c23aada 100644
--- a/spec/ruby/library/rexml/attribute/hash_spec.rb
+++ b/spec/ruby/library/rexml/attribute/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#hash" do
diff --git a/spec/ruby/library/rexml/attribute/initialize_spec.rb b/spec/ruby/library/rexml/attribute/initialize_spec.rb
index 9f5e30c517..637bd1b012 100644
--- a/spec/ruby/library/rexml/attribute/initialize_spec.rb
+++ b/spec/ruby/library/rexml/attribute/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#initialize" do
@@ -19,7 +19,7 @@ describe "REXML::Attribute#initialize" do
copy.should == @name
end
- it "receives a parent node" do
+ it "recives a parent node" do
last_name = REXML::Attribute.new("last_name", "McBrain", @e)
last_name.element.should == @e
diff --git a/spec/ruby/library/rexml/attribute/inspect_spec.rb b/spec/ruby/library/rexml/attribute/inspect_spec.rb
index 632b477cca..bfc764f663 100644
--- a/spec/ruby/library/rexml/attribute/inspect_spec.rb
+++ b/spec/ruby/library/rexml/attribute/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#inspect" do
@@ -13,7 +13,8 @@ describe "REXML::Attribute#inspect" do
end
it "does not escape text" do
- a = REXML::Attribute.new("name", "<>")
- a.inspect.should == "name='<>'"
+ a = REXML::Attribute.new("&&", "<>")
+ a.inspect.should == "&&='<>'"
end
end
+
diff --git a/spec/ruby/library/rexml/attribute/namespace_spec.rb b/spec/ruby/library/rexml/attribute/namespace_spec.rb
index 9d50770735..5df9742cd3 100644
--- a/spec/ruby/library/rexml/attribute/namespace_spec.rb
+++ b/spec/ruby/library/rexml/attribute/namespace_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#namespace" do
diff --git a/spec/ruby/library/rexml/attribute/node_type_spec.rb b/spec/ruby/library/rexml/attribute/node_type_spec.rb
index 664d7cfa03..d44695deff 100644
--- a/spec/ruby/library/rexml/attribute/node_type_spec.rb
+++ b/spec/ruby/library/rexml/attribute/node_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#node_type" do
diff --git a/spec/ruby/library/rexml/attribute/prefix_spec.rb b/spec/ruby/library/rexml/attribute/prefix_spec.rb
index 2a47f74ad1..698c8d5d7b 100644
--- a/spec/ruby/library/rexml/attribute/prefix_spec.rb
+++ b/spec/ruby/library/rexml/attribute/prefix_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#prefix" do
diff --git a/spec/ruby/library/rexml/attribute/remove_spec.rb b/spec/ruby/library/rexml/attribute/remove_spec.rb
index 08d22cb6ba..5a08ef3a3c 100644
--- a/spec/ruby/library/rexml/attribute/remove_spec.rb
+++ b/spec/ruby/library/rexml/attribute/remove_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#remove" do
@@ -15,6 +15,6 @@ describe "REXML::Attribute#remove" do
end
it "does not anything if element has no parent" do
- -> {@attr.remove}.should_not raise_error(Exception)
+ lambda {@attr.remove}.should_not raise_error(Exception)
end
end
diff --git a/spec/ruby/library/rexml/attribute/to_s_spec.rb b/spec/ruby/library/rexml/attribute/to_s_spec.rb
index e1ce48ec33..96831625b6 100644
--- a/spec/ruby/library/rexml/attribute/to_s_spec.rb
+++ b/spec/ruby/library/rexml/attribute/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#to_s" do
diff --git a/spec/ruby/library/rexml/attribute/to_string_spec.rb b/spec/ruby/library/rexml/attribute/to_string_spec.rb
index 420913afeb..f8cc639a9d 100644
--- a/spec/ruby/library/rexml/attribute/to_string_spec.rb
+++ b/spec/ruby/library/rexml/attribute/to_string_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#to_string" do
@@ -12,3 +12,4 @@ describe "REXML::Attribute#to_string" do
attr_ns.to_string.should == "xmlns:ns='http://uri'"
end
end
+
diff --git a/spec/ruby/library/rexml/attribute/value_spec.rb b/spec/ruby/library/rexml/attribute/value_spec.rb
index 7763976881..912509cd75 100644
--- a/spec/ruby/library/rexml/attribute/value_spec.rb
+++ b/spec/ruby/library/rexml/attribute/value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#value" do
@@ -12,3 +12,4 @@ describe "REXML::Attribute#value" do
attr_empty.value.should == ""
end
end
+
diff --git a/spec/ruby/library/rexml/attribute/write_spec.rb b/spec/ruby/library/rexml/attribute/write_spec.rb
index 7ada7460f9..b6b59930e3 100644
--- a/spec/ruby/library/rexml/attribute/write_spec.rb
+++ b/spec/ruby/library/rexml/attribute/write_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#write" do
diff --git a/spec/ruby/library/rexml/attribute/xpath_spec.rb b/spec/ruby/library/rexml/attribute/xpath_spec.rb
index 8335e0a8ef..6fb80ead37 100644
--- a/spec/ruby/library/rexml/attribute/xpath_spec.rb
+++ b/spec/ruby/library/rexml/attribute/xpath_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attribute#xpath" do
@@ -14,6 +14,7 @@ describe "REXML::Attribute#xpath" do
end
it "raises an error if attribute has no parent" do
- -> { @attr.xpath }.should raise_error(Exception)
+ lambda { @attr.xpath }.should raise_error(Exception)
end
end
+
diff --git a/spec/ruby/library/rexml/attributes/add_spec.rb b/spec/ruby/library/rexml/attributes/add_spec.rb
index 32a927e10b..72e3c4c823 100644
--- a/spec/ruby/library/rexml/attributes/add_spec.rb
+++ b/spec/ruby/library/rexml/attributes/add_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/add'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/add', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#add" do
diff --git a/spec/ruby/library/rexml/attributes/append_spec.rb b/spec/ruby/library/rexml/attributes/append_spec.rb
index f1b08f7d6a..89f3fc3e81 100644
--- a/spec/ruby/library/rexml/attributes/append_spec.rb
+++ b/spec/ruby/library/rexml/attributes/append_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/add'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/add', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#<<" do
diff --git a/spec/ruby/library/rexml/attributes/delete_all_spec.rb b/spec/ruby/library/rexml/attributes/delete_all_spec.rb
index 9340b5693b..f11f0d66a3 100644
--- a/spec/ruby/library/rexml/attributes/delete_all_spec.rb
+++ b/spec/ruby/library/rexml/attributes/delete_all_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#delete_all" do
diff --git a/spec/ruby/library/rexml/attributes/delete_spec.rb b/spec/ruby/library/rexml/attributes/delete_spec.rb
index 495e4085ef..1c02e5c03b 100644
--- a/spec/ruby/library/rexml/attributes/delete_spec.rb
+++ b/spec/ruby/library/rexml/attributes/delete_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#delete" do
diff --git a/spec/ruby/library/rexml/attributes/each_attribute_spec.rb b/spec/ruby/library/rexml/attributes/each_attribute_spec.rb
index e84c8dbf51..cd1649be21 100644
--- a/spec/ruby/library/rexml/attributes/each_attribute_spec.rb
+++ b/spec/ruby/library/rexml/attributes/each_attribute_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#each_attribute" do
@@ -20,3 +20,6 @@ describe "REXML::Attributes#each_attribute" do
attributes.last.should == ns_uri
end
end
+
+
+
diff --git a/spec/ruby/library/rexml/attributes/each_spec.rb b/spec/ruby/library/rexml/attributes/each_spec.rb
index ed60634b90..f49bc75c0d 100644
--- a/spec/ruby/library/rexml/attributes/each_spec.rb
+++ b/spec/ruby/library/rexml/attributes/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#each" do
@@ -21,3 +21,5 @@ describe "REXML::Attributes#each" do
attributes.last.should == ["xmlns:ns", "http://some_uri"]
end
end
+
+
diff --git a/spec/ruby/library/rexml/attributes/element_reference_spec.rb b/spec/ruby/library/rexml/attributes/element_reference_spec.rb
index dac7952669..0e85ecafe8 100644
--- a/spec/ruby/library/rexml/attributes/element_reference_spec.rb
+++ b/spec/ruby/library/rexml/attributes/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#[]" do
@@ -16,3 +16,4 @@ describe "REXML::Attributes#[]" do
@e.attributes["chunky bacon"].should == nil
end
end
+
diff --git a/spec/ruby/library/rexml/attributes/element_set_spec.rb b/spec/ruby/library/rexml/attributes/element_set_spec.rb
index 1ed94dd2a1..659d259df6 100644
--- a/spec/ruby/library/rexml/attributes/element_set_spec.rb
+++ b/spec/ruby/library/rexml/attributes/element_set_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#[]=" do
@@ -23,3 +23,4 @@ describe "REXML::Attributes#[]=" do
@e.attributes.length.should == 0
end
end
+
diff --git a/spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb b/spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb
index 1664d6e42a..f4aeb76378 100644
--- a/spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb
+++ b/spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#get_attribute_ns" do
diff --git a/spec/ruby/library/rexml/attributes/get_attribute_spec.rb b/spec/ruby/library/rexml/attributes/get_attribute_spec.rb
index cfe58c1b9e..b7d83f5944 100644
--- a/spec/ruby/library/rexml/attributes/get_attribute_spec.rb
+++ b/spec/ruby/library/rexml/attributes/get_attribute_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#get_attribute" do
diff --git a/spec/ruby/library/rexml/attributes/initialize_spec.rb b/spec/ruby/library/rexml/attributes/initialize_spec.rb
index f18bd20c69..2bf59b1f76 100644
--- a/spec/ruby/library/rexml/attributes/initialize_spec.rb
+++ b/spec/ruby/library/rexml/attributes/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#initialize" do
diff --git a/spec/ruby/library/rexml/attributes/length_spec.rb b/spec/ruby/library/rexml/attributes/length_spec.rb
index 3a8361b8d7..cd68461e34 100644
--- a/spec/ruby/library/rexml/attributes/length_spec.rb
+++ b/spec/ruby/library/rexml/attributes/length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#length" do
diff --git a/spec/ruby/library/rexml/attributes/namespaces_spec.rb b/spec/ruby/library/rexml/attributes/namespaces_spec.rb
index 9e329fef6f..41486d0316 100644
--- a/spec/ruby/library/rexml/attributes/namespaces_spec.rb
+++ b/spec/ruby/library/rexml/attributes/namespaces_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#namespaces" do
diff --git a/spec/ruby/library/rexml/attributes/prefixes_spec.rb b/spec/ruby/library/rexml/attributes/prefixes_spec.rb
index 4675095aad..9eca67b5ff 100644
--- a/spec/ruby/library/rexml/attributes/prefixes_spec.rb
+++ b/spec/ruby/library/rexml/attributes/prefixes_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#prefixes" do
diff --git a/spec/ruby/library/rexml/attributes/shared/length.rb b/spec/ruby/library/rexml/attributes/shared/length.rb
index 7848f9bf33..94681882a6 100644
--- a/spec/ruby/library/rexml/attributes/shared/length.rb
+++ b/spec/ruby/library/rexml/attributes/shared/length.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'rexml/document'
describe :rexml_attribute_length, shared: true do
diff --git a/spec/ruby/library/rexml/attributes/size_spec.rb b/spec/ruby/library/rexml/attributes/size_spec.rb
index 3b1df9510d..761fcc1d5b 100644
--- a/spec/ruby/library/rexml/attributes/size_spec.rb
+++ b/spec/ruby/library/rexml/attributes/size_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#size" do
diff --git a/spec/ruby/library/rexml/attributes/to_a_spec.rb b/spec/ruby/library/rexml/attributes/to_a_spec.rb
index 1fbf71b683..a3de48cf1c 100644
--- a/spec/ruby/library/rexml/attributes/to_a_spec.rb
+++ b/spec/ruby/library/rexml/attributes/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Attributes#to_a" do
@@ -17,3 +17,4 @@ describe "REXML::Attributes#to_a" do
REXML::Element.new("root").attributes.to_a.should == []
end
end
+
diff --git a/spec/ruby/library/rexml/cdata/clone_spec.rb b/spec/ruby/library/rexml/cdata/clone_spec.rb
index 7d3cfda902..15dcf13a04 100644
--- a/spec/ruby/library/rexml/cdata/clone_spec.rb
+++ b/spec/ruby/library/rexml/cdata/clone_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::CData#clone" do
diff --git a/spec/ruby/library/rexml/cdata/initialize_spec.rb b/spec/ruby/library/rexml/cdata/initialize_spec.rb
index 0184440d87..bc0bc5cd6d 100644
--- a/spec/ruby/library/rexml/cdata/initialize_spec.rb
+++ b/spec/ruby/library/rexml/cdata/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::CData#initialize" do
diff --git a/spec/ruby/library/rexml/cdata/to_s_spec.rb b/spec/ruby/library/rexml/cdata/to_s_spec.rb
index ff3076e55e..3fb233cdaf 100644
--- a/spec/ruby/library/rexml/cdata/to_s_spec.rb
+++ b/spec/ruby/library/rexml/cdata/to_s_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/to_s'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
require 'rexml/document'
describe "REXML::CData#to_s" do
diff --git a/spec/ruby/library/rexml/cdata/value_spec.rb b/spec/ruby/library/rexml/cdata/value_spec.rb
index 6e8f8587a1..f9af73c0f6 100644
--- a/spec/ruby/library/rexml/cdata/value_spec.rb
+++ b/spec/ruby/library/rexml/cdata/value_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/to_s'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_s', __FILE__)
require 'rexml/document'
describe "REXML::CData#value" do
diff --git a/spec/ruby/library/rexml/document/add_element_spec.rb b/spec/ruby/library/rexml/document/add_element_spec.rb
index 42981d6465..03c95727e2 100644
--- a/spec/ruby/library/rexml/document/add_element_spec.rb
+++ b/spec/ruby/library/rexml/document/add_element_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#add_element" do
it "adds arg1 with attributes arg2 as root node" do
diff --git a/spec/ruby/library/rexml/document/add_spec.rb b/spec/ruby/library/rexml/document/add_spec.rb
index db95114e7e..491c28259b 100644
--- a/spec/ruby/library/rexml/document/add_spec.rb
+++ b/spec/ruby/library/rexml/document/add_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
# This spec defines Document#add and Document#<<
@@ -44,14 +44,14 @@ describe :rexml_document_add, shared: true do
end
it "refuses to add second root" do
- -> { @doc.send(@method, REXML::Element.new("foo")) }.should raise_error(RuntimeError)
+ lambda { @doc.send(@method, REXML::Element.new("foo")) }.should raise_error(RuntimeError)
end
end
describe "REXML::Document#add" do
- it_behaves_like :rexml_document_add, :add
+ it_behaves_like(:rexml_document_add, :add)
end
describe "REXML::Document#<<" do
- it_behaves_like :rexml_document_add, :<<
+ it_behaves_like(:rexml_document_add, :<<)
end
diff --git a/spec/ruby/library/rexml/document/clone_spec.rb b/spec/ruby/library/rexml/document/clone_spec.rb
index 4aebb6f156..cf333bf4df 100644
--- a/spec/ruby/library/rexml/document/clone_spec.rb
+++ b/spec/ruby/library/rexml/document/clone_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
# According to the MRI documentation (http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/index.html),
# clone's behavior "should be obvious". Apparently "obvious" means cloning
diff --git a/spec/ruby/library/rexml/document/doctype_spec.rb b/spec/ruby/library/rexml/document/doctype_spec.rb
index b919b071e1..5f277f6ad6 100644
--- a/spec/ruby/library/rexml/document/doctype_spec.rb
+++ b/spec/ruby/library/rexml/document/doctype_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#doctype" do
it "returns the doctype" do
diff --git a/spec/ruby/library/rexml/document/encoding_spec.rb b/spec/ruby/library/rexml/document/encoding_spec.rb
index 343e0ee45f..d20be0f7b7 100644
--- a/spec/ruby/library/rexml/document/encoding_spec.rb
+++ b/spec/ruby/library/rexml/document/encoding_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#encoding" do
before :each do
diff --git a/spec/ruby/library/rexml/document/expanded_name_spec.rb b/spec/ruby/library/rexml/document/expanded_name_spec.rb
index 1225d13fb0..e18fd95c14 100644
--- a/spec/ruby/library/rexml/document/expanded_name_spec.rb
+++ b/spec/ruby/library/rexml/document/expanded_name_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :document_expanded_name, shared: true do
it "returns an empty string for root" do # root nodes have no expanded name
@@ -8,9 +8,9 @@ describe :document_expanded_name, shared: true do
end
describe "REXML::Document#expanded_name" do
- it_behaves_like :document_expanded_name, :expanded_name
+ it_behaves_like(:document_expanded_name, :expanded_name)
end
describe "REXML::Document#name" do
- it_behaves_like :document_expanded_name, :name
+ it_behaves_like(:document_expanded_name, :name)
end
diff --git a/spec/ruby/library/rexml/document/new_spec.rb b/spec/ruby/library/rexml/document/new_spec.rb
index 3ff5e99b25..0caa3fd583 100644
--- a/spec/ruby/library/rexml/document/new_spec.rb
+++ b/spec/ruby/library/rexml/document/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Document#new" do
@@ -27,7 +27,7 @@ describe "REXML::Document#new" do
end
it "raises an error if source is not a Document, String or IO" do
- -> {REXML::Document.new(3)}.should raise_error(RuntimeError)
+ lambda {REXML::Document.new(3)}.should raise_error(RuntimeError)
end
it "does not perform XML validation" do
diff --git a/spec/ruby/library/rexml/document/node_type_spec.rb b/spec/ruby/library/rexml/document/node_type_spec.rb
index 85a4d507aa..b18b1a0dfe 100644
--- a/spec/ruby/library/rexml/document/node_type_spec.rb
+++ b/spec/ruby/library/rexml/document/node_type_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#node_type" do
it "returns :document" do
diff --git a/spec/ruby/library/rexml/document/root_spec.rb b/spec/ruby/library/rexml/document/root_spec.rb
index 3c24e79b2d..55be68da6f 100644
--- a/spec/ruby/library/rexml/document/root_spec.rb
+++ b/spec/ruby/library/rexml/document/root_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#root" do
it "returns document root tag name" do
diff --git a/spec/ruby/library/rexml/document/stand_alone_spec.rb b/spec/ruby/library/rexml/document/stand_alone_spec.rb
index 4ac24329d6..250c604dad 100644
--- a/spec/ruby/library/rexml/document/stand_alone_spec.rb
+++ b/spec/ruby/library/rexml/document/stand_alone_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#stand_alone?" do
it "returns the XMLDecl standalone value" do
diff --git a/spec/ruby/library/rexml/document/version_spec.rb b/spec/ruby/library/rexml/document/version_spec.rb
index 983b4b9af0..ca979dbf34 100644
--- a/spec/ruby/library/rexml/document/version_spec.rb
+++ b/spec/ruby/library/rexml/document/version_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#version" do
it "returns XML version from declaration" do
diff --git a/spec/ruby/library/rexml/document/write_spec.rb b/spec/ruby/library/rexml/document/write_spec.rb
index efa94b7117..f2a7e2c200 100644
--- a/spec/ruby/library/rexml/document/write_spec.rb
+++ b/spec/ruby/library/rexml/document/write_spec.rb
@@ -1,6 +1,6 @@
require 'rexml/document'
require 'rexml/formatters/transitive'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
# Maybe this can be cleaned
describe "REXML::Document#write" do
diff --git a/spec/ruby/library/rexml/document/xml_decl_spec.rb b/spec/ruby/library/rexml/document/xml_decl_spec.rb
index 30288a150b..6a5bf07c0b 100644
--- a/spec/ruby/library/rexml/document/xml_decl_spec.rb
+++ b/spec/ruby/library/rexml/document/xml_decl_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Document#xml_decl" do
it "returns XML declaration of the document" do
diff --git a/spec/ruby/library/rexml/element/add_attribute_spec.rb b/spec/ruby/library/rexml/element/add_attribute_spec.rb
index d15fb81ef1..998f5d6251 100644
--- a/spec/ruby/library/rexml/element/add_attribute_spec.rb
+++ b/spec/ruby/library/rexml/element/add_attribute_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#add_attribute" do
before :each do
diff --git a/spec/ruby/library/rexml/element/add_attributes_spec.rb b/spec/ruby/library/rexml/element/add_attributes_spec.rb
index b462fdf5fe..d4c0f0a6e2 100644
--- a/spec/ruby/library/rexml/element/add_attributes_spec.rb
+++ b/spec/ruby/library/rexml/element/add_attributes_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#add_attributes" do
before :each do
diff --git a/spec/ruby/library/rexml/element/add_element_spec.rb b/spec/ruby/library/rexml/element/add_element_spec.rb
index 8e2ffe3148..b6aab3da6a 100644
--- a/spec/ruby/library/rexml/element/add_element_spec.rb
+++ b/spec/ruby/library/rexml/element/add_element_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#add_element" do
diff --git a/spec/ruby/library/rexml/element/add_namespace_spec.rb b/spec/ruby/library/rexml/element/add_namespace_spec.rb
index 77c00eec46..60db839f02 100644
--- a/spec/ruby/library/rexml/element/add_namespace_spec.rb
+++ b/spec/ruby/library/rexml/element/add_namespace_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#add_namespace" do
before :each do
@@ -21,3 +21,4 @@ describe "REXML::Element#add_namespace" do
@elem.namespace.should == "some_uri"
end
end
+
diff --git a/spec/ruby/library/rexml/element/add_text_spec.rb b/spec/ruby/library/rexml/element/add_text_spec.rb
index 54e127bf4b..2f77b5f9f7 100644
--- a/spec/ruby/library/rexml/element/add_text_spec.rb
+++ b/spec/ruby/library/rexml/element/add_text_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#add_text" do
before :each do
diff --git a/spec/ruby/library/rexml/element/attribute_spec.rb b/spec/ruby/library/rexml/element/attribute_spec.rb
index e40d612ef3..9c5fb7a20e 100644
--- a/spec/ruby/library/rexml/element/attribute_spec.rb
+++ b/spec/ruby/library/rexml/element/attribute_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#attribute" do
it "returns an attribute by name" do
diff --git a/spec/ruby/library/rexml/element/attributes_spec.rb b/spec/ruby/library/rexml/element/attributes_spec.rb
index 8959b769a8..7cc5310ed1 100644
--- a/spec/ruby/library/rexml/element/attributes_spec.rb
+++ b/spec/ruby/library/rexml/element/attributes_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#attributes" do
it "returns element's Attributes" do
diff --git a/spec/ruby/library/rexml/element/cdatas_spec.rb b/spec/ruby/library/rexml/element/cdatas_spec.rb
index a371a5734b..1b44abe1e7 100644
--- a/spec/ruby/library/rexml/element/cdatas_spec.rb
+++ b/spec/ruby/library/rexml/element/cdatas_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#cdatas" do
before :each do
diff --git a/spec/ruby/library/rexml/element/clone_spec.rb b/spec/ruby/library/rexml/element/clone_spec.rb
index d26392db41..08f97e7793 100644
--- a/spec/ruby/library/rexml/element/clone_spec.rb
+++ b/spec/ruby/library/rexml/element/clone_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#clone" do
before :each do
diff --git a/spec/ruby/library/rexml/element/comments_spec.rb b/spec/ruby/library/rexml/element/comments_spec.rb
index 9dac2cc5b8..158b008b4f 100644
--- a/spec/ruby/library/rexml/element/comments_spec.rb
+++ b/spec/ruby/library/rexml/element/comments_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#comments" do
before :each do
diff --git a/spec/ruby/library/rexml/element/delete_attribute_spec.rb b/spec/ruby/library/rexml/element/delete_attribute_spec.rb
index 5c55c5efda..930db603b8 100644
--- a/spec/ruby/library/rexml/element/delete_attribute_spec.rb
+++ b/spec/ruby/library/rexml/element/delete_attribute_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#delete_attribute" do
before :each do
diff --git a/spec/ruby/library/rexml/element/delete_element_spec.rb b/spec/ruby/library/rexml/element/delete_element_spec.rb
index 9417229bd4..e6e36364ba 100644
--- a/spec/ruby/library/rexml/element/delete_element_spec.rb
+++ b/spec/ruby/library/rexml/element/delete_element_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#delete_element" do
before :each do
diff --git a/spec/ruby/library/rexml/element/delete_namespace_spec.rb b/spec/ruby/library/rexml/element/delete_namespace_spec.rb
index 8683a40cab..10de705076 100644
--- a/spec/ruby/library/rexml/element/delete_namespace_spec.rb
+++ b/spec/ruby/library/rexml/element/delete_namespace_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#delete_namespace" do
diff --git a/spec/ruby/library/rexml/element/document_spec.rb b/spec/ruby/library/rexml/element/document_spec.rb
index 24773580f2..bdf9205a85 100644
--- a/spec/ruby/library/rexml/element/document_spec.rb
+++ b/spec/ruby/library/rexml/element/document_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#document" do
@@ -14,3 +14,5 @@ describe "REXML::Element#document" do
REXML::Element.new("standalone").document.should be_nil
end
end
+
+
diff --git a/spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb b/spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb
index 3c5da3f015..2769fd2d26 100644
--- a/spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb
+++ b/spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#each_element_with_attributes" do
before :each do
diff --git a/spec/ruby/library/rexml/element/each_element_with_text_spec.rb b/spec/ruby/library/rexml/element/each_element_with_text_spec.rb
index 5f9e5b85dc..79848c779c 100644
--- a/spec/ruby/library/rexml/element/each_element_with_text_spec.rb
+++ b/spec/ruby/library/rexml/element/each_element_with_text_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#each_element_with_text" do
before :each do
diff --git a/spec/ruby/library/rexml/element/element_reference_spec.rb b/spec/ruby/library/rexml/element/element_reference_spec.rb
index 9660ff7507..eb01169137 100644
--- a/spec/ruby/library/rexml/element/element_reference_spec.rb
+++ b/spec/ruby/library/rexml/element/element_reference_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#[]" do
@@ -9,12 +9,14 @@ describe "REXML::Element#[]" do
@doc.root.add_element @child
end
- it "return attribute value if argument is string or symbol" do
- @doc.root[:foo].should == 'bar'
- @doc.root['foo'].should == 'bar'
- end
+ ruby_version_is "2.4" do
+ it "return attribute value if argument is string or symbol" do
+ @doc.root[:foo].should == 'bar'
+ @doc.root['foo'].should == 'bar'
+ end
- it "return nth element if argument is int" do
- @doc.root[0].should == @child
+ it "return nth element if argument is int" do
+ @doc.root[0].should == @child
+ end
end
end
diff --git a/spec/ruby/library/rexml/element/get_text_spec.rb b/spec/ruby/library/rexml/element/get_text_spec.rb
index 8ee9ea0824..9ae343e097 100644
--- a/spec/ruby/library/rexml/element/get_text_spec.rb
+++ b/spec/ruby/library/rexml/element/get_text_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#get_text" do
before :each do
diff --git a/spec/ruby/library/rexml/element/has_attributes_spec.rb b/spec/ruby/library/rexml/element/has_attributes_spec.rb
index f89ec675f5..f6c1c45e31 100644
--- a/spec/ruby/library/rexml/element/has_attributes_spec.rb
+++ b/spec/ruby/library/rexml/element/has_attributes_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#has_attributes?" do
before :each do
diff --git a/spec/ruby/library/rexml/element/has_elements_spec.rb b/spec/ruby/library/rexml/element/has_elements_spec.rb
index dc5fc9c25b..54898b0d19 100644
--- a/spec/ruby/library/rexml/element/has_elements_spec.rb
+++ b/spec/ruby/library/rexml/element/has_elements_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#has_elements?" do
before :each do
diff --git a/spec/ruby/library/rexml/element/has_text_spec.rb b/spec/ruby/library/rexml/element/has_text_spec.rb
index e9d5a176cb..4747149ac7 100644
--- a/spec/ruby/library/rexml/element/has_text_spec.rb
+++ b/spec/ruby/library/rexml/element/has_text_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#has_text?" do
diff --git a/spec/ruby/library/rexml/element/inspect_spec.rb b/spec/ruby/library/rexml/element/inspect_spec.rb
index f45edd0b1f..8e93afb562 100644
--- a/spec/ruby/library/rexml/element/inspect_spec.rb
+++ b/spec/ruby/library/rexml/element/inspect_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#inspect" do
diff --git a/spec/ruby/library/rexml/element/instructions_spec.rb b/spec/ruby/library/rexml/element/instructions_spec.rb
index aa2d192e7c..01a2374820 100644
--- a/spec/ruby/library/rexml/element/instructions_spec.rb
+++ b/spec/ruby/library/rexml/element/instructions_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#instructions" do
before :each do
diff --git a/spec/ruby/library/rexml/element/namespace_spec.rb b/spec/ruby/library/rexml/element/namespace_spec.rb
index 89662f3599..a0b7ba0c83 100644
--- a/spec/ruby/library/rexml/element/namespace_spec.rb
+++ b/spec/ruby/library/rexml/element/namespace_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#namespace" do
before :each do
diff --git a/spec/ruby/library/rexml/element/namespaces_spec.rb b/spec/ruby/library/rexml/element/namespaces_spec.rb
index a84c1d1dab..646503e184 100644
--- a/spec/ruby/library/rexml/element/namespaces_spec.rb
+++ b/spec/ruby/library/rexml/element/namespaces_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#namespaces" do
before :each do
diff --git a/spec/ruby/library/rexml/element/new_spec.rb b/spec/ruby/library/rexml/element/new_spec.rb
index 4ffdf4dabe..c18a33624b 100644
--- a/spec/ruby/library/rexml/element/new_spec.rb
+++ b/spec/ruby/library/rexml/element/new_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#new" do
diff --git a/spec/ruby/library/rexml/element/next_element_spec.rb b/spec/ruby/library/rexml/element/next_element_spec.rb
index 5b6d6cad9b..51b8438ba7 100644
--- a/spec/ruby/library/rexml/element/next_element_spec.rb
+++ b/spec/ruby/library/rexml/element/next_element_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#next_element" do
before :each do
diff --git a/spec/ruby/library/rexml/element/node_type_spec.rb b/spec/ruby/library/rexml/element/node_type_spec.rb
index bcab9e126d..3c9b713fde 100644
--- a/spec/ruby/library/rexml/element/node_type_spec.rb
+++ b/spec/ruby/library/rexml/element/node_type_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#node_type" do
it "returns :element" do
diff --git a/spec/ruby/library/rexml/element/prefixes_spec.rb b/spec/ruby/library/rexml/element/prefixes_spec.rb
index b6edf9a847..03c46eab9e 100644
--- a/spec/ruby/library/rexml/element/prefixes_spec.rb
+++ b/spec/ruby/library/rexml/element/prefixes_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#prefixes" do
before :each do
diff --git a/spec/ruby/library/rexml/element/previous_element_spec.rb b/spec/ruby/library/rexml/element/previous_element_spec.rb
index 2fe79d955f..49279e8e94 100644
--- a/spec/ruby/library/rexml/element/previous_element_spec.rb
+++ b/spec/ruby/library/rexml/element/previous_element_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#previous_element" do
before :each do
diff --git a/spec/ruby/library/rexml/element/raw_spec.rb b/spec/ruby/library/rexml/element/raw_spec.rb
index 404ccce5f4..a872c36c8b 100644
--- a/spec/ruby/library/rexml/element/raw_spec.rb
+++ b/spec/ruby/library/rexml/element/raw_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#raw" do
it "returns true if raw mode is set to all" do
diff --git a/spec/ruby/library/rexml/element/root_spec.rb b/spec/ruby/library/rexml/element/root_spec.rb
index 1e0669033e..24e488e701 100644
--- a/spec/ruby/library/rexml/element/root_spec.rb
+++ b/spec/ruby/library/rexml/element/root_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Element#root" do
diff --git a/spec/ruby/library/rexml/element/text_spec.rb b/spec/ruby/library/rexml/element/text_spec.rb
index 7c290c4cda..25791d6397 100644
--- a/spec/ruby/library/rexml/element/text_spec.rb
+++ b/spec/ruby/library/rexml/element/text_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#text" do
before :each do
diff --git a/spec/ruby/library/rexml/element/texts_spec.rb b/spec/ruby/library/rexml/element/texts_spec.rb
index 7975833c89..de3a818866 100644
--- a/spec/ruby/library/rexml/element/texts_spec.rb
+++ b/spec/ruby/library/rexml/element/texts_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#texts" do
diff --git a/spec/ruby/library/rexml/element/whitespace_spec.rb b/spec/ruby/library/rexml/element/whitespace_spec.rb
index dc785ae5ce..ea9ff42c03 100644
--- a/spec/ruby/library/rexml/element/whitespace_spec.rb
+++ b/spec/ruby/library/rexml/element/whitespace_spec.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "REXML::Element#whitespace" do
it "returns true if whitespace is respected in the element" do
diff --git a/spec/ruby/library/rexml/node/each_recursive_spec.rb b/spec/ruby/library/rexml/node/each_recursive_spec.rb
index dd4aa9a2f2..5f26c898ea 100644
--- a/spec/ruby/library/rexml/node/each_recursive_spec.rb
+++ b/spec/ruby/library/rexml/node/each_recursive_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Node#each_recursive" do
diff --git a/spec/ruby/library/rexml/node/find_first_recursive_spec.rb b/spec/ruby/library/rexml/node/find_first_recursive_spec.rb
index ba46f2ca35..20e87fe9e9 100644
--- a/spec/ruby/library/rexml/node/find_first_recursive_spec.rb
+++ b/spec/ruby/library/rexml/node/find_first_recursive_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Node#find_first_recursive" do
diff --git a/spec/ruby/library/rexml/node/index_in_parent_spec.rb b/spec/ruby/library/rexml/node/index_in_parent_spec.rb
index 092851e3e7..018a4c08ac 100644
--- a/spec/ruby/library/rexml/node/index_in_parent_spec.rb
+++ b/spec/ruby/library/rexml/node/index_in_parent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Node#index_in_parent" do
diff --git a/spec/ruby/library/rexml/node/next_sibling_node_spec.rb b/spec/ruby/library/rexml/node/next_sibling_node_spec.rb
index 2e8601627d..9ca91c9149 100644
--- a/spec/ruby/library/rexml/node/next_sibling_node_spec.rb
+++ b/spec/ruby/library/rexml/node/next_sibling_node_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Node#next_sibling_node" do
diff --git a/spec/ruby/library/rexml/node/parent_spec.rb b/spec/ruby/library/rexml/node/parent_spec.rb
index d88ba69657..ee3c234534 100644
--- a/spec/ruby/library/rexml/node/parent_spec.rb
+++ b/spec/ruby/library/rexml/node/parent_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Node#parent?" do
@@ -18,3 +18,4 @@ describe "REXML::Node#parent?" do
e.parent?.should == false
end
end
+
diff --git a/spec/ruby/library/rexml/node/previous_sibling_node_spec.rb b/spec/ruby/library/rexml/node/previous_sibling_node_spec.rb
index 8b96f1565a..b8e4465979 100644
--- a/spec/ruby/library/rexml/node/previous_sibling_node_spec.rb
+++ b/spec/ruby/library/rexml/node/previous_sibling_node_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Node#previous_sibling_node" do
diff --git a/spec/ruby/library/rexml/shared/each_element.rb b/spec/ruby/library/rexml/shared/each_element.rb
index 2e0871161d..1cb79c8d3a 100644
--- a/spec/ruby/library/rexml/shared/each_element.rb
+++ b/spec/ruby/library/rexml/shared/each_element.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :rexml_each_element, shared: true do
before :each do
diff --git a/spec/ruby/library/rexml/shared/elements_to_a.rb b/spec/ruby/library/rexml/shared/elements_to_a.rb
index 388250d8b3..6299c628c3 100644
--- a/spec/ruby/library/rexml/shared/elements_to_a.rb
+++ b/spec/ruby/library/rexml/shared/elements_to_a.rb
@@ -1,5 +1,5 @@
require 'rexml/document'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe :rexml_elements_to_a, shared: true do
before :each do
diff --git a/spec/ruby/library/rexml/text/append_spec.rb b/spec/ruby/library/rexml/text/append_spec.rb
index de281fb0b0..c8f73f9393 100644
--- a/spec/ruby/library/rexml/text/append_spec.rb
+++ b/spec/ruby/library/rexml/text/append_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#<<" do
diff --git a/spec/ruby/library/rexml/text/clone_spec.rb b/spec/ruby/library/rexml/text/clone_spec.rb
index 8031e140c7..c7d16e0d85 100644
--- a/spec/ruby/library/rexml/text/clone_spec.rb
+++ b/spec/ruby/library/rexml/text/clone_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#clone" do
diff --git a/spec/ruby/library/rexml/text/comparison_spec.rb b/spec/ruby/library/rexml/text/comparison_spec.rb
index 8bc5d66a03..ba637ea37e 100644
--- a/spec/ruby/library/rexml/text/comparison_spec.rb
+++ b/spec/ruby/library/rexml/text/comparison_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#<=>" do
diff --git a/spec/ruby/library/rexml/text/empty_spec.rb b/spec/ruby/library/rexml/text/empty_spec.rb
index d0b66b7a2a..7102e1586e 100644
--- a/spec/ruby/library/rexml/text/empty_spec.rb
+++ b/spec/ruby/library/rexml/text/empty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#empty?" do
diff --git a/spec/ruby/library/rexml/text/indent_text_spec.rb b/spec/ruby/library/rexml/text/indent_text_spec.rb
index 1b0ee5ab16..2aa908826b 100644
--- a/spec/ruby/library/rexml/text/indent_text_spec.rb
+++ b/spec/ruby/library/rexml/text/indent_text_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#indent_text" do
@@ -21,3 +21,4 @@ describe "REXML::Text#indent_text" do
@t.indent_text("foo", 1, "\t", false).should == "foo"
end
end
+
diff --git a/spec/ruby/library/rexml/text/inspect_spec.rb b/spec/ruby/library/rexml/text/inspect_spec.rb
index 0d66088a64..655e42fcdf 100644
--- a/spec/ruby/library/rexml/text/inspect_spec.rb
+++ b/spec/ruby/library/rexml/text/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#inspect" do
diff --git a/spec/ruby/library/rexml/text/new_spec.rb b/spec/ruby/library/rexml/text/new_spec.rb
index 3c081dec30..0d7a750a1d 100644
--- a/spec/ruby/library/rexml/text/new_spec.rb
+++ b/spec/ruby/library/rexml/text/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text.new" do
@@ -28,12 +28,12 @@ describe "REXML::Text.new" do
t = REXML::Text.new("&lt;&amp;&gt;", false, nil, true)
t.should == "&lt;&amp;&gt;"
- ->{ REXML::Text.new("<&>", false, nil, true)}.should raise_error(Exception)
+ lambda{ REXML::Text.new("<&>", false, nil, true)}.should raise_error(Exception)
end
it "uses raw value of the parent if raw is nil" do
e1 = REXML::Element.new("root", nil, { raw: :all})
- -> {REXML::Text.new("<&>", false, e1)}.should raise_error(Exception)
+ lambda {REXML::Text.new("<&>", false, e1)}.should raise_error(Exception)
e2 = REXML::Element.new("root", nil, { raw: []})
e2.raw.should be_false
@@ -46,3 +46,4 @@ describe "REXML::Text.new" do
t.should == "&lt;&amp;&gt;"
end
end
+
diff --git a/spec/ruby/library/rexml/text/node_type_spec.rb b/spec/ruby/library/rexml/text/node_type_spec.rb
index 1c25a74dad..a1c51b5b91 100644
--- a/spec/ruby/library/rexml/text/node_type_spec.rb
+++ b/spec/ruby/library/rexml/text/node_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#node_type" do
diff --git a/spec/ruby/library/rexml/text/normalize_spec.rb b/spec/ruby/library/rexml/text/normalize_spec.rb
index ce3b2b3b5f..1725c38146 100644
--- a/spec/ruby/library/rexml/text/normalize_spec.rb
+++ b/spec/ruby/library/rexml/text/normalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text.normalize" do
diff --git a/spec/ruby/library/rexml/text/read_with_substitution_spec.rb b/spec/ruby/library/rexml/text/read_with_substitution_spec.rb
index 83b42f6d6b..7e42c40248 100644
--- a/spec/ruby/library/rexml/text/read_with_substitution_spec.rb
+++ b/spec/ruby/library/rexml/text/read_with_substitution_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text.read_with_substitution" do
@@ -7,6 +7,7 @@ describe "REXML::Text.read_with_substitution" do
end
it "accepts an regex for invalid expressions and raises an error if text matches" do
- -> {REXML::Text.read_with_substitution("this is illegal", /illegal/)}.should raise_error(Exception)
+ lambda {REXML::Text.read_with_substitution("this is illegal", /illegal/)}.should raise_error(Exception)
end
end
+
diff --git a/spec/ruby/library/rexml/text/to_s_spec.rb b/spec/ruby/library/rexml/text/to_s_spec.rb
index 14d7399a60..94356ff075 100644
--- a/spec/ruby/library/rexml/text/to_s_spec.rb
+++ b/spec/ruby/library/rexml/text/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#to_s" do
@@ -15,3 +15,4 @@ describe "REXML::Text#to_s" do
t.to_s.should == "&amp; &lt; &gt;"
end
end
+
diff --git a/spec/ruby/library/rexml/text/unnormalize_spec.rb b/spec/ruby/library/rexml/text/unnormalize_spec.rb
index 3072809c13..6406589694 100644
--- a/spec/ruby/library/rexml/text/unnormalize_spec.rb
+++ b/spec/ruby/library/rexml/text/unnormalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text.unnormalize" do
diff --git a/spec/ruby/library/rexml/text/value_spec.rb b/spec/ruby/library/rexml/text/value_spec.rb
index b0545b3cbd..d14e8aca6b 100644
--- a/spec/ruby/library/rexml/text/value_spec.rb
+++ b/spec/ruby/library/rexml/text/value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#value" do
diff --git a/spec/ruby/library/rexml/text/wrap_spec.rb b/spec/ruby/library/rexml/text/wrap_spec.rb
index 0b60fd4151..a56759b0f4 100644
--- a/spec/ruby/library/rexml/text/wrap_spec.rb
+++ b/spec/ruby/library/rexml/text/wrap_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#wrap" do
@@ -18,3 +18,4 @@ describe "REXML::Text#wrap" do
@t.wrap("abc def", 3, true).should == "\nabc\ndef"
end
end
+
diff --git a/spec/ruby/library/rexml/text/write_with_substitution_spec.rb b/spec/ruby/library/rexml/text/write_with_substitution_spec.rb
index ee79489d86..e5f027f297 100644
--- a/spec/ruby/library/rexml/text/write_with_substitution_spec.rb
+++ b/spec/ruby/library/rexml/text/write_with_substitution_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'rexml/document'
describe "REXML::Text#write_with_substitution" do
diff --git a/spec/ruby/library/rubygems/gem/bin_path_spec.rb b/spec/ruby/library/rubygems/gem/bin_path_spec.rb
deleted file mode 100644
index 67b3e042c2..0000000000
--- a/spec/ruby/library/rubygems/gem/bin_path_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../../spec_helper'
-require 'rubygems'
-
-describe "Gem.bin_path" do
- before :each do
- @bundle_gemfile = ENV['BUNDLE_GEMFILE']
- ENV['BUNDLE_GEMFILE'] = tmp("no-gemfile")
- end
-
- after :each do
- ENV['BUNDLE_GEMFILE'] = @bundle_gemfile
- end
-
- platform_is_not :windows do
- it "finds executables of default gems, which are the only files shipped for default gems" do
- # For instance, Gem.bin_path("bundler", "bundle") is used by rails new
-
- if Gem.respond_to? :default_specifications_dir
- default_specifications_dir = Gem.default_specifications_dir
- else
- default_specifications_dir = Gem::Specification.default_specifications_dir
- end
-
- skip "Could not find the default gemspecs" unless Dir.exist?(default_specifications_dir)
-
- Gem::Specification.each_spec([default_specifications_dir]) do |spec|
- spec.executables.each do |exe|
- path = Gem.bin_path(spec.name, exe)
- File.should.exist?(path)
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/scanf/io/block_scanf_spec.rb b/spec/ruby/library/scanf/io/block_scanf_spec.rb
index b9cc1b507e..0f6188f91c 100644
--- a/spec/ruby/library/scanf/io/block_scanf_spec.rb
+++ b/spec/ruby/library/scanf/io/block_scanf_spec.rb
@@ -1,10 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/block_scanf.rb', __FILE__)
+require 'scanf'
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "IO#block_scanf" do
- it_behaves_like :scanf_io_block_scanf, :block_scanf
- end
+describe "IO#block_scanf" do
+ it_behaves_like(:scanf_io_block_scanf, :block_scanf)
end
diff --git a/spec/ruby/library/scanf/io/scanf_spec.rb b/spec/ruby/library/scanf/io/scanf_spec.rb
index 6a3e6d0d1a..27c3142678 100644
--- a/spec/ruby/library/scanf/io/scanf_spec.rb
+++ b/spec/ruby/library/scanf/io/scanf_spec.rb
@@ -1,38 +1,35 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/block_scanf.rb', __FILE__)
+require 'scanf'
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "IO#scanf" do
- before :each do
- @hw = File.open(fixture(__FILE__, 'helloworld.txt'), 'rb')
- @data = File.open(fixture(__FILE__, 'date.txt'), 'rb')
- end
-
- after :each do
- @hw.close unless @hw.closed?
- @data.close unless @data.closed?
- end
+describe "IO#scanf" do
+ before :each do
+ @hw = File.open(File.dirname(__FILE__) + '/fixtures/helloworld.txt', 'r')
+ @data = File.open(File.dirname(__FILE__) + '/fixtures/date.txt', 'r')
+ end
- it "returns an array containing the input converted in the specified type" do
- @hw.scanf("%s%s").should == ["hello", "world"]
- @data.scanf("%s%d").should == ["Beethoven", 1770]
- end
+ after :each do
+ @hw.close unless @hw.closed?
+ @data.close unless @data.closed?
+ end
- it "returns an array containing the input converted in the specified type with given maximum field width" do
- @hw.scanf("%2s").should == ["he"]
- @data.scanf("%2c").should == ["Be"]
- end
+ it "returns an array containing the input converted in the specified type" do
+ @hw.scanf("%s%s").should == ["hello", "world"]
+ @data.scanf("%s%d").should == ["Beethoven", 1770]
+ end
- it "returns an empty array when a wrong specifier is passed" do
- @hw.scanf("%a").should == []
- @hw.scanf("%1").should == []
- @data.scanf("abc").should == []
- end
+ it "returns an array containing the input converted in the specified type with given maximum field width" do
+ @hw.scanf("%2s").should == ["he"]
+ @data.scanf("%2c").should == ["Be"]
end
- describe "IO#scanf with block" do
- it_behaves_like :scanf_io_block_scanf, :scanf
+ it "returns an empty array when a wrong specifier is passed" do
+ @hw.scanf("%a").should == []
+ @hw.scanf("%1").should == []
+ @data.scanf("abc").should == []
end
end
+
+describe "IO#scanf with block" do
+ it_behaves_like(:scanf_io_block_scanf, :scanf)
+end
diff --git a/spec/ruby/library/scanf/io/shared/block_scanf.rb b/spec/ruby/library/scanf/io/shared/block_scanf.rb
index d938f43734..8c5bffb93b 100644
--- a/spec/ruby/library/scanf/io/shared/block_scanf.rb
+++ b/spec/ruby/library/scanf/io/shared/block_scanf.rb
@@ -2,7 +2,7 @@ require 'scanf'
describe :scanf_io_block_scanf, shared: true do
before :each do
- @data = File.open(fixture(__FILE__, 'date.txt'), 'rb')
+ @data= File.open(File.dirname(__FILE__) + '/../fixtures/date.txt', 'r')
end
after :each do
diff --git a/spec/ruby/library/scanf/string/block_scanf_spec.rb b/spec/ruby/library/scanf/string/block_scanf_spec.rb
index 277e1fa1d7..1444cc2975 100644
--- a/spec/ruby/library/scanf/string/block_scanf_spec.rb
+++ b/spec/ruby/library/scanf/string/block_scanf_spec.rb
@@ -1,10 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/block_scanf.rb', __FILE__)
+require 'scanf'
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "String#block_scanf" do
- it_behaves_like :scanf_string_block_scanf, :block_scanf
- end
+describe "String#block_scanf" do
+ it_behaves_like(:scanf_string_block_scanf, :block_scanf)
end
diff --git a/spec/ruby/library/scanf/string/scanf_spec.rb b/spec/ruby/library/scanf/string/scanf_spec.rb
index c8897db675..360c72fba8 100644
--- a/spec/ruby/library/scanf/string/scanf_spec.rb
+++ b/spec/ruby/library/scanf/string/scanf_spec.rb
@@ -1,56 +1,53 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/block_scanf.rb', __FILE__)
+require 'scanf'
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "String#scanf" do
- it "returns an array containing the input converted in the specified type" do
- "hello world".scanf("%s").should == ["hello"]
- "hello world".scanf("%s%d").should == ["hello"]
- "hello world".scanf("%s%c").should == ["hello", " "]
- "hello world".scanf("%c%s").should == ["h", "ello"]
- "hello world".scanf("%s%s").should == ["hello", "world"]
- "hello world".scanf("%c").should == ["h"]
- "123".scanf("%s").should == ["123"]
- "123".scanf("%c").should == ["1"]
- "123".scanf("%d").should == [123]
- "123".scanf("%u").should == [123]
- "123".scanf("%o").should == [83]
- "123".scanf("%x").should == [291]
- "123".scanf("%i").should == [123]
- "0123".scanf("%i").should == [83]
- "123".scanf("%f").should == [123.0]
- "0X123".scanf("%i").should == [291]
- "0x123".scanf("%i").should == [291]
- end
-
- it "returns an array containing the input converted in the specified type with given maximum field width" do
- "hello world".scanf("%2s").should == ["he"]
- "hello world".scanf("%2c").should == ["he"]
- "123".scanf("%2s").should == ["12"]
- "123".scanf("%2c").should == ["12"]
- "123".scanf("%2d").should == [12]
- "123".scanf("%2u").should == [12]
- "123".scanf("%2o").should == [10]
- "123".scanf("%2x").should == [18]
- "123".scanf("%2i").should == [12]
- "0123".scanf("%2i").should == [1]
- "123".scanf("%2f").should == [12.0]
- "0X123".scanf("%2i").should == [0]
- "0X123".scanf("%3i").should == [1]
- "0X123".scanf("%4i").should == [18]
- end
+describe "String#scanf" do
+ it "returns an array containing the input converted in the specified type" do
+ "hello world".scanf("%s").should == ["hello"]
+ "hello world".scanf("%s%d").should == ["hello"]
+ "hello world".scanf("%s%c").should == ["hello", " "]
+ "hello world".scanf("%c%s").should == ["h", "ello"]
+ "hello world".scanf("%s%s").should == ["hello", "world"]
+ "hello world".scanf("%c").should == ["h"]
+ "123".scanf("%s").should == ["123"]
+ "123".scanf("%c").should == ["1"]
+ "123".scanf("%d").should == [123]
+ "123".scanf("%u").should == [123]
+ "123".scanf("%o").should == [83]
+ "123".scanf("%x").should == [291]
+ "123".scanf("%i").should == [123]
+ "0123".scanf("%i").should == [83]
+ "123".scanf("%f").should == [123.0]
+ "0X123".scanf("%i").should == [291]
+ "0x123".scanf("%i").should == [291]
+ end
- it "returns an empty array when a wrong specifier is passed" do
- "hello world".scanf("%a").should == []
- "123".scanf("%1").should == []
- "123".scanf("abc").should == []
- "123".scanf(:d).should == []
- end
+ it "returns an array containing the input converted in the specified type with given maximum field width" do
+ "hello world".scanf("%2s").should == ["he"]
+ "hello world".scanf("%2c").should == ["he"]
+ "123".scanf("%2s").should == ["12"]
+ "123".scanf("%2c").should == ["12"]
+ "123".scanf("%2d").should == [12]
+ "123".scanf("%2u").should == [12]
+ "123".scanf("%2o").should == [10]
+ "123".scanf("%2x").should == [18]
+ "123".scanf("%2i").should == [12]
+ "0123".scanf("%2i").should == [1]
+ "123".scanf("%2f").should == [12.0]
+ "0X123".scanf("%2i").should == [0]
+ "0X123".scanf("%3i").should == [1]
+ "0X123".scanf("%4i").should == [18]
end
- describe "String#scanf with block" do
- it_behaves_like :scanf_string_block_scanf, :scanf
+ it "returns an empty array when a wrong specifier is passed" do
+ "hello world".scanf("%a").should == []
+ "123".scanf("%1").should == []
+ "123".scanf("abc").should == []
+ "123".scanf(:d).should == []
end
end
+
+describe "String#scanf with block" do
+ it_behaves_like(:scanf_string_block_scanf, :scanf)
+end
diff --git a/spec/ruby/library/securerandom/base64_spec.rb b/spec/ruby/library/securerandom/base64_spec.rb
index 34cd419ce2..57db25fa29 100644
--- a/spec/ruby/library/securerandom/base64_spec.rb
+++ b/spec/ruby/library/securerandom/base64_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'securerandom'
@@ -42,7 +42,7 @@ describe "SecureRandom.base64" do
end
it "raises ArgumentError on negative arguments" do
- -> {
+ lambda {
SecureRandom.base64(-1)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/securerandom/bytes_spec.rb b/spec/ruby/library/securerandom/bytes_spec.rb
deleted file mode 100644
index a1ab836d16..0000000000
--- a/spec/ruby/library/securerandom/bytes_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require_relative '../../core/random/shared/bytes'
-
-require 'securerandom'
-
-describe "SecureRandom.bytes" do
- it_behaves_like :random_bytes, :bytes, SecureRandom
-end
diff --git a/spec/ruby/library/securerandom/hex_spec.rb b/spec/ruby/library/securerandom/hex_spec.rb
index bdb920b217..8690d8458c 100644
--- a/spec/ruby/library/securerandom/hex_spec.rb
+++ b/spec/ruby/library/securerandom/hex_spec.rb
@@ -1,9 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'securerandom'
describe "SecureRandom.hex" do
- it "generates a random hex string of length twice the specified argument" do
+ it "generates a random hex string of length twice the specified argement" do
(1..64).each do |idx|
hex = SecureRandom.hex(idx)
hex.should be_kind_of(String)
@@ -41,7 +41,7 @@ describe "SecureRandom.hex" do
end
it "raises ArgumentError on negative arguments" do
- -> {
+ lambda {
SecureRandom.hex(-1)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/securerandom/random_bytes_spec.rb b/spec/ruby/library/securerandom/random_bytes_spec.rb
index ed3a02255c..37d82f55a6 100644
--- a/spec/ruby/library/securerandom/random_bytes_spec.rb
+++ b/spec/ruby/library/securerandom/random_bytes_spec.rb
@@ -1,11 +1,8 @@
-require_relative '../../spec_helper'
-require_relative '../../core/random/shared/bytes'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'securerandom'
describe "SecureRandom.random_bytes" do
- it_behaves_like :random_bytes, :random_bytes, SecureRandom
-
it "generates a random binary string of length 16 if no argument is provided" do
bytes = SecureRandom.random_bytes
bytes.should be_kind_of(String)
@@ -40,7 +37,7 @@ describe "SecureRandom.random_bytes" do
end
it "raises ArgumentError on negative arguments" do
- -> {
+ lambda {
SecureRandom.random_bytes(-1)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/securerandom/random_number_spec.rb b/spec/ruby/library/securerandom/random_number_spec.rb
index 3e1812c6e8..a23a457df2 100644
--- a/spec/ruby/library/securerandom/random_number_spec.rb
+++ b/spec/ruby/library/securerandom/random_number_spec.rb
@@ -1,12 +1,8 @@
-require_relative '../../spec_helper'
-require_relative '../../core/random/shared/rand'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'securerandom'
describe "SecureRandom.random_number" do
- it_behaves_like :random_number, :rand, SecureRandom
- it_behaves_like :random_number, :random_number, SecureRandom
-
it "generates a random positive number smaller then the positive integer argument" do
(1..64).each do |idx|
num = SecureRandom.random_number(idx)
@@ -35,32 +31,34 @@ describe "SecureRandom.random_number" do
end
end
- it "generates a random value in given (integer) range limits" do
- 64.times do
- num = SecureRandom.random_number 11...13
- num.should be_kind_of(Integer)
- (11 <= num).should == true
- (num < 13).should == true
+ ruby_version_is "2.3" do
+ it "generates a random value in given (integer) range limits" do
+ 64.times do
+ num = SecureRandom.random_number 11...13
+ num.should be_kind_of(Integer)
+ (11 <= num).should == true
+ (num < 13).should == true
+ end
end
- end
- it "generates a random value in given big (integer) range limits" do
- lower = 12345678901234567890
- upper = 12345678901234567890 + 5
- 32.times do
- num = SecureRandom.random_number lower..upper
- num.should be_kind_of(Integer)
- (lower <= num).should == true
- (num <= upper).should == true
+ it "generates a random value in given big (integer) range limits" do
+ lower = 12345678901234567890
+ upper = 12345678901234567890 + 5
+ 32.times do
+ num = SecureRandom.random_number lower..upper
+ num.should be_kind_of(Integer)
+ (lower <= num).should == true
+ (num <= upper).should == true
+ end
end
- end
- it "generates a random value in given (float) range limits" do
- 64.times do
- num = SecureRandom.random_number 0.6..0.9
- num.should be_kind_of(Float)
- (0.6 <= num).should == true
- (num <= 0.9).should == true
+ it "generates a random value in given (float) range limits" do
+ 64.times do
+ num = SecureRandom.random_number 0.6..0.9
+ num.should be_kind_of(Float)
+ (0.6 <= num).should == true
+ (num <= 0.9).should == true
+ end
end
end
@@ -90,7 +88,7 @@ describe "SecureRandom.random_number" do
end
it "raises ArgumentError if the argument is non-numeric" do
- -> {
+ lambda {
SecureRandom.random_number(Object.new)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/set/add_spec.rb b/spec/ruby/library/set/add_spec.rb
index 68356cc111..a7d6fb8a56 100644
--- a/spec/ruby/library/set/add_spec.rb
+++ b/spec/ruby/library/set/add_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/add'
+require File.expand_path('../shared/add', __FILE__)
describe "Set#add" do
it_behaves_like :set_add, :add
diff --git a/spec/ruby/library/set/append_spec.rb b/spec/ruby/library/set/append_spec.rb
index 8b3498b779..b3097c0904 100644
--- a/spec/ruby/library/set/append_spec.rb
+++ b/spec/ruby/library/set/append_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/add'
+require File.expand_path('../shared/add', __FILE__)
describe "Set#<<" do
it_behaves_like :set_add, :<<
diff --git a/spec/ruby/library/set/case_compare_spec.rb b/spec/ruby/library/set/case_compare_spec.rb
index 193006dbda..f47e4e20c2 100644
--- a/spec/ruby/library/set/case_compare_spec.rb
+++ b/spec/ruby/library/set/case_compare_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
require 'set'
ruby_version_is "2.5" do
@@ -12,3 +12,4 @@ ruby_version_is "2.5" do
end
end
end
+
diff --git a/spec/ruby/library/set/case_equality_spec.rb b/spec/ruby/library/set/case_equality_spec.rb
index 875630612e..f256324d49 100644
--- a/spec/ruby/library/set/case_equality_spec.rb
+++ b/spec/ruby/library/set/case_equality_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
require 'set'
ruby_version_is "2.5" do
diff --git a/spec/ruby/library/set/classify_spec.rb b/spec/ruby/library/set/classify_spec.rb
index ec600c91d6..87e5b62f96 100644
--- a/spec/ruby/library/set/classify_spec.rb
+++ b/spec/ruby/library/set/classify_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#classify" do
diff --git a/spec/ruby/library/set/clear_spec.rb b/spec/ruby/library/set/clear_spec.rb
index 2b1c9c5b5a..b35ce4fec0 100644
--- a/spec/ruby/library/set/clear_spec.rb
+++ b/spec/ruby/library/set/clear_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#clear" do
diff --git a/spec/ruby/library/set/collect_spec.rb b/spec/ruby/library/set/collect_spec.rb
index f8813a9331..03c00c9794 100644
--- a/spec/ruby/library/set/collect_spec.rb
+++ b/spec/ruby/library/set/collect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/collect'
+require File.expand_path('../shared/collect', __FILE__)
describe "Set#collect!" do
it_behaves_like :set_collect_bang, :collect!
diff --git a/spec/ruby/library/set/compare_by_identity_spec.rb b/spec/ruby/library/set/compare_by_identity_spec.rb
index a6ad794ad3..437af9dd0b 100644
--- a/spec/ruby/library/set/compare_by_identity_spec.rb
+++ b/spec/ruby/library/set/compare_by_identity_spec.rb
@@ -1,143 +1,147 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
-describe "Set#compare_by_identity" do
- it "compares its members by identity" do
- a = "a"
- b1 = "b"
- b2 = "b"
+ruby_version_is '2.4' do
+ describe "Set#compare_by_identity" do
+ it "compares its members by identity" do
+ a = "a"
+ b1 = "b"
+ b2 = "b"
- set = Set.new
- set.compare_by_identity
- set.merge([a, a, b1, b2])
- set.to_a.sort.should == [a, b1, b2].sort
- end
-
- it "causes future comparisons on the receiver to be made by identity" do
- elt = [1]
- set = Set.new
- set << elt
- set.member?(elt.dup).should be_true
- set.compare_by_identity
- set.member?(elt.dup).should be_false
- end
-
- it "rehashes internally so that old members can be looked up" do
- set = Set.new
- (1..10).each { |k| set << k }
- o = Object.new
- def o.hash; 123; end
- set << o
- set.compare_by_identity
- set.member?(o).should be_true
- end
-
- it "returns self" do
- set = Set.new
- result = set.compare_by_identity
- result.should equal(set)
- end
-
- it "is idempotent and has no effect on an already compare_by_identity set" do
- set = Set.new.compare_by_identity
- set << :foo
- set.compare_by_identity.should equal(set)
- set.compare_by_identity?.should == true
- set.to_a.should == [:foo]
- end
-
- it "uses the semantics of BasicObject#equal? to determine members identity" do
- :a.equal?(:a).should == true
- Set.new.compare_by_identity.merge([:a, :a]).to_a.should == [:a]
-
- ary1 = [1]
- ary2 = [1]
- ary1.equal?(ary2).should == false
- Set.new.compare_by_identity.merge([ary1, ary2]).to_a.sort.should == [ary1, ary2].sort
- end
-
- it "uses #equal? semantics, but doesn't actually call #equal? to determine identity" do
- set = Set.new.compare_by_identity
- obj = mock("equal")
- obj.should_not_receive(:equal?)
- set << :foo
- set << obj
- set.to_a.should == [:foo, obj]
- end
-
- it "does not call #hash on members" do
- elt = mock("element")
- elt.should_not_receive(:hash)
- set = Set.new.compare_by_identity
- set << elt
- set.member?(elt).should be_true
- end
-
- it "regards #dup'd objects as having different identities" do
- a1 = "a"
- a2 = a1.dup
-
- set = Set.new.compare_by_identity
- set.merge([a1, a2])
- set.to_a.sort.should == [a1, a2].sort
- end
-
- it "regards #clone'd objects as having different identities" do
- a1 = "a"
- a2 = a1.clone
-
- set = Set.new.compare_by_identity
- set.merge([a1, a2])
- set.to_a.sort.should == [a1, a2].sort
- end
-
- it "raises a #{frozen_error_class} on frozen sets" do
- set = Set.new.freeze
- -> {
+ set = Set.new
set.compare_by_identity
- }.should raise_error(frozen_error_class, /frozen Hash/)
- end
-
- it "persists over #dups" do
- set = Set.new.compare_by_identity
- set << :a
- set_dup = set.dup
- set_dup.should == set
- set_dup << :a
- set_dup.to_a.should == [:a]
- end
-
- it "persists over #clones" do
- set = Set.new.compare_by_identity
- set << :a
- set_clone = set.clone
- set_clone.should == set
- set_clone << :a
- set_clone.to_a.should == [:a]
- end
-
- it "is not equal to set what does not compare by identity" do
- Set.new([1, 2]).should == Set.new([1, 2])
- Set.new([1, 2]).should_not == Set.new([1, 2]).compare_by_identity
+ set.merge([a, a, b1, b2])
+ set.to_a.sort.should == [a, b1, b2].sort
+ end
+
+ it "causes future comparisons on the receiver to be made by identity" do
+ elt = [1]
+ set = Set.new
+ set << elt
+ set.member?(elt.dup).should be_true
+ set.compare_by_identity
+ set.member?(elt.dup).should be_false
+ end
+
+ it "rehashes internally so that old members can be looked up" do
+ set = Set.new
+ (1..10).each { |k| set << k }
+ o = Object.new
+ def o.hash; 123; end
+ set << o
+ set.compare_by_identity
+ set.member?(o).should be_true
+ end
+
+ it "returns self" do
+ set = Set.new
+ result = set.compare_by_identity
+ result.should equal(set)
+ end
+
+ it "is idempotent and has no effect on an already compare_by_identity set" do
+ set = Set.new.compare_by_identity
+ set << :foo
+ set.compare_by_identity.should equal(set)
+ set.compare_by_identity?.should == true
+ set.to_a.should == [:foo]
+ end
+
+ it "uses the semantics of BasicObject#equal? to determine members identity" do
+ :a.equal?(:a).should == true
+ Set.new.compare_by_identity.merge([:a, :a]).to_a.should == [:a]
+
+ ary1 = [1]
+ ary2 = [1]
+ ary1.equal?(ary2).should == false
+ Set.new.compare_by_identity.merge([ary1, ary2]).to_a.sort.should == [ary1, ary2].sort
+ end
+
+ it "uses #equal? semantics, but doesn't actually call #equal? to determine identity" do
+ set = Set.new.compare_by_identity
+ obj = mock("equal")
+ obj.should_not_receive(:equal?)
+ set << :foo
+ set << obj
+ set.to_a.should == [:foo, obj]
+ end
+
+ it "does not call #hash on members" do
+ elt = mock("element")
+ elt.should_not_receive(:hash)
+ set = Set.new.compare_by_identity
+ set << elt
+ set.member?(elt).should be_true
+ end
+
+ it "regards #dup'd objects as having different identities" do
+ a1 = "a"
+ a2 = a1.dup
+
+ set = Set.new.compare_by_identity
+ set.merge([a1, a2])
+ set.to_a.sort.should == [a1, a2].sort
+ end
+
+ it "regards #clone'd objects as having different identities" do
+ a1 = "a"
+ a2 = a1.clone
+
+ set = Set.new.compare_by_identity
+ set.merge([a1, a2])
+ set.to_a.sort.should == [a1, a2].sort
+ end
+
+ it "raises a RuntimeError on frozen sets" do
+ set = Set.new.freeze
+ lambda {
+ set.compare_by_identity
+ }.should raise_error(RuntimeError, /frozen Hash/)
+ end
+
+ it "persists over #dups" do
+ set = Set.new.compare_by_identity
+ set << :a
+ set_dup = set.dup
+ set_dup.should == set
+ set_dup << :a
+ set_dup.to_a.should == [:a]
+ end
+
+ it "persists over #clones" do
+ set = Set.new.compare_by_identity
+ set << :a
+ set_clone = set.clone
+ set_clone.should == set
+ set_clone << :a
+ set_clone.to_a.should == [:a]
+ end
+
+ it "is not equal to set what does not compare by identity" do
+ Set.new([1, 2]).should == Set.new([1, 2])
+ Set.new([1, 2]).should_not == Set.new([1, 2]).compare_by_identity
+ end
end
end
-describe "Set#compare_by_identity?" do
- it "returns false by default" do
- Set.new.compare_by_identity?.should == false
- end
+ruby_version_is '2.4' do
+ describe "Set#compare_by_identity?" do
+ it "returns false by default" do
+ Set.new.compare_by_identity?.should == false
+ end
- it "returns true once #compare_by_identity has been invoked on self" do
- set = Set.new
- set.compare_by_identity
- set.compare_by_identity?.should == true
- end
+ it "returns true once #compare_by_identity has been invoked on self" do
+ set = Set.new
+ set.compare_by_identity
+ set.compare_by_identity?.should == true
+ end
- it "returns true when called multiple times on the same set" do
- set = Set.new
- set.compare_by_identity
- set.compare_by_identity?.should == true
- set.compare_by_identity?.should == true
- set.compare_by_identity?.should == true
+ it "returns true when called multiple times on the same set" do
+ set = Set.new
+ set.compare_by_identity
+ set.compare_by_identity?.should == true
+ set.compare_by_identity?.should == true
+ set.compare_by_identity?.should == true
+ end
end
end
diff --git a/spec/ruby/library/set/constructor_spec.rb b/spec/ruby/library/set/constructor_spec.rb
index bb84861514..75c7ba8bc8 100644
--- a/spec/ruby/library/set/constructor_spec.rb
+++ b/spec/ruby/library/set/constructor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set[]" do
diff --git a/spec/ruby/library/set/delete_if_spec.rb b/spec/ruby/library/set/delete_if_spec.rb
index 33caeeaab7..b6bd28a59f 100644
--- a/spec/ruby/library/set/delete_if_spec.rb
+++ b/spec/ruby/library/set/delete_if_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#delete_if" do
diff --git a/spec/ruby/library/set/delete_spec.rb b/spec/ruby/library/set/delete_spec.rb
index b12524384a..4f0326e37a 100644
--- a/spec/ruby/library/set/delete_spec.rb
+++ b/spec/ruby/library/set/delete_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#delete" do
diff --git a/spec/ruby/library/set/difference_spec.rb b/spec/ruby/library/set/difference_spec.rb
index 422f2ed3c7..416dffe802 100644
--- a/spec/ruby/library/set/difference_spec.rb
+++ b/spec/ruby/library/set/difference_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/difference'
+require File.expand_path('../shared/difference', __FILE__)
describe "Set#difference" do
it_behaves_like :set_difference, :difference
diff --git a/spec/ruby/library/set/disjoint_spec.rb b/spec/ruby/library/set/disjoint_spec.rb
deleted file mode 100644
index ea3b141455..0000000000
--- a/spec/ruby/library/set/disjoint_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
-require 'set'
-
-describe "Set#disjoint?" do
- it "returns false when two Sets have at least one element in common" do
- Set[1, 2].disjoint?(Set[2, 3]).should == false
- end
-
- it "returns true when two Sets have no element in common" do
- Set[1, 2].disjoint?(Set[3, 4]).should == true
- end
-
- context "when comparing to a Set-like object" do
- it "returns false when a Set has at least one element in common with a Set-like object" do
- Set[1, 2].disjoint?(SetSpecs::SetLike.new([2, 3])).should be_false
- end
-
- it "returns true when a Set has no element in common with a Set-like object" do
- Set[1, 2].disjoint?(SetSpecs::SetLike.new([3, 4])).should be_true
- end
- end
-end
diff --git a/spec/ruby/library/set/divide_spec.rb b/spec/ruby/library/set/divide_spec.rb
index fdd8cd9622..930c69885f 100644
--- a/spec/ruby/library/set/divide_spec.rb
+++ b/spec/ruby/library/set/divide_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#divide" do
diff --git a/spec/ruby/library/set/each_spec.rb b/spec/ruby/library/set/each_spec.rb
index 9bb5ead03a..867e94ff0b 100644
--- a/spec/ruby/library/set/each_spec.rb
+++ b/spec/ruby/library/set/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#each" do
diff --git a/spec/ruby/library/set/empty_spec.rb b/spec/ruby/library/set/empty_spec.rb
index 1789a664c7..044d58727c 100644
--- a/spec/ruby/library/set/empty_spec.rb
+++ b/spec/ruby/library/set/empty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#empty?" do
diff --git a/spec/ruby/library/set/enumerable/to_set_spec.rb b/spec/ruby/library/set/enumerable/to_set_spec.rb
index 0f5504fef2..41ca039de6 100644
--- a/spec/ruby/library/set/enumerable/to_set_spec.rb
+++ b/spec/ruby/library/set/enumerable/to_set_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
-describe "Enumerable#to_set" do
+describe "Emumerable#to_set" do
it "returns a new Set created from self" do
[1, 2, 3].to_set.should == Set[1, 2, 3]
{a: 1, b: 2}.to_set.should == Set[[:b, 2], [:a, 1]]
diff --git a/spec/ruby/library/set/eql_spec.rb b/spec/ruby/library/set/eql_spec.rb
index dd8e633775..ed62e20d7a 100644
--- a/spec/ruby/library/set/eql_spec.rb
+++ b/spec/ruby/library/set/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#eql?" do
diff --git a/spec/ruby/library/set/equal_value_spec.rb b/spec/ruby/library/set/equal_value_spec.rb
index f5b5f790c0..2e2c875407 100644
--- a/spec/ruby/library/set/equal_value_spec.rb
+++ b/spec/ruby/library/set/equal_value_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#==" do
@@ -24,10 +23,4 @@ describe "Set#==" do
set2 = Set[Set["c", "d"], Set["a", "b"], Set["e", "f"]]
set1.should == set2
end
-
- context "when comparing to a Set-like object" do
- it "returns true when a Set and a Set-like object contain the same elements" do
- Set[1, 2, 3].should == SetSpecs::SetLike.new([1, 2, 3])
- end
- end
end
diff --git a/spec/ruby/library/set/exclusion_spec.rb b/spec/ruby/library/set/exclusion_spec.rb
index 5bc4b5a2bf..d2923ba2d7 100644
--- a/spec/ruby/library/set/exclusion_spec.rb
+++ b/spec/ruby/library/set/exclusion_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#^" do
@@ -6,13 +6,13 @@ describe "Set#^" do
@set = Set[1, 2, 3, 4]
end
- it "returns a new Set containing elements that are not in both self and the passed Enumerable" do
+ it "returns a new Set containing elements that are not in both self and the passed Enumberable" do
(@set ^ Set[3, 4, 5]).should == Set[1, 2, 5]
(@set ^ [3, 4, 5]).should == Set[1, 2, 5]
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set ^ 3 }.should raise_error(ArgumentError)
- -> { @set ^ Object.new }.should raise_error(ArgumentError)
+ lambda { @set ^ 3 }.should raise_error(ArgumentError)
+ lambda { @set ^ Object.new }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/filter_spec.rb b/spec/ruby/library/set/filter_spec.rb
deleted file mode 100644
index a4dfe70d52..0000000000
--- a/spec/ruby/library/set/filter_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
-
-ruby_version_is "2.6" do
- describe "Set#filter!" do
- it_behaves_like :set_select_bang, :filter!
- end
-end
diff --git a/spec/ruby/library/set/fixtures/set_like.rb b/spec/ruby/library/set/fixtures/set_like.rb
deleted file mode 100644
index 46f61a451e..0000000000
--- a/spec/ruby/library/set/fixtures/set_like.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'set'
-
-module SetSpecs
- # This class is used to test the interaction of "Set-like" objects with real Sets
- #
- # These "Set-like" objects reply to is_a?(Set) with true and thus real Set objects are able to transparently
- # interoperate with them in a duck-typing manner.
- class SetLike
- include Enumerable
-
- def is_a?(klass)
- super || klass == ::Set
- end
-
- def initialize(entries)
- @entries = entries
- end
-
- def each(&block)
- @entries.each(&block)
- end
-
- def inspect
- "#<#{self.class}: {#{map(&:inspect).join(", ")}}>"
- end
-
- def size
- @entries.size
- end
- end
-end
diff --git a/spec/ruby/library/set/flatten_merge_spec.rb b/spec/ruby/library/set/flatten_merge_spec.rb
index f2c99a9481..bbddec7076 100644
--- a/spec/ruby/library/set/flatten_merge_spec.rb
+++ b/spec/ruby/library/set/flatten_merge_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#flatten_merge" do
@@ -18,6 +18,6 @@ describe "Set#flatten_merge" do
set2 = Set[5, 6, 7]
set2 << set2
- -> { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
+ lambda { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/flatten_spec.rb b/spec/ruby/library/set/flatten_spec.rb
index 4ac83ea825..2fa7f9f6e5 100644
--- a/spec/ruby/library/set/flatten_spec.rb
+++ b/spec/ruby/library/set/flatten_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#flatten" do
@@ -13,13 +12,7 @@ describe "Set#flatten" do
it "raises an ArgumentError when self is recursive" do
(set = Set[]) << set
- -> { set.flatten }.should raise_error(ArgumentError)
- end
-
- context "when Set contains a Set-like object" do
- it "returns a copy of self with each included Set-like object flattened" do
- Set[SetSpecs::SetLike.new([1])].flatten.should == Set[1]
- end
+ lambda { set.flatten }.should raise_error(ArgumentError)
end
end
@@ -42,12 +35,6 @@ describe "Set#flatten!" do
it "raises an ArgumentError when self is recursive" do
(set = Set[]) << set
- -> { set.flatten! }.should raise_error(ArgumentError)
- end
-
- context "when Set contains a Set-like object" do
- it "flattens self, including Set-like objects" do
- Set[SetSpecs::SetLike.new([1])].flatten!.should == Set[1]
- end
+ lambda { set.flatten! }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/hash_spec.rb b/spec/ruby/library/set/hash_spec.rb
index 47c43c05f1..ea39105937 100644
--- a/spec/ruby/library/set/hash_spec.rb
+++ b/spec/ruby/library/set/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#hash" do
diff --git a/spec/ruby/library/set/include_spec.rb b/spec/ruby/library/set/include_spec.rb
index 68532d9a04..693b8b997f 100644
--- a/spec/ruby/library/set/include_spec.rb
+++ b/spec/ruby/library/set/include_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
require 'set'
describe "Set#include?" do
diff --git a/spec/ruby/library/set/initialize_spec.rb b/spec/ruby/library/set/initialize_spec.rb
index 887cae45fc..e14cbaacc2 100644
--- a/spec/ruby/library/set/initialize_spec.rb
+++ b/spec/ruby/library/set/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#initialize" do
@@ -14,14 +14,6 @@ describe "Set#initialize" do
s.should include(3)
end
- it "should initialize with empty array and set" do
- s = Set.new([])
- s.size.should eql(0)
-
- s = Set.new({})
- s.size.should eql(0)
- end
-
it "preprocesses all elements by a passed block before adding to self" do
s = Set.new([1, 2, 3]) { |x| x * x }
s.size.should eql(3)
@@ -29,20 +21,4 @@ describe "Set#initialize" do
s.should include(4)
s.should include(9)
end
-
- it "should initialize with empty array and block" do
- s = Set.new([]) { |x| x * x }
- s.size.should eql(0)
- end
-
- it "should initialize with empty set and block" do
- s = Set.new(Set.new) { |x| x * x }
- s.size.should eql(0)
- end
-
- it "should initialize with just block" do
- s = Set.new { |x| x * x }
- s.size.should eql(0)
- s.should eql(Set.new)
- end
end
diff --git a/spec/ruby/library/set/inspect_spec.rb b/spec/ruby/library/set/inspect_spec.rb
index 4060c63b95..ef91b11645 100644
--- a/spec/ruby/library/set/inspect_spec.rb
+++ b/spec/ruby/library/set/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/inspect'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/inspect', __FILE__)
require 'set'
describe "Set#inspect" do
diff --git a/spec/ruby/library/set/intersect_spec.rb b/spec/ruby/library/set/intersect_spec.rb
deleted file mode 100644
index e60f06db94..0000000000
--- a/spec/ruby/library/set/intersect_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
-require 'set'
-
-describe "Set#intersect?" do
- it "returns true when two Sets have at least one element in common" do
- Set[1, 2].intersect?(Set[2, 3]).should == true
- end
-
- it "returns false when two Sets have no element in common" do
- Set[1, 2].intersect?(Set[3, 4]).should == false
- end
-
- context "when comparing to a Set-like object" do
- it "returns true when a Set has at least one element in common with a Set-like object" do
- Set[1, 2].intersect?(SetSpecs::SetLike.new([2, 3])).should be_true
- end
-
- it "returns false when a Set has no element in common with a Set-like object" do
- Set[1, 2].intersect?(SetSpecs::SetLike.new([3, 4])).should be_false
- end
- end
-end
diff --git a/spec/ruby/library/set/intersection_spec.rb b/spec/ruby/library/set/intersection_spec.rb
index 792c2d8f07..c5adef5fc4 100644
--- a/spec/ruby/library/set/intersection_spec.rb
+++ b/spec/ruby/library/set/intersection_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/intersection'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/intersection', __FILE__)
require 'set'
describe "Set#intersection" do
diff --git a/spec/ruby/library/set/keep_if_spec.rb b/spec/ruby/library/set/keep_if_spec.rb
index 7edc80769f..45f2cbf07a 100644
--- a/spec/ruby/library/set/keep_if_spec.rb
+++ b/spec/ruby/library/set/keep_if_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#keep_if" do
diff --git a/spec/ruby/library/set/length_spec.rb b/spec/ruby/library/set/length_spec.rb
index fef63d25a7..274abcde83 100644
--- a/spec/ruby/library/set/length_spec.rb
+++ b/spec/ruby/library/set/length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'set'
describe "Set#length" do
diff --git a/spec/ruby/library/set/map_spec.rb b/spec/ruby/library/set/map_spec.rb
index e60e98b179..8610982ba9 100644
--- a/spec/ruby/library/set/map_spec.rb
+++ b/spec/ruby/library/set/map_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/collect'
+require File.expand_path('../shared/collect', __FILE__)
describe "Set#map!" do
it_behaves_like :set_collect_bang, :map!
diff --git a/spec/ruby/library/set/member_spec.rb b/spec/ruby/library/set/member_spec.rb
index 5b56a38ab9..1a807c061b 100644
--- a/spec/ruby/library/set/member_spec.rb
+++ b/spec/ruby/library/set/member_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
require 'set'
describe "Set#member?" do
diff --git a/spec/ruby/library/set/merge_spec.rb b/spec/ruby/library/set/merge_spec.rb
index a8e3ffc870..ecee51b951 100644
--- a/spec/ruby/library/set/merge_spec.rb
+++ b/spec/ruby/library/set/merge_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#merge" do
@@ -13,7 +13,7 @@ describe "Set#merge" do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { Set[1, 2].merge(1) }.should raise_error(ArgumentError)
- -> { Set[1, 2].merge(Object.new) }.should raise_error(ArgumentError)
+ lambda { Set[1, 2].merge(1) }.should raise_error(ArgumentError)
+ lambda { Set[1, 2].merge(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/minus_spec.rb b/spec/ruby/library/set/minus_spec.rb
index 3fe0b6a2cc..3b14d6649d 100644
--- a/spec/ruby/library/set/minus_spec.rb
+++ b/spec/ruby/library/set/minus_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/difference'
+require File.expand_path('../shared/difference', __FILE__)
describe "Set#-" do
it_behaves_like :set_difference, :-
diff --git a/spec/ruby/library/set/plus_spec.rb b/spec/ruby/library/set/plus_spec.rb
index 3e70d3269d..38b78b6330 100644
--- a/spec/ruby/library/set/plus_spec.rb
+++ b/spec/ruby/library/set/plus_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/union'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/union', __FILE__)
require 'set'
describe "Set#+" do
diff --git a/spec/ruby/library/set/pretty_print_cycle_spec.rb b/spec/ruby/library/set/pretty_print_cycle_spec.rb
index 4f440353e5..a7eaab337b 100644
--- a/spec/ruby/library/set/pretty_print_cycle_spec.rb
+++ b/spec/ruby/library/set/pretty_print_cycle_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#pretty_print_cycle" do
diff --git a/spec/ruby/library/set/pretty_print_spec.rb b/spec/ruby/library/set/pretty_print_spec.rb
index f2392e6968..60f3ba7d3d 100644
--- a/spec/ruby/library/set/pretty_print_spec.rb
+++ b/spec/ruby/library/set/pretty_print_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#pretty_print" do
diff --git a/spec/ruby/library/set/proper_subset_spec.rb b/spec/ruby/library/set/proper_subset_spec.rb
index 1f496a6199..1a1fa13c3c 100644
--- a/spec/ruby/library/set/proper_subset_spec.rb
+++ b/spec/ruby/library/set/proper_subset_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#proper_subset?" do
@@ -27,15 +26,9 @@ describe "Set#proper_subset?" do
end
it "raises an ArgumentError when passed a non-Set" do
- -> { Set[].proper_subset?([]) }.should raise_error(ArgumentError)
- -> { Set[].proper_subset?(1) }.should raise_error(ArgumentError)
- -> { Set[].proper_subset?("test") }.should raise_error(ArgumentError)
- -> { Set[].proper_subset?(Object.new) }.should raise_error(ArgumentError)
- end
-
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a proper subset of" do
- Set[1, 2, 3].proper_subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
- end
+ lambda { Set[].proper_subset?([]) }.should raise_error(ArgumentError)
+ lambda { Set[].proper_subset?(1) }.should raise_error(ArgumentError)
+ lambda { Set[].proper_subset?("test") }.should raise_error(ArgumentError)
+ lambda { Set[].proper_subset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/proper_superset_spec.rb b/spec/ruby/library/set/proper_superset_spec.rb
index a386c8c097..61c7984a6b 100644
--- a/spec/ruby/library/set/proper_superset_spec.rb
+++ b/spec/ruby/library/set/proper_superset_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#proper_superset?" do
@@ -27,15 +26,9 @@ describe "Set#proper_superset?" do
end
it "raises an ArgumentError when passed a non-Set" do
- -> { Set[].proper_superset?([]) }.should raise_error(ArgumentError)
- -> { Set[].proper_superset?(1) }.should raise_error(ArgumentError)
- -> { Set[].proper_superset?("test") }.should raise_error(ArgumentError)
- -> { Set[].proper_superset?(Object.new) }.should raise_error(ArgumentError)
- end
-
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a proper superset of" do
- Set[1, 2, 3, 4].proper_superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true
- end
+ lambda { Set[].proper_superset?([]) }.should raise_error(ArgumentError)
+ lambda { Set[].proper_superset?(1) }.should raise_error(ArgumentError)
+ lambda { Set[].proper_superset?("test") }.should raise_error(ArgumentError)
+ lambda { Set[].proper_superset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/reject_spec.rb b/spec/ruby/library/set/reject_spec.rb
index 9131f960ad..32d3a92801 100644
--- a/spec/ruby/library/set/reject_spec.rb
+++ b/spec/ruby/library/set/reject_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#reject!" do
diff --git a/spec/ruby/library/set/replace_spec.rb b/spec/ruby/library/set/replace_spec.rb
index 7511066c9c..6f0c45b7ed 100644
--- a/spec/ruby/library/set/replace_spec.rb
+++ b/spec/ruby/library/set/replace_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#replace" do
diff --git a/spec/ruby/library/set/select_spec.rb b/spec/ruby/library/set/select_spec.rb
index b458ffacaa..34274a7c46 100644
--- a/spec/ruby/library/set/select_spec.rb
+++ b/spec/ruby/library/set/select_spec.rb
@@ -1,6 +1,42 @@
-require_relative '../../spec_helper'
-require_relative 'shared/select'
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'set'
describe "Set#select!" do
- it_behaves_like :set_select_bang, :select!
+ before :each do
+ @set = Set["one", "two", "three"]
+ end
+
+ it "yields every element of self" do
+ ret = []
+ @set.select! { |x| ret << x }
+ ret.sort.should == ["one", "two", "three"].sort
+ end
+
+ it "keeps every element from self for which the passed block returns true" do
+ @set.select! { |x| x.size != 3 }
+ @set.size.should eql(1)
+
+ @set.should_not include("one")
+ @set.should_not include("two")
+ @set.should include("three")
+ end
+
+ it "returns self when self was modified" do
+ @set.select! { false }.should equal(@set)
+ end
+
+ it "returns nil when self was not modified" do
+ @set.select! { true }.should be_nil
+ end
+
+ it "returns an Enumerator when passed no block" do
+ enum = @set.select!
+ enum.should be_an_instance_of(Enumerator)
+
+ enum.each { |x| x.size != 3 }
+
+ @set.should_not include("one")
+ @set.should_not include("two")
+ @set.should include("three")
+ end
end
diff --git a/spec/ruby/library/set/shared/difference.rb b/spec/ruby/library/set/shared/difference.rb
index f88987ed2a..52807709c3 100644
--- a/spec/ruby/library/set/shared/difference.rb
+++ b/spec/ruby/library/set/shared/difference.rb
@@ -9,7 +9,7 @@ describe :set_difference, shared: true do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, 1) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/shared/intersection.rb b/spec/ruby/library/set/shared/intersection.rb
index 5ae4199c94..ed0db7457d 100644
--- a/spec/ruby/library/set/shared/intersection.rb
+++ b/spec/ruby/library/set/shared/intersection.rb
@@ -9,7 +9,7 @@ describe :set_intersection, shared: true do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, 1) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/shared/select.rb b/spec/ruby/library/set/shared/select.rb
deleted file mode 100644
index 2108d398b4..0000000000
--- a/spec/ruby/library/set/shared/select.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require_relative '../../../spec_helper'
-require 'set'
-
-describe :set_select_bang, shared: true do
- before :each do
- @set = Set["one", "two", "three"]
- end
-
- it "yields every element of self" do
- ret = []
- @set.send(@method) { |x| ret << x }
- ret.sort.should == ["one", "two", "three"].sort
- end
-
- it "keeps every element from self for which the passed block returns true" do
- @set.send(@method) { |x| x.size != 3 }
- @set.size.should eql(1)
-
- @set.should_not include("one")
- @set.should_not include("two")
- @set.should include("three")
- end
-
- it "returns self when self was modified" do
- @set.send(@method) { false }.should equal(@set)
- end
-
- it "returns nil when self was not modified" do
- @set.send(@method) { true }.should be_nil
- end
-
- it "returns an Enumerator when passed no block" do
- enum = @set.send(@method)
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |x| x.size != 3 }
-
- @set.should_not include("one")
- @set.should_not include("two")
- @set.should include("three")
- end
-end
diff --git a/spec/ruby/library/set/shared/union.rb b/spec/ruby/library/set/shared/union.rb
index 314f0e852d..81920f5687 100644
--- a/spec/ruby/library/set/shared/union.rb
+++ b/spec/ruby/library/set/shared/union.rb
@@ -9,7 +9,7 @@ describe :set_union, shared: true do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, 1) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/size_spec.rb b/spec/ruby/library/set/size_spec.rb
index 3c8cb38517..f33740c5cd 100644
--- a/spec/ruby/library/set/size_spec.rb
+++ b/spec/ruby/library/set/size_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'set'
describe "Set#size" do
diff --git a/spec/ruby/library/set/sortedset/add_spec.rb b/spec/ruby/library/set/sortedset/add_spec.rb
index 5f8bde02f5..df291561a8 100644
--- a/spec/ruby/library/set/sortedset/add_spec.rb
+++ b/spec/ruby/library/set/sortedset/add_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/add'
+require File.expand_path('../shared/add', __FILE__)
describe "SortedSet#add" do
it_behaves_like :sorted_set_add, :add
@@ -8,13 +8,13 @@ describe "SortedSet#add" do
it "takes only values which responds <=>" do
obj = mock('no_comparison_operator')
obj.stub!(:respond_to?).with(:<=>).and_return(false)
- -> { SortedSet["hello"].add(obj) }.should raise_error(ArgumentError)
+ lambda { SortedSet["hello"].add(obj) }.should raise_error(ArgumentError)
end
it "raises on incompatible <=> comparison" do
# Use #to_a here as elements are sorted only when needed.
# Therefore the <=> incompatibility is only noticed on sorting.
- -> { SortedSet['1', '2'].add(3).to_a }.should raise_error(ArgumentError)
+ lambda { SortedSet['1', '2'].add(3).to_a }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/append_spec.rb b/spec/ruby/library/set/sortedset/append_spec.rb
index ebcceba962..62933f3e42 100644
--- a/spec/ruby/library/set/sortedset/append_spec.rb
+++ b/spec/ruby/library/set/sortedset/append_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/add'
+require File.expand_path('../shared/add', __FILE__)
describe "SortedSet#<<" do
it_behaves_like :sorted_set_add, :<<
diff --git a/spec/ruby/library/set/sortedset/case_equality_spec.rb b/spec/ruby/library/set/sortedset/case_equality_spec.rb
index 5627917677..cea52dedbd 100644
--- a/spec/ruby/library/set/sortedset/case_equality_spec.rb
+++ b/spec/ruby/library/set/sortedset/case_equality_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
require 'set'
ruby_version_is "2.5" do
diff --git a/spec/ruby/library/set/sortedset/classify_spec.rb b/spec/ruby/library/set/sortedset/classify_spec.rb
index 62b26d5d28..1e8c814699 100644
--- a/spec/ruby/library/set/sortedset/classify_spec.rb
+++ b/spec/ruby/library/set/sortedset/classify_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#classify" do
diff --git a/spec/ruby/library/set/sortedset/clear_spec.rb b/spec/ruby/library/set/sortedset/clear_spec.rb
index 11b5db2095..3a3277dd8a 100644
--- a/spec/ruby/library/set/sortedset/clear_spec.rb
+++ b/spec/ruby/library/set/sortedset/clear_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#clear" do
diff --git a/spec/ruby/library/set/sortedset/collect_spec.rb b/spec/ruby/library/set/sortedset/collect_spec.rb
index 21ead4fe55..18274e6353 100644
--- a/spec/ruby/library/set/sortedset/collect_spec.rb
+++ b/spec/ruby/library/set/sortedset/collect_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/collect'
+require File.expand_path('../shared/collect', __FILE__)
describe "SortedSet#collect!" do
it_behaves_like :sorted_set_collect_bang, :collect!
diff --git a/spec/ruby/library/set/sortedset/constructor_spec.rb b/spec/ruby/library/set/sortedset/constructor_spec.rb
index 953144dbdb..45b6749e27 100644
--- a/spec/ruby/library/set/sortedset/constructor_spec.rb
+++ b/spec/ruby/library/set/sortedset/constructor_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet[]" do
diff --git a/spec/ruby/library/set/sortedset/delete_if_spec.rb b/spec/ruby/library/set/sortedset/delete_if_spec.rb
index 1ff689376a..c809ff75f0 100644
--- a/spec/ruby/library/set/sortedset/delete_if_spec.rb
+++ b/spec/ruby/library/set/sortedset/delete_if_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#delete_if" do
diff --git a/spec/ruby/library/set/sortedset/delete_spec.rb b/spec/ruby/library/set/sortedset/delete_spec.rb
index 71583c7f13..7123f79bcf 100644
--- a/spec/ruby/library/set/sortedset/delete_spec.rb
+++ b/spec/ruby/library/set/sortedset/delete_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#delete" do
diff --git a/spec/ruby/library/set/sortedset/difference_spec.rb b/spec/ruby/library/set/sortedset/difference_spec.rb
index c3d679aff8..bc3650c55c 100644
--- a/spec/ruby/library/set/sortedset/difference_spec.rb
+++ b/spec/ruby/library/set/sortedset/difference_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/difference'
+require File.expand_path('../shared/difference', __FILE__)
describe "SortedSet#difference" do
it_behaves_like :sorted_set_difference, :difference
diff --git a/spec/ruby/library/set/sortedset/divide_spec.rb b/spec/ruby/library/set/sortedset/divide_spec.rb
index 4b2135a8c9..adb152b7e6 100644
--- a/spec/ruby/library/set/sortedset/divide_spec.rb
+++ b/spec/ruby/library/set/sortedset/divide_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#divide" do
diff --git a/spec/ruby/library/set/sortedset/each_spec.rb b/spec/ruby/library/set/sortedset/each_spec.rb
index bcf0d74d1f..c715c403b2 100644
--- a/spec/ruby/library/set/sortedset/each_spec.rb
+++ b/spec/ruby/library/set/sortedset/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#each" do
diff --git a/spec/ruby/library/set/sortedset/empty_spec.rb b/spec/ruby/library/set/sortedset/empty_spec.rb
index deb3b567fb..50d046e4c0 100644
--- a/spec/ruby/library/set/sortedset/empty_spec.rb
+++ b/spec/ruby/library/set/sortedset/empty_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#empty?" do
diff --git a/spec/ruby/library/set/sortedset/eql_spec.rb b/spec/ruby/library/set/sortedset/eql_spec.rb
index b22858a362..e7b3e7b624 100644
--- a/spec/ruby/library/set/sortedset/eql_spec.rb
+++ b/spec/ruby/library/set/sortedset/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#eql?" do
diff --git a/spec/ruby/library/set/sortedset/equal_value_spec.rb b/spec/ruby/library/set/sortedset/equal_value_spec.rb
index cb1b7c9443..e358372aa4 100644
--- a/spec/ruby/library/set/sortedset/equal_value_spec.rb
+++ b/spec/ruby/library/set/sortedset/equal_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#==" do
diff --git a/spec/ruby/library/set/sortedset/exclusion_spec.rb b/spec/ruby/library/set/sortedset/exclusion_spec.rb
index d0f1ab95cb..193dbb7725 100644
--- a/spec/ruby/library/set/sortedset/exclusion_spec.rb
+++ b/spec/ruby/library/set/sortedset/exclusion_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#^" do
@@ -6,13 +6,13 @@ describe "SortedSet#^" do
@set = SortedSet[1, 2, 3, 4]
end
- it "returns a new SortedSet containing elements that are not in both self and the passed Enumerable" do
+ it "returns a new SortedSet containing elements that are not in both self and the passed Enumberable" do
(@set ^ SortedSet[3, 4, 5]).should == SortedSet[1, 2, 5]
(@set ^ [3, 4, 5]).should == SortedSet[1, 2, 5]
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set ^ 3 }.should raise_error(ArgumentError)
- -> { @set ^ Object.new }.should raise_error(ArgumentError)
+ lambda { @set ^ 3 }.should raise_error(ArgumentError)
+ lambda { @set ^ Object.new }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/filter_spec.rb b/spec/ruby/library/set/sortedset/filter_spec.rb
deleted file mode 100644
index cfaa8b2729..0000000000
--- a/spec/ruby/library/set/sortedset/filter_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/select'
-require 'set'
-
-ruby_version_is "2.6" do
- describe "SortedSet#filter!" do
- it_behaves_like :sorted_set_select_bang, :filter!
- end
-end
diff --git a/spec/ruby/library/set/sortedset/flatten_merge_spec.rb b/spec/ruby/library/set/sortedset/flatten_merge_spec.rb
index 9a8ed13f00..2a2505a58b 100644
--- a/spec/ruby/library/set/sortedset/flatten_merge_spec.rb
+++ b/spec/ruby/library/set/sortedset/flatten_merge_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#flatten_merge" do
diff --git a/spec/ruby/library/set/sortedset/flatten_spec.rb b/spec/ruby/library/set/sortedset/flatten_spec.rb
index ca4e4637e6..80d064b846 100644
--- a/spec/ruby/library/set/sortedset/flatten_spec.rb
+++ b/spec/ruby/library/set/sortedset/flatten_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
# Note: Flatten make little sens on sorted sets, because SortedSets are not (by default)
diff --git a/spec/ruby/library/set/sortedset/hash_spec.rb b/spec/ruby/library/set/sortedset/hash_spec.rb
index 7833c68a10..176cb7e8dc 100644
--- a/spec/ruby/library/set/sortedset/hash_spec.rb
+++ b/spec/ruby/library/set/sortedset/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#hash" do
diff --git a/spec/ruby/library/set/sortedset/include_spec.rb b/spec/ruby/library/set/sortedset/include_spec.rb
index 030a9e146a..bb8ceda708 100644
--- a/spec/ruby/library/set/sortedset/include_spec.rb
+++ b/spec/ruby/library/set/sortedset/include_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
require 'set'
describe "SortedSet#include?" do
diff --git a/spec/ruby/library/set/sortedset/initialize_spec.rb b/spec/ruby/library/set/sortedset/initialize_spec.rb
index 1238f4efc4..77ee23e851 100644
--- a/spec/ruby/library/set/sortedset/initialize_spec.rb
+++ b/spec/ruby/library/set/sortedset/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#initialize" do
@@ -25,6 +25,6 @@ describe "SortedSet#initialize" do
it "raises on incompatible <=> comparison" do
# Use #to_a here as elements are sorted only when needed.
# Therefore the <=> incompatibility is only noticed on sorting.
- -> { SortedSet.new(['00', nil]).to_a }.should raise_error(ArgumentError)
+ lambda { SortedSet.new(['00', nil]).to_a }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/inspect_spec.rb b/spec/ruby/library/set/sortedset/inspect_spec.rb
index 7103bee3f5..64b3f3d882 100644
--- a/spec/ruby/library/set/sortedset/inspect_spec.rb
+++ b/spec/ruby/library/set/sortedset/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#inspect" do
diff --git a/spec/ruby/library/set/sortedset/intersection_spec.rb b/spec/ruby/library/set/sortedset/intersection_spec.rb
index 6ff9c80ce1..d3f5b49ceb 100644
--- a/spec/ruby/library/set/sortedset/intersection_spec.rb
+++ b/spec/ruby/library/set/sortedset/intersection_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/intersection'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/intersection', __FILE__)
require 'set'
describe "SortedSet#intersection" do
diff --git a/spec/ruby/library/set/sortedset/keep_if_spec.rb b/spec/ruby/library/set/sortedset/keep_if_spec.rb
index 2235eb3766..7a117fbc87 100644
--- a/spec/ruby/library/set/sortedset/keep_if_spec.rb
+++ b/spec/ruby/library/set/sortedset/keep_if_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#keep_if" do
diff --git a/spec/ruby/library/set/sortedset/length_spec.rb b/spec/ruby/library/set/sortedset/length_spec.rb
index 5f138dd6f7..d829b3e08e 100644
--- a/spec/ruby/library/set/sortedset/length_spec.rb
+++ b/spec/ruby/library/set/sortedset/length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'set'
describe "SortedSet#length" do
diff --git a/spec/ruby/library/set/sortedset/map_spec.rb b/spec/ruby/library/set/sortedset/map_spec.rb
index 1d7b5954e5..1f0828f347 100644
--- a/spec/ruby/library/set/sortedset/map_spec.rb
+++ b/spec/ruby/library/set/sortedset/map_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/collect'
+require File.expand_path('../shared/collect', __FILE__)
describe "SortedSet#map!" do
it_behaves_like :sorted_set_collect_bang, :map!
diff --git a/spec/ruby/library/set/sortedset/member_spec.rb b/spec/ruby/library/set/sortedset/member_spec.rb
index d6005557ab..d64e318b83 100644
--- a/spec/ruby/library/set/sortedset/member_spec.rb
+++ b/spec/ruby/library/set/sortedset/member_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/include'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/include', __FILE__)
require 'set'
describe "SortedSet#member?" do
diff --git a/spec/ruby/library/set/sortedset/merge_spec.rb b/spec/ruby/library/set/sortedset/merge_spec.rb
index 31570ad4db..c422fe9513 100644
--- a/spec/ruby/library/set/sortedset/merge_spec.rb
+++ b/spec/ruby/library/set/sortedset/merge_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#merge" do
@@ -13,7 +13,7 @@ describe "SortedSet#merge" do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { SortedSet[1, 2].merge(1) }.should raise_error(ArgumentError)
- -> { SortedSet[1, 2].merge(Object.new) }.should raise_error(ArgumentError)
+ lambda { SortedSet[1, 2].merge(1) }.should raise_error(ArgumentError)
+ lambda { SortedSet[1, 2].merge(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/minus_spec.rb b/spec/ruby/library/set/sortedset/minus_spec.rb
index ffb8ee85d1..1f56d57037 100644
--- a/spec/ruby/library/set/sortedset/minus_spec.rb
+++ b/spec/ruby/library/set/sortedset/minus_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
-require_relative 'shared/difference'
+require File.expand_path('../shared/difference', __FILE__)
describe "SortedSet#-" do
it_behaves_like :sorted_set_difference, :-
diff --git a/spec/ruby/library/set/sortedset/plus_spec.rb b/spec/ruby/library/set/sortedset/plus_spec.rb
index 355c775d7e..af9bdf82fa 100644
--- a/spec/ruby/library/set/sortedset/plus_spec.rb
+++ b/spec/ruby/library/set/sortedset/plus_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/union'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/union', __FILE__)
require 'set'
describe "SortedSet#+" do
diff --git a/spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb b/spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb
index fe15f1bf7d..6e79245e18 100644
--- a/spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb
+++ b/spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#pretty_print_cycle" do
diff --git a/spec/ruby/library/set/sortedset/pretty_print_spec.rb b/spec/ruby/library/set/sortedset/pretty_print_spec.rb
index 601ff4d182..5317357b8f 100644
--- a/spec/ruby/library/set/sortedset/pretty_print_spec.rb
+++ b/spec/ruby/library/set/sortedset/pretty_print_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#pretty_print" do
diff --git a/spec/ruby/library/set/sortedset/proper_subset_spec.rb b/spec/ruby/library/set/sortedset/proper_subset_spec.rb
index 818173a7f9..7e94774c1f 100644
--- a/spec/ruby/library/set/sortedset/proper_subset_spec.rb
+++ b/spec/ruby/library/set/sortedset/proper_subset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#proper_subset?" do
@@ -25,9 +25,9 @@ describe "SortedSet#proper_subset?" do
end
it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].proper_subset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_subset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_subset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_subset?(Object.new) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_subset?([]) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_subset?(1) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_subset?("test") }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_subset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/proper_superset_spec.rb b/spec/ruby/library/set/sortedset/proper_superset_spec.rb
index 2699290f0e..ccfa37988d 100644
--- a/spec/ruby/library/set/sortedset/proper_superset_spec.rb
+++ b/spec/ruby/library/set/sortedset/proper_superset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#proper_superset?" do
@@ -25,9 +25,9 @@ describe "SortedSet#proper_superset?" do
end
it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].proper_superset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_superset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_superset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_superset?(Object.new) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_superset?([]) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_superset?(1) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_superset?("test") }.should raise_error(ArgumentError)
+ lambda { SortedSet[].proper_superset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/reject_spec.rb b/spec/ruby/library/set/sortedset/reject_spec.rb
index da2a76e7a7..e357d55052 100644
--- a/spec/ruby/library/set/sortedset/reject_spec.rb
+++ b/spec/ruby/library/set/sortedset/reject_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#reject!" do
diff --git a/spec/ruby/library/set/sortedset/replace_spec.rb b/spec/ruby/library/set/sortedset/replace_spec.rb
index 2a7fa73efb..a5bf333e87 100644
--- a/spec/ruby/library/set/sortedset/replace_spec.rb
+++ b/spec/ruby/library/set/sortedset/replace_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#replace" do
diff --git a/spec/ruby/library/set/sortedset/select_spec.rb b/spec/ruby/library/set/sortedset/select_spec.rb
index 68326cd02c..3ca748350a 100644
--- a/spec/ruby/library/set/sortedset/select_spec.rb
+++ b/spec/ruby/library/set/sortedset/select_spec.rb
@@ -1,7 +1,35 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/select'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#select!" do
- it_behaves_like :sorted_set_select_bang, :select!
+ before :each do
+ @set = SortedSet["one", "two", "three"]
+ end
+
+ it "yields each Object in self in sorted order" do
+ res = []
+ @set.select! { |x| res << x }
+ res.should == ["one", "two", "three"].sort
+ end
+
+ it "keeps every element from self for which the passed block returns true" do
+ @set.select! { |x| x.size != 3 }
+ @set.to_a.should == ["three"]
+ end
+
+ it "returns self when self was modified" do
+ @set.select! { false }.should equal(@set)
+ end
+
+ it "returns nil when self was not modified" do
+ @set.select! { true }.should be_nil
+ end
+
+ it "returns an Enumerator when passed no block" do
+ enum = @set.select!
+ enum.should be_an_instance_of(Enumerator)
+
+ enum.each { |x| x.size != 3 }
+ @set.to_a.should == ["three"]
+ end
end
diff --git a/spec/ruby/library/set/sortedset/shared/difference.rb b/spec/ruby/library/set/sortedset/shared/difference.rb
index 688e23a7a7..cf50ff0eb2 100644
--- a/spec/ruby/library/set/sortedset/shared/difference.rb
+++ b/spec/ruby/library/set/sortedset/shared/difference.rb
@@ -9,7 +9,7 @@ describe :sorted_set_difference, shared: true do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, 1) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/shared/intersection.rb b/spec/ruby/library/set/sortedset/shared/intersection.rb
index 045716ad05..d3cfa96656 100644
--- a/spec/ruby/library/set/sortedset/shared/intersection.rb
+++ b/spec/ruby/library/set/sortedset/shared/intersection.rb
@@ -9,7 +9,7 @@ describe :sorted_set_intersection, shared: true do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, 1) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/shared/select.rb b/spec/ruby/library/set/sortedset/shared/select.rb
deleted file mode 100644
index e13311eda5..0000000000
--- a/spec/ruby/library/set/sortedset/shared/select.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../../../../spec_helper'
-require 'set'
-
-describe :sorted_set_select_bang, shared: true do
- before :each do
- @set = SortedSet["one", "two", "three"]
- end
-
- it "yields each Object in self in sorted order" do
- res = []
- @set.send(@method) { |x| res << x }
- res.should == ["one", "two", "three"].sort
- end
-
- it "keeps every element from self for which the passed block returns true" do
- @set.send(@method) { |x| x.size != 3 }
- @set.to_a.should == ["three"]
- end
-
- it "returns self when self was modified" do
- @set.send(@method) { false }.should equal(@set)
- end
-
- it "returns nil when self was not modified" do
- @set.send(@method) { true }.should be_nil
- end
-
- it "returns an Enumerator when passed no block" do
- enum = @set.send(@method)
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |x| x.size != 3 }
- @set.to_a.should == ["three"]
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/union.rb b/spec/ruby/library/set/sortedset/shared/union.rb
index 9015bdc8e3..4ff07ef5cc 100644
--- a/spec/ruby/library/set/sortedset/shared/union.rb
+++ b/spec/ruby/library/set/sortedset/shared/union.rb
@@ -9,7 +9,7 @@ describe :sorted_set_union, shared: true do
end
it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, 1) }.should raise_error(ArgumentError)
+ lambda { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/size_spec.rb b/spec/ruby/library/set/sortedset/size_spec.rb
index 13e5085b0c..dbcdc3ded3 100644
--- a/spec/ruby/library/set/sortedset/size_spec.rb
+++ b/spec/ruby/library/set/sortedset/size_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'set'
describe "SortedSet#size" do
diff --git a/spec/ruby/library/set/sortedset/subset_spec.rb b/spec/ruby/library/set/sortedset/subset_spec.rb
index 7768692df6..81f938317c 100644
--- a/spec/ruby/library/set/sortedset/subset_spec.rb
+++ b/spec/ruby/library/set/sortedset/subset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#subset?" do
@@ -25,9 +25,9 @@ describe "SortedSet#subset?" do
end
it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].subset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].subset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].subset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].subset?(Object.new) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].subset?([]) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].subset?(1) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].subset?("test") }.should raise_error(ArgumentError)
+ lambda { SortedSet[].subset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/subtract_spec.rb b/spec/ruby/library/set/sortedset/subtract_spec.rb
index 64d66c3688..207748cfb9 100644
--- a/spec/ruby/library/set/sortedset/subtract_spec.rb
+++ b/spec/ruby/library/set/sortedset/subtract_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#subtract" do
diff --git a/spec/ruby/library/set/sortedset/superset_spec.rb b/spec/ruby/library/set/sortedset/superset_spec.rb
index 823781b860..fc54e618a2 100644
--- a/spec/ruby/library/set/sortedset/superset_spec.rb
+++ b/spec/ruby/library/set/sortedset/superset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#superset?" do
@@ -25,9 +25,9 @@ describe "SortedSet#superset?" do
end
it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].superset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].superset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].superset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].superset?(Object.new) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].superset?([]) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].superset?(1) }.should raise_error(ArgumentError)
+ lambda { SortedSet[].superset?("test") }.should raise_error(ArgumentError)
+ lambda { SortedSet[].superset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/sortedset/to_a_spec.rb b/spec/ruby/library/set/sortedset/to_a_spec.rb
index ba37d18cdb..77deb17731 100644
--- a/spec/ruby/library/set/sortedset/to_a_spec.rb
+++ b/spec/ruby/library/set/sortedset/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'set'
describe "SortedSet#to_a" do
diff --git a/spec/ruby/library/set/sortedset/union_spec.rb b/spec/ruby/library/set/sortedset/union_spec.rb
index eb77600fee..c7255c3d2f 100644
--- a/spec/ruby/library/set/sortedset/union_spec.rb
+++ b/spec/ruby/library/set/sortedset/union_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative 'shared/union'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/union', __FILE__)
require 'set'
describe "SortedSet#union" do
diff --git a/spec/ruby/library/set/subset_spec.rb b/spec/ruby/library/set/subset_spec.rb
index f375efa6df..6503a7539f 100644
--- a/spec/ruby/library/set/subset_spec.rb
+++ b/spec/ruby/library/set/subset_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#subset?" do
@@ -27,15 +26,9 @@ describe "Set#subset?" do
end
it "raises an ArgumentError when passed a non-Set" do
- -> { Set[].subset?([]) }.should raise_error(ArgumentError)
- -> { Set[].subset?(1) }.should raise_error(ArgumentError)
- -> { Set[].subset?("test") }.should raise_error(ArgumentError)
- -> { Set[].subset?(Object.new) }.should raise_error(ArgumentError)
- end
-
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a subset of" do
- Set[1, 2, 3].subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
- end
+ lambda { Set[].subset?([]) }.should raise_error(ArgumentError)
+ lambda { Set[].subset?(1) }.should raise_error(ArgumentError)
+ lambda { Set[].subset?("test") }.should raise_error(ArgumentError)
+ lambda { Set[].subset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/subtract_spec.rb b/spec/ruby/library/set/subtract_spec.rb
index 56713de8b3..b0889bb675 100644
--- a/spec/ruby/library/set/subtract_spec.rb
+++ b/spec/ruby/library/set/subtract_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#subtract" do
diff --git a/spec/ruby/library/set/superset_spec.rb b/spec/ruby/library/set/superset_spec.rb
index bd9d2f3eee..b7364f529e 100644
--- a/spec/ruby/library/set/superset_spec.rb
+++ b/spec/ruby/library/set/superset_spec.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/set_like'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#superset?" do
@@ -27,15 +26,9 @@ describe "Set#superset?" do
end
it "raises an ArgumentError when passed a non-Set" do
- -> { Set[].superset?([]) }.should raise_error(ArgumentError)
- -> { Set[].superset?(1) }.should raise_error(ArgumentError)
- -> { Set[].superset?("test") }.should raise_error(ArgumentError)
- -> { Set[].superset?(Object.new) }.should raise_error(ArgumentError)
- end
-
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a superset of" do
- Set[1, 2, 3, 4].superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true
- end
+ lambda { Set[].superset?([]) }.should raise_error(ArgumentError)
+ lambda { Set[].superset?(1) }.should raise_error(ArgumentError)
+ lambda { Set[].superset?("test") }.should raise_error(ArgumentError)
+ lambda { Set[].superset?(Object.new) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/set/to_a_spec.rb b/spec/ruby/library/set/to_a_spec.rb
index 689e44f38a..daee014e90 100644
--- a/spec/ruby/library/set/to_a_spec.rb
+++ b/spec/ruby/library/set/to_a_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'set'
describe "Set#to_a" do
diff --git a/spec/ruby/library/set/to_s_spec.rb b/spec/ruby/library/set/to_s_spec.rb
index ca2806d669..f4c361f74f 100644
--- a/spec/ruby/library/set/to_s_spec.rb
+++ b/spec/ruby/library/set/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/inspect'
+require File.expand_path('../shared/inspect', __FILE__)
require 'set'
ruby_version_is "2.5" do
diff --git a/spec/ruby/library/set/union_spec.rb b/spec/ruby/library/set/union_spec.rb
index 20fe0ddca3..c705497928 100644
--- a/spec/ruby/library/set/union_spec.rb
+++ b/spec/ruby/library/set/union_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/union'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/union', __FILE__)
require 'set'
describe "Set#union" do
diff --git a/spec/ruby/library/shellwords/shellwords_spec.rb b/spec/ruby/library/shellwords/shellwords_spec.rb
index 2975fd9974..f8ab0cbd9d 100644
--- a/spec/ruby/library/shellwords/shellwords_spec.rb
+++ b/spec/ruby/library/shellwords/shellwords_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'shellwords'
include Shellwords
@@ -20,15 +20,17 @@ describe "Shellwords#shellwords" do
end
it "raises ArgumentError when double quoted strings are misquoted" do
- -> { shellwords('a "b c d e') }.should raise_error(ArgumentError)
+ lambda { shellwords('a "b c d e') }.should raise_error(ArgumentError)
end
it "raises ArgumentError when single quoted strings are misquoted" do
- -> { shellwords("a 'b c d e") }.should raise_error(ArgumentError)
+ lambda { shellwords("a 'b c d e") }.should raise_error(ArgumentError)
end
- # https://bugs.ruby-lang.org/issues/10055
- it "matches POSIX sh behavior for backslashes within double quoted strings" do
- shellsplit('printf "%s\n"').should == ['printf', '%s\n']
+ ruby_version_is '2.4' do
+ # https://bugs.ruby-lang.org/issues/10055
+ it "matches POSIX sh behavior for backslashes within double quoted strings" do
+ shellsplit('printf "%s\n"').should == ['printf', '%s\n']
+ end
end
end
diff --git a/spec/ruby/library/singleton/allocate_spec.rb b/spec/ruby/library/singleton/allocate_spec.rb
index 6a1512d53b..ce6a501db7 100644
--- a/spec/ruby/library/singleton/allocate_spec.rb
+++ b/spec/ruby/library/singleton/allocate_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Singleton.allocate" do
it "is a private method" do
- -> { SingletonSpecs::MyClass.allocate }.should raise_error(NoMethodError)
+ lambda { SingletonSpecs::MyClass.allocate }.should raise_error(NoMethodError)
end
end
diff --git a/spec/ruby/library/singleton/clone_spec.rb b/spec/ruby/library/singleton/clone_spec.rb
index 3635bcd594..964a57bdee 100644
--- a/spec/ruby/library/singleton/clone_spec.rb
+++ b/spec/ruby/library/singleton/clone_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Singleton#clone" do
it "is prevented" do
- -> { SingletonSpecs::MyClass.instance.clone }.should raise_error(TypeError)
+ lambda { SingletonSpecs::MyClass.instance.clone }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/singleton/dump_spec.rb b/spec/ruby/library/singleton/dump_spec.rb
index 333e3bc4b0..03f94cffd2 100644
--- a/spec/ruby/library/singleton/dump_spec.rb
+++ b/spec/ruby/library/singleton/dump_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Singleton#_dump" do
diff --git a/spec/ruby/library/singleton/dup_spec.rb b/spec/ruby/library/singleton/dup_spec.rb
index 13d5a213e9..16fe147f26 100644
--- a/spec/ruby/library/singleton/dup_spec.rb
+++ b/spec/ruby/library/singleton/dup_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Singleton#dup" do
it "is prevented" do
- -> { SingletonSpecs::MyClass.instance.dup }.should raise_error(TypeError)
+ lambda { SingletonSpecs::MyClass.instance.dup }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/singleton/instance_spec.rb b/spec/ruby/library/singleton/instance_spec.rb
index 1679728d4c..84cc081510 100644
--- a/spec/ruby/library/singleton/instance_spec.rb
+++ b/spec/ruby/library/singleton/instance_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Singleton.instance" do
it "returns an instance of the singleton class" do
diff --git a/spec/ruby/library/singleton/load_spec.rb b/spec/ruby/library/singleton/load_spec.rb
index 4c753f9e7a..fa5868693b 100644
--- a/spec/ruby/library/singleton/load_spec.rb
+++ b/spec/ruby/library/singleton/load_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
# TODO: change to a.should be_equal(b)
# TODO: write spec for cloning classes and calling private methods
diff --git a/spec/ruby/library/singleton/new_spec.rb b/spec/ruby/library/singleton/new_spec.rb
index 2f45db819c..cd20bebc2b 100644
--- a/spec/ruby/library/singleton/new_spec.rb
+++ b/spec/ruby/library/singleton/new_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Singleton.new" do
it "is a private method" do
- -> { SingletonSpecs::NewSpec.new }.should raise_error(NoMethodError)
+ lambda { SingletonSpecs::NewSpec.new }.should raise_error(NoMethodError)
end
end
diff --git a/spec/ruby/library/socket/addrinfo/afamily_spec.rb b/spec/ruby/library/socket/addrinfo/afamily_spec.rb
index 7229dab9de..1845ab5e04 100644
--- a/spec/ruby/library/socket/addrinfo/afamily_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/afamily_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#afamily" do
describe "for an ipv4 socket" do
@@ -23,7 +24,7 @@ describe "Addrinfo#afamily" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/bind_spec.rb b/spec/ruby/library/socket/addrinfo/bind_spec.rb
index 6f78890a4d..c892b05756 100644
--- a/spec/ruby/library/socket/addrinfo/bind_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/bind_spec.rb
@@ -1,5 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require 'socket'
describe "Addrinfo#bind" do
diff --git a/spec/ruby/library/socket/addrinfo/canonname_spec.rb b/spec/ruby/library/socket/addrinfo/canonname_spec.rb
index a1cc8b3980..15dfe86467 100644
--- a/spec/ruby/library/socket/addrinfo/canonname_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/canonname_spec.rb
@@ -1,5 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require 'socket'
describe "Addrinfo#canonname" do
@@ -15,13 +16,4 @@ describe "Addrinfo#canonname" do
canonname.should == nil
end
end
-
- describe 'when the canonical name is not available' do
- it 'returns nil' do
- addr = Addrinfo.new(Socket.sockaddr_in(0, '127.0.0.1'))
-
- addr.canonname.should be_nil
- end
- end
-
end
diff --git a/spec/ruby/library/socket/addrinfo/connect_from_spec.rb b/spec/ruby/library/socket/addrinfo/connect_from_spec.rb
deleted file mode 100644
index 55fce2e159..0000000000
--- a/spec/ruby/library/socket/addrinfo/connect_from_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Addrinfo#connect_from' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- @port = @server.connect_address.ip_port
- @addr = Addrinfo.tcp(ip_address, @port)
- end
-
- after do
- @socket.close if @socket
- @server.close
- end
-
- describe 'using separate arguments' do
- it 'returns a Socket when no block is given' do
- @socket = @addr.connect_from(ip_address, 0)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'yields the Socket when a block is given' do
- @addr.connect_from(ip_address, 0) do |socket|
- socket.should be_an_instance_of(Socket)
- end
- end
-
- it 'treats the last argument as a set of options if it is a Hash' do
- @socket = @addr.connect_from(ip_address, 0, timeout: 2)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'binds the socket to the local address' do
- @socket = @addr.connect_from(ip_address, 0)
-
- @socket.local_address.ip_address.should == ip_address
-
- @socket.local_address.ip_port.should > 0
- @socket.local_address.ip_port.should_not == @port
- end
- end
-
- describe 'using an Addrinfo as the 1st argument' do
- before do
- @from_addr = Addrinfo.tcp(ip_address, 0)
- end
-
- it 'returns a Socket when no block is given' do
- @socket = @addr.connect_from(@from_addr)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'yields the Socket when a block is given' do
- @addr.connect_from(@from_addr) do |socket|
- socket.should be_an_instance_of(Socket)
- end
- end
-
- it 'treats the last argument as a set of options if it is a Hash' do
- @socket = @addr.connect_from(@from_addr, timeout: 2)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'binds the socket to the local address' do
- @socket = @addr.connect_from(@from_addr)
-
- @socket.local_address.ip_address.should == ip_address
-
- @socket.local_address.ip_port.should > 0
- @socket.local_address.ip_port.should_not == @port
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/connect_spec.rb b/spec/ruby/library/socket/addrinfo/connect_spec.rb
deleted file mode 100644
index 1c2dc609ca..0000000000
--- a/spec/ruby/library/socket/addrinfo/connect_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Addrinfo#connect' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- @port = @server.connect_address.ip_port
- end
-
- after do
- @socket.close if @socket
- @server.close
- end
-
- it 'returns a Socket when no block is given' do
- addr = Addrinfo.tcp(ip_address, @port)
- @socket = addr.connect
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'yields a Socket when a block is given' do
- addr = Addrinfo.tcp(ip_address, @port)
- addr.connect do |socket|
- socket.should be_an_instance_of(Socket)
- end
- end
-
- it 'accepts a Hash of options' do
- addr = Addrinfo.tcp(ip_address, @port)
- @socket = addr.connect(timeout: 2)
- @socket.should be_an_instance_of(Socket)
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/connect_to_spec.rb b/spec/ruby/library/socket/addrinfo/connect_to_spec.rb
deleted file mode 100644
index 69666da19b..0000000000
--- a/spec/ruby/library/socket/addrinfo/connect_to_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Addrinfo#connect_to' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- @port = @server.connect_address.ip_port
- @addr = Addrinfo.tcp(ip_address, 0)
- end
-
- after do
- @socket.close if @socket
- @server.close
- end
-
- describe 'using separate arguments' do
- it 'returns a Socket when no block is given' do
- @socket = @addr.connect_to(ip_address, @port)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'yields the Socket when a block is given' do
- @addr.connect_to(ip_address, @port) do |socket|
- socket.should be_an_instance_of(Socket)
- end
- end
-
- it 'treats the last argument as a set of options if it is a Hash' do
- @socket = @addr.connect_to(ip_address, @port, timeout: 2)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'binds the Addrinfo to the local address' do
- @socket = @addr.connect_to(ip_address, @port)
-
- @socket.local_address.ip_address.should == ip_address
-
- @socket.local_address.ip_port.should > 0
- @socket.local_address.ip_port.should_not == @port
- end
- end
-
- describe 'using an Addrinfo as the 1st argument' do
- before do
- @to_addr = Addrinfo.tcp(ip_address, @port)
- end
-
- it 'returns a Socket when no block is given' do
- @socket = @addr.connect_to(@to_addr)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'yields the Socket when a block is given' do
- @addr.connect_to(@to_addr) do |socket|
- socket.should be_an_instance_of(Socket)
- end
- end
-
- it 'treats the last argument as a set of options if it is a Hash' do
- @socket = @addr.connect_to(@to_addr, timeout: 2)
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'binds the socket to the local address' do
- @socket = @addr.connect_to(@to_addr)
-
- @socket.local_address.ip_address.should == ip_address
-
- @socket.local_address.ip_port.should > 0
- @socket.local_address.ip_port.should_not == @port
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb b/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb
deleted file mode 100644
index 2bc3b6a2e3..0000000000
--- a/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#family_addrinfo' do
- it 'raises ArgumentError if no arguments are given' do
- addr = Addrinfo.tcp('127.0.0.1', 0)
-
- -> { addr.family_addrinfo }.should raise_error(ArgumentError)
- end
-
- describe 'using multiple arguments' do
- describe 'with an IP Addrinfo' do
- before do
- @source = Addrinfo.tcp('127.0.0.1', 0)
- end
-
- it 'raises ArgumentError if only 1 argument is given' do
- -> { @source.family_addrinfo('127.0.0.1') }.should raise_error(ArgumentError)
- end
-
- it 'raises ArgumentError if more than 2 arguments are given' do
- -> { @source.family_addrinfo('127.0.0.1', 0, 666) }.should raise_error(ArgumentError)
- end
-
- it 'returns an Addrinfo when a host and port are given' do
- addr = @source.family_addrinfo('127.0.0.1', 0)
-
- addr.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- before do
- @addr = @source.family_addrinfo('127.0.0.1', 0)
- end
-
- it 'uses the same address family as the source Addrinfo' do
- @addr.afamily.should == @source.afamily
- end
-
- it 'uses the same protocol family as the source Addrinfo' do
- @addr.pfamily.should == @source.pfamily
- end
-
- it 'uses the same socket type as the source Addrinfo' do
- @addr.socktype.should == @source.socktype
- end
-
- it 'uses the same protocol as the source Addrinfo' do
- @addr.protocol.should == @source.protocol
- end
- end
- end
-
- with_feature :unix_socket do
- describe 'with a UNIX Addrinfo' do
- before do
- @source = Addrinfo.unix('cats')
- end
-
- it 'raises ArgumentError if more than 1 argument is given' do
- -> { @source.family_addrinfo('foo', 'bar') }.should raise_error(ArgumentError)
- end
-
- it 'returns an Addrinfo when a UNIX socket path is given' do
- addr = @source.family_addrinfo('dogs')
-
- addr.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- before do
- @addr = @source.family_addrinfo('dogs')
- end
-
- it 'uses AF_UNIX as the address family' do
- @addr.afamily.should == Socket::AF_UNIX
- end
-
- it 'uses PF_UNIX as the protocol family' do
- @addr.pfamily.should == Socket::PF_UNIX
- end
-
- it 'uses the given socket path' do
- @addr.unix_path.should == 'dogs'
- end
- end
- end
- end
- end
-
- describe 'using an Addrinfo as the 1st argument' do
- before do
- @source = Addrinfo.tcp('127.0.0.1', 0)
- end
-
- it 'returns the input Addrinfo' do
- input = Addrinfo.tcp('127.0.0.2', 0)
- @source.family_addrinfo(input).should == input
- end
-
- it 'raises ArgumentError if more than 1 argument is given' do
- input = Addrinfo.tcp('127.0.0.2', 0)
- -> { @source.family_addrinfo(input, 666) }.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError if the protocol families don't match" do
- input = Addrinfo.tcp('::1', 0)
- -> { @source.family_addrinfo(input) }.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError if the socket types don't match" do
- input = Addrinfo.udp('127.0.0.1', 0)
- -> { @source.family_addrinfo(input) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/foreach_spec.rb b/spec/ruby/library/socket/addrinfo/foreach_spec.rb
deleted file mode 100644
index 6ec8fab905..0000000000
--- a/spec/ruby/library/socket/addrinfo/foreach_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo.foreach' do
- it 'yields Addrinfo instances to the supplied block' do
- Addrinfo.foreach('127.0.0.1', 80) do |addr|
- addr.should be_an_instance_of(Addrinfo)
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb b/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb
deleted file mode 100644
index 67fad73815..0000000000
--- a/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Addrinfo.getaddrinfo' do
- it 'returns an Array of Addrinfo instances' do
- array = Addrinfo.getaddrinfo('127.0.0.1', 80)
-
- array.should be_an_instance_of(Array)
- array[0].should be_an_instance_of(Addrinfo)
- end
-
- SocketSpecs.each_ip_protocol do |family, ip_address|
- it 'sets the IP address of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo(ip_address, 80)
-
- array[0].ip_address.should == ip_address
- end
-
- it 'sets the port of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo(ip_address, 80)
-
- array[0].ip_port.should == 80
- end
-
- it 'sets the address family of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo(ip_address, 80)
-
- array[0].afamily.should == family
- end
-
- it 'sets the protocol family of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo(ip_address, 80)
-
- array[0].pfamily.should == family
- end
- end
-
- guard -> { SocketSpecs.ipv6_available? } do
- it 'sets a custom protocol family of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo('::1', 80, Socket::PF_INET6)
-
- array[0].pfamily.should == Socket::PF_INET6
- end
-
- it 'sets a corresponding address family based on a custom protocol family' do
- array = Addrinfo.getaddrinfo('::1', 80, Socket::PF_INET6)
-
- array[0].afamily.should == Socket::AF_INET6
- end
- end
-
- platform_is_not :windows do
- it 'sets the default socket type of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo('127.0.0.1', 80)
- possible = [Socket::SOCK_STREAM, Socket::SOCK_DGRAM]
-
- possible.should include(array[0].socktype)
- end
- end
-
- it 'sets a custom socket type of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo('127.0.0.1', 80, nil, Socket::SOCK_DGRAM)
-
- array[0].socktype.should == Socket::SOCK_DGRAM
- end
-
- platform_is_not :windows do
- it 'sets the default socket protocol of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo('127.0.0.1', 80)
- possible = [Socket::IPPROTO_TCP, Socket::IPPROTO_UDP]
-
- possible.should include(array[0].protocol)
- end
- end
-
- platform_is_not :'solaris2.10' do # i386-solaris
- it 'sets a custom socket protocol of the Addrinfo instances' do
- array = Addrinfo.getaddrinfo('127.0.0.1', 80, nil, nil, Socket::IPPROTO_UDP)
-
- array[0].protocol.should == Socket::IPPROTO_UDP
- end
- end
-
- platform_is_not :solaris do
- it 'sets the canonical name when AI_CANONNAME is given as a flag' do
- array = Addrinfo.getaddrinfo('localhost', 80, nil, nil, nil, Socket::AI_CANONNAME)
-
- array[0].canonname.should be_an_instance_of(String)
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb b/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb
deleted file mode 100644
index c5284f1c0f..0000000000
--- a/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Addrinfo#getnameinfo' do
- describe 'using an IP Addrinfo' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @addr = Addrinfo.tcp(ip_address, 21)
- end
-
- it 'returns the node and service names' do
- host, service = @addr.getnameinfo
- service.should == 'ftp'
- end
-
- it 'accepts flags as an Integer as the first argument' do
- host, service = @addr.getnameinfo(Socket::NI_NUMERICSERV)
- service.should == '21'
- end
- end
- end
-
- platform_is :linux do
- with_feature :unix_socket do
- describe 'using a UNIX Addrinfo' do
- before do
- @addr = Addrinfo.unix('cats')
- @host = Socket.gethostname
- end
-
- it 'returns the hostname and UNIX socket path' do
- host, path = @addr.getnameinfo
-
- host.should == @host
- path.should == 'cats'
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/initialize_spec.rb b/spec/ruby/library/socket/addrinfo/initialize_spec.rb
index 8354553f61..254539f95e 100644
--- a/spec/ruby/library/socket/addrinfo/initialize_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/initialize_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#initialize" do
@@ -21,12 +22,6 @@ describe "Addrinfo#initialize" do
@addrinfo.pfamily.should == Socket::PF_UNSPEC
end
- it 'returns AF_INET as the default address family' do
- addr = Addrinfo.new(Socket.sockaddr_in(80, '127.0.0.1'))
-
- addr.afamily.should == Socket::AF_INET
- end
-
it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET6
end
@@ -147,7 +142,7 @@ describe "Addrinfo#initialize" do
@addrinfo.ip_port.should == 46102
end
- it "returns the Socket::PF_INET pfamily" do
+ it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET
end
@@ -164,46 +159,6 @@ describe "Addrinfo#initialize" do
end
end
- describe 'with a valid IP address' do
- # Uses AF_INET6 since AF_INET is the default, making it a better test
- # that Addrinfo actually sets the family correctly.
- before do
- @sockaddr = ['AF_INET6', 80, 'hostname', '::1']
- end
-
- it 'returns an Addrinfo with the correct IP' do
- addr = Addrinfo.new(@sockaddr)
-
- addr.ip_address.should == '::1'
- end
-
- it 'returns an Addrinfo with the correct address family' do
- addr = Addrinfo.new(@sockaddr)
-
- addr.afamily.should == Socket::AF_INET6
- end
-
- it 'returns an Addrinfo with the correct protocol family' do
- addr = Addrinfo.new(@sockaddr)
-
- addr.pfamily.should == Socket::PF_INET6
- end
-
- it 'returns an Addrinfo with the correct port' do
- addr = Addrinfo.new(@sockaddr)
-
- addr.ip_port.should == 80
- end
- end
-
- describe 'with an invalid IP address' do
- it 'raises SocketError' do
- block = -> { Addrinfo.new(['AF_INET6', 80, 'hostname', '127.0.0.1']) }
-
- block.should raise_error(SocketError)
- end
- end
-
describe "with a family given" do
before :each do
@addrinfo = Addrinfo.new(["AF_INET", 46102, "localhost", "127.0.0.1"], Socket::PF_INET)
@@ -262,38 +217,6 @@ describe "Addrinfo#initialize" do
it "returns the 0 protocol" do
@addrinfo.protocol.should == 0
end
-
- [:SOCK_STREAM, :SOCK_DGRAM, :SOCK_RAW].each do |type|
- it "overwrites the socket type #{type}" do
- sockaddr = ['AF_INET', 80, 'hostname', '127.0.0.1']
-
- value = Socket.const_get(type)
- addr = Addrinfo.new(sockaddr, nil, value)
-
- addr.socktype.should == value
- end
- end
-
- with_feature :sock_packet do
- [:SOCK_SEQPACKET].each do |type|
- it "overwrites the socket type #{type}" do
- sockaddr = ['AF_INET', 80, 'hostname', '127.0.0.1']
-
- value = Socket.const_get(type)
- addr = Addrinfo.new(sockaddr, nil, value)
-
- addr.socktype.should == value
- end
- end
- end
-
- it "raises SocketError when using SOCK_RDM" do
- sockaddr = ['AF_INET', 80, 'hostname', '127.0.0.1']
- value = Socket::SOCK_RDM
- block = -> { Addrinfo.new(sockaddr, nil, value) }
-
- block.should raise_error(SocketError)
- end
end
describe "with a family, socket type and protocol" do
@@ -327,261 +250,4 @@ describe "Addrinfo#initialize" do
end
end
- describe 'using an Array with extra arguments' do
- describe 'with the AF_INET6 address family and an explicit protocol family' do
- before do
- @sockaddr = ['AF_INET6', 80, 'hostname', '127.0.0.1']
- end
-
- it "raises SocketError when using any Socket constant except except AF_INET(6)/PF_INET(6)" do
- Socket.constants.grep(/(^AF_|^PF_)(?!INET)/).each do |constant|
- value = Socket.const_get(constant)
- -> {
- Addrinfo.new(@sockaddr, value)
- }.should raise_error(SocketError)
- end
- end
- end
-
- describe 'with the AF_INET address family and an explicit socket protocol' do
- before do
- @sockaddr = ['AF_INET', 80, 'hostname', '127.0.0.1']
- end
-
- describe 'and no socket type is given' do
- valid = [:IPPROTO_IP, :IPPROTO_UDP, :IPPROTO_HOPOPTS]
-
- valid.each do |type|
- it "overwrites the protocol when using #{type}" do
- value = Socket.const_get(type)
- addr = Addrinfo.new(@sockaddr, nil, nil, value)
-
- addr.protocol.should == value
- end
- end
-
- platform_is_not :windows, :aix, :solaris do
- (Socket.constants.grep(/^IPPROTO/) - valid).each do |type|
- it "raises SocketError when using #{type}" do
- value = Socket.const_get(type)
- block = -> { Addrinfo.new(@sockaddr, nil, nil, value) }
-
- block.should raise_error(SocketError)
- end
- end
- end
- end
-
- describe 'and the socket type is set to SOCK_DGRAM' do
- before do
- @socktype = Socket::SOCK_DGRAM
- end
-
- valid = [:IPPROTO_IP, :IPPROTO_UDP, :IPPROTO_HOPOPTS]
-
- valid.each do |type|
- it "overwrites the protocol when using #{type}" do
- value = Socket.const_get(type)
- addr = Addrinfo.new(@sockaddr, nil, @socktype, value)
-
- addr.protocol.should == value
- end
- end
-
- platform_is_not :windows, :aix, :solaris do
- (Socket.constants.grep(/^IPPROTO/) - valid).each do |type|
- it "raises SocketError when using #{type}" do
- value = Socket.const_get(type)
- block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) }
-
- block.should raise_error(SocketError)
- end
- end
- end
- end
-
- with_feature :sock_packet do
- describe 'and the socket type is set to SOCK_PACKET' do
- before do
- @socktype = Socket::SOCK_PACKET
- end
-
- Socket.constants.grep(/^IPPROTO/).each do |type|
- it "raises SocketError when using #{type}" do
- value = Socket.const_get(type)
- block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) }
-
- block.should raise_error(SocketError)
- end
- end
- end
- end
-
- describe 'and the socket type is set to SOCK_RAW' do
- before do
- @socktype = Socket::SOCK_RAW
- end
-
- Socket.constants.grep(/^IPPROTO/).each do |type|
- it "overwrites the protocol when using #{type}" do
- value = Socket.const_get(type)
- addr = Addrinfo.new(@sockaddr, nil, @socktype, value)
-
- addr.protocol.should == value
- end
- end
- end
-
- describe 'and the socket type is set to SOCK_RDM' do
- before do
- @socktype = Socket::SOCK_RDM
- end
-
- Socket.constants.grep(/^IPPROTO/).each do |type|
- it "raises SocketError when using #{type}" do
- value = Socket.const_get(type)
- block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) }
-
- block.should raise_error(SocketError)
- end
- end
- end
-
- platform_is :linux do
- describe 'and the socket type is set to SOCK_SEQPACKET' do
- before do
- @socktype = Socket::SOCK_SEQPACKET
- end
-
- valid = [:IPPROTO_IP, :IPPROTO_HOPOPTS]
-
- valid.each do |type|
- it "overwrites the protocol when using #{type}" do
- value = Socket.const_get(type)
- addr = Addrinfo.new(@sockaddr, nil, @socktype, value)
-
- addr.protocol.should == value
- end
- end
-
- (Socket.constants.grep(/^IPPROTO/) - valid).each do |type|
- it "raises SocketError when using #{type}" do
- value = Socket.const_get(type)
- block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) }
-
- block.should raise_error(SocketError)
- end
- end
- end
- end
-
- describe 'and the socket type is set to SOCK_STREAM' do
- before do
- @socktype = Socket::SOCK_STREAM
- end
-
- valid = [:IPPROTO_IP, :IPPROTO_TCP, :IPPROTO_HOPOPTS]
-
- valid.each do |type|
- it "overwrites the protocol when using #{type}" do
- value = Socket.const_get(type)
- addr = Addrinfo.new(@sockaddr, nil, @socktype, value)
-
- addr.protocol.should == value
- end
- end
-
- platform_is_not :windows, :aix, :solaris do
- (Socket.constants.grep(/^IPPROTO/) - valid).each do |type|
- it "raises SocketError when using #{type}" do
- value = Socket.const_get(type)
- block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) }
-
- block.should raise_error(SocketError)
- end
- end
- end
- end
- end
- end
-
- describe 'with Symbols' do
- before do
- @sockaddr = Socket.sockaddr_in(80, '127.0.0.1')
- end
-
- it 'returns an Addrinfo with :PF_INET family' do
- addr = Addrinfo.new(@sockaddr, :PF_INET)
-
- addr.pfamily.should == Socket::PF_INET
- end
-
- it 'returns an Addrinfo with :INET family' do
- addr = Addrinfo.new(@sockaddr, :INET)
-
- addr.pfamily.should == Socket::PF_INET
- end
-
- it 'returns an Addrinfo with :SOCK_STREAM as the socket type' do
- addr = Addrinfo.new(@sockaddr, nil, :SOCK_STREAM)
-
- addr.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'returns an Addrinfo with :STREAM as the socket type' do
- addr = Addrinfo.new(@sockaddr, nil, :STREAM)
-
- addr.socktype.should == Socket::SOCK_STREAM
- end
- end
-
- describe 'with Strings' do
- before do
- @sockaddr = Socket.sockaddr_in(80, '127.0.0.1')
- end
-
- it 'returns an Addrinfo with "PF_INET" family' do
- addr = Addrinfo.new(@sockaddr, 'PF_INET')
-
- addr.pfamily.should == Socket::PF_INET
- end
-
- it 'returns an Addrinfo with "INET" family' do
- addr = Addrinfo.new(@sockaddr, 'INET')
-
- addr.pfamily.should == Socket::PF_INET
- end
-
- it 'returns an Addrinfo with "SOCK_STREAM" as the socket type' do
- addr = Addrinfo.new(@sockaddr, nil, 'SOCK_STREAM')
-
- addr.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'returns an Addrinfo with "STREAM" as the socket type' do
- addr = Addrinfo.new(@sockaddr, nil, 'STREAM')
-
- addr.socktype.should == Socket::SOCK_STREAM
- end
- end
-
- with_feature :unix_socket do
- describe 'using separate arguments for a Unix socket' do
- before do
- @sockaddr = Socket.pack_sockaddr_un('socket')
- end
-
- it 'returns an Addrinfo with the correct unix path' do
- Addrinfo.new(@sockaddr).unix_path.should == 'socket'
- end
-
- it 'returns an Addrinfo with the correct protocol family' do
- Addrinfo.new(@sockaddr).pfamily.should == Socket::PF_UNSPEC
- end
-
- it 'returns an Addrinfo with the correct address family' do
- Addrinfo.new(@sockaddr).afamily.should == Socket::AF_UNIX
- end
- end
- end
end
diff --git a/spec/ruby/library/socket/addrinfo/inspect_sockaddr_spec.rb b/spec/ruby/library/socket/addrinfo/inspect_sockaddr_spec.rb
index 70ca4dd4d7..c7d69db760 100644
--- a/spec/ruby/library/socket/addrinfo/inspect_sockaddr_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/inspect_sockaddr_spec.rb
@@ -1,50 +1,25 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe 'Addrinfo#inspect_sockaddr' do
- describe 'using an IPv4 address' do
- it 'returns a String containing the IP address and port number' do
- addr = Addrinfo.tcp('127.0.0.1', 80)
-
- addr.inspect_sockaddr.should == '127.0.0.1:80'
- end
-
- it 'returns a String containing just the IP address when no port is given' do
- addr = Addrinfo.tcp('127.0.0.1', 0)
-
- addr.inspect_sockaddr.should == '127.0.0.1'
- end
+ it 'IPv4' do
+ Addrinfo.tcp('127.0.0.1', 80).inspect_sockaddr.should == '127.0.0.1:80'
+ Addrinfo.tcp('127.0.0.1', 0).inspect_sockaddr.should == '127.0.0.1'
end
- describe 'using an IPv6 address' do
- before :each do
- @ip = '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
- end
-
- it 'returns a String containing the IP address and port number' do
- Addrinfo.tcp('::1', 80).inspect_sockaddr.should == '[::1]:80'
- Addrinfo.tcp(@ip, 80).inspect_sockaddr.should == '[2001:db8:85a3::8a2e:370:7334]:80'
- end
-
- it 'returns a String containing just the IP address when no port is given' do
- Addrinfo.tcp('::1', 0).inspect_sockaddr.should == '::1'
- Addrinfo.tcp(@ip, 0).inspect_sockaddr.should == '2001:db8:85a3::8a2e:370:7334'
- end
+ it 'IPv6' do
+ Addrinfo.tcp('::1', 80).inspect_sockaddr.should == '[::1]:80'
+ Addrinfo.tcp('::1', 0).inspect_sockaddr.should == '::1'
+ ip = '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
+ Addrinfo.tcp(ip, 80).inspect_sockaddr.should == '[2001:db8:85a3::8a2e:370:7334]:80'
+ Addrinfo.tcp(ip, 0).inspect_sockaddr.should == '2001:db8:85a3::8a2e:370:7334'
end
- with_feature :unix_socket do
- describe 'using a UNIX path' do
- it 'returns a String containing the UNIX path' do
- addr = Addrinfo.unix('/foo/bar')
-
- addr.inspect_sockaddr.should == '/foo/bar'
- end
-
- it 'returns a String containing the UNIX path when using a relative path' do
- addr = Addrinfo.unix('foo')
-
- addr.inspect_sockaddr.should == 'UNIX foo'
- end
+ platform_is_not :windows do
+ it 'UNIX' do
+ Addrinfo.unix('/tmp/sock').inspect_sockaddr.should == '/tmp/sock'
+ Addrinfo.unix('rel').inspect_sockaddr.should == 'UNIX rel'
end
end
end
diff --git a/spec/ruby/library/socket/addrinfo/inspect_spec.rb b/spec/ruby/library/socket/addrinfo/inspect_spec.rb
deleted file mode 100644
index 98e1e83ffa..0000000000
--- a/spec/ruby/library/socket/addrinfo/inspect_spec.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#inspect' do
- describe 'using an IPv4 Addrinfo' do
- it 'returns a String when using a TCP Addrinfo' do
- addr = Addrinfo.tcp('127.0.0.1', 80)
-
- addr.inspect.should == '#<Addrinfo: 127.0.0.1:80 TCP>'
- end
-
- it 'returns a String when using an UDP Addrinfo' do
- addr = Addrinfo.udp('127.0.0.1', 80)
-
- addr.inspect.should == '#<Addrinfo: 127.0.0.1:80 UDP>'
- end
-
- it 'returns a String when using an Addrinfo without a port' do
- addr = Addrinfo.ip('127.0.0.1')
-
- addr.inspect.should == '#<Addrinfo: 127.0.0.1>'
- end
- end
-
- describe 'using an IPv6 Addrinfo' do
- it 'returns a String when using a TCP Addrinfo' do
- addr = Addrinfo.tcp('::1', 80)
-
- addr.inspect.should == '#<Addrinfo: [::1]:80 TCP>'
- end
-
- it 'returns a String when using an UDP Addrinfo' do
- addr = Addrinfo.udp('::1', 80)
-
- addr.inspect.should == '#<Addrinfo: [::1]:80 UDP>'
- end
-
- it 'returns a String when using an Addrinfo without a port' do
- addr = Addrinfo.ip('::1')
-
- addr.inspect.should == '#<Addrinfo: ::1>'
- end
- end
-
- with_feature :unix_socket do
- describe 'using a UNIX Addrinfo' do
- it 'returns a String' do
- addr = Addrinfo.unix('/foo')
-
- addr.inspect.should == '#<Addrinfo: /foo SOCK_STREAM>'
- end
-
- it 'returns a String when using a relative UNIX path' do
- addr = Addrinfo.unix('foo')
-
- addr.inspect.should == '#<Addrinfo: UNIX foo SOCK_STREAM>'
- end
-
- it 'returns a String when using a DGRAM socket' do
- addr = Addrinfo.unix('/foo', Socket::SOCK_DGRAM)
-
- addr.inspect.should == '#<Addrinfo: /foo SOCK_DGRAM>'
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ip_address_spec.rb b/spec/ruby/library/socket/addrinfo/ip_address_spec.rb
index 4522cf5cfd..f82cef0812 100644
--- a/spec/ruby/library/socket/addrinfo/ip_address_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ip_address_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ip_address" do
describe "for an ipv4 socket" do
@@ -21,46 +22,15 @@ describe "Addrinfo#ip_address" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end
it "raises an exception" do
- -> { @addrinfo.ip_address }.should raise_error(SocketError)
+ lambda { @addrinfo.ip_address }.should raise_error(SocketError)
end
end
end
-
- describe 'with an Array as the socket address' do
- it 'returns the IP as a String' do
- sockaddr = ['AF_INET', 80, 'localhost', '127.0.0.1']
- addr = Addrinfo.new(sockaddr)
-
- addr.ip_address.should == '127.0.0.1'
- end
- end
-
- describe 'without an IP address' do
- before do
- @ips = ['127.0.0.1', '0.0.0.0', '::1']
- end
-
- # Both these cases seem to return different values at times on MRI. Since
- # this is network dependent we can't rely on an exact IP being returned.
- it 'returns the local IP address when using an empty String as the IP' do
- sockaddr = Socket.sockaddr_in(80, '')
- addr = Addrinfo.new(sockaddr)
-
- @ips.include?(addr.ip_address).should == true
- end
-
- it 'returns the local IP address when using nil as the IP' do
- sockaddr = Socket.sockaddr_in(80, nil)
- addr = Addrinfo.new(sockaddr)
-
- @ips.include?(addr.ip_address).should == true
- end
- end
end
diff --git a/spec/ruby/library/socket/addrinfo/ip_port_spec.rb b/spec/ruby/library/socket/addrinfo/ip_port_spec.rb
index 4118607db0..e437b88ca1 100644
--- a/spec/ruby/library/socket/addrinfo/ip_port_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ip_port_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ip_port" do
describe "for an ipv4 socket" do
@@ -21,14 +22,14 @@ describe "Addrinfo#ip_port" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end
it "raises an exception" do
- -> { @addrinfo.ip_port }.should raise_error(SocketError)
+ lambda { @addrinfo.ip_port }.should raise_error(SocketError)
end
end
end
diff --git a/spec/ruby/library/socket/addrinfo/ip_spec.rb b/spec/ruby/library/socket/addrinfo/ip_spec.rb
index 80e7a62df7..2e4b613ae5 100644
--- a/spec/ruby/library/socket/addrinfo/ip_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ip_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ip?" do
describe "for an ipv4 socket" do
@@ -22,43 +22,15 @@ describe "Addrinfo#ip?" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end
- it "returns false" do
+ it "returns Socket::AF_INET6" do
@addrinfo.ip?.should be_false
end
end
end
end
-
-describe 'Addrinfo.ip' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- it 'returns an Addrinfo instance' do
- Addrinfo.ip(ip_address).should be_an_instance_of(Addrinfo)
- end
-
- it 'sets the IP address' do
- Addrinfo.ip(ip_address).ip_address.should == ip_address
- end
-
- it 'sets the port to 0' do
- Addrinfo.ip(ip_address).ip_port.should == 0
- end
-
- it 'sets the address family' do
- Addrinfo.ip(ip_address).afamily.should == family
- end
-
- it 'sets the protocol family' do
- Addrinfo.ip(ip_address).pfamily.should == family
- end
-
- it 'sets the socket type to 0' do
- Addrinfo.ip(ip_address).socktype.should == 0
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb b/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb
index 6c81c48d1c..2b4a9372cc 100644
--- a/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ip_unpack" do
describe "for an ipv4 socket" do
@@ -21,14 +22,14 @@ describe "Addrinfo#ip_unpack" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end
it "raises an exception" do
- -> { @addrinfo.ip_unpack }.should raise_error(SocketError)
+ lambda { @addrinfo.ip_unpack }.should raise_error(SocketError)
end
end
end
diff --git a/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb
index f5bab711db..457bd7cebf 100644
--- a/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb
@@ -1,16 +1,19 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ipv4_loopback?" do
describe "for an ipv4 socket" do
+ before :each do
+ @loopback = Addrinfo.tcp("127.0.0.1", 80)
+ @other = Addrinfo.tcp("0.0.0.0", 80)
+ end
+
it "returns true for the loopback address" do
- Addrinfo.ip('127.0.0.1').ipv4_loopback?.should == true
- Addrinfo.ip('127.0.0.2').ipv4_loopback?.should == true
- Addrinfo.ip('127.255.0.1').ipv4_loopback?.should == true
- Addrinfo.ip('127.255.255.255').ipv4_loopback?.should == true
+ @loopback.ipv4_loopback?.should be_true
end
it "returns false for another address" do
- Addrinfo.ip('255.255.255.0').ipv4_loopback?.should be_false
+ @other.ipv4_loopback?.should be_false
end
end
@@ -29,7 +32,7 @@ describe "Addrinfo#ipv4_loopback?" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb
index bdd14c1b00..01f6a6ebf7 100644
--- a/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb
@@ -1,21 +1,38 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ipv4_multicast?" do
- it 'returns true for a multicast address' do
- Addrinfo.ip('224.0.0.0').ipv4_multicast?.should == true
- Addrinfo.ip('224.0.0.9').ipv4_multicast?.should == true
- Addrinfo.ip('239.255.255.250').ipv4_multicast?.should == true
- end
+ describe "for an ipv4 socket" do
+ before :each do
+ @multicast = Addrinfo.tcp("224.0.0.1", 80)
+ @other = Addrinfo.tcp("0.0.0.0", 80)
+ end
- it 'returns false for a regular address' do
- Addrinfo.ip('8.8.8.8').ipv4_multicast?.should == false
+ it "returns true for the loopback address" do
+ @multicast.ipv4_multicast?.should be_true
+ end
+
+ it "returns false for another address" do
+ @other.ipv4_multicast?.should be_false
+ end
end
- it 'returns false for an IPv6 address' do
- Addrinfo.ip('::1').ipv4_multicast?.should == false
+ describe "for an ipv6 socket" do
+ before :each do
+ @multicast = Addrinfo.tcp("ff02::1", 80)
+ @other = Addrinfo.tcp("::", 80)
+ end
+
+ it "returns false for the loopback address" do
+ @multicast.ipv4_multicast?.should be_false
+ end
+
+ it "returns false for another address" do
+ @other.ipv4_multicast?.should be_false
+ end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb
index 733577609e..cf8bd8c1aa 100644
--- a/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ipv4_private?" do
describe "for an ipv4 socket" do
@@ -8,14 +9,7 @@ describe "Addrinfo#ipv4_private?" do
end
it "returns true for a private address" do
- Addrinfo.ip('10.0.0.0').ipv4_private?.should == true
- Addrinfo.ip('10.0.0.5').ipv4_private?.should == true
-
- Addrinfo.ip('172.16.0.0').ipv4_private?.should == true
- Addrinfo.ip('172.16.0.5').ipv4_private?.should == true
-
- Addrinfo.ip('192.168.0.0').ipv4_private?.should == true
- Addrinfo.ip('192.168.0.5').ipv4_private?.should == true
+ @private.ipv4_private?.should be_true
end
it "returns false for a public address" do
@@ -33,7 +27,7 @@ describe "Addrinfo#ipv4_private?" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/ipv4_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_spec.rb
index 7cba8209b6..3d4560532e 100644
--- a/spec/ruby/library/socket/addrinfo/ipv4_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ipv4_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ipv4?" do
describe "for an ipv4 socket" do
@@ -21,7 +22,7 @@ describe "Addrinfo#ipv4?" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb
deleted file mode 100644
index 291b4d7d6b..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-guard -> { SocketSpecs.ipv6_available? } do
- describe 'Addrinfo#ipv6_linklocal?' do
- platform_is_not :aix do
- it 'returns true for a link-local address' do
- Addrinfo.ip('fe80::').ipv6_linklocal?.should == true
- Addrinfo.ip('fe81::').ipv6_linklocal?.should == true
- Addrinfo.ip('fe8f::').ipv6_linklocal?.should == true
- Addrinfo.ip('fe80::1').ipv6_linklocal?.should == true
- end
- end
-
- it 'returns false for a regular address' do
- Addrinfo.ip('::1').ipv6_linklocal?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_linklocal?.should == false
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb
index 9ff8f107bf..b0060378e6 100644
--- a/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ipv6_loopback?" do
describe "for an ipv4 socket" do
@@ -7,7 +8,7 @@ describe "Addrinfo#ipv6_loopback?" do
@other = Addrinfo.tcp("0.0.0.0", 80)
end
- it "returns false for the loopback address" do
+ it "returns true for the loopback address" do
@loopback.ipv6_loopback?.should be_false
end
@@ -22,7 +23,7 @@ describe "Addrinfo#ipv6_loopback?" do
@other = Addrinfo.tcp("::", 80)
end
- it "returns true for the loopback address" do
+ it "returns false for the loopback address" do
@loopback.ipv6_loopback?.should be_true
end
@@ -31,7 +32,7 @@ describe "Addrinfo#ipv6_loopback?" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb
deleted file mode 100644
index 9c8e4dccb4..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_mc_global?' do
- it 'returns true for a multi-cast address in the global scope' do
- Addrinfo.ip('ff1e::').ipv6_mc_global?.should == true
- Addrinfo.ip('fffe::').ipv6_mc_global?.should == true
- Addrinfo.ip('ff0e::').ipv6_mc_global?.should == true
- Addrinfo.ip('ff1e::1').ipv6_mc_global?.should == true
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_mc_global?.should == false
- Addrinfo.ip('ff1a::').ipv6_mc_global?.should == false
- Addrinfo.ip('ff1f::1').ipv6_mc_global?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_mc_global?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb
deleted file mode 100644
index dd52a9ad8b..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_mc_linklocal?' do
- it 'returns true for a multi-cast link-local address' do
- Addrinfo.ip('ff12::').ipv6_mc_linklocal?.should == true
- Addrinfo.ip('ff02::').ipv6_mc_linklocal?.should == true
- Addrinfo.ip('fff2::').ipv6_mc_linklocal?.should == true
- Addrinfo.ip('ff12::1').ipv6_mc_linklocal?.should == true
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_mc_linklocal?.should == false
- Addrinfo.ip('fff1::').ipv6_mc_linklocal?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_mc_linklocal?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb
deleted file mode 100644
index b3cf5ffbab..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_mc_nodelocal?' do
- it 'returns true for a multi-cast node-local address' do
- Addrinfo.ip('ff11::').ipv6_mc_nodelocal?.should == true
- Addrinfo.ip('ff01::').ipv6_mc_nodelocal?.should == true
- Addrinfo.ip('fff1::').ipv6_mc_nodelocal?.should == true
- Addrinfo.ip('ff11::1').ipv6_mc_nodelocal?.should == true
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_mc_nodelocal?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_mc_nodelocal?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb
deleted file mode 100644
index 90653dd49c..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_mc_orglocal?' do
- it 'returns true for a multi-cast org-local address' do
- Addrinfo.ip('ff18::').ipv6_mc_orglocal?.should == true
- Addrinfo.ip('ff08::').ipv6_mc_orglocal?.should == true
- Addrinfo.ip('fff8::').ipv6_mc_orglocal?.should == true
- Addrinfo.ip('ff18::1').ipv6_mc_orglocal?.should == true
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_mc_orglocal?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_mc_orglocal?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb
deleted file mode 100644
index 686b625e0d..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_mc_sitelocal?' do
- it 'returns true for a multi-cast site-local address' do
- Addrinfo.ip('ff15::').ipv6_mc_sitelocal?.should == true
- Addrinfo.ip('ff05::').ipv6_mc_sitelocal?.should == true
- Addrinfo.ip('fff5::').ipv6_mc_sitelocal?.should == true
- Addrinfo.ip('ff15::1').ipv6_mc_sitelocal?.should == true
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_mc_sitelocal?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_mc_sitelocal?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb
index c25322869c..d8b3a96ebb 100644
--- a/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ipv6_multicast?" do
describe "for an ipv4 socket" do
@@ -7,7 +8,7 @@ describe "Addrinfo#ipv6_multicast?" do
@other = Addrinfo.tcp("0.0.0.0", 80)
end
- it "returns true for a multicast address" do
+ it "returns true for the loopback address" do
@multicast.ipv6_multicast?.should be_false
end
@@ -17,24 +18,21 @@ describe "Addrinfo#ipv6_multicast?" do
end
describe "for an ipv6 socket" do
- it "returns true for a multicast address" do
- Addrinfo.ip('ff00::').ipv6_multicast?.should == true
- Addrinfo.ip('ff00::1').ipv6_multicast?.should == true
- Addrinfo.ip('ff08::1').ipv6_multicast?.should == true
- Addrinfo.ip('fff8::1').ipv6_multicast?.should == true
-
- Addrinfo.ip('ff02::').ipv6_multicast?.should == true
- Addrinfo.ip('ff02::1').ipv6_multicast?.should == true
- Addrinfo.ip('ff0f::').ipv6_multicast?.should == true
+ before :each do
+ @multicast = Addrinfo.tcp("ff02::1", 80)
+ @other = Addrinfo.tcp("::", 80)
+ end
+
+ it "returns false for the loopback address" do
+ @multicast.ipv6_multicast?.should be_true
end
it "returns false for another address" do
- Addrinfo.ip('::1').ipv6_multicast?.should == false
- Addrinfo.ip('fe80::').ipv6_multicast?.should == false
+ @other.ipv6_multicast?.should be_false
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb
deleted file mode 100644
index dd202a1749..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-guard -> { SocketSpecs.ipv6_available? } do
- describe 'Addrinfo#ipv6_sitelocal?' do
- platform_is_not :aix do
- it 'returns true for a site-local address' do
- Addrinfo.ip('feef::').ipv6_sitelocal?.should == true
- Addrinfo.ip('fee0::').ipv6_sitelocal?.should == true
- Addrinfo.ip('fee2::').ipv6_sitelocal?.should == true
- Addrinfo.ip('feef::1').ipv6_sitelocal?.should == true
- end
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_sitelocal?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_sitelocal?.should == false
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_spec.rb
index 131e38849c..b66bc0d70b 100644
--- a/spec/ruby/library/socket/addrinfo/ipv6_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/ipv6_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#ipv6?" do
describe "for an ipv4 socket" do
@@ -21,7 +22,7 @@ describe "Addrinfo#ipv6?" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb
deleted file mode 100644
index 6dfaf531ae..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-guard -> { SocketSpecs.ipv6_available? } do
- describe 'Addrinfo#ipv6_to_ipv4' do
- it 'returns an Addrinfo for ::192.168.1.1' do
- addr = Addrinfo.ip('::192.168.1.1').ipv6_to_ipv4
-
- addr.should be_an_instance_of(Addrinfo)
-
- addr.afamily.should == Socket::AF_INET
- addr.ip_address.should == '192.168.1.1'
- end
-
- platform_is_not :aix do
- it 'returns an Addrinfo for ::0.0.1.1' do
- addr = Addrinfo.ip('::0.0.1.1').ipv6_to_ipv4
-
- addr.should be_an_instance_of(Addrinfo)
-
- addr.afamily.should == Socket::AF_INET
- addr.ip_address.should == '0.0.1.1'
- end
-
- it 'returns an Addrinfo for ::0.0.1.0' do
- addr = Addrinfo.ip('::0.0.1.0').ipv6_to_ipv4
-
- addr.should be_an_instance_of(Addrinfo)
-
- addr.afamily.should == Socket::AF_INET
- addr.ip_address.should == '0.0.1.0'
- end
-
- it 'returns an Addrinfo for ::0.1.0.0' do
- addr = Addrinfo.ip('::0.1.0.0').ipv6_to_ipv4
-
- addr.should be_an_instance_of(Addrinfo)
-
- addr.afamily.should == Socket::AF_INET
- addr.ip_address.should == '0.1.0.0'
- end
- end
-
- it 'returns an Addrinfo for ::ffff:192.168.1.1' do
- addr = Addrinfo.ip('::ffff:192.168.1.1').ipv6_to_ipv4
-
- addr.should be_an_instance_of(Addrinfo)
-
- addr.afamily.should == Socket::AF_INET
- addr.ip_address.should == '192.168.1.1'
- end
-
- it 'returns nil for ::0.0.0.1' do
- Addrinfo.ip('::0.0.0.1').ipv6_to_ipv4.should be_nil
- end
-
- it 'returns nil for a pure IPv6 Addrinfo' do
- Addrinfo.ip('::1').ipv6_to_ipv4.should be_nil
- end
-
- it 'returns nil for an IPv4 Addrinfo' do
- Addrinfo.ip('192.168.1.1').ipv6_to_ipv4.should be_nil
- end
-
- with_feature :unix_socket do
- it 'returns nil for a UNIX Addrinfo' do
- Addrinfo.unix('foo').ipv6_to_ipv4.should be_nil
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb
deleted file mode 100644
index b80a15fcb0..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_unique_local?' do
- it 'returns true for an unique local IPv6 address' do
- Addrinfo.ip('fc00::').ipv6_unique_local?.should == true
- Addrinfo.ip('fd00::').ipv6_unique_local?.should == true
- Addrinfo.ip('fcff::').ipv6_unique_local?.should == true
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_unique_local?.should == false
- Addrinfo.ip('fe00::').ipv6_unique_local?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_unique_local?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb
deleted file mode 100644
index dd79d57503..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_unspecified?' do
- it 'returns true for an unspecified IPv6 address' do
- Addrinfo.ip('::').ipv6_unspecified?.should == true
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_unspecified?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_unspecified?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb
deleted file mode 100644
index ab8388a21b..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_v4compat?' do
- it 'returns true for an IPv4 compatible address' do
- Addrinfo.ip('::127.0.0.1').ipv6_v4compat?.should == true
- Addrinfo.ip('::192.168.1.1').ipv6_v4compat?.should == true
- end
-
- it 'returns false for an IPv4 mapped address' do
- Addrinfo.ip('::ffff:192.168.1.1').ipv6_v4compat?.should == false
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_v4compat?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_v4compat?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb
deleted file mode 100644
index 82b272c165..0000000000
--- a/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#ipv6_v4mapped?' do
- it 'returns true for an IPv4 compatible address' do
- Addrinfo.ip('::ffff:192.168.1.1').ipv6_v4mapped?.should == true
- end
-
- it 'returns false for an IPv4 compatible address' do
- Addrinfo.ip('::192.168.1.1').ipv6_v4mapped?.should == false
- Addrinfo.ip('::127.0.0.1').ipv6_v4mapped?.should == false
- end
-
- it 'returns false for a regular IPv6 address' do
- Addrinfo.ip('::1').ipv6_v4mapped?.should == false
- end
-
- it 'returns false for an IPv4 address' do
- Addrinfo.ip('127.0.0.1').ipv6_v4mapped?.should == false
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/listen_spec.rb b/spec/ruby/library/socket/addrinfo/listen_spec.rb
deleted file mode 100644
index 714a96ed6c..0000000000
--- a/spec/ruby/library/socket/addrinfo/listen_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#listen' do
- before do
- @addr = Addrinfo.tcp('127.0.0.1', 0)
- @socket = nil
- end
-
- after do
- @socket.close if @socket
- end
-
- it 'returns a Socket when no block is given' do
- @socket = @addr.listen
-
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'yields the Socket if a block is given' do
- @addr.listen do |socket|
- socket.should be_an_instance_of(Socket)
- end
- end
-
- it 'closes the socket if a block is given' do
- socket = nil
-
- @addr.listen do |sock|
- socket = sock
- end
-
- socket.closed?.should == true
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb b/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb
deleted file mode 100644
index c4220a6f3e..0000000000
--- a/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#marshal_dump' do
- describe 'using an IP Addrinfo' do
- before do
- @addr = Addrinfo.getaddrinfo('localhost', 80, :INET, :STREAM,
- Socket::IPPROTO_TCP, Socket::AI_CANONNAME)[0]
- end
-
- it 'returns an Array' do
- @addr.marshal_dump.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = @addr.marshal_dump
- end
-
- it 'includes the address family as the 1st value' do
- @array[0].should == 'AF_INET'
- end
-
- it 'includes the IP address as the 2nd value' do
- @array[1].should == [@addr.ip_address, @addr.ip_port.to_s]
- end
-
- it 'includes the protocol family as the 3rd value' do
- @array[2].should == 'PF_INET'
- end
-
- it 'includes the socket type as the 4th value' do
- @array[3].should == 'SOCK_STREAM'
- end
-
- platform_is_not :'solaris2.10' do # i386-solaris
- it 'includes the protocol as the 5th value' do
- @array[4].should == 'IPPROTO_TCP'
- end
- end
-
- it 'includes the canonical name as the 6th value' do
- @array[5].should == @addr.canonname
- end
- end
- end
-
- with_feature :unix_socket do
- describe 'using a UNIX Addrinfo' do
- before do
- @addr = Addrinfo.unix('foo')
- end
-
- it 'returns an Array' do
- @addr.marshal_dump.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = @addr.marshal_dump
- end
-
- it 'includes the address family as the 1st value' do
- @array[0].should == 'AF_UNIX'
- end
-
- it 'includes the UNIX path as the 2nd value' do
- @array[1].should == @addr.unix_path
- end
-
- it 'includes the protocol family as the 3rd value' do
- @array[2].should == 'PF_UNIX'
- end
-
- it 'includes the socket type as the 4th value' do
- @array[3].should == 'SOCK_STREAM'
- end
-
- it 'includes the protocol as the 5th value' do
- @array[4].should == 0
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/marshal_load_spec.rb b/spec/ruby/library/socket/addrinfo/marshal_load_spec.rb
deleted file mode 100644
index aa20865224..0000000000
--- a/spec/ruby/library/socket/addrinfo/marshal_load_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Addrinfo#marshal_load' do
- describe 'using an IP address' do
- it 'returns a new Addrinfo' do
- source = Addrinfo.getaddrinfo('localhost', 80, :INET, :STREAM,
- Socket::IPPROTO_TCP, Socket::AI_CANONNAME)[0]
-
- addr = Marshal.load(Marshal.dump(source))
-
- addr.afamily.should == source.afamily
- addr.pfamily.should == source.pfamily
- addr.socktype.should == source.socktype
- addr.protocol.should == source.protocol
- addr.ip_address.should == source.ip_address
- addr.ip_port.should == source.ip_port
- addr.canonname.should == source.canonname
- end
- end
-
- with_feature :unix_socket do
- describe 'using a UNIX socket' do
- it 'returns a new Addrinfo' do
- source = Addrinfo.unix('foo')
- addr = Marshal.load(Marshal.dump(source))
-
- addr.afamily.should == source.afamily
- addr.pfamily.should == source.pfamily
- addr.socktype.should == source.socktype
- addr.protocol.should == source.protocol
- addr.unix_path.should == source.unix_path
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/addrinfo/pfamily_spec.rb b/spec/ruby/library/socket/addrinfo/pfamily_spec.rb
index 984744a964..d37ed73e1e 100644
--- a/spec/ruby/library/socket/addrinfo/pfamily_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/pfamily_spec.rb
@@ -1,12 +1,7 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#pfamily" do
- it 'returns PF_UNSPEC as the default socket family' do
- sockaddr = Socket.pack_sockaddr_in(80, 'localhost')
-
- Addrinfo.new(sockaddr).pfamily.should == Socket::PF_UNSPEC
- end
-
describe "for an ipv4 socket" do
before :each do
@@ -29,7 +24,7 @@ describe "Addrinfo#pfamily" do
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/protocol_spec.rb b/spec/ruby/library/socket/addrinfo/protocol_spec.rb
index ea143fc4a8..4ff11dc017 100644
--- a/spec/ruby/library/socket/addrinfo/protocol_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/protocol_spec.rb
@@ -1,16 +1,30 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#protocol" do
- it 'returns 0 by default' do
- Addrinfo.ip('127.0.0.1').protocol.should == 0
+ describe "for an ipv4 socket" do
+
+ before :each do
+ @addrinfo = Addrinfo.tcp("127.0.0.1", 80)
+ end
+
+ it "returns Socket::IPPROTO_TCP" do
+ @addrinfo.protocol.should == Socket::IPPROTO_TCP
+ end
+
end
- it 'returns a custom protocol when given' do
- Addrinfo.tcp('127.0.0.1', 80).protocol.should == Socket::IPPROTO_TCP
- Addrinfo.tcp('::1', 80).protocol.should == Socket::IPPROTO_TCP
+ describe "for an ipv6 socket" do
+ before :each do
+ @addrinfo = Addrinfo.tcp("::1", 80)
+ end
+
+ it "returns Socket::IPPROTO_TCP" do
+ @addrinfo.protocol.should == Socket::IPPROTO_TCP
+ end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb b/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
index c32da5986d..86819a31b0 100644
--- a/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
+++ b/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
@@ -6,7 +6,7 @@ describe :socket_addrinfo_to_sockaddr, :shared => true do
end
it "returns a sockaddr packed structure" do
- @addrinfo.send(@method).should == Socket.sockaddr_in(80, '127.0.0.1')
+ @addrinfo.send(@method).should be_kind_of(String)
end
end
@@ -16,36 +16,20 @@ describe :socket_addrinfo_to_sockaddr, :shared => true do
end
it "returns a sockaddr packed structure" do
- @addrinfo.send(@method).should == Socket.sockaddr_in(80, '::1')
+ @addrinfo.send(@method).should be_kind_of(String)
end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end
it "returns a sockaddr packed structure" do
- @addrinfo.send(@method).should == Socket.sockaddr_un('/tmp/sock')
+ @addrinfo.send(@method).should be_kind_of(String)
end
end
end
- describe 'using a Addrinfo with just an IP address' do
- it 'returns a String' do
- addr = Addrinfo.ip('127.0.0.1')
-
- addr.send(@method).should == Socket.sockaddr_in(0, '127.0.0.1')
- end
- end
-
- describe 'using a Addrinfo without an IP and port' do
- it 'returns a String' do
- addr = Addrinfo.new(['AF_INET', 0, '', ''])
-
- addr.send(@method).should == Socket.sockaddr_in(0, '')
- end
- end
-
end
diff --git a/spec/ruby/library/socket/addrinfo/socktype_spec.rb b/spec/ruby/library/socket/addrinfo/socktype_spec.rb
index b994bea140..e1c8c0f3f5 100644
--- a/spec/ruby/library/socket/addrinfo/socktype_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/socktype_spec.rb
@@ -1,15 +1,30 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Addrinfo#socktype" do
- it 'returns 0 by default' do
- Addrinfo.ip('127.0.0.1').socktype.should == 0
+ describe "for an ipv4 socket" do
+
+ before :each do
+ @addrinfo = Addrinfo.tcp("127.0.0.1", 80)
+ end
+
+ it "returns Socket::SOCK_STREAM" do
+ @addrinfo.socktype.should == Socket::SOCK_STREAM
+ end
+
end
- it 'returns the socket type when given' do
- Addrinfo.tcp('127.0.0.1', 80).socktype.should == Socket::SOCK_STREAM
+ describe "for an ipv6 socket" do
+ before :each do
+ @addrinfo = Addrinfo.tcp("::1", 80)
+ end
+
+ it "returns Socket::SOCK_STREAM" do
+ @addrinfo.socktype.should == Socket::SOCK_STREAM
+ end
end
- with_feature :unix_socket do
+ platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
diff --git a/spec/ruby/library/socket/addrinfo/tcp_spec.rb b/spec/ruby/library/socket/addrinfo/tcp_spec.rb
index c74c9c21c2..b5c18cefea 100644
--- a/spec/ruby/library/socket/addrinfo/tcp_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/tcp_spec.rb
@@ -1,34 +1,20 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
-describe 'Addrinfo.tcp' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- it 'returns an Addrinfo instance' do
- Addrinfo.tcp(ip_address, 80).should be_an_instance_of(Addrinfo)
- end
-
- it 'sets the IP address' do
- Addrinfo.tcp(ip_address, 80).ip_address.should == ip_address
- end
-
- it 'sets the port' do
- Addrinfo.tcp(ip_address, 80).ip_port.should == 80
- end
-
- it 'sets the address family' do
- Addrinfo.tcp(ip_address, 80).afamily.should == family
- end
-
- it 'sets the protocol family' do
- Addrinfo.tcp(ip_address, 80).pfamily.should == family
- end
+describe "Addrinfo.tcp" do
- it 'sets the socket type' do
- Addrinfo.tcp(ip_address, 80).socktype.should == Socket::SOCK_STREAM
- end
+ before :each do
+ @addrinfo = Addrinfo.tcp("localhost", "smtp")
+ end
- it 'sets the socket protocol' do
- Addrinfo.tcp(ip_address, 80).protocol.should == Socket::IPPROTO_TCP
+ it "creates a addrinfo for a tcp socket" do
+ ["::1", "127.0.0.1"].should include(@addrinfo.ip_address)
+ [Socket::PF_INET, Socket::PF_INET6].should include(@addrinfo.pfamily)
+ @addrinfo.ip_port.should == 25
+ @addrinfo.socktype.should == Socket::SOCK_STREAM
+ platform_is_not :solaris do
+ @addrinfo.protocol.should == Socket::IPPROTO_TCP
end
end
+
end
diff --git a/spec/ruby/library/socket/addrinfo/to_s_spec.rb b/spec/ruby/library/socket/addrinfo/to_s_spec.rb
index ddf994e051..7205bdc823 100644
--- a/spec/ruby/library/socket/addrinfo/to_s_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/to_s_spec.rb
@@ -1,6 +1,7 @@
-require_relative '../spec_helper'
-require_relative 'shared/to_sockaddr'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_sockaddr', __FILE__)
+require 'socket'
describe "Addrinfo#to_s" do
- it_behaves_like :socket_addrinfo_to_sockaddr, :to_s
+ it_behaves_like(:socket_addrinfo_to_sockaddr, :to_s)
end
diff --git a/spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb b/spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb
index b9f75454bd..f3f926c2b6 100644
--- a/spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb
@@ -1,6 +1,7 @@
-require_relative '../spec_helper'
-require_relative 'shared/to_sockaddr'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/to_sockaddr', __FILE__)
+require 'socket'
describe "Addrinfo#to_sockaddr" do
- it_behaves_like :socket_addrinfo_to_sockaddr, :to_sockaddr
+ it_behaves_like(:socket_addrinfo_to_sockaddr, :to_sockaddr)
end
diff --git a/spec/ruby/library/socket/addrinfo/udp_spec.rb b/spec/ruby/library/socket/addrinfo/udp_spec.rb
index b05cbf9b0b..712d730e05 100644
--- a/spec/ruby/library/socket/addrinfo/udp_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/udp_spec.rb
@@ -1,36 +1,20 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
-describe 'Addrinfo.udp' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- it 'returns an Addrinfo instance' do
- Addrinfo.udp(ip_address, 80).should be_an_instance_of(Addrinfo)
- end
-
- it 'sets the IP address' do
- Addrinfo.udp(ip_address, 80).ip_address.should == ip_address
- end
-
- it 'sets the port' do
- Addrinfo.udp(ip_address, 80).ip_port.should == 80
- end
-
- it 'sets the address family' do
- Addrinfo.udp(ip_address, 80).afamily.should == family
- end
-
- it 'sets the protocol family' do
- Addrinfo.udp(ip_address, 80).pfamily.should == family
- end
+describe "Addrinfo.udp" do
- it 'sets the socket type' do
- Addrinfo.udp(ip_address, 80).socktype.should == Socket::SOCK_DGRAM
- end
+ before :each do
+ @addrinfo = Addrinfo.udp("localhost", "daytime")
+ end
+ it "creates a addrinfo for a tcp socket" do
+ ["::1", "127.0.0.1"].should include(@addrinfo.ip_address)
+ [Socket::PF_INET, Socket::PF_INET6].should include(@addrinfo.pfamily)
+ @addrinfo.ip_port.should == 13
+ @addrinfo.socktype.should == Socket::SOCK_DGRAM
platform_is_not :solaris do
- it 'sets the socket protocol' do
- Addrinfo.udp(ip_address, 80).protocol.should == Socket::IPPROTO_UDP
- end
+ @addrinfo.protocol.should == Socket::IPPROTO_UDP
end
end
+
end
diff --git a/spec/ruby/library/socket/addrinfo/unix_path_spec.rb b/spec/ruby/library/socket/addrinfo/unix_path_spec.rb
index 6bfb56a4ac..3f7e03dd7b 100644
--- a/spec/ruby/library/socket/addrinfo/unix_path_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/unix_path_spec.rb
@@ -1,6 +1,7 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
-with_feature :unix_socket do
+platform_is_not :windows do
describe "Addrinfo#unix_path" do
describe "for an ipv4 socket" do
@@ -9,7 +10,7 @@ with_feature :unix_socket do
end
it "raises an exception" do
- -> { @addrinfo.unix_path }.should raise_error(SocketError)
+ lambda { @addrinfo.unix_path }.should raise_error(SocketError)
end
end
@@ -20,17 +21,19 @@ with_feature :unix_socket do
end
it "raises an exception" do
- -> { @addrinfo.unix_path }.should raise_error(SocketError)
+ lambda { @addrinfo.unix_path }.should raise_error(SocketError)
end
end
- describe "for a unix socket" do
- before :each do
- @addrinfo = Addrinfo.unix("/tmp/sock")
- end
+ platform_is_not :windows do
+ describe "for a unix socket" do
+ before :each do
+ @addrinfo = Addrinfo.unix("/tmp/sock")
+ end
- it "returns the socket path" do
- @addrinfo.unix_path.should == "/tmp/sock"
+ it "returns the socket path" do
+ @addrinfo.unix_path.should == "/tmp/sock"
+ end
end
end
end
diff --git a/spec/ruby/library/socket/addrinfo/unix_spec.rb b/spec/ruby/library/socket/addrinfo/unix_spec.rb
index 4596ece17e..00eedc96e7 100644
--- a/spec/ruby/library/socket/addrinfo/unix_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/unix_spec.rb
@@ -1,35 +1,18 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
-with_feature :unix_socket do
- describe 'Addrinfo.unix' do
- it 'returns an Addrinfo instance' do
- Addrinfo.unix('socket').should be_an_instance_of(Addrinfo)
- end
-
- it 'sets the IP address' do
- Addrinfo.unix('socket').unix_path.should == 'socket'
- end
-
- it 'sets the address family' do
- Addrinfo.unix('socket').afamily.should == Socket::AF_UNIX
- end
-
- it 'sets the protocol family' do
- Addrinfo.unix('socket').pfamily.should == Socket::PF_UNIX
- end
-
- it 'sets the socket type' do
- Addrinfo.unix('socket').socktype.should == Socket::SOCK_STREAM
- end
+describe "Addrinfo.unix" do
- it 'sets a custom socket type' do
- addr = Addrinfo.unix('socket', Socket::SOCK_DGRAM)
-
- addr.socktype.should == Socket::SOCK_DGRAM
+ platform_is_not :windows do
+ before :each do
+ @addrinfo = Addrinfo.unix("/tmp/sock")
end
- it 'sets the socket protocol to 0' do
- Addrinfo.unix('socket').protocol.should == 0
+ it "creates a addrinfo for a unix socket" do
+ @addrinfo.pfamily.should == Socket::PF_UNIX
+ @addrinfo.socktype.should == Socket::SOCK_STREAM
+ @addrinfo.protocol.should == 0
+ @addrinfo.unix_path.should == "/tmp/sock"
end
end
end
diff --git a/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb b/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb
deleted file mode 100644
index c54ee29825..0000000000
--- a/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData#cmsg_is?' do
- describe 'using :INET, :IP, :TTL as the family, level, and type' do
- before do
- @data = Socket::AncillaryData.new(:INET, :IP, :TTL, '')
- end
-
- it 'returns true when comparing with IPPROTO_IP and IP_TTL' do
- @data.cmsg_is?(Socket::IPPROTO_IP, Socket::IP_TTL).should == true
- end
-
- it 'returns true when comparing with :IP and :TTL' do
- @data.cmsg_is?(:IP, :TTL).should == true
- end
-
- with_feature :pktinfo do
- it 'returns false when comparing with :IP and :PKTINFO' do
- @data.cmsg_is?(:IP, :PKTINFO).should == false
- end
- end
-
- it 'returns false when comparing with :SOCKET and :RIGHTS' do
- @data.cmsg_is?(:SOCKET, :RIGHTS).should == false
- end
-
- it 'raises SocketError when comparing with :IPV6 and :RIGHTS' do
- -> { @data.cmsg_is?(:IPV6, :RIGHTS) }.should raise_error(SocketError)
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/data_spec.rb b/spec/ruby/library/socket/ancillarydata/data_spec.rb
deleted file mode 100644
index 5a1a446dd5..0000000000
--- a/spec/ruby/library/socket/ancillarydata/data_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData#data' do
- it 'returns the data as a String' do
- Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, 'ugh').data.should == 'ugh'
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/family_spec.rb b/spec/ruby/library/socket/ancillarydata/family_spec.rb
deleted file mode 100644
index 975f0d2538..0000000000
--- a/spec/ruby/library/socket/ancillarydata/family_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData#family' do
- it 'returns the family as an Integer' do
- Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').family.should == Socket::AF_INET
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/initialize_spec.rb b/spec/ruby/library/socket/ancillarydata/initialize_spec.rb
deleted file mode 100644
index 344d1485c5..0000000000
--- a/spec/ruby/library/socket/ancillarydata/initialize_spec.rb
+++ /dev/null
@@ -1,284 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData#initialize' do
- describe 'using Integers for the family, level, and type' do
- before do
- @data = Socket::AncillaryData
- .new(Socket::AF_INET, Socket::IPPROTO_IP, Socket::IP_RECVTTL, 'ugh')
- end
-
- it 'sets the address family' do
- @data.family.should == Socket::AF_INET
- end
-
- it 'sets the message level' do
- @data.level.should == Socket::IPPROTO_IP
- end
-
- it 'sets the message type' do
- @data.type.should == Socket::IP_RECVTTL
- end
-
- it 'sets the data' do
- @data.data.should == 'ugh'
- end
- end
-
- describe 'using Symbols for the family, level, and type' do
- before do
- @data = Socket::AncillaryData.new(:INET, :IPPROTO_IP, :RECVTTL, 'ugh')
- end
-
- it 'sets the address family' do
- @data.family.should == Socket::AF_INET
- end
-
- it 'sets the message level' do
- @data.level.should == Socket::IPPROTO_IP
- end
-
- it 'sets the message type' do
- @data.type.should == Socket::IP_RECVTTL
- end
-
- it 'sets the data' do
- @data.data.should == 'ugh'
- end
- end
-
- describe 'using Strings for the family, level, and type' do
- before do
- @data = Socket::AncillaryData.new('INET', 'IPPROTO_IP', 'RECVTTL', 'ugh')
- end
-
- it 'sets the address family' do
- @data.family.should == Socket::AF_INET
- end
-
- it 'sets the message level' do
- @data.level.should == Socket::IPPROTO_IP
- end
-
- it 'sets the message type' do
- @data.type.should == Socket::IP_RECVTTL
- end
-
- it 'sets the data' do
- @data.data.should == 'ugh'
- end
- end
-
- describe 'using custom objects with a to_str method for the family, level, and type' do
- before do
- fmock = mock(:family)
- lmock = mock(:level)
- tmock = mock(:type)
- dmock = mock(:data)
-
- fmock.stub!(:to_str).and_return('INET')
- lmock.stub!(:to_str).and_return('IP')
- tmock.stub!(:to_str).and_return('RECVTTL')
- dmock.stub!(:to_str).and_return('ugh')
-
- @data = Socket::AncillaryData.new(fmock, lmock, tmock, dmock)
- end
-
- it 'sets the address family' do
- @data.family.should == Socket::AF_INET
- end
-
- it 'sets the message level' do
- @data.level.should == Socket::IPPROTO_IP
- end
-
- it 'sets the message type' do
- @data.type.should == Socket::IP_RECVTTL
- end
-
- it 'sets the data' do
- @data.data.should == 'ugh'
- end
- end
-
- describe 'using :AF_INET as the family and :SOCKET as the level' do
- it 'sets the type to SCM_RIGHTS when using :RIGHTS as the type argument' do
- Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').type.should == Socket::SCM_RIGHTS
- end
-
- platform_is_not :"solaris2.10", :aix do
- it 'sets the type to SCM_TIMESTAMP when using :TIMESTAMP as the type argument' do
- Socket::AncillaryData.new(:INET, :SOCKET, :TIMESTAMP, '').type.should == Socket::SCM_TIMESTAMP
- end
- end
-
- it 'raises TypeError when using a numeric string as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :IGMP, Socket::SCM_RIGHTS.to_s, '')
- }.should raise_error(TypeError)
- end
-
- it 'raises SocketError when using :RECVTTL as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :SOCKET, :RECVTTL, '')
- }.should raise_error(SocketError)
- end
-
- it 'raises SocketError when using :MOO as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :SOCKET, :MOO, '')
- }.should raise_error(SocketError)
- end
-
- it 'raises SocketError when using :IP_RECVTTL as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :SOCKET, :IP_RECVTTL, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_INET as the family and :SOCKET as the level' do
- it 'sets the type to SCM_RIGHTS when using :RIGHTS as the type argument' do
- Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').type.should == Socket::SCM_RIGHTS
- end
- end
-
- describe 'using :AF_INET as the family and :IP as the level' do
- it 'sets the type to IP_RECVTTL when using :RECVTTL as the type argument' do
- Socket::AncillaryData.new(:INET, :IP, :RECVTTL, '').type.should == Socket::IP_RECVTTL
- end
-
- with_feature :ip_mtu do
- it 'sets the type to IP_MTU when using :MTU as the type argument' do
- Socket::AncillaryData.new(:INET, :IP, :MTU, '').type.should == Socket::IP_MTU
- end
- end
-
- it 'raises SocketError when using :RIGHTS as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :IP, :RIGHTS, '')
- }.should raise_error(SocketError)
- end
-
- it 'raises SocketError when using :MOO as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :IP, :MOO, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_INET as the family and :IPV6 as the level' do
- it 'sets the type to IPV6_CHECKSUM when using :CHECKSUM as the type argument' do
- Socket::AncillaryData.new(:INET, :IPV6, :CHECKSUM, '').type.should == Socket::IPV6_CHECKSUM
- end
-
- with_feature :ipv6_nexthop do
- it 'sets the type to IPV6_NEXTHOP when using :NEXTHOP as the type argument' do
- Socket::AncillaryData.new(:INET, :IPV6, :NEXTHOP, '').type.should == Socket::IPV6_NEXTHOP
- end
- end
-
- it 'raises SocketError when using :RIGHTS as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :IPV6, :RIGHTS, '')
- }.should raise_error(SocketError)
- end
-
- it 'raises SocketError when using :MOO as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :IPV6, :MOO, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_INET as the family and :TCP as the level' do
- with_feature :tcp_cork do
- it 'sets the type to TCP_CORK when using :CORK as the type argument' do
- Socket::AncillaryData.new(:INET, :TCP, :CORK, '').type.should == Socket::TCP_CORK
- end
- end
-
- with_feature :tcp_info do
- it 'sets the type to TCP_INFO when using :INFO as the type argument' do
- Socket::AncillaryData.new(:INET, :TCP, :INFO, '').type.should == Socket::TCP_INFO
- end
- end
-
- it 'raises SocketError when using :RIGHTS as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :TCP, :RIGHTS, '')
- }.should raise_error(SocketError)
- end
-
- it 'raises SocketError when using :MOO as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :TCP, :MOO, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_INET as the family and :UDP as the level' do
- with_feature :udp_cork do
- it 'sets the type to UDP_CORK when using :CORK as the type argument' do
- Socket::AncillaryData.new(:INET, :UDP, :CORK, '').type.should == Socket::UDP_CORK
- end
- end
-
- it 'raises SocketError when using :RIGHTS as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :UDP, :RIGHTS, '')
- }.should raise_error(SocketError)
- end
-
- it 'raises SocketError when using :MOO as the type argument' do
- -> {
- Socket::AncillaryData.new(:INET, :UDP, :MOO, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_UNIX as the family and :SOCKET as the level' do
- it 'sets the type to SCM_RIGHTS when using :RIGHTS as the type argument' do
- Socket::AncillaryData.new(:UNIX, :SOCKET, :RIGHTS, '').type.should == Socket::SCM_RIGHTS
- end
-
- it 'raises SocketError when using :CORK sa the type argument' do
- -> {
- Socket::AncillaryData.new(:UNIX, :SOCKET, :CORK, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_UNIX as the family and :IP as the level' do
- it 'raises SocketError' do
- -> {
- Socket::AncillaryData.new(:UNIX, :IP, :RECVTTL, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_UNIX as the family and :IPV6 as the level' do
- it 'raises SocketError' do
- -> {
- Socket::AncillaryData.new(:UNIX, :IPV6, :NEXTHOP, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_UNIX as the family and :TCP as the level' do
- it 'raises SocketError' do
- -> {
- Socket::AncillaryData.new(:UNIX, :TCP, :CORK, '')
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using :AF_UNIX as the family and :UDP as the level' do
- it 'raises SocketError' do
- -> {
- Socket::AncillaryData.new(:UNIX, :UDP, :CORK, '')
- }.should raise_error(SocketError)
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/int_spec.rb b/spec/ruby/library/socket/ancillarydata/int_spec.rb
deleted file mode 100644
index fe41a30a1a..0000000000
--- a/spec/ruby/library/socket/ancillarydata/int_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData.int' do
- before do
- @data = Socket::AncillaryData.int(:INET, :SOCKET, :RIGHTS, 4)
- end
-
- it 'returns a Socket::AncillaryData' do
- @data.should be_an_instance_of(Socket::AncillaryData)
- end
-
- it 'sets the family to AF_INET' do
- @data.family.should == Socket::AF_INET
- end
-
- it 'sets the level SOL_SOCKET' do
- @data.level.should == Socket::SOL_SOCKET
- end
-
- it 'sets the type SCM_RIGHTS' do
- @data.type.should == Socket::SCM_RIGHTS
- end
-
- it 'sets the data to a packed String' do
- @data.data.should == [4].pack('I')
- end
- end
-
- describe 'Socket::AncillaryData#int' do
- it 'returns the data as an Integer' do
- data = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, 4)
-
- data.int.should == 4
- end
-
- it 'raises when the data is not an Integer' do
- data = Socket::AncillaryData.new(:UNIX, :SOCKET, :RIGHTS, 'ugh')
-
- -> { data.int }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb b/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb
deleted file mode 100644
index 84910a038a..0000000000
--- a/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb
+++ /dev/null
@@ -1,145 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data, :pktinfo do
- describe 'Socket::AncillaryData.ip_pktinfo' do
- describe 'with a source address and index' do
- before do
- @data = Socket::AncillaryData.ip_pktinfo(Addrinfo.ip('127.0.0.1'), 4)
- end
-
- it 'returns a Socket::AncillaryData' do
- @data.should be_an_instance_of(Socket::AncillaryData)
- end
-
- it 'sets the family to AF_INET' do
- @data.family.should == Socket::AF_INET
- end
-
- it 'sets the level to IPPROTO_IP' do
- @data.level.should == Socket::IPPROTO_IP
- end
-
- it 'sets the type to IP_PKTINFO' do
- @data.type.should == Socket::IP_PKTINFO
- end
- end
-
- describe 'with a source address, index, and destination address' do
- before do
- source = Addrinfo.ip('127.0.0.1')
- dest = Addrinfo.ip('127.0.0.5')
- @data = Socket::AncillaryData.ip_pktinfo(source, 4, dest)
- end
-
- it 'returns a Socket::AncillaryData' do
- @data.should be_an_instance_of(Socket::AncillaryData)
- end
-
- it 'sets the family to AF_INET' do
- @data.family.should == Socket::AF_INET
- end
-
- it 'sets the level to IPPROTO_IP' do
- @data.level.should == Socket::IPPROTO_IP
- end
-
- it 'sets the type to IP_PKTINFO' do
- @data.type.should == Socket::IP_PKTINFO
- end
- end
- end
-
- describe 'Socket::AncillaryData#ip_pktinfo' do
- describe 'using an Addrinfo without a port number' do
- before do
- @source = Addrinfo.ip('127.0.0.1')
- @dest = Addrinfo.ip('127.0.0.5')
- @data = Socket::AncillaryData.ip_pktinfo(@source, 4, @dest)
- end
-
- it 'returns an Array' do
- @data.ip_pktinfo.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @info = @data.ip_pktinfo
- end
-
- it 'stores an Addrinfo at index 0' do
- @info[0].should be_an_instance_of(Addrinfo)
- end
-
- it 'stores the ifindex at index 1' do
- @info[1].should be_kind_of(Integer)
- end
-
- it 'stores an Addrinfo at index 2' do
- @info[2].should be_an_instance_of(Addrinfo)
- end
- end
-
- describe 'the source Addrinfo' do
- before do
- @addr = @data.ip_pktinfo[0]
- end
-
- it 'uses the correct IP address' do
- @addr.ip_address.should == '127.0.0.1'
- end
-
- it 'is not the same object as the input Addrinfo' do
- @addr.should_not equal @source
- end
- end
-
- describe 'the ifindex' do
- it 'is an Integer' do
- @data.ip_pktinfo[1].should == 4
- end
- end
-
- describe 'the destination Addrinfo' do
- before do
- @addr = @data.ip_pktinfo[2]
- end
-
- it 'uses the correct IP address' do
- @addr.ip_address.should == '127.0.0.5'
- end
-
- it 'is not the same object as the input Addrinfo' do
- @addr.should_not equal @dest
- end
- end
- end
-
- describe 'using an Addrinfo with a port number' do
- before do
- @source = Addrinfo.tcp('127.0.0.1', 80)
- @dest = Addrinfo.tcp('127.0.0.5', 85)
- @data = Socket::AncillaryData.ip_pktinfo(@source, 4, @dest)
- end
-
- describe 'the source Addrinfo' do
- before do
- @addr = @data.ip_pktinfo[0]
- end
-
- it 'does not contain a port number' do
- @addr.ip_port.should == 0
- end
- end
-
- describe 'the destination Addrinfo' do
- before do
- @addr = @data.ip_pktinfo[2]
- end
-
- it 'does not contain a port number' do
- @addr.ip_port.should == 0
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb
deleted file mode 100644
index f70fe27d6a..0000000000
--- a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data, :ipv6_pktinfo do
- describe 'Socket::AncillaryData#ipv6_pktinfo_addr' do
- it 'returns an Addrinfo' do
- data = Socket::AncillaryData.ipv6_pktinfo(Addrinfo.ip('::1'), 4)
-
- data.ipv6_pktinfo_addr.should be_an_instance_of(Addrinfo)
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_ifindex_spec.rb b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_ifindex_spec.rb
deleted file mode 100644
index bda37eec98..0000000000
--- a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_ifindex_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data, :ipv6_pktinfo do
- describe 'Socket::AncillaryData#ipv6_pktinfo_ifindex' do
- it 'returns an Addrinfo' do
- data = Socket::AncillaryData.ipv6_pktinfo(Addrinfo.ip('::1'), 4)
-
- data.ipv6_pktinfo_ifindex.should == 4
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb
deleted file mode 100644
index 0fffc720dc..0000000000
--- a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data, :ipv6_pktinfo do
- describe 'Socket::AncillaryData.ipv6_pktinfo' do
- before do
- @data = Socket::AncillaryData.ipv6_pktinfo(Addrinfo.ip('::1'), 4)
- end
-
- it 'returns a Socket::AncillaryData' do
- @data.should be_an_instance_of(Socket::AncillaryData)
- end
-
- it 'sets the family to AF_INET' do
- @data.family.should == Socket::AF_INET6
- end
-
- it 'sets the level to IPPROTO_IP' do
- @data.level.should == Socket::IPPROTO_IPV6
- end
-
- it 'sets the type to IP_PKTINFO' do
- @data.type.should == Socket::IPV6_PKTINFO
- end
- end
-
- describe 'Socket::AncillaryData#ipv6_pktinfo' do
- describe 'using an Addrinfo without a port number' do
- before do
- @source = Addrinfo.ip('::1')
- @data = Socket::AncillaryData.ipv6_pktinfo(@source, 4)
- end
-
- it 'returns an Array' do
- @data.ipv6_pktinfo.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @info = @data.ipv6_pktinfo
- end
-
- it 'stores an Addrinfo at index 0' do
- @info[0].should be_an_instance_of(Addrinfo)
- end
-
- it 'stores the ifindex at index 1' do
- @info[1].should be_kind_of(Integer)
- end
- end
-
- describe 'the source Addrinfo' do
- before do
- @addr = @data.ipv6_pktinfo[0]
- end
-
- it 'uses the correct IP address' do
- @addr.ip_address.should == '::1'
- end
-
- it 'is not the same object as the input Addrinfo' do
- @addr.should_not equal @source
- end
- end
-
- describe 'the ifindex' do
- it 'is an Integer' do
- @data.ipv6_pktinfo[1].should == 4
- end
- end
- end
-
- describe 'using an Addrinfo with a port number' do
- before do
- @source = Addrinfo.tcp('::1', 80)
- @data = Socket::AncillaryData.ipv6_pktinfo(@source, 4)
- end
-
- describe 'the source Addrinfo' do
- before do
- @addr = @data.ipv6_pktinfo[0]
- end
-
- it 'does not contain a port number' do
- @addr.ip_port.should == 0
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/level_spec.rb b/spec/ruby/library/socket/ancillarydata/level_spec.rb
deleted file mode 100644
index a2ff216f9d..0000000000
--- a/spec/ruby/library/socket/ancillarydata/level_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData#level' do
- it 'returns the level as an Integer' do
- Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').level.should == Socket::SOL_SOCKET
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/type_spec.rb b/spec/ruby/library/socket/ancillarydata/type_spec.rb
deleted file mode 100644
index 972beeeca0..0000000000
--- a/spec/ruby/library/socket/ancillarydata/type_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData#type' do
- it 'returns the type as an Integer' do
- Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').type.should == Socket::SCM_RIGHTS
- end
- end
-end
diff --git a/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb b/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb
deleted file mode 100644
index 65ffcb01af..0000000000
--- a/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :ancillary_data do
- describe 'Socket::AncillaryData.unix_rights' do
- describe 'using a list of IO objects' do
- before do
- @data = Socket::AncillaryData.unix_rights(STDOUT, STDERR)
- end
-
- it 'sets the family to AF_UNIX' do
- @data.family.should == Socket::AF_UNIX
- end
-
- it 'sets the level to SOL_SOCKET' do
- @data.level.should == Socket::SOL_SOCKET
- end
-
- it 'sets the type to SCM_RIGHTS' do
- @data.type.should == Socket::SCM_RIGHTS
- end
-
- it 'sets the data to a String containing the file descriptors' do
- @data.data.unpack('I*').should == [STDOUT.fileno, STDERR.fileno]
- end
- end
-
- describe 'using non IO objects' do
- it 'raises TypeError' do
- -> { Socket::AncillaryData.unix_rights(10) }.should raise_error(TypeError)
- end
- end
- end
-
- describe 'Socket::AncillaryData#unix_rights' do
- it 'returns the data as an Array of IO objects' do
- data = Socket::AncillaryData.unix_rights(STDOUT, STDERR)
-
- data.unix_rights.should == [STDOUT, STDERR]
- end
-
- it 'returns nil when the data is not a list of file descriptors' do
- data = Socket::AncillaryData.new(:UNIX, :SOCKET, :RIGHTS, '')
-
- data.unix_rights.should be_nil
- end
-
- it 'raises TypeError when the level is not SOL_SOCKET' do
- data = Socket::AncillaryData.new(:INET, :IP, :RECVTTL, '')
-
- -> { data.unix_rights }.should raise_error(TypeError)
- end
-
- platform_is_not :"solaris2.10", :aix do
- it 'raises TypeError when the type is not SCM_RIGHTS' do
- data = Socket::AncillaryData.new(:INET, :SOCKET, :TIMESTAMP, '')
-
- -> { data.unix_rights }.should raise_error(TypeError)
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/close_read_spec.rb b/spec/ruby/library/socket/basicsocket/close_read_spec.rb
index f317b34955..c71e1acaf9 100644
--- a/spec/ruby/library/socket/basicsocket/close_read_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/close_read_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::BasicSocket#close_read" do
before :each do
@@ -12,16 +12,16 @@ describe "Socket::BasicSocket#close_read" do
it "closes the reading end of the socket" do
@server.close_read
- -> { @server.read }.should raise_error(IOError)
+ lambda { @server.read }.should raise_error(IOError)
end
- it 'does not raise when called on a socket already closed for reading' do
+ it "it works on sockets with closed ends" do
@server.close_read
- @server.close_read
- -> { @server.read }.should raise_error(IOError)
+ lambda { @server.close_read }.should_not raise_error(Exception)
+ lambda { @server.read }.should raise_error(IOError)
end
- it 'does not fully close the socket' do
+ it "does not close the socket" do
@server.close_read
@server.closed?.should be_false
end
@@ -32,9 +32,9 @@ describe "Socket::BasicSocket#close_read" do
@server.closed?.should be_true
end
- it 'raises IOError when called on a fully closed socket' do
+ it "raises IOError on closed socket" do
@server.close
- -> { @server.close_read }.should raise_error(IOError)
+ lambda { @server.close_read }.should raise_error(IOError)
end
it "returns nil" do
diff --git a/spec/ruby/library/socket/basicsocket/close_write_spec.rb b/spec/ruby/library/socket/basicsocket/close_write_spec.rb
index 232cfbb7c6..a00f5d5870 100644
--- a/spec/ruby/library/socket/basicsocket/close_write_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/close_write_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::BasicSocket#close_write" do
before :each do
@@ -12,16 +12,16 @@ describe "Socket::BasicSocket#close_write" do
it "closes the writing end of the socket" do
@server.close_write
- -> { @server.write("foo") }.should raise_error(IOError)
+ lambda { @server.write("foo") }.should raise_error(IOError)
end
- it 'does not raise when called on a socket already closed for writing' do
+ it "works on sockets with closed write ends" do
@server.close_write
- @server.close_write
- -> { @server.write("foo") }.should raise_error(IOError)
+ lambda { @server.close_write }.should_not raise_error(Exception)
+ lambda { @server.write("foo") }.should raise_error(IOError)
end
- it 'does not fully close the socket' do
+ it "does not close the socket" do
@server.close_write
@server.closed?.should be_false
end
@@ -37,9 +37,9 @@ describe "Socket::BasicSocket#close_write" do
@server.closed?.should be_true
end
- it 'raises IOError when called on a fully closed socket' do
+ it "raises IOError on closed socket" do
@server.close
- -> { @server.close_write }.should raise_error(IOError)
+ lambda { @server.close_write }.should raise_error(IOError)
end
it "returns nil" do
diff --git a/spec/ruby/library/socket/basicsocket/connect_address_spec.rb b/spec/ruby/library/socket/basicsocket/connect_address_spec.rb
deleted file mode 100644
index 1a1c9982d9..0000000000
--- a/spec/ruby/library/socket/basicsocket/connect_address_spec.rb
+++ /dev/null
@@ -1,154 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket#connect_address' do
- describe 'using an unbound socket' do
- after do
- @sock.close
- end
-
- it 'raises SocketError' do
- @sock = Socket.new(:INET, :STREAM)
-
- -> { @sock.connect_address }.should raise_error(SocketError)
- end
- end
-
- describe 'using a socket bound to 0.0.0.0' do
- before do
- @sock = Socket.new(:INET, :STREAM)
- @sock.bind(Socket.sockaddr_in(0, '0.0.0.0'))
- end
-
- after do
- @sock.close
- end
-
- it 'returns an Addrinfo' do
- @sock.connect_address.should be_an_instance_of(Addrinfo)
- end
-
- it 'uses 127.0.0.1 as the IP address' do
- @sock.connect_address.ip_address.should == '127.0.0.1'
- end
-
- it 'uses the correct port number' do
- @sock.connect_address.ip_port.should > 0
- end
-
- it 'uses AF_INET as the address family' do
- @sock.connect_address.afamily.should == Socket::AF_INET
- end
-
- it 'uses PF_INET as the address family' do
- @sock.connect_address.pfamily.should == Socket::PF_INET
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @sock.connect_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses 0 as the protocol' do
- @sock.connect_address.protocol.should == 0
- end
- end
-
- guard -> { SocketSpecs.ipv6_available? } do
- describe 'using a socket bound to ::' do
- before do
- @sock = Socket.new(:INET6, :STREAM)
- @sock.bind(Socket.sockaddr_in(0, '::'))
- end
-
- after do
- @sock.close
- end
-
- it 'returns an Addrinfo' do
- @sock.connect_address.should be_an_instance_of(Addrinfo)
- end
-
- it 'uses ::1 as the IP address' do
- @sock.connect_address.ip_address.should == '::1'
- end
-
- it 'uses the correct port number' do
- @sock.connect_address.ip_port.should > 0
- end
-
- it 'uses AF_INET6 as the address family' do
- @sock.connect_address.afamily.should == Socket::AF_INET6
- end
-
- it 'uses PF_INET6 as the address family' do
- @sock.connect_address.pfamily.should == Socket::PF_INET6
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @sock.connect_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses 0 as the protocol' do
- @sock.connect_address.protocol.should == 0
- end
- end
- end
-
- with_feature :unix_socket do
- platform_is_not :aix do
- describe 'using an unbound UNIX socket' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- @client = UNIXSocket.new(@path)
- end
-
- after do
- @client.close
- @server.close
- rm_r(@path)
- end
-
- it 'raises SocketError' do
- -> { @client.connect_address }.should raise_error(SocketError)
- end
- end
- end
-
- describe 'using a bound UNIX socket' do
- before do
- @path = SocketSpecs.socket_path
- @sock = UNIXServer.new(@path)
- end
-
- after do
- @sock.close
- rm_r(@path)
- end
-
- it 'returns an Addrinfo' do
- @sock.connect_address.should be_an_instance_of(Addrinfo)
- end
-
- it 'uses the correct socket path' do
- @sock.connect_address.unix_path.should == @path
- end
-
- it 'uses AF_UNIX as the address family' do
- @sock.connect_address.afamily.should == Socket::AF_UNIX
- end
-
- it 'uses PF_UNIX as the protocol family' do
- @sock.connect_address.pfamily.should == Socket::PF_UNIX
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @sock.connect_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses 0 as the protocol' do
- @sock.connect_address.protocol.should == 0
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb b/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb
index a8800a8493..3ef3a686e2 100644
--- a/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "BasicSocket.do_not_reverse_lookup" do
before :each do
@@ -37,67 +37,3 @@ describe "BasicSocket.do_not_reverse_lookup" do
@socket.peeraddr[2].should == "127.0.0.1"
end
end
-
-describe :socket_do_not_reverse_lookup, shared: true do
- it "inherits from BasicSocket.do_not_reverse_lookup when the socket is created" do
- @socket = @method.call
- reverse = BasicSocket.do_not_reverse_lookup
- @socket.do_not_reverse_lookup.should == reverse
-
- BasicSocket.do_not_reverse_lookup = !reverse
- @socket.do_not_reverse_lookup.should == reverse
- end
-
- it "is true when BasicSocket.do_not_reverse_lookup is true" do
- BasicSocket.do_not_reverse_lookup = true
- @socket = @method.call
- @socket.do_not_reverse_lookup.should == true
- end
-
- it "is false when BasicSocket.do_not_reverse_lookup is false" do
- BasicSocket.do_not_reverse_lookup = false
- @socket = @method.call
- @socket.do_not_reverse_lookup.should == false
- end
-
- it "can be changed with #do_not_reverse_lookup=" do
- @socket = @method.call
- reverse = @socket.do_not_reverse_lookup
- @socket.do_not_reverse_lookup = !reverse
- @socket.do_not_reverse_lookup.should == !reverse
- end
-end
-
-describe "BasicSocket#do_not_reverse_lookup" do
- before :each do
- @do_not_reverse_lookup = BasicSocket.do_not_reverse_lookup
- @server = TCPServer.new('127.0.0.1', 0)
- @port = @server.addr[1]
- end
-
- after :each do
- @server.close unless @server.closed?
- @socket.close if @socket && !@socket.closed?
- BasicSocket.do_not_reverse_lookup = @do_not_reverse_lookup
- end
-
- describe "for an TCPSocket.new socket" do
- it_behaves_like :socket_do_not_reverse_lookup, -> {
- TCPSocket.new('127.0.0.1', @port)
- }
- end
-
- describe "for an TCPServer#accept socket" do
- before :each do
- @client = TCPSocket.new('127.0.0.1', @port)
- end
-
- after :each do
- @client.close if @client && !@client.closed?
- end
-
- it_behaves_like :socket_do_not_reverse_lookup, -> {
- @server.accept
- }
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/for_fd_spec.rb b/spec/ruby/library/socket/basicsocket/for_fd_spec.rb
index 9c9e6a8b55..164e4dc93c 100644
--- a/spec/ruby/library/socket/basicsocket/for_fd_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/for_fd_spec.rb
@@ -1,14 +1,14 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-describe "BasicSocket.for_fd" do
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "BasicSocket#for_fd" do
before :each do
@server = TCPServer.new(0)
@s2 = nil
end
after :each do
- @socket1.close if @socket1
@server.close if @server
end
@@ -18,21 +18,4 @@ describe "BasicSocket.for_fd" do
@s2.should be_kind_of(TCPServer)
@s2.fileno.should == @server.fileno
end
-
- it 'returns a new socket for a file descriptor' do
- @socket1 = Socket.new(:INET, :DGRAM)
- socket2 = Socket.for_fd(@socket1.fileno)
- socket2.autoclose = false
-
- socket2.should be_an_instance_of(Socket)
- socket2.fileno.should == @socket1.fileno
- end
-
- it 'sets the socket into binary mode' do
- @socket1 = Socket.new(:INET, :DGRAM)
- socket2 = Socket.for_fd(@socket1.fileno)
- socket2.autoclose = false
-
- socket2.binmode?.should be_true
- end
end
diff --git a/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb b/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb
deleted file mode 100644
index 6179211d96..0000000000
--- a/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'BasicSocket#getpeereid' do
- with_feature :unix_socket do
- describe 'using a UNIXSocket' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- @client = UNIXSocket.new(@path)
- end
-
- after do
- @client.close
- @server.close
-
- rm_r(@path)
- end
-
- it 'returns an Array with the user and group ID' do
- @client.getpeereid.should == [Process.euid, Process.egid]
- end
- end
- end
-
- describe 'using an IPSocket' do
- after do
- @sock.close
- end
-
- it 'raises NoMethodError' do
- @sock = TCPServer.new('127.0.0.1', 0)
- -> { @sock.getpeereid }.should raise_error(NoMethodError)
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/getpeername_spec.rb b/spec/ruby/library/socket/basicsocket/getpeername_spec.rb
index 0b93f02eef..cecf590092 100644
--- a/spec/ruby/library/socket/basicsocket/getpeername_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/getpeername_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::BasicSocket#getpeername" do
@@ -19,7 +19,8 @@ describe "Socket::BasicSocket#getpeername" do
@client.getpeername.should == server_sockaddr
end
- it 'raises Errno::ENOTCONN for a disconnected socket' do
- -> { @server.getpeername }.should raise_error(Errno::ENOTCONN)
+ # Catch general exceptions to prevent NotImplementedError
+ it "raises an error if socket's not connected" do
+ lambda { @server.getpeername }.should raise_error(Exception)
end
end
diff --git a/spec/ruby/library/socket/basicsocket/getsockname_spec.rb b/spec/ruby/library/socket/basicsocket/getsockname_spec.rb
index b33db088b6..cb3a45eb5f 100644
--- a/spec/ruby/library/socket/basicsocket/getsockname_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/getsockname_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::BasicSocket#getsockname" do
after :each do
@@ -7,7 +7,7 @@ describe "Socket::BasicSocket#getsockname" do
@socket.close
end
- it "returns the sockaddr associated with the socket" do
+ it "returns the sockaddr associacted with the socket" do
@socket = TCPServer.new("127.0.0.1", 0)
sockaddr = Socket.unpack_sockaddr_in(@socket.getsockname)
sockaddr.should == [@socket.addr[1], "127.0.0.1"]
@@ -20,7 +20,7 @@ describe "Socket::BasicSocket#getsockname" do
sockaddr[0].should == @socket.addr[1]
end
- it 'returns a default socket address for a disconnected socket' do
+ it "returns empty sockaddr for unbinded sockets" do
@socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
sockaddr = Socket.unpack_sockaddr_in(@socket.getsockname)
sockaddr.should == [0, "0.0.0.0"]
diff --git a/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb b/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb
index ce65d6c92b..dc4fffa5c1 100644
--- a/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "BasicSocket#getsockopt" do
before :each do
@@ -41,148 +41,6 @@ describe "BasicSocket#getsockopt" do
end
it "raises a SystemCallError with an invalid socket option" do
- -> { @sock.getsockopt Socket::SOL_SOCKET, -1 }.should raise_error(Errno::ENOPROTOOPT)
- end
-
- it 'returns a Socket::Option using a constant' do
- opt = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_TYPE)
-
- opt.should be_an_instance_of(Socket::Option)
- end
-
- it 'returns a Socket::Option for a boolean option' do
- opt = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR)
-
- opt.bool.should == false
- end
-
- it 'returns a Socket::Option for a numeric option' do
- opt = @sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL)
-
- opt.int.should be_kind_of(Integer)
- end
-
- it 'returns a Socket::Option for a struct option' do
- opt = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER)
-
- opt.linger.should == [false, 0]
- end
-
- it 'raises Errno::ENOPROTOOPT when requesting an invalid option' do
- -> { @sock.getsockopt(Socket::SOL_SOCKET, -1) }.should raise_error(Errno::ENOPROTOOPT)
- end
-
- describe 'using Symbols as arguments' do
- it 'returns a Socket::Option for arguments :SOCKET and :TYPE' do
- opt = @sock.getsockopt(:SOCKET, :TYPE)
-
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_TYPE
- end
-
- it 'returns a Socket::Option for arguments :IP and :TTL' do
- opt = @sock.getsockopt(:IP, :TTL)
-
- opt.level.should == Socket::IPPROTO_IP
- opt.optname.should == Socket::IP_TTL
- end
-
- it 'returns a Socket::Option for arguments :SOCKET and :REUSEADDR' do
- opt = @sock.getsockopt(:SOCKET, :REUSEADDR)
-
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_REUSEADDR
- end
-
- it 'returns a Socket::Option for arguments :SOCKET and :LINGER' do
- opt = @sock.getsockopt(:SOCKET, :LINGER)
-
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_LINGER
- end
-
- with_feature :udp_cork do
- it 'returns a Socket::Option for arguments :UDP and :CORK' do
- sock = Socket.new(:INET, :DGRAM)
- begin
- opt = sock.getsockopt(:UDP, :CORK)
-
- opt.level.should == Socket::IPPROTO_UDP
- opt.optname.should == Socket::UDP_CORK
- ensure
- sock.close
- end
- end
- end
- end
-
- describe 'using Strings as arguments' do
- it 'returns a Socket::Option for arguments "SOCKET" and "TYPE"' do
- opt = @sock.getsockopt("SOCKET", "TYPE")
-
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_TYPE
- end
-
- it 'returns a Socket::Option for arguments "IP" and "TTL"' do
- opt = @sock.getsockopt("IP", "TTL")
-
- opt.level.should == Socket::IPPROTO_IP
- opt.optname.should == Socket::IP_TTL
- end
-
- it 'returns a Socket::Option for arguments "SOCKET" and "REUSEADDR"' do
- opt = @sock.getsockopt("SOCKET", "REUSEADDR")
-
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_REUSEADDR
- end
-
- it 'returns a Socket::Option for arguments "SOCKET" and "LINGER"' do
- opt = @sock.getsockopt("SOCKET", "LINGER")
-
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_LINGER
- end
-
- with_feature :udp_cork do
- it 'returns a Socket::Option for arguments "UDP" and "CORK"' do
- sock = Socket.new("INET", "DGRAM")
- begin
- opt = sock.getsockopt("UDP", "CORK")
-
- opt.level.should == Socket::IPPROTO_UDP
- opt.optname.should == Socket::UDP_CORK
- ensure
- sock.close
- end
- end
- end
- end
-
- describe 'using a String based option' do
- it 'allows unpacking of a boolean option' do
- opt = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR).to_s
-
- opt.unpack('i').should == [0]
- end
-
- it 'allows unpacking of a numeric option' do
- opt = @sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL).to_s
- array = opt.unpack('i')
-
- array[0].should be_kind_of(Integer)
- array[0].should > 0
- end
-
- it 'allows unpacking of a struct option' do
- opt = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER).to_s
-
- if opt.bytesize == 8
- opt.unpack('ii').should == [0, 0]
- else
- opt.unpack('i').should == [0]
- end
- end
+ lambda { @sock.getsockopt Socket::SOL_SOCKET, -1 }.should raise_error(Errno::ENOPROTOOPT)
end
end
diff --git a/spec/ruby/library/socket/basicsocket/ioctl_spec.rb b/spec/ruby/library/socket/basicsocket/ioctl_spec.rb
index 615d92bea8..9a7f535317 100644
--- a/spec/ruby/library/socket/basicsocket/ioctl_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/ioctl_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'socket'
describe "Socket::BasicSocket#ioctl" do
platform_is :linux do
diff --git a/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb
deleted file mode 100644
index 1823f3d75d..0000000000
--- a/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-ruby_version_is "2.5" do
- describe "BasicSocket#read_nonblock" do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before :each do
- @r = Socket.new(family, :DGRAM)
- @w = Socket.new(family, :DGRAM)
-
- @r.bind(Socket.pack_sockaddr_in(0, ip_address))
- @w.send("aaa", 0, @r.getsockname)
- end
-
- after :each do
- @r.close unless @r.closed?
- @w.close unless @w.closed?
- end
-
- it "receives data after it's ready" do
- IO.select([@r], nil, nil, 2)
- @r.recv_nonblock(5).should == "aaa"
- end
-
- platform_is :linux do
- it 'does not set the IO in nonblock mode' do
- require 'io/nonblock'
- @r.nonblock?.should == false
- IO.select([@r], nil, nil, 2)
- @r.read_nonblock(3).should == "aaa"
- @r.nonblock?.should == false
- end
- end
-
- platform_is_not :linux, :windows do
- it 'sets the IO in nonblock mode' do
- require 'io/nonblock'
- @r.nonblock?.should == false
- IO.select([@r], nil, nil, 2)
- @r.read_nonblock(3).should == "aaa"
- @r.nonblock?.should == true
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb
index 0363f2f8de..2c948eaa2f 100644
--- a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb
@@ -1,70 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/recv_nonblock', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::BasicSocket#recv_nonblock" do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before :each do
- @s1 = Socket.new(family, :DGRAM)
- @s2 = Socket.new(family, :DGRAM)
- end
-
- after :each do
- @s1.close unless @s1.closed?
- @s2.close unless @s2.closed?
- end
-
- platform_is_not :windows do
- describe 'using an unbound socket' do
- it 'raises an exception extending IO::WaitReadable' do
- -> { @s1.recv_nonblock(1) }.should raise_error(IO::WaitReadable)
- end
- end
- end
-
- it "raises an exception extending IO::WaitReadable if there's no data available" do
- @s1.bind(Socket.pack_sockaddr_in(0, ip_address))
- -> {
- @s1.recv_nonblock(5)
- }.should raise_error(IO::WaitReadable) { |e|
- platform_is_not :windows do
- e.should be_kind_of(Errno::EAGAIN)
- end
- platform_is :windows do
- e.should be_kind_of(Errno::EWOULDBLOCK)
- end
- }
- end
-
- it "returns :wait_readable with exception: false" do
- @s1.bind(Socket.pack_sockaddr_in(0, ip_address))
- @s1.recv_nonblock(5, exception: false).should == :wait_readable
- end
-
- it "receives data after it's ready" do
- @s1.bind(Socket.pack_sockaddr_in(0, ip_address))
- @s2.send("aaa", 0, @s1.getsockname)
- IO.select([@s1], nil, nil, 2)
- @s1.recv_nonblock(5).should == "aaa"
- end
-
- it "allows an output buffer as third argument" do
- @s1.bind(Socket.pack_sockaddr_in(0, ip_address))
- @s2.send("data", 0, @s1.getsockname)
- IO.select([@s1], nil, nil, 2)
-
- buf = "foo"
- @s1.recv_nonblock(5, 0, buf)
- buf.should == "data"
- end
-
- it "does not block if there's no data available" do
- @s1.bind(Socket.pack_sockaddr_in(0, ip_address))
- @s2.send("a", 0, @s1.getsockname)
- IO.select([@s1], nil, nil, 2)
- @s1.recv_nonblock(1).should == "a"
- -> {
- @s1.recv_nonblock(5)
- }.should raise_error(IO::WaitReadable)
- end
- end
+ it_behaves_like :socket_recv_nonblock, :recv_nonblock
end
diff --git a/spec/ruby/library/socket/basicsocket/recv_spec.rb b/spec/ruby/library/socket/basicsocket/recv_spec.rb
index b6ccda5d00..5891bf9c87 100644
--- a/spec/ruby/library/socket/basicsocket/recv_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/recv_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "BasicSocket#recv" do
@@ -76,84 +76,21 @@ describe "BasicSocket#recv" do
ScratchPad.recorded.should == "firstline\377"
end
- it "allows an output buffer as third argument" do
- socket = TCPSocket.new('127.0.0.1', @port)
- socket.write("data")
-
- client = @server.accept
- buf = "foo"
- begin
- client.recv(4, 0, buf)
- ensure
- client.close
- end
- buf.should == "data"
-
- socket.close
- end
-end
-
-describe 'BasicSocket#recv' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :DGRAM)
- @client = Socket.new(family, :DGRAM)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'using an unbound socket' do
- it 'blocks the caller' do
- -> { @server.recv(4) }.should block_caller
- end
- end
-
- describe 'using a bound socket' do
- before do
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
+ ruby_version_is "2.3" do
+ it "allows an output buffer as third argument" do
+ socket = TCPSocket.new('127.0.0.1', @port)
+ socket.write("data")
- describe 'without any data available' do
- it 'blocks the caller' do
- -> { @server.recv(4) }.should block_caller
- end
+ client = @server.accept
+ buf = "foo"
+ begin
+ client.recv(4, 0, buf)
+ ensure
+ client.close
end
+ buf.should == "data"
- describe 'with data available' do
- before do
- @client.connect(@server.getsockname)
- end
-
- it 'reads the given amount of bytes' do
- @client.write('hello')
-
- @server.recv(2).should == 'he'
- end
-
- it 'reads the given amount of bytes when it exceeds the data size' do
- @client.write('he')
-
- @server.recv(6).should == 'he'
- end
-
- it 'blocks the caller when called twice without new data being available' do
- @client.write('hello')
-
- @server.recv(2).should == 'he'
-
- -> { @server.recv(4) }.should block_caller
- end
-
- it 'takes a peek at the data when using the MSG_PEEK flag' do
- @client.write('hello')
-
- @server.recv(2, Socket::MSG_PEEK).should == 'he'
- @server.recv(2).should == 'he'
- end
- end
+ socket.close
end
end
end
diff --git a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb
deleted file mode 100644
index 8e6c232c59..0000000000
--- a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb
+++ /dev/null
@@ -1,209 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'BasicSocket#recvmsg_nonblock' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a disconnected socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
- end
-
- after do
- @client.close
- @server.close
- end
-
- platform_is_not :windows do
- describe 'using an unbound socket' do
- it 'raises an exception extending IO::WaitReadable' do
- -> { @server.recvmsg_nonblock }.should raise_error(IO::WaitReadable)
- end
- end
- end
-
- describe 'using a bound socket' do
- before do
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- describe 'without any data available' do
- it 'raises an exception extending IO::WaitReadable' do
- -> { @server.recvmsg_nonblock }.should raise_error(IO::WaitReadable)
- end
-
- it 'returns :wait_readable with exception: false' do
- @server.recvmsg_nonblock(exception: false).should == :wait_readable
- end
- end
-
- describe 'with data available' do
- before do
- @client.connect(@server.getsockname)
-
- @client.write('hello')
-
- IO.select([@server], nil, nil, 5)
- end
-
- it 'returns an Array containing the data, an Addrinfo and the flags' do
- @server.recvmsg_nonblock.should be_an_instance_of(Array)
- end
-
- describe 'without a maximum message length' do
- it 'reads all the available data' do
- @server.recvmsg_nonblock[0].should == 'hello'
- end
- end
-
- describe 'with a maximum message length' do
- platform_is_not :windows do
- it 'reads up to the maximum amount of bytes' do
- @server.recvmsg_nonblock(2)[0].should == 'he'
- end
- end
- end
-
- describe 'the returned Array' do
- before do
- @array = @server.recvmsg_nonblock
- end
-
- it 'stores the message at index 0' do
- @array[0].should == 'hello'
- end
-
- it 'stores an Addrinfo at index 1' do
- @array[1].should be_an_instance_of(Addrinfo)
- end
-
- platform_is_not :windows do
- it 'stores the flags at index 2' do
- @array[2].should be_kind_of(Integer)
- end
- end
-
- describe 'the returned Addrinfo' do
- before do
- @addr = @array[1]
- end
-
- it 'uses the IP address of the client' do
- @addr.ip_address.should == @client.local_address.ip_address
- end
-
- it 'uses the correct address family' do
- @addr.afamily.should == family
- end
-
- it 'uses the correct protocol family' do
- @addr.pfamily.should == family
- end
-
- it 'uses the correct socket type' do
- @addr.socktype.should == Socket::SOCK_DGRAM
- end
-
- it 'uses the port number of the client' do
- @addr.ip_port.should == @client.local_address.ip_port
- end
- end
- end
- end
- end
- end
-
- platform_is_not :windows do
- describe 'using a connected socket' do
- before do
- @client = Socket.new(family, :STREAM)
- @server = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @server.listen(1)
-
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without any data available' do
- it 'raises IO::WaitReadable' do
- -> {
- socket, _ = @server.accept
- begin
- socket.recvmsg_nonblock
- ensure
- socket.close
- end
- }.should raise_error(IO::WaitReadable)
- end
- end
-
- describe 'with data available' do
- before do
- @client.write('hello')
-
- @socket, _ = @server.accept
- IO.select([@socket])
- end
-
- after do
- @socket.close
- end
-
- it 'returns an Array containing the data, an Addrinfo and the flags' do
- @socket.recvmsg_nonblock.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = @socket.recvmsg_nonblock
- end
-
- it 'stores the message at index 0' do
- @array[0].should == 'hello'
- end
-
- it 'stores an Addrinfo at index 1' do
- @array[1].should be_an_instance_of(Addrinfo)
- end
-
- it 'stores the flags at index 2' do
- @array[2].should be_kind_of(Integer)
- end
-
- describe 'the returned Addrinfo' do
- before do
- @addr = @array[1]
- end
-
- it 'raises when receiving the ip_address message' do
- -> { @addr.ip_address }.should raise_error(SocketError)
- end
-
- it 'uses the correct address family' do
- @addr.afamily.should == Socket::AF_UNSPEC
- end
-
- it 'uses 0 for the protocol family' do
- @addr.pfamily.should == 0
- end
-
- it 'uses the correct socket type' do
- @addr.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'raises when receiving the ip_port message' do
- -> { @addr.ip_port }.should raise_error(SocketError)
- end
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb b/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb
deleted file mode 100644
index 8063723701..0000000000
--- a/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb
+++ /dev/null
@@ -1,197 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'BasicSocket#recvmsg' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a disconnected socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
- end
-
- after do
- @client.close
- @server.close
- end
-
- platform_is_not :windows do
- describe 'using an unbound socket' do
- it 'blocks the caller' do
- -> { @server.recvmsg }.should block_caller
- end
- end
- end
-
- describe 'using a bound socket' do
- before do
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- describe 'without any data available' do
- it 'blocks the caller' do
- -> { @server.recvmsg }.should block_caller
- end
- end
-
- describe 'with data available' do
- before do
- @client.connect(@server.getsockname)
-
- @client.write('hello')
- end
-
- it 'returns an Array containing the data, an Addrinfo and the flags' do
- @server.recvmsg.should be_an_instance_of(Array)
- end
-
- describe 'without a maximum message length' do
- it 'reads all the available data' do
- @server.recvmsg[0].should == 'hello'
- end
- end
-
- describe 'with a maximum message length' do
- it 'reads up to the maximum amount of bytes' do
- @server.recvmsg(2)[0].should == 'he'
- end
- end
-
- describe 'the returned Array' do
- before do
- @array = @server.recvmsg
- end
-
- it 'stores the message at index 0' do
- @array[0].should == 'hello'
- end
-
- it 'stores an Addrinfo at index 1' do
- @array[1].should be_an_instance_of(Addrinfo)
- end
-
- platform_is_not :windows do
- it 'stores the flags at index 2' do
- @array[2].should be_kind_of(Integer)
- end
- end
-
- describe 'the returned Addrinfo' do
- before do
- @addr = @array[1]
- end
-
- it 'uses the IP address of the client' do
- @addr.ip_address.should == @client.local_address.ip_address
- end
-
- it 'uses the correct address family' do
- @addr.afamily.should == family
- end
-
- it 'uses the correct protocol family' do
- @addr.pfamily.should == family
- end
-
- it 'uses the correct socket type' do
- @addr.socktype.should == Socket::SOCK_DGRAM
- end
-
- it 'uses the port number of the client' do
- @addr.ip_port.should == @client.local_address.ip_port
- end
- end
- end
- end
- end
- end
-
- platform_is_not :windows do
- describe 'using a connected socket' do
- before do
- @client = Socket.new(family, :STREAM)
- @server = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @server.listen(1)
-
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without any data available' do
- it 'blocks the caller' do
- socket, _ = @server.accept
- begin
- -> { socket.recvmsg }.should block_caller
- ensure
- socket.close
- end
- end
- end
-
- describe 'with data available' do
- before do
- @client.write('hello')
- @socket, _ = @server.accept
- end
-
- after do
- @socket.close
- end
-
- it 'returns an Array containing the data, an Addrinfo and the flags' do
- @socket.recvmsg.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = @socket.recvmsg
- end
-
- it 'stores the message at index 0' do
- @array[0].should == 'hello'
- end
-
- it 'stores an Addrinfo at index 1' do
- @array[1].should be_an_instance_of(Addrinfo)
- end
-
- it 'stores the flags at index 2' do
- @array[2].should be_kind_of(Integer)
- end
-
- describe 'the returned Addrinfo' do
- before do
- @addr = @array[1]
- end
-
- it 'raises when receiving the ip_address message' do
- -> { @addr.ip_address }.should raise_error(SocketError)
- end
-
- it 'uses the correct address family' do
- @addr.afamily.should == Socket::AF_UNSPEC
- end
-
- it 'returns 0 for the protocol family' do
- @addr.pfamily.should == 0
- end
-
- it 'uses the correct socket type' do
- @addr.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'raises when receiving the ip_port message' do
- -> { @addr.ip_port }.should raise_error(SocketError)
- end
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/send_spec.rb b/spec/ruby/library/socket/basicsocket/send_spec.rb
index 041ee46998..4df0d04a10 100644
--- a/spec/ruby/library/socket/basicsocket/send_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/send_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "BasicSocket#send" do
before :each do
@@ -83,130 +83,3 @@ describe "BasicSocket#send" do
data.should == 'hello'
end
end
-
-describe 'BasicSocket#send' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a disconnected socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without a destination address' do
- it "raises #{SocketSpecs.dest_addr_req_error}" do
- -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error)
- end
- end
-
- describe 'with a destination address as a String' do
- it 'returns the amount of sent bytes' do
- @client.send('hello', 0, @server.getsockname).should == 5
- end
-
- it 'does not persist the connection after writing to the socket' do
- @client.send('hello', 0, @server.getsockname)
-
- -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error)
- end
- end
-
- describe 'with a destination address as an Addrinfo' do
- it 'returns the amount of sent bytes' do
- @client.send('hello', 0, @server.connect_address).should == 5
- end
- end
- end
-
- describe 'using a connected UDP socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without a destination address argument' do
- before do
- @client.connect(@server.getsockname)
- end
-
- it 'returns the amount of bytes written' do
- @client.send('hello', 0).should == 5
- end
- end
-
- describe 'with a destination address argument' do
- before do
- @alt_server = Socket.new(family, :DGRAM)
-
- @alt_server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @alt_server.close
- end
-
- it 'sends the message to the given address instead' do
- @client.send('hello', 0, @alt_server.getsockname).should == 5
-
- -> { @server.recv(5) }.should block_caller
-
- @alt_server.recv(5).should == 'hello'
- end
-
- it 'does not persist the alternative connection after writing to the socket' do
- @client.send('hello', 0, @alt_server.getsockname)
-
- @client.connect(@server.getsockname)
- @client.send('world', 0)
-
- @server.recv(5).should == 'world'
- end
- end
- end
-
- platform_is_not :darwin, :windows do
- describe 'using a connected TCP socket' do
- before do
- @client = Socket.new(family, :STREAM)
- @server = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @server.listen(1)
-
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'using the MSG_OOB flag' do
- it 'sends an out-of-band message' do
- socket, _ = @server.accept
- socket.setsockopt(:SOCKET, :OOBINLINE, true)
- @client.send('a', Socket::MSG_OOB).should == 1
- begin
- socket.recv(10).should == 'a'
- ensure
- socket.close
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb
deleted file mode 100644
index c112f2ab4a..0000000000
--- a/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'BasicSocket#sendmsg_nonblock' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a disconnected socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without a destination address' do
- it "raises #{SocketSpecs.dest_addr_req_error}" do
- -> { @client.sendmsg_nonblock('hello') }.should raise_error(SocketSpecs.dest_addr_req_error)
- end
- end
-
- describe 'with a destination address as a String' do
- it 'returns the amount of sent bytes' do
- @client.sendmsg_nonblock('hello', 0, @server.getsockname).should == 5
- end
- end
-
- describe 'with a destination address as an Addrinfo' do
- it 'returns the amount of sent bytes' do
- @client.sendmsg_nonblock('hello', 0, @server.connect_address).should == 5
- end
- end
- end
-
- describe 'using a connected UDP socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without a destination address argument' do
- before do
- @client.connect(@server.getsockname)
- end
-
- it 'returns the amount of bytes written' do
- @client.sendmsg_nonblock('hello').should == 5
- end
- end
-
- describe 'with a destination address argument' do
- before do
- @alt_server = Socket.new(family, :DGRAM)
- @alt_server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @alt_server.close
- end
-
- it 'sends the message to the given address instead' do
- @client.sendmsg_nonblock('hello', 0, @alt_server.getsockname).should == 5
- -> { @server.recv(5) }.should block_caller
- @alt_server.recv(5).should == 'hello'
- end
- end
- end
-
- platform_is_not :windows do
- describe 'using a connected TCP socket' do
- before do
- @client = Socket.new(family, :STREAM)
- @server = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @server.listen(1)
-
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'raises IO::WaitWritable when the underlying buffer is full' do
- -> {
- 10.times { @client.sendmsg_nonblock('hello' * 1_000_000) }
- }.should raise_error(IO::WaitWritable)
- end
-
- it 'returns :wait_writable when the underlying buffer is full with exception: false' do
- ret = nil
- 10.times {
- ret = @client.sendmsg_nonblock('hello' * 1_000_000, exception: false)
- break unless ret.is_a?(Integer)
- }
- ret.should == :wait_writable
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb b/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb
deleted file mode 100644
index 7ff336c0b7..0000000000
--- a/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'BasicSocket#sendmsg' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a disconnected socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- platform_is_not :windows do
- describe 'without a destination address' do
- it "raises #{SocketSpecs.dest_addr_req_error}" do
- -> { @client.sendmsg('hello') }.should raise_error(SocketSpecs.dest_addr_req_error)
- end
- end
- end
-
- describe 'with a destination address as a String' do
- it 'returns the amount of sent bytes' do
- @client.sendmsg('hello', 0, @server.getsockname).should == 5
- end
- end
-
- describe 'with a destination address as an Addrinfo' do
- it 'returns the amount of sent bytes' do
- @client.sendmsg('hello', 0, @server.connect_address).should == 5
- end
- end
- end
-
- describe 'using a connected UDP socket' do
- before do
- @client = Socket.new(family, :DGRAM)
- @server = Socket.new(family, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without a destination address argument' do
- before do
- @client.connect(@server.getsockname)
- end
-
- it 'returns the amount of bytes written' do
- @client.sendmsg('hello').should == 5
- end
- end
-
- describe 'with a destination address argument' do
- before do
- @alt_server = Socket.new(family, :DGRAM)
-
- @alt_server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @alt_server.close
- end
-
- it 'sends the message to the given address instead' do
- @client.sendmsg('hello', 0, @alt_server.getsockname).should == 5
-
- -> { @server.recv(5) }.should block_caller
-
- @alt_server.recv(5).should == 'hello'
- end
- end
- end
-
- platform_is_not :windows do # spurious
- describe 'using a connected TCP socket' do
- before do
- @client = Socket.new(family, :STREAM)
- @server = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @server.listen(1)
-
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'blocks when the underlying buffer is full' do
- # Buffer sizes may differ per platform, so sadly this is the only
- # reliable way of testing blocking behaviour.
- -> do
- 10.times { @client.sendmsg('hello' * 1_000_000) }
- end.should block_caller
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb b/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb
index 1e8d84e1c9..523a22d957 100644
--- a/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "BasicSocket#setsockopt" do
@@ -38,7 +38,7 @@ describe "BasicSocket#setsockopt" do
platform_is_not :windows do
it "raises EINVAL if passed wrong linger value" do
- -> do
+ lambda do
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, 0)
end.should raise_error(Errno::EINVAL)
end
@@ -70,7 +70,7 @@ describe "BasicSocket#setsockopt" do
n.should_not == [0].pack("i")
platform_is_not :windows do
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "")
}.should raise_error(SystemCallError)
end
@@ -80,7 +80,7 @@ describe "BasicSocket#setsockopt" do
n.should_not == [0].pack("i")
platform_is_not :windows do
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "0")
}.should raise_error(SystemCallError)
end
@@ -90,13 +90,13 @@ describe "BasicSocket#setsockopt" do
n.should == [0].pack("i")
platform_is_not :windows do
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "1")
}.should raise_error(SystemCallError)
end
platform_is_not :windows do
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "\x00\x00\x00")
}.should raise_error(SystemCallError)
end
@@ -125,7 +125,7 @@ describe "BasicSocket#setsockopt" do
n = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF).to_s
n.unpack('i')[0].should >= 1
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, nil).should == 0
}.should raise_error(TypeError)
@@ -137,23 +137,23 @@ describe "BasicSocket#setsockopt" do
n = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF).to_s
n.unpack('i')[0].should >= 2
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "")
}.should raise_error(SystemCallError)
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "bla")
}.should raise_error(SystemCallError)
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "0")
}.should raise_error(SystemCallError)
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "1")
}.should raise_error(SystemCallError)
- -> {
+ lambda {
@sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "\x00\x00\x00")
}.should raise_error(SystemCallError)
@@ -211,126 +211,3 @@ describe "BasicSocket#setsockopt" do
end
end
end
-
-describe 'BasicSocket#setsockopt' do
- describe 'using a STREAM socket' do
- before do
- @socket = Socket.new(:INET, :STREAM)
- end
-
- after do
- @socket.close
- end
-
- describe 'using separate arguments with Symbols' do
- it 'raises TypeError when the first argument is nil' do
- -> { @socket.setsockopt(nil, :REUSEADDR, true) }.should raise_error(TypeError)
- end
-
- it 'sets a boolean option' do
- @socket.setsockopt(:SOCKET, :REUSEADDR, true).should == 0
- @socket.getsockopt(:SOCKET, :REUSEADDR).bool.should == true
- end
-
- it 'sets an integer option' do
- @socket.setsockopt(:IP, :TTL, 255).should == 0
- @socket.getsockopt(:IP, :TTL).int.should == 255
- end
-
- guard -> { SocketSpecs.ipv6_available? } do
- it 'sets an IPv6 boolean option' do
- socket = Socket.new(:INET6, :STREAM)
- begin
- socket.setsockopt(:IPV6, :V6ONLY, true).should == 0
- socket.getsockopt(:IPV6, :V6ONLY).bool.should == true
- ensure
- socket.close
- end
- end
- end
-
- platform_is_not :windows do
- it 'raises Errno::EINVAL when setting an invalid option value' do
- -> { @socket.setsockopt(:SOCKET, :OOBINLINE, 'bla') }.should raise_error(Errno::EINVAL)
- end
- end
- end
-
- describe 'using separate arguments with Symbols' do
- it 'sets a boolean option' do
- @socket.setsockopt('SOCKET', 'REUSEADDR', true).should == 0
- @socket.getsockopt(:SOCKET, :REUSEADDR).bool.should == true
- end
-
- it 'sets an integer option' do
- @socket.setsockopt('IP', 'TTL', 255).should == 0
- @socket.getsockopt(:IP, :TTL).int.should == 255
- end
- end
-
- describe 'using separate arguments with constants' do
- it 'sets a boolean option' do
- @socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true).should == 0
- @socket.getsockopt(:SOCKET, :REUSEADDR).bool.should == true
- end
-
- it 'sets an integer option' do
- @socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255).should == 0
- @socket.getsockopt(:IP, :TTL).int.should == 255
- end
- end
-
- describe 'using separate arguments with custom objects' do
- it 'sets a boolean option' do
- level = mock(:level)
- name = mock(:name)
-
- level.stub!(:to_str).and_return('SOCKET')
- name.stub!(:to_str).and_return('REUSEADDR')
-
- @socket.setsockopt(level, name, true).should == 0
- end
- end
-
- describe 'using a Socket::Option as the first argument' do
- it 'sets a boolean option' do
- @socket.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)).should == 0
- @socket.getsockopt(:SOCKET, :REUSEADDR).bool.should == true
- end
-
- it 'sets an integer option' do
- @socket.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255)).should == 0
- @socket.getsockopt(:IP, :TTL).int.should == 255
- end
-
- it 'raises ArgumentError when passing 2 arguments' do
- option = Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)
- -> { @socket.setsockopt(option, :REUSEADDR) }.should raise_error(ArgumentError)
- end
-
- it 'raises TypeError when passing 3 arguments' do
- option = Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)
- -> { @socket.setsockopt(option, :REUSEADDR, true) }.should raise_error(TypeError)
- end
- end
- end
-
- with_feature :unix_socket do
- describe 'using a UNIX socket' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- end
-
- after do
- @server.close
- rm_r @path
- end
-
- it 'sets a boolean option' do
- @server.setsockopt(:SOCKET, :REUSEADDR, true)
- @server.getsockopt(:SOCKET, :REUSEADDR).bool.should == true
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb
index 41d9581bde..c874f08697 100644
--- a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb
@@ -1,155 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
-platform_is_not :windows do # hangs
- describe "Socket::BasicSocket#shutdown" do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :STREAM)
- @client = Socket.new(family, :STREAM)
+describe "Socket::BasicSocket#shutdown" do
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @server.listen(1)
-
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'using an Integer' do
- it 'shuts down a socket for reading' do
- @client.shutdown(Socket::SHUT_RD)
-
- @client.recv(1).should be_empty
- end
-
- it 'shuts down a socket for writing' do
- @client.shutdown(Socket::SHUT_WR)
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
-
- it 'shuts down a socket for reading and writing' do
- @client.shutdown(Socket::SHUT_RDWR)
-
- @client.recv(1).should be_empty
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
-
- it 'raises ArgumentError when using an invalid option' do
- -> { @server.shutdown(666) }.should raise_error(ArgumentError)
- end
- end
-
- describe 'using a Symbol' do
- it 'shuts down a socket for reading using :RD' do
- @client.shutdown(:RD)
-
- @client.recv(1).should be_empty
- end
-
- it 'shuts down a socket for reading using :SHUT_RD' do
- @client.shutdown(:SHUT_RD)
-
- @client.recv(1).should be_empty
- end
-
- it 'shuts down a socket for writing using :WR' do
- @client.shutdown(:WR)
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
-
- it 'shuts down a socket for writing using :SHUT_WR' do
- @client.shutdown(:SHUT_WR)
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
-
- it 'shuts down a socket for reading and writing' do
- @client.shutdown(:RDWR)
-
- @client.recv(1).should be_empty
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
-
- it 'raises ArgumentError when using an invalid option' do
- -> { @server.shutdown(:Nope) }.should raise_error(SocketError)
- end
- end
-
- describe 'using a String' do
- it 'shuts down a socket for reading using "RD"' do
- @client.shutdown('RD')
-
- @client.recv(1).should be_empty
- end
-
- it 'shuts down a socket for reading using "SHUT_RD"' do
- @client.shutdown('SHUT_RD')
-
- @client.recv(1).should be_empty
- end
-
- it 'shuts down a socket for writing using "WR"' do
- @client.shutdown('WR')
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
-
- it 'shuts down a socket for writing using "SHUT_WR"' do
- @client.shutdown('SHUT_WR')
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
-
- it 'raises ArgumentError when using an invalid option' do
- -> { @server.shutdown('Nope') }.should raise_error(SocketError)
- end
- end
-
- describe 'using an object that responds to #to_str' do
- before do
- @dummy = mock(:dummy)
- end
-
- it 'shuts down a socket for reading using "RD"' do
- @dummy.stub!(:to_str).and_return('RD')
-
- @client.shutdown(@dummy)
-
- @client.recv(1).should be_empty
- end
-
- it 'shuts down a socket for reading using "SHUT_RD"' do
- @dummy.stub!(:to_str).and_return('SHUT_RD')
-
- @client.shutdown(@dummy)
-
- @client.recv(1).should be_empty
- end
-
- it 'shuts down a socket for reading and writing' do
- @dummy.stub!(:to_str).and_return('RDWR')
-
- @client.shutdown(@dummy)
-
- @client.recv(1).should be_empty
-
- -> { @client.write('hello') }.should raise_error(Errno::EPIPE)
- end
- end
-
- describe 'using an object that does not respond to #to_str' do
- it 'raises TypeError' do
- -> { @server.shutdown(mock(:dummy)) }.should raise_error(TypeError)
- end
- end
- end
- end
end
diff --git a/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb
deleted file mode 100644
index f2e7366eb1..0000000000
--- a/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-ruby_version_is "2.5" do
- describe "BasicSocket#write_nonblock" do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before :each do
- @r = Socket.new(family, :DGRAM)
- @w = Socket.new(family, :DGRAM)
-
- @r.bind(Socket.pack_sockaddr_in(0, ip_address))
- @w.connect(@r.getsockname)
- end
-
- after :each do
- @r.close unless @r.closed?
- @w.close unless @w.closed?
- end
-
- it "sends data" do
- @w.write_nonblock("aaa").should == 3
- IO.select([@r], nil, nil, 2)
- @r.recv_nonblock(5).should == "aaa"
- end
-
- platform_is :linux do
- it 'does not set the IO in nonblock mode' do
- require 'io/nonblock'
- @w.nonblock?.should == false
- @w.write_nonblock("aaa").should == 3
- @w.nonblock?.should == false
- end
- end
-
- platform_is_not :linux, :windows do
- it 'sets the IO in nonblock mode' do
- require 'io/nonblock'
- @w.nonblock?.should == false
- @w.write_nonblock("aaa").should == 3
- @w.nonblock?.should == true
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/constants/constants_spec.rb b/spec/ruby/library/socket/constants/constants_spec.rb
index 710af12828..9b8a0e55b3 100644
--- a/spec/ruby/library/socket/constants/constants_spec.rb
+++ b/spec/ruby/library/socket/constants/constants_spec.rb
@@ -1,5 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+include Socket::Constants
describe "Socket::Constants" do
it "defines socket types" do
@@ -86,23 +87,4 @@ describe "Socket::Constants" do
Socket::Constants.should have_constant(c)
end
end
-
- platform_is_not :windows do
- it 'defines SCM options' do
- Socket::Constants.should have_constant('SCM_RIGHTS')
- end
-
- it 'defines error options' do
- consts = ["EAI_ADDRFAMILY", "EAI_NODATA"]
-
- # FreeBSD (11.1, at least) obsoletes EAI_ADDRFAMILY and EAI_NODATA
- platform_is :freebsd do
- consts = %w(EAI_MEMORY)
- end
-
- consts.each do |c|
- Socket::Constants.should have_constant(c)
- end
- end
- end
end
diff --git a/spec/ruby/library/socket/fixtures/classes.rb b/spec/ruby/library/socket/fixtures/classes.rb
index 4a590502ca..b8e5d2a38d 100644
--- a/spec/ruby/library/socket/fixtures/classes.rb
+++ b/spec/ruby/library/socket/fixtures/classes.rb
@@ -1,16 +1,16 @@
require 'socket'
module SocketSpecs
- # helper to get the hostname associated to 127.0.0.1 or the given ip
- def self.hostname(ip = "127.0.0.1")
+ # helper to get the hostname associated to 127.0.0.1
+ def self.hostname
# Calculate each time, without caching, since the result might
# depend on things like do_not_reverse_lookup mode, which is
# changing from test to test
- Socket.getaddrinfo(ip, nil)[0][2]
+ Socket.getaddrinfo("127.0.0.1", nil)[0][2]
end
- def self.hostname_reverse_lookup(ip = "127.0.0.1")
- Socket.getaddrinfo(ip, nil, 0, 0, 0, 0, true)[0][2]
+ def self.hostnamev6
+ Socket.getaddrinfo("::1", nil)[0][2]
end
def self.addr(which=:ipv4)
@@ -34,9 +34,9 @@ module SocketSpecs
def self.socket_path
path = tmp("unix.sock", false)
- # Check for too long unix socket path (max 104 bytes on macOS)
+ # Check for too long unix socket path (max 108 bytes including \0 => 107)
# Note that Linux accepts not null-terminated paths but the man page advises against it.
- if path.bytesize > 104
+ if path.bytesize > 107
path = "/tmp/unix_server_spec.socket"
end
rm_socket(path)
@@ -47,48 +47,6 @@ module SocketSpecs
File.delete(path) if File.exist?(path)
end
- def self.ipv6_available?
- @ipv6_available ||= begin
- server = TCPServer.new('::1', 0)
- rescue Errno::EAFNOSUPPORT, Errno::EADDRNOTAVAIL, SocketError
- :no
- else
- server.close
- :yes
- end
- @ipv6_available == :yes
- end
-
- def self.each_ip_protocol
- describe 'using IPv4' do
- yield Socket::AF_INET, '127.0.0.1', 'AF_INET'
- end
-
- guard -> { SocketSpecs.ipv6_available? } do
- describe 'using IPv6' do
- yield Socket::AF_INET6, '::1', 'AF_INET6'
- end
- end
- end
-
- def self.loop_with_timeout(timeout = TIME_TOLERANCE)
- start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
-
- while yield == :retry
- if Process.clock_gettime(Process::CLOCK_MONOTONIC) - start >= timeout
- raise RuntimeError, "Did not succeed within #{timeout} seconds"
- end
- end
- end
-
- def self.dest_addr_req_error
- error = Errno::EDESTADDRREQ
- platform_is :windows do
- error = Errno::ENOTCONN
- end
- error
- end
-
# TCPServer echo server accepting one connection
class SpecTCPServer
attr_reader :hostname, :port
@@ -132,33 +90,4 @@ module SocketSpecs
@logger.puts message if @logger
end
end
-
- # We need to find a free port for Socket.tcp_server_loop and Socket.udp_server_loop,
- # and the only reliable way to do that is to pass 0 as the port, but then we need to
- # find out which one was chosen and the API doesn't let us find what it is. So we
- # intercept one of the public API methods called by these methods.
- class ServerLoopPortFinder < Socket
- def self.tcp_server_sockets(*args)
- super(*args) { |sockets|
- @port = sockets.first.local_address.ip_port
- yield(sockets)
- }
- end
-
- def self.udp_server_sockets(*args, &block)
- super(*args) { |sockets|
- @port = sockets.first.local_address.ip_port
- yield(sockets)
- }
- end
-
- def self.cleanup
- @port = nil
- end
-
- def self.port
- sleep 0.001 until @port
- @port
- end
- end
end
diff --git a/spec/ruby/library/socket/ipsocket/addr_spec.rb b/spec/ruby/library/socket/ipsocket/addr_spec.rb
index 199eb85ab7..2184082c51 100644
--- a/spec/ruby/library/socket/ipsocket/addr_spec.rb
+++ b/spec/ruby/library/socket/ipsocket/addr_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::IPSocket#addr" do
before :each do
@@ -40,66 +40,3 @@ describe "Socket::IPSocket#addr" do
addrinfo[3].should == "127.0.0.1"
end
end
-
-describe 'Socket::IPSocket#addr' do
- SocketSpecs.each_ip_protocol do |family, ip_address, family_name|
- before do
- @server = TCPServer.new(ip_address, 0)
- @port = @server.connect_address.ip_port
- end
-
- after do
- @server.close
- end
-
- describe 'without reverse lookups' do
- before do
- @hostname = Socket.getaddrinfo(ip_address, nil)[0][2]
- end
-
- it 'returns an Array containing address information' do
- @server.addr.should == [family_name, @port, @hostname, ip_address]
- end
- end
-
- describe 'with reverse lookups' do
- before do
- @hostname = Socket.getaddrinfo(ip_address, nil, nil, 0, 0, 0, true)[0][2]
- end
-
- describe 'using true as the argument' do
- it 'returns an Array containing address information' do
- @server.addr(true).should == [family_name, @port, @hostname, ip_address]
- end
- end
-
- describe 'using :hostname as the argument' do
- it 'returns an Array containing address information' do
- @server.addr(:hostname).should == [family_name, @port, @hostname, ip_address]
- end
- end
-
- describe 'using :cats as the argument' do
- it 'raises ArgumentError' do
- -> { @server.addr(:cats) }.should raise_error(ArgumentError)
- end
- end
- end
-
- describe 'with do_not_reverse_lookup disabled on socket level' do
- before do
- @server.do_not_reverse_lookup = false
-
- @hostname = Socket.getaddrinfo(ip_address, nil, nil, 0, 0, 0, true)[0][2]
- end
-
- after do
- @server.do_not_reverse_lookup = true
- end
-
- it 'returns an Array containing address information' do
- @server.addr.should == [family_name, @port, @hostname, ip_address]
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/ipsocket/getaddress_spec.rb b/spec/ruby/library/socket/ipsocket/getaddress_spec.rb
index 746d2ab86b..c574c7d267 100644
--- a/spec/ruby/library/socket/ipsocket/getaddress_spec.rb
+++ b/spec/ruby/library/socket/ipsocket/getaddress_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::IPSocket#getaddress" do
@@ -11,15 +11,17 @@ describe "Socket::IPSocket#getaddress" do
it "returns the IP address when passed an IP" do
IPSocket.getaddress("127.0.0.1").should == "127.0.0.1"
IPSocket.getaddress("0.0.0.0").should == "0.0.0.0"
- IPSocket.getaddress('::1').should == '::1'
end
# There is no way to make this fail-proof on all machines, because
# DNS servers like opendns return A records for ANY host, including
# traditionally invalidly named ones.
- it "raises an error on unknown hostnames" do
- -> {
- IPSocket.getaddress("rubyspecdoesntexist.fallingsnow.net")
- }.should raise_error(SocketError)
+ quarantine! do
+ it "raises an error on unknown hostnames" do
+ lambda {
+ IPSocket.getaddress("rubyspecdoesntexist.fallingsnow.net")
+ }.should raise_error(SocketError)
+ end
end
+
end
diff --git a/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb b/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb
index 702650940b..27529c3d1c 100644
--- a/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb
+++ b/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::IPSocket#peeraddr" do
before :each do
@@ -16,7 +16,7 @@ describe "Socket::IPSocket#peeraddr" do
end
it "raises error if socket is not connected" do
- -> {
+ lambda {
@server.peeraddr
}.should raise_error(Errno::ENOTCONN)
end
@@ -49,69 +49,3 @@ describe "Socket::IPSocket#peeraddr" do
addrinfo[3].should == "127.0.0.1"
end
end
-
-describe 'Socket::IPSocket#peeraddr' do
- SocketSpecs.each_ip_protocol do |family, ip_address, family_name|
- before do
- @server = TCPServer.new(ip_address, 0)
- @port = @server.connect_address.ip_port
- @client = TCPSocket.new(ip_address, @port)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'without reverse lookups' do
- before do
- @hostname = Socket.getaddrinfo(ip_address, nil)[0][2]
- end
-
- it 'returns an Array containing address information' do
- @client.peeraddr.should == [family_name, @port, @hostname, ip_address]
- end
- end
-
- describe 'with reverse lookups' do
- before do
- @hostname = Socket.getaddrinfo(ip_address, nil, nil, 0, 0, 0, true)[0][2]
- end
-
- describe 'using true as the argument' do
- it 'returns an Array containing address information' do
- @client.peeraddr(true).should == [family_name, @port, @hostname, ip_address]
- end
- end
-
- describe 'using :hostname as the argument' do
- it 'returns an Array containing address information' do
- @client.peeraddr(:hostname).should == [family_name, @port, @hostname, ip_address]
- end
- end
-
- describe 'using :cats as the argument' do
- it 'raises ArgumentError' do
- -> { @client.peeraddr(:cats) }.should raise_error(ArgumentError)
- end
- end
- end
-
- describe 'with do_not_reverse_lookup disabled on socket level' do
- before do
- @client.do_not_reverse_lookup = false
-
- @hostname = Socket.getaddrinfo(ip_address, nil, nil, 0, 0, 0, true)[0][2]
- @port = @client.local_address.ip_port
- end
-
- after do
- @client.do_not_reverse_lookup = true
- end
-
- it 'returns an Array containing address information' do
- @client.addr.should == [family_name, @port, @hostname, ip_address]
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb b/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb
index 2af86ea70d..54f150decf 100644
--- a/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb
+++ b/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::IPSocket#recvfrom" do
+
before :each do
@server = TCPServer.new("127.0.0.1", 0)
@port = @server.addr[1]
@@ -64,60 +65,8 @@ describe "Socket::IPSocket#recvfrom" do
data.size.should == 2
data.first.should == "hel"
- # This does not apply to every platform, dependent on recvfrom(2)
+ # This does not apply to every platform, dependant on recvfrom(2)
# data.last.should == nil
end
-end
-
-describe 'Socket::IPSocket#recvfrom' do
- SocketSpecs.each_ip_protocol do |family, ip_address, family_name|
- before do
- @server = UDPSocket.new(family)
- @client = UDPSocket.new(family)
-
- @server.bind(ip_address, 0)
- @client.connect(ip_address, @server.connect_address.ip_port)
-
- @hostname = Socket.getaddrinfo(ip_address, nil)[0][2]
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'returns an Array containing up to N bytes and address information' do
- @client.write('hello')
-
- port = @client.local_address.ip_port
- ret = @server.recvfrom(2)
-
- ret.should == ['he', [family_name, port, @hostname, ip_address]]
- end
- it 'allows specifying of flags when receiving data' do
- @client.write('hello')
-
- @server.recvfrom(2, Socket::MSG_PEEK)[0].should == 'he'
-
- @server.recvfrom(2)[0].should == 'he'
- end
-
- describe 'using reverse lookups' do
- before do
- @server.do_not_reverse_lookup = false
-
- @hostname = Socket.getaddrinfo(ip_address, nil, 0, 0, 0, 0, true)[0][2]
- end
-
- it 'includes the hostname in the address Array' do
- @client.write('hello')
-
- port = @client.local_address.ip_port
- ret = @server.recvfrom(2)
-
- ret.should == ['he', [family_name, port, @hostname, ip_address]]
- end
- end
- end
end
diff --git a/spec/ruby/library/socket/option/bool_spec.rb b/spec/ruby/library/socket/option/bool_spec.rb
index 144a78043d..74c832a0ad 100644
--- a/spec/ruby/library/socket/option/bool_spec.rb
+++ b/spec/ruby/library/socket/option/bool_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::Option.bool" do
it "creates a new Socket::Option" do
@@ -18,10 +18,8 @@ describe "Socket::Option#bool" do
Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false).bool.should == false
end
- platform_is_not :windows do
- it 'raises TypeError when called on a non boolean option' do
- opt = Socket::Option.linger(1, 4)
- -> { opt.bool }.should raise_error(TypeError)
- end
+ it "raises TypeError if option has not good size" do
+ so = Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*'))
+ lambda { so.bool }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/socket/option/initialize_spec.rb b/spec/ruby/library/socket/option/initialize_spec.rb
deleted file mode 100644
index 8071ad7ef0..0000000000
--- a/spec/ruby/library/socket/option/initialize_spec.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket::Option#initialize' do
- before do
- @bool = [0].pack('i')
- end
-
- describe 'using Integers' do
- it 'returns a Socket::Option' do
- opt = Socket::Option
- .new(Socket::AF_INET, Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, @bool)
-
- opt.should be_an_instance_of(Socket::Option)
-
- opt.family.should == Socket::AF_INET
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_KEEPALIVE
- opt.data.should == @bool
- end
- end
-
- describe 'using Symbols' do
- it 'returns a Socket::Option' do
- opt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, @bool)
-
- opt.should be_an_instance_of(Socket::Option)
-
- opt.family.should == Socket::AF_INET
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_KEEPALIVE
- opt.data.should == @bool
- end
-
- it 'raises when using an invalid address family' do
- -> {
- Socket::Option.new(:INET2, :SOCKET, :KEEPALIVE, @bool)
- }.should raise_error(SocketError)
- end
-
- it 'raises when using an invalid level' do
- -> {
- Socket::Option.new(:INET, :CATS, :KEEPALIVE, @bool)
- }.should raise_error(SocketError)
- end
-
- it 'raises when using an invalid option name' do
- -> {
- Socket::Option.new(:INET, :SOCKET, :CATS, @bool)
- }.should raise_error(SocketError)
- end
- end
-
- describe 'using Strings' do
- it 'returns a Socket::Option' do
- opt = Socket::Option.new('INET', 'SOCKET', 'KEEPALIVE', @bool)
-
- opt.should be_an_instance_of(Socket::Option)
-
- opt.family.should == Socket::AF_INET
- opt.level.should == Socket::SOL_SOCKET
- opt.optname.should == Socket::SO_KEEPALIVE
- opt.data.should == @bool
- end
-
- it 'raises when using an invalid address family' do
- -> {
- Socket::Option.new('INET2', 'SOCKET', 'KEEPALIVE', @bool)
- }.should raise_error(SocketError)
- end
-
- it 'raises when using an invalid level' do
- -> {
- Socket::Option.new('INET', 'CATS', 'KEEPALIVE', @bool)
- }.should raise_error(SocketError)
- end
-
- it 'raises when using an invalid option name' do
- -> {
- Socket::Option.new('INET', 'SOCKET', 'CATS', @bool)
- }.should raise_error(SocketError)
- end
- end
-end
diff --git a/spec/ruby/library/socket/option/inspect_spec.rb b/spec/ruby/library/socket/option/inspect_spec.rb
index ebea940d2f..df72f227a9 100644
--- a/spec/ruby/library/socket/option/inspect_spec.rb
+++ b/spec/ruby/library/socket/option/inspect_spec.rb
@@ -1,6 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require 'socket'
describe 'Socket::Option#inspect' do
it 'correctly returns SO_LINGER value' do
diff --git a/spec/ruby/library/socket/option/int_spec.rb b/spec/ruby/library/socket/option/int_spec.rb
index 8c69ef6cbd..f926ff7968 100644
--- a/spec/ruby/library/socket/option/int_spec.rb
+++ b/spec/ruby/library/socket/option/int_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::Option.int" do
it "creates a new Socket::Option" do
@@ -10,17 +10,6 @@ describe "Socket::Option.int" do
so.optname.should == Socket::Constants::SO_KEEPALIVE
so.data.should == [5].pack('i')
end
-
- it 'returns a Socket::Option' do
- opt = Socket::Option.int(:INET, :IP, :TTL, 4)
-
- opt.should be_an_instance_of(Socket::Option)
-
- opt.family.should == Socket::AF_INET
- opt.level.should == Socket::IPPROTO_IP
- opt.optname.should == Socket::IP_TTL
- opt.data.should == [4].pack('i')
- end
end
describe "Socket::Option#int" do
@@ -30,14 +19,10 @@ describe "Socket::Option#int" do
so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 32765)
so.int.should == 32765
-
- Socket::Option.int(:INET, :IP, :TTL, 4).int.should == 4
end
- platform_is_not :windows do
- it 'raises TypeError when called on a non integer option' do
- opt = Socket::Option.linger(1, 4)
- -> { opt.int }.should raise_error(TypeError)
- end
+ it "raises TypeError if option has not good size" do
+ so = Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*'))
+ lambda { so.int }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/socket/option/linger_spec.rb b/spec/ruby/library/socket/option/linger_spec.rb
index ee987db85b..687d421af3 100644
--- a/spec/ruby/library/socket/option/linger_spec.rb
+++ b/spec/ruby/library/socket/option/linger_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
option_pack = 'i*'
platform_is :windows do
@@ -10,11 +10,9 @@ describe "Socket::Option.linger" do
it "creates a new Socket::Option for SO_LINGER" do
so = Socket::Option.linger(1, 10)
so.should be_an_instance_of(Socket::Option)
-
so.family.should == Socket::Constants::AF_UNSPEC
so.level.should == Socket::Constants::SOL_SOCKET
so.optname.should == Socket::Constants::SO_LINGER
-
so.data.should == [1, 10].pack(option_pack)
end
@@ -52,25 +50,13 @@ describe "Socket::Option#linger" do
it "raises TypeError if not a SO_LINGER" do
so = Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :KEEPALIVE, 1)
- -> { so.linger }.should raise_error(TypeError)
- end
-
- it 'raises TypeError when called on a non SOL_SOCKET/SO_LINGER option' do
- opt = Socket::Option.int(:INET, :IP, :TTL, 4)
-
- -> { opt.linger }.should raise_error(TypeError)
+ lambda { so.linger }.should raise_error(TypeError)
end
platform_is_not :windows do
it "raises TypeError if option has not good size" do
so = Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
- -> { so.linger }.should raise_error(TypeError)
+ lambda { so.linger }.should raise_error(TypeError)
end
end
-
- it 'raises TypeError when called on a non linger option' do
- opt = Socket::Option.new(:INET, :SOCKET, :LINGER, '')
-
- -> { opt.linger }.should raise_error(TypeError)
- end
end
diff --git a/spec/ruby/library/socket/option/new_spec.rb b/spec/ruby/library/socket/option/new_spec.rb
index a9e6f09097..4f2d0c5386 100644
--- a/spec/ruby/library/socket/option/new_spec.rb
+++ b/spec/ruby/library/socket/option/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::Option.new" do
it "should accept integers" do
@@ -22,14 +22,14 @@ describe "Socket::Option.new" do
end
it "should raise error on unknown family" do
- -> { Socket::Option.new(:INET4, :SOCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
+ lambda { Socket::Option.new(:INET4, :SOCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
end
it "should raise error on unknown level" do
- -> { Socket::Option.new(:INET, :ROCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
+ lambda { Socket::Option.new(:INET, :ROCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
end
it "should raise error on unknown option name" do
- -> { Socket::Option.new(:INET, :SOCKET, :ALIVE, [0].pack('i')) }.should raise_error(SocketError)
+ lambda { Socket::Option.new(:INET, :SOCKET, :ALIVE, [0].pack('i')) }.should raise_error(SocketError)
end
end
diff --git a/spec/ruby/library/socket/shared/pack_sockaddr.rb b/spec/ruby/library/socket/shared/pack_sockaddr.rb
index 2df09027c9..4ffa02a8d8 100644
--- a/spec/ruby/library/socket/shared/pack_sockaddr.rb
+++ b/spec/ruby/library/socket/shared/pack_sockaddr.rb
@@ -18,41 +18,10 @@ describe :socket_pack_sockaddr_in, shared: true do
sockaddr_in = Socket.public_send(@method, nil, '127.0.0.1')
Socket.unpack_sockaddr_in(sockaddr_in).should == [0, '127.0.0.1']
end
-
- describe 'using an IPv4 address' do
- it 'returns a String of 16 bytes' do
- str = Socket.public_send(@method, 80, '127.0.0.1')
-
- str.should be_an_instance_of(String)
- str.bytesize.should == 16
- end
- end
-
- platform_is_not :solaris do
- describe 'using an IPv6 address' do
- it 'returns a String of 28 bytes' do
- str = Socket.public_send(@method, 80, '::1')
-
- str.should be_an_instance_of(String)
- str.bytesize.should == 28
- end
- end
- end
-
- platform_is :solaris do
- describe 'using an IPv6 address' do
- it 'returns a String of 32 bytes' do
- str = Socket.public_send(@method, 80, '::1')
-
- str.should be_an_instance_of(String)
- str.bytesize.should == 32
- end
- end
- end
end
describe :socket_pack_sockaddr_un, shared: true do
- with_feature :unix_socket do
+ platform_is_not :windows do
it 'should be idempotent' do
bytes = Socket.public_send(@method, '/tmp/foo').bytes
bytes[2..9].should == [47, 116, 109, 112, 47, 102, 111, 111]
@@ -71,29 +40,11 @@ describe :socket_pack_sockaddr_un, shared: true do
end
end
- platform_is :linux do
- it 'returns a String of 110 bytes' do
- str = Socket.public_send(@method, '/tmp/test.sock')
-
- str.should be_an_instance_of(String)
- str.bytesize.should == 110
- end
- end
-
- platform_is :bsd do
- it 'returns a String of 106 bytes' do
- str = Socket.public_send(@method, '/tmp/test.sock')
-
- str.should be_an_instance_of(String)
- str.bytesize.should == 106
- end
- end
-
platform_is_not :windows, :aix do
- it "raises ArgumentError for paths that are too long" do
+ it "raises if path length exceeds max size" do
# AIX doesn't raise error
- long_path = 'a' * 110
- -> { Socket.public_send(@method, long_path) }.should raise_error(ArgumentError)
+ long_path = Array.new(512, 0).join
+ lambda { Socket.public_send(@method, long_path) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/library/socket/shared/recv_nonblock.rb b/spec/ruby/library/socket/shared/recv_nonblock.rb
new file mode 100644
index 0000000000..a5f6c6812e
--- /dev/null
+++ b/spec/ruby/library/socket/shared/recv_nonblock.rb
@@ -0,0 +1,54 @@
+describe :socket_recv_nonblock, shared: true do
+ before :each do
+ @s1 = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
+ @s2 = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
+ end
+
+ after :each do
+ @s1.close unless @s1.closed?
+ @s2.close unless @s2.closed?
+ end
+
+ it "raises an exception extending IO::WaitReadable if there's no data available" do
+ @s1.bind(Socket.pack_sockaddr_in(0, "127.0.0.1"))
+ lambda {
+ @s1.recv_nonblock(5)
+ }.should raise_error(IO::WaitReadable) { |e|
+ platform_is_not :windows do
+ e.should be_kind_of(Errno::EAGAIN)
+ end
+ platform_is :windows do
+ e.should be_kind_of(Errno::EWOULDBLOCK)
+ end
+ }
+ end
+
+ it "receives data after it's ready" do
+ @s1.bind(Socket.pack_sockaddr_in(0, "127.0.0.1"))
+ @s2.send("aaa", 0, @s1.getsockname)
+ IO.select([@s1], nil, nil, 2)
+ @s1.recv_nonblock(5).should == "aaa"
+ end
+
+ ruby_version_is "2.3" do
+ it "allows an output buffer as third argument" do
+ @s1.bind(Socket.pack_sockaddr_in(0, "127.0.0.1"))
+ @s2.send("data", 0, @s1.getsockname)
+ IO.select([@s1], nil, nil, 2)
+
+ buf = "foo"
+ @s1.recv_nonblock(5, 0, buf)
+ buf.should == "data"
+ end
+ end
+
+ it "does not block if there's no data available" do
+ @s1.bind(Socket.pack_sockaddr_in(0, "127.0.0.1"))
+ @s2.send("a", 0, @s1.getsockname)
+ IO.select([@s1], nil, nil, 2)
+ @s1.recv_nonblock(1).should == "a"
+ lambda {
+ @s1.recv_nonblock(5)
+ }.should raise_error(IO::WaitReadable)
+ end
+end
diff --git a/spec/ruby/library/socket/shared/socketpair.rb b/spec/ruby/library/socket/shared/socketpair.rb
index 25146cfff6..03ee0e1a52 100644
--- a/spec/ruby/library/socket/shared/socketpair.rb
+++ b/spec/ruby/library/socket/shared/socketpair.rb
@@ -19,120 +19,5 @@ describe :socket_socketpair, shared: true do
s2.close
end
end
-
- describe 'using an Integer as the 1st and 2nd argument' do
- it 'returns two Socket objects' do
- s1, s2 = Socket.public_send(@method, Socket::AF_UNIX, Socket::SOCK_STREAM)
-
- s1.should be_an_instance_of(Socket)
- s2.should be_an_instance_of(Socket)
- s1.close
- s2.close
- end
- end
-
- describe 'using a Symbol as the 1st and 2nd argument' do
- it 'returns two Socket objects' do
- s1, s2 = Socket.public_send(@method, :UNIX, :STREAM)
-
- s1.should be_an_instance_of(Socket)
- s2.should be_an_instance_of(Socket)
- s1.close
- s2.close
- end
-
- it 'raises SocketError for an unknown address family' do
- -> { Socket.public_send(@method, :CATS, :STREAM) }.should raise_error(SocketError)
- end
-
- it 'raises SocketError for an unknown socket type' do
- -> { Socket.public_send(@method, :UNIX, :CATS) }.should raise_error(SocketError)
- end
- end
-
- describe 'using a String as the 1st and 2nd argument' do
- it 'returns two Socket objects' do
- s1, s2 = Socket.public_send(@method, 'UNIX', 'STREAM')
-
- s1.should be_an_instance_of(Socket)
- s2.should be_an_instance_of(Socket)
- s1.close
- s2.close
- end
-
- it 'raises SocketError for an unknown address family' do
- -> { Socket.public_send(@method, 'CATS', 'STREAM') }.should raise_error(SocketError)
- end
-
- it 'raises SocketError for an unknown socket type' do
- -> { Socket.public_send(@method, 'UNIX', 'CATS') }.should raise_error(SocketError)
- end
- end
-
- describe 'using an object that responds to #to_str as the 1st and 2nd argument' do
- it 'returns two Socket objects' do
- family = mock(:family)
- type = mock(:type)
-
- family.stub!(:to_str).and_return('UNIX')
- type.stub!(:to_str).and_return('STREAM')
-
- s1, s2 = Socket.public_send(@method, family, type)
-
- s1.should be_an_instance_of(Socket)
- s2.should be_an_instance_of(Socket)
- s1.close
- s2.close
- end
-
- it 'raises TypeError when #to_str does not return a String' do
- family = mock(:family)
- type = mock(:type)
-
- family.stub!(:to_str).and_return(Socket::AF_UNIX)
- type.stub!(:to_str).and_return(Socket::SOCK_STREAM)
-
- -> { Socket.public_send(@method, family, type) }.should raise_error(TypeError)
- end
-
- it 'raises SocketError for an unknown address family' do
- family = mock(:family)
- type = mock(:type)
-
- family.stub!(:to_str).and_return('CATS')
- type.stub!(:to_str).and_return('STREAM')
-
- -> { Socket.public_send(@method, family, type) }.should raise_error(SocketError)
- end
-
- it 'raises SocketError for an unknown socket type' do
- family = mock(:family)
- type = mock(:type)
-
- family.stub!(:to_str).and_return('UNIX')
- type.stub!(:to_str).and_return('CATS')
-
- -> { Socket.public_send(@method, family, type) }.should raise_error(SocketError)
- end
- end
-
- it 'accepts a custom protocol as an Integer as the 3rd argument' do
- s1, s2 = Socket.public_send(@method, :UNIX, :STREAM, Socket::IPPROTO_IP)
- s1.should be_an_instance_of(Socket)
- s2.should be_an_instance_of(Socket)
- s1.close
- s2.close
- end
-
- it 'connects the returned Socket objects' do
- s1, s2 = Socket.public_send(@method, :UNIX, :STREAM)
- begin
- s1.write('hello')
- s2.recv(5).should == 'hello'
- ensure
- s1.close
- s2.close
- end
- end
end
end
diff --git a/spec/ruby/library/socket/socket/accept_loop_spec.rb b/spec/ruby/library/socket/socket/accept_loop_spec.rb
deleted file mode 100644
index 78e8c3fa4a..0000000000
--- a/spec/ruby/library/socket/socket/accept_loop_spec.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.accept_loop' do
- before do
- @server = Socket.new(:INET, :STREAM)
- @client = Socket.new(:INET, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, '127.0.0.1'))
- @server.listen(1)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'using an Array of Sockets' do
- describe 'without any available connections' do
- # FIXME windows randomly hangs here forever
- # https://ci.appveyor.com/project/ruby/ruby/builds/20817932/job/dor2ipny7ru4erpa
- platform_is_not :windows do
- it 'blocks the caller' do
- -> { Socket.accept_loop([@server]) }.should block_caller
- end
- end
- end
-
- describe 'with available connections' do
- before do
- @client.connect(@server.getsockname)
- end
-
- it 'yields a Socket and an Addrinfo' do
- conn = nil
- addr = nil
-
- Socket.accept_loop([@server]) do |connection, address|
- conn = connection
- addr = address
- break
- end
-
- begin
- conn.should be_an_instance_of(Socket)
- addr.should be_an_instance_of(Addrinfo)
- ensure
- conn.close
- end
- end
- end
- end
-
- describe 'using separate Socket arguments' do
- describe 'without any available connections' do
- it 'blocks the caller' do
- -> { Socket.accept_loop(@server) }.should block_caller
- end
- end
-
- describe 'with available connections' do
- before do
- @client.connect(@server.getsockname)
- end
-
- it 'yields a Socket and an Addrinfo' do
- conn = nil
- addr = nil
-
- Socket.accept_loop(@server) do |connection, address|
- conn = connection
- addr = address
- break
- end
-
- begin
- conn.should be_an_instance_of(Socket)
- addr.should be_an_instance_of(Addrinfo)
- ensure
- conn.close
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
index 3221f0b128..be0bbf5f03 100644
--- a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
+++ b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
@@ -1,5 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+require 'socket'
describe "Socket#accept_nonblock" do
before :each do
@@ -15,7 +17,7 @@ describe "Socket#accept_nonblock" do
end
it "raises IO::WaitReadable if the connection is not accepted yet" do
- -> {
+ lambda {
@socket.accept_nonblock
}.should raise_error(IO::WaitReadable) { |e|
platform_is_not :windows do
@@ -27,112 +29,9 @@ describe "Socket#accept_nonblock" do
}
end
- it 'returns :wait_readable in exceptionless mode' do
- @socket.accept_nonblock(exception: false).should == :wait_readable
- end
-end
-
-describe 'Socket#accept_nonblock' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :STREAM, 0)
- @sockaddr = Socket.sockaddr_in(0, ip_address)
- end
-
- after do
- @server.close unless @server.closed?
- end
-
- describe 'using an unbound socket' do
- it 'raises Errno::EINVAL' do
- -> { @server.accept_nonblock }.should raise_error(Errno::EINVAL)
- end
- end
-
- describe "using a bound socket that's not listening" do
- before do
- @server.bind(@sockaddr)
- end
-
- it 'raises Errno::EINVAL' do
- -> { @server.accept_nonblock }.should raise_error(Errno::EINVAL)
- end
- end
-
- describe 'using a closed socket' do
- it 'raises IOError' do
- @server.close
-
- -> { @server.accept_nonblock }.should raise_error(IOError)
- end
- end
-
- describe "using a bound socket that's listening" do
- before do
- @server.bind(@sockaddr)
- @server.listen(1)
- end
-
- describe 'without a connected client' do
- it 'raises IO::WaitReadable' do
- -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable)
- end
- end
-
- platform_is_not :windows do
- describe 'with a connected client' do
- before do
- addr = Socket.sockaddr_in(@server.local_address.ip_port, ip_address)
- @client = Socket.new(family, :STREAM, 0)
-
- @client.connect(addr)
- end
-
- after do
- @socket.close if @socket
- @client.close
- end
-
- it 'returns an Array containing a Socket and an Addrinfo' do
- IO.select([@server])
- @socket, addrinfo = @server.accept_nonblock
-
- @socket.should be_an_instance_of(Socket)
- addrinfo.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- before do
- IO.select([@server])
- @socket, @addr = @server.accept_nonblock
- end
-
- it 'uses AF_INET as the address family' do
- @addr.afamily.should == family
- end
-
- it 'uses PF_INET as the protocol family' do
- @addr.pfamily.should == family
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @addr.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses 0 as the protocol' do
- @addr.protocol.should == 0
- end
-
- it 'uses the same IP address as the client Socket' do
- @addr.ip_address.should == @client.local_address.ip_address
- end
-
- it 'uses the same port as the client Socket' do
- @addr.ip_port.should == @client.local_address.ip_port
- end
- end
- end
- end
+ ruby_version_is '2.3' do
+ it 'returns :wait_readable in exceptionless mode' do
+ @socket.accept_nonblock(exception: false).should == :wait_readable
end
end
end
diff --git a/spec/ruby/library/socket/socket/accept_spec.rb b/spec/ruby/library/socket/socket/accept_spec.rb
index 417f996c55..fcd29e1257 100644
--- a/spec/ruby/library/socket/socket/accept_spec.rb
+++ b/spec/ruby/library/socket/socket/accept_spec.rb
@@ -1,121 +1,2 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket#accept' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :STREAM, 0)
- @sockaddr = Socket.sockaddr_in(0, ip_address)
- end
-
- after do
- @server.close unless @server.closed?
- end
-
- platform_is :linux do # hangs on other platforms
- describe 'using an unbound socket' do
- it 'raises Errno::EINVAL' do
- -> { @server.accept }.should raise_error(Errno::EINVAL)
- end
- end
-
- describe "using a bound socket that's not listening" do
- before do
- @server.bind(@sockaddr)
- end
-
- it 'raises Errno::EINVAL' do
- -> { @server.accept }.should raise_error(Errno::EINVAL)
- end
- end
- end
-
- describe 'using a closed socket' do
- it 'raises IOError' do
- @server.close
-
- -> { @server.accept }.should raise_error(IOError)
- end
- end
-
- describe "using a bound socket that's listening" do
- before do
- @server.bind(@sockaddr)
- @server.listen(1)
-
- server_ip = @server.local_address.ip_port
- @server_addr = Socket.sockaddr_in(server_ip, ip_address)
- end
-
- describe 'without a connected client' do
- it 'blocks the caller until a connection is available' do
- client = Socket.new(family, :STREAM, 0)
- thread = Thread.new do
- @server.accept
- end
-
- client.connect(@server_addr)
-
- value = thread.value
- begin
- value.should be_an_instance_of(Array)
- ensure
- client.close
- value[0].close
- end
- end
- end
-
- describe 'with a connected client' do
- before do
- addr = Socket.sockaddr_in(@server.local_address.ip_port, ip_address)
- @client = Socket.new(family, :STREAM, 0)
-
- @client.connect(addr)
- end
-
- after do
- @socket.close if @socket
- @client.close
- end
-
- it 'returns an Array containing a Socket and an Addrinfo' do
- @socket, addrinfo = @server.accept
-
- @socket.should be_an_instance_of(Socket)
- addrinfo.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- before do
- @socket, @addr = @server.accept
- end
-
- it 'uses AF_INET as the address family' do
- @addr.afamily.should == family
- end
-
- it 'uses PF_INET as the protocol family' do
- @addr.pfamily.should == family
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @addr.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses 0 as the protocol' do
- @addr.protocol.should == 0
- end
-
- it 'uses the same IP address as the client Socket' do
- @addr.ip_address.should == @client.local_address.ip_address
- end
-
- it 'uses the same port as the client Socket' do
- @addr.ip_port.should == @client.local_address.ip_port
- end
- end
- end
- end
- end
-end
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
diff --git a/spec/ruby/library/socket/socket/bind_spec.rb b/spec/ruby/library/socket/socket/bind_spec.rb
index 0349df84a6..399c988b32 100644
--- a/spec/ruby/library/socket/socket/bind_spec.rb
+++ b/spec/ruby/library/socket/socket/bind_spec.rb
@@ -1,9 +1,11 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+include Socket::Constants
describe "Socket#bind on SOCK_DGRAM socket" do
before :each do
- @sock = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
+ @sock = Socket.new(AF_INET, SOCK_DGRAM, 0)
@sockaddr = Socket.pack_sockaddr_in(0, "127.0.0.1")
end
@@ -13,7 +15,7 @@ describe "Socket#bind on SOCK_DGRAM socket" do
end
it "binds to a port" do
- -> { @sock.bind(@sockaddr) }.should_not raise_error
+ lambda { @sock.bind(@sockaddr) }.should_not raise_error
end
it "returns 0 if successful" do
@@ -23,28 +25,26 @@ describe "Socket#bind on SOCK_DGRAM socket" do
it "raises Errno::EINVAL when already bound" do
@sock.bind(@sockaddr)
- -> { @sock.bind(@sockaddr) }.should raise_error(Errno::EINVAL)
+ lambda { @sock.bind(@sockaddr) }.should raise_error(Errno::EINVAL)
end
it "raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available from the local machine" do
sockaddr1 = Socket.pack_sockaddr_in(0, "4.3.2.1")
- -> { @sock.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL)
+ lambda { @sock.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL)
end
platform_is_not :windows, :cygwin do
- as_user do
- it "raises Errno::EACCES when the current user does not have permission to bind" do
- sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1")
- -> { @sock.bind(sockaddr1) }.should raise_error(Errno::EACCES)
- end
+ it "raises Errno::EACCES when the current user does not have permission to bind" do
+ sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1")
+ lambda { @sock.bind(sockaddr1) }.should raise_error(Errno::EACCES)
end
end
end
describe "Socket#bind on SOCK_STREAM socket" do
before :each do
- @sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
- @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
+ @sock = Socket.new(AF_INET, SOCK_STREAM, 0)
+ @sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, true)
@sockaddr = Socket.pack_sockaddr_in(0, "127.0.0.1")
end
@@ -54,7 +54,7 @@ describe "Socket#bind on SOCK_STREAM socket" do
end
it "binds to a port" do
- -> { @sock.bind(@sockaddr) }.should_not raise_error
+ lambda { @sock.bind(@sockaddr) }.should_not raise_error
end
it "returns 0 if successful" do
@@ -64,83 +64,18 @@ describe "Socket#bind on SOCK_STREAM socket" do
it "raises Errno::EINVAL when already bound" do
@sock.bind(@sockaddr)
- -> { @sock.bind(@sockaddr) }.should raise_error(Errno::EINVAL)
+ lambda { @sock.bind(@sockaddr) }.should raise_error(Errno::EINVAL)
end
it "raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available from the local machine" do
sockaddr1 = Socket.pack_sockaddr_in(0, "4.3.2.1")
- -> { @sock.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL)
+ lambda { @sock.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL)
end
platform_is_not :windows, :cygwin do
- as_user do
- it "raises Errno::EACCES when the current user does not have permission to bind" do
- sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1")
- -> { @sock.bind(sockaddr1) }.should raise_error(Errno::EACCES)
- end
- end
- end
-end
-
-describe 'Socket#bind' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a packed socket address' do
- before do
- @socket = Socket.new(family, :DGRAM)
- @sockaddr = Socket.sockaddr_in(0, ip_address)
- end
-
- after do
- @socket.close
- end
-
- it 'returns 0 when successfully bound' do
- @socket.bind(@sockaddr).should == 0
- end
-
- it 'raises Errno::EINVAL when binding to an already bound port' do
- @socket.bind(@sockaddr)
-
- -> { @socket.bind(@sockaddr) }.should raise_error(Errno::EINVAL)
- end
-
- it 'raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available' do
- ip = family == Socket::AF_INET ? '4.3.2.1' : '::2'
- sockaddr1 = Socket.sockaddr_in(0, ip)
-
- -> { @socket.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL)
- end
-
- platform_is_not :windows do
- as_user do
- it 'raises Errno::EACCES when the user is not allowed to bind to the port' do
- sockaddr1 = Socket.pack_sockaddr_in(1, ip_address)
-
- -> { @socket.bind(sockaddr1) }.should raise_error(Errno::EACCES)
- end
- end
- end
- end
-
- describe 'using an Addrinfo' do
- before do
- @addr = Addrinfo.udp(ip_address, 0)
- @socket = Socket.new(@addr.afamily, @addr.socktype)
- end
-
- after do
- @socket.close
- end
-
- it 'binds to an Addrinfo' do
- @socket.bind(@addr).should == 0
- @socket.local_address.should be_an_instance_of(Addrinfo)
- end
-
- it 'uses a new Addrinfo for the local address' do
- @socket.bind(@addr)
- @socket.local_address.should_not == @addr
- end
+ it "raises Errno::EACCES when the current user does not have permission to bind" do
+ sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1")
+ lambda { @sock.bind(sockaddr1) }.should raise_error(Errno::EACCES)
end
end
end
diff --git a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb
index 3cf667fc4a..26bceabb51 100644
--- a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb
+++ b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb
@@ -1,5 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+require 'socket'
describe "Socket#connect_nonblock" do
before :each do
@@ -16,133 +18,55 @@ describe "Socket#connect_nonblock" do
@thread.join if @thread
end
- platform_is_not :solaris do
- it "connects the socket to the remote side" do
- port = nil
- accept = false
- @thread = Thread.new do
- server = TCPServer.new(@hostname, 0)
- port = server.addr[1]
- Thread.pass until accept
- conn = server.accept
- conn << "hello!"
- conn.close
- server.close
- end
-
- Thread.pass until port
+ it "connects the socket to the remote side" do
+ port = nil
+ accept = false
+ @thread = Thread.new do
+ server = TCPServer.new(@hostname, 0)
+ port = server.addr[1]
+ Thread.pass until accept
+ conn = server.accept
+ conn << "hello!"
+ conn.close
+ server.close
+ end
- addr = Socket.sockaddr_in(port, @hostname)
- begin
- @socket.connect_nonblock(addr)
- rescue Errno::EINPROGRESS
- end
+ Thread.pass until port
- accept = true
- IO.select nil, [@socket]
+ addr = Socket.sockaddr_in(port, @hostname)
+ begin
+ @socket.connect_nonblock(addr)
+ rescue Errno::EINPROGRESS
+ end
- begin
- @socket.connect_nonblock(addr)
- rescue Errno::EISCONN
- # Not all OS's use this errno, so we trap and ignore it
- end
+ accept = true
+ IO.select nil, [@socket]
- @socket.read(6).should == "hello!"
+ begin
+ @socket.connect_nonblock(addr)
+ rescue Errno::EISCONN
+ # Not all OS's use this errno, so we trap and ignore it
end
+
+ @socket.read(6).should == "hello!"
end
platform_is_not :freebsd, :solaris, :aix do
it "raises Errno::EINPROGRESS when the connect would block" do
- -> do
+ lambda do
@socket.connect_nonblock(@addr)
end.should raise_error(Errno::EINPROGRESS)
end
it "raises Errno::EINPROGRESS with IO::WaitWritable mixed in when the connect would block" do
- -> do
+ lambda do
@socket.connect_nonblock(@addr)
end.should raise_error(IO::WaitWritable)
end
- it "returns :wait_writable in exceptionless mode when the connect would block" do
- @socket.connect_nonblock(@addr, exception: false).should == :wait_writable
- end
- end
-end
-
-describe 'Socket#connect_nonblock' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a DGRAM socket' do
- before do
- @server = Socket.new(family, :DGRAM)
- @client = Socket.new(family, :DGRAM)
- @sockaddr = Socket.sockaddr_in(0, ip_address)
-
- @server.bind(@sockaddr)
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'returns 0 when successfully connected using a String' do
- @client.connect_nonblock(@server.getsockname).should == 0
- end
-
- it 'returns 0 when successfully connected using an Addrinfo' do
- @client.connect_nonblock(@server.connect_address).should == 0
- end
-
- it 'raises TypeError when passed an Integer' do
- -> { @client.connect_nonblock(666) }.should raise_error(TypeError)
- end
- end
-
- describe 'using a STREAM socket' do
- before do
- @server = Socket.new(family, :STREAM)
- @client = Socket.new(family, :STREAM)
- @sockaddr = Socket.sockaddr_in(0, ip_address)
- end
-
- after do
- @client.close
- @server.close
- end
-
- platform_is_not :windows do
- it 'raises Errno::EISCONN when already connected' do
- @server.listen(1)
- @client.connect(@server.connect_address).should == 0
-
- -> {
- @client.connect_nonblock(@server.connect_address)
-
- # A second call needed if non-blocking sockets become default
- # XXX honestly I don't expect any real code to care about this spec
- # as it's too implementation-dependent and checking for connect()
- # errors is futile anyways because of TOCTOU
- @client.connect_nonblock(@server.connect_address)
- }.should raise_error(Errno::EISCONN)
- end
-
- it 'returns 0 when already connected in exceptionless mode' do
- @server.listen(1)
- @client.connect(@server.connect_address).should == 0
-
- @client.connect_nonblock(@server.connect_address, exception: false).should == 0
- end
- end
-
- platform_is_not :freebsd, :solaris do
- it 'raises IO:EINPROGRESSWaitWritable when the connection would block' do
- @server.bind(@sockaddr)
-
- -> {
- @client.connect_nonblock(@server.connect_address)
- }.should raise_error(IO::EINPROGRESSWaitWritable)
- end
+ ruby_version_is "2.3" do
+ it "returns :wait_writable in exceptionless mode when the connect would block" do
+ @socket.connect_nonblock(@addr, exception: false).should == :wait_writable
end
end
end
diff --git a/spec/ruby/library/socket/socket/connect_spec.rb b/spec/ruby/library/socket/socket/connect_spec.rb
index 8653fba552..fcd29e1257 100644
--- a/spec/ruby/library/socket/socket/connect_spec.rb
+++ b/spec/ruby/library/socket/socket/connect_spec.rb
@@ -1,56 +1,2 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket#connect' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :STREAM)
- @client = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'returns 0 when connected successfully using a String' do
- @server.listen(1)
-
- @client.connect(@server.getsockname).should == 0
- end
-
- it 'returns 0 when connected successfully using an Addrinfo' do
- @server.listen(1)
-
- @client.connect(@server.connect_address).should == 0
- end
-
- it 'raises Errno::EISCONN when already connected' do
- @server.listen(1)
-
- @client.connect(@server.getsockname).should == 0
-
- -> {
- @client.connect(@server.getsockname)
-
- # A second call needed if non-blocking sockets become default
- # XXX honestly I don't expect any real code to care about this spec
- # as it's too implementation-dependent and checking for connect()
- # errors is futile anyways because of TOCTOU
- @client.connect(@server.getsockname)
- }.should raise_error(Errno::EISCONN)
- end
-
- platform_is_not :darwin do
- it 'raises Errno::ECONNREFUSED or Errno::ETIMEDOUT when the connection failed' do
- begin
- @client.connect(@server.getsockname)
- rescue => e
- [Errno::ECONNREFUSED, Errno::ETIMEDOUT].include?(e.class).should == true
- end
- end
- end
- end
-end
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
diff --git a/spec/ruby/library/socket/socket/for_fd_spec.rb b/spec/ruby/library/socket/socket/for_fd_spec.rb
index e89228d436..6688988448 100644
--- a/spec/ruby/library/socket/socket/for_fd_spec.rb
+++ b/spec/ruby/library/socket/socket/for_fd_spec.rb
@@ -1,5 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require 'socket'
describe "Socket.for_fd" do
before :each do
diff --git a/spec/ruby/library/socket/socket/getaddrinfo_spec.rb b/spec/ruby/library/socket/socket/getaddrinfo_spec.rb
index e0eff3cef4..fa8112c010 100644
--- a/spec/ruby/library/socket/socket/getaddrinfo_spec.rb
+++ b/spec/ruby/library/socket/socket/getaddrinfo_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Socket.getaddrinfo" do
+require 'socket'
+
+describe "Socket#getaddrinfo" do
before :each do
@do_not_reverse_lookup = BasicSocket.do_not_reverse_lookup
BasicSocket.do_not_reverse_lookup = true
@@ -51,10 +53,10 @@ describe "Socket.getaddrinfo" do
end
end
- # #getaddrinfo will return a INADDR_ANY address (0.0.0.0 or "::")
- # if it's a passive socket. In the case of non-passive
+ # #getaddrinfo will return a INADDR_ANY address (0.0.0.0
+ # or "::") if it's a passive socket. In the case of non-passive
# sockets (AI_PASSIVE not set) it should return the loopback
- # address (127.0.0.1 or "::1").
+ # address (127.0.0.1 or "::1".
it "accepts empty addresses for IPv4 passive sockets" do
res = Socket.getaddrinfo(nil, "discard",
@@ -90,7 +92,7 @@ describe "Socket.getaddrinfo" do
["AF_INET6", 9, "::", "::", Socket::AF_INET6, Socket::SOCK_STREAM, Socket::IPPROTO_TCP],
["AF_INET6", 9, "0:0:0:0:0:0:0:0", "0:0:0:0:0:0:0:0", Socket::AF_INET6, Socket::SOCK_STREAM, Socket::IPPROTO_TCP]
]
- res.each { |a| expected.should include(a) }
+ res.each { |a| expected.should include (a) }
end
it "accepts empty addresses for IPv6 non-passive sockets" do
@@ -108,266 +110,3 @@ describe "Socket.getaddrinfo" do
end
end
end
-
-describe 'Socket.getaddrinfo' do
- describe 'without global reverse lookups' do
- it 'returns an Array' do
- Socket.getaddrinfo(nil, 'ftp').should be_an_instance_of(Array)
- end
-
- it 'accepts an Integer as the address family' do
- array = Socket.getaddrinfo(nil, 'ftp', Socket::AF_INET)[0]
-
- array[0].should == 'AF_INET'
- array[1].should == 21
- array[2].should == '127.0.0.1'
- array[3].should == '127.0.0.1'
- array[4].should == Socket::AF_INET
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts an Integer as the address family using IPv6' do
- array = Socket.getaddrinfo(nil, 'ftp', Socket::AF_INET6)[0]
-
- array[0].should == 'AF_INET6'
- array[1].should == 21
- array[2].should == '::1'
- array[3].should == '::1'
- array[4].should == Socket::AF_INET6
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts a Symbol as the address family' do
- array = Socket.getaddrinfo(nil, 'ftp', :INET)[0]
-
- array[0].should == 'AF_INET'
- array[1].should == 21
- array[2].should == '127.0.0.1'
- array[3].should == '127.0.0.1'
- array[4].should == Socket::AF_INET
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts a Symbol as the address family using IPv6' do
- array = Socket.getaddrinfo(nil, 'ftp', :INET6)[0]
-
- array[0].should == 'AF_INET6'
- array[1].should == 21
- array[2].should == '::1'
- array[3].should == '::1'
- array[4].should == Socket::AF_INET6
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts a String as the address family' do
- array = Socket.getaddrinfo(nil, 'ftp', 'INET')[0]
-
- array[0].should == 'AF_INET'
- array[1].should == 21
- array[2].should == '127.0.0.1'
- array[3].should == '127.0.0.1'
- array[4].should == Socket::AF_INET
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts a String as the address family using IPv6' do
- array = Socket.getaddrinfo(nil, 'ftp', 'INET6')[0]
-
- array[0].should == 'AF_INET6'
- array[1].should == 21
- array[2].should == '::1'
- array[3].should == '::1'
- array[4].should == Socket::AF_INET6
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts an object responding to #to_str as the host' do
- dummy = mock(:dummy)
-
- dummy.stub!(:to_str).and_return('127.0.0.1')
-
- array = Socket.getaddrinfo(dummy, 'ftp')[0]
-
- array[0].should == 'AF_INET'
- array[1].should == 21
- array[2].should == '127.0.0.1'
- array[3].should == '127.0.0.1'
- array[4].should == Socket::AF_INET
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts an object responding to #to_str as the address family' do
- dummy = mock(:dummy)
-
- dummy.stub!(:to_str).and_return('INET')
-
- array = Socket.getaddrinfo(nil, 'ftp', dummy)[0]
-
- array[0].should == 'AF_INET'
- array[1].should == 21
- array[2].should == '127.0.0.1'
- array[3].should == '127.0.0.1'
- array[4].should == Socket::AF_INET
- array[5].should be_kind_of(Integer)
- array[6].should be_kind_of(Integer)
- end
-
- it 'accepts an Integer as the socket type' do
- *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, Socket::SOCK_STREAM)[0]
- array.should == [
- 'AF_INET',
- 21,
- '127.0.0.1',
- '127.0.0.1',
- Socket::AF_INET,
- Socket::SOCK_STREAM,
- ]
- [0, Socket::IPPROTO_TCP].should include(proto)
- end
-
- it 'accepts a Symbol as the socket type' do
- *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM)[0]
- array.should == [
- 'AF_INET',
- 21,
- '127.0.0.1',
- '127.0.0.1',
- Socket::AF_INET,
- Socket::SOCK_STREAM,
- ]
- [0, Socket::IPPROTO_TCP].should include(proto)
- end
-
- it 'accepts a String as the socket type' do
- *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, 'STREAM')[0]
- array.should == [
- 'AF_INET',
- 21,
- '127.0.0.1',
- '127.0.0.1',
- Socket::AF_INET,
- Socket::SOCK_STREAM,
- ]
- [0, Socket::IPPROTO_TCP].should include(proto)
- end
-
- it 'accepts an object responding to #to_str as the socket type' do
- dummy = mock(:dummy)
-
- dummy.stub!(:to_str).and_return('STREAM')
-
- *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, dummy)[0]
- array.should == [
- 'AF_INET',
- 21,
- '127.0.0.1',
- '127.0.0.1',
- Socket::AF_INET,
- Socket::SOCK_STREAM,
- ]
- [0, Socket::IPPROTO_TCP].should include(proto)
- end
-
- platform_is_not :windows do
- it 'accepts an Integer as the protocol family' do
- *array, proto = Socket.getaddrinfo(nil, 'discard', :INET, :DGRAM, Socket::IPPROTO_UDP)[0]
- array.should == [
- 'AF_INET',
- 9,
- '127.0.0.1',
- '127.0.0.1',
- Socket::AF_INET,
- Socket::SOCK_DGRAM,
- ]
- [0, Socket::IPPROTO_UDP].should include(proto)
- end
- end
-
- it 'accepts an Integer as the flags' do
- *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
- Socket::IPPROTO_TCP, Socket::AI_PASSIVE)[0]
- array.should == [
- 'AF_INET',
- 21,
- '0.0.0.0',
- '0.0.0.0',
- Socket::AF_INET,
- Socket::SOCK_STREAM,
- ]
- [0, Socket::IPPROTO_TCP].should include(proto)
- end
-
- it 'performs a reverse lookup when the reverse_lookup argument is true' do
- addr = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
- Socket::IPPROTO_TCP, 0, true)[0]
-
- addr[0].should == 'AF_INET'
- addr[1].should == 21
-
- addr[2].should be_an_instance_of(String)
- addr[2].should_not == addr[3]
-
- addr[3].should == '127.0.0.1'
- end
-
- it 'performs a reverse lookup when the reverse_lookup argument is :hostname' do
- addr = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
- Socket::IPPROTO_TCP, 0, :hostname)[0]
-
- addr[0].should == 'AF_INET'
- addr[1].should == 21
-
- addr[2].should be_an_instance_of(String)
- addr[2].should_not == addr[3]
-
- addr[3].should == '127.0.0.1'
- end
-
- it 'performs a reverse lookup when the reverse_lookup argument is :numeric' do
- *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM,
- Socket::IPPROTO_TCP, 0, :numeric)[0]
- array.should == [
- 'AF_INET',
- 21,
- '127.0.0.1',
- '127.0.0.1',
- Socket::AF_INET,
- Socket::SOCK_STREAM,
- ]
- [0, Socket::IPPROTO_TCP].should include(proto)
- end
- end
-
- describe 'with global reverse lookups' do
- before do
- @do_not_reverse_lookup = BasicSocket.do_not_reverse_lookup
- BasicSocket.do_not_reverse_lookup = false
- end
-
- after do
- BasicSocket.do_not_reverse_lookup = @do_not_reverse_lookup
- end
-
- it 'returns an address honoring the global lookup option' do
- addr = Socket.getaddrinfo(nil, 'ftp', :INET)[0]
-
- addr[0].should == 'AF_INET'
- addr[1].should == 21
-
- # We don't have control over this value and there's no way to test this
- # without relying on Socket.getaddrinfo()'s own behaviour (meaning this
- # test would faily any way of the method was not implemented correctly).
- addr[2].should be_an_instance_of(String)
- addr[2].should_not == addr[3]
-
- addr[3].should == '127.0.0.1'
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb
index 5d97341103..fcd29e1257 100644
--- a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb
+++ b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb
@@ -1,124 +1,2 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require 'ipaddr'
-
-describe 'Socket.gethostbyaddr' do
- describe 'using an IPv4 address' do
- before do
- @addr = IPAddr.new('127.0.0.1').hton
- end
-
- describe 'without an explicit address family' do
- it 'returns an Array' do
- Socket.gethostbyaddr(@addr).should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = Socket.gethostbyaddr(@addr)
- end
-
- # RubyCI Solaris 11x defines 127.0.0.1 as unstable11x
- platform_is_not :"solaris2.11" do
- it 'includes the hostname as the first value' do
- @array[0].should == SocketSpecs.hostname_reverse_lookup
- end
- end
-
- it 'includes the aliases as the 2nd value' do
- @array[1].should be_an_instance_of(Array)
-
- @array[1].each do |val|
- val.should be_an_instance_of(String)
- end
- end
-
- it 'includes the address type as the 3rd value' do
- @array[2].should == Socket::AF_INET
- end
-
- it 'includes all address strings as the remaining values' do
- @array[3].should == @addr
-
- @array[4..-1].each do |val|
- val.should be_an_instance_of(String)
- end
- end
- end
- end
-
- describe 'with an explicit address family' do
- it 'returns an Array when using an Integer as the address family' do
- Socket.gethostbyaddr(@addr, Socket::AF_INET).should be_an_instance_of(Array)
- end
-
- it 'returns an Array when using a Symbol as the address family' do
- Socket.gethostbyaddr(@addr, :INET).should be_an_instance_of(Array)
- end
-
- it 'raises SocketError when the address is not supported by the family' do
- -> { Socket.gethostbyaddr(@addr, :INET6) }.should raise_error(SocketError)
- end
- end
- end
-
- guard -> { SocketSpecs.ipv6_available? && platform_is_not(:aix) } do
- describe 'using an IPv6 address' do
- before do
- @addr = IPAddr.new('::1').hton
- end
-
- describe 'without an explicit address family' do
- it 'returns an Array' do
- Socket.gethostbyaddr(@addr).should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = Socket.gethostbyaddr(@addr)
- end
-
- it 'includes the hostname as the first value' do
- @array[0].should == SocketSpecs.hostname_reverse_lookup("::1")
- end
-
- it 'includes the aliases as the 2nd value' do
- @array[1].should be_an_instance_of(Array)
-
- @array[1].each do |val|
- val.should be_an_instance_of(String)
- end
- end
-
- it 'includes the address type as the 3rd value' do
- @array[2].should == Socket::AF_INET6
- end
-
- it 'includes all address strings as the remaining values' do
- @array[3].should be_an_instance_of(String)
-
- @array[4..-1].each do |val|
- val.should be_an_instance_of(String)
- end
- end
- end
- end
-
- describe 'with an explicit address family' do
- it 'returns an Array when using an Integer as the address family' do
- Socket.gethostbyaddr(@addr, Socket::AF_INET6).should be_an_instance_of(Array)
- end
-
- it 'returns an Array when using a Symbol as the address family' do
- Socket.gethostbyaddr(@addr, :INET6).should be_an_instance_of(Array)
- end
-
- platform_is_not :windows do
- it 'raises SocketError when the address is not supported by the family' do
- -> { Socket.gethostbyaddr(@addr, :INET) }.should raise_error(SocketError)
- end
- end
- end
- end
- end
-end
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
diff --git a/spec/ruby/library/socket/socket/gethostbyname_spec.rb b/spec/ruby/library/socket/socket/gethostbyname_spec.rb
index 2696f44566..a93c9ffb98 100644
--- a/spec/ruby/library/socket/socket/gethostbyname_spec.rb
+++ b/spec/ruby/library/socket/socket/gethostbyname_spec.rb
@@ -1,135 +1,17 @@
# -*- encoding: binary -*-
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "Socket.gethostbyname" do
+require 'socket'
+
+describe "Socket#gethostbyname" do
it "returns broadcast address info for '<broadcast>'" do
addr = Socket.gethostbyname('<broadcast>');
- addr.should == ["255.255.255.255", [], 2, "\xFF\xFF\xFF\xFF"]
+ addr.should == ["255.255.255.255", [], 2, "\377\377\377\377"]
end
it "returns broadcast address info for '<any>'" do
addr = Socket.gethostbyname('<any>');
- addr.should == ["0.0.0.0", [], 2, "\x00\x00\x00\x00"]
- end
-end
-
-describe 'Socket.gethostbyname' do
- it 'returns an Array' do
- Socket.gethostbyname('127.0.0.1').should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = Socket.gethostbyname('127.0.0.1')
- end
-
- it 'includes the hostname as the first value' do
- @array[0].should == '127.0.0.1'
- end
-
- it 'includes the aliases as the 2nd value' do
- @array[1].should be_an_instance_of(Array)
-
- @array[1].each do |val|
- val.should be_an_instance_of(String)
- end
- end
-
- it 'includes the address type as the 3rd value' do
- possible = [Socket::AF_INET, Socket::AF_INET6]
-
- possible.include?(@array[2]).should == true
- end
-
- it 'includes the address strings as the remaining values' do
- @array[3].should be_an_instance_of(String)
-
- @array[4..-1].each do |val|
- val.should be_an_instance_of(String)
- end
- end
- end
-
- describe 'using <broadcast> as the input address' do
- describe 'the returned Array' do
- before do
- @addr = Socket.gethostbyname('<broadcast>')
- end
-
- it 'includes the broadcast address as the first value' do
- @addr[0].should == '255.255.255.255'
- end
-
- it 'includes the address type as the 3rd value' do
- @addr[2].should == Socket::AF_INET
- end
-
- it 'includes the address string as the 4th value' do
- @addr[3].should == [255, 255, 255, 255].pack('C4')
- end
- end
- end
-
- describe 'using <any> as the input address' do
- describe 'the returned Array' do
- before do
- @addr = Socket.gethostbyname('<any>')
- end
-
- it 'includes the wildcard address as the first value' do
- @addr[0].should == '0.0.0.0'
- end
-
- it 'includes the address type as the 3rd value' do
- @addr[2].should == Socket::AF_INET
- end
-
- it 'includes the address string as the 4th value' do
- @addr[3].should == [0, 0, 0, 0].pack('C4')
- end
- end
- end
-
- describe 'using an IPv4 address' do
- describe 'the returned Array' do
- before do
- @addr = Socket.gethostbyname('127.0.0.1')
- end
-
- it 'includes the IP address as the first value' do
- @addr[0].should == '127.0.0.1'
- end
-
- it 'includes the address type as the 3rd value' do
- @addr[2].should == Socket::AF_INET
- end
-
- it 'includes the address string as the 4th value' do
- @addr[3].should == [127, 0, 0, 1].pack('C4')
- end
- end
- end
-
- guard -> { SocketSpecs.ipv6_available? } do
- describe 'using an IPv6 address' do
- describe 'the returned Array' do
- before do
- @addr = Socket.gethostbyname('::1')
- end
-
- it 'includes the IP address as the first value' do
- @addr[0].should == '::1'
- end
-
- it 'includes the address type as the 3rd value' do
- @addr[2].should == Socket::AF_INET6
- end
-
- it 'includes the address string as the 4th value' do
- @addr[3].should == [0, 0, 0, 0, 0, 0, 0, 1].pack('n8')
- end
- end
- end
+ addr.should == ["0.0.0.0", [], 2, "\000\000\000\000"]
end
end
diff --git a/spec/ruby/library/socket/socket/gethostname_spec.rb b/spec/ruby/library/socket/socket/gethostname_spec.rb
index 4b79747b27..c61e6b3eb4 100644
--- a/spec/ruby/library/socket/socket/gethostname_spec.rb
+++ b/spec/ruby/library/socket/socket/gethostname_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket.gethostname" do
it "returns the host name" do
diff --git a/spec/ruby/library/socket/socket/getifaddrs_spec.rb b/spec/ruby/library/socket/socket/getifaddrs_spec.rb
deleted file mode 100644
index 7df542abe6..0000000000
--- a/spec/ruby/library/socket/socket/getifaddrs_spec.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-require_relative '../spec_helper'
-
-platform_is_not :aix, :"solaris2.10" do
-describe 'Socket.getifaddrs' do
- before do
- @ifaddrs = Socket.getifaddrs
- end
-
- it 'returns an Array' do
- @ifaddrs.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- it 'should not be empty' do
- @ifaddrs.should_not be_empty
- end
-
- it 'contains instances of Socket::Ifaddr' do
- @ifaddrs.each do |ifaddr|
- ifaddr.should be_an_instance_of(Socket::Ifaddr)
- end
- end
- end
-
- describe 'each returned Socket::Ifaddr' do
- it 'has an interface index' do
- @ifaddrs.each do |ifaddr|
- ifaddr.ifindex.should be_kind_of(Integer)
- end
- end
-
- it 'has an interface name' do
- @ifaddrs.each do |ifaddr|
- ifaddr.name.should be_an_instance_of(String)
- end
- end
-
- it 'has a set of flags' do
- @ifaddrs.each do |ifaddr|
- ifaddr.flags.should be_kind_of(Integer)
- end
- end
- end
-
- describe 'the Socket::Ifaddr address' do
- before do
- @addrs = @ifaddrs.map(&:addr).compact
- end
-
- it 'is an Addrinfo' do
- @addrs.all? do |addr|
- addr.should be_an_instance_of(Addrinfo)
- true
- end.should be_true
- end
-
- it 'has an address family' do
- @addrs.all? do |addr|
- addr.afamily.should be_kind_of(Integer)
- addr.afamily.should_not == Socket::AF_UNSPEC
- true
- end.should be_true
- end
- end
-
- platform_is_not :windows do
- describe 'the Socket::Ifaddr broadcast address' do
- before do
- @addrs = @ifaddrs.map(&:broadaddr).compact
- end
-
- it 'is an Addrinfo' do
- @addrs.all? do |addr|
- addr.should be_an_instance_of(Addrinfo)
- true
- end.should be_true
- end
-
- it 'has an address family' do
- @addrs.all? do |addr|
- addr.afamily.should be_kind_of(Integer)
- addr.afamily.should_not == Socket::AF_UNSPEC
- true
- end.should be_true
- end
- end
-
- describe 'the Socket::Ifaddr netmask address' do
- before do
- @addrs = @ifaddrs.map(&:netmask).compact.select(&:ip?)
- end
-
- it 'is an Addrinfo' do
- @addrs.all? do |addr|
- addr.should be_an_instance_of(Addrinfo)
- true
- end.should be_true
- end
-
- it 'has an address family' do
- @addrs.all? do |addr|
- addr.afamily.should be_kind_of(Integer)
- addr.afamily.should_not == Socket::AF_UNSPEC
- true
- end.should be_true
- end
-
- it 'has an IP address' do
- @addrs.all? do |addr|
- addr.ip_address.should be_an_instance_of(String)
- true
- end.should be_true
- end
- end
- end
-end
-end
diff --git a/spec/ruby/library/socket/socket/getnameinfo_spec.rb b/spec/ruby/library/socket/socket/getnameinfo_spec.rb
index b406348aa8..9fc55dd61b 100644
--- a/spec/ruby/library/socket/socket/getnameinfo_spec.rb
+++ b/spec/ruby/library/socket/socket/getnameinfo_spec.rb
@@ -1,5 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+require 'socket'
describe "Socket.getnameinfo" do
before :each do
@@ -60,88 +62,5 @@ describe "Socket.getnameinfo" do
name_info = Socket.getnameinfo ["AF_INET", 9, 'foo', '127.0.0.1']
name_info[1].should == 'discard'
end
-end
-
-describe 'Socket.getnameinfo' do
- describe 'using a String as the first argument' do
- before do
- @addr = Socket.sockaddr_in(21, '127.0.0.1')
- end
-
- it 'raises SocketError or TypeError when using an invalid String' do
- -> { Socket.getnameinfo('cats') }.should raise_error(Exception) { |e|
- [SocketError, TypeError].should include(e.class)
- }
- end
-
- describe 'without custom flags' do
- it 'returns an Array containing the hostname and service name' do
- Socket.getnameinfo(@addr).should == [SocketSpecs.hostname_reverse_lookup, 'ftp']
- end
- end
-
- describe 'using NI_NUMERICHOST as the flag' do
- it 'returns an Array containing the numeric hostname and service name' do
- array = Socket.getnameinfo(@addr, Socket::NI_NUMERICHOST)
-
- %w{127.0.0.1 ::1}.include?(array[0]).should == true
-
- array[1].should == 'ftp'
- end
- end
- end
- SocketSpecs.each_ip_protocol do |family, ip_address, family_name|
- before do
- @hostname = SocketSpecs.hostname_reverse_lookup(ip_address)
- end
-
- describe 'using a 3 element Array as the first argument' do
- before do
- @addr = [family_name, 21, @hostname]
- end
-
- it 'raises ArgumentError when using an invalid Array' do
- -> { Socket.getnameinfo([family_name]) }.should raise_error(ArgumentError)
- end
-
- platform_is_not :windows do
- describe 'using NI_NUMERICHOST as the flag' do
- it 'returns an Array containing the numeric hostname and service name' do
- Socket.getnameinfo(@addr, Socket::NI_NUMERICHOST).should == [ip_address, 'ftp']
- end
- end
- end
- end
-
- describe 'using a 4 element Array as the first argument' do
- before do
- @addr = [family_name, 21, ip_address, ip_address]
- end
-
- describe 'without custom flags' do
- it 'returns an Array containing the hostname and service name' do
- array = Socket.getnameinfo(@addr)
- array.should be_an_instance_of(Array)
- array[0].should == @hostname
- array[1].should == 'ftp'
- end
-
- it 'uses the 3rd value as the hostname if the 4th is not present' do
- addr = [family_name, 21, ip_address, nil]
-
- array = Socket.getnameinfo(addr)
- array.should be_an_instance_of(Array)
- array[0].should == @hostname
- array[1].should == 'ftp'
- end
- end
-
- describe 'using NI_NUMERICHOST as the flag' do
- it 'returns an Array containing the numeric hostname and service name' do
- Socket.getnameinfo(@addr, Socket::NI_NUMERICHOST).should == [ip_address, 'ftp']
- end
- end
- end
- end
end
diff --git a/spec/ruby/library/socket/socket/getservbyname_spec.rb b/spec/ruby/library/socket/socket/getservbyname_spec.rb
index d361e619f2..a48b5753b4 100644
--- a/spec/ruby/library/socket/socket/getservbyname_spec.rb
+++ b/spec/ruby/library/socket/socket/getservbyname_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket#getservbyname" do
it "returns the port for service 'discard'" do
@@ -10,14 +10,6 @@ describe "Socket#getservbyname" do
Socket.getservbyname('discard', 'tcp').should == 9
end
- it 'returns the port for service "ftp"' do
- Socket.getservbyname('ftp').should == 21
- end
-
- it 'returns the port for service "ftp" with protocol "tcp"' do
- Socket.getservbyname('ftp', 'tcp').should == 21
- end
-
it "returns the port for service 'domain' with protocol 'udp'" do
Socket.getservbyname('domain', 'udp').should == 53
end
@@ -27,6 +19,6 @@ describe "Socket#getservbyname" do
end
it "raises a SocketError when the service or port is invalid" do
- -> { Socket.getservbyname('invalid') }.should raise_error(SocketError)
+ lambda { Socket.getservbyname('invalid') }.should raise_error(SocketError)
end
end
diff --git a/spec/ruby/library/socket/socket/getservbyport_spec.rb b/spec/ruby/library/socket/socket/getservbyport_spec.rb
deleted file mode 100644
index 563c592b54..0000000000
--- a/spec/ruby/library/socket/socket/getservbyport_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.getservbyport' do
- platform_is_not :windows do
- it 'returns the service name as a String' do
- Socket.getservbyport(514).should == 'shell'
- end
- end
-
- platform_is :windows do
- it 'returns the service name as a String' do
- Socket.getservbyport(514).should == 'cmd'
- end
- end
-
- it 'returns the service name when using a custom protocol name' do
- Socket.getservbyport(514, 'udp').should == 'syslog'
- end
-
- it 'raises SocketError for an unknown port number' do
- -> { Socket.getservbyport(0) }.should raise_error(SocketError)
- end
-end
diff --git a/spec/ruby/library/socket/socket/initialize_spec.rb b/spec/ruby/library/socket/socket/initialize_spec.rb
deleted file mode 100644
index f8337bcaa5..0000000000
--- a/spec/ruby/library/socket/socket/initialize_spec.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket#initialize' do
- before do
- @socket = nil
- end
-
- after do
- @socket.close if @socket
- end
-
- describe 'using an Integer as the 1st and 2nd arguments' do
- it 'returns a Socket' do
- @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
-
- @socket.should be_an_instance_of(Socket)
- end
- end
-
- describe 'using Symbols as the 1st and 2nd arguments' do
- it 'returns a Socket' do
- @socket = Socket.new(:INET, :STREAM)
-
- @socket.should be_an_instance_of(Socket)
- end
- end
-
- describe 'using Strings as the 1st and 2nd arguments' do
- it 'returns a Socket' do
- @socket = Socket.new('INET', 'STREAM')
-
- @socket.should be_an_instance_of(Socket)
- end
- end
-
- describe 'using objects that respond to #to_str' do
- it 'returns a Socket' do
- family = mock(:family)
- type = mock(:type)
-
- family.stub!(:to_str).and_return('AF_INET')
- type.stub!(:to_str).and_return('STREAM')
-
- @socket = Socket.new(family, type)
-
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'raises TypeError when the #to_str method does not return a String' do
- family = mock(:family)
- type = mock(:type)
-
- family.stub!(:to_str).and_return(Socket::AF_INET)
- type.stub!(:to_str).and_return(Socket::SOCK_STREAM)
-
- -> { Socket.new(family, type) }.should raise_error(TypeError)
- end
- end
-
- describe 'using a custom protocol' do
- it 'returns a Socket when using an Integer' do
- @socket = Socket.new(:INET, :STREAM, Socket::IPPROTO_TCP)
-
- @socket.should be_an_instance_of(Socket)
- end
-
- it 'raises TypeError when using a Symbol' do
- -> { Socket.new(:INET, :STREAM, :TCP) }.should raise_error(TypeError)
- end
- end
-
- it 'sets the do_not_reverse_lookup option' do
- @socket = Socket.new(:INET, :STREAM)
-
- @socket.do_not_reverse_lookup.should == Socket.do_not_reverse_lookup
- end
-
- it "sets basic IO accessors" do
- @socket = Socket.new(:INET, :STREAM)
- @socket.lineno.should == 0
- end
-
- it "sets the socket to binary mode" do
- @socket = Socket.new(:INET, :STREAM)
- @socket.binmode?.should be_true
- end
-end
diff --git a/spec/ruby/library/socket/socket/ip_address_list_spec.rb b/spec/ruby/library/socket/socket/ip_address_list_spec.rb
deleted file mode 100644
index f97c2d7f85..0000000000
--- a/spec/ruby/library/socket/socket/ip_address_list_spec.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.ip_address_list' do
- it 'returns an Array' do
- Socket.ip_address_list.should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- @array = Socket.ip_address_list
- end
-
- it 'is not empty' do
- @array.should_not be_empty
- end
-
- it 'contains Addrinfo objects' do
- @array.each do |klass|
- klass.should be_an_instance_of(Addrinfo)
- end
- end
- end
-
- describe 'each returned Addrinfo' do
- before do
- @array = Socket.ip_address_list
- end
-
- it 'has a non-empty IP address' do
- @array.each do |addr|
- addr.ip_address.should be_an_instance_of(String)
- addr.ip_address.should_not be_empty
- end
- end
-
- it 'has an address family' do
- families = [Socket::AF_INET, Socket::AF_INET6]
-
- @array.each do |addr|
- families.include?(addr.afamily).should == true
- end
- end
-
- it 'uses 0 as the port number' do
- @array.each do |addr|
- addr.ip_port.should == 0
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/ipv6only_bang_spec.rb b/spec/ruby/library/socket/socket/ipv6only_bang_spec.rb
deleted file mode 100644
index 4f429c089e..0000000000
--- a/spec/ruby/library/socket/socket/ipv6only_bang_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-guard -> { SocketSpecs.ipv6_available? } do
- describe 'Socket#ipv6only!' do
- before do
- @socket = Socket.new(:INET6, :DGRAM)
- end
-
- after do
- @socket.close
- end
-
- it 'enables IPv6 only mode' do
- @socket.ipv6only!
-
- @socket.getsockopt(:IPV6, :V6ONLY).bool.should == true
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/listen_spec.rb b/spec/ruby/library/socket/socket/listen_spec.rb
index 5de70d6db0..bea87f4ec5 100644
--- a/spec/ruby/library/socket/socket/listen_spec.rb
+++ b/spec/ruby/library/socket/socket/listen_spec.rb
@@ -1,9 +1,11 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+include Socket::Constants
describe "Socket#listen" do
before :each do
- @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
+ @socket = Socket.new(AF_INET, SOCK_STREAM, 0)
end
after :each do
@@ -18,47 +20,3 @@ describe "Socket#listen" do
@socket.listen(1).should == 0
end
end
-
-describe 'Socket#listen' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'using a DGRAM socket' do
- before do
- @server = Socket.new(family, :DGRAM)
- @client = Socket.new(family, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'raises Errno::EOPNOTSUPP' do
- -> { @server.listen(1) }.should raise_error(Errno::EOPNOTSUPP)
- end
- end
-
- describe 'using a STREAM socket' do
- before do
- @server = Socket.new(family, :STREAM)
- @client = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'returns 0' do
- @server.listen(1).should == 0
- end
-
- it "raises when the given argument can't be coerced to an Integer" do
- -> { @server.listen('cats') }.should raise_error(TypeError)
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/local_address_spec.rb b/spec/ruby/library/socket/socket/local_address_spec.rb
deleted file mode 100644
index 3687f93a0c..0000000000
--- a/spec/ruby/library/socket/socket/local_address_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket#local_address' do
- before do
- @sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, Socket::IPPROTO_TCP)
- end
-
- after do
- @sock.close
- end
-
- it 'returns an Addrinfo' do
- @sock.local_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses AF_INET as the address family' do
- @sock.local_address.afamily.should == Socket::AF_INET
- end
-
- it 'uses PF_INET as the protocol family' do
- @sock.local_address.pfamily.should == Socket::PF_INET
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @sock.local_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses 0.0.0.0 as the IP address' do
- @sock.local_address.ip_address.should == '0.0.0.0'
- end
-
- platform_is_not :windows do
- it 'uses 0 as the port' do
- @sock.local_address.ip_port.should == 0
- end
- end
-
- it 'uses 0 as the protocol' do
- @sock.local_address.protocol.should == 0
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/new_spec.rb b/spec/ruby/library/socket/socket/new_spec.rb
index b2ec607f6a..fcd29e1257 100644
--- a/spec/ruby/library/socket/socket/new_spec.rb
+++ b/spec/ruby/library/socket/socket/new_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
diff --git a/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb b/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb
index 63d4724453..8c95b948dc 100644
--- a/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb
+++ b/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/pack_sockaddr'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/pack_sockaddr', __FILE__)
describe "Socket#pack_sockaddr_in" do
it_behaves_like :socket_pack_sockaddr_in, :pack_sockaddr_in
diff --git a/spec/ruby/library/socket/socket/pack_sockaddr_un_spec.rb b/spec/ruby/library/socket/socket/pack_sockaddr_un_spec.rb
index 1ee0bc6157..aacb6d54dc 100644
--- a/spec/ruby/library/socket/socket/pack_sockaddr_un_spec.rb
+++ b/spec/ruby/library/socket/socket/pack_sockaddr_un_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/pack_sockaddr'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/pack_sockaddr', __FILE__)
describe "Socket#pack_sockaddr_un" do
it_behaves_like :socket_pack_sockaddr_un, :pack_sockaddr_un
diff --git a/spec/ruby/library/socket/socket/pair_spec.rb b/spec/ruby/library/socket/socket/pair_spec.rb
index 292eacd38d..663ca3f183 100644
--- a/spec/ruby/library/socket/socket/pair_spec.rb
+++ b/spec/ruby/library/socket/socket/pair_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/socketpair'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/socketpair', __FILE__)
describe "Socket#pair" do
it_behaves_like :socket_socketpair, :pair
diff --git a/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb b/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb
index 94f58ac49f..fcd29e1257 100644
--- a/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb
+++ b/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb
@@ -1,118 +1,2 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket#recvfrom_nonblock' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :DGRAM)
- @client = Socket.new(family, :DGRAM)
- end
-
- after do
- @client.close
- @server.close
- end
-
- platform_is_not :windows do
- describe 'using an unbound socket' do
- it 'raises IO::WaitReadable' do
- -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable)
- end
- end
- end
-
- describe 'using a bound socket' do
- before do
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @client.connect(@server.getsockname)
- end
-
- describe 'without any data available' do
- it 'raises IO::WaitReadable' do
- -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable)
- end
-
- it 'returns :wait_readable with exception: false' do
- @server.recvfrom_nonblock(1, exception: false).should == :wait_readable
- end
- end
-
- describe 'with data available' do
- before do
- @client.write('hello')
- end
-
- platform_is_not :windows do
- it 'returns an Array containing the data and an Addrinfo' do
- IO.select([@server])
- ret = @server.recvfrom_nonblock(1)
-
- ret.should be_an_instance_of(Array)
- ret.length.should == 2
- end
- end
-
- describe 'the returned data' do
- it 'is the same as the sent data' do
- 5.times do
- @client.write('hello')
-
- IO.select([@server])
- msg, _ = @server.recvfrom_nonblock(5)
-
- msg.should == 'hello'
- end
- end
- end
-
- platform_is_not :windows do
- describe 'the returned Array' do
- before do
- IO.select([@server])
- @array = @server.recvfrom_nonblock(1)
- end
-
- it 'contains the data at index 0' do
- @array[0].should == 'h'
- end
-
- it 'contains an Addrinfo at index 1' do
- @array[1].should be_an_instance_of(Addrinfo)
- end
- end
-
- describe 'the returned Addrinfo' do
- before do
- IO.select([@server])
- @addr = @server.recvfrom_nonblock(1)[1]
- end
-
- it 'uses AF_INET as the address family' do
- @addr.afamily.should == family
- end
-
- it 'uses SOCK_DGRAM as the socket type' do
- @addr.socktype.should == Socket::SOCK_DGRAM
- end
-
- it 'uses PF_INET as the protocol family' do
- @addr.pfamily.should == family
- end
-
- it 'uses 0 as the protocol' do
- @addr.protocol.should == 0
- end
-
- it 'uses the IP address of the client' do
- @addr.ip_address.should == ip_address
- end
-
- it 'uses the port of the client' do
- @addr.ip_port.should == @client.local_address.ip_port
- end
- end
- end
- end
- end
- end
-end
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
diff --git a/spec/ruby/library/socket/socket/recvfrom_spec.rb b/spec/ruby/library/socket/socket/recvfrom_spec.rb
index faf161e4a5..fcd29e1257 100644
--- a/spec/ruby/library/socket/socket/recvfrom_spec.rb
+++ b/spec/ruby/library/socket/socket/recvfrom_spec.rb
@@ -1,92 +1,2 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket#recvfrom' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :DGRAM)
- @client = Socket.new(family, :DGRAM)
- end
-
- after do
- @client.close
- @server.close
- end
-
- describe 'using an unbound socket' do
- it 'blocks the caller' do
- -> { @server.recvfrom(1) }.should block_caller
- end
- end
-
- describe 'using a bound socket' do
- before do
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @client.connect(@server.getsockname)
- end
-
- describe 'without any data available' do
- it 'blocks the caller' do
- -> { @server.recvfrom(1) }.should block_caller
- end
- end
-
- describe 'with data available' do
- before do
- @client.write('hello')
- end
-
- it 'returns an Array containing the data and an Addrinfo' do
- ret = @server.recvfrom(1)
-
- ret.should be_an_instance_of(Array)
- ret.length.should == 2
- end
-
- describe 'the returned Array' do
- before do
- @array = @server.recvfrom(1)
- end
-
- it 'contains the data at index 0' do
- @array[0].should == 'h'
- end
-
- it 'contains an Addrinfo at index 1' do
- @array[1].should be_an_instance_of(Addrinfo)
- end
- end
-
- describe 'the returned Addrinfo' do
- before do
- @addr = @server.recvfrom(1)[1]
- end
-
- it 'uses AF_INET as the address family' do
- @addr.afamily.should == family
- end
-
- it 'uses SOCK_DGRAM as the socket type' do
- @addr.socktype.should == Socket::SOCK_DGRAM
- end
-
- it 'uses PF_INET as the protocol family' do
- @addr.pfamily.should == family
- end
-
- it 'uses 0 as the protocol' do
- @addr.protocol.should == 0
- end
-
- it 'uses the IP address of the client' do
- @addr.ip_address.should == ip_address
- end
-
- it 'uses the port of the client' do
- @addr.ip_port.should == @client.local_address.ip_port
- end
- end
- end
- end
- end
-end
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
diff --git a/spec/ruby/library/socket/socket/remote_address_spec.rb b/spec/ruby/library/socket/socket/remote_address_spec.rb
deleted file mode 100644
index 24d60d7f58..0000000000
--- a/spec/ruby/library/socket/socket/remote_address_spec.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket#remote_address' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :STREAM)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
- @server.listen(1)
-
- @host = @server.local_address.ip_address
- @port = @server.local_address.ip_port
- @client = Socket.new(family, :STREAM, Socket::IPPROTO_TCP)
-
- @client.connect(Socket.sockaddr_in(@port, @host))
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'returns an Addrinfo' do
- @client.remote_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses AF_INET as the address family' do
- @client.remote_address.afamily.should == family
- end
-
- it 'uses PF_INET as the protocol family' do
- @client.remote_address.pfamily.should == family
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @client.remote_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses the correct IP address' do
- @client.remote_address.ip_address.should == @host
- end
-
- it 'uses the correct port' do
- @client.remote_address.ip_port.should == @port
- end
-
- it 'uses 0 as the protocol' do
- @client.remote_address.protocol.should == 0
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/sockaddr_in_spec.rb b/spec/ruby/library/socket/socket/sockaddr_in_spec.rb
index 8ee956ac26..59e0318fda 100644
--- a/spec/ruby/library/socket/socket/sockaddr_in_spec.rb
+++ b/spec/ruby/library/socket/socket/sockaddr_in_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/pack_sockaddr'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/pack_sockaddr', __FILE__)
describe "Socket#sockaddr_in" do
it_behaves_like :socket_pack_sockaddr_in, :sockaddr_in
diff --git a/spec/ruby/library/socket/socket/sockaddr_un_spec.rb b/spec/ruby/library/socket/socket/sockaddr_un_spec.rb
index 8922ff4d6d..fa233587d9 100644
--- a/spec/ruby/library/socket/socket/sockaddr_un_spec.rb
+++ b/spec/ruby/library/socket/socket/sockaddr_un_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/pack_sockaddr'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/pack_sockaddr', __FILE__)
describe "Socket#sockaddr_un" do
it_behaves_like :socket_pack_sockaddr_un, :sockaddr_un
diff --git a/spec/ruby/library/socket/socket/socket_spec.rb b/spec/ruby/library/socket/socket/socket_spec.rb
index 5a3d6733e0..dbaed17af4 100644
--- a/spec/ruby/library/socket/socket/socket_spec.rb
+++ b/spec/ruby/library/socket/socket/socket_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket" do
it "inherits from BasicSocket and IO" do
diff --git a/spec/ruby/library/socket/socket/socketpair_spec.rb b/spec/ruby/library/socket/socket/socketpair_spec.rb
index 5b8311124e..80b07170a6 100644
--- a/spec/ruby/library/socket/socket/socketpair_spec.rb
+++ b/spec/ruby/library/socket/socket/socketpair_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/socketpair'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/socketpair', __FILE__)
describe "Socket#socketpair" do
it_behaves_like :socket_socketpair, :socketpair
diff --git a/spec/ruby/library/socket/socket/sysaccept_spec.rb b/spec/ruby/library/socket/socket/sysaccept_spec.rb
index 92ac21124e..fcd29e1257 100644
--- a/spec/ruby/library/socket/socket/sysaccept_spec.rb
+++ b/spec/ruby/library/socket/socket/sysaccept_spec.rb
@@ -1,91 +1,2 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket#sysaccept' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :STREAM)
- @sockaddr = Socket.sockaddr_in(0, ip_address)
- end
-
- after do
- @server.close
- end
-
- platform_is :linux do # hangs on other platforms
- describe 'using an unbound socket' do
- it 'raises Errno::EINVAL' do
- -> { @server.sysaccept }.should raise_error(Errno::EINVAL)
- end
- end
-
- describe "using a bound socket that's not listening" do
- before do
- @server.bind(@sockaddr)
- end
-
- it 'raises Errno::EINVAL' do
- -> { @server.sysaccept }.should raise_error(Errno::EINVAL)
- end
- end
- end
-
- describe "using a bound socket that's listening" do
- before do
- @server.bind(@sockaddr)
- @server.listen(1)
-
- server_ip = @server.local_address.ip_port
- @server_addr = Socket.sockaddr_in(server_ip, ip_address)
- end
-
- after do
- Socket.for_fd(@fd).close if @fd
- end
-
- describe 'without a connected client' do
- before do
- @client = Socket.new(family, :STREAM)
- end
-
- after do
- @client.close
- end
-
- it 'blocks the caller until a connection is available' do
- thread = Thread.new do
- @fd, _ = @server.sysaccept
- end
-
- @client.connect(@server_addr)
-
- thread.value.should be_an_instance_of(Array)
- end
- end
-
- describe 'with a connected client' do
- before do
- @client = Socket.new(family, :STREAM)
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- end
-
- it 'returns an Array containing an Integer and an Addrinfo' do
- @fd, addrinfo = @server.sysaccept
-
- @fd.should be_kind_of(Integer)
- addrinfo.should be_an_instance_of(Addrinfo)
- end
-
- it 'returns a new file descriptor' do
- @fd, _ = @server.sysaccept
-
- @fd.should_not == @client.fileno
- end
- end
- end
- end
-end
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
diff --git a/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb b/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb
deleted file mode 100644
index a46c6df5c6..0000000000
--- a/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket.tcp_server_loop' do
- describe 'when no connections are available' do
- it 'blocks the caller' do
- -> { Socket.tcp_server_loop('127.0.0.1', 0) }.should block_caller
- end
- end
-
- describe 'when a connection is available' do
- before do
- @client = Socket.new(:INET, :STREAM)
- SocketSpecs::ServerLoopPortFinder.cleanup
- end
-
- after do
- @sock.close if @sock
- @client.close
- end
-
- it 'yields a Socket and an Addrinfo' do
- @sock, addr = nil
-
- thread = Thread.new do
- SocketSpecs::ServerLoopPortFinder.tcp_server_loop('127.0.0.1', 0) do |socket, addrinfo|
- @sock = socket
- addr = addrinfo
-
- break
- end
- end
-
- port = SocketSpecs::ServerLoopPortFinder.port
-
- SocketSpecs.loop_with_timeout do
- begin
- @client.connect(Socket.sockaddr_in(port, '127.0.0.1'))
- rescue SystemCallError
- sleep 0.01
- :retry
- end
- end
-
- # At this point the connection has been set up but the thread may not yet
- # have returned, thus we'll need to wait a little longer for it to
- # complete.
- thread.join
-
- @sock.should be_an_instance_of(Socket)
- addr.should be_an_instance_of(Addrinfo)
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb b/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb
deleted file mode 100644
index 10c030a8ce..0000000000
--- a/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.tcp_server_sockets' do
- describe 'without a block' do
- before do
- @sockets = nil
- end
-
- after do
- @sockets.each(&:close)
- end
-
- it 'returns an Array of Socket objects' do
- @sockets = Socket.tcp_server_sockets(0)
-
- @sockets.should be_an_instance_of(Array)
- @sockets[0].should be_an_instance_of(Socket)
- end
- end
-
- describe 'with a block' do
- it 'yields the sockets to the supplied block' do
- Socket.tcp_server_sockets(0) do |sockets|
- sockets.should be_an_instance_of(Array)
- sockets[0].should be_an_instance_of(Socket)
- end
- end
-
- it 'closes all sockets after the block returns' do
- sockets = nil
-
- Socket.tcp_server_sockets(0) { |socks| sockets = socks }
-
- sockets.each do |socket|
- socket.closed?.should == true
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/tcp_spec.rb b/spec/ruby/library/socket/socket/tcp_spec.rb
deleted file mode 100644
index d36e3e6adb..0000000000
--- a/spec/ruby/library/socket/socket/tcp_spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.tcp' do
- before do
- @server = Socket.new(:INET, :STREAM)
- @client = nil
-
- @server.bind(Socket.sockaddr_in(0, '127.0.0.1'))
- @server.listen(1)
-
- @host = @server.connect_address.ip_address
- @port = @server.connect_address.ip_port
- end
-
- after do
- @client.close if @client && !@client.closed?
- @client = nil
-
- @server.close
- end
-
- it 'returns a Socket when no block is given' do
- @client = Socket.tcp(@host, @port)
-
- @client.should be_an_instance_of(Socket)
- end
-
- it 'yields the Socket when a block is given' do
- Socket.tcp(@host, @port) do |socket|
- socket.should be_an_instance_of(Socket)
- end
- end
-
- it 'closes the Socket automatically when a block is given' do
- Socket.tcp(@host, @port) do |socket|
- @socket = socket
- end
-
- @socket.closed?.should == true
- end
-
- it 'binds to a local address and port when specified' do
- @client = Socket.tcp(@host, @port, @host, 0)
-
- @client.local_address.ip_address.should == @host
-
- @client.local_address.ip_port.should > 0
- @client.local_address.ip_port.should_not == @port
- end
-
- it 'raises ArgumentError when 6 arguments are provided' do
- -> {
- Socket.tcp(@host, @port, @host, 0, {:connect_timeout => 1}, 10)
- }.should raise_error(ArgumentError)
- end
-
- it 'connects to the server' do
- @client = Socket.tcp(@host, @port)
-
- @client.write('hello')
-
- connection, _ = @server.accept
-
- begin
- connection.recv(5).should == 'hello'
- ensure
- connection.close
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb b/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb
deleted file mode 100644
index cb8c5c5587..0000000000
--- a/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.udp_server_loop_on' do
- before do
- @server = Socket.new(:INET, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, '127.0.0.1'))
- end
-
- after do
- @server.close
- end
-
- describe 'when no connections are available' do
- it 'blocks the caller' do
- -> { Socket.udp_server_loop_on([@server]) }.should block_caller
- end
- end
-
- describe 'when a connection is available' do
- before do
- @client = Socket.new(:INET, :DGRAM)
- end
-
- after do
- @client.close
- end
-
- it 'yields the message and a Socket::UDPSource' do
- msg = nil
- src = nil
-
- @client.connect(@server.getsockname)
- @client.write('hello')
-
- Socket.udp_server_loop_on([@server]) do |message, source|
- msg = message
- src = source
-
- break
- end
-
- msg.should == 'hello'
- src.should be_an_instance_of(Socket::UDPSource)
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/udp_server_loop_spec.rb b/spec/ruby/library/socket/socket/udp_server_loop_spec.rb
deleted file mode 100644
index 66563bc742..0000000000
--- a/spec/ruby/library/socket/socket/udp_server_loop_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'Socket.udp_server_loop' do
- describe 'when no connections are available' do
- it 'blocks the caller' do
- -> { Socket.udp_server_loop('127.0.0.1', 0) }.should block_caller
- end
- end
-
- describe 'when a connection is available' do
- before do
- @client = Socket.new(:INET, :DGRAM)
- SocketSpecs::ServerLoopPortFinder.cleanup
- end
-
- after do
- @client.close
- end
-
- it 'yields the message and a Socket::UDPSource' do
- msg, src = nil
-
- Thread.new do
- SocketSpecs::ServerLoopPortFinder.udp_server_loop('127.0.0.1', 0) do |message, source|
- msg = message
- src = source
-
- break
- end
- end
-
- port = SocketSpecs::ServerLoopPortFinder.port
-
- # Because this will return even if the server is up and running (it's UDP
- # after all) we'll have to write and wait until "msg" is set.
- @client.connect(Socket.sockaddr_in(port, '127.0.0.1'))
-
- SocketSpecs.loop_with_timeout do
- begin
- @client.write('hello')
- rescue SystemCallError
- sleep 0.01
- :retry
- else
- unless msg
- sleep 0.001
- :retry
- end
- end
- end
-
- msg.should == 'hello'
- src.should be_an_instance_of(Socket::UDPSource)
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/udp_server_recv_spec.rb b/spec/ruby/library/socket/socket/udp_server_recv_spec.rb
deleted file mode 100644
index 47ed74bc03..0000000000
--- a/spec/ruby/library/socket/socket/udp_server_recv_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.udp_server_recv' do
- before do
- @server = Socket.new(:INET, :DGRAM)
- @client = Socket.new(:INET, :DGRAM)
-
- @server.bind(Socket.sockaddr_in(0, '127.0.0.1'))
- @client.connect(@server.getsockname)
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'yields the message and a Socket::UDPSource' do
- msg = :unset
- src = :unset
-
- @client.write('hello')
-
- readable, _, _ = IO.select([@server])
- readable.size.should == 1
-
- Socket.udp_server_recv(readable) do |message, source|
- msg = message
- src = source
- break
- end
-
- msg.should == 'hello'
- src.should be_an_instance_of(Socket::UDPSource)
- end
-end
diff --git a/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb b/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb
deleted file mode 100644
index 3aeb472dda..0000000000
--- a/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'Socket.udp_server_sockets' do
- describe 'without a block' do
- before do
- @sockets = nil
- end
-
- after do
- @sockets.each(&:close)
- end
-
- it 'returns an Array of Socket objects' do
- @sockets = Socket.udp_server_sockets(0)
-
- @sockets.should be_an_instance_of(Array)
- @sockets[0].should be_an_instance_of(Socket)
- end
- end
-
- describe 'with a block' do
- it 'yields the sockets to the supplied block' do
- Socket.udp_server_sockets(0) do |sockets|
- sockets.should be_an_instance_of(Array)
- sockets[0].should be_an_instance_of(Socket)
- end
- end
-
- it 'closes all sockets after the block returns' do
- sockets = nil
-
- Socket.udp_server_sockets(0) { |socks| sockets = socks }
-
- sockets.each do |socket|
- socket.closed?.should == true
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/unix_server_loop_spec.rb b/spec/ruby/library/socket/socket/unix_server_loop_spec.rb
deleted file mode 100644
index 0f34d4a50b..0000000000
--- a/spec/ruby/library/socket/socket/unix_server_loop_spec.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'Socket.unix_server_loop' do
- before do
- @path = SocketSpecs.socket_path
- end
-
- after do
- rm_r(@path) if File.file?(@path)
- end
-
- describe 'when no connections are available' do
- it 'blocks the caller' do
- -> { Socket.unix_server_loop(@path) }.should block_caller
- end
- end
-
- describe 'when a connection is available' do
- before do
- @client = nil
- end
-
- after do
- @sock.close if @sock
- @client.close if @client
- end
-
- it 'yields a Socket and an Addrinfo' do
- @sock, addr = nil
-
- thread = Thread.new do
- Socket.unix_server_loop(@path) do |socket, addrinfo|
- @sock = socket
- addr = addrinfo
-
- break
- end
- end
-
- SocketSpecs.loop_with_timeout do
- begin
- @client = Socket.unix(@path)
- rescue SystemCallError
- sleep 0.01
- :retry
- end
- end
-
- thread.join
-
- @sock.should be_an_instance_of(Socket)
- addr.should be_an_instance_of(Addrinfo)
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/unix_server_socket_spec.rb b/spec/ruby/library/socket/socket/unix_server_socket_spec.rb
deleted file mode 100644
index fc357740fa..0000000000
--- a/spec/ruby/library/socket/socket/unix_server_socket_spec.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'Socket.unix_server_socket' do
- before do
- @path = SocketSpecs.socket_path
- end
-
- after do
- rm_r(@path)
- end
-
- describe 'when no block is given' do
- before do
- @socket = nil
- end
-
- after do
- @socket.close
- end
-
- it 'returns a Socket' do
- @socket = Socket.unix_server_socket(@path)
-
- @socket.should be_an_instance_of(Socket)
- end
- end
-
- describe 'when a block is given' do
- it 'yields a Socket' do
- Socket.unix_server_socket(@path) do |sock|
- sock.should be_an_instance_of(Socket)
- end
- end
-
- it 'closes the Socket when the block returns' do
- socket = nil
-
- Socket.unix_server_socket(@path) do |sock|
- socket = sock
- end
-
- socket.should be_an_instance_of(Socket)
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/unix_spec.rb b/spec/ruby/library/socket/socket/unix_spec.rb
deleted file mode 100644
index add54a097d..0000000000
--- a/spec/ruby/library/socket/socket/unix_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'Socket.unix' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- @socket = nil
- end
-
- after do
- @server.close
- @socket.close if @socket
-
- rm_r(@path)
- end
-
- describe 'when no block is given' do
- it 'returns a Socket' do
- @socket = Socket.unix(@path)
-
- @socket.should be_an_instance_of(Socket)
- end
- end
-
- describe 'when a block is given' do
- it 'yields a Socket' do
- Socket.unix(@path) do |sock|
- sock.should be_an_instance_of(Socket)
- end
- end
-
- it 'closes the Socket when the block returns' do
- socket = nil
-
- Socket.unix(@path) do |sock|
- socket = sock
- end
-
- socket.closed?.should == true
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb b/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb
index 79ec68cd18..91d2b947a1 100644
--- a/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb
+++ b/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb
@@ -1,7 +1,9 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require 'socket'
describe "Socket.unpack_sockaddr_in" do
+
it "decodes the host name and port number of a packed sockaddr_in" do
sockaddr = Socket.sockaddr_in 3333, '127.0.0.1'
Socket.unpack_sockaddr_in(sockaddr).should == [3333, '127.0.0.1']
@@ -12,35 +14,16 @@ describe "Socket.unpack_sockaddr_in" do
Socket.unpack_sockaddr_in(addrinfo).should == [3333, '127.0.0.1']
end
- describe 'using an IPv4 address' do
- it 'returns an Array containing the port and IP address' do
- port = 80
- ip = '127.0.0.1'
- addr = Socket.pack_sockaddr_in(port, ip)
-
- Socket.unpack_sockaddr_in(addr).should == [port, ip]
- end
- end
-
- describe 'using an IPv6 address' do
- it 'returns an Array containing the port and IP address' do
- port = 80
- ip = '::1'
- addr = Socket.pack_sockaddr_in(port, ip)
-
- Socket.unpack_sockaddr_in(addr).should == [port, ip]
- end
- end
-
- with_feature :unix_socket do
+ platform_is_not :windows do
it "raises an ArgumentError when the sin_family is not AF_INET" do
sockaddr = Socket.sockaddr_un '/tmp/x'
- -> { Socket.unpack_sockaddr_in sockaddr }.should raise_error(ArgumentError)
+ lambda { Socket.unpack_sockaddr_in sockaddr }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when passed addrinfo is not AF_INET/AF_INET6" do
addrinfo = Addrinfo.unix('/tmp/sock')
- -> { Socket.unpack_sockaddr_in(addrinfo) }.should raise_error(ArgumentError)
+ lambda { Socket.unpack_sockaddr_in(addrinfo) }.should raise_error(ArgumentError)
end
end
+
end
diff --git a/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb b/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb
index bd95f1db08..f81d36f7e9 100644
--- a/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb
+++ b/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
-with_feature :unix_socket do
- describe 'Socket.unpack_sockaddr_un' do
+describe 'Socket.unpack_sockaddr_un' do
+ platform_is_not :windows do
it 'decodes sockaddr to unix path' do
sockaddr = Socket.sockaddr_un('/tmp/sock')
Socket.unpack_sockaddr_un(sockaddr).should == '/tmp/sock'
@@ -15,12 +15,12 @@ with_feature :unix_socket do
it 'raises an ArgumentError when the sin_family is not AF_UNIX' do
sockaddr = Socket.sockaddr_in(0, '127.0.0.1')
- -> { Socket.unpack_sockaddr_un(sockaddr) }.should raise_error(ArgumentError)
+ lambda { Socket.unpack_sockaddr_un(sockaddr) }.should raise_error(ArgumentError)
end
it 'raises an ArgumentError when passed addrinfo is not AF_UNIX' do
addrinfo = Addrinfo.tcp('127.0.0.1', 0)
- -> { Socket.unpack_sockaddr_un(addrinfo) }.should raise_error(ArgumentError)
+ lambda { Socket.unpack_sockaddr_un(addrinfo) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/library/socket/spec_helper.rb b/spec/ruby/library/socket/spec_helper.rb
deleted file mode 100644
index 1121542dd5..0000000000
--- a/spec/ruby/library/socket/spec_helper.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../spec_helper'
-require 'socket'
-
-MSpec.enable_feature :sock_packet if Socket.const_defined?(:SOCK_PACKET)
-MSpec.enable_feature :unix_socket unless PlatformGuard.windows?
-MSpec.enable_feature :udp_cork if Socket.const_defined?(:UDP_CORK)
-MSpec.enable_feature :tcp_cork if Socket.const_defined?(:TCP_CORK)
-MSpec.enable_feature :pktinfo if Socket.const_defined?(:IP_PKTINFO)
-MSpec.enable_feature :ipv6_pktinfo if Socket.const_defined?(:IPV6_PKTINFO)
-MSpec.enable_feature :ip_mtu if Socket.const_defined?(:IP_MTU)
-MSpec.enable_feature :ipv6_nexthop if Socket.const_defined?(:IPV6_NEXTHOP)
-MSpec.enable_feature :tcp_info if Socket.const_defined?(:TCP_INFO)
-MSpec.enable_feature :ancillary_data if Socket.const_defined?(:AncillaryData)
diff --git a/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb
index 91f6a327f0..d6f7448084 100644
--- a/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "Socket::TCPServer.accept_nonblock" do
before :each do
@@ -13,12 +13,12 @@ describe "Socket::TCPServer.accept_nonblock" do
it "accepts non blocking connections" do
@server.listen(5)
- -> {
+ lambda {
@server.accept_nonblock
}.should raise_error(IO::WaitReadable)
c = TCPSocket.new("127.0.0.1", @port)
- IO.select([@server])
+ sleep 0.1
s = @server.accept_nonblock
port, address = Socket.unpack_sockaddr_in(s.getsockname)
@@ -33,52 +33,17 @@ describe "Socket::TCPServer.accept_nonblock" do
it "raises an IOError if the socket is closed" do
@server.close
- -> { @server.accept }.should raise_error(IOError)
+ lambda { @server.accept }.should raise_error(IOError)
end
describe 'without a connected client' do
it 'raises error' do
- -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable)
+ lambda { @server.accept_nonblock }.should raise_error(IO::WaitReadable)
end
- it 'returns :wait_readable in exceptionless mode' do
- @server.accept_nonblock(exception: false).should == :wait_readable
- end
- end
-end
-
-describe 'TCPServer#accept_nonblock' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- end
-
- after do
- @server.close
- end
-
- describe 'without a connected client' do
- it 'raises IO::WaitReadable' do
- -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable)
- end
- end
-
- platform_is_not :windows do # spurious
- describe 'with a connected client' do
- before do
- @client = TCPSocket.new(ip_address, @server.connect_address.ip_port)
- end
-
- after do
- @socket.close if @socket
- @client.close
- end
-
- it 'returns a TCPSocket' do
- IO.select([@server])
- @socket = @server.accept_nonblock
- @socket.should be_an_instance_of(TCPSocket)
- end
+ ruby_version_is '2.3' do
+ it 'returns :wait_readable in exceptionless mode' do
+ @server.accept_nonblock(exception: false).should == :wait_readable
end
end
end
diff --git a/spec/ruby/library/socket/tcpserver/accept_spec.rb b/spec/ruby/library/socket/tcpserver/accept_spec.rb
index 0da4e2218b..e7a1d87dbe 100644
--- a/spec/ruby/library/socket/tcpserver/accept_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/accept_spec.rb
@@ -1,5 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
describe "TCPServer#accept" do
before :each do
@@ -60,40 +61,6 @@ describe "TCPServer#accept" do
it "raises an IOError if the socket is closed" do
@server.close
- -> { @server.accept }.should raise_error(IOError)
- end
-end
-
-describe 'TCPServer#accept' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- end
-
- after do
- @server.close
- end
-
- describe 'without a connected client' do
- it 'blocks the caller' do
- -> { @server.accept }.should block_caller
- end
- end
-
- describe 'with a connected client' do
- before do
- @client = TCPSocket.new(ip_address, @server.connect_address.ip_port)
- end
-
- after do
- @socket.close if @socket
- @client.close
- end
-
- it 'returns a TCPSocket' do
- @socket = @server.accept
- @socket.should be_an_instance_of(TCPSocket)
- end
- end
+ lambda { @server.accept }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/socket/tcpserver/gets_spec.rb b/spec/ruby/library/socket/tcpserver/gets_spec.rb
index 417976d737..86ba65eae2 100644
--- a/spec/ruby/library/socket/tcpserver/gets_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/gets_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "TCPServer#gets" do
before :each do
@@ -11,6 +11,6 @@ describe "TCPServer#gets" do
end
it "raises Errno::ENOTCONN on gets" do
- -> { @server.gets }.should raise_error(Errno::ENOTCONN)
+ lambda { @server.gets }.should raise_error(Errno::ENOTCONN)
end
end
diff --git a/spec/ruby/library/socket/tcpserver/initialize_spec.rb b/spec/ruby/library/socket/tcpserver/initialize_spec.rb
deleted file mode 100644
index 4ddd1f465f..0000000000
--- a/spec/ruby/library/socket/tcpserver/initialize_spec.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'TCPServer#initialize' do
- describe 'with a single Integer argument' do
- before do
- @server = TCPServer.new(0)
- end
-
- after do
- @server.close
- end
-
- it 'sets the port to the given argument' do
- @server.local_address.ip_port.should be_kind_of(Integer)
- @server.local_address.ip_port.should > 0
- end
-
- platform_is_not :windows do
- it 'sets the hostname to 0.0.0.0 or ::' do
- a = @server.local_address
- a.ip_address.should == (a.ipv6? ? '::' : '0.0.0.0')
- end
- end
-
- it "sets the socket to binmode" do
- @server.binmode?.should be_true
- end
- end
-
- describe 'with a single String argument containing a numeric value' do
- before do
- @server = TCPServer.new('0')
- end
-
- after do
- @server.close
- end
-
- it 'sets the port to the given argument' do
- @server.local_address.ip_port.should be_kind_of(Integer)
- @server.local_address.ip_port.should > 0
- end
-
- platform_is_not :windows do
- it 'sets the hostname to 0.0.0.0 or ::' do
- a = @server.local_address
- a.ip_address.should == (a.ipv6? ? '::' : '0.0.0.0')
- end
- end
- end
-
- describe 'with a single String argument containing a non numeric value' do
- it 'raises SocketError' do
- -> { TCPServer.new('cats') }.should raise_error(SocketError)
- end
- end
-
- describe 'with a String and an Integer' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- end
-
- after do
- @server.close
- end
-
- it 'sets the port to the given port argument' do
- @server.local_address.ip_port.should be_kind_of(Integer)
- @server.local_address.ip_port.should > 0
- end
-
- it 'sets the hostname to the given host argument' do
- @server.local_address.ip_address.should == ip_address
- end
- end
- end
-
- describe 'with a String and a custom object' do
- before do
- dummy = mock(:dummy)
- dummy.stub!(:to_str).and_return('0')
-
- @server = TCPServer.new('127.0.0.1', dummy)
- end
-
- after do
- @server.close
- end
-
- it 'sets the port to the given port argument' do
- @server.local_address.ip_port.should be_kind_of(Integer)
- @server.local_address.ip_port.should > 0
- end
-
- it 'sets the hostname to the given host argument' do
- @server.local_address.ip_address.should == '127.0.0.1'
- end
- end
-end
diff --git a/spec/ruby/library/socket/tcpserver/listen_spec.rb b/spec/ruby/library/socket/tcpserver/listen_spec.rb
index c877fdced6..d764b4ce70 100644
--- a/spec/ruby/library/socket/tcpserver/listen_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/listen_spec.rb
@@ -1,22 +1,18 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe 'TCPServer#listen' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- end
+require 'socket'
- after do
- @server.close
- end
+describe 'TCPServer#listen' do
+ before :each do
+ @server = TCPServer.new(SocketSpecs.hostname, 0)
+ end
- it 'returns 0' do
- @server.listen(1).should == 0
- end
+ after :each do
+ @server.close unless @server.closed?
+ end
- it "raises when the given argument can't be coerced to an Integer" do
- -> { @server.listen('cats') }.should raise_error(TypeError)
- end
+ it 'returns 0' do
+ @server.listen(10).should == 0
end
end
diff --git a/spec/ruby/library/socket/tcpserver/new_spec.rb b/spec/ruby/library/socket/tcpserver/new_spec.rb
index 8d9696c9d8..adbc3f303e 100644
--- a/spec/ruby/library/socket/tcpserver/new_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "TCPServer.new" do
after :each do
@@ -10,7 +10,7 @@ describe "TCPServer.new" do
@server = TCPServer.new('127.0.0.1', 0)
addr = @server.addr
addr[0].should == 'AF_INET'
- addr[1].should be_kind_of(Integer)
+ addr[1].should be_kind_of(Fixnum)
# on some platforms (Mac), MRI
# returns comma at the end.
addr[2].should =~ /^#{SocketSpecs.hostname}\b/
@@ -20,12 +20,12 @@ describe "TCPServer.new" do
it "binds to localhost and a port with either IPv4 or IPv6" do
@server = TCPServer.new(SocketSpecs.hostname, 0)
addr = @server.addr
- addr[1].should be_kind_of(Integer)
+ addr[1].should be_kind_of(Fixnum)
if addr[0] == 'AF_INET'
addr[2].should =~ /^#{SocketSpecs.hostname}\b/
addr[3].should == '127.0.0.1'
else
- addr[2].should =~ /^#{SocketSpecs.hostname('::1')}\b/
+ addr[2].should =~ /^#{SocketSpecs.hostnamev6}\b/
addr[3].should == '::1'
end
end
@@ -34,71 +34,36 @@ describe "TCPServer.new" do
@server = TCPServer.new('', 0)
addr = @server.addr
addr[0].should == 'AF_INET'
- addr[1].should be_kind_of(Integer)
+ addr[1].should be_kind_of(Fixnum)
addr[2].should == '0.0.0.0'
addr[3].should == '0.0.0.0'
end
it "binds to INADDR_ANY if the hostname is empty and the port is a string" do
- @server = TCPServer.new('', '0')
- addr = @server.addr
- addr[0].should == 'AF_INET'
- addr[1].should be_kind_of(Integer)
- addr[2].should == '0.0.0.0'
- addr[3].should == '0.0.0.0'
- end
-
- it "binds to a port if the port is explicitly nil" do
- @server = TCPServer.new('', nil)
- addr = @server.addr
- addr[0].should == 'AF_INET'
- addr[1].should be_kind_of(Integer)
- addr[2].should == '0.0.0.0'
- addr[3].should == '0.0.0.0'
- end
-
- it "binds to a port if the port is an empty string" do
- @server = TCPServer.new('', '')
+ @server = TCPServer.new('', 0)
addr = @server.addr
addr[0].should == 'AF_INET'
- addr[1].should be_kind_of(Integer)
+ addr[1].should be_kind_of(Fixnum)
addr[2].should == '0.0.0.0'
addr[3].should == '0.0.0.0'
end
it "coerces port to string, then determines port from that number or service name" do
- -> { TCPServer.new(SocketSpecs.hostname, Object.new) }.should raise_error(TypeError)
+ lambda { TCPServer.new(SocketSpecs.hostname, Object.new) }.should raise_error(TypeError)
port = Object.new
port.should_receive(:to_str).and_return("0")
@server = TCPServer.new(SocketSpecs.hostname, port)
addr = @server.addr
- addr[1].should be_kind_of(Integer)
+ addr[1].should be_kind_of(Fixnum)
# TODO: This should also accept strings like 'https', but I don't know how to
# pick such a service port that will be able to reliably bind...
end
- it "has a single argument form and treats it as a port number" do
- @server = TCPServer.new(0)
- addr = @server.addr
- addr[1].should be_kind_of(Integer)
- end
-
- it "coerces port to a string when it is the only argument" do
- -> { TCPServer.new(Object.new) }.should raise_error(TypeError)
-
- port = Object.new
- port.should_receive(:to_str).and_return("0")
-
- @server = TCPServer.new(port)
- addr = @server.addr
- addr[1].should be_kind_of(Integer)
- end
-
it "raises Errno::EADDRNOTAVAIL when the address is unknown" do
- -> { TCPServer.new("1.2.3.4", 0) }.should raise_error(Errno::EADDRNOTAVAIL)
+ lambda { TCPServer.new("1.2.3.4", 0) }.should raise_error(Errno::EADDRNOTAVAIL)
end
# There is no way to make this fail-proof on all machines, because
@@ -106,7 +71,7 @@ describe "TCPServer.new" do
# traditionally invalidly named ones.
quarantine! do
it "raises a SocketError when the host is unknown" do
- -> {
+ lambda {
TCPServer.new("--notavalidname", 0)
}.should raise_error(SocketError)
end
@@ -114,7 +79,7 @@ describe "TCPServer.new" do
it "raises Errno::EADDRINUSE when address is already in use" do
@server = TCPServer.new('127.0.0.1', 0)
- -> {
+ lambda {
@server = TCPServer.new('127.0.0.1', @server.addr[1])
}.should raise_error(Errno::EADDRINUSE)
end
diff --git a/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb b/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb
index bd7d33faf4..93c1ffe152 100644
--- a/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb
@@ -1,5 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+require 'socket'
describe "TCPServer#sysaccept" do
before :each do
@@ -12,7 +14,7 @@ describe "TCPServer#sysaccept" do
end
it 'blocks if no connections' do
- -> { @server.sysaccept }.should block_caller
+ lambda { @server.sysaccept }.should block_caller
end
it 'returns file descriptor of an accepted connection' do
@@ -21,46 +23,10 @@ describe "TCPServer#sysaccept" do
fd = @server.sysaccept
- fd.should be_kind_of(Integer)
+ fd.should be_an_instance_of(Fixnum)
ensure
sock.close if sock && !sock.closed?
IO.for_fd(fd).close if fd
end
end
end
-
-describe 'TCPServer#sysaccept' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- end
-
- after do
- @server.close
- end
-
- describe 'without a connected client' do
- it 'blocks the caller' do
- -> { @server.sysaccept }.should block_caller
- end
- end
-
- describe 'with a connected client' do
- before do
- @client = TCPSocket.new(ip_address, @server.connect_address.ip_port)
- end
-
- after do
- Socket.for_fd(@fd).close if @fd
- @client.close
- end
-
- it 'returns a new file descriptor as an Integer' do
- @fd = @server.sysaccept
-
- @fd.should be_kind_of(Integer)
- @fd.should_not == @client.fileno
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb b/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb
index 703abff81c..11838aca27 100644
--- a/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
# TODO: verify these for windows
describe "TCPSocket#gethostbyname" do
@@ -49,63 +49,3 @@ describe "TCPSocket#gethostbyname" do
@host_info[1].should be_kind_of(Array)
end
end
-
-describe 'TCPSocket#gethostbyname' do
- it 'returns an Array' do
- TCPSocket.gethostbyname('127.0.0.1').should be_an_instance_of(Array)
- end
-
- describe 'using a hostname' do
- describe 'the returned Array' do
- before do
- @array = TCPSocket.gethostbyname('127.0.0.1')
- end
-
- it 'includes the canonical name as the 1st value' do
- @array[0].should == '127.0.0.1'
- end
-
- it 'includes an array of alternative hostnames as the 2nd value' do
- @array[1].should be_an_instance_of(Array)
- end
-
- it 'includes the address family as the 3rd value' do
- @array[2].should be_kind_of(Integer)
- end
-
- it 'includes the IP addresses as all the remaining values' do
- ips = %w{::1 127.0.0.1}
-
- ips.include?(@array[3]).should == true
-
- # Not all machines might have both IPv4 and IPv6 set up, so this value is
- # optional.
- ips.include?(@array[4]).should == true if @array[4]
- end
- end
- end
-
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'the returned Array' do
- before do
- @array = TCPSocket.gethostbyname(ip_address)
- end
-
- it 'includes the IP address as the 1st value' do
- @array[0].should == ip_address
- end
-
- it 'includes an empty list of aliases as the 2nd value' do
- @array[1].should == []
- end
-
- it 'includes the address family as the 3rd value' do
- @array[2].should == family
- end
-
- it 'includes the IP address as the 4th value' do
- @array[3].should == ip_address
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb
deleted file mode 100644
index a3cee05412..0000000000
--- a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'TCPSocket#initialize' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- describe 'when no server is listening on the given address' do
- it 'raises Errno::ECONNREFUSED' do
- -> { TCPSocket.new(ip_address, 666) }.should raise_error(Errno::ECONNREFUSED)
- end
- end
-
- describe 'when a server is listening on the given address' do
- before do
- @server = TCPServer.new(ip_address, 0)
- @port = @server.connect_address.ip_port
- end
-
- after do
- @client.close if @client
- @server.close
- end
-
- it 'returns a TCPSocket when using an Integer as the port' do
- @client = TCPSocket.new(ip_address, @port)
- @client.should be_an_instance_of(TCPSocket)
- end
-
- it 'returns a TCPSocket when using a String as the port' do
- @client = TCPSocket.new(ip_address, @port.to_s)
- @client.should be_an_instance_of(TCPSocket)
- end
-
- it 'raises SocketError when the port number is a non numeric String' do
- -> { TCPSocket.new(ip_address, 'cats') }.should raise_error(SocketError)
- end
-
- it 'set the socket to binmode' do
- @client = TCPSocket.new(ip_address, @port)
- @client.binmode?.should be_true
- end
-
- it 'connects to the right address' do
- @client = TCPSocket.new(ip_address, @port)
-
- @client.remote_address.ip_address.should == @server.local_address.ip_address
- @client.remote_address.ip_port.should == @server.local_address.ip_port
- end
-
- describe 'using a local address and service' do
- it 'binds the client socket to the local address and service' do
- @client = TCPSocket.new(ip_address, @port, ip_address, 0)
-
- @client.local_address.ip_address.should == ip_address
-
- @client.local_address.ip_port.should > 0
- @client.local_address.ip_port.should_not == @port
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/tcpsocket/local_address_spec.rb b/spec/ruby/library/socket/tcpsocket/local_address_spec.rb
deleted file mode 100644
index ce66d5ff8f..0000000000
--- a/spec/ruby/library/socket/tcpsocket/local_address_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'TCPSocket#local_address' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- @host = @server.connect_address.ip_address
- @port = @server.connect_address.ip_port
- end
-
- after do
- @server.close
- end
-
- describe 'using an explicit hostname' do
- before do
- @sock = TCPSocket.new(@host, @port)
- end
-
- after do
- @sock.close
- end
-
- it 'returns an Addrinfo' do
- @sock.local_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses AF_INET as the address family' do
- @sock.local_address.afamily.should == family
- end
-
- it 'uses PF_INET as the protocol family' do
- @sock.local_address.pfamily.should == family
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @sock.local_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses the correct IP address' do
- @sock.local_address.ip_address.should == @host
- end
-
- it 'uses a randomly assigned local port' do
- @sock.local_address.ip_port.should > 0
- @sock.local_address.ip_port.should_not == @port
- end
-
- it 'uses 0 as the protocol' do
- @sock.local_address.protocol.should == 0
- end
- end
- end
-
- describe 'using an implicit hostname' do
- before do
- @sock = TCPSocket.new(nil, @port)
- end
-
- after do
- @sock.close
- end
-
- describe 'the returned Addrinfo' do
- it 'uses the correct IP address' do
- @sock.local_address.ip_address.should == @host
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/tcpsocket/new_spec.rb b/spec/ruby/library/socket/tcpsocket/new_spec.rb
index 4924468be7..279576272b 100644
--- a/spec/ruby/library/socket/tcpsocket/new_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/new'
+require File.expand_path('../shared/new', __FILE__)
describe "TCPSocket.new" do
it_behaves_like :tcpsocket_new, :new
diff --git a/spec/ruby/library/socket/tcpsocket/open_spec.rb b/spec/ruby/library/socket/tcpsocket/open_spec.rb
index 31b630a23b..fb4cc4629a 100644
--- a/spec/ruby/library/socket/tcpsocket/open_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/open_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/new'
+require File.expand_path('../shared/new', __FILE__)
describe "TCPSocket.open" do
it_behaves_like :tcpsocket_new, :open
diff --git a/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb b/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb
index a381627a39..6a43eea625 100644
--- a/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/partially_closable_sockets'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/partially_closable_sockets', __FILE__)
describe "TCPSocket partial closability" do
diff --git a/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb b/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb
index bfd815c658..237ff781a3 100644
--- a/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "TCPSocket#recv_nonblock" do
before :each do
@@ -27,8 +27,10 @@ describe "TCPSocket#recv_nonblock" do
@socket.recv_nonblock(50).should == "TCPSocket#recv_nonblock"
end
- it 'returns :wait_readable in exceptionless mode' do
- @socket = TCPSocket.new @hostname, @server.port
- @socket.recv_nonblock(50, exception: false).should == :wait_readable
+ ruby_version_is '2.3' do
+ it 'returns :wait_readable in exceptionless mode' do
+ @socket = TCPSocket.new @hostname, @server.port
+ @socket.recv_nonblock(50, exception: false).should == :wait_readable
+ end
end
end
diff --git a/spec/ruby/library/socket/tcpsocket/recv_spec.rb b/spec/ruby/library/socket/tcpsocket/recv_spec.rb
deleted file mode 100644
index f380db670d..0000000000
--- a/spec/ruby/library/socket/tcpsocket/recv_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'TCPSocket#recv' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- @client = TCPSocket.new(ip_address, @server.connect_address.ip_port)
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'returns the message data' do
- @client.write('hello')
-
- socket = @server.accept
-
- begin
- socket.recv(5).should == 'hello'
- ensure
- socket.close
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb b/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb
deleted file mode 100644
index eb9dabc075..0000000000
--- a/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'TCPSocket#remote_address' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = TCPServer.new(ip_address, 0)
- @host = @server.connect_address.ip_address
- @port = @server.connect_address.ip_port
- end
-
- after do
- @server.close
- end
-
- describe 'using an explicit hostname' do
- before do
- @sock = TCPSocket.new(@host, @port)
- end
-
- after do
- @sock.close
- end
-
- it 'returns an Addrinfo' do
- @sock.remote_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses AF_INET as the address family' do
- @sock.remote_address.afamily.should == family
- end
-
- it 'uses PF_INET as the protocol family' do
- @sock.remote_address.pfamily.should == family
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @sock.remote_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses the correct IP address' do
- @sock.remote_address.ip_address.should == @host
- end
-
- it 'uses the correct port' do
- @sock.remote_address.ip_port.should == @port
- end
-
- it 'uses 0 as the protocol' do
- @sock.remote_address.protocol.should == 0
- end
- end
- end
-
- describe 'using an implicit hostname' do
- before do
- @sock = TCPSocket.new(nil, @port)
- end
-
- after do
- @sock.close
- end
-
- describe 'the returned Addrinfo' do
- it 'uses the correct IP address' do
- @sock.remote_address.ip_address.should == @host
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb b/spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb
index 8b728b7522..8a0cb443b5 100644
--- a/spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "TCPSocket#setsockopt" do
before :each do
diff --git a/spec/ruby/library/socket/tcpsocket/shared/new.rb b/spec/ruby/library/socket/tcpsocket/shared/new.rb
index 5ca3a0e6cc..912208c86c 100644
--- a/spec/ruby/library/socket/tcpsocket/shared/new.rb
+++ b/spec/ruby/library/socket/tcpsocket/shared/new.rb
@@ -1,13 +1,13 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/classes', __FILE__)
describe :tcpsocket_new, shared: true do
it "requires a hostname and a port as arguments" do
- -> { TCPSocket.send(@method) }.should raise_error(ArgumentError)
+ lambda { TCPSocket.send(@method) }.should raise_error(ArgumentError)
end
it "refuses the connection when there is no server to connect to" do
- -> do
+ lambda do
TCPSocket.send(@method, SocketSpecs.hostname, SocketSpecs.reserved_unused_port)
end.should raise_error(SystemCallError) {|e|
[Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL].should include(e.class)
@@ -72,7 +72,7 @@ describe :tcpsocket_new, shared: true do
@socket.addr[3].should == SocketSpecs.addr(:ipv6)
end
- @socket.addr[1].should be_kind_of(Integer)
+ @socket.addr[1].should be_kind_of(Fixnum)
@socket.addr[2].should =~ /^#{@hostname}/
end
end
diff --git a/spec/ruby/library/socket/udpsocket/bind_spec.rb b/spec/ruby/library/socket/udpsocket/bind_spec.rb
index 08b386e941..bdc3c3d33f 100644
--- a/spec/ruby/library/socket/udpsocket/bind_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/bind_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "UDPSocket.bind" do
-describe "UDPSocket#bind" do
before :each do
@socket = UDPSocket.new
end
@@ -18,7 +19,7 @@ describe "UDPSocket#bind" do
it "raises Errno::EINVAL when already bound" do
@socket.bind(SocketSpecs.hostname, 0)
- -> {
+ lambda {
@socket.bind(SocketSpecs.hostname, @socket.addr[1])
}.should raise_error(Errno::EINVAL)
end
@@ -33,51 +34,9 @@ describe "UDPSocket#bind" do
end
it "binds to INADDR_ANY if the hostname is empty" do
- @socket.bind("", 0).should == 0
+ @socket.bind("", 0)
port, host = Socket.unpack_sockaddr_in(@socket.getsockname)
host.should == "0.0.0.0"
port.should == @socket.addr[1]
end
end
-
-describe 'UDPSocket#bind' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @socket = UDPSocket.new(family)
- end
-
- after do
- @socket.close
- end
-
- it 'binds to an address and port' do
- @socket.bind(ip_address, 0).should == 0
-
- @socket.local_address.ip_address.should == ip_address
- @socket.local_address.ip_port.should > 0
- end
-
- it 'binds to an address and port using String arguments' do
- @socket.bind(ip_address, '0').should == 0
-
- @socket.local_address.ip_address.should == ip_address
- @socket.local_address.ip_port.should > 0
- end
-
- it 'can receive data after being bound to an address' do
- @socket.bind(ip_address, 0)
-
- addr = @socket.connect_address
- client = UDPSocket.new(family)
-
- client.connect(addr.ip_address, addr.ip_port)
- client.write('hello')
-
- begin
- @socket.recv(6).should == 'hello'
- ensure
- client.close
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/connect_spec.rb b/spec/ruby/library/socket/udpsocket/connect_spec.rb
deleted file mode 100644
index d92bdeb981..0000000000
--- a/spec/ruby/library/socket/udpsocket/connect_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'UDPSocket#connect' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @socket = UDPSocket.new(family)
- end
-
- after do
- @socket.close
- end
-
- it 'connects to an address even when it is not used' do
- @socket.connect(ip_address, 9996).should == 0
- end
-
- it 'can send data after connecting' do
- receiver = UDPSocket.new(family)
-
- receiver.bind(ip_address, 0)
-
- addr = receiver.connect_address
-
- @socket.connect(addr.ip_address, addr.ip_port)
- @socket.write('hello')
-
- begin
- receiver.recv(6).should == 'hello'
- ensure
- receiver.close
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/initialize_spec.rb b/spec/ruby/library/socket/udpsocket/initialize_spec.rb
deleted file mode 100644
index 1d635149f7..0000000000
--- a/spec/ruby/library/socket/udpsocket/initialize_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'UDPSocket#initialize' do
- after do
- @socket.close if @socket
- end
-
- it 'initializes a new UDPSocket' do
- @socket = UDPSocket.new
- @socket.should be_an_instance_of(UDPSocket)
- end
-
- it 'initializes a new UDPSocket using an Integer' do
- @socket = UDPSocket.new(Socket::AF_INET)
- @socket.should be_an_instance_of(UDPSocket)
- end
-
- it 'initializes a new UDPSocket using a Symbol' do
- @socket = UDPSocket.new(:INET)
- @socket.should be_an_instance_of(UDPSocket)
- end
-
- it 'initializes a new UDPSocket using a String' do
- @socket = UDPSocket.new('INET')
- @socket.should be_an_instance_of(UDPSocket)
- end
-
- it 'sets the socket to binmode' do
- @socket = UDPSocket.new(:INET)
- @socket.binmode?.should be_true
- end
-
- it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT when given an invalid address family' do
- -> {
- UDPSocket.new(666)
- }.should raise_error(SystemCallError) { |e|
- [Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should include(e.class)
- }
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/inspect_spec.rb b/spec/ruby/library/socket/udpsocket/inspect_spec.rb
deleted file mode 100644
index 201e8b3fc6..0000000000
--- a/spec/ruby/library/socket/udpsocket/inspect_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require_relative '../spec_helper'
-
-describe 'UDPSocket#inspect' do
- before do
- @socket = UDPSocket.new
- @socket.bind('127.0.0.1', 0)
- end
-
- after do
- @socket.close
- end
-
- ruby_version_is ""..."2.5" do
- it 'returns a String with the fd' do
- @socket.inspect.should == "#<UDPSocket:fd #{@socket.fileno}>"
- end
- end
-
- ruby_version_is "2.5" do
- it 'returns a String with the fd, family, address and port' do
- port = @socket.addr[1]
- @socket.inspect.should == "#<UDPSocket:fd #{@socket.fileno}, AF_INET, 127.0.0.1, #{port}>"
- end
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/local_address_spec.rb b/spec/ruby/library/socket/udpsocket/local_address_spec.rb
deleted file mode 100644
index 92e4cc10c7..0000000000
--- a/spec/ruby/library/socket/udpsocket/local_address_spec.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'UDPSocket#local_address' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :DGRAM, Socket::IPPROTO_UDP)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
-
- @host = @server.connect_address.ip_address
- @port = @server.connect_address.ip_port
- end
-
- after do
- @server.close
- end
-
- describe 'using an explicit hostname' do
- before do
- @sock = UDPSocket.new(family)
-
- @sock.connect(@host, @port)
- end
-
- after do
- @sock.close
- end
-
- it 'returns an Addrinfo' do
- @sock.local_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses the correct address family' do
- @sock.local_address.afamily.should == family
- end
-
- it 'uses the correct protocol family' do
- @sock.local_address.pfamily.should == family
- end
-
- it 'uses SOCK_DGRAM as the socket type' do
- @sock.local_address.socktype.should == Socket::SOCK_DGRAM
- end
-
- it 'uses the correct IP address' do
- @sock.local_address.ip_address.should == @host
- end
-
- it 'uses a randomly assigned local port' do
- @sock.local_address.ip_port.should > 0
- @sock.local_address.ip_port.should_not == @port
- end
-
- it 'uses 0 as the protocol' do
- @sock.local_address.protocol.should == 0
- end
- end
- end
-
- describe 'using an implicit hostname' do
- before do
- @sock = UDPSocket.new(family)
-
- @sock.connect(nil, @port)
- end
-
- after do
- @sock.close
- end
-
- describe 'the returned Addrinfo' do
- it 'uses the correct IP address' do
- @sock.local_address.ip_address.should == @host
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/new_spec.rb b/spec/ruby/library/socket/udpsocket/new_spec.rb
index 6cc0cadbcb..f13e605959 100644
--- a/spec/ruby/library/socket/udpsocket/new_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe 'UDPSocket.new' do
after :each do
@@ -11,7 +11,7 @@ describe 'UDPSocket.new' do
@socket.should be_an_instance_of(UDPSocket)
end
- it 'using Integer argument' do
+ it 'using Fixnum argument' do
@socket = UDPSocket.new(Socket::AF_INET)
@socket.should be_an_instance_of(UDPSocket)
end
@@ -27,7 +27,7 @@ describe 'UDPSocket.new' do
end
it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT if unsupported family passed' do
- -> { UDPSocket.new(-1) }.should raise_error(SystemCallError) { |e|
+ lambda { UDPSocket.new(-1) }.should raise_error(SystemCallError) { |e|
[Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should include(e.class)
}
end
diff --git a/spec/ruby/library/socket/udpsocket/open_spec.rb b/spec/ruby/library/socket/udpsocket/open_spec.rb
index e4dbb2ee2a..188f879ed1 100644
--- a/spec/ruby/library/socket/udpsocket/open_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/open_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UDPSocket.open" do
after :each do
diff --git a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb b/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb
deleted file mode 100644
index c66d1df84d..0000000000
--- a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'UDPSocket#recvfrom_nonblock' do
- SocketSpecs.each_ip_protocol do |family, ip_address, family_name|
- before do
- @server = UDPSocket.new(family)
- @client = UDPSocket.new(family)
- end
-
- after do
- @client.close
- @server.close
- end
-
- platform_is_not :windows do
- describe 'using an unbound socket' do
- it 'raises IO::WaitReadable' do
- -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable)
- end
- end
- end
-
- describe 'using a bound socket' do
- before do
- @server.bind(ip_address, 0)
-
- addr = @server.connect_address
-
- @client.connect(addr.ip_address, addr.ip_port)
- end
-
- describe 'without any data available' do
- it 'raises IO::WaitReadable' do
- -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable)
- end
-
- it 'returns :wait_readable with exception: false' do
- @server.recvfrom_nonblock(1, exception: false).should == :wait_readable
- end
- end
-
- platform_is_not :windows do
- describe 'with data available' do
- before do
- @client.write('hello')
- end
-
- it 'returns an Array containing the data and an Array' do
- IO.select([@server])
- @server.recvfrom_nonblock(1).should be_an_instance_of(Array)
- end
-
- describe 'the returned Array' do
- before do
- IO.select([@server])
- @array = @server.recvfrom_nonblock(1)
- end
-
- it 'contains the data at index 0' do
- @array[0].should == 'h'
- end
-
- it 'contains an Array at index 1' do
- @array[1].should be_an_instance_of(Array)
- end
- end
-
- describe 'the returned address Array' do
- before do
- IO.select([@server])
- @addr = @server.recvfrom_nonblock(1)[1]
- end
-
- it 'uses the correct address family' do
- @addr[0].should == family_name
- end
-
- it 'uses the port of the client' do
- @addr[1].should == @client.local_address.ip_port
- end
-
- it 'uses the hostname of the client' do
- @addr[2].should == ip_address
- end
-
- it 'uses the IP address of the client' do
- @addr[3].should == ip_address
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/remote_address_spec.rb b/spec/ruby/library/socket/udpsocket/remote_address_spec.rb
deleted file mode 100644
index 94889ce560..0000000000
--- a/spec/ruby/library/socket/udpsocket/remote_address_spec.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-describe 'UDPSocket#remote_address' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = Socket.new(family, :DGRAM, Socket::IPPROTO_UDP)
-
- @server.bind(Socket.sockaddr_in(0, ip_address))
-
- @host = @server.connect_address.ip_address
- @port = @server.connect_address.ip_port
- end
-
- after do
- @server.close
- end
-
- describe 'using an explicit hostname' do
- before do
- @sock = UDPSocket.new(family)
-
- @sock.connect(@host, @port)
- end
-
- after do
- @sock.close
- end
-
- it 'returns an Addrinfo' do
- @sock.remote_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses the correct address family' do
- @sock.remote_address.afamily.should == family
- end
-
- it 'uses the correct protocol family' do
- @sock.remote_address.pfamily.should == family
- end
-
- it 'uses SOCK_DGRAM as the socket type' do
- @sock.remote_address.socktype.should == Socket::SOCK_DGRAM
- end
-
- it 'uses the correct IP address' do
- @sock.remote_address.ip_address.should == @host
- end
-
- it 'uses the correct port' do
- @sock.remote_address.ip_port.should == @port
- end
-
- it 'uses 0 as the protocol' do
- @sock.remote_address.protocol.should == 0
- end
- end
- end
-
- describe 'using an implicit hostname' do
- before do
- @sock = UDPSocket.new(family)
-
- @sock.connect(nil, @port)
- end
-
- after do
- @sock.close
- end
-
- describe 'the returned Addrinfo' do
- it 'uses the correct IP address' do
- @sock.remote_address.ip_address.should == @host
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/send_spec.rb b/spec/ruby/library/socket/udpsocket/send_spec.rb
index 5d5de684af..1a6f44b26e 100644
--- a/spec/ruby/library/socket/udpsocket/send_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/send_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
-describe "UDPSocket#send" do
+describe "UDPSocket.send" do
before :each do
@port = nil
@server_thread = Thread.new do
@@ -34,7 +34,7 @@ describe "UDPSocket#send" do
@msg[0].should == "ad hoc"
@msg[1][0].should == "AF_INET"
- @msg[1][1].should be_kind_of(Integer)
+ @msg[1][1].should be_kind_of(Fixnum)
@msg[1][3].should == "127.0.0.1"
end
@@ -46,7 +46,7 @@ describe "UDPSocket#send" do
@msg[0].should == "ad hoc"
@msg[1][0].should == "AF_INET"
- @msg[1][1].should be_kind_of(Integer)
+ @msg[1][1].should be_kind_of(Fixnum)
@msg[1][3].should == "127.0.0.1"
end
@@ -59,14 +59,14 @@ describe "UDPSocket#send" do
@msg[0].should == "connection-based"
@msg[1][0].should == "AF_INET"
- @msg[1][1].should be_kind_of(Integer)
+ @msg[1][1].should be_kind_of(Fixnum)
@msg[1][3].should == "127.0.0.1"
end
it "raises EMSGSIZE if data is too too big" do
@socket = UDPSocket.open
begin
- -> do
+ lambda do
@socket.send('1' * 100_000, 0, SocketSpecs.hostname, @port.to_s)
end.should raise_error(Errno::EMSGSIZE)
ensure
@@ -76,79 +76,3 @@ describe "UDPSocket#send" do
end
end
end
-
-describe 'UDPSocket#send' do
- SocketSpecs.each_ip_protocol do |family, ip_address|
- before do
- @server = UDPSocket.new(family)
- @client = UDPSocket.new(family)
-
- @server.bind(ip_address, 0)
-
- @addr = @server.connect_address
- end
-
- after do
- @server.close
- @client.close
- end
-
- describe 'using a disconnected socket' do
- describe 'without a destination address' do
- it "raises #{SocketSpecs.dest_addr_req_error}" do
- -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error)
- end
- end
-
- describe 'with a destination address as separate arguments' do
- it 'returns the amount of sent bytes' do
- @client.send('hello', 0, @addr.ip_address, @addr.ip_port).should == 5
- end
-
- it 'does not persist the connection after sending data' do
- @client.send('hello', 0, @addr.ip_address, @addr.ip_port)
-
- -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error)
- end
- end
-
- describe 'with a destination address as a single String argument' do
- it 'returns the amount of sent bytes' do
- @client.send('hello', 0, @server.getsockname).should == 5
- end
- end
- end
-
- describe 'using a connected socket' do
- describe 'without an explicit destination address' do
- before do
- @client.connect(@addr.ip_address, @addr.ip_port)
- end
-
- it 'returns the amount of bytes written' do
- @client.send('hello', 0).should == 5
- end
- end
-
- describe 'with an explicit destination address' do
- before do
- @alt_server = UDPSocket.new(family)
-
- @alt_server.bind(ip_address, 0)
- end
-
- after do
- @alt_server.close
- end
-
- it 'sends the data to the given address instead' do
- @client.send('hello', 0, @alt_server.getsockname).should == 5
-
- -> { @server.recv(5) }.should block_caller
-
- @alt_server.recv(5).should == 'hello'
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/udpsocket/write_spec.rb b/spec/ruby/library/socket/udpsocket/write_spec.rb
index c971f29b62..11e38bb470 100644
--- a/spec/ruby/library/socket/udpsocket/write_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/write_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UDPSocket#write" do
it "raises EMSGSIZE if msg is too long" do
@@ -10,7 +10,7 @@ describe "UDPSocket#write" do
s2 = UDPSocket.new
s2.connect(host, s1.addr[1])
- -> do
+ lambda do
s2.write('1' * 100_000)
end.should raise_error(Errno::EMSGSIZE)
ensure
diff --git a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb
index 30688b46b6..b94e91e879 100644
--- a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb
+++ b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXServer#accept_nonblock" do
@@ -29,63 +29,9 @@ describe "UNIXServer#accept_nonblock" do
@socket.should be_kind_of(UNIXSocket)
end
- it 'returns :wait_readable in exceptionless mode' do
- @server.accept_nonblock(exception: false).should == :wait_readable
- end
- end
-end
-
-with_feature :unix_socket do
- describe 'UNIXServer#accept_nonblock' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- end
-
- after do
- @server.close
- rm_r(@path)
- end
-
- describe 'without a client' do
- it 'raises IO::WaitReadable' do
- -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable)
- end
- end
-
- describe 'with a client' do
- before do
- @client = UNIXSocket.new(@path)
- end
-
- after do
- @client.close
- @socket.close if @socket
- end
-
- describe 'without any data' do
- it 'returns a UNIXSocket' do
- @socket = @server.accept_nonblock
- @socket.should be_an_instance_of(UNIXSocket)
- end
- end
-
- describe 'with data available' do
- before do
- @client.write('hello')
- end
-
- it 'returns a UNIXSocket' do
- @socket = @server.accept_nonblock
- @socket.should be_an_instance_of(UNIXSocket)
- end
-
- describe 'the returned UNIXSocket' do
- it 'can read the data written' do
- @socket = @server.accept_nonblock
- @socket.recv(5).should == 'hello'
- end
- end
+ ruby_version_is '2.3' do
+ it 'returns :wait_readable in exceptionless mode' do
+ @server.accept_nonblock(exception: false).should == :wait_readable
end
end
end
diff --git a/spec/ruby/library/socket/unixserver/accept_spec.rb b/spec/ruby/library/socket/unixserver/accept_spec.rb
index c05fbe7f22..3921dadd9d 100644
--- a/spec/ruby/library/socket/unixserver/accept_spec.rb
+++ b/spec/ruby/library/socket/unixserver/accept_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
platform_is_not :windows do
describe "UNIXServer#accept" do
@@ -59,59 +59,3 @@ platform_is_not :windows do
end
end
end
-
-with_feature :unix_socket do
- describe 'UNIXServer#accept' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- end
-
- after do
- @server.close
- rm_r(@path)
- end
-
- describe 'without a client' do
- it 'blocks the calling thread' do
- -> { @server.accept }.should block_caller
- end
- end
-
- describe 'with a client' do
- before do
- @client = UNIXSocket.new(@path)
- end
-
- after do
- @client.close
- @socket.close if @socket
- end
-
- describe 'without any data' do
- it 'returns a UNIXSocket' do
- @socket = @server.accept
- @socket.should be_an_instance_of(UNIXSocket)
- end
- end
-
- describe 'with data available' do
- before do
- @client.write('hello')
- end
-
- it 'returns a UNIXSocket' do
- @socket = @server.accept
- @socket.should be_an_instance_of(UNIXSocket)
- end
-
- describe 'the returned UNIXSocket' do
- it 'can read the data written' do
- @socket = @server.accept
- @socket.recv(5).should == 'hello'
- end
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixserver/for_fd_spec.rb b/spec/ruby/library/socket/unixserver/for_fd_spec.rb
index 4f3816ad37..c3cfd86a1c 100644
--- a/spec/ruby/library/socket/unixserver/for_fd_spec.rb
+++ b/spec/ruby/library/socket/unixserver/for_fd_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
platform_is_not :windows do
describe "UNIXServer#for_fd" do
diff --git a/spec/ruby/library/socket/unixserver/initialize_spec.rb b/spec/ruby/library/socket/unixserver/initialize_spec.rb
deleted file mode 100644
index 0cc49ef1eb..0000000000
--- a/spec/ruby/library/socket/unixserver/initialize_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'UNIXServer#initialize' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- end
-
- after do
- @server.close if @server
- rm_r @path
- end
-
- it 'returns a new UNIXServer' do
- @server.should be_an_instance_of(UNIXServer)
- end
-
- it 'sets the socket to binmode' do
- @server.binmode?.should be_true
- end
-
- it 'raises Errno::EADDRINUSE when the socket is already in use' do
- -> { UNIXServer.new(@path) }.should raise_error(Errno::EADDRINUSE)
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixserver/listen_spec.rb b/spec/ruby/library/socket/unixserver/listen_spec.rb
deleted file mode 100644
index b90b3bbb09..0000000000
--- a/spec/ruby/library/socket/unixserver/listen_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'UNIXServer#listen' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- end
-
- after do
- @server.close
-
- rm_r(@path)
- end
-
- it 'returns 0' do
- @server.listen(1).should == 0
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixserver/new_spec.rb b/spec/ruby/library/socket/unixserver/new_spec.rb
index f831f40bc6..d34aa0ca03 100644
--- a/spec/ruby/library/socket/unixserver/new_spec.rb
+++ b/spec/ruby/library/socket/unixserver/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'shared/new'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "UNIXServer.new" do
it_behaves_like :unixserver_new, :new
diff --git a/spec/ruby/library/socket/unixserver/open_spec.rb b/spec/ruby/library/socket/unixserver/open_spec.rb
index f2506d9f6f..47c76eb9b4 100644
--- a/spec/ruby/library/socket/unixserver/open_spec.rb
+++ b/spec/ruby/library/socket/unixserver/open_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/new'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "UNIXServer.open" do
it_behaves_like :unixserver_new, :open
diff --git a/spec/ruby/library/socket/unixserver/shared/new.rb b/spec/ruby/library/socket/unixserver/shared/new.rb
index 35395826c9..2018140caa 100644
--- a/spec/ruby/library/socket/unixserver/shared/new.rb
+++ b/spec/ruby/library/socket/unixserver/shared/new.rb
@@ -1,5 +1,6 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/classes', __FILE__)
+require 'tempfile'
describe :unixserver_new, shared: true do
platform_is_not :windows do
diff --git a/spec/ruby/library/socket/unixserver/sysaccept_spec.rb b/spec/ruby/library/socket/unixserver/sysaccept_spec.rb
deleted file mode 100644
index e59731878a..0000000000
--- a/spec/ruby/library/socket/unixserver/sysaccept_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'UNIXServer#sysaccept' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- end
-
- after do
- @server.close
-
- rm_r(@path)
- end
-
- describe 'without a client' do
- it 'blocks the calling thread' do
- -> { @server.sysaccept }.should block_caller
- end
- end
-
- describe 'with a client' do
- before do
- @client = UNIXSocket.new(@path)
- end
-
- after do
- Socket.for_fd(@fd).close if @fd
- @client.close
- end
-
- describe 'without any data' do
- it 'returns an Integer' do
- @fd = @server.sysaccept
- @fd.should be_kind_of(Integer)
- end
- end
-
- describe 'with data available' do
- before do
- @client.write('hello')
- end
-
- it 'returns an Integer' do
- @fd = @server.sysaccept
- @fd.should be_kind_of(Integer)
- end
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixsocket/addr_spec.rb b/spec/ruby/library/socket/unixsocket/addr_spec.rb
index e8431bea16..34c62e083f 100644
--- a/spec/ruby/library/socket/unixsocket/addr_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/addr_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXSocket#addr" do
@@ -16,13 +16,8 @@ describe "UNIXSocket#addr" do
SocketSpecs.rm_socket @path
end
- it "returns an array" do
- @client.addr.should be_kind_of(Array)
- end
-
it "returns the address family of this socket in an array" do
@client.addr[0].should == "AF_UNIX"
- @server.addr[0].should == "AF_UNIX"
end
it "returns the path of the socket in an array if it's a server" do
@@ -32,5 +27,10 @@ describe "UNIXSocket#addr" do
it "returns an empty string for path if it's a client" do
@client.addr[1].should == ""
end
+
+ it "returns an array" do
+ @client.addr.should be_kind_of(Array)
+ end
end
+
end
diff --git a/spec/ruby/library/socket/unixsocket/initialize_spec.rb b/spec/ruby/library/socket/unixsocket/initialize_spec.rb
deleted file mode 100644
index 13b6972f03..0000000000
--- a/spec/ruby/library/socket/unixsocket/initialize_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'UNIXSocket#initialize' do
- describe 'using a non existing path' do
- it 'raises Errno::ENOENT' do
- -> { UNIXSocket.new(SocketSpecs.socket_path) }.should raise_error(Errno::ENOENT)
- end
- end
-
- describe 'using an existing socket path' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- @socket = UNIXSocket.new(@path)
- end
-
- after do
- @socket.close
- @server.close
- rm_r(@path)
- end
-
- it 'returns a new UNIXSocket' do
- @socket.should be_an_instance_of(UNIXSocket)
- end
-
- it 'sets the socket path to an empty String' do
- @socket.path.should == ''
- end
-
- it 'sets the socket to binmode' do
- @socket.binmode?.should be_true
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixsocket/inspect_spec.rb b/spec/ruby/library/socket/unixsocket/inspect_spec.rb
index d2e3cabbd3..8ea25ec1e9 100644
--- a/spec/ruby/library/socket/unixsocket/inspect_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/inspect_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXSocket#inspect" do
platform_is_not :windows do
diff --git a/spec/ruby/library/socket/unixsocket/local_address_spec.rb b/spec/ruby/library/socket/unixsocket/local_address_spec.rb
deleted file mode 100644
index cbf315f9f4..0000000000
--- a/spec/ruby/library/socket/unixsocket/local_address_spec.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'UNIXSocket#local_address' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- @client = UNIXSocket.new(@path)
- end
-
- after do
- @client.close
- @server.close
-
- rm_r(@path)
- end
-
- it 'returns an Addrinfo' do
- @client.local_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- platform_is_not :aix do
- it 'uses AF_UNIX as the address family' do
- @client.local_address.afamily.should == Socket::AF_UNIX
- end
-
- it 'uses PF_UNIX as the protocol family' do
- @client.local_address.pfamily.should == Socket::PF_UNIX
- end
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @client.local_address.socktype.should == Socket::SOCK_STREAM
- end
-
- platform_is_not :aix do
- it 'uses an empty socket path' do
- @client.local_address.unix_path.should == ''
- end
- end
-
- it 'uses 0 as the protocol' do
- @client.local_address.protocol.should == 0
- end
- end
- end
-end
-
-with_feature :unix_socket do
- describe 'UNIXSocket#local_address with a UNIX socket pair' do
- before :each do
- @sock, @sock2 = Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM)
- end
-
- after :each do
- @sock.close
- @sock2.close
- end
-
- it 'returns an Addrinfo' do
- @sock.local_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses AF_UNIX as the address family' do
- @sock.local_address.afamily.should == Socket::AF_UNIX
- end
-
- it 'uses PF_UNIX as the protocol family' do
- @sock.local_address.pfamily.should == Socket::PF_UNIX
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @sock.local_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'raises SocketError for #ip_address' do
- -> {
- @sock.local_address.ip_address
- }.should raise_error(SocketError, "need IPv4 or IPv6 address")
- end
-
- it 'raises SocketError for #ip_port' do
- -> {
- @sock.local_address.ip_port
- }.should raise_error(SocketError, "need IPv4 or IPv6 address")
- end
-
- it 'uses 0 as the protocol' do
- @sock.local_address.protocol.should == 0
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixsocket/new_spec.rb b/spec/ruby/library/socket/unixsocket/new_spec.rb
index 05a6b3eda2..7db8613b96 100644
--- a/spec/ruby/library/socket/unixsocket/new_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/new_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative 'shared/new'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "UNIXSocket.new" do
it_behaves_like :unixsocket_new, :new
diff --git a/spec/ruby/library/socket/unixsocket/open_spec.rb b/spec/ruby/library/socket/unixsocket/open_spec.rb
index ad5048fedd..5b9b19ee33 100644
--- a/spec/ruby/library/socket/unixsocket/open_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/open_spec.rb
@@ -1,6 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative 'shared/new'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/new', __FILE__)
describe "UNIXSocket.open" do
it_behaves_like :unixsocket_new, :open
@@ -19,7 +18,7 @@ describe "UNIXSocket.open" do
end
it "opens a unix socket on the specified file and yields it to the block" do
- UNIXSocket.open(@path) do |client|
+ UNIXSocket.send(@method, @path) do |client|
client.addr[0].should == "AF_UNIX"
client.closed?.should == false
end
diff --git a/spec/ruby/library/socket/unixsocket/pair_spec.rb b/spec/ruby/library/socket/unixsocket/pair_spec.rb
index 845ff76ecc..5cd75e2906 100644
--- a/spec/ruby/library/socket/unixsocket/pair_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/pair_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/partially_closable_sockets'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/partially_closable_sockets', __FILE__)
describe "UNIXSocket#pair" do
platform_is_not :windows do
diff --git a/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb b/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb
index 78a64fe6be..f43274db2e 100644
--- a/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/partially_closable_sockets'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/partially_closable_sockets', __FILE__)
platform_is_not :windows do
describe "UNIXSocket partial closability" do
diff --git a/spec/ruby/library/socket/unixsocket/path_spec.rb b/spec/ruby/library/socket/unixsocket/path_spec.rb
index 317ffc0975..a2beaffeea 100644
--- a/spec/ruby/library/socket/unixsocket/path_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/path_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXSocket#path" do
diff --git a/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb b/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb
index 0b6b1ccf04..dc5a319f4d 100644
--- a/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXSocket#peeraddr" do
@@ -16,12 +16,12 @@ describe "UNIXSocket#peeraddr" do
SocketSpecs.rm_socket @path
end
- it "returns the address family and path of the server end of the connection" do
+ it "returns the address familly and path of the server end of the connection" do
@client.peeraddr.should == ["AF_UNIX", @path]
end
it "raises an error in server sockets" do
- -> {
+ lambda {
@server.peeraddr
}.should raise_error(Errno::ENOTCONN)
end
diff --git a/spec/ruby/library/socket/unixsocket/recv_io_spec.rb b/spec/ruby/library/socket/unixsocket/recv_io_spec.rb
index 533f02a0fa..c7a8946ceb 100644
--- a/spec/ruby/library/socket/unixsocket/recv_io_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/recv_io_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXSocket#recv_io" do
@@ -38,50 +38,7 @@ describe "UNIXSocket#recv_io" do
@socket = @server.accept
@io = @socket.recv_io(File)
- @io.should be_an_instance_of(File)
- end
- end
-end
-
-with_feature :unix_socket do
- describe 'UNIXSocket#recv_io' do
- before do
- @file = File.open('/dev/null', 'w')
- @client, @server = UNIXSocket.socketpair
- end
-
- after do
- @client.close
- @server.close
- @io.close if @io
- @file.close
- end
-
- describe 'without a custom class' do
- it 'returns an IO' do
- @client.send_io(@file)
-
- @io = @server.recv_io
- @io.should be_an_instance_of(IO)
- end
- end
-
- describe 'with a custom class' do
- it 'returns an instance of the custom class' do
- @client.send_io(@file)
-
- @io = @server.recv_io(File)
- @io.should be_an_instance_of(File)
- end
- end
-
- describe 'with a custom mode' do
- it 'opens the IO using the given mode' do
- @client.send_io(@file)
-
- @io = @server.recv_io(File, File::WRONLY)
- @io.should be_an_instance_of(File)
- end
+ @io.should be_kind_of(File)
end
end
end
diff --git a/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb b/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb
index c0e1cf670b..78e272bfe2 100644
--- a/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXSocket#recvfrom" do
+
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
@@ -42,57 +43,5 @@ describe "UNIXSocket#recvfrom" do
sock.close
end
end
-end
-
-
-with_feature :unix_socket do
- describe 'UNIXSocket#recvfrom' do
- describe 'using a socket pair' do
- before do
- @client, @server = UNIXSocket.socketpair
- @client.write('hello')
- end
-
- after do
- @client.close
- @server.close
- end
-
- it 'returns an Array containing the data and address information' do
- @server.recvfrom(5).should == ['hello', ['AF_UNIX', '']]
- end
- end
-
- # These specs are taken from the rdoc examples on UNIXSocket#recvfrom.
- describe 'using a UNIX socket constructed using UNIXSocket.for_fd' do
- before do
- @path1 = SocketSpecs.socket_path
- @path2 = SocketSpecs.socket_path.chop + '2'
- rm_r(@path2)
- @client_raw = Socket.new(:UNIX, :DGRAM)
- @client_raw.bind(Socket.sockaddr_un(@path1))
-
- @server_raw = Socket.new(:UNIX, :DGRAM)
- @server_raw.bind(Socket.sockaddr_un(@path2))
-
- @socket = UNIXSocket.for_fd(@server_raw.fileno)
- @socket.autoclose = false
- end
-
- after do
- @client_raw.close
- @server_raw.close # also closes @socket
-
- rm_r @path1
- rm_r @path2
- end
-
- it 'returns an Array containing the data and address information' do
- @client_raw.send('hello', 0, Socket.sockaddr_un(@path2))
-
- @socket.recvfrom(5).should == ['hello', ['AF_UNIX', @path1]]
- end
- end
- end
end
diff --git a/spec/ruby/library/socket/unixsocket/remote_address_spec.rb b/spec/ruby/library/socket/unixsocket/remote_address_spec.rb
deleted file mode 100644
index 0b416254d0..0000000000
--- a/spec/ruby/library/socket/unixsocket/remote_address_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
-
-with_feature :unix_socket do
- describe 'UNIXSocket#remote_address' do
- before do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.new(@path)
- @client = UNIXSocket.new(@path)
- end
-
- after do
- @client.close
- @server.close
-
- rm_r(@path)
- end
-
- it 'returns an Addrinfo' do
- @client.remote_address.should be_an_instance_of(Addrinfo)
- end
-
- describe 'the returned Addrinfo' do
- it 'uses AF_UNIX as the address family' do
- @client.remote_address.afamily.should == Socket::AF_UNIX
- end
-
- it 'uses PF_UNIX as the protocol family' do
- @client.remote_address.pfamily.should == Socket::PF_UNIX
- end
-
- it 'uses SOCK_STREAM as the socket type' do
- @client.remote_address.socktype.should == Socket::SOCK_STREAM
- end
-
- it 'uses the correct socket path' do
- @client.remote_address.unix_path.should == @path
- end
-
- it 'uses 0 as the protocol' do
- @client.remote_address.protocol.should == 0
- end
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixsocket/send_io_spec.rb b/spec/ruby/library/socket/unixsocket/send_io_spec.rb
index a2a7d26539..ec8d6b2314 100644
--- a/spec/ruby/library/socket/unixsocket/send_io_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/send_io_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
describe "UNIXSocket#send_io" do
@@ -33,26 +33,3 @@ describe "UNIXSocket#send_io" do
end
end
end
-
-with_feature :unix_socket do
- describe 'UNIXSocket#send_io' do
- before do
- @file = File.open('/dev/null', 'w')
- @client, @server = UNIXSocket.socketpair
- end
-
- after do
- @client.close
- @server.close
- @io.close if @io
- @file.close
- end
-
- it 'sends an IO object' do
- @client.send_io(@file)
-
- @io = @server.recv_io
- @io.should be_an_instance_of(IO)
- end
- end
-end
diff --git a/spec/ruby/library/socket/unixsocket/shared/new.rb b/spec/ruby/library/socket/unixsocket/shared/new.rb
index 76a4e1701e..76c0d07b83 100644
--- a/spec/ruby/library/socket/unixsocket/shared/new.rb
+++ b/spec/ruby/library/socket/unixsocket/shared/new.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/classes'
+require File.expand_path('../../../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/classes', __FILE__)
describe :unixsocket_new, shared: true do
platform_is_not :windows do
diff --git a/spec/ruby/library/socket/unixsocket/socketpair_spec.rb b/spec/ruby/library/socket/unixsocket/socketpair_spec.rb
deleted file mode 100644
index 3e9646f76b..0000000000
--- a/spec/ruby/library/socket/unixsocket/socketpair_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require_relative '../spec_helper'
-
-with_feature :unix_socket do
- describe 'UNIXSocket.socketpair' do
- before do
- @s1, @s2 = UNIXSocket.socketpair
- end
-
- after do
- @s1.close
- @s2.close
- end
-
- it 'returns two UNIXSockets' do
- @s1.should be_an_instance_of(UNIXSocket)
- @s2.should be_an_instance_of(UNIXSocket)
- end
-
- it 'connects the sockets to each other' do
- @s1.write('hello')
-
- @s2.recv(5).should == 'hello'
- end
-
- it 'sets the socket paths to empty Strings' do
- @s1.path.should == ''
- @s2.path.should == ''
- end
-
- it 'sets the socket addresses to empty Strings' do
- @s1.addr.should == ['AF_UNIX', '']
- @s2.addr.should == ['AF_UNIX', '']
- end
-
- it 'sets the socket peer addresses to empty Strings' do
- @s1.peeraddr.should == ['AF_UNIX', '']
- @s2.peeraddr.should == ['AF_UNIX', '']
- end
- end
-end
diff --git a/spec/ruby/library/stringio/append_spec.rb b/spec/ruby/library/stringio/append_spec.rb
index c46dc59ee5..ff0dc233cd 100644
--- a/spec/ruby/library/stringio/append_spec.rb
+++ b/spec/ruby/library/stringio/append_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#<< when passed [Object]" do
before :each do
@@ -29,11 +29,9 @@ describe "StringIO#<< when passed [Object]" do
@io.string.should == "example\000\000\000\000\000\000\000\000just testing"
end
- ruby_version_is ""..."2.7" do
- it "taints self's String when the passed argument is tainted" do
- (@io << "test".taint)
- @io.string.tainted?.should be_true
- end
+ it "taints self's String when the passed argument is tainted" do
+ (@io << "test".taint)
+ @io.string.tainted?.should be_true
end
it "does not taint self when the passed argument is tainted" do
@@ -57,11 +55,11 @@ end
describe "StringIO#<< when self is not writable" do
it "raises an IOError" do
io = StringIO.new("test", "r")
- -> { io << "test" }.should raise_error(IOError)
+ lambda { io << "test" }.should raise_error(IOError)
io = StringIO.new("test")
io.close_write
- -> { io << "test" }.should raise_error(IOError)
+ lambda { io << "test" }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/binmode_spec.rb b/spec/ruby/library/stringio/binmode_spec.rb
index 5d9a8c41df..11fbbaadeb 100644
--- a/spec/ruby/library/stringio/binmode_spec.rb
+++ b/spec/ruby/library/stringio/binmode_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#binmode" do
it "returns self" do
diff --git a/spec/ruby/library/stringio/bytes_spec.rb b/spec/ruby/library/stringio/bytes_spec.rb
index 692fba997f..22d990dff7 100644
--- a/spec/ruby/library/stringio/bytes_spec.rb
+++ b/spec/ruby/library/stringio/bytes_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/each_byte'
+require File.expand_path('../shared/each_byte', __FILE__)
describe "StringIO#bytes" do
it_behaves_like :stringio_each_byte, :bytes
diff --git a/spec/ruby/library/stringio/chars_spec.rb b/spec/ruby/library/stringio/chars_spec.rb
index 7dc55d4b37..c5ffde23db 100644
--- a/spec/ruby/library/stringio/chars_spec.rb
+++ b/spec/ruby/library/stringio/chars_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/each_char'
+require File.expand_path('../shared/each_char', __FILE__)
describe "StringIO#chars" do
it_behaves_like :stringio_each_char, :chars
diff --git a/spec/ruby/library/stringio/close_read_spec.rb b/spec/ruby/library/stringio/close_read_spec.rb
index 80bd547e85..59e16385d2 100644
--- a/spec/ruby/library/stringio/close_read_spec.rb
+++ b/spec/ruby/library/stringio/close_read_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#close_read" do
before :each do
@@ -12,7 +12,7 @@ describe "StringIO#close_read" do
it "prevents further reading" do
@io.close_read
- -> { @io.read(1) }.should raise_error(IOError)
+ lambda { @io.read(1) }.should raise_error(IOError)
end
it "allows further writing" do
@@ -22,10 +22,15 @@ describe "StringIO#close_read" do
it "raises an IOError when in write-only mode" do
io = StringIO.new("example", "w")
- -> { io.close_read }.should raise_error(IOError)
+ lambda { io.close_read }.should raise_error(IOError)
io = StringIO.new("example")
io.close_read
- io.close_read.should == nil
+ ruby_version_is ''...'2.3' do
+ lambda { io.close_read }.should raise_error(IOError)
+ end
+ ruby_version_is '2.3' do
+ io.close_read.should == nil
+ end
end
end
diff --git a/spec/ruby/library/stringio/close_spec.rb b/spec/ruby/library/stringio/close_spec.rb
index 520a8de782..423aad4bd1 100644
--- a/spec/ruby/library/stringio/close_spec.rb
+++ b/spec/ruby/library/stringio/close_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#close" do
before :each do
@@ -12,12 +12,21 @@ describe "StringIO#close" do
it "prevents further reading and/or writing" do
@io.close
- -> { @io.read(1) }.should raise_error(IOError)
- -> { @io.write('x') }.should raise_error(IOError)
+ lambda { @io.read(1) }.should raise_error(IOError)
+ lambda { @io.write('x') }.should raise_error(IOError)
end
- it "does not raise anything when self was already closed" do
- @io.close
- -> { @io.close }.should_not raise_error(IOError)
+ ruby_version_is ''...'2.3' do
+ it "raises an IOError when self was already closed" do
+ @io.close
+ lambda { @io.close }.should raise_error(IOError)
+ end
+ end
+
+ ruby_version_is "2.3" do
+ it "does not raise anything when self was already closed" do
+ @io.close
+ lambda { @io.close }.should_not raise_error(IOError)
+ end
end
end
diff --git a/spec/ruby/library/stringio/close_write_spec.rb b/spec/ruby/library/stringio/close_write_spec.rb
index 1a4cfa113e..6637fe6043 100644
--- a/spec/ruby/library/stringio/close_write_spec.rb
+++ b/spec/ruby/library/stringio/close_write_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#close_write" do
before :each do
@@ -12,7 +12,7 @@ describe "StringIO#close_write" do
it "prevents further writing" do
@io.close_write
- -> { @io.write('x') }.should raise_error(IOError)
+ lambda { @io.write('x') }.should raise_error(IOError)
end
it "allows further reading" do
@@ -22,10 +22,15 @@ describe "StringIO#close_write" do
it "raises an IOError when in read-only mode" do
io = StringIO.new("example", "r")
- -> { io.close_write }.should raise_error(IOError)
+ lambda { io.close_write }.should raise_error(IOError)
io = StringIO.new("example")
io.close_write
- io.close_write.should == nil
+ ruby_version_is ''...'2.3' do
+ lambda { io.close_write }.should raise_error(IOError)
+ end
+ ruby_version_is '2.3' do
+ io.close_write.should == nil
+ end
end
end
diff --git a/spec/ruby/library/stringio/closed_read_spec.rb b/spec/ruby/library/stringio/closed_read_spec.rb
index cb4267ac98..971eb5f71c 100644
--- a/spec/ruby/library/stringio/closed_read_spec.rb
+++ b/spec/ruby/library/stringio/closed_read_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#closed_read?" do
it "returns true if self is not readable" do
diff --git a/spec/ruby/library/stringio/closed_spec.rb b/spec/ruby/library/stringio/closed_spec.rb
index ca8a2232a8..4026d78775 100644
--- a/spec/ruby/library/stringio/closed_spec.rb
+++ b/spec/ruby/library/stringio/closed_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#closed?" do
it "returns true if self is completely closed" do
diff --git a/spec/ruby/library/stringio/closed_write_spec.rb b/spec/ruby/library/stringio/closed_write_spec.rb
index 5c111affd8..52707aa240 100644
--- a/spec/ruby/library/stringio/closed_write_spec.rb
+++ b/spec/ruby/library/stringio/closed_write_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#closed_write?" do
it "returns true if self is not writable" do
diff --git a/spec/ruby/library/stringio/codepoints_spec.rb b/spec/ruby/library/stringio/codepoints_spec.rb
index cc2e5d1b5d..098bd3c4c3 100644
--- a/spec/ruby/library/stringio/codepoints_spec.rb
+++ b/spec/ruby/library/stringio/codepoints_spec.rb
@@ -1,9 +1,9 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/codepoints'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/codepoints', __FILE__)
# See redmine #1667
describe "StringIO#codepoints" do
- it_behaves_like :stringio_codepoints, :codepoints
+ it_behaves_like(:stringio_codepoints, :codepoints)
end
diff --git a/spec/ruby/library/stringio/each_byte_spec.rb b/spec/ruby/library/stringio/each_byte_spec.rb
index 6f82a32441..8e88997bc0 100644
--- a/spec/ruby/library/stringio/each_byte_spec.rb
+++ b/spec/ruby/library/stringio/each_byte_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/each_byte'
+require File.expand_path('../shared/each_byte', __FILE__)
describe "StringIO#each_byte" do
it_behaves_like :stringio_each_byte, :each_byte
diff --git a/spec/ruby/library/stringio/each_char_spec.rb b/spec/ruby/library/stringio/each_char_spec.rb
index 7305162ee6..a141ae03fe 100644
--- a/spec/ruby/library/stringio/each_char_spec.rb
+++ b/spec/ruby/library/stringio/each_char_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/each_char'
+require File.expand_path('../shared/each_char', __FILE__)
describe "StringIO#each_char" do
it_behaves_like :stringio_each_char, :each_char
diff --git a/spec/ruby/library/stringio/each_codepoint_spec.rb b/spec/ruby/library/stringio/each_codepoint_spec.rb
index 85aa34d9d8..25a0bf4c81 100644
--- a/spec/ruby/library/stringio/each_codepoint_spec.rb
+++ b/spec/ruby/library/stringio/each_codepoint_spec.rb
@@ -1,9 +1,10 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/codepoints'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/codepoints', __FILE__)
# See redmine #1667
describe "StringIO#each_codepoint" do
- it_behaves_like :stringio_codepoints, :codepoints
+ it_behaves_like(:stringio_codepoints, :codepoints)
end
+
diff --git a/spec/ruby/library/stringio/each_line_spec.rb b/spec/ruby/library/stringio/each_line_spec.rb
index 1389408399..d770c18e67 100644
--- a/spec/ruby/library/stringio/each_line_spec.rb
+++ b/spec/ruby/library/stringio/each_line_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/each'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each', __FILE__)
describe "StringIO#each_line when passed a separator" do
it_behaves_like :stringio_each_separator, :each_line
@@ -14,6 +14,8 @@ describe "StringIO#each_line when self is not readable" do
it_behaves_like :stringio_each_not_readable, :each_line
end
-describe "StringIO#each_line when passed chomp" do
- it_behaves_like :stringio_each_chomp, :each_line
+ruby_version_is "2.4" do
+ describe "StringIO#each_line when passed chomp" do
+ it_behaves_like :stringio_each_chomp, :each_line
+ end
end
diff --git a/spec/ruby/library/stringio/each_spec.rb b/spec/ruby/library/stringio/each_spec.rb
index a76460049b..cebaa345d8 100644
--- a/spec/ruby/library/stringio/each_spec.rb
+++ b/spec/ruby/library/stringio/each_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/each'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each', __FILE__)
describe "StringIO#each when passed a separator" do
it_behaves_like :stringio_each_separator, :each
@@ -14,6 +14,8 @@ describe "StringIO#each when self is not readable" do
it_behaves_like :stringio_each_not_readable, :each
end
-describe "StringIO#each when passed chomp" do
- it_behaves_like :stringio_each_chomp, :each
+ruby_version_is "2.4" do
+ describe "StringIO#each when passed chomp" do
+ it_behaves_like :stringio_each_chomp, :each
+ end
end
diff --git a/spec/ruby/library/stringio/eof_spec.rb b/spec/ruby/library/stringio/eof_spec.rb
index af0170977c..a5bb3dbe3d 100644
--- a/spec/ruby/library/stringio/eof_spec.rb
+++ b/spec/ruby/library/stringio/eof_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/eof'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/eof', __FILE__)
describe "StringIO#eof?" do
it_behaves_like :stringio_eof, :eof?
diff --git a/spec/ruby/library/stringio/external_encoding_spec.rb b/spec/ruby/library/stringio/external_encoding_spec.rb
index 6c5edb1713..9bf2d8ee8c 100644
--- a/spec/ruby/library/stringio/external_encoding_spec.rb
+++ b/spec/ruby/library/stringio/external_encoding_spec.rb
@@ -1,5 +1,5 @@
require 'stringio'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "StringIO#external_encoding" do
it "gets the encoding of the underlying String" do
@@ -8,18 +8,14 @@ describe "StringIO#external_encoding" do
io.external_encoding.should == Encoding::EUC_JP
end
- it "changes to match string if string's encoding is changed" do
- io = StringIO.new
- io.string.force_encoding(Encoding::EUC_JP)
- io.external_encoding.should == Encoding::EUC_JP
- end
-
- it "does not set the encoding of its buffer string if the string is frozen" do
- str = "foo".freeze
- enc = str.encoding
- io = StringIO.new(str)
- io.set_encoding Encoding::EUC_JP
- io.external_encoding.should == Encoding::EUC_JP
- str.encoding.should == enc
+ ruby_version_is "2.3" do
+ it "does not set the encoding of its buffer string if the string is frozen" do
+ str = "foo".freeze
+ enc = str.encoding
+ io = StringIO.new(str)
+ io.set_encoding Encoding::EUC_JP
+ io.external_encoding.should == Encoding::EUC_JP
+ str.encoding.should == enc
+ end
end
end
diff --git a/spec/ruby/library/stringio/fcntl_spec.rb b/spec/ruby/library/stringio/fcntl_spec.rb
index a78004d868..5250359a79 100644
--- a/spec/ruby/library/stringio/fcntl_spec.rb
+++ b/spec/ruby/library/stringio/fcntl_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#fcntl" do
it "raises a NotImplementedError" do
- -> { StringIO.new("boom").fcntl }.should raise_error(NotImplementedError)
+ lambda { StringIO.new("boom").fcntl }.should raise_error(NotImplementedError)
end
end
diff --git a/spec/ruby/library/stringio/fileno_spec.rb b/spec/ruby/library/stringio/fileno_spec.rb
index eea03a5af3..a5ae820830 100644
--- a/spec/ruby/library/stringio/fileno_spec.rb
+++ b/spec/ruby/library/stringio/fileno_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/each'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/each', __FILE__)
describe "StringIO#fileno" do
it "returns nil" do
diff --git a/spec/ruby/library/stringio/flush_spec.rb b/spec/ruby/library/stringio/flush_spec.rb
index 17a16dfdd5..75a92db85a 100644
--- a/spec/ruby/library/stringio/flush_spec.rb
+++ b/spec/ruby/library/stringio/flush_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#flush" do
it "returns self" do
diff --git a/spec/ruby/library/stringio/fsync_spec.rb b/spec/ruby/library/stringio/fsync_spec.rb
index 8fb2b59a24..509f4a972f 100644
--- a/spec/ruby/library/stringio/fsync_spec.rb
+++ b/spec/ruby/library/stringio/fsync_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#fsync" do
it "returns zero" do
diff --git a/spec/ruby/library/stringio/getbyte_spec.rb b/spec/ruby/library/stringio/getbyte_spec.rb
index 3daa3d8e02..163cb9d0c6 100644
--- a/spec/ruby/library/stringio/getbyte_spec.rb
+++ b/spec/ruby/library/stringio/getbyte_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/getc'
+require File.expand_path('../shared/getc', __FILE__)
describe "StringIO#getbyte" do
it_behaves_like :stringio_getc, :getbyte
@@ -8,9 +8,9 @@ describe "StringIO#getbyte" do
it "returns the 8-bit byte at the current position" do
io = StringIO.new("example")
- io.getbyte.should == 101
- io.getbyte.should == 120
- io.getbyte.should == 97
+ io.send(@method).should == 101
+ io.send(@method).should == 120
+ io.send(@method).should == 97
end
end
diff --git a/spec/ruby/library/stringio/getc_spec.rb b/spec/ruby/library/stringio/getc_spec.rb
index 263d418316..804502d8ba 100644
--- a/spec/ruby/library/stringio/getc_spec.rb
+++ b/spec/ruby/library/stringio/getc_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/getc'
+require File.expand_path('../shared/getc', __FILE__)
describe "StringIO#getc" do
it_behaves_like :stringio_getc, :getc
@@ -8,9 +8,9 @@ describe "StringIO#getc" do
it "returns the character at the current position" do
io = StringIO.new("example")
- io.getc.should == ?e
- io.getc.should == ?x
- io.getc.should == ?a
+ io.send(@method).should == ?e
+ io.send(@method).should == ?x
+ io.send(@method).should == ?a
end
end
diff --git a/spec/ruby/library/stringio/getch_spec.rb b/spec/ruby/library/stringio/getch_spec.rb
index 113b4971bf..d6f652424e 100644
--- a/spec/ruby/library/stringio/getch_spec.rb
+++ b/spec/ruby/library/stringio/getch_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/getc'
+require File.expand_path('../shared/getc', __FILE__)
# This method is added by io/console on require.
describe "StringIO#getch" do
@@ -12,30 +12,32 @@ describe "StringIO#getch" do
it "returns the character at the current position" do
io = StringIO.new("example")
- io.getch.should == ?e
- io.getch.should == ?x
- io.getch.should == ?a
+ io.send(@method).should == ?e
+ io.send(@method).should == ?x
+ io.send(@method).should == ?a
end
- it "increments #pos by the byte size of the character in multibyte strings" do
- io = StringIO.new("föóbar")
+ with_feature :encoding do
+ it "increments #pos by the byte size of the character in multibyte strings" do
+ io = StringIO.new("föóbar")
- io.getch; io.pos.should == 1 # "f" has byte size 1
- io.getch; io.pos.should == 3 # "ö" has byte size 2
- io.getch; io.pos.should == 5 # "ó" has byte size 2
- io.getch; io.pos.should == 6 # "b" has byte size 1
+ io.send(@method); io.pos.should == 1 # "f" has byte size 1
+ io.send(@method); io.pos.should == 3 # "ö" has byte size 2
+ io.send(@method); io.pos.should == 5 # "ó" has byte size 2
+ io.send(@method); io.pos.should == 6 # "b" has byte size 1
+ end
end
it "returns nil at the end of the string" do
# empty string case
io = StringIO.new("")
- io.getch.should == nil
- io.getch.should == nil
+ io.send(@method).should == nil
+ io.send(@method).should == nil
# non-empty string case
io = StringIO.new("a")
- io.getch # skip one
- io.getch.should == nil
+ io.send(@method) # skip one
+ io.send(@method).should == nil
end
describe "StringIO#getch when self is not readable" do
diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb
index 69880672a3..a718098a4b 100644
--- a/spec/ruby/library/stringio/gets_spec.rb
+++ b/spec/ruby/library/stringio/gets_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
describe "StringIO#gets when passed [separator]" do
@@ -229,17 +229,19 @@ end
describe "StringIO#gets when in write-only mode" do
it "raises an IOError" do
io = StringIO.new("xyz", "w")
- -> { io.gets }.should raise_error(IOError)
+ lambda { io.gets }.should raise_error(IOError)
io = StringIO.new("xyz")
io.close_read
- -> { io.gets }.should raise_error(IOError)
+ lambda { io.gets }.should raise_error(IOError)
end
end
-describe "StringIO#gets when passed [chomp]" do
- it "returns the data read without a trailing newline character" do
- io = StringIO.new("this>is>an>example\n")
- io.gets(chomp: true).should == "this>is>an>example"
+ruby_version_is "2.4" do
+ describe "StringIO#gets when passed [chomp]" do
+ it "returns the data read without a trailing newline character" do
+ io = StringIO.new("this>is>an>example\n")
+ io.gets(chomp: true).should == "this>is>an>example"
+ end
end
end
diff --git a/spec/ruby/library/stringio/initialize_spec.rb b/spec/ruby/library/stringio/initialize_spec.rb
index 8aae47dacb..8b661a3790 100644
--- a/spec/ruby/library/stringio/initialize_spec.rb
+++ b/spec/ruby/library/stringio/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
describe "StringIO#initialize when passed [Object, mode]" do
@@ -110,9 +110,9 @@ describe "StringIO#initialize when passed [Object, mode]" do
io.closed_write?.should be_false
end
- it "raises a #{frozen_error_class} when passed a frozen String in truncate mode as StringIO backend" do
+ it "raises a RuntimeError when passed a frozen String in truncate mode as StringIO backend" do
io = StringIO.allocate
- -> { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(frozen_error_class)
+ lambda { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(RuntimeError)
end
it "tries to convert the passed mode to a String using #to_str" do
@@ -126,9 +126,9 @@ describe "StringIO#initialize when passed [Object, mode]" do
it "raises an Errno::EACCES error when passed a frozen string with a write-mode" do
(str = "example").freeze
- -> { @io.send(:initialize, str, "r+") }.should raise_error(Errno::EACCES)
- -> { @io.send(:initialize, str, "w") }.should raise_error(Errno::EACCES)
- -> { @io.send(:initialize, str, "a") }.should raise_error(Errno::EACCES)
+ lambda { @io.send(:initialize, str, "r+") }.should raise_error(Errno::EACCES)
+ lambda { @io.send(:initialize, str, "w") }.should raise_error(Errno::EACCES)
+ lambda { @io.send(:initialize, str, "a") }.should raise_error(Errno::EACCES)
end
end
@@ -183,30 +183,3 @@ describe "StringIO#initialize when passed no arguments" do
@io.string.should == ""
end
end
-
-describe "StringIO#initialize sets the encoding to" do
- before :each do
- @external = Encoding.default_external
- @internal = Encoding.default_internal
- Encoding.default_external = Encoding::ISO_8859_2
- Encoding.default_internal = Encoding::ISO_8859_2
- end
-
- after :each do
- Encoding.default_external = @external
- Encoding.default_internal = @internal
- end
-
- it "Encoding.default_external when passed no arguments" do
- io = StringIO.new
- io.external_encoding.should == Encoding::ISO_8859_2
- io.string.encoding.should == Encoding::ISO_8859_2
- end
-
- it "the same as the encoding of the String when passed a String" do
- s = ''.force_encoding(Encoding::EUC_JP)
- io = StringIO.new(s)
- io.external_encoding.should == Encoding::EUC_JP
- io.string.encoding.should == Encoding::EUC_JP
- end
-end
diff --git a/spec/ruby/library/stringio/internal_encoding_spec.rb b/spec/ruby/library/stringio/internal_encoding_spec.rb
index 2035cf25a9..f8ecb35989 100644
--- a/spec/ruby/library/stringio/internal_encoding_spec.rb
+++ b/spec/ruby/library/stringio/internal_encoding_spec.rb
@@ -1,5 +1,5 @@
require 'stringio'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "StringIO#internal_encoding" do
it "returns nil" do
diff --git a/spec/ruby/library/stringio/isatty_spec.rb b/spec/ruby/library/stringio/isatty_spec.rb
index 1ef33978b5..c07dc2f6cc 100644
--- a/spec/ruby/library/stringio/isatty_spec.rb
+++ b/spec/ruby/library/stringio/isatty_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/isatty'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/isatty', __FILE__)
describe "StringIO#isatty" do
it_behaves_like :stringio_isatty, :isatty
diff --git a/spec/ruby/library/stringio/length_spec.rb b/spec/ruby/library/stringio/length_spec.rb
index d3070f50a7..ae8eb15502 100644
--- a/spec/ruby/library/stringio/length_spec.rb
+++ b/spec/ruby/library/stringio/length_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "StringIO#length" do
it_behaves_like :stringio_length, :length
diff --git a/spec/ruby/library/stringio/lineno_spec.rb b/spec/ruby/library/stringio/lineno_spec.rb
index c620a1a686..b7ef83c7e1 100644
--- a/spec/ruby/library/stringio/lineno_spec.rb
+++ b/spec/ruby/library/stringio/lineno_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
describe "StringIO#lineno" do
diff --git a/spec/ruby/library/stringio/lines_spec.rb b/spec/ruby/library/stringio/lines_spec.rb
index d9dd26c2e2..c3af802073 100644
--- a/spec/ruby/library/stringio/lines_spec.rb
+++ b/spec/ruby/library/stringio/lines_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/each'
+require File.expand_path('../shared/each', __FILE__)
describe "StringIO#lines when passed a separator" do
it_behaves_like :stringio_each_separator, :lines
@@ -14,6 +14,8 @@ describe "StringIO#lines when self is not readable" do
it_behaves_like :stringio_each_not_readable, :lines
end
-describe "StringIO#lines when passed chomp" do
- it_behaves_like :stringio_each_chomp, :lines
+ruby_version_is "2.4" do
+ describe "StringIO#lines when passed chomp" do
+ it_behaves_like :stringio_each_chomp, :lines
+ end
end
diff --git a/spec/ruby/library/stringio/open_spec.rb b/spec/ruby/library/stringio/open_spec.rb
index adb784c890..136ff5f972 100644
--- a/spec/ruby/library/stringio/open_spec.rb
+++ b/spec/ruby/library/stringio/open_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
describe "StringIO.open when passed [Object, mode]" do
@@ -134,8 +134,8 @@ describe "StringIO.open when passed [Object, mode]" do
io.closed_write?.should be_false
end
- it "raises a #{frozen_error_class} when passed a frozen String in truncate mode as StringIO backend" do
- -> { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed a frozen String in truncate mode as StringIO backend" do
+ lambda { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(RuntimeError)
end
it "tries to convert the passed mode to a String using #to_str" do
@@ -149,9 +149,9 @@ describe "StringIO.open when passed [Object, mode]" do
it "raises an Errno::EACCES error when passed a frozen string with a write-mode" do
(str = "example").freeze
- -> { StringIO.open(str, "r+") }.should raise_error(Errno::EACCES)
- -> { StringIO.open(str, "w") }.should raise_error(Errno::EACCES)
- -> { StringIO.open(str, "a") }.should raise_error(Errno::EACCES)
+ lambda { StringIO.open(str, "r+") }.should raise_error(Errno::EACCES)
+ lambda { StringIO.open(str, "w") }.should raise_error(Errno::EACCES)
+ lambda { StringIO.open(str, "a") }.should raise_error(Errno::EACCES)
end
end
@@ -205,3 +205,4 @@ describe "StringIO.open when passed no arguments" do
StringIO.open.string.should == ""
end
end
+
diff --git a/spec/ruby/library/stringio/path_spec.rb b/spec/ruby/library/stringio/path_spec.rb
index 1184ca523f..6165cf97c4 100644
--- a/spec/ruby/library/stringio/path_spec.rb
+++ b/spec/ruby/library/stringio/path_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#path" do
it "is not defined" do
- -> { StringIO.new("path").path }.should raise_error(NoMethodError)
+ lambda { StringIO.new("path").path }.should raise_error(NoMethodError)
end
end
diff --git a/spec/ruby/library/stringio/pid_spec.rb b/spec/ruby/library/stringio/pid_spec.rb
index 08f2d7ab1a..41e60880cc 100644
--- a/spec/ruby/library/stringio/pid_spec.rb
+++ b/spec/ruby/library/stringio/pid_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#pid" do
it "returns nil" do
diff --git a/spec/ruby/library/stringio/pos_spec.rb b/spec/ruby/library/stringio/pos_spec.rb
index 81be5f01a5..d5f3c3ab95 100644
--- a/spec/ruby/library/stringio/pos_spec.rb
+++ b/spec/ruby/library/stringio/pos_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/tell'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/tell', __FILE__)
describe "StringIO#pos" do
it_behaves_like :stringio_tell, :pos
@@ -17,7 +17,7 @@ describe "StringIO#pos=" do
end
it "raises an EINVAL if given a negative argument" do
- -> { @io.pos = -10 }.should raise_error(Errno::EINVAL)
+ lambda { @io.pos = -10 }.should raise_error(Errno::EINVAL)
end
it "updates the current byte offset after reaching EOF" do
diff --git a/spec/ruby/library/stringio/print_spec.rb b/spec/ruby/library/stringio/print_spec.rb
index d0f07d1e50..0f67aeb921 100644
--- a/spec/ruby/library/stringio/print_spec.rb
+++ b/spec/ruby/library/stringio/print_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#print" do
before :each do
@@ -91,10 +91,10 @@ end
describe "StringIO#print when self is not writable" do
it "raises an IOError" do
io = StringIO.new("test", "r")
- -> { io.print("test") }.should raise_error(IOError)
+ lambda { io.print("test") }.should raise_error(IOError)
io = StringIO.new("test")
io.close_write
- -> { io.print("test") }.should raise_error(IOError)
+ lambda { io.print("test") }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/printf_spec.rb b/spec/ruby/library/stringio/printf_spec.rb
index f88ca1eb20..a2094bf52d 100644
--- a/spec/ruby/library/stringio/printf_spec.rb
+++ b/spec/ruby/library/stringio/printf_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative '../../core/kernel/shared/sprintf'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../../../core/kernel/shared/sprintf', __FILE__)
describe "StringIO#printf" do
before :each do
@@ -31,7 +31,7 @@ describe "StringIO#printf" do
end
describe "formatting" do
- it_behaves_like :kernel_sprintf, -> format, *args {
+ it_behaves_like :kernel_sprintf, -> (format, *args) {
io = StringIO.new
io.printf(format, *args)
io.string
@@ -61,10 +61,11 @@ end
describe "StringIO#printf when self is not writable" do
it "raises an IOError" do
io = StringIO.new("test", "r")
- -> { io.printf("test") }.should raise_error(IOError)
+ lambda { io.printf("test") }.should raise_error(IOError)
io = StringIO.new("test")
io.close_write
- -> { io.printf("test") }.should raise_error(IOError)
+ lambda { io.printf("test") }.should raise_error(IOError)
end
end
+
diff --git a/spec/ruby/library/stringio/putc_spec.rb b/spec/ruby/library/stringio/putc_spec.rb
index 223b3523e5..783e5a405b 100644
--- a/spec/ruby/library/stringio/putc_spec.rb
+++ b/spec/ruby/library/stringio/putc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#putc when passed [String]" do
before :each do
@@ -64,7 +64,7 @@ describe "StringIO#putc when passed [Object]" do
end
it "raises a TypeError when the passed argument can't be coerced to Integer" do
- -> { @io.putc(Object.new) }.should raise_error(TypeError)
+ lambda { @io.putc(Object.new) }.should raise_error(TypeError)
end
end
@@ -79,10 +79,10 @@ end
describe "StringIO#putc when self is not writable" do
it "raises an IOError" do
io = StringIO.new("test", "r")
- -> { io.putc(?a) }.should raise_error(IOError)
+ lambda { io.putc(?a) }.should raise_error(IOError)
io = StringIO.new("test")
io.close_write
- -> { io.putc("t") }.should raise_error(IOError)
+ lambda { io.putc("t") }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/puts_spec.rb b/spec/ruby/library/stringio/puts_spec.rb
index 2d3db25c5f..93a676aa15 100644
--- a/spec/ruby/library/stringio/puts_spec.rb
+++ b/spec/ruby/library/stringio/puts_spec.rb
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#puts when passed an Array" do
before :each do
@@ -51,14 +51,6 @@ describe "StringIO#puts when passed an Array" do
@io.puts([obj])
@io.string.should == "to_s\n"
end
-
- it "returns general object info if :to_s does not return a string" do
- object = mock('hola')
- object.should_receive(:to_s).and_return(false)
-
- @io.puts(object).should == nil
- @io.string.should == object.inspect.split(" ")[0] + ">\n"
- end
end
describe "StringIO#puts when passed 1 or more objects" do
@@ -148,11 +140,11 @@ end
describe "StringIO#puts when self is not writable" do
it "raises an IOError" do
io = StringIO.new("test", "r")
- -> { io.puts }.should raise_error(IOError)
+ lambda { io.puts }.should raise_error(IOError)
io = StringIO.new("test")
io.close_write
- -> { io.puts }.should raise_error(IOError)
+ lambda { io.puts }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/read_nonblock_spec.rb b/spec/ruby/library/stringio/read_nonblock_spec.rb
index 2a8f926bd0..84aefe8de7 100644
--- a/spec/ruby/library/stringio/read_nonblock_spec.rb
+++ b/spec/ruby/library/stringio/read_nonblock_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
-require_relative 'shared/read'
-require_relative 'shared/sysread'
+require File.expand_path('../shared/read', __FILE__)
+require File.expand_path('../shared/sysread', __FILE__)
describe "StringIO#read_nonblock when passed length, buffer" do
it_behaves_like :stringio_read, :read_nonblock
@@ -18,25 +18,3 @@ end
describe "StringIO#read_nonblock when passed length" do
it_behaves_like :stringio_sysread_length, :read_nonblock
end
-
-describe "StringIO#read_nonblock" do
-
- it "accepts an exception option" do
- stringio = StringIO.new('foo')
- stringio.read_nonblock(3, exception: false).should == 'foo'
- end
-
- context "when exception option is set to false" do
- context "when the end is reached" do
- it "returns nil" do
- stringio = StringIO.new('')
- stringio << "hello"
- stringio.rewind
-
- stringio.read_nonblock(5).should == "hello"
- stringio.read_nonblock(5, exception: false).should be_nil
- end
- end
- end
-
-end
diff --git a/spec/ruby/library/stringio/read_spec.rb b/spec/ruby/library/stringio/read_spec.rb
index 52ab3dcf47..2b9c6e10b2 100644
--- a/spec/ruby/library/stringio/read_spec.rb
+++ b/spec/ruby/library/stringio/read_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
-require_relative 'shared/read'
+require File.expand_path('../shared/read', __FILE__)
describe "StringIO#read when passed length, buffer" do
it_behaves_like :stringio_read, :read
diff --git a/spec/ruby/library/stringio/readbyte_spec.rb b/spec/ruby/library/stringio/readbyte_spec.rb
index 41a0911293..0fbc49a4dd 100644
--- a/spec/ruby/library/stringio/readbyte_spec.rb
+++ b/spec/ruby/library/stringio/readbyte_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/readchar'
+require File.expand_path('../shared/readchar', __FILE__)
describe "StringIO#readbyte" do
it_behaves_like :stringio_readchar, :readbyte
@@ -8,10 +8,10 @@ describe "StringIO#readbyte" do
it "reads the next 8-bit byte from self's current position" do
io = StringIO.new("example")
- io.readbyte.should == 101
+ io.send(@method).should == 101
io.pos = 4
- io.readbyte.should == 112
+ io.send(@method).should == 112
end
end
diff --git a/spec/ruby/library/stringio/readchar_spec.rb b/spec/ruby/library/stringio/readchar_spec.rb
index 38944819a2..af673c871a 100644
--- a/spec/ruby/library/stringio/readchar_spec.rb
+++ b/spec/ruby/library/stringio/readchar_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
-require_relative 'shared/readchar'
+require File.expand_path('../shared/readchar', __FILE__)
describe "StringIO#readchar" do
it_behaves_like :stringio_readchar, :readchar
@@ -8,10 +8,10 @@ describe "StringIO#readchar" do
it "reads the next 8-bit byte from self's current position" do
io = StringIO.new("example")
- io.readchar.should == ?e
+ io.send(@method).should == ?e
io.pos = 4
- io.readchar.should == ?p
+ io.send(@method).should == ?p
end
end
diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb
index 9af633472e..1deb52c492 100644
--- a/spec/ruby/library/stringio/readline_spec.rb
+++ b/spec/ruby/library/stringio/readline_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#readline when passed [separator]" do
@@ -106,24 +106,26 @@ describe "StringIO#readline when passed no argument" do
it "raises an IOError if self is at the end" do
@io.pos = 40
- -> { @io.readline }.should raise_error(IOError)
+ lambda { @io.readline }.should raise_error(IOError)
end
end
describe "StringIO#readline when in write-only mode" do
it "raises an IOError" do
io = StringIO.new("xyz", "w")
- -> { io.readline }.should raise_error(IOError)
+ lambda { io.readline }.should raise_error(IOError)
io = StringIO.new("xyz")
io.close_read
- -> { io.readline }.should raise_error(IOError)
+ lambda { io.readline }.should raise_error(IOError)
end
end
-describe "StringIO#readline when passed [chomp]" do
- it "returns the data read without a trailing newline character" do
- io = StringIO.new("this>is>an>example\n")
- io.readline(chomp: true).should == "this>is>an>example"
+ruby_version_is "2.4" do
+ describe "StringIO#readline when passed [chomp]" do
+ it "returns the data read without a trailing newline character" do
+ io = StringIO.new("this>is>an>example\n")
+ io.readline(chomp: true).should == "this>is>an>example"
+ end
end
end
diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb
index 7f9f9f5846..11217d1e59 100644
--- a/spec/ruby/library/stringio/readlines_spec.rb
+++ b/spec/ruby/library/stringio/readlines_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#readlines when passed [separator]" do
before :each do
@@ -83,17 +83,19 @@ end
describe "StringIO#readlines when in write-only mode" do
it "raises an IOError" do
io = StringIO.new("xyz", "w")
- -> { io.readlines }.should raise_error(IOError)
+ lambda { io.readlines }.should raise_error(IOError)
io = StringIO.new("xyz")
io.close_read
- -> { io.readlines }.should raise_error(IOError)
+ lambda { io.readlines }.should raise_error(IOError)
end
end
-describe "StringIO#readlines when passed [chomp]" do
- it "returns the data read without a trailing newline character" do
- io = StringIO.new("this>is\nan>example\r\n")
- io.readlines(chomp: true).should == ["this>is", "an>example"]
+ruby_version_is "2.4" do
+ describe "StringIO#readlines when passed [chomp]" do
+ it "returns the data read without a trailing newline character" do
+ io = StringIO.new("this>is\nan>example\r\n")
+ io.readlines(chomp: true).should == ["this>is", "an>example"]
+ end
end
end
diff --git a/spec/ruby/library/stringio/readpartial_spec.rb b/spec/ruby/library/stringio/readpartial_spec.rb
index 2601fe8c42..e65e50fa41 100644
--- a/spec/ruby/library/stringio/readpartial_spec.rb
+++ b/spec/ruby/library/stringio/readpartial_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#readpartial" do
before :each do
@@ -12,7 +12,7 @@ describe "StringIO#readpartial" do
it "raises IOError on closed stream" do
@string.close
- -> { @string.readpartial(10) }.should raise_error(IOError)
+ lambda { @string.readpartial(10) }.should raise_error(IOError)
end
it "reads at most the specified number of bytes" do
@@ -55,23 +55,23 @@ describe "StringIO#readpartial" do
it "raises EOFError on EOF" do
@string.readpartial(18).should == 'Stop, look, listen'
- -> { @string.readpartial(10) }.should raise_error(EOFError)
+ lambda { @string.readpartial(10) }.should raise_error(EOFError)
end
it "discards the existing buffer content upon error" do
buffer = 'hello'
@string.readpartial(100)
- -> { @string.readpartial(1, buffer) }.should raise_error(EOFError)
+ lambda { @string.readpartial(1, buffer) }.should raise_error(EOFError)
buffer.should be_empty
end
it "raises IOError if the stream is closed" do
@string.close
- -> { @string.readpartial(1) }.should raise_error(IOError)
+ lambda { @string.readpartial(1) }.should raise_error(IOError)
end
it "raises ArgumentError if the negative argument is provided" do
- -> { @string.readpartial(-1) }.should raise_error(ArgumentError)
+ lambda { @string.readpartial(-1) }.should raise_error(ArgumentError)
end
it "immediately returns an empty string if the length argument is 0" do
diff --git a/spec/ruby/library/stringio/reopen_spec.rb b/spec/ruby/library/stringio/reopen_spec.rb
index 34e38a63b4..abdecdf9de 100644
--- a/spec/ruby/library/stringio/reopen_spec.rb
+++ b/spec/ruby/library/stringio/reopen_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#reopen when passed [Object, Integer]" do
before :each do
@@ -40,16 +40,16 @@ describe "StringIO#reopen when passed [Object, Integer]" do
end
it "raises a TypeError when the passed Object can't be converted to a String" do
- -> { @io.reopen(Object.new, IO::RDWR) }.should raise_error(TypeError)
+ lambda { @io.reopen(Object.new, IO::RDWR) }.should raise_error(TypeError)
end
it "raises an Errno::EACCES when trying to reopen self with a frozen String in write-mode" do
- -> { @io.reopen("burn".freeze, IO::WRONLY) }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should raise_error(Errno::EACCES)
+ lambda { @io.reopen("burn".freeze, IO::WRONLY) }.should raise_error(Errno::EACCES)
+ lambda { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should raise_error(Errno::EACCES)
end
- it "raises a #{frozen_error_class} when trying to reopen self with a frozen String in truncate-mode" do
- -> { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when trying to reopen self with a frozen String in truncate-mode" do
+ lambda { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(RuntimeError)
end
it "does not raise IOError when passed a frozen String in read-mode" do
@@ -107,7 +107,7 @@ describe "StringIO#reopen when passed [Object, Object]" do
end
it "raises a TypeError when the passed Object can't be converted to a String using #to_str" do
- -> { @io.reopen(Object.new, "r") }.should raise_error(TypeError)
+ lambda { @io.reopen(Object.new, "r") }.should raise_error(TypeError)
end
it "resets self's position to 0" do
@@ -132,10 +132,10 @@ describe "StringIO#reopen when passed [Object, Object]" do
end
it "raises an Errno::EACCES error when trying to reopen self with a frozen String in write-mode" do
- -> { @io.reopen("burn".freeze, 'w') }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, 'w+') }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, 'a') }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, "r+") }.should raise_error(Errno::EACCES)
+ lambda { @io.reopen("burn".freeze, 'w') }.should raise_error(Errno::EACCES)
+ lambda { @io.reopen("burn".freeze, 'w+') }.should raise_error(Errno::EACCES)
+ lambda { @io.reopen("burn".freeze, 'a') }.should raise_error(Errno::EACCES)
+ lambda { @io.reopen("burn".freeze, "r+") }.should raise_error(Errno::EACCES)
end
it "does not raise IOError if a frozen string is passed in read mode" do
@@ -185,13 +185,13 @@ describe "StringIO#reopen when passed [Object]" do
end
it "raises a TypeError when passed an Object that can't be converted to a StringIO" do
- -> { @io.reopen(Object.new) }.should raise_error(TypeError)
+ lambda { @io.reopen(Object.new) }.should raise_error(TypeError)
end
it "does not try to convert the passed Object to a String using #to_str" do
obj = mock("not to_str")
obj.should_not_receive(:to_str)
- -> { @io.reopen(obj) }.should raise_error(TypeError)
+ lambda { @io.reopen(obj) }.should raise_error(TypeError)
end
it "tries to convert the passed Object to a StringIO using #to_strio" do
@@ -202,11 +202,9 @@ describe "StringIO#reopen when passed [Object]" do
end
# NOTE: WEIRD!
- ruby_version_is ""..."2.7" do
- it "taints self when the passed Object was tainted" do
- @io.reopen(StringIO.new("reopened").taint)
- @io.tainted?.should be_true
- end
+ it "taints self when the passed Object was tainted" do
+ @io.reopen(StringIO.new("reopened").taint)
+ @io.tainted?.should be_true
end
end
@@ -272,13 +270,11 @@ describe "StringIO#reopen" do
str.should == ''
end
- ruby_version_is ""..."2.7" do
- it "taints self if the provided StringIO argument is tainted" do
- new_io = StringIO.new("tainted")
- new_io.taint
- @io.reopen(new_io)
- @io.tainted?.should == true
- end
+ it "taints self if the provided StringIO argument is tainted" do
+ new_io = StringIO.new("tainted")
+ new_io.taint
+ @io.reopen(new_io)
+ @io.tainted?.should == true
end
it "does not truncate the content even when the StringIO argument is in the truncate mode" do
diff --git a/spec/ruby/library/stringio/rewind_spec.rb b/spec/ruby/library/stringio/rewind_spec.rb
index 5f885ecf81..ef144a9f5f 100644
--- a/spec/ruby/library/stringio/rewind_spec.rb
+++ b/spec/ruby/library/stringio/rewind_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#rewind" do
before :each do
diff --git a/spec/ruby/library/stringio/seek_spec.rb b/spec/ruby/library/stringio/seek_spec.rb
index 253b5027a9..ec79122039 100644
--- a/spec/ruby/library/stringio/seek_spec.rb
+++ b/spec/ruby/library/stringio/seek_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#seek" do
before :each do
@@ -33,14 +33,14 @@ describe "StringIO#seek" do
end
it "raises an Errno::EINVAL error on negative amounts when whence is IO::SEEK_SET" do
- -> { @io.seek(-5, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
+ lambda { @io.seek(-5, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
end
it "raises an Errno::EINVAL error on incorrect whence argument" do
- -> { @io.seek(0, 3) }.should raise_error(Errno::EINVAL)
- -> { @io.seek(0, -1) }.should raise_error(Errno::EINVAL)
- -> { @io.seek(0, 2**16) }.should raise_error(Errno::EINVAL)
- -> { @io.seek(0, -2**16) }.should raise_error(Errno::EINVAL)
+ lambda { @io.seek(0, 3) }.should raise_error(Errno::EINVAL)
+ lambda { @io.seek(0, -1) }.should raise_error(Errno::EINVAL)
+ lambda { @io.seek(0, 2**16) }.should raise_error(Errno::EINVAL)
+ lambda { @io.seek(0, -2**16) }.should raise_error(Errno::EINVAL)
end
it "tries to convert the passed Object to a String using #to_int" do
@@ -51,7 +51,7 @@ describe "StringIO#seek" do
end
it "raises a TypeError when the passed Object can't be converted to an Integer" do
- -> { @io.seek(Object.new) }.should raise_error(TypeError)
+ lambda { @io.seek(Object.new) }.should raise_error(TypeError)
end
end
@@ -62,6 +62,6 @@ describe "StringIO#seek when self is closed" do
end
it "raises an IOError" do
- -> { @io.seek(5) }.should raise_error(IOError)
+ lambda { @io.seek(5) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/set_encoding_spec.rb b/spec/ruby/library/stringio/set_encoding_spec.rb
index 21d45750f3..c66c70ab04 100644
--- a/spec/ruby/library/stringio/set_encoding_spec.rb
+++ b/spec/ruby/library/stringio/set_encoding_spec.rb
@@ -1,20 +1,10 @@
require 'stringio'
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "StringIO#set_encoding" do
- it "sets the encoding of the underlying String if the String is not frozen" do
- str = "".encode(Encoding::US_ASCII)
-
- io = StringIO.new(str)
+ it "sets the encoding of the underlying String" do
+ io = StringIO.new
io.set_encoding Encoding::UTF_8
io.string.encoding.should == Encoding::UTF_8
end
-
- it "does not set the encoding of the underlying String if the String is frozen" do
- str = "".encode(Encoding::US_ASCII).freeze
-
- io = StringIO.new(str)
- io.set_encoding Encoding::UTF_8
- io.string.encoding.should == Encoding::US_ASCII
- end
end
diff --git a/spec/ruby/library/stringio/shared/codepoints.rb b/spec/ruby/library/stringio/shared/codepoints.rb
index 9d84aa4919..c8ca03329f 100644
--- a/spec/ruby/library/stringio/shared/codepoints.rb
+++ b/spec/ruby/library/stringio/shared/codepoints.rb
@@ -20,15 +20,15 @@ describe :stringio_codepoints, shared: true do
it "raises an error if reading invalid sequence" do
@io.pos = 1 # inside of a multibyte sequence
- -> { @enum.first }.should raise_error(ArgumentError)
+ lambda { @enum.first }.should raise_error(ArgumentError)
end
it "raises an IOError if not readable" do
@io.close_read
- -> { @enum.to_a }.should raise_error(IOError)
+ lambda { @enum.to_a }.should raise_error(IOError)
io = StringIO.new("xyz", "w")
- -> { io.send(@method).to_a }.should raise_error(IOError)
+ lambda { io.send(@method).to_a }.should raise_error(IOError)
end
diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb
index c08d40344c..55ed27c1c7 100644
--- a/spec/ruby/library/stringio/shared/each.rb
+++ b/spec/ruby/library/stringio/shared/each.rb
@@ -96,11 +96,11 @@ end
describe :stringio_each_not_readable, shared: true do
it "raises an IOError" do
io = StringIO.new("a b c d e", "w")
- -> { io.send(@method) { |b| b } }.should raise_error(IOError)
+ lambda { io.send(@method) { |b| b } }.should raise_error(IOError)
io = StringIO.new("a b c d e")
io.close_read
- -> { io.send(@method) { |b| b } }.should raise_error(IOError)
+ lambda { io.send(@method) { |b| b } }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/shared/each_byte.rb b/spec/ruby/library/stringio/shared/each_byte.rb
index 56734ff99d..1dc48ee437 100644
--- a/spec/ruby/library/stringio/shared/each_byte.rb
+++ b/spec/ruby/library/stringio/shared/each_byte.rb
@@ -39,10 +39,10 @@ end
describe :stringio_each_byte_not_readable, shared: true do
it "raises an IOError" do
io = StringIO.new("xyz", "w")
- -> { io.send(@method) { |b| b } }.should raise_error(IOError)
+ lambda { io.send(@method) { |b| b } }.should raise_error(IOError)
io = StringIO.new("xyz")
io.close_read
- -> { io.send(@method) { |b| b } }.should raise_error(IOError)
+ lambda { io.send(@method) { |b| b } }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/shared/each_char.rb b/spec/ruby/library/stringio/shared/each_char.rb
index bcdac53282..35efdcb749 100644
--- a/spec/ruby/library/stringio/shared/each_char.rb
+++ b/spec/ruby/library/stringio/shared/each_char.rb
@@ -27,10 +27,10 @@ end
describe :stringio_each_char_not_readable, shared: true do
it "raises an IOError" do
io = StringIO.new("xyz", "w")
- -> { io.send(@method) { |b| b } }.should raise_error(IOError)
+ lambda { io.send(@method) { |b| b } }.should raise_error(IOError)
io = StringIO.new("xyz")
io.close_read
- -> { io.send(@method) { |b| b } }.should raise_error(IOError)
+ lambda { io.send(@method) { |b| b } }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/shared/getc.rb b/spec/ruby/library/stringio/shared/getc.rb
index 6318bcc30f..3e064f9c1e 100644
--- a/spec/ruby/library/stringio/shared/getc.rb
+++ b/spec/ruby/library/stringio/shared/getc.rb
@@ -34,10 +34,10 @@ end
describe :stringio_getc_not_readable, shared: true do
it "raises an IOError" do
io = StringIO.new("xyz", "w")
- -> { io.send(@method) }.should raise_error(IOError)
+ lambda { io.send(@method) }.should raise_error(IOError)
io = StringIO.new("xyz")
io.close_read
- -> { io.send(@method) }.should raise_error(IOError)
+ lambda { io.send(@method) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/shared/read.rb b/spec/ruby/library/stringio/shared/read.rb
index 15ce58ae6a..025829a2b1 100644
--- a/spec/ruby/library/stringio/shared/read.rb
+++ b/spec/ruby/library/stringio/shared/read.rb
@@ -24,11 +24,11 @@ describe :stringio_read, shared: true do
end
it "raises a TypeError when the passed buffer Object can't be converted to a String" do
- -> { @io.send(@method, 7, Object.new) }.should raise_error(TypeError)
+ lambda { @io.send(@method, 7, Object.new) }.should raise_error(TypeError)
end
- it "raises a #{frozen_error_class} error when passed a frozen String as buffer" do
- -> { @io.send(@method, 7, "".freeze) }.should raise_error(frozen_error_class)
+ it "raises an error when passed a frozen String as buffer" do
+ lambda { @io.send(@method, 7, "".freeze) }.should raise_error(RuntimeError)
end
end
@@ -61,15 +61,15 @@ describe :stringio_read_length, shared: true do
end
it "raises a TypeError when the passed length can't be converted to an Integer" do
- -> { @io.send(@method, Object.new) }.should raise_error(TypeError)
+ lambda { @io.send(@method, Object.new) }.should raise_error(TypeError)
end
it "raises a TypeError when the passed length is negative" do
- -> { @io.send(@method, -2) }.should raise_error(ArgumentError)
+ lambda { @io.send(@method, -2) }.should raise_error(ArgumentError)
end
it "returns a binary String" do
- @io.send(@method, 4).encoding.should == Encoding::BINARY
+ @io.send(@method, 4).encoding.should == Encoding::ASCII_8BIT
end
end
@@ -112,10 +112,10 @@ end
describe :stringio_read_not_readable, shared: true do
it "raises an IOError" do
io = StringIO.new("test", "w")
- -> { io.send(@method) }.should raise_error(IOError)
+ lambda { io.send(@method) }.should raise_error(IOError)
io = StringIO.new("test")
io.close_read
- -> { io.send(@method) }.should raise_error(IOError)
+ lambda { io.send(@method) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/shared/readchar.rb b/spec/ruby/library/stringio/shared/readchar.rb
index 4248e75420..19194f0680 100644
--- a/spec/ruby/library/stringio/shared/readchar.rb
+++ b/spec/ruby/library/stringio/shared/readchar.rb
@@ -13,17 +13,17 @@ describe :stringio_readchar, shared: true do
it "raises an EOFError when self is at the end" do
@io.pos = 7
- -> { @io.send(@method) }.should raise_error(EOFError)
+ lambda { @io.send(@method) }.should raise_error(EOFError)
end
end
describe :stringio_readchar_not_readable, shared: true do
it "raises an IOError" do
io = StringIO.new("a b c d e", "w")
- -> { io.send(@method) }.should raise_error(IOError)
+ lambda { io.send(@method) }.should raise_error(IOError)
io = StringIO.new("a b c d e")
io.close_read
- -> { io.send(@method) }.should raise_error(IOError)
+ lambda { io.send(@method) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/shared/sysread.rb b/spec/ruby/library/stringio/shared/sysread.rb
index 3376bd9907..9800b2339b 100644
--- a/spec/ruby/library/stringio/shared/sysread.rb
+++ b/spec/ruby/library/stringio/shared/sysread.rb
@@ -10,6 +10,6 @@ describe :stringio_sysread_length, :shared => true do
it "raises an EOFError when passed length > 0 and no data remains" do
@io.read.should == "example"
- -> { @io.sysread(1) }.should raise_error(EOFError)
+ lambda { @io.sysread(1) }.should raise_error(EOFError)
end
end
diff --git a/spec/ruby/library/stringio/shared/write.rb b/spec/ruby/library/stringio/shared/write.rb
index 28683e3cb1..bcb548bbd0 100644
--- a/spec/ruby/library/stringio/shared/write.rb
+++ b/spec/ruby/library/stringio/shared/write.rb
@@ -45,11 +45,9 @@ describe :stringio_write_string, shared: true do
@io.pos.should eql(4)
end
- ruby_version_is ""..."2.7" do
- it "taints self's String when the passed argument is tainted" do
- @io.send(@method, "test".taint)
- @io.string.tainted?.should be_true
- end
+ it "taints self's String when the passed argument is tainted" do
+ @io.send(@method, "test".taint)
+ @io.string.tainted?.should be_true
end
it "does not taint self when the passed argument is tainted" do
@@ -61,11 +59,11 @@ end
describe :stringio_write_not_writable, shared: true do
it "raises an IOError" do
io = StringIO.new("test", "r")
- -> { io.send(@method, "test") }.should raise_error(IOError)
+ lambda { io.send(@method, "test") }.should raise_error(IOError)
io = StringIO.new("test")
io.close_write
- -> { io.send(@method, "test") }.should raise_error(IOError)
+ lambda { io.send(@method, "test") }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/size_spec.rb b/spec/ruby/library/stringio/size_spec.rb
index f674d22db9..1d6a7fc15e 100644
--- a/spec/ruby/library/stringio/size_spec.rb
+++ b/spec/ruby/library/stringio/size_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
describe "StringIO#size" do
it_behaves_like :stringio_length, :size
diff --git a/spec/ruby/library/stringio/string_spec.rb b/spec/ruby/library/stringio/string_spec.rb
index 1ed5233ba6..7c4181b6de 100644
--- a/spec/ruby/library/stringio/string_spec.rb
+++ b/spec/ruby/library/stringio/string_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#string" do
it "returns the underlying string" do
@@ -45,6 +45,6 @@ describe "StringIO#string=" do
end
it "raises a TypeError when the passed Object can't be converted to an Integer" do
- -> { @io.seek(Object.new) }.should raise_error(TypeError)
+ lambda { @io.seek(Object.new) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/stringio/stringio_spec.rb b/spec/ruby/library/stringio/stringio_spec.rb
index 5ef42b3390..9e2cb9cf90 100644
--- a/spec/ruby/library/stringio/stringio_spec.rb
+++ b/spec/ruby/library/stringio/stringio_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
describe "StringIO" do
@@ -6,3 +6,4 @@ describe "StringIO" do
StringIO.should include(Enumerable)
end
end
+
diff --git a/spec/ruby/library/stringio/sync_spec.rb b/spec/ruby/library/stringio/sync_spec.rb
index e717a5697b..b662d7b7cc 100644
--- a/spec/ruby/library/stringio/sync_spec.rb
+++ b/spec/ruby/library/stringio/sync_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#sync" do
it "returns true" do
diff --git a/spec/ruby/library/stringio/sysread_spec.rb b/spec/ruby/library/stringio/sysread_spec.rb
index 8f78073f42..cce8d8c88a 100644
--- a/spec/ruby/library/stringio/sysread_spec.rb
+++ b/spec/ruby/library/stringio/sysread_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
-require_relative 'shared/read'
+require File.expand_path('../shared/read', __FILE__)
describe "StringIO#sysread when passed length, buffer" do
it_behaves_like :stringio_read, :sysread
@@ -39,7 +39,7 @@ describe "StringIO#sysread when passed [length]" do
it "raises an EOFError when self's position is at the end" do
@io.pos = 7
- -> { @io.sysread(10) }.should raise_error(EOFError)
+ lambda { @io.sysread(10) }.should raise_error(EOFError)
end
it "returns an empty String when length is 0" do
diff --git a/spec/ruby/library/stringio/syswrite_spec.rb b/spec/ruby/library/stringio/syswrite_spec.rb
index c4891e669b..8b65e81a05 100644
--- a/spec/ruby/library/stringio/syswrite_spec.rb
+++ b/spec/ruby/library/stringio/syswrite_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/write'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/write', __FILE__)
describe "StringIO#syswrite when passed [Object]" do
it_behaves_like :stringio_write, :syswrite
diff --git a/spec/ruby/library/stringio/tell_spec.rb b/spec/ruby/library/stringio/tell_spec.rb
index 8350ee6f4d..af6a01497e 100644
--- a/spec/ruby/library/stringio/tell_spec.rb
+++ b/spec/ruby/library/stringio/tell_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/tell'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/tell', __FILE__)
describe "StringIO#tell" do
it_behaves_like :stringio_tell, :tell
diff --git a/spec/ruby/library/stringio/truncate_spec.rb b/spec/ruby/library/stringio/truncate_spec.rb
index ba910ee98c..1023b3d13c 100644
--- a/spec/ruby/library/stringio/truncate_spec.rb
+++ b/spec/ruby/library/stringio/truncate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
describe "StringIO#truncate when passed [length]" do
@@ -35,8 +35,8 @@ describe "StringIO#truncate when passed [length]" do
end
it "raises an Errno::EINVAL when the passed length is negative" do
- -> { @io.truncate(-1) }.should raise_error(Errno::EINVAL)
- -> { @io.truncate(-10) }.should raise_error(Errno::EINVAL)
+ lambda { @io.truncate(-1) }.should raise_error(Errno::EINVAL)
+ lambda { @io.truncate(-10) }.should raise_error(Errno::EINVAL)
end
it "tries to convert the passed length to an Integer using #to_int" do
@@ -54,17 +54,17 @@ describe "StringIO#truncate when passed [length]" do
end
it "raises a TypeError when the passed length can't be converted to an Integer" do
- -> { @io.truncate(Object.new) }.should raise_error(TypeError)
+ lambda { @io.truncate(Object.new) }.should raise_error(TypeError)
end
end
describe "StringIO#truncate when self is not writable" do
it "raises an IOError" do
io = StringIO.new("test", "r")
- -> { io.truncate(2) }.should raise_error(IOError)
+ lambda { io.truncate(2) }.should raise_error(IOError)
io = StringIO.new("test")
io.close_write
- -> { io.truncate(2) }.should raise_error(IOError)
+ lambda { io.truncate(2) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/tty_spec.rb b/spec/ruby/library/stringio/tty_spec.rb
index c6293dcbd7..7540e68a2b 100644
--- a/spec/ruby/library/stringio/tty_spec.rb
+++ b/spec/ruby/library/stringio/tty_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/isatty'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/isatty', __FILE__)
describe "StringIO#tty?" do
it_behaves_like :stringio_isatty, :tty?
diff --git a/spec/ruby/library/stringio/ungetbyte_spec.rb b/spec/ruby/library/stringio/ungetbyte_spec.rb
index 701463e621..a7d9b28024 100644
--- a/spec/ruby/library/stringio/ungetbyte_spec.rb
+++ b/spec/ruby/library/stringio/ungetbyte_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
describe "StringIO#ungetbyte" do
diff --git a/spec/ruby/library/stringio/ungetc_spec.rb b/spec/ruby/library/stringio/ungetc_spec.rb
index 91ef2100a1..613d49cfbd 100644
--- a/spec/ruby/library/stringio/ungetc_spec.rb
+++ b/spec/ruby/library/stringio/ungetc_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "StringIO#ungetc when passed [char]" do
before :each do
@@ -39,7 +39,7 @@ describe "StringIO#ungetc when passed [char]" do
end
it "raises a TypeError when the passed length can't be converted to an Integer or String" do
- -> { @io.ungetc(Object.new) }.should raise_error(TypeError)
+ lambda { @io.ungetc(Object.new) }.should raise_error(TypeError)
end
end
@@ -47,12 +47,12 @@ describe "StringIO#ungetc when self is not readable" do
it "raises an IOError" do
io = StringIO.new("test", "w")
io.pos = 1
- -> { io.ungetc(?A) }.should raise_error(IOError)
+ lambda { io.ungetc(?A) }.should raise_error(IOError)
io = StringIO.new("test")
io.pos = 1
io.close_read
- -> { io.ungetc(?A) }.should raise_error(IOError)
+ lambda { io.ungetc(?A) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/stringio/write_nonblock_spec.rb b/spec/ruby/library/stringio/write_nonblock_spec.rb
index 4f4c5039fe..d4d5ab5a85 100644
--- a/spec/ruby/library/stringio/write_nonblock_spec.rb
+++ b/spec/ruby/library/stringio/write_nonblock_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/write'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/write', __FILE__)
describe "StringIO#write_nonblock when passed [Object]" do
it_behaves_like :stringio_write, :write_nonblock
diff --git a/spec/ruby/library/stringio/write_spec.rb b/spec/ruby/library/stringio/write_spec.rb
index 3f755c32b4..706234da7e 100644
--- a/spec/ruby/library/stringio/write_spec.rb
+++ b/spec/ruby/library/stringio/write_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/write'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/write', __FILE__)
describe "StringIO#write when passed [Object]" do
it_behaves_like :stringio_write, :write
diff --git a/spec/ruby/library/stringscanner/append_spec.rb b/spec/ruby/library/stringscanner/append_spec.rb
index 378c62e2b1..f75b3cc715 100644
--- a/spec/ruby/library/stringscanner/append_spec.rb
+++ b/spec/ruby/library/stringscanner/append_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/concat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/concat.rb', __FILE__)
require 'strscan'
describe "StringScanner#<<" do
diff --git a/spec/ruby/library/stringscanner/beginning_of_line_spec.rb b/spec/ruby/library/stringscanner/beginning_of_line_spec.rb
index 3f6f0da75f..192a83f2c9 100644
--- a/spec/ruby/library/stringscanner/beginning_of_line_spec.rb
+++ b/spec/ruby/library/stringscanner/beginning_of_line_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/bol'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/bol.rb', __FILE__)
require 'strscan'
describe "StringScanner#beginning_of_line?" do
- it_behaves_like :strscan_bol, :beginning_of_line?
+ it_behaves_like(:strscan_bol, :beginning_of_line?)
end
diff --git a/spec/ruby/library/stringscanner/bol_spec.rb b/spec/ruby/library/stringscanner/bol_spec.rb
index d31766e0e2..ee5257529a 100644
--- a/spec/ruby/library/stringscanner/bol_spec.rb
+++ b/spec/ruby/library/stringscanner/bol_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/bol'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/bol.rb', __FILE__)
require 'strscan'
describe "StringScanner#bol?" do
- it_behaves_like :strscan_bol, :bol?
+ it_behaves_like(:strscan_bol, :bol?)
end
diff --git a/spec/ruby/library/stringscanner/check_spec.rb b/spec/ruby/library/stringscanner/check_spec.rb
index c7f788f0b3..db98197f81 100644
--- a/spec/ruby/library/stringscanner/check_spec.rb
+++ b/spec/ruby/library/stringscanner/check_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#check" do
diff --git a/spec/ruby/library/stringscanner/check_until_spec.rb b/spec/ruby/library/stringscanner/check_until_spec.rb
index e92ae5a2e9..e397b2e4c1 100644
--- a/spec/ruby/library/stringscanner/check_until_spec.rb
+++ b/spec/ruby/library/stringscanner/check_until_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#check_until" do
diff --git a/spec/ruby/library/stringscanner/clear_spec.rb b/spec/ruby/library/stringscanner/clear_spec.rb
index 7ae089704a..81b2e68897 100644
--- a/spec/ruby/library/stringscanner/clear_spec.rb
+++ b/spec/ruby/library/stringscanner/clear_spec.rb
@@ -1,18 +1,20 @@
-require_relative '../../spec_helper'
-require_relative 'shared/terminate'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/terminate.rb', __FILE__)
require 'strscan'
describe "StringScanner#clear" do
- it_behaves_like :strscan_terminate, :clear
+ it_behaves_like(:strscan_terminate, :clear)
it "warns in verbose mode that the method is obsolete" do
s = StringScanner.new("abc")
- -> {
+ lambda {
+ $VERBOSE = true
s.clear
- }.should complain(/clear.*obsolete.*terminate/, verbose: true)
+ }.should complain(/clear.*obsolete.*terminate/)
- -> {
+ lambda {
+ $VERBOSE = false
s.clear
- }.should_not complain(verbose: false)
+ }.should_not complain
end
end
diff --git a/spec/ruby/library/stringscanner/concat_spec.rb b/spec/ruby/library/stringscanner/concat_spec.rb
index 17a699dd2e..dccc7d0efd 100644
--- a/spec/ruby/library/stringscanner/concat_spec.rb
+++ b/spec/ruby/library/stringscanner/concat_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/concat'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/concat.rb', __FILE__)
require 'strscan'
describe "StringScanner#concat" do
- it_behaves_like :strscan_concat, :concat
+ it_behaves_like(:strscan_concat, :concat)
end
describe "StringScanner#concat when passed a Fixnum" do
- it_behaves_like :strscan_concat_fixnum, :concat
+ it_behaves_like(:strscan_concat_fixnum, :concat)
end
diff --git a/spec/ruby/library/stringscanner/dup_spec.rb b/spec/ruby/library/stringscanner/dup_spec.rb
index 0fc52a1477..2f0feff071 100644
--- a/spec/ruby/library/stringscanner/dup_spec.rb
+++ b/spec/ruby/library/stringscanner/dup_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#dup" do
@@ -12,7 +12,7 @@ describe "StringScanner#dup" do
s.string.should == @string
end
- it "copies the passed StringScanner's position to self" do
+ it "copies the passed StringSCanner's position to self" do
@orig_s.pos = 5
s = @orig_s.dup
s.pos.should eql(5)
diff --git a/spec/ruby/library/stringscanner/element_reference_spec.rb b/spec/ruby/library/stringscanner/element_reference_spec.rb
index 60fe15d807..c9acb1c7e7 100644
--- a/spec/ruby/library/stringscanner/element_reference_spec.rb
+++ b/spec/ruby/library/stringscanner/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#[]" do
@@ -34,18 +34,18 @@ describe "StringScanner#[]" do
it "raises a TypeError if the given index is nil" do
@s.scan(/(\w+) (\w+) (\d+) /)
- -> { @s[nil]}.should raise_error(TypeError)
+ lambda { @s[nil]}.should raise_error(TypeError)
end
it "raises a TypeError when a Range is as argument" do
@s.scan(/(\w+) (\w+) (\d+) /)
- -> { @s[0..2]}.should raise_error(TypeError)
+ lambda { @s[0..2]}.should raise_error(TypeError)
end
it "raises a IndexError when there's no named capture" do
@s.scan(/(\w+) (\w+) (\d+) /)
- -> { @s["wday"]}.should raise_error(IndexError)
- -> { @s[:wday]}.should raise_error(IndexError)
+ lambda { @s["wday"]}.should raise_error(IndexError)
+ lambda { @s[:wday]}.should raise_error(IndexError)
end
it "returns named capture" do
@@ -58,3 +58,4 @@ describe "StringScanner#[]" do
@s[:day].should == "13"
end
end
+
diff --git a/spec/ruby/library/stringscanner/empty_spec.rb b/spec/ruby/library/stringscanner/empty_spec.rb
index d9449bea6e..ebbc2c2703 100644
--- a/spec/ruby/library/stringscanner/empty_spec.rb
+++ b/spec/ruby/library/stringscanner/empty_spec.rb
@@ -1,18 +1,20 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eos.rb', __FILE__)
require 'strscan'
describe "StringScanner#empty?" do
- it_behaves_like :strscan_eos, :empty?
+ it_behaves_like(:strscan_eos, :empty?)
it "warns in verbose mode that the method is obsolete" do
s = StringScanner.new("abc")
- -> {
+ lambda {
+ $VERBOSE = true
s.empty?
- }.should complain(/empty?.*obsolete.*eos?/, verbose: true)
+ }.should complain(/empty?.*obsolete.*eos?/)
- -> {
+ lambda {
+ $VERBOSE = false
s.empty?
- }.should_not complain(verbose: false)
+ }.should_not complain
end
end
diff --git a/spec/ruby/library/stringscanner/eos_spec.rb b/spec/ruby/library/stringscanner/eos_spec.rb
index b58ee1e473..3fdeceb25d 100644
--- a/spec/ruby/library/stringscanner/eos_spec.rb
+++ b/spec/ruby/library/stringscanner/eos_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/eos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/eos.rb', __FILE__)
require 'strscan'
describe "StringScanner#eos?" do
- it_behaves_like :strscan_eos, :eos?
+ it_behaves_like(:strscan_eos, :eos?)
end
diff --git a/spec/ruby/library/stringscanner/exist_spec.rb b/spec/ruby/library/stringscanner/exist_spec.rb
index beafadc07b..ff13de89df 100644
--- a/spec/ruby/library/stringscanner/exist_spec.rb
+++ b/spec/ruby/library/stringscanner/exist_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#exist?" do
diff --git a/spec/ruby/library/stringscanner/get_byte_spec.rb b/spec/ruby/library/stringscanner/get_byte_spec.rb
index 29e2f557de..786b068042 100644
--- a/spec/ruby/library/stringscanner/get_byte_spec.rb
+++ b/spec/ruby/library/stringscanner/get_byte_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/get_byte'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/get_byte', __FILE__)
require 'strscan'
describe "StringScanner#get_byte" do
diff --git a/spec/ruby/library/stringscanner/getbyte_spec.rb b/spec/ruby/library/stringscanner/getbyte_spec.rb
index e0659a5829..6d3b8c357d 100644
--- a/spec/ruby/library/stringscanner/getbyte_spec.rb
+++ b/spec/ruby/library/stringscanner/getbyte_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'shared/get_byte'
-require_relative 'shared/extract_range'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/get_byte', __FILE__)
+require File.expand_path('../shared/extract_range', __FILE__)
require 'strscan'
describe "StringScanner#getbyte" do
@@ -8,13 +8,15 @@ describe "StringScanner#getbyte" do
it "warns in verbose mode that the method is obsolete" do
s = StringScanner.new("abc")
- -> {
+ lambda {
+ $VERBOSE = true
s.getbyte
- }.should complain(/getbyte.*obsolete.*get_byte/, verbose: true)
+ }.should complain(/getbyte.*obsolete.*get_byte/)
- -> {
+ lambda {
+ $VERBOSE = false
s.getbyte
- }.should_not complain(verbose: false)
+ }.should_not complain
end
it_behaves_like :extract_range, :getbyte
diff --git a/spec/ruby/library/stringscanner/getch_spec.rb b/spec/ruby/library/stringscanner/getch_spec.rb
index a6be0d4221..ae2907d817 100644
--- a/spec/ruby/library/stringscanner/getch_spec.rb
+++ b/spec/ruby/library/stringscanner/getch_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
-require_relative '../../spec_helper'
-require_relative 'shared/extract_range'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range', __FILE__)
require 'strscan'
describe "StringScanner#getch" do
diff --git a/spec/ruby/library/stringscanner/initialize_spec.rb b/spec/ruby/library/stringscanner/initialize_spec.rb
index 047d9d058b..ab0ea23408 100644
--- a/spec/ruby/library/stringscanner/initialize_spec.rb
+++ b/spec/ruby/library/stringscanner/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#initialize" do
@@ -12,6 +12,7 @@ describe "StringScanner#initialize" do
it "returns an instance of StringScanner" do
@s.should be_kind_of(StringScanner)
+ @s.tainted?.should be_false
@s.eos?.should be_false
end
diff --git a/spec/ruby/library/stringscanner/inspect_spec.rb b/spec/ruby/library/stringscanner/inspect_spec.rb
index ff6b97eb91..2f22a29a2e 100644
--- a/spec/ruby/library/stringscanner/inspect_spec.rb
+++ b/spec/ruby/library/stringscanner/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#inspect" do
diff --git a/spec/ruby/library/stringscanner/match_spec.rb b/spec/ruby/library/stringscanner/match_spec.rb
index ec59680914..227be6c3a5 100644
--- a/spec/ruby/library/stringscanner/match_spec.rb
+++ b/spec/ruby/library/stringscanner/match_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#match?" do
diff --git a/spec/ruby/library/stringscanner/matched_size_spec.rb b/spec/ruby/library/stringscanner/matched_size_spec.rb
index a36bd3aafe..7aac71878a 100644
--- a/spec/ruby/library/stringscanner/matched_size_spec.rb
+++ b/spec/ruby/library/stringscanner/matched_size_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/matched_size'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/matched_size.rb', __FILE__)
require 'strscan'
describe "StringScanner#matched_size" do
- it_behaves_like :strscan_matched_size, :matched_size
+ it_behaves_like(:strscan_matched_size, :matched_size)
end
diff --git a/spec/ruby/library/stringscanner/matched_spec.rb b/spec/ruby/library/stringscanner/matched_spec.rb
index c020bd3eae..1d781bd3ef 100644
--- a/spec/ruby/library/stringscanner/matched_spec.rb
+++ b/spec/ruby/library/stringscanner/matched_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/extract_range_matched'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
require 'strscan'
describe "StringScanner#matched" do
diff --git a/spec/ruby/library/stringscanner/must_C_version_spec.rb b/spec/ruby/library/stringscanner/must_C_version_spec.rb
index fcc5b596f6..c7d24ed2f8 100644
--- a/spec/ruby/library/stringscanner/must_C_version_spec.rb
+++ b/spec/ruby/library/stringscanner/must_C_version_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner.must_C_version" do
diff --git a/spec/ruby/library/stringscanner/peek_spec.rb b/spec/ruby/library/stringscanner/peek_spec.rb
index cbb5630ff9..49490ec3da 100644
--- a/spec/ruby/library/stringscanner/peek_spec.rb
+++ b/spec/ruby/library/stringscanner/peek_spec.rb
@@ -1,7 +1,8 @@
-require_relative '../../spec_helper'
-require_relative 'shared/peek'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/peek.rb', __FILE__)
require 'strscan'
describe "StringScanner#peek" do
- it_behaves_like :strscan_peek, :peek
+ it_behaves_like(:strscan_peek, :peek)
end
+
diff --git a/spec/ruby/library/stringscanner/peep_spec.rb b/spec/ruby/library/stringscanner/peep_spec.rb
index bf6d579325..677c6f8a21 100644
--- a/spec/ruby/library/stringscanner/peep_spec.rb
+++ b/spec/ruby/library/stringscanner/peep_spec.rb
@@ -1,18 +1,20 @@
-require_relative '../../spec_helper'
-require_relative 'shared/peek'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/peek.rb', __FILE__)
require 'strscan'
describe "StringScanner#peep" do
- it_behaves_like :strscan_peek, :peep
+ it_behaves_like(:strscan_peek, :peep)
it "warns in verbose mode that the method is obsolete" do
s = StringScanner.new("abc")
- -> {
+ lambda {
+ $VERBOSE = true
s.peep(1)
- }.should complain(/peep.*obsolete.*peek/, verbose: true)
+ }.should complain(/peep.*obsolete.*peek/)
- -> {
+ lambda {
+ $VERBOSE = false
s.peep(1)
- }.should_not complain(verbose: false)
+ }.should_not complain
end
end
diff --git a/spec/ruby/library/stringscanner/pointer_spec.rb b/spec/ruby/library/stringscanner/pointer_spec.rb
index bc0c0c50b7..8c993c5a71 100644
--- a/spec/ruby/library/stringscanner/pointer_spec.rb
+++ b/spec/ruby/library/stringscanner/pointer_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/pos.rb', __FILE__)
require 'strscan'
describe "StringScanner#pointer" do
- it_behaves_like :strscan_pos, :pointer
+ it_behaves_like(:strscan_pos, :pointer)
end
describe "StringScanner#pointer=" do
- it_behaves_like :strscan_pos_set, :pointer=
+ it_behaves_like(:strscan_pos_set, :pointer=)
end
diff --git a/spec/ruby/library/stringscanner/pos_spec.rb b/spec/ruby/library/stringscanner/pos_spec.rb
index 275fecf0f3..059e6ff846 100644
--- a/spec/ruby/library/stringscanner/pos_spec.rb
+++ b/spec/ruby/library/stringscanner/pos_spec.rb
@@ -1,11 +1,11 @@
-require_relative '../../spec_helper'
-require_relative 'shared/pos'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/pos.rb', __FILE__)
require 'strscan'
describe "StringScanner#pos" do
- it_behaves_like :strscan_pos, :pos
+ it_behaves_like(:strscan_pos, :pos)
end
describe "StringScanner#pos=" do
- it_behaves_like :strscan_pos_set, :pos=
+ it_behaves_like(:strscan_pos_set, :pos=)
end
diff --git a/spec/ruby/library/stringscanner/post_match_spec.rb b/spec/ruby/library/stringscanner/post_match_spec.rb
index 720dc3530d..94064bb368 100644
--- a/spec/ruby/library/stringscanner/post_match_spec.rb
+++ b/spec/ruby/library/stringscanner/post_match_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/extract_range_matched'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
require 'strscan'
describe "StringScanner#post_match" do
diff --git a/spec/ruby/library/stringscanner/pre_match_spec.rb b/spec/ruby/library/stringscanner/pre_match_spec.rb
index 1c2c511d5c..0d4759dc5c 100644
--- a/spec/ruby/library/stringscanner/pre_match_spec.rb
+++ b/spec/ruby/library/stringscanner/pre_match_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/extract_range_matched'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
require 'strscan'
describe "StringScanner#pre_match" do
diff --git a/spec/ruby/library/stringscanner/reset_spec.rb b/spec/ruby/library/stringscanner/reset_spec.rb
index a10ca2d838..9631d0bb4a 100644
--- a/spec/ruby/library/stringscanner/reset_spec.rb
+++ b/spec/ruby/library/stringscanner/reset_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#reset" do
diff --git a/spec/ruby/library/stringscanner/rest_size_spec.rb b/spec/ruby/library/stringscanner/rest_size_spec.rb
index e62e3a8f8c..ad019f2a6b 100644
--- a/spec/ruby/library/stringscanner/rest_size_spec.rb
+++ b/spec/ruby/library/stringscanner/rest_size_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rest_size'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rest_size.rb', __FILE__)
require 'strscan'
describe "StringScanner#rest_size" do
- it_behaves_like :strscan_rest_size, :rest_size
+ it_behaves_like(:strscan_rest_size, :rest_size)
end
diff --git a/spec/ruby/library/stringscanner/rest_spec.rb b/spec/ruby/library/stringscanner/rest_spec.rb
index 67072f880d..87f2d056bb 100644
--- a/spec/ruby/library/stringscanner/rest_spec.rb
+++ b/spec/ruby/library/stringscanner/rest_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/extract_range_matched'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
require 'strscan'
describe "StringScanner#rest" do
diff --git a/spec/ruby/library/stringscanner/restsize_spec.rb b/spec/ruby/library/stringscanner/restsize_spec.rb
index 710520afae..9822d69d84 100644
--- a/spec/ruby/library/stringscanner/restsize_spec.rb
+++ b/spec/ruby/library/stringscanner/restsize_spec.rb
@@ -1,18 +1,20 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rest_size'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rest_size.rb', __FILE__)
require 'strscan'
describe "StringScanner#restsize" do
- it_behaves_like :strscan_rest_size, :restsize
+ it_behaves_like(:strscan_rest_size, :restsize)
it "warns in verbose mode that the method is obsolete" do
s = StringScanner.new("abc")
- -> {
+ lambda {
+ $VERBOSE = true
s.restsize
- }.should complain(/restsize.*obsolete.*rest_size/, verbose: true)
+ }.should complain(/restsize.*obsolete.*rest_size/)
- -> {
+ lambda {
+ $VERBOSE = false
s.restsize
- }.should_not complain(verbose: false)
+ }.should_not complain
end
end
diff --git a/spec/ruby/library/stringscanner/scan_full_spec.rb b/spec/ruby/library/stringscanner/scan_full_spec.rb
index ed34d7d3f6..ada9578558 100644
--- a/spec/ruby/library/stringscanner/scan_full_spec.rb
+++ b/spec/ruby/library/stringscanner/scan_full_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#scan_full" do
diff --git a/spec/ruby/library/stringscanner/scan_spec.rb b/spec/ruby/library/stringscanner/scan_spec.rb
index 2269abd6b3..84a0f27f08 100644
--- a/spec/ruby/library/stringscanner/scan_spec.rb
+++ b/spec/ruby/library/stringscanner/scan_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#scan" do
@@ -19,22 +19,6 @@ describe "StringScanner#scan" do
@s.scan(/^\s/).should == " "
end
- it "treats ^ as matching from the beginning of the current position when it's not the first character in the regexp" do
- @s.scan(/\w+/).should == "This"
- @s.scan(/( is not|^ is a)/).should == " is a"
- end
-
- it "treats \\A as matching from the beginning of the current position" do
- @s.scan(/\w+/).should == "This"
- @s.scan(/\A\d/).should be_nil
- @s.scan(/\A\s/).should == " "
- end
-
- it "treats \\A as matching from the beginning of the current position when it's not the first character in the regexp" do
- @s.scan(/\w+/).should == "This"
- @s.scan(/( is not|\A is a)/).should == " is a"
- end
-
it "returns nil if there's no match" do
@s.scan(/\d/).should == nil
end
@@ -50,48 +34,10 @@ describe "StringScanner#scan" do
@s.scan(/./).should be_nil
end
- ruby_version_is ""..."2.7" do
- it "raises a TypeError if pattern is a String" do
- -> { @s.scan("aoeu") }.should raise_error(TypeError)
- end
- end
-
- ruby_version_is "2.7" do
- it "treats String as the pattern itself" do
- @s.scan("this").should be_nil
- @s.scan("This").should == "This"
- end
- end
-
- it "raises a TypeError if pattern isn't a Regexp nor String" do
- -> { @s.scan(5) }.should raise_error(TypeError)
- -> { @s.scan(:test) }.should raise_error(TypeError)
- -> { @s.scan(mock('x')) }.should raise_error(TypeError)
- end
-end
-
-describe "StringScanner#scan with fixed_anchor: true" do
- before :each do
- @s = StringScanner.new("This\nis\na\ntest", fixed_anchor: true)
- end
-
- ruby_version_is "2.7" do
- it "returns the matched string" do
- @s.scan(/\w+/).should == "This"
- @s.scan(/.../m).should == "\nis"
- @s.scan(//).should == ""
- @s.scan(/\s+/).should == "\n"
- end
-
- it "treats ^ as matching from the beginning of line" do
- @s.scan(/\w+\n/).should == "This\n"
- @s.scan(/^\w/).should == "i"
- @s.scan(/^\w/).should be_nil
- end
-
- it "treats \\A as matching from the beginning of string" do
- @s.scan(/\A\w/).should == "T"
- @s.scan(/\A\w/).should be_nil
- end
+ it "raises a TypeError if pattern isn't a Regexp" do
+ lambda { @s.scan("aoeu") }.should raise_error(TypeError)
+ lambda { @s.scan(5) }.should raise_error(TypeError)
+ lambda { @s.scan(:test) }.should raise_error(TypeError)
+ lambda { @s.scan(mock('x')) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/stringscanner/scan_until_spec.rb b/spec/ruby/library/stringscanner/scan_until_spec.rb
index 94239db50e..702283ed22 100644
--- a/spec/ruby/library/stringscanner/scan_until_spec.rb
+++ b/spec/ruby/library/stringscanner/scan_until_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#scan_until" do
diff --git a/spec/ruby/library/stringscanner/search_full_spec.rb b/spec/ruby/library/stringscanner/search_full_spec.rb
index da9067e012..43ff840003 100644
--- a/spec/ruby/library/stringscanner/search_full_spec.rb
+++ b/spec/ruby/library/stringscanner/search_full_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#search_full" do
diff --git a/spec/ruby/library/stringscanner/shared/concat.rb b/spec/ruby/library/stringscanner/shared/concat.rb
index cb884a5c01..28788d3ff1 100644
--- a/spec/ruby/library/stringscanner/shared/concat.rb
+++ b/spec/ruby/library/stringscanner/shared/concat.rb
@@ -7,24 +7,24 @@ describe :strscan_concat, shared: true do
end
it "raises a TypeError if the given argument can't be converted to a String" do
- -> { StringScanner.new('hello').send(@method, :world) }.should raise_error(TypeError)
- -> { StringScanner.new('hello').send(@method, mock('x')) }.should raise_error(TypeError)
+ lambda { StringScanner.new('hello').send(@method, :world) }.should raise_error(TypeError)
+ lambda { StringScanner.new('hello').send(@method, mock('x')) }.should raise_error(TypeError)
end
end
describe :strscan_concat_fixnum, shared: true do
it "raises a TypeError" do
a = StringScanner.new("hello world")
- -> { a.send(@method, 333) }.should raise_error(TypeError)
+ lambda { a.send(@method, 333) }.should raise_error(TypeError)
b = StringScanner.new("")
- -> { b.send(@method, (256 * 3 + 64)) }.should raise_error(TypeError)
- -> { b.send(@method, -200) }.should raise_error(TypeError)
+ lambda { b.send(@method, (256 * 3 + 64)) }.should raise_error(TypeError)
+ lambda { b.send(@method, -200) }.should raise_error(TypeError)
end
it "doesn't call to_int on the argument" do
x = mock('x')
x.should_not_receive(:to_int)
- -> { StringScanner.new("").send(@method, x) }.should raise_error(TypeError)
+ lambda { "".send(@method, x) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/stringscanner/shared/extract_range.rb b/spec/ruby/library/stringscanner/shared/extract_range.rb
index 1c14f716c9..7e98540b1a 100644
--- a/spec/ruby/library/stringscanner/shared/extract_range.rb
+++ b/spec/ruby/library/stringscanner/shared/extract_range.rb
@@ -9,16 +9,14 @@ describe :extract_range, shared: true do
ch.should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "taints the returned String if the input was tainted" do
- str = 'abc'
- str.taint
+ it "taints the returned String if the input was tainted" do
+ str = 'abc'
+ str.taint
- s = StringScanner.new(str)
+ s = StringScanner.new(str)
- s.send(@method).tainted?.should be_true
- s.send(@method).tainted?.should be_true
- s.send(@method).tainted?.should be_true
- end
+ s.send(@method).tainted?.should be_true
+ s.send(@method).tainted?.should be_true
+ s.send(@method).tainted?.should be_true
end
end
diff --git a/spec/ruby/library/stringscanner/shared/extract_range_matched.rb b/spec/ruby/library/stringscanner/shared/extract_range_matched.rb
index 5c536f5c01..fe695e8ac1 100644
--- a/spec/ruby/library/stringscanner/shared/extract_range_matched.rb
+++ b/spec/ruby/library/stringscanner/shared/extract_range_matched.rb
@@ -11,14 +11,12 @@ describe :extract_range_matched, shared: true do
ch.should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "taints the returned String if the input was tainted" do
- str = 'abc'
- str.taint
+ it "taints the returned String if the input was tainted" do
+ str = 'abc'
+ str.taint
- s = StringScanner.new(str)
- s.scan(/\w{1}/)
- s.send(@method).tainted?.should be_true
- end
+ s = StringScanner.new(str)
+ s.scan(/\w{1}/)
+ s.send(@method).tainted?.should be_true
end
end
diff --git a/spec/ruby/library/stringscanner/shared/peek.rb b/spec/ruby/library/stringscanner/shared/peek.rb
index 4e2e643353..418ebb6536 100644
--- a/spec/ruby/library/stringscanner/shared/peek.rb
+++ b/spec/ruby/library/stringscanner/shared/peek.rb
@@ -19,11 +19,11 @@ describe :strscan_peek, shared: true do
end
it "raises a ArgumentError when the passed argument is negative" do
- -> { @s.send(@method, -2) }.should raise_error(ArgumentError)
+ lambda { @s.send(@method, -2) }.should raise_error(ArgumentError)
end
it "raises a RangeError when the passed argument is a Bignum" do
- -> { @s.send(@method, bignum_value) }.should raise_error(RangeError)
+ lambda { @s.send(@method, bignum_value) }.should raise_error(RangeError)
end
it "returns an instance of String when passed a String subclass" do
@@ -37,13 +37,11 @@ describe :strscan_peek, shared: true do
ch.should be_an_instance_of(String)
end
- ruby_version_is ''...'2.7' do
- it "taints the returned String if the input was tainted" do
- str = 'abc'
- str.taint
+ it "taints the returned String if the input was tainted" do
+ str = 'abc'
+ str.taint
- s = StringScanner.new(str)
- s.send(@method, 1).tainted?.should be_true
- end
+ s = StringScanner.new(str)
+ s.send(@method, 1).tainted?.should be_true
end
end
diff --git a/spec/ruby/library/stringscanner/shared/pos.rb b/spec/ruby/library/stringscanner/shared/pos.rb
index 6d540881f2..80ded17b0f 100644
--- a/spec/ruby/library/stringscanner/shared/pos.rb
+++ b/spec/ruby/library/stringscanner/shared/pos.rb
@@ -41,12 +41,12 @@ describe :strscan_pos_set, shared: true do
end
it "raises a RangeError if position too far backward" do
- -> {
+ lambda {
@s.send(@method, -20)
}.should raise_error(RangeError)
end
it "raises a RangeError when the passed argument is out of range" do
- -> { @s.send(@method, 20) }.should raise_error(RangeError)
+ lambda { @s.send(@method, 20) }.should raise_error(RangeError)
end
end
diff --git a/spec/ruby/library/stringscanner/skip_spec.rb b/spec/ruby/library/stringscanner/skip_spec.rb
index 473361782c..7426267b6e 100644
--- a/spec/ruby/library/stringscanner/skip_spec.rb
+++ b/spec/ruby/library/stringscanner/skip_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#skip" do
diff --git a/spec/ruby/library/stringscanner/skip_until_spec.rb b/spec/ruby/library/stringscanner/skip_until_spec.rb
index 73eb91b8ad..c6e17900d1 100644
--- a/spec/ruby/library/stringscanner/skip_until_spec.rb
+++ b/spec/ruby/library/stringscanner/skip_until_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#skip_until" do
diff --git a/spec/ruby/library/stringscanner/string_spec.rb b/spec/ruby/library/stringscanner/string_spec.rb
index 28e2f0ed37..080c0dfcf1 100644
--- a/spec/ruby/library/stringscanner/string_spec.rb
+++ b/spec/ruby/library/stringscanner/string_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#string" do
diff --git a/spec/ruby/library/stringscanner/terminate_spec.rb b/spec/ruby/library/stringscanner/terminate_spec.rb
index 249023f1ab..01cea3dbdf 100644
--- a/spec/ruby/library/stringscanner/terminate_spec.rb
+++ b/spec/ruby/library/stringscanner/terminate_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'shared/terminate'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/terminate.rb', __FILE__)
require 'strscan'
describe "StringScanner#terminate" do
- it_behaves_like :strscan_terminate, :terminate
+ it_behaves_like(:strscan_terminate, :terminate)
end
diff --git a/spec/ruby/library/stringscanner/unscan_spec.rb b/spec/ruby/library/stringscanner/unscan_spec.rb
index df0ea43367..7663f20d61 100644
--- a/spec/ruby/library/stringscanner/unscan_spec.rb
+++ b/spec/ruby/library/stringscanner/unscan_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'strscan'
describe "StringScanner#unscan" do
@@ -22,7 +22,7 @@ describe "StringScanner#unscan" do
end
it "raises a ScanError when the previous match had failed" do
- -> { @s.unscan }.should raise_error(ScanError)
- -> { @s.scan(/\d/); @s.unscan }.should raise_error(ScanError)
+ lambda { @s.unscan }.should raise_error(ScanError)
+ lambda { @s.scan(/\d/); @s.unscan }.should raise_error(ScanError)
end
end
diff --git a/spec/ruby/library/syslog/alert_spec.rb b/spec/ruby/library/syslog/alert_spec.rb
index edff789dc9..e61b3d6ef3 100644
--- a/spec/ruby/library/syslog/alert_spec.rb
+++ b/spec/ruby/library/syslog/alert_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.alert" do
diff --git a/spec/ruby/library/syslog/close_spec.rb b/spec/ruby/library/syslog/close_spec.rb
index 8186ecf125..d7aadb2198 100644
--- a/spec/ruby/library/syslog/close_spec.rb
+++ b/spec/ruby/library/syslog/close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
@@ -23,11 +23,11 @@ platform_is_not :windows do
end
it "raises a RuntimeError if the log's already closed" do
- -> { Syslog.close }.should raise_error(RuntimeError)
+ lambda { Syslog.close }.should raise_error(RuntimeError)
end
it "it does not work inside blocks" do
- -> {
+ lambda {
Syslog.open { |s| s.close }
}.should raise_error(RuntimeError)
Syslog.opened?.should == false
diff --git a/spec/ruby/library/syslog/constants_spec.rb b/spec/ruby/library/syslog/constants_spec.rb
index 2b9524c53d..1ce82be883 100644
--- a/spec/ruby/library/syslog/constants_spec.rb
+++ b/spec/ruby/library/syslog/constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
diff --git a/spec/ruby/library/syslog/crit_spec.rb b/spec/ruby/library/syslog/crit_spec.rb
index 5d3904f719..cf2cc71abc 100644
--- a/spec/ruby/library/syslog/crit_spec.rb
+++ b/spec/ruby/library/syslog/crit_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.crit" do
diff --git a/spec/ruby/library/syslog/debug_spec.rb b/spec/ruby/library/syslog/debug_spec.rb
index d03e8a88c9..09ba9997a2 100644
--- a/spec/ruby/library/syslog/debug_spec.rb
+++ b/spec/ruby/library/syslog/debug_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.debug" do
diff --git a/spec/ruby/library/syslog/emerg_spec.rb b/spec/ruby/library/syslog/emerg_spec.rb
index 2ab4d60291..d416ee57c6 100644
--- a/spec/ruby/library/syslog/emerg_spec.rb
+++ b/spec/ruby/library/syslog/emerg_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.emerg" do
diff --git a/spec/ruby/library/syslog/err_spec.rb b/spec/ruby/library/syslog/err_spec.rb
index 43e876ed37..ad65f6c276 100644
--- a/spec/ruby/library/syslog/err_spec.rb
+++ b/spec/ruby/library/syslog/err_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.err" do
diff --git a/spec/ruby/library/syslog/facility_spec.rb b/spec/ruby/library/syslog/facility_spec.rb
index 550ca70b11..fdcabfa0dd 100644
--- a/spec/ruby/library/syslog/facility_spec.rb
+++ b/spec/ruby/library/syslog/facility_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
diff --git a/spec/ruby/library/syslog/ident_spec.rb b/spec/ruby/library/syslog/ident_spec.rb
index e8345ebb49..ef1144f12e 100644
--- a/spec/ruby/library/syslog/ident_spec.rb
+++ b/spec/ruby/library/syslog/ident_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
diff --git a/spec/ruby/library/syslog/info_spec.rb b/spec/ruby/library/syslog/info_spec.rb
index f2d535299c..b2abe7c04a 100644
--- a/spec/ruby/library/syslog/info_spec.rb
+++ b/spec/ruby/library/syslog/info_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.info" do
diff --git a/spec/ruby/library/syslog/inspect_spec.rb b/spec/ruby/library/syslog/inspect_spec.rb
index f45231f8e3..c22a053286 100644
--- a/spec/ruby/library/syslog/inspect_spec.rb
+++ b/spec/ruby/library/syslog/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
diff --git a/spec/ruby/library/syslog/instance_spec.rb b/spec/ruby/library/syslog/instance_spec.rb
index 891296c52d..65d97a5d50 100644
--- a/spec/ruby/library/syslog/instance_spec.rb
+++ b/spec/ruby/library/syslog/instance_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
diff --git a/spec/ruby/library/syslog/log_spec.rb b/spec/ruby/library/syslog/log_spec.rb
index 389da775b1..eac6be8b01 100644
--- a/spec/ruby/library/syslog/log_spec.rb
+++ b/spec/ruby/library/syslog/log_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
@@ -15,41 +15,41 @@ platform_is_not :windows do
end
it "receives a priority as first argument" do
- -> {
+ lambda {
Syslog.open("rubyspec", Syslog::LOG_PERROR) do |s|
s.log(Syslog::LOG_ALERT, "Hello")
s.log(Syslog::LOG_CRIT, "World")
end
- }.should output_to_fd(/\Arubyspec(?::| \d+ - -) Hello\nrubyspec(?::| \d+ - -) World\n\z/, $stderr)
+ }.should output_to_fd("rubyspec: Hello\nrubyspec: World\n", $stderr)
end
- it "accepts undefined priorities" do
- -> {
+ it "accepts undefined priorites" do
+ lambda {
Syslog.open("rubyspec", Syslog::LOG_PERROR) do |s|
s.log(1337, "Hello")
end
# use a regex since it'll output unknown facility/priority messages
- }.should output_to_fd(/rubyspec(?::| \d+ - -) Hello\n\z/, $stderr)
+ }.should output_to_fd(/rubyspec: Hello/, $stderr)
end
it "fails with TypeError on nil log messages" do
Syslog.open do |s|
- -> { s.log(1, nil) }.should raise_error(TypeError)
+ lambda { s.log(1, nil) }.should raise_error(TypeError)
end
end
it "fails if the log is closed" do
- -> {
+ lambda {
Syslog.log(Syslog::LOG_ALERT, "test")
}.should raise_error(RuntimeError)
end
it "accepts printf parameters" do
- -> {
+ lambda {
Syslog.open("rubyspec", Syslog::LOG_PERROR) do |s|
s.log(Syslog::LOG_ALERT, "%s x %d", "chunky bacon", 2)
end
- }.should output_to_fd(/rubyspec(?::| \d+ - -) chunky bacon x 2\n\z/, $stderr)
+ }.should output_to_fd("rubyspec: chunky bacon x 2\n", $stderr)
end
end
end
diff --git a/spec/ruby/library/syslog/mask_spec.rb b/spec/ruby/library/syslog/mask_spec.rb
index 6581f6a756..7a11d1e88c 100644
--- a/spec/ruby/library/syslog/mask_spec.rb
+++ b/spec/ruby/library/syslog/mask_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
@@ -91,7 +91,7 @@ platform_is_not :windows do
end
it "raises an error if the log is closed" do
- -> { Syslog.mask = 1337 }.should raise_error(RuntimeError)
+ lambda { Syslog.mask = 1337 }.should raise_error(RuntimeError)
end
it "only accepts numbers" do
@@ -103,8 +103,8 @@ platform_is_not :windows do
Syslog.mask = 3.1416
Syslog.mask.should == 3
- -> { Syslog.mask = "oh hai" }.should raise_error(TypeError)
- -> { Syslog.mask = "43" }.should raise_error(TypeError)
+ lambda { Syslog.mask = "oh hai" }.should raise_error(TypeError)
+ lambda { Syslog.mask = "43" }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/library/syslog/notice_spec.rb b/spec/ruby/library/syslog/notice_spec.rb
index a2134e0140..f31074f3f6 100644
--- a/spec/ruby/library/syslog/notice_spec.rb
+++ b/spec/ruby/library/syslog/notice_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.notice" do
diff --git a/spec/ruby/library/syslog/open_spec.rb b/spec/ruby/library/syslog/open_spec.rb
index 543f5d418b..424b48d831 100644
--- a/spec/ruby/library/syslog/open_spec.rb
+++ b/spec/ruby/library/syslog/open_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/reopen'
+ require File.expand_path('../shared/reopen', __FILE__)
require 'syslog'
describe "Syslog.open" do
@@ -74,10 +74,10 @@ platform_is_not :windows do
it "raises an error if the log is opened" do
Syslog.open
- -> {
+ lambda {
Syslog.open
}.should raise_error(RuntimeError, /syslog already open/)
- -> {
+ lambda {
Syslog.close
Syslog.open
}.should_not raise_error
diff --git a/spec/ruby/library/syslog/opened_spec.rb b/spec/ruby/library/syslog/opened_spec.rb
index 94432e65a4..1db388fa61 100644
--- a/spec/ruby/library/syslog/opened_spec.rb
+++ b/spec/ruby/library/syslog/opened_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
diff --git a/spec/ruby/library/syslog/options_spec.rb b/spec/ruby/library/syslog/options_spec.rb
index 83ba43503e..145d11a2fb 100644
--- a/spec/ruby/library/syslog/options_spec.rb
+++ b/spec/ruby/library/syslog/options_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
require 'syslog'
diff --git a/spec/ruby/library/syslog/reopen_spec.rb b/spec/ruby/library/syslog/reopen_spec.rb
index a78529fa1f..49704784e5 100644
--- a/spec/ruby/library/syslog/reopen_spec.rb
+++ b/spec/ruby/library/syslog/reopen_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/reopen'
+ require File.expand_path('../shared/reopen', __FILE__)
require 'syslog'
describe "Syslog.reopen" do
diff --git a/spec/ruby/library/syslog/shared/log.rb b/spec/ruby/library/syslog/shared/log.rb
index 2947f5d062..6d0d3a3c23 100644
--- a/spec/ruby/library/syslog/shared/log.rb
+++ b/spec/ruby/library/syslog/shared/log.rb
@@ -9,31 +9,32 @@ describe :syslog_log, shared: true do
end
it "logs a message" do
- -> {
+ lambda {
Syslog.open("rubyspec", Syslog::LOG_PERROR) do
Syslog.send(@method, "Hello")
end
- }.should output_to_fd(/\Arubyspec(?::| \d+ - -) Hello\n\z/, $stderr)
+ }.should output_to_fd("rubyspec: Hello\n", $stderr)
end
it "accepts sprintf arguments" do
- -> {
+ lambda {
Syslog.open("rubyspec", Syslog::LOG_PERROR) do
Syslog.send(@method, "Hello %s", "world")
Syslog.send(@method, "%d dogs", 2)
end
- }.should output_to_fd(/\Arubyspec(?::| \d+ - -) Hello world\nrubyspec(?::| \d+ - -) 2 dogs\n\z/, $stderr)
+ }.should output_to_fd("rubyspec: Hello world\nrubyspec: 2 dogs\n", $stderr)
end
it "works as an alias for Syslog.log" do
level = Syslog.const_get "LOG_#{@method.to_s.upcase}"
- -> {
+ response = "rubyspec: Hello\n"
+ lambda {
Syslog.open("rubyspec", Syslog::LOG_PERROR) do
Syslog.send(@method, "Hello")
Syslog.log(level, "Hello")
end
# make sure the same thing is written to $stderr.
- }.should output_to_fd(/\A(?:rubyspec(?::| \d+ - -) Hello\n){2}\z/, $stderr)
+ }.should output_to_fd(response * 2, $stderr)
end
end
end
diff --git a/spec/ruby/library/syslog/shared/reopen.rb b/spec/ruby/library/syslog/shared/reopen.rb
index 621437a01d..fd30ab824a 100644
--- a/spec/ruby/library/syslog/shared/reopen.rb
+++ b/spec/ruby/library/syslog/shared/reopen.rb
@@ -10,13 +10,13 @@ describe :syslog_reopen, shared: true do
it "reopens the log" do
Syslog.open
- -> { Syslog.send(@method)}.should_not raise_error
+ lambda { Syslog.send(@method)}.should_not raise_error
Syslog.opened?.should be_true
Syslog.close
end
it "fails with RuntimeError if the log is closed" do
- -> { Syslog.send(@method)}.should raise_error(RuntimeError)
+ lambda { Syslog.send(@method)}.should raise_error(RuntimeError)
end
it "receives the same parameters as Syslog.open" do
diff --git a/spec/ruby/library/syslog/warning_spec.rb b/spec/ruby/library/syslog/warning_spec.rb
index eeca603136..31fa9524f7 100644
--- a/spec/ruby/library/syslog/warning_spec.rb
+++ b/spec/ruby/library/syslog/warning_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
platform_is_not :windows do
- require_relative 'shared/log'
+ require File.expand_path('../shared/log', __FILE__)
require 'syslog'
describe "Syslog.warning" do
diff --git a/spec/ruby/library/tempfile/_close_spec.rb b/spec/ruby/library/tempfile/_close_spec.rb
index c08f425b6f..d91a3e1adc 100644
--- a/spec/ruby/library/tempfile/_close_spec.rb
+++ b/spec/ruby/library/tempfile/_close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#_close" do
diff --git a/spec/ruby/library/tempfile/callback_spec.rb b/spec/ruby/library/tempfile/callback_spec.rb
index c0b1518326..045252fec3 100644
--- a/spec/ruby/library/tempfile/callback_spec.rb
+++ b/spec/ruby/library/tempfile/callback_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile.callback" do
diff --git a/spec/ruby/library/tempfile/close_spec.rb b/spec/ruby/library/tempfile/close_spec.rb
index db0eae3fa5..aa776b840c 100644
--- a/spec/ruby/library/tempfile/close_spec.rb
+++ b/spec/ruby/library/tempfile/close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#close when passed no argument or [false]" do
@@ -18,7 +18,7 @@ describe "Tempfile#close when passed no argument or [false]" do
it "does not unlink self" do
path = @tempfile.path
@tempfile.close
- File.should.exist?(path)
+ File.exist?(path).should be_true
end
end
@@ -35,7 +35,7 @@ describe "Tempfile#close when passed [true]" do
it "unlinks self" do
path = @tempfile.path
@tempfile.close(true)
- File.should_not.exist?(path)
+ File.exist?(path).should be_false
end
end
@@ -52,6 +52,6 @@ describe "Tempfile#close!" do
it "unlinks self" do
path = @tempfile.path
@tempfile.close!
- File.should_not.exist?(path)
+ File.exist?(path).should be_false
end
end
diff --git a/spec/ruby/library/tempfile/delete_spec.rb b/spec/ruby/library/tempfile/delete_spec.rb
index 0332b44dde..8e92631e62 100644
--- a/spec/ruby/library/tempfile/delete_spec.rb
+++ b/spec/ruby/library/tempfile/delete_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/unlink'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/unlink', __FILE__)
require 'tempfile'
describe "Tempfile#delete" do
diff --git a/spec/ruby/library/tempfile/initialize_spec.rb b/spec/ruby/library/tempfile/initialize_spec.rb
index f2e786d7d8..79f33e3e98 100644
--- a/spec/ruby/library/tempfile/initialize_spec.rb
+++ b/spec/ruby/library/tempfile/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#initialize" do
@@ -12,7 +12,7 @@ describe "Tempfile#initialize" do
it "opens a new tempfile with the passed name in the passed directory" do
@tempfile.send(:initialize, "basename", tmp(""))
- File.should.exist?(@tempfile.path)
+ File.exist?(@tempfile.path).should be_true
tmpdir = tmp("")
path = @tempfile.path
@@ -28,7 +28,7 @@ describe "Tempfile#initialize" do
end
platform_is_not :windows do
- it "sets the permissions on the tempfile to 0600" do
+ it "sets the permisssions on the tempfile to 0600" do
@tempfile.send(:initialize, "basename", tmp(""))
File.stat(@tempfile.path).mode.should == 0100600
end
@@ -38,9 +38,4 @@ describe "Tempfile#initialize" do
@tempfile.send(:initialize, ['shiftjis', 'yml'], encoding: 'SHIFT_JIS')
@tempfile.external_encoding.should == Encoding::Shift_JIS
end
-
- it "does not try to modify the arguments" do
- @tempfile.send(:initialize, ['frozen'.freeze, 'txt'.freeze], encoding: Encoding::IBM437)
- @tempfile.external_encoding.should == Encoding::IBM437
- end
end
diff --git a/spec/ruby/library/tempfile/length_spec.rb b/spec/ruby/library/tempfile/length_spec.rb
index bc622b9a70..b4f0a3b1d4 100644
--- a/spec/ruby/library/tempfile/length_spec.rb
+++ b/spec/ruby/library/tempfile/length_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'tempfile'
describe "Tempfile#length" do
diff --git a/spec/ruby/library/tempfile/open_spec.rb b/spec/ruby/library/tempfile/open_spec.rb
index ef2c95376f..3ceaeec502 100644
--- a/spec/ruby/library/tempfile/open_spec.rb
+++ b/spec/ruby/library/tempfile/open_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#open" do
@@ -41,22 +41,6 @@ describe "Tempfile.open" do
Tempfile.open(["specs", ".tt"]) { |tempfile| @tempfile = tempfile }
@tempfile.path.should =~ /specs.*\.tt$/
end
-
- it "passes the third argument (options) to open" do
- Tempfile.open("specs", Dir.tmpdir, encoding: "IBM037:IBM037", binmode: true) do |tempfile|
- @tempfile = tempfile
- tempfile.external_encoding.should == Encoding.find("IBM037")
- tempfile.binmode?.should be_true
- end
- end
-
- it "uses a blank string for basename when passed no arguments" do
- Tempfile.open() do |tempfile|
- @tempfile = tempfile
- tempfile.closed?.should be_false
- end
- @tempfile.should_not == nil
- end
end
describe "Tempfile.open when passed a block" do
@@ -95,3 +79,4 @@ describe "Tempfile.open when passed a block" do
@tempfile.closed?.should be_true
end
end
+
diff --git a/spec/ruby/library/tempfile/path_spec.rb b/spec/ruby/library/tempfile/path_spec.rb
index 07f75b3e10..f25e902872 100644
--- a/spec/ruby/library/tempfile/path_spec.rb
+++ b/spec/ruby/library/tempfile/path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'tempfile'
describe "Tempfile#path" do
diff --git a/spec/ruby/library/tempfile/shared/unlink.rb b/spec/ruby/library/tempfile/shared/unlink.rb
index e821228d70..2b575fd391 100644
--- a/spec/ruby/library/tempfile/shared/unlink.rb
+++ b/spec/ruby/library/tempfile/shared/unlink.rb
@@ -7,6 +7,6 @@ describe :tempfile_unlink, shared: true do
@tempfile.close
path = @tempfile.path
@tempfile.send(@method)
- File.should_not.exist?(path)
+ File.exist?(path).should be_false
end
end
diff --git a/spec/ruby/library/tempfile/size_spec.rb b/spec/ruby/library/tempfile/size_spec.rb
index f4824601c7..ac66d35906 100644
--- a/spec/ruby/library/tempfile/size_spec.rb
+++ b/spec/ruby/library/tempfile/size_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/length'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/length', __FILE__)
require 'tempfile'
describe "Tempfile#size" do
diff --git a/spec/ruby/library/tempfile/unlink_spec.rb b/spec/ruby/library/tempfile/unlink_spec.rb
index eac7df8472..d4ef343c8d 100644
--- a/spec/ruby/library/tempfile/unlink_spec.rb
+++ b/spec/ruby/library/tempfile/unlink_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/unlink'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/unlink', __FILE__)
require 'tempfile'
describe "Tempfile#unlink" do
diff --git a/spec/ruby/library/thread/exclusive_spec.rb b/spec/ruby/library/thread/exclusive_spec.rb
new file mode 100644
index 0000000000..9d30188976
--- /dev/null
+++ b/spec/ruby/library/thread/exclusive_spec.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'thread'
+
+describe "Thread.exclusive" do
+ before :each do
+ ScratchPad.clear
+ end
+
+ it "returns the result of yielding" do
+ Thread.exclusive { :result }.should == :result
+ end
+end
diff --git a/spec/ruby/library/thread/queue/append_spec.rb b/spec/ruby/library/thread/queue/append_spec.rb
new file mode 100644
index 0000000000..8a9e6a21ec
--- /dev/null
+++ b/spec/ruby/library/thread/queue/append_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/enque', __FILE__)
+
+describe "Thread::Queue#<<" do
+ it_behaves_like :queue_enq, :<<, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/clear_spec.rb b/spec/ruby/library/thread/queue/clear_spec.rb
new file mode 100644
index 0000000000..3272a5f3e0
--- /dev/null
+++ b/spec/ruby/library/thread/queue/clear_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/clear', __FILE__)
+
+describe "Thread::Queue#clear" do
+ it_behaves_like :queue_clear, :clear, -> { Queue.new }
+
+ # TODO: test for atomicity of Queue#clear
+end
diff --git a/spec/ruby/library/thread/queue/close_spec.rb b/spec/ruby/library/thread/queue/close_spec.rb
new file mode 100644
index 0000000000..728fff1bfa
--- /dev/null
+++ b/spec/ruby/library/thread/queue/close_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/close', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "Queue#close" do
+ it_behaves_like :queue_close, :close, -> { Queue.new }
+ end
+end
diff --git a/spec/ruby/library/thread/queue/closed_spec.rb b/spec/ruby/library/thread/queue/closed_spec.rb
new file mode 100644
index 0000000000..98ce9c70e3
--- /dev/null
+++ b/spec/ruby/library/thread/queue/closed_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/closed', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "Queue#closed?" do
+ it_behaves_like :queue_closed?, :closed?, -> { Queue.new }
+ end
+end
diff --git a/spec/ruby/library/thread/queue/deq_spec.rb b/spec/ruby/library/thread/queue/deq_spec.rb
new file mode 100644
index 0000000000..7b629bafce
--- /dev/null
+++ b/spec/ruby/library/thread/queue/deq_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/deque', __FILE__)
+
+describe "Thread::Queue#deq" do
+ it_behaves_like :queue_deq, :deq, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/empty_spec.rb b/spec/ruby/library/thread/queue/empty_spec.rb
new file mode 100644
index 0000000000..dea7eb658e
--- /dev/null
+++ b/spec/ruby/library/thread/queue/empty_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/empty', __FILE__)
+
+describe "Thread::Queue#empty?" do
+ it_behaves_like :queue_empty?, :empty?, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/enq_spec.rb b/spec/ruby/library/thread/queue/enq_spec.rb
new file mode 100644
index 0000000000..dc2508589e
--- /dev/null
+++ b/spec/ruby/library/thread/queue/enq_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/enque', __FILE__)
+
+describe "Thread::Queue#enq" do
+ it_behaves_like :queue_enq, :enq, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/length_spec.rb b/spec/ruby/library/thread/queue/length_spec.rb
new file mode 100644
index 0000000000..f33e51a971
--- /dev/null
+++ b/spec/ruby/library/thread/queue/length_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/length', __FILE__)
+
+describe "Thread::Queue#length" do
+ it_behaves_like :queue_length, :length, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/num_waiting_spec.rb b/spec/ruby/library/thread/queue/num_waiting_spec.rb
new file mode 100644
index 0000000000..253ef8a476
--- /dev/null
+++ b/spec/ruby/library/thread/queue/num_waiting_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/num_waiting', __FILE__)
+
+describe "Thread::Queue#num_waiting" do
+ it_behaves_like :queue_num_waiting, :num_waiting, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/pop_spec.rb b/spec/ruby/library/thread/queue/pop_spec.rb
new file mode 100644
index 0000000000..e812e9442e
--- /dev/null
+++ b/spec/ruby/library/thread/queue/pop_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/deque', __FILE__)
+
+describe "Thread::Queue#pop" do
+ it_behaves_like :queue_deq, :pop, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/push_spec.rb b/spec/ruby/library/thread/queue/push_spec.rb
new file mode 100644
index 0000000000..2f1a31315d
--- /dev/null
+++ b/spec/ruby/library/thread/queue/push_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/enque', __FILE__)
+
+describe "Thread::Queue#push" do
+ it_behaves_like :queue_enq, :push, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/shift_spec.rb b/spec/ruby/library/thread/queue/shift_spec.rb
new file mode 100644
index 0000000000..16164a72ec
--- /dev/null
+++ b/spec/ruby/library/thread/queue/shift_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/deque', __FILE__)
+
+describe "Thread::Queue#shift" do
+ it_behaves_like :queue_deq, :shift, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue/size_spec.rb b/spec/ruby/library/thread/queue/size_spec.rb
new file mode 100644
index 0000000000..4b148aecd3
--- /dev/null
+++ b/spec/ruby/library/thread/queue/size_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/length', __FILE__)
+
+describe "Thread::Queue#size" do
+ it_behaves_like :queue_length, :size, -> { Queue.new }
+end
diff --git a/spec/ruby/library/thread/queue_spec.rb b/spec/ruby/library/thread/queue_spec.rb
deleted file mode 100644
index c7e2bb1b50..0000000000
--- a/spec/ruby/library/thread/queue_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Thread::Queue" do
- it "is the same class as ::Queue" do
- Thread.should have_constant(:Queue)
- Thread::Queue.should equal ::Queue
- end
-end
diff --git a/spec/ruby/library/thread/shared/queue/clear.rb b/spec/ruby/library/thread/shared/queue/clear.rb
new file mode 100644
index 0000000000..59ea37d615
--- /dev/null
+++ b/spec/ruby/library/thread/shared/queue/clear.rb
@@ -0,0 +1,10 @@
+describe :queue_clear, shared: true do
+ it "removes all objects from the queue" do
+ queue = @object.call
+ queue << Object.new
+ queue << 1
+ queue.empty?.should be_false
+ queue.clear
+ queue.empty?.should be_true
+ end
+end
diff --git a/spec/ruby/library/thread/shared/queue/close.rb b/spec/ruby/library/thread/shared/queue/close.rb
new file mode 100644
index 0000000000..4457f3ae8b
--- /dev/null
+++ b/spec/ruby/library/thread/shared/queue/close.rb
@@ -0,0 +1,26 @@
+describe :queue_close, shared: true do
+ it "closes the queue and returns nil for further #pop" do
+ q = @object.call
+ q << 1
+ q.close
+ q.pop.should == 1
+ q.pop.should == nil
+ q.pop.should == nil
+ end
+
+ it "prevents further #push" do
+ q = @object.call
+ q.close
+ lambda {
+ q << 1
+ }.should raise_error(ClosedQueueError)
+ end
+
+ it "may be called multiple times" do
+ q = @object.call
+ q.close
+ q.closed?.should be_true
+ q.close # no effect
+ q.closed?.should be_true
+ end
+end
diff --git a/spec/ruby/shared/queue/closed.rb b/spec/ruby/library/thread/shared/queue/closed.rb
index b3cea0c524..b3cea0c524 100644
--- a/spec/ruby/shared/queue/closed.rb
+++ b/spec/ruby/library/thread/shared/queue/closed.rb
diff --git a/spec/ruby/library/thread/shared/queue/deque.rb b/spec/ruby/library/thread/shared/queue/deque.rb
new file mode 100644
index 0000000000..1b06dffa2c
--- /dev/null
+++ b/spec/ruby/library/thread/shared/queue/deque.rb
@@ -0,0 +1,37 @@
+describe :queue_deq, shared: true do
+ it "removes an item from the Queue" do
+ q = @object.call
+ q << Object.new
+ q.size.should == 1
+ q.send(@method)
+ q.size.should == 0
+ end
+
+ it "returns items in the order they were added" do
+ q = @object.call
+ q << 1
+ q << 2
+ q.send(@method).should == 1
+ q.send(@method).should == 2
+ end
+
+ it "blocks the thread until there are items in the queue" do
+ q = @object.call
+ v = 0
+
+ th = Thread.new do
+ q.send(@method)
+ v = 1
+ end
+
+ v.should == 0
+ q << Object.new
+ th.join
+ v.should == 1
+ end
+
+ it "raises a ThreadError if Queue is empty" do
+ q = @object.call
+ lambda { q.send(@method,true) }.should raise_error(ThreadError)
+ end
+end
diff --git a/spec/ruby/shared/queue/empty.rb b/spec/ruby/library/thread/shared/queue/empty.rb
index 4acd831d48..4acd831d48 100644
--- a/spec/ruby/shared/queue/empty.rb
+++ b/spec/ruby/library/thread/shared/queue/empty.rb
diff --git a/spec/ruby/library/thread/shared/queue/enque.rb b/spec/ruby/library/thread/shared/queue/enque.rb
new file mode 100644
index 0000000000..36b98d3a07
--- /dev/null
+++ b/spec/ruby/library/thread/shared/queue/enque.rb
@@ -0,0 +1,10 @@
+describe :queue_enq, shared: true do
+ it "adds an element to the Queue" do
+ q = @object.call
+ q.size.should == 0
+ q.send(@method, Object.new)
+ q.size.should == 1
+ q.send(@method, Object.new)
+ q.size.should == 2
+ end
+end
diff --git a/spec/ruby/shared/queue/length.rb b/spec/ruby/library/thread/shared/queue/length.rb
index a0143a4e19..a0143a4e19 100644
--- a/spec/ruby/shared/queue/length.rb
+++ b/spec/ruby/library/thread/shared/queue/length.rb
diff --git a/spec/ruby/shared/queue/num_waiting.rb b/spec/ruby/library/thread/shared/queue/num_waiting.rb
index b054951e45..b054951e45 100644
--- a/spec/ruby/shared/queue/num_waiting.rb
+++ b/spec/ruby/library/thread/shared/queue/num_waiting.rb
diff --git a/spec/ruby/library/thread/sizedqueue/append_spec.rb b/spec/ruby/library/thread/sizedqueue/append_spec.rb
new file mode 100644
index 0000000000..2799472767
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/append_spec.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/enque', __FILE__)
+require File.expand_path('../shared/enque', __FILE__)
+
+describe "Thread::SizedQueue#<<" do
+ it_behaves_like :queue_enq, :<<, -> { SizedQueue.new(10) }
+end
+
+describe "Thread::SizedQueue#<<" do
+ it_behaves_like :sizedqueue_enq, :<<
+end
diff --git a/spec/ruby/library/thread/sizedqueue/clear_spec.rb b/spec/ruby/library/thread/sizedqueue/clear_spec.rb
new file mode 100644
index 0000000000..7dc328803a
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/clear_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/clear', __FILE__)
+
+describe "Thread::SizedQueue#clear" do
+ it_behaves_like :queue_clear, :clear, -> { SizedQueue.new(10) }
+
+ # TODO: test for atomicity of Queue#clear
+end
diff --git a/spec/ruby/library/thread/sizedqueue/close_spec.rb b/spec/ruby/library/thread/sizedqueue/close_spec.rb
new file mode 100644
index 0000000000..465b9ea091
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/close_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/close', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "SizedQueue#close" do
+ it_behaves_like :queue_close, :close, -> { SizedQueue.new(10) }
+ end
+end
diff --git a/spec/ruby/library/thread/sizedqueue/closed_spec.rb b/spec/ruby/library/thread/sizedqueue/closed_spec.rb
new file mode 100644
index 0000000000..9ec72c1aa7
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/closed_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/closed', __FILE__)
+
+ruby_version_is "2.3" do
+ describe "SizedQueue#closed?" do
+ it_behaves_like :queue_closed?, :closed?, -> { SizedQueue.new(10) }
+ end
+end
diff --git a/spec/ruby/library/thread/sizedqueue/deq_spec.rb b/spec/ruby/library/thread/sizedqueue/deq_spec.rb
new file mode 100644
index 0000000000..cc11319d22
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/deq_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/deque', __FILE__)
+
+describe "Thread::SizedQueue#deq" do
+ it_behaves_like :queue_deq, :deq, -> { SizedQueue.new(10) }
+end
diff --git a/spec/ruby/library/thread/sizedqueue/empty_spec.rb b/spec/ruby/library/thread/sizedqueue/empty_spec.rb
new file mode 100644
index 0000000000..368bb00d5f
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/empty_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/empty', __FILE__)
+
+describe "Thread::SizedQueue#empty?" do
+ it_behaves_like :queue_empty?, :empty?, -> { SizedQueue.new(10) }
+end
diff --git a/spec/ruby/library/thread/sizedqueue/enq_spec.rb b/spec/ruby/library/thread/sizedqueue/enq_spec.rb
new file mode 100644
index 0000000000..a0be7bbf05
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/enq_spec.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/enque', __FILE__)
+require File.expand_path('../shared/enque', __FILE__)
+
+describe "Thread::SizedQueue#enq" do
+ it_behaves_like :queue_enq, :enq, -> { SizedQueue.new(10) }
+end
+
+describe "Thread::SizedQueue#enq" do
+ it_behaves_like :sizedqueue_enq, :enq
+end
diff --git a/spec/ruby/library/thread/sizedqueue/length_spec.rb b/spec/ruby/library/thread/sizedqueue/length_spec.rb
new file mode 100644
index 0000000000..c292883a8e
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/length_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/length', __FILE__)
+
+describe "Thread::SizedQueue#length" do
+ it_behaves_like :queue_length, :length, -> { SizedQueue.new(10) }
+end
diff --git a/spec/ruby/library/thread/sizedqueue/max_spec.rb b/spec/ruby/library/thread/sizedqueue/max_spec.rb
new file mode 100644
index 0000000000..54cc6351bd
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/max_spec.rb
@@ -0,0 +1,52 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+
+describe "Thread::SizedQueue#max" do
+ before :each do
+ @sized_queue = SizedQueue.new(5)
+ end
+
+ it "returns the size of the queue" do
+ @sized_queue.max.should == 5
+ end
+end
+
+describe "Thread::SizedQueue#max=" do
+ before :each do
+ @sized_queue = SizedQueue.new(5)
+ end
+
+ it "sets the size of the queue" do
+ @sized_queue.max.should == 5
+ @sized_queue.max = 10
+ @sized_queue.max.should == 10
+ end
+
+ it "does not remove items already in the queue beyond the maximum" do
+ @sized_queue.enq 1
+ @sized_queue.enq 2
+ @sized_queue.enq 3
+ @sized_queue.max = 2
+ (@sized_queue.size > @sized_queue.max).should be_true
+ @sized_queue.deq.should == 1
+ @sized_queue.deq.should == 2
+ @sized_queue.deq.should == 3
+ end
+
+ it "raises a TypeError when given a non-numeric value" do
+ lambda { @sized_queue.max = "foo" }.should raise_error(TypeError)
+ lambda { @sized_queue.max = Object.new }.should raise_error(TypeError)
+ end
+
+ it "raises an argument error when set to zero" do
+ @sized_queue.max.should == 5
+ lambda { @sized_queue.max = 0 }.should raise_error(ArgumentError)
+ @sized_queue.max.should == 5
+ end
+
+ it "raises an argument error when set to a negative number" do
+ @sized_queue.max.should == 5
+ lambda { @sized_queue.max = -1 }.should raise_error(ArgumentError)
+ @sized_queue.max.should == 5
+ end
+end
diff --git a/spec/ruby/library/thread/sizedqueue/new_spec.rb b/spec/ruby/library/thread/sizedqueue/new_spec.rb
new file mode 100644
index 0000000000..a36aa5ed18
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/new_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+
+describe "Thread::SizedQueue#new" do
+ it "returns a new SizedQueue" do
+ SizedQueue.new(1).should be_kind_of(SizedQueue)
+ end
+
+ it "raises a TypeError when the given argument is not Numeric" do
+ lambda { SizedQueue.new("foo") }.should raise_error(TypeError)
+ lambda { SizedQueue.new(Object.new) }.should raise_error(TypeError)
+ end
+
+ it "raises an argument error when no argument is given" do
+ lambda { SizedQueue.new }.should raise_error(ArgumentError)
+ end
+
+ it "raises an argument error when the given argument is zero" do
+ lambda { SizedQueue.new(0) }.should raise_error(ArgumentError)
+ end
+
+ it "raises an argument error when the given argument is negative" do
+ lambda { SizedQueue.new(-1) }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/library/thread/sizedqueue/num_waiting_spec.rb b/spec/ruby/library/thread/sizedqueue/num_waiting_spec.rb
new file mode 100644
index 0000000000..2ce53875cc
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/num_waiting_spec.rb
@@ -0,0 +1,18 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/num_waiting', __FILE__)
+
+describe "Thread::SizedQueue#num_waiting" do
+ it_behaves_like :queue_num_waiting, :num_waiting, -> { SizedQueue.new(10) }
+
+ it "reports the number of threads waiting to push" do
+ q = SizedQueue.new(1)
+ q.push(1)
+ t = Thread.new { q.push(2) }
+ sleep 0.05 until t.stop?
+ q.num_waiting.should == 1
+
+ q.pop
+ t.join
+ end
+end
diff --git a/spec/ruby/library/thread/sizedqueue/pop_spec.rb b/spec/ruby/library/thread/sizedqueue/pop_spec.rb
new file mode 100644
index 0000000000..a83ea6406a
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/pop_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/deque', __FILE__)
+
+describe "Thread::SizedQueue#pop" do
+ it_behaves_like :queue_deq, :pop, -> { SizedQueue.new(10) }
+end
diff --git a/spec/ruby/library/thread/sizedqueue/push_spec.rb b/spec/ruby/library/thread/sizedqueue/push_spec.rb
new file mode 100644
index 0000000000..6021a043c9
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/push_spec.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/enque', __FILE__)
+require File.expand_path('../shared/enque', __FILE__)
+
+describe "Thread::SizedQueue#push" do
+ it_behaves_like :queue_enq, :push, -> { SizedQueue.new(10) }
+end
+
+describe "Thread::SizedQueue#push" do
+ it_behaves_like :sizedqueue_enq, :push
+end
diff --git a/spec/ruby/library/thread/sizedqueue/shared/enque.rb b/spec/ruby/library/thread/sizedqueue/shared/enque.rb
new file mode 100644
index 0000000000..627f8bd745
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/shared/enque.rb
@@ -0,0 +1,34 @@
+describe :sizedqueue_enq, shared: true do
+ it "blocks if queued elements exceed size" do
+ q = SizedQueue.new(1)
+
+ q.size.should == 0
+ q.send(@method, :first_element)
+ q.size.should == 1
+
+ blocked_thread = Thread.new { q.send(@method, :second_element) }
+ sleep 0.01 until blocked_thread.stop?
+
+ q.size.should == 1
+ q.pop.should == :first_element
+
+ blocked_thread.join
+ q.size.should == 1
+ q.pop.should == :second_element
+ q.size.should == 0
+ end
+
+ it "raises a ThreadError if queued elements exceed size when not blocking" do
+ q = SizedQueue.new(2)
+
+ non_blocking = true
+ add_to_queue = lambda { q.send(@method, Object.new, non_blocking) }
+
+ q.size.should == 0
+ add_to_queue.call
+ q.size.should == 1
+ add_to_queue.call
+ q.size.should == 2
+ add_to_queue.should raise_error(ThreadError)
+ end
+end
diff --git a/spec/ruby/library/thread/sizedqueue/shift_spec.rb b/spec/ruby/library/thread/sizedqueue/shift_spec.rb
new file mode 100644
index 0000000000..89345718df
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/shift_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/deque', __FILE__)
+
+describe "Thread::SizedQueue#shift" do
+ it_behaves_like :queue_deq, :shift, -> { SizedQueue.new(10) }
+end
diff --git a/spec/ruby/library/thread/sizedqueue/size_spec.rb b/spec/ruby/library/thread/sizedqueue/size_spec.rb
new file mode 100644
index 0000000000..7ab72d91b1
--- /dev/null
+++ b/spec/ruby/library/thread/sizedqueue/size_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'thread'
+require File.expand_path('../../shared/queue/length', __FILE__)
+
+describe "Thread::SizedQueue#size" do
+ it_behaves_like :queue_length, :size, -> { SizedQueue.new(10) }
+end
diff --git a/spec/ruby/library/thread/sizedqueue_spec.rb b/spec/ruby/library/thread/sizedqueue_spec.rb
deleted file mode 100644
index 6151ff437c..0000000000
--- a/spec/ruby/library/thread/sizedqueue_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Thread::SizedQueue" do
- it "is the same class as ::SizedQueue" do
- Thread.should have_constant(:SizedQueue)
- Thread::SizedQueue.should equal ::SizedQueue
- end
-end
diff --git a/spec/ruby/library/time/httpdate_spec.rb b/spec/ruby/library/time/httpdate_spec.rb
index 90953a9307..af3fd83608 100644
--- a/spec/ruby/library/time/httpdate_spec.rb
+++ b/spec/ruby/library/time/httpdate_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'time'
describe "Time.httpdate" do
diff --git a/spec/ruby/library/time/iso8601_spec.rb b/spec/ruby/library/time/iso8601_spec.rb
index 4a9eb45613..5f324e5ac6 100644
--- a/spec/ruby/library/time/iso8601_spec.rb
+++ b/spec/ruby/library/time/iso8601_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/xmlschema'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/xmlschema', __FILE__)
require 'time'
describe "Time.xmlschema" do
diff --git a/spec/ruby/library/time/rfc2822_spec.rb b/spec/ruby/library/time/rfc2822_spec.rb
index 7fc5e9a64b..ac3950440f 100644
--- a/spec/ruby/library/time/rfc2822_spec.rb
+++ b/spec/ruby/library/time/rfc2822_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rfc2822'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rfc2822', __FILE__)
require 'time'
describe "Time.rfc2822" do
diff --git a/spec/ruby/library/time/rfc822_spec.rb b/spec/ruby/library/time/rfc822_spec.rb
index da77e6ee77..969050d5ac 100644
--- a/spec/ruby/library/time/rfc822_spec.rb
+++ b/spec/ruby/library/time/rfc822_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/rfc2822'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rfc2822', __FILE__)
require 'time'
describe "Time.rfc822" do
diff --git a/spec/ruby/library/time/shared/rfc2822.rb b/spec/ruby/library/time/shared/rfc2822.rb
index d99f1f76de..b7bf0fb5f5 100644
--- a/spec/ruby/library/time/shared/rfc2822.rb
+++ b/spec/ruby/library/time/shared/rfc2822.rb
@@ -57,7 +57,7 @@ describe :time_rfc2822, shared: true do
t18 = Time.rfc2822("Fri, 21 Nov 1997 09 : 55 : 06 -0600")
t17.should == t18
- -> {
+ lambda {
# inner comment is not supported.
Time.rfc2822("Fri, 21 Nov 1997 09(comment): 55 : 06 -0600")
}.should raise_error(ArgumentError)
diff --git a/spec/ruby/library/time/to_date_spec.rb b/spec/ruby/library/time/to_date_spec.rb
index baeafe0847..855dc796cf 100644
--- a/spec/ruby/library/time/to_date_spec.rb
+++ b/spec/ruby/library/time/to_date_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'time'
describe "Time#to_date" do
diff --git a/spec/ruby/library/time/to_datetime_spec.rb b/spec/ruby/library/time/to_datetime_spec.rb
index 0e37a61108..54655963c6 100644
--- a/spec/ruby/library/time/to_datetime_spec.rb
+++ b/spec/ruby/library/time/to_datetime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'time'
describe "Time#to_datetime" do
diff --git a/spec/ruby/library/time/to_time_spec.rb b/spec/ruby/library/time/to_time_spec.rb
index 7e6c75a003..a02ec31cb9 100644
--- a/spec/ruby/library/time/to_time_spec.rb
+++ b/spec/ruby/library/time/to_time_spec.rb
@@ -1,15 +1,17 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'time'
-describe "Time#to_time" do
- it "returns itself in the same timezone" do
- time = Time.new(2012, 2, 21, 10, 11, 12)
+ruby_version_is "2.4" do
+ describe "Time#to_time" do
+ it "returns itself in the same timezone" do
+ time = Time.new(2012, 2, 21, 10, 11, 12)
- with_timezone("America/Regina") do
- time.to_time.should equal time
- end
+ with_timezone("America/Regina") do
+ time.to_time.should equal time
+ end
- time2 = Time.utc(2012, 2, 21, 10, 11, 12)
- time2.to_time.should equal time2
+ time2 = Time.utc(2012, 2, 21, 10, 11, 12)
+ time2.to_time.should equal time2
+ end
end
end
diff --git a/spec/ruby/library/time/xmlschema_spec.rb b/spec/ruby/library/time/xmlschema_spec.rb
index 4279311199..14ea081d6e 100644
--- a/spec/ruby/library/time/xmlschema_spec.rb
+++ b/spec/ruby/library/time/xmlschema_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'shared/xmlschema'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/xmlschema', __FILE__)
require 'time'
describe "Time.xmlschema" do
diff --git a/spec/ruby/library/timeout/error_spec.rb b/spec/ruby/library/timeout/error_spec.rb
index 6c236e5128..37462ecd49 100644
--- a/spec/ruby/library/timeout/error_spec.rb
+++ b/spec/ruby/library/timeout/error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'timeout'
describe "Timeout::Error" do
diff --git a/spec/ruby/library/timeout/timeout_spec.rb b/spec/ruby/library/timeout/timeout_spec.rb
index a9a60fdeb9..2eccd02097 100644
--- a/spec/ruby/library/timeout/timeout_spec.rb
+++ b/spec/ruby/library/timeout/timeout_spec.rb
@@ -1,23 +1,34 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'timeout'
describe "Timeout.timeout" do
it "raises Timeout::Error when it times out with no specified error type" do
- -> {
+ lambda {
Timeout.timeout(1) do
- sleep
+ sleep 3
end
}.should raise_error(Timeout::Error)
end
it "raises specified error type when it times out" do
- -> do
+ lambda do
Timeout.timeout(1, StandardError) do
- sleep
+ sleep 3
end
end.should raise_error(StandardError)
end
+ it "does not wait too long" do
+ before_time = Time.now
+ lambda do
+ Timeout.timeout(1, StandardError) do
+ sleep 3
+ end
+ end.should raise_error(StandardError)
+
+ (Time.now - before_time).should be_close(1.0, 0.5)
+ end
+
it "returns back the last value in the block" do
Timeout.timeout(1) do
42
diff --git a/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb b/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb
index 8165c2d8a8..3459a47fe6 100644
--- a/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb
+++ b/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require "tmpdir"
describe "Dir.mktmpdir when passed no arguments" do
@@ -39,7 +39,7 @@ describe "Dir.mktmpdir when passed a block" do
Dir.mktmpdir do |path|
@tmpdir = path
called = true
- path.should.start_with?(@real_tmp_root)
+ path.start_with?(@real_tmp_root).should be_true
end
called.should be_true
end
@@ -99,7 +99,7 @@ describe "Dir.mktmpdir when passed [Array]" do
Dir.rmdir @tmpdir if File.directory? @tmpdir
end
- it "uses the first element of the passed Array as a prefix and the second element as a suffix to the tmp-directory" do
+ it "uses the first element of the passed Array as a prefix and the scond element as a suffix to the tmp-directory" do
prefix = "before"
suffix = "after"
@@ -110,8 +110,8 @@ end
describe "Dir.mktmpdir when passed [Object]" do
it "raises an ArgumentError" do
- -> { Dir.mktmpdir(Object.new) }.should raise_error(ArgumentError)
- -> { Dir.mktmpdir(:symbol) }.should raise_error(ArgumentError)
- -> { Dir.mktmpdir(10) }.should raise_error(ArgumentError)
+ lambda { Dir.mktmpdir(Object.new) }.should raise_error(ArgumentError)
+ lambda { Dir.mktmpdir(:symbol) }.should raise_error(ArgumentError)
+ lambda { Dir.mktmpdir(10) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb b/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb
index f4ab5e40b8..19d54e03b3 100644
--- a/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb
+++ b/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require "tmpdir"
describe "Dir.tmpdir" do
diff --git a/spec/ruby/library/uri/decode_www_form_component_spec.rb b/spec/ruby/library/uri/decode_www_form_component_spec.rb
index 075cec1087..04cc634947 100644
--- a/spec/ruby/library/uri/decode_www_form_component_spec.rb
+++ b/spec/ruby/library/uri/decode_www_form_component_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI.decode_www_form_component" do
diff --git a/spec/ruby/library/uri/decode_www_form_spec.rb b/spec/ruby/library/uri/decode_www_form_spec.rb
index 8dd37e514f..d4854a6ece 100644
--- a/spec/ruby/library/uri/decode_www_form_spec.rb
+++ b/spec/ruby/library/uri/decode_www_form_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI.decode_www_form" do
diff --git a/spec/ruby/library/uri/encode_www_form_component_spec.rb b/spec/ruby/library/uri/encode_www_form_component_spec.rb
index a0508b207c..753b6d50d0 100644
--- a/spec/ruby/library/uri/encode_www_form_component_spec.rb
+++ b/spec/ruby/library/uri/encode_www_form_component_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI.encode_www_form_component" do
diff --git a/spec/ruby/library/uri/encode_www_form_spec.rb b/spec/ruby/library/uri/encode_www_form_spec.rb
index 7f4aecf89b..b72b928344 100644
--- a/spec/ruby/library/uri/encode_www_form_spec.rb
+++ b/spec/ruby/library/uri/encode_www_form_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI.encode_www_form" do
diff --git a/spec/ruby/library/uri/eql_spec.rb b/spec/ruby/library/uri/eql_spec.rb
index 2bbf8fd40c..2bbc5291e9 100644
--- a/spec/ruby/library/uri/eql_spec.rb
+++ b/spec/ruby/library/uri/eql_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/normalization'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/normalization', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
require 'uri'
describe "URI#eql?" do
diff --git a/spec/ruby/library/uri/equality_spec.rb b/spec/ruby/library/uri/equality_spec.rb
index 1c247ce291..07d48a9583 100644
--- a/spec/ruby/library/uri/equality_spec.rb
+++ b/spec/ruby/library/uri/equality_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/normalization'
-require_relative 'shared/eql'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/normalization', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
require 'uri'
describe "URI#==" do
diff --git a/spec/ruby/library/uri/escape/decode_spec.rb b/spec/ruby/library/uri/escape/decode_spec.rb
index b4ef799411..34d3e787c4 100644
--- a/spec/ruby/library/uri/escape/decode_spec.rb
+++ b/spec/ruby/library/uri/escape/decode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Escape#decode" do
diff --git a/spec/ruby/library/uri/escape/encode_spec.rb b/spec/ruby/library/uri/escape/encode_spec.rb
index 2b61b7c152..edde60b3cd 100644
--- a/spec/ruby/library/uri/escape/encode_spec.rb
+++ b/spec/ruby/library/uri/escape/encode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Escape#encode" do
diff --git a/spec/ruby/library/uri/escape/escape_spec.rb b/spec/ruby/library/uri/escape/escape_spec.rb
index dddbc60707..3c6b957b18 100644
--- a/spec/ruby/library/uri/escape/escape_spec.rb
+++ b/spec/ruby/library/uri/escape/escape_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Escape#escape" do
diff --git a/spec/ruby/library/uri/escape/unescape_spec.rb b/spec/ruby/library/uri/escape/unescape_spec.rb
index 7d574d13c1..6a7165a0d3 100644
--- a/spec/ruby/library/uri/escape/unescape_spec.rb
+++ b/spec/ruby/library/uri/escape/unescape_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Escape#unescape" do
diff --git a/spec/ruby/library/uri/extract_spec.rb b/spec/ruby/library/uri/extract_spec.rb
index 1294a480f1..7b660851b6 100644
--- a/spec/ruby/library/uri/extract_spec.rb
+++ b/spec/ruby/library/uri/extract_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI.extract" do
diff --git a/spec/ruby/library/uri/ftp/build_spec.rb b/spec/ruby/library/uri/ftp/build_spec.rb
index 9e0fb44cf1..c7765e2868 100644
--- a/spec/ruby/library/uri/ftp/build_spec.rb
+++ b/spec/ruby/library/uri/ftp/build_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::FTP.build" do
diff --git a/spec/ruby/library/uri/ftp/merge_spec.rb b/spec/ruby/library/uri/ftp/merge_spec.rb
index 7a9997bbac..b766e992ca 100644
--- a/spec/ruby/library/uri/ftp/merge_spec.rb
+++ b/spec/ruby/library/uri/ftp/merge_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::FTP#merge" do
diff --git a/spec/ruby/library/uri/ftp/new2_spec.rb b/spec/ruby/library/uri/ftp/new2_spec.rb
index eb1b149c81..a43916af6a 100644
--- a/spec/ruby/library/uri/ftp/new2_spec.rb
+++ b/spec/ruby/library/uri/ftp/new2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::FTP.new2" do
diff --git a/spec/ruby/library/uri/ftp/path_spec.rb b/spec/ruby/library/uri/ftp/path_spec.rb
index 5fec7f11b6..9e1a00602f 100644
--- a/spec/ruby/library/uri/ftp/path_spec.rb
+++ b/spec/ruby/library/uri/ftp/path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::FTP#path=" do
diff --git a/spec/ruby/library/uri/ftp/set_typecode_spec.rb b/spec/ruby/library/uri/ftp/set_typecode_spec.rb
index 31067930c0..b815bc8740 100644
--- a/spec/ruby/library/uri/ftp/set_typecode_spec.rb
+++ b/spec/ruby/library/uri/ftp/set_typecode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::FTP#set_typecode" do
diff --git a/spec/ruby/library/uri/ftp/to_s_spec.rb b/spec/ruby/library/uri/ftp/to_s_spec.rb
index 3b4ff2d906..e4e2832e86 100644
--- a/spec/ruby/library/uri/ftp/to_s_spec.rb
+++ b/spec/ruby/library/uri/ftp/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
diff --git a/spec/ruby/library/uri/ftp/typecode_spec.rb b/spec/ruby/library/uri/ftp/typecode_spec.rb
index 1f2bb02252..b298c2ae98 100644
--- a/spec/ruby/library/uri/ftp/typecode_spec.rb
+++ b/spec/ruby/library/uri/ftp/typecode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::FTP#typecode" do
diff --git a/spec/ruby/library/uri/generic/absolute_spec.rb b/spec/ruby/library/uri/generic/absolute_spec.rb
index fe4b48d067..4f6526b827 100644
--- a/spec/ruby/library/uri/generic/absolute_spec.rb
+++ b/spec/ruby/library/uri/generic/absolute_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#absolute" do
diff --git a/spec/ruby/library/uri/generic/build2_spec.rb b/spec/ruby/library/uri/generic/build2_spec.rb
index 9abd1d80ef..0b9a6788f6 100644
--- a/spec/ruby/library/uri/generic/build2_spec.rb
+++ b/spec/ruby/library/uri/generic/build2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic.build2" do
diff --git a/spec/ruby/library/uri/generic/build_spec.rb b/spec/ruby/library/uri/generic/build_spec.rb
index 50c27674ce..6fa5d6ac55 100644
--- a/spec/ruby/library/uri/generic/build_spec.rb
+++ b/spec/ruby/library/uri/generic/build_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic.build" do
diff --git a/spec/ruby/library/uri/generic/coerce_spec.rb b/spec/ruby/library/uri/generic/coerce_spec.rb
index f695e560ac..1b1a040f63 100644
--- a/spec/ruby/library/uri/generic/coerce_spec.rb
+++ b/spec/ruby/library/uri/generic/coerce_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#coerce" do
diff --git a/spec/ruby/library/uri/generic/component_ary_spec.rb b/spec/ruby/library/uri/generic/component_ary_spec.rb
index b39752f8d9..3244073e0e 100644
--- a/spec/ruby/library/uri/generic/component_ary_spec.rb
+++ b/spec/ruby/library/uri/generic/component_ary_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#component_ary" do
diff --git a/spec/ruby/library/uri/generic/component_spec.rb b/spec/ruby/library/uri/generic/component_spec.rb
index f92409a0b0..6fb83d7796 100644
--- a/spec/ruby/library/uri/generic/component_spec.rb
+++ b/spec/ruby/library/uri/generic/component_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#component" do
diff --git a/spec/ruby/library/uri/generic/default_port_spec.rb b/spec/ruby/library/uri/generic/default_port_spec.rb
index 4e10e34c9d..d1e0ce2d3f 100644
--- a/spec/ruby/library/uri/generic/default_port_spec.rb
+++ b/spec/ruby/library/uri/generic/default_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#default_port" do
diff --git a/spec/ruby/library/uri/generic/eql_spec.rb b/spec/ruby/library/uri/generic/eql_spec.rb
index df9987b524..65f9204a19 100644
--- a/spec/ruby/library/uri/generic/eql_spec.rb
+++ b/spec/ruby/library/uri/generic/eql_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#eql?" do
diff --git a/spec/ruby/library/uri/generic/equal_value_spec.rb b/spec/ruby/library/uri/generic/equal_value_spec.rb
index bd2feb86d4..f41b202498 100644
--- a/spec/ruby/library/uri/generic/equal_value_spec.rb
+++ b/spec/ruby/library/uri/generic/equal_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#==" do
diff --git a/spec/ruby/library/uri/generic/fragment_spec.rb b/spec/ruby/library/uri/generic/fragment_spec.rb
index 20126b207a..de6f4e078d 100644
--- a/spec/ruby/library/uri/generic/fragment_spec.rb
+++ b/spec/ruby/library/uri/generic/fragment_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#fragment" do
diff --git a/spec/ruby/library/uri/generic/hash_spec.rb b/spec/ruby/library/uri/generic/hash_spec.rb
index 286c1ab38d..3410558067 100644
--- a/spec/ruby/library/uri/generic/hash_spec.rb
+++ b/spec/ruby/library/uri/generic/hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#hash" do
diff --git a/spec/ruby/library/uri/generic/hierarchical_spec.rb b/spec/ruby/library/uri/generic/hierarchical_spec.rb
index df9bbae202..1c90dc4f8f 100644
--- a/spec/ruby/library/uri/generic/hierarchical_spec.rb
+++ b/spec/ruby/library/uri/generic/hierarchical_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#hierarchical?" do
diff --git a/spec/ruby/library/uri/generic/host_spec.rb b/spec/ruby/library/uri/generic/host_spec.rb
index f2076d2bc1..6fb6c1c36a 100644
--- a/spec/ruby/library/uri/generic/host_spec.rb
+++ b/spec/ruby/library/uri/generic/host_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#host" do
diff --git a/spec/ruby/library/uri/generic/inspect_spec.rb b/spec/ruby/library/uri/generic/inspect_spec.rb
index 4ff81eef82..696c3308d4 100644
--- a/spec/ruby/library/uri/generic/inspect_spec.rb
+++ b/spec/ruby/library/uri/generic/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#inspect" do
diff --git a/spec/ruby/library/uri/generic/merge_spec.rb b/spec/ruby/library/uri/generic/merge_spec.rb
index 017873cc90..63642197e1 100644
--- a/spec/ruby/library/uri/generic/merge_spec.rb
+++ b/spec/ruby/library/uri/generic/merge_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#merge" do
diff --git a/spec/ruby/library/uri/generic/minus_spec.rb b/spec/ruby/library/uri/generic/minus_spec.rb
index ad8f816839..3426a6068b 100644
--- a/spec/ruby/library/uri/generic/minus_spec.rb
+++ b/spec/ruby/library/uri/generic/minus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#-" do
diff --git a/spec/ruby/library/uri/generic/normalize_spec.rb b/spec/ruby/library/uri/generic/normalize_spec.rb
index d70a77c044..ac02b644d0 100644
--- a/spec/ruby/library/uri/generic/normalize_spec.rb
+++ b/spec/ruby/library/uri/generic/normalize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#normalize" do
diff --git a/spec/ruby/library/uri/generic/opaque_spec.rb b/spec/ruby/library/uri/generic/opaque_spec.rb
index e6d40da52b..f418c220f2 100644
--- a/spec/ruby/library/uri/generic/opaque_spec.rb
+++ b/spec/ruby/library/uri/generic/opaque_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#opaque" do
diff --git a/spec/ruby/library/uri/generic/password_spec.rb b/spec/ruby/library/uri/generic/password_spec.rb
index 18db503883..087db60fb9 100644
--- a/spec/ruby/library/uri/generic/password_spec.rb
+++ b/spec/ruby/library/uri/generic/password_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#password" do
diff --git a/spec/ruby/library/uri/generic/path_spec.rb b/spec/ruby/library/uri/generic/path_spec.rb
index d84975c579..5ea60b5418 100644
--- a/spec/ruby/library/uri/generic/path_spec.rb
+++ b/spec/ruby/library/uri/generic/path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#path" do
diff --git a/spec/ruby/library/uri/generic/plus_spec.rb b/spec/ruby/library/uri/generic/plus_spec.rb
index e6d2222dac..3d1c031022 100644
--- a/spec/ruby/library/uri/generic/plus_spec.rb
+++ b/spec/ruby/library/uri/generic/plus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#+" do
diff --git a/spec/ruby/library/uri/generic/port_spec.rb b/spec/ruby/library/uri/generic/port_spec.rb
index 6e5ef01493..148e84ff14 100644
--- a/spec/ruby/library/uri/generic/port_spec.rb
+++ b/spec/ruby/library/uri/generic/port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#port" do
diff --git a/spec/ruby/library/uri/generic/query_spec.rb b/spec/ruby/library/uri/generic/query_spec.rb
index 528cc3be02..945fdc06a3 100644
--- a/spec/ruby/library/uri/generic/query_spec.rb
+++ b/spec/ruby/library/uri/generic/query_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#query" do
diff --git a/spec/ruby/library/uri/generic/registry_spec.rb b/spec/ruby/library/uri/generic/registry_spec.rb
index aece265a07..6a48b25465 100644
--- a/spec/ruby/library/uri/generic/registry_spec.rb
+++ b/spec/ruby/library/uri/generic/registry_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#registry" do
diff --git a/spec/ruby/library/uri/generic/relative_spec.rb b/spec/ruby/library/uri/generic/relative_spec.rb
index a7de1f306a..09730fa4eb 100644
--- a/spec/ruby/library/uri/generic/relative_spec.rb
+++ b/spec/ruby/library/uri/generic/relative_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#relative?" do
diff --git a/spec/ruby/library/uri/generic/route_from_spec.rb b/spec/ruby/library/uri/generic/route_from_spec.rb
index fd69816edf..03321cbf0d 100644
--- a/spec/ruby/library/uri/generic/route_from_spec.rb
+++ b/spec/ruby/library/uri/generic/route_from_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#route_from" do
diff --git a/spec/ruby/library/uri/generic/route_to_spec.rb b/spec/ruby/library/uri/generic/route_to_spec.rb
index 7ab9aff2e8..a12e1f7649 100644
--- a/spec/ruby/library/uri/generic/route_to_spec.rb
+++ b/spec/ruby/library/uri/generic/route_to_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#route_to" do
diff --git a/spec/ruby/library/uri/generic/scheme_spec.rb b/spec/ruby/library/uri/generic/scheme_spec.rb
index 7922a8e977..fa3dfcb8aa 100644
--- a/spec/ruby/library/uri/generic/scheme_spec.rb
+++ b/spec/ruby/library/uri/generic/scheme_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#scheme" do
diff --git a/spec/ruby/library/uri/generic/select_spec.rb b/spec/ruby/library/uri/generic/select_spec.rb
index 99aef83f99..5cc104f5dd 100644
--- a/spec/ruby/library/uri/generic/select_spec.rb
+++ b/spec/ruby/library/uri/generic/select_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#select" do
diff --git a/spec/ruby/library/uri/generic/set_fragment_spec.rb b/spec/ruby/library/uri/generic/set_fragment_spec.rb
index 2476315f08..cebad46585 100644
--- a/spec/ruby/library/uri/generic/set_fragment_spec.rb
+++ b/spec/ruby/library/uri/generic/set_fragment_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_fragment" do
diff --git a/spec/ruby/library/uri/generic/set_host_spec.rb b/spec/ruby/library/uri/generic/set_host_spec.rb
index c7f5c6884e..357b7a6889 100644
--- a/spec/ruby/library/uri/generic/set_host_spec.rb
+++ b/spec/ruby/library/uri/generic/set_host_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_host" do
diff --git a/spec/ruby/library/uri/generic/set_opaque_spec.rb b/spec/ruby/library/uri/generic/set_opaque_spec.rb
index 8a494a7ee2..afd6597675 100644
--- a/spec/ruby/library/uri/generic/set_opaque_spec.rb
+++ b/spec/ruby/library/uri/generic/set_opaque_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_opaque" do
diff --git a/spec/ruby/library/uri/generic/set_password_spec.rb b/spec/ruby/library/uri/generic/set_password_spec.rb
index 93b05fe911..15b4fdc37d 100644
--- a/spec/ruby/library/uri/generic/set_password_spec.rb
+++ b/spec/ruby/library/uri/generic/set_password_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_password" do
diff --git a/spec/ruby/library/uri/generic/set_path_spec.rb b/spec/ruby/library/uri/generic/set_path_spec.rb
index 6d9f59d1a5..b4366d789c 100644
--- a/spec/ruby/library/uri/generic/set_path_spec.rb
+++ b/spec/ruby/library/uri/generic/set_path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_path" do
diff --git a/spec/ruby/library/uri/generic/set_port_spec.rb b/spec/ruby/library/uri/generic/set_port_spec.rb
index 2c8a4edd22..aa65bb96e3 100644
--- a/spec/ruby/library/uri/generic/set_port_spec.rb
+++ b/spec/ruby/library/uri/generic/set_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_port" do
diff --git a/spec/ruby/library/uri/generic/set_query_spec.rb b/spec/ruby/library/uri/generic/set_query_spec.rb
index 3f3453ba8e..b1c25e56ca 100644
--- a/spec/ruby/library/uri/generic/set_query_spec.rb
+++ b/spec/ruby/library/uri/generic/set_query_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_query" do
diff --git a/spec/ruby/library/uri/generic/set_registry_spec.rb b/spec/ruby/library/uri/generic/set_registry_spec.rb
index 44afe246d1..602f868ac1 100644
--- a/spec/ruby/library/uri/generic/set_registry_spec.rb
+++ b/spec/ruby/library/uri/generic/set_registry_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_registry" do
diff --git a/spec/ruby/library/uri/generic/set_scheme_spec.rb b/spec/ruby/library/uri/generic/set_scheme_spec.rb
index ffa29da446..e1a94c5b1a 100644
--- a/spec/ruby/library/uri/generic/set_scheme_spec.rb
+++ b/spec/ruby/library/uri/generic/set_scheme_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_scheme" do
diff --git a/spec/ruby/library/uri/generic/set_user_spec.rb b/spec/ruby/library/uri/generic/set_user_spec.rb
index 9a39e1f4c3..36a6ac9e85 100644
--- a/spec/ruby/library/uri/generic/set_user_spec.rb
+++ b/spec/ruby/library/uri/generic/set_user_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_user" do
diff --git a/spec/ruby/library/uri/generic/set_userinfo_spec.rb b/spec/ruby/library/uri/generic/set_userinfo_spec.rb
index 76878204d2..cbe80d9809 100644
--- a/spec/ruby/library/uri/generic/set_userinfo_spec.rb
+++ b/spec/ruby/library/uri/generic/set_userinfo_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#set_userinfo" do
diff --git a/spec/ruby/library/uri/generic/to_s_spec.rb b/spec/ruby/library/uri/generic/to_s_spec.rb
index 8c90d7645b..c0a0f803ef 100644
--- a/spec/ruby/library/uri/generic/to_s_spec.rb
+++ b/spec/ruby/library/uri/generic/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#to_s" do
diff --git a/spec/ruby/library/uri/generic/use_registry_spec.rb b/spec/ruby/library/uri/generic/use_registry_spec.rb
index bdfe27c048..4e7ae6a5cf 100644
--- a/spec/ruby/library/uri/generic/use_registry_spec.rb
+++ b/spec/ruby/library/uri/generic/use_registry_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic.use_registry" do
diff --git a/spec/ruby/library/uri/generic/user_spec.rb b/spec/ruby/library/uri/generic/user_spec.rb
index 345412ca29..b785ef6879 100644
--- a/spec/ruby/library/uri/generic/user_spec.rb
+++ b/spec/ruby/library/uri/generic/user_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#user" do
diff --git a/spec/ruby/library/uri/generic/userinfo_spec.rb b/spec/ruby/library/uri/generic/userinfo_spec.rb
index 4bf111079c..5d0fc50b65 100644
--- a/spec/ruby/library/uri/generic/userinfo_spec.rb
+++ b/spec/ruby/library/uri/generic/userinfo_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Generic#userinfo" do
diff --git a/spec/ruby/library/uri/http/build_spec.rb b/spec/ruby/library/uri/http/build_spec.rb
index d34cf83ecf..85103167e0 100644
--- a/spec/ruby/library/uri/http/build_spec.rb
+++ b/spec/ruby/library/uri/http/build_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::HTTP.build" do
diff --git a/spec/ruby/library/uri/http/request_uri_spec.rb b/spec/ruby/library/uri/http/request_uri_spec.rb
index 7b05147d36..85d89aba77 100644
--- a/spec/ruby/library/uri/http/request_uri_spec.rb
+++ b/spec/ruby/library/uri/http/request_uri_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::HTTP.request_uri" do
diff --git a/spec/ruby/library/uri/join_spec.rb b/spec/ruby/library/uri/join_spec.rb
index 796f74134f..3e0dbe7f2b 100644
--- a/spec/ruby/library/uri/join_spec.rb
+++ b/spec/ruby/library/uri/join_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI.join" do
@@ -21,7 +21,7 @@ describe "URI.join" do
end
it "raises an error if given no argument" do
- -> {
+ lambda {
URI.join
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/uri/ldap/attributes_spec.rb b/spec/ruby/library/uri/ldap/attributes_spec.rb
index 88e3328bad..2309de7c62 100644
--- a/spec/ruby/library/uri/ldap/attributes_spec.rb
+++ b/spec/ruby/library/uri/ldap/attributes_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#attributes" do
diff --git a/spec/ruby/library/uri/ldap/build_spec.rb b/spec/ruby/library/uri/ldap/build_spec.rb
index 8d0e312d1a..99e2611b1f 100644
--- a/spec/ruby/library/uri/ldap/build_spec.rb
+++ b/spec/ruby/library/uri/ldap/build_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP.build" do
diff --git a/spec/ruby/library/uri/ldap/dn_spec.rb b/spec/ruby/library/uri/ldap/dn_spec.rb
index a5ac02e891..b1371611d3 100644
--- a/spec/ruby/library/uri/ldap/dn_spec.rb
+++ b/spec/ruby/library/uri/ldap/dn_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#dn" do
diff --git a/spec/ruby/library/uri/ldap/extensions_spec.rb b/spec/ruby/library/uri/ldap/extensions_spec.rb
index 473222eb7a..2d9b09e6a7 100644
--- a/spec/ruby/library/uri/ldap/extensions_spec.rb
+++ b/spec/ruby/library/uri/ldap/extensions_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#extensions" do
diff --git a/spec/ruby/library/uri/ldap/filter_spec.rb b/spec/ruby/library/uri/ldap/filter_spec.rb
index d0b7fcc384..1f996339db 100644
--- a/spec/ruby/library/uri/ldap/filter_spec.rb
+++ b/spec/ruby/library/uri/ldap/filter_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#filter" do
diff --git a/spec/ruby/library/uri/ldap/hierarchical_spec.rb b/spec/ruby/library/uri/ldap/hierarchical_spec.rb
index 5471c53d76..97c23a7f0c 100644
--- a/spec/ruby/library/uri/ldap/hierarchical_spec.rb
+++ b/spec/ruby/library/uri/ldap/hierarchical_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#hierarchical?" do
diff --git a/spec/ruby/library/uri/ldap/scope_spec.rb b/spec/ruby/library/uri/ldap/scope_spec.rb
index 5ea5581671..d4a02e08f0 100644
--- a/spec/ruby/library/uri/ldap/scope_spec.rb
+++ b/spec/ruby/library/uri/ldap/scope_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#scope" do
diff --git a/spec/ruby/library/uri/ldap/set_attributes_spec.rb b/spec/ruby/library/uri/ldap/set_attributes_spec.rb
index fdaaa8344a..1bbcb34837 100644
--- a/spec/ruby/library/uri/ldap/set_attributes_spec.rb
+++ b/spec/ruby/library/uri/ldap/set_attributes_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#set_attributes" do
diff --git a/spec/ruby/library/uri/ldap/set_dn_spec.rb b/spec/ruby/library/uri/ldap/set_dn_spec.rb
index c50ee6a98d..abb640b585 100644
--- a/spec/ruby/library/uri/ldap/set_dn_spec.rb
+++ b/spec/ruby/library/uri/ldap/set_dn_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#set_dn" do
diff --git a/spec/ruby/library/uri/ldap/set_extensions_spec.rb b/spec/ruby/library/uri/ldap/set_extensions_spec.rb
index 5a39da4607..5cd2077aab 100644
--- a/spec/ruby/library/uri/ldap/set_extensions_spec.rb
+++ b/spec/ruby/library/uri/ldap/set_extensions_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#set_extensions" do
diff --git a/spec/ruby/library/uri/ldap/set_filter_spec.rb b/spec/ruby/library/uri/ldap/set_filter_spec.rb
index c3ede20bb4..f1b8e5e595 100644
--- a/spec/ruby/library/uri/ldap/set_filter_spec.rb
+++ b/spec/ruby/library/uri/ldap/set_filter_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#set_filter" do
diff --git a/spec/ruby/library/uri/ldap/set_scope_spec.rb b/spec/ruby/library/uri/ldap/set_scope_spec.rb
index 43f3f68f86..5a0841cfd8 100644
--- a/spec/ruby/library/uri/ldap/set_scope_spec.rb
+++ b/spec/ruby/library/uri/ldap/set_scope_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::LDAP#set_scope" do
diff --git a/spec/ruby/library/uri/mailto/build_spec.rb b/spec/ruby/library/uri/mailto/build_spec.rb
index 2c011626ab..cb57f0c794 100644
--- a/spec/ruby/library/uri/mailto/build_spec.rb
+++ b/spec/ruby/library/uri/mailto/build_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Mailto.build" do
@@ -84,9 +84,15 @@ describe "URI::Mailto.build" do
end
bad.each do |x|
- -> { URI::MailTo.build(x) }.should raise_error(URI::InvalidComponentError)
+ lambda { URI::MailTo.build(x) }.should raise_error(URI::InvalidComponentError)
end
ok.flatten.join("\0").should == ok_all
end
end
+
+
+
+describe "URI::MailTo.build" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/headers_spec.rb b/spec/ruby/library/uri/mailto/headers_spec.rb
index 8aefec0e75..844fdee714 100644
--- a/spec/ruby/library/uri/mailto/headers_spec.rb
+++ b/spec/ruby/library/uri/mailto/headers_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::MailTo#headers" do
diff --git a/spec/ruby/library/uri/mailto/set_headers_spec.rb b/spec/ruby/library/uri/mailto/set_headers_spec.rb
index b6ce1a694b..c1384d5dca 100644
--- a/spec/ruby/library/uri/mailto/set_headers_spec.rb
+++ b/spec/ruby/library/uri/mailto/set_headers_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::MailTo#set_headers" do
diff --git a/spec/ruby/library/uri/mailto/set_to_spec.rb b/spec/ruby/library/uri/mailto/set_to_spec.rb
index eabc47f9a8..a8351a2092 100644
--- a/spec/ruby/library/uri/mailto/set_to_spec.rb
+++ b/spec/ruby/library/uri/mailto/set_to_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::MailTo#set_to" do
diff --git a/spec/ruby/library/uri/mailto/to_mailtext_spec.rb b/spec/ruby/library/uri/mailto/to_mailtext_spec.rb
index 3763a2d402..4c7a48874f 100644
--- a/spec/ruby/library/uri/mailto/to_mailtext_spec.rb
+++ b/spec/ruby/library/uri/mailto/to_mailtext_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::MailTo#to_mailtext" do
diff --git a/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb b/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb
index 2843b46848..e769f62deb 100644
--- a/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb
+++ b/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::MailTo#to_rfc822text" do
diff --git a/spec/ruby/library/uri/mailto/to_s_spec.rb b/spec/ruby/library/uri/mailto/to_s_spec.rb
index 746e8356eb..2709d19d27 100644
--- a/spec/ruby/library/uri/mailto/to_s_spec.rb
+++ b/spec/ruby/library/uri/mailto/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::MailTo#to_s" do
diff --git a/spec/ruby/library/uri/mailto/to_spec.rb b/spec/ruby/library/uri/mailto/to_spec.rb
index 68dfadd359..f30d23dd53 100644
--- a/spec/ruby/library/uri/mailto/to_spec.rb
+++ b/spec/ruby/library/uri/mailto/to_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::MailTo#to" do
diff --git a/spec/ruby/library/uri/merge_spec.rb b/spec/ruby/library/uri/merge_spec.rb
index e9644a7fd0..c62e80d6b2 100644
--- a/spec/ruby/library/uri/merge_spec.rb
+++ b/spec/ruby/library/uri/merge_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI#merge" do
diff --git a/spec/ruby/library/uri/normalize_spec.rb b/spec/ruby/library/uri/normalize_spec.rb
index 3d4451990a..079a9ad61d 100644
--- a/spec/ruby/library/uri/normalize_spec.rb
+++ b/spec/ruby/library/uri/normalize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/normalization'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/normalization', __FILE__)
require 'uri'
describe "URI#normalize" do
diff --git a/spec/ruby/library/uri/parse_spec.rb b/spec/ruby/library/uri/parse_spec.rb
index e9ec59b490..4aa84ae2ee 100644
--- a/spec/ruby/library/uri/parse_spec.rb
+++ b/spec/ruby/library/uri/parse_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "URI.parse" do
diff --git a/spec/ruby/library/uri/parser/escape_spec.rb b/spec/ruby/library/uri/parser/escape_spec.rb
index 66853d9fcb..8682e0ebce 100644
--- a/spec/ruby/library/uri/parser/escape_spec.rb
+++ b/spec/ruby/library/uri/parser/escape_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Parser#escape" do
diff --git a/spec/ruby/library/uri/parser/extract_spec.rb b/spec/ruby/library/uri/parser/extract_spec.rb
index 20d4565b08..5dac947060 100644
--- a/spec/ruby/library/uri/parser/extract_spec.rb
+++ b/spec/ruby/library/uri/parser/extract_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../shared/extract'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/extract', __FILE__)
require 'uri'
describe "URI::Parser#extract" do
diff --git a/spec/ruby/library/uri/parser/inspect_spec.rb b/spec/ruby/library/uri/parser/inspect_spec.rb
index 44fbd4077c..2eaeeeafee 100644
--- a/spec/ruby/library/uri/parser/inspect_spec.rb
+++ b/spec/ruby/library/uri/parser/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Parser#split" do
diff --git a/spec/ruby/library/uri/parser/join_spec.rb b/spec/ruby/library/uri/parser/join_spec.rb
index 0c9230be76..1800a16236 100644
--- a/spec/ruby/library/uri/parser/join_spec.rb
+++ b/spec/ruby/library/uri/parser/join_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../../spec_helper'
-require_relative '../shared/join'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/join', __FILE__)
require 'uri'
describe "URI::Parser#join" do
diff --git a/spec/ruby/library/uri/parser/make_regexp_spec.rb b/spec/ruby/library/uri/parser/make_regexp_spec.rb
index 0631d13ee6..e27f0d14db 100644
--- a/spec/ruby/library/uri/parser/make_regexp_spec.rb
+++ b/spec/ruby/library/uri/parser/make_regexp_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Parser#make_regexp" do
diff --git a/spec/ruby/library/uri/parser/parse_spec.rb b/spec/ruby/library/uri/parser/parse_spec.rb
index df126eab6d..76c1970645 100644
--- a/spec/ruby/library/uri/parser/parse_spec.rb
+++ b/spec/ruby/library/uri/parser/parse_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../../spec_helper'
-require_relative '../fixtures/classes'
-require_relative '../shared/parse'
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/parse', __FILE__)
describe "URI::Parser#parse" do
it_behaves_like :uri_parse, :parse, URI::Parser.new
diff --git a/spec/ruby/library/uri/parser/split_spec.rb b/spec/ruby/library/uri/parser/split_spec.rb
index 44fbd4077c..2eaeeeafee 100644
--- a/spec/ruby/library/uri/parser/split_spec.rb
+++ b/spec/ruby/library/uri/parser/split_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Parser#split" do
diff --git a/spec/ruby/library/uri/parser/unescape_spec.rb b/spec/ruby/library/uri/parser/unescape_spec.rb
index e18d2eb9d3..8ffc534226 100644
--- a/spec/ruby/library/uri/parser/unescape_spec.rb
+++ b/spec/ruby/library/uri/parser/unescape_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Parser#unescape" do
diff --git a/spec/ruby/library/uri/plus_spec.rb b/spec/ruby/library/uri/plus_spec.rb
index b84b0767c1..45c1aa5e57 100644
--- a/spec/ruby/library/uri/plus_spec.rb
+++ b/spec/ruby/library/uri/plus_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
#an alias of URI#merge
@@ -31,12 +31,12 @@ describe "URI#+" do
(URI.parse('http://a/b/c/../../../') + ".").should == URI("http://a/")
end
- it "doesn't canonicalize the path when adding to the empty string" do
+ it "doesn't conconicalize the path when adding to the empty string" do
(URI.parse('http://a/b/c/../') + "").should == URI("http://a/b/c/../")
end
it "raises a URI::BadURIError when adding two relative URIs" do
- -> {URI.parse('a/b/c') + "d"}.should raise_error(URI::BadURIError)
+ lambda {URI.parse('a/b/c') + "d"}.should raise_error(URI::BadURIError)
end
#Todo: make more BDD?
diff --git a/spec/ruby/library/uri/regexp_spec.rb b/spec/ruby/library/uri/regexp_spec.rb
index 6e8b3df4d0..cf63507013 100644
--- a/spec/ruby/library/uri/regexp_spec.rb
+++ b/spec/ruby/library/uri/regexp_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
#I'm more or less ok with these limited tests, as the more extensive extract tests
diff --git a/spec/ruby/library/uri/route_from_spec.rb b/spec/ruby/library/uri/route_from_spec.rb
index 501f455775..11a2c44f90 100644
--- a/spec/ruby/library/uri/route_from_spec.rb
+++ b/spec/ruby/library/uri/route_from_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI#route_from" do
diff --git a/spec/ruby/library/uri/route_to_spec.rb b/spec/ruby/library/uri/route_to_spec.rb
index ae9d38d23d..2eb68afdfd 100644
--- a/spec/ruby/library/uri/route_to_spec.rb
+++ b/spec/ruby/library/uri/route_to_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI#route_to" do
diff --git a/spec/ruby/library/uri/select_spec.rb b/spec/ruby/library/uri/select_spec.rb
index 839b68b3a1..46474757cc 100644
--- a/spec/ruby/library/uri/select_spec.rb
+++ b/spec/ruby/library/uri/select_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI#select" do
@@ -15,12 +15,16 @@ describe "URI#select" do
end
it "raises an ArgumentError if a component is requested that isn't valid under the given scheme" do
- -> { URI("mailto:spam@mailinator.com").select(:path) }.should raise_error(ArgumentError)
- -> { URI("http://blog.blag.web").select(:typecode) }.should raise_error(ArgumentError)
+ [
+ lambda {URI("mailto:spam@mailinator.com").select(:path)},
+ lambda {URI("http://blog.blag.web").select(:typecode)},
+ ].each do |select_lambda|
+ select_lambda.should raise_error(ArgumentError)
+ end
end
it "raises an ArgumentError if given strings rather than symbols" do
- -> {
+ lambda {
URI("http://host:8080/path/").select("scheme","host","port",'path')
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/uri/set_component_spec.rb b/spec/ruby/library/uri/set_component_spec.rb
index 642a5d6fcf..9b8372108a 100644
--- a/spec/ruby/library/uri/set_component_spec.rb
+++ b/spec/ruby/library/uri/set_component_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
#TODO: make this more BDD
@@ -27,19 +27,21 @@ describe "URI#select" do
uri.to_s.should == 'http://foo:bar@zab:8080/?a=1#b123'
uri = URI.parse('http://example.com')
- -> { uri.password = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.password = 'bar' }.should raise_error(URI::InvalidURIError)
uri.userinfo = 'foo:bar'
uri.to_s.should == 'http://foo:bar@example.com'
- -> { uri.registry = 'bar' }.should raise_error(URI::InvalidURIError)
- -> { uri.opaque = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.registry = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.opaque = 'bar' }.should raise_error(URI::InvalidURIError)
uri = URI.parse('mailto:foo@example.com')
- -> { uri.user = 'bar' }.should raise_error(URI::InvalidURIError)
- -> { uri.password = 'bar' }.should raise_error(URI::InvalidURIError)
- -> { uri.userinfo = ['bar', 'baz'] }.should raise_error(URI::InvalidURIError)
- -> { uri.host = 'bar' }.should raise_error(URI::InvalidURIError)
- -> { uri.port = 'bar' }.should raise_error(URI::InvalidURIError)
- -> { uri.path = 'bar' }.should raise_error(URI::InvalidURIError)
- -> { uri.query = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.user = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.password = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.userinfo = ['bar', 'baz'] }.should raise_error(URI::InvalidURIError)
+ lambda { uri.host = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.port = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.path = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.query = 'bar' }.should raise_error(URI::InvalidURIError)
end
end
+
+
diff --git a/spec/ruby/library/uri/shared/join.rb b/spec/ruby/library/uri/shared/join.rb
index 4df0782b37..ff85b57a80 100644
--- a/spec/ruby/library/uri/shared/join.rb
+++ b/spec/ruby/library/uri/shared/join.rb
@@ -18,7 +18,7 @@ describe :uri_join, shared: true do
end
it "raises an error if given no argument" do
- -> {
+ lambda {
@object.join
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/library/uri/shared/parse.rb b/spec/ruby/library/uri/shared/parse.rb
index 87e1ee933e..5ecbffcaf2 100644
--- a/spec/ruby/library/uri/shared/parse.rb
+++ b/spec/ruby/library/uri/shared/parse.rb
@@ -193,7 +193,7 @@ describe :uri_parse, shared: true do
end
it "raises errors on malformed URIs" do
- -> { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError)
- -> { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError)
+ lambda { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError)
+ lambda { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError)
end
end
diff --git a/spec/ruby/library/uri/split_spec.rb b/spec/ruby/library/uri/split_spec.rb
index 9ad37e3b1f..f0ab6ff35c 100644
--- a/spec/ruby/library/uri/split_spec.rb
+++ b/spec/ruby/library/uri/split_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
describe "URI.split" do
diff --git a/spec/ruby/library/uri/uri_spec.rb b/spec/ruby/library/uri/uri_spec.rb
index 45a7502052..90936a770f 100644
--- a/spec/ruby/library/uri/uri_spec.rb
+++ b/spec/ruby/library/uri/uri_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'uri'
#the testing is light here as this is an alias for URI.parse
@@ -24,6 +24,6 @@ describe "the URI method" do
#apparently this was a concern? imported from MRI tests
it "does not add a URI method to Object instances" do
- -> {Object.new.URI("http://ruby-lang.org/")}.should raise_error(NoMethodError)
+ lambda {Object.new.URI("http://ruby-lang.org/")}.should raise_error(NoMethodError)
end
end
diff --git a/spec/ruby/library/uri/util/make_components_hash_spec.rb b/spec/ruby/library/uri/util/make_components_hash_spec.rb
index 6d26b81130..0f491112e8 100644
--- a/spec/ruby/library/uri/util/make_components_hash_spec.rb
+++ b/spec/ruby/library/uri/util/make_components_hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'uri'
describe "URI::Util.make_components_hash" do
diff --git a/spec/ruby/library/weakref/__getobj___spec.rb b/spec/ruby/library/weakref/__getobj___spec.rb
index 79b06f5c96..e75b8f4704 100644
--- a/spec/ruby/library/weakref/__getobj___spec.rb
+++ b/spec/ruby/library/weakref/__getobj___spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "WeakRef#__getobj__" do
it "returns the object if it is reachable" do
@@ -10,7 +10,7 @@ describe "WeakRef#__getobj__" do
it "raises WeakRef::RefError if the object is no longer reachable" do
ref = WeakRefSpec.make_dead_weakref
- -> {
+ lambda {
ref.__getobj__
}.should raise_error(WeakRef::RefError)
end
diff --git a/spec/ruby/library/weakref/allocate_spec.rb b/spec/ruby/library/weakref/allocate_spec.rb
deleted file mode 100644
index e734cfd23d..0000000000
--- a/spec/ruby/library/weakref/allocate_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require 'weakref'
-
-describe "WeakRef#allocate" do
- it "assigns nil as the reference" do
- -> { WeakRef.allocate.__getobj__ }.should raise_error(WeakRef::RefError)
- end
-end
diff --git a/spec/ruby/library/weakref/new_spec.rb b/spec/ruby/library/weakref/new_spec.rb
deleted file mode 100644
index 6290e61fe3..0000000000
--- a/spec/ruby/library/weakref/new_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../spec_helper'
-require 'weakref'
-
-describe "WeakRef#new" do
- it "creates a subclass correctly" do
- wr2 = Class.new(WeakRef) {
- def __getobj__
- :dummy
- end
- }
- wr2.new(Object.new).__getobj__.should == :dummy
- end
-end
diff --git a/spec/ruby/library/weakref/send_spec.rb b/spec/ruby/library/weakref/send_spec.rb
index 9591657e01..173e1055dd 100644
--- a/spec/ruby/library/weakref/send_spec.rb
+++ b/spec/ruby/library/weakref/send_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'weakref'
describe "WeakRef#__send__" do
@@ -27,11 +27,11 @@ describe "WeakRef#__send__" do
it "delegates to protected methods of the weakly-referenced object" do
wr = WeakRef.new(WeakRefSpecs)
- -> { wr.protected_method }.should raise_error(NameError)
+ lambda { wr.protected_method }.should raise_error(NameError)
end
it "does not delegate to private methods of the weakly-referenced object" do
wr = WeakRef.new(WeakRefSpecs)
- -> { wr.private_method }.should raise_error(NameError)
+ lambda { wr.private_method }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/library/weakref/weakref_alive_spec.rb b/spec/ruby/library/weakref/weakref_alive_spec.rb
index 173ea01485..b3c2eab620 100644
--- a/spec/ruby/library/weakref/weakref_alive_spec.rb
+++ b/spec/ruby/library/weakref/weakref_alive_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "WeakRef#weakref_alive?" do
it "returns true if the object is reachable" do
@@ -8,7 +8,7 @@ describe "WeakRef#weakref_alive?" do
ref.weakref_alive?.should == true
end
- it "returns a falsy value if the object is no longer reachable" do
+ it "returns a falsey value if the object is no longer reachable" do
ref = WeakRefSpec.make_dead_weakref
[false, nil].should include(ref.weakref_alive?)
end
diff --git a/spec/ruby/library/win32ole/fixtures/classes.rb b/spec/ruby/library/win32ole/fixtures/classes.rb
index f61cf6ba69..830b1be0b5 100644
--- a/spec/ruby/library/win32ole/fixtures/classes.rb
+++ b/spec/ruby/library/win32ole/fixtures/classes.rb
@@ -1,22 +1,14 @@
-require 'win32ole'
-
module WIN32OLESpecs
- MSXML_AVAILABLE = WIN32OLE_TYPELIB.typelibs.any? { |t| t.name.start_with?('Microsoft XML') }
- SYSTEM_MONITOR_CONTROL_AVAILABLE = WIN32OLE_TYPELIB.typelibs.any? { |t| t.name.start_with?('System Monitor Control') }
-
def self.new_ole(name)
- tries = 0
+ retried = false
begin
WIN32OLE.new(name)
rescue WIN32OLERuntimeError => e
- if tries < 3
- tries += 1
- $stderr.puts "WIN32OLESpecs#new_ole retry (#{tries}): #{e.class}: #{e.message}"
- sleep(2 ** tries)
+ unless retried
+ retried = true
retry
- else
- raise
end
+ raise e
end
end
end
diff --git a/spec/ruby/library/win32ole/fixtures/event.xml b/spec/ruby/library/win32ole/fixtures/event.xml
deleted file mode 100644
index 23f3d2b126..0000000000
--- a/spec/ruby/library/win32ole/fixtures/event.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<program>
- <name>Ruby</name>
- <version>trunk</version>
-</program>
diff --git a/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb
index 940eebfb91..650a641f5b 100644
--- a/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb
@@ -1,14 +1,19 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#_getproperty" do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
- it "gets value" do
- @dict.add('key', 'value')
- @dict._getproperty(0, ['key'], [WIN32OLE::VARIANT::VT_BSTR]).should == 'value'
+ it "gets name" do
+ @ie._getproperty(0, [], []).should =~ /explorer/i
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb
index 91f5091d24..c2fe9a8490 100644
--- a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#_invoke" do
before :each do
@@ -7,9 +9,9 @@ platform_is :windows do
end
it "raises ArgumentError if insufficient number of arguments are given" do
- -> { @shell._invoke() }.should raise_error ArgumentError
- -> { @shell._invoke(0) }.should raise_error ArgumentError
- -> { @shell._invoke(0, []) }.should raise_error ArgumentError
+ lambda { @shell._invoke() }.should raise_error ArgumentError
+ lambda { @shell._invoke(0) }.should raise_error ArgumentError
+ lambda { @shell._invoke(0, []) }.should raise_error ArgumentError
end
it "dispatches the method bound to a specific ID" do
diff --git a/spec/ruby/library/win32ole/win32ole/codepage_spec.rb b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb
index 4e0cf5ca55..c84593871d 100644
--- a/spec/ruby/library/win32ole/win32ole/codepage_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE.codepage=" do
it "sets codepage" do
diff --git a/spec/ruby/library/win32ole/win32ole/connect_spec.rb b/spec/ruby/library/win32ole/win32ole/connect_spec.rb
index 72dceb1572..ee480a727c 100644
--- a/spec/ruby/library/win32ole/win32ole/connect_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/connect_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE.connect" do
it "creates WIN32OLE object given valid argument" do
@@ -8,7 +10,7 @@ platform_is :windows do
end
it "raises TypeError when given invalid argument" do
- -> { WIN32OLE.connect 1 }.should raise_error TypeError
+ lambda { WIN32OLE.connect 1 }.should raise_error TypeError
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb
index cacc7a2b22..a3c50f215e 100644
--- a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE.const_load when passed Shell.Application OLE object" do
before :each do
diff --git a/spec/ruby/library/win32ole/win32ole/constants_spec.rb b/spec/ruby/library/win32ole/win32ole/constants_spec.rb
index 978b7ade92..2a04511305 100644
--- a/spec/ruby/library/win32ole/win32ole/constants_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/constants_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE class" do
it "defines constant CP_ACP" do
diff --git a/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb
index 2e18b6ab11..17a7df10be 100644
--- a/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE.create_guid" do
it "generates guid with valid format" do
diff --git a/spec/ruby/library/win32ole/win32ole/invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb
index 08a5156e05..41752de359 100644
--- a/spec/ruby/library/win32ole/win32ole/invoke_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb
@@ -1,14 +1,19 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#invoke" do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
- it "get value by invoking 'Item' OLE method" do
- @dict.add('key', 'value')
- @dict.invoke('Item', 'key').should == 'value'
+ it "get name by invoking 'Name' OLE method" do
+ @ie.invoke('Name').should =~ /explorer/i
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/locale_spec.rb b/spec/ruby/library/win32ole/win32ole/locale_spec.rb
index 75a82ddd7f..7cf4d9bc98 100644
--- a/spec/ruby/library/win32ole/win32ole/locale_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/locale_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE.locale" do
it "gets locale" do
@@ -19,7 +21,7 @@ platform_is :windows do
WIN32OLE.locale.should == 1041
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
- -> { WIN32OLE.locale = 111 }.should raise_error WIN32OLERuntimeError
+ lambda { WIN32OLE.locale = 111 }.should raise_error WIN32OLERuntimeError
WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT
ensure
WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT
diff --git a/spec/ruby/library/win32ole/win32ole/new_spec.rb b/spec/ruby/library/win32ole/win32ole/new_spec.rb
index 6b717195f1..78f141b608 100644
--- a/spec/ruby/library/win32ole/win32ole/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/new_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLESpecs.new_ole" do
it "creates a WIN32OLE object from OLE server name" do
@@ -13,11 +15,11 @@ platform_is :windows do
end
it "raises TypeError if argument cannot be converted to String" do
- -> { WIN32OLESpecs.new_ole(42) }.should raise_error( TypeError )
+ lambda { WIN32OLESpecs.new_ole(42) }.should raise_error( TypeError )
end
it "raises WIN32OLERuntimeError if invalid string is given" do
- -> { WIN32OLE.new('foo') }.should raise_error( WIN32OLERuntimeError )
+ lambda { WIN32OLESpecs.new_ole('foo') }.should raise_error( WIN32OLERuntimeError )
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
index 75748182fe..82b5eb2680 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
@@ -1,21 +1,27 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#ole_func_methods" do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
it "raises ArgumentError if argument is given" do
- -> { @dict.ole_func_methods(1) }.should raise_error ArgumentError
+ lambda { @ie.ole_func_methods(1) }.should raise_error ArgumentError
end
it "returns an array of WIN32OLE_METHODs" do
- @dict.ole_func_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true
+ @ie.ole_func_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true
end
- it "contains a 'AddRef' method for Scripting Dictionary" do
- @dict.ole_func_methods.map { |m| m.name }.include?('AddRef').should be_true
+ it "contains a 'AddRef' method for Internet Explorer" do
+ @ie.ole_func_methods.map { |m| m.name }.include?('AddRef').should be_true
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb
index a991624a23..3ec92d3efc 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb
@@ -1,5 +1,7 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#ole_get_methods" do
diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb
index 8a26d79a20..45b8e93eac 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb
@@ -1,6 +1,8 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/ole_method', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
- require_relative 'shared/ole_method'
+ require 'win32ole'
describe "WIN32OLE#ole_method_help" do
it_behaves_like :win32ole_ole_method, :ole_method_help
diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb
index f82a212f5d..cb1d1d172b 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb
@@ -1,6 +1,8 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/ole_method', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
- require_relative 'shared/ole_method'
+ require 'win32ole'
describe "WIN32OLE#ole_method" do
it_behaves_like :win32ole_ole_method, :ole_method
diff --git a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb
index 5ac9ae9cfa..bba2aa73ae 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb
@@ -1,21 +1,27 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#ole_methods" do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
it "raises ArgumentError if argument is given" do
- -> { @dict.ole_methods(1) }.should raise_error ArgumentError
+ lambda { @ie.ole_methods(1) }.should raise_error ArgumentError
end
it "returns an array of WIN32OLE_METHODs" do
- @dict.ole_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true
+ @ie.ole_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true
end
- it "contains a 'AddRef' method for Scripting Dictionary" do
- @dict.ole_methods.map { |m| m.name }.include?('AddRef').should be_true
+ it "contains a 'AddRef' method for Internet Explorer" do
+ @ie.ole_methods.map { |m| m.name }.include?('AddRef').should be_true
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb
index ef8944ee39..eede93bb87 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb
@@ -1,18 +1,23 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#ole_obj_help" do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
it "raises ArgumentError if argument is given" do
- -> { @dict.ole_obj_help(1) }.should raise_error ArgumentError
+ lambda { @ie.ole_obj_help(1) }.should raise_error ArgumentError
end
it "returns an instance of WIN32OLE_TYPE" do
- @dict.ole_obj_help.kind_of?(WIN32OLE_TYPE).should be_true
+ @ie.ole_obj_help.kind_of?(WIN32OLE_TYPE).should be_true
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb
index 727291e9f0..5334e7a47d 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb
@@ -1,21 +1,27 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
describe "WIN32OLE#ole_put_methods" do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
it "raises ArgumentError if argument is given" do
- -> { @dict.ole_put_methods(1) }.should raise_error ArgumentError
+ lambda { @ie.ole_put_methods(1) }.should raise_error ArgumentError
end
it "returns an array of WIN32OLE_METHODs" do
- @dict.ole_put_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true
+ @ie.ole_put_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true
end
- it "contains a 'Key' method for Scripting Dictionary" do
- @dict.ole_put_methods.map { |m| m.name }.include?('Key').should be_true
+ it "contains a 'Height' method for Internet Explorer" do
+ @ie.ole_put_methods.map { |m| m.name }.include?('Height').should be_true
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb
index 7409823f20..ae08e63f78 100644
--- a/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb
@@ -1,6 +1,8 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../shared/setproperty', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
- require_relative 'shared/setproperty'
+ require 'win32ole'
describe "WIN32OLE#setproperty" do
it_behaves_like :win32ole_setproperty, :setproperty
diff --git a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb
index f1fd8713a4..668000c1fc 100644
--- a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb
+++ b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb
@@ -1,19 +1,25 @@
+require File.expand_path('../../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../../fixtures/classes'
+ require 'win32ole'
describe :win32ole_ole_method, shared: true do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
it "raises ArgumentError if no argument is given" do
- -> { @dict.send(@method) }.should raise_error ArgumentError
+ lambda { @ie.send(@method) }.should raise_error ArgumentError
end
- it "returns the WIN32OLE_METHOD 'Add' if given 'Add'" do
- result = @dict.send(@method, "Add")
+ it "returns the WIN32OLE_METHOD 'Quit' if given 'Quit'" do
+ result = @ie.send(@method, "Quit")
result.kind_of?(WIN32OLE_METHOD).should be_true
- result.name.should == 'Add'
+ result.name.should == 'Quit'
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb
index b9267aef71..9703e402bf 100644
--- a/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb
+++ b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb
@@ -1,23 +1,25 @@
+require File.expand_path('../../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../../fixtures/classes'
+ require 'win32ole'
describe :win32ole_setproperty, shared: true do
before :each do
- @dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
+
+ after :each do
+ @ie.Quit
end
it "raises ArgumentError if no argument is given" do
- -> { @dict.send(@method) }.should raise_error ArgumentError
+ lambda { @ie.send(@method) }.should raise_error ArgumentError
end
- it "sets key to newkey and returns nil" do
- oldkey = 'oldkey'
- newkey = 'newkey'
- @dict.add(oldkey, 'value')
- result = @dict.send(@method, 'Key', oldkey, newkey)
+ it "sets height to 500 and returns nil" do
+ height = 500
+ result = @ie.send(@method, 'Height', height)
result.should == nil
- @dict[oldkey].should == nil
- @dict[newkey].should == 'value'
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb
index a1a1612393..5fffac535e 100644
--- a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb
@@ -1,33 +1,33 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
+ require 'win32ole'
- guard -> { WIN32OLESpecs::MSXML_AVAILABLE } do
- describe "WIN32OLE_EVENT.new" do
- before :all do
- @xml_dom = WIN32OLESpecs.new_ole('MSXML.DOMDocument')
- end
+ describe "WIN32OLE_EVENT.new" do
+ before :each do
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ end
- after :all do
- @xml_dom = nil
- end
+ after :each do
+ @ie.Quit if @ie
+ end
- it "raises TypeError given invalid argument" do
- -> { WIN32OLE_EVENT.new "A" }.should raise_error TypeError
- end
+ it "raises TypeError given invalid argument" do
+ lambda { WIN32OLE_EVENT.new "A" }.should raise_error TypeError
+ end
- it "raises RuntimeError if event does not exist" do
- -> { WIN32OLE_EVENT.new(@xml_dom, 'A') }.should raise_error RuntimeError
- end
+ it "raises RuntimeError if event does not exist" do
+ lambda { WIN32OLE_EVENT.new(@ie, 'A') }.should raise_error RuntimeError
+ end
- it "raises RuntimeError if OLE object has no events" do
- dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
- -> { WIN32OLE_EVENT.new(dict) }.should raise_error RuntimeError
- end
+ it "raises RuntimeError if OLE object has no events" do
+ dict = WIN32OLESpecs.new_ole('Scripting.Dictionary')
+ lambda { WIN32OLE_EVENT.new(dict) }.should raise_error RuntimeError
+ end
- it "creates WIN32OLE_EVENT object" do
- ev = WIN32OLE_EVENT.new(@xml_dom)
- ev.should be_kind_of WIN32OLE_EVENT
- end
+ it "creates WIN32OLE_EVENT object" do
+ ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ ev.should be_kind_of WIN32OLE_EVENT
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
index feb26b0637..6bf8d2e1da 100644
--- a/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
@@ -1,70 +1,62 @@
+require File.expand_path('../../fixtures/classes', __FILE__)
+
platform_is :windows do
- require_relative '../fixtures/classes'
- guard -> { WIN32OLESpecs::MSXML_AVAILABLE } do
+ require 'win32ole'
- def handler_global(event, *args)
- @event_global += event
- end
+ def default_handler(event, *args)
+ @event += event
+ end
- def handler_specific(*args)
- @event_specific = "specific"
- end
+ def alternate_handler(event, *args)
+ @event2 = "alternate"
+ end
- def handler_spec_alt(*args)
- @event_spec_alt = "spec_alt"
- end
+ def handler3(event, *args)
+ @event3 += event
+ end
- describe "WIN32OLE_EVENT#on_event" do
- before :all do
- @fn_xml = File.absolute_path "../fixtures/event.xml", __dir__
- end
- before :each do
- @xml_dom = WIN32OLESpecs.new_ole 'MSXML.DOMDocument'
- @xml_dom.async = true
- @ev = WIN32OLE_EVENT.new @xml_dom
- @event_global = ''
- @event_specific = ''
- @event_spec_alt = ''
- end
+ describe "WIN32OLE_EVENT#on_event with no argument" do
+ before :each do
+ @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application')
+ @ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ @event = ''
+ @event2 = ''
+ @event3 = ''
+ @ie.StatusBar = true
+ end
- after :each do
- @xml_dom = nil
- @ev = nil
- end
+ after :each do
+ @ie.Quit
+ end
- it "sets global event handler properly, and the handler is invoked by event loop" do
- @ev.on_event { |*args| handler_global(*args) }
- @xml_dom.loadXML "<program><name>Ruby</name><version>trunk</version></program>"
- WIN32OLE_EVENT.message_loop
- @event_global.should =~ /onreadystatechange/
- end
+ it "sets event handler properly, and the handler is invoked by event loop" do
+ @ev.on_event { |*args| default_handler(*args) }
+ @ie.StatusText='hello'
+ WIN32OLE_EVENT.message_loop
+ @event.should =~ /StatusTextChange/
+ end
- it "accepts a String argument and the handler is invoked by event loop" do
- @ev.on_event("onreadystatechange") { |*args| @event = 'foo' }
- @xml_dom.loadXML "<program><name>Ruby</name><version>trunk</version></program>"
- WIN32OLE_EVENT.message_loop
- @event.should =~ /foo/
- end
+ it "accepts a String argument, sets event handler properly, and the handler is invoked by event loop" do
+ @ev.on_event("StatusTextChange") { |*args| @event = 'foo' }
+ @ie.StatusText='hello'
+ WIN32OLE_EVENT.message_loop
+ @event.should =~ /foo/
+ end
- it "accepts a Symbol argument and the handler is invoked by event loop" do
- @ev.on_event(:onreadystatechange) { |*args| @event = 'bar' }
- @xml_dom.loadXML "<program><name>Ruby</name><version>trunk</version></program>"
- WIN32OLE_EVENT.message_loop
- @event.should =~ /bar/
- end
+ it "registers multiple event handlers for the same event" do
+ @ev.on_event("StatusTextChange") { |*args| default_handler(*args) }
+ @ev.on_event("StatusTextChange") { |*args| alternate_handler(*args) }
+ @ie.StatusText= 'hello'
+ WIN32OLE_EVENT.message_loop
+ @event2.should == 'alternate'
+ end
- it "accepts a specific event handler and overrides a global event handler" do
- @ev.on_event { |*args| handler_global(*args) }
- @ev.on_event("onreadystatechange") { |*args| handler_specific(*args) }
- @ev.on_event("onreadystatechange") { |*args| handler_spec_alt(*args) }
- @xml_dom.load @fn_xml
- WIN32OLE_EVENT.message_loop
- @event_global.should == 'ondataavailable'
- @event_global.should_not =~ /onreadystatechange/
- @event_specific.should == ''
- @event_spec_alt.should == "spec_alt"
- end
+ it "accepts a Symbol argument, sets event handler properly, and the handler is invoked by event loop" do
+ @ev.on_event(:StatusTextChange) { |*args| @event = 'foo' }
+ @ie.StatusText='hello'
+ WIN32OLE_EVENT.message_loop
+ @event.should =~ /foo/
end
end
end
diff --git a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb
index 69068683b7..840cdf72b8 100644
--- a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m.dispid(0) }.should raise_error ArgumentError
+ lambda { @m.dispid(0) }.should raise_error ArgumentError
end
it "returns expected dispatch ID for Shell's 'namespace' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb
index 70c8b30cca..9d3ca2b8e4 100644
--- a/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb
@@ -1,28 +1,26 @@
platform_is :windows do
- require_relative '../fixtures/classes'
- guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do
+ require 'win32ole'
- describe "WIN32OLE_METHOD#event_interface" do
- before :each do
- ole_type = WIN32OLE_TYPE.new("System Monitor Control", "SystemMonitor")
- @on_dbl_click_method = WIN32OLE_METHOD.new(ole_type, "OnDblClick")
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
- @namespace_method = WIN32OLE_METHOD.new(ole_type, "namespace")
- end
-
- it "raises ArgumentError if argument is given" do
- -> { @on_dbl_click_method.event_interface(1) }.should raise_error ArgumentError
- end
+ describe "WIN32OLE_METHOD#event_interface" do
+ before :each do
+ ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser")
+ @navigate_method = WIN32OLE_METHOD.new(ole_type, "NavigateComplete")
+ ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
+ @namespace_method = WIN32OLE_METHOD.new(ole_type, "namespace")
+ end
- it "returns expected string for System Monitor Control's 'OnDblClick' method" do
- @on_dbl_click_method.event_interface.should == "DISystemMonitorEvents"
- end
+ it "raises ArgumentError if argument is given" do
+ lambda { @navigate_method.event_interface(1) }.should raise_error ArgumentError
+ end
- it "returns nil if method has no event interface" do
- @namespace_method.event_interface.should be_nil
- end
+ it "returns expected string for browser's 'NavigateComplete' method" do
+ @navigate_method.event_interface.should == "DWebBrowserEvents"
+ end
+ it "returns nil if method has no event interface" do
+ @namespace_method.event_interface.should be_nil
end
+
end
end
diff --git a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb
index c41f8fe99d..25435438aa 100644
--- a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb
@@ -1,22 +1,20 @@
platform_is :windows do
- require_relative '../fixtures/classes'
- guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do
+ require 'win32ole'
- describe "WIN32OLE_METHOD#event?" do
- before :each do
- ole_type = WIN32OLE_TYPE.new("System Monitor Control", "SystemMonitor")
- @on_dbl_click_method = WIN32OLE_METHOD.new(ole_type, "OnDblClick")
- end
-
- it "raises ArgumentError if argument is given" do
- -> { @on_dbl_click_method.event?(1) }.should raise_error ArgumentError
- end
+ describe "WIN32OLE_METHOD#event?" do
+ before :each do
+ ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser")
+ @navigate_method = WIN32OLE_METHOD.new(ole_type, "NavigateComplete")
+ end
- it "returns true for System Monitor Control's 'OnDblClick' method" do
- @on_dbl_click_method.event?.should be_true
- end
+ it "raises ArgumentError if argument is given" do
+ lambda { @navigate_method.event?(1) }.should raise_error ArgumentError
+ end
+ it "returns true for browser's 'NavigateComplete' method" do
+ @navigate_method.event?.should be_true
end
+
end
end
diff --git a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb
index 21b3ae8bde..c0e66a7a18 100644
--- a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb
@@ -3,18 +3,18 @@ platform_is :windows do
describe "WIN32OLE_METHOD#helpcontext" do
before :each do
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject")
- @get_file_version = WIN32OLE_METHOD.new(ole_type, "GetFileVersion")
+ ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser")
+ @navigate_method = WIN32OLE_METHOD.new(ole_type, "NavigateComplete")
ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File")
@m_file_name = WIN32OLE_METHOD.new(ole_type, "name")
end
it "raises ArgumentError if argument is given" do
- -> { @get_file_version.helpcontext(1) }.should raise_error ArgumentError
+ lambda { @navigate_method.helpcontext(1) }.should raise_error ArgumentError
end
- it "returns expected value for FileSystemObject's 'GetFileVersion' method" do
- @get_file_version.helpcontext.should == 0
+ it "returns expected value for browser's 'NavigateComplete' method" do
+ @navigate_method.helpcontext.should == 0
end
it "returns expected value for Scripting Runtime's 'name' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb
index b6d0a19a37..72cc4da16b 100644
--- a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.helpfile(1) }.should raise_error ArgumentError
+ lambda { @m_file_name.helpfile(1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'File' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb
index 9f940fd4a0..60105d0aa2 100644
--- a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.helpstring(1) }.should raise_error ArgumentError
+ lambda { @m_file_name.helpstring(1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'File' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb
index 7fff479daf..cf0a74bbce 100644
--- a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.invkind(1) }.should raise_error ArgumentError
+ lambda { @m_file_name.invkind(1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'name' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb
index e8638abd91..4d2af8fb0c 100644
--- a/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.invoke_kind(1) }.should raise_error ArgumentError
+ lambda { @m_file_name.invoke_kind(1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'name' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/name_spec.rb b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb
index cd5404fc54..0c2b3eeba0 100644
--- a/spec/ruby/library/win32ole/win32ole_method/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb
index 8ebf93b992..f904107c6c 100644
--- a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb
@@ -7,12 +7,12 @@ platform_is :windows do
end
it "raises TypeError when given non-strings" do
- -> { WIN32OLE_METHOD.new(1, 2) }.should raise_error TypeError
+ lambda { WIN32OLE_METHOD.new(1, 2) }.should raise_error TypeError
end
it "raises ArgumentError if only 1 argument is given" do
- -> { WIN32OLE_METHOD.new("hello") }.should raise_error ArgumentError
- -> { WIN32OLE_METHOD.new(@ole_type) }.should raise_error ArgumentError
+ lambda { WIN32OLE_METHOD.new("hello") }.should raise_error ArgumentError
+ lambda { WIN32OLE_METHOD.new(@ole_type) }.should raise_error ArgumentError
end
it "returns a valid WIN32OLE_METHOD object" do
@@ -21,11 +21,11 @@ platform_is :windows do
end
it "raises WIN32OLERuntimeError if the method does not exist" do
- -> { WIN32OLE_METHOD.new(@ole_type, "NonexistentMethod") }.should raise_error WIN32OLERuntimeError
+ lambda { WIN32OLE_METHOD.new(@ole_type, "NonexistentMethod") }.should raise_error WIN32OLERuntimeError
end
it "raises TypeError if second argument is not a String" do
- -> { WIN32OLE_METHOD.new(@ole_type, 5) }.should raise_error TypeError
+ lambda { WIN32OLE_METHOD.new(@ole_type, 5) }.should raise_error TypeError
end
end
diff --git a/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb
index 8e50c39787..e436441409 100644
--- a/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb
@@ -8,11 +8,11 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.offset_vtbl(1) }.should raise_error ArgumentError
+ lambda { @m_file_name.offset_vtbl(1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'name' method" do
- pointer_size = PlatformGuard::POINTER_SIZE
+ pointer_size = RUBY_PLATFORM =~ /\bx64\b/ ? 64 : 1.size * 8
@m_file_name.offset_vtbl.should == pointer_size
end
diff --git a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb
index 2f8da3d45b..08c7f04bdd 100644
--- a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb
@@ -10,7 +10,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.params(1) }.should raise_error ArgumentError
+ lambda { @m_file_name.params(1) }.should raise_error ArgumentError
end
it "returns empty array for Scripting Runtime's 'name' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb
index f8ce3e1b3a..b8f2bbe084 100644
--- a/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_browse_for_folder.return_type_detail(1) }.should raise_error ArgumentError
+ lambda { @m_browse_for_folder.return_type_detail(1) }.should raise_error ArgumentError
end
it "returns expected value for Shell Control's 'BrowseForFolder' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb
index 58e26df77b..b68481fe59 100644
--- a/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.return_type(1) }.should raise_error ArgumentError
+ lambda { @m_file_name.return_type(1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'name' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb
index dc159dd09e..f236de01f9 100644
--- a/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_browse_for_folder.return_vtype(1) }.should raise_error ArgumentError
+ lambda { @m_browse_for_folder.return_vtype(1) }.should raise_error ArgumentError
end
it "returns expected value for Shell Control's 'BrowseForFolder' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/shared/name.rb b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb
index ddaff4011b..2be6478a6e 100644
--- a/spec/ruby/library/win32ole/win32ole_method/shared/name.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_file_name.send(@method, 1) }.should raise_error ArgumentError
+ lambda { @m_file_name.send(@method, 1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'name' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb
index a38fe5c681..a63c50474c 100644
--- a/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_browse_for_folder.size_opt_params(1) }.should raise_error ArgumentError
+ lambda { @m_browse_for_folder.size_opt_params(1) }.should raise_error ArgumentError
end
it "returns expected value for Shell Control's 'BrowseForFolder' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb
index 0c5a94c338..fe93d5bc66 100644
--- a/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_browse_for_folder.size_params(1) }.should raise_error ArgumentError
+ lambda { @m_browse_for_folder.size_params(1) }.should raise_error ArgumentError
end
it "returns expected value for Shell Control's 'BrowseForFolder' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb
index ecb3c08038..95fd2fcdb5 100644
--- a/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb
index 918b6ef782..b49fac6066 100644
--- a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb
@@ -8,7 +8,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @m_browse_for_folder.visible?(1) }.should raise_error ArgumentError
+ lambda { @m_browse_for_folder.visible?(1) }.should raise_error ArgumentError
end
it "returns true for Shell Control's 'BrowseForFolder' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb
index af08c84782..7a1337ec7c 100644
--- a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb
@@ -13,7 +13,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @params[0].default(1) }.should raise_error ArgumentError
+ lambda { @params[0].default(1) }.should raise_error ArgumentError
end
it "returns nil for each of WIN32OLE_PARAM for Shell's 'BrowseForFolder' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb
index a0022fef13..bdf4bccc79 100644
--- a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb
@@ -9,7 +9,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @param_overwritefiles.input?(1) }.should raise_error ArgumentError
+ lambda { @param_overwritefiles.input?(1) }.should raise_error ArgumentError
end
it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/name_spec.rb b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb
index 0c20c24720..b3c947d6fb 100644
--- a/spec/ruby/library/win32ole/win32ole_param/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb
index e683d1c16e..3ba51c02f1 100644
--- a/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb
@@ -9,7 +9,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @param_overwritefiles.ole_type_detail(1) }.should raise_error ArgumentError
+ lambda { @param_overwritefiles.ole_type_detail(1) }.should raise_error ArgumentError
end
it "returns ['BOOL'] for 3rd parameter of FileSystemObject's 'CopyFile' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb
index b9a3639c3e..52bee2c9b8 100644
--- a/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb
@@ -9,7 +9,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @param_overwritefiles.ole_type(1) }.should raise_error ArgumentError
+ lambda { @param_overwritefiles.ole_type(1) }.should raise_error ArgumentError
end
it "returns 'BOOL' for 3rd parameter of FileSystemObject's 'CopyFile' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb
index 3fb9dc1867..2476df8641 100644
--- a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb
@@ -9,7 +9,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @param_overwritefiles.optional?(1) }.should raise_error ArgumentError
+ lambda { @param_overwritefiles.optional?(1) }.should raise_error ArgumentError
end
it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb
index f5546e79e5..90946c0774 100644
--- a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb
@@ -9,7 +9,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @param_overwritefiles.retval?(1) }.should raise_error ArgumentError
+ lambda { @param_overwritefiles.retval?(1) }.should raise_error ArgumentError
end
it "returns false for 3rd parameter of FileSystemObject's 'CopyFile' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/shared/name.rb b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb
index 043bc32856..b7892d92fb 100644
--- a/spec/ruby/library/win32ole/win32ole_param/shared/name.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb
@@ -9,7 +9,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @param_overwritefiles.send(@method, 1) }.should raise_error ArgumentError
+ lambda { @param_overwritefiles.send(@method, 1) }.should raise_error ArgumentError
end
it "returns expected value for Scripting Runtime's 'name' method" do
diff --git a/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb
index 5b4b4c1c80..7852bb0494 100644
--- a/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/name_spec.rb b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb
index b7a28c553a..b395cf05d5 100644
--- a/spec/ruby/library/win32ole/win32ole_type/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
index 3c3aa1c390..9443a64c75 100644
--- a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
@@ -3,27 +3,24 @@ platform_is :windows do
describe "WIN32OLE_TYPE.new" do
it "raises ArgumentError with no argument" do
- -> { WIN32OLE_TYPE.new }.should raise_error ArgumentError
+ lambda { WIN32OLE_TYPE.new }.should raise_error ArgumentError
end
it "raises ArgumentError with invalid string" do
- -> { WIN32OLE_TYPE.new("foo") }.should raise_error ArgumentError
+ lambda { WIN32OLE_TYPE.new("foo") }.should raise_error ArgumentError
end
it "raises TypeError if second argument is not a String" do
- -> { WIN32OLE_TYPE.new(1,2) }.should raise_error TypeError
- -> {
- WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation',2)
- }.should raise_error TypeError
+ lambda { WIN32OLE_TYPE.new(1,2) }.should raise_error TypeError
+ lambda { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation',2) }.
+ should raise_error TypeError
end
it "raise WIN32OLERuntimeError if OLE object specified is not found" do
- -> {
- WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','foo')
- }.should raise_error WIN32OLERuntimeError
- -> {
- WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','Application')
- }.should raise_error WIN32OLERuntimeError
+ lambda { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','foo') }.
+ should raise_error WIN32OLERuntimeError
+ lambda { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','Application') }.
+ should raise_error WIN32OLERuntimeError
end
it "creates WIN32OLE_TYPE object from name and valid type" do
diff --git a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb
index 19d8bf56e0..0cdd3514e3 100644
--- a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb
@@ -3,7 +3,7 @@ platform_is :windows do
describe "WIN32OLE_TYPE.progids" do
it "raises ArgumentError if an argument is given" do
- -> { WIN32OLE_TYPE.progids(1) }.should raise_error ArgumentError
+ lambda { WIN32OLE_TYPE.progids(1) }.should raise_error ArgumentError
end
it "returns an array containing 'Shell.Explorer'" do
diff --git a/spec/ruby/library/win32ole/win32ole_type/shared/name.rb b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb
index 6f37446b23..6484ef0ef8 100644
--- a/spec/ruby/library/win32ole/win32ole_type/shared/name.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb
@@ -7,7 +7,7 @@ platform_is :windows do
end
it "raises ArgumentError if argument is given" do
- -> { @ole_type.send(@method, 1) }.should raise_error ArgumentError
+ lambda { @ole_type.send(@method, 1) }.should raise_error ArgumentError
end
it "returns a String" do
diff --git a/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb
index b713990ed2..5a50bd11de 100644
--- a/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb
index 369e0274f3..3a28c0496c 100644
--- a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb
@@ -11,7 +11,7 @@ platform_is :windows do
end
it "raises ArgumentError if any argument is give" do
- -> { WIN32OLE_TYPE.typelibs(1) }.should raise_error ArgumentError
+ lambda { WIN32OLE_TYPE.typelibs(1) }.should raise_error ArgumentError
end
it "returns array of type libraries" do
diff --git a/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb
index 8bac1a9891..724fd5c70a 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb
index 000ac14d7e..9853f91801 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'shared/name'
+require File.expand_path('../shared/name', __FILE__)
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/yaml/add_builtin_type_spec.rb b/spec/ruby/library/yaml/add_builtin_type_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/add_builtin_type_spec.rb
+++ b/spec/ruby/library/yaml/add_builtin_type_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/add_domain_type_spec.rb b/spec/ruby/library/yaml/add_domain_type_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/add_domain_type_spec.rb
+++ b/spec/ruby/library/yaml/add_domain_type_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/add_private_type_spec.rb b/spec/ruby/library/yaml/add_private_type_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/add_private_type_spec.rb
+++ b/spec/ruby/library/yaml/add_private_type_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/add_ruby_type_spec.rb b/spec/ruby/library/yaml/add_ruby_type_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/add_ruby_type_spec.rb
+++ b/spec/ruby/library/yaml/add_ruby_type_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/detect_implicit_spec.rb b/spec/ruby/library/yaml/detect_implicit_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/detect_implicit_spec.rb
+++ b/spec/ruby/library/yaml/detect_implicit_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/dump_spec.rb b/spec/ruby/library/yaml/dump_spec.rb
index 5af794b7f8..c3613521e0 100644
--- a/spec/ruby/library/yaml/dump_spec.rb
+++ b/spec/ruby/library/yaml/dump_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
# TODO: WTF is this using a global?
describe "YAML.dump" do
diff --git a/spec/ruby/library/yaml/dump_stream_spec.rb b/spec/ruby/library/yaml/dump_stream_spec.rb
index 9d30fef819..918b62607f 100644
--- a/spec/ruby/library/yaml/dump_stream_spec.rb
+++ b/spec/ruby/library/yaml/dump_stream_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "YAML.dump_stream" do
it "returns a YAML stream containing the objects passed" do
diff --git a/spec/ruby/library/yaml/each_node_spec.rb b/spec/ruby/library/yaml/each_node_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/each_node_spec.rb
+++ b/spec/ruby/library/yaml/each_node_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/emitter_spec.rb b/spec/ruby/library/yaml/emitter_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/emitter_spec.rb
+++ b/spec/ruby/library/yaml/emitter_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/fixtures/example_class.rb b/spec/ruby/library/yaml/fixtures/example_class.rb
index 8259870799..751435a305 100644
--- a/spec/ruby/library/yaml/fixtures/example_class.rb
+++ b/spec/ruby/library/yaml/fixtures/example_class.rb
@@ -1,7 +1,5 @@
-module YAMLSpecs
- class Example
- def initialize(name)
- @name = name
- end
+class FooBar
+ def initialize(name)
+ @name = name
end
end
diff --git a/spec/ruby/library/yaml/generic_parser_spec.rb b/spec/ruby/library/yaml/generic_parser_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/generic_parser_spec.rb
+++ b/spec/ruby/library/yaml/generic_parser_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/load_documents_spec.rb b/spec/ruby/library/yaml/load_documents_spec.rb
index 27edbcaa86..77d6dd8ae1 100644
--- a/spec/ruby/library/yaml/load_documents_spec.rb
+++ b/spec/ruby/library/yaml/load_documents_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'fixtures/strings'
-require_relative 'shared/each_document'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/strings', __FILE__)
+require File.expand_path('../shared/each_document', __FILE__)
ruby_version_is ''...'2.5' do
describe "YAML.load_documents" do
diff --git a/spec/ruby/library/yaml/load_file_spec.rb b/spec/ruby/library/yaml/load_file_spec.rb
index 2363c08120..d9ba5bedb1 100644
--- a/spec/ruby/library/yaml/load_file_spec.rb
+++ b/spec/ruby/library/yaml/load_file_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "YAML.load_file" do
after :each do
diff --git a/spec/ruby/library/yaml/load_spec.rb b/spec/ruby/library/yaml/load_spec.rb
index 0b6bef2dac..6a2ab65b65 100644
--- a/spec/ruby/library/yaml/load_spec.rb
+++ b/spec/ruby/library/yaml/load_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'fixtures/strings'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/strings', __FILE__)
describe "YAML.load" do
after :each do
@@ -61,7 +61,7 @@ describe "YAML.load" do
else
error = ArgumentError
end
- -> { YAML.load("key1: value\ninvalid_key") }.should raise_error(error)
+ lambda { YAML.load("key1: value\ninvalid_key") }.should raise_error(error)
end
it "accepts symbols" do
@@ -130,7 +130,7 @@ describe "YAML.load" do
it "loads a File but raise an error when used as it is uninitialized" do
loaded = YAML.load("--- !ruby/object:File {}\n")
- -> {
+ lambda {
loaded.read(1)
}.should raise_error(IOError)
end
diff --git a/spec/ruby/library/yaml/load_stream_spec.rb b/spec/ruby/library/yaml/load_stream_spec.rb
index 689653c8cd..f134f4642f 100644
--- a/spec/ruby/library/yaml/load_stream_spec.rb
+++ b/spec/ruby/library/yaml/load_stream_spec.rb
@@ -1,7 +1,7 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'fixtures/strings'
-require_relative 'shared/each_document'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/strings', __FILE__)
+require File.expand_path('../shared/each_document', __FILE__)
describe "YAML.load_stream" do
it_behaves_like :yaml_each_document, :load_stream
diff --git a/spec/ruby/library/yaml/object_maker_spec.rb b/spec/ruby/library/yaml/object_maker_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/object_maker_spec.rb
+++ b/spec/ruby/library/yaml/object_maker_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/parse_documents_spec.rb b/spec/ruby/library/yaml/parse_documents_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/parse_documents_spec.rb
+++ b/spec/ruby/library/yaml/parse_documents_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/parse_file_spec.rb b/spec/ruby/library/yaml/parse_file_spec.rb
index 8c59a2d7ef..d8980135f5 100644
--- a/spec/ruby/library/yaml/parse_file_spec.rb
+++ b/spec/ruby/library/yaml/parse_file_spec.rb
@@ -1,8 +1,10 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "YAML#parse_file" do
- it "returns a YAML::Syck::Map object after parsing a YAML file" do
- YAML.parse_file($test_parse_file).should be_kind_of(Psych::Nodes::Document)
+ quarantine! do
+ it "returns a YAML::Syck::Map object after parsing a YAML file" do
+ YAML.parse_file($test_parse_file).should be_kind_of(YAML::Syck::Map)
+ end
end
end
diff --git a/spec/ruby/library/yaml/parse_spec.rb b/spec/ruby/library/yaml/parse_spec.rb
index d5dbfdcee2..137fc23cf8 100644
--- a/spec/ruby/library/yaml/parse_spec.rb
+++ b/spec/ruby/library/yaml/parse_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
describe "YAML#parse with an empty string" do
it "returns false" do
diff --git a/spec/ruby/library/yaml/parser_spec.rb b/spec/ruby/library/yaml/parser_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/parser_spec.rb
+++ b/spec/ruby/library/yaml/parser_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/quick_emit_spec.rb b/spec/ruby/library/yaml/quick_emit_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/quick_emit_spec.rb
+++ b/spec/ruby/library/yaml/quick_emit_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/read_type_class_spec.rb b/spec/ruby/library/yaml/read_type_class_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/read_type_class_spec.rb
+++ b/spec/ruby/library/yaml/read_type_class_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/tagurize_spec.rb b/spec/ruby/library/yaml/tagurize_spec.rb
index cc1b757ce9..f6025cbea3 100644
--- a/spec/ruby/library/yaml/tagurize_spec.rb
+++ b/spec/ruby/library/yaml/tagurize_spec.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
ruby_version_is ''...'2.5' do
describe "YAML.tagurize" do
diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb
index 03ec4f6916..afe583d502 100644
--- a/spec/ruby/library/yaml/to_yaml_spec.rb
+++ b/spec/ruby/library/yaml/to_yaml_spec.rb
@@ -1,6 +1,6 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'fixtures/example_class'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/example_class', __FILE__)
describe "Object#to_yaml" do
@@ -13,7 +13,8 @@ describe "Object#to_yaml" do
end
it "returns the YAML representation of a Class object" do
- YAMLSpecs::Example.new("baz").to_yaml.should match_yaml("--- !ruby/object:YAMLSpecs::Example\nname: baz\n")
+ FooBar.new("baz").to_yaml.should match_yaml("--- !ruby/object:FooBar\nname: baz\n")
+
end
it "returns the YAML representation of a Date object" do
@@ -72,16 +73,8 @@ describe "Object#to_yaml" do
true_klass.to_yaml.should match_yaml("--- true\n")
end
- ruby_version_is ""..."2.7" do
- it "returns the YAML representation of a Error object" do
- StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\n")
- end
- end
-
- ruby_version_is "2.7" do
- it "returns the YAML representation of a Error object" do
- StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\nbacktrace: \n")
- end
+ it "returns the YAML representation of a Error object" do
+ StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\n")
end
it "returns the YAML representation for Range objects" do
diff --git a/spec/ruby/library/yaml/transfer_spec.rb b/spec/ruby/library/yaml/transfer_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/transfer_spec.rb
+++ b/spec/ruby/library/yaml/transfer_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/try_implicit_spec.rb b/spec/ruby/library/yaml/try_implicit_spec.rb
index 44c820940f..a8af231b47 100644
--- a/spec/ruby/library/yaml/try_implicit_spec.rb
+++ b/spec/ruby/library/yaml/try_implicit_spec.rb
@@ -1,2 +1,2 @@
-require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/zlib/adler32_spec.rb b/spec/ruby/library/zlib/adler32_spec.rb
index 62240e2de7..1767dc2011 100644
--- a/spec/ruby/library/zlib/adler32_spec.rb
+++ b/spec/ruby/library/zlib/adler32_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib.adler32" do
@@ -19,7 +19,7 @@ describe "Zlib.adler32" do
Zlib.adler32(test_string, 1).should == 66391324
Zlib.adler32(test_string, 2**8).should == 701435419
Zlib.adler32(test_string, 2**16).should == 63966491
- -> { Zlib.adler32(test_string, 2**128) }.should raise_error(RangeError)
+ lambda { Zlib.adler32(test_string, 2**128) }.should raise_error(RangeError)
end
it "calculates the Adler checksum for string and initial Adler value for Bignums" do
diff --git a/spec/ruby/library/zlib/crc32_spec.rb b/spec/ruby/library/zlib/crc32_spec.rb
index 4c1d6ce2e9..22d1dac28b 100644
--- a/spec/ruby/library/zlib/crc32_spec.rb
+++ b/spec/ruby/library/zlib/crc32_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib.crc32" do
@@ -24,9 +24,7 @@ describe "Zlib.crc32" do
Zlib.crc32(test_string, 1).should == 1809313411
Zlib.crc32(test_string, 2**8).should == 1722745982
Zlib.crc32(test_string, 2**16).should == 1932511220
- Zlib.crc32("p", ~305419896).should == 4046865307
- Zlib.crc32("p", -305419897).should == 4046865307
- -> { Zlib.crc32(test_string, 2**128) }.should raise_error(RangeError)
+ lambda { Zlib.crc32(test_string, 2**128) }.should raise_error(RangeError)
end
it "calculates the CRC checksum for string and initial CRC value for Bignums" do
diff --git a/spec/ruby/library/zlib/crc_table_spec.rb b/spec/ruby/library/zlib/crc_table_spec.rb
index f7fc2749fa..22aaa32233 100644
--- a/spec/ruby/library/zlib/crc_table_spec.rb
+++ b/spec/ruby/library/zlib/crc_table_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require "zlib"
describe "Zlib.crc_table" do
diff --git a/spec/ruby/library/zlib/deflate/append_spec.rb b/spec/ruby/library/zlib/deflate/append_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/deflate/append_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/deflate/deflate_spec.rb b/spec/ruby/library/zlib/deflate/deflate_spec.rb
index 828880f8d8..44b3389701 100644
--- a/spec/ruby/library/zlib/deflate/deflate_spec.rb
+++ b/spec/ruby/library/zlib/deflate/deflate_spec.rb
@@ -1,5 +1,5 @@
require 'zlib'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Zlib::Deflate.deflate" do
it "deflates some data" do
@@ -25,7 +25,7 @@ describe "Zlib::Deflate.deflate" do
random_generator = Random.new(0)
deflated = ''
- Zlib::Deflate.deflate(random_generator.bytes(20000)) do |chunk|
+ Zlib.deflate(random_generator.bytes(20000)) do |chunk|
deflated << chunk
end
diff --git a/spec/ruby/library/zlib/deflate/flush_spec.rb b/spec/ruby/library/zlib/deflate/flush_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/deflate/flush_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/deflate/new_spec.rb b/spec/ruby/library/zlib/deflate/new_spec.rb
index e15f14f95f..6a4c1dadb4 100644
--- a/spec/ruby/library/zlib/deflate/new_spec.rb
+++ b/spec/ruby/library/zlib/deflate/new_spec.rb
@@ -1 +1 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/deflate/params_spec.rb b/spec/ruby/library/zlib/deflate/params_spec.rb
index 0b1cca8c8a..59b1353c07 100644
--- a/spec/ruby/library/zlib/deflate/params_spec.rb
+++ b/spec/ruby/library/zlib/deflate/params_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::Deflate#params" do
diff --git a/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb b/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb
index 0e461229c7..c5c62d9529 100644
--- a/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb
+++ b/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::Deflate#set_dictionary" do
@@ -12,3 +12,4 @@ describe "Zlib::Deflate#set_dictionary" do
2, 0, 21, 134, 3, 248].pack('C*')
end
end
+
diff --git a/spec/ruby/library/zlib/deflate_spec.rb b/spec/ruby/library/zlib/deflate_spec.rb
deleted file mode 100644
index 6eeaa164c5..0000000000
--- a/spec/ruby/library/zlib/deflate_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require "zlib"
-
-describe "Zlib.deflate" do
- it "deflates some data" do
- Zlib.deflate("1" * 10).should == [120, 156, 51, 52, 132, 1, 0, 10, 145, 1, 235].pack('C*')
- end
-end
diff --git a/spec/ruby/library/zlib/gunzip_spec.rb b/spec/ruby/library/zlib/gunzip_spec.rb
deleted file mode 100644
index 2417fed57c..0000000000
--- a/spec/ruby/library/zlib/gunzip_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../spec_helper'
-require 'zlib'
-
-describe "Zlib.gunzip" do
- before :each do
- @data = '12345abcde'
- @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
- 76, 74, 78, 73, 5, 0, 157, 5, 0, 36, 10, 0, 0, 0].pack('C*')
- end
-
- it "decodes the given gzipped string" do
- Zlib.gunzip(@zip).should == @data
- end
-end
diff --git a/spec/ruby/library/zlib/gzip_spec.rb b/spec/ruby/library/zlib/gzip_spec.rb
deleted file mode 100644
index 35694264f0..0000000000
--- a/spec/ruby/library/zlib/gzip_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../../spec_helper'
-require 'zlib'
-
-describe "Zlib.gzip" do
- before :each do
- @data = '12345abcde'
- @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
- 76, 74, 78, 73, 5, 0, 157, 5, 0, 36, 10, 0, 0, 0].pack('C*')
- end
-
- it "gzips the given string" do
- # skip gzip header for now
- Zlib.gzip(@data)[10..-1].should == @zip[10..-1]
- end
-end
diff --git a/spec/ruby/library/zlib/gzipfile/close_spec.rb b/spec/ruby/library/zlib/gzipfile/close_spec.rb
index 870870f2fa..9486d6b9ec 100644
--- a/spec/ruby/library/zlib/gzipfile/close_spec.rb
+++ b/spec/ruby/library/zlib/gzipfile/close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
@@ -10,12 +10,13 @@ describe "Zlib::GzipFile#close" do
gzio.closed?.should == true
- -> { gzio.orig_name }.should \
+ lambda { gzio.orig_name }.should \
raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
- -> { gzio.comment }.should \
+ lambda { gzio.comment }.should \
raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
end
io.string[10..-1].should == ([3] + Array.new(9,0)).pack('C*')
end
end
+
diff --git a/spec/ruby/library/zlib/gzipfile/closed_spec.rb b/spec/ruby/library/zlib/gzipfile/closed_spec.rb
index b885add485..69785bc41c 100644
--- a/spec/ruby/library/zlib/gzipfile/closed_spec.rb
+++ b/spec/ruby/library/zlib/gzipfile/closed_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
@@ -14,3 +14,4 @@ describe "Zlib::GzipFile#closed?" do
end
end
end
+
diff --git a/spec/ruby/library/zlib/gzipfile/comment_spec.rb b/spec/ruby/library/zlib/gzipfile/comment_spec.rb
index 70d97ecaf6..638e85a4a7 100644
--- a/spec/ruby/library/zlib/gzipfile/comment_spec.rb
+++ b/spec/ruby/library/zlib/gzipfile/comment_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
@@ -19,8 +19,9 @@ describe "Zlib::GzipFile#comment" do
Zlib::GzipWriter.wrap @io do |gzio|
gzio.close
- -> { gzio.comment }.should \
+ lambda { gzio.comment }.should \
raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
end
end
end
+
diff --git a/spec/ruby/library/zlib/gzipfile/crc_spec.rb b/spec/ruby/library/zlib/gzipfile/crc_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/crc_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipfile/finish_spec.rb b/spec/ruby/library/zlib/gzipfile/finish_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/finish_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipfile/level_spec.rb b/spec/ruby/library/zlib/gzipfile/level_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/level_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipfile/mtime_spec.rb b/spec/ruby/library/zlib/gzipfile/mtime_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/mtime_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb
index ebfd3692af..42a3b2f376 100644
--- a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb
+++ b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
@@ -19,8 +19,9 @@ describe "Zlib::GzipFile#orig_name" do
Zlib::GzipWriter.wrap @io do |gzio|
gzio.close
- -> { gzio.orig_name }.should \
+ lambda { gzio.orig_name }.should \
raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
end
end
end
+
diff --git a/spec/ruby/library/zlib/gzipfile/os_code_spec.rb b/spec/ruby/library/zlib/gzipfile/os_code_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/os_code_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipfile/sync_spec.rb b/spec/ruby/library/zlib/gzipfile/sync_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/sync_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipfile/to_io_spec.rb b/spec/ruby/library/zlib/gzipfile/to_io_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/to_io_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipfile/wrap_spec.rb b/spec/ruby/library/zlib/gzipfile/wrap_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/wrap_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb b/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb
index 48821dc833..6da9ac8323 100644
--- a/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#each_byte" do
+describe "GzipReader#each_byte" do
before :each do
@data = '12345abcde'
diff --git a/spec/ruby/library/zlib/gzipreader/each_line_spec.rb b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
index efaf27d6bb..7ff116a258 100644
--- a/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'shared/each'
+require File.expand_path('../shared/each', __FILE__)
-describe "Zlib::GzipReader#each_line" do
+describe "GzipReader#each_line" do
it_behaves_like :gzipreader_each, :each_line
end
diff --git a/spec/ruby/library/zlib/gzipreader/each_spec.rb b/spec/ruby/library/zlib/gzipreader/each_spec.rb
index 59aa63e52c..dd780e4083 100644
--- a/spec/ruby/library/zlib/gzipreader/each_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'shared/each'
+require File.expand_path('../shared/each', __FILE__)
-describe "Zlib::GzipReader#each" do
+describe "GzipReader#each" do
it_behaves_like :gzipreader_each, :each
end
diff --git a/spec/ruby/library/zlib/gzipreader/eof_spec.rb b/spec/ruby/library/zlib/gzipreader/eof_spec.rb
index 673220fdfd..446cbfec37 100644
--- a/spec/ruby/library/zlib/gzipreader/eof_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/eof_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#eof?" do
+describe "GzipReader#eof?" do
+
before :each do
@data = '{"a":1234}'
@zip = [31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 171, 86, 74, 84, 178, 50,
@@ -48,7 +49,8 @@ describe "Zlib::GzipReader#eof?" do
gz.read(1).should == @data[i, 1]
end
gz.eof?.should be_true
- gz.read.should == ""
+ gz.read().should == ""
gz.eof?.should be_true
end
+
end
diff --git a/spec/ruby/library/zlib/gzipreader/getc_spec.rb b/spec/ruby/library/zlib/gzipreader/getc_spec.rb
index e567231940..a3c4aecf76 100644
--- a/spec/ruby/library/zlib/gzipreader/getc_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/getc_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#getc" do
+describe "GzipReader#getc" do
+
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
@@ -36,4 +37,5 @@ describe "Zlib::GzipReader#getc" do
gz.getc.should be_nil
gz.pos.should == pos
end
+
end
diff --git a/spec/ruby/library/zlib/gzipreader/gets_spec.rb b/spec/ruby/library/zlib/gzipreader/gets_spec.rb
index d3a2e7d263..d49adc2850 100644
--- a/spec/ruby/library/zlib/gzipreader/gets_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/gets_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
require 'stringio'
-describe 'Zlib::GzipReader#gets' do
+describe 'GzipReader#gets' do
describe 'with "" separator' do
it 'reads paragraphs skipping newlines' do
# gz contains "\n\n\n\n\n123\n45\n\n\n\n\nabc\nde\n\n\n\n\n"
diff --git a/spec/ruby/library/zlib/gzipreader/lineno_spec.rb b/spec/ruby/library/zlib/gzipreader/lineno_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/lineno_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/new_spec.rb b/spec/ruby/library/zlib/gzipreader/new_spec.rb
index e15f14f95f..6a4c1dadb4 100644
--- a/spec/ruby/library/zlib/gzipreader/new_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/new_spec.rb
@@ -1 +1 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/open_spec.rb b/spec/ruby/library/zlib/gzipreader/open_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/open_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/pos_spec.rb b/spec/ruby/library/zlib/gzipreader/pos_spec.rb
index 8586faec92..66fbf388d8 100644
--- a/spec/ruby/library/zlib/gzipreader/pos_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/pos_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#pos" do
+describe "GzipReader#pos" do
+
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
@@ -21,4 +22,6 @@ describe "Zlib::GzipReader#pos" do
gz.read
gz.pos.should == @data.length
end
+
end
+
diff --git a/spec/ruby/library/zlib/gzipreader/read_spec.rb b/spec/ruby/library/zlib/gzipreader/read_spec.rb
index b81954b5ce..337f507502 100644
--- a/spec/ruby/library/zlib/gzipreader/read_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/read_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#read" do
+describe "GzipReader#read" do
+
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
@@ -28,7 +29,7 @@ describe "Zlib::GzipReader#read" do
it "does not accept a negative length to read" do
gz = Zlib::GzipReader.new @io
- -> {
+ lambda {
gz.read(-1)
}.should raise_error(ArgumentError)
end
@@ -48,7 +49,7 @@ describe "Zlib::GzipReader#read" do
end
describe "at the end of data" do
- it "returns empty string if length parameter is not specified or 0" do
+ it "returns empty string if length prameter is not specified or 0" do
gz = Zlib::GzipReader.new @io
gz.read # read till the end
gz.read(0).should == ""
@@ -56,11 +57,12 @@ describe "Zlib::GzipReader#read" do
gz.read(nil).should == ""
end
- it "returns nil if length parameter is positive" do
+ it "returns nil if length prameter is positive" do
gz = Zlib::GzipReader.new @io
gz.read # read till the end
gz.read(1).should be_nil
gz.read(2**16).should be_nil
end
end
+
end
diff --git a/spec/ruby/library/zlib/gzipreader/readchar_spec.rb b/spec/ruby/library/zlib/gzipreader/readchar_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/readchar_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/readline_spec.rb b/spec/ruby/library/zlib/gzipreader/readline_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/readline_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/readlines_spec.rb b/spec/ruby/library/zlib/gzipreader/readlines_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/readlines_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb b/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb
index 559ce9f841..2cdef54fd1 100644
--- a/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#readpartial" do
+describe 'GzipReader#readpartial' do
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
diff --git a/spec/ruby/library/zlib/gzipreader/rewind_spec.rb b/spec/ruby/library/zlib/gzipreader/rewind_spec.rb
index b31abb6abf..70bee3372d 100644
--- a/spec/ruby/library/zlib/gzipreader/rewind_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/rewind_spec.rb
@@ -1,8 +1,9 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#rewind" do
+describe "GzipReader#rewind" do
+
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
diff --git a/spec/ruby/library/zlib/gzipreader/shared/each.rb b/spec/ruby/library/zlib/gzipreader/shared/each.rb
index 71608e04ab..47cd284b6a 100644
--- a/spec/ruby/library/zlib/gzipreader/shared/each.rb
+++ b/spec/ruby/library/zlib/gzipreader/shared/each.rb
@@ -1,8 +1,9 @@
-require_relative '../../../../spec_helper'
+require File.expand_path('../../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
describe :gzipreader_each, shared: true do
+
before :each do
@data = "firstline\nsecondline\n\nforthline"
@zip = [31, 139, 8, 0, 244, 125, 128, 88, 2, 255, 75, 203, 44, 42, 46, 201,
@@ -46,4 +47,5 @@ describe :gzipreader_each, shared: true do
@gzreader.pos.should == i
end
end
+
end
diff --git a/spec/ruby/library/zlib/gzipreader/tell_spec.rb b/spec/ruby/library/zlib/gzipreader/tell_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/tell_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
index 7fa0608f9f..16f1c12272 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#ungetbyte" do
+describe 'GzipReader#ungetbyte' do
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
@@ -21,9 +21,11 @@ describe "Zlib::GzipReader#ungetbyte" do
@gz.read.should == '!12345abcde'
end
- it 'decrements pos' do
- @gz.ungetbyte 0x21
- @gz.pos.should == -1
+ ruby_bug "#13616", ""..."2.6" do
+ it 'decrements pos' do
+ @gz.ungetbyte 0x21
+ @gz.pos.should == -1
+ end
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
index 34f2a1a2ca..2d218e8d19 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipReader#ungetc" do
+describe 'GzipReader#ungetc' do
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
@@ -21,9 +21,11 @@ describe "Zlib::GzipReader#ungetc" do
@gz.read.should == 'x12345abcde'
end
- it 'decrements pos' do
- @gz.ungetc 'x'
- @gz.pos.should == -1
+ ruby_bug "#13616", ""..."2.6" do
+ it 'decrements pos' do
+ @gz.ungetc 'x'
+ @gz.pos.should == -1
+ end
end
end
@@ -33,9 +35,11 @@ describe "Zlib::GzipReader#ungetc" do
@gz.read.should == 'Å·12345abcde'
end
- it 'decrements pos' do
- @gz.ungetc 'Å·'
- @gz.pos.should == -2
+ ruby_bug "#13616", ""..."2.6" do
+ it 'decrements pos' do
+ @gz.ungetc 'Å·'
+ @gz.pos.should == -2
+ end
end
end
@@ -45,9 +49,11 @@ describe "Zlib::GzipReader#ungetc" do
@gz.read.should == 'xŷž12345abcde'
end
- it 'decrements pos' do
- @gz.ungetc 'xŷž'
- @gz.pos.should == -5
+ ruby_bug "#13616", ""..."2.6" do
+ it 'decrements pos' do
+ @gz.ungetc 'xŷž'
+ @gz.pos.should == -5
+ end
end
end
@@ -57,9 +63,11 @@ describe "Zlib::GzipReader#ungetc" do
@gz.read.should == '!12345abcde'
end
- it 'decrements pos' do
- @gz.ungetc 0x21
- @gz.pos.should == -1
+ ruby_bug "#13616", ""..."2.6" do
+ it 'decrements pos' do
+ @gz.ungetc 0x21
+ @gz.pos.should == -1
+ end
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/unused_spec.rb b/spec/ruby/library/zlib/gzipreader/unused_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/unused_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/append_spec.rb b/spec/ruby/library/zlib/gzipwriter/append_spec.rb
index 6aa2824180..922e921840 100644
--- a/spec/ruby/library/zlib/gzipwriter/append_spec.rb
+++ b/spec/ruby/library/zlib/gzipwriter/append_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
@@ -12,4 +12,6 @@ describe "Zlib::GzipWriter#<<" do
(gzio << "test").should equal(gzio)
end
end
+
+ it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/library/zlib/gzipwriter/comment_spec.rb b/spec/ruby/library/zlib/gzipwriter/comment_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/comment_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/flush_spec.rb b/spec/ruby/library/zlib/gzipwriter/flush_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/flush_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb
index 621b602dc7..af7a4ac735 100644
--- a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb
+++ b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
@@ -31,7 +31,7 @@ describe "Zlib::GzipWriter#mtime=" do
Zlib::GzipWriter.wrap @io do |gzio|
gzio.write ''
- -> { gzio.mtime = nil }.should \
+ lambda { gzio.mtime = nil }.should \
raise_error(Zlib::GzipFile::Error, 'header is already written')
end
end
diff --git a/spec/ruby/library/zlib/gzipwriter/new_spec.rb b/spec/ruby/library/zlib/gzipwriter/new_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/new_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/open_spec.rb b/spec/ruby/library/zlib/gzipwriter/open_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/open_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb b/spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/pos_spec.rb b/spec/ruby/library/zlib/gzipwriter/pos_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/pos_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/print_spec.rb b/spec/ruby/library/zlib/gzipwriter/print_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/print_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/printf_spec.rb b/spec/ruby/library/zlib/gzipwriter/printf_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/printf_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/putc_spec.rb b/spec/ruby/library/zlib/gzipwriter/putc_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/putc_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/puts_spec.rb b/spec/ruby/library/zlib/gzipwriter/puts_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/puts_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/tell_spec.rb b/spec/ruby/library/zlib/gzipwriter/tell_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipwriter/tell_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/gzipwriter/write_spec.rb b/spec/ruby/library/zlib/gzipwriter/write_spec.rb
index 522ae7f2aa..5ff4241423 100644
--- a/spec/ruby/library/zlib/gzipwriter/write_spec.rb
+++ b/spec/ruby/library/zlib/gzipwriter/write_spec.rb
@@ -1,8 +1,8 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'stringio'
require 'zlib'
-describe "Zlib::GzipWriter#write" do
+describe "GzipWriter#write" do
before :each do
@data = '12345abcde'
@zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
diff --git a/spec/ruby/library/zlib/inflate/append_spec.rb b/spec/ruby/library/zlib/inflate/append_spec.rb
index f121e66566..a768a766a2 100644
--- a/spec/ruby/library/zlib/inflate/append_spec.rb
+++ b/spec/ruby/library/zlib/inflate/append_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::Inflate#<<" do
@@ -41,7 +41,7 @@ describe "Zlib::Inflate#<<" do
it "properly handles incomplete data" do
# add bytes, one by one
@foo_deflated[0, 5].each_byte { |d| @z << d.chr}
- -> { @z.finish }.should raise_error(Zlib::BufError)
+ lambda { @z.finish }.should raise_error(Zlib::BufError)
end
it "properly handles excessive data, byte-by-byte" do
diff --git a/spec/ruby/library/zlib/inflate/inflate_spec.rb b/spec/ruby/library/zlib/inflate/inflate_spec.rb
index cc33bd4c32..1fa16d9e98 100644
--- a/spec/ruby/library/zlib/inflate/inflate_spec.rb
+++ b/spec/ruby/library/zlib/inflate/inflate_spec.rb
@@ -1,5 +1,5 @@
require 'zlib'
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
describe "Zlib::Inflate#inflate" do
@@ -77,7 +77,7 @@ describe "Zlib::Inflate.inflate" do
# add bytes, one by one, but not all
result = ""
data.each_byte { |d| result << z.inflate(d.chr)}
- -> { result << z.finish }.should raise_error(Zlib::BufError)
+ lambda { result << z.finish }.should raise_error(Zlib::BufError)
end
it "properly handles excessive data, byte-by-byte" do
diff --git a/spec/ruby/library/zlib/inflate/new_spec.rb b/spec/ruby/library/zlib/inflate/new_spec.rb
index e15f14f95f..6a4c1dadb4 100644
--- a/spec/ruby/library/zlib/inflate/new_spec.rb
+++ b/spec/ruby/library/zlib/inflate/new_spec.rb
@@ -1 +1 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb b/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb
index 251cec44bb..890815b8e6 100644
--- a/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb
+++ b/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: binary -*-
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::Inflate#set_dictionary" do
@@ -18,3 +18,4 @@ describe "Zlib::Inflate#set_dictionary" do
i.finish.should == 'abcdefghij'
end
end
+
diff --git a/spec/ruby/library/zlib/inflate/sync_point_spec.rb b/spec/ruby/library/zlib/inflate/sync_point_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/inflate/sync_point_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/inflate/sync_spec.rb b/spec/ruby/library/zlib/inflate/sync_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/inflate/sync_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/inflate_spec.rb b/spec/ruby/library/zlib/inflate_spec.rb
deleted file mode 100644
index 42c8dc5fbe..0000000000
--- a/spec/ruby/library/zlib/inflate_spec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative '../../spec_helper'
-require "zlib"
-
-describe "Zlib.inflate" do
- it "inflates some data" do
- Zlib.inflate([120, 156, 51, 52, 132, 1, 0, 10, 145, 1, 235].pack('C*')).should == "1" * 10
- end
-end
diff --git a/spec/ruby/library/zlib/zlib_version_spec.rb b/spec/ruby/library/zlib/zlib_version_spec.rb
index f83dfae66d..14fb93ef07 100644
--- a/spec/ruby/library/zlib/zlib_version_spec.rb
+++ b/spec/ruby/library/zlib/zlib_version_spec.rb
@@ -1,8 +1 @@
-require_relative '../../spec_helper'
-require 'zlib'
-
-describe "Zlib.zlib_version" do
- it "returns the version of the libz library" do
- Zlib.zlib_version.should be_an_instance_of(String)
- end
-end
+require File.expand_path('../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/adler_spec.rb b/spec/ruby/library/zlib/zstream/adler_spec.rb
index 55ac8ae79e..e562fd260e 100644
--- a/spec/ruby/library/zlib/zstream/adler_spec.rb
+++ b/spec/ruby/library/zlib/zstream/adler_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::ZStream#adler" do
diff --git a/spec/ruby/library/zlib/zstream/avail_in_spec.rb b/spec/ruby/library/zlib/zstream/avail_in_spec.rb
index eddae15830..25d3219a5a 100644
--- a/spec/ruby/library/zlib/zstream/avail_in_spec.rb
+++ b/spec/ruby/library/zlib/zstream/avail_in_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::ZStream#avail_in" do
diff --git a/spec/ruby/library/zlib/zstream/avail_out_spec.rb b/spec/ruby/library/zlib/zstream/avail_out_spec.rb
index 2e5a394ec0..c747bbbc2f 100644
--- a/spec/ruby/library/zlib/zstream/avail_out_spec.rb
+++ b/spec/ruby/library/zlib/zstream/avail_out_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::ZStream#avail_out" do
diff --git a/spec/ruby/library/zlib/zstream/close_spec.rb b/spec/ruby/library/zlib/zstream/close_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/close_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/closed_spec.rb b/spec/ruby/library/zlib/zstream/closed_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/closed_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/data_type_spec.rb b/spec/ruby/library/zlib/zstream/data_type_spec.rb
index 8be96adf7c..614f0d10a2 100644
--- a/spec/ruby/library/zlib/zstream/data_type_spec.rb
+++ b/spec/ruby/library/zlib/zstream/data_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::ZStream#data_type" do
diff --git a/spec/ruby/library/zlib/zstream/end_spec.rb b/spec/ruby/library/zlib/zstream/end_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/end_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/ended_spec.rb b/spec/ruby/library/zlib/zstream/ended_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/ended_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/finish_spec.rb b/spec/ruby/library/zlib/zstream/finish_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/finish_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/finished_spec.rb b/spec/ruby/library/zlib/zstream/finished_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/finished_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/flush_next_in_spec.rb b/spec/ruby/library/zlib/zstream/flush_next_in_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/flush_next_in_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb b/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb
index 59a0622903..8ba8414cd1 100644
--- a/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb
+++ b/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require File.expand_path('../../../../spec_helper', __FILE__)
require 'zlib'
describe "Zlib::ZStream#flush_next_out" do
@@ -12,3 +12,5 @@ describe "Zlib::ZStream#flush_next_out" do
zs.flush_next_out.should == ''
end
end
+
+
diff --git a/spec/ruby/library/zlib/zstream/reset_spec.rb b/spec/ruby/library/zlib/zstream/reset_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/reset_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/stream_end_spec.rb b/spec/ruby/library/zlib/zstream/stream_end_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/stream_end_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/total_in_spec.rb b/spec/ruby/library/zlib/zstream/total_in_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/total_in_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/library/zlib/zstream/total_out_spec.rb b/spec/ruby/library/zlib/zstream/total_out_spec.rb
new file mode 100644
index 0000000000..6a4c1dadb4
--- /dev/null
+++ b/spec/ruby/library/zlib/zstream/total_out_spec.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
diff --git a/spec/ruby/optional/capi/README b/spec/ruby/optional/capi/README
index 57b0c51f01..efbfb09dcb 100644
--- a/spec/ruby/optional/capi/README
+++ b/spec/ruby/optional/capi/README
@@ -13,4 +13,4 @@ specs:
5. Name the C functions 'array_spec_rb_ary_new'.
6. Wrap the code in the optional/capi/ext/array_spec.c in
'#ifdef HAVE_RB_ARY_NEW'
-7. Attach the C function to the class using the name 'rb_ary_new'
+6. Attach the C function to the class using the name 'rb_ary_new'
diff --git a/spec/ruby/optional/capi/array_spec.rb b/spec/ruby/optional/capi/array_spec.rb
index cf65bc19b6..2fd898ad94 100644
--- a/spec/ruby/optional/capi/array_spec.rb
+++ b/spec/ruby/optional/capi/array_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("array")
@@ -8,7 +8,7 @@ describe :rb_ary_new2, shared: true do
end
it "raises an ArgumentError when the given argument is negative" do
- -> { @s.send(@method, -1) }.should raise_error(ArgumentError)
+ lambda { @s.send(@method, -1) }.should raise_error(ArgumentError)
end
end
@@ -83,8 +83,8 @@ describe "C-API Array function" do
@s.rb_ary_cat([1, 2], 3, 4).should == [1, 2, 3, 4]
end
- it "raises a #{frozen_error_class} if the array is frozen" do
- -> { @s.rb_ary_cat([].freeze, 1) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if the array is frozen" do
+ lambda { @s.rb_ary_cat([].freeze, 1) }.should raise_error(RuntimeError)
end
end
@@ -130,8 +130,8 @@ describe "C-API Array function" do
@s.rb_ary_rotate([1, 2, 3, 4], -3).should == [2, 3, 4, 1]
end
- it "raises a #{frozen_error_class} if the array is frozen" do
- -> { @s.rb_ary_rotate([].freeze, 1) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if the array is frozen" do
+ lambda { @s.rb_ary_rotate([].freeze, 1) }.should raise_error(RuntimeError)
end
end
@@ -205,7 +205,7 @@ describe "C-API Array function" do
it "raises an IndexError if the negative index is greater than the length" do
a = [1, 2, 3]
- -> { @s.rb_ary_store(a, -10, 5) }.should raise_error(IndexError)
+ lambda { @s.rb_ary_store(a, -10, 5) }.should raise_error(IndexError)
end
it "enlarges the array as needed" do
@@ -214,9 +214,9 @@ describe "C-API Array function" do
a.should == [nil, nil, 7]
end
- it "raises a #{frozen_error_class} if the array is frozen" do
+ it "raises a RuntimeError if the array is frozen" do
a = [1, 2, 3].freeze
- -> { @s.rb_ary_store(a, 1, 5) }.should raise_error(frozen_error_class)
+ lambda { @s.rb_ary_store(a, 1, 5) }.should raise_error(RuntimeError)
end
end
@@ -249,14 +249,6 @@ describe "C-API Array function" do
@s.RARRAY_PTR_assign(a, :set)
a.should == [:set, :set, :set]
end
-
- it "allows memcpying between arrays" do
- a = [1, 2, 3]
- b = [0, 0, 0]
- @s.RARRAY_PTR_memcpy(a, b)
- b.should == [1, 2, 3]
- a.should == [1, 2, 3] # check a was not modified
- end
end
describe "RARRAY_LEN" do
diff --git a/spec/ruby/optional/capi/bignum_spec.rb b/spec/ruby/optional/capi/bignum_spec.rb
index b20275b8f7..a5d5995dc0 100644
--- a/spec/ruby/optional/capi/bignum_spec.rb
+++ b/spec/ruby/optional/capi/bignum_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("bignum")
@@ -33,8 +33,8 @@ describe "CApiBignumSpecs" do
end
it "raises RangeError if passed Bignum overflow long" do
- -> { @s.rb_big2long(ensure_bignum(@max_long + 1)) }.should raise_error(RangeError)
- -> { @s.rb_big2long(ensure_bignum(@min_long - 1)) }.should raise_error(RangeError)
+ lambda { @s.rb_big2long(ensure_bignum(@max_long + 1)) }.should raise_error(RangeError)
+ lambda { @s.rb_big2long(ensure_bignum(@min_long - 1)) }.should raise_error(RangeError)
end
end
@@ -47,8 +47,8 @@ describe "CApiBignumSpecs" do
end
it "raises RangeError if passed Bignum overflow long" do
- -> { @s.rb_big2ll(ensure_bignum(@max_long << 40)) }.should raise_error(RangeError)
- -> { @s.rb_big2ll(ensure_bignum(@min_long << 40)) }.should raise_error(RangeError)
+ lambda { @s.rb_big2ll(ensure_bignum(@max_long << 40)) }.should raise_error(RangeError)
+ lambda { @s.rb_big2ll(ensure_bignum(@min_long << 40)) }.should raise_error(RangeError)
end
end
@@ -65,8 +65,8 @@ describe "CApiBignumSpecs" do
end
it "raises RangeError if passed Bignum overflow long" do
- -> { @s.rb_big2ulong(ensure_bignum(@max_ulong + 1)) }.should raise_error(RangeError)
- -> { @s.rb_big2ulong(ensure_bignum(@min_long - 1)) }.should raise_error(RangeError)
+ lambda { @s.rb_big2ulong(ensure_bignum(@max_ulong + 1)) }.should raise_error(RangeError)
+ lambda { @s.rb_big2ulong(ensure_bignum(@min_long - 1)) }.should raise_error(RangeError)
end
end
@@ -97,16 +97,6 @@ describe "CApiBignumSpecs" do
end
end
- describe "RBIGNUM_SIGN" do
- it "returns 1 for a positive Bignum" do
- @s.RBIGNUM_SIGN(bignum_value(1)).should == 1
- end
-
- it "returns 0 for a negative Bignum" do
- @s.RBIGNUM_SIGN(-bignum_value(1)).should == 0
- end
- end
-
describe "rb_big_cmp" do
it "compares a Bignum with a Bignum" do
@s.rb_big_cmp(bignum_value, bignum_value(1)).should == -1
@@ -212,13 +202,13 @@ describe "CApiBignumSpecs" do
it "raises FloatDomainError for Infinity values" do
inf = 1.0 / 0
- -> { @s.rb_dbl2big(inf) }.should raise_error(FloatDomainError)
+ lambda { @s.rb_dbl2big(inf) }.should raise_error(FloatDomainError)
end
it "raises FloatDomainError for NaN values" do
nan = 0.0 / 0
- -> { @s.rb_dbl2big(nan) }.should raise_error(FloatDomainError)
+ lambda { @s.rb_dbl2big(nan) }.should raise_error(FloatDomainError)
end
end
end
diff --git a/spec/ruby/optional/capi/boolean_spec.rb b/spec/ruby/optional/capi/boolean_spec.rb
index 351419cbec..49303662e7 100644
--- a/spec/ruby/optional/capi/boolean_spec.rb
+++ b/spec/ruby/optional/capi/boolean_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("boolean")
diff --git a/spec/ruby/optional/capi/class_spec.rb b/spec/ruby/optional/capi/class_spec.rb
index 0b03fb9e6c..a25e80af60 100644
--- a/spec/ruby/optional/capi/class_spec.rb
+++ b/spec/ruby/optional/capi/class_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'spec_helper'
-require_relative 'fixtures/class'
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/class', __FILE__)
load_extension("class")
compile_extension("class_under_autoload")
@@ -18,19 +18,19 @@ describe :rb_path_to_class, shared: true do
end
it "raises an ArgumentError if a constant in the path does not exist" do
- -> { @s.send(@method, "CApiClassSpecs::NotDefined::B") }.should raise_error(ArgumentError)
+ lambda { @s.send(@method, "CApiClassSpecs::NotDefined::B") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the final constant does not exist" do
- -> { @s.send(@method, "CApiClassSpecs::NotDefined") }.should raise_error(ArgumentError)
+ lambda { @s.send(@method, "CApiClassSpecs::NotDefined") }.should raise_error(ArgumentError)
end
it "raises a TypeError if the constant is not a class or module" do
- -> { @s.send(@method, "CApiClassSpecs::A::C") }.should raise_error(TypeError)
+ lambda { @s.send(@method, "CApiClassSpecs::A::C") }.should raise_error(TypeError)
end
it "raises an ArgumentError even if a constant in the path exists on toplevel" do
- -> { @s.send(@method, "CApiClassSpecs::Object") }.should raise_error(ArgumentError)
+ lambda { @s.send(@method, "CApiClassSpecs::Object") }.should raise_error(ArgumentError)
end
end
@@ -56,7 +56,7 @@ describe "C-API Class function" do
it "includes a module into a class" do
c = Class.new
o = c.new
- -> { o.included? }.should raise_error(NameError)
+ lambda { o.included? }.should raise_error(NameError)
@s.rb_include_module(c, CApiClassSpecs::M)
o.included?.should be_true
end
@@ -70,12 +70,12 @@ describe "C-API Class function" do
it "defines an attr_reader when passed true, false" do
@s.rb_define_attr(CApiClassSpecs::Attr, :foo, true, false)
@a.foo.should == 1
- -> { @a.foo = 5 }.should raise_error(NameError)
+ lambda { @a.foo = 5 }.should raise_error(NameError)
end
it "defines an attr_writer when passed false, true" do
@s.rb_define_attr(CApiClassSpecs::Attr, :bar, false, true)
- -> { @a.bar }.should raise_error(NameError)
+ lambda { @a.bar }.should raise_error(NameError)
@a.bar = 5
@a.instance_variable_get(:@bar).should == 5
end
@@ -95,12 +95,6 @@ describe "C-API Class function" do
obj.call_super_method.should == :super_method
end
- it "calls the method in the superclass with the correct self" do
- @s.define_call_super_method CApiClassSpecs::SubSelf, "call_super_method"
- obj = CApiClassSpecs::SubSelf.new
- obj.call_super_method.should equal obj
- end
-
it "calls the method in the superclass through two native levels" do
@s.define_call_super_method CApiClassSpecs::Sub, "call_super_method"
@s.define_call_super_method CApiClassSpecs::SubSub, "call_super_method"
@@ -109,16 +103,6 @@ describe "C-API Class function" do
end
end
- describe "rb_define_method" do
- it "defines a method taking variable arguments as a C array if the argument count is -1" do
- @s.rb_method_varargs_1(1, 3, 7, 4).should == [1, 3, 7, 4]
- end
-
- it "defines a method taking variable arguments as a Ruby array if the argument count is -2" do
- @s.rb_method_varargs_2(1, 3, 7, 4).should == [1, 3, 7, 4]
- end
- end
-
describe "rb_class2name" do
it "returns the class name" do
@s.rb_class2name(CApiClassSpecs).should == "CApiClassSpecs"
@@ -187,7 +171,7 @@ describe "C-API Class function" do
end
it "raises a NameError if the class variable is not defined" do
- -> {
+ lambda {
@s.rb_cv_get(CApiClassSpecs::CVars, "@@no_cvar")
}.should raise_error(NameError, /class variable @@no_cvar/)
end
@@ -226,21 +210,23 @@ describe "C-API Class function" do
end
it "raises a TypeError when given a non class object to superclass" do
- -> {
+ lambda {
@s.rb_define_class("ClassSpecDefineClass3", Module.new)
}.should raise_error(TypeError)
end
it "raises a TypeError when given a mismatched class to superclass" do
- -> {
+ lambda {
@s.rb_define_class("ClassSpecDefineClass", Object)
}.should raise_error(TypeError)
end
- it "raises a ArgumentError when given NULL as superclass" do
- -> {
- @s.rb_define_class("ClassSpecDefineClass4", nil)
- }.should raise_error(ArgumentError)
+ ruby_version_is "2.4" do
+ it "raises a ArgumentError when given NULL as superclass" do
+ lambda {
+ @s.rb_define_class("ClassSpecDefineClass4", nil)
+ }.should raise_error(ArgumentError)
+ end
end
end
@@ -265,26 +251,40 @@ describe "C-API Class function" do
end
it "raises a TypeError when given a non class object to superclass" do
- -> { @s.rb_define_class_under(CApiClassSpecs,
+ lambda { @s.rb_define_class_under(CApiClassSpecs,
"ClassUnder5",
Module.new)
}.should raise_error(TypeError)
end
- it "raises a TypeError when given a mismatched class to superclass" do
- CApiClassSpecs::ClassUnder6 = Class.new(CApiClassSpecs::Super)
- -> { @s.rb_define_class_under(CApiClassSpecs,
- "ClassUnder6",
- Class.new)
- }.should raise_error(TypeError)
+ ruby_version_is "2.3" do
+ it "raises a TypeError when given a mismatched class to superclass" do
+ CApiClassSpecs::ClassUnder6 = Class.new(CApiClassSpecs::Super)
+ lambda { @s.rb_define_class_under(CApiClassSpecs,
+ "ClassUnder6",
+ Class.new)
+ }.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is ""..."2.3" do
+ it "raises a NameError when given a mismatched class to superclass" do
+ CApiClassSpecs::ClassUnder6 = Class.new(CApiClassSpecs::Super)
+ lambda { @s.rb_define_class_under(CApiClassSpecs,
+ "ClassUnder6",
+ Class.new)
+ }.should raise_error(NameError)
+ end
end
it "defines a class for an existing Autoload" do
ClassUnderAutoload.name.should == "ClassUnderAutoload"
end
- it "raises a TypeError if class is defined and its superclass mismatches the given one" do
- -> { @s.rb_define_class_under(CApiClassSpecs, "Sub", Object) }.should raise_error(TypeError)
+ ruby_version_is "2.3" do
+ it "raises a TypeError if class is defined and its superclass mismatches the given one" do
+ lambda { @s.rb_define_class_under(CApiClassSpecs, "Sub", Object) }.should raise_error(TypeError)
+ end
end
end
@@ -310,8 +310,10 @@ describe "C-API Class function" do
ClassIdUnderAutoload.name.should == "ClassIdUnderAutoload"
end
- it "raises a TypeError if class is defined and its superclass mismatches the given one" do
- -> { @s.rb_define_class_id_under(CApiClassSpecs, :Sub, Object) }.should raise_error(TypeError)
+ ruby_version_is "2.3" do
+ it "raises a TypeError if class is defined and its superclass mismatches the given one" do
+ lambda { @s.rb_define_class_id_under(CApiClassSpecs, :Sub, Object) }.should raise_error(TypeError)
+ end
end
end
@@ -331,7 +333,7 @@ describe "C-API Class function" do
end
it "raises a NameError if the class variable is not defined" do
- -> {
+ lambda {
@s.rb_cvar_get(CApiClassSpecs::CVars, "@@no_cvar")
}.should raise_error(NameError, /class variable @@no_cvar/)
end
@@ -344,12 +346,12 @@ describe "C-API Class function" do
end
it "raises a TypeError if passed Class as the superclass" do
- -> { @s.rb_class_new(Class) }.should raise_error(TypeError)
+ lambda { @s.rb_class_new(Class) }.should raise_error(TypeError)
end
it "raises a TypeError if passed a singleton class as the superclass" do
metaclass = Object.new.singleton_class
- -> { @s.rb_class_new(metaclass) }.should raise_error(TypeError)
+ lambda { @s.rb_class_new(metaclass) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/optional/capi/complex_spec.rb b/spec/ruby/optional/capi/complex_spec.rb
index 3d8142d172..ad84e47ced 100644
--- a/spec/ruby/optional/capi/complex_spec.rb
+++ b/spec/ruby/optional/capi/complex_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("complex")
diff --git a/spec/ruby/optional/capi/constants_spec.rb b/spec/ruby/optional/capi/constants_spec.rb
index 11a328a91f..096332971c 100644
--- a/spec/ruby/optional/capi/constants_spec.rb
+++ b/spec/ruby/optional/capi/constants_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("constants")
@@ -11,6 +11,12 @@ describe "C-API constant" do
@s.rb_cArray.should == Array
end
+ ruby_version_is ""..."2.4" do
+ specify "rb_cBignum references the Bignum class" do
+ @s.rb_cBignum.should == Bignum
+ end
+ end
+
specify "rb_cClass references the Class class" do
@s.rb_cClass.should == Class
end
@@ -37,6 +43,12 @@ describe "C-API constant" do
@s.rb_cFile.should == File
end
+ ruby_version_is ""..."2.4" do
+ specify "rb_cFixnum references the Fixnum class" do
+ @s.rb_cFixnum.should == Fixnum
+ end
+ end
+
specify "rb_cFloat references the Float class" do
@s.rb_cFloat.should == Float
end
diff --git a/spec/ruby/optional/capi/data_spec.rb b/spec/ruby/optional/capi/data_spec.rb
index c03b863678..ae1f57b091 100644
--- a/spec/ruby/optional/capi/data_spec.rb
+++ b/spec/ruby/optional/capi/data_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("data")
@@ -19,6 +19,11 @@ describe "CApiWrappedStruct" do
@s.get_struct(a).should == 1024
end
+ it "allows for using NULL as the klass for Data_Wrap_Struct" do
+ a = @s.wrap_struct_null(1024)
+ @s.get_struct(a).should == 1024
+ end
+
describe "RDATA()" do
it "returns the struct data" do
a = @s.wrap_struct(1024)
@@ -30,10 +35,6 @@ describe "CApiWrappedStruct" do
@s.change_struct(a, 100)
@s.get_struct(a).should == 100
end
-
- it "raises a TypeError if the object does not wrap a struct" do
- -> { @s.get_struct(Object.new) }.should raise_error(TypeError)
- end
end
describe "DATA_PTR" do
diff --git a/spec/ruby/optional/capi/encoding_spec.rb b/spec/ruby/optional/capi/encoding_spec.rb
index 003edc9669..d6b0bacd70 100644
--- a/spec/ruby/optional/capi/encoding_spec.rb
+++ b/spec/ruby/optional/capi/encoding_spec.rb
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
-require_relative 'spec_helper'
-require_relative 'fixtures/encoding'
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/encoding', __FILE__)
load_extension('encoding')
@@ -12,6 +12,24 @@ describe :rb_enc_get_index, shared: true do
it "returns the index of the encoding of a Regexp" do
@s.send(@method, /regexp/).should >= 0
end
+
+ it "returns the index of the encoding of an Object" do
+ obj = mock("rb_enc_get_index string")
+ @s.rb_enc_set_index(obj, 1)
+ @s.send(@method, obj).should == 1
+ end
+
+ it "returns the index of the dummy encoding of an Object" do
+ obj = mock("rb_enc_get_index string")
+ index = Encoding.list.index(Encoding::UTF_16)
+ @s.rb_enc_set_index(obj, index)
+ @s.send(@method, obj).should == index
+ end
+
+ it "returns 0 for an object without an encoding" do
+ obj = mock("rb_enc_get_index string")
+ @s.send(@method, obj).should == 0
+ end
end
describe :rb_enc_set_index, shared: true do
@@ -21,7 +39,7 @@ describe :rb_enc_set_index, shared: true do
# This is used because indexes should be considered implementation
# dependent. So a pair is returned:
- # [rb_enc_find_index() -> name, rb_enc_get(obj) -> name]
+ # [rb_enc_find_index()->name, rb_enc_get(obj)->name]
result.first.should == result.last
end
@@ -31,30 +49,22 @@ describe :rb_enc_set_index, shared: true do
result.first.should == result.last
end
- ruby_version_is "2.6" do
- it "raises an ArgumentError for a non-encoding capable object" do
- obj = Object.new
- -> {
- result = @s.send(@method, obj, 1)
- }.should raise_error(ArgumentError, "cannot set encoding on non-encoding capable object")
- end
+ it "associates an encoding with an object" do
+ obj = mock("rb_enc_set_index string")
+ result = @s.send(@method, obj, 1)
+ result.first.should == result.last
end
end
describe "C-API Encoding function" do
- @n = 0
-
before :each do
@s = CApiEncodingSpecs.new
end
- ruby_version_is "2.6" do
- describe "rb_enc_alias" do
- it "creates an alias for an existing Encoding" do
- name = "ZOMGWTFBBQ#{@n += 1}"
- @s.rb_enc_alias(name, "UTF-8").should >= 0
- Encoding.find(name).name.should == "UTF-8"
- end
+ describe "rb_encdb_alias" do
+ it "creates an alias for an existing Encoding" do
+ @s.rb_encdb_alias("ZOMGWTFBBQ", "UTF-8").should >= 0
+ Encoding.find("ZOMGWTFBBQ").name.should == "UTF-8"
end
end
@@ -95,7 +105,7 @@ describe "C-API Encoding function" do
end
describe "rb_ascii8bit_encoding" do
- it "returns the encoding for Encoding::BINARY" do
+ it "returns the encoding for Encoding::ASCII_8BIT" do
@s.rb_ascii8bit_encoding.should == "ASCII-8BIT"
end
end
@@ -125,16 +135,16 @@ describe "C-API Encoding function" do
end
describe "rb_enc_get" do
- it "returns the encoding associated with an object" do
- str = "abc".encode Encoding::BINARY
+ it "returns the encoding ossociated with an object" do
+ str = "abc".encode Encoding::ASCII_8BIT
@s.rb_enc_get(str).should == "ASCII-8BIT"
end
end
describe "rb_obj_encoding" do
- it "returns the encoding associated with an object" do
- str = "abc".encode Encoding::BINARY
- @s.rb_obj_encoding(str).should == Encoding::BINARY
+ it "returns the encoding ossociated with an object" do
+ str = "abc".encode Encoding::ASCII_8BIT
+ @s.rb_obj_encoding(str).should == Encoding::ASCII_8BIT
end
end
@@ -142,22 +152,15 @@ describe "C-API Encoding function" do
it_behaves_like :rb_enc_get_index, :rb_enc_get_index
it "returns the index of the encoding of a Symbol" do
- @s.rb_enc_get_index(:symbol).should >= 0
+ @s.send(@method, :symbol).should >= 0
end
it "returns -1 as the index of nil" do
- @s.rb_enc_get_index(nil).should == -1
+ @s.send(@method, nil).should == -1
end
it "returns -1 as the index for immediates" do
- @s.rb_enc_get_index(1).should == -1
- end
-
- ruby_version_is "2.6" do
- it "returns -1 for an object without an encoding" do
- obj = Object.new
- @s.rb_enc_get_index(obj).should == -1
- end
+ @s.send(@method, 1).should == -1
end
end
@@ -174,15 +177,15 @@ describe "C-API Encoding function" do
end
describe "rb_enc_str_coderange" do
- describe "when the encoding is BINARY" do
+ describe "when the encoding is ASCII-8BIT" do
it "returns ENC_CODERANGE_7BIT if there are no high bits set" do
- result = @s.rb_enc_str_coderange("abc".force_encoding("binary"))
+ result = @s.rb_enc_str_coderange("abc".force_encoding("ascii-8bit"))
result.should == :coderange_7bit
end
it "returns ENC_CODERANGE_VALID if there are high bits set" do
xEE = [0xEE].pack('C').force_encoding('utf-8')
- result = @s.rb_enc_str_coderange(xEE.force_encoding("binary"))
+ result = @s.rb_enc_str_coderange(xEE.force_encoding("ascii-8bit"))
result.should == :coderange_valid
end
end
@@ -283,7 +286,7 @@ describe "C-API Encoding function" do
describe "rb_enc_compatible" do
it "returns 0 if the encodings of the Strings are not compatible" do
- a = [0xff].pack('C').force_encoding "binary"
+ a = [0xff].pack('C').force_encoding "ascii-8bit"
b = "\u3042".encode("utf-8")
@s.rb_enc_compatible(a, b).should == 0
end
@@ -308,7 +311,7 @@ describe "C-API Encoding function" do
end
it "raises a RuntimeError if the second argument is a Symbol" do
- -> { @s.rb_enc_copy(:symbol, @obj) }.should raise_error(RuntimeError)
+ lambda { @s.rb_enc_copy(:symbol, @obj) }.should raise_error(RuntimeError)
end
it "sets the encoding of a Regexp to that of the second argument" do
@@ -348,34 +351,34 @@ describe "C-API Encoding function" do
end
it "returns the encoding for Encoding.default_external" do
- Encoding.default_external = "ASCII-8BIT"
+ Encoding.default_external = "BINARY"
@s.rb_default_external_encoding.should == "ASCII-8BIT"
end
end
describe "rb_enc_associate" do
it "sets the encoding of a String to the encoding" do
- @s.rb_enc_associate("string", "BINARY").encoding.should == Encoding::BINARY
+ @s.rb_enc_associate("string", "ASCII-8BIT").encoding.should == Encoding::ASCII_8BIT
end
it "raises a RuntimeError if the argument is Symbol" do
- -> { @s.rb_enc_associate(:symbol, "US-ASCII") }.should raise_error(RuntimeError)
+ lambda { @s.rb_enc_associate(:symbol, "US-ASCII") }.should raise_error(RuntimeError)
end
it "sets the encoding of a Regexp to the encoding" do
- @s.rb_enc_associate(/regexp/, "BINARY").encoding.should == Encoding::BINARY
+ @s.rb_enc_associate(/regexp/, "ASCII-8BIT").encoding.should == Encoding::ASCII_8BIT
end
it "sets the encoding of a String to a default when the encoding is NULL" do
- @s.rb_enc_associate("string", nil).encoding.should == Encoding::BINARY
+ @s.rb_enc_associate("string", nil).encoding.should == Encoding::ASCII_8BIT
end
end
describe "rb_enc_associate_index" do
it "sets the encoding of a String to the encoding" do
- index = @s.rb_enc_find_index("BINARY")
+ index = @s.rb_enc_find_index("ASCII-8BIT")
enc = @s.rb_enc_associate_index("string", index).encoding
- enc.should == Encoding::BINARY
+ enc.should == Encoding::ASCII_8BIT
end
it "sets the encoding of a Regexp to the encoding" do
@@ -386,7 +389,7 @@ describe "C-API Encoding function" do
it "sets the encoding of a Symbol to the encoding" do
index = @s.rb_enc_find_index("UTF-8")
- -> { @s.rb_enc_associate_index(:symbol, index) }.should raise_error(RuntimeError)
+ lambda { @s.rb_enc_associate_index(:symbol, index) }.should raise_error(RuntimeError)
end
end
@@ -440,13 +443,13 @@ describe "C-API Encoding function" do
describe "rb_enc_codepoint_len" do
it "raises ArgumentError if an empty string is given" do
- -> do
+ lambda do
@s.rb_enc_codepoint_len("")
end.should raise_error(ArgumentError)
end
it "raises ArgumentError if an invalid byte sequence is given" do
- -> do
+ lambda do
@s.rb_enc_codepoint_len([0xa0, 0xa1].pack('CC').force_encoding('utf-8')) # Invalid sequence identifier
end.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/optional/capi/enumerator_spec.rb b/spec/ruby/optional/capi/enumerator_spec.rb
index 9ed68c9063..44634f73a1 100644
--- a/spec/ruby/optional/capi/enumerator_spec.rb
+++ b/spec/ruby/optional/capi/enumerator_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("enumerator")
@@ -36,31 +36,4 @@ describe "C-API Enumerator function" do
enumerator.each {}
end
end
-
- describe "rb_enumeratorize_with_size" do
-
- it "enumerates the given object" do
- enumerator = @s.rb_enumeratorize_with_size(@enumerable, :each)
- enumerated = []
- enumerator.each { |i| enumerated << i }
- enumerated.should == @enumerable
- end
-
- it "uses the given method for enumeration" do
- enumerator = @s.rb_enumeratorize_with_size(@enumerable, :awesome_each)
- @enumerable.should_receive(:awesome_each)
- enumerator.each {}
- end
-
- it "passes the given arguments to the enumeration method" do
- enumerator = @s.rb_enumeratorize_with_size(@enumerable, :each, :arg1, :arg2)
- @enumerable.should_receive(:each).with(:arg1, :arg2)
- enumerator.each {}
- end
-
- it "uses the size function to report the size" do
- enumerator = @s.rb_enumeratorize_with_size(@enumerable, :each, :arg1, :arg2)
- enumerator.size.should == 7
- end
- end
end
diff --git a/spec/ruby/optional/capi/exception_spec.rb b/spec/ruby/optional/capi/exception_spec.rb
index 62d7d3706e..4800e6ffc0 100644
--- a/spec/ruby/optional/capi/exception_spec.rb
+++ b/spec/ruby/optional/capi/exception_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("exception")
@@ -28,13 +28,13 @@ describe "C-API Exception function" do
describe "rb_exc_raise" do
it "raises passed exception" do
runtime_error = RuntimeError.new '42'
- -> { @s.rb_exc_raise(runtime_error) }.should raise_error(RuntimeError, '42')
+ lambda { @s.rb_exc_raise(runtime_error) }.should raise_error(RuntimeError, '42')
end
it "raises an exception with an empty backtrace" do
runtime_error = RuntimeError.new '42'
runtime_error.set_backtrace []
- -> { @s.rb_exc_raise(runtime_error) }.should raise_error(RuntimeError, '42')
+ lambda { @s.rb_exc_raise(runtime_error) }.should raise_error(RuntimeError, '42')
end
end
@@ -52,7 +52,7 @@ describe "C-API Exception function" do
end
it "raises a TypeError if the object is not nil or an Exception instance" do
- -> { @s.rb_set_errinfo("error") }.should raise_error(TypeError)
+ lambda { @s.rb_set_errinfo("error") }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/optional/capi/ext/array_spec.c b/spec/ruby/optional/capi/ext/array_spec.c
index 454cf03303..8bc144195c 100644
--- a/spec/ruby/optional/capi/ext/array_spec.c
+++ b/spec/ruby/optional/capi/ext/array_spec.c
@@ -7,10 +7,13 @@
extern "C" {
#endif
+#ifdef HAVE_RB_ARRAY
static VALUE array_spec_rb_Array(VALUE self, VALUE object) {
return rb_Array(object);
}
+#endif
+#if defined(HAVE_RARRAY_LEN) && defined(HAVE_RARRAY_PTR)
static VALUE array_spec_RARRAY_PTR_iterate(VALUE self, VALUE array) {
int i;
VALUE* ptr;
@@ -32,88 +35,109 @@ static VALUE array_spec_RARRAY_PTR_assign(VALUE self, VALUE array, VALUE value)
}
return Qnil;
}
+#endif
-
-static VALUE array_spec_RARRAY_PTR_memcpy(VALUE self, VALUE array1, VALUE array2) {
- VALUE *ptr1, *ptr2;
- long size;
- size = RARRAY_LEN(array1);
- ptr1 = RARRAY_PTR(array1);
- ptr2 = RARRAY_PTR(array2);
- if (ptr1 != NULL && ptr2 != NULL) {
- memcpy(ptr2, ptr1, size * sizeof(VALUE));
- }
- return Qnil;
-}
-
+#ifdef HAVE_RARRAY_LEN
static VALUE array_spec_RARRAY_LEN(VALUE self, VALUE array) {
return INT2FIX(RARRAY_LEN(array));
}
+#endif
+#ifdef HAVE_RARRAY_AREF
static VALUE array_spec_RARRAY_AREF(VALUE self, VALUE array, VALUE index) {
return RARRAY_AREF(array, FIX2INT(index));
}
+#endif
+#ifdef HAVE_RB_ARY_AREF
static VALUE array_spec_rb_ary_aref(int argc, VALUE *argv, VALUE self) {
VALUE ary, args;
rb_scan_args(argc, argv, "1*", &ary, &args);
return rb_ary_aref((int)RARRAY_LEN(args), RARRAY_PTR(args), ary);
}
+#endif
+#ifdef HAVE_RB_ARY_CLEAR
static VALUE array_spec_rb_ary_clear(VALUE self, VALUE array) {
return rb_ary_clear(array);
}
+#endif
+#ifdef HAVE_RB_ARY_DELETE
static VALUE array_spec_rb_ary_delete(VALUE self, VALUE array, VALUE item) {
return rb_ary_delete(array, item);
}
+#endif
+#ifdef HAVE_RB_ARY_DELETE_AT
static VALUE array_spec_rb_ary_delete_at(VALUE self, VALUE array, VALUE index) {
return rb_ary_delete_at(array, NUM2LONG(index));
}
+#endif
+#ifdef HAVE_RB_ARY_DUP
static VALUE array_spec_rb_ary_dup(VALUE self, VALUE array) {
return rb_ary_dup(array);
}
+#endif
+#ifdef HAVE_RB_ARY_ENTRY
static VALUE array_spec_rb_ary_entry(VALUE self, VALUE array, VALUE offset) {
return rb_ary_entry(array, FIX2INT(offset));
}
+#endif
+#ifdef HAVE_RB_ARY_INCLUDES
static VALUE array_spec_rb_ary_includes(VALUE self, VALUE ary, VALUE item) {
return rb_ary_includes(ary, item);
}
+#endif
+#ifdef HAVE_RB_ARY_JOIN
static VALUE array_spec_rb_ary_join(VALUE self, VALUE array1, VALUE array2) {
return rb_ary_join(array1, array2);
}
+#endif
+#ifdef HAVE_RB_ARY_TO_S
static VALUE array_spec_rb_ary_to_s(VALUE self, VALUE array) {
return rb_ary_to_s(array);
}
+#endif
+#ifdef HAVE_RB_ARY_NEW
static VALUE array_spec_rb_ary_new(VALUE self) {
VALUE ret;
ret = rb_ary_new();
return ret;
}
+#endif
+#ifdef HAVE_RB_ARY_NEW2
static VALUE array_spec_rb_ary_new2(VALUE self, VALUE length) {
return rb_ary_new2(NUM2LONG(length));
}
+#endif
+#ifdef HAVE_RB_ARY_NEW_CAPA
static VALUE array_spec_rb_ary_new_capa(VALUE self, VALUE length) {
return rb_ary_new_capa(NUM2LONG(length));
}
+#endif
+#ifdef HAVE_RB_ARY_NEW3
static VALUE array_spec_rb_ary_new3(VALUE self, VALUE first, VALUE second, VALUE third) {
return rb_ary_new3(3, first, second, third);
}
+#endif
+#ifdef HAVE_RB_ARY_NEW_FROM_ARGS
static VALUE array_spec_rb_ary_new_from_args(VALUE self, VALUE first, VALUE second, VALUE third) {
return rb_ary_new_from_args(3, first, second, third);
}
+#endif
+#ifdef HAVE_RB_ARY_NEW4
static VALUE array_spec_rb_ary_new4(VALUE self, VALUE first, VALUE second, VALUE third) {
VALUE values[3];
values[0] = first;
@@ -121,7 +145,9 @@ static VALUE array_spec_rb_ary_new4(VALUE self, VALUE first, VALUE second, VALUE
values[2] = third;
return rb_ary_new4(3, values);
}
+#endif
+#ifdef HAVE_RB_ARY_NEW_FROM_VALUES
static VALUE array_spec_rb_ary_new_from_values(VALUE self, VALUE first, VALUE second, VALUE third) {
VALUE values[3];
values[0] = first;
@@ -129,57 +155,81 @@ static VALUE array_spec_rb_ary_new_from_values(VALUE self, VALUE first, VALUE se
values[2] = third;
return rb_ary_new_from_values(3, values);
}
+#endif
+#ifdef HAVE_RB_ARY_POP
static VALUE array_spec_rb_ary_pop(VALUE self, VALUE array) {
return rb_ary_pop(array);
}
+#endif
+#ifdef HAVE_RB_ARY_PUSH
static VALUE array_spec_rb_ary_push(VALUE self, VALUE array, VALUE item) {
rb_ary_push(array, item);
return array;
}
+#endif
+#ifdef HAVE_RB_ARY_CAT
static VALUE array_spec_rb_ary_cat(int argc, VALUE *argv, VALUE self) {
VALUE ary, args;
rb_scan_args(argc, argv, "1*", &ary, &args);
return rb_ary_cat(ary, RARRAY_PTR(args), RARRAY_LEN(args));
}
+#endif
+#ifdef HAVE_RB_ARY_REVERSE
static VALUE array_spec_rb_ary_reverse(VALUE self, VALUE array) {
return rb_ary_reverse(array);
}
+#endif
+#ifdef HAVE_RB_ARY_ROTATE
static VALUE array_spec_rb_ary_rotate(VALUE self, VALUE array, VALUE count) {
return rb_ary_rotate(array, NUM2LONG(count));
}
+#endif
+#ifdef HAVE_RB_ARY_SHIFT
static VALUE array_spec_rb_ary_shift(VALUE self, VALUE array) {
return rb_ary_shift(array);
}
+#endif
+#ifdef HAVE_RB_ARY_STORE
static VALUE array_spec_rb_ary_store(VALUE self, VALUE array, VALUE offset, VALUE value) {
rb_ary_store(array, FIX2INT(offset), value);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_ARY_CONCAT
static VALUE array_spec_rb_ary_concat(VALUE self, VALUE array1, VALUE array2) {
return rb_ary_concat(array1, array2);
}
+#endif
+#ifdef HAVE_RB_ARY_PLUS
static VALUE array_spec_rb_ary_plus(VALUE self, VALUE array1, VALUE array2) {
return rb_ary_plus(array1, array2);
}
+#endif
+#ifdef HAVE_RB_ARY_UNSHIFT
static VALUE array_spec_rb_ary_unshift(VALUE self, VALUE array, VALUE val) {
return rb_ary_unshift(array, val);
}
+#endif
+#ifdef HAVE_RB_ASSOC_NEW
static VALUE array_spec_rb_assoc_new(VALUE self, VALUE first, VALUE second) {
return rb_assoc_new(first, second);
}
+#endif
-static VALUE copy_ary(RB_BLOCK_CALL_FUNC_ARGLIST(el, new_ary)) {
+#if defined(HAVE_RB_ITERATE) && defined(HAVE_RB_EACH)
+static VALUE copy_ary(VALUE el, VALUE new_ary) {
return rb_ary_push(new_ary, el);
}
@@ -191,7 +241,7 @@ static VALUE array_spec_rb_iterate(VALUE self, VALUE ary) {
return new_ary;
}
-static VALUE sub_pair(RB_BLOCK_CALL_FUNC_ARGLIST(el, holder)) {
+static VALUE sub_pair(VALUE el, VALUE holder) {
return rb_ary_push(holder, rb_ary_entry(el, 1));
}
@@ -207,7 +257,7 @@ static VALUE array_spec_rb_iterate_each_pair(VALUE self, VALUE obj) {
return new_ary;
}
-static VALUE iter_yield(RB_BLOCK_CALL_FUNC_ARGLIST(el, ary)) {
+static VALUE iter_yield(VALUE el, VALUE ary) {
rb_yield(el);
return Qnil;
}
@@ -216,68 +266,185 @@ static VALUE array_spec_rb_iterate_then_yield(VALUE self, VALUE obj) {
rb_iterate(rb_each, obj, iter_yield, obj);
return Qnil;
}
+#endif
+#if defined(HAVE_RB_MEM_CLEAR)
static VALUE array_spec_rb_mem_clear(VALUE self, VALUE obj) {
VALUE ary[1];
ary[0] = obj;
rb_mem_clear(ary, 1);
return ary[0];
}
+#endif
+#ifdef HAVE_RB_ARY_FREEZE
static VALUE array_spec_rb_ary_freeze(VALUE self, VALUE ary) {
return rb_ary_freeze(ary);
}
+#endif
+#ifdef HAVE_RB_ARY_TO_ARY
static VALUE array_spec_rb_ary_to_ary(VALUE self, VALUE ary) {
return rb_ary_to_ary(ary);
}
+#endif
+#ifdef HAVE_RB_ARY_SUBSEQ
static VALUE array_spec_rb_ary_subseq(VALUE self, VALUE ary, VALUE begin, VALUE len) {
return rb_ary_subseq(ary, FIX2LONG(begin), FIX2LONG(len));
}
+#endif
void Init_array_spec(void) {
- VALUE cls = rb_define_class("CApiArraySpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiArraySpecs", rb_cObject);
+
+#ifdef HAVE_RB_ARRAY
rb_define_method(cls, "rb_Array", array_spec_rb_Array, 1);
+#endif
+
+#ifdef HAVE_RARRAY_LEN
rb_define_method(cls, "RARRAY_LEN", array_spec_RARRAY_LEN, 1);
+#endif
+
+#if defined(HAVE_RARRAY_LEN) && defined(HAVE_RARRAY_PTR)
rb_define_method(cls, "RARRAY_PTR_iterate", array_spec_RARRAY_PTR_iterate, 1);
rb_define_method(cls, "RARRAY_PTR_assign", array_spec_RARRAY_PTR_assign, 2);
- rb_define_method(cls, "RARRAY_PTR_memcpy", array_spec_RARRAY_PTR_memcpy, 2);
+#endif
+
+#ifdef HAVE_RARRAY_AREF
rb_define_method(cls, "RARRAY_AREF", array_spec_RARRAY_AREF, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_AREF
rb_define_method(cls, "rb_ary_aref", array_spec_rb_ary_aref, -1);
+#endif
+
+#ifdef HAVE_RB_ARY_CLEAR
rb_define_method(cls, "rb_ary_clear", array_spec_rb_ary_clear, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_DELETE
rb_define_method(cls, "rb_ary_delete", array_spec_rb_ary_delete, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_DELETE_AT
rb_define_method(cls, "rb_ary_delete_at", array_spec_rb_ary_delete_at, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_DUP
rb_define_method(cls, "rb_ary_dup", array_spec_rb_ary_dup, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_ENTRY
rb_define_method(cls, "rb_ary_entry", array_spec_rb_ary_entry, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_INCLUDES
rb_define_method(cls, "rb_ary_includes", array_spec_rb_ary_includes, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_JOIN
rb_define_method(cls, "rb_ary_join", array_spec_rb_ary_join, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_TO_S
rb_define_method(cls, "rb_ary_to_s", array_spec_rb_ary_to_s, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW
rb_define_method(cls, "rb_ary_new", array_spec_rb_ary_new, 0);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW2
rb_define_method(cls, "rb_ary_new2", array_spec_rb_ary_new2, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW_CAPA
rb_define_method(cls, "rb_ary_new_capa", array_spec_rb_ary_new_capa, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW3
rb_define_method(cls, "rb_ary_new3", array_spec_rb_ary_new3, 3);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW_FROM_ARGS
rb_define_method(cls, "rb_ary_new_from_args", array_spec_rb_ary_new_from_args, 3);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW4
rb_define_method(cls, "rb_ary_new4", array_spec_rb_ary_new4, 3);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW_FROM_VALUES
rb_define_method(cls, "rb_ary_new_from_values", array_spec_rb_ary_new_from_values, 3);
+#endif
+
+#ifdef HAVE_RB_ARY_POP
rb_define_method(cls, "rb_ary_pop", array_spec_rb_ary_pop, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_PUSH
rb_define_method(cls, "rb_ary_push", array_spec_rb_ary_push, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_CAT
rb_define_method(cls, "rb_ary_cat", array_spec_rb_ary_cat, -1);
+#endif
+
+#ifdef HAVE_RB_ARY_REVERSE
rb_define_method(cls, "rb_ary_reverse", array_spec_rb_ary_reverse, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_ROTATE
rb_define_method(cls, "rb_ary_rotate", array_spec_rb_ary_rotate, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_SHIFT
rb_define_method(cls, "rb_ary_shift", array_spec_rb_ary_shift, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_STORE
rb_define_method(cls, "rb_ary_store", array_spec_rb_ary_store, 3);
+#endif
+
+#ifdef HAVE_RB_ARY_CONCAT
rb_define_method(cls, "rb_ary_concat", array_spec_rb_ary_concat, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_PLUS
rb_define_method(cls, "rb_ary_plus", array_spec_rb_ary_plus, 2);
+#endif
+
+#ifdef HAVE_RB_ARY_UNSHIFT
rb_define_method(cls, "rb_ary_unshift", array_spec_rb_ary_unshift, 2);
+#endif
+
+#ifdef HAVE_RB_ASSOC_NEW
rb_define_method(cls, "rb_assoc_new", array_spec_rb_assoc_new, 2);
+#endif
+
+#if defined(HAVE_RB_ITERATE) && defined(HAVE_RB_EACH)
rb_define_method(cls, "rb_iterate", array_spec_rb_iterate, 1);
rb_define_method(cls, "rb_iterate_each_pair", array_spec_rb_iterate_each_pair, 1);
rb_define_method(cls, "rb_iterate_then_yield", array_spec_rb_iterate_then_yield, 1);
+#endif
+
+#if defined(HAVE_RB_MEM_CLEAR)
rb_define_method(cls, "rb_mem_clear", array_spec_rb_mem_clear, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_FREEZE
rb_define_method(cls, "rb_ary_freeze", array_spec_rb_ary_freeze, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_TO_ARY
rb_define_method(cls, "rb_ary_to_ary", array_spec_rb_ary_to_ary, 1);
+#endif
+
+#ifdef HAVE_RB_ARY_SUBSEQ
rb_define_method(cls, "rb_ary_subseq", array_spec_rb_ary_subseq, 3);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/bignum_spec.c b/spec/ruby/optional/capi/ext/bignum_spec.c
index 14a51f5099..ab3b36eadc 100644
--- a/spec/ruby/optional/capi/ext/bignum_spec.c
+++ b/spec/ruby/optional/capi/ext/bignum_spec.c
@@ -5,40 +5,51 @@
extern "C" {
#endif
+#ifdef HAVE_RB_BIG2DBL
static VALUE bignum_spec_rb_big2dbl(VALUE self, VALUE num) {
return rb_float_new(rb_big2dbl(num));
}
+#endif
+#ifdef HAVE_RB_DBL2BIG
static VALUE bignum_spec_rb_dbl2big(VALUE self, VALUE num) {
double dnum = NUM2DBL(num);
return rb_dbl2big(dnum);
}
+#endif
+#ifdef HAVE_RB_BIG2LL
static VALUE bignum_spec_rb_big2ll(VALUE self, VALUE num) {
return rb_ll2inum(rb_big2ll(num));
}
+#endif
+#ifdef HAVE_RB_BIG2LONG
static VALUE bignum_spec_rb_big2long(VALUE self, VALUE num) {
return LONG2NUM(rb_big2long(num));
}
+#endif
+#ifdef HAVE_RB_BIG2STR
static VALUE bignum_spec_rb_big2str(VALUE self, VALUE num, VALUE base) {
return rb_big2str(num, FIX2INT(base));
}
+#endif
+#ifdef HAVE_RB_BIG2ULONG
static VALUE bignum_spec_rb_big2ulong(VALUE self, VALUE num) {
return ULONG2NUM(rb_big2ulong(num));
}
+#endif
-static VALUE bignum_spec_RBIGNUM_SIGN(VALUE self, VALUE val) {
- return INT2FIX(RBIGNUM_SIGN(val));
-}
-
+#ifdef HAVE_RB_BIG_CMP
static VALUE bignum_spec_rb_big_cmp(VALUE self, VALUE x, VALUE y) {
return rb_big_cmp(x, y);
}
+#endif
+#ifdef HAVE_RB_BIG_PACK
static VALUE bignum_spec_rb_big_pack(VALUE self, VALUE val) {
unsigned long buff;
@@ -46,7 +57,9 @@ static VALUE bignum_spec_rb_big_pack(VALUE self, VALUE val) {
return ULONG2NUM(buff);
}
+#endif
+#if HAVE_ABSINT_SIZE
static VALUE bignum_spec_rb_big_pack_length(VALUE self, VALUE val) {
long long_len;
int leading_bits = 0;
@@ -59,7 +72,9 @@ static VALUE bignum_spec_rb_big_pack_length(VALUE self, VALUE val) {
long_len = len / divisor + ((len % divisor == 0) ? 0 : 1);
return LONG2NUM(long_len);
}
+#endif
+#ifdef HAVE_RB_BIG_PACK
static VALUE bignum_spec_rb_big_pack_array(VALUE self, VALUE val, VALUE len) {
int i;
long long_len = NUM2LONG(len);
@@ -85,20 +100,48 @@ static VALUE bignum_spec_rb_big_pack_array(VALUE self, VALUE val, VALUE len) {
free(buf);
return ary;
}
+#endif
void Init_bignum_spec(void) {
- VALUE cls = rb_define_class("CApiBignumSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiBignumSpecs", rb_cObject);
+
+#ifdef HAVE_RB_BIG2DBL
rb_define_method(cls, "rb_big2dbl", bignum_spec_rb_big2dbl, 1);
+#endif
+
+#ifdef HAVE_RB_DBL2BIG
rb_define_method(cls, "rb_dbl2big", bignum_spec_rb_dbl2big, 1);
+#endif
+
+#ifdef HAVE_RB_BIG2LL
rb_define_method(cls, "rb_big2ll", bignum_spec_rb_big2ll, 1);
+#endif
+
+#ifdef HAVE_RB_BIG2LONG
rb_define_method(cls, "rb_big2long", bignum_spec_rb_big2long, 1);
+#endif
+
+#ifdef HAVE_RB_BIG2STR
rb_define_method(cls, "rb_big2str", bignum_spec_rb_big2str, 2);
+#endif
+
+#ifdef HAVE_RB_BIG2ULONG
rb_define_method(cls, "rb_big2ulong", bignum_spec_rb_big2ulong, 1);
- rb_define_method(cls, "RBIGNUM_SIGN", bignum_spec_RBIGNUM_SIGN, 1);
+#endif
+
+#ifdef HAVE_RB_BIG_CMP
rb_define_method(cls, "rb_big_cmp", bignum_spec_rb_big_cmp, 2);
+#endif
+
+#ifdef HAVE_RB_BIG_PACK
rb_define_method(cls, "rb_big_pack", bignum_spec_rb_big_pack, 1);
rb_define_method(cls, "rb_big_pack_array", bignum_spec_rb_big_pack_array, 2);
+#endif
+
+#ifdef HAVE_ABSINT_SIZE
rb_define_method(cls, "rb_big_pack_length", bignum_spec_rb_big_pack_length, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/boolean_spec.c b/spec/ruby/optional/capi/ext/boolean_spec.c
index 7bb6fe569d..94d79c0fc0 100644
--- a/spec/ruby/optional/capi/ext/boolean_spec.c
+++ b/spec/ruby/optional/capi/ext/boolean_spec.c
@@ -22,7 +22,8 @@ static VALUE boolean_spec_q_false(VALUE self) {
}
void Init_boolean_spec(void) {
- VALUE cls = rb_define_class("CApiBooleanSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiBooleanSpecs", rb_cObject);
rb_define_method(cls, "is_true", boolean_spec_is_true, 1);
rb_define_method(cls, "q_true", boolean_spec_q_true, 0);
rb_define_method(cls, "q_false", boolean_spec_q_false, 0);
diff --git a/spec/ruby/optional/capi/ext/class_spec.c b/spec/ruby/optional/capi/ext/class_spec.c
index 6e5c02e657..e3860df1da 100644
--- a/spec/ruby/optional/capi/ext/class_spec.c
+++ b/spec/ruby/optional/capi/ext/class_spec.c
@@ -8,6 +8,7 @@
extern "C" {
#endif
+#ifdef HAVE_RB_CALL_SUPER
static VALUE class_spec_call_super_method(VALUE self) {
return rb_call_super(0, 0);
}
@@ -16,31 +17,45 @@ static VALUE class_spec_define_call_super_method(VALUE self, VALUE obj, VALUE st
rb_define_method(obj, RSTRING_PTR(str_name), class_spec_call_super_method, 0);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_CLASS_PATH
static VALUE class_spec_rb_class_path(VALUE self, VALUE klass) {
return rb_class_path(klass);
}
+#endif
+#ifdef HAVE_RB_CLASS_NAME
static VALUE class_spec_rb_class_name(VALUE self, VALUE klass) {
return rb_class_name(klass);
}
+#endif
+#ifdef HAVE_RB_CLASS2NAME
static VALUE class_spec_rb_class2name(VALUE self, VALUE klass) {
return rb_str_new2( rb_class2name(klass) );
}
+#endif
+#ifdef HAVE_RB_PATH2CLASS
static VALUE class_spec_rb_path2class(VALUE self, VALUE path) {
return rb_path2class(RSTRING_PTR(path));
}
+#endif
+#ifdef HAVE_RB_PATH_TO_CLASS
static VALUE class_spec_rb_path_to_class(VALUE self, VALUE path) {
return rb_path_to_class(path);
}
+#endif
+#ifdef HAVE_RB_CLASS_NEW
static VALUE class_spec_rb_class_new(VALUE self, VALUE super) {
return rb_class_new(super);
}
+#endif
+#ifdef HAVE_RB_CLASS_NEW_INSTANCE
static VALUE class_spec_rb_class_new_instance(VALUE self,
VALUE nargs, VALUE args,
VALUE klass) {
@@ -53,7 +68,9 @@ static VALUE class_spec_rb_class_new_instance(VALUE self,
return rb_class_new_instance(c_nargs, c_args, klass);
}
+#endif
+#ifdef HAVE_RB_CLASS_REAL
static VALUE class_spec_rb_class_real(VALUE self, VALUE object) {
if(rb_type_p(object, T_FIXNUM)) {
return INT2FIX(rb_class_real(FIX2INT(object)));
@@ -61,35 +78,49 @@ static VALUE class_spec_rb_class_real(VALUE self, VALUE object) {
return rb_class_real(CLASS_OF(object));
}
}
+#endif
+#ifdef HAVE_RB_CLASS_SUPERCLASS
static VALUE class_spec_rb_class_superclass(VALUE self, VALUE klass) {
return rb_class_superclass(klass);
}
+#endif
+#ifdef HAVE_RB_CVAR_DEFINED
static VALUE class_spec_cvar_defined(VALUE self, VALUE klass, VALUE id) {
ID as_id = rb_intern(StringValuePtr(id));
return rb_cvar_defined(klass, as_id);
}
+#endif
+#ifdef HAVE_RB_CVAR_GET
static VALUE class_spec_cvar_get(VALUE self, VALUE klass, VALUE name) {
return rb_cvar_get(klass, rb_intern(StringValuePtr(name)));
}
+#endif
+#ifdef HAVE_RB_CVAR_SET
static VALUE class_spec_cvar_set(VALUE self, VALUE klass, VALUE name, VALUE val) {
rb_cvar_set(klass, rb_intern(StringValuePtr(name)), val);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_CV_GET
static VALUE class_spec_cv_get(VALUE self, VALUE klass, VALUE name) {
return rb_cv_get(klass, StringValuePtr(name));
}
+#endif
+#ifdef HAVE_RB_CV_SET
static VALUE class_spec_cv_set(VALUE self, VALUE klass, VALUE name, VALUE val) {
rb_cv_set(klass, StringValuePtr(name), val);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_ATTR
VALUE class_spec_define_attr(VALUE self, VALUE klass, VALUE sym, VALUE read, VALUE write) {
int int_read, int_write;
int_read = read == Qtrue ? 1 : 0;
@@ -97,72 +128,132 @@ VALUE class_spec_define_attr(VALUE self, VALUE klass, VALUE sym, VALUE read, VAL
rb_define_attr(klass, rb_id2name(SYM2ID(sym)), int_read, int_write);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_CLASS
static VALUE class_spec_rb_define_class(VALUE self, VALUE name, VALUE super) {
if(NIL_P(super)) super = 0;
return rb_define_class(RSTRING_PTR(name), super);
}
+#endif
+#ifdef HAVE_RB_DEFINE_CLASS_UNDER
static VALUE class_spec_rb_define_class_under(VALUE self, VALUE outer,
VALUE name, VALUE super) {
if(NIL_P(super)) super = 0;
return rb_define_class_under(outer, RSTRING_PTR(name), super);
}
+#endif
+#ifdef HAVE_RB_DEFINE_CLASS_ID_UNDER
static VALUE class_spec_rb_define_class_id_under(VALUE self, VALUE outer,
VALUE name, VALUE super) {
if(NIL_P(super)) super = 0;
return rb_define_class_id_under(outer, SYM2ID(name), super);
}
+#endif
+#ifdef HAVE_RB_DEFINE_CLASS_VARIABLE
static VALUE class_spec_define_class_variable(VALUE self, VALUE klass, VALUE name, VALUE val) {
rb_define_class_variable(klass, StringValuePtr(name), val);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_INCLUDE_MODULE
static VALUE class_spec_include_module(VALUE self, VALUE klass, VALUE module) {
rb_include_module(klass, module);
return klass;
}
-
-static VALUE class_spec_method_var_args_1(int argc, VALUE *argv, VALUE self) {
- VALUE ary = rb_ary_new();
- int i;
- for (i = 0; i < argc; i++) {
- rb_ary_push(ary, argv[i]);
- }
- return ary;
-}
-
-static VALUE class_spec_method_var_args_2(VALUE self, VALUE argv) {
- return argv;
-}
+#endif
void Init_class_spec(void) {
- VALUE cls = rb_define_class("CApiClassSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiClassSpecs", rb_cObject);
+
+#ifdef HAVE_RB_CALL_SUPER
rb_define_method(cls, "define_call_super_method", class_spec_define_call_super_method, 2);
+#endif
+
+#ifdef HAVE_RB_CLASS_PATH
rb_define_method(cls, "rb_class_path", class_spec_rb_class_path, 1);
+#endif
+
+#ifdef HAVE_RB_CLASS_NAME
rb_define_method(cls, "rb_class_name", class_spec_rb_class_name, 1);
+#endif
+
+#ifdef HAVE_RB_CLASS2NAME
rb_define_method(cls, "rb_class2name", class_spec_rb_class2name, 1);
+#endif
+
+#ifdef HAVE_RB_PATH2CLASS
rb_define_method(cls, "rb_path2class", class_spec_rb_path2class, 1);
+#endif
+
+#ifdef HAVE_RB_PATH_TO_CLASS
rb_define_method(cls, "rb_path_to_class", class_spec_rb_path_to_class, 1);
+#endif
+
+#ifdef HAVE_RB_CLASS_NEW
rb_define_method(cls, "rb_class_new", class_spec_rb_class_new, 1);
+#endif
+
+#ifdef HAVE_RB_CLASS_NEW_INSTANCE
rb_define_method(cls, "rb_class_new_instance", class_spec_rb_class_new_instance, 3);
+#endif
+
+#ifdef HAVE_RB_CLASS_REAL
rb_define_method(cls, "rb_class_real", class_spec_rb_class_real, 1);
+#endif
+
+#ifdef HAVE_RB_CLASS_SUPERCLASS
rb_define_method(cls, "rb_class_superclass", class_spec_rb_class_superclass, 1);
+#endif
+
+#ifdef HAVE_RB_CVAR_DEFINED
rb_define_method(cls, "rb_cvar_defined", class_spec_cvar_defined, 2);
+#endif
+
+#ifdef HAVE_RB_CVAR_GET
rb_define_method(cls, "rb_cvar_get", class_spec_cvar_get, 2);
+#endif
+
+#ifdef HAVE_RB_CVAR_SET
rb_define_method(cls, "rb_cvar_set", class_spec_cvar_set, 3);
+#endif
+
+#ifdef HAVE_RB_CV_GET
rb_define_method(cls, "rb_cv_get", class_spec_cv_get, 2);
+#endif
+
+#ifdef HAVE_RB_CV_SET
rb_define_method(cls, "rb_cv_set", class_spec_cv_set, 3);
+#endif
+
+#ifdef HAVE_RB_DEFINE_ATTR
rb_define_method(cls, "rb_define_attr", class_spec_define_attr, 4);
+#endif
+
+#ifdef HAVE_RB_DEFINE_CLASS
rb_define_method(cls, "rb_define_class", class_spec_rb_define_class, 2);
+#endif
+
+#ifdef HAVE_RB_DEFINE_CLASS_UNDER
rb_define_method(cls, "rb_define_class_under", class_spec_rb_define_class_under, 3);
+#endif
+
+#ifdef HAVE_RB_DEFINE_CLASS_ID_UNDER
rb_define_method(cls, "rb_define_class_id_under", class_spec_rb_define_class_id_under, 3);
+#endif
+
+#ifdef HAVE_RB_DEFINE_CLASS_VARIABLE
rb_define_method(cls, "rb_define_class_variable", class_spec_define_class_variable, 3);
+#endif
+
+#ifdef HAVE_RB_INCLUDE_MODULE
rb_define_method(cls, "rb_include_module", class_spec_include_module, 2);
- rb_define_method(cls, "rb_method_varargs_1", class_spec_method_var_args_1, -1);
- rb_define_method(cls, "rb_method_varargs_2", class_spec_method_var_args_2, -2);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/complex_spec.c b/spec/ruby/optional/capi/ext/complex_spec.c
index dfccd7a037..476bbce31c 100644
--- a/spec/ruby/optional/capi/ext/complex_spec.c
+++ b/spec/ruby/optional/capi/ext/complex_spec.c
@@ -5,38 +5,69 @@
extern "C" {
#endif
+#ifdef HAVE_RB_COMPLEX
static VALUE complex_spec_rb_Complex(VALUE self, VALUE num, VALUE den) {
return rb_Complex(num, den);
}
+#endif
+#ifdef HAVE_RB_COMPLEX1
static VALUE complex_spec_rb_Complex1(VALUE self, VALUE num) {
return rb_Complex1(num);
}
+#endif
+#ifdef HAVE_RB_COMPLEX2
static VALUE complex_spec_rb_Complex2(VALUE self, VALUE num, VALUE den) {
return rb_Complex2(num, den);
}
+#endif
+#ifdef HAVE_RB_COMPLEX_NEW
static VALUE complex_spec_rb_complex_new(VALUE self, VALUE num, VALUE den) {
return rb_complex_new(num, den);
}
+#endif
+#ifdef HAVE_RB_COMPLEX_NEW1
static VALUE complex_spec_rb_complex_new1(VALUE self, VALUE num) {
return rb_complex_new1(num);
}
+#endif
+#ifdef HAVE_RB_COMPLEX_NEW2
static VALUE complex_spec_rb_complex_new2(VALUE self, VALUE num, VALUE den) {
return rb_complex_new2(num, den);
}
+#endif
void Init_complex_spec(void) {
- VALUE cls = rb_define_class("CApiComplexSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiComplexSpecs", rb_cObject);
+
+#ifdef HAVE_RB_COMPLEX
rb_define_method(cls, "rb_Complex", complex_spec_rb_Complex, 2);
+#endif
+
+#ifdef HAVE_RB_COMPLEX1
rb_define_method(cls, "rb_Complex1", complex_spec_rb_Complex1, 1);
+#endif
+
+#ifdef HAVE_RB_COMPLEX2
rb_define_method(cls, "rb_Complex2", complex_spec_rb_Complex2, 2);
+#endif
+
+#ifdef HAVE_RB_COMPLEX_NEW
rb_define_method(cls, "rb_complex_new", complex_spec_rb_complex_new, 2);
+#endif
+
+#ifdef HAVE_RB_COMPLEX_NEW1
rb_define_method(cls, "rb_complex_new1", complex_spec_rb_complex_new1, 1);
+#endif
+
+#ifdef HAVE_RB_COMPLEX_NEW2
rb_define_method(cls, "rb_complex_new2", complex_spec_rb_complex_new2, 2);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/constants_spec.c b/spec/ruby/optional/capi/ext/constants_spec.c
index c8ae843016..7751b12224 100644
--- a/spec/ruby/optional/capi/ext/constants_spec.c
+++ b/spec/ruby/optional/capi/ext/constants_spec.c
@@ -5,333 +5,640 @@
extern "C" {
#endif
+#ifdef HAVE_RB_CARRAY
static VALUE constants_spec_rb_cArray(VALUE self) {
return rb_cArray;
}
+#endif
-#ifndef RUBY_INTEGER_UNIFICATION
+#ifdef HAVE_RB_CBIGNUM
static VALUE constants_spec_rb_cBignum(VALUE self) {
return rb_cBignum;
}
#endif
+#ifdef HAVE_RB_CCLASS
static VALUE constants_spec_rb_cClass(VALUE self) {
return rb_cClass;
}
+#endif
+#ifdef HAVE_RB_CDATA
static VALUE constants_spec_rb_cData(VALUE self) {
return rb_cData;
}
+#endif
+#ifdef HAVE_RB_CFALSECLASS
static VALUE constants_spec_rb_cFalseClass(VALUE self) {
return rb_cFalseClass;
}
+#endif
+#ifdef HAVE_RB_CFILE
static VALUE constants_spec_rb_cFile(VALUE self) {
return rb_cFile;
}
+#endif
-#ifndef RUBY_INTEGER_UNIFICATION
+#ifdef HAVE_RB_CFIXNUM
static VALUE constants_spec_rb_cFixnum(VALUE self) {
return rb_cFixnum;
}
#endif
+#ifdef HAVE_RB_CFLOAT
static VALUE constants_spec_rb_cFloat(VALUE self) {
return rb_cFloat;
}
+#endif
+#ifdef HAVE_RB_CHASH
static VALUE constants_spec_rb_cHash(VALUE self) {
return rb_cHash;
}
+#endif
+#ifdef HAVE_RB_CINTEGER
static VALUE constants_spec_rb_cInteger(VALUE self) {
return rb_cInteger;
}
+#endif
+#ifdef HAVE_RB_CIO
static VALUE constants_spec_rb_cIO(VALUE self) {
return rb_cIO;
}
+#endif
+#ifdef HAVE_RB_CMODULE
static VALUE constants_spec_rb_cModule(VALUE self) {
return rb_cModule;
}
+#endif
+#ifdef HAVE_RB_CMATCH
static VALUE constants_spec_rb_cMatch(VALUE self) {
return rb_cMatch;
}
+#endif
+#ifdef HAVE_RB_CNILCLASS
static VALUE constants_spec_rb_cNilClass(VALUE self) {
return rb_cNilClass;
}
+#endif
+#ifdef HAVE_RB_CNUMERIC
static VALUE constants_spec_rb_cNumeric(VALUE self) {
return rb_cNumeric;
}
+#endif
+#ifdef HAVE_RB_COBJECT
static VALUE constants_spec_rb_cObject(VALUE self) {
return rb_cObject;
}
+#endif
+#ifdef HAVE_RB_CRANGE
static VALUE constants_spec_rb_cRange(VALUE self) {
return rb_cRange;
}
+#endif
+#ifdef HAVE_RB_CREGEXP
static VALUE constants_spec_rb_cRegexp(VALUE self) {
return rb_cRegexp;
}
+#endif
+#ifdef HAVE_RB_CSTRING
static VALUE constants_spec_rb_cString(VALUE self) {
return rb_cString;
}
+#endif
+#ifdef HAVE_RB_CSTRUCT
static VALUE constants_spec_rb_cStruct(VALUE self) {
return rb_cStruct;
}
+#endif
+#ifdef HAVE_RB_CSYMBOL
static VALUE constants_spec_rb_cSymbol(VALUE self) {
return rb_cSymbol;
}
+#endif
+#ifdef HAVE_RB_CTIME
static VALUE constants_spec_rb_cTime(VALUE self) {
return rb_cTime;
}
+#endif
+#ifdef HAVE_RB_CTHREAD
static VALUE constants_spec_rb_cThread(VALUE self) {
return rb_cThread;
}
+#endif
+#ifdef HAVE_RB_CTRUECLASS
static VALUE constants_spec_rb_cTrueClass(VALUE self) {
return rb_cTrueClass;
}
+#endif
+#ifdef HAVE_RB_CPROC
static VALUE constants_spec_rb_cProc(VALUE self) {
return rb_cProc;
}
+#endif
+#ifdef HAVE_RB_CMETHOD
static VALUE constants_spec_rb_cMethod(VALUE self) {
return rb_cMethod;
}
+#endif
+#ifdef HAVE_RB_CENUMERATOR
static VALUE constants_spec_rb_cEnumerator(VALUE self) {
return rb_cEnumerator;
}
+#endif
+#ifdef HAVE_RB_MCOMPARABLE
static VALUE constants_spec_rb_mComparable(VALUE self) {
return rb_mComparable;
}
+#endif
+#ifdef HAVE_RB_MENUMERABLE
static VALUE constants_spec_rb_mEnumerable(VALUE self) {
return rb_mEnumerable;
}
+#endif
+#ifdef HAVE_RB_MKERNEL
static VALUE constants_spec_rb_mKernel(VALUE self) {
return rb_mKernel;
}
+#endif
+#ifdef HAVE_RB_EARGERROR
static VALUE constants_spec_rb_eArgError(VALUE self) {
return rb_eArgError;
}
+#endif
+#ifdef HAVE_RB_EEOFERROR
static VALUE constants_spec_rb_eEOFError(VALUE self) {
return rb_eEOFError;
}
+#endif
+#ifdef HAVE_RB_MERRNO
static VALUE constants_spec_rb_mErrno(VALUE self) {
return rb_mErrno;
}
+#endif
+#ifdef HAVE_RB_EEXCEPTION
static VALUE constants_spec_rb_eException(VALUE self) {
return rb_eException;
}
+#endif
+#ifdef HAVE_RB_EFLOATDOMAINERROR
static VALUE constants_spec_rb_eFloatDomainError(VALUE self) {
return rb_eFloatDomainError;
}
+#endif
+#ifdef HAVE_RB_EINDEXERROR
static VALUE constants_spec_rb_eIndexError(VALUE self) {
return rb_eIndexError;
}
+#endif
+#ifdef HAVE_RB_EINTERRUPT
static VALUE constants_spec_rb_eInterrupt(VALUE self) {
return rb_eInterrupt;
}
+#endif
+#ifdef HAVE_RB_EIOERROR
static VALUE constants_spec_rb_eIOError(VALUE self) {
return rb_eIOError;
}
+#endif
+#ifdef HAVE_RB_ELOADERROR
static VALUE constants_spec_rb_eLoadError(VALUE self) {
return rb_eLoadError;
}
+#endif
+#ifdef HAVE_RB_ELOCALJUMPERROR
static VALUE constants_spec_rb_eLocalJumpError(VALUE self) {
return rb_eLocalJumpError;
}
+#endif
+#ifdef HAVE_RB_ENAMEERROR
static VALUE constants_spec_rb_eNameError(VALUE self) {
return rb_eNameError;
}
+#endif
+#ifdef HAVE_RB_ENOMEMERROR
static VALUE constants_spec_rb_eNoMemError(VALUE self) {
return rb_eNoMemError;
}
+#endif
+#ifdef HAVE_RB_ENOMETHODERROR
static VALUE constants_spec_rb_eNoMethodError(VALUE self) {
return rb_eNoMethodError;
}
+#endif
+#ifdef HAVE_RB_ENOTIMPERROR
static VALUE constants_spec_rb_eNotImpError(VALUE self) {
return rb_eNotImpError;
}
+#endif
+#ifdef HAVE_RB_ERANGEERROR
static VALUE constants_spec_rb_eRangeError(VALUE self) {
return rb_eRangeError;
}
+#endif
+#ifdef HAVE_RB_EREGEXPERROR
static VALUE constants_spec_rb_eRegexpError(VALUE self) {
return rb_eRegexpError;
}
+#endif
+#ifdef HAVE_RB_ERUNTIMEERROR
static VALUE constants_spec_rb_eRuntimeError(VALUE self) {
return rb_eRuntimeError;
}
+#endif
+#ifdef HAVE_RB_ESCRIPTERROR
static VALUE constants_spec_rb_eScriptError(VALUE self) {
return rb_eScriptError;
}
+#endif
+#ifdef HAVE_RB_ESECURITYERROR
static VALUE constants_spec_rb_eSecurityError(VALUE self) {
return rb_eSecurityError;
}
+#endif
+#ifdef HAVE_RB_ESIGNAL
static VALUE constants_spec_rb_eSignal(VALUE self) {
return rb_eSignal;
}
+#endif
+#ifdef HAVE_RB_ESTANDARDERROR
static VALUE constants_spec_rb_eStandardError(VALUE self) {
return rb_eStandardError;
}
+#endif
+#ifdef HAVE_RB_ESYNTAXERROR
static VALUE constants_spec_rb_eSyntaxError(VALUE self) {
return rb_eSyntaxError;
}
+#endif
+#ifdef HAVE_RB_ESYSTEMCALLERROR
static VALUE constants_spec_rb_eSystemCallError(VALUE self) {
return rb_eSystemCallError;
}
+#endif
+#ifdef HAVE_RB_ESYSTEMEXIT
static VALUE constants_spec_rb_eSystemExit(VALUE self) {
return rb_eSystemExit;
}
+#endif
+#ifdef HAVE_RB_ESYSSTACKERROR
static VALUE constants_spec_rb_eSysStackError(VALUE self) {
return rb_eSysStackError;
}
+#endif
+#ifdef HAVE_RB_ETYPEERROR
static VALUE constants_spec_rb_eTypeError(VALUE self) {
return rb_eTypeError;
}
+#endif
+#ifdef HAVE_RB_ETHREADERROR
static VALUE constants_spec_rb_eThreadError(VALUE self) {
return rb_eThreadError;
}
+#endif
+#ifdef HAVE_RB_EZERODIVERROR
static VALUE constants_spec_rb_eZeroDivError(VALUE self) {
return rb_eZeroDivError;
}
+#endif
+#ifdef HAVE_RB_EMATHDOMAINERROR
static VALUE constants_spec_rb_eMathDomainError(VALUE self) {
return rb_eMathDomainError;
}
+#endif
+#ifdef HAVE_RB_EENCCOMPATERROR
static VALUE constants_spec_rb_eEncCompatError(VALUE self) {
return rb_eEncCompatError;
}
+#endif
+#ifdef HAVE_RB_MWAITREADABLE
static VALUE constants_spec_rb_mWaitReadable(VALUE self) {
return rb_mWaitReadable;
}
+#endif
+#ifdef HAVE_RB_MWAITWRITABLE
static VALUE constants_spec_rb_mWaitWritable(VALUE self) {
return rb_mWaitWritable;
}
+#endif
+#ifdef HAVE_RB_CDIR
static VALUE constants_spec_rb_cDir(VALUE self) {
return rb_cDir;
}
+#endif
void Init_constants_spec(void) {
- VALUE cls = rb_define_class("CApiConstantsSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiConstantsSpecs", rb_cObject);
+
+#ifdef HAVE_RB_CARRAY
rb_define_method(cls, "rb_cArray", constants_spec_rb_cArray, 0);
-#ifndef RUBY_INTEGER_UNIFICATION
+#endif
+
+#ifdef HAVE_RB_CBIGNUM
rb_define_method(cls, "rb_cBignum", constants_spec_rb_cBignum, 0);
#endif
+#ifdef HAVE_RB_CCLASS
rb_define_method(cls, "rb_cClass", constants_spec_rb_cClass, 0);
+#endif
+
+#ifdef HAVE_RB_CDATA
rb_define_method(cls, "rb_cData", constants_spec_rb_cData, 0);
+#endif
+
+#ifdef HAVE_RB_CFALSECLASS
rb_define_method(cls, "rb_cFalseClass", constants_spec_rb_cFalseClass, 0);
+#endif
+
+#ifdef HAVE_RB_CFILE
rb_define_method(cls, "rb_cFile", constants_spec_rb_cFile, 0);
-#ifndef RUBY_INTEGER_UNIFICATION
+#endif
+
+#ifdef HAVE_RB_CFIXNUM
rb_define_method(cls, "rb_cFixnum", constants_spec_rb_cFixnum, 0);
#endif
+#ifdef HAVE_RB_CFLOAT
rb_define_method(cls, "rb_cFloat", constants_spec_rb_cFloat, 0);
+#endif
+
+#ifdef HAVE_RB_CHASH
rb_define_method(cls, "rb_cHash", constants_spec_rb_cHash, 0);
+#endif
+
+#ifdef HAVE_RB_CINTEGER
rb_define_method(cls, "rb_cInteger", constants_spec_rb_cInteger, 0);
+#endif
+
+#ifdef HAVE_RB_CIO
rb_define_method(cls, "rb_cIO", constants_spec_rb_cIO, 0);
+#endif
+
+#ifdef HAVE_RB_CMATCH
rb_define_method(cls, "rb_cMatch", constants_spec_rb_cMatch, 0);
+#endif
+
+#ifdef HAVE_RB_CMODULE
rb_define_method(cls, "rb_cModule", constants_spec_rb_cModule, 0);
+#endif
+
+#ifdef HAVE_RB_CNILCLASS
rb_define_method(cls, "rb_cNilClass", constants_spec_rb_cNilClass, 0);
+#endif
+
+#ifdef HAVE_RB_CNUMERIC
rb_define_method(cls, "rb_cNumeric", constants_spec_rb_cNumeric, 0);
+#endif
+
+#ifdef HAVE_RB_COBJECT
rb_define_method(cls, "rb_cObject", constants_spec_rb_cObject, 0);
+#endif
+
+#ifdef HAVE_RB_CRANGE
rb_define_method(cls, "rb_cRange", constants_spec_rb_cRange, 0);
+#endif
+
+#ifdef HAVE_RB_CREGEXP
rb_define_method(cls, "rb_cRegexp", constants_spec_rb_cRegexp, 0);
+#endif
+
+#ifdef HAVE_RB_CSTRING
rb_define_method(cls, "rb_cString", constants_spec_rb_cString, 0);
+#endif
+
+#ifdef HAVE_RB_CSTRUCT
rb_define_method(cls, "rb_cStruct", constants_spec_rb_cStruct, 0);
+#endif
+
+#ifdef HAVE_RB_CSYMBOL
rb_define_method(cls, "rb_cSymbol", constants_spec_rb_cSymbol, 0);
+#endif
+
+#ifdef HAVE_RB_CTIME
rb_define_method(cls, "rb_cTime", constants_spec_rb_cTime, 0);
+#endif
+
+#ifdef HAVE_RB_CTHREAD
rb_define_method(cls, "rb_cThread", constants_spec_rb_cThread, 0);
+#endif
+
+#ifdef HAVE_RB_CTRUECLASS
rb_define_method(cls, "rb_cTrueClass", constants_spec_rb_cTrueClass, 0);
+#endif
+
+#ifdef HAVE_RB_CPROC
rb_define_method(cls, "rb_cProc", constants_spec_rb_cProc, 0);
+#endif
+
+#ifdef HAVE_RB_CMETHOD
rb_define_method(cls, "rb_cMethod", constants_spec_rb_cMethod, 0);
+#endif
+
+#ifdef HAVE_RB_CENUMERATOR
rb_define_method(cls, "rb_cEnumerator", constants_spec_rb_cEnumerator, 0);
+#endif
+
+#ifdef HAVE_RB_MCOMPARABLE
rb_define_method(cls, "rb_mComparable", constants_spec_rb_mComparable, 0);
+#endif
+
+#ifdef HAVE_RB_MENUMERABLE
rb_define_method(cls, "rb_mEnumerable", constants_spec_rb_mEnumerable, 0);
+#endif
+
+#ifdef HAVE_RB_MKERNEL
rb_define_method(cls, "rb_mKernel", constants_spec_rb_mKernel, 0);
+#endif
+
+#ifdef HAVE_RB_EARGERROR
rb_define_method(cls, "rb_eArgError", constants_spec_rb_eArgError, 0);
+#endif
+
+#ifdef HAVE_RB_EEOFERROR
rb_define_method(cls, "rb_eEOFError", constants_spec_rb_eEOFError, 0);
+#endif
+
+#ifdef HAVE_RB_MERRNO
rb_define_method(cls, "rb_mErrno", constants_spec_rb_mErrno, 0);
+#endif
+
+#ifdef HAVE_RB_EEXCEPTION
rb_define_method(cls, "rb_eException", constants_spec_rb_eException, 0);
+#endif
+
+#ifdef HAVE_RB_EFLOATDOMAINERROR
rb_define_method(cls, "rb_eFloatDomainError", constants_spec_rb_eFloatDomainError, 0);
+#endif
+
+#ifdef HAVE_RB_EINDEXERROR
rb_define_method(cls, "rb_eIndexError", constants_spec_rb_eIndexError, 0);
+#endif
+
+#ifdef HAVE_RB_EINTERRUPT
rb_define_method(cls, "rb_eInterrupt", constants_spec_rb_eInterrupt, 0);
+#endif
+
+#ifdef HAVE_RB_EIOERROR
rb_define_method(cls, "rb_eIOError", constants_spec_rb_eIOError, 0);
+#endif
+
+#ifdef HAVE_RB_ELOADERROR
rb_define_method(cls, "rb_eLoadError", constants_spec_rb_eLoadError, 0);
+#endif
+
+#ifdef HAVE_RB_ELOCALJUMPERROR
rb_define_method(cls, "rb_eLocalJumpError", constants_spec_rb_eLocalJumpError, 0);
+#endif
+
+#ifdef HAVE_RB_ENAMEERROR
rb_define_method(cls, "rb_eNameError", constants_spec_rb_eNameError, 0);
+#endif
+
+#ifdef HAVE_RB_ENOMEMERROR
rb_define_method(cls, "rb_eNoMemError", constants_spec_rb_eNoMemError, 0);
+#endif
+
+#ifdef HAVE_RB_ENOMETHODERROR
rb_define_method(cls, "rb_eNoMethodError", constants_spec_rb_eNoMethodError, 0);
+#endif
+
+#ifdef HAVE_RB_ENOTIMPERROR
rb_define_method(cls, "rb_eNotImpError", constants_spec_rb_eNotImpError, 0);
+#endif
+
+#ifdef HAVE_RB_ERANGEERROR
rb_define_method(cls, "rb_eRangeError", constants_spec_rb_eRangeError, 0);
+#endif
+
+#ifdef HAVE_RB_EREGEXPERROR
rb_define_method(cls, "rb_eRegexpError", constants_spec_rb_eRegexpError, 0);
+#endif
+
+#ifdef HAVE_RB_ERUNTIMEERROR
rb_define_method(cls, "rb_eRuntimeError", constants_spec_rb_eRuntimeError, 0);
+#endif
+
+#ifdef HAVE_RB_ESCRIPTERROR
rb_define_method(cls, "rb_eScriptError", constants_spec_rb_eScriptError, 0);
+#endif
+
+#ifdef HAVE_RB_ESECURITYERROR
rb_define_method(cls, "rb_eSecurityError", constants_spec_rb_eSecurityError, 0);
+#endif
+
+#ifdef HAVE_RB_ESIGNAL
rb_define_method(cls, "rb_eSignal", constants_spec_rb_eSignal, 0);
+#endif
+
+#ifdef HAVE_RB_ESTANDARDERROR
rb_define_method(cls, "rb_eStandardError", constants_spec_rb_eStandardError, 0);
+#endif
+
+#ifdef HAVE_RB_ESYNTAXERROR
rb_define_method(cls, "rb_eSyntaxError", constants_spec_rb_eSyntaxError, 0);
+#endif
+
+#ifdef HAVE_RB_ESYSTEMCALLERROR
rb_define_method(cls, "rb_eSystemCallError", constants_spec_rb_eSystemCallError, 0);
+#endif
+
+#ifdef HAVE_RB_ESYSTEMEXIT
rb_define_method(cls, "rb_eSystemExit", constants_spec_rb_eSystemExit, 0);
+#endif
+
+#ifdef HAVE_RB_ESYSSTACKERROR
rb_define_method(cls, "rb_eSysStackError", constants_spec_rb_eSysStackError, 0);
+#endif
+
+#ifdef HAVE_RB_ETYPEERROR
rb_define_method(cls, "rb_eTypeError", constants_spec_rb_eTypeError, 0);
+#endif
+
+#ifdef HAVE_RB_ETHREADERROR
rb_define_method(cls, "rb_eThreadError", constants_spec_rb_eThreadError, 0);
+#endif
+
+#ifdef HAVE_RB_EZERODIVERROR
rb_define_method(cls, "rb_eZeroDivError", constants_spec_rb_eZeroDivError, 0);
+#endif
+
+#ifdef HAVE_RB_EMATHDOMAINERROR
rb_define_method(cls, "rb_eMathDomainError", constants_spec_rb_eMathDomainError, 0);
+#endif
+
+#ifdef HAVE_RB_EENCCOMPATERROR
rb_define_method(cls, "rb_eEncCompatError", constants_spec_rb_eEncCompatError, 0);
+#endif
+
+#ifdef HAVE_RB_MWAITREADABLE
rb_define_method(cls, "rb_mWaitReadable", constants_spec_rb_mWaitReadable, 0);
+#endif
+
+#ifdef HAVE_RB_MWAITWRITABLE
rb_define_method(cls, "rb_mWaitWritable", constants_spec_rb_mWaitWritable, 0);
+#endif
+
+#ifdef HAVE_RB_CDIR
rb_define_method(cls, "rb_cDir", constants_spec_rb_cDir, 0);
+#endif
+
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/data_spec.c b/spec/ruby/optional/capi/ext/data_spec.c
index a41666f655..ed79497897 100644
--- a/spec/ruby/optional/capi/ext/data_spec.c
+++ b/spec/ruby/optional/capi/ext/data_spec.c
@@ -7,6 +7,7 @@
extern "C" {
#endif
+#if defined(HAVE_RDATA) && defined(HAVE_DATA_WRAP_STRUCT)
struct sample_wrapped_struct {
int foo;
};
@@ -19,7 +20,7 @@ void sample_wrapped_struct_mark(void* st) {
}
VALUE sdaf_alloc_func(VALUE klass) {
- struct sample_wrapped_struct* bar = malloc(sizeof(struct sample_wrapped_struct));
+ struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
bar->foo = 42;
return Data_Wrap_Struct(klass, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
}
@@ -32,11 +33,17 @@ VALUE sdaf_get_struct(VALUE self) {
}
VALUE sws_wrap_struct(VALUE self, VALUE val) {
- struct sample_wrapped_struct* bar = malloc(sizeof(struct sample_wrapped_struct));
+ struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
bar->foo = FIX2INT(val);
return Data_Wrap_Struct(rb_cObject, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
}
+VALUE sws_wrap_struct_null(VALUE self, VALUE val) {
+ struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
+ bar->foo = FIX2INT(val);
+ return Data_Wrap_Struct(0, &sample_wrapped_struct_mark, &sample_wrapped_struct_free, bar);
+}
+
VALUE sws_get_struct(VALUE self, VALUE obj) {
struct sample_wrapped_struct* bar;
Data_Get_Struct(obj, struct sample_wrapped_struct, bar);
@@ -58,24 +65,31 @@ VALUE sws_get_struct_data_ptr(VALUE self, VALUE obj) {
VALUE sws_change_struct(VALUE self, VALUE obj, VALUE new_val) {
struct sample_wrapped_struct *old_struct, *new_struct;
- new_struct = malloc(sizeof(struct sample_wrapped_struct));
+ new_struct = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
new_struct->foo = FIX2INT(new_val);
old_struct = RDATA(obj)->data;
free(old_struct);
RDATA(obj)->data = new_struct;
return Qnil;
}
+#endif
void Init_data_spec(void) {
- VALUE cls = rb_define_class("CApiAllocSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiAllocSpecs", rb_cObject);
+
+#if defined(HAVE_RDATA) && defined(HAVE_DATA_WRAP_STRUCT)
rb_define_alloc_func(cls, sdaf_alloc_func);
rb_define_method(cls, "wrapped_data", sdaf_get_struct, 0);
+
cls = rb_define_class("CApiWrappedStructSpecs", rb_cObject);
rb_define_method(cls, "wrap_struct", sws_wrap_struct, 1);
+ rb_define_method(cls, "wrap_struct_null", sws_wrap_struct_null, 1);
rb_define_method(cls, "get_struct", sws_get_struct, 1);
rb_define_method(cls, "get_struct_rdata", sws_get_struct_rdata, 1);
rb_define_method(cls, "get_struct_data_ptr", sws_get_struct_data_ptr, 1);
rb_define_method(cls, "change_struct", sws_change_struct, 2);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/encoding_spec.c b/spec/ruby/optional/capi/ext/encoding_spec.c
index 3cde884225..2e555ebc77 100644
--- a/spec/ruby/optional/capi/ext/encoding_spec.c
+++ b/spec/ruby/optional/capi/ext/encoding_spec.c
@@ -7,6 +7,7 @@
extern "C" {
#endif
+#ifdef HAVE_ENC_CODERANGE_ASCIIONLY
static VALUE encoding_spec_ENC_CODERANGE_ASCIIONLY(VALUE self, VALUE obj) {
if(ENC_CODERANGE_ASCIIONLY(obj)) {
return Qtrue;
@@ -14,73 +15,106 @@ static VALUE encoding_spec_ENC_CODERANGE_ASCIIONLY(VALUE self, VALUE obj) {
return Qfalse;
}
}
+#endif
+#ifdef HAVE_RB_USASCII_ENCODING
static VALUE encoding_spec_rb_usascii_encoding(VALUE self) {
return rb_str_new2(rb_usascii_encoding()->name);
}
+#endif
+#ifdef HAVE_RB_USASCII_ENCINDEX
static VALUE encoding_spec_rb_usascii_encindex(VALUE self) {
return INT2NUM(rb_usascii_encindex());
}
+#endif
+#ifdef HAVE_RB_ASCII8BIT_ENCODING
static VALUE encoding_spec_rb_ascii8bit_encoding(VALUE self) {
return rb_str_new2(rb_ascii8bit_encoding()->name);
}
+#endif
+#ifdef HAVE_RB_ASCII8BIT_ENCINDEX
static VALUE encoding_spec_rb_ascii8bit_encindex(VALUE self) {
return INT2NUM(rb_ascii8bit_encindex());
}
+#endif
+#ifdef HAVE_RB_UTF8_ENCODING
static VALUE encoding_spec_rb_utf8_encoding(VALUE self) {
return rb_str_new2(rb_utf8_encoding()->name);
}
+#endif
+#ifdef HAVE_RB_UTF8_ENCINDEX
static VALUE encoding_spec_rb_utf8_encindex(VALUE self) {
return INT2NUM(rb_utf8_encindex());
}
+#endif
+#ifdef HAVE_RB_LOCALE_ENCODING
static VALUE encoding_spec_rb_locale_encoding(VALUE self) {
return rb_str_new2(rb_locale_encoding()->name);
}
+#endif
+#ifdef HAVE_RB_LOCALE_ENCINDEX
static VALUE encoding_spec_rb_locale_encindex(VALUE self) {
return INT2NUM(rb_locale_encindex());
}
+#endif
+#ifdef HAVE_RB_FILESYSTEM_ENCODING
static VALUE encoding_spec_rb_filesystem_encoding(VALUE self) {
return rb_str_new2(rb_filesystem_encoding()->name);
}
+#endif
+#ifdef HAVE_RB_FILESYSTEM_ENCINDEX
static VALUE encoding_spec_rb_filesystem_encindex(VALUE self) {
return INT2NUM(rb_filesystem_encindex());
}
+#endif
+#ifdef HAVE_RB_DEFAULT_INTERNAL_ENCODING
static VALUE encoding_spec_rb_default_internal_encoding(VALUE self) {
rb_encoding* enc = rb_default_internal_encoding();
if(enc == 0) return Qnil;
return rb_str_new2(enc->name);
}
+#endif
+#ifdef HAVE_RB_DEFAULT_EXTERNAL_ENCODING
static VALUE encoding_spec_rb_default_external_encoding(VALUE self) {
rb_encoding* enc = rb_default_external_encoding();
if(enc == 0) return Qnil;
return rb_str_new2(enc->name);
}
+#endif
-#ifdef RUBY_VERSION_IS_2_6
-static VALUE encoding_spec_rb_enc_alias(VALUE self, VALUE alias, VALUE orig) {
- return INT2NUM(rb_enc_alias(RSTRING_PTR(alias), RSTRING_PTR(orig)));
+#ifdef HAVE_RB_ENCDB_ALIAS
+/* Not exposed by MRI C-API encoding.h but used in the pg gem. */
+extern int rb_encdb_alias(const char* alias, const char* orig);
+
+static VALUE encoding_spec_rb_encdb_alias(VALUE self, VALUE alias, VALUE orig) {
+ return INT2NUM(rb_encdb_alias(RSTRING_PTR(alias), RSTRING_PTR(orig)));
}
#endif
+#if defined(HAVE_RB_ENC_ASSOCIATE) && defined(HAVE_RB_ENC_FIND)
static VALUE encoding_spec_rb_enc_associate(VALUE self, VALUE obj, VALUE enc) {
return rb_enc_associate(obj, NIL_P(enc) ? NULL : rb_enc_find(RSTRING_PTR(enc)));
}
+#endif
+#if defined(HAVE_RB_ENC_ASSOCIATE_INDEX) && defined(HAVE_RB_ENC_FIND_INDEX)
static VALUE encoding_spec_rb_enc_associate_index(VALUE self, VALUE obj, VALUE index) {
return rb_enc_associate_index(obj, FIX2INT(index));
}
+#endif
+#ifdef HAVE_RB_ENC_COMPATIBLE
static VALUE encoding_spec_rb_enc_compatible(VALUE self, VALUE a, VALUE b) {
rb_encoding* enc = rb_enc_compatible(a, b);
@@ -88,40 +122,60 @@ static VALUE encoding_spec_rb_enc_compatible(VALUE self, VALUE a, VALUE b) {
return rb_enc_from_encoding(enc);
}
+#endif
+#ifdef HAVE_RB_ENC_COPY
static VALUE encoding_spec_rb_enc_copy(VALUE self, VALUE dest, VALUE src) {
rb_enc_copy(dest, src);
return dest;
}
+#endif
+#ifdef HAVE_RB_ENC_FIND
static VALUE encoding_spec_rb_enc_find(VALUE self, VALUE name) {
return rb_str_new2(rb_enc_find(RSTRING_PTR(name))->name);
}
+#endif
+#ifdef HAVE_RB_ENC_FIND_INDEX
static VALUE encoding_spec_rb_enc_find_index(VALUE self, VALUE name) {
return INT2NUM(rb_enc_find_index(RSTRING_PTR(name)));
}
+#endif
+#ifdef HAVE_RB_ENC_FROM_INDEX
static VALUE encoding_spec_rb_enc_from_index(VALUE self, VALUE index) {
return rb_str_new2(rb_enc_from_index(NUM2INT(index))->name);
}
+#endif
+#ifdef HAVE_RB_ENC_FROM_ENCODING
static VALUE encoding_spec_rb_enc_from_encoding(VALUE self, VALUE name) {
return rb_enc_from_encoding(rb_enc_find(RSTRING_PTR(name)));
}
+#endif
+#ifdef HAVE_RB_ENC_GET
static VALUE encoding_spec_rb_enc_get(VALUE self, VALUE obj) {
return rb_str_new2(rb_enc_get(obj)->name);
}
+#endif
+#ifdef HAVE_RB_OBJ_ENCODING
static VALUE encoding_spec_rb_obj_encoding(VALUE self, VALUE obj) {
return rb_obj_encoding(obj);
}
+#endif
+#ifdef HAVE_RB_ENC_GET_INDEX
static VALUE encoding_spec_rb_enc_get_index(VALUE self, VALUE obj) {
return INT2NUM(rb_enc_get_index(obj));
}
+#endif
+#if defined(HAVE_RB_ENC_SET_INDEX) \
+ && defined(HAVE_RB_ENC_FIND_INDEX) \
+ && defined(HAVE_RB_ENC_FIND_INDEX)
static VALUE encoding_spec_rb_enc_set_index(VALUE self, VALUE obj, VALUE index) {
int i = NUM2INT(index);
@@ -131,7 +185,9 @@ static VALUE encoding_spec_rb_enc_set_index(VALUE self, VALUE obj, VALUE index)
return rb_ary_new3(2, rb_str_new2(rb_enc_name(enc)),
rb_str_new2(rb_enc_name(rb_enc_get(obj))));
}
+#endif
+#ifdef HAVE_RB_ENC_STR_CODERANGE
static VALUE encoding_spec_rb_enc_str_coderange(VALUE self, VALUE str) {
int coderange = rb_enc_str_coderange(str);
@@ -148,15 +204,21 @@ static VALUE encoding_spec_rb_enc_str_coderange(VALUE self, VALUE str) {
return ID2SYM(rb_intern("coderange_unrecognized"));
}
}
+#endif
+#ifdef HAVE_RB_ENC_STR_NEW
static VALUE encoding_spec_rb_enc_str_new(VALUE self, VALUE str, VALUE len, VALUE enc) {
return rb_enc_str_new(RSTRING_PTR(str), FIX2INT(len), rb_to_encoding(enc));
}
+#endif
+#ifdef HAVE_ENCODING_GET
static VALUE encoding_spec_ENCODING_GET(VALUE self, VALUE obj) {
return INT2NUM(ENCODING_GET(obj));
}
+#endif
+#ifdef HAVE_ENCODING_SET
static VALUE encoding_spec_ENCODING_SET(VALUE self, VALUE obj, VALUE index) {
int i = NUM2INT(index);
@@ -166,26 +228,36 @@ static VALUE encoding_spec_ENCODING_SET(VALUE self, VALUE obj, VALUE index) {
return rb_ary_new3(2, rb_str_new2(rb_enc_name(enc)),
rb_str_new2(rb_enc_name(rb_enc_get(obj))));
}
+#endif
+#if defined(HAVE_RB_ENC_TO_INDEX) && defined(HAVE_RB_ENC_FIND)
static VALUE encoding_spec_rb_enc_to_index(VALUE self, VALUE name) {
return INT2NUM(rb_enc_to_index(NIL_P(name) ? NULL : rb_enc_find(RSTRING_PTR(name))));
}
+#endif
+#ifdef HAVE_RB_TO_ENCODING
static VALUE encoding_spec_rb_to_encoding(VALUE self, VALUE obj) {
return rb_str_new2(rb_to_encoding(obj)->name);
}
+#endif
+#ifdef HAVE_RB_TO_ENCODING_INDEX
static VALUE encoding_spec_rb_to_encoding_index(VALUE self, VALUE obj) {
return INT2NUM(rb_to_encoding_index(obj));
}
+#endif
+#ifdef HAVE_RB_ENC_NTH
static VALUE encoding_spec_rb_enc_nth(VALUE self, VALUE str, VALUE index) {
char* start = RSTRING_PTR(str);
char* end = start + RSTRING_LEN(str);
char* ptr = rb_enc_nth(start, end, FIX2LONG(index), rb_enc_get(str));
return LONG2NUM(ptr - start);
}
+#endif
+#ifdef HAVE_RB_ENC_CODEPOINT_LEN
static VALUE encoding_spec_rb_enc_codepoint_len(VALUE self, VALUE str) {
char* start = RSTRING_PTR(str);
char* end = start + RSTRING_LEN(str);
@@ -195,53 +267,156 @@ static VALUE encoding_spec_rb_enc_codepoint_len(VALUE self, VALUE str) {
return rb_ary_new3(2, LONG2NUM(codepoint), LONG2NUM(len));
}
+#endif
void Init_encoding_spec(void) {
- VALUE cls = rb_define_class("CApiEncodingSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiEncodingSpecs", rb_cObject);
+
+#ifdef HAVE_ENC_CODERANGE_ASCIIONLY
rb_define_method(cls, "ENC_CODERANGE_ASCIIONLY",
encoding_spec_ENC_CODERANGE_ASCIIONLY, 1);
+#endif
+#ifdef HAVE_RB_USASCII_ENCODING
rb_define_method(cls, "rb_usascii_encoding", encoding_spec_rb_usascii_encoding, 0);
+#endif
+
+#ifdef HAVE_RB_USASCII_ENCINDEX
rb_define_method(cls, "rb_usascii_encindex", encoding_spec_rb_usascii_encindex, 0);
+#endif
+
+#ifdef HAVE_RB_ASCII8BIT_ENCODING
rb_define_method(cls, "rb_ascii8bit_encoding", encoding_spec_rb_ascii8bit_encoding, 0);
+#endif
+
+#ifdef HAVE_RB_ASCII8BIT_ENCINDEX
rb_define_method(cls, "rb_ascii8bit_encindex", encoding_spec_rb_ascii8bit_encindex, 0);
+#endif
+
+#ifdef HAVE_RB_UTF8_ENCODING
rb_define_method(cls, "rb_utf8_encoding", encoding_spec_rb_utf8_encoding, 0);
+#endif
+
+#ifdef HAVE_RB_UTF8_ENCINDEX
rb_define_method(cls, "rb_utf8_encindex", encoding_spec_rb_utf8_encindex, 0);
+#endif
+
+#ifdef HAVE_RB_LOCALE_ENCODING
rb_define_method(cls, "rb_locale_encoding", encoding_spec_rb_locale_encoding, 0);
+#endif
+
+#ifdef HAVE_RB_LOCALE_ENCINDEX
rb_define_method(cls, "rb_locale_encindex", encoding_spec_rb_locale_encindex, 0);
+#endif
+
+#ifdef HAVE_RB_FILESYSTEM_ENCODING
rb_define_method(cls, "rb_filesystem_encoding", encoding_spec_rb_filesystem_encoding, 0);
+#endif
+
+#ifdef HAVE_RB_FILESYSTEM_ENCINDEX
rb_define_method(cls, "rb_filesystem_encindex", encoding_spec_rb_filesystem_encindex, 0);
+#endif
+
+#ifdef HAVE_RB_DEFAULT_INTERNAL_ENCODING
rb_define_method(cls, "rb_default_internal_encoding",
encoding_spec_rb_default_internal_encoding, 0);
+#endif
+#ifdef HAVE_RB_DEFAULT_EXTERNAL_ENCODING
rb_define_method(cls, "rb_default_external_encoding",
encoding_spec_rb_default_external_encoding, 0);
+#endif
-#ifdef RUBY_VERSION_IS_2_6
- rb_define_method(cls, "rb_enc_alias", encoding_spec_rb_enc_alias, 2);
+#ifdef HAVE_RB_ENCDB_ALIAS
+ rb_define_method(cls, "rb_encdb_alias", encoding_spec_rb_encdb_alias, 2);
#endif
+#ifdef HAVE_RB_ENC_ASSOCIATE
rb_define_method(cls, "rb_enc_associate", encoding_spec_rb_enc_associate, 2);
+#endif
+
+#ifdef HAVE_RB_ENC_ASSOCIATE_INDEX
rb_define_method(cls, "rb_enc_associate_index", encoding_spec_rb_enc_associate_index, 2);
+#endif
+
+#ifdef HAVE_RB_ENC_COMPATIBLE
rb_define_method(cls, "rb_enc_compatible", encoding_spec_rb_enc_compatible, 2);
+#endif
+
+#ifdef HAVE_RB_ENC_COPY
rb_define_method(cls, "rb_enc_copy", encoding_spec_rb_enc_copy, 2);
+#endif
+
+#ifdef HAVE_RB_ENC_FIND
rb_define_method(cls, "rb_enc_find", encoding_spec_rb_enc_find, 1);
+#endif
+
+#ifdef HAVE_RB_ENC_FIND_INDEX
rb_define_method(cls, "rb_enc_find_index", encoding_spec_rb_enc_find_index, 1);
+#endif
+
+#ifdef HAVE_RB_ENC_FROM_INDEX
rb_define_method(cls, "rb_enc_from_index", encoding_spec_rb_enc_from_index, 1);
+#endif
+
+#ifdef HAVE_RB_ENC_FROM_ENCODING
rb_define_method(cls, "rb_enc_from_encoding", encoding_spec_rb_enc_from_encoding, 1);
+#endif
+
+#ifdef HAVE_RB_ENC_GET
rb_define_method(cls, "rb_enc_get", encoding_spec_rb_enc_get, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_ENCODING
rb_define_method(cls, "rb_obj_encoding", encoding_spec_rb_obj_encoding, 1);
+#endif
+
+#ifdef HAVE_RB_ENC_GET_INDEX
rb_define_method(cls, "rb_enc_get_index", encoding_spec_rb_enc_get_index, 1);
+#endif
+
+#if defined(HAVE_RB_ENC_SET_INDEX) \
+ && defined(HAVE_RB_ENC_FIND_INDEX) \
+ && defined(HAVE_RB_ENC_FIND_INDEX)
rb_define_method(cls, "rb_enc_set_index", encoding_spec_rb_enc_set_index, 2);
+#endif
+
+#ifdef HAVE_RB_ENC_STR_CODERANGE
rb_define_method(cls, "rb_enc_str_coderange", encoding_spec_rb_enc_str_coderange, 1);
+#endif
+
+#ifdef HAVE_RB_ENC_STR_NEW
rb_define_method(cls, "rb_enc_str_new", encoding_spec_rb_enc_str_new, 3);
+#endif
+
+#ifdef HAVE_ENCODING_GET
rb_define_method(cls, "ENCODING_GET", encoding_spec_ENCODING_GET, 1);
+#endif
+
+#ifdef HAVE_ENCODING_SET
rb_define_method(cls, "ENCODING_SET", encoding_spec_ENCODING_SET, 2);
+#endif
+
+#if defined(HAVE_RB_ENC_TO_INDEX) && defined(HAVE_RB_ENC_FIND)
rb_define_method(cls, "rb_enc_to_index", encoding_spec_rb_enc_to_index, 1);
+#endif
+
+#ifdef HAVE_RB_TO_ENCODING
rb_define_method(cls, "rb_to_encoding", encoding_spec_rb_to_encoding, 1);
+#endif
+
+#ifdef HAVE_RB_TO_ENCODING_INDEX
rb_define_method(cls, "rb_to_encoding_index", encoding_spec_rb_to_encoding_index, 1);
+#endif
+
+#ifdef HAVE_RB_ENC_NTH
rb_define_method(cls, "rb_enc_nth", encoding_spec_rb_enc_nth, 2);
+#endif
+
+#ifdef HAVE_RB_ENC_CODEPOINT_LEN
rb_define_method(cls, "rb_enc_codepoint_len", encoding_spec_rb_enc_codepoint_len, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/enumerator_spec.c b/spec/ruby/optional/capi/ext/enumerator_spec.c
index 917621c003..6b08feab52 100644
--- a/spec/ruby/optional/capi/ext/enumerator_spec.c
+++ b/spec/ruby/optional/capi/ext/enumerator_spec.c
@@ -5,26 +5,21 @@
extern "C" {
#endif
+#ifdef HAVE_RB_ENUMERATORIZE
VALUE enumerator_spec_rb_enumeratorize(int argc, VALUE *argv, VALUE self) {
VALUE obj, meth, args;
rb_scan_args(argc, argv, "2*", &obj, &meth, &args);
return rb_enumeratorize(obj, meth, (int)RARRAY_LEN(args), RARRAY_PTR(args));
}
-
-VALUE enumerator_spec_size_fn(VALUE obj, VALUE args, VALUE anEnum) {
- return INT2NUM(7);
-}
-
-VALUE enumerator_spec_rb_enumeratorize_with_size(int argc, VALUE *argv, VALUE self) {
- VALUE obj, meth, args;
- rb_scan_args(argc, argv, "2*", &obj, &meth, &args);
- return rb_enumeratorize_with_size(obj, meth, (int)RARRAY_LEN(args), RARRAY_PTR(args), enumerator_spec_size_fn);
-}
+#endif
void Init_enumerator_spec(void) {
- VALUE cls = rb_define_class("CApiEnumeratorSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiEnumeratorSpecs", rb_cObject);
+
+#ifdef HAVE_RB_ENUMERATORIZE
rb_define_method(cls, "rb_enumeratorize", enumerator_spec_rb_enumeratorize, -1);
- rb_define_method(cls, "rb_enumeratorize_with_size", enumerator_spec_rb_enumeratorize_with_size, -1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/exception_spec.c b/spec/ruby/optional/capi/ext/exception_spec.c
index cdd86b183e..b37f74f03e 100644
--- a/spec/ruby/optional/capi/ext/exception_spec.c
+++ b/spec/ruby/optional/capi/ext/exception_spec.c
@@ -8,37 +8,63 @@
extern "C" {
#endif
+#ifdef HAVE_RB_EXC_NEW
VALUE exception_spec_rb_exc_new(VALUE self, VALUE str) {
char *cstr = StringValuePtr(str);
return rb_exc_new(rb_eException, cstr, strlen(cstr));
}
+#endif
+#ifdef HAVE_RB_EXC_NEW2
VALUE exception_spec_rb_exc_new2(VALUE self, VALUE str) {
char *cstr = StringValuePtr(str);
return rb_exc_new2(rb_eException, cstr);
}
+#endif
+#ifdef HAVE_RB_EXC_NEW3
VALUE exception_spec_rb_exc_new3(VALUE self, VALUE str) {
return rb_exc_new3(rb_eException, str);
}
+#endif
+#ifdef HAVE_RB_EXC_RAISE
VALUE exception_spec_rb_exc_raise(VALUE self, VALUE exc) {
if (self != Qundef) rb_exc_raise(exc);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_SET_ERRINFO
VALUE exception_spec_rb_set_errinfo(VALUE self, VALUE exc) {
rb_set_errinfo(exc);
return Qnil;
}
+#endif
void Init_exception_spec(void) {
- VALUE cls = rb_define_class("CApiExceptionSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiExceptionSpecs", rb_cObject);
+
+#ifdef HAVE_RB_EXC_NEW
rb_define_method(cls, "rb_exc_new", exception_spec_rb_exc_new, 1);
+#endif
+
+#ifdef HAVE_RB_EXC_NEW2
rb_define_method(cls, "rb_exc_new2", exception_spec_rb_exc_new2, 1);
+#endif
+
+#ifdef HAVE_RB_EXC_NEW3
rb_define_method(cls, "rb_exc_new3", exception_spec_rb_exc_new3, 1);
+#endif
+
+#ifdef HAVE_RB_EXC_RAISE
rb_define_method(cls, "rb_exc_raise", exception_spec_rb_exc_raise, 1);
+#endif
+
+#ifdef HAVE_RB_SET_ERRINFO
rb_define_method(cls, "rb_set_errinfo", exception_spec_rb_set_errinfo, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/file_spec.c b/spec/ruby/optional/capi/ext/file_spec.c
index cd4a653765..98f8db1595 100644
--- a/spec/ruby/optional/capi/ext/file_spec.c
+++ b/spec/ruby/optional/capi/ext/file_spec.c
@@ -5,23 +5,38 @@
extern "C" {
#endif
+#ifdef HAVE_RB_FILE_OPEN
VALUE file_spec_rb_file_open(VALUE self, VALUE name, VALUE mode) {
return rb_file_open(RSTRING_PTR(name), RSTRING_PTR(mode));
}
+#endif
+#ifdef HAVE_RB_FILE_OPEN_STR
VALUE file_spec_rb_file_open_str(VALUE self, VALUE name, VALUE mode) {
return rb_file_open_str(name, RSTRING_PTR(mode));
}
+#endif
+#ifdef HAVE_FILEPATHVALUE
VALUE file_spec_FilePathValue(VALUE self, VALUE obj) {
return FilePathValue(obj);
}
+#endif
void Init_file_spec(void) {
VALUE cls = rb_define_class("CApiFileSpecs", rb_cObject);
+
+#ifdef HAVE_RB_FILE_OPEN
rb_define_method(cls, "rb_file_open", file_spec_rb_file_open, 2);
+#endif
+
+#ifdef HAVE_RB_FILE_OPEN_STR
rb_define_method(cls, "rb_file_open_str", file_spec_rb_file_open_str, 2);
+#endif
+
+#ifdef HAVE_FILEPATHVALUE
rb_define_method(cls, "FilePathValue", file_spec_FilePathValue, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/fixnum_spec.c b/spec/ruby/optional/capi/ext/fixnum_spec.c
index 7048ce3f13..c3a207b387 100644
--- a/spec/ruby/optional/capi/ext/fixnum_spec.c
+++ b/spec/ruby/optional/capi/ext/fixnum_spec.c
@@ -15,10 +15,36 @@ static VALUE fixnum_spec_FIX2UINT(VALUE self, VALUE value) {
return UINT2NUM(i);
}
+#ifdef HAVE_RB_FIX2UINT
+static VALUE fixnum_spec_rb_fix2uint(VALUE self, VALUE value) {
+ unsigned long i = rb_fix2uint(value);
+ return ULONG2NUM(i);
+}
+#endif
+
+#ifdef HAVE_RB_FIX2INT
+static VALUE fixnum_spec_rb_fix2int(VALUE self, VALUE value) {
+ long i = rb_fix2int(value);
+ return LONG2NUM(i);
+}
+#endif
+
void Init_fixnum_spec(void) {
- VALUE cls = rb_define_class("CApiFixnumSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiFixnumSpecs", rb_cObject);
+
rb_define_method(cls, "FIX2INT", fixnum_spec_FIX2INT, 1);
rb_define_method(cls, "FIX2UINT", fixnum_spec_FIX2UINT, 1);
+
+#ifdef HAVE_RB_FIX2UINT
+ rb_define_method(cls, "rb_fix2uint", fixnum_spec_rb_fix2uint, 1);
+#endif
+
+#ifdef HAVE_RB_FIX2INT
+ rb_define_method(cls, "rb_fix2int", fixnum_spec_rb_fix2int, 1);
+#endif
+
+ (void)cls;
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/float_spec.c b/spec/ruby/optional/capi/ext/float_spec.c
index 34be917965..15c74e62c9 100644
--- a/spec/ruby/optional/capi/ext/float_spec.c
+++ b/spec/ruby/optional/capi/ext/float_spec.c
@@ -7,6 +7,7 @@
extern "C" {
#endif
+#ifdef HAVE_RB_FLOAT_NEW
static VALUE float_spec_new_zero(VALUE self) {
double flt = 0;
return rb_float_new(flt);
@@ -16,21 +17,36 @@ static VALUE float_spec_new_point_five(VALUE self) {
double flt = 0.555;
return rb_float_new(flt);
}
+#endif
+#ifdef HAVE_RB_RFLOAT
static VALUE float_spec_rb_Float(VALUE self, VALUE float_str) {
return rb_Float(float_str);
}
+#endif
+#ifdef HAVE_RFLOAT_VALUE
static VALUE float_spec_RFLOAT_VALUE(VALUE self, VALUE float_h) {
return rb_float_new(RFLOAT_VALUE(float_h));
}
+#endif
void Init_float_spec(void) {
- VALUE cls = rb_define_class("CApiFloatSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiFloatSpecs", rb_cObject);
+
+#ifdef HAVE_RB_FLOAT_NEW
rb_define_method(cls, "new_zero", float_spec_new_zero, 0);
rb_define_method(cls, "new_point_five", float_spec_new_point_five, 0);
+#endif
+
+#ifdef HAVE_RB_RFLOAT
rb_define_method(cls, "rb_Float", float_spec_rb_Float, 1);
+#endif
+
+#ifdef HAVE_RFLOAT_VALUE
rb_define_method(cls, "RFLOAT_VALUE", float_spec_RFLOAT_VALUE, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/gc_spec.c b/spec/ruby/optional/capi/ext/gc_spec.c
index 57b1f11faa..05341bb01d 100644
--- a/spec/ruby/optional/capi/ext/gc_spec.c
+++ b/spec/ruby/optional/capi/ext/gc_spec.c
@@ -5,6 +5,7 @@
extern "C" {
#endif
+#ifdef HAVE_RB_GC_REGISTER_ADDRESS
VALUE registered_tagged_value;
VALUE registered_reference_value;
@@ -15,27 +16,33 @@ static VALUE registered_tagged_address(VALUE self) {
static VALUE registered_reference_address(VALUE self) {
return registered_reference_value;
}
+#endif
+#ifdef HAVE_RB_GC_ENABLE
static VALUE gc_spec_rb_gc_enable() {
return rb_gc_enable();
}
+#endif
+#ifdef HAVE_RB_GC_DISABLE
static VALUE gc_spec_rb_gc_disable() {
return rb_gc_disable();
}
+#endif
+#ifdef HAVE_RB_GC
static VALUE gc_spec_rb_gc() {
rb_gc();
return Qnil;
}
+#endif
-static VALUE gc_spec_rb_gc_adjust_memory_usage(VALUE self, VALUE diff) {
- rb_gc_adjust_memory_usage(NUM2SSIZET(diff));
- return Qnil;
-}
void Init_gc_spec(void) {
- VALUE cls = rb_define_class("CApiGCSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiGCSpecs", rb_cObject);
+
+#ifdef HAVE_RB_GC_REGISTER_ADDRESS
registered_tagged_value = INT2NUM(10);
registered_reference_value = rb_str_new2("Globally registered data");
@@ -44,10 +51,20 @@ void Init_gc_spec(void) {
rb_define_method(cls, "registered_tagged_address", registered_tagged_address, 0);
rb_define_method(cls, "registered_reference_address", registered_reference_address, 0);
+#endif
+
+#ifdef HAVE_RB_GC_ENABLE
rb_define_method(cls, "rb_gc_enable", gc_spec_rb_gc_enable, 0);
+#endif
+
+#ifdef HAVE_RB_GC_DISABLE
rb_define_method(cls, "rb_gc_disable", gc_spec_rb_gc_disable, 0);
+#endif
+
+#ifdef HAVE_RB_GC
rb_define_method(cls, "rb_gc", gc_spec_rb_gc, 0);
- rb_define_method(cls, "rb_gc_adjust_memory_usage", gc_spec_rb_gc_adjust_memory_usage, 1);
+#endif
+
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/globals_spec.c b/spec/ruby/optional/capi/ext/globals_spec.c
index f70622f66c..0c28a7f8ab 100644
--- a/spec/ruby/optional/capi/ext/globals_spec.c
+++ b/spec/ruby/optional/capi/ext/globals_spec.c
@@ -5,6 +5,7 @@
extern "C" {
#endif
+#ifdef HAVE_RB_DEFINE_HOOKED_VARIABLE
VALUE g_hooked_var;
void var_2x_setter(VALUE val, ID id, VALUE *var) {
@@ -15,7 +16,9 @@ static VALUE sb_define_hooked_variable(VALUE self, VALUE var_name) {
rb_define_hooked_variable(StringValuePtr(var_name), &g_hooked_var, 0, var_2x_setter);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_READONLY_VARIABLE
VALUE g_ro_var;
static VALUE sb_define_readonly_variable(VALUE self, VALUE var_name, VALUE val) {
@@ -23,7 +26,9 @@ static VALUE sb_define_readonly_variable(VALUE self, VALUE var_name, VALUE val)
rb_define_readonly_variable(StringValuePtr(var_name), &g_ro_var);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_VARIABLE
VALUE g_var;
static VALUE sb_get_global_value(VALUE self) {
@@ -35,82 +40,158 @@ static VALUE sb_define_variable(VALUE self, VALUE var_name, VALUE val) {
rb_define_variable(StringValuePtr(var_name), &g_var);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_F_GLOBAL_VARIABLES
static VALUE sb_f_global_variables(VALUE self) {
return rb_f_global_variables();
}
+#endif
+#ifdef HAVE_RB_GV_GET
static VALUE sb_gv_get(VALUE self, VALUE var) {
return rb_gv_get(StringValuePtr(var));
}
+#endif
+#ifdef HAVE_RB_GV_SET
static VALUE sb_gv_set(VALUE self, VALUE var, VALUE val) {
return rb_gv_set(StringValuePtr(var), val);
}
+#endif
+#ifdef HAVE_RB_STDIN
static VALUE global_spec_rb_stdin(VALUE self) {
return rb_stdin;
}
+#endif
+#ifdef HAVE_RB_STDOUT
static VALUE global_spec_rb_stdout(VALUE self) {
return rb_stdout;
}
+#endif
+#ifdef HAVE_RB_STDERR
static VALUE global_spec_rb_stderr(VALUE self) {
return rb_stderr;
}
+#endif
+#ifdef HAVE_RB_DEFOUT
static VALUE global_spec_rb_defout(VALUE self) {
return rb_defout;
}
+#endif
+#ifdef HAVE_RB_RS
static VALUE global_spec_rb_rs(VALUE self) {
return rb_rs;
}
+#endif
+#ifdef HAVE_RB_DEFAULT_RS
static VALUE global_spec_rb_default_rs(VALUE self) {
return rb_default_rs;
}
+#endif
+#ifdef HAVE_RB_OUTPUT_RS
static VALUE global_spec_rb_output_rs(VALUE self) {
return rb_output_rs;
}
+#endif
+#ifdef HAVE_RB_OUTPUT_FS
static VALUE global_spec_rb_output_fs(VALUE self) {
return rb_output_fs;
}
+#endif
+#ifdef HAVE_RB_LASTLINE_SET
static VALUE global_spec_rb_lastline_set(VALUE self, VALUE line) {
rb_lastline_set(line);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_LASTLINE_GET
static VALUE global_spec_rb_lastline_get(VALUE self) {
return rb_lastline_get();
}
+#endif
void Init_globals_spec(void) {
- VALUE cls = rb_define_class("CApiGlobalSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiGlobalSpecs", rb_cObject);
+
+#ifdef HAVE_RB_DEFINE_HOOKED_VARIABLE
g_hooked_var = Qnil;
rb_define_method(cls, "rb_define_hooked_variable_2x", sb_define_hooked_variable, 1);
+#endif
+
+#ifdef HAVE_RB_DEFINE_READONLY_VARIABLE
g_ro_var = Qnil;
rb_define_method(cls, "rb_define_readonly_variable", sb_define_readonly_variable, 2);
+#endif
+
+#ifdef HAVE_RB_DEFINE_VARIABLE
g_var = Qnil;
rb_define_method(cls, "rb_define_variable", sb_define_variable, 2);
rb_define_method(cls, "sb_get_global_value", sb_get_global_value, 0);
+#endif
+
+#ifdef HAVE_RB_F_GLOBAL_VARIABLES
rb_define_method(cls, "rb_f_global_variables", sb_f_global_variables, 0);
+#endif
+
+#ifdef HAVE_RB_GV_GET
rb_define_method(cls, "sb_gv_get", sb_gv_get, 1);
+#endif
+
+#ifdef HAVE_RB_GV_SET
rb_define_method(cls, "sb_gv_set", sb_gv_set, 2);
+#endif
+
+#ifdef HAVE_RB_STDIN
rb_define_method(cls, "rb_stdin", global_spec_rb_stdin, 0);
+#endif
+
+#ifdef HAVE_RB_STDOUT
rb_define_method(cls, "rb_stdout", global_spec_rb_stdout, 0);
+#endif
+
+#ifdef HAVE_RB_STDERR
rb_define_method(cls, "rb_stderr", global_spec_rb_stderr, 0);
+#endif
+
+#ifdef HAVE_RB_DEFOUT
rb_define_method(cls, "rb_defout", global_spec_rb_defout, 0);
+#endif
+
+#ifdef HAVE_RB_RS
rb_define_method(cls, "rb_rs", global_spec_rb_rs, 0);
+#endif
+
+#ifdef HAVE_RB_DEFAULT_RS
rb_define_method(cls, "rb_default_rs", global_spec_rb_default_rs, 0);
+#endif
+
+#ifdef HAVE_RB_OUTPUT_RS
rb_define_method(cls, "rb_output_rs", global_spec_rb_output_rs, 0);
+#endif
+
+#ifdef HAVE_RB_OUTPUT_FS
rb_define_method(cls, "rb_output_fs", global_spec_rb_output_fs, 0);
+#endif
+
+#ifdef HAVE_RB_LASTLINE_SET
rb_define_method(cls, "rb_lastline_set", global_spec_rb_lastline_set, 1);
+#endif
+
+#ifdef HAVE_RB_LASTLINE_GET
rb_define_method(cls, "rb_lastline_get", global_spec_rb_lastline_get, 0);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/hash_spec.c b/spec/ruby/optional/capi/ext/hash_spec.c
index c8735cec2c..73e7ef5c13 100644
--- a/spec/ruby/optional/capi/ext/hash_spec.c
+++ b/spec/ruby/optional/capi/ext/hash_spec.c
@@ -5,26 +5,37 @@
extern "C" {
#endif
+#ifdef HAVE_RB_HASH
VALUE hash_spec_rb_hash(VALUE self, VALUE hash) {
return rb_hash(hash);
}
+#endif
+#ifdef HAVE_RB_HASH2
VALUE hash_spec_rb_Hash(VALUE self, VALUE val) {
return rb_Hash(val);
}
+#endif
+#ifdef HAVE_RB_HASH_DUP
VALUE hash_spec_rb_hash_dup(VALUE self, VALUE hash) {
return rb_hash_dup(hash);
}
+#endif
+#ifdef HAVE_RB_HASH_FETCH
VALUE hash_spec_rb_hash_fetch(VALUE self, VALUE hash, VALUE key) {
return rb_hash_fetch(hash, key);
}
+#endif
+#ifdef HAVE_RB_HASH_FREEZE
VALUE hash_spec_rb_hash_freeze(VALUE self, VALUE hash) {
return rb_hash_freeze(hash);
}
+#endif
+#ifdef HAVE_RB_HASH_AREF
VALUE hash_spec_rb_hash_aref(VALUE self, VALUE hash, VALUE key) {
return rb_hash_aref(hash, key);
}
@@ -33,23 +44,33 @@ VALUE hash_spec_rb_hash_aref_nil(VALUE self, VALUE hash, VALUE key) {
VALUE ret = rb_hash_aref(hash, key);
return NIL_P(ret) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_HASH_ASET
VALUE hash_spec_rb_hash_aset(VALUE self, VALUE hash, VALUE key, VALUE val) {
return rb_hash_aset(hash, key, val);
}
+#endif
+#ifdef HAVE_RB_HASH_CLEAR
VALUE hash_spec_rb_hash_clear(VALUE self, VALUE hash) {
return rb_hash_clear(hash);
}
+#endif
+#ifdef HAVE_RB_HASH_DELETE
VALUE hash_spec_rb_hash_delete(VALUE self, VALUE hash, VALUE key) {
return rb_hash_delete(hash, key);
}
+#endif
+#ifdef HAVE_RB_HASH_DELETE_IF
VALUE hash_spec_rb_hash_delete_if(VALUE self, VALUE hash) {
return rb_hash_delete_if(hash);
}
+#endif
+#ifdef HAVE_RB_HASH_FOREACH
static int foreach_i(VALUE key, VALUE val, VALUE other) {
rb_hash_aset(other, key, val);
return 0; /* ST_CONTINUE; */
@@ -82,7 +103,9 @@ VALUE hash_spec_rb_hash_foreach_delete(VALUE self, VALUE hsh) {
rb_hash_foreach(hsh, foreach_delete_i, other);
return other;
}
+#endif
+#ifdef HAVE_RB_HASH_LOOKUP
VALUE hash_spec_rb_hash_lookup(VALUE self, VALUE hash, VALUE key) {
return rb_hash_lookup(hash, key);
}
@@ -91,51 +114,103 @@ VALUE hash_spec_rb_hash_lookup_nil(VALUE self, VALUE hash, VALUE key) {
VALUE ret = rb_hash_lookup(hash, key);
return ret == Qnil ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_HASH_LOOKUP2
VALUE hash_spec_rb_hash_lookup2(VALUE self, VALUE hash, VALUE key, VALUE def) {
return rb_hash_lookup2(hash, key, def);
}
+#endif
-VALUE hash_spec_rb_hash_lookup2_default_undef(VALUE self, VALUE hash, VALUE key) {
- VALUE ret = rb_hash_lookup2(hash, key, Qundef);
- return ret == Qundef ? Qtrue : Qfalse;
-}
-
+#ifdef HAVE_RB_HASH_NEW
VALUE hash_spec_rb_hash_new(VALUE self) {
return rb_hash_new();
}
+#endif
+#ifdef HAVE_RB_HASH_SIZE
VALUE hash_spec_rb_hash_size(VALUE self, VALUE hash) {
return rb_hash_size(hash);
}
+#endif
+#ifdef HAVE_RB_HASH_SET_IFNONE
VALUE hash_spec_rb_hash_set_ifnone(VALUE self, VALUE hash, VALUE def) {
return rb_hash_set_ifnone(hash, def);
}
+#endif
void Init_hash_spec(void) {
- VALUE cls = rb_define_class("CApiHashSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiHashSpecs", rb_cObject);
+
+#ifdef HAVE_RB_HASH
rb_define_method(cls, "rb_hash", hash_spec_rb_hash, 1);
+#endif
+
+#ifdef HAVE_RB_HASH2
rb_define_method(cls, "rb_Hash", hash_spec_rb_Hash, 1);
+#endif
+
+#ifdef HAVE_RB_HASH_DUP
rb_define_method(cls, "rb_hash_dup", hash_spec_rb_hash_dup, 1);
+#endif
+
+#ifdef HAVE_RB_HASH_FREEZE
rb_define_method(cls, "rb_hash_freeze", hash_spec_rb_hash_freeze, 1);
+#endif
+
+#ifdef HAVE_RB_HASH_AREF
rb_define_method(cls, "rb_hash_aref", hash_spec_rb_hash_aref, 2);
rb_define_method(cls, "rb_hash_aref_nil", hash_spec_rb_hash_aref_nil, 2);
+#endif
+
+#ifdef HAVE_RB_HASH_ASET
rb_define_method(cls, "rb_hash_aset", hash_spec_rb_hash_aset, 3);
+#endif
+
+#ifdef HAVE_RB_HASH_CLEAR
rb_define_method(cls, "rb_hash_clear", hash_spec_rb_hash_clear, 1);
+#endif
+
+#ifdef HAVE_RB_HASH_DELETE
rb_define_method(cls, "rb_hash_delete", hash_spec_rb_hash_delete, 2);
+#endif
+
+#ifdef HAVE_RB_HASH_DELETE_IF
rb_define_method(cls, "rb_hash_delete_if", hash_spec_rb_hash_delete_if, 1);
+#endif
+
+#ifdef HAVE_RB_HASH_FETCH
rb_define_method(cls, "rb_hash_fetch", hash_spec_rb_hash_fetch, 2);
+#endif
+
+#ifdef HAVE_RB_HASH_FOREACH
rb_define_method(cls, "rb_hash_foreach", hash_spec_rb_hash_foreach, 1);
rb_define_method(cls, "rb_hash_foreach_stop", hash_spec_rb_hash_foreach_stop, 1);
rb_define_method(cls, "rb_hash_foreach_delete", hash_spec_rb_hash_foreach_delete, 1);
+#endif
+
+#ifdef HAVE_RB_HASH_LOOKUP
rb_define_method(cls, "rb_hash_lookup_nil", hash_spec_rb_hash_lookup_nil, 2);
rb_define_method(cls, "rb_hash_lookup", hash_spec_rb_hash_lookup, 2);
+#endif
+
+#ifdef HAVE_RB_HASH_LOOKUP2
rb_define_method(cls, "rb_hash_lookup2", hash_spec_rb_hash_lookup2, 3);
- rb_define_method(cls, "rb_hash_lookup2_default_undef", hash_spec_rb_hash_lookup2_default_undef, 2);
+#endif
+
+#ifdef HAVE_RB_HASH_NEW
rb_define_method(cls, "rb_hash_new", hash_spec_rb_hash_new, 0);
+#endif
+
+#ifdef HAVE_RB_HASH_SIZE
rb_define_method(cls, "rb_hash_size", hash_spec_rb_hash_size, 1);
+#endif
+
+#ifdef HAVE_RB_HASH_SET_IFNONE
rb_define_method(cls, "rb_hash_set_ifnone", hash_spec_rb_hash_set_ifnone, 2);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/integer_spec.c b/spec/ruby/optional/capi/ext/integer_spec.c
index 7e9e8b26bd..821d8373c9 100644
--- a/spec/ruby/optional/capi/ext/integer_spec.c
+++ b/spec/ruby/optional/capi/ext/integer_spec.c
@@ -5,6 +5,7 @@
extern "C" {
#endif
+#ifdef HAVE_RB_INTEGER_PACK
static VALUE integer_spec_rb_integer_pack(VALUE self, VALUE value,
VALUE words, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags)
{
@@ -12,9 +13,13 @@ static VALUE integer_spec_rb_integer_pack(VALUE self, VALUE value,
FIX2INT(wordsize), FIX2INT(nails), FIX2INT(flags));
return INT2FIX(result);
}
+#endif
void Init_integer_spec(void) {
- VALUE cls = rb_define_class("CApiIntegerSpecs", rb_cObject);
+#ifdef HAVE_RB_INTEGER_PACK
+ VALUE cls;
+ cls = rb_define_class("CApiIntegerSpecs", rb_cObject);
+
rb_define_const(cls, "MSWORD", INT2NUM(INTEGER_PACK_MSWORD_FIRST));
rb_define_const(cls, "LSWORD", INT2NUM(INTEGER_PACK_LSWORD_FIRST));
rb_define_const(cls, "MSBYTE", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));
@@ -27,6 +32,7 @@ void Init_integer_spec(void) {
rb_define_const(cls, "NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE));
rb_define_method(cls, "rb_integer_pack", integer_spec_rb_integer_pack, 6);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/io_spec.c b/spec/ruby/optional/capi/ext/io_spec.c
index b656de081a..40069bd54b 100644
--- a/spec/ruby/optional/capi/ext/io_spec.c
+++ b/spec/ruby/optional/capi/ext/io_spec.c
@@ -21,12 +21,12 @@ static int set_non_blocking(int fd) {
int flags = 1;
return ioctl(fd, FIOBIO, &flags);
#else
-#define SET_NON_BLOCKING_FAILS_ALWAYS 1
errno = ENOSYS;
return -1;
#endif
}
+#ifdef HAVE_GET_OPEN_FILE
static int io_spec_get_fd(VALUE io) {
rb_io_t* fp;
GetOpenFile(io, fp);
@@ -36,11 +36,15 @@ static int io_spec_get_fd(VALUE io) {
VALUE io_spec_GetOpenFile_fd(VALUE self, VALUE io) {
return INT2NUM(io_spec_get_fd(io));
}
+#endif
+#ifdef HAVE_RB_IO_ADDSTR
VALUE io_spec_rb_io_addstr(VALUE self, VALUE io, VALUE str) {
return rb_io_addstr(io, str);
}
+#endif
+#ifdef HAVE_RB_IO_PRINTF
VALUE io_spec_rb_io_printf(VALUE self, VALUE io, VALUE ary) {
long argc = RARRAY_LEN(ary);
VALUE *argv = alloca(sizeof(VALUE) * argc);
@@ -52,7 +56,9 @@ VALUE io_spec_rb_io_printf(VALUE self, VALUE io, VALUE ary) {
return rb_io_printf((int)argc, argv, io);
}
+#endif
+#ifdef HAVE_RB_IO_PRINT
VALUE io_spec_rb_io_print(VALUE self, VALUE io, VALUE ary) {
long argc = RARRAY_LEN(ary);
VALUE *argv = alloca(sizeof(VALUE) * argc);
@@ -64,7 +70,9 @@ VALUE io_spec_rb_io_print(VALUE self, VALUE io, VALUE ary) {
return rb_io_print((int)argc, argv, io);
}
+#endif
+#ifdef HAVE_RB_IO_PUTS
VALUE io_spec_rb_io_puts(VALUE self, VALUE io, VALUE ary) {
long argc = RARRAY_LEN(ary);
VALUE *argv = alloca(sizeof(VALUE) * argc);
@@ -76,60 +84,67 @@ VALUE io_spec_rb_io_puts(VALUE self, VALUE io, VALUE ary) {
return rb_io_puts((int)argc, argv, io);
}
+#endif
+#ifdef HAVE_RB_IO_WRITE
VALUE io_spec_rb_io_write(VALUE self, VALUE io, VALUE str) {
return rb_io_write(io, str);
}
+#endif
+#ifdef HAVE_RB_IO_CHECK_IO
VALUE io_spec_rb_io_check_io(VALUE self, VALUE io) {
return rb_io_check_io(io);
}
+#endif
+#ifdef HAVE_RB_IO_CHECK_READABLE
VALUE io_spec_rb_io_check_readable(VALUE self, VALUE io) {
rb_io_t* fp;
GetOpenFile(io, fp);
rb_io_check_readable(fp);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_IO_CHECK_WRITABLE
VALUE io_spec_rb_io_check_writable(VALUE self, VALUE io) {
rb_io_t* fp;
GetOpenFile(io, fp);
rb_io_check_writable(fp);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_IO_CHECK_CLOSED
VALUE io_spec_rb_io_check_closed(VALUE self, VALUE io) {
rb_io_t* fp;
GetOpenFile(io, fp);
rb_io_check_closed(fp);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_IO_TAINT_CHECK
VALUE io_spec_rb_io_taint_check(VALUE self, VALUE io) {
/*rb_io_t* fp;
GetOpenFile(io, fp);*/
rb_io_taint_check(io);
return io;
}
+#endif
+#ifdef HAVE_RB_IO_WAIT_READABLE
#define RB_IO_WAIT_READABLE_BUF 13
-#ifdef SET_NON_BLOCKING_FAILS_ALWAYS
-NORETURN(VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p));
-#endif
-
VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) {
int fd = io_spec_get_fd(io);
-#ifndef SET_NON_BLOCKING_FAILS_ALWAYS
char buf[RB_IO_WAIT_READABLE_BUF];
int ret, saved_errno;
-#endif
if (set_non_blocking(fd) == -1)
rb_sys_fail("set_non_blocking failed");
-#ifndef SET_NON_BLOCKING_FAILS_ALWAYS
if(RTEST(read_p)) {
if (read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) {
return Qnil;
@@ -152,89 +167,135 @@ VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) {
}
return ret ? Qtrue : Qfalse;
-#else
- UNREACHABLE;
-#endif
}
+#endif
+#ifdef HAVE_RB_IO_WAIT_WRITABLE
VALUE io_spec_rb_io_wait_writable(VALUE self, VALUE io) {
int ret = rb_io_wait_writable(io_spec_get_fd(io));
return ret ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_THREAD_WAIT_FD
VALUE io_spec_rb_thread_wait_fd(VALUE self, VALUE io) {
rb_thread_wait_fd(io_spec_get_fd(io));
return Qnil;
}
+#endif
-VALUE io_spec_rb_wait_for_single_fd(VALUE self, VALUE io, VALUE events, VALUE secs, VALUE usecs) {
- int fd = io_spec_get_fd(io);
- struct timeval tv;
- if (!NIL_P(secs)) {
- tv.tv_sec = FIX2INT(secs);
- tv.tv_usec = FIX2INT(usecs);
- }
- return INT2FIX(rb_wait_for_single_fd(fd, FIX2INT(events), NIL_P(secs) ? NULL : &tv));
-}
-
+#ifdef HAVE_RB_THREAD_FD_WRITABLE
VALUE io_spec_rb_thread_fd_writable(VALUE self, VALUE io) {
rb_thread_fd_writable(io_spec_get_fd(io));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_IO_BINMODE
VALUE io_spec_rb_io_binmode(VALUE self, VALUE io) {
return rb_io_binmode(io);
}
+#endif
+#ifdef HAVE_RB_FD_FIX_CLOEXEC
VALUE io_spec_rb_fd_fix_cloexec(VALUE self, VALUE io) {
rb_fd_fix_cloexec(io_spec_get_fd(io));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_CLOEXEC_OPEN
VALUE io_spec_rb_cloexec_open(VALUE self, VALUE path, VALUE flags, VALUE mode) {
const char *pathname = StringValuePtr(path);
int fd = rb_cloexec_open(pathname, FIX2INT(flags), FIX2INT(mode));
return rb_funcall(rb_cIO, rb_intern("for_fd"), 1, INT2FIX(fd));
}
+#endif
+#ifdef HAVE_RB_IO_CLOSE
VALUE io_spec_rb_io_close(VALUE self, VALUE io) {
return rb_io_close(io);
}
-
-/*
- * this is needed to ensure rb_io_wait_*able functions behave
- * predictably because errno may be set to unexpected values
- * otherwise.
- */
-static VALUE io_spec_errno_set(VALUE self, VALUE val) {
- int e = NUM2INT(val);
- errno = e;
- return val;
-}
+#endif
void Init_io_spec(void) {
VALUE cls = rb_define_class("CApiIOSpecs", rb_cObject);
+
+#ifdef HAVE_GET_OPEN_FILE
rb_define_method(cls, "GetOpenFile_fd", io_spec_GetOpenFile_fd, 1);
+#endif
+
+#ifdef HAVE_RB_IO_ADDSTR
rb_define_method(cls, "rb_io_addstr", io_spec_rb_io_addstr, 2);
+#endif
+
+#ifdef HAVE_RB_IO_PRINTF
rb_define_method(cls, "rb_io_printf", io_spec_rb_io_printf, 2);
+#endif
+
+#ifdef HAVE_RB_IO_PRINT
rb_define_method(cls, "rb_io_print", io_spec_rb_io_print, 2);
+#endif
+
+#ifdef HAVE_RB_IO_PUTS
rb_define_method(cls, "rb_io_puts", io_spec_rb_io_puts, 2);
+#endif
+
+#ifdef HAVE_RB_IO_WRITE
rb_define_method(cls, "rb_io_write", io_spec_rb_io_write, 2);
+#endif
+
+#ifdef HAVE_RB_IO_CLOSE
rb_define_method(cls, "rb_io_close", io_spec_rb_io_close, 1);
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_IO
rb_define_method(cls, "rb_io_check_io", io_spec_rb_io_check_io, 1);
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_READABLE
rb_define_method(cls, "rb_io_check_readable", io_spec_rb_io_check_readable, 1);
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_WRITABLE
rb_define_method(cls, "rb_io_check_writable", io_spec_rb_io_check_writable, 1);
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_CLOSED
rb_define_method(cls, "rb_io_check_closed", io_spec_rb_io_check_closed, 1);
+#endif
+
+#ifdef HAVE_RB_IO_TAINT_CHECK
rb_define_method(cls, "rb_io_taint_check", io_spec_rb_io_taint_check, 1);
+#endif
+
+#ifdef HAVE_RB_IO_WAIT_READABLE
rb_define_method(cls, "rb_io_wait_readable", io_spec_rb_io_wait_readable, 2);
+#endif
+
+#ifdef HAVE_RB_IO_WAIT_WRITABLE
rb_define_method(cls, "rb_io_wait_writable", io_spec_rb_io_wait_writable, 1);
+#endif
+
+#ifdef HAVE_RB_THREAD_WAIT_FD
rb_define_method(cls, "rb_thread_wait_fd", io_spec_rb_thread_wait_fd, 1);
+#endif
+
+#ifdef HAVE_RB_THREAD_FD_WRITABLE
rb_define_method(cls, "rb_thread_fd_writable", io_spec_rb_thread_fd_writable, 1);
- rb_define_method(cls, "rb_wait_for_single_fd", io_spec_rb_wait_for_single_fd, 4);
+#endif
+
+#ifdef HAVE_RB_IO_BINMODE
rb_define_method(cls, "rb_io_binmode", io_spec_rb_io_binmode, 1);
+#endif
+
+#ifdef HAVE_RB_FD_FIX_CLOEXEC
rb_define_method(cls, "rb_fd_fix_cloexec", io_spec_rb_fd_fix_cloexec, 1);
+#endif
+
+#ifdef HAVE_RB_CLOEXEC_OPEN
rb_define_method(cls, "rb_cloexec_open", io_spec_rb_cloexec_open, 3);
- rb_define_method(cls, "errno=", io_spec_errno_set, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/kernel_spec.c b/spec/ruby/optional/capi/ext/kernel_spec.c
index e98ae35067..226354e18a 100644
--- a/spec/ruby/optional/capi/ext/kernel_spec.c
+++ b/spec/ruby/optional/capi/ext/kernel_spec.c
@@ -13,28 +13,28 @@ VALUE kernel_spec_call_proc(VALUE arg_array) {
return rb_funcall(proc, rb_intern("call"), 1, arg);
}
-VALUE kernel_spec_call_proc_raise(VALUE arg_array, VALUE raised_exc) {
- return kernel_spec_call_proc(arg_array);
-}
-
+#ifdef HAVE_RB_BLOCK_GIVEN_P
static VALUE kernel_spec_rb_block_given_p(VALUE self) {
return rb_block_given_p() ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_NEED_BLOCK
VALUE kernel_spec_rb_need_block(VALUE self) {
rb_need_block();
return Qnil;
}
+#endif
+#ifdef HAVE_RB_BLOCK_PROC
VALUE kernel_spec_rb_block_proc(VALUE self) {
return rb_block_proc();
}
+#endif
-VALUE kernel_spec_rb_block_lambda(VALUE self) {
- return rb_block_lambda();
-}
+#ifdef HAVE_RB_BLOCK_CALL
-VALUE block_call_inject(RB_BLOCK_CALL_FUNC_ARGLIST(yield_value, data2)) {
+VALUE block_call_inject(VALUE yield_value, VALUE data2) {
/* yield_value yields the first block argument */
VALUE elem = yield_value;
VALUE elem_incr = INT2FIX(FIX2INT(elem) + 1);
@@ -45,7 +45,7 @@ VALUE kernel_spec_rb_block_call(VALUE self, VALUE ary) {
return rb_block_call(ary, rb_intern("map"), 0, NULL, block_call_inject, Qnil);
}
-VALUE block_call_inject_multi_arg(RB_BLOCK_CALL_FUNC_ARGLIST(yield_value, data2)) {
+VALUE block_call_inject_multi_arg(VALUE yield_value, VALUE data2, int argc, VALUE argv[]) {
/* yield_value yields the first block argument */
VALUE sum = yield_value;
VALUE elem = argv[1];
@@ -59,23 +59,13 @@ VALUE kernel_spec_rb_block_call_multi_arg(VALUE self, VALUE ary) {
return rb_block_call(ary, rb_intern("inject"), 1, method_args, block_call_inject_multi_arg, Qnil);
}
-static VALUE return_extra_data(RB_BLOCK_CALL_FUNC_ARGLIST(yield_value, extra_data)) {
- return extra_data;
-}
-
-VALUE rb_block_call_extra_data(VALUE self, VALUE object) {
- return rb_block_call(object, rb_intern("instance_exec"), 0, NULL, return_extra_data, object);
-}
-
VALUE kernel_spec_rb_block_call_no_func(VALUE self, VALUE ary) {
return rb_block_call(ary, rb_intern("map"), 0, NULL, NULL, Qnil);
}
+#endif
-VALUE kernel_spec_rb_frame_this_func(VALUE self) {
- return ID2SYM(rb_frame_this_func());
-}
-
+#ifdef HAVE_RB_ENSURE
VALUE kernel_spec_rb_ensure(VALUE self, VALUE main_proc, VALUE arg,
VALUE ensure_proc, VALUE arg2) {
VALUE main_array, ensure_array;
@@ -91,27 +81,35 @@ VALUE kernel_spec_rb_ensure(VALUE self, VALUE main_proc, VALUE arg,
return rb_ensure(kernel_spec_call_proc, main_array,
kernel_spec_call_proc, ensure_array);
}
+#endif
-VALUE kernel_spec_call_proc_with_catch(RB_BLOCK_CALL_FUNC_ARGLIST(arg, data)) {
+#ifdef HAVE_RB_CATCH
+VALUE kernel_spec_call_proc_with_catch(VALUE arg, VALUE data) {
return rb_funcall(data, rb_intern("call"), 0);
}
VALUE kernel_spec_rb_catch(VALUE self, VALUE sym, VALUE main_proc) {
return rb_catch(StringValuePtr(sym), kernel_spec_call_proc_with_catch, main_proc);
}
+#endif
-VALUE kernel_spec_call_proc_with_catch_obj(RB_BLOCK_CALL_FUNC_ARGLIST(arg, data)) {
+#ifdef HAVE_RB_CATCH_OBJ
+VALUE kernel_spec_call_proc_with_catch_obj(VALUE arg, VALUE data) {
return rb_funcall(data, rb_intern("call"), 0);
}
VALUE kernel_spec_rb_catch_obj(VALUE self, VALUE obj, VALUE main_proc) {
- return rb_catch_obj(obj, kernel_spec_call_proc_with_catch_obj, main_proc);
+ return rb_catch_obj(obj, kernel_spec_call_proc_with_catch, main_proc);
}
+#endif
+#ifdef HAVE_RB_EVAL_STRING
VALUE kernel_spec_rb_eval_string(VALUE self, VALUE str) {
return rb_eval_string(RSTRING_PTR(str));
}
+#endif
+#ifdef HAVE_RB_RAISE
VALUE kernel_spec_rb_raise(VALUE self, VALUE hash) {
rb_hash_aset(hash, ID2SYM(rb_intern("stage")), ID2SYM(rb_intern("before")));
if (self != Qundef)
@@ -119,17 +117,23 @@ VALUE kernel_spec_rb_raise(VALUE self, VALUE hash) {
rb_hash_aset(hash, ID2SYM(rb_intern("stage")), ID2SYM(rb_intern("after")));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_THROW
VALUE kernel_spec_rb_throw(VALUE self, VALUE result) {
if (self != Qundef) rb_throw("foo", result);
return ID2SYM(rb_intern("rb_throw_failed"));
}
+#endif
+#ifdef HAVE_RB_THROW_OBJ
VALUE kernel_spec_rb_throw_obj(VALUE self, VALUE obj, VALUE result) {
if (self != Qundef) rb_throw_obj(obj, result);
return ID2SYM(rb_intern("rb_throw_failed"));
}
+#endif
+#ifdef HAVE_RB_RESCUE
VALUE kernel_spec_call_proc_with_raised_exc(VALUE arg_array, VALUE raised_exc) {
VALUE argv[2];
int argc;
@@ -160,7 +164,9 @@ VALUE kernel_spec_rb_rescue(VALUE self, VALUE main_proc, VALUE arg,
return rb_rescue(kernel_spec_call_proc, main_array,
kernel_spec_call_proc_with_raised_exc, raise_array);
}
+#endif
+#ifdef HAVE_RB_RESCUE2
VALUE kernel_spec_rb_rescue2(int argc, VALUE *args, VALUE self) {
VALUE main_array, raise_array;
@@ -173,31 +179,23 @@ VALUE kernel_spec_rb_rescue2(int argc, VALUE *args, VALUE self) {
rb_ary_push(raise_array, args[3]);
return rb_rescue2(kernel_spec_call_proc, main_array,
- kernel_spec_call_proc_raise, raise_array, args[4], args[5], (VALUE)0);
+ kernel_spec_call_proc, raise_array, args[4], args[5], (VALUE)0);
}
+#endif
+#ifdef HAVE_RB_PROTECT
static VALUE kernel_spec_rb_protect_yield(VALUE self, VALUE obj, VALUE ary) {
int status = 0;
VALUE res = rb_protect(rb_yield, obj, &status);
rb_ary_store(ary, 0, INT2NUM(23));
- rb_ary_store(ary, 1, res);
- if (status) {
- rb_jump_tag(status);
- }
- return res;
-}
-
-static VALUE kernel_spec_rb_eval_string_protect(VALUE self, VALUE str, VALUE ary) {
- int status = 0;
- VALUE res = rb_eval_string_protect(RSTRING_PTR(str), &status);
- rb_ary_store(ary, 0, INT2NUM(23));
- rb_ary_store(ary, 1, res);
if (status) {
rb_jump_tag(status);
}
return res;
}
+#endif
+#ifdef HAVE_RB_SYS_FAIL
VALUE kernel_spec_rb_sys_fail(VALUE self, VALUE msg) {
errno = 1;
if(msg == Qnil) {
@@ -207,7 +205,9 @@ VALUE kernel_spec_rb_sys_fail(VALUE self, VALUE msg) {
}
return Qnil;
}
+#endif
+#ifdef HAVE_RB_SYSERR_FAIL
VALUE kernel_spec_rb_syserr_fail(VALUE self, VALUE err, VALUE msg) {
if(msg == Qnil) {
rb_syserr_fail(NUM2INT(err), NULL);
@@ -216,12 +216,16 @@ VALUE kernel_spec_rb_syserr_fail(VALUE self, VALUE err, VALUE msg) {
}
return Qnil;
}
+#endif
+#ifdef HAVE_RB_WARN
VALUE kernel_spec_rb_warn(VALUE self, VALUE msg) {
rb_warn("%s", StringValuePtr(msg));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_YIELD
static VALUE kernel_spec_rb_yield(VALUE self, VALUE obj) {
return rb_yield(obj);
}
@@ -253,15 +257,21 @@ static VALUE kernel_indirected(int (*compar)(const void *, const void *)) {
static VALUE kernel_spec_rb_yield_indirected(VALUE self, VALUE obj) {
return kernel_indirected(kernel_cb);
}
+#endif
+#ifdef HAVE_RB_YIELD_SPLAT
static VALUE kernel_spec_rb_yield_splat(VALUE self, VALUE ary) {
return rb_yield_splat(ary);
}
+#endif
+#ifdef HAVE_RB_YIELD_VALUES
static VALUE kernel_spec_rb_yield_values(VALUE self, VALUE obj1, VALUE obj2) {
return rb_yield_values(2, obj1, obj2);
}
+#endif
+#ifdef HAVE_RB_EXEC_RECURSIVE
static VALUE do_rec(VALUE obj, VALUE arg, int is_rec) {
if(is_rec) {
return obj;
@@ -275,7 +285,9 @@ static VALUE do_rec(VALUE obj, VALUE arg, int is_rec) {
static VALUE kernel_spec_rb_exec_recursive(VALUE self, VALUE obj) {
return rb_exec_recursive(do_rec, obj, Qtrue);
}
+#endif
+#ifdef HAVE_RB_SET_END_PROC
static void write_io(VALUE io) {
rb_funcall(io, rb_intern("write"), 1, rb_str_new2("e"));
}
@@ -284,65 +296,153 @@ static VALUE kernel_spec_rb_set_end_proc(VALUE self, VALUE io) {
rb_set_end_proc(write_io, io);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_F_SPRINTF
static VALUE kernel_spec_rb_f_sprintf(VALUE self, VALUE ary) {
return rb_f_sprintf((int)RARRAY_LEN(ary), RARRAY_PTR(ary));
}
+#endif
+#ifdef HAVE_RB_MAKE_BACKTRACE
static VALUE kernel_spec_rb_make_backtrace(VALUE self) {
return rb_make_backtrace();
}
+#endif
+#ifdef HAVE_RB_OBJ_METHOD
static VALUE kernel_spec_rb_obj_method(VALUE self, VALUE obj, VALUE method) {
return rb_obj_method(obj, method);
}
+#endif
+#ifdef HAVE_RB_FUNCALL3
static VALUE kernel_spec_rb_funcall3(VALUE self, VALUE obj, VALUE method) {
return rb_funcall3(obj, SYM2ID(method), 0, NULL);
}
+#endif
+#ifdef HAVE_RB_FUNCALL_WITH_BLOCK
static VALUE kernel_spec_rb_funcall_with_block(VALUE self, VALUE obj, VALUE method, VALUE block) {
return rb_funcall_with_block(obj, SYM2ID(method), 0, NULL, block);
}
+#endif
void Init_kernel_spec(void) {
- VALUE cls = rb_define_class("CApiKernelSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiKernelSpecs", rb_cObject);
+
+#ifdef HAVE_RB_BLOCK_GIVEN_P
rb_define_method(cls, "rb_block_given_p", kernel_spec_rb_block_given_p, 0);
+#endif
+
+#ifdef HAVE_RB_NEED_BLOCK
rb_define_method(cls, "rb_need_block", kernel_spec_rb_need_block, 0);
+#endif
+
+#ifdef HAVE_RB_BLOCK_CALL
rb_define_method(cls, "rb_block_call", kernel_spec_rb_block_call, 1);
rb_define_method(cls, "rb_block_call_multi_arg", kernel_spec_rb_block_call_multi_arg, 1);
rb_define_method(cls, "rb_block_call_no_func", kernel_spec_rb_block_call_no_func, 1);
- rb_define_method(cls, "rb_block_call_extra_data", rb_block_call_extra_data, 1);
+#endif
+
+#ifdef HAVE_RB_BLOCK_PROC
rb_define_method(cls, "rb_block_proc", kernel_spec_rb_block_proc, 0);
- rb_define_method(cls, "rb_block_lambda", kernel_spec_rb_block_lambda, 0);
- rb_define_method(cls, "rb_frame_this_func_test", kernel_spec_rb_frame_this_func, 0);
- rb_define_method(cls, "rb_frame_this_func_test_again", kernel_spec_rb_frame_this_func, 0);
+#endif
+
+#ifdef HAVE_RB_ENSURE
rb_define_method(cls, "rb_ensure", kernel_spec_rb_ensure, 4);
+#endif
+
+#ifdef HAVE_RB_EVAL_STRING
rb_define_method(cls, "rb_eval_string", kernel_spec_rb_eval_string, 1);
+#endif
+
+#ifdef HAVE_RB_RAISE
rb_define_method(cls, "rb_raise", kernel_spec_rb_raise, 1);
+#endif
+
+#ifdef HAVE_RB_THROW
rb_define_method(cls, "rb_throw", kernel_spec_rb_throw, 1);
+#endif
+
+#ifdef HAVE_RB_THROW_OBJ
rb_define_method(cls, "rb_throw_obj", kernel_spec_rb_throw_obj, 2);
+#endif
+
+#ifdef HAVE_RB_RESCUE
rb_define_method(cls, "rb_rescue", kernel_spec_rb_rescue, 4);
+#endif
+
+#ifdef HAVE_RB_RESCUE2
rb_define_method(cls, "rb_rescue2", kernel_spec_rb_rescue2, -1);
+#endif
+
+#ifdef HAVE_RB_PROTECT
rb_define_method(cls, "rb_protect_yield", kernel_spec_rb_protect_yield, 2);
- rb_define_method(cls, "rb_eval_string_protect", kernel_spec_rb_eval_string_protect, 2);
+#endif
+
+#ifdef HAVE_RB_CATCH
rb_define_method(cls, "rb_catch", kernel_spec_rb_catch, 2);
+#endif
+
+#ifdef HAVE_RB_CATCH_OBJ
rb_define_method(cls, "rb_catch_obj", kernel_spec_rb_catch_obj, 2);
+#endif
+
+#ifdef HAVE_RB_SYS_FAIL
rb_define_method(cls, "rb_sys_fail", kernel_spec_rb_sys_fail, 1);
+#endif
+
+#ifdef HAVE_RB_SYSERR_FAIL
rb_define_method(cls, "rb_syserr_fail", kernel_spec_rb_syserr_fail, 2);
+#endif
+
+#ifdef HAVE_RB_WARN
rb_define_method(cls, "rb_warn", kernel_spec_rb_warn, 1);
+#endif
+
+#ifdef HAVE_RB_YIELD
rb_define_method(cls, "rb_yield", kernel_spec_rb_yield, 1);
rb_define_method(cls, "rb_yield_indirected", kernel_spec_rb_yield_indirected, 1);
rb_define_method(cls, "rb_yield_define_each", kernel_spec_rb_yield_define_each, 1);
+#endif
+
+#ifdef HAVE_RB_YIELD_VALUES
rb_define_method(cls, "rb_yield_values", kernel_spec_rb_yield_values, 2);
+#endif
+
+#ifdef HAVE_RB_YIELD_SPLAT
rb_define_method(cls, "rb_yield_splat", kernel_spec_rb_yield_splat, 1);
+#endif
+
+#ifdef HAVE_RB_EXEC_RECURSIVE
rb_define_method(cls, "rb_exec_recursive", kernel_spec_rb_exec_recursive, 1);
+#endif
+
+#ifdef HAVE_RB_SET_END_PROC
rb_define_method(cls, "rb_set_end_proc", kernel_spec_rb_set_end_proc, 1);
+#endif
+
+#ifdef HAVE_RB_F_SPRINTF
rb_define_method(cls, "rb_f_sprintf", kernel_spec_rb_f_sprintf, 1);
+#endif
+
+#ifdef HAVE_RB_MAKE_BACKTRACE
rb_define_method(cls, "rb_make_backtrace", kernel_spec_rb_make_backtrace, 0);
+#endif
+
+#ifdef HAVE_RB_OBJ_METHOD
rb_define_method(cls, "rb_obj_method", kernel_spec_rb_obj_method, 2);
+#endif
+
+#ifdef HAVE_RB_FUNCALL3
rb_define_method(cls, "rb_funcall3", kernel_spec_rb_funcall3, 2);
+#endif
+
+#ifdef HAVE_RB_FUNCALL_WITH_BLOCK
rb_define_method(cls, "rb_funcall_with_block", kernel_spec_rb_funcall_with_block, 3);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/marshal_spec.c b/spec/ruby/optional/capi/ext/marshal_spec.c
index ea8e3d5a07..dbb6e71abf 100644
--- a/spec/ruby/optional/capi/ext/marshal_spec.c
+++ b/spec/ruby/optional/capi/ext/marshal_spec.c
@@ -5,18 +5,30 @@
extern "C" {
#endif
+#ifdef HAVE_RB_MARSHAL_DUMP
VALUE marshal_spec_rb_marshal_dump(VALUE self, VALUE obj, VALUE port) {
return rb_marshal_dump(obj, port);
}
+#endif
+#ifdef HAVE_RB_MARSHAL_LOAD
VALUE marshal_spec_rb_marshal_load(VALUE self, VALUE data) {
return rb_marshal_load(data);
}
+#endif
void Init_marshal_spec(void) {
- VALUE cls = rb_define_class("CApiMarshalSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiMarshalSpecs", rb_cObject);
+
+#ifdef HAVE_RB_MARSHAL_DUMP
rb_define_method(cls, "rb_marshal_dump", marshal_spec_rb_marshal_dump, 2);
+#endif
+
+#ifdef HAVE_RB_MARSHAL_LOAD
rb_define_method(cls, "rb_marshal_load", marshal_spec_rb_marshal_load, 1);
+#endif
+
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/module_spec.c b/spec/ruby/optional/capi/ext/module_spec.c
index 3c8455a942..e408404a09 100644
--- a/spec/ruby/optional/capi/ext/module_spec.c
+++ b/spec/ruby/optional/capi/ext/module_spec.c
@@ -9,145 +9,252 @@ static VALUE module_specs_test_method(VALUE self) {
return ID2SYM(rb_intern("test_method"));
}
+#ifdef HAVE_RB_CONST_DEFINED
static VALUE module_specs_const_defined(VALUE self, VALUE klass, VALUE id) {
return rb_const_defined(klass, SYM2ID(id)) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_CONST_DEFINED_AT
static VALUE module_specs_const_defined_at(VALUE self, VALUE klass, VALUE id) {
return rb_const_defined_at(klass, SYM2ID(id)) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_CONST_GET
static VALUE module_specs_const_get(VALUE self, VALUE klass, VALUE val) {
return rb_const_get(klass, SYM2ID(val));
}
+#endif
+#ifdef HAVE_RB_CONST_GET_AT
static VALUE module_specs_const_get_at(VALUE self, VALUE klass, VALUE val) {
return rb_const_get_at(klass, SYM2ID(val));
}
+#endif
+#ifdef HAVE_RB_CONST_GET_FROM
static VALUE module_specs_const_get_from(VALUE self, VALUE klass, VALUE val) {
return rb_const_get_from(klass, SYM2ID(val));
}
+#endif
+#ifdef HAVE_RB_CONST_SET
static VALUE module_specs_const_set(VALUE self, VALUE klass, VALUE name, VALUE val) {
rb_const_set(klass, SYM2ID(name), val);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_ALIAS
static VALUE module_specs_rb_define_alias(VALUE self, VALUE obj,
VALUE new_name, VALUE old_name) {
rb_define_alias(obj, RSTRING_PTR(new_name), RSTRING_PTR(old_name));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_ALIAS
static VALUE module_specs_rb_alias(VALUE self, VALUE obj,
VALUE new_name, VALUE old_name) {
rb_alias(obj, SYM2ID(new_name), SYM2ID(old_name));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_MODULE
static VALUE module_specs_rb_define_module(VALUE self, VALUE name) {
return rb_define_module(RSTRING_PTR(name));
}
+#endif
+#ifdef HAVE_RB_DEFINE_MODULE_UNDER
static VALUE module_specs_rb_define_module_under(VALUE self, VALUE outer, VALUE name) {
return rb_define_module_under(outer, RSTRING_PTR(name));
}
+#endif
+#ifdef HAVE_RB_DEFINE_CONST
static VALUE module_specs_define_const(VALUE self, VALUE klass, VALUE str_name, VALUE val) {
rb_define_const(klass, RSTRING_PTR(str_name), val);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_GLOBAL_CONST
static VALUE module_specs_define_global_const(VALUE self, VALUE str_name, VALUE obj) {
rb_define_global_const(RSTRING_PTR(str_name), obj);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_GLOBAL_FUNCTION
static VALUE module_specs_rb_define_global_function(VALUE self, VALUE str_name) {
rb_define_global_function(RSTRING_PTR(str_name), module_specs_test_method, 0);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_METHOD
static VALUE module_specs_rb_define_method(VALUE self, VALUE cls, VALUE str_name) {
rb_define_method(cls, RSTRING_PTR(str_name), module_specs_test_method, 0);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_MODULE_FUNCTION
static VALUE module_specs_rb_define_module_function(VALUE self, VALUE cls, VALUE str_name) {
rb_define_module_function(cls, RSTRING_PTR(str_name), module_specs_test_method, 0);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_PRIVATE_METHOD
static VALUE module_specs_rb_define_private_method(VALUE self, VALUE cls, VALUE str_name) {
rb_define_private_method(cls, RSTRING_PTR(str_name), module_specs_test_method, 0);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_PROTECTED_METHOD
static VALUE module_specs_rb_define_protected_method(VALUE self, VALUE cls, VALUE str_name) {
rb_define_protected_method(cls, RSTRING_PTR(str_name), module_specs_test_method, 0);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_DEFINE_SINGLETON_METHOD
static VALUE module_specs_rb_define_singleton_method(VALUE self, VALUE cls, VALUE str_name) {
rb_define_singleton_method(cls, RSTRING_PTR(str_name), module_specs_test_method, 0);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_UNDEF_METHOD
static VALUE module_specs_rb_undef_method(VALUE self, VALUE cls, VALUE str_name) {
rb_undef_method(cls, RSTRING_PTR(str_name));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_UNDEF
static VALUE module_specs_rb_undef(VALUE self, VALUE cls, VALUE symbol_name) {
rb_undef(cls, SYM2ID(symbol_name));
return Qnil;
}
+#endif
+#ifdef HAVE_RB_CLASS2NAME
static VALUE module_specs_rbclass2name(VALUE self, VALUE klass) {
return rb_str_new2(rb_class2name(klass));
}
+#endif
+#ifdef HAVE_RB_MOD_ANCESTORS
static VALUE module_specs_rb_mod_ancestors(VALUE self, VALUE klass) {
return rb_mod_ancestors(klass);
}
+#endif
void Init_module_spec(void) {
- VALUE cls = rb_define_class("CApiModuleSpecs", rb_cObject);
+ VALUE cls;
+
+ cls = rb_define_class("CApiModuleSpecs", rb_cObject);
+
+#ifdef HAVE_RB_CONST_DEFINED
rb_define_method(cls, "rb_const_defined", module_specs_const_defined, 2);
+#endif
+
+#ifdef HAVE_RB_CONST_DEFINED_AT
rb_define_method(cls, "rb_const_defined_at", module_specs_const_defined_at, 2);
+#endif
+
+#ifdef HAVE_RB_CONST_GET
rb_define_method(cls, "rb_const_get", module_specs_const_get, 2);
+#endif
+
+#ifdef HAVE_RB_CONST_GET_AT
rb_define_method(cls, "rb_const_get_at", module_specs_const_get_at, 2);
+#endif
+
+#ifdef HAVE_RB_CONST_GET_FROM
rb_define_method(cls, "rb_const_get_from", module_specs_const_get_from, 2);
+#endif
+
+#ifdef HAVE_RB_CONST_SET
rb_define_method(cls, "rb_const_set", module_specs_const_set, 3);
+#endif
+
+#ifdef HAVE_RB_DEFINE_ALIAS
rb_define_method(cls, "rb_define_alias", module_specs_rb_define_alias, 3);
+#endif
+
+#ifdef HAVE_RB_ALIAS
rb_define_method(cls, "rb_alias", module_specs_rb_alias, 3);
+#endif
+
+#ifdef HAVE_RB_DEFINE_MODULE
rb_define_method(cls, "rb_define_module", module_specs_rb_define_module, 1);
+#endif
+
+#ifdef HAVE_RB_DEFINE_MODULE_UNDER
rb_define_method(cls, "rb_define_module_under", module_specs_rb_define_module_under, 2);
+#endif
+
+#ifdef HAVE_RB_DEFINE_CONST
rb_define_method(cls, "rb_define_const", module_specs_define_const, 3);
+#endif
+
+#ifdef HAVE_RB_DEFINE_GLOBAL_CONST
rb_define_method(cls, "rb_define_global_const", module_specs_define_global_const, 2);
+#endif
+
+#ifdef HAVE_RB_DEFINE_GLOBAL_FUNCTION
rb_define_method(cls, "rb_define_global_function",
module_specs_rb_define_global_function, 1);
+#endif
+#ifdef HAVE_RB_DEFINE_METHOD
rb_define_method(cls, "rb_define_method", module_specs_rb_define_method, 2);
+#endif
+
+#ifdef HAVE_RB_DEFINE_MODULE_FUNCTION
rb_define_method(cls, "rb_define_module_function",
module_specs_rb_define_module_function, 2);
+#endif
+#ifdef HAVE_RB_DEFINE_PRIVATE_METHOD
rb_define_method(cls, "rb_define_private_method",
module_specs_rb_define_private_method, 2);
+#endif
+#ifdef HAVE_RB_DEFINE_PROTECTED_METHOD
rb_define_method(cls, "rb_define_protected_method",
module_specs_rb_define_protected_method, 2);
+#endif
+#ifdef HAVE_RB_DEFINE_SINGLETON_METHOD
rb_define_method(cls, "rb_define_singleton_method",
module_specs_rb_define_singleton_method, 2);
+#endif
+#ifdef HAVE_RB_UNDEF_METHOD
rb_define_method(cls, "rb_undef_method", module_specs_rb_undef_method, 2);
+#endif
+
+#ifdef HAVE_RB_UNDEF
rb_define_method(cls, "rb_undef", module_specs_rb_undef, 2);
+#endif
+
+#ifdef HAVE_RB_CLASS2NAME
rb_define_method(cls, "rb_class2name", module_specs_rbclass2name, 1);
+#endif
+
+#ifdef HAVE_RB_MOD_ANCESTORS
rb_define_method(cls, "rb_mod_ancestors", module_specs_rb_mod_ancestors, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/mutex_spec.c b/spec/ruby/optional/capi/ext/mutex_spec.c
index c2fdf917ac..d5ce06e124 100644
--- a/spec/ruby/optional/capi/ext/mutex_spec.c
+++ b/spec/ruby/optional/capi/ext/mutex_spec.c
@@ -5,30 +5,43 @@
extern "C" {
#endif
+#ifdef HAVE_RB_MUTEX_NEW
VALUE mutex_spec_rb_mutex_new(VALUE self) {
return rb_mutex_new();
}
+#endif
+#ifdef HAVE_RB_MUTEX_LOCKED_P
VALUE mutex_spec_rb_mutex_locked_p(VALUE self, VALUE mutex) {
return rb_mutex_locked_p(mutex);
}
+#endif
+#ifdef HAVE_RB_MUTEX_TRYLOCK
VALUE mutex_spec_rb_mutex_trylock(VALUE self, VALUE mutex) {
return rb_mutex_trylock(mutex);
}
+#endif
+#ifdef HAVE_RB_MUTEX_LOCK
VALUE mutex_spec_rb_mutex_lock(VALUE self, VALUE mutex) {
return rb_mutex_lock(mutex);
}
+#endif
+#ifdef HAVE_RB_MUTEX_UNLOCK
VALUE mutex_spec_rb_mutex_unlock(VALUE self, VALUE mutex) {
return rb_mutex_unlock(mutex);
}
+#endif
+#ifdef HAVE_RB_MUTEX_SLEEP
VALUE mutex_spec_rb_mutex_sleep(VALUE self, VALUE mutex, VALUE timeout) {
return rb_mutex_sleep(mutex, timeout);
}
+#endif
+#ifdef HAVE_RB_MUTEX_SYNCHRONIZE
VALUE mutex_spec_rb_mutex_callback(VALUE arg) {
return rb_funcall(arg, rb_intern("call"), 0);
@@ -37,16 +50,39 @@ VALUE mutex_spec_rb_mutex_callback(VALUE arg) {
VALUE mutex_spec_rb_mutex_synchronize(VALUE self, VALUE mutex, VALUE value) {
return rb_mutex_synchronize(mutex, mutex_spec_rb_mutex_callback, value);
}
+#endif
void Init_mutex_spec(void) {
- VALUE cls = rb_define_class("CApiMutexSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiMutexSpecs", rb_cObject);
+
+#ifdef HAVE_RB_MUTEX_NEW
rb_define_method(cls, "rb_mutex_new", mutex_spec_rb_mutex_new, 0);
+#endif
+
+#ifdef HAVE_RB_MUTEX_LOCKED_P
rb_define_method(cls, "rb_mutex_locked_p", mutex_spec_rb_mutex_locked_p, 1);
+#endif
+
+#ifdef HAVE_RB_MUTEX_TRYLOCK
rb_define_method(cls, "rb_mutex_trylock", mutex_spec_rb_mutex_trylock, 1);
+#endif
+
+#ifdef HAVE_RB_MUTEX_LOCK
rb_define_method(cls, "rb_mutex_lock", mutex_spec_rb_mutex_lock, 1);
+#endif
+
+#ifdef HAVE_RB_MUTEX_UNLOCK
rb_define_method(cls, "rb_mutex_unlock", mutex_spec_rb_mutex_unlock, 1);
+#endif
+
+#ifdef HAVE_RB_MUTEX_SLEEP
rb_define_method(cls, "rb_mutex_sleep", mutex_spec_rb_mutex_sleep, 2);
+#endif
+
+#ifdef HAVE_RB_MUTEX_SYNCHRONIZE
rb_define_method(cls, "rb_mutex_synchronize", mutex_spec_rb_mutex_synchronize, 2);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/numeric_spec.c b/spec/ruby/optional/capi/ext/numeric_spec.c
index 556c71a587..2f0f504549 100644
--- a/spec/ruby/optional/capi/ext/numeric_spec.c
+++ b/spec/ruby/optional/capi/ext/numeric_spec.c
@@ -5,119 +5,170 @@
extern "C" {
#endif
-static VALUE numeric_spec_size_of_VALUE(VALUE self) {
- return INT2FIX(sizeof(VALUE));
-}
-
-static VALUE numeric_spec_size_of_long_long(VALUE self) {
- return INT2FIX(sizeof(LONG_LONG));
-}
-
+#ifdef HAVE_NUM2CHR
static VALUE numeric_spec_NUM2CHR(VALUE self, VALUE value) {
return INT2FIX(NUM2CHR(value));
}
+#endif
+#ifdef HAVE_RB_INT2INUM
static VALUE numeric_spec_rb_int2inum_14(VALUE self) {
return rb_int2inum(14);
}
+#endif
-static VALUE numeric_spec_rb_uint2inum_14(VALUE self) {
- return rb_uint2inum(14);
-}
-
-static VALUE numeric_spec_rb_uint2inum_n14(VALUE self) {
- return rb_uint2inum(-14);
-}
-
+#ifdef HAVE_RB_INTEGER
static VALUE numeric_spec_rb_Integer(VALUE self, VALUE str) {
return rb_Integer(str);
}
+#endif
+#ifdef HAVE_RB_LL2INUM
static VALUE numeric_spec_rb_ll2inum_14(VALUE self) {
return rb_ll2inum(14);
}
+#endif
-static VALUE numeric_spec_rb_ull2inum_14(VALUE self) {
- return rb_ull2inum(14);
-}
-
-static VALUE numeric_spec_rb_ull2inum_n14(VALUE self) {
- return rb_ull2inum(-14);
-}
-
-static VALUE numeric_spec_NUM2DBL(VALUE self, VALUE num) {
- return rb_float_new(NUM2DBL(num));
+#ifdef HAVE_RB_NUM2DBL
+static VALUE numeric_spec_rb_num2dbl(VALUE self, VALUE num) {
+ return rb_float_new(rb_num2dbl(num));
}
+#endif
-static VALUE numeric_spec_NUM2INT(VALUE self, VALUE num) {
- return LONG2NUM(NUM2INT(num));
+#ifdef HAVE_RB_NUM2INT
+static VALUE numeric_spec_rb_num2int(VALUE self, VALUE num) {
+ return LONG2NUM(rb_num2int(num));
}
+#endif
-static VALUE numeric_spec_INT2NUM(VALUE self, VALUE num) {
- return INT2NUM(NUM2LONG(num));
+#ifdef HAVE_RB_INT2NUM
+static VALUE numeric_spec_rb_int2num(VALUE self, VALUE num) {
+ return INT2NUM(rb_num2long(num));
}
+#endif
-static VALUE numeric_spec_NUM2LONG(VALUE self, VALUE num) {
- return LONG2NUM(NUM2LONG(num));
+#ifdef HAVE_RB_NUM2LONG
+static VALUE numeric_spec_rb_num2long(VALUE self, VALUE num) {
+ return LONG2NUM(rb_num2long(num));
}
+#endif
-static VALUE numeric_spec_NUM2UINT(VALUE self, VALUE num) {
- return ULONG2NUM(NUM2UINT(num));
+#ifdef HAVE_RB_NUM2UINT
+static VALUE numeric_spec_rb_num2uint(VALUE self, VALUE num) {
+ return ULONG2NUM(rb_num2uint(num));
}
+#endif
-static VALUE numeric_spec_NUM2ULONG(VALUE self, VALUE num) {
- return ULONG2NUM(NUM2ULONG(num));
+#ifdef HAVE_RB_NUM2ULONG
+static VALUE numeric_spec_rb_num2ulong(VALUE self, VALUE num) {
+ return ULONG2NUM(rb_num2ulong(num));
}
+#endif
+#ifdef HAVE_RB_NUM_ZERODIV
static VALUE numeric_spec_rb_num_zerodiv(VALUE self) {
rb_num_zerodiv();
return Qnil;
}
+#endif
+#ifdef HAVE_RB_CMPINT
static VALUE numeric_spec_rb_cmpint(VALUE self, VALUE val, VALUE b) {
return INT2FIX(rb_cmpint(val, val, b));
}
+#endif
+#ifdef HAVE_RB_NUM_COERCE_BIN
static VALUE numeric_spec_rb_num_coerce_bin(VALUE self, VALUE x, VALUE y, VALUE op) {
return rb_num_coerce_bin(x, y, SYM2ID(op));
}
+#endif
+#ifdef HAVE_RB_NUM_COERCE_CMP
static VALUE numeric_spec_rb_num_coerce_cmp(VALUE self, VALUE x, VALUE y, VALUE op) {
return rb_num_coerce_cmp(x, y, SYM2ID(op));
}
+#endif
+#ifdef HAVE_RB_NUM_COERCE_RELOP
static VALUE numeric_spec_rb_num_coerce_relop(VALUE self, VALUE x, VALUE y, VALUE op) {
return rb_num_coerce_relop(x, y, SYM2ID(op));
}
+#endif
+#ifdef HAVE_RB_ABSINT_SINGLEBIT_P
static VALUE numeric_spec_rb_absint_singlebit_p(VALUE self, VALUE num) {
return INT2FIX(rb_absint_singlebit_p(num));
}
+#endif
void Init_numeric_spec(void) {
- VALUE cls = rb_define_class("CApiNumericSpecs", rb_cObject);
- rb_define_method(cls, "size_of_VALUE", numeric_spec_size_of_VALUE, 0);
- rb_define_method(cls, "size_of_long_long", numeric_spec_size_of_long_long, 0);
+ VALUE cls;
+ cls = rb_define_class("CApiNumericSpecs", rb_cObject);
+
+#ifdef HAVE_NUM2CHR
rb_define_method(cls, "NUM2CHR", numeric_spec_NUM2CHR, 1);
+#endif
+
+#ifdef HAVE_RB_INT2INUM
rb_define_method(cls, "rb_int2inum_14", numeric_spec_rb_int2inum_14, 0);
- rb_define_method(cls, "rb_uint2inum_14", numeric_spec_rb_uint2inum_14, 0);
- rb_define_method(cls, "rb_uint2inum_n14", numeric_spec_rb_uint2inum_n14, 0);
+#endif
+
+#ifdef HAVE_RB_INTEGER
rb_define_method(cls, "rb_Integer", numeric_spec_rb_Integer, 1);
+#endif
+
+#ifdef HAVE_RB_LL2INUM
rb_define_method(cls, "rb_ll2inum_14", numeric_spec_rb_ll2inum_14, 0);
- rb_define_method(cls, "rb_ull2inum_14", numeric_spec_rb_ull2inum_14, 0);
- rb_define_method(cls, "rb_ull2inum_n14", numeric_spec_rb_ull2inum_n14, 0);
- rb_define_method(cls, "NUM2DBL", numeric_spec_NUM2DBL, 1);
- rb_define_method(cls, "NUM2INT", numeric_spec_NUM2INT, 1);
- rb_define_method(cls, "NUM2LONG", numeric_spec_NUM2LONG, 1);
- rb_define_method(cls, "INT2NUM", numeric_spec_INT2NUM, 1);
- rb_define_method(cls, "NUM2UINT", numeric_spec_NUM2UINT, 1);
- rb_define_method(cls, "NUM2ULONG", numeric_spec_NUM2ULONG, 1);
+#endif
+
+#ifdef HAVE_RB_NUM2DBL
+ rb_define_method(cls, "rb_num2dbl", numeric_spec_rb_num2dbl, 1);
+#endif
+
+#ifdef HAVE_RB_NUM2INT
+ rb_define_method(cls, "rb_num2int", numeric_spec_rb_num2int, 1);
+#endif
+
+#ifdef HAVE_RB_NUM2LONG
+ rb_define_method(cls, "rb_num2long", numeric_spec_rb_num2long, 1);
+#endif
+
+#ifdef HAVE_RB_INT2NUM
+ rb_define_method(cls, "rb_int2num", numeric_spec_rb_int2num, 1);
+#endif
+
+#ifdef HAVE_RB_NUM2UINT
+ rb_define_method(cls, "rb_num2uint", numeric_spec_rb_num2uint, 1);
+#endif
+
+#ifdef HAVE_RB_NUM2ULONG
+ rb_define_method(cls, "rb_num2ulong", numeric_spec_rb_num2ulong, 1);
+#endif
+
+#ifdef HAVE_RB_NUM_ZERODIV
rb_define_method(cls, "rb_num_zerodiv", numeric_spec_rb_num_zerodiv, 0);
+#endif
+
+#ifdef HAVE_RB_CMPINT
rb_define_method(cls, "rb_cmpint", numeric_spec_rb_cmpint, 2);
+#endif
+
+#ifdef HAVE_RB_NUM_COERCE_BIN
rb_define_method(cls, "rb_num_coerce_bin", numeric_spec_rb_num_coerce_bin, 3);
+#endif
+
+#ifdef HAVE_RB_NUM_COERCE_CMP
rb_define_method(cls, "rb_num_coerce_cmp", numeric_spec_rb_num_coerce_cmp, 3);
+#endif
+
+#ifdef HAVE_RB_NUM_COERCE_RELOP
rb_define_method(cls, "rb_num_coerce_relop", numeric_spec_rb_num_coerce_relop, 3);
+#endif
+
+#ifdef HAVE_RB_ABSINT_SINGLEBIT_P
rb_define_method(cls, "rb_absint_singlebit_p", numeric_spec_rb_absint_singlebit_p, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/object_spec.c b/spec/ruby/optional/capi/ext/object_spec.c
index cd32050f14..45a28169ef 100644
--- a/spec/ruby/optional/capi/ext/object_spec.c
+++ b/spec/ruby/optional/capi/ext/object_spec.c
@@ -5,6 +5,7 @@
extern "C" {
#endif
+#ifdef HAVE_FL_ABLE
static VALUE object_spec_FL_ABLE(VALUE self, VALUE obj) {
if (FL_ABLE(obj)) {
return Qtrue;
@@ -12,7 +13,9 @@ static VALUE object_spec_FL_ABLE(VALUE self, VALUE obj) {
return Qfalse;
}
}
+#endif
+#ifdef HAVE_FL_TEST
static int object_spec_FL_TEST_flag(VALUE flag_string) {
char *flag_cstr = StringValueCStr(flag_string);
if (strcmp(flag_cstr, "FL_TAINT") == 0) {
@@ -26,79 +29,115 @@ static int object_spec_FL_TEST_flag(VALUE flag_string) {
static VALUE object_spec_FL_TEST(VALUE self, VALUE obj, VALUE flag) {
return INT2FIX(FL_TEST(obj, object_spec_FL_TEST_flag(flag)));
}
+#endif
+#ifdef HAVE_OBJ_TAINT
static VALUE object_spec_OBJ_TAINT(VALUE self, VALUE obj) {
OBJ_TAINT(obj);
return Qnil;
}
+#endif
+#ifdef HAVE_OBJ_TAINTED
static VALUE object_spec_OBJ_TAINTED(VALUE self, VALUE obj) {
return OBJ_TAINTED(obj) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_OBJ_INFECT
static VALUE object_spec_OBJ_INFECT(VALUE self, VALUE host, VALUE source) {
OBJ_INFECT(host, source);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_ANY_TO_S
static VALUE object_spec_rb_any_to_s(VALUE self, VALUE obj) {
return rb_any_to_s(obj);
}
+#endif
+#ifdef HAVE_RB_ATTR_GET
static VALUE so_attr_get(VALUE self, VALUE obj, VALUE attr) {
return rb_attr_get(obj, SYM2ID(attr));
}
+#endif
+#ifdef HAVE_RB_OBJ_INSTANCE_VARIABLES
static VALUE object_spec_rb_obj_instance_variables(VALUE self, VALUE obj) {
return rb_obj_instance_variables(obj);
}
+#endif
+#ifdef HAVE_RB_CHECK_ARRAY_TYPE
static VALUE so_check_array_type(VALUE self, VALUE ary) {
return rb_check_array_type(ary);
}
+#endif
+#ifdef HAVE_RB_CHECK_CONVERT_TYPE
static VALUE so_check_convert_type(VALUE self, VALUE obj, VALUE klass, VALUE method) {
return rb_check_convert_type(obj, T_ARRAY, RSTRING_PTR(klass), RSTRING_PTR(method));
}
+#endif
+#ifdef HAVE_RB_CHECK_TO_INTEGER
static VALUE so_check_to_integer(VALUE self, VALUE obj, VALUE method) {
return rb_check_to_integer(obj, RSTRING_PTR(method));
}
+#endif
+#ifdef HAVE_RB_CHECK_FROZEN
static VALUE object_spec_rb_check_frozen(VALUE self, VALUE obj) {
rb_check_frozen(obj);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_CHECK_STRING_TYPE
static VALUE so_check_string_type(VALUE self, VALUE str) {
return rb_check_string_type(str);
}
+#endif
+#ifdef HAVE_RB_CLASS_OF
static VALUE so_rbclassof(VALUE self, VALUE obj) {
return rb_class_of(obj);
}
+#endif
+#ifdef HAVE_RB_CONVERT_TYPE
static VALUE so_convert_type(VALUE self, VALUE obj, VALUE klass, VALUE method) {
return rb_convert_type(obj, T_ARRAY, RSTRING_PTR(klass), RSTRING_PTR(method));
}
+#endif
+#ifdef HAVE_RB_EXTEND_OBJECT
static VALUE object_spec_rb_extend_object(VALUE self, VALUE obj, VALUE mod) {
rb_extend_object(obj, mod);
return obj;
}
+#endif
+#ifdef HAVE_RB_INSPECT
static VALUE so_inspect(VALUE self, VALUE obj) {
return rb_inspect(obj);
}
+#endif
+#ifdef HAVE_RB_OBJ_ALLOC
static VALUE so_rb_obj_alloc(VALUE self, VALUE klass) {
return rb_obj_alloc(klass);
}
+#endif
+#ifdef HAVE_RB_OBJ_DUP
static VALUE so_rb_obj_dup(VALUE self, VALUE klass) {
return rb_obj_dup(klass);
}
+#endif
+#ifdef HAVE_RB_OBJ_CALL_INIT
static VALUE so_rb_obj_call_init(VALUE self, VALUE object,
VALUE nargs, VALUE args) {
int c_nargs = FIX2INT(nargs);
@@ -112,58 +151,84 @@ static VALUE so_rb_obj_call_init(VALUE self, VALUE object,
return Qnil;
}
+#endif
+#ifdef HAVE_RB_OBJ_CLASSNAME
static VALUE so_rbobjclassname(VALUE self, VALUE obj) {
return rb_str_new2(rb_obj_classname(obj));
}
+#endif
+#ifdef HAVE_RB_OBJ_FREEZE
static VALUE object_spec_rb_obj_freeze(VALUE self, VALUE obj) {
return rb_obj_freeze(obj);
}
+#endif
+#ifdef HAVE_RB_OBJ_FROZEN_P
static VALUE object_spec_rb_obj_frozen_p(VALUE self, VALUE obj) {
return rb_obj_frozen_p(obj);
}
+#endif
+#ifdef HAVE_RB_OBJ_ID
static VALUE object_spec_rb_obj_id(VALUE self, VALUE obj) {
return rb_obj_id(obj);
}
+#endif
+#ifdef HAVE_RB_OBJ_IS_INSTANCE_OF
static VALUE so_instance_of(VALUE self, VALUE obj, VALUE klass) {
return rb_obj_is_instance_of(obj, klass);
}
+#endif
+#ifdef HAVE_RB_OBJ_IS_KIND_OF
static VALUE so_kind_of(VALUE self, VALUE obj, VALUE klass) {
return rb_obj_is_kind_of(obj, klass);
}
+#endif
+#ifdef HAVE_RB_OBJ_METHOD_ARITY
static VALUE object_specs_rb_obj_method_arity(VALUE self, VALUE obj, VALUE mid) {
return INT2FIX(rb_obj_method_arity(obj, SYM2ID(mid)));
}
+#endif
+#ifdef HAVE_RB_OBJ_TAINT
static VALUE object_spec_rb_obj_taint(VALUE self, VALUE obj) {
return rb_obj_taint(obj);
}
+#endif
+#ifdef HAVE_RB_REQUIRE
static VALUE so_require(VALUE self) {
rb_require("fixtures/foo");
return Qnil;
}
+#endif
+#ifdef HAVE_RB_RESPOND_TO
static VALUE so_respond_to(VALUE self, VALUE obj, VALUE sym) {
return rb_respond_to(obj, SYM2ID(sym)) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_OBJ_RESPOND_TO
static VALUE so_obj_respond_to(VALUE self, VALUE obj, VALUE sym, VALUE priv) {
return rb_obj_respond_to(obj, SYM2ID(sym), priv == Qtrue ? 1 : 0) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_METHOD_BOUNDP
static VALUE object_spec_rb_method_boundp(VALUE self, VALUE obj, VALUE method, VALUE exclude_private) {
ID id = SYM2ID(method);
return rb_method_boundp(obj, id, exclude_private == Qtrue ? 1 : 0) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_SPECIAL_CONST_P
static VALUE object_spec_rb_special_const_p(VALUE self, VALUE value) {
if (rb_special_const_p(value)) {
return Qtrue;
@@ -171,15 +236,21 @@ static VALUE object_spec_rb_special_const_p(VALUE self, VALUE value) {
return Qfalse;
}
}
+#endif
+#ifdef HAVE_RB_TO_ID
static VALUE so_to_id(VALUE self, VALUE obj) {
return ID2SYM(rb_to_id(obj));
}
+#endif
+#ifdef HAVE_RTEST
static VALUE object_spec_RTEST(VALUE self, VALUE value) {
return RTEST(value) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_TYPE
static VALUE so_is_type_nil(VALUE self, VALUE obj) {
if(TYPE(obj) == T_NIL) {
return Qtrue;
@@ -221,7 +292,9 @@ static VALUE so_is_type_data(VALUE self, VALUE obj) {
}
return Qfalse;
}
+#endif
+#ifdef HAVE_RB_TYPE_P
static VALUE so_is_rb_type_p_nil(VALUE self, VALUE obj) {
if(rb_type_p(obj, T_NIL)) {
return Qtrue;
@@ -263,7 +336,9 @@ static VALUE so_is_rb_type_p_data(VALUE self, VALUE obj) {
}
return Qfalse;
}
+#endif
+#ifdef HAVE_BUILTIN_TYPE
static VALUE so_is_builtin_type_object(VALUE self, VALUE obj) {
if(BUILTIN_TYPE(obj) == T_OBJECT) {
return Qtrue;
@@ -298,120 +373,272 @@ static VALUE so_is_builtin_type_data(VALUE self, VALUE obj) {
}
return Qfalse;
}
+#endif
+#ifdef HAVE_RB_TO_INT
static VALUE object_spec_rb_to_int(VALUE self, VALUE obj) {
return rb_to_int(obj);
}
+#endif
+#ifdef HAVE_RB_OBJ_INSTANCE_EVAL
static VALUE object_spec_rb_obj_instance_eval(VALUE self, VALUE obj) {
return rb_obj_instance_eval(0, NULL, obj);
}
+#endif
+#ifdef HAVE_RB_IV_GET
static VALUE object_spec_rb_iv_get(VALUE self, VALUE obj, VALUE name) {
return rb_iv_get(obj, RSTRING_PTR(name));
}
+#endif
+#ifdef HAVE_RB_IV_SET
static VALUE object_spec_rb_iv_set(VALUE self, VALUE obj, VALUE name, VALUE value) {
return rb_iv_set(obj, RSTRING_PTR(name), value);
}
+#endif
+#ifdef HAVE_RB_IVAR_GET
static VALUE object_spec_rb_ivar_get(VALUE self, VALUE obj, VALUE sym_name) {
return rb_ivar_get(obj, SYM2ID(sym_name));
}
+#endif
+#ifdef HAVE_RB_IVAR_SET
static VALUE object_spec_rb_ivar_set(VALUE self, VALUE obj, VALUE sym_name, VALUE value) {
return rb_ivar_set(obj, SYM2ID(sym_name), value);
}
+#endif
+#ifdef HAVE_RB_IVAR_DEFINED
static VALUE object_spec_rb_ivar_defined(VALUE self, VALUE obj, VALUE sym_name) {
return rb_ivar_defined(obj, SYM2ID(sym_name));
}
+#endif
-static VALUE object_spec_rb_copy_generic_ivar(VALUE self, VALUE clone, VALUE obj) {
- rb_copy_generic_ivar(clone, obj);
- return self;
-}
-
-static VALUE object_spec_rb_free_generic_ivar(VALUE self, VALUE obj) {
- rb_free_generic_ivar(obj);
- return self;
-}
-
+#ifdef HAVE_RB_EQUAL
static VALUE object_spec_rb_equal(VALUE self, VALUE a, VALUE b) {
return rb_equal(a, b);
}
+#endif
+#ifdef HAVE_RB_CLASS_INHERITED_P
static VALUE object_spec_rb_class_inherited_p(VALUE self, VALUE mod, VALUE arg) {
return rb_class_inherited_p(mod, arg);
}
+#endif
void Init_object_spec(void) {
- VALUE cls = rb_define_class("CApiObjectSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiObjectSpecs", rb_cObject);
+
+#ifdef HAVE_FL_ABLE
rb_define_method(cls, "FL_ABLE", object_spec_FL_ABLE, 1);
+#endif
+
+#ifdef HAVE_FL_TEST
rb_define_method(cls, "FL_TEST", object_spec_FL_TEST, 2);
+#endif
+
+#ifdef HAVE_OBJ_TAINT
rb_define_method(cls, "OBJ_TAINT", object_spec_OBJ_TAINT, 1);
+#endif
+
+#ifdef HAVE_OBJ_TAINTED
rb_define_method(cls, "OBJ_TAINTED", object_spec_OBJ_TAINTED, 1);
+#endif
+
+#ifdef HAVE_OBJ_INFECT
rb_define_method(cls, "OBJ_INFECT", object_spec_OBJ_INFECT, 2);
+#endif
+
+#ifdef HAVE_RB_ANY_TO_S
rb_define_method(cls, "rb_any_to_s", object_spec_rb_any_to_s, 1);
+#endif
+
+#ifdef HAVE_RB_ATTR_GET
rb_define_method(cls, "rb_attr_get", so_attr_get, 2);
+#endif
+
+#ifdef HAVE_RB_OBJ_INSTANCE_VARIABLES
rb_define_method(cls, "rb_obj_instance_variables", object_spec_rb_obj_instance_variables, 1);
+#endif
+
+#ifdef HAVE_RB_CHECK_ARRAY_TYPE
rb_define_method(cls, "rb_check_array_type", so_check_array_type, 1);
+#endif
+
+#ifdef HAVE_RB_CHECK_CONVERT_TYPE
rb_define_method(cls, "rb_check_convert_type", so_check_convert_type, 3);
+#endif
+
+#ifdef HAVE_RB_CHECK_TO_INTEGER
rb_define_method(cls, "rb_check_to_integer", so_check_to_integer, 2);
+#endif
+
+#ifdef HAVE_RB_CHECK_FROZEN
rb_define_method(cls, "rb_check_frozen", object_spec_rb_check_frozen, 1);
+#endif
+
+#ifdef HAVE_RB_CHECK_STRING_TYPE
rb_define_method(cls, "rb_check_string_type", so_check_string_type, 1);
+#endif
+
+#ifdef HAVE_RB_CLASS_OF
rb_define_method(cls, "rb_class_of", so_rbclassof, 1);
+#endif
+
+#ifdef HAVE_RB_CONVERT_TYPE
rb_define_method(cls, "rb_convert_type", so_convert_type, 3);
+#endif
+
+#ifdef HAVE_RB_EXTEND_OBJECT
rb_define_method(cls, "rb_extend_object", object_spec_rb_extend_object, 2);
+#endif
+
+#ifdef HAVE_RB_INSPECT
rb_define_method(cls, "rb_inspect", so_inspect, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_ALLOC
rb_define_method(cls, "rb_obj_alloc", so_rb_obj_alloc, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_ALLOC
rb_define_method(cls, "rb_obj_dup", so_rb_obj_dup, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_CALL_INIT
rb_define_method(cls, "rb_obj_call_init", so_rb_obj_call_init, 3);
+#endif
+
+#ifdef HAVE_RB_OBJ_CLASSNAME
rb_define_method(cls, "rb_obj_classname", so_rbobjclassname, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_FREEZE
rb_define_method(cls, "rb_obj_freeze", object_spec_rb_obj_freeze, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_FROZEN_P
rb_define_method(cls, "rb_obj_frozen_p", object_spec_rb_obj_frozen_p, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_ID
rb_define_method(cls, "rb_obj_id", object_spec_rb_obj_id, 1);
+#endif
+
+#ifdef HAVE_RB_OBJ_IS_INSTANCE_OF
rb_define_method(cls, "rb_obj_is_instance_of", so_instance_of, 2);
+#endif
+
+#ifdef HAVE_RB_OBJ_IS_KIND_OF
rb_define_method(cls, "rb_obj_is_kind_of", so_kind_of, 2);
+#endif
+
+#ifdef HAVE_RB_OBJ_METHOD_ARITY
rb_define_method(cls, "rb_obj_method_arity", object_specs_rb_obj_method_arity, 2);
+#endif
+
+#ifdef HAVE_RB_OBJ_TAINT
rb_define_method(cls, "rb_obj_taint", object_spec_rb_obj_taint, 1);
+#endif
+
+#ifdef HAVE_RB_REQUIRE
rb_define_method(cls, "rb_require", so_require, 0);
+#endif
+
+#ifdef HAVE_RB_RESPOND_TO
rb_define_method(cls, "rb_respond_to", so_respond_to, 2);
+#endif
+
+#ifdef HAVE_RB_METHOD_BOUNDP
rb_define_method(cls, "rb_method_boundp", object_spec_rb_method_boundp, 3);
+#endif
+
+#ifdef HAVE_RB_OBJ_RESPOND_TO
rb_define_method(cls, "rb_obj_respond_to", so_obj_respond_to, 3);
+#endif
+
+#ifdef HAVE_RB_SPECIAL_CONST_P
rb_define_method(cls, "rb_special_const_p", object_spec_rb_special_const_p, 1);
+#endif
+
+#ifdef HAVE_RB_STR_NEW2
+#endif
+#ifdef HAVE_RB_TO_ID
rb_define_method(cls, "rb_to_id", so_to_id, 1);
+#endif
+
+#ifdef HAVE_RTEST
rb_define_method(cls, "RTEST", object_spec_RTEST, 1);
+#endif
+
+#ifdef HAVE_TYPE
rb_define_method(cls, "rb_is_type_nil", so_is_type_nil, 1);
rb_define_method(cls, "rb_is_type_object", so_is_type_object, 1);
rb_define_method(cls, "rb_is_type_array", so_is_type_array, 1);
rb_define_method(cls, "rb_is_type_module", so_is_type_module, 1);
rb_define_method(cls, "rb_is_type_class", so_is_type_class, 1);
rb_define_method(cls, "rb_is_type_data", so_is_type_data, 1);
+#endif
+
+#ifdef HAVE_RB_TYPE_P
rb_define_method(cls, "rb_is_rb_type_p_nil", so_is_rb_type_p_nil, 1);
rb_define_method(cls, "rb_is_rb_type_p_object", so_is_rb_type_p_object, 1);
rb_define_method(cls, "rb_is_rb_type_p_array", so_is_rb_type_p_array, 1);
rb_define_method(cls, "rb_is_rb_type_p_module", so_is_rb_type_p_module, 1);
rb_define_method(cls, "rb_is_rb_type_p_class", so_is_rb_type_p_class, 1);
rb_define_method(cls, "rb_is_rb_type_p_data", so_is_rb_type_p_data, 1);
+#endif
+
+#ifdef HAVE_BUILTIN_TYPE
rb_define_method(cls, "rb_is_builtin_type_object", so_is_builtin_type_object, 1);
rb_define_method(cls, "rb_is_builtin_type_array", so_is_builtin_type_array, 1);
rb_define_method(cls, "rb_is_builtin_type_module", so_is_builtin_type_module, 1);
rb_define_method(cls, "rb_is_builtin_type_class", so_is_builtin_type_class, 1);
rb_define_method(cls, "rb_is_builtin_type_data", so_is_builtin_type_data, 1);
+#endif
+
+#ifdef HAVE_RB_TO_INT
rb_define_method(cls, "rb_to_int", object_spec_rb_to_int, 1);
+#endif
+
+#ifdef HAVE_RB_EQUAL
rb_define_method(cls, "rb_equal", object_spec_rb_equal, 2);
+#endif
+
+#ifdef HAVE_RB_CLASS_INHERITED_P
rb_define_method(cls, "rb_class_inherited_p", object_spec_rb_class_inherited_p, 2);
+#endif
+
+#ifdef HAVE_RB_OBJ_INSTANCE_EVAL
rb_define_method(cls, "rb_obj_instance_eval", object_spec_rb_obj_instance_eval, 1);
+#endif
+
+#ifdef HAVE_RB_IV_GET
rb_define_method(cls, "rb_iv_get", object_spec_rb_iv_get, 2);
+#endif
+
+#ifdef HAVE_RB_IV_SET
rb_define_method(cls, "rb_iv_set", object_spec_rb_iv_set, 3);
+#endif
+
+#ifdef HAVE_RB_IVAR_GET
rb_define_method(cls, "rb_ivar_get", object_spec_rb_ivar_get, 2);
+#endif
+
+#ifdef HAVE_RB_IVAR_SET
rb_define_method(cls, "rb_ivar_set", object_spec_rb_ivar_set, 3);
+#endif
+
+#ifdef HAVE_RB_IVAR_DEFINED
rb_define_method(cls, "rb_ivar_defined", object_spec_rb_ivar_defined, 2);
- rb_define_method(cls, "rb_copy_generic_ivar", object_spec_rb_copy_generic_ivar, 2);
- rb_define_method(cls, "rb_free_generic_ivar", object_spec_rb_free_generic_ivar, 1);
+#endif
+
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/proc_spec.c b/spec/ruby/optional/capi/ext/proc_spec.c
index 18fd1997ee..f9c0f6b1b9 100644
--- a/spec/ruby/optional/capi/ext/proc_spec.c
+++ b/spec/ruby/optional/capi/ext/proc_spec.c
@@ -7,21 +7,27 @@
extern "C" {
#endif
-VALUE proc_spec_rb_proc_new_function(RB_BLOCK_CALL_FUNC_ARGLIST(args, dummy)) {
+#ifdef HAVE_RB_PROC_NEW
+VALUE proc_spec_rb_proc_new_function(VALUE args) {
return rb_funcall(args, rb_intern("inspect"), 0);
}
VALUE proc_spec_rb_proc_new(VALUE self) {
return rb_proc_new(proc_spec_rb_proc_new_function, Qnil);
}
+#endif
+#ifdef HAVE_RB_PROC_ARITY
VALUE proc_spec_rb_proc_arity(VALUE self, VALUE prc) {
return INT2FIX(rb_proc_arity(prc));
}
+#endif
+#ifdef HAVE_RB_PROC_CALL
VALUE proc_spec_rb_proc_call(VALUE self, VALUE prc, VALUE args) {
return rb_proc_call(prc, args);
}
+#endif
/* This helper is not strictly necessary but reflects the code in wxRuby that
* originally exposed issues with this Proc.new behavior.
@@ -56,10 +62,21 @@ VALUE proc_spec_rb_Proc_new(VALUE self, VALUE scenario) {
}
void Init_proc_spec(void) {
- VALUE cls = rb_define_class("CApiProcSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiProcSpecs", rb_cObject);
+
+#ifdef HAVE_RB_PROC_NEW
rb_define_method(cls, "rb_proc_new", proc_spec_rb_proc_new, 0);
+#endif
+
+#ifdef HAVE_RB_PROC_ARITY
rb_define_method(cls, "rb_proc_arity", proc_spec_rb_proc_arity, 1);
+#endif
+
+#ifdef HAVE_RB_PROC_CALL
rb_define_method(cls, "rb_proc_call", proc_spec_rb_proc_call, 2);
+#endif
+
rb_define_method(cls, "rb_Proc_new", proc_spec_rb_Proc_new, 1);
}
diff --git a/spec/ruby/optional/capi/ext/range_spec.c b/spec/ruby/optional/capi/ext/range_spec.c
index 7a475ec695..6dc2d579fd 100644
--- a/spec/ruby/optional/capi/ext/range_spec.c
+++ b/spec/ruby/optional/capi/ext/range_spec.c
@@ -5,6 +5,7 @@
extern "C" {
#endif
+#ifdef HAVE_RB_RANGE_NEW
VALUE range_spec_rb_range_new(int argc, VALUE* argv, VALUE self) {
int exclude_end = 0;
if(argc == 3) {
@@ -12,7 +13,9 @@ VALUE range_spec_rb_range_new(int argc, VALUE* argv, VALUE self) {
}
return rb_range_new(argv[0], argv[1], exclude_end);
}
+#endif
+#ifdef HAVE_RB_RANGE_VALUES
VALUE range_spec_rb_range_values(VALUE self, VALUE range) {
VALUE beg;
VALUE end;
@@ -24,7 +27,9 @@ VALUE range_spec_rb_range_values(VALUE self, VALUE range) {
rb_ary_store(ary, 2, excl ? Qtrue : Qfalse);
return ary;
}
+#endif
+#ifdef HAVE_RB_RANGE_BEG_LEN
VALUE range_spec_rb_range_beg_len(VALUE self, VALUE range, VALUE begpv, VALUE lenpv, VALUE lenv, VALUE errv) {
long begp = FIX2LONG(begpv);
long lenp = FIX2LONG(lenpv);
@@ -37,12 +42,23 @@ VALUE range_spec_rb_range_beg_len(VALUE self, VALUE range, VALUE begpv, VALUE le
rb_ary_store(ary, 2, res);
return ary;
}
+#endif
void Init_range_spec(void) {
- VALUE cls = rb_define_class("CApiRangeSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiRangeSpecs", rb_cObject);
+
+#ifdef HAVE_RB_RANGE_NEW
rb_define_method(cls, "rb_range_new", range_spec_rb_range_new, -1);
+#endif
+
+#ifdef HAVE_RB_RANGE_VALUES
rb_define_method(cls, "rb_range_values", range_spec_rb_range_values, 1);
+#endif
+
+#ifdef HAVE_RB_RANGE_BEG_LEN
rb_define_method(cls, "rb_range_beg_len", range_spec_rb_range_beg_len, 5);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/rational_spec.c b/spec/ruby/optional/capi/ext/rational_spec.c
index 6273af68c5..9f349261a0 100644
--- a/spec/ruby/optional/capi/ext/rational_spec.c
+++ b/spec/ruby/optional/capi/ext/rational_spec.c
@@ -5,48 +5,89 @@
extern "C" {
#endif
+#ifdef HAVE_RB_RATIONAL
static VALUE rational_spec_rb_Rational(VALUE self, VALUE num, VALUE den) {
return rb_Rational(num, den);
}
+#endif
+#ifdef HAVE_RB_RATIONAL1
static VALUE rational_spec_rb_Rational1(VALUE self, VALUE num) {
return rb_Rational1(num);
}
+#endif
+#ifdef HAVE_RB_RATIONAL2
static VALUE rational_spec_rb_Rational2(VALUE self, VALUE num, VALUE den) {
return rb_Rational2(num, den);
}
+#endif
+#ifdef HAVE_RB_RATIONAL_NEW
static VALUE rational_spec_rb_rational_new(VALUE self, VALUE num, VALUE den) {
return rb_rational_new(num, den);
}
+#endif
+#ifdef HAVE_RB_RATIONAL_NEW1
static VALUE rational_spec_rb_rational_new1(VALUE self, VALUE num) {
return rb_rational_new1(num);
}
+#endif
+#ifdef HAVE_RB_RATIONAL_NEW2
static VALUE rational_spec_rb_rational_new2(VALUE self, VALUE num, VALUE den) {
return rb_rational_new2(num, den);
}
+#endif
+#ifdef HAVE_RB_RATIONAL_NUM
static VALUE rational_spec_rb_rational_num(VALUE self, VALUE rational) {
return rb_rational_num(rational);
}
+#endif
+#ifdef HAVE_RB_RATIONAL_DEN
static VALUE rational_spec_rb_rational_den(VALUE self, VALUE rational) {
return rb_rational_den(rational);
}
+#endif
void Init_rational_spec(void) {
- VALUE cls = rb_define_class("CApiRationalSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiRationalSpecs", rb_cObject);
+
+#ifdef HAVE_RB_RATIONAL
rb_define_method(cls, "rb_Rational", rational_spec_rb_Rational, 2);
+#endif
+
+#ifdef HAVE_RB_RATIONAL1
rb_define_method(cls, "rb_Rational1", rational_spec_rb_Rational1, 1);
+#endif
+
+#ifdef HAVE_RB_RATIONAL2
rb_define_method(cls, "rb_Rational2", rational_spec_rb_Rational2, 2);
+#endif
+
+#ifdef HAVE_RB_RATIONAL_NEW
rb_define_method(cls, "rb_rational_new", rational_spec_rb_rational_new, 2);
+#endif
+
+#ifdef HAVE_RB_RATIONAL_NEW1
rb_define_method(cls, "rb_rational_new1", rational_spec_rb_rational_new1, 1);
+#endif
+
+#ifdef HAVE_RB_RATIONAL_NEW2
rb_define_method(cls, "rb_rational_new2", rational_spec_rb_rational_new2, 2);
+#endif
+
+#ifdef HAVE_RB_RATIONAL_NUM
rb_define_method(cls, "rb_rational_num", rational_spec_rb_rational_num, 1);
+#endif
+
+#ifdef HAVE_RB_RATIONAL_DEN
rb_define_method(cls, "rb_rational_den", rational_spec_rb_rational_den, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/regexp_spec.c b/spec/ruby/optional/capi/ext/regexp_spec.c
index fc1c8b1e63..1058293444 100644
--- a/spec/ruby/optional/capi/ext/regexp_spec.c
+++ b/spec/ruby/optional/capi/ext/regexp_spec.c
@@ -9,29 +9,41 @@
extern "C" {
#endif
+#ifdef HAVE_RB_REG_NEW
VALUE regexp_spec_re(VALUE self) {
return rb_reg_new("a", 1, 0);
}
+#endif
+#ifdef HAVE_RB_REG_NTH_MATCH
VALUE regexp_spec_reg_1st_match(VALUE self, VALUE md) {
return rb_reg_nth_match(1, md);
}
+#endif
+#ifdef HAVE_RB_REG_OPTIONS
VALUE regexp_spec_rb_reg_options(VALUE self, VALUE regexp) {
return INT2FIX(rb_reg_options(regexp));
}
+#endif
+#ifdef HAVE_RB_REG_REGCOMP
VALUE regexp_spec_rb_reg_regcomp(VALUE self, VALUE str) {
return rb_reg_regcomp(str);
}
+#endif
+#ifdef HAVE_RB_REG_MATCH
VALUE regexp_spec_reg_match(VALUE self, VALUE re, VALUE str) {
return rb_reg_match(re, str);
}
+#endif
+#ifdef HAVE_RB_BACKREF_GET
VALUE regexp_spec_backref_get(VALUE self) {
return rb_backref_get();
}
+#endif
VALUE regexp_spec_match(VALUE self, VALUE regexp, VALUE str) {
return rb_funcall(regexp, rb_intern("match"), 1, str);
@@ -39,13 +51,32 @@ VALUE regexp_spec_match(VALUE self, VALUE regexp, VALUE str) {
void Init_regexp_spec(void) {
VALUE cls = rb_define_class("CApiRegexpSpecs", rb_cObject);
+
rb_define_method(cls, "match", regexp_spec_match, 2);
+
+#ifdef HAVE_RB_REG_NEW
rb_define_method(cls, "a_re", regexp_spec_re, 0);
+#endif
+
+#ifdef HAVE_RB_REG_NTH_MATCH
rb_define_method(cls, "a_re_1st_match", regexp_spec_reg_1st_match, 1);
+#endif
+
+#ifdef HAVE_RB_REG_MATCH
rb_define_method(cls, "rb_reg_match", regexp_spec_reg_match, 2);
+#endif
+
+#ifdef HAVE_RB_BACKREF_GET
rb_define_method(cls, "rb_backref_get", regexp_spec_backref_get, 0);
+#endif
+
+#ifdef HAVE_RB_REG_OPTIONS
rb_define_method(cls, "rb_reg_options", regexp_spec_rb_reg_options, 1);
+#endif
+
+#ifdef HAVE_RB_REG_REGCOMP
rb_define_method(cls, "rb_reg_regcomp", regexp_spec_rb_reg_regcomp, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/rubyspec.h b/spec/ruby/optional/capi/ext/rubyspec.h
index 78e298fddb..341cff0428 100644
--- a/spec/ruby/optional/capi/ext/rubyspec.h
+++ b/spec/ruby/optional/capi/ext/rubyspec.h
@@ -23,12 +23,591 @@
(RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR < (minor)) || \
(RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR == (minor) && RUBY_VERSION_TEENY < (teeny)))
-#if RUBY_VERSION_MAJOR > 2 || (RUBY_VERSION_MAJOR == 2 && RUBY_VERSION_MINOR >= 6)
-#define RUBY_VERSION_IS_2_6
-#endif
-
#if RUBY_VERSION_MAJOR > 2 || (RUBY_VERSION_MAJOR == 2 && RUBY_VERSION_MINOR >= 4)
#define RUBY_VERSION_IS_2_4
#endif
+#if RUBY_VERSION_MAJOR > 2 || (RUBY_VERSION_MAJOR == 2 && RUBY_VERSION_MINOR >= 3)
+#define RUBY_VERSION_IS_2_3
+#endif
+
+/* Define all function flags */
+
+/* Array */
+#define HAVE_RB_ARRAY 1
+#define HAVE_RARRAY_AREF 1
+#define HAVE_RARRAY_LEN 1
+#define HAVE_RARRAY_PTR 1
+#define HAVE_RB_ARY_AREF 1
+#define HAVE_RB_ARY_CLEAR 1
+#define HAVE_RB_ARY_DELETE 1
+#define HAVE_RB_ARY_DELETE_AT 1
+#define HAVE_RB_ARY_DUP 1
+#define HAVE_RB_ARY_ENTRY 1
+#define HAVE_RB_ARY_FREEZE 1
+#define HAVE_RB_ARY_INCLUDES 1
+#define HAVE_RB_ARY_JOIN 1
+#define HAVE_RB_ARY_NEW 1
+#define HAVE_RB_ARY_NEW2 1
+#define HAVE_RB_ARY_NEW_CAPA 1
+#define HAVE_RB_ARY_NEW3 1
+#define HAVE_RB_ARY_NEW_FROM_ARGS 1
+#define HAVE_RB_ARY_NEW4 1
+#define HAVE_RB_ARY_NEW_FROM_VALUES 1
+#define HAVE_RB_ARY_POP 1
+#define HAVE_RB_ARY_PUSH 1
+#define HAVE_RB_ARY_CAT 1
+#define HAVE_RB_ARY_REVERSE 1
+#define HAVE_RB_ARY_ROTATE 1
+#define HAVE_RB_ARY_SHIFT 1
+#define HAVE_RB_ARY_STORE 1
+#define HAVE_RB_ARY_CONCAT 1
+#define HAVE_RB_ARY_PLUS 1
+#define HAVE_RB_ARY_TO_ARY 1
+#define HAVE_RB_ARY_SUBSEQ 1
+#define HAVE_RB_ARY_TO_S 1
+#define HAVE_RB_ARY_UNSHIFT 1
+#define HAVE_RB_ASSOC_NEW 1
+
+#define HAVE_RB_EACH 1
+#define HAVE_RB_ITERATE 1
+#define HAVE_RB_MEM_CLEAR 1
+
+/* Bignum */
+#define HAVE_ABSINT_SIZE 1
+#define HAVE_RB_BIG2DBL 1
+#define HAVE_RB_DBL2BIG 1
+#define HAVE_RB_BIG2LL 1
+#define HAVE_RB_BIG2LONG 1
+#define HAVE_RB_BIG2STR 1
+#define HAVE_RB_BIG2ULONG 1
+#define HAVE_RB_BIG_CMP 1
+#define HAVE_RB_BIG_PACK 1
+
+/* Class */
+#define HAVE_RB_CALL_SUPER 1
+#define HAVE_RB_CLASS2NAME 1
+#define HAVE_RB_CLASS_NAME 1
+#define HAVE_RB_CLASS_NEW 1
+#define HAVE_RB_CLASS_NEW_INSTANCE 1
+#define HAVE_RB_CLASS_PATH 1
+#define HAVE_RB_CLASS_REAL 1
+#define HAVE_RB_CVAR_DEFINED 1
+#define HAVE_RB_CVAR_GET 1
+#define HAVE_RB_CVAR_SET 1
+#define HAVE_RB_CV_GET 1
+#define HAVE_RB_CV_SET 1
+#define HAVE_RB_DEFINE_ATTR 1
+#define HAVE_RB_DEFINE_CLASS_VARIABLE 1
+#define HAVE_RB_INCLUDE_MODULE 1
+#define HAVE_RB_PATH2CLASS 1
+#define HAVE_RB_PATH_TO_CLASS 1
+#define HAVE_RB_CLASS_SUPERCLASS 1
+
+/* Complex */
+#define HAVE_RB_COMPLEX 1
+#define HAVE_RB_COMPLEX1 1
+#define HAVE_RB_COMPLEX2 1
+#define HAVE_RB_COMPLEX_NEW 1
+#define HAVE_RB_COMPLEX_NEW1 1
+#define HAVE_RB_COMPLEX_NEW2 1
+
+/* Constants */
+#define HAVE_RB_CARRAY 1
+#ifndef RUBY_INTEGER_UNIFICATION
+#define HAVE_RB_CBIGNUM 1
+#endif
+#define HAVE_RB_CCLASS 1
+#define HAVE_RB_CDATA 1
+#define HAVE_RB_CFALSECLASS 1
+#define HAVE_RB_CFILE 1
+#ifndef RUBY_INTEGER_UNIFICATION
+#define HAVE_RB_CFIXNUM 1
+#endif
+#define HAVE_RB_CFLOAT 1
+#define HAVE_RB_CHASH 1
+#define HAVE_RB_CINTEGER 1
+#define HAVE_RB_CIO 1
+#define HAVE_RB_CMATCH 1
+#define HAVE_RB_CMODULE 1
+#define HAVE_RB_CNILCLASS 1
+#define HAVE_RB_CNUMERIC 1
+#define HAVE_RB_COBJECT 1
+#define HAVE_RB_CPROC 1
+#define HAVE_RB_CMETHOD 1
+#define HAVE_RB_CRANGE 1
+#define HAVE_RB_CREGEXP 1
+#define HAVE_RB_CSTRING 1
+#define HAVE_RB_CSTRUCT 1
+#define HAVE_RB_CSYMBOL 1
+#define HAVE_RB_CTIME 1
+#define HAVE_RB_CTHREAD 1
+#define HAVE_RB_CTRUECLASS 1
+#define HAVE_RB_CNUMERATOR 1
+#define HAVE_RB_EARGERROR 1
+#define HAVE_RB_EEOFERROR 1
+#define HAVE_RB_EEXCEPTION 1
+#define HAVE_RB_EFLOATDOMAINERROR 1
+#define HAVE_RB_EINDEXERROR 1
+#define HAVE_RB_EINTERRUPT 1
+#define HAVE_RB_EIOERROR 1
+#define HAVE_RB_ELOADERROR 1
+#define HAVE_RB_ELOCALJUMPERROR 1
+#define HAVE_RB_EMATHDOMAINERROR 1
+#define HAVE_RB_ENAMEERROR 1
+#define HAVE_RB_ENOMEMERROR 1
+#define HAVE_RB_ENOMETHODERROR 1
+#define HAVE_RB_ENOTIMPERROR 1
+#define HAVE_RB_ERANGEERROR 1
+#define HAVE_RB_EREGEXPERROR 1
+#define HAVE_RB_ERUNTIMEERROR 1
+#define HAVE_RB_ESCRIPTERROR 1
+#define HAVE_RB_ESECURITYERROR 1
+#define HAVE_RB_ESIGNAL 1
+#define HAVE_RB_ESTANDARDERROR 1
+#define HAVE_RB_ESYNTAXERROR 1
+#define HAVE_RB_ESYSSTACKERROR 1
+#define HAVE_RB_ESYSTEMCALLERROR 1
+#define HAVE_RB_ESYSTEMEXIT 1
+#define HAVE_RB_ETHREADERROR 1
+#define HAVE_RB_ETYPEERROR 1
+#define HAVE_RB_EZERODIVERROR 1
+#define HAVE_RB_MCOMPARABLE 1
+#define HAVE_RB_MENUMERABLE 1
+#define HAVE_RB_MERRNO 1
+#define HAVE_RB_MKERNEL 1
+#define HAVE_RB_CDIR 1
+
+/* Data */
+#define HAVE_DATA_WRAP_STRUCT 1
+#define HAVE_RDATA 1
+
+#define HAVE_TYPEDDATA_WRAP_STRUCT 1
+#define HAVE_RTYPEDDATA
+
+/* Encoding */
+#define HAVE_ENCODING_GET 1
+#define HAVE_ENCODING_SET 1
+#define HAVE_ENC_CODERANGE_ASCIIONLY 1
+
+#define HAVE_RB_ASCII8BIT_ENCODING 1
+#define HAVE_RB_ASCII8BIT_ENCINDEX 1
+#define HAVE_RB_USASCII_ENCODING 1
+#define HAVE_RB_USASCII_ENCINDEX 1
+#define HAVE_RB_UTF8_ENCODING 1
+#define HAVE_RB_UTF8_ENCINDEX 1
+#define HAVE_RB_LOCALE_ENCODING 1
+#define HAVE_RB_LOCALE_ENCINDEX 1
+#define HAVE_RB_FILESYSTEM_ENCODING 1
+#define HAVE_RB_FILESYSTEM_ENCINDEX 1
+
+#define HAVE_RB_DEFAULT_INTERNAL_ENCODING 1
+#define HAVE_RB_DEFAULT_EXTERNAL_ENCODING 1
+
+#define HAVE_RB_ENCDB_ALIAS 1
+#define HAVE_RB_ENC_ASSOCIATE 1
+#define HAVE_RB_ENC_ASSOCIATE_INDEX 1
+#define HAVE_RB_ENC_CODEPOINT_LEN 1
+#define HAVE_RB_ENC_COMPATIBLE 1
+#define HAVE_RB_ENC_COPY 1
+#define HAVE_RB_ENC_FIND 1
+#define HAVE_RB_ENC_FIND_INDEX 1
+#define HAVE_RB_ENC_FROM_ENCODING 1
+#define HAVE_RB_ENC_FROM_INDEX 1
+#define HAVE_RB_ENC_GET 1
+#define HAVE_RB_ENC_GET_INDEX 1
+#define HAVE_RB_ENC_SET_INDEX 1
+#define HAVE_RB_ENC_STR_CODERANGE 1
+#define HAVE_RB_ENC_STR_NEW 1
+#define HAVE_RB_ENC_TO_INDEX 1
+#define HAVE_RB_OBJ_ENCODING 1
+
+#define HAVE_RB_STR_ENCODE 1
+#define HAVE_RB_STR_NEW_CSTR 1
+#define HAVE_RB_USASCII_STR_NEW 1
+#define HAVE_RB_USASCII_STR_NEW_CSTR 1
+#define HAVE_RB_EXTERNAL_STR_NEW 1
+#define HAVE_RB_EXTERNAL_STR_NEW_CSTR 1
+#define HAVE_RB_EXTERNAL_STR_NEW_WITH_ENC 1
+
+#define HAVE_RB_TO_ENCODING 1
+#define HAVE_RB_TO_ENCODING_INDEX 1
+#define HAVE_RB_ENC_NTH 1
+
+#define HAVE_RB_EENCCOMPATERROR 1
+
+#define HAVE_RB_MWAITREADABLE 1
+#define HAVE_RB_MWAITWRITABLE 1
+
+#define HAVE_RSTRING_LENINT 1
+#define HAVE_TIMET2NUM 1
+
+#define HAVE_RB_LONG2INT 1
+#define HAVE_RB_INTERN3 1
+
+#define HAVE_RB_ITER_BREAK 1
+#define HAVE_RB_SOURCEFILE 1
+#define HAVE_RB_SOURCELINE 1
+#define HAVE_RB_METHOD_BOUNDP 1
+
+/* Enumerable */
+#define HAVE_RB_ENUMERATORIZE 1
+
+/* Exception */
+#define HAVE_RB_EXC_NEW 1
+#define HAVE_RB_EXC_NEW2 1
+#define HAVE_RB_EXC_NEW3 1
+#define HAVE_RB_EXC_RAISE 1
+#define HAVE_RB_SET_ERRINFO 1
+
+/* File */
+#define HAVE_RB_FILE_OPEN 1
+#define HAVE_RB_FILE_OPEN_STR 1
+#define HAVE_FILEPATHVALUE 1
+
+/* Float */
+#define HAVE_RB_FLOAT_NEW 1
+#define HAVE_RB_RFLOAT 1
+#define HAVE_RFLOAT_VALUE 1
+
+/* Globals */
+#define HAVE_RB_DEFAULT_RS 1
+#define HAVE_RB_DEFINE_HOOKED_VARIABLE 1
+#define HAVE_RB_DEFINE_READONLY_VARIABLE 1
+#define HAVE_RB_DEFINE_VARIABLE 1
+#define HAVE_RB_F_GLOBAL_VARIABLES 1
+#define HAVE_RB_GV_GET 1
+#define HAVE_RB_GV_SET 1
+#define HAVE_RB_RS 1
+#define HAVE_RB_OUTPUT_RS 1
+#define HAVE_RB_OUTPUT_FS 1
+#define HAVE_RB_STDERR 1
+#define HAVE_RB_STDIN 1
+#define HAVE_RB_STDOUT 1
+#define HAVE_RB_DEFOUT 1
+
+#define HAVE_RB_LASTLINE_SET 1
+#define HAVE_RB_LASTLINE_GET 1
+
+/* Hash */
+#define HAVE_RB_HASH 1
+#define HAVE_RB_HASH2 1
+#define HAVE_RB_HASH_DUP 1
+#define HAVE_RB_HASH_FREEZE 1
+#define HAVE_RB_HASH_AREF 1
+#define HAVE_RB_HASH_ASET 1
+#define HAVE_RB_HASH_CLEAR 1
+#define HAVE_RB_HASH_DELETE 1
+#define HAVE_RB_HASH_DELETE_IF 1
+#define HAVE_RB_HASH_FETCH 1
+#define HAVE_RB_HASH_FOREACH 1
+#define HAVE_RB_HASH_LOOKUP 1
+#define HAVE_RB_HASH_LOOKUP2 1
+#define HAVE_RB_HASH_NEW 1
+#define HAVE_RB_HASH_SET_IFNONE 1
+#define HAVE_RB_HASH_SIZE 1
+
+/* Integer */
+#define HAVE_RB_INTEGER_PACK 1
+
+/* IO */
+#define HAVE_GET_OPEN_FILE 1
+#define HAVE_RB_IO_ADDSTR 1
+#define HAVE_RB_IO_CHECK_IO 1
+#define HAVE_RB_IO_CHECK_CLOSED 1
+#define HAVE_RB_IO_TAINT_CHECK 1
+#define HAVE_RB_IO_CHECK_READABLE 1
+#define HAVE_RB_IO_CHECK_WRITABLE 1
+#define HAVE_RB_IO_CLOSE 1
+#define HAVE_RB_IO_PRINT 1
+#define HAVE_RB_IO_PRINTF 1
+#define HAVE_RB_IO_PUTS 1
+#define HAVE_RB_IO_WAIT_READABLE 1
+#define HAVE_RB_IO_WAIT_WRITABLE 1
+#define HAVE_RB_IO_WRITE 1
+#define HAVE_RB_IO_BINMODE 1
+
+#define HAVE_RB_THREAD_FD_WRITABLE 1
+#define HAVE_RB_THREAD_WAIT_FD 1
+
+#define HAVE_RB_MUTEX_NEW 1
+#define HAVE_RB_MUTEX_LOCKED_P 1
+#define HAVE_RB_MUTEX_TRYLOCK 1
+#define HAVE_RB_MUTEX_LOCK 1
+#define HAVE_RB_MUTEX_UNLOCK 1
+#define HAVE_RB_MUTEX_SLEEP 1
+#define HAVE_RB_MUTEX_SYNCHRONIZE 1
+
+#define HAVE_RB_FD_FIX_CLOEXEC 1
+#define HAVE_RB_CLOEXEC_OPEN 1
+
+/* Kernel */
+#define HAVE_RB_BLOCK_GIVEN_P 1
+#define HAVE_RB_BLOCK_PROC 1
+#define HAVE_RB_BLOCK_CALL 1
+#define HAVE_RB_ENSURE 1
+#define HAVE_RB_EVAL_STRING 1
+#define HAVE_RB_EXEC_RECURSIVE 1
+#define HAVE_RB_F_SPRINTF 1
+#define HAVE_RB_NEED_BLOCK 1
+#define HAVE_RB_RAISE 1
+#define HAVE_RB_RESCUE 1
+#define HAVE_RB_RESCUE2 1
+#define HAVE_RB_SET_END_PROC 1
+#define HAVE_RB_SYS_FAIL 1
+#define HAVE_RB_SYSERR_FAIL 1
+#define HAVE_RB_MAKE_BACKTRACE 1
+#define HAVE_RB_THROW 1
+#define HAVE_RB_CATCH 1
+#define HAVE_RB_THROW_OBJ 1
+#define HAVE_RB_CATCH_OBJ 1
+#define HAVE_RB_WARN 1
+#define HAVE_RB_YIELD 1
+#define HAVE_RB_YIELD_SPLAT 1
+#define HAVE_RB_YIELD_VALUES 1
+#define HAVE_RB_FUNCALL3 1
+#define HAVE_RB_FUNCALL_WITH_BLOCK 1
+#define HAVE_RB_PROTECT 1
+
+/* GC */
+#define HAVE_RB_GC_REGISTER_ADDRESS 1
+#define HAVE_RB_GC_ENABLE 1
+#define HAVE_RB_GC_DISABLE 1
+#define HAVE_RB_GC 1
+
+/* Marshal */
+#define HAVE_RB_MARSHAL_DUMP 1
+#define HAVE_RB_MARSHAL_LOAD 1
+
+/* Module */
+#define HAVE_RB_ALIAS 1
+#define HAVE_RB_CONST_DEFINED 1
+#define HAVE_RB_CONST_DEFINED_AT 1
+#define HAVE_RB_CONST_GET 1
+#define HAVE_RB_CONST_GET_AT 1
+#define HAVE_RB_CONST_GET_FROM 1
+#define HAVE_RB_CONST_SET 1
+#define HAVE_RB_DEFINE_ALIAS 1
+#define HAVE_RB_DEFINE_CLASS 1
+#define HAVE_RB_DEFINE_CLASS_UNDER 1
+#define HAVE_RB_DEFINE_CLASS_ID_UNDER 1
+#define HAVE_RB_DEFINE_CONST 1
+#define HAVE_RB_DEFINE_GLOBAL_CONST 1
+#define HAVE_RB_DEFINE_GLOBAL_FUNCTION 1
+#define HAVE_RB_DEFINE_METHOD 1
+#define HAVE_RB_DEFINE_MODULE_FUNCTION 1
+#define HAVE_RB_DEFINE_MODULE 1
+#define HAVE_RB_DEFINE_MODULE_UNDER 1
+#define HAVE_RB_DEFINE_PRIVATE_METHOD 1
+#define HAVE_RB_DEFINE_PROTECTED_METHOD 1
+#define HAVE_RB_DEFINE_SINGLETON_METHOD 1
+#define HAVE_RB_MOD_ANCESTORS 1
+#define HAVE_RB_UNDEF 1
+#define HAVE_RB_UNDEF_METHOD 1
+
+/* Numeric */
+#define HAVE_NUM2CHR 1
+#define HAVE_RB_CMPINT 1
+#define HAVE_RB_INT2INUM 1
+#define HAVE_RB_INTEGER 1
+#define HAVE_RB_LL2INUM 1
+#define HAVE_RB_NUM2DBL 1
+#if SIZEOF_INT < SIZEOF_LONG
+#define HAVE_RB_NUM2INT 1
+#define HAVE_RB_NUM2UINT 1
+#endif
+#define HAVE_RB_NUM2LONG 1
+#define HAVE_RB_INT2NUM 1
+#define HAVE_RB_NUM2ULONG 1
+#define HAVE_RB_NUM_COERCE_BIN 1
+#define HAVE_RB_NUM_COERCE_CMP 1
+#define HAVE_RB_NUM_COERCE_RELOP 1
+#define HAVE_RB_ABSINT_SINGLEBIT_P 1
+#define HAVE_RB_NUM_ZERODIV 1
+
+/* Fixnum */
+#if SIZEOF_INT < SIZEOF_LONG
+#define HAVE_RB_FIX2UINT 1
+#define HAVE_RB_FIX2INT 1
+#endif
+
+/* Object */
+#define HAVE_FL_ABLE 1
+#define HAVE_FL_TEST 1
+#define HAVE_OBJ_TAINT 1
+#define HAVE_OBJ_TAINTED 1
+#define HAVE_OBJ_INFECT 1
+#define HAVE_RB_ANY_TO_S 1
+#define HAVE_RB_ATTR_GET 1
+#define HAVE_RB_OBJ_INSTANCE_VARIABLES 1
+#define HAVE_RB_CHECK_ARRAY_TYPE 1
+#define HAVE_RB_CHECK_CONVERT_TYPE 1
+#define HAVE_RB_CHECK_TO_INTEGER 1
+#define HAVE_RB_CHECK_FROZEN 1
+#define HAVE_RB_CHECK_STRING_TYPE 1
+#define HAVE_RB_CLASS_OF 1
+#define HAVE_RB_CONVERT_TYPE 1
+#define HAVE_RB_EQUAL 1
+#define HAVE_RB_CLASS_INHERITED_P 1
+#define HAVE_RB_EXTEND_OBJECT 1
+#define HAVE_RB_INSPECT 1
+#define HAVE_RB_IVAR_DEFINED 1
+#define HAVE_RB_IVAR_GET 1
+#define HAVE_RB_IVAR_SET 1
+#define HAVE_RB_IV_GET 1
+#define HAVE_RB_IV_SET 1
+#define HAVE_RB_OBJ_ALLOC 1
+#define HAVE_RB_OBJ_CALL_INIT 1
+#define HAVE_RB_OBJ_CLASSNAME 1
+#define HAVE_RB_OBJ_DUP 1
+#define HAVE_RB_OBJ_FREEZE 1
+#define HAVE_RB_OBJ_FROZEN_P 1
+#define HAVE_RB_OBJ_ID 1
+#define HAVE_RB_OBJ_INSTANCE_EVAL 1
+#define HAVE_RB_OBJ_IS_INSTANCE_OF 1
+#define HAVE_RB_OBJ_IS_KIND_OF 1
+#define HAVE_RB_OBJ_TAINT 1
+#define HAVE_RB_OBJ_METHOD 1
+#define HAVE_RB_OBJ_METHOD_ARITY 1
+#define HAVE_RB_REQUIRE 1
+#define HAVE_RB_RESPOND_TO 1
+#define HAVE_RB_OBJ_RESPOND_TO 1
+#define HAVE_RB_SPECIAL_CONST_P 1
+#define HAVE_RB_TO_ID 1
+#define HAVE_RB_TO_INT 1
+#define HAVE_RTEST 1
+#define HAVE_TYPE 1
+#define HAVE_RB_TYPE_P 1
+#define HAVE_BUILTIN_TYPE 1
+
+/* Proc */
+#define HAVE_RB_PROC_NEW 1
+#define HAVE_RB_PROC_ARITY 1
+#define HAVE_RB_PROC_CALL 1
+
+/* Range */
+#define HAVE_RB_RANGE_NEW 1
+#define HAVE_RB_RANGE_VALUES 1
+#define HAVE_RB_RANGE_BEG_LEN 1
+
+/* Rational */
+#define HAVE_RB_RATIONAL 1
+#define HAVE_RB_RATIONAL1 1
+#define HAVE_RB_RATIONAL2 1
+#define HAVE_RB_RATIONAL_NEW 1
+#define HAVE_RB_RATIONAL_NEW1 1
+#define HAVE_RB_RATIONAL_NEW2 1
+#define HAVE_RB_RATIONAL_NUM 1
+#define HAVE_RB_RATIONAL_DEN 1
+
+/* Regexp */
+#define HAVE_RB_BACKREF_GET 1
+#define HAVE_RB_REG_MATCH 1
+#define HAVE_RB_REG_NEW 1
+#define HAVE_RB_REG_NTH_MATCH 1
+#define HAVE_RB_REG_OPTIONS 1
+#define HAVE_RB_REG_REGCOMP 1
+
+/* st */
+#define HAVE_RB_ST 1
+
+/* String */
+#define HAVE_RB_CSTR2INUM 1
+#define HAVE_RB_CSTR_TO_INUM 1
+#define HAVE_RB_STR2INUM 1
+#define HAVE_RB_STR_APPEND 1
+#define HAVE_RB_STR_BUF_CAT 1
+#define HAVE_RB_STR_BUF_NEW 1
+#define HAVE_RB_STR_BUF_NEW2 1
+#define HAVE_RB_STR_CAT 1
+#define HAVE_RB_STR_CAT2 1
+#define HAVE_RB_STR_CMP 1
+#define HAVE_RB_STR_DUP 1
+#define HAVE_RB_STR_FLUSH 1
+#define HAVE_RB_STR_FREEZE 1
+#define HAVE_RB_STR_HASH 1
+#define HAVE_RB_STR_UPDATE 1
+#define HAVE_RB_STR_INSPECT 1
+#define HAVE_RB_STR_INTERN 1
+#define HAVE_RB_STR_NEW 1
+#define HAVE_RB_STR_NEW2 1
+#define HAVE_RB_STR_NEW3 1
+#define HAVE_RB_STR_NEW4 1
+#define HAVE_RB_STR_NEW5 1
+#define HAVE_RB_TAINTED_STR_NEW 1
+#define HAVE_RB_TAINTED_STR_NEW2 1
+#define HAVE_RB_STR_PLUS 1
+#define HAVE_RB_STR_TIMES 1
+#define HAVE_RB_STR_RESIZE 1
+#define HAVE_RB_STR_SET_LEN 1
+#define HAVE_RB_STR_SPLIT 1
+#define HAVE_RB_STR_SUBSTR 1
+#define HAVE_RB_STR_TO_STR 1
+#define HAVE_RSTRING_LEN 1
+#define HAVE_RSTRING_PTR 1
+#define HAVE_STRINGVALUE 1
+
+#define HAVE_RB_STR_FREE 1
+#define HAVE_RB_SPRINTF 1
+#define HAVE_RB_LOCALE_STR_NEW 1
+#define HAVE_RB_LOCALE_STR_NEW_CSTR 1
+#define HAVE_RB_STR_CONV_ENC 1
+#define HAVE_RB_STR_CONV_ENC_OPTS 1
+#define HAVE_RB_STR_EXPORT 1
+#define HAVE_RB_STR_EXPORT_LOCALE 1
+#define HAVE_RB_STR_LENGTH 1
+#define HAVE_RB_STR_EQUAL 1
+#define HAVE_RB_STR_SUBSEQ 1
+#define HAVE_RB_VSPRINTF 1
+#define HAVE_RB_STRING 1
+#define HAVE_SAFE_STRING_VALUE 1
+
+/* Struct */
+#define HAVE_RB_STRUCT_AREF 1
+#define HAVE_RB_STRUCT_ASET 1
+#define HAVE_RB_STRUCT_DEFINE 1
+#define HAVE_RB_STRUCT_DEFINE_UNDER 1
+#define HAVE_RB_STRUCT_NEW 1
+#define HAVE_RB_STRUCT_GETMEMBER 1
+#define HAVE_RB_STRUCT_S_MEMBERS 1
+#define HAVE_RB_STRUCT_MEMBERS 1
+#ifdef RUBY_VERSION_IS_2_4
+#define HAVE_RB_STRUCT_SIZE 1
+#endif
+
+/* Symbol */
+#define HAVE_RB_ID2NAME 1
+#define HAVE_RB_ID2STR 1
+#define HAVE_RB_INTERN_STR 1
+#define HAVE_RB_INTERN 1
+#define HAVE_RB_IS_CLASS_ID 1
+#define HAVE_RB_IS_CONST_ID 1
+#define HAVE_RB_IS_INSTANCE_ID 1
+#define HAVE_RB_SYM2STR 1
+
+/* Thread */
+#define HAVE_RB_THREAD_ALONE 1
+#define HAVE_RB_THREAD_CALL_WITHOUT_GVL 1
+#define HAVE_RB_THREAD_CURRENT 1
+#define HAVE_RB_THREAD_LOCAL_AREF 1
+#define HAVE_RB_THREAD_LOCAL_ASET 1
+#define HAVE_RB_THREAD_WAIT_FOR 1
+#define HAVE_RB_THREAD_WAKEUP 1
+#define HAVE_RB_THREAD_CREATE 1
+
+/* Time */
+#define HAVE_RB_TIME_NEW 1
+#define HAVE_RB_TIME_NANO_NEW 1
+#define HAVE_RB_TIME_NUM_NEW 1
+#define HAVE_RB_TIME_INTERVAL 1
+#define HAVE_RB_TIME_TIMEVAL 1
+#define HAVE_RB_TIME_TIMESPEC 1
+#ifdef RUBY_VERSION_IS_2_3
+#define HAVE_RB_TIMESPEC_NOW 1
+#define HAVE_RB_TIME_TIMESPEC_NEW 1
+#endif
+
+/* Util */
+#define HAVE_RB_SCAN_ARGS 1
+
#endif
diff --git a/spec/ruby/optional/capi/ext/st_spec.c b/spec/ruby/optional/capi/ext/st_spec.c
index 0fb5b5dc2d..4e59698d77 100644
--- a/spec/ruby/optional/capi/ext/st_spec.c
+++ b/spec/ruby/optional/capi/ext/st_spec.c
@@ -4,12 +4,15 @@
#include <string.h>
#include <stdarg.h>
+#ifdef HAVE_RB_ST
#include <ruby/st.h>
+#endif
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef HAVE_RB_ST
#if SIZEOF_LONG == SIZEOF_VOIDP
# define ST2NUM(x) ULONG2NUM(x)
@@ -69,13 +72,20 @@ VALUE st_spec_st_lookup(VALUE self) {
#endif
}
+#endif
+
void Init_st_spec(void) {
- VALUE cls = rb_define_class("CApiStSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiStSpecs", rb_cObject);
+
+#ifdef HAVE_RB_ST
rb_define_method(cls, "st_init_numtable", st_spec_st_init_numtable, 0);
rb_define_method(cls, "st_init_numtable_with_size", st_spec_st_init_numtable_with_size, 0);
rb_define_method(cls, "st_insert", st_spec_st_insert, 0);
rb_define_method(cls, "st_foreach", st_spec_st_foreach, 0);
rb_define_method(cls, "st_lookup", st_spec_st_lookup, 0);
+#endif
+
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/string_spec.c b/spec/ruby/optional/capi/ext/string_spec.c
index a44e437bba..929d69f9e5 100644
--- a/spec/ruby/optional/capi/ext/string_spec.c
+++ b/spec/ruby/optional/capi/ext/string_spec.c
@@ -4,39 +4,42 @@
#include <string.h>
#include <stdarg.h>
+#ifdef HAVE_RUBY_ENCODING_H
#include "ruby/encoding.h"
+#endif
#ifdef __cplusplus
extern "C" {
#endif
-/* Make sure the RSTRING_PTR and the bytes are in native memory.
- * On TruffleRuby RSTRING_PTR and the bytes remain in managed memory
- * until they must be written to native memory.
- * In some specs we want to test using the native memory. */
-#ifndef NATIVE_RSTRING_PTR
-#define NATIVE_RSTRING_PTR(str) RSTRING_PTR(str)
-#endif
-
+#ifdef HAVE_RB_CSTR2INUM
VALUE string_spec_rb_cstr2inum(VALUE self, VALUE str, VALUE inum) {
int num = FIX2INT(inum);
return rb_cstr2inum(RSTRING_PTR(str), num);
}
+#endif
+#ifdef HAVE_RB_CSTR_TO_INUM
static VALUE string_spec_rb_cstr_to_inum(VALUE self, VALUE str, VALUE inum, VALUE badcheck) {
int num = FIX2INT(inum);
return rb_cstr_to_inum(RSTRING_PTR(str), num, RTEST(badcheck));
}
+#endif
+#ifdef HAVE_RB_STR2INUM
VALUE string_spec_rb_str2inum(VALUE self, VALUE str, VALUE inum) {
int num = FIX2INT(inum);
return rb_str2inum(str, num);
}
+#endif
+#ifdef HAVE_RB_STR_APPEND
VALUE string_spec_rb_str_append(VALUE self, VALUE str, VALUE str2) {
return rb_str_append(str, str2);
}
+#endif
+#ifdef HAVE_RB_STR_SET_LEN
VALUE string_spec_rb_str_set_len(VALUE self, VALUE str, VALUE len) {
rb_str_set_len(str, NUM2LONG(len));
@@ -48,7 +51,9 @@ VALUE string_spec_rb_str_set_len_RSTRING_LEN(VALUE self, VALUE str, VALUE len) {
return INT2FIX(RSTRING_LEN(str));
}
+#endif
+#ifdef HAVE_RB_STR_BUF_NEW
VALUE string_spec_rb_str_buf_new(VALUE self, VALUE len, VALUE str) {
VALUE buf;
@@ -60,33 +65,41 @@ VALUE string_spec_rb_str_buf_new(VALUE self, VALUE len, VALUE str) {
return buf;
}
+#endif
-VALUE string_spec_rb_str_capacity(VALUE self, VALUE str) {
- return SIZET2NUM(rb_str_capacity(str));
-}
-
+#ifdef HAVE_RB_STR_BUF_NEW2
VALUE string_spec_rb_str_buf_new2(VALUE self) {
return rb_str_buf_new2("hello\0invisible");
}
+#endif
+#ifdef HAVE_RB_STR_BUF_CAT
VALUE string_spec_rb_str_buf_cat(VALUE self, VALUE str) {
const char *question_mark = "?";
rb_str_buf_cat(str, question_mark, strlen(question_mark));
return str;
}
+#endif
+#ifdef HAVE_RB_STR_CAT
VALUE string_spec_rb_str_cat(VALUE self, VALUE str) {
return rb_str_cat(str, "?", 1);
}
+#endif
+#ifdef HAVE_RB_STR_CAT2
VALUE string_spec_rb_str_cat2(VALUE self, VALUE str) {
return rb_str_cat2(str, "?");
}
+#endif
+#ifdef HAVE_RB_STR_CMP
VALUE string_spec_rb_str_cmp(VALUE self, VALUE str1, VALUE str2) {
return INT2NUM(rb_str_cmp(str1, str2));
}
+#endif
+#ifdef HAVE_RB_STR_CONV_ENC
VALUE string_spec_rb_str_conv_enc(VALUE self, VALUE str, VALUE from, VALUE to) {
rb_encoding* from_enc;
rb_encoding* to_enc;
@@ -101,7 +114,9 @@ VALUE string_spec_rb_str_conv_enc(VALUE self, VALUE str, VALUE from, VALUE to) {
return rb_str_conv_enc(str, from_enc, to_enc);
}
+#endif
+#ifdef HAVE_RB_STR_CONV_ENC_OPTS
VALUE string_spec_rb_str_conv_enc_opts(VALUE self, VALUE str, VALUE from, VALUE to,
VALUE ecflags, VALUE ecopts)
{
@@ -118,51 +133,61 @@ VALUE string_spec_rb_str_conv_enc_opts(VALUE self, VALUE str, VALUE from, VALUE
return rb_str_conv_enc_opts(str, from_enc, to_enc, FIX2INT(ecflags), ecopts);
}
+#endif
-VALUE string_spec_rb_str_drop_bytes(VALUE self, VALUE str, VALUE len) {
- return rb_str_drop_bytes(str, NUM2LONG(len));
-}
-
+#ifdef HAVE_RB_STR_EXPORT
VALUE string_spec_rb_str_export(VALUE self, VALUE str) {
return rb_str_export(str);
}
+#endif
+#ifdef HAVE_RB_STR_EXPORT_LOCALE
VALUE string_spec_rb_str_export_locale(VALUE self, VALUE str) {
return rb_str_export_locale(str);
}
+#endif
+#ifdef HAVE_RB_STR_DUP
VALUE string_spec_rb_str_dup(VALUE self, VALUE str) {
return rb_str_dup(str);
}
+#endif
+#ifdef HAVE_RB_STR_FREEZE
VALUE string_spec_rb_str_freeze(VALUE self, VALUE str) {
return rb_str_freeze(str);
}
+#endif
+#ifdef HAVE_RB_STR_INSPECT
VALUE string_spec_rb_str_inspect(VALUE self, VALUE str) {
return rb_str_inspect(str);
}
+#endif
+#ifdef HAVE_RB_STR_INTERN
VALUE string_spec_rb_str_intern(VALUE self, VALUE str) {
return rb_str_intern(str);
}
+#endif
+#ifdef HAVE_RB_STR_LENGTH
VALUE string_spec_rb_str_length(VALUE self, VALUE str) {
return rb_str_length(str);
}
+#endif
+#ifdef HAVE_RB_STR_NEW
VALUE string_spec_rb_str_new(VALUE self, VALUE str, VALUE len) {
return rb_str_new(RSTRING_PTR(str), FIX2INT(len));
}
-VALUE string_spec_rb_str_new_native(VALUE self, VALUE str, VALUE len) {
- return rb_str_new(NATIVE_RSTRING_PTR(str), FIX2INT(len));
-}
-
VALUE string_spec_rb_str_new_offset(VALUE self, VALUE str, VALUE offset, VALUE len) {
return rb_str_new(RSTRING_PTR(str) + FIX2INT(offset), FIX2INT(len));
}
+#endif
+#ifdef HAVE_RB_STR_NEW2
VALUE string_spec_rb_str_new2(VALUE self, VALUE str) {
if(NIL_P(str)) {
return rb_str_new2("");
@@ -170,15 +195,15 @@ VALUE string_spec_rb_str_new2(VALUE self, VALUE str) {
return rb_str_new2(RSTRING_PTR(str));
}
}
+#endif
+#ifdef HAVE_RB_STR_ENCODE
VALUE string_spec_rb_str_encode(VALUE self, VALUE str, VALUE enc, VALUE flags, VALUE opts) {
return rb_str_encode(str, enc, FIX2INT(flags), opts);
}
+#endif
-VALUE string_spec_rb_str_export_to_enc(VALUE self, VALUE str, VALUE enc) {
- return rb_str_export_to_enc(str, rb_to_encoding(enc));
-}
-
+#ifdef HAVE_RB_STR_NEW_CSTR
VALUE string_spec_rb_str_new_cstr(VALUE self, VALUE str) {
if(NIL_P(str)) {
return rb_str_new_cstr("");
@@ -186,60 +211,81 @@ VALUE string_spec_rb_str_new_cstr(VALUE self, VALUE str) {
return rb_str_new_cstr(RSTRING_PTR(str));
}
}
+#endif
+#ifdef HAVE_RB_EXTERNAL_STR_NEW
VALUE string_spec_rb_external_str_new(VALUE self, VALUE str) {
return rb_external_str_new(RSTRING_PTR(str), RSTRING_LEN(str));
}
+#endif
+#ifdef HAVE_RB_EXTERNAL_STR_NEW_CSTR
VALUE string_spec_rb_external_str_new_cstr(VALUE self, VALUE str) {
return rb_external_str_new_cstr(RSTRING_PTR(str));
}
+#endif
+#ifdef HAVE_RB_EXTERNAL_STR_NEW_WITH_ENC
VALUE string_spec_rb_external_str_new_with_enc(VALUE self, VALUE str, VALUE len, VALUE encoding) {
return rb_external_str_new_with_enc(RSTRING_PTR(str), FIX2LONG(len), rb_to_encoding(encoding));
}
+#endif
+#ifdef HAVE_RB_LOCALE_STR_NEW
VALUE string_spec_rb_locale_str_new(VALUE self, VALUE str, VALUE len) {
return rb_locale_str_new(RSTRING_PTR(str), FIX2INT(len));
}
+#endif
+#ifdef HAVE_RB_LOCALE_STR_NEW_CSTR
VALUE string_spec_rb_locale_str_new_cstr(VALUE self, VALUE str) {
return rb_locale_str_new_cstr(RSTRING_PTR(str));
}
+#endif
+#ifdef HAVE_RB_STR_NEW3
VALUE string_spec_rb_str_new3(VALUE self, VALUE str) {
return rb_str_new3(str);
}
+#endif
+#ifdef HAVE_RB_STR_NEW4
VALUE string_spec_rb_str_new4(VALUE self, VALUE str) {
return rb_str_new4(str);
}
+#endif
+#ifdef HAVE_RB_STR_NEW5
VALUE string_spec_rb_str_new5(VALUE self, VALUE str, VALUE ptr, VALUE len) {
return rb_str_new5(str, RSTRING_PTR(ptr), FIX2INT(len));
}
+#endif
+#ifdef HAVE_RB_TAINTED_STR_NEW
VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) {
return rb_tainted_str_new(RSTRING_PTR(str), FIX2INT(len));
}
+#endif
+#ifdef HAVE_RB_TAINTED_STR_NEW2
VALUE string_spec_rb_tainted_str_new2(VALUE self, VALUE str) {
return rb_tainted_str_new2(RSTRING_PTR(str));
}
+#endif
+#ifdef HAVE_RB_STR_PLUS
VALUE string_spec_rb_str_plus(VALUE self, VALUE str1, VALUE str2) {
return rb_str_plus(str1, str2);
}
+#endif
+#ifdef HAVE_RB_STR_TIMES
VALUE string_spec_rb_str_times(VALUE self, VALUE str, VALUE times) {
return rb_str_times(str, times);
}
+#endif
-VALUE string_spec_rb_str_modify_expand(VALUE self, VALUE str, VALUE size) {
- rb_str_modify_expand(str, FIX2LONG(size));
- return str;
-}
-
+#ifdef HAVE_RB_STR_RESIZE
VALUE string_spec_rb_str_resize(VALUE self, VALUE str, VALUE size) {
return rb_str_resize(str, FIX2INT(size));
}
@@ -248,31 +294,45 @@ VALUE string_spec_rb_str_resize_RSTRING_LEN(VALUE self, VALUE str, VALUE size) {
VALUE modified = rb_str_resize(str, FIX2INT(size));
return INT2FIX(RSTRING_LEN(modified));
}
+#endif
+#ifdef HAVE_RB_STR_SPLIT
VALUE string_spec_rb_str_split(VALUE self, VALUE str) {
return rb_str_split(str, ",");
}
+#endif
+#ifdef HAVE_RB_STR_SUBSEQ
VALUE string_spec_rb_str_subseq(VALUE self, VALUE str, VALUE beg, VALUE len) {
return rb_str_subseq(str, FIX2INT(beg), FIX2INT(len));
}
+#endif
+#ifdef HAVE_RB_STR_SUBSTR
VALUE string_spec_rb_str_substr(VALUE self, VALUE str, VALUE beg, VALUE len) {
return rb_str_substr(str, FIX2INT(beg), FIX2INT(len));
}
+#endif
+#ifdef HAVE_RB_STR_TO_STR
VALUE string_spec_rb_str_to_str(VALUE self, VALUE arg) {
return rb_str_to_str(arg);
}
+#endif
+#ifdef HAVE_RSTRING_LEN
VALUE string_spec_RSTRING_LEN(VALUE self, VALUE str) {
return INT2FIX(RSTRING_LEN(str));
}
+#endif
+#ifdef HAVE_RSTRING_LENINT
VALUE string_spec_RSTRING_LENINT(VALUE self, VALUE str) {
return INT2FIX(RSTRING_LENINT(str));
}
+#endif
+#ifdef HAVE_RSTRING_PTR
VALUE string_spec_RSTRING_PTR_iterate(VALUE self, VALUE str) {
int i;
char* ptr;
@@ -298,11 +358,6 @@ VALUE string_spec_RSTRING_PTR_assign(VALUE self, VALUE str, VALUE chr) {
return Qnil;
}
-VALUE string_spec_RSTRING_PTR_set(VALUE self, VALUE str, VALUE i, VALUE chr) {
- RSTRING_PTR(str)[FIX2INT(i)] = (char) FIX2INT(chr);
- return str;
-}
-
VALUE string_spec_RSTRING_PTR_after_funcall(VALUE self, VALUE str, VALUE cb) {
/* Silence gcc 4.3.2 warning about computed value not used */
if(RSTRING_PTR(str)) { /* force it out */
@@ -311,64 +366,57 @@ VALUE string_spec_RSTRING_PTR_after_funcall(VALUE self, VALUE str, VALUE cb) {
return rb_str_new2(RSTRING_PTR(str));
}
+#endif
-VALUE string_spec_RSTRING_PTR_after_yield(VALUE self, VALUE str) {
- char* ptr = NATIVE_RSTRING_PTR(str);
- long len = RSTRING_LEN(str);
- VALUE from_rstring_ptr;
-
- ptr[0] = '1';
- rb_yield(str);
- ptr[2] = '2';
-
- from_rstring_ptr = rb_str_new(ptr, len);
- return from_rstring_ptr;
-}
-
+#ifdef HAVE_STRINGVALUE
VALUE string_spec_StringValue(VALUE self, VALUE str) {
return StringValue(str);
}
+#endif
+#ifdef HAVE_SAFE_STRING_VALUE
static VALUE string_spec_SafeStringValue(VALUE self, VALUE str) {
SafeStringValue(str);
return str;
}
+#endif
+#ifdef HAVE_RB_STR_HASH
static VALUE string_spec_rb_str_hash(VALUE self, VALUE str) {
st_index_t val = rb_str_hash(str);
#if SIZEOF_LONG == SIZEOF_VOIDP || SIZEOF_LONG_LONG == SIZEOF_VOIDP
return LONG2FIX((long)val);
#else
-#error unsupported platform
+# error unsupported platform
#endif
}
+#endif
+#ifdef HAVE_RB_STR_UPDATE
static VALUE string_spec_rb_str_update(VALUE self, VALUE str, VALUE beg, VALUE end, VALUE replacement) {
rb_str_update(str, FIX2LONG(beg), FIX2LONG(end), replacement);
return str;
}
+#endif
+#ifdef HAVE_RB_STR_FREE
static VALUE string_spec_rb_str_free(VALUE self, VALUE str) {
rb_str_free(str);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_SPRINTF
static VALUE string_spec_rb_sprintf1(VALUE self, VALUE str, VALUE repl) {
return rb_sprintf(RSTRING_PTR(str), RSTRING_PTR(repl));
}
static VALUE string_spec_rb_sprintf2(VALUE self, VALUE str, VALUE repl1, VALUE repl2) {
return rb_sprintf(RSTRING_PTR(str), RSTRING_PTR(repl1), RSTRING_PTR(repl2));
}
+#endif
-static VALUE string_spec_rb_sprintf3(VALUE self, VALUE str) {
- return rb_sprintf("Result: %"PRIsVALUE".", str);
-}
-
-static VALUE string_spec_rb_sprintf4(VALUE self, VALUE str) {
- return rb_sprintf("Result: %+"PRIsVALUE".", str);
-}
-
+#ifdef HAVE_RB_VSPRINTF
static VALUE string_spec_rb_vsprintf_worker(char* fmt, ...) {
va_list varargs;
VALUE str;
@@ -384,122 +432,265 @@ static VALUE string_spec_rb_vsprintf(VALUE self, VALUE fmt, VALUE str, VALUE i,
return string_spec_rb_vsprintf_worker(RSTRING_PTR(fmt), RSTRING_PTR(str),
FIX2INT(i), RFLOAT_VALUE(f));
}
+#endif
+#ifdef HAVE_RB_STR_EQUAL
VALUE string_spec_rb_str_equal(VALUE self, VALUE str1, VALUE str2) {
return rb_str_equal(str1, str2);
}
+#endif
+#ifdef HAVE_RB_USASCII_STR_NEW
static VALUE string_spec_rb_usascii_str_new(VALUE self, VALUE str, VALUE len) {
return rb_usascii_str_new(RSTRING_PTR(str), NUM2INT(len));
}
+#endif
+#ifdef HAVE_RB_USASCII_STR_NEW_CSTR
static VALUE string_spec_rb_usascii_str_new_cstr(VALUE self, VALUE str) {
return rb_usascii_str_new_cstr(RSTRING_PTR(str));
}
+#endif
+#ifdef HAVE_RB_STRING
static VALUE string_spec_rb_String(VALUE self, VALUE val) {
return rb_String(val);
}
-
-static VALUE string_spec_rb_string_value_cstr(VALUE self, VALUE str) {
- char *c_str = rb_string_value_cstr(&str);
- return c_str ? Qtrue : Qfalse;
-}
-
-static VALUE string_spec_rb_str_modify(VALUE self, VALUE str) {
- rb_str_modify(str);
- return str;
-}
-
-static VALUE string_spec_rb_utf8_str_new_static(VALUE self) {
- return rb_utf8_str_new_static("nokogiri", 8);
-}
-
-static VALUE string_spec_rb_utf8_str_new(VALUE self) {
- return rb_utf8_str_new("nokogiri", 8);
-}
-
-static VALUE string_spec_rb_utf8_str_new_cstr(VALUE self) {
- return rb_utf8_str_new_cstr("nokogiri");
-}
+#endif
void Init_string_spec(void) {
- VALUE cls = rb_define_class("CApiStringSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiStringSpecs", rb_cObject);
+
+#ifdef HAVE_RB_CSTR2INUM
rb_define_method(cls, "rb_cstr2inum", string_spec_rb_cstr2inum, 2);
+#endif
+
+#ifdef HAVE_RB_CSTR_TO_INUM
rb_define_method(cls, "rb_cstr_to_inum", string_spec_rb_cstr_to_inum, 3);
+#endif
+
+#ifdef HAVE_RB_STR2INUM
rb_define_method(cls, "rb_str2inum", string_spec_rb_str2inum, 2);
+#endif
+
+#ifdef HAVE_RB_STR_APPEND
rb_define_method(cls, "rb_str_append", string_spec_rb_str_append, 2);
+#endif
+
+#ifdef HAVE_RB_STR_BUF_NEW
rb_define_method(cls, "rb_str_buf_new", string_spec_rb_str_buf_new, 2);
- rb_define_method(cls, "rb_str_capacity", string_spec_rb_str_capacity, 1);
+#endif
+
+#ifdef HAVE_RB_STR_BUF_NEW2
rb_define_method(cls, "rb_str_buf_new2", string_spec_rb_str_buf_new2, 0);
+#endif
+
+#ifdef HAVE_RB_STR_BUF_CAT
rb_define_method(cls, "rb_str_buf_cat", string_spec_rb_str_buf_cat, 1);
+#endif
+
+#ifdef HAVE_RB_STR_CAT
rb_define_method(cls, "rb_str_cat", string_spec_rb_str_cat, 1);
+#endif
+
+#ifdef HAVE_RB_STR_CAT2
rb_define_method(cls, "rb_str_cat2", string_spec_rb_str_cat2, 1);
+#endif
+
+#ifdef HAVE_RB_STR_CMP
rb_define_method(cls, "rb_str_cmp", string_spec_rb_str_cmp, 2);
+#endif
+
+#ifdef HAVE_RB_STR_CONV_ENC
rb_define_method(cls, "rb_str_conv_enc", string_spec_rb_str_conv_enc, 3);
+#endif
+
+#ifdef HAVE_RB_STR_CONV_ENC_OPTS
rb_define_method(cls, "rb_str_conv_enc_opts", string_spec_rb_str_conv_enc_opts, 5);
- rb_define_method(cls, "rb_str_drop_bytes", string_spec_rb_str_drop_bytes, 2);
+#endif
+
+#ifdef HAVE_RB_STR_EXPORT
rb_define_method(cls, "rb_str_export", string_spec_rb_str_export, 1);
+#endif
+
+#ifdef HAVE_RB_STR_EXPORT_LOCALE
rb_define_method(cls, "rb_str_export_locale", string_spec_rb_str_export_locale, 1);
+#endif
+
+#ifdef HAVE_RB_STR_DUP
rb_define_method(cls, "rb_str_dup", string_spec_rb_str_dup, 1);
+#endif
+
+#ifdef HAVE_RB_STR_FREEZE
rb_define_method(cls, "rb_str_freeze", string_spec_rb_str_freeze, 1);
+#endif
+
+#ifdef HAVE_RB_STR_INSPECT
rb_define_method(cls, "rb_str_inspect", string_spec_rb_str_inspect, 1);
+#endif
+
+#ifdef HAVE_RB_STR_INTERN
rb_define_method(cls, "rb_str_intern", string_spec_rb_str_intern, 1);
+#endif
+
+#ifdef HAVE_RB_STR_LENGTH
rb_define_method(cls, "rb_str_length", string_spec_rb_str_length, 1);
+#endif
+
+#ifdef HAVE_RB_STR_NEW
rb_define_method(cls, "rb_str_new", string_spec_rb_str_new, 2);
- rb_define_method(cls, "rb_str_new_native", string_spec_rb_str_new_native, 2);
rb_define_method(cls, "rb_str_new_offset", string_spec_rb_str_new_offset, 3);
+#endif
+
+#ifdef HAVE_RB_STR_NEW2
rb_define_method(cls, "rb_str_new2", string_spec_rb_str_new2, 1);
+#endif
+
+#ifdef HAVE_RB_STR_ENCODE
rb_define_method(cls, "rb_str_encode", string_spec_rb_str_encode, 4);
- rb_define_method(cls, "rb_str_export_to_enc", string_spec_rb_str_export_to_enc, 2);
+#endif
+
+#ifdef HAVE_RB_STR_NEW_CSTR
rb_define_method(cls, "rb_str_new_cstr", string_spec_rb_str_new_cstr, 1);
+#endif
+
+#ifdef HAVE_RB_EXTERNAL_STR_NEW
rb_define_method(cls, "rb_external_str_new", string_spec_rb_external_str_new, 1);
- rb_define_method(cls, "rb_external_str_new_cstr", string_spec_rb_external_str_new_cstr, 1);
+#endif
+
+#ifdef HAVE_RB_EXTERNAL_STR_NEW_CSTR
+ rb_define_method(cls, "rb_external_str_new_cstr",
+ string_spec_rb_external_str_new_cstr, 1);
+#endif
+
+#ifdef HAVE_RB_EXTERNAL_STR_NEW_WITH_ENC
rb_define_method(cls, "rb_external_str_new_with_enc", string_spec_rb_external_str_new_with_enc, 3);
+#endif
+
+#ifdef HAVE_RB_LOCALE_STR_NEW
rb_define_method(cls, "rb_locale_str_new", string_spec_rb_locale_str_new, 2);
+#endif
+
+#ifdef HAVE_RB_LOCALE_STR_NEW_CSTR
rb_define_method(cls, "rb_locale_str_new_cstr", string_spec_rb_locale_str_new_cstr, 1);
+#endif
+
+#ifdef HAVE_RB_STR_NEW3
rb_define_method(cls, "rb_str_new3", string_spec_rb_str_new3, 1);
+#endif
+
+#ifdef HAVE_RB_STR_NEW4
rb_define_method(cls, "rb_str_new4", string_spec_rb_str_new4, 1);
+#endif
+
+#ifdef HAVE_RB_STR_NEW5
rb_define_method(cls, "rb_str_new5", string_spec_rb_str_new5, 3);
+#endif
+
+#ifdef HAVE_RB_TAINTED_STR_NEW
rb_define_method(cls, "rb_tainted_str_new", string_spec_rb_tainted_str_new, 2);
+#endif
+
+#ifdef HAVE_RB_TAINTED_STR_NEW2
rb_define_method(cls, "rb_tainted_str_new2", string_spec_rb_tainted_str_new2, 1);
+#endif
+
+#ifdef HAVE_RB_STR_PLUS
rb_define_method(cls, "rb_str_plus", string_spec_rb_str_plus, 2);
+#endif
+
+#ifdef HAVE_RB_STR_TIMES
rb_define_method(cls, "rb_str_times", string_spec_rb_str_times, 2);
- rb_define_method(cls, "rb_str_modify_expand", string_spec_rb_str_modify_expand, 2);
+#endif
+
+#ifdef HAVE_RB_STR_RESIZE
rb_define_method(cls, "rb_str_resize", string_spec_rb_str_resize, 2);
- rb_define_method(cls, "rb_str_resize_RSTRING_LEN", string_spec_rb_str_resize_RSTRING_LEN, 2);
+ rb_define_method(cls, "rb_str_resize_RSTRING_LEN",
+ string_spec_rb_str_resize_RSTRING_LEN, 2);
+#endif
+
+#ifdef HAVE_RB_STR_SET_LEN
rb_define_method(cls, "rb_str_set_len", string_spec_rb_str_set_len, 2);
- rb_define_method(cls, "rb_str_set_len_RSTRING_LEN", string_spec_rb_str_set_len_RSTRING_LEN, 2);
+ rb_define_method(cls, "rb_str_set_len_RSTRING_LEN",
+ string_spec_rb_str_set_len_RSTRING_LEN, 2);
+#endif
+
+#ifdef HAVE_RB_STR_SPLIT
rb_define_method(cls, "rb_str_split", string_spec_rb_str_split, 1);
+#endif
+
+#ifdef HAVE_RB_STR_SUBSEQ
rb_define_method(cls, "rb_str_subseq", string_spec_rb_str_subseq, 3);
+#endif
+
+#ifdef HAVE_RB_STR_SUBSTR
rb_define_method(cls, "rb_str_substr", string_spec_rb_str_substr, 3);
+#endif
+
+#ifdef HAVE_RB_STR_TO_STR
rb_define_method(cls, "rb_str_to_str", string_spec_rb_str_to_str, 1);
+#endif
+
+#ifdef HAVE_RSTRING_LEN
rb_define_method(cls, "RSTRING_LEN", string_spec_RSTRING_LEN, 1);
+#endif
+
+#ifdef HAVE_RSTRING_LENINT
rb_define_method(cls, "RSTRING_LENINT", string_spec_RSTRING_LENINT, 1);
+#endif
+
+#ifdef HAVE_RSTRING_PTR
rb_define_method(cls, "RSTRING_PTR_iterate", string_spec_RSTRING_PTR_iterate, 1);
rb_define_method(cls, "RSTRING_PTR_assign", string_spec_RSTRING_PTR_assign, 2);
- rb_define_method(cls, "RSTRING_PTR_set", string_spec_RSTRING_PTR_set, 3);
- rb_define_method(cls, "RSTRING_PTR_after_funcall", string_spec_RSTRING_PTR_after_funcall, 2);
- rb_define_method(cls, "RSTRING_PTR_after_yield", string_spec_RSTRING_PTR_after_yield, 1);
+ rb_define_method(cls, "RSTRING_PTR_after_funcall",
+ string_spec_RSTRING_PTR_after_funcall, 2);
+#endif
+
+#ifdef HAVE_STRINGVALUE
rb_define_method(cls, "StringValue", string_spec_StringValue, 1);
+#endif
+
+#ifdef HAVE_SAFE_STRING_VALUE
rb_define_method(cls, "SafeStringValue", string_spec_SafeStringValue, 1);
+#endif
+
+#ifdef HAVE_RB_STR_HASH
rb_define_method(cls, "rb_str_hash", string_spec_rb_str_hash, 1);
+#endif
+
+#ifdef HAVE_RB_STR_UPDATE
rb_define_method(cls, "rb_str_update", string_spec_rb_str_update, 4);
+#endif
+
+#ifdef HAVE_RB_STR_FREE
rb_define_method(cls, "rb_str_free", string_spec_rb_str_free, 1);
+#endif
+
+#ifdef HAVE_RB_SPRINTF
rb_define_method(cls, "rb_sprintf1", string_spec_rb_sprintf1, 2);
rb_define_method(cls, "rb_sprintf2", string_spec_rb_sprintf2, 3);
- rb_define_method(cls, "rb_sprintf3", string_spec_rb_sprintf3, 1);
- rb_define_method(cls, "rb_sprintf4", string_spec_rb_sprintf4, 1);
+#endif
+
+#ifdef HAVE_RB_VSPRINTF
rb_define_method(cls, "rb_vsprintf", string_spec_rb_vsprintf, 4);
+#endif
+
+#ifdef HAVE_RB_STR_EQUAL
rb_define_method(cls, "rb_str_equal", string_spec_rb_str_equal, 2);
+#endif
+
+#ifdef HAVE_RB_USASCII_STR_NEW
rb_define_method(cls, "rb_usascii_str_new", string_spec_rb_usascii_str_new, 2);
+#endif
+
+#ifdef HAVE_RB_USASCII_STR_NEW_CSTR
rb_define_method(cls, "rb_usascii_str_new_cstr", string_spec_rb_usascii_str_new_cstr, 1);
+#endif
+
+#ifdef HAVE_RB_STRING
rb_define_method(cls, "rb_String", string_spec_rb_String, 1);
- rb_define_method(cls, "rb_string_value_cstr", string_spec_rb_string_value_cstr, 1);
- rb_define_method(cls, "rb_str_modify", string_spec_rb_str_modify, 1);
- rb_define_method(cls, "rb_utf8_str_new_static", string_spec_rb_utf8_str_new_static, 0);
- rb_define_method(cls, "rb_utf8_str_new", string_spec_rb_utf8_str_new, 0);
- rb_define_method(cls, "rb_utf8_str_new_cstr", string_spec_rb_utf8_str_new_cstr, 0);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/struct_spec.c b/spec/ruby/optional/capi/ext/struct_spec.c
index b9c3b902bf..8f373d9f48 100644
--- a/spec/ruby/optional/capi/ext/struct_spec.c
+++ b/spec/ruby/optional/capi/ext/struct_spec.c
@@ -7,28 +7,39 @@
extern "C" {
#endif
+#ifdef HAVE_RB_STRUCT_AREF
static VALUE struct_spec_rb_struct_aref(VALUE self, VALUE st, VALUE key) {
return rb_struct_aref(st, key);
}
+#endif
+#ifdef HAVE_RB_STRUCT_GETMEMBER
static VALUE struct_spec_rb_struct_getmember(VALUE self, VALUE st, VALUE key) {
return rb_struct_getmember(st, SYM2ID(key));
}
+#endif
+#ifdef HAVE_RB_STRUCT_S_MEMBERS
static VALUE struct_spec_rb_struct_s_members(VALUE self, VALUE klass)
{
return rb_ary_dup(rb_struct_s_members(klass));
}
+#endif
+#ifdef HAVE_RB_STRUCT_MEMBERS
static VALUE struct_spec_rb_struct_members(VALUE self, VALUE st)
{
return rb_ary_dup(rb_struct_members(st));
}
+#endif
+#ifdef HAVE_RB_STRUCT_ASET
static VALUE struct_spec_rb_struct_aset(VALUE self, VALUE st, VALUE key, VALUE value) {
return rb_struct_aset(st, key, value);
}
+#endif
+#ifdef HAVE_RB_STRUCT_DEFINE
/* Only allow setting three attributes, should be sufficient for testing. */
static VALUE struct_spec_struct_define(VALUE self, VALUE name,
VALUE attr1, VALUE attr2, VALUE attr3) {
@@ -42,7 +53,9 @@ static VALUE struct_spec_struct_define(VALUE self, VALUE name,
return rb_struct_define(nm, a1, a2, a3, NULL);
}
+#endif
+#ifdef HAVE_RB_STRUCT_DEFINE_UNDER
/* Only allow setting three attributes, should be sufficient for testing. */
static VALUE struct_spec_struct_define_under(VALUE self, VALUE outer,
VALUE name, VALUE attr1, VALUE attr2, VALUE attr3) {
@@ -54,15 +67,18 @@ static VALUE struct_spec_struct_define_under(VALUE self, VALUE outer,
return rb_struct_define_under(outer, nm, a1, a2, a3, NULL);
}
+#endif
+#ifdef HAVE_RB_STRUCT_NEW
static VALUE struct_spec_rb_struct_new(VALUE self, VALUE klass,
VALUE a, VALUE b, VALUE c)
{
return rb_struct_new(klass, a, b, c);
}
+#endif
-#ifdef RUBY_VERSION_IS_2_4
+#ifdef HAVE_RB_STRUCT_SIZE
static VALUE struct_spec_rb_struct_size(VALUE self, VALUE st)
{
return rb_struct_size(st);
@@ -70,16 +86,42 @@ static VALUE struct_spec_rb_struct_size(VALUE self, VALUE st)
#endif
void Init_struct_spec(void) {
- VALUE cls = rb_define_class("CApiStructSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiStructSpecs", rb_cObject);
+
+#ifdef HAVE_RB_STRUCT_AREF
rb_define_method(cls, "rb_struct_aref", struct_spec_rb_struct_aref, 2);
+#endif
+
+#ifdef HAVE_RB_STRUCT_GETMEMBER
rb_define_method(cls, "rb_struct_getmember", struct_spec_rb_struct_getmember, 2);
+#endif
+
+#ifdef HAVE_RB_STRUCT_S_MEMBERS
rb_define_method(cls, "rb_struct_s_members", struct_spec_rb_struct_s_members, 1);
+#endif
+
+#ifdef HAVE_RB_STRUCT_MEMBERS
rb_define_method(cls, "rb_struct_members", struct_spec_rb_struct_members, 1);
+#endif
+
+#ifdef HAVE_RB_STRUCT_ASET
rb_define_method(cls, "rb_struct_aset", struct_spec_rb_struct_aset, 3);
+#endif
+
+#ifdef HAVE_RB_STRUCT_DEFINE
rb_define_method(cls, "rb_struct_define", struct_spec_struct_define, 4);
+#endif
+
+#ifdef HAVE_RB_STRUCT_DEFINE_UNDER
rb_define_method(cls, "rb_struct_define_under", struct_spec_struct_define_under, 5);
+#endif
+
+#ifdef HAVE_RB_STRUCT_NEW
rb_define_method(cls, "rb_struct_new", struct_spec_rb_struct_new, 4);
-#ifdef RUBY_VERSION_IS_2_4
+#endif
+
+#ifdef HAVE_RB_STRUCT_SIZE
rb_define_method(cls, "rb_struct_size", struct_spec_rb_struct_size, 1);
#endif
}
diff --git a/spec/ruby/optional/capi/ext/symbol_spec.c b/spec/ruby/optional/capi/ext/symbol_spec.c
index 28da69ea3c..7ffa7cf9b1 100644
--- a/spec/ruby/optional/capi/ext/symbol_spec.c
+++ b/spec/ruby/optional/capi/ext/symbol_spec.c
@@ -1,12 +1,15 @@
#include "ruby.h"
#include "rubyspec.h"
+#ifdef HAVE_RUBY_ENCODING_H
#include "ruby/encoding.h"
+#endif
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef HAVE_RB_INTERN
VALUE symbol_spec_rb_intern(VALUE self, VALUE string) {
return ID2SYM(rb_intern(RSTRING_PTR(string)));
}
@@ -28,7 +31,9 @@ VALUE symbol_spec_rb_intern2_c_compare(VALUE self, VALUE string, VALUE len, VALU
ID symbol = rb_intern2(RSTRING_PTR(string), FIX2LONG(len));
return (SYM2ID(sym) == symbol) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_INTERN3
VALUE symbol_spec_rb_intern3(VALUE self, VALUE string, VALUE len, VALUE enc) {
return ID2SYM(rb_intern3(RSTRING_PTR(string), FIX2LONG(len), rb_enc_get(enc)));
}
@@ -37,52 +42,95 @@ VALUE symbol_spec_rb_intern3_c_compare(VALUE self, VALUE string, VALUE len, VALU
ID symbol = rb_intern3(RSTRING_PTR(string), FIX2LONG(len), rb_enc_get(enc));
return (SYM2ID(sym) == symbol) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_ID2NAME
VALUE symbol_spec_rb_id2name(VALUE self, VALUE symbol) {
const char* c_str = rb_id2name(SYM2ID(symbol));
return rb_str_new(c_str, strlen(c_str));
}
+#endif
+#ifdef HAVE_RB_ID2STR
VALUE symbol_spec_rb_id2str(VALUE self, VALUE symbol) {
return rb_id2str(SYM2ID(symbol));
}
+#endif
+#ifdef HAVE_RB_INTERN_STR
VALUE symbol_spec_rb_intern_str(VALUE self, VALUE str) {
return ID2SYM(rb_intern_str(str));
}
+#endif
+#ifdef HAVE_RB_IS_CLASS_ID
VALUE symbol_spec_rb_is_class_id(VALUE self, VALUE sym) {
return rb_is_class_id(SYM2ID(sym)) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_IS_CONST_ID
VALUE symbol_spec_rb_is_const_id(VALUE self, VALUE sym) {
return rb_is_const_id(SYM2ID(sym)) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_IS_INSTANCE_ID
VALUE symbol_spec_rb_is_instance_id(VALUE self, VALUE sym) {
return rb_is_instance_id(SYM2ID(sym)) ? Qtrue : Qfalse;
}
+#endif
+#ifdef HAVE_RB_SYM2STR
VALUE symbol_spec_rb_sym2str(VALUE self, VALUE sym) {
return rb_sym2str(sym);
}
+#endif
void Init_symbol_spec(void) {
- VALUE cls = rb_define_class("CApiSymbolSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiSymbolSpecs", rb_cObject);
+
+#ifdef HAVE_RB_INTERN
rb_define_method(cls, "rb_intern", symbol_spec_rb_intern, 1);
rb_define_method(cls, "rb_intern2", symbol_spec_rb_intern2, 2);
rb_define_method(cls, "rb_intern_const", symbol_spec_rb_intern_const, 1);
rb_define_method(cls, "rb_intern_c_compare", symbol_spec_rb_intern_c_compare, 2);
rb_define_method(cls, "rb_intern2_c_compare", symbol_spec_rb_intern2_c_compare, 3);
+#endif
+
+#ifdef HAVE_RB_INTERN3
rb_define_method(cls, "rb_intern3", symbol_spec_rb_intern3, 3);
rb_define_method(cls, "rb_intern3_c_compare", symbol_spec_rb_intern3_c_compare, 4);
+#endif
+
+#ifdef HAVE_RB_ID2NAME
rb_define_method(cls, "rb_id2name", symbol_spec_rb_id2name, 1);
+#endif
+
+#ifdef HAVE_RB_ID2STR
rb_define_method(cls, "rb_id2str", symbol_spec_rb_id2str, 1);
+#endif
+
+#ifdef HAVE_RB_INTERN_STR
rb_define_method(cls, "rb_intern_str", symbol_spec_rb_intern_str, 1);
+#endif
+
+#ifdef HAVE_RB_IS_CLASS_ID
rb_define_method(cls, "rb_is_class_id", symbol_spec_rb_is_class_id, 1);
+#endif
+
+#ifdef HAVE_RB_IS_CONST_ID
rb_define_method(cls, "rb_is_const_id", symbol_spec_rb_is_const_id, 1);
+#endif
+
+#ifdef HAVE_RB_IS_INSTANCE_ID
rb_define_method(cls, "rb_is_instance_id", symbol_spec_rb_is_instance_id, 1);
+#endif
+
+#ifdef HAVE_RB_SYM2STR
rb_define_method(cls, "rb_sym2str", symbol_spec_rb_sym2str, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/thread_spec.c b/spec/ruby/optional/capi/ext/thread_spec.c
index 139652e326..3bfe76b925 100644
--- a/spec/ruby/optional/capi/ext/thread_spec.c
+++ b/spec/ruby/optional/capi/ext/thread_spec.c
@@ -4,7 +4,7 @@
#include <math.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
+#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if defined(_WIN32)
@@ -15,16 +15,19 @@
extern "C" {
#endif
+#ifdef HAVE_RB_THREAD_ALONE
static VALUE thread_spec_rb_thread_alone() {
return rb_thread_alone() ? Qtrue : Qfalse;
}
+#endif
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
/* This is unblocked by unblock_func(). */
static void* blocking_gvl_func(void* data) {
int rfd = *(int *)data;
- char dummy = ' ';
+ char dummy;
ssize_t r;
do {
@@ -33,7 +36,7 @@ static void* blocking_gvl_func(void* data) {
close(rfd);
- return (void*)((r == 1 && dummy == 'A') ? Qtrue : Qfalse);
+ return (void*)((r == 1) ? Qtrue : Qfalse);
}
static void unblock_gvl_func(void *data) {
@@ -54,7 +57,7 @@ static VALUE thread_spec_rb_thread_call_without_gvl(VALUE self) {
void* ret;
if (pipe(fds) == -1) {
- rb_raise(rb_eRuntimeError, "could not create pipe");
+ return Qfalse;
}
ret = rb_thread_call_without_gvl(blocking_gvl_func, &fds[0],
unblock_gvl_func, &fds[1]);
@@ -79,7 +82,7 @@ static VALUE thread_spec_rb_thread_call_without_gvl_with_ubf_io(VALUE self) {
void* ret;
if (pipe(fds) == -1) {
- rb_raise(rb_eRuntimeError, "could not create pipe");
+ return Qfalse;
}
ret = rb_thread_call_without_gvl(blocking_gvl_func_for_udf_io,
@@ -88,23 +91,33 @@ static VALUE thread_spec_rb_thread_call_without_gvl_with_ubf_io(VALUE self) {
close(fds[1]);
return (VALUE)ret;
}
+#endif
+#ifdef HAVE_RB_THREAD_CURRENT
static VALUE thread_spec_rb_thread_current() {
return rb_thread_current();
}
+#endif
+#ifdef HAVE_RB_THREAD_LOCAL_AREF
static VALUE thread_spec_rb_thread_local_aref(VALUE self, VALUE thr, VALUE sym) {
return rb_thread_local_aref(thr, SYM2ID(sym));
}
+#endif
+#ifdef HAVE_RB_THREAD_LOCAL_ASET
static VALUE thread_spec_rb_thread_local_aset(VALUE self, VALUE thr, VALUE sym, VALUE value) {
return rb_thread_local_aset(thr, SYM2ID(sym), value);
}
+#endif
+#ifdef HAVE_RB_THREAD_WAKEUP
static VALUE thread_spec_rb_thread_wakeup(VALUE self, VALUE thr) {
return rb_thread_wakeup(thr);
}
+#endif
+#ifdef HAVE_RB_THREAD_WAIT_FOR
static VALUE thread_spec_rb_thread_wait_for(VALUE self, VALUE s, VALUE ms) {
struct timeval tv;
tv.tv_sec = NUM2INT(s);
@@ -112,10 +125,11 @@ static VALUE thread_spec_rb_thread_wait_for(VALUE self, VALUE s, VALUE ms) {
rb_thread_wait_for(tv);
return Qnil;
}
+#endif
+#ifdef HAVE_RB_THREAD_CREATE
-VALUE thread_spec_call_proc(void *arg_ptr) {
- VALUE arg_array = (VALUE)arg_ptr;
+VALUE thread_spec_call_proc(VALUE arg_array) {
VALUE arg = rb_ary_pop(arg_array);
VALUE proc = rb_ary_pop(arg_array);
return rb_funcall(proc, rb_intern("call"), 1, arg);
@@ -128,19 +142,45 @@ static VALUE thread_spec_rb_thread_create(VALUE self, VALUE proc, VALUE arg) {
return rb_thread_create(thread_spec_call_proc, (void*)args);
}
+#endif
void Init_thread_spec(void) {
- VALUE cls = rb_define_class("CApiThreadSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiThreadSpecs", rb_cObject);
+
+#ifdef HAVE_RB_THREAD_ALONE
rb_define_method(cls, "rb_thread_alone", thread_spec_rb_thread_alone, 0);
+#endif
+
+#ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
rb_define_method(cls, "rb_thread_call_without_gvl", thread_spec_rb_thread_call_without_gvl, 0);
rb_define_method(cls, "rb_thread_call_without_gvl_with_ubf_io", thread_spec_rb_thread_call_without_gvl_with_ubf_io, 0);
+#endif
+
+#ifdef HAVE_RB_THREAD_CURRENT
rb_define_method(cls, "rb_thread_current", thread_spec_rb_thread_current, 0);
+#endif
+
+#ifdef HAVE_RB_THREAD_LOCAL_AREF
rb_define_method(cls, "rb_thread_local_aref", thread_spec_rb_thread_local_aref, 2);
+#endif
+
+#ifdef HAVE_RB_THREAD_LOCAL_ASET
rb_define_method(cls, "rb_thread_local_aset", thread_spec_rb_thread_local_aset, 3);
+#endif
+
+#ifdef HAVE_RB_THREAD_WAKEUP
rb_define_method(cls, "rb_thread_wakeup", thread_spec_rb_thread_wakeup, 1);
+#endif
+
+#ifdef HAVE_RB_THREAD_WAIT_FOR
rb_define_method(cls, "rb_thread_wait_for", thread_spec_rb_thread_wait_for, 2);
+#endif
+
+#ifdef HAVE_RB_THREAD_CREATE
rb_define_method(cls, "rb_thread_create", thread_spec_rb_thread_create, 2);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/time_spec.c b/spec/ruby/optional/capi/ext/time_spec.c
index fec70dea9d..6b51120f1b 100644
--- a/spec/ruby/optional/capi/ext/time_spec.c
+++ b/spec/ruby/optional/capi/ext/time_spec.c
@@ -7,18 +7,25 @@
extern "C" {
#endif
+#ifdef HAVE_RB_TIME_NEW
static VALUE time_spec_rb_time_new(VALUE self, VALUE sec, VALUE usec) {
return rb_time_new(NUM2TIMET(sec), NUM2LONG(usec));
}
+#endif
+#ifdef HAVE_RB_TIME_NANO_NEW
static VALUE time_spec_rb_time_nano_new(VALUE self, VALUE sec, VALUE nsec) {
return rb_time_nano_new(NUM2TIMET(sec), NUM2LONG(nsec));
}
+#endif
+#ifdef HAVE_RB_TIME_NUM_NEW
static VALUE time_spec_rb_time_num_new(VALUE self, VALUE ts, VALUE offset) {
return rb_time_num_new(ts, offset);
}
+#endif
+#ifdef HAVE_RB_TIME_INTERVAL
static VALUE time_spec_rb_time_interval(VALUE self, VALUE ts) {
struct timeval interval = rb_time_interval(ts);
VALUE ary = rb_ary_new();
@@ -26,7 +33,9 @@ static VALUE time_spec_rb_time_interval(VALUE self, VALUE ts) {
rb_ary_push(ary, TIMET2NUM(interval.tv_usec));
return ary;
}
+#endif
+#ifdef HAVE_RB_TIME_TIMEVAL
static VALUE time_spec_rb_time_timeval(VALUE self, VALUE ts) {
struct timeval tv = rb_time_timeval(ts);
VALUE ary = rb_ary_new();
@@ -34,7 +43,9 @@ static VALUE time_spec_rb_time_timeval(VALUE self, VALUE ts) {
rb_ary_push(ary, TIMET2NUM(tv.tv_usec));
return ary;
}
+#endif
+#ifdef HAVE_RB_TIME_TIMESPEC
static VALUE time_spec_rb_time_timespec(VALUE self, VALUE time) {
struct timespec ts = rb_time_timespec(time);
VALUE ary = rb_ary_new();
@@ -42,7 +53,9 @@ static VALUE time_spec_rb_time_timespec(VALUE self, VALUE time) {
rb_ary_push(ary, TIMET2NUM(ts.tv_nsec));
return ary;
}
+#endif
+#ifdef HAVE_RB_TIME_TIMESPEC_NEW
static VALUE time_spec_rb_time_timespec_new(VALUE self, VALUE sec, VALUE nsec, VALUE offset) {
struct timespec ts;
ts.tv_sec = NUM2TIMET(sec);
@@ -50,30 +63,63 @@ static VALUE time_spec_rb_time_timespec_new(VALUE self, VALUE sec, VALUE nsec, V
return rb_time_timespec_new(&ts, NUM2INT(offset));
}
+#endif
+#ifdef HAVE_RB_TIMESPEC_NOW
static VALUE time_spec_rb_time_from_timspec_now(VALUE self, VALUE offset) {
struct timespec ts;
rb_timespec_now(&ts);
return rb_time_timespec_new(&ts, NUM2INT(offset));
}
+#endif
+#ifdef HAVE_TIMET2NUM
static VALUE time_spec_TIMET2NUM(VALUE self) {
time_t t = 10;
return TIMET2NUM(t);
}
+#endif
void Init_time_spec(void) {
- VALUE cls = rb_define_class("CApiTimeSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiTimeSpecs", rb_cObject);
+
+#ifdef HAVE_RB_TIME_NEW
rb_define_method(cls, "rb_time_new", time_spec_rb_time_new, 2);
+#endif
+
+#ifdef HAVE_TIMET2NUM
rb_define_method(cls, "TIMET2NUM", time_spec_TIMET2NUM, 0);
+#endif
+
+#ifdef HAVE_RB_TIME_NANO_NEW
rb_define_method(cls, "rb_time_nano_new", time_spec_rb_time_nano_new, 2);
+#endif
+
+#ifdef HAVE_RB_TIME_NUM_NEW
rb_define_method(cls, "rb_time_num_new", time_spec_rb_time_num_new, 2);
+#endif
+
+#ifdef HAVE_RB_TIME_INTERVAL
rb_define_method(cls, "rb_time_interval", time_spec_rb_time_interval, 1);
+#endif
+
+#ifdef HAVE_RB_TIME_TIMEVAL
rb_define_method(cls, "rb_time_timeval", time_spec_rb_time_timeval, 1);
+#endif
+
+#ifdef HAVE_RB_TIME_TIMESPEC
rb_define_method(cls, "rb_time_timespec", time_spec_rb_time_timespec, 1);
+#endif
+
+#ifdef HAVE_RB_TIME_TIMESPEC_NEW
rb_define_method(cls, "rb_time_timespec_new", time_spec_rb_time_timespec_new, 3);
+#endif
+
+#ifdef HAVE_RB_TIMESPEC_NOW
rb_define_method(cls, "rb_time_from_timespec", time_spec_rb_time_from_timspec_now, 1);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/typed_data_spec.c b/spec/ruby/optional/capi/ext/typed_data_spec.c
index a2cc53f54d..8c9a0708b4 100644
--- a/spec/ruby/optional/capi/ext/typed_data_spec.c
+++ b/spec/ruby/optional/capi/ext/typed_data_spec.c
@@ -7,6 +7,7 @@
extern "C" {
#endif
+#if defined(HAVE_RTYPEDDATA) && defined(HAVE_TYPEDDATA_WRAP_STRUCT)
struct sample_typed_wrapped_struct_parent {
int foo;
};
@@ -43,11 +44,7 @@ void sample_typed_wrapped_struct_mark(void* st) {
}
size_t sample_typed_wrapped_struct_memsize(const void* st) {
- if (st == NULL) {
- return 0;
- } else {
- return ((struct sample_typed_wrapped_struct *)st)->foo;
- }
+ return sizeof(struct sample_typed_wrapped_struct);
}
static const rb_data_type_t sample_typed_wrapped_struct_data_type = {
@@ -104,6 +101,12 @@ VALUE sws_typed_wrap_struct(VALUE self, VALUE val) {
return TypedData_Wrap_Struct(rb_cObject, &sample_typed_wrapped_struct_data_type, bar);
}
+VALUE sws_typed_wrap_struct_null(VALUE self, VALUE val) {
+ struct sample_typed_wrapped_struct* bar = (struct sample_typed_wrapped_struct *)malloc(sizeof(struct sample_typed_wrapped_struct));
+ bar->foo = FIX2INT(val);
+ return TypedData_Wrap_Struct(0, &sample_typed_wrapped_struct_data_type, bar);
+}
+
VALUE sws_typed_get_struct(VALUE self, VALUE obj) {
struct sample_typed_wrapped_struct* bar;
TypedData_Get_Struct(obj, struct sample_typed_wrapped_struct, &sample_typed_wrapped_struct_data_type, bar);
@@ -146,19 +149,26 @@ VALUE sws_typed_change_struct(VALUE self, VALUE obj, VALUE new_val) {
RTYPEDDATA(obj)->data = new_struct;
return Qnil;
}
+#endif
void Init_typed_data_spec(void) {
- VALUE cls = rb_define_class("CApiAllocTypedSpecs", rb_cObject);
+ VALUE cls;
+ cls = rb_define_class("CApiAllocTypedSpecs", rb_cObject);
+
+#if defined(HAVE_RTYPEDDATA) && defined(HAVE_TYPEDDATA_WRAP_STRUCT)
rb_define_alloc_func(cls, sdaf_alloc_typed_func);
rb_define_method(cls, "typed_wrapped_data", sdaf_typed_get_struct, 0);
+
cls = rb_define_class("CApiWrappedTypedStructSpecs", rb_cObject);
rb_define_method(cls, "typed_wrap_struct", sws_typed_wrap_struct, 1);
+ rb_define_method(cls, "typed_wrap_struct_null", sws_typed_wrap_struct_null, 1);
rb_define_method(cls, "typed_get_struct", sws_typed_get_struct, 1);
rb_define_method(cls, "typed_get_struct_other", sws_typed_get_struct_different_type, 1);
rb_define_method(cls, "typed_get_struct_parent", sws_typed_get_struct_parent_type, 1);
rb_define_method(cls, "typed_get_struct_rdata", sws_typed_get_struct_rdata, 1);
rb_define_method(cls, "typed_get_struct_data_ptr", sws_typed_get_struct_data_ptr, 1);
rb_define_method(cls, "typed_change_struct", sws_typed_change_struct, 2);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/util_spec.c b/spec/ruby/optional/capi/ext/util_spec.c
index f3c6a1ba58..50795b51af 100644
--- a/spec/ruby/optional/capi/ext/util_spec.c
+++ b/spec/ruby/optional/capi/ext/util_spec.c
@@ -5,6 +5,7 @@
extern "C" {
#endif
+#ifdef HAVE_RB_SCAN_ARGS
VALUE util_spec_rb_scan_args(VALUE self, VALUE argv, VALUE fmt, VALUE expected, VALUE acc) {
int i, result, argc = (int)RARRAY_LEN(argv);
VALUE args[6], failed, a1, a2, a3, a4, a5, a6;
@@ -16,32 +17,19 @@ VALUE util_spec_rb_scan_args(VALUE self, VALUE argv, VALUE fmt, VALUE expected,
args[i] = rb_ary_entry(argv, i);
}
-#ifdef RB_SCAN_ARGS_KEYWORDS
- if (*RSTRING_PTR(fmt) == 'k') {
- result = rb_scan_args_kw(RB_SCAN_ARGS_KEYWORDS, argc, args, RSTRING_PTR(fmt)+1, &a1, &a2, &a3, &a4, &a5, &a6);
- } else {
-#endif
- result = rb_scan_args(argc, args, RSTRING_PTR(fmt), &a1, &a2, &a3, &a4, &a5, &a6);
-#ifdef RB_SCAN_ARGS_KEYWORDS
- }
-#endif
+ result = rb_scan_args(argc, args, RSTRING_PTR(fmt), &a1, &a2, &a3, &a4, &a5, &a6);
switch(NUM2INT(expected)) {
case 6:
rb_ary_unshift(acc, a6);
- /* FALLTHROUGH */
case 5:
rb_ary_unshift(acc, a5);
- /* FALLTHROUGH */
case 4:
rb_ary_unshift(acc, a4);
- /* FALLTHROUGH */
case 3:
rb_ary_unshift(acc, a3);
- /* FALLTHROUGH */
case 2:
rb_ary_unshift(acc, a2);
- /* FALLTHROUGH */
case 1:
rb_ary_unshift(acc, a1);
break;
@@ -51,56 +39,55 @@ VALUE util_spec_rb_scan_args(VALUE self, VALUE argv, VALUE fmt, VALUE expected,
return INT2NUM(result);
}
+#endif
-static VALUE util_spec_rb_get_kwargs(VALUE self, VALUE keyword_hash, VALUE keys, VALUE required, VALUE optional) {
- int req = FIX2INT(required);
- int opt = FIX2INT(optional);
- int len = RARRAY_LENINT(keys);
-
- int values_len = req + (opt < 0 ? -1 - opt : opt);
- int i = 0;
-
- ID *ids = malloc(sizeof(VALUE) * len);
- VALUE *results = malloc(sizeof(VALUE) * values_len);
- int extracted = 0;
- VALUE ary = Qundef;
-
- for (i = 0; i < len; i++) {
- ids[i] = SYM2ID(rb_ary_entry(keys, i));
- }
-
- extracted = rb_get_kwargs(keyword_hash, ids, req, opt, results);
- ary = rb_ary_new_from_values(extracted, results);
- free(results);
- free(ids);
- return ary;
-}
-
+#ifdef HAVE_RB_LONG2INT
static VALUE util_spec_rb_long2int(VALUE self, VALUE n) {
return INT2NUM(rb_long2int(NUM2LONG(n)));
}
+#endif
+#ifdef HAVE_RB_ITER_BREAK
static VALUE util_spec_rb_iter_break(VALUE self) {
rb_iter_break();
return Qnil;
}
+#endif
+#ifdef HAVE_RB_SOURCEFILE
static VALUE util_spec_rb_sourcefile(VALUE self) {
return rb_str_new2(rb_sourcefile());
}
+#endif
+#ifdef HAVE_RB_SOURCELINE
static VALUE util_spec_rb_sourceline(VALUE self) {
return INT2NUM(rb_sourceline());
}
+#endif
void Init_util_spec(void) {
VALUE cls = rb_define_class("CApiUtilSpecs", rb_cObject);
+
+#ifdef HAVE_RB_SCAN_ARGS
rb_define_method(cls, "rb_scan_args", util_spec_rb_scan_args, 4);
- rb_define_method(cls, "rb_get_kwargs", util_spec_rb_get_kwargs, 4);
+#endif
+
+#ifdef HAVE_RB_LONG2INT
rb_define_method(cls, "rb_long2int", util_spec_rb_long2int, 1);
+#endif
+
+#ifdef HAVE_RB_ITER_BREAK
rb_define_method(cls, "rb_iter_break", util_spec_rb_iter_break, 0);
+#endif
+
+#ifdef HAVE_RB_SOURCEFILE
rb_define_method(cls, "rb_sourcefile", util_spec_rb_sourcefile, 0);
+#endif
+
+#ifdef HAVE_RB_SOURCELINE
rb_define_method(cls, "rb_sourceline", util_spec_rb_sourceline, 0);
+#endif
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/file_spec.rb b/spec/ruby/optional/capi/file_spec.rb
index 96d731e4fa..2459dba979 100644
--- a/spec/ruby/optional/capi/file_spec.rb
+++ b/spec/ruby/optional/capi/file_spec.rb
@@ -1,11 +1,11 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension('file')
describe :rb_file_open, shared: true do
it "raises an ArgumentError if passed an empty mode string" do
touch @name
- -> { @s.rb_file_open(@name, "") }.should raise_error(ArgumentError)
+ lambda { @s.rb_file_open(@name, "") }.should raise_error(ArgumentError)
end
it "opens a file in read-only mode with 'r'" do
diff --git a/spec/ruby/optional/capi/fixnum_spec.rb b/spec/ruby/optional/capi/fixnum_spec.rb
index aa02a0543b..d9e9d1946d 100644
--- a/spec/ruby/optional/capi/fixnum_spec.rb
+++ b/spec/ruby/optional/capi/fixnum_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("fixnum")
@@ -8,16 +8,14 @@ describe "CApiFixnumSpecs" do
end
describe "FIX2INT" do
- max_int = (1 << 31) - 1
- min_int = -(1 << 31)
-
it "converts a Fixnum to a native int" do
@s.FIX2INT(42).should == 42
@s.FIX2INT(-14).should == -14
- @s.FIX2INT(-1).should == -1
- @s.FIX2INT(1).should == 1
end
+ max_int = (1 << 31) - 1
+ min_int = -(1 << 31)
+
guard -> { fixnum_min <= min_int and max_int <= fixnum_max } do
it "converts a Fixnum representing the minimum and maximum native int" do
@s.FIX2INT(max_int).should == max_int
@@ -25,76 +23,101 @@ describe "CApiFixnumSpecs" do
end
end
- platform_is wordsize: 64 do # sizeof(long) > sizeof(int)
+ end
+
+ describe "FIX2UINT" do
+ it "converts a Fixnum to a native int" do
+ @s.FIX2UINT(42).should == 42
+ @s.FIX2UINT(0).should == 0
+ end
+
+ max_uint = (1 << 32) - 1
+
+ guard -> { max_uint <= fixnum_max } do
+ it "converts a Fixnum representing the maximum native uint" do
+ @s.FIX2UINT(max_uint).should == max_uint
+ end
+ end
+
+ end
+
+ platform_is wordsize: 64 do
+ describe "rb_fix2uint" do
it "raises a TypeError if passed nil" do
- -> { @s.FIX2INT(nil) }.should raise_error(TypeError)
+ lambda { @s.rb_fix2uint(nil) }.should raise_error(TypeError)
end
- it "converts a Float" do
- @s.FIX2INT(25.4567).should == 25
+ it "converts a Fixnum" do
+ @s.rb_fix2uint(0).should == 0
+ @s.rb_fix2uint(1).should == 1
end
- it "converts a negative Bignum into an signed number" do
- @s.FIX2INT(-2147442171).should == -2147442171
+ it "converts the maximum uint value" do
+ @s.rb_fix2uint(0xffff_ffff).should == 0xffff_ffff
end
- it "raises a RangeError if the value does not fit a native int" do
- -> { @s.FIX2INT(0x7fff_ffff+1) }.should raise_error(RangeError)
- -> { @s.FIX2INT(-(1 << 31) - 1) }.should raise_error(RangeError)
+ it "converts a Float" do
+ @s.rb_fix2uint(25.4567).should == 25
end
- it "raises a RangeError if the value is more than 32bits" do
- -> { @s.FIX2INT(0xffff_ffff+1) }.should raise_error(RangeError)
+ it "raises a RangeError if the value does not fit a native uint" do
+ # Interestingly, on MRI rb_fix2uint(-1) is allowed
+ lambda { @s.rb_fix2uint(0xffff_ffff+1) }.should raise_error(RangeError)
+ lambda { @s.rb_fix2uint(-(1 << 31) - 1) }.should raise_error(RangeError)
end
- it "raises a RangeError if the value is more than 64bits" do
- -> { @s.FIX2INT(0xffff_ffff_ffff_ffff+1) }.should raise_error(RangeError)
+ it "raises a RangeError if the value is more than 32bits" do
+ lambda { @s.rb_fix2uint(0xffff_ffff+1) }.should raise_error(RangeError)
end
- it "calls #to_int to coerce the value" do
- obj = mock("number")
- obj.should_receive(:to_int).and_return(2)
- @s.FIX2INT(obj).should == 2
+ it "raises a RangeError if the value is more than 64bits" do
+ lambda { @s.rb_fix2uint(0xffff_ffff_ffff_ffff+1) }.should raise_error(RangeError)
end
end
- end
- describe "FIX2UINT" do
- max_uint = (1 << 32) - 1
+ describe "rb_fix2int" do
+ it "raises a TypeError if passed nil" do
+ lambda { @s.rb_fix2int(nil) }.should raise_error(TypeError)
+ end
- it "converts a Fixnum" do
- @s.FIX2UINT(0).should == 0
- @s.FIX2UINT(1).should == 1
- @s.FIX2UINT(42).should == 42
- end
+ it "converts a Fixnum" do
+ @s.rb_fix2int(-1).should == -1
+ @s.rb_fix2int(1).should == 1
+ end
- guard -> { max_uint <= fixnum_max } do
- it "converts a Fixnum representing the maximum native uint" do
- @s.FIX2UINT(max_uint).should == max_uint
+ it "converts the minimum int value" do
+ @s.rb_fix2int(-(1 << 31)).should == -(1 << 31)
end
- end
- platform_is wordsize: 64 do # sizeof(long) > sizeof(int)
- it "raises a TypeError if passed nil" do
- -> { @s.FIX2UINT(nil) }.should raise_error(TypeError)
+ it "converts the maximum int value" do
+ @s.rb_fix2int(0x7fff_ffff).should == 0x7fff_ffff
end
it "converts a Float" do
- @s.FIX2UINT(25.4567).should == 25
+ @s.rb_fix2int(25.4567).should == 25
end
- it "raises a RangeError if the value does not fit a native uint" do
- # Interestingly, on MRI FIX2UINT(-1) is allowed
- -> { @s.FIX2UINT(0xffff_ffff+1) }.should raise_error(RangeError)
- -> { @s.FIX2UINT(-(1 << 31) - 1) }.should raise_error(RangeError)
+ it "converts a negative Bignum into an signed number" do
+ @s.rb_fix2int(-2147442171).should == -2147442171
+ end
+
+ it "raises a RangeError if the value does not fit a native int" do
+ lambda { @s.rb_fix2int(0x7fff_ffff+1) }.should raise_error(RangeError)
+ lambda { @s.rb_fix2int(-(1 << 31) - 1) }.should raise_error(RangeError)
end
it "raises a RangeError if the value is more than 32bits" do
- -> { @s.FIX2UINT(0xffff_ffff+1) }.should raise_error(RangeError)
+ lambda { @s.rb_fix2int(0xffff_ffff+1) }.should raise_error(RangeError)
end
it "raises a RangeError if the value is more than 64bits" do
- -> { @s.FIX2UINT(0xffff_ffff_ffff_ffff+1) }.should raise_error(RangeError)
+ lambda { @s.rb_fix2int(0xffff_ffff_ffff_ffff+1) }.should raise_error(RangeError)
+ end
+
+ it "calls #to_int to coerce the value" do
+ obj = mock("number")
+ obj.should_receive(:to_int).and_return(2)
+ @s.rb_fix2int(obj).should == 2
end
end
end
diff --git a/spec/ruby/optional/capi/fixtures/class.rb b/spec/ruby/optional/capi/fixtures/class.rb
index dbb0b69967..de824b3ab0 100644
--- a/spec/ruby/optional/capi/fixtures/class.rb
+++ b/spec/ruby/optional/capi/fixtures/class.rb
@@ -68,19 +68,10 @@ class CApiClassSpecs
class SubSub < Sub
def call_super_method
- :subsubclass_method
- end
- end
-
- class SuperSelf
- def call_super_method
- self
+ :subclass_method
end
end
- class SubSelf < SuperSelf
- end
-
class A
C = 1
autoload :D, File.expand_path('../path_to_class.rb', __FILE__)
diff --git a/spec/ruby/optional/capi/float_spec.rb b/spec/ruby/optional/capi/float_spec.rb
index 8381945315..8d709b2b82 100644
--- a/spec/ruby/optional/capi/float_spec.rb
+++ b/spec/ruby/optional/capi/float_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("float")
diff --git a/spec/ruby/optional/capi/gc_spec.rb b/spec/ruby/optional/capi/gc_spec.rb
index 46c03156e4..ee9e11d11c 100644
--- a/spec/ruby/optional/capi/gc_spec.rb
+++ b/spec/ruby/optional/capi/gc_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("gc")
@@ -9,9 +9,9 @@ describe "CApiGCSpecs" do
it "correctly gets the value from a registered address" do
@f.registered_tagged_address.should == 10
- @f.registered_tagged_address.should equal(@f.registered_tagged_address)
+ @f.registered_tagged_address.object_id.should == @f.registered_tagged_address.object_id
@f.registered_reference_address.should == "Globally registered data"
- @f.registered_reference_address.should equal(@f.registered_reference_address)
+ @f.registered_reference_address.object_id.should == @f.registered_reference_address.object_id
end
describe "rb_gc_enable" do
@@ -42,20 +42,13 @@ describe "CApiGCSpecs" do
end
describe "rb_gc" do
+
it "increases gc count" do
gc_count = GC.count
@f.rb_gc
GC.count.should > gc_count
end
- end
- describe "rb_gc_adjust_memory_usage" do
- # Just check that it does not throw, as it seems hard to observe any effect
- it "adjusts the amount of registered external memory" do
- -> {
- @f.rb_gc_adjust_memory_usage(8)
- @f.rb_gc_adjust_memory_usage(-8)
- }.should_not raise_error
- end
end
+
end
diff --git a/spec/ruby/optional/capi/globals_spec.rb b/spec/ruby/optional/capi/globals_spec.rb
index 84694b1375..c6e2ed912b 100644
--- a/spec/ruby/optional/capi/globals_spec.rb
+++ b/spec/ruby/optional/capi/globals_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
require "stringio"
load_extension("globals")
@@ -44,7 +44,7 @@ describe "CApiGlobalSpecs" do
it "rb_define_readonly_variable should define a new readonly global variable" do
@f.rb_define_readonly_variable("ro_gvar", 15)
$ro_gvar.should == 15
- -> { $ro_gvar = 10 }.should raise_error(NameError)
+ lambda { $ro_gvar = 10 }.should raise_error(NameError)
end
it "rb_define_hooked_variable should define a C hooked global variable" do
@@ -159,7 +159,7 @@ describe "CApiGlobalSpecs" do
end
after :each do
- suppress_warning {$, = @dollar_comma}
+ $, = @dollar_comma
end
it "returns nil by default" do
@@ -167,7 +167,7 @@ describe "CApiGlobalSpecs" do
end
it "returns the value of $\\" do
- suppress_warning {$, = "foo"}
+ $, = "foo"
@f.rb_output_fs.should == "foo"
end
end
diff --git a/spec/ruby/optional/capi/hash_spec.rb b/spec/ruby/optional/capi/hash_spec.rb
index 2923faf7de..1c406f0394 100644
--- a/spec/ruby/optional/capi/hash_spec.rb
+++ b/spec/ruby/optional/capi/hash_spec.rb
@@ -1,5 +1,4 @@
-require_relative 'spec_helper'
-require_relative '../../shared/hash/key_error'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("hash")
@@ -36,7 +35,7 @@ describe "C-API Hash function" do
obj = mock("rb_hash no to_int")
obj.should_receive(:hash).and_return(nil)
- -> { @s.rb_hash(obj) }.should raise_error(TypeError)
+ lambda { @s.rb_hash(obj) }.should raise_error(TypeError)
end
end
@@ -131,17 +130,11 @@ describe "C-API Hash function" do
it "raises a KeyError if the key is not found and default is set" do
@hsh.default = :d
- -> { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError)
+ lambda { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError)
end
it "raises a KeyError if the key is not found and no default is set" do
- -> { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError)
- end
-
- context "when key is not found" do
- it_behaves_like :key_error, -> obj, key {
- @s.rb_hash_fetch(obj, key)
- }, { a: 1 }
+ lambda { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError)
end
end
@@ -211,11 +204,6 @@ describe "C-API Hash function" do
@s.rb_hash_lookup2(hash, :chunky, 10).should == 10
end
-
- it "returns undefined if that is the default value specified" do
- hsh = Hash.new(0)
- @s.rb_hash_lookup2_default_undef(hsh, :chunky).should be_true
- end
end
end
@@ -245,13 +233,13 @@ describe "C-API Hash function" do
end
it "raises a TypeError if the argument does not respond to #to_hash" do
- -> { @s.rb_Hash(42) }.should raise_error(TypeError)
+ lambda { @s.rb_Hash(42) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_hash does not return a hash" do
h = BasicObject.new
def h.to_hash; 42; end
- -> { @s.rb_Hash(h) }.should raise_error(TypeError)
+ lambda { @s.rb_Hash(h) }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/optional/capi/integer_spec.rb b/spec/ruby/optional/capi/integer_spec.rb
index 56f7ca3034..9a660cdb5c 100644
--- a/spec/ruby/optional/capi/integer_spec.rb
+++ b/spec/ruby/optional/capi/integer_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: binary -*-
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("integer")
diff --git a/spec/ruby/optional/capi/io_spec.rb b/spec/ruby/optional/capi/io_spec.rb
index 4d61fc8755..92bc2da54e 100644
--- a/spec/ruby/optional/capi/io_spec.rb
+++ b/spec/ruby/optional/capi/io_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension('io')
@@ -9,7 +9,7 @@ describe "C-API IO function" do
@name = tmp("c_api_rb_io_specs")
touch @name
- @io = new_io @name, "w:utf-8"
+ @io = new_io @name, fmode("w:utf-8")
@io.sync = true
end
@@ -113,7 +113,7 @@ describe "C-API IO function" do
@name = tmp("c_api_io_specs")
touch @name
- @io = new_io @name, "r:utf-8"
+ @io = new_io @name, fmode("r:utf-8")
end
after :each do
@@ -142,12 +142,12 @@ describe "C-API IO function" do
describe "rb_io_check_closed" do
it "does not raise an exception if the IO is not closed" do
# The MRI function is void, so we use should_not raise_error
- -> { @o.rb_io_check_closed(@io) }.should_not raise_error
+ lambda { @o.rb_io_check_closed(@io) }.should_not raise_error
end
it "raises an error if the IO is closed" do
@io.close
- -> { @o.rb_io_check_closed(@io) }.should raise_error(IOError)
+ lambda { @o.rb_io_check_closed(@io) }.should raise_error(IOError)
end
end
@@ -155,13 +155,13 @@ describe "C-API IO function" do
# object is frozen, *not* if it's tainted.
describe "rb_io_taint_check" do
it "does not raise an exception if the IO is not frozen" do
- -> { @o.rb_io_taint_check(@io) }.should_not raise_error
+ lambda { @o.rb_io_taint_check(@io) }.should_not raise_error
end
it "raises an exception if the IO is frozen" do
@io.freeze
- -> { @o.rb_io_taint_check(@io) }.should raise_error(RuntimeError)
+ lambda { @o.rb_io_taint_check(@io) }.should raise_error(RuntimeError)
end
end
@@ -193,7 +193,7 @@ describe "C-API IO function" do
@name = tmp("c_api_io_specs")
touch @name
- @rw_io = new_io @name, "w+"
+ @rw_io = new_io @name, fmode("w+")
end
after :each do
@@ -206,43 +206,42 @@ describe "C-API IO function" do
describe "rb_io_check_readable" do
it "does not raise an exception if the IO is opened for reading" do
# The MRI function is void, so we use should_not raise_error
- -> { @o.rb_io_check_readable(@r_io) }.should_not raise_error
+ lambda { @o.rb_io_check_readable(@r_io) }.should_not raise_error
end
it "does not raise an exception if the IO is opened for read and write" do
- -> { @o.rb_io_check_readable(@rw_io) }.should_not raise_error
+ lambda { @o.rb_io_check_readable(@rw_io) }.should_not raise_error
end
it "raises an IOError if the IO is not opened for reading" do
- -> { @o.rb_io_check_readable(@w_io) }.should raise_error(IOError)
+ lambda { @o.rb_io_check_readable(@w_io) }.should raise_error(IOError)
end
end
describe "rb_io_check_writable" do
- it "does not raise an exception if the IO is opened for writing" do
+ it "does not raise an exeption if the IO is opened for writing" do
# The MRI function is void, so we use should_not raise_error
- -> { @o.rb_io_check_writable(@w_io) }.should_not raise_error
+ lambda { @o.rb_io_check_writable(@w_io) }.should_not raise_error
end
it "does not raise an exception if the IO is opened for read and write" do
- -> { @o.rb_io_check_writable(@rw_io) }.should_not raise_error
+ lambda { @o.rb_io_check_writable(@rw_io) }.should_not raise_error
end
it "raises an IOError if the IO is not opened for reading" do
- -> { @o.rb_io_check_writable(@r_io) }.should raise_error(IOError)
+ lambda { @o.rb_io_check_writable(@r_io) }.should raise_error(IOError)
end
end
describe "rb_io_wait_writable" do
it "returns false if there is no error condition" do
- @o.errno = 0
@o.rb_io_wait_writable(@w_io).should be_false
end
it "raises an IOError if the IO is closed" do
@w_io.close
- -> { @o.rb_io_wait_writable(@w_io) }.should raise_error(IOError)
+ lambda { @o.rb_io_wait_writable(@w_io) }.should raise_error(IOError)
end
end
@@ -255,13 +254,12 @@ describe "C-API IO function" do
platform_is_not :windows do
describe "rb_io_wait_readable" do
it "returns false if there is no error condition" do
- @o.errno = 0
@o.rb_io_wait_readable(@r_io, false).should be_false
end
it "raises and IOError if passed a closed stream" do
@r_io.close
- -> {
+ lambda {
@o.rb_io_wait_readable(@r_io, false)
}.should raise_error(IOError)
end
@@ -273,7 +271,6 @@ describe "C-API IO function" do
@w_io.write "rb_io_wait_readable"
end
- @o.errno = Errno::EAGAIN.new.errno
@o.rb_io_wait_readable(@r_io, true).should be_true
@o.instance_variable_get(:@read_data).should == "rb_io_wait_re"
@@ -299,26 +296,6 @@ describe "C-API IO function" do
end
end
- describe "rb_wait_for_single_fd" do
- it "waits til an fd is ready for reading" do
- start = false
- thr = Thread.new do
- start = true
- sleep 0.05
- @w_io.write "rb_io_wait_readable"
- end
-
- Thread.pass until start
-
- @o.rb_wait_for_single_fd(@r_io, 1, nil, nil).should == 1
-
- thr.join
- end
-
- it "polls whether an fd is ready for reading if timeout is 0" do
- @o.rb_wait_for_single_fd(@r_io, 1, 0, 0).should == 0
- end
- end
end
describe "rb_fd_fix_cloexec" do
@@ -329,7 +306,7 @@ describe "rb_fd_fix_cloexec" do
@name = tmp("c_api_rb_io_specs")
touch @name
- @io = new_io @name, "w:utf-8"
+ @io = new_io @name, fmode("w:utf-8")
@io.close_on_exec = false
@io.sync = true
end
diff --git a/spec/ruby/optional/capi/kernel_spec.rb b/spec/ruby/optional/capi/kernel_spec.rb
index 32cdd3f421..73928b3154 100644
--- a/spec/ruby/optional/capi/kernel_spec.rb
+++ b/spec/ruby/optional/capi/kernel_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("kernel")
@@ -19,7 +19,7 @@ describe "C-API Kernel function" do
describe "rb_need_block" do
it "raises a LocalJumpError if no block is given" do
- -> { @s.rb_need_block }.should raise_error(LocalJumpError)
+ lambda { @s.rb_need_block }.should raise_error(LocalJumpError)
end
it "does not raise a LocalJumpError if a block is given" do
@@ -53,28 +53,16 @@ describe "C-API Kernel function" do
i + 1
end.should == [2, 4, 6]
end
-
- it "can pass extra data to the function" do
- ary = [3]
- @s.rb_block_call_extra_data(ary).should equal(ary)
- end
- end
-
- describe "rb_frame_this_func" do
- it "returns the name of the method called" do
- @s.rb_frame_this_func_test.should == :rb_frame_this_func_test
- @s.rb_frame_this_func_test_again.should == :rb_frame_this_func_test_again
- end
end
describe "rb_raise" do
it "raises an exception" do
- -> { @s.rb_raise({}) }.should raise_error(TypeError)
+ lambda { @s.rb_raise({}) }.should raise_error(TypeError)
end
it "terminates the function at the point it was called" do
h = {}
- -> { @s.rb_raise(h) }.should raise_error(TypeError)
+ lambda { @s.rb_raise(h) }.should raise_error(TypeError)
h[:stage].should == :before
end
end
@@ -100,7 +88,7 @@ describe "C-API Kernel function" do
end
it "raises an ArgumentError if there is no catch block for the symbol" do
- -> { @s.rb_throw(nil) }.should raise_error(ArgumentError)
+ lambda { @s.rb_throw(nil) }.should raise_error(ArgumentError)
end
end
@@ -126,7 +114,7 @@ describe "C-API Kernel function" do
end
it "raises an ArgumentError if there is no catch block for the symbol" do
- -> { @s.rb_throw(nil) }.should raise_error(ArgumentError)
+ lambda { @s.rb_throw(nil) }.should raise_error(ArgumentError)
end
end
@@ -156,13 +144,13 @@ describe "C-API Kernel function" do
describe "rb_sys_fail" do
it "raises an exception from the value of errno" do
- -> do
+ lambda do
@s.rb_sys_fail("additional info")
end.should raise_error(SystemCallError, /additional info/)
end
it "can take a NULL message" do
- -> do
+ lambda do
@s.rb_sys_fail(nil)
end.should raise_error(Errno::EPERM)
end
@@ -170,13 +158,13 @@ describe "C-API Kernel function" do
describe "rb_syserr_fail" do
it "raises an exception from the given error" do
- -> do
+ lambda do
@s.rb_syserr_fail(Errno::EINVAL::Errno, "additional info")
end.should raise_error(Errno::EINVAL, /additional info/)
end
it "can take a NULL message" do
- -> do
+ lambda do
@s.rb_syserr_fail(Errno::EINVAL::Errno, nil)
end.should raise_error(Errno::EINVAL)
end
@@ -194,7 +182,7 @@ describe "C-API Kernel function" do
end
it "raises LocalJumpError when no block is given" do
- -> { @s.rb_yield(1) }.should raise_error(LocalJumpError)
+ lambda { @s.rb_yield(1) }.should raise_error(LocalJumpError)
end
it "rb_yield to a block that breaks does not raise an error" do
@@ -234,7 +222,7 @@ describe "C-API Kernel function" do
end
it "raises LocalJumpError when no block is given" do
- -> { @s.rb_yield_splat([1, 2]) }.should raise_error(LocalJumpError)
+ lambda { @s.rb_yield_splat([1, 2]) }.should raise_error(LocalJumpError)
end
end
@@ -249,12 +237,8 @@ describe "C-API Kernel function" do
@s.rb_yield_splat([1, 2]) { |x, y| x + y }.should == 3
end
- it "passes arguments to a block accepting splatted args" do
- @s.rb_yield_splat([1, 2]) { |*v| v }.should == [1, 2]
- end
-
it "raises LocalJumpError when no block is given" do
- -> { @s.rb_yield_splat([1, 2]) }.should raise_error(LocalJumpError)
+ lambda { @s.rb_yield_splat([1, 2]) }.should raise_error(LocalJumpError)
end
end
@@ -281,46 +265,21 @@ describe "C-API Kernel function" do
it "will allow cleanup code to run after a raise" do
proof = [] # Hold proof of work performed after the yield.
- -> do
+ lambda do
@s.rb_protect_yield(7, proof) { |x| raise NameError}
end.should raise_error(NameError)
proof[0].should == 23
end
-
- it "will return nil if an error was raised" do
- proof = [] # Hold proof of work performed after the yield.
- -> do
- @s.rb_protect_yield(7, proof) { |x| raise NameError}
- end.should raise_error(NameError)
- proof[0].should == 23
- proof[1].should == nil
- end
- end
-
- describe "rb_eval_string_protect" do
- it "will evaluate the given string" do
- proof = []
- res = @s.rb_eval_string_protect('1 + 7', proof)
- proof.should == [23, 8]
- end
-
- it "will allow cleanup code to be run when an exception is raised" do
- proof = []
- -> do
- @s.rb_eval_string_protect('raise RuntimeError', proof)
- end.should raise_error(RuntimeError)
- proof.should == [23, nil]
- end
end
describe "rb_rescue" do
before :each do
- @proc = -> x { x }
- @raise_proc_returns_sentinel = -> *_ { :raise_proc_executed }
- @raise_proc_returns_arg = -> *a { a }
- @arg_error_proc = -> *_ { raise ArgumentError, '' }
- @std_error_proc = -> *_ { raise StandardError, '' }
- @exc_error_proc = -> *_ { raise Exception, '' }
+ @proc = lambda { |x| x }
+ @raise_proc_returns_sentinel = lambda {|*_| :raise_proc_executed }
+ @raise_proc_returns_arg = lambda {|*a| a }
+ @arg_error_proc = lambda { |*_| raise ArgumentError, '' }
+ @std_error_proc = lambda { |*_| raise StandardError, '' }
+ @exc_error_proc = lambda { |*_| raise Exception, '' }
end
it "executes passed function" do
@@ -349,21 +308,21 @@ describe "C-API Kernel function" do
end
it "raises an exception if passed function raises an exception other than StandardError" do
- -> { @s.rb_rescue(@exc_error_proc, nil, @raise_proc_returns_arg, nil) }.should raise_error(Exception)
+ lambda { @s.rb_rescue(@exc_error_proc, nil, @raise_proc_returns_arg, nil) }.should raise_error(Exception)
end
it "raises an exception if any exception is raised inside 'raise function'" do
- -> { @s.rb_rescue(@std_error_proc, nil, @std_error_proc, nil) }.should raise_error(StandardError)
+ lambda { @s.rb_rescue(@std_error_proc, nil, @std_error_proc, nil) }.should raise_error(StandardError)
end
it "makes $! available only during 'raise function' execution" do
- @s.rb_rescue(@std_error_proc, nil, -> *_ { $! }, nil).class.should == StandardError
+ @s.rb_rescue(@std_error_proc, nil, lambda { |*_| $! }, nil).class.should == StandardError
$!.should == nil
end
it "returns the break value if the passed function yields to a block with a break" do
def proc_caller
- @s.rb_rescue(-> *_ { yield }, nil, @proc, nil)
+ @s.rb_rescue(lambda { |*_| yield }, nil, @proc, nil)
end
proc_caller { break :value }.should == :value
@@ -372,13 +331,13 @@ describe "C-API Kernel function" do
describe "rb_rescue2" do
it "only rescues if one of the passed exceptions is raised" do
- proc = -> x { x }
- arg_error_proc = -> *_ { raise ArgumentError, '' }
- run_error_proc = -> *_ { raise RuntimeError, '' }
- type_error_proc = -> *_ { raise TypeError, '' }
+ proc = lambda { |x| x }
+ arg_error_proc = lambda { |*_| raise ArgumentError, '' }
+ run_error_proc = lambda { |*_| raise RuntimeError, '' }
+ type_error_proc = lambda { |*_| raise TypeError, '' }
@s.rb_rescue2(arg_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError).should == :exc
@s.rb_rescue2(run_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError).should == :exc
- -> {
+ lambda {
@s.rb_rescue2(type_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError)
}.should raise_error(TypeError)
end
@@ -390,11 +349,11 @@ describe "C-API Kernel function" do
end
it "executes passed function" do
- @s.rb_catch("foo", -> { 1 }).should == 1
+ @s.rb_catch("foo", lambda { 1 }).should == 1
end
it "terminates the function at the point it was called" do
- proc = -> do
+ proc = lambda do
ScratchPad << :before_throw
throw :thrown_value
ScratchPad << :after_throw
@@ -404,7 +363,7 @@ describe "C-API Kernel function" do
end
it "raises an ArgumentError if the throw symbol isn't caught" do
- -> { @s.rb_catch("foo", -> { throw :bar }) }.should raise_error(ArgumentError)
+ lambda { @s.rb_catch("foo", lambda { throw :bar }) }.should raise_error(ArgumentError)
end
end
@@ -416,11 +375,11 @@ describe "C-API Kernel function" do
end
it "executes passed function" do
- @s.rb_catch_obj(@tag, -> { 1 }).should == 1
+ @s.rb_catch_obj(@tag, lambda { 1 }).should == 1
end
it "terminates the function at the point it was called" do
- proc = -> do
+ proc = lambda do
ScratchPad << :before_throw
throw @tag
ScratchPad << :after_throw
@@ -430,36 +389,36 @@ describe "C-API Kernel function" do
end
it "raises an ArgumentError if the throw symbol isn't caught" do
- -> { @s.rb_catch("foo", -> { throw :bar }) }.should raise_error(ArgumentError)
+ lambda { @s.rb_catch("foo", lambda { throw :bar }) }.should raise_error(ArgumentError)
end
end
describe "rb_ensure" do
it "executes passed function and returns its value" do
- proc = -> x { x }
+ proc = lambda { |x| x }
@s.rb_ensure(proc, :proc, proc, :ensure_proc).should == :proc
end
it "executes passed 'ensure function' when no exception is raised" do
foo = nil
- proc = -> *_ { }
- ensure_proc = -> x { foo = x }
+ proc = lambda { |*_| }
+ ensure_proc = lambda { |x| foo = x }
@s.rb_ensure(proc, nil, ensure_proc, :foo)
foo.should == :foo
end
it "executes passed 'ensure function' when an exception is raised" do
foo = nil
- raise_proc = -> { raise '' }
- ensure_proc = -> x { foo = x }
+ raise_proc = lambda { raise '' }
+ ensure_proc = lambda { |x| foo = x }
@s.rb_ensure(raise_proc, nil, ensure_proc, :foo) rescue nil
foo.should == :foo
end
it "raises the same exception raised inside passed function" do
- raise_proc = -> *_ { raise RuntimeError, 'foo' }
- proc = -> *_ { }
- -> { @s.rb_ensure(raise_proc, nil, proc, nil) }.should raise_error(RuntimeError, 'foo')
+ raise_proc = lambda { |*_| raise RuntimeError, 'foo' }
+ proc = lambda { |*_| }
+ lambda { @s.rb_ensure(raise_proc, nil, proc, nil) }.should raise_error(RuntimeError, 'foo')
end
end
@@ -471,35 +430,9 @@ describe "C-API Kernel function" do
describe "rb_block_proc" do
it "converts the implicit block into a proc" do
- proc = @s.rb_block_proc { 1+1 }
- proc.should be_kind_of(Proc)
- proc.call.should == 2
- proc.lambda?.should == false
- end
-
- it "passes through an existing lambda and does not convert to a proc" do
- b = -> { 1+1 }
- proc = @s.rb_block_proc(&b)
- proc.should equal(b)
- proc.call.should == 2
- proc.lambda?.should == true
- end
- end
-
- describe "rb_block_lambda" do
- it "converts the implicit block into a lambda" do
- proc = @s.rb_block_lambda { 1+1 }
+ proc = @s.rb_block_proc() { 1+1 }
proc.should be_kind_of(Proc)
proc.call.should == 2
- proc.lambda?.should == true
- end
-
- it "passes through an existing Proc and does not convert to a lambda" do
- b = proc { 1+1 }
- proc = @s.rb_block_lambda(&b)
- proc.should equal(b)
- proc.call.should == 2
- proc.lambda?.should == false
end
end
@@ -574,7 +507,7 @@ describe "C-API Kernel function" do
@s.rb_funcall3(@obj, :method_public).should == :method_public
end
it "does not call a private method" do
- -> { @s.rb_funcall3(@obj, :method_private) }.should raise_error(NoMethodError, /private/)
+ lambda { @s.rb_funcall3(@obj, :method_private) }.should raise_error(NoMethodError, /private/)
end
end
@@ -593,7 +526,7 @@ describe "C-API Kernel function" do
end
it "does not call a private method" do
- -> { @s.rb_funcall_with_block(@obj, :method_private, proc { :result }) }.should raise_error(NoMethodError, /private/)
+ lambda { @s.rb_funcall_with_block(@obj, :method_private, proc { :result }) }.should raise_error(NoMethodError, /private/)
end
end
end
diff --git a/spec/ruby/optional/capi/marshal_spec.rb b/spec/ruby/optional/capi/marshal_spec.rb
index f15b6b705a..ee06f96b72 100644
--- a/spec/ruby/optional/capi/marshal_spec.rb
+++ b/spec/ruby/optional/capi/marshal_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("marshal")
diff --git a/spec/ruby/optional/capi/module_spec.rb b/spec/ruby/optional/capi/module_spec.rb
index bf09e9d8a5..fbb5bd690d 100644
--- a/spec/ruby/optional/capi/module_spec.rb
+++ b/spec/ruby/optional/capi/module_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'spec_helper'
-require_relative 'fixtures/module'
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/module', __FILE__)
load_extension('module')
compile_extension("module_under_autoload")
@@ -30,20 +30,6 @@ describe "CApiModule" do
}.should complain(/already initialized constant/)
CApiModuleSpecs::C::Z.should == 8
end
-
- it "allows arbitrary names, including constant names not valid in Ruby" do
- -> {
- CApiModuleSpecs::C.const_set(:_INVALID, 1)
- }.should raise_error(NameError, /wrong constant name/)
-
- @m.rb_const_set(CApiModuleSpecs::C, :_INVALID, 2)
- @m.rb_const_get(CApiModuleSpecs::C, :_INVALID).should == 2
-
- # Ruby-level should still not allow access
- -> {
- CApiModuleSpecs::C.const_get(:_INVALID)
- }.should raise_error(NameError, /wrong constant name/)
- end
end
describe "rb_define_module" do
@@ -54,7 +40,7 @@ describe "CApiModule" do
it "raises a TypeError if the constant is not a module" do
::CApiModuleSpecsGlobalConst = 7
- -> { @m.rb_define_module("CApiModuleSpecsGlobalConst") }.should raise_error(TypeError)
+ lambda { @m.rb_define_module("CApiModuleSpecsGlobalConst") }.should raise_error(TypeError)
Object.send :remove_const, :CApiModuleSpecsGlobalConst
end
@@ -154,16 +140,6 @@ describe "CApiModule" do
it "resolves autoload constants in Object" do
@m.rb_const_get(Object, :CApiModuleSpecsAutoload).should == 123
end
-
- it "allows arbitrary names, including constant names not valid in Ruby" do
- -> {
- CApiModuleSpecs::A.const_get(:_INVALID)
- }.should raise_error(NameError, /wrong constant name/)
-
- -> {
- @m.rb_const_get(CApiModuleSpecs::A, :_INVALID)
- }.should raise_error(NameError, /uninitialized constant/)
- end
end
describe "rb_const_get_from" do
@@ -303,7 +279,7 @@ describe "CApiModule" do
a = cls.new
@m.rb_define_singleton_method a, "module_specs_singleton_method"
a.module_specs_singleton_method.should == :test_method
- -> { cls.new.module_specs_singleton_method }.should raise_error(NoMethodError)
+ lambda { cls.new.module_specs_singleton_method }.should raise_error(NoMethodError)
end
end
@@ -322,13 +298,8 @@ describe "CApiModule" do
@class.should_not have_instance_method(:ruby_test_method)
end
- it "undefines private methods also" do
- @m.rb_undef_method @class, "initialize_copy"
- -> { @class.new.dup }.should raise_error(NoMethodError)
- end
-
it "does not raise exceptions when passed a missing name" do
- -> { @m.rb_undef_method @class, "not_exist" }.should_not raise_error
+ lambda { @m.rb_undef_method @class, "not_exist" }.should_not raise_error
end
describe "when given a frozen Class" do
@@ -336,12 +307,12 @@ describe "CApiModule" do
@frozen = @class.dup.freeze
end
- it "raises a #{frozen_error_class} when passed a name" do
- -> { @m.rb_undef_method @frozen, "ruby_test_method" }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed a name" do
+ lambda { @m.rb_undef_method @frozen, "ruby_test_method" }.should raise_error(RuntimeError)
end
- it "raises a #{frozen_error_class} when passed a missing name" do
- -> { @m.rb_undef_method @frozen, "not_exist" }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError when passed a missing name" do
+ lambda { @m.rb_undef_method @frozen, "not_exist" }.should raise_error(RuntimeError)
end
end
end
diff --git a/spec/ruby/optional/capi/mutex_spec.rb b/spec/ruby/optional/capi/mutex_spec.rb
index 34659974f5..c435d09eff 100644
--- a/spec/ruby/optional/capi/mutex_spec.rb
+++ b/spec/ruby/optional/capi/mutex_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("mutex")
@@ -46,14 +46,14 @@ describe "C-API Mutex functions" do
it "throws an exception when already locked in the same thread" do
@m.lock
- -> { @s.rb_mutex_lock(@m) }.should raise_error(ThreadError)
+ lambda { @s.rb_mutex_lock(@m) }.should raise_error(ThreadError)
@m.locked?.should be_true
end
end
describe "rb_mutex_unlock" do
it "raises an exception when not locked" do
- -> { @s.rb_mutex_unlock(@m) }.should raise_error(ThreadError)
+ lambda { @s.rb_mutex_unlock(@m) }.should raise_error(ThreadError)
@m.locked?.should be_false
end
@@ -66,23 +66,22 @@ describe "C-API Mutex functions" do
describe "rb_mutex_sleep" do
it "throws an exception when the mutex is not locked" do
- -> { @s.rb_mutex_sleep(@m, 0.1) }.should raise_error(ThreadError)
+ lambda { @s.rb_mutex_sleep(@m, 0.1) }.should raise_error(ThreadError)
@m.locked?.should be_false
end
it "sleeps when the mutex is locked" do
@m.lock
- t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- @s.rb_mutex_sleep(@m, 0.001)
- t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- (t2 - t1).should >= 0
+ start = Time.now
+ @s.rb_mutex_sleep(@m, 0.1)
+ (Time.now - start).should be_close(0.1, 0.2)
@m.locked?.should be_true
end
end
describe "rb_mutex_synchronize" do
it "calls the function while the mutex is locked" do
- callback = -> { @m.locked?.should be_true }
+ callback = lambda { @m.locked?.should be_true }
@s.rb_mutex_synchronize(@m, callback)
end
end
diff --git a/spec/ruby/optional/capi/numeric_spec.rb b/spec/ruby/optional/capi/numeric_spec.rb
index d76f353850..1d4a44d7a2 100644
--- a/spec/ruby/optional/capi/numeric_spec.rb
+++ b/spec/ruby/optional/capi/numeric_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("numeric")
@@ -7,131 +7,135 @@ describe "CApiNumericSpecs" do
@s = CApiNumericSpecs.new
end
- describe "NUM2INT" do
- it "raises a TypeError if passed nil" do
- -> { @s.NUM2INT(nil) }.should raise_error(TypeError)
- end
+ platform_is wordsize: 64 do
+ describe "rb_num2int" do
+ it "raises a TypeError if passed nil" do
+ lambda { @s.rb_num2int(nil) }.should raise_error(TypeError)
+ end
- it "converts a Float" do
- @s.NUM2INT(4.2).should == 4
- end
+ it "converts a Float" do
+ @s.rb_num2int(4.2).should == 4
+ end
- it "converts a Bignum" do
- @s.NUM2INT(0x7fff_ffff).should == 0x7fff_ffff
- end
+ it "converts a Bignum" do
+ @s.rb_num2int(0x7fff_ffff).should == 0x7fff_ffff
+ end
- it "converts a Fixnum" do
- @s.NUM2INT(5).should == 5
- end
+ it "converts a Fixnum" do
+ @s.rb_num2int(5).should == 5
+ end
- it "converts -1 to an signed number" do
- @s.NUM2INT(-1).should == -1
- end
+ it "converts -1 to an signed number" do
+ @s.rb_num2int(-1).should == -1
+ end
- it "converts a negative Bignum into an signed number" do
- @s.NUM2INT(-2147442171).should == -2147442171
- end
+ it "converts a negative Bignum into an signed number" do
+ @s.rb_num2int(-2147442171).should == -2147442171
+ end
- it "raises a RangeError if the value is more than 32bits" do
- -> { @s.NUM2INT(0xffff_ffff+1) }.should raise_error(RangeError)
- end
+ it "raises a RangeError if the value is more than 32bits" do
+ lambda { @s.rb_num2int(0xffff_ffff+1) }.should raise_error(RangeError)
+ end
- it "calls #to_int to coerce the value" do
- obj = mock("number")
- obj.should_receive(:to_int).and_return(2)
- @s.NUM2INT(obj).should == 2
+ it "calls #to_int to coerce the value" do
+ obj = mock("number")
+ obj.should_receive(:to_int).and_return(2)
+ @s.rb_num2long(obj).should == 2
+ end
end
end
- describe "NUM2UINT" do
- it "raises a TypeError if passed nil" do
- -> { @s.NUM2UINT(nil) }.should raise_error(TypeError)
- end
+ platform_is wordsize: 64 do
+ describe "rb_num2uint" do
+ it "raises a TypeError if passed nil" do
+ lambda { @s.rb_num2uint(nil) }.should raise_error(TypeError)
+ end
- it "converts a Float" do
- @s.NUM2UINT(4.2).should == 4
- end
+ it "converts a Float" do
+ @s.rb_num2uint(4.2).should == 4
+ end
- it "converts a Bignum" do
- @s.NUM2UINT(0xffff_ffff).should == 0xffff_ffff
- end
+ it "converts a Bignum" do
+ @s.rb_num2uint(0xffff_ffff).should == 0xffff_ffff
+ end
- it "converts a Fixnum" do
- @s.NUM2UINT(5).should == 5
- end
+ it "converts a Fixnum" do
+ @s.rb_num2uint(5).should == 5
+ end
- it "converts a negative number to the complement" do
- @s.NUM2UINT(-1).should == 4294967295
- end
+ it "converts a negative number to the complement" do
+ @s.rb_num2uint(-1).should == 18446744073709551615
+ end
- it "converts a signed int value to the complement" do
- @s.NUM2UINT(-0x8000_0000).should == 2147483648
- end
+ it "converts a signed int value to the complement" do
+ @s.rb_num2uint(-0x8000_0000).should == 18446744071562067968
+ end
- it "raises a RangeError if the value is more than 32bits" do
- -> { @s.NUM2UINT(0xffff_ffff+1) }.should raise_error(RangeError)
- end
+ it "raises a RangeError if the value is more than 32bits" do
+ lambda { @s.rb_num2uint(0xffff_ffff+1) }.should raise_error(RangeError)
+ end
- it "raises a RangeError if the value is less than 32bits negative" do
- -> { @s.NUM2UINT(-0x8000_0000-1) }.should raise_error(RangeError)
- end
+ it "raises a RangeError if the value is less than 32bits negative" do
+ lambda { @s.rb_num2uint(-0x8000_0000-1) }.should raise_error(RangeError)
+ end
- it "raises a RangeError if the value is more than 64bits" do
- -> do
- @s.NUM2UINT(0xffff_ffff_ffff_ffff+1)
- end.should raise_error(RangeError)
- end
+ it "raises a RangeError if the value is more than 64bits" do
+ lambda do
+ @s.rb_num2uint(0xffff_ffff_ffff_ffff+1)
+ end.should raise_error(RangeError)
+ end
- it "calls #to_int to coerce the value" do
- obj = mock("number")
- obj.should_receive(:to_int).and_return(2)
- @s.NUM2UINT(obj).should == 2
+ it "calls #to_int to coerce the value" do
+ obj = mock("number")
+ obj.should_receive(:to_int).and_return(2)
+ @s.rb_num2uint(obj).should == 2
+ end
end
end
- describe "NUM2LONG" do
+ describe "rb_num2long" do
it "raises a TypeError if passed nil" do
- -> { @s.NUM2LONG(nil) }.should raise_error(TypeError)
+ lambda { @s.rb_num2long(nil) }.should raise_error(TypeError)
end
it "converts a Float" do
- @s.NUM2LONG(4.2).should == 4
+ @s.rb_num2long(4.2).should == 4
end
it "converts a Bignum" do
- @s.NUM2LONG(0x7fff_ffff).should == 0x7fff_ffff
+ @s.rb_num2long(0x7fff_ffff).should == 0x7fff_ffff
end
it "converts a Fixnum" do
- @s.NUM2LONG(5).should == 5
+ @s.rb_num2long(5).should == 5
end
platform_is wordsize: 32 do
it "converts -1 to an signed number" do
- @s.NUM2LONG(-1).should == -1
+ @s.rb_num2long(-1).should == -1
end
it "converts a negative Bignum into an signed number" do
- @s.NUM2LONG(-2147442171).should == -2147442171
+ @s.rb_num2long(-2147442171).should == -2147442171
end
it "raises a RangeError if the value is more than 32bits" do
- -> { @s.NUM2LONG(0xffff_ffff+1) }.should raise_error(RangeError)
+ lambda { @s.rb_num2long(0xffff_ffff+1) }.should raise_error(RangeError)
end
end
platform_is wordsize: 64 do
it "converts -1 to an signed number" do
- @s.NUM2LONG(-1).should == -1
+ @s.rb_num2long(-1).should == -1
end
it "converts a negative Bignum into an signed number" do
- @s.NUM2LONG(-9223372036854734331).should == -9223372036854734331
+ @s.rb_num2long(-9223372036854734331).should == -9223372036854734331
end
it "raises a RangeError if the value is more than 64bits" do
- -> do
- @s.NUM2LONG(0xffff_ffff_ffff_ffff+1)
+ lambda do
+ @s.rb_num2long(0xffff_ffff_ffff_ffff+1)
end.should raise_error(RangeError)
end
end
@@ -139,89 +143,75 @@ describe "CApiNumericSpecs" do
it "calls #to_int to coerce the value" do
obj = mock("number")
obj.should_receive(:to_int).and_return(2)
- @s.NUM2LONG(obj).should == 2
+ @s.rb_num2long(obj).should == 2
end
end
- describe "INT2NUM" do
+ describe "rb_int2num" do
it "raises a TypeError if passed nil" do
- -> { @s.INT2NUM(nil) }.should raise_error(TypeError)
+ lambda { @s.rb_int2num(nil) }.should raise_error(TypeError)
end
it "converts a Float" do
- @s.INT2NUM(4.2).should == 4
+ @s.rb_int2num(4.2).should == 4
end
it "raises a RangeError when passed a Bignum" do
- -> { @s.INT2NUM(bignum_value) }.should raise_error(RangeError)
+ lambda { @s.rb_int2num(bignum_value) }.should raise_error(RangeError)
end
it "converts a Fixnum" do
- @s.INT2NUM(5).should == 5
+ @s.rb_int2num(5).should == 5
end
it "converts a negative Fixnum" do
- @s.INT2NUM(-11).should == -11
+ @s.rb_int2num(-11).should == -11
end
end
- describe "NUM2ULONG" do
+ describe "rb_num2ulong" do
it "raises a TypeError if passed nil" do
- -> { @s.NUM2ULONG(nil) }.should raise_error(TypeError)
+ lambda { @s.rb_num2ulong(nil) }.should raise_error(TypeError)
end
it "converts a Float" do
- @s.NUM2ULONG(4.2).should == 4
+ @s.rb_num2ulong(4.2).should == 4
end
it "converts a Bignum" do
- @s.NUM2ULONG(0xffff_ffff).should == 0xffff_ffff
+ @s.rb_num2ulong(0xffff_ffff).should == 0xffff_ffff
end
it "converts a Fixnum" do
- @s.NUM2ULONG(5).should == 5
+ @s.rb_num2ulong(5).should == 5
end
platform_is wordsize: 32 do
it "converts -1 to an unsigned number" do
- @s.NUM2ULONG(-1).should == 4294967295
+ @s.rb_num2ulong(-1).should == 4294967295
end
it "converts a negative Bignum into an unsigned number" do
- @s.NUM2ULONG(-2147442171).should == 2147525125
- end
-
- it "converts positive Bignums if the values is less than 64bits" do
- @s.NUM2ULONG(0xffff_ffff).should == 0xffff_ffff
- @s.NUM2ULONG(2**30).should == 2**30
- @s.NUM2ULONG(fixnum_max+1).should == fixnum_max+1
- @s.NUM2ULONG(fixnum_max).should == fixnum_max
+ @s.rb_num2ulong(-2147442171).should == 2147525125
end
it "raises a RangeError if the value is more than 32bits" do
- -> { @s.NUM2ULONG(0xffff_ffff+1) }.should raise_error(RangeError)
+ lambda { @s.rb_num2ulong(0xffff_ffff+1) }.should raise_error(RangeError)
end
end
platform_is wordsize: 64 do
it "converts -1 to an unsigned number" do
- @s.NUM2ULONG(-1).should == 18446744073709551615
+ @s.rb_num2ulong(-1).should == 18446744073709551615
end
it "converts a negative Bignum into an unsigned number" do
- @s.NUM2ULONG(-9223372036854734331).should == 9223372036854817285
- end
-
- it "converts positive Bignums if the values is less than 64bits" do
- @s.NUM2ULONG(0xffff_ffff_ffff_ffff).should == 0xffff_ffff_ffff_ffff
- @s.NUM2ULONG(2**62).should == 2**62
- @s.NUM2ULONG(fixnum_max+1).should == fixnum_max+1
- @s.NUM2ULONG(fixnum_max).should == fixnum_max
+ @s.rb_num2ulong(-9223372036854734331).should == 9223372036854817285
end
it "raises a RangeError if the value is more than 64bits" do
- -> do
- @s.NUM2ULONG(0xffff_ffff_ffff_ffff+1)
+ lambda do
+ @s.rb_num2ulong(0xffff_ffff_ffff_ffff+1)
end.should raise_error(RangeError)
end
end
@@ -229,12 +219,12 @@ describe "CApiNumericSpecs" do
it "calls #to_int to coerce the value" do
obj = mock("number")
obj.should_receive(:to_int).and_return(2)
- @s.NUM2ULONG(obj).should == 2
+ @s.rb_num2ulong(obj).should == 2
end
end
describe "rb_Integer" do
- it "creates an Integer from a String" do
+ it "creates a new Integer from a String" do
i = @s.rb_Integer("8675309")
i.should be_kind_of(Integer)
i.should eql(8675309)
@@ -242,74 +232,46 @@ describe "CApiNumericSpecs" do
end
describe "rb_ll2inum" do
- it "creates a Fixnum from a small signed long long" do
+ it "creates a new Fixnum from a small signed long long" do
i = @s.rb_ll2inum_14()
i.should be_kind_of(Fixnum)
i.should eql(14)
end
end
- describe "rb_ull2inum" do
- it "creates a Fixnum from a small unsigned long long" do
- i = @s.rb_ull2inum_14()
- i.should be_kind_of(Fixnum)
- i.should eql(14)
- end
-
- it "creates a positive Bignum from a negative long long" do
- i = @s.rb_ull2inum_n14()
- i.should be_kind_of(Bignum)
- i.should eql(2 ** (@s.size_of_long_long * 8) - 14)
- end
- end
-
describe "rb_int2inum" do
- it "creates a Fixnum from a long" do
+ it "creates a new Fixnum from a long" do
i = @s.rb_int2inum_14()
i.should be_kind_of(Fixnum)
i.should eql(14)
end
end
- describe "rb_uint2inum" do
- it "creates a Fixnum from a long" do
- i = @s.rb_uint2inum_14()
- i.should be_kind_of(Fixnum)
- i.should eql(14)
- end
-
- it "creates a positive Bignum from a negative long" do
- i = @s.rb_uint2inum_n14()
- i.should be_kind_of(Bignum)
- i.should eql(2 ** (@s.size_of_VALUE * 8) - 14)
- end
- end
-
- describe "NUM2DBL" do
+ describe "rb_num2dbl" do
it "raises a TypeError if passed nil" do
- -> { @s.NUM2DBL(nil) }.should raise_error(TypeError)
+ lambda { @s.rb_num2dbl(nil) }.should raise_error(TypeError)
end
it "raises a TypeError if passed a String" do
- -> { @s.NUM2DBL("1.2") }.should raise_error(TypeError)
+ lambda { @s.rb_num2dbl("1.2") }.should raise_error(TypeError)
end
it "converts a Float" do
- @s.NUM2DBL(4.2).should == 4.2
+ @s.rb_num2dbl(4.2).should == 4.2
end
it "converts a Bignum" do
- @s.NUM2DBL(2**70).should == (2**70).to_f
+ @s.rb_num2dbl(2**70).should == (2**70).to_f
end
it "converts a Fixnum" do
- @s.NUM2DBL(5).should == 5.0
+ @s.rb_num2dbl(5).should == 5.0
end
it "calls #to_f to coerce the value" do
obj = mock("number")
obj.should_receive(:to_f).and_return(2.0)
- @s.NUM2DBL(obj).should == 2.0
+ @s.rb_num2dbl(obj).should == 2.0
end
end
@@ -327,13 +289,13 @@ describe "CApiNumericSpecs" do
end
it "raises a TypeError when passed an empty String" do
- -> { @s.NUM2CHR("") }.should raise_error(TypeError)
+ lambda { @s.NUM2CHR("") }.should raise_error(TypeError)
end
end
describe "rb_num_zerodiv" do
it "raises a RuntimeError" do
- -> { @s.rb_num_zerodiv() }.should raise_error(ZeroDivisionError, 'divided by 0')
+ lambda { @s.rb_num_zerodiv() }.should raise_error(ZeroDivisionError, 'divided by 0')
end
end
@@ -363,7 +325,7 @@ describe "CApiNumericSpecs" do
end
it "raises an ArgumentError when passed nil" do
- -> {
+ lambda {
@s.rb_cmpint(nil, 4)
}.should raise_error(ArgumentError)
end
@@ -389,7 +351,7 @@ describe "CApiNumericSpecs" do
obj = mock("rb_num_coerce_bin")
obj.should_receive(:coerce).with(2).and_return(nil)
- -> { @s.rb_num_coerce_bin(2, obj, :+) }.should raise_error(TypeError)
+ lambda { @s.rb_num_coerce_bin(2, obj, :+) }.should raise_error(TypeError)
end
end
@@ -457,14 +419,14 @@ describe "CApiNumericSpecs" do
obj.should_receive(:coerce).with(2).and_return([obj, 2])
obj.should_receive(:<).with(2).and_return(nil)
- -> { @s.rb_num_coerce_relop(2, obj, :<) }.should raise_error(ArgumentError)
+ lambda { @s.rb_num_coerce_relop(2, obj, :<) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if #coerce does not return an Array" do
obj = mock("rb_num_coerce_relop")
obj.should_receive(:coerce).with(2).and_return(nil)
- -> { @s.rb_num_coerce_relop(2, obj, :<) }.should raise_error(ArgumentError)
+ lambda { @s.rb_num_coerce_relop(2, obj, :<) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/optional/capi/object_spec.rb b/spec/ruby/optional/capi/object_spec.rb
index 30abe715e7..97bff38ec0 100644
--- a/spec/ruby/optional/capi/object_spec.rb
+++ b/spec/ruby/optional/capi/object_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("object")
@@ -230,7 +230,7 @@ describe "CApiObject" do
obj = mock("rb_check_convert_type")
obj.should_receive(:to_array).and_return("string")
- -> do
+ lambda do
@o.rb_check_convert_type(obj, "Array", "to_array")
end.should raise_error(TypeError)
end
@@ -255,7 +255,7 @@ describe "CApiObject" do
obj = mock("rb_convert_type")
obj.should_receive(:to_array).and_return(nil)
- -> do
+ lambda do
@o.rb_convert_type(obj, "Array", "to_array")
end.should raise_error(TypeError)
end
@@ -264,7 +264,7 @@ describe "CApiObject" do
obj = mock("rb_convert_type")
obj.should_receive(:to_array).and_return("string")
- -> do
+ lambda do
@o.rb_convert_type(obj, "Array", "to_array")
end.should raise_error(TypeError)
end
@@ -308,13 +308,13 @@ describe "CApiObject" do
it "sends #to_ary to the argument and raises TypeError if it's not a kind of Array" do
obj = mock("to_ary")
obj.should_receive(:to_ary).and_return(Object.new)
- -> { @o.rb_check_array_type obj }.should raise_error(TypeError)
+ lambda { @o.rb_check_array_type obj }.should raise_error(TypeError)
end
it "does not rescue exceptions raised by #to_ary" do
obj = mock("to_ary")
- obj.should_receive(:to_ary).and_raise(frozen_error_class)
- -> { @o.rb_check_array_type obj }.should raise_error(frozen_error_class)
+ obj.should_receive(:to_ary).and_raise(RuntimeError)
+ lambda { @o.rb_check_array_type obj }.should raise_error(RuntimeError)
end
end
@@ -356,13 +356,13 @@ describe "CApiObject" do
it "sends #to_str to the argument and raises TypeError if it's not a kind of String" do
obj = mock("to_str")
obj.should_receive(:to_str).and_return(Object.new)
- -> { @o.rb_check_string_type obj }.should raise_error(TypeError)
+ lambda { @o.rb_check_string_type obj }.should raise_error(TypeError)
end
it "does not rescue exceptions raised by #to_str" do
obj = mock("to_str")
obj.should_receive(:to_str).and_raise(RuntimeError)
- -> { @o.rb_check_string_type obj }.should raise_error(RuntimeError)
+ lambda { @o.rb_check_string_type obj }.should raise_error(RuntimeError)
end
end
@@ -414,13 +414,11 @@ describe "CApiObject" do
end
describe "FL_TEST" do
- ruby_version_is ''...'2.7' do
- it "returns correct status for FL_TAINT" do
- obj = Object.new
- @o.FL_TEST(obj, "FL_TAINT").should == 0
- obj.taint
- @o.FL_TEST(obj, "FL_TAINT").should_not == 0
- end
+ it "returns correct status for FL_TAINT" do
+ obj = Object.new
+ @o.FL_TEST(obj, "FL_TAINT").should == 0
+ obj.taint
+ @o.FL_TEST(obj, "FL_TAINT").should_not == 0
end
it "returns correct status for FL_FREEZE" do
@@ -572,67 +570,61 @@ describe "CApiObject" do
end
describe "OBJ_TAINT" do
- ruby_version_is ''...'2.7' do
- it "taints the object" do
- obj = mock("tainted")
- @o.OBJ_TAINT(obj)
- obj.tainted?.should be_true
- end
+ it "taints the object" do
+ obj = mock("tainted")
+ @o.OBJ_TAINT(obj)
+ obj.tainted?.should be_true
end
end
describe "OBJ_TAINTED" do
- ruby_version_is ''...'2.7' do
- it "returns C true if the object is tainted" do
- obj = mock("tainted")
- obj.taint
- @o.OBJ_TAINTED(obj).should be_true
- end
+ it "returns C true if the object is tainted" do
+ obj = mock("tainted")
+ obj.taint
+ @o.OBJ_TAINTED(obj).should be_true
+ end
- it "returns C false if the object is not tainted" do
- obj = mock("untainted")
- @o.OBJ_TAINTED(obj).should be_false
- end
+ it "returns C false if the object is not tainted" do
+ obj = mock("untainted")
+ @o.OBJ_TAINTED(obj).should be_false
end
end
describe "OBJ_INFECT" do
- ruby_version_is ''...'2.7' do
- it "does not taint the first argument if the second argument is not tainted" do
- host = mock("host")
- source = mock("source")
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_false
- end
+ it "does not taint the first argument if the second argument is not tainted" do
+ host = mock("host")
+ source = mock("source")
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_false
+ end
- it "taints the first argument if the second argument is tainted" do
- host = mock("host")
- source = mock("source").taint
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_true
- end
+ it "taints the first argument if the second argument is tainted" do
+ host = mock("host")
+ source = mock("source").taint
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_true
+ end
- it "does not untrust the first argument if the second argument is trusted" do
- host = mock("host")
- source = mock("source")
- @o.OBJ_INFECT(host, source)
- host.untrusted?.should be_false
- end
+ it "does not untrust the first argument if the second argument is trusted" do
+ host = mock("host")
+ source = mock("source")
+ @o.OBJ_INFECT(host, source)
+ host.untrusted?.should be_false
+ end
- it "untrusts the first argument if the second argument is untrusted" do
- host = mock("host")
- source = mock("source").untrust
- @o.OBJ_INFECT(host, source)
- host.untrusted?.should be_true
- end
+ it "untrusts the first argument if the second argument is untrusted" do
+ host = mock("host")
+ source = mock("source").untrust
+ @o.OBJ_INFECT(host, source)
+ host.untrusted?.should be_true
+ end
- it "propagates both taint and distrust" do
- host = mock("host")
- source = mock("source").taint.untrust
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_true
- host.untrusted?.should be_true
- end
+ it "propagates both taint and distrust" do
+ host = mock("host")
+ source = mock("source").taint.untrust
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_true
+ host.untrusted?.should be_true
end
end
@@ -647,7 +639,7 @@ describe "CApiObject" do
describe "rb_obj_instance_eval" do
it "evaluates the block in the object context, that includes private methods" do
obj = ObjectTest
- -> do
+ lambda do
@o.rb_obj_instance_eval(obj) { include Kernel }
end.should_not raise_error(NoMethodError)
end
@@ -667,28 +659,26 @@ describe "CApiObject" do
end
describe "rb_obj_taint" do
- ruby_version_is ''...'2.7' do
- it "marks the object passed as tainted" do
- obj = ""
- obj.tainted?.should == false
- @o.rb_obj_taint(obj)
- obj.tainted?.should == true
- end
+ it "marks the object passed as tainted" do
+ obj = ""
+ obj.tainted?.should == false
+ @o.rb_obj_taint(obj)
+ obj.tainted?.should == true
+ end
- it "raises a #{frozen_error_class} if the object passed is frozen" do
- -> { @o.rb_obj_taint("".freeze) }.should raise_error(frozen_error_class)
- end
+ it "raises a RuntimeError if the object passed is frozen" do
+ lambda { @o.rb_obj_taint("".freeze) }.should raise_error(RuntimeError)
end
end
describe "rb_check_frozen" do
- it "raises a #{frozen_error_class} if the obj is frozen" do
- -> { @o.rb_check_frozen("".freeze) }.should raise_error(frozen_error_class)
+ it "raises a RuntimeError if the obj is frozen" do
+ lambda { @o.rb_check_frozen("".freeze) }.should raise_error(RuntimeError)
end
it "does nothing when object isn't frozen" do
obj = ""
- -> { @o.rb_check_frozen(obj) }.should_not raise_error(TypeError)
+ lambda { @o.rb_check_frozen(obj) }.should_not raise_error(TypeError)
end
end
@@ -728,23 +718,23 @@ describe "CApiObject" do
it "raises a TypeError if #to_int does not return an Integer" do
x = mock("to_int")
x.should_receive(:to_int).and_return("5")
- -> { @o.rb_to_int(x) }.should raise_error(TypeError)
+ lambda { @o.rb_to_int(x) }.should raise_error(TypeError)
end
it "raises a TypeError if called with nil" do
- -> { @o.rb_to_int(nil) }.should raise_error(TypeError)
+ lambda { @o.rb_to_int(nil) }.should raise_error(TypeError)
end
it "raises a TypeError if called with true" do
- -> { @o.rb_to_int(true) }.should raise_error(TypeError)
+ lambda { @o.rb_to_int(true) }.should raise_error(TypeError)
end
it "raises a TypeError if called with false" do
- -> { @o.rb_to_int(false) }.should raise_error(TypeError)
+ lambda { @o.rb_to_int(false) }.should raise_error(TypeError)
end
it "raises a TypeError if called with a String" do
- -> { @o.rb_to_int("1") }.should raise_error(TypeError)
+ lambda { @o.rb_to_int("1") }.should raise_error(TypeError)
end
end
@@ -780,7 +770,7 @@ describe "CApiObject" do
end
it "raises a TypeError if arg is no class or module" do
- ->{
+ lambda{
@o.rb_class_inherited_p(1, 2)
}.should raise_error(TypeError)
end
@@ -823,15 +813,6 @@ describe "CApiObject" do
it "returns nil if the instance variable has not been initialized" do
@o.rb_ivar_get(@test, :@bar).should == nil
end
-
- it "returns nil if the instance variable has not been initialized and is not a valid Ruby name" do
- @o.rb_ivar_get(@test, :bar).should == nil
- end
-
- it 'returns the instance variable when it is not a valid Ruby name' do
- @o.rb_ivar_set(@test, :foo, 27)
- @o.rb_ivar_get(@test, :foo).should == 27
- end
end
describe "rb_ivar_set" do
@@ -839,15 +820,6 @@ describe "CApiObject" do
@o.rb_ivar_set(@test, :@foo, 42).should == 42
@test.instance_eval { @foo }.should == 42
end
-
- it "sets and returns the instance variable on an object" do
- @o.rb_ivar_set(@test, :@foo, 42).should == 42
- @test.instance_eval { @foo }.should == 42
- end
-
- it 'sets and returns the instance variable when it is not a valid Ruby name' do
- @o.rb_ivar_set(@test, :foo, 27).should == 27
- end
end
describe "rb_ivar_defined" do
@@ -858,33 +830,6 @@ describe "CApiObject" do
it "returns false if the instance variable is not defined" do
@o.rb_ivar_defined(@test, :@bar).should == false
end
-
- it "does not throw an error if the instance variable is not a valid Ruby name" do
- @o.rb_ivar_defined(@test, :bar).should == false
- end
- end
-
- # The `generic_iv_tbl` table and `*_generic_ivar` functions are for mutable
- # objects which do not store ivars directly in MRI such as RString, because
- # there is no member iv_index_tbl (ivar table) such as in RObject and RClass.
-
- describe "rb_copy_generic_ivar for objects which do not store ivars directly" do
- it "copies the instance variables from one object to another" do
- original = "abc"
- original.instance_variable_set(:@foo, :bar)
- clone = "def"
- @o.rb_copy_generic_ivar(clone, original)
- clone.instance_variable_get(:@foo).should == :bar
- end
- end
-
- describe "rb_free_generic_ivar for objects which do not store ivars directly" do
- it "removes the instance variables from an object" do
- o = "abc"
- o.instance_variable_set(:@baz, :flibble)
- @o.rb_free_generic_ivar(o)
- o.instance_variables.should == []
- end
end
end
end
diff --git a/spec/ruby/optional/capi/proc_spec.rb b/spec/ruby/optional/capi/proc_spec.rb
index 9f9a37cc98..ca6163b574 100644
--- a/spec/ruby/optional/capi/proc_spec.rb
+++ b/spec/ruby/optional/capi/proc_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'spec_helper'
-require_relative 'fixtures/proc'
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../fixtures/proc', __FILE__)
load_extension("proc")
@@ -69,44 +69,40 @@ describe "C-API when calling Proc.new from a C function" do
# For example: C -> Ruby <- C -> Ruby means a C function called into Ruby
# code which returned to C, then C called into Ruby code again.
- ruby_version_is ""..."2.7" do
- # Ruby -> C -> rb_funcall(Proc.new)
- it "returns the Proc passed by the Ruby code calling the C function" do
- prc = @p.rb_Proc_new(0) { :called }
- prc.call.should == :called
- end
+ # Ruby -> C -> rb_funcall(Proc.new)
+ it "returns the Proc passed by the Ruby code calling the C function" do
+ prc = @p.rb_Proc_new(0) { :called }
+ prc.call.should == :called
+ end
- # Ruby -> C -> Ruby <- C -> rb_funcall(Proc.new)
- it "returns the Proc passed to the Ruby method when the C function calls other Ruby methods before calling Proc.new" do
- prc = @p.rb_Proc_new(1) { :called }
- prc.call.should == :called
- end
+ # Ruby -> C -> Ruby <- C -> rb_funcall(Proc.new)
+ it "returns the Proc passed to the Ruby method when the C function calls other Ruby methods before calling Proc.new" do
+ prc = @p.rb_Proc_new(1) { :called }
+ prc.call.should == :called
end
# Ruby -> C -> Ruby -> Proc.new
it "raises an ArgumentError when the C function calls a Ruby method that calls Proc.new" do
def @p.Proc_new() Proc.new end
- -> { @p.rb_Proc_new(2) { :called } }.should raise_error(ArgumentError)
+ lambda { @p.rb_Proc_new(2) { :called } }.should raise_error(ArgumentError)
end
# Ruby -> C -> Ruby -> C -> rb_funcall(Proc.new)
it "raises an ArgumentError when the C function calls a Ruby method and that method calls a C function that calls Proc.new" do
def @p.redispatch() rb_Proc_new(0) end
- -> { @p.rb_Proc_new(3) { :called } }.should raise_error(ArgumentError)
+ lambda { @p.rb_Proc_new(3) { :called } }.should raise_error(ArgumentError)
end
- ruby_version_is ""..."2.7" do
- # Ruby -> C -> Ruby -> C (with new block) -> rb_funcall(Proc.new)
- it "returns the most recent Proc passed when the Ruby method called the C function" do
- prc = @p.rb_Proc_new(4) { :called }
- prc.call.should == :calling_with_block
- end
+ # Ruby -> C -> Ruby -> C (with new block) -> rb_funcall(Proc.new)
+ it "returns the most recent Proc passed when the Ruby method called the C function" do
+ prc = @p.rb_Proc_new(4) { :called }
+ prc.call.should == :calling_with_block
+ end
- # Ruby -> C -> Ruby -> C (with new block) <- Ruby <- C -> # rb_funcall(Proc.new)
- it "returns the Proc passed from the original Ruby call to the C function" do
- prc = @p.rb_Proc_new(5) { :called }
- prc.call.should == :called
- end
+ # Ruby -> C -> Ruby -> C (with new block) <- Ruby <- C -> # rb_funcall(Proc.new)
+ it "returns the Proc passed from the original Ruby call to the C function" do
+ prc = @p.rb_Proc_new(5) { :called }
+ prc.call.should == :called
end
# Ruby -> C -> Ruby -> block_given?
diff --git a/spec/ruby/optional/capi/rake_helper.rb b/spec/ruby/optional/capi/rake_helper.rb
index c13f1189c5..2b7a6ccbe3 100644
--- a/spec/ruby/optional/capi/rake_helper.rb
+++ b/spec/ruby/optional/capi/rake_helper.rb
@@ -20,3 +20,4 @@ task default: [output]
file output => [input] do
sh build_cmd
end
+
diff --git a/spec/ruby/optional/capi/range_spec.rb b/spec/ruby/optional/capi/range_spec.rb
index 7a52dc7ff8..aa16f9773e 100644
--- a/spec/ruby/optional/capi/range_spec.rb
+++ b/spec/ruby/optional/capi/range_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("range")
@@ -31,8 +31,8 @@ describe "C-API Range function" do
end
it "raises an ArgumentError when the given start and end can't be compared by using #<=>" do
- -> { @s.rb_range_new(1, mock('x')) }.should raise_error(ArgumentError)
- -> { @s.rb_range_new(mock('x'), mock('y')) }.should raise_error(ArgumentError)
+ lambda { @s.rb_range_new(1, mock('x')) }.should raise_error(ArgumentError)
+ lambda { @s.rb_range_new(mock('x'), mock('y')) }.should raise_error(ArgumentError)
end
end
@@ -83,7 +83,7 @@ describe "C-API Range function" do
it "raises a RangeError when not in range and err is 1" do
r = -5..-1
- -> { @s.rb_range_beg_len(r, 0, 0, 1, 1) }.should raise_error(RangeError)
+ lambda { @s.rb_range_beg_len(r, 0, 0, 1, 1) }.should raise_error(RangeError)
end
it "returns nil when not in range and err is 0" do
diff --git a/spec/ruby/optional/capi/rational_spec.rb b/spec/ruby/optional/capi/rational_spec.rb
index 1c241ac48e..e3144666d3 100644
--- a/spec/ruby/optional/capi/rational_spec.rb
+++ b/spec/ruby/optional/capi/rational_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("rational")
diff --git a/spec/ruby/optional/capi/regexp_spec.rb b/spec/ruby/optional/capi/regexp_spec.rb
index 52aae6bb01..27b1627c50 100644
--- a/spec/ruby/optional/capi/regexp_spec.rb
+++ b/spec/ruby/optional/capi/regexp_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("regexp")
diff --git a/spec/ruby/optional/capi/spec_helper.rb b/spec/ruby/optional/capi/spec_helper.rb
index eda4964b69..373012a869 100644
--- a/spec/ruby/optional/capi/spec_helper.rb
+++ b/spec/ruby/optional/capi/spec_helper.rb
@@ -1,4 +1,4 @@
-# Require the main spec_helper.rb at the end to let `ruby ...spec.rb` work
+require File.expand_path('../../../spec_helper', __FILE__)
# MRI magic to use built but not installed ruby
$extmk = false
@@ -6,9 +6,13 @@ $extmk = false
require 'rbconfig'
OBJDIR ||= File.expand_path("../../../ext/#{RUBY_ENGINE}/#{RUBY_VERSION}", __FILE__)
+mkdir_p(OBJDIR)
+
+def extension_path
+ File.expand_path("../ext", __FILE__)
+end
def object_path
- mkdir_p(OBJDIR)
OBJDIR
end
@@ -16,45 +20,29 @@ def compile_extension(name)
debug = false
run_mkmf_in_process = RUBY_ENGINE == 'truffleruby'
- core_ext_dir = File.expand_path("../ext", __FILE__)
-
- spec_caller_location = caller_locations.find { |c| c.path.end_with?('_spec.rb') }
- spec_file_path = spec_caller_location.path
- spec_ext_dir = File.expand_path("../ext", spec_file_path)
-
ext = "#{name}_spec"
lib = "#{object_path}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"
ruby_header = "#{RbConfig::CONFIG['rubyhdrdir']}/ruby.h"
-
- if RbConfig::CONFIG["ENABLE_SHARED"] == "yes"
- if PlatformGuard.windows?
- libruby_so = "#{RbConfig::CONFIG['bindir']}/#{RbConfig::CONFIG['LIBRUBY_SO']}"
- else
- libruby_so = "#{RbConfig::CONFIG['libdir']}/#{RbConfig::CONFIG['LIBRUBY_SO']}"
- end
+ libruby_so = RbConfig::CONFIG['LIBRUBY_SO']
+ ruby_library = "#{RbConfig::CONFIG['libdir']}/#{libruby_so}"
+ unless libruby_so and File.exist?(ruby_library)
+ # Statically-compiled lib in the binary, ignore this check
+ ruby_library = nil
end
- begin
- mtime = File.mtime(lib)
- rescue Errno::ENOENT
- # not found, then compile
- else
- case # if lib is older than headers, source or libruby, then recompile
- when mtime <= File.mtime("#{core_ext_dir}/rubyspec.h")
- when mtime <= File.mtime("#{spec_ext_dir}/#{ext}.c")
- when mtime <= File.mtime(ruby_header)
- when libruby_so && mtime <= File.mtime(libruby_so)
- else
- return lib # up-to-date
- end
- end
+ return lib if File.exist?(lib) and
+ File.mtime(lib) > File.mtime("#{extension_path}/rubyspec.h") and
+ File.mtime(lib) > File.mtime("#{extension_path}/#{ext}.c") and
+ File.mtime(lib) > File.mtime(ruby_header) and
+ (!ruby_library || File.mtime(lib) > File.mtime(ruby_library)) and
+ true # sentinel
# Copy needed source files to tmpdir
tmpdir = tmp("cext_#{name}")
Dir.mkdir(tmpdir)
begin
- ["#{core_ext_dir}/rubyspec.h", "#{spec_ext_dir}/#{ext}.c"].each do |file|
- cp file, "#{tmpdir}/#{File.basename(file)}"
+ ["rubyspec.h", "#{ext}.c"].each do |file|
+ cp "#{extension_path}/#{file}", "#{tmpdir}/#{file}"
end
Dir.chdir(tmpdir) do
@@ -117,8 +105,8 @@ end
def load_extension(name)
require compile_extension(name)
-rescue LoadError => e
- if %r{/usr/sbin/execerror ruby "\(ld 3 1 main ([/a-zA-Z0-9_\-.]+_spec\.so)"} =~ e.message
+rescue LoadError
+ if %r{/usr/sbin/execerror ruby "\(ld 3 1 main ([/a-zA-Z0-9_\-.]+_spec\.so)"} =~ $!.message
system('/usr/sbin/execerror', "#{RbConfig::CONFIG["bindir"]}/ruby", "(ld 3 1 main #{$1}")
end
raise
@@ -126,7 +114,3 @@ end
# Constants
CAPI_SIZEOF_LONG = [0].pack('l!').size
-
-# Require the main spec_helper.rb only here so load_extension() is defined
-# when running specs with `ruby ...spec.rb`
-require_relative '../../spec_helper'
diff --git a/spec/ruby/optional/capi/st_spec.rb b/spec/ruby/optional/capi/st_spec.rb
index 8ca2950d83..7f2bc08c62 100644
--- a/spec/ruby/optional/capi/st_spec.rb
+++ b/spec/ruby/optional/capi/st_spec.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension('st')
diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb
index 1ad35b9e8a..73e6deb498 100644
--- a/spec/ruby/optional/capi/string_spec.rb
+++ b/spec/ruby/optional/capi/string_spec.rb
@@ -1,33 +1,9 @@
# encoding: utf-8
-require_relative 'spec_helper'
-require_relative '../../shared/string/times'
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../../../shared/string/times', __FILE__)
load_extension('string')
-class CApiStringSpecs
- class ValidTostrTest
- def to_str
- "ruby"
- end
- end
-
- class InvalidTostrTest
- def to_str
- []
- end
- end
-
- class ToSOrInspect
- def to_s
- 'A string'
- end
-
- def inspect
- 'A different string'
- end
- end
-end
-
describe :rb_str_new2, shared: true do
it "returns a new string object calling strlen on the passed C string" do
# Hardcoded to pass const char * = "hello\0invisible"
@@ -35,7 +11,7 @@ describe :rb_str_new2, shared: true do
end
it "encodes the string with ASCII_8BIT" do
- @s.send(@method, "hello").encoding.should == Encoding::BINARY
+ @s.send(@method, "hello").encoding.should == Encoding::ASCII_8BIT
end
end
@@ -44,71 +20,42 @@ describe "C-API String function" do
@s = CApiStringSpecs.new
end
- [Encoding::BINARY, Encoding::UTF_8].each do |enc|
- describe "rb_str_set_len on a #{enc.name} String" do
- before :each do
- @str = "abcdefghij".force_encoding(enc)
- # Make sure to unshare the string
- @s.rb_str_modify(@str)
- end
-
- it "reduces the size of the string" do
- @s.rb_str_set_len(@str, 5).should == "abcde"
- end
-
- it "inserts a NULL byte at the length" do
- @s.rb_str_set_len(@str, 5).should == "abcde"
- @s.rb_str_set_len(@str, 8).should == "abcde\x00gh"
- end
-
- it "updates the byte size" do
- @s.rb_str_set_len(@str, 4)
- @str.bytesize.should == 4
- @str.should == "abcd"
- end
-
- it "invalidates the character size" do
- @str.size.should == 10
- @s.rb_str_set_len(@str, 4)
- @str.size.should == 4
- @str.should == "abcd"
- end
+ class ValidTostrTest
+ def to_str
+ "ruby"
+ end
+ end
- it "invalidates the code range" do
- @s.rb_str_set_len(@str, 4)
- @str.ascii_only?.should == true
- end
+ class InvalidTostrTest
+ def to_str
+ []
+ end
+ end
- it "updates the string's attributes visible in C code" do
- @s.rb_str_set_len_RSTRING_LEN(@str, 4).should == 4
- end
+ describe "rb_str_set_len" do
+ before :each do
+ # Make a completely new copy of the string
+ # for every example (#dup doesn't cut it).
+ @str = "abcdefghij"[0..-1]
+ end
- it "can reveal characters written from C with RSTRING_PTR" do
- @s.rb_str_set_len(@str, 1)
- @str.should == "a"
+ it "reduces the size of the string" do
+ @s.rb_str_set_len(@str, 5).should == "abcde"
+ end
- @s.RSTRING_PTR_set(@str, 1, 'B'.ord)
- @s.RSTRING_PTR_set(@str, 2, 'C'.ord)
- @s.rb_str_set_len(@str, 3)
+ it "inserts a NULL byte at the length" do
+ @s.rb_str_set_len(@str, 5).should == "abcde"
+ @s.rb_str_set_len(@str, 8).should == "abcde\x00gh"
+ end
- @str.bytesize.should == 3
- @str.should == "aBC"
- end
+ it "updates the string's attributes visible in C code" do
+ @s.rb_str_set_len_RSTRING_LEN(@str, 4).should == 4
end
end
describe "rb_str_buf_new" do
it "returns the equivalent of an empty string" do
- buf = @s.rb_str_buf_new(10, nil)
- buf.should == ""
- buf.bytesize.should == 0
- buf.size.should == 0
- @s.RSTRING_LEN(buf).should == 0
- end
-
- it "returns a string with the given capacity" do
- buf = @s.rb_str_buf_new(256, nil)
- @s.rb_str_capacity(buf).should == 256
+ @s.rb_str_buf_new(10, nil).should == ""
end
it "returns a string that can be appended to" do
@@ -136,19 +83,6 @@ describe "C-API String function" do
str[0, 6].should == "abcd\x00f"
@s.RSTRING_LEN(str).should == 8
end
-
- it "can be used as a general buffer and reveal characters with rb_str_set_len" do
- str = @s.rb_str_buf_new(10, "abcdef")
-
- @s.RSTRING_PTR_set(str, 0, 195)
- @s.RSTRING_PTR_set(str, 1, 169)
- @s.rb_str_set_len(str, 2)
-
- str.force_encoding(Encoding::UTF_8)
- str.bytesize.should == 2
- str.size.should == 1
- str.should == "é"
- end
end
describe "rb_str_buf_new2" do
@@ -159,29 +93,14 @@ describe "C-API String function" do
end
describe "rb_str_new" do
- it "creates a new String with BINARY Encoding" do
- @s.rb_str_new("", 0).encoding.should == Encoding::BINARY
- end
-
it "returns a new string object from a char buffer of len characters" do
@s.rb_str_new("hello", 3).should == "hel"
end
- ruby_version_is ''...'2.7' do
- it "returns a non-tainted string" do
- @s.rb_str_new("hello", 5).tainted?.should == false
- end
- end
-
it "returns an empty string if len is 0" do
@s.rb_str_new("hello", 0).should == ""
end
- it "copy length bytes and does not stop at the first \\0 byte" do
- @s.rb_str_new("he\x00llo", 6).should == "he\x00llo"
- @s.rb_str_new_native("he\x00llo", 6).should == "he\x00llo"
- end
-
it "returns a string from an offset char buffer" do
@s.rb_str_new_offset("hello", 1, 3).should == "ell"
end
@@ -191,6 +110,12 @@ describe "C-API String function" do
it_behaves_like :rb_str_new2, :rb_str_new2
end
+ describe "rb_str_new" do
+ it "creates a new String with ASCII-8BIT Encoding" do
+ @s.rb_str_new("", 0).encoding.should == Encoding::ASCII_8BIT
+ end
+ end
+
describe "rb_str_new_cstr" do
it_behaves_like :rb_str_new2, :rb_str_new_cstr
end
@@ -263,7 +188,7 @@ describe "C-API String function" do
str1 = "hi"
str2 = @s.rb_str_new3 str1
str1.should == str2
- str1.should_not equal str2
+ str1.object_id.should_not == str2.object_id
end
end
@@ -292,7 +217,7 @@ describe "C-API String function" do
str1 = "hi"
str2 = @s.rb_str_dup str1
str1.should == str2
- str1.should_not equal str2
+ str1.object_id.should_not == str2.object_id
end
end
@@ -307,21 +232,19 @@ describe "C-API String function" do
end
end
- ruby_version_is ''...'2.7' do
- describe "rb_tainted_str_new" do
- it "creates a new tainted String" do
- newstring = @s.rb_tainted_str_new("test", 4)
- newstring.should == "test"
- newstring.tainted?.should be_true
- end
+ describe "rb_tainted_str_new" do
+ it "creates a new tainted String" do
+ newstring = @s.rb_tainted_str_new("test", 4)
+ newstring.should == "test"
+ newstring.tainted?.should be_true
end
+ end
- describe "rb_tainted_str_new2" do
- it "creates a new tainted String" do
- newstring = @s.rb_tainted_str_new2("test")
- newstring.should == "test"
- newstring.tainted?.should be_true
- end
+ describe "rb_tainted_str_new2" do
+ it "creates a new tainted String" do
+ newstring = @s.rb_tainted_str_new2("test")
+ newstring.should == "test"
+ newstring.tainted?.should be_true
end
end
@@ -331,7 +254,7 @@ describe "C-API String function" do
end
it "raises a TypeError trying to append non-String-like object" do
- -> { @s.rb_str_append("Hello", 32323)}.should raise_error(TypeError)
+ lambda { @s.rb_str_append("Hello", 32323)}.should raise_error(TypeError)
end
it "changes Encoding if a string is appended to an empty string" do
@@ -347,7 +270,7 @@ describe "C-API String function" do
end
describe "rb_str_times" do
- it_behaves_like :string_times, :rb_str_times, -> str, times { @s.rb_str_times(str, times) }
+ it_behaves_like :string_times, :rb_str_times, ->(str, times) { @s.rb_str_times(str, times) }
end
describe "rb_str_buf_cat" do
@@ -418,7 +341,7 @@ describe "C-API String function" do
end
it "converts a C string to a Fixnum strictly if base is 0" do
- -> { @s.rb_cstr2inum("1234a", 0) }.should raise_error(ArgumentError)
+ lambda { @s.rb_cstr2inum("1234a", 0) }.should raise_error(ArgumentError)
end
end
@@ -436,7 +359,7 @@ describe "C-API String function" do
end
it "converts a C string to a Fixnum strictly" do
- -> { @s.rb_cstr_to_inum("1234a", 10, true) }.should raise_error(ArgumentError)
+ lambda { @s.rb_cstr_to_inum("1234a", 10, true) }.should raise_error(ArgumentError)
end
end
@@ -458,12 +381,12 @@ describe "C-API String function" do
describe "rb_str_to_str" do
it "calls #to_str to coerce the value to a String" do
@s.rb_str_to_str("foo").should == "foo"
- @s.rb_str_to_str(CApiStringSpecs::ValidTostrTest.new).should == "ruby"
+ @s.rb_str_to_str(ValidTostrTest.new).should == "ruby"
end
it "raises a TypeError if coercion fails" do
- -> { @s.rb_str_to_str(0) }.should raise_error(TypeError)
- -> { @s.rb_str_to_str(CApiStringSpecs::InvalidTostrTest.new) }.should raise_error(TypeError)
+ lambda { @s.rb_str_to_str(0) }.should raise_error(TypeError)
+ lambda { @s.rb_str_to_str(InvalidTostrTest.new) }.should raise_error(TypeError)
end
end
@@ -479,7 +402,7 @@ describe "C-API String function" do
it "allows changing the characters in the string" do
str = "abc"
- @s.RSTRING_PTR_assign(str, 'A'.ord)
+ @s.RSTRING_PTR_assign(str, 65)
str.should == "AAA"
end
@@ -494,13 +417,6 @@ describe "C-API String function" do
ret.should == str
end
- it "reflects changes from native memory and from String#setbyte in bounds" do
- str = "abc"
- from_rstring_ptr = @s.RSTRING_PTR_after_yield(str) { str.setbyte(1, 'B'.ord) }
- from_rstring_ptr.should == "1B2"
- str.should == "1B2"
- end
-
it "returns a pointer to the contents of encoded pointer-sized string" do
s = "70パク".
encode(Encoding::UTF_16LE).
@@ -553,7 +469,7 @@ describe "C-API String function" do
it "does not call #to_s on non-String objects" do
str = mock("fake")
str.should_not_receive(:to_s)
- -> { @s.send(@method, str) }.should raise_error(TypeError)
+ lambda { @s.send(@method, str) }.should raise_error(TypeError)
end
end
@@ -562,51 +478,22 @@ describe "C-API String function" do
end
describe "SafeStringValue" do
- ruby_version_is ''...'2.7' do
- it "raises for tained string when $SAFE is 1" do
- begin
- Thread.new {
- $SAFE = 1
- -> {
- @s.SafeStringValue("str".taint)
- }.should raise_error(SecurityError)
- }.join
- ensure
- $SAFE = 0
- end
- end
-
- it_behaves_like :string_value_macro, :SafeStringValue
+ it "raises for tained string when $SAFE is 1" do
+ Thread.new {
+ $SAFE = 1
+ lambda {
+ @s.SafeStringValue("str".taint)
+ }.should raise_error(SecurityError)
+ }.join
end
- end
- describe "rb_str_modify_expand" do
- it "grows the capacity to bytesize + expand, not changing the bytesize" do
- str = @s.rb_str_buf_new(256, "abcd")
- @s.rb_str_capacity(str).should == 256
-
- @s.rb_str_set_len(str, 3)
- str.bytesize.should == 3
- @s.RSTRING_LEN(str).should == 3
- @s.rb_str_capacity(str).should == 256
-
- @s.rb_str_modify_expand(str, 4)
- str.bytesize.should == 3
- @s.RSTRING_LEN(str).should == 3
- @s.rb_str_capacity(str).should == 7
-
- @s.rb_str_modify_expand(str, 1024)
- str.bytesize.should == 3
- @s.RSTRING_LEN(str).should == 3
- @s.rb_str_capacity(str).should == 1027
- end
+ it_behaves_like :string_value_macro, :SafeStringValue
end
describe "rb_str_resize" do
it "reduces the size of the string" do
str = @s.rb_str_resize("test", 2)
str.size.should == 2
- str.bytesize.should == 2
@s.RSTRING_LEN(str).should == 2
str.should == "te"
end
@@ -619,7 +506,6 @@ describe "C-API String function" do
expected = "test".force_encoding("US-ASCII")
str = @s.rb_str_resize(expected.dup, 12)
str.size.should == 12
- str.bytesize.should == 12
@s.RSTRING_LEN(str).should == 12
str[0, 4].should == expected
end
@@ -682,16 +568,14 @@ describe :rb_external_str_new, shared: true do
@s.send(@method, "abc").encoding.should == Encoding::UTF_8
end
- it "returns a binary encoded string if any non-ascii bytes are present and default external is US-ASCII" do
+ it "returns an ASCII-8BIT encoded string if any non-ascii bytes are present and default external is US-ASCII" do
Encoding.default_external = "US-ASCII"
x80 = [0x80].pack('C')
- @s.send(@method, "#{x80}abc").encoding.should == Encoding::BINARY
+ @s.send(@method, "#{x80}abc").encoding.should == Encoding::ASCII_8BIT
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted String" do
- @s.send(@method, "abc").tainted?.should be_true
- end
+ it "returns a tainted String" do
+ @s.send(@method, "abc").tainted?.should be_true
end
end
@@ -743,10 +627,10 @@ describe "C-API String function" do
s.encoding.should == Encoding::UTF_8
end
- it "returns a binary encoded String if any non-ascii bytes are present and the specified encoding is US-ASCII" do
+ it "returns an ASCII-8BIT encoded String if any non-ascii bytes are present and the specified encoding is US-ASCII" do
x80 = [0x80].pack('C')
s = @s.rb_external_str_new_with_enc("#{x80}abc", 4, Encoding::US_ASCII)
- s.encoding.should == Encoding::BINARY
+ s.encoding.should == Encoding::ASCII_8BIT
end
@@ -758,7 +642,7 @@ describe "C-API String function" do
# s = @s.rb_external_str_new_with_enc(a, a.bytesize, Encoding::UTF_8)
# -
# - s.should == "\xA4\xA2\xA4\xEC".force_encoding("euc-jp")
-# + x = [0xA4, 0xA2, 0xA4, 0xEC].pack('C4')#.force_encoding('binary')
+# + x = [0xA4, 0xA2, 0xA4, 0xEC].pack('C4')#.force_encoding('ascii-8bit')
# + s.should == x
# s.encoding.should equal(Encoding::EUC_JP)
# end
@@ -773,11 +657,9 @@ describe "C-API String function" do
s.encoding.should equal(Encoding::EUC_JP)
end
- ruby_version_is ''...'2.7' do
- it "returns a tainted String" do
- s = @s.rb_external_str_new_with_enc("abc", 3, Encoding::US_ASCII)
- s.tainted?.should be_true
- end
+ it "returns a tainted String" do
+ s = @s.rb_external_str_new_with_enc("abc", 3, Encoding::US_ASCII)
+ s.tainted?.should be_true
end
end
@@ -827,9 +709,9 @@ describe "C-API String function" do
@s.rb_str_conv_enc(a, Encoding::UTF_8, Encoding::US_ASCII).should equal(a)
end
- it "returns the origin String if the destination encoding is BINARY" do
- a = "abc".force_encoding("binary")
- @s.rb_str_conv_enc(a, Encoding::US_ASCII, Encoding::BINARY).should equal(a)
+ it "returns the origin String if the destination encoding is ASCII-8BIT" do
+ a = "abc".force_encoding("ascii-8bit")
+ @s.rb_str_conv_enc(a, Encoding::US_ASCII, Encoding::ASCII_8BIT).should equal(a)
end
end
end
@@ -867,10 +749,10 @@ describe "C-API String function" do
Encoding::US_ASCII, 0, nil).should equal(a)
end
- it "returns the origin String if the destination encoding is BINARY" do
- a = "abc".force_encoding("binary")
+ it "returns the origin String if the destination encoding is ASCII-8BIT" do
+ a = "abc".force_encoding("ascii-8bit")
@s.rb_str_conv_enc_opts(a, Encoding::US_ASCII,
- Encoding::BINARY, 0, nil).should equal(a)
+ Encoding::ASCII_8BIT, 0, nil).should equal(a)
end
end
end
@@ -891,27 +773,6 @@ describe "C-API String function" do
end
end
- describe "rb_str_export_to_enc" do
- it "returns a copy of an ascii string converted to the new encoding" do
- source = "A simple string".encode(Encoding::US_ASCII)
- result = @s.rb_str_export_to_enc(source, Encoding::UTF_8)
- result.should == source.encode(Encoding::UTF_8)
- result.encoding.should == Encoding::UTF_8
- end
-
- it "returns the source string if it can not be converted" do
- source = ["00ff"].pack("H*");
- result = @s.rb_str_export_to_enc(source, Encoding::UTF_8)
- result.should equal(source)
- end
-
- it "does not alter the source string if it can not be converted" do
- source = ["00ff"].pack("H*");
- result = @s.rb_str_export_to_enc(source, Encoding::UTF_8)
- source.bytes.should == [0, 255]
- end
-end
-
describe "rb_sprintf" do
it "replaces the parts like sprintf" do
@s.rb_sprintf1("Awesome %s is replaced", "string").should == "Awesome string is replaced"
@@ -922,26 +783,6 @@ end
s = "Awesome %s is here with %s"
@s.rb_sprintf2(s, "string", "content").should == "Awesome string is here with content"
end
-
- it "formats a string VALUE using to_s if sign not specified in format" do
- s = 'Result: A string.'
- @s.rb_sprintf3(CApiStringSpecs::ToSOrInspect.new).should == s
- end
-
- it "formats a string VALUE using inspect if sign specified in format" do
- s = 'Result: A different string.'
- @s.rb_sprintf4(CApiStringSpecs::ToSOrInspect.new).should == s
- end
-
- it "formats a TrueClass VALUE as `TrueClass` if sign not specified in format" do
- s = 'Result: TrueClass.'
- @s.rb_sprintf3(true.class).should == s
- end
-
- it "formats a TrueClass VALUE as 'true' if sign specified in format" do
- s = 'Result: true.'
- @s.rb_sprintf4(true.class).should == s
- end
end
describe "rb_vsprintf" do
@@ -957,78 +798,15 @@ end
end
it "tries to convert the passed argument to a string by calling #to_str first" do
- @s.rb_String(CApiStringSpecs::ValidTostrTest.new).should == "ruby"
+ @s.rb_String(ValidTostrTest.new).should == "ruby"
end
it "raises a TypeError if #to_str does not return a string" do
- -> { @s.rb_String(CApiStringSpecs::InvalidTostrTest.new) }.should raise_error(TypeError)
+ lambda { @s.rb_String(InvalidTostrTest.new) }.should raise_error(TypeError)
end
it "tries to convert the passed argument to a string by calling #to_s" do
@s.rb_String({"bar" => "foo"}).should == '{"bar"=>"foo"}'
end
end
-
- describe "rb_string_value_cstr" do
- it "returns a non-null pointer for a simple string" do
- @s.rb_string_value_cstr("Hello").should == true
- end
-
- it "returns a non-null pointer for a UTF-16 string" do
- @s.rb_string_value_cstr("Hello".encode('UTF-16BE')).should == true
- end
-
- it "raises an error if a string contains a null" do
- -> { @s.rb_string_value_cstr("Hello\0 with a null.") }.should raise_error(ArgumentError)
- end
-
- it "raises an error if a UTF-16 string contains a null" do
- -> { @s.rb_string_value_cstr("Hello\0 with a null.".encode('UTF-16BE')) }.should raise_error(ArgumentError)
- end
-
- end
-
- describe "rb_str_drop_bytes" do
- it "drops N characters for an ASCII string" do
- str = "12345678".encode("US-ASCII")
- @s.rb_str_drop_bytes(str, 4)
- str.should == "5678".encode("US-ASCII")
- end
-
- it "drop N/2 characters for a UTF-16 string" do
- str = "12345678".encode("UTF-16LE")
- @s.rb_str_drop_bytes(str, 4)
- str.should == "345678".encode("UTF-16LE")
- end
-
- it "drop N/4 characters for a UTF-32 string" do
- str = "12345678".encode("UTF-32LE")
- @s.rb_str_drop_bytes(str, 4)
- str.should == "2345678".encode("UTF-32LE")
- end
- end
-
- describe "rb_utf8_str_new_static" do
- it "returns a UTF-8 string of the correct characters and length" do
- str = @s.rb_utf8_str_new_static
- str.should == "nokogiri"
- str.encoding.should == Encoding::UTF_8
- end
- end
-
- describe "rb_utf8_str_new" do
- it "returns a UTF-8 string of the correct characters and length" do
- str = @s.rb_utf8_str_new
- str.should == "nokogiri"
- str.encoding.should == Encoding::UTF_8
- end
- end
-
- describe "rb_utf8_str_new_cstr" do
- it "returns a UTF-8 string of the correct characters and length" do
- str = @s.rb_utf8_str_new_cstr
- str.should == "nokogiri"
- str.encoding.should == Encoding::UTF_8
- end
- end
end
diff --git a/spec/ruby/optional/capi/struct_spec.rb b/spec/ruby/optional/capi/struct_spec.rb
index 6254b098a9..9a0eafeb7b 100644
--- a/spec/ruby/optional/capi/struct_spec.rb
+++ b/spec/ruby/optional/capi/struct_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("struct")
@@ -64,7 +64,7 @@ end
describe "C-API Struct function" do
before :each do
@s = CApiStructSpecs.new
- @struct = @s.rb_struct_define_under(CApiStructSpecs, "CAPIStructUnder", "a", "b", "c")
+ @struct = @s.rb_struct_define_under(CApiStructSpecs, "CAPIStruct", "a", "b", "c")
end
describe "rb_struct_define_under" do
@@ -80,15 +80,11 @@ describe "C-API Struct function" do
it "has a value of nil for the member of a newly created instance" do
# Verify that attributes are on an instance basis
- CApiStructSpecs::CAPIStructUnder.new.b.should be_nil
- end
-
- it "does not create a constant scoped under Struct for the named Struct" do
- Struct.should_not have_constant(:CAPIStructUnder)
+ CApiStructSpecs::CAPIStruct.new.b.should be_nil
end
it "creates a constant scoped under the namespace of the given class" do
- CApiStructSpecs.should have_constant(:CAPIStructUnder)
+ CApiStructSpecs.should have_constant(:CAPIStruct)
end
it "returns the member names as Symbols" do
@@ -106,11 +102,11 @@ describe "C-API Struct function" do
describe "rb_struct_define" do
it "raises an ArgumentError if arguments contain duplicate member name" do
- -> { @s.rb_struct_define(nil, "a", "b", "a") }.should raise_error(ArgumentError)
+ lambda { @s.rb_struct_define(nil, "a", "b", "a") }.should raise_error(ArgumentError)
end
it "raises a NameError if an invalid constant name is given" do
- -> { @s.rb_struct_define("foo", "a", "b", "c") }.should raise_error(NameError)
+ lambda { @s.rb_struct_define("foo", "a", "b", "c") }.should raise_error(NameError)
end
end
@@ -131,12 +127,12 @@ describe "C-API Struct function" do
end
it "raises a NameError if the struct member does not exist" do
- -> { @s.rb_struct_aref(@struct, :d) }.should raise_error(NameError)
+ lambda { @s.rb_struct_aref(@struct, :d) }.should raise_error(NameError)
end
it "raises an IndexError if the given index is out of range" do
- -> { @s.rb_struct_aref(@struct, -4) }.should raise_error(IndexError)
- -> { @s.rb_struct_aref(@struct, 3) }.should raise_error(IndexError)
+ lambda { @s.rb_struct_aref(@struct, -4) }.should raise_error(IndexError)
+ lambda { @s.rb_struct_aref(@struct, 3) }.should raise_error(IndexError)
end
end
@@ -147,7 +143,7 @@ describe "C-API Struct function" do
end
it "raises a NameError if the struct member does not exist" do
- -> { @s.rb_struct_getmember(@struct, :d) }.should raise_error(NameError)
+ lambda { @s.rb_struct_getmember(@struct, :d) }.should raise_error(NameError)
end
end
@@ -180,17 +176,17 @@ describe "C-API Struct function" do
end
it "raises a NameError if the struct member does not exist" do
- -> { @s.rb_struct_aset(@struct, :d, 1) }.should raise_error(NameError)
+ lambda { @s.rb_struct_aset(@struct, :d, 1) }.should raise_error(NameError)
end
it "raises an IndexError if the given index is out of range" do
- -> { @s.rb_struct_aset(@struct, -4, 1) }.should raise_error(IndexError)
- -> { @s.rb_struct_aset(@struct, 3, 1) }.should raise_error(IndexError)
+ lambda { @s.rb_struct_aset(@struct, -4, 1) }.should raise_error(IndexError)
+ lambda { @s.rb_struct_aset(@struct, 3, 1) }.should raise_error(IndexError)
end
- it "raises a #{frozen_error_class} if the struct is frozen" do
+ it "raises a RuntimeError if the struct is frozen" do
@struct.freeze
- -> { @s.rb_struct_aset(@struct, :a, 1) }.should raise_error(frozen_error_class)
+ lambda { @s.rb_struct_aset(@struct, :a, 1) }.should raise_error(RuntimeError)
end
end
@@ -203,9 +199,11 @@ describe "C-API Struct function" do
end
end
- describe "rb_struct_size" do
- it "returns the number of struct members" do
- @s.rb_struct_size(@struct).should == 3
+ ruby_version_is "2.4" do
+ describe "rb_struct_size" do
+ it "returns the number of struct members" do
+ @s.rb_struct_size(@struct).should == 3
+ end
end
end
end
diff --git a/spec/ruby/optional/capi/symbol_spec.rb b/spec/ruby/optional/capi/symbol_spec.rb
index ddc748c8d8..b6532f4a4e 100644
--- a/spec/ruby/optional/capi/symbol_spec.rb
+++ b/spec/ruby/optional/capi/symbol_spec.rb
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension('symbol')
diff --git a/spec/ruby/optional/capi/thread_spec.rb b/spec/ruby/optional/capi/thread_spec.rb
index df454d1ea8..ab3d609bcf 100644
--- a/spec/ruby/optional/capi/thread_spec.rb
+++ b/spec/ruby/optional/capi/thread_spec.rb
@@ -1,5 +1,5 @@
-require_relative 'spec_helper'
-require_relative '../../core/thread/shared/wakeup'
+require File.expand_path('../spec_helper', __FILE__)
+require File.expand_path('../../../core/thread/shared/wakeup', __FILE__)
load_extension("thread")
@@ -24,7 +24,7 @@ describe "C-API Thread function" do
it "sleeps the current thread for the give amount of time" do
start = Time.now
@t.rb_thread_wait_for(0, 100_000)
- (Time.now - start).should be_close(0.1, TIME_TOLERANCE)
+ (Time.now - start).should be_close(0.1, 0.2)
end
end
@@ -70,7 +70,7 @@ describe "C-API Thread function" do
describe "rb_thread_create" do
it "creates a new thread" do
obj = Object.new
- proc = -> x { ScratchPad.record x }
+ proc = lambda { |x| ScratchPad.record x }
thr = @t.rb_thread_create(proc, obj)
thr.should be_kind_of(Thread)
thr.join
@@ -78,20 +78,20 @@ describe "C-API Thread function" do
end
it "handles throwing an exception in the thread" do
- prc = -> x {
+ prc = lambda { |x|
Thread.current.report_on_exception = false
raise "my error"
}
thr = @t.rb_thread_create(prc, nil)
thr.should be_kind_of(Thread)
- -> {
+ lambda {
thr.join
}.should raise_error(RuntimeError, "my error")
end
it "sets the thread's group" do
- thr = @t.rb_thread_create(-> x { }, nil)
+ thr = @t.rb_thread_create(lambda { |x| }, nil)
begin
thread_group = thr.group
thread_group.should be_an_instance_of(ThreadGroup)
@@ -117,29 +117,11 @@ describe "C-API Thread function" do
# Wake it up, causing the unblock function to be run.
thr.wakeup
- # Make sure it stopped and we got a proper value
- thr.value.should be_true
- end
-
- guard -> { platform_is :mingw and ruby_version_is ""..."2.7" } do
- it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do
- thr = Thread.new do
- @t.rb_thread_call_without_gvl_with_ubf_io
- end
-
- # Wait until it's blocking...
- Thread.pass while thr.status and thr.status != "sleep"
+ # Make sure it stopped
+ thr.join(1).should_not be_nil
- # The thread status is set to sleep by rb_thread_call_without_gvl(),
- # but the thread might not be in the blocking read(2) yet, so wait a bit.
- sleep 0.1
-
- # Wake it up, causing the unblock function to be run.
- thr.wakeup
-
- # Make sure it stopped and we got a proper value
- thr.value.should be_true
- end
+ # And we got a proper value
+ thr.value.should be_true
end
end
end
diff --git a/spec/ruby/optional/capi/time_spec.rb b/spec/ruby/optional/capi/time_spec.rb
index 2c824bb566..c8f0d9d4e0 100644
--- a/spec/ruby/optional/capi/time_spec.rb
+++ b/spec/ruby/optional/capi/time_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("time")
@@ -96,9 +96,9 @@ describe "CApiTimeSpecs" do
end
it "throws an argument error for a negative value" do
- -> { @s.rb_time_interval(-1232141421) }.should raise_error(ArgumentError)
- -> { @s.rb_time_interval(Rational(-3, 2)) }.should raise_error(ArgumentError)
- -> { @s.rb_time_interval(-1.5) }.should raise_error(ArgumentError)
+ lambda { @s.rb_time_interval(-1232141421) }.should raise_error(ArgumentError)
+ lambda { @s.rb_time_interval(Rational(-3, 2)) }.should raise_error(ArgumentError)
+ lambda { @s.rb_time_interval(-1.5) }.should raise_error(ArgumentError)
end
end
@@ -129,13 +129,13 @@ describe "CApiTimeSpecs" do
end
it "throws an argument error for a negative value" do
- -> { @s.rb_time_interval(-1232141421) }.should raise_error(ArgumentError)
- -> { @s.rb_time_interval(Rational(-3, 2)) }.should raise_error(ArgumentError)
- -> { @s.rb_time_interval(-1.5) }.should raise_error(ArgumentError)
+ lambda { @s.rb_time_interval(-1232141421) }.should raise_error(ArgumentError)
+ lambda { @s.rb_time_interval(Rational(-3, 2)) }.should raise_error(ArgumentError)
+ lambda { @s.rb_time_interval(-1.5) }.should raise_error(ArgumentError)
end
it "throws an argument error when given a Time instance" do
- -> { @s.rb_time_interval(Time.now) }.should raise_error(TypeError)
+ lambda { @s.rb_time_interval(Time.now) }.should raise_error(TypeError)
end
end
@@ -165,7 +165,7 @@ describe "CApiTimeSpecs" do
usec.should == 500000
end
- guard -> { platform_is_not :mingw or ruby_version_is '2.5' } do
+ platform_is_not :mingw32 do
it "creates a timeval for a negative Fixnum" do
sec, usec = @s.rb_time_timeval(-1232141421)
sec.should be_kind_of(Integer)
@@ -224,7 +224,7 @@ describe "CApiTimeSpecs" do
nsec.should == 500000000
end
- guard -> { platform_is_not :mingw or ruby_version_is '2.5' } do
+ platform_is_not :mingw32 do
it "creates a timespec for a negative Fixnum" do
sec, nsec = @s.rb_time_timespec(-1232141421)
sec.should be_kind_of(Integer)
@@ -258,43 +258,45 @@ describe "CApiTimeSpecs" do
end
end
- describe "rb_time_timespec_new" do
- it "returns a time object with the given timespec and UTC offset" do
- @s.rb_time_timespec_new(1447087832, 476451125, 32400).should == Time.at(1447087832, 476451.125).localtime(32400)
- end
-
- describe "when offset given is within range of -86400 and 86400 (exclusive)" do
- it "sets time's is_gmt to false" do
- @s.rb_time_timespec_new(1447087832, 476451125, 0).gmt?.should be_false
+ ruby_version_is "2.3" do
+ describe "rb_time_timespec_new" do
+ it "returns a time object with the given timespec and UTC offset" do
+ @s.rb_time_timespec_new(1447087832, 476451125, 32400).should == Time.at(1447087832, 476451.125).localtime(32400)
end
- it "sets time's offset to the offset given" do
- @s.rb_time_timespec_new(1447087832, 476451125, 86399).gmtoff.should == 86399
+ describe "when offset given is within range of -86400 and 86400 (exclusive)" do
+ it "sets time's is_gmt to false" do
+ @s.rb_time_timespec_new(1447087832, 476451125, 0).gmt?.should be_false
+ end
+
+ it "sets time's offset to the offset given" do
+ @s.rb_time_timespec_new(1447087832, 476451125, 86399).gmtoff.should == 86399
+ end
end
- end
- it "returns time object in UTC if offset given equals INT_MAX - 1" do
- @s.rb_time_timespec_new(1447087832, 476451125, 0x7ffffffe).utc?.should be_true
- end
+ it "returns time object in UTC if offset given equals INT_MAX - 1" do
+ @s.rb_time_timespec_new(1447087832, 476451125, 0x7ffffffe).utc?.should be_true
+ end
- it "returns time object in localtime if offset given equals INT_MAX" do
- @s.rb_time_timespec_new(1447087832, 476451125, 0x7fffffff).should == Time.at(1447087832, 476451.125).localtime
- t = Time.now
- @s.rb_time_timespec_new(t.tv_sec, t.tv_nsec, 0x7fffffff).gmtoff.should == t.gmtoff
- end
+ it "returns time object in localtime if offset given equals INT_MAX" do
+ @s.rb_time_timespec_new(1447087832, 476451125, 0x7fffffff).should == Time.at(1447087832, 476451.125).localtime
+ t = Time.now
+ @s.rb_time_timespec_new(t.tv_sec, t.tv_nsec, 0x7fffffff).gmtoff.should == t.gmtoff
+ end
- it "raises an ArgumentError if offset passed is not within range of -86400 and 86400 (exclusive)" do
- -> { @s.rb_time_timespec_new(1447087832, 476451125, 86400) }.should raise_error(ArgumentError)
- -> { @s.rb_time_timespec_new(1447087832, 476451125, -86400) }.should raise_error(ArgumentError)
+ it "raises an ArgumentError if offset passed is not within range of -86400 and 86400 (exclusive)" do
+ lambda { @s.rb_time_timespec_new(1447087832, 476451125, 86400) }.should raise_error(ArgumentError)
+ lambda { @s.rb_time_timespec_new(1447087832, 476451125, -86400) }.should raise_error(ArgumentError)
+ end
end
- end
- describe "rb_timespec_now" do
- it "fills a struct timespec with the current time" do
- now = Time.now
- time = @s.rb_time_from_timespec(now.utc_offset)
- time.should be_an_instance_of(Time)
- (time - now).should be_close(0, TIME_TOLERANCE)
+ describe "rb_timespec_now" do
+ it "fills a struct timespec with the current time" do
+ now = Time.now
+ time = @s.rb_time_from_timespec(now.utc_offset)
+ time.should be_an_instance_of(Time)
+ (time - now).should be_close(0, 10)
+ end
end
end
end
diff --git a/spec/ruby/optional/capi/typed_data_spec.rb b/spec/ruby/optional/capi/typed_data_spec.rb
index da56a050fd..1b2852d349 100644
--- a/spec/ruby/optional/capi/typed_data_spec.rb
+++ b/spec/ruby/optional/capi/typed_data_spec.rb
@@ -1,5 +1,4 @@
-require_relative 'spec_helper'
-require 'objspace'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("typed_data")
@@ -8,14 +7,6 @@ describe "CApiAllocTypedSpecs (a class with an alloc func defined)" do
@s = CApiAllocTypedSpecs.new
@s.typed_wrapped_data.should == 42 # not defined in initialize
end
-
- it "uses the specified memsize function for ObjectSpace.memsize" do
- @s = CApiAllocTypedSpecs.new
- # The defined memsize function for the type should return 42 as
- # the size, and this should be added to the size of the object as
- # known by Ruby.
- ObjectSpace.memsize_of(@s).should > 42
- end
end
describe "CApiWrappedTypedStruct" do
@@ -30,7 +21,7 @@ describe "CApiWrappedTypedStruct" do
it "throws an exception for a wrong type" do
a = @s.typed_wrap_struct(1024)
- -> { @s.typed_get_struct_other(a) }.should raise_error(TypeError)
+ lambda { @s.typed_get_struct_other(a) }.should raise_error(TypeError)
end
it "unwraps data for a parent type" do
@@ -38,6 +29,11 @@ describe "CApiWrappedTypedStruct" do
@s.typed_get_struct_parent(a).should == 1024
end
+ it "allows for using NULL as the klass for Data_Wrap_Struct" do
+ a = @s.typed_wrap_struct_null(1024)
+ @s.typed_get_struct(a).should == 1024
+ end
+
describe "RTYPEDATA" do
it "returns the struct data" do
a = @s.typed_wrap_struct(1024)
diff --git a/spec/ruby/optional/capi/util_spec.rb b/spec/ruby/optional/capi/util_spec.rb
index 3556c8c010..b2ef2ba92e 100644
--- a/spec/ruby/optional/capi/util_spec.rb
+++ b/spec/ruby/optional/capi/util_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension('util')
@@ -9,9 +9,8 @@ describe "C-API Util function" do
describe "rb_scan_args" do
before :each do
- @prc = -> { 1 }
+ @prc = lambda { 1 }
@acc = []
- @keyword_prefix = 'k' if RUBY_VERSION >= '2.7'
ScratchPad.record @acc
end
@@ -21,11 +20,7 @@ describe "C-API Util function" do
end
it "raises an ArgumentError if there are insufficient arguments" do
- -> { @o.rb_scan_args([1, 2], "3", 0, @acc) }.should raise_error(ArgumentError)
- end
-
- it "raises an ArgumentError if there are too many arguments" do
- -> { @o.rb_scan_args([1, 2, 3, 4], "3", 0, @acc) }.should raise_error(ArgumentError)
+ lambda { @o.rb_scan_args([1, 2], "3", 0, @acc) }.should raise_error(ArgumentError)
end
it "assigns the required and optional arguments scanned" do
@@ -100,13 +95,13 @@ describe "C-API Util function" do
it "assigns Hash arguments" do
h = {a: 1, b: 2}
- @o.rb_scan_args([h], "#{@keyword_prefix}0:", 1, @acc).should == 0
+ @o.rb_scan_args([h], "0:", 1, @acc).should == 0
ScratchPad.recorded.should == [h]
end
it "assigns required and Hash arguments" do
h = {a: 1, b: 2}
- @o.rb_scan_args([1, h], "#{@keyword_prefix}1:", 2, @acc).should == 1
+ @o.rb_scan_args([1, h], "1:", 2, @acc).should == 1
ScratchPad.recorded.should == [1, h]
end
@@ -116,101 +111,44 @@ describe "C-API Util function" do
end
it "assigns required and Hash arguments with nil Hash" do
- suppress_warning do
- @o.rb_scan_args([1, nil], "1:", 2, @acc).should == 1
- end
+ @o.rb_scan_args([1, nil], "1:", 2, @acc).should == 1
ScratchPad.recorded.should == [1, nil]
end
- it "assigns required and optional arguments with no hash argument given" do
- @o.rb_scan_args([1, 7, 4], "21:", 3, @acc).should == 3
- ScratchPad.recorded.should == [1, 7, 4]
- end
-
it "assigns required, optional, splat, post-splat, Hash and block arguments" do
h = {a: 1, b: 2}
- @o.rb_scan_args([1, 2, 3, 4, 5, h], "#{@keyword_prefix}11*1:&", 6, @acc, &@prc).should == 5
+ @o.rb_scan_args([1, 2, 3, 4, 5, h], "11*1:&", 6, @acc, &@prc).should == 5
ScratchPad.recorded.should == [1, 2, [3, 4], 5, h, @prc]
end
# r43934
it "rejects non-keyword arguments" do
h = {1 => 2, 3 => 4}
- -> {
- suppress_warning do
- @o.rb_scan_args([h], "#{@keyword_prefix}0:", 1, @acc)
- end
+ lambda {
+ @o.rb_scan_args([h], "0:", 1, @acc)
}.should raise_error(ArgumentError)
ScratchPad.recorded.should == []
end
it "rejects required and non-keyword arguments" do
h = {1 => 2, 3 => 4}
- -> {
- suppress_warning do
- @o.rb_scan_args([1, h], "#{@keyword_prefix}1:", 2, @acc)
- end
+ lambda {
+ @o.rb_scan_args([1, h], "1:", 2, @acc)
}.should raise_error(ArgumentError)
ScratchPad.recorded.should == []
end
it "considers the hash as a post argument when there is a splat" do
h = {1 => 2, 3 => 4}
- suppress_warning do
- @o.rb_scan_args([1, 2, 3, 4, 5, h], "#{@keyword_prefix}11*1:&", 6, @acc, &@prc).should == 6
- end
+ @o.rb_scan_args([1, 2, 3, 4, 5, h], "11*1:&", 6, @acc, &@prc).should == 6
ScratchPad.recorded.should == [1, 2, [3, 4, 5], h, nil, @prc]
end
end
- describe "rb_get_kwargs" do
- it "extracts required arguments in the order requested" do
- h = { :a => 7, :b => 5 }
- @o.rb_get_kwargs(h, [:b, :a], 2, 0).should == [5, 7]
- h.should == {}
- end
-
- it "extracts required and optional arguments in the order requested" do
- h = { :a => 7, :c => 12, :b => 5 }
- @o.rb_get_kwargs(h, [:b, :a, :c], 2, 1).should == [5, 7, 12]
- h.should == {}
- end
-
- it "accepts nil instead of a hash when only optional arguments are requested" do
- h = nil
- @o.rb_get_kwargs(h, [:b, :a, :c], 0, 3).should == []
- h.should == nil
- end
-
- it "raises an error if a required argument is not in the hash" do
- h = { :a => 7, :c => 12, :b => 5 }
- -> { @o.rb_get_kwargs(h, [:b, :d], 2, 0) }.should raise_error(ArgumentError, /missing keyword: :?d/)
- h.should == {:a => 7, :c => 12}
- end
-
- it "does not raise an error for an optional argument not in the hash" do
- h = { :a => 7, :b => 5 }
- @o.rb_get_kwargs(h, [:b, :a, :c], 2, 1).should == [5, 7]
- h.should == {}
- end
-
- it "raises an error if there are additional arguments and optional is positive" do
- h = { :a => 7, :c => 12, :b => 5 }
- -> { @o.rb_get_kwargs(h, [:b, :a], 2, 0) }.should raise_error(ArgumentError, /unknown keyword: :?c/)
- h.should == {:c => 12}
- end
-
- it "leaves additional arguments in the hash if optional is negative" do
- h = { :a => 7, :c => 12, :b => 5 }
- @o.rb_get_kwargs(h, [:b, :a], 2, -1).should == [5, 7]
- h.should == {:c => 12}
- end
- end
-
platform_is wordsize: 64 do
describe "rb_long2int" do
it "raises a RangeError if the value is outside the range of a C int" do
- -> { @o.rb_long2int(0xffff_ffff_ffff) }.should raise_error(RangeError)
+ lambda { @o.rb_long2int(0xffff_ffff_ffff) }.should raise_error(RangeError)
end
end
diff --git a/spec/ruby/security/cve_2010_1330_spec.rb b/spec/ruby/security/cve_2010_1330_spec.rb
deleted file mode 100644
index fa4c756c6d..0000000000
--- a/spec/ruby/security/cve_2010_1330_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../spec_helper'
-
-describe "String#gsub" do
-
- it "resists CVE-2010-1330 by raising an exception on invalid UTF-8 bytes" do
- # This original vulnerability talked about KCODE, which is no longer
- # used. Instead we are forcing encodings here. But I think the idea is the
- # same - we want to check that Ruby implementations raise an error on
- # #gsub on a string in the UTF-8 encoding but with invalid an UTF-8 byte
- # sequence.
-
- str = "\xF6<script>"
- str.force_encoding Encoding::BINARY
- str.gsub(/</, "&lt;").should == "\xF6&lt;script>".b
- str.force_encoding Encoding::UTF_8
- -> {
- str.gsub(/</, "&lt;")
- }.should raise_error(ArgumentError, /invalid byte sequence in UTF-8/)
- end
-
-end
diff --git a/spec/ruby/security/cve_2011_4815_spec.rb b/spec/ruby/security/cve_2011_4815_spec.rb
index 554e014a1f..0a353b742a 100644
--- a/spec/ruby/security/cve_2011_4815_spec.rb
+++ b/spec/ruby/security/cve_2011_4815_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe :resists_cve_2011_4815, shared: true do
it "resists CVE-2011-4815 by having different hash codes in different processes" do
@@ -22,20 +22,14 @@ describe "Float#hash" do
it_behaves_like :resists_cve_2011_4815, '3.14'
end
-describe "Rational#hash" do
- it_behaves_like :resists_cve_2011_4815, 'Rational(1, 2)'
-end
-
-describe "Complex#hash" do
- it_behaves_like :resists_cve_2011_4815, 'Complex(1, 2)'
-end
-
describe "String#hash" do
it_behaves_like :resists_cve_2011_4815, '"abc"'
end
describe "Symbol#hash" do
- it_behaves_like :resists_cve_2011_4815, ':a'
+ ruby_bug "#13376", "2.3.0"..."2.3.4" do
+ it_behaves_like :resists_cve_2011_4815, ':a'
+ end
end
describe "Array#hash" do
diff --git a/spec/ruby/security/cve_2013_4164_spec.rb b/spec/ruby/security/cve_2013_4164_spec.rb
index 94578cc7ce..06b2bb0306 100644
--- a/spec/ruby/security/cve_2013_4164_spec.rb
+++ b/spec/ruby/security/cve_2013_4164_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
require 'json'
diff --git a/spec/ruby/security/cve_2014_8080_spec.rb b/spec/ruby/security/cve_2014_8080_spec.rb
index 64e22cf3a7..6453b0c317 100644
--- a/spec/ruby/security/cve_2014_8080_spec.rb
+++ b/spec/ruby/security/cve_2014_8080_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
require 'rexml/document'
@@ -24,9 +24,9 @@ describe "REXML::Document.new" do
</x>
XML
- -> {
- REXML::Document.new(xml).doctype.entities['x9'].value
- }.should raise_error(REXML::ParseException, /entity expansion has grown too large/)
+ lambda { REXML::Document.new(xml).doctype.entities['x9'].value }.should raise_error(REXML::ParseException) { |e|
+ e.message.should =~ /entity expansion has grown too large/
+ }
end
end
diff --git a/spec/ruby/security/cve_2017_17742_spec.rb b/spec/ruby/security/cve_2017_17742_spec.rb
deleted file mode 100644
index 72776cb497..0000000000
--- a/spec/ruby/security/cve_2017_17742_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../spec_helper'
-
-require "webrick"
-require "stringio"
-require "net/http"
-
-describe "WEBrick" do
- describe "resists CVE-2017-17742" do
- it "for a response splitting headers" do
- config = WEBrick::Config::HTTP
- res = WEBrick::HTTPResponse.new config
- res['X-header'] = "malicious\r\nCookie: hack"
- io = StringIO.new
- res.send_response io
- io.rewind
- res = Net::HTTPResponse.read_new(Net::BufferedIO.new(io))
- res.code.should == '500'
- io.string.should_not =~ /hack/
- end
-
- it "for a response splitting cookie headers" do
- user_input = "malicious\r\nCookie: hack"
- config = WEBrick::Config::HTTP
- res = WEBrick::HTTPResponse.new config
- res.cookies << WEBrick::Cookie.new('author', user_input)
- io = StringIO.new
- res.send_response io
- io.rewind
- res = Net::HTTPResponse.read_new(Net::BufferedIO.new(io))
- res.code.should == '500'
- io.string.should_not =~ /hack/
- end
- end
-end
diff --git a/spec/ruby/security/cve_2018_16396_spec.rb b/spec/ruby/security/cve_2018_16396_spec.rb
deleted file mode 100644
index 303c47a8c7..0000000000
--- a/spec/ruby/security/cve_2018_16396_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require_relative '../spec_helper'
-
-describe "Array#pack" do
-
- ruby_version_is ''...'2.7' do
- it "resists CVE-2018-16396 by tainting output based on input" do
- "aAZBbHhuMmPp".each_char do |f|
- ["123456".taint].pack(f).tainted?.should be_true
- end
- end
- end
-
-end
-
-describe "String#unpack" do
-
- ruby_version_is ''...'2.7' do
- it "resists CVE-2018-16396 by tainting output based on input" do
- "aAZBbHhuMm".each_char do |f|
- "123456".taint.unpack(f).first.tainted?.should be_true
- end
- end
- end
-
-end
diff --git a/spec/ruby/security/cve_2018_6914_spec.rb b/spec/ruby/security/cve_2018_6914_spec.rb
deleted file mode 100644
index f0aedb0dc6..0000000000
--- a/spec/ruby/security/cve_2018_6914_spec.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require_relative '../spec_helper'
-
-require 'tempfile'
-require 'tmpdir'
-
-describe "CVE-2018-6914 is resisted by" do
- before :each do
- @tmpdir = ENV['TMPDIR']
- @dir = tmp("CVE-2018-6914")
- Dir.mkdir(@dir, 0700)
- ENV['TMPDIR'] = @dir
- @dir << '/'
-
- @tempfile = nil
- end
-
- after :each do
- ENV['TMPDIR'] = @tmpdir
- @tempfile.close! if @tempfile
- rm_r @dir
- end
-
- it "Tempfile.open by deleting separators" do
- @tempfile = Tempfile.open(['../', 'foo'])
- actual = @tempfile.path
- File.absolute_path(actual).should.start_with?(@dir)
- end
-
- it "Tempfile.new by deleting separators" do
- @tempfile = Tempfile.new('../foo')
- actual = @tempfile.path
- File.absolute_path(actual).should.start_with?(@dir)
- end
-
- it "Tempfile.create by deleting separators" do
- actual = Tempfile.create('../foo') do |t|
- t.path
- end
- File.absolute_path(actual).should.start_with?(@dir)
- end
-
- it "Dir.mktmpdir by deleting separators" do
- actual = Dir.mktmpdir('../foo') do |path|
- path
- end
- File.absolute_path(actual).should.start_with?(@dir)
- end
-
- it "Dir.mktmpdir with an array by deleting separators" do
- actual = Dir.mktmpdir(['../', 'foo']) do |path|
- path
- end
- File.absolute_path(actual).should.start_with?(@dir)
- end
-end
diff --git a/spec/ruby/security/cve_2018_8778_spec.rb b/spec/ruby/security/cve_2018_8778_spec.rb
deleted file mode 100644
index 628159a4db..0000000000
--- a/spec/ruby/security/cve_2018_8778_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require_relative '../spec_helper'
-
-describe "String#unpack" do
-
- it "resists CVE-2018-8778 by raising an exception when a position indicator is larger than a native integer" do
- pos = (1 << PlatformGuard::POINTER_SIZE) - 99
- -> {
- "0123456789".unpack("@#{pos}C10")
- }.should raise_error(RangeError, /pack length too big/)
- end
-
-end
diff --git a/spec/ruby/security/cve_2018_8779_spec.rb b/spec/ruby/security/cve_2018_8779_spec.rb
deleted file mode 100644
index 603dcf497b..0000000000
--- a/spec/ruby/security/cve_2018_8779_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../spec_helper'
-
-require 'socket'
-require 'tempfile'
-
-platform_is_not :windows do
- describe "CVE-2018-8779 is resisted by" do
- before :each do
- tmpfile = Tempfile.new("s")
- @path = tmpfile.path
- tmpfile.close(true)
- end
-
- after :each do
- File.unlink @path if @path && File.socket?(@path)
- end
-
- it "UNIXServer.open by raising an exception when there is a NUL byte" do
- -> {
- UNIXServer.open(@path+"\0")
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
-
- it "UNIXSocket.open by raising an exception when there is a NUL byte" do
- -> {
- UNIXSocket.open(@path+"\0")
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
- end
-end
diff --git a/spec/ruby/security/cve_2018_8780_spec.rb b/spec/ruby/security/cve_2018_8780_spec.rb
deleted file mode 100644
index 555ce9365c..0000000000
--- a/spec/ruby/security/cve_2018_8780_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative '../spec_helper'
-
-describe "CVE-2018-8780 is resisted by" do
- before :all do
- @root = File.realpath(tmp(""))
- end
-
- it "Dir.glob by raising an exception when there is a NUL byte" do
- -> {
- Dir.glob([[@root, File.join(@root, "*")].join("\0")])
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
-
- it "Dir.entries by raising an exception when there is a NUL byte" do
- -> {
- Dir.entries(@root+"\0")
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
-
- it "Dir.foreach by raising an exception when there is a NUL byte" do
- -> {
- Dir.foreach(@root+"\0").to_a
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
-
- it "Dir.empty? by raising an exception when there is a NUL byte" do
- -> {
- Dir.empty?(@root+"\0")
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
-
- ruby_version_is "2.5" do
- it "Dir.children by raising an exception when there is a NUL byte" do
- -> {
- Dir.children(@root+"\0")
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
-
- it "Dir.each_child by raising an exception when there is a NUL byte" do
- -> {
- Dir.each_child(@root+"\0").to_a
- }.should raise_error(ArgumentError, /(path name|string) contains null byte/)
- end
- end
-end
diff --git a/spec/ruby/security/cve_2019_8321_spec.rb b/spec/ruby/security/cve_2019_8321_spec.rb
deleted file mode 100644
index affcd00e02..0000000000
--- a/spec/ruby/security/cve_2019_8321_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../spec_helper'
-
-require 'rubygems'
-require 'rubygems/user_interaction'
-
-ruby_version_is "2.5.5" do
- describe "CVE-2019-8321 is resisted by" do
- it "sanitising verbose messages" do
- ui = Class.new {
- include Gem::UserInteraction
- }.new
- ui.should_receive(:say).with(".]2;nyan.")
- verbose_before = Gem.configuration.verbose
- begin
- Gem.configuration.verbose = :really_verbose
- ui.verbose("\e]2;nyan\a")
- ensure
- Gem.configuration.verbose = verbose_before
- end
- end
- end
-end
diff --git a/spec/ruby/security/cve_2019_8322_spec.rb b/spec/ruby/security/cve_2019_8322_spec.rb
deleted file mode 100644
index 04fb1a7a26..0000000000
--- a/spec/ruby/security/cve_2019_8322_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../spec_helper'
-
-require 'yaml'
-require 'rubygems'
-require 'rubygems/safe_yaml'
-require 'rubygems/commands/owner_command'
-
-ruby_version_is "2.5.5" do
- describe "CVE-2019-8322 is resisted by" do
- it "sanitising owner names" do
- command = Gem::Commands::OwnerCommand.new
- def command.rubygems_api_request(*args)
- Struct.new(:body).new("---\n- email: \"\e]2;nyan\a\"\n handle: handle\n id: id\n")
- end
- def command.with_response(response)
- yield response
- end
- command.should_receive(:say).with("Owners for gem: name")
- command.should_receive(:say).with("- .]2;nyan.")
- command.show_owners "name"
- end
- end
-end
diff --git a/spec/ruby/security/cve_2019_8323_spec.rb b/spec/ruby/security/cve_2019_8323_spec.rb
deleted file mode 100644
index af0b270880..0000000000
--- a/spec/ruby/security/cve_2019_8323_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../spec_helper'
-
-require 'optparse'
-
-require 'rubygems'
-require 'rubygems/gemcutter_utilities'
-
-ruby_version_is "2.5.5" do
- describe "CVE-2019-8323 is resisted by" do
- describe "sanitising the body" do
- it "for success codes" do
- cutter = Class.new {
- include Gem::GemcutterUtilities
- }.new
- response = Net::HTTPSuccess.new(nil, nil, nil)
- def response.body
- "\e]2;nyan\a"
- end
- cutter.should_receive(:say).with(".]2;nyan.")
- cutter.with_response response
- end
-
- it "for error codes" do
- cutter = Class.new {
- include Gem::GemcutterUtilities
- }.new
- def cutter.terminate_interaction(n)
- end
- response = Net::HTTPNotFound.new(nil, nil, nil)
- def response.body
- "\e]2;nyan\a"
- end
- cutter.should_receive(:say).with(".]2;nyan.")
- cutter.with_response response
- end
- end
- end
-end
diff --git a/spec/ruby/security/cve_2019_8325_spec.rb b/spec/ruby/security/cve_2019_8325_spec.rb
deleted file mode 100644
index dcdbe34210..0000000000
--- a/spec/ruby/security/cve_2019_8325_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../spec_helper'
-
-require 'rubygems'
-require 'rubygems/command_manager'
-
-ruby_version_is "2.5.5" do
- describe "CVE-2019-8325 is resisted by" do
- describe "sanitising error message components" do
- it "for the 'while executing' message" do
- manager = Gem::CommandManager.new
- def manager.process_args(args, build_args)
- raise StandardError, "\e]2;nyan\a"
- end
- def manager.terminate_interaction(n)
- end
- manager.should_receive(:alert_error).with("While executing gem ... (StandardError)\n .]2;nyan.")
- manager.run nil, nil
- end
-
- it "for the 'invalid option' message" do
- manager = Gem::CommandManager.new
- def manager.terminate_interaction(n)
- end
- manager.should_receive(:alert_error).with("Invalid option: --.]2;nyan.. See 'gem --help'.")
- manager.process_args ["--\e]2;nyan\a"], nil
- end
-
- it "for the 'loading command' message" do
- manager = Gem::CommandManager.new
- def manager.require(x)
- raise 'foo'
- end
- manager.should_receive(:alert_error).with("Loading command: .]2;nyan. (RuntimeError)\n\tfoo")
- manager.send :load_and_instantiate, "\e]2;nyan\a"
- end
- end
- end
-end
diff --git a/spec/ruby/shared/basicobject/method_missing.rb b/spec/ruby/shared/basicobject/method_missing.rb
index 4871603dce..97ece14c03 100644
--- a/spec/ruby/shared/basicobject/method_missing.rb
+++ b/spec/ruby/shared/basicobject/method_missing.rb
@@ -1,5 +1,5 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/basicobject/method_missing'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/basicobject/method_missing', __FILE__)
describe :method_missing_defined_module, shared: true do
describe "for a Module with #method_missing defined" do
@@ -24,15 +24,15 @@ end
describe :method_missing_module, shared: true do
describe "for a Module" do
it "raises a NoMethodError when an undefined method is called" do
- -> { @object.no_such_method }.should raise_error(NoMethodError)
+ lambda { @object.no_such_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a protected method is called" do
- -> { @object.method_protected }.should raise_error(NoMethodError)
+ lambda { @object.method_protected }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a private method is called" do
- -> { @object.method_private }.should raise_error(NoMethodError)
+ lambda { @object.method_private }.should raise_error(NoMethodError)
end
end
end
@@ -60,15 +60,15 @@ end
describe :method_missing_class, shared: true do
describe "for a Class" do
it "raises a NoMethodError when an undefined method is called" do
- -> { @object.no_such_method }.should raise_error(NoMethodError)
+ lambda { @object.no_such_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a protected method is called" do
- -> { @object.method_protected }.should raise_error(NoMethodError)
+ lambda { @object.method_protected }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a private method is called" do
- -> { @object.method_private }.should raise_error(NoMethodError)
+ lambda { @object.method_private }.should raise_error(NoMethodError)
end
end
end
@@ -100,24 +100,26 @@ end
describe :method_missing_instance, shared: true do
describe "for an instance" do
it "raises a NoMethodError when an undefined method is called" do
- -> { @object.new.no_such_method }.should raise_error(NoMethodError)
+ lambda { @object.new.no_such_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a protected method is called" do
- -> { @object.new.method_protected }.should raise_error(NoMethodError)
+ lambda { @object.new.method_protected }.should raise_error(NoMethodError)
end
it "raises a NoMethodError when a private method is called" do
- -> { @object.new.method_private }.should raise_error(NoMethodError)
+ lambda { @object.new.method_private }.should raise_error(NoMethodError)
end
- it 'sets the receiver of the raised NoMethodError' do
- obj = @object.new
+ ruby_version_is "2.3" do
+ it 'sets the receiver of the raised NoMethodError' do
+ obj = @object.new
- begin
- obj.method_private
- rescue NoMethodError => error
- (error.receiver == obj).should == true
+ begin
+ obj.method_private
+ rescue NoMethodError => error
+ (error.receiver == obj).should == true
+ end
end
end
end
diff --git a/spec/ruby/shared/basicobject/send.rb b/spec/ruby/shared/basicobject/send.rb
index 625aaa2917..f8c63c5522 100644
--- a/spec/ruby/shared/basicobject/send.rb
+++ b/spec/ruby/shared/basicobject/send.rb
@@ -29,20 +29,13 @@ describe :basicobject_send, shared: true do
SendSpecs::Foo.send(@method, :bar).should == 'done'
end
- it "raises a TypeError if the method name is not a string or symbol" do
- -> { SendSpecs.send(@method, nil) }.should raise_error(TypeError, /not a symbol nor a string/)
- -> { SendSpecs.send(@method, 42) }.should raise_error(TypeError, /not a symbol nor a string/)
- -> { SendSpecs.send(@method, 3.14) }.should raise_error(TypeError, /not a symbol nor a string/)
- -> { SendSpecs.send(@method, true) }.should raise_error(TypeError, /not a symbol nor a string/)
- end
-
it "raises a NameError if the corresponding method can't be found" do
class SendSpecs::Foo
def bar
'done'
end
end
- -> { SendSpecs::Foo.new.send(@method, :syegsywhwua) }.should raise_error(NameError)
+ lambda { SendSpecs::Foo.new.send(@method, :syegsywhwua) }.should raise_error(NameError)
end
it "raises a NameError if the corresponding singleton method can't be found" do
@@ -51,12 +44,12 @@ describe :basicobject_send, shared: true do
'done'
end
end
- -> { SendSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
+ lambda { SendSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
end
it "raises an ArgumentError if no arguments are given" do
class SendSpecs::Foo; end
- -> { SendSpecs::Foo.new.send @method }.should raise_error(ArgumentError)
+ lambda { SendSpecs::Foo.new.send @method }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if called with more arguments than available parameters" do
@@ -64,7 +57,7 @@ describe :basicobject_send, shared: true do
def bar; end
end
- -> { SendSpecs::Foo.new.send(@method, :bar, :arg) }.should raise_error(ArgumentError)
+ lambda { SendSpecs::Foo.new.send(@method, :bar, :arg) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if called with fewer arguments than required parameters" do
@@ -72,7 +65,7 @@ describe :basicobject_send, shared: true do
def foo(arg); end
end
- -> { SendSpecs::Foo.new.send(@method, :foo) }.should raise_error(ArgumentError)
+ lambda { SendSpecs::Foo.new.send(@method, :foo) }.should raise_error(ArgumentError)
end
it "succeeds if passed an arbitrary number of arguments as a splat parameter" do
@@ -114,15 +107,4 @@ describe :basicobject_send, shared: true do
it "has a negative arity" do
method(@method).arity.should < 0
end
-
- it "invokes module methods with super correctly" do
- m1 = Module.new { def foo(ary); ary << :m1; end; }
- m2 = Module.new { def foo(ary = []); super(ary); ary << :m2; end; }
- c2 = Class.new do
- include m1
- include m2
- end
-
- c2.new.send(@method, :foo, *[[]]).should == %i[m1 m2]
- end
end
diff --git a/spec/ruby/shared/complex/Complex.rb b/spec/ruby/shared/complex/Complex.rb
new file mode 100644
index 0000000000..5a9715b161
--- /dev/null
+++ b/spec/ruby/shared/complex/Complex.rb
@@ -0,0 +1,133 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :kernel_Complex, shared: true do
+ describe "when passed [Complex, Complex]" do
+ it "returns a new Complex number based on the two given numbers" do
+ Complex(Complex(3, 4), Complex(5, 6)).should == Complex(3 - 6, 4 + 5)
+ Complex(Complex(1.5, 2), Complex(-5, 6.3)).should == Complex(1.5 - 6.3, 2 - 5)
+ end
+ end
+
+ describe "when passed [Complex]" do
+ it "returns the passed Complex number" do
+ Complex(Complex(1, 2)).should == Complex(1, 2)
+ Complex(Complex(-3.4, bignum_value)).should == Complex(-3.4, bignum_value)
+ end
+ end
+
+ describe "when passed [Integer, Integer]" do
+ it "returns a new Complex number" do
+ Complex(1, 2).should be_an_instance_of(Complex)
+ Complex(1, 2).real.should == 1
+ Complex(1, 2).imag.should == 2
+
+ Complex(-3, -5).should be_an_instance_of(Complex)
+ Complex(-3, -5).real.should == -3
+ Complex(-3, -5).imag.should == -5
+
+ Complex(3.5, -4.5).should be_an_instance_of(Complex)
+ Complex(3.5, -4.5).real.should == 3.5
+ Complex(3.5, -4.5).imag.should == -4.5
+
+ Complex(bignum_value, 30).should be_an_instance_of(Complex)
+ Complex(bignum_value, 30).real.should == bignum_value
+ Complex(bignum_value, 30).imag.should == 30
+ end
+ end
+
+ describe "when passed [Integer]" do
+ it "returns a new Complex number with 0 as the imaginary component" do
+ # Guard against the Mathn library
+ conflicts_with :Prime do
+ Complex(1).should be_an_instance_of(Complex)
+ Complex(1).imag.should == 0
+ Complex(1).real.should == 1
+
+ Complex(-3).should be_an_instance_of(Complex)
+ Complex(-3).imag.should == 0
+ Complex(-3).real.should == -3
+
+ Complex(-4.5).should be_an_instance_of(Complex)
+ Complex(-4.5).imag.should == 0
+ Complex(-4.5).real.should == -4.5
+
+ Complex(bignum_value).should be_an_instance_of(Complex)
+ Complex(bignum_value).imag.should == 0
+ Complex(bignum_value).real.should == bignum_value
+ end
+ end
+ end
+
+ describe "when passed a String" do
+ it "needs to be reviewed for spec completeness"
+ end
+
+ describe "when passed an Objectc which responds to #to_c" do
+ it "returns the passed argument" do
+ obj = Object.new; def obj.to_c; 1i end
+ Complex(obj).should == Complex(0, 1)
+ end
+ end
+
+ describe "when passed a Numeric which responds to #real? with false" do
+ it "returns the passed argument" do
+ n = mock_numeric("unreal")
+ n.should_receive(:real?).and_return(false)
+ Complex(n).should equal(n)
+ end
+ end
+
+ describe "when passed a Numeric which responds to #real? with true" do
+ it "returns a Complex with the passed argument as the real component and 0 as the imaginary component" do
+ n = mock_numeric("real")
+ n.should_receive(:real?).any_number_of_times.and_return(true)
+ result = Complex(n)
+ result.real.should equal(n)
+ result.imag.should equal(0)
+ end
+ end
+
+ describe "when passed Numerics n1 and n2 and at least one responds to #real? with false" do
+ [[false, false], [false, true], [true, false]].each do |r1, r2|
+ it "returns n1 + n2 * Complex(0, 1)" do
+ n1 = mock_numeric("n1")
+ n2 = mock_numeric("n2")
+ n3 = mock_numeric("n3")
+ n4 = mock_numeric("n4")
+ n1.should_receive(:real?).any_number_of_times.and_return(r1)
+ n2.should_receive(:real?).any_number_of_times.and_return(r2)
+ n2.should_receive(:*).with(Complex(0, 1)).and_return(n3)
+ n1.should_receive(:+).with(n3).and_return(n4)
+ Complex(n1, n2).should equal(n4)
+ end
+ end
+ end
+
+ describe "when passed two Numerics and both respond to #real? with true" do
+ it "returns a Complex with the passed arguments as real and imaginary components respectively" do
+ n1 = mock_numeric("n1")
+ n2 = mock_numeric("n2")
+ n1.should_receive(:real?).any_number_of_times.and_return(true)
+ n2.should_receive(:real?).any_number_of_times.and_return(true)
+ result = Complex(n1, n2)
+ result.real.should equal(n1)
+ result.imag.should equal(n2)
+ end
+ end
+
+ describe "when passed a single non-Numeric" do
+ it "coerces the passed argument using #to_c" do
+ n = mock("n")
+ c = Complex(0, 0)
+ n.should_receive(:to_c).and_return(c)
+ Complex(n).should equal(c)
+ end
+ end
+
+ describe "when passed a non-Numeric second argument" do
+ it "raises TypeError" do
+ lambda { Complex.send(@method, :sym, :sym) }.should raise_error(TypeError)
+ lambda { Complex.send(@method, 0, :sym) }.should raise_error(TypeError)
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/abs.rb b/spec/ruby/shared/complex/abs.rb
new file mode 100644
index 0000000000..1f8d861f65
--- /dev/null
+++ b/spec/ruby/shared/complex/abs.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_abs, shared: true do
+ it "returns the modulus: |a + bi| = sqrt((a ^ 2) + (b ^ 2))" do
+ Complex(0, 0).send(@method).should == 0
+ Complex(3, 4).send(@method).should == 5 # well-known integer case
+ Complex(-3, 4).send(@method).should == 5
+ Complex(1, -1).send(@method).should be_close(Math.sqrt(2), TOLERANCE)
+ Complex(6.5, 0).send(@method).should be_close(6.5, TOLERANCE)
+ Complex(0, -7.2).send(@method).should be_close(7.2, TOLERANCE)
+ end
+end
diff --git a/spec/ruby/shared/complex/abs2.rb b/spec/ruby/shared/complex/abs2.rb
new file mode 100644
index 0000000000..f899a41a3e
--- /dev/null
+++ b/spec/ruby/shared/complex/abs2.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_abs2, shared: true do
+ it "returns the sum of the squares of the real and imaginary parts" do
+ Complex(1, -2).abs2.should == 1 + 4
+ Complex(-0.1, 0.2).abs2.should be_close(0.01 + 0.04, TOLERANCE)
+ # Guard against Mathn library
+ conflicts_with :Prime do
+ Complex(0).abs2.should == 0
+ end
+ end
+end
diff --git a/spec/ruby/core/complex/shared/arg.rb b/spec/ruby/shared/complex/arg.rb
index c81f197433..c81f197433 100644
--- a/spec/ruby/core/complex/shared/arg.rb
+++ b/spec/ruby/shared/complex/arg.rb
diff --git a/spec/ruby/shared/complex/coerce.rb b/spec/ruby/shared/complex/coerce.rb
new file mode 100644
index 0000000000..b8a230dfb5
--- /dev/null
+++ b/spec/ruby/shared/complex/coerce.rb
@@ -0,0 +1,70 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_coerce, shared: true do
+ before :each do
+ @one = Complex(1)
+ end
+
+ it "returns an array containing other and self as Complex when other is an Integer" do
+ result = @one.coerce(2)
+ result.should == [2, 1]
+ result.first.should be_kind_of(Complex)
+ result.last.should be_kind_of(Complex)
+ end
+
+ it "returns an array containing other and self as Complex when other is a Float" do
+ result = @one.coerce(20.5)
+ result.should == [20.5, 1]
+ result.first.should be_kind_of(Complex)
+ result.last.should be_kind_of(Complex)
+ end
+
+ it "returns an array containing other and self as Complex when other is a Bignum" do
+ result = @one.coerce(4294967296)
+ result.should == [4294967296, 1]
+ result.first.should be_kind_of(Complex)
+ result.last.should be_kind_of(Complex)
+ end
+
+ it "returns an array containing other and self as Complex when other is a Rational" do
+ result = @one.coerce(Rational(5,6))
+ result.should == [Rational(5,6), 1]
+ result.first.should be_kind_of(Complex)
+ result.last.should be_kind_of(Complex)
+ end
+
+ it "returns an array containing other and self when other is a Complex" do
+ other = Complex(2)
+ result = @one.coerce(other)
+ result.should == [other, @one]
+ result.first.should equal(other)
+ result.last.should equal(@one)
+ end
+
+ it "returns an array containing other as Complex and self when other is a Numeric which responds to #real? with true" do
+ other = mock_numeric('other')
+ other.should_receive(:real?).any_number_of_times.and_return(true)
+ result = @one.coerce(other)
+ result.should == [other, @one]
+ result.first.should eql(Complex(other))
+ result.last.should equal(@one)
+ end
+
+ it "raises TypeError when other is a Numeric which responds to #real? with false" do
+ other = mock_numeric('other')
+ other.should_receive(:real?).any_number_of_times.and_return(false)
+ lambda { @one.coerce(other) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when other is a String" do
+ lambda { @one.coerce("20") }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when other is nil" do
+ lambda { @one.coerce(nil) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when other is false" do
+ lambda { @one.coerce(false) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/core/complex/shared/conjugate.rb b/spec/ruby/shared/complex/conjugate.rb
index d1ae47bcb6..d1ae47bcb6 100644
--- a/spec/ruby/core/complex/shared/conjugate.rb
+++ b/spec/ruby/shared/complex/conjugate.rb
diff --git a/spec/ruby/shared/complex/constants.rb b/spec/ruby/shared/complex/constants.rb
new file mode 100644
index 0000000000..e8bb5fc907
--- /dev/null
+++ b/spec/ruby/shared/complex/constants.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_I, shared: true do
+ it "is Complex(0, 1)" do
+ Complex::I.should eql(Complex(0, 1))
+ end
+end
diff --git a/spec/ruby/shared/complex/denominator.rb b/spec/ruby/shared/complex/denominator.rb
new file mode 100644
index 0000000000..6084cbf672
--- /dev/null
+++ b/spec/ruby/shared/complex/denominator.rb
@@ -0,0 +1,13 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_denominator, shared: true do
+ it "returns the least common multiple denominator of the real and imaginary parts" do
+ Complex(3, 4).denominator.should == 1
+ Complex(3, bignum_value).denominator.should == 1
+
+ Complex(3, Rational(3,4)).denominator.should == 4
+
+ Complex(Rational(4,8), Rational(3,4)).denominator.should == 4
+ Complex(Rational(3,8), Rational(3,4)).denominator.should == 8
+ end
+end
diff --git a/spec/ruby/shared/complex/divide.rb b/spec/ruby/shared/complex/divide.rb
new file mode 100644
index 0000000000..0bd88f197e
--- /dev/null
+++ b/spec/ruby/shared/complex/divide.rb
@@ -0,0 +1,84 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_divide, shared: true do
+ describe "with Complex" do
+ it "divides according to the usual rule for complex numbers" do
+ a = Complex((1 * 10) - (2 * 20), (1 * 20) + (2 * 10))
+ b = Complex(1, 2)
+ a.send(@method, b).should == Complex(10, 20)
+
+ c = Complex((1.5 * 100.2) - (2.1 * -30.3), (1.5 * -30.3) + (2.1 * 100.2))
+ d = Complex(1.5, 2.1)
+ # remember the floating-point arithmetic
+ c.send(@method, d).should be_close(Complex(100.2, -30.3), TOLERANCE)
+ end
+ end
+
+ describe "with Fixnum" do
+ it "divides both parts of the Complex number" do
+ Complex(20, 40).send(@method, 2).should == Complex(10, 20)
+ Complex(30, 30).send(@method, 10).should == Complex(3, 3)
+ end
+
+ it "raises a ZeroDivisionError when given zero" do
+ lambda { Complex(20, 40).send(@method, 0) }.should raise_error(ZeroDivisionError)
+ end
+
+ it "produces Rational parts" do
+ Complex(5, 9).send(@method, 2).should eql(Complex(Rational(5,2), Rational(9,2)))
+ end
+ end
+
+ describe "with Bignum" do
+ it "divides both parts of the Complex number" do
+ Complex(20, 40).send(@method, 2).should == Complex(10, 20)
+ Complex(15, 16).send(@method, 2.0).should be_close(Complex(7.5, 8), TOLERANCE)
+ end
+ end
+
+ describe "with Float" do
+ it "divides both parts of the Complex number" do
+ Complex(3, 9).send(@method, 1.5).should == Complex(2, 6)
+ Complex(15, 16).send(@method, 2.0).should be_close(Complex(7.5, 8), TOLERANCE)
+ end
+
+ it "returns Complex(Infinity, Infinity) when given zero" do
+ Complex(20, 40).send(@method, 0.0).real.infinite?.should == 1
+ Complex(20, 40).send(@method, 0.0).imag.infinite?.should == 1
+ Complex(-20, 40).send(@method, 0.0).real.infinite?.should == -1
+ Complex(-20, 40).send(@method, 0.0).imag.infinite?.should == 1
+ end
+ end
+
+ describe "with Object" do
+ it "tries to coerce self into other" do
+ value = Complex(3, 9)
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(value).and_return([4, 2])
+ value.send(@method, obj).should == 2
+ end
+ end
+
+ describe "with a Numeric which responds to #real? with true" do
+ it "returns Complex(real.quo(other), imag.quo(other))" do
+ other = mock_numeric('other')
+ real = mock_numeric('real')
+ imag = mock_numeric('imag')
+ other.should_receive(:real?).and_return(true)
+ real.should_receive(:quo).with(other).and_return(1)
+ imag.should_receive(:quo).with(other).and_return(2)
+ Complex(real, imag).send(@method, other).should == Complex(1, 2)
+ end
+ end
+
+ describe "with a Numeric which responds to #real? with false" do
+ it "coerces the passed argument to Complex and divides the resulting elements" do
+ complex = Complex(3, 0)
+ other = mock_numeric('other')
+ other.should_receive(:real?).any_number_of_times.and_return(false)
+ other.should_receive(:coerce).with(complex).and_return([5, 2])
+ complex.send(@method, other).should eql(Rational(5, 2))
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/equal_value.rb b/spec/ruby/shared/complex/equal_value.rb
new file mode 100644
index 0000000000..d944698878
--- /dev/null
+++ b/spec/ruby/shared/complex/equal_value.rb
@@ -0,0 +1,93 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_equal_value, shared: true do
+ describe "with Complex" do
+ it "returns true when self and other have numerical equality" do
+ Complex(1, 2).should == Complex(1, 2)
+ Complex(3, 9).should == Complex(3, 9)
+ Complex(-3, -9).should == Complex(-3, -9)
+
+ Complex(1, 2).should_not == Complex(3, 4)
+ Complex(3, 9).should_not == Complex(9, 3)
+
+ Complex(1.0, 2.0).should == Complex(1, 2)
+ Complex(3.0, 9.0).should_not == Complex(9.0, 3.0)
+
+ Complex(1.5, 2.5).should == Complex(1.5, 2.5)
+ Complex(1.5, 2.5).should == Complex(1.5, 2.5)
+ Complex(-1.5, 2.5).should == Complex(-1.5, 2.5)
+
+ Complex(1.5, 2.5).should_not == Complex(2.5, 1.5)
+ Complex(3.75, 2.5).should_not == Complex(1.5, 2.5)
+
+ Complex(bignum_value, 2.5).should == Complex(bignum_value, 2.5)
+ Complex(3.75, bignum_value).should_not == Complex(1.5, bignum_value)
+
+ Complex(nan_value).should_not == Complex(nan_value)
+ end
+ end
+
+ describe "with Numeric" do
+ it "returns true when self's imaginary part is 0 and the real part and other have numerical equality" do
+ Complex(3, 0).should == 3
+ Complex(-3, 0).should == -3
+
+ Complex(3.5, 0).should == 3.5
+ Complex(-3.5, 0).should == -3.5
+
+ Complex(bignum_value, 0).should == bignum_value
+ Complex(-bignum_value, 0).should == -bignum_value
+
+ Complex(3.0, 0).should == 3
+ Complex(-3.0, 0).should == -3
+
+ Complex(3, 0).should_not == 4
+ Complex(-3, 0).should_not == -4
+
+ Complex(3.5, 0).should_not == -4.5
+ Complex(-3.5, 0).should_not == 2.5
+
+ Complex(bignum_value, 0).should_not == bignum_value(10)
+ Complex(-bignum_value, 0).should_not == -bignum_value(20)
+ end
+ end
+
+ describe "with Object" do
+ # Fixnum#==, Float#== and Bignum#== only return booleans - Bug?
+ it "calls other#== with self" do
+ value = Complex(3, 0)
+
+ obj = mock("Object")
+ obj.should_receive(:==).with(value).and_return(:expected)
+
+ (value == obj).should_not be_false
+ end
+ end
+
+ describe "with a Numeric which responds to #real? with true" do
+ before do
+ @other = mock_numeric('other')
+ @other.should_receive(:real?).any_number_of_times.and_return(true)
+ end
+
+ it "returns real == other when the imaginary part is zero" do
+ real = mock_numeric('real')
+ real.should_receive(:==).with(@other).and_return(true)
+ (Complex(real, 0) == @other).should be_true
+ end
+
+ it "returns false when when the imaginary part is not zero" do
+ (Complex(3, 1) == @other).should be_false
+ end
+ end
+
+ describe "with a Numeric which responds to #real? with false" do
+ it "returns other == self" do
+ complex = Complex(3, 0)
+ other = mock_numeric('other')
+ other.should_receive(:real?).any_number_of_times.and_return(false)
+ other.should_receive(:==).with(complex).and_return(true)
+ (complex == other).should be_true
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/exponent.rb b/spec/ruby/shared/complex/exponent.rb
new file mode 100644
index 0000000000..8261db872a
--- /dev/null
+++ b/spec/ruby/shared/complex/exponent.rb
@@ -0,0 +1,61 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_exponent, shared: true do
+ describe "with Fixnum 0" do
+ it "returns Complex(1)" do
+ (Complex(3, 4) ** 0).should eql(Complex(1))
+ end
+ end
+
+ describe "with Float 0.0" do
+ it "returns Complex(1.0, 0.0)" do
+ (Complex(3, 4) ** 0.0).should eql(Complex(1.0, 0.0))
+ end
+ end
+
+ describe "with Complex" do
+ it "returns self raised to the given power" do
+ (Complex(2, 1) ** Complex(2, 1)).should be_close(Complex(-0.504824688978319, 3.10414407699553), TOLERANCE)
+ (Complex(2, 1) ** Complex(3, 4)).should be_close(Complex(-0.179174656916581, -1.74071656397662), TOLERANCE)
+
+ (Complex(2, 1) ** Complex(-2, -1)).should be_close(Complex(-0.051041070450869, -0.313849223270419), TOLERANCE)
+ (Complex(-2, -1) ** Complex(2, 1)).should be_close(Complex(-11.6819929610857, 71.8320439736158), TOLERANCE)
+ end
+ end
+
+ describe "with Integer" do
+ it "returns self raised to the given power" do
+ (Complex(2, 1) ** 2).should == Complex(3, 4)
+ (Complex(3, 4) ** 2).should == Complex(-7, 24)
+ (Complex(3, 4) ** -2).should be_close(Complex(-0.0112, -0.0384), TOLERANCE)
+
+
+ (Complex(2, 1) ** 2.5).should be_close(Complex(2.99179707178602, 6.85206901006896), TOLERANCE)
+ (Complex(3, 4) ** 2.5).should be_close(Complex(-38.0, 41.0), TOLERANCE)
+ (Complex(3, 4) ** -2.5).should be_close(Complex(-0.01216, -0.01312), TOLERANCE)
+
+ (Complex(1) ** 1).should == Complex(1)
+
+ # NOTE: Takes way too long...
+ #(Complex(2, 1) ** bignum_value)
+ end
+ end
+
+ describe "with Rational" do
+ it "returns self raised to the given power" do
+ (Complex(2, 1) ** Rational(3, 4)).should be_close(Complex(1.71913265276568, 0.623124744394697), TOLERANCE)
+ (Complex(2, 1) ** Rational(4, 3)).should be_close(Complex(2.3828547125173, 1.69466313833091), TOLERANCE)
+ (Complex(2, 1) ** Rational(-4, 3)).should be_close(Complex(0.278700377879388, -0.198209003071003), TOLERANCE)
+ end
+ end
+
+ describe "with Object" do
+ it "tries to coerce self into other" do
+ value = Complex(3, 9)
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(value).and_return([2, 5])
+ (value ** obj).should == 2 ** 5
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/float/arg.rb b/spec/ruby/shared/complex/float/arg.rb
new file mode 100644
index 0000000000..ca29796610
--- /dev/null
+++ b/spec/ruby/shared/complex/float/arg.rb
@@ -0,0 +1,38 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe :float_arg, shared: true do
+ it "returns NaN if NaN" do
+ f = nan_value
+ f.send(@method).nan?.should be_true
+ end
+
+ it "returns self if NaN" do
+ f = nan_value
+ f.send(@method).should equal(f)
+ end
+
+ it "returns 0 if positive" do
+ 1.0.send(@method).should == 0
+ end
+
+ it "returns 0 if +0.0" do
+ 0.0.send(@method).should == 0
+ end
+
+ it "returns 0 if +Infinity" do
+ infinity_value.send(@method).should == 0
+ end
+
+ it "returns Pi if negative" do
+ (-1.0).send(@method).should == Math::PI
+ end
+
+ # This was established in r23960
+ it "returns Pi if -0.0" do
+ (-0.0).send(@method).should == Math::PI
+ end
+
+ it "returns Pi if -Infinity" do
+ (-infinity_value).send(@method).should == Math::PI
+ end
+end
diff --git a/spec/ruby/shared/complex/hash.rb b/spec/ruby/shared/complex/hash.rb
new file mode 100644
index 0000000000..26ca59aeaf
--- /dev/null
+++ b/spec/ruby/shared/complex/hash.rb
@@ -0,0 +1,16 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_hash, shared: true do
+ it "is static" do
+ Complex(1).hash.should == Complex(1).hash
+ Complex(1, 0).hash.should == Complex(1).hash
+ Complex(1, 1).hash.should == Complex(1, 1).hash
+ end
+
+ it "is different for different instances" do
+ Complex(1, 2).hash.should_not == Complex(1, 1).hash
+ Complex(2, 1).hash.should_not == Complex(1, 1).hash
+
+ Complex(1, 2).hash.should_not == Complex(2, 1).hash
+ end
+end
diff --git a/spec/ruby/shared/complex/image.rb b/spec/ruby/shared/complex/image.rb
new file mode 100644
index 0000000000..5d45210b45
--- /dev/null
+++ b/spec/ruby/shared/complex/image.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_image, shared: true do
+ it "returns the imaginary part of self" do
+ Complex(1, 0).send(@method).should == 0
+ Complex(2, 1).send(@method).should == 1
+ Complex(6.7, 8.9).send(@method).should == 8.9
+ Complex(1, bignum_value).send(@method).should == bignum_value
+ end
+end
diff --git a/spec/ruby/shared/complex/inspect.rb b/spec/ruby/shared/complex/inspect.rb
new file mode 100644
index 0000000000..7c0c3d6b9c
--- /dev/null
+++ b/spec/ruby/shared/complex/inspect.rb
@@ -0,0 +1,14 @@
+describe :complex_inspect, shared: true do
+ it "returns (${real}+${image}i) for positive imaginary parts" do
+ Complex(1).inspect.should == "(1+0i)"
+ Complex(7).inspect.should == "(7+0i)"
+ Complex(-1, 4).inspect.should == "(-1+4i)"
+ Complex(-7, 6.7).inspect.should == "(-7+6.7i)"
+ end
+
+ it "returns (${real}-${image}i) for negative imaginary parts" do
+ Complex(0, -1).inspect.should == "(0-1i)"
+ Complex(-1, -4).inspect.should == "(-1-4i)"
+ Complex(-7, -6.7).inspect.should == "(-7-6.7i)"
+ end
+end
diff --git a/spec/ruby/shared/complex/minus.rb b/spec/ruby/shared/complex/minus.rb
new file mode 100644
index 0000000000..c28d08ad2e
--- /dev/null
+++ b/spec/ruby/shared/complex/minus.rb
@@ -0,0 +1,45 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_minus, shared: true do
+ describe "with Complex" do
+ it "subtracts both the real and imaginary components" do
+ (Complex(1, 2) - Complex(10, 20)).should == Complex(1 - 10, 2 - 20)
+ (Complex(1.5, 2.1) - Complex(100.2, -30.3)).should == Complex(1.5 - 100.2, 2.1 - (-30.3))
+ end
+ end
+
+ describe "with Integer" do
+ it "subtracts the real number from the real component of self" do
+ (Complex(1, 2) - 50).should == Complex(-49, 2)
+ (Complex(1, 2) - 50.5).should == Complex(-49.5, 2)
+ end
+ end
+
+ describe "with Object" do
+ it "tries to coerce self into other" do
+ value = Complex(3, 9)
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(value).and_return([2, 5])
+ (value - obj).should == 2 - 5
+ end
+ end
+
+ describe "passed Numeric which responds to #real? with true" do
+ it "coerces the passed argument to the type of the real part and subtracts the resulting elements" do
+ n = mock_numeric('n')
+ n.should_receive(:real?).and_return(true)
+ n.should_receive(:coerce).with(1).and_return([1, 4])
+ (Complex(1, 2) - n).should == Complex(-3, 2)
+ end
+ end
+
+ describe "passed Numeric which responds to #real? with false" do
+ it "coerces the passed argument to Complex and subtracts the resulting elements" do
+ n = mock_numeric('n')
+ n.should_receive(:real?).and_return(false)
+ n.should_receive(:coerce).with(Complex(1, 2)).and_return([Complex(1, 2), Complex(3, 4)])
+ (Complex(1, 2) - n).should == Complex(-2, -2)
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/multiply.rb b/spec/ruby/shared/complex/multiply.rb
new file mode 100644
index 0000000000..4d94ef2ce3
--- /dev/null
+++ b/spec/ruby/shared/complex/multiply.rb
@@ -0,0 +1,49 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_multiply, shared: true do
+ describe "with Complex" do
+ it "multiplies according to the usual rule for complex numbers: (a + bi) * (c + di) = ac - bd + (ad + bc)i" do
+ (Complex(1, 2) * Complex(10, 20)).should == Complex((1 * 10) - (2 * 20), (1 * 20) + (2 * 10))
+ (Complex(1.5, 2.1) * Complex(100.2, -30.3)).should == Complex((1.5 * 100.2) - (2.1 * -30.3), (1.5 * -30.3) + (2.1 * 100.2))
+ end
+ end
+
+ describe "with Integer" do
+ it "multiplies both parts of self by the given Integer" do
+ (Complex(3, 2) * 50).should == Complex(150, 100)
+ (Complex(-3, 2) * 50.5).should == Complex(-151.5, 101)
+ end
+ end
+
+ describe "with Object" do
+ it "tries to coerce self into other" do
+ value = Complex(3, 9)
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(value).and_return([2, 5])
+ (value * obj).should == 2 * 5
+ end
+ end
+
+ describe "with a Numeric which responds to #real? with true" do
+ it "multiples both parts of self by other" do
+ other = mock_numeric('other')
+ real = mock_numeric('real')
+ imag = mock_numeric('imag')
+ other.should_receive(:real?).and_return(true)
+ real.should_receive(:*).with(other).and_return(1)
+ imag.should_receive(:*).with(other).and_return(2)
+ (Complex(real, imag) * other).should == Complex(1, 2)
+ end
+
+ describe "with a Numeric which responds to #real? with false" do
+ it "coerces the passed argument to Complex and multiplies the resulting elements" do
+ complex = Complex(3, 0)
+ other = mock_numeric('other')
+ other.should_receive(:real?).any_number_of_times.and_return(false)
+ other.should_receive(:coerce).with(complex).and_return([5, 2])
+ (complex * other).should == 10
+ end
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/numerator.rb b/spec/ruby/shared/complex/numerator.rb
new file mode 100644
index 0000000000..b8384e4a93
--- /dev/null
+++ b/spec/ruby/shared/complex/numerator.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_numerator, shared: true do
+ it "returns self's numerator" do
+ Complex(2).numerator.should == Complex(2)
+ Complex(3, 4).numerator.should == Complex(3, 4)
+
+ Complex(Rational(3, 4), Rational(3, 4)).numerator.should == Complex(3, 3)
+ Complex(Rational(7, 4), Rational(8, 4)).numerator.should == Complex(7, 8)
+
+ Complex(Rational(7, 8), Rational(8, 4)).numerator.should == Complex(7, 16)
+ Complex(Rational(7, 4), Rational(8, 8)).numerator.should == Complex(7, 4)
+
+ # NOTE:
+ # Bug? - Fails with a MethodMissingError
+ # (undefined method `denominator' for 3.5:Float)
+ # Complex(3.5, 3.7).numerator
+ end
+end
diff --git a/spec/ruby/shared/complex/numeric/arg.rb b/spec/ruby/shared/complex/numeric/arg.rb
new file mode 100644
index 0000000000..b7eb1f2e2d
--- /dev/null
+++ b/spec/ruby/shared/complex/numeric/arg.rb
@@ -0,0 +1,38 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe :numeric_arg, shared: true do
+ before :each do
+ @numbers = [
+ 20,
+ Rational(3, 4),
+ bignum_value,
+ infinity_value
+ ]
+ end
+
+ it "returns 0 if positive" do
+ @numbers.each do |number|
+ number.send(@method).should == 0
+ end
+ end
+
+ it "returns Pi if negative" do
+ @numbers.each do |number|
+ (0-number).send(@method).should == Math::PI
+ end
+ end
+
+ describe "with a Numeric subclass" do
+ it "returns 0 if self#<(0) returns false" do
+ numeric = mock_numeric('positive')
+ numeric.should_receive(:<).with(0).and_return(false)
+ numeric.send(@method).should == 0
+ end
+
+ it "returns Pi if self#<(0) returns true" do
+ numeric = mock_numeric('positive')
+ numeric.should_receive(:<).with(0).and_return(true)
+ numeric.send(@method).should == Math::PI
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/numeric/conj.rb b/spec/ruby/shared/complex/numeric/conj.rb
new file mode 100644
index 0000000000..50cb060442
--- /dev/null
+++ b/spec/ruby/shared/complex/numeric/conj.rb
@@ -0,0 +1,20 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe :numeric_conj, shared: true do
+ before :each do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ bignum_value,
+ infinity_value,
+ nan_value
+ ]
+ end
+
+ it "returns self" do
+ @numbers.each do |number|
+ number.send(@method).should equal(number)
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/numeric/imag.rb b/spec/ruby/shared/complex/numeric/imag.rb
new file mode 100644
index 0000000000..caf54e2cf9
--- /dev/null
+++ b/spec/ruby/shared/complex/numeric/imag.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe :numeric_imag, shared: true do
+ before :each do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ bignum_value, # Bignum
+ infinity_value,
+ nan_value
+ ].map{|n| [n,-n]}.flatten
+ end
+
+ it "returns 0" do
+ @numbers.each do |number|
+ number.send(@method).should == 0
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/numeric/polar.rb b/spec/ruby/shared/complex/numeric/polar.rb
new file mode 100644
index 0000000000..952b65c1b6
--- /dev/null
+++ b/spec/ruby/shared/complex/numeric/polar.rb
@@ -0,0 +1,50 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe :numeric_polar, shared: true do
+ before :each do
+ @pos_numbers = [
+ 1,
+ 3898172610**9,
+ 987.18273,
+ Float::MAX,
+ Rational(13,7),
+ infinity_value,
+ ]
+ @neg_numbers = @pos_numbers.map {|n| -n}
+ @numbers = @pos_numbers + @neg_numbers
+ @numbers.push(0, 0.0)
+ end
+
+ it "returns a two-element Array" do
+ @numbers.each do |number|
+ number.polar.should be_an_instance_of(Array)
+ number.polar.size.should == 2
+ end
+ end
+
+ it "sets the first value to the absolute value of self" do
+ @numbers.each do |number|
+ number.polar.first.should == number.abs
+ end
+ end
+
+ it "sets the last value to 0 if self is positive" do
+ (@numbers - @neg_numbers).each do |number|
+ number.should >= 0
+ number.polar.last.should == 0
+ end
+ end
+
+ it "sets the last value to Pi if self is negative" do
+ @neg_numbers.each do |number|
+ number.should < 0
+ number.polar.last.should == Math::PI
+ end
+ end
+
+ it "returns [NaN, NaN] if self is NaN" do
+ nan_value.polar.size.should == 2
+ nan_value.polar.first.nan?.should be_true
+ nan_value.polar.last.nan?.should be_true
+ end
+end
diff --git a/spec/ruby/shared/complex/numeric/real.rb b/spec/ruby/shared/complex/numeric/real.rb
new file mode 100644
index 0000000000..0dcf2e8381
--- /dev/null
+++ b/spec/ruby/shared/complex/numeric/real.rb
@@ -0,0 +1,30 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe :numeric_real, shared: true do
+ before :each do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ bignum_value, # Bignum
+ infinity_value,
+ nan_value
+ ].map{|n| [n,-n]}.flatten
+ end
+
+ it "returns self" do
+ @numbers.each do |number|
+ if number.to_f.nan?
+ number.real.nan?.should be_true
+ else
+ number.real.should == number
+ end
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.real(number) }.should raise_error(ArgumentError)
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/plus.rb b/spec/ruby/shared/complex/plus.rb
new file mode 100644
index 0000000000..47e362d886
--- /dev/null
+++ b/spec/ruby/shared/complex/plus.rb
@@ -0,0 +1,45 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_plus, shared: true do
+ describe "with Complex" do
+ it "adds both the real and imaginary components" do
+ (Complex(1, 2) + Complex(10, 20)).should == Complex(1 + 10, 2 + 20)
+ (Complex(1.5, 2.1) + Complex(100.2, -30.3)).should == Complex(1.5 + 100.2, 2.1 + (-30.3))
+ end
+ end
+
+ describe "with Integer" do
+ it "adds the real number to the real component of self" do
+ (Complex(1, 2) + 50).should == Complex(51, 2)
+ (Complex(1, 2) + 50.5).should == Complex(51.5, 2)
+ end
+ end
+
+ describe "with Object" do
+ it "tries to coerce self into other" do
+ value = Complex(3, 9)
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(value).and_return([2, 5])
+ (value + obj).should == 2 + 5
+ end
+ end
+
+ describe "passed Numeric which responds to #real? with true" do
+ it "coerces the passed argument to the type of the real part and adds the resulting elements" do
+ n = mock_numeric('n')
+ n.should_receive(:real?).and_return(true)
+ n.should_receive(:coerce).with(1).and_return([1, 4])
+ (Complex(1, 2) + n).should == Complex(5, 2)
+ end
+ end
+
+ describe "passed Numeric which responds to #real? with false" do
+ it "coerces the passed argument to Complex and adds the resulting elements" do
+ n = mock_numeric('n')
+ n.should_receive(:real?).and_return(false)
+ n.should_receive(:coerce).with(Complex(1, 2)).and_return([Complex(1, 2), Complex(3, 4)])
+ (Complex(1, 2) + n).should == Complex(4, 6)
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/polar.rb b/spec/ruby/shared/complex/polar.rb
new file mode 100644
index 0000000000..acc063d89f
--- /dev/null
+++ b/spec/ruby/shared/complex/polar.rb
@@ -0,0 +1,22 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_polar_class, shared: true do
+ it "returns a complex number in terms of radius and angle" do
+ Complex.polar(50, 60).should be_close(Complex(-47.6206490207578, -15.2405310551108), TOLERANCE)
+ Complex.polar(-10, -20).should be_close(Complex(-4.08082061813392, 9.12945250727628), TOLERANCE)
+ end
+end
+
+describe :complex_polar, shared: true do
+ it "returns the absolute value and the argument" do
+ a = Complex(3, 4)
+ a.polar.size.should == 2
+ a.polar.first.should == 5.0
+ a.polar.last.should be_close(0.927295218001612, TOLERANCE)
+
+ b = Complex(-3.5, 4.7)
+ b.polar.size.should == 2
+ b.polar.first.should be_close(5.86003412959345, TOLERANCE)
+ b.polar.last.should be_close(2.21088447955664, TOLERANCE)
+ end
+end
diff --git a/spec/ruby/shared/complex/real.rb b/spec/ruby/shared/complex/real.rb
new file mode 100644
index 0000000000..ab8ed07a4d
--- /dev/null
+++ b/spec/ruby/shared/complex/real.rb
@@ -0,0 +1,8 @@
+describe :complex_real, shared: true do
+ it "returns the real part of self" do
+ Complex(1, 0).real.should == 1
+ Complex(2, 1).real.should == 2
+ Complex(6.7, 8.9).real.should == 6.7
+ Complex(bignum_value, 3).real.should == bignum_value
+ end
+end
diff --git a/spec/ruby/shared/complex/rect.rb b/spec/ruby/shared/complex/rect.rb
new file mode 100644
index 0000000000..8a59d873eb
--- /dev/null
+++ b/spec/ruby/shared/complex/rect.rb
@@ -0,0 +1,96 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_rect, shared: true do
+ before :each do
+ @numbers = [
+ Complex(1),
+ Complex(0, 20),
+ Complex(0, 0),
+ Complex(0.0),
+ Complex(9999999**99),
+ Complex(-20),
+ Complex.polar(76, 10)
+ ]
+ end
+
+ it "returns an Array" do
+ @numbers.each do |number|
+ number.send(@method).should be_an_instance_of(Array)
+ end
+ end
+
+ it "returns a two-element Array" do
+ @numbers.each do |number|
+ number.send(@method).size.should == 2
+ end
+ end
+
+ it "returns the real part of self as the first element" do
+ @numbers.each do |number|
+ number.send(@method).first.should == number.real
+ end
+ end
+
+ it "returns the imaginary part of self as the last element" do
+ @numbers.each do |number|
+ number.send(@method).last.should == number.imaginary
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+end
+
+describe :complex_rect_class, shared: true do
+ describe "passed a Numeric n which responds to #real? with true" do
+ it "returns a Complex with real part n and imaginary part 0" do
+ n = mock_numeric('n')
+ n.should_receive(:real?).any_number_of_times.and_return(true)
+ result = Complex.send(@method, n)
+ result.real.should == n
+ result.imag.should == 0
+ end
+ end
+
+ describe "passed a Numeric which responds to #real? with false" do
+ it "raises TypeError" do
+ n = mock_numeric('n')
+ n.should_receive(:real?).any_number_of_times.and_return(false)
+ lambda { Complex.send(@method, n) }.should raise_error(TypeError)
+ end
+ end
+
+ describe "passed Numerics n1 and n2 and at least one responds to #real? with false" do
+ [[false, false], [false, true], [true, false]].each do |r1, r2|
+ it "raises TypeError" do
+ n1 = mock_numeric('n1')
+ n2 = mock_numeric('n2')
+ n1.should_receive(:real?).any_number_of_times.and_return(r1)
+ n2.should_receive(:real?).any_number_of_times.and_return(r2)
+ lambda { Complex.send(@method, n1, n2) }.should raise_error(TypeError)
+ end
+ end
+ end
+
+ describe "passed Numerics n1 and n2 and both respond to #real? with true" do
+ it "returns a Complex with real part n1 and imaginary part n2" do
+ n1 = mock_numeric('n1')
+ n2 = mock_numeric('n2')
+ n1.should_receive(:real?).any_number_of_times.and_return(true)
+ n2.should_receive(:real?).any_number_of_times.and_return(true)
+ result = Complex.send(@method, n1, n2)
+ result.real.should == n1
+ result.imag.should == n2
+ end
+ end
+
+ describe "passed a non-Numeric" do
+ it "raises TypeError" do
+ lambda { Complex.send(@method, :sym) }.should raise_error(TypeError)
+ lambda { Complex.send(@method, 0, :sym) }.should raise_error(TypeError)
+ end
+ end
+end
diff --git a/spec/ruby/shared/complex/to_s.rb b/spec/ruby/shared/complex/to_s.rb
new file mode 100644
index 0000000000..03f4f98b84
--- /dev/null
+++ b/spec/ruby/shared/complex/to_s.rb
@@ -0,0 +1,44 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :complex_to_s, shared: true do
+ describe "when self's real component is 0" do
+ it "returns both the real and imaginary component even when the real is 0" do
+ Complex(0, 5).to_s.should == "0+5i"
+ Complex(0, -3.2).to_s.should == "0-3.2i"
+ end
+ end
+
+ it "returns self as String" do
+ Complex(1, 5).to_s.should == "1+5i"
+ Complex(-2.5, 1.5).to_s.should == "-2.5+1.5i"
+
+ Complex(1, -5).to_s.should == "1-5i"
+ Complex(-2.5, -1.5).to_s.should == "-2.5-1.5i"
+
+ # Guard against the Mathn library
+ conflicts_with :Prime do
+ Complex(1, 0).to_s.should == "1+0i"
+ Complex(1, -0).to_s.should == "1+0i"
+ end
+ end
+
+ it "returns 1+0.0i for Complex(1, 0.0)" do
+ Complex(1, 0.0).to_s.should == "1+0.0i"
+ end
+
+ it "returns 1-0.0i for Complex(1, -0.0)" do
+ Complex(1, -0.0).to_s.should == "1-0.0i"
+ end
+
+ it "returns 1+Infinity*i for Complex(1, Infinity)" do
+ Complex(1, infinity_value).to_s.should == "1+Infinity*i"
+ end
+
+ it "returns 1-Infinity*i for Complex(1, -Infinity)" do
+ Complex(1, -infinity_value).to_s.should == "1-Infinity*i"
+ end
+
+ it "returns 1+NaN*i for Complex(1, NaN)" do
+ Complex(1, nan_value).to_s.should == "1+NaN*i"
+ end
+end
diff --git a/spec/ruby/shared/enumerator/each.rb b/spec/ruby/shared/enumerator/each.rb
new file mode 100644
index 0000000000..bbab86fed7
--- /dev/null
+++ b/spec/ruby/shared/enumerator/each.rb
@@ -0,0 +1,89 @@
+# -*- encoding: us-ascii -*-
+
+describe :enum_each, shared: true do
+ before :each do
+ object_each_with_arguments = Object.new
+ def object_each_with_arguments.each_with_arguments(arg, *args)
+ yield arg, *args
+ :method_returned
+ end
+
+ @enum_with_arguments = object_each_with_arguments.to_enum(:each_with_arguments, :arg0, :arg1, :arg2)
+
+ @enum_with_yielder = Enumerator.new {|y| y.yield :ok}
+ end
+
+ it "yields each element of self to the given block" do
+ acc = []
+ [1,2,3].to_enum.each {|e| acc << e }
+ acc.should == [1,2,3]
+ end
+
+ it "calls #each on the object given in the constructor by default" do
+ each = mock('each')
+ each.should_receive(:each)
+ each.to_enum.each {|e| e }
+ end
+
+ it "calls #each on the underlying object until it's exhausted" do
+ each = mock('each')
+ each.should_receive(:each).and_yield(1).and_yield(2).and_yield(3)
+ acc = []
+ each.to_enum.each {|e| acc << e }
+ acc.should == [1,2,3]
+ end
+
+ it "calls the method given in the constructor instead of #each" do
+ each = mock('peach')
+ each.should_receive(:peach)
+ each.to_enum(:peach).each {|e| e }
+ end
+
+ it "calls the method given in the constructor until it's exhausted" do
+ each = mock('each')
+ each.should_receive(:each).and_yield(1).and_yield(2).and_yield(3)
+ acc = []
+ each.to_enum.each {|e| acc << e }
+ acc.should == [1,2,3]
+ end
+
+ it "raises a NoMethodError if the object doesn't respond to #each" do
+ enum = Object.new.to_enum
+ lambda do
+ enum.each { |e| e }
+ end.should raise_error(NoMethodError)
+ end
+
+ it "returns self if not given arguments and not given a block" do
+ @enum_with_arguments.each.should equal(@enum_with_arguments)
+
+ @enum_with_yielder.each.should equal(@enum_with_yielder)
+ end
+
+ it "returns the same value from receiver.each if block is given" do
+ @enum_with_arguments.each {}.should equal(:method_returned)
+ end
+
+ it "passes given arguments at initialized to receiver.each" do
+ @enum_with_arguments.each.to_a.should == [[:arg0, :arg1, :arg2]]
+ end
+
+ it "requires multiple arguments" do
+ Enumerator.instance_method(:each).arity.should < 0
+ end
+
+ it "appends given arguments to receiver.each" do
+ @enum_with_arguments.each(:each0, :each1).to_a.should == [[:arg0, :arg1, :arg2, :each0, :each1]]
+ @enum_with_arguments.each(:each2, :each3).to_a.should == [[:arg0, :arg1, :arg2, :each2, :each3]]
+ end
+
+ it "returns the same value from receiver.each if block and arguments are given" do
+ @enum_with_arguments.each(:each1, :each2) {}.should equal(:method_returned)
+ end
+
+ it "returns new Enumerator if given arguments but not given a block" do
+ ret = @enum_with_arguments.each 1
+ ret.should be_an_instance_of(Enumerator)
+ ret.should_not equal(@enum_with_arguments)
+ end
+end
diff --git a/spec/ruby/shared/enumerator/enum_cons.rb b/spec/ruby/shared/enumerator/enum_cons.rb
new file mode 100644
index 0000000000..59eed949d8
--- /dev/null
+++ b/spec/ruby/shared/enumerator/enum_cons.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/enumerator/classes', __FILE__)
+
+describe :enum_cons, shared: true do
+ it "returns an enumerator of the receiver with iteration of each_cons for each array of n concecutive elements" do
+ a = []
+ enum = EnumSpecs::Numerous.new.enum_cons(3)
+ enum.each {|x| a << x}
+ enum.should be_an_instance_of(Enumerator)
+ a.should == [[2, 5, 3], [5, 3, 6], [3, 6, 1], [6, 1, 4]]
+ end
+end
diff --git a/spec/ruby/shared/enumerator/new.rb b/spec/ruby/shared/enumerator/new.rb
new file mode 100644
index 0000000000..23ace99816
--- /dev/null
+++ b/spec/ruby/shared/enumerator/new.rb
@@ -0,0 +1,42 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :enum_new, shared: true do
+ it "creates a new custom enumerator with the given object, iterator and arguments" do
+ enum = Enumerator.new(1, :upto, 3)
+ enum.should be_an_instance_of(Enumerator)
+ end
+
+ it "creates a new custom enumerator that responds to #each" do
+ enum = Enumerator.new(1, :upto, 3)
+ enum.respond_to?(:each).should == true
+ end
+
+ it "creates a new custom enumerator that runs correctly" do
+ Enumerator.new(1, :upto, 3).map{|x|x}.should == [1,2,3]
+ end
+
+ it "aliases the second argument to :each" do
+ Enumerator.new(1..2).to_a.should == Enumerator.new(1..2, :each).to_a
+ end
+
+ it "doesn't check for the presence of the iterator method" do
+ Enumerator.new(nil).should be_an_instance_of(Enumerator)
+ end
+
+ it "uses the latest define iterator method" do
+ class StrangeEach
+ def each
+ yield :foo
+ end
+ end
+ enum = Enumerator.new(StrangeEach.new)
+ enum.to_a.should == [:foo]
+ class StrangeEach
+ def each
+ yield :bar
+ end
+ end
+ enum.to_a.should == [:bar]
+ end
+
+end
diff --git a/spec/ruby/shared/enumerator/next.rb b/spec/ruby/shared/enumerator/next.rb
new file mode 100644
index 0000000000..d8ae6d9673
--- /dev/null
+++ b/spec/ruby/shared/enumerator/next.rb
@@ -0,0 +1,28 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :enum_next, shared: true do
+
+ before :each do
+ @enum = 1.upto(3)
+ end
+
+ it "returns the next element of the enumeration" do
+ @enum.next.should == 1
+ @enum.next.should == 2
+ @enum.next.should == 3
+ end
+
+ it "raises a StopIteration exception at the end of the stream" do
+ 3.times { @enum.next }
+ lambda { @enum.next }.should raise_error(StopIteration)
+ end
+
+ it "cannot be called again until the enumerator is rewound" do
+ 3.times { @enum.next }
+ lambda { @enum.next }.should raise_error(StopIteration)
+ lambda { @enum.next }.should raise_error(StopIteration)
+ lambda { @enum.next }.should raise_error(StopIteration)
+ @enum.rewind
+ @enum.next.should == 1
+ end
+end
diff --git a/spec/ruby/shared/enumerator/rewind.rb b/spec/ruby/shared/enumerator/rewind.rb
new file mode 100644
index 0000000000..4d4139204c
--- /dev/null
+++ b/spec/ruby/shared/enumerator/rewind.rb
@@ -0,0 +1,39 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe :enum_rewind, shared: true do
+
+ before :each do
+ @enum = 1.upto(3)
+ end
+
+ it "resets the enumerator to its initial state" do
+ @enum.next.should == 1
+ @enum.next.should == 2
+ @enum.rewind
+ @enum.next.should == 1
+ end
+
+ it "returns self" do
+ @enum.rewind.should == @enum
+ end
+
+ it "has no effect on a new enumerator" do
+ @enum.rewind
+ @enum.next.should == 1
+ end
+
+ it "has no effect if called multiple, consecutive times" do
+ @enum.next.should == 1
+ @enum.rewind
+ @enum.rewind
+ @enum.next.should == 1
+ end
+
+ it "works with peek to reset the position" do
+ @enum.next
+ @enum.next
+ @enum.rewind
+ @enum.next
+ @enum.peek.should == 2
+ end
+end
diff --git a/spec/ruby/shared/enumerator/with_index.rb b/spec/ruby/shared/enumerator/with_index.rb
index 89f40070e0..37048a7b52 100644
--- a/spec/ruby/shared/enumerator/with_index.rb
+++ b/spec/ruby/shared/enumerator/with_index.rb
@@ -1,22 +1,21 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :enum_with_index, shared: true do
- require_relative '../../fixtures/enumerator/classes'
+ require File.expand_path('../../../fixtures/enumerator/classes', __FILE__)
before :each do
- @origin = [1, 2, 3, 4]
- @enum = @origin.to_enum
+ @enum = [1, 2, 3, 4].to_enum
end
it "passes each element and its index to block" do
- a = []
- @enum.send(@method) { |o, i| a << [o, i] }
- a.should == [[1, 0], [2, 1], [3, 2], [4, 3]]
+ @a = []
+ @enum.send(@method) { |o, i| @a << [o, i] }
+ @a.should == [[1, 0], [2, 1], [3, 2], [4, 3]]
end
it "returns the object being enumerated when given a block" do
- @enum.send(@method) { |o, i| :glark }.should equal(@origin)
+ [1, 2, 3, 4].should == @enum.send(@method) { |o, i| :glark }
end
it "binds splat arguments properly" do
diff --git a/spec/ruby/shared/enumerator/with_object.rb b/spec/ruby/shared/enumerator/with_object.rb
index c2e3a79366..1830736713 100644
--- a/spec/ruby/shared/enumerator/with_object.rb
+++ b/spec/ruby/shared/enumerator/with_object.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :enum_with_object, shared: true do
before :each do
diff --git a/spec/ruby/shared/fiber/resume.rb b/spec/ruby/shared/fiber/resume.rb
index d3dc438ae2..058ef4e15a 100644
--- a/spec/ruby/shared/fiber/resume.rb
+++ b/spec/ruby/shared/fiber/resume.rb
@@ -4,16 +4,19 @@ describe :fiber_resume, shared: true do
fiber.send(@method).should == :fiber
end
+ it "raises a FiberError if the Fiber tries to resume itself" do
+ fiber = Fiber.new { fiber.resume }
+ -> { fiber.resume }.should raise_error(FiberError, /double resume/)
+ end
+
it "raises a FiberError if invoked from a different Thread" do
fiber = Fiber.new { 42 }
Thread.new do
-> {
- fiber.send(@method)
+ fiber.resume
}.should raise_error(FiberError)
end.join
-
- # Check the Fiber can still be used
- fiber.send(@method).should == 42
+ fiber.resume.should == 42
end
it "passes control to the beginning of the block on first invocation" do
@@ -50,7 +53,7 @@ describe :fiber_resume, shared: true do
it "accepts any number of arguments" do
fiber = Fiber.new { |a| }
- -> { fiber.send(@method, *(1..10).to_a) }.should_not raise_error
+ lambda { fiber.send(@method, *(1..10).to_a) }.should_not raise_error
end
it "sets the block parameters to its arguments on the first invocation" do
@@ -64,16 +67,16 @@ describe :fiber_resume, shared: true do
it "raises a FiberError if the Fiber is dead" do
fiber = Fiber.new { true }
fiber.send(@method)
- -> { fiber.send(@method) }.should raise_error(FiberError)
+ lambda { fiber.send(@method) }.should raise_error(FiberError)
end
it "raises a LocalJumpError if the block includes a return statement" do
fiber = Fiber.new { return; }
- -> { fiber.send(@method) }.should raise_error(LocalJumpError)
+ lambda { fiber.send(@method) }.should raise_error(LocalJumpError)
end
it "raises a LocalJumpError if the block includes a break statement" do
fiber = Fiber.new { break; }
- -> { fiber.send(@method) }.should raise_error(LocalJumpError)
+ lambda { fiber.send(@method) }.should raise_error(LocalJumpError)
end
end
diff --git a/spec/ruby/shared/file/directory.rb b/spec/ruby/shared/file/directory.rb
index 8ba933a601..67e939bf16 100644
--- a/spec/ruby/shared/file/directory.rb
+++ b/spec/ruby/shared/file/directory.rb
@@ -24,12 +24,12 @@ describe :file_directory, shared: true do
end
it "raises a TypeError when passed an Integer" do
- -> { @object.send(@method, 1) }.should raise_error(TypeError)
- -> { @object.send(@method, bignum_value) }.should raise_error(TypeError)
+ lambda { @object.send(@method, 1) }.should raise_error(TypeError)
+ lambda { @object.send(@method, bignum_value) }.should raise_error(TypeError)
end
it "raises a TypeError when passed nil" do
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/executable.rb b/spec/ruby/shared/file/executable.rb
index 2987d0aabb..5b21fb0d97 100644
--- a/spec/ruby/shared/file/executable.rb
+++ b/spec/ruby/shared/file/executable.rb
@@ -31,13 +31,13 @@ describe :file_executable, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- -> { @object.send(@method) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- -> { @object.send(@method, 1) }.should raise_error(TypeError)
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
- -> { @object.send(@method, false) }.should raise_error(TypeError)
+ lambda { @object.send(@method, 1) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, false) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/executable_real.rb b/spec/ruby/shared/file/executable_real.rb
index ce3d5ca176..2b1bf8f585 100644
--- a/spec/ruby/shared/file/executable_real.rb
+++ b/spec/ruby/shared/file/executable_real.rb
@@ -29,13 +29,13 @@ describe :file_executable_real, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- -> { @object.send(@method) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- -> { @object.send(@method, 1) }.should raise_error(TypeError)
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
- -> { @object.send(@method, false) }.should raise_error(TypeError)
+ lambda { @object.send(@method, 1) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, false) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/exist.rb b/spec/ruby/shared/file/exist.rb
index 3bd97711b4..1557f01a82 100644
--- a/spec/ruby/shared/file/exist.rb
+++ b/spec/ruby/shared/file/exist.rb
@@ -10,12 +10,12 @@ describe :file_exist, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- -> { @object.send(@method) }.should raise_error(ArgumentError)
- -> { @object.send(@method, __FILE__, __FILE__) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, __FILE__, __FILE__) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "accepts an object that has a #to_path method" do
diff --git a/spec/ruby/shared/file/file.rb b/spec/ruby/shared/file/file.rb
index c1748a88b3..095bd63fff 100644
--- a/spec/ruby/shared/file/file.rb
+++ b/spec/ruby/shared/file/file.rb
@@ -34,12 +34,12 @@ describe :file_file, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- -> { @object.send(@method) }.should raise_error(ArgumentError)
- -> { @object.send(@method, @null, @file) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, @null, @file) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
- -> { @object.send(@method, 1) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, 1) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/grpowned.rb b/spec/ruby/shared/file/grpowned.rb
index 24e84c28e3..91a6483030 100644
--- a/spec/ruby/shared/file/grpowned.rb
+++ b/spec/ruby/shared/file/grpowned.rb
@@ -26,7 +26,8 @@ describe :file_grpowned, shared: true do
@object.send(@method, @file).should == true
else
- skip "No supplementary groups"
+ # No supplementary groups
+ 1.should == 1
end
end
end
diff --git a/spec/ruby/shared/file/identical.rb b/spec/ruby/shared/file/identical.rb
index ecc21727ca..e89cd309ea 100644
--- a/spec/ruby/shared/file/identical.rb
+++ b/spec/ruby/shared/file/identical.rb
@@ -31,12 +31,12 @@ describe :file_identical, shared: true do
end
it "raises an ArgumentError if not passed two arguments" do
- -> { @object.send(@method, @file1, @file2, @link) }.should raise_error(ArgumentError)
- -> { @object.send(@method, @file1) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, @file1, @file2, @link) }.should raise_error(ArgumentError)
+ lambda { @object.send(@method, @file1) }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed String types" do
- -> { @object.send(@method, 1,1) }.should raise_error(TypeError)
+ lambda { @object.send(@method, 1,1) }.should raise_error(TypeError)
end
it "returns true if both named files are identical" do
diff --git a/spec/ruby/shared/file/size.rb b/spec/ruby/shared/file/size.rb
index 880dfbb612..bb95190fc0 100644
--- a/spec/ruby/shared/file/size.rb
+++ b/spec/ruby/shared/file/size.rb
@@ -56,7 +56,7 @@ describe :file_size_raise_when_missing, shared: true do
end
it "raises an error if file_name doesn't exist" do
- -> {@object.send(@method, @missing)}.should raise_error(Errno::ENOENT)
+ lambda {@object.send(@method, @missing)}.should raise_error(Errno::ENOENT)
end
end
diff --git a/spec/ruby/shared/file/world_readable.rb b/spec/ruby/shared/file/world_readable.rb
index 85761e633f..0fddf98b73 100644
--- a/spec/ruby/shared/file/world_readable.rb
+++ b/spec/ruby/shared/file/world_readable.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :file_world_readable, shared: true do
@@ -37,7 +37,7 @@ describe :file_world_readable, shared: true do
it "returns a Fixnum if the file is a directory and chmod 644" do
dir = rand().to_s + '-ww'
Dir.mkdir(dir)
- Dir.should.exist?(dir)
+ Dir.exist?(dir).should be_true
File.chmod(0644, dir)
@object.world_readable?(dir).should be_an_instance_of(Fixnum)
Dir.rmdir(dir)
diff --git a/spec/ruby/shared/file/world_writable.rb b/spec/ruby/shared/file/world_writable.rb
index 61b691bcb6..43ac23a997 100644
--- a/spec/ruby/shared/file/world_writable.rb
+++ b/spec/ruby/shared/file/world_writable.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :file_world_writable, shared: true do
@@ -36,7 +36,7 @@ describe :file_world_writable, shared: true do
it "returns a Fixnum if the file is a directory and chmod 777" do
dir = rand().to_s + '-ww'
Dir.mkdir(dir)
- Dir.should.exist?(dir)
+ Dir.exist?(dir).should be_true
File.chmod(0777, dir)
@object.world_writable?(dir).should be_an_instance_of(Fixnum)
Dir.rmdir(dir)
diff --git a/spec/ruby/shared/file/writable.rb b/spec/ruby/shared/file/writable.rb
index 902d545da1..e8296928f3 100644
--- a/spec/ruby/shared/file/writable.rb
+++ b/spec/ruby/shared/file/writable.rb
@@ -9,9 +9,7 @@ describe :file_writable, shared: true do
it "returns true if named file is writable by the effective user id of the process, otherwise false" do
platform_is_not :windows do
- as_user do
- @object.send(@method, "/etc/passwd").should == false
- end
+ @object.send(@method, "/etc/passwd").should == false
end
File.open(@file,'w') { @object.send(@method, @file).should == true }
end
diff --git a/spec/ruby/shared/file/writable_real.rb b/spec/ruby/shared/file/writable_real.rb
index e9721fd379..3730befb7a 100644
--- a/spec/ruby/shared/file/writable_real.rb
+++ b/spec/ruby/shared/file/writable_real.rb
@@ -16,13 +16,13 @@ describe :file_writable_real, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- -> { File.writable_real? }.should raise_error(ArgumentError)
+ lambda { File.writable_real? }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- -> { @object.send(@method, 1) }.should raise_error(TypeError)
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
- -> { @object.send(@method, false) }.should raise_error(TypeError)
+ lambda { @object.send(@method, 1) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, false) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/file/zero.rb b/spec/ruby/shared/file/zero.rb
index 6a9399a021..cf014d4722 100644
--- a/spec/ruby/shared/file/zero.rb
+++ b/spec/ruby/shared/file/zero.rb
@@ -40,13 +40,13 @@ describe :file_zero, shared: true do
end
it "raises an ArgumentError if not passed one argument" do
- -> { File.zero? }.should raise_error(ArgumentError)
+ lambda { File.zero? }.should raise_error(ArgumentError)
end
it "raises a TypeError if not passed a String type" do
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
- -> { @object.send(@method, true) }.should raise_error(TypeError)
- -> { @object.send(@method, false) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, true) }.should raise_error(TypeError)
+ lambda { @object.send(@method, false) }.should raise_error(TypeError)
end
it "returns true inside a block opening a file if it is empty" do
diff --git a/spec/ruby/shared/hash/key_error.rb b/spec/ruby/shared/hash/key_error.rb
deleted file mode 100644
index 061c88c483..0000000000
--- a/spec/ruby/shared/hash/key_error.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-describe :key_error, shared: true do
- it "raises a KeyError" do
- -> {
- @method.call(@object, 'foo')
- }.should raise_error(KeyError)
- end
-
- ruby_version_is "2.5" do
- it "sets the Hash as the receiver of KeyError" do
- -> {
- @method.call(@object, 'foo')
- }.should raise_error(KeyError) { |err|
- err.receiver.should equal(@object)
- }
- end
-
- it "sets the unmatched key as the key of KeyError" do
- -> {
- @method.call(@object, 'foo')
- }.should raise_error(KeyError) { |err|
- err.key.to_s.should == 'foo'
- }
- end
- end
-end
diff --git a/spec/ruby/shared/io/putc.rb b/spec/ruby/shared/io/putc.rb
index fac14886ee..5f620f183f 100644
--- a/spec/ruby/shared/io/putc.rb
+++ b/spec/ruby/shared/io/putc.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# -*- encoding: ascii-8bit -*-
describe :io_putc, shared: true do
after :each do
@io.close if @io && !@io.closed?
@@ -40,18 +40,18 @@ describe :io_putc, shared: true do
it "raises IOError on a closed stream" do
@io.close
- -> { @io_object.send(@method, "a") }.should raise_error(IOError)
+ lambda { @io_object.send(@method, "a") }.should raise_error(IOError)
end
it "raises a TypeError when passed nil" do
- -> { @io_object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @io_object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed false" do
- -> { @io_object.send(@method, false) }.should raise_error(TypeError)
+ lambda { @io_object.send(@method, false) }.should raise_error(TypeError)
end
it "raises a TypeError when passed true" do
- -> { @io_object.send(@method, true) }.should raise_error(TypeError)
+ lambda { @io_object.send(@method, true) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/kernel/raise.rb b/spec/ruby/shared/kernel/raise.rb
index d4553775f4..70d638fff9 100644
--- a/spec/ruby/shared/kernel/raise.rb
+++ b/spec/ruby/shared/kernel/raise.rb
@@ -4,7 +4,7 @@ describe :kernel_raise, shared: true do
end
it "aborts execution" do
- -> do
+ lambda do
@object.raise Exception, "abort"
ScratchPad.record :no_abort
end.should raise_error(Exception, "abort")
@@ -13,42 +13,42 @@ describe :kernel_raise, shared: true do
end
it "raises RuntimeError if no exception class is given" do
- -> { @object.raise }.should raise_error(RuntimeError, "")
+ lambda { @object.raise }.should raise_error(RuntimeError)
end
it "raises a given Exception instance" do
error = RuntimeError.new
- -> { @object.raise(error) }.should raise_error(error)
+ lambda { @object.raise(error) }.should raise_error(error)
end
it "raises a RuntimeError if string given" do
- -> { @object.raise("a bad thing") }.should raise_error(RuntimeError)
+ lambda { @object.raise("a bad thing") }.should raise_error(RuntimeError)
end
it "raises a TypeError when passed a non-Exception object" do
- -> { @object.raise(Object.new) }.should raise_error(TypeError)
+ lambda { @object.raise(Object.new) }.should raise_error(TypeError)
end
it "raises a TypeError when passed true" do
- -> { @object.raise(true) }.should raise_error(TypeError)
+ lambda { @object.raise(true) }.should raise_error(TypeError)
end
it "raises a TypeError when passed false" do
- -> { @object.raise(false) }.should raise_error(TypeError)
+ lambda { @object.raise(false) }.should raise_error(TypeError)
end
it "raises a TypeError when passed nil" do
- -> { @object.raise(nil) }.should raise_error(TypeError)
+ lambda { @object.raise(nil) }.should raise_error(TypeError)
end
- it "re-raises the previously rescued exception if no exception is specified" do
- -> do
+ it "re-raises the rescued exception" do
+ lambda do
begin
- @object.raise Exception, "outer"
+ raise Exception, "outer"
ScratchPad.record :no_abort
rescue
begin
- @object.raise StandardError, "inner"
+ raise StandardError, "inner"
rescue
end
@@ -60,25 +60,8 @@ describe :kernel_raise, shared: true do
ScratchPad.recorded.should be_nil
end
- it "re-raises a previously rescued exception without overwriting the backtrace" do
- begin
- initial_raise_line = __LINE__; @object.raise 'raised'
- rescue => raised
- begin
- raise_again_line = __LINE__; @object.raise raised
- rescue => raised_again
- # This spec is written using #backtrace and matching the line number
- # from the string, as backtrace_locations is a more advanced
- # method that is not always supported by implementations.
-
- raised_again.backtrace.first.should include("#{__FILE__}:#{initial_raise_line}:")
- raised_again.backtrace.first.should_not include("#{__FILE__}:#{raise_again_line}:")
- end
- end
- end
-
it "allows Exception, message, and backtrace parameters" do
- -> do
+ lambda do
@object.raise(ArgumentError, "message", caller)
end.should raise_error(ArgumentError, "message")
end
diff --git a/spec/ruby/shared/math/atanh.rb b/spec/ruby/shared/math/atanh.rb
index 3fb64153a0..1d1a6ebd74 100644
--- a/spec/ruby/shared/math/atanh.rb
+++ b/spec/ruby/shared/math/atanh.rb
@@ -11,11 +11,11 @@ describe :math_atanh_base, shared: true do
end
it "raises a TypeError if the argument is nil" do
- -> { @object.send(@method, nil) }.should raise_error(TypeError)
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the argument is not a Numeric" do
- -> { @object.send(@method, "test") }.should raise_error(TypeError)
+ lambda { @object.send(@method, "test") }.should raise_error(TypeError)
end
it "returns Infinity if x == 1.0" do
@@ -35,10 +35,10 @@ end
describe :math_atanh_no_complex, shared: true do
it "raises a Math::DomainError for arguments greater than 1.0" do
- -> { @object.send(@method, 1.0 + Float::EPSILON) }.should raise_error(Math::DomainError)
+ lambda { @object.send(@method, 1.0 + Float::EPSILON) }.should raise_error(Math::DomainError)
end
it "raises a Math::DomainError for arguments less than -1.0" do
- -> { @object.send(@method, -1.0 - Float::EPSILON) }.should raise_error(Math::DomainError)
+ lambda { @object.send(@method, -1.0 - Float::EPSILON) }.should raise_error(Math::DomainError)
end
end
diff --git a/spec/ruby/shared/process/abort.rb b/spec/ruby/shared/process/abort.rb
index 935637e1c2..1a25aeffc2 100644
--- a/spec/ruby/shared/process/abort.rb
+++ b/spec/ruby/shared/process/abort.rb
@@ -8,29 +8,29 @@ describe :process_abort, shared: true do
end
it "raises a SystemExit exception" do
- -> { @object.abort }.should raise_error(SystemExit)
+ lambda { @object.abort }.should raise_error(SystemExit)
end
it "sets the exception message to the given message" do
- -> { @object.abort "message" }.should raise_error { |e| e.message.should == "message" }
+ lambda { @object.abort "message" }.should raise_error { |e| e.message.should == "message" }
end
it "sets the exception status code of 1" do
- -> { @object.abort }.should raise_error { |e| e.status.should == 1 }
+ lambda { @object.abort }.should raise_error { |e| e.status.should == 1 }
end
it "prints the specified message to STDERR" do
- -> { @object.abort "a message" }.should raise_error(SystemExit)
+ lambda { @object.abort "a message" }.should raise_error(SystemExit)
$stderr.should =~ /a message/
end
it "coerces the argument with #to_str" do
str = mock('to_str')
str.should_receive(:to_str).any_number_of_times.and_return("message")
- -> { @object.abort str }.should raise_error(SystemExit, "message")
+ lambda { @object.abort str }.should raise_error(SystemExit, "message")
end
it "raises TypeError when given a non-String object" do
- -> { @object.abort 123 }.should raise_error(TypeError)
+ lambda { @object.abort 123 }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/process/exit.rb b/spec/ruby/shared/process/exit.rb
index 1820dd17fd..7d567c8195 100644
--- a/spec/ruby/shared/process/exit.rb
+++ b/spec/ruby/shared/process/exit.rb
@@ -1,13 +1,13 @@
describe :process_exit, shared: true do
it "raises a SystemExit with status 0" do
- -> { @object.exit }.should raise_error(SystemExit) { |e|
+ lambda { @object.exit }.should raise_error(SystemExit) { |e|
e.status.should == 0
}
end
it "raises a SystemExit with the specified status" do
[-2**16, -2**8, -8, -1, 0, 1 , 8, 2**8, 2**16].each do |value|
- -> { @object.exit(value) }.should raise_error(SystemExit) { |e|
+ lambda { @object.exit(value) }.should raise_error(SystemExit) { |e|
e.status.should == value
}
end
@@ -15,7 +15,7 @@ describe :process_exit, shared: true do
it "raises a SystemExit with the specified boolean status" do
{ true => 0, false => 1 }.each do |value, status|
- -> { @object.exit(value) }.should raise_error(SystemExit) { |e|
+ lambda { @object.exit(value) }.should raise_error(SystemExit) { |e|
e.status.should == status
}
end
@@ -24,24 +24,24 @@ describe :process_exit, shared: true do
it "tries to convert the passed argument to an Integer using #to_int" do
obj = mock('5')
obj.should_receive(:to_int).and_return(5)
- -> { @object.exit(obj) }.should raise_error(SystemExit) { |e|
+ lambda { @object.exit(obj) }.should raise_error(SystemExit) { |e|
e.status.should == 5
}
end
it "converts the passed Float argument to an Integer" do
{ -2.2 => -2, -0.1 => 0, 5.5 => 5, 827.999 => 827 }.each do |value, status|
- -> { @object.exit(value) }.should raise_error(SystemExit) { |e|
+ lambda { @object.exit(value) }.should raise_error(SystemExit) { |e|
e.status.should == status
}
end
end
it "raises TypeError if can't convert the argument to an Integer" do
- -> { @object.exit(Object.new) }.should raise_error(TypeError)
- -> { @object.exit('0') }.should raise_error(TypeError)
- -> { @object.exit([0]) }.should raise_error(TypeError)
- -> { @object.exit(nil) }.should raise_error(TypeError)
+ lambda { @object.exit(Object.new) }.should raise_error(TypeError)
+ lambda { @object.exit('0') }.should raise_error(TypeError)
+ lambda { @object.exit([0]) }.should raise_error(TypeError)
+ lambda { @object.exit(nil) }.should raise_error(TypeError)
end
it "raises the SystemExit in the main thread if it reaches the top-level handler of another thread" do
@@ -69,7 +69,7 @@ describe :process_exit, shared: true do
ScratchPad.recorded.should == [:in_thread, :in_main]
# the thread also keeps the exception as its value
- -> { t.value }.should raise_error(SystemExit)
+ lambda { t.value }.should raise_error(SystemExit)
end
end
diff --git a/spec/ruby/shared/process/fork.rb b/spec/ruby/shared/process/fork.rb
index 11e18d7b1c..c2c2aee9bf 100644
--- a/spec/ruby/shared/process/fork.rb
+++ b/spec/ruby/shared/process/fork.rb
@@ -8,7 +8,7 @@ describe :process_fork, shared: true do
end
it "raises a NotImplementedError when called" do
- -> { @object.fork }.should raise_error(NotImplementedError)
+ lambda { @object.fork }.should raise_error(NotImplementedError)
end
end
@@ -60,7 +60,7 @@ describe :process_fork, shared: true do
else
Process.waitpid(child_id)
end
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "runs a block in a child process" do
@@ -69,7 +69,7 @@ describe :process_fork, shared: true do
Process.exit!
}
Process.waitpid(pid)
- File.should.exist?(@file)
+ File.exist?(@file).should == true
end
it "marks threads from the parent as killed" do
diff --git a/spec/ruby/shared/queue/clear.rb b/spec/ruby/shared/queue/clear.rb
deleted file mode 100644
index 5db5a5b497..0000000000
--- a/spec/ruby/shared/queue/clear.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-describe :queue_clear, shared: true do
- it "removes all objects from the queue" do
- queue = @object.call
- queue << Object.new
- queue << 1
- queue.empty?.should be_false
- queue.clear
- queue.empty?.should be_true
- end
-
- # TODO: test for atomicity of Queue#clear
-end
diff --git a/spec/ruby/shared/queue/close.rb b/spec/ruby/shared/queue/close.rb
deleted file mode 100644
index 0e7c69acba..0000000000
--- a/spec/ruby/shared/queue/close.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe :queue_close, shared: true do
- it "may be called multiple times" do
- q = @object.call
- q.close
- q.closed?.should be_true
- q.close # no effect
- q.closed?.should be_true
- end
-
- it "returns self" do
- q = @object.call
- q.close.should == q
- end
-end
diff --git a/spec/ruby/shared/queue/deque.rb b/spec/ruby/shared/queue/deque.rb
deleted file mode 100644
index 8b755dd9b7..0000000000
--- a/spec/ruby/shared/queue/deque.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-describe :queue_deq, shared: true do
- it "removes an item from the queue" do
- q = @object.call
- q << Object.new
- q.size.should == 1
- q.send @method
- q.size.should == 0
- end
-
- it "returns items in the order they were added" do
- q = @object.call
- q << 1
- q << 2
- q.send(@method).should == 1
- q.send(@method).should == 2
- end
-
- it "blocks the thread until there are items in the queue" do
- q = @object.call
- v = 0
-
- th = Thread.new do
- q.send(@method)
- v = 1
- end
-
- v.should == 0
- q << Object.new
- th.join
- v.should == 1
- end
-
- it "removes an item from a closed queue" do
- q = @object.call
- q << 1
- q.close
- q.send(@method).should == 1
- end
-
- it "returns nil for a closed empty queue" do
- q = @object.call
- q.close
- q.send(@method).should == nil
- end
-
- it "returns nil for an empty queue that becomes closed" do
- q = @object.call
-
- t = Thread.new {
- q.send(@method).should == nil
- }
-
- Thread.pass until t.status == "sleep" && q.num_waiting == 1
- q.close
- t.join
- end
-
- describe "in non-blocking mode" do
- it "removes an item from the queue" do
- q = @object.call
- q << Object.new
- q.size.should == 1
- q.send(@method, true)
- q.size.should == 0
- end
-
- it "raises a ThreadError if the queue is empty" do
- q = @object.call
- -> { q.send(@method, true) }.should raise_error(ThreadError)
- end
-
- it "removes an item from a closed queue" do
- q = @object.call
- q << 1
- q.close
- q.send(@method, true).should == 1
- end
-
- it "raises a ThreadError for a closed empty queue" do
- q = @object.call
- q.close
- -> { q.send(@method, true) }.should raise_error(ThreadError)
- end
- end
-end
diff --git a/spec/ruby/shared/queue/enque.rb b/spec/ruby/shared/queue/enque.rb
deleted file mode 100644
index 8aba02e544..0000000000
--- a/spec/ruby/shared/queue/enque.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-describe :queue_enq, shared: true do
- it "adds an element to the Queue" do
- q = @object.call
- q.size.should == 0
- q.send @method, Object.new
- q.size.should == 1
- q.send @method, Object.new
- q.size.should == 2
- end
-
- it "is an error for a closed queue" do
- q = @object.call
- q.close
- -> {
- q.send @method, Object.new
- }.should raise_error(ClosedQueueError)
- end
-end
diff --git a/spec/ruby/shared/rational/Rational.rb b/spec/ruby/shared/rational/Rational.rb
index 2c36243dc3..0165fa769a 100644
--- a/spec/ruby/shared/rational/Rational.rb
+++ b/spec/ruby/shared/rational/Rational.rb
@@ -1,10 +1,10 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/rational'
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/rational', __FILE__)
describe :kernel_Rational, shared: true do
describe "passed Integer" do
# Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
+ conflicts_with :Prime do
it "returns a new Rational number with 1 as the denominator" do
Rational(1).should eql(Rational(1, 1))
Rational(-3).should eql(Rational(-3, 1))
@@ -80,64 +80,24 @@ describe :kernel_Rational, shared: true do
end
it "raises a RangeError if the imaginary part is not 0" do
- -> { Rational(Complex(1, 2)) }.should raise_error(RangeError)
+ lambda { Rational(Complex(1, 2)) }.should raise_error(RangeError)
end
end
it "raises a TypeError if the first argument is nil" do
- -> { Rational(nil) }.should raise_error(TypeError)
+ lambda { Rational(nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the second argument is nil" do
- -> { Rational(1, nil) }.should raise_error(TypeError)
+ lambda { Rational(1, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the first argument is a Symbol" do
- -> { Rational(:sym) }.should raise_error(TypeError)
+ lambda { Rational(:sym) }.should raise_error(TypeError)
end
it "raises a TypeError if the second argument is a Symbol" do
- -> { Rational(1, :sym) }.should raise_error(TypeError)
- end
- end
-
- ruby_version_is "2.6" do
- describe "when passed exception: false" do
- describe "and [non-Numeric]" do
- it "swallows an error" do
- Rational(:sym, exception: false).should == nil
- Rational("abc", exception: false).should == nil
- end
- end
-
- describe "and [non-Numeric, Numeric]" do
- it "swallows an error" do
- Rational(:sym, 1, exception: false).should == nil
- Rational("abc", 1, exception: false).should == nil
- end
- end
-
- describe "and [anything, non-Numeric]" do
- it "swallows an error" do
- Rational(:sym, :sym, exception: false).should == nil
- Rational("abc", :sym, exception: false).should == nil
- end
- end
-
- describe "and non-Numeric String arguments" do
- it "swallows an error" do
- Rational("a", "b", exception: false).should == nil
- Rational("a", 0, exception: false).should == nil
- Rational(0, "b", exception: false).should == nil
- end
- end
-
- describe "and nil arguments" do
- it "swallows an error" do
- Rational(nil, exception: false).should == nil
- Rational(nil, nil, exception: false).should == nil
- end
- end
+ lambda { Rational(1, :sym) }.should raise_error(TypeError)
end
end
end
diff --git a/spec/ruby/shared/rational/abs.rb b/spec/ruby/shared/rational/abs.rb
index 8beb20da7e..aa1bdc4363 100644
--- a/spec/ruby/shared/rational/abs.rb
+++ b/spec/ruby/shared/rational/abs.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_abs, shared: true do
it "returns self's absolute value" do
diff --git a/spec/ruby/shared/rational/arithmetic_exception_in_coerce.rb b/spec/ruby/shared/rational/arithmetic_exception_in_coerce.rb
deleted file mode 100644
index 9377814732..0000000000
--- a/spec/ruby/shared/rational/arithmetic_exception_in_coerce.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../../fixtures/rational'
-
-describe :rational_arithmetic_exception_in_coerce, shared: true do
- ruby_version_is ""..."2.5" do
- it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(RationalSpecs::CoerceError)
-
- # e.g. Rational(3, 4) + b
- -> { Rational(3, 4).send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Rational/)
- end
-
- it "does not rescue Exception and StandardError siblings raised in other#coerce" do
- [Exception, NoMemoryError].each do |exception|
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(exception)
-
- # e.g. Rational(3, 4) + b
- -> { Rational(3, 4).send(@method, b) }.should raise_error(exception)
- end
- end
- end
-
- ruby_version_is "2.5" do
- it "does not rescue exception raised in other#coerce" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(RationalSpecs::CoerceError)
-
- # e.g. Rational(3, 4) + b
- -> { Rational(3, 4).send(@method, b) }.should raise_error(RationalSpecs::CoerceError)
- end
- end
-end
diff --git a/spec/ruby/shared/rational/ceil.rb b/spec/ruby/shared/rational/ceil.rb
index f1cf60d2be..cbb4ed0d08 100644
--- a/spec/ruby/shared/rational/ceil.rb
+++ b/spec/ruby/shared/rational/ceil.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_ceil, shared: true do
before do
diff --git a/spec/ruby/shared/rational/coerce.rb b/spec/ruby/shared/rational/coerce.rb
index ffb118e2a7..8bdd19aa2a 100644
--- a/spec/ruby/shared/rational/coerce.rb
+++ b/spec/ruby/shared/rational/coerce.rb
@@ -1,6 +1,4 @@
-require_relative '../../spec_helper'
-
-require 'bigdecimal'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_coerce, shared: true do
it "returns the passed argument, self as Float, when given a Float" do
@@ -20,10 +18,4 @@ describe :rational_coerce, shared: true do
it "returns [argument, self] when given a Rational" do
Rational(3, 7).coerce(Rational(9, 2)).should == [Rational(9, 2), Rational(3, 7)]
end
-
- it "raises an error when passed a BigDecimal" do
- -> {
- Rational(500, 3).coerce(BigDecimal('166.666666666'))
- }.should raise_error(TypeError, /BigDecimal can't be coerced into Rational/)
- end
end
diff --git a/spec/ruby/shared/rational/comparison.rb b/spec/ruby/shared/rational/comparison.rb
index 0c8b3d0ac1..c52363781f 100644
--- a/spec/ruby/shared/rational/comparison.rb
+++ b/spec/ruby/shared/rational/comparison.rb
@@ -1,5 +1,4 @@
-require_relative '../../spec_helper'
-require_relative '../../fixtures/rational'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_cmp_rat, shared: true do
it "returns 1 when self is greater than the passed argument" do
@@ -79,37 +78,6 @@ describe :rational_cmp_coerce, shared: true do
end
end
-describe :rational_cmp_coerce_exception, shared: true do
- ruby_version_is ""..."2.5" do
- it "rescues exception (StandardError and subclasses) raised in other#coerce and returns nil" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(RationalSpecs::CoerceError)
-
- -> {
- (Rational(3, 4) <=> b).should == nil
- }.should complain(/Numerical comparison operators will no more rescue exceptions of #coerce/)
- end
-
- it "does not rescue Exception and StandardError siblings raised in other#coerce" do
- [Exception, NoMemoryError].each do |exception|
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(exception)
-
- -> { Rational(3, 4) <=> b }.should raise_error(exception)
- end
- end
- end
-
- ruby_version_is "2.5" do
- it "does not rescue exception raised in other#coerce" do
- b = mock("numeric with failed #coerce")
- b.should_receive(:coerce).and_raise(RationalSpecs::CoerceError)
-
- -> { Rational(3, 4) <=> b }.should raise_error(RationalSpecs::CoerceError)
- end
- end
-end
-
describe :rational_cmp_other, shared: true do
it "returns nil" do
(Rational <=> mock("Object")).should be_nil
diff --git a/spec/ruby/shared/rational/denominator.rb b/spec/ruby/shared/rational/denominator.rb
index 10d46aacb3..74e464465d 100644
--- a/spec/ruby/shared/rational/denominator.rb
+++ b/spec/ruby/shared/rational/denominator.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_denominator, shared: true do
it "returns the denominator" do
diff --git a/spec/ruby/shared/rational/div.rb b/spec/ruby/shared/rational/div.rb
index d5bd9e6644..23c11f5d12 100644
--- a/spec/ruby/shared/rational/div.rb
+++ b/spec/ruby/shared/rational/div.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_div_rat, shared: true do
it "performs integer division and returns the result" do
@@ -7,11 +7,11 @@ describe :rational_div_rat, shared: true do
end
it "raises a ZeroDivisionError when the argument has a numerator of 0" do
- -> { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the argument has a numerator of 0.0" do
- -> { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
end
end
@@ -23,7 +23,7 @@ describe :rational_div_float, shared: true do
end
it "raises a ZeroDivisionError when the argument is 0.0" do
- -> { Rational(3, 4).div(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(3, 4).div(0.0) }.should raise_error(ZeroDivisionError)
end
end
@@ -34,7 +34,7 @@ describe :rational_div_int, shared: true do
end
it "raises a ZeroDivisionError when the argument is 0" do
- -> { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
end
end
@@ -44,11 +44,11 @@ describe :rational_div, shared: true do
end
it "raises an ArgumentError if passed more than one argument" do
- -> { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
+ lambda { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
end
# See http://redmine.ruby-lang.org/issues/show/1648
it "raises a TypeError if passed a non-numeric argument" do
- -> { Rational(3, 4).div([]) }.should raise_error(TypeError)
+ lambda { Rational(3, 4).div([]) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/shared/rational/divide.rb b/spec/ruby/shared/rational/divide.rb
index 7d6d66390f..8c5bf666e6 100644
--- a/spec/ruby/shared/rational/divide.rb
+++ b/spec/ruby/shared/rational/divide.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_divide_rat, shared: true do
it "returns self divided by other as a Rational" do
@@ -10,7 +10,7 @@ describe :rational_divide_rat, shared: true do
end
it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do
- -> { Rational(3, 4).send(@method, Rational(0, 1)) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(3, 4).send(@method, Rational(0, 1)) }.should raise_error(ZeroDivisionError)
end
end
@@ -22,7 +22,7 @@ describe :rational_divide_int, shared: true do
end
it "raises a ZeroDivisionError when passed 0" do
- -> { Rational(3, 4).send(@method, 0) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(3, 4).send(@method, 0) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/shared/rational/divmod.rb b/spec/ruby/shared/rational/divmod.rb
index 5b319a95ff..607ae9d693 100644
--- a/spec/ruby/shared/rational/divmod.rb
+++ b/spec/ruby/shared/rational/divmod.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_divmod_rat, shared: true do
it "returns the quotient as Integer and the remainder as Rational" do
@@ -10,7 +10,7 @@ describe :rational_divmod_rat, shared: true do
end
it "raises a ZeroDivisonError when passed a Rational with a numerator of 0" do
- -> { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
end
end
@@ -23,7 +23,7 @@ describe :rational_divmod_int, shared: true do
end
it "raises a ZeroDivisionError when passed 0" do
- -> { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError)
end
end
@@ -37,6 +37,6 @@ describe :rational_divmod_float, shared: true do
end
it "raises a ZeroDivisionError when passed 0" do
- -> { Rational(7, 4).divmod(0.0) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(7, 4).divmod(0.0) }.should raise_error(ZeroDivisionError)
end
end
diff --git a/spec/ruby/shared/rational/equal_value.rb b/spec/ruby/shared/rational/equal_value.rb
index b2e7e09415..be4d5af598 100644
--- a/spec/ruby/shared/rational/equal_value.rb
+++ b/spec/ruby/shared/rational/equal_value.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_equal_value_rat, shared: true do
it "returns true if self has the same numerator and denominator as the passed argument" do
diff --git a/spec/ruby/shared/rational/exponent.rb b/spec/ruby/shared/rational/exponent.rb
index 1d808177e9..7e7c5be7c1 100644
--- a/spec/ruby/shared/rational/exponent.rb
+++ b/spec/ruby/shared/rational/exponent.rb
@@ -1,9 +1,8 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_exponent, shared: true do
describe "when passed Rational" do
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
+ conflicts_with :Prime do
it "returns Rational(1) if the exponent is Rational(0)" do
(Rational(0) ** Rational(0)).should eql(Rational(1))
(Rational(1) ** Rational(0)).should eql(Rational(1))
@@ -46,8 +45,7 @@ describe :rational_exponent, shared: true do
(Rational(3, -bignum_value) ** -4).should == Rational(7237005577332262213973186563042994240829374041602535252466099000494570602496, 81)
end
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
+ conflicts_with :Prime do
it "returns Rational(1, 1) when the passed argument is 0" do
(Rational(3, 4) ** 0).should eql(Rational(1, 1))
(Rational(-3, 4) ** 0).should eql(Rational(1, 1))
@@ -66,7 +64,7 @@ describe :rational_exponent, shared: true do
end
it "raises ZeroDivisionError when self is Rational(0) and the exponent is negative" do
- -> { Rational(0) ** -bignum_value }.should raise_error(ZeroDivisionError)
+ lambda { Rational(0) ** -bignum_value }.should raise_error(ZeroDivisionError)
end
it "returns Rational(1) when self is Rational(1)" do
@@ -117,9 +115,9 @@ describe :rational_exponent, shared: true do
end
it "returns a complex number if self is negative and the passed argument is not 0" do
- (Rational(-3, 2) ** 1.5).should be_close(Complex(0.0, -1.8371173070873836), TOLERANCE)
- (Rational(3, -2) ** 1.5).should be_close(Complex(0.0, -1.8371173070873836), TOLERANCE)
- (Rational(3, -2) ** -1.5).should be_close(Complex(0.0, 0.5443310539518174), TOLERANCE)
+ (Rational(-3, 2) ** 1.5).should be_close(Complex(-3.374618290464398e-16, -1.8371173070873836), TOLERANCE)
+ (Rational(3, -2) ** 1.5).should be_close(Complex(-3.374618290464398e-16, -1.8371173070873836), TOLERANCE)
+ (Rational(3, -2) ** -1.5).should be_close(Complex(-9.998869008783402e-17, 0.5443310539518174), TOLERANCE)
end
it "returns Complex(1.0) when the passed argument is 0.0" do
@@ -153,19 +151,19 @@ describe :rational_exponent, shared: true do
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Integer" do
[-1, -4, -9999].each do |exponent|
- -> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
+ lambda { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
end
end
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational with denominator 1" do
[Rational(-1, 1), Rational(-3, 1)].each do |exponent|
- -> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
+ lambda { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
end
end
# #7513
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational" do
- -> { Rational(0, 1) ** Rational(-3, 2) }.should raise_error(ZeroDivisionError, "divided by 0")
+ lambda { Rational(0, 1) ** Rational(-3, 2) }.should raise_error(ZeroDivisionError, "divided by 0")
end
platform_is_not :solaris do # See https://github.com/ruby/spec/issues/134
diff --git a/spec/ruby/shared/rational/fdiv.rb b/spec/ruby/shared/rational/fdiv.rb
index 6911ade8ac..22ca4b4ddc 100644
--- a/spec/ruby/shared/rational/fdiv.rb
+++ b/spec/ruby/shared/rational/fdiv.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_fdiv, shared: true do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/shared/rational/floor.rb b/spec/ruby/shared/rational/floor.rb
index ddf7fdbd17..5106e0b4d9 100644
--- a/spec/ruby/shared/rational/floor.rb
+++ b/spec/ruby/shared/rational/floor.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_floor, shared: true do
before do
diff --git a/spec/ruby/shared/rational/hash.rb b/spec/ruby/shared/rational/hash.rb
index 50f21cec20..a83ce49afb 100644
--- a/spec/ruby/shared/rational/hash.rb
+++ b/spec/ruby/shared/rational/hash.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_hash, shared: true do
# BUG: Rational(2, 3).hash == Rational(3, 2).hash
diff --git a/spec/ruby/shared/rational/inspect.rb b/spec/ruby/shared/rational/inspect.rb
index 19691a2f25..a641db8eb8 100644
--- a/spec/ruby/shared/rational/inspect.rb
+++ b/spec/ruby/shared/rational/inspect.rb
@@ -1,13 +1,11 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_inspect, shared: true do
- it "returns a string representation of self" do
- Rational(3, 4).inspect.should == "(3/4)"
- Rational(-5, 8).inspect.should == "(-5/8)"
- Rational(-1, -2).inspect.should == "(1/2)"
-
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
+ conflicts_with :Prime do
+ it "returns a string representation of self" do
+ Rational(3, 4).inspect.should == "(3/4)"
+ Rational(-5, 8).inspect.should == "(-5/8)"
+ Rational(-1, -2).inspect.should == "(1/2)"
Rational(bignum_value, 1).inspect.should == "(#{bignum_value}/1)"
end
end
diff --git a/spec/ruby/shared/rational/marshal_dump.rb b/spec/ruby/shared/rational/marshal_dump.rb
index 09782b45a5..673c6c8327 100644
--- a/spec/ruby/shared/rational/marshal_dump.rb
+++ b/spec/ruby/shared/rational/marshal_dump.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_marshal_dump, shared: true do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/shared/rational/marshal_load.rb b/spec/ruby/shared/rational/marshal_load.rb
index 20bdd6fdf4..7cf32ad1db 100644
--- a/spec/ruby/shared/rational/marshal_load.rb
+++ b/spec/ruby/shared/rational/marshal_load.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_marshal_load, shared: true do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/shared/rational/minus.rb b/spec/ruby/shared/rational/minus.rb
index 0a0946fdb9..e23430111e 100644
--- a/spec/ruby/shared/rational/minus.rb
+++ b/spec/ruby/shared/rational/minus.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_minus_rat, shared: true do
it "returns the result of subtracting other from self as a Rational" do
diff --git a/spec/ruby/shared/rational/modulo.rb b/spec/ruby/shared/rational/modulo.rb
index 9e4b0c49e6..ca69650f20 100644
--- a/spec/ruby/shared/rational/modulo.rb
+++ b/spec/ruby/shared/rational/modulo.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_modulo, shared: true do
it "returns the remainder when this value is divided by other" do
@@ -22,21 +22,21 @@ describe :rational_modulo, shared: true do
end
it "raises ZeroDivisionError on zero denominator" do
- -> {
+ lambda {
Rational(3, 5).send(@method, Rational(0, 1))
}.should raise_error(ZeroDivisionError)
- -> {
+ lambda {
Rational(0, 1).send(@method, Rational(0, 1))
}.should raise_error(ZeroDivisionError)
- -> {
+ lambda {
Rational(3, 5).send(@method, 0)
}.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the argument is 0.0" do
- -> {
+ lambda {
Rational(3, 5).send(@method, 0.0)
}.should raise_error(ZeroDivisionError)
end
diff --git a/spec/ruby/shared/rational/multiply.rb b/spec/ruby/shared/rational/multiply.rb
index 9c861cf79d..05a9cfc5c8 100644
--- a/spec/ruby/shared/rational/multiply.rb
+++ b/spec/ruby/shared/rational/multiply.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_multiply_rat, shared: true do
it "returns self divided by other as a Rational" do
diff --git a/spec/ruby/shared/rational/numerator.rb b/spec/ruby/shared/rational/numerator.rb
index 50d768168c..e4868ef43c 100644
--- a/spec/ruby/shared/rational/numerator.rb
+++ b/spec/ruby/shared/rational/numerator.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_numerator, shared: true do
it "returns the numerator" do
diff --git a/spec/ruby/shared/rational/plus.rb b/spec/ruby/shared/rational/plus.rb
index b126360ee4..e37c757c13 100644
--- a/spec/ruby/shared/rational/plus.rb
+++ b/spec/ruby/shared/rational/plus.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_plus_rat, shared: true do
it "returns the result of subtracting other from self as a Rational" do
diff --git a/spec/ruby/shared/rational/quo.rb b/spec/ruby/shared/rational/quo.rb
index 53b32fed2f..61bd3fad9d 100644
--- a/spec/ruby/shared/rational/quo.rb
+++ b/spec/ruby/shared/rational/quo.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_quo, shared: true do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/shared/rational/remainder.rb b/spec/ruby/shared/rational/remainder.rb
index dd907608db..64aeb55e6c 100644
--- a/spec/ruby/shared/rational/remainder.rb
+++ b/spec/ruby/shared/rational/remainder.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_remainder, shared: true do
it "needs to be reviewed for spec completeness"
diff --git a/spec/ruby/shared/rational/round.rb b/spec/ruby/shared/rational/round.rb
index 5b159ee3e6..c7a4cc6d07 100644
--- a/spec/ruby/shared/rational/round.rb
+++ b/spec/ruby/shared/rational/round.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_round, shared: true do
before do
@@ -47,11 +47,8 @@ describe :rational_round, shared: true do
it "returns a Rational" do
@rational.round(1).should be_kind_of(Rational)
@rational.round(2).should be_kind_of(Rational)
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
- Rational(0, 1).round(1).should be_kind_of(Rational)
- Rational(2, 1).round(1).should be_kind_of(Rational)
- end
+ Rational(0, 1).round(1).should be_kind_of(Rational)
+ Rational(2, 1).round(1).should be_kind_of(Rational)
end
it "moves the truncation point n decimal places right" do
@@ -72,35 +69,28 @@ describe :rational_round, shared: true do
end
end
- describe "with half option" do
- it "returns an Integer when precision is not passed" do
- Rational(10, 4).round(half: nil).should == 3
- Rational(10, 4).round(half: :up).should == 3
- Rational(10, 4).round(half: :down).should == 2
- Rational(10, 4).round(half: :even).should == 2
- Rational(-10, 4).round(half: nil).should == -3
- Rational(-10, 4).round(half: :up).should == -3
- Rational(-10, 4).round(half: :down).should == -2
- Rational(-10, 4).round(half: :even).should == -2
- end
-
- it "returns a Rational when the precision is greater than 0" do
- Rational(25, 100).round(1, half: nil).should == Rational(3, 10)
- Rational(25, 100).round(1, half: :up).should == Rational(3, 10)
- Rational(25, 100).round(1, half: :down).should == Rational(1, 5)
- Rational(25, 100).round(1, half: :even).should == Rational(1, 5)
- Rational(35, 100).round(1, half: nil).should == Rational(2, 5)
- Rational(35, 100).round(1, half: :up).should == Rational(2, 5)
- Rational(35, 100).round(1, half: :down).should == Rational(3, 10)
- Rational(35, 100).round(1, half: :even).should == Rational(2, 5)
- Rational(-25, 100).round(1, half: nil).should == Rational(-3, 10)
- Rational(-25, 100).round(1, half: :up).should == Rational(-3, 10)
- Rational(-25, 100).round(1, half: :down).should == Rational(-1, 5)
- Rational(-25, 100).round(1, half: :even).should == Rational(-1, 5)
- end
+ ruby_version_is "2.4" do
+ describe "with half option" do
+ it "returns an Integer when precision is not passed" do
+ Rational(10, 4).round(half: :up).should == 3
+ Rational(10, 4).round(half: :down).should == 2
+ Rational(10, 4).round(half: :even).should == 2
+ Rational(-10, 4).round(half: :up).should == -3
+ Rational(-10, 4).round(half: :down).should == -2
+ Rational(-10, 4).round(half: :even).should == -2
+ end
- it "raise for a non-existent round mode" do
- -> { Rational(10, 4).round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
+ it "returns a Rational when the precision is greater than 0" do
+ Rational(25, 100).round(1, half: :up).should == Rational(3, 10)
+ Rational(25, 100).round(1, half: :down).should == Rational(1, 5)
+ Rational(25, 100).round(1, half: :even).should == Rational(1, 5)
+ Rational(35, 100).round(1, half: :up).should == Rational(2, 5)
+ Rational(35, 100).round(1, half: :down).should == Rational(3, 10)
+ Rational(35, 100).round(1, half: :even).should == Rational(2, 5)
+ Rational(-25, 100).round(1, half: :up).should == Rational(-3, 10)
+ Rational(-25, 100).round(1, half: :down).should == Rational(-1, 5)
+ Rational(-25, 100).round(1, half: :even).should == Rational(-1, 5)
+ end
end
end
end
diff --git a/spec/ruby/shared/rational/to_f.rb b/spec/ruby/shared/rational/to_f.rb
index 56e0b61d68..2c9afdddda 100644
--- a/spec/ruby/shared/rational/to_f.rb
+++ b/spec/ruby/shared/rational/to_f.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_to_f, shared: true do
it "returns self converted to a Float" do
diff --git a/spec/ruby/shared/rational/to_i.rb b/spec/ruby/shared/rational/to_i.rb
index 9be1183aa4..b0db78b3a8 100644
--- a/spec/ruby/shared/rational/to_i.rb
+++ b/spec/ruby/shared/rational/to_i.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_to_i, shared: true do
it "converts self to an Integer by truncation" do
diff --git a/spec/ruby/shared/rational/to_r.rb b/spec/ruby/shared/rational/to_r.rb
index 372c086850..646167614a 100644
--- a/spec/ruby/shared/rational/to_r.rb
+++ b/spec/ruby/shared/rational/to_r.rb
@@ -1,11 +1,13 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_to_r, shared: true do
- it "returns self" do
- a = Rational(3, 4)
- a.to_r.should equal(a)
+ conflicts_with :Prime do
+ it "returns self" do
+ a = Rational(3, 4)
+ a.to_r.should equal(a)
- a = Rational(bignum_value, 4)
- a.to_r.should equal(a)
+ a = Rational(bignum_value, 4)
+ a.to_r.should equal(a)
+ end
end
end
diff --git a/spec/ruby/shared/rational/to_s.rb b/spec/ruby/shared/rational/to_s.rb
index e90c6e5e39..429a021908 100644
--- a/spec/ruby/shared/rational/to_s.rb
+++ b/spec/ruby/shared/rational/to_s.rb
@@ -1,12 +1,9 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_to_s, shared: true do
it "returns a string representation of self" do
- # Guard against the Mathn library
- guard -> { !defined?(Math.rsqrt) } do
- Rational(1, 1).to_s.should == "1/1"
- Rational(2, 1).to_s.should == "2/1"
- end
+ Rational(1, 1).to_s.should == "1/1"
+ Rational(2, 1).to_s.should == "2/1"
Rational(1, 2).to_s.should == "1/2"
Rational(-1, 3).to_s.should == "-1/3"
Rational(1, -3).to_s.should == "-1/3"
diff --git a/spec/ruby/shared/rational/truncate.rb b/spec/ruby/shared/rational/truncate.rb
index 761dd3113a..993c654c45 100644
--- a/spec/ruby/shared/rational/truncate.rb
+++ b/spec/ruby/shared/rational/truncate.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe :rational_truncate, shared: true do
before do
diff --git a/spec/ruby/shared/sizedqueue/enque.rb b/spec/ruby/shared/sizedqueue/enque.rb
deleted file mode 100644
index 6ef12349f8..0000000000
--- a/spec/ruby/shared/sizedqueue/enque.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-describe :sizedqueue_enq, shared: true do
- it "blocks if queued elements exceed size" do
- q = @object.call(1)
-
- q.size.should == 0
- q.send(@method, :first_element)
- q.size.should == 1
-
- blocked_thread = Thread.new { q.send(@method, :second_element) }
- sleep 0.01 until blocked_thread.stop?
-
- q.size.should == 1
- q.pop.should == :first_element
-
- blocked_thread.join
- q.size.should == 1
- q.pop.should == :second_element
- q.size.should == 0
- end
-
- it "raises a ThreadError if queued elements exceed size when not blocking" do
- q = @object.call(2)
-
- non_blocking = true
- add_to_queue = -> { q.send(@method, Object.new, non_blocking) }
-
- q.size.should == 0
- add_to_queue.call
- q.size.should == 1
- add_to_queue.call
- q.size.should == 2
- add_to_queue.should raise_error(ThreadError)
- end
-
- it "interrupts enqueuing threads with ClosedQueueError when the queue is closed" do
- q = @object.call(1)
- q << 1
-
- t = Thread.new {
- -> { q.send(@method, 2) }.should raise_error(ClosedQueueError)
- }
-
- Thread.pass until q.num_waiting == 1
-
- q.close
-
- t.join
- q.pop.should == 1
- end
-end
diff --git a/spec/ruby/shared/sizedqueue/max.rb b/spec/ruby/shared/sizedqueue/max.rb
deleted file mode 100644
index ea10d24be0..0000000000
--- a/spec/ruby/shared/sizedqueue/max.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-describe :sizedqueue_max, shared: true do
- it "returns the size of the queue" do
- q = @object.call(5)
- q.max.should == 5
- end
-end
-
-describe :sizedqueue_max=, shared: true do
- it "sets the size of the queue" do
- q = @object.call(5)
- q.max.should == 5
- q.max = 10
- q.max.should == 10
- end
-
- it "does not remove items already in the queue beyond the maximum" do
- q = @object.call(5)
- q.enq 1
- q.enq 2
- q.enq 3
- q.max = 2
- (q.size > q.max).should be_true
- q.deq.should == 1
- q.deq.should == 2
- q.deq.should == 3
- end
-
- it "raises a TypeError when given a non-numeric value" do
- q = @object.call(5)
- -> { q.max = "foo" }.should raise_error(TypeError)
- -> { q.max = Object.new }.should raise_error(TypeError)
- end
-
- it "raises an argument error when set to zero" do
- q = @object.call(5)
- q.max.should == 5
- -> { q.max = 0 }.should raise_error(ArgumentError)
- q.max.should == 5
- end
-
- it "raises an argument error when set to a negative number" do
- q = @object.call(5)
- q.max.should == 5
- -> { q.max = -1 }.should raise_error(ArgumentError)
- q.max.should == 5
- end
-end
diff --git a/spec/ruby/shared/sizedqueue/new.rb b/spec/ruby/shared/sizedqueue/new.rb
deleted file mode 100644
index 713785fb50..0000000000
--- a/spec/ruby/shared/sizedqueue/new.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-describe :sizedqueue_new, shared: true do
- it "raises a TypeError when the given argument is not Numeric" do
- -> { @object.call("foo") }.should raise_error(TypeError)
- -> { @object.call(Object.new) }.should raise_error(TypeError)
- end
-
- it "raises an argument error when no argument is given" do
- -> { @object.call }.should raise_error(ArgumentError)
- end
-
- it "raises an argument error when the given argument is zero" do
- -> { @object.call(0) }.should raise_error(ArgumentError)
- end
-
- it "raises an argument error when the given argument is negative" do
- -> { @object.call(-1) }.should raise_error(ArgumentError)
- end
-end
diff --git a/spec/ruby/shared/sizedqueue/num_waiting.rb b/spec/ruby/shared/sizedqueue/num_waiting.rb
deleted file mode 100644
index 8c31e48ca5..0000000000
--- a/spec/ruby/shared/sizedqueue/num_waiting.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-describe :sizedqueue_num_waiting, shared: true do
- it "reports the number of threads waiting to push" do
- q = @object.call(1)
- q.push(1)
- t = Thread.new { q.push(2) }
- sleep 0.05 until t.stop?
- q.num_waiting.should == 1
-
- q.pop
- t.join
- end
-end
diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb
index 6b45f7aa1e..c44a76c9b7 100644
--- a/spec/ruby/shared/string/times.rb
+++ b/spec/ruby/shared/string/times.rb
@@ -18,12 +18,12 @@ describe :string_times, shared: true do
end
it "raises an ArgumentError when given integer is negative" do
- -> { @object.call("cool", -3) }.should raise_error(ArgumentError)
- -> { @object.call("cool", -3.14) }.should raise_error(ArgumentError)
+ lambda { @object.call("cool", -3) }.should raise_error(ArgumentError)
+ lambda { @object.call("cool", -3.14) }.should raise_error(ArgumentError)
end
it "raises a RangeError when given integer is a Bignum" do
- -> { @object.call("cool", 999999999999999999999) }.should raise_error(RangeError)
+ lambda { @object.call("cool", 999999999999999999999) }.should raise_error(RangeError)
end
it "returns subclass instances" do
@@ -32,33 +32,33 @@ describe :string_times, shared: true do
@object.call(MyString.new("cool"), 2).should be_an_instance_of(MyString)
end
- ruby_version_is ''...'2.7' do
- it "always taints the result when self is tainted" do
- ["", "OK", MyString.new(""), MyString.new("OK")].each do |str|
- str.taint
+ it "always taints the result when self is tainted" do
+ ["", "OK", MyString.new(""), MyString.new("OK")].each do |str|
+ str.taint
- [0, 1, 2].each do |arg|
- @object.call(str, arg).tainted?.should == true
- end
+ [0, 1, 2].each do |arg|
+ @object.call(str, arg).tainted?.should == true
end
end
end
- it "returns a String in the same encoding as self" do
- str = "\xE3\x81\x82".force_encoding Encoding::UTF_8
- result = @object.call(str, 2)
- result.encoding.should equal(Encoding::UTF_8)
+ with_feature :encoding do
+ it "returns a String in the same encoding as self" do
+ str = "\xE3\x81\x82".force_encoding Encoding::UTF_8
+ result = @object.call(str, 2)
+ result.encoding.should equal(Encoding::UTF_8)
+ end
end
platform_is wordsize: 32 do
it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do
- -> { @object.call("abc", (2 ** 31) - 1) }.should raise_error(ArgumentError)
+ lambda { @object.call("abc", (2 ** 31) - 1) }.should raise_error(ArgumentError)
end
end
platform_is wordsize: 64 do
it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do
- -> { @object.call("abc", (2 ** 63) - 1) }.should raise_error(ArgumentError)
+ lambda { @object.call("abc", (2 ** 63) - 1) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/shared/time/strftime_for_date.rb b/spec/ruby/shared/time/strftime_for_date.rb
index dbb124adc8..f126c5a323 100644
--- a/spec/ruby/shared/time/strftime_for_date.rb
+++ b/spec/ruby/shared/time/strftime_for_date.rb
@@ -264,10 +264,12 @@ describe :strftime_date, shared: true do
@new_date[2001,3,22].strftime("%-m/%-d/%-y").should == "3/22/1"
end
- it "passes the format string's encoding to the result string" do
- result = @new_date[2010,3,8].strftime("%d. März %Y")
+ with_feature :encoding do
+ it "passes the format string's encoding to the result string" do
+ result = @new_date[2010,3,8].strftime("%d. März %Y")
- result.encoding.should == Encoding::UTF_8
- result.should == "08. März 2010"
+ result.encoding.should == Encoding::UTF_8
+ result.should == "08. März 2010"
+ end
end
end
diff --git a/sprintf.c b/sprintf.c
index 23eb39a73b..a956381cd4 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -11,9 +11,8 @@
**********************************************************************/
-#include "ruby/encoding.h"
-#include "ruby/re.h"
#include "internal.h"
+#include "ruby/re.h"
#include "id.h"
#include <math.h>
#include <stdarg.h>
@@ -194,6 +193,267 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
return (*hash = tmp);
}
+/*
+ * call-seq:
+ * format(format_string [, arguments...] ) -> string
+ * sprintf(format_string [, arguments...] ) -> string
+ *
+ * Returns the string resulting from applying <i>format_string</i> to
+ * any additional arguments. Within the format string, any characters
+ * other than format sequences are copied to the result.
+ *
+ * The syntax of a format sequence is follows.
+ *
+ * %[flags][width][.precision]type
+ *
+ * A format
+ * sequence consists of a percent sign, followed by optional flags,
+ * width, and precision indicators, then terminated with a field type
+ * character. The field type controls how the corresponding
+ * <code>sprintf</code> argument is to be interpreted, while the flags
+ * modify that interpretation.
+ *
+ * The field type characters are:
+ *
+ * Field | Integer Format
+ * ------+--------------------------------------------------------------
+ * b | Convert argument as a binary number.
+ * | Negative numbers will be displayed as a two's complement
+ * | prefixed with `..1'.
+ * B | Equivalent to `b', but uses an uppercase 0B for prefix
+ * | in the alternative format by #.
+ * d | Convert argument as a decimal number.
+ * i | Identical to `d'.
+ * o | Convert argument as an octal number.
+ * | Negative numbers will be displayed as a two's complement
+ * | prefixed with `..7'.
+ * u | Identical to `d'.
+ * x | Convert argument as a hexadecimal number.
+ * | Negative numbers will be displayed as a two's complement
+ * | prefixed with `..f' (representing an infinite string of
+ * | leading 'ff's).
+ * X | Equivalent to `x', but uses uppercase letters.
+ *
+ * Field | Float Format
+ * ------+--------------------------------------------------------------
+ * e | Convert floating point argument into exponential notation
+ * | with one digit before the decimal point as [-]d.dddddde[+-]dd.
+ * | The precision specifies the number of digits after the decimal
+ * | point (defaulting to six).
+ * E | Equivalent to `e', but uses an uppercase E to indicate
+ * | the exponent.
+ * f | Convert floating point argument as [-]ddd.dddddd,
+ * | where the precision specifies the number of digits after
+ * | the decimal point.
+ * g | Convert a floating point number using exponential form
+ * | if the exponent is less than -4 or greater than or
+ * | equal to the precision, or in dd.dddd form otherwise.
+ * | The precision specifies the number of significant digits.
+ * G | Equivalent to `g', but use an uppercase `E' in exponent form.
+ * a | Convert floating point argument as [-]0xh.hhhhp[+-]dd,
+ * | which is consisted from optional sign, "0x", fraction part
+ * | as hexadecimal, "p", and exponential part as decimal.
+ * A | Equivalent to `a', but use uppercase `X' and `P'.
+ *
+ * Field | Other Format
+ * ------+--------------------------------------------------------------
+ * c | Argument is the numeric code for a single character or
+ * | a single character string itself.
+ * p | The valuing of argument.inspect.
+ * s | Argument is a string to be substituted. If the format
+ * | sequence contains a precision, at most that many characters
+ * | will be copied.
+ * % | A percent sign itself will be displayed. No argument taken.
+ *
+ * The flags modifies the behavior of the formats.
+ * The flag characters are:
+ *
+ * Flag | Applies to | Meaning
+ * ---------+---------------+-----------------------------------------
+ * space | bBdiouxX | Leave a space at the start of
+ * | aAeEfgG | non-negative numbers.
+ * | (numeric fmt) | For `o', `x', `X', `b' and `B', use
+ * | | a minus sign with absolute value for
+ * | | negative values.
+ * ---------+---------------+-----------------------------------------
+ * (digit)$ | all | Specifies the absolute argument number
+ * | | for this field. Absolute and relative
+ * | | argument numbers cannot be mixed in a
+ * | | sprintf string.
+ * ---------+---------------+-----------------------------------------
+ * # | bBoxX | Use an alternative format.
+ * | aAeEfgG | For the conversions `o', increase the precision
+ * | | until the first digit will be `0' if
+ * | | it is not formatted as complements.
+ * | | For the conversions `x', `X', `b' and `B'
+ * | | on non-zero, prefix the result with ``0x'',
+ * | | ``0X'', ``0b'' and ``0B'', respectively.
+ * | | For `a', `A', `e', `E', `f', `g', and 'G',
+ * | | force a decimal point to be added,
+ * | | even if no digits follow.
+ * | | For `g' and 'G', do not remove trailing zeros.
+ * ---------+---------------+-----------------------------------------
+ * + | bBdiouxX | Add a leading plus sign to non-negative
+ * | aAeEfgG | numbers.
+ * | (numeric fmt) | For `o', `x', `X', `b' and `B', use
+ * | | a minus sign with absolute value for
+ * | | negative values.
+ * ---------+---------------+-----------------------------------------
+ * - | all | Left-justify the result of this conversion.
+ * ---------+---------------+-----------------------------------------
+ * 0 (zero) | bBdiouxX | Pad with zeros, not spaces.
+ * | aAeEfgG | For `o', `x', `X', `b' and `B', radix-1
+ * | (numeric fmt) | is used for negative numbers formatted as
+ * | | complements.
+ * ---------+---------------+-----------------------------------------
+ * * | all | Use the next argument as the field width.
+ * | | If negative, left-justify the result. If the
+ * | | asterisk is followed by a number and a dollar
+ * | | sign, use the indicated argument as the width.
+ *
+ * Examples of flags:
+ *
+ * # `+' and space flag specifies the sign of non-negative numbers.
+ * sprintf("%d", 123) #=> "123"
+ * sprintf("%+d", 123) #=> "+123"
+ * sprintf("% d", 123) #=> " 123"
+ *
+ * # `#' flag for `o' increases number of digits to show `0'.
+ * # `+' and space flag changes format of negative numbers.
+ * sprintf("%o", 123) #=> "173"
+ * sprintf("%#o", 123) #=> "0173"
+ * sprintf("%+o", -123) #=> "-173"
+ * sprintf("%o", -123) #=> "..7605"
+ * sprintf("%#o", -123) #=> "..7605"
+ *
+ * # `#' flag for `x' add a prefix `0x' for non-zero numbers.
+ * # `+' and space flag disables complements for negative numbers.
+ * sprintf("%x", 123) #=> "7b"
+ * sprintf("%#x", 123) #=> "0x7b"
+ * sprintf("%+x", -123) #=> "-7b"
+ * sprintf("%x", -123) #=> "..f85"
+ * sprintf("%#x", -123) #=> "0x..f85"
+ * sprintf("%#x", 0) #=> "0"
+ *
+ * # `#' for `X' uses the prefix `0X'.
+ * sprintf("%X", 123) #=> "7B"
+ * sprintf("%#X", 123) #=> "0X7B"
+ *
+ * # `#' flag for `b' add a prefix `0b' for non-zero numbers.
+ * # `+' and space flag disables complements for negative numbers.
+ * sprintf("%b", 123) #=> "1111011"
+ * sprintf("%#b", 123) #=> "0b1111011"
+ * sprintf("%+b", -123) #=> "-1111011"
+ * sprintf("%b", -123) #=> "..10000101"
+ * sprintf("%#b", -123) #=> "0b..10000101"
+ * sprintf("%#b", 0) #=> "0"
+ *
+ * # `#' for `B' uses the prefix `0B'.
+ * sprintf("%B", 123) #=> "1111011"
+ * sprintf("%#B", 123) #=> "0B1111011"
+ *
+ * # `#' for `e' forces to show the decimal point.
+ * sprintf("%.0e", 1) #=> "1e+00"
+ * sprintf("%#.0e", 1) #=> "1.e+00"
+ *
+ * # `#' for `f' forces to show the decimal point.
+ * sprintf("%.0f", 1234) #=> "1234"
+ * sprintf("%#.0f", 1234) #=> "1234."
+ *
+ * # `#' for `g' forces to show the decimal point.
+ * # It also disables stripping lowest zeros.
+ * sprintf("%g", 123.4) #=> "123.4"
+ * sprintf("%#g", 123.4) #=> "123.400"
+ * sprintf("%g", 123456) #=> "123456"
+ * sprintf("%#g", 123456) #=> "123456."
+ *
+ * The field width is an optional integer, followed optionally by a
+ * period and a precision. The width specifies the minimum number of
+ * characters that will be written to the result for this field.
+ *
+ * Examples of width:
+ *
+ * # padding is done by spaces, width=20
+ * # 0 or radix-1. <------------------>
+ * sprintf("%20d", 123) #=> " 123"
+ * sprintf("%+20d", 123) #=> " +123"
+ * sprintf("%020d", 123) #=> "00000000000000000123"
+ * sprintf("%+020d", 123) #=> "+0000000000000000123"
+ * sprintf("% 020d", 123) #=> " 0000000000000000123"
+ * sprintf("%-20d", 123) #=> "123 "
+ * sprintf("%-+20d", 123) #=> "+123 "
+ * sprintf("%- 20d", 123) #=> " 123 "
+ * sprintf("%020x", -123) #=> "..ffffffffffffffff85"
+ *
+ * For
+ * numeric fields, the precision controls the number of decimal places
+ * displayed. For string fields, the precision determines the maximum
+ * number of characters to be copied from the string. (Thus, the format
+ * sequence <code>%10.10s</code> will always contribute exactly ten
+ * characters to the result.)
+ *
+ * Examples of precisions:
+ *
+ * # precision for `d', 'o', 'x' and 'b' is
+ * # minimum number of digits <------>
+ * sprintf("%20.8d", 123) #=> " 00000123"
+ * sprintf("%20.8o", 123) #=> " 00000173"
+ * sprintf("%20.8x", 123) #=> " 0000007b"
+ * sprintf("%20.8b", 123) #=> " 01111011"
+ * sprintf("%20.8d", -123) #=> " -00000123"
+ * sprintf("%20.8o", -123) #=> " ..777605"
+ * sprintf("%20.8x", -123) #=> " ..ffff85"
+ * sprintf("%20.8b", -11) #=> " ..110101"
+ *
+ * # "0x" and "0b" for `#x' and `#b' is not counted for
+ * # precision but "0" for `#o' is counted. <------>
+ * sprintf("%#20.8d", 123) #=> " 00000123"
+ * sprintf("%#20.8o", 123) #=> " 00000173"
+ * sprintf("%#20.8x", 123) #=> " 0x0000007b"
+ * sprintf("%#20.8b", 123) #=> " 0b01111011"
+ * sprintf("%#20.8d", -123) #=> " -00000123"
+ * sprintf("%#20.8o", -123) #=> " ..777605"
+ * sprintf("%#20.8x", -123) #=> " 0x..ffff85"
+ * sprintf("%#20.8b", -11) #=> " 0b..110101"
+ *
+ * # precision for `e' is number of
+ * # digits after the decimal point <------>
+ * sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03"
+ *
+ * # precision for `f' is number of
+ * # digits after the decimal point <------>
+ * sprintf("%20.8f", 1234.56789) #=> " 1234.56789000"
+ *
+ * # precision for `g' is number of
+ * # significant digits <------->
+ * sprintf("%20.8g", 1234.56789) #=> " 1234.5679"
+ *
+ * # <------->
+ * sprintf("%20.8g", 123456789) #=> " 1.2345679e+08"
+ *
+ * # precision for `s' is
+ * # maximum number of characters <------>
+ * sprintf("%20.8s", "string test") #=> " string t"
+ *
+ * Examples:
+ *
+ * sprintf("%d %04x", 123, 123) #=> "123 007b"
+ * sprintf("%08b '%4s'", 123, 123) #=> "01111011 ' 123'"
+ * sprintf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello"
+ * sprintf("%1$*2$s %2$d", "hello", -8) #=> "hello -8"
+ * sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23"
+ * sprintf("%u", -123) #=> "-123"
+ *
+ * For more complex formatting, Ruby supports a reference by name.
+ * %<name>s style uses format style, but %{name} style doesn't.
+ *
+ * Examples:
+ * sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 })
+ * #=> 1 : 2.000000
+ * sprintf("%{foo}f", { :foo => 1 })
+ * # => "1f"
+ */
+
VALUE
rb_f_sprintf(int argc, const VALUE *argv)
{
@@ -215,6 +475,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
int width, prec, flags = FNONE;
int nextarg = 1;
int posarg = 0;
+ int tainted = 0;
VALUE nextvalue;
VALUE tmp;
VALUE orig;
@@ -238,6 +499,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
++argc;
--argv;
+ if (OBJ_TAINTED(fmt)) tainted = 1;
StringValue(fmt);
enc = rb_enc_get(fmt);
orig = fmt;
@@ -414,7 +676,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
case '\n':
case '\0':
p--;
- /* fall through */
case '%':
if (flags != FNONE) {
rb_raise(rb_eArgError, "invalid format character - %%");
@@ -477,6 +738,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
else {
str = rb_obj_as_string(arg);
}
+ if (OBJ_TAINTED(str)) tainted = 1;
len = RSTRING_LEN(str);
rb_str_set_len(result, blen);
if (coderange != ENC_CODERANGE_BROKEN && scanned < blen) {
@@ -928,6 +1190,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
}
rb_str_resize(result, blen);
+ if (tainted) OBJ_TAINT(result);
return result;
}
@@ -1011,7 +1274,7 @@ ruby_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
static int
ruby_do_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
{
- ssize_t ret;
+ int ret;
rb_printf_buffer f;
f._flags = __SWR | __SSTR;
@@ -1019,12 +1282,9 @@ ruby_do_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
f._bf._size = f._w = str ? (n - 1) : 0;
f.vwrite = BSD__sfvwrite;
f.vextra = 0;
- ret = BSD_vfprintf(&f, fmt, ap);
+ ret = (int)BSD_vfprintf(&f, fmt, ap);
if (str) *f._p = 0;
-#if SIZEOF_SIZE_T > SIZEOF_INT
- if (n > INT_MAX) return INT_MAX;
-#endif
- return (int)ret;
+ return ret;
}
int
@@ -1114,12 +1374,6 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
}
value = rb_inspect(value);
}
- else if (SYMBOL_P(value)) {
- value = rb_sym2str(value);
- if (sign == ' ' && !rb_str_symname_p(value)) {
- value = rb_str_inspect(value);
- }
- }
else {
value = rb_obj_as_string(value);
if (sign == ' ') value = QUOTE(value);
@@ -1138,6 +1392,7 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
StringValueCStr(value);
RSTRING_GETMEM(value, cp, *sz);
((rb_printf_buffer_extra *)fp)->value = value;
+ OBJ_INFECT(result, value);
return cp;
}
diff --git a/st.c b/st.c
index 599f93a463..d44c979e19 100644
--- a/st.c
+++ b/st.c
@@ -140,22 +140,21 @@ struct st_table_entry {
};
#define type_numhash st_hashtype_num
-static const struct st_hash_type st_hashtype_num = {
+const struct st_hash_type st_hashtype_num = {
st_numcmp,
st_numhash,
};
-static int st_strcmp(st_data_t, st_data_t);
+/* extern int strcmp(const char *, const char *); */
static st_index_t strhash(st_data_t);
static const struct st_hash_type type_strhash = {
- st_strcmp,
+ strcmp,
strhash,
};
-static int st_locale_insensitive_strcasecmp_i(st_data_t lhs, st_data_t rhs);
static st_index_t strcasehash(st_data_t);
static const struct st_hash_type type_strcasehash = {
- st_locale_insensitive_strcasecmp_i,
+ st_locale_insensitive_strcasecmp,
strcasehash,
};
@@ -316,9 +315,6 @@ static const struct st_features features[] = {
#define RESERVED_HASH_VAL (~(st_hash_t) 0)
#define RESERVED_HASH_SUBSTITUTION_VAL ((st_hash_t) 0)
-const st_hash_t st_reserved_hash_val = RESERVED_HASH_VAL;
-const st_hash_t st_reserved_hash_substitution_val = RESERVED_HASH_SUBSTITUTION_VAL;
-
/* Return hash value of KEY for table TAB. */
static inline st_hash_t
do_hash(st_data_t key, st_table *tab)
@@ -345,7 +341,10 @@ do_hash(st_data_t key, st_table *tab)
static int
get_power2(st_index_t size)
{
- unsigned int n = ST_INDEX_BITS - nlz_intptr(size);
+ unsigned int n;
+
+ for (n = 0; size != 0; n++)
+ size >>= 1;
if (n <= MAX_POWER2)
return n < MINIMAL_POWER2 ? MINIMAL_POWER2 : n;
#ifndef NOT_RUBY
@@ -561,8 +560,6 @@ stat_col(void)
FILE *f;
if (!collision.total) return;
f = fopen((snprintf(fname, sizeof(fname), "/tmp/col%ld", (long)getpid()), fname), "w");
- if (f == NULL)
- return;
fprintf(f, "collision: %d / %d (%6.2f)\n", collision.all, collision.total,
((double)collision.all / (collision.total)) * 100);
fprintf(f, "num: %d, str: %d, strcase: %d\n", collision.num, collision.str, collision.strcase);
@@ -593,38 +590,17 @@ st_init_table_with_size(const struct st_hash_type *type, st_index_t size)
#endif
n = get_power2(size);
-#ifndef RUBY
- if (n < 0)
- return NULL;
-#endif
tab = (st_table *) malloc(sizeof (st_table));
-#ifndef RUBY
- if (tab == NULL)
- return NULL;
-#endif
tab->type = type;
tab->entry_power = n;
tab->bin_power = features[n].bin_power;
tab->size_ind = features[n].size_ind;
if (n <= MAX_POWER2_FOR_TABLES_WITHOUT_BINS)
tab->bins = NULL;
- else {
+ else
tab->bins = (st_index_t *) malloc(bins_size(tab));
-#ifndef RUBY
- if (tab->bins == NULL) {
- free(tab);
- return NULL;
- }
-#endif
- }
tab->entries = (st_table_entry *) malloc(get_allocated_entries(tab)
* sizeof(st_table_entry));
-#ifndef RUBY
- if (tab->entries == NULL) {
- st_free_table(tab);
- return NULL;
- }
-#endif
#ifdef ST_DEBUG
memset(tab->entries, ST_INIT_VAL_BYTE,
get_allocated_entries(tab) * sizeof(st_table_entry));
@@ -714,7 +690,7 @@ st_free_table(st_table *tab)
free(tab);
}
-/* Return byte size of memory allocated for table TAB. */
+/* Return byte size of memory allocted for table TAB. */
size_t
st_memsize(const st_table *tab)
{
@@ -1322,30 +1298,13 @@ st_copy(st_table *old_tab)
st_table *new_tab;
new_tab = (st_table *) malloc(sizeof(st_table));
-#ifndef RUBY
- if (new_tab == NULL)
- return NULL;
-#endif
*new_tab = *old_tab;
if (old_tab->bins == NULL)
new_tab->bins = NULL;
- else {
+ else
new_tab->bins = (st_index_t *) malloc(bins_size(old_tab));
-#ifndef RUBY
- if (new_tab->bins == NULL) {
- free(new_tab);
- return NULL;
- }
-#endif
- }
new_tab->entries = (st_table_entry *) malloc(get_allocated_entries(old_tab)
* sizeof(st_table_entry));
-#ifndef RUBY
- if (new_tab->entries == NULL) {
- st_free_table(new_tab);
- return NULL;
- }
-#endif
MEMCPY(new_tab->entries, old_tab->entries, st_table_entry,
get_allocated_entries(old_tab));
if (old_tab->bins != NULL)
@@ -1486,6 +1445,7 @@ st_shift(st_table *tab, st_data_t *key, st_data_t *value)
}
}
st_assert(tab->num_entries == 0);
+ tab->entries_start = tab->entries_bound = 0;
if (value != 0) *value = 0;
return 0;
}
@@ -1585,7 +1545,7 @@ st_update(st_table *tab, st_data_t key,
different for ST_CHECK and when the current element is removed
during traversing. */
static inline int
-st_general_foreach(st_table *tab, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg,
+st_general_foreach(st_table *tab, int (*func)(ANYARGS), st_data_t arg,
int check_p)
{
st_index_t bin;
@@ -1609,15 +1569,6 @@ st_general_foreach(st_table *tab, st_foreach_check_callback_func *func, st_updat
rebuilds_num = tab->rebuilds_num;
hash = curr_entry_ptr->hash;
retval = (*func)(key, curr_entry_ptr->record, arg, 0);
-
- if (retval == ST_REPLACE && replace) {
- st_data_t value;
- value = curr_entry_ptr->record;
- retval = (*replace)(&key, &value, arg, TRUE);
- curr_entry_ptr->key = key;
- curr_entry_ptr->record = value;
- }
-
if (rebuilds_num != tab->rebuilds_num) {
retry:
entries = tab->entries;
@@ -1646,8 +1597,6 @@ st_general_foreach(st_table *tab, st_foreach_check_callback_func *func, st_updat
curr_entry_ptr = &entries[i];
}
switch (retval) {
- case ST_REPLACE:
- break;
case ST_CONTINUE:
break;
case ST_CHECK:
@@ -1696,36 +1645,17 @@ st_general_foreach(st_table *tab, st_foreach_check_callback_func *func, st_updat
}
int
-st_foreach_with_replace(st_table *tab, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
+st_foreach(st_table *tab, int (*func)(ANYARGS), st_data_t arg)
{
- return st_general_foreach(tab, func, replace, arg, TRUE);
-}
-
-struct functor {
- st_foreach_callback_func *func;
- st_data_t arg;
-};
-
-static int
-apply_functor(st_data_t k, st_data_t v, st_data_t d, int _)
-{
- const struct functor *f = (void *)d;
- return f->func(k, v, f->arg);
-}
-
-int
-st_foreach(st_table *tab, st_foreach_callback_func *func, st_data_t arg)
-{
- const struct functor f = { func, arg };
- return st_general_foreach(tab, apply_functor, NULL, (st_data_t)&f, FALSE);
+ return st_general_foreach(tab, func, arg, FALSE);
}
/* See comments for function st_delete_safe. */
int
-st_foreach_check(st_table *tab, st_foreach_check_callback_func *func, st_data_t arg,
+st_foreach_check(st_table *tab, int (*func)(ANYARGS), st_data_t arg,
st_data_t never ATTRIBUTE_UNUSED)
{
- return st_general_foreach(tab, func, NULL, arg, TRUE);
+ return st_general_foreach(tab, func, arg, TRUE);
}
/* Set up array KEYS by at most SIZE keys of head table TAB entries.
@@ -1814,7 +1744,7 @@ st_values_check(st_table *tab, st_data_t *values, st_index_t size,
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
- defined(__powerpc64__) || defined(__aarch64__) || \
+ defined(__powerpc64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# endif
@@ -1836,10 +1766,6 @@ st_values_check(st_table *tab, st_data_t *values, st_index_t size,
#define C1 BIG_CONSTANT(0x87c37b91,0x114253d5);
#define C2 BIG_CONSTANT(0x4cf5ad43,0x2745937f);
#endif
-NO_SANITIZE("unsigned-integer-overflow", static inline st_index_t murmur_step(st_index_t h, st_index_t k));
-NO_SANITIZE("unsigned-integer-overflow", static inline st_index_t murmur_finish(st_index_t h));
-NO_SANITIZE("unsigned-integer-overflow", extern st_index_t st_hash(const void *ptr, size_t len, st_index_t h));
-
static inline st_index_t
murmur_step(st_index_t h, st_index_t k)
{
@@ -1984,14 +1910,9 @@ st_hash(const void *ptr, size_t len, st_index_t h)
}
else
#endif
-#ifdef HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED
-#define aligned_data __builtin_assume_aligned(data, sizeof(st_index_t))
-#else
-#define aligned_data data
-#endif
{
do {
- h = murmur_step(h, *(st_index_t *)aligned_data);
+ h = murmur_step(h, *(st_index_t *)data);
data += sizeof(st_index_t);
len -= sizeof(st_index_t);
} while (len >= sizeof(st_index_t));
@@ -2007,7 +1928,7 @@ st_hash(const void *ptr, size_t len, st_index_t h)
case 6: t |= data_at(5) << 40;
case 5: t |= data_at(4) << 32;
case 4:
- t |= (st_index_t)*(uint32_t*)aligned_data;
+ t |= (st_index_t)*(uint32_t*)data;
goto skip_tail;
# define SKIP_TAIL 1
#endif
@@ -2032,7 +1953,6 @@ st_hash(const void *ptr, size_t len, st_index_t h)
h *= C2;
}
h ^= l;
-#undef aligned_data
return murmur_finish(h);
}
@@ -2043,7 +1963,6 @@ st_hash_uint32(st_index_t h, uint32_t i)
return murmur_step(h, i);
}
-NO_SANITIZE("unsigned-integer-overflow", extern st_index_t st_hash_uint(st_index_t h, st_index_t i));
st_index_t
st_hash_uint(st_index_t h, st_index_t i)
{
@@ -2066,7 +1985,7 @@ st_hash_end(st_index_t h)
#undef st_hash_start
st_index_t
-rb_st_hash_start(st_index_t h)
+st_hash_start(st_index_t h)
{
return h;
}
@@ -2081,18 +2000,18 @@ strhash(st_data_t arg)
int
st_locale_insensitive_strcasecmp(const char *s1, const char *s2)
{
- char c1, c2;
+ unsigned int c1, c2;
while (1) {
- c1 = *s1++;
- c2 = *s2++;
+ c1 = (unsigned char)*s1++;
+ c2 = (unsigned char)*s2++;
if (c1 == '\0' || c2 == '\0') {
if (c1 != '\0') return 1;
if (c2 != '\0') return -1;
return 0;
}
- if (('A' <= c1) && (c1 <= 'Z')) c1 += 'a' - 'A';
- if (('A' <= c2) && (c2 <= 'Z')) c2 += 'a' - 'A';
+ if ((unsigned int)(c1 - 'A') <= ('Z' - 'A')) c1 += 'a' - 'A';
+ if ((unsigned int)(c2 - 'A') <= ('Z' - 'A')) c2 += 'a' - 'A';
if (c1 != c2) {
if (c1 > c2)
return 1;
@@ -2105,19 +2024,18 @@ st_locale_insensitive_strcasecmp(const char *s1, const char *s2)
int
st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n)
{
- char c1, c2;
- size_t i;
+ unsigned int c1, c2;
- for (i = 0; i < n; i++) {
- c1 = *s1++;
- c2 = *s2++;
+ while (n--) {
+ c1 = (unsigned char)*s1++;
+ c2 = (unsigned char)*s2++;
if (c1 == '\0' || c2 == '\0') {
if (c1 != '\0') return 1;
if (c2 != '\0') return -1;
return 0;
}
- if (('A' <= c1) && (c1 <= 'Z')) c1 += 'a' - 'A';
- if (('A' <= c2) && (c2 <= 'Z')) c2 += 'a' - 'A';
+ if ((unsigned int)(c1 - 'A') <= ('Z' - 'A')) c1 += 'a' - 'A';
+ if ((unsigned int)(c2 - 'A') <= ('Z' - 'A')) c2 += 'a' - 'A';
if (c1 != c2) {
if (c1 > c2)
return 1;
@@ -2128,23 +2046,7 @@ st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n)
return 0;
}
-static int
-st_strcmp(st_data_t lhs, st_data_t rhs)
-{
- const char *s1 = (char *)lhs;
- const char *s2 = (char *)rhs;
- return strcmp(s1, s2);
-}
-
-static int
-st_locale_insensitive_strcasecmp_i(st_data_t lhs, st_data_t rhs)
-{
- const char *s1 = (char *)lhs;
- const char *s2 = (char *)rhs;
- return st_locale_insensitive_strcasecmp(s1, s2);
-}
-
-NO_SANITIZE("unsigned-integer-overflow", PUREFUNC(static st_index_t strcasehash(st_data_t)));
+PUREFUNC(static st_index_t strcasehash(st_data_t));
static st_index_t
strcasehash(st_data_t arg)
{
@@ -2270,13 +2172,13 @@ st_rehash_indexed(st_table *tab)
ind = hash_bin(p->hash, tab);
for(;;) {
st_index_t bin = get_bin(bins, size_ind, ind);
+ st_table_entry *q = &tab->entries[bin - ENTRY_BASE];
if (EMPTY_OR_DELETED_BIN_P(bin)) {
/* ok, new room */
set_bin(bins, size_ind, ind, i + ENTRY_BASE);
break;
}
else {
- st_table_entry *q = &tab->entries[bin - ENTRY_BASE];
DO_PTR_EQUAL_CHECK(tab, q, p->hash, p->key, eq_p, rebuilt_p);
if (EXPECT(rebuilt_p, 0))
return TRUE;
@@ -2324,8 +2226,8 @@ st_rehash(st_table *tab)
static st_data_t
st_stringify(VALUE key)
{
- return (rb_obj_class(key) == rb_cString && !RB_OBJ_FROZEN(key)) ?
- rb_hash_key_str(key) : key;
+ return (rb_obj_class(key) == rb_cString) ?
+ rb_str_new_frozen(key) : key;
}
static void
@@ -2373,16 +2275,24 @@ st_insert_generic(st_table *tab, long argc, const VALUE *argv, VALUE hash)
st_rehash(tab);
}
-/* Mimics ruby's { foo => bar } syntax. This function is subpart
- of rb_hash_bulk_insert. */
+/* Mimics ruby's { foo => bar } syntax. This function is placed here
+ because it touches table internals and write barriers at once. */
void
-rb_hash_bulk_insert_into_st_table(long argc, const VALUE *argv, VALUE hash)
+rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
{
- st_index_t n, size = argc / 2;
- st_table *tab = RHASH_ST_TABLE(hash);
+ st_index_t n;
+ st_table *tab = RHASH(hash)->ntbl;
- tab = RHASH_TBL_RAW(hash);
- n = tab->entries_bound + size;
+ st_assert(argc % 2 == 0);
+ if (! argc)
+ return;
+ if (! tab) {
+ VALUE tmp = rb_hash_new_with_size(argc / 2);
+ RBASIC_CLEAR_CLASS(tmp);
+ RHASH(hash)->ntbl = tab = RHASH(tmp)->ntbl;
+ RHASH(tmp)->ntbl = NULL;
+ }
+ n = tab->entries_bound + argc / 2;
st_expand_table(tab, n);
if (UNLIKELY(tab->num_entries))
st_insert_generic(tab, argc, argv, hash);
diff --git a/strftime.c b/strftime.c
index 446be7d338..ebb587c379 100644
--- a/strftime.c
+++ b/strftime.c
@@ -226,8 +226,8 @@ format_value(VALUE val, int base)
*/
static VALUE
rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
- rb_encoding *enc, VALUE time, const struct vtm *vtm,
- VALUE timev, struct timespec *ts, int gmt, size_t maxsize)
+ rb_encoding *enc, const struct vtm *vtm, VALUE timev,
+ struct timespec *ts, int gmt, size_t maxsize)
{
size_t len = RSTRING_LEN(ftime);
char *s = RSTRING_PTR(ftime);
@@ -246,7 +246,6 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
#ifdef MAILHEADER_EXT
int sign;
#endif
- VALUE zone = Qnil;
/* various tables, useful in North America */
static const char days_l[][10] = {
@@ -318,7 +317,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
len = s - start; \
rb_str_set_len(ftime, len); \
if (!rb_strftime_with_timespec(ftime, (fmt), rb_strlen_lit(fmt), \
- enc, time, vtm, timev, ts, gmt, maxsize)) \
+ enc, vtm, timev, ts, gmt, maxsize)) \
return 0; \
s = RSTRING_PTR(ftime); \
i = RSTRING_LEN(ftime) - len; \
@@ -326,9 +325,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
s += len; \
if (i > 0) case_conv(s, i, flags); \
if (precision > i) {\
- s += i; \
NEEDS(precision); \
- s -= i; \
memmove(s + precision - i, s, i);\
memset(s, padding ? padding : ' ', precision - i); \
s += precision; \
@@ -622,14 +619,11 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
tp = "UTC";
break;
}
- if (NIL_P(vtm->zone)) {
+ if (vtm->zone == NULL) {
i = 0;
}
else {
- if (NIL_P(zone)) {
- zone = rb_time_zone_abbreviation(vtm->zone, time);
- }
- tp = RSTRING_PTR(zone);
+ tp = vtm->zone;
if (enc) {
for (i = 0; i < TBUFSIZE && tp[i]; i++) {
if ((unsigned char)tp[i] > 0x7F) {
@@ -828,7 +822,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
args[0] = INT2FIX(precision);
args[1] = subsec;
result = rb_str_format(2, args,
- rb_fstring_lit("%0*d"));
+ rb_fstring_cstr("%0*d"));
(void)strlcpy(s, StringValueCStr(result), endp-s);
s += precision;
}
@@ -918,34 +912,34 @@ strftime_size_limit(size_t format_len)
}
VALUE
-rb_strftime(const char *format, size_t format_len, rb_encoding *enc,
- VALUE time, const struct vtm *vtm, VALUE timev, int gmt)
+rb_strftime(const char *format, size_t format_len,
+ rb_encoding *enc, const struct vtm *vtm, VALUE timev, int gmt)
{
VALUE result = rb_enc_str_new(0, 0, enc);
return rb_strftime_with_timespec(result, format, format_len, enc,
- time, vtm, timev, NULL, gmt,
+ vtm, timev, NULL, gmt,
strftime_size_limit(format_len));
}
VALUE
-rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc,
- VALUE time, const struct vtm *vtm, struct timespec *ts, int gmt)
+rb_strftime_timespec(const char *format, size_t format_len,
+ rb_encoding *enc, const struct vtm *vtm, struct timespec *ts, int gmt)
{
VALUE result = rb_enc_str_new(0, 0, enc);
return rb_strftime_with_timespec(result, format, format_len, enc,
- time, vtm, Qnil, ts, gmt,
+ vtm, Qnil, ts, gmt,
strftime_size_limit(format_len));
}
#if 0
VALUE
-rb_strftime_limit(const char *format, size_t format_len, rb_encoding *enc,
- VALUE time, const struct vtm *vtm, struct timespec *ts,
+rb_strftime_limit(const char *format, size_t format_len,
+ rb_encoding *enc, const struct vtm *vtm, struct timespec *ts,
int gmt, size_t maxsize)
{
VALUE result = rb_enc_str_new(0, 0, enc);
return rb_strftime_with_timespec(result, format, format_len, enc,
- time, vtm, Qnil, ts, gmt, maxsize);
+ vtm, Qnil, ts, gmt, maxsize);
}
#endif
diff --git a/string.c b/string.c
index c6dec224f1..f0d1a286a5 100644
--- a/string.c
+++ b/string.c
@@ -11,9 +11,8 @@
**********************************************************************/
-#include "ruby/encoding.h"
-#include "ruby/re.h"
#include "internal.h"
+#include "ruby/re.h"
#include "encindex.h"
#include "probes.h"
#include "gc.h"
@@ -25,7 +24,6 @@
#define BEG(no) (regs->beg[(no)])
#define END(no) (regs->end[(no)])
-#include <errno.h>
#include <math.h>
#include <ctype.h>
@@ -42,6 +40,8 @@
# define HAVE_CRYPT_R 1
#endif
+#define STRING_ENUMERATORS_WANTARRAY 0 /* next major */
+
#undef rb_str_new
#undef rb_usascii_str_new
#undef rb_utf8_str_new
@@ -60,6 +60,7 @@
#undef rb_str_cat2
#undef rb_str_cat_cstr
#undef rb_fstring_cstr
+#undef rb_fstring_enc_cstr
static VALUE rb_str_clear(VALUE str);
@@ -71,10 +72,7 @@ VALUE rb_cSymbol;
* 1: RSTRING_NOEMBED
* 2: STR_SHARED (== ELTS_SHARED)
* 2-6: RSTRING_EMBED_LEN (5 bits == 32)
- * 5: STR_SHARED_ROOT (RSTRING_NOEMBED==1 && STR_SHARED == 0, there may be
- * other strings that rely on this string's buffer)
- * 6: STR_BORROWED (when RSTRING_NOEMBED==1 && klass==0, unsafe to recycle
- * early, specific to rb_str_tmp_frozen_{acquire,release})
+ * 6: STR_IS_SHARED_M (shared, when RSTRING_NOEMBED==1 && klass==0)
* 7: STR_TMPLOCK
* 8-9: ENC_CODERANGE (2 bits)
* 10-16: ENCODING (7 bits == 128)
@@ -84,8 +82,7 @@ VALUE rb_cSymbol;
*/
#define RUBY_MAX_CHAR_LEN 16
-#define STR_SHARED_ROOT FL_USER5
-#define STR_BORROWED FL_USER6
+#define STR_IS_SHARED_M FL_USER6
#define STR_TMPLOCK FL_USER7
#define STR_NOFREE FL_USER18
#define STR_FAKESTR FL_USER19
@@ -148,8 +145,7 @@ VALUE rb_cSymbol;
}\
else {\
assert(!FL_TEST((str), STR_SHARED)); \
- SIZED_REALLOC_N(RSTRING(str)->as.heap.ptr, char, \
- (size_t)(capacity) + (termlen), STR_HEAP_SIZE(str)); \
+ REALLOC_N(RSTRING(str)->as.heap.ptr, char, (size_t)(capacity) + (termlen));\
RSTRING(str)->as.heap.aux.capa = (capacity);\
}\
} while (0)
@@ -158,9 +154,8 @@ VALUE rb_cSymbol;
if (!FL_TEST(str, STR_FAKESTR)) { \
RB_OBJ_WRITE((str), &RSTRING(str)->as.heap.aux.shared, (shared_str)); \
FL_SET((str), STR_SHARED); \
- FL_SET((shared_str), STR_SHARED_ROOT); \
if (RBASIC_CLASS((shared_str)) == 0) /* for CoW-friendliness */ \
- FL_SET_RAW((shared_str), STR_BORROWED); \
+ FL_SET_RAW((shared_str), STR_IS_SHARED_M); \
} \
} while (0)
@@ -262,7 +257,7 @@ const struct st_hash_type rb_fstring_hash_type = {
rb_str_hash,
};
-#define BARE_STRING_P(str) (!FL_ANY_RAW(str, FL_EXIVAR) && RBASIC_CLASS(str) == rb_cString)
+#define BARE_STRING_P(str) (!FL_ANY_RAW(str, FL_TAINT|FL_EXIVAR) && RBASIC_CLASS(str) == rb_cString)
static int
fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
@@ -320,20 +315,11 @@ rb_fstring(VALUE str)
return str;
bare = BARE_STRING_P(str);
- if (!bare) {
- if (STR_EMBED_P(str)) {
- OBJ_FREEZE_RAW(str);
- return str;
- }
- if (FL_TEST_RAW(str, STR_NOEMBED|STR_SHARED_ROOT|STR_SHARED) == (STR_NOEMBED|STR_SHARED_ROOT)) {
- assert(OBJ_FROZEN(str));
- return str;
- }
+ if (STR_EMBED_P(str) && !bare) {
+ OBJ_FREEZE_RAW(str);
+ return str;
}
- if (!OBJ_FROZEN(str))
- rb_str_resize(str, RSTRING_LEN(str));
-
fstr = register_fstring(str);
if (!bare) {
@@ -359,6 +345,7 @@ register_fstring(VALUE str)
assert(OBJ_FROZEN(ret));
assert(!FL_TEST_RAW(ret, STR_FAKESTR));
assert(!FL_TEST_RAW(ret, FL_EXIVAR));
+ assert(!FL_TEST_RAW(ret, FL_TAINT));
assert(RBASIC_CLASS(ret) == rb_cString);
return ret;
}
@@ -378,21 +365,13 @@ setup_fake_str(struct RString *fake_str, const char *name, long len, int encidx)
return (VALUE)fake_str;
}
-/*
- * set up a fake string which refers a static string literal.
- */
VALUE
rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc)
{
return setup_fake_str(fake_str, name, len, rb_enc_to_index(enc));
}
-/*
- * rb_fstring_new and rb_fstring_cstr family create or lookup a frozen
- * shared string which refers a static string literal. `ptr` must
- * point a constant string.
- */
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_fstring_new(const char *ptr, long len)
{
struct RString fake_str;
@@ -412,6 +391,12 @@ rb_fstring_cstr(const char *ptr)
return rb_fstring_new(ptr, strlen(ptr));
}
+VALUE
+rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc)
+{
+ return rb_fstring_enc_new(ptr, strlen(ptr), enc);
+}
+
static int
fstring_set_class_i(st_data_t key, st_data_t val, st_data_t arg)
{
@@ -455,23 +440,10 @@ static inline const char *
search_nonascii(const char *p, const char *e)
{
const uintptr_t *s, *t;
-
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-# if SIZEOF_UINTPTR_T == 8
-# define NONASCII_MASK UINT64_C(0x8080808080808080)
-# elif SIZEOF_UINTPTR_T == 4
-# define NONASCII_MASK UINT32_C(0x80808080)
-# else
-# error "don't know what to do."
-# endif
-#else
-# if SIZEOF_UINTPTR_T == 8
-# define NONASCII_MASK ((uintptr_t)0x80808080UL << 32 | (uintptr_t)0x80808080UL)
-# elif SIZEOF_UINTPTR_T == 4
-# define NONASCII_MASK 0x80808080UL /* or...? */
-# else
-# error "don't know what to do."
-# endif
+#if SIZEOF_VOIDP == 8
+# define NONASCII_MASK 0x8080808080808080ULL
+#elif SIZEOF_VOIDP == 4
+# define NONASCII_MASK 0x80808080UL
#endif
if (UNALIGNED_WORD_ACCESS || e - p >= SIZEOF_VOIDP) {
@@ -494,15 +466,8 @@ search_nonascii(const char *p, const char *e)
}
}
#endif
-#if defined(HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED) &&! UNALIGNED_WORD_ACCESS
-#define aligned_ptr(value) \
- __builtin_assume_aligned((value), sizeof(uintptr_t))
-#else
-#define aligned_ptr(value) (uintptr_t *)(value)
-#endif
- s = aligned_ptr(p);
- t = (uintptr_t *)(e - (SIZEOF_VOIDP-1));
-#undef aligned_ptr
+ s = (const uintptr_t *)p;
+ t = (const uintptr_t *)(e - (SIZEOF_VOIDP-1));
for (;s < t; s++) {
if (*s & NONASCII_MASK) {
#ifdef WORDS_BIGENDIAN
@@ -808,11 +773,6 @@ VALUE
rb_str_new_cstr(const char *ptr)
{
must_not_null(ptr);
- /* rb_str_new_cstr() can take pointer from non-malloc-generated
- * memory regions, and that cannot be detected by the MSAN. Just
- * trust the programmer that the argument passed here is a sane C
- * string. */
- __msan_unpoison_string(ptr);
return rb_str_new(ptr, strlen(ptr));
}
@@ -895,15 +855,28 @@ rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc)
VALUE
rb_tainted_str_new(const char *ptr, long len)
{
- rb_warning("rb_tainted_str_new is deprecated and will be removed in Ruby 3.2.");
- return rb_str_new(ptr, len);
+ VALUE str = rb_str_new(ptr, len);
+
+ OBJ_TAINT(str);
+ return str;
+}
+
+static VALUE
+rb_tainted_str_new_with_enc(const char *ptr, long len, rb_encoding *enc)
+{
+ VALUE str = rb_enc_str_new(ptr, len, enc);
+
+ OBJ_TAINT(str);
+ return str;
}
VALUE
rb_tainted_str_new_cstr(const char *ptr)
{
- rb_warning("rb_tainted_str_new_cstr is deprecated and will be removed in Ruby 3.2.");
- return rb_str_new_cstr(ptr);
+ VALUE str = rb_str_new_cstr(ptr);
+
+ OBJ_TAINT(str);
+ return str;
}
static VALUE str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
@@ -936,6 +909,7 @@ rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags,
/* some error, return original */
return str;
}
+ OBJ_INFECT(newstr, str);
return newstr;
}
@@ -1040,28 +1014,28 @@ rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
const int eidx = rb_enc_to_index(eenc);
if (!ptr) {
- return rb_enc_str_new(ptr, len, eenc);
+ return rb_tainted_str_new_with_enc(ptr, len, eenc);
}
/* ASCII-8BIT case, no conversion */
if ((eidx == rb_ascii8bit_encindex()) ||
(eidx == rb_usascii_encindex() && search_nonascii(ptr, ptr + len))) {
- return rb_str_new(ptr, len);
+ return rb_tainted_str_new(ptr, len);
}
/* no default_internal or same encoding, no conversion */
ienc = rb_default_internal_encoding();
if (!ienc || eenc == ienc) {
- return rb_enc_str_new(ptr, len, eenc);
+ return rb_tainted_str_new_with_enc(ptr, len, eenc);
}
/* ASCII compatible, and ASCII only string, no conversion in
* default_internal */
if ((eidx == rb_ascii8bit_encindex()) ||
(eidx == rb_usascii_encindex()) ||
(rb_enc_asciicompat(eenc) && !search_nonascii(ptr, ptr + len))) {
- return rb_enc_str_new(ptr, len, ienc);
+ return rb_tainted_str_new_with_enc(ptr, len, ienc);
}
/* convert from the given encoding to default_internal */
- str = rb_enc_str_new(NULL, 0, ienc);
+ str = rb_tainted_str_new_with_enc(NULL, 0, ienc);
/* when the conversion failed for some reason, just ignore the
* default_internal and result in the given encoding as-is. */
if (NIL_P(rb_str_cat_conv_enc_opts(str, 0, ptr, len, eenc, 0, Qnil))) {
@@ -1162,19 +1136,10 @@ str_replace_shared_without_enc(VALUE str2, VALUE str)
root = rb_str_new_frozen(str);
RSTRING_GETMEM(root, ptr, len);
}
- if (!STR_EMBED_P(str2) && !FL_TEST_RAW(str2, STR_SHARED|STR_NOFREE)) {
- if (FL_TEST_RAW(str2, STR_SHARED_ROOT)) {
- rb_fatal("about to free a possible shared root");
- }
- char *ptr2 = STR_HEAP_PTR(str2);
- if (ptr2 != ptr) {
- ruby_sized_xfree(ptr2, STR_HEAP_SIZE(str2));
- }
- }
FL_SET(str2, STR_NOEMBED);
RSTRING(str2)->as.heap.len = len;
RSTRING(str2)->as.heap.ptr = ptr;
- STR_SET_SHARED(str2, root);
+ STR_SET_SHARED(str2, root);
}
return str2;
}
@@ -1196,21 +1161,35 @@ str_new_shared(VALUE klass, VALUE str)
VALUE
rb_str_new_shared(VALUE str)
{
- return str_new_shared(rb_obj_class(str), str);
+ VALUE str2 = str_new_shared(rb_obj_class(str), str);
+
+ OBJ_INFECT(str2, str);
+ return str2;
}
VALUE
rb_str_new_frozen(VALUE orig)
{
+ VALUE str;
+
if (OBJ_FROZEN(orig)) return orig;
- return str_new_frozen(rb_obj_class(orig), orig);
+
+ str = str_new_frozen(rb_obj_class(orig), orig);
+ OBJ_INFECT(str, orig);
+ return str;
}
VALUE
rb_str_tmp_frozen_acquire(VALUE orig)
{
+ VALUE tmp;
+
if (OBJ_FROZEN_RAW(orig)) return orig;
- return str_new_frozen(0, orig);
+
+ tmp = str_new_frozen(0, orig);
+ OBJ_INFECT(tmp, orig);
+
+ return tmp;
}
void
@@ -1227,7 +1206,7 @@ rb_str_tmp_frozen_release(VALUE orig, VALUE tmp)
!FL_TEST_RAW(orig, STR_TMPLOCK|RUBY_FL_FREEZE)) {
VALUE shared = RSTRING(orig)->as.heap.aux.shared;
- if (shared == tmp && !FL_TEST_RAW(tmp, STR_BORROWED)) {
+ if (shared == tmp && !FL_TEST_RAW(tmp, STR_IS_SHARED_M)) {
FL_UNSET_RAW(orig, STR_SHARED);
assert(RSTRING(orig)->as.heap.ptr == RSTRING(tmp)->as.heap.ptr);
assert(RSTRING(orig)->as.heap.len == RSTRING(tmp)->as.heap.len);
@@ -1257,6 +1236,7 @@ str_new_frozen(VALUE klass, VALUE orig)
if ((ofs > 0) || (rest > 0) ||
(klass != RBASIC(shared)->klass) ||
+ ((RBASIC(shared)->flags ^ RBASIC(orig)->flags) & FL_TAINT) ||
ENCODING_GET(shared) != ENCODING_GET(orig)) {
str = str_new_shared(klass, shared);
RSTRING(str)->as.heap.ptr += ofs;
@@ -1264,7 +1244,7 @@ str_new_frozen(VALUE klass, VALUE orig)
}
else {
if (RBASIC_CLASS(shared) == 0)
- FL_SET_RAW(shared, STR_BORROWED);
+ FL_SET_RAW(shared, STR_IS_SHARED_M);
return shared;
}
}
@@ -1285,7 +1265,7 @@ str_new_frozen(VALUE klass, VALUE orig)
RBASIC(orig)->flags &= ~STR_NOFREE;
STR_SET_SHARED(orig, str);
if (klass == 0)
- FL_UNSET_RAW(str, STR_BORROWED);
+ FL_UNSET_RAW(str, STR_IS_SHARED_M);
}
}
@@ -1305,10 +1285,11 @@ str_new_empty(VALUE str)
{
VALUE v = rb_str_new_with_class(str, 0, 0);
rb_enc_copy(v, str);
+ OBJ_INFECT(v, str);
return v;
}
-#define STR_BUF_MIN_SIZE 63
+#define STR_BUF_MIN_SIZE 127
STATIC_ASSERT(STR_BUF_MIN_SIZE, STR_BUF_MIN_SIZE > RSTRING_EMBED_LEN_MAX);
VALUE
@@ -1404,6 +1385,7 @@ str_shared_replace(VALUE str, VALUE str2)
enc = STR_ENC_GET(str2);
cr = ENC_CODERANGE(str2);
str_discard(str);
+ OBJ_INFECT(str, str2);
termlen = rb_enc_mbminlen(enc);
if (STR_EMBEDDABLE_P(RSTRING_LEN(str2), termlen)) {
@@ -1436,6 +1418,8 @@ str_shared_replace(VALUE str, VALUE str2)
}
}
+VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
+
VALUE
rb_obj_as_string(VALUE obj)
{
@@ -1448,11 +1432,14 @@ rb_obj_as_string(VALUE obj)
return rb_obj_as_string_result(str, obj);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_obj_as_string_result(VALUE str, VALUE obj)
{
if (!RB_TYPE_P(str, T_STRING))
return rb_any_to_s(obj);
+ if (!FL_TEST_RAW(str, RSTRING_FSTR) && FL_ABLE(obj))
+ /* fstring must not be tainted, at least */
+ OBJ_INFECT_RAW(str, obj);
return str;
}
@@ -1475,6 +1462,7 @@ str_replace(VALUE str, VALUE str2)
str_replace_shared(str, str2);
}
+ OBJ_INFECT(str, str2);
return str;
}
@@ -1485,7 +1473,7 @@ str_duplicate(VALUE klass, VALUE str)
const VALUE flag_mask =
RSTRING_NOEMBED | RSTRING_EMBED_LEN_MASK |
ENC_CODERANGE_MASK | ENCODING_MASK |
- FL_FREEZE
+ FL_TAINT | FL_FREEZE
;
VALUE flags = FL_TEST_RAW(str, flag_mask);
VALUE dup = str_alloc(klass);
@@ -1497,6 +1485,7 @@ str_duplicate(VALUE klass, VALUE str)
}
else if (UNLIKELY(!(flags & FL_FREEZE))) {
str = str_new_frozen(klass, str);
+ FL_SET_RAW(str, flags & FL_TAINT);
flags = FL_TEST_RAW(str, flag_mask);
}
if (flags & STR_NOEMBED) {
@@ -1594,12 +1583,11 @@ rb_str_init(int argc, VALUE *argv, VALUE str)
const size_t osize = RSTRING(str)->as.heap.len + TERM_LEN(str);
char *new_ptr = ALLOC_N(char, (size_t)capa + termlen);
memcpy(new_ptr, old_ptr, osize < size ? osize : size);
- FL_UNSET_RAW(str, STR_SHARED|STR_NOFREE);
+ FL_UNSET_RAW(str, STR_SHARED);
RSTRING(str)->as.heap.ptr = new_ptr;
}
else if (STR_HEAP_SIZE(str) != (size_t)capa + termlen) {
- SIZED_REALLOC_N(RSTRING(str)->as.heap.ptr, char,
- (size_t)capa + termlen, STR_HEAP_SIZE(str));
+ REALLOC_N(RSTRING(str)->as.heap.ptr, char, (size_t)capa + termlen);
}
RSTRING(str)->as.heap.len = len;
TERM_FILL(&RSTRING(str)->as.heap.ptr[len], termlen);
@@ -1884,7 +1872,7 @@ rb_str_empty(VALUE str)
* call-seq:
* str + other_str -> new_str
*
- * Concatenation---Returns a new String containing
+ * Concatenation---Returns a new <code>String</code> containing
* <i>other_str</i> concatenated to <i>str</i>.
*
* "Hello from " + self.to_s #=> "Hello from main"
@@ -1913,6 +1901,7 @@ rb_str_plus(VALUE str1, VALUE str2)
memcpy(ptr3+len1, ptr2, len2);
TERM_FILL(&ptr3[len1+len2], termlen);
+ FL_SET_RAW(str3, OBJ_TAINTED_RAW(str1) | OBJ_TAINTED_RAW(str2));
ENCODING_CODERANGE_SET(str3, rb_enc_to_index(enc),
ENC_CODERANGE_AND(ENC_CODERANGE(str1), ENC_CODERANGE(str2)));
RB_GC_GUARD(str1);
@@ -1920,37 +1909,6 @@ rb_str_plus(VALUE str1, VALUE str2)
return str3;
}
-/* A variant of rb_str_plus that does not raise but return Qundef instead. */
-MJIT_FUNC_EXPORTED VALUE
-rb_str_opt_plus(VALUE str1, VALUE str2)
-{
- assert(RBASIC_CLASS(str1) == rb_cString);
- assert(RBASIC_CLASS(str2) == rb_cString);
- long len1, len2;
- MAYBE_UNUSED(char) *ptr1, *ptr2;
- RSTRING_GETMEM(str1, ptr1, len1);
- RSTRING_GETMEM(str2, ptr2, len2);
- int enc1 = rb_enc_get_index(str1);
- int enc2 = rb_enc_get_index(str2);
-
- if (enc1 < 0) {
- return Qundef;
- }
- else if (enc2 < 0) {
- return Qundef;
- }
- else if (enc1 != enc2) {
- return Qundef;
- }
- else if (len1 > LONG_MAX - len2) {
- return Qundef;
- }
- else {
- return rb_str_plus(str1, str2);
- }
-
-}
-
/*
* call-seq:
* str * integer -> new_str
@@ -1976,6 +1934,7 @@ rb_str_times(VALUE str, VALUE times)
if (times == INT2FIX(0)) {
str2 = str_alloc(rb_obj_class(str));
rb_enc_copy(str2, str);
+ OBJ_INFECT(str2, str);
return str2;
}
len = NUM2LONG(times);
@@ -1991,6 +1950,7 @@ rb_str_times(VALUE str, VALUE times)
}
STR_SET_LEN(str2, len);
rb_enc_copy(str2, str);
+ OBJ_INFECT(str2, str);
return str2;
}
if (len && LONG_MAX/len < RSTRING_LEN(str)) {
@@ -2012,6 +1972,7 @@ rb_str_times(VALUE str, VALUE times)
}
STR_SET_LEN(str2, len);
TERM_FILL(&ptr2[len], termlen);
+ OBJ_INFECT(str2, str);
rb_enc_cr_str_copy_for_substr(str2, str);
return str2;
@@ -2021,14 +1982,14 @@ rb_str_times(VALUE str, VALUE times)
* call-seq:
* str % arg -> new_str
*
- * Format---Uses <i>str</i> as a format specification, and returns
- * the result of applying it to <i>arg</i>. If the format
- * specification contains more than one substitution, then <i>arg</i>
- * must be an Array or Hash containing the values to be
- * substituted. See Kernel#sprintf for details of the format string.
+ * Format---Uses <i>str</i> as a format specification, and returns the result
+ * of applying it to <i>arg</i>. If the format specification contains more than
+ * one substitution, then <i>arg</i> must be an <code>Array</code> or <code>Hash</code>
+ * containing the values to be substituted. See <code>Kernel::sprintf</code> for
+ * details of the format string.
*
* "%05d" % 123 #=> "00123"
- * "%-5s: %016x" % [ "ID", self.object_id ] #=> "ID : 00002b054ec93168"
+ * "%-5s: %08x" % [ "ID", self.object_id ] #=> "ID : 200e14d6"
* "foo = %{foo}" % { :foo => 'bar' } #=> "foo = bar"
*/
@@ -2038,7 +1999,9 @@ rb_str_format_m(VALUE str, VALUE arg)
VALUE tmp = rb_check_array_type(arg);
if (!NIL_P(tmp)) {
- return rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
+ VALUE rv = rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
+ RB_GC_GUARD(tmp);
+ return rv;
}
return rb_str_format(1, &arg, str);
}
@@ -2127,7 +2090,7 @@ rb_str_modify_expand(VALUE str, long expand)
if (expand < 0) {
rb_raise(rb_eArgError, "negative expanding string size");
}
- if (expand >= LONG_MAX - len) {
+ if (expand > LONG_MAX - len) {
rb_raise(rb_eArgError, "string size too big");
}
@@ -2489,6 +2452,7 @@ rb_str_subseq(VALUE str, long beg, long len)
}
rb_enc_cr_str_copy_for_substr(str2, str);
+ OBJ_INFECT(str2, str);
return str2;
}
@@ -2605,6 +2569,7 @@ str_substr(VALUE str, long beg, long len, int empty)
else {
if (!len && !empty) return Qnil;
str2 = rb_str_new_with_class(str, p, len);
+ OBJ_INFECT(str2, str);
RB_GC_GUARD(str);
}
rb_enc_cr_str_copy_for_substr(str2, str);
@@ -2644,18 +2609,20 @@ str_uplus(VALUE str)
* call-seq:
* -str -> str (frozen)
*
- * Returns a frozen, possibly pre-existing copy of the string.
+ * If the string is frozen, then return the string itself.
*
- * The string will be deduplicated as long as it does not have
- * any instance variables set on it.
+ * If the string is not frozen, return a frozen, possibly pre-existing
+ * copy of it.
*/
static VALUE
str_uminus(VALUE str)
{
- if (!BARE_STRING_P(str) && !rb_obj_frozen_p(str)) {
- str = rb_str_dup(str);
+ if (OBJ_FROZEN(str)) {
+ return str;
+ }
+ else {
+ return rb_fstring(str);
}
- return rb_fstring(str);
}
RUBY_ALIAS_FUNCTION(rb_str_dup_frozen(VALUE str), rb_str_new_frozen, (str))
@@ -2747,8 +2714,7 @@ rb_str_resize(VALUE str, long len)
}
else if ((capa = RSTRING(str)->as.heap.aux.capa) < len ||
(capa - len) > (len < 1024 ? len : 1024)) {
- SIZED_REALLOC_N(RSTRING(str)->as.heap.ptr, char,
- (size_t)len + termlen, STR_HEAP_SIZE(str));
+ REALLOC_N(RSTRING(str)->as.heap.ptr, char, (size_t)len + termlen);
RSTRING(str)->as.heap.aux.capa = len;
}
else if (len == slen) return str;
@@ -2956,6 +2922,7 @@ rb_str_buf_append(VALUE str, VALUE str2)
rb_enc_cr_str_buf_cat(str, RSTRING_PTR(str2), RSTRING_LEN(str2),
ENCODING_GET(str2), str2_cr, &str2_cr);
+ OBJ_INFECT(str, str2);
ENC_CODERANGE_SET(str2, str2_cr);
return str;
@@ -2970,7 +2937,7 @@ rb_str_append(VALUE str, VALUE str2)
#define MIN_PRE_ALLOC_SIZE 48
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_str_concat_literals(size_t num, const VALUE *strary)
{
VALUE str;
@@ -2997,6 +2964,7 @@ rb_str_concat_literals(size_t num, const VALUE *strary)
rb_enc_cr_str_buf_cat(str, RSTRING_PTR(v), RSTRING_LEN(v),
encidx, ENC_CODERANGE(v), NULL);
+ OBJ_INFECT_RAW(str, v);
if (encidx != ENCINDEX_US_ASCII) {
if (ENCODING_GET_INLINED(str) == ENCINDEX_US_ASCII)
rb_enc_set_index(str, encidx);
@@ -3007,11 +2975,11 @@ rb_str_concat_literals(size_t num, const VALUE *strary)
/*
* call-seq:
- * str.concat(obj1, obj2, ...) -> str
+ * str.concat(obj1, obj2,...) -> str
*
* Concatenates the given object(s) to <i>str</i>. If an object is an
- * Integer, it is considered a codepoint and converted to a character
- * before concatenation.
+ * <code>Integer</code>, it is considered a codepoint and converted
+ * to a character before concatenation.
*
* +concat+ can take multiple arguments, and all the arguments are
* concatenated in order.
@@ -3052,8 +3020,8 @@ rb_str_concat_multi(int argc, VALUE *argv, VALUE str)
* str << integer -> str
*
* Appends the given object to <i>str</i>. If the object is an
- * Integer, it is considered a codepoint and converted to a character
- * before being appended.
+ * <code>Integer</code>, it is considered a codepoint and converted
+ * to a character before being appended.
*
* a = "hello "
* a << "world" #=> "hello world"
@@ -3127,7 +3095,7 @@ rb_str_concat(VALUE str1, VALUE str2)
/*
* call-seq:
- * str.prepend(other_str1, other_str2, ...) -> str
+ * str.prepend(other_str1, other_str2,...) -> str
*
* Prepend---Prepend the given strings to <i>str</i>.
*
@@ -3185,7 +3153,7 @@ rb_str_hash_cmp(VALUE str1, VALUE str2)
* call-seq:
* str.hash -> integer
*
- * Returns a hash based on the string's length, content and encoding.
+ * Return a hash based on the string's length, content and encoding.
*
* See also Object#hash.
*/
@@ -3250,6 +3218,22 @@ rb_str_cmp(VALUE str1, VALUE str2)
return -1;
}
+/* expect tail call optimization */
+static VALUE
+str_eql(const VALUE str1, const VALUE str2)
+{
+ const long len = RSTRING_LEN(str1);
+ const char *ptr1, *ptr2;
+
+ if (len != RSTRING_LEN(str2)) return Qfalse;
+ if (!rb_str_comparable(str1, str2)) return Qfalse;
+ if ((ptr1 = RSTRING_PTR(str1)) == (ptr2 = RSTRING_PTR(str2)))
+ return Qtrue;
+ if (memcmp(ptr1, ptr2, len) == 0)
+ return Qtrue;
+ return Qfalse;
+}
+
/*
* call-seq:
* str == obj -> true or false
@@ -3273,7 +3257,7 @@ rb_str_equal(VALUE str1, VALUE str2)
}
return rb_equal(str2, str1);
}
- return rb_str_eql_internal(str1, str2);
+ return str_eql(str1, str2);
}
/*
@@ -3283,12 +3267,12 @@ rb_str_equal(VALUE str1, VALUE str2)
* Two strings are equal if they have the same length and content.
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_str_eql(VALUE str1, VALUE str2)
{
if (str1 == str2) return Qtrue;
if (!RB_TYPE_P(str2, T_STRING)) return Qfalse;
- return rb_str_eql_internal(str1, str2);
+ return str_eql(str1, str2);
}
/*
@@ -3335,7 +3319,7 @@ static VALUE str_casecmp_p(VALUE str1, VALUE str2);
* call-seq:
* str.casecmp(other_str) -> -1, 0, +1, or nil
*
- * Case-insensitive version of String#<=>.
+ * Case-insensitive version of <code>String#<=></code>.
* Currently, case-insensitivity only works on characters A-Z/a-z,
* not all of Unicode. This is different from String#casecmp?.
*
@@ -3378,8 +3362,8 @@ str_casecmp(VALUE str1, VALUE str2)
if (single_byte_optimizable(str1) && single_byte_optimizable(str2)) {
while (p1 < p1end && p2 < p2end) {
if (*p1 != *p2) {
- unsigned int c1 = TOLOWER(*p1 & 0xff);
- unsigned int c2 = TOLOWER(*p2 & 0xff);
+ unsigned int c1 = TOUPPER(*p1 & 0xff);
+ unsigned int c2 = TOUPPER(*p2 & 0xff);
if (c1 != c2)
return INT2FIX(c1 < c2 ? -1 : 1);
}
@@ -3393,8 +3377,8 @@ str_casecmp(VALUE str1, VALUE str2)
int l2, c2 = rb_enc_ascget(p2, p2end, &l2, enc);
if (0 <= c1 && 0 <= c2) {
- c1 = TOLOWER(c1);
- c2 = TOLOWER(c2);
+ c1 = TOUPPER(c1);
+ c2 = TOUPPER(c2);
if (c1 != c2)
return INT2FIX(c1 < c2 ? -1 : 1);
}
@@ -3770,11 +3754,11 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
* call-seq:
* str =~ obj -> integer or nil
*
- * Match---If <i>obj</i> is a Regexp, use it as a pattern to match
+ * Match---If <i>obj</i> is a <code>Regexp</code>, use it as a pattern to match
* against <i>str</i>,and returns the position the match starts, or
* <code>nil</code> if there is no match. Otherwise, invokes
* <i>obj.=~</i>, passing <i>str</i> as an argument. The default
- * <code>=~</code> in Object returns <code>nil</code>.
+ * <code>=~</code> in <code>Object</code> returns <code>nil</code>.
*
* Note: <code>str =~ regexp</code> is not the same as
* <code>regexp =~ str</code>. Strings captured from named capture groups
@@ -3810,7 +3794,7 @@ static VALUE get_pat(VALUE);
* str.match(pattern) -> matchdata or nil
* str.match(pattern, pos) -> matchdata or nil
*
- * Converts <i>pattern</i> to a Regexp (if it isn't already one),
+ * Converts <i>pattern</i> to a <code>Regexp</code> (if it isn't already one),
* then invokes its <code>match</code> method on <i>str</i>. If the second
* parameter is present, it specifies the position in the string to begin the
* search.
@@ -4092,6 +4076,7 @@ rb_str_succ(VALUE orig)
VALUE str;
str = rb_str_new_with_class(orig, RSTRING_PTR(orig), RSTRING_LEN(orig));
rb_enc_cr_str_copy_for_substr(str, orig);
+ OBJ_INFECT(str, orig);
return str_succ(str);
}
@@ -4100,7 +4085,7 @@ str_succ(VALUE str)
{
rb_encoding *enc;
char *sbeg, *s, *e, *last_alnum = 0;
- int found_alnum = 0;
+ int c = -1;
long l, slen;
char carry[ONIGENC_CODE_TO_MBC_MAXLEN] = "\1";
long carry_pos = 0, carry_len = 1;
@@ -4117,6 +4102,7 @@ str_succ(VALUE str)
if (neighbor == NEIGHBOR_NOT_CHAR && last_alnum) {
if (ISALPHA(*last_alnum) ? ISDIGIT(*s) :
ISDIGIT(*last_alnum) ? ISALPHA(*s) : 0) {
+ s = last_alnum;
break;
}
}
@@ -4133,11 +4119,11 @@ str_succ(VALUE str)
last_alnum = s;
break;
}
- found_alnum = 1;
+ c = 1;
carry_pos = s - sbeg;
carry_len = l;
}
- if (!found_alnum) { /* str contains no alnum */
+ if (c == -1) { /* str contains no alnum */
s = e;
while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) {
enum neighbor_char neighbor;
@@ -4188,7 +4174,8 @@ str_succ(VALUE str)
* str.succ! -> str
* str.next! -> str
*
- * Equivalent to String#succ, but modifies the receiver in place.
+ * Equivalent to <code>String#succ</code>, but modifies the receiver in
+ * place.
*/
static VALUE
@@ -4209,6 +4196,8 @@ all_digits_p(const char *s, long len)
return 1;
}
+static VALUE str_upto_each(VALUE beg, VALUE end, int excl, int (*each)(VALUE, VALUE), VALUE);
+
static int
str_upto_i(VALUE str, VALUE arg)
{
@@ -4222,11 +4211,10 @@ str_upto_i(VALUE str, VALUE arg)
* str.upto(other_str, exclusive=false) -> an_enumerator
*
* Iterates through successive values, starting at <i>str</i> and
- * ending at <i>other_str</i> inclusive, passing each value in turn
- * to the block. The String#succ method is used to generate each
- * value. If optional second argument exclusive is omitted or is
- * false, the last value will be included; otherwise it will be
- * excluded.
+ * ending at <i>other_str</i> inclusive, passing each value in turn to
+ * the block. The <code>String#succ</code> method is used to generate
+ * each value. If optional second argument exclusive is omitted or is false,
+ * the last value will be included; otherwise it will be excluded.
*
* If no block is given, an enumerator is returned instead.
*
@@ -4256,11 +4244,11 @@ rb_str_upto(int argc, VALUE *argv, VALUE beg)
rb_scan_args(argc, argv, "11", &end, &exclusive);
RETURN_ENUMERATOR(beg, argc, argv);
- return rb_str_upto_each(beg, end, RTEST(exclusive), str_upto_i, Qnil);
+ return str_upto_each(beg, end, RTEST(exclusive), str_upto_i, Qnil);
}
-VALUE
-rb_str_upto_each(VALUE beg, VALUE end, int excl, int (*each)(VALUE, VALUE), VALUE arg)
+static VALUE
+str_upto_each(VALUE beg, VALUE end, int excl, int (*each)(VALUE, VALUE), VALUE arg)
{
VALUE current, after_end;
ID succ;
@@ -4308,7 +4296,7 @@ rb_str_upto_each(VALUE beg, VALUE end, int excl, int (*each)(VALUE, VALUE), VALU
}
else {
ID op = excl ? '<' : idLE;
- VALUE args[2], fmt = rb_fstring_lit("%.*d");
+ VALUE args[2], fmt = rb_fstring_cstr("%.*d");
args[0] = INT2FIX(width);
while (rb_funcall(b, op, 1, e)) {
@@ -4341,50 +4329,6 @@ rb_str_upto_each(VALUE beg, VALUE end, int excl, int (*each)(VALUE, VALUE), VALU
return beg;
}
-VALUE
-rb_str_upto_endless_each(VALUE beg, int (*each)(VALUE, VALUE), VALUE arg)
-{
- VALUE current;
- ID succ;
-
- CONST_ID(succ, "succ");
- /* both edges are all digits */
- if (is_ascii_string(beg) && ISDIGIT(RSTRING_PTR(beg)[0]) &&
- all_digits_p(RSTRING_PTR(beg), RSTRING_LEN(beg))) {
- VALUE b, args[2], fmt = rb_fstring_lit("%.*d");
- int width = RSTRING_LENINT(beg);
- b = rb_str_to_inum(beg, 10, FALSE);
- if (FIXNUM_P(b)) {
- long bi = FIX2LONG(b);
- rb_encoding *usascii = rb_usascii_encoding();
-
- while (FIXABLE(bi)) {
- if ((*each)(rb_enc_sprintf(usascii, "%.*ld", width, bi), arg)) break;
- bi++;
- }
- b = LONG2NUM(bi);
- }
- args[0] = INT2FIX(width);
- while (1) {
- args[1] = b;
- if ((*each)(rb_str_format(numberof(args), args, fmt), arg)) break;
- b = rb_funcallv(b, succ, 0, 0);
- }
- }
- /* normal case */
- current = rb_str_dup(beg);
- while (1) {
- VALUE next = rb_funcallv(current, succ, 0, 0);
- if ((*each)(current, arg)) break;
- current = next;
- StringValue(current);
- if (RSTRING_LEN(current) == 0)
- break;
- }
-
- return beg;
-}
-
static int
include_range_i(VALUE str, VALUE arg)
{
@@ -4433,7 +4377,7 @@ rb_str_include_range_p(VALUE beg, VALUE end, VALUE val, VALUE exclusive)
}
#endif
}
- rb_str_upto_each(beg, end, RTEST(exclusive), include_range_i, (VALUE)&val);
+ str_upto_each(beg, end, RTEST(exclusive), include_range_i, (VALUE)&val);
return NIL_P(val) ? Qtrue : Qfalse;
}
@@ -4606,6 +4550,7 @@ rb_str_splice_0(VALUE str, long beg, long len, VALUE val)
if (beg == 0 && vlen == 0) {
rb_str_drop_bytes(str, len);
+ OBJ_INFECT(str, val);
return;
}
@@ -4636,6 +4581,7 @@ rb_str_splice_0(VALUE str, long beg, long len, VALUE val)
slen += vlen - len;
STR_SET_LEN(str, slen);
TERM_FILL(&sptr[slen], TERM_LEN(str));
+ OBJ_INFECT(str, val);
ENC_CODERANGE_SET(str, cr);
}
@@ -4737,7 +4683,7 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
}
if (SPECIAL_CONST_P(indx)) goto generic;
- switch (BUILTIN_TYPE(indx)) {
+ switch (TYPE(indx)) {
case T_REGEXP:
rb_str_subpat_set(str, indx, INT2FIX(0), val);
return val;
@@ -4776,18 +4722,19 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
* str[regexp, name] = new_str
* str[other_str] = new_str
*
- * Element Assignment---Replaces some or all of the content of
- * <i>str</i>. The portion of the string affected is determined using
- * the same criteria as String#[]. If the replacement string is not
- * the same length as the text it is replacing, the string will be
- * adjusted accordingly. If the regular expression or string is used
- * as the index doesn't match a position in the string, IndexError is
- * raised. If the regular expression form is used, the optional
- * second Integer allows you to specify which portion of the match to
- * replace (effectively using the MatchData indexing rules. The forms
- * that take an Integer will raise an IndexError if the value is out
- * of range; the Range form will raise a RangeError, and the Regexp
- * and String will raise an IndexError on negative match.
+ * Element Assignment---Replaces some or all of the content of <i>str</i>. The
+ * portion of the string affected is determined using the same criteria as
+ * <code>String#[]</code>. If the replacement string is not the same length as
+ * the text it is replacing, the string will be adjusted accordingly. If the
+ * regular expression or string is used as the index doesn't match a position
+ * in the string, <code>IndexError</code> is raised. If the regular expression
+ * form is used, the optional second <code>Integer</code> allows you to specify
+ * which portion of the match to replace (effectively using the
+ * <code>MatchData</code> indexing rules. The forms that take an
+ * <code>Integer</code> will raise an <code>IndexError</code> if the value is
+ * out of range; the <code>Range</code> form will raise a
+ * <code>RangeError</code>, and the <code>Regexp</code> and <code>String</code>
+ * will raise an <code>IndexError</code> on negative match.
*/
static VALUE
@@ -4937,8 +4884,11 @@ rb_pat_search(VALUE pat, VALUE str, long pos, int set_backref_str)
pos = rb_strseq_index(str, pat, pos, 1);
if (set_backref_str) {
if (pos >= 0) {
+ VALUE match;
str = rb_str_new_frozen(str);
rb_backref_set_string(str, pos, RSTRING_LEN(pat));
+ match = rb_backref_get();
+ OBJ_INFECT(match, pat);
}
else {
rb_backref_set(Qnil);
@@ -4968,6 +4918,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
{
VALUE pat, repl, hash = Qnil;
int iter = 0;
+ int tainted = 0;
long plen;
int min_arity = rb_block_given_p() ? 1 : 2;
long beg;
@@ -4982,6 +4933,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
if (NIL_P(hash)) {
StringValue(repl);
}
+ tainted = OBJ_TAINTED_RAW(repl);
}
pat = get_pat_quoted(argv[0], 1);
@@ -5041,6 +4993,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
}
rb_str_modify(str);
rb_enc_associate(str, enc);
+ tainted |= OBJ_TAINTED_RAW(repl);
if (ENC_CODERANGE_UNKNOWN < cr && cr < ENC_CODERANGE_BROKEN) {
int cr2 = ENC_CODERANGE(repl);
if (cr2 == ENC_CODERANGE_BROKEN ||
@@ -5050,7 +5003,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
cr = cr2;
}
plen = end0 - beg0;
- rlen = RSTRING_LEN(repl);
+ rlen = RSTRING_LEN(repl);
len = RSTRING_LEN(str);
if (rlen > plen) {
RESIZE_CAPA(str, len + rlen - plen);
@@ -5059,12 +5012,13 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
if (rlen != plen) {
memmove(p + beg0 + rlen, p + beg0 + plen, len - beg0 - plen);
}
- rp = RSTRING_PTR(repl);
- memmove(p + beg0, rp, rlen);
+ rp = RSTRING_PTR(repl);
+ memmove(p + beg0, rp, rlen);
len += rlen - plen;
STR_SET_LEN(str, len);
TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str));
ENC_CODERANGE_SET(str, cr);
+ FL_SET_RAW(str, tainted);
return str;
}
@@ -5081,31 +5035,30 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
* Returns a copy of +str+ with the _first_ occurrence of +pattern+
* replaced by the second argument. The +pattern+ is typically a Regexp; if
* given as a String, any regular expression metacharacters it contains will
- * be interpreted literally, e.g. <code>\d</code> will match a backslash
+ * be interpreted literally, e.g. <code>'\\\d'</code> will match a backslash
* followed by 'd', instead of a digit.
*
* If +replacement+ is a String it will be substituted for the matched text.
* It may contain back-references to the pattern's capture groups of the form
- * <code>\d</code>, where <i>d</i> is a group number, or
- * <code>\k<n></code>, where <i>n</i> is a group name.
- * Similarly, <code>\&</code>, <code>\'</code>, <code>\`</code>, and
- * <code>\+</code> correspond to special variables, <code>$&</code>,
- * <code>$'</code>, <code>$`</code>, and <code>$+</code>, respectively.
- * (See rdoc-ref:regexp.rdoc for details.)
- * <code>\0</code> is the same as <code>\&</code>.
- * <code>\\\\</code> is interpreted as an escape, i.e., a single backslash.
- * Note that, within +replacement+ the special match variables, such as
- * <code>$&</code>, will not refer to the current match.
+ * <code>"\\d"</code>, where <i>d</i> is a group number, or
+ * <code>"\\k<n>"</code>, where <i>n</i> is a group name. If it is a
+ * double-quoted string, both back-references must be preceded by an
+ * additional backslash. However, within +replacement+ the special match
+ * variables, such as <code>$&</code>, will not refer to the current match.
+ * If +replacement+ is a String that looks like a pattern's capture group but
+ * is actually not a pattern capture group e.g. <code>"\\'"</code>, then it
+ * will have to be preceded by two backslashes like so <code>"\\\\'"</code>.
*
* If the second argument is a Hash, and the matched text is one of its keys,
* the corresponding value is the replacement string.
*
* In the block form, the current match string is passed in as a parameter,
* and variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,
- * <code>$&</code>, and <code>$'</code> will be set appropriately.
- * (See rdoc-ref:regexp.rdoc for details.)
- * The value returned by the block will be substituted for the match on each
- * call.
+ * <code>$&</code>, and <code>$'</code> will be set appropriately. The value
+ * returned by the block will be substituted for the match on each call.
+ *
+ * The result inherits any tainting in the original string or any supplied
+ * replacement string.
*
* "hello".sub(/[aeiou]/, '*') #=> "h*llo"
* "hello".sub(/([aeiou])/, '<\1>') #=> "h<e>llo"
@@ -5113,19 +5066,6 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
* "hello".sub(/(?<foo>[aeiou])/, '*\k<foo>*') #=> "h*e*llo"
* 'Is SHELL your preferred shell?'.sub(/[[:upper:]]{2,}/, ENV)
* #=> "Is /bin/bash your preferred shell?"
- *
- * Note that a string literal consumes backslashes.
- * (See rdoc-ref:syntax/literals.rdoc for details about string literals.)
- * Back-references are typically preceded by an additional backslash.
- * For example, if you want to write a back-reference <code>\&</code> in
- * +replacement+ with a double-quoted string literal, you need to write:
- * <code>"..\\\\&.."</code>.
- * If you want to write a non-back-reference string <code>\&</code> in
- * +replacement+, you need first to escape the backslash to prevent
- * this method from interpreting it as a back-reference, and then you
- * need to escape the backslashes again to prevent a string literal from
- * consuming them: <code>"..\\\\\\\\&.."</code>.
- * You may want to use the block form to avoid a lot of backslashes.
*/
static VALUE
@@ -5145,6 +5085,7 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
long offset, blen, slen, len, last;
enum {STR, ITER, MAP} mode = STR;
char *sp, *cp;
+ int tainted = 0;
int need_backref = -1;
rb_encoding *str_enc;
@@ -5162,9 +5103,10 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
else {
mode = MAP;
}
+ tainted = OBJ_TAINTED_RAW(repl);
break;
default:
- rb_error_arity(argc, 1, 2);
+ rb_check_arity(argc, 1, 2);
}
pat = get_pat_quoted(argv[0], 1);
@@ -5221,6 +5163,8 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
val = repl;
}
+ tainted |= OBJ_TAINTED_RAW(val);
+
len = beg0 - offset; /* copy pre-match substr */
if (len) {
rb_enc_str_buf_cat(dest, cp, len, str_enc);
@@ -5253,9 +5197,11 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
}
else {
RBASIC_SET_CLASS(dest, rb_obj_class(str));
+ tainted |= OBJ_TAINTED_RAW(str);
str = dest;
}
+ FL_SET_RAW(str, tainted);
return str;
}
@@ -5267,10 +5213,9 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
* str.gsub!(pattern) {|match| block } -> str or nil
* str.gsub!(pattern) -> an_enumerator
*
- * Performs the substitutions of String#gsub in place, returning
- * <i>str</i>, or <code>nil</code> if no substitutions were
- * performed. If no block and no <i>replacement</i> is given, an
- * enumerator is returned instead.
+ * Performs the substitutions of <code>String#gsub</code> in place, returning
+ * <i>str</i>, or <code>nil</code> if no substitutions were performed.
+ * If no block and no <i>replacement</i> is given, an enumerator is returned instead.
*/
static VALUE
@@ -5290,55 +5235,38 @@ rb_str_gsub_bang(int argc, VALUE *argv, VALUE str)
*
* Returns a copy of <i>str</i> with <em>all</em> occurrences of
* <i>pattern</i> substituted for the second argument. The <i>pattern</i> is
- * typically a Regexp; if given as a String, any
+ * typically a <code>Regexp</code>; if given as a <code>String</code>, any
* regular expression metacharacters it contains will be interpreted
- * literally, e.g. <code>\d</code> will match a backslash followed by 'd',
+ * literally, e.g. <code>'\\\d'</code> will match a backslash followed by 'd',
* instead of a digit.
*
- * If +replacement+ is a String it will be substituted for the matched text.
- * It may contain back-references to the pattern's capture groups of the form
- * <code>\d</code>, where <i>d</i> is a group number, or
- * <code>\k<n></code>, where <i>n</i> is a group name.
- * Similarly, <code>\&</code>, <code>\'</code>, <code>\`</code>, and
- * <code>\+</code> correspond to special variables, <code>$&</code>,
- * <code>$'</code>, <code>$`</code>, and <code>$+</code>, respectively.
- * (See rdoc-ref:regexp.rdoc for details.)
- * <code>\0</code> is the same as <code>\&</code>.
- * <code>\\\\</code> is interpreted as an escape, i.e., a single backslash.
- * Note that, within +replacement+ the special match variables, such as
- * <code>$&</code>, will not refer to the current match.
- *
- * If the second argument is a Hash, and the matched text is one
+ * If <i>replacement</i> is a <code>String</code> it will be substituted for
+ * the matched text. It may contain back-references to the pattern's capture
+ * groups of the form <code>\\\d</code>, where <i>d</i> is a group number, or
+ * <code>\\\k<n></code>, where <i>n</i> is a group name. If it is a
+ * double-quoted string, both back-references must be preceded by an
+ * additional backslash. However, within <i>replacement</i> the special match
+ * variables, such as <code>$&</code>, will not refer to the current match.
+ *
+ * If the second argument is a <code>Hash</code>, and the matched text is one
* of its keys, the corresponding value is the replacement string.
*
* In the block form, the current match string is passed in as a parameter,
* and variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,
- * <code>$&</code>, and <code>$'</code> will be set appropriately.
- * (See rdoc-ref:regexp.rdoc for details.)
- * The value returned by the block will be substituted for the match on each
- * call.
+ * <code>$&</code>, and <code>$'</code> will be set appropriately. The value
+ * returned by the block will be substituted for the match on each call.
+ *
+ * The result inherits any tainting in the original string or any supplied
+ * replacement string.
*
* When neither a block nor a second argument is supplied, an
- * Enumerator is returned.
+ * <code>Enumerator</code> is returned.
*
* "hello".gsub(/[aeiou]/, '*') #=> "h*ll*"
* "hello".gsub(/([aeiou])/, '<\1>') #=> "h<e>ll<o>"
* "hello".gsub(/./) {|s| s.ord.to_s + ' '} #=> "104 101 108 108 111 "
* "hello".gsub(/(?<foo>[aeiou])/, '{\k<foo>}') #=> "h{e}ll{o}"
* 'hello'.gsub(/[eo]/, 'e' => 3, 'o' => '*') #=> "h3ll*"
- *
- * Note that a string literal consumes backslashes.
- * (See rdoc-ref:syntax/literals.rdoc for details on string literals.)
- * Back-references are typically preceded by an additional backslash.
- * For example, if you want to write a back-reference <code>\&</code> in
- * +replacement+ with a double-quoted string literal, you need to write:
- * <code>"..\\\\&.."</code>.
- * If you want to write a non-back-reference string <code>\&</code> in
- * +replacement+, you need first to escape the backslash to prevent
- * this method from interpreting it as a back-reference, and then you
- * need to escape the backslashes again to prevent a string literal from
- * consuming them: <code>"..\\\\\\\\&.."</code>.
- * You may want to use the block form to avoid a lot of backslashes.
*/
static VALUE
@@ -5352,7 +5280,7 @@ rb_str_gsub(int argc, VALUE *argv, VALUE str)
* call-seq:
* str.replace(other_str) -> str
*
- * Replaces the contents of <i>str</i> with the corresponding
+ * Replaces the contents and taintedness of <i>str</i> with the corresponding
* values in <i>other_str</i>.
*
* s = "hello" #=> "hello"
@@ -5439,9 +5367,9 @@ static VALUE
rb_str_setbyte(VALUE str, VALUE index, VALUE value)
{
long pos = NUM2LONG(index);
+ int byte = NUM2INT(value);
long len = RSTRING_LEN(str);
- char *head, *left = 0;
- unsigned char *ptr;
+ char *head, *ptr, *left = 0;
rb_encoding *enc;
int cr = ENC_CODERANGE_UNKNOWN, width, nlen;
@@ -5450,20 +5378,16 @@ rb_str_setbyte(VALUE str, VALUE index, VALUE value)
if (pos < 0)
pos += len;
- VALUE v = rb_to_int(value);
- VALUE w = rb_int_and(v, INT2FIX(0xff));
- unsigned char byte = NUM2INT(w) & 0xFF;
-
if (!str_independent(str))
str_make_independent(str);
enc = STR_ENC_GET(str);
head = RSTRING_PTR(str);
- ptr = (unsigned char *)&head[pos];
+ ptr = &head[pos];
if (!STR_EMBED_P(str)) {
cr = ENC_CODERANGE(str);
switch (cr) {
case ENC_CODERANGE_7BIT:
- left = (char *)ptr;
+ left = ptr;
*ptr = byte;
if (ISASCII(byte)) goto end;
nlen = rb_enc_precise_mbclen(left, head+len, enc);
@@ -5542,6 +5466,8 @@ str_byte_substr(VALUE str, long beg, long len, int empty)
}
}
+ OBJ_INFECT_RAW(str2, str);
+
return str2;
}
@@ -5576,10 +5502,10 @@ str_byte_aref(VALUE str, VALUE indx)
* str.byteslice(integer, integer) -> new_str or nil
* str.byteslice(range) -> new_str or nil
*
- * Byte Reference---If passed a single Integer, returns a
- * substring of one byte at that position. If passed two Integer
+ * Byte Reference---If passed a single <code>Integer</code>, returns a
+ * substring of one byte at that position. If passed two <code>Integer</code>
* objects, returns a substring starting at the offset given by the first, and
- * a length given by the second. If given a Range, a substring containing
+ * a length given by the second. If given a <code>Range</code>, a substring containing
* bytes at offsets given by the range is returned. In all three cases, if
* an offset is negative, it is counted from the end of <i>str</i>. Returns
* <code>nil</code> if the initial offset falls outside the string, the length
@@ -5658,6 +5584,7 @@ rb_str_reverse(VALUE str)
}
}
STR_SET_LEN(rev, RSTRING_LEN(str));
+ OBJ_INFECT_RAW(rev, str);
str_enc_copy(rev, str);
ENC_CODERANGE_SET(rev, cr);
@@ -5748,9 +5675,16 @@ rb_str_include(VALUE str, VALUE arg)
static VALUE
rb_str_to_i(int argc, VALUE *argv, VALUE str)
{
- int base = 10;
+ int base;
+
+ if (argc == 0) base = 10;
+ else {
+ VALUE b;
- if (rb_check_arity(argc, 0, 1) && (base = NUM2INT(argv[0])) < 0) {
+ rb_scan_args(argc, argv, "01", &b);
+ base = NUM2INT(b);
+ }
+ if (base < 0) {
rb_raise(rb_eArgError, "invalid radix %d", base);
}
return rb_str_to_inum(str, base, FALSE);
@@ -5844,24 +5778,6 @@ rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p)
return l;
}
-const char *
-ruby_escaped_char(int c)
-{
- switch (c) {
- case '\0': return "\\0";
- case '\n': return "\\n";
- case '\r': return "\\r";
- case '\t': return "\\t";
- case '\f': return "\\f";
- case '\013': return "\\v";
- case '\010': return "\\b";
- case '\007': return "\\a";
- case '\033': return "\\e";
- case '\x7f': return "\\c?";
- }
- return NULL;
-}
-
VALUE
rb_str_escape(VALUE str)
{
@@ -5876,8 +5792,7 @@ rb_str_escape(VALUE str)
int asciicompat = rb_enc_asciicompat(enc);
while (p < pend) {
- unsigned int c;
- const char *cc;
+ unsigned int c, cc;
int n = rb_enc_precise_mbclen(p, pend, enc);
if (!MBCLEN_CHARFOUND_P(n)) {
if (p > prev) str_buf_cat(result, prev, p - prev);
@@ -5894,10 +5809,22 @@ rb_str_escape(VALUE str)
n = MBCLEN_CHARFOUND_LEN(n);
c = rb_enc_mbc_to_codepoint(p, pend, enc);
p += n;
- cc = ruby_escaped_char(c);
+ switch (c) {
+ case '\n': cc = 'n'; break;
+ case '\r': cc = 'r'; break;
+ case '\t': cc = 't'; break;
+ case '\f': cc = 'f'; break;
+ case '\013': cc = 'v'; break;
+ case '\010': cc = 'b'; break;
+ case '\007': cc = 'a'; break;
+ case 033: cc = 'e'; break;
+ default: cc = 0; break;
+ }
if (cc) {
if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
- str_buf_cat(result, cc, strlen(cc));
+ buf[0] = '\\';
+ buf[1] = (char)cc;
+ str_buf_cat(result, buf, 2);
prev = p;
}
else if (asciicompat && rb_enc_isascii(c, enc) && ISPRINT(c)) {
@@ -5911,6 +5838,7 @@ rb_str_escape(VALUE str)
if (p > prev) str_buf_cat(result, prev, p - prev);
ENCODING_CODERANGE_SET(result, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
+ OBJ_INFECT_RAW(result, str);
return result;
}
@@ -6017,6 +5945,7 @@ rb_str_inspect(VALUE str)
if (p > prev) str_buf_cat(result, prev, p - prev);
str_buf_cat2(result, "\"");
+ OBJ_INFECT_RAW(result, str);
return result;
}
@@ -6026,16 +5955,10 @@ rb_str_inspect(VALUE str)
* call-seq:
* str.dump -> new_str
*
- * Returns a quoted version of the string with all non-printing characters
- * replaced by <code>\xHH</code> notation and all special characters escaped.
- *
- * This method can be used for round-trip: if the resulting +new_str+ is
- * eval'ed, it will produce the original string.
- *
- * "hello \n ''".dump #=> "\"hello \\n ''\""
- * "\f\x00\xff\\\"".dump #=> "\"\\f\\x00\\xFF\\\\\\\"\""
+ * Produces a version of +str+ with all non-printing characters replaced by
+ * <code>\nnn</code> notation and all special characters escaped.
*
- * See also String#undump.
+ * "hello \n ''".dump #=> "\"hello \\n ''\""
*/
VALUE
@@ -6048,7 +5971,7 @@ rb_str_dump(VALUE str)
char *q, *qend;
VALUE result;
int u8 = (encidx == rb_utf8_encindex());
- static const char nonascii_suffix[] = ".dup.force_encoding(\"%s\")";
+ static const char nonascii_suffix[] = ".force_encoding(\"%s\")";
len = 2; /* "" */
if (!rb_enc_asciicompat(enc)) {
@@ -6179,6 +6102,7 @@ rb_str_dump(VALUE str)
snprintf(q, qend-q, nonascii_suffix, enc->name);
encidx = rb_ascii8bit_encindex();
}
+ OBJ_INFECT_RAW(result, str);
/* result from dump is ASCII */
rb_enc_associate_index(result, encidx);
ENC_CODERANGE_SET(result, ENC_CODERANGE_7BIT);
@@ -6217,7 +6141,7 @@ undump_after_backslash(VALUE undumped, const char **ss, const char *s_end, rb_en
unsigned int c;
int codelen;
size_t hexlen;
- unsigned char buf[6];
+ char buf[6];
static rb_encoding *enc_utf8 = NULL;
switch (*s) {
@@ -6235,8 +6159,8 @@ undump_after_backslash(VALUE undumped, const char **ss, const char *s_end, rb_en
case 'b':
case 'a':
case 'e':
- *buf = unescape_ascii(*s);
- rb_str_cat(undumped, (char *)buf, 1);
+ *buf = (char)unescape_ascii(*s);
+ rb_str_cat(undumped, buf, 1);
s++;
break;
case 'u':
@@ -6276,8 +6200,8 @@ undump_after_backslash(VALUE undumped, const char **ss, const char *s_end, rb_en
if (0xd800 <= c && c <= 0xdfff) {
rb_raise(rb_eRuntimeError, "invalid Unicode codepoint");
}
- codelen = rb_enc_mbcput(c, (char *)buf, *penc);
- rb_str_cat(undumped, (char *)buf, codelen);
+ codelen = rb_enc_mbcput(c, buf, *penc);
+ rb_str_cat(undumped, buf, codelen);
s += hexlen;
}
}
@@ -6289,8 +6213,8 @@ undump_after_backslash(VALUE undumped, const char **ss, const char *s_end, rb_en
if (0xd800 <= c && c <= 0xdfff) {
rb_raise(rb_eRuntimeError, "invalid Unicode codepoint");
}
- codelen = rb_enc_mbcput(c, (char *)buf, *penc);
- rb_str_cat(undumped, (char *)buf, codelen);
+ codelen = rb_enc_mbcput(c, buf, *penc);
+ rb_str_cat(undumped, buf, codelen);
s += hexlen;
}
break;
@@ -6306,7 +6230,7 @@ undump_after_backslash(VALUE undumped, const char **ss, const char *s_end, rb_en
if (hexlen != 2) {
rb_raise(rb_eRuntimeError, "invalid hex escape");
}
- rb_str_cat(undumped, (char *)buf, 1);
+ rb_str_cat(undumped, buf, 1);
s += hexlen;
break;
default:
@@ -6323,8 +6247,8 @@ static VALUE rb_str_is_ascii_only_p(VALUE str);
* call-seq:
* str.undump -> new_str
*
- * Returns an unescaped version of the string.
- * This does the inverse of String#dump.
+ * Produces unescaped version of +str+.
+ * See also String#dump because String#undump does inverse of String#dump.
*
* "\"hello \\n ''\"".undump #=> "hello \n ''"
*/
@@ -6366,25 +6290,19 @@ str_undump(VALUE str)
break;
}
else {
- static const char force_encoding_suffix[] = ".force_encoding(\""; /* "\")" */
- static const char dup_suffix[] = ".dup";
const char *encname;
int encidx;
ptrdiff_t size;
- /* check separately for strings dumped by older versions */
- size = sizeof(dup_suffix) - 1;
- if (s_end - s > size && memcmp(s, dup_suffix, size) == 0) s += size;
-
- size = sizeof(force_encoding_suffix) - 1;
- if (s_end - s <= size) goto invalid_format;
- if (memcmp(s, force_encoding_suffix, size) != 0) goto invalid_format;
- s += size;
-
if (utf8) {
rb_raise(rb_eRuntimeError, "dumped string contained Unicode escape but used force_encoding");
}
+ size = rb_strlen_lit(".force_encoding(\"");
+ if (s_end - s <= size) goto invalid_format;
+ if (memcmp(s, ".force_encoding(\"", size) != 0) goto invalid_format;
+ s += size;
+
encname = s;
s = memchr(s, '"', s_end-s);
size = s - encname;
@@ -6413,6 +6331,7 @@ str_undump(VALUE str)
}
}
+ OBJ_INFECT(undumped, str);
return undumped;
invalid_format:
rb_raise(rb_eRuntimeError, "invalid dumped string; not wrapped with '\"' nor '\"...\".force_encoding(\"...\")' form");
@@ -6427,14 +6346,6 @@ rb_str_check_dummy_enc(rb_encoding *enc)
}
}
-static rb_encoding *
-str_true_enc(VALUE str)
-{
- rb_encoding *enc = STR_ENC_GET(str);
- rb_str_check_dummy_enc(enc);
- return enc;
-}
-
static OnigCaseFoldType
check_case_options(int argc, VALUE *argv, OnigCaseFoldType flags)
{
@@ -6475,14 +6386,6 @@ check_case_options(int argc, VALUE *argv, OnigCaseFoldType flags)
return flags;
}
-static inline bool
-case_option_single_p(OnigCaseFoldType flags, rb_encoding *enc, VALUE str)
-{
- if ((flags & ONIGENC_CASE_ASCII_ONLY) && (enc==rb_utf8_encoding() || rb_enc_mbmaxlen(enc) == 1))
- return true;
- return !(flags & ONIGENC_CASE_FOLD_TURKISH_AZERI) && ENC_CODERANGE(str) == ENC_CODERANGE_7BIT;
-}
-
/* 16 should be long enough to absorb any kind of single character length increase */
#define CASE_MAPPING_ADDITIONAL_LENGTH 20
#ifndef CASEMAP_DEBUG
@@ -6494,7 +6397,7 @@ typedef struct mapping_buffer {
size_t capa;
size_t used;
struct mapping_buffer *next;
- OnigUChar space[FLEX_ARY_LEN];
+ OnigUChar space[1];
} mapping_buffer;
static void
@@ -6519,7 +6422,7 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
{
VALUE target;
- const OnigUChar *source_current, *source_end;
+ OnigUChar *source_current, *source_end;
int target_length = 0;
VALUE buffer_anchor;
mapping_buffer *current_buffer = 0;
@@ -6553,7 +6456,7 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
if (buffer_length_or_invalid < 0) {
current_buffer = DATA_PTR(buffer_anchor);
DATA_PTR(buffer_anchor) = 0;
- mapping_buffer_free(current_buffer);
+ mapping_buffer_free(current_buffer);
rb_raise(rb_eArgError, "input string invalid");
}
target_length += current_buffer->used = buffer_length_or_invalid;
@@ -6570,7 +6473,7 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
target = rb_str_new_with_class(source, 0, target_length);
target_current = RSTRING_PTR(target);
- current_buffer = DATA_PTR(buffer_anchor);
+ current_buffer = DATA_PTR(buffer_anchor);
while (current_buffer) {
memcpy(target_current, current_buffer->space, current_buffer->used);
target_current += current_buffer->used;
@@ -6582,36 +6485,28 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
mapping_buffer_free(current_buffer);
/* TODO: check about string terminator character */
+ OBJ_INFECT_RAW(target, source);
str_enc_copy(target, source);
/*ENC_CODERANGE_SET(mapped, cr);*/
return target;
}
-static VALUE
-rb_str_ascii_casemap(VALUE source, VALUE target, OnigCaseFoldType *flags, rb_encoding *enc)
+static void
+rb_str_ascii_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
{
- const OnigUChar *source_current, *source_end;
- OnigUChar *target_current, *target_end;
+ OnigUChar *source_current, *source_end;
long old_length = RSTRING_LEN(source);
int length_or_invalid;
- if (old_length == 0) return Qnil;
+ if (old_length == 0) return;
source_current = (OnigUChar*)RSTRING_PTR(source);
source_end = (OnigUChar*)RSTRING_END(source);
- if (source == target) {
- target_current = (OnigUChar*)source_current;
- target_end = (OnigUChar*)source_end;
- }
- else {
- target_current = (OnigUChar*)RSTRING_PTR(target);
- target_end = (OnigUChar*)RSTRING_END(target);
- }
length_or_invalid = onigenc_ascii_only_case_map(flags,
- &source_current, source_end,
- target_current, target_end, enc);
+ (const OnigUChar**)&source_current, source_end,
+ source_current, source_end, enc);
if (length_or_invalid < 0)
rb_raise(rb_eArgError, "input string invalid");
if (CASEMAP_DEBUG && length_or_invalid != old_length) {
@@ -6620,28 +6515,6 @@ rb_str_ascii_casemap(VALUE source, VALUE target, OnigCaseFoldType *flags, rb_enc
rb_raise(rb_eArgError, "internal problem with rb_str_ascii_casemap"
"; old_length=%ld, new_length=%d\n", old_length, length_or_invalid);
}
-
- str_enc_copy(target, source);
-
- return target;
-}
-
-static bool
-upcase_single(VALUE str)
-{
- char *s = RSTRING_PTR(str), *send = RSTRING_END(str);
- bool modified = false;
-
- while (s < send) {
- unsigned int c = *(unsigned char*)s;
-
- if (rb_enc_isascii(c, enc) && 'a' <= c && c <= 'z') {
- *s = 'A' + (c - 'a');
- modified = true;
- }
- s++;
- }
- return modified;
}
/*
@@ -6663,13 +6536,24 @@ rb_str_upcase_bang(int argc, VALUE *argv, VALUE str)
flags = check_case_options(argc, argv, flags);
str_modify_keep_cr(str);
- enc = str_true_enc(str);
- if (case_option_single_p(flags, enc, str)) {
- if (upcase_single(str))
- flags |= ONIGENC_CASE_MODIFIED;
+ enc = STR_ENC_GET(str);
+ rb_str_check_dummy_enc(enc);
+ if (((flags&ONIGENC_CASE_ASCII_ONLY) && (enc==rb_utf8_encoding() || rb_enc_mbmaxlen(enc)==1))
+ || (!(flags&ONIGENC_CASE_FOLD_TURKISH_AZERI) && ENC_CODERANGE(str)==ENC_CODERANGE_7BIT)) {
+ char *s = RSTRING_PTR(str), *send = RSTRING_END(str);
+
+ while (s < send) {
+ unsigned int c = *(unsigned char*)s;
+
+ if (rb_enc_isascii(c, enc) && 'a' <= c && c <= 'z') {
+ *s = 'A' + (c - 'a');
+ flags |= ONIGENC_CASE_MODIFIED;
+ }
+ s++;
+ }
}
else if (flags&ONIGENC_CASE_ASCII_ONLY)
- rb_str_ascii_casemap(str, str, &flags, enc);
+ rb_str_ascii_casemap(str, &flags, enc);
else
str_shared_replace(str, rb_str_casemap(str, &flags, enc));
@@ -6694,45 +6578,9 @@ rb_str_upcase_bang(int argc, VALUE *argv, VALUE str)
static VALUE
rb_str_upcase(int argc, VALUE *argv, VALUE str)
{
- rb_encoding *enc;
- OnigCaseFoldType flags = ONIGENC_CASE_UPCASE;
- VALUE ret;
-
- flags = check_case_options(argc, argv, flags);
- enc = str_true_enc(str);
- if (case_option_single_p(flags, enc, str)) {
- ret = rb_str_new_with_class(str, RSTRING_PTR(str), RSTRING_LEN(str));
- str_enc_copy(ret, str);
- upcase_single(ret);
- }
- else if (flags&ONIGENC_CASE_ASCII_ONLY) {
- ret = rb_str_new_with_class(str, 0, RSTRING_LEN(str));
- rb_str_ascii_casemap(str, ret, &flags, enc);
- }
- else {
- ret = rb_str_casemap(str, &flags, enc);
- }
-
- return ret;
-}
-
-static bool
-downcase_single(VALUE str)
-{
- char *s = RSTRING_PTR(str), *send = RSTRING_END(str);
- bool modified = false;
-
- while (s < send) {
- unsigned int c = *(unsigned char*)s;
-
- if (rb_enc_isascii(c, enc) && 'A' <= c && c <= 'Z') {
- *s = 'a' + (c - 'A');
- modified = true;
- }
- s++;
- }
-
- return modified;
+ str = rb_str_dup(str);
+ rb_str_upcase_bang(argc, argv, str);
+ return str;
}
/*
@@ -6754,13 +6602,24 @@ rb_str_downcase_bang(int argc, VALUE *argv, VALUE str)
flags = check_case_options(argc, argv, flags);
str_modify_keep_cr(str);
- enc = str_true_enc(str);
- if (case_option_single_p(flags, enc, str)) {
- if (downcase_single(str))
- flags |= ONIGENC_CASE_MODIFIED;
+ enc = STR_ENC_GET(str);
+ rb_str_check_dummy_enc(enc);
+ if (((flags&ONIGENC_CASE_ASCII_ONLY) && (enc==rb_utf8_encoding() || rb_enc_mbmaxlen(enc)==1))
+ || (!(flags&ONIGENC_CASE_FOLD_TURKISH_AZERI) && ENC_CODERANGE(str)==ENC_CODERANGE_7BIT)) {
+ char *s = RSTRING_PTR(str), *send = RSTRING_END(str);
+
+ while (s < send) {
+ unsigned int c = *(unsigned char*)s;
+
+ if (rb_enc_isascii(c, enc) && 'A' <= c && c <= 'Z') {
+ *s = 'a' + (c - 'A');
+ flags |= ONIGENC_CASE_MODIFIED;
+ }
+ s++;
+ }
}
else if (flags&ONIGENC_CASE_ASCII_ONLY)
- rb_str_ascii_casemap(str, str, &flags, enc);
+ rb_str_ascii_casemap(str, &flags, enc);
else
str_shared_replace(str, rb_str_casemap(str, &flags, enc));
@@ -6792,7 +6651,7 @@ rb_str_downcase_bang(int argc, VALUE *argv, VALUE str)
* This option cannot be combined with any other option.
* :turkic ::
* Full Unicode case mapping, adapted for Turkic languages
- * (Turkish, Azerbaijani, ...). This means that upper case I is mapped to
+ * (Turkish, Aserbaijani,...). This means that upper case I is mapped to
* lower case dotless i, and so on.
* :lithuanian ::
* Currently, just full Unicode case mapping. In the future, full Unicode
@@ -6802,7 +6661,7 @@ rb_str_downcase_bang(int argc, VALUE *argv, VALUE str)
* Only available on +downcase+ and +downcase!+. Unicode case <b>folding</b>,
* which is more far-reaching than Unicode case mapping.
* This option currently cannot be combined with any other option
- * (i.e. there is currently no variant for turkic languages).
+ * (i.e. there is currenty no variant for turkic languages).
*
* Please note that several assumptions that are valid for ASCII-only case
* conversions do not hold for more general case conversions. For example,
@@ -6822,26 +6681,9 @@ rb_str_downcase_bang(int argc, VALUE *argv, VALUE str)
static VALUE
rb_str_downcase(int argc, VALUE *argv, VALUE str)
{
- rb_encoding *enc;
- OnigCaseFoldType flags = ONIGENC_CASE_DOWNCASE;
- VALUE ret;
-
- flags = check_case_options(argc, argv, flags);
- enc = str_true_enc(str);
- if (case_option_single_p(flags, enc, str)) {
- ret = rb_str_new_with_class(str, RSTRING_PTR(str), RSTRING_LEN(str));
- str_enc_copy(ret, str);
- downcase_single(ret);
- }
- else if (flags&ONIGENC_CASE_ASCII_ONLY) {
- ret = rb_str_new_with_class(str, 0, RSTRING_LEN(str));
- rb_str_ascii_casemap(str, ret, &flags, enc);
- }
- else {
- ret = rb_str_casemap(str, &flags, enc);
- }
-
- return ret;
+ str = rb_str_dup(str);
+ rb_str_downcase_bang(argc, argv, str);
+ return str;
}
@@ -6852,8 +6694,6 @@ rb_str_downcase(int argc, VALUE *argv, VALUE str)
*
* Modifies <i>str</i> by converting the first character to uppercase and the
* remainder to lowercase. Returns <code>nil</code> if no changes are made.
- * There is an exception for modern Georgian (mkhedruli/MTAVRULI), where
- * the result is the same as for String#downcase, to avoid mixed case.
*
* See String#downcase for meaning of +options+ and use with different encodings.
*
@@ -6871,10 +6711,11 @@ rb_str_capitalize_bang(int argc, VALUE *argv, VALUE str)
flags = check_case_options(argc, argv, flags);
str_modify_keep_cr(str);
- enc = str_true_enc(str);
+ enc = STR_ENC_GET(str);
+ rb_str_check_dummy_enc(enc);
if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil;
if (flags&ONIGENC_CASE_ASCII_ONLY)
- rb_str_ascii_casemap(str, str, &flags, enc);
+ rb_str_ascii_casemap(str, &flags, enc);
else
str_shared_replace(str, rb_str_casemap(str, &flags, enc));
@@ -6901,21 +6742,9 @@ rb_str_capitalize_bang(int argc, VALUE *argv, VALUE str)
static VALUE
rb_str_capitalize(int argc, VALUE *argv, VALUE str)
{
- rb_encoding *enc;
- OnigCaseFoldType flags = ONIGENC_CASE_UPCASE | ONIGENC_CASE_TITLECASE;
- VALUE ret;
-
- flags = check_case_options(argc, argv, flags);
- enc = str_true_enc(str);
- if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return str;
- if (flags&ONIGENC_CASE_ASCII_ONLY) {
- ret = rb_str_new_with_class(str, 0, RSTRING_LEN(str));
- rb_str_ascii_casemap(str, ret, &flags, enc);
- }
- else {
- ret = rb_str_casemap(str, &flags, enc);
- }
- return ret;
+ str = rb_str_dup(str);
+ rb_str_capitalize_bang(argc, argv, str);
+ return str;
}
@@ -6924,11 +6753,10 @@ rb_str_capitalize(int argc, VALUE *argv, VALUE str)
* str.swapcase! -> str or nil
* str.swapcase!([options]) -> str or nil
*
- * Equivalent to String#swapcase, but modifies the receiver in place,
- * returning <i>str</i>, or <code>nil</code> if no changes were made.
+ * Equivalent to <code>String#swapcase</code>, but modifies the receiver in
+ * place, returning <i>str</i>, or <code>nil</code> if no changes were made.
*
- * See String#downcase for meaning of +options+ and use with
- * different encodings.
+ * See String#downcase for meaning of +options+ and use with different encodings.
*/
static VALUE
@@ -6939,9 +6767,10 @@ rb_str_swapcase_bang(int argc, VALUE *argv, VALUE str)
flags = check_case_options(argc, argv, flags);
str_modify_keep_cr(str);
- enc = str_true_enc(str);
+ enc = STR_ENC_GET(str);
+ rb_str_check_dummy_enc(enc);
if (flags&ONIGENC_CASE_ASCII_ONLY)
- rb_str_ascii_casemap(str, str, &flags, enc);
+ rb_str_ascii_casemap(str, &flags, enc);
else
str_shared_replace(str, rb_str_casemap(str, &flags, enc));
@@ -6967,21 +6796,9 @@ rb_str_swapcase_bang(int argc, VALUE *argv, VALUE str)
static VALUE
rb_str_swapcase(int argc, VALUE *argv, VALUE str)
{
- rb_encoding *enc;
- OnigCaseFoldType flags = ONIGENC_CASE_UPCASE | ONIGENC_CASE_DOWNCASE;
- VALUE ret;
-
- flags = check_case_options(argc, argv, flags);
- enc = str_true_enc(str);
- if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return str;
- if (flags&ONIGENC_CASE_ASCII_ONLY) {
- ret = rb_str_new_with_class(str, 0, RSTRING_LEN(str));
- rb_str_ascii_casemap(str, ret, &flags, enc);
- }
- else {
- ret = rb_str_casemap(str, &flags, enc);
- }
- return ret;
+ str = rb_str_dup(str);
+ rb_str_swapcase_bang(argc, argv, str);
+ return str;
}
typedef unsigned char *USTR;
@@ -7058,7 +6875,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
int cflag = 0;
unsigned int c, c0, last = 0;
int modify = 0, i, l;
- unsigned char *s, *send;
+ char *s, *send;
VALUE hash = 0;
int singlebyte = single_byte_optimizable(str);
int termlen;
@@ -7142,18 +6959,18 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
if (cr == ENC_CODERANGE_VALID && rb_enc_asciicompat(e1))
cr = ENC_CODERANGE_7BIT;
str_modify_keep_cr(str);
- s = (unsigned char *)RSTRING_PTR(str); send = (unsigned char *)RSTRING_END(str);
+ s = RSTRING_PTR(str); send = RSTRING_END(str);
termlen = rb_enc_mbminlen(enc);
if (sflag) {
int clen, tlen;
long offset, max = RSTRING_LEN(str);
unsigned int save = -1;
- unsigned char *buf = ALLOC_N(unsigned char, max + termlen), *t = buf;
+ char *buf = ALLOC_N(char, max + termlen), *t = buf;
while (s < send) {
int may_modify = 0;
- c0 = c = rb_enc_codepoint_len((char *)s, (char *)send, &clen, e1);
+ c0 = c = rb_enc_codepoint_len(s, send, &clen, e1);
tlen = enc == e1 ? clen : rb_enc_codelen(c, enc);
s += clen;
@@ -7187,9 +7004,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
if (enc != e1) may_modify = 1;
}
if ((offset = t - buf) + tlen > max) {
- size_t MAYBE_UNUSED(old) = max + termlen;
max = offset + tlen + (send - s);
- SIZED_REALLOC_N(buf, unsigned char, max + termlen, old);
+ REALLOC_N(buf, char, max + termlen);
t = buf + offset;
}
rb_enc_mbcput(c, t, enc);
@@ -7202,8 +7018,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
if (!STR_EMBED_P(str)) {
ruby_sized_xfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
}
- TERM_FILL((char *)t, termlen);
- RSTRING(str)->as.heap.ptr = (char *)buf;
+ TERM_FILL(t, termlen);
+ RSTRING(str)->as.heap.ptr = buf;
RSTRING(str)->as.heap.len = t - buf;
STR_SET_NOEMBED(str);
RSTRING(str)->as.heap.aux.capa = max;
@@ -7229,11 +7045,11 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
else {
int clen, tlen;
long offset, max = (long)((send - s) * 1.2);
- unsigned char *buf = ALLOC_N(unsigned char, max + termlen), *t = buf;
+ char *buf = ALLOC_N(char, max + termlen), *t = buf;
while (s < send) {
int may_modify = 0;
- c0 = c = rb_enc_codepoint_len((char *)s, (char *)send, &clen, e1);
+ c0 = c = rb_enc_codepoint_len(s, send, &clen, e1);
tlen = enc == e1 ? clen : rb_enc_codelen(c, enc);
if (c < 256) {
@@ -7260,9 +7076,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
if (enc != e1) may_modify = 1;
}
if ((offset = t - buf) + tlen > max) {
- size_t MAYBE_UNUSED(old) = max + termlen;
max = offset + tlen + (long)((send - s) * 1.2);
- SIZED_REALLOC_N(buf, unsigned char, max + termlen, old);
+ REALLOC_N(buf, char, max + termlen);
t = buf + offset;
}
if (s != t) {
@@ -7278,8 +7093,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
if (!STR_EMBED_P(str)) {
ruby_sized_xfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
}
- TERM_FILL((char *)t, termlen);
- RSTRING(str)->as.heap.ptr = (char *)buf;
+ TERM_FILL(t, termlen);
+ RSTRING(str)->as.heap.ptr = buf;
RSTRING(str)->as.heap.len = t - buf;
STR_SET_NOEMBED(str);
RSTRING(str)->as.heap.aux.capa = max;
@@ -7300,8 +7115,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
* str.tr!(from_str, to_str) -> str or nil
*
* Translates <i>str</i> in place, using the same rules as
- * String#tr. Returns <i>str</i>, or <code>nil</code> if no changes
- * were made.
+ * <code>String#tr</code>. Returns <i>str</i>, or <code>nil</code> if no
+ * changes were made.
*/
static VALUE
@@ -7517,7 +7332,7 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str)
*
* Returns a copy of <i>str</i> with all characters in the intersection of its
* arguments deleted. Uses the same rules for building the set of characters as
- * String#count.
+ * <code>String#count</code>.
*
* "hello".delete "l","lo" #=> "heo"
* "hello".delete "lo" #=> "he"
@@ -7548,7 +7363,7 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
char squeez[TR_TABLE_SIZE];
rb_encoding *enc = 0;
VALUE del = 0, nodel = 0;
- unsigned char *s, *send, *t;
+ char *s, *send, *t;
int i, modify = 0;
int ascompat, singlebyte = single_byte_optimizable(str);
unsigned int save;
@@ -7569,15 +7384,15 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
}
str_modify_keep_cr(str);
- s = t = (unsigned char *)RSTRING_PTR(str);
+ s = t = RSTRING_PTR(str);
if (!s || RSTRING_LEN(str) == 0) return Qnil;
- send = (unsigned char *)RSTRING_END(str);
+ send = RSTRING_END(str);
save = -1;
ascompat = rb_enc_asciicompat(enc);
if (singlebyte) {
while (s < send) {
- unsigned int c = *s++;
+ unsigned int c = *(unsigned char*)s++;
if (c != save || (argc > 0 && !squeez[c])) {
*t++ = save = c;
}
@@ -7588,14 +7403,14 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
unsigned int c;
int clen;
- if (ascompat && (c = *s) < 0x80) {
+ if (ascompat && (c = *(unsigned char*)s) < 0x80) {
if (c != save || (argc > 0 && !squeez[c])) {
*t++ = save = c;
}
s++;
}
else {
- c = rb_enc_codepoint_len((char *)s, (char *)send, &clen, enc);
+ c = rb_enc_codepoint_len(s, send, &clen, enc);
if (c != save || (argc > 0 && !tr_find(c, squeez, del, nodel))) {
if (t != s) rb_enc_mbcput(c, t, enc);
@@ -7607,9 +7422,9 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
}
}
- TERM_FILL((char *)t, TERM_LEN(str));
- if ((char *)t - RSTRING_PTR(str) != RSTRING_LEN(str)) {
- STR_SET_LEN(str, (char *)t - RSTRING_PTR(str));
+ TERM_FILL(t, TERM_LEN(str));
+ if (t - RSTRING_PTR(str) != RSTRING_LEN(str)) {
+ STR_SET_LEN(str, t - RSTRING_PTR(str));
modify = 1;
}
@@ -7622,11 +7437,11 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
* call-seq:
* str.squeeze([other_str]*) -> new_str
*
- * Builds a set of characters from the <i>other_str</i> parameter(s)
- * using the procedure described for String#count. Returns a new
- * string where runs of the same character that occur in this set are
- * replaced by a single character. If no arguments are given, all
- * runs of identical characters are replaced by a single character.
+ * Builds a set of characters from the <i>other_str</i> parameter(s) using the
+ * procedure described for <code>String#count</code>. Returns a new string
+ * where runs of the same character that occur in this set are replaced by a
+ * single character. If no arguments are given, all runs of identical
+ * characters are replaced by a single character.
*
* "yellow moon".squeeze #=> "yelow mon"
* " now is the".squeeze(" ") #=> " now is the"
@@ -7646,7 +7461,7 @@ rb_str_squeeze(int argc, VALUE *argv, VALUE str)
* call-seq:
* str.tr_s!(from_str, to_str) -> str or nil
*
- * Performs String#tr_s processing on <i>str</i> in place,
+ * Performs <code>String#tr_s</code> processing on <i>str</i> in place,
* returning <i>str</i>, or <code>nil</code> if no changes were made.
*/
@@ -7661,8 +7476,8 @@ rb_str_tr_s_bang(VALUE str, VALUE src, VALUE repl)
* call-seq:
* str.tr_s(from_str, to_str) -> new_str
*
- * Processes a copy of <i>str</i> as described under String#tr, then
- * removes duplicate characters in regions that were affected by the
+ * Processes a copy of <i>str</i> as described under <code>String#tr</code>,
+ * then removes duplicate characters in regions that were affected by the
* translation.
*
* "hello".tr_s('l', 'r') #=> "hero"
@@ -7807,49 +7622,19 @@ static const char isspacetable[256] = {
#define ascii_isspace(c) isspacetable[(unsigned char)(c)]
-static long
-split_string(VALUE result, VALUE str, long beg, long len, long empty_count)
-{
- if (empty_count >= 0 && len == 0) {
- return empty_count + 1;
- }
- if (empty_count > 0) {
- /* make different substrings */
- if (result) {
- do {
- rb_ary_push(result, str_new_empty(str));
- } while (--empty_count > 0);
- }
- else {
- do {
- rb_yield(str_new_empty(str));
- } while (--empty_count > 0);
- }
- }
- str = rb_str_subseq(str, beg, len);
- if (result) {
- rb_ary_push(result, str);
- }
- else {
- rb_yield(str);
- }
- return empty_count;
-}
-
/*
* call-seq:
- * str.split(pattern=nil, [limit]) -> an_array
- * str.split(pattern=nil, [limit]) {|sub| block } -> str
+ * str.split(pattern=nil, [limit]) -> an_array
*
* Divides <i>str</i> into substrings based on a delimiter, returning an array
* of these substrings.
*
- * If <i>pattern</i> is a String, then its contents are used as
+ * If <i>pattern</i> is a <code>String</code>, then its contents are used as
* the delimiter when splitting <i>str</i>. If <i>pattern</i> is a single
- * space, <i>str</i> is split on whitespace, with leading and trailing
- * whitespace and runs of contiguous whitespace characters ignored.
+ * space, <i>str</i> is split on whitespace, with leading whitespace and runs
+ * of contiguous whitespace characters ignored.
*
- * If <i>pattern</i> is a Regexp, <i>str</i> is divided where the
+ * If <i>pattern</i> is a <code>Regexp</code>, <i>str</i> is divided where the
* pattern matches. Whenever the pattern matches a zero-length string,
* <i>str</i> is split into individual characters. If <i>pattern</i> contains
* groups, the respective matches will be returned in the array as well.
@@ -7870,8 +7655,8 @@ split_string(VALUE result, VALUE str, long beg, long len, long empty_count)
* When the input +str+ is empty an empty Array is returned as the string is
* considered to have no fields to split.
*
- * " now's the time ".split #=> ["now's", "the", "time"]
- * " now's the time ".split(' ') #=> ["now's", "the", "time"]
+ * " now's the time".split #=> ["now's", "the", "time"]
+ * " now's the time".split(' ') #=> ["now's", "the", "time"]
* " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"]
* "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"]
* "hello".split(//) #=> ["h", "e", "l", "l", "o"]
@@ -7886,9 +7671,6 @@ split_string(VALUE result, VALUE str, long beg, long len, long empty_count)
* "1:2:3".split(/(:)()()/, 2) #=> ["1", ":", "", "", "2:3"]
*
* "".split(',', -1) #=> []
- *
- * If a block is given, invoke the block with each split substring.
- *
*/
static VALUE
@@ -7897,28 +7679,21 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
rb_encoding *enc;
VALUE spat;
VALUE limit;
- enum {awk, string, regexp, chars} split_type;
- long beg, end, i = 0, empty_count = -1;
+ enum {awk, string, regexp} split_type;
+ long beg, end, i = 0;
int lim = 0;
VALUE result, tmp;
- result = rb_block_given_p() ? Qfalse : Qnil;
if (rb_scan_args(argc, argv, "02", &spat, &limit) == 2) {
lim = NUM2INT(limit);
if (lim <= 0) limit = Qnil;
else if (lim == 1) {
if (RSTRING_LEN(str) == 0)
- return result ? rb_ary_new2(0) : str;
- tmp = rb_str_dup(str);
- if (!result) {
- rb_yield(tmp);
- return str;
- }
- return rb_ary_new3(1, tmp);
+ return rb_ary_new2(0);
+ return rb_ary_new3(1, rb_str_dup(str));
}
i = 1;
}
- if (NIL_P(limit) && !lim) empty_count = 0;
enc = STR_ENC_GET(str);
split_type = regexp;
@@ -7931,9 +7706,6 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
else if (!(spat = rb_fs_check(spat))) {
rb_raise(rb_eTypeError, "value of $; must be String or Regexp");
}
- else {
- rb_warn("$; is set to non-nil value");
- }
if (split_type != awk) {
if (BUILTIN_TYPE(spat) == T_STRING) {
rb_encoding *enc2 = STR_ENC_GET(spat);
@@ -7942,7 +7714,8 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
split_type = string;
if (RSTRING_LEN(spat) == 0) {
/* Special case - split into chars */
- split_type = chars;
+ spat = rb_reg_regcomp(spat);
+ split_type = regexp;
}
else if (rb_enc_asciicompat(enc2) == 1) {
if (RSTRING_LEN(spat) == 1 && RSTRING_PTR(spat)[0] == ' ') {
@@ -7959,13 +7732,11 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
}
}
-#define SPLIT_STR(beg, len) (empty_count = split_string(result, str, beg, len, empty_count))
-
- if (result) result = rb_ary_new();
+ result = rb_ary_new();
beg = 0;
- char *ptr = RSTRING_PTR(str);
- char *eptr = RSTRING_END(str);
if (split_type == awk) {
+ char *ptr = RSTRING_PTR(str);
+ char *eptr = RSTRING_END(str);
char *bptr = ptr;
int skip = 1;
unsigned int c;
@@ -7985,7 +7756,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
}
}
else if (ascii_isspace(c)) {
- SPLIT_STR(beg, end-beg);
+ rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
skip = 1;
beg = ptr - bptr;
if (!NIL_P(limit)) ++i;
@@ -8012,7 +7783,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
}
}
else if (rb_isspace(c)) {
- SPLIT_STR(beg, end-beg);
+ rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
skip = 1;
beg = ptr - bptr;
if (!NIL_P(limit)) ++i;
@@ -8024,8 +7795,10 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
}
}
else if (split_type == string) {
+ char *ptr = RSTRING_PTR(str);
char *str_start = ptr;
char *substr_start = ptr;
+ char *eptr = RSTRING_END(str);
char *sptr = RSTRING_PTR(spat);
long slen = RSTRING_LEN(spat);
@@ -8039,77 +7812,77 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
ptr = t;
continue;
}
- SPLIT_STR(substr_start - str_start, (ptr+end) - substr_start);
+ rb_ary_push(result, rb_str_subseq(str, substr_start - str_start,
+ (ptr+end) - substr_start));
ptr += end + slen;
substr_start = ptr;
if (!NIL_P(limit) && lim <= ++i) break;
}
beg = ptr - str_start;
}
- else if (split_type == chars) {
- char *str_start = ptr;
- int n;
-
- mustnot_broken(str);
- enc = rb_enc_get(str);
- while (ptr < eptr &&
- (n = rb_enc_precise_mbclen(ptr, eptr, enc)) > 0) {
- SPLIT_STR(ptr - str_start, n);
- ptr += n;
- if (!NIL_P(limit) && lim <= ++i) break;
- }
- beg = ptr - str_start;
- }
else {
+ char *ptr = RSTRING_PTR(str);
long len = RSTRING_LEN(str);
long start = beg;
long idx;
int last_null = 0;
struct re_registers *regs;
- VALUE match = 0;
- for (; (end = rb_reg_search(spat, str, start, 0)) >= 0;
- (match ? (rb_match_unbusy(match), rb_backref_set(match)) : (void)0)) {
- match = rb_backref_get();
- if (!result) rb_match_busy(match);
- regs = RMATCH_REGS(match);
+ while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
+ regs = RMATCH_REGS(rb_backref_get());
if (start == end && BEG(0) == END(0)) {
if (!ptr) {
- SPLIT_STR(0, 0);
+ rb_ary_push(result, str_new_empty(str));
break;
}
else if (last_null == 1) {
- SPLIT_STR(beg, rb_enc_fast_mbclen(ptr+beg, eptr, enc));
+ rb_ary_push(result, rb_str_subseq(str, beg,
+ rb_enc_fast_mbclen(ptr+beg,
+ ptr+len,
+ enc)));
beg = start;
}
else {
if (start == len)
start++;
else
- start += rb_enc_fast_mbclen(ptr+start,eptr,enc);
+ start += rb_enc_fast_mbclen(ptr+start,ptr+len,enc);
last_null = 1;
continue;
}
}
else {
- SPLIT_STR(beg, end-beg);
+ rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
beg = start = END(0);
}
last_null = 0;
for (idx=1; idx < regs->num_regs; idx++) {
if (BEG(idx) == -1) continue;
- SPLIT_STR(BEG(idx), END(idx)-BEG(idx));
+ if (BEG(idx) == END(idx))
+ tmp = str_new_empty(str);
+ else
+ tmp = rb_str_subseq(str, BEG(idx), END(idx)-BEG(idx));
+ rb_ary_push(result, tmp);
}
if (!NIL_P(limit) && lim <= ++i) break;
}
- if (match) rb_match_unbusy(match);
}
if (RSTRING_LEN(str) > 0 && (!NIL_P(limit) || RSTRING_LEN(str) > beg || lim < 0)) {
- SPLIT_STR(beg, RSTRING_LEN(str)-beg);
+ if (RSTRING_LEN(str) == beg)
+ tmp = str_new_empty(str);
+ else
+ tmp = rb_str_subseq(str, beg, RSTRING_LEN(str)-beg);
+ rb_ary_push(result, tmp);
+ }
+ if (NIL_P(limit) && lim == 0) {
+ long len;
+ while ((len = RARRAY_LEN(result)) > 0 &&
+ (tmp = RARRAY_AREF(result, len-1), RSTRING_LEN(tmp) == 0))
+ rb_ary_pop(result);
}
- return result ? result : str;
+ return result;
}
VALUE
@@ -8122,7 +7895,22 @@ rb_str_split(VALUE str, const char *sep0)
return rb_str_split_m(1, &sep, str);
}
-#define WANTARRAY(m, size) (!rb_block_given_p() ? rb_ary_new_capa(size) : 0)
+static int
+enumerator_wantarray(const char *method)
+{
+ if (rb_block_given_p()) {
+#if STRING_ENUMERATORS_WANTARRAY
+ rb_warn("given block not used");
+#else
+ rb_warning("passing a block to String#%s is deprecated", method);
+ return 0;
+#endif
+ }
+ return 1;
+}
+
+#define WANTARRAY(m, size) \
+ (enumerator_wantarray(m) ? rb_ary_new_capa(size) : 0)
static inline int
enumerator_element(VALUE ary, VALUE e)
@@ -8289,8 +8077,8 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
/*
* call-seq:
- * str.each_line(separator=$/, chomp: false) {|substr| block } -> str
- * str.each_line(separator=$/, chomp: false) -> an_enumerator
+ * str.each_line(separator=$/ [, getline_args]) {|substr| block } -> str
+ * str.each_line(separator=$/ [, getline_args]) -> an_enumerator
*
* Splits <i>str</i> using the supplied parameter as the record
* separator (<code>$/</code> by default), passing each substring in
@@ -8298,40 +8086,30 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
* supplied, the string is split into paragraphs delimited by
* multiple successive newlines.
*
- * If +chomp+ is +true+, +separator+ will be removed from the end of each
- * line.
+ * See IO.readlines for details about getline_args.
*
* If no block is given, an enumerator is returned instead.
*
+ * print "Example one\n"
* "hello\nworld".each_line {|s| p s}
- * # prints:
- * # "hello\n"
- * # "world"
- *
+ * print "Example two\n"
* "hello\nworld".each_line('l') {|s| p s}
- * # prints:
- * # "hel"
- * # "l"
- * # "o\nworl"
- * # "d"
- *
+ * print "Example three\n"
* "hello\n\n\nworld".each_line('') {|s| p s}
- * # prints
- * # "hello\n\n"
- * # "world"
- *
- * "hello\nworld".each_line(chomp: true) {|s| p s}
- * # prints:
- * # "hello"
- * # "world"
*
- * "hello\nworld".each_line('l', chomp: true) {|s| p s}
- * # prints:
- * # "he"
- * # ""
- * # "o\nwor"
- * # "d"
+ * <em>produces:</em>
*
+ * Example one
+ * "hello\n"
+ * "world"
+ * Example two
+ * "hel"
+ * "l"
+ * "o\nworl"
+ * "d"
+ * Example three
+ * "hello\n\n"
+ * "world"
*/
static VALUE
@@ -8343,18 +8121,11 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
/*
* call-seq:
- * str.lines(separator=$/, chomp: false) -> an_array
+ * str.lines(separator=$/) -> an_array
*
* Returns an array of lines in <i>str</i> split using the supplied
* record separator (<code>$/</code> by default). This is a
- * shorthand for <code>str.each_line(separator, getline_args).to_a</code>.
- *
- * If +chomp+ is +true+, +separator+ will be removed from the end of each
- * line.
- *
- * "hello\nworld\n".lines #=> ["hello\n", "world\n"]
- * "hello world".lines(' ') #=> ["hello ", " ", "world"]
- * "hello\nworld\n".lines(chomp: true) #=> ["hello", "world"]
+ * shorthand for <code>str.each_line(separator).to_a</code>.
*
* If a block is given, which is a deprecated form, works the same as
* <code>each_line</code>.
@@ -8539,7 +8310,7 @@ rb_str_enumerate_codepoints(VALUE str, VALUE ary)
* str.each_codepoint {|integer| block } -> str
* str.each_codepoint -> an_enumerator
*
- * Passes the Integer ordinal of each character in <i>str</i>,
+ * Passes the <code>Integer</code> ordinal of each character in <i>str</i>,
* also known as a <i>codepoint</i> when applied to Unicode strings to the
* given block. For encodings other than UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE),
* values are directly derived from the binary representation
@@ -8565,7 +8336,7 @@ rb_str_each_codepoint(VALUE str)
* call-seq:
* str.codepoints -> an_array
*
- * Returns an array of the Integer ordinals of the
+ * Returns an array of the <code>Integer</code> ordinals of the
* characters in <i>str</i>. This is a shorthand for
* <code>str.each_codepoint.to_a</code>.
*
@@ -8592,35 +8363,11 @@ get_reg_grapheme_cluster(rb_encoding *enc)
reg_grapheme_cluster = reg_grapheme_cluster_utf8;
}
if (!reg_grapheme_cluster) {
- const OnigUChar source_ascii[] = "\\X";
- OnigErrorInfo einfo;
- const OnigUChar *source = source_ascii;
- size_t source_len = sizeof(source_ascii) - 1;
- switch (encidx) {
-#define CHARS_16BE(x) (OnigUChar)((x)>>8), (OnigUChar)(x)
-#define CHARS_16LE(x) (OnigUChar)(x), (OnigUChar)((x)>>8)
-#define CHARS_32BE(x) CHARS_16BE((x)>>16), CHARS_16BE(x)
-#define CHARS_32LE(x) CHARS_16LE(x), CHARS_16LE((x)>>16)
-#define CASE_UTF(e) \
- case ENCINDEX_UTF_##e: { \
- static const OnigUChar source_UTF_##e[] = {CHARS_##e('\\'), CHARS_##e('X')}; \
- source = source_UTF_##e; \
- source_len = sizeof(source_UTF_##e); \
- break; \
- }
- CASE_UTF(16BE); CASE_UTF(16LE); CASE_UTF(32BE); CASE_UTF(32LE);
-#undef CASE_UTF
-#undef CHARS_16BE
-#undef CHARS_16LE
-#undef CHARS_32BE
-#undef CHARS_32LE
- }
- int r = onig_new(&reg_grapheme_cluster, source, source + source_len,
- ONIG_OPTION_DEFAULT, enc, OnigDefaultSyntax, &einfo);
+ const OnigUChar source[] = "\\X";
+ int r = onig_new(&reg_grapheme_cluster, source, source + sizeof(source) - 1,
+ ONIG_OPTION_DEFAULT, enc, OnigDefaultSyntax, NULL);
if (r) {
- UChar message[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(message, r, &einfo);
- rb_fatal("cannot compile grapheme cluster regexp: %s", (char *)message);
+ rb_bug("cannot compile grapheme cluster regexp");
}
if (encidx == rb_utf8_encindex()) {
reg_grapheme_cluster_utf8 = reg_grapheme_cluster;
@@ -8679,7 +8426,7 @@ rb_str_enumerate_grapheme_clusters(VALUE str, VALUE ary)
(const OnigUChar *)ptr, (const OnigUChar *)end,
(const OnigUChar *)ptr, NULL, 0);
if (len <= 0) break;
- ENUM_ELEM(ary, rb_str_subseq(str, ptr-ptr0, len));
+ ENUM_ELEM(ary, rb_str_subseq(str, ptr-ptr0, len));
ptr += len;
}
RB_GC_GUARD(str);
@@ -8737,7 +8484,7 @@ chopped_length(VALUE str)
beg = RSTRING_PTR(str);
end = beg + RSTRING_LEN(str);
- if (beg >= end) return 0;
+ if (beg > end) return 0;
p = rb_enc_prev_char(beg, end, end, enc);
if (!p) return 0;
if (p > beg && rb_enc_ascget(p, end, 0, enc) == '\n') {
@@ -8751,9 +8498,9 @@ chopped_length(VALUE str)
* call-seq:
* str.chop! -> str or nil
*
- * Processes <i>str</i> as for String#chop, returning <i>str</i>, or
- * <code>nil</code> if <i>str</i> is the empty string. See also
- * String#chomp!.
+ * Processes <i>str</i> as for <code>String#chop</code>, returning <i>str</i>,
+ * or <code>nil</code> if <i>str</i> is the empty string. See also
+ * <code>String#chomp!</code>.
*/
static VALUE
@@ -8778,12 +8525,11 @@ rb_str_chop_bang(VALUE str)
* call-seq:
* str.chop -> new_str
*
- * Returns a new String with the last character removed. If the
- * string ends with <code>\r\n</code>, both characters are
- * removed. Applying <code>chop</code> to an empty string returns an
- * empty string. String#chomp is often a safer alternative, as it
- * leaves the string unchanged if it doesn't end in a record
- * separator.
+ * Returns a new <code>String</code> with the last character removed. If the
+ * string ends with <code>\r\n</code>, both characters are removed. Applying
+ * <code>chop</code> to an empty string returns an empty
+ * string. <code>String#chomp</code> is often a safer alternative, as it leaves
+ * the string unchanged if it doesn't end in a record separator.
*
* "string\r\n".chop #=> "string"
* "string\n\r".chop #=> "string\n"
@@ -8936,9 +8682,8 @@ rb_str_chomp_string(VALUE str, VALUE rs)
* call-seq:
* str.chomp!(separator=$/) -> str or nil
*
- * Modifies <i>str</i> in place as described for String#chomp,
- * returning <i>str</i>, or <code>nil</code> if no modifications were
- * made.
+ * Modifies <i>str</i> in place as described for <code>String#chomp</code>,
+ * returning <i>str</i>, or <code>nil</code> if no modifications were made.
*/
static VALUE
@@ -8957,7 +8702,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
* call-seq:
* str.chomp(separator=$/) -> new_str
*
- * Returns a new String with the given record separator removed
+ * Returns a new <code>String</code> with the given record separator removed
* from the end of <i>str</i> (if present). If <code>$/</code> has not been
* changed from the default Ruby record separator, then <code>chomp</code> also
* removes carriage return characters (that is it will remove <code>\n</code>,
@@ -9010,11 +8755,11 @@ lstrip_offset(VALUE str, const char *s, const char *e, rb_encoding *enc)
* call-seq:
* str.lstrip! -> self or nil
*
- * Removes leading whitespace from the receiver.
- * Returns the altered receiver, or +nil+ if no change was made.
- * See also String#rstrip! and String#strip!.
+ * Removes leading whitespace from <i>str</i>, returning <code>nil</code> if no
+ * change was made. See also <code>String#rstrip!</code> and
+ * <code>String#strip!</code>.
*
- * Refer to String#strip for the definition of whitespace.
+ * Refer to <code>strip</code> for the definition of whitespace.
*
* " hello ".lstrip! #=> "hello "
* "hello ".lstrip! #=> nil
@@ -9050,10 +8795,10 @@ rb_str_lstrip_bang(VALUE str)
* call-seq:
* str.lstrip -> new_str
*
- * Returns a copy of the receiver with leading whitespace removed.
- * See also String#rstrip and String#strip.
+ * Returns a copy of <i>str</i> with leading whitespace removed. See also
+ * <code>String#rstrip</code> and <code>String#strip</code>.
*
- * Refer to String#strip for the definition of whitespace.
+ * Refer to <code>strip</code> for the definition of whitespace.
*
* " hello ".lstrip #=> "hello "
* "hello".lstrip #=> "hello"
@@ -9100,11 +8845,11 @@ rstrip_offset(VALUE str, const char *s, const char *e, rb_encoding *enc)
* call-seq:
* str.rstrip! -> self or nil
*
- * Removes trailing whitespace from the receiver.
- * Returns the altered receiver, or +nil+ if no change was made.
- * See also String#lstrip! and String#strip!.
+ * Removes trailing whitespace from <i>str</i>, returning <code>nil</code> if
+ * no change was made. See also <code>String#lstrip!</code> and
+ * <code>String#strip!</code>.
*
- * Refer to String#strip for the definition of whitespace.
+ * Refer to <code>strip</code> for the definition of whitespace.
*
* " hello ".rstrip! #=> " hello"
* " hello".rstrip! #=> nil
@@ -9139,10 +8884,10 @@ rb_str_rstrip_bang(VALUE str)
* call-seq:
* str.rstrip -> new_str
*
- * Returns a copy of the receiver with trailing whitespace removed.
- * See also String#lstrip and String#strip.
+ * Returns a copy of <i>str</i> with trailing whitespace removed. See also
+ * <code>String#lstrip</code> and <code>String#strip</code>.
*
- * Refer to String#strip for the definition of whitespace.
+ * Refer to <code>strip</code> for the definition of whitespace.
*
* " hello ".rstrip #=> " hello"
* "hello".rstrip #=> "hello"
@@ -9166,15 +8911,12 @@ rb_str_rstrip(VALUE str)
/*
* call-seq:
- * str.strip! -> self or nil
+ * str.strip! -> str or nil
*
- * Removes leading and trailing whitespace from the receiver.
- * Returns the altered receiver, or +nil+ if there was no change.
+ * Removes leading and trailing whitespace from <i>str</i>. Returns
+ * <code>nil</code> if <i>str</i> was not altered.
*
- * Refer to String#strip for the definition of whitespace.
- *
- * " hello ".strip! #=> "hello"
- * "hello".strip! #=> nil
+ * Refer to <code>strip</code> for the definition of whitespace.
*/
static VALUE
@@ -9210,7 +8952,7 @@ rb_str_strip_bang(VALUE str)
* call-seq:
* str.strip -> new_str
*
- * Returns a copy of the receiver with leading and trailing whitespace removed.
+ * Returns a copy of <i>str</i> with leading and trailing whitespace removed.
*
* Whitespace is defined as any of the following characters:
* null, horizontal tab, line feed, vertical tab, form feed, carriage return, space.
@@ -9218,7 +8960,6 @@ rb_str_strip_bang(VALUE str)
* " hello ".strip #=> "hello"
* "\tgoodbye\r\n".strip #=> "goodbye"
* "\x00\t\n\v\f\r ".strip #=> ""
- * "hello".strip #=> "hello"
*/
static VALUE
@@ -9270,6 +9011,7 @@ scan_once(VALUE str, VALUE pat, long *start, int set_backref_str)
}
if (!regs || regs->num_regs == 1) {
result = rb_str_subseq(str, pos, end - pos);
+ OBJ_INFECT(result, pat);
return result;
}
result = rb_ary_new2(regs->num_regs);
@@ -9277,6 +9019,7 @@ scan_once(VALUE str, VALUE pat, long *start, int set_backref_str)
VALUE s = Qnil;
if (BEG(i) >= 0) {
s = rb_str_subseq(str, BEG(i), END(i)-BEG(i));
+ OBJ_INFECT(s, pat);
}
rb_ary_push(result, s);
}
@@ -9293,7 +9036,7 @@ scan_once(VALUE str, VALUE pat, long *start, int set_backref_str)
* str.scan(pattern) {|match, ...| block } -> str
*
* Both forms iterate through <i>str</i>, matching the pattern (which may be a
- * Regexp or a String). For each match, a result is
+ * <code>Regexp</code> or a <code>String</code>). For each match, a result is
* generated and either added to the result array or passed to the block. If
* the pattern contains no groups, each individual result consists of the
* matched string, <code>$&</code>. If the pattern contains groups, each
@@ -9401,60 +9144,17 @@ rb_str_oct(VALUE str)
* call-seq:
* str.crypt(salt_str) -> new_str
*
- * Returns the string generated by calling <code>crypt(3)</code>
- * standard library function with <code>str</code> and
- * <code>salt_str</code>, in this order, as its arguments. Please do
- * not use this method any longer. It is legacy; provided only for
- * backward compatibility with ruby scripts in earlier days. It is
- * bad to use in contemporary programs for several reasons:
- *
- * * Behaviour of C's <code>crypt(3)</code> depends on the OS it is
- * run. The generated string lacks data portability.
- *
- * * On some OSes such as Mac OS, <code>crypt(3)</code> never fails
- * (i.e. silently ends up in unexpected results).
- *
- * * On some OSes such as Mac OS, <code>crypt(3)</code> is not
- * thread safe.
- *
- * * So-called "traditional" usage of <code>crypt(3)</code> is very
- * very very weak. According to its manpage, Linux's traditional
- * <code>crypt(3)</code> output has only 2**56 variations; too
- * easy to brute force today. And this is the default behaviour.
- *
- * * In order to make things robust some OSes implement so-called
- * "modular" usage. To go through, you have to do a complex
- * build-up of the <code>salt_str</code> parameter, by hand.
- * Failure in generation of a proper salt string tends not to
- * yield any errors; typos in parameters are normally not
- * detectable.
- *
- * * For instance, in the following example, the second invocation
- * of String#crypt is wrong; it has a typo in "round=" (lacks
- * "s"). However the call does not fail and something unexpected
- * is generated.
- *
- * "foo".crypt("$5$rounds=1000$salt$") # OK, proper usage
- * "foo".crypt("$5$round=1000$salt$") # Typo not detected
- *
- * * Even in the "modular" mode, some hash functions are considered
- * archaic and no longer recommended at all; for instance module
- * <code>$1$</code> is officially abandoned by its author: see
- * http://phk.freebsd.dk/sagas/md5crypt_eol.html . For another
- * instance module <code>$3$</code> is considered completely
- * broken: see the manpage of FreeBSD.
+ * Applies a one-way cryptographic hash to <i>str</i> by invoking the
+ * standard library function <code>crypt(3)</code> with the given
+ * salt string. While the format and the result are system and
+ * implementation dependent, using a salt matching the regular
+ * expression <code>\A[a-zA-Z0-9./]{2}</code> should be valid and
+ * safe on any platform, in which only the first two characters are
+ * significant.
*
- * * On some OS such as Mac OS, there is no modular mode. Yet, as
- * written above, <code>crypt(3)</code> on Mac OS never fails.
- * This means even if you build up a proper salt string it
- * generates a traditional DES hash anyways, and there is no way
- * for you to be aware of.
- *
- * "foo".crypt("$5$rounds=1000$salt$") # => "$5fNPQMxC5j6."
- *
- * If for some reason you cannot migrate to other secure contemporary
- * password hashing algorithms, install the string-crypt gem and
- * <code>require 'string/crypt'</code> to continue using it.
+ * This method is for use in system specific scripts, so if you want
+ * a cross-platform hash function consider using Digest or OpenSSL
+ * instead.
*/
static VALUE
@@ -9510,6 +9210,7 @@ rb_str_crypt(VALUE str, VALUE salt)
}
result = rb_str_new_cstr(res);
CRYPT_END();
+ FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt));
return result;
}
@@ -9518,7 +9219,7 @@ rb_str_crypt(VALUE str, VALUE salt)
* call-seq:
* str.ord -> integer
*
- * Returns the Integer ordinal of a one-character string.
+ * Return the <code>Integer</code> ordinal of a one-character string.
*
* "a".ord #=> 97
*/
@@ -9536,7 +9237,7 @@ rb_str_ord(VALUE s)
* str.sum(n=16) -> integer
*
* Returns a basic <em>n</em>-bit checksum of the characters in <i>str</i>,
- * where <em>n</em> is the optional Integer parameter, defaulting
+ * where <em>n</em> is the optional <code>Integer</code> parameter, defaulting
* to 16. The result is simply the sum of the binary value of each byte in
* <i>str</i> modulo <code>2**n - 1</code>. This is not a particularly good
* checksum.
@@ -9545,14 +9246,21 @@ rb_str_ord(VALUE s)
static VALUE
rb_str_sum(int argc, VALUE *argv, VALUE str)
{
- int bits = 16;
+ VALUE vbits;
+ int bits;
char *ptr, *p, *pend;
long len;
VALUE sum = INT2FIX(0);
unsigned long sum0 = 0;
- if (rb_check_arity(argc, 0, 1) && (bits = NUM2INT(argv[0])) < 0) {
- bits = 0;
+ if (argc == 0) {
+ bits = 16;
+ }
+ else {
+ rb_scan_args(argc, argv, "01", &vbits);
+ bits = NUM2INT(vbits);
+ if (bits < 0)
+ bits = 0;
}
ptr = p = RSTRING_PTR(str);
len = RSTRING_LEN(str);
@@ -9677,6 +9385,8 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
}
TERM_FILL(p, termlen);
STR_SET_LEN(res, p-RSTRING_PTR(res));
+ OBJ_INFECT_RAW(res, str);
+ if (!NIL_P(pad)) OBJ_INFECT_RAW(res, pad);
rb_enc_associate(res, enc);
if (argc == 2)
cr = ENC_CODERANGE_AND(cr, ENC_CODERANGE(pad));
@@ -9693,7 +9403,7 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
* str.ljust(integer, padstr=' ') -> new_str
*
* If <i>integer</i> is greater than the length of <i>str</i>, returns a new
- * String of length <i>integer</i> with <i>str</i> left justified
+ * <code>String</code> of length <i>integer</i> with <i>str</i> left justified
* and padded with <i>padstr</i>; otherwise, returns <i>str</i>.
*
* "hello".ljust(4) #=> "hello"
@@ -9713,7 +9423,7 @@ rb_str_ljust(int argc, VALUE *argv, VALUE str)
* str.rjust(integer, padstr=' ') -> new_str
*
* If <i>integer</i> is greater than the length of <i>str</i>, returns a new
- * String of length <i>integer</i> with <i>str</i> right justified
+ * <code>String</code> of length <i>integer</i> with <i>str</i> right justified
* and padded with <i>padstr</i>; otherwise, returns <i>str</i>.
*
* "hello".rjust(4) #=> "hello"
@@ -9844,10 +9554,8 @@ rb_str_rpartition(VALUE str, VALUE sep)
* str.start_with?([prefixes]+) -> true or false
*
* Returns true if +str+ starts with one of the +prefixes+ given.
- * Each of the +prefixes+ should be a String or a Regexp.
*
* "hello".start_with?("hell") #=> true
- * "hello".start_with?(/H/i) #=> true
*
* # returns true if one of the prefixes matches.
* "hello".start_with?("heaven", "hell") #=> true
@@ -9861,11 +9569,14 @@ rb_str_start_with(int argc, VALUE *argv, VALUE str)
for (i=0; i<argc; i++) {
VALUE tmp = argv[i];
- if (RB_TYPE_P(tmp, T_REGEXP)) {
- if (rb_reg_start_with_p(tmp, str))
- return Qtrue;
- }
- else {
+ switch (TYPE(tmp)) {
+ case T_REGEXP:
+ {
+ bool r = rb_reg_start_with_p(tmp, str);
+ if (r) return Qtrue;
+ }
+ break;
+ default:
StringValue(tmp);
rb_enc_check(str, tmp);
if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
@@ -10091,9 +9802,6 @@ rb_fs_setter(VALUE val, ID id, VALUE *var)
"value of %"PRIsVALUE" must be String or Regexp",
rb_id2str(id));
}
- if (!NIL_P(val)) {
- rb_warn_deprecated("`$;'", NULL);
- }
*var = val;
}
@@ -10126,6 +9834,7 @@ rb_str_b(VALUE str)
{
VALUE str2 = str_alloc(rb_cString);
str_replace_shared_without_enc(str2, str);
+ OBJ_INFECT_RAW(str2, str);
ENC_CODERANGE_CLEAR(str2);
return str2;
}
@@ -10268,9 +9977,9 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
{
int encidx;
VALUE buf = Qnil;
- const char *rep, *p, *e, *p1, *sp;
+ const char *rep;
long replen = -1;
- long slen;
+ int tainted = 0;
if (rb_block_given_p()) {
if (!NIL_P(repl))
@@ -10283,6 +9992,7 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
if (!NIL_P(repl)) {
repl = str_compat_and_valid(repl, enc);
+ tainted = OBJ_TAINTED_RAW(repl);
}
if (rb_enc_dummy_p(enc)) {
@@ -10295,13 +10005,10 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
rep = replace; replen = (int)sizeof(replace); \
} while (0)
- slen = RSTRING_LEN(str);
- p = RSTRING_PTR(str);
- e = RSTRING_END(str);
- p1 = p;
- sp = p;
-
if (rb_enc_asciicompat(enc)) {
+ const char *p = RSTRING_PTR(str);
+ const char *e = RSTRING_END(str);
+ const char *p1 = p;
int rep7bit_p;
if (!replen) {
rep = NULL;
@@ -10366,8 +10073,8 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
}
else {
repl = rb_yield(rb_enc_str_new(p, clen, enc));
- str_mod_check(str, sp, slen);
repl = str_compat_and_valid(repl, enc);
+ tainted |= OBJ_TAINTED_RAW(repl);
rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl));
if (ENC_CODERANGE(repl) == ENC_CODERANGE_VALID)
cr = ENC_CODERANGE_VALID;
@@ -10401,8 +10108,8 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
}
else {
repl = rb_yield(rb_enc_str_new(p, e-p, enc));
- str_mod_check(str, sp, slen);
repl = str_compat_and_valid(repl, enc);
+ tainted |= OBJ_TAINTED_RAW(repl);
rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl));
if (ENC_CODERANGE(repl) == ENC_CODERANGE_VALID)
cr = ENC_CODERANGE_VALID;
@@ -10411,6 +10118,9 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
}
else {
/* ASCII incompatible */
+ const char *p = RSTRING_PTR(str);
+ const char *e = RSTRING_END(str);
+ const char *p1 = p;
long mbminlen = rb_enc_mbminlen(enc);
if (!replen) {
rep = NULL;
@@ -10467,8 +10177,8 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
}
else {
repl = rb_yield(rb_enc_str_new(p, clen, enc));
- str_mod_check(str, sp, slen);
repl = str_compat_and_valid(repl, enc);
+ tainted |= OBJ_TAINTED_RAW(repl);
rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl));
}
p += clen;
@@ -10494,13 +10204,14 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
}
else {
repl = rb_yield(rb_enc_str_new(p, e-p, enc));
- str_mod_check(str, sp, slen);
repl = str_compat_and_valid(repl, enc);
+ tainted |= OBJ_TAINTED_RAW(repl);
rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl));
}
}
cr = ENC_CODERANGE_VALID;
}
+ FL_SET_RAW(buf, tainted|OBJ_TAINTED_RAW(str));
ENCODING_CODERANGE_SET(buf, rb_enc_to_index(enc), cr);
return buf;
}
@@ -10565,7 +10276,7 @@ unicode_normalize_common(int argc, VALUE *argv, VALUE str, ID id)
UnicodeNormalizeRequired = 1;
}
argv2[0] = str;
- if (rb_check_arity(argc, 0, 1)) argv2[1] = argv[0];
+ rb_scan_args(argc, argv, "01", &argv2[1]);
return rb_funcallv(mUnicodeNormalize, id, argc+1, argv2);
}
@@ -10636,15 +10347,17 @@ rb_str_unicode_normalized_p(int argc, VALUE *argv, VALUE str)
/**********************************************************************
* Document-class: Symbol
*
- * Symbol objects represent names inside the Ruby interpreter. They
- * are generated using the <code>:name</code> and
- * <code>:"string"</code> literals syntax, and by the various
- * <code>to_sym</code> methods. The same Symbol object will be
- * created for a given name or string for the duration of a program's
- * execution, regardless of the context or meaning of that name. Thus
- * if <code>Fred</code> is a constant in one context, a method in
- * another, and a class in a third, the Symbol <code>:Fred</code>
- * will be the same object in all three contexts.
+ * <code>Symbol</code> objects represent names and some strings
+ * inside the Ruby
+ * interpreter. They are generated using the <code>:name</code> and
+ * <code>:"string"</code> literals
+ * syntax, and by the various <code>to_sym</code> methods. The same
+ * <code>Symbol</code> object will be created for a given name or string
+ * for the duration of a program's execution, regardless of the context
+ * or meaning of that name. Thus if <code>Fred</code> is a constant in
+ * one context, a method in another, and a class in a third, the
+ * <code>Symbol</code> <code>:Fred</code> will be the same object in
+ * all three contexts.
*
* module One
* class Fred
@@ -10704,7 +10417,7 @@ rb_str_symname_p(VALUE sym)
ptr = RSTRING_PTR(sym);
len = RSTRING_LEN(sym);
if ((resenc != enc && !rb_str_is_ascii_only_p(sym)) || len != (long)strlen(ptr) ||
- !rb_enc_symname2_p(ptr, len, enc) || !sym_printable(ptr, ptr + len, enc)) {
+ !rb_enc_symname_p(ptr, enc) || !sym_printable(ptr, ptr + len, enc)) {
return FALSE;
}
return TRUE;
@@ -10731,14 +10444,10 @@ rb_str_quote_unprintable(VALUE str)
return str;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_id_quote_unprintable(ID id)
{
- VALUE str = rb_id2str(id);
- if (!rb_str_symname_p(str)) {
- return rb_str_inspect(str);
- }
- return str;
+ return rb_str_quote_unprintable(rb_id2str(id));
}
/*
@@ -10801,7 +10510,7 @@ rb_sym_to_s(VALUE sym)
* sym.to_sym -> sym
* sym.intern -> sym
*
- * In general, <code>to_sym</code> returns the Symbol corresponding
+ * In general, <code>to_sym</code> returns the <code>Symbol</code> corresponding
* to an object. As <i>sym</i> is already a symbol, <code>self</code> is returned
* in this case.
*/
@@ -10812,8 +10521,8 @@ sym_to_sym(VALUE sym)
return sym;
}
-MJIT_FUNC_EXPORTED VALUE
-rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc)
+VALUE
+rb_sym_proc_call(ID mid, int argc, const VALUE *argv, VALUE passed_proc)
{
VALUE obj;
@@ -10821,7 +10530,7 @@ rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed
rb_raise(rb_eArgError, "no receiver given");
}
obj = argv[0];
- return rb_funcall_with_block_kw(obj, mid, argc - 1, argv + 1, passed_proc, kw_splat);
+ return rb_funcall_with_block(obj, mid, argc - 1, argv + 1, passed_proc);
}
#if 0
@@ -10829,7 +10538,7 @@ rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed
* call-seq:
* sym.to_proc
*
- * Returns a _Proc_ object which responds to the given method by _sym_.
+ * Returns a _Proc_ object which respond to the given method by _sym_.
*
* (1..3).collect(&:to_s) #=> ["1", "2", "3"]
*/
@@ -10881,7 +10590,7 @@ sym_cmp(VALUE sym, VALUE other)
* call-seq:
* sym.casecmp(other_symbol) -> -1, 0, +1, or nil
*
- * Case-insensitive version of Symbol#<=>.
+ * Case-insensitive version of <code>Symbol#<=></code>.
* Currently, case-insensitivity only works on characters A-Z/a-z,
* not all of Unicode. This is different from Symbol#casecmp?.
*
@@ -11076,46 +10785,6 @@ sym_swapcase(int argc, VALUE *argv, VALUE sym)
}
/*
- * call-seq:
- * sym.start_with?([prefixes]+) -> true or false
- *
- * Returns true if +sym+ starts with one of the +prefixes+ given.
- * Each of the +prefixes+ should be a String or a Regexp.
- *
- * :hello.start_with?("hell") #=> true
- * :hello.start_with?(/H/i) #=> true
- *
- * # returns true if one of the prefixes matches.
- * :hello.start_with?("heaven", "hell") #=> true
- * :hello.start_with?("heaven", "paradise") #=> false
- */
-
-static VALUE
-sym_start_with(int argc, VALUE *argv, VALUE sym)
-{
- return rb_str_start_with(argc, argv, rb_sym2str(sym));
-}
-
-/*
- * call-seq:
- * sym.end_with?([suffixes]+) -> true or false
- *
- * Returns true if +sym+ ends with one of the +suffixes+ given.
- *
- * :hello.end_with?("ello") #=> true
- *
- * # returns true if one of the +suffixes+ matches.
- * :hello.end_with?("heaven", "ello") #=> true
- * :hello.end_with?("heaven", "paradise") #=> false
- */
-
-static VALUE
-sym_end_with(int argc, VALUE *argv, VALUE sym)
-{
- return rb_str_end_with(argc, argv, rb_sym2str(sym));
-}
-
-/*
* call-seq:
* sym.encoding -> encoding
*
@@ -11163,37 +10832,15 @@ rb_to_symbol(VALUE name)
}
/*
- * call-seq:
- * Symbol.all_symbols => array
- *
- * Returns an array of all the symbols currently in Ruby's symbol
- * table.
- *
- * Symbol.all_symbols.size #=> 903
- * Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
- * :chown, :EOFError, :$;, :String,
- * :LOCK_SH, :"setuid?", :$<,
- * :default_proc, :compact, :extend,
- * :Tms, :getwd, :$=, :ThreadGroup,
- * :wait2, :$>]
- */
-
-static VALUE
-sym_all_symbols(VALUE _)
-{
- return rb_sym_all_symbols();
-}
-
-/*
- * A String object holds and manipulates an arbitrary sequence of
+ * A <code>String</code> object holds and manipulates an arbitrary sequence of
* bytes, typically representing characters. String objects may be created
- * using String::new or as literals.
+ * using <code>String::new</code> or as literals.
*
* Because of aliasing issues, users of strings should be aware of the methods
- * that modify the contents of a String object. Typically,
+ * that modify the contents of a <code>String</code> object. Typically,
* methods with names ending in ``!'' modify their receiver, while those
- * without a ``!'' return a new String. However, there are
- * exceptions, such as String#[]=.
+ * without a ``!'' return a new <code>String</code>. However, there are
+ * exceptions, such as <code>String#[]=</code>.
*
*/
@@ -11370,7 +11017,7 @@ Init_String(void)
rb_include_module(rb_cSymbol, rb_mComparable);
rb_undef_alloc_func(rb_cSymbol);
rb_undef_method(CLASS_OF(rb_cSymbol), "new");
- rb_define_singleton_method(rb_cSymbol, "all_symbols", sym_all_symbols, 0);
+ rb_define_singleton_method(rb_cSymbol, "all_symbols", rb_sym_all_symbols, 0); /* in symbol.c */
rb_define_method(rb_cSymbol, "==", sym_equal, 1);
rb_define_method(rb_cSymbol, "===", sym_equal, 1);
@@ -11401,8 +11048,5 @@ Init_String(void)
rb_define_method(rb_cSymbol, "capitalize", sym_capitalize, -1);
rb_define_method(rb_cSymbol, "swapcase", sym_swapcase, -1);
- rb_define_method(rb_cSymbol, "start_with?", sym_start_with, -1);
- rb_define_method(rb_cSymbol, "end_with?", sym_end_with, -1);
-
rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0);
}
diff --git a/struct.c b/struct.c
index 3fb5649c99..16b1fe7c62 100644
--- a/struct.c
+++ b/struct.c
@@ -12,7 +12,6 @@
#include "internal.h"
#include "vm_core.h"
#include "id.h"
-#include "transient_heap.h"
/* only for struct[:field] access */
enum {
@@ -139,6 +138,7 @@ static inline int
struct_member_pos(VALUE s, VALUE name)
{
VALUE back = struct_ivar_get(rb_obj_class(s), id_back_members);
+ VALUE const * p;
long j, mask;
if (UNLIKELY(NIL_P(back))) {
@@ -148,6 +148,7 @@ struct_member_pos(VALUE s, VALUE name)
rb_raise(rb_eTypeError, "corrupted struct");
}
+ p = RARRAY_CONST_PTR(back);
mask = RARRAY_LEN(back);
if (mask <= AREF_HASH_THRESHOLD) {
@@ -157,7 +158,7 @@ struct_member_pos(VALUE s, VALUE name)
mask, RSTRUCT_LEN(s));
}
for (j = 0; j < mask; j++) {
- if (RARRAY_AREF(back, j) == name)
+ if (p[j] == name)
return (int)j;
}
return -1;
@@ -172,10 +173,9 @@ struct_member_pos(VALUE s, VALUE name)
j = struct_member_pos_ideal(name, mask);
for (;;) {
- VALUE e = RARRAY_AREF(back, j);
- if (e == name)
- return FIX2INT(RARRAY_AREF(back, j + 1));
- if (!RTEST(e)) {
+ if (p[j] == name)
+ return FIX2INT(p[j + 1]);
+ if (!RTEST(p[j])) {
return -1;
}
j = struct_member_pos_probe(j, mask);
@@ -217,7 +217,7 @@ rb_struct_getmember(VALUE obj, ID id)
}
rb_name_err_raise("`%1$s' is not a struct member", obj, ID2SYM(id));
- UNREACHABLE_RETURN(Qnil);
+ UNREACHABLE;
}
static VALUE rb_struct_ref0(VALUE obj) {return RSTRUCT_GET(obj, 0);}
@@ -250,6 +250,7 @@ static void
rb_struct_modify(VALUE s)
{
rb_check_frozen(s);
+ rb_check_trusted(s);
}
static VALUE
@@ -310,34 +311,29 @@ rb_struct_s_inspect(VALUE klass)
}
static VALUE
-struct_new_kw(int argc, const VALUE *argv, VALUE klass)
-{
- return rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
-}
-
-static VALUE
setup_struct(VALUE nstr, VALUE members)
{
+ const VALUE *ptr_members;
long i, len;
members = struct_set_members(nstr, members);
rb_define_alloc_func(nstr, struct_alloc);
- rb_define_singleton_method(nstr, "new", struct_new_kw, -1);
- rb_define_singleton_method(nstr, "[]", struct_new_kw, -1);
+ rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1);
+ rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1);
rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0);
rb_define_singleton_method(nstr, "inspect", rb_struct_s_inspect, 0);
+ ptr_members = RARRAY_CONST_PTR(members);
len = RARRAY_LEN(members);
for (i=0; i< len; i++) {
- VALUE sym = RARRAY_AREF(members, i);
- ID id = SYM2ID(sym);
+ ID id = SYM2ID(ptr_members[i]);
VALUE off = LONG2NUM(i);
if (i < N_REF_FUNC) {
rb_define_method_id(nstr, id, ref_func[i], 0);
}
else {
- define_aref_method(nstr, sym, off);
+ define_aref_method(nstr, ptr_members[i], off);
}
define_aset_method(nstr, ID2SYM(rb_id_attrset(id)), off);
}
@@ -554,9 +550,6 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
tbl = RHASH_TBL(rest);
for (i=0; i<argc; i++) {
VALUE mem = rb_to_symbol(argv[i]);
- if (rb_is_attrset_sym(mem)) {
- rb_raise(rb_eArgError, "invalid struct member: %"PRIsVALUE, mem);
- }
if (st_insert(tbl, mem, Qtrue)) {
rb_raise(rb_eArgError, "duplicate member: %"PRIsVALUE, mem);
}
@@ -574,7 +567,7 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
setup_struct(st, rest);
rb_ivar_set(st, id_keyword_init, keyword_init);
if (rb_block_given_p()) {
- rb_mod_module_eval(0, 0, st);
+ rb_mod_module_eval(0, 0, st);
}
return st;
@@ -629,7 +622,7 @@ rb_struct_initialize_m(int argc, const VALUE *argv, VALUE self)
n = num_members(klass);
if (argc > 0 && RTEST(rb_struct_s_keyword_init(klass))) {
struct struct_hash_set_arg arg;
- if (argc > 1 || !RB_TYPE_P(argv[0], T_HASH)) {
+ if (argc > 2 || !RB_TYPE_P(argv[0], T_HASH)) {
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 0)", argc);
}
rb_mem_clear((VALUE *)RSTRUCT_CONST_PTR(self), n);
@@ -661,43 +654,6 @@ rb_struct_initialize(VALUE self, VALUE values)
return rb_struct_initialize_m(RARRAY_LENINT(values), RARRAY_CONST_PTR(values), self);
}
-static VALUE *
-struct_heap_alloc(VALUE st, size_t len)
-{
- VALUE *ptr = rb_transient_heap_alloc((VALUE)st, sizeof(VALUE) * len);
-
- if (ptr) {
- RSTRUCT_TRANSIENT_SET(st);
- return ptr;
- }
- else {
- RSTRUCT_TRANSIENT_UNSET(st);
- return ALLOC_N(VALUE, len);
- }
-}
-
-#if USE_TRANSIENT_HEAP
-void
-rb_struct_transient_heap_evacuate(VALUE obj, int promote)
-{
- if (RSTRUCT_TRANSIENT_P(obj)) {
- const VALUE *old_ptr = rb_struct_const_heap_ptr(obj);
- VALUE *new_ptr;
- long len = RSTRUCT_LEN(obj);
-
- if (promote) {
- new_ptr = ALLOC_N(VALUE, len);
- FL_UNSET_RAW(obj, RSTRUCT_TRANSIENT_FLAG);
- }
- else {
- new_ptr = struct_heap_alloc(obj, len);
- }
- MEMCPY(new_ptr, old_ptr, VALUE, len);
- RSTRUCT(obj)->as.heap.ptr = new_ptr;
- }
-}
-#endif
-
static VALUE
struct_alloc(VALUE klass)
{
@@ -712,9 +668,9 @@ struct_alloc(VALUE klass)
rb_mem_clear((VALUE *)st->as.ary, n);
}
else {
- st->as.heap.ptr = struct_heap_alloc((VALUE)st, n);
- rb_mem_clear((VALUE *)st->as.heap.ptr, n);
- st->as.heap.len = n;
+ st->as.heap.ptr = ALLOC_N(VALUE, n);
+ rb_mem_clear((VALUE *)st->as.heap.ptr, n);
+ st->as.heap.len = n;
}
return (VALUE)st;
@@ -868,6 +824,7 @@ inspect_struct(VALUE s, VALUE dummy, int recur)
rb_str_append(str, rb_inspect(RSTRUCT_GET(s, i)));
}
rb_str_cat2(str, ">");
+ OBJ_INFECT(str, s);
return str;
}
@@ -906,19 +863,13 @@ rb_struct_to_a(VALUE s)
/*
* call-seq:
- * struct.to_h -> hash
- * struct.to_h {|name, value| block } -> hash
+ * struct.to_h -> hash
*
* Returns a Hash containing the names and values for the struct's members.
*
- * If a block is given, the results of the block on each pair of the receiver
- * will be used as pairs.
- *
* Customer = Struct.new(:name, :address, :zip)
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
* joe.to_h[:address] #=> "123 Maple, Anytown NC"
- * joe.to_h{|name, value| [name.upcase, value.to_s.upcase]}[:ADDRESS]
- * #=> "123 MAPLE, ANYTOWN NC"
*/
static VALUE
@@ -927,44 +878,9 @@ rb_struct_to_h(VALUE s)
VALUE h = rb_hash_new_with_size(RSTRUCT_LEN(s));
VALUE members = rb_struct_members(s);
long i;
- int block_given = rb_block_given_p();
for (i=0; i<RSTRUCT_LEN(s); i++) {
- VALUE k = rb_ary_entry(members, i), v = RSTRUCT_GET(s, i);
- if (block_given)
- rb_hash_set_pair(h, rb_yield_values(2, k, v));
- else
- rb_hash_aset(h, k, v);
- }
- return h;
-}
-
-static VALUE
-rb_struct_deconstruct_keys(VALUE s, VALUE keys)
-{
- VALUE h;
- long i;
-
- if (NIL_P(keys)) {
- return rb_struct_to_h(s);
- }
- if (UNLIKELY(!RB_TYPE_P(keys, T_ARRAY))) {
- rb_raise(rb_eTypeError,
- "wrong argument type %"PRIsVALUE" (expected Array or nil)",
- rb_obj_class(keys));
-
- }
- if (RSTRUCT_LEN(s) < RARRAY_LEN(keys)) {
- return rb_hash_new_with_size(0);
- }
- h = rb_hash_new_with_size(RARRAY_LEN(keys));
- for (i=0; i<RARRAY_LEN(keys); i++) {
- VALUE key = RARRAY_AREF(keys, i);
- int i = rb_struct_pos(s, &key);
- if (i < 0) {
- return h;
- }
- rb_hash_aset(h, key, RSTRUCT_GET(s, i));
+ rb_hash_aset(h, rb_ary_entry(members, i), RSTRUCT_GET(s, i));
}
return h;
}
@@ -1141,8 +1057,6 @@ rb_struct_values_at(int argc, VALUE *argv, VALUE s)
* call-seq:
* struct.select {|obj| block } -> array
* struct.select -> enumerator
- * struct.filter {|obj| block } -> array
- * struct.filter -> enumerator
*
* Yields each member value from the struct to the block and returns an Array
* containing the member values from the +struct+ for which the given block
@@ -1151,8 +1065,6 @@ rb_struct_values_at(int argc, VALUE *argv, VALUE s)
* Lots = Struct.new(:a, :b, :c, :d, :e, :f)
* l = Lots.new(11, 22, 33, 44, 55, 66)
* l.select {|v| v.even? } #=> [22, 44, 66]
- *
- * Struct#filter is an alias for Struct#select.
*/
static VALUE
@@ -1176,12 +1088,15 @@ rb_struct_select(int argc, VALUE *argv, VALUE s)
static VALUE
recursive_equal(VALUE s, VALUE s2, int recur)
{
+ const VALUE *ptr, *ptr2;
long i, len;
if (recur) return Qtrue; /* Subtle! */
+ ptr = RSTRUCT_CONST_PTR(s);
+ ptr2 = RSTRUCT_CONST_PTR(s2);
len = RSTRUCT_LEN(s);
for (i=0; i<len; i++) {
- if (!rb_equal(RSTRUCT_GET(s, i), RSTRUCT_GET(s2, i))) return Qfalse;
+ if (!rb_equal(ptr[i], ptr2[i])) return Qfalse;
}
return Qtrue;
}
@@ -1229,26 +1144,31 @@ rb_struct_hash(VALUE s)
long i, len;
st_index_t h;
VALUE n;
+ const VALUE *ptr;
h = rb_hash_start(rb_hash(rb_obj_class(s)));
+ ptr = RSTRUCT_CONST_PTR(s);
len = RSTRUCT_LEN(s);
for (i = 0; i < len; i++) {
- n = rb_hash(RSTRUCT_GET(s, i));
+ n = rb_hash(ptr[i]);
h = rb_hash_uint(h, NUM2LONG(n));
}
h = rb_hash_end(h);
- return ST2FIX(h);
+ return INT2FIX(h);
}
static VALUE
recursive_eql(VALUE s, VALUE s2, int recur)
{
+ const VALUE *ptr, *ptr2;
long i, len;
if (recur) return Qtrue; /* Subtle! */
+ ptr = RSTRUCT_CONST_PTR(s);
+ ptr2 = RSTRUCT_CONST_PTR(s2);
len = RSTRUCT_LEN(s);
for (i=0; i<len; i++) {
- if (!rb_eql(RSTRUCT_GET(s, i), RSTRUCT_GET(s2, i))) return Qfalse;
+ if (!rb_eql(ptr[i], ptr2[i])) return Qfalse;
}
return Qtrue;
}
@@ -1375,14 +1295,10 @@ InitVM_Struct(void)
rb_define_method(rb_cStruct, "[]", rb_struct_aref, 1);
rb_define_method(rb_cStruct, "[]=", rb_struct_aset, 2);
rb_define_method(rb_cStruct, "select", rb_struct_select, -1);
- rb_define_method(rb_cStruct, "filter", rb_struct_select, -1);
rb_define_method(rb_cStruct, "values_at", rb_struct_values_at, -1);
rb_define_method(rb_cStruct, "members", rb_struct_members_m, 0);
rb_define_method(rb_cStruct, "dig", rb_struct_dig, -1);
-
- rb_define_method(rb_cStruct, "deconstruct", rb_struct_to_a, 0);
- rb_define_method(rb_cStruct, "deconstruct_keys", rb_struct_deconstruct_keys, 1);
}
#undef rb_intern
diff --git a/symbol.c b/symbol.c
index 14517df01e..d200e9e21a 100644
--- a/symbol.c
+++ b/symbol.c
@@ -9,9 +9,8 @@
**********************************************************************/
-#include "ruby/encoding.h"
-#include "ruby/st.h"
#include "internal.h"
+#include "ruby/st.h"
#include "symbol.h"
#include "gc.h"
#include "probes.h"
@@ -63,8 +62,12 @@ enum id_entry_type {
ID_ENTRY_SIZE
};
-rb_symbols_t ruby_global_symbols = {tNEXT_ID-1};
-#define global_symbols ruby_global_symbols
+static struct symbols {
+ rb_id_serial_t last_id;
+ st_table *str_sym;
+ VALUE ids;
+ VALUE dsymbol_fstr_hash;
+} global_symbols = {tNEXT_ID-1};
static const struct st_hash_type symhash = {
rb_str_hash_cmp,
@@ -92,6 +95,8 @@ WARN_UNUSED_RESULT(static VALUE dsymbol_check(const VALUE sym));
WARN_UNUSED_RESULT(static ID lookup_str_id(VALUE str));
WARN_UNUSED_RESULT(static VALUE lookup_str_sym(const VALUE str));
WARN_UNUSED_RESULT(static VALUE lookup_id_str(ID id));
+WARN_UNUSED_RESULT(static ID attrsetname_to_attr(VALUE name));
+WARN_UNUSED_RESULT(static ID attrsetname_to_attr_id(VALUE name));
WARN_UNUSED_RESULT(static ID intern_str(VALUE str, int mutable));
ID
@@ -152,6 +157,12 @@ rb_id_attrset(ID id)
return id;
}
+ID
+rb_id_attrget(ID id)
+{
+ return attrsetname_to_attr(rb_id2str(id));
+}
+
static int
is_special_global_name(const char *m, const char *e, rb_encoding *enc)
{
@@ -190,46 +201,10 @@ rb_enc_symname_p(const char *name, rb_encoding *enc)
return rb_enc_symname2_p(name, strlen(name), enc);
}
-static int
-rb_sym_constant_char_p(const char *name, long nlen, rb_encoding *enc)
-{
- int c, len;
- const char *end = name + nlen;
-
- if (nlen < 1) return FALSE;
- if (ISASCII(*name)) return ISUPPER(*name);
- c = rb_enc_precise_mbclen(name, end, enc);
- if (!MBCLEN_CHARFOUND_P(c)) return FALSE;
- len = MBCLEN_CHARFOUND_LEN(c);
- c = rb_enc_mbc_to_codepoint(name, end, enc);
- if (ONIGENC_IS_UNICODE(enc)) {
- static int ctype_titlecase = 0;
- if (rb_enc_isupper(c, enc)) return TRUE;
- if (rb_enc_islower(c, enc)) return FALSE;
- if (!ctype_titlecase) {
- static const UChar cname[] = "titlecaseletter";
- static const UChar *const end = cname + sizeof(cname) - 1;
- ctype_titlecase = ONIGENC_PROPERTY_NAME_TO_CTYPE(enc, cname, end);
- }
- if (rb_enc_isctype(c, ctype_titlecase, enc)) return TRUE;
- }
- else {
- /* fallback to case-folding */
- OnigUChar fold[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
- const OnigUChar *beg = (const OnigUChar *)name;
- int r = enc->mbc_case_fold(ONIGENC_CASE_FOLD,
- &beg, (const OnigUChar *)end,
- fold, enc);
- if (r > 0 && (r != len || memcmp(fold, name, r)))
- return TRUE;
- }
- return FALSE;
-}
-
#define IDSET_ATTRSET_FOR_SYNTAX ((1U<<ID_LOCAL)|(1U<<ID_CONST))
#define IDSET_ATTRSET_FOR_INTERN (~(~0U<<(1<<ID_SCOPE_SHIFT)) & ~(1U<<ID_ATTRSET))
-int
+static int
rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset)
{
const char *m = name;
@@ -306,7 +281,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
break;
default:
- type = rb_sym_constant_char_p(m, e-m, enc) ? ID_CONST : ID_LOCAL;
+ type = ISUPPER(*m) ? ID_CONST : ID_LOCAL;
id:
if (m >= e || (*m != '_' && !ISALPHA(*m) && ISASCII(*m))) {
if (len > 1 && *(e-1) == '=') {
@@ -521,7 +496,7 @@ dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc, const
const VALUE dsym = rb_newobj_of(klass, T_SYMBOL | FL_WB_PROTECTED);
long hashval;
- rb_enc_set_index(dsym, rb_enc_to_index(enc));
+ rb_enc_associate(dsym, enc);
OBJ_FREEZE(dsym);
RB_OBJ_WRITE(dsym, &RSYMBOL(dsym)->fstr, str);
RSYMBOL(dsym)->id = type;
@@ -691,8 +666,8 @@ rb_gc_free_dsymbol(VALUE sym)
* str.intern -> symbol
* str.to_sym -> symbol
*
- * Returns the Symbol corresponding to <i>str</i>, creating the
- * symbol if it did not previously exist. See Symbol#id2name.
+ * Returns the <code>Symbol</code> corresponding to <i>str</i>, creating the
+ * symbol if it did not previously exist. See <code>Symbol#id2name</code>.
*
* "Koala".intern #=> :Koala
* s = 'cat'.to_sym #=> :cat
@@ -731,8 +706,7 @@ rb_str_intern(VALUE str)
enc = ascii;
}
else {
- str = rb_str_dup(str);
- OBJ_FREEZE(str);
+ str = rb_str_new_frozen(str);
}
str = rb_fstring(str);
type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
@@ -836,6 +810,22 @@ symbols_i(st_data_t key, st_data_t value, st_data_t arg)
}
+/*
+ * call-seq:
+ * Symbol.all_symbols => array
+ *
+ * Returns an array of all the symbols currently in Ruby's symbol
+ * table.
+ *
+ * Symbol.all_symbols.size #=> 903
+ * Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
+ * :chown, :EOFError, :$;, :String,
+ * :LOCK_SH, :"setuid?", :$<,
+ * :default_proc, :compact, :extend,
+ * :Tms, :getwd, :$=, :ThreadGroup,
+ * :wait2, :$>]
+ */
+
VALUE
rb_sym_all_symbols(void)
{
@@ -899,11 +889,41 @@ rb_is_const_sym(VALUE sym)
}
int
+rb_is_class_sym(VALUE sym)
+{
+ return is_class_sym(sym);
+}
+
+int
+rb_is_global_sym(VALUE sym)
+{
+ return is_global_sym(sym);
+}
+
+int
+rb_is_instance_sym(VALUE sym)
+{
+ return is_instance_sym(sym);
+}
+
+int
rb_is_attrset_sym(VALUE sym)
{
return is_attrset_sym(sym);
}
+int
+rb_is_local_sym(VALUE sym)
+{
+ return is_local_sym(sym);
+}
+
+int
+rb_is_junk_sym(VALUE sym)
+{
+ return is_junk_sym(sym);
+}
+
/**
* Returns ID for the given name if it is interned already, or 0.
*
@@ -1011,11 +1031,13 @@ rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
return Qnil;
}
+#undef rb_sym_intern_cstr
#undef rb_sym_intern_ascii_cstr
#ifdef __clang__
NOINLINE(VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc));
#else
FUNC_MINIMIZED(VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc));
+FUNC_MINIMIZED(VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc));
FUNC_MINIMIZED(VALUE rb_sym_intern_ascii(const char *ptr, long len));
FUNC_MINIMIZED(VALUE rb_sym_intern_ascii_cstr(const char *ptr));
#endif
@@ -1029,6 +1051,12 @@ rb_sym_intern(const char *ptr, long len, rb_encoding *enc)
}
VALUE
+rb_sym_intern_cstr(const char *ptr, rb_encoding *enc)
+{
+ return rb_sym_intern(ptr, strlen(ptr), enc);
+}
+
+VALUE
rb_sym_intern_ascii(const char *ptr, long len)
{
return rb_sym_intern(ptr, len, rb_usascii_encoding());
@@ -1046,6 +1074,34 @@ rb_to_symbol_type(VALUE obj)
return rb_convert_type_with_id(obj, T_SYMBOL, "Symbol", idTo_sym);
}
+static ID
+attrsetname_to_attr_id(VALUE name)
+{
+ ID id;
+ struct RString fake_str;
+ /* make local name by chopping '=' */
+ const VALUE localname = rb_setup_fake_str(&fake_str,
+ RSTRING_PTR(name), RSTRING_LEN(name) - 1,
+ rb_enc_get(name));
+ OBJ_FREEZE(localname);
+
+ if ((id = lookup_str_id(localname)) != 0) {
+ return id;
+ }
+ RB_GC_GUARD(name);
+ return (ID)0;
+}
+
+static ID
+attrsetname_to_attr(VALUE name)
+{
+ if (rb_is_attrset_name(name)) {
+ return attrsetname_to_attr_id(name);
+ }
+
+ return (ID)0;
+}
+
int
rb_is_const_name(VALUE name)
{
@@ -1059,15 +1115,43 @@ rb_is_class_name(VALUE name)
}
int
+rb_is_global_name(VALUE name)
+{
+ return rb_str_symname_type(name, 0) == ID_GLOBAL;
+}
+
+int
rb_is_instance_name(VALUE name)
{
return rb_str_symname_type(name, 0) == ID_INSTANCE;
}
int
+rb_is_attrset_name(VALUE name)
+{
+ return rb_str_symname_type(name, IDSET_ATTRSET_FOR_INTERN) == ID_ATTRSET;
+}
+
+int
rb_is_local_name(VALUE name)
{
return rb_str_symname_type(name, 0) == ID_LOCAL;
}
+int
+rb_is_method_name(VALUE name)
+{
+ switch (rb_str_symname_type(name, 0)) {
+ case ID_LOCAL: case ID_ATTRSET: case ID_JUNK:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+rb_is_junk_name(VALUE name)
+{
+ return rb_str_symname_type(name, IDSET_ATTRSET_FOR_SYNTAX) == -1;
+}
+
#include "id_table.c"
diff --git a/symbol.h b/symbol.h
index 4b5c676d55..cc7f156997 100644
--- a/symbol.h
+++ b/symbol.h
@@ -58,13 +58,6 @@ static const uint32_t RB_ID_SERIAL_MAX = /* 256M on LP32 */
((sizeof(ID)-sizeof(rb_id_serial_t))*CHAR_BIT < RUBY_ID_SCOPE_SHIFT ?
RUBY_ID_SCOPE_SHIFT : 0);
-typedef struct {
- rb_id_serial_t last_id;
- st_table *str_sym;
- VALUE ids;
- VALUE dsymbol_fstr_hash;
-} rb_symbols_t;
-
static inline rb_id_serial_t
rb_id_to_serial(ID id)
{
@@ -109,7 +102,7 @@ is_global_name_punct(const int c)
return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
}
-int rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset);
+ID rb_intern_cstr_without_pindown(const char *, long, rb_encoding *);
RUBY_SYMBOL_EXPORT_BEGIN
diff --git a/template/Doxyfile.tmpl b/template/Doxyfile.tmpl
index a16e43bc65..0361c48bdd 100644
--- a/template/Doxyfile.tmpl
+++ b/template/Doxyfile.tmpl
@@ -21,7 +21,7 @@ have_dot = dot.empty? ? "NO" : "YES"
PROJECT_NAME = Ruby
PROJECT_NUMBER = <%=RUBY_VERSION%><%= RUBY_PATCHLEVEL < 0 ? 'dev' : "p#{RUBY_PATCHLEVEL}" %> (<%=RUBY_RELEASE_DATE%> revision <%=RUBY_REVISION%>)
STRIP_FROM_PATH = <%=srcdir%>
-FILE_VERSION_FILTER = "<%=miniruby%> <%=srcdir%>/tool/file2lastrev.rb -q --srcdir=<%=srcdir%>"
+FILE_VERSION_FILTER = "<%=miniruby%> <%=srcdir%>/tool/file2lastrev.rb -q"
INPUT = <%=srcdir%> .
INPUT_FILTER = "<%=miniruby%> <%=srcdir%>/tool/strip-rdoc.rb"
@@ -102,11 +102,11 @@ WARN_LOGFILE =
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT_ENCODING = UTF-8
-FILE_PATTERNS = *.c *.h *.hpp *.y *.def
+FILE_PATTERNS = *.c *.h *.y *.def
RECURSIVE = YES
EXCLUDE = <%=srcdir%>/ext/dl/callback <%=srcdir%>/ccan <%=srcdir%>/ext/psych/yaml
EXCLUDE_SYMLINKS = YES
-EXCLUDE_PATTERNS = *.src doc enc build */ext/-test-/* tmp test yarvtest lib bootstraptest spec .ext .git .svn extconf.h *prelude.c encdb.h transdb.h insns.def rb_mjit_header.h
+EXCLUDE_PATTERNS = *.src doc enc build */ext/-test-/* tmp test yarvtest lib bootstraptest spec .ext .git .svn extconf.h *prelude.c encdb.h transdb.h insns.def
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
diff --git a/template/GNUmakefile.in b/template/GNUmakefile.in
index d0444d37e2..c904d3474e 100644
--- a/template/GNUmakefile.in
+++ b/template/GNUmakefile.in
@@ -1,10 +1,4 @@
include Makefile
-
-ifeq ($(HAVE_BASERUBY),yes)
-override REVISION_FORCE := PHONY
-endif
-
-include $(srcdir)/defs/universal.mk
-include uncommon.mk
include $(srcdir)/defs/gmake.mk
diff --git a/template/Makefile.in b/template/Makefile.in
deleted file mode 100644
index 3845f02dc7..0000000000
--- a/template/Makefile.in
+++ /dev/null
@@ -1,683 +0,0 @@
-# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
-
-SHELL = /bin/sh
-NULLCMD = @NULLCMD@
-n=$(NULLCMD)
-ECHO1 = $(V:1=$n)
-RUNCMD = $(SHELL)
-CDPATH = .
-CHDIR = @CHDIR@
-exec = exec
-NULL = /dev/null
-PATH_SEPARATOR = @PATH_SEPARATOR@
-
-#### Start of system configuration section. ####
-
-srcdir = @srcdir@
-top_srcdir = $(srcdir)
-hdrdir = $(srcdir)/include
-PLATFORM_DIR = @PLATFORM_DIR@
-
-CC_WRAPPER = @XCC_WRAPPER@
-CC = @CC@
-CPP = @CPP@
-LD = @LD@
-YACC = bison
-PURIFY =
-AUTOCONF = autoconf
-ACLOCAL = aclocal
-CONFIGURE = @CONFIGURE@
-@SET_MAKE@
-MKFILES = @MAKEFILES@
-BASERUBY = @BASERUBY@
-HAVE_BASERUBY = @HAVE_BASERUBY@
-TEST_RUNNABLE = @TEST_RUNNABLE@
-CROSS_COMPILING = @CROSS_COMPILING@
-DOXYGEN = @DOXYGEN@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-sbindir = @sbindir@
-libdir = @libdir@
-libexecdir = @libexecdir@
-datarootdir = @datarootdir@
-datadir = @datadir@
-arch = @arch@
-sitearch = @sitearch@
-sitedir = @sitedir@
-archlibdir = @archlibdir@
-includedir = @includedir@
-archincludedir = @archincludedir@
-rubylibprefix = @rubylibprefix@
-rubylibdir = @rubylibdir@
-rubyarchprefix = @rubyarchprefix@
-rubyarchdir = @rubyarchdir@
-rubyhdrdir = @rubyhdrdir@
-rubyarchhdrdir = @rubyarchhdrdir@
-ruby_version = @ruby_version@
-RUBY_VERSION_NAME = @RUBY_VERSION_NAME@
-UNIVERSAL_ARCHNAMES = @UNIVERSAL_ARCHNAMES@
-
-TESTUI = console
-TESTS =
-INSTALLDOC = @INSTALLDOC@
-DOCTARGETS = @RDOCTARGET@ @CAPITARGET@
-
-EXTOUT = @EXTOUT@
-TIMESTAMPDIR = $(EXTOUT)/.timestamp
-arch_hdrdir = $(EXTOUT)/include/$(arch)
-VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir):$(srcdir)/missing
-
-empty =
-CC_VERSION = @CC_VERSION@
-OUTFLAG = @OUTFLAG@$(empty)
-COUTFLAG = @COUTFLAG@$(empty)
-CPPOUTFLAG = $(COUTFLAG)
-ARCH_FLAG = @ARCH_FLAG@
-CFLAGS_NO_ARCH = @CFLAGS@
-CFLAGS = $(CFLAGS_NO_ARCH) $(ARCH_FLAG)
-cflags = @cflags@
-optflags = @optflags@
-debugflags = @debugflags@
-warnflags = @warnflags@ @strict_warnflags@
-cppflags = @cppflags@
-MATHN = @MATHN@
-XCFLAGS = @XCFLAGS@ $(MATHN:yes=-DCANONICALIZATION_FOR_MATHN) $(INCFLAGS)
-USE_RUBYGEMS = @USE_RUBYGEMS@
-USE_RUBYGEMS_ = $(USE_RUBYGEMS:yes=)
-CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1)
-MJIT_SUPPORT = @MJIT_SUPPORT@
-MJIT_HEADER_FLAGS = @MJIT_HEADER_FLAGS@
-MJIT_HEADER_SUFFIX =
-MJIT_HEADER_ARCH =
-MJIT_HEADER_INSTALL_DIR = @MJIT_HEADER_INSTALL_DIR@
-MJIT_CC = @MJIT_CC@
-MJIT_CFLAGS = @MJIT_CFLAGS@
-MJIT_OPTFLAGS = @MJIT_OPTFLAGS@
-MJIT_DEBUGFLAGS = @MJIT_DEBUGFLAGS@
-MJIT_LDSHARED = @MJIT_LDSHARED@
-MJIT_DLDFLAGS = @DLDFLAGS@
-MJIT_HEADER = rb_mjit_header.h
-MJIT_MIN_HEADER_NAME = rb_mjit_min_header-$(RUBY_PROGRAM_VERSION).h
-MJIT_MIN_HEADER = $(MJIT_HEADER_BUILD_DIR)/$(MJIT_MIN_HEADER_NAME)
-MJIT_HEADER_BUILD_DIR = $(EXTOUT)/include/$(arch)
-LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
-EXTLDFLAGS = @EXTLDFLAGS@
-XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
-EXTLIBS =
-LIBS = @LIBS@ $(EXTLIBS)
-MISSING = @LIBOBJS@ @ALLOCA@
-ENABLE_SHARED = @ENABLE_SHARED@
-LDSHARED = @LIBRUBY_LDSHARED@
-DLDSHARED = @DLDSHARED@
-DLDFLAGS = @LIBRUBY_DLDFLAGS@ $(XLDFLAGS) $(ARCH_FLAG)
-SOLIBS = @SOLIBS@
-ENABLE_DEBUG_ENV = @ENABLE_DEBUG_ENV@
-MAINLIBS = @MAINLIBS@
-ARCHMINIOBJS = @MINIOBJS@
-DLNOBJ = @DLNOBJ@
-ENCOBJS = @ENCOBJS@
-EXTOBJS = @EXTOBJS@
-BUILTIN_ENCOBJS = @BUILTIN_ENCOBJS@
-BUILTIN_TRANSSRCS = @BUILTIN_TRANSSRCS@
-BUILTIN_TRANSOBJS = @BUILTIN_TRANSOBJS@
-POSTLINK = @POSTLINK@
-
-RUBY_BASE_NAME=@RUBY_BASE_NAME@
-RUBY_API_VERSION=@RUBY_API_VERSION@
-RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
-RUBY_SO_NAME=@RUBY_SO_NAME@
-EXEEXT = @EXEEXT@
-LIBEXT = @LIBEXT@
-PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
-RUBY = $(RUBY_INSTALL_NAME)
-MINIRUBY = @MINIRUBY@\
- $(MINIRUBYOPT)
-# RUNRUBY_COMMAND:: runruby.rb or baseruby. do not append options directly
-RUNRUBY_COMMAND = @RUNRUBY_COMMAND@
-# RUNRUBY:: run ruby with RUN_OPTS which is passed to ruby
-RUNRUBY = @RUNRUBY@ $(RUN_OPTS)
-# RUNRUBY_DEBUGGER:: debugging option for runruby.rb
-RUNRUBY_DEBUGGER = --debugger='gdb -x run.gdb --quiet --args'
-XRUBY = @XRUBY@
-BTESTRUBY = @BTESTRUBY@\
- $(MINIRUBYOPT)
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-XRUBY_LIBDIR = @XRUBY_LIBDIR@
-XRUBY_RUBYLIBDIR = @XRUBY_RUBYLIBDIR@
-XRUBY_RUBYHDRDIR = @XRUBY_RUBYHDRDIR@
-BOOTSTRAPRUBY = @BOOTSTRAPRUBY@
-
-COROUTINE_H = @X_COROUTINE_H@
-COROUTINE_OBJ = $(COROUTINE_H:.h=.@OBJEXT@)
-COROUTINE_SRC = @X_COROUTINE_SRC@
-
-#### End of system configuration section. ####
-
-MAJOR= @MAJOR@
-MINOR= @MINOR@
-TEENY= @TEENY@
-
-# here for MJIT_MIN_HEADER_NAME, not in common.mk
-RUBY_PROGRAM_VERSION = $(MAJOR).$(MINOR).$(TEENY)
-
-LIBRUBY_A = @LIBRUBY_A@
-LIBRUBY_SO = @LIBRUBY_SO@
-LIBRUBY_SONAME= @LIBRUBY_SONAME@
-LIBRUBY_ALIASES= @LIBRUBY_ALIASES@
-LIBRUBY = @LIBRUBY@
-LIBRUBYARG = @LIBRUBYARG@
-LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@
-LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@
-LIBRUBY_RELATIVE = @LIBRUBY_RELATIVE@
-LIBRUBY_A_OBJS = @LIBRUBY_A_OBJS@
-
-DTRACE_REBUILD_OBJS = $(DTRACE_REBUILD:yes=$(DTRACE_DEPENDENT_OBJS))
-
-DTRACE_DEPENDENT_OBJS = array.$(OBJEXT) \
- eval.$(OBJEXT) \
- gc.$(OBJEXT) \
- hash.$(OBJEXT) \
- load.$(OBJEXT) \
- object.$(OBJEXT) \
- parse.$(OBJEXT) \
- string.$(OBJEXT) \
- symbol.$(OBJEXT) \
- vm.$(OBJEXT)
-
-THREAD_MODEL = @THREAD_MODEL@
-
-PREP = @PREP@
-ARCHFILE = @ARCHFILE@
-SETUP =
-EXTSTATIC = @EXTSTATIC@
-ENCSTATIC = @ENCSTATIC@
-SET_LC_MESSAGES = env LC_MESSAGES=C
-
-MAKEDIRS = @MKDIR_P@
-CP = cp
-MV = mv
-RM = rm -f
-RMDIR = @RMDIR@
-RMDIRS = @RMDIRS@
-RMALL = @RMALL@
-NM = @NM@
-AR = @AR@
-ARFLAGS = @ARFLAGS@$(empty)
-RANLIB = @RANLIB@
-AS = @AS@
-ASFLAGS = @ASFLAGS@ $(INCFLAGS)
-IFCHANGE = $(srcdir)/tool/ifchange
-OBJDUMP = @OBJDUMP@
-OBJCOPY = @OBJCOPY@
-HAVE_GIT = @HAVE_GIT@
-GIT = @GIT@
-VCS = @VCS@
-VCSUP = @VCSUP@
-DTRACE = @DTRACE@ @DTRACE_OPT@
-DTRACE_EXT = @DTRACE_EXT@
-DTRACE_OBJ = @DTRACE_OBJ@
-DTRACE_REBUILD= @DTRACE_REBUILD@
-DTRACE_GLOMMED_OBJ = $(DTRACE_REBUILD:yes=ruby-glommed.$(OBJEXT))
-
-OBJEXT = @OBJEXT@
-ASMEXT = @ASMEXT@
-SOEXT = @SOEXT@
-DLEXT = @DLEXT@
-MANTYPE = @MANTYPE@
-SYMBOL_PREFIX = @SYMBOL_PREFIX@
-
-INSTALLED_LIST= .installed.list
-
-NEWLINE_C = enc/trans/newline.c
-MINIPRELUDE_C = miniprelude.c
-GOLF_PRELUDE_C= golf_prelude.c
-RBCONFIG = .rbconfig.time
-
-MAINSRC = $(MAINOBJ:.@OBJEXT@=.c)
-
-SRC_FILE = $<
-OS_SRC_FILE = $<
-DEST_FILE = $@
-OS_DEST_FILE = $@
-
-MESSAGE_BEGIN = @for line in
-MESSAGE_END = ; do echo "$$line"; done
-ECHO_BEGIN = @sep=''; for word in
-ECHO_END = ; do echo @ECHO_N@ "$$sep'$$word'@ECHO_C@"; sep=' '; done; echo
-
-DESTDIR = @DESTDIR@
-
-configure_args = @configure_args@
-#### End of variables
-
-.SUFFIXES: .inc .h .c .y .i .$(ASMEXT) .$(DTRACE_EXT)
-
-all:
-
-# Prevent GNU make v3 from overflowing arg limit on SysV.
-.NOEXPORT:
-
-miniruby$(EXEEXT):
- @-if test -f $@; then $(MV) -f $@ $@.old; $(RM) $@.old; fi
- $(ECHO) linking $@
- $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@
- $(Q) $(POSTLINK)
-
-$(PROGRAM):
- @$(RM) $@
- $(ECHO) linking $@
- $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@
- $(Q) $(POSTLINK)
-
-PRE_LIBRUBY_UPDATE = [ -n "$(LIBRUBY_SO_UPDATE)" ] || $(gnumake:yes=exec) $(RM) $(LIBRUBY_EXTS)
-
-# We must `rm' the library each time this rule is invoked because "updating" a
-# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
-# supported.
-$(LIBRUBY_A):
- @$(RM) $@
- @-[ -z "$(EXTSTATIC)" ] || $(PRE_LIBRUBY_UPDATE)
- $(ECHO) linking static-library $@
- $(Q) $(AR) $(ARFLAGS) $@ $(LIBRUBY_A_OBJS) $(INITOBJS)
- @-$(RANLIB) $@ 2> /dev/null || true
-
-verify-static-library: $(LIBRUBY_A)
- $(ECHO) verifying static-library $@
- @$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)conftest$(EXEEXT)
- @$(RMALL) conftest$(EXEEXT) conftest.c conftest.dSYM
-
-$(LIBRUBY_SO):
- @-[ -n "$(EXTSTATIC)" ] || $(PRE_LIBRUBY_UPDATE)
- $(ECHO) linking shared-library $@
- $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(EXTSOLIBS) $(OUTFLAG)$@
- -$(Q) $(OBJCOPY) -w -L '$(SYMBOL_PREFIX)Init_*' -L '$(SYMBOL_PREFIX)ruby_static_id_*' \
- -L '$(SYMBOL_PREFIX)*_threadptr_*' -L '$(SYMBOL_PREFIX)*_ec_*' $@
- $(Q) $(POSTLINK)
- @-$(MINIRUBY) -e 'so, *aliases = ARGV; aliases.uniq!; aliases.delete(File.basename(so)); \
- aliases.each { |link| File.delete link rescue nil; File.symlink so, link }' \
- $(LIBRUBY_SO) $(LIBRUBY_ALIASES) || true
-
-LIBRUBY_WITH_EXT = @LIBRUBY_WITH_EXT@
-$(LIBRUBY_$(LIBRUBY_WITH_EXT)): $(LIBRUBY_SO_UPDATE)
-
-ruby_pc = @ruby_pc@
-ruby.pc: $(ruby_pc)
-$(ruby_pc): config.status
- @./config.status --file=$@:$(srcdir)/template/ruby.pc.in
-
-ruby-runner.h: template/ruby-runner.h.in config.status
- @./config.status --file=$@:$(srcdir)/template/$(@F).in
-
-$(RBCONFIG): $(PREP)
-
-rbconfig.rb: $(RBCONFIG)
-
-install-cross: $(arch)-fake.rb $(RBCONFIG) rbconfig.rb $(arch_hdrdir)/ruby/config.h \
- $(LIBRUBY_A) $(LIBRUBY_SO) $(ARCHFILE)
- $(ECHO) installing cross-compiling stuff
- $(Q) $(MAKEDIRS) $(XRUBY_RUBYLIBDIR)/$(arch) $(XRUBY_RUBYHDRDIR)/$(arch)/ruby
- $(Q) sed '/^\$$:\.unshift/q' $(arch)-fake.rb > fake.rb
- $(Q) $(BASERUBY) -p \
- -e '~/^\s*CONFIG\["LDFLAGS"\]/ and' \
- -e '$$_[/(?=\s*"$$)/] = %q[ #{(CONFIG["LIBPATHFLAG"]%File.dirname(__FILE__)).strip}]' \
- rbconfig.rb > fake-rbconfig.rb
- $(INSTALL_SCRIPT) fake.rb $(XRUBY_RUBYLIBDIR)/$(arch)/fake.rb
- $(INSTALL_SCRIPT) fake-rbconfig.rb $(XRUBY_RUBYLIBDIR)/$(arch)/rbconfig.rb
- @$(RM) fake.rb fake-rbconfig.rb
- $(INSTALL_DATA) $(arch_hdrdir)/ruby/config.h $(XRUBY_RUBYHDRDIR)/$(arch)/ruby
- $(INSTALL_DATA) $(top_srcdir)/include/ruby/win32.h $(XRUBY_RUBYHDRDIR)/ruby
- $(INSTALL_DATA) $(LIBRUBY) $(LIBRUBY_A) $(XRUBY_RUBYLIBDIR)/$(arch)
- $(INSTALL_PROGRAM) $(LIBRUBY_SO) $(XRUBY_RUBYLIBDIR)/$(arch)
-
-Makefile: $(srcdir)/template/Makefile.in $(srcdir)/enc/Makefile.in
-
-$(MKFILES): config.status $(srcdir)/version.h
- @[ -f $@ ] && mv $@ $@.old
- MAKE=$(MAKE) $(SHELL) ./config.status $@
- @cmp $@ $@.old > /dev/null 2>&1 && echo $@ unchanged && exit 0; \
- { \
- echo "all:; -@rm -f conftest.mk"; \
- echo "conftest.mk: .force; @echo AUTO_REMAKE"; \
- echo ".force:"; \
- } > conftest.mk || exit 1; \
- $(MAKE) -f conftest.mk | grep '^AUTO_REMAKE$$' >/dev/null 2>&1 || \
- { echo "$@ updated, restart."; exit 1; }
-
-uncommon.mk: $(srcdir)/common.mk
- sed 's/{\$$([^(){}]*)[^{}]*}//g' $< > $@
-
-.PHONY: reconfig
-reconfig-args = $(srcdir)/$(CONFIGURE) $(configure_args)
-config.status-args = ./config.status --recheck
-reconfig-exec-0 = test -t 1 && { : $${CONFIGURE_TTY=yes}; export CONFIGURE_TTY; }; exec 3>&1; exit `exec 4>&1; { "$$@" 3>&- 4>&-; echo $$? 1>&4; } | fgrep -v '(cached)' 1>&3 3>&- 4>&-`
-reconfig-exec-1 = set -x; "$$@"
-
-reconfig config.status: $(srcdir)/$(CONFIGURE) $(srcdir)/enc/Makefile.in \
- $(srcdir)/include/ruby/version.h
- @PWD= MINIRUBY="$(MINIRUBY)"; export MINIRUBY; \
- set $(SHELL) $($@-args); $(reconfig-exec-$(V))
-
-$(srcdir)/$(CONFIGURE): $(srcdir)/configure.ac $(srcdir)/aclocal.m4
- $(CHDIR) $(srcdir) && exec $(AUTOCONF) -o $(@F)
-
-$(srcdir)/aclocal.m4:
- $(CHDIR) $(srcdir) && \
- type $(ACLOCAL) >/dev/null 2>&1 && exec $(ACLOCAL); \
- touch $(@F)
-
-prereq: $(srcdir)/$(CONFIGURE)
-
-incs: id.h
-all-incs: probes.h
-
-# Things which should be considered:
-# * with gperf v.s. without gperf
-# * committers may have various versions of gperf
-# * ./configure v.s. ../ruby/configure
-# * GNU make v.s. HP-UX make # HP-UX make invokes the action if lex.c and keywords has same mtime.
-# * svn checkout generate a file with mtime as current time
-# * ext4 and XFS has a mtime with fractional part
-lex.c: defs/keywords
- @\
- if cmp -s $(srcdir)/defs/lex.c.src $?; then \
- [ $(Q) ] && echo copying $@ || set -x; \
- $(CP) $(srcdir)/lex.c.blt $@; \
- else \
- [ $(Q) ] && echo generating $@ || set -x; \
- gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? \
- | sed -f $(srcdir)/tool/gperf.sed \
- > $@.tmp && \
- $(MV) $@.tmp $@ && \
- $(CP) $? $(srcdir)/defs/lex.c.src && \
- $(CP) $@ $(srcdir)/lex.c.blt; \
- fi
-
-JIS_PROPS_OPTIONS = -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property
-
-$(srcdir)/enc/jis/props.h: enc/jis/props.kwd
- $(MAKEDIRS) $(@D)
- @set +e; \
- if cmp -s $(?:.kwd=.src) $?; then \
- set -x; \
- $(CP) $(?:.kwd=.h.blt) $@; \
- else \
- set -x; \
- gperf $(JIS_PROPS_OPTIONS) $? | \
- sed -f $(srcdir)/tool/gperf.sed > $@ && \
- $(CP) $? $(?:.kwd=.src) && \
- $(CP) $@ $(?:.kwd=.h.blt); \
- fi
-
-.c.@OBJEXT@:
- @$(ECHO) compiling $<
- $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $<
-
-.$(ASMEXT).@OBJEXT@:
- @$(ECHO) assembling $<
- $(Q) $(CC) $(ASFLAGS) -DSYMBOL_PREFIX=$(SYMBOL_PREFIX) -o $@ -c $<
-
-.c.$(ASMEXT):
- @$(ECHO) translating $<
- $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -S $<
-
-.c.i:
- @$(ECHO) preprocessing $<
- $(Q) $(CPP) $(warnflags) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -E $< > $@
-
-.d.h:
- @$(ECHO) translating probes $<
- $(Q) $(DTRACE) -o $@.tmp -h -C $(INCFLAGS) -s $<
- $(Q) sed -e 's/RUBY_/RUBY_DTRACE_/g' -e 's/PROBES_H_TMP/RUBY_PROBES_H/' -e 's/(char \*/(const char */g' -e 's/, char \*/, const char */g' $@.tmp > $@
- $(Q) $(RM) $@.tmp
-
-.dmyh.h:
- @$(ECHO) making dummy $(DEST_FILE)
- $(Q)echo '#include "$(*F).dmyh"' > $@
-
-probes.stamp: $(DTRACE_REBUILD_OBJS)
- $(Q) if test -f $@ -o -f probes.$(OBJEXT); then \
- $(RM) $(DTRACE_REBUILD_OBJS) $@; \
- $(ECHO0) "rebuilding objects which were modified by \"dtrace -G\""; \
- $(MAKE) $(DTRACE_REBUILD_OBJS); \
- fi
- $(Q) touch $@
-
-probes.$(OBJEXT): $(srcdir)/probes.d $(DTRACE_REBUILD:yes=probes.stamp)
- @$(ECHO) processing probes in object files
- $(Q) $(RM) $@
- $(Q) $(DTRACE) -G -C $(INCFLAGS) -s $(srcdir)/probes.d -o $@ $(DTRACE_REBUILD_OBJS)
-
-main: mjit-headers
-yes-mjit-headers: $(MJIT_MIN_HEADER)
-clean-local::
- $(Q)$(RM) \
- $(MJIT_HEADER) $(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX:%=*).h \
- $(MJIT_MIN_HEADER) $(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX:%=*).h \
- $(MJIT_HEADER_INSTALL_DIR)/rb_mjit_min_header-*.h \
- $(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time mjit_config.h \
- || $(NULLCMD)
- $(Q)$(RM) -r mjit_build_dir.*
- -$(Q) $(RMDIRS) $(MJIT_HEADER_INSTALL_DIR) $(MJIT_HEADER_BUILD_DIR) $(TIMESTAMPDIR) 2> $(NULL) || $(NULLCMD)
-
-# DTrace static library hacks described here:
-# http://mail.opensolaris.org/pipermail/dtrace-discuss/2005-August/000207.html
-ruby-glommed.$(OBJEXT):
- @$(ECHO) generating a glommed object with DTrace probes for static library
- $(Q) $(LD) -r -o $@ $(OBJS)
-
-clean-local::
- $(Q)$(RM) \
- ext/extinit.c ext/extinit.$(OBJEXT) ext/ripper/y.output \
- enc/encinit.c enc/encinit.$(OBJEXT) $(pkgconfig_DATA) \
- ruby-runner.$(OBJEXT) ruby-runner.h *.dSYM \
- || $(NULLCMD)
- -$(Q)$(RMALL) exe/
-
-distclean-local::
- $(Q)$(RM) \
- ext/config.cache $(RBCONFIG) Doxyfile run.gdb \
- $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h verconf.h \
- || $(NULLCMD)
- -$(Q)$(RMDIRS) $(arch_hdrdir)/ruby 2> /dev/null || true
-
-ext/clean.sub:: ext/clean.mk
-ext/distclean.sub:: ext/distclean.mk
-ext/realclean.sub:: ext/realclean.mk
-
-ext/clean.mk ext/distclean.mk ext/realclean.mk::
- -$(Q) if [ -f $(EXTS_MK) ]; then exec $(MAKE) -f $(EXTS_MK) $(@F:.mk=); fi
-
-ext/clean:: ext/clean.sub
-ext/distclean:: ext/distclean.sub
-ext/realclean:: ext/realclean.sub
-gems/clean:: gems/clean.sub
-gems/distclean:: gems/distclean.sub
-gems/realclean:: gems/realclean.sub
-
-ext/clean.sub ext/distclean.sub ext/realclean.sub \
-gems/clean.sub gems/distclean.sub gems/realclean.sub::
- $(Q) set dummy `echo "${EXTS}" | tr , ' '`; shift; \
- test "$$#" = 0 && set .; \
- set dummy `\
- cd $(@D) 2>/dev/null && \
- find "$$@" \( -name Makefile -o -name exts.mk \) -print | \
- sed -n 's:^\./::;s:^:$(@D)/:;s:/[^/][^/]*$$::p' | sort -u; \
- `; shift; \
- for dir do \
- $(RM) "$$dir/exts.mk"; \
- if [ -f "$$dir/Makefile" ]; then \
- echo $(@F:.sub=)ing "$$dir"; \
- (cd "$$dir" && exec $(MAKE) $(mflags) $(@F:.sub=)); \
- fi; \
- done || true
-
-ext/distclean ext/realclean gems/distclean gems/realclean::
- $(Q) set dummy `echo "${EXTS}" | tr , ' '`; shift; \
- test "$$#" = 0 && set .; \
- cd $(@D) 2>/dev/null && \
- find "$$@" -type d -empty -exec $(RMDIRS) {} + 2> /dev/null || true
- $(Q) $(RMDIRS) $(@D) 2> /dev/null || true
-
-clean-enc distclean-enc realclean-enc:
- @test -f "$(ENC_MK)" || exit 0; \
- echo $(@:-enc=ing) encodings; \
- exec $(MAKE) $(MAKE_ENC) $(@:-enc=)
-
-ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
- $(ECHO) compiling $@
- $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c
-
-enc/encinit.$(OBJEXT): enc/encinit.c $(SETUP)
-
-cont.$(OBJEXT): $(COROUTINE_H)
-
-update-src::
- @$(CHDIR) "$(srcdir)" && LC_TIME=C exec $(VCSUP)
-
-update-download:: update-config_files
-
-after-update:: prereq
-
-gcov:
- $(Q) $(BASERUBY) $(srcdir)/tool/run-gcov.rb
-
-lcov:
- $(Q) $(BASERUBY) $(srcdir)/tool/run-lcov.rb
-
-update-benchmark-driver:
- $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/benchmark $(Q1:0=-q) \
- --branch $(BENCHMARK_DRIVER_GIT_REF) \
- $(BENCHMARK_DRIVER_GIT_URL) benchmark-driver $(GIT_OPTS)
-
-update-doclie:
- $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
- --branch $(DOCLIE_GIT_REF) \
- $(DOCLIE_GIT_URL) doclie $(GIT_OPTS)
-
-update-simplecov-html:
- $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
- --branch $(SIMPLECOV_HTML_GIT_REF) \
- $(SIMPLECOV_HTML_GIT_URL) simplecov-html $(GIT_OPTS)
-
-update-simplecov:
- $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
- --branch $(SIMPLECOV_GIT_REF) \
- $(SIMPLECOV_GIT_URL) simplecov $(GIT_OPTS)
-
-update-coverage: update-simplecov update-simplecov-html update-doclie
-
-update-known-errors:
- errno --list | cut -d' ' -f1 | sort -u - $(srcdir)/defs/known_errors.def | \
- $(IFCHANGE) $(srcdir)/defs/known_errors.def -
-
-INSNS = opt_sc.inc optinsn.inc optunifs.inc insns.inc insns_info.inc \
- vmtc.inc vm.inc mjit_compile.inc
-
-$(INSNS): $(srcdir)/insns.def vm_opts.h \
- $(srcdir)/defs/opt_operand.def $(srcdir)/defs/opt_insn_unif.def \
- $(srcdir)/tool/insns2vm.rb \
- $(srcdir)/tool/ruby_vm/controllers/application_controller.rb \
- $(srcdir)/tool/ruby_vm/helpers/c_escape.rb \
- $(srcdir)/tool/ruby_vm/helpers/dumper.rb \
- $(srcdir)/tool/ruby_vm/helpers/scanner.rb \
- $(srcdir)/tool/ruby_vm/loaders/insns_def.rb \
- $(srcdir)/tool/ruby_vm/loaders/opt_insn_unif_def.rb \
- $(srcdir)/tool/ruby_vm/loaders/opt_operand_def.rb \
- $(srcdir)/tool/ruby_vm/loaders/vm_opts_h.rb \
- $(srcdir)/tool/ruby_vm/models/attribute.rb \
- $(srcdir)/tool/ruby_vm/models/bare_instructions.rb \
- $(srcdir)/tool/ruby_vm/models/c_expr.rb \
- $(srcdir)/tool/ruby_vm/models/instructions.rb \
- $(srcdir)/tool/ruby_vm/models/instructions_unifications.rb \
- $(srcdir)/tool/ruby_vm/models/operands_unifications.rb \
- $(srcdir)/tool/ruby_vm/models/trace_instructions.rb \
- $(srcdir)/tool/ruby_vm/models/typemap.rb \
- $(srcdir)/tool/ruby_vm/scripts/converter.rb \
- $(srcdir)/tool/ruby_vm/scripts/insns2vm.rb \
- $(srcdir)/tool/ruby_vm/views/_attributes.erb \
- $(srcdir)/tool/ruby_vm/views/_c_expr.erb \
- $(srcdir)/tool/ruby_vm/views/_comptime_insn_stack_increase.erb \
- $(srcdir)/tool/ruby_vm/views/_copyright.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_entry.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_len_info.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_name_info.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_operand_info.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_sp_pc_dependency.erb \
- $(srcdir)/tool/ruby_vm/views/_insn_type_chars.erb \
- $(srcdir)/tool/ruby_vm/views/_leaf_helpers.erb \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_insn.erb \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_insn_body.erb \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_ivar.erb \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb \
- $(srcdir)/tool/ruby_vm/views/_mjit_compile_send.erb \
- $(srcdir)/tool/ruby_vm/views/_notice.erb \
- $(srcdir)/tool/ruby_vm/views/_sp_inc_helpers.erb \
- $(srcdir)/tool/ruby_vm/views/_trace_instruction.erb \
- $(srcdir)/tool/ruby_vm/views/insns.inc.erb \
- $(srcdir)/tool/ruby_vm/views/insns_info.inc.erb \
- $(srcdir)/tool/ruby_vm/views/mjit_compile.inc.erb \
- $(srcdir)/tool/ruby_vm/views/opt_sc.inc.erb \
- $(srcdir)/tool/ruby_vm/views/optinsn.inc.erb \
- $(srcdir)/tool/ruby_vm/views/optunifs.inc.erb \
- $(srcdir)/tool/ruby_vm/views/vm.inc.erb \
- $(srcdir)/tool/ruby_vm/views/vmtc.inc.erb
- $(ECHO) generating $@
- $(Q) $(BASERUBY) -Ku $(srcdir)/tool/insns2vm.rb $(INSNS2VMOPT) $@
-
-verconf.h: $(RBCONFIG)
-
-loadpath: verconf.h
- @$(CPP) $(XCFLAGS) $(CPPFLAGS) $(srcdir)/loadpath.c | \
- sed -e '1,/^const char ruby_initial_load_paths/d;/;/,$$d' \
- -e '/^ /!d;s/ *"\\0"$$//;s/" *"//g'
-
-un-runnable:
- $(ECHO) cannot make runnable, configure with --enable-load-relative.
- $(Q) exit 1
-
-mjit_config.h:
- $(ECHO) making $@
- @{ \
- . $(srcdir)/tool/mjit_archflag.sh; \
- parse_arch_flags "$(UNIVERSAL_ARCHNAMES)" $(ARCH_FLAG); \
- test "$(Q)" = @ || set -x; \
- echo '#ifndef RUBY_MJIT_CONFIG_H'; \
- echo '#define RUBY_MJIT_CONFIG_H 1'; \
- echo; \
- sep=; \
- echo '#ifdef LOAD_RELATIVE'; \
- quote MJIT_HEADER_INSTALL_DIR "/$(MJIT_HEADER_INSTALL_DIR)"; \
- echo '#else'; \
- quote MJIT_HEADER_INSTALL_DIR "$(rubyarchhdrdir)"; \
- echo '#endif'; \
- quote MJIT_MIN_HEADER_NAME "$(MJIT_MIN_HEADER_NAME)"; \
- sep=,; \
- quote "MJIT_CC_COMMON " $(MJIT_CC); \
- quote "MJIT_CFLAGS MJIT_ARCHFLAG" $(MJIT_CFLAGS); \
- quote "MJIT_OPTFLAGS " $(MJIT_OPTFLAGS); \
- quote "MJIT_DEBUGFLAGS " $(MJIT_DEBUGFLAGS); \
- quote "MJIT_LDSHARED " $(MJIT_LDSHARED); \
- quote "MJIT_DLDFLAGS MJIT_ARCHFLAG" $(MJIT_DLDFLAGS); \
- quote "MJIT_LIBS " $(LIBRUBYARG_SHARED); \
- quote 'PRELOADENV "@PRELOADENV@"'; \
- indent=$${archs:+' '}; \
- define_arch_flags; \
- echo; \
- echo '#endif /* RUBY_MJIT_CONFIG_H */'; \
- } > $@
-
-yes-test-almost yes-test-all: mjit_build_dir.$(SOEXT)
-mjit_build_dir.$(SOEXT): $(MJIT_MIN_HEADER) $(srcdir)/ruby-runner.c ruby-runner.h
- $(ECHO) making $@
- $(Q) $(DLDSHARED) $(MJIT_DLDFLAGS) $(ARCH_FLAG) $(CFLAGS) $(INCFLAGS) $(CPPFLAGS) \
- -DMAKE_MJIT_BUILD_DIR=1 -DMJIT_MIN_HEADER='"$(MJIT_MIN_HEADER)"' \
- $(OUTFLAG)$@ $(srcdir)/ruby-runner.c
-
-# yes-test-basic: leaked-globals
-leaked-globals: $(COMMONOBJS) prog $(srcdir)/tool/leaked-globals PHONY
- $(Q) $(XRUBY) $(srcdir)/tool/leaked-globals NM=$(NM) SYMBOL_PREFIX=$(SYMBOL_PREFIX) $(srcdir)/configure.ac $(COMMONOBJS)
diff --git a/template/configure-ext.mk.tmpl b/template/configure-ext.mk.tmpl
index 438e109eba..4f0d31d700 100644
--- a/template/configure-ext.mk.tmpl
+++ b/template/configure-ext.mk.tmpl
@@ -24,7 +24,7 @@ end
MINIRUBY = <%=miniruby%>
SCRIPT_ARGS = <%=script_args%>
EXTMK_ARGS = $(SCRIPT_ARGS) --gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
- --make-flags="MINIRUBY='$(MINIRUBY)'"
+ --make-flags='MINIRUBY=$(MINIRUBY)'
all: exts gems
exts:
diff --git a/template/depend.tmpl b/template/depend.tmpl
deleted file mode 100644
index 0301ce074c..0000000000
--- a/template/depend.tmpl
+++ /dev/null
@@ -1,2 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-# AUTOGENERATED DEPENDENCIES END
diff --git a/template/encdb.h.tmpl b/template/encdb.h.tmpl
index 06afb5dbe1..9de29bebde 100644
--- a/template/encdb.h.tmpl
+++ b/template/encdb.h.tmpl
@@ -40,28 +40,20 @@ encdirs.each do |encdir|
files[fn] = true
open(File.join(encdir,fn)) do |f|
name = nil
- skip_ifndef_ruby = false
- encoding_def = false
f.each_line do |line|
- case line
- when /^#ifndef RUBY/
- skip_ifndef_ruby = true
- when /^#endif/
- skip_ifndef_ruby = false
- end
- next if skip_ifndef_ruby
- encoding_def = true if /^OnigEncodingDefine/ =~ line
- if encoding_def && /"(.*?)"/ =~ line
- encoding_def = false
- if name
- lines << %[ENC_SET_BASE("#$1", "#{name}");]
- else
- name = $1
+ if (/^#ifndef RUBY/ =~ line)..(/^#endif/ =~ line)
+ elsif (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
+ if $1
+ if name
+ lines << %[ENC_SET_BASE("#$1", "#{name}");]
+ else
+ name = $1
+ end
+ check_duplication(defs, $1, fn, $.)
+ next if BUILTIN_ENCODINGS[name]
+ encodings << $1
+ count += 1
end
- check_duplication(defs, $1, fn, $.)
- next if BUILTIN_ENCODINGS[name]
- encodings << $1
- count += 1
else
case line
when /^\s*rb_enc_register\(\s*"([^"]+)"/
diff --git a/template/exts.mk.tmpl b/template/exts.mk.tmpl
index ea1219805b..e35c28294e 100644
--- a/template/exts.mk.tmpl
+++ b/template/exts.mk.tmpl
@@ -128,25 +128,14 @@ libencs:
ext/extinit.<%=objext%>:
$(Q)$(MAKE)<%=mflags%> V=$(V) EXTINITS="$(EXTINITS)" $@
-% exts = macros["extensions"].map {|e|e.chomp("/.")}.sort
-% targets.each do |tgt|
-% exts.each do |d|
-% t = "#{d}/#{tgt}"
-% if /^(dist|real)?clean$/ =~ tgt
-% deps = exts.select {|e|e.start_with?("#{d}/")}.map {|e|"#{e}/#{tgt}"}
-% pd = ' ' + deps.join(' ') unless deps.empty?
-% else
-% pext = File.dirname(d)
-% pd = " #{pext}/#{tgt}" if exts.include?(pext)
-% end
-<%=t%>:<%=pd%>
-% if /^(dist|real)clean$/ =~ tgt
+% targets.product(macros["extensions"].map {|e|e.chomp("/.")}) do |t, e|
+<%=e%>/<%=t%>:
+% if /^(dist|real)clean$/ =~ t
$(ECHO) $(@F)ing $(@D)
-% end
+% end
$(Q)<%= submake %><%=mflags%> V=$(V) $(@F)
-% if /^(dist|real)clean$/ =~ tgt
+% if /^(dist|real)clean$/ =~ t
$(Q)$(RMDIRS) $(@D)
-% end
% end
% end
diff --git a/template/fake.rb.in b/template/fake.rb.in
index f1da719ecb..5e95530c38 100644
--- a/template/fake.rb.in
+++ b/template/fake.rb.in
@@ -7,15 +7,12 @@ while /\A(\w+)=(.*)/ =~ ARGV[0]
end
if inc = arg['i']
src = inc == '-' ? STDIN.read : File.read(inc)
- def src.value(name)
- eval(self[/\bruby_#{name}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1].gsub(/#/, '\\#'))
- end
arg['versions'] = version = {}
File.read(File.join(arg['srcdir'], 'version.c')).
scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|STR)\(([^()]*)\)/m) do |n, v|
- version[n] = src.value(v)
+ version[n] =
+ eval(src[/\bruby_#{v}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1].gsub(/#/, '\\#'))
end
- arg['RUBY_DESCRIPTION_WITH_JIT'] = src.value('description_with_jit')
end
%>baseruby="<%=arg['BASERUBY']%>"
_\
@@ -32,19 +29,12 @@ class Object
CROSS_COMPILING = RUBY_PLATFORM
constants.grep(/^RUBY_/) {|n| remove_const n}
% arg['versions'].each {|n, v|
- <%=n%> = <%if n=='RUBY_DESCRIPTION' %>RubyVM.const_defined?(:MJIT) && RubyVM::MJIT.enabled? ?
- <%=arg['RUBY_DESCRIPTION_WITH_JIT'].inspect%> :
- <%end%><%=v.inspect%>
+ <%=n%> = <%=v.inspect%>
% }
end
builddir = File.dirname(File.expand_path(__FILE__))
srcdir = "<%=arg['srcdir']%>"
top_srcdir = File.realpath(srcdir, builddir)
fake = File.join(top_srcdir, "tool/fake.rb")
-eval(File.binread(fake), nil, fake)
-ropt = "-r#{__FILE__}"
-["RUBYOPT"].each do |flag|
- opt = ENV[flag]
- opt = opt ? ([ropt] | opt.b.split(/\s+/)).join(" ") : ropt
- ENV[flag] = opt
-end
+eval(File.read(fake), nil, fake)
+ENV["RUBYOPT"] = ["-r#{__FILE__}", ENV["RUBYOPT"]].compact.join(" ")
diff --git a/template/insns.inc.tmpl b/template/insns.inc.tmpl
new file mode 100644
index 0000000000..112732dce5
--- /dev/null
+++ b/template/insns.inc.tmpl
@@ -0,0 +1,24 @@
+/** -*-c-*-
+ This file contains YARV instructions list.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'template/insns.inc.tmpl'
+ or tool/insns2vm.rb
+ */
+
+
+/* BIN : Basic Instruction Name */
+#define BIN(n) YARVINSN_##n
+
+enum ruby_vminsn_type {
+% @insns.each do |insn|
+ BIN(<%=insn.name%>),
+% end
+ VM_INSTRUCTION_SIZE
+};
+
+#define ASSERT_VM_INSTRUCTION_SIZE(array) \
+ STATIC_ASSERT(numberof_##array, numberof(array) == VM_INSTRUCTION_SIZE)
diff --git a/template/insns_info.inc.tmpl b/template/insns_info.inc.tmpl
new file mode 100644
index 0000000000..933eb5ae0e
--- /dev/null
+++ b/template/insns_info.inc.tmpl
@@ -0,0 +1,109 @@
+/** -*-c-*-
+ This file contains instruction information for yarv instruction sequence.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'template/insns_info.inc.tmpl'
+ or tool/insns2vm.rb
+ */
+
+% TYPE_CHARS.each do |t, c|
+#define <%=t%> '<%=c%>'
+% end
+
+static const unsigned short insn_name_info_offset[] = {
+% insn_name_length = @insns.inject(0) do |ofs, insn|
+ <%= ofs %>,
+% ofs + insn.name.size + 1
+% end
+};
+
+ASSERT_VM_INSTRUCTION_SIZE(insn_name_info_offset);
+
+static const char insn_name_info_base[<%=insn_name_length%>] = ""
+% @insns.each do |insn|
+ "<%= insn.name %>\0"
+% end
+;
+
+#define insn_name_info insn_name_info_base+insn_name_info_offset
+
+static const char insn_operand_info[][8] = {
+% @insns.each do |insn|
+ "\<%= (insn.opes.size+1).to_s(8) %>""<%
+ insn.opes.each {|type, _|
+ %><%=TYPE_CHARS.fetch(op2typesig(type))%><%
+ }%>",
+% end
+};
+
+ASSERT_VM_INSTRUCTION_SIZE(insn_operand_info);
+
+#ifdef USE_INSN_RET_NUM
+static const unsigned short insn_stack_push_num_info[] = {
+% @insns.each do |insn|
+ <%= insn.rets.size %>,
+% end
+};
+
+ASSERT_VM_INSTRUCTION_SIZE(insn_stack_push_num_info);
+#endif
+
+#ifdef USE_INSN_STACK_INCREASE
+static int
+insn_stack_increase(int depth, int insn, VALUE *opes)
+{
+ switch (insn) {
+% @insns.each do |insn|
+ case BIN(<%= insn.name %>): {
+ <%= insn.sp_increase_c_expr %>
+ }
+% end
+ default:
+ rb_bug("insn_sp_increase: unreachable");
+ }
+ return 0;
+}
+#endif
+
+/* some utilities */
+
+static int
+insn_len(VALUE insn)
+{
+ return (unsigned char)insn_operand_info[(int)insn][0];
+}
+
+static const char *
+insn_name(VALUE insn)
+{
+ return insn_name_info[(int)insn];
+}
+
+static const char *
+insn_op_types(VALUE insn)
+{
+ return insn_operand_info[(int)insn]+1;
+}
+
+static int
+insn_op_type(VALUE insn, long pos)
+{
+ int len = insn_len(insn) - 1;
+ if (pos < len) {
+ return insn_operand_info[(int)insn][pos+1];
+ }
+ else{
+ return 0;
+ }
+}
+
+#ifdef USE_INSN_RET_NUM
+static int
+insn_ret_num(VALUE insn)
+{
+ return insn_stack_push_num_info[(int)insn];
+}
+#endif
diff --git a/template/minsns.inc.tmpl b/template/minsns.inc.tmpl
new file mode 100644
index 0000000000..f32b28cb7f
--- /dev/null
+++ b/template/minsns.inc.tmpl
@@ -0,0 +1,14 @@
+/** -*-c-*-
+ This file contains YARV instructions list, to define YARVCore::Instructions.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'template/minsns.inc.tmpl'
+ or tool/insns2vm.rb
+ */
+
+% @insns.each_with_index do |insn, i|
+ rb_define_const(mYarvInsns, "I<%=insn.name%>", INT2FIX(<%=i%>));
+% end
diff --git a/template/opt_sc.inc.tmpl b/template/opt_sc.inc.tmpl
new file mode 100644
index 0000000000..4c85f96c0f
--- /dev/null
+++ b/template/opt_sc.inc.tmpl
@@ -0,0 +1,35 @@
+/* -*-c-*- *********************************************************/
+/*******************************************************************/
+/*******************************************************************/
+/**
+ This file is for threaded code.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'template/opt_sc.inc.tmpl'
+ or tool/insns2vm.rb
+ */
+
+#define SC_STATE_SIZE 6
+
+#define SCS_XX 1
+#define SCS_AX 2
+#define SCS_BX 3
+#define SCS_AB 4
+#define SCS_BA 5
+
+#define SC_ERROR 0xffffffff
+
+static const VALUE sc_insn_info[][SC_STATE_SIZE] = {
+<%= sc_insn_info %>
+};
+
+ASSERT_VM_INSTRUCTION_SIZE(sc_insn_info);
+
+static const VALUE sc_insn_next[] = {
+<%= sc_insn_next %>
+};
+
+ASSERT_VM_INSTRUCTION_SIZE(sc_insn_next);
diff --git a/template/optinsn.inc.tmpl b/template/optinsn.inc.tmpl
new file mode 100644
index 0000000000..b1fba6dea3
--- /dev/null
+++ b/template/optinsn.inc.tmpl
@@ -0,0 +1,78 @@
+/* -*-c-*- *********************************************************/
+/*******************************************************************/
+/*******************************************************************/
+/**
+ This file is for threaded code.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'template/optinsn.inc.tmpl'
+ or tool/insns2vm.rb
+ */
+
+static INSN *
+insn_operands_unification(INSN *insnobj)
+{
+#ifdef OPT_OPERANDS_UNIFICATION
+ /* optimize rule */
+ switch(insnobj->insn_id){
+% opt_insns_map.each do |originsn, optinsns|
+ case BIN(<%=originsn.name%>):
+% optinsns.each {|opti|
+ if (
+% opti.defopes.each_with_index {|opinfo, i|
+% next if opinfo[1] == '*'
+ insnobj->operands[<%=i%>] == <%=val_as_type(opinfo)%> &&
+% }
+ 1) {
+% idx = 0
+% opti.defopes.each_with_index {|opinfo, n|
+% if opinfo[1] == '*'
+% if idx != n
+ insnobj->operands[<%=idx%>] = insnobj->operands[<%=n%>];
+% end
+% idx += 1
+% end
+% }
+ insnobj->insn_id = BIN(<%=opti.name%>);
+ insnobj->operand_size = <%=idx%>;
+ break;
+ }
+% }
+ break;
+% end
+
+ default:
+ /* do nothing */;
+ break;
+ }
+#endif
+ return insnobj;
+}
+
+int
+rb_insn_unified_local_var_level(VALUE insn)
+{
+#ifdef OPT_OPERANDS_UNIFICATION
+ /* optimize rule */
+ switch (insn) {
+% opt_insns_map.each do |originsn, optinsns|
+% optinsns.each {|opti|
+ case BIN(<%=opti.name%>):
+% opti.defopes.each {|opinfo|
+% next if opinfo[1] == '*'
+ return <%=opinfo[1]%>;
+% break
+% }
+% }
+% end
+
+ default:
+ /* do nothing */;
+ break;
+ }
+#endif
+ return -1;
+}
diff --git a/template/optunifs.inc.tmpl b/template/optunifs.inc.tmpl
new file mode 100644
index 0000000000..3ac5872346
--- /dev/null
+++ b/template/optunifs.inc.tmpl
@@ -0,0 +1,67 @@
+/* -*-c-*- *********************************************************/
+/*******************************************************************/
+/*******************************************************************/
+/**
+ This file is for threaded code.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'template/optunifs.inc.tmpl'
+ or tool/insns2vm.rb
+ */
+
+/*
+ static const int UNIFIED_insn_name_1[] = {id, size, ...};
+ static const int UNIFIED_insn_name_2[] = {id, size, ...};
+ ...
+
+ static const int *const UNIFIED_insn_name[] = {size,
+ UNIFIED_insn_name_1,
+ UNIFIED_insn_name_2, ...};
+ ...
+
+ static const int *const *const unified_insns_data[] = {
+ UNIFIED_insn_nameA,
+ UNIFIED_insn_nameB, ...};
+ */
+
+% unif_insns_data = @insns.find_all {|insn| !insn.is_sc}.map do |insn|
+% size = insn.unifs.size
+% if size > 0
+% name = "UNIFIED_#{insn.name}"
+% insn.unifs.sort_by{|unif| -unif[1].size}.each_with_index do |(uni_insn, uni_insns), i|
+% uni_insns = uni_insns[1..-1]
+static const int <%=name%>_<%=i%>[] = {
+ BIN(<%=uni_insn.name%>), <%=uni_insns.size + 2%>,
+ <% uni_insns.map{|e| -%>
+BIN(<%=e.name%>),<% -%>
+% }
+
+};
+% end
+
+static const int *const <%=name%>[] = {(int *)<%=size+1%>,
+% size.times do |e|
+ <%=name%>_<%=e%>,
+% end
+};
+% name
+% end
+% end
+
+static const int *const *const unified_insns_data[] = {<%#-%>
+% unif_insns_data.each_with_index do |insn, i|
+% if (i%8).zero?
+
+ <% -%>
+% end
+ <%=insn || "0"%>,<%#-%>
+% end
+
+};
+
+#undef GET_INSN_NAME
+
+ASSERT_VM_INSTRUCTION_SIZE(unified_insns_data);
diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl
index b582e2ddd6..11ec71f575 100644
--- a/template/prelude.c.tmpl
+++ b/template/prelude.c.tmpl
@@ -30,21 +30,12 @@ class Prelude
"<internal:" + prelude_base(filename) + ">"
end
- def initialize(output, preludes, vpath)
- @output = output
+ def initialize(init_name, preludes, vpath)
+ @init_name = init_name
@have_sublib = false
@vpath = vpath
- @prelude_count = 0
- @builtin_count = 0
@preludes = {}
- @mains = preludes.map do |filename|
- if prelude = filename.end_with?("golf_prelude.rb")
- @prelude_count += 1
- else
- @builtin_count += 1
- end
- translate(filename, (filename unless prelude))[0]
- end
+ @mains = preludes.map {|filename| translate(filename)[0]}
@preludes.delete_if {|_, (_, _, lines, sub)| sub && lines.empty?}
end
@@ -54,7 +45,6 @@ class Prelude
lines = []
result = [@preludes.size, @vpath.strip(filename), lines, sub]
@vpath.foreach(filename) do |line|
- line.force_encoding("ASCII-8BIT") if line.respond_to?(:force_encoding)
@preludes[filename] ||= result
comment = ($1 || '' if line.sub!(/(?:^|\s+)\#(?:$|[#\s](.*))/, ''))
if line.size > LINE_LIMIT
@@ -79,7 +69,7 @@ class Prelude
result
end
end
-Prelude.new(output, ARGV, vpath).instance_eval do
+Prelude.new(output && output[/\w+(?=_prelude.c\b)/] || 'prelude', ARGV, vpath).instance_eval do
-%>
/* -*-c-*-
THIS FILE WAS AUTOGENERATED BY template/prelude.c.tmpl. DO NOT EDIT.
@@ -96,7 +86,9 @@ Prelude.new(output, ARGV, vpath).instance_eval do
% preludes.each {|i, prelude, lines, sub|
% name = prelude_name(*prelude)
-static const char prelude_name<%=i%><%=%>[] = "<%=c_esc(name)%>";
+static const struct {
+ char L0[<%=name.size%><%=%>];
+} prelude_name<%=i%><%=%> = {"<%=c_esc(name)%>"};
static const struct {
% size = beg = 0
% lines.each_with_index {|(line, comment), n|
@@ -123,7 +115,7 @@ static const struct {
% size += line.size
"<%=c_esc(line)%>"<%if comment%>/* <%=c_esc(comment)%> */<%end%>
% }
-#line <%=_erbout.count("\n")+2%> "<%=@output%>"
+#line <%=_erbout.count("\n")+2%> "<%=@init_name%>.c"
};
% }
@@ -143,50 +135,13 @@ prelude_prefix_path(VALUE self)
struct prelude_env *ptr = DATA_PTR(self);
return ptr->prefix_path;
}
-
-% end
-% unless preludes.empty?
-#define PRELUDE_NAME(n) rb_usascii_str_new_static(prelude_name##n, sizeof(prelude_name##n)-1)
-#define PRELUDE_CODE(n) rb_utf8_str_new_static(prelude_code##n.L0, sizeof(prelude_code##n))
-
-static rb_ast_t *
-prelude_ast(VALUE name, VALUE code, int line)
-{
- rb_ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
- if (!ast->body.root) {
- rb_ast_dispose(ast);
- rb_exc_raise(rb_errinfo());
- }
- return ast;
-}
-
% end
-% if @builtin_count > 0
-#define PRELUDE_AST(n, name_str) \
- (((sizeof(prelude_name<%='##'%><%=%>n) - prefix_len - 2) == namelen) && \
- (strncmp(prelude_name<%='##'%><%=%>n + prefix_len, feature_name, namelen) == 0) ? \
- prelude_ast((name_str) = PRELUDE_NAME(n), PRELUDE_CODE(n), 1) : 0)
-
-rb_ast_t *
-rb_builtin_ast(const char *feature_name, VALUE *name_str)
-{
- const size_t prefix_len = rb_strlen_lit("<internal:");
- size_t namelen = strlen(feature_name);
- rb_ast_t *ast = 0;
-% @preludes.each_value do |i, prelude, lines, sub|
-% if sub and sub != true
- if ((ast = PRELUDE_AST(<%=i%><%=%>, *name_str)) != 0) return ast;
-% end
-% end
- return ast;
-}
-
-% end
-% if @prelude_count > 0
-COMPILER_WARNING_PUSH
-#if GCC_VERSION_SINCE(4, 2, 0)
-COMPILER_WARNING_ERROR(-Wmissing-field-initializers)
+% unless preludes.empty?
+#define PRELUDE_STR(n) rb_usascii_str_new_static(prelude_##n.L0, sizeof(prelude_##n))
+#ifdef __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic error "-Wmissing-field-initializers"
#endif
static void
prelude_eval(VALUE code, VALUE name, int line)
@@ -194,7 +149,7 @@ prelude_eval(VALUE code, VALUE name, int line)
static const rb_compile_option_t optimization = {
TRUE, /* int inline_const_cache; */
TRUE, /* int peephole_optimization; */
- FALSE,/* int tailcall_optimization; */
+ TRUE, /* int tailcall_optimization; */
TRUE, /* int specialized_instruction; */
TRUE, /* int operands_unification; */
TRUE, /* int instructions_unification; */
@@ -205,14 +160,20 @@ prelude_eval(VALUE code, VALUE name, int line)
0, /* int debug_level; */
};
- rb_ast_t *ast = prelude_ast(name, code, line);
- rb_iseq_eval(rb_iseq_new_with_opt(&ast->body, name, name, Qnil, INT2FIX(line),
+ rb_ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
+ if (!ast->root) {
+ rb_ast_dispose(ast);
+ rb_exc_raise(rb_errinfo());
+ }
+ rb_iseq_eval(rb_iseq_new_with_opt(ast->root, name, name, Qnil, INT2FIX(line),
NULL, ISEQ_TYPE_TOP, &optimization));
rb_ast_dispose(ast);
}
-COMPILER_WARNING_POP
-
+#ifdef __GNUC__
+# pragma GCC diagnostic pop
+#endif
% end
+
% if @have_sublib
static VALUE
prelude_require(VALUE self, VALUE nth)
@@ -226,10 +187,10 @@ prelude_require(VALUE self, VALUE nth)
ptr->loaded[n] = 1;
switch (n) {
% @preludes.each_value do |i, prelude, lines, sub|
-% if sub == true
+% if sub
case <%=i%><%=%>:
- code = PRELUDE_CODE(<%=i%><%=%>);
- name = PRELUDE_NAME(<%=i%><%=%>);
+ code = PRELUDE_STR(code<%=i%><%=%>);
+ name = PRELUDE_STR(name<%=i%><%=%>);
break;
% end
% end
@@ -242,11 +203,10 @@ prelude_require(VALUE self, VALUE nth)
% end
%end
-% init_name = @output && @output[/\w+(?=_prelude.c\b)/] || 'prelude'
void
-Init_<%=init_name%><%=%>(void)
+Init_<%=@init_name%><%=%>(void)
{
-%unless @prelude_count.zero?
+%unless @preludes.empty?
% if @have_sublib
struct prelude_env memo;
ID name = rb_intern("TMP_RUBY_PREFIX");
@@ -262,7 +222,7 @@ Init_<%=init_name%><%=%>(void)
% end
% preludes.each do |i, prelude, lines, sub|
% next if sub
- prelude_eval(PRELUDE_CODE(<%=i%><%=%>), PRELUDE_NAME(<%=i%><%=%>), 1);
+ prelude_eval(PRELUDE_STR(code<%=i%><%=%>), PRELUDE_STR(name<%=i%><%=%>), 1);
% end
% if @have_sublib
rb_gc_force_recycle(prelude);
diff --git a/template/ruby-runner.h.in b/template/ruby-runner.h.in
index fdfe88dcb9..b94086c565 100644
--- a/template/ruby-runner.h.in
+++ b/template/ruby-runner.h.in
@@ -1,9 +1,7 @@
#define ABS_SRCDIR "@abs_srcdir@"
#define BUILDDIR "@abs_top_builddir@"
#define LIBPATHENV "@LIBPATHENV@"
-#define PRELOADENV "@PRELOADENV@"
#define PATH_SEPARATOR "@PATH_SEPARATOR@"
#define PATH_SEP '@PATH_SEPARATOR@'
#define EXTOUT "@EXTOUT@"
#define ARCH "@arch@"
-#define SOEXT "@SOEXT@"
diff --git a/template/ruby.pc.in b/template/ruby.pc.in
index 7ce4461c05..d874f92c3b 100644
--- a/template/ruby.pc.in
+++ b/template/ruby.pc.in
@@ -38,7 +38,6 @@ sitehdrdir=@sitehdrdir@
rubyarchhdrdir=@rubyarchhdrdir@
vendorarchhdrdir=@vendorarchhdrdir@
sitearchhdrdir=@sitearchhdrdir@
-MAINLIBS=@MAINLIBS@
SOEXT=@SOEXT@
LIBPATH=@LIBPATH@
LIBRUBY_A=@LIBRUBY_A@
diff --git a/template/transdb.h.tmpl b/template/transdb.h.tmpl
index 16565dd638..d0cf101344 100644
--- a/template/transdb.h.tmpl
+++ b/template/transdb.h.tmpl
@@ -36,18 +36,17 @@ transdirs.each do |transdir|
files[fn] = true
path = File.join(transdir,fn)
open(path) do |f|
- transcoder_def = false
f.each_line do |line|
- transcoder_def = true if /^static const rb_transcoder/ =~ line
- if transcoder_def && /"(.*?)"\s*,\s*"(.*?)"/ =~ line
- transcoder_def = false
- from_to = "%s to %s" % [$1, $2]
- if converters[from_to]
- raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
- [path, $., from_to, *converters[from_to].values_at(3, 4)]
- else
- converters[from_to] = [$1, $2, fn[0..-3], path, $.]
- converter_list << from_to
+ if (/^static const rb_transcoder/ =~ line)..(/"(.*?)"\s*,\s*"(.*?)"/ =~ line)
+ if $1 && $2
+ from_to = "%s to %s" % [$1, $2]
+ if converters[from_to]
+ raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
+ [path, $., from_to, *converters[from_to].values_at(3, 4)]
+ else
+ converters[from_to] = [$1, $2, fn[0..-3], path, $.]
+ converter_list << from_to
+ end
end
end
end
diff --git a/template/unicode_norm_gen.tmpl b/template/unicode_norm_gen.tmpl
index a16712fbac..64acfc8d18 100644
--- a/template/unicode_norm_gen.tmpl
+++ b/template/unicode_norm_gen.tmpl
@@ -5,7 +5,7 @@
# Script to generate Ruby data structures used in implementing
# String#unicode_normalize,...
-# Constants for input and output directory
+# Constants for input and ouput directory
InputDataDir = ARGV[0] || 'enc/unicode/data'
unicode_version = InputDataDir[/.*\/(\d+\.\d+\.\d+)(?=\/|\z)/, 1]
@@ -42,7 +42,7 @@ end
class Array
def to_UTF8() collect {|c| c.to_UTF8}.join('') end
- def each_regexp_chars(n = 1) # converts an array of Integers to character ranges
+ def each_regexp_chars(n = 8) # converts an array of Integers to character ranges
sort.inject([]) do |ranges, value|
if ranges.last and ranges.last[1]+1>=value
ranges.last[1] = value
@@ -82,7 +82,7 @@ combining_class = {} # constant to allow use in Integer#to_UTF8
# read the file 'UnicodeData.txt'
vpath.foreach("#{InputDataDir}/UnicodeData.txt") do |line|
- codepoint, name, _, char_class, _, decomposition, *_rest = line.split(";")
+ codepoint, name, _2, char_class, _4, decomposition, *_rest = line.split(";")
case decomposition
when /^[0-9A-F]/
@@ -193,28 +193,28 @@ module UnicodeNormalize # :nodoc:
"<%end%>]"
class_table = {
-% combining_class.each do |key, value|
- "<%=key.to_UTF8%>"=><%=value%><%=%>,
+% combining_class.each_slice(8) do |slice|
+ <% slice.each do |key, value|%> "<%=key.to_UTF8%>"=><%=value%><%=%>,<% end%>
% end
}
class_table.default = 0
CLASS_TABLE = class_table.freeze
DECOMPOSITION_TABLE = {
-% decomposition_table.each do |key, value|
- "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,
+% decomposition_table.each_slice(8) do |slice|
+ <% slice.each do |key, value|%> "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,<% end%>
% end
}.freeze
KOMPATIBLE_TABLE = {
-% kompatible_table.each do |key, value|
- "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,
+% kompatible_table.each_slice(8) do |slice|
+ <% slice.each do |key, value|%> "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,<% end%>
% end
}.freeze
COMPOSITION_TABLE = {
-% composition_table.each do |key, value|
- "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,
+% composition_table.each_slice(8) do |slice|
+ <% slice.each do |key, value|%> "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,<% end%>
% end
}.freeze
end
diff --git a/template/verconf.h.tmpl b/template/verconf.h.tmpl
index 9ba2bd6de5..3b8a8aad76 100644
--- a/template/verconf.h.tmpl
+++ b/template/verconf.h.tmpl
@@ -4,7 +4,7 @@
% C = rbconfig::MAKEFILE_CONFIG.dup
% def C.[](name) str = super and (str unless str.empty?); end
#define RUBY_BASE_NAME "${RUBY_BASE_NAME}"
-#define RUBY_VERSION_NAME "${RUBY_VERSION_NAME}"
+#define RUBY_VERSION_NAME RUBY_BASE_NAME"-"RUBY_LIB_VERSION
% if C["RUBY_LIB_VERSION_STYLE"]
#define RUBY_LIB_VERSION_STYLE ${RUBY_LIB_VERSION_STYLE}
% elsif !C["RUBY_LIB_VERSION"]
diff --git a/template/vm.inc.tmpl b/template/vm.inc.tmpl
new file mode 100644
index 0000000000..14b6ba3f10
--- /dev/null
+++ b/template/vm.inc.tmpl
@@ -0,0 +1,33 @@
+/* -*-c-*- *********************************************************/
+/*******************************************************************/
+/*******************************************************************/
+/**
+ This file is VM main loop.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'insns.def'
+ */
+
+
+% line = _erbout.count("\n") + 1
+% @insns.each do |insn|
+<%
+line += 1
+make_insn_def(insn).split(/(__CURRENT_LINE__|__CURRENT_FILE__)/).each {|e|
+ %><%=
+ case e
+ when '__CURRENT_LINE__'
+ line.to_s
+ when '__CURRENT_FILE__'
+ "vm.inc"
+ else
+ line += e.count("\n")
+ e
+ end
+ %><%
+}
+%>
+% end
diff --git a/template/vmtc.inc.tmpl b/template/vmtc.inc.tmpl
new file mode 100644
index 0000000000..3c313113a5
--- /dev/null
+++ b/template/vmtc.inc.tmpl
@@ -0,0 +1,21 @@
+/* -*-c-*- *********************************************************/
+/*******************************************************************/
+/*******************************************************************/
+/**
+ This file is for threaded code.
+
+ ----
+ This file is auto generated by insns2vm.rb
+ DO NOT TOUCH!
+
+ If you want to fix something, you must edit 'template/vmtc.inc.tmpl'
+ or insns2vm.rb
+ */
+
+static const void *const insns_address_table[] = {
+% @insns.each do |insn|
+ LABEL_PTR(<%=insn.name%>),
+% end
+};
+
+ASSERT_VM_INSTRUCTION_SIZE(insns_address_table);
diff --git a/doc/yarvarch.en b/template/yarvarch.en
index 7a76e25b7e..7a76e25b7e 100644
--- a/doc/yarvarch.en
+++ b/template/yarvarch.en
diff --git a/doc/yarvarch.ja b/template/yarvarch.ja
index 2739ec6b14..2739ec6b14 100644
--- a/doc/yarvarch.ja
+++ b/template/yarvarch.ja
diff --git a/template/yasmdata.rb.tmpl b/template/yasmdata.rb.tmpl
new file mode 100644
index 0000000000..a11df0a712
--- /dev/null
+++ b/template/yasmdata.rb.tmpl
@@ -0,0 +1,20 @@
+# -*-ruby-*-
+#
+
+class VM
+ class InstructionSequence
+ class Instruction
+ InsnID2NO = {
+<%= insn_id2no %>
+ }
+
+ def self.id2insn_no id
+ if InsnID2NO.has_key? id
+ InsnID2NO[id]
+ end
+ end
+ end
+ end
+end
+
+
diff --git a/test/-ext-/arith_seq/test_arith_seq_extract.rb b/test/-ext-/arith_seq/test_arith_seq_extract.rb
deleted file mode 100644
index d64fe6a7b5..0000000000
--- a/test/-ext-/arith_seq/test_arith_seq_extract.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-
-class Test_ArithSeq < Test::Unit::TestCase
- def test_extract_with_arith_seq
- assert_separately([], <<-"end;") #do
- require '-test-/arith_seq/extract'
-
- b, e, s, f, r = Enumerator::ArithmeticSequence.__extract__(1.step(10, 2))
- assert_equal([1, 10, 2, 0, 1], [b, e, s, f, r])
-
- b, e, s, f, r = Enumerator::ArithmeticSequence.__extract__((1..10) % 2)
- assert_equal([1, 10, 2, 0, 1], [b, e, s, f, r])
-
- b, e, s, f, r = Enumerator::ArithmeticSequence.__extract__((1...10) % 2)
- assert_equal([1, 10, 2, 1, 1], [b, e, s, f, r])
- end;
- end
-
- def test_extract_with_range
- assert_separately([], <<-"end;") #do
- require '-test-/arith_seq/extract'
-
- b, e, s, f, r = Enumerator::ArithmeticSequence.__extract__(1..10)
- assert_equal([1, 10, 1, 0, 1], [b, e, s, f, r])
-
- b, e, s, f, r = Enumerator::ArithmeticSequence.__extract__(1...10)
- assert_equal([1, 10, 1, 1, 1], [b, e, s, f, r])
- end;
- end
-
- def test_extract_with_others
- assert_separately([], <<-"end;") #do
- require '-test-/arith_seq/extract'
-
- b, e, s, f, r = Enumerator::ArithmeticSequence.__extract__(nil)
- assert_equal([nil, nil, nil, nil, 0], [b, e, s, f, r])
- end;
- end
-end
diff --git a/test/-ext-/array/test_resize.rb b/test/-ext-/array/test_resize.rb
index c7a57f3cf1..f6a368cb75 100644
--- a/test/-ext-/array/test_resize.rb
+++ b/test/-ext-/array/test_resize.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require '-test-/array/resize'
-class Test_Array < Test::Unit::TestCase
+class TestArray < Test::Unit::TestCase
class TestResize < Test::Unit::TestCase
def test_expand
feature = '[ruby-dev:42912]'
diff --git a/test/-ext-/bignum/test_big2str.rb b/test/-ext-/bignum/test_big2str.rb
index cc28d97ce5..296a5a9c49 100644
--- a/test/-ext-/bignum/test_big2str.rb
+++ b/test/-ext-/bignum/test_big2str.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require "-test-/bignum"
-class Test_Bignum < Test::Unit::TestCase
+class TestBignum < Test::Unit::TestCase
class TestBig2str < Test::Unit::TestCase
SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT
diff --git a/test/-ext-/bignum/test_bigzero.rb b/test/-ext-/bignum/test_bigzero.rb
index cf34964acd..43a99b01a3 100644
--- a/test/-ext-/bignum/test_bigzero.rb
+++ b/test/-ext-/bignum/test_bigzero.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require "-test-/bignum"
-class Test_Bignum < Test::Unit::TestCase
+class TestBignum < Test::Unit::TestCase
class TestBigZero < Test::Unit::TestCase
def test_equal_0
bug8204 = '[ruby-core:53893] [Bug #8204]'
diff --git a/test/-ext-/bignum/test_div.rb b/test/-ext-/bignum/test_div.rb
index 4e4bd3fa3e..c53332630a 100644
--- a/test/-ext-/bignum/test_div.rb
+++ b/test/-ext-/bignum/test_div.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require "-test-/bignum"
-class Test_Bignum < Test::Unit::TestCase
+class TestBignum < Test::Unit::TestCase
class TestDiv < Test::Unit::TestCase
SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT
diff --git a/test/-ext-/bignum/test_mul.rb b/test/-ext-/bignum/test_mul.rb
index 5de046a804..fa974ab55d 100644
--- a/test/-ext-/bignum/test_mul.rb
+++ b/test/-ext-/bignum/test_mul.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require "-test-/bignum"
-class Test_Bignum < Test::Unit::TestCase
+class TestBignum < Test::Unit::TestCase
class TestMul < Test::Unit::TestCase
SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT
diff --git a/test/-ext-/bignum/test_pack.rb b/test/-ext-/bignum/test_pack.rb
index 5d553435fe..04bf3e02de 100644
--- a/test/-ext-/bignum/test_pack.rb
+++ b/test/-ext-/bignum/test_pack.rb
@@ -4,7 +4,7 @@
require 'test/unit'
require "-test-/bignum"
-class Test_Bignum < Test::Unit::TestCase
+class TestBignum < Test::Unit::TestCase
class TestPack < Test::Unit::TestCase
MSWORD_FIRST = Integer::INTEGER_PACK_MSWORD_FIRST
diff --git a/test/-ext-/bignum/test_str2big.rb b/test/-ext-/bignum/test_str2big.rb
index 6886e4a968..c14811d9c4 100644
--- a/test/-ext-/bignum/test_str2big.rb
+++ b/test/-ext-/bignum/test_str2big.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require "-test-/bignum"
-class Test_Bignum < Test::Unit::TestCase
+class TestBignum < Test::Unit::TestCase
class TestStr2big < Test::Unit::TestCase
SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT
diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb
index 576628d63e..7bfb660faf 100644
--- a/test/-ext-/bug_reporter/test_bug_reporter.rb
+++ b/test/-ext-/bug_reporter/test_bug_reporter.rb
@@ -4,12 +4,10 @@ require 'tmpdir'
class TestBugReporter < Test::Unit::TestCase
def test_bug_reporter_add
- description = RUBY_DESCRIPTION
- description = description.sub(/\+JIT /, '') if RubyVM::MJIT.enabled?
expected_stderr = [
:*,
/\[BUG\]\sSegmentation\sfault.*\n/,
- /#{ Regexp.quote(description) }\n\n/,
+ /#{ Regexp.quote(RUBY_DESCRIPTION) }\n\n/,
:*,
/Sample bug reporter: 12345/,
:*
diff --git a/test/-ext-/debug/test_debug.rb b/test/-ext-/debug/test_debug.rb
index 8a351d74fa..bc41c1bb79 100644
--- a/test/-ext-/debug/test_debug.rb
+++ b/test/-ext-/debug/test_debug.rb
@@ -63,7 +63,7 @@ class TestDebug < Test::Unit::TestCase
def each
yield :each_entry
end
- end
+ end
def test_lazy_block
x = MyRelation.new.any? do
diff --git a/test/-ext-/debug/test_profile_frames.rb b/test/-ext-/debug/test_profile_frames.rb
index 0335267ee9..5ea506046e 100644
--- a/test/-ext-/debug/test_profile_frames.rb
+++ b/test/-ext-/debug/test_profile_frames.rb
@@ -3,16 +3,6 @@ require 'test/unit'
require '-test-/debug'
class SampleClassForTestProfileFrames
- class << self
- attr_accessor :sample4
- end
-
- self.sample4 = Module.new do
- def self.corge(block)
- Sample2.new.baz(block)
- end
- end
-
class Sample2
def baz(block)
instance_eval "def zab(block) block.call end"
@@ -20,16 +10,8 @@ class SampleClassForTestProfileFrames
end
end
- module Sample3
- class << self
- def qux(block)
- SampleClassForTestProfileFrames.sample4.corge(block)
- end
- end
- end
-
def self.bar(block)
- Sample3.qux(block)
+ Sample2.new.baz(block)
end
def foo(block)
@@ -47,8 +29,6 @@ class TestProfileFrames < Test::Unit::TestCase
"test_profile_frames",
"zab",
"baz",
- "corge",
- "qux",
"bar",
"foo",
"test_profile_frames",
@@ -57,8 +37,6 @@ class TestProfileFrames < Test::Unit::TestCase
"test_profile_frames",
"zab",
"baz",
- "corge",
- "qux",
"bar",
"foo",
"test_profile_frames",
@@ -67,8 +45,6 @@ class TestProfileFrames < Test::Unit::TestCase
"TestProfileFrames#test_profile_frames",
"#{obj.inspect}.zab",
"SampleClassForTestProfileFrames::Sample2#baz",
- "#{SampleClassForTestProfileFrames.sample4.inspect}.corge",
- "SampleClassForTestProfileFrames::Sample3.qux",
"SampleClassForTestProfileFrames.bar",
"SampleClassForTestProfileFrames#foo",
"TestProfileFrames#test_profile_frames",
@@ -77,21 +53,17 @@ class TestProfileFrames < Test::Unit::TestCase
TestProfileFrames,
obj,
SampleClassForTestProfileFrames::Sample2,
- SampleClassForTestProfileFrames.sample4,
- SampleClassForTestProfileFrames::Sample3,
SampleClassForTestProfileFrames, # singleton method
SampleClassForTestProfileFrames,
TestProfileFrames,
]
singleton_method_p = [
- false, true, false, true, true, true, false, false, false,
+ false, true, false, true, false, false, false,
]
method_names = [
"test_profile_frames",
"zab",
"baz",
- "corge",
- "qux",
"bar",
"foo",
"test_profile_frames",
@@ -100,14 +72,14 @@ class TestProfileFrames < Test::Unit::TestCase
"TestProfileFrames#test_profile_frames",
"#{obj.inspect}.zab",
"SampleClassForTestProfileFrames::Sample2#baz",
- "#{SampleClassForTestProfileFrames.sample4.inspect}.corge",
- "SampleClassForTestProfileFrames::Sample3.qux",
"SampleClassForTestProfileFrames.bar",
"SampleClassForTestProfileFrames#foo",
"TestProfileFrames#test_profile_frames",
]
- paths = [ file=__FILE__, "(eval)", file, file, file, file, file, file ]
- absolute_paths = [ file, nil, file, file, file, file, file, file ]
+ paths = [ file=__FILE__, "(eval)", file, file, file, file ]
+ absolute_paths = [ file, nil, file, file, file, file ]
+
+ # pp frames
assert_equal(labels.size, frames.size)
diff --git a/test/-ext-/exception/test_data_error.rb b/test/-ext-/exception/test_data_error.rb
index 0fec4ac1ec..d33d8ca43f 100644
--- a/test/-ext-/exception/test_data_error.rb
+++ b/test/-ext-/exception/test_data_error.rb
@@ -2,7 +2,7 @@
require 'test/unit'
module Bug
- class Test_ExceptionDE < Test::Unit::TestCase
+ class TestException < Test::Unit::TestCase
def test_cleanup_data_error
bug9167 = '[ruby-core:58643] [Bug #9167]'
assert_normal_exit(<<-'end;', bug9167) # do
diff --git a/test/-ext-/exception/test_enc_raise.rb b/test/-ext-/exception/test_enc_raise.rb
index 706f0e2772..2bc7f02413 100644
--- a/test/-ext-/exception/test_enc_raise.rb
+++ b/test/-ext-/exception/test_enc_raise.rb
@@ -3,7 +3,7 @@ require 'test/unit'
require '-test-/exception'
module Bug
- class Test_ExceptionER < Test::Unit::TestCase
+ class TestException < Test::Unit::TestCase
def test_enc_raise
feature5650 = '[ruby-core:41160]'
Encoding.list.each do |enc|
diff --git a/test/-ext-/exception/test_ensured.rb b/test/-ext-/exception/test_ensured.rb
index c250e46bab..858245868b 100644
--- a/test/-ext-/exception/test_ensured.rb
+++ b/test/-ext-/exception/test_ensured.rb
@@ -5,7 +5,7 @@ module Bug
class Bug7802 < RuntimeError
end
- class Test_ExceptionE < Test::Unit::TestCase
+ class TestException < Test::Unit::TestCase
def test_ensured
assert_separately([], <<-'end;') # do
diff --git a/test/-ext-/exception/test_exception_at_throwing.rb b/test/-ext-/exception/test_exception_at_throwing.rb
index 4bce348a25..aba26079eb 100644
--- a/test/-ext-/exception/test_exception_at_throwing.rb
+++ b/test/-ext-/exception/test_exception_at_throwing.rb
@@ -2,7 +2,7 @@
require 'test/unit'
module Bug
- class Test_ExceptionAT < Test::Unit::TestCase
+ class TestException < Test::Unit::TestCase
def test_exception_at_throwing
assert_separately(%w[-r-test-/exception], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;
diff --git a/test/-ext-/funcall/test_passing_block.rb b/test/-ext-/funcall/test_passing_block.rb
index d1164871b0..5112bc0925 100644
--- a/test/-ext-/funcall/test_passing_block.rb
+++ b/test/-ext-/funcall/test_passing_block.rb
@@ -3,8 +3,8 @@ require 'test/unit'
class TestFuncall < Test::Unit::TestCase
module Relay
- def self.target(*args, **kw, &block)
- yield(*args, **kw) if block
+ def self.target(*args, &block)
+ yield(*args) if block
end
end
require '-test-/funcall'
@@ -20,56 +20,4 @@ class TestFuncall < Test::Unit::TestCase
Relay.with_funcall_passing_block("feature#4504") {|arg| ok = arg || true}
assert_equal("feature#4504", ok)
end
-
- def test_with_funcall_passing_block_kw
- block = ->(*a, **kw) { [a, kw] }
- assert_equal([[1], {}], Relay.with_funcall_passing_block_kw(0, 1, &block))
- assert_equal([[], {a: 1}], Relay.with_funcall_passing_block_kw(1, a: 1, &block))
- assert_equal([[1], {a: 1}], Relay.with_funcall_passing_block_kw(1, 1, a: 1, &block))
- assert_equal([[{}], {}], Relay.with_funcall_passing_block_kw(2, {}, **{}, &block))
- assert_equal([[], {a: 1}], Relay.with_funcall_passing_block_kw(3, a: 1, &block))
- assert_equal([[{a: 1}], {}], Relay.with_funcall_passing_block_kw(3, {a: 1}, **{}, &block))
- assert_warn(/warning: Passing the keyword argument as the last hash parameter is deprecated.*The called method is defined here/m) do
- assert_equal({}, Relay.with_funcall_passing_block_kw(3, **{}, &->(a){a}))
- end
- end
-
- def test_with_funcallv_public_kw
- o = Object.new
- def o.foo(*args, **kw)
- [args, kw]
- end
- def o.bar(*args, **kw)
- [args, kw]
- end
- o.singleton_class.send(:private, :bar)
- def o.baz(arg)
- arg
- end
- assert_equal([[1], {}], Relay.with_funcallv_public_kw(o, :foo, 0, 1))
- assert_equal([[], {a: 1}], Relay.with_funcallv_public_kw(o, :foo, 1, a: 1))
- assert_equal([[1], {a: 1}], Relay.with_funcallv_public_kw(o, :foo, 1, 1, a: 1))
- assert_equal([[{}], {}], Relay.with_funcallv_public_kw(o, :foo, 2, {}, **{}))
- assert_equal([[], {a: 1}], Relay.with_funcallv_public_kw(o, :foo, 3, a: 1))
- assert_equal([[{a: 1}], {}], Relay.with_funcallv_public_kw(o, :foo, 3, {a: 1}, **{}))
- assert_raise(NoMethodError) { Relay.with_funcallv_public_kw(o, :bar, 3, {a: 1}, **{}) }
- assert_warn(/warning: Passing the keyword argument as the last hash parameter is deprecated.*The called method `baz'/m) do
- assert_equal({}, Relay.with_funcallv_public_kw(o, :baz, 3, **{}))
- end
- end
-
- def test_with_yield_splat_kw
- block = ->(*a, **kw) { [a, kw] }
- assert_equal([[1], {}], Relay.with_yield_splat_kw(0, [1], &block))
- assert_equal([[], {a: 1}], Relay.with_yield_splat_kw(1, [{a: 1}], &block))
- assert_equal([[1], {a: 1}], Relay.with_yield_splat_kw(1, [1, {a: 1}], &block))
- assert_equal([[{}], {}], Relay.with_yield_splat_kw(2, [{}], **{}, &block))
- assert_warn(/warning: Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[], {a: 1}], Relay.with_yield_splat_kw(3, [{a: 1}], &block))
- end
- assert_equal([[{a: 1}], {}], Relay.with_yield_splat_kw(3, [{a: 1}], **{}, &block))
- assert_warn(/warning: Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal({}, Relay.with_yield_splat_kw(3, [], **{}, &->(a){a}))
- end
- end
end
diff --git a/test/-ext-/gvl/test_last_thread.rb b/test/-ext-/gvl/test_last_thread.rb
index 6808e963bf..3b297a5b31 100644
--- a/test/-ext-/gvl/test_last_thread.rb
+++ b/test/-ext-/gvl/test_last_thread.rb
@@ -3,6 +3,7 @@ class TestLastThread < Test::Unit::TestCase
# [Bug #11237]
def test_last_thread
+
assert_separately([], <<-"end;") #do
require '-test-/gvl/call_without_gvl'
diff --git a/test/-ext-/gvl/test_ubf_async_safe.rb b/test/-ext-/gvl/test_ubf_async_safe.rb
deleted file mode 100644
index 85c4a7d38e..0000000000
--- a/test/-ext-/gvl/test_ubf_async_safe.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-class TestUbfAsyncSafe < Test::Unit::TestCase
- def test_ubf_async_safe
- skip 'need fork for single-threaded test' unless Process.respond_to?(:fork)
- IO.pipe do |r, w|
- pid = fork do
- require '-test-/gvl/call_without_gvl'
- r.close
- trap(:INT) { exit!(0) }
- Thread.current.__ubf_async_safe__(w.fileno)
- exit!(1)
- end
- w.close
- assert IO.select([r], nil, nil, 30), 'child did not become ready'
- Process.kill(:INT, pid)
- _, st = Process.waitpid2(pid)
- assert_predicate st, :success?, ':INT signal triggered exit'
- end
- end
-end
diff --git a/test/-ext-/hash/test_delete.rb b/test/-ext-/hash/test_delete.rb
index 91e6ff67cb..e2ad3cbdbc 100644
--- a/test/-ext-/hash/test_delete.rb
+++ b/test/-ext-/hash/test_delete.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require '-test-/hash'
-class Test_Hash < Test::Unit::TestCase
+class TestHash < Test::Unit::TestCase
class TestDelete < Test::Unit::TestCase
def test_delete
hash = Bug::Hash.new
diff --git a/test/-ext-/integer/test_integer.rb b/test/-ext-/integer/test_integer.rb
index 8d7785047b..8ac0583a9f 100644
--- a/test/-ext-/integer/test_integer.rb
+++ b/test/-ext-/integer/test_integer.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require '-test-/integer'
-class Test_Integer < Test::Unit::TestCase
+class TestInteger < Test::Unit::TestCase
FIXNUM_MIN = RbConfig::LIMITS['FIXNUM_MIN']
FIXNUM_MAX = RbConfig::LIMITS['FIXNUM_MAX']
diff --git a/test/-ext-/integer/test_my_integer.rb b/test/-ext-/integer/test_my_integer.rb
index 1b6f8489f8..260986d203 100644
--- a/test/-ext-/integer/test_my_integer.rb
+++ b/test/-ext-/integer/test_my_integer.rb
@@ -2,7 +2,7 @@
require 'test/unit'
require "-test-/integer"
-class Test_MyInteger < Test::Unit::TestCase
+class TestIntegerExt < Test::Unit::TestCase
def test_my_integer_to_f
assert_raise(NotImplementedError) do
Bug::Integer::MyInteger.new.to_f
diff --git a/test/-ext-/iseq_load/test_iseq_load.rb b/test/-ext-/iseq_load/test_iseq_load.rb
index ffa6541c72..87b28fa56a 100644
--- a/test/-ext-/iseq_load/test_iseq_load.rb
+++ b/test/-ext-/iseq_load/test_iseq_load.rb
@@ -6,8 +6,7 @@ class TestIseqLoad < Test::Unit::TestCase
ISeq = RubyVM::InstructionSequence
def test_bug8543
- assert_iseq_roundtrip "#{<<~"begin;"}\n#{<<~'end;'}"
- begin;
+ assert_iseq_roundtrip <<-'end;'
puts "tralivali"
def funct(a, b)
a**b
@@ -16,35 +15,8 @@ class TestIseqLoad < Test::Unit::TestCase
end;
end
- def test_stressful_roundtrip
- assert_separately(%w[-r-test-/iseq_load], "#{<<~"begin;"}\n#{<<~'end;;'}", timeout: 120)
- begin;
- ISeq = RubyVM::InstructionSequence
- def assert_iseq_roundtrip(src, line=caller_locations(1,1)[0].lineno+1)
- a = ISeq.compile(src, __FILE__, __FILE__, line).to_a
- b = ISeq.iseq_load(a).to_a
- assert_equal a, b, proc {diff(a, b)}
- b = ISeq.iseq_load(b).to_a
- assert_equal a, b, proc {diff(a, b)}
- end
- def test_bug8543
- assert_iseq_roundtrip "#{<<~"begin;"}\n#{<<~'end;'}"
- begin;
- puts "tralivali"
- def funct(a, b)
- a**b
- end
- 3.times { |i| puts "Hello, world#{funct(2,i)}!" }
- end;
- end
- GC.stress = true
- test_bug8543
- end;;
- end
-
def test_case_when
- assert_iseq_roundtrip "#{<<~"begin;"}\n#{<<~'end;'}"
- begin;
+ assert_iseq_roundtrip <<-'end;'
def user_mask(target)
target.each_char.inject(0) do |mask, chr|
case chr
@@ -65,36 +37,27 @@ class TestIseqLoad < Test::Unit::TestCase
end
def test_splatsplat
- assert_iseq_roundtrip("#{<<-"begin;"}\n#{<<-'end;'}")
- begin;
- def splatsplat(**); end
- end;
+ assert_iseq_roundtrip('def splatsplat(**); end')
end
def test_hidden
- assert_iseq_roundtrip("#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- def x(a, (b, *c), d: false); end
- end;
+ assert_iseq_roundtrip('def x(a, (b, *c), d: false); end')
end
- def assert_iseq_roundtrip(src, line=caller_locations(1,1)[0].lineno+1)
- a = ISeq.compile(src, __FILE__, __FILE__, line).to_a
+ def assert_iseq_roundtrip(src)
+ a = ISeq.compile(src).to_a
b = ISeq.iseq_load(a).to_a
- assert_equal a, b, proc {diff(a, b)}
- b = ISeq.iseq_load(b).to_a
- assert_equal a, b, proc {diff(a, b)}
+ warn diff(a, b) if a != b
+ assert_equal a, b
+ assert_equal a, ISeq.iseq_load(b).to_a
end
def test_next_in_block_in_block
@next_broke = false
- src, line = "#{<<~"begin;"}#{<<~'end;'}", __LINE__+2
- begin;
+ src = <<-'end;'
3.times { 3.times { next; @next_broke = true } }
end;
- a = EnvUtil.suppress_warning {
- ISeq.compile(src, __FILE__, __FILE__, line)
- }.to_a
+ a = ISeq.compile(src).to_a
iseq = ISeq.iseq_load(a)
iseq.eval
assert_equal false, @next_broke
@@ -103,8 +66,7 @@ class TestIseqLoad < Test::Unit::TestCase
end
def test_break_ensure
- src, line = "#{<<~"begin;"}#{<<~'end;'}", __LINE__+2
- begin;
+ src = <<-'end;'
def test_break_ensure_def_method
bad = true
while true
@@ -117,7 +79,7 @@ class TestIseqLoad < Test::Unit::TestCase
bad
end
end;
- a = ISeq.compile(src, __FILE__, __FILE__, line).to_a
+ a = ISeq.compile(src).to_a
iseq = ISeq.iseq_load(a)
iseq.eval
assert_equal false, test_break_ensure_def_method
@@ -126,8 +88,7 @@ class TestIseqLoad < Test::Unit::TestCase
end
def test_kwarg
- assert_iseq_roundtrip "#{<<~"begin;"}\n#{<<~'end;'}"
- begin;
+ assert_iseq_roundtrip <<-'end;'
def foo(kwarg: :foo)
kwarg
end
diff --git a/test/-ext-/iter/test_yield_block.rb b/test/-ext-/iter/test_yield_block.rb
index c03a8ee370..0036854fd4 100644
--- a/test/-ext-/iter/test_yield_block.rb
+++ b/test/-ext-/iter/test_yield_block.rb
@@ -16,7 +16,7 @@ class TestIter::YieldBlock < Test::Unit::TestCase
block.call {}
end
def call_lambda(&block)
- block.call(&->{})
+ block.call &->{}
end
end
diff --git a/test/-ext-/marshal/test_internal_ivar.rb b/test/-ext-/marshal/test_internal_ivar.rb
index a32138f6e8..51529667b5 100644
--- a/test/-ext-/marshal/test_internal_ivar.rb
+++ b/test/-ext-/marshal/test_internal_ivar.rb
@@ -7,18 +7,14 @@ module Bug end
module Bug::Marshal
class TestInternalIVar < Test::Unit::TestCase
def test_marshal
- v = InternalIVar.new("hello", "world", "bye")
+ v = InternalIVar.new("hello", "world")
assert_equal("hello", v.normal)
assert_equal("world", v.internal)
- assert_equal("bye", v.encoding_short)
- dump = assert_warn(/instance variable `E' on class \S+ is not dumped/) {
- ::Marshal.dump(v)
- }
+ dump = ::Marshal.dump(v)
v = assert_nothing_raised {break ::Marshal.load(dump)}
assert_instance_of(InternalIVar, v)
assert_equal("hello", v.normal)
assert_nil(v.internal)
- assert_nil(v.encoding_short)
end
end
end
diff --git a/test/-ext-/method/test_arity.rb b/test/-ext-/method/test_arity.rb
index cb8549e7c9..2ba73c8d4c 100644
--- a/test/-ext-/method/test_arity.rb
+++ b/test/-ext-/method/test_arity.rb
@@ -2,7 +2,7 @@
require '-test-/method'
require 'test/unit'
-class Test_Method < Test::Unit::TestCase
+class TestMethod < Test::Unit::TestCase
class TestArity < Test::Unit::TestCase
class A
def foo0()
diff --git a/test/-ext-/popen_deadlock/test_popen_deadlock.rb b/test/-ext-/popen_deadlock/test_popen_deadlock.rb
index e6ba5e7c1a..97892e5008 100644
--- a/test/-ext-/popen_deadlock/test_popen_deadlock.rb
+++ b/test/-ext-/popen_deadlock/test_popen_deadlock.rb
@@ -26,7 +26,7 @@ class TestPopenDeadlock < Test::Unit::TestCase
end
private :assert_popen_without_deadlock
- # 10 test methods are defined for showing progress reports
+ # 10 test methods are defined for showing progess reports
10.times do |i|
define_method("test_popen_without_deadlock_#{i}") {
assert_popen_without_deadlock
diff --git a/test/-ext-/postponed_job/test_postponed_job.rb b/test/-ext-/postponed_job/test_postponed_job.rb
index 7dc28776d0..978b728ef7 100644
--- a/test/-ext-/postponed_job/test_postponed_job.rb
+++ b/test/-ext-/postponed_job/test_postponed_job.rb
@@ -19,8 +19,8 @@ class TestPostponed_job < Test::Unit::TestCase
Bug.postponed_job_call_direct_wrapper(direct)
Bug.postponed_job_register_wrapper(registered)
- assert_equal([0], direct)
- assert_equal([3], registered)
+ assert_match( /postponed_job_call_direct_wrapper/, direct.join)
+ assert_not_match( /postponed_job_register_wrapper/, registered.join)
Bug.postponed_job_register_one(ary = [])
assert_equal [1], ary
diff --git a/test/-ext-/proc/test_bmethod.rb b/test/-ext-/proc/test_bmethod.rb
index 403d99bfd1..344f975755 100644
--- a/test/-ext-/proc/test_bmethod.rb
+++ b/test/-ext-/proc/test_bmethod.rb
@@ -2,12 +2,12 @@
require 'test/unit'
require '-test-/proc'
-class Test_Proc < Test::Unit::TestCase
+class TestProc < Test::Unit::TestCase
class TestBMethod < Test::Unit::TestCase
end
end
-class Test_Proc::TestBMethod
+class TestProc::TestBMethod
class Base
def foo(*a)
a
diff --git a/test/-ext-/string/test_capacity.rb b/test/-ext-/string/test_capacity.rb
index df59e76778..65444123a7 100644
--- a/test/-ext-/string/test_capacity.rb
+++ b/test/-ext-/string/test_capacity.rb
@@ -37,23 +37,4 @@ class Test_StringCapacity < Test::Unit::TestCase
open(__FILE__) {|f|s = f.read(1024*1024)}
assert_operator(capa(s), :<=, s.bytesize+4096)
end
-
- def test_literal_capacity
- s = "I am testing string literal capacity"
- assert_equal(s.length, capa(s))
- end
-
- def test_capacity_frozen
- s = String.new("I am testing", capacity: 1000)
- s << "fstring capacity"
- s.freeze
- assert_equal(s.length, capa(s))
- end
-
- def test_capacity_fstring
- s = String.new("I am testing", capacity: 1000)
- s << "fstring capacity"
- s = -s
- assert_equal(s.length, capa(s))
- end
end
diff --git a/test/-ext-/string/test_fstring.rb b/test/-ext-/string/test_fstring.rb
index 76afa30e14..1b3b15c922 100644
--- a/test/-ext-/string/test_fstring.rb
+++ b/test/-ext-/string/test_fstring.rb
@@ -12,6 +12,36 @@ class Test_String_Fstring < Test::Unit::TestCase
yield fstr
end
+ def test_taint_shared_string
+ str = __method__.to_s.dup
+ str.taint
+ assert_fstring(str) {|s| assert_predicate(s, :tainted?)}
+ end
+
+ def test_taint_normal_string
+ str = __method__.to_s * 3
+ str.taint
+ assert_fstring(str) {|s| assert_predicate(s, :tainted?)}
+ end
+
+ def test_taint_registered_tainted
+ str = __method__.to_s * 3
+ str.taint
+ assert_fstring(str) {|s| assert_predicate(s, :tainted?)}
+
+ str = __method__.to_s * 3
+ assert_fstring(str) {|s| assert_not_predicate(s, :tainted?)}
+ end
+
+ def test_taint_registered_untainted
+ str = __method__.to_s * 3
+ assert_fstring(str) {|s| assert_not_predicate(s, :tainted?)}
+
+ str = __method__.to_s * 3
+ str.taint
+ assert_fstring(str) {|s| assert_predicate(s, :tainted?)}
+ end
+
def test_instance_variable
str = __method__.to_s * 3
str.instance_variable_set(:@test, 42)
@@ -28,7 +58,7 @@ class Test_String_Fstring < Test::Unit::TestCase
end
def test_singleton_class
- str = noninterned_name
+ str = noninterned_name.force_encoding("us-ascii")
fstr = Bug::String.fstring(str)
assert_raise(TypeError) {fstr.singleton_class}
end
@@ -41,18 +71,4 @@ class Test_String_Fstring < Test::Unit::TestCase
str.freeze
assert_fstring(str) {|s| assert_instance_of(S, s)}
end
-
- def test_shared_string_safety
- _unused = -('a' * 30).force_encoding(Encoding::ASCII)
- begin
- verbose_back, $VERBOSE = $VERBOSE, nil
- str = ('a' * 30).force_encoding(Encoding::ASCII).taint
- ensure
- $VERBOSE = verbose_back
- end
- frozen_str = Bug::String.rb_str_new_frozen(str)
- assert_fstring(frozen_str) {|s| assert_equal(str, s)}
- GC.start
- assert_equal('a' * 30, str, "[Bug #16151]")
- end
end
diff --git a/test/-ext-/string/test_modify_expand.rb b/test/-ext-/string/test_modify_expand.rb
index 9aa3b9a6ca..b7f96426fc 100644
--- a/test/-ext-/string/test_modify_expand.rb
+++ b/test/-ext-/string/test_modify_expand.rb
@@ -19,8 +19,9 @@ class Test_StringModifyExpand < Test::Unit::TestCase
return if RbConfig::SIZEOF['size_t'] > RbConfig::SIZEOF['long']
bug12390 = '[ruby-core:75592] [Bug #12390]'
s = Bug::String.new
+ long_max = (1 << (8 * RbConfig::SIZEOF['long'] - 1)) - 1
assert_raise(ArgumentError, bug12390) {
- s.modify_expand!(RbConfig::LIMITS["LONG_MAX"])
+ s.modify_expand!(long_max)
}
end
end
diff --git a/test/-ext-/struct/test_duplicate.rb b/test/-ext-/struct/test_duplicate.rb
index 265102d4fc..77d61988b6 100644
--- a/test/-ext-/struct/test_duplicate.rb
+++ b/test/-ext-/struct/test_duplicate.rb
@@ -3,7 +3,7 @@ require 'test/unit'
require "-test-/struct"
class Bug::Struct::Test_Duplicate < Test::Unit::TestCase
- def test_new_duplicate
+ def test_new_dupilicate
bug12291 = '[ruby-core:74971] [Bug #12291]'
assert_raise_with_message(ArgumentError, /duplicate member/, bug12291) {
Bug::Struct.new_duplicate(nil, "a")
@@ -13,7 +13,7 @@ class Bug::Struct::Test_Duplicate < Test::Unit::TestCase
}
end
- def test_new_duplicate_under
+ def test_new_dupilicate_under
bug12291 = '[ruby-core:74971] [Bug #12291]'
assert_raise_with_message(ArgumentError, /duplicate member/, bug12291) {
Bug::Struct.new_duplicate_under("x", "a")
diff --git a/test/-ext-/symbol/noninterned_name.rb b/test/-ext-/symbol/noninterned_name.rb
index d8b8fb0c06..7c9097ae25 100644
--- a/test/-ext-/symbol/noninterned_name.rb
+++ b/test/-ext-/symbol/noninterned_name.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
require "-test-/symbol"
module Test_Symbol
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb
index 40b3f59f7f..a923340828 100644
--- a/test/-ext-/symbol/test_inadvertent_creation.rb
+++ b/test/-ext-/symbol/test_inadvertent_creation.rb
@@ -20,13 +20,21 @@ module Test_Symbol
def assert_not_interned_error(obj, meth, name, msg = nil, &block)
e = assert_raise(NameError, msg) {obj.__send__(meth, name, &block)}
- assert_not_pinneddown(name, msg)
+ if Symbol === name
+ assert_not_pinneddown(name, msg)
+ else
+ assert_not_interned(name, msg)
+ end
e
end
def assert_not_interned_false(obj, meth, name, msg = nil)
assert_not_send([obj, meth, name], msg)
- assert_not_pinneddown(name, msg)
+ if Symbol === name
+ assert_not_pinneddown(name, msg)
+ else
+ assert_not_interned(name, msg)
+ end
end
Feature5072 = '[ruby-core:38367]'
@@ -482,14 +490,5 @@ module Test_Symbol
foo.call(name.to_sym => 42)
end
end
-
- def test_iv_get
- obj = Object.new
- assert_warning(/not initialized/) do
- assert_no_immortal_symbol_created("rb_iv_get") do |name|
- Bug::Symbol.iv_get(obj, name)
- end
- end
- end
end
end
diff --git a/test/-ext-/test_bug-14834.rb b/test/-ext-/test_bug-14834.rb
deleted file mode 100644
index a3623b8adc..0000000000
--- a/test/-ext-/test_bug-14834.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-class Test_BUG_14834 < Test::Unit::TestCase
- def test
- assert_ruby_status [], <<~'end;', '[ruby-core:87449] [Bug #14834]'
- require '-test-/bug_14834'
- Bug.bug_14834 do
- [123].group_by {}
- end
- end;
- end
-end
diff --git a/test/-ext-/test_enumerator_kw.rb b/test/-ext-/test_enumerator_kw.rb
deleted file mode 100644
index fb47c2bcf8..0000000000
--- a/test/-ext-/test_enumerator_kw.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'test/unit'
-require '-test-/enumerator_kw'
-
-class TestEnumeratorKw < Test::Unit::TestCase
- def test_enumerator_kw
- o = Object.new
- o.extend Bug::EnumeratorKw
- assert_equal([nil, [], {:a=>1}, o], o.m(a: 1) { |*a| a })
- assert_equal([nil, [[], {:a=>1}, o], nil, o], o.m(a: 1).each { |*a| a })
- end
-end
diff --git a/test/-ext-/test_notimplement.rb b/test/-ext-/test_notimplement.rb
index 038b507b73..0eba7bdaf8 100644
--- a/test/-ext-/test_notimplement.rb
+++ b/test/-ext-/test_notimplement.rb
@@ -1,44 +1,15 @@
# frozen_string_literal: false
require '-test-/notimplement'
-class Test_NotImplement < Test::Unit::TestCase
+class TestNotImplement < Test::Unit::TestCase
def test_funcall_notimplement
bug3662 = '[ruby-dev:41953]'
assert_raise(NotImplementedError, bug3662) {
Bug.funcall(:notimplement)
}
- assert_raise(NotImplementedError) {
- Bug::NotImplement.new.notimplement
- }
end
def test_respond_to
- assert_include(Bug.methods(false), :notimplement)
- assert_include(Bug::NotImplement.instance_methods(false), :notimplement)
assert_not_respond_to(Bug, :notimplement)
- assert_not_respond_to(Bug::NotImplement.new, :notimplement)
- end
-
- def test_method_inspect_notimplement
- assert_match(/not-implemented/, Bug.method(:notimplement).inspect)
- assert_match(/not-implemented/, Bug::NotImplement.instance_method(:notimplement).inspect)
- end
-
- def test_not_method_defined
- assert !Bug::NotImplement.method_defined?(:notimplement)
- assert !Bug::NotImplement.method_defined?(:notimplement, true)
- assert !Bug::NotImplement.method_defined?(:notimplement, false)
- end
-
- def test_not_private_method_defined
- assert !Bug::NotImplement.private_method_defined?(:notimplement)
- assert !Bug::NotImplement.private_method_defined?(:notimplement, true)
- assert !Bug::NotImplement.private_method_defined?(:notimplement, false)
- end
-
- def test_not_protected_method_defined
- assert !Bug::NotImplement.protected_method_defined?(:notimplement)
- assert !Bug::NotImplement.protected_method_defined?(:notimplement, true)
- assert !Bug::NotImplement.protected_method_defined?(:notimplement, false)
end
end
diff --git a/test/-ext-/test_printf.rb b/test/-ext-/test_printf.rb
index cfec388e8c..cd3ba76364 100644
--- a/test/-ext-/test_printf.rb
+++ b/test/-ext-/test_printf.rb
@@ -24,8 +24,6 @@ class Test_SPrintf < Test::Unit::TestCase
assert_equal('["\n"]', Bug::Printf.q("\n"))
assert_equal('[aaa]', Bug::Printf.q('aaa'))
assert_equal('[a a]', Bug::Printf.q('a a'))
- assert_equal('[]', Bug::Printf.q(''))
- assert_equal('[""]', Bug::Printf.q(:''))
end
def test_encoding
@@ -35,6 +33,15 @@ class Test_SPrintf < Test::Unit::TestCase
assert_equal("<\u{3042 3044 3046 3048 304a}>", Bug::Printf.s(self))
end
+ def test_taint
+ obj = Object.new.taint
+ assert_equal({to_s: true, inspect: true},
+ {
+ to_s: Bug::Printf.s(obj).tainted?,
+ inspect: Bug::Printf.v(obj).tainted?,
+ })
+ end
+
VS = [
#-0x1000000000000000000000000000000000000000000000002,
#-0x1000000000000000000000000000000000000000000000001,
diff --git a/test/-ext-/test_scan_args.rb b/test/-ext-/test_scan_args.rb
index dda016d6af..cb2dab5760 100644
--- a/test/-ext-/test_scan_args.rb
+++ b/test/-ext-/test_scan_args.rb
@@ -93,14 +93,7 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([1, "a", nil], Bug::ScanArgs.lead_hash("a"))
assert_raise(ArgumentError) {Bug::ScanArgs.lead_hash("a", "b")}
assert_equal([1, "a", {b: 1}], Bug::ScanArgs.lead_hash("a", b: 1))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, {b: 1}, nil], Bug::ScanArgs.lead_hash(b: 1))
- end
- assert_equal([1, {"a"=>0, b: 1}, nil], Bug::ScanArgs.lead_hash({"a"=>0, b: 1}, **{}))
- assert_raise(ArgumentError) {Bug::ScanArgs.lead_hash(1, {"a"=>0, b: 1}, **{})}
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, {}, nil], Bug::ScanArgs.lead_hash(**{}))
- end
+ assert_equal([1, {b: 1}, nil], Bug::ScanArgs.lead_hash(b: 1))
end
def test_opt_hash
@@ -109,10 +102,7 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([0, nil, {b: 1}], Bug::ScanArgs.opt_hash(b: 1))
assert_equal([1, "a", {b: 1}], Bug::ScanArgs.opt_hash("a", b: 1))
assert_raise(ArgumentError) {Bug::ScanArgs.opt_hash("a", "b")}
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([1, {"a"=>0}, {b: 1}], Bug::ScanArgs.opt_hash("a"=>0, b: 1))
- end
- assert_equal([1, {"a"=>0, b: 1}, nil], Bug::ScanArgs.opt_hash({"a"=>0, b: 1}, **{}))
+ assert_equal([1, {"a"=>0}, {b: 1}], Bug::ScanArgs.opt_hash("a"=>0, b: 1))
end
def test_lead_opt_hash
@@ -120,13 +110,9 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([2, "a", "b", nil], Bug::ScanArgs.lead_opt_hash("a", "b"))
assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.lead_opt_hash("a", c: 1))
assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.lead_opt_hash("a", "b", c: 1))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.lead_opt_hash(c: 1))
- end
+ assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.lead_opt_hash(c: 1))
assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_hash("a", "b", "c")}
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_hash("a", "b"=>0, c: 1))
- end
+ assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_hash("a", "b"=>0, c: 1))
end
def test_var_hash
@@ -134,9 +120,7 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([1, ["a"], nil], Bug::ScanArgs.var_hash("a"))
assert_equal([1, ["a"], {b: 1}], Bug::ScanArgs.var_hash("a", b: 1))
assert_equal([0, [], {b: 1}], Bug::ScanArgs.var_hash(b: 1))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([1, [{"a"=>0}], {b: 1}], Bug::ScanArgs.var_hash("a"=>0, b: 1))
- end
+ assert_equal([1, [{"a"=>0}], {b: 1}], Bug::ScanArgs.var_hash("a"=>0, b: 1))
end
def test_lead_var_hash
@@ -145,13 +129,9 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([2, "a", ["b"], nil], Bug::ScanArgs.lead_var_hash("a", "b"))
assert_equal([2, "a", ["b"], {c: 1}], Bug::ScanArgs.lead_var_hash("a", "b", c: 1))
assert_equal([1, "a", [], {c: 1}], Bug::ScanArgs.lead_var_hash("a", c: 1))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, {c: 1}, [], nil], Bug::ScanArgs.lead_var_hash(c: 1))
- end
+ assert_equal([1, {c: 1}, [], nil], Bug::ScanArgs.lead_var_hash(c: 1))
assert_equal([3, "a", ["b", "c"], nil], Bug::ScanArgs.lead_var_hash("a", "b", "c"))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([2, "a", [{"b"=>0}], {c: 1}], Bug::ScanArgs.lead_var_hash("a", "b"=>0, c: 1))
- end
+ assert_equal([2, "a", [{"b"=>0}], {c: 1}], Bug::ScanArgs.lead_var_hash("a", "b"=>0, c: 1))
end
def test_opt_var_hash
@@ -162,9 +142,7 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([1, "a", [], {c: 1}], Bug::ScanArgs.opt_var_hash("a", c: 1))
assert_equal([0, nil, [], {c: 1}], Bug::ScanArgs.opt_var_hash(c: 1))
assert_equal([3, "a", ["b", "c"], nil], Bug::ScanArgs.opt_var_hash("a", "b", "c"))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([2, "a", [{"b"=>0}], {c: 1}], Bug::ScanArgs.opt_var_hash("a", "b"=>0, c: 1))
- end
+ assert_equal([2, "a", [{"b"=>0}], {c: 1}], Bug::ScanArgs.opt_var_hash("a", "b"=>0, c: 1))
end
def test_lead_opt_var_hash
@@ -173,14 +151,10 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([2, "a", "b", [], nil], Bug::ScanArgs.lead_opt_var_hash("a", "b"))
assert_equal([2, "a", "b", [], {c: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", c: 1))
assert_equal([1, "a", nil, [], {c: 1}], Bug::ScanArgs.lead_opt_var_hash("a", c: 1))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, {c: 1}, nil, [], nil], Bug::ScanArgs.lead_opt_var_hash(c: 1))
- end
+ assert_equal([1, {c: 1}, nil, [], nil], Bug::ScanArgs.lead_opt_var_hash(c: 1))
assert_equal([3, "a", "b", ["c"], nil], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c"))
assert_equal([3, "a", "b", ["c"], {d: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c", d: 1))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([3, "a", "b", [{"c"=>0}], {d: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c"=>0, d: 1))
- end
+ assert_equal([3, "a", "b", [{"c"=>0}], {d: 1}], Bug::ScanArgs.lead_opt_var_hash("a", "b", "c"=>0, d: 1))
end
def test_opt_trail_hash
@@ -189,13 +163,9 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([2, "a", "b", nil], Bug::ScanArgs.opt_trail_hash("a", "b"))
assert_equal([1, nil, "a", {c: 1}], Bug::ScanArgs.opt_trail_hash("a", c: 1))
assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.opt_trail_hash("a", "b", c: 1))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, nil, {c: 1}, nil], Bug::ScanArgs.opt_trail_hash(c: 1))
- end
+ assert_equal([1, nil, {c: 1}, nil], Bug::ScanArgs.opt_trail_hash(c: 1))
assert_raise(ArgumentError) {Bug::ScanArgs.opt_trail_hash("a", "b", "c")}
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.opt_trail_hash("a", "b"=>0, c: 1))
- end
+ assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.opt_trail_hash("a", "b"=>0, c: 1))
end
def test_lead_opt_trail_hash
@@ -203,16 +173,12 @@ class TestScanArgs < Test::Unit::TestCase
assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_trail_hash("a")}
assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_trail_hash(c: 1)}
assert_equal([2, "a", nil, "b", nil], Bug::ScanArgs.lead_opt_trail_hash("a", "b"))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([2, "a", nil, {c: 1}, nil], Bug::ScanArgs.lead_opt_trail_hash("a", c: 1))
- end
+ assert_equal([2, "a", nil, {c: 1}, nil], Bug::ScanArgs.lead_opt_trail_hash("a", c: 1))
assert_equal([2, "a", nil, "b", {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", c: 1))
assert_equal([3, "a", "b", "c", nil], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c"))
assert_equal([3, "a", "b", "c", {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c", c: 1))
assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c", "d")}
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([3, "a", "b", {"c"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c"=>0, c: 1))
- end
+ assert_equal([3, "a", "b", {"c"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_trail_hash("a", "b", "c"=>0, c: 1))
end
def test_var_trail_hash
@@ -221,104 +187,45 @@ class TestScanArgs < Test::Unit::TestCase
assert_equal([2, ["a"], "b", nil], Bug::ScanArgs.var_trail_hash("a", "b"))
assert_equal([1, [], "a", {c: 1}], Bug::ScanArgs.var_trail_hash("a", c: 1))
assert_equal([2, ["a"], "b", {c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", c: 1))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, [], {c: 1}, nil], Bug::ScanArgs.var_trail_hash(c: 1))
- end
+ assert_equal([1, [], {c: 1}, nil], Bug::ScanArgs.var_trail_hash(c: 1))
assert_equal([3, ["a", "b"], "c", nil], Bug::ScanArgs.var_trail_hash("a", "b", "c"))
assert_equal([3, ["a", "b"], "c", {c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", "c", c: 1))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([3, ["a", "b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", "c"=>0, c: 1))
- end
+ assert_equal([3, ["a", "b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.var_trail_hash("a", "b", "c"=>0, c: 1))
end
def test_lead_var_trail_hash
assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_trail_hash()}
assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_trail_hash("a")}
assert_raise(ArgumentError) {Bug::ScanArgs.lead_var_trail_hash(c: 1)}
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([2, "a", [], {c: 1}, nil], Bug::ScanArgs.lead_var_trail_hash("a", c: 1))
- end
+ assert_equal([2, "a", [], {c: 1}, nil], Bug::ScanArgs.lead_var_trail_hash("a", c: 1))
assert_equal([2, "a", [], "b", nil], Bug::ScanArgs.lead_var_trail_hash("a", "b"))
assert_equal([2, "a", [], "b", {c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", c: 1))
assert_equal([3, "a", ["b"], "c", nil], Bug::ScanArgs.lead_var_trail_hash("a", "b", "c"))
assert_equal([3, "a", ["b"], "c", {c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", "c", c: 1))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([3, "a", ["b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", c: 1, "c"=>0))
- end
+ assert_equal([3, "a", ["b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.lead_var_trail_hash("a", "b", c: 1, "c"=>0))
end
def test_opt_var_trail_hash
assert_raise(ArgumentError) {Bug::ScanArgs.opt_var_trail_hash()}
assert_equal([1, nil, [], "a", nil], Bug::ScanArgs.opt_var_trail_hash("a"))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, nil, [], {c: 1}, nil], Bug::ScanArgs.opt_var_trail_hash(c: 1))
- end
+ assert_equal([1, nil, [], {c: 1}, nil], Bug::ScanArgs.opt_var_trail_hash(c: 1))
assert_equal([1, nil, [], "a", {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", c: 1))
assert_equal([2, "a", [], "b", nil], Bug::ScanArgs.opt_var_trail_hash("a", "b"))
assert_equal([2, "a", [], "b", {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", c: 1))
assert_equal([3, "a", ["b"], "c", nil], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c"))
assert_equal([3, "a", ["b"], "c", {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c", c: 1))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([3, "a", ["b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c"=>0, c: 1))
- end
+ assert_equal([3, "a", ["b"], {"c"=>0}, {c: 1}], Bug::ScanArgs.opt_var_trail_hash("a", "b", "c"=>0, c: 1))
end
def test_lead_opt_var_trail_hash
assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_var_trail_hash()}
assert_raise(ArgumentError) {Bug::ScanArgs.lead_opt_var_trail_hash("a")}
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([2, "a", nil, [], {b: 1}, nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", b: 1))
- end
+ assert_equal([2, "a", nil, [], {b: 1}, nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", b: 1))
assert_equal([2, "a", nil, [], "b", nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b"))
assert_equal([2, "a", nil, [], "b", {c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", c: 1))
assert_equal([3, "a", "b", [], "c", nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c"))
assert_equal([3, "a", "b", [], "c", {c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", c: 1))
assert_equal([4, "a", "b", ["c"], "d", nil], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", "d"))
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([4, "a", "b", ["c"], {"d"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", "d"=>0, c: 1))
- end
- end
-
- def test_k_lead_opt_hash
- assert_raise(ArgumentError) {Bug::ScanArgs.k_lead_opt_hash}
- assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", c: 1))
- assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", {c: 1}))
- assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", "b", c: 1))
- assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", "b", {c: 1}))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.k_lead_opt_hash(c: 1))
- end
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.k_lead_opt_hash("a", "b"=>0, c: 1))
- end
- end
-
- def test_e_lead_opt_hash
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([1, {}, nil, nil], Bug::ScanArgs.e_lead_opt_hash)
- end
- assert_equal([1, "a", nil, nil], Bug::ScanArgs.e_lead_opt_hash("a"))
- assert_equal([2, "a", "b", nil], Bug::ScanArgs.e_lead_opt_hash("a", "b"))
- assert_equal([2, "a", {c: 1}, nil], Bug::ScanArgs.e_lead_opt_hash("a", c: 1))
- assert_raise(ArgumentError) {Bug::ScanArgs.e_lead_opt_hash("a", "b", c: 1)}
- assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.e_lead_opt_hash(c: 1))
- assert_raise(ArgumentError) {Bug::ScanArgs.e_lead_opt_hash("a", "b", "c")}
- assert_equal([2, "a", {"b"=>0, c: 1}, nil], Bug::ScanArgs.e_lead_opt_hash("a", "b"=>0, c: 1))
- end
-
- def test_n_lead_opt_hash
- assert_raise(ArgumentError) {Bug::ScanArgs.n_lead_opt_hash}
- assert_equal([1, "a", nil, nil], Bug::ScanArgs.n_lead_opt_hash("a"))
- assert_equal([2, "a", "b", nil], Bug::ScanArgs.n_lead_opt_hash("a", "b"))
- assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", c: 1))
- assert_equal([1, "a", nil, {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", {c: 1}))
- assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", "b", c: 1))
- assert_equal([2, "a", "b", {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", "b", {c: 1}))
- assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.n_lead_opt_hash(c: 1))
- assert_equal([1, {c: 1}, nil, nil], Bug::ScanArgs.n_lead_opt_hash({c: 1}))
- assert_raise(ArgumentError) {Bug::ScanArgs.n_lead_opt_hash("a", "b", "c")}
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- assert_equal([2, "a", {"b"=>0}, {c: 1}], Bug::ScanArgs.n_lead_opt_hash("a", "b"=>0, c: 1))
- end
+ assert_equal([4, "a", "b", ["c"], {"d"=>0}, {c: 1}], Bug::ScanArgs.lead_opt_var_trail_hash("a", "b", "c", "d"=>0, c: 1))
end
end
diff --git a/test/-ext-/tracepoint/test_tracepoint.rb b/test/-ext-/tracepoint/test_tracepoint.rb
index 60bdefd9e0..33d0c3e8e1 100644
--- a/test/-ext-/tracepoint/test_tracepoint.rb
+++ b/test/-ext-/tracepoint/test_tracepoint.rb
@@ -10,15 +10,13 @@ class TestTracepointObj < Test::Unit::TestCase
end
def test_tracks_objspace_events
- result = EnvUtil.suppress_warning {eval(<<-EOS, nil, __FILE__, __LINE__+1)}
- Bug.tracepoint_track_objspace_events {
+ result = Bug.tracepoint_track_objspace_events{
99
'abc'
_="foobar"
Object.new
nil
}
- EOS
newobj_count, free_count, gc_start_count, gc_end_mark_count, gc_end_sweep_count, *newobjs = *result
assert_equal 2, newobj_count
@@ -43,7 +41,7 @@ class TestTracepointObj < Test::Unit::TestCase
GC.stat(stat2)
GC.enable
- newobj_count, free_count, gc_start_count, gc_end_mark_count, gc_end_sweep_count, = *result
+ newobj_count, free_count, gc_start_count, gc_end_mark_count, gc_end_sweep_count, *newobjs = *result
assert_operator stat2[:total_allocated_objects] - stat1[:total_allocated_objects], :>=, newobj_count
assert_operator 1_000_000, :<=, newobj_count
@@ -79,8 +77,4 @@ class TestTracepointObj < Test::Unit::TestCase
end
end
- def test_teardown_with_active_GC_end_hook
- assert_separately([], 'require("-test-/tracepoint"); Bug.after_gc_exit_hook = proc {}')
- end
-
end
diff --git a/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb b/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb
index 777e9d14dd..1141dd317c 100644
--- a/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb
+++ b/test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb
@@ -4,8 +4,18 @@ require 'test/unit'
class TestWaitForSingleFD < Test::Unit::TestCase
require '-test-/wait_for_single_fd'
+ def with_pipe
+ r, w = IO.pipe
+ begin
+ yield r, w
+ ensure
+ r.close unless r.closed?
+ w.close unless w.closed?
+ end
+ end
+
def test_wait_for_valid_fd
- IO.pipe do |r,w|
+ with_pipe do |r,w|
rc = IO.wait_for_single_fd(w.fileno, RB_WAITFD_OUT, nil)
assert_equal RB_WAITFD_OUT, rc
end
@@ -21,11 +31,8 @@ class TestWaitForSingleFD < Test::Unit::TestCase
# FreeBSD 8.2 or prior sticks this
# http://bugs.ruby-lang.org/issues/5524
- if /freebsd([\d\.]+)/ =~ RUBY_PLATFORM
- ver = $1.to_r
- skip 'FreeBSD <= 8.2' if ver <= 8.2r
- end
- IO.pipe do |r,w|
+ skip if /freebsd[1-8]/ =~ RUBY_PLATFORM
+ with_pipe do |r,w|
wfd = w.fileno
w.close
assert_raise(Errno::EBADF) do
@@ -35,15 +42,12 @@ class TestWaitForSingleFD < Test::Unit::TestCase
end
def test_wait_for_closed_pipe
- IO.pipe do |r,w|
+ with_pipe do |r,w|
w.close
rc = IO.wait_for_single_fd(r.fileno, RB_WAITFD_IN, nil)
assert_equal RB_WAITFD_IN, rc
end
end
- def test_wait_for_kqueue
- skip 'no kqueue' unless IO.respond_to?(:kqueue_test_wait)
- assert_equal RB_WAITFD_IN, IO.kqueue_test_wait
- end
+
end
diff --git a/test/-ext-/win32/test_console_attr.rb b/test/-ext-/win32/test_console_attr.rb
index 35d425ded7..e596e13469 100644
--- a/test/-ext-/win32/test_console_attr.rb
+++ b/test/-ext-/win32/test_console_attr.rb
@@ -5,17 +5,6 @@ if /mswin|mingw/ =~ RUBY_PLATFORM and STDOUT.tty?
require 'test/unit'
class Test_Win32Console < Test::Unit::TestCase
- REVERSE_VIDEO = Bug::Win32::REVERSE_VIDEO
-
- def reverse_video(fore, back = 0x0)
- info = STDOUT.console_info
- if (info.attr & REVERSE_VIDEO) == 0
- (fore << 4) | back
- else
- (back << 4) | fore | REVERSE_VIDEO
- end
- end
-
def reset
STDOUT.console_attribute(7)
end
@@ -31,7 +20,7 @@ if /mswin|mingw/ =~ RUBY_PLATFORM and STDOUT.tty?
def test_reverse
print "\e[7m"
info = STDOUT.console_info
- assert_equal(reverse_video(0x7), info.attr);
+ assert_equal(0x70, info.attr);
end
def test_bold
@@ -43,13 +32,13 @@ if /mswin|mingw/ =~ RUBY_PLATFORM and STDOUT.tty?
def test_bold_reverse
print "\e[1;7m"
info = STDOUT.console_info
- assert_equal(reverse_video(0xf), info.attr);
+ assert_equal(0xf0, info.attr);
end
def test_reverse_bold
print "\e[7;1m"
info = STDOUT.console_info
- assert_equal(reverse_video(0xf), info.attr);
+ assert_equal(0xf0, info.attr);
end
end
end
diff --git a/test/benchmark/test_benchmark.rb b/test/benchmark/test_benchmark.rb
index 0eb331a1cd..655c6946e7 100644
--- a/test/benchmark/test_benchmark.rb
+++ b/test/benchmark/test_benchmark.rb
@@ -34,8 +34,12 @@ class TestBenchmark < Test::Unit::TestCase
end
end
+ def capture_output
+ capture_io { yield }.first.gsub(/[ \-]\d\.\d{6}/, ' --time--')
+ end
+
def capture_bench_output(type, *args, &block)
- capture_output { bench(type, *args, &block) }.first.gsub(/[ \-]\d\.\d{6}/, ' --time--')
+ capture_output { bench(type, *args, &block) }
end
def test_tms_outputs_nicely
@@ -81,7 +85,7 @@ BENCH
def test_bm_returns_an_Array_of_the_times_with_the_labels
[:bm, :bmbm].each do |meth|
- capture_output do
+ capture_io do
results = bench(meth)
assert_instance_of(Array, results)
assert_equal(labels.size, results.size)
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 0e76081431..595783c63d 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -44,84 +44,49 @@ class TestBigDecimal < Test::Unit::TestCase
end
def test_not_equal
- assert_not_equal BigDecimal("1"), BigDecimal("2")
+ assert_not_equal BigDecimal("1"), BigDecimal.allocate
end
- def test_BigDecimal
+ def test_global_new
assert_equal(1, BigDecimal("1"))
assert_equal(1, BigDecimal("1", 1))
- assert_equal(1, BigDecimal(" 1 "))
- assert_equal(111, BigDecimal("1_1_1_"))
- assert_equal(10**(-1), BigDecimal("1E-1"), '#4825')
- assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r"))
- bd = BigDecimal("1.12", 1)
- assert_same(bd, BigDecimal(bd))
- assert_same(bd, BigDecimal(bd, exception: false))
- assert_not_same(bd, BigDecimal(bd, 1))
- assert_not_same(bd, BigDecimal(bd, 1, exception: false))
-
assert_raise(ArgumentError) { BigDecimal("1", -1) }
- assert_raise_with_message(ArgumentError, /"1__1_1"/) { BigDecimal("1__1_1") }
- assert_raise_with_message(ArgumentError, /"_1_1_1"/) { BigDecimal("_1_1_1") }
BigDecimal.save_exception_mode do
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
- assert_positive_infinite(BigDecimal("Infinity"))
- assert_positive_infinite(BigDecimal("1E1111111111111111111"))
+ assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r"))
assert_positive_infinite(BigDecimal(" \t\n\r \rInfinity \t\n\r \r"))
- assert_negative_infinite(BigDecimal("-Infinity"))
assert_negative_infinite(BigDecimal(" \t\n\r \r-Infinity \t\n\r \r"))
- assert_nan(BigDecimal("NaN"))
assert_nan(BigDecimal(" \t\n\r \rNaN \t\n\r \r"))
end
end
- def test_BigDecimal_bug7522
- bd = BigDecimal("1.12", 1)
- assert_same(bd, BigDecimal(bd))
- assert_same(bd, BigDecimal(bd, exception: false))
- assert_not_same(bd, BigDecimal(bd, 1))
- assert_not_same(bd, BigDecimal(bd, 1, exception: false))
- end
-
- def test_BigDecimal_with_invalid_string
+ def test_global_new_with_invalid_string
[
'', '.', 'e1', 'd1', '.e', '.d', '1.e', '1.d', '.1e', '.1d',
- '2,30', '19,000.0', '-2,30', '-19,000.0', '+2,30', '+19,000.0',
- '2.3,0', '19.000,0', '-2.3,0', '-19.000,0', '+2.3,0', '+19.000,0',
- '2.3.0', '19.000.0', '-2.3.0', '-19.000.0', '+2.3.0', '+19.000.0',
- 'invlaid value', '123 xyz'
+ 'invlaid value'
].each do |invalid_string|
assert_raise_with_message(ArgumentError, %Q[invalid value for BigDecimal(): "#{invalid_string}"]) do
BigDecimal(invalid_string)
end
end
-
- BigDecimal.save_exception_mode do
- BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
- BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
- assert_raise_with_message(ArgumentError, /"Infinity_"/) { BigDecimal("Infinity_") }
- assert_raise_with_message(ArgumentError, /"\+Infinity_"/) { BigDecimal("+Infinity_") }
- assert_raise_with_message(ArgumentError, /"-Infinity_"/) { BigDecimal("-Infinity_") }
- assert_raise_with_message(ArgumentError, /"NaN_"/) { BigDecimal("NaN_") }
- end
end
- def test_BigDecimal_with_integer
+ def test_global_new_with_integer
assert_equal(BigDecimal("1"), BigDecimal(1))
assert_equal(BigDecimal("-1"), BigDecimal(-1))
assert_equal(BigDecimal((2**100).to_s), BigDecimal(2**100))
assert_equal(BigDecimal((-2**100).to_s), BigDecimal(-2**100))
end
- def test_BigDecimal_with_rational
+ def test_global_new_with_rational
assert_equal(BigDecimal("0.333333333333333333333"), BigDecimal(1.quo(3), 21))
assert_equal(BigDecimal("-0.333333333333333333333"), BigDecimal(-1.quo(3), 21))
assert_raise_with_message(ArgumentError, "can't omit precision for a Rational.") { BigDecimal(42.quo(7)) }
end
- def test_BigDecimal_with_float
+ def test_global_new_with_float
assert_equal(BigDecimal("0.1235"), BigDecimal(0.1234567, 4))
assert_equal(BigDecimal("-0.1235"), BigDecimal(-0.1234567, 4))
assert_raise_with_message(ArgumentError, "can't omit precision for a Float.") { BigDecimal(4.2) }
@@ -142,7 +107,7 @@ class TestBigDecimal < Test::Unit::TestCase
end
end
- def test_BigDecimal_with_big_decimal
+ def test_global_new_with_big_decimal
assert_equal(BigDecimal(1), BigDecimal(BigDecimal(1)))
assert_equal(BigDecimal('+0'), BigDecimal(BigDecimal('+0')))
assert_equal(BigDecimal('-0'), BigDecimal(BigDecimal('-0')))
@@ -155,107 +120,81 @@ class TestBigDecimal < Test::Unit::TestCase
end
end
- if RUBY_VERSION < '2.7'
- def test_BigDecimal_with_tainted_string
- Thread.new {
- $SAFE = 1
- BigDecimal('1'.taint)
- }.join
- ensure
- $SAFE = 0
+ def test_global_new_with_tainted_string
+ Thread.new {
+ $SAFE = 1
+ BigDecimal('1'.taint)
+ }.join
+ end
+
+ def test_s_ver
+ assert_warning(/BigDecimal\.ver is deprecated; use BigDecimal::VERSION instead/) do
+ BigDecimal.ver
end
end
- def test_BigDecimal_with_exception_keyword
- assert_raise(ArgumentError) {
- BigDecimal('.', exception: true)
- }
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, BigDecimal(".", exception: false))
- }
- assert_raise(ArgumentError) {
- BigDecimal("1", -1, exception: true)
- }
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, BigDecimal("1", -1, exception: false))
- }
- assert_raise(ArgumentError) {
- BigDecimal(42.quo(7), exception: true)
- }
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, BigDecimal(42.quo(7), exception: false))
- }
- assert_raise(ArgumentError) {
- BigDecimal(4.2, exception: true)
- }
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, BigDecimal(4.2, exception: false))
- }
- # TODO: support conversion from complex
- # assert_raise(RangeError) {
- # BigDecimal(1i, exception: true)
- # }
- # assert_nothing_raised(RangeError) {
- # assert_equal(nil, BigDecimal(1i, exception: false))
- # }
- assert_raise(TypeError) {
- BigDecimal(nil, exception: true)
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, BigDecimal(nil, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, BigDecimal(:test, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, BigDecimal(Object.new, exception: false))
- }
- # TODO: support to_d
- # assert_nothing_raised(TypeError) {
- # o = Object.new
- # def o.to_d; 3.14; end
- # assert_equal(3.14, BigDecimal(o, exception: false))
- # }
- # assert_nothing_raised(RuntimeError) {
- # o = Object.new
- # def o.to_d; raise; end
- # assert_equal(nil, BigDecimal(o, exception: false))
- # }
+ def test_s_new
+ assert_warning(/BigDecimal.new is deprecated/) do
+ BigDecimal.new("1")
+ end
end
- def test_s_ver
- assert_raise_with_message(NoMethodError, /undefined method `ver'/) { BigDecimal.ver }
+ def test_new
+ assert_equal(1, BigDecimal("1"))
+ assert_equal(1, BigDecimal("1", 1))
+ assert_equal(1, BigDecimal(" 1 "))
+ assert_equal(111, BigDecimal("1_1_1_"))
+ assert_equal(10**(-1), BigDecimal("1E-1"), '#4825')
+
+ assert_raise(ArgumentError, /"_1_1_1"/) { BigDecimal("_1_1_1") }
+
+ BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
+ BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
+ assert_positive_infinite(BigDecimal("Infinity"))
+ assert_negative_infinite(BigDecimal("-Infinity"))
+ assert_nan(BigDecimal("NaN"))
+ assert_positive_infinite(BigDecimal("1E1111111111111111111"))
end
- def test_s_allocate
- assert_raise_with_message(NoMethodError, /undefined method `allocate'/) { BigDecimal.allocate }
+ def test_new_with_integer
+ assert_equal(BigDecimal("1"), BigDecimal(1))
+ assert_equal(BigDecimal("-1"), BigDecimal(-1))
+ assert_equal(BigDecimal((2**100).to_s), BigDecimal(2**100))
+ assert_equal(BigDecimal((-2**100).to_s), BigDecimal(-2**100))
end
- def test_s_new
- assert_raise_with_message(NoMethodError, /undefined method `new'/) { BigDecimal.new("1") }
+ def test_new_with_rational
+ assert_equal(BigDecimal("0.333333333333333333333"), BigDecimal(1.quo(3), 21))
+ assert_equal(BigDecimal("-0.333333333333333333333"), BigDecimal(-1.quo(3), 21))
+ assert_raise(ArgumentError) { BigDecimal(1.quo(3)) }
end
- def test_s_interpret_loosely
- assert_equal(BigDecimal('1'), BigDecimal.interpret_loosely("1__1_1"))
- assert_equal(BigDecimal('2.5'), BigDecimal.interpret_loosely("2.5"))
- assert_equal(BigDecimal('2.5'), BigDecimal.interpret_loosely("2.5 degrees"))
- assert_equal(BigDecimal('2.5e1'), BigDecimal.interpret_loosely("2.5e1 degrees"))
- assert_equal(BigDecimal('0'), BigDecimal.interpret_loosely("degrees 100.0"))
- assert_equal(BigDecimal('0.125'), BigDecimal.interpret_loosely("0.1_2_5"))
- assert_equal(BigDecimal('0.125'), BigDecimal.interpret_loosely("0.1_2_5__"))
- assert_equal(BigDecimal('1'), BigDecimal.interpret_loosely("1_.125"))
- assert_equal(BigDecimal('1'), BigDecimal.interpret_loosely("1._125"))
- assert_equal(BigDecimal('0.1'), BigDecimal.interpret_loosely("0.1__2_5"))
- assert_equal(BigDecimal('0.1'), BigDecimal.interpret_loosely("0.1_e10"))
- assert_equal(BigDecimal('0.1'), BigDecimal.interpret_loosely("0.1e_10"))
- assert_equal(BigDecimal('1'), BigDecimal.interpret_loosely("0.1e1__0"))
- assert_equal(BigDecimal('1.2'), BigDecimal.interpret_loosely("1.2.3"))
- assert_equal(BigDecimal('1'), BigDecimal.interpret_loosely("1."))
- assert_equal(BigDecimal('1'), BigDecimal.interpret_loosely("1e"))
+ def test_new_with_float
+ assert_equal(BigDecimal("0.1235"), BigDecimal(0.1234567, 4))
+ assert_equal(BigDecimal("-0.1235"), BigDecimal(-0.1234567, 4))
+ assert_raise(ArgumentError) { BigDecimal(0.1) }
+ assert_raise(ArgumentError) { BigDecimal(0.1, Float::DIG + 2) }
+ assert_nothing_raised { BigDecimal(0.1, Float::DIG + 1) }
+ end
- assert_equal(BigDecimal('0.0'), BigDecimal.interpret_loosely("invalid"))
+ def test_new_with_big_decimal
+ assert_equal(BigDecimal(1), BigDecimal(BigDecimal(1)))
+ assert_equal(BigDecimal('+0'), BigDecimal(BigDecimal('+0')))
+ assert_equal(BigDecimal('-0'), BigDecimal(BigDecimal('-0')))
+ BigDecimal.save_exception_mode do
+ BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
+ BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
+ assert_positive_infinite(BigDecimal(BigDecimal('Infinity')))
+ assert_negative_infinite(BigDecimal(BigDecimal('-Infinity')))
+ assert_nan(BigDecimal(BigDecimal('NaN')))
+ end
+ end
- assert(BigDecimal.interpret_loosely("2.5").frozen?)
+ def test_new_with_tainted_string
+ Thread.new {
+ $SAFE = 1
+ BigDecimal('1'.taint)
+ }.join
end
def _test_mode(type)
@@ -1621,13 +1560,6 @@ class TestBigDecimal < Test::Unit::TestCase
end
end
- def test_exp_with_negative
- x = BigDecimal(-1)
- y = BigMath.exp(x, 20)
- assert_equal(y, BigMath.exp(-1, 20))
- assert_equal(BigDecimal(-1), x)
- end
-
def test_exp_with_negative_infinite
BigDecimal.save_exception_mode do
BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, false)
@@ -1842,12 +1774,6 @@ class TestBigDecimal < Test::Unit::TestCase
EOS
end
- def test_frozen_p
- x = BigDecimal(1)
- assert(x.frozen?)
- assert((x + x).frozen?)
- end
-
def test_clone
assert_warning(/^$/) do
x = BigDecimal(0)
@@ -1864,9 +1790,15 @@ class TestBigDecimal < Test::Unit::TestCase
end
end
- def test_new_subclass
- c = Class.new(BigDecimal)
- assert_raise_with_message(NoMethodError, /undefined method `new'/) { c.new(1) }
+ def test_dup_subclass
+ assert_warning(/BigDecimal\.new is deprecated/) do
+ c = Class.new(BigDecimal)
+ x = c.new(1)
+ y = x.dup
+ assert_same(x, y)
+ assert_equal(1, y)
+ assert_kind_of(c, y)
+ end
end
def test_to_d
@@ -1898,7 +1830,7 @@ class TestBigDecimal < Test::Unit::TestCase
assert_no_memory_leak("BigDecimal()")
end
- def test_no_memory_leak_BigDecimal
+ def test_no_memory_leak_global_new
assert_no_memory_leak("BigDecimal('10')")
assert_no_memory_leak("BigDecimal(b)")
end
diff --git a/test/bigdecimal/test_bigdecimal_util.rb b/test/bigdecimal/test_bigdecimal_util.rb
index b963fcdeeb..fd457f6bf5 100644
--- a/test/bigdecimal/test_bigdecimal_util.rb
+++ b/test/bigdecimal/test_bigdecimal_util.rb
@@ -12,8 +12,6 @@ class TestBigDecimalUtil < Test::Unit::TestCase
def test_Integer_to_d
assert_equal(BigDecimal(1), 1.to_d)
assert_equal(BigDecimal(2<<100), (2<<100).to_d)
-
- assert(1.to_d.frozen?)
end
def test_Float_to_d_without_precision
@@ -24,11 +22,6 @@ class TestBigDecimalUtil < Test::Unit::TestCase
bug9214 = '[ruby-core:58858]'
assert_equal((-0.0).to_d.sign, -1, bug9214)
-
- assert_raise(TypeError) { 0.3.to_d(nil) }
- assert_raise(TypeError) { 0.3.to_d(false) }
-
- assert(1.1.to_d.frozen?)
end
def test_Float_to_d_with_precision
@@ -39,8 +32,6 @@ class TestBigDecimalUtil < Test::Unit::TestCase
bug9214 = '[ruby-core:58858]'
assert_equal((-0.0).to_d(digits).sign, -1, bug9214)
-
- assert(1.1.to_d(digits).frozen?)
end
def test_Rational_to_d
@@ -48,8 +39,6 @@ class TestBigDecimalUtil < Test::Unit::TestCase
delta = 1.0/10**(digits)
assert_in_delta(BigDecimal(1.quo(2), digits), 1.quo(2).to_d(digits), delta)
assert_in_delta(BigDecimal(355.quo(113), digits), 355.quo(113).to_d(digits), delta)
-
- assert(355.quo(113).to_d(digits).frozen?)
end
def test_Rational_to_d_with_zero_precision
@@ -61,33 +50,11 @@ class TestBigDecimalUtil < Test::Unit::TestCase
end
def test_String_to_d
- assert_equal(BigDecimal('1'), "1__1_1".to_d)
- assert_equal(BigDecimal('2.5'), "2.5".to_d)
- assert_equal(BigDecimal('2.5'), "2.5 degrees".to_d)
- assert_equal(BigDecimal('2.5e1'), "2.5e1 degrees".to_d)
- assert_equal(BigDecimal('0'), "degrees 100.0".to_d)
- assert_equal(BigDecimal('0.125'), "0.1_2_5".to_d)
- assert_equal(BigDecimal('0.125'), "0.1_2_5__".to_d)
- assert_equal(BigDecimal('1'), "1_.125".to_d)
- assert_equal(BigDecimal('1'), "1._125".to_d)
- assert_equal(BigDecimal('0.1'), "0.1__2_5".to_d)
- assert_equal(BigDecimal('0.1'), "0.1_e10".to_d)
- assert_equal(BigDecimal('0.1'), "0.1e_10".to_d)
- assert_equal(BigDecimal('1'), "0.1e1__0".to_d)
- assert_equal(BigDecimal('1.2'), "1.2.3".to_d)
- assert_equal(BigDecimal('1'), "1.".to_d)
- assert_equal(BigDecimal('1'), "1e".to_d)
-
- assert("2.5".to_d.frozen?)
+ assert_equal("2.5".to_d, BigDecimal('2.5'))
end
def test_invalid_String_to_d
assert_equal("invalid".to_d, BigDecimal('0.0'))
end
- def test_Nil_to_d
- assert_equal(nil.to_d, BigDecimal('0.0'))
-
- assert(nil.to_d)
- end
end
diff --git a/test/cgi/test_cgi_cookie.rb b/test/cgi/test_cgi_cookie.rb
index 985cc0d7a1..115a57e4a1 100644
--- a/test/cgi/test_cgi_cookie.rb
+++ b/test/cgi/test_cgi_cookie.rb
@@ -101,11 +101,6 @@ class CGICookieTest < Test::Unit::TestCase
end
end
- def test_cgi_cookie_parse_not_decode_name
- cookie_str = "%66oo=baz;foo=bar"
- cookies = CGI::Cookie.parse(cookie_str)
- assert_equal({"%66oo" => ["baz"], "foo" => ["bar"]}, cookies)
- end
def test_cgi_cookie_arrayinterface
cookie = CGI::Cookie.new('name1', 'a', 'b', 'c')
diff --git a/test/cgi/test_cgi_multipart.rb b/test/cgi/test_cgi_multipart.rb
index 5e8ec25390..d27b1cb8b6 100644
--- a/test/cgi/test_cgi_multipart.rb
+++ b/test/cgi/test_cgi_multipart.rb
@@ -355,7 +355,7 @@ class CGIMultipartTest < Test::Unit::TestCase
require 'stringio'
ENV['REQUEST_METHOD'] = 'POST'
ENV['CONTENT_TYPE'] = 'multipart/form-data; boundary=foobar1234'
- body = <<-BODY.gsub(/\n/, "\r\n")
+ body = <<-BODY
--foobar1234
Content-Disposition: form-data: name=\"name1\"
@@ -370,6 +370,7 @@ Content-Type: text/html
--foobar1234--
BODY
+ body.gsub!(/\n/, "\r\n")
ENV['CONTENT_LENGTH'] = body.size.to_s
$stdin = StringIO.new(body)
CGI.new
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index b7bb7b8eae..f2f5575efb 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -25,30 +25,30 @@ class CGIUtilTest < Test::Unit::TestCase
def test_cgi_escape
- assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93', CGI.escape(@str1))
- assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93'.ascii_only?, CGI.escape(@str1).ascii_only?) if defined?(::Encoding)
+ assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93', CGI::escape(@str1))
+ assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93'.ascii_only?, CGI::escape(@str1).ascii_only?) if defined?(::Encoding)
end
def test_cgi_escape_with_unreserved_characters
assert_equal("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",
- CGI.escape("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"),
+ CGI::escape("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"),
"should not escape any unreserved characters, as per RFC3986 Section 2.3")
end
def test_cgi_escape_with_invalid_byte_sequence
assert_nothing_raised(ArgumentError) do
- assert_equal('%C0%3C%3C', CGI.escape("\xC0\<\<".dup.force_encoding("UTF-8")))
+ assert_equal('%C0%3C%3C', CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8")))
end
end
def test_cgi_escape_preserve_encoding
- assert_equal(Encoding::US_ASCII, CGI.escape("\xC0\<\<".dup.force_encoding("US-ASCII")).encoding)
- assert_equal(Encoding::ASCII_8BIT, CGI.escape("\xC0\<\<".dup.force_encoding("ASCII-8BIT")).encoding)
- assert_equal(Encoding::UTF_8, CGI.escape("\xC0\<\<".dup.force_encoding("UTF-8")).encoding)
+ assert_equal(Encoding::US_ASCII, CGI::escape("\xC0\<\<".dup.force_encoding("US-ASCII")).encoding)
+ assert_equal(Encoding::ASCII_8BIT, CGI::escape("\xC0\<\<".dup.force_encoding("ASCII-8BIT")).encoding)
+ assert_equal(Encoding::UTF_8, CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8")).encoding)
end
def test_cgi_unescape
- str = CGI.unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93')
+ str = CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93')
assert_equal(@str1, str)
return unless defined?(::Encoding)
@@ -57,9 +57,9 @@ class CGIUtilTest < Test::Unit::TestCase
end
def test_cgi_unescape_preserve_encoding
- assert_equal(Encoding::US_ASCII, CGI.unescape("%C0%3C%3C".dup.force_encoding("US-ASCII")).encoding)
- assert_equal(Encoding::ASCII_8BIT, CGI.unescape("%C0%3C%3C".dup.force_encoding("ASCII-8BIT")).encoding)
- assert_equal(Encoding::UTF_8, CGI.unescape("%C0%3C%3C".dup.force_encoding("UTF-8")).encoding)
+ assert_equal(Encoding::US_ASCII, CGI::unescape("%C0%3C%3C".dup.force_encoding("US-ASCII")).encoding)
+ assert_equal(Encoding::ASCII_8BIT, CGI::unescape("%C0%3C%3C".dup.force_encoding("ASCII-8BIT")).encoding)
+ assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".dup.force_encoding("UTF-8")).encoding)
end
def test_cgi_unescape_accept_charset
@@ -73,23 +73,23 @@ class CGIUtilTest < Test::Unit::TestCase
end
def test_cgi_pretty
- assert_equal("<HTML>\n <BODY>\n </BODY>\n</HTML>\n",CGI.pretty("<HTML><BODY></BODY></HTML>"))
- assert_equal("<HTML>\n\t<BODY>\n\t</BODY>\n</HTML>\n",CGI.pretty("<HTML><BODY></BODY></HTML>","\t"))
+ assert_equal("<HTML>\n <BODY>\n </BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>"))
+ assert_equal("<HTML>\n\t<BODY>\n\t</BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>","\t"))
end
def test_cgi_escapeHTML
- assert_equal("&#39;&amp;&quot;&gt;&lt;", CGI.escapeHTML("'&\"><"))
+ assert_equal("&#39;&amp;&quot;&gt;&lt;", CGI::escapeHTML("'&\"><"))
end
def test_cgi_escape_html_duplicated
orig = "Ruby".dup.force_encoding("US-ASCII")
- str = CGI.escapeHTML(orig)
+ str = CGI::escapeHTML(orig)
assert_equal(orig, str)
assert_not_same(orig, str)
end
def assert_cgi_escape_html_preserve_encoding(str, encoding)
- assert_equal(encoding, CGI.escapeHTML(str.dup.force_encoding(encoding)).encoding)
+ assert_equal(encoding, CGI::escapeHTML(str.dup.force_encoding(encoding)).encoding)
end
def test_cgi_escape_html_preserve_encoding
@@ -99,19 +99,26 @@ class CGIUtilTest < Test::Unit::TestCase
end
end
+ def test_cgi_escape_html_preserve_tainted
+ assert_not_predicate CGI::escapeHTML("'&\"><"), :tainted?
+ assert_predicate CGI::escapeHTML("'&\"><".dup.taint), :tainted?
+ assert_not_predicate CGI::escapeHTML("Ruby"), :tainted?
+ assert_predicate CGI::escapeHTML("Ruby".dup.taint), :tainted?
+ end
+
def test_cgi_escape_html_dont_freeze
- assert_not_predicate CGI.escapeHTML("'&\"><".dup), :frozen?
- assert_not_predicate CGI.escapeHTML("'&\"><".freeze), :frozen?
- assert_not_predicate CGI.escapeHTML("Ruby".dup), :frozen?
- assert_not_predicate CGI.escapeHTML("Ruby".freeze), :frozen?
+ assert_not_predicate CGI::escapeHTML("'&\"><".dup), :frozen?
+ assert_not_predicate CGI::escapeHTML("'&\"><".freeze), :frozen?
+ assert_not_predicate CGI::escapeHTML("Ruby".dup), :frozen?
+ assert_not_predicate CGI::escapeHTML("Ruby".freeze), :frozen?
end
def test_cgi_unescapeHTML
- assert_equal("'&\"><", CGI.unescapeHTML("&#39;&amp;&quot;&gt;&lt;"))
+ assert_equal("'&\"><", CGI::unescapeHTML("&#39;&amp;&quot;&gt;&lt;"))
end
def test_cgi_unescapeHTML_invalid
- assert_equal('&<&amp>&quot&abcdefghijklmn', CGI.unescapeHTML('&&lt;&amp&gt;&quot&abcdefghijklmn'))
+ assert_equal('&<&amp>&quot&abcdefghijklmn', CGI::unescapeHTML('&&lt;&amp&gt;&quot&abcdefghijklmn'))
end
Encoding.list.each do |enc|
@@ -122,10 +129,10 @@ class CGIUtilTest < Test::Unit::TestCase
next
else
define_method("test_cgi_escapeHTML:#{enc.name}") do
- assert_equal(escaped, CGI.escapeHTML(unescaped))
+ assert_equal(escaped, CGI::escapeHTML(unescaped))
end
define_method("test_cgi_unescapeHTML:#{enc.name}") do
- assert_equal(unescaped, CGI.unescapeHTML(escaped))
+ assert_equal(unescaped, CGI::unescapeHTML(escaped))
end
end
end
@@ -139,16 +146,16 @@ class CGIUtilTest < Test::Unit::TestCase
next
else
define_method("test_cgi_escape:#{enc.name}") do
- assert_equal(escaped, CGI.escape(unescaped))
+ assert_equal(escaped, CGI::escape(unescaped))
end
define_method("test_cgi_unescape:#{enc.name}") do
- assert_equal(unescaped, CGI.unescape(escaped, enc))
+ assert_equal(unescaped, CGI::unescape(escaped, enc))
end
end
end
def test_cgi_unescapeHTML_uppercasecharacter
- assert_equal("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86", CGI.unescapeHTML("&#x3042;&#x3044;&#X3046;"))
+ assert_equal("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86", CGI::unescapeHTML("&#x3042;&#x3044;&#X3046;"))
end
def test_cgi_include_escape
diff --git a/tool/colors b/test/colors
index a65c326ade..a65c326ade 100644
--- a/tool/colors
+++ b/test/colors
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index 1de39bf569..940f5d39be 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -127,6 +127,15 @@ class TestCoverage < Test::Unit::TestCase
}
end
+ def test_nonpositive_linenumber
+ bug12517 = '[ruby-core:76141] [Bug #12517]'
+ assert_in_out_err(%w[-W0 -rcoverage], <<-"end;", ['{"<compiled>"=>[nil]}'], [], bug12517)
+ Coverage.start
+ RubyVM::InstructionSequence.compile(":ok", nil, "<compiled>", 0)
+ p Coverage.result
+ end;
+ end
+
def test_eval
bug13305 = '[ruby-core:80079] [Bug #13305]'
@@ -167,20 +176,6 @@ class TestCoverage < Test::Unit::TestCase
end;
end
- def test_coverage_optimized_branch
- result = {
- :branches => {
- [:"&.", 0, 1, 0, 1, 8] => {
- [:then, 1, 1, 0, 1, 8] => 0,
- [:else, 2, 1, 0, 1, 8] => 1,
- },
- },
- }
- assert_coverage(<<~"end;", { branches: true }, result) # Bug #15476
- nil&.foo
- end;
- end
-
def assert_coverage(code, opt, stdout)
stdout = [stdout] unless stdout.is_a?(Array)
stdout = stdout.map {|s| s.to_s }
@@ -208,7 +203,7 @@ class TestCoverage < Test::Unit::TestCase
def test_line_coverage_for_multiple_lines
result = {
- :lines => [nil, 1, nil, nil, nil, 1, nil, nil, nil, 1, nil, 1, nil, nil, nil, nil, 1, 1, nil, 1, nil, nil, nil, nil, 1]
+ :lines => [1, nil, nil, nil, nil, nil, 1, nil, 1, nil, nil, nil, nil, nil, 1, nil, 1, 1, 1, nil, nil, nil, nil, nil, 1]
}
assert_coverage(<<~"end;", { lines: true }, result) # Bug #14191
FOO = [
@@ -359,57 +354,18 @@ class TestCoverage < Test::Unit::TestCase
end;
end
- def test_branch_coverage_for_pattern_matching
- result = {
- :branches=> {
- [:case, 0, 3, 4, 8, 7] => {[:in, 1, 5, 6, 5, 7]=>2, [:in, 2, 7, 6, 7, 7]=>0, [:else, 3, 3, 4, 8, 7]=>1},
- [:case, 4, 12, 2, 17, 5] => {[:in, 5, 14, 4, 14, 5]=>2, [:else, 6, 16, 4, 16, 5]=>1}},
- }
- assert_coverage(<<~"end;", { branches: true }, result)
- def foo(x)
- begin
- case x
- in 0
- 0
- in 1
- 1
- end
- rescue NoMatchingPatternError
- end
-
- case x
- in 0
- 0
- else
- 1
- end
- end
-
- foo(0)
- foo(0)
- foo(2)
- end;
- end
-
def test_branch_coverage_for_safe_method_invocation
result = {
:branches=>{
- [:"&.", 0, 6, 0, 6, 6] => {[:then, 1, 6, 0, 6, 6]=>1, [:else, 2, 6, 0, 6, 6]=>0},
- [:"&.", 3, 7, 0, 7, 6] => {[:then, 4, 7, 0, 7, 6]=>0, [:else, 5, 7, 0, 7, 6]=>1},
- [:"&.", 6, 8, 0, 8, 10] => {[:then, 7, 8, 0, 8, 10]=>1, [:else, 8, 8, 0, 8, 10]=>0},
- [:"&.", 9, 9, 0, 9, 10] => {[:then, 10, 9, 0, 9, 10]=>0, [:else, 11, 9, 0, 9, 10]=>1},
+ [:"&.", 0, 3, 0, 3, 6] => {[:then, 1, 3, 0, 3, 6]=>1, [:else, 2, 3, 0, 3, 6]=>0},
+ [:"&.", 3, 4, 0, 4, 6] => {[:then, 4, 4, 0, 4, 6]=>0, [:else, 5, 4, 0, 4, 6]=>1},
}
}
assert_coverage(<<~"end;", { branches: true }, result)
- class Dummy; def foo; end; def foo=(x); end; end
- a = Dummy.new
+ a = 10
b = nil
- c = Dummy.new
- d = nil
- a&.foo
- b&.foo
- c&.foo = 1
- d&.foo = 1
+ a&.abs
+ b&.hoo
end;
end
@@ -536,208 +492,4 @@ class TestCoverage < Test::Unit::TestCase
}
assert_coverage(code, { methods: true }, result)
end
-
- def test_oneshot_line_coverage
- result = {
- :oneshot_lines => [2, 6, 10, 12, 17, 18, 25, 20]
- }
- assert_coverage(<<~"end;", { oneshot_lines: true }, result)
- FOO = [
- { foo: 'bar' }, # 2
- { bar: 'baz' }
- ]
-
- 'some string'.split # 6
- .map(&:length)
-
- some =
- 'value' # 10
-
- Struct.new( # 12
- :foo,
- :bar
- ).new
-
- class Test # 17
- def foo(bar) # 18
- {
- foo: bar # 20
- }
- end
- end
-
- Test.new.foo(Object.new) # 25
- end;
- end
-
- def test_clear_with_lines
- Dir.mktmpdir {|tmp|
- Dir.chdir(tmp) {
- File.open("test.rb", "w") do |f|
- f.puts "def foo(x)"
- f.puts " if x > 0"
- f.puts " :pos"
- f.puts " else"
- f.puts " :non_pos"
- f.puts " end"
- f.puts "end"
- end
-
- exp = [
- "{:lines=>[1, 0, 0, nil, 0, nil, nil]}",
- "{:lines=>[0, 1, 1, nil, 0, nil, nil]}",
- "{:lines=>[0, 1, 0, nil, 1, nil, nil]}",
- ]
- assert_in_out_err(%w[-rcoverage], <<-"end;", exp, [])
- Coverage.start(lines: true)
- tmp = Dir.pwd
- f = tmp + "/test.rb"
- require f
- p Coverage.result(stop: false, clear: true)[f]
- foo(1)
- p Coverage.result(stop: false, clear: true)[f]
- foo(-1)
- p Coverage.result[f]
- end;
- }
- }
- end
-
- def test_clear_with_branches
- Dir.mktmpdir {|tmp|
- Dir.chdir(tmp) {
- File.open("test.rb", "w") do |f|
- f.puts "def foo(x)"
- f.puts " if x > 0"
- f.puts " :pos"
- f.puts " else"
- f.puts " :non_pos"
- f.puts " end"
- f.puts "end"
- end
-
- exp = [
- "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>0, [:else, 2, 5, 4, 5, 12]=>0}}}",
- "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>1, [:else, 2, 5, 4, 5, 12]=>0}}}",
- "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>0, [:else, 2, 5, 4, 5, 12]=>1}}}",
- "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>0, [:else, 2, 5, 4, 5, 12]=>1}}}",
- ]
- assert_in_out_err(%w[-rcoverage], <<-"end;", exp, [])
- Coverage.start(branches: true)
- tmp = Dir.pwd
- f = tmp + "/test.rb"
- require f
- p Coverage.result(stop: false, clear: true)[f]
- foo(1)
- p Coverage.result(stop: false, clear: true)[f]
- foo(-1)
- p Coverage.result(stop: false, clear: true)[f]
- foo(-1)
- p Coverage.result(stop: false, clear: true)[f]
- end;
- }
- }
- end
-
- def test_clear_with_methods
- Dir.mktmpdir {|tmp|
- Dir.chdir(tmp) {
- File.open("test.rb", "w") do |f|
- f.puts "def foo(x)"
- f.puts " if x > 0"
- f.puts " :pos"
- f.puts " else"
- f.puts " :non_pos"
- f.puts " end"
- f.puts "end"
- end
-
- exp = [
- "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>0}}",
- "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>1}}",
- "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>1}}",
- "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>1}}"
- ]
- assert_in_out_err(%w[-rcoverage], <<-"end;", exp, [])
- Coverage.start(methods: true)
- tmp = Dir.pwd
- f = tmp + "/test.rb"
- require f
- p Coverage.result(stop: false, clear: true)[f]
- foo(1)
- p Coverage.result(stop: false, clear: true)[f]
- foo(-1)
- p Coverage.result(stop: false, clear: true)[f]
- foo(-1)
- p Coverage.result(stop: false, clear: true)[f]
- end;
- }
- }
- end
-
- def test_clear_with_oneshot_lines
- Dir.mktmpdir {|tmp|
- Dir.chdir(tmp) {
- File.open("test.rb", "w") do |f|
- f.puts "def foo(x)"
- f.puts " if x > 0"
- f.puts " :pos"
- f.puts " else"
- f.puts " :non_pos"
- f.puts " end"
- f.puts "end"
- end
-
- exp = [
- "{:oneshot_lines=>[1]}",
- "{:oneshot_lines=>[2, 3]}",
- "{:oneshot_lines=>[5]}",
- "{:oneshot_lines=>[]}",
- ]
- assert_in_out_err(%w[-rcoverage], <<-"end;", exp, [])
- Coverage.start(oneshot_lines: true)
- tmp = Dir.pwd
- f = tmp + "/test.rb"
- require f
- p Coverage.result(stop: false, clear: true)[f]
- foo(1)
- p Coverage.result(stop: false, clear: true)[f]
- foo(-1)
- p Coverage.result(stop: false, clear: true)[f]
- foo(-1)
- p Coverage.result(stop: false, clear: true)[f]
- end;
- }
- }
- end
-
- def test_line_stub
- Dir.mktmpdir {|tmp|
- Dir.chdir(tmp) {
- File.open("test.rb", "w") do |f|
- f.puts "def foo(x)"
- f.puts " if x > 0"
- f.puts " :pos"
- f.puts " else"
- f.puts " :non_pos"
- f.puts " end"
- f.puts "end"
- end
-
- assert_equal([0, 0, 0, nil, 0, nil, nil], Coverage.line_stub("test.rb"))
- }
- }
- end
-
- def test_stop_wrong_peephole_optimization
- result = {
- :lines => [1, 1, 1, nil]
- }
- assert_coverage(<<~"end;", { lines: true }, result)
- raise if 1 == 2
- while true
- break
- end
- end;
- end
end
diff --git a/test/csv/base.rb b/test/csv/base.rb
new file mode 100644
index 0000000000..a282c7afed
--- /dev/null
+++ b/test/csv/base.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: false
+require "test/unit"
+
+require "csv"
+
+require_relative "../lib/with_different_ofs.rb"
+
+class TestCSV < Test::Unit::TestCase
+end
diff --git a/test/csv/helper.rb b/test/csv/helper.rb
deleted file mode 100644
index eadff54408..0000000000
--- a/test/csv/helper.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require "tempfile"
-require "test/unit"
-
-require "csv"
-
-require_relative "../lib/with_different_ofs"
-
-module Helper
- def with_chunk_size(chunk_size)
- chunk_size_keep = ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"]
- begin
- ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] = chunk_size
- yield
- ensure
- ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] = chunk_size_keep
- end
- end
-end
diff --git a/test/csv/interface/test_delegation.rb b/test/csv/interface/test_delegation.rb
deleted file mode 100644
index 349257633b..0000000000
--- a/test/csv/interface/test_delegation.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVInterfaceDelegation < Test::Unit::TestCase
- class TestStringIO < self
- def setup
- @csv = CSV.new("h1,h2")
- end
-
- def test_flock
- assert_raise(NotImplementedError) do
- @csv.flock(File::LOCK_EX)
- end
- end
-
- def test_ioctl
- assert_raise(NotImplementedError) do
- @csv.ioctl(0)
- end
- end
-
- def test_stat
- assert_raise(NotImplementedError) do
- @csv.stat
- end
- end
-
- def test_to_i
- assert_raise(NotImplementedError) do
- @csv.to_i
- end
- end
-
- def test_binmode?
- assert_equal(false, @csv.binmode?)
- end
-
- def test_path
- assert_equal(nil, @csv.path)
- end
-
- def test_to_io
- assert_instance_of(StringIO, @csv.to_io)
- end
- end
-end
diff --git a/test/csv/interface/test_read.rb b/test/csv/interface/test_read.rb
deleted file mode 100644
index 58ec188f94..0000000000
--- a/test/csv/interface/test_read.rb
+++ /dev/null
@@ -1,277 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVInterfaceRead < Test::Unit::TestCase
- extend DifferentOFS
-
- def setup
- super
- @data = ""
- @data << "1\t2\t3\r\n"
- @data << "4\t5\r\n"
- @input = Tempfile.new(["interface-read", ".csv"], binmode: true)
- @input << @data
- @input.rewind
- @rows = [
- ["1", "2", "3"],
- ["4", "5"],
- ]
- end
-
- def teardown
- @input.close(true)
- super
- end
-
- def test_foreach
- rows = []
- CSV.foreach(@input.path, col_sep: "\t", row_sep: "\r\n").each do |row|
- rows << row
- end
- assert_equal(@rows, rows)
- end
-
- def test_foreach_mode
- rows = []
- CSV.foreach(@input.path, "r", col_sep: "\t", row_sep: "\r\n").each do |row|
- rows << row
- end
- assert_equal(@rows, rows)
- end
-
- def test_foreach_enumurator
- rows = CSV.foreach(@input.path, col_sep: "\t", row_sep: "\r\n").to_a
- assert_equal(@rows, rows)
- end
-
- def test_closed?
- csv = CSV.open(@input.path, "r+", col_sep: "\t", row_sep: "\r\n")
- assert_not_predicate(csv, :closed?)
- csv.close
- assert_predicate(csv, :closed?)
- end
-
- def test_open_auto_close
- csv = nil
- CSV.open(@input.path) do |_csv|
- csv = _csv
- end
- assert_predicate(csv, :closed?)
- end
-
- def test_open_closed
- csv = nil
- CSV.open(@input.path) do |_csv|
- csv = _csv
- csv.close
- end
- assert_predicate(csv, :closed?)
- end
-
- def test_open_block_return_value
- return_value = CSV.open(@input.path) do
- "Return value."
- end
- assert_equal("Return value.", return_value)
- end
-
- def test_open_encoding_valid
- # U+1F600 GRINNING FACE
- # U+1F601 GRINNING FACE WITH SMILING EYES
- File.open(@input.path, "w") do |file|
- file << "\u{1F600},\u{1F601}"
- end
- CSV.open(@input.path, encoding: "utf-8") do |csv|
- assert_equal([["\u{1F600}", "\u{1F601}"]],
- csv.to_a)
- end
- end
-
- def test_open_encoding_invalid
- # U+1F600 GRINNING FACE
- # U+1F601 GRINNING FACE WITH SMILING EYES
- File.open(@input.path, "w") do |file|
- file << "\u{1F600},\u{1F601}"
- end
- CSV.open(@input.path, encoding: "EUC-JP") do |csv|
- error = assert_raise(CSV::MalformedCSVError) do
- csv.shift
- end
- assert_equal("Invalid byte sequence in EUC-JP in line 1.",
- error.message)
- end
- end
-
- def test_open_encoding_nonexistent
- _output, error = capture_output do
- CSV.open(@input.path, encoding: "nonexistent") do
- end
- end
- assert_equal("path:0: warning: Unsupported encoding nonexistent ignored\n",
- error.gsub(/\A.+:\d+: /, "path:0: "))
- end
-
- def test_open_encoding_utf_8_with_bom
- # U+FEFF ZERO WIDTH NO-BREAK SPACE, BOM
- # U+1F600 GRINNING FACE
- # U+1F601 GRINNING FACE WITH SMILING EYES
- File.open(@input.path, "w") do |file|
- file << "\u{FEFF}\u{1F600},\u{1F601}"
- end
- CSV.open(@input.path, encoding: "bom|utf-8") do |csv|
- assert_equal([["\u{1F600}", "\u{1F601}"]],
- csv.to_a)
- end
- end
-
- def test_parse
- assert_equal(@rows,
- CSV.parse(@data, col_sep: "\t", row_sep: "\r\n"))
- end
-
- def test_parse_block
- rows = []
- CSV.parse(@data, col_sep: "\t", row_sep: "\r\n") do |row|
- rows << row
- end
- assert_equal(@rows, rows)
- end
-
- def test_parse_enumerator
- rows = CSV.parse(@data, col_sep: "\t", row_sep: "\r\n").to_a
- assert_equal(@rows, rows)
- end
-
- def test_parse_headers_only
- table = CSV.parse("a,b,c", headers: true)
- assert_equal([
- ["a", "b", "c"],
- [],
- ],
- [
- table.headers,
- table.each.to_a,
- ])
- end
-
- def test_parse_line
- assert_equal(["1", "2", "3"],
- CSV.parse_line("1;2;3", col_sep: ";"))
- end
-
- def test_parse_line_shortcut
- assert_equal(["1", "2", "3"],
- "1;2;3".parse_csv(col_sep: ";"))
- end
-
- def test_parse_line_empty
- assert_equal(nil, CSV.parse_line("")) # to signal eof
- end
-
- def test_parse_line_empty_line
- assert_equal([], CSV.parse_line("\n1,2,3"))
- end
-
- def test_read
- assert_equal(@rows,
- CSV.read(@input.path, col_sep: "\t", row_sep: "\r\n"))
- end
-
- def test_readlines
- assert_equal(@rows,
- CSV.readlines(@input.path, col_sep: "\t", row_sep: "\r\n"))
- end
-
- def test_open_read
- rows = CSV.open(@input.path, col_sep: "\t", row_sep: "\r\n") do |csv|
- csv.read
- end
- assert_equal(@rows, rows)
- end
-
- def test_open_readlines
- rows = CSV.open(@input.path, col_sep: "\t", row_sep: "\r\n") do |csv|
- csv.readlines
- end
- assert_equal(@rows, rows)
- end
-
- def test_table
- table = CSV.table(@input.path, col_sep: "\t", row_sep: "\r\n")
- assert_equal(CSV::Table.new([
- CSV::Row.new([:"1", :"2", :"3"], [4, 5, nil]),
- ]),
- table)
- end
-
- def test_shift # aliased as gets() and readline()
- CSV.open(@input.path, "rb+", col_sep: "\t", row_sep: "\r\n") do |csv|
- rows = [
- csv.shift,
- csv.shift,
- csv.shift,
- ]
- assert_equal(@rows + [nil],
- rows)
- end
- end
-
- def test_enumerator
- CSV.open(@input.path, col_sep: "\t", row_sep: "\r\n") do |csv|
- assert_equal(@rows, csv.each.to_a)
- end
- end
-
- def test_shift_and_each
- CSV.open(@input.path, col_sep: "\t", row_sep: "\r\n") do |csv|
- rows = []
- rows << csv.shift
- rows.concat(csv.each.to_a)
- assert_equal(@rows, rows)
- end
- end
-
- def test_each_twice
- CSV.open(@input.path, col_sep: "\t", row_sep: "\r\n") do |csv|
- assert_equal([
- @rows,
- [],
- ],
- [
- csv.each.to_a,
- csv.each.to_a,
- ])
- end
- end
-
- def test_eof?
- eofs = []
- CSV.open(@input.path, col_sep: "\t", row_sep: "\r\n") do |csv|
- eofs << csv.eof?
- csv.shift
- eofs << csv.eof?
- csv.shift
- eofs << csv.eof?
- end
- assert_equal([false, false, true],
- eofs)
- end
-
- def test_new_nil
- assert_raise_with_message ArgumentError, "Cannot parse nil as CSV" do
- CSV.new(nil)
- end
- end
-
- def test_options_not_modified
- options = {}.freeze
- CSV.foreach(@input.path, **options)
- CSV.open(@input.path, **options) {}
- CSV.parse("", **options)
- CSV.parse_line("", **options)
- CSV.read(@input.path, **options)
- CSV.readlines(@input.path, **options)
- CSV.table(@input.path, **options)
- end
-end
diff --git a/test/csv/interface/test_read_write.rb b/test/csv/interface/test_read_write.rb
deleted file mode 100644
index 877e5f355e..0000000000
--- a/test/csv/interface/test_read_write.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVInterfaceReadWrite < Test::Unit::TestCase
- extend DifferentOFS
-
- def test_filter
- input = <<-CSV
-1;2;3
-4;5
- CSV
- output = ""
- CSV.filter(input, output,
- in_col_sep: ";",
- out_col_sep: ",",
- converters: :all) do |row|
- row.map! {|n| n * 2}
- row << "Added\r"
- end
- assert_equal(<<-CSV, output)
-2,4,6,"Added\r"
-8,10,"Added\r"
- CSV
- end
-
- def test_instance_same
- data = ""
- assert_equal(CSV.instance(data, col_sep: ";").object_id,
- CSV.instance(data, col_sep: ";").object_id)
- end
-
- def test_instance_append
- output = ""
- CSV.instance(output, col_sep: ";") << ["a", "b", "c"]
- assert_equal(<<-CSV, output)
-a;b;c
- CSV
- CSV.instance(output, col_sep: ";") << [1, 2, 3]
- assert_equal(<<-CSV, output)
-a;b;c
-1;2;3
- CSV
- end
-
- def test_instance_shortcut
- assert_equal(CSV.instance,
- CSV {|csv| csv})
- end
-end
diff --git a/test/csv/interface/test_write.rb b/test/csv/interface/test_write.rb
deleted file mode 100644
index 8650ecd624..0000000000
--- a/test/csv/interface/test_write.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVInterfaceWrite < Test::Unit::TestCase
- extend DifferentOFS
-
- def setup
- super
- @output = Tempfile.new(["interface-write", ".csv"])
- end
-
- def teardown
- @output.close(true)
- super
- end
-
- def test_generate_default
- csv_text = CSV.generate do |csv|
- csv << [1, 2, 3] << [4, nil, 5]
- end
- assert_equal(<<-CSV, csv_text)
-1,2,3
-4,,5
- CSV
- end
-
- def test_generate_append
- csv_text = <<-CSV
-1,2,3
-4,,5
- CSV
- CSV.generate(csv_text) do |csv|
- csv << ["last", %Q{"row"}]
- end
- assert_equal(<<-CSV, csv_text)
-1,2,3
-4,,5
-last,"""row"""
- CSV
- end
-
- def test_generate_no_new_line
- csv_text = CSV.generate("test") do |csv|
- csv << ["row"]
- end
- assert_equal(<<-CSV, csv_text)
-testrow
- CSV
- end
-
- def test_generate_line_col_sep
- line = CSV.generate_line(["1", "2", "3"], col_sep: ";")
- assert_equal(<<-LINE, line)
-1;2;3
- LINE
- end
-
- def test_generate_line_row_sep
- line = CSV.generate_line(["1", "2"], row_sep: nil)
- assert_equal(<<-LINE.chomp, line)
-1,2
- LINE
- end
-
- def test_generate_line_shortcut
- line = ["1", "2", "3"].to_csv(col_sep: ";")
- assert_equal(<<-LINE, line)
-1;2;3
- LINE
- end
-
- def test_headers_detection
- headers = ["a", "b", "c"]
- CSV.open(@output.path, "w", headers: true) do |csv|
- csv << headers
- csv << ["1", "2", "3"]
- assert_equal(headers, csv.headers)
- end
- end
-
- def test_lineno
- CSV.open(@output.path, "w") do |csv|
- n_lines = 20
- n_lines.times do
- csv << ["a", "b", "c"]
- end
- assert_equal(n_lines, csv.lineno)
- end
- end
-
- def test_append_row
- CSV.open(@output.path, "wb") do |csv|
- csv <<
- CSV::Row.new([], ["1", "2", "3"]) <<
- CSV::Row.new([], ["a", "b", "c"])
- end
- assert_equal(<<-CSV, File.read(@output.path, mode: "rb"))
-1,2,3
-a,b,c
- CSV
- end
-
- def test_append_hash
- CSV.open(@output.path, "wb", headers: true) do |csv|
- csv << [:a, :b, :c]
- csv << {a: 1, b: 2, c: 3}
- csv << {a: 4, b: 5, c: 6}
- end
- assert_equal(<<-CSV, File.read(@output.path, mode: "rb"))
-a,b,c
-1,2,3
-4,5,6
- CSV
- end
-
- def test_append_hash_headers_array
- CSV.open(@output.path, "wb", headers: [:b, :a, :c]) do |csv|
- csv << {a: 1, b: 2, c: 3}
- csv << {a: 4, b: 5, c: 6}
- end
- assert_equal(<<-CSV, File.read(@output.path, mode: "rb"))
-2,1,3
-5,4,6
- CSV
- end
-
- def test_append_hash_headers_string
- CSV.open(@output.path, "wb", headers: "b|a|c", col_sep: "|") do |csv|
- csv << {"a" => 1, "b" => 2, "c" => 3}
- csv << {"a" => 4, "b" => 5, "c" => 6}
- end
- assert_equal(<<-CSV, File.read(@output.path, mode: "rb"))
-2|1|3
-5|4|6
- CSV
- end
-
- def test_write_headers
- CSV.open(@output.path,
- "wb",
- headers: "b|a|c",
- write_headers: true,
- col_sep: "|" ) do |csv|
- csv << {"a" => 1, "b" => 2, "c" => 3}
- csv << {"a" => 4, "b" => 5, "c" => 6}
- end
- assert_equal(<<-CSV, File.read(@output.path, mode: "rb"))
-b|a|c
-2|1|3
-5|4|6
- CSV
- end
-
- def test_write_headers_empty
- CSV.open(@output.path,
- "wb",
- headers: "b|a|c",
- write_headers: true,
- col_sep: "|" ) do |csv|
- end
- assert_equal(<<-CSV, File.read(@output.path, mode: "rb"))
-b|a|c
- CSV
- end
-
- def test_options_not_modified
- options = {}.freeze
- CSV.generate(**options) {}
- CSV.generate_line([], **options)
- CSV.filter("", "", **options)
- CSV.instance("", **options)
- end
-end
diff --git a/test/csv/parse/test_column_separator.rb b/test/csv/parse/test_column_separator.rb
deleted file mode 100644
index d6eaa7b6de..0000000000
--- a/test/csv/parse/test_column_separator.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseColumnSeparator < Test::Unit::TestCase
- extend DifferentOFS
-
- def test_comma
- assert_equal([["a", "b", nil, "d"]],
- CSV.parse("a,b,,d", col_sep: ","))
- end
-
- def test_space
- assert_equal([["a", "b", nil, "d"]],
- CSV.parse("a b d", col_sep: " "))
- end
-
- def test_tab
- assert_equal([["a", "b", nil, "d"]],
- CSV.parse("a\tb\t\td", col_sep: "\t"))
- end
-
- def test_multiple_characters_include_sub_separator
- assert_equal([["a b", nil, "d"]],
- CSV.parse("a b d", col_sep: " "))
- end
-
- def test_multiple_characters_leading_empty_fields
- data = <<-CSV
-<=><=>A<=>B<=>C
-1<=>2<=>3
- CSV
- assert_equal([
- [nil, nil, "A", "B", "C"],
- ["1", "2", "3"],
- ],
- CSV.parse(data, col_sep: "<=>"))
- end
-end
diff --git a/test/csv/parse/test_convert.rb b/test/csv/parse/test_convert.rb
deleted file mode 100644
index bfe6ddd527..0000000000
--- a/test/csv/parse/test_convert.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseConvert < Test::Unit::TestCase
- extend DifferentOFS
-
- def setup
- super
- @data = "Numbers,:integer,1,:float,3.015"
- @parser = CSV.new(@data)
-
- @custom = lambda {|field| /\A:(\S.*?)\s*\Z/ =~ field ? $1.to_sym : field}
-
- @time = Time.utc(2018, 12, 30, 6, 41, 29)
- @windows_safe_time_data = @time.strftime("%a %b %d %H:%M:%S %Y")
- end
-
- def test_integer
- @parser.convert(:integer)
- assert_equal(["Numbers", ":integer", 1, ":float", "3.015"],
- @parser.shift)
- end
-
- def test_float
- @parser.convert(:float)
- assert_equal(["Numbers", ":integer", 1.0, ":float", 3.015],
- @parser.shift)
- end
-
- def test_float_integer
- @parser.convert(:float)
- @parser.convert(:integer)
- assert_equal(["Numbers", ":integer", 1.0, ":float", 3.015],
- @parser.shift)
- end
-
- def test_integer_float
- @parser.convert(:integer)
- @parser.convert(:float)
- assert_equal(["Numbers", ":integer", 1, ":float", 3.015],
- @parser.shift)
- end
-
- def test_numberic
- @parser.convert(:numeric)
- assert_equal(["Numbers", ":integer", 1, ":float", 3.015],
- @parser.shift)
- end
-
- def test_all
- @data << ",#{@windows_safe_time_data}"
- @parser = CSV.new(@data)
- @parser.convert(:all)
- assert_equal(["Numbers", ":integer", 1, ":float", 3.015, @time.to_datetime],
- @parser.shift)
- end
-
- def test_custom
- @parser.convert do |field|
- /\A:(\S.*?)\s*\Z/ =~ field ? $1.to_sym : field
- end
- assert_equal(["Numbers", :integer, "1", :float, "3.015"],
- @parser.shift)
- end
-
- def test_builtin_custom
- @parser.convert(:numeric)
- @parser.convert(&@custom)
- assert_equal(["Numbers", :integer, 1, :float, 3.015],
- @parser.shift)
- end
-
- def test_custom_field_info_line
- @parser.convert do |field, info|
- assert_equal(1, info.line)
- info.index == 4 ? Float(field).floor : field
- end
- assert_equal(["Numbers", ":integer", "1", ":float", 3],
- @parser.shift)
- end
-
- def test_custom_field_info_header
- headers = ["one", "two", "three", "four", "five"]
- @parser = CSV.new(@data, headers: headers)
- @parser.convert do |field, info|
- info.header == "three" ? Integer(field) * 100 : field
- end
- assert_equal(CSV::Row.new(headers,
- ["Numbers", ":integer", 100, ":float", "3.015"]),
- @parser.shift)
- end
-
- def test_custom_blank_field
- converter = lambda {|field| field.nil?}
- row = CSV.parse_line('nil,', converters: converter)
- assert_equal([false, true], row)
- end
-
- def test_nil_value
- assert_equal(["nil", "", "a"],
- CSV.parse_line(',"",a', nil_value: "nil"))
- end
-
- def test_empty_value
- assert_equal([nil, "empty", "a"],
- CSV.parse_line(',"",a', empty_value: "empty"))
- end
-end
diff --git a/test/csv/parse/test_each.rb b/test/csv/parse/test_each.rb
deleted file mode 100644
index ce0b71d058..0000000000
--- a/test/csv/parse/test_each.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseEach < Test::Unit::TestCase
- extend DifferentOFS
-
- def test_twice
- data = <<-CSV
-Ruby,2.6.0,script
- CSV
- csv = CSV.new(data)
- assert_equal([
- [["Ruby", "2.6.0", "script"]],
- [],
- ],
- [
- csv.to_a,
- csv.to_a,
- ])
- end
-end
diff --git a/test/csv/parse/test_general.rb b/test/csv/parse/test_general.rb
deleted file mode 100644
index 655bb26560..0000000000
--- a/test/csv/parse/test_general.rb
+++ /dev/null
@@ -1,255 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require "timeout"
-
-require_relative "../helper"
-
-#
-# Following tests are my interpretation of the
-# {CSV RCF}[http://www.ietf.org/rfc/rfc4180.txt]. I only deviate from that
-# document in one place (intentionally) and that is to make the default row
-# separator <tt>$/</tt>.
-#
-class TestCSVParseGeneral < Test::Unit::TestCase
- extend DifferentOFS
-
- BIG_DATA = "123456789\n" * 1024
-
- def test_mastering_regex_example
- ex = %Q{Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K}
- assert_equal( [ "Ten Thousand", "10000", " 2710 ", nil, "10,000",
- "It's \"10 Grand\", baby", "10K" ],
- CSV.parse_line(ex) )
- end
-
- # Old Ruby 1.8 CSV library tests.
- def test_std_lib_csv
- [ ["\t", ["\t"]],
- ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
- ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
- ["\"\"\"\n\",\"\"\"\n\"", ["\"\n", "\"\n"]],
- ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
- ["\"\"", [""]],
- ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
- ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
- ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
- ["foo,\"\",baz", ["foo", "", "baz"]],
- ["\",\"", [","]],
- ["foo", ["foo"]],
- [",,", [nil, nil, nil]],
- [",", [nil, nil]],
- ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
- ["foo,,baz", ["foo", nil, "baz"]],
- ["\"\"\"\r\",\"\"\"\r\"", ["\"\r", "\"\r"]],
- ["\",\",\",\"", [",", ","]],
- ["foo,bar,", ["foo", "bar", nil]],
- [",foo,bar", [nil, "foo", "bar"]],
- ["foo,bar", ["foo", "bar"]],
- [";", [";"]],
- ["\t,\t", ["\t", "\t"]],
- ["foo,\"\r\n\r\",baz", ["foo", "\r\n\r", "baz"]],
- ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
- ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
- [";,;", [";", ";"]] ].each do |csv_test|
- assert_equal(csv_test.last, CSV.parse_line(csv_test.first))
- end
-
- [ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
- ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
- ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
- ["\"\"", [""]],
- ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
- ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
- ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
- ["foo,\"\",baz", ["foo", "", "baz"]],
- ["foo", ["foo"]],
- [",,", [nil, nil, nil]],
- [",", [nil, nil]],
- ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
- ["foo,,baz", ["foo", nil, "baz"]],
- ["foo,bar", ["foo", "bar"]],
- ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
- ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]] ].each do |csv_test|
- assert_equal(csv_test.last, CSV.parse_line(csv_test.first))
- end
- end
-
- # From: http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/6496
- def test_aras_edge_cases
- [ [%Q{a,b}, ["a", "b"]],
- [%Q{a,"""b"""}, ["a", "\"b\""]],
- [%Q{a,"""b"}, ["a", "\"b"]],
- [%Q{a,"b"""}, ["a", "b\""]],
- [%Q{a,"\nb"""}, ["a", "\nb\""]],
- [%Q{a,"""\nb"}, ["a", "\"\nb"]],
- [%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
- [%Q{a,"""\nb\n""",\nc}, ["a", "\"\nb\n\"", nil]],
- [%Q{a,,,}, ["a", nil, nil, nil]],
- [%Q{,}, [nil, nil]],
- [%Q{"",""}, ["", ""]],
- [%Q{""""}, ["\""]],
- [%Q{"""",""}, ["\"",""]],
- [%Q{,""}, [nil,""]],
- [%Q{,"\r"}, [nil,"\r"]],
- [%Q{"\r\n,"}, ["\r\n,"]],
- [%Q{"\r\n,",}, ["\r\n,", nil]] ].each do |edge_case|
- assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
- end
- end
-
- def test_james_edge_cases
- # A read at eof? should return nil.
- assert_equal(nil, CSV.parse_line(""))
- #
- # With Ruby 1.8 CSV it's impossible to tell an empty line from a line
- # containing a single +nil+ field. The old CSV library returns
- # <tt>[nil]</tt> in these cases, but <tt>Array.new</tt> makes more sense to
- # me.
- #
- assert_equal(Array.new, CSV.parse_line("\n1,2,3\n"))
- end
-
- def test_rob_edge_cases
- [ [%Q{"a\nb"}, ["a\nb"]],
- [%Q{"\n\n\n"}, ["\n\n\n"]],
- [%Q{a,"b\n\nc"}, ['a', "b\n\nc"]],
- [%Q{,"\r\n"}, [nil,"\r\n"]],
- [%Q{,"\r\n."}, [nil,"\r\n."]],
- [%Q{"a\na","one newline"}, ["a\na", 'one newline']],
- [%Q{"a\n\na","two newlines"}, ["a\n\na", 'two newlines']],
- [%Q{"a\r\na","one CRLF"}, ["a\r\na", 'one CRLF']],
- [%Q{"a\r\n\r\na","two CRLFs"}, ["a\r\n\r\na", 'two CRLFs']],
- [%Q{with blank,"start\n\nfinish"\n}, ['with blank', "start\n\nfinish"]],
- ].each do |edge_case|
- assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
- end
- end
-
- def test_non_regex_edge_cases
- # An early version of the non-regex parser fails this test
- [ [ "foo,\"foo,bar,baz,foo\",\"foo\"",
- ["foo", "foo,bar,baz,foo", "foo"] ] ].each do |edge_case|
- assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
- end
-
- assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line("1,\"23\"4\"5\", 6")
- end
- end
-
- def test_malformed_csv_cr_first_line
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line("1,2\r,3", row_sep: "\n")
- end
- assert_equal("Unquoted fields do not allow new line <\"\\r\"> in line 1.",
- error.message)
- end
-
- def test_malformed_csv_cr_middle_line
- csv = <<-CSV
-line,1,abc
-line,2,"def\nghi"
-
-line,4,some\rjunk
-line,5,jkl
- CSV
-
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse(csv)
- end
- assert_equal("Unquoted fields do not allow new line <\"\\r\"> in line 4.",
- error.message)
- end
-
- def test_malformed_csv_unclosed_quote
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line('1,2,"3...')
- end
- assert_equal("Unclosed quoted field in line 1.",
- error.message)
- end
-
- def test_malformed_csv_illegal_quote_middle_line
- csv = <<-CSV
-line,1,abc
-line,2,"def\nghi"
-
-line,4,8'10"
-line,5,jkl
- CSV
-
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse(csv)
- end
- assert_equal("Illegal quoting in line 4.",
- error.message)
- end
-
- def test_the_parse_fails_fast_when_it_can_for_unquoted_fields
- assert_parse_errors_out('valid,fields,bad start"' + BIG_DATA)
- end
-
- def test_the_parse_fails_fast_when_it_can_for_unescaped_quotes
- assert_parse_errors_out('valid,fields,"bad start"unescaped' + BIG_DATA)
- end
-
- def test_field_size_limit_controls_lookahead
- assert_parse_errors_out( 'valid,fields,"' + BIG_DATA + '"',
- field_size_limit: 2048 )
- end
-
- def test_field_size_limit_in_extended_column_not_exceeding
- data = <<~DATA
- "a","b"
- "
- 2
- ",""
- DATA
- assert_nothing_raised(CSV::MalformedCSVError) do
- CSV.parse(data, field_size_limit: 4)
- end
- end
-
- def test_field_size_limit_in_extended_column_exceeding
- data = <<~DATA
- "a","b"
- "
- 2345
- ",""
- DATA
- assert_parse_errors_out(data, field_size_limit: 5)
- end
-
- def test_row_sep_auto_cr
- assert_equal([["a"]], CSV.parse("a\r"))
- end
-
- def test_row_sep_auto_lf
- assert_equal([["a"]], CSV.parse("a\n"))
- end
-
- def test_row_sep_auto_cr_lf
- assert_equal([["a"]], CSV.parse("a\r\n"))
- end
-
- def test_seeked_string_io
- input_with_bom = StringIO.new("\ufeffã‚,ã„,ã†\r\na,b,c\r\n")
- input_with_bom.read(3)
- assert_equal([
- ["ã‚", "ã„", "ã†"],
- ["a", "b", "c"],
- ],
- CSV.new(input_with_bom).each.to_a)
- end
-
- private
- def assert_parse_errors_out(data, **options)
- assert_raise(CSV::MalformedCSVError) do
- Timeout.timeout(0.2) do
- CSV.parse(data, **options)
- fail("Parse didn't error out")
- end
- end
- end
-end
diff --git a/test/csv/parse/test_header.rb b/test/csv/parse/test_header.rb
deleted file mode 100644
index 481c5107c6..0000000000
--- a/test/csv/parse/test_header.rb
+++ /dev/null
@@ -1,335 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVHeaders < Test::Unit::TestCase
- extend DifferentOFS
-
- def setup
- super
- @data = <<-CSV
-first,second,third
-A,B,C
-1,2,3
- CSV
- end
-
- def test_first_row
- [:first_row, true].each do |setting| # two names for the same setting
- # activate headers
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, headers: setting)
- end
-
- # first data row - skipping headers
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first A}, %w{second B}, %w{third C}], row.to_a)
-
- # second data row
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first 1}, %w{second 2}, %w{third 3}], row.to_a)
-
- # empty
- assert_nil(csv[2])
- end
- end
-
- def test_array_of_headers
- # activate headers
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, headers: [:my, :new, :headers])
- end
-
- # first data row - skipping headers
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal( [[:my, "first"], [:new, "second"], [:headers, "third"]],
- row.to_a )
-
- # second data row
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([[:my, "A"], [:new, "B"], [:headers, "C"]], row.to_a)
-
- # third data row
- row = csv[2]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([[:my, "1"], [:new, "2"], [:headers, "3"]], row.to_a)
-
- # empty
- assert_nil(csv[3])
-
- # with return and convert
- assert_nothing_raised(Exception) do
- csv = CSV.parse( @data, headers: [:my, :new, :headers],
- return_headers: true,
- header_converters: lambda { |h| h.to_s } )
- end
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([["my", :my], ["new", :new], ["headers", :headers]], row.to_a)
- assert_predicate(row, :header_row?)
- assert_not_predicate(row, :field_row?)
- end
-
- def test_csv_header_string
- # activate headers
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, headers: "my,new,headers")
- end
-
- # first data row - skipping headers
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{my first}, %w{new second}, %w{headers third}], row.to_a)
-
- # second data row
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{my A}, %w{new B}, %w{headers C}], row.to_a)
-
- # third data row
- row = csv[2]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{my 1}, %w{new 2}, %w{headers 3}], row.to_a)
-
- # empty
- assert_nil(csv[3])
-
- # with return and convert
- assert_nothing_raised(Exception) do
- csv = CSV.parse( @data, headers: "my,new,headers",
- return_headers: true,
- header_converters: :symbol )
- end
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([[:my, "my"], [:new, "new"], [:headers, "headers"]], row.to_a)
- assert_predicate(row, :header_row?)
- assert_not_predicate(row, :field_row?)
- end
-
- def test_csv_header_string_inherits_separators
- # parse with custom col_sep
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse( @data.tr(",", "|"), col_sep: "|",
- headers: "my|new|headers" )
- end
-
- # verify headers were recognized
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{my first}, %w{new second}, %w{headers third}], row.to_a)
- end
-
- def test_return_headers
- # activate headers and request they are returned
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, headers: true, return_headers: true)
- end
-
- # header row
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal( [%w{first first}, %w{second second}, %w{third third}],
- row.to_a )
- assert_predicate(row, :header_row?)
- assert_not_predicate(row, :field_row?)
-
- # first data row - skipping headers
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first A}, %w{second B}, %w{third C}], row.to_a)
- assert_not_predicate(row, :header_row?)
- assert_predicate(row, :field_row?)
-
- # second data row
- row = csv[2]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first 1}, %w{second 2}, %w{third 3}], row.to_a)
- assert_not_predicate(row, :header_row?)
- assert_predicate(row, :field_row?)
-
- # empty
- assert_nil(csv[3])
- end
-
- def test_converters
- # create test data where headers and fields look alike
- data = <<-CSV
-1,2,3
-1,2,3
- CSV
-
- # normal converters do not affect headers
- csv = CSV.parse( data, headers: true,
- return_headers: true,
- converters: :numeric )
- assert_equal([%w{1 1}, %w{2 2}, %w{3 3}], csv[0].to_a)
- assert_equal([["1", 1], ["2", 2], ["3", 3]], csv[1].to_a)
- assert_nil(csv[2])
-
- # header converters do affect headers (only)
- assert_nothing_raised(Exception) do
- csv = CSV.parse( data, headers: true,
- return_headers: true,
- converters: :numeric,
- header_converters: :symbol )
- end
- assert_equal([[:"1", "1"], [:"2", "2"], [:"3", "3"]], csv[0].to_a)
- assert_equal([[:"1", 1], [:"2", 2], [:"3", 3]], csv[1].to_a)
- assert_nil(csv[2])
- end
-
- def test_builtin_downcase_converter
- csv = CSV.parse( "One,TWO Three", headers: true,
- return_headers: true,
- header_converters: :downcase )
- assert_equal(%w{one two\ three}, csv.headers)
- end
-
- def test_builtin_symbol_converter
- # Note that the trailing space is intentional
- csv = CSV.parse( "One,TWO Three ", headers: true,
- return_headers: true,
- header_converters: :symbol )
- assert_equal([:one, :two_three], csv.headers)
- end
-
- def test_builtin_symbol_converter_with_punctuation
- csv = CSV.parse( "One, Two & Three ($)", headers: true,
- return_headers: true,
- header_converters: :symbol )
- assert_equal([:one, :two_three], csv.headers)
- end
-
- def test_builtin_converters_with_blank_header
- csv = CSV.parse( "one,,three", headers: true,
- return_headers: true,
- header_converters: [:downcase, :symbol] )
- assert_equal([:one, nil, :three], csv.headers)
- end
-
- def test_custom_converter
- converter = lambda { |header| header.tr(" ", "_") }
- csv = CSV.parse( "One,TWO Three",
- headers: true,
- return_headers: true,
- header_converters: converter )
- assert_equal(%w{One TWO_Three}, csv.headers)
- end
-
- def test_table_support
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, headers: true)
- end
-
- assert_instance_of(CSV::Table, csv)
- end
-
- def test_skip_blanks
- @data = <<-CSV
-
-
-A,B,C
-
-1,2,3
-
-
-
- CSV
-
- expected = [%w[1 2 3]]
- CSV.parse(@data, headers: true, skip_blanks: true) do |row|
- assert_equal(expected.shift, row.fields)
- end
-
- expected = [%w[A B C], %w[1 2 3]]
- CSV.parse( @data,
- headers: true,
- return_headers: true,
- skip_blanks: true ) do |row|
- assert_equal(expected.shift, row.fields)
- end
- end
-
- def test_headers_reader
- # no headers
- assert_nil(CSV.new(@data).headers)
-
- # headers
- csv = CSV.new(@data, headers: true)
- assert_equal(true, csv.headers) # before headers are read
- csv.shift # set headers
- assert_equal(%w[first second third], csv.headers) # after headers are read
- end
-
- def test_blank_row
- @data += "\n#{@data}" # add a blank row
-
- # ensure that everything returned is a Row object
- CSV.parse(@data, headers: true) do |row|
- assert_instance_of(CSV::Row, row)
- end
- end
-
- def test_nil_row_header
- @data = <<-CSV
-A
-
-1
- CSV
-
- csv = CSV.parse(@data, headers: true)
-
- # ensure nil row creates Row object with headers
- row = csv[0]
- assert_equal([["A"], [nil]],
- [row.headers, row.fields])
- end
-
- def test_parse_empty
- assert_equal(CSV::Table.new([]),
- CSV.parse("", headers: true))
- end
-
- def test_parse_empty_line
- assert_equal(CSV::Table.new([]),
- CSV.parse("\n", headers: true))
- end
-
- def test_specified_empty
- assert_equal(CSV::Table.new([],
- headers: ["header1"]),
- CSV.parse("", headers: ["header1"]))
- end
-
- def test_specified_empty_line
- assert_equal(CSV::Table.new([CSV::Row.new(["header1"], [])],
- headers: ["header1"]),
- CSV.parse("\n", headers: ["header1"]))
- end
-end
diff --git a/test/csv/parse/test_invalid.rb b/test/csv/parse/test_invalid.rb
deleted file mode 100644
index 9dfd081380..0000000000
--- a/test/csv/parse/test_invalid.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseInvalid < Test::Unit::TestCase
- def test_no_column_mixed_new_lines
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse("\n" +
- "\r")
- end
- assert_equal("New line must be <\"\\n\"> not <\"\\r\"> in line 2.",
- error.message)
- end
-
- def test_ignore_invalid_line
- csv = CSV.new(<<-CSV, headers: true, return_headers: true)
-head1,head2,head3
-aaa,bbb,ccc
-ddd,ee"e.fff
-ggg,hhh,iii
- CSV
- headers = ["head1", "head2", "head3"]
- assert_equal(CSV::Row.new(headers, headers),
- csv.shift)
- assert_equal(CSV::Row.new(headers, ["aaa", "bbb", "ccc"]),
- csv.shift)
- assert_equal(false, csv.eof?)
- error = assert_raise(CSV::MalformedCSVError) do
- csv.shift
- end
- assert_equal("Illegal quoting in line 3.",
- error.message)
- assert_equal(false, csv.eof?)
- assert_equal(CSV::Row.new(headers, ["ggg", "hhh", "iii"]),
- csv.shift)
- assert_equal(true, csv.eof?)
- end
-end
diff --git a/test/csv/parse/test_liberal_parsing.rb b/test/csv/parse/test_liberal_parsing.rb
deleted file mode 100644
index 2f7b34689f..0000000000
--- a/test/csv/parse/test_liberal_parsing.rb
+++ /dev/null
@@ -1,160 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseLiberalParsing < Test::Unit::TestCase
- extend DifferentOFS
-
- def test_middle_quote_start
- input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line(input)
- end
- assert_equal("Illegal quoting in line 1.",
- error.message)
- assert_equal(["Johnson, Dwayne", 'Dwayne "The Rock" Johnson'],
- CSV.parse_line(input, liberal_parsing: true))
- end
-
- def test_middle_quote_end
- input = '"quoted" field'
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line(input)
- end
- assert_equal("Any value after quoted field isn't allowed in line 1.",
- error.message)
- assert_equal(['"quoted" field'],
- CSV.parse_line(input, liberal_parsing: true))
- end
-
- def test_quote_after_column_separator
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line('is,this "three," or four,fields', liberal_parsing: true)
- end
- assert_equal("Unclosed quoted field in line 1.",
- error.message)
- end
-
- def test_quote_before_column_separator
- assert_equal(["is", 'this "three', ' or four"', "fields"],
- CSV.parse_line('is,this "three, or four",fields',
- liberal_parsing: true))
- end
-
- def test_backslash_quote
- assert_equal([
- "1",
- "\"Hamlet says, \\\"Seems",
- "\\\" madam! Nay it is; I know not \\\"seems.\\\"\"",
- ],
- CSV.parse_line('1,' +
- '"Hamlet says, \"Seems,' +
- '\" madam! Nay it is; I know not \"seems.\""',
- liberal_parsing: true))
- end
-
- def test_space_quote
- input = <<~CSV
- Los Angeles, 34°03'N, 118°15'W
- New York City, 40°42'46"N, 74°00'21"W
- Paris, 48°51'24"N, 2°21'03"E
- CSV
- assert_equal(
- [
- ["Los Angeles", " 34°03'N", " 118°15'W"],
- ["New York City", " 40°42'46\"N", " 74°00'21\"W"],
- ["Paris", " 48°51'24\"N", " 2°21'03\"E"],
- ],
- CSV.parse(input, liberal_parsing: true))
- end
-
- def test_double_quote_outside_quote
- data = %Q{a,""b""}
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse(data)
- end
- assert_equal("Any value after quoted field isn't allowed in line 1.",
- error.message)
- assert_equal([
- [["a", %Q{""b""}]],
- [["a", %Q{"b"}]],
- ],
- [
- CSV.parse(data, liberal_parsing: true),
- CSV.parse(data,
- liberal_parsing: {
- double_quote_outside_quote: true,
- }),
- ])
- end
-
- class TestBackslashQuote < Test::Unit::TestCase
- extend ::DifferentOFS
-
- def test_double_quote_outside_quote
- data = %Q{a,""b""}
- assert_equal([
- [["a", %Q{""b""}]],
- [["a", %Q{"b"}]],
- ],
- [
- CSV.parse(data,
- liberal_parsing: {
- backslash_quote: true
- }),
- CSV.parse(data,
- liberal_parsing: {
- backslash_quote: true,
- double_quote_outside_quote: true
- }),
- ])
- end
-
- def test_unquoted_value
- data = %q{\"\"a\"\"}
- assert_equal([
- [[%q{\"\"a\"\"}]],
- [[%q{""a""}]],
- ],
- [
- CSV.parse(data, liberal_parsing: true),
- CSV.parse(data,
- liberal_parsing: {
- backslash_quote: true
- }),
- ])
- end
-
- def test_unquoted_value_multiple_characters_col_sep
- data = %q{a<\\"b<=>x}
- assert_equal([[%Q{a<"b}, "x"]],
- CSV.parse(data,
- col_sep: "<=>",
- liberal_parsing: {
- backslash_quote: true
- }))
- end
-
- def test_quoted_value
- data = %q{"\"\"a\"\""}
- assert_equal([
- [[%q{"\"\"a\"\""}]],
- [[%q{""a""}]],
- [[%q{""a""}]],
- ],
- [
- CSV.parse(data, liberal_parsing: true),
- CSV.parse(data,
- liberal_parsing: {
- backslash_quote: true
- }),
- CSV.parse(data,
- liberal_parsing: {
- backslash_quote: true,
- double_quote_outside_quote: true
- }),
- ])
- end
- end
-end
diff --git a/test/csv/parse/test_quote_char_nil.rb b/test/csv/parse/test_quote_char_nil.rb
deleted file mode 100644
index fc3b646759..0000000000
--- a/test/csv/parse/test_quote_char_nil.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseQuoteCharNil < Test::Unit::TestCase
- extend DifferentOFS
-
- def test_full
- assert_equal(["a", "b"], CSV.parse_line(%Q{a,b}, quote_char: nil))
- end
-
- def test_end_with_nil
- assert_equal(["a", nil, nil, nil], CSV.parse_line(%Q{a,,,}, quote_char: nil))
- end
-
- def test_nil_nil
- assert_equal([nil, nil], CSV.parse_line(%Q{,}, quote_char: nil))
- end
-
- def test_unquoted_value_multiple_characters_col_sep
- data = %q{a<b<=>x}
- assert_equal([[%Q{a<b}, "x"]], CSV.parse(data, col_sep: "<=>", quote_char: nil))
- end
-
- def test_csv_header_string
- data = <<~DATA
- first,second,third
- A,B,C
- 1,2,3
- DATA
- assert_equal(
- CSV::Table.new([
- CSV::Row.new(["my", "new", "headers"], ["first", "second", "third"]),
- CSV::Row.new(["my", "new", "headers"], ["A", "B", "C"]),
- CSV::Row.new(["my", "new", "headers"], ["1", "2", "3"])
- ]),
- CSV.parse(data, headers: "my,new,headers", quote_char: nil)
- )
- end
-
- def test_comma
- assert_equal([["a", "b", nil, "d"]],
- CSV.parse("a,b,,d", col_sep: ",", quote_char: nil))
- end
-
- def test_space
- assert_equal([["a", "b", nil, "d"]],
- CSV.parse("a b d", col_sep: " ", quote_char: nil))
- end
-
- def encode_array(array, encoding)
- array.collect do |element|
- element ? element.encode(encoding) : element
- end
- end
-
- def test_space_no_ascii
- encoding = Encoding::UTF_16LE
- assert_equal([encode_array(["a", "b", nil, "d"], encoding)],
- CSV.parse("a b d".encode(encoding),
- col_sep: " ".encode(encoding),
- quote_char: nil))
- end
-
- def test_multiple_space
- assert_equal([["a b", nil, "d"]],
- CSV.parse("a b d", col_sep: " ", quote_char: nil))
- end
-
- def test_multiple_characters_leading_empty_fields
- data = <<-CSV
-<=><=>A<=>B<=>C
-1<=>2<=>3
- CSV
- assert_equal([
- [nil, nil, "A", "B", "C"],
- ["1", "2", "3"],
- ],
- CSV.parse(data, col_sep: "<=>", quote_char: nil))
- end
-
- def test_line
- lines = [
- "abc,def\n",
- ]
- csv = CSV.new(lines.join(""), quote_char: nil)
- lines.each do |line|
- csv.shift
- assert_equal(line, csv.line)
- end
- end
-end
diff --git a/test/csv/parse/test_rewind.rb b/test/csv/parse/test_rewind.rb
deleted file mode 100644
index 0aa403b756..0000000000
--- a/test/csv/parse/test_rewind.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseRewind < Test::Unit::TestCase
- extend DifferentOFS
-
- def parse(data, **options)
- csv = CSV.new(data, **options)
- records = csv.to_a
- csv.rewind
- [records, csv.to_a]
- end
-
- def test_default
- data = <<-CSV
-Ruby,2.6.0,script
- CSV
- assert_equal([
- [["Ruby", "2.6.0", "script"]],
- [["Ruby", "2.6.0", "script"]],
- ],
- parse(data))
- end
-
- def test_have_headers
- data = <<-CSV
-Language,Version,Type
-Ruby,2.6.0,script
- CSV
- assert_equal([
- [CSV::Row.new(["Language", "Version", "Type"],
- ["Ruby", "2.6.0", "script"])],
- [CSV::Row.new(["Language", "Version", "Type"],
- ["Ruby", "2.6.0", "script"])],
- ],
- parse(data, headers: true))
- end
-end
diff --git a/test/csv/parse/test_row_separator.rb b/test/csv/parse/test_row_separator.rb
deleted file mode 100644
index eaf6adc910..0000000000
--- a/test/csv/parse/test_row_separator.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseRowSeparator < Test::Unit::TestCase
- extend DifferentOFS
- include Helper
-
- def test_multiple_characters
- with_chunk_size("1") do
- assert_equal([["a"], ["b"]],
- CSV.parse("a\r\nb\r\n", row_sep: "\r\n"))
- end
- end
-end
diff --git a/test/csv/parse/test_skip_lines.rb b/test/csv/parse/test_skip_lines.rb
deleted file mode 100644
index 196858f1b0..0000000000
--- a/test/csv/parse/test_skip_lines.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseSkipLines < Test::Unit::TestCase
- extend DifferentOFS
- include Helper
-
- def test_default
- csv = CSV.new("a,b,c\n")
- assert_nil(csv.skip_lines)
- end
-
- def test_regexp
- csv = <<-CSV
-1
-#2
- #3
-4
- CSV
- assert_equal([
- ["1"],
- ["4"],
- ],
- CSV.parse(csv, :skip_lines => /\A\s*#/))
- end
-
- def test_regexp_quoted
- csv = <<-CSV
-1
-#2
-"#3"
-4
- CSV
- assert_equal([
- ["1"],
- ["#3"],
- ["4"],
- ],
- CSV.parse(csv, :skip_lines => /\A\s*#/))
- end
-
- def test_string
- csv = <<-CSV
-1
-.2
-3.
-4
- CSV
- assert_equal([
- ["1"],
- ["4"],
- ],
- CSV.parse(csv, :skip_lines => "."))
- end
-
- class RegexStub
- end
-
- def test_not_matchable
- regex_stub = RegexStub.new
- csv = CSV.new("1\n", :skip_lines => regex_stub)
- error = assert_raise(ArgumentError) do
- csv.shift
- end
- assert_equal(":skip_lines has to respond to #match: #{regex_stub.inspect}",
- error.message)
- end
-
- class Matchable
- def initialize(pattern)
- @pattern = pattern
- end
-
- def match(line)
- @pattern.match(line)
- end
- end
-
- def test_matchable
- csv = <<-CSV
-1
-# 2
-3
-# 4
- CSV
- assert_equal([
- ["1"],
- ["3"],
- ],
- CSV.parse(csv, :skip_lines => Matchable.new(/\A#/)))
- end
-
- def test_multibyte_data
- # U+3042 HIRAGANA LETTER A
- # U+3044 HIRAGANA LETTER I
- # U+3046 HIRAGANA LETTER U
- value = "\u3042\u3044\u3046"
- with_chunk_size("5") do
- assert_equal([[value], [value]],
- CSV.parse("#{value}\n#{value}\n",
- :skip_lines => /\A#/))
- end
- end
-end
diff --git a/test/csv/parse/test_strip.rb b/test/csv/parse/test_strip.rb
deleted file mode 100644
index 0255bb9a30..0000000000
--- a/test/csv/parse/test_strip.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseStrip < Test::Unit::TestCase
- extend DifferentOFS
-
- def test_both
- assert_equal(["a", "b"],
- CSV.parse_line(%Q{ a , b }, strip: true))
- end
-
- def test_left
- assert_equal(["a", "b"],
- CSV.parse_line(%Q{ a, b}, strip: true))
- end
-
- def test_right
- assert_equal(["a", "b"],
- CSV.parse_line(%Q{a ,b }, strip: true))
- end
-
- def test_quoted
- assert_equal([" a ", " b "],
- CSV.parse_line(%Q{" a "," b "}, strip: true))
- end
-
- def test_liberal_parsing
- assert_equal([" a ", "b", " c ", " d "],
- CSV.parse_line(%Q{" a ", b , " c "," d " },
- strip: true,
- liberal_parsing: true))
- end
-
- def test_string
- assert_equal(["a", " b"],
- CSV.parse_line(%Q{ a , " b" },
- strip: " "))
- end
-
- def test_no_quote
- assert_equal([" a ", " b "],
- CSV.parse_line(%Q{" a ", b },
- strip: %Q{"},
- quote_char: nil))
- end
-
- def test_do_not_strip_cr
- assert_equal([
- ["a", "b "],
- ["a", "b "],
- ],
- CSV.parse(%Q{"a" ,"b " \r} +
- %Q{"a" ,"b " \r},
- strip: true))
- end
-
- def test_do_not_strip_lf
- assert_equal([
- ["a", "b "],
- ["a", "b "],
- ],
- CSV.parse(%Q{"a" ,"b " \n} +
- %Q{"a" ,"b " \n},
- strip: true))
- end
-
- def test_do_not_strip_crlf
- assert_equal([
- ["a", "b "],
- ["a", "b "],
- ],
- CSV.parse(%Q{"a" ,"b " \r\n} +
- %Q{"a" ,"b " \r\n},
- strip: true))
- end
-end
diff --git a/test/csv/parse/test_unconverted_fields.rb b/test/csv/parse/test_unconverted_fields.rb
deleted file mode 100644
index 437124ebd3..0000000000
--- a/test/csv/parse/test_unconverted_fields.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-class TestCSVParseUnconvertedFields < Test::Unit::TestCase
- extend DifferentOFS
-
- def setup
- super
- @custom = lambda {|field| /\A:(\S.*?)\s*\Z/ =~ field ? $1.to_sym : field}
-
- @headers = ["first", "second", "third"]
- @data = <<-CSV
-first,second,third
-1,2,3
- CSV
- end
-
-
- def test_custom
- row = CSV.parse_line("Numbers,:integer,1,:float,3.015",
- converters: [:numeric, @custom],
- unconverted_fields: true)
- assert_equal([
- ["Numbers", :integer, 1, :float, 3.015],
- ["Numbers", ":integer", "1", ":float", "3.015"],
- ],
- [
- row,
- row.unconverted_fields,
- ])
- end
-
- def test_no_fields
- row = CSV.parse_line("\n",
- converters: [:numeric, @custom],
- unconverted_fields: true)
- assert_equal([
- [],
- [],
- ],
- [
- row,
- row.unconverted_fields,
- ])
- end
-
- def test_parsed_header
- row = CSV.parse_line(@data,
- converters: :numeric,
- unconverted_fields: true,
- headers: :first_row)
- assert_equal([
- CSV::Row.new(@headers,
- [1, 2, 3]),
- ["1", "2", "3"],
- ],
- [
- row,
- row.unconverted_fields,
- ])
- end
-
- def test_return_headers
- row = CSV.parse_line(@data,
- converters: :numeric,
- unconverted_fields: true,
- headers: :first_row,
- return_headers: true)
- assert_equal([
- CSV::Row.new(@headers,
- @headers),
- @headers,
- ],
- [
- row,
- row.unconverted_fields,
- ])
- end
-
- def test_header_converters
- row = CSV.parse_line(@data,
- converters: :numeric,
- unconverted_fields: true,
- headers: :first_row,
- return_headers: true,
- header_converters: :symbol)
- assert_equal([
- CSV::Row.new(@headers.collect(&:to_sym),
- @headers),
- @headers,
- ],
- [
- row,
- row.unconverted_fields,
- ])
- end
-
- def test_specified_headers
- row = CSV.parse_line("\n",
- converters: :numeric,
- unconverted_fields: true,
- headers: %w{my new headers},
- return_headers: true,
- header_converters: :symbol)
- assert_equal([
- CSV::Row.new([:my, :new, :headers],
- ["my", "new", "headers"]),
- [],
- ],
- [
- row,
- row.unconverted_fields,
- ])
- end
-end
diff --git a/test/csv/test_csv_parsing.rb b/test/csv/test_csv_parsing.rb
new file mode 100755
index 0000000000..547e70e933
--- /dev/null
+++ b/test/csv/test_csv_parsing.rb
@@ -0,0 +1,244 @@
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
+# frozen_string_literal: false
+
+# tc_csv_parsing.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
+
+require "timeout"
+
+require_relative "base"
+
+#
+# Following tests are my interpretation of the
+# {CSV RCF}[http://www.ietf.org/rfc/rfc4180.txt]. I only deviate from that
+# document in one place (intentionally) and that is to make the default row
+# separator <tt>$/</tt>.
+#
+class TestCSV::Parsing < TestCSV
+ extend DifferentOFS
+
+ BIG_DATA = "123456789\n" * 1024
+
+ def test_mastering_regex_example
+ ex = %Q{Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K}
+ assert_equal( [ "Ten Thousand", "10000", " 2710 ", nil, "10,000",
+ "It's \"10 Grand\", baby", "10K" ],
+ CSV.parse_line(ex) )
+ end
+
+ # Old Ruby 1.8 CSV library tests.
+ def test_std_lib_csv
+ [ ["\t", ["\t"]],
+ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
+ ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
+ ["\"\"\"\n\",\"\"\"\n\"", ["\"\n", "\"\n"]],
+ ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
+ ["\"\"", [""]],
+ ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
+ ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
+ ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
+ ["foo,\"\",baz", ["foo", "", "baz"]],
+ ["\",\"", [","]],
+ ["foo", ["foo"]],
+ [",,", [nil, nil, nil]],
+ [",", [nil, nil]],
+ ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
+ ["foo,,baz", ["foo", nil, "baz"]],
+ ["\"\"\"\r\",\"\"\"\r\"", ["\"\r", "\"\r"]],
+ ["\",\",\",\"", [",", ","]],
+ ["foo,bar,", ["foo", "bar", nil]],
+ [",foo,bar", [nil, "foo", "bar"]],
+ ["foo,bar", ["foo", "bar"]],
+ [";", [";"]],
+ ["\t,\t", ["\t", "\t"]],
+ ["foo,\"\r\n\r\",baz", ["foo", "\r\n\r", "baz"]],
+ ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
+ ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
+ [";,;", [";", ";"]] ].each do |csv_test|
+ assert_equal(csv_test.last, CSV.parse_line(csv_test.first))
+ end
+
+ [ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
+ ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
+ ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
+ ["\"\"", [""]],
+ ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
+ ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
+ ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
+ ["foo,\"\",baz", ["foo", "", "baz"]],
+ ["foo", ["foo"]],
+ [",,", [nil, nil, nil]],
+ [",", [nil, nil]],
+ ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
+ ["foo,,baz", ["foo", nil, "baz"]],
+ ["foo,bar", ["foo", "bar"]],
+ ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
+ ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]] ].each do |csv_test|
+ assert_equal(csv_test.last, CSV.parse_line(csv_test.first))
+ end
+ end
+
+ # From: http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/6496
+ def test_aras_edge_cases
+ [ [%Q{a,b}, ["a", "b"]],
+ [%Q{a,"""b"""}, ["a", "\"b\""]],
+ [%Q{a,"""b"}, ["a", "\"b"]],
+ [%Q{a,"b"""}, ["a", "b\""]],
+ [%Q{a,"\nb"""}, ["a", "\nb\""]],
+ [%Q{a,"""\nb"}, ["a", "\"\nb"]],
+ [%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
+ [%Q{a,"""\nb\n""",\nc}, ["a", "\"\nb\n\"", nil]],
+ [%Q{a,,,}, ["a", nil, nil, nil]],
+ [%Q{,}, [nil, nil]],
+ [%Q{"",""}, ["", ""]],
+ [%Q{""""}, ["\""]],
+ [%Q{"""",""}, ["\"",""]],
+ [%Q{,""}, [nil,""]],
+ [%Q{,"\r"}, [nil,"\r"]],
+ [%Q{"\r\n,"}, ["\r\n,"]],
+ [%Q{"\r\n,",}, ["\r\n,", nil]] ].each do |edge_case|
+ assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
+ end
+ end
+
+ def test_james_edge_cases
+ # A read at eof? should return nil.
+ assert_equal(nil, CSV.parse_line(""))
+ #
+ # With Ruby 1.8 CSV it's impossible to tell an empty line from a line
+ # containing a single +nil+ field. The old CSV library returns
+ # <tt>[nil]</tt> in these cases, but <tt>Array.new</tt> makes more sense to
+ # me.
+ #
+ assert_equal(Array.new, CSV.parse_line("\n1,2,3\n"))
+ end
+
+ def test_rob_edge_cases
+ [ [%Q{"a\nb"}, ["a\nb"]],
+ [%Q{"\n\n\n"}, ["\n\n\n"]],
+ [%Q{a,"b\n\nc"}, ['a', "b\n\nc"]],
+ [%Q{,"\r\n"}, [nil,"\r\n"]],
+ [%Q{,"\r\n."}, [nil,"\r\n."]],
+ [%Q{"a\na","one newline"}, ["a\na", 'one newline']],
+ [%Q{"a\n\na","two newlines"}, ["a\n\na", 'two newlines']],
+ [%Q{"a\r\na","one CRLF"}, ["a\r\na", 'one CRLF']],
+ [%Q{"a\r\n\r\na","two CRLFs"}, ["a\r\n\r\na", 'two CRLFs']],
+ [%Q{with blank,"start\n\nfinish"\n}, ['with blank', "start\n\nfinish"]],
+ ].each do |edge_case|
+ assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
+ end
+ end
+
+ def test_non_regex_edge_cases
+ # An early version of the non-regex parser fails this test
+ [ [ "foo,\"foo,bar,baz,foo\",\"foo\"",
+ ["foo", "foo,bar,baz,foo", "foo"] ] ].each do |edge_case|
+ assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
+ end
+
+ assert_raise(CSV::MalformedCSVError) do
+ CSV.parse_line("1,\"23\"4\"5\", 6")
+ end
+ end
+
+ def test_malformed_csv
+ assert_raise(CSV::MalformedCSVError) do
+ CSV.parse_line("1,2\r,3", row_sep: "\n")
+ end
+
+ bad_data = <<-END_DATA.gsub(/^ +/, "")
+ line,1,abc
+ line,2,"def\nghi"
+
+ line,4,some\rjunk
+ line,5,jkl
+ END_DATA
+ lines = bad_data.lines.to_a
+ assert_equal(6, lines.size)
+ assert_match(/\Aline,4/, lines.find { |l| l =~ /some\rjunk/ })
+
+ csv = CSV.new(bad_data)
+ begin
+ loop do
+ assert_not_nil(csv.shift)
+ assert_send([csv.lineno, :<, 4])
+ end
+ rescue CSV::MalformedCSVError
+ assert_equal( "Unquoted fields do not allow \\r or \\n (line 4).",
+ $!.message )
+ end
+
+ assert_raise(CSV::MalformedCSVError) { CSV.parse_line('1,2,"3...') }
+
+ bad_data = <<-END_DATA.gsub(/^ +/, "")
+ line,1,abc
+ line,2,"def\nghi"
+
+ line,4,8'10"
+ line,5,jkl
+ END_DATA
+ lines = bad_data.lines.to_a
+ assert_equal(6, lines.size)
+ assert_match(/\Aline,4/, lines.find { |l| l =~ /8'10"/ })
+
+ csv = CSV.new(bad_data)
+ begin
+ loop do
+ assert_not_nil(csv.shift)
+ assert_send([csv.lineno, :<, 4])
+ end
+ rescue CSV::MalformedCSVError
+ assert_equal("Illegal quoting in line 4.", $!.message)
+ end
+ end
+
+ def test_the_parse_fails_fast_when_it_can_for_unquoted_fields
+ assert_parse_errors_out('valid,fields,bad start"' + BIG_DATA)
+ end
+
+ def test_the_parse_fails_fast_when_it_can_for_unescaped_quotes
+ assert_parse_errors_out('valid,fields,"bad start"unescaped' + BIG_DATA)
+ end
+
+ def test_field_size_limit_controls_lookahead
+ assert_parse_errors_out( 'valid,fields,"' + BIG_DATA + '"',
+ field_size_limit: 2048 )
+ end
+
+ def test_field_size_limit_in_extended_column_not_exceeding
+ data = <<~DATA
+ "a","b"
+ "
+ 2
+ ",""
+ DATA
+ assert_nothing_raised(CSV::MalformedCSVError) do
+ CSV.parse(data, field_size_limit: 4)
+ end
+ end
+
+ def test_field_size_limit_in_extended_column_exceeding
+ data = <<~DATA
+ "a","b"
+ "
+ 2345
+ ",""
+ DATA
+ assert_parse_errors_out(data, field_size_limit: 5)
+ end
+
+ private
+
+ def assert_parse_errors_out(*args)
+ assert_raise(CSV::MalformedCSVError) do
+ Timeout.timeout(0.2) do
+ CSV.parse(*args)
+ fail("Parse didn't error out")
+ end
+ end
+ end
+end
diff --git a/test/csv/test_csv_writing.rb b/test/csv/test_csv_writing.rb
new file mode 100755
index 0000000000..de82dae244
--- /dev/null
+++ b/test/csv/test_csv_writing.rb
@@ -0,0 +1,98 @@
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
+# frozen_string_literal: false
+
+# tc_csv_writing.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
+
+require_relative "base"
+
+class TestCSV::Writing < TestCSV
+ extend DifferentOFS
+
+ def test_writing
+ [ ["\t", ["\t"]],
+ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
+ ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
+ ["\"\"\"\n\",\"\"\"\n\"", ["\"\n", "\"\n"]],
+ ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
+ ["\"\"", [""]],
+ ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
+ ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
+ ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
+ ["foo,\"\",baz", ["foo", "", "baz"]],
+ ["\",\"", [","]],
+ ["foo", ["foo"]],
+ [",,", [nil, nil, nil]],
+ [",", [nil, nil]],
+ ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
+ ["foo,,baz", ["foo", nil, "baz"]],
+ ["\"\"\"\r\",\"\"\"\r\"", ["\"\r", "\"\r"]],
+ ["\",\",\",\"", [",", ","]],
+ ["foo,bar,", ["foo", "bar", nil]],
+ [",foo,bar", [nil, "foo", "bar"]],
+ ["foo,bar", ["foo", "bar"]],
+ [";", [";"]],
+ ["\t,\t", ["\t", "\t"]],
+ ["foo,\"\r\n\r\",baz", ["foo", "\r\n\r", "baz"]],
+ ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
+ ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
+ [";,;", [";", ";"]],
+ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
+ ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
+ ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
+ ["\"\"", [""]],
+ ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
+ ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
+ ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
+ ["foo,\"\",baz", ["foo", "", "baz"]],
+ ["foo", ["foo"]],
+ [",,", [nil, nil, nil]],
+ [",", [nil, nil]],
+ ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
+ ["foo,,baz", ["foo", nil, "baz"]],
+ ["foo,bar", ["foo", "bar"]],
+ ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
+ ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
+ [%Q{a,b}, ["a", "b"]],
+ [%Q{a,"""b"""}, ["a", "\"b\""]],
+ [%Q{a,"""b"}, ["a", "\"b"]],
+ [%Q{a,"b"""}, ["a", "b\""]],
+ [%Q{a,"\nb"""}, ["a", "\nb\""]],
+ [%Q{a,"""\nb"}, ["a", "\"\nb"]],
+ [%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
+ [%Q{a,"""\nb\n""",}, ["a", "\"\nb\n\"", nil]],
+ [%Q{a,,,}, ["a", nil, nil, nil]],
+ [%Q{,}, [nil, nil]],
+ [%Q{"",""}, ["", ""]],
+ [%Q{""""}, ["\""]],
+ [%Q{"""",""}, ["\"",""]],
+ [%Q{,""}, [nil,""]],
+ [%Q{,"\r"}, [nil,"\r"]],
+ [%Q{"\r\n,"}, ["\r\n,"]],
+ [%Q{"\r\n,",}, ["\r\n,", nil]] ].each do |test_case|
+ assert_equal(test_case.first + $/, CSV.generate_line(test_case.last))
+ end
+ end
+
+ def test_col_sep
+ assert_equal( "a;b;;c\n", CSV.generate_line( ["a", "b", nil, "c"],
+ col_sep: ";" ) )
+ assert_equal( "a\tb\t\tc\n", CSV.generate_line( ["a", "b", nil, "c"],
+ col_sep: "\t" ) )
+ end
+
+ def test_row_sep
+ assert_equal( "a,b,,c\r\n", CSV.generate_line( ["a", "b", nil, "c"],
+ row_sep: "\r\n" ) )
+ end
+
+ def test_force_quotes
+ assert_equal( %Q{"1","b","","already ""quoted"""\n},
+ CSV.generate_line( [1, "b", nil, %Q{already "quoted"}],
+ force_quotes: true ) )
+ end
+end
diff --git a/test/csv/test_data_converters.rb b/test/csv/test_data_converters.rb
index 1620e077be..0786ca6d0f 100644..100755
--- a/test/csv/test_data_converters.rb
+++ b/test/csv/test_data_converters.rb
@@ -1,13 +1,25 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
# frozen_string_literal: false
-require_relative "helper"
+# tc_data_converters.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
-class TestCSVDataConverters < Test::Unit::TestCase
+require_relative "base"
+
+class TestCSV::DataConverters < TestCSV
extend DifferentOFS
def setup
super
+ @data = "Numbers,:integer,1,:float,3.015"
+ @parser = CSV.new(@data)
+
+ @custom = lambda { |field| field =~ /\A:(\S.*?)\s*\Z/ ? $1.to_sym : field }
+
@win_safe_time_str = Time.now.strftime("%a %b %d %H:%M:%S %Y")
end
@@ -55,52 +67,207 @@ class TestCSVDataConverters < Test::Unit::TestCase
assert_instance_of(String, CSV::Converters[:date_time]["junk"])
end
- def test_builtin_date_time_converter_iso8601_date
- iso8601_string = "2018-01-14"
- datetime = DateTime.new(2018, 1, 14)
- assert_equal(datetime,
- CSV::Converters[:date_time][iso8601_string])
+ def test_convert_with_builtin_integer
+ # setup parser...
+ assert_respond_to(@parser, :convert)
+ assert_nothing_raised(Exception) { @parser.convert(:integer) }
+
+ # and use
+ assert_equal(["Numbers", ":integer", 1, ":float", "3.015"], @parser.shift)
+ end
+
+ def test_convert_with_builtin_float
+ # setup parser...
+ assert_respond_to(@parser, :convert)
+ assert_nothing_raised(Exception) { @parser.convert(:float) }
+
+ # and use
+ assert_equal(["Numbers", ":integer", 1.0, ":float", 3.015], @parser.shift)
+ end
+
+ def test_convert_order_float_integer
+ # floats first, then integers...
+ assert_nothing_raised(Exception) do
+ @parser.convert(:float)
+ @parser.convert(:integer)
+ end
+
+ # gets us nothing but floats
+ assert_equal( [String, String, Float, String, Float],
+ @parser.shift.map { |field| field.class } )
+ end
+
+ def test_convert_order_integer_float
+ # integers have precendance...
+ assert_nothing_raised(Exception) do
+ @parser.convert(:integer)
+ @parser.convert(:float)
+ end
+
+ # gives us proper number conversion
+ assert_equal( [String, String, Integer, String, Float],
+ @parser.shift.map { |field| field.class } )
end
- def test_builtin_date_time_converter_iso8601_minute
- iso8601_string = "2018-01-14T22:25"
- datetime = DateTime.new(2018, 1, 14, 22, 25)
- assert_equal(datetime,
- CSV::Converters[:date_time][iso8601_string])
+ def test_builtin_numeric_combo_converter
+ # setup parser...
+ assert_nothing_raised(Exception) { @parser.convert(:numeric) }
+
+ # and use
+ assert_equal( [String, String, Integer, String, Float],
+ @parser.shift.map { |field| field.class } )
end
- def test_builtin_date_time_converter_iso8601_second
- iso8601_string = "2018-01-14T22:25:19"
- datetime = DateTime.new(2018, 1, 14, 22, 25, 19)
- assert_equal(datetime,
- CSV::Converters[:date_time][iso8601_string])
+ def test_builtin_all_nested_combo_converter
+ # setup parser...
+ @data << ",#{@win_safe_time_str}" # add a DateTime field
+ @parser = CSV.new(@data) # reset parser
+ assert_nothing_raised(Exception) { @parser.convert(:all) }
+
+ # and use
+ assert_equal( [String, String, Integer, String, Float, DateTime],
+ @parser.shift.map { |field| field.class } )
end
- def test_builtin_date_time_converter_iso8601_under_second
- iso8601_string = "2018-01-14T22:25:19.1"
- datetime = DateTime.new(2018, 1, 14, 22, 25, 19.1)
- assert_equal(datetime,
- CSV::Converters[:date_time][iso8601_string])
+ def test_convert_with_custom_code
+ # define custom converter...
+ assert_nothing_raised(Exception) do
+ @parser.convert { |field| field =~ /\A:(\S.*?)\s*\Z/ ? $1.to_sym : field }
+ end
+
+ # and use
+ assert_equal(["Numbers", :integer, "1", :float, "3.015"], @parser.shift)
end
- def test_builtin_date_time_converter_iso8601_under_second_offset
- iso8601_string = "2018-01-14T22:25:19.1+09:00"
- datetime = DateTime.new(2018, 1, 14, 22, 25, 19.1, "+9")
- assert_equal(datetime,
- CSV::Converters[:date_time][iso8601_string])
+ def test_convert_with_custom_code_mix
+ # mix built-in and custom...
+ assert_nothing_raised(Exception) { @parser.convert(:numeric) }
+ assert_nothing_raised(Exception) { @parser.convert(&@custom) }
+
+ # and use
+ assert_equal(["Numbers", :integer, 1, :float, 3.015], @parser.shift)
end
- def test_builtin_date_time_converter_iso8601_offset
- iso8601_string = "2018-01-14T22:25:19+09:00"
- datetime = DateTime.new(2018, 1, 14, 22, 25, 19, "+9")
- assert_equal(datetime,
- CSV::Converters[:date_time][iso8601_string])
+ def test_convert_with_custom_code_using_field_info
+ # define custom converter that uses field information...
+ assert_nothing_raised(Exception) do
+ @parser.convert do |field, info|
+ assert_equal(1, info.line)
+ info.index == 4 ? Float(field).floor : field
+ end
+ end
+
+ # and use
+ assert_equal(["Numbers", ":integer", "1", ":float", 3], @parser.shift)
end
- def test_builtin_date_time_converter_iso8601_utc
- iso8601_string = "2018-01-14T22:25:19Z"
- datetime = DateTime.new(2018, 1, 14, 22, 25, 19)
- assert_equal(datetime,
- CSV::Converters[:date_time][iso8601_string])
+ def test_convert_with_custom_code_using_field_info_header
+ @parser = CSV.new(@data, headers: %w{one two three four five})
+
+ # define custom converter that uses field header information...
+ assert_nothing_raised(Exception) do
+ @parser.convert do |field, info|
+ info.header == "three" ? Integer(field) * 100 : field
+ end
+ end
+
+ # and use
+ assert_equal( ["Numbers", ":integer", 100, ":float", "3.015"],
+ @parser.shift.fields )
+ end
+
+ def test_custom_converter_with_blank_field
+ converter = lambda { |field| field.nil? }
+ row = nil
+ assert_nothing_raised(Exception) do
+ row = CSV.parse_line('nil,', converters: converter)
+ end
+ assert_equal([false, true], row);
+ end
+
+ def test_shortcut_interface
+ assert_equal( ["Numbers", ":integer", 1, ":float", 3.015],
+ CSV.parse_line(@data, converters: :numeric) )
+
+ assert_equal( ["Numbers", ":integer", 1, ":float", 3.015],
+ CSV.parse_line(@data, converters: [:integer, :float]) )
+
+ assert_equal( ["Numbers", :integer, 1, :float, 3.015],
+ CSV.parse_line(@data, converters: [:numeric, @custom]) )
+ end
+
+ def test_unconverted_fields
+ [ [ @data,
+ ["Numbers", :integer, 1, :float, 3.015],
+ %w{Numbers :integer 1 :float 3.015} ],
+ ["\n", Array.new, Array.new] ].each do |test, fields, unconverted|
+ row = nil
+ assert_nothing_raised(Exception) do
+ row = CSV.parse_line( test,
+ converters: [:numeric, @custom],
+ unconverted_fields: true )
+ end
+ assert_not_nil(row)
+ assert_equal(fields, row)
+ assert_respond_to(row, :unconverted_fields)
+ assert_equal(unconverted, row.unconverted_fields)
+ end
+
+ data = <<-END_CSV.gsub(/^\s+/, "")
+ first,second,third
+ 1,2,3
+ END_CSV
+ row = nil
+ assert_nothing_raised(Exception) do
+ row = CSV.parse_line( data,
+ converters: :numeric,
+ unconverted_fields: true,
+ headers: :first_row )
+ end
+ assert_not_nil(row)
+ assert_equal([["first", 1], ["second", 2], ["third", 3]], row.to_a)
+ assert_respond_to(row, :unconverted_fields)
+ assert_equal(%w{1 2 3}, row.unconverted_fields)
+
+ assert_nothing_raised(Exception) do
+ row = CSV.parse_line( data,
+ converters: :numeric,
+ unconverted_fields: true,
+ headers: :first_row,
+ return_headers: true )
+ end
+ assert_not_nil(row)
+ assert_equal( [%w{first first}, %w{second second}, %w{third third}],
+ row.to_a )
+ assert_respond_to(row, :unconverted_fields)
+ assert_equal(%w{first second third}, row.unconverted_fields)
+
+ assert_nothing_raised(Exception) do
+ row = CSV.parse_line( data,
+ converters: :numeric,
+ unconverted_fields: true,
+ headers: :first_row,
+ return_headers: true,
+ header_converters: :symbol )
+ end
+ assert_not_nil(row)
+ assert_equal( [[:first, "first"], [:second, "second"], [:third, "third"]],
+ row.to_a )
+ assert_respond_to(row, :unconverted_fields)
+ assert_equal(%w{first second third}, row.unconverted_fields)
+
+ assert_nothing_raised(Exception) do
+ row = CSV.parse_line( data,
+ converters: :numeric,
+ unconverted_fields: true,
+ headers: %w{my new headers},
+ return_headers: true,
+ header_converters: :symbol )
+ end
+ assert_not_nil(row)
+ assert_equal( [[:my, "my"], [:new, "new"], [:headers, "headers"]],
+ row.to_a )
+ assert_respond_to(row, :unconverted_fields)
+ assert_equal(Array.new, row.unconverted_fields)
end
end
diff --git a/test/csv/test_encodings.rb b/test/csv/test_encodings.rb
index acee03db45..7460a3ff34 100644..100755
--- a/test/csv/test_encodings.rb
+++ b/test/csv/test_encodings.rb
@@ -1,9 +1,16 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
# frozen_string_literal: false
-require_relative "helper"
+# tc_encodings.rb
+#
+# Created by James Edward Gray II on 2008-09-13.
+# Copyright 2008 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
-class TestCSVEncodings < Test::Unit::TestCase
+require_relative "base"
+
+class TestCSV::Encodings < TestCSV
extend DifferentOFS
def setup
@@ -249,45 +256,26 @@ class TestCSVEncodings < Test::Unit::TestCase
assert_equal(["foo,\u3042\n".encode(Encoding::Windows_31J), Encoding::Windows_31J], [s, s.encoding], bug9766)
end
- def test_row_separator_detection_with_invalid_encoding
- csv = CSV.new("invalid,\xF8\r\nvalid,x\r\n".force_encoding("UTF-8"),
- encoding: "UTF-8")
- assert_equal("\r\n", csv.row_sep)
- end
-
- def test_invalid_encoding_row_error
- csv = CSV.new("valid,x\rinvalid,\xF8\r".force_encoding("UTF-8"),
- encoding: "UTF-8", row_sep: "\r")
- error = assert_raise(CSV::MalformedCSVError) do
- csv.shift
- csv.shift
- end
- assert_equal("Invalid byte sequence in UTF-8 in line 2.",
- error.message)
- end
-
private
- def assert_parses(fields, encoding, **options)
+ def assert_parses(fields, encoding, options = { })
encoding = Encoding.find(encoding) unless encoding.is_a? Encoding
orig_fields = fields
- fields = encode_ary(fields, encoding)
- data = ary_to_data(fields, **options)
- parsed = CSV.parse(data, **options)
+ fields = encode_ary(fields, encoding)
+ data = ary_to_data(fields, options)
+ parsed = CSV.parse(data, options)
assert_equal(fields, parsed)
parsed.flatten.each_with_index do |field, i|
assert_equal(encoding, field.encoding, "Field[#{i + 1}] was transcoded.")
end
File.open(@temp_csv_path, "wb") {|f| f.print(data)}
- CSV.open(@temp_csv_path, "rb:#{encoding}", **options) do |csv|
+ CSV.open(@temp_csv_path, "rb:#{encoding}", options) do |csv|
csv.each_with_index do |row, i|
assert_equal(fields[i], row)
end
end
begin
- CSV.open(@temp_csv_path,
- "rb:#{encoding}:#{__ENCODING__}",
- **options) do |csv|
+ CSV.open(@temp_csv_path, "rb:#{encoding}:#{__ENCODING__}", options) do |csv|
csv.each_with_index do |row, i|
assert_equal(orig_fields[i], row)
end
@@ -295,7 +283,7 @@ class TestCSVEncodings < Test::Unit::TestCase
rescue Encoding::ConverterNotFoundError
end
options[:encoding] = encoding.name
- CSV.open(@temp_csv_path, **options) do |csv|
+ CSV.open(@temp_csv_path, options) do |csv|
csv.each_with_index do |row, i|
assert_equal(fields[i], row)
end
@@ -304,7 +292,7 @@ class TestCSVEncodings < Test::Unit::TestCase
options[:external_encoding] = encoding.name
options[:internal_encoding] = __ENCODING__.name
begin
- CSV.open(@temp_csv_path, **options) do |csv|
+ CSV.open(@temp_csv_path, options) do |csv|
csv.each_with_index do |row, i|
assert_equal(orig_fields[i], row)
end
@@ -317,7 +305,7 @@ class TestCSVEncodings < Test::Unit::TestCase
ary.map { |row| row.map { |field| field.encode(encoding) } }
end
- def ary_to_data(ary, **options)
+ def ary_to_data(ary, options = { })
encoding = ary.flatten.first.encoding
quote_char = (options[:quote_char] || '"').encode(encoding)
col_sep = (options[:col_sep] || ",").encode(encoding)
@@ -329,9 +317,9 @@ class TestCSVEncodings < Test::Unit::TestCase
}.join('').encode(encoding)
end
- def encode_for_tests(data, **options)
- yield ary_to_data(encode_ary(data, "UTF-8"), **options)
- yield ary_to_data(encode_ary(data, "UTF-16BE"), **options)
+ def encode_for_tests(data, options = { })
+ yield ary_to_data(encode_ary(data, "UTF-8"), options)
+ yield ary_to_data(encode_ary(data, "UTF-16BE"), options)
end
def each_encoding
diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb
index d6eb2dc13b..6b73093ad3 100644..100755
--- a/test/csv/test_features.rb
+++ b/test/csv/test_features.rb
@@ -1,15 +1,22 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
# frozen_string_literal: false
+# tc_features.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
+
begin
require "zlib"
rescue LoadError
end
-require_relative "helper"
+require_relative "base"
require "tempfile"
-class TestCSVFeatures < Test::Unit::TestCase
+class TestCSV::Features < TestCSV
extend DifferentOFS
TEST_CASES = [ [%Q{a,b}, ["a", "b"]],
@@ -32,12 +39,12 @@ class TestCSVFeatures < Test::Unit::TestCase
def setup
super
- @sample_data = <<-CSV
-line,1,abc
-line,2,"def\nghi"
+ @sample_data = <<-END_DATA.gsub(/^ +/, "")
+ line,1,abc
+ line,2,"def\nghi"
-line,4,jkl
- CSV
+ line,4,jkl
+ END_DATA
@csv = CSV.new(@sample_data)
end
@@ -52,52 +59,27 @@ line,4,jkl
assert_equal([",,,", nil], CSV.parse_line(",,,;", col_sep: ";"))
end
- def test_col_sep_nil
- assert_raise_with_message(ArgumentError,
- ":col_sep must be 1 or more characters: nil") do
- CSV.parse(@sample_data, col_sep: nil)
- end
- end
-
- def test_col_sep_empty
- assert_raise_with_message(ArgumentError,
- ":col_sep must be 1 or more characters: \"\"") do
- CSV.parse(@sample_data, col_sep: "")
- end
- end
-
def test_row_sep
- error = assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line("1,2,3\n,4,5\r\n", row_sep: "\r\n")
+ assert_raise(CSV::MalformedCSVError) do
+ CSV.parse_line("1,2,3\n,4,5\r\n", row_sep: "\r\n")
end
- assert_equal("Unquoted fields do not allow new line <\"\\n\"> in line 1.",
- error.message)
assert_equal( ["1", "2", "3\n", "4", "5"],
CSV.parse_line(%Q{1,2,"3\n",4,5\r\n}, row_sep: "\r\n"))
end
def test_quote_char
TEST_CASES.each do |test_case|
- assert_equal(test_case.last.map {|t| t.tr('"', "'") unless t.nil?},
- CSV.parse_line(test_case.first.tr('"', "'"),
- quote_char: "'" ))
- end
- end
-
- def test_quote_char_special_regexp_char
- TEST_CASES.each do |test_case|
- assert_equal(test_case.last.map {|t| t.tr('"', "|") unless t.nil?},
- CSV.parse_line(test_case.first.tr('"', "|"),
- quote_char: "|"))
+ assert_equal( test_case.last.map { |t| t.tr('"', "'") unless t.nil? },
+ CSV.parse_line( test_case.first.tr('"', "'"),
+ quote_char: "'" ) )
end
end
- def test_quote_char_special_regexp_char_liberal_parsing
+ def test_bug_8405
TEST_CASES.each do |test_case|
- assert_equal(test_case.last.map {|t| t.tr('"', "|") unless t.nil?},
- CSV.parse_line(test_case.first.tr('"', "|"),
- quote_char: "|",
- liberal_parsing: true))
+ assert_equal( test_case.last.map { |t| t.tr('"', "|") unless t.nil? },
+ CSV.parse_line( test_case.first.tr('"', "|"),
+ quote_char: "|" ) )
end
end
@@ -124,10 +106,10 @@ line,4,jkl
def test_line
lines = [
- %Q(\u{3000}abc,def\n),
- %Q(\u{3000}abc,"d\nef"\n),
- %Q(\u{3000}abc,"d\r\nef"\n),
- %Q(\u{3000}abc,"d\ref")
+ %Q(abc,def\n),
+ %Q(abc,"d\nef"\n),
+ %Q(abc,"d\r\nef"\n),
+ %Q(abc,"d\ref")
]
csv = CSV.new(lines.join(''))
lines.each do |line|
@@ -177,6 +159,29 @@ line,4,jkl
assert_equal(3, count)
end
+ def test_liberal_parsing
+ input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
+ assert_raise(CSV::MalformedCSVError) do
+ CSV.parse_line(input)
+ end
+ assert_equal(["Johnson, Dwayne", 'Dwayne "The Rock" Johnson'],
+ CSV.parse_line(input, liberal_parsing: true))
+
+ input = '"quoted" field'
+ assert_raise(CSV::MalformedCSVError) do
+ CSV.parse_line(input)
+ end
+ assert_equal(['"quoted" field'],
+ CSV.parse_line(input, liberal_parsing: true))
+
+ assert_raise(CSV::MalformedCSVError) do
+ CSV.parse_line('is,this "three," or four,fields', liberal_parsing: true)
+ end
+
+ assert_equal(["is", 'this "three', ' or four"', "fields"],
+ CSV.parse_line('is,this "three, or four",fields', liberal_parsing: true))
+ end
+
def test_csv_behavior_readers
%w[ unconverted_fields return_headers write_headers
skip_blanks force_quotes ].each do |behavior|
@@ -222,19 +227,29 @@ line,4,jkl
end
# reported by Kev Jackson
- def test_failing_to_escape_col_sep
+ def test_failing_to_escape_col_sep_bug_fix
assert_nothing_raised(Exception) { CSV.new(String.new, col_sep: "|") }
end
# reported by Chris Roos
- def test_failing_to_reset_headers_in_rewind
+ def test_failing_to_reset_headers_in_rewind_bug_fix
csv = CSV.new("forename,surname", headers: true, return_headers: true)
csv.each {|row| assert_predicate row, :header_row?}
csv.rewind
csv.each {|row| assert_predicate row, :header_row?}
end
- def test_gzip_reader
+ # reported by Dave Burt
+ def test_leading_empty_fields_with_multibyte_col_sep_bug_fix
+ data = <<-END_DATA.gsub(/^\s+/, "")
+ <=><=>A<=>B<=>C
+ 1<=>2<=>3
+ END_DATA
+ parsed = CSV.parse(data, col_sep: "<=>")
+ assert_equal([[nil, nil, "A", "B", "C"], ["1", "2", "3"]], parsed)
+ end
+
+ def test_gzip_reader_bug_fix
zipped = nil
assert_nothing_raised(NoMethodError) do
zipped = CSV.new(
@@ -248,7 +263,7 @@ line,4,jkl
zipped.close
end if defined?(Zlib::GzipReader)
- def test_gzip_writer
+ def test_gzip_writer_bug_fix
Tempfile.create(%w"temp .gz") {|tempfile|
tempfile.close
file = tempfile.path
@@ -289,71 +304,77 @@ line,4,jkl
end
def test_inspect_shows_headers_when_available
- csv = CSV.new("one,two,three\n1,2,3\n", headers: true)
- assert_include(csv.inspect, "headers:true", "Header hint not shown.")
- csv.shift # load headers
- assert_match(/headers:\[[^\]]+\]/, csv.inspect)
+ CSV.new("one,two,three\n1,2,3\n", headers: true) do |csv|
+ assert_include(csv.inspect, "headers:true", "Header hint not shown.")
+ csv.shift # load headers
+ assert_match(/headers:\[[^\]]+\]/, csv.inspect)
+ end
end
def test_inspect_encoding_is_ascii_compatible
- csv = CSV.new("one,two,three\n1,2,3\n".encode("UTF-16BE"))
- assert_send([Encoding, :compatible?,
- Encoding.find("US-ASCII"), csv.inspect.encoding],
- "inspect() was not ASCII compatible.")
+ CSV.new("one,two,three\n1,2,3\n".encode("UTF-16BE")) do |csv|
+ assert_send([Encoding, :compatible?,
+ Encoding.find("US-ASCII"), csv.inspect.encoding],
+ "inspect() was not ASCII compatible.")
+ end
end
def test_version
assert_not_nil(CSV::VERSION)
assert_instance_of(String, CSV::VERSION)
assert_predicate(CSV::VERSION, :frozen?)
- assert_match(/\A\d\.\d\.\d\z/, CSV::VERSION)
+ assert_match(/\A\d\.\d\.\d\Z/, CSV::VERSION)
end
- def test_table_nil_equality
- assert_nothing_raised(NoMethodError) { CSV.parse("test", headers: true) == nil }
+ def test_accepts_comment_skip_lines_option
+ assert_nothing_raised(ArgumentError) do
+ CSV.new(@sample_data, :skip_lines => /\A\s*#/)
+ end
end
- # non-seekable input stream for testing https://github.com/ruby/csv/issues/44
- class DummyIO
- extend Forwardable
- def_delegators :@io, :gets, :read, :pos, :eof? # no seek or rewind!
- def initialize(data)
- @io = StringIO.new(data)
- end
+ def test_accepts_comment_defaults_to_nil
+ c = CSV.new(@sample_data)
+ assert_nil(c.skip_lines)
+ end
+
+ class RegexStub
end
- def test_line_separator_autodetection_for_non_seekable_input_lf
- c = CSV.new(DummyIO.new("one,two,three\nfoo,bar,baz\n"))
- assert_equal [["one", "two", "three"], ["foo", "bar", "baz"]], c.each.to_a
+ def test_requires_skip_lines_to_call_match
+ regex_stub = RegexStub.new
+ assert_raise_with_message(ArgumentError, /skip_lines/) do
+ CSV.new(@sample_data, :skip_lines => regex_stub)
+ end
end
- def test_line_separator_autodetection_for_non_seekable_input_cr
- c = CSV.new(DummyIO.new("one,two,three\rfoo,bar,baz\r"))
- assert_equal [["one", "two", "three"], ["foo", "bar", "baz"]], c.each.to_a
+ def test_comment_rows_are_ignored
+ sample_data = "line,1,a\n#not,a,line\nline,2,b\n #also,no,line"
+ c = CSV.new sample_data, :skip_lines => /\A\s*#/
+ assert_equal [["line", "1", "a"], ["line", "2", "b"]], c.each.to_a
end
- def test_line_separator_autodetection_for_non_seekable_input_cr_lf
- c = CSV.new(DummyIO.new("one,two,three\r\nfoo,bar,baz\r\n"))
- assert_equal [["one", "two", "three"], ["foo", "bar", "baz"]], c.each.to_a
+ def test_comment_rows_are_ignored_with_heredoc
+ c = CSV.new(<<~EOL, skip_lines: ".")
+ 1,foo
+ .2,bar
+ 3,baz
+ EOL
+ assert_equal [["1", "foo"], ["3", "baz"]], c.each.to_a
end
- def test_line_separator_autodetection_for_non_seekable_input_1024_over_lf
- table = (1..10).map { |row| (1..200).map { |col| "row#{row}col#{col}" }.to_a }.to_a
- input = table.map { |line| line.join(",") }.join("\n")
- c = CSV.new(DummyIO.new(input))
- assert_equal table, c.each.to_a
+ def test_quoted_skip_line_markers_are_ignored
+ sample_data = "line,1,a\n\"#not\",a,line\nline,2,b"
+ c = CSV.new sample_data, :skip_lines => /\A\s*#/
+ assert_equal [["line", "1", "a"], ["#not", "a", "line"], ["line", "2", "b"]], c.each.to_a
end
- def test_line_separator_autodetection_for_non_seekable_input_1024_over_cr_lf
- table = (1..10).map { |row| (1..200).map { |col| "row#{row}col#{col}" }.to_a }.to_a
- input = table.map { |line| line.join(",") }.join("\r\n")
- c = CSV.new(DummyIO.new(input))
- assert_equal table, c.each.to_a
+ def test_string_works_like_a_regexp
+ sample_data = "line,1,a\n#(not,a,line\nline,2,b\n also,#no,line"
+ c = CSV.new sample_data, :skip_lines => "#"
+ assert_equal [["line", "1", "a"], ["line", "2", "b"]], c.each.to_a
end
- def test_line_separator_autodetection_for_non_seekable_input_many_cr_only
- # input with lots of CRs (to make sure no bytes are lost due to look-ahead)
- c = CSV.new(DummyIO.new("foo\r" + "\r" * 9999 + "bar\r"))
- assert_equal [["foo"]] + [[]] * 9999 + [["bar"]], c.each.to_a
+ def test_table_nil_equality
+ assert_nothing_raised(NoMethodError) { CSV.parse("test", headers: true) == nil }
end
end
diff --git a/test/csv/test_headers.rb b/test/csv/test_headers.rb
new file mode 100755
index 0000000000..5ec8932d95
--- /dev/null
+++ b/test/csv/test_headers.rb
@@ -0,0 +1,305 @@
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
+# frozen_string_literal: false
+
+# tc_headers.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
+
+require_relative "base"
+
+class TestCSV::Headers < TestCSV
+ extend DifferentOFS
+
+ def setup
+ super
+ @data = <<-END_CSV.gsub(/^\s+/, "")
+ first,second,third
+ A,B,C
+ 1,2,3
+ END_CSV
+ end
+
+ def test_first_row
+ [:first_row, true].each do |setting| # two names for the same setting
+ # activate headers
+ csv = nil
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse(@data, headers: setting)
+ end
+
+ # first data row - skipping headers
+ row = csv[0]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{first A}, %w{second B}, %w{third C}], row.to_a)
+
+ # second data row
+ row = csv[1]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{first 1}, %w{second 2}, %w{third 3}], row.to_a)
+
+ # empty
+ assert_nil(csv[2])
+ end
+ end
+
+ def test_array_of_headers
+ # activate headers
+ csv = nil
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse(@data, headers: [:my, :new, :headers])
+ end
+
+ # first data row - skipping headers
+ row = csv[0]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal( [[:my, "first"], [:new, "second"], [:headers, "third"]],
+ row.to_a )
+
+ # second data row
+ row = csv[1]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([[:my, "A"], [:new, "B"], [:headers, "C"]], row.to_a)
+
+ # third data row
+ row = csv[2]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([[:my, "1"], [:new, "2"], [:headers, "3"]], row.to_a)
+
+ # empty
+ assert_nil(csv[3])
+
+ # with return and convert
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse( @data, headers: [:my, :new, :headers],
+ return_headers: true,
+ header_converters: lambda { |h| h.to_s } )
+ end
+ row = csv[0]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([["my", :my], ["new", :new], ["headers", :headers]], row.to_a)
+ assert_predicate(row, :header_row?)
+ assert_not_predicate(row, :field_row?)
+ end
+
+ def test_csv_header_string
+ # activate headers
+ csv = nil
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse(@data, headers: "my,new,headers")
+ end
+
+ # first data row - skipping headers
+ row = csv[0]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{my first}, %w{new second}, %w{headers third}], row.to_a)
+
+ # second data row
+ row = csv[1]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{my A}, %w{new B}, %w{headers C}], row.to_a)
+
+ # third data row
+ row = csv[2]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{my 1}, %w{new 2}, %w{headers 3}], row.to_a)
+
+ # empty
+ assert_nil(csv[3])
+
+ # with return and convert
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse( @data, headers: "my,new,headers",
+ return_headers: true,
+ header_converters: :symbol )
+ end
+ row = csv[0]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([[:my, "my"], [:new, "new"], [:headers, "headers"]], row.to_a)
+ assert_predicate(row, :header_row?)
+ assert_not_predicate(row, :field_row?)
+ end
+
+ def test_csv_header_string_inherits_separators
+ # parse with custom col_sep
+ csv = nil
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse( @data.tr(",", "|"), col_sep: "|",
+ headers: "my|new|headers" )
+ end
+
+ # verify headers were recognized
+ row = csv[0]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{my first}, %w{new second}, %w{headers third}], row.to_a)
+ end
+
+ def test_return_headers
+ # activate headers and request they are returned
+ csv = nil
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse(@data, headers: true, return_headers: true)
+ end
+
+ # header row
+ row = csv[0]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal( [%w{first first}, %w{second second}, %w{third third}],
+ row.to_a )
+ assert_predicate(row, :header_row?)
+ assert_not_predicate(row, :field_row?)
+
+ # first data row - skipping headers
+ row = csv[1]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{first A}, %w{second B}, %w{third C}], row.to_a)
+ assert_not_predicate(row, :header_row?)
+ assert_predicate(row, :field_row?)
+
+ # second data row
+ row = csv[2]
+ assert_not_nil(row)
+ assert_instance_of(CSV::Row, row)
+ assert_equal([%w{first 1}, %w{second 2}, %w{third 3}], row.to_a)
+ assert_not_predicate(row, :header_row?)
+ assert_predicate(row, :field_row?)
+
+ # empty
+ assert_nil(csv[3])
+ end
+
+ def test_converters
+ # create test data where headers and fields look alike
+ data = <<-END_MATCHING_CSV.gsub(/^\s+/, "")
+ 1,2,3
+ 1,2,3
+ END_MATCHING_CSV
+
+ # normal converters do not affect headers
+ csv = CSV.parse( data, headers: true,
+ return_headers: true,
+ converters: :numeric )
+ assert_equal([%w{1 1}, %w{2 2}, %w{3 3}], csv[0].to_a)
+ assert_equal([["1", 1], ["2", 2], ["3", 3]], csv[1].to_a)
+ assert_nil(csv[2])
+
+ # header converters do affect headers (only)
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse( data, headers: true,
+ return_headers: true,
+ converters: :numeric,
+ header_converters: :symbol )
+ end
+ assert_equal([[:"1", "1"], [:"2", "2"], [:"3", "3"]], csv[0].to_a)
+ assert_equal([[:"1", 1], [:"2", 2], [:"3", 3]], csv[1].to_a)
+ assert_nil(csv[2])
+ end
+
+ def test_builtin_downcase_converter
+ csv = CSV.parse( "One,TWO Three", headers: true,
+ return_headers: true,
+ header_converters: :downcase )
+ assert_equal(%w{one two\ three}, csv.headers)
+ end
+
+ def test_builtin_symbol_converter
+ # Note that the trailing space is intentional
+ csv = CSV.parse( "One,TWO Three ", headers: true,
+ return_headers: true,
+ header_converters: :symbol )
+ assert_equal([:one, :two_three], csv.headers)
+ end
+
+ def test_builtin_symbol_converter_with_punctuation
+ csv = CSV.parse( "One, Two & Three ($)", headers: true,
+ return_headers: true,
+ header_converters: :symbol )
+ assert_equal([:one, :two_three], csv.headers)
+ end
+
+ def test_builtin_converters_with_blank_header
+ csv = CSV.parse( "one,,three", headers: true,
+ return_headers: true,
+ header_converters: [:downcase, :symbol] )
+ assert_equal([:one, nil, :three], csv.headers)
+ end
+
+ def test_custom_converter
+ converter = lambda { |header| header.tr(" ", "_") }
+ csv = CSV.parse( "One,TWO Three",
+ headers: true,
+ return_headers: true,
+ header_converters: converter )
+ assert_equal(%w{One TWO_Three}, csv.headers)
+ end
+
+ def test_table_support
+ csv = nil
+ assert_nothing_raised(Exception) do
+ csv = CSV.parse(@data, headers: true)
+ end
+
+ assert_instance_of(CSV::Table, csv)
+ end
+
+ def test_skip_blanks
+ @data = <<-END_CSV.gsub(/^ +/, "")
+
+
+ A,B,C
+
+ 1,2,3
+
+
+
+ END_CSV
+
+ expected = [%w[1 2 3]]
+ CSV.parse(@data, headers: true, skip_blanks: true) do |row|
+ assert_equal(expected.shift, row.fields)
+ end
+
+ expected = [%w[A B C], %w[1 2 3]]
+ CSV.parse( @data,
+ headers: true,
+ return_headers: true,
+ skip_blanks: true ) do |row|
+ assert_equal(expected.shift, row.fields)
+ end
+ end
+
+ def test_headers_reader
+ # no headers
+ assert_nil(CSV.new(@data).headers)
+
+ # headers
+ csv = CSV.new(@data, headers: true)
+ assert_equal(true, csv.headers) # before headers are read
+ csv.shift # set headers
+ assert_equal(%w[first second third], csv.headers) # after headers are read
+ end
+
+ def test_blank_row_bug_fix
+ @data += "\n#{@data}" # add a blank row
+
+ # ensure that everything returned is a Row object
+ CSV.parse(@data, headers: true) do |row|
+ assert_instance_of(CSV::Row, row)
+ end
+ end
+end
diff --git a/test/csv/test_interface.rb b/test/csv/test_interface.rb
new file mode 100755
index 0000000000..be27fcd616
--- /dev/null
+++ b/test/csv/test_interface.rb
@@ -0,0 +1,393 @@
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
+# frozen_string_literal: false
+
+# tc_interface.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
+
+require_relative "base"
+require "tempfile"
+
+class TestCSV::Interface < TestCSV
+ extend DifferentOFS
+
+ def setup
+ super
+ @tempfile = Tempfile.new(%w"temp .csv")
+ @tempfile.close
+ @path = @tempfile.path
+
+ File.open(@path, "wb") do |file|
+ file << "1\t2\t3\r\n"
+ file << "4\t5\r\n"
+ end
+
+ @expected = [%w{1 2 3}, %w{4 5}]
+ end
+
+ def teardown
+ @tempfile.close(true)
+ super
+ end
+
+ ### Test Read Interface ###
+
+ def test_foreach
+ CSV.foreach(@path, col_sep: "\t", row_sep: "\r\n") do |row|
+ assert_equal(@expected.shift, row)
+ end
+ end
+
+ def test_foreach_enum
+ CSV.foreach(@path, col_sep: "\t", row_sep: "\r\n").zip(@expected) do |row, exp|
+ assert_equal(exp, row)
+ end
+ end
+
+ def test_open_and_close
+ csv = CSV.open(@path, "r+", col_sep: "\t", row_sep: "\r\n")
+ assert_not_nil(csv)
+ assert_instance_of(CSV, csv)
+ assert_not_predicate(csv, :closed?)
+ csv.close
+ assert_predicate(csv, :closed?)
+
+ ret = CSV.open(@path) do |new_csv|
+ csv = new_csv
+ assert_instance_of(CSV, new_csv)
+ "Return value."
+ end
+ assert_predicate(csv, :closed?)
+ assert_equal("Return value.", ret)
+ end
+
+ def test_parse
+ data = File.binread(@path)
+ assert_equal( @expected,
+ CSV.parse(data, col_sep: "\t", row_sep: "\r\n") )
+
+ CSV.parse(data, col_sep: "\t", row_sep: "\r\n") do |row|
+ assert_equal(@expected.shift, row)
+ end
+ end
+
+ def test_parse_line
+ row = CSV.parse_line("1;2;3", col_sep: ";")
+ assert_not_nil(row)
+ assert_instance_of(Array, row)
+ assert_equal(%w{1 2 3}, row)
+
+ # shortcut interface
+ row = "1;2;3".parse_csv(col_sep: ";")
+ assert_not_nil(row)
+ assert_instance_of(Array, row)
+ assert_equal(%w{1 2 3}, row)
+ end
+
+ def test_parse_line_with_empty_lines
+ assert_equal(nil, CSV.parse_line("")) # to signal eof
+ assert_equal(Array.new, CSV.parse_line("\n1,2,3"))
+ end
+
+ def test_read_and_readlines
+ assert_equal( @expected,
+ CSV.read(@path, col_sep: "\t", row_sep: "\r\n") )
+ assert_equal( @expected,
+ CSV.readlines(@path, col_sep: "\t", row_sep: "\r\n") )
+
+
+ data = CSV.open(@path, col_sep: "\t", row_sep: "\r\n") do |csv|
+ csv.read
+ end
+ assert_equal(@expected, data)
+ data = CSV.open(@path, col_sep: "\t", row_sep: "\r\n") do |csv|
+ csv.readlines
+ end
+ assert_equal(@expected, data)
+ end
+
+ def test_table
+ table = CSV.table(@path, col_sep: "\t", row_sep: "\r\n")
+ assert_instance_of(CSV::Table, table)
+ assert_equal([[:"1", :"2", :"3"], [4, 5, nil]], table.to_a)
+ end
+
+ def test_shift # aliased as gets() and readline()
+ CSV.open(@path, "rb+", col_sep: "\t", row_sep: "\r\n") do |csv|
+ assert_equal(@expected.shift, csv.shift)
+ assert_equal(@expected.shift, csv.shift)
+ assert_equal(nil, csv.shift)
+ end
+ end
+
+ def test_enumerators_are_supported
+ CSV.open(@path, col_sep: "\t", row_sep: "\r\n") do |csv|
+ enum = csv.each
+ assert_instance_of(Enumerator, enum)
+ assert_equal(@expected.shift, enum.next)
+ end
+ end
+
+ def test_nil_is_not_acceptable
+ assert_raise_with_message ArgumentError, "Cannot parse nil as CSV" do
+ CSV.new(nil)
+ end
+ end
+
+ def test_open_handles_prematurely_closed_file_descriptor_gracefully
+ assert_nothing_raised(Exception) do
+ CSV.open(@path) do |csv|
+ csv.close
+ end
+ end
+ end
+
+ ### Test Write Interface ###
+
+ def test_generate
+ str = CSV.generate do |csv| # default empty String
+ assert_instance_of(CSV, csv)
+ assert_equal(csv, csv << [1, 2, 3])
+ assert_equal(csv, csv << [4, nil, 5])
+ end
+ assert_not_nil(str)
+ assert_instance_of(String, str)
+ assert_equal("1,2,3\n4,,5\n", str)
+
+ CSV.generate(str) do |csv| # appending to a String
+ assert_equal(csv, csv << ["last", %Q{"row"}])
+ end
+ assert_equal(%Q{1,2,3\n4,,5\nlast,"""row"""\n}, str)
+ end
+
+ def test_generate_line
+ line = CSV.generate_line(%w{1 2 3}, col_sep: ";")
+ assert_not_nil(line)
+ assert_instance_of(String, line)
+ assert_equal("1;2;3\n", line)
+
+ # shortcut interface
+ line = %w{1 2 3}.to_csv(col_sep: ";")
+ assert_not_nil(line)
+ assert_instance_of(String, line)
+ assert_equal("1;2;3\n", line)
+
+ line = CSV.generate_line(%w"1 2", row_sep: nil)
+ assert_equal("1,2", line)
+ end
+
+ def test_write_header_detection
+ File.unlink(@path)
+
+ headers = %w{a b c}
+ CSV.open(@path, "w", headers: true) do |csv|
+ csv << headers
+ csv << %w{1 2 3}
+ assert_equal(headers, csv.instance_variable_get(:@headers))
+ end
+ end
+
+ def test_write_lineno
+ File.unlink(@path)
+
+ CSV.open(@path, "w") do |csv|
+ lines = 20
+ lines.times { csv << %w{a b c} }
+ assert_equal(lines, csv.lineno)
+ end
+ end
+
+ def test_write_hash
+ File.unlink(@path)
+
+ lines = [{a: 1, b: 2, c: 3}, {a: 4, b: 5, c: 6}]
+ CSV.open( @path, "wb", headers: true,
+ header_converters: :symbol ) do |csv|
+ csv << lines.first.keys
+ lines.each { |line| csv << line }
+ end
+ CSV.open( @path, "rb", headers: true,
+ converters: :all,
+ header_converters: :symbol ) do |csv|
+ csv.each { |line| assert_equal(lines.shift, line.to_hash) }
+ end
+ end
+
+ def test_write_hash_with_string_keys
+ File.unlink(@path)
+
+ lines = [{a: 1, b: 2, c: 3}, {a: 4, b: 5, c: 6}]
+ CSV.open( @path, "wb", headers: true ) do |csv|
+ csv << lines.first.keys
+ lines.each { |line| csv << line }
+ end
+ CSV.open( @path, "rb", headers: true ) do |csv|
+ csv.each do |line|
+ csv.headers.each_with_index do |header, h|
+ keys = line.to_hash.keys
+ assert_instance_of(String, keys[h])
+ assert_same(header, keys[h])
+ end
+ end
+ end
+ end
+
+ def test_write_hash_with_headers_array
+ File.unlink(@path)
+
+ lines = [{a: 1, b: 2, c: 3}, {a: 4, b: 5, c: 6}]
+ CSV.open(@path, "wb", headers: [:b, :a, :c]) do |csv|
+ lines.each { |line| csv << line }
+ end
+
+ # test writing fields in the correct order
+ File.open(@path, "rb") do |f|
+ assert_equal("2,1,3", f.gets.strip)
+ assert_equal("5,4,6", f.gets.strip)
+ end
+
+ # test reading CSV with headers
+ CSV.open( @path, "rb", headers: [:b, :a, :c],
+ converters: :all ) do |csv|
+ csv.each { |line| assert_equal(lines.shift, line.to_hash) }
+ end
+ end
+
+ def test_write_hash_with_headers_string
+ File.unlink(@path)
+
+ lines = [{"a" => 1, "b" => 2, "c" => 3}, {"a" => 4, "b" => 5, "c" => 6}]
+ CSV.open(@path, "wb", headers: "b|a|c", col_sep: "|") do |csv|
+ lines.each { |line| csv << line }
+ end
+
+ # test writing fields in the correct order
+ File.open(@path, "rb") do |f|
+ assert_equal("2|1|3", f.gets.strip)
+ assert_equal("5|4|6", f.gets.strip)
+ end
+
+ # test reading CSV with headers
+ CSV.open( @path, "rb", headers: "b|a|c",
+ col_sep: "|",
+ converters: :all ) do |csv|
+ csv.each { |line| assert_equal(lines.shift, line.to_hash) }
+ end
+ end
+
+ def test_write_headers
+ File.unlink(@path)
+
+ lines = [{"a" => 1, "b" => 2, "c" => 3}, {"a" => 4, "b" => 5, "c" => 6}]
+ CSV.open( @path, "wb", headers: "b|a|c",
+ write_headers: true,
+ col_sep: "|" ) do |csv|
+ lines.each { |line| csv << line }
+ end
+
+ # test writing fields in the correct order
+ File.open(@path, "rb") do |f|
+ assert_equal("b|a|c", f.gets.strip)
+ assert_equal("2|1|3", f.gets.strip)
+ assert_equal("5|4|6", f.gets.strip)
+ end
+
+ # test reading CSV with headers
+ CSV.open( @path, "rb", headers: true,
+ col_sep: "|",
+ converters: :all ) do |csv|
+ csv.each { |line| assert_equal(lines.shift, line.to_hash) }
+ end
+ end
+
+ def test_write_headers_empty
+ File.unlink(@path)
+
+ CSV.open( @path, "wb", headers: "b|a|c",
+ write_headers: true,
+ col_sep: "|" ) do |csv|
+ end
+
+ File.open(@path, "rb") do |f|
+ assert_equal("b|a|c", f.gets.strip)
+ end
+ end
+
+ def test_append # aliased add_row() and puts()
+ File.unlink(@path)
+
+ CSV.open(@path, "wb", col_sep: "\t", row_sep: "\r\n") do |csv|
+ @expected.each { |row| csv << row }
+ end
+
+ test_shift
+
+ # same thing using CSV::Row objects
+ File.unlink(@path)
+
+ CSV.open(@path, "wb", col_sep: "\t", row_sep: "\r\n") do |csv|
+ @expected.each { |row| csv << CSV::Row.new(Array.new, row) }
+ end
+
+ test_shift
+ end
+
+ ### Test Read and Write Interface ###
+
+ def test_filter
+ assert_respond_to(CSV, :filter)
+
+ expected = [[1, 2, 3], [4, 5]]
+ CSV.filter( "1;2;3\n4;5\n", (result = String.new),
+ in_col_sep: ";", out_col_sep: ",",
+ converters: :all ) do |row|
+ assert_equal(row, expected.shift)
+ row.map! { |n| n * 2 }
+ row << "Added\r"
+ end
+ assert_equal("2,4,6,\"Added\r\"\n8,10,\"Added\r\"\n", result)
+ end
+
+ def test_instance
+ csv = String.new
+
+ first = nil
+ assert_nothing_raised(Exception) do
+ first = CSV.instance(csv, col_sep: ";")
+ first << %w{a b c}
+ end
+
+ assert_equal("a;b;c\n", csv)
+
+ second = nil
+ assert_nothing_raised(Exception) do
+ second = CSV.instance(csv, col_sep: ";")
+ second << [1, 2, 3]
+ end
+
+ assert_equal(first.object_id, second.object_id)
+ assert_equal("a;b;c\n1;2;3\n", csv)
+
+ # shortcuts
+ assert_equal(STDOUT, CSV.instance.instance_eval { @io })
+ assert_equal(STDOUT, CSV { |new_csv| new_csv.instance_eval { @io } })
+ end
+
+ def test_options_are_not_modified
+ opt = {}.freeze
+ assert_nothing_raised { CSV.foreach(@path, opt) }
+ assert_nothing_raised { CSV.open(@path, opt){} }
+ assert_nothing_raised { CSV.parse("", opt) }
+ assert_nothing_raised { CSV.parse_line("", opt) }
+ assert_nothing_raised { CSV.read(@path, opt) }
+ assert_nothing_raised { CSV.readlines(@path, opt) }
+ assert_nothing_raised { CSV.table(@path, opt) }
+ assert_nothing_raised { CSV.generate(opt){} }
+ assert_nothing_raised { CSV.generate_line([], opt) }
+ assert_nothing_raised { CSV.filter("", "", opt){} }
+ assert_nothing_raised { CSV.instance("", opt) }
+ end
+end
diff --git a/test/csv/test_row.rb b/test/csv/test_row.rb
index f709dd3f13..1cb851b027 100644..100755
--- a/test/csv/test_row.rb
+++ b/test/csv/test_row.rb
@@ -1,9 +1,16 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
# frozen_string_literal: false
-require_relative "helper"
+# tc_row.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
-class TestCSVRow < Test::Unit::TestCase
+require_relative "base"
+
+class TestCSV::Row < TestCSV
extend DifferentOFS
def setup
@@ -100,19 +107,6 @@ class TestCSVRow < Test::Unit::TestCase
def test_has_key?
assert_equal(true, @row.has_key?('B'))
assert_equal(false, @row.has_key?('foo'))
-
- # aliases
- assert_equal(true, @row.header?('B'))
- assert_equal(false, @row.header?('foo'))
-
- assert_equal(true, @row.include?('B'))
- assert_equal(false, @row.include?('foo'))
-
- assert_equal(true, @row.member?('B'))
- assert_equal(false, @row.member?('foo'))
-
- assert_equal(true, @row.key?('B'))
- assert_equal(false, @row.key?('foo'))
end
def test_set_field
@@ -269,6 +263,12 @@ class TestCSVRow < Test::Unit::TestCase
end
def test_queries
+ # headers
+ assert_send([@row, :header?, "A"])
+ assert_send([@row, :header?, "C"])
+ assert_not_send([@row, :header?, "Z"])
+ assert_send([@row, :include?, "A"]) # alias
+
# fields
assert(@row.field?(4))
assert(@row.field?(nil))
@@ -304,17 +304,6 @@ class TestCSVRow < Test::Unit::TestCase
end
end
- def test_each_pair
- assert_equal([
- ["A", 1],
- ["B", 2],
- ["C", 3],
- ["A", 4],
- ["A", nil],
- ],
- @row.each_pair.to_a)
- end
-
def test_enumerable
assert_equal( [["A", 1], ["A", 4], ["A", nil]],
@row.select { |pair| pair.first == "A" } )
@@ -334,7 +323,7 @@ class TestCSVRow < Test::Unit::TestCase
def test_to_hash
hash = @row.to_hash
- assert_equal({"A" => @row["A"], "B" => @row["B"], "C" => @row["C"]}, hash)
+ assert_equal({"A" => nil, "B" => 2, "C" => 3}, hash)
hash.keys.each_with_index do |string_key, h|
assert_predicate(string_key, :frozen?)
assert_same(string_key, @row.headers[h])
@@ -388,45 +377,4 @@ class TestCSVRow < Test::Unit::TestCase
r = @row == []
assert_equal false, r
end
-
- def test_dig_by_index
- assert_equal(2, @row.dig(1))
-
- assert_nil(@row.dig(100))
- end
-
- def test_dig_by_header
- assert_equal(2, @row.dig("B"))
-
- assert_nil(@row.dig("Missing"))
- end
-
- def test_dig_cell
- row = CSV::Row.new(%w{A}, [["foo", ["bar", ["baz"]]]])
-
- assert_equal("foo", row.dig(0, 0))
- assert_equal("bar", row.dig(0, 1, 0))
-
- assert_equal("foo", row.dig("A", 0))
- assert_equal("bar", row.dig("A", 1, 0))
- end
-
- def test_dig_cell_no_dig
- row = CSV::Row.new(%w{A}, ["foo"])
-
- assert_raise(TypeError) do
- row.dig(0, 0)
- end
- assert_raise(TypeError) do
- row.dig("A", 0)
- end
- end
-
- def test_dup
- row = CSV::Row.new(["A"], ["foo"])
- dupped_row = row.dup
- dupped_row.delete("A")
- assert_equal(["foo", nil],
- [row["A"], dupped_row["A"]])
- end
end
diff --git a/test/csv/test_table.rb b/test/csv/test_table.rb
index 50edc77e40..25ef11a772 100644..100755
--- a/test/csv/test_table.rb
+++ b/test/csv/test_table.rb
@@ -1,9 +1,16 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
# frozen_string_literal: false
-require_relative "helper"
+# tc_table.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
-class TestCSVTable < Test::Unit::TestCase
+require_relative "base"
+
+class TestCSV::Table < TestCSV
extend DifferentOFS
def setup
@@ -16,8 +23,6 @@ class TestCSVTable < Test::Unit::TestCase
@header_table = CSV::Table.new(
[CSV::Row.new(%w{A B C}, %w{A B C}, true)] + @rows
)
-
- @header_only_table = CSV::Table.new([], headers: %w{A B C})
end
def test_initialze
@@ -39,11 +44,6 @@ class TestCSVTable < Test::Unit::TestCase
assert_equal(:row, rows.mode)
assert_equal(@table, rows)
- col_or_row = rows.by_col_or_row
- assert_equal(:row, rows.mode)
- assert_equal(:col_or_row, col_or_row.mode)
- assert_equal(@table, col_or_row)
-
# destructive mode changing calls
assert_equal(@table, @table.by_row!)
assert_equal(:row, @table.mode)
@@ -60,17 +60,6 @@ class TestCSVTable < Test::Unit::TestCase
assert_equal Array.new, t.headers
end
- def test_headers_only
- assert_equal(%w[A B C], @header_only_table.headers)
- end
-
- def test_headers_modified_by_row
- table = CSV::Table.new([], headers: ["A", "B"])
- table << ["a", "b"]
- table.first << {"C" => "c"}
- assert_equal(["A", "B", "C"], table.headers)
- end
-
def test_index
##################
### Mixed Mode ###
@@ -161,13 +150,13 @@ class TestCSVTable < Test::Unit::TestCase
@table.to_a )
# verify resulting table
- assert_equal(<<-CSV, @table.to_csv)
-A,B,C,Type,Index
-1,100,3,data,1
-4,200,6,data,2
-10,,12,data,3
-13,,15,data,
- CSV
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ A,B,C,Type,Index
+ 1,100,3,data,1
+ 4,200,6,data,2
+ 10,,12,data,3
+ 13,,15,data,
+ END_RESULT
# with headers
@header_table["Type"] = "data"
@@ -274,15 +263,6 @@ A,B,C,Type,Index
@table.each { |row| assert_instance_of(CSV::Row, row) }
end
- def test_each_split
- yielded_values = []
- @table.each do |column1, column2, column3|
- yielded_values << [column1, column2, column3]
- end
- assert_equal(@rows.collect(&:to_a),
- yielded_values)
- end
-
def test_enumerable
assert_equal( @rows.values_at(0, 2),
@table.select { |row| (row["B"] % 2).zero? } )
@@ -299,12 +279,12 @@ A,B,C,Type,Index
end
def test_to_csv
- csv = <<-CSV
-A,B,C
-1,2,3
-4,5,6
-7,8,9
- CSV
+ csv = <<-END_CSV.gsub(/^\s+/, "")
+ A,B,C
+ 1,2,3
+ 4,5,6
+ 7,8,9
+ END_CSV
# normal conversion
assert_equal(csv, @table.to_csv)
@@ -332,7 +312,7 @@ A,B,C
assert_equal(CSV::Row.new(%w[A B C], [13, 14, 15]), @table[-1])
end
- def test_delete_mixed_one
+ def test_delete_mixed
##################
### Mixed Mode ###
##################
@@ -343,33 +323,11 @@ A,B,C
assert_equal(@rows.map { |row| row["A"] }, @table.delete("A"))
# verify resulting table
- assert_equal(<<-CSV, @table.to_csv)
-B,C
-2,3
-8,9
- CSV
- end
-
- def test_delete_mixed_multiple
- ##################
- ### Mixed Mode ###
- ##################
- # delete row and col
- second_row = @rows[1]
- a_col = @rows.map { |row| row["A"] }
- a_col_without_second_row = a_col[0..0] + a_col[2..-1]
- assert_equal([
- second_row,
- a_col_without_second_row,
- ],
- @table.delete(1, "A"))
-
- # verify resulting table
- assert_equal(<<-CSV, @table.to_csv)
-B,C
-2,3
-8,9
- CSV
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ B,C
+ 2,3
+ 8,9
+ END_RESULT
end
def test_delete_column
@@ -382,12 +340,12 @@ B,C
assert_equal(@rows.map { |row| row["C"] }, @table.delete("C"))
# verify resulting table
- assert_equal(<<-CSV, @table.to_csv)
-B
-2
-5
-8
- CSV
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ B
+ 2
+ 5
+ 8
+ END_RESULT
end
def test_delete_row
@@ -400,11 +358,11 @@ B
assert_raise(TypeError) { @table.delete("C") }
# verify resulting table
- assert_equal(<<-CSV, @table.to_csv)
-A,B,C
-1,2,3
-7,8,9
- CSV
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ A,B,C
+ 1,2,3
+ 7,8,9
+ END_RESULT
end
def test_delete_with_blank_rows
@@ -421,10 +379,10 @@ A,B,C
assert_equal(@table, @table.delete_if { |row| (row["B"] % 2).zero? })
# verify resulting table
- assert_equal(<<-CSV, @table.to_csv)
-A,B,C
-4,5,6
- CSV
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ A,B,C
+ 4,5,6
+ END_RESULT
end
def test_delete_if_row_without_block
@@ -439,10 +397,10 @@ A,B,C
assert_equal(@table, enum.each { |row| (row["B"] % 2).zero? })
# verify resulting table
- assert_equal(<<-CSV, @table.to_csv)
-A,B,C
-4,5,6
- CSV
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ A,B,C
+ 4,5,6
+ END_RESULT
end
def test_delete_if_column
@@ -452,12 +410,12 @@ A,B,C
@table.by_col!
assert_equal(@table, @table.delete_if { |h, v| h > "A" })
- assert_equal(<<-CSV, @table.to_csv)
-A
-1
-4
-7
- CSV
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ A
+ 1
+ 4
+ 7
+ END_RESULT
end
def test_delete_if_column_without_block
@@ -471,27 +429,12 @@ A
assert_equal(@table.headers.size, enum.size)
assert_equal(@table, enum.each { |h, v| h > "A" })
- assert_equal(<<-CSV, @table.to_csv)
-A
-1
-4
-7
- CSV
- end
-
- def test_delete_headers_only
- ###################
- ### Column Mode ###
- ###################
- @header_only_table.by_col!
-
- # delete by index
- assert_equal([], @header_only_table.delete(0))
- assert_equal(%w[B C], @header_only_table.headers)
-
- # delete by header
- assert_equal([], @header_only_table.delete("C"))
- assert_equal(%w[B], @header_only_table.headers)
+ assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
+ A
+ 1
+ 4
+ 7
+ END_RESULT
end
def test_values_at
@@ -551,70 +494,4 @@ A
@table.inspect.encoding],
"inspect() was not ASCII compatible." )
end
-
- def test_dig_mixed
- # by row
- assert_equal(@rows[0], @table.dig(0))
- assert_nil(@table.dig(100)) # empty row
-
- # by col
- assert_equal([2, 5, 8], @table.dig("B"))
- assert_equal([nil] * @rows.size, @table.dig("Z")) # empty col
-
- # by row then col
- assert_equal(2, @table.dig(0, 1))
- assert_equal(6, @table.dig(1, "C"))
-
- # by col then row
- assert_equal(5, @table.dig("B", 1))
- assert_equal(9, @table.dig("C", 2))
- end
-
- def test_dig_by_column
- @table.by_col!
-
- assert_equal([2, 5, 8], @table.dig(1))
- assert_equal([2, 5, 8], @table.dig("B"))
-
- # by col then row
- assert_equal(5, @table.dig("B", 1))
- assert_equal(9, @table.dig("C", 2))
- end
-
- def test_dig_by_row
- @table.by_row!
-
- assert_equal(@rows[1], @table.dig(1))
- assert_raise(TypeError) { @table.dig("B") }
-
- # by row then col
- assert_equal(2, @table.dig(0, 1))
- assert_equal(6, @table.dig(1, "C"))
- end
-
- def test_dig_cell
- table = CSV::Table.new([CSV::Row.new(["A"], [["foo", ["bar", ["baz"]]]])])
-
- # by row, col then cell
- assert_equal("foo", table.dig(0, "A", 0))
- assert_equal(["baz"], table.dig(0, "A", 1, 1))
-
- # by col, row then cell
- assert_equal("foo", table.dig("A", 0, 0))
- assert_equal(["baz"], table.dig("A", 0, 1, 1))
- end
-
- def test_dig_cell_no_dig
- table = CSV::Table.new([CSV::Row.new(["A"], ["foo"])])
-
- # by row, col then cell
- assert_raise(TypeError) do
- table.dig(0, "A", 0)
- end
-
- # by col, row then cell
- assert_raise(TypeError) do
- table.dig("A", 0, 0)
- end
- end
end
diff --git a/test/csv/ts_all.rb b/test/csv/ts_all.rb
new file mode 100644
index 0000000000..9eadf12918
--- /dev/null
+++ b/test/csv/ts_all.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby -w
+# encoding: UTF-8
+# frozen_string_literal: false
+
+# ts_all.rb
+#
+# Created by James Edward Gray II on 2005-10-31.
+# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
+# under the terms of Ruby's license.
+
+require "test/unit"
+
+require "test_csv_parsing"
+require "test_features"
+require "test_interface"
+require "test_csv_writing"
+require "test_data_converters"
+require "test_row"
+require "test_table"
+require "test_headers"
+require "test_encodings"
diff --git a/test/csv/write/test_converters.rb b/test/csv/write/test_converters.rb
deleted file mode 100644
index a93b1040ac..0000000000
--- a/test/csv/write/test_converters.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-module TestCSVWriteConverters
- def test_one
- assert_equal(%Q[=a,=b,=c\n],
- generate_line(["a", "b", "c"],
- write_converters: ->(value) {"=" + value}))
- end
-
- def test_multiple
- assert_equal(%Q[=a_,=b_,=c_\n],
- generate_line(["a", "b", "c"],
- write_converters: [
- ->(value) {"=" + value},
- ->(value) {value + "_"},
- ]))
- end
-
- def test_nil_value
- assert_equal(%Q[a,NaN,c\n],
- generate_line(["a", nil, "c"],
- write_nil_value: "NaN"))
- end
-
- def test_empty_value
- assert_equal(%Q[a,,c\n],
- generate_line(["a", "", "c"],
- write_empty_value: nil))
- end
-end
-
-class TestCSVWriteConvertersGenerateLine < Test::Unit::TestCase
- include TestCSVWriteConverters
- extend DifferentOFS
-
- def generate_line(row, **kwargs)
- CSV.generate_line(row, **kwargs)
- end
-end
-
-class TestCSVWriteConvertersGenerate < Test::Unit::TestCase
- include TestCSVWriteConverters
- extend DifferentOFS
-
- def generate_line(row, **kwargs)
- CSV.generate(**kwargs) do |csv|
- csv << row
- end
- end
-end
diff --git a/test/csv/write/test_general.rb b/test/csv/write/test_general.rb
deleted file mode 100644
index f39456b98a..0000000000
--- a/test/csv/write/test_general.rb
+++ /dev/null
@@ -1,258 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-module TestCSVWriteGeneral
- def test_tab
- assert_equal("\t#{$INPUT_RECORD_SEPARATOR}",
- generate_line(["\t"]))
- end
-
- def test_quote_character
- assert_equal(%Q[foo,"""",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", %Q["], "baz"]))
- end
-
- def test_quote_character_double
- assert_equal(%Q[foo,"""""",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", %Q[""], "baz"]))
- end
-
- def test_quote
- assert_equal(%Q[foo,"""bar""",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", %Q["bar"], "baz"]))
- end
-
- def test_quote_lf
- assert_equal(%Q["""\n","""\n"#{$INPUT_RECORD_SEPARATOR}],
- generate_line([%Q["\n], %Q["\n]]))
- end
-
- def test_quote_cr
- assert_equal(%Q["""\r","""\r"#{$INPUT_RECORD_SEPARATOR}],
- generate_line([%Q["\r], %Q["\r]]))
- end
-
- def test_quote_last
- assert_equal(%Q[foo,"bar"""#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", %Q[bar"]]))
- end
-
- def test_quote_lf_last
- assert_equal(%Q[foo,"\nbar"""#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", %Q[\nbar"]]))
- end
-
- def test_quote_lf_value_lf
- assert_equal(%Q[foo,"""\nbar\n"""#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", %Q["\nbar\n"]]))
- end
-
- def test_quote_lf_value_lf_nil
- assert_equal(%Q[foo,"""\nbar\n""",#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", %Q["\nbar\n"], nil]))
- end
-
- def test_cr
- assert_equal(%Q[foo,"\r",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "\r", "baz"]))
- end
-
- def test_lf
- assert_equal(%Q[foo,"\n",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "\n", "baz"]))
- end
-
- def test_cr_lf
- assert_equal(%Q[foo,"\r\n",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "\r\n", "baz"]))
- end
-
- def test_cr_dot_lf
- assert_equal(%Q[foo,"\r.\n",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "\r.\n", "baz"]))
- end
-
- def test_cr_lf_cr
- assert_equal(%Q[foo,"\r\n\r",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "\r\n\r", "baz"]))
- end
-
- def test_cr_lf_lf
- assert_equal(%Q[foo,"\r\n\n",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "\r\n\n", "baz"]))
- end
-
- def test_cr_lf_comma
- assert_equal(%Q["\r\n,"#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["\r\n,"]))
- end
-
- def test_cr_lf_comma_nil
- assert_equal(%Q["\r\n,",#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["\r\n,", nil]))
- end
-
- def test_comma
- assert_equal(%Q[","#{$INPUT_RECORD_SEPARATOR}],
- generate_line([","]))
- end
-
- def test_comma_double
- assert_equal(%Q[",",","#{$INPUT_RECORD_SEPARATOR}],
- generate_line([",", ","]))
- end
-
- def test_comma_and_value
- assert_equal(%Q[foo,"foo,bar",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "foo,bar", "baz"]))
- end
-
- def test_one_element
- assert_equal(%Q[foo#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo"]))
- end
-
- def test_nil_values_only
- assert_equal(%Q[,,#{$INPUT_RECORD_SEPARATOR}],
- generate_line([nil, nil, nil]))
- end
-
- def test_nil_double_only
- assert_equal(%Q[,#{$INPUT_RECORD_SEPARATOR}],
- generate_line([nil, nil]))
- end
-
- def test_nil_values
- assert_equal(%Q[foo,,,#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", nil, nil, nil]))
- end
-
- def test_nil_value_first
- assert_equal(%Q[,foo,baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line([nil, "foo", "baz"]))
- end
-
- def test_nil_value_middle
- assert_equal(%Q[foo,,baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", nil, "baz"]))
- end
-
- def test_nil_value_last
- assert_equal(%Q[foo,baz,#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "baz", nil]))
- end
-
- def test_nil_empty
- assert_equal(%Q[,""#{$INPUT_RECORD_SEPARATOR}],
- generate_line([nil, ""]))
- end
-
- def test_nil_cr
- assert_equal(%Q[,"\r"#{$INPUT_RECORD_SEPARATOR}],
- generate_line([nil, "\r"]))
- end
-
- def test_values
- assert_equal(%Q[foo,bar#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "bar"]))
- end
-
- def test_semi_colon
- assert_equal(%Q[;#{$INPUT_RECORD_SEPARATOR}],
- generate_line([";"]))
- end
-
- def test_semi_colon_values
- assert_equal(%Q[;,;#{$INPUT_RECORD_SEPARATOR}],
- generate_line([";", ";"]))
- end
-
- def test_tab_values
- assert_equal(%Q[\t,\t#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["\t", "\t"]))
- end
-
- def test_col_sep
- assert_equal(%Q[a;b;;c#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["a", "b", nil, "c"],
- col_sep: ";"))
- assert_equal(%Q[a\tb\t\tc#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["a", "b", nil, "c"],
- col_sep: "\t"))
- end
-
- def test_row_sep
- assert_equal(%Q[a,b,,c\r\n],
- generate_line(["a", "b", nil, "c"],
- row_sep: "\r\n"))
- end
-
- def test_force_quotes
- assert_equal(%Q["1","b","","already ""quoted"""#{$INPUT_RECORD_SEPARATOR}],
- generate_line([1, "b", nil, %Q{already "quoted"}],
- force_quotes: true))
- end
-
- def test_encoding_utf8
- assert_equal(%Q[ã‚,ã„,ã†#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["ã‚" , "ã„", "ã†"]))
- end
-
- def test_encoding_euc_jp
- row = ["ã‚", "ã„", "ã†"].collect {|field| field.encode("EUC-JP")}
- assert_equal(%Q[ã‚,ã„,ã†#{$INPUT_RECORD_SEPARATOR}].encode("EUC-JP"),
- generate_line(row))
- end
-
- def test_encoding_with_default_internal
- with_default_internal(Encoding::UTF_8) do
- row = ["ã‚", "ã„", "ã†"].collect {|field| field.encode("EUC-JP")}
- assert_equal(%Q[ã‚,ã„,ã†#{$INPUT_RECORD_SEPARATOR}].encode("EUC-JP"),
- generate_line(row, encoding: Encoding::EUC_JP))
- end
- end
-
- def test_with_default_internal
- with_default_internal(Encoding::UTF_8) do
- row = ["ã‚", "ã„", "ã†"].collect {|field| field.encode("EUC-JP")}
- assert_equal(%Q[ã‚,ã„,ã†#{$INPUT_RECORD_SEPARATOR}].encode("EUC-JP"),
- generate_line(row))
- end
- end
-
- def with_default_internal(encoding)
- original = Encoding.default_internal
- begin
- $VERBOSE, verbose_bak = nil, $VERBOSE
- Encoding.default_internal = encoding
- $VERBOSE = verbose_bak
- yield
- ensure
- $VERBOSE, verbose_bak = nil, $VERBOSE
- Encoding.default_internal = original
- $VERBOSE = verbose_bak
- end
- end
-end
-
-class TestCSVWriteGeneralGenerateLine < Test::Unit::TestCase
- include TestCSVWriteGeneral
- extend DifferentOFS
-
- def generate_line(row, **kwargs)
- CSV.generate_line(row, **kwargs)
- end
-end
-
-class TestCSVWriteGeneralGenerate < Test::Unit::TestCase
- include TestCSVWriteGeneral
- extend DifferentOFS
-
- def generate_line(row, **kwargs)
- CSV.generate(**kwargs) do |csv|
- csv << row
- end
- end
-end
diff --git a/test/csv/write/test_quote_empty.rb b/test/csv/write/test_quote_empty.rb
deleted file mode 100644
index 70f73dad4a..0000000000
--- a/test/csv/write/test_quote_empty.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-
-require_relative "../helper"
-
-module TestCSVWriteQuoteEmpty
- def test_quote_empty_default
- assert_equal(%Q["""",""#{$INPUT_RECORD_SEPARATOR}],
- generate_line([%Q["], ""]))
- end
-
- def test_quote_empty_false
- assert_equal(%Q["""",#{$INPUT_RECORD_SEPARATOR}],
- generate_line([%Q["], ""],
- quote_empty: false))
- end
-
- def test_empty_default
- assert_equal(%Q[foo,"",baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "", "baz"]))
- end
-
- def test_empty_false
- assert_equal(%Q[foo,,baz#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["foo", "", "baz"],
- quote_empty: false))
- end
-
- def test_empty_only_default
- assert_equal(%Q[""#{$INPUT_RECORD_SEPARATOR}],
- generate_line([""]))
- end
-
- def test_empty_only_false
- assert_equal(%Q[#{$INPUT_RECORD_SEPARATOR}],
- generate_line([""],
- quote_empty: false))
- end
-
- def test_empty_double_default
- assert_equal(%Q["",""#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["", ""]))
- end
-
- def test_empty_double_false
- assert_equal(%Q[,#{$INPUT_RECORD_SEPARATOR}],
- generate_line(["", ""],
- quote_empty: false))
- end
-end
-
-class TestCSVWriteQuoteEmptyGenerateLine < Test::Unit::TestCase
- include TestCSVWriteQuoteEmpty
- extend DifferentOFS
-
- def generate_line(row, **kwargs)
- CSV.generate_line(row, **kwargs)
- end
-end
-
-class TestCSVWriteQuoteEmptyGenerate < Test::Unit::TestCase
- include TestCSVWriteQuoteEmpty
- extend DifferentOFS
-
- def generate_line(row, **kwargs)
- CSV.generate(**kwargs) do |csv|
- csv << row
- end
- end
-end
diff --git a/test/date/test_date.rb b/test/date/test_date.rb
index ebd75ae12d..03e935e299 100644
--- a/test/date/test_date.rb
+++ b/test/date/test_date.rb
@@ -6,19 +6,6 @@ class DateSub < Date; end
class DateTimeSub < DateTime; end
class TestDate < Test::Unit::TestCase
- def test_range_infinite_float
- today = Date.today
- r = today...Float::INFINITY
- assert_equal today, r.begin
- assert_equal Float::INFINITY, r.end
- assert_equal true, r.cover?(today+1)
- assert_equal false, r.cover?(today-1)
- r = (-Float::INFINITY)...today
- assert_equal(-Float::INFINITY, r.begin)
- assert_equal today, r.end
- assert_equal false, r.cover?(today+1)
- assert_equal true, r.cover?(today-1)
- end
def test__const
assert_nil(Date::MONTHNAMES[0])
diff --git a/test/date/test_date_arith.rb b/test/date/test_date_arith.rb
index c3633c9473..d0d27d72f7 100644
--- a/test/date/test_date_arith.rb
+++ b/test/date/test_date_arith.rb
@@ -3,18 +3,11 @@ require 'test/unit'
require 'date'
class TestDateArith < Test::Unit::TestCase
- class Rat < Numeric
- def to_r; self; end
- end
- def test_new_offset
+ def new_offset
d = DateTime.new(2002, 3, 14)
assert_equal(Rational(9, 24), d.new_offset(Rational(9, 24)).offset)
assert_equal(Rational(9, 24), d.new_offset('+0900').offset)
- n = Rat.new
- assert_raise(TypeError) do
- Timeout.timeout(1) {d.new_offset(n)}
- end
end
def test__plus
@@ -44,13 +37,6 @@ class TestDateArith < Test::Unit::TestCase
assert_raise(e) do
DateTime.new(2000,2,29) + Time.mktime(2000,2,29)
end
- n = Rat.new
- assert_raise(e) do
- Timeout.timeout(1) {Date.new(2000,2,29) + n}
- end
- assert_raise(e) do
- Timeout.timeout(1) {DateTime.new(2000,2,29) + n}
- end
end
def test__minus
@@ -277,18 +263,16 @@ class TestDateArith < Test::Unit::TestCase
end
def test_step__compare
- p = Date.new(2000, 1, 1)
- q = Date.new(1999, 12, 31)
o = Object.new
def o.<=>(*);end
assert_raise(ArgumentError) {
- p.step(q, o).to_a
+ Date.new(2000, 1, 1).step(3, o).to_a
}
o = Object.new
def o.<=>(*);2;end
a = []
- p.step(q, o) {|d| a << d}
+ Date.new(2000, 1, 1).step(3, o) {|d| a << d}
assert_empty(a)
end
end
diff --git a/test/date/test_date_attr.rb b/test/date/test_date_attr.rb
index 1e4d1bfd7a..b3b5d3a800 100644
--- a/test/date/test_date_attr.rb
+++ b/test/date/test_date_attr.rb
@@ -88,16 +88,16 @@ class TestDateAttr < Test::Unit::TestCase
end
def test_nth_kday
- assert_equal(false, Date.new(2001,1,14).nth_kday?(1,0))
- assert_equal(true, Date.new(2001,1,14).nth_kday?(2,0))
- assert_equal(false, Date.new(2001,1,14).nth_kday?(3,0))
- assert_equal(false, Date.new(2001,1,14).nth_kday?(4,0))
- assert_equal(false, Date.new(2001,1,14).nth_kday?(5,0))
- assert_equal(false, Date.new(2001,1,14).nth_kday?(-1,0))
- assert_equal(false, Date.new(2001,1,14).nth_kday?(-2,0))
- assert_equal(true, Date.new(2001,1,14).nth_kday?(-3,0))
- assert_equal(false, Date.new(2001,1,14).nth_kday?(-4,0))
- assert_equal(false, Date.new(2001,1,14).nth_kday?(-5,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, 1,0))
+ assert_equal(true, Date.new(2001,1,14).__send__(:nth_kday?, 2,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, 3,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, 4,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, 5,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, -1,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, -2,0))
+ assert_equal(true, Date.new(2001,1,14).__send__(:nth_kday?, -3,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, -4,0))
+ assert_equal(false, Date.new(2001,1,14).__send__(:nth_kday?, -5,0))
end if Date.new.respond_to?(:nth_kday?, true)
end
diff --git a/test/date/test_date_base.rb b/test/date/test_date_base.rb
new file mode 100644
index 0000000000..c097eb0fd1
--- /dev/null
+++ b/test/date/test_date_base.rb
@@ -0,0 +1,435 @@
+# frozen_string_literal: true
+require 'test/unit'
+require 'date'
+
+begin
+ require 'calendar'
+ include Calendar
+rescue LoadError
+end
+
+class TestDateBase < Test::Unit::TestCase
+
+ def setup
+ if defined?(Calendar)
+ @from ||= julian_day_number_from_absolute(absolute_from_julian(1, 1, 1601))
+ @to ||= julian_day_number_from_absolute(absolute_from_julian(12, 31, 2400))
+ @from4t ||= julian_day_number_from_absolute(absolute_from_julian(1, 1, 1970))
+ @to4t ||= julian_day_number_from_absolute(absolute_from_julian(12, 31, 2037))
+ end
+ end
+
+ def test__inf
+ assert_equal(0, Date::Infinity.new(-1) <=> Date::Infinity.new(-1))
+ assert_equal(-1, Date::Infinity.new(-1) <=> Date::Infinity.new(+1))
+ assert_equal(-1, Date::Infinity.new(-1) <=> 0)
+
+ assert_equal(1, Date::Infinity.new(+1) <=> Date::Infinity.new(-1))
+ assert_equal(0, Date::Infinity.new(+1) <=> Date::Infinity.new(+1))
+ assert_equal(1, Date::Infinity.new(+1) <=> 0)
+
+ assert_equal(1, 0 <=> Date::Infinity.new(-1))
+ assert_equal(-1, 0 <=> Date::Infinity.new(+1))
+ assert_equal(0, 0 <=> 0)
+
+ assert_equal(0, Date::ITALY <=> Date::ITALY)
+ assert_equal(-1, Date::ITALY <=> Date::ENGLAND)
+ assert_equal(-1, Date::ITALY <=> Date::JULIAN)
+ assert_equal(1, Date::ITALY <=> Date::GREGORIAN)
+
+ assert_equal(1, Date::ENGLAND <=> Date::ITALY)
+ assert_equal(0, Date::ENGLAND <=> Date::ENGLAND)
+ assert_equal(-1, Date::ENGLAND <=> Date::JULIAN)
+ assert_equal(1, Date::ENGLAND <=> Date::GREGORIAN)
+
+ assert_equal(1, Date::JULIAN <=> Date::ITALY)
+ assert_equal(1, Date::JULIAN <=> Date::ENGLAND)
+ assert_equal(0, Date::JULIAN <=> Date::JULIAN)
+ assert_equal(1, Date::JULIAN <=> Date::GREGORIAN)
+
+ assert_equal(-1, Date::GREGORIAN <=> Date::ITALY)
+ assert_equal(-1, Date::GREGORIAN <=> Date::ENGLAND)
+ assert_equal(-1, Date::GREGORIAN <=> Date::JULIAN)
+ assert_equal(0, Date::GREGORIAN <=> Date::GREGORIAN)
+ end
+
+ def test_ordinal__julian
+ for j in @from..@to
+ m, d, y = julian_from_absolute(absolute_from_julian_day_number(j))
+ j0 = julian_day_number_from_absolute(absolute_from_julian(12, 31, y - 1))
+ j2 = julian_day_number_from_absolute(absolute_from_julian(m, d, y))
+ assert_equal(j, j2)
+ oy, od = Date.__send__(:jd_to_ordinal, j, Date::JULIAN)
+ assert_equal(y, oy)
+ assert_equal(j2 - j0, od)
+ oj = Date.__send__(:ordinal_to_jd, oy, od, Date::JULIAN)
+ assert_equal(j, oj)
+ end
+ end
+
+ def test_ordinal__gregorian
+ for j in @from..@to
+ m, d, y = gregorian_from_absolute(absolute_from_julian_day_number(j))
+ j0 =
+ julian_day_number_from_absolute(absolute_from_gregorian(12, 31, y - 1))
+ j2 = julian_day_number_from_absolute(absolute_from_gregorian(m, d, y))
+ assert_equal(j, j2)
+ oy, od = Date.__send__(:jd_to_ordinal, j, Date::GREGORIAN)
+ assert_equal(y, oy)
+ assert_equal(j2 - j0, od)
+ oj = Date.__send__(:ordinal_to_jd, oy, od, Date::GREGORIAN)
+ assert_equal(j, oj)
+ end
+ end
+
+ def test_civil__julian
+ for j in @from..@to
+ m, d, y = julian_from_absolute(absolute_from_julian_day_number(j))
+ j2 = julian_day_number_from_absolute(absolute_from_julian(m, d, y))
+ assert_equal(j2, j)
+ cy, cm, cd = Date.__send__(:jd_to_civil, j, Date::JULIAN)
+ assert_equal(y, cy)
+ assert_equal(m, cm)
+ assert_equal(d, cd)
+ cj = Date.__send__(:civil_to_jd, cy, cm, cd, Date::JULIAN)
+ assert_equal(j, cj)
+ end
+ end
+
+ def test_civil__gregorian
+ for j in @from..@to
+ m, d, y = gregorian_from_absolute(absolute_from_julian_day_number(j))
+ j2 = julian_day_number_from_absolute(absolute_from_gregorian(m, d, y))
+ assert_equal(j2, j)
+ cy, cm, cd = Date.__send__(:jd_to_civil, j, Date::GREGORIAN)
+ assert_equal(y, cy)
+ assert_equal(m, cm)
+ assert_equal(d, cd)
+ cj = Date.__send__(:civil_to_jd, cy, cm, cd, Date::GREGORIAN)
+ assert_equal(j, cj)
+ end
+ end
+
+ def test_commercial__gregorian
+ for j in @from..@to
+ w, d, y = iso_from_absolute(absolute_from_julian_day_number(j))
+ j2 = julian_day_number_from_absolute(absolute_from_iso(w, d, y))
+ assert_equal(j2, j)
+ cy, cw, cd = Date.__send__(:jd_to_commercial, j, Date::GREGORIAN)
+ assert_equal(y, cy)
+ assert_equal(w, cw)
+ assert_equal(d, cd)
+ cj = Date.__send__(:commercial_to_jd, cy, cw, cd, Date::GREGORIAN)
+ assert_equal(j, cj)
+ end
+ end
+
+ def test_weeknum
+ for j in @from..@to
+ for k in 0..1
+ wy, ww, wd = Date.__send__(:jd_to_weeknum, j, k, Date::GREGORIAN)
+ wj = Date.__send__(:weeknum_to_jd, wy, ww, wd, k, Date::GREGORIAN)
+ assert_equal(j, wj)
+ end
+ end
+ end
+
+ def test_weeknum__2
+ for j in @from4t..@to4t
+ d = Date.jd(j)
+ t = Time.mktime(d.year, d.mon, d.mday)
+ [
+ '%Y %U %w',
+ '%Y %U %u',
+ '%Y %W %w',
+ '%Y %W %u'
+ ].each do |fmt|
+ s = t.strftime(fmt)
+ d2 = Date.strptime(s, fmt)
+ assert_equal(j, d2.jd)
+ end
+ end
+ end
+
+ def test_nth_kday
+ skip unless (Date.respond_to?(:nth_kday_to_jd, true) &&
+ Date.respond_to?(:jd_to_nth_kday, true))
+ for y in 1601..2401
+ for m in 1..12
+ for n in -5..5
+ next if n == 0
+ for k in 0..6
+ j = julian_day_number_from_absolute(Nth_Kday(n, k, m, y))
+ j2 = Date.__send__(:nth_kday_to_jd, y, m, n, k, Date::GREGORIAN)
+ assert_equal(j, j2)
+
+ d1 = Date.__send__(:jd_to_nth_kday, j2, Date::GREGORIAN)
+ j3 = Date.__send__(:nth_kday_to_jd, *d1)
+ assert_equal(j, j3)
+ end
+ end
+ end
+ end
+ end
+
+ def test_jd
+ assert_equal(1 << 33, Date.jd(1 << 33).jd)
+ end
+
+ def test_mjd
+ skip unless Date.respond_to?(:mjd_to_jd, true)
+ jd = Date.__send__(:mjd_to_jd, 51321)
+ mjd = Date.__send__(:jd_to_mjd, jd)
+ assert_equal(51321, mjd)
+ end
+
+ def test_ld
+ skip unless Date.respond_to?(:ld_to_jd, true)
+ jd = Date.__send__(:ld_to_jd, 152162)
+ ld = Date.__send__(:jd_to_ld, jd)
+ assert_equal(152162, ld)
+ end
+
+ def test_wday
+ skip unless Date.respond_to?(:jd_to_wday, true)
+ assert_equal(4, Date.__send__(:jd_to_wday, 3))
+ assert_equal(3, Date.__send__(:jd_to_wday, 2))
+ assert_equal(2, Date.__send__(:jd_to_wday, 1))
+ assert_equal(1, Date.__send__(:jd_to_wday, 0))
+ assert_equal(0, Date.__send__(:jd_to_wday, -1))
+ assert_equal(6, Date.__send__(:jd_to_wday, -2))
+ assert_equal(5, Date.__send__(:jd_to_wday, -3))
+ end
+
+ def test_leap?
+ assert_equal(true, Date.julian_leap?(1900))
+ assert_equal(false, Date.julian_leap?(1999))
+ assert_equal(true, Date.julian_leap?(2000))
+
+ assert_equal(false, Date.gregorian_leap?(1900))
+ assert_equal(false, Date.gregorian_leap?(1999))
+ assert_equal(true, Date.gregorian_leap?(2000))
+
+ assert_equal(Date.leap?(1990), Date.gregorian_leap?(1900))
+ assert_equal(Date.leap?(1999), Date.gregorian_leap?(1999))
+ assert_equal(Date.leap?(2000), Date.gregorian_leap?(2000))
+ end
+
+ def test_valid_jd
+ valid_jd_p = :_valid_jd?
+ skip unless Date.respond_to?(valid_jd_p, true)
+ assert_equal(-1, Date.__send__(valid_jd_p, -1))
+ assert_equal(0, Date.__send__(valid_jd_p, 0))
+ assert_equal(1, Date.__send__(valid_jd_p, 1))
+ assert_equal(2452348, Date.__send__(valid_jd_p, 2452348))
+ end
+
+ def test_valid_ordinal
+ valid_ordinal_p = :_valid_ordinal?
+ skip unless Date.respond_to?(valid_ordinal_p, true)
+ assert_nil(Date.__send__(valid_ordinal_p, 1999,366))
+ assert_equal(2451910, Date.__send__(valid_ordinal_p, 2000,366))
+ assert_nil(Date.__send__(valid_ordinal_p, 1999,-366))
+ assert_equal(2451545, Date.__send__(valid_ordinal_p, 2000,-366))
+ assert_equal(2452275, Date.__send__(valid_ordinal_p, 2001,365))
+ assert_nil(Date.__send__(valid_ordinal_p, 2001,366))
+ assert_equal(Date.__send__(valid_ordinal_p, 2001,1),
+ Date.__send__(valid_ordinal_p, 2001,-365))
+ assert_nil(Date.__send__(valid_ordinal_p, 2001,-366))
+ assert_equal(2452348, Date.__send__(valid_ordinal_p, 2002,73))
+ end
+
+ def test_valid_ordinal__edge
+ valid_ordinal_p = :_valid_ordinal?
+ skip unless Date.respond_to?(valid_ordinal_p, true)
+ (1601..2400).each do |y|
+ d = if Date.leap?(y) then 366 else 365 end
+ assert_not_nil(Date.__send__(valid_ordinal_p, y,d))
+ assert_nil(Date.__send__(valid_ordinal_p, y,d + 1))
+ assert_not_nil(Date.__send__(valid_ordinal_p, y,-d))
+ assert_nil(Date.__send__(valid_ordinal_p, y,-(d + 1)))
+ end
+ end
+
+ # October 1582
+ # S M Tu W Th F S
+ # 274 275 276 277 288 289
+ # 290 291 292 293 294 295 296
+ # 297 298 299 300 301 302 303
+ # 304
+
+ # October 1582
+ # S M Tu W Th F S
+ # -92 -91 -90 -89 -78 -77
+ # -76 -75 -74 -73 -72 -71 -70
+ # -69 -68 -67 -66 -65 -64 -63
+ # -62
+
+ def test_valid_ordinal__italy
+ valid_ordinal_p = :_valid_ordinal?
+ skip unless Date.respond_to?(valid_ordinal_p, true)
+ (1..355).each do |d|
+ assert_not_nil(Date.__send__(valid_ordinal_p, 1582,d,Date::ITALY))
+ end
+ (356..365).each do |d|
+ assert_nil(Date.__send__(valid_ordinal_p, 1582,d,Date::ITALY))
+ end
+ end
+
+ # September 1752
+ # S M Tu W Th F S
+ # 245 246 258 259 260
+ # 261 262 263 264 265 266 267
+ # 268 269 270 271 272 273 274
+
+ def test_valid_ordinal__england
+ valid_ordinal_p = :_valid_ordinal?
+ skip unless Date.respond_to?(valid_ordinal_p, true)
+ (1..355).each do |d|
+ assert_not_nil(Date.__send__(valid_ordinal_p, 1752,d,Date::ENGLAND))
+ end
+ (356..366).each do |d|
+ assert_nil(Date.__send__(valid_ordinal_p, 1752,d,Date::ENGLAND))
+ end
+ end
+
+ def test_valid_civil
+ valid_civil_p = :_valid_civil?
+ skip unless Date.respond_to?(valid_civil_p, true)
+ assert_nil(Date.__send__(valid_civil_p, 1999,2,29))
+ assert_equal(2451604, Date.__send__(valid_civil_p, 2000,2,29))
+ assert_nil(Date.__send__(valid_civil_p, 1999,2,-29))
+ assert_equal(2451576, Date.__send__(valid_civil_p, 2000,2,-29))
+ assert_equal(2451941, Date.__send__(valid_civil_p, 2001,1,31))
+ assert_nil(Date.__send__(valid_civil_p, 2001,1,32))
+ assert_equal(Date.__send__(valid_civil_p, 2001,1,1),
+ Date.__send__(valid_civil_p, 2001,1,-31))
+ assert_nil(Date.__send__(valid_civil_p, 2001,1,-32))
+ assert_equal(2452348, Date.__send__(valid_civil_p, 2002,3,14))
+ assert_nil(Date.__send__(valid_civil_p, 2010,-13,-1))
+ end
+
+ def test_valid_civil__edge
+ valid_civil_p = :_valid_civil?
+ skip unless Date.respond_to?(valid_civil_p, true)
+ (1601..2400).each do |y|
+ d = if Date.leap?(y) then 29 else 28 end
+ assert_not_nil(Date.__send__(valid_civil_p, y,2,d))
+ assert_nil(Date.__send__(valid_civil_p, y,2,d + 1))
+ assert_not_nil(Date.__send__(valid_civil_p, y,2,-d))
+ assert_nil(Date.__send__(valid_civil_p, y,2,-(d + 1)))
+ end
+ end
+
+ # October 1582
+ # S M Tu W Th F S
+ # 1 2 3 4 15 16
+ # 17 18 19 20 21 22 23
+ # 24 25 26 27 28 29 30
+ # 31
+
+ def test_valid_civil__italy
+ valid_civil_p = :_valid_civil?
+ skip unless Date.respond_to?(valid_civil_p, true)
+ (1..4).each do |d|
+ assert_not_nil(Date.__send__(valid_civil_p, 1582,10,d,Date::ITALY))
+ end
+ (5..14).each do |d|
+ assert_nil(Date.__send__(valid_civil_p, 1582,10,d,Date::ITALY))
+ end
+ (15..31).each do |d|
+ assert_not_nil(Date.__send__(valid_civil_p, 1582,10,d,Date::ITALY))
+ end
+ (32..100).each do |d|
+ assert_nil(Date.__send__(valid_civil_p, 1582,10,d,Date::ITALY))
+ end
+ (-31..-22).each do |d|
+ assert_nil(Date.__send__(valid_civil_p, 1582,10,d,Date::ITALY))
+ end
+ (-21..-1).each do |d|
+ assert_not_nil(Date.__send__(valid_civil_p, 1582,10,d,Date::ITALY))
+ end
+ end
+
+ # September 1752
+ # S M Tu W Th F S
+ # 1 2 14 15 16
+ # 17 18 19 20 21 22 23
+ # 24 25 26 27 28 29 30
+
+ def test_valid_civil__england
+ valid_civil_p = :_valid_civil?
+ skip unless Date.respond_to?(valid_civil_p, true)
+ (1..2).each do |d|
+ assert_not_nil(Date.__send__(valid_civil_p, 1752,9,d,Date::ENGLAND))
+ end
+ (3..13).each do |d|
+ assert_nil(Date.__send__(valid_civil_p, 1752,9,d,Date::ENGLAND))
+ end
+ (14..30).each do |d|
+ assert_not_nil(Date.__send__(valid_civil_p, 1752,9,d,Date::ENGLAND))
+ end
+ (31..100).each do |d|
+ assert_nil(Date.__send__(valid_civil_p, 1752,9,d,Date::ENGLAND))
+ end
+ (-31..-20).each do |d|
+ assert_nil(Date.__send__(valid_civil_p, 1752,9,d,Date::ENGLAND))
+ end
+ (-19..-1).each do |d|
+ assert_not_nil(Date.__send__(valid_civil_p, 1752,9,d,Date::ENGLAND))
+ end
+ end
+
+ def test_valid_commercial
+ valid_commercial_p = :_valid_commercial?
+ skip unless Date.respond_to?(valid_commercial_p, true)
+ assert_nil(Date.__send__(valid_commercial_p, 1999,53,1))
+ assert_equal(2453367, Date.__send__(valid_commercial_p, 2004,53,1))
+ assert_nil(Date.__send__(valid_commercial_p, 1999,-53,-1))
+ assert_equal(2453009, Date.__send__(valid_commercial_p, 2004,-53,-1))
+ assert_equal(2452348, Date.__send__(valid_commercial_p, 2002,11,4))
+ end
+
+ def test_valid_weeknum
+ valid_weeknum_p = :_valid_weeknum?
+ skip unless Date.respond_to?(valid_weeknum_p, true)
+ assert_nil(Date.__send__(valid_weeknum_p, 1999,53,0, 0))
+ assert_equal(2454101, Date.__send__(valid_weeknum_p, 2006,53,0, 0))
+ assert_nil(Date.__send__(valid_weeknum_p, 1999,-53,-1, 0))
+ assert_equal(2453743, Date.__send__(valid_weeknum_p, 2006,-53,-1, 0))
+ assert_equal(2452355, Date.__send__(valid_weeknum_p, 2002,11,4, 0))
+ assert_nil(Date.__send__(valid_weeknum_p, 1999,53,0, 1))
+ assert_equal(2454101, Date.__send__(valid_weeknum_p, 2006,52,6, 1))
+ assert_nil(Date.__send__(valid_weeknum_p, 1999,-53,-1, 1))
+ assert_equal(2453743, Date.__send__(valid_weeknum_p, 2006,-52,-2, 1))
+ assert_equal(2452355, Date.__send__(valid_weeknum_p, 2002,11,3, 1))
+ end
+
+ def test_valid_nth_kday
+ valid_nth_kday_p = :_valid_nth_kday?
+ skip unless Date.respond_to?(valid_nth_kday_p, true)
+ assert_nil(Date.__send__(valid_nth_kday_p, 1992,2, 5,0))
+ assert_equal(2448682, Date.__send__(valid_nth_kday_p, 1992,2, 5,6))
+ assert_equal(2448682, Date.__send__(valid_nth_kday_p, 1992,2, 5,-1))
+ assert_equal(2448682, Date.__send__(valid_nth_kday_p, 1992,2, -1,6))
+ assert_equal(2448682, Date.__send__(valid_nth_kday_p, 1992,2, -1,-1))
+ end
+
+ def test_valid_time
+ valid_time_p = :_valid_time?
+ skip unless Date.respond_to?(valid_time_p, true)
+ assert_equal(Rational(0), DateTime.__send__(valid_time_p, 0,0,0))
+ assert_nil(DateTime.__send__(valid_time_p, 25,59,59))
+ assert_nil(DateTime.__send__(valid_time_p, 23,60,59))
+ assert_nil(DateTime.__send__(valid_time_p, 23,59,60))
+ assert_equal(Rational(86399, 86400),
+ DateTime.__send__(valid_time_p, 23,59,59))
+ assert_equal(Rational(86399, 86400),
+ DateTime.__send__(valid_time_p, -1,-1,-1))
+ assert_equal(Rational(1), DateTime.__send__(valid_time_p, 24,0,0))
+ assert_nil(DateTime.__send__(valid_time_p, 24,0,1))
+ assert_nil(DateTime.__send__(valid_time_p, 24,1,0))
+ assert_nil(DateTime.__send__(valid_time_p, 24,1,1))
+ end
+
+end if defined?(Calendar)
diff --git a/test/date/test_date_conv.rb b/test/date/test_date_conv.rb
index d41ff45d85..5c295daba6 100644
--- a/test/date/test_date_conv.rb
+++ b/test/date/test_date_conv.rb
@@ -48,24 +48,6 @@ class TestDateConv < Test::Unit::TestCase
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.usec])
end
- def test_to_time_to_date_roundtrip__from_gregorian_date
- d = Date.new(1582, 10, 15)
- t = d.to_time
- assert_equal([1582, 10, 15, 0, 0, 0, 0],
- [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.usec])
- assert_equal(d, t.to_date)
- assert_equal(d.jd, t.to_date.jd)
- end
-
- def test_to_time_to_date_roundtrip__from_julian_date
- d = Date.new(1582, 10, 4)
- t = d.to_time
- assert_equal([1582, 10, 14, 0, 0, 0, 0],
- [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.usec])
- assert_equal(d, t.to_date)
- assert_equal(d.jd, t.to_date.jd)
- end
-
def test_to_time__from_datetime
d = DateTime.new(2004, 9, 19, 1, 2, 3, 8.to_r/24) + 456789.to_r/86400000000
t = d.to_time
diff --git a/test/date/test_date_marshal.rb b/test/date/test_date_marshal.rb
index fa8b2d91f8..99a7239f95 100644
--- a/test/date/test_date_marshal.rb
+++ b/test/date/test_date_marshal.rb
@@ -30,30 +30,13 @@ class TestDateMarshal < Test::Unit::TestCase
a = d.marshal_dump
d.freeze
assert(d.frozen?)
- expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
- assert_raise(expected_error){d.marshal_load(a)}
+ assert_raise(FrozenError){d.marshal_load(a)}
d = DateTime.now
a = d.marshal_dump
d.freeze
assert(d.frozen?)
- expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
- assert_raise(expected_error){d.marshal_load(a)}
-
- d = Date.new + 1/2r + 2304/65437r/86400
- m = Marshal.dump(d)
- d2 = Marshal.load(m)
- assert_equal(d, d2)
- assert_equal(d.start, d2.start)
- assert_instance_of(String, d2.to_s)
+ assert_raise(FrozenError){d.marshal_load(a)}
end
- def test_memsize
- require 'objspace'
- t = DateTime.new(2018, 11, 13)
- size = ObjectSpace.memsize_of(t)
- t2 = Marshal.load(Marshal.dump(t))
- assert_equal(t, t2)
- assert_equal(size, ObjectSpace.memsize_of(t2), "not reallocated but memsize changed")
- end
end
diff --git a/test/date/test_date_new.rb b/test/date/test_date_new.rb
index eddeeff820..fe9a631ad0 100644
--- a/test/date/test_date_new.rb
+++ b/test/date/test_date_new.rb
@@ -27,61 +27,11 @@ class TestDateNew < Test::Unit::TestCase
end
def test_jd__ex
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.jd(0, 23,59,60,0)
end
end
- def test_valid_with_invalid_types
- o = Object.new
- assert_equal(false, Date.valid_jd?(o))
- assert_equal(false, Date.valid_civil?(o, 1, 1))
- assert_equal(false, Date.valid_civil?(1, o, 1))
- assert_equal(false, Date.valid_civil?(1, 1, o))
- assert_equal(false, Date.valid_ordinal?(o, 1))
- assert_equal(false, Date.valid_ordinal?(1, o))
- assert_equal(false, Date.valid_commercial?(o, 1, 1))
- assert_equal(false, Date.valid_commercial?(1, o, 1))
- assert_equal(false, Date.valid_commercial?(1, 1, o))
- end
-
- def test_invalid_types
- o = Object.new
- assert_raise(TypeError) { Date.julian_leap?(o) }
- assert_raise(TypeError) { Date.gregorian_leap?(o) }
- assert_raise(TypeError) { Date.jd(o) }
- assert_raise(TypeError) { Date.new(o) }
- assert_raise(TypeError) { Date.new(1, o) }
- assert_raise(TypeError) { Date.new(1, 1, o) }
- assert_raise(TypeError) { Date.ordinal(o) }
- assert_raise(TypeError) { Date.ordinal(1, o) }
- assert_raise(TypeError) { Date.commercial(o) }
- assert_raise(TypeError) { Date.commercial(1, o) }
- assert_raise(TypeError) { Date.commercial(1, 1, o) }
-
- assert_raise(TypeError) { DateTime.jd(o) }
- assert_raise(TypeError) { DateTime.jd(1, o) }
- assert_raise(TypeError) { DateTime.jd(1, 1, o) }
- assert_raise(TypeError) { DateTime.jd(1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.new(o) }
- assert_raise(TypeError) { DateTime.new(1, o) }
- assert_raise(TypeError) { DateTime.new(1, 1, o) }
- assert_raise(TypeError) { DateTime.new(1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.new(1, 1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.new(1, 1, 1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.ordinal(o) }
- assert_raise(TypeError) { DateTime.ordinal(1, o) }
- assert_raise(TypeError) { DateTime.ordinal(1, 1, o) }
- assert_raise(TypeError) { DateTime.ordinal(1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.ordinal(1, 1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.commercial(o) }
- assert_raise(TypeError) { DateTime.commercial(1, o) }
- assert_raise(TypeError) { DateTime.commercial(1, 1, o) }
- assert_raise(TypeError) { DateTime.commercial(1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.commercial(1, 1, 1, 1, o) }
- assert_raise(TypeError) { DateTime.commercial(1, 1, 1, 1, 1, o) }
- end
-
def test_ordinal
d = Date.ordinal
dt = DateTime.ordinal
@@ -118,10 +68,10 @@ class TestDateNew < Test::Unit::TestCase
end
def test_ordinal__ex
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.ordinal(2001,366)
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.ordinal(2001,365, 23,59,60, 0)
end
end
@@ -165,10 +115,6 @@ class TestDateNew < Test::Unit::TestCase
assert_equal([2001, 2, 3, 4, 5, 6, 0],
[d.year, d.mon, d.mday, d.hour, d.min, d.sec, d.offset])
assert_equal(1.to_r/2, d.sec_fraction)
-
- d = DateTime.civil(2001, 2)
- assert_equal([2001, 2, 1, 0, 0, 0, 0],
- [d.year, d.mon, d.mday, d.hour, d.min, d.sec, d.offset])
end
def test_civil__neg
@@ -181,13 +127,13 @@ class TestDateNew < Test::Unit::TestCase
end
def test_civil__ex
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.civil(2001,2,29)
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.civil(2001,2,28, 23,59,60, 0)
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.civil(2001,2,28, 24,59,59, 0)
end
end
@@ -248,55 +194,55 @@ class TestDateNew < Test::Unit::TestCase
end
def test_commercial__ex
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.commercial(1997,53,1)
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.commercial(1997,52,1, 23,59,60, 0)
end
end
def test_weeknum
- d = Date.weeknum
- dt = DateTime.weeknum
+ d = Date.__send__(:weeknum)
+ dt = DateTime.__send__(:weeknum)
assert_equal([-4712, 1, 1], [d.year, d.mon, d.mday])
assert_equal([-4712, 1, 1], [dt.year, dt.mon, dt.mday])
assert_equal([0, 0, 0], [dt.hour, dt.min, dt.sec])
- d = Date.weeknum(2002,11,4, 0)
+ d = Date.__send__(:weeknum, 2002,11,4, 0)
assert_equal(2452355, d.jd)
- d = DateTime.weeknum(2002,11,4, 0, 11,22,33)
+ d = DateTime.__send__(:weeknum, 2002,11,4, 0, 11,22,33)
assert_equal(2452355, d.jd)
assert_equal([11,22,33], [d.hour, d.min, d.sec])
- assert_raise(Date::Error) do
- Date.weeknum(1999,53,0, 0)
+ assert_raise(ArgumentError) do
+ Date.__send__(:weeknum, 1999,53,0, 0)
end
- assert_raise(Date::Error) do
- Date.weeknum(1999,-53,-1, 0)
+ assert_raise(ArgumentError) do
+ Date.__send__(:weeknum, 1999,-53,-1, 0)
end
end if Date.respond_to?(:weeknum, true)
def test_nth_kday
- d = Date.nth_kday
- dt = DateTime.nth_kday
+ d = Date.__send__(:nth_kday)
+ dt = DateTime.__send__(:nth_kday)
assert_equal([-4712, 1, 1], [d.year, d.mon, d.mday])
assert_equal([-4712, 1, 1], [dt.year, dt.mon, dt.mday])
assert_equal([0, 0, 0], [dt.hour, dt.min, dt.sec])
- d = Date.nth_kday(1992,2, 5,6)
+ d = Date.__send__(:nth_kday, 1992,2, 5,6)
assert_equal(2448682, d.jd)
- d = DateTime.nth_kday(1992,2, 5,6, 11,22,33)
+ d = DateTime.__send__(:nth_kday, 1992,2, 5,6, 11,22,33)
assert_equal(2448682, d.jd)
assert_equal([11,22,33], [d.hour, d.min, d.sec])
- assert_raise(Date::Error) do
- Date.nth_kday(2006,5, 5,0)
+ assert_raise(ArgumentError) do
+ Date.__send__(:nth_kday, 2006,5, 5,0)
end
- assert_raise(Date::Error) do
- Date.nth_kday(2006,5, -5,0)
+ assert_raise(ArgumentError) do
+ Date.__send__(:nth_kday, 2006,5, -5,0)
end
end if Date.respond_to?(:nth_kday, true)
@@ -321,12 +267,4 @@ class TestDateNew < Test::Unit::TestCase
assert_in_delta(t, t2, t - z + 2)
end
- def test_memsize
- require 'objspace'
- t = DateTime.now
- size = ObjectSpace.memsize_of(t)
- t.__send__(:initialize_copy, Date.today)
- assert_instance_of(DateTime, t)
- assert_equal(size, ObjectSpace.memsize_of(t), "not reallocated but memsize changed")
- end
end
diff --git a/test/date/test_date_parse.rb b/test/date/test_date_parse.rb
index 34a672b069..ac0eb85ca7 100644
--- a/test/date/test_date_parse.rb
+++ b/test/date/test_date_parse.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'test/unit'
require 'date'
-require 'timeout'
class TestDateParse < Test::Unit::TestCase
@@ -25,7 +24,6 @@ class TestDateParse < Test::Unit::TestCase
[['Sat Aug 28 02:29:34 JST 02',true],[2002,8,28,2,29,34,'JST',9*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 JST 0002',false],[2,8,28,2,29,34,'JST',9*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 JST 0002',true],[2,8,28,2,29,34,'JST',9*3600,6], __LINE__],
- [['Sat Aug 28 02:29:34 AEST 0002',true],[2,8,28,2,29,34,'AEST',10*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 GMT+09 0002',false],[2,8,28,2,29,34,'GMT+09',9*3600,6], __LINE__],
[['Sat Aug 28 02:29:34 GMT+0900 0002',false],[2,8,28,2,29,34,'GMT+0900',9*3600,6], __LINE__],
@@ -123,8 +121,6 @@ class TestDateParse < Test::Unit::TestCase
[['S40.05.23T23:55:21-09:00',false],[1965,5,23,23,55,21,'-09:00',-9*3600,nil], __LINE__],
[['H11.05.23 23:55:21Z',false],[1999,5,23,23,55,21,'Z',0,nil], __LINE__],
[['H11.05.23T23:55:21Z',false],[1999,5,23,23,55,21,'Z',0,nil], __LINE__],
- [['H31.04.30 23:55:21Z',false],[2019,4,30,23,55,21,'Z',0,nil], __LINE__],
- [['H31.04.30T23:55:21Z',false],[2019,4,30,23,55,21,'Z',0,nil], __LINE__],
# ofx date
[['19990523235521',false],[1999,5,23,23,55,21,nil,nil,nil], __LINE__],
@@ -209,7 +205,7 @@ class TestDateParse < Test::Unit::TestCase
[['08-DEC-0088',false],[88,12,8,nil,nil,nil,nil,nil,nil], __LINE__],
[['08-DEC-0088',true],[88,12,8,nil,nil,nil,nil,nil,nil], __LINE__],
- # swapped vms
+ # swaped vms
[['DEC-08-1988',false],[1988,12,8,nil,nil,nil,nil,nil,nil], __LINE__],
[['JAN-31-1999',false],[1999,1,31,nil,nil,nil,nil,nil,nil], __LINE__],
[['JAN-31--1999',false],[-1999,1,31,nil,nil,nil,nil,nil,nil], __LINE__],
@@ -420,13 +416,7 @@ class TestDateParse < Test::Unit::TestCase
a[1] = -1
a[2] = h[:yday]
end
- l = format('<failed at line %d>', l)
- assert_equal(y, a, l)
- if y[6]
- h = Date._parse(x[0].dup, *x[1..-1])
- assert_equal(y[6], h[:zone], l)
- assert_equal(y[6].encoding, h[:zone].encoding, l)
- end
+ assert_equal(y, a, format('<failed at line %d>', l))
end
end
@@ -661,39 +651,27 @@ class TestDateParse < Test::Unit::TestCase
end
def test_parse__ex
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.parse('')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.parse('')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.parse('2001-02-29')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.parse('2001-02-29T23:59:60')
end
- assert_nothing_raised(Date::Error) do
+ assert_nothing_raised(ArgumentError) do
DateTime.parse('2001-03-01T23:59:60')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.parse('2001-03-01T23:59:61')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.parse('23:55')
end
-
- begin
- Date.parse('')
- rescue ArgumentError => e
- assert e.is_a? Date::Error
- end
-
- begin
- DateTime.parse('')
- rescue ArgumentError => e
- assert e.is_a? Date::Error
- end
end
def test__iso8601
@@ -725,9 +703,6 @@ class TestDateParse < Test::Unit::TestCase
h = Date._iso8601('2001-02-03T04:05:06.07+01:00')
assert_equal([2001, 2, 3, 4, 5, 6, 3600],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._iso8601('2001-02')
- assert_equal([2001, 2],
- h.values_at(:year, :mon))
h = Date._iso8601('010203T040506Z')
assert_equal([2001, 2, 3, 4, 5, 6, 0],
@@ -848,13 +823,6 @@ class TestDateParse < Test::Unit::TestCase
h = Date._iso8601('')
assert_equal({}, h)
-
- h = Date._iso8601(nil)
- assert_equal({}, h)
-
- h = Date._iso8601('01-02-03T04:05:06Z'.to_sym)
- assert_equal([2001, 2, 3, 4, 5, 6, 0],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
def test__rfc3339
@@ -870,13 +838,6 @@ class TestDateParse < Test::Unit::TestCase
h = Date._rfc3339('')
assert_equal({}, h)
-
- h = Date._rfc3339(nil)
- assert_equal({}, h)
-
- h = Date._rfc3339('2001-02-03T04:05:06Z'.to_sym)
- assert_equal([2001, 2, 3, 4, 5, 6, 0],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
def test__xmlschema
@@ -959,13 +920,6 @@ class TestDateParse < Test::Unit::TestCase
h = Date._xmlschema('')
assert_equal({}, h)
-
- h = Date._xmlschema(nil)
- assert_equal({}, h)
-
- h = Date._xmlschema('2001-02-03'.to_sym)
- assert_equal([2001, 2, 3, nil, nil, nil, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
def test__rfc2822
@@ -998,13 +952,6 @@ class TestDateParse < Test::Unit::TestCase
h = Date._rfc2822('')
assert_equal({}, h)
-
- h = Date._rfc2822(nil)
- assert_equal({}, h)
-
- h = Date._rfc2822('Sat, 3 Feb 2001 04:05:06 UT'.to_sym)
- assert_equal([2001, 2, 3, 4, 5, 6, 0],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
def test__httpdate
@@ -1025,13 +972,6 @@ class TestDateParse < Test::Unit::TestCase
h = Date._httpdate('')
assert_equal({}, h)
-
- h = Date._httpdate(nil)
- assert_equal({}, h)
-
- h = Date._httpdate('Sat, 03 Feb 2001 04:05:06 GMT'.to_sym)
- assert_equal([2001, 2, 3, 4, 5, 6, 0],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
def test__jisx0301
@@ -1044,15 +984,6 @@ class TestDateParse < Test::Unit::TestCase
h = Date._jisx0301('S63.02.03')
assert_equal([1988, 2, 3, nil, nil, nil, nil],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.04.30')
- assert_equal([2019, 4, 30, nil, nil, nil, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.05.01')
- assert_equal([2019, 5, 1, nil, nil, nil, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('R01.05.01')
- assert_equal([2019, 5, 1, nil, nil, nil, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
h = Date._jisx0301('H13.02.03T04:05:06')
assert_equal([2001, 2, 3, 4, 5, 6, nil],
@@ -1067,54 +998,8 @@ class TestDateParse < Test::Unit::TestCase
assert_equal([2001, 2, 3, 4, 5, 6, 3600],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.04.30T04:05:06')
- assert_equal([2019, 4, 30, 4, 5, 6, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.04.30T04:05:06,07')
- assert_equal([2019, 4, 30, 4, 5, 6, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.04.30T04:05:06Z')
- assert_equal([2019, 4, 30, 4, 5, 6, 0],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.04.30T04:05:06.07+0100')
- assert_equal([2019, 4, 30, 4, 5, 6, 3600],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
-
- h = Date._jisx0301('H31.05.01T04:05:06')
- assert_equal([2019, 5, 1, 4, 5, 6, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.05.01T04:05:06,07')
- assert_equal([2019, 5, 1, 4, 5, 6, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.05.01T04:05:06Z')
- assert_equal([2019, 5, 1, 4, 5, 6, 0],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('H31.05.01T04:05:06.07+0100')
- assert_equal([2019, 5, 1, 4, 5, 6, 3600],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
-
- h = Date._jisx0301('R01.05.01T04:05:06')
- assert_equal([2019, 5, 1, 4, 5, 6, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('R01.05.01T04:05:06,07')
- assert_equal([2019, 5, 1, 4, 5, 6, nil],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('R01.05.01T04:05:06Z')
- assert_equal([2019, 5, 1, 4, 5, 6, 0],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
- h = Date._jisx0301('R01.05.01T04:05:06.07+0100')
- assert_equal([2019, 5, 1, 4, 5, 6, 3600],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
-
h = Date._jisx0301('')
assert_equal({}, h)
-
- h = Date._jisx0301(nil)
- assert_equal({}, h)
-
- h = Date._jisx0301('H13.02.03T04:05:06.07+0100'.to_sym)
- assert_equal([2001, 2, 3, 4, 5, 6, 3600],
- h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
def test_iso8601
@@ -1198,33 +1083,9 @@ class TestDateParse < Test::Unit::TestCase
assert_equal(Date.new(2001,2,3), d)
assert_equal(Date::ITALY + 10, d.start)
- d = Date.jisx0301('H31.04.30', Date::ITALY + 10)
- assert_equal(Date.new(2019,4,30), d)
- assert_equal(Date::ITALY + 10, d.start)
-
- d = Date.jisx0301('H31.05.01', Date::ITALY + 10)
- assert_equal(Date.new(2019,5,1), d)
- assert_equal(Date::ITALY + 10, d.start)
-
- d = Date.jisx0301('R01.05.01', Date::ITALY + 10)
- assert_equal(Date.new(2019,5,1), d)
- assert_equal(Date::ITALY + 10, d.start)
-
d = DateTime.jisx0301('H13.02.03T04:05:06+07:00', Date::ITALY + 10)
assert_equal(DateTime.new(2001,2,3,4,5,6,'+07:00'), d)
assert_equal(Date::ITALY + 10, d.start)
-
- d = DateTime.jisx0301('H31.04.30T04:05:06+07:00', Date::ITALY + 10)
- assert_equal(DateTime.new(2019,4,30,4,5,6,'+07:00'), d)
- assert_equal(Date::ITALY + 10, d.start)
-
- d = DateTime.jisx0301('H31.05.01T04:05:06+07:00', Date::ITALY + 10)
- assert_equal(DateTime.new(2019,5,1,4,5,6,'+07:00'), d)
- assert_equal(Date::ITALY + 10, d.start)
-
- d = DateTime.jisx0301('R01.05.01T04:05:06+07:00', Date::ITALY + 10)
- assert_equal(DateTime.new(2019,5,1,4,5,6,'+07:00'), d)
- assert_equal(Date::ITALY + 10, d.start)
end
def test_given_string
@@ -1259,44 +1120,6 @@ class TestDateParse < Test::Unit::TestCase
s0 = s.dup
assert_not_equal({}, Date._jisx0301(s))
assert_equal(s0, s)
-
- s = 'H31.04.30T04:05:06,07Z'
- s0 = s.dup
- assert_not_equal({}, Date._jisx0301(s))
- assert_equal(s0, s)
-
- s = 'H31.05.01T04:05:06,07Z'
- s0 = s.dup
- assert_not_equal({}, Date._jisx0301(s))
- assert_equal(s0, s)
end
- def test_length_limit
- assert_raise(ArgumentError) { Date._parse("1" * 1000) }
- assert_raise(ArgumentError) { Date._iso8601("1" * 1000) }
- assert_raise(ArgumentError) { Date._rfc3339("1" * 1000) }
- assert_raise(ArgumentError) { Date._xmlschema("1" * 1000) }
- assert_raise(ArgumentError) { Date._rfc2822("1" * 1000) }
- assert_raise(ArgumentError) { Date._rfc822("1" * 1000) }
- assert_raise(ArgumentError) { Date._jisx0301("1" * 1000) }
-
- assert_raise(ArgumentError) { Date.parse("1" * 1000) }
- assert_raise(ArgumentError) { Date.iso8601("1" * 1000) }
- assert_raise(ArgumentError) { Date.rfc3339("1" * 1000) }
- assert_raise(ArgumentError) { Date.xmlschema("1" * 1000) }
- assert_raise(ArgumentError) { Date.rfc2822("1" * 1000) }
- assert_raise(ArgumentError) { Date.rfc822("1" * 1000) }
- assert_raise(ArgumentError) { Date.jisx0301("1" * 1000) }
-
- assert_raise(ArgumentError) { DateTime.parse("1" * 1000) }
- assert_raise(ArgumentError) { DateTime.iso8601("1" * 1000) }
- assert_raise(ArgumentError) { DateTime.rfc3339("1" * 1000) }
- assert_raise(ArgumentError) { DateTime.xmlschema("1" * 1000) }
- assert_raise(ArgumentError) { DateTime.rfc2822("1" * 1000) }
- assert_raise(ArgumentError) { DateTime.rfc822("1" * 1000) }
- assert_raise(ArgumentError) { DateTime.jisx0301("1" * 1000) }
-
- assert_raise(ArgumentError) { Date._parse("Jan " + "9" * 1000000) }
- assert_raise(Timeout::Error) { Timeout.timeout(1) { Date._parse("Jan " + "9" * 1000000, limit: nil) } }
- end
end
diff --git a/test/date/test_date_strftime.rb b/test/date/test_date_strftime.rb
index f82874d26d..a33eaa340f 100644
--- a/test/date/test_date_strftime.rb
+++ b/test/date/test_date_strftime.rb
@@ -186,16 +186,13 @@ class TestDateStrftime < Test::Unit::TestCase
(-24..24).collect{|x| '%+.2d' % x}.each do |hh|
%w(00 30).each do |mm|
r = hh + mm
- next if r.end_with?('2430')
+ if r[-4,4] == '2430'
+ r = '+0000'
+ end
d = DateTime.parse(s + hh + mm)
assert_equal(r, d.strftime('%z'))
end
end
- %w[+2430 -2430].each do |r|
- assert_warning(/invalid offset/) do
- DateTime.parse(s + r)
- end
- end
end
def test_strftime_milli
@@ -409,8 +406,6 @@ class TestDateStrftime < Test::Unit::TestCase
assert_equal('S64.01.07', Date.parse('1989-01-07').jisx0301)
assert_equal('H01.01.08', Date.parse('1989-01-08').jisx0301)
assert_equal('H18.09.01', Date.parse('2006-09-01').jisx0301)
- assert_equal('H31.04.30', Date.parse('2019-04-30').jisx0301)
- assert_equal('R01.05.01', Date.parse('2019-05-01').jisx0301)
%w(M06.01.01
M45.07.29
@@ -419,10 +414,7 @@ class TestDateStrftime < Test::Unit::TestCase
S01.12.25
S64.01.07
H01.01.08
- H18.09.01
- H31.04.30
- R01.05.01
- ).each do |s|
+ H18.09.01).each do |s|
assert_equal(s, Date.parse(s).jisx0301)
end
diff --git a/test/date/test_date_strptime.rb b/test/date/test_date_strptime.rb
index fc42ebf7cd..bf3002a24a 100644
--- a/test/date/test_date_strptime.rb
+++ b/test/date/test_date_strptime.rb
@@ -178,8 +178,7 @@ class TestDateStrptime < Test::Unit::TestCase
[['11:33:44 PM AMT', '%I:%M:%S %p %Z'], [nil,nil,nil,23,33,44,'AMT',nil,nil], __LINE__],
[['11:33:44 P.M. AMT', '%I:%M:%S %p %Z'], [nil,nil,nil,23,33,44,'AMT',nil,nil], __LINE__],
- [['fri1feb034pm+5', '%a%d%b%y%H%p%Z'], [2003,2,1,16,nil,nil,'+5',5*3600,5]],
- [['E. Australia Standard Time', '%Z'], [nil,nil,nil,nil,nil,nil,'E. Australia Standard Time',10*3600,nil], __LINE__],
+ [['fri1feb034pm+5', '%a%d%b%y%H%p%Z'], [2003,2,1,16,nil,nil,'+5',5*3600,5]]
].each do |x, y|
h = Date._strptime(*x)
a = h.values_at(:year,:mon,:mday,:hour,:min,:sec,:zone,:offset,:wday)
@@ -460,28 +459,28 @@ class TestDateStrptime < Test::Unit::TestCase
end
def test_strptime__ex
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.strptime('')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.strptime('')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.strptime('2001-02-29', '%F')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.strptime('2001-02-29T23:59:60', '%FT%T')
end
- assert_nothing_raised(Date::Error) do
+ assert_nothing_raised(ArgumentError) do
DateTime.strptime('2001-03-01T23:59:60', '%FT%T')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
DateTime.strptime('2001-03-01T23:59:61', '%FT%T')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.strptime('23:55', '%H:%M')
end
- assert_raise(Date::Error) do
+ assert_raise(ArgumentError) do
Date.strptime('01-31-2011', '%m/%d/%Y')
end
end
diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb
index bdf299e030..16814d44df 100644
--- a/test/date/test_switch_hitter.rb
+++ b/test/date/test_switch_hitter.rb
@@ -187,18 +187,18 @@ class TestSH < Test::Unit::TestCase
d = Date.jd(Rational(2451944))
assert_equal(2451944, d.jd)
d = Date.jd(2451944.5)
- assert_equal(2451944, d.jd)
+ assert_equal([2451944, 12], [d.jd, d.send('hour')])
d = Date.jd(Rational('2451944.5'))
- assert_equal(2451944, d.jd)
+ assert_equal([2451944, 12], [d.jd, d.send('hour')])
d = Date.civil(2001, 2, 3.0)
assert_equal([2001, 2, 3], [d.year, d.mon, d.mday])
d = Date.civil(2001, 2, Rational(3))
assert_equal([2001, 2, 3], [d.year, d.mon, d.mday])
d = Date.civil(2001, 2, 3.5)
- assert_equal([2001, 2, 3], [d.year, d.mon, d.mday])
+ assert_equal([2001, 2, 3, 12], [d.year, d.mon, d.mday, d.send('hour')])
d = Date.civil(2001, 2, Rational('3.5'))
- assert_equal([2001, 2, 3], [d.year, d.mon, d.mday])
+ assert_equal([2001, 2, 3, 12], [d.year, d.mon, d.mday, d.send('hour')])
d = Date.ordinal(2001, 2.0)
assert_equal([2001, 2], [d.year, d.yday])
@@ -266,8 +266,10 @@ class TestSH < Test::Unit::TestCase
end
def test_zone
+ d = Date.new(2001, 2, 3)
+ assert_equal(Encoding::US_ASCII, d.send(:zone).encoding)
d = DateTime.new(2001, 2, 3)
- assert_equal(Encoding::US_ASCII, d.zone.encoding)
+ assert_equal(Encoding::US_ASCII, d.send(:zone).encoding)
end
def test_to_s
@@ -530,15 +532,17 @@ class TestSH < Test::Unit::TestCase
def test_marshal14
s = "\x04\x03u:\x01\x04Date\x01\v\x04\x03[\x01\x02i\x03\xE8i%T"
- d = suppress_warning {Marshal.load(s)}
+ d = Marshal.load(s)
assert_equal(Rational(4903887,2), d.ajd)
+ assert_equal(0, d.send(:offset))
assert_equal(Date::GREGORIAN, d.start)
end
def test_marshal16
s = "\x04\x06u:\tDate\x0F\x04\x06[\ai\x03\xE8i%T"
- d = suppress_warning {Marshal.load(s)}
+ d = Marshal.load(s)
assert_equal(Rational(4903887,2), d.ajd)
+ assert_equal(0, d.send(:offset))
assert_equal(Date::GREGORIAN, d.start)
end
@@ -546,6 +550,7 @@ class TestSH < Test::Unit::TestCase
s = "\x04\bu:\tDateP\x04\b[\bo:\rRational\a:\x0F@numeratori\x03\xCF\xD3J:\x11@denominatori\ai\x00o:\x13Date::Infinity\x06:\a@di\xFA"
d = Marshal.load(s)
assert_equal(Rational(4903887,2), d.ajd)
+ assert_equal(0, d.send(:offset))
assert_equal(Date::GREGORIAN, d.start)
s = "\x04\bu:\rDateTime`\x04\b[\bo:\rRational\a:\x0F@numeratorl+\b\xC9\xB0\x81\xBD\x02\x00:\x11@denominatori\x02\xC0\x12o;\x00\a;\x06i\b;\ai\ro:\x13Date::Infinity\x06:\a@di\xFA"
@@ -559,6 +564,7 @@ class TestSH < Test::Unit::TestCase
s = "\x04\bU:\tDate[\bU:\rRational[\ai\x03\xCF\xD3Ji\ai\x00o:\x13Date::Infinity\x06:\a@di\xFA"
d = Marshal.load(s)
assert_equal(Rational(4903887,2), d.ajd)
+ assert_equal(Rational(0,24), d.send(:offset))
assert_equal(Date::GREGORIAN, d.start)
s = "\x04\bU:\rDateTime[\bU:\rRational[\al+\b\xC9\xB0\x81\xBD\x02\x00i\x02\xC0\x12U;\x06[\ai\bi\ro:\x13Date::Infinity\x06:\a@di\xFA"
@@ -568,6 +574,35 @@ class TestSH < Test::Unit::TestCase
assert_equal(Date::GREGORIAN, d.start)
end
+ def test_taint
+ h = Date._strptime('15:43+09:00', '%R%z')
+ assert_equal(false, h[:zone].tainted?)
+ h = Date._strptime('15:43+09:00'.dup.taint, '%R%z')
+ assert_equal(true, h[:zone].tainted?)
+
+ h = Date._strptime('1;1/0', '%d')
+ assert_equal(false, h[:leftover].tainted?)
+ h = Date._strptime('1;1/0'.dup.taint, '%d')
+ assert_equal(true, h[:leftover].tainted?)
+
+ h = Date._parse('15:43+09:00')
+ assert_equal(false, h[:zone].tainted?)
+ h = Date._parse('15:43+09:00'.dup.taint)
+ assert_equal(true, h[:zone].tainted?)
+
+ s = Date.today.strftime('new 105')
+ assert_equal(false, s.tainted?)
+ s = Date.today.strftime('new 105'.dup.taint)
+ assert_equal(true, s.tainted?)
+ s = Date.today.strftime("new \000 105".dup.taint)
+ assert_equal(true, s.tainted?)
+
+ s = DateTime.now.strftime('super $record')
+ assert_equal(false, s.tainted?)
+ s = DateTime.now.strftime('super $record'.dup.taint)
+ assert_equal(true, s.tainted?)
+ end
+
def test_enc
Date::MONTHNAMES.each do |s|
assert_equal(Encoding::US_ASCII, s.encoding) if s
@@ -626,12 +661,4 @@ class TestSH < Test::Unit::TestCase
assert_equal(true, Date.test_all)
end if defined?(Date.test_all)
- private
-
- def suppress_warning
- $VERBOSE, verbose = nil, $VERBOSE
- yield
- ensure
- $VERBOSE = verbose
- end
end
diff --git a/test/dbm/test_dbm.rb b/test/dbm/test_dbm.rb
index dcbe57851c..874b326404 100644
--- a/test/dbm/test_dbm.rb
+++ b/test/dbm/test_dbm.rb
@@ -63,6 +63,7 @@ if defined? DBM
result = Object.new
assert_same(result, @dbm_rdonly.fetch("bar") {|k| notfound = k; result})
assert_equal("bar", notfound)
+ assert_predicate(notfound, :tainted?)
end
end
@@ -624,10 +625,9 @@ if defined? DBM
end
def test_freeze
- expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
DBM.open("#{@tmproot}/a") {|d|
d.freeze
- assert_raise(expected_error) { d["k"] = "v" }
+ assert_raise(FrozenError) { d["k"] = "v" }
}
end
end
diff --git a/test/did_you_mean/core_ext/test_name_error_extension.rb b/test/did_you_mean/core_ext/test_name_error_extension.rb
deleted file mode 100644
index 9dc08dbde3..0000000000
--- a/test/did_you_mean/core_ext/test_name_error_extension.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require_relative '../helper'
-
-class NameErrorExtensionTest < Test::Unit::TestCase
- SPELL_CHECKERS = DidYouMean::SPELL_CHECKERS
-
- class TestSpellChecker
- def initialize(*); end
- def corrections; ["does_exist"]; end
- end
-
- def setup
- @org, SPELL_CHECKERS['NameError'] = SPELL_CHECKERS['NameError'], TestSpellChecker
-
- @error = assert_raise(NameError){ doesnt_exist }
- end
-
- def teardown
- SPELL_CHECKERS['NameError'] = @org
- end
-
- def test_message
- assert_match(/Did you mean\? does_exist/, @error.to_s)
- assert_match(/Did you mean\? does_exist/, @error.message)
- end
-
- def test_to_s_does_not_make_disruptive_changes_to_error_message
- error = assert_raise(NameError) do
- raise NameError, "uninitialized constant Object"
- end
-
- error.to_s
- assert_equal 1, error.to_s.scan("Did you mean?").count
- end
-
- def test_correctable_error_objects_are_dumpable
- error =
- begin
- Dir.chdir(__dir__) { File.open('test_name_error_extension.rb') { |f| f.sizee } }
- rescue NoMethodError => e
- e
- end
-
- error.to_s
-
- assert_equal "undefined method `sizee' for #<File:test_name_error_extension.rb (closed)>",
- Marshal.load(Marshal.dump(error)).original_message
- end
-end
diff --git a/test/did_you_mean/edit_distance/test_jaro_winkler.rb b/test/did_you_mean/edit_distance/test_jaro_winkler.rb
deleted file mode 100644
index 04043aaaaa..0000000000
--- a/test/did_you_mean/edit_distance/test_jaro_winkler.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require_relative '../helper'
-
-# These tests were originally written by Jian Weihang (簡煒航) as part of his work
-# on the jaro_winkler gem. The original code could be found here:
-# https://github.com/tonytonyjan/jaro_winkler/blob/9bd12421/spec/jaro_winkler_spec.rb
-#
-# Copyright (c) 2014 Jian Weihang
-
-class JaroWinklerTest < Test::Unit::TestCase
- def test_jaro_winkler_distance
- assert_distance 0.9667, 'henka', 'henkan'
- assert_distance 1.0, 'al', 'al'
- assert_distance 0.9611, 'martha', 'marhta'
- assert_distance 0.8324, 'jones', 'johnson'
- assert_distance 0.9167, 'abcvwxyz', 'zabcvwxy'
- assert_distance 0.9583, 'abcvwxyz', 'cabvwxyz'
- assert_distance 0.84, 'dwayne', 'duane'
- assert_distance 0.8133, 'dixon', 'dicksonx'
- assert_distance 0.0, 'fvie', 'ten'
- assert_distance 0.9067, 'does_exist', 'doesnt_exist'
- assert_distance 1.0, 'x', 'x'
- end
-
- def test_jarowinkler_distance_with_utf8_strings
- assert_distance 0.9818, '變形金剛4:絕跡é‡ç”Ÿ', '變形金剛4: 絕跡é‡ç”Ÿ'
- assert_distance 0.8222, '連勿–‡', '連å‹ä¸¼'
- assert_distance 0.8222, '馬英ä¹', '馬英丸'
- assert_distance 0.6667, '良ã„', 'ã„ã„'
- end
-
- private
-
- def assert_distance(score, str1, str2)
- assert_equal score, DidYouMean::JaroWinkler.distance(str1, str2).round(4)
- end
-end
diff --git a/test/did_you_mean/fixtures/book.rb b/test/did_you_mean/fixtures/book.rb
deleted file mode 100644
index e6644a6263..0000000000
--- a/test/did_you_mean/fixtures/book.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-class Book
- class Cover
- end
-end
diff --git a/test/did_you_mean/fixtures/mini_dir.yml b/test/did_you_mean/fixtures/mini_dir.yml
deleted file mode 100644
index 12fd96083d..0000000000
--- a/test/did_you_mean/fixtures/mini_dir.yml
+++ /dev/null
@@ -1,15 +0,0 @@
----
-- test/core_ext/name_error_extension_test.rb
-- test/edit_distance/jaro_winkler_test.rb
-- test/fixtures/book.rb
-- test/spell_checker_test.rb
-- test/spell_checking/class_name_check_test.rb
-- test/spell_checking/key_name_check_test.rb
-- test/spell_checking/method_name_check_test.rb
-- test/spell_checking/uncorrectable_name_check_test.rb
-- test/spell_checking/variable_name_check_test.rb
-- test/test_helper.rb
-- test/tree_spell_checker_test.rb
-- test/tree_spell_explore_test.rb
-- test/tree_spell_human_typo_test.rb
-- test/verbose_formatter_test.rb
diff --git a/test/did_you_mean/fixtures/rspec_dir.yml b/test/did_you_mean/fixtures/rspec_dir.yml
deleted file mode 100644
index 66d8a5f6a0..0000000000
--- a/test/did_you_mean/fixtures/rspec_dir.yml
+++ /dev/null
@@ -1,112 +0,0 @@
----
-- spec/spec_helper.rb
-- spec/integration/suite_hooks_errors_spec.rb
-- spec/integration/filtering_spec.rb
-- spec/integration/spec_file_load_errors_spec.rb
-- spec/integration/failed_line_detection_spec.rb
-- spec/integration/persistence_failures_spec.rb
-- spec/integration/bisect_runners_spec.rb
-- spec/integration/order_spec.rb
-- spec/integration/fail_if_no_examples_spec.rb
-- spec/integration/bisect_spec.rb
-- spec/integration/output_stream_spec.rb
-- spec/support/sandboxing.rb
-- spec/support/spec_files.rb
-- spec/support/fake_libs/json.rb
-- spec/support/fake_libs/open3.rb
-- spec/support/fake_libs/drb/acl.rb
-- spec/support/fake_libs/drb/drb.rb
-- spec/support/fake_libs/mocha/api.rb
-- spec/support/fake_libs/test/unit/assertions.rb
-- spec/support/fake_libs/flexmock/rspec.rb
-- spec/support/fake_libs/rake/tasklib.rb
-- spec/support/fake_libs/coderay.rb
-- spec/support/fake_libs/rr.rb
-- spec/support/fake_libs/rake.rb
-- spec/support/fake_libs/erb.rb
-- spec/support/fake_libs/rspec/mocks.rb
-- spec/support/fake_libs/rspec/expectations.rb
-- spec/support/fake_libs/minitest/assertions.rb
-- spec/support/fake_libs/minitest.rb
-- spec/support/matchers.rb
-- spec/support/runner_support.rb
-- spec/support/isolated_home_directory.rb
-- spec/support/config_options_helper.rb
-- spec/support/mathn_integration_support.rb
-- spec/support/helper_methods.rb
-- spec/support/formatter_support.rb
-- spec/support/fake_bisect_runner.rb
-- spec/support/shared_example_groups.rb
-- spec/support/aruba_support.rb
-- spec/rspec/core/runner_spec.rb
-- spec/rspec/core/did_you_mean_spec.rb
-- spec/rspec/core/drb_spec.rb
-- spec/rspec/core/metadata_spec.rb
-- spec/rspec/core/example_group_spec.rb
-- spec/rspec/core/configuration/only_failures_support_spec.rb
-- spec/rspec/core/rake_task_spec.rb
-- spec/rspec/core/memoized_helpers_spec.rb
-- spec/rspec/core/ordering_spec.rb
-- spec/rspec/core/option_parser_spec.rb
-- spec/rspec/core/example_execution_result_spec.rb
-- spec/rspec/core/suite_hooks_spec.rb
-- spec/rspec/core/set_spec.rb
-- spec/rspec/core/configuration_spec.rb
-- spec/rspec/core/rspec_matchers_spec.rb
-- spec/rspec/core/hooks_filtering_spec.rb
-- spec/rspec/core/bisect/shell_command_spec.rb
-- spec/rspec/core/bisect/server_spec.rb
-- spec/rspec/core/bisect/example_minimizer_spec.rb
-- spec/rspec/core/bisect/shell_runner_spec.rb
-- spec/rspec/core/bisect/utilities_spec.rb
-- spec/rspec/core/bisect/coordinator_spec.rb
-- spec/rspec/core/resources/a_foo.rb
-- spec/rspec/core/resources/formatter_specs.rb
-- spec/rspec/core/resources/inconsistently_ordered_specs.rb
-- spec/rspec/core/resources/a_bar.rb
-- spec/rspec/core/resources/utf8_encoded.rb
-- spec/rspec/core/resources/a_spec.rb
-- spec/rspec/core/resources/acceptance/bar.rb
-- spec/rspec/core/resources/acceptance/foo_spec.rb
-- spec/rspec/core/resources/custom_example_group_runner.rb
-- spec/rspec/core/failed_example_notification_spec.rb
-- spec/rspec/core/hooks_spec.rb
-- spec/rspec/core/formatters/profile_formatter_spec.rb
-- spec/rspec/core/formatters/deprecation_formatter_spec.rb
-- spec/rspec/core/formatters/syntax_highlighter_spec.rb
-- spec/rspec/core/formatters/base_text_formatter_spec.rb
-- spec/rspec/core/formatters/snippet_extractor_spec.rb
-- spec/rspec/core/formatters/progress_formatter_spec.rb
-- spec/rspec/core/formatters/html_snippet_extractor_spec.rb
-- spec/rspec/core/formatters/helpers_spec.rb
-- spec/rspec/core/formatters/html_formatter_spec.rb
-- spec/rspec/core/formatters/json_formatter_spec.rb
-- spec/rspec/core/formatters/documentation_formatter_spec.rb
-- spec/rspec/core/formatters/exception_presenter_spec.rb
-- spec/rspec/core/formatters/console_codes_spec.rb
-- spec/rspec/core/formatters/fallback_message_formatter_spec.rb
-- spec/rspec/core/invocations_spec.rb
-- spec/rspec/core/configuration_options_spec.rb
-- spec/rspec/core/pending_spec.rb
-- spec/rspec/core/profiler_spec.rb
-- spec/rspec/core/project_initializer_spec.rb
-- spec/rspec/core/aggregate_failures_spec.rb
-- spec/rspec/core/dsl_spec.rb
-- spec/rspec/core/ruby_project_spec.rb
-- spec/rspec/core/formatters_spec.rb
-- spec/rspec/core/metadata_filter_spec.rb
-- spec/rspec/core/example_group_constants_spec.rb
-- spec/rspec/core/world_spec.rb
-- spec/rspec/core/shared_context_spec.rb
-- spec/rspec/core/pending_example_spec.rb
-- spec/rspec/core/filter_manager_spec.rb
-- spec/rspec/core/shared_example_group_spec.rb
-- spec/rspec/core/example_status_persister_spec.rb
-- spec/rspec/core/backtrace_formatter_spec.rb
-- spec/rspec/core/output_wrapper_spec.rb
-- spec/rspec/core/example_spec.rb
-- spec/rspec/core/reporter_spec.rb
-- spec/rspec/core/filterable_item_repository_spec.rb
-- spec/rspec/core/notifications_spec.rb
-- spec/rspec/core/warnings_spec.rb
-- spec/rspec/core_spec.rb
diff --git a/test/did_you_mean/helper.rb b/test/did_you_mean/helper.rb
deleted file mode 100644
index d8aa41c3d1..0000000000
--- a/test/did_you_mean/helper.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require 'test/unit'
-
-module DidYouMean
- module TestHelper
- class << self
- attr_reader :root
- end
-
- if File.file?(File.expand_path('../lib/did_you_mean.rb', __dir__))
- # In this case we're being run from inside the gem, so we just want to
- # require the root of the library
-
- @root = File.expand_path('../lib/did_you_mean', __dir__)
- require_relative @root
- else
- # In this case we're being run from inside ruby core, and we want to
- # include the experimental features in the test suite
-
- @root = File.expand_path('../../lib/did_you_mean', __dir__)
- require_relative @root
- # We are excluding experimental features for now.
- # require_relative File.join(@root, 'experimental')
- end
-
- def assert_correction(expected, array)
- assert_equal Array(expected), array, "Expected #{array.inspect} to only include #{expected.inspect}"
- end
- end
-end
diff --git a/test/did_you_mean/spell_checking/test_class_name_check.rb b/test/did_you_mean/spell_checking/test_class_name_check.rb
deleted file mode 100644
index ffe7a4c31b..0000000000
--- a/test/did_you_mean/spell_checking/test_class_name_check.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-require_relative '../helper'
-
-module ACRONYM
-end
-
-class Project
- def self.bo0k
- Bo0k
- end
-end
-
-class Book
- class TableOfContents; end
-
- def tableof_contents
- TableofContents
- end
-
- class Page
- def tableof_contents
- TableofContents
- end
-
- def self.tableof_contents
- TableofContents
- end
- end
-end
-
-class ClassNameCheckTest < Test::Unit::TestCase
- include DidYouMean::TestHelper
-
- def test_corrections
- error = assert_raise(NameError) { ::Bo0k }
- assert_correction "Book", error.corrections
- end
-
- def test_corrections_include_case_specific_class_name
- error = assert_raise(NameError) { ::Acronym }
- assert_correction "ACRONYM", error.corrections
- end
-
- def test_corrections_include_top_level_class_name
- error = assert_raise(NameError) { Project.bo0k }
- assert_correction "Book", error.corrections
- end
-
- def test_names_in_corrections_have_namespaces
- error = assert_raise(NameError) { ::Book::TableofContents }
- assert_correction "Book::TableOfContents", error.corrections
- end
-
- def test_corrections_candidates_for_names_in_upper_level_scopes
- error = assert_raise(NameError) { Book::Page.tableof_contents }
- assert_correction "Book::TableOfContents", error.corrections
- end
-
- def test_corrections_should_work_from_within_instance_method
- error = assert_raise(NameError) { ::Book.new.tableof_contents }
- assert_correction "Book::TableOfContents", error.corrections
- end
-
- def test_corrections_should_work_from_within_instance_method_on_nested_class
- error = assert_raise(NameError) { ::Book::Page.new.tableof_contents }
- assert_correction "Book::TableOfContents", error.corrections
- end
-
- def test_does_not_suggest_user_input
- error = assert_raise(NameError) { ::Book::Cover }
-
- # This is a weird require, but in a multi-threaded condition, a constant may
- # be loaded between when a NameError occurred and when the spell checker
- # attempts to find a possible suggestion. The manual require here simulates
- # a race condition a single test.
- require_relative '../fixtures/book'
-
- assert_empty error.corrections
- end
-end
diff --git a/test/did_you_mean/spell_checking/test_key_name_check.rb b/test/did_you_mean/spell_checking/test_key_name_check.rb
deleted file mode 100644
index ea05ff69e4..0000000000
--- a/test/did_you_mean/spell_checking/test_key_name_check.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require_relative '../helper'
-
-class KeyNameCheckTest < Test::Unit::TestCase
- include DidYouMean::TestHelper
-
- def test_corrects_hash_key_name_with_fetch
- hash = { "foo" => 1, bar: 2 }
-
- error = assert_raise(KeyError) { hash.fetch(:bax) }
- assert_correction ":bar", error.corrections
- assert_match "Did you mean? :bar", error.to_s
-
- error = assert_raise(KeyError) { hash.fetch("fooo") }
- assert_correction %("foo"), error.corrections
- assert_match %(Did you mean? "foo"), error.to_s
- end
-
- def test_corrects_hash_key_name_with_fetch_values
- hash = { "foo" => 1, bar: 2 }
-
- error = assert_raise(KeyError) { hash.fetch_values("foo", :bar, :bax) }
- assert_correction ":bar", error.corrections
- assert_match "Did you mean? :bar", error.to_s
-
- error = assert_raise(KeyError) { hash.fetch_values("foo", :bar, "fooo") }
- assert_correction %("foo"), error.corrections
- assert_match %(Did you mean? "foo"), error.to_s
- end
-
- def test_correct_symbolized_hash_keys_with_string_value
- hash = { foo_1: 1, bar_2: 2 }
-
- error = assert_raise(KeyError) { hash.fetch('foo_1') }
- assert_correction %(:foo_1), error.corrections
- assert_match %(Did you mean? :foo_1), error.to_s
- end
-
- def test_corrects_sprintf_key_name
- error = assert_raise(KeyError) { sprintf("%<foo>d", {fooo: 1}) }
- assert_correction ":fooo", error.corrections
- assert_match "Did you mean? :fooo", error.to_s
- end
-
- def test_corrects_env_key_name
- ENV["FOO"] = "1"
- ENV["BAR"] = "2"
- error = assert_raise(KeyError) { ENV.fetch("BAX") }
- assert_correction %("BAR"), error.corrections
- assert_match %(Did you mean? "BAR"), error.to_s
- ensure
- ENV.delete("FOO")
- ENV.delete("BAR")
- end
-end
diff --git a/test/did_you_mean/spell_checking/test_method_name_check.rb b/test/did_you_mean/spell_checking/test_method_name_check.rb
deleted file mode 100644
index f3a6b1c7c7..0000000000
--- a/test/did_you_mean/spell_checking/test_method_name_check.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-require_relative '../helper'
-
-class MethodNameCheckTest < Test::Unit::TestCase
- include DidYouMean::TestHelper
-
- class User
- def friends; end
- def first_name; end
- def descendants; end
- def call_incorrect_private_method
- raiae NoMethodError
- end
-
- def raise_no_method_error
- self.firstname
- rescue NoMethodError => e
- raise e, e.message, e.backtrace
- end
-
- protected
- def the_protected_method; end
-
- private
- def friend; end
- def the_private_method; end
-
- class << self
- def load; end
- end
- end
-
- module UserModule
- def from_module; end
- end
-
- def setup
- @user = User.new.extend(UserModule)
- end
-
- def test_corrections_include_instance_method
- error = assert_raise(NoMethodError){ @user.flrst_name }
-
- assert_correction :first_name, error.corrections
- assert_match "Did you mean? first_name", error.to_s
- end
-
- def test_corrections_include_private_method
- error = assert_raise(NoMethodError){ @user.friend }
-
- assert_correction :friends, error.corrections
- assert_match "Did you mean? friends", error.to_s
- end
-
- def test_corrections_include_method_from_module
- error = assert_raise(NoMethodError){ @user.fr0m_module }
-
- assert_correction :from_module, error.corrections
- assert_match "Did you mean? from_module", error.to_s
- end
-
- def test_corrections_include_class_method
- error = assert_raise(NoMethodError){ User.l0ad }
-
- assert_correction :load, error.corrections
- assert_match "Did you mean? load", error.to_s
- end
-
- def test_private_methods_should_not_be_suggested
- error = assert_raise(NoMethodError){ User.new.the_protected_method }
- refute_includes error.corrections, :the_protected_method
-
- error = assert_raise(NoMethodError){ User.new.the_private_method }
- refute_includes error.corrections, :the_private_method
- end
-
- def test_corrections_when_private_method_is_called_with_args
- error = assert_raise(NoMethodError){ @user.call_incorrect_private_method }
-
- assert_correction :raise, error.corrections
- assert_match "Did you mean? raise", error.to_s
- end
-
- def test_exclude_methods_on_nil
- error = assert_raise(NoMethodError){ nil.map }
- assert_empty error.corrections
- end
-
- def test_does_not_exclude_custom_methods_on_nil
- def nil.empty?
- end
-
- error = assert_raise(NoMethodError){ nil.empty }
- assert_correction :empty?, error.corrections
- ensure
- NilClass.class_eval { undef empty? }
- end
-
- def test_does_not_append_suggestions_twice
- error = assert_raise NoMethodError do
- begin
- @user.firstname
- rescue NoMethodError => e
- raise e, e.message, e.backtrace
- end
- end
-
- assert_equal 1, error.to_s.scan(/Did you mean/).count
- end
-
- def test_does_not_append_suggestions_three_times
- error = assert_raise NoMethodError do
- begin
- @user.raise_no_method_error
- rescue NoMethodError => e
- raise e, e.message, e.backtrace
- end
- end
-
- assert_equal 1, error.to_s.scan(/Did you mean/).count
- end
-
- def test_suggests_corrections_on_nested_error
- error = assert_raise NoMethodError do
- begin
- @user.firstname
- rescue NoMethodError
- @user.firstname
- end
- end
-
- assert_equal 1, error.to_s.scan(/Did you mean/).count
- end
-
- def test_suggests_yield
- error = assert_raise(NoMethodError) { yeild(1) }
-
- assert_correction :yield, error.corrections
- assert_match "Did you mean? yield", error.to_s
- end
-end
diff --git a/test/did_you_mean/spell_checking/test_uncorrectable_name_check.rb b/test/did_you_mean/spell_checking/test_uncorrectable_name_check.rb
deleted file mode 100644
index 5d934e5f70..0000000000
--- a/test/did_you_mean/spell_checking/test_uncorrectable_name_check.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../helper'
-
-class UncorrectableNameCheckTest < Test::Unit::TestCase
- class FirstNameError < NameError; end
-
- def setup
- @error = assert_raise(FirstNameError) do
- raise FirstNameError, "Other name error"
- end
- end
-
- def test_message
- assert_equal "Other name error", @error.message
- end
-end
diff --git a/test/did_you_mean/spell_checking/test_variable_name_check.rb b/test/did_you_mean/spell_checking/test_variable_name_check.rb
deleted file mode 100644
index 193e2b7520..0000000000
--- a/test/did_you_mean/spell_checking/test_variable_name_check.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-require_relative '../helper'
-
-class VariableNameCheckTest < Test::Unit::TestCase
- include DidYouMean::TestHelper
-
- class User
- def initialize
- @email_address = 'email_address@address.net'
- @first_name = nil
- @last_name = nil
- end
-
- def first_name; end
- def to_s
- "#{@first_name} #{@last_name} <#{email_address}>"
- end
-
- private
-
- def cia_codename; "Alexa" end
- end
-
- module UserModule
- def from_module; end
- end
-
- def setup
- @user = User.new.extend(UserModule)
- end
-
- def test_corrections_include_instance_method
- error = assert_raise(NameError) do
- @user.instance_eval { flrst_name }
- end
-
- @user.instance_eval do
- remove_instance_variable :@first_name
- remove_instance_variable :@last_name
- end
-
- assert_correction :first_name, error.corrections
- assert_match "Did you mean? first_name", error.to_s
- end
-
- def test_corrections_include_method_from_module
- error = assert_raise(NameError) do
- @user.instance_eval { fr0m_module }
- end
-
- assert_correction :from_module, error.corrections
- assert_match "Did you mean? from_module", error.to_s
- end
-
- def test_corrections_include_local_variable_name
- if RUBY_ENGINE != "jruby"
- person = person = nil
- error = (eprson rescue $!) # Do not use @assert_raise here as it changes a scope.
-
- assert_correction :person, error.corrections
- assert_match "Did you mean? person", error.to_s
- end
- end
-
- def test_corrections_include_ruby_predefined_objects
- some_var = some_var = nil
-
- false_error = assert_raise(NameError) do
- some_var = fals
- end
-
- true_error = assert_raise(NameError) do
- some_var = treu
- end
-
- nil_error = assert_raise(NameError) do
- some_var = nul
- end
-
- file_error = assert_raise(NameError) do
- __FIEL__
- end
-
- assert_correction :false, false_error.corrections
- assert_match "Did you mean? false", false_error.to_s
-
- assert_correction :true, true_error.corrections
- assert_match "Did you mean? true", true_error.to_s
-
- assert_correction :nil, nil_error.corrections
- assert_match "Did you mean? nil", nil_error.to_s
-
- assert_correction :__FILE__, file_error.corrections
- assert_match "Did you mean? __FILE__", file_error.to_s
- end
-
- def test_suggests_yield
- error = assert_raise(NameError) { yeild }
-
- assert_correction :yield, error.corrections
- assert_match "Did you mean? yield", error.to_s
- end
-
- def test_corrections_include_instance_variable_name
- error = assert_raise(NameError){ @user.to_s }
-
- assert_correction :@email_address, error.corrections
- assert_match "Did you mean? @email_address", error.to_s
- end
-
- def test_corrections_include_private_method
- error = assert_raise(NameError) do
- @user.instance_eval { cia_code_name }
- end
-
- assert_correction :cia_codename, error.corrections
- assert_match "Did you mean? cia_codename", error.to_s
- end
-
- @@does_exist = true
-
- def test_corrections_include_class_variable_name
- error = assert_raise(NameError){ @@doesnt_exist }
-
- assert_correction :@@does_exist, error.corrections
- assert_match "Did you mean? @@does_exist", error.to_s
- end
-
- def test_struct_name_error
- value = Struct.new(:does_exist).new
- error = assert_raise(NameError){ value[:doesnt_exist] }
-
- assert_correction [:does_exist, :does_exist=], error.corrections
- assert_match "Did you mean? does_exist", error.to_s
- end
-
- def test_exclude_typical_incorrect_suggestions
- error = assert_raise(NameError){ foo }
- assert_empty error.corrections
- end
-end
diff --git a/test/did_you_mean/test_spell_checker.rb b/test/did_you_mean/test_spell_checker.rb
deleted file mode 100644
index 98460b4d94..0000000000
--- a/test/did_you_mean/test_spell_checker.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require_relative './helper'
-
-class SpellCheckerTest < Test::Unit::TestCase
- def test_spell_checker_corrects_mistypes
- assert_spell 'foo', input: 'doo', dictionary: ['foo', 'fork']
- assert_spell 'email', input: 'meail', dictionary: ['email', 'fail', 'eval']
- assert_spell 'fail', input: 'fial', dictionary: ['email', 'fail', 'eval']
- assert_spell 'fail', input: 'afil', dictionary: ['email', 'fail', 'eval']
- assert_spell 'eval', input: 'eavl', dictionary: ['email', 'fail', 'eval']
- assert_spell 'eval', input: 'veal', dictionary: ['email', 'fail', 'eval']
- assert_spell 'sub!', input: 'suv!', dictionary: ['sub', 'gsub', 'sub!']
- assert_spell 'sub', input: 'suv', dictionary: ['sub', 'gsub', 'sub!']
-
- assert_spell %w(gsub! gsub), input: 'gsuv!', dictionary: %w(sub gsub gsub!)
- assert_spell %w(sub! sub gsub!), input: 'ssub!', dictionary: %w(sub sub! gsub gsub!)
-
- group_methods = %w(groups group_url groups_url group_path)
- assert_spell 'groups', input: 'group', dictionary: group_methods
-
- group_classes = %w(
- GroupMembership
- GroupMembershipPolicy
- GroupMembershipDecorator
- GroupMembershipSerializer
- GroupHelper
- Group
- GroupMailer
- NullGroupMembership
- )
-
- assert_spell 'GroupMembership', dictionary: group_classes, input: 'GroupMemberhip'
- assert_spell 'GroupMembershipDecorator', dictionary: group_classes, input: 'GroupMemberhipDecorator'
-
- names = %w(first_name_change first_name_changed? first_name_will_change!)
- assert_spell names, input: 'first_name_change!', dictionary: names
-
- assert_empty DidYouMean::SpellChecker.new(dictionary: ['proc']).correct('product_path')
- assert_empty DidYouMean::SpellChecker.new(dictionary: ['fork']).correct('fooo')
- end
-
- def test_spell_checker_corrects_misspells
- assert_spell 'descendants', input: 'dependents', dictionary: ['descendants']
- assert_spell 'drag_to', input: 'drag', dictionary: ['drag_to']
- assert_spell 'set_result_count', input: 'set_result', dictionary: ['set_result_count']
- end
-
- def test_spell_checker_sorts_results_by_simiarity
- expected = %w(
- name12345
- name1234
- name123
- )
-
- actual = DidYouMean::SpellChecker.new(dictionary: %w(
- name12
- name123
- name1234
- name12345
- name123456
- )).correct('name123456')
-
- assert_equal expected, actual
- end
-
- def test_spell_checker_excludes_input_from_dictionary
- assert_empty DidYouMean::SpellChecker.new(dictionary: ['input']).correct('input')
- assert_empty DidYouMean::SpellChecker.new(dictionary: [:input]).correct('input')
- assert_empty DidYouMean::SpellChecker.new(dictionary: ['input']).correct(:input)
- end
-
- private
-
- def assert_spell(expected, input: , dictionary: )
- corrections = DidYouMean::SpellChecker.new(dictionary: dictionary).correct(input)
- assert_equal Array(expected), corrections, "Expected to suggest #{expected}, but got #{corrections.inspect}"
- end
-end
diff --git a/test/did_you_mean/test_tree_spell_checker.rb b/test/did_you_mean/test_tree_spell_checker.rb
deleted file mode 100644
index b61a491e20..0000000000
--- a/test/did_you_mean/test_tree_spell_checker.rb
+++ /dev/null
@@ -1,173 +0,0 @@
-require 'set'
-require 'yaml'
-
-require_relative './helper'
-
-class TreeSpellCheckerTest < Test::Unit::TestCase
- MINI_DIRECTORIES = YAML.load_file(File.expand_path('fixtures/mini_dir.yml', __dir__))
- RSPEC_DIRECTORIES = YAML.load_file(File.expand_path('fixtures/rspec_dir.yml', __dir__))
-
- def setup
- @dictionary =
- %w(
- spec/models/concerns/vixen_spec.rb
- spec/models/concerns/abcd_spec.rb
- spec/models/concerns/vixenus_spec.rb
- spec/models/concerns/efgh_spec.rb
- spec/modals/confirms/abcd_spec.rb
- spec/modals/confirms/efgh_spec.rb
- spec/models/gafafa_spec.rb
- spec/models/gfsga_spec.rb
- spec/controllers/vixen_controller_spec.rb
- )
- @test_str = 'spek/modeks/confirns/viken_spec.rb'
- @tsp = DidYouMean::TreeSpellChecker.new(dictionary: @dictionary)
- end
-
- def test_corrupt_root
- word = 'test/verbose_formatter_test.rb'
- word_error = 'btets/cverbose_formatter_etst.rb suggestions'
- tsp = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES)
- s = tsp.correct(word_error).first
- assert_match s, word
- end
-
- def test_leafless_state
- tsp = DidYouMean::TreeSpellChecker.new(dictionary: @dictionary.push('spec/features'))
- word = 'spec/modals/confirms/efgh_spec.rb'
- word_error = 'spec/modals/confirXX/efgh_spec.rb'
- s = tsp.correct(word_error).first
- assert_equal s, word
- s = tsp.correct('spec/featuresXX')
- assert_equal 'spec/features', s.first
- end
-
- def test_rake_dictionary
- dict = %w(parallel:prepare parallel:create parallel:rake parallel:migrate)
- word_error = 'parallel:preprare'
- tsp = DidYouMean::TreeSpellChecker.new(dictionary: dict, separator: ':')
- s = tsp.correct(word_error).first
- assert_match s, 'parallel:prepare'
- end
-
- def test_special_words_mini
- tsp = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES)
- special_words_mini.each do |word, word_error|
- s = tsp.correct(word_error).first
- assert_match s, word
- end
- end
-
- def test_special_words_rspec
- tsp = DidYouMean::TreeSpellChecker.new(dictionary: RSPEC_DIRECTORIES)
- special_words_rspec.each do |word, word_error|
- s = tsp.correct(word_error)
- assert_match s.first, word
- end
- end
-
- def special_words_rspec
- [
- ['spec/rspec/core/formatters/exception_presenter_spec.rb','spec/rspec/core/formatters/eception_presenter_spec.rb'],
- ['spec/rspec/core/ordering_spec.rb', 'spec/spec/core/odrering_spec.rb'],
- ['spec/rspec/core/metadata_spec.rb', 'spec/rspec/core/metadata_spe.crb'],
- ['spec/support/mathn_integration_support.rb', 'spec/support/mathn_itegrtion_support.rb']
- ]
- end
-
- def special_words_mini
- [
- ['test/fixtures/book.rb', 'test/fixture/book.rb'],
- ['test/fixtures/book.rb', 'test/fixture/book.rb'],
- ['test/edit_distance/jaro_winkler_test.rb', 'test/edit_distace/jaro_winkler_test.rb'],
- ['test/edit_distance/jaro_winkler_test.rb', 'teste/dit_distane/jaro_winkler_test.rb'],
- ['test/fixtures/book.rb', 'test/fixturWes/book.rb'],
- ['test/test_helper.rb', 'tes!t/test_helper.rb'],
- ['test/fixtures/book.rb', 'test/hfixtures/book.rb'],
- ['test/edit_distance/jaro_winkler_test.rb', 'test/eidt_distance/jaro_winkler_test.@rb'],
- ['test/spell_checker_test.rb', 'test/spell_checke@r_test.rb'],
- ['test/tree_spell_human_typo_test.rb', 'testt/ree_spell_human_typo_test.rb'],
- ['test/spell_checking/variable_name_check_test.rb', 'test/spell_checking/vriabl_ename_check_test.rb'],
- ['test/spell_checking/key_name_check_test.rb', 'tesit/spell_checking/key_name_choeck_test.rb'],
- ['test/edit_distance/jaro_winkler_test.rb', 'test/edit_distance/jaro_winkler_tuest.rb']
- ]
- end
-
- def test_file_in_root
- word = 'test/spell_checker_test.rb'
- word_error = 'test/spell_checker_test.r'
- suggestions = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES).correct word_error
- assert_equal word, suggestions.first
- end
-
- def test_no_plausible_states
- word_error = 'testspell_checker_test.rb'
- suggestions = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES).correct word_error
- assert_equal [], suggestions
- end
-
- def test_no_plausible_states_with_augmentation
- word_error = 'testspell_checker_test.rb'
- suggestions = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES).correct word_error
- assert_equal [], suggestions
- suggestions = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES, augment: true).correct word_error
- assert_equal 'test/spell_checker_test.rb', suggestions.first
- end
-
- def test_no_idea_with_augmentation
- word_error = 'test/spell_checking/key_name.rb'
- suggestions = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES).correct word_error
- assert_equal [], suggestions
- suggestions = DidYouMean::TreeSpellChecker.new(dictionary: MINI_DIRECTORIES, augment: true).correct word_error
- assert_equal 'test/spell_checking/key_name_check_test.rb', suggestions.first
- end
-
- def test_works_out_suggestions
- exp = ['spec/models/concerns/vixen_spec.rb',
- 'spec/models/concerns/vixenus_spec.rb']
- suggestions = @tsp.correct(@test_str)
- assert_equal suggestions.to_set, exp.to_set
- end
-
- def test_works_when_input_is_correct
- correct_input = 'spec/models/concerns/vixenus_spec.rb'
- suggestions = @tsp.correct correct_input
- assert_equal suggestions.first, correct_input
- end
-
- def test_find_out_leaves_in_a_path
- path = 'spec/modals/confirms'
- names = @tsp.send(:find_leaves, path)
- assert_equal names.to_set, %w(abcd_spec.rb efgh_spec.rb).to_set
- end
-
- def test_works_out_nodes
- exp_paths = ['spec/models/concerns',
- 'spec/models/confirms',
- 'spec/modals/concerns',
- 'spec/modals/confirms',
- 'spec/controllers/concerns',
- 'spec/controllers/confirms'].to_set
- states = @tsp.send(:parse_dimensions)
- nodes = states[0].product(*states[1..-1])
- paths = @tsp.send(:possible_paths, nodes)
- assert_equal paths.to_set, exp_paths.to_set
- end
-
- def test_works_out_state_space
- suggestions = @tsp.send(:plausible_dimensions, @test_str)
- assert_equal suggestions, [["spec"], ["models", "modals"], ["confirms", "concerns"]]
- end
-
- def test_parses_dictionary
- states = @tsp.send(:parse_dimensions)
- assert_equal states, [["spec"], ["models", "modals", "controllers"], ["concerns", "confirms"]]
- end
-
- def test_parses_elementary_dictionary
- dictionary = ['spec/models/user_spec.rb', 'spec/services/account_spec.rb']
- tsp = DidYouMean::TreeSpellChecker.new(dictionary: dictionary)
- states = tsp.send(:parse_dimensions)
- assert_equal states, [['spec'], ['models', 'services']]
- end
-end
diff --git a/test/did_you_mean/test_verbose_formatter.rb b/test/did_you_mean/test_verbose_formatter.rb
deleted file mode 100644
index 6639d60a4a..0000000000
--- a/test/did_you_mean/test_verbose_formatter.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative './helper'
-
-class VerboseFormatterTest < Test::Unit::TestCase
- def setup
- require_relative File.join(DidYouMean::TestHelper.root, 'verbose')
- end
-
- def teardown
- DidYouMean.formatter = DidYouMean::PlainFormatter.new
- end
-
- def test_message
- @error = assert_raise(NoMethodError){ 1.zeor? }
-
- assert_match <<~MESSAGE.strip, @error.message
- undefined method `zeor?' for 1:Integer
-
- Did you mean? zero?
- MESSAGE
- end
-end
diff --git a/test/did_you_mean/tree_spell/change_word.rb b/test/did_you_mean/tree_spell/change_word.rb
deleted file mode 100644
index d34b1f38e6..0000000000
--- a/test/did_you_mean/tree_spell/change_word.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-module TreeSpell
- # Changes a word with one of four actions:
- # insertion, substitution, deletion and transposition.
- class ChangeWord
- # initialize with input string
- def initialize(input)
- @input = input
- @len = input.length
- end
-
- # insert char after index of i_place
- def insertion(i_place, char)
- @word = input.dup
- return char + word if i_place == 0
- return word + char if i_place == len - 1
- word.insert(i_place + 1, char)
- end
-
- # substitute char at index of i_place
- def substitution(i_place, char)
- @word = input.dup
- word[i_place] = char
- word
- end
-
- # delete character at index of i_place
- def deletion(i_place)
- @word = input.dup
- word.slice!(i_place)
- word
- end
-
- # transpose char at i_place with char at i_place + direction
- # if i_place + direction is out of bounds just swap in other direction
- def transposition(i_place, direction)
- @word = input.dup
- w = word.dup
- return swap_first_two(w) if i_place + direction < 0
- return swap_last_two(w) if i_place + direction >= len
- swap_two(w, i_place, direction)
- w
- end
-
- private
-
- attr_accessor :word, :input, :len
-
- def swap_first_two(w)
- w[1] + w[0] + word[2..-1]
- end
-
- def swap_last_two(w)
- w[0...(len - 2)] + word[len - 1] + word[len - 2]
- end
-
- def swap_two(w, i_place, direction)
- w[i_place] = word[i_place + direction]
- w[i_place + direction] = word[i_place]
- end
- end
-end
diff --git a/test/did_you_mean/tree_spell/human_typo.rb b/test/did_you_mean/tree_spell/human_typo.rb
deleted file mode 100644
index 302d4d6902..0000000000
--- a/test/did_you_mean/tree_spell/human_typo.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# module for classes needed to test TreeSpellChecker
-module TreeSpell
- require_relative 'change_word'
- # Simulate an error prone human typist
- # see doc/human_typo_api.md for the api description
- class HumanTypo
- def initialize(input, lambda: 0.05)
- @input = input
- check_input
- @len = input.length
- @lambda = lambda
- end
-
- def call
- @word = input.dup
- i_place = initialize_i_place
- loop do
- action = action_type
- @word = make_change action, i_place
- @len = word.length
- i_place += exponential
- break if i_place >= len
- end
- word
- end
-
- private
-
- attr_accessor :input, :word, :len, :lambda
-
- def initialize_i_place
- i_place = nil
- loop do
- i_place = exponential
- break if i_place < len
- end
- i_place
- end
-
- def exponential
- (rand / (lambda / 2)).to_i
- end
-
- def rand_char
- popular_chars = alphabetic_characters + special_characters
- n = popular_chars.length
- popular_chars[rand(n)]
- end
-
- def alphabetic_characters
- ('a'..'z').to_a.join + ('A'..'Z').to_a.join
- end
-
- def special_characters
- '?<>,.!`+=-_":;@#$%^&*()'
- end
-
- def toss
- return +1 if rand >= 0.5
- -1
- end
-
- def action_type
- [:insert, :transpose, :delete, :substitute][rand(4)]
- end
-
- def make_change(action, i_place)
- cw = ChangeWord.new(word)
- case action
- when :delete
- cw.deletion(i_place)
- when :insert
- cw.insertion(i_place, rand_char)
- when :substitute
- cw.substitution(i_place, rand_char)
- when :transpose
- cw.transposition(i_place, toss)
- end
- end
-
- def check_input
- fail check_input_message if input.nil? || input.length < 5
- end
-
- def check_input_message
- "input length must be greater than 5 characters: #{input}"
- end
- end
-end
diff --git a/test/did_you_mean/tree_spell/test_change_word.rb b/test/did_you_mean/tree_spell/test_change_word.rb
deleted file mode 100644
index 613e11b869..0000000000
--- a/test/did_you_mean/tree_spell/test_change_word.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../helper'
-require_relative 'change_word'
-
-class ChangeWordTest < Test::Unit::TestCase
- def setup
- @input = 'spec/services/anything_spec'
- @cw = TreeSpell::ChangeWord.new(@input)
- @len = @input.length
- end
-
- def test_deleletion
- assert_match @cw.deletion(5), 'spec/ervices/anything_spec'
- assert_match @cw.deletion(@len - 1), 'spec/services/anything_spe'
- assert_match @cw.deletion(0), 'pec/services/anything_spec'
- end
-
- def test_substitution
- assert_match @cw.substitution(5, '$'), 'spec/$ervices/anything_spec'
- assert_match @cw.substitution(@len - 1, '$'), 'spec/services/anything_spe$'
- assert_match @cw.substitution(0, '$'), '$pec/services/anything_spec'
- end
-
- def test_insertion
- assert_match @cw.insertion(7, 'X'), 'spec/serXvices/anything_spec'
- assert_match @cw.insertion(0, 'X'), 'Xspec/services/anything_spec'
- assert_match @cw.insertion(@len - 1, 'X'), 'spec/services/anything_specX'
- end
-
- def test_transposition
- n = @input.length
- assert_match @cw.transposition(0, -1), 'psec/services/anything_spec'
- assert_match @cw.transposition(n - 1, +1), 'spec/services/anything_spce'
- assert_match @cw.transposition(4, +1), 'specs/ervices/anything_spec'
- assert_match @cw.transposition(4, -1), 'spe/cservices/anything_spec'
- assert_match @cw.transposition(21, -1), 'spec/services/anythign_spec'
- assert_match @cw.transposition(21, +1), 'spec/services/anythin_gspec'
- end
-end
diff --git a/test/did_you_mean/tree_spell/test_human_typo.rb b/test/did_you_mean/tree_spell/test_human_typo.rb
deleted file mode 100644
index 7ede9e393e..0000000000
--- a/test/did_you_mean/tree_spell/test_human_typo.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../helper'
-require_relative 'human_typo'
-
-class HumanTypoTest < Test::Unit::TestCase
- def setup
- @input = 'spec/services/anything_spec'
- @sh = TreeSpell::HumanTypo.new(@input, lambda: 0.05)
- @len = @input.length
- end
-
- def test_changes
- # srand seed ensures all four actions are called
- srand 247_696_449
- sh = TreeSpell::HumanTypo.new(@input, lambda: 0.20)
- word_error = sh.call
- assert_equal word_error, 'spec/suervcieq/anythin_gpec'
- end
-
- def test_check_input
- assert_raise(RuntimeError, "input length must be greater than 5 characters: tiny") do
- TreeSpell::HumanTypo.new('tiny')
- end
- end
-end
diff --git a/test/digest/test_digest_extend.rb b/test/digest/test_digest_extend.rb
index bd599f2d20..9dd026b5e3 100644
--- a/test/digest/test_digest_extend.rb
+++ b/test/digest/test_digest_extend.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
require 'test/unit'
require 'digest'
-require_relative '../lib/with_different_ofs'
+require_relative '../lib/with_different_ofs.rb'
class TestDigestExtend < Test::Unit::TestCase
extend DifferentOFS
diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb
index a8363b0c43..2796100280 100644
--- a/test/drb/drbtest.rb
+++ b/test/drb/drbtest.rb
@@ -7,6 +7,7 @@ require 'timeout'
module DRbTests
class DRbService
+ @@manager = DRb::ExtServManager.new
@@ruby = [EnvUtil.rubybin]
@@ruby << "-d" if $DEBUG
def self.add_service_command(nm)
@@ -17,32 +18,21 @@ class DRbService
%w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eq.rb).each do |nm|
add_service_command(nm)
end
-
- def initialize
- @manager = DRb::ExtServManager.new
- start
- @manager.uri = server.uri
+ @server = @@server = DRb::DRbServer.new('druby://localhost:0', @@manager, {})
+ @@manager.uri = @@server.uri
+ def self.manager
+ @@manager
end
-
- def start
- @server = DRb::DRbServer.new('druby://localhost:0', manager, {})
+ def self.server
+ @server || @@server
end
-
- attr_reader :manager
- attr_reader :server
-
- def ext_service(name)
- EnvUtil.timeout(100, RuntimeError) do
+ def self.ext_service(name)
+ Timeout.timeout(100, RuntimeError) do
manager.service(name)
end
end
-
- def finish
- server.instance_variable_get(:@grp).list.each {|th| th.join }
- server.stop_service
- manager.instance_variable_get(:@queue)&.push(nil)
- manager.instance_variable_get(:@thread)&.join
- DRb::DRbConn.stop_pool
+ def self.finish
+ @server.instance_variable_get(:@grp).list.each {|th| th.join }
end
end
@@ -78,43 +68,35 @@ class XArray < Array
end
module DRbBase
- def setup
- @drb_service ||= DRbService.new
- end
-
def setup_service(service_name)
@service_name = service_name
- @ext = @drb_service.ext_service(@service_name)
+ @ext = DRbService.ext_service(@service_name)
@there = @ext.front
end
def teardown
@ext.stop_service if defined?(@ext) && @ext
- if defined?(@service_name) && @service_name
- @drb_service.manager.unregist(@service_name)
- while (@there&&@there.to_s rescue nil)
- # nop
- end
- signal = /mswin|mingw/ =~ RUBY_PLATFORM ? :KILL : :TERM
- Thread.list.each {|th|
- if th.respond_to?(:pid) && th[:drb_service] == @service_name
- 10.times do
- begin
- Process.kill signal, th.pid
- break
- rescue Errno::ESRCH
- break
- rescue Errno::EPERM # on Windows
- sleep 0.1
- retry
- end
+ DRbService.manager.unregist(@service_name)
+ while (@there&&@there.to_s rescue nil)
+ # nop
+ end
+ signal = /mswin|mingw/ =~ RUBY_PLATFORM ? :KILL : :TERM
+ Thread.list.each {|th|
+ if th.respond_to?(:pid) && th[:drb_service] == @service_name
+ 10.times do
+ begin
+ Process.kill signal, th.pid
+ break
+ rescue Errno::ESRCH
+ break
+ rescue Errno::EPERM # on Windows
+ sleep 0.1
+ retry
end
- th.join
end
- }
- end
- @drb_service.finish
- DRb::DRbConn.stop_pool
+ th.join
+ end
+ }
end
end
@@ -157,14 +139,6 @@ module DRbCore
end
end
- def test_02_basic_object
- obj = @there.basic_object
- assert_kind_of(DRb::DRbObject, obj)
- assert_equal(1, obj.foo)
- assert_raise(NoMethodError){obj.prot}
- assert_raise(NoMethodError){obj.priv}
- end
-
def test_02_unknown
obj = @there.unknown_class
assert_kind_of(DRb::DRbUnknown, obj)
@@ -213,16 +187,12 @@ module DRbCore
end
def test_06_timeout
- skip if RUBY_PLATFORM.include?("armv7l-linux")
- skip if RUBY_PLATFORM.include?("sparc-solaris2.10")
- Timeout.timeout(60) do
- ten = Onecky.new(10)
- assert_raise(Timeout::Error) do
- @there.do_timeout(ten)
- end
- assert_raise(Timeout::Error) do
- @there.do_timeout(ten)
- end
+ ten = Onecky.new(10)
+ assert_raise(Timeout::Error) do
+ @there.do_timeout(ten)
+ end
+ assert_raise(Timeout::Error) do
+ @there.do_timeout(ten)
end
end
diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb
index 6d7b10e347..52e79ea496 100644
--- a/test/drb/test_drb.rb
+++ b/test/drb/test_drb.rb
@@ -7,14 +7,29 @@ class TestDRbCore < Test::Unit::TestCase
include DRbCore
def setup
- super
setup_service 'ut_drb.rb'
+ super
+ end
+
+ def teardown
+ super
+ DRbService.finish
end
end
-module DRbYield
+class TestDRbYield < Test::Unit::TestCase
include DRbBase
+ def setup
+ setup_service 'ut_drb.rb'
+ super
+ end
+
+ def teardown
+ super
+ DRbService.finish
+ end
+
def test_01_one
@there.echo_yield_1([]) {|one|
assert_equal([], one)
@@ -103,25 +118,18 @@ module DRbYield
@there.xarray_each {|x| assert_kind_of(XArray, x)}
@there.xarray_each {|*x| assert_kind_of(XArray, x[0])}
end
-end
-
-class TestDRbYield < Test::Unit::TestCase
- include DRbYield
- def setup
- super
- setup_service 'ut_drb.rb'
+ def test_06_taint
+ x = proc {}
+ assert_not_predicate(x, :tainted?)
+ @there.echo_yield(x) {|o|
+ assert_equal(x, o)
+ assert_not_predicate(x, :tainted?)
+ }
end
end
-class TestDRbRubyYield < Test::Unit::TestCase
- include DRbYield
-
- def setup
- @there = self
- super
- end
-
+class TestDRbRubyYield < TestDRbYield
def echo_yield(*arg)
yield(*arg)
end
@@ -145,11 +153,15 @@ class TestDRbRubyYield < Test::Unit::TestCase
end
end
-end
+ def setup
+ @there = self
+ end
-class TestDRbRuby18Yield < Test::Unit::TestCase
- include DRbYield
+ def teardown
+ end
+end
+class TestDRbRuby18Yield < TestDRbRubyYield
class YieldTest18
def echo_yield(*arg, &proc)
proc.call(*arg)
@@ -176,7 +188,6 @@ class TestDRbRuby18Yield < Test::Unit::TestCase
def setup
@there = YieldTest18.new
- super
end
end
@@ -184,8 +195,13 @@ class TestDRbAry < Test::Unit::TestCase
include DRbAry
def setup
- super
setup_service 'ut_array.rb'
+ super
+ end
+
+ def teardown
+ super
+ DRbService.finish
end
end
@@ -193,8 +209,8 @@ class TestDRbMServer < Test::Unit::TestCase
include DRbBase
def setup
- super
setup_service 'ut_drb.rb'
+ super
@server = (1..3).collect do |n|
DRb::DRbServer.new("druby://localhost:0", Onecky.new(n.to_s))
end
@@ -205,6 +221,7 @@ class TestDRbMServer < Test::Unit::TestCase
s.stop_service
end
super
+ DRbService.finish
end
def test_01
@@ -212,20 +229,28 @@ class TestDRbMServer < Test::Unit::TestCase
end
end
-class TestDRbSafe1 < Test::Unit::TestCase
- include DRbAry
+class TestDRbSafe1 < TestDRbAry
def setup
- super
setup_service 'ut_safe1.rb'
end
+
+ def teardown
+ super
+ DRbService.finish
+ end
end
class TestDRbLarge < Test::Unit::TestCase
include DRbBase
def setup
- super
setup_service 'ut_large.rb'
+ super
+ end
+
+ def teardown
+ super
+ DRbService.finish
end
def test_01_large_ary
@@ -308,60 +333,18 @@ class TestBug4409 < Test::Unit::TestCase
include DRbBase
def setup
- super
setup_service 'ut_eq.rb'
+ super
end
- def test_bug4409
- foo = @there.foo
- assert_operator(@there, :foo?, foo)
- end
-end
-
-class TestDRbAnyToS < Test::Unit::TestCase
- class BO < BasicObject
- end
-
- def test_any_to_s
- server = DRb::DRbServer.new('druby://localhost:0')
- server.singleton_class.send(:public, :any_to_s)
- assert_equal("foo:String", server.any_to_s("foo"))
- assert_match(/\A#<DRbTests::TestDRbAnyToS::BO:0x[0-9a-f]+>\z/, server.any_to_s(BO.new))
- server.stop_service
- server.thread.join
- DRb::DRbConn.stop_pool
- end
-end
-
-class TestDRbTCP < Test::Unit::TestCase
- def test_immediate_close
- server = DRb::DRbServer.new('druby://localhost:0')
- host, port, = DRb::DRbTCPSocket.send(:parse_uri, server.uri)
- socket = TCPSocket.open host, port
- socket.shutdown
- socket.close
- client = DRb::DRbTCPSocket.new(server.uri, socket)
- assert client
- client.close
- server.stop_service
- server.thread.join
- DRb::DRbConn.stop_pool
- end
-end
-
-class TestBug16634 < Test::Unit::TestCase
- include DRbBase
-
- def setup
+ def teardown
super
- setup_service 'ut_drb.rb'
+ DRbService.finish
end
- def test_bug16634
- assert_equal(42, @there.keyword_test1(a: 42))
- assert_equal("default", @there.keyword_test2)
- assert_equal(42, @there.keyword_test2(b: 42))
- assert_equal({:a=>42, :b=>42}, @there.keyword_test3(a: 42, b: 42))
+ def test_bug4409
+ foo = @there.foo
+ assert_operator(@there, :foo?, foo)
end
end
diff --git a/test/drb/test_drbobject.rb b/test/drb/test_drbobject.rb
deleted file mode 100644
index 2b0e2061ee..0000000000
--- a/test/drb/test_drbobject.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'test/unit'
-require 'drb'
-require 'drb/timeridconv'
-require 'drb/weakidconv'
-
-module DRbObjectTest
- class Foo
- def initialize
- @foo = 'foo'
- end
- end
-
- def teardown
- DRb.stop_service
- DRb::DRbConn.stop_pool
- end
-
- def drb_eq(obj)
- proxy = DRbObject.new(obj)
- assert_equal(obj, DRb.to_obj(proxy.__drbref))
- end
-
- def test_DRbObject_id_dereference
- drb_eq(Foo.new)
- drb_eq(Foo)
- drb_eq(File)
- drb_eq(Enumerable)
- drb_eq(nil)
- drb_eq(1)
- drb_eq($stdout)
- drb_eq([])
- end
-end
-
-class TestDRbObject < Test::Unit::TestCase
- include DRbObjectTest
-
- def setup
- DRb.start_service
- end
-end
-
-class TestDRbObjectTimerIdConv < Test::Unit::TestCase
- include DRbObjectTest
-
- def setup
- @idconv = DRb::TimerIdConv.new
- DRb.start_service(nil, nil, {:idconv => @idconv})
- end
-
- def teardown
- super
- # stop DRb::TimerIdConv::TimerHolder2#on_gc
- @idconv.instance_eval do
- @holder.instance_eval do
- @expires = nil
- end
- end
- GC.start
- end
-end
-
-class TestDRbObjectWeakIdConv < Test::Unit::TestCase
- include DRbObjectTest
-
- def setup
- DRb.start_service(nil, nil, {:idconv => DRb::WeakIdConv.new})
- end
-end
diff --git a/test/drb/test_drbssl.rb b/test/drb/test_drbssl.rb
index 58606119f3..1f1495356e 100644
--- a/test/drb/test_drbssl.rb
+++ b/test/drb/test_drbssl.rb
@@ -15,35 +15,37 @@ class DRbSSLService < DRbService
%w(ut_drb_drbssl.rb ut_array_drbssl.rb).each do |nm|
add_service_command(nm)
end
-
- def start
- config = Hash.new
-
- config[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER
- config[:SSLVerifyCallback] = lambda{ |ok,x509_store|
- true
- }
- begin
- data = open("sample.key"){|io| io.read }
- config[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(data)
- data = open("sample.crt"){|io| io.read }
- config[:SSLCertificate] = OpenSSL::X509::Certificate.new(data)
- rescue
- # $stderr.puts "Switching to use self-signed certificate"
- config[:SSLCertName] =
- [ ["C","JP"], ["O","Foo.DRuby.Org"], ["CN", "Sample"] ]
- end
-
- @server = DRb::DRbServer.new('drbssl://localhost:0', manager, config)
+ config = Hash.new
+
+ config[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER
+ config[:SSLVerifyCallback] = lambda{ |ok,x509_store|
+ true
+ }
+ begin
+ data = open("sample.key"){|io| io.read }
+ config[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(data)
+ data = open("sample.crt"){|io| io.read }
+ config[:SSLCertificate] = OpenSSL::X509::Certificate.new(data)
+ rescue
+ # $stderr.puts "Switching to use self-signed certificate"
+ config[:SSLCertName] =
+ [ ["C","JP"], ["O","Foo.DRuby.Org"], ["CN", "Sample"] ]
end
+
+ uri = ARGV.shift if $0 == __FILE__
+ @server = DRb::DRbServer.new(uri || 'drbssl://:0', self.manager, config)
end
class TestDRbSSLCore < Test::Unit::TestCase
include DRbCore
def setup
- @drb_service = DRbSSLService.new
- super
setup_service 'ut_drb_drbssl.rb'
+ super
+ end
+
+ def teardown
+ super
+ DRbService.finish
end
def test_02_unknown
@@ -59,9 +61,13 @@ end
class TestDRbSSLAry < Test::Unit::TestCase
include DRbAry
def setup
- @drb_service = DRbSSLService.new
- super
setup_service 'ut_array_drbssl.rb'
+ super
+ end
+
+ def teardown
+ super
+ DRbService.finish
end
end
diff --git a/test/drb/test_drbunix.rb b/test/drb/test_drbunix.rb
index 95b3c3ca91..7ece2453a9 100644
--- a/test/drb/test_drbunix.rb
+++ b/test/drb/test_drbunix.rb
@@ -16,17 +16,20 @@ class DRbUNIXService < DRbService
add_service_command(nm)
end
- def start
- @server = DRb::DRbServer.new('drbunix:', manager, {})
- end
+ uri = ARGV.shift if $0 == __FILE__
+ @server = DRb::DRbServer.new(uri || 'drbunix:', self.manager, {})
end
class TestDRbUNIXCore < Test::Unit::TestCase
include DRbCore
def setup
- @drb_service = DRbUNIXService.new
- super
setup_service 'ut_drb_drbunix.rb'
+ super
+ end
+
+ def teardown
+ super
+ DRbService.finish
end
def test_02_unknown
@@ -37,20 +40,17 @@ class TestDRbUNIXCore < Test::Unit::TestCase
def test_05_eq
end
-
- def test_bad_uri
- assert_raise(DRb::DRbBadURI) do
- DRb::DRbServer.new("badfile\n""drbunix:")
- end
- end
end
class TestDRbUNIXAry < Test::Unit::TestCase
include DRbAry
def setup
- @drb_service = DRbUNIXService.new
- super
setup_service 'ut_array_drbunix.rb'
+ super
+ end
+ def teardown
+ super
+ DRbService.finish
end
end
diff --git a/test/drb/ut_drb.rb b/test/drb/ut_drb.rb
index e7bd2dff73..6a94a0fb40 100644
--- a/test/drb/ut_drb.rb
+++ b/test/drb/ut_drb.rb
@@ -63,15 +63,6 @@ class DRbEx
FooBar.new
end
- class BO < ::BasicObject
- def foo; 1 end
- protected def prot; 2; end
- private def priv; 3; end
- end
- def basic_object
- BO.new
- end
-
def unknown_class
Unknown2.new
end
@@ -148,18 +139,6 @@ class DRbEx
end
end
- def keyword_test1(a:)
- a
- end
-
- def keyword_test2(b: "default")
- b
- end
-
- def keyword_test3(**opt)
- opt
- end
-
private
def call_private_method
true
diff --git a/test/dtrace/helper.rb b/test/dtrace/helper.rb
index ce730800b4..5828bcd5ba 100644
--- a/test/dtrace/helper.rb
+++ b/test/dtrace/helper.rb
@@ -10,57 +10,17 @@ elsif (sudo = ENV["SUDO"]) and !sudo.empty? and (`#{sudo} echo ok` rescue false)
else
ok = false
end
-
-impl = :dtrace
-
-# GNU/Linux distros with Systemtap support allows unprivileged users
-# in the stapusr and statdev groups to work.
-if RUBY_PLATFORM =~ /linux/
- impl = :stap
- begin
- require 'etc'
- ok = (%w[stapusr stapdev].map {|g|(Etc.getgrnam(g) || raise(ArgumentError)).gid} & Process.groups).size == 2
- rescue LoadError, ArgumentError
- end unless ok
-end
-
if ok
case RUBY_PLATFORM
when /darwin/i
begin
require 'pty'
rescue LoadError
+ ok = false
end
end
end
-
-# use miniruby to reduce the amount of trace data we don't care about
-rubybin = "miniruby#{RbConfig::CONFIG["EXEEXT"]}"
-rubybin = File.join(File.dirname(EnvUtil.rubybin), rubybin)
-rubybin = EnvUtil.rubybin unless File.executable?(rubybin)
-
-# make sure ruby was built with --enable-dtrace and we can run
-# dtrace(1) or stap(1):
-cmd = "#{rubybin} --disable=gems -eexit"
-case impl
-when :dtrace; cmd = %W(dtrace -l -n ruby$target:::gc-sweep-end -c #{cmd})
-when :stap; cmd = %W(stap -l process.mark("gc__sweep__end") -c #{cmd})
-else
- warn "don't know how to check if built with #{impl} support"
- cmd = false
-end
-
-NEEDED_ENVS = [RbConfig::CONFIG["LIBPATHENV"], "RUBY", "RUBYOPT"].compact
-
-if cmd and ok
- sudocmd = []
- if sudo
- sudocmd << sudo
- NEEDED_ENVS.each {|name| val = ENV[name] and sudocmd << "#{name}=#{val}"}
- end
- ok = system(*sudocmd, *cmd, err: IO::NULL, out: IO::NULL)
-end
-
+ok &= (`dtrace -V` rescue false)
module DTrace
class TestCase < Test::Unit::TestCase
INCLUDE = File.expand_path('..', File.dirname(__FILE__))
@@ -77,40 +37,7 @@ module DTrace
Process.wait(pid)
end
lines
- end if defined?(PTY)
- end
-
- # only handles simple cases, use a Hash for d_program
- # if there are more complex cases
- def dtrace2systemtap(d_program)
- translate = lambda do |str|
- # dtrace starts args with '0', systemtap with '1' and prefixes '$'
- str = str.gsub(/\barg(\d+)/) { "$arg#{$1.to_i + 1}" }
- # simple function mappings:
- str.gsub!(/\bcopyinstr\b/, 'user_string')
- str.gsub!(/\bstrstr\b/, 'isinstr')
- str
- end
- out = ''
- cond = nil
- d_program.split(/^/).each do |l|
- case l
- when /\bruby\$target:::([a-z-]+)/
- name = $1.gsub(/-/, '__')
- out << %Q{probe process.mark("#{name}")\n}
- when %r{/(.+)/}
- cond = translate.call($1)
- when "{\n"
- out << l
- out << "if (#{cond}) {\n" if cond
- when "}\n"
- out << "}\n" if cond
- out << l
- else
- out << translate.call(l)
- end
end
- out
end
DTRACE_CMD ||= %w[dtrace]
@@ -119,13 +46,10 @@ module DTrace
IO.popen(cmd, err: [:child, :out], &:readlines)
end
+ miniruby = "#{RbConfig::TOPDIR}/miniruby#{RbConfig::CONFIG["EXEEXT"]}"
+ RUBYBIN = File.exist?(miniruby) ? miniruby : EnvUtil.rubybin
+
def trap_probe d_program, ruby_program
- if Hash === d_program
- d_program = d_program[IMPL] or
- skip "#{d_program} not implemented for #{IMPL}"
- elsif String === d_program && IMPL == :stap
- d_program = dtrace2systemtap(d_program)
- end
d = Tempfile.new(%w'probe .d')
d.write d_program
d.flush
@@ -136,15 +60,11 @@ module DTrace
d_path = d.path
rb_path = rb.path
- cmd = "#{RUBYBIN} --disable=gems -I#{INCLUDE} #{rb_path}"
- if IMPL == :stap
- cmd = %W(stap #{d_path} -c #{cmd})
- else
- cmd = [*DTRACE_CMD, "-q", "-s", d_path, "-c", cmd ]
- end
+
+ cmd = [*DTRACE_CMD, "-q", "-s", d_path, "-c", "#{RUBYBIN} -I#{INCLUDE} #{rb_path}"]
if sudo = @@sudo
- NEEDED_ENVS.each do |name|
- if val = ENV[name]
+ [RbConfig::CONFIG["LIBPATHENV"], "RUBY", "RUBYOPT"].each do |name|
+ if name and val = ENV[name]
cmd.unshift("#{name}=#{val}")
end
end
@@ -160,6 +80,4 @@ end if ok
if ok
DTrace::TestCase.class_variable_set(:@@sudo, sudo)
- DTrace::TestCase.const_set(:IMPL, impl)
- DTrace::TestCase.const_set(:RUBYBIN, rubybin)
end
diff --git a/test/dtrace/test_array_create.rb b/test/dtrace/test_array_create.rb
index 1bf20085ba..44d4657b61 100644
--- a/test/dtrace/test_array_create.rb
+++ b/test/dtrace/test_array_create.rb
@@ -14,11 +14,11 @@ module DTrace
end
def test_many_lit
- trap_probe(probe, '[1,2,3,4]') { |_,rbfile,orig|
- saw = orig.map(&:split).find_all { |num, file, line|
+ trap_probe(probe, '[1,2,3,4]') { |_,rbfile,saw|
+ saw = saw.map(&:split).find_all { |num, file, line|
file == rbfile && num == '4' && line == '1'
}
- assert_operator saw.length, :>, 0, orig
+ assert_operator saw.length, :>, 0
}
end
@@ -26,7 +26,7 @@ module DTrace
def probe type = 'array'
<<-eoprobe
ruby$target:::#{type}-create
-/arg1 && arg2/
+/arg1/
{
printf("%d %s %d\\n", arg0, copyinstr(arg1), arg2);
}
diff --git a/test/dtrace/test_function_entry.rb b/test/dtrace/test_function_entry.rb
index e2395ab15a..fc07ccc455 100644
--- a/test/dtrace/test_function_entry.rb
+++ b/test/dtrace/test_function_entry.rb
@@ -17,8 +17,8 @@ ruby$target:::method-entry
row.first == 'Foo' && row[1] == 'foo'
}
- assert_equal 10, foo_calls.length, probes
- line = '3'
+ assert_equal 10, foo_calls.length
+ line = '2'
foo_calls.each { |f| assert_equal line, f[3] }
foo_calls.each { |f| assert_equal rb_file, f[2] }
}
@@ -38,8 +38,8 @@ ruby$target:::method-return
row.first == 'Foo' && row[1] == 'foo'
}
- assert_equal 10, foo_calls.length, probes.inspect
- line = '3'
+ assert_equal 10, foo_calls.length
+ line = '2'
foo_calls.each { |f| assert_equal line, f[3] }
foo_calls.each { |f| assert_equal rb_file, f[2] }
}
@@ -77,7 +77,6 @@ ruby$target:::method-return
private
def ruby_program
<<-eoruby
- TracePoint.new{}.__enable(nil, nil, Thread.current)
class Foo
def foo; end
end
diff --git a/test/dtrace/test_hash_create.rb b/test/dtrace/test_hash_create.rb
index 603ee21872..83a4d0062c 100644
--- a/test/dtrace/test_hash_create.rb
+++ b/test/dtrace/test_hash_create.rb
@@ -22,11 +22,11 @@ module DTrace
end
def test_hash_lit_elements
- trap_probe(probe, '{ :foo => :bar }') { |_,rbfile,orig|
- saw = orig.map(&:split).find_all { |num, file, line|
+ trap_probe(probe, '{ :foo => :bar }') { |_,rbfile,saw|
+ saw = saw.map(&:split).find_all { |num, file, line|
file == rbfile && num == '2'
}
- assert_operator saw.length, :>, 0, orig
+ assert_operator saw.length, :>, 0
}
end
diff --git a/test/dtrace/test_method_cache.rb b/test/dtrace/test_method_cache.rb
index 88b927464a..a101b5ddec 100644
--- a/test/dtrace/test_method_cache.rb
+++ b/test/dtrace/test_method_cache.rb
@@ -19,7 +19,7 @@ module DTrace
def probe
<<-eoprobe
ruby$target:::method-cache-clear
-/arg1 && arg2/
+/arg1/
{
printf("%s %s %d\\n", copyinstr(arg0), copyinstr(arg1), arg2);
}
diff --git a/test/dtrace/test_require.rb b/test/dtrace/test_require.rb
index da5c08f7fc..9fa6c0e87c 100644
--- a/test/dtrace/test_require.rb
+++ b/test/dtrace/test_require.rb
@@ -25,12 +25,6 @@ ruby$target:::require-return
printf("%s\\n", copyinstr(arg0));
}
eoprobe
- trap_probe(probe, ruby_program) { |d_file, rb_file, saw|
- required = saw.map { |s| s.split }.find_all do |(required, _)|
- required == 'dtrace/dummy'
- end
- assert_equal 10, required.length
- }
end
private
diff --git a/test/dtrace/test_singleton_function.rb b/test/dtrace/test_singleton_function.rb
index bad1fa0692..3698a02c93 100644
--- a/test/dtrace/test_singleton_function.rb
+++ b/test/dtrace/test_singleton_function.rb
@@ -17,8 +17,8 @@ ruby$target:::method-entry
row.first == 'Foo' && row[1] == 'foo'
}
- assert_equal 10, foo_calls.length, probes.inspect
- line = '3'
+ assert_equal 10, foo_calls.length
+ line = '2'
foo_calls.each { |f| assert_equal line, f[3] }
foo_calls.each { |f| assert_equal rb_file, f[2] }
}
@@ -37,8 +37,8 @@ ruby$target:::method-return
row.first == 'Foo' && row[1] == 'foo'
}
- assert_equal 10, foo_calls.length, probes.inspect
- line = '3'
+ assert_equal 10, foo_calls.length
+ line = '2'
foo_calls.each { |f| assert_equal line, f[3] }
foo_calls.each { |f| assert_equal rb_file, f[2] }
}
@@ -46,7 +46,6 @@ ruby$target:::method-return
def ruby_program
<<-eoruby
- TracePoint.new{}.__enable(nil, nil, Thread.current)
class Foo
def self.foo; end
end
diff --git a/test/dtrace/test_string.rb b/test/dtrace/test_string.rb
index a72f989f63..407280b1fc 100644
--- a/test/dtrace/test_string.rb
+++ b/test/dtrace/test_string.rb
@@ -4,11 +4,11 @@ require_relative 'helper'
module DTrace
class TestStringProbes < TestCase
def test_object_create_start_string_lit
- trap_probe(probe, '"omglolwutbbq"') { |_,rbfile,orig|
- saw = orig.map(&:split).find_all { |klass, file, line, len|
+ trap_probe(probe, '"omglolwutbbq"') { |_,rbfile,saw|
+ saw = saw.map(&:split).find_all { |klass, file, line, len|
file == rbfile && len == '12' && line == '1'
}
- assert_equal(%w{ String }, saw.map(&:first), orig.inspect)
+ assert_equal(%w{ String }, saw.map(&:first))
assert_equal([rbfile], saw.map { |line| line[1] })
assert_equal(['1'], saw.map { |line| line[2] })
}
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb
index d3e9b6c944..045ce5129b 100644
--- a/test/erb/test_erb.rb
+++ b/test/erb/test_erb.rb
@@ -24,22 +24,16 @@ class TestERB < Test::Unit::TestCase
assert_match(/\Atest filename:1\b/, e.backtrace[0])
end
- # [deprecated] This will be removed later
def test_without_filename_with_safe_level
- erb = EnvUtil.suppress_warning do
- ERB.new("<% raise ::TestERB::MyError %>", 1)
- end
+ erb = ERB.new("<% raise ::TestERB::MyError %>", 1)
e = assert_raise(MyError) {
erb.result
}
assert_match(/\A\(erb\):1\b/, e.backtrace[0])
end
- # [deprecated] This will be removed later
def test_with_filename_and_safe_level
- erb = EnvUtil.suppress_warning do
- ERB.new("<% raise ::TestERB::MyError %>", 1)
- end
+ erb = ERB.new("<% raise ::TestERB::MyError %>", 1)
erb.filename = "test filename"
e = assert_raise(MyError) {
erb.result
@@ -98,12 +92,9 @@ class TestERBCore < Test::Unit::TestCase
end
def test_core
- # [deprecated] Fix initializer later
- EnvUtil.suppress_warning do
- _test_core(nil)
- _test_core(0)
- _test_core(1)
- end
+ _test_core(nil)
+ _test_core(0)
+ _test_core(1)
end
def _test_core(safe)
@@ -212,51 +203,29 @@ EOS
end
def test_trim_line1_with_carriage_return
- erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", trim_mode: '>')
+ erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", nil, '>')
assert_equal("line\r\n" * 3, erb.result)
- erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", trim_mode: '%>')
+ erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", nil, '%>')
assert_equal("line\r\n" * 3, erb.result)
end
def test_trim_line2_with_carriage_return
- erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", trim_mode: '<>')
+ erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", nil, '<>')
assert_equal("line\r\n" * 3, erb.result)
- erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", trim_mode: '%<>')
+ erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", nil, '%<>')
assert_equal("line\r\n" * 3, erb.result)
end
def test_explicit_trim_line_with_carriage_return
- erb = @erb.new("<%- 3.times do -%>\r\nline\r\n<%- end -%>\r\n", trim_mode: '-')
+ erb = @erb.new("<%- 3.times do -%>\r\nline\r\n<%- end -%>\r\n", nil, '-')
assert_equal("line\r\n" * 3, erb.result)
- erb = @erb.new("<%- 3.times do -%>\r\nline\r\n<%- end -%>\r\n", trim_mode: '%-')
+ erb = @erb.new("<%- 3.times do -%>\r\nline\r\n<%- end -%>\r\n", nil, '%-')
assert_equal("line\r\n" * 3, erb.result)
end
- def test_invalid_trim_mode
- assert_warning(/#{__FILE__}:#{__LINE__ + 1}/) do
- @erb.new("", trim_mode: 'abc-def')
- end
-
- assert_warning(/Invalid ERB trim mode/) do
- @erb.new("", trim_mode: 'abc-def')
- end
-
- assert_warning(/Invalid ERB trim mode/) do
- @erb.new("", trim_mode: '%<')
- end
-
- assert_warning(/Invalid ERB trim mode/) do
- @erb.new("", trim_mode: '%<>-')
- end
-
- assert_warning(/Invalid ERB trim mode/) do
- @erb.new("", trim_mode: 3)
- end
- end
-
def test_run
out = StringIO.new
orig, $stdout = $stdout, out
@@ -290,26 +259,26 @@ EOS
%n = 1
<%= n%>
EOS
- assert_equal("1\n", ERB.new(src, trim_mode: '%').result(binding))
+ assert_equal("1\n", ERB.new(src, nil, '%').result(binding))
src = <<EOS
<%
%>
EOS
ans = "\n"
- assert_equal(ans, ERB.new(src, trim_mode: '%').result(binding))
+ assert_equal(ans, ERB.new(src, nil, '%').result(binding))
src = "<%\n%>"
# ans = "\n"
ans = ""
- assert_equal(ans, ERB.new(src, trim_mode: '%').result(binding))
+ assert_equal(ans, ERB.new(src, nil, '%').result(binding))
src = <<EOS
<%
n = 1
%><%= n%>
EOS
- assert_equal("1\n", ERB.new(src, trim_mode: '%').result(binding))
+ assert_equal("1\n", ERB.new(src, nil, '%').result(binding))
src = <<EOS
%n = 1
@@ -325,7 +294,7 @@ EOS
% %%><%1
%%
EOS
- assert_equal(ans, ERB.new(src, trim_mode: '%').result(binding))
+ assert_equal(ans, ERB.new(src, nil, '%').result(binding))
end
def test_def_erb_method
@@ -409,7 +378,7 @@ foo
%% print 'foo'
EOS
- assert_equal(ans, ERB.new(src, trim_mode: '%').result)
+ assert_equal(ans, ERB.new(src, nil, '%').result)
end
def test_keep_lineno
@@ -420,7 +389,7 @@ Hello,\s
% raise("lineno")
EOS
- erb = ERB.new(src, trim_mode: '%')
+ erb = ERB.new(src, nil, '%')
e = assert_raise(RuntimeError) {
erb.result
}
@@ -438,7 +407,7 @@ EOS
%>Hello,\s
World%>
EOS
- assert_equal(ans, ERB.new(src, trim_mode: '>').result)
+ assert_equal(ans, ERB.new(src, nil, '>').result)
ans = <<EOS
%>
@@ -446,7 +415,7 @@ Hello,\s
World%>
EOS
- assert_equal(ans, ERB.new(src, trim_mode: '<>').result)
+ assert_equal(ans, ERB.new(src, nil, '<>').result)
ans = <<EOS
%>
@@ -471,13 +440,13 @@ EOS
}
assert_match(/\A\(erb\):5\b/, e.backtrace[0].to_s)
- erb = ERB.new(src, trim_mode: '>')
+ erb = ERB.new(src, nil, '>')
e = assert_raise(RuntimeError) {
erb.result
}
assert_match(/\A\(erb\):5\b/, e.backtrace[0].to_s)
- erb = ERB.new(src, trim_mode: '<>')
+ erb = ERB.new(src, nil, '<>')
e = assert_raise(RuntimeError) {
erb.result
}
@@ -491,13 +460,13 @@ EOS
<% raise("lineno") %>
EOS
- erb = ERB.new(src, trim_mode: '-')
+ erb = ERB.new(src, nil, '-')
e = assert_raise(RuntimeError) {
erb.result
}
assert_match(/\A\(erb\):5\b/, e.backtrace[0].to_s)
- erb = ERB.new(src, trim_mode: '%-')
+ erb = ERB.new(src, nil, '%-')
e = assert_raise(RuntimeError) {
erb.result
}
@@ -533,8 +502,8 @@ NotSkip NotSkip
* WORLD
KeepNewLine \s
EOS
- assert_equal(ans, ERB.new(src, trim_mode: '-').result)
- assert_equal(ans, ERB.new(src, trim_mode: '-%').result)
+ assert_equal(ans, ERB.new(src, nil, '-').result)
+ assert_equal(ans, ERB.new(src, nil, '-%').result)
end
def test_url_encode
@@ -550,7 +519,7 @@ EOS
end
def test_percent_after_etag
- assert_equal("1%", @erb.new("<%= 1 %>%", trim_mode: "%").result)
+ assert_equal("1%", @erb.new("<%= 1 %>%", nil, "%").result)
end
def test_token_extension
@@ -660,47 +629,6 @@ EOS
@erb.new("<% # comment %>\n").result
end
end
-
- # [deprecated] These interfaces will be removed later
- def test_deprecated_interface_warnings
- [nil, 0].each do |safe|
- assert_warning(/2nd argument of ERB.new is deprecated/) do
- ERB.new('', safe)
- end
- end
-
- [1, 2].each do |safe|
- assert_warn(/2nd argument of ERB.new is deprecated/) do
- ERB.new('', safe)
- end
- end
-
- [nil, '', '%', '%<>'].each do |trim|
- assert_warning(/3rd argument of ERB.new is deprecated/) do
- ERB.new('', nil, trim)
- end
- end
-
- [nil, '_erbout', '_hamlout'].each do |eoutvar|
- assert_warning(/4th argument of ERB.new is deprecated/) do
- ERB.new('', nil, nil, eoutvar)
- end
- end
- end
-
- def test_prohibited_marshal_dump
- erb = ERB.new("")
- assert_raise(TypeError) {Marshal.dump(erb)}
- end
-
- def test_prohibited_marshal_load
- erb = ERB.allocate
- erb.instance_variable_set(:@src, "")
- erb.instance_variable_set(:@lineno, 1)
- erb.instance_variable_set(:@_init, true)
- erb = Marshal.load(Marshal.dump(erb))
- assert_raise(ArgumentError) {erb.result}
- end
end
class TestERBCoreWOStrScan < TestERBCore
diff --git a/test/erb/test_erb_command.rb b/test/erb/test_erb_command.rb
index ed13c29c96..7e2b874632 100644
--- a/test/erb/test_erb_command.rb
+++ b/test/erb/test_erb_command.rb
@@ -15,16 +15,4 @@ class TestErbCommand < Test::Unit::TestCase
File.expand_path("../../../bin/erb", __FILE__)],
"<%=''.encoding.to_s%>", ["UTF-8"])
end
-
- # These interfaces will be removed at Ruby 2.7.
- def test_deprecated_option
- warnings = [
- "warning: -S option of erb command is deprecated. Please do not use this.",
- /\n.+\/bin\/erb:\d+: warning: Passing safe_level with the 2nd argument of ERB\.new is deprecated\. Do not use it, and specify other arguments as keyword arguments\.\n/,
- ]
- assert_in_out_err(["-w",
- File.expand_path("../../../bin/erb", __FILE__),
- "-S", "0"],
- "hoge", ["hoge"], warnings)
- end
end
diff --git a/test/erb/test_erb_m17n.rb b/test/erb/test_erb_m17n.rb
index 2fd9e700f3..a7840c9605 100644
--- a/test/erb/test_erb_m17n.rb
+++ b/test/erb/test_erb_m17n.rb
@@ -3,7 +3,7 @@
require 'test/unit'
require 'erb'
-class TestERBEncoding < Test::Unit::TestCase
+class TestERB < Test::Unit::TestCase
def test_result_encoding
erb = ERB.new("hello")
assert_equal __ENCODING__, erb.result.encoding
diff --git a/test/excludes/_appveyor/TestArray.rb b/test/excludes/_appveyor/TestArray.rb
deleted file mode 100644
index 7d03833f07..0000000000
--- a/test/excludes/_appveyor/TestArray.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# https://ci.appveyor.com/project/ruby/ruby/builds/20339189/job/ltdpffep976xtj85
-# `test_push_over_ary_max': failed to allocate memory (NoMemoryError)
-exclude(:test_push_over_ary_max, 'Sometimes AppVeyor has insufficient memory to run this test')
-# https://ci.appveyor.com/project/ruby/ruby/builds/20728419/job/o73q9fy1ojfibg5v
-exclude(:test_unshift_over_ary_max, 'Sometimes AppVeyor has insufficient memory to run this test')
-# https://ci.appveyor.com/project/ruby/ruby/builds/20427662/job/prq9i2lkfxv2j0uy
-exclude(:test_splice_over_ary_max, 'Sometimes AppVeyor has insufficient memory to run this test')
diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb
index 73f6f78d6d..4aaa55ea78 100644
--- a/test/fiddle/helper.rb
+++ b/test/fiddle/helper.rb
@@ -10,28 +10,12 @@ case RUBY_PLATFORM
when /cygwin/
libc_so = "cygwin1.dll"
libm_so = "cygwin1.dll"
-when /android/
- libdir = '/system/lib'
- if [0].pack('L!').size == 8
- libdir = '/system/lib64'
- end
- libc_so = File.join(libdir, "libc.so")
- libm_so = File.join(libdir, "libm.so")
when /linux/
libdir = '/lib'
- case RbConfig::SIZEOF['void*']
+ case [0].pack('L!').size
when 4
# 32-bit ruby
- case RUBY_PLATFORM
- when /armv\w+-linux/
- # In the ARM 32-bit libc package such as libc6:armhf libc6:armel,
- # libc.so and libm.so are installed to /lib/arm-linux-gnu*.
- # It's not installed to /lib32.
- dirs = Dir.glob('/lib/arm-linux-gnu*')
- libdir = dirs[0] if dirs && File.directory?(dirs[0])
- else
- libdir = '/lib32' if File.directory? '/lib32'
- end
+ libdir = '/lib32' if File.directory? '/lib32'
when 8
# 64-bit ruby
libdir = '/lib64' if File.directory? '/lib64'
@@ -43,7 +27,8 @@ when /mingw/, /mswin/
crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase'
libc_so = libm_so = "#{crtname}.dll"
when /darwin/
- libc_so = libm_so = "/usr/lib/libSystem.B.dylib"
+ libc_so = "/usr/lib/libc.dylib"
+ libm_so = "/usr/lib/libm.dylib"
when /kfreebsd/
libc_so = "/lib/libc.so.0.1"
libm_so = "/lib/libm.so.1"
@@ -61,7 +46,7 @@ when /bsd|dragonfly/
libm_so = "/usr/lib/libm.so"
when /solaris/
libdir = '/lib'
- case RbConfig::SIZEOF['void*']
+ case [0].pack('L!').size
when 4
# 32-bit ruby
libdir = '/lib' if File.directory? '/lib'
@@ -110,16 +95,8 @@ end
libc_so = nil if !libc_so || (libc_so[0] == ?/ && !File.file?(libc_so))
libm_so = nil if !libm_so || (libm_so[0] == ?/ && !File.file?(libm_so))
-# macOS 11.0+ removed libSystem.B.dylib from /usr/lib. But It works with dlopen.
-if RUBY_PLATFORM =~ /darwin/
- libc_so = libm_so = "/usr/lib/libSystem.B.dylib"
-end
-
if !libc_so || !libm_so
ruby = EnvUtil.rubybin
- # When the ruby binary is 32-bit and the host is 64-bit,
- # `ldd ruby` outputs "not a dynamic executable" message.
- # libc_so and libm_so are not set.
ldd = `ldd #{ruby}`
#puts ldd
libc_so = $& if !libc_so && %r{/\S*/libc\.so\S*} =~ ldd
diff --git a/test/fiddle/test_cparser.rb b/test/fiddle/test_cparser.rb
index 5d9ac3c815..c053706e13 100644
--- a/test/fiddle/test_cparser.rb
+++ b/test/fiddle/test_cparser.rb
@@ -127,13 +127,10 @@ module Fiddle
'short', 'unsigned short',
'int', 'unsigned int',
'long', 'unsigned long',
- defined?(TYPE_LONG_LONG) && \
- [
'long long', 'unsigned long long',
- ],
'float', 'double',
'const char*', 'void*',
- ].flatten.compact
+ ]
func, ret, args = parse_signature("void func(#{types.join(',')})")
assert_equal 'func', func
assert_equal TYPE_VOID, ret
@@ -142,13 +139,10 @@ module Fiddle
TYPE_SHORT, -TYPE_SHORT,
TYPE_INT, -TYPE_INT,
TYPE_LONG, -TYPE_LONG,
- defined?(TYPE_LONG_LONG) && \
- [
TYPE_LONG_LONG, -TYPE_LONG_LONG,
- ],
TYPE_FLOAT, TYPE_DOUBLE,
TYPE_VOIDP, TYPE_VOIDP,
- ].flatten.compact, args
+ ], args
end
def test_signature_single_variable
diff --git a/test/fiddle/test_func.rb b/test/fiddle/test_func.rb
index ca89173766..8c35833a32 100644
--- a/test/fiddle/test_func.rb
+++ b/test/fiddle/test_func.rb
@@ -11,6 +11,16 @@ module Fiddle
assert_nil f.call(10)
end
+ def test_syscall_with_tainted_string
+ f = Function.new(@libc['system'], [TYPE_VOIDP], TYPE_INT)
+ Thread.new {
+ $SAFE = 1
+ assert_raise(SecurityError) do
+ f.call("uname -rs".dup.taint)
+ end
+ }.join
+ end
+
def test_sinf
begin
f = Function.new(@libm['sinf'], [TYPE_FLOAT], TYPE_FLOAT)
diff --git a/test/fiddle/test_function.rb b/test/fiddle/test_function.rb
index a58d7afcb1..cbf84eae9d 100644
--- a/test/fiddle/test_function.rb
+++ b/test/fiddle/test_function.rb
@@ -73,12 +73,6 @@ module Fiddle
end
def test_nogvl_poll
- # XXX hack to quiet down CI errors on EINTR from r64353
- # [ruby-core:88360] [Misc #14937]
- # Making pipes (and sockets) non-blocking by default would allow
- # us to get rid of POSIX timers / timer pthread
- # https://bugs.ruby-lang.org/issues/14968
- IO.pipe { |r,w| IO.select([r], [w]) }
begin
poll = @libc['poll']
rescue Fiddle::DLError
@@ -92,26 +86,15 @@ module Fiddle
n1 = f.call(nil, 0, msec)
n2 = th.value
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
- assert_in_delta(msec, t1 - t0, 180, 'slept amount of time')
- assert_equal(0, n1, perror("poll(2) in main-thread"))
- assert_equal(0, n2, perror("poll(2) in sub-thread"))
+ assert_in_delta(msec, t1 - t0, 100, 'slept correct amount of time')
+ assert_equal(0, n1, 'poll(2) called correctly main-thread')
+ assert_equal(0, n2, 'poll(2) called correctly in sub-thread')
end
def test_no_memory_leak
- prep = 'r = Fiddle::Function.new(Fiddle.dlopen(nil)["rb_obj_frozen"], [Fiddle::TYPE_UINTPTR_T], Fiddle::TYPE_UINTPTR_T); a = "a"'
+ prep = 'r = Fiddle::Function.new(Fiddle.dlopen(nil)["rb_obj_tainted"], [Fiddle::TYPE_UINTPTR_T], Fiddle::TYPE_UINTPTR_T); a = "a"'
code = 'begin r.call(a); rescue TypeError; end'
assert_no_memory_leak(%w[-W0 -rfiddle], "#{prep}\n1000.times{#{code}}", "10_000.times {#{code}}", limit: 1.2)
end
-
- private
-
- def perror(m)
- proc do
- if e = Fiddle.last_error
- m = "#{m}: #{SystemCallError.new(e).message}"
- end
- m
- end
- end
end
end if defined?(Fiddle)
diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb
index 17f9c92a11..77559eb4d9 100644
--- a/test/fiddle/test_handle.rb
+++ b/test/fiddle/test_handle.rb
@@ -8,6 +8,25 @@ module Fiddle
class TestHandle < TestCase
include Fiddle
+ def test_safe_handle_open
+ Thread.new do
+ $SAFE = 1
+ assert_raise(SecurityError) {
+ Fiddle::Handle.new(LIBC_SO.dup.taint)
+ }
+ end.join
+ end
+
+ def test_safe_function_lookup
+ Thread.new do
+ h = Fiddle::Handle.new(LIBC_SO)
+ $SAFE = 1
+ assert_raise(SecurityError) {
+ h["qsort".dup.taint]
+ }
+ end.join
+ end
+
def test_to_i
handle = Fiddle::Handle.new(LIBC_SO)
assert_kind_of Integer, handle.to_i
diff --git a/test/fiddle/test_import.rb b/test/fiddle/test_import.rb
index 99294ea161..ff16d17d50 100644
--- a/test/fiddle/test_import.rb
+++ b/test/fiddle/test_import.rb
@@ -64,7 +64,7 @@ module Fiddle
assert_equal(SIZEOF_VOIDP, LIBC.sizeof("FILE*"))
assert_equal(LIBC::MyStruct.size(), LIBC.sizeof(LIBC::MyStruct))
assert_equal(LIBC::MyStruct.size(), LIBC.sizeof(LIBC::MyStruct.malloc()))
- assert_equal(SIZEOF_LONG_LONG, LIBC.sizeof("long long")) if defined?(SIZEOF_LONG_LONG)
+ assert_equal(SIZEOF_LONG_LONG, LIBC.sizeof("long long"))
end
Fiddle.constants.grep(/\ATYPE_(?!VOID\z)(.*)/) do
@@ -147,9 +147,5 @@ module Fiddle
r = LIBC.atof("12.34")
assert_includes(12.00..13.00, r)
end
-
- def test_no_message_with_debug
- assert_in_out_err(%w[--debug --disable=gems -rfiddle/import], 'p Fiddle::Importer', ['Fiddle::Importer'])
- end
end
end if defined?(Fiddle)
diff --git a/test/fiddle/test_pointer.rb b/test/fiddle/test_pointer.rb
index 5581c1dea7..27a8a6cb06 100644
--- a/test/fiddle/test_pointer.rb
+++ b/test/fiddle/test_pointer.rb
@@ -79,6 +79,7 @@ module Fiddle
def test_to_ptr_string
str = "hello world"
ptr = Pointer[str]
+ assert ptr.tainted?, 'pointer should be tainted'
assert_equal str.length, ptr.size
assert_equal 'hello', ptr[0,5]
end
@@ -151,7 +152,11 @@ module Fiddle
def test_free=
assert_normal_exit(<<-"End", '[ruby-dev:39269]')
require 'fiddle'
+ Fiddle::LIBC_SO = #{Fiddle::LIBC_SO.dump}
+ Fiddle::LIBM_SO = #{Fiddle::LIBM_SO.dump}
include Fiddle
+ @libc = dlopen(LIBC_SO)
+ @libm = dlopen(LIBM_SO)
free = Fiddle::Function.new(Fiddle::RUBY_FREE, [TYPE_VOIDP], TYPE_VOID)
ptr = Fiddle::Pointer.malloc(4)
ptr.free = free
diff --git a/test/fileutils/test_dryrun.rb b/test/fileutils/test_dryrun.rb
index fd8a7805ec..97d72fcdf9 100644
--- a/test/fileutils/test_dryrun.rb
+++ b/test/fileutils/test_dryrun.rb
@@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsDryRun < Test::Unit::TestCase
include FileUtils::DryRun
- include TestFileUtilsInc::Visibility
+ include TestFileUtils::Visibility
def setup
super
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index ca435ed1ff..521a712acb 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -6,7 +6,6 @@ require 'etc'
require_relative 'fileasserts'
require 'pathname'
require 'tmpdir'
-require 'stringio'
require 'test/unit'
class TestFileUtils < Test::Unit::TestCase
@@ -234,7 +233,7 @@ class TestFileUtils < Test::Unit::TestCase
def test_assert_output_lines
assert_raise(MiniTest::Assertion) {
- Timeout.timeout(0.5) {
+ Timeout.timeout(0.1) {
assert_output_lines([]) {
Thread.current.report_on_exception = false
raise "ok"
@@ -382,16 +381,6 @@ class TestFileUtils < Test::Unit::TestCase
assert_same_file 'tmp/cpr_src/b', 'tmp/cpr_dest/b'
assert_same_file 'tmp/cpr_src/c', 'tmp/cpr_dest/c'
assert_directory 'tmp/cpr_dest/d'
- assert_raise(ArgumentError) do
- cp_r 'tmp/cpr_src', './tmp/cpr_src'
- end
- assert_raise(ArgumentError) do
- cp_r './tmp/cpr_src', 'tmp/cpr_src'
- end
- assert_raise(ArgumentError) do
- cp_r './tmp/cpr_src', File.expand_path('tmp/cpr_src')
- end
-
my_rm_rf 'tmp/cpr_src'
my_rm_rf 'tmp/cpr_dest'
@@ -441,35 +430,6 @@ class TestFileUtils < Test::Unit::TestCase
}
end if have_symlink? and !no_broken_symlink?
- def test_cp_r_fifo
- Dir.mkdir('tmp/cpr_src')
- File.mkfifo 'tmp/cpr_src/fifo', 0600
- cp_r 'tmp/cpr_src', 'tmp/cpr_dest'
- assert_equal(true, File.pipe?('tmp/cpr_dest/fifo'))
- end if File.respond_to?(:mkfifo)
-
- def test_cp_r_dev
- devs = Dir['/dev/*']
- chardev = devs.find{|f| File.chardev?(f)}
- blockdev = devs.find{|f| File.blockdev?(f)}
- Dir.mkdir('tmp/cpr_dest')
- assert_raise(RuntimeError) { cp_r chardev, 'tmp/cpr_dest/cd' } if chardev
- assert_raise(RuntimeError) { cp_r blockdev, 'tmp/cpr_dest/bd' } if blockdev
- end
-
- begin
- require 'socket'
- rescue LoadError
- else
- def test_cp_r_socket
- pend "Skipping socket test on JRuby" if RUBY_ENGINE == 'jruby'
- Dir.mkdir('tmp/cpr_src')
- UNIXServer.new('tmp/cpr_src/socket').close
- cp_r 'tmp/cpr_src', 'tmp/cpr_dest'
- assert_equal(true, File.socket?('tmp/cpr_dest/socket'))
- end if defined?(UNIXServer)
- end
-
def test_cp_r_pathname
# pathname
touch 'tmp/cprtmp'
@@ -489,45 +449,6 @@ class TestFileUtils < Test::Unit::TestCase
cp_r 'tmp/src', 'tmp/dest/', remove_destination: true
end if have_symlink?
- def test_cp_lr
- check_singleton :cp_lr
-
- cp_lr 'data', 'tmp'
- TARGETS.each do |fname|
- assert_same_file fname, "tmp/#{fname}"
- end
-
- # a/* -> b/*
- mkdir 'tmp/cpr_src'
- mkdir 'tmp/cpr_dest'
- File.open('tmp/cpr_src/a', 'w') {|f| f.puts 'a' }
- File.open('tmp/cpr_src/b', 'w') {|f| f.puts 'b' }
- File.open('tmp/cpr_src/c', 'w') {|f| f.puts 'c' }
- mkdir 'tmp/cpr_src/d'
- cp_lr 'tmp/cpr_src/.', 'tmp/cpr_dest'
- assert_same_file 'tmp/cpr_src/a', 'tmp/cpr_dest/a'
- assert_same_file 'tmp/cpr_src/b', 'tmp/cpr_dest/b'
- assert_same_file 'tmp/cpr_src/c', 'tmp/cpr_dest/c'
- assert_directory 'tmp/cpr_dest/d'
- my_rm_rf 'tmp/cpr_src'
- my_rm_rf 'tmp/cpr_dest'
-
- bug3588 = '[ruby-core:31360]'
- mkdir 'tmp2'
- assert_nothing_raised(ArgumentError, bug3588) do
- cp_lr 'tmp', 'tmp2'
- end
- assert_directory 'tmp2/tmp'
- assert_raise(ArgumentError, bug3588) do
- cp_lr 'tmp2', 'tmp2/new_tmp2'
- end
-
- bug12892 = '[ruby-core:77885] [Bug #12892]'
- assert_raise(Errno::ENOENT, bug12892) do
- cp_lr 'non/existent', 'tmp'
- end
- end if have_hardlink?
-
def test_mv
check_singleton :mv
@@ -885,15 +806,13 @@ class TestFileUtils < Test::Unit::TestCase
check_singleton :ln_s
TARGETS.each do |fname|
- begin
- fname = "../#{fname}"
- lnfname = 'tmp/lnsdest'
- ln_s fname, lnfname
- assert FileTest.symlink?(lnfname), 'not symlink'
- assert_equal fname, File.readlink(lnfname)
- ensure
- rm_f lnfname
- end
+ fname = "../#{fname}"
+ lnfname = 'tmp/lnsdest'
+ ln_s fname, lnfname
+ assert FileTest.symlink?(lnfname), 'not symlink'
+ assert_equal fname, File.readlink(lnfname)
+ ensure
+ rm_f lnfname
end
end if have_symlink? and !no_broken_symlink?
@@ -1052,7 +971,7 @@ class TestFileUtils < Test::Unit::TestCase
else
tmpdir = Dir.pwd
end
- pend "No drive letter" unless /\A[a-z]:/i =~ tmpdir
+ skip "No drive letter" unless /\A[a-z]:/i =~ tmpdir
drive = "./#{$&}"
assert_file_not_exist drive
mkdir_p "#{tmpdir}/none/dir"
@@ -1160,30 +1079,6 @@ class TestFileUtils < Test::Unit::TestCase
}
end
- def test_install_mode_option
- File.open('tmp/a', 'w') {|f| f.puts 'aaa' }
- install 'tmp/a', 'tmp/b', :mode => "u=wrx,g=rx,o=x"
- assert_filemode 0751, 'tmp/b'
- install 'tmp/b', 'tmp/c', :mode => "g+w-x"
- assert_filemode 0761, 'tmp/c'
- install 'tmp/c', 'tmp/d', :mode => "o+r,g=o+w,o-r,u-o" # 761 => 763 => 773 => 771 => 671
- assert_filemode 0671, 'tmp/d'
- install 'tmp/d', 'tmp/e', :mode => "go=u"
- assert_filemode 0666, 'tmp/e'
- install 'tmp/e', 'tmp/f', :mode => "u=wrx,g=,o="
- assert_filemode 0700, 'tmp/f'
- install 'tmp/f', 'tmp/g', :mode => "u=rx,go="
- assert_filemode 0500, 'tmp/g'
- install 'tmp/g', 'tmp/h', :mode => "+wrx"
- assert_filemode 0777, 'tmp/h'
- install 'tmp/h', 'tmp/i', :mode => "u+s,o=s"
- assert_filemode 04770, 'tmp/i'
- install 'tmp/i', 'tmp/j', :mode => "u-w,go-wrx"
- assert_filemode 04500, 'tmp/j'
- install 'tmp/j', 'tmp/k', :mode => "+s"
- assert_filemode 06500, 'tmp/k'
- end if have_file_perm?
-
def test_chmod
check_singleton :chmod
@@ -1690,37 +1585,10 @@ class TestFileUtils < Test::Unit::TestCase
check_singleton :cd
end
- def test_cd_result
- assert_equal 42, cd('.') { 42 }
- end
-
def test_chdir
check_singleton :chdir
end
- def test_chdir_verbose
- assert_output_lines(["cd .", "cd -"], FileUtils) do
- FileUtils.chdir('.', verbose: true){}
- end
- end
-
- def test_chdir_verbose_frozen
- o = Object.new
- o.extend(FileUtils)
- o.singleton_class.send(:public, :chdir)
- o.freeze
- orig_stderr = $stderr
- $stderr = StringIO.new
- o.chdir('.', verbose: true){}
- $stderr.rewind
- assert_equal(<<-END, $stderr.read)
-cd .
-cd -
- END
- ensure
- $stderr = orig_stderr if orig_stderr
- end
-
def test_getwd
check_singleton :getwd
end
diff --git a/test/fileutils/test_nowrite.rb b/test/fileutils/test_nowrite.rb
index 543fa39f5a..b804498525 100644
--- a/test/fileutils/test_nowrite.rb
+++ b/test/fileutils/test_nowrite.rb
@@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsNoWrite < Test::Unit::TestCase
include FileUtils::NoWrite
- include TestFileUtilsInc::Visibility
+ include TestFileUtils::Visibility
def setup
super
diff --git a/test/fileutils/test_verbose.rb b/test/fileutils/test_verbose.rb
index cf65be8e03..0019946393 100644
--- a/test/fileutils/test_verbose.rb
+++ b/test/fileutils/test_verbose.rb
@@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsVerbose < Test::Unit::TestCase
include FileUtils::Verbose
- include TestFileUtilsInc::Visibility
+ include TestFileUtils::Visibility
def setup
super
diff --git a/test/fileutils/visibility_tests.rb b/test/fileutils/visibility_tests.rb
index 4c02c9d207..0ce00d5f2c 100644
--- a/test/fileutils/visibility_tests.rb
+++ b/test/fileutils/visibility_tests.rb
@@ -2,14 +2,14 @@
require 'test/unit'
require 'fileutils'
-class TestFileUtilsInc < Test::Unit::TestCase
+class TestFileUtils < Test::Unit::TestCase
end
##
# These tests are reused in the FileUtils::Verbose, FileUtils::NoWrite and
# FileUtils::DryRun tests
-module TestFileUtilsInc::Visibility
+module TestFileUtils::Visibility
FileUtils::METHODS.each do |m|
define_method "test_singleton_visibility_#{m}" do
diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb
index 64692a4465..9e97eb3587 100644
--- a/test/gdbm/test_gdbm.rb
+++ b/test/gdbm/test_gdbm.rb
@@ -164,7 +164,7 @@ if defined? GDBM
open_db_child(dbname) do
assert_raise(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
GDBM.open(dbname, 0644) {|gdbm|
- assert(false)
+ assert_instance_of(GDBM, gdbm)
}
}
end
@@ -213,7 +213,7 @@ if defined? GDBM
end if defined? GDBM::NOLOCK # gdbm 1.8.0 specific
def test_s_open_error
- skip "because root can open anything" if Process.uid == 0
+ skip if Process.uid == 0 # because root can open anything
assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0))
assert_raise(Errno::EACCES, Errno::EWOULDBLOCK) {
@@ -726,8 +726,7 @@ if defined? GDBM
def test_freeze
GDBM.open("#{@tmproot}/a.dbm") {|d|
d.freeze
- expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
- assert_raise(expected_error) { d["k"] = "v" }
+ assert_raise(FrozenError) { d["k"] = "v" }
}
end
end
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index a02605dd1e..764c5e1a61 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -7,28 +7,6 @@ rescue LoadError
end
class TestIO_Console < Test::Unit::TestCase
- PATHS = $LOADED_FEATURES.grep(%r"/io/console(?:\.#{RbConfig::CONFIG['DLEXT']}|/\w+\.rb)\z") {$`}
- PATHS.uniq!
-
- # FreeBSD seems to hang on TTOU when running parallel tests
- # tested on FreeBSD 11.x.
- #
- # Solaris gets stuck too, even in non-parallel mode.
- # It occurs only in chkbuild. It does not occur when running
- # `make test-all` in SSH terminal.
- #
- # I suspect that it occurs only when having no TTY.
- # (Parallel mode runs tests in child processes, so I guess
- # they has no TTY.)
- # But it does not occur in `make test-all > /dev/null`, so
- # there should be an additional factor, I guess.
- def set_winsize_setup
- @old_ttou = trap(:TTOU, 'IGNORE') if RUBY_PLATFORM =~ /freebsd|solaris/i
- end
-
- def set_winsize_teardown
- trap(:TTOU, @old_ttou) if defined?(@old_ttou) and @old_ttou
- end
end
defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
@@ -51,15 +29,12 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
end
def test_raw_minchar
- q = Thread::Queue.new
helper {|m, s|
len = 0
assert_equal([nil, 0], [s.getch(min: 0), len])
main = Thread.current
go = false
th = Thread.start {
- q.pop
- sleep 0.01 until main.stop?
len += 1
m.print("a")
m.flush
@@ -69,8 +44,6 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
m.flush
}
begin
- sleep 0.1
- q.push(1)
assert_equal(["a", 1], [s.getch(min: 1), len])
go = true
assert_equal(["1", 11], [s.getch, len])
@@ -154,22 +127,22 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
sleep 0.1
s.print "b\n"
sleep 0.1
- assert_equal("a\r\nb\r\n", m.gets + m.gets)
- assert_equal("a\n", s.gets)
+ assert_equal("a\r\nb\r\n", m.readpartial(10))
+ assert_equal("a\n", s.readpartial(10))
s.noecho {
assert_not_send([s, :echo?])
m.print "a\n"
s.print "b\n"
- assert_equal("b\r\n", m.gets)
- assert_equal("a\n", s.gets)
+ assert_equal("b\r\n", m.readpartial(10))
+ assert_equal("a\n", s.readpartial(10))
}
assert_send([s, :echo?])
m.print "a\n"
sleep 0.1
s.print "b\n"
sleep 0.1
- assert_equal("a\r\nb\r\n", m.gets + m.gets)
- assert_equal("a\n", s.gets)
+ assert_equal("a\r\nb\r\n", m.readpartial(10))
+ assert_equal("a\n", s.readpartial(10))
}
end
@@ -192,22 +165,22 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
sleep 0.1
s.print "b\n"
sleep 0.1
- assert_equal("a\r\nb\r\n", m.gets + m.gets)
- assert_equal("a\n", s.gets)
+ assert_equal("a\r\nb\r\n", m.readpartial(10))
+ assert_equal("a\n", s.readpartial(10))
s.echo = false
assert_not_send([s, :echo?])
m.print "a\n"
s.print "b\n"
- assert_equal("b\r\n", m.gets)
- assert_equal("a\n", s.gets)
+ assert_equal("b\r\n", m.readpartial(10))
+ assert_equal("a\n", s.readpartial(10))
s.echo = true
assert_send([s, :echo?])
m.print "a\n"
sleep 0.1
s.print "b\n"
sleep 0.1
- assert_equal("a\r\nb\r\n", m.gets + m.gets)
- assert_equal("a\n", s.gets)
+ assert_equal("a\r\nb\r\n", m.readpartial(10))
+ assert_equal("a\n", s.readpartial(10))
}
end
@@ -229,7 +202,7 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
s.iflush
m.print "b\n"
m.flush
- assert_equal("b\n", s.gets)
+ assert_equal("b\n", s.readpartial(10))
}
end
@@ -239,7 +212,6 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
s.oflush # oflush may be issued after "a" is already sent.
s.print "b"
s.flush
- sleep 0.1
assert_include(["b", "ab"], m.readpartial(10))
}
end
@@ -250,7 +222,7 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
s.ioflush
m.print "b\n"
m.flush
- assert_equal("b\n", s.gets)
+ assert_equal("b\n", s.readpartial(10))
}
end
@@ -282,7 +254,6 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
end
def test_set_winsize_invalid_dev
- set_winsize_setup
[IO::NULL, __FILE__].each do |path|
open(path) do |io|
begin
@@ -295,81 +266,6 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
assert_raise(ArgumentError) {io.winsize = [0, 0, 0]}
end
end
- ensure
- set_winsize_teardown
- end
-
- def test_cursor_position
- run_pty("#{<<~"begin;"}\n#{<<~'end;'}") do |r, w, _|
- begin;
- con = IO.console
- p con.cursor
- con.cursor_down(3); con.puts
- con.cursor_right(4); con.puts
- con.cursor_left(2); con.puts
- con.cursor_up(1); con.puts
- end;
- assert_equal("\e[6n", r.readpartial(5))
- w.print("\e[12;34R"); w.flush
- assert_equal([11, 33], eval(r.gets))
- assert_equal("\e[3B", r.gets.chomp)
- assert_equal("\e[4C", r.gets.chomp)
- assert_equal("\e[2D", r.gets.chomp)
- assert_equal("\e[1A", r.gets.chomp)
- end
- end
-
- def assert_ctrl(expect, cc, r, w)
- sleep 0.1
- w.print cc
- w.flush
- result = EnvUtil.timeout(3) {r.gets}
- assert_equal(expect, result.chomp)
- end
-
- def test_intr
- run_pty("#{<<~"begin;"}\n#{<<~'end;'}") do |r, w, _|
- begin;
- require 'timeout'
- STDOUT.puts `stty -a`.scan(/\b\w+ *= *\^.;/), ""
- STDOUT.flush
- con = IO.console
- while c = con.getch
- p c.ord
- p con.getch(intr: false).ord
- begin
- p Timeout.timeout(1) {con.getch(intr: true)}.ord
- rescue Timeout::Error, Interrupt => e
- p e
- end
- end
- end;
- ctrl = {}
- r.each do |l|
- break unless /^(\w+) *= *\^(\\?.)/ =~ l
- ctrl[$1] = eval("?\\C-#$2")
- end
- if cc = ctrl["intr"]
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("Interrupt", cc, r, w) unless /linux/ =~ RUBY_PLATFORM
- end
- if cc = ctrl["dsusp"]
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("#{cc.ord}", cc, r, w)
- end
- if cc = ctrl["lnext"]
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("#{cc.ord}", cc, r, w)
- end
- if cc = ctrl["stop"]
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("#{cc.ord}", cc, r, w)
- assert_ctrl("#{cc.ord}", cc, r, w)
- end
- end
end
unless IO.console
@@ -396,7 +292,7 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
end
def run_pty(src, n = 1)
- r, w, pid = PTY.spawn(EnvUtil.rubybin, "-I#{TestIO_Console::PATHS.join(File::PATH_SEPARATOR)}", "-rio/console", "-e", src)
+ r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", src)
rescue RuntimeError
skip $!
else
@@ -425,7 +321,6 @@ defined?(IO.console) and TestIO_Console.class_eval do
end
def test_set_winsize_console
- set_winsize_setup
s = IO.console.winsize
assert_nothing_raised(TypeError) {IO.console.winsize = s}
bug = '[ruby-core:82741] [Bug #13888]'
@@ -433,8 +328,6 @@ defined?(IO.console) and TestIO_Console.class_eval do
assert_equal([s[0], s[1]+1], IO.console.winsize, bug)
IO.console.winsize = s
assert_equal(s, IO.console.winsize, bug)
- ensure
- set_winsize_teardown
end
def test_close
@@ -462,7 +355,7 @@ defined?(IO.console) and TestIO_Console.class_eval do
noctty = [EnvUtil.rubybin, "-e", "Process.daemon(true)"]
when !(rubyw = RbConfig::CONFIG["RUBYW_INSTALL_NAME"]).empty?
dir, base = File.split(EnvUtil.rubybin)
- noctty = [File.join(dir, base.sub(RUBY_ENGINE, rubyw))]
+ noctty = [File.join(dir, base.sub(/ruby/, rubyw))]
end
if noctty
diff --git a/test/io/nonblock/test_flush.rb b/test/io/nonblock/test_flush.rb
index 08d129de3f..63e16db5a3 100644
--- a/test/io/nonblock/test_flush.rb
+++ b/test/io/nonblock/test_flush.rb
@@ -53,7 +53,6 @@ class TestIONonblock < Test::Unit::TestCase
def test_nonblock
IO.pipe {|r, w|
- w.nonblock = false
assert_equal(false, w.nonblock?)
w.nonblock do
assert_equal(true, w.nonblock?)
diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb
index 6b4722e1be..2c1073d104 100644
--- a/test/io/wait/test_io_wait.rb
+++ b/test/io/wait/test_io_wait.rb
@@ -63,20 +63,16 @@ class TestIOWait < Test::Unit::TestCase
end
def test_wait_forever
- q = Thread::Queue.new
- th = Thread.new { q.pop; @w.syswrite "." }
- q.push(true)
+ th = Thread.new { sleep 0.01; @w.syswrite "." }
assert_equal @r, @r.wait
ensure
th.join
end
def test_wait_eof
- q = Thread::Queue.new
- th = Thread.new { q.pop; @w.close }
+ th = Thread.new { sleep 0.01; @w.close }
ret = nil
assert_nothing_raised(Timeout::Error) do
- q.push(true)
Timeout.timeout(0.1) { ret = @r.wait }
end
assert_equal @r, ret
@@ -87,7 +83,7 @@ class TestIOWait < Test::Unit::TestCase
def test_wait_readable
assert_nil @r.wait_readable(0)
@w.syswrite "."
- IO.select([@r])
+ sleep 0.1
assert_equal @r, @r.wait_readable(0)
end
@@ -98,20 +94,16 @@ class TestIOWait < Test::Unit::TestCase
end
def test_wait_readable_forever
- q = Thread::Queue.new
- th = Thread.new { q.pop; @w.syswrite "." }
- q.push(true)
+ th = Thread.new { sleep 0.01; @w.syswrite "." }
assert_equal @r, @r.wait_readable
ensure
th.join
end
def test_wait_readable_eof
- q = Thread::Queue.new
- th = Thread.new { q.pop; @w.close }
+ th = Thread.new { sleep 0.01; @w.close }
ret = nil
assert_nothing_raised(Timeout::Error) do
- q.push(true)
Timeout.timeout(0.1) { ret = @r.wait_readable }
end
assert_equal @r, ret
@@ -172,8 +164,4 @@ private
return written
end while true
end
-
- def sleep(time)
- super EnvUtil.apply_timeout_scale(time)
- end
end if IO.method_defined?(:wait)
diff --git a/test/io/wait/test_io_wait_uncommon.rb b/test/io/wait/test_io_wait_uncommon.rb
deleted file mode 100644
index e7f222c578..0000000000
--- a/test/io/wait/test_io_wait_uncommon.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-require 'io/wait'
-
-# test uncommon device types to check portability problems
-# We may optimize IO#wait_*able for non-Linux kernels in the future
-class TestIOWaitUncommon < Test::Unit::TestCase
- def test_tty_wait
- begin
- tty = File.open('/dev/tty', 'w+')
- rescue Errno::ENOENT, Errno::ENXIO => e
- skip "/dev/tty: #{e.message} (#{e.class})"
- end
- assert_include [ nil, tty ], tty.wait_readable(0)
- assert_equal tty, tty.wait_writable(1), 'portability test'
- ensure
- tty&.close
- end
-
- def test_fifo_wait
- skip 'no mkfifo' unless File.respond_to?(:mkfifo) && IO.const_defined?(:NONBLOCK)
- Dir.mktmpdir('rubytest-fifo') do |dir|
- fifo = "#{dir}/fifo"
- assert_equal 0, File.mkfifo(fifo)
- rd = Thread.new { File.open(fifo, IO::RDONLY|IO::NONBLOCK) }
- begin
- wr = File.open(fifo, IO::WRONLY|IO::NONBLOCK)
- rescue Errno::ENXIO
- Thread.pass
- end until wr
- assert_instance_of File, rd.value
- assert_instance_of File, wr
- rd = rd.value
- assert_nil rd.wait_readable(0)
- assert_same wr, wr.wait_writable(0)
- wr.syswrite 'hi'
- assert_same rd, rd.wait_readable(1)
- wr.close
- assert_equal 'hi', rd.gets
- rd.close
- end
- end
-
- # used to find portability problems because some ppoll implementations
- # are incomplete and do not work for certain "file" types
- def check_dev(dev, m = :wait_readable)
- begin
- fp = File.open("/dev/#{dev}", m == :wait_readable ? 'r' : 'w')
- rescue SystemCallError => e
- skip "#{dev} could not be opened #{e.message} (#{e.class})"
- end
- assert_same fp, fp.__send__(m)
- ensure
- fp&.close
- end
-
- def test_wait_readable_urandom
- check_dev 'urandom'
- end
-
- def test_wait_readable_random
- File.open('/dev/random') do |fp|
- assert_nothing_raised do
- fp.wait_readable(0)
- end
- end
- rescue SystemCallError => e
- skip "/dev/random could not be opened #{e.message} (#{e.class})"
- end
-
- def test_wait_readable_zero
- check_dev 'zero'
- end
-
- def test_wait_writable_null
- check_dev 'null', :wait_writable
- end
-end
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb
deleted file mode 100644
index d0f1ac645c..0000000000
--- a/test/irb/test_cmd.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-# frozen_string_literal: false
-require "test/unit"
-require "irb"
-require "irb/extend-command"
-
-module TestIRB
- class ExtendCommand < Test::Unit::TestCase
- def setup
- @pwd = Dir.pwd
- @tmpdir = File.join(Dir.tmpdir, "test_reline_config_#{$$}")
- begin
- Dir.mkdir(@tmpdir)
- rescue Errno::EEXIST
- FileUtils.rm_rf(@tmpdir)
- Dir.mkdir(@tmpdir)
- end
- Dir.chdir(@tmpdir)
- @home_backup = ENV["HOME"]
- ENV["HOME"] = @tmpdir
- @xdg_config_home_backup = ENV.delete("XDG_CONFIG_HOME")
- @default_encoding = [Encoding.default_external, Encoding.default_internal]
- @stdio_encodings = [STDIN, STDOUT, STDERR].map {|io| [io.external_encoding, io.internal_encoding] }
- IRB.instance_variable_get(:@CONF).clear
- end
-
- def teardown
- ENV["XDG_CONFIG_HOME"] = @xdg_config_home_backup
- ENV["HOME"] = @home_backup
- Dir.chdir(@pwd)
- FileUtils.rm_rf(@tmpdir)
- EnvUtil.suppress_warning {
- Encoding.default_external, Encoding.default_internal = *@default_encoding
- [STDIN, STDOUT, STDERR].zip(@stdio_encodings) do |io, encs|
- io.set_encoding(*encs)
- end
- }
- end
-
- def test_irb_info_multiline
- FileUtils.touch("#{@tmpdir}/.inputrc")
- FileUtils.touch("#{@tmpdir}/.irbrc")
- IRB.setup(__FILE__, argv: [])
- IRB.conf[:USE_MULTILINE] = true
- IRB.conf[:USE_SINGLELINE] = false
- IRB.conf[:VERBOSE] = false
- workspace = IRB::WorkSpace.new(self)
- irb = IRB::Irb.new(workspace)
- IRB.conf[:MAIN_CONTEXT] = irb.context
- expected = %r{
- Ruby\sversion: .+\n
- IRB\sversion:\sirb .+\n
- InputMethod:\sReidlineInputMethod\swith\sReline .+ and .+\n
- \.irbrc\spath: .+
- }x
- assert_match expected, irb.context.main.irb_info.to_s
- end
-
- def test_irb_info_singleline
- FileUtils.touch("#{@tmpdir}/.inputrc")
- FileUtils.touch("#{@tmpdir}/.irbrc")
- IRB.setup(__FILE__, argv: [])
- IRB.conf[:USE_MULTILINE] = false
- IRB.conf[:USE_SINGLELINE] = true
- IRB.conf[:VERBOSE] = false
- workspace = IRB::WorkSpace.new(self)
- irb = IRB::Irb.new(workspace)
- IRB.conf[:MAIN_CONTEXT] = irb.context
- expected = %r{
- Ruby\sversion: .+\n
- IRB\sversion:\sirb .+\n
- InputMethod:\sReadlineInputMethod\swith .+ and .+\n
- \.irbrc\spath: .+
- }x
- assert_match expected, irb.context.main.irb_info.to_s
- end
-
- def test_irb_info_multiline_without_rc_files
- inputrc_backup = ENV["INPUTRC"]
- ENV["INPUTRC"] = "unknown_inpurc"
- ext_backup = IRB::IRBRC_EXT
- IRB.__send__(:remove_const, :IRBRC_EXT)
- IRB.const_set(:IRBRC_EXT, "unknown_ext")
- IRB.setup(__FILE__, argv: [])
- IRB.conf[:USE_MULTILINE] = true
- IRB.conf[:USE_SINGLELINE] = false
- IRB.conf[:VERBOSE] = false
- workspace = IRB::WorkSpace.new(self)
- irb = IRB::Irb.new(workspace)
- IRB.conf[:MAIN_CONTEXT] = irb.context
- expected = %r{
- Ruby\sversion: .+\n
- IRB\sversion:\sirb .+\n
- InputMethod:\sReidlineInputMethod\swith\sReline\s[^ ]+(?!\sand\s.+)\n
- \z
- }x
- assert_match expected, irb.context.main.irb_info.to_s
- ensure
- ENV["INPUTRC"] = inputrc_backup
- IRB.__send__(:remove_const, :IRBRC_EXT)
- IRB.const_set(:IRBRC_EXT, ext_backup)
- end
-
- def test_irb_info_singleline_without_rc_files
- inputrc_backup = ENV["INPUTRC"]
- ENV["INPUTRC"] = "unknown_inpurc"
- ext_backup = IRB::IRBRC_EXT
- IRB.__send__(:remove_const, :IRBRC_EXT)
- IRB.const_set(:IRBRC_EXT, "unknown_ext")
- IRB.setup(__FILE__, argv: [])
- IRB.conf[:USE_MULTILINE] = false
- IRB.conf[:USE_SINGLELINE] = true
- IRB.conf[:VERBOSE] = false
- workspace = IRB::WorkSpace.new(self)
- irb = IRB::Irb.new(workspace)
- IRB.conf[:MAIN_CONTEXT] = irb.context
- expected = %r{
- Ruby\sversion: .+\n
- IRB\sversion:\sirb .+\n
- InputMethod:\sReadlineInputMethod\swith\s(?~.*\sand\s.+)\n
- \z
- }x
- assert_match expected, irb.context.main.irb_info.to_s
- ensure
- ENV["INPUTRC"] = inputrc_backup
- IRB.__send__(:remove_const, :IRBRC_EXT)
- IRB.const_set(:IRBRC_EXT, ext_backup)
- end
- end
-end
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
deleted file mode 100644
index cb90d29c9d..0000000000
--- a/test/irb/test_color.rb
+++ /dev/null
@@ -1,193 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-require 'irb/color'
-require 'rubygems'
-require 'stringio'
-
-module TestIRB
- class TestColor < Test::Unit::TestCase
- CLEAR = "\e[0m"
- BOLD = "\e[1m"
- UNDERLINE = "\e[4m"
- REVERSE = "\e[7m"
- RED = "\e[31m"
- GREEN = "\e[32m"
- YELLOW = "\e[33m"
- BLUE = "\e[34m"
- MAGENTA = "\e[35m"
- CYAN = "\e[36m"
-
- def test_colorize_code
- # Common behaviors. Warn parser error, but do not warn compile error.
- tests = {
- "1" => "#{BLUE}#{BOLD}1#{CLEAR}",
- "2.3" => "#{MAGENTA}#{BOLD}2.3#{CLEAR}",
- "7r" => "#{BLUE}#{BOLD}7r#{CLEAR}",
- "8i" => "#{BLUE}#{BOLD}8i#{CLEAR}",
- "['foo', :bar]" => "[#{RED}#{BOLD}'#{CLEAR}#{RED}foo#{CLEAR}#{RED}#{BOLD}'#{CLEAR}, #{YELLOW}:#{CLEAR}#{YELLOW}bar#{CLEAR}]",
- "class A; end" => "#{GREEN}class#{CLEAR} #{BLUE}#{BOLD}#{UNDERLINE}A#{CLEAR}; #{GREEN}end#{CLEAR}",
- "def self.foo; bar; end" => "#{GREEN}def#{CLEAR} #{CYAN}#{BOLD}self#{CLEAR}.#{BLUE}#{BOLD}foo#{CLEAR}; bar; #{GREEN}end#{CLEAR}",
- 'erb = ERB.new("a#{nil}b", trim_mode: "-")' => "erb = #{BLUE}#{BOLD}#{UNDERLINE}ERB#{CLEAR}.new(#{RED}#{BOLD}\"#{CLEAR}#{RED}a#{CLEAR}#{RED}\#{#{CLEAR}#{CYAN}#{BOLD}nil#{CLEAR}#{RED}}#{CLEAR}#{RED}b#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}, #{MAGENTA}trim_mode:#{CLEAR} #{RED}#{BOLD}\"#{CLEAR}#{RED}-#{CLEAR}#{RED}#{BOLD}\"#{CLEAR})",
- "# comment" => "#{BLUE}#{BOLD}# comment#{CLEAR}",
- "def f;yield(hello);end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}f#{CLEAR};#{GREEN}yield#{CLEAR}(hello);#{GREEN}end#{CLEAR}",
- '"##@var]"' => "#{RED}#{BOLD}\"#{CLEAR}#{RED}\##{CLEAR}#{RED}\##{CLEAR}@var#{RED}]#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}",
- '"foo#{a} #{b}"' => "#{RED}#{BOLD}\"#{CLEAR}#{RED}foo#{CLEAR}#{RED}\#{#{CLEAR}a#{RED}}#{CLEAR}#{RED} #{CLEAR}#{RED}\#{#{CLEAR}b#{RED}}#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}",
- '/r#{e}g/' => "#{RED}#{BOLD}/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e#{RED}}#{CLEAR}#{RED}g#{CLEAR}#{RED}#{BOLD}/#{CLEAR}",
- "'a\nb'" => "#{RED}#{BOLD}'#{CLEAR}#{RED}a#{CLEAR}\n#{RED}b#{CLEAR}#{RED}#{BOLD}'#{CLEAR}",
- "[1]]]\u0013" => "[1]]]^S",
- "%[str]" => "#{RED}#{BOLD}%[#{CLEAR}#{RED}str#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "%Q[str]" => "#{RED}#{BOLD}%Q[#{CLEAR}#{RED}str#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "%q[str]" => "#{RED}#{BOLD}%q[#{CLEAR}#{RED}str#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "%x[cmd]" => "#{RED}#{BOLD}%x[#{CLEAR}#{RED}cmd#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "%r[reg]" => "#{RED}#{BOLD}%r[#{CLEAR}#{RED}reg#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "%w[a b]" => "#{RED}#{BOLD}%w[#{CLEAR}#{RED}a#{CLEAR} #{RED}b#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "%W[a b]" => "#{RED}#{BOLD}%W[#{CLEAR}#{RED}a#{CLEAR} #{RED}b#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "%s[a b]" => "#{YELLOW}%s[#{CLEAR}#{YELLOW}a b#{CLEAR}#{YELLOW}]#{CLEAR}",
- "%i[c d]" => "#{YELLOW}%i[#{CLEAR}#{YELLOW}c#{CLEAR}#{YELLOW} #{CLEAR}#{YELLOW}d#{CLEAR}#{YELLOW}]#{CLEAR}",
- "%I[c d]" => "#{YELLOW}%I[#{CLEAR}#{YELLOW}c#{CLEAR}#{YELLOW} #{CLEAR}#{YELLOW}d#{CLEAR}#{YELLOW}]#{CLEAR}",
- "{'a': 1}" => "{#{RED}#{BOLD}'#{CLEAR}#{RED}a#{CLEAR}#{RED}#{BOLD}':#{CLEAR} #{BLUE}#{BOLD}1#{CLEAR}}",
- ":Struct" => "#{YELLOW}:#{CLEAR}#{YELLOW}Struct#{CLEAR}",
- '"#{}"' => "#{RED}#{BOLD}\"#{CLEAR}#{RED}\#{#{CLEAR}#{RED}}#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}",
- ':"a#{}b"' => "#{YELLOW}:\"#{CLEAR}#{YELLOW}a#{CLEAR}#{YELLOW}\#{#{CLEAR}#{YELLOW}}#{CLEAR}#{YELLOW}b#{CLEAR}#{YELLOW}\"#{CLEAR}",
- ':"a#{ def b; end; \'c\' + "#{ :d }" }e"' => "#{YELLOW}:\"#{CLEAR}#{YELLOW}a#{CLEAR}#{YELLOW}\#{#{CLEAR} #{GREEN}def#{CLEAR} #{BLUE}#{BOLD}b#{CLEAR}; #{GREEN}end#{CLEAR}; #{RED}#{BOLD}'#{CLEAR}#{RED}c#{CLEAR}#{RED}#{BOLD}'#{CLEAR} + #{RED}#{BOLD}\"#{CLEAR}#{RED}\#{#{CLEAR} #{YELLOW}:#{CLEAR}#{YELLOW}d#{CLEAR} #{RED}}#{CLEAR}#{RED}#{BOLD}\"#{CLEAR} #{YELLOW}}#{CLEAR}#{YELLOW}e#{CLEAR}#{YELLOW}\"#{CLEAR}",
- "[__FILE__, __LINE__]" => "[#{CYAN}#{BOLD}__FILE__#{CLEAR}, #{CYAN}#{BOLD}__LINE__#{CLEAR}]",
- ":self" => "#{YELLOW}:#{CLEAR}#{YELLOW}self#{CLEAR}",
- ":class" => "#{YELLOW}:#{CLEAR}#{YELLOW}class#{CLEAR}",
- "[:end, 2]" => "[#{YELLOW}:#{CLEAR}#{YELLOW}end#{CLEAR}, #{BLUE}#{BOLD}2#{CLEAR}]",
- "[:>, 3]" => "[#{YELLOW}:#{CLEAR}#{YELLOW}>#{CLEAR}, #{BLUE}#{BOLD}3#{CLEAR}]",
- ":Hello ? world : nil" => "#{YELLOW}:#{CLEAR}#{YELLOW}Hello#{CLEAR} ? world : #{CYAN}#{BOLD}nil#{CLEAR}",
- 'raise "foo#{bar}baz"' => "raise #{RED}#{BOLD}\"#{CLEAR}#{RED}foo#{CLEAR}#{RED}\#{#{CLEAR}bar#{RED}}#{CLEAR}#{RED}baz#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}",
- '["#{obj.inspect}"]' => "[#{RED}#{BOLD}\"#{CLEAR}#{RED}\#{#{CLEAR}obj.inspect#{RED}}#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}]",
- 'URI.parse "#{}"' => "#{BLUE}#{BOLD}#{UNDERLINE}URI#{CLEAR}.parse #{RED}#{BOLD}\"#{CLEAR}#{RED}\#{#{CLEAR}#{RED}}#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}",
- "begin\nrescue\nend" => "#{GREEN}begin#{CLEAR}\n#{GREEN}rescue#{CLEAR}\n#{GREEN}end#{CLEAR}",
- "foo %w[bar]" => "foo #{RED}#{BOLD}%w[#{CLEAR}#{RED}bar#{CLEAR}#{RED}#{BOLD}]#{CLEAR}",
- "foo %i[bar]" => "foo #{YELLOW}%i[#{CLEAR}#{YELLOW}bar#{CLEAR}#{YELLOW}]#{CLEAR}",
- "foo :@bar, baz, :@@qux, :$quux" => "foo #{YELLOW}:#{CLEAR}#{YELLOW}@bar#{CLEAR}, baz, #{YELLOW}:#{CLEAR}#{YELLOW}@@qux#{CLEAR}, #{YELLOW}:#{CLEAR}#{YELLOW}$quux#{CLEAR}",
- "`echo`" => "#{RED}#{BOLD}`#{CLEAR}#{RED}echo#{CLEAR}#{RED}#{BOLD}`#{CLEAR}",
- "\t" => "\t", # not ^I
- "foo(*%W(bar))" => "foo(*#{RED}#{BOLD}%W(#{CLEAR}#{RED}bar#{CLEAR}#{RED}#{BOLD})#{CLEAR})",
- "$stdout" => "#{GREEN}#{BOLD}$stdout#{CLEAR}",
- }
-
- # specific to Ruby 2.7+
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
- tests.merge!({
- "4.5.6" => "#{MAGENTA}#{BOLD}4.5#{CLEAR}#{RED}#{REVERSE}.6#{CLEAR}",
- "\e[0m\n" => "#{RED}#{REVERSE}^[#{CLEAR}[#{BLUE}#{BOLD}0#{CLEAR}#{RED}#{REVERSE}m#{CLEAR}\n",
- "<<EOS\nhere\nEOS" => "#{RED}<<EOS#{CLEAR}\n#{RED}here#{CLEAR}\n#{RED}EOS#{CLEAR}",
- })
- end
-
- tests.each do |code, result|
- if colorize_code_supported?
- actual = with_term { IRB::Color.colorize_code(code, complete: true) }
- assert_equal(result, actual, "Case: IRB::Color.colorize_code(#{code.dump}, complete: true)\nResult: #{humanized_literal(actual)}")
-
- actual = with_term { IRB::Color.colorize_code(code, complete: false) }
- assert_equal(result, actual, "Case: IRB::Color.colorize_code(#{code.dump}, complete: false)\nResult: #{humanized_literal(actual)}")
- else
- actual = with_term { IRB::Color.colorize_code(code) }
- assert_equal(code, actual)
- end
- end
- end
-
- def test_colorize_code_complete_true
- unless complete_option_supported?
- skip '`complete: true` is the same as `complete: false` in Ruby 2.6-'
- end
-
- # `complete: true` behaviors. Warn end-of-file.
- {
- "'foo' + 'bar" => "#{RED}#{BOLD}'#{CLEAR}#{RED}foo#{CLEAR}#{RED}#{BOLD}'#{CLEAR} + #{RED}#{BOLD}'#{CLEAR}#{RED}#{REVERSE}bar#{CLEAR}",
- "('foo" => "(#{RED}#{BOLD}'#{CLEAR}#{RED}#{REVERSE}foo#{CLEAR}",
- }.each do |code, result|
- actual = with_term { IRB::Color.colorize_code(code, complete: true) }
- assert_equal(result, actual, "Case: colorize_code(#{code.dump}, complete: true)\nResult: #{humanized_literal(actual)}")
- end
- end
-
- def test_colorize_code_complete_false
- # `complete: false` behaviors. Do not warn end-of-file.
- {
- "'foo' + 'bar" => "#{RED}#{BOLD}'#{CLEAR}#{RED}foo#{CLEAR}#{RED}#{BOLD}'#{CLEAR} + #{RED}#{BOLD}'#{CLEAR}#{RED}bar#{CLEAR}",
- "('foo" => "(#{RED}#{BOLD}'#{CLEAR}#{RED}foo#{CLEAR}",
- }.each do |code, result|
- if colorize_code_supported?
- actual = with_term { IRB::Color.colorize_code(code, complete: false) }
- assert_equal(result, actual, "Case: colorize_code(#{code.dump}, complete: false)\nResult: #{humanized_literal(actual)}")
-
- unless complete_option_supported?
- actual = with_term { IRB::Color.colorize_code(code, complete: true) }
- assert_equal(result, actual, "Case: colorize_code(#{code.dump}, complete: false)\nResult: #{humanized_literal(actual)}")
- end
- else
- actual = with_term { IRB::Color.colorize_code(code) }
- assert_equal(code, actual)
- end
- end
- end
-
- def test_inspect_colorable
- {
- 1 => true,
- 2.3 => true,
- ['foo', :bar] => true,
- (a = []; a << a; a) => false,
- (h = {}; h[h] = h; h) => false,
- { a: 4 } => true,
- /reg/ => true,
- (1..3) => true,
- Object.new => false,
- Struct => true,
- Test => true,
- Struct.new(:a) => false,
- Struct.new(:a).new(1) => false,
- }.each do |object, result|
- assert_equal(result, IRB::Color.inspect_colorable?(object), "Case: inspect_colorable?(#{object.inspect})")
- end
- end
-
- private
-
- # `#colorize_code` is supported only for Ruby 2.5+. It just returns the original code in 2.4-.
- def colorize_code_supported?
- Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
- end
-
- # `complete: true` is the same as `complete: false` in Ruby 2.6-
- def complete_option_supported?
- Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
- end
-
- def with_term
- stdout = $stdout
- io = StringIO.new
- def io.tty?; true; end
- $stdout = io
-
- env = ENV.to_h.dup
- ENV['TERM'] = 'xterm-256color'
-
- yield
- ensure
- $stdout = stdout
- ENV.replace(env) if env
- end
-
- def humanized_literal(str)
- str
- .gsub(CLEAR, '@@@{CLEAR}')
- .gsub(BOLD, '@@@{BOLD}')
- .gsub(UNDERLINE, '@@@{UNDERLINE}')
- .gsub(REVERSE, '@@@{REVERSE}')
- .gsub(RED, '@@@{RED}')
- .gsub(GREEN, '@@@{GREEN}')
- .gsub(YELLOW, '@@@{YELLOW}')
- .gsub(BLUE, '@@@{BLUE}')
- .gsub(MAGENTA, '@@@{MAGENTA}')
- .gsub(CYAN, '@@@{CYAN}')
- .dump.gsub(/@@@/, '#')
- end
- end
-end
diff --git a/test/irb/test_completion.rb b/test/irb/test_completion.rb
index a765bbf3a5..608c41bad9 100644
--- a/test/irb/test_completion.rb
+++ b/test/irb/test_completion.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: false
-require "test/unit"
-require "irb"
+require 'test/unit'
module TestIRB
class TestCompletion < Test::Unit::TestCase
@@ -8,8 +7,7 @@ module TestIRB
begin
require "irb/completion"
bug5938 = '[ruby-core:42244]'
- bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
- cmds = bundle_exec + %W[-W0 -rirb -rirb/completion -e IRB.setup(__FILE__)
+ cmds = %W[-rirb -rirb/completion -e IRB.setup(__FILE__)
-e IRB.conf[:MAIN_CONTEXT]=IRB::Irb.new.context
-e module\sFoo;def\sself.name;//;end;end
-e IRB::InputCompletor::CompletionProc.call("[1].first.")
@@ -20,32 +18,5 @@ module TestIRB
skip "cannot load irb/completion"
end
end
-
- def test_complete_numeric
- assert_include(IRB::InputCompletor.retrieve_completion_data("1r.positi", bind: binding), "1r.positive?")
- assert_empty(IRB::InputCompletor.retrieve_completion_data("1i.positi", bind: binding))
- end
-
- def test_complete_symbol
- _ = :aiueo
- assert_include(IRB::InputCompletor.retrieve_completion_data(":a", bind: binding), ":aiueo")
- assert_empty(IRB::InputCompletor.retrieve_completion_data(":irb_unknown_symbol_abcdefg", bind: binding))
- end
-
- def test_complete_symbol_failure
- assert_nil(IRB::InputCompletor::PerfectMatchedProc.(":aiueo", bind: binding))
- end
-
- def test_complete_reserved_words
- candidates = IRB::InputCompletor.retrieve_completion_data("de", bind: binding)
- %w[def defined?].each do |word|
- assert_include candidates, word
- end
-
- candidates = IRB::InputCompletor.retrieve_completion_data("__", bind: binding)
- %w[__ENCODING__ __LINE__ __FILE__].each do |word|
- assert_include candidates, word
- end
- end
end
end
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb
deleted file mode 100644
index fa628bba46..0000000000
--- a/test/irb/test_context.rb
+++ /dev/null
@@ -1,426 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-require 'tempfile'
-require 'irb'
-require 'rubygems' if defined?(Gem)
-
-module TestIRB
- class TestContext < Test::Unit::TestCase
- class TestInputMethod < ::IRB::InputMethod
- attr_reader :list, :line_no
-
- def initialize(list = [])
- super("test")
- @line_no = 0
- @list = list
- end
-
- def gets
- @list[@line_no]&.tap {@line_no += 1}
- end
-
- def eof?
- @line_no >= @list.size
- end
-
- def encoding
- Encoding.default_external
- end
-
- def reset
- @line_no = 0
- end
-
- def winsize
- [10, 20]
- end
- end
-
- def setup
- IRB.init_config(nil)
- IRB.conf[:USE_SINGLELINE] = false
- IRB.conf[:VERBOSE] = false
- workspace = IRB::WorkSpace.new(Object.new)
- @context = IRB::Context.new(nil, workspace, TestInputMethod.new)
- end
-
- def test_last_value
- assert_nil(@context.last_value)
- assert_nil(@context.evaluate('_', 1))
- obj = Object.new
- @context.set_last_value(obj)
- assert_same(obj, @context.last_value)
- assert_same(obj, @context.evaluate('_', 1))
- end
-
- def test_evaluate_with_exception
- assert_nil(@context.evaluate("$!", 1))
- e = assert_raise_with_message(RuntimeError, 'foo') {
- @context.evaluate("raise 'foo'", 1)
- }
- assert_equal('foo', e.message)
- assert_same(e, @context.evaluate('$!', 1, exception: e))
- e = assert_raise(SyntaxError) {
- @context.evaluate("1,2,3", 1, exception: e)
- }
- assert_match(/\A\(irb\):1:/, e.message)
- assert_not_match(/rescue _\.class/, e.message)
- end
-
- def test_evaluate_with_encoding_error_without_lineno
- assert_raise_with_message(EncodingError, /invalid symbol/) {
- @context.evaluate(%q[{"\xAE": 1}], 1)
- # The backtrace of this invalid encoding hash doesn't contain lineno.
- }
- end
-
- def test_evaluate_with_onigmo_warning
- assert_warning("(irb):1: warning: character class has duplicated range: /[aa]/\n") do
- @context.evaluate('/[aa]/', 1)
- end
- end
-
- def test_eval_input
- verbose, $VERBOSE = $VERBOSE, nil
- input = TestInputMethod.new([
- "raise 'Foo'\n",
- "_\n",
- "0\n",
- "_\n",
- ])
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
- out, err = capture_output do
- irb.eval_input
- end
- assert_empty err
- assert_pattern_list([:*, /RuntimeError \(.*Foo.*\).*\n/,
- :*, /#<RuntimeError: Foo>\n/,
- :*, /0$/,
- :*, /0$/,
- /\s*/], out)
- ensure
- $VERBOSE = verbose
- end
-
- def test_eval_object_without_inspect_method
- verbose, $VERBOSE = $VERBOSE, nil
- input = TestInputMethod.new([
- "BasicObject.new\n",
- ])
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
- out, err = capture_output do
- irb.eval_input
- end
- assert_empty err
- assert(/\(Object doesn't support #inspect\)\n(=> )?\n/, out)
- ensure
- $VERBOSE = verbose
- end
-
- def test_default_config
- assert_equal(true, @context.use_colorize?)
- end
-
- def test_assignment_expression
- input = TestInputMethod.new
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
- [
- "foo = bar",
- "@foo = bar",
- "$foo = bar",
- "@@foo = bar",
- "::Foo = bar",
- "a::Foo = bar",
- "Foo = bar",
- "foo.bar = 1",
- "foo[1] = bar",
- "foo += bar",
- "foo -= bar",
- "foo ||= bar",
- "foo &&= bar",
- "foo, bar = 1, 2",
- "foo.bar=(1)",
- "foo; foo = bar",
- "foo; foo = bar; ;\n ;",
- "foo\nfoo = bar",
- ].each do |exp|
- assert(
- irb.assignment_expression?(exp),
- "#{exp.inspect}: should be an assignment expression"
- )
- end
-
- [
- "foo",
- "foo.bar",
- "foo[0]",
- "foo = bar; foo",
- "foo = bar\nfoo",
- ].each do |exp|
- refute(
- irb.assignment_expression?(exp),
- "#{exp.inspect}: should not be an assignment expression"
- )
- end
- end
-
- def test_echo_on_assignment
- input = TestInputMethod.new([
- "a = 1\n",
- "a\n",
- "a, b = 2, 3\n",
- "a\n",
- "b\n",
- "b = 4\n",
- "_\n"
- ])
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
- irb.context.return_format = "=> %s\n"
-
- # The default
- irb.context.echo = true
- irb.context.echo_on_assignment = false
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> 1\n=> 2\n=> 3\n=> 4\n", out)
-
- # Everything is output, like before echo_on_assignment was introduced
- input.reset
- irb.context.echo = true
- irb.context.echo_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> 1\n=> 1\n=> [2, 3]\n=> 2\n=> 3\n=> 4\n=> 4\n", out)
-
- # Nothing is output when echo is false
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = false
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
-
- # Nothing is output when echo is false even if echo_on_assignment is true
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
- end
-
- def test_omit_on_assignment
- input = TestInputMethod.new([
- "a = [1] * 100\n",
- "a\n",
- ])
- value = [1] * 100
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
- irb.context.return_format = "=> %s\n"
-
- irb.context.echo = true
- irb.context.echo_on_assignment = false
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> #{value.inspect}\n", out)
-
- input.reset
- irb.context.echo = true
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> #{value.inspect[0..(input.winsize.last - 9)]}...\e[0m\n=> #{value.inspect}\n", out)
-
- input.reset
- irb.context.echo = true
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = false
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> #{value.inspect}\n=> #{value.inspect}\n", out)
-
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = false
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
-
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
-
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = false
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
- end
-
- def test_omit_multiline_on_assignment
- input = TestInputMethod.new([
- "class A; def inspect; ([?* * 1000] * 3).join(%{\\n}); end; end; a = A.new\n",
- "a\n"
- ])
- value = ([?* * 1000] * 3).join(%{\n})
- value_first_line = (?* * 1000).to_s
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
- irb.context.return_format = "=> %s\n"
-
- irb.context.echo = true
- irb.context.echo_on_assignment = false
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> \n#{value}\n", out)
- irb.context.evaluate('A.remove_method(:inspect)', 0)
-
- input.reset
- irb.context.echo = true
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> #{value_first_line[0..(input.winsize.last - 9)]}...\e[0m\n=> \n#{value}\n", out)
- irb.context.evaluate('A.remove_method(:inspect)', 0)
-
- input.reset
- irb.context.echo = true
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = false
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> \n#{value}\n=> \n#{value}\n", out)
- irb.context.evaluate('A.remove_method(:inspect)', 0)
-
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = false
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
- irb.context.evaluate('A.remove_method(:inspect)', 0)
-
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
- irb.context.evaluate('A.remove_method(:inspect)', 0)
-
- input.reset
- irb.context.echo = false
- irb.context.echo_on_assignment = true
- irb.context.omit_on_assignment = false
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("", out)
- irb.context.evaluate('A.remove_method(:inspect)', 0)
- end
-
- def test_echo_on_assignment_conf
- # Default
- IRB.conf[:ECHO] = nil
- IRB.conf[:ECHO_ON_ASSIGNMENT] = nil
- input = TestInputMethod.new()
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
-
- assert(irb.context.echo?, "echo? should be true by default")
- assert(irb.context.echo_on_assignment?, "echo_on_assignment? should be true by default")
- assert(irb.context.omit_on_assignment?, "omit_on_assignment? should be true by default")
-
- # Explicitly set :ECHO to false
- IRB.conf[:ECHO] = false
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
-
- refute(irb.context.echo?, "echo? should be false when IRB.conf[:ECHO] is set to false")
- assert(irb.context.echo_on_assignment?, "echo_on_assignment? should be true by default")
- assert(irb.context.omit_on_assignment?, "omit_on_assignment? should be true by default")
-
- # Explicitly set :ECHO_ON_ASSIGNMENT to true
- IRB.conf[:ECHO] = nil
- IRB.conf[:ECHO_ON_ASSIGNMENT] = false
- IRB.conf[:OMIT_ON_ASSIGNMENT] = false
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
-
- assert(irb.context.echo?, "echo? should be true by default")
- refute(irb.context.echo_on_assignment?, "echo_on_assignment? should be false when IRB.conf[:ECHO_ON_ASSIGNMENT] is set to false")
- refute(irb.context.omit_on_assignment?, "omit_on_assignment? should be false when IRB.conf[:OMIT_ON_ASSIGNMENT] is set to false")
- end
-
- def test_multiline_output_on_default_inspector
- main = Object.new
- def main.inspect
- "abc\ndef"
- end
- input = TestInputMethod.new([
- "self"
- ])
- irb = IRB::Irb.new(IRB::WorkSpace.new(main), input)
- irb.context.return_format = "=> %s\n"
-
- # The default
- irb.context.newline_before_multiline_output = true
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> \nabc\ndef\n",
- out)
-
- # No newline before multiline output
- input.reset
- irb.context.newline_before_multiline_output = false
- out, err = capture_io do
- irb.eval_input
- end
- assert_empty err
- assert_equal("=> abc\ndef\n",
- out)
- end
- end
-end
diff --git a/test/irb/test_history.rb b/test/irb/test_history.rb
deleted file mode 100644
index 1ba4d2e515..0000000000
--- a/test/irb/test_history.rb
+++ /dev/null
@@ -1,175 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-require 'irb'
-require 'irb/ext/save-history'
-require 'readline'
-
-module TestIRB
- class TestHistory < Test::Unit::TestCase
- def setup
- IRB.conf[:RC_NAME_GENERATOR] = nil
- end
-
- def teardown
- IRB.conf[:RC_NAME_GENERATOR] = nil
- end
-
- class TestInputMethod < ::IRB::InputMethod
- HISTORY = Array.new
-
- include IRB::HistorySavingAbility
-
- attr_reader :list, :line_no
-
- def initialize(list = [])
- super("test")
- @line_no = 0
- @list = list
- end
-
- def gets
- @list[@line_no]&.tap {@line_no += 1}
- end
-
- def eof?
- @line_no >= @list.size
- end
-
- def encoding
- Encoding.default_external
- end
-
- def reset
- @line_no = 0
- end
-
- def winsize
- [10, 20]
- end
- end
-
- def test_history_save_1
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- IRB.conf[:SAVE_HISTORY] = 1
- assert_history(<<~EXPECTED_HISTORY, <<~INITIAL_HISTORY, <<~INPUT)
- exit
- EXPECTED_HISTORY
- 1
- 2
- 3
- 4
- INITIAL_HISTORY
- 5
- exit
- INPUT
- end
-
- def test_history_save_100
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- IRB.conf[:SAVE_HISTORY] = 100
- assert_history(<<~EXPECTED_HISTORY, <<~INITIAL_HISTORY, <<~INPUT)
- 1
- 2
- 3
- 4
- 5
- exit
- EXPECTED_HISTORY
- 1
- 2
- 3
- 4
- INITIAL_HISTORY
- 5
- exit
- INPUT
- end
-
- def test_history_save_bignum
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- IRB.conf[:SAVE_HISTORY] = 10 ** 19
- assert_history(<<~EXPECTED_HISTORY, <<~INITIAL_HISTORY, <<~INPUT)
- 1
- 2
- 3
- 4
- 5
- exit
- EXPECTED_HISTORY
- 1
- 2
- 3
- 4
- INITIAL_HISTORY
- 5
- exit
- INPUT
- end
-
- def test_history_save_minus_as_infinity
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- IRB.conf[:SAVE_HISTORY] = -1 # infinity
- assert_history(<<~EXPECTED_HISTORY, <<~INITIAL_HISTORY, <<~INPUT)
- 1
- 2
- 3
- 4
- 5
- exit
- EXPECTED_HISTORY
- 1
- 2
- 3
- 4
- INITIAL_HISTORY
- 5
- exit
- INPUT
- end
-
- private
-
- def assert_history(expected_history, initial_irb_history, input)
- backup_verbose, $VERBOSE = $VERBOSE, nil
- backup_home = ENV["HOME"]
- backup_xdg_config_home = ENV.delete("XDG_CONFIG_HOME")
- IRB.conf[:LC_MESSAGES] = IRB::Locale.new
- actual_history = nil
- Dir.mktmpdir("test_irb_history_#{$$}") do |tmpdir|
- ENV["HOME"] = tmpdir
- open(IRB.rc_file("_history"), "w") do |f|
- f.write(initial_irb_history)
- end
-
- io = TestInputMethod.new
- io.class::HISTORY.clear
- io.load_history
- io.class::HISTORY.concat(input.split)
- io.save_history
-
- io.load_history
- open(IRB.rc_file("_history"), "r") do |f|
- actual_history = f.read
- end
- end
- assert_equal(expected_history, actual_history, <<~MESSAGE)
- expected:
- #{expected_history}
- but actual:
- #{actual_history}
- MESSAGE
- ensure
- $VERBOSE = backup_verbose
- ENV["HOME"] = backup_home
- ENV["XDG_CONFIG_HOME"] = backup_xdg_config_home
- end
-
- def with_temp_stdio
- Tempfile.create("test_readline_stdin") do |stdin|
- Tempfile.create("test_readline_stdout") do |stdout|
- yield stdin, stdout
- end
- end
- end
- end
-end if not RUBY_PLATFORM.match?(/solaris|mswin|mingw/i)
diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb
index 83b4b5a543..3d6c0f3bdc 100644
--- a/test/irb/test_init.rb
+++ b/test/irb/test_init.rb
@@ -1,69 +1,23 @@
# frozen_string_literal: false
require "test/unit"
require "irb"
-require "fileutils"
module TestIRB
class TestInit < Test::Unit::TestCase
def test_setup_with_argv_preserves_global_argv
argv = ["foo", "bar"]
with_argv(argv) do
- IRB.setup(eval("__FILE__"), argv: %w[-f])
+ IRB.setup(eval("__FILE__"), argv: [])
assert_equal argv, ARGV
end
end
- def test_setup_with_minimum_argv_does_not_change_dollar0
+ def test_setup_with_empty_argv_does_not_change_dollar0
orig = $0.dup
- IRB.setup(eval("__FILE__"), argv: %w[-f])
+ IRB.setup(eval("__FILE__"), argv: [])
assert_equal orig, $0
end
- def test_rc_file
- backup_irbrc = ENV.delete("IRBRC") # This is for RVM...
- backup_xdg_config_home = ENV.delete("XDG_CONFIG_HOME")
- backup_home = ENV["HOME"]
- Dir.mktmpdir("test_irb_init_#{$$}") do |tmpdir|
- ENV["HOME"] = tmpdir
-
- IRB.conf[:RC_NAME_GENERATOR] = nil
- assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
- assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
- IRB.conf[:RC_NAME_GENERATOR] = nil
- FileUtils.touch(tmpdir+"/.irb#{IRB::IRBRC_EXT}")
- assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
- assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
- end
- ensure
- ENV["HOME"] = backup_home
- ENV["XDG_CONFIG_HOME"] = backup_xdg_config_home
- ENV["IRBRC"] = backup_irbrc
- end
-
- def test_rc_file_in_subdir
- backup_irbrc = ENV.delete("IRBRC") # This is for RVM...
- backup_xdg_config_home = ENV.delete("XDG_CONFIG_HOME")
- backup_home = ENV["HOME"]
- Dir.mktmpdir("test_irb_init_#{$$}") do |tmpdir|
- ENV["HOME"] = tmpdir
-
- FileUtils.mkdir_p("#{tmpdir}/mydir")
- Dir.chdir("#{tmpdir}/mydir") do
- IRB.conf[:RC_NAME_GENERATOR] = nil
- assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
- assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
- IRB.conf[:RC_NAME_GENERATOR] = nil
- FileUtils.touch(tmpdir+"/.irb#{IRB::IRBRC_EXT}")
- assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
- assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
- end
- end
- ensure
- ENV["HOME"] = backup_home
- ENV["XDG_CONFIG_HOME"] = backup_xdg_config_home
- ENV["IRBRC"] = backup_irbrc
- end
-
private
def with_argv(argv)
diff --git a/test/irb/test_option.rb b/test/irb/test_option.rb
index aa634c02a2..85ebd085ca 100644
--- a/test/irb/test_option.rb
+++ b/test/irb/test_option.rb
@@ -5,8 +5,7 @@ module TestIRB
class TestOption < Test::Unit::TestCase
def test_end_of_option
bug4117 = '[ruby-core:33574]'
- bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
- status = assert_in_out_err(bundle_exec + %w[-W0 -rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117)
+ status = assert_in_out_err(%w[-rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117)
assert(status.success?, bug4117)
end
end
diff --git a/test/irb/test_raise_no_backtrace_exception.rb b/test/irb/test_raise_no_backtrace_exception.rb
index 2174600082..d3882a427c 100644
--- a/test/irb/test_raise_no_backtrace_exception.rb
+++ b/test/irb/test_raise_no_backtrace_exception.rb
@@ -4,10 +4,8 @@ require 'test/unit'
module TestIRB
class TestRaiseNoBacktraceException < Test::Unit::TestCase
def test_raise_exception
- bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
- assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
+ status = assert_in_out_err(%w[-rirb -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
e = Exception.new("foo")
- puts e.inspect
def e.backtrace; nil; end
raise e
IRB
diff --git a/test/irb/test_ruby-lex.rb b/test/irb/test_ruby-lex.rb
new file mode 100644
index 0000000000..b07b4a2eb6
--- /dev/null
+++ b/test/irb/test_ruby-lex.rb
@@ -0,0 +1,108 @@
+# frozen_string_literal: false
+require 'test/unit'
+require 'irb/ruby-lex'
+require 'stringio'
+
+module TestIRB
+ class TestRubyLex < Test::Unit::TestCase
+ def setup
+ @scanner = RubyLex.new
+ end
+
+ def teardown
+ RubyLex.debug_level = 0
+ end
+
+ def test_set_input_proc
+ called = false
+ @scanner.set_input(nil) {called = true; nil}
+ @scanner.each_top_level_statement {}
+ assert(called)
+ end
+
+ def test_comment
+ assert_equal([["#\n", 1]], top_level_statement("#\n"))
+ end
+
+ def test_top_level_statement
+ result = top_level_statement("#{<<-"begin;"}#{<<~"end;"}")
+ begin;
+ begin
+ end
+ begin
+ end
+ end;
+ assert_equal([
+ ["begin\n""end\n", 1],
+ ["begin\n""end\n", 3],
+ ],
+ result)
+ end
+
+ def test_immature_statement
+ src = "if false\n"
+ assert_equal([[src, 1]], top_level_statement(src))
+ end
+
+ def test_prompt
+ prompts = []
+ @scanner.set_prompt {|*a|
+ a << @scanner.instance_variable_get(:@lex_state)
+ unless prompts.last == a
+ prompts << a
+ end
+ }
+ src, lineno = "#{<<-"begin;"}#{<<~'end;'}", __LINE__+1
+ begin;
+ # #;# LTYPE:INDENT:CONTINUE
+ x #;# -:0:-
+ x( #;# -:0:-
+ ) #;# -:1:*
+ a \ #;# -:0:-
+ #;# -:0:*
+ a; #;# -:0:-
+ a #;# -:0:-
+ #;# -:0:-
+ a #;# -:0:-
+ a = #;# -:0:-
+ ' #;# -:0:*
+ ' #;# ':0:*
+ if false or #;# -:0:-
+ true #;# -:1:*
+ a #;# -:1:-
+ " #;# -:1:-
+ " #;# ":1:-
+ begin #;# -:1:-
+ a #;# -:2:-
+ a #;# -:2:-
+ end #;# -:2:-
+ else #;# -:1:-
+ nil #;# -:1:-
+ end #;# -:1:-
+ end;
+ top_level_statement(src.gsub(/[ \t]*#;#.*/, ''))
+ src.each_line.with_index(1) do |line, i|
+ p = prompts.shift
+ next unless /#;#\s*(?:-|(?<ltype>\S)):(?<indent>\d+):(?:(?<cont>\*)|-)(?:.*FIXME:(?<fixme>.*))?/ =~ line
+ indent = indent.to_i
+ cont = (fixme && /`continue'/.match?(fixme)) ^ cont
+ assert_equal([ltype, indent, cont, i], p[0..3], "#{lineno+i}:#{p[4]}: #{line}")
+ end
+ end
+
+ def top_level_statement(lines)
+ input = InputLines.new(lines, "r")
+ scanned = []
+ @scanner.set_input(input)
+ @scanner.each_top_level_statement {|*e|
+ scanned << e
+ yield(*e) if defined?(yield)
+ }
+ scanned
+ end
+
+ class InputLines < StringIO
+ alias encoding external_encoding
+ end
+ end
+end
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb
deleted file mode 100644
index 14b43f5718..0000000000
--- a/test/irb/test_ruby_lex.rb
+++ /dev/null
@@ -1,264 +0,0 @@
-$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
-require 'irb/ruby-lex'
-require 'test/unit'
-require 'ostruct'
-
-module TestIRB
- class TestRubyLex < Test::Unit::TestCase
- Row = Struct.new(:content, :current_line_spaces, :new_line_spaces, :nesting_level)
-
- class MockIO
- def initialize(params, &assertion)
- @params = params
- @assertion = assertion
- end
-
- def auto_indent(&block)
- result = block.call(*@params)
- @assertion.call(result)
- end
- end
-
- def assert_indenting(lines, correct_space_count, add_new_line)
- lines = lines + [""] if add_new_line
- last_line_index = lines.length - 1
- byte_pointer = lines.last.length
-
- ruby_lex = RubyLex.new()
- io = MockIO.new([lines, last_line_index, byte_pointer, add_new_line]) do |auto_indent|
- error_message = "Calculated the wrong number of spaces for:\n #{lines.join("\n")}"
- assert_equal(correct_space_count, auto_indent, error_message)
- end
- ruby_lex.set_input(io)
- context = OpenStruct.new(auto_indent_mode: true)
- ruby_lex.set_auto_indent(context)
- end
-
- def assert_nesting_level(lines, expected)
- ruby_lex = RubyLex.new()
- io = proc{ lines.join("\n") }
- ruby_lex.set_input(io, io)
- ruby_lex.lex
- error_message = "Calculated the wrong number of nesting level for:\n #{lines.join("\n")}"
- assert_equal(expected, ruby_lex.instance_variable_get(:@indent), error_message)
- end
-
- def test_auto_indent
- input_with_correct_indents = [
- Row.new(%q(def each_top_level_statement), nil, 2),
- Row.new(%q( initialize_input), nil, 2),
- Row.new(%q( catch(:TERM_INPUT) do), nil, 4),
- Row.new(%q( loop do), nil, 6),
- Row.new(%q( begin), nil, 8),
- Row.new(%q( prompt), nil, 8),
- Row.new(%q( unless l = lex), nil, 10),
- Row.new(%q( throw :TERM_INPUT if @line == ''), nil, 10),
- Row.new(%q( else), 8, 10),
- Row.new(%q( @line_no += l.count("\n")), nil, 10),
- Row.new(%q( next if l == "\n"), nil, 10),
- Row.new(%q( @line.concat l), nil, 10),
- Row.new(%q( if @code_block_open or @ltype or @continue or @indent > 0), nil, 12),
- Row.new(%q( next), nil, 12),
- Row.new(%q( end), 10, 10),
- Row.new(%q( end), 8, 8),
- Row.new(%q( if @line != "\n"), nil, 10),
- Row.new(%q( @line.force_encoding(@io.encoding)), nil, 10),
- Row.new(%q( yield @line, @exp_line_no), nil, 10),
- Row.new(%q( end), 8, 8),
- Row.new(%q( break if @io.eof?), nil, 8),
- Row.new(%q( @line = ''), nil, 8),
- Row.new(%q( @exp_line_no = @line_no), nil, 8),
- Row.new(%q( ), nil, 8),
- Row.new(%q( @indent = 0), nil, 8),
- Row.new(%q( rescue TerminateLineInput), 6, 8),
- Row.new(%q( initialize_input), nil, 8),
- Row.new(%q( prompt), nil, 8),
- Row.new(%q( end), 6, 6),
- Row.new(%q( end), 4, 4),
- Row.new(%q( end), 2, 2),
- Row.new(%q(end), 0, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_braces_on_their_own_line
- input_with_correct_indents = [
- Row.new(%q(if true), nil, 2),
- Row.new(%q( [), nil, 4),
- Row.new(%q( ]), 2, 2),
- Row.new(%q(end), 0, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_multiple_braces_in_a_line
- input_with_correct_indents = [
- Row.new(%q([[[), nil, 6),
- Row.new(%q( ]), 4, 4),
- Row.new(%q( ]), 2, 2),
- Row.new(%q(]), 0, 0),
- Row.new(%q([<<FOO]), nil, 0),
- Row.new(%q(hello), nil, 0),
- Row.new(%q(FOO), nil, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_a_closed_brace_and_not_closed_brace_in_a_line
- input_with_correct_indents = [
- Row.new(%q(p() {), nil, 2),
- Row.new(%q(}), 0, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_incomplete_coding_magic_comment
- input_with_correct_indents = [
- Row.new(%q(#coding:u), nil, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_incomplete_encoding_magic_comment
- input_with_correct_indents = [
- Row.new(%q(#encoding:u), nil, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_incomplete_emacs_coding_magic_comment
- input_with_correct_indents = [
- Row.new(%q(# -*- coding: u), nil, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_incomplete_vim_coding_magic_comment
- input_with_correct_indents = [
- Row.new(%q(# vim:set fileencoding=u), nil, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_mixed_rescue
- input_with_correct_indents = [
- Row.new(%q(def m), nil, 2),
- Row.new(%q( begin), nil, 4),
- Row.new(%q( begin), nil, 6),
- Row.new(%q( x = a rescue 4), nil, 6),
- Row.new(%q( y = [(a rescue 5)]), nil, 6),
- Row.new(%q( [x, y]), nil, 6),
- Row.new(%q( rescue => e), 4, 6),
- Row.new(%q( raise e rescue 8), nil, 6),
- Row.new(%q( end), 4, 4),
- Row.new(%q( rescue), 2, 4),
- Row.new(%q( raise rescue 11), nil, 4),
- Row.new(%q( end), 2, 2),
- Row.new(%q(rescue => e), 0, 2),
- Row.new(%q( raise e rescue 14), nil, 2),
- Row.new(%q(end), 0, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_oneliner_method_definition
- input_with_correct_indents = [
- Row.new(%q(class A), nil, 2),
- Row.new(%q( def foo0), nil, 4),
- Row.new(%q( 3), nil, 4),
- Row.new(%q( end), 2, 2),
- Row.new(%q( def foo1()), nil, 4),
- Row.new(%q( 3), nil, 4),
- Row.new(%q( end), 2, 2),
- Row.new(%q( def foo2(a, b)), nil, 4),
- Row.new(%q( a + b), nil, 4),
- Row.new(%q( end), 2, 2),
- Row.new(%q( def foo3 a, b), nil, 4),
- Row.new(%q( a + b), nil, 4),
- Row.new(%q( end), 2, 2),
- Row.new(%q( def bar0() = 3), nil, 2),
- Row.new(%q( def bar1(a) = a), nil, 2),
- Row.new(%q( def bar2(a, b) = a + b), nil, 2),
- Row.new(%q(end), 0, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- end
- end
-
- def test_tlambda
- input_with_correct_indents = [
- Row.new(%q(if true), nil, 2, 1),
- Row.new(%q( -> {), nil, 4, 2),
- Row.new(%q( }), 2, 2, 1),
- Row.new(%q(end), 0, 0, 0),
- ]
-
- lines = []
- input_with_correct_indents.each do |row|
- lines << row.content
- assert_indenting(lines, row.current_line_spaces, false)
- assert_indenting(lines, row.new_line_spaces, true)
- assert_nesting_level(lines, row.nesting_level)
- end
- end
- end
-end
diff --git a/test/irb/test_workspace.rb b/test/irb/test_workspace.rb
index 15c77315a8..0795b17e09 100644
--- a/test/irb/test_workspace.rb
+++ b/test/irb/test_workspace.rb
@@ -1,15 +1,12 @@
# frozen_string_literal: false
require 'test/unit'
require 'tempfile'
-require 'rubygems'
-require 'irb'
require 'irb/workspace'
-require 'irb/color'
module TestIRB
class TestWorkSpace < Test::Unit::TestCase
def test_code_around_binding
- Tempfile.create('irb') do |f|
+ Tempfile.create do |f|
code = <<~RUBY
# 1
# 2
@@ -21,7 +18,7 @@ module TestIRB
f.close
workspace = eval(code, binding, f.path)
- assert_equal(<<~EOS, without_term { workspace.code_around_binding })
+ assert_equal(<<~EOS, workspace.code_around_binding)
From: #{f.path} @ line 3 :
@@ -39,7 +36,7 @@ module TestIRB
skip 'chmod cannot make file unreadable on windows' if windows?
skip 'skipped in root privilege' if Process.uid == 0
- Tempfile.create('irb') do |f|
+ Tempfile.create do |f|
code = "IRB::WorkSpace.new(binding)\n"
f.print(code)
f.close
@@ -53,12 +50,12 @@ module TestIRB
def test_code_around_binding_with_script_lines__
with_script_lines do |script_lines|
- Tempfile.create('irb') do |f|
+ Tempfile.create do |f|
code = "IRB::WorkSpace.new(binding)\n"
script_lines[f.path] = code.split(/^/)
workspace = eval(code, binding, f.path)
- assert_equal(<<~EOS, without_term { workspace.code_around_binding })
+ assert_equal(<<~EOS, workspace.code_around_binding)
From: #{f.path} @ line 1 :
@@ -93,13 +90,5 @@ module TestIRB
const_set(:SCRIPT_LINES__, script_lines) if script_lines
end
end
-
- def without_term
- env = ENV.to_h.dup
- ENV.delete('TERM')
- yield
- ensure
- ENV.replace(env)
- end
end
end
diff --git a/test/json/json_addition_test.rb b/test/json/json_addition_test.rb
index 61625f89e2..a028e0f08a 100644
--- a/test/json/json_addition_test.rb
+++ b/test/json/json_addition_test.rb
@@ -5,7 +5,6 @@ require 'json/add/complex'
require 'json/add/rational'
require 'json/add/bigdecimal'
require 'json/add/ostruct'
-require 'json/add/set'
require 'date'
class JSONAdditionTest < Test::Unit::TestCase
@@ -191,13 +190,4 @@ class JSONAdditionTest < Test::Unit::TestCase
o.foo = { 'bar' => true }
assert_equal o, parse(JSON(o), :create_additions => true)
end
-
- def test_set
- s = Set.new([:a, :b, :c, :a])
- assert_equal s, JSON.parse(JSON(s), :create_additions => true)
- ss = SortedSet.new([:d, :b, :a, :c])
- ss_again = JSON.parse(JSON(ss), :create_additions => true)
- assert_kind_of ss.class, ss_again
- assert_equal ss, ss_again
- end
end
diff --git a/test/json/json_common_interface_test.rb b/test/json/json_common_interface_test.rb
index 53f335ed3b..29b4a5b569 100644
--- a/test/json/json_common_interface_test.rb
+++ b/test/json/json_common_interface_test.rb
@@ -27,15 +27,15 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
end
def test_parser
- assert_match(/::Parser\z/, JSON.parser.name)
+ assert_match /::Parser\z/, JSON.parser.name
end
def test_generator
- assert_match(/::Generator\z/, JSON.generator.name)
+ assert_match /::Generator\z/, JSON.generator.name
end
def test_state
- assert_match(/::Generator::State\z/, JSON.state.name)
+ assert_match /::Generator::State\z/, JSON.state.name
end
def test_create_id
@@ -56,7 +56,7 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
end
def test_parse_bang
- assert_equal [ 1, Infinity, 3, ], JSON.parse!('[ 1, Infinity, 3 ]')
+ assert_equal [ 1, NaN, 3, ], JSON.parse!('[ 1, NaN, 3 ]')
end
def test_generate
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb
index ee19fa5e6c..86be398f46 100644
--- a/test/json/json_generator_test.rb
+++ b/test/json/json_generator_test.rb
@@ -40,44 +40,6 @@ class JSONGeneratorTest < Test::Unit::TestCase
EOT
end
- def silence
- v = $VERBOSE
- $VERBOSE = nil
- yield
- ensure
- $VERBOSE = v
- end
-
- def test_remove_const_segv
- return if RUBY_ENGINE == 'jruby'
- stress = GC.stress
- const = JSON::SAFE_STATE_PROTOTYPE.dup
-
- bignum_too_long_to_embed_as_string = 1234567890123456789012345
- expect = bignum_too_long_to_embed_as_string.to_s
- GC.stress = true
-
- 10.times do |i|
- tmp = bignum_too_long_to_embed_as_string.to_json
- raise "'\#{expect}' is expected, but '\#{tmp}'" unless tmp == expect
- end
-
- silence do
- JSON.const_set :SAFE_STATE_PROTOTYPE, nil
- end
-
- 10.times do |i|
- assert_raise TypeError do
- bignum_too_long_to_embed_as_string.to_json
- end
- end
- ensure
- GC.stress = stress
- silence do
- JSON.const_set :SAFE_STATE_PROTOTYPE, const
- end
- end if JSON.const_defined?("Ext")
-
def test_generate
json = generate(@hash)
assert_equal(parse(@json2), parse(json))
@@ -412,10 +374,4 @@ EOT
assert_equal '["foo"]', JSON.generate([s.new('foo')])
end
end
-
- if defined?(Encoding)
- def test_nonutf8_encoding
- assert_equal("\"5\u{b0}\"", "5\xb0".force_encoding("iso-8859-1").to_json)
- end
- end
end
diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb
index 9946dd93e7..5f454eb121 100644
--- a/test/json/json_parser_test.rb
+++ b/test/json/json_parser_test.rb
@@ -91,27 +91,27 @@ class JSONParserTest < Test::Unit::TestCase
assert_raise(JSON::ParserError) { parse('+23') }
assert_raise(JSON::ParserError) { parse('.23') }
assert_raise(JSON::ParserError) { parse('023') }
- assert_equal(23, parse('23'))
- assert_equal(-23, parse('-23'))
- assert_equal_float(3.141, parse('3.141'))
- assert_equal_float(-3.141, parse('-3.141'))
- assert_equal_float(3.141, parse('3141e-3'))
- assert_equal_float(3.141, parse('3141.1e-3'))
- assert_equal_float(3.141, parse('3141E-3'))
- assert_equal_float(3.141, parse('3141.0E-3'))
- assert_equal_float(-3.141, parse('-3141.0e-3'))
- assert_equal_float(-3.141, parse('-3141e-3'))
+ assert_equal 23, parse('23')
+ assert_equal -23, parse('-23')
+ assert_equal_float 3.141, parse('3.141')
+ assert_equal_float -3.141, parse('-3.141')
+ assert_equal_float 3.141, parse('3141e-3')
+ assert_equal_float 3.141, parse('3141.1e-3')
+ assert_equal_float 3.141, parse('3141E-3')
+ assert_equal_float 3.141, parse('3141.0E-3')
+ assert_equal_float -3.141, parse('-3141.0e-3')
+ assert_equal_float -3.141, parse('-3141e-3')
assert_raise(ParserError) { parse('NaN') }
assert parse('NaN', :allow_nan => true).nan?
assert_raise(ParserError) { parse('Infinity') }
- assert_equal(1.0/0, parse('Infinity', :allow_nan => true))
+ assert_equal 1.0/0, parse('Infinity', :allow_nan => true)
assert_raise(ParserError) { parse('-Infinity') }
- assert_equal(-1.0/0, parse('-Infinity', :allow_nan => true))
+ assert_equal -1.0/0, parse('-Infinity', :allow_nan => true)
end
def test_parse_bigdecimals
- assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class)
- assert_equal(BigDecimal("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] )
+ assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class)
+ assert_equal(BigDecimal.new("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] )
end
if Array.method_defined?(:permutation)
diff --git a/test/json/test_helper.rb b/test/json/test_helper.rb
index c5ec0fca7b..7e99c29d0d 100644
--- a/test/json/test_helper.rb
+++ b/test/json/test_helper.rb
@@ -15,3 +15,7 @@ begin
require 'byebug'
rescue LoadError
end
+if ENV['START_SIMPLECOV'].to_i == 1
+ require 'simplecov'
+ SimpleCov.start
+end
diff --git a/tool/lib/-test-/integer.rb b/test/lib/-test-/integer.rb
index a224148f24..a224148f24 100644
--- a/tool/lib/-test-/integer.rb
+++ b/test/lib/-test-/integer.rb
diff --git a/test/lib/envutil.rb b/test/lib/envutil.rb
new file mode 100644
index 0000000000..5d3bce99ec
--- /dev/null
+++ b/test/lib/envutil.rb
@@ -0,0 +1,298 @@
+# -*- coding: us-ascii -*-
+# frozen_string_literal: true
+require "open3"
+require "timeout"
+require_relative "find_executable"
+begin
+ require 'rbconfig'
+rescue LoadError
+end
+begin
+ require "rbconfig/sizeof"
+rescue LoadError
+end
+
+module EnvUtil
+ def rubybin
+ if ruby = ENV["RUBY"]
+ return ruby
+ end
+ ruby = "ruby"
+ exeext = RbConfig::CONFIG["EXEEXT"]
+ rubyexe = (ruby + exeext if exeext and !exeext.empty?)
+ 3.times do
+ if File.exist? ruby and File.executable? ruby and !File.directory? ruby
+ return File.expand_path(ruby)
+ end
+ if rubyexe and File.exist? rubyexe and File.executable? rubyexe
+ return File.expand_path(rubyexe)
+ end
+ ruby = File.join("..", ruby)
+ end
+ if defined?(RbConfig.ruby)
+ RbConfig.ruby
+ else
+ "ruby"
+ end
+ end
+ module_function :rubybin
+
+ LANG_ENVS = %w"LANG LC_ALL LC_CTYPE"
+
+ DEFAULT_SIGNALS = Signal.list
+ DEFAULT_SIGNALS.delete("TERM") if /mswin|mingw/ =~ RUBY_PLATFORM
+
+ RUBYLIB = ENV["RUBYLIB"]
+
+ class << self
+ attr_accessor :subprocess_timeout_scale
+ attr_reader :original_internal_encoding, :original_external_encoding,
+ :original_verbose
+
+ def capture_global_values
+ @original_internal_encoding = Encoding.default_internal
+ @original_external_encoding = Encoding.default_external
+ @original_verbose = $VERBOSE
+ end
+ end
+
+ def apply_timeout_scale(t)
+ if scale = EnvUtil.subprocess_timeout_scale
+ t * scale
+ else
+ t
+ end
+ end
+ module_function :apply_timeout_scale
+
+ def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = false,
+ encoding: nil, timeout: 10, reprieve: 1, timeout_error: Timeout::Error,
+ stdout_filter: nil, stderr_filter: nil,
+ signal: :TERM,
+ rubybin: EnvUtil.rubybin, precommand: nil,
+ **opt)
+ timeout = apply_timeout_scale(timeout)
+ reprieve = apply_timeout_scale(reprieve) if reprieve
+
+ in_c, in_p = IO.pipe
+ out_p, out_c = IO.pipe if capture_stdout
+ err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout
+ opt[:in] = in_c
+ opt[:out] = out_c if capture_stdout
+ opt[:err] = capture_stderr == :merge_to_stdout ? out_c : err_c if capture_stderr
+ if encoding
+ out_p.set_encoding(encoding) if out_p
+ err_p.set_encoding(encoding) if err_p
+ end
+ c = "C"
+ child_env = {}
+ LANG_ENVS.each {|lc| child_env[lc] = c}
+ if Array === args and Hash === args.first
+ child_env.update(args.shift)
+ end
+ if RUBYLIB and lib = child_env["RUBYLIB"]
+ child_env["RUBYLIB"] = [lib, RUBYLIB].join(File::PATH_SEPARATOR)
+ end
+ args = [args] if args.kind_of?(String)
+ pid = spawn(child_env, *precommand, rubybin, *args, **opt)
+ in_c.close
+ out_c.close if capture_stdout
+ err_c.close if capture_stderr && capture_stderr != :merge_to_stdout
+ if block_given?
+ return yield in_p, out_p, err_p, pid
+ else
+ th_stdout = Thread.new { out_p.read } if capture_stdout
+ th_stderr = Thread.new { err_p.read } if capture_stderr && capture_stderr != :merge_to_stdout
+ in_p.write stdin_data.to_str unless stdin_data.empty?
+ in_p.close
+ if (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
+ timeout_error = nil
+ else
+ signals = Array(signal).select do |sig|
+ DEFAULT_SIGNALS[sig.to_s] or
+ DEFAULT_SIGNALS[Signal.signame(sig)] rescue false
+ end
+ signals |= [:ABRT, :KILL]
+ case pgroup = opt[:pgroup]
+ when 0, true
+ pgroup = -pid
+ when nil, false
+ pgroup = pid
+ end
+ while signal = signals.shift
+ begin
+ Process.kill signal, pgroup
+ rescue Errno::EINVAL
+ next
+ rescue Errno::ESRCH
+ break
+ end
+ if signals.empty? or !reprieve
+ Process.wait(pid)
+ else
+ begin
+ Timeout.timeout(reprieve) {Process.wait(pid)}
+ rescue Timeout::Error
+ end
+ end
+ end
+ status = $?
+ end
+ stdout = th_stdout.value if capture_stdout
+ stderr = th_stderr.value if capture_stderr && capture_stderr != :merge_to_stdout
+ out_p.close if capture_stdout
+ err_p.close if capture_stderr && capture_stderr != :merge_to_stdout
+ status ||= Process.wait2(pid)[1]
+ stdout = stdout_filter.call(stdout) if stdout_filter
+ stderr = stderr_filter.call(stderr) if stderr_filter
+ if timeout_error
+ bt = caller_locations
+ msg = "execution of #{bt.shift.label} expired timeout (#{timeout} sec)"
+ msg = Test::Unit::Assertions::FailDesc[status, msg, [stdout, stderr].join("\n")].()
+ raise timeout_error, msg, bt.map(&:to_s)
+ end
+ return stdout, stderr, status
+ end
+ ensure
+ [th_stdout, th_stderr].each do |th|
+ th.kill if th
+ end
+ [in_c, in_p, out_c, out_p, err_c, err_p].each do |io|
+ io&.close
+ end
+ [th_stdout, th_stderr].each do |th|
+ th.join if th
+ end
+ end
+ module_function :invoke_ruby
+
+ alias rubyexec invoke_ruby
+ class << self
+ alias rubyexec invoke_ruby
+ end
+
+ def verbose_warning
+ class << (stderr = "".dup)
+ alias write concat
+ def flush; end
+ end
+ stderr, $stderr = $stderr, stderr
+ $VERBOSE = true
+ yield stderr
+ return $stderr
+ ensure
+ stderr, $stderr = $stderr, stderr
+ $VERBOSE = EnvUtil.original_verbose
+ end
+ module_function :verbose_warning
+
+ def default_warning
+ $VERBOSE = false
+ yield
+ ensure
+ $VERBOSE = EnvUtil.original_verbose
+ end
+ module_function :default_warning
+
+ def suppress_warning
+ $VERBOSE = nil
+ yield
+ ensure
+ $VERBOSE = EnvUtil.original_verbose
+ end
+ module_function :suppress_warning
+
+ def under_gc_stress(stress = true)
+ stress, GC.stress = GC.stress, stress
+ yield
+ ensure
+ GC.stress = stress
+ end
+ module_function :under_gc_stress
+
+ def with_default_external(enc)
+ suppress_warning { Encoding.default_external = enc }
+ yield
+ ensure
+ suppress_warning { Encoding.default_external = EnvUtil.original_external_encoding }
+ end
+ module_function :with_default_external
+
+ def with_default_internal(enc)
+ suppress_warning { Encoding.default_internal = enc }
+ yield
+ ensure
+ suppress_warning { Encoding.default_internal = EnvUtil.original_internal_encoding }
+ end
+ module_function :with_default_internal
+
+ def labeled_module(name, &block)
+ Module.new do
+ singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
+ class_eval(&block) if block
+ end
+ end
+ module_function :labeled_module
+
+ def labeled_class(name, superclass = Object, &block)
+ Class.new(superclass) do
+ singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
+ class_eval(&block) if block
+ end
+ end
+ module_function :labeled_class
+
+ if /darwin/ =~ RUBY_PLATFORM
+ DIAGNOSTIC_REPORTS_PATH = File.expand_path("~/Library/Logs/DiagnosticReports")
+ DIAGNOSTIC_REPORTS_TIMEFORMAT = '%Y-%m-%d-%H%M%S'
+ @ruby_install_name = RbConfig::CONFIG['RUBY_INSTALL_NAME']
+
+ def self.diagnostic_reports(signame, pid, now)
+ return unless %w[ABRT QUIT SEGV ILL TRAP].include?(signame)
+ cmd = File.basename(rubybin)
+ cmd = @ruby_install_name if "ruby-runner#{RbConfig::CONFIG["EXEEXT"]}" == cmd
+ path = DIAGNOSTIC_REPORTS_PATH
+ timeformat = DIAGNOSTIC_REPORTS_TIMEFORMAT
+ pat = "#{path}/#{cmd}_#{now.strftime(timeformat)}[-_]*.crash"
+ first = true
+ 30.times do
+ first ? (first = false) : sleep(0.1)
+ Dir.glob(pat) do |name|
+ log = File.read(name) rescue next
+ if /\AProcess:\s+#{cmd} \[#{pid}\]$/ =~ log
+ File.unlink(name)
+ File.unlink("#{path}/.#{File.basename(name)}.plist") rescue nil
+ return log
+ end
+ end
+ end
+ nil
+ end
+ else
+ def self.diagnostic_reports(signame, pid, now)
+ end
+ end
+
+ def self.gc_stress_to_class?
+ unless defined?(@gc_stress_to_class)
+ _, _, status = invoke_ruby(["-e""exit GC.respond_to?(:add_stress_to_class)"])
+ @gc_stress_to_class = status.success?
+ end
+ @gc_stress_to_class
+ end
+end
+
+if defined?(RbConfig)
+ module RbConfig
+ @ruby = EnvUtil.rubybin
+ class << self
+ undef ruby if method_defined?(:ruby)
+ attr_reader :ruby
+ end
+ dir = File.dirname(ruby)
+ CONFIG['bindir'] = dir
+ Gem::ConfigMap[:bindir] = dir if defined?(Gem::ConfigMap)
+ end
+end
+
+EnvUtil.capture_global_values
diff --git a/tool/lib/find_executable.rb b/test/lib/find_executable.rb
index 89c6fb8f3b..89c6fb8f3b 100644
--- a/tool/lib/find_executable.rb
+++ b/test/lib/find_executable.rb
diff --git a/test/lib/iseq_loader_checker.rb b/test/lib/iseq_loader_checker.rb
new file mode 100644
index 0000000000..1a1a694834
--- /dev/null
+++ b/test/lib/iseq_loader_checker.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+begin
+ require '-test-/iseq_load/iseq_load'
+rescue LoadError
+end
+require 'tempfile'
+
+class RubyVM::InstructionSequence
+ def disasm_if_possible
+ begin
+ self.disasm
+ rescue Encoding::CompatibilityError, EncodingError, SecurityError
+ nil
+ end
+ end
+
+ def self.compare_dump_and_load i1, dumper, loader
+ dump = dumper.call(i1)
+ return i1 unless dump
+ i2 = loader.call(dump)
+
+ # compare disassembled result
+ d1 = i1.disasm_if_possible
+ d2 = i2.disasm_if_possible
+
+ if d1 != d2
+ STDERR.puts "expected:"
+ STDERR.puts d1
+ STDERR.puts "actual:"
+ STDERR.puts d2
+
+ t1 = Tempfile.new("expected"); t1.puts d1; t1.close
+ t2 = Tempfile.new("actual"); t2.puts d2; t2.close
+ system("diff -u #{t1.path} #{t2.path}") # use diff if available
+ exit(1)
+ end
+ i2
+ end
+
+ CHECK_TO_A = ENV['RUBY_ISEQ_DUMP_DEBUG'] == 'to_a'
+ CHECK_TO_BINARY = ENV['RUBY_ISEQ_DUMP_DEBUG'] == 'to_binary'
+
+ def self.translate i1
+ # check to_a/load_iseq
+ compare_dump_and_load(i1,
+ proc{|iseq|
+ ary = iseq.to_a
+ ary[9] == :top ? ary : nil
+ },
+ proc{|ary|
+ RubyVM::InstructionSequence.iseq_load(ary)
+ }) if CHECK_TO_A && defined?(RubyVM::InstructionSequence.iseq_load)
+
+ # check to_binary
+ i2_bin = compare_dump_and_load(i1,
+ proc{|iseq|
+ begin
+ iseq.to_binary
+ rescue RuntimeError # not a toplevel
+ # STDERR.puts [:failed, $!, iseq].inspect
+ nil
+ end
+ },
+ proc{|bin|
+ iseq = RubyVM::InstructionSequence.load_from_binary(bin)
+ # STDERR.puts iseq.inspect
+ iseq
+ }) if CHECK_TO_BINARY
+ # return value
+ i2_bin if CHECK_TO_BINARY
+ end if CHECK_TO_A || CHECK_TO_BINARY
+end
+
+#require_relative 'x'; exit(1)
diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb
deleted file mode 100644
index 3785c31ed2..0000000000
--- a/test/lib/jit_support.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'rbconfig'
-
-module JITSupport
- JIT_TIMEOUT = 600 # 10min for each...
- JIT_SUCCESS_PREFIX = 'JIT success \(\d+\.\dms\)'
- JIT_COMPACTION_PREFIX = 'JIT compaction \(\d+\.\dms\)'
- UNSUPPORTED_COMPILERS = [
- %r[\A/opt/intel/.*/bin/intel64/icc\b],
- %r[\A/opt/developerstudio\d+\.\d+/bin/cc\z],
- ]
- # freebsd12: cc1 internal failure https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd12/ruby-master/log/20200306T103003Z.fail.html.gz
- # rhel8: one or more PCH files were found, but they were invalid https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel8/ruby-master/log/20200306T153003Z.fail.html.gz
- # centos8: ditto https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos8/ruby-master/log/20200512T003004Z.fail.html.gz
- PENDING_RUBYCI_NICKNAMES = %w[
- freebsd12
- rhel8
- centos8
- ]
-
- module_function
- # Run Ruby script with --jit-wait (Synchronous JIT compilation).
- # Returns [stdout, stderr]
- def eval_with_jit(env = nil, script, **opts)
- stdout, stderr = nil, nil
- # retry 3 times while cc1 error happens.
- 3.times do |i|
- stdout, stderr, status = eval_with_jit_without_retry(env, script, **opts)
- assert_equal(true, status.success?, "Failed to run script with JIT:\n#{code_block(script)}\nstdout:\n#{code_block(stdout)}\nstderr:\n#{code_block(stderr)}")
- break unless retried_stderr?(stderr)
- end
- [stdout, stderr]
- end
-
- def eval_with_jit_without_retry(env = nil, script, verbose: 0, min_calls: 5, save_temps: false, max_cache: 1000, wait: true, timeout: JIT_TIMEOUT)
- args = [
- '--disable-gems', "--jit-verbose=#{verbose}",
- "--jit-min-calls=#{min_calls}", "--jit-max-cache=#{max_cache}",
- ]
- args << '--jit-wait' if wait
- args << '--jit-save-temps' if save_temps
- args << '--jit-debug' if defined?(@jit_debug) && @jit_debug
- args << '-e' << script
- base_env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' } # workaround to skip requiring `make install` for `make test-all`
- if preloadenv = RbConfig::CONFIG['PRELOADENV'] and !preloadenv.empty?
- so = "mjit_build_dir.#{RbConfig::CONFIG['SOEXT']}"
- base_env[preloadenv] = File.realpath(so) rescue nil
- end
- args.unshift(env ? base_env.merge!(env) : base_env)
- EnvUtil.invoke_ruby(args,
- '', true, true, timeout: timeout,
- )
- end
-
- def supported?
- return @supported if defined?(@supported)
- @supported = UNSUPPORTED_COMPILERS.all? do |regexp|
- !regexp.match?(RbConfig::CONFIG['MJIT_CC'])
- end && RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME'])
- end
-
- def remove_mjit_logs(stderr)
- if RubyVM::MJIT.enabled? # utility for -DFORCE_MJIT_ENABLE
- stderr.gsub(/^MJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '')
- else
- stderr
- end
- end
-
- def code_block(code)
- %Q["""\n#{code}\n"""\n\n]
- end
-
- # We're retrying cc1 not found error on gcc, which should be solved in the future but ignored for now.
- def retried_stderr?(stderr)
- RbConfig::CONFIG['CC'].start_with?('gcc') &&
- stderr.include?("error trying to exec 'cc1': execvp: No such file or directory")
- end
-end
diff --git a/test/lib/leakchecker.rb b/test/lib/leakchecker.rb
new file mode 100644
index 0000000000..d236b7d7f0
--- /dev/null
+++ b/test/lib/leakchecker.rb
@@ -0,0 +1,229 @@
+# frozen_string_literal: true
+class LeakChecker
+ def initialize
+ @fd_info = find_fds
+ @tempfile_info = find_tempfiles
+ @thread_info = find_threads
+ @env_info = find_env
+ @encoding_info = find_encodings
+ end
+
+ def check(test_name)
+ leaks = [
+ check_fd_leak(test_name),
+ check_thread_leak(test_name),
+ check_tempfile_leak(test_name),
+ check_env(test_name),
+ check_encodings(test_name),
+ ]
+ GC.start if leaks.any?
+ end
+
+ def find_fds
+ if IO.respond_to?(:console) and (m = IO.method(:console)).arity.nonzero?
+ m[:close]
+ end
+ fd_dir = "/proc/self/fd"
+ if File.directory?(fd_dir)
+ fds = Dir.open(fd_dir) {|d|
+ a = d.grep(/\A\d+\z/, &:to_i)
+ if d.respond_to? :fileno
+ a -= [d.fileno]
+ end
+ a
+ }
+ fds.sort
+ else
+ []
+ end
+ end
+
+ def check_fd_leak(test_name)
+ leaked = false
+ live1 = @fd_info
+ live2 = find_fds
+ fd_closed = live1 - live2
+ if !fd_closed.empty?
+ fd_closed.each {|fd|
+ puts "Closed file descriptor: #{test_name}: #{fd}"
+ }
+ end
+ fd_leaked = live2 - live1
+ if !fd_leaked.empty?
+ leaked = true
+ h = {}
+ ObjectSpace.each_object(IO) {|io|
+ inspect = io.inspect
+ begin
+ autoclose = io.autoclose?
+ fd = io.fileno
+ rescue IOError # closed IO object
+ next
+ end
+ (h[fd] ||= []) << [io, autoclose, inspect]
+ }
+ fd_leaked.each {|fd|
+ str = ''.dup
+ if h[fd]
+ str << ' :'
+ h[fd].map {|io, autoclose, inspect|
+ s = ' ' + inspect
+ s << "(not-autoclose)" if !autoclose
+ s
+ }.sort.each {|s|
+ str << s
+ }
+ end
+ puts "Leaked file descriptor: #{test_name}: #{fd}#{str}"
+ }
+ #system("lsof -p #$$") if !fd_leaked.empty?
+ h.each {|fd, list|
+ next if list.length <= 1
+ if 1 < list.count {|io, autoclose, inspect| autoclose }
+ str = list.map {|io, autoclose, inspect| " #{inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join
+ puts "Multiple autoclose IO object for a file descriptor:#{str}"
+ end
+ }
+ end
+ @fd_info = live2
+ return leaked
+ end
+
+ def extend_tempfile_counter
+ return if defined? LeakChecker::TempfileCounter
+ m = Module.new {
+ @count = 0
+ class << self
+ attr_accessor :count
+ end
+
+ def new(data)
+ LeakChecker::TempfileCounter.count += 1
+ super(data)
+ end
+ }
+ LeakChecker.const_set(:TempfileCounter, m)
+
+ class << Tempfile::Remover
+ prepend LeakChecker::TempfileCounter
+ end
+ end
+
+ def find_tempfiles(prev_count=-1)
+ return [prev_count, []] unless defined? Tempfile
+ extend_tempfile_counter
+ count = TempfileCounter.count
+ if prev_count == count
+ [prev_count, []]
+ else
+ tempfiles = ObjectSpace.each_object(Tempfile).find_all {|t|
+ t.instance_variable_defined?(:@tmpfile) and t.path
+ }
+ [count, tempfiles]
+ end
+ end
+
+ def check_tempfile_leak(test_name)
+ return false unless defined? Tempfile
+ count1, initial_tempfiles = @tempfile_info
+ count2, current_tempfiles = find_tempfiles(count1)
+ leaked = false
+ tempfiles_leaked = current_tempfiles - initial_tempfiles
+ if !tempfiles_leaked.empty?
+ leaked = true
+ list = tempfiles_leaked.map {|t| t.inspect }.sort
+ list.each {|str|
+ puts "Leaked tempfile: #{test_name}: #{str}"
+ }
+ tempfiles_leaked.each {|t| t.close! }
+ end
+ @tempfile_info = [count2, initial_tempfiles]
+ return leaked
+ end
+
+ def find_threads
+ Thread.list.find_all {|t|
+ t != Thread.current && t.alive?
+ }
+ end
+
+ def check_thread_leak(test_name)
+ live1 = @thread_info
+ live2 = find_threads
+ thread_finished = live1 - live2
+ leaked = false
+ if !thread_finished.empty?
+ list = thread_finished.map {|t| t.inspect }.sort
+ list.each {|str|
+ puts "Finished thread: #{test_name}: #{str}"
+ }
+ end
+ thread_leaked = live2 - live1
+ if !thread_leaked.empty?
+ leaked = true
+ list = thread_leaked.map {|t| t.inspect }.sort
+ list.each {|str|
+ puts "Leaked thread: #{test_name}: #{str}"
+ }
+ end
+ @thread_info = live2
+ return leaked
+ end
+
+ def find_env
+ ENV.to_h
+ end
+
+ def check_env(test_name)
+ old_env = @env_info
+ new_env = ENV.to_h
+ return false if old_env == new_env
+ (old_env.keys | new_env.keys).sort.each {|k|
+ if old_env.has_key?(k)
+ if new_env.has_key?(k)
+ if old_env[k] != new_env[k]
+ puts "Environment variable changed: #{test_name} : #{k.inspect} changed : #{old_env[k].inspect} -> #{new_env[k].inspect}"
+ end
+ else
+ puts "Environment variable changed: #{test_name} : #{k.inspect} deleted"
+ end
+ else
+ if new_env.has_key?(k)
+ puts "Environment variable changed: #{test_name} : #{k.inspect} added"
+ else
+ flunk "unreachable"
+ end
+ end
+ }
+ @env_info = new_env
+ return true
+ end
+
+ def find_encodings
+ [Encoding.default_internal, Encoding.default_external]
+ end
+
+ def check_encodings(test_name)
+ old_internal, old_external = @encoding_info
+ new_internal, new_external = find_encodings
+ leaked = false
+ if new_internal != old_internal
+ leaked = true
+ puts "Encoding.default_internal changed: #{test_name} : #{old_internal.inspect} to #{new_internal.inspect}"
+ end
+ if new_external != old_external
+ leaked = true
+ puts "Encoding.default_external changed: #{test_name} : #{old_external.inspect} to #{new_external.inspect}"
+ end
+ @encoding_info = [new_internal, new_external]
+ return leaked
+ end
+
+ def puts(*a)
+ output = MiniTest::Unit.output
+ if defined?(output.set_encoding)
+ output.set_encoding(nil, nil)
+ end
+ output.puts(*a)
+ end
+end
diff --git a/tool/lib/memory_status.rb b/test/lib/memory_status.rb
index ad002b2dda..ad002b2dda 100644
--- a/tool/lib/memory_status.rb
+++ b/test/lib/memory_status.rb
diff --git a/tool/lib/minitest/README.txt b/test/lib/minitest/README.txt
index 368cc3aa4e..368cc3aa4e 100644
--- a/tool/lib/minitest/README.txt
+++ b/test/lib/minitest/README.txt
diff --git a/tool/lib/minitest/autorun.rb b/test/lib/minitest/autorun.rb
index 844096623c..844096623c 100644
--- a/tool/lib/minitest/autorun.rb
+++ b/test/lib/minitest/autorun.rb
diff --git a/tool/lib/minitest/benchmark.rb b/test/lib/minitest/benchmark.rb
index b3f2bc28b3..b3f2bc28b3 100644
--- a/tool/lib/minitest/benchmark.rb
+++ b/test/lib/minitest/benchmark.rb
diff --git a/tool/lib/minitest/mock.rb b/test/lib/minitest/mock.rb
index 224b06cb89..224b06cb89 100644
--- a/tool/lib/minitest/mock.rb
+++ b/test/lib/minitest/mock.rb
diff --git a/test/lib/minitest/unit.rb b/test/lib/minitest/unit.rb
new file mode 100644
index 0000000000..89b6a8eaf4
--- /dev/null
+++ b/test/lib/minitest/unit.rb
@@ -0,0 +1,1414 @@
+# encoding: utf-8
+# frozen_string_literal: true
+
+require "optparse"
+require "rbconfig"
+require "leakchecker"
+
+##
+# Minimal (mostly drop-in) replacement for test-unit.
+#
+# :include: README.txt
+
+module MiniTest
+
+ def self.const_missing name # :nodoc:
+ case name
+ when :MINI_DIR then
+ msg = "MiniTest::MINI_DIR was removed. Don't violate other's internals."
+ warn "WAR\NING: #{msg}"
+ warn "WAR\NING: Used by #{caller.first}."
+ const_set :MINI_DIR, "bad value"
+ else
+ super
+ end
+ end
+
+ ##
+ # Assertion base class
+
+ class Assertion < Exception; end
+
+ ##
+ # Assertion raised when skipping a test
+
+ class Skip < Assertion; end
+
+ class << self
+ ##
+ # Filter object for backtraces.
+
+ attr_accessor :backtrace_filter
+ end
+
+ class BacktraceFilter # :nodoc:
+ def filter bt
+ return ["No backtrace"] unless bt
+
+ new_bt = []
+
+ unless $DEBUG then
+ bt.each do |line|
+ break if line =~ /lib\/minitest/
+ new_bt << line
+ end
+
+ new_bt = bt.reject { |line| line =~ /lib\/minitest/ } if new_bt.empty?
+ new_bt = bt.dup if new_bt.empty?
+ else
+ new_bt = bt.dup
+ end
+
+ new_bt
+ end
+ end
+
+ self.backtrace_filter = BacktraceFilter.new
+
+ def self.filter_backtrace bt # :nodoc:
+ backtrace_filter.filter bt
+ end
+
+ ##
+ # MiniTest Assertions. All assertion methods accept a +msg+ which is
+ # printed if the assertion fails.
+
+ module Assertions
+ ##
+ # Returns the diff command to use in #diff. Tries to intelligently
+ # figure out what diff to use.
+
+ def self.diff
+ @diff = if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ &&
+ system("diff.exe", __FILE__, __FILE__)) then
+ "diff.exe -u"
+ elsif Minitest::Unit::Guard.maglev? then # HACK
+ "diff -u"
+ elsif system("gdiff", __FILE__, __FILE__)
+ "gdiff -u" # solaris and kin suck
+ elsif system("diff", __FILE__, __FILE__)
+ "diff -u"
+ else
+ nil
+ end unless defined? @diff
+
+ @diff
+ end
+
+ ##
+ # Set the diff command to use in #diff.
+
+ def self.diff= o
+ @diff = o
+ end
+
+ ##
+ # Returns a diff between +exp+ and +act+. If there is no known
+ # diff command or if it doesn't make sense to diff the output
+ # (single line, short output), then it simply returns a basic
+ # comparison between the two.
+
+ def diff exp, act
+ require "tempfile"
+
+ expect = mu_pp_for_diff exp
+ butwas = mu_pp_for_diff act
+ result = nil
+
+ need_to_diff =
+ MiniTest::Assertions.diff &&
+ (expect.include?("\n") ||
+ butwas.include?("\n") ||
+ expect.size > 30 ||
+ butwas.size > 30 ||
+ expect == butwas)
+
+ return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
+ need_to_diff
+
+ tempfile_a = nil
+ tempfile_b = nil
+
+ Tempfile.open("expect") do |a|
+ tempfile_a = a
+ a.puts expect
+ a.flush
+
+ Tempfile.open("butwas") do |b|
+ tempfile_b = b
+ b.puts butwas
+ b.flush
+
+ result = `#{MiniTest::Assertions.diff} #{a.path} #{b.path}`
+ result.sub!(/^\-\-\- .+/, "--- expected")
+ result.sub!(/^\+\+\+ .+/, "+++ actual")
+
+ if result.empty? then
+ klass = exp.class
+ result = [
+ "No visible difference in the #{klass}#inspect output.\n",
+ "You should look at the implementation of #== on ",
+ "#{klass} or its members.\n",
+ expect,
+ ].join
+ end
+ end
+ end
+
+ result
+ ensure
+ tempfile_a.close! if tempfile_a
+ tempfile_b.close! if tempfile_b
+ end
+
+ ##
+ # This returns a human-readable version of +obj+. By default
+ # #inspect is called. You can override this to use #pretty_print
+ # if you want.
+
+ def mu_pp obj
+ s = obj.inspect
+ s = s.encode Encoding.default_external if defined? Encoding
+ s
+ end
+
+ ##
+ # This returns a diff-able human-readable version of +obj+. This
+ # differs from the regular mu_pp because it expands escaped
+ # newlines and makes hex-values generic (like object_ids). This
+ # uses mu_pp to do the first pass and then cleans it up.
+
+ def mu_pp_for_diff obj
+ mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
+ end
+
+ def _assertions= n # :nodoc:
+ @_assertions = n
+ end
+
+ def _assertions # :nodoc:
+ @_assertions ||= 0
+ end
+
+ ##
+ # Fails unless +test+ is a true value.
+
+ def assert test, msg = nil
+ msg ||= "Failed assertion, no message given."
+ self._assertions += 1
+ unless test then
+ msg = msg.call if Proc === msg
+ raise MiniTest::Assertion, msg
+ end
+ true
+ end
+
+ ##
+ # Fails unless +obj+ is empty.
+
+ def assert_empty obj, msg = nil
+ msg = message(msg) { "Expected #{mu_pp(obj)} to be empty" }
+ assert_respond_to obj, :empty?
+ assert obj.empty?, msg
+ end
+
+ ##
+ # Fails unless <tt>exp == act</tt> printing the difference between
+ # the two, if possible.
+ #
+ # If there is no visible difference but the assertion fails, you
+ # should suspect that your #== is buggy, or your inspect output is
+ # missing crucial details.
+ #
+ # For floats use assert_in_delta.
+ #
+ # See also: MiniTest::Assertions.diff
+
+ def assert_equal exp, act, msg = nil
+ msg = message(msg, "") { diff exp, act }
+ assert exp == act, msg
+ end
+
+ ##
+ # For comparing Floats. Fails unless +exp+ and +act+ are within +delta+
+ # of each other.
+ #
+ # assert_in_delta Math::PI, (22.0 / 7.0), 0.01
+
+ def assert_in_delta exp, act, delta = 0.001, msg = nil
+ n = (exp - act).abs
+ msg = message(msg) {
+ "Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}"
+ }
+ assert delta >= n, msg
+ end
+
+ ##
+ # For comparing Floats. Fails unless +exp+ and +act+ have a relative
+ # error less than +epsilon+.
+
+ def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
+ assert_in_delta a, b, [a.abs, b.abs].min * epsilon, msg
+ end
+
+ ##
+ # Fails unless +collection+ includes +obj+.
+
+ def assert_includes collection, obj, msg = nil
+ msg = message(msg) {
+ "Expected #{mu_pp(collection)} to include #{mu_pp(obj)}"
+ }
+ assert_respond_to collection, :include?
+ assert collection.include?(obj), msg
+ end
+
+ ##
+ # Fails unless +obj+ is an instance of +cls+.
+
+ def assert_instance_of cls, obj, msg = nil
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}"
+ }
+
+ assert obj.instance_of?(cls), msg
+ end
+
+ ##
+ # Fails unless +obj+ is a kind of +cls+.
+
+ def assert_kind_of cls, obj, msg = nil # TODO: merge with instance_of
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
+
+ assert obj.kind_of?(cls), msg
+ end
+
+ ##
+ # Fails unless +matcher+ <tt>=~</tt> +obj+.
+
+ def assert_match matcher, obj, msg = nil
+ msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
+ assert_respond_to matcher, :"=~"
+ matcher = Regexp.new Regexp.escape matcher if String === matcher
+ assert matcher =~ obj, msg
+ end
+
+ ##
+ # Fails unless +obj+ is nil
+
+ def assert_nil obj, msg = nil
+ msg = message(msg) { "Expected #{mu_pp(obj)} to be nil" }
+ assert obj.nil?, msg
+ end
+
+ ##
+ # For testing with binary operators.
+ #
+ # assert_operator 5, :<=, 4
+
+ def assert_operator o1, op, o2 = (predicate = true; nil), msg = nil
+ return assert_predicate o1, op, msg if predicate
+ msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op} #{mu_pp(o2)}" }
+ assert o1.__send__(op, o2), msg
+ end
+
+ ##
+ # Fails if stdout or stderr do not output the expected results.
+ # Pass in nil if you don't care about that streams output. Pass in
+ # "" if you require it to be silent. Pass in a regexp if you want
+ # to pattern match.
+ #
+ # NOTE: this uses #capture_io, not #capture_subprocess_io.
+ #
+ # See also: #assert_silent
+
+ def assert_output stdout = nil, stderr = nil
+ out, err = capture_io do
+ yield
+ end
+
+ err_msg = Regexp === stderr ? :assert_match : :assert_equal if stderr
+ out_msg = Regexp === stdout ? :assert_match : :assert_equal if stdout
+
+ y = send err_msg, stderr, err, "In stderr" if err_msg
+ x = send out_msg, stdout, out, "In stdout" if out_msg
+
+ (!stdout || x) && (!stderr || y)
+ end
+
+ ##
+ # For testing with predicates.
+ #
+ # assert_predicate str, :empty?
+ #
+ # This is really meant for specs and is front-ended by assert_operator:
+ #
+ # str.must_be :empty?
+
+ def assert_predicate o1, op, msg = nil
+ msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op}" }
+ assert o1.__send__(op), msg
+ end
+
+ ##
+ # Fails unless the block raises one of +exp+. Returns the
+ # exception matched so you can check the message, attributes, etc.
+
+ def assert_raises *exp
+ msg = "#{exp.pop}.\n" if String === exp.last
+
+ begin
+ yield
+ rescue MiniTest::Skip => e
+ return e if exp.include? MiniTest::Skip
+ raise e
+ rescue Exception => e
+ expected = exp.any? { |ex|
+ if ex.instance_of? Module then
+ e.kind_of? ex
+ else
+ e.instance_of? ex
+ end
+ }
+
+ assert expected, proc {
+ exception_details(e, "#{msg}#{mu_pp(exp)} exception expected, not")
+ }
+
+ return e
+ end
+
+ exp = exp.first if exp.size == 1
+
+ flunk "#{msg}#{mu_pp(exp)} expected but nothing was raised."
+ end
+
+ ##
+ # Fails unless +obj+ responds to +meth+.
+
+ def assert_respond_to obj, meth, msg = nil
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
+ }
+ assert obj.respond_to?(meth), msg
+ end
+
+ ##
+ # Fails unless +exp+ and +act+ are #equal?
+
+ def assert_same exp, act, msg = nil
+ msg = message(msg) {
+ data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
+ "Expected %s (oid=%d) to be the same as %s (oid=%d)" % data
+ }
+ assert exp.equal?(act), msg
+ end
+
+ ##
+ # +send_ary+ is a receiver, message and arguments.
+ #
+ # Fails unless the call returns a true value
+ # TODO: I should prolly remove this from specs
+
+ def assert_send send_ary, m = nil
+ recv, msg, *args = send_ary
+ m = message(m) {
+ "Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
+ assert recv.__send__(msg, *args), m
+ end
+
+ ##
+ # Fails if the block outputs anything to stderr or stdout.
+ #
+ # See also: #assert_output
+
+ def assert_silent
+ assert_output "", "" do
+ yield
+ end
+ end
+
+ ##
+ # Fails unless the block throws +sym+
+
+ def assert_throws sym, msg = nil
+ default = "Expected #{mu_pp(sym)} to have been thrown"
+ caught = true
+ catch(sym) do
+ begin
+ yield
+ rescue ThreadError => e # wtf?!? 1.8 + threads == suck
+ default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
+ rescue ArgumentError => e # 1.9 exception
+ default += ", not #{e.message.split(/ /).last}"
+ rescue NameError => e # 1.8 exception
+ default += ", not #{e.name.inspect}"
+ end
+ caught = false
+ end
+
+ assert caught, message(msg) { default }
+ end
+
+ ##
+ # Captures $stdout and $stderr into strings:
+ #
+ # out, err = capture_io do
+ # puts "Some info"
+ # warn "You did a bad thing"
+ # end
+ #
+ # assert_match %r%info%, out
+ # assert_match %r%bad%, err
+ #
+ # NOTE: For efficiency, this method uses StringIO and does not
+ # capture IO for subprocesses. Use #capture_subprocess_io for
+ # that.
+
+ def capture_io
+ require 'stringio'
+
+ captured_stdout, captured_stderr = StringIO.new, StringIO.new
+
+ synchronize do
+ orig_stdout, orig_stderr = $stdout, $stderr
+ $stdout, $stderr = captured_stdout, captured_stderr
+
+ begin
+ yield
+ ensure
+ $stdout = orig_stdout
+ $stderr = orig_stderr
+ end
+ end
+
+ return captured_stdout.string, captured_stderr.string
+ end
+
+ ##
+ # Captures $stdout and $stderr into strings, using Tempfile to
+ # ensure that subprocess IO is captured as well.
+ #
+ # out, err = capture_subprocess_io do
+ # system "echo Some info"
+ # system "echo You did a bad thing 1>&2"
+ # end
+ #
+ # assert_match %r%info%, out
+ # assert_match %r%bad%, err
+ #
+ # NOTE: This method is approximately 10x slower than #capture_io so
+ # only use it when you need to test the output of a subprocess.
+
+ def capture_subprocess_io
+ require 'tempfile'
+
+ captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
+
+ synchronize do
+ orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
+ $stdout.reopen captured_stdout
+ $stderr.reopen captured_stderr
+
+ begin
+ yield
+
+ $stdout.rewind
+ $stderr.rewind
+
+ [captured_stdout.read, captured_stderr.read]
+ ensure
+ $stdout.reopen orig_stdout
+ $stderr.reopen orig_stderr
+ orig_stdout.close
+ orig_stderr.close
+ captured_stdout.close!
+ captured_stderr.close!
+ end
+ end
+ end
+
+ ##
+ # Returns details for exception +e+
+
+ def exception_details e, msg
+ [
+ "#{msg}",
+ "Class: <#{e.class}>",
+ "Message: <#{e.message.inspect}>",
+ "---Backtrace---",
+ "#{MiniTest::filter_backtrace(e.backtrace).join("\n")}",
+ "---------------",
+ ].join "\n"
+ end
+
+ ##
+ # Fails with +msg+
+
+ def flunk msg = nil
+ msg ||= "Epic Fail!"
+ assert false, msg
+ end
+
+ ##
+ # Returns a proc that will output +msg+ along with the default message.
+
+ def message msg = nil, ending = ".", &default
+ proc {
+ msg = msg.call.chomp(".") if Proc === msg
+ custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
+ "#{custom_message}#{default.call}#{ending}"
+ }
+ end
+
+ ##
+ # used for counting assertions
+
+ def pass msg = nil
+ assert true
+ end
+
+ ##
+ # Fails if +test+ is a true value
+
+ def refute test, msg = nil
+ msg ||= "Failed refutation, no message given"
+ not assert(! test, msg)
+ end
+
+ ##
+ # Fails if +obj+ is empty.
+
+ def refute_empty obj, msg = nil
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not be empty" }
+ assert_respond_to obj, :empty?
+ refute obj.empty?, msg
+ end
+
+ ##
+ # Fails if <tt>exp == act</tt>.
+ #
+ # For floats use refute_in_delta.
+
+ def refute_equal exp, act, msg = nil
+ msg = message(msg) {
+ "Expected #{mu_pp(act)} to not be equal to #{mu_pp(exp)}"
+ }
+ refute exp == act, msg
+ end
+
+ ##
+ # For comparing Floats. Fails if +exp+ is within +delta+ of +act+.
+ #
+ # refute_in_delta Math::PI, (22.0 / 7.0)
+
+ def refute_in_delta exp, act, delta = 0.001, msg = nil
+ n = (exp - act).abs
+ msg = message(msg) {
+ "Expected |#{exp} - #{act}| (#{n}) to not be <= #{delta}"
+ }
+ refute delta >= n, msg
+ end
+
+ ##
+ # For comparing Floats. Fails if +exp+ and +act+ have a relative error
+ # less than +epsilon+.
+
+ def refute_in_epsilon a, b, epsilon = 0.001, msg = nil
+ refute_in_delta a, b, a * epsilon, msg
+ end
+
+ ##
+ # Fails if +collection+ includes +obj+.
+
+ def refute_includes collection, obj, msg = nil
+ msg = message(msg) {
+ "Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}"
+ }
+ assert_respond_to collection, :include?
+ refute collection.include?(obj), msg
+ end
+
+ ##
+ # Fails if +obj+ is an instance of +cls+.
+
+ def refute_instance_of cls, obj, msg = nil
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} to not be an instance of #{cls}"
+ }
+ refute obj.instance_of?(cls), msg
+ end
+
+ ##
+ # Fails if +obj+ is a kind of +cls+.
+
+ def refute_kind_of cls, obj, msg = nil # TODO: merge with instance_of
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not be a kind of #{cls}" }
+ refute obj.kind_of?(cls), msg
+ end
+
+ ##
+ # Fails if +matcher+ <tt>=~</tt> +obj+.
+
+ def refute_match matcher, obj, msg = nil
+ msg = message(msg) {"Expected #{mu_pp matcher} to not match #{mu_pp obj}"}
+ assert_respond_to matcher, :"=~"
+ matcher = Regexp.new Regexp.escape matcher if String === matcher
+ refute matcher =~ obj, msg
+ end
+
+ ##
+ # Fails if +obj+ is nil.
+
+ def refute_nil obj, msg = nil
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not be nil" }
+ refute obj.nil?, msg
+ end
+
+ ##
+ # Fails if +o1+ is not +op+ +o2+. Eg:
+ #
+ # refute_operator 1, :>, 2 #=> pass
+ # refute_operator 1, :<, 2 #=> fail
+
+ def refute_operator o1, op, o2 = (predicate = true; nil), msg = nil
+ return refute_predicate o1, op, msg if predicate
+ msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op} #{mu_pp(o2)}"}
+ refute o1.__send__(op, o2), msg
+ end
+
+ ##
+ # For testing with predicates.
+ #
+ # refute_predicate str, :empty?
+ #
+ # This is really meant for specs and is front-ended by refute_operator:
+ #
+ # str.wont_be :empty?
+
+ def refute_predicate o1, op, msg = nil
+ msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op}" }
+ refute o1.__send__(op), msg
+ end
+
+ ##
+ # Fails if +obj+ responds to the message +meth+.
+
+ def refute_respond_to obj, meth, msg = nil
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
+
+ refute obj.respond_to?(meth), msg
+ end
+
+ ##
+ # Fails if +exp+ is the same (by object identity) as +act+.
+
+ def refute_same exp, act, msg = nil
+ msg = message(msg) {
+ data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
+ "Expected %s (oid=%d) to not be the same as %s (oid=%d)" % data
+ }
+ refute exp.equal?(act), msg
+ end
+
+ ##
+ # Skips the current test. Gets listed at the end of the run but
+ # doesn't cause a failure exit code.
+
+ def skip msg = nil, bt = caller
+ msg ||= "Skipped, no message given"
+ @skip = true
+ raise MiniTest::Skip, msg, bt
+ end
+
+ ##
+ # Was this testcase skipped? Meant for #teardown.
+
+ def skipped?
+ defined?(@skip) and @skip
+ end
+
+ ##
+ # Takes a block and wraps it with the runner's shared mutex.
+
+ def synchronize
+ Minitest::Unit.runner.synchronize do
+ yield
+ end
+ end
+ end
+
+ class Unit # :nodoc:
+ VERSION = "4.7.5" # :nodoc:
+
+ attr_accessor :report, :failures, :errors, :skips # :nodoc:
+ attr_accessor :assertion_count # :nodoc:
+ attr_writer :test_count # :nodoc:
+ attr_accessor :start_time # :nodoc:
+ attr_accessor :help # :nodoc:
+ attr_accessor :verbose # :nodoc:
+ attr_writer :options # :nodoc:
+
+ ##
+ # :attr:
+ #
+ # if true, installs an "INFO" signal handler (only available to BSD and
+ # OS X users) which prints diagnostic information about the test run.
+ #
+ # This is auto-detected by default but may be overridden by custom
+ # runners.
+
+ attr_accessor :info_signal
+
+ ##
+ # Lazy accessor for options.
+
+ def options
+ @options ||= {}
+ end
+
+ @@installed_at_exit ||= false
+ @@out = $stdout
+ @@after_tests = []
+
+ ##
+ # A simple hook allowing you to run a block of code after _all_ of
+ # the tests are done. Eg:
+ #
+ # MiniTest::Unit.after_tests { p $debugging_info }
+
+ def self.after_tests &block
+ @@after_tests << block
+ end
+
+ ##
+ # Registers MiniTest::Unit to run tests at process exit
+
+ def self.autorun
+ at_exit {
+ # don't run if there was a non-exit exception
+ next if $! and not $!.kind_of? SystemExit
+
+ # the order here is important. The at_exit handler must be
+ # installed before anyone else gets a chance to install their
+ # own, that way we can be assured that our exit will be last
+ # to run (at_exit stacks).
+ exit_code = nil
+
+ at_exit {
+ @@after_tests.reverse_each(&:call)
+ exit false if exit_code && exit_code != 0
+ }
+
+ exit_code = MiniTest::Unit.new.run ARGV
+ } unless @@installed_at_exit
+ @@installed_at_exit = true
+ end
+
+ ##
+ # Returns the stream to use for output.
+
+ def self.output
+ @@out
+ end
+
+ ##
+ # Sets MiniTest::Unit to write output to +stream+. $stdout is the default
+ # output
+
+ def self.output= stream
+ @@out = stream
+ end
+
+ ##
+ # Tells MiniTest::Unit to delegate to +runner+, an instance of a
+ # MiniTest::Unit subclass, when MiniTest::Unit#run is called.
+
+ def self.runner= runner
+ @@runner = runner
+ end
+
+ ##
+ # Returns the MiniTest::Unit subclass instance that will be used
+ # to run the tests. A MiniTest::Unit instance is the default
+ # runner.
+
+ def self.runner
+ @@runner ||= self.new
+ end
+
+ ##
+ # Return all plugins' run methods (methods that start with "run_").
+
+ def self.plugins
+ @@plugins ||= (["run_tests"] +
+ public_instance_methods(false).
+ grep(/^run_/).map { |s| s.to_s }).uniq
+ end
+
+ ##
+ # Return the IO for output.
+
+ def output
+ self.class.output
+ end
+
+ def puts *a # :nodoc:
+ output.puts(*a)
+ end
+
+ def print *a # :nodoc:
+ output.print(*a)
+ end
+
+ def test_count # :nodoc:
+ @test_count ||= 0
+ end
+
+ ##
+ # Runner for a given +type+ (eg, test vs bench).
+
+ def _run_anything type
+ suites = TestCase.send "#{type}_suites"
+ return if suites.empty?
+
+ puts
+ puts "# Running #{type}s:"
+ puts
+
+ @test_count, @assertion_count = 0, 0
+ test_count = assertion_count = 0
+ sync = output.respond_to? :"sync=" # stupid emacs
+ old_sync, output.sync = output.sync, true if sync
+
+ count = 0
+ begin
+ start = Time.now
+
+ results = _run_suites suites, type
+
+ @test_count = results.inject(0) { |sum, (tc, _)| sum + tc }
+ @assertion_count = results.inject(0) { |sum, (_, ac)| sum + ac }
+ test_count += @test_count
+ assertion_count += @assertion_count
+ t = Time.now - start
+ count += 1
+ unless @repeat_count
+ puts
+ puts
+ end
+ puts "Finished%s %ss in %.6fs, %.4f tests/s, %.4f assertions/s.\n" %
+ [(@repeat_count ? "(#{count}/#{@repeat_count}) " : ""), type,
+ t, @test_count.fdiv(t), @assertion_count.fdiv(t)]
+ end while @repeat_count && count < @repeat_count &&
+ report.empty? && failures.zero? && errors.zero?
+
+ output.sync = old_sync if sync
+
+ report.each_with_index do |msg, i|
+ puts "\n%3d) %s" % [i + 1, msg]
+ end
+
+ puts
+ @test_count = test_count
+ @assertion_count = assertion_count
+
+ status
+ end
+
+ ##
+ # Runs all the +suites+ for a given +type+.
+ #
+
+ def _run_suites suites, type
+ suites.map { |suite| _run_suite suite, type }
+ end
+
+ ##
+ # Run a single +suite+ for a given +type+.
+
+ def _run_suite suite, type
+ header = "#{type}_suite_header"
+ puts send(header, suite) if respond_to? header
+
+ filter = options[:filter] || '/./'
+ filter = Regexp.new $1 if filter =~ /\/(.*)\//
+
+ all_test_methods = suite.send "#{type}_methods"
+
+ filtered_test_methods = all_test_methods.find_all { |m|
+ filter === m || filter === "#{suite}##{m}"
+ }
+
+ leakchecker = LeakChecker.new
+
+ assertions = filtered_test_methods.map { |method|
+ inst = suite.new method
+ inst._assertions = 0
+
+ print "#{suite}##{method} = " if @verbose
+
+ start_time = Time.now if @verbose
+ result = inst.run self
+
+ print "%.2f s = " % (Time.now - start_time) if @verbose
+ print result
+ puts if @verbose
+ $stdout.flush
+
+ leakchecker.check("#{inst.class}\##{inst.__name__}")
+
+ inst._assertions
+ }
+
+ return assertions.size, assertions.inject(0) { |sum, n| sum + n }
+ end
+
+ ##
+ # Record the result of a single test. Makes it very easy to gather
+ # information. Eg:
+ #
+ # class StatisticsRecorder < MiniTest::Unit
+ # def record suite, method, assertions, time, error
+ # # ... record the results somewhere ...
+ # end
+ # end
+ #
+ # MiniTest::Unit.runner = StatisticsRecorder.new
+ #
+ # NOTE: record might be sent more than once per test. It will be
+ # sent once with the results from the test itself. If there is a
+ # failure or error in teardown, it will be sent again with the
+ # error or failure.
+
+ def record suite, method, assertions, time, error
+ end
+
+ def location e # :nodoc:
+ last_before_assertion = ""
+ e.backtrace.reverse_each do |s|
+ break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
+ last_before_assertion = s
+ end
+ last_before_assertion.sub(/:in .*$/, '')
+ end
+
+ ##
+ # Writes status for failed test +meth+ in +klass+ which finished with
+ # exception +e+
+
+ def puke klass, meth, e
+ e = case e
+ when MiniTest::Skip then
+ @skips += 1
+ return "S" unless @verbose
+ "Skipped:\n#{klass}##{meth} [#{location e}]:\n#{e.message}\n"
+ when MiniTest::Assertion then
+ @failures += 1
+ "Failure:\n#{klass}##{meth} [#{location e}]:\n#{e.message}\n"
+ else
+ @errors += 1
+ bt = MiniTest::filter_backtrace(e.backtrace).join "\n "
+ "Error:\n#{klass}##{meth}:\n#{e.class}: #{e.message.b}\n #{bt}\n"
+ end
+ @report << e
+ e[0, 1]
+ end
+
+ def initialize # :nodoc:
+ @report = []
+ @errors = @failures = @skips = 0
+ @verbose = false
+ @mutex = Thread::Mutex.new
+ @info_signal = Signal.list['INFO']
+ @repeat_count = nil
+ end
+
+ def synchronize # :nodoc:
+ if @mutex then
+ @mutex.synchronize { yield }
+ else
+ yield
+ end
+ end
+
+ def process_args args = [] # :nodoc:
+ options = {}
+ orig_args = args.dup
+
+ OptionParser.new do |opts|
+ opts.banner = 'minitest options:'
+ opts.version = MiniTest::Unit::VERSION
+
+ opts.on '-h', '--help', 'Display this help.' do
+ puts opts
+ exit
+ end
+
+ opts.on '-s', '--seed SEED', Integer, "Sets random seed" do |m|
+ options[:seed] = m.to_i
+ end
+
+ opts.on '-v', '--verbose', "Verbose. Show progress processing files." do
+ options[:verbose] = true
+ end
+
+ opts.on '-n', '--name PATTERN', "Filter test names on pattern (e.g. /foo/)" do |a|
+ options[:filter] = a
+ end
+
+ opts.parse! args
+ orig_args -= args
+ end
+
+ unless options[:seed] then
+ srand
+ options[:seed] = srand % 0xFFFF
+ orig_args << "--seed" << options[:seed].to_s
+ end
+
+ srand options[:seed]
+
+ self.verbose = options[:verbose]
+ @help = orig_args.map { |s| s =~ /[\s|&<>$()]/ ? s.inspect : s }.join " "
+
+ options
+ end
+
+ ##
+ # Begins the full test run. Delegates to +runner+'s #_run method.
+
+ def run args = []
+ self.class.runner._run(args)
+ end
+
+ ##
+ # Top level driver, controls all output and filtering.
+
+ def _run args = []
+ args = process_args args # ARGH!! blame test/unit process_args
+ self.options.merge! args
+
+ puts "Run options: #{help}"
+
+ self.class.plugins.each do |plugin|
+ send plugin
+ break unless report.empty?
+ end
+
+ return failures + errors if self.test_count > 0 # or return nil...
+ rescue Interrupt
+ abort 'Interrupted'
+ end
+
+ ##
+ # Runs test suites matching +filter+.
+
+ def run_tests
+ _run_anything :test
+ end
+
+ ##
+ # Writes status to +io+
+
+ def status io = self.output
+ format = "%d tests, %d assertions, %d failures, %d errors, %d skips"
+ io.puts format % [test_count, assertion_count, failures, errors, skips]
+ end
+
+ ##
+ # Provides a simple set of guards that you can use in your tests
+ # to skip execution if it is not applicable. These methods are
+ # mixed into TestCase as both instance and class methods so you
+ # can use them inside or outside of the test methods.
+ #
+ # def test_something_for_mri
+ # skip "bug 1234" if jruby?
+ # # ...
+ # end
+ #
+ # if windows? then
+ # # ... lots of test methods ...
+ # end
+
+ module Guard
+
+ ##
+ # Is this running on jruby?
+
+ def jruby? platform = RUBY_PLATFORM
+ "java" == platform
+ end
+
+ ##
+ # Is this running on mri?
+
+ def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
+ "maglev" == platform
+ end
+
+ module_function :maglev?
+
+ ##
+ # Is this running on mri?
+
+ def mri? platform = RUBY_DESCRIPTION
+ /^ruby/ =~ platform
+ end
+
+ ##
+ # Is this running on rubinius?
+
+ def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
+ "rbx" == platform
+ end
+
+ ##
+ # Is this running on windows?
+
+ def windows? platform = RUBY_PLATFORM
+ /mswin|mingw/ =~ platform
+ end
+ end
+
+ ##
+ # Provides before/after hooks for setup and teardown. These are
+ # meant for library writers, NOT for regular test authors. See
+ # #before_setup for an example.
+
+ module LifecycleHooks
+ ##
+ # Runs before every test, after setup. This hook is meant for
+ # libraries to extend minitest. It is not meant to be used by
+ # test developers.
+ #
+ # See #before_setup for an example.
+
+ def after_setup; end
+
+ ##
+ # Runs before every test, before setup. This hook is meant for
+ # libraries to extend minitest. It is not meant to be used by
+ # test developers.
+ #
+ # As a simplistic example:
+ #
+ # module MyMinitestPlugin
+ # def before_setup
+ # super
+ # # ... stuff to do before setup is run
+ # end
+ #
+ # def after_setup
+ # # ... stuff to do after setup is run
+ # super
+ # end
+ #
+ # def before_teardown
+ # super
+ # # ... stuff to do before teardown is run
+ # end
+ #
+ # def after_teardown
+ # # ... stuff to do after teardown is run
+ # super
+ # end
+ # end
+ #
+ # class MiniTest::Unit::TestCase
+ # include MyMinitestPlugin
+ # end
+
+ def before_setup; end
+
+ ##
+ # Runs after every test, before teardown. This hook is meant for
+ # libraries to extend minitest. It is not meant to be used by
+ # test developers.
+ #
+ # See #before_setup for an example.
+
+ def before_teardown; end
+
+ ##
+ # Runs after every test, after teardown. This hook is meant for
+ # libraries to extend minitest. It is not meant to be used by
+ # test developers.
+ #
+ # See #before_setup for an example.
+
+ def after_teardown; end
+ end
+
+ ##
+ # Subclass TestCase to create your own tests. Typically you'll want a
+ # TestCase subclass per implementation class.
+ #
+ # See MiniTest::Assertions
+
+ class TestCase
+ include LifecycleHooks
+ include Guard
+ extend Guard
+
+ attr_reader :__name__ # :nodoc:
+
+ PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException,
+ Interrupt, SystemExit] # :nodoc:
+
+ ##
+ # Runs the tests reporting the status to +runner+
+
+ def run runner
+ trap "INFO" do
+ runner.report.each_with_index do |msg, i|
+ warn "\n%3d) %s" % [i + 1, msg]
+ end
+ warn ''
+ time = runner.start_time ? Time.now - runner.start_time : 0
+ warn "Current Test: %s#%s %.2fs" % [self.class, self.__name__, time]
+ runner.status $stderr
+ end if runner.info_signal
+
+ start_time = Time.now
+
+ result = ""
+ begin
+ @passed = nil
+ self.before_setup
+ self.setup
+ self.after_setup
+ self.run_test self.__name__
+ result = "." unless io?
+ time = Time.now - start_time
+ runner.record self.class, self.__name__, self._assertions, time, nil
+ @passed = true
+ rescue *PASSTHROUGH_EXCEPTIONS
+ raise
+ rescue Exception => e
+ @passed = Skip === e
+ time = Time.now - start_time
+ runner.record self.class, self.__name__, self._assertions, time, e
+ result = runner.puke self.class, self.__name__, e
+ ensure
+ %w{ before_teardown teardown after_teardown }.each do |hook|
+ begin
+ self.send hook
+ rescue *PASSTHROUGH_EXCEPTIONS
+ raise
+ rescue Exception => e
+ @passed = false
+ runner.record self.class, self.__name__, self._assertions, time, e
+ result = runner.puke self.class, self.__name__, e
+ end
+ end
+ trap 'INFO', 'DEFAULT' if runner.info_signal
+ end
+ result
+ end
+
+ alias :run_test :__send__
+
+ def initialize name # :nodoc:
+ @__name__ = name
+ @__io__ = nil
+ @passed = nil
+ @@current = self # FIX: make thread local
+ end
+
+ def self.current # :nodoc:
+ @@current # FIX: make thread local
+ end
+
+ ##
+ # Return the output IO object
+
+ def io
+ @__io__ = true
+ MiniTest::Unit.output
+ end
+
+ ##
+ # Have we hooked up the IO yet?
+
+ def io?
+ @__io__
+ end
+
+ def self.reset # :nodoc:
+ @@test_suites = {}
+ end
+
+ reset
+
+ ##
+ # Make diffs for this TestCase use #pretty_inspect so that diff
+ # in assert_equal can be more details. NOTE: this is much slower
+ # than the regular inspect but much more usable for complex
+ # objects.
+
+ def self.make_my_diffs_pretty!
+ require 'pp'
+
+ define_method :mu_pp do |o|
+ o.pretty_inspect
+ end
+ end
+
+ def self.inherited klass # :nodoc:
+ @@test_suites[klass] = true
+ super
+ end
+
+ def self.test_order # :nodoc:
+ :random
+ end
+
+ def self.test_suites # :nodoc:
+ @@test_suites.keys.sort_by { |ts| ts.name.to_s }
+ end
+
+ def self.test_methods # :nodoc:
+ methods = public_instance_methods(true).grep(/^test/).map { |m| m.to_s }
+
+ case self.test_order
+ when :parallel
+ max = methods.size
+ ParallelEach.new methods.sort.sort_by { rand max }
+ when :random then
+ max = methods.size
+ methods.sort.sort_by { rand max }
+ when :alpha, :sorted then
+ methods.sort
+ else
+ raise "Unknown test_order: #{self.test_order.inspect}"
+ end
+ end
+
+ ##
+ # Returns true if the test passed.
+
+ def passed?
+ @passed
+ end
+
+ ##
+ # Runs before every test. Use this to set up before each test
+ # run.
+
+ def setup; end
+
+ ##
+ # Runs after every test. Use this to clean up after each test
+ # run.
+
+ def teardown; end
+
+ include MiniTest::Assertions
+ end # class TestCase
+ end # class Unit
+
+ Test = Unit::TestCase
+end # module MiniTest
+
+Minitest = MiniTest # :nodoc: because ugh... I typo this all the time
diff --git a/test/lib/profile_test_all.rb b/test/lib/profile_test_all.rb
new file mode 100644
index 0000000000..4771b72afb
--- /dev/null
+++ b/test/lib/profile_test_all.rb
@@ -0,0 +1,91 @@
+# frozen_string_literal: true
+#
+# purpose:
+# Profile memory usage of each tests.
+#
+# usage:
+# RUBY_TEST_ALL_PROFILE=[file] make test-all
+#
+# output:
+# [file] specified by RUBY_TEST_ALL_PROFILE
+# If [file] is 'true', then it is ./test_all_profile
+#
+# collected information:
+# - ObjectSpace.memsize_of_all
+# - GC.stat
+# - /proc/meminfo (some fields, if exists)
+# - /proc/self/status (some fields, if exists)
+# - /proc/self/statm (if exists)
+#
+
+require 'objspace'
+
+class MiniTest::Unit::TestCase
+ alias orig_run run
+
+ file = ENV['RUBY_TEST_ALL_PROFILE']
+ file = 'test-all-profile-result' if file == 'true'
+ TEST_ALL_PROFILE_OUT = open(file, 'w')
+ TEST_ALL_PROFILE_GC_STAT_HASH = {}
+ TEST_ALL_PROFILE_BANNER = ['name']
+ TEST_ALL_PROFILE_PROCS = []
+
+ def self.add *name, &b
+ TEST_ALL_PROFILE_BANNER.concat name
+ TEST_ALL_PROFILE_PROCS << b
+ end
+
+ add 'failed?' do |result, tc|
+ result << (tc.passed? ? 0 : 1)
+ end
+
+ add 'memsize_of_all' do |result, *|
+ result << ObjectSpace.memsize_of_all
+ end
+
+ add *GC.stat.keys do |result, *|
+ GC.stat(TEST_ALL_PROFILE_GC_STAT_HASH)
+ result.concat TEST_ALL_PROFILE_GC_STAT_HASH.values
+ end
+
+ def self.add_proc_meminfo file, fields
+ return unless FileTest.exist?(file)
+ regexp = /(#{fields.join("|")}):\s*(\d+) kB/
+ # check = {}; fields.each{|e| check[e] = true}
+ add *fields do |result, *|
+ text = File.read(file)
+ text.scan(regexp){
+ # check.delete $1
+ result << $2
+ ''
+ }
+ # raise check.inspect unless check.empty?
+ end
+ end
+
+ add_proc_meminfo '/proc/meminfo', %w(MemTotal MemFree)
+ add_proc_meminfo '/proc/self/status', %w(VmPeak VmSize VmHWM VmRSS)
+
+ if FileTest.exist?('/proc/self/statm')
+ add *%w(size resident share text lib data dt) do |result, *|
+ result.concat File.read('/proc/self/statm').split(/\s+/)
+ end
+ end
+
+ def memprofile_test_all_result_result
+ result = ["#{self.class}\##{self.__name__.to_s.gsub(/\s+/, '')}"]
+ TEST_ALL_PROFILE_PROCS.each{|proc|
+ proc.call(result, self)
+ }
+ result.join("\t")
+ end
+
+ def run runner
+ result = orig_run(runner)
+ TEST_ALL_PROFILE_OUT.puts memprofile_test_all_result_result
+ TEST_ALL_PROFILE_OUT.flush
+ result
+ end
+
+ TEST_ALL_PROFILE_OUT.puts TEST_ALL_PROFILE_BANNER.join("\t")
+end
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
new file mode 100644
index 0000000000..761fe92df8
--- /dev/null
+++ b/test/lib/test/unit.rb
@@ -0,0 +1,1176 @@
+# frozen_string_literal: true
+begin
+ gem 'minitest', '< 5.0.0' if defined? Gem
+rescue Gem::LoadError
+end
+require 'minitest/unit'
+require 'test/unit/assertions'
+require_relative '../envutil'
+require 'test/unit/testcase'
+require 'optparse'
+
+# See Test::Unit
+module Test
+ ##
+ # Test::Unit is an implementation of the xUnit testing framework for Ruby.
+ #
+ # If you are writing new test code, please use MiniTest instead of Test::Unit.
+ #
+ # Test::Unit has been left in the standard library to support legacy test
+ # suites.
+ module Unit
+ TEST_UNIT_IMPLEMENTATION = 'test/unit compatibility layer using minitest' # :nodoc:
+
+ module RunCount # :nodoc: all
+ @@run_count = 0
+
+ def self.have_run?
+ @@run_count.nonzero?
+ end
+
+ def run(*)
+ @@run_count += 1
+ super
+ end
+
+ def run_once
+ return if have_run?
+ return if $! # don't run if there was an exception
+ yield
+ end
+ module_function :run_once
+ end
+
+ module Options # :nodoc: all
+ def initialize(*, &block)
+ @init_hook = block
+ @options = nil
+ super(&nil)
+ end
+
+ def option_parser
+ @option_parser ||= OptionParser.new
+ end
+
+ def process_args(args = [])
+ return @options if @options
+ orig_args = args.dup
+ options = {}
+ opts = option_parser
+ setup_options(opts, options)
+ opts.parse!(args)
+ orig_args -= args
+ args = @init_hook.call(args, options) if @init_hook
+ non_options(args, options)
+ @run_options = orig_args
+ @help = orig_args.map { |s| s =~ /[\s|&<>$()]/ ? s.inspect : s }.join " "
+ @options = options
+ end
+
+ private
+ def setup_options(opts, options)
+ opts.separator 'minitest options:'
+ opts.version = MiniTest::Unit::VERSION
+
+ opts.on '-h', '--help', 'Display this help.' do
+ puts opts
+ exit
+ end
+
+ opts.on '-s', '--seed SEED', Integer, "Sets random seed" do |m|
+ options[:seed] = m
+ end
+
+ opts.on '-v', '--verbose', "Verbose. Show progress processing files." do
+ options[:verbose] = true
+ self.verbose = options[:verbose]
+ end
+
+ opts.on '-n', '--name PATTERN', "Filter test method names on pattern: /REGEXP/, !/REGEXP/ or STRING" do |a|
+ (options[:filter] ||= []) << a
+ end
+
+ opts.on '--test-order=random|alpha|sorted', [:random, :alpha, :sorted] do |a|
+ MiniTest::Unit::TestCase.test_order = a
+ end
+ end
+
+ def non_options(files, options)
+ filter = options[:filter]
+ if filter
+ pos_pat = /\A\/(.*)\/\z/
+ neg_pat = /\A!\/(.*)\/\z/
+ negative, positive = filter.partition {|s| neg_pat =~ s}
+ if positive.empty?
+ filter = nil
+ elsif negative.empty? and positive.size == 1 and pos_pat !~ positive[0]
+ filter = positive[0]
+ else
+ filter = Regexp.union(*positive.map! {|s| Regexp.new(s[pos_pat, 1] || "\\A#{Regexp.quote(s)}\\z")})
+ end
+ unless negative.empty?
+ negative = Regexp.union(*negative.map! {|s| Regexp.new(s[neg_pat, 1])})
+ filter = /\A(?=.*#{filter})(?!.*#{negative})/
+ end
+ if Regexp === filter
+ # bypass conversion in minitest
+ def filter.=~(other) # :nodoc:
+ super unless Regexp === other
+ end
+ end
+ options[:filter] = filter
+ end
+ true
+ end
+ end
+
+ module Parallel # :nodoc: all
+ def process_args(args = [])
+ return @options if @options
+ options = super
+ if @options[:parallel]
+ @files = args
+ end
+ options
+ end
+
+ def non_options(files, options)
+ @jobserver = nil
+ if !options[:parallel] and
+ /(?:\A|\s)--jobserver-(?:auth|fds)=(\d+),(\d+)/ =~ ENV["MAKEFLAGS"]
+ begin
+ r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
+ w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
+ rescue
+ r.close if r
+ nil
+ else
+ @jobserver = [r, w]
+ options[:parallel] ||= 1
+ end
+ end
+ super
+ end
+
+ def status(*args)
+ result = super
+ raise @interrupt if @interrupt
+ result
+ end
+
+ private
+ def setup_options(opts, options)
+ super
+
+ opts.separator "parallel test options:"
+
+ options[:retry] = true
+
+ opts.on '-j N', '--jobs N', /\A(t)?(\d+)\z/, "Allow run tests with N jobs at once" do |_, t, a|
+ options[:testing] = true & t # For testing
+ options[:parallel] = a.to_i
+ end
+
+ opts.on '--separate', "Restart job process after one testcase has done" do
+ options[:parallel] ||= 1
+ options[:separate] = true
+ end
+
+ opts.on '--retry', "Retry running testcase when --jobs specified" do
+ options[:retry] = true
+ end
+
+ opts.on '--no-retry', "Disable --retry" do
+ options[:retry] = false
+ end
+
+ opts.on '--ruby VAL', "Path to ruby which is used at -j option" do |a|
+ options[:ruby] = a.split(/ /).reject(&:empty?)
+ end
+ end
+
+ class Worker
+ def self.launch(ruby,args=[])
+ io = IO.popen([*ruby, "-W1",
+ "#{File.dirname(__FILE__)}/unit/parallel.rb",
+ *args], "rb+")
+ new(io, io.pid, :waiting)
+ end
+
+ attr_reader :quit_called
+
+ def initialize(io, pid, status)
+ @io = io
+ @pid = pid
+ @status = status
+ @file = nil
+ @real_file = nil
+ @loadpath = []
+ @hooks = {}
+ @quit_called = false
+ end
+
+ def puts(*args)
+ @io.puts(*args)
+ end
+
+ def run(task,type)
+ @file = File.basename(task, ".rb")
+ @real_file = task
+ begin
+ puts "loadpath #{[Marshal.dump($:-@loadpath)].pack("m0")}"
+ @loadpath = $:.dup
+ puts "run #{task} #{type}"
+ @status = :prepare
+ rescue Errno::EPIPE
+ died
+ rescue IOError
+ raise unless /stream closed|closed stream/ =~ $!.message
+ died
+ end
+ end
+
+ def hook(id,&block)
+ @hooks[id] ||= []
+ @hooks[id] << block
+ self
+ end
+
+ def read
+ res = (@status == :quit) ? @io.read : @io.gets
+ res && res.chomp
+ end
+
+ def close
+ @io.close unless @io.closed?
+ self
+ rescue IOError
+ end
+
+ def quit
+ return if @io.closed?
+ @quit_called = true
+ @io.puts "quit"
+ end
+
+ def kill
+ Process.kill(:KILL, @pid)
+ rescue Errno::ESRCH
+ end
+
+ def died(*additional)
+ @status = :quit
+ @io.close
+ status = $?
+ if status and status.signaled?
+ additional[0] ||= SignalException.new(status.termsig)
+ end
+
+ call_hook(:dead,*additional)
+ end
+
+ def to_s
+ if @file and @status != :ready
+ "#{@pid}=#{@file}"
+ else
+ "#{@pid}:#{@status.to_s.ljust(7)}"
+ end
+ end
+
+ attr_reader :io, :pid
+ attr_accessor :status, :file, :real_file, :loadpath
+
+ private
+
+ def call_hook(id,*additional)
+ @hooks[id] ||= []
+ @hooks[id].each{|hook| hook[self,additional] }
+ self
+ end
+
+ end
+
+ def flush_job_tokens
+ if @jobserver
+ r, w = @jobserver.shift(2)
+ @jobserver = nil
+ w << @job_tokens.slice!(0..-1)
+ r.close
+ w.close
+ end
+ end
+
+ def after_worker_down(worker, e=nil, c=false)
+ return unless @options[:parallel]
+ return if @interrupt
+ flush_job_tokens
+ warn e if e
+ real_file = worker.real_file and warn "running file: #{real_file}"
+ @need_quit = true
+ warn ""
+ warn "Some worker was crashed. It seems ruby interpreter's bug"
+ warn "or, a bug of test/unit/parallel.rb. try again without -j"
+ warn "option."
+ warn ""
+ STDERR.flush
+ exit c
+ end
+
+ def after_worker_quit(worker)
+ return unless @options[:parallel]
+ return if @interrupt
+ worker.close
+ if @jobserver and (token = @job_tokens.slice!(0))
+ @jobserver[1] << token
+ end
+ @workers.delete(worker)
+ @dead_workers << worker
+ @ios = @workers.map(&:io)
+ end
+
+ def launch_worker
+ begin
+ worker = Worker.launch(@options[:ruby], @run_options)
+ rescue => e
+ abort "ERROR: Failed to launch job process - #{e.class}: #{e.message}"
+ end
+ worker.hook(:dead) do |w,info|
+ after_worker_quit w
+ after_worker_down w, *info if !info.empty? && !worker.quit_called
+ end
+ @workers << worker
+ @ios << worker.io
+ @workers_hash[worker.io] = worker
+ worker
+ end
+
+ def delete_worker(worker)
+ @workers_hash.delete worker.io
+ @workers.delete worker
+ @ios.delete worker.io
+ end
+
+ def quit_workers
+ return if @workers.empty?
+ @workers.reject! do |worker|
+ begin
+ Timeout.timeout(1) do
+ worker.quit
+ end
+ rescue Errno::EPIPE
+ rescue Timeout::Error
+ end
+ worker.close
+ end
+
+ return if @workers.empty?
+ begin
+ Timeout.timeout(0.2 * @workers.size) do
+ Process.waitall
+ end
+ rescue Timeout::Error
+ @workers.each do |worker|
+ worker.kill
+ end
+ @worker.clear
+ end
+ end
+
+ FakeClass = Struct.new(:name)
+ def fake_class(name)
+ (@fake_classes ||= {})[name] ||= FakeClass.new(name)
+ end
+
+ def deal(io, type, result, rep, shutting_down = false)
+ worker = @workers_hash[io]
+ cmd = worker.read
+ cmd.sub!(/\A\.+/, '') if cmd # read may return nil
+ case cmd
+ when ''
+ # just only dots, ignore
+ when /^okay$/
+ worker.status = :running
+ when /^ready(!)?$/
+ bang = $1
+ worker.status = :ready
+
+ unless task = @tasks.shift
+ worker.quit
+ return nil
+ end
+ if @options[:separate] and not bang
+ worker.quit
+ worker = add_worker
+ end
+ worker.run(task, type)
+ @test_count += 1
+
+ jobs_status(worker)
+ when /^done (.+?)$/
+ begin
+ r = Marshal.load($1.unpack("m")[0])
+ rescue
+ print "unknown object: #{$1.unpack("m")[0].dump}"
+ return true
+ end
+ result << r[0..1] unless r[0..1] == [nil,nil]
+ rep << {file: worker.real_file, report: r[2], result: r[3], testcase: r[5]}
+ $:.push(*r[4]).uniq!
+ jobs_status(worker) if @options[:job_status] == :replace
+ return true
+ when /^record (.+?)$/
+ begin
+ r = Marshal.load($1.unpack("m")[0])
+ rescue => e
+ print "unknown record: #{e.message} #{$1.unpack("m")[0].dump}"
+ return true
+ end
+ record(fake_class(r[0]), *r[1..-1])
+ when /^p (.+?)$/
+ del_jobs_status
+ print $1.unpack("m")[0]
+ jobs_status(worker) if @options[:job_status] == :replace
+ when /^after (.+?)$/
+ @warnings << Marshal.load($1.unpack("m")[0])
+ when /^bye (.+?)$/
+ after_worker_down worker, Marshal.load($1.unpack("m")[0])
+ when /^bye$/, nil
+ if shutting_down || worker.quit_called
+ after_worker_quit worker
+ else
+ after_worker_down worker
+ end
+ else
+ print "unknown command: #{cmd.dump}\n"
+ end
+ return false
+ end
+
+ def _run_parallel suites, type, result
+ if @options[:parallel] < 1
+ warn "Error: parameter of -j option should be greater than 0."
+ return
+ end
+
+ # Require needed thing for parallel running
+ require 'timeout'
+ @tasks = @files.dup # Array of filenames.
+ @need_quit = false
+ @dead_workers = [] # Array of dead workers.
+ @warnings = []
+ @total_tests = @tasks.size.to_s(10)
+ rep = [] # FIXME: more good naming
+
+ @workers = [] # Array of workers.
+ @workers_hash = {} # out-IO => worker
+ @ios = [] # Array of worker IOs
+ @job_tokens = String.new(encoding: Encoding::ASCII_8BIT) if @jobserver
+ begin
+ [@tasks.size, @options[:parallel]].min.times {launch_worker}
+
+ while _io = IO.select(@ios)[0]
+ break if _io.any? do |io|
+ @need_quit or
+ (deal(io, type, result, rep).nil? and
+ !@workers.any? {|x| [:running, :prepare].include? x.status})
+ end
+ if @jobserver and @job_tokens and !@tasks.empty? and !@workers.any? {|x| x.status == :ready}
+ t = @jobserver[0].read_nonblock([@tasks.size, @options[:parallel]].min, exception: false)
+ if String === t
+ @job_tokens << t
+ t.size.times {launch_worker}
+ end
+ end
+ end
+ rescue Interrupt => ex
+ @interrupt = ex
+ return result
+ ensure
+ if @interrupt
+ @ios.select!{|x| @workers_hash[x].status == :running }
+ while !@ios.empty? && (__io = IO.select(@ios,[],[],10))
+ __io[0].reject! {|io| deal(io, type, result, rep, true)}
+ end
+ end
+
+ quit_workers
+ flush_job_tokens
+
+ unless @interrupt || !@options[:retry] || @need_quit
+ parallel = @options[:parallel]
+ @options[:parallel] = false
+ suites, rep = rep.partition {|r| r[:testcase] && r[:file] && r[:report].any? {|e| !e[2].is_a?(MiniTest::Skip)}}
+ suites.map {|r| r[:file]}.uniq.each {|file| require file}
+ suites.map! {|r| eval("::"+r[:testcase])}
+ del_status_line or puts
+ unless suites.empty?
+ puts "\n""Retrying..."
+ _run_suites(suites, type)
+ end
+ @options[:parallel] = parallel
+ end
+ unless @options[:retry]
+ del_status_line or puts
+ end
+ unless rep.empty?
+ rep.each do |r|
+ r[:report].each do |f|
+ puke(*f) if f
+ end
+ end
+ if @options[:retry]
+ @errors += rep.map{|x| x[:result][0] }.inject(:+)
+ @failures += rep.map{|x| x[:result][1] }.inject(:+)
+ @skips += rep.map{|x| x[:result][2] }.inject(:+)
+ end
+ end
+ unless @warnings.empty?
+ warn ""
+ @warnings.uniq! {|w| w[1].message}
+ @warnings.each do |w|
+ warn "#{w[0]}: #{w[1].message} (#{w[1].class})"
+ end
+ warn ""
+ end
+ end
+ end
+
+ def _run_suites suites, type
+ _prepare_run(suites, type)
+ @interrupt = nil
+ result = []
+ GC.start
+ if @options[:parallel]
+ _run_parallel suites, type, result
+ else
+ suites.each {|suite|
+ begin
+ result << _run_suite(suite, type)
+ rescue Interrupt => e
+ @interrupt = e
+ break
+ end
+ }
+ end
+ del_status_line
+ result
+ end
+ end
+
+ module Skipping # :nodoc: all
+ def failed(s)
+ super if !s or @options[:hide_skip]
+ end
+
+ private
+ def setup_options(opts, options)
+ super
+
+ opts.separator "skipping options:"
+
+ options[:hide_skip] = true
+
+ opts.on '-q', '--hide-skip', 'Hide skipped tests' do
+ options[:hide_skip] = true
+ end
+
+ opts.on '--show-skip', 'Show skipped tests' do
+ options[:hide_skip] = false
+ end
+ end
+
+ private
+ def _run_suites(suites, type)
+ result = super
+ report.reject!{|r| r.start_with? "Skipped:" } if @options[:hide_skip]
+ report.sort_by!{|r| r.start_with?("Skipped:") ? 0 : \
+ (r.start_with?("Failure:") ? 1 : 2) }
+ failed(nil)
+ result
+ end
+ end
+
+ module Statistics
+ def update_list(list, rec, max)
+ if i = list.empty? ? 0 : list.bsearch_index {|*a| yield(*a)}
+ list[i, 0] = [rec]
+ list[max..-1] = [] if list.size >= max
+ end
+ end
+
+ def record(suite, method, assertions, time, error)
+ if @options.values_at(:longest, :most_asserted).any?
+ @tops ||= {}
+ rec = [suite.name, method, assertions, time, error]
+ if max = @options[:longest]
+ update_list(@tops[:longest] ||= [], rec, max) {|_,_,_,t,_|t<time}
+ end
+ if max = @options[:most_asserted]
+ update_list(@tops[:most_asserted] ||= [], rec, max) {|_,_,a,_,_|a<assertions}
+ end
+ end
+ # (((@record ||= {})[suite] ||= {})[method]) = [assertions, time, error]
+ super
+ end
+
+ def run(*args)
+ result = super
+ if @tops ||= nil
+ @tops.each do |t, list|
+ if list
+ puts "#{t.to_s.tr('_', ' ')} tests:"
+ list.each {|suite, method, assertions, time, error|
+ printf "%5.2fsec(%d): %s#%s\n", time, assertions, suite, method
+ }
+ end
+ end
+ end
+ result
+ end
+
+ private
+ def setup_options(opts, options)
+ super
+ opts.separator "statistics options:"
+ opts.on '--longest=N', Integer, 'Show longest N tests' do |n|
+ options[:longest] = n
+ end
+ opts.on '--most-asserted=N', Integer, 'Show most asserted N tests' do |n|
+ options[:most_asserted] = n
+ end
+ end
+ end
+
+ module StatusLine # :nodoc: all
+ def terminal_width
+ unless @terminal_width ||= nil
+ begin
+ require 'io/console'
+ width = $stdout.winsize[1]
+ rescue LoadError, NoMethodError, Errno::ENOTTY, Errno::EBADF, Errno::EINVAL
+ width = ENV["COLUMNS"].to_i.nonzero? || 80
+ end
+ width -= 1 if /mswin|mingw/ =~ RUBY_PLATFORM
+ @terminal_width = width
+ end
+ @terminal_width
+ end
+
+ def del_status_line(flush = true)
+ @status_line_size ||= 0
+ if @options[:job_status] == :replace
+ $stdout.print "\r"+" "*@status_line_size+"\r"
+ else
+ $stdout.puts if @status_line_size > 0
+ end
+ $stdout.flush if flush
+ @status_line_size = 0
+ end
+
+ def add_status(line)
+ @status_line_size ||= 0
+ if @options[:job_status] == :replace
+ line = line[0...(terminal_width-@status_line_size)]
+ end
+ print line
+ @status_line_size += line.size
+ end
+
+ def jobs_status(worker)
+ return if !@options[:job_status] or @options[:verbose]
+ if @options[:job_status] == :replace
+ status_line = @workers.map(&:to_s).join(" ")
+ else
+ status_line = worker.to_s
+ end
+ update_status(status_line) or (puts; nil)
+ end
+
+ def del_jobs_status
+ return unless @options[:job_status] == :replace && @status_line_size.nonzero?
+ del_status_line
+ end
+
+ def output
+ (@output ||= nil) || super
+ end
+
+ def _prepare_run(suites, type)
+ options[:job_status] ||= :replace if @tty && !@verbose
+ case options[:color]
+ when :always
+ color = true
+ when :auto, nil
+ color = (@tty || @options[:job_status] == :replace) && /dumb/ !~ ENV["TERM"]
+ else
+ color = false
+ end
+ if color
+ # dircolors-like style
+ colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
+ begin
+ File.read(File.join(__dir__, "../../colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
+ colors[n] ||= c
+ end
+ rescue
+ end
+ @passed_color = "\e[;#{colors["pass"] || "32"}m"
+ @failed_color = "\e[;#{colors["fail"] || "31"}m"
+ @skipped_color = "\e[;#{colors["skip"] || "33"}m"
+ @reset_color = "\e[m"
+ else
+ @passed_color = @failed_color = @skipped_color = @reset_color = ""
+ end
+ if color or @options[:job_status] == :replace
+ @verbose = !options[:parallel]
+ end
+ @output = Output.new(self) unless @options[:testing]
+ filter = options[:filter]
+ type = "#{type}_methods"
+ total = if filter
+ suites.inject(0) {|n, suite| n + suite.send(type).grep(filter).size}
+ else
+ suites.inject(0) {|n, suite| n + suite.send(type).size}
+ end
+ @test_count = 0
+ @total_tests = total.to_s(10)
+ end
+
+ def new_test(s)
+ @test_count += 1
+ update_status(s)
+ end
+
+ def update_status(s)
+ count = @test_count.to_s(10).rjust(@total_tests.size)
+ del_status_line(false)
+ print(@passed_color)
+ add_status("[#{count}/#{@total_tests}]")
+ print(@reset_color)
+ add_status(" #{s}")
+ $stdout.print "\r" if @options[:job_status] == :replace and !@verbose
+ $stdout.flush
+ end
+
+ def _print(s); $stdout.print(s); end
+ def succeed; del_status_line; end
+
+ def failed(s)
+ return if s and @options[:job_status] != :replace
+ sep = "\n"
+ @report_count ||= 0
+ report.each do |msg|
+ if msg.start_with? "Skipped:"
+ if @options[:hide_skip]
+ del_status_line
+ next
+ end
+ color = @skipped_color
+ else
+ color = @failed_color
+ end
+ msg = msg.split(/$/, 2)
+ $stdout.printf("%s%s%3d) %s%s%s\n",
+ sep, color, @report_count += 1,
+ msg[0], @reset_color, msg[1])
+ sep = nil
+ end
+ report.clear
+ end
+
+ def initialize
+ super
+ @tty = $stdout.tty?
+ end
+
+ def run(*args)
+ result = super
+ puts "\nruby -v: #{RUBY_DESCRIPTION}"
+ result
+ end
+
+ private
+ def setup_options(opts, options)
+ super
+
+ opts.separator "status line options:"
+
+ options[:job_status] = nil
+
+ opts.on '--jobs-status [TYPE]', [:normal, :replace, :none],
+ "Show status of jobs every file; Disabled when --jobs isn't specified." do |type|
+ options[:job_status] = (type || :normal if type != :none)
+ end
+
+ opts.on '--color[=WHEN]',
+ [:always, :never, :auto],
+ "colorize the output. WHEN defaults to 'always'", "or can be 'never' or 'auto'." do |c|
+ options[:color] = c || :always
+ end
+
+ opts.on '--tty[=WHEN]',
+ [:yes, :no],
+ "force to output tty control. WHEN defaults to 'yes'", "or can be 'no'." do |c|
+ @tty = c != :no
+ end
+ end
+
+ class Output < Struct.new(:runner) # :nodoc: all
+ def puts(*a) $stdout.puts(*a) unless a.empty? end
+ def respond_to_missing?(*a) $stdout.respond_to?(*a) end
+ def method_missing(*a, &b) $stdout.__send__(*a, &b) end
+
+ def print(s)
+ case s
+ when /\A(.*\#.*) = \z/
+ runner.new_test($1)
+ when /\A(.* s) = \z/
+ runner.add_status(" = #$1")
+ when /\A\.+\z/
+ runner.succeed
+ when /\A[EFS]\z/
+ runner.failed(s)
+ else
+ $stdout.print(s)
+ end
+ end
+ end
+ end
+
+ module LoadPathOption # :nodoc: all
+ def non_options(files, options)
+ begin
+ require "rbconfig"
+ rescue LoadError
+ warn "#{caller(1, 1)[0]}: warning: Parallel running disabled because can't get path to ruby; run specify with --ruby argument"
+ options[:parallel] = nil
+ else
+ options[:ruby] ||= [RbConfig.ruby]
+ end
+
+ super
+ end
+
+ def setup_options(parser, options)
+ super
+ parser.separator "load path options:"
+ parser.on '-Idirectory', 'Add library load path' do |dirs|
+ dirs.split(':').each { |d| $LOAD_PATH.unshift d }
+ end
+ end
+ end
+
+ module GlobOption # :nodoc: all
+ @@testfile_prefix = "test"
+ @@testfile_suffix = "test"
+
+ def setup_options(parser, options)
+ super
+ parser.separator "globbing options:"
+ parser.on '-b', '--basedir=DIR', 'Base directory of test suites.' do |dir|
+ options[:base_directory] = dir
+ end
+ parser.on '-x', '--exclude REGEXP', 'Exclude test files on pattern.' do |pattern|
+ (options[:reject] ||= []) << pattern
+ end
+ end
+
+ def non_options(files, options)
+ paths = [options.delete(:base_directory), nil].uniq
+ if reject = options.delete(:reject)
+ reject_pat = Regexp.union(reject.map {|r| %r"#{r}"})
+ end
+ files.map! {|f|
+ f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix|
+ if prefix
+ path = f.empty? ? prefix : "#{prefix}/#{f}"
+ else
+ next if f.empty?
+ path = f
+ end
+ if !(match = (Dir["#{path}/**/#{@@testfile_prefix}_*.rb"] + Dir["#{path}/**/*_#{@@testfile_suffix}.rb"]).uniq).empty?
+ if reject
+ match.reject! {|n|
+ n[(prefix.length+1)..-1] if prefix
+ reject_pat =~ n
+ }
+ end
+ break match
+ elsif !reject or reject_pat !~ f and File.exist? path
+ break path
+ end
+ end or
+ raise ArgumentError, "file not found: #{f}"
+ }
+ files.flatten!
+ super(files, options)
+ end
+ end
+
+ module GCStressOption # :nodoc: all
+ def setup_options(parser, options)
+ super
+ parser.separator "GC options:"
+ parser.on '--[no-]gc-stress', 'Set GC.stress as true' do |flag|
+ options[:gc_stress] = flag
+ end
+ end
+
+ def non_options(files, options)
+ if options.delete(:gc_stress)
+ MiniTest::Unit::TestCase.class_eval do
+ oldrun = instance_method(:run)
+ define_method(:run) do |runner|
+ begin
+ gc_stress, GC.stress = GC.stress, true
+ oldrun.bind(self).call(runner)
+ ensure
+ GC.stress = gc_stress
+ end
+ end
+ end
+ end
+ super
+ end
+ end
+
+ module RequireFiles # :nodoc: all
+ def non_options(files, options)
+ return false if !super
+ errors = {}
+ result = false
+ files.each {|f|
+ d = File.dirname(path = File.realpath(f))
+ unless $:.include? d
+ $: << d
+ end
+ begin
+ require path unless options[:parallel]
+ result = true
+ rescue LoadError
+ next if errors[$!.message]
+ errors[$!.message] = true
+ puts "#{f}: #{$!}"
+ end
+ }
+ result
+ end
+ end
+
+ module RepeatOption # :nodoc: all
+ def setup_options(parser, options)
+ super
+ options[:repeat_count] = nil
+ parser.separator "repeat options:"
+ parser.on '--repeat-count=NUM', "Number of times to repeat", Integer do |n|
+ options[:repeat_count] = n
+ end
+ end
+
+ def _run_anything(type)
+ @repeat_count = @options[:repeat_count]
+ super
+ end
+ end
+
+ module ExcludesOption # :nodoc: all
+ class ExcludedMethods < Struct.new(:excludes)
+ def exclude(name, reason)
+ excludes[name] = reason
+ end
+
+ def exclude_from(klass)
+ excludes = self.excludes
+ pattern = excludes.keys.grep(Regexp).tap {|k|
+ break (Regexp.new(k.join('|')) unless k.empty?)
+ }
+ klass.class_eval do
+ public_instance_methods(false).each do |method|
+ if excludes[method] or (pattern and pattern =~ method)
+ remove_method(method)
+ end
+ end
+ public_instance_methods(true).each do |method|
+ if excludes[method] or (pattern and pattern =~ method)
+ undef_method(method)
+ end
+ end
+ end
+ end
+
+ def self.load(dirs, name)
+ return unless dirs and name
+ instance = nil
+ dirs.each do |dir|
+ path = File.join(dir, name.gsub(/::/, '/') + ".rb")
+ begin
+ src = File.read(path)
+ rescue Errno::ENOENT
+ nil
+ else
+ instance ||= new({})
+ instance.instance_eval(src, path)
+ end
+ end
+ instance
+ end
+ end
+
+ def setup_options(parser, options)
+ super
+ if excludes = ENV["EXCLUDES"]
+ excludes = excludes.split(File::PATH_SEPARATOR)
+ end
+ options[:excludes] = excludes || []
+ parser.separator "excludes options:"
+ parser.on '-X', '--excludes-dir DIRECTORY', "Directory name of exclude files" do |d|
+ options[:excludes].concat d.split(File::PATH_SEPARATOR)
+ end
+ end
+
+ def _run_suite(suite, type)
+ if ex = ExcludedMethods.load(@options[:excludes], suite.name)
+ ex.exclude_from(suite)
+ end
+ super
+ end
+ end
+
+ module SubprocessOption
+ def setup_options(parser, options)
+ super
+ parser.separator "subprocess options:"
+ parser.on '--subprocess-timeout-scale NUM', "Scale subprocess timeout", Float do |scale|
+ raise OptionParser::InvalidArgument, "timeout scale must be positive" unless scale > 0
+ options[:timeout_scale] = scale
+ end
+ if scale = options[:timeout_scale] or
+ (scale = ENV["RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE"] and (scale = scale.to_f) > 0)
+ EnvUtil.subprocess_timeout_scale = scale
+ end
+ end
+ end
+
+ class Runner < MiniTest::Unit # :nodoc: all
+ include Test::Unit::Options
+ include Test::Unit::StatusLine
+ include Test::Unit::Parallel
+ include Test::Unit::Statistics
+ include Test::Unit::Skipping
+ include Test::Unit::GlobOption
+ include Test::Unit::RepeatOption
+ include Test::Unit::LoadPathOption
+ include Test::Unit::GCStressOption
+ include Test::Unit::ExcludesOption
+ include Test::Unit::SubprocessOption
+ include Test::Unit::RunCount
+
+ class << self; undef autorun; end
+
+ @@stop_auto_run = false
+ def self.autorun
+ at_exit {
+ Test::Unit::RunCount.run_once {
+ exit(Test::Unit::Runner.new.run(ARGV) || true)
+ } unless @@stop_auto_run
+ } unless @@installed_at_exit
+ @@installed_at_exit = true
+ end
+
+ alias mini_run_suite _run_suite
+
+ # Overriding of MiniTest::Unit#puke
+ def puke klass, meth, e
+ # TODO:
+ # this overriding is for minitest feature that skip messages are
+ # hidden when not verbose (-v), note this is temporally.
+ n = report.size
+ rep = super
+ if MiniTest::Skip === e and /no message given\z/ =~ e.message
+ report.slice!(n..-1)
+ rep = "."
+ end
+ rep
+ end
+ end
+
+ class AutoRunner # :nodoc: all
+ class Runner < Test::Unit::Runner
+ include Test::Unit::RequireFiles
+ end
+
+ attr_accessor :to_run, :options
+
+ def initialize(force_standalone = false, default_dir = nil, argv = ARGV)
+ @force_standalone = force_standalone
+ @runner = Runner.new do |files, options|
+ options[:base_directory] ||= default_dir
+ files << default_dir if files.empty? and default_dir
+ @to_run = files
+ yield self if block_given?
+ files
+ end
+ Runner.runner = @runner
+ @options = @runner.option_parser
+ if @force_standalone
+ @options.banner.sub!(/\[options\]/, '\& tests...')
+ end
+ @argv = argv
+ end
+
+ def process_args(*args)
+ @runner.process_args(*args)
+ !@to_run.empty?
+ end
+
+ def run
+ if @force_standalone and not process_args(@argv)
+ abort @options.banner
+ end
+ @runner.run(@argv) || true
+ end
+
+ def self.run(*args)
+ new(*args).run
+ end
+ end
+
+ class ProxyError < StandardError # :nodoc: all
+ def initialize(ex)
+ @message = ex.message
+ @backtrace = ex.backtrace
+ end
+
+ attr_accessor :message, :backtrace
+ end
+ end
+end
+
+module MiniTest # :nodoc: all
+ class Unit
+ end
+end
+
+class MiniTest::Unit::TestCase # :nodoc: all
+ test_order = self.test_order
+ class << self
+ attr_writer :test_order
+ undef test_order
+ end
+ def self.test_order
+ defined?(@test_order) ? @test_order : superclass.test_order
+ end
+ self.test_order = test_order
+ undef run_test
+ RUN_TEST_TRACE = "#{__FILE__}:#{__LINE__+3}:in `run_test'".freeze
+ def run_test(name)
+ progname, $0 = $0, "#{$0}: #{self.class}##{name}"
+ self.__send__(name)
+ ensure
+ $@.delete(RUN_TEST_TRACE) if $@
+ $0 = progname
+ end
+end
+
+Test::Unit::Runner.autorun
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
new file mode 100644
index 0000000000..eed5aca6a4
--- /dev/null
+++ b/test/lib/test/unit/assertions.rb
@@ -0,0 +1,943 @@
+# frozen_string_literal: true
+require 'minitest/unit'
+require 'pp'
+
+module Test
+ module Unit
+ module Assertions
+ include MiniTest::Assertions
+
+ def mu_pp(obj) #:nodoc:
+ obj.pretty_inspect.chomp
+ end
+
+ MINI_DIR = File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), "minitest") #:nodoc:
+
+ # :call-seq:
+ # assert(test, [failure_message])
+ #
+ #Tests if +test+ is true.
+ #
+ #+msg+ may be a String or a Proc. If +msg+ is a String, it will be used
+ #as the failure message. Otherwise, the result of calling +msg+ will be
+ #used as the message if the assertion fails.
+ #
+ #If no +msg+ is given, a default message will be used.
+ #
+ # assert(false, "This was expected to be true")
+ def assert(test, *msgs)
+ case msg = msgs.first
+ when String, Proc
+ when nil
+ msgs.shift
+ else
+ bt = caller.reject { |s| s.start_with?(MINI_DIR) }
+ raise ArgumentError, "assertion message must be String or Proc, but #{msg.class} was given.", bt
+ end unless msgs.empty?
+ super
+ end
+
+ # :call-seq:
+ # assert_block( failure_message = nil )
+ #
+ #Tests the result of the given block. If the block does not return true,
+ #the assertion will fail. The optional +failure_message+ argument is the same as in
+ #Assertions#assert.
+ #
+ # assert_block do
+ # [1, 2, 3].any? { |num| num < 1 }
+ # end
+ def assert_block(*msgs)
+ assert yield, *msgs
+ end
+
+ # :call-seq:
+ # assert_raise( *args, &block )
+ #
+ #Tests if the given block raises an exception. Acceptable exception
+ #types may be given as optional arguments. If the last argument is a
+ #String, it will be used as the error message.
+ #
+ # assert_raise do #Fails, no Exceptions are raised
+ # end
+ #
+ # assert_raise NameError do
+ # puts x #Raises NameError, so assertion succeeds
+ # end
+ def assert_raise(*exp, &b)
+ case exp.last
+ when String, Proc
+ msg = exp.pop
+ end
+
+ begin
+ yield
+ rescue MiniTest::Skip => e
+ return e if exp.include? MiniTest::Skip
+ raise e
+ rescue Exception => e
+ expected = exp.any? { |ex|
+ if ex.instance_of? Module then
+ e.kind_of? ex
+ else
+ e.instance_of? ex
+ end
+ }
+
+ assert expected, proc {
+ exception_details(e, message(msg) {"#{mu_pp(exp)} exception expected, not"}.call)
+ }
+
+ return e
+ ensure
+ unless e
+ exp = exp.first if exp.size == 1
+
+ flunk(message(msg) {"#{mu_pp(exp)} expected but nothing was raised"})
+ end
+ end
+ end
+
+ def assert_raises(*exp, &b)
+ raise NoMethodError, "use assert_raise", caller
+ end
+
+ # :call-seq:
+ # assert_raise_with_message(exception, expected, msg = nil, &block)
+ #
+ #Tests if the given block raises an exception with the expected
+ #message.
+ #
+ # assert_raise_with_message(RuntimeError, "foo") do
+ # nil #Fails, no Exceptions are raised
+ # end
+ #
+ # assert_raise_with_message(RuntimeError, "foo") do
+ # raise ArgumentError, "foo" #Fails, different Exception is raised
+ # end
+ #
+ # assert_raise_with_message(RuntimeError, "foo") do
+ # raise "bar" #Fails, RuntimeError is raised but the message differs
+ # end
+ #
+ # assert_raise_with_message(RuntimeError, "foo") do
+ # raise "foo" #Raises RuntimeError with the message, so assertion succeeds
+ # end
+ def assert_raise_with_message(exception, expected, msg = nil, &block)
+ case expected
+ when String
+ assert = :assert_equal
+ when Regexp
+ assert = :assert_match
+ else
+ raise TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}"
+ end
+
+ ex = m = nil
+ EnvUtil.with_default_internal(expected.encoding) do
+ ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) do
+ yield
+ end
+ m = ex.message
+ end
+ msg = message(msg, "") {"Expected Exception(#{exception}) was raised, but the message doesn't match"}
+
+ if assert == :assert_equal
+ assert_equal(expected, m, msg)
+ else
+ msg = message(msg) { "Expected #{mu_pp expected} to match #{mu_pp m}" }
+ assert expected =~ m, msg
+ block.binding.eval("proc{|_|$~=_}").call($~)
+ end
+ ex
+ end
+
+ # :call-seq:
+ # assert_nothing_raised( *args, &block )
+ #
+ #If any exceptions are given as arguments, the assertion will
+ #fail if one of those exceptions are raised. Otherwise, the test fails
+ #if any exceptions are raised.
+ #
+ #The final argument may be a failure message.
+ #
+ # assert_nothing_raised RuntimeError do
+ # raise Exception #Assertion passes, Exception is not a RuntimeError
+ # end
+ #
+ # assert_nothing_raised do
+ # raise Exception #Assertion fails
+ # end
+ def assert_nothing_raised(*args)
+ self._assertions += 1
+ if Module === args.last
+ msg = nil
+ else
+ msg = args.pop
+ end
+ begin
+ line = __LINE__; yield
+ rescue MiniTest::Skip
+ raise
+ rescue Exception => e
+ bt = e.backtrace
+ as = e.instance_of?(MiniTest::Assertion)
+ if as
+ ans = /\A#{Regexp.quote(__FILE__)}:#{line}:in /o
+ bt.reject! {|ln| ans =~ ln}
+ end
+ if ((args.empty? && !as) ||
+ args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
+ msg = message(msg) { "Exception raised:\n<#{mu_pp(e)}>" }
+ raise MiniTest::Assertion, msg.call, bt
+ else
+ raise
+ end
+ end
+ end
+
+ # :call-seq:
+ # assert_nothing_thrown( failure_message = nil, &block )
+ #
+ #Fails if the given block uses a call to Kernel#throw, and
+ #returns the result of the block otherwise.
+ #
+ #An optional failure message may be provided as the final argument.
+ #
+ # assert_nothing_thrown "Something was thrown!" do
+ # throw :problem?
+ # end
+ def assert_nothing_thrown(msg=nil)
+ begin
+ ret = yield
+ rescue ArgumentError => error
+ raise error if /\Auncaught throw (.+)\z/m !~ error.message
+ msg = message(msg) { "<#{$1}> was thrown when nothing was expected" }
+ flunk(msg)
+ end
+ assert(true, "Expected nothing to be thrown")
+ ret
+ end
+
+ # :call-seq:
+ # assert_throw( tag, failure_message = nil, &block )
+ #
+ #Fails unless the given block throws +tag+, returns the caught
+ #value otherwise.
+ #
+ #An optional failure message may be provided as the final argument.
+ #
+ # tag = Object.new
+ # assert_throw(tag, "#{tag} was not thrown!") do
+ # throw tag
+ # end
+ def assert_throw(tag, msg = nil)
+ ret = catch(tag) do
+ begin
+ yield(tag)
+ rescue UncaughtThrowError => e
+ thrown = e.tag
+ end
+ msg = message(msg) {
+ "Expected #{mu_pp(tag)} to have been thrown"\
+ "#{%Q[, not #{thrown}] if thrown}"
+ }
+ assert(false, msg)
+ end
+ assert(true)
+ ret
+ end
+
+ # :call-seq:
+ # assert_equal( expected, actual, failure_message = nil )
+ #
+ #Tests if +expected+ is equal to +actual+.
+ #
+ #An optional failure message may be provided as the final argument.
+ def assert_equal(exp, act, msg = nil)
+ msg = message(msg) {
+ exp_str = mu_pp(exp)
+ act_str = mu_pp(act)
+ exp_comment = ''
+ act_comment = ''
+ if exp_str == act_str
+ if (exp.is_a?(String) && act.is_a?(String)) ||
+ (exp.is_a?(Regexp) && act.is_a?(Regexp))
+ exp_comment = " (#{exp.encoding})"
+ act_comment = " (#{act.encoding})"
+ elsif exp.is_a?(Float) && act.is_a?(Float)
+ exp_str = "%\#.#{Float::DIG+2}g" % exp
+ act_str = "%\#.#{Float::DIG+2}g" % act
+ elsif exp.is_a?(Time) && act.is_a?(Time)
+ if exp.subsec * 1000_000_000 == exp.nsec
+ exp_comment = " (#{exp.nsec}[ns])"
+ else
+ exp_comment = " (subsec=#{exp.subsec})"
+ end
+ if act.subsec * 1000_000_000 == act.nsec
+ act_comment = " (#{act.nsec}[ns])"
+ else
+ act_comment = " (subsec=#{act.subsec})"
+ end
+ elsif exp.class != act.class
+ # a subclass of Range, for example.
+ exp_comment = " (#{exp.class})"
+ act_comment = " (#{act.class})"
+ end
+ elsif !Encoding.compatible?(exp_str, act_str)
+ if exp.is_a?(String) && act.is_a?(String)
+ exp_str = exp.dump
+ act_str = act.dump
+ exp_comment = " (#{exp.encoding})"
+ act_comment = " (#{act.encoding})"
+ else
+ exp_str = exp_str.dump
+ act_str = act_str.dump
+ end
+ end
+ "<#{exp_str}>#{exp_comment} expected but was\n<#{act_str}>#{act_comment}"
+ }
+ assert(exp == act, msg)
+ end
+
+ # :call-seq:
+ # assert_not_nil( expression, failure_message = nil )
+ #
+ #Tests if +expression+ is not nil.
+ #
+ #An optional failure message may be provided as the final argument.
+ def assert_not_nil(exp, msg=nil)
+ msg = message(msg) { "<#{mu_pp(exp)}> expected to not be nil" }
+ assert(!exp.nil?, msg)
+ end
+
+ # :call-seq:
+ # assert_not_equal( expected, actual, failure_message = nil )
+ #
+ #Tests if +expected+ is not equal to +actual+.
+ #
+ #An optional failure message may be provided as the final argument.
+ def assert_not_equal(exp, act, msg=nil)
+ msg = message(msg) { "<#{mu_pp(exp)}> expected to be != to\n<#{mu_pp(act)}>" }
+ assert(exp != act, msg)
+ end
+
+ # :call-seq:
+ # assert_no_match( regexp, string, failure_message = nil )
+ #
+ #Tests if the given Regexp does not match a given String.
+ #
+ #An optional failure message may be provided as the final argument.
+ def assert_no_match(regexp, string, msg=nil)
+ assert_instance_of(Regexp, regexp, "The first argument to assert_no_match should be a Regexp.")
+ self._assertions -= 1
+ msg = message(msg) { "<#{mu_pp(regexp)}> expected to not match\n<#{mu_pp(string)}>" }
+ assert(regexp !~ string, msg)
+ end
+
+ # :call-seq:
+ # assert_not_same( expected, actual, failure_message = nil )
+ #
+ #Tests if +expected+ is not the same object as +actual+.
+ #This test uses Object#equal? to test equality.
+ #
+ #An optional failure message may be provided as the final argument.
+ #
+ # assert_not_same("x", "x") #Succeeds
+ def assert_not_same(expected, actual, message="")
+ msg = message(msg) { build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__) }
+<?>
+with id <?> expected to not be equal\\? to
+<?>
+with id <?>.
+EOT
+ assert(!actual.equal?(expected), msg)
+ end
+
+ # :call-seq:
+ # assert_respond_to( object, method, failure_message = nil )
+ #
+ #Tests if the given Object responds to +method+.
+ #
+ #An optional failure message may be provided as the final argument.
+ #
+ # assert_respond_to("hello", :reverse) #Succeeds
+ # assert_respond_to("hello", :does_not_exist) #Fails
+ def assert_respond_to(obj, (meth, *priv), msg = nil)
+ unless priv.empty?
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}#{" privately" if priv[0]}"
+ }
+ return assert obj.respond_to?(meth, *priv), msg
+ end
+ #get rid of overcounting
+ if caller_locations(1, 1)[0].path.start_with?(MINI_DIR)
+ return if obj.respond_to?(meth)
+ end
+ super(obj, meth, msg)
+ end
+
+ # :call-seq:
+ # assert_not_respond_to( object, method, failure_message = nil )
+ #
+ #Tests if the given Object does not respond to +method+.
+ #
+ #An optional failure message may be provided as the final argument.
+ #
+ # assert_not_respond_to("hello", :reverse) #Fails
+ # assert_not_respond_to("hello", :does_not_exist) #Succeeds
+ def assert_not_respond_to(obj, (meth, *priv), msg = nil)
+ unless priv.empty?
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} (#{obj.class}) to not respond to ##{meth}#{" privately" if priv[0]}"
+ }
+ return assert !obj.respond_to?(meth, *priv), msg
+ end
+ #get rid of overcounting
+ if caller_locations(1, 1)[0].path.start_with?(MINI_DIR)
+ return unless obj.respond_to?(meth)
+ end
+ refute_respond_to(obj, meth, msg)
+ end
+
+ # :call-seq:
+ # assert_send( +send_array+, failure_message = nil )
+ #
+ # Passes if the method send returns a true value.
+ #
+ # +send_array+ is composed of:
+ # * A receiver
+ # * A method
+ # * Arguments to the method
+ #
+ # Example:
+ # assert_send(["Hello world", :include?, "Hello"]) # -> pass
+ # assert_send(["Hello world", :include?, "Goodbye"]) # -> fail
+ def assert_send send_ary, m = nil
+ recv, msg, *args = send_ary
+ m = message(m) {
+ if args.empty?
+ argsstr = ""
+ else
+ (argsstr = mu_pp(args)).sub!(/\A\[(.*)\]\z/m, '(\1)')
+ end
+ "Expected #{mu_pp(recv)}.#{msg}#{argsstr} to return true"
+ }
+ assert recv.__send__(msg, *args), m
+ end
+
+ # :call-seq:
+ # assert_not_send( +send_array+, failure_message = nil )
+ #
+ # Passes if the method send doesn't return a true value.
+ #
+ # +send_array+ is composed of:
+ # * A receiver
+ # * A method
+ # * Arguments to the method
+ #
+ # Example:
+ # assert_not_send([[1, 2], :member?, 1]) # -> fail
+ # assert_not_send([[1, 2], :member?, 4]) # -> pass
+ def assert_not_send send_ary, m = nil
+ recv, msg, *args = send_ary
+ m = message(m) {
+ if args.empty?
+ argsstr = ""
+ else
+ (argsstr = mu_pp(args)).sub!(/\A\[(.*)\]\z/m, '(\1)')
+ end
+ "Expected #{mu_pp(recv)}.#{msg}#{argsstr} to return false"
+ }
+ assert !recv.__send__(msg, *args), m
+ end
+
+ ms = instance_methods(true).map {|sym| sym.to_s }
+ ms.grep(/\Arefute_/) do |m|
+ mname = ('assert_not_'.dup << m.to_s[/.*?_(.*)/, 1])
+ alias_method(mname, m) unless ms.include? mname
+ end
+ alias assert_include assert_includes
+ alias assert_not_include assert_not_includes
+
+ def assert_all?(obj, m = nil, &blk)
+ failed = []
+ obj.each do |*a, &b|
+ unless blk.call(*a, &b)
+ failed << (a.size > 1 ? a : a[0])
+ end
+ end
+ assert(failed.empty?, message(m) {failed.pretty_inspect})
+ end
+
+ def assert_not_all?(obj, m = nil, &blk)
+ failed = []
+ obj.each do |*a, &b|
+ if blk.call(*a, &b)
+ failed << a.size > 1 ? a : a[0]
+ end
+ end
+ assert(failed.empty?, message(m) {failed.pretty_inspect})
+ end
+
+ # compatibility with test-unit
+ alias pend skip
+
+ if defined?(RubyVM::InstructionSequence)
+ def syntax_check(code, fname, line)
+ code = code.dup.force_encoding(Encoding::UTF_8)
+ RubyVM::InstructionSequence.compile(code, fname, fname, line)
+ :ok
+ end
+ else
+ def syntax_check(code, fname, line)
+ code = code.b
+ code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
+ "#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
+ }
+ code = code.force_encoding(Encoding::UTF_8)
+ catch {|tag| eval(code, binding, fname, line - 1)}
+ end
+ end
+
+ def prepare_syntax_check(code, fname = caller_locations(2, 1)[0], mesg = fname.to_s, verbose: nil)
+ verbose, $VERBOSE = $VERBOSE, verbose
+ case
+ when Array === fname
+ fname, line = *fname
+ when defined?(fname.path) && defined?(fname.lineno)
+ fname, line = fname.path, fname.lineno
+ else
+ line = 1
+ end
+ yield(code, fname, line, mesg)
+ ensure
+ $VERBOSE = verbose
+ end
+
+ def assert_valid_syntax(code, *args)
+ prepare_syntax_check(code, *args) do |src, fname, line, mesg|
+ yield if defined?(yield)
+ assert_nothing_raised(SyntaxError, mesg) do
+ assert_equal(:ok, syntax_check(src, fname, line), mesg)
+ end
+ end
+ end
+
+ def assert_syntax_error(code, error, *args)
+ prepare_syntax_check(code, *args) do |src, fname, line, mesg|
+ yield if defined?(yield)
+ e = assert_raise(SyntaxError, mesg) do
+ syntax_check(src, fname, line)
+ end
+ assert_match(error, e.message, mesg)
+ e
+ end
+ end
+
+ def assert_normal_exit(testsrc, message = '', child_env: nil, **opt)
+ assert_valid_syntax(testsrc, caller_locations(1, 1)[0])
+ if child_env
+ child_env = [child_env]
+ else
+ child_env = []
+ end
+ out, _, status = EnvUtil.invoke_ruby(child_env + %W'-W0', testsrc, true, :merge_to_stdout, **opt)
+ assert !status.signaled?, FailDesc[status, message, out]
+ end
+
+ FailDesc = proc do |status, message = "", out = ""|
+ pid = status.pid
+ now = Time.now
+ faildesc = proc do
+ if signo = status.termsig
+ signame = Signal.signame(signo)
+ sigdesc = "signal #{signo}"
+ end
+ log = EnvUtil.diagnostic_reports(signame, pid, now)
+ if signame
+ sigdesc = "SIG#{signame} (#{sigdesc})"
+ end
+ if status.coredump?
+ sigdesc = "#{sigdesc} (core dumped)"
+ end
+ full_message = ''.dup
+ message = message.call if Proc === message
+ if message and !message.empty?
+ full_message << message << "\n"
+ end
+ full_message << "pid #{pid}"
+ full_message << " exit #{status.exitstatus}" if status.exited?
+ full_message << " killed by #{sigdesc}" if sigdesc
+ if out and !out.empty?
+ full_message << "\n" << out.b.gsub(/^/, '| ')
+ full_message.sub!(/(?<!\n)\z/, "\n")
+ end
+ if log
+ full_message << "Diagnostic reports:\n" << log.b.gsub(/^/, '| ')
+ end
+ full_message
+ end
+ faildesc
+ end
+
+ def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil,
+ success: nil, **opt)
+ stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, true, true, **opt)
+ if signo = status.termsig
+ EnvUtil.diagnostic_reports(Signal.signame(signo), status.pid, Time.now)
+ end
+ if block_given?
+ raise "test_stdout ignored, use block only or without block" if test_stdout != []
+ raise "test_stderr ignored, use block only or without block" if test_stderr != []
+ yield(stdout.lines.map {|l| l.chomp }, stderr.lines.map {|l| l.chomp }, status)
+ else
+ all_assertions(message) do |a|
+ [["stdout", test_stdout, stdout], ["stderr", test_stderr, stderr]].each do |key, exp, act|
+ a.for(key) do
+ if exp.is_a?(Regexp)
+ assert_match(exp, act)
+ elsif exp.all? {|e| String === e}
+ assert_equal(exp, act.lines.map {|l| l.chomp })
+ else
+ assert_pattern_list(exp, act)
+ end
+ end
+ end
+ unless success.nil?
+ a.for("success?") do
+ if success
+ assert_predicate(status, :success?)
+ else
+ assert_not_predicate(status, :success?)
+ end
+ end
+ end
+ end
+ status
+ end
+ end
+
+ def assert_ruby_status(args, test_stdin="", message=nil, **opt)
+ out, _, status = EnvUtil.invoke_ruby(args, test_stdin, true, :merge_to_stdout, **opt)
+ desc = FailDesc[status, message, out]
+ assert(!status.signaled?, desc)
+ message ||= "ruby exit status is not success:"
+ assert(status.success?, desc)
+ end
+
+ ABORT_SIGNALS = Signal.list.values_at(*%w"ILL ABRT BUS SEGV TERM")
+
+ def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **opt)
+ unless file and line
+ loc, = caller_locations(1,1)
+ file ||= loc.path
+ line ||= loc.lineno
+ end
+ src = <<eom
+# -*- coding: #{line += __LINE__; src.encoding}; -*-
+ require #{__dir__.dump};include Test::Unit::Assertions
+ END {
+ puts [Marshal.dump($!)].pack('m'), "assertions=\#{self._assertions}"
+ }
+#{line -= __LINE__; src}
+ class Test::Unit::Runner
+ @@stop_auto_run = true
+ end
+eom
+ args = args.dup
+ args.insert((Hash === args.first ? 1 : 0), "-w", "--disable=gems", *$:.map {|l| "-I#{l}"})
+ stdout, stderr, status = EnvUtil.invoke_ruby(args, src, true, true, **opt)
+ abort = status.coredump? || (status.signaled? && ABORT_SIGNALS.include?(status.termsig))
+ assert(!abort, FailDesc[status, nil, stderr])
+ self._assertions += stdout[/^assertions=(\d+)/, 1].to_i
+ begin
+ res = Marshal.load(stdout.unpack("m")[0])
+ rescue => marshal_error
+ ignore_stderr = nil
+ end
+ if res
+ if bt = res.backtrace
+ bt.each do |l|
+ l.sub!(/\A-:(\d+)/){"#{file}:#{line + $1.to_i}"}
+ end
+ bt.concat(caller)
+ else
+ res.set_backtrace(caller)
+ end
+ raise res unless SystemExit === res
+ end
+
+ # really is it succeed?
+ unless ignore_stderr
+ # the body of assert_separately must not output anything to detect error
+ assert(stderr.empty?, FailDesc[status, "assert_separately failed with error message", stderr])
+ end
+ assert(status.success?, FailDesc[status, "assert_separately failed", stderr])
+ raise marshal_error if marshal_error
+ end
+
+ def assert_warning(pat, msg = nil)
+ stderr = EnvUtil.with_default_internal(pat.encoding) {
+ EnvUtil.verbose_warning {
+ yield
+ }
+ }
+ msg = message(msg) {diff pat, stderr}
+ assert(pat === stderr, msg)
+ end
+
+ def assert_warn(*args)
+ assert_warning(*args) {$VERBOSE = false; yield}
+ end
+
+ def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
+ require_relative '../../memory_status'
+ raise MiniTest::Skip, "unsupported platform" unless defined?(Memory::Status)
+
+ token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
+ token_dump = token.dump
+ token_re = Regexp.quote(token)
+ envs = args.shift if Array === args and Hash === args.first
+ args = [
+ "--disable=gems",
+ "-r", File.expand_path("../../../memory_status", __FILE__),
+ *args,
+ "-v", "-",
+ ]
+ if defined? Memory::NO_MEMORY_LEAK_ENVS then
+ envs ||= {}
+ newenvs = envs.merge(Memory::NO_MEMORY_LEAK_ENVS) { |_, _, _| break }
+ envs = newenvs if newenvs
+ end
+ args.unshift(envs) if envs
+ cmd = [
+ 'END {STDERR.puts '"#{token_dump}"'"FINAL=#{Memory::Status.new}"}',
+ prepare,
+ 'STDERR.puts('"#{token_dump}"'"START=#{$initial_status = Memory::Status.new}")',
+ '$initial_size = $initial_status.size',
+ code,
+ 'GC.start',
+ ].join("\n")
+ _, err, status = EnvUtil.invoke_ruby(args, cmd, true, true, **opt)
+ before = err.sub!(/^#{token_re}START=(\{.*\})\n/, '') && Memory::Status.parse($1)
+ after = err.sub!(/^#{token_re}FINAL=(\{.*\})\n/, '') && Memory::Status.parse($1)
+ assert(status.success?, FailDesc[status, message, err])
+ ([:size, (rss && :rss)] & after.members).each do |n|
+ b = before[n]
+ a = after[n]
+ next unless a > 0 and b > 0
+ assert_operator(a.fdiv(b), :<, limit, message(message) {"#{n}: #{b} => #{a}"})
+ end
+ rescue LoadError
+ skip
+ end
+
+ def assert_cpu_usage_low(msg = nil, pct: 0.01)
+ require 'benchmark'
+
+ tms = Benchmark.measure(msg || '') { yield }
+ max = pct * tms.real
+ if tms.real < 0.1 # TIME_QUANTUM_USEC in thread_pthread.c
+ warn "test #{msg || 'assert_cpu_usage_low'} too short to be accurate"
+ end
+
+ # kernel resolution can limit the minimum time we can measure
+ # [ruby-core:81540]
+ min_hz = windows? ? 67 : 100
+ min_measurable = 1.0 / min_hz
+ min_measurable *= 1.10 # add a little (10%) to account for misc. overheads
+ if max < min_measurable
+ max = min_measurable
+ end
+
+ assert_operator tms.total, :<=, max, msg
+ end
+
+ def assert_is_minus_zero(f)
+ assert(1.0/f == -Float::INFINITY, "#{f} is not -0.0")
+ end
+
+ def assert_file
+ AssertFile
+ end
+
+ # pattern_list is an array which contains regexp and :*.
+ # :* means any sequence.
+ #
+ # pattern_list is anchored.
+ # Use [:*, regexp, :*] for non-anchored match.
+ def assert_pattern_list(pattern_list, actual, message=nil)
+ rest = actual
+ anchored = true
+ pattern_list.each_with_index {|pattern, i|
+ if pattern == :*
+ anchored = false
+ else
+ if anchored
+ match = /\A#{pattern}/.match(rest)
+ else
+ match = pattern.match(rest)
+ end
+ unless match
+ msg = message(msg) {
+ expect_msg = "Expected #{mu_pp pattern}\n"
+ if /\n[^\n]/ =~ rest
+ actual_mesg = +"to match\n"
+ rest.scan(/.*\n+/) {
+ actual_mesg << ' ' << $&.inspect << "+\n"
+ }
+ actual_mesg.sub!(/\+\n\z/, '')
+ else
+ actual_mesg = "to match " + mu_pp(rest)
+ end
+ actual_mesg << "\nafter #{i} patterns with #{actual.length - rest.length} characters"
+ expect_msg + actual_mesg
+ }
+ assert false, msg
+ end
+ rest = match.post_match
+ anchored = true
+ end
+ }
+ if anchored
+ assert_equal("", rest)
+ end
+ end
+
+ # threads should respond to shift method.
+ # Array can be used.
+ def assert_join_threads(threads, message = nil)
+ errs = []
+ values = []
+ while th = threads.shift
+ begin
+ values << th.value
+ rescue Exception
+ errs << [th, $!]
+ end
+ end
+ if !errs.empty?
+ msg = "exceptions on #{errs.length} threads:\n" +
+ errs.map {|t, err|
+ "#{t.inspect}:\n" +
+ err.backtrace.map.with_index {|line, i|
+ if i == 0
+ "#{line}: #{err.message} (#{err.class})"
+ else
+ "\tfrom #{line}"
+ end
+ }.join("\n")
+ }.join("\n---\n")
+ if message
+ msg = "#{message}\n#{msg}"
+ end
+ raise MiniTest::Assertion, msg
+ end
+ values
+ end
+
+ class << (AssertFile = Struct.new(:failure_message).new)
+ include Assertions
+ def assert_file_predicate(predicate, *args)
+ if /\Anot_/ =~ predicate
+ predicate = $'
+ neg = " not"
+ end
+ result = File.__send__(predicate, *args)
+ result = !result if neg
+ mesg = "Expected file ".dup << args.shift.inspect
+ mesg << "#{neg} to be #{predicate}"
+ mesg << mu_pp(args).sub(/\A\[(.*)\]\z/m, '(\1)') unless args.empty?
+ mesg << " #{failure_message}" if failure_message
+ assert(result, mesg)
+ end
+ alias method_missing assert_file_predicate
+
+ def for(message)
+ clone.tap {|a| a.failure_message = message}
+ end
+ end
+
+ class AllFailures
+ attr_reader :failures
+
+ def initialize
+ @count = 0
+ @failures = {}
+ end
+
+ def for(key)
+ @count += 1
+ yield
+ rescue Exception => e
+ @failures[key] = [@count, e]
+ end
+
+ def foreach(*keys)
+ keys.each do |key|
+ @count += 1
+ begin
+ yield key
+ rescue Exception => e
+ @failures[key] = [@count, e]
+ end
+ end
+ end
+
+ def message
+ i = 0
+ total = @count.to_s
+ fmt = "%#{total.size}d"
+ @failures.map {|k, (n, v)|
+ v = v.message
+ "\n#{i+=1}. [#{fmt%n}/#{total}] Assertion for #{k.inspect}\n#{v.b.gsub(/^/, ' | ').force_encoding(v.encoding)}"
+ }.join("\n")
+ end
+
+ def pass?
+ @failures.empty?
+ end
+ end
+
+ def assert_all_assertions(msg = nil)
+ all = AllFailures.new
+ yield all
+ ensure
+ assert(all.pass?, message(msg) {all.message.chomp(".")})
+ end
+ alias all_assertions assert_all_assertions
+
+ def assert_all_assertions_foreach(msg = nil, *keys, &block)
+ all = AllFailures.new
+ all.foreach(*keys, &block)
+ ensure
+ assert(all.pass?, message(msg) {all.message.chomp(".")})
+ end
+ alias all_assertions_foreach assert_all_assertions_foreach
+
+ def build_message(head, template=nil, *arguments) #:nodoc:
+ template &&= template.chomp
+ template.gsub(/\G((?:[^\\]|\\.)*?)(\\)?\?/) { $1 + ($2 ? "?" : mu_pp(arguments.shift)) }
+ end
+
+ def message(msg = nil, *args, &default) # :nodoc:
+ if Proc === msg
+ super(nil, *args) do
+ ary = [msg.call, (default.call if default)].compact.reject(&:empty?)
+ if 1 < ary.length
+ ary[0...-1] = ary[0...-1].map {|str| str.sub(/(?<!\.)\z/, '.') }
+ end
+ begin
+ ary.join("\n")
+ rescue Encoding::CompatibilityError
+ ary.map(&:b).join("\n")
+ end
+ end
+ else
+ super
+ end
+ end
+ end
+ end
+end
diff --git a/test/lib/test/unit/parallel.rb b/test/lib/test/unit/parallel.rb
new file mode 100644
index 0000000000..d851326aca
--- /dev/null
+++ b/test/lib/test/unit/parallel.rb
@@ -0,0 +1,208 @@
+# frozen_string_literal: true
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../.."
+require 'test/unit'
+
+module Test
+ module Unit
+ class Worker < Runner # :nodoc:
+ class << self
+ undef autorun
+ end
+
+ alias orig_run_suite mini_run_suite
+ undef _run_suite
+ undef _run_suites
+ undef run
+
+ def increment_io(orig) # :nodoc:
+ *rest, io = 32.times.inject([orig.dup]){|ios, | ios << ios.last.dup }
+ rest.each(&:close)
+ io
+ end
+
+ def _run_suites(suites, type) # :nodoc:
+ suites.map do |suite|
+ _run_suite(suite, type)
+ end
+ end
+
+ def _run_suite(suite, type) # :nodoc:
+ @partial_report = []
+ orig_testout = MiniTest::Unit.output
+ i,o = IO.pipe
+
+ MiniTest::Unit.output = o
+ orig_stdin, orig_stdout = $stdin, $stdout
+
+ th = Thread.new do
+ begin
+ while buf = (self.verbose ? i.gets : i.readpartial(1024))
+ _report "p", buf
+ end
+ rescue IOError
+ rescue Errno::EPIPE
+ end
+ end
+
+ e, f, s = @errors, @failures, @skips
+
+ begin
+ result = orig_run_suite(suite, type)
+ rescue Interrupt
+ @need_exit = true
+ result = [nil,nil]
+ end
+
+ MiniTest::Unit.output = orig_testout
+ $stdin = orig_stdin
+ $stdout = orig_stdout
+
+ o.close
+ begin
+ th.join
+ rescue IOError
+ raise unless /stream closed|closed stream/ =~ $!.message
+ end
+ i.close
+
+ result << @partial_report
+ @partial_report = nil
+ result << [@errors-e,@failures-f,@skips-s]
+ result << ($: - @old_loadpath)
+ result << suite.name
+
+ begin
+ _report "done", Marshal.dump(result)
+ rescue Errno::EPIPE; end
+ return result
+ ensure
+ MiniTest::Unit.output = orig_stdout
+ $stdin = orig_stdin if orig_stdin
+ $stdout = orig_stdout if orig_stdout
+ o.close if o && !o.closed?
+ i.close if i && !i.closed?
+ end
+
+ def run(args = []) # :nodoc:
+ process_args args
+ @@stop_auto_run = true
+ @opts = @options.dup
+ @need_exit = false
+
+ @old_loadpath = []
+ begin
+ begin
+ @stdout = increment_io(STDOUT)
+ @stdin = increment_io(STDIN)
+ rescue
+ exit 2
+ end
+ exit 2 unless @stdout && @stdin
+
+ @stdout.sync = true
+ _report "ready!"
+ while buf = @stdin.gets
+ case buf.chomp
+ when /^loadpath (.+?)$/
+ @old_loadpath = $:.dup
+ $:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq!
+ when /^run (.+?) (.+?)$/
+ _report "okay"
+
+ @options = @opts.dup
+ suites = MiniTest::Unit::TestCase.test_suites
+
+ begin
+ require File.realpath($1)
+ rescue LoadError
+ _report "after", Marshal.dump([$1, ProxyError.new($!)])
+ _report "ready"
+ next
+ end
+ _run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym
+
+ if @need_exit
+ begin
+ _report "bye"
+ rescue Errno::EPIPE; end
+ exit
+ else
+ _report "ready"
+ end
+ when /^quit$/
+ begin
+ _report "bye"
+ rescue Errno::EPIPE; end
+ exit
+ end
+ end
+ rescue Errno::EPIPE
+ rescue Exception => e
+ begin
+ trace = e.backtrace || ['unknown method']
+ err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| t.prepend("\t") }
+
+ _report "bye", Marshal.dump(err.join("\n"))
+ rescue Errno::EPIPE;end
+ exit
+ ensure
+ @stdin.close if @stdin
+ @stdout.close if @stdout
+ end
+ end
+
+ def _report(res, *args) # :nodoc:
+ @stdout.write(args.empty? ? "#{res}\n" : "#{res} #{args.pack("m0")}\n")
+ end
+
+ def puke(klass, meth, e) # :nodoc:
+ if e.is_a?(MiniTest::Skip)
+ new_e = MiniTest::Skip.new(e.message)
+ new_e.set_backtrace(e.backtrace)
+ e = new_e
+ end
+ @partial_report << [klass.name, meth, e.is_a?(MiniTest::Assertion) ? e : ProxyError.new(e)]
+ super
+ end
+
+ def record(suite, method, assertions, time, error) # :nodoc:
+ case error
+ when nil
+ when MiniTest::Assertion, MiniTest::Skip
+ case error.cause
+ when nil, MiniTest::Assertion, MiniTest::Skip
+ else
+ bt = error.backtrace
+ error = error.class.new(error.message)
+ error.set_backtrace(bt)
+ end
+ else
+ error = ProxyError.new(error)
+ end
+ _report "record", Marshal.dump([suite.name, method, assertions, time, error])
+ super
+ end
+ end
+ end
+end
+
+if $0 == __FILE__
+ module Test
+ module Unit
+ class TestCase < MiniTest::Unit::TestCase # :nodoc: all
+ undef on_parallel_worker?
+ def on_parallel_worker?
+ true
+ end
+ end
+ end
+ end
+ require 'rubygems'
+ module Gem # :nodoc:
+ end
+ class Gem::TestCase < MiniTest::Unit::TestCase # :nodoc:
+ @@project_dir = File.expand_path('../../../../..', __FILE__)
+ end
+
+ Test::Unit::Worker.new.run(ARGV)
+end
diff --git a/tool/lib/test/unit/testcase.rb b/test/lib/test/unit/testcase.rb
index 58cfbcab99..58cfbcab99 100644
--- a/tool/lib/test/unit/testcase.rb
+++ b/test/lib/test/unit/testcase.rb
diff --git a/test/lib/tracepointchecker.rb b/test/lib/tracepointchecker.rb
new file mode 100644
index 0000000000..47822ecef5
--- /dev/null
+++ b/test/lib/tracepointchecker.rb
@@ -0,0 +1,126 @@
+# frozen_string_literal: true
+module TracePointChecker
+ STATE = {
+ count: 0,
+ running: false,
+ }
+
+ module ZombieTraceHunter
+ def tracepoint_capture_stat_get
+ TracePoint.stat.map{|k, (activated, deleted)|
+ deleted = 0 unless @tracepoint_captured_singlethread
+ [k, activated, deleted]
+ }
+ end
+
+ def before_setup
+ @tracepoint_captured_singlethread = (Thread.list.size == 1)
+ @tracepoint_captured_stat = tracepoint_capture_stat_get()
+ super
+ end
+
+ def after_teardown
+ super
+
+ # detect zombie traces.
+ assert_equal(
+ @tracepoint_captured_stat,
+ tracepoint_capture_stat_get(),
+ "The number of active/deleted trace events was changed"
+ )
+ # puts "TracePoint - deleted: #{deleted}" if deleted > 0
+
+ TracePointChecker.check if STATE[:running]
+ end
+ end
+
+ MAIN_THREAD = Thread.current
+ TRACES = []
+
+ def self.prefix event
+ case event
+ when :call, :return
+ :n
+ when :c_call, :c_return
+ :c
+ when :b_call, :b_return
+ :b
+ end
+ end
+
+ def self.clear_call_stack
+ Thread.current[:call_stack] = []
+ end
+
+ def self.call_stack
+ stack = Thread.current[:call_stack]
+ stack = clear_call_stack unless stack
+ stack
+ end
+
+ def self.verbose_out label, method
+ puts label => call_stack, :count => STATE[:count], :method => method
+ end
+
+ def self.method_label tp
+ "#{prefix(tp.event)}##{tp.method_id}"
+ end
+
+ def self.start verbose: false, stop_at_failure: false
+ call_events = %i(a_call)
+ return_events = %i(a_return)
+ clear_call_stack
+
+ STATE[:running] = true
+
+ TRACES << TracePoint.new(*call_events){|tp|
+ next if Thread.current != MAIN_THREAD
+
+ method = method_label(tp)
+ call_stack.push method
+ STATE[:count] += 1
+
+ verbose_out :psuh, method if verbose
+ }
+
+ TRACES << TracePoint.new(*return_events){|tp|
+ next if Thread.current != MAIN_THREAD
+ STATE[:count] += 1
+
+ method = "#{prefix(tp.event)}##{tp.method_id}"
+ verbose_out :pop1, method if verbose
+
+ stored_method = call_stack.pop
+ next if stored_method.nil?
+
+ verbose_out :pop2, method if verbose
+
+ if stored_method != method
+ stop if stop_at_failure
+ RubyVM::SDR() if defined? RubyVM::SDR()
+ call_stack.clear
+ raise "#{stored_method} is expected, but #{method} (count: #{STATE[:count]})"
+ end
+ }
+
+ TRACES.each{|trace| trace.enable}
+ end
+
+ def self.stop
+ STATE[:running] = true
+ TRACES.each{|trace| trace.disable}
+ TRACES.clear
+ end
+
+ def self.check
+ TRACES.each{|trace|
+ raise "trace #{trace} should not be deactivated" unless trace.enabled?
+ }
+ end
+end if defined?(TracePoint.stat)
+
+class ::Test::Unit::TestCase
+ include TracePointChecker::ZombieTraceHunter
+end if defined?(TracePointChecker)
+
+# TracePointChecker.start verbose: false
diff --git a/test/lib/with_different_ofs.rb b/test/lib/with_different_ofs.rb
index 559ed6a1d1..b7ac646f8f 100644
--- a/test/lib/with_different_ofs.rb
+++ b/test/lib/with_different_ofs.rb
@@ -3,14 +3,10 @@ module DifferentOFS
module WithDifferentOFS
def setup
super
- verbose, $VERBOSE = $VERBOSE, nil
@ofs, $, = $,, "-"
- $VERBOSE = verbose
end
def teardown
- verbose, $VERBOSE = $VERBOSE, nil
$, = @ofs
- $VERBOSE = verbose
super
end
end
diff --git a/test/lib/zombie_hunter.rb b/test/lib/zombie_hunter.rb
new file mode 100644
index 0000000000..2b81e396ac
--- /dev/null
+++ b/test/lib/zombie_hunter.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+module ZombieHunter
+ def after_teardown
+ super
+ assert_empty(Process.waitall)
+ end
+end
+
+Test::Unit::TestCase.include ZombieHunter
diff --git a/test/logger/helper.rb b/test/logger/helper.rb
deleted file mode 100644
index 9eaeb205b0..0000000000
--- a/test/logger/helper.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-ROOT_DIR = File.dirname(__dir__)
-$LOAD_PATH.unshift File.join(ROOT_DIR, 'lib') # to use logger in this repo instead of ruby built-in logger
-$LOAD_PATH.unshift File.join(ROOT_DIR, 'test', 'lib') # to use custom test-unit in this repo
-require 'logger'
-require 'test/unit'
-
-begin
- # for standalone test suite on ruby/logger
- require 'core_assertions'
-
- Test::Unit::TestCase.include Test::Unit::CoreAssertions
-rescue LoadError
-end
diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb
index 2a01dab17f..7d5bf9ac81 100644
--- a/test/logger/test_logdevice.rb
+++ b/test/logger/test_logdevice.rb
@@ -1,6 +1,7 @@
# coding: US-ASCII
# frozen_string_literal: false
-require_relative 'helper'
+require 'test/unit'
+require 'logger'
require 'tempfile'
require 'tmpdir'
@@ -30,7 +31,7 @@ class TestLogDevice < Test::Unit::TestCase
end
def d(log, opt = {})
- Logger::LogDevice.new(log, **opt)
+ Logger::LogDevice.new(log, opt)
end
def test_initialize
@@ -45,17 +46,14 @@ class TestLogDevice < Test::Unit::TestCase
begin
assert_file.exist?(@filename)
assert_predicate(logdev.dev, :sync)
- refute_predicate(logdev.dev, :binmode?)
assert_equal(@filename, logdev.filename)
logdev.write('hello')
ensure
logdev.close
end
- # create logfile which is already exist.
+ # create logfile whitch is already exist.
logdev = d(@filename)
begin
- assert_predicate(logdev.dev, :sync)
- refute_predicate(logdev.dev, :binmode?)
logdev.write('world')
logfile = File.read(@filename)
assert_equal(2, logfile.split(/\n/).size)
@@ -63,21 +61,6 @@ class TestLogDevice < Test::Unit::TestCase
ensure
logdev.close
end
- # logfile object with path
- tempfile = Tempfile.new("logger")
- tempfile.sync = true
- logdev = d(tempfile)
- begin
- logdev.write('world')
- logfile = File.read(tempfile.path)
- assert_equal(1, logfile.split(/\n/).size)
- assert_match(/^world$/, logfile)
- assert_equal(tempfile.path, logdev.filename)
- ensure
- logdev.close
- File.unlink(tempfile)
- tempfile.close(true)
- end
end
def test_write
@@ -275,12 +258,8 @@ class TestLogDevice < Test::Unit::TestCase
logger.close
end
- def test_invalid_shifting_age
- assert_raise(ArgumentError) { Logger::Period.next_rotate_time(Time.now, 'invalid') }
- assert_raise(ArgumentError) { Logger::Period.previous_period_end(Time.now, 'invalid') }
- end
-
def test_shifting_age
+ # shift_age other than 'daily', 'weekly', and 'monthly' means 'everytime'
yyyymmdd = Time.now.strftime("%Y%m%d")
filename1 = @filename + ".#{yyyymmdd}"
filename2 = @filename + ".#{yyyymmdd}.1"
@@ -315,6 +294,7 @@ class TestLogDevice < Test::Unit::TestCase
end
def test_shifting_period_suffix
+ # shift_age other than 'daily', 'weekly', and 'monthly' means 'everytime'
['%Y%m%d', '%Y-%m-%d', '%Y'].each do |format|
if format == '%Y%m%d' # default
logger = Logger.new(@filename, 'now', 1048576)
@@ -493,7 +473,7 @@ class TestLogDevice < Test::Unit::TestCase
end
end
- env_tz_works = /linux|darwin|freebsd|openbsd/ =~ RUBY_PLATFORM # borrow from test/ruby/test_time_tz.rb
+ env_tz_works = /linux|darwin|freebsd/ =~ RUBY_PLATFORM # borrow from test/ruby/test_time_tz.rb
def test_shifting_weekly
Dir.mktmpdir do |tmpdir|
diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb
index 521b5627d4..a153db4a2a 100644
--- a/test/logger/test_logger.rb
+++ b/test/logger/test_logger.rb
@@ -1,6 +1,7 @@
# coding: US-ASCII
# frozen_string_literal: false
-require_relative 'helper'
+require 'test/unit'
+require 'logger'
require 'tempfile'
class TestLogger < Test::Unit::TestCase
@@ -240,29 +241,6 @@ class TestLogger < Test::Unit::TestCase
assert_equal("false\n", log.msg)
end
- def test_add_binary_data_with_binmode_logdev
- EnvUtil.with_default_internal(Encoding::UTF_8) do
- begin
- tempfile = Tempfile.new("logger")
- tempfile.close
- filename = tempfile.path
- File.unlink(filename)
-
- logger = Logger.new filename, binmode: true
- logger.level = Logger::DEBUG
-
- str = +"\x80"
- str.force_encoding("ASCII-8BIT")
-
- logger.add Logger::DEBUG, str
- assert_equal(2, File.binread(filename).split(/\n/).size)
- ensure
- logger.close
- tempfile.unlink
- end
- end
- end
-
def test_level_log
logger = Logger.new(nil)
logger.progname = "my_progname"
@@ -348,7 +326,7 @@ class TestLogger < Test::Unit::TestCase
r, w = IO.pipe
logger = Logger.new(w)
logger << "msg"
- IO.select([r], nil, nil, 0.1)
+ read_ready, = IO.select([r], nil, nil, 0.1)
w.close
msg = r.read
r.close
@@ -357,25 +335,10 @@ class TestLogger < Test::Unit::TestCase
r, w = IO.pipe
logger = Logger.new(w)
logger << "msg2\n\n"
- IO.select([r], nil, nil, 0.1)
+ read_ready, = IO.select([r], nil, nil, 0.1)
w.close
msg = r.read
r.close
assert_equal("msg2\n\n", msg)
end
-
- class CustomLogger < Logger
- def level
- INFO
- end
- end
-
- def test_overriding_level
- logger = CustomLogger.new(nil)
- log = log(logger, :info) { "msg" }
- assert_equal "msg\n", log.msg
- #
- log = log(logger, :debug) { "msg" }
- assert_nil log.msg
- end
end
diff --git a/test/logger/test_logperiod.rb b/test/logger/test_logperiod.rb
deleted file mode 100644
index 3c5cbbcd9b..0000000000
--- a/test/logger/test_logperiod.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# coding: US-ASCII
-# frozen_string_literal: false
-require_relative 'helper'
-require 'time'
-
-class TestLogPeriod < Test::Unit::TestCase
- def test_next_rotate_time
- time = Time.parse("2019-07-18 13:52:02")
-
- daily_result = Logger::Period.next_rotate_time(time, 'daily')
- next_day = Time.parse("2019-07-19 00:00:00")
- assert_equal(next_day, daily_result)
-
- weekly_result = Logger::Period.next_rotate_time(time, 'weekly')
- next_week = Time.parse("2019-07-21 00:00:00")
- assert_equal(next_week, weekly_result)
-
- monthly_result = Logger::Period.next_rotate_time(time, 'monthly')
- next_month = Time.parse("2019-08-1 00:00:00")
- assert_equal(next_month, monthly_result)
-
- assert_raise(ArgumentError) { Logger::Period.next_rotate_time(time, 'invalid') }
- end
-
- def test_next_rotate_time_extreme_cases
- # First day of Month and Saturday
- time = Time.parse("2018-07-01 00:00:00")
-
- daily_result = Logger::Period.next_rotate_time(time, 'daily')
- next_day = Time.parse("2018-07-02 00:00:00")
- assert_equal(next_day, daily_result)
-
- weekly_result = Logger::Period.next_rotate_time(time, 'weekly')
- next_week = Time.parse("2018-07-08 00:00:00")
- assert_equal(next_week, weekly_result)
-
- monthly_result = Logger::Period.next_rotate_time(time, 'monthly')
- next_month = Time.parse("2018-08-1 00:00:00")
- assert_equal(next_month, monthly_result)
-
- assert_raise(ArgumentError) { Logger::Period.next_rotate_time(time, 'invalid') }
- end
-
- def test_previous_period_end
- time = Time.parse("2019-07-18 13:52:02")
-
- daily_result = Logger::Period.previous_period_end(time, 'daily')
- day_ago = Time.parse("2019-07-17 23:59:59")
- assert_equal(day_ago, daily_result)
-
- weekly_result = Logger::Period.previous_period_end(time, 'weekly')
- week_ago = Time.parse("2019-07-13 23:59:59")
- assert_equal(week_ago, weekly_result)
-
- monthly_result = Logger::Period.previous_period_end(time, 'monthly')
- month_ago = Time.parse("2019-06-30 23:59:59")
- assert_equal(month_ago, monthly_result)
-
- assert_raise(ArgumentError) { Logger::Period.next_rotate_time(time, 'invalid') }
- end
-
- def test_previous_period_end_extreme_cases
- # First day of Month and Saturday
- time = Time.parse("2018-07-01 00:00:00")
-
- daily_result = Logger::Period.previous_period_end(time, 'daily')
- day_ago = Time.parse("2018-06-30 23:59:59")
- assert_equal(day_ago, daily_result)
-
- weekly_result = Logger::Period.previous_period_end(time, 'weekly')
- week_ago = Time.parse("2018-06-30 23:59:59")
- assert_equal(week_ago, weekly_result)
-
- monthly_result = Logger::Period.previous_period_end(time, 'monthly')
- month_ago = Time.parse("2018-06-30 23:59:59")
- assert_equal(month_ago, monthly_result)
-
- assert_raise(ArgumentError) { Logger::Period.next_rotate_time(time, 'invalid') }
- end
-end
diff --git a/test/logger/test_severity.rb b/test/logger/test_severity.rb
index 1197e8abb9..f17a392829 100644
--- a/test/logger/test_severity.rb
+++ b/test/logger/test_severity.rb
@@ -1,6 +1,7 @@
# coding: US-ASCII
# frozen_string_literal: false
-require_relative 'helper'
+require 'test/unit'
+require 'logger'
class TestLoggerSeverity < Test::Unit::TestCase
def test_enum
@@ -12,15 +13,4 @@ class TestLoggerSeverity < Test::Unit::TestCase
end
assert_equal(levels.size, Logger::Severity.constants.size)
end
-
- def test_level_assignment
- logger = Logger.new(nil)
-
- Logger::Severity.constants.each do |level|
- next if level == :UNKNOWN
-
- logger.send("#{level.downcase}!")
- assert(logger.level) == Logger::Severity.const_get(level)
- end
- end
end
diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb
index 7dbb1000d9..d40e0c0430 100644
--- a/test/matrix/test_matrix.rb
+++ b/test/matrix/test_matrix.rb
@@ -283,18 +283,7 @@ class TestMatrix < Test::Unit::TestCase
end
def test_collect
- m1 = Matrix.zero(2,2)
- m2 = Matrix.build(3,4){|row, col| 1}
-
- assert_equal(Matrix[[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]], m2.collect{|e| e * 5})
- assert_equal(Matrix[[7, 0],[0, 7]], m1.collect(:diagonal){|e| e + 7})
- assert_equal(Matrix[[0, 5],[5, 0]], m1.collect(:off_diagonal){|e| e + 5})
- assert_equal(Matrix[[8, 1, 1, 1], [8, 8, 1, 1], [8, 8, 8, 1]], m2.collect(:lower){|e| e + 7})
- assert_equal(Matrix[[1, 1, 1, 1], [-11, 1, 1, 1], [-11, -11, 1, 1]], m2.collect(:strict_lower){|e| e - 12})
- assert_equal(Matrix[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], m2.collect(:strict_upper){|e| e ** 2})
- assert_equal(Matrix[[-1, -1, -1, -1], [1, -1, -1, -1], [1, 1, -1, -1]], m2.collect(:upper){|e| -e})
- assert_raise(ArgumentError) {m1.collect(:test){|e| e + 7}}
- assert_not_equal(m2, m2.collect {|e| e * 2 })
+ assert_equal(Matrix[[1, 4, 9], [16, 25, 36]], @m1.collect {|x| x ** 2 })
end
def test_minor
@@ -583,11 +572,6 @@ class TestMatrix < Test::Unit::TestCase
assert_equal(1, s1 ** o)
end
- def test_abs
- s1 = @a3.abs
- assert_equal(s1, Matrix[[4, 1, 3], [0, 3, 7], [11, 4, 2]])
- end
-
def test_hstack
assert_equal Matrix[[1,2,3,2,3,4,1,2,3], [4,5,6,5,6,7,4,5,6]],
@m1.hstack(@n1, @m1)
@@ -639,134 +623,6 @@ class TestMatrix < Test::Unit::TestCase
assert_equal Matrix.empty(0,3), Matrix.combine(Matrix.empty(0,3), Matrix.empty(0,3)) { raise }
end
- def test_set_element
- src = Matrix[
- [1, 2, 3, 4],
- [5, 6, 7, 8],
- [9, 10, 11, 12],
- ]
- rows = {
- range: [1..2, 1...3, 1..-1, -2..2, 1.., 1..., -2.., -2...],
- int: [2, -1],
- invalid: [-4, 4, -4..2, 2..-4, 0...0, 2..0, -4..],
- }
- columns = {
- range: [2..3, 2...4, 2..-1, -2..3, 2.., 2..., -2..., -2..],
- int: [3, -1],
- invalid: [-5, 5, -5..2, 2..-5, 0...0, -5..],
- }
- values = {
- element: 42,
- matrix: Matrix[[20, 21], [22, 23]],
- vector: Vector[30, 31],
- row: Matrix[[60, 61]],
- column: Matrix[[50], [51]],
- mismatched_matrix: Matrix.identity(3),
- mismatched_vector: Vector[0, 1, 2, 3],
- }
- solutions = {
- [:int, :int] => {
- element: Matrix[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 42]],
- },
- [:range , :int] => {
- element: Matrix[[1, 2, 3, 4], [5, 6, 7, 42], [9, 10, 11, 42]],
- column: Matrix[[1, 2, 3, 4], [5, 6, 7, 50], [9, 10, 11, 51]],
- vector: Matrix[[1, 2, 3, 4], [5, 6, 7, 30], [9, 10, 11, 31]],
- },
- [:int, :range] => {
- element: Matrix[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 42, 42]],
- row: Matrix[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 60, 61]],
- vector: Matrix[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 30, 31]],
- },
- [:range , :range] => {
- element: Matrix[[1, 2, 3, 4], [5, 6, 42, 42], [9, 10, 42, 42]],
- matrix: Matrix[[1, 2, 3, 4], [5, 6, 20, 21], [9, 10, 22, 23]],
- },
- }
- solutions.default = Hash.new(IndexError)
-
- rows.each do |row_style, row_arguments|
- row_arguments.each do |row_argument|
- columns.each do |column_style, column_arguments|
- column_arguments.each do |column_argument|
- values.each do |value_type, value|
- expected = solutions[[row_style, column_style]][value_type] || Matrix::ErrDimensionMismatch
-
- result = src.clone
- begin
- result[row_argument, column_argument] = value
- assert_equal expected, result,
- "m[#{row_argument.inspect}][#{column_argument.inspect}] = #{value.inspect} failed"
- rescue Exception => e
- raise if e.class != expected
- end
- end
- end
- end
- end
- end
- end
-
- def test_map!
- m1 = Matrix.zero(2,2)
- m2 = Matrix.build(3,4){|row, col| 1}
- m3 = Matrix.zero(3,5).freeze
- m4 = Matrix.empty.freeze
-
- assert_equal Matrix[[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]], m2.map!{|e| e * 5}
- assert_equal Matrix[[7, 0],[0, 7]], m1.map!(:diagonal){|e| e + 7}
- assert_equal Matrix[[7, 5],[5, 7]], m1.map!(:off_diagonal){|e| e + 5}
- assert_equal Matrix[[12, 5, 5, 5], [12, 12, 5, 5], [12, 12, 12, 5]], m2.map!(:lower){|e| e + 7}
- assert_equal Matrix[[12, 5, 5, 5], [0, 12, 5, 5], [0, 0, 12, 5]], m2.map!(:strict_lower){|e| e - 12}
- assert_equal Matrix[[12, 25, 25, 25], [0, 12, 25, 25], [0, 0, 12, 25]], m2.map!(:strict_upper){|e| e ** 2}
- assert_equal Matrix[[-12, -25, -25, -25], [0, -12, -25, -25], [0, 0, -12, -25]], m2.map!(:upper){|e| -e}
- assert_equal m1, m1.map!{|e| e ** 2 }
- assert_equal m2, m2.map!(:lower){ |e| e - 3 }
- assert_raise(ArgumentError) {m1.map!(:test){|e| e + 7}}
- assert_raise(FrozenError) { m3.map!{|e| e * 2} }
- assert_raise(FrozenError) { m4.map!{} }
- end
-
- def test_freeze
- m = Matrix[[1, 2, 3],[4, 5, 6]]
- f = m.freeze
- assert_equal true, f.frozen?
- assert m.equal?(f)
- assert m.equal?(f.freeze)
- assert_raise(FrozenError){ m[0, 1] = 56 }
- assert_equal m.dup, m
- end
-
- def test_clone
- a = Matrix[[4]]
- def a.foo
- 42
- end
-
- m = a.clone
- m[0, 0] = 2
- assert_equal a, m * 2
- assert_equal 42, m.foo
-
- a.freeze
- m = a.clone
- assert m.frozen?
- assert_equal 42, m.foo
- end
-
- def test_dup
- a = Matrix[[4]]
- def a.foo
- 42
- end
- a.freeze
-
- m = a.dup
- m[0, 0] = 2
- assert_equal a, m * 2
- assert !m.respond_to?(:foo)
- end
-
def test_eigenvalues_and_eigenvectors_symmetric
m = Matrix[
[8, 1],
diff --git a/test/matrix/test_vector.rb b/test/matrix/test_vector.rb
index 8b771efee3..52785120b1 100644
--- a/test/matrix/test_vector.rb
+++ b/test/matrix/test_vector.rb
@@ -27,108 +27,6 @@ class TestVector < Test::Unit::TestCase
assert_raise(ArgumentError) { Vector.basis(index: 3) }
end
- def test_get_element
- assert_equal(@v1[0..], [1, 2, 3])
- assert_equal(@v1[0..1], [1, 2])
- assert_equal(@v1[2], 3)
- assert_equal(@v1[4], nil)
- end
-
- def test_set_element
-
- assert_block do
- v = Vector[5, 6, 7, 8, 9]
- v[1..2] = Vector[1, 2]
- v == Vector[5, 1, 2, 8, 9]
- end
-
- assert_block do
- v = Vector[6, 7, 8]
- v[1..2] = Matrix[[1, 3]]
- v == Vector[6, 1, 3]
- end
-
- assert_block do
- v = Vector[1, 2, 3, 4, 5, 6]
- v[0..2] = 8
- v == Vector[8, 8, 8, 4, 5, 6]
- end
-
- assert_block do
- v = Vector[1, 3, 4, 5]
- v[2] = 5
- v == Vector[1, 3, 5, 5]
- end
-
- assert_block do
- v = Vector[2, 3, 5]
- v[-2] = 13
- v == Vector[2, 13, 5]
- end
-
- assert_block do
- v = Vector[4, 8, 9, 11, 30]
- v[1..-2] = Vector[1, 2, 3]
- v == Vector[4, 1, 2, 3, 30]
- end
-
- assert_raise(IndexError) {Vector[1, 3, 4, 5][5..6] = 17}
- assert_raise(IndexError) {Vector[1, 3, 4, 5][6] = 17}
- assert_raise(Matrix::ErrDimensionMismatch) {Vector[1, 3, 4, 5][0..2] = Matrix[[1], [2], [3]]}
- assert_raise(ArgumentError) {Vector[1, 2, 3, 4, 5, 6][0..2] = Vector[1, 2, 3, 4, 5, 6]}
- assert_raise(FrozenError) { Vector[7, 8, 9].freeze[0..1] = 5}
- end
-
- def test_map!
- v1 = Vector[1, 2, 3]
- v2 = Vector[1, 3, 5].freeze
- v3 = Vector[].freeze
- assert_equal Vector[1, 4, 9], v1.map!{|e| e ** 2}
- assert_equal v1, v1.map!{|e| e - 8}
- assert_raise(FrozenError) { v2.map!{|e| e + 2 }}
- assert_raise(FrozenError){ v3.map!{} }
- end
-
- def test_freeze
- v = Vector[1,2,3]
- f = v.freeze
- assert_equal true, f.frozen?
- assert v.equal?(f)
- assert v.equal?(f.freeze)
- assert_raise(FrozenError){ v[1] = 56 }
- assert_equal v.dup, v
- end
-
- def test_clone
- a = Vector[4]
- def a.foo
- 42
- end
-
- v = a.clone
- v[0] = 2
- assert_equal a, v * 2
- assert_equal 42, v.foo
-
- a.freeze
- v = a.clone
- assert v.frozen?
- assert_equal 42, v.foo
- end
-
- def test_dup
- a = Vector[4]
- def a.foo
- 42
- end
- a.freeze
-
- v = a.dup
- v[0] = 2
- assert_equal a, v * 2
- assert !v.respond_to?(:foo)
- end
-
def test_identity
assert_same @v1, @v1
assert_not_same @v1, @v2
@@ -325,8 +223,6 @@ class TestVector < Test::Unit::TestCase
assert_in_epsilon(Math::PI/2, Vector[1, 0].angle_with(Vector[0, -1]))
assert_in_epsilon(Math::PI/4, Vector[2, 2].angle_with(Vector[0, 1]))
assert_in_delta(0.0, Vector[1, 1].angle_with(Vector[1, 1]), 0.00001)
- assert_equal(Vector[6, 6].angle_with(Vector[7, 7]), 0.0)
- assert_equal(Vector[6, 6].angle_with(Vector[-7, -7]), Math::PI)
assert_raise(Vector::ZeroVectorError) { Vector[1, 1].angle_with(Vector[0, 0]) }
assert_raise(Vector::ZeroVectorError) { Vector[0, 0].angle_with(Vector[1, 1]) }
diff --git a/tool/test/minitest/metametameta.rb b/test/minitest/metametameta.rb
index a12717c8b1..a12717c8b1 100644
--- a/tool/test/minitest/metametameta.rb
+++ b/test/minitest/metametameta.rb
diff --git a/tool/test/minitest/test_minitest_benchmark.rb b/test/minitest/test_minitest_benchmark.rb
index a783e684c2..a783e684c2 100644
--- a/tool/test/minitest/test_minitest_benchmark.rb
+++ b/test/minitest/test_minitest_benchmark.rb
diff --git a/test/minitest/test_minitest_mock.rb b/test/minitest/test_minitest_mock.rb
new file mode 100644
index 0000000000..6dcf39b75e
--- /dev/null
+++ b/test/minitest/test_minitest_mock.rb
@@ -0,0 +1,404 @@
+# encoding: utf-8
+# frozen_string_literal: false
+
+require 'minitest/autorun'
+
+class TestMiniTestMock < MiniTest::Unit::TestCase
+ def setup
+ @mock = MiniTest::Mock.new.expect(:foo, nil)
+ @mock.expect(:meaning_of_life, 42)
+ end
+
+ def test_create_stub_method
+ assert_nil @mock.foo
+ end
+
+ def test_allow_return_value_specification
+ assert_equal 42, @mock.meaning_of_life
+ end
+
+ def test_blow_up_if_not_called
+ @mock.foo
+
+ util_verify_bad "expected meaning_of_life() => 42, got []"
+ end
+
+ def test_not_blow_up_if_everything_called
+ @mock.foo
+ @mock.meaning_of_life
+
+ assert @mock.verify
+ end
+
+ def test_allow_expectations_to_be_added_after_creation
+ @mock.expect(:bar, true)
+ assert @mock.bar
+ end
+
+ def test_not_verify_if_new_expected_method_is_not_called
+ @mock.foo
+ @mock.meaning_of_life
+ @mock.expect(:bar, true)
+
+ util_verify_bad "expected bar() => true, got []"
+ end
+
+ def test_blow_up_on_wrong_number_of_arguments
+ @mock.foo
+ @mock.meaning_of_life
+ @mock.expect(:sum, 3, [1, 2])
+
+ e = assert_raises ArgumentError do
+ @mock.sum
+ end
+
+ assert_equal "mocked method :sum expects 2 arguments, got 0", e.message
+ end
+
+ def test_return_mock_does_not_raise
+ retval = MiniTest::Mock.new
+ mock = MiniTest::Mock.new
+ mock.expect(:foo, retval)
+ mock.foo
+
+ assert mock.verify
+ end
+
+ def test_mock_args_does_not_raise
+ skip "non-opaque use of ==" if maglev?
+
+ arg = MiniTest::Mock.new
+ mock = MiniTest::Mock.new
+ mock.expect(:foo, nil, [arg])
+ mock.foo(arg)
+
+ assert mock.verify
+ end
+
+ def test_blow_up_on_wrong_arguments
+ @mock.foo
+ @mock.meaning_of_life
+ @mock.expect(:sum, 3, [1, 2])
+
+ e = assert_raises MockExpectationError do
+ @mock.sum(2, 4)
+ end
+
+ exp = "mocked method :sum called with unexpected arguments [2, 4]"
+ assert_equal exp, e.message
+ end
+
+ def test_expect_with_non_array_args
+ e = assert_raises ArgumentError do
+ @mock.expect :blah, 3, false
+ end
+
+ assert_equal "args must be an array", e.message
+ end
+
+ def test_respond_appropriately
+ assert @mock.respond_to?(:foo)
+ assert @mock.respond_to?(:foo, true)
+ assert @mock.respond_to?('foo')
+ assert !@mock.respond_to?(:bar)
+ end
+
+ def test_no_method_error_on_unexpected_methods
+ e = assert_raises NoMethodError do
+ @mock.bar
+ end
+
+ expected = "unmocked method :bar, expected one of [:foo, :meaning_of_life]"
+
+ assert_equal expected, e.message
+ end
+
+ def test_assign_per_mock_return_values
+ a = MiniTest::Mock.new
+ b = MiniTest::Mock.new
+
+ a.expect(:foo, :a)
+ b.expect(:foo, :b)
+
+ assert_equal :a, a.foo
+ assert_equal :b, b.foo
+ end
+
+ def test_do_not_create_stub_method_on_new_mocks
+ a = MiniTest::Mock.new
+ a.expect(:foo, :a)
+
+ assert !MiniTest::Mock.new.respond_to?(:foo)
+ end
+
+ def test_mock_is_a_blank_slate
+ @mock.expect :kind_of?, true, [Integer]
+ @mock.expect :==, true, [1]
+
+ assert @mock.kind_of?(Integer), "didn't mock :kind_of\?"
+ assert @mock == 1, "didn't mock :=="
+ end
+
+ def test_verify_allows_called_args_to_be_loosely_specified
+ mock = MiniTest::Mock.new
+ mock.expect :loose_expectation, true, [Integer]
+ mock.loose_expectation 1
+
+ assert mock.verify
+ end
+
+ def test_verify_raises_with_strict_args
+ mock = MiniTest::Mock.new
+ mock.expect :strict_expectation, true, [2]
+
+ e = assert_raises MockExpectationError do
+ mock.strict_expectation 1
+ end
+
+ exp = "mocked method :strict_expectation called with unexpected arguments [1]"
+ assert_equal exp, e.message
+ end
+
+ def test_method_missing_empty
+ mock = MiniTest::Mock.new
+
+ mock.expect :a, nil
+
+ mock.a
+
+ e = assert_raises MockExpectationError do
+ mock.a
+ end
+
+ assert_equal "No more expects available for :a: []", e.message
+ end
+
+ def test_same_method_expects_are_verified_when_all_called
+ mock = MiniTest::Mock.new
+ mock.expect :foo, nil, [:bar]
+ mock.expect :foo, nil, [:baz]
+
+ mock.foo :bar
+ mock.foo :baz
+
+ assert mock.verify
+ end
+
+ def test_same_method_expects_blow_up_when_not_all_called
+ mock = MiniTest::Mock.new
+ mock.expect :foo, nil, [:bar]
+ mock.expect :foo, nil, [:baz]
+
+ mock.foo :bar
+
+ e = assert_raises(MockExpectationError) { mock.verify }
+
+ exp = "expected foo(:baz) => nil, got [foo(:bar) => nil]"
+
+ assert_equal exp, e.message
+ end
+
+ def test_verify_passes_when_mock_block_returns_true
+ mock = MiniTest::Mock.new
+ mock.expect :foo, nil do
+ true
+ end
+
+ mock.foo
+
+ assert mock.verify
+ end
+
+ def test_mock_block_is_passed_function_params
+ arg1, arg2, arg3 = :bar, [1,2,3], {:a => 'a'}
+ mock = MiniTest::Mock.new
+ mock.expect :foo, nil do |a1, a2, a3|
+ a1 == arg1 &&
+ a2 == arg2 &&
+ a3 == arg3
+ end
+
+ mock.foo arg1, arg2, arg3
+
+ assert mock.verify
+ end
+
+ def test_verify_fails_when_mock_block_returns_false
+ mock = MiniTest::Mock.new
+ mock.expect :foo, nil do
+ false
+ end
+
+ e = assert_raises(MockExpectationError) { mock.foo }
+ exp = "mocked method :foo failed block w/ []"
+
+ assert_equal exp, e.message
+ end
+
+ def test_mock_block_throws_if_args_passed
+ mock = MiniTest::Mock.new
+
+ e = assert_raises(ArgumentError) do
+ mock.expect :foo, nil, [:a, :b, :c] do
+ true
+ end
+ end
+
+ exp = "args ignored when block given"
+
+ assert_equal exp, e.message
+ end
+
+ def test_mock_returns_retval_when_called_with_block
+ mock = MiniTest::Mock.new
+ mock.expect(:foo, 32) do
+ true
+ end
+
+ rs = mock.foo
+
+ assert_equal rs, 32
+ end
+
+ def util_verify_bad exp
+ e = assert_raises MockExpectationError do
+ @mock.verify
+ end
+
+ assert_equal exp, e.message
+ end
+end
+
+require "minitest/metametameta"
+
+class TestMiniTestStub < MiniTest::Unit::TestCase
+ def setup
+ super
+ MiniTest::Unit::TestCase.reset
+
+ @tc = MiniTest::Unit::TestCase.new 'fake tc'
+ @assertion_count = 1
+ end
+
+ def teardown
+ super
+ assert_equal @assertion_count, @tc._assertions
+ end
+
+ class Time
+ def self.now
+ 24
+ end
+ end
+
+ def assert_stub val_or_callable
+ @assertion_count += 1
+
+ t = Time.now.to_i
+
+ Time.stub :now, val_or_callable do
+ @tc.assert_equal 42, Time.now
+ end
+
+ @tc.assert_operator Time.now.to_i, :>=, t
+ end
+
+ def test_stub_private_module_method
+ @assertion_count += 1
+
+ t0 = Time.now
+
+ self.stub :sleep, nil do
+ @tc.assert_nil sleep(10)
+ end
+
+ @tc.assert_operator Time.now - t0, :<=, 1
+ end
+
+ def test_stub_private_module_method_indirect
+ @assertion_count += 1
+
+ slow_clapper = Class.new do
+ def slow_clap
+ sleep 3
+ :clap
+ end
+ end.new
+
+ slow_clapper.stub :sleep, nil do |fast_clapper|
+ @tc.assert_equal :clap, fast_clapper.slow_clap # either form works
+ @tc.assert_equal :clap, slow_clapper.slow_clap # yay closures
+ end
+ end
+
+ def test_stub_public_module_method
+ Math.stub(:log10, 42.0) do
+ @tc.assert_in_delta 42.0, Math.log10(1000)
+ end
+ end
+
+ def test_stub_value
+ assert_stub 42
+ end
+
+ def test_stub_block
+ assert_stub lambda { 42 }
+ end
+
+ def test_stub_block_args
+ @assertion_count += 1
+
+ t = Time.now.to_i
+
+ Time.stub :now, lambda { |n| n * 2 } do
+ @tc.assert_equal 42, Time.now(21)
+ end
+
+ @tc.assert_operator Time.now.to_i, :>=, t
+ end
+
+ def test_stub_callable
+ obj = Object.new
+
+ def obj.call
+ 42
+ end
+
+ assert_stub obj
+ end
+
+ def test_stub_yield_self
+ obj = "foo"
+
+ val = obj.stub :to_s, "bar" do |s|
+ s.to_s
+ end
+
+ @tc.assert_equal "bar", val
+ end
+
+ def test_dynamic_method
+ @assertion_count = 2
+
+ dynamic = Class.new do
+ def self.respond_to?(meth)
+ meth == :found
+ end
+
+ def self.method_missing(meth, *args, &block)
+ if meth == :found
+ false
+ else
+ super
+ end
+ end
+ end
+
+ val = dynamic.stub(:found, true) do |s|
+ s.found
+ end
+
+ @tc.assert_equal true, val
+ @tc.assert_equal false, dynamic.found
+ end
+end
diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb
new file mode 100644
index 0000000000..0b050c6ee2
--- /dev/null
+++ b/test/minitest/test_minitest_unit.rb
@@ -0,0 +1,1779 @@
+# encoding: utf-8
+# frozen_string_literal: false
+
+require 'pathname'
+require 'minitest/metametameta'
+
+module MyModule; end
+class AnError < StandardError; include MyModule; end
+class ImmutableString < String; def inspect; super.freeze; end; end
+
+class TestMiniTestUnit < MetaMetaMetaTestCase
+ pwd = Pathname.new File.expand_path Dir.pwd
+ basedir = Pathname.new(File.expand_path "lib/minitest") + 'mini'
+ basedir = basedir.relative_path_from(pwd).to_s
+ MINITEST_BASE_DIR = basedir[/\A\./] ? basedir : "./#{basedir}"
+ BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in `each'",
+ "#{MINITEST_BASE_DIR}/test.rb:158:in `each'",
+ "#{MINITEST_BASE_DIR}/test.rb:139:in `run'",
+ "#{MINITEST_BASE_DIR}/test.rb:106:in `run'"]
+
+ def test_class_puke_with_assertion_failed
+ exception = MiniTest::Assertion.new "Oh no!"
+ exception.set_backtrace ["unhappy"]
+ assert_equal 'F', @tu.puke('SomeClass', 'method_name', exception)
+ assert_equal 1, @tu.failures
+ assert_match(/^Failure.*Oh no!/m, @tu.report.first)
+ assert_match("SomeClass#method_name [unhappy]", @tu.report.first)
+ end
+
+ def test_class_puke_with_assertion_failed_and_long_backtrace
+ bt = (["test/test_some_class.rb:615:in `method_name'",
+ "#{MINITEST_BASE_DIR}/unit.rb:140:in `assert_raises'",
+ "test/test_some_class.rb:615:in `each'",
+ "test/test_some_class.rb:614:in `test_method_name'",
+ "#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
+ BT_MIDDLE +
+ ["#{MINITEST_BASE_DIR}/test.rb:29"])
+ bt = util_expand_bt bt
+
+ ex_location = util_expand_bt(["test/test_some_class.rb:615"]).first
+
+ exception = MiniTest::Assertion.new "Oh no!"
+ exception.set_backtrace bt
+ assert_equal 'F', @tu.puke('TestSomeClass', 'test_method_name', exception)
+ assert_equal 1, @tu.failures
+ assert_match(/^Failure.*Oh no!/m, @tu.report.first)
+ assert_match("TestSomeClass#test_method_name [#{ex_location}]", @tu.report.first)
+ end
+
+ def test_class_puke_with_assertion_failed_and_user_defined_assertions
+ bt = (["lib/test/my/util.rb:16:in `another_method_name'",
+ "#{MINITEST_BASE_DIR}/unit.rb:140:in `assert_raises'",
+ "lib/test/my/util.rb:15:in `block in assert_something'",
+ "lib/test/my/util.rb:14:in `each'",
+ "lib/test/my/util.rb:14:in `assert_something'",
+ "test/test_some_class.rb:615:in `each'",
+ "test/test_some_class.rb:614:in `test_method_name'",
+ "#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
+ BT_MIDDLE +
+ ["#{MINITEST_BASE_DIR}/test.rb:29"])
+ bt = util_expand_bt bt
+
+ ex_location = util_expand_bt(["test/test_some_class.rb:615"]).first
+
+ exception = MiniTest::Assertion.new "Oh no!"
+ exception.set_backtrace bt
+ assert_equal 'F', @tu.puke('TestSomeClass', 'test_method_name', exception)
+ assert_equal 1, @tu.failures
+ assert_match(/^Failure.*Oh no!/m, @tu.report.first)
+ assert_match("TestSomeClass#test_method_name [#{ex_location}]", @tu.report.first)
+ end
+
+ def test_class_puke_with_failure_and_flunk_in_backtrace
+ exception = begin
+ MiniTest::Unit::TestCase.new('fake tc').flunk
+ rescue MiniTest::Assertion => failure
+ failure
+ end
+ assert_equal 'F', @tu.puke('SomeClass', 'method_name', exception)
+ refute @tu.report.any?{|line| line =~ /in .flunk/}
+ end
+
+ def test_class_puke_with_flunk_and_user_defined_assertions
+ bt = (["lib/test/my/util.rb:16:in `flunk'",
+ "#{MINITEST_BASE_DIR}/unit.rb:140:in `assert_raises'",
+ "lib/test/my/util.rb:15:in `block in assert_something'",
+ "lib/test/my/util.rb:14:in `each'",
+ "lib/test/my/util.rb:14:in `assert_something'",
+ "test/test_some_class.rb:615:in `each'",
+ "test/test_some_class.rb:614:in `test_method_name'",
+ "#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
+ BT_MIDDLE +
+ ["#{MINITEST_BASE_DIR}/test.rb:29"])
+ bt = util_expand_bt bt
+
+ ex_location = util_expand_bt(["test/test_some_class.rb:615"]).first
+
+ exception = MiniTest::Assertion.new "Oh no!"
+ exception.set_backtrace bt
+ assert_equal 'F', @tu.puke('TestSomeClass', 'test_method_name', exception)
+ assert_equal 1, @tu.failures
+ assert_match(/^Failure.*Oh no!/m, @tu.report.first)
+ assert_match("TestSomeClass#test_method_name [#{ex_location}]", @tu.report.first)
+ end
+
+ def test_class_puke_with_non_failure_exception
+ exception = Exception.new("Oh no again!")
+ assert_equal 'E', @tu.puke('SomeClass', 'method_name', exception)
+ assert_equal 1, @tu.errors
+ assert_match(/^Exception.*Oh no again!/m, @tu.report.first)
+ end
+
+ def test_filter_backtrace
+ # this is a semi-lame mix of relative paths.
+ # I cheated by making the autotest parts not have ./
+ bt = (["lib/autotest.rb:571:in `add_exception'",
+ "test/test_autotest.rb:62:in `test_add_exception'",
+ "#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
+ BT_MIDDLE +
+ ["#{MINITEST_BASE_DIR}/test.rb:29",
+ "test/test_autotest.rb:422"])
+ bt = util_expand_bt bt
+
+ ex = ["lib/autotest.rb:571:in `add_exception'",
+ "test/test_autotest.rb:62:in `test_add_exception'"]
+ ex = util_expand_bt ex
+
+ fu = MiniTest::filter_backtrace(bt)
+
+ assert_equal ex, fu
+ end
+
+ def test_filter_backtrace_all_unit
+ bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
+ BT_MIDDLE +
+ ["#{MINITEST_BASE_DIR}/test.rb:29"])
+ ex = bt.clone
+ fu = MiniTest::filter_backtrace(bt)
+ assert_equal ex, fu
+ end
+
+ def test_filter_backtrace_unit_starts
+ bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
+ BT_MIDDLE +
+ ["#{MINITEST_BASE_DIR}/mini/test.rb:29",
+ "-e:1"])
+
+ bt = util_expand_bt bt
+
+ ex = ["-e:1"]
+ fu = MiniTest::filter_backtrace bt
+ assert_equal ex, fu
+ end
+
+ def test_default_runner_is_minitest_unit
+ assert_instance_of MiniTest::Unit, MiniTest::Unit.runner
+ end
+
+
+ def test_passed_eh_teardown_good
+ test_class = Class.new MiniTest::Unit::TestCase do
+ def teardown; assert true; end
+ def test_omg; assert true; end
+ end
+
+ test = test_class.new :test_omg
+ test.run @tu
+ assert test.passed?
+ end
+
+ def test_passed_eh_teardown_skipped
+ test_class = Class.new MiniTest::Unit::TestCase do
+ def teardown; assert true; end
+ def test_omg; skip "bork"; end
+ end
+
+ test = test_class.new :test_omg
+ test.run @tu
+ assert test.passed?
+ end
+
+ def test_passed_eh_teardown_flunked
+ test_class = Class.new MiniTest::Unit::TestCase do
+ def teardown; flunk; end
+ def test_omg; assert true; end
+ end
+
+ test = test_class.new :test_omg
+ test.run @tu
+ refute test.passed?
+ end
+
+ def util_expand_bt bt
+ bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
+ end
+end
+
+class TestMiniTestUnitInherited < MetaMetaMetaTestCase
+ def with_overridden_include
+ Class.class_eval do
+ def inherited_with_hacks klass
+ throw :inherited_hook
+ end
+
+ alias inherited_without_hacks inherited
+ alias inherited inherited_with_hacks
+ alias IGNORE_ME! inherited # 1.8 bug. god I love venture bros
+ end
+
+ yield
+ ensure
+ Class.class_eval do
+ alias inherited inherited_without_hacks
+
+ undef_method :inherited_with_hacks
+ undef_method :inherited_without_hacks
+ end
+
+ refute_respond_to Class, :inherited_with_hacks
+ refute_respond_to Class, :inherited_without_hacks
+ end
+
+ def test_inherited_hook_plays_nice_with_others
+ with_overridden_include do
+ assert_throws :inherited_hook do
+ Class.new MiniTest::Unit::TestCase
+ end
+ end
+ end
+end
+
+class TestMiniTestRunner < MetaMetaMetaTestCase
+ # do not parallelize this suite... it just can't handle it.
+
+ def test_class_test_suites
+ @assertion_count = 0
+
+ tc = Class.new(MiniTest::Unit::TestCase)
+
+ assert_equal 1, MiniTest::Unit::TestCase.test_suites.size
+ assert_equal [tc], MiniTest::Unit::TestCase.test_suites
+ end
+
+ def test_run_test
+ Class.new MiniTest::Unit::TestCase do
+ attr_reader :foo
+
+ def run_test name
+ @foo = "hi mom!"
+ super
+ @foo = "okay"
+ end
+
+ def test_something
+ assert_equal "hi mom!", foo
+ end
+ end
+
+ expected = clean <<-EOM
+ .
+
+ Finished tests in 0.00
+
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_report expected
+ end
+
+ def test_run_error
+ Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+
+ def test_error
+ raise "unhandled exception"
+ end
+ end
+
+ expected = clean <<-EOM
+ E.
+
+ Finished tests in 0.00
+
+ 1) Error:
+ #<Class:0xXXX>#test_error:
+ RuntimeError: unhandled exception
+ FILE:LINE:in \`test_error\'
+
+ 2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
+ EOM
+
+ assert_report expected
+ end
+
+ def test_run_error_teardown
+ Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+
+ def teardown
+ raise "unhandled exception"
+ end
+ end
+
+ expected = clean <<-EOM
+ E
+
+ Finished tests in 0.00
+
+ 1) Error:
+ #<Class:0xXXX>#test_something:
+ RuntimeError: unhandled exception
+ FILE:LINE:in \`teardown\'
+
+ 1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
+ EOM
+
+ assert_report expected
+ end
+
+ def test_run_failing
+ Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+
+ def test_failure
+ assert false
+ end
+ end
+
+ expected = clean <<-EOM
+ F.
+
+ Finished tests in 0.00
+
+ 1) Failure:
+ #<Class:0xXXX>#test_failure [FILE:LINE]:
+ Failed assertion, no message given.
+
+ 2 tests, 2 assertions, 1 failures, 0 errors, 0 skips
+ EOM
+
+ assert_report expected
+ end
+
+ def test_run_failing_filtered
+ Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+
+ def test_failure
+ assert false
+ end
+ end
+
+ expected = clean <<-EOM
+ .
+
+ Finished tests in 0.00
+
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_report expected, %w[--name /some|thing/ --seed 42]
+ end
+
+ def assert_filtering name, expected, a = false
+ args = %W[--name #{name} --seed 42]
+
+ alpha = Class.new MiniTest::Unit::TestCase do
+ define_method :test_something do
+ assert a
+ end
+ end
+ Object.const_set(:Alpha, alpha)
+
+ beta = Class.new MiniTest::Unit::TestCase do
+ define_method :test_something do
+ assert true
+ end
+ end
+ Object.const_set(:Beta, beta)
+
+ assert_report expected, args
+ ensure
+ Object.send :remove_const, :Alpha
+ Object.send :remove_const, :Beta
+ end
+
+ def test_run_filtered_including_suite_name
+ expected = clean <<-EOM
+ .
+
+ Finished tests in 0.00
+
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_filtering "/Beta#test_something/", expected
+ end
+
+ def test_run_filtered_including_suite_name_string
+ expected = clean <<-EOM
+ .
+
+ Finished tests in 0.00
+
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_filtering "Beta#test_something", expected
+ end
+
+ def test_run_filtered_string_method_only
+ expected = clean <<-EOM
+ ..
+
+ Finished tests in 0.00
+
+ 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_filtering "test_something", expected, :pass
+ end
+
+ def test_run_passing
+ Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+ end
+
+ expected = clean <<-EOM
+ .
+
+ Finished tests in 0.00
+
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_report expected
+ end
+
+ def test_run_skip
+ Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+
+ def test_skip
+ skip "not yet"
+ end
+ end
+
+ expected = clean <<-EOM
+ S.
+
+ Finished tests in 0.00
+
+ 2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
+ EOM
+
+ assert_report expected
+ end
+
+ def test_run_skip_verbose
+ Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+
+ def test_skip
+ skip "not yet"
+ end
+ end
+
+ expected = clean <<-EOM
+ #<Class:0xXXX>#test_skip = 0.00 s = S
+ #<Class:0xXXX>#test_something = 0.00 s = .
+
+
+ Finished tests in 0.00
+
+ 1) Skipped:
+ #<Class:0xXXX>#test_skip [FILE:LINE]:
+ not yet
+
+ 2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
+ EOM
+
+ assert_report expected, %w[--seed 42 --verbose]
+ end
+
+ def test_run_with_other_runner
+ MiniTest::Unit.runner = Class.new MiniTest::Unit do
+ def _run_suite suite, type
+ suite.before_suite # Run once before each suite
+ super suite, type
+ end
+ end.new
+
+ Class.new MiniTest::Unit::TestCase do
+ def self.name; "wacky!" end
+
+ def self.before_suite
+ MiniTest::Unit.output.puts "Running #{self.name} tests"
+ @@foo = 1
+ end
+
+ def test_something
+ assert_equal 1, @@foo
+ end
+
+ def test_something_else
+ assert_equal 1, @@foo
+ end
+ end
+
+ expected = clean <<-EOM
+ Running wacky! tests
+ ..
+
+ Finished tests in 0.00
+
+ 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_report expected
+ end
+
+ require 'monitor'
+
+ class Latch
+ def initialize count = 1
+ @count = count
+ @lock = Monitor.new
+ @cv = @lock.new_cond
+ end
+
+ def release
+ @lock.synchronize do
+ @count -= 1 if @count > 0
+ @cv.broadcast if @count == 0
+ end
+ end
+
+ def await
+ @lock.synchronize { @cv.wait_while { @count > 0 } }
+ end
+ end
+end
+
+class TestMiniTestUnitOrder < MetaMetaMetaTestCase
+ # do not parallelize this suite... it just can't handle it.
+
+ def test_before_setup
+ call_order = []
+ Class.new MiniTest::Unit::TestCase do
+ define_method :setup do
+ super()
+ call_order << :setup
+ end
+
+ define_method :before_setup do
+ call_order << :before_setup
+ end
+
+ def test_omg; assert true; end
+ end
+
+ with_output do
+ @tu.run %w[--seed 42]
+ end
+
+ expected = [:before_setup, :setup]
+ assert_equal expected, call_order
+ end
+
+ def test_after_teardown
+ call_order = []
+ Class.new MiniTest::Unit::TestCase do
+ define_method :teardown do
+ super()
+ call_order << :teardown
+ end
+
+ define_method :after_teardown do
+ call_order << :after_teardown
+ end
+
+ def test_omg; assert true; end
+ end
+
+ with_output do
+ @tu.run %w[--seed 42]
+ end
+
+ expected = [:teardown, :after_teardown]
+ assert_equal expected, call_order
+ end
+
+ def test_all_teardowns_are_guaranteed_to_run
+ call_order = []
+ Class.new MiniTest::Unit::TestCase do
+ define_method :after_teardown do
+ super()
+ call_order << :after_teardown
+ raise
+ end
+
+ define_method :teardown do
+ super()
+ call_order << :teardown
+ raise
+ end
+
+ define_method :before_teardown do
+ super()
+ call_order << :before_teardown
+ raise
+ end
+
+ def test_omg; assert true; end
+ end
+
+ with_output do
+ @tu.run %w[--seed 42]
+ end
+
+ expected = [:before_teardown, :teardown, :after_teardown]
+ assert_equal expected, call_order
+ end
+
+ def test_setup_and_teardown_survive_inheritance
+ call_order = []
+
+ parent = Class.new MiniTest::Unit::TestCase do
+ define_method :setup do
+ call_order << :setup_method
+ end
+
+ define_method :teardown do
+ call_order << :teardown_method
+ end
+
+ define_method :test_something do
+ call_order << :test
+ end
+ end
+
+ _ = Class.new parent
+
+ with_output do
+ @tu.run %w[--seed 42]
+ end
+
+ # Once for the parent class, once for the child
+ expected = [:setup_method, :test, :teardown_method] * 2
+
+ assert_equal expected, call_order
+ end
+end
+
+class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
+ # do not call parallelize_me! - teardown accesses @tc._assertions
+ # which is not threadsafe. Nearly every method in here is an
+ # assertion test so it isn't worth splitting it out further.
+
+ RUBY18 = ! defined? Encoding
+
+ def setup
+ super
+
+ MiniTest::Unit::TestCase.reset
+
+ @tc = MiniTest::Unit::TestCase.new 'fake tc'
+ @zomg = "zomg ponies!"
+ @assertion_count = 1
+ end
+
+ def teardown
+ assert_equal(@assertion_count, @tc._assertions,
+ "expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc.passed?
+ end
+
+ def non_verbose
+ orig_verbose = $VERBOSE
+ $VERBOSE = false
+
+ yield
+ ensure
+ $VERBOSE = orig_verbose
+ end
+
+ def test_assert
+ @assertion_count = 2
+
+ @tc.assert_equal true, @tc.assert(true), "returns true on success"
+ end
+
+ def test_assert__triggered
+ util_assert_triggered "Failed assertion, no message given." do
+ @tc.assert false
+ end
+ end
+
+ def test_assert__triggered_message
+ util_assert_triggered @zomg do
+ @tc.assert false, @zomg
+ end
+ end
+
+ def test_assert_empty
+ @assertion_count = 2
+
+ @tc.assert_empty []
+ end
+
+ def test_assert_empty_triggered
+ @assertion_count = 2
+
+ util_assert_triggered "Expected [1] to be empty." do
+ @tc.assert_empty [1]
+ end
+ end
+
+ def test_assert_equal
+ @tc.assert_equal 1, 1
+ end
+
+ def test_assert_equal_different_collection_array_hex_invisible
+ object1 = Object.new
+ object2 = Object.new
+ msg = "No visible difference in the Array#inspect output.
+ You should look at the implementation of #== on Array or its members.
+ [#<Object:0xXXXXXX>]".gsub(/^ +/, "")
+ util_assert_triggered msg do
+ @tc.assert_equal [object1], [object2]
+ end
+ end
+
+ def test_assert_equal_different_collection_hash_hex_invisible
+ h1, h2 = {}, {}
+ h1[1] = Object.new
+ h2[1] = Object.new
+ msg = "No visible difference in the Hash#inspect output.
+ You should look at the implementation of #== on Hash or its members.
+ {1=>#<Object:0xXXXXXX>}".gsub(/^ +/, "")
+
+ util_assert_triggered msg do
+ @tc.assert_equal h1, h2
+ end
+ end
+
+ def test_assert_equal_different_diff_deactivated
+ skip "https://github.com/MagLev/maglev/issues/209" if maglev?
+
+ without_diff do
+ util_assert_triggered util_msg("haha" * 10, "blah" * 10) do
+ o1 = "haha" * 10
+ o2 = "blah" * 10
+
+ @tc.assert_equal o1, o2
+ end
+ end
+ end
+
+ def test_assert_equal_different_hex
+ c = Class.new do
+ def initialize s; @name = s; end
+ end
+
+ o1 = c.new "a"
+ o2 = c.new "b"
+ msg = "--- expected
+ +++ actual
+ @@ -1 +1 @@
+ -#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"a\">
+ +#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"b\">
+ ".gsub(/^ +/, "")
+
+ util_assert_triggered msg do
+ @tc.assert_equal o1, o2
+ end
+ end
+
+ def test_assert_equal_different_hex_invisible
+ o1 = Object.new
+ o2 = Object.new
+
+ msg = "No visible difference in the Object#inspect output.
+ You should look at the implementation of #== on Object or its members.
+ #<Object:0xXXXXXX>".gsub(/^ +/, "")
+
+ util_assert_triggered msg do
+ @tc.assert_equal o1, o2
+ end
+ end
+
+ def test_assert_equal_different_long
+ msg = "--- expected
+ +++ actual
+ @@ -1 +1 @@
+ -\"hahahahahahahahahahahahahahahahahahahaha\"
+ +\"blahblahblahblahblahblahblahblahblahblah\"
+ ".gsub(/^ +/, "")
+
+ util_assert_triggered msg do
+ o1 = "haha" * 10
+ o2 = "blah" * 10
+
+ @tc.assert_equal o1, o2
+ end
+ end
+
+ def test_assert_equal_different_long_invisible
+ msg = "No visible difference in the String#inspect output.
+ You should look at the implementation of #== on String or its members.
+ \"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "")
+
+ util_assert_triggered msg do
+ o1 = "blah" * 10
+ o2 = "blah" * 10
+ def o1.== o
+ false
+ end
+ @tc.assert_equal o1, o2
+ end
+ end
+
+ def test_assert_equal_different_long_msg
+ msg = "message.
+ --- expected
+ +++ actual
+ @@ -1 +1 @@
+ -\"hahahahahahahahahahahahahahahahahahahaha\"
+ +\"blahblahblahblahblahblahblahblahblahblah\"
+ ".gsub(/^ +/, "")
+
+ util_assert_triggered msg do
+ o1 = "haha" * 10
+ o2 = "blah" * 10
+ @tc.assert_equal o1, o2, "message"
+ end
+ end
+
+ def test_assert_equal_different_short
+ util_assert_triggered util_msg(1, 2) do
+ @tc.assert_equal 1, 2
+ end
+ end
+
+ def test_assert_equal_different_short_msg
+ util_assert_triggered util_msg(1, 2, "message") do
+ @tc.assert_equal 1, 2, "message"
+ end
+ end
+
+ def test_assert_equal_different_short_multiline
+ msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n"
+ util_assert_triggered msg do
+ @tc.assert_equal "a\nb", "a\nc"
+ end
+ end
+
+ def test_assert_in_delta
+ @tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
+ end
+
+ def test_delta_consistency
+ @tc.assert_in_delta 0, 1, 1
+
+ util_assert_triggered "Expected |0 - 1| (1) to not be <= 1." do
+ @tc.refute_in_delta 0, 1, 1
+ end
+ end
+
+ def test_assert_in_delta_triggered
+ x = maglev? ? "9.999999xxxe-07" : "1.0e-06"
+ util_assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
+ @tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
+ end
+ end
+
+ def test_assert_in_epsilon
+ @assertion_count = 10
+
+ @tc.assert_in_epsilon 10000, 9991
+ @tc.assert_in_epsilon 9991, 10000
+ @tc.assert_in_epsilon 1.0, 1.001
+ @tc.assert_in_epsilon 1.001, 1.0
+
+ @tc.assert_in_epsilon 10000, 9999.1, 0.0001
+ @tc.assert_in_epsilon 9999.1, 10000, 0.0001
+ @tc.assert_in_epsilon 1.0, 1.0001, 0.0001
+ @tc.assert_in_epsilon 1.0001, 1.0, 0.0001
+
+ @tc.assert_in_epsilon(-1, -1)
+ @tc.assert_in_epsilon(-10000, -9991)
+ end
+
+ def test_epsilon_consistency
+ @tc.assert_in_epsilon 1.0, 1.001
+
+ msg = "Expected |1.0 - 1.001| (0.000999xxx) to not be <= 0.001."
+ util_assert_triggered msg do
+ @tc.refute_in_epsilon 1.0, 1.001
+ end
+ end
+
+ def test_assert_in_epsilon_triggered
+ util_assert_triggered 'Expected |10000 - 9990| (10) to be <= 9.99.' do
+ @tc.assert_in_epsilon 10000, 9990
+ end
+ end
+
+ def test_assert_in_epsilon_triggered_negative_case
+ x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
+ y = maglev? ? "0.100000xxx" : "0.1"
+ util_assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
+ @tc.assert_in_epsilon(-1.1, -1, 0.1)
+ end
+ end
+
+ def test_assert_includes
+ @assertion_count = 2
+
+ @tc.assert_includes [true], true
+ end
+
+ def test_assert_includes_triggered
+ @assertion_count = 3
+
+ e = @tc.assert_raises MiniTest::Assertion do
+ @tc.assert_includes [true], false
+ end
+
+ expected = "Expected [true] to include false."
+ assert_equal expected, e.message
+ end
+
+ def test_assert_instance_of
+ @tc.assert_instance_of String, "blah"
+ end
+
+ def test_assert_instance_of_triggered
+ util_assert_triggered 'Expected "blah" to be an instance of Array, not String.' do
+ @tc.assert_instance_of Array, "blah"
+ end
+ end
+
+ def test_assert_kind_of
+ @tc.assert_kind_of String, "blah"
+ end
+
+ def test_assert_kind_of_triggered
+ util_assert_triggered 'Expected "blah" to be a kind of Array, not String.' do
+ @tc.assert_kind_of Array, "blah"
+ end
+ end
+
+ def test_assert_match
+ @assertion_count = 2
+ @tc.assert_match(/\w+/, "blah blah blah")
+ end
+
+ def test_assert_match_matcher_object
+ @assertion_count = 2
+
+ pattern = Object.new
+ def pattern.=~(other) true end
+
+ @tc.assert_match pattern, 5
+ end
+
+ def test_assert_match_matchee_to_str
+ @assertion_count = 2
+
+ obj = Object.new
+ def obj.to_str; "blah" end
+
+ @tc.assert_match "blah", obj
+ end
+
+ def test_assert_match_object_triggered
+ @assertion_count = 2
+
+ pattern = Object.new
+ def pattern.=~(other) false end
+ def pattern.inspect; "[Object]" end
+
+ util_assert_triggered 'Expected [Object] to match 5.' do
+ @tc.assert_match pattern, 5
+ end
+ end
+
+ def test_assert_match_triggered
+ @assertion_count = 2
+ util_assert_triggered 'Expected /\d+/ to match "blah blah blah".' do
+ @tc.assert_match(/\d+/, "blah blah blah")
+ end
+ end
+
+ def test_assert_nil
+ @tc.assert_nil nil
+ end
+
+ def test_assert_nil_triggered
+ util_assert_triggered 'Expected 42 to be nil.' do
+ @tc.assert_nil 42
+ end
+ end
+
+ def test_assert_operator
+ @tc.assert_operator 2, :>, 1
+ end
+
+ def test_assert_operator_bad_object
+ bad = Object.new
+ def bad.==(other) true end
+
+ @tc.assert_operator bad, :equal?, bad
+ end
+
+ def test_assert_operator_triggered
+ util_assert_triggered "Expected 2 to be < 1." do
+ @tc.assert_operator 2, :<, 1
+ end
+ end
+
+ def test_assert_output_both
+ @assertion_count = 2
+
+ @tc.assert_output "yay", "blah" do
+ print "yay"
+ $stderr.print "blah"
+ end
+ end
+
+ def test_assert_output_both_regexps
+ @assertion_count = 4
+
+ @tc.assert_output(/y.y/, /bl.h/) do
+ print "yay"
+ $stderr.print "blah"
+ end
+ end
+
+ def test_assert_output_err
+ @tc.assert_output nil, "blah" do
+ $stderr.print "blah"
+ end
+ end
+
+ def test_assert_output_neither
+ @assertion_count = 0
+
+ @tc.assert_output do
+ # do nothing
+ end
+ end
+
+ def test_assert_output_out
+ @tc.assert_output "blah" do
+ print "blah"
+ end
+ end
+
+ def test_assert_output_triggered_both
+ util_assert_triggered util_msg("blah", "blah blah", "In stderr") do
+ @tc.assert_output "yay", "blah" do
+ print "boo"
+ $stderr.print "blah blah"
+ end
+ end
+ end
+
+ def test_assert_output_triggered_err
+ util_assert_triggered util_msg("blah", "blah blah", "In stderr") do
+ @tc.assert_output nil, "blah" do
+ $stderr.print "blah blah"
+ end
+ end
+ end
+
+ def test_assert_output_triggered_out
+ util_assert_triggered util_msg("blah", "blah blah", "In stdout") do
+ @tc.assert_output "blah" do
+ print "blah blah"
+ end
+ end
+ end
+
+ def test_assert_predicate
+ @tc.assert_predicate "", :empty?
+ end
+
+ def test_assert_predicate_triggered
+ util_assert_triggered 'Expected "blah" to be empty?.' do
+ @tc.assert_predicate "blah", :empty?
+ end
+ end
+
+ def test_assert_raises
+ @tc.assert_raises RuntimeError do
+ raise "blah"
+ end
+ end
+
+ def test_assert_raises_module
+ @tc.assert_raises MyModule do
+ raise AnError
+ end
+ end
+
+ ##
+ # *sigh* This is quite an odd scenario, but it is from real (albeit
+ # ugly) test code in ruby-core:
+ #
+ # http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29259
+
+ def test_assert_raises_skip
+ @assertion_count = 0
+
+ util_assert_triggered "skipped", MiniTest::Skip do
+ @tc.assert_raises ArgumentError do
+ begin
+ raise "blah"
+ rescue
+ skip "skipped"
+ end
+ end
+ end
+ end
+
+ def test_assert_raises_triggered_different
+ e = assert_raises MiniTest::Assertion do
+ @tc.assert_raises RuntimeError do
+ raise SyntaxError, "icky"
+ end
+ end
+
+ expected = clean <<-EOM.chomp
+ [RuntimeError] exception expected, not
+ Class: <SyntaxError>
+ Message: <\"icky\">
+ ---Backtrace---
+ FILE:LINE:in \`test_assert_raises_triggered_different\'
+ ---------------
+ EOM
+
+ actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
+ actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
+
+ assert_equal expected, actual
+ end
+
+ def test_assert_raises_triggered_different_msg
+ e = assert_raises MiniTest::Assertion do
+ @tc.assert_raises RuntimeError, "XXX" do
+ raise SyntaxError, "icky"
+ end
+ end
+
+ expected = clean <<-EOM
+ XXX.
+ [RuntimeError] exception expected, not
+ Class: <SyntaxError>
+ Message: <\"icky\">
+ ---Backtrace---
+ FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
+ ---------------
+ EOM
+
+ actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
+ actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
+
+ assert_equal expected.chomp, actual
+ end
+
+ def test_assert_raises_triggered_none
+ e = assert_raises MiniTest::Assertion do
+ @tc.assert_raises MiniTest::Assertion do
+ # do nothing
+ end
+ end
+
+ expected = "MiniTest::Assertion expected but nothing was raised."
+
+ assert_equal expected, e.message
+ end
+
+ def test_assert_raises_triggered_none_msg
+ e = assert_raises MiniTest::Assertion do
+ @tc.assert_raises MiniTest::Assertion, "XXX" do
+ # do nothing
+ end
+ end
+
+ expected = "XXX.\nMiniTest::Assertion expected but nothing was raised."
+
+ assert_equal expected, e.message
+ end
+
+ def test_assert_raises_triggered_subclass
+ e = assert_raises MiniTest::Assertion do
+ @tc.assert_raises StandardError do
+ raise AnError
+ end
+ end
+
+ expected = clean <<-EOM.chomp
+ [StandardError] exception expected, not
+ Class: <AnError>
+ Message: <\"AnError\">
+ ---Backtrace---
+ FILE:LINE:in \`test_assert_raises_triggered_subclass\'
+ ---------------
+ EOM
+
+ actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
+ actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
+
+ assert_equal expected, actual
+ end
+
+ def test_assert_respond_to
+ @tc.assert_respond_to "blah", :empty?
+ end
+
+ def test_assert_respond_to_triggered
+ util_assert_triggered 'Expected "blah" (String) to respond to #rawr!.' do
+ @tc.assert_respond_to "blah", :rawr!
+ end
+ end
+
+ def test_assert_same
+ @assertion_count = 3
+
+ o = "blah"
+ @tc.assert_same 1, 1
+ @tc.assert_same :blah, :blah
+ @tc.assert_same o, o
+ end
+
+ def test_assert_same_triggered
+ @assertion_count = 2
+
+ util_assert_triggered 'Expected 2 (oid=N) to be the same as 1 (oid=N).' do
+ @tc.assert_same 1, 2
+ end
+
+ s1 = "blah"
+ s2 = "blah"
+
+ util_assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
+ @tc.assert_same s1, s2
+ end
+ end
+
+ def test_assert_send
+ @tc.assert_send [1, :<, 2]
+ end
+
+ def test_assert_send_bad
+ util_assert_triggered "Expected 1.>(*[2]) to return true." do
+ @tc.assert_send [1, :>, 2]
+ end
+ end
+
+ def test_assert_silent
+ @assertion_count = 2
+
+ @tc.assert_silent do
+ # do nothing
+ end
+ end
+
+ def test_assert_silent_triggered_err
+ util_assert_triggered util_msg("", "blah blah", "In stderr") do
+ @tc.assert_silent do
+ $stderr.print "blah blah"
+ end
+ end
+ end
+
+ def test_assert_silent_triggered_out
+ @assertion_count = 2
+
+ util_assert_triggered util_msg("", "blah blah", "In stdout") do
+ @tc.assert_silent do
+ print "blah blah"
+ end
+ end
+ end
+
+ def test_assert_throws
+ @tc.assert_throws :blah do
+ throw :blah
+ end
+ end
+
+ def test_assert_throws_different
+ util_assert_triggered 'Expected :blah to have been thrown, not :not_blah.' do
+ @tc.assert_throws :blah do
+ throw :not_blah
+ end
+ end
+ end
+
+ def test_assert_throws_unthrown
+ util_assert_triggered 'Expected :blah to have been thrown.' do
+ @tc.assert_throws :blah do
+ # do nothing
+ end
+ end
+ end
+
+ def test_capture_io
+ @assertion_count = 0
+
+ non_verbose do
+ out, err = capture_io do
+ puts 'hi'
+ $stderr.puts 'bye!'
+ end
+
+ assert_equal "hi\n", out
+ assert_equal "bye!\n", err
+ end
+ end
+
+ def test_capture_subprocess_io
+ @assertion_count = 0
+
+ non_verbose do
+ out, err = capture_subprocess_io do
+ system("echo", "hi")
+ system("echo", "bye!", out: :err)
+ end
+
+ assert_equal "hi\n", out
+ assert_equal "bye!\n", err
+ end
+ end
+
+ def test_class_asserts_match_refutes
+ @assertion_count = 0
+
+ methods = MiniTest::Assertions.public_instance_methods
+ methods.map! { |m| m.to_s } if Symbol === methods.first
+
+ # These don't have corresponding refutes _on purpose_. They're
+ # useless and will never be added, so don't bother.
+ ignores = %w[assert_output assert_raises assert_send
+ assert_silent assert_throws]
+
+ # These are test/unit methods. I'm not actually sure why they're still here
+ ignores += %w[assert_no_match assert_not_equal assert_not_nil
+ assert_not_same assert_nothing_raised
+ assert_nothing_thrown assert_raise]
+
+ asserts = methods.grep(/^assert/).sort - ignores
+ refutes = methods.grep(/^refute/).sort - ignores
+
+ assert_empty refutes.map { |n| n.sub(/^refute/, 'assert') } - asserts
+ assert_empty asserts.map { |n| n.sub(/^assert/, 'refute') } - refutes
+ end
+
+ def test_flunk
+ util_assert_triggered 'Epic Fail!' do
+ @tc.flunk
+ end
+ end
+
+ def test_flunk_message
+ util_assert_triggered @zomg do
+ @tc.flunk @zomg
+ end
+ end
+
+ def test_message
+ @assertion_count = 0
+
+ assert_equal "blah2.", @tc.message { "blah2" }.call
+ assert_equal "blah2.", @tc.message("") { "blah2" }.call
+ assert_equal "blah1.\nblah2.", @tc.message(:blah1) { "blah2" }.call
+ assert_equal "blah1.\nblah2.", @tc.message("blah1") { "blah2" }.call
+
+ message = proc { "blah1" }
+ assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
+
+ message = @tc.message { "blah1" }
+ assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
+ end
+
+ def test_message_message
+ util_assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
+ @tc.assert_equal 1, 2, message { "whoops" }
+ end
+ end
+
+ def test_message_lambda
+ util_assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
+ @tc.assert_equal 1, 2, lambda { "whoops" }
+ end
+ end
+
+ def test_message_deferred
+ @assertion_count, var = 0, nil
+
+ msg = message { var = "blah" }
+
+ assert_nil var
+
+ msg.call
+
+ assert_equal "blah", var
+ end
+
+ def test_pass
+ @tc.pass
+ end
+
+ def test_prints
+ printer = Class.new { extend MiniTest::Assertions }
+ @tc.assert_equal '"test"', printer.mu_pp(ImmutableString.new 'test')
+ end
+
+ def test_refute
+ @assertion_count = 2
+
+ @tc.assert_equal false, @tc.refute(false), "returns false on success"
+ end
+
+ def test_refute_empty
+ @assertion_count = 2
+
+ @tc.refute_empty [1]
+ end
+
+ def test_refute_empty_triggered
+ @assertion_count = 2
+
+ util_assert_triggered "Expected [] to not be empty." do
+ @tc.refute_empty []
+ end
+ end
+
+ def test_refute_equal
+ @tc.refute_equal "blah", "yay"
+ end
+
+ def test_refute_equal_triggered
+ util_assert_triggered 'Expected "blah" to not be equal to "blah".' do
+ @tc.refute_equal "blah", "blah"
+ end
+ end
+
+ def test_refute_in_delta
+ @tc.refute_in_delta 0.0, 1.0 / 1000, 0.000001
+ end
+
+ def test_refute_in_delta_triggered
+ x = maglev? ? "0.100000xxx" : "0.1"
+ util_assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
+ @tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
+ end
+ end
+
+ def test_refute_in_epsilon
+ @tc.refute_in_epsilon 10000, 9990-1
+ end
+
+ def test_refute_in_epsilon_triggered
+ util_assert_triggered 'Expected |10000 - 9990| (10) to not be <= 10.0.' do
+ @tc.refute_in_epsilon 10000, 9990
+ fail
+ end
+ end
+
+ def test_refute_includes
+ @assertion_count = 2
+
+ @tc.refute_includes [true], false
+ end
+
+ def test_refute_includes_triggered
+ @assertion_count = 3
+
+ e = @tc.assert_raises MiniTest::Assertion do
+ @tc.refute_includes [true], true
+ end
+
+ expected = "Expected [true] to not include true."
+ assert_equal expected, e.message
+ end
+
+ def test_refute_instance_of
+ @tc.refute_instance_of Array, "blah"
+ end
+
+ def test_refute_instance_of_triggered
+ util_assert_triggered 'Expected "blah" to not be an instance of String.' do
+ @tc.refute_instance_of String, "blah"
+ end
+ end
+
+ def test_refute_kind_of
+ @tc.refute_kind_of Array, "blah"
+ end
+
+ def test_refute_kind_of_triggered
+ util_assert_triggered 'Expected "blah" to not be a kind of String.' do
+ @tc.refute_kind_of String, "blah"
+ end
+ end
+
+ def test_refute_match
+ @assertion_count = 2
+ @tc.refute_match(/\d+/, "blah blah blah")
+ end
+
+ def test_refute_match_matcher_object
+ @assertion_count = 2
+ @tc.refute_match Object.new, 5 # default #=~ returns false
+ end
+
+ def test_refute_match_object_triggered
+ @assertion_count = 2
+
+ pattern = Object.new
+ def pattern.=~(other) true end
+ def pattern.inspect; "[Object]" end
+
+ util_assert_triggered 'Expected [Object] to not match 5.' do
+ @tc.refute_match pattern, 5
+ end
+ end
+
+ def test_refute_match_triggered
+ @assertion_count = 2
+ util_assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do
+ @tc.refute_match(/\w+/, "blah blah blah")
+ end
+ end
+
+ def test_refute_nil
+ @tc.refute_nil 42
+ end
+
+ def test_refute_nil_triggered
+ util_assert_triggered 'Expected nil to not be nil.' do
+ @tc.refute_nil nil
+ end
+ end
+
+ def test_refute_predicate
+ @tc.refute_predicate "42", :empty?
+ end
+
+ def test_refute_predicate_triggered
+ util_assert_triggered 'Expected "" to not be empty?.' do
+ @tc.refute_predicate "", :empty?
+ end
+ end
+
+ def test_refute_operator
+ @tc.refute_operator 2, :<, 1
+ end
+
+ def test_refute_operator_bad_object
+ bad = Object.new
+ def bad.==(other) true end
+
+ @tc.refute_operator true, :equal?, bad
+ end
+
+ def test_refute_operator_triggered
+ util_assert_triggered "Expected 2 to not be > 1." do
+ @tc.refute_operator 2, :>, 1
+ end
+ end
+
+ def test_refute_respond_to
+ @tc.refute_respond_to "blah", :rawr!
+ end
+
+ def test_refute_respond_to_triggered
+ util_assert_triggered 'Expected "blah" to not respond to empty?.' do
+ @tc.refute_respond_to "blah", :empty?
+ end
+ end
+
+ def test_refute_same
+ @tc.refute_same 1, 2
+ end
+
+ def test_refute_same_triggered
+ util_assert_triggered 'Expected 1 (oid=N) to not be the same as 1 (oid=N).' do
+ @tc.refute_same 1, 1
+ end
+ end
+
+ def test_skip
+ @assertion_count = 0
+
+ util_assert_triggered "haha!", MiniTest::Skip do
+ @tc.skip "haha!"
+ end
+ end
+
+ def test_test_methods_random
+ @assertion_count = 0
+
+ sample_test_case = Class.new MiniTest::Unit::TestCase do
+ def self.test_order; :random; end
+ def test_test1; assert "does not matter" end
+ def test_test2; assert "does not matter" end
+ def test_test3; assert "does not matter" end
+ @test_order = [1, 0, 2]
+ def self.rand(n) @test_order.shift; end
+ end
+
+ expected = %w(test_test2 test_test1 test_test3)
+ assert_equal expected, sample_test_case.test_methods
+ end
+
+ def test_test_methods_sorted
+ @assertion_count = 0
+
+ sample_test_case = Class.new MiniTest::Unit::TestCase do
+ def self.test_order; :sorted end
+ def test_test3; assert "does not matter" end
+ def test_test2; assert "does not matter" end
+ def test_test1; assert "does not matter" end
+ end
+
+ expected = %w(test_test1 test_test2 test_test3)
+ assert_equal expected, sample_test_case.test_methods
+ end
+
+ def assert_triggered expected, klass = MiniTest::Assertion
+ e = assert_raises klass do
+ yield
+ end
+
+ msg = e.message.sub(/(---Backtrace---).*/m, '\1')
+ msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)')
+ msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
+
+ assert_equal expected, msg
+ end
+ alias util_assert_triggered assert_triggered
+
+ def util_msg exp, act, msg = nil
+ s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}"
+ s = "#{msg}.\n#{s}" if msg
+ s
+ end
+
+ def without_diff
+ old_diff = MiniTest::Assertions.diff
+ MiniTest::Assertions.diff = nil
+
+ yield
+ ensure
+ MiniTest::Assertions.diff = old_diff
+ end
+end
+
+class TestMiniTestGuard < MiniTest::Unit::TestCase
+ def test_mri_eh
+ assert self.class.mri? "ruby blah"
+ assert self.mri? "ruby blah"
+ end
+
+ def test_jruby_eh
+ assert self.class.jruby? "java"
+ assert self.jruby? "java"
+ end
+
+ def test_rubinius_eh
+ assert self.class.rubinius? "rbx"
+ assert self.rubinius? "rbx"
+ end
+
+ def test_windows_eh
+ assert self.class.windows? "mswin"
+ assert self.windows? "mswin"
+ end
+end
+
+class TestMiniTestUnitRecording < MetaMetaMetaTestCase
+ # do not parallelize this suite... it just can't handle it.
+
+ def assert_run_record(*expected, &block)
+ def @tu.record suite, method, assertions, time, error
+ recording[method] << error
+ end
+
+ def @tu.recording
+ @recording ||= Hash.new { |h,k| h[k] = [] }
+ end
+
+ MiniTest::Unit.runner = @tu
+
+ Class.new MiniTest::Unit::TestCase, &block
+
+ with_output do
+ @tu.run
+ end
+
+ recorded = @tu.recording.fetch("test_method").map(&:class)
+
+ assert_equal expected, recorded
+ end
+
+ def test_record_passing
+ assert_run_record NilClass do
+ def test_method
+ assert true
+ end
+ end
+ end
+
+ def test_record_failing
+ assert_run_record MiniTest::Assertion do
+ def test_method
+ assert false
+ end
+ end
+ end
+
+ def test_record_error
+ assert_run_record RuntimeError do
+ def test_method
+ raise "unhandled exception"
+ end
+ end
+ end
+
+ def test_record_error_teardown
+ assert_run_record NilClass, RuntimeError do
+ def test_method
+ assert true
+ end
+
+ def teardown
+ raise "unhandled exception"
+ end
+ end
+ end
+
+ def test_record_error_in_test_and_teardown
+ assert_run_record AnError, RuntimeError do
+ def test_method
+ raise AnError
+ end
+
+ def teardown
+ raise "unhandled exception"
+ end
+ end
+ end
+
+ def test_record_skip
+ assert_run_record MiniTest::Skip do
+ def test_method
+ skip "not yet"
+ end
+ end
+ end
+end
diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb
index 4f67478a56..3ba3e03387 100644
--- a/test/mkmf/base.rb
+++ b/test/mkmf/base.rb
@@ -1,13 +1,5 @@
# frozen_string_literal: false
$extmk = true
-require 'rbconfig'
-RbConfig.fire_update!("top_srcdir", File.expand_path("../..", __dir__))
-File.foreach(RbConfig::CONFIG["topdir"]+"/Makefile") do |line|
- if /^CC_WRAPPER\s*=\s*/ =~ line
- RbConfig.fire_update!('CC_WRAPPER', $'.strip)
- break
- end
-end
require 'test/unit'
require 'mkmf'
@@ -130,10 +122,8 @@ module TestMkmf::Base
def mkmf(*args, &block)
@stdout.clear
stdout, @stdout.origin, $stdout = @stdout.origin, $stdout, @stdout
- verbose, $VERBOSE = $VERBOSE, false
@mkmfobj.instance_eval(*args, &block)
ensure
- $VERBOSE = verbose
$stdout, @stdout.origin = @stdout.origin, stdout
end
@@ -149,7 +139,7 @@ end
class TestMkmf
include TestMkmf::Base
- def assert_separately(args, src, *rest, **options)
- super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\nEND{teardown}\n#{src}", *rest, **options)
+ def assert_separately(args, src, *rest)
+ super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\nEND{teardown}\n#{src}", *rest)
end
end
diff --git a/test/mkmf/test_flags.rb b/test/mkmf/test_flags.rb
index a3596d8e55..69a1084608 100644
--- a/test/mkmf/test_flags.rb
+++ b/test/mkmf/test_flags.rb
@@ -41,7 +41,7 @@ class TestMkmf
end
def test_try_cflag_invalid_opt
- assert_separately([], <<-'end;', timeout: 30) #do
+ assert_separately([], <<-'end;') #do
assert(!try_cflags("nosuch.c"), TestMkmf::MKMFLOG)
assert(have_devel?, TestMkmf::MKMFLOG)
end;
diff --git a/test/mkmf/test_framework.rb b/test/mkmf/test_framework.rb
index ba15299ae0..eb29c6b518 100644
--- a/test/mkmf/test_framework.rb
+++ b/test/mkmf/test_framework.rb
@@ -10,7 +10,7 @@ class TestMkmf
FileUtils.mkdir_p(hdrdir)
File.write("#{hdrdir}/#{hdrname}", "")
src = "#{fwdir}/main.c"
- File.write(src, "void #{fw}(void) {}\n")
+ File.write(src, "void #{fw}(void) {}")
cmd = LINK_SO.dup
RbConfig.expand(cmd, RbConfig::CONFIG.merge("OBJS"=>src))
cmd.gsub!("$@", "#{fwdir}/#{fw}")
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb
index 721c848d68..a036069647 100644
--- a/test/monitor/test_monitor.rb
+++ b/test/monitor/test_monitor.rb
@@ -35,29 +35,6 @@ class TestMonitor < Test::Unit::TestCase
assert_equal((1..10).to_a, ary)
end
- def test_exit
- m = Monitor.new
- m.enter
- assert_equal true, m.mon_owned?
- m.exit
- assert_equal false, m.mon_owned?
-
- assert_raise ThreadError do
- m.exit
- end
-
- assert_equal false, m.mon_owned?
-
- m.enter
- Thread.new{
- assert_raise(ThreadError) do
- m.exit
- end
- }.join
- assert_equal true, m.mon_owned?
- m.exit
- end
-
def test_enter_second_after_killed_thread
th = Thread.start {
@monitor.enter
@@ -195,8 +172,6 @@ class TestMonitor < Test::Unit::TestCase
assert @monitor.mon_locked?
assert @monitor.mon_owned?
end
- ensure
- th.join
end
def test_cond
@@ -223,19 +198,6 @@ class TestMonitor < Test::Unit::TestCase
assert_join_threads([th, th2])
end
- class NewCondTest
- include MonitorMixin
- attr_reader :cond
- def initialize
- @cond = new_cond
- super # mon_initialize
- end
- end
-
- def test_new_cond_before_initialize
- assert NewCondTest.new.cond.instance_variable_get(:@monitor) != nil
- end
-
def test_timedwait
cond = @monitor.new_cond
b = "foo"
@@ -307,26 +269,4 @@ class TestMonitor < Test::Unit::TestCase
# end
# cumber_thread.kill
end
-
- def test_wait_interruption
- cond = @monitor.new_cond
-
- th = Thread.start {
- @monitor.synchronize do
- begin
- cond.wait(0.1)
- @monitor.mon_owned?
- rescue Interrupt
- @monitor.mon_owned?
- end
- end
- }
- sleep(0.1)
- th.raise(Interrupt)
-
- begin
- assert_equal true, th.value
- rescue Interrupt
- end
- end
end
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb
index 24c5d3a12f..8e0a688135 100644
--- a/test/net/ftp/test_ftp.rb
+++ b/test/net/ftp/test_ftp.rb
@@ -61,7 +61,7 @@ class FTPTest < Test::Unit::TestCase
end
def test_parse227
- ftp = Net::FTP.new(nil, use_pasv_ip: true)
+ ftp = Net::FTP.new
host, port = ftp.send(:parse227, "227 Entering Passive Mode (192,168,0,1,12,34)")
assert_equal("192.168.0.1", host)
assert_equal(3106, port)
@@ -80,14 +80,6 @@ class FTPTest < Test::Unit::TestCase
assert_raise(Net::FTPProtoError) do
ftp.send(:parse227, "227 ) foo bar (")
end
-
- ftp = Net::FTP.new
- sock = OpenStruct.new
- sock.remote_address = OpenStruct.new
- sock.remote_address.ip_address = "10.0.0.1"
- ftp.instance_variable_set(:@bare_sock, sock)
- host, port = ftp.send(:parse227, "227 Entering Passive Mode (192,168,0,1,12,34)")
- assert_equal("10.0.0.1", host)
end
def test_parse228
@@ -343,7 +335,7 @@ class FTPTest < Test::Unit::TestCase
sleep(0.1)
sock.print("331 Please specify the password.\r\n")
commands.push(sock.gets)
- sleep(2.0) # Net::ReadTimeout
+ sleep(0.3)
sock.print("230 Login successful.\r\n")
commands.push(sock.gets)
sleep(0.1)
@@ -352,7 +344,7 @@ class FTPTest < Test::Unit::TestCase
begin
begin
ftp = Net::FTP.new
- ftp.read_timeout = 0.4
+ ftp.read_timeout = 0.2
ftp.connect(SERVER_ADDR, server.port)
assert_raise(Net::ReadTimeout) do
ftp.login
@@ -538,7 +530,6 @@ class FTPTest < Test::Unit::TestCase
sock.print("553 Requested action not taken.\r\n")
commands.push(sock.gets)
sock.print("200 Switching to Binary mode.\r\n")
- [host, port]
}
begin
begin
@@ -720,7 +711,6 @@ class FTPTest < Test::Unit::TestCase
host, port = process_port_or_eprt(sock, line)
commands.push(sock.gets)
sock.print("550 Requested action not taken.\r\n")
- [host, port]
}
begin
begin
@@ -947,7 +937,6 @@ class FTPTest < Test::Unit::TestCase
host, port = process_port_or_eprt(sock, line)
commands.push(sock.gets)
sock.print("452 Requested file action aborted.\r\n")
- [host, port]
}
begin
begin
@@ -1538,102 +1527,6 @@ EOF
end
end
- def test_features
- commands = []
- server = create_ftp_server { |sock|
- sock.print("220 (test_ftp).\r\n")
- commands.push(sock.gets)
- sock.print("211-Features\r\n")
- sock.print(" LANG EN*\r\n")
- sock.print(" UTF8\r\n")
- sock.print("211 End\r\n")
- }
- begin
- begin
- ftp = Net::FTP.new
- ftp.connect(SERVER_ADDR, server.port)
- assert_equal(['LANG EN*', 'UTF8'], ftp.features)
- assert_equal("FEAT\r\n", commands.shift)
- assert_equal(nil, commands.shift)
- ensure
- ftp.close if ftp
- end
- ensure
- server.close
- end
- end
-
- def test_features_not_implemented
- commands = []
- server = create_ftp_server { |sock|
- sock.print("220 (test_ftp).\r\n")
- commands.push(sock.gets)
- sock.print("502 Not Implemented\r\n")
- }
- begin
- begin
- ftp = Net::FTP.new
- ftp.connect(SERVER_ADDR, server.port)
- assert_raise(Net::FTPPermError) do
- ftp.features
- end
- assert_equal("FEAT\r\n", commands.shift)
- assert_equal(nil, commands.shift)
- ensure
- ftp.close if ftp
- end
- ensure
- server.close
- end
-
- end
-
- def test_option
- commands = []
- server = create_ftp_server { |sock|
- sock.print("220 (test_ftp)\r\n")
- commands.push(sock.gets)
- sock.print("200 OPTS UTF8 command successful\r\n")
- }
- begin
- begin
- ftp = Net::FTP.new
- ftp.connect(SERVER_ADDR, server.port)
- ftp.option("UTF8", "ON")
- assert_equal("OPTS UTF8 ON\r\n", commands.shift)
- assert_equal(nil, commands.shift)
- ensure
- ftp.close if ftp
- end
- ensure
- server.close
- end
- end
-
- def test_option_not_implemented
- commands = []
- server = create_ftp_server { |sock|
- sock.print("220 (test_ftp)\r\n")
- commands.push(sock.gets)
- sock.print("502 Not implemented\r\n")
- }
- begin
- begin
- ftp = Net::FTP.new
- ftp.connect(SERVER_ADDR, server.port)
- assert_raise(Net::FTPPermError) do
- ftp.option("UTF8", "ON")
- end
- assert_equal("OPTS UTF8 ON\r\n", commands.shift)
- assert_equal(nil, commands.shift)
- ensure
- ftp.close if ftp
- end
- ensure
- server.close
- end
- end
-
def test_mlst
commands = []
server = create_ftp_server { |sock|
@@ -2278,7 +2171,7 @@ EOF
begin
ftp = Net::FTP.new
ftp.resume = resume
- ftp.read_timeout = RubyVM::MJIT.enabled? ? 5 : 0.2 # use large timeout for --jit-wait
+ ftp.read_timeout = 0.2
ftp.connect(SERVER_ADDR, server.port)
ftp.login
assert_match(/\AUSER /, commands.shift)
@@ -2467,155 +2360,10 @@ EOF
end
end
- def test_ignore_pasv_ip
- commands = []
- binary_data = (0..0xff).map {|i| i.chr}.join * 4 * 3
- server = create_ftp_server(nil, "127.0.0.1") { |sock|
- sock.print("220 (test_ftp).\r\n")
- commands.push(sock.gets)
- sock.print("331 Please specify the password.\r\n")
- commands.push(sock.gets)
- sock.print("230 Login successful.\r\n")
- commands.push(sock.gets)
- sock.print("200 Switching to Binary mode.\r\n")
- line = sock.gets
- commands.push(line)
- data_server = TCPServer.new("127.0.0.1", 0)
- port = data_server.local_address.ip_port
- sock.printf("227 Entering Passive Mode (999,0,0,1,%s).\r\n",
- port.divmod(256).join(","))
- commands.push(sock.gets)
- sock.print("150 Opening BINARY mode data connection for foo (#{binary_data.size} bytes)\r\n")
- conn = data_server.accept
- binary_data.scan(/.{1,1024}/nm) do |s|
- conn.print(s)
- end
- conn.shutdown(Socket::SHUT_WR)
- conn.read
- conn.close
- data_server.close
- sock.print("226 Transfer complete.\r\n")
- }
- begin
- begin
- ftp = Net::FTP.new
- ftp.passive = true
- ftp.read_timeout *= 5 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait
- ftp.connect("127.0.0.1", server.port)
- ftp.login
- assert_match(/\AUSER /, commands.shift)
- assert_match(/\APASS /, commands.shift)
- assert_equal("TYPE I\r\n", commands.shift)
- buf = ftp.getbinaryfile("foo", nil)
- assert_equal(binary_data, buf)
- assert_equal(Encoding::ASCII_8BIT, buf.encoding)
- assert_equal("PASV\r\n", commands.shift)
- assert_equal("RETR foo\r\n", commands.shift)
- assert_equal(nil, commands.shift)
- ensure
- ftp.close if ftp
- end
- ensure
- server.close
- end
- end
-
- def test_use_pasv_ip
- commands = []
- binary_data = (0..0xff).map {|i| i.chr}.join * 4 * 3
- server = create_ftp_server(nil, "127.0.0.1") { |sock|
- sock.print("220 (test_ftp).\r\n")
- commands.push(sock.gets)
- sock.print("331 Please specify the password.\r\n")
- commands.push(sock.gets)
- sock.print("230 Login successful.\r\n")
- commands.push(sock.gets)
- sock.print("200 Switching to Binary mode.\r\n")
- line = sock.gets
- commands.push(line)
- data_server = TCPServer.new("127.0.0.1", 0)
- port = data_server.local_address.ip_port
- sock.printf("227 Entering Passive Mode (127,0,0,1,%s).\r\n",
- port.divmod(256).join(","))
- commands.push(sock.gets)
- sock.print("150 Opening BINARY mode data connection for foo (#{binary_data.size} bytes)\r\n")
- conn = data_server.accept
- binary_data.scan(/.{1,1024}/nm) do |s|
- conn.print(s)
- end
- conn.shutdown(Socket::SHUT_WR)
- conn.read
- conn.close
- data_server.close
- sock.print("226 Transfer complete.\r\n")
- }
- begin
- begin
- ftp = Net::FTP.new
- ftp.passive = true
- ftp.use_pasv_ip = true
- ftp.read_timeout *= 5 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait
- ftp.connect("127.0.0.1", server.port)
- ftp.login
- assert_match(/\AUSER /, commands.shift)
- assert_match(/\APASS /, commands.shift)
- assert_equal("TYPE I\r\n", commands.shift)
- buf = ftp.getbinaryfile("foo", nil)
- assert_equal(binary_data, buf)
- assert_equal(Encoding::ASCII_8BIT, buf.encoding)
- assert_equal("PASV\r\n", commands.shift)
- assert_equal("RETR foo\r\n", commands.shift)
- assert_equal(nil, commands.shift)
- ensure
- ftp.close if ftp
- end
- ensure
- server.close
- end
- end
-
- def test_use_pasv_invalid_ip
- commands = []
- binary_data = (0..0xff).map {|i| i.chr}.join * 4 * 3
- server = create_ftp_server(nil, "127.0.0.1") { |sock|
- sock.print("220 (test_ftp).\r\n")
- commands.push(sock.gets)
- sock.print("331 Please specify the password.\r\n")
- commands.push(sock.gets)
- sock.print("230 Login successful.\r\n")
- commands.push(sock.gets)
- sock.print("200 Switching to Binary mode.\r\n")
- line = sock.gets
- commands.push(line)
- sock.print("227 Entering Passive Mode (999,0,0,1,48,57).\r\n")
- commands.push(sock.gets)
- }
- begin
- begin
- ftp = Net::FTP.new
- ftp.passive = true
- ftp.use_pasv_ip = true
- ftp.read_timeout *= 5 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait
- ftp.connect("127.0.0.1", server.port)
- ftp.login
- assert_match(/\AUSER /, commands.shift)
- assert_match(/\APASS /, commands.shift)
- assert_equal("TYPE I\r\n", commands.shift)
- assert_raise(SocketError) do
- ftp.getbinaryfile("foo", nil)
- end
- ensure
- ftp.close if ftp
- end
- ensure
- server.close
- end
- end
-
private
- def create_ftp_server(sleep_time = nil, addr = SERVER_ADDR)
- server = TCPServer.new(addr, 0)
+ def create_ftp_server(sleep_time = nil)
+ server = TCPServer.new(SERVER_ADDR, 0)
@thread = Thread.start do
if sleep_time
sleep(sleep_time)
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index 231aa48557..d3c2aecb9f 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -34,7 +34,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_class_Proxy_from_ENV
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
# These are ignored on purpose. See Bug 4388 and Feature 6546
@@ -115,7 +115,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_address
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
http = Net::HTTP.new 'hostname.example', nil, 'proxy.example'
assert_equal 'proxy.example', http.proxy_address
@@ -125,7 +125,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_address_no_proxy
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
http = Net::HTTP.new 'hostname.example', nil, 'proxy.example', nil, nil, nil, 'example'
assert_nil http.proxy_address
@@ -135,7 +135,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_from_env_ENV
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
assert_equal false, Net::HTTP.proxy_class?
@@ -146,7 +146,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_address_ENV
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
http = Net::HTTP.new 'hostname.example'
@@ -156,13 +156,13 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_eh_no_proxy
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
assert_equal false, Net::HTTP.new('hostname.example', nil, nil).proxy?
end
end
def test_proxy_eh_ENV
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
http = Net::HTTP.new 'hostname.example'
@@ -172,7 +172,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_eh_ENV_with_user
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://foo:bar@proxy.example:8000'
http = Net::HTTP.new 'hostname.example'
@@ -189,13 +189,13 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_eh_ENV_none_set
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
assert_equal false, Net::HTTP.new('hostname.example').proxy?
end
end
def test_proxy_eh_ENV_no_proxy
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
ENV['no_proxy'] = 'hostname.example'
@@ -204,7 +204,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_port
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
http = Net::HTTP.new 'example', nil, 'proxy.example'
assert_equal 'proxy.example', http.proxy_address
assert_equal 80, http.proxy_port
@@ -216,7 +216,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_proxy_port_ENV
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
http = Net::HTTP.new 'hostname.example'
@@ -226,7 +226,7 @@ class TestNetHTTP < Test::Unit::TestCase
end
def test_newobj
- TestNetHTTPUtils.clean_http_proxy_env do
+ clean_http_proxy_env do
ENV['http_proxy'] = 'http://proxy.example:8000'
http = Net::HTTP.newobj 'hostname.example'
@@ -235,6 +235,25 @@ class TestNetHTTP < Test::Unit::TestCase
end
end
+ def clean_http_proxy_env
+ orig = {
+ 'http_proxy' => ENV['http_proxy'],
+ 'http_proxy_user' => ENV['http_proxy_user'],
+ 'http_proxy_pass' => ENV['http_proxy_pass'],
+ 'no_proxy' => ENV['no_proxy'],
+ }
+
+ orig.each_key do |key|
+ ENV.delete key
+ end
+
+ yield
+ ensure
+ orig.each do |key, value|
+ ENV[key] = value
+ end
+ end
+
def test_failure_message_includes_failed_domain_and_port
# hostname to be included in the error message
host = Struct.new(:to_s).new("<example>")
@@ -243,7 +262,7 @@ class TestNetHTTP < Test::Unit::TestCase
def host.to_str; raise SocketError, "open failure"; end
uri = Struct.new(:scheme, :hostname, :port).new("http", host, port)
assert_raise_with_message(SocketError, /#{host}:#{port}/) do
- TestNetHTTPUtils.clean_http_proxy_env{ Net::HTTP.get(uri) }
+ clean_http_proxy_env{ Net::HTTP.get(uri) }
end
end
@@ -450,11 +469,9 @@ module TestNetHTTP_version_1_1_methods
def test_s_post
url = "http://#{config('host')}:#{config('port')}/?q=a"
- res = assert_warning(/Content-Type did not set/) do
- Net::HTTP.post(
+ res = Net::HTTP.post(
URI.parse(url),
"a=x")
- end
assert_equal "application/x-www-form-urlencoded", res["Content-Type"]
assert_equal "a=x", res.body
assert_equal url, res["X-request-uri"]
@@ -512,32 +529,6 @@ module TestNetHTTP_version_1_1_methods
assert_equal data, res.entity
end
- def test_timeout_during_HTTP_session_write
- th = nil
- # listen for connections... but deliberately do not read
- TCPServer.open('localhost', 0) {|server|
- port = server.addr[1]
-
- conn = Net::HTTP.new('localhost', port)
- conn.write_timeout = EnvUtil.apply_timeout_scale(0.01)
- conn.read_timeout = EnvUtil.apply_timeout_scale(0.01) if windows?
- conn.open_timeout = EnvUtil.apply_timeout_scale(0.1)
-
- th = Thread.new do
- err = !windows? ? Net::WriteTimeout : Net::ReadTimeout
- assert_raise(err) do
- assert_warning(/Content-Type did not set/) do
- conn.post('/', "a"*50_000_000)
- end
- end
- end
- assert th.join(EnvUtil.apply_timeout_scale(10))
- }
- ensure
- th&.kill
- th&.join
- end
-
def test_timeout_during_HTTP_session
bug4246 = "expected the HTTP session to have timed out but have not. c.f. [ruby-core:34203]"
@@ -547,15 +538,15 @@ module TestNetHTTP_version_1_1_methods
port = server.addr[1]
conn = Net::HTTP.new('localhost', port)
- conn.read_timeout = EnvUtil.apply_timeout_scale(0.01)
- conn.open_timeout = EnvUtil.apply_timeout_scale(0.1)
+ conn.read_timeout = 0.01
+ conn.open_timeout = 0.1
th = Thread.new do
assert_raise(Net::ReadTimeout) {
conn.get('/')
}
end
- assert th.join(EnvUtil.apply_timeout_scale(10)), bug4246
+ assert th.join(10), bug4246
}
ensure
th.kill
@@ -871,17 +862,6 @@ class TestNetHTTP_v1_2 < Test::Unit::TestCase
Net::HTTP.version_1_2
super
end
-
- def test_send_large_POST_request
- start {|http|
- data = ' '*6000000
- res = http.send_request('POST', '/', data, 'content-type' => 'application/x-www-form-urlencoded')
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of String, res.body
- assert_equal data.size, res.body.size
- assert_equal data, res.body
- }
- end
end
class TestNetHTTP_v1_2_chunked < Test::Unit::TestCase
@@ -987,7 +967,7 @@ class TestNetHTTPContinue < Test::Unit::TestCase
raise WEBrick::HTTPStatus::Forbidden
}
start {|http|
- uheader = {'content-type' => 'application/x-www-form-urlencoded', 'content-length' => '5', 'expect' => '100-continue'}
+ uheader = {'content-length' => '5', 'expect' => '100-continue'}
http.continue_timeout = 1 # allow the server to respond before sending
http.request_post('/continue', 'data', uheader) {|res|
assert_equal(res.code, '403')
@@ -1039,8 +1019,7 @@ class TestNetHTTPSwitchingProtocols < Test::Unit::TestCase
}
start {|http|
http.continue_timeout = 0.2
- http.request_post('/continue', 'body=BODY',
- 'content-type' => 'application/x-www-form-urlencoded') {|res|
+ http.request_post('/continue', 'body=BODY') {|res|
assert_equal('BODY', res.read_body)
}
}
diff --git a/test/net/http/test_http_request.rb b/test/net/http/test_http_request.rb
index c1ad99a118..c2144d86c7 100644
--- a/test/net/http/test_http_request.rb
+++ b/test/net/http/test_http_request.rb
@@ -65,19 +65,6 @@ class HTTPRequestTest < Test::Unit::TestCase
'Bug #7381 - do not decode content if the user overrides'
end if Net::HTTP::HAVE_ZLIB
- def test_initialize_GET_uri
- req = Net::HTTP::Get.new(URI("http://example.com/foo"))
- assert_equal "/foo", req.path
- assert_equal "example.com", req['Host']
-
- req = Net::HTTP::Get.new(URI("https://example.com/foo"))
- assert_equal "/foo", req.path
- assert_equal "example.com", req['Host']
-
- assert_raise(ArgumentError){ Net::HTTP::Get.new(URI("urn:ietf:rfc:7231")) }
- assert_raise(ArgumentError){ Net::HTTP::Get.new(URI("http://")) }
- end
-
def test_header_set
req = Net::HTTP::Get.new '/'
diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb
index cfbe36bcfd..f8778522eb 100644
--- a/test/net/http/test_httpheader.rb
+++ b/test/net/http/test_httpheader.rb
@@ -31,11 +31,6 @@ class HTTPHeaderTest < Test::Unit::TestCase
assert_raise(ArgumentError){ @c.initialize_http_header("foo"=>"a\xff") }
end
- def test_initialize_with_symbol
- @c.initialize_http_header(foo: "abc")
- assert_equal "abc", @c["foo"]
- end
-
def test_size
assert_equal 0, @c.size
@c['a'] = 'a'
@@ -119,19 +114,7 @@ class HTTPHeaderTest < Test::Unit::TestCase
class D; include Net::HTTPHeader; end
def test_nil_variable_header
- assert_nothing_raised do
- assert_warning("#{__FILE__}:#{__LINE__+1}: warning: net/http: nil HTTP header: Authorization\n") do
- D.new.initialize_http_header({Authorization: nil})
- end
- end
- end
-
- def test_duplicated_variable_header
- assert_nothing_raised do
- assert_warning("#{__FILE__}:#{__LINE__+1}: warning: net/http: duplicated HTTP header: Authorization\n") do
- D.new.initialize_http_header({"AUTHORIZATION": "yes", "Authorization": "no"})
- end
- end
+ assert_nothing_raised { D.new.initialize_http_header({Authorization: nil}) }
end
def test_delete
diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb
index a03bb2e152..d99c3611c5 100644
--- a/test/net/http/test_httpresponse.rb
+++ b/test/net/http/test_httpresponse.rb
@@ -422,41 +422,11 @@ EOS
res = Net::HTTPResponse.read_new(io)
assert_equal(nil, res.message)
- assert_raise Net::HTTPClientException do
+ assert_raise Net::HTTPServerException do
res.error!
end
end
- def test_read_code_type
- res = Net::HTTPUnknownResponse.new('1.0', '???', 'test response')
- assert_equal Net::HTTPUnknownResponse, res.code_type
-
- res = Net::HTTPInformation.new('1.0', '1xx', 'test response')
- assert_equal Net::HTTPInformation, res.code_type
-
- res = Net::HTTPSuccess.new('1.0', '2xx', 'test response')
- assert_equal Net::HTTPSuccess, res.code_type
-
- res = Net::HTTPRedirection.new('1.0', '3xx', 'test response')
- assert_equal Net::HTTPRedirection, res.code_type
-
- res = Net::HTTPClientError.new('1.0', '4xx', 'test response')
- assert_equal Net::HTTPClientError, res.code_type
-
- res = Net::HTTPServerError.new('1.0', '5xx', 'test response')
- assert_equal Net::HTTPServerError, res.code_type
- end
-
- def test_inspect_response
- res = Net::HTTPUnknownResponse.new('1.0', '???', 'test response')
- assert_equal '#<Net::HTTPUnknownResponse ??? test response readbody=false>', res.inspect
-
- res = Net::HTTPUnknownResponse.new('1.0', '???', 'test response')
- socket = Net::BufferedIO.new(StringIO.new('test body'))
- res.reading_body(socket, true) {}
- assert_equal '#<Net::HTTPUnknownResponse ??? test response readbody=true>', res.inspect
- end
-
private
def dummy_io(str)
diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb
index a501222668..c1d486470a 100644
--- a/test/net/http/test_https.rb
+++ b/test/net/http/test_https.rb
@@ -44,88 +44,12 @@ class TestNetHTTPS < Test::Unit::TestCase
http.request_get("/") {|res|
assert_equal($test_net_http_data, res.body)
}
- # TODO: OpenSSL 1.1.1h seems to yield only SERVER_CERT; need to check the incompatibility
- certs.zip([CA_CERT, SERVER_CERT][-certs.size..]) do |actual, expected|
- assert_equal(expected.to_der, actual.to_der)
- end
+ assert_equal(CA_CERT.to_der, certs[0].to_der)
+ assert_equal(SERVER_CERT.to_der, certs[1].to_der)
rescue SystemCallError
skip $!
end
- def test_get_SNI
- http = Net::HTTP.new("localhost", config("port"))
- http.ipaddr = config('host')
- http.use_ssl = true
- http.cert_store = TEST_STORE
- certs = []
- http.verify_callback = Proc.new do |preverify_ok, store_ctx|
- certs << store_ctx.current_cert
- preverify_ok
- end
- http.request_get("/") {|res|
- assert_equal($test_net_http_data, res.body)
- }
- # TODO: OpenSSL 1.1.1h seems to yield only SERVER_CERT; need to check the incompatibility
- certs.zip([CA_CERT, SERVER_CERT][-certs.size..]) do |actual, expected|
- assert_equal(expected.to_der, actual.to_der)
- end
- end
-
- def test_get_SNI_proxy
- TCPServer.open("127.0.0.1", 0) {|serv|
- _, port, _, _ = serv.addr
- client_thread = Thread.new {
- proxy = Net::HTTP.Proxy("127.0.0.1", port, 'user', 'password')
- http = proxy.new("foo.example.org", 8000)
- http.ipaddr = "192.0.2.1"
- http.use_ssl = true
- http.cert_store = TEST_STORE
- certs = []
- http.verify_callback = Proc.new do |preverify_ok, store_ctx|
- certs << store_ctx.current_cert
- preverify_ok
- end
- begin
- http.start
- rescue EOFError
- end
- }
- server_thread = Thread.new {
- sock = serv.accept
- begin
- proxy_request = sock.gets("\r\n\r\n")
- assert_equal(
- "CONNECT 192.0.2.1:8000 HTTP/1.1\r\n" +
- "Host: foo.example.org:8000\r\n" +
- "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==\r\n" +
- "\r\n",
- proxy_request,
- "[ruby-dev:25673]")
- ensure
- sock.close
- end
- }
- assert_join_threads([client_thread, server_thread])
- }
-
- end
-
- def test_get_SNI_failure
- TestNetHTTPUtils.clean_http_proxy_env do
- http = Net::HTTP.new("invalid_servername", config("port"))
- http.ipaddr = config('host')
- http.use_ssl = true
- http.cert_store = TEST_STORE
- certs = []
- http.verify_callback = Proc.new do |preverify_ok, store_ctx|
- certs << store_ctx.current_cert
- preverify_ok
- end
- @log_tester = lambda {|_| }
- assert_raise(OpenSSL::SSL::SSLError){ http.start }
- end
- end
-
def test_post
http = Net::HTTP.new("localhost", config("port"))
http.use_ssl = true
diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb
index 53f3be0b88..dbfd112f31 100644
--- a/test/net/http/utils.rb
+++ b/test/net/http/utils.rb
@@ -107,23 +107,4 @@ module TestNetHTTPUtils
def print(*args) end
def printf(*args) end
end
-
- def self.clean_http_proxy_env
- orig = {
- 'http_proxy' => ENV['http_proxy'],
- 'http_proxy_user' => ENV['http_proxy_user'],
- 'http_proxy_pass' => ENV['http_proxy_pass'],
- 'no_proxy' => ENV['no_proxy'],
- }
-
- orig.each_key do |key|
- ENV.delete key
- end
-
- yield
- ensure
- orig.each do |key, value|
- ENV[key] = value
- end
- end
end
diff --git a/test/net/fixtures/Makefile b/test/net/imap/Makefile
index b2bc9c7368..b2bc9c7368 100644
--- a/test/net/fixtures/Makefile
+++ b/test/net/imap/Makefile
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index 0ce0eb67ba..41f25fe1c7 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -127,30 +127,12 @@ class IMAPTest < Test::Unit::TestCase
imap.disconnect
end
end
-
- def test_starttls_stripping
- starttls_stripping_test do |port|
- imap = Net::IMAP.new("localhost", :port => port)
- assert_raise(Net::IMAP::UnknownResponseError) do
- imap.starttls(:ca_file => CA_FILE)
- end
- imap
- end
- end
- end
-
- def start_server
- th = Thread.new do
- yield
- end
- @threads << th
- sleep 0.1 until th.stop?
end
def test_unexpected_eof
server = create_tcp_server
port = server.addr[1]
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -176,7 +158,7 @@ class IMAPTest < Test::Unit::TestCase
server = create_tcp_server
port = server.addr[1]
requests = []
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -223,7 +205,7 @@ class IMAPTest < Test::Unit::TestCase
server = create_tcp_server
port = server.addr[1]
requests = []
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -249,7 +231,7 @@ class IMAPTest < Test::Unit::TestCase
in_idle = false
exception_raised = false
c = m.new_cond
- raiser = Thread.start do
+ @threads << Thread.start do
m.synchronize do
until in_idle
c.wait(0.1)
@@ -261,7 +243,6 @@ class IMAPTest < Test::Unit::TestCase
c.signal
end
end
- @threads << raiser
imap.idle do |res|
m.synchronize do
in_idle = true
@@ -279,14 +260,13 @@ class IMAPTest < Test::Unit::TestCase
imap.logout
ensure
imap.disconnect if imap
- raiser.kill unless in_idle
end
end
def test_idle_done_not_during_idle
server = create_tcp_server
port = server.addr[1]
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -309,7 +289,7 @@ class IMAPTest < Test::Unit::TestCase
server = create_tcp_server
port = server.addr[1]
requests = []
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -365,7 +345,7 @@ class IMAPTest < Test::Unit::TestCase
def test_unexpected_bye
server = create_tcp_server
port = server.addr[1]
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK Gimap ready for requests from 75.101.246.151 33if2752585qyk.26\r\n")
@@ -387,7 +367,7 @@ class IMAPTest < Test::Unit::TestCase
def test_exception_during_shutdown
server = create_tcp_server
port = server.addr[1]
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -422,9 +402,7 @@ class IMAPTest < Test::Unit::TestCase
requests = []
sock = nil
threads = []
- started = false
threads << Thread.start do
- started = true
begin
sock = server.accept
sock.print("* OK test server\r\n")
@@ -435,7 +413,6 @@ class IMAPTest < Test::Unit::TestCase
server.close
end
end
- sleep 0.1 until started
threads << Thread.start do
imap = Net::IMAP.new(server_addr, :port => port)
begin
@@ -482,25 +459,16 @@ class IMAPTest < Test::Unit::TestCase
def test_connection_closed_without_greeting
server = create_tcp_server
port = server.addr[1]
- h = {'server before close': server.inspect} # inspect info before close
- start_server do
+ @threads << Thread.start do
begin
sock = server.accept
- h[:sock_addr], h[:sock_peeraddr] = sock.addr, sock.peeraddr
sock.close
ensure
server.close
end
end
assert_raise(Net::IMAP::Error) do
- #begin
Net::IMAP.new(server_addr, :port => port)
- #rescue Net::IMAP::Error
- # raise Errno::EINVAL
- #end
- rescue Errno::EINVAL => e # for debug on OpenCSW
- h.merge!({e: e, server: server, port: port, server_addr: server_addr})
- raise(h.inspect)
end
end
@@ -515,7 +483,7 @@ class IMAPTest < Test::Unit::TestCase
def test_send_invalid_number
server = create_tcp_server
port = server.addr[1]
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -567,7 +535,7 @@ class IMAPTest < Test::Unit::TestCase
port = server.addr[1]
requests = []
literal = nil
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -602,7 +570,7 @@ class IMAPTest < Test::Unit::TestCase
def test_disconnect
server = create_tcp_server
port = server.addr[1]
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -638,7 +606,7 @@ hello world
EOF
requests = []
received_mail = nil
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -660,7 +628,7 @@ EOF
begin
imap = Net::IMAP.new(server_addr, :port => port)
- imap.append("INBOX", mail)
+ resp = imap.append("INBOX", mail)
assert_equal(1, requests.length)
assert_equal("RUBY0001 APPEND INBOX {#{mail.size}}\r\n", requests[0])
assert_equal(mail, received_mail)
@@ -683,7 +651,8 @@ Subject: hello
hello world
EOF
requests = []
- start_server do
+ received_mail = nil
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -727,11 +696,9 @@ EOF
OpenSSL::X509::Certificate.new(f)
}
ssl_server = OpenSSL::SSL::SSLServer.new(server, ctx)
- started = false
ths = Thread.start do
Thread.current.report_on_exception = false # always join-ed
begin
- started = true
sock = ssl_server.accept
begin
sock.print("* OK test server\r\n")
@@ -744,7 +711,6 @@ EOF
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNABORTED
end
end
- sleep 0.1 until started
begin
begin
imap = yield(port)
@@ -761,7 +727,7 @@ EOF
def starttls_test
server = create_tcp_server
port = server.addr[1]
- start_server do
+ @threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
@@ -794,27 +760,6 @@ EOF
end
end
- def starttls_stripping_test
- server = create_tcp_server
- port = server.addr[1]
- start_server do
- sock = server.accept
- begin
- sock.print("* OK test server\r\n")
- sock.gets
- sock.print("RUBY0001 BUG unhandled command\r\n")
- ensure
- sock.close
- server.close
- end
- end
- begin
- imap = yield(port)
- ensure
- imap.disconnect if imap && !imap.disconnected?
- end
- end
-
def create_tcp_server
return TCPServer.new(server_addr, 0)
end
diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb
index 4e470459c9..12c8a27017 100644
--- a/test/net/imap/test_imap_response_parser.rb
+++ b/test/net/imap/test_imap_response_parser.rb
@@ -20,17 +20,28 @@ class IMAPResponseParserTest < Test::Unit::TestCase
end
end
+ def test_flag_list_safe
+ parser = Net::IMAP::ResponseParser.new
+ response = lambda {
+ $SAFE = 1
+ parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+* LIST (\\HasChildren) "." "INBOX"
+EOF
+ }.call
+ assert_equal [:Haschildren], response.data.attr
+ end
+
def test_flag_list_too_many_flags
parser = Net::IMAP::ResponseParser.new
assert_nothing_raised do
3.times do |i|
- parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* LIST (\\Foo#{i}) "." "INBOX"
EOF
end
end
assert_raise(Net::IMAP::FlagCountError) do
- parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* LIST (\\Foo3) "." "INBOX"
EOF
end
@@ -40,7 +51,7 @@ EOF
parser = Net::IMAP::ResponseParser.new
assert_nothing_raised do
100.times do
- parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* LIST (\\Foo) "." "INBOX"
EOF
end
@@ -49,7 +60,7 @@ EOF
def test_flag_xlist_inbox
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* XLIST (\\Inbox) "." "INBOX"
EOF
assert_equal [:Inbox], response.data.attr
@@ -57,7 +68,7 @@ EOF
def test_resp_text_code
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* OK [CLOSED] Previous mailbox closed.
EOF
assert_equal "CLOSED", response.data.code.name
@@ -65,15 +76,15 @@ EOF
def test_search_response
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* SEARCH
EOF
assert_equal [], response.data
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* SEARCH 1
EOF
assert_equal [1], response.data
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* SEARCH 1 2 3
EOF
assert_equal [1, 2, 3], response.data
@@ -81,11 +92,11 @@ EOF
def test_search_response_of_yahoo
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* SEARCH 1\s
EOF
assert_equal [1], response.data
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* SEARCH 1 2 3\s
EOF
assert_equal [1, 2, 3], response.data
@@ -93,12 +104,12 @@ EOF
def test_msg_att_extra_space
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* 1 FETCH (UID 92285)
EOF
assert_equal 92285, response.data.attr["UID"]
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* 1 FETCH (UID 92285 )
EOF
assert_equal 92285, response.data.attr["UID"]
@@ -107,7 +118,7 @@ EOF
def test_msg_att_parse_error
parser = Net::IMAP::ResponseParser.new
e = assert_raise(Net::IMAP::ResponseParseError) {
- parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* 123 FETCH (UNKNOWN 92285)
EOF
}
@@ -116,13 +127,13 @@ EOF
def test_msg_att_rfc822_text
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* 123 FETCH (RFC822 {5}
foo
)
EOF
assert_equal("foo\r\n", response.data.attr["RFC822"])
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* 123 FETCH (RFC822[] {5}
foo
)
@@ -133,7 +144,7 @@ EOF
# [Bug #6397] [ruby-core:44849]
def test_body_type_attachment
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* 980 FETCH (UID 2862 BODYSTRUCTURE ((("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 416 21 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 1493 32 NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "Boundary_(ID_IaecgfnXwG5bn3x8lIeGIQ)") NIL NIL)("MESSAGE" "RFC822" ("NAME" "Fw_ ____ _____ ____.eml") NIL NIL "7BIT" 1980088 NIL ("ATTACHMENT" ("FILENAME" "Fw_ ____ _____ ____.eml")) NIL) "MIXED" ("BOUNDARY" "Boundary_(ID_eDdLc/j0mBIzIlR191pHjA)") NIL NIL))
EOF
assert_equal("Fw_ ____ _____ ____.eml",
@@ -142,7 +153,7 @@ EOF
def assert_parseable(s)
parser = Net::IMAP::ResponseParser.new
- parser.parse(s.gsub(/\n/, "\r\n"))
+ parser.parse(s.gsub(/\n/, "\r\n").taint)
end
# [Bug #7146]
@@ -171,7 +182,7 @@ EOF
# [Bug #8167]
def test_msg_delivery_status_with_extra_data
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* 29021 FETCH (RFC822.SIZE 3162 UID 113622 RFC822.HEADER {1155}
Return-path: <>
Envelope-to: info@xxxxxxxx.si
@@ -214,7 +225,7 @@ EOF
# [Bug #8281]
def test_acl
parser = Net::IMAP::ResponseParser.new
- response = parser.parse(<<EOF.gsub(/\n/, "\r\n"))
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
* ACL "INBOX/share" "imshare2copy1366146467@xxxxxxxxxxxxxxxxxx.com" lrswickxteda
EOF
assert_equal("ACL", response.name)
diff --git a/test/net/protocol/test_protocol.rb b/test/net/protocol/test_protocol.rb
index d3dc2ccf4c..048526b1c7 100644
--- a/test/net/protocol/test_protocol.rb
+++ b/test/net/protocol/test_protocol.rb
@@ -26,97 +26,4 @@ class TestProtocol < Test::Unit::TestCase
assert_equal("\u3042\r\n.\r\n", sio.string)
end
end
-
- def create_mockio(capacity: 100, max: nil)
- mockio = Object.new
- mockio.instance_variable_set(:@str, +'')
- mockio.instance_variable_set(:@capacity, capacity)
- mockio.instance_variable_set(:@max, max)
- def mockio.string; @str; end
- def mockio.to_io; self; end
- def mockio.wait_writable(sec); sleep sec; false; end
- def mockio.write_nonblock(*strs, exception: true)
- if @capacity <= @str.bytesize
- if exception
- raise Net::WaitWritable
- else
- return :wait_writable
- end
- end
- len = 0
- max = @max ? [@capacity, @str.bytesize + @max].min : @capacity
- strs.each do |str|
- len1 = @str.bytesize
- break if max <= len1
- @str << str.byteslice(0, max - @str.bytesize)
- len2 = @str.bytesize
- len += len2 - len1
- end
- len
- end
- mockio
- end
-
- def test_write0_multibyte
- mockio = create_mockio(max: 1)
- io = Net::BufferedIO.new(mockio)
- assert_equal(3, io.write("\u3042"))
- end
-
- def test_write0_timeout
- mockio = create_mockio
- io = Net::BufferedIO.new(mockio)
- io.write_timeout = 0.1
- assert_raise(Net::WriteTimeout){ io.write("a"*1000) }
- end
-
- def test_write0_success
- mockio = create_mockio
- io = Net::BufferedIO.new(mockio)
- io.write_timeout = 0.1
- len = io.write("a"*10)
- assert_equal "a"*10, mockio.string
- assert_equal 10, len
- end
-
- def test_write0_success2
- mockio = create_mockio
- io = Net::BufferedIO.new(mockio)
- io.write_timeout = 0.1
- len = io.write("a"*100)
- assert_equal "a"*100, mockio.string
- assert_equal 100, len
- end
-
- def test_write0_success_multi1
- mockio = create_mockio
- io = Net::BufferedIO.new(mockio)
- io.write_timeout = 0.1
- len = io.write("a"*50, "a"*49)
- assert_equal "a"*99, mockio.string
- assert_equal 99, len
- end
-
- def test_write0_success_multi2
- mockio = create_mockio
- io = Net::BufferedIO.new(mockio)
- io.write_timeout = 0.1
- len = io.write("a"*50, "a"*50)
- assert_equal "a"*100, mockio.string
- assert_equal 100, len
- end
-
- def test_write0_timeout_multi1
- mockio = create_mockio
- io = Net::BufferedIO.new(mockio)
- io.write_timeout = 0.1
- assert_raise(Net::WriteTimeout){ io.write("a"*50,"a"*51) }
- end
-
- def test_write0_timeout_multi2
- mockio = create_mockio
- io = Net::BufferedIO.new(mockio)
- io.write_timeout = 0.1
- assert_raise(Net::WriteTimeout){ io.write("a"*50,"a"*50,"a") }
- end
end
diff --git a/test/net/smtp/test_smtp.rb b/test/net/smtp/test_smtp.rb
index 90c92e06f8..23e1542d8f 100644
--- a/test/net/smtp/test_smtp.rb
+++ b/test/net/smtp/test_smtp.rb
@@ -190,7 +190,7 @@ module Net
loop do
readable, = IO.select(servers.map(&:to_io))
readable.each do |r|
- sock, = r.accept_nonblock(exception: false)
+ sock, addr = r.accept_nonblock(exception: false)
next if sock == :wait_readable
return sock
end
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 336b30f75a..0e1ad327b9 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -98,22 +98,19 @@ class TestObjSpace < Test::Unit::TestCase
res = ObjectSpace.count_imemo_objects
assert_not_empty(res)
assert_not_nil(res[:imemo_cref])
- assert_not_empty res.inspect
-
arg = {}
res = ObjectSpace.count_imemo_objects(arg)
assert_not_empty(res)
end
def test_memsize_of_iseq
- iseqw = RubyVM::InstructionSequence.compile('def a; a = :b; a; end')
+ iseqw = RubyVM::InstructionSequence.compile('def a; a = :b; end')
base_obj_size = ObjectSpace.memsize_of(Object.new)
assert_operator(ObjectSpace.memsize_of(iseqw), :>, base_obj_size)
end
def test_reachable_objects_from
- opts = %w[--disable-gem --disable=frozen-string-literal -robjspace]
- assert_separately opts, "#{<<-"begin;"}\n#{<<-'end;'}"
+ assert_separately %w[--disable-gem -robjspace], "#{<<-"begin;"}\n#{<<-'end;'}"
begin;
assert_equal(nil, ObjectSpace.reachable_objects_from(nil))
assert_equal([Array, 'a', 'b', 'c'], ObjectSpace.reachable_objects_from(['a', 'b', 'c']))
@@ -235,8 +232,8 @@ class TestObjSpace < Test::Unit::TestCase
def test_dump_flags
info = ObjectSpace.dump("foo".freeze)
- assert_match(/"wb_protected":true, "old":true/, info)
- assert_match(/"fstring":true/, info)
+ assert_match /"wb_protected":true, "old":true/, info
+ assert_match /"fstring":true/, info
JSON.parse(info) if defined?(JSON)
end
@@ -268,10 +265,10 @@ class TestObjSpace < Test::Unit::TestCase
def assert_dump_object(info, line)
loc = caller_locations(1, 1)[0]
- assert_match(/"type":"STRING"/, info)
- assert_match(/"embedded":true, "bytesize":11, "value":"hello world", "encoding":"UTF-8"/, info)
- assert_match(/"file":"#{Regexp.escape __FILE__}", "line":#{line}/, info)
- assert_match(/"method":"#{loc.base_label}"/, info)
+ assert_match /"type":"STRING"/, info
+ assert_match /"embedded":true, "bytesize":11, "value":"hello world", "encoding":"UTF-8"/, info
+ assert_match /"file":"#{Regexp.escape __FILE__}", "line":#{line}/, info
+ assert_match /"method":"#{loc.base_label}"/, info
JSON.parse(info) if defined?(JSON)
end
@@ -286,8 +283,8 @@ class TestObjSpace < Test::Unit::TestCase
def test_dump_dynamic_symbol
dump = ObjectSpace.dump(("foobar%x" % rand(0x10000)).to_sym)
- assert_match(/"type":"SYMBOL"/, dump)
- assert_match(/"value":"foobar\h+"/, dump)
+ assert_match /"type":"SYMBOL"/, dump
+ assert_match /"value":"foobar\h+"/, dump
end
def test_dump_includes_imemo_type
@@ -321,67 +318,10 @@ class TestObjSpace < Test::Unit::TestCase
end
end
- def test_dump_addresses_match_dump_all_addresses
- assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error|
- begin;
- def dump_my_heap_please
- obj = Object.new
- puts ObjectSpace.dump(obj)
- ObjectSpace.dump_all(output: $stdout)
- end
-
- dump_my_heap_please
- end;
- needle = JSON.parse(output.first)
- addr = needle['address']
- found = output.drop(1).find { |l| JSON.parse(l)['address'] == addr }
- assert found, "object #{addr} should be findable in full heap dump"
- end
- end
-
- def test_dump_class_addresses_match_dump_all_addresses
- assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error|
- begin;
- def dump_my_heap_please
- obj = Object.new
- puts ObjectSpace.dump(obj)
- ObjectSpace.dump_all(output: $stdout)
- end
-
- dump_my_heap_please
- end;
- needle = JSON.parse(output.first)
- addr = needle['class']
- found = output.drop(1).find { |l| JSON.parse(l)['address'] == addr }
- assert found, "object #{addr} should be findable in full heap dump"
- end
- end
-
- def test_dump_reference_addresses_match_dump_all_addresses
- assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error|
- begin;
- def dump_my_heap_please
- obj = Object.new
- obj2 = Object.new
- obj2.instance_variable_set(:@ref, obj)
- puts ObjectSpace.dump(obj)
- ObjectSpace.dump_all(output: $stdout)
- end
-
- dump_my_heap_please
- end;
- needle = JSON.parse(output.first)
- addr = needle['address']
- found = output.drop(1).find { |l| (JSON.parse(l)['references'] || []).include? addr }
- assert found, "object #{addr} should be findable in full heap dump"
- end
- end
-
def test_dump_all
entry = /"bytesize":11, "value":"TEST STRING", "encoding":"UTF-8", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":/
- opts = %w[--disable-gem --disable=frozen-string-literal -robjspace]
- assert_in_out_err(opts, "#{<<-"begin;"}#{<<-'end;'}") do |output, error|
+ assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}#{<<-'end;'}") do |output, error|
begin;
def dump_my_heap_please
ObjectSpace.trace_object_allocations_start
@@ -400,16 +340,16 @@ class TestObjSpace < Test::Unit::TestCase
def dump_my_heap_please
ObjectSpace.trace_object_allocations_start
GC.start
- (str = "TEST STRING").force_encoding("UTF-8")
+ str = "TEST STRING".force_encoding("UTF-8")
ObjectSpace.dump_all().path
end
puts dump_my_heap_please
end;
- assert_nil(error)
- dump = File.readlines(output)
+ skip if /is not supported/ =~ error
+ skip error unless output
+ assert_match(entry, File.readlines(output).grep(/TEST STRING/).join("\n"))
File.unlink(output)
- assert_match(entry, dump.grep(/TEST STRING/).join("\n"))
end
if defined?(JSON)
@@ -432,8 +372,8 @@ class TestObjSpace < Test::Unit::TestCase
puts ObjectSpace.dump(File.allocate)
RUBY
assert_nil error
- assert_match(/"type":"FILE"/, output)
- assert_not_match(/"fd":/, output)
+ assert_match /"type":"FILE"/, output
+ assert_not_match /"fd":/, output
end
end
diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb
index 0c7d77c305..0301483902 100644
--- a/test/open-uri/test_open-uri.rb
+++ b/test/open-uri/test_open-uri.rb
@@ -68,18 +68,6 @@ class TestOpenURI < Test::Unit::TestCase
@proxies.each_with_index {|k, i| ENV[k] = @old_proxies[i] }
end
- def test_deprecated_kernel_open
- with_http {|srv, dr, url|
- srv.mount_proc("/foo200", lambda { |req, res| res.body = "foo200" } )
- assert_warning(/calling URI.open via Kernel#open is deprecated, call URI.open directly/) {
- open("#{url}/foo200") {|f|
- assert_equal("200", f.status[0])
- assert_equal("foo200", f.read)
- }
- }
- }
- end
-
def test_200_uri_open
with_http {|srv, dr, url|
srv.mount_proc("/urifoo200", lambda { |req, res| res.body = "urifoo200" } )
@@ -93,7 +81,7 @@ class TestOpenURI < Test::Unit::TestCase
def test_200
with_http {|srv, dr, url|
srv.mount_proc("/foo200", lambda { |req, res| res.body = "foo200" } )
- URI.open("#{url}/foo200") {|f|
+ open("#{url}/foo200") {|f|
assert_equal("200", f.status[0])
assert_equal("foo200", f.read)
}
@@ -104,7 +92,7 @@ class TestOpenURI < Test::Unit::TestCase
with_http {|srv, dr, url|
content = "foo200big"*10240
srv.mount_proc("/foo200big", lambda { |req, res| res.body = content } )
- URI.open("#{url}/foo200big") {|f|
+ open("#{url}/foo200big") {|f|
assert_equal("200", f.status[0])
assert_equal(content, f.read)
}
@@ -117,7 +105,7 @@ class TestOpenURI < Test::Unit::TestCase
assert_match(%r{ERROR `/not-exist' not found}, server_log[0])
}
with_http(log_tester) {|srv, dr, url, server_thread, server_log|
- exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/not-exist") {} }
+ exc = assert_raise(OpenURI::HTTPError) { open("#{url}/not-exist") {} }
assert_equal("404", exc.io.status[0])
}
end
@@ -126,7 +114,7 @@ class TestOpenURI < Test::Unit::TestCase
with_http {|srv, dr, url|
srv.mount_proc("/foo_ou", lambda { |req, res| res.body = "foo_ou" } )
u = URI("#{url}/foo_ou")
- URI.open(u) {|f|
+ open(u) {|f|
assert_equal("200", f.status[0])
assert_equal("foo_ou", f.read)
}
@@ -134,7 +122,7 @@ class TestOpenURI < Test::Unit::TestCase
end
def test_open_too_many_arg
- assert_raise(ArgumentError) { URI.open("http://192.0.2.1/tma", "r", 0666, :extra) {} }
+ assert_raise(ArgumentError) { open("http://192.0.2.1/tma", "r", 0666, :extra) {} }
end
def test_read_timeout
@@ -181,28 +169,28 @@ class TestOpenURI < Test::Unit::TestCase
end
def test_invalid_option
- assert_raise(ArgumentError) { URI.open("http://127.0.0.1/", :invalid_option=>true) {} }
+ assert_raise(ArgumentError) { open("http://127.0.0.1/", :invalid_option=>true) {} }
end
def test_mode
with_http {|srv, dr, url|
srv.mount_proc("/mode", lambda { |req, res| res.body = "mode" } )
- URI.open("#{url}/mode", "r") {|f|
+ open("#{url}/mode", "r") {|f|
assert_equal("200", f.status[0])
assert_equal("mode", f.read)
}
- URI.open("#{url}/mode", "r", 0600) {|f|
+ open("#{url}/mode", "r", 0600) {|f|
assert_equal("200", f.status[0])
assert_equal("mode", f.read)
}
- assert_raise(ArgumentError) { URI.open("#{url}/mode", "a") {} }
- URI.open("#{url}/mode", "r:us-ascii") {|f|
+ assert_raise(ArgumentError) { open("#{url}/mode", "a") {} }
+ open("#{url}/mode", "r:us-ascii") {|f|
assert_equal(Encoding::US_ASCII, f.read.encoding)
}
- URI.open("#{url}/mode", "r:utf-8") {|f|
+ open("#{url}/mode", "r:utf-8") {|f|
assert_equal(Encoding::UTF_8, f.read.encoding)
}
- assert_raise(ArgumentError) { URI.open("#{url}/mode", "r:invalid-encoding") {} }
+ assert_raise(ArgumentError) { open("#{url}/mode", "r:invalid-encoding") {} }
}
end
@@ -210,7 +198,7 @@ class TestOpenURI < Test::Unit::TestCase
with_http {|srv, dr, url|
srv.mount_proc("/without_block", lambda { |req, res| res.body = "without_block" } )
begin
- f = URI.open("#{url}/without_block")
+ f = open("#{url}/without_block")
assert_equal("200", f.status[0])
assert_equal("without_block", f.read)
ensure
@@ -223,7 +211,7 @@ class TestOpenURI < Test::Unit::TestCase
with_http {|srv, dr, url|
srv.mount_proc("/close200", lambda { |req, res| res.body = "close200" } )
assert_nothing_raised {
- URI.open("#{url}/close200") {|f|
+ open("#{url}/close200") {|f|
f.close
}
}
@@ -235,7 +223,7 @@ class TestOpenURI < Test::Unit::TestCase
content = "close200big"*10240
srv.mount_proc("/close200big", lambda { |req, res| res.body = content } )
assert_nothing_raised {
- URI.open("#{url}/close200big") {|f|
+ open("#{url}/close200big") {|f|
f.close
}
}
@@ -247,7 +235,7 @@ class TestOpenURI < Test::Unit::TestCase
myheader2 = nil
with_http {|srv, dr, url|
srv.mount_proc("/h/") {|req, res| myheader2 = req['myheader']; res.body = "foo" }
- URI.open("#{url}/h/", 'MyHeader'=>myheader1) {|f|
+ open("#{url}/h/", 'MyHeader'=>myheader1) {|f|
assert_equal("foo", f.read)
assert_equal(myheader1, myheader2)
}
@@ -256,13 +244,13 @@ class TestOpenURI < Test::Unit::TestCase
def test_multi_proxy_opt
assert_raise(ArgumentError) {
- URI.open("http://127.0.0.1/", :proxy_http_basic_authentication=>true, :proxy=>true) {}
+ open("http://127.0.0.1/", :proxy_http_basic_authentication=>true, :proxy=>true) {}
}
end
def test_non_http_proxy
assert_raise(RuntimeError) {
- URI.open("http://127.0.0.1/", :proxy=>URI("ftp://127.0.0.1/")) {}
+ open("http://127.0.0.1/", :proxy=>URI("ftp://127.0.0.1/")) {}
}
end
@@ -285,28 +273,28 @@ class TestOpenURI < Test::Unit::TestCase
begin
proxy_thread = proxy.start
srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
- URI.open("#{url}/proxy", :proxy=>proxy_url) {|f|
+ open("#{url}/proxy", :proxy=>proxy_url) {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear
- URI.open("#{url}/proxy", :proxy=>URI(proxy_url)) {|f|
+ open("#{url}/proxy", :proxy=>URI(proxy_url)) {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear
- URI.open("#{url}/proxy", :proxy=>nil) {|f|
+ open("#{url}/proxy", :proxy=>nil) {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
assert_equal("", proxy_auth_log); proxy_auth_log.clear
assert_raise(ArgumentError) {
- URI.open("#{url}/proxy", :proxy=>:invalid) {}
+ open("#{url}/proxy", :proxy=>:invalid) {}
}
assert_equal("", proxy_auth_log); proxy_auth_log.clear
with_env("http_proxy"=>proxy_url) {
# should not use proxy for 127.0.0.0/8.
- URI.open("#{url}/proxy") {|f|
+ open("#{url}/proxy") {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
@@ -342,7 +330,7 @@ class TestOpenURI < Test::Unit::TestCase
begin
th = proxy.start
srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
- exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/proxy", :proxy=>proxy_url) {} }
+ exc = assert_raise(OpenURI::HTTPError) { open("#{url}/proxy", :proxy=>proxy_url) {} }
assert_equal("407", exc.io.status[0])
assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear
ensure
@@ -375,14 +363,14 @@ class TestOpenURI < Test::Unit::TestCase
begin
th = proxy.start
srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
- URI.open("#{url}/proxy",
+ open("#{url}/proxy",
:proxy_http_basic_authentication=>[proxy_url, "user", "pass"]) {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
assert_match(/#{Regexp.quote url}/, proxy_auth_log); proxy_auth_log.clear
assert_raise(ArgumentError) {
- URI.open("#{url}/proxy",
+ open("#{url}/proxy",
:proxy_http_basic_authentication=>[true, "user", "pass"]) {}
}
assert_equal("", proxy_auth_log); proxy_auth_log.clear
@@ -416,7 +404,7 @@ class TestOpenURI < Test::Unit::TestCase
begin
th = proxy.start
srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
- URI.open("#{url}/proxy", :proxy => proxy_url) {|f|
+ open("#{url}/proxy", :proxy => proxy_url) {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
@@ -435,12 +423,12 @@ class TestOpenURI < Test::Unit::TestCase
srv.mount_proc("/r1/") {|req, res| res.status = 301; res["location"] = "#{url}/r2"; res.body = "r1" }
srv.mount_proc("/r2/") {|req, res| res.body = "r2" }
srv.mount_proc("/to-file/") {|req, res| res.status = 301; res["location"] = "file:///foo" }
- URI.open("#{url}/r1/") {|f|
+ open("#{url}/r1/") {|f|
assert_equal("#{url}/r2", f.base_uri.to_s)
assert_equal("r2", f.read)
}
- assert_raise(OpenURI::HTTPRedirect) { URI.open("#{url}/r1/", :redirect=>false) {} }
- assert_raise(RuntimeError) { URI.open("#{url}/to-file/") {} }
+ assert_raise(OpenURI::HTTPRedirect) { open("#{url}/r1/", :redirect=>false) {} }
+ assert_raise(RuntimeError) { open("#{url}/to-file/") {} }
}
end
@@ -448,7 +436,7 @@ class TestOpenURI < Test::Unit::TestCase
with_http {|srv, dr, url|
srv.mount_proc("/r1/") {|req, res| res.status = 301; res["location"] = "#{url}/r2"; res.body = "r1" }
srv.mount_proc("/r2/") {|req, res| res.status = 301; res["location"] = "#{url}/r1"; res.body = "r2" }
- assert_raise(RuntimeError) { URI.open("#{url}/r1/") {} }
+ assert_raise(RuntimeError) { open("#{url}/r1/") {} }
}
end
@@ -527,7 +515,7 @@ class TestOpenURI < Test::Unit::TestCase
def test_redirect_auth_success
with_http {|srv, dr, url|
setup_redirect_auth(srv, url)
- URI.open("#{url}/r2/", :http_basic_authentication=>['user', 'pass']) {|f|
+ open("#{url}/r2/", :http_basic_authentication=>['user', 'pass']) {|f|
assert_equal("r2", f.read)
}
}
@@ -540,7 +528,7 @@ class TestOpenURI < Test::Unit::TestCase
}
with_http(log_tester) {|srv, dr, url, server_thread, server_log|
setup_redirect_auth(srv, url)
- exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/r2/") {} }
+ exc = assert_raise(OpenURI::HTTPError) { open("#{url}/r2/") {} }
assert_equal("401", exc.io.status[0])
}
end
@@ -552,13 +540,13 @@ class TestOpenURI < Test::Unit::TestCase
}
with_http(log_tester) {|srv, dr, url, server_thread, server_log|
setup_redirect_auth(srv, url)
- exc = assert_raise(OpenURI::HTTPError) { URI.open("#{url}/r1/", :http_basic_authentication=>['user', 'pass']) {} }
+ exc = assert_raise(OpenURI::HTTPError) { open("#{url}/r1/", :http_basic_authentication=>['user', 'pass']) {} }
assert_equal("401", exc.io.status[0])
}
end
def test_userinfo
- assert_raise(ArgumentError) { URI.open("http://user:pass@127.0.0.1/") {} }
+ assert_raise(ArgumentError) { open("http://user:pass@127.0.0.1/") {} }
end
def test_progress
@@ -567,7 +555,7 @@ class TestOpenURI < Test::Unit::TestCase
srv.mount_proc("/data/") {|req, res| res.body = content }
length = []
progress = []
- URI.open("#{url}/data/",
+ open("#{url}/data/",
:content_length_proc => lambda {|n| length << n },
:progress_proc => lambda {|n| progress << n }
) {|f|
@@ -587,7 +575,7 @@ class TestOpenURI < Test::Unit::TestCase
srv.mount_proc("/data/") {|req, res| res.body = content; res.chunked = true }
length = []
progress = []
- URI.open("#{url}/data/",
+ open("#{url}/data/",
:content_length_proc => lambda {|n| length << n },
:progress_proc => lambda {|n| progress << n }
) {|f|
@@ -617,25 +605,25 @@ class TestOpenURI < Test::Unit::TestCase
srv.mount_proc("/u8/") {|req, res| res.body = content_u8; res['content-type'] = 'text/plain; charset=utf-8' }
srv.mount_proc("/ej/") {|req, res| res.body = content_ej; res['content-type'] = 'TEXT/PLAIN; charset=EUC-JP' }
srv.mount_proc("/nc/") {|req, res| res.body = "aa"; res['content-type'] = 'Text/Plain' }
- URI.open("#{url}/u8/") {|f|
+ open("#{url}/u8/") {|f|
assert_equal(content_u8, f.read)
assert_equal("text/plain", f.content_type)
assert_equal("utf-8", f.charset)
}
- URI.open("#{url}/ej/") {|f|
+ open("#{url}/ej/") {|f|
assert_equal(content_ej, f.read)
assert_equal("text/plain", f.content_type)
assert_equal("euc-jp", f.charset)
assert_equal(Encoding::EUC_JP, f.read.encoding)
}
- URI.open("#{url}/ej/", 'r:utf-8') {|f|
+ open("#{url}/ej/", 'r:utf-8') {|f|
# override charset with encoding option
assert_equal(content_ej.dup.force_encoding('utf-8'), f.read)
assert_equal("text/plain", f.content_type)
assert_equal("euc-jp", f.charset)
assert_equal(Encoding::UTF_8, f.read.encoding)
}
- URI.open("#{url}/ej/", :encoding=>'utf-8') {|f|
+ open("#{url}/ej/", :encoding=>'utf-8') {|f|
# override charset with encoding option
assert_equal(content_ej.dup.force_encoding('utf-8'), f.read)
assert_equal("text/plain", f.content_type)
@@ -643,12 +631,12 @@ class TestOpenURI < Test::Unit::TestCase
assert_equal(Encoding::UTF_8, f.read.encoding)
}
assert_raise(ArgumentError) {
- URI.open("#{url}/ej/", 'r:utf-8', :encoding=>'utf-8') {|f| }
+ open("#{url}/ej/", 'r:utf-8', :encoding=>'utf-8') {|f| }
}
- URI.open("#{url}/nc/") {|f|
+ open("#{url}/nc/") {|f|
assert_equal("aa", f.read)
assert_equal("text/plain", f.content_type)
- assert_equal("utf-8", f.charset)
+ assert_equal("iso-8859-1", f.charset)
assert_equal("unknown", f.charset { "unknown" })
}
}
@@ -658,7 +646,7 @@ class TestOpenURI < Test::Unit::TestCase
with_http {|srv, dr, url|
content_u8 = "\u3042"
srv.mount_proc("/qu8/") {|req, res| res.body = content_u8; res['content-type'] = 'text/plain; charset="utf\-8"' }
- URI.open("#{url}/qu8/") {|f|
+ open("#{url}/qu8/") {|f|
assert_equal(content_u8, f.read)
assert_equal("text/plain", f.content_type)
assert_equal("utf-8", f.charset)
@@ -669,7 +657,7 @@ class TestOpenURI < Test::Unit::TestCase
def test_last_modified
with_http {|srv, dr, url|
srv.mount_proc("/data/") {|req, res| res.body = "foo"; res['last-modified'] = 'Fri, 07 Aug 2009 06:05:04 GMT' }
- URI.open("#{url}/data/") {|f|
+ open("#{url}/data/") {|f|
assert_equal("foo", f.read)
assert_equal(Time.utc(2009,8,7,6,5,4), f.last_modified)
}
@@ -683,15 +671,15 @@ class TestOpenURI < Test::Unit::TestCase
srv.mount_proc("/data/") {|req, res| res.body = content_gz; res['content-encoding'] = 'gzip' }
srv.mount_proc("/data2/") {|req, res| res.body = content_gz; res['content-encoding'] = 'gzip'; res.chunked = true }
srv.mount_proc("/noce/") {|req, res| res.body = content_gz }
- URI.open("#{url}/data/") {|f|
+ open("#{url}/data/") {|f|
assert_equal [], f.content_encoding
assert_equal(content, f.read)
}
- URI.open("#{url}/data2/") {|f|
+ open("#{url}/data2/") {|f|
assert_equal [], f.content_encoding
assert_equal(content, f.read)
}
- URI.open("#{url}/noce/") {|f|
+ open("#{url}/noce/") {|f|
assert_equal [], f.content_encoding
assert_equal(content_gz, f.read.force_encoding("ascii-8bit"))
}
@@ -705,7 +693,7 @@ class TestOpenURI < Test::Unit::TestCase
res.cookies << "name2=value2; blabla"
res.body = "foo"
}
- URI.open("#{url}/mcookie/") {|f|
+ open("#{url}/mcookie/") {|f|
assert_equal("foo", f.read)
assert_equal(["name1=value1; blabla", "name2=value2; blabla"],
f.metas['set-cookie'].sort)
diff --git a/test/open-uri/test_ssl.rb b/test/open-uri/test_ssl.rb
index 4f645d83b9..948cb6a959 100644
--- a/test/open-uri/test_ssl.rb
+++ b/test/open-uri/test_ssl.rb
@@ -67,7 +67,7 @@ class TestOpenURISSL
def setup_validation(srv, dr)
cacert_filename = "#{dr}/cacert.pem"
- URI.open(cacert_filename, "w") {|f| f << CA_CERT }
+ open(cacert_filename, "w") {|f| f << CA_CERT }
srv.mount_proc("/data", lambda { |req, res| res.body = "ddd" } )
cacert_filename
end
@@ -75,7 +75,7 @@ class TestOpenURISSL
def test_validation_success
with_https {|srv, dr, url|
cacert_filename = setup_validation(srv, dr)
- URI.open("#{url}/data", :ssl_ca_cert => cacert_filename) {|f|
+ open("#{url}/data", :ssl_ca_cert => cacert_filename) {|f|
assert_equal("200", f.status[0])
assert_equal("ddd", f.read)
}
@@ -85,7 +85,7 @@ class TestOpenURISSL
def test_validation_noverify
with_https {|srv, dr, url|
setup_validation(srv, dr)
- URI.open("#{url}/data", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) {|f|
+ open("#{url}/data", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) {|f|
assert_equal("200", f.status[0])
assert_equal("ddd", f.read)
}
@@ -103,7 +103,7 @@ class TestOpenURISSL
end
with_https(log_tester) {|srv, dr, url, server_thread, server_log|
setup_validation(srv, dr)
- assert_raise(OpenSSL::SSL::SSLError) { URI.open("#{url}/data") {} }
+ assert_raise(OpenSSL::SSL::SSLError) { open("#{url}/data") {} }
}
end
@@ -149,7 +149,7 @@ class TestOpenURISSL
}
with_https_proxy(proxy_log_tester) {|srv, dr, url_, cacert_filename, cacert_directory, proxy_host, proxy_port|
url = url_
- URI.open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_filename) {|f|
+ open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_filename) {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
@@ -165,7 +165,7 @@ class TestOpenURISSL
}
with_https_proxy(proxy_log_tester) {|srv, dr, url_, cacert_filename, cacert_directory, proxy_host, proxy_port|
url = url_
- URI.open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_directory) {|f|
+ open("#{url}/proxy", :proxy=>"http://#{proxy_host}:#{proxy_port}/", :ssl_ca_cert => cacert_directory) {|f|
assert_equal("200", f.status[0])
assert_equal("proxy", f.read)
}
@@ -175,18 +175,18 @@ class TestOpenURISSL
end if defined?(OpenSSL::SSL)
if defined?(OpenSSL::SSL)
-# cp /etc/ssl/openssl.cnf . # I copied from OpenSSL 1.1.1b source
+# cp /etc/ssl/openssl.cnf . # I copied from OpenSSL 1.0.2h source
# mkdir demoCA demoCA/private demoCA/newcerts
# touch demoCA/index.txt
# echo 00 > demoCA/serial
-# openssl genrsa -des3 -out demoCA/private/cakey.pem 2048
+# openssl genrsa -des3 -out demoCA/private/cakey.pem 1024
# openssl req -new -key demoCA/private/cakey.pem -out demoCA/careq.pem -subj "/C=JP/ST=Tokyo/O=RubyTest/CN=Ruby Test CA"
# # basicConstraints=CA:TRUE is required; the default openssl.cnf has it in [v3_ca]
# openssl ca -config openssl.cnf -extensions v3_ca -out demoCA/cacert.pem -startdate 090101000000Z -enddate 491231235959Z -batch -keyfile demoCA/private/cakey.pem -selfsign -infiles demoCA/careq.pem
# mkdir server
-# openssl genrsa -des3 -out server/server.key 2048
+# openssl genrsa -des3 -out server/server.key 1024
# openssl req -new -key server/server.key -out server/csr.pem -subj "/C=JP/ST=Tokyo/O=RubyTest/CN=127.0.0.1"
# openssl ca -config openssl.cnf -startdate 090101000000Z -enddate 491231235959Z -in server/csr.pem -keyfile demoCA/private/cakey.pem -cert demoCA/cacert.pem -out server/cert.pem
@@ -199,7 +199,7 @@ Certificate:
Data:
Version: 3 (0x2)
Serial Number: 0 (0x0)
- Signature Algorithm: sha256WithRSAEncryption
+ Signature Algorithm: sha256WithRSAEncryption
Issuer: C=JP, ST=Tokyo, O=RubyTest, CN=Ruby Test CA
Validity
Not Before: Jan 1 00:00:00 2009 GMT
@@ -207,70 +207,49 @@ Certificate:
Subject: C=JP, ST=Tokyo, O=RubyTest, CN=Ruby Test CA
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
- RSA Public-Key: (2048 bit)
+ Public-Key: (1024 bit)
Modulus:
- 00:ad:f3:4d:5b:0b:01:54:cc:86:36:d1:93:6b:33:
- 56:25:90:61:d6:9a:a0:f4:24:20:ee:c8:14:ab:0f:
- 4b:89:d8:7c:bb:c0:f8:7f:fb:e9:a2:d5:1c:6b:6f:
- dc:5c:23:b1:49:aa:2c:e8:ca:43:48:64:69:4b:8a:
- bd:44:57:9b:14:d9:7a:b2:49:00:d6:c2:74:67:62:
- 52:1d:a9:32:df:fe:7a:22:20:49:83:e1:cb:3d:dc:
- 1a:2a:f0:36:20:c1:e8:c8:89:d4:51:1a:68:91:20:
- e0:ba:67:0a:b2:6b:f8:e3:8c:f5:ee:a1:36:b1:89:
- ec:23:b6:f2:39:a9:b9:2e:ea:de:d9:86:e5:42:11:
- 46:ed:10:9a:90:76:44:4e:4d:49:2d:49:e8:e3:cb:
- ff:7a:7d:80:cb:bf:c4:c3:69:ba:9c:60:4a:de:af:
- bf:26:78:b8:fb:46:d1:37:d0:89:ba:78:93:6a:37:
- a5:e9:58:e7:e2:e3:7d:7c:95:20:79:41:56:15:cd:
- b2:c6:3b:e1:b7:e7:ba:47:60:9a:05:b1:07:f3:26:
- 72:9d:3b:1b:02:18:3d:d5:de:e6:e9:30:a9:b5:8f:
- 15:1b:40:f9:64:61:54:d3:53:e8:c4:29:4a:89:f3:
- e5:0d:fd:16:61:ee:f2:6d:8a:45:a8:34:7e:53:46:
- 8e:87
+ 00:be:74:41:33:c9:1b:e1:12:78:6b:b4:52:2e:ae:
+ b6:e2:1e:58:65:57:2d:cb:07:3f:91:c9:53:7a:e7:
+ 2e:68:2c:0c:5d:8b:16:a7:42:4a:5c:6f:c7:aa:44:
+ ff:6d:c6:d7:49:0e:b1:5d:03:5b:51:ce:d5:cc:cd:
+ ab:69:cc:c2:43:76:b1:b2:30:3b:e7:f6:1f:3e:35:
+ 1d:21:75:41:96:eb:84:a0:34:6f:a4:5d:70:a2:b2:
+ d5:fe:b9:45:47:a1:e8:ca:e3:b7:bb:4d:37:1c:f3:
+ 96:d4:2d:80:85:cd:8e:31:96:53:92:a0:fe:e4:4c:
+ 16:47:5e:c8:27:32:70:a8:6b
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Subject Key Identifier:
- A0:7E:0B:AD:A3:AD:37:D7:21:0B:75:6F:8A:90:5F:8C:C9:69:DF:98
+ 71:DB:DC:BA:F6:7F:75:31:7A:ED:AB:8B:48:93:86:94:1A:FF:30:58
X509v3 Authority Key Identifier:
- keyid:A0:7E:0B:AD:A3:AD:37:D7:21:0B:75:6F:8A:90:5F:8C:C9:69:DF:98
+ keyid:71:DB:DC:BA:F6:7F:75:31:7A:ED:AB:8B:48:93:86:94:1A:FF:30:58
- X509v3 Basic Constraints: critical
+ X509v3 Basic Constraints:
CA:TRUE
Signature Algorithm: sha256WithRSAEncryption
- 06:ea:06:02:19:9a:cb:94:a2:7e:c0:86:71:66:e7:a5:71:46:
- a2:25:55:f5:e5:58:df:d1:91:58:e6:8a:0e:91:b3:22:4c:88:
- 4d:5f:02:af:0f:73:65:0d:af:9a:f2:e4:36:f3:1f:e8:28:1d:
- 9c:74:72:5b:f7:12:e8:fa:45:d6:df:e5:f1:d3:91:f4:0e:db:
- e2:56:63:ee:82:57:6f:12:ad:d7:0d:de:5a:8c:3d:76:d2:87:
- c9:48:1c:c4:f3:89:63:3c:c2:25:e0:dd:63:a6:4c:6c:5a:07:
- 7b:86:78:62:86:02:a1:ef:0e:41:75:c5:d4:61:ab:c3:3b:9b:
- 51:0b:e6:34:6d:0b:14:5a:2d:aa:d3:58:26:43:8f:4c:d7:45:
- 73:1e:67:66:5e:f3:0c:69:70:27:a1:d5:70:f3:5a:10:98:c8:
- 4f:8a:3b:9f:ad:8e:8d:49:8f:fb:f6:36:5d:4f:70:f9:4f:54:
- 33:cf:a2:a6:1d:8c:61:b9:30:42:f2:49:d1:3d:a1:f1:eb:1e:
- 78:a6:30:f8:8a:48:89:c7:3e:bd:0d:d8:72:04:a6:00:e5:62:
- a4:13:3f:9e:b6:86:25:dc:d1:ff:3a:fc:f5:0e:e4:0e:f7:b8:
- 66:90:fe:4f:c2:54:2a:7f:61:6e:e7:4b:bf:40:7e:75:30:02:
- 5b:bb:91:1b
+ 91:1c:45:a5:c0:4e:fc:54:39:62:33:80:7d:03:c1:b8:51:f7:
+ 56:83:6c:a3:15:50:cf:92:a0:77:a3:34:16:b5:30:f0:33:5a:
+ be:6a:ac:17:87:70:f8:4e:4d:49:ac:8b:84:fd:e5:0f:15:d7:
+ 9a:29:cc:a9:f5:97:f5:13:2a:86:3b:2d:f4:b7:b4:a2:7c:e1:
+ 0e:2a:ff:91:64:31:8f:12:cc:99:bf:e1:de:8f:6f:7c:1b:e4:
+ cc:56:c8:bb:85:c9:ba:df:7f:07:7a:cd:03:22:2c:b6:f8:06:
+ 35:72:72:b8:52:eb:62:15:85:2b:8f:8c:bc:27:3c:8b:de:32:
+ db:95
-----BEGIN CERTIFICATE-----
-MIIDXDCCAkSgAwIBAgIBADANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQGEwJKUDEO
+MIICVDCCAb2gAwIBAgIBADANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQGEwJKUDEO
MAwGA1UECAwFVG9reW8xETAPBgNVBAoMCFJ1YnlUZXN0MRUwEwYDVQQDDAxSdWJ5
IFRlc3QgQ0EwHhcNMDkwMTAxMDAwMDAwWhcNNDkxMjMxMjM1OTU5WjBHMQswCQYD
VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xETAPBgNVBAoMCFJ1YnlUZXN0MRUwEwYD
-VQQDDAxSdWJ5IFRlc3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
-AQCt801bCwFUzIY20ZNrM1YlkGHWmqD0JCDuyBSrD0uJ2Hy7wPh/++mi1Rxrb9xc
-I7FJqizoykNIZGlLir1EV5sU2XqySQDWwnRnYlIdqTLf/noiIEmD4cs93Boq8DYg
-wejIidRRGmiRIOC6Zwqya/jjjPXuoTaxiewjtvI5qbku6t7ZhuVCEUbtEJqQdkRO
-TUktSejjy/96fYDLv8TDabqcYErer78meLj7RtE30Im6eJNqN6XpWOfi4318lSB5
-QVYVzbLGO+G357pHYJoFsQfzJnKdOxsCGD3V3ubpMKm1jxUbQPlkYVTTU+jEKUqJ
-8+UN/RZh7vJtikWoNH5TRo6HAgMBAAGjUzBRMB0GA1UdDgQWBBSgfguto6031yEL
-dW+KkF+MyWnfmDAfBgNVHSMEGDAWgBSgfguto6031yELdW+KkF+MyWnfmDAPBgNV
-HRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAG6gYCGZrLlKJ+wIZxZuel
-cUaiJVX15Vjf0ZFY5ooOkbMiTIhNXwKvD3NlDa+a8uQ28x/oKB2cdHJb9xLo+kXW
-3+Xx05H0DtviVmPugldvEq3XDd5ajD120ofJSBzE84ljPMIl4N1jpkxsWgd7hnhi
-hgKh7w5BdcXUYavDO5tRC+Y0bQsUWi2q01gmQ49M10VzHmdmXvMMaXAnodVw81oQ
-mMhPijufrY6NSY/79jZdT3D5T1Qzz6KmHYxhuTBC8knRPaHx6x54pjD4ikiJxz69
-DdhyBKYA5WKkEz+etoYl3NH/Ovz1DuQO97hmkP5PwlQqf2Fu50u/QH51MAJbu5Eb
+VQQDDAxSdWJ5IFRlc3QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL50
+QTPJG+ESeGu0Ui6utuIeWGVXLcsHP5HJU3rnLmgsDF2LFqdCSlxvx6pE/23G10kO
+sV0DW1HO1czNq2nMwkN2sbIwO+f2Hz41HSF1QZbrhKA0b6RdcKKy1f65RUeh6Mrj
+t7tNNxzzltQtgIXNjjGWU5Kg/uRMFkdeyCcycKhrAgMBAAGjUDBOMB0GA1UdDgQW
+BBRx29y69n91MXrtq4tIk4aUGv8wWDAfBgNVHSMEGDAWgBRx29y69n91MXrtq4tI
+k4aUGv8wWDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4GBAJEcRaXATvxU
+OWIzgH0DwbhR91aDbKMVUM+SoHejNBa1MPAzWr5qrBeHcPhOTUmsi4T95Q8V15op
+zKn1l/UTKoY7LfS3tKJ84Q4q/5FkMY8SzJm/4d6Pb3wb5MxWyLuFybrffwd6zQMi
+LLb4BjVycrhS62IVhSuPjLwnPIveMtuV
-----END CERTIFICATE-----
End
@@ -279,7 +258,7 @@ Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
- Signature Algorithm: sha256WithRSAEncryption
+ Signature Algorithm: sha256WithRSAEncryption
Issuer: C=JP, ST=Tokyo, O=RubyTest, CN=Ruby Test CA
Validity
Not Before: Jan 1 00:00:00 2009 GMT
@@ -287,26 +266,17 @@ Certificate:
Subject: C=JP, ST=Tokyo, O=RubyTest, CN=127.0.0.1
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
- RSA Public-Key: (2048 bit)
+ Public-Key: (1024 bit)
Modulus:
- 00:cb:b3:71:95:12:70:fc:db:d4:a9:a7:66:d6:d3:
- 09:dd:06:80:19:e1:f2:d6:1e:31:b6:6b:20:75:51:
- dc:a7:37:a9:ac:5b:57:5d:69:36:b6:de:1d:2c:f6:
- 44:64:f8:e8:d6:f0:da:38:6a:ba:c2:b1:9e:dc:bb:
- 79:94:e0:25:0c:ce:76:87:17:5d:79:9e:14:9e:bd:
- 4c:0d:aa:74:10:3a:96:ef:76:82:d5:72:16:b5:c1:
- ac:17:2d:90:83:73:5c:d7:a6:f5:36:0f:4c:55:f3:
- 30:5d:19:dc:01:0e:f8:e6:fe:a5:ad:52:88:59:dc:
- 4a:07:ed:a2:eb:a1:01:63:c4:8a:92:ba:06:80:9b:
- 0d:85:f2:9f:f9:70:ac:d7:ad:f0:7a:3f:b8:92:2a:
- 33:ca:69:d0:01:65:5d:31:38:1d:f6:1f:b2:17:07:
- 7e:ac:88:67:a6:c4:5f:3e:93:94:61:e6:e4:49:9d:
- ba:d4:d2:e8:e3:93:d1:66:79:c5:e3:1d:f8:5a:50:
- 54:58:3d:04:b0:fd:65:d1:b3:8a:b5:8a:30:5f:b2:
- dc:34:1a:14:f7:74:4c:03:29:97:63:5a:d7:de:bb:
- eb:7f:4a:2a:90:59:c0:2b:47:09:82:8f:75:de:14:
- 3f:bc:78:9a:69:25:80:5b:6c:a0:65:12:0d:29:61:
- ac:f9
+ 00:bb:bd:74:69:53:58:50:24:79:f2:eb:db:8b:97:
+ e4:69:a4:dd:48:0c:40:35:62:42:b3:35:8c:96:2a:
+ 62:76:98:b5:2a:e0:f8:78:33:b6:ff:f8:55:bf:44:
+ 69:21:d7:b5:0e:bd:8a:dd:31:1b:88:d5:b4:5e:7a:
+ 82:e0:ba:99:6c:04:76:e9:ff:e6:f8:f5:06:8e:7e:
+ a4:db:db:eb:43:44:12:a7:ca:ca:2b:aa:5f:83:10:
+ e2:9e:35:55:e8:e8:af:be:c8:7d:bb:c2:d4:aa:c1:
+ 1c:57:0b:c0:0c:3a:1d:6e:23:a9:03:26:7c:ea:8c:
+ f0:86:61:ce:f1:ff:42:c7:23
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
@@ -314,167 +284,104 @@ Certificate:
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
- EC:6B:7C:79:B8:3B:11:1D:42:F3:9A:2A:CF:9A:15:59:D7:F9:D8:C6
+ 7F:17:5A:58:88:96:E1:1F:44:EA:FF:AD:C6:2E:90:E2:95:32:DD:F0
X509v3 Authority Key Identifier:
- keyid:A0:7E:0B:AD:A3:AD:37:D7:21:0B:75:6F:8A:90:5F:8C:C9:69:DF:98
+ keyid:71:DB:DC:BA:F6:7F:75:31:7A:ED:AB:8B:48:93:86:94:1A:FF:30:58
Signature Algorithm: sha256WithRSAEncryption
- 29:14:db:71:e9:a0:86:f8:cc:4d:e4:8a:76:78:a7:ff:4e:94:
- b4:4d:92:dc:57:9a:52:64:46:27:15:8b:4f:2a:18:a7:0d:fc:
- d2:75:ce:4e:49:97:0b:46:71:57:23:e3:a5:c0:c5:71:94:fc:
- f2:1d:3b:06:93:82:03:59:56:d4:fb:09:06:08:b4:97:50:33:
- cf:58:89:dd:91:31:07:26:9a:7e:7f:8d:71:de:09:dc:4f:e5:
- 6b:a3:10:71:d4:50:24:43:a0:1c:f5:2a:d9:1a:fb:e3:d6:f1:
- bc:6b:42:67:16:b4:3b:31:f4:ec:03:7d:78:e2:64:16:57:6d:
- ba:7c:0c:e1:14:b2:7c:75:4e:2b:09:3e:86:e4:aa:cc:7e:5c:
- 2b:bd:8d:26:4d:49:36:74:86:fe:c5:a6:15:4a:af:e8:b4:4e:
- d5:f2:e1:59:c2:fb:7e:c3:c4:f1:63:d8:c2:b0:9a:ae:31:96:
- 90:c3:09:d0:ce:2e:31:90:d7:83:dd:ac:31:cc:f7:87:41:08:
- 92:33:28:52:fa:2d:9e:ad:ae:6a:9f:c3:be:ce:c1:a6:e4:16:
- 2f:69:34:40:86:b6:10:21:0e:31:69:81:9e:fc:fd:c3:06:25:
- 65:37:d3:d9:4a:20:84:aa:e7:0e:60:7c:bf:3f:88:67:ac:e5:
- 8c:e0:61:d6
+ 1c:80:02:67:f0:4e:a8:5a:6a:73:9c:de:75:ad:7d:2e:e9:ce:
+ c3:2e:cd:70:b4:21:d9:42:0d:7c:0e:77:9e:97:91:13:02:77:
+ 4a:cd:f6:fc:26:3d:42:2e:08:85:05:10:df:3a:5f:f0:77:85:
+ 44:29:41:dd:03:6b:eb:e7:c8:89:8e:d1:57:a8:ac:43:c8:85:
+ c3:95:64:9f:a5:6e:e9:2e:6e:06:45:21:36:ec:d5:79:f5:0e:
+ a8:53:b5:f7:02:b0:59:12:e3:ae:73:25:fd:18:ab:23:b2:fc:
+ a9:f9:60:e5:a7:d8:ba:0f:db:be:17:81:25:90:fd:7a:21:cb:
+ fa:8b
-----BEGIN CERTIFICATE-----
-MIIDgTCCAmmgAwIBAgIBATANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQGEwJKUDEO
+MIICfDCCAeWgAwIBAgIBATANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQGEwJKUDEO
MAwGA1UECAwFVG9reW8xETAPBgNVBAoMCFJ1YnlUZXN0MRUwEwYDVQQDDAxSdWJ5
IFRlc3QgQ0EwHhcNMDkwMTAxMDAwMDAwWhcNNDkxMjMxMjM1OTU5WjBEMQswCQYD
VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xETAPBgNVBAoMCFJ1YnlUZXN0MRIwEAYD
-VQQDDAkxMjcuMC4wLjEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDL
-s3GVEnD829Spp2bW0wndBoAZ4fLWHjG2ayB1UdynN6msW1ddaTa23h0s9kRk+OjW
-8No4arrCsZ7cu3mU4CUMznaHF115nhSevUwNqnQQOpbvdoLVcha1wawXLZCDc1zX
-pvU2D0xV8zBdGdwBDvjm/qWtUohZ3EoH7aLroQFjxIqSugaAmw2F8p/5cKzXrfB6
-P7iSKjPKadABZV0xOB32H7IXB36siGemxF8+k5Rh5uRJnbrU0ujjk9FmecXjHfha
-UFRYPQSw/WXRs4q1ijBfstw0GhT3dEwDKZdjWtfeu+t/SiqQWcArRwmCj3XeFD+8
-eJppJYBbbKBlEg0pYaz5AgMBAAGjezB5MAkGA1UdEwQCMAAwLAYJYIZIAYb4QgEN
-BB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBTsa3x5
-uDsRHULzmirPmhVZ1/nYxjAfBgNVHSMEGDAWgBSgfguto6031yELdW+KkF+MyWnf
-mDANBgkqhkiG9w0BAQsFAAOCAQEAKRTbcemghvjMTeSKdnin/06UtE2S3FeaUmRG
-JxWLTyoYpw380nXOTkmXC0ZxVyPjpcDFcZT88h07BpOCA1lW1PsJBgi0l1Azz1iJ
-3ZExByaafn+Ncd4J3E/la6MQcdRQJEOgHPUq2Rr749bxvGtCZxa0OzH07AN9eOJk
-FldtunwM4RSyfHVOKwk+huSqzH5cK72NJk1JNnSG/sWmFUqv6LRO1fLhWcL7fsPE
-8WPYwrCarjGWkMMJ0M4uMZDXg92sMcz3h0EIkjMoUvotnq2uap/Dvs7BpuQWL2k0
-QIa2ECEOMWmBnvz9wwYlZTfT2UoghKrnDmB8vz+IZ6zljOBh1g==
+VQQDDAkxMjcuMC4wLjEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALu9dGlT
+WFAkefLr24uX5Gmk3UgMQDViQrM1jJYqYnaYtSrg+Hgztv/4Vb9EaSHXtQ69it0x
+G4jVtF56guC6mWwEdun/5vj1Bo5+pNvb60NEEqfKyiuqX4MQ4p41Vejor77IfbvC
+1KrBHFcLwAw6HW4jqQMmfOqM8IZhzvH/QscjAgMBAAGjezB5MAkGA1UdEwQCMAAw
+LAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0G
+A1UdDgQWBBR/F1pYiJbhH0Tq/63GLpDilTLd8DAfBgNVHSMEGDAWgBRx29y69n91
+MXrtq4tIk4aUGv8wWDANBgkqhkiG9w0BAQsFAAOBgQAcgAJn8E6oWmpznN51rX0u
+6c7DLs1wtCHZQg18Dneel5ETAndKzfb8Jj1CLgiFBRDfOl/wd4VEKUHdA2vr58iJ
+jtFXqKxDyIXDlWSfpW7pLm4GRSE27NV59Q6oU7X3ArBZEuOucyX9GKsjsvyp+WDl
+p9i6D9u+F4ElkP16Icv6iw==
-----END CERTIFICATE-----
End
TestOpenURISSL::SERVER_KEY = <<'End'
-RSA Private-Key: (2048 bit, 2 primes)
+Private-Key: (1024 bit)
modulus:
- 00:cb:b3:71:95:12:70:fc:db:d4:a9:a7:66:d6:d3:
- 09:dd:06:80:19:e1:f2:d6:1e:31:b6:6b:20:75:51:
- dc:a7:37:a9:ac:5b:57:5d:69:36:b6:de:1d:2c:f6:
- 44:64:f8:e8:d6:f0:da:38:6a:ba:c2:b1:9e:dc:bb:
- 79:94:e0:25:0c:ce:76:87:17:5d:79:9e:14:9e:bd:
- 4c:0d:aa:74:10:3a:96:ef:76:82:d5:72:16:b5:c1:
- ac:17:2d:90:83:73:5c:d7:a6:f5:36:0f:4c:55:f3:
- 30:5d:19:dc:01:0e:f8:e6:fe:a5:ad:52:88:59:dc:
- 4a:07:ed:a2:eb:a1:01:63:c4:8a:92:ba:06:80:9b:
- 0d:85:f2:9f:f9:70:ac:d7:ad:f0:7a:3f:b8:92:2a:
- 33:ca:69:d0:01:65:5d:31:38:1d:f6:1f:b2:17:07:
- 7e:ac:88:67:a6:c4:5f:3e:93:94:61:e6:e4:49:9d:
- ba:d4:d2:e8:e3:93:d1:66:79:c5:e3:1d:f8:5a:50:
- 54:58:3d:04:b0:fd:65:d1:b3:8a:b5:8a:30:5f:b2:
- dc:34:1a:14:f7:74:4c:03:29:97:63:5a:d7:de:bb:
- eb:7f:4a:2a:90:59:c0:2b:47:09:82:8f:75:de:14:
- 3f:bc:78:9a:69:25:80:5b:6c:a0:65:12:0d:29:61:
- ac:f9
+ 00:bb:bd:74:69:53:58:50:24:79:f2:eb:db:8b:97:
+ e4:69:a4:dd:48:0c:40:35:62:42:b3:35:8c:96:2a:
+ 62:76:98:b5:2a:e0:f8:78:33:b6:ff:f8:55:bf:44:
+ 69:21:d7:b5:0e:bd:8a:dd:31:1b:88:d5:b4:5e:7a:
+ 82:e0:ba:99:6c:04:76:e9:ff:e6:f8:f5:06:8e:7e:
+ a4:db:db:eb:43:44:12:a7:ca:ca:2b:aa:5f:83:10:
+ e2:9e:35:55:e8:e8:af:be:c8:7d:bb:c2:d4:aa:c1:
+ 1c:57:0b:c0:0c:3a:1d:6e:23:a9:03:26:7c:ea:8c:
+ f0:86:61:ce:f1:ff:42:c7:23
publicExponent: 65537 (0x10001)
privateExponent:
- 12:be:d5:b2:01:3b:72:99:8c:4d:7c:81:43:3d:b2:
- 87:ab:84:78:5d:49:aa:98:a6:bc:81:c9:3f:e2:a3:
- aa:a3:bd:b2:85:c9:59:68:48:47:b5:d2:fb:83:42:
- 32:04:91:f0:cd:c3:57:33:c3:32:0d:84:70:0d:b4:
- 97:95:b4:f3:23:c0:d6:97:b8:db:6b:47:bc:7f:f1:
- 12:c4:df:df:6a:74:df:5e:89:95:b8:e5:0c:1e:e1:
- 86:54:84:1b:04:af:c3:8c:b2:be:21:d4:45:88:96:
- a7:ca:ac:6b:50:84:69:45:7f:db:9e:5f:bb:dd:40:
- d6:cf:f0:91:3c:84:d3:38:65:c9:15:f7:9e:37:aa:
- 1a:2e:bc:16:b6:95:be:bc:af:45:76:ba:ad:99:f6:
- ef:6a:e8:fd:f0:31:89:19:c4:04:67:a1:ec:c4:79:
- 59:08:77:ab:0b:65:88:88:02:b1:38:5c:80:4e:27:
- 78:b2:a5:bd:b5:ad:d5:9c:4c:ea:ad:db:05:56:25:
- 70:28:da:22:fb:d8:de:8c:3b:78:fe:3e:cf:ed:1b:
- f9:97:c6:b6:4a:bf:60:08:8f:dc:85:5e:b1:49:ab:
- 87:8b:68:72:f4:6a:3f:bc:db:a3:6c:f7:e8:b0:15:
- bb:4b:ba:37:49:a2:d1:7c:f8:4f:1b:05:11:22:d9:
- 81
+ 00:af:3a:ec:17:0a:f5:d9:07:d2:d3:4c:15:c5:3b:
+ 66:b4:bc:6e:d5:ba:a9:8b:aa:45:3b:63:f5:ee:8b:
+ 6d:0f:e9:04:e0:1a:cf:8f:d2:25:32:d1:a5:a7:3a:
+ c1:2e:17:5a:25:82:00:c4:e7:fb:1d:42:ea:71:6c:
+ c4:0f:e1:db:23:ff:1e:d6:c8:d6:60:ca:2d:06:fc:
+ 54:3c:03:d4:09:96:bb:38:7a:22:a1:61:2c:f7:d0:
+ d0:90:6c:9f:61:ba:61:30:5a:aa:64:ad:43:3a:53:
+ 38:e8:ba:cc:8c:51:3e:68:3e:3a:6a:0f:5d:5d:e0:
+ d6:df:f2:54:93:d3:14:22:a1
prime1:
- 00:fb:d2:cb:14:61:00:c1:7a:83:ba:fe:79:97:a2:
- 4d:5a:ea:40:78:96:6e:d2:be:71:5b:c6:2c:1f:c9:
- 18:48:6b:ae:20:86:87:b5:08:0b:17:69:ca:93:cd:
- 00:36:22:51:7b:d5:2d:8c:0c:0e:de:bc:86:a8:07:
- 0e:c5:57:e4:df:be:ed:7d:cc:b1:a4:d6:a8:2b:00:
- 65:2a:69:30:5e:dc:6d:6d:c4:c8:7e:20:34:eb:6f:
- 5e:cf:b3:b8:2e:8d:56:31:44:a8:17:ea:be:65:19:
- ff:da:14:e0:0c:73:56:14:08:47:4c:5b:79:51:74:
- 5d:bc:e7:fe:01:2f:55:27:69
+ 00:e8:ec:11:fe:e6:2b:23:21:29:d5:40:a6:11:ec:
+ 4c:ae:4d:08:2a:71:18:ac:d1:3e:40:2f:12:41:59:
+ 12:09:e2:f7:c2:d7:6b:0a:96:0a:06:e3:90:6a:4e:
+ b2:eb:25:b7:09:68:e9:13:ab:d0:5a:29:7a:e4:72:
+ 1a:ee:46:a0:8b
prime2:
- 00:cf:14:54:47:bb:5f:5d:d6:2b:2d:ed:a6:8a:6f:
- 36:fc:47:5e:9f:84:ae:aa:1f:f8:44:50:91:15:f5:
- ed:9d:29:d9:2b:2a:19:66:56:2e:96:15:b5:8e:a9:
- 7f:89:27:21:b5:57:55:7e:2a:c5:8c:93:fe:f6:0a:
- a5:17:15:91:91:b3:7d:35:1a:d5:9a:2e:b8:0d:ad:
- e6:97:6d:83:a3:27:29:ee:00:74:ef:57:34:f3:07:
- ad:12:43:37:0c:5c:b7:26:34:bc:4e:3a:43:65:6b:
- 0c:b8:23:ac:77:fd:b2:23:eb:7b:65:70:f6:96:c4:
- 17:2c:aa:24:b8:a5:5e:b7:11
+ 00:ce:57:5e:31:e9:c9:a8:5b:1f:55:af:67:e2:49:
+ 2a:af:90:b6:02:c0:32:2f:ca:ae:1e:de:47:81:73:
+ a8:f8:37:53:70:93:24:62:77:d4:b8:80:30:9f:65:
+ 26:20:46:ae:5a:65:6e:6d:af:68:4c:8d:e8:3c:f3:
+ d1:d1:d9:6e:c9
exponent1:
- 00:92:32:ae:f4:05:dd:0a:76:b6:43:b9:b9:9d:ee:
- fc:39:ec:05:c1:fc:94:1a:85:b6:0a:31:e3:2c:10:
- f3:a8:17:db:df:c6:3a:c3:3f:08:31:6f:99:cc:75:
- 17:ca:55:e2:38:a2:6a:ef:03:91:1e:7f:15:2e:37:
- ea:bb:67:6b:d8:fa:5f:a6:c9:4f:d9:03:46:5e:b0:
- bc:0b:03:46:b1:cc:07:3b:d3:23:13:16:5f:a2:cf:
- e5:9b:70:1b:5d:eb:70:3e:ea:3d:2c:a5:7c:23:f6:
- 14:33:e8:2a:ab:0f:ca:c9:96:84:ce:2f:cd:1f:1d:
- 0f:ce:bc:61:1b:0e:ff:c1:01
+ 03:f1:02:b8:f2:82:26:5d:08:4d:30:83:de:e7:c5:
+ c0:69:53:4b:0c:90:e3:53:c3:1e:e8:ed:01:28:15:
+ b3:0f:21:2c:2d:e3:04:d1:d7:27:98:b0:37:ec:4f:
+ 00:c5:a9:9c:42:27:37:8a:ff:c2:96:d3:1a:8c:87:
+ c2:22:75:d3
exponent2:
- 00:9e:0b:f3:03:48:73:d1:e7:9a:cf:13:f9:ae:e0:
- 91:03:dc:e8:d0:30:f1:2a:30:fa:48:11:81:9a:54:
- 37:c5:62:e2:37:fa:8a:a6:3b:92:94:c3:fe:ec:e2:
- 5a:cf:70:09:5f:21:47:c3:e2:9b:21:de:f6:92:0c:
- af:d1:bd:89:7b:bd:95:0b:49:ee:cb:1d:6b:26:2d:
- 9a:b7:ea:42:b4:ec:38:29:49:39:f6:4e:05:c0:93:
- 14:39:c3:09:29:ab:3d:b1:b0:40:24:28:7d:b5:d3:
- 0d:43:21:1f:09:f9:9b:d3:a4:6f:6a:8d:db:f6:57:
- b5:24:46:bb:7e:1d:e0:fb:31
+ 6f:17:32:ab:84:c7:01:51:2d:e9:9f:ea:3a:36:52:
+ 38:fb:9c:42:96:df:6e:43:9c:c3:19:c1:3d:bc:db:
+ 77:e7:b1:90:a6:67:ac:6b:ff:a6:e5:bd:47:d3:d9:
+ 56:ff:36:d7:8c:4c:8b:d9:28:3a:2f:1c:9d:d4:57:
+ 5e:b7:c5:a1
coefficient:
- 10:93:1d:c8:33:a5:c1:d3:84:6a:22:68:e5:60:cc:
- 9c:27:0a:52:0b:58:a3:0c:83:f4:f4:46:09:0c:a1:
- 41:a6:ea:bf:80:9d:0e:5d:d8:3d:25:00:c5:a1:35:
- 7a:8c:ea:95:16:94:c3:7c:8f:2b:e0:53:ea:66:ae:
- 19:be:55:04:3d:ee:e2:4b:a8:69:1b:7e:d8:09:7f:
- ed:7c:ee:95:88:10:dc:4b:5b:bf:81:a4:e8:dc:7e:
- 4f:e5:c3:90:c4:e5:5a:90:10:32:d6:08:b5:1f:5d:
- 09:18:d8:44:28:e4:c4:c7:07:75:9b:9b:b3:80:86:
- 68:9d:fe:68:f3:4d:db:66
-writing RSA key
+ 45:50:47:66:56:e9:21:d9:40:0e:af:3f:f2:05:77:
+ ab:e7:08:40:97:88:2a:51:b3:7e:86:b0:b2:03:2e:
+ 6d:36:3f:46:42:97:7d:5a:a2:93:6c:05:c2:8b:8b:
+ 2d:af:d5:7d:75:e9:70:f0:2d:21:e3:b9:cf:4d:9a:
+ c4:97:e2:79
-----BEGIN RSA PRIVATE KEY-----
-MIIEpAIBAAKCAQEAy7NxlRJw/NvUqadm1tMJ3QaAGeHy1h4xtmsgdVHcpzeprFtX
-XWk2tt4dLPZEZPjo1vDaOGq6wrGe3Lt5lOAlDM52hxddeZ4Unr1MDap0EDqW73aC
-1XIWtcGsFy2Qg3Nc16b1Ng9MVfMwXRncAQ745v6lrVKIWdxKB+2i66EBY8SKkroG
-gJsNhfKf+XCs163wej+4kiozymnQAWVdMTgd9h+yFwd+rIhnpsRfPpOUYebkSZ26
-1NLo45PRZnnF4x34WlBUWD0EsP1l0bOKtYowX7LcNBoU93RMAymXY1rX3rvrf0oq
-kFnAK0cJgo913hQ/vHiaaSWAW2ygZRINKWGs+QIDAQABAoIBABK+1bIBO3KZjE18
-gUM9soerhHhdSaqYpryByT/io6qjvbKFyVloSEe10vuDQjIEkfDNw1czwzINhHAN
-tJeVtPMjwNaXuNtrR7x/8RLE399qdN9eiZW45Qwe4YZUhBsEr8OMsr4h1EWIlqfK
-rGtQhGlFf9ueX7vdQNbP8JE8hNM4ZckV9543qhouvBa2lb68r0V2uq2Z9u9q6P3w
-MYkZxARnoezEeVkId6sLZYiIArE4XIBOJ3iypb21rdWcTOqt2wVWJXAo2iL72N6M
-O3j+Ps/tG/mXxrZKv2AIj9yFXrFJq4eLaHL0aj+826Ns9+iwFbtLujdJotF8+E8b
-BREi2YECgYEA+9LLFGEAwXqDuv55l6JNWupAeJZu0r5xW8YsH8kYSGuuIIaHtQgL
-F2nKk80ANiJRe9UtjAwO3ryGqAcOxVfk377tfcyxpNaoKwBlKmkwXtxtbcTIfiA0
-629ez7O4Lo1WMUSoF+q+ZRn/2hTgDHNWFAhHTFt5UXRdvOf+AS9VJ2kCgYEAzxRU
-R7tfXdYrLe2mim82/Eden4Suqh/4RFCRFfXtnSnZKyoZZlYulhW1jql/iSchtVdV
-firFjJP+9gqlFxWRkbN9NRrVmi64Da3ml22Doycp7gB071c08wetEkM3DFy3JjS8
-TjpDZWsMuCOsd/2yI+t7ZXD2lsQXLKokuKVetxECgYEAkjKu9AXdCna2Q7m5ne78
-OewFwfyUGoW2CjHjLBDzqBfb38Y6wz8IMW+ZzHUXylXiOKJq7wORHn8VLjfqu2dr
-2PpfpslP2QNGXrC8CwNGscwHO9MjExZfos/lm3AbXetwPuo9LKV8I/YUM+gqqw/K
-yZaEzi/NHx0PzrxhGw7/wQECgYEAngvzA0hz0eeazxP5ruCRA9zo0DDxKjD6SBGB
-mlQ3xWLiN/qKpjuSlMP+7OJaz3AJXyFHw+KbId72kgyv0b2Je72VC0nuyx1rJi2a
-t+pCtOw4KUk59k4FwJMUOcMJKas9sbBAJCh9tdMNQyEfCfmb06Rvao3b9le1JEa7
-fh3g+zECgYAQkx3IM6XB04RqImjlYMycJwpSC1ijDIP09EYJDKFBpuq/gJ0OXdg9
-JQDFoTV6jOqVFpTDfI8r4FPqZq4ZvlUEPe7iS6hpG37YCX/tfO6ViBDcS1u/gaTo
-3H5P5cOQxOVakBAy1gi1H10JGNhEKOTExwd1m5uzgIZonf5o803bZg==
+MIICXAIBAAKBgQC7vXRpU1hQJHny69uLl+RppN1IDEA1YkKzNYyWKmJ2mLUq4Ph4
+M7b/+FW/RGkh17UOvYrdMRuI1bReeoLguplsBHbp/+b49QaOfqTb2+tDRBKnysor
+ql+DEOKeNVXo6K++yH27wtSqwRxXC8AMOh1uI6kDJnzqjPCGYc7x/0LHIwIDAQAB
+AoGBAK867BcK9dkH0tNMFcU7ZrS8btW6qYuqRTtj9e6LbQ/pBOAaz4/SJTLRpac6
+wS4XWiWCAMTn+x1C6nFsxA/h2yP/HtbI1mDKLQb8VDwD1AmWuzh6IqFhLPfQ0JBs
+n2G6YTBaqmStQzpTOOi6zIxRPmg+OmoPXV3g1t/yVJPTFCKhAkEA6OwR/uYrIyEp
+1UCmEexMrk0IKnEYrNE+QC8SQVkSCeL3wtdrCpYKBuOQak6y6yW3CWjpE6vQWil6
+5HIa7kagiwJBAM5XXjHpyahbH1WvZ+JJKq+QtgLAMi/Krh7eR4FzqPg3U3CTJGJ3
+1LiAMJ9lJiBGrlplbm2vaEyN6Dzz0dHZbskCQAPxArjygiZdCE0wg97nxcBpU0sM
+kONTwx7o7QEoFbMPISwt4wTR1yeYsDfsTwDFqZxCJzeK/8KW0xqMh8IiddMCQG8X
+MquExwFRLemf6jo2Ujj7nEKW325DnMMZwT2823fnsZCmZ6xr/6blvUfT2Vb/NteM
+TIvZKDovHJ3UV163xaECQEVQR2ZW6SHZQA6vP/IFd6vnCECXiCpRs36GsLIDLm02
+P0ZCl31aopNsBcKLiy2v1X116XDwLSHjuc9NmsSX4nk=
-----END RSA PRIVATE KEY-----
End
diff --git a/test/openssl/fixtures/pkey/dh-1.pem b/test/openssl/fixtures/pkey/dh-1.pem
deleted file mode 100644
index 3340a6a188..0000000000
--- a/test/openssl/fixtures/pkey/dh-1.pem
+++ /dev/null
@@ -1,13 +0,0 @@
------BEGIN DH PARAMETERS-----
-MIICCAKCAgEAvRzXYxY6L2DjeYmm1eowtMDu1it3j+VwFr6s6PRWzc1apMtztr9G
-xZ2mYndUAJLgNLO3n2fUDCYVMB6ZkcekW8Siocof3xWiMA6wqZ6uw0dsE3q7ZX+6
-TLjgSjaXeGvjutvuEwVrFeaUi83bMgfXN8ToxIQVprIF35sYFt6fpbFATKfW7qqi
-P1pQkjmCskU4tztaWvlLh0qg85wuQGnpJaQT3gS30378i0IGbA0EBvJcSpTHYbLa
-nsdI9bfN/ZVgeolVMNMU9/n8R8vRhNPcHuciFwaqS656q+HavCIyxw/LfjSwwFvR
-TngCn0wytRErkzFIXnRKckh8/BpI4S+0+l1NkOwG4WJ55KJ/9OOdZW5o/QCp2bDi
-E0JN1EP/gkSom/prq8JR/yEqtsy99uc5nUxPmzv0IgdcFHZEfiQU7iRggEbx7qfQ
-Ve55XksmmJInmpCy1bSabAEgIKp8Ckt5KLYZ0RgTXUhcEpsxEo6cuAwoSJT5o4Rp
-yG3xow2ozPcqZkvb+d2CHj1sc54w9BVFAjVANEKmRil/9WKz14bu3wxEhOPqC54n
-QojjLcoXSoT66ZUOQnYxTSiLtzoKGPy8cAVPbkBrXz2u2sj5gcvr1JjoGjdHm9/3
-qnqC8fsTz8UndKNIQC337o4K0833bQMzRGl1/qjbAPit2B7E3b6xTZMCAQI=
------END DH PARAMETERS-----
diff --git a/test/openssl/fixtures/pkey/rsa-1.pem b/test/openssl/fixtures/pkey/rsa-1.pem
deleted file mode 100644
index bd5a624f6b..0000000000
--- a/test/openssl/fixtures/pkey/rsa-1.pem
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJJwIBAAKCAgEArIEJUYZrXhMfUXXdl2gLcXrRB4ciWNEeXt5UVLG0nPhygZwJ
-xis8tOrjXOJEpUXUsfgF35pQiJLD4T9/Vp3zLFtMOOQjOR3AxjIelbH9KPyGFEr9
-TcPtsJ24zhcG7RbwOGXR4iIcDaTx+bCLSAd7BjG3XHQtyeepGGRZkGyGUvXjPorH
-XP+dQjQnMd09wv0GMZSqQ06PedUUKQ4PJRfMCP+mwjFP+rB3NZuThF0CsNmpoixg
-GdoQ591Yrf5rf2Bs848JrYdqJlKlBL6rTFf2glHiC+mE5YRny7RZtv/qIkyUNotV
-ce1cE0GFrRmCpw9bqulDDcgKjFkhihTg4Voq0UYdJ6Alg7Ur4JerKTfyCaRGF27V
-fh/g2A2/6Vu8xKYYwTAwLn+Tvkx9OTVZ1t15wM7Ma8hHowNoO0g/lWkeltgHLMji
-rmeuIYQ20BQmdx2RRgWKl57D0wO/N0HIR+Bm4vcBoNPgMlk9g5WHA6idHR8TLxOr
-dMMmTiWfefB0/FzGXBv7DuuzHN3+urdCvG1QIMFQ06kHXhr4rC28KbWIxg+PJGM8
-oGNEGtGWAOvi4Ov+BVsIdbD5Sfyb4nY3L9qqPl6TxRxMWTKsYCYx11jC8civCzOu
-yL1z+wgIICJ6iGzrfYf6C2BiNV3BC1YCtp2XsG+AooIxCwjL2CP/54MuRnUCAwEA
-AQKCAgAP4+8M0HoRd2d6JIZeDRqIwIyCygLy9Yh7qrVP+/KsRwKdR9dqps73x29c
-Pgeexdj67+Lynw9uFT7v/95mBzTAUESsNO+9sizw1OsWVQgB/4kGU4YT5Ml/bHf6
-nApqSqOkPlTgJM46v4f+vTGHWBEQGAJRBO62250q/wt1D1osSDQ/rZ8BxRYiZBV8
-NWocDRzF8nDgtFrpGSS7R21DuHZ2Gb6twscgS6MfkA49sieuTM6gfr/3gavu/+fM
-V1Rlrmc65GE61++CSjijQEEdTjkJ9isBd+hjEBhTnnBpOBfEQxOgFqOvU/MYXv/G
-W0Q6yWJjUwt3OIcoOImrY5L3j0vERneA1Alweqsbws3fXXMjA+jhLxlJqjPvSAKc
-POi7xu7QCJjSSLAzHSDPdmGmfzlrbdWS1h0mrC5YZYOyToLajfnmAlXNNrytnePg
-JV9/1136ZFrJyEi1JVN3kyrC+1iVd1E+lWK0U1UQ6/25tJvKFc1I+xToaUbK10UN
-ycXib7p2Zsc/+ZMlPRgCxWmpIHmKhnwbO7vtRunnnc6wzhvlQQNHWlIvkyQukV50
-6k/bzWw0M6A98B4oCICIcxcpS3njDlHyL7NlkCD+/OfZp6X3RZF/m4grmA2doebz
-glsaNMyGHFrpHkHq19Y63Y4jtBdW/XuBv06Cnr4r3BXdjEzzwQKCAQEA5bj737Nk
-ZLA0UgzVVvY67MTserTOECIt4i37nULjRQwsSFiz0AWFOBwUCBJ5N2qDEelbf0Fa
-t4VzrphryEgzLz/95ZXi+oxw1liqCHi8iHeU2wSclDtx2jKv2q7bFvFSaH4CKC4N
-zBJNfP92kdXuAjXkbK/jWwr64fLNh/2KFWUAmrYmtGfnOjjyL+yZhPxBatztE58q
-/T61pkvP9NiLfrr7Xq8fnzrwqGERhXKueyoK6ig9ZJPZ2VTykMUUvNYJJ7OYQZru
-EYA3zkuEZifqmjgF57Bgg7dkkIh285TzH3CNf3MCMTmjlWVyHjlyeSPYgISB9Mys
-VKKQth+SvYcChQKCAQEAwDyCcolA7+bQBfECs6GXi7RYy2YSlx562S5vhjSlY9Ko
-WiwVJWviF7uSBdZRnGUKoPv4K4LV34o2lJpSSTi5Xgp7FH986VdGePe3p4hcXSIZ
-NtsKImLVLnEjrmkZExfQl7p0MkcU/LheCf/eEZVp0Z84O54WCs6GRm9wHYIUyrag
-9FREqqxTRVNhQQ2EDVGq1slREdwB+aygE76axK/qosk0RaoLzGZiMn4Sb8bpJxXO
-mee+ftq5bayVltfR0DhC8eHkcPPFeQMll1g+ML7HbINwHTr01ONm3cFUO4zOLBOO
-ws/+vtNfiv6S/lO1RQSRoiApbENBLdSc3V8Cy70PMQKCAQBOcZN4uP5gL5c+KWm0
-T1KhxUDnSdRPyAwY/xC7i7qlullovvlv4GK0XUot03kXBkUJmcEHvF5o6qYtCZlM
-g/MOgHCHtF4Upl5lo1M0n13pz8PB4lpBd+cR1lscdrcTp4Y3bkf4RnmppNpXA7kO
-ZZnnoVWGE620ShSPkWTDuj0rvxisu+SNmClqRUXWPZnSwnzoK9a86443efF3fs3d
-UxCXTuxFUdGfgvXo2XStOBMCtcGSYflM3fv27b4C13mUXhY0O2yTgn8m9LyZsknc
-xGalENpbWmwqrjYl8KOF2+gFZV68FZ67Bm6otkJ4ta80VJw6joT9/eIe6IA34KIw
-G+ktAoIBAFRuPxzvC4ZSaasyX21l25mQbC9pdWDKEkqxCmp3VOyy6R4xnlgBOhwS
-VeAacV2vQyvRfv4dSLIVkkNSRDHEqCWVlNk75TDXFCytIAyE54xAHbLqIVlY7yim
-qHVB07F/FC6PxdkPPziAAU2DA5XVedSHibslg6jbbD4jU6qiJ1+hNrAZEs+jQC+C
-n4Ri20y+Qbp0URb2+icemnARlwgr+3HjzQGL3gK4NQjYNmDBjEWOXl9aWWB90FNL
-KahGwfAhxcVW4W56opCzwR7nsujV4eDXGba83itidRuQfd5pyWOyc1E86TYGwD/b
-79OkEElv6Ea8uXTDVS075GmWATRapQECggEAd9ZAbyT+KouTfi2e6yLOosxSZfns
-eF06QAJi5n9GOtdfK5fqdmHJqJI7wbubCnd0oxPeL71lRjrOAMXufaQRdZtfXSMn
-B1TljteNrh1en5xF451rCPR/Y6tNKBvIKnhy1waO27/vA+ovXrm17iR9rRuGZ29i
-IurlKA6z/96UdrSdpqITTCyTjSOBYg34f49ueGjlpL4+8HJq2wor4Cb1Sbv8ErqA
-bsQ/Jz+KIGUiuFCfNa6d6McPRXIrGgzpprXgfimkV3nj49QyrnuCF/Pc4psGgIaN
-l3EiGXzRt/55K7DQVadtbcjo9zREac8QnDD6dS/gOfJ82L7frQfMpNWgQA==
------END RSA PRIVATE KEY-----
diff --git a/test/openssl/fixtures/pkey/rsa-2.pem b/test/openssl/fixtures/pkey/rsa-2.pem
deleted file mode 100644
index e4fd4f4370..0000000000
--- a/test/openssl/fixtures/pkey/rsa-2.pem
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJKAIBAAKCAgEA1HUbx825tG7+/ulC5DpDogzXqM2/KmeCwGXZY4XjiWa+Zj7b
-ECkZwQh7zxFUsPixGqQKJSyFwCogdaPzYTRNtqKKaw/IWS0um1PTn4C4/9atbIsf
-HVKu/fWg4VrZL+ixFIZxa8Z6pvTB2omMcx+uEzbXPsO01i1pHf7MaWBxUDGFyC9P
-lASJBfFZAf2Ar1H99OTS4SP+gxM9Kk5tcc22r8uFiqqbhJmQNSDApdHvT1zSZxAc
-T1BFEZqfmR0B0UegPyJc/9hW0dYpB9JjR29UaZRSta3LUMpqltoOF5bzaKVgMuBm
-Qy79xJ71LjGp8bKhgRaWXyPsDzAC0MQlOW6En0v8LK8fntivJEvw9PNOMcZ8oMTn
-no0NeVt32HiQJW8LIVo7dOLVFtguSBMWUVe8mdKbuIIULD6JlSYke9Ob6andUhzO
-U79m/aRWs2yjD6o5QAktjFBARdPgcpTdWfppc8xpJUkQgRmVhINoIMT9W6Wl898E
-P4aPx6mRV/k05ellN3zRgd9tx5dyNuj3RBaNmR47cAVvGYRQgtH9bQYs6jtf0oer
-A5yIYEKspNRlZZJKKrQdLflQFOEwjQJyZnTk7Mp0y21wOuEGgZBexew55/hUJDC2
-mQ8CqjV4ki/Mm3z6Cw3jXIMNBJkH7oveBGSX0S9bF8A/73oOCU3W/LkORxECAwEA
-AQKCAgBLK7RMmYmfQbaPUtEMF2FesNSNMV72DfHBSUgFYpYDQ4sSeiLgMOqf1fSY
-azVf+F4RYwED7iDUwRMDDKNMPUlR2WjIQKlOhCH9a0dxJAZQ3xA1W3QC2AJ6cLIf
-ihlWTip5bKgszekPsYH1ZL2A7jCVM84ssuoE7cRHjKOelTUCfsMq9TJe2MvyglZP
-0fX6EjSctWm3pxiiH+iAU4d9wJ9my8fQLFUiMYNIiPIguYrGtbzsIlMh7PDDLcZS
-UmUWOxWDwRDOpSjyzadu0Q23dLiVMpmhFoDdcQENptFdn1c4K2tCFQuZscKwEt4F
-HiVXEzD5j5hcyUT4irA0VXImQ+hAH3oSDmn7wyHvyOg0bDZpUZXEHXb83Vvo54/d
-Fb4AOUva1dwhjci8CTEMxCENMy/CLilRv46AeHbOX8KMPM7BnRSJPptvTTh/qB9C
-HI5hxfkO+EOYnu0kUlxhJfrqG86H4IS+zA8HWiSEGxQteMjUQfgJoBzJ94YChpzo
-ePpKSpjxxl1PNNWKxWM3yUvlKmI2lNl6YNC8JpF2wVg4VvYkG7iVjleeRg21ay89
-NCVMF98n3MI5jdzfDKACnuYxg7sw+gjMy8PSoFvQ5pvHuBBOpa8tho6vk7bLJixT
-QY5uXMNQaO6OwpkBssKpnuXhIJzDhO48nSjJ5nUEuadPH1nGwQKCAQEA7twrUIMi
-Vqze/X6VyfEBnX+n3ZyQHLGqUv/ww1ZOOHmSW5ceC4GxHa8EPDjoh9NEjYffwGq9
-bfQh9Gntjk5gFipT/SfPrIhbPt59HthUqVvOGgSErCmn0vhsa0+ROpVi4K2WHS7O
-7SEwnoCWd6p1omon2olVY0ODlMH4neCx/ZuKV8SRMREubABlL8/MLp37AkgKarTY
-tewd0lpaZMvsjOhr1zVCGUUBxy87Fc7OKAcoQY8//0r8VMH7Jlga7F2PKVPzqRKf
-tjeW5jMAuRxTqtEdIeclJZwvUMxvb23BbBE+mtvKpXv69TB3DK8T1YIkhW2CidZW
-lad4MESC+QFNbQKCAQEA47PtULM/0ZFdE+PDDHOa2kJ2arm94sVIqF2168ZLXR69
-NkvCWfjkUPDeejINCx7XQgk0d/+5BCvrJpcM7lE4XfnYVNtPpct1el6eTfaOcPU8
-wAMsnq5n9Mxt02U+XRPtEqGk+lt0KLPDDSG88Z7jPmfftigLyPH6i/ZJyRUETlGk
-rGnWSx/LFUxQU5aBa2jUCjKOKa+OOk2jGg50A5Cmk26v9sA/ksOHisMjfdIpZc9P
-r4R0IteDDD5awlkWTF++5u1GpgU2yav4uan0wzY8OWYFzVyceA6+wffEcoplLm82
-CPd/qJOB5HHkjoM+CJgfumFxlNtdowKvKNUxpoQNtQKCAQEAh3ugofFPp+Q0M4r6
-gWnPZbuDxsLIR05K8vszYEjy4zup1YO4ygQNJ24fM91/n5Mo/jJEqwqgWd6w58ax
-tRclj00BCMXtGMrbHqTqSXWhR9LH66AGdPTHuXWpYZDnKliTlic/z1u+iWhbAHyl
-XEj2omIeKunc4gnod5cyYrKRouz3omLfi/pX33C19FGkWgjH2HpuViowBbhhDfCr
-9yJoEWC/0njl/hlTMdzLYcpEyxWMMuuC/FZXG+hPgWdWFh3XVzTEL3Fd3+hWEkp5
-rYWwu2ITaSiHvHaDrAvZZVXW8WoynXnvzr+tECgmTq57zI4eEwSTl4VY5VfxZ0dl
-FsIzXQKCAQBC07GYd6MJPGJWzgeWhe8yk0Lxu6WRAll6oFYd5kqD/9uELePSSAup
-/actsbbGRrziMpVlinWgVctjvf0bjFbArezhqqPLgtTtnwtS0kOnvzGfIM9dms4D
-uGObISGWa5yuVSZ4G5MRxwA9wGMVfo4u6Iltin868FmZ7iRlkXd8DNYJi95KmgAe
-NhF1FrzQ6ykf/QpgDZfuYI63vPorea6JonieMHn39s622OJ3sNBZguheGL+E4j8h
-vsMgOskijQ8X8xdC7lDQC1qqEsk06ZvvNJQLW1zIl3tArhjHjPp5EEaJhym+Ldx3
-UT3E3Zu9JfhZ2PNevqrShp0lnLw/pI3pAoIBAAUMz5Lj6V9ftsl1pTa8WDFeBJW0
-Wa5AT1BZg/ip2uq2NLPnA5JWcD+v682fRSvIj1pU0DRi6VsXlzhs+1q3+sgqiXGz
-u2ArFylh8TvC1gXUctXKZz/M3Rqr6aSNoejUGLmvHre+ja/k6Zwmu6ePtB7dL50d
-6+xMTYquS4gLbrbSLcEu3iBAAnvRLreXK4KguPxaBdICB7v7epdpAKe3Z7hp/sst
-eJj1+6KRdlcmt8fh5MPkBBXa6I/9XGmX5UEo7q4wAxeM9nuFWY3watz/EO9LiO6P
-LmqUSWL65m4cX0VZPvhYEsHppKi1eoWGlHqS4Af5+aIXi2alu2iljQFeA+Q=
------END RSA PRIVATE KEY-----
diff --git a/test/openssl/fixtures/pkey/rsa-3.pem b/test/openssl/fixtures/pkey/rsa-3.pem
deleted file mode 100644
index 6c9c9cedd2..0000000000
--- a/test/openssl/fixtures/pkey/rsa-3.pem
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJKAIBAAKCAgEAzn+YCcOh7BIRzrb7TEuhQLD545+/Fx/zCYO3l+y/8ogUxMTg
-LG5HrcXlX3JP796ie90/GHIf8/lwczVhP1jk/keYjkwoTYDt477R7KRcJPyGqHRr
-qLp7AnZxtz3JLNboTgO3bAYzlvtsSKU/R3oehBbGHzEWCP2UEYj/Kky0zpcjkhZU
-jiErr9ARPq8+dOGqBf+CE2NLKYC1bu8hZe9AddvvN2SvfMN6uhJtEGZO1k8tScwf
-AyvPJ1Po/6z08pzMAgfBUCE95waAVeYJWIOlnNB4eEievzlXdPB9vEt8OOwtWfQX
-V8xyMsoKeAW05s413E0eTYx1aulFXdWwG2mWEBRtNzKF1iBudlg1a3x1zThWi1pY
-jW5vROvoWZMCbl9bYQ/LxOCVqDoUl86+NPEGeuESMzm5NvOQA2e0Ty5wphnt9M19
-Wcc8neBhb6iCGqYzxWNvUYXZWUv1+/MrPHKyJuv7MSivwtctfp8SacUGxkd6T+u6
-V6ntHf3qtN/5pAmni6nzUTgjC65MS0LEhi/RTzwafkIfifeJH7/LqFtjrursuwua
-+p9lkACck/J5TpzaAfLroFQuepP8qgeq1cpD5Iii56IJ+FPSnkvesHuRUmZIkhtR
-VVsVqMaNPv/Uzc02bOaRXWP4auUY91mDKx/FDmORa9YCDQxMkKke05SWQ90CAwEA
-AQKCAgA0+B/c6VTgxGXS+7cMhB3yBTOkgva2jNh/6Uyv6Of345ZIPyQt4X/7gFbt
-G9qLcjWFxmQH9kZiA+snclrmr/vVijIE1l5EOz1KfUlGBYcpaal1DqALIQKqyA01
-buDq4pmmYWesiw6yvP2yyMipohav1VOu7p1zYvCXaufhRtneYICcWaQI7VNSfvHd
-fYBs5PIDJd6M8Jx4Ie7obOjJSAzl7qu3LtmhDFev4Ugeu8+fQ6IfWv/dhWBW+zw6
-UXhnv3bJUonw7wX8+/rxjdd54BMcXZF5cU9fR+s6MPJf2ZEc3OBpQaa3O9dTVeZH
-kVctGVpRj2qlg9EewoWro0PQVE5Mjah+mdFhPAHWoGl1xht6xJmg0uHYxMCzbUSz
-7NSS3knR0qieFvsp5ESY72i7DnQsbhbn6mTuYdVtm9bphxifAWCP3jFdft/bjtSF
-4yuPI7Qga+3m0B8QhtbWhEzPVon6NyiY7qfa6qllp0opEbw2hE22uGFFNJo2mpPa
-pe9VwARtD0IyfeklE7KrBEwV8NjTaAipZTZODw0w/dt4K3dOiePDl3pPWjmERpVg
-Lkw7XSCMtu5X87I1BbfOYbQhOXksPY+W9Asf6ETBeIZ8bD6Iypuk2ssool1lukqv
-yq1Y8gbR9B2x91ftYwXgzqBSvd8PFNsaXWLD3nrai2G1vb81lQKCAQEA6W02eZcN
-7wJfkqNokcuqhc5OKXH14gVIRV+KocG6f3vg88wrCg5J2GqNhBFuwVrafJjRenm6
-C8zWdneeyrl6cztgbaySw7kXnqFdTBiuOT8bhiG5NTPjDQ109EucaTbZU9KUXk6k
-ChPlr4G6IPrONpvi/9BvDDZLZkwR6uIg1kFWBy9kZaxFUEIug02hrbkTpPtnEUrO
-r3nG0QL/D0vf+bm4YHIVRMH2O2ZTTWexMw9XlfCe1+WjbJ+PS35QRCRDcRdWHXDb
-HnIFIAajtH5LtaJLgWUYq3B25WkQYtbHmFkm94sp/G4trb8JIJGzVO8cj9t6KeAT
-LG+tk8OqplqsYwKCAQEA4ne81KXx8VNwsKVFqwmiDIoi1q3beNa2hoXdzAMrnYdj
-iLxbfCVgrKPav9hdfXPBncHaNlGsd2G5W1a1UsOr128lTdfBsgm1RVPhVMKvo3fl
-yUnWajtAR1q3tVEUhuFlbJ/RHEtxJaGrzudYCPWQiYhydpDgSckbxD8PuElEgFBX
-O91vnWZEjMsxrABWiZNBxmtBUEv+fjUU/9USYzO4sN79UeD1+ZuBxPFwscsRcjLr
-bPgZWOwiywH6UmQ+DJTzeu0wJ6jgPoy/pgEujsbPDz1wNos6NhA/RQv31QeX33/B
-7/F5XKNmbJ2AFb/B+xTaTQPg0pjT5Exm+HrNU5OivwKCAQEAsLLVi9FG4OiBBHXi
-UItFuChljoYPxVqOTMV4Id6OmLZjoOmqouASElsGaTTxDDkEL1FXMUk4Bnq21dLT
-R06EXPpTknISX0qbkJ9CCrqcGAWnhi+9DYMLmvPW1p7t9c9pUESVv5X0IxTQx7yB
-8zkoJLp4aYGUrj/jb7qhzZYDmWy3/JRpgXWYupp+rzJy8xiowDj22mYwczDRyaJl
-BWVAVL+7zHZPl07kYC6jXHLj9mzktkIBXBkfTriyNkmV5R82VkN+Eqc9l5xkOMwN
-3DHGieYjFf47YHuv5RVVLBy91puWHckgrU+SEHYOKLNidybSDivsHArdOMQJN1Pk
-uCznVQKCAQAYY7DQbfa6eLQAMixomSb8lrvdxueGAgmyPyR93jGKS5Rqm2521ket
-EBB07MZUxmyposDvbKhYSwv9TD9G5I/TKcMouP3BQM5m4vu3dygXQMhcfzk6Q5tO
-k/SI8Gx3gjq8EhIhK/bJiLnKFJwkit3AEhPRtRSSnbgB0JDO1gUslHpwlg55MxRa
-3V9CGN84/cTtq4tjLGwCB5F1Y+sRB/byBXHeqY2UDi1Rmnb6jtYYKGe2WpnQO84b
-cuEUknskO75lFLpE6ykLU3koVaQ/+CVAjOtS1He2btWBiCJurNysU0P9pVHeqjJT
-rDqpHPe1JK/F74783zyir5+/Tuph/9pdAoIBAANPdFRQkJVH8K6iuhxQk6vFqiYB
-MUxpIVeLonD0p9TgMdezVNESht/AIutc0+5wabM45XuDWFRTuonvcE8lckv2Ux3a
-AvSsamjuesxw2YmkEtzZouVqDU0+oxppQJiwBG3MiaHX9F5IfnK6YmQ6xPwZ6MXi
-9feq1jR4KOc1ZrHtRMNgjnBWEFWroGe3FHgV7O133hpMSshRFmwcbE0nAaDr82U9
-sl8dclDjEKBxaqjAeNajOr+BU0w0AAwWXL7dt/ctG2QClcj9wqbEfsXnOR10h4AI
-rqkcvQrOLbTwcrOD/6R1rQfQXtEHKf1maThxosootAQZXdf6jxU3oonx3tU=
------END RSA PRIVATE KEY-----
diff --git a/test/openssl/test_asn1.rb b/test/openssl/test_asn1.rb
index 1170703775..cc11301804 100644
--- a/test/openssl/test_asn1.rb
+++ b/test/openssl/test_asn1.rb
@@ -635,6 +635,11 @@ class OpenSSL::TestASN1 < OpenSSL::TestCase
assert_equal data, seq.entries
end
+ def test_gc_stress
+ skip "very time consuming test"
+ assert_ruby_status(['--disable-gems', '-eGC.stress=true', '-erequire "openssl.so"'])
+ end
+
private
def B(ary)
diff --git a/test/openssl/test_config.rb b/test/openssl/test_config.rb
index c1a01d4dbe..8096375c07 100644
--- a/test/openssl/test_config.rb
+++ b/test/openssl/test_config.rb
@@ -61,14 +61,14 @@ foo\\bar::foo\\bar = baz
[default1 default2]\t\t # space is allowed in section name
fo =b ar # space allowed in value
[emptysection]
- [dollar ]
+ [doller ]
foo=bar
bar = $(foo)
baz = 123$(default::bar)456${foo}798
qux = ${baz}
quxx = $qux.$qux
__EOC__
- assert_equal(['default', 'default1 default2', 'dollar', 'emptysection', 'foo', 'foo\\bar'], c.sections.sort)
+ assert_equal(['default', 'default1 default2', 'doller', 'emptysection', 'foo', 'foo\\bar'], c.sections.sort)
assert_equal(['', 'a', 'bar', 'baz', 'd', 'dq', 'dq2', 'esc', 'foo\\bar', 'sq'], c['default'].keys.sort)
assert_equal('c', c['default'][''])
assert_equal('', c['default']['a'])
@@ -84,12 +84,12 @@ __EOC__
assert_equal('baz', c['foo\\bar']['foo\\bar'])
assert_equal('b ar', c['default1 default2']['fo'])
- # dollar
- assert_equal('bar', c['dollar']['foo'])
- assert_equal('bar', c['dollar']['bar'])
- assert_equal('123baz456bar798', c['dollar']['baz'])
- assert_equal('123baz456bar798', c['dollar']['qux'])
- assert_equal('123baz456bar798.123baz456bar798', c['dollar']['quxx'])
+ # dolloer
+ assert_equal('bar', c['doller']['foo'])
+ assert_equal('bar', c['doller']['bar'])
+ assert_equal('123baz456bar798', c['doller']['baz'])
+ assert_equal('123baz456bar798', c['doller']['qux'])
+ assert_equal('123baz456bar798.123baz456bar798', c['doller']['quxx'])
excn = assert_raise(OpenSSL::ConfigError) do
OpenSSL::Config.parse("foo = $bar")
@@ -120,49 +120,6 @@ __EOC__
assert_equal("error in line 7: missing close square bracket", excn.message)
end
- def test_s_parse_include
- in_tmpdir("ossl-config-include-test") do |dir|
- Dir.mkdir("child")
- File.write("child/a.conf", <<~__EOC__)
- [default]
- file-a = a.conf
- [sec-a]
- a = 123
- __EOC__
- File.write("child/b.cnf", <<~__EOC__)
- [default]
- file-b = b.cnf
- [sec-b]
- b = 123
- __EOC__
- File.write("include-child.conf", <<~__EOC__)
- key_outside_section = value_a
- .include child
- __EOC__
-
- include_file = <<~__EOC__
- [default]
- file-main = unnamed
- [sec-main]
- main = 123
- .include = include-child.conf
- __EOC__
-
- # Include a file by relative path
- c1 = OpenSSL::Config.parse(include_file)
- assert_equal(["default", "sec-a", "sec-b", "sec-main"], c1.sections.sort)
- assert_equal(["file-main", "file-a", "file-b"], c1["default"].keys)
- assert_equal({"a" => "123"}, c1["sec-a"])
- assert_equal({"b" => "123"}, c1["sec-b"])
- assert_equal({"main" => "123", "key_outside_section" => "value_a"}, c1["sec-main"])
-
- # Relative paths are from the working directory
- assert_raise(OpenSSL::ConfigError) do
- Dir.chdir("child") { OpenSSL::Config.parse(include_file) }
- end
- end
- end
-
def test_s_load
# alias of new
c = OpenSSL::Config.load
@@ -342,17 +299,6 @@ __EOC__
@it['newsection'] = {'a' => 'b'}
assert_not_equal(@it.sections.sort, c.sections.sort)
end
-
- private
-
- def in_tmpdir(*args)
- Dir.mktmpdir(*args) do |dir|
- dir = File.realpath(dir)
- Dir.chdir(dir) do
- yield dir
- end
- end
- end
end
end
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
index 08c15a0f75..29d5c9bbb1 100644
--- a/test/openssl/test_pair.rb
+++ b/test/openssl/test_pair.rb
@@ -10,7 +10,7 @@ module OpenSSL::SSLPairM
ee_exts = [
["keyUsage", "keyEncipherment,digitalSignature", true],
]
- @svr_key = OpenSSL::TestUtils::Fixtures.pkey("rsa-1")
+ @svr_key = OpenSSL::TestUtils::Fixtures.pkey("rsa1024")
@svr_cert = issue_cert(svr_dn, @svr_key, 1, ee_exts, nil, nil)
end
@@ -23,7 +23,7 @@ module OpenSSL::SSLPairM
sctx = OpenSSL::SSL::SSLContext.new
sctx.cert = @svr_cert
sctx.key = @svr_key
- sctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
+ sctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") }
sctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION
ssls = OpenSSL::SSL::SSLServer.new(tcps, sctx)
ns = ssls.accept
@@ -397,7 +397,7 @@ module OpenSSL::TestPairM
ctx2 = OpenSSL::SSL::SSLContext.new
ctx2.cert = @svr_cert
ctx2.key = @svr_key
- ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
+ ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") }
sock1, sock2 = tcp_pair
@@ -442,47 +442,54 @@ module OpenSSL::TestPairM
end
def test_connect_accept_nonblock
- ctx = OpenSSL::SSL::SSLContext.new
+ ctx = OpenSSL::SSL::SSLContext.new()
ctx.cert = @svr_cert
ctx.key = @svr_key
- ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
+ ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey_dh("dh1024") }
sock1, sock2 = tcp_pair
th = Thread.new {
s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx)
- 5.times {
- begin
- break s2.accept_nonblock
- rescue IO::WaitReadable
- IO.select([s2], nil, nil, 1)
- rescue IO::WaitWritable
- IO.select(nil, [s2], nil, 1)
- end
- sleep 0.2
- }
- }
-
- s1 = OpenSSL::SSL::SSLSocket.new(sock1)
- 5.times {
+ s2.sync_close = true
begin
- break s1.connect_nonblock
+ sleep 0.2
+ s2.accept_nonblock
rescue IO::WaitReadable
- IO.select([s1], nil, nil, 1)
+ IO.select([s2])
+ retry
rescue IO::WaitWritable
- IO.select(nil, [s1], nil, 1)
+ IO.select(nil, [s2])
+ retry
end
- sleep 0.2
+ s2
}
+ sleep 0.1
+ ctx = OpenSSL::SSL::SSLContext.new()
+ s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx)
+ begin
+ sleep 0.2
+ s1.connect_nonblock
+ rescue IO::WaitReadable
+ IO.select([s1])
+ retry
+ rescue IO::WaitWritable
+ IO.select(nil, [s1])
+ retry
+ end
+ s1.sync_close = true
+
s2 = th.value
s1.print "a\ndef"
assert_equal("a\n", s2.gets)
ensure
- sock1&.close
- sock2&.close
- th&.join
+ th.join if th
+ s1.close if s1 && !s1.closed?
+ s2.close if s2 && !s2.closed?
+ sock1.close if sock1 && !sock1.closed?
+ sock2.close if sock2 && !sock2.closed?
end
end
diff --git a/test/openssl/test_pkey_dh.rb b/test/openssl/test_pkey_dh.rb
index 8c8fbaeefb..77cdb0ab84 100644
--- a/test/openssl/test_pkey_dh.rb
+++ b/test/openssl/test_pkey_dh.rb
@@ -19,7 +19,7 @@ class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase
end
def test_DHparams
- dh1024 = Fixtures.pkey("dh1024")
+ dh1024 = Fixtures.pkey_dh("dh1024")
asn1 = OpenSSL::ASN1::Sequence([
OpenSSL::ASN1::Integer(dh1024.p),
OpenSSL::ASN1::Integer(dh1024.g)
@@ -42,7 +42,7 @@ class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase
end
def test_public_key
- dh = Fixtures.pkey("dh1024")
+ dh = Fixtures.pkey_dh("dh1024")
public_key = dh.public_key
assert_no_key(public_key) #implies public_key.public? is false!
assert_equal(dh.to_der, public_key.to_der)
@@ -50,14 +50,14 @@ class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase
end
def test_generate_key
- dh = Fixtures.pkey("dh1024").public_key # creates a copy
+ dh = Fixtures.pkey_dh("dh1024").public_key # creates a copy
assert_no_key(dh)
dh.generate_key!
assert_key(dh)
end
def test_key_exchange
- dh = Fixtures.pkey("dh1024")
+ dh = Fixtures.pkey_dh("dh1024")
dh2 = dh.public_key
dh.generate_key!
dh2.generate_key!
diff --git a/test/openssl/test_pkey_ec.rb b/test/openssl/test_pkey_ec.rb
index 95b5a6426e..dc5a14e6bf 100644
--- a/test/openssl/test_pkey_ec.rb
+++ b/test/openssl/test_pkey_ec.rb
@@ -309,14 +309,8 @@ class OpenSSL::TestEC < OpenSSL::PKeyTestCase
result_b1 = point_a.mul([3], [])
assert_equal B(%w{ 04 10 0D }), result_b1.to_octet_string(:uncompressed)
# 3 * point_a + 2 * point_a = 3 * (6, 3) + 2 * (6, 3) = (7, 11)
- begin
- result_b1 = point_a.mul([3, 2], [point_a])
- rescue OpenSSL::PKey::EC::Point::Error
- # LibreSSL doesn't support multiple entries in first argument
- raise if $!.message !~ /called a function you should not call/
- else
- assert_equal B(%w{ 04 07 0B }), result_b1.to_octet_string(:uncompressed)
- end
+ result_b1 = point_a.mul([3, 2], [point_a])
+ assert_equal B(%w{ 04 07 0B }), result_b1.to_octet_string(:uncompressed)
# 3 * point_a + 5 * point_a.group.generator = 3 * (6, 3) + 5 * (5, 1) = (13, 10)
result_b1 = point_a.mul([3], [], 5)
assert_equal B(%w{ 04 0D 0A }), result_b1.to_octet_string(:uncompressed)
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
index 53457e21d3..060c1f1cfc 100644
--- a/test/openssl/test_ssl.rb
+++ b/test/openssl/test_ssl.rb
@@ -81,7 +81,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
add0_chain_supported = openssl?(1, 0, 2)
if add0_chain_supported
- ca2_key = Fixtures.pkey("rsa2048")
+ ca2_key = Fixtures.pkey("rsa1024")
ca2_exts = [
["basicConstraints", "CA:TRUE", true],
["keyUsage", "cRLSign, keyCertSign", true],
@@ -207,10 +207,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
def test_client_auth_success
vflag = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
- start_server(verify_mode: vflag,
- ctx_proc: proc { |ctx|
- ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION if libressl?(3, 2, 0)
- }) { |port|
+ start_server(verify_mode: vflag) { |port|
ctx = OpenSSL::SSL::SSLContext.new
ctx.key = @cli_key
ctx.cert = @cli_cert
@@ -256,8 +253,6 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
end
def test_client_ca
- pend "LibreSSL 3.2 has broken client CA support" if libressl?(3, 2, 0)
-
ctx_proc = Proc.new do |ctx|
ctx.client_ca = [@ca_cert]
end
@@ -531,12 +526,8 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, "www.example.com\0.evil.com"))
assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.255'))
assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.1'))
- assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, '13::17'))
- assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '13::18'))
+ assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '13::17'))
assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, '13:0:0:0:0:0:0:17'))
- assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '44:0:0:0:0:0:0:17'))
- assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, '0013:0000:0000:0000:0000:0000:0000:0017'))
- assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '1313:0000:0000:0000:0000:0000:0000:0017'))
end
end
@@ -717,7 +708,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
def test_tlsext_hostname
fooctx = OpenSSL::SSL::SSLContext.new
- fooctx.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
+ fooctx.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
fooctx.cert = @cli_cert
fooctx.key = @cli_key
@@ -769,7 +760,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
ctx2 = OpenSSL::SSL::SSLContext.new
ctx2.cert = @svr_cert
ctx2.key = @svr_key
- ctx2.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
+ ctx2.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
ctx2.servername_cb = lambda { |args| Object.new }
sock1, sock2 = socketpair
@@ -798,13 +789,11 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
def test_verify_hostname_on_connect
ctx_proc = proc { |ctx|
- san = "DNS:a.example.com,DNS:*.b.example.com"
- san += ",DNS:c*.example.com,DNS:d.*.example.com" unless libressl?(3, 2, 2)
exts = [
["keyUsage", "keyEncipherment,digitalSignature", true],
- ["subjectAltName", san],
+ ["subjectAltName", "DNS:a.example.com,DNS:*.b.example.com," \
+ "DNS:c*.example.com,DNS:d.*.example.com"],
]
-
ctx.cert = issue_cert(@svr, @svr_key, 4, exts, @ca_cert, @ca_key)
ctx.key = @svr_key
}
@@ -825,7 +814,6 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
["cx.example.com", true],
["d.x.example.com", false],
].each do |name, expected_ok|
- next if name.start_with?('cx') if libressl?(3, 2, 2)
begin
sock = TCPSocket.new("127.0.0.1", port)
ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
@@ -844,46 +832,6 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
end
end
- def test_verify_hostname_failure_error_code
- ctx_proc = proc { |ctx|
- exts = [
- ["keyUsage", "keyEncipherment,digitalSignature", true],
- ["subjectAltName", "DNS:a.example.com"],
- ]
- ctx.cert = issue_cert(@svr, @svr_key, 4, exts, @ca_cert, @ca_key)
- ctx.key = @svr_key
- }
-
- start_server(ctx_proc: ctx_proc, ignore_listener_error: true) do |port|
- verify_callback_ok = verify_callback_err = nil
-
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.verify_hostname = true
- ctx.cert_store = OpenSSL::X509::Store.new
- ctx.cert_store.add_cert(@ca_cert)
- ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
- ctx.verify_callback = -> (preverify_ok, store_ctx) {
- verify_callback_ok = preverify_ok
- verify_callback_err = store_ctx.error
- preverify_ok
- }
-
- begin
- sock = TCPSocket.new("127.0.0.1", port)
- ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
- ssl.hostname = "b.example.com"
- assert_handshake_error { ssl.connect }
- assert_equal false, verify_callback_ok
- code_expected = openssl?(1, 0, 2) || defined?(OpenSSL::X509::V_ERR_HOSTNAME_MISMATCH) ?
- OpenSSL::X509::V_ERR_HOSTNAME_MISMATCH :
- OpenSSL::X509::V_ERR_CERT_REJECTED
- assert_equal code_expected, verify_callback_err
- ensure
- sock&.close
- end
- end
- end
-
def test_connect_certificate_verify_failed_exception_message
start_server(ignore_listener_error: true) { |port|
ctx = OpenSSL::SSL::SSLContext.new
@@ -1192,7 +1140,7 @@ if openssl?(1, 0, 2) || libressl?
ctx1 = OpenSSL::SSL::SSLContext.new
ctx1.cert = @svr_cert
ctx1.key = @svr_key
- ctx1.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
+ ctx1.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
ctx1.alpn_select_cb = -> (protocols) { nil }
ssl1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1)
@@ -1303,13 +1251,8 @@ end
}
end
- def readwrite_loop_safe(ctx, ssl)
- readwrite_loop(ctx, ssl)
- rescue OpenSSL::SSL::SSLError
- end
-
def test_close_after_socket_close
- start_server(server_proc: method(:readwrite_loop_safe)) { |port|
+ start_server { |port|
sock = TCPSocket.new("127.0.0.1", port)
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.connect
@@ -1385,10 +1328,6 @@ end
end
def test_fallback_scsv
- supported = check_supported_protocol_versions
- return unless supported.include?(OpenSSL::SSL::TLS1_1_VERSION) &&
- supported.include?(OpenSSL::SSL::TLS1_2_VERSION)
-
pend "Fallback SCSV is not supported" unless \
OpenSSL::SSL::SSLContext.method_defined?(:enable_fallback_scsv)
@@ -1418,12 +1357,7 @@ end
# Server support better, so refuse the connection
sock1, sock2 = socketpair
begin
- # This test is for the downgrade protection mechanism of TLS1.2.
- # This is why ctx1 bounds max_version == TLS1.2.
- # Otherwise, this test fails when using openssl 1.1.1 (or later) that supports TLS1.3.
- # TODO: We may need another test for TLS1.3 because it seems to have a different mechanism.
ctx1 = OpenSSL::SSL::SSLContext.new
- ctx1.max_version = OpenSSL::SSL::TLS1_2_VERSION
s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1)
ctx2 = OpenSSL::SSL::SSLContext.new
@@ -1448,21 +1382,20 @@ end
def test_dh_callback
pend "TLS 1.2 is not supported" unless tls12_supported?
- dh = Fixtures.pkey("dh-1")
called = false
ctx_proc = -> ctx {
ctx.ssl_version = :TLSv1_2
ctx.ciphers = "DH:!NULL"
ctx.tmp_dh_callback = ->(*args) {
called = true
- dh
+ Fixtures.pkey_dh("dh1024")
}
}
start_server(ctx_proc: ctx_proc) do |port|
server_connect(port) { |ssl|
assert called, "dh callback should be called"
if ssl.respond_to?(:tmp_key)
- assert_equal dh.to_der, ssl.tmp_key.to_der
+ assert_equal Fixtures.pkey_dh("dh1024").to_der, ssl.tmp_key.to_der
end
}
end
@@ -1509,13 +1442,12 @@ end
end
end
- def test_ecdh_curves_tls12
+ def test_ecdh_curves
pend "EC is disabled" unless defined?(OpenSSL::PKey::EC)
ctx_proc = -> ctx {
# Enable both ECDHE (~ TLS 1.2) cipher suites and TLS 1.3
- ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
- ctx.ciphers = "kEECDH"
+ ctx.ciphers = "DEFAULT:!kRSA:!kEDH"
ctx.ecdh_curves = "P-384:P-521"
}
start_server(ctx_proc: ctx_proc, ignore_listener_error: true) do |port|
@@ -1524,9 +1456,13 @@ end
server_connect(port, ctx) { |ssl|
cs = ssl.cipher[0]
- assert_match (/\AECDH/), cs
- if ssl.respond_to?(:tmp_key)
+ if /\ATLS/ =~ cs # Is TLS 1.3 is used?
assert_equal "secp384r1", ssl.tmp_key.group.curve_name
+ else
+ assert_match (/\AECDH/), cs
+ if ssl.respond_to?(:tmp_key)
+ assert_equal "secp384r1", ssl.tmp_key.group.curve_name
+ end
end
ssl.puts "abc"; assert_equal "abc\n", ssl.gets
}
@@ -1550,26 +1486,6 @@ end
end
end
- def test_ecdh_curves_tls13
- pend "EC is disabled" unless defined?(OpenSSL::PKey::EC)
- pend "TLS 1.3 not supported" unless tls13_supported?
-
- ctx_proc = -> ctx {
- # Assume TLS 1.3 is enabled and chosen by default
- ctx.ecdh_curves = "P-384:P-521"
- }
- start_server(ctx_proc: ctx_proc, ignore_listener_error: true) do |port|
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.ecdh_curves = "P-256:P-384" # disable P-521
-
- server_connect(port, ctx) { |ssl|
- assert_equal "TLSv1.3", ssl.ssl_version
- assert_equal "secp384r1", ssl.tmp_key.group.curve_name
- ssl.puts "abc"; assert_equal "abc\n", ssl.gets
- }
- end
- end
-
def test_security_level
ctx = OpenSSL::SSL::SSLContext.new
begin
diff --git a/test/openssl/test_ssl_session.rb b/test/openssl/test_ssl_session.rb
index 1d82aebfd5..e199f86d2b 100644
--- a/test/openssl/test_ssl_session.rb
+++ b/test/openssl/test_ssl_session.rb
@@ -122,7 +122,6 @@ __EOS__
ctx.options &= ~OpenSSL::SSL::OP_NO_TICKET
# Disable server-side session cache which is enabled by default
ctx.session_cache_mode = OpenSSL::SSL::SSLContext::SESSION_CACHE_OFF
- ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION if libressl?(3, 2, 0)
}
start_server(ctx_proc: ctx_proc) do |port|
sess1 = server_connect_with_session(port, nil, nil) { |ssl|
diff --git a/test/openssl/test_x509name.rb b/test/openssl/test_x509name.rb
index f0146595d6..e31b5e29fb 100644
--- a/test/openssl/test_x509name.rb
+++ b/test/openssl/test_x509name.rb
@@ -409,12 +409,12 @@ class OpenSSL::TestX509Name < OpenSSL::TestCase
n2 = OpenSSL::X509::Name.new([["CN", "a"]])
n3 = OpenSSL::X509::Name.new([["CN", "ab"]])
- assert_equal(0, n1 <=> n2)
- assert_equal(-1, n1 <=> n3)
- assert_equal(0, n2 <=> n1)
- assert_equal(-1, n2 <=> n3)
- assert_equal(1, n3 <=> n1)
- assert_equal(1, n3 <=> n2)
+ assert_equal 0, n1 <=> n2
+ assert_equal -1, n1 <=> n3
+ assert_equal 0, n2 <=> n1
+ assert_equal -1, n2 <=> n3
+ assert_equal 1, n3 <=> n1
+ assert_equal 1, n3 <=> n2
end
def name_hash(name)
diff --git a/test/openssl/utils.rb b/test/openssl/utils.rb
index 34c89a2e04..6318246ddb 100644
--- a/test/openssl/utils.rb
+++ b/test/openssl/utils.rb
@@ -42,8 +42,10 @@ module OpenSSL::TestUtils
def pkey(name)
OpenSSL::PKey.read(read_file("pkey", name))
- rescue OpenSSL::PKey::PKeyError
- # TODO: DH parameters can be read by OpenSSL::PKey.read atm
+ end
+
+ def pkey_dh(name)
+ # DH parameters can be read by OpenSSL::PKey.read atm
OpenSSL::PKey::DH.new(read_file("pkey", name))
end
@@ -155,9 +157,9 @@ class OpenSSL::SSLTestCase < OpenSSL::TestCase
def setup
super
- @ca_key = Fixtures.pkey("rsa-1")
- @svr_key = Fixtures.pkey("rsa-2")
- @cli_key = Fixtures.pkey("rsa-3")
+ @ca_key = Fixtures.pkey("rsa2048")
+ @svr_key = Fixtures.pkey("rsa1024")
+ @cli_key = Fixtures.pkey("rsa2048")
@ca = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=CA")
@svr = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=localhost")
@cli = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=localhost")
@@ -181,14 +183,6 @@ class OpenSSL::SSLTestCase < OpenSSL::TestCase
rescue
end
- def tls13_supported?
- return false unless defined?(OpenSSL::SSL::TLS1_3_VERSION)
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.min_version = ctx.max_version = OpenSSL::SSL::TLS1_3_VERSION
- true
- rescue
- end
-
def readwrite_loop(ctx, ssl)
while line = ssl.gets
ssl.write(line)
@@ -206,7 +200,7 @@ class OpenSSL::SSLTestCase < OpenSSL::TestCase
ctx.cert_store = store
ctx.cert = @svr_cert
ctx.key = @svr_key
- ctx.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
+ ctx.tmp_dh_callback = proc { Fixtures.pkey_dh("dh1024") }
ctx.verify_mode = verify_mode
ctx_proc.call(ctx) if ctx_proc
@@ -274,9 +268,8 @@ class OpenSSL::SSLTestCase < OpenSSL::TestCase
pend = nil
threads.each { |th|
begin
- timeout = EnvUtil.apply_timeout_scale(30)
- th.join(timeout) or
- th.raise(RuntimeError, "[start_server] thread did not exit in #{ timeout } secs")
+ th.join(10) or
+ th.raise(RuntimeError, "[start_server] thread did not exit in 10 secs")
rescue (defined?(MiniTest::Skip) ? MiniTest::Skip : Test::Unit::PendedError)
# MiniTest::Skip is for the Ruby tree
pend = $!
diff --git a/test/optparse/test_autoconf.rb b/test/optparse/test_autoconf.rb
index 45f2ba09b2..3be4a4c598 100644
--- a/test/optparse/test_autoconf.rb
+++ b/test/optparse/test_autoconf.rb
@@ -32,13 +32,6 @@ class TestOptionParser::AutoConf < Test::Unit::TestCase
assert_equal(true, @bar)
end
- def test_enable_value
- @opt.parse!(%w"--enable-foo=A")
- assert_equal("A", @foo)
- @opt.parse!(%w"--enable-bar=B")
- assert_equal("B", @bar)
- end
-
def test_disable
@opt.parse!(%w"--disable-foo")
assert_equal(false, @foo)
diff --git a/test/optparse/test_did_you_mean.rb b/test/optparse/test_did_you_mean.rb
deleted file mode 100644
index 763062586c..0000000000
--- a/test/optparse/test_did_you_mean.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: false
-require_relative 'test_optparse'
-begin
- require "did_you_mean"
-rescue LoadError
- return
-end
-
-class TestOptionParser::DidYouMean < TestOptionParser
- def setup
- super
- @opt.def_option("--foo", Integer) { |v| @foo = v }
- @opt.def_option("--bar", Integer) { |v| @bar = v }
- @opt.def_option("--baz", Integer) { |v| @baz = v }
- @formatter = ::DidYouMean.formatter
- case @formatter
- when ::DidYouMean::PlainFormatter
- else
- ::DidYouMean.formatter = ::DidYouMean::PlainFormatter.new
- end
- end
-
- def teardown
- ::DidYouMean.formatter = @formatter
- end
-
- def test_no_suggestion
- assert_raise_with_message(OptionParser::InvalidOption, "invalid option: --cuz") do
- @opt.permute!(%w"--cuz")
- end
- end
-
- def test_plain
- assert_raise_with_message(OptionParser::InvalidOption, /invalid option: --baa\nDid you mean\?\s+bar\s+baz\Z/) do
- @opt.permute!(%w"--baa")
- end
- end
-
- def test_verbose
- require 'did_you_mean/formatters/verbose_formatter'
- ::DidYouMean.formatter = ::DidYouMean::VerboseFormatter.new
- assert_raise_with_message(OptionParser::InvalidOption, /invalid option: --baa\n\s+Did you mean\?\s+bar\s+baz\s*\Z/) do
- @opt.permute!(%w"--baa")
- end
- end
-
- def test_ambiguos
- assert_raise_with_message(OptionParser::AmbiguousOption, /ambiguous option: --ba\nDid you mean\?\s+bar\s+baz\Z/) do
- @opt.permute!(%w"--ba")
- end
- end
-end
diff --git a/test/optparse/test_summary.rb b/test/optparse/test_summary.rb
index 67b05672d4..b743aa00c1 100644
--- a/test/optparse/test_summary.rb
+++ b/test/optparse/test_summary.rb
@@ -44,15 +44,4 @@ class TestOptionParser::SummaryTest < TestOptionParser
assert_equal("foo bar\n", o.to_s, bug6348)
assert_equal(["foo bar"], o.to_a, bug6348)
end
-
- def test_ver
- o = OptionParser.new("foo bar")
- o.program_name = "foo"
- assert_warning('') {assert_nil(o.version)}
- assert_warning('') {assert_nil(o.release)}
- o.version = [0, 1]
- assert_equal "foo 0.1", o.ver
- o.release = "rel"
- assert_equal "foo 0.1 (rel)", o.ver
- end
end
diff --git a/test/optparse/test_zsh_completion.rb b/test/optparse/test_zsh_completion.rb
index c548d4af8a..1bc6c7f0bb 100644
--- a/test/optparse/test_zsh_completion.rb
+++ b/test/optparse/test_zsh_completion.rb
@@ -4,7 +4,7 @@ require 'optparse'
class TestOptionParser < Test::Unit::TestCase
end
-class TestOptionParser::ZshCompletion < Test::Unit::TestCase
+class TestOptionParser::BashCompletion < Test::Unit::TestCase
def setup
@opt = OptionParser.new
@opt.define("-z", "zzz") {}
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 61a4822810..19f06a85a7 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -66,16 +66,15 @@ class TC_OpenStruct < Test::Unit::TestCase
o = OpenStruct.new(foo: 42)
o.a = 'a'
o.freeze
- expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
- assert_raise(expected_error) {o.b = 'b'}
+ assert_raise(RuntimeError) {o.b = 'b'}
assert_not_respond_to(o, :b)
- assert_raise(expected_error) {o.a = 'z'}
+ assert_raise(RuntimeError) {o.a = 'z'}
assert_equal('a', o.a)
assert_equal(42, o.foo)
o = OpenStruct.new :a => 42
def o.frozen?; nil end
o.freeze
- assert_raise(expected_error, '[ruby-core:22559]') {o.a = 1764}
+ assert_raise(RuntimeError, '[ruby-core:22559]') {o.a = 1764}
end
def test_delete_field
@@ -141,13 +140,6 @@ class TC_OpenStruct < Test::Unit::TestCase
assert_equal(h, OpenStruct.new("name" => "John Smith", "age" => 70, pension: 300).to_h)
end
- def test_to_h_with_block
- os = OpenStruct.new("country" => "Australia", :capital => "Canberra")
- assert_equal({"country" => "AUSTRALIA", "capital" => "CANBERRA" },
- os.to_h {|name, value| [name.to_s, value.upcase]})
- assert_equal("Australia", os.country)
- end
-
def test_each_pair
h = {name: "John Smith", age: 70, pension: 300}
os = OpenStruct.new(h)
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index e5168d5e2e..8a72b8026d 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -291,10 +291,9 @@ class TestPathname < Test::Unit::TestCase
end
def relative_path_from(dest_directory, base_directory)
- Pathname.new(dest_directory).relative_path_from(base_directory).to_s
+ Pathname.new(dest_directory).relative_path_from(Pathname.new(base_directory)).to_s
end
- defassert(:relative_path_from, "../a", Pathname.new("a"), "b")
defassert(:relative_path_from, "../a", "a", "b")
defassert(:relative_path_from, "../a", "a", "b/")
defassert(:relative_path_from, "../a", "a/", "b")
@@ -471,12 +470,6 @@ class TestPathname < Test::Unit::TestCase
assert_raise(ArgumentError) { Pathname.new("a\0") }
end
- def test_global_constructor
- p = Pathname.new('a')
- assert_equal(p, Pathname('a'))
- assert_same(p, Pathname(p))
- end
-
class AnotherStringLike # :nodoc:
def initialize(s) @s = s end
def to_str() @s end
@@ -592,6 +585,39 @@ class TestPathname < Test::Unit::TestCase
assert_raise(ArgumentError) { Pathname.new("\0") }
end
+ def test_taint
+ obj = Pathname.new("a"); assert_same(obj, obj.taint)
+ obj = Pathname.new("a"); assert_same(obj, obj.untaint)
+
+ assert_equal(false, Pathname.new("a" ) .tainted?)
+ assert_equal(false, Pathname.new("a" ) .to_s.tainted?)
+ assert_equal(true, Pathname.new("a" ).taint .tainted?)
+ assert_equal(true, Pathname.new("a" ).taint.to_s.tainted?)
+ assert_equal(true, Pathname.new("a".dup.taint) .tainted?)
+ assert_equal(true, Pathname.new("a".dup.taint) .to_s.tainted?)
+ assert_equal(true, Pathname.new("a".dup.taint).taint .tainted?)
+ assert_equal(true, Pathname.new("a".dup.taint).taint.to_s.tainted?)
+
+ str = "a".dup
+ path = Pathname.new(str)
+ str.taint
+ assert_equal(false, path .tainted?)
+ assert_equal(false, path.to_s.tainted?)
+ end
+
+ def test_untaint
+ obj = Pathname.new("a"); assert_same(obj, obj.untaint)
+
+ assert_equal(false, Pathname.new("a").taint.untaint .tainted?)
+ assert_equal(false, Pathname.new("a").taint.untaint.to_s.tainted?)
+
+ str = "a".dup.taint
+ path = Pathname.new(str)
+ str.untaint
+ assert_equal(true, path .tainted?)
+ assert_equal(true, path.to_s.tainted?)
+ end
+
def test_freeze
obj = Pathname.new("a"); assert_same(obj, obj.freeze)
@@ -605,6 +631,20 @@ class TestPathname < Test::Unit::TestCase
assert_equal(false, Pathname.new("a".freeze).freeze.to_s.frozen?)
end
+ def test_freeze_and_taint
+ obj = Pathname.new("a")
+ obj.freeze
+ assert_equal(false, obj.tainted?)
+ assert_raise(FrozenError) { obj.taint }
+
+ obj = Pathname.new("a")
+ obj.taint
+ assert_equal(true, obj.tainted?)
+ obj.freeze
+ assert_equal(true, obj.tainted?)
+ assert_nothing_raised { obj.taint }
+ end
+
def test_to_s
str = "a"
obj = Pathname.new(str)
@@ -690,32 +730,6 @@ class TestPathname < Test::Unit::TestCase
}
end
- def test_each_line_opts
- with_tmpchdir('rubytest-pathname') {|dir|
- open("a", "w") {|f| f.puts 1, 2 }
- a = []
- Pathname("a").each_line(chomp: true) {|line| a << line }
- assert_equal(["1", "2"], a)
-
- a = []
- Pathname("a").each_line("2", chomp: true) {|line| a << line }
- assert_equal(["1\n", "\n"], a)
-
- a = []
- Pathname("a").each_line(1, chomp: true) {|line| a << line }
- assert_equal(["1", "", "2", ""], a)
-
- a = []
- Pathname("a").each_line("2", 1, chomp: true) {|line| a << line }
- assert_equal(["1", "\n", "", "\n"], a)
-
- a = []
- enum = Pathname("a").each_line(chomp: true)
- enum.each {|line| a << line }
- assert_equal(["1", "2"], a)
- }
- end
-
def test_readlines
with_tmpchdir('rubytest-pathname') {|dir|
open("a", "w") {|f| f.puts 1, 2 }
@@ -724,14 +738,6 @@ class TestPathname < Test::Unit::TestCase
}
end
- def test_readlines_opts
- with_tmpchdir('rubytest-pathname') {|dir|
- open("a", "w") {|f| f.puts 1, 2 }
- a = Pathname("a").readlines 1, chomp: true
- assert_equal(["1", "", "2", ""], a)
- }
- end
-
def test_read
with_tmpchdir('rubytest-pathname') {|dir|
open("a", "w") {|f| f.puts 1, 2 }
@@ -756,14 +762,6 @@ class TestPathname < Test::Unit::TestCase
}
end
- def test_write_opts
- with_tmpchdir('rubytest-pathname') {|dir|
- path = Pathname("a")
- path.write "abc", mode: "w"
- assert_equal("abc", path.read)
- }
- end
-
def test_binwrite
with_tmpchdir('rubytest-pathname') {|dir|
path = Pathname("a")
@@ -772,14 +770,6 @@ class TestPathname < Test::Unit::TestCase
}
end
- def test_binwrite_opts
- with_tmpchdir('rubytest-pathname') {|dir|
- path = Pathname("a")
- path.binwrite "abc\x80", mode: 'w'
- assert_equal("abc\x80".b, path.binread)
- }
- end
-
def test_sysopen
with_tmpchdir('rubytest-pathname') {|dir|
open("a", "w") {|f| f.write "abc" }
@@ -798,21 +788,10 @@ class TestPathname < Test::Unit::TestCase
end
def test_birthtime
- skip if RUBY_PLATFORM =~ /android/
- # Check under a (probably) local filesystem.
- # Remote filesystems often may not support birthtime.
- with_tmpchdir('rubytest-pathname') do |dir|
- open("a", "w") {}
- assert_kind_of(Time, Pathname("a").birthtime)
- rescue Errno::EPERM
- # Docker prohibits statx syscall by the default.
- skip("statx(2) is prohibited by seccomp")
- rescue Errno::ENOSYS
- skip("statx(2) is not supported on this filesystem")
- rescue NotImplementedError
- # assert_raise(NotImplementedError) do
- # File.birthtime("a")
- # end
+ assert_kind_of(Time, Pathname(__FILE__).birthtime)
+ rescue NotImplementedError
+ assert_raise(NotImplementedError) do
+ File.birthtime(__FILE__)
end
end
@@ -844,7 +823,7 @@ class TestPathname < Test::Unit::TestCase
old = path.lstat.mode
begin
path.lchmod(0444)
- rescue NotImplementedError, Errno::EOPNOTSUPP
+ rescue NotImplementedError
next
end
assert_equal(0444, path.lstat.mode & 0777)
@@ -932,25 +911,17 @@ class TestPathname < Test::Unit::TestCase
assert_equal("abc", f.read)
}
- path.open(mode: "r") {|f|
- assert_equal("abc", f.read)
- }
-
Pathname("b").open("w", 0444) {|f| f.write "def" }
assert_equal(0444 & ~File.umask, File.stat("b").mode & 0777)
assert_equal("def", File.read("b"))
- Pathname("c").open("w", 0444, **{}) {|f| f.write "ghi" }
+ Pathname("c").open("w", 0444, {}) {|f| f.write "ghi" }
assert_equal(0444 & ~File.umask, File.stat("c").mode & 0777)
assert_equal("ghi", File.read("c"))
g = path.open
assert_equal("abc", g.read)
g.close
-
- g = path.open(mode: "r")
- assert_equal("abc", g.read)
- g.close
}
end
@@ -1269,17 +1240,6 @@ class TestPathname < Test::Unit::TestCase
}
end
- def test_s_glob_3args
- with_tmpchdir('rubytest-pathname') {|dir|
- open("f", "w") {|f| f.write "abc" }
- Dir.chdir("/") {
- assert_equal(
- [Pathname("."), Pathname(".."), Pathname("f")],
- Pathname.glob("*", File::FNM_DOTMATCH, base: dir).sort)
- }
- }
- end
-
def test_s_getwd
wd = Pathname.getwd
assert_kind_of(Pathname, wd)
@@ -1446,6 +1406,14 @@ class TestPathname < Test::Unit::TestCase
assert(File.fnmatch("*.*", Pathname.new("bar.baz")))
end
+ def test_file_join
+ assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar")))
+ lambda {
+ $SAFE = 1
+ assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar").taint))
+ }.call
+ end
+
def test_relative_path_from_casefold
assert_separately([], <<-'end;') # do
module File::Constants
@@ -1458,19 +1426,4 @@ class TestPathname < Test::Unit::TestCase
assert_instance_of(Pathname, foo.relative_path_from(bar))
end;
end
-
- def test_relative_path_from_mock
- assert_equal(
- Pathname.new("../bar"),
- Pathname.new("/foo/bar").relative_path_from(Pathname.new("/foo/baz")))
- assert_equal(
- Pathname.new("../bar"),
- Pathname.new("/foo/bar").relative_path_from("/foo/baz"))
- obj = Object.new
- def obj.cleanpath() Pathname.new("/foo/baz") end
- def obj.is_a?(m) m == Pathname end
- assert_equal(
- Pathname.new("../bar"),
- Pathname.new("/foo/bar").relative_path_from(obj))
- end
end
diff --git a/test/psych/test_exception.rb b/test/psych/test_exception.rb
index e7fc88c706..3040bfb7a2 100644
--- a/test/psych/test_exception.rb
+++ b/test/psych/test_exception.rb
@@ -15,26 +15,6 @@ module Psych
def setup
super
@wups = Wups.new
-
- @orig_verbose, $VERBOSE = $VERBOSE, nil
- end
-
- def teardown
- $VERBOSE = @orig_verbose
- end
-
- def make_ex msg = 'oh no!'
- begin
- raise msg
- rescue ::Exception => e
- e
- end
- end
-
- def test_backtrace
- err = make_ex
- new_err = Psych.load(Psych.dump(err))
- assert_equal err.backtrace, new_err.backtrace
end
def test_naming_exception
@@ -50,15 +30,9 @@ module Psych
assert_nil ex.file
ex = assert_raises(Psych::SyntaxError) do
- Psych.load '--- `', filename: 'meow'
+ Psych.load '--- `', 'meow'
end
assert_equal 'meow', ex.file
-
- # deprecated interface
- ex = assert_raises(Psych::SyntaxError) do
- Psych.load '--- `', 'deprecated'
- end
- assert_equal 'deprecated', ex.file
end
def test_psych_parse_stream_takes_file
@@ -69,7 +43,7 @@ module Psych
assert_match '(<unknown>)', ex.message
ex = assert_raises(Psych::SyntaxError) do
- Psych.parse_stream '--- `', filename: 'omg!'
+ Psych.parse_stream '--- `', 'omg!'
end
assert_equal 'omg!', ex.file
assert_match 'omg!', ex.message
@@ -83,15 +57,9 @@ module Psych
assert_match '(<unknown>)', ex.message
ex = assert_raises(Psych::SyntaxError) do
- Psych.load_stream '--- `', filename: 'omg!'
+ Psych.load_stream '--- `', 'omg!'
end
assert_equal 'omg!', ex.file
-
- # deprecated interface
- ex = assert_raises(Psych::SyntaxError) do
- Psych.load_stream '--- `', 'deprecated'
- end
- assert_equal 'deprecated', ex.file
end
def test_parse_file_exception
@@ -126,15 +94,9 @@ module Psych
assert_nil ex.file
ex = assert_raises(Psych::SyntaxError) do
- Psych.parse '--- `', filename: 'omg!'
+ Psych.parse '--- `', 'omg!'
end
assert_match 'omg!', ex.message
-
- # deprecated interface
- ex = assert_raises(Psych::SyntaxError) do
- Psych.parse '--- `', 'deprecated'
- end
- assert_match 'deprecated', ex.message
end
def test_attributes
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index ba11b827da..e93aa73249 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -6,18 +6,6 @@ module Psych
class X < Hash
end
- class HashWithIvar < Hash
- def initialize
- @keys = []
- super
- end
-
- def []=(k, v)
- @keys << k
- super(k, v)
- end
- end
-
class HashWithCustomInit < Hash
attr_reader :obj
def initialize(obj)
@@ -36,14 +24,6 @@ module Psych
@hash = { :a => 'b' }
end
- def test_hash_with_ivar
- t1 = HashWithIvar.new
- t1[:foo] = :bar
- t2 = Psych.load(Psych.dump(t1))
- assert_equal t1, t2
- assert_cycle t1
- end
-
def test_referenced_hash_with_ivar
a = [1,2,3,4,5]
t1 = [HashWithCustomInit.new(a)]
@@ -111,19 +91,5 @@ bar:
eoyml
assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash)
end
-
- def test_key_deduplication
- unless String.method_defined?(:-@) && (-("a" * 20)).equal?((-("a" * 20)))
- skip "This Ruby implementation doesn't support string deduplication"
- end
-
- hashes = Psych.load(<<-eoyml)
----
-- unique_identifier: 1
-- unique_identifier: 2
-eoyml
-
- assert_same hashes[0].keys.first, hashes[1].keys.first
- end
end
end
diff --git a/test/psych/test_nil.rb b/test/psych/test_nil.rb
index bcbbcb9c93..910a2e697d 100644
--- a/test/psych/test_nil.rb
+++ b/test/psych/test_nil.rb
@@ -5,13 +5,13 @@ module Psych
class TestNil < TestCase
def test_nil
yml = Psych.dump nil
- assert_match(/---[ ]?\n(?:\.\.\.\n)?/, yml)
+ assert_match(/--- \n(?:\.\.\.\n)?/, yml)
assert_nil Psych.load(yml)
end
def test_array_nil
yml = Psych.dump [nil]
- assert_match(/---\n-[ ]?\n/, yml)
+ assert_equal "---\n- \n", yml
assert_equal [nil], Psych.load(yml)
end
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index e557feffb7..2812fd1bd8 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -5,14 +5,8 @@ require 'stringio'
require 'tempfile'
class TestPsych < Psych::TestCase
-
- def setup
- @orig_verbose, $VERBOSE = $VERBOSE, nil
- end
-
def teardown
Psych.domain_types.clear
- $VERBOSE = @orig_verbose
end
def test_line_width_invalid
@@ -66,22 +60,6 @@ class TestPsych < Psych::TestCase
end
end
- def test_parse
- assert_equal %w[a b], Psych.parse("- a\n- b").to_ruby
- end
-
- def test_parse_default_fallback
- assert_equal false, Psych.parse("")
- end
-
- def test_parse_raises_on_bad_input
- assert_raises(Psych::SyntaxError) { Psych.parse("--- `") }
- end
-
- def test_parse_with_fallback
- assert_equal 42, Psych.parse("", fallback: 42)
- end
-
def test_non_existing_class_on_deserialize
e = assert_raises(ArgumentError) do
Psych.load("--- !ruby/object:NonExistent\nfoo: 1")
@@ -125,44 +103,9 @@ class TestPsych < Psych::TestCase
assert_equal %w{ foo bar }, docs
end
- def test_load_stream_default_fallback
- assert_equal [], Psych.load_stream("")
- end
-
- def test_load_stream_raises_on_bad_input
- assert_raises(Psych::SyntaxError) { Psych.load_stream("--- `") }
- end
-
def test_parse_stream
docs = Psych.parse_stream("--- foo\n...\n--- bar\n...")
- assert_equal(%w[foo bar], docs.children.map(&:transform))
- end
-
- def test_parse_stream_with_block
- docs = []
- Psych.parse_stream("--- foo\n...\n--- bar\n...") do |node|
- docs << node
- end
-
- assert_equal %w[foo bar], docs.map(&:to_ruby)
- end
-
- def test_parse_stream_default_fallback
- docs = Psych.parse_stream("")
- assert_equal [], docs.children.map(&:to_ruby)
- end
-
- def test_parse_stream_with_block_default_fallback
- docs = []
- Psych.parse_stream("") do |node|
- docs << node
- end
-
- assert_equal [], docs.map(&:to_ruby)
- end
-
- def test_parse_stream_raises_on_bad_input
- assert_raises(Psych::SyntaxError) { Psych.parse_stream("--- `") }
+ assert_equal %w{ foo bar }, docs.children.map { |x| x.transform }
end
def test_add_builtin_type
@@ -178,45 +121,20 @@ class TestPsych < Psych::TestCase
def test_domain_types
got = nil
- Psych.add_domain_type 'foo.bar/2002', 'foo' do |type, val|
+ Psych.add_domain_type 'foo.bar,2002', 'foo' do |type, val|
got = val
end
- Psych.load('--- !foo.bar/2002:foo hello')
+ Psych.load('--- !foo.bar,2002/foo hello')
assert_equal 'hello', got
- Psych.load("--- !foo.bar/2002:foo\n- hello\n- world")
+ Psych.load("--- !foo.bar,2002/foo\n- hello\n- world")
assert_equal %w{ hello world }, got
- Psych.load("--- !foo.bar/2002:foo\nhello: world")
+ Psych.load("--- !foo.bar,2002/foo\nhello: world")
assert_equal({ 'hello' => 'world' }, got)
end
- def test_load_default_fallback
- assert_equal false, Psych.load("")
- end
-
- def test_load_with_fallback
- assert_equal 42, Psych.load("", "file", fallback: 42)
- end
-
- def test_load_with_fallback_nil_or_false
- assert_nil Psych.load("", "file", fallback: nil)
- assert_equal false, Psych.load("", "file", fallback: false)
- end
-
- def test_load_with_fallback_hash
- assert_equal Hash.new, Psych.load("", "file", fallback: Hash.new)
- end
-
- def test_load_with_fallback_for_nil
- assert_nil Psych.load("--- null", "file", fallback: 42)
- end
-
- def test_load_with_fallback_for_false
- assert_equal false, Psych.load("--- false", "file", fallback: 42)
- end
-
def test_load_file
Tempfile.create(['yikes', 'yml']) {|t|
t.binmode
@@ -226,49 +144,12 @@ class TestPsych < Psych::TestCase
}
end
- def test_load_file_default_fallback
- Tempfile.create(['empty', 'yml']) {|t|
- assert_equal false, Psych.load_file(t.path)
- }
- end
-
def test_load_file_with_fallback
Tempfile.create(['empty', 'yml']) {|t|
- assert_equal 42, Psych.load_file(t.path, fallback: 42)
- }
- end
-
- def test_load_file_with_fallback_nil_or_false
- Tempfile.create(['empty', 'yml']) {|t|
- assert_nil Psych.load_file(t.path, fallback: nil)
- assert_equal false, Psych.load_file(t.path, fallback: false)
- }
- end
-
- def test_load_file_with_fallback_hash
- Tempfile.create(['empty', 'yml']) {|t|
assert_equal Hash.new, Psych.load_file(t.path, fallback: Hash.new)
}
end
- def test_load_file_with_fallback_for_nil
- Tempfile.create(['nil', 'yml']) {|t|
- t.binmode
- t.write('--- null')
- t.close
- assert_nil Psych.load_file(t.path, fallback: 42)
- }
- end
-
- def test_load_file_with_fallback_for_false
- Tempfile.create(['false', 'yml']) {|t|
- t.binmode
- t.write('--- false')
- t.close
- assert_equal false, Psych.load_file(t.path, fallback: 42)
- }
- end
-
def test_parse_file
Tempfile.create(['yikes', 'yml']) {|t|
t.binmode
@@ -278,12 +159,6 @@ class TestPsych < Psych::TestCase
}
end
- def test_parse_file_default_fallback
- Tempfile.create(['empty', 'yml']) do |t|
- assert_equal false, Psych.parse_file(t.path)
- end
- end
-
def test_degenerate_strings
assert_equal false, Psych.load(' ')
assert_equal false, Psych.parse(' ')
@@ -295,13 +170,16 @@ class TestPsych < Psych::TestCase
types = []
appender = lambda { |*args| types << args }
- Psych.add_domain_type('example.com:2002', 'foo', &appender)
+ Psych.add_builtin_type('foo', &appender)
+ Psych.add_domain_type('example.com,2002', 'foo', &appender)
Psych.load <<-eoyml
-- !tag:example.com:2002:foo bar
+- !tag:yaml.org,2002:foo bar
+- !tag:example.com,2002:foo bar
eoyml
assert_equal [
- ["tag:example.com:2002:foo", "bar"]
+ ["tag:yaml.org,2002:foo", "bar"],
+ ["tag:example.com,2002:foo", "bar"]
], types
end
diff --git a/test/psych/test_safe_load.rb b/test/psych/test_safe_load.rb
index e3972712fc..f3fdb9b9a2 100644
--- a/test/psych/test_safe_load.rb
+++ b/test/psych/test_safe_load.rb
@@ -3,14 +3,6 @@ require 'psych/helper'
module Psych
class TestSafeLoad < TestCase
- def setup
- @orig_verbose, $VERBOSE = $VERBOSE, nil
- end
-
- def teardown
- $VERBOSE = @orig_verbose
- end
-
class Foo; end
[1, 2.2, {}, [], "foo"].each do |obj|
@@ -30,26 +22,14 @@ module Psych
def test_explicit_recursion
x = []
x << x
- assert_equal(x, Psych.safe_load(Psych.dump(x), permitted_classes: [], permitted_symbols: [], aliases: true))
- # deprecated interface
assert_equal(x, Psych.safe_load(Psych.dump(x), [], [], true))
end
- def test_permitted_symbol
+ def test_symbol_whitelist
yml = Psych.dump :foo
assert_raises(Psych::DisallowedClass) do
Psych.safe_load yml
end
- assert_equal(
- :foo,
- Psych.safe_load(
- yml,
- permitted_classes: [Symbol],
- permitted_symbols: [:foo]
- )
- )
-
- # deprecated interface
assert_equal(:foo, Psych.safe_load(yml, [Symbol], [:foo]))
end
@@ -58,71 +38,32 @@ module Psych
assert_safe_cycle :foo
end
assert_raises(Psych::DisallowedClass) do
- Psych.safe_load '--- !ruby/symbol foo', permitted_classes: []
- end
-
- # deprecated interface
- assert_raises(Psych::DisallowedClass) do
Psych.safe_load '--- !ruby/symbol foo', []
end
-
- assert_safe_cycle :foo, permitted_classes: [Symbol]
- assert_safe_cycle :foo, permitted_classes: %w{ Symbol }
- assert_equal :foo, Psych.safe_load('--- !ruby/symbol foo', permitted_classes: [Symbol])
-
- # deprecated interface
+ assert_safe_cycle :foo, [Symbol]
+ assert_safe_cycle :foo, %w{ Symbol }
assert_equal :foo, Psych.safe_load('--- !ruby/symbol foo', [Symbol])
end
def test_foo
assert_raises(Psych::DisallowedClass) do
- Psych.safe_load '--- !ruby/object:Foo {}', permitted_classes: [Foo]
- end
-
- # deprecated interface
- assert_raises(Psych::DisallowedClass) do
Psych.safe_load '--- !ruby/object:Foo {}', [Foo]
end
-
assert_raises(Psych::DisallowedClass) do
assert_safe_cycle Foo.new
end
- assert_kind_of(Foo, Psych.safe_load(Psych.dump(Foo.new), permitted_classes: [Foo]))
-
- # deprecated interface
assert_kind_of(Foo, Psych.safe_load(Psych.dump(Foo.new), [Foo]))
end
X = Struct.new(:x)
def test_struct_depends_on_sym
- assert_safe_cycle(X.new, permitted_classes: [X, Symbol])
+ assert_safe_cycle(X.new, [X, Symbol])
assert_raises(Psych::DisallowedClass) do
- cycle X.new, permitted_classes: [X]
+ cycle X.new, [X]
end
end
def test_anon_struct
- assert Psych.safe_load(<<-eoyml, permitted_classes: [Struct, Symbol])
---- !ruby/struct
- foo: bar
- eoyml
-
- assert_raises(Psych::DisallowedClass) do
- Psych.safe_load(<<-eoyml, permitted_classes: [Struct])
---- !ruby/struct
- foo: bar
- eoyml
- end
-
- assert_raises(Psych::DisallowedClass) do
- Psych.safe_load(<<-eoyml, permitted_classes: [Symbol])
---- !ruby/struct
- foo: bar
- eoyml
- end
- end
-
- def test_deprecated_anon_struct
assert Psych.safe_load(<<-eoyml, [Struct, Symbol])
--- !ruby/struct
foo: bar
@@ -143,28 +84,14 @@ module Psych
end
end
- def test_safe_load_default_fallback
- assert_nil Psych.safe_load("")
- end
-
- def test_safe_load
- assert_equal %w[a b], Psych.safe_load("- a\n- b")
- end
-
- def test_safe_load_raises_on_bad_input
- assert_raises(Psych::SyntaxError) { Psych.safe_load("--- `") }
- end
-
private
- def cycle object, permitted_classes: []
- Psych.safe_load(Psych.dump(object), permitted_classes: permitted_classes)
- # deprecated interface test
- Psych.safe_load(Psych.dump(object), permitted_classes)
+ def cycle object, whitelist = []
+ Psych.safe_load(Psych.dump(object), whitelist)
end
- def assert_safe_cycle object, permitted_classes: []
- other = cycle object, permitted_classes: permitted_classes
+ def assert_safe_cycle object, whitelist = []
+ other = cycle object, whitelist
assert_equal object, other
end
end
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index d12a905330..ebe8daf672 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -113,22 +113,5 @@ module Psych
def test_scan_strings_starting_with_underscores
assert_equal "_100", ss.tokenize('_100')
end
-
- def test_scan_int_commas_and_underscores
- # NB: This test is to ensure backward compatibility with prior Psych versions,
- # not to test against any actual YAML specification.
- assert_equal 123_456_789, ss.tokenize('123_456_789')
- assert_equal 123_456_789, ss.tokenize('123,456,789')
- assert_equal 123_456_789, ss.tokenize('1_2,3,4_5,6_789')
-
- assert_equal 0b010101010, ss.tokenize('0b010101010')
- assert_equal 0b010101010, ss.tokenize('0b0,1_0,1_,0,1_01,0')
-
- assert_equal 01234567, ss.tokenize('01234567')
- assert_equal 01234567, ss.tokenize('0_,,,1_2,_34567')
-
- assert_equal 0x123456789abcdef, ss.tokenize('0x123456789abcdef')
- assert_equal 0x123456789abcdef, ss.tokenize('0x12_,34,_56,_789abcdef')
- end
end
end
diff --git a/test/psych/test_stream.rb b/test/psych/test_stream.rb
index 9b71c6d996..3bd557cb68 100644
--- a/test/psych/test_stream.rb
+++ b/test/psych/test_stream.rb
@@ -3,22 +3,6 @@ require_relative 'helper'
module Psych
class TestStream < TestCase
- [
- [Psych::Nodes::Alias, :alias?],
- [Psych::Nodes::Document, :document?],
- [Psych::Nodes::Mapping, :mapping?],
- [Psych::Nodes::Scalar, :scalar?],
- [Psych::Nodes::Sequence, :sequence?],
- [Psych::Nodes::Stream, :stream?],
- ].each do |klass, block|
- define_method :"test_predicate_#{block}" do
- rb = Psych.parse_stream("---\n- foo: bar\n- &a !!str Anchored\n- *a")
- nodes = rb.grep(klass)
- assert_operator nodes.length, :>, 0
- assert_equal nodes, rb.find_all(&block)
- end
- end
-
def test_parse_partial
rb = Psych.parse("--- foo\n...\n--- `").to_ruby
assert_equal 'foo', rb
diff --git a/test/psych/test_tainted.rb b/test/psych/test_tainted.rb
new file mode 100644
index 0000000000..dcf150b138
--- /dev/null
+++ b/test/psych/test_tainted.rb
@@ -0,0 +1,131 @@
+# frozen_string_literal: true
+require_relative '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
+
+ def alias name
+ assert_taintedness name
+ end
+
+ def scalar value, anchor, tag, plain, quoted, style
+ assert_taintedness value
+ assert_taintedness tag if tag
+ assert_taintedness anchor if anchor
+ end
+
+ def start_sequence anchor, tag, implicit, style
+ assert_taintedness tag if tag
+ assert_taintedness anchor if anchor
+ end
+
+ def start_mapping anchor, tag, implicit, style
+ assert_taintedness tag if tag
+ assert_taintedness anchor if anchor
+ end
+
+ def assert_taintedness thing, message = "'#{thing}' should be tainted"
+ tc.assert thing.tainted?, message
+ end
+ end
+
+ class Untainted < Tainted
+ def assert_taintedness thing, message = "'#{thing}' should not be tainted"
+ tc.assert !thing.tainted?, message
+ end
+ end
+
+
+ def setup
+ handler = Tainted.new self
+ @parser = Psych::Parser.new handler
+ end
+
+ def test_tags_are_tainted
+ assert_taintedness "%TAG !yaml! tag:yaml.org,2002:\n---\n!yaml!str \"foo\""
+ end
+
+ def test_alias
+ assert_taintedness "--- &ponies\n- foo\n- *ponies"
+ end
+
+ def test_scalar
+ assert_taintedness "--- ponies"
+ end
+
+ def test_anchor
+ assert_taintedness "--- &hi ponies"
+ end
+
+ def test_scalar_tag
+ assert_taintedness "--- !str ponies"
+ end
+
+ def test_seq_start_tag
+ assert_taintedness "--- !!seq [ a ]"
+ end
+
+ def test_seq_start_anchor
+ assert_taintedness "--- &zomg [ a ]"
+ end
+
+ def test_seq_mapping_tag
+ assert_taintedness "--- !!map { a: b }"
+ end
+
+ def test_seq_mapping_anchor
+ assert_taintedness "--- &himom { a: b }"
+ end
+
+ def assert_taintedness string
+ @parser.parse string.dup.taint
+ end
+ end
+
+ class TestStringUntainted < TestStringTainted
+ def setup
+ handler = Untainted.new self
+ @parser = Psych::Parser.new handler
+ end
+
+ def assert_taintedness string
+ @parser.parse string
+ end
+ end
+
+ class TestStringIOUntainted < TestStringTainted
+ def setup
+ handler = Untainted.new self
+ @parser = Psych::Parser.new handler
+ end
+
+ def assert_taintedness string
+ @parser.parse StringIO.new(string)
+ end
+ end
+
+ class TestIOTainted < TestStringTainted
+ def assert_taintedness string
+ Tempfile.create(['something', 'yml']) {|t|
+ t.binmode
+ t.write string
+ t.close
+ File.open(t.path, 'r:bom|utf-8') { |f|
+ @parser.parse f
+ }
+ }
+ end
+ end
+end
diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb
index 0dfd60f894..5fa759c981 100644
--- a/test/psych/test_yaml.rb
+++ b/test/psych/test_yaml.rb
@@ -617,11 +617,11 @@ EOY
raise ArgumentError, "Not a Hash in domain.tld,2002/invoice: " + val.inspect
end
}
- Psych.add_domain_type( "domain.tld/2002", 'invoice', &customer_proc )
- Psych.add_domain_type( "domain.tld/2002", 'customer', &customer_proc )
+ Psych.add_domain_type( "domain.tld,2002", 'invoice', &customer_proc )
+ Psych.add_domain_type( "domain.tld,2002", 'customer', &customer_proc )
assert_parse_only( { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }, <<EOY
# 'http://domain.tld,2002/invoice' is some type family.
-invoice: !domain.tld/2002:invoice
+invoice: !domain.tld,2002/invoice
# 'seq' is shorthand for 'http://yaml.org/seq'.
# This does not effect '^customer' below
# because it is does not specify a prefix.
@@ -705,7 +705,7 @@ EOY
end
def test_spec_explicit_families
- Psych.add_domain_type( "somewhere.com/2002", 'type' ) { |type, val|
+ Psych.add_domain_type( "somewhere.com,2002", 'type' ) { |type, val|
"SOMEWHERE: #{val}"
}
assert_parse_only(
@@ -717,7 +717,7 @@ picture: !binary |
Pz7Y6OjuDg4J+fn5OTk6enp
56enmleECcgggoBADs=
-hmm: !somewhere.com/2002:type |
+hmm: !somewhere.com,2002/type |
family above is short for
http://somewhere.com/type
EOY
@@ -726,7 +726,7 @@ EOY
def test_spec_application_family
# Testing the clarkevans.com graphs
- Psych.add_domain_type( "clarkevans.com/2002", 'graph/shape' ) { |type, val|
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
if Array === val
val << "Shape Container"
val
@@ -743,13 +743,13 @@ EOY
raise ArgumentError, "Invalid graph of type #{val.class}: " + val.inspect
end
}
- Psych.add_domain_type( "clarkevans.com/2002", 'graph/circle', &one_shape_proc )
- Psych.add_domain_type( "clarkevans.com/2002", 'graph/line', &one_shape_proc )
- Psych.add_domain_type( "clarkevans.com/2002", 'graph/text', &one_shape_proc )
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
+ Psych.add_domain_type( "clarkevans.com,2002", 'graph/text', &one_shape_proc )
# MODIFIED to remove invalid Psych
assert_parse_only(
[[{"radius"=>7, "center"=>{"x"=>73, "y"=>129}, "TYPE"=>"Shape: graph/circle"}, {"finish"=>{"x"=>89, "y"=>102}, "TYPE"=>"Shape: graph/line", "start"=>{"x"=>73, "y"=>129}}, {"TYPE"=>"Shape: graph/text", "value"=>"Pretty vector drawing.", "start"=>{"x"=>73, "y"=>129}, "color"=>16772795}, "Shape Container"]], <<EOY
-- !clarkevans.com/2002:graph/shape
+- !clarkevans.com,2002/graph/shape
- !/graph/circle
center: &ORIGIN {x: 73, y: 129}
radius: 7
@@ -771,8 +771,8 @@ EOY
# have the same type and value.
- 10.0
- !float 10
-- !yaml.org/2002/float '10'
-- !yaml.org/2002/float "\\
+- !yaml.org,2002/float '10'
+- !yaml.org,2002/float "\\
1\\
0"
EOY
diff --git a/test/psych/test_yaml_special_cases.rb b/test/psych/test_yaml_special_cases.rb
deleted file mode 100644
index 4501704030..0000000000
--- a/test/psych/test_yaml_special_cases.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'helper'
-
-require 'stringio'
-require 'tempfile'
-
-module Psych
- class TestYamlSpecialCases < TestCase
- def setup
- super
- end
-
- def test_empty_string
- s = ""
- assert_equal false, Psych.load(s)
- assert_equal [], Psych.load_stream(s)
- assert_equal false, Psych.parse(s)
- assert_equal [], Psych.parse_stream(s).transform
- assert_nil Psych.safe_load(s)
- end
-
- def test_false
- s = "false"
- assert_equal false, Psych.load(s)
- assert_equal [false], Psych.load_stream(s)
- assert_equal false, Psych.parse(s).transform
- assert_equal [false], Psych.parse_stream(s).transform
- assert_equal false, Psych.safe_load(s)
- end
-
- def test_n
- s = "n"
- assert_equal "n", Psych.load(s)
- assert_equal ["n"], Psych.load_stream(s)
- assert_equal "n", Psych.parse(s).transform
- assert_equal ["n"], Psych.parse_stream(s).transform
- assert_equal "n", Psych.safe_load(s)
- end
-
- def test_off
- s = "off"
- assert_equal false, Psych.load(s)
- assert_equal [false], Psych.load_stream(s)
- assert_equal false, Psych.parse(s).transform
- assert_equal [false], Psych.parse_stream(s).transform
- assert_equal false, Psych.safe_load(s)
- end
-
- def test_inf
- s = "-.inf"
- assert_equal(-Float::INFINITY, Psych.load(s))
- assert_equal([-Float::INFINITY], Psych.load_stream(s))
- assert_equal(-Float::INFINITY, Psych.parse(s).transform)
- assert_equal([-Float::INFINITY], Psych.parse_stream(s).transform)
- assert_equal(-Float::INFINITY, Psych.safe_load(s))
- end
-
- def test_NaN
- s = ".NaN"
- assert Float::NAN, Psych.load(s).nan?
- assert [Float::NAN], Psych.load_stream(s).first.nan?
- assert Psych.parse(s).transform.nan?
- assert Psych.parse_stream(s).transform.first.nan?
- assert Psych.safe_load(s).nan?
- end
-
- def test_0xC
- s = "0xC"
- assert_equal 12, Psych.load(s)
- assert_equal [12], Psych.load_stream(s)
- assert_equal 12, Psych.parse(s).transform
- assert_equal [12], Psych.parse_stream(s).transform
- assert_equal 12, Psych.safe_load(s)
- end
-
- def test_arrows
- s = "<<"
- assert_equal "<<", Psych.load(s)
- assert_equal ["<<"], Psych.load_stream(s)
- assert_equal "<<", Psych.parse(s).transform
- assert_equal ["<<"], Psych.parse_stream(s).transform
- assert_equal "<<", Psych.safe_load(s)
- end
-
- def test_arrows_hash
- s = "<<: {}"
- assert_equal({}, Psych.load(s))
- assert_equal [{}], Psych.load_stream(s)
- assert_equal({}, Psych.parse(s).transform)
- assert_equal [{}], Psych.parse_stream(s).transform
- assert_equal({}, Psych.safe_load(s))
- end
-
- def test_thousand
- s = "- 1000\n- +1000\n- 1_000"
- assert_equal [1000, 1000, 1000], Psych.load(s)
- assert_equal [[1000, 1000, 1000]], Psych.load_stream(s)
- assert_equal [1000, 1000, 1000], Psych.parse(s).transform
- assert_equal [[1000, 1000, 1000]], Psych.parse_stream(s).transform
- assert_equal [1000, 1000, 1000], Psych.safe_load(s)
- end
-
- def test_8
- s = "[8, 08, 0o10, 010]"
- assert_equal [8, "08", "0o10", 8], Psych.load(s)
- assert_equal [[8, "08", "0o10", 8]], Psych.load_stream(s)
- assert_equal [8, "08", "0o10", 8], Psych.parse(s).transform
- assert_equal [[8, "08", "0o10", 8]], Psych.parse_stream(s).transform
- assert_equal [8, "08", "0o10", 8], Psych.safe_load(s)
- end
-
- def test_null
- s = "null"
- assert_nil Psych.load(s)
- assert_equal [nil], Psych.load_stream(s)
- assert_nil Psych.parse(s).transform
- assert_equal [nil], Psych.parse_stream(s).transform
- assert_nil Psych.safe_load(s)
- end
-
- private
-
- def special_case_cycle(object)
- %w[load load_stream parse parse_stream safe_load].map do |m|
- Psych.public_send(m, object)
- end
- end
- end
-end
diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index 69885ee9c6..01f1aecd08 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -7,7 +7,7 @@ module Psych
class TestDelegatorClass < Delegator
def initialize(obj); super; @obj = obj; end
def __setobj__(obj); @obj = obj; end
- def __getobj__; @obj if defined?(@obj); end
+ def __getobj__; @obj; end
end
class TestSimpleDelegatorClass < SimpleDelegator
diff --git a/test/racc/assets/cadenza.y b/test/racc/assets/cadenza.y
deleted file mode 100644
index 1940ead225..0000000000
--- a/test/racc/assets/cadenza.y
+++ /dev/null
@@ -1,170 +0,0 @@
-# This grammar is released under an MIT license
-# Author: William Howard (http://github.com/whoward)
-# Source: https://github.com/whoward/cadenza/blob/master/src/cadenza.y
-
-class Cadenza::RaccParser
-
-/* expect this many shift/reduce conflicts */
-expect 37
-
-rule
- target
- : document
- | /* none */ { result = nil }
- ;
-
- parameter_list
- : logical_expression { result = [val[0]] }
- | parameter_list ',' logical_expression { result = val[0].push(val[2]) }
- ;
-
- /* this has a shift/reduce conflict but since Racc will shift in this case it is the correct behavior */
- primary_expression
- : IDENTIFIER { result = VariableNode.new(val[0].value) }
- | IDENTIFIER parameter_list { result = VariableNode.new(val[0].value, val[1]) }
- | INTEGER { result = ConstantNode.new(val[0].value) }
- | REAL { result = ConstantNode.new(val[0].value) }
- | STRING { result = ConstantNode.new(val[0].value) }
- | '(' filtered_expression ')' { result = val[1] }
- ;
-
- multiplicative_expression
- : primary_expression
- | multiplicative_expression '*' primary_expression { result = OperationNode.new(val[0], "*", val[2]) }
- | multiplicative_expression '/' primary_expression { result = OperationNode.new(val[0], "/", val[2]) }
- ;
-
- additive_expression
- : multiplicative_expression
- | additive_expression '+' multiplicative_expression { result = OperationNode.new(val[0], "+", val[2]) }
- | additive_expression '-' multiplicative_expression { result = OperationNode.new(val[0], "-", val[2]) }
- ;
-
- boolean_expression
- : additive_expression
- | boolean_expression OP_EQ additive_expression { result = OperationNode.new(val[0], "==", val[2]) }
- | boolean_expression OP_NEQ additive_expression { result = OperationNode.new(val[0], "!=", val[2]) }
- | boolean_expression OP_LEQ additive_expression { result = OperationNode.new(val[0], "<=", val[2]) }
- | boolean_expression OP_GEQ additive_expression { result = OperationNode.new(val[0], ">=", val[2]) }
- | boolean_expression '>' additive_expression { result = OperationNode.new(val[0], ">", val[2]) }
- | boolean_expression '<' additive_expression { result = OperationNode.new(val[0], "<", val[2]) }
- ;
-
- inverse_expression
- : boolean_expression
- | NOT boolean_expression { result = BooleanInverseNode.new(val[1]) }
- ;
-
- logical_expression
- : inverse_expression
- | logical_expression AND inverse_expression { result = OperationNode.new(val[0], "and", val[2]) }
- | logical_expression OR inverse_expression { result = OperationNode.new(val[0], "or", val[2]) }
- ;
-
- filter
- : IDENTIFIER { result = FilterNode.new(val[0].value) }
- | IDENTIFIER ':' parameter_list { result = FilterNode.new(val[0].value, val[2]) }
- ;
-
- filter_list
- : filter { result = [val[0]] }
- | filter_list '|' filter { result = val[0].push(val[2]) }
- ;
-
- filtered_expression
- : logical_expression
- | logical_expression '|' filter_list { result = FilteredValueNode.new(val[0], val[2]) }
- ;
-
- inject_statement
- : VAR_OPEN filtered_expression VAR_CLOSE { result = val[1] }
- ;
-
- if_tag
- : STMT_OPEN IF logical_expression STMT_CLOSE { open_scope!; result = val[2] }
- | STMT_OPEN UNLESS logical_expression STMT_CLOSE { open_scope!; result = BooleanInverseNode.new(val[2]) }
- ;
-
- else_tag
- : STMT_OPEN ELSE STMT_CLOSE { result = close_scope!; open_scope! }
- ;
-
- end_if_tag
- : STMT_OPEN ENDIF STMT_CLOSE { result = close_scope! }
- | STMT_OPEN ENDUNLESS STMT_CLOSE { result = close_scope! }
- ;
-
- if_block
- : if_tag end_if_tag { result = IfNode.new(val[0], val[1]) }
- | if_tag document end_if_tag { result = IfNode.new(val[0], val[2]) }
- | if_tag else_tag document end_if_tag { result = IfNode.new(val[0], val[1], val[3]) }
- | if_tag document else_tag end_if_tag { result = IfNode.new(val[0], val[2], val[3]) }
- | if_tag document else_tag document end_if_tag { result = IfNode.new(val[0], val[2], val[4]) }
- ;
-
- for_tag
- : STMT_OPEN FOR IDENTIFIER IN filtered_expression STMT_CLOSE { open_scope!; result = [val[2].value, val[4]] }
- ;
-
- end_for_tag
- : STMT_OPEN ENDFOR STMT_CLOSE { result = close_scope! }
- ;
-
- /* this has a shift/reduce conflict but since Racc will shift in this case it is the correct behavior */
- for_block
- : for_tag end_for_tag { result = ForNode.new(VariableNode.new(val[0].first), val[0].last, val[1]) }
- | for_tag document end_for_tag { result = ForNode.new(VariableNode.new(val[0].first), val[0].last, val[2]) }
- ;
-
- block_tag
- : STMT_OPEN BLOCK IDENTIFIER STMT_CLOSE { result = open_block_scope!(val[2].value) }
- ;
-
- end_block_tag
- : STMT_OPEN ENDBLOCK STMT_CLOSE { result = close_block_scope! }
- ;
-
- /* this has a shift/reduce conflict but since Racc will shift in this case it is the correct behavior */
- block_block
- : block_tag end_block_tag { result = BlockNode.new(val[0], val[1]) }
- | block_tag document end_block_tag { result = BlockNode.new(val[0], val[2]) }
- ;
-
- generic_block_tag
- : STMT_OPEN IDENTIFIER STMT_CLOSE { open_scope!; result = [val[1].value, []] }
- | STMT_OPEN IDENTIFIER parameter_list STMT_CLOSE { open_scope!; result = [val[1].value, val[2]] }
- ;
-
- end_generic_block_tag
- : STMT_OPEN END STMT_CLOSE { result = close_scope! }
- ;
-
- generic_block
- : generic_block_tag document end_generic_block_tag { result = GenericBlockNode.new(val[0].first, val[2], val[0].last) }
- ;
-
- extends_statement
- : STMT_OPEN EXTENDS STRING STMT_CLOSE { result = val[2].value }
- | STMT_OPEN EXTENDS IDENTIFIER STMT_CLOSE { result = VariableNode.new(val[2].value) }
- ;
-
- document_component
- : TEXT_BLOCK { result = TextNode.new(val[0].value) }
- | inject_statement
- | if_block
- | for_block
- | generic_block
- | block_block
- ;
-
- document
- : document_component { push val[0] }
- | document document_component { push val[1] }
- | extends_statement { document.extends = val[0] }
- | document extends_statement { document.extends = val[1] }
- ;
-
----- header ----
-# racc_parser.rb : generated by racc
-
----- inner ----
diff --git a/test/racc/assets/cast.y b/test/racc/assets/cast.y
deleted file mode 100644
index d180c09e14..0000000000
--- a/test/racc/assets/cast.y
+++ /dev/null
@@ -1,926 +0,0 @@
-# The MIT License
-#
-# Copyright (c) George Ogata
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class C::Parser
-# shift/reduce conflict on "if (c) if (c) ; else ; else ;"
-expect 1
-rule
-
-# A.2.4 External definitions
-
-# Returns TranslationUnit
-translation_unit
- : external_declaration {result = TranslationUnit.new_at(val[0].pos, NodeChain[val[0]])}
- | translation_unit external_declaration {result = val[0]; result.entities << val[1]}
-
-# Returns Declaration|FunctionDef
-external_declaration
- : function_definition {result = val[0]}
- | declaration {result = val[0]}
-
-# Returns FunctionDef
-function_definition
- : declaration_specifiers declarator declaration_list compound_statement {result = make_function_def(val[0][0], val[0][1], val[1], val[2], val[3])}
- | declaration_specifiers declarator compound_statement {result = make_function_def(val[0][0], val[0][1], val[1], nil , val[2])}
-
-# Returns [Declaration]
-declaration_list
- : declaration {result = [val[0]]}
- | declaration_list declaration {result = val[0] << val[1]}
-
-# A.2.3 Statements
-
-# Returns Statement
-statement
- : labeled_statement {result = val[0]}
- | compound_statement {result = val[0]}
- | expression_statement {result = val[0]}
- | selection_statement {result = val[0]}
- | iteration_statement {result = val[0]}
- | jump_statement {result = val[0]}
-
-# Returns Statement
-labeled_statement
- : identifier COLON statement {val[2].labels.unshift(PlainLabel.new_at(val[0].pos, val[0].val)); result = val[2]}
- | CASE constant_expression COLON statement {val[3].labels.unshift(Case .new_at(val[0].pos, val[1] )); result = val[3]}
- | DEFAULT COLON statement {val[2].labels.unshift(Default .new_at(val[0].pos )); result = val[2]}
- # type names can also be used as labels
- | typedef_name COLON statement {val[2].labels.unshift(PlainLabel.new_at(val[0].pos, val[0].name)); result = val[2]}
-
-# Returns Block
-compound_statement
- : LBRACE block_item_list RBRACE {result = Block.new_at(val[0].pos, val[1])}
- | LBRACE RBRACE {result = Block.new_at(val[0].pos )}
-
-# Returns NodeChain[Declaration|Statement]
-block_item_list
- : block_item {result = NodeChain[val[0]]}
- | block_item_list block_item {result = val[0] << val[1]}
-
-# Returns Declaration|Statement
-block_item
- : declaration {result = val[0]}
- | statement {result = val[0]}
-
-# Returns ExpressionStatement
-expression_statement
- : expression SEMICOLON {result = ExpressionStatement.new_at(val[0].pos, val[0])}
- | SEMICOLON {result = ExpressionStatement.new_at(val[0].pos )}
-
-# Returns Statement
-selection_statement
- : IF LPAREN expression RPAREN statement {result = If .new_at(val[0].pos, val[2], val[4] )}
- | IF LPAREN expression RPAREN statement ELSE statement {result = If .new_at(val[0].pos, val[2], val[4], val[6])}
- | SWITCH LPAREN expression RPAREN statement {result = Switch.new_at(val[0].pos, val[2], val[4] )}
-
-# Returns Statement
-iteration_statement
- : WHILE LPAREN expression RPAREN statement {result = While.new_at(val[0].pos, val[2], val[4] )}
- | DO statement WHILE LPAREN expression RPAREN SEMICOLON {result = While.new_at(val[0].pos, val[4], val[1], :do => true )}
- | FOR LPAREN expression SEMICOLON expression SEMICOLON expression RPAREN statement {result = For.new_at(val[0].pos, val[2], val[4], val[6], val[8])}
- | FOR LPAREN expression SEMICOLON expression SEMICOLON RPAREN statement {result = For.new_at(val[0].pos, val[2], val[4], nil , val[7])}
- | FOR LPAREN expression SEMICOLON SEMICOLON expression RPAREN statement {result = For.new_at(val[0].pos, val[2], nil , val[5], val[7])}
- | FOR LPAREN expression SEMICOLON SEMICOLON RPAREN statement {result = For.new_at(val[0].pos, val[2], nil , nil , val[6])}
- | FOR LPAREN SEMICOLON expression SEMICOLON expression RPAREN statement {result = For.new_at(val[0].pos, nil , val[3], val[5], val[7])}
- | FOR LPAREN SEMICOLON expression SEMICOLON RPAREN statement {result = For.new_at(val[0].pos, nil , val[3], nil , val[6])}
- | FOR LPAREN SEMICOLON SEMICOLON expression RPAREN statement {result = For.new_at(val[0].pos, nil , nil , val[4], val[6])}
- | FOR LPAREN SEMICOLON SEMICOLON RPAREN statement {result = For.new_at(val[0].pos, nil , nil , nil , val[5])}
- | FOR LPAREN declaration expression SEMICOLON expression RPAREN statement {result = For.new_at(val[0].pos, val[2], val[3], val[5], val[7])}
- | FOR LPAREN declaration expression SEMICOLON RPAREN statement {result = For.new_at(val[0].pos, val[2], val[3], nil , val[6])}
- | FOR LPAREN declaration SEMICOLON expression RPAREN statement {result = For.new_at(val[0].pos, val[2], nil , val[4], val[6])}
- | FOR LPAREN declaration SEMICOLON RPAREN statement {result = For.new_at(val[0].pos, val[2], nil , nil , val[5])}
-
-# Returns Statement
-jump_statement
- : GOTO identifier SEMICOLON {result = Goto .new_at(val[0].pos, val[1].val)}
- | CONTINUE SEMICOLON {result = Continue.new_at(val[0].pos )}
- | BREAK SEMICOLON {result = Break .new_at(val[0].pos )}
- | RETURN expression SEMICOLON {result = Return .new_at(val[0].pos, val[1] )}
- | RETURN SEMICOLON {result = Return .new_at(val[0].pos )}
- # type names can also be used as labels
- | GOTO typedef_name SEMICOLON {result = Goto .new_at(val[0].pos, val[1].name)}
-
-# A.2.2 Declarations
-
-# Returns Declaration
-declaration
- : declaration_specifiers init_declarator_list SEMICOLON {result = make_declaration(val[0][0], val[0][1], val[1])}
- | declaration_specifiers SEMICOLON {result = make_declaration(val[0][0], val[0][1], NodeArray[])}
-
-# Returns {Pos, [Symbol]}
-declaration_specifiers
- : storage_class_specifier declaration_specifiers {val[1][1] << val[0][1]; result = val[1]}
- | storage_class_specifier {result = [val[0][0], [val[0][1]]]}
- | type_specifier declaration_specifiers {val[1][1] << val[0][1]; result = val[1]}
- | type_specifier {result = [val[0][0], [val[0][1]]]}
- | type_qualifier declaration_specifiers {val[1][1] << val[0][1]; result = val[1]}
- | type_qualifier {result = [val[0][0], [val[0][1]]]}
- | function_specifier declaration_specifiers {val[1][1] << val[0][1]; result = val[1]}
- | function_specifier {result = [val[0][0], [val[0][1]]]}
-
-# Returns NodeArray[Declarator]
-init_declarator_list
- : init_declarator {result = NodeArray[val[0]]}
- | init_declarator_list COMMA init_declarator {result = val[0] << val[2]}
-
-# Returns Declarator
-init_declarator
- : declarator {result = val[0]}
- | declarator EQ initializer {val[0].init = val[2]; result = val[0]}
-
-# Returns [Pos, Symbol]
-storage_class_specifier
- : TYPEDEF {result = [val[0].pos, :typedef ]}
- | EXTERN {result = [val[0].pos, :extern ]}
- | STATIC {result = [val[0].pos, :static ]}
- | AUTO {result = [val[0].pos, :auto ]}
- | REGISTER {result = [val[0].pos, :register]}
-
-# Returns [Pos, Type|Symbol]
-type_specifier
- : VOID {result = [val[0].pos, :void ]}
- | CHAR {result = [val[0].pos, :char ]}
- | SHORT {result = [val[0].pos, :short ]}
- | INT {result = [val[0].pos, :int ]}
- | LONG {result = [val[0].pos, :long ]}
- | FLOAT {result = [val[0].pos, :float ]}
- | DOUBLE {result = [val[0].pos, :double ]}
- | SIGNED {result = [val[0].pos, :signed ]}
- | UNSIGNED {result = [val[0].pos, :unsigned ]}
- | BOOL {result = [val[0].pos, :_Bool ]}
- | COMPLEX {result = [val[0].pos, :_Complex ]}
- | IMAGINARY {result = [val[0].pos, :_Imaginary]}
- | struct_or_union_specifier {result = [val[0].pos, val[0] ]}
- | enum_specifier {result = [val[0].pos, val[0] ]}
- | typedef_name {result = [val[0].pos, val[0] ]}
-
-# Returns Struct|Union
-struct_or_union_specifier
- : struct_or_union identifier LBRACE struct_declaration_list RBRACE {result = val[0][1].new_at(val[0][0], val[1].val, val[3])}
- | struct_or_union LBRACE struct_declaration_list RBRACE {result = val[0][1].new_at(val[0][0], nil , val[2])}
- | struct_or_union identifier {result = val[0][1].new_at(val[0][0], val[1].val, nil )}
- # type names can also be used as struct identifiers
- | struct_or_union typedef_name LBRACE struct_declaration_list RBRACE {result = val[0][1].new_at(val[0][0], val[1].name, val[3])}
- | struct_or_union typedef_name {result = val[0][1].new_at(val[0][0], val[1].name, nil )}
-
-# Returns [Pos, Class]
-struct_or_union
- : STRUCT {result = [val[0].pos, Struct]}
- | UNION {result = [val[0].pos, Union ]}
-
-# Returns NodeArray[Declaration]
-struct_declaration_list
- : struct_declaration {result = NodeArray[val[0]]}
- | struct_declaration_list struct_declaration {val[0] << val[1]; result = val[0]}
-
-# Returns Declaration
-struct_declaration
- : specifier_qualifier_list struct_declarator_list SEMICOLON {result = make_declaration(val[0][0], val[0][1], val[1])}
-
-# Returns {Pos, [Symbol]}
-specifier_qualifier_list
- : type_specifier specifier_qualifier_list {val[1][1] << val[0][1]; result = val[1]}
- | type_specifier {result = [val[0][0], [val[0][1]]]}
- | type_qualifier specifier_qualifier_list {val[1][1] << val[0][1]; result = val[1]}
- | type_qualifier {result = [val[0][0], [val[0][1]]]}
-
-# Returns NodeArray[Declarator]
-struct_declarator_list
- : struct_declarator {result = NodeArray[val[0]]}
- | struct_declarator_list COMMA struct_declarator {result = val[0] << val[2]}
-
-# Returns Declarator
-struct_declarator
- : declarator {result = val[0]}
- | declarator COLON constant_expression {result = val[0]; val[0].num_bits = val[2]}
- | COLON constant_expression {result = Declarator.new_at(val[0].pos, :num_bits => val[1])}
-
-# Returns Enum
-enum_specifier
- : ENUM identifier LBRACE enumerator_list RBRACE {result = Enum.new_at(val[0].pos, val[1].val, val[3])}
- | ENUM LBRACE enumerator_list RBRACE {result = Enum.new_at(val[0].pos, nil , val[2])}
- | ENUM identifier LBRACE enumerator_list COMMA RBRACE {result = Enum.new_at(val[0].pos, val[1].val, val[3])}
- | ENUM LBRACE enumerator_list COMMA RBRACE {result = Enum.new_at(val[0].pos, nil , val[2])}
- | ENUM identifier {result = Enum.new_at(val[0].pos, val[1].val, nil )}
- # type names can also be used as enum names
- | ENUM typedef_name LBRACE enumerator_list RBRACE {result = Enum.new_at(val[0].pos, val[1].name, val[3])}
- | ENUM typedef_name LBRACE enumerator_list COMMA RBRACE {result = Enum.new_at(val[0].pos, val[1].name, val[3])}
- | ENUM typedef_name {result = Enum.new_at(val[0].pos, val[1].name, nil )}
-
-# Returns NodeArray[Enumerator]
-enumerator_list
- : enumerator {result = NodeArray[val[0]]}
- | enumerator_list COMMA enumerator {result = val[0] << val[2]}
-
-# Returns Enumerator
-enumerator
- : enumeration_constant {result = Enumerator.new_at(val[0].pos, val[0].val, nil )}
- | enumeration_constant EQ constant_expression {result = Enumerator.new_at(val[0].pos, val[0].val, val[2])}
-
-# Returns [Pos, Symbol]
-type_qualifier
- : CONST {result = [val[0].pos, :const ]}
- | RESTRICT {result = [val[0].pos, :restrict]}
- | VOLATILE {result = [val[0].pos, :volatile]}
-
-# Returns [Pos, Symbol]
-function_specifier
- : INLINE {result = [val[0].pos, :inline]}
-
-# Returns Declarator
-declarator
- : pointer direct_declarator {result = add_decl_type(val[1], val[0])}
- | direct_declarator {result = val[0]}
-
-# Returns Declarator
-direct_declarator
- : identifier {result = Declarator.new_at(val[0].pos, nil, val[0].val)}
- | LPAREN declarator RPAREN {result = val[1]}
- | direct_declarator LBRACKET type_qualifier_list assignment_expression RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))} # TODO
- | direct_declarator LBRACKET type_qualifier_list RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))} # TODO
- | direct_declarator LBRACKET assignment_expression RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos, nil, val[2]))}
- | direct_declarator LBRACKET RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))}
- | direct_declarator LBRACKET STATIC type_qualifier_list assignment_expression RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))} # TODO
- | direct_declarator LBRACKET STATIC assignment_expression RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))} # TODO
- | direct_declarator LBRACKET type_qualifier_list STATIC assignment_expression RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))} # TODO
- | direct_declarator LBRACKET type_qualifier_list MUL RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))} # TODO
- | direct_declarator LBRACKET MUL RBRACKET {result = add_decl_type(val[0], Array.new_at(val[0].pos ))} # TODO
- | direct_declarator LPAREN parameter_type_list RPAREN {result = add_decl_type(val[0], Function.new_at(val[0].pos, nil, param_list(*val[2]), :var_args => val[2][1]))}
- | direct_declarator LPAREN identifier_list RPAREN {result = add_decl_type(val[0], Function.new_at(val[0].pos, nil, val[2]))}
- | direct_declarator LPAREN RPAREN {result = add_decl_type(val[0], Function.new_at(val[0].pos ))}
-
-# Returns Pointer
-pointer
- : MUL type_qualifier_list {result = add_type_quals(Pointer.new_at(val[0].pos), val[1][1]) }
- | MUL {result = Pointer.new_at(val[0].pos) }
- | MUL type_qualifier_list pointer {p = add_type_quals(Pointer.new_at(val[0].pos), val[1][1]); val[2].direct_type = p; result = val[2]}
- | MUL pointer {p = Pointer.new_at(val[0].pos) ; val[1].direct_type = p; result = val[1]}
-
-# Returns {Pos, [Symbol]}
-type_qualifier_list
- : type_qualifier {result = [val[0][0], [val[0][1]]]}
- | type_qualifier_list type_qualifier {val[0][1] << val[1][1]; result = val[0]}
-
-# Returns [NodeArray[Parameter], var_args?]
-parameter_type_list
- : parameter_list {result = [val[0], false]}
- | parameter_list COMMA ELLIPSIS {result = [val[0], true ]}
-
-# Returns NodeArray[Parameter]
-parameter_list
- : parameter_declaration {result = NodeArray[val[0]]}
- | parameter_list COMMA parameter_declaration {result = val[0] << val[2]}
-
-# Returns Parameter
-parameter_declaration
- : declaration_specifiers declarator {ind_type = val[1].indirect_type and ind_type.detach
- result = make_parameter(val[0][0], val[0][1], ind_type, val[1].name)}
- | declaration_specifiers abstract_declarator {result = make_parameter(val[0][0], val[0][1], val[1] , nil )}
- | declaration_specifiers {result = make_parameter(val[0][0], val[0][1], nil , nil )}
-
-# Returns NodeArray[Parameter]
-identifier_list
- : identifier {result = NodeArray[Parameter.new_at(val[0].pos, nil, val[0].val)]}
- | identifier_list COMMA identifier {result = val[0] << Parameter.new_at(val[2].pos, nil, val[2].val)}
-
-# Returns Type
-type_name
- : specifier_qualifier_list abstract_declarator {val[1].direct_type = make_direct_type(val[0][0], val[0][1]); result = val[1]}
- | specifier_qualifier_list {result = make_direct_type(val[0][0], val[0][1]) }
-
-# Returns Type
-abstract_declarator
- : pointer {result = val[0]}
- | pointer direct_abstract_declarator {val[1].direct_type = val[0]; result = val[1]}
- | direct_abstract_declarator {result = val[0]}
-
-# Returns Type
-direct_abstract_declarator
- : LPAREN abstract_declarator RPAREN {result = val[1]}
- | direct_abstract_declarator LBRACKET assignment_expression RBRACKET {val[0].direct_type = Array.new_at(val[0].pos, nil, val[2]); result = val[0]}
- | direct_abstract_declarator LBRACKET RBRACKET {val[0].direct_type = Array.new_at(val[0].pos, nil, nil ); result = val[0]}
- | LBRACKET assignment_expression RBRACKET {result = Array.new_at(val[0].pos, nil, val[1])}
- | LBRACKET RBRACKET {result = Array.new_at(val[0].pos )}
- | direct_abstract_declarator LBRACKET MUL RBRACKET {val[0].direct_type = Array.new_at(val[0].pos); result = val[0]} # TODO
- | LBRACKET MUL RBRACKET {result = Array.new_at(val[0].pos)} # TODO
- | direct_abstract_declarator LPAREN parameter_type_list RPAREN {val[0].direct_type = Function.new_at(val[0].pos, nil, param_list(*val[2]), val[2][1]); result = val[0]}
- | direct_abstract_declarator LPAREN RPAREN {val[0].direct_type = Function.new_at(val[0].pos ); result = val[0]}
- | LPAREN parameter_type_list RPAREN {result = Function.new_at(val[0].pos, nil, param_list(*val[1]), val[1][1])}
- | LPAREN RPAREN {result = Function.new_at(val[0].pos )}
-
-# Returns CustomType
-typedef_name
- #: identifier -- insufficient since we must distinguish between type
- # names and var names (otherwise we have a conflict)
- : TYPENAME {result = CustomType.new_at(val[0].pos, val[0].val)}
-
-# Returns Expression
-initializer
- : assignment_expression {result = val[0]}
- | LBRACE initializer_list RBRACE {result = CompoundLiteral.new_at(val[0].pos, nil, val[1])}
- | LBRACE initializer_list COMMA RBRACE {result = CompoundLiteral.new_at(val[0].pos, nil, val[1])}
-
-# Returns NodeArray[MemberInit]
-initializer_list
- : designation initializer {result = NodeArray[MemberInit.new_at(val[0][0] , val[0][1], val[1])]}
- | initializer {result = NodeArray[MemberInit.new_at(val[0].pos, nil , val[0])]}
- | initializer_list COMMA designation initializer {result = val[0] << MemberInit.new_at(val[2][0] , val[2][1], val[3])}
- | initializer_list COMMA initializer {result = val[0] << MemberInit.new_at(val[2].pos, nil , val[2])}
-
-# Returns {Pos, NodeArray[Expression|Token]}
-designation
- : designator_list EQ {result = val[0]}
-
-# Returns {Pos, NodeArray[Expression|Token]}
-designator_list
- : designator {result = val[0]; val[0][1] = NodeArray[val[0][1]]}
- | designator_list designator {result = val[0]; val[0][1] << val[1][1]}
-
-# Returns {Pos, Expression|Member}
-designator
- : LBRACKET constant_expression RBRACKET {result = [val[1].pos, val[1] ]}
- | DOT identifier {result = [val[1].pos, Member.new_at(val[1].pos, val[1].val)]}
-
-# A.2.1 Expressions
-
-# Returns Expression
-primary_expression
- : identifier {result = Variable.new_at(val[0].pos, val[0].val)}
- | constant {result = val[0]}
- | string_literal {result = val[0]}
- # GCC EXTENSION: allow a compound statement in parentheses as an expression
- | LPAREN expression RPAREN {result = val[1]}
- | LPAREN compound_statement RPAREN {block_expressions_enabled? or parse_error val[0].pos, "compound statement found where expression expected"
- result = BlockExpression.new(val[1]); result.pos = val[0].pos}
-
-# Returns Expression
-postfix_expression
- : primary_expression {result = val[0]}
- | postfix_expression LBRACKET expression RBRACKET {result = Index .new_at(val[0].pos, val[0], val[2])}
- | postfix_expression LPAREN argument_expression_list RPAREN {result = Call .new_at(val[0].pos, val[0], val[2] )}
- | postfix_expression LPAREN RPAREN {result = Call .new_at(val[0].pos, val[0], NodeArray[])}
- | postfix_expression DOT identifier {result = Dot .new_at(val[0].pos, val[0], Member.new(val[2].val))}
- | postfix_expression ARROW identifier {result = Arrow .new_at(val[0].pos, val[0], Member.new(val[2].val))}
- | postfix_expression INC {result = PostInc .new_at(val[0].pos, val[0] )}
- | postfix_expression DEC {result = PostDec .new_at(val[0].pos, val[0] )}
- | LPAREN type_name RPAREN LBRACE initializer_list RBRACE {result = CompoundLiteral.new_at(val[0].pos, val[1], val[4])}
- | LPAREN type_name RPAREN LBRACE initializer_list COMMA RBRACE {result = CompoundLiteral.new_at(val[0].pos, val[1], val[4])}
-
-# Returns [Expression|Type]
-argument_expression_list
- : argument_expression {result = NodeArray[val[0]]}
- | argument_expression_list COMMA argument_expression {result = val[0] << val[2]}
-
-# Returns Expression|Type -- EXTENSION: allow type names here too, to support some standard library macros (e.g., va_arg [7.15.1.1])
-argument_expression
- : assignment_expression {result = val[0]}
- | type_name {result = val[0]}
-
-# Returns Expression
-unary_expression
- : postfix_expression {result = val[0]}
- | INC unary_expression {result = PreInc.new_at(val[0].pos, val[1])}
- | DEC unary_expression {result = PreDec.new_at(val[0].pos, val[1])}
- | unary_operator cast_expression {result = val[0][0].new_at(val[0][1], val[1])}
- | SIZEOF unary_expression {result = Sizeof.new_at(val[0].pos, val[1])}
- | SIZEOF LPAREN type_name RPAREN {result = Sizeof.new_at(val[0].pos, val[2])}
-
-# Returns [Class, Pos]
-unary_operator
- : AND {result = [Address , val[0].pos]}
- | MUL {result = [Dereference, val[0].pos]}
- | ADD {result = [Positive , val[0].pos]}
- | SUB {result = [Negative , val[0].pos]}
- | NOT {result = [BitNot , val[0].pos]}
- | BANG {result = [Not , val[0].pos]}
-
-# Returns Expression
-cast_expression
- : unary_expression {result = val[0]}
- | LPAREN type_name RPAREN cast_expression {result = Cast.new_at(val[0].pos, val[1], val[3])}
-
-# Returns Expression
-multiplicative_expression
- : cast_expression {result = val[0]}
- | multiplicative_expression MUL cast_expression {result = Multiply.new_at(val[0].pos, val[0], val[2])}
- | multiplicative_expression DIV cast_expression {result = Divide .new_at(val[0].pos, val[0], val[2])}
- | multiplicative_expression MOD cast_expression {result = Mod .new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-additive_expression
- : multiplicative_expression {result = val[0]}
- | additive_expression ADD multiplicative_expression {result = Add .new_at(val[0].pos, val[0], val[2])}
- | additive_expression SUB multiplicative_expression {result = Subtract.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-shift_expression
- : additive_expression {result = val[0]}
- | shift_expression LSHIFT additive_expression {result = ShiftLeft .new_at(val[0].pos, val[0], val[2])}
- | shift_expression RSHIFT additive_expression {result = ShiftRight.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-relational_expression
- : shift_expression {result = val[0]}
- | relational_expression LT shift_expression {result = Less.new_at(val[0].pos, val[0], val[2])}
- | relational_expression GT shift_expression {result = More.new_at(val[0].pos, val[0], val[2])}
- | relational_expression LEQ shift_expression {result = LessOrEqual.new_at(val[0].pos, val[0], val[2])}
- | relational_expression GEQ shift_expression {result = MoreOrEqual.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-equality_expression
- : relational_expression {result = val[0]}
- | equality_expression EQEQ relational_expression {result = Equal .new_at(val[0].pos, val[0], val[2])}
- | equality_expression NEQ relational_expression {result = NotEqual.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-and_expression
- : equality_expression {result = val[0]}
- | and_expression AND equality_expression {result = BitAnd.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-exclusive_or_expression
- : and_expression {result = val[0]}
- | exclusive_or_expression XOR and_expression {result = BitXor.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-inclusive_or_expression
- : exclusive_or_expression {result = val[0]}
- | inclusive_or_expression OR exclusive_or_expression {result = BitOr.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-logical_and_expression
- : inclusive_or_expression {result = val[0]}
- | logical_and_expression ANDAND inclusive_or_expression {result = And.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-logical_or_expression
- : logical_and_expression {result = val[0]}
- | logical_or_expression OROR logical_and_expression {result = Or.new_at(val[0].pos, val[0], val[2])}
-
-# Returns Expression
-conditional_expression
- : logical_or_expression {result = val[0]}
- | logical_or_expression QUESTION expression COLON conditional_expression {result = Conditional.new_at(val[0].pos, val[0], val[2], val[4])}
-
-# Returns Expression
-assignment_expression
- : conditional_expression {result = val[0]}
- | unary_expression assignment_operator assignment_expression {result = val[1].new_at(val[0].pos, val[0], val[2])}
-
-# Returns Class
-assignment_operator
- : EQ {result = Assign}
- | MULEQ {result = MultiplyAssign}
- | DIVEQ {result = DivideAssign}
- | MODEQ {result = ModAssign}
- | ADDEQ {result = AddAssign}
- | SUBEQ {result = SubtractAssign}
- | LSHIFTEQ {result = ShiftLeftAssign}
- | RSHIFTEQ {result = ShiftRightAssign}
- | ANDEQ {result = BitAndAssign}
- | XOREQ {result = BitXorAssign}
- | OREQ {result = BitOrAssign}
-
-# Returns Expression
-expression
- : assignment_expression {result = val[0]}
- | expression COMMA assignment_expression {
- if val[0].is_a? Comma
- if val[2].is_a? Comma
- val[0].exprs.push(*val[2].exprs)
- else
- val[0].exprs << val[2]
- end
- result = val[0]
- else
- if val[2].is_a? Comma
- val[2].exprs.unshift(val[0])
- val[2].pos = val[0].pos
- result = val[2]
- else
- result = Comma.new_at(val[0].pos, NodeArray[val[0], val[2]])
- end
- end
- }
-
-# Returns Expression
-constant_expression
- : conditional_expression {result = val[0]}
-
-# A.1.1 -- Lexical elements
-#
-# token
-# : keyword (raw string)
-# | identifier expanded below
-# | constant expanded below
-# | string_literal expanded below
-# | punctuator (raw string)
-#
-# preprocessing-token (skip)
-
-# Returns Token
-identifier
- : ID {result = val[0]}
-
-# Returns Literal
-constant
- : ICON {result = val[0].val; result.pos = val[0].pos}
- | FCON {result = val[0].val; result.pos = val[0].pos}
- #| enumeration_constant -- these are parsed as identifiers at all
- # places the `constant' nonterminal appears
- | CCON {result = val[0].val; result.pos = val[0].pos}
-
-# Returns Token
-enumeration_constant
- : ID {result = val[0]}
-
-# Returns StringLiteral
-# Also handles string literal concatenation (6.4.5.4)
-string_literal
- : string_literal SCON {val[0].val << val[1].val.val; result = val[0]}
- | SCON { result = val[0].val; result.pos = val[0].pos }
-
----- inner
- # A.1.9 -- Preprocessing numbers -- skip
- # A.1.8 -- Header names -- skip
-
- # A.1.7 -- Puncuators -- we don't bother with {##,#,%:,%:%:} since
- # we don't do preprocessing
- @@punctuators = %r'\+\+|-[->]|&&|\|\||\.\.\.|(?:<<|>>|[<>=!*/%+\-&^|])=?|[\[\](){}.~?:;,]'
- @@digraphs = %r'<[:%]|[:%]>'
-
- # A.1.6 -- String Literals -- simple for us because we don't decode
- # the string (and indeed accept some illegal strings)
- @@string_literal = %r'L?"(?:[^\\]|\\.)*?"'m
-
- # A.1.5 -- Constants
- @@decimal_floating_constant = %r'(?:(?:\d*\.\d+|\d+\.)(?:e[-+]?\d+)?|\d+e[-+]?\d+)[fl]?'i
- @@hexadecimal_floating_constant = %r'0x(?:(?:[0-9a-f]*\.[0-9a-f]+|[0-9a-f]+\.)|[0-9a-f]+)p[-+]?\d+[fl]?'i
-
- @@integer_constant = %r'(?:[1-9][0-9]*|0x[0-9a-f]+|0[0-7]*)(?:ul?l?|ll?u?)?'i
- @@floating_constant = %r'#{@@decimal_floating_constant}|#{@@hexadecimal_floating_constant}'
- @@enumeration_constant = %r'[a-zA-Z_\\][a-zA-Z_\\0-9]*'
- @@character_constant = %r"L?'(?:[^\\]|\\.)+?'"
- # (note that as with string-literals, we accept some illegal
- # character-constants)
-
- # A.1.4 -- Universal character names -- skip
-
- # A.1.3 -- Identifiers -- skip, since an identifier is lexically
- # identical to an enumeration constant
-
- # A.1.2 Keywords
- keywords = %w'auto break case char const continue default do
-double else enum extern float for goto if inline int long register
-restrict return short signed sizeof static struct switch typedef union
- unsigned void volatile while _Bool _Complex _Imaginary'
- @@keywords = %r"#{keywords.join('|')}"
-
- def initialize
- @type_names = ::Set.new
-
- @warning_proc = lambda{}
- @pos = C::Node::Pos.new(nil, 1, 0)
- end
- def initialize_copy(x)
- @pos = x.pos.dup
- @type_names = x.type_names.dup
- end
- attr_accessor :pos, :type_names
-
- def parse(str)
- if str.respond_to? :read
- str = str.read
- end
- @str = str
- begin
- prepare_lexer(str)
- return do_parse
- rescue ParseError => e
- e.set_backtrace(caller)
- raise
- end
- end
-
- #
- # Error handler, as used by racc.
- #
- def on_error(error_token_id, error_value, value_stack)
- if error_value == '$'
- parse_error @pos, "unexpected EOF"
- else
- parse_error(error_value.pos,
- "parse error on #{token_to_str(error_token_id)} (#{error_value.val})")
- end
- end
-
- def self.feature(name)
- attr_writer "#{name}_enabled"
- class_eval <<-EOS
- def enable_#{name}
- @#{name}_enabled = true
- end
- def #{name}_enabled?
- @#{name}_enabled
- end
- EOS
- end
- private_class_method :feature
-
- #
- # Allow blocks in parentheses as expressions, as per the gcc
- # extension. [http://rubyurl.com/iB7]
- #
- feature :block_expressions
-
- private # ---------------------------------------------------------
-
- class Token
- attr_accessor :pos, :val
- def initialize(pos, val)
- @pos = pos
- @val = val
- end
- end
- def eat(str)
- lines = str.split(/\r\n|[\r\n]/, -1)
- if lines.length == 1
- @pos.col_num += lines[0].length
- else
- @pos.line_num += lines.length - 1
- @pos.col_num = lines[-1].length
- end
- end
-
- #
- # Make a Declaration from the given specs and declarators.
- #
- def make_declaration(pos, specs, declarators)
- specs.all?{|x| x.is_a?(Symbol) || x.is_a?(Type)} or raise specs.map{|x| x.class}.inspect
- decl = Declaration.new_at(pos, nil, declarators)
-
- # set storage class
- storage_classes = specs.find_all do |x|
- [:typedef, :extern, :static, :auto, :register].include? x
- end
- # 6.7.1p2: at most, one storage-class specifier may be given in
- # the declaration specifiers in a declaration
- storage_classes.length <= 1 or
- begin
- if declarators.length == 0
- for_name = ''
- else
- for_name = "for `#{declarators[0].name}'"
- end
- parse_error pos, "multiple or duplicate storage classes given #{for_name}'"
- end
- decl.storage = storage_classes[0]
-
- # set type (specifiers, qualifiers)
- decl.type = make_direct_type(pos, specs)
-
- # set function specifiers
- decl.inline = specs.include?(:inline)
-
- # look for new type names
- if decl.typedef?
- decl.declarators.each do |d|
- if d.name
- @type_names << d.name
- end
- end
- end
-
- return decl
- end
-
- def make_function_def(pos, specs, func_declarator, decl_list, defn)
- add_decl_type(func_declarator, make_direct_type(pos, specs))
-
- # get types from decl_list if necessary
- function = func_declarator.indirect_type
- function.is_a? Function or
- parse_error pos, "non function type for function `#{func_declarator.name}'"
- params = function.params
- if decl_list
- params.all?{|p| p.type.nil?} or
- parse_error pos, "both prototype and declaration list given for `#{func_declarator.name}'"
- decl_list.each do |declaration|
- declaration.declarators.each do |declarator|
- param = params.find{|p| p.name == declarator.name} or
- parse_error pos, "no parameter named #{declarator.name}"
- if declarator.indirect_type
- param.type = declarator.indirect_type
- param.type.direct_type = declaration.type.dup
- else
- param.type = declaration.type.dup
- end
- end
- end
- params.all?{|p| p.type} or
- begin
- s = params.find_all{|p| p.type.nil?}.map{|p| "`#{p.name}'"}.join(' and ')
- parse_error pos, "types missing for parameters #{s}"
- end
- end
-
- fd = FunctionDef.new_at(pos,
- function.detach,
- func_declarator.name,
- defn,
- :no_prototype => !decl_list.nil?)
-
- # set storage class
- # 6.9.1p4: only extern or static allowed
- specs.each do |s|
- [:typedef, :auto, :register].include?(s) and
- "`#{s}' illegal for function"
- end
- storage_classes = specs.find_all do |s|
- s == :extern || s == :static
- end
- # 6.7.1p2: at most, one storage-class specifier may be given in
- # the declaration specifiers in a declaration
- storage_classes.length <= 1 or
- "multiple or duplicate storage classes given for `#{func_declarator.name}'"
- fd.storage = storage_classes[0] if storage_classes[0]
-
- # set function specifiers
- # 6.7.4p5 'inline' can be repeated
- fd.inline = specs.include?(:inline)
-
- return fd
- end
-
- #
- # Make a direct type from the list of type specifiers and type
- # qualifiers.
- #
- def make_direct_type(pos, specs)
- specs_order = [:signed, :unsigned, :short, :long, :double, :void,
- :char, :int, :float, :_Bool, :_Complex, :_Imaginary]
-
- type_specs = specs.find_all do |x|
- specs_order.include?(x) || !x.is_a?(Symbol)
- end
- type_specs.sort! do |a, b|
- (specs_order.index(a)||100) <=> (specs_order.index(b)||100)
- end
-
- # set type specifiers
- # 6.7.2p2: the specifier list should be one of these
- type =
- case type_specs
- when [:void]
- Void.new
- when [:char]
- Char.new
- when [:signed, :char]
- Char.new :signed => true
- when [:unsigned, :char]
- Char.new :signed => false
- when [:short], [:signed, :short], [:short, :int],
- [:signed, :short, :int]
- Int.new :longness => -1
- when [:unsigned, :short], [:unsigned, :short, :int]
- Int.new :unsigned => true, :longness => -1
- when [:int], [:signed], [:signed, :int]
- Int.new
- when [:unsigned], [:unsigned, :int]
- Int.new :unsigned => true
- when [:long], [:signed, :long], [:long, :int],
- [:signed, :long, :int]
- Int.new :longness => 1
- when [:unsigned, :long], [:unsigned, :long, :int]
- Int.new :longness => 1, :unsigned => true
- when [:long, :long], [:signed, :long, :long],
- [:long, :long, :int], [:signed, :long, :long, :int]
- Int.new :longness => 2
- when [:unsigned, :long, :long], [:unsigned, :long, :long, :int]
- Int.new :longness => 2, :unsigned => true
- when [:float]
- Float.new
- when [:double]
- Float.new :longness => 1
- when [:long, :double]
- Float.new :longness => 2
- when [:_Bool]
- Bool.new
- when [:float, :_Complex]
- Complex.new
- when [:double, :_Complex]
- Complex.new :longness => 1
- when [:long, :double, :_Complex]
- Complex.new :longness => 2
- when [:float, :_Imaginary]
- Imaginary.new
- when [:double, :_Imaginary]
- Imaginary.new :longness => 1
- when [:long, :double, :_Imaginary]
- Imaginary.new :longness => 2
- else
- if type_specs.length == 1 &&
- [CustomType, Struct, Union, Enum].any?{|c| type_specs[0].is_a? c}
- type_specs[0]
- else
- if type_specs == []
- parse_error pos, "no type specifiers given"
- else
- parse_error pos, "invalid type specifier combination: #{type_specs.join(' ')}"
- end
- end
- end
- type.pos ||= pos
-
- # set type qualifiers
- # 6.7.3p4: type qualifiers can be repeated
- type.const = specs.any?{|x| x.equal? :const }
- type.restrict = specs.any?{|x| x.equal? :restrict}
- type.volatile = specs.any?{|x| x.equal? :volatile}
-
- return type
- end
-
- def make_parameter(pos, specs, indirect_type, name)
- type = indirect_type
- if type
- type.direct_type = make_direct_type(pos, specs)
- else
- type = make_direct_type(pos, specs)
- end
- [:typedef, :extern, :static, :auto, :inline].each do |sym|
- specs.include? sym and
- parse_error pos, "parameter `#{declarator.name}' declared `#{sym}'"
- end
- return Parameter.new_at(pos, type, name,
- :register => specs.include?(:register))
- end
-
- def add_type_quals(type, quals)
- type.const = quals.include?(:const )
- type.restrict = quals.include?(:restrict)
- type.volatile = quals.include?(:volatile)
- return type
- end
-
- #
- # Add te given type as the "most direct" type to the given
- # declarator. Return the declarator.
- #
- def add_decl_type(declarator, type)
- if declarator.indirect_type
- declarator.indirect_type.direct_type = type
- else
- declarator.indirect_type = type
- end
- return declarator
- end
-
- def param_list(params, var_args)
- if params.length == 1 &&
- params[0].type.is_a?(Void) &&
- params[0].name.nil?
- return NodeArray[]
- elsif params.empty?
- return nil
- else
- return params
- end
- end
-
- def parse_error(pos, str)
- raise ParseError, "#{pos}: #{str}"
- end
-
----- header
-
-require 'set'
-
-# Error classes
-module C
- class ParseError < StandardError; end
-end
-
-# Local variables:
-# mode: ruby
-# end:
diff --git a/test/racc/assets/chk.y b/test/racc/assets/chk.y
deleted file mode 100644
index 7e0ee20f1e..0000000000
--- a/test/racc/assets/chk.y
+++ /dev/null
@@ -1,126 +0,0 @@
-#
-# racc tester
-#
-
-class Calcp
-
- prechigh
- left '*' '/'
- left '+' '-'
- preclow
-
- convert
- NUMBER 'Number'
- end
-
-rule
-
- target : exp | /* none */ { result = 0 } ;
-
- exp : exp '+' exp { result += val[2]; @plus = 'plus' }
- | exp '-' exp { result -= val[2]; @str = "string test" }
- | exp '*' exp { result *= val[2] }
- | exp '/' exp { result /= val[2] }
- | '(' { $emb = true } exp ')'
- {
- raise 'must not happen' unless $emb
- result = val[2]
- }
- | '-' NUMBER { result = -val[1] }
- | NUMBER
- ;
-
-end
-
-----header
-
-class Number; end
-
-----inner
-
- def parse( src )
- $emb = false
- @plus = nil
- @str = nil
- @src = src
- result = do_parse
- if @plus
- raise 'string parse failed' unless @plus == 'plus'
- end
- if @str
- raise 'string parse failed' unless @str == 'string test'
- end
- result
- end
-
- def next_token
- @src.shift
- end
-
- def initialize
- @yydebug = true
- end
-
-----footer
-
-$parser = Calcp.new
-$test_number = 1
-
-def chk( src, ans )
- result = $parser.parse(src)
- raise "test #{$test_number} fail" unless result == ans
- $test_number += 1
-end
-
-chk(
- [ [Number, 9],
- [false, false],
- [false, false] ], 9
-)
-
-chk(
- [ [Number, 5],
- ['*', nil],
- [Number, 1],
- ['-', nil],
- [Number, 1],
- ['*', nil],
- [Number, 8],
- [false, false],
- [false, false] ], -3
-)
-
-chk(
- [ [Number, 5],
- ['+', nil],
- [Number, 2],
- ['-', nil],
- [Number, 5],
- ['+', nil],
- [Number, 2],
- ['-', nil],
- [Number, 5],
- [false, false],
- [false, false] ], -1
-)
-
-chk(
- [ ['-', nil],
- [Number, 4],
- [false, false],
- [false, false] ], -4
-)
-
-chk(
- [ [Number, 7],
- ['*', nil],
- ['(', nil],
- [Number, 4],
- ['+', nil],
- [Number, 3],
- [')', nil],
- ['-', nil],
- [Number, 9],
- [false, false],
- [false, false] ], 40
-)
diff --git a/test/racc/assets/conf.y b/test/racc/assets/conf.y
deleted file mode 100644
index de9de71d28..0000000000
--- a/test/racc/assets/conf.y
+++ /dev/null
@@ -1,16 +0,0 @@
-
-class A
-rule
-
-a: A c C expr;
-
-b: A B; # useless
-
-c: A;
-c: A;
-
-expr: expr '+' expr
-expr: expr '-' expr
-expr: NUMBER
-
-end
diff --git a/test/racc/assets/csspool.y b/test/racc/assets/csspool.y
deleted file mode 100644
index 3d6af25d85..0000000000
--- a/test/racc/assets/csspool.y
+++ /dev/null
@@ -1,729 +0,0 @@
-class CSSPool::CSS::Parser
-
-token CHARSET_SYM IMPORT_SYM STRING SEMI IDENT S COMMA LBRACE RBRACE STAR HASH
-token LSQUARE RSQUARE EQUAL INCLUDES DASHMATCH LPAREN RPAREN FUNCTION GREATER PLUS
-token SLASH NUMBER MINUS LENGTH PERCENTAGE ANGLE TIME FREQ URI
-token IMPORTANT_SYM MEDIA_SYM NOT ONLY AND NTH_PSEUDO_CLASS
-token DOCUMENT_QUERY_SYM FUNCTION_NO_QUOTE
-token TILDE
-token PREFIXMATCH SUFFIXMATCH SUBSTRINGMATCH
-token NOT_PSEUDO_CLASS
-token KEYFRAMES_SYM
-token MATCHES_PSEUDO_CLASS
-token NAMESPACE_SYM
-token MOZ_PSEUDO_ELEMENT
-token RESOLUTION
-token COLON
-token SUPPORTS_SYM
-token OR
-token VARIABLE_NAME
-token CALC_SYM
-token FONTFACE_SYM
-token UNICODE_RANGE
-token RATIO
-
-rule
- document
- : { @handler.start_document }
- stylesheet
- { @handler.end_document }
- ;
- stylesheet
- : charset stylesheet
- | import stylesheet
- | namespace stylesheet
- | charset
- | import
- | namespace
- | body
- |
- ;
- charset
- : CHARSET_SYM STRING SEMI { @handler.charset interpret_string(val[1]), {} }
- ;
- import
- : IMPORT_SYM import_location medium SEMI {
- @handler.import_style val[2], val[1]
- }
- | IMPORT_SYM import_location SEMI {
- @handler.import_style [], val[1]
- }
- ;
- import_location
- : import_location S
- | STRING { result = Terms::String.new interpret_string val.first }
- | URI { result = Terms::URI.new interpret_uri val.first }
- ;
- namespace
- : NAMESPACE_SYM ident import_location SEMI {
- @handler.namespace val[1], val[2]
- }
- | NAMESPACE_SYM import_location SEMI {
- @handler.namespace nil, val[1]
- }
- ;
- medium
- : medium COMMA IDENT {
- result = val[0] << MediaType.new(val[2])
- }
- | IDENT {
- result = [MediaType.new(val[0])]
- }
- ;
- media_query_list
- : media_query { result = MediaQueryList.new([ val[0] ]) }
- | media_query_list COMMA media_query { result = val[0] << val[2] }
- | { result = MediaQueryList.new }
- ;
- media_query
- : optional_only_or_not media_type optional_and_exprs { result = MediaQuery.new(val[0], val[1], val[2]) }
- | media_expr optional_and_exprs { result = MediaQuery.new(nil, val[0], val[1]) }
- ;
- optional_only_or_not
- : ONLY { result = :only }
- | NOT { result = :not }
- | { result = nil }
- ;
- media_type
- : IDENT { result = MediaType.new(val[0]) }
- ;
- media_expr
- : LPAREN optional_space IDENT optional_space RPAREN { result = MediaType.new(val[2]) }
- | LPAREN optional_space IDENT optional_space COLON optional_space expr RPAREN { result = MediaFeature.new(val[2], val[6][0]) }
- ;
- optional_space
- : S { result = val[0] }
- | { result = nil }
- ;
- optional_and_exprs
- : optional_and_exprs AND media_expr { result = val[0] << val[2] }
- | { result = [] }
- ;
- resolution
- : RESOLUTION {
- unit = val.first.gsub(/[\s\d.]/, '')
- number = numeric(val.first)
- result = Terms::Resolution.new(number, unit)
- }
- ;
- body
- : ruleset body
- | conditional_rule body
- | keyframes_rule body
- | fontface_rule body
- | ruleset
- | conditional_rule
- | keyframes_rule
- | fontface_rule
- ;
- conditional_rule
- : media
- | document_query
- | supports
- ;
- body_in_media
- : body
- | empty_ruleset
- ;
- media
- : start_media body_in_media RBRACE { @handler.end_media val.first }
- ;
- start_media
- : MEDIA_SYM media_query_list LBRACE {
- result = val[1]
- @handler.start_media result
- }
- ;
- document_query
- : start_document_query body RBRACE { @handler.end_document_query(before_pos(val), after_pos(val)) }
- | start_document_query RBRACE { @handler.end_document_query(before_pos(val), after_pos(val)) }
- ;
- start_document_query
- : start_document_query_pos url_match_fns LBRACE {
- @handler.start_document_query(val[1], after_pos(val))
- }
- ;
- start_document_query_pos
- : DOCUMENT_QUERY_SYM {
- @handler.node_start_pos = before_pos(val)
- }
- ;
- url_match_fns
- : url_match_fn COMMA url_match_fns {
- result = [val[0], val[2]].flatten
- }
- | url_match_fn {
- result = val
- }
- ;
- url_match_fn
- : function_no_quote
- | function
- | uri
- ;
- supports
- : start_supports body RBRACE { @handler.end_supports }
- | start_supports RBRACE { @handler.end_supports }
- ;
- start_supports
- : SUPPORTS_SYM supports_condition_root LBRACE {
- @handler.start_supports val[1]
- }
- ;
- supports_condition_root
- : supports_negation { result = val.join('') }
- | supports_conjunction_or_disjunction { result = val.join('') }
- | supports_condition_in_parens { result = val.join('') }
- ;
- supports_condition
- : supports_negation { result = val.join('') }
- | supports_conjunction_or_disjunction { result = val.join('') }
- | supports_condition_in_parens { result = val.join('') }
- ;
- supports_condition_in_parens
- : LPAREN supports_condition RPAREN { result = val.join('') }
- | supports_declaration_condition { result = val.join('') }
- ;
- supports_negation
- : NOT supports_condition_in_parens { result = val.join('') }
- ;
- supports_conjunction_or_disjunction
- : supports_conjunction
- | supports_disjunction
- ;
- supports_conjunction
- : supports_condition_in_parens AND supports_condition_in_parens { result = val.join('') }
- | supports_conjunction_or_disjunction AND supports_condition_in_parens { result = val.join('') }
- ;
- supports_disjunction
- : supports_condition_in_parens OR supports_condition_in_parens { result = val.join('') }
- | supports_conjunction_or_disjunction OR supports_condition_in_parens { result = val.join('') }
- ;
- supports_declaration_condition
- : LPAREN declaration_internal RPAREN { result = val.join('') }
- | LPAREN S declaration_internal RPAREN { result = val.join('') }
- ;
- keyframes_rule
- : start_keyframes_rule keyframes_blocks RBRACE
- | start_keyframes_rule RBRACE
- ;
- start_keyframes_rule
- : KEYFRAMES_SYM IDENT LBRACE {
- @handler.start_keyframes_rule val[1]
- }
- ;
- keyframes_blocks
- : keyframes_block keyframes_blocks
- | keyframes_block
- ;
- keyframes_block
- : start_keyframes_block declarations RBRACE { @handler.end_keyframes_block }
- | start_keyframes_block RBRACE { @handler.end_keyframes_block }
- ;
- start_keyframes_block
- : keyframes_selectors LBRACE {
- @handler.start_keyframes_block val[0]
- }
- ;
- keyframes_selectors
- | keyframes_selector COMMA keyframes_selectors {
- result = val[0] + ', ' + val[2]
- }
- | keyframes_selector
- ;
- keyframes_selector
- : IDENT
- | PERCENTAGE { result = val[0].strip }
- ;
- fontface_rule
- : start_fontface_rule declarations RBRACE { @handler.end_fontface_rule }
- | start_fontface_rule RBRACE { @handler.end_fontface_rule }
- ;
- start_fontface_rule
- : FONTFACE_SYM LBRACE {
- @handler.start_fontface_rule
- }
- ;
- ruleset
- : start_selector declarations RBRACE {
- @handler.end_selector val.first
- }
- | start_selector RBRACE {
- @handler.end_selector val.first
- }
- ;
- empty_ruleset
- : optional_space {
- start = @handler.start_selector([])
- @handler.end_selector(start)
- }
- ;
- start_selector
- : S start_selector { result = val.last }
- | selectors LBRACE {
- @handler.start_selector val.first
- }
- ;
- selectors
- : selector COMMA selectors
- {
- sel = Selector.new(val.first, {})
- result = [sel].concat(val[2])
- }
- | selector
- {
- result = [Selector.new(val.first, {})]
- }
- ;
- selector
- : simple_selector combinator selector
- {
- val.flatten!
- val[2].combinator = val.delete_at 1
- result = val
- }
- | simple_selector
- ;
- combinator
- : S { result = :s }
- | GREATER { result = :> }
- | PLUS { result = :+ }
- | TILDE { result = :~ }
- ;
- simple_selector
- : element_name hcap {
- selector = val.first
- selector.additional_selectors = val.last
- result = [selector]
- }
- | element_name { result = val }
- | hcap
- {
- ss = Selectors::Simple.new nil, nil
- ss.additional_selectors = val.flatten
- result = [ss]
- }
- ;
- simple_selectors
- : simple_selector COMMA simple_selectors { result = [val[0], val[2]].flatten }
- | simple_selector
- ;
- ident_with_namespace
- : IDENT { result = [interpret_identifier(val[0]), nil] }
- | IDENT '|' IDENT { result = [interpret_identifier(val[2]), interpret_identifier(val[0])] }
- | '|' IDENT { result = [interpret_identifier(val[1]), nil] }
- | STAR '|' IDENT { result = [interpret_identifier(val[2]), '*'] }
- ;
- element_name
- : ident_with_namespace { result = Selectors::Type.new val.first[0], nil, val.first[1] }
- | STAR { result = Selectors::Universal.new val.first }
- | '|' STAR { result = Selectors::Universal.new val[1] }
- | STAR '|' STAR { result = Selectors::Universal.new val[2], nil, val[0] }
- | IDENT '|' STAR { result = Selectors::Universal.new val[2], nil, interpret_identifier(val[0]) }
- ;
- hcap
- : hash { result = val }
- | class { result = val }
- | attrib { result = val }
- | pseudo { result = val }
- | hash hcap { result = val.flatten }
- | class hcap { result = val.flatten }
- | attrib hcap { result = val.flatten }
- | pseudo hcap { result = val.flatten }
- ;
- hash
- : HASH {
- result = Selectors::Id.new interpret_identifier val.first.sub(/^#/, '')
- }
- class
- : '.' IDENT {
- result = Selectors::Class.new interpret_identifier val.last
- }
- ;
- attrib
- : LSQUARE ident_with_namespace EQUAL IDENT RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::EQUALS,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace EQUAL STRING RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::EQUALS,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace INCLUDES STRING RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::INCLUDES,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace INCLUDES IDENT RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::INCLUDES,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace DASHMATCH IDENT RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::DASHMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace DASHMATCH STRING RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::DASHMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace PREFIXMATCH IDENT RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::PREFIXMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace PREFIXMATCH STRING RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::PREFIXMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace SUFFIXMATCH IDENT RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::SUFFIXMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace SUFFIXMATCH STRING RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::SUFFIXMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace SUBSTRINGMATCH IDENT RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::SUBSTRINGMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace SUBSTRINGMATCH STRING RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::SUBSTRINGMATCH,
- val[1][1]
- )
- }
- | LSQUARE ident_with_namespace RSQUARE {
- result = Selectors::Attribute.new(
- val[1][0],
- nil,
- Selectors::Attribute::SET,
- val[1][1]
- )
- }
- ;
- pseudo
- : COLON IDENT {
- result = Selectors::pseudo interpret_identifier(val[1])
- }
- | COLON COLON IDENT {
- result = Selectors::PseudoElement.new(
- interpret_identifier(val[2])
- )
- }
- | COLON FUNCTION RPAREN {
- result = Selectors::PseudoClass.new(
- interpret_identifier(val[1].sub(/\($/, '')),
- ''
- )
- }
- | COLON FUNCTION IDENT RPAREN {
- result = Selectors::PseudoClass.new(
- interpret_identifier(val[1].sub(/\($/, '')),
- interpret_identifier(val[2])
- )
- }
- | COLON NOT_PSEUDO_CLASS simple_selector RPAREN {
- result = Selectors::PseudoClass.new(
- 'not',
- val[2].first.to_s
- )
- }
- | COLON NTH_PSEUDO_CLASS {
- result = Selectors::PseudoClass.new(
- interpret_identifier(val[1].sub(/\(.*/, '')),
- interpret_identifier(val[1].sub(/.*\(/, '').sub(/\).*/, ''))
- )
- }
- | COLON MATCHES_PSEUDO_CLASS simple_selectors RPAREN {
- result = Selectors::PseudoClass.new(
- val[1].split('(').first.strip,
- val[2].join(', ')
- )
- }
- | COLON MOZ_PSEUDO_ELEMENT optional_space any_number_of_idents optional_space RPAREN {
- result = Selectors::PseudoElement.new(
- interpret_identifier(val[1].sub(/\($/, ''))
- )
- }
- | COLON COLON MOZ_PSEUDO_ELEMENT optional_space any_number_of_idents optional_space RPAREN {
- result = Selectors::PseudoElement.new(
- interpret_identifier(val[2].sub(/\($/, ''))
- )
- }
- ;
- any_number_of_idents
- :
- | multiple_idents
- ;
- multiple_idents
- : IDENT
- | IDENT COMMA multiple_idents
- ;
- # declarations can be separated by one *or more* semicolons. semi-colons at the start or end of a ruleset are also allowed
- one_or_more_semis
- : SEMI
- | SEMI one_or_more_semis
- ;
- declarations
- : declaration one_or_more_semis declarations
- | one_or_more_semis declarations
- | declaration one_or_more_semis
- | declaration
- | one_or_more_semis
- ;
- declaration
- : declaration_internal { @handler.property val.first }
- ;
- declaration_internal
- : property COLON expr prio
- { result = Declaration.new(val.first, val[2], val[3]) }
- | property COLON S expr prio
- { result = Declaration.new(val.first, val[3], val[4]) }
- | property S COLON expr prio
- { result = Declaration.new(val.first, val[3], val[4]) }
- | property S COLON S expr prio
- { result = Declaration.new(val.first, val[4], val[5]) }
- ;
- prio
- : IMPORTANT_SYM { result = true }
- | { result = false }
- ;
- property
- : IDENT { result = interpret_identifier val[0] }
- | STAR IDENT { result = interpret_identifier val.join }
- | VARIABLE_NAME { result = interpret_identifier val[0] }
- ;
- operator
- : COMMA
- | SLASH
- | EQUAL
- ;
- expr
- : term operator expr {
- result = [val.first, val.last].flatten
- val.last.first.operator = val[1]
- }
- | term expr { result = val.flatten }
- | term { result = val }
- ;
- term
- : ident
- | ratio
- | numeric
- | string
- | uri
- | hexcolor
- | calc
- | function
- | resolution
- | VARIABLE_NAME
- | uranges
- ;
- function
- : function S { result = val.first }
- | FUNCTION expr RPAREN {
- name = interpret_identifier val.first.sub(/\($/, '')
- if name == 'rgb'
- result = Terms::Rgb.new(*val[1])
- else
- result = Terms::Function.new name, val[1]
- end
- }
- | FUNCTION RPAREN {
- name = interpret_identifier val.first.sub(/\($/, '')
- result = Terms::Function.new name
- }
- ;
- function_no_quote
- : function_no_quote S { result = val.first }
- | FUNCTION_NO_QUOTE {
- parts = val.first.split('(')
- name = interpret_identifier parts.first
- result = Terms::Function.new(name, [Terms::String.new(interpret_string_no_quote(parts.last))])
- }
- ;
- uranges
- : UNICODE_RANGE COMMA uranges
- | UNICODE_RANGE
- ;
- calc
- : CALC_SYM calc_sum RPAREN optional_space {
- result = Terms::Math.new(val.first.split('(').first, val[1])
- }
- ;
- # plus and minus are supposed to have whitespace around them, per http://dev.w3.org/csswg/css-values/#calc-syntax, but the numbers are eating trailing whitespace, so we inject it back in
- calc_sum
- : calc_product
- | calc_product PLUS calc_sum { val.insert(1, ' '); result = val.join('') }
- | calc_product MINUS calc_sum { val.insert(1, ' '); result = val.join('') }
- ;
- calc_product
- : calc_value
- | calc_value optional_space STAR calc_value { result = val.join('') }
- | calc_value optional_space SLASH calc_value { result = val.join('') }
- ;
- calc_value
- : numeric { result = val.join('') }
- | function { result = val.join('') } # for var() variable references
- | LPAREN calc_sum RPAREN { result = val.join('') }
- ;
- hexcolor
- : hexcolor S { result = val.first }
- | HASH { result = Terms::Hash.new val.first.sub(/^#/, '') }
- ;
- uri
- : uri S { result = val.first }
- | URI { result = Terms::URI.new interpret_uri val.first }
- ;
- string
- : string S { result = val.first }
- | STRING { result = Terms::String.new interpret_string val.first }
- ;
- numeric
- : unary_operator numeric {
- result = val[1]
- val[1].unary_operator = val.first
- }
- | NUMBER {
- result = Terms::Number.new numeric val.first
- }
- | PERCENTAGE {
- result = Terms::Number.new numeric(val.first), nil, '%'
- }
- | LENGTH {
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
- }
- | ANGLE {
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
- }
- | TIME {
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
- }
- | FREQ {
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
- }
- ;
- ratio
- : RATIO {
- result = Terms::Ratio.new(val[0], val[1])
- }
- ;
- unary_operator
- : MINUS { result = :minus }
- | PLUS { result = :plus }
- ;
- ident
- : ident S { result = val.first }
- | IDENT { result = Terms::Ident.new interpret_identifier val.first }
- ;
-
----- inner
-
-def numeric thing
- thing = thing.gsub(/[^\d.]/, '')
- Integer(thing) rescue Float(thing)
-end
-
-def interpret_identifier s
- interpret_escapes s
-end
-
-def interpret_uri s
- interpret_escapes s.match(/^url\((.*)\)$/mui)[1].strip.match(/^(['"]?)((?:\\.|.)*)\1$/mu)[2]
-end
-
-def interpret_string_no_quote s
- interpret_escapes s.match(/^(.*)\)$/mu)[1].strip.match(/^(['"]?)((?:\\.|.)*)\1$/mu)[2]
-end
-
-def interpret_string s
- interpret_escapes s.match(/^(['"])((?:\\.|.)*)\1$/mu)[2]
-end
-
-def interpret_escapes s
- token_exp = /\\(?:([0-9a-fA-F]{1,6}(?:\r\n|\s)?)|(.))/mu
- return s.gsub(token_exp) do |escape_sequence|
- if !$1.nil?
- code = $1.chomp.to_i 16
- code = 0xFFFD if code > 0x10FFFF
- next [code].pack('U')
- end
- next '' if $2 == "\n"
- next $2
- end
-end
-
-# override racc's on_error so we can have context in our error messages
-def on_error(t, val, vstack)
- errcontext = (@ss.pre_match[-10..-1] || @ss.pre_match) +
- @ss.matched + @ss.post_match[0..9]
- line_number = @ss.pre_match.lines.count
- raise ParseError, sprintf("parse error on value %s (%s) " +
- "on line %s around \"%s\"",
- val.inspect, token_to_str(t) || '?',
- line_number, errcontext)
-end
-
-def before_pos(val)
- # don't include leading whitespace
- return current_pos - val.last.length + val.last[/\A\s*/].size
-end
-
-def after_pos(val)
- # don't include trailing whitespace
- return current_pos - val.last[/\s*\z/].size
-end
-
-# charpos will work with multibyte strings but is not available until ruby 2
-def current_pos
- @ss.respond_to?('charpos') ? @ss.charpos : @ss.pos
-end
diff --git a/test/racc/assets/digraph.y b/test/racc/assets/digraph.y
deleted file mode 100644
index 17a034ee54..0000000000
--- a/test/racc/assets/digraph.y
+++ /dev/null
@@ -1,29 +0,0 @@
-# ? detect digraph bug
-
-class P
- token A B C D
-rule
- target : a b c d
- a : A
- |
- b : B
- |
- c : C
- |
- d : D
- |
-end
-
----- inner
-
- def parse
- do_parse
- end
-
- def next_token
- [false, '$']
- end
-
----- footer
-
-P.new.parse
diff --git a/test/racc/assets/echk.y b/test/racc/assets/echk.y
deleted file mode 100644
index 0fda2685aa..0000000000
--- a/test/racc/assets/echk.y
+++ /dev/null
@@ -1,118 +0,0 @@
-#
-# racc tester
-#
-
-class Calcp
-
- prechigh
- left '*' '/'
- left '+' '-'
- preclow
-
- convert
- NUMBER 'Number'
- end
-
-rule
-
- target : exp | /* none */ { result = 0 } ;
-
- exp : exp '+' exp { result += val[2]; a = 'plus' }
- | exp '-' exp { result -= val[2]; "string test" }
- | exp '*' exp { result *= val[2] }
- | exp '/' exp { result /= val[2] }
- | '(' { $emb = true } exp ')'
- {
- raise 'must not happen' unless $emb
- result = val[2]
- }
- | '-' NUMBER { result = -val[1] }
- | NUMBER
- ;
-
-end
-
-----header
-
-class Number ; end
-
-----inner
-
- def parse( src )
- @src = src
- do_parse
- end
-
- def next_token
- @src.shift
- end
-
- def initialize
- @yydebug = true
- end
-
-----footer
-
-$parser = Calcp.new
-$tidx = 1
-
-def chk( src, ans )
- ret = $parser.parse( src )
- unless ret == ans then
- bug! "test #{$tidx} fail"
- end
- $tidx += 1
-end
-
-chk(
- [ [Number, 9],
- [false, false],
- [false, false] ], 9
-)
-
-chk(
- [ [Number, 5],
- ['*', nil],
- [Number, 1],
- ['-', nil],
- [Number, 1],
- ['*', nil],
- [Number, 8],
- [false, false],
- [false, false] ], -3
-)
-
-chk(
- [ [Number, 5],
- ['+', nil],
- [Number, 2],
- ['-', nil],
- [Number, 5],
- ['+', nil],
- [Number, 2],
- ['-', nil],
- [Number, 5],
- [false, false],
- [false, false] ], -1
-)
-
-chk(
- [ ['-', nil],
- [Number, 4],
- [false, false],
- [false, false] ], -4
-)
-
-chk(
- [ [Number, 7],
- ['*', nil],
- ['(', nil],
- [Number, 4],
- ['+', nil],
- [Number, 3],
- [')', nil],
- ['-', nil],
- [Number, 9],
- [false, false],
- [false, false] ], 40
-)
diff --git a/test/racc/assets/edtf.y b/test/racc/assets/edtf.y
deleted file mode 100644
index 4f5f6bb4fd..0000000000
--- a/test/racc/assets/edtf.y
+++ /dev/null
@@ -1,583 +0,0 @@
-# -*- racc -*-
-
-# Copyright 2011 Sylvester Keil. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-# EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and documentation are
-# those of the authors and should not be interpreted as representing official
-# policies, either expressed or implied, of the copyright holder.
-
-class EDTF::Parser
-
-token T Z E X U UNKNOWN OPEN LONGYEAR UNMATCHED DOTS UA PUA
-
-expect 0
-
-rule
-
- edtf : level_0_expression
- | level_1_expression
- | level_2_expression
- ;
-
- # ---- Level 0 / ISO 8601 Rules ----
-
- # NB: level 0 intervals are covered by the level 1 interval rules
- level_0_expression : date
- | date_time
- ;
-
- date : positive_date
- | negative_date
- ;
-
- positive_date :
- year { result = Date.new(val[0]).year_precision! }
- | year_month { result = Date.new(*val.flatten).month_precision! }
- | year_month_day { result = Date.new(*val.flatten).day_precision! }
- ;
-
- negative_date : '-' positive_date { result = -val[1] }
-
-
- date_time : date T time {
- result = DateTime.new(val[0].year, val[0].month, val[0].day, *val[2])
- result.skip_timezone = (val[2].length == 3)
- }
-
- time : base_time
- | base_time zone_offset { result = val.flatten }
-
- base_time : hour ':' minute ':' second { result = val.values_at(0, 2, 4) }
- | midnight
-
- midnight : '2' '4' ':' '0' '0' ':' '0' '0' { result = [24, 0, 0] }
-
- zone_offset : Z { result = 0 }
- | '-' zone_offset_hour { result = -1 * val[1] }
- | '+' positive_zone_offset { result = val[1] }
- ;
-
- positive_zone_offset : zone_offset_hour
- | '0' '0' ':' '0' '0' { result = 0 }
- ;
-
-
- zone_offset_hour : d01_13 ':' minute { result = Rational(val[0] * 60 + val[2], 1440) }
- | '1' '4' ':' '0' '0' { result = Rational(840, 1440) }
- | '0' '0' ':' d01_59 { result = Rational(val[3], 1440) }
- ;
-
- year : digit digit digit digit {
- result = val.zip([1000,100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
- }
-
- month : d01_12
- day : d01_31
-
- year_month : year '-' month { result = [val[0], val[2]] }
-
- # We raise an exception if there are two many days for the month, but
- # do not consider leap years, as the EDTF BNF did not either.
- # NB: an exception will be raised regardless, because the Ruby Date
- # implementation calculates leap years.
- year_month_day : year_month '-' day {
- result = val[0] << val[2]
- if result[2] > 31 || (result[2] > 30 && [2,4,6,9,11].include?(result[1])) || (result[2] > 29 && result[1] == 2)
- raise ArgumentError, "invalid date (invalid days #{result[2]} for month #{result[1]})"
- end
- }
-
- hour : d00_23
- minute : d00_59
- second : d00_59
-
- # Completely covered by level_1_interval
- # level_0_interval : date '/' date { result = Interval.new(val[0], val[1]) }
-
-
- # ---- Level 1 Extension Rules ----
-
- # NB: Uncertain/approximate Dates are covered by the Level 2 rules
- level_1_expression : unspecified | level_1_interval | long_year_simple | season
-
- # uncertain_or_approximate_date : date UA { result = uoa(val[0], val[1]) }
-
- unspecified : unspecified_year
- {
- result = Date.new(val[0][0]).year_precision!
- result.unspecified.year[2,2] = val[0][1]
- }
- | unspecified_month
- | unspecified_day
- | unspecified_day_and_month
- ;
-
- unspecified_year :
- digit digit digit U
- {
- result = [val[0,3].zip([1000,100,10]).reduce(0) { |s,(a,b)| s += a * b }, [false,true]]
- }
- | digit digit U U
- {
- result = [val[0,2].zip([1000,100]).reduce(0) { |s,(a,b)| s += a * b }, [true, true]]
- }
-
- unspecified_month : year '-' U U {
- result = Date.new(val[0]).unspecified!(:month)
- result.precision = :month
- }
-
- unspecified_day : year_month '-' U U {
- result = Date.new(*val[0]).unspecified!(:day)
- }
-
- unspecified_day_and_month : year '-' U U '-' U U {
- result = Date.new(val[0]).unspecified!([:day,:month])
- }
-
-
- level_1_interval : level_1_start '/' level_1_end {
- result = Interval.new(val[0], val[2])
- }
-
- level_1_start : date | partial_uncertain_or_approximate | unspecified | partial_unspecified | UNKNOWN
-
- level_1_end : level_1_start | OPEN
-
-
- long_year_simple :
- LONGYEAR long_year
- {
- result = Date.new(val[1])
- result.precision = :year
- }
- | LONGYEAR '-' long_year
- {
- result = Date.new(-1 * val[2])
- result.precision = :year
- }
- ;
-
- long_year :
- positive_digit digit digit digit digit {
- result = val.zip([10000,1000,100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
- }
- | long_year digit { result = 10 * val[0] + val[1] }
- ;
-
-
- season : year '-' season_number ua {
- result = Season.new(val[0], val[2])
- val[3].each { |ua| result.send(ua) }
- }
-
- season_number : '2' '1' { result = 21 }
- | '2' '2' { result = 22 }
- | '2' '3' { result = 23 }
- | '2' '4' { result = 24 }
- ;
-
-
- # ---- Level 2 Extension Rules ----
-
- # NB: Level 2 Intervals are covered by the Level 1 Interval rules.
- level_2_expression : season_qualified
- | partial_uncertain_or_approximate
- | partial_unspecified
- | choice_list
- | inclusive_list
- | masked_precision
- | date_and_calendar
- | long_year_scientific
- ;
-
-
- season_qualified : season '^' { result = val[0]; result.qualifier = val[1] }
-
-
- long_year_scientific :
- long_year_simple E integer
- {
- result = Date.new(val[0].year * 10 ** val[2]).year_precision!
- }
- | LONGYEAR int1_4 E integer
- {
- result = Date.new(val[1] * 10 ** val[3]).year_precision!
- }
- | LONGYEAR '-' int1_4 E integer
- {
- result = Date.new(-1 * val[2] * 10 ** val[4]).year_precision!
- }
- ;
-
-
- date_and_calendar : date '^' { result = val[0]; result.calendar = val[1] }
-
-
- masked_precision :
- digit digit digit X
- {
- d = val[0,3].zip([1000,100,10]).reduce(0) { |s,(a,b)| s += a * b }
- result = EDTF::Decade.new(d)
- }
- | digit digit X X
- {
- d = val[0,2].zip([1000,100]).reduce(0) { |s,(a,b)| s += a * b }
- result = EDTF::Century.new(d)
- }
- ;
-
-
- choice_list : '[' list ']' { result = val[1].choice! }
-
- inclusive_list : '{' list '}' { result = val[1] }
-
- list : earlier { result = EDTF::Set.new(val[0]).earlier! }
- | earlier ',' list_elements ',' later { result = EDTF::Set.new([val[0]] + val[2] + [val[4]]).earlier!.later! }
- | earlier ',' list_elements { result = EDTF::Set.new([val[0]] + val[2]).earlier! }
- | earlier ',' later { result = EDTF::Set.new([val[0]] + [val[2]]).earlier!.later! }
- | list_elements ',' later { result = EDTF::Set.new(val[0] + [val[2]]).later! }
- | list_elements { result = EDTF::Set.new(*val[0]) }
- | later { result = EDTF::Set.new(val[0]).later! }
- ;
-
- list_elements : list_element { result = [val[0]].flatten }
- | list_elements ',' list_element { result = val[0] + [val[2]].flatten }
- ;
-
- list_element : atomic
- | consecutives
- ;
-
- atomic : date
- | partial_uncertain_or_approximate
- | unspecified
- ;
-
- earlier : DOTS date { result = val[1] }
-
- later : year_month_day DOTS { result = Date.new(*val[0]).year_precision! }
- | year_month DOTS { result = Date.new(*val[0]).month_precision! }
- | year DOTS { result = Date.new(val[0]).year_precision! }
- ;
-
- consecutives : year_month_day DOTS year_month_day { result = (Date.new(val[0]).day_precision! .. Date.new(val[2]).day_precision!) }
- | year_month DOTS year_month { result = (Date.new(val[0]).month_precision! .. Date.new(val[2]).month_precision!) }
- | year DOTS year { result = (Date.new(val[0]).year_precision! .. Date.new(val[2]).year_precision!) }
- ;
-
- partial_unspecified :
- unspecified_year '-' month '-' day
- {
- result = Date.new(val[0][0], val[2], val[4])
- result.unspecified.year[2,2] = val[0][1]
- }
- | unspecified_year '-' U U '-' day
- {
- result = Date.new(val[0][0], 1, val[5])
- result.unspecified.year[2,2] = val[0][1]
- result.unspecified!(:month)
- }
- | unspecified_year '-' U U '-' U U
- {
- result = Date.new(val[0][0], 1, 1)
- result.unspecified.year[2,2] = val[0][1]
- result.unspecified!([:month, :day])
- }
- | unspecified_year '-' month '-' U U
- {
- result = Date.new(val[0][0], val[2], 1)
- result.unspecified.year[2,2] = val[0][1]
- result.unspecified!(:day)
- }
- | year '-' U U '-' day
- {
- result = Date.new(val[0], 1, val[5])
- result.unspecified!(:month)
- }
- ;
-
-
- partial_uncertain_or_approximate : pua_base
- | '(' pua_base ')' UA { result = uoa(val[1], val[3]) }
-
- pua_base :
- pua_year { result = val[0].year_precision! }
- | pua_year_month { result = val[0][0].month_precision! }
- | pua_year_month_day { result = val[0].day_precision! }
-
- pua_year : year UA { result = uoa(Date.new(val[0]), val[1], :year) }
-
- pua_year_month :
- pua_year '-' month ua {
- result = [uoa(val[0].change(:month => val[2]), val[3], [:month, :year])]
- }
- | year '-' month UA {
- result = [uoa(Date.new(val[0], val[2]), val[3], [:year, :month])]
- }
- | year '-(' month ')' UA {
- result = [uoa(Date.new(val[0], val[2]), val[4], [:month]), true]
- }
- | pua_year '-(' month ')' UA {
- result = [uoa(val[0].change(:month => val[2]), val[4], [:month]), true]
- }
- ;
-
- pua_year_month_day :
- pua_year_month '-' day ua {
- result = uoa(val[0][0].change(:day => val[2]), val[3], val[0][1] ? [:day] : nil)
- }
- | pua_year_month '-(' day ')' UA {
- result = uoa(val[0][0].change(:day => val[2]), val[4], [:day])
- }
- | year '-(' month ')' UA day ua {
- result = uoa(uoa(Date.new(val[0], val[2], val[5]), val[4], :month), val[6], :day)
- }
- | year_month '-' day UA {
- result = uoa(Date.new(val[0][0], val[0][1], val[2]), val[3])
- }
- | year_month '-(' day ')' UA {
- result = uoa(Date.new(val[0][0], val[0][1], val[2]), val[4], [:day])
- }
- | year '-(' month '-' day ')' UA {
- result = uoa(Date.new(val[0], val[2], val[4]), val[6], [:month, :day])
- }
- | year '-(' month '-(' day ')' UA ')' UA {
- result = Date.new(val[0], val[2], val[4])
- result = uoa(result, val[6], [:day])
- result = uoa(result, val[8], [:month, :day])
- }
- | pua_year '-(' month '-' day ')' UA {
- result = val[0].change(:month => val[2], :day => val[4])
- result = uoa(result, val[6], [:month, :day])
- }
- | pua_year '-(' month '-(' day ')' UA ')' UA {
- result = val[0].change(:month => val[2], :day => val[4])
- result = uoa(result, val[6], [:day])
- result = uoa(result, val[8], [:month, :day])
- }
- # | '(' pua_year '-(' month ')' UA ')' UA '-' day ua {
- # result = val[1].change(:month => val[3], :day => val[9])
- # result = uoa(result, val[5], [:month])
- # result = [uoa(result, val[7], [:year]), true]
- # }
- ;
-
- ua : { result = [] } | UA
-
- # ---- Auxiliary Rules ----
-
- digit : '0' { result = 0 }
- | positive_digit
- ;
-
- positive_digit : '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
-
- d01_12 : '0' positive_digit { result = val[1] }
- | '1' '0' { result = 10 }
- | '1' '1' { result = 11 }
- | '1' '2' { result = 12 }
- ;
-
- d01_13 : d01_12
- | '1' '3' { result = 13 }
- ;
-
- d01_23 : '0' positive_digit { result = val[1] }
- | '1' digit { result = 10 + val[1] }
- | '2' '0' { result = 20 }
- | '2' '1' { result = 21 }
- | '2' '2' { result = 22 }
- | '2' '3' { result = 23 }
- ;
-
- d00_23 : '0' '0'
- | d01_23
- ;
-
- d01_29 : d01_23
- | '2' '4' { result = 24 }
- | '2' '5' { result = 25 }
- | '2' '6' { result = 26 }
- | '2' '7' { result = 27 }
- | '2' '8' { result = 28 }
- | '2' '9' { result = 29 }
- ;
-
- d01_30 : d01_29
- | '3' '0' { result = 30 }
- ;
-
- d01_31 : d01_30
- | '3' '1' { result = 31 }
- ;
-
- d01_59 : d01_29
- | '3' digit { result = 30 + val[1] }
- | '4' digit { result = 40 + val[1] }
- | '5' digit { result = 50 + val[1] }
- ;
-
- d00_59 : '0' '0'
- | d01_59
- ;
-
- int1_4 : positive_digit { result = val[0] }
- | positive_digit digit { result = 10 * val[0] + val[1] }
- | positive_digit digit digit
- {
- result = val.zip([100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
- }
- | positive_digit digit digit digit
- {
- result = val.zip([1000,100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
- }
- ;
-
- integer : positive_digit { result = val[0] }
- | integer digit { result = 10 * val[0] + val[1] }
- ;
-
-
-
----- header
-require 'strscan'
-
----- inner
-
- @defaults = {
- :level => 2,
- :debug => false
- }.freeze
-
- class << self; attr_reader :defaults; end
-
- attr_reader :options
-
- def initialize(options = {})
- @options = Parser.defaults.merge(options)
- end
-
- def debug?
- !!(options[:debug] || ENV['DEBUG'])
- end
-
- def parse(input)
- parse!(input)
- rescue => e
- warn e.message if debug?
- nil
- end
-
- def parse!(input)
- @yydebug = debug?
- @src = StringScanner.new(input)
- do_parse
- end
-
- def on_error(tid, value, stack)
- raise ArgumentError,
- "failed to parse date: unexpected '#{value}' at #{stack.inspect}"
- end
-
- def apply_uncertainty(date, uncertainty, scope = nil)
- uncertainty.each do |u|
- scope.nil? ? date.send(u) : date.send(u, scope)
- end
- date
- end
-
- alias uoa apply_uncertainty
-
- def next_token
- case
- when @src.eos?
- nil
- # when @src.scan(/\s+/)
- # ignore whitespace
- when @src.scan(/\(/)
- ['(', @src.matched]
- # when @src.scan(/\)\?~-/)
- # [:PUA, [:uncertain!, :approximate!]]
- # when @src.scan(/\)\?-/)
- # [:PUA, [:uncertain!]]
- # when @src.scan(/\)~-/)
- # [:PUA, [:approximate!]]
- when @src.scan(/\)/)
- [')', @src.matched]
- when @src.scan(/\[/)
- ['[', @src.matched]
- when @src.scan(/\]/)
- [']', @src.matched]
- when @src.scan(/\{/)
- ['{', @src.matched]
- when @src.scan(/\}/)
- ['}', @src.matched]
- when @src.scan(/T/)
- [:T, @src.matched]
- when @src.scan(/Z/)
- [:Z, @src.matched]
- when @src.scan(/\?~/)
- [:UA, [:uncertain!, :approximate!]]
- when @src.scan(/\?/)
- [:UA, [:uncertain!]]
- when @src.scan(/~/)
- [:UA, [:approximate!]]
- when @src.scan(/open/i)
- [:OPEN, :open]
- when @src.scan(/unkn?own/i) # matches 'unkown' typo too
- [:UNKNOWN, :unknown]
- when @src.scan(/u/)
- [:U, @src.matched]
- when @src.scan(/x/i)
- [:X, @src.matched]
- when @src.scan(/y/)
- [:LONGYEAR, @src.matched]
- when @src.scan(/e/)
- [:E, @src.matched]
- when @src.scan(/\+/)
- ['+', @src.matched]
- when @src.scan(/-\(/)
- ['-(', @src.matched]
- when @src.scan(/-/)
- ['-', @src.matched]
- when @src.scan(/:/)
- [':', @src.matched]
- when @src.scan(/\//)
- ['/', @src.matched]
- when @src.scan(/\s*\.\.\s*/)
- [:DOTS, '..']
- when @src.scan(/\s*,\s*/)
- [',', ',']
- when @src.scan(/\^\w+/)
- ['^', @src.matched[1..-1]]
- when @src.scan(/\d/)
- [@src.matched, @src.matched.to_i]
- else @src.scan(/./)
- [:UNMATCHED, @src.rest]
- end
- end
-
-
-# -*- racc -*-
diff --git a/test/racc/assets/err.y b/test/racc/assets/err.y
deleted file mode 100644
index ae280957cc..0000000000
--- a/test/racc/assets/err.y
+++ /dev/null
@@ -1,60 +0,0 @@
-
-class ErrTestp
-
-rule
-
-target: lines
- ;
-
-lines: line
- | lines line
- ;
-
-line: A B C D E
- | error E
- ;
-
-end
-
----- inner
-
-def initialize
- @yydebug = false
- @q = [
- [:A, 'a'],
- # [:B, 'b'],
- [:C, 'c'],
- [:D, 'd'],
- [:E, 'e'],
-
- [:A, 'a'],
- [:B, 'b'],
- [:C, 'c'],
- [:D, 'd'],
- [:E, 'e'],
-
- [:A, 'a'],
- [:B, 'b'],
- # [:C, 'c'],
- [:D, 'd'],
- [:E, 'e'],
- [false, nil]
- ]
-end
-
-def next_token
- @q.shift
-end
-
-def on_error( t, val, values )
- $stderr.puts "error on token '#{val}'(#{t})"
-end
-
-def parse
- do_parse
-end
-
----- footer
-
-p = ErrTestp.new
-p.parse
diff --git a/test/racc/assets/error_recovery.y b/test/racc/assets/error_recovery.y
deleted file mode 100644
index 1fd21ac7d0..0000000000
--- a/test/racc/assets/error_recovery.y
+++ /dev/null
@@ -1,35 +0,0 @@
-# Regression test case for the bug discussed here:
-# https://github.com/whitequark/parser/issues/93
-# In short, a Racc-generated parser could go into an infinite loop when
-# attempting error recovery at EOF
-
-class InfiniteLoop
-
-rule
-
- stmts: stmt
- | error stmt
-
- stmt: '%' stmt
-
-end
-
----- inner
-
- def parse
- @errors = []
- do_parse
- end
-
- def next_token
- nil
- end
-
- def on_error(error_token, error_value, value_stack)
- # oh my, an error
- @errors << [error_token, error_value]
- end
-
----- footer
-
-InfiniteLoop.new.parse \ No newline at end of file
diff --git a/test/racc/assets/expect.y b/test/racc/assets/expect.y
deleted file mode 100644
index 24c27443e2..0000000000
--- a/test/racc/assets/expect.y
+++ /dev/null
@@ -1,7 +0,0 @@
-class E
- expect 1
-rule
- list: inlist inlist
- inlist:
- | A
-end
diff --git a/test/racc/assets/firstline.y b/test/racc/assets/firstline.y
deleted file mode 100644
index ab0692e543..0000000000
--- a/test/racc/assets/firstline.y
+++ /dev/null
@@ -1,4 +0,0 @@
-class T
-rule
- a: A B C
-end
diff --git a/test/racc/assets/huia.y b/test/racc/assets/huia.y
deleted file mode 100644
index de9d45150c..0000000000
--- a/test/racc/assets/huia.y
+++ /dev/null
@@ -1,318 +0,0 @@
-# Copyright (c) 2014 James Harton
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Huia::Parser
-
- token
- IDENTIFIER EQUAL PLUS MINUS ASTERISK FWD_SLASH COLON FLOAT INTEGER STRING
- EXPO INDENT OUTDENT OPAREN CPAREN DOT SIGNATURE NL EOF PIPE COMMA NIL TRUE
- FALSE EQUALITY CALL SELF CONSTANT CHAR DOUBLE_TICK_STRING
- DOUBLE_TICK_STRING_END INTERPOLATE_START INTERPOLATE_END BOX LSQUARE
- RSQUARE FACES LFACE RFACE BANG TILDE RETURN NOT_EQUALITY OR AND GT LT
- GTE LTE AT
-
- prechigh
- left EXPO
- left BANG TILDE
- left ASTERISK FWD_SLASH PERCENT
- left PLUS MINUS
-
- right EQUAL
- preclow
-
- rule
- statements: statement
- | statements statement { return scope }
-
- statement: expr eol { return scope.append val[0] }
- | expr { return scope.append val[0] }
- | eol { return scope }
-
- eol: NL | EOF
- nlq: NL |
-
- expr: literal
- | grouped_expr
- | binary_op
- | unary_op
- | method_call
- | constant
- | variable
- | array
- | hash
- | return
-
- return: return_expr
- | return_nil
- return_expr: RETURN expr { return n(:Return, val[1]) }
- return_nil: RETURN { return n(:Return, n(:Nil)) }
-
- array: empty_array
- | array_list
-
- empty_array: BOX { return n :Array }
-
- array_list: LSQUARE array_items RSQUARE { return val[1] }
- array_items: expr { return n :Array, [val[0]] }
- | array_items COMMA expr { val[0].append(val[2]); return val[0] }
-
- hash: empty_hash
- | hash_list
- empty_hash: FACES { return n :Hash }
- hash_list: LFACE hash_items RFACE { return val[1] }
- hash_items: hash_item { return n :Hash, val[0] }
- | hash_items COMMA hash_item { val[0].append(val[2]); return val[0] }
- hash_item: expr COLON expr { return n :HashItem, val[0], val[2] }
-
- constant: CONSTANT { return constant val[0] }
-
- indented: indented_w_stmts
- | indented_w_expr
- | indented_wo_stmts
- indented_w_stmts: indent statements outdent { return val[0] }
- indented_w_expr: indent expr outdent { return val[0].append(val[1]) }
- indented_wo_stmts: indent outdent { return val[0] }
- outdent: OUTDENT { return pop_scope }
-
-
- indent_w_args: indent_pipe indent_args PIPE nlq INDENT { return val[0] }
- indent_pipe: PIPE { return push_scope }
- indent_wo_args: INDENT { return push_scope }
- indent: indent_w_args
- | indent_wo_args
-
- indent_args: indent_arg
- | indent_args COMMA indent_arg
- indent_arg: arg_var { return scope.add_argument val[0] }
- | arg_var EQUAL expr { return n :Assignment, val[0], val[2] }
- arg_var: IDENTIFIER { return n :Variable, val[0] }
-
- method_call: method_call_on_object
- | method_call_on_self
- | method_call_on_closure
- method_call_on_object: expr DOT call_signature { return n :MethodCall, val[0], val[2] }
- | expr DOT IDENTIFIER { return n :MethodCall, val[0], n(:CallSignature, val[2]) }
- method_call_on_self: call_signature { return n :MethodCall, scope_instance, val[0] }
-
- method_call_on_closure: AT call_signature { return n :MethodCall, this_closure, val[1] }
- | AT IDENTIFIER { return n :MethodCall, this_closure, n(:CallSignature, val[1]) }
-
- call_signature: call_arguments
- | call_simple_name
- call_simple_name: CALL { return n :CallSignature, val[0] }
- call_argument: SIGNATURE call_passed_arg { return n :CallSignature, val[0], [val[1]] }
- call_passed_arg: call_passed_simple
- | call_passed_indented
- call_passed_simple: expr
- | expr NL
- call_passed_indented: indented
- | indented NL
- call_arguments: call_argument { return val[0] }
- | call_arguments call_argument { return val[0].concat_signature val[1] }
-
- grouped_expr: OPAREN expr CPAREN { return n :Expression, val[1] }
-
- variable: IDENTIFIER { return allocate_local val[0] }
-
- binary_op: assignment
- | addition
- | subtraction
- | multiplication
- | division
- | exponentiation
- | modulo
- | equality
- | not_equality
- | logical_or
- | logical_and
- | greater_than
- | less_than
- | greater_or_eq
- | less_or_eq
-
- assignment: IDENTIFIER EQUAL expr { return allocate_local_assignment val[0], val[2] }
- addition: expr PLUS expr { return binary val[0], val[2], 'plus:' }
- subtraction: expr MINUS expr { return binary val[0], val[2], 'minus:' }
- multiplication: expr ASTERISK expr { return binary val[0], val[2], 'multiplyBy:' }
- division: expr FWD_SLASH expr { return binary val[0], val[2], 'divideBy:' }
- exponentiation: expr EXPO expr { return binary val[0], val[2], 'toThePowerOf:' }
- modulo: expr PERCENT expr { return binary val[0], val[2], 'moduloOf:' }
- equality: expr EQUALITY expr { return binary val[0], val[2], 'isEqualTo:' }
- not_equality: expr NOT_EQUALITY expr { return binary val[0], val[2], 'isNotEqualTo:' }
- logical_or: expr OR expr { return binary val[0], val[2], 'logicalOr:' }
- logical_and: expr AND expr { return binary val[0], val[2], 'logicalAnd:' }
- greater_than: expr GT expr { return binary val[0], val[2], 'isGreaterThan:' }
- less_than: expr LT expr { return binary val[0], val[2], 'isLessThan:' }
- greater_or_eq: expr GTE expr { return binary val[0], val[2], 'isGreaterOrEqualTo:' }
- less_or_eq: expr LTE expr { return binary val[0], val[2], 'isLessOrEqualTo:' }
-
- unary_op: unary_not
- | unary_plus
- | unary_minus
- | unary_complement
-
- unary_not: BANG expr { return unary val[1], 'unaryNot' }
- unary_plus: PLUS expr { return unary val[1], 'unaryPlus' }
- unary_minus: MINUS expr { return unary val[1], 'unaryMinus' }
- unary_complement: TILDE expr { return unary val[1], 'unaryComplement' }
-
- literal: integer
- | float
- | string
- | nil
- | true
- | false
- | self
-
- float: FLOAT { return n :Float, val[0] }
- integer: INTEGER { return n :Integer, val[0] }
- nil: NIL { return n :Nil }
- true: TRUE { return n :True }
- false: FALSE { return n :False }
- self: SELF { return n :Self }
-
- string: STRING { return n :String, val[0] }
- | interpolated_string
- | empty_string
-
- interpolated_string: DOUBLE_TICK_STRING interpolated_string_contents DOUBLE_TICK_STRING_END { return val[1] }
- interpolation: INTERPOLATE_START expr INTERPOLATE_END { return val[1] }
- interpolated_string_contents: interpolated_string_chunk { return n :InterpolatedString, val[0] }
- | interpolated_string_contents interpolated_string_chunk { val[0].append(val[1]); return val[0] }
- interpolated_string_chunk: chars { return val[0] }
- | interpolation { return to_string(val[0]) }
- empty_string: DOUBLE_TICK_STRING DOUBLE_TICK_STRING_END { return n :String, '' }
-
- chars: CHAR { return n :String, val[0] }
- | chars CHAR { val[0].append(val[1]); return val[0] }
-end
-
----- inner
-
-attr_accessor :lexer, :scopes, :state
-
-def initialize lexer
- @lexer = lexer
- @state = []
- @scopes = []
- push_scope
-end
-
-def ast
- @ast ||= do_parse
- @scopes.first
-end
-
-def on_error t, val, vstack
- line = lexer.line
- col = lexer.column
- message = "Unexpected #{token_to_str t} at #{lexer.filename} line #{line}:#{col}:\n\n"
-
- start = line - 5 > 0 ? line - 5 : 0
- i_size = line.to_s.size
- (start..(start + 5)).each do |i|
- message << sprintf("\t%#{i_size}d: %s\n", i, lexer.get_line(i))
- message << "\t#{' ' * i_size} #{'-' * (col - 1)}^\n" if i == line
- end
-
- raise SyntaxError, message
-end
-
-def next_token
- nt = lexer.next_computed_token
- # just use a state stack for now, we'll have to do something
- # more sophisticated soon.
- if nt && nt.first == :state
- if nt.last
- state.push << nt.last
- else
- state.pop
- end
- next_token
- else
- nt
- end
-end
-
-def push_scope
- new_scope = Huia::AST::Scope.new scope
- new_scope.file = lexer.filename
- new_scope.line = lexer.line
- new_scope.column = lexer.column
- scopes.push new_scope
- new_scope
-end
-
-def pop_scope
- scopes.pop
-end
-
-def scope
- scopes.last
-end
-
-def binary left, right, method
- node(:MethodCall, left, node(:CallSignature, method, [right]))
-end
-
-def unary left, method
- node(:MethodCall, left, node(:CallSignature, method))
-end
-
-def node type, *args
- Huia::AST.const_get(type).new(*args).tap do |n|
- n.file = lexer.filename
- n.line = lexer.line
- n.column = lexer.column
- end
-end
-alias n node
-
-def allocate_local name
- node(:Variable, name).tap do |n|
- scope.allocate_local n
- end
-end
-
-def allocate_local_assignment name, value
- node(:Assignment, name, value).tap do |n|
- scope.allocate_local n
- end
-end
-
-def this_closure
- allocate_local('@')
-end
-
-def scope_instance
- node(:ScopeInstance, scope)
-end
-
-def constant name
- return scope_instance if name == 'self'
- node(:Constant, name)
-end
-
-def to_string expr
- node(:MethodCall, expr, node(:CallSignature, 'toString'))
-end
diff --git a/test/racc/assets/ichk.y b/test/racc/assets/ichk.y
deleted file mode 100644
index 1d359df83e..0000000000
--- a/test/racc/assets/ichk.y
+++ /dev/null
@@ -1,102 +0,0 @@
-class Calculator
-
- prechigh
- left '*' '/'
- left '+' '-'
- preclow
-
- convert
- NUMBER 'Number'
- end
-
-rule
-
- target : exp
- | /* none */ { result = 0 }
-
- exp : exp '+' exp { result += val[2]; a = 'plus' }
- | exp '-' exp { result -= val[2]; a = "string test" }
- | exp '*' exp { result *= val[2] }
- | exp '/' exp { result /= val[2] }
- | '(' { $emb = true } exp ')'
- {
- raise 'must not happen' unless $emb
- result = val[2]
- }
- | '-' NUMBER { result = -val[1] }
- | NUMBER
-
-----header
-
-class Number
-end
-
-----inner
-
- def initialize
- @racc_debug_out = $stdout
- @yydebug = false
- end
-
- def validate(expected, src)
- result = parse(src)
- unless result == expected
- raise "test #{@test_number} fail"
- end
- @test_number += 1
- end
-
- def parse(src)
- @src = src
- @test_number = 1
- yyparse self, :scan
- end
-
- def scan(&block)
- @src.each(&block)
- end
-
-----footer
-
-calc = Calculator.new
-
-calc.validate(9, [[Number, 9], nil])
-
-calc.validate(-3,
- [[Number, 5],
- ['*', '*'],
- [Number, 1],
- ['-', '*'],
- [Number, 1],
- ['*', '*'],
- [Number, 8],
- nil])
-
-calc.validate(-1,
- [[Number, 5],
- ['+', '+'],
- [Number, 2],
- ['-', '-'],
- [Number, 5],
- ['+', '+'],
- [Number, 2],
- ['-', '-'],
- [Number, 5],
- nil])
-
-calc.validate(-4,
- [['-', 'UMINUS'],
- [Number, 4],
- nil])
-
-calc.validate(40,
- [[Number, 7],
- ['*', '*'],
- ['(', '('],
- [Number, 4],
- ['+', '+'],
- [Number, 3],
- [')', ')'],
- ['-', '-'],
- [Number, 9],
- nil])
diff --git a/test/racc/assets/intp.y b/test/racc/assets/intp.y
deleted file mode 100644
index 39e42afd74..0000000000
--- a/test/racc/assets/intp.y
+++ /dev/null
@@ -1,546 +0,0 @@
-#
-# intp
-#
-
-class Intp::Parser
-
-prechigh
- nonassoc UMINUS
- left '*' '/'
- left '+' '-'
- nonassoc EQ
-preclow
-
-rule
-
- program : stmt_list
- {
- result = RootNode.new( val[0] )
- }
-
- stmt_list :
- {
- result = []
- }
- | stmt_list stmt EOL
- {
- result.push val[1]
- }
- | stmt_list EOL
-
- stmt : expr
- | assign
- | IDENT realprim
- {
- result = FuncallNode.new( @fname, val[0][0],
- val[0][1], [val[1]] )
- }
- | if_stmt
- | while_stmt
- | defun
-
- if_stmt : IF stmt THEN EOL stmt_list else_stmt END
- {
- result = IfNode.new( @fname, val[0][0],
- val[1], val[4], val[5] )
- }
-
- else_stmt : ELSE EOL stmt_list
- {
- result = val[2]
- }
- |
- {
- result = nil
- }
-
- while_stmt: WHILE stmt DO EOL stmt_list END
- {
- result = WhileNode.new(@fname, val[0][0],
- val[1], val[4])
- }
-
- defun : DEF IDENT param EOL stmt_list END
- {
- result = DefNode.new(@fname, val[0][0], val[1][1],
- Function.new(@fname, val[0][0], val[2], val[4]))
- }
-
- param : '(' name_list ')'
- {
- result = val[1]
- }
- | '(' ')'
- {
- result = []
- }
- |
- {
- result = []
- }
-
- name_list : IDENT
- {
- result = [ val[0][1] ]
- }
- | name_list ',' IDENT
- {
- result.push val[2][1]
- }
-
- assign : IDENT '=' expr
- {
- result = AssignNode.new(@fname, val[0][0], val[0][1], val[2])
- }
-
- expr : expr '+' expr
- {
- result = FuncallNode.new(@fname, val[0].lineno, '+', [val[0], val[2]])
- }
- | expr '-' expr
- {
- result = FuncallNode.new(@fname, val[0].lineno, '-', [val[0], val[2]])
- }
- | expr '*' expr
- {
- result = FuncallNode.new(@fname, val[0].lineno, '*', [val[0], val[2]])
- }
- | expr '/' expr
- {
- result = FuncallNode.new(@fname, val[0].lineno,
- '/', [val[0], val[2]])
- }
- | expr EQ expr
- {
- result = FuncallNode.new(@fname, val[0].lineno, '==', [val[0], val[2]])
- }
- | primary
-
- primary : realprim
- | '(' expr ')'
- {
- result = val[1]
- }
- | '-' expr =UMINUS
- {
- result = FuncallNode.new(@fname, val[0][0], '-@', [val[1]])
- }
-
- realprim : IDENT
- {
- result = VarRefNode.new(@fname, val[0][0],
- val[0][1])
- }
- | NUMBER
- {
- result = LiteralNode.new(@fname, *val[0])
- }
- | STRING
- {
- result = StringNode.new(@fname, *val[0])
- }
- | TRUE
- {
- result = LiteralNode.new(@fname, *val[0])
- }
- | FALSE
- {
- result = LiteralNode.new(@fname, *val[0])
- }
- | NIL
- {
- result = LiteralNode.new(@fname, *val[0])
- }
- | funcall
-
- funcall : IDENT '(' args ')'
- {
- result = FuncallNode.new(@fname, val[0][0], val[0][1], val[2])
- }
- | IDENT '(' ')'
- {
- result = FuncallNode.new(@fname, val[0][0], val[0][1], [])
- }
-
- args : expr
- {
- result = val
- }
- | args ',' expr
- {
- result.push val[2]
- }
-
-end
-
----- header
-#
-# intp/parser.rb
-#
-
----- inner
-
- def initialize
- @scope = {}
- end
-
- RESERVED = {
- 'if' => :IF,
- 'else' => :ELSE,
- 'while' => :WHILE,
- 'then' => :THEN,
- 'do' => :DO,
- 'def' => :DEF,
- 'true' => :TRUE,
- 'false' => :FALSE,
- 'nil' => :NIL,
- 'end' => :END
- }
-
- RESERVED_V = {
- 'true' => true,
- 'false' => false,
- 'nil' => nil
- }
-
- def parse(f, fname)
- @q = []
- @fname = fname
- lineno = 1
- f.each do |line|
- line.strip!
- until line.empty?
- case line
- when /\A\s+/, /\A\#.*/
- ;
- when /\A[a-zA-Z_]\w*/
- word = $&
- @q.push [(RESERVED[word] || :IDENT),
- [lineno, RESERVED_V.key?(word) ? RESERVED_V[word] : word.intern]]
- when /\A\d+/
- @q.push [:NUMBER, [lineno, $&.to_i]]
- when /\A"(?:[^"\\]+|\\.)*"/, /\A'(?:[^'\\]+|\\.)*'/
- @q.push [:STRING, [lineno, eval($&)]]
- when /\A==/
- @q.push [:EQ, [lineno, '==']]
- when /\A./
- @q.push [$&, [lineno, $&]]
- else
- raise RuntimeError, 'must not happen'
- end
- line = $'
- end
- @q.push [:EOL, [lineno, nil]]
- lineno += 1
- end
- @q.push [false, '$']
- do_parse
- end
-
- def next_token
- @q.shift
- end
-
- def on_error(t, v, values)
- if v
- line = v[0]
- v = v[1]
- else
- line = 'last'
- end
- raise Racc::ParseError, "#{@fname}:#{line}: syntax error on #{v.inspect}"
- end
-
----- footer
-# intp/node.rb
-
-module Intp
-
- class IntpError < StandardError; end
- class IntpArgumentError < IntpError; end
-
- class Core
-
- def initialize
- @ftab = {}
- @obj = Object.new
- @stack = []
- @stack.push Frame.new '(toplevel)'
- end
-
- def frame
- @stack[-1]
- end
-
- def define_function(fname, node)
- raise IntpError, "function #{fname} defined twice" if @ftab.key?(fname)
- @ftab[fname] = node
- end
-
- def call_function_or(fname, args)
- call_intp_function_or(fname, args) {
- call_ruby_toplevel_or(fname, args) {
- yield
- }
- }
- end
-
- def call_intp_function_or(fname, args)
- if func = @ftab[fname]
- frame = Frame.new(fname)
- @stack.push frame
- func.call self, frame, args
- @stack.pop
- else
- yield
- end
- end
-
- def call_ruby_toplevel_or(fname, args)
- if @obj.respond_to? fname, true
- @obj.send fname, *args
- else
- yield
- end
- end
-
- end
-
- class Frame
-
- def initialize(fname)
- @fname = fname
- @lvars = {}
- end
-
- attr :fname
-
- def lvar?(name)
- @lvars.key? name
- end
-
- def [](key)
- @lvars[key]
- end
-
- def []=(key, val)
- @lvars[key] = val
- end
-
- end
-
-
- class Node
-
- def initialize(fname, lineno)
- @filename = fname
- @lineno = lineno
- end
-
- attr_reader :filename
- attr_reader :lineno
-
- def exec_list(intp, nodes)
- v = nil
- nodes.each {|i| v = i.evaluate(intp) }
- v
- end
-
- def intp_error!(msg)
- raise IntpError, "in #{filename}:#{lineno}: #{msg}"
- end
-
- def inspect
- "#{self.class.name}/#{lineno}"
- end
-
- end
-
-
- class RootNode < Node
-
- def initialize(tree)
- super nil, nil
- @tree = tree
- end
-
- def evaluate
- exec_list Core.new, @tree
- end
-
- end
-
-
- class DefNode < Node
-
- def initialize(file, lineno, fname, func)
- super file, lineno
- @funcname = fname
- @funcobj = func
- end
-
- def evaluate(intp)
- intp.define_function @funcname, @funcobj
- end
-
- end
-
- class FuncallNode < Node
-
- def initialize(file, lineno, func, args)
- super file, lineno
- @funcname = func
- @args = args
- end
-
- def evaluate(intp)
- args = @args.map {|i| i.evaluate intp }
- begin
- intp.call_intp_function_or(@funcname, args) {
- if args.empty? or not args[0].respond_to?(@funcname)
- intp.call_ruby_toplevel_or(@funcname, args) {
- intp_error! "undefined function #{@funcname.id2name}"
- }
- else
- recv = args.shift
- recv.send @funcname, *args
- end
- }
- rescue IntpArgumentError, ArgumentError
- intp_error! $!.message
- end
- end
-
- end
-
- class Function < Node
-
- def initialize(file, lineno, params, body)
- super file, lineno
- @params = params
- @body = body
- end
-
- def call(intp, frame, args)
- unless args.size == @params.size
- raise IntpArgumentError,
- "wrong # of arg for #{frame.fname}() (#{args.size} for #{@params.size})"
- end
- args.each_with_index do |v,i|
- frame[@params[i]] = v
- end
- exec_list intp, @body
- end
-
- end
-
-
- class IfNode < Node
-
- def initialize(fname, lineno, cond, tstmt, fstmt)
- super fname, lineno
- @condition = cond
- @tstmt = tstmt
- @fstmt = fstmt
- end
-
- def evaluate(intp)
- if @condition.evaluate(intp)
- exec_list intp, @tstmt
- else
- exec_list intp, @fstmt if @fstmt
- end
- end
-
- end
-
- class WhileNode < Node
-
- def initialize(fname, lineno, cond, body)
- super fname, lineno
- @condition = cond
- @body = body
- end
-
- def evaluate(intp)
- while @condition.evaluate(intp)
- exec_list intp, @body
- end
- end
-
- end
-
-
- class AssignNode < Node
-
- def initialize(fname, lineno, vname, val)
- super fname, lineno
- @vname = vname
- @val = val
- end
-
- def evaluate(intp)
- intp.frame[@vname] = @val.evaluate(intp)
- end
-
- end
-
- class VarRefNode < Node
-
- def initialize(fname, lineno, vname)
- super fname, lineno
- @vname = vname
- end
-
- def evaluate(intp)
- if intp.frame.lvar?(@vname)
- intp.frame[@vname]
- else
- intp.call_function_or(@vname, []) {
- intp_error! "unknown method or local variable #{@vname.id2name}"
- }
- end
- end
-
- end
-
- class StringNode < Node
-
- def initialize(fname, lineno, str)
- super fname, lineno
- @val = str
- end
-
- def evaluate(intp)
- @val.dup
- end
-
- end
-
- class LiteralNode < Node
-
- def initialize(fname, lineno, val)
- super fname, lineno
- @val = val
- end
-
- def evaluate(intp)
- @val
- end
-
- end
-
-end # module Intp
-
-begin
- tree = nil
- fname = 'src.intp'
- File.open(fname) {|f|
- tree = Intp::Parser.new.parse(f, fname)
- }
- tree.evaluate
-rescue Racc::ParseError, Intp::IntpError, Errno::ENOENT
- raise ####
- $stderr.puts "#{File.basename $0}: #{$!}"
- exit 1
-end
diff --git a/test/racc/assets/journey.y b/test/racc/assets/journey.y
deleted file mode 100644
index c2640f3339..0000000000
--- a/test/racc/assets/journey.y
+++ /dev/null
@@ -1,47 +0,0 @@
-class Journey::Parser
-
-token SLASH LITERAL SYMBOL LPAREN RPAREN DOT STAR OR
-
-rule
- expressions
- : expressions expression { result = Cat.new(val.first, val.last) }
- | expression { result = val.first }
- | or
- ;
- expression
- : terminal
- | group
- | star
- ;
- group
- : LPAREN expressions RPAREN { result = Group.new(val[1]) }
- ;
- or
- : expressions OR expression { result = Or.new([val.first, val.last]) }
- ;
- star
- : STAR { result = Star.new(Symbol.new(val.last)) }
- ;
- terminal
- : symbol
- | literal
- | slash
- | dot
- ;
- slash
- : SLASH { result = Slash.new('/') }
- ;
- symbol
- : SYMBOL { result = Symbol.new(val.first) }
- ;
- literal
- : LITERAL { result = Literal.new(val.first) }
- dot
- : DOT { result = Dot.new(val.first) }
- ;
-
-end
-
----- header
-
-require 'journey/parser_extras'
diff --git a/test/racc/assets/liquor.y b/test/racc/assets/liquor.y
deleted file mode 100644
index 8045a072a4..0000000000
--- a/test/racc/assets/liquor.y
+++ /dev/null
@@ -1,313 +0,0 @@
-# Copyright (c) 2012-2013 Peter Zotov <whitequark@whitequark.org>
-# 2012 Yaroslav Markin <yaroslav@markin.net>
-# 2012 Nate Gadgibalaev <nat@xnsv.ru>
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Liquor::Parser
- token comma dot endtag ident integer keyword lblock lblock2 lbracket
- linterp lparen op_div op_eq op_gt op_geq op_lt op_leq op_minus
- op_mod op_mul op_neq op_not op_plus pipe plaintext rblock
- rbracket rinterp rparen string tag_ident
-
- prechigh
- left dot
- nonassoc op_uminus op_not
- left op_mul op_div op_mod
- left op_plus op_minus
- left op_eq op_neq op_lt op_leq op_gt op_geq
- left op_and
- left op_or
- preclow
-
- expect 15
-
- start block
-
-rule
- block: /* empty */
- { result = [] }
- | plaintext block
- { result = [ val[0], *val[1] ] }
- | interp block
- { result = [ val[0], *val[1] ] }
- | tag block
- { result = [ val[0], *val[1] ] }
-
- interp:
- linterp expr rinterp
- { result = [ :interp, retag(val), val[1] ] }
- | linterp filter_chain rinterp
- { result = [ :interp, retag(val), val[1] ] }
-
- primary_expr:
- ident
- | lparen expr rparen
- { result = [ val[1][0], retag(val), *val[1][2..-1] ] }
-
- expr:
- integer
- | string
- | tuple
- | ident function_args
- { result = [ :call, retag(val), val[0], val[1] ] }
- | expr lbracket expr rbracket
- { result = [ :index, retag(val), val[0], val[2] ] }
- | expr dot ident function_args
- { result = [ :external, retag(val), val[0], val[2], val[3] ] }
- | expr dot ident
- { result = [ :external, retag(val), val[0], val[2], nil ] }
- | op_minus expr =op_uminus
- { result = [ :uminus, retag(val), val[1] ] }
- | op_not expr
- { result = [ :not, retag(val), val[1] ] }
- | expr op_mul expr
- { result = [ :mul, retag(val), val[0], val[2] ] }
- | expr op_div expr
- { result = [ :div, retag(val), val[0], val[2] ] }
- | expr op_mod expr
- { result = [ :mod, retag(val), val[0], val[2] ] }
- | expr op_plus expr
- { result = [ :plus, retag(val), val[0], val[2] ] }
- | expr op_minus expr
- { result = [ :minus, retag(val), val[0], val[2] ] }
- | expr op_eq expr
- { result = [ :eq, retag(val), val[0], val[2] ] }
- | expr op_neq expr
- { result = [ :neq, retag(val), val[0], val[2] ] }
- | expr op_lt expr
- { result = [ :lt, retag(val), val[0], val[2] ] }
- | expr op_leq expr
- { result = [ :leq, retag(val), val[0], val[2] ] }
- | expr op_gt expr
- { result = [ :gt, retag(val), val[0], val[2] ] }
- | expr op_geq expr
- { result = [ :geq, retag(val), val[0], val[2] ] }
- | expr op_and expr
- { result = [ :and, retag(val), val[0], val[2] ] }
- | expr op_or expr
- { result = [ :or, retag(val), val[0], val[2] ] }
- | primary_expr
-
- tuple:
- lbracket tuple_content rbracket
- { result = [ :tuple, retag(val), val[1].compact ] }
-
- tuple_content:
- expr comma tuple_content
- { result = [ val[0], *val[2] ] }
- | expr
- { result = [ val[0] ] }
- | /* empty */
- { result = [ ] }
-
- function_args:
- lparen function_args_inside rparen
- { result = [ :args, retag(val), *val[1] ] }
-
- function_args_inside:
- expr function_keywords
- { result = [ val[0], val[1][2] ] }
- | function_keywords
- { result = [ nil, val[0][2] ] }
-
- function_keywords:
- keyword expr function_keywords
- { name = val[0][2].to_sym
- tail = val[2][2]
- loc = retag([ val[0], val[1] ])
-
- if tail.include? name
- @errors << SyntaxError.new("duplicate keyword argument `#{val[0][2]}'",
- tail[name][1])
- end
-
- hash = {
- name => [ val[1][0], loc, *val[1][2..-1] ]
- }.merge(tail)
-
- result = [ :keywords, retag([ loc, val[2] ]), hash ]
- }
- | /* empty */
- { result = [ :keywords, nil, {} ] }
-
- filter_chain:
- expr pipe filter_chain_cont
- { result = [ val[0], *val[2] ].
- reduce { |tree, node| node[3][2] = tree; node }
- }
-
- filter_chain_cont:
- filter_call pipe filter_chain_cont
- { result = [ val[0], *val[2] ] }
- | filter_call
- { result = [ val[0] ] }
-
- filter_call:
- ident function_keywords
- { ident_loc = val[0][1]
- empty_args_loc = { line: ident_loc[:line],
- start: ident_loc[:end] + 1,
- end: ident_loc[:end] + 1, }
- result = [ :call, val[0][1], val[0],
- [ :args, val[1][1] || empty_args_loc, nil, val[1][2] ] ]
- }
-
- tag:
- lblock ident expr tag_first_cont
- { result = [ :tag, retag(val), val[1], val[2], *reduce_tag_args(val[3][2]) ] }
- | lblock ident tag_first_cont
- { result = [ :tag, retag(val), val[1], nil, *reduce_tag_args(val[2][2]) ] }
-
- # Racc cannot do lookahead across rules. I had to add states
- # explicitly to avoid S/R conflicts. You are not expected to
- # understand this.
-
- tag_first_cont:
- rblock
- { result = [ :cont, retag(val), [] ] }
- | keyword tag_first_cont2
- { result = [ :cont, retag(val), [ val[0], *val[1][2] ] ] }
-
- tag_first_cont2:
- rblock block lblock2 tag_next_cont
- { result = [ :cont2, val[0][1], [ [:block, val[0][1], val[1] ], *val[3] ] ] }
- | expr tag_first_cont
- { result = [ :cont2, retag(val), [ val[0], *val[1][2] ] ] }
-
- tag_next_cont:
- endtag rblock
- { result = [] }
- | keyword tag_next_cont2
- { result = [ val[0], *val[1] ] }
-
- tag_next_cont2:
- rblock block lblock2 tag_next_cont
- { result = [ [:block, val[0][1], val[1] ], *val[3] ] }
- | expr keyword tag_next_cont3
- { result = [ val[0], val[1], *val[2] ] }
-
- tag_next_cont3:
- rblock block lblock2 tag_next_cont
- { result = [ [:block, val[0][1], val[1] ], *val[3] ] }
- | expr tag_next_cont
- { result = [ val[0], *val[1] ] }
-
----- inner
- attr_reader :errors, :ast
-
- def initialize(tags={})
- super()
-
- @errors = []
- @ast = nil
- @tags = tags
- end
-
- def success?
- @errors.empty?
- end
-
- def parse(string, name='(code)')
- @errors.clear
- @name = name
- @ast = nil
-
- begin
- @stream = Lexer.lex(string, @name, @tags)
- @ast = do_parse
- rescue Liquor::SyntaxError => e
- @errors << e
- end
-
- success?
- end
-
- def next_token
- tok = @stream.shift
- [ tok[0], tok ] if tok
- end
-
- TOKEN_NAME_MAP = {
- :comma => ',',
- :dot => '.',
- :lblock => '{%',
- :rblock => '%}',
- :linterp => '{{',
- :rinterp => '}}',
- :lbracket => '[',
- :rbracket => ']',
- :lparen => '(',
- :rparen => ')',
- :pipe => '|',
- :op_not => '!',
- :op_mul => '*',
- :op_div => '/',
- :op_mod => '%',
- :op_plus => '+',
- :op_minus => '-',
- :op_eq => '==',
- :op_neq => '!=',
- :op_lt => '<',
- :op_leq => '<=',
- :op_gt => '>',
- :op_geq => '>=',
- :keyword => 'keyword argument name',
- :kwarg => 'keyword argument',
- :ident => 'identifier',
- }
-
- def on_error(error_token_id, error_token, value_stack)
- if token_to_str(error_token_id) == "$end"
- raise Liquor::SyntaxError.new("unexpected end of program", {
- file: @name
- })
- else
- type, (loc, value) = error_token
- type = TOKEN_NAME_MAP[type] || type
-
- raise Liquor::SyntaxError.new("unexpected token `#{type}'", loc)
- end
- end
-
- def retag(nodes)
- loc = nodes.map { |node| node[1] }.compact
- first, *, last = loc
- return first if last.nil?
-
- {
- file: first[:file],
- line: first[:line],
- start: first[:start],
- end: last[:end],
- }
- end
-
- def reduce_tag_args(list)
- list.each_slice(2).reduce([]) { |args, (k, v)|
- if v[0] == :block
- args << [ :blockarg, retag([ k, v ]), k, v[2] || [] ]
- else
- args << [ :kwarg, retag([ k, v ]), k, v ]
- end
- }
- end \ No newline at end of file
diff --git a/test/racc/assets/machete.y b/test/racc/assets/machete.y
deleted file mode 100644
index ea92d47a69..0000000000
--- a/test/racc/assets/machete.y
+++ /dev/null
@@ -1,423 +0,0 @@
-# Copyright (c) 2011 SUSE
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation
-# files (the "Software"), to deal in the Software without
-# restriction, including without limitation the rights to use,
-# copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following
-# conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-# OTHER DEALINGS IN THE SOFTWARE.
-
-class Machete::Parser
-
-token NIL
-token TRUE
-token FALSE
-token INTEGER
-token SYMBOL
-token STRING
-token REGEXP
-token ANY
-token EVEN
-token ODD
-token METHOD_NAME
-token CLASS_NAME
-
-start expression
-
-rule
-
-expression : primary
- | expression "|" primary {
- result = if val[0].is_a?(ChoiceMatcher)
- ChoiceMatcher.new(val[0].alternatives << val[2])
- else
- ChoiceMatcher.new([val[0], val[2]])
- end
- }
-
-primary : node
- | array
- | literal
- | any
-
-node : CLASS_NAME {
- result = NodeMatcher.new(val[0].to_sym)
- }
- | CLASS_NAME "<" attrs ">" {
- result = NodeMatcher.new(val[0].to_sym, val[2])
- }
-
-attrs : attr
- | attrs "," attr { result = val[0].merge(val[2]) }
-
-attr : method_name "=" expression { result = { val[0].to_sym => val[2] } }
- | method_name "^=" SYMBOL {
- result = {
- val[0].to_sym => SymbolRegexpMatcher.new(
- Regexp.new("^" + Regexp.escape(symbol_value(val[2]).to_s))
- )
- }
- }
- | method_name "$=" SYMBOL {
- result = {
- val[0].to_sym => SymbolRegexpMatcher.new(
- Regexp.new(Regexp.escape(symbol_value(val[2]).to_s) + "$")
- )
- }
- }
- | method_name "*=" SYMBOL {
- result = {
- val[0].to_sym => SymbolRegexpMatcher.new(
- Regexp.new(Regexp.escape(symbol_value(val[2]).to_s))
- )
- }
- }
- | method_name "^=" STRING {
- result = {
- val[0].to_sym => StringRegexpMatcher.new(
- Regexp.new("^" + Regexp.escape(string_value(val[2])))
- )
- }
- }
- | method_name "$=" STRING {
- result = {
- val[0].to_sym => StringRegexpMatcher.new(
- Regexp.new(Regexp.escape(string_value(val[2])) + "$")
- )
- }
- }
- | method_name "*=" STRING {
- result = {
- val[0].to_sym => StringRegexpMatcher.new(
- Regexp.new(Regexp.escape(string_value(val[2])))
- )
- }
- }
- | method_name "*=" REGEXP {
- result = {
- val[0].to_sym => IndifferentRegexpMatcher.new(
- Regexp.new(regexp_value(val[2]))
- )
- }
- }
-
-# Hack to overcome the fact that some tokens will lex as simple tokens, not
-# METHOD_NAME tokens, and that "reserved words" will lex as separate kinds of
-# tokens.
-method_name : METHOD_NAME
- | NIL
- | TRUE
- | FALSE
- | ANY
- | EVEN
- | ODD
- | "*"
- | "+"
- | "<"
- | ">"
- | "^"
- | "|"
-
-array : "[" items_opt "]" { result = ArrayMatcher.new(val[1]) }
-
-items_opt : /* empty */ { result = [] }
- | items
-
-items : item { result = [val[0]] }
- | items "," item { result = val[0] << val[2] }
-
-item : expression
- | expression quantifier { result = Quantifier.new(val[0], *val[1]) }
-
-quantifier : "*" { result = [0, nil, 1] }
- | "+" { result = [1, nil, 1] }
- | "?" { result = [0, 1, 1] }
- | "{" INTEGER "}" {
- result = [integer_value(val[1]), integer_value(val[1]), 1]
- }
- | "{" INTEGER "," "}" {
- result = [integer_value(val[1]), nil, 1]
- }
- | "{" "," INTEGER "}" {
- result = [0, integer_value(val[2]), 1]
- }
- | "{" INTEGER "," INTEGER "}" {
- result = [integer_value(val[1]), integer_value(val[3]), 1]
- }
- | "{" EVEN "}" { result = [0, nil, 2] }
- | "{" ODD "}" { result = [1, nil, 2] }
-
-literal : NIL { result = LiteralMatcher.new(nil) }
- | TRUE { result = LiteralMatcher.new(true) }
- | FALSE { result = LiteralMatcher.new(false) }
- | INTEGER { result = LiteralMatcher.new(integer_value(val[0])) }
- | SYMBOL { result = LiteralMatcher.new(symbol_value(val[0])) }
- | STRING { result = LiteralMatcher.new(string_value(val[0])) }
- | REGEXP { result = LiteralMatcher.new(regexp_value(val[0])) }
-
-any : ANY { result = AnyMatcher.new }
-
----- inner
-
-include Matchers
-
-class SyntaxError < StandardError; end
-
-def parse(input)
- @input = input
- @pos = 0
-
- do_parse
-end
-
-private
-
-def integer_value(value)
- if value =~ /^0[bB]/
- value[2..-1].to_i(2)
- elsif value =~ /^0[oO]/
- value[2..-1].to_i(8)
- elsif value =~ /^0[dD]/
- value[2..-1].to_i(10)
- elsif value =~ /^0[xX]/
- value[2..-1].to_i(16)
- elsif value =~ /^0/
- value.to_i(8)
- else
- value.to_i
- end
-end
-
-def symbol_value(value)
- value[1..-1].to_sym
-end
-
-def string_value(value)
- quote = value[0..0]
- if quote == "'"
- value[1..-2].gsub("\\\\", "\\").gsub("\\'", "'")
- elsif quote == '"'
- value[1..-2].
- gsub("\\\\", "\\").
- gsub('\\"', '"').
- gsub("\\n", "\n").
- gsub("\\t", "\t").
- gsub("\\r", "\r").
- gsub("\\f", "\f").
- gsub("\\v", "\v").
- gsub("\\a", "\a").
- gsub("\\e", "\e").
- gsub("\\b", "\b").
- gsub("\\s", "\s").
- gsub(/\\([0-7]{1,3})/) { $1.to_i(8).chr }.
- gsub(/\\x([0-9a-fA-F]{1,2})/) { $1.to_i(16).chr }
- else
- raise "Unknown quote: #{quote.inspect}."
- end
-end
-
-REGEXP_OPTIONS = {
- 'i' => Regexp::IGNORECASE,
- 'm' => Regexp::MULTILINE,
- 'x' => Regexp::EXTENDED
-}
-
-def regexp_value(value)
- /\A\/(.*)\/([imx]*)\z/ =~ value
- pattern, options = $1, $2
-
- Regexp.new(pattern, options.chars.map { |ch| REGEXP_OPTIONS[ch] }.inject(:|))
-end
-
-# "^" needs to be here because if it were among operators recognized by
-# METHOD_NAME, "^=" would be recognized as two tokens.
-SIMPLE_TOKENS = [
- "|",
- "<",
- ">",
- ",",
- "=",
- "^=",
- "^",
- "$=",
- "[",
- "]",
- "*=",
- "*",
- "+",
- "?",
- "{",
- "}"
-]
-
-COMPLEX_TOKENS = [
- [:NIL, /^nil/],
- [:TRUE, /^true/],
- [:FALSE, /^false/],
- # INTEGER needs to be before METHOD_NAME, otherwise e.g. "+1" would be
- # recognized as two tokens.
- [
- :INTEGER,
- /^
- [+-]? # sign
- (
- 0[bB][01]+(_[01]+)* # binary (prefixed)
- |
- 0[oO][0-7]+(_[0-7]+)* # octal (prefixed)
- |
- 0[dD]\d+(_\d+)* # decimal (prefixed)
- |
- 0[xX][0-9a-fA-F]+(_[0-9a-fA-F]+)* # hexadecimal (prefixed)
- |
- 0[0-7]*(_[0-7]+)* # octal (unprefixed)
- |
- [1-9]\d*(_\d+)* # decimal (unprefixed)
- )
- /x
- ],
- [
- :SYMBOL,
- /^
- :
- (
- # class name
- [A-Z][a-zA-Z0-9_]*
- |
- # regular method name
- [a-z_][a-zA-Z0-9_]*[?!=]?
- |
- # instance variable name
- @[a-zA-Z_][a-zA-Z0-9_]*
- |
- # class variable name
- @@[a-zA-Z_][a-zA-Z0-9_]*
- |
- # operator (sorted by length, then alphabetically)
- (<=>|===|\[\]=|\*\*|\+@|-@|<<|<=|==|=~|>=|>>|\[\]|[%&*+\-\/<>^`|~])
- )
- /x
- ],
- [
- :STRING,
- /^
- (
- ' # sinqle-quoted string
- (
- \\[\\'] # escape
- |
- [^'] # regular character
- )*
- '
- |
- " # double-quoted string
- (
- \\ # escape
- (
- [\\"ntrfvaebs] # one-character escape
- |
- [0-7]{1,3} # octal number escape
- |
- x[0-9a-fA-F]{1,2} # hexadecimal number escape
- )
- |
- [^"] # regular character
- )*
- "
- )
- /x
- ],
- [
- :REGEXP,
- /^
- \/
- (
- \\ # escape
- (
- [\\\/ntrfvaebs\(\)\[\]\{\}\-\.\?\*\+\|\^\$] # one-character escape
- |
- [0-7]{2,3} # octal number escape
- |
- x[0-9a-fA-F]{1,2} # hexadecimal number escape
- )
- |
- [^\/] # regular character
- )*
- \/
- [imx]*
- /x
- ],
- # ANY, EVEN and ODD need to be before METHOD_NAME, otherwise they would be
- # recognized as method names.
- [:ANY, /^any/],
- [:EVEN, /^even/],
- [:ODD, /^odd/],
- # We exclude "*", "+", "<", ">", "^" and "|" from method names since they are
- # lexed as simple tokens. This is because they have also other meanings in
- # Machette patterns beside Ruby method names.
- [
- :METHOD_NAME,
- /^
- (
- # regular name
- [a-z_][a-zA-Z0-9_]*[?!=]?
- |
- # operator (sorted by length, then alphabetically)
- (<=>|===|\[\]=|\*\*|\+@|-@|<<|<=|==|=~|>=|>>|\[\]|[%&\-\/`~])
- )
- /x
- ],
- [:CLASS_NAME, /^[A-Z][a-zA-Z0-9_]*/]
-]
-
-def next_token
- skip_whitespace
-
- return false if remaining_input.empty?
-
- # Complex tokens need to be before simple tokens, otherwise e.g. "<<" would be
- # recognized as two tokens.
-
- COMPLEX_TOKENS.each do |type, regexp|
- if remaining_input =~ regexp
- @pos += $&.length
- return [type, $&]
- end
- end
-
- SIMPLE_TOKENS.each do |token|
- if remaining_input[0...token.length] == token
- @pos += token.length
- return [token, token]
- end
- end
-
- raise SyntaxError, "Unexpected character: #{remaining_input[0..0].inspect}."
-end
-
-def skip_whitespace
- if remaining_input =~ /\A^[ \t\r\n]+/
- @pos += $&.length
- end
-end
-
-def remaining_input
- @input[@pos..-1]
-end
-
-def on_error(error_token_id, error_value, value_stack)
- raise SyntaxError, "Unexpected token: #{error_value.inspect}."
-end
diff --git a/test/racc/assets/macruby.y b/test/racc/assets/macruby.y
deleted file mode 100644
index 5ede008308..0000000000
--- a/test/racc/assets/macruby.y
+++ /dev/null
@@ -1,2197 +0,0 @@
-# Copyright (c) 2013 Peter Zotov <whitequark@whitequark.org>
-#
-# Parts of the source are derived from ruby_parser:
-# Copyright (c) Ryan Davis, seattle.rb
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Parser::MacRuby
-
-token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
- tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
- tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
- tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
- tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
- tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
- tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
- tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
- tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tREGEXP_OPT
- tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
- tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG
- tCHARACTER
-
-prechigh
- right tBANG tTILDE tUPLUS
- right tPOW
- right tUMINUS_NUM tUMINUS
- left tSTAR2 tDIVIDE tPERCENT
- left tPLUS tMINUS
- left tLSHFT tRSHFT
- left tAMPER2
- left tPIPE tCARET
- left tGT tGEQ tLT tLEQ
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
- left tANDOP
- left tOROP
- nonassoc tDOT2 tDOT3
- right tEH tCOLON
- left kRESCUE_MOD
- right tEQL tOP_ASGN
- nonassoc kDEFINED
- right kNOT
- left kOR kAND
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
- nonassoc tLBRACE_ARG
- nonassoc tLOWEST
-preclow
-
-rule
-
- program: top_compstmt
-
- top_compstmt: top_stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- top_stmts: # nothing
- {
- result = []
- }
- | top_stmt
- {
- result = [ val[0] ]
- }
- | top_stmts terms top_stmt
- {
- result = val[0] << val[2]
- }
- | error top_stmt
- {
- result = [ val[1] ]
- }
-
- top_stmt: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- result = @builder.preexe(val[0], val[1], val[2], val[3])
- }
-
- bodystmt: compstmt opt_rescue opt_else opt_ensure
- {
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
- }
-
- compstmt: stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- stmts: # nothing
- {
- result = []
- }
- | stmt
- {
- result = [ val[0] ]
- }
- | stmts terms stmt
- {
- result = val[0] << val[2]
- }
- | error stmt
- {
- result = [ val[1] ]
- }
-
- stmt: kALIAS fitem
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = @builder.alias(val[0], val[1], val[3])
- }
- | kALIAS tGVAR tGVAR
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
- }
- | kALIAS tGVAR tBACK_REF
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
- }
- | kALIAS tGVAR tNTH_REF
- {
- diagnostic :error, :nth_ref_alias, nil, val[2]
- }
- | kUNDEF undef_list
- {
- result = @builder.undef_method(val[0], val[1])
- }
- | stmt kIF_MOD expr_value
- {
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
- }
- | stmt kUNLESS_MOD expr_value
- {
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
- }
- | stmt kWHILE_MOD expr_value
- {
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
- }
- | stmt kUNTIL_MOD expr_value
- {
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
- }
- | stmt kRESCUE_MOD stmt
- {
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
- }
- | klEND tLCURLY compstmt tRCURLY
- {
- result = @builder.postexe(val[0], val[1], val[2], val[3])
- }
- | lhs tEQL command_call
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | mlhs tEQL command_call
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN command_call
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | backref tOP_ASGN command_call
- {
- @builder.op_assign(val[0], val[1], val[2])
- }
- | lhs tEQL mrhs
- {
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | mlhs tEQL arg_value
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | mlhs tEQL mrhs
- {
- result = @builder.multi_assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | expr
-
- expr: command_call
- | expr kAND expr
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | expr kOR expr
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kNOT opt_nl expr
- {
- result = @builder.not_op(val[0], nil, val[2], nil)
- }
- | tBANG command_call
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | arg
-
- expr_value: expr
-
- command_call: command
- | block_command
-
- block_command: block_call
- | block_call tDOT operation2 command_args
- {
- result = @builder.call_method(val[0], val[1], val[2],
- *val[3])
- }
- | block_call tCOLON2 operation2 command_args
- {
- result = @builder.call_method(val[0], val[1], val[2],
- *val[3])
- }
-
- cmd_brace_block: tLBRACE_ARG
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- command: operation command_args =tLOWEST
- {
- result = @builder.call_method(nil, nil, val[0],
- *val[1])
- }
- | operation command_args cmd_brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0],
- *val[1])
-
- begin_t, args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tDOT operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- *val[3])
- }
- | primary_value tDOT operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- *val[3])
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tCOLON2 operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- *val[3])
- }
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- *val[3])
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | kSUPER command_args
- {
- result = @builder.keyword_cmd(:super, val[0],
- *val[1])
- }
- | kYIELD command_args
- {
- result = @builder.keyword_cmd(:yield, val[0],
- *val[1])
- }
- | kRETURN call_args
- {
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
- }
- | kBREAK call_args
- {
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
- }
- | kNEXT call_args
- {
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
- }
-
- mlhs: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_inner: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- mlhs_basic: mlhs_head
- | mlhs_head mlhs_item
- {
- result = val[0].
- push(val[1])
- }
- | mlhs_head tSTAR mlhs_node
- {
- result = val[0].
- push(@builder.splat(val[1], val[2]))
- }
- | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1], val[2])).
- concat(val[4])
- }
- | mlhs_head tSTAR
- {
- result = val[0].
- push(@builder.splat(val[1]))
- }
- | mlhs_head tSTAR tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1])).
- concat(val[3])
- }
- | tSTAR mlhs_node
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.splat(val[0]) ]
- }
- | tSTAR tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0]),
- *val[2] ]
- }
-
- mlhs_item: mlhs_node
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_head: mlhs_item tCOMMA
- {
- result = [ val[0] ]
- }
- | mlhs_head mlhs_item tCOMMA
- {
- result = val[0] << val[1]
- }
-
- mlhs_post: mlhs_item
- {
- result = [ val[0] ]
- }
- | mlhs_post tCOMMA mlhs_item
- {
- result = val[0] << val[2]
- }
-
- mlhs_node: variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- lhs: variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- cname: tIDENTIFIER
- {
- diagnostic :error, :module_name_const, nil, val[0]
- }
- | tCONSTANT
-
- cpath: tCOLON3 cname
- {
- result = @builder.const_global(val[0], val[1])
- }
- | cname
- {
- result = @builder.const(val[0])
- }
- | primary_value tCOLON2 cname
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
-
- fname: tIDENTIFIER | tCONSTANT | tFID
- | op
- | reswords
-
- fsym: fname
- {
- result = @builder.symbol(val[0])
- }
- | symbol
-
- fitem: fsym
- | dsym
-
- undef_list: fitem
- {
- result = [ val[0] ]
- }
- | undef_list tCOMMA
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = val[0] << val[3]
- }
-
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
- | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
- | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
- | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
-
- reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
- | kALIAS | kAND | kBEGIN | kBREAK | kCASE
- | kCLASS | kDEF | kDEFINED | kDO | kELSE
- | kELSIF | kEND | kENSURE | kFALSE | kFOR
- | kIN | kMODULE | kNEXT | kNIL | kNOT
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN
- | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
- | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
- | kUNTIL
-
- arg: lhs tEQL arg
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
- }
- | var_lhs tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.op_assign(val[0], val[1], rescue_)
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
- {
- diagnostic :error, :dynamic_const, nil, val[2], [ val[3] ]
- }
- | tCOLON3 tCONSTANT tOP_ASGN arg
- {
- diagnostic :error, :dynamic_const, nil, val[1], [ val[2] ]
- }
- | backref tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | arg tDOT2 arg
- {
- result = @builder.range_inclusive(val[0], val[1], val[2])
- }
- | arg tDOT3 arg
- {
- result = @builder.range_exclusive(val[0], val[1], val[2])
- }
- | arg tPLUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMINUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tSTAR2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tDIVIDE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPERCENT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPOW arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tUMINUS_NUM tINTEGER tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.integer(val[1]),
- val[2], val[3]))
- }
- | tUMINUS_NUM tFLOAT tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.float(val[1]),
- val[2], val[3]))
- }
- | tUPLUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | tUMINUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tPIPE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCARET arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tAMPER2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCMP arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tNEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMATCH arg
- {
- result = @builder.match_op(val[0], val[1], val[2])
- }
- | arg tNMATCH arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tBANG arg
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | tTILDE arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tLSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tRSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tANDOP arg
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | arg tOROP arg
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kDEFINED opt_nl arg
- {
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
- }
-
- | arg tEH arg opt_nl tCOLON arg
- {
- result = @builder.ternary(val[0], val[1],
- val[2], val[4], val[5])
- }
- | primary
-
- arg_value: arg
-
- aref_args: none
- | args trailer
- | args tCOMMA assocs trailer
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs trailer
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- paren_args: tLPAREN2 opt_call_args rparen
- {
- result = val
- }
-
- opt_paren_args: # nothing
- {
- result = [ nil, [], nil ]
- }
- | paren_args
-
- opt_call_args: # nothing
- {
- result = []
- }
- | call_args
-
- call_args: command
- {
- result = [ val[0] ]
- }
- | args opt_block_arg
- {
- result = val[0].concat(val[1])
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- result.concat(val[1])
- }
- | args tCOMMA assocs opt_block_arg
- {
- assocs = @builder.associate(nil, val[2], nil)
- result = val[0] << assocs
- result.concat(val[3])
- }
- | args tCOMMA assocs tCOMMA args opt_block_arg
- {
- val[2][-1] = @builder.objc_varargs(val[2][-1], val[4])
- assocs = @builder.associate(nil, val[2], nil)
- result = val[0] << assocs
- result.concat(val[5])
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- call_args2: arg_value tCOMMA args opt_block_arg
- {
- result = [ val[0], *val[2].concat(val[3]) ]
- }
- | arg_value tCOMMA block_arg
- {
- result = [ val[0], val[2] ]
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil),
- *val[1] ]
- }
- | arg_value tCOMMA assocs opt_block_arg
- {
- result = [ val[0],
- @builder.associate(nil, val[2], nil),
- *val[3] ]
- }
- | arg_value tCOMMA args tCOMMA assocs opt_block_arg
- {
- result = [ val[0],
- *val[2].
- push(@builder.associate(nil, val[4], nil)).
- concat(val[5]) ]
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- command_args: {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
- }
- open_args
- {
- @lexer.cmdarg = val[0]
-
- result = val[1]
- }
-
- open_args: call_args
- {
- result = [ nil, val[0], nil ]
- }
- | tLPAREN_ARG
- {
- @lexer.state = :expr_endarg
- }
- rparen
- {
- result = [ val[0], [], val[2] ]
- }
- | tLPAREN_ARG call_args2
- {
- @lexer.state = :expr_endarg
- }
- rparen
- {
- result = [ val[0], val[1], val[3] ]
- }
-
- block_arg: tAMPER arg_value
- {
- result = @builder.block_pass(val[0], val[1])
- }
-
- opt_block_arg: tCOMMA block_arg
- {
- result = [ val[1] ]
- }
- | tCOMMA
- {
- result = []
- }
- | # nothing
- {
- result = []
- }
-
- args: arg_value
- {
- result = [ val[0] ]
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
-
- mrhs: args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- primary: literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | var_ref
- | backref
- | tFID
- {
- result = @builder.call_method(nil, nil, val[0])
- }
- | kBEGIN bodystmt kEND
- {
- result = @builder.begin_keyword(val[0], val[1], val[2])
- }
- | tLPAREN_ARG expr
- {
- @lexer.state = :expr_endarg
- }
- rparen
- {
- result = @builder.begin(val[0], val[1], val[3])
- }
- | tLPAREN compstmt tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.const_global(val[0], val[1])
- }
- | tLBRACK aref_args tRBRACK
- {
- result = @builder.array(val[0], val[1], val[2])
- }
- | tLBRACE assoc_list tRCURLY
- {
- result = @builder.associate(val[0], val[1], val[2])
- }
- | kRETURN
- {
- result = @builder.keyword_cmd(:return, val[0])
- }
- | kYIELD tLPAREN2 call_args rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
- }
- | kYIELD tLPAREN2 rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
- }
- | kYIELD
- {
- result = @builder.keyword_cmd(:yield, val[0])
- }
- | kDEFINED opt_nl tLPAREN2 expr rparen
- {
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
- }
- | kNOT tLPAREN2 expr rparen
- {
- result = @builder.not_op(val[0], val[1], val[2], val[3])
- }
- | kNOT tLPAREN2 rparen
- {
- result = @builder.not_op(val[0], val[1], nil, val[2])
- }
- | operation brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | method_call
- | method_call brace_block
- {
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
- }
- | tLAMBDA lambda
- {
- lambda_call = @builder.call_lambda(val[0])
-
- args, (begin_t, body, end_t) = val[1]
- result = @builder.block(lambda_call,
- begin_t, args, body, end_t)
- }
- | kIF expr_value then compstmt if_tail kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
- }
- | kUNLESS expr_value then compstmt opt_else kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
- }
- | kWHILE
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kUNTIL
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kCASE expr_value opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[3]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
- }
- | kCASE opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[2]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
- }
- | kFOR for_var kIN
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
- }
- | kCLASS cpath superclass
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kCLASS tLSHFT expr term
- {
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- @def_level = val[4]
- }
- | kMODULE cpath
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kDEF fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kDEF singleton dot_or_colon
- {
- @lexer.state = :expr_fname
- }
- fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kBREAK
- {
- result = @builder.keyword_cmd(:break, val[0])
- }
- | kNEXT
- {
- result = @builder.keyword_cmd(:next, val[0])
- }
- | kREDO
- {
- result = @builder.keyword_cmd(:redo, val[0])
- }
- | kRETRY
- {
- result = @builder.keyword_cmd(:retry, val[0])
- }
-
- primary_value: primary
-
- then: term
- | kTHEN
- | term kTHEN
- {
- result = val[1]
- }
-
- do: term
- | kDO_COND
-
- if_tail: opt_else
- | kELSIF expr_value then compstmt if_tail
- {
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
- }
-
- opt_else: none
- | kELSE compstmt
- {
- result = val
- }
-
- for_var: lhs
- | mlhs
-
- f_marg: f_norm_arg
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_marg_list: f_marg
- {
- result = [ val[0] ]
- }
- | f_marg_list tCOMMA f_marg
- {
- result = val[0] << val[2]
- }
-
- f_margs: f_marg_list
- | f_marg_list tCOMMA tSTAR f_norm_arg
- {
- result = val[0].
- push(@builder.objc_restarg(val[2], val[3]))
- }
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.objc_restarg(val[2], val[3])).
- concat(val[5])
- }
- | f_marg_list tCOMMA tSTAR
- {
- result = val[0].
- push(@builder.objc_restarg(val[2]))
- }
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.objc_restarg(val[2])).
- concat(val[4])
- }
- | tSTAR f_norm_arg
- {
- result = [ @builder.objc_restarg(val[0], val[1]) ]
- }
- | tSTAR f_norm_arg tCOMMA f_marg_list
- {
- result = [ @builder.objc_restarg(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.objc_restarg(val[0]) ]
- }
- | tSTAR tCOMMA f_marg_list
- {
- result = [ @builder.objc_restarg(val[0]),
- *val[2] ]
- }
-
- block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_block_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_block_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_block_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
- opt_block_param: # nothing
- {
- result = @builder.args(nil, [], nil)
- }
- | block_param_def
- {
- @lexer.state = :expr_value
- }
-
- block_param_def: tPIPE opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1], val[2])
- }
- | tOROP
- {
- result = @builder.args(val[0], [], val[0])
- }
- | tPIPE block_param opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
-
- opt_bv_decl: # nothing
- {
- result = []
- }
- | tSEMI bv_decls
- {
- result = val[1]
- }
-
- bv_decls: bvar
- {
- result = [ val[0] ]
- }
- | bv_decls tCOMMA bvar
- {
- result = val[0] << val[2]
- }
-
- bvar: tIDENTIFIER
- {
- result = @builder.shadowarg(val[0])
- }
- | f_bad_arg
-
- lambda: {
- @static_env.extend_dynamic
- }
- f_larglist lambda_body
- {
- result = [ val[1], val[2] ]
-
- @static_env.unextend
- }
-
- f_larglist: tLPAREN2 f_args opt_bv_decl rparen
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
- | f_args
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- lambda_body: tLAMBEG compstmt tRCURLY
- {
- result = [ val[0], val[1], val[2] ]
- }
- | kDO_LAMBDA compstmt kEND
- {
- result = [ val[0], val[1], val[2] ]
- }
-
- do_block: kDO_BLOCK
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- block_call: command do_block
- {
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
- }
- | block_call tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | block_call tCOLON2 operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
-
- method_call: operation paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
- }
- | primary_value tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation3
- {
- result = @builder.call_method(val[0], val[1], val[2])
- }
- | primary_value tDOT paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | kSUPER paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
- }
- | kSUPER
- {
- result = @builder.keyword_cmd(:zsuper, val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index(val[0], val[1], val[2], val[3])
- }
-
- brace_block: tLCURLY
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
- | kDO
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- case_body: kWHEN args then compstmt cases
- {
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
- }
-
- cases: opt_else
- {
- result = [ val[0] ]
- }
- | case_body
-
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
- {
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
- }
- |
- {
- result = []
- }
-
- exc_list: arg_value
- {
- result = [ val[0] ]
- }
- | mrhs
- | none
-
- exc_var: tASSOC lhs
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- opt_ensure: kENSURE compstmt
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- literal: numeric
- | symbol
- | dsym
-
- strings: string
- {
- result = @builder.string_compose(nil, val[0], nil)
- }
-
- string: string1
- {
- result = [ val[0] ]
- }
- | string string1
- {
- result = val[0] << val[1]
- }
-
- string1: tSTRING_BEG string_contents tSTRING_END
- {
- result = @builder.string_compose(val[0], val[1], val[2])
- }
- | tSTRING
- {
- result = @builder.string(val[0])
- }
- | tCHARACTER
- {
- result = @builder.character(val[0])
- }
-
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
- {
- result = @builder.xstring_compose(val[0], val[1], val[2])
- }
-
- regexp: tREGEXP_BEG regexp_contents tSTRING_END tREGEXP_OPT
- {
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
- }
-
- words: tWORDS_BEG word_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- word_list: # nothing
- {
- result = []
- }
- | word_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- word: string_content
- {
- result = [ val[0] ]
- }
- | word string_content
- {
- result = val[0] << val[1]
- }
-
- qwords: tQWORDS_BEG qword_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- qword_list: # nothing
- {
- result = []
- }
- | qword_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.string_internal(val[1])
- }
-
- string_contents: # nothing
- {
- result = []
- }
- | string_contents string_content
- {
- result = val[0] << val[1]
- }
-
-xstring_contents: # nothing
- {
- result = []
- }
- | xstring_contents string_content
- {
- result = val[0] << val[1]
- }
-
-regexp_contents: # nothing
- {
- result = []
- }
- | regexp_contents string_content
- {
- result = val[0] << val[1]
- }
-
- string_content: tSTRING_CONTENT
- {
- result = @builder.string_internal(val[0])
- }
- | tSTRING_DVAR string_dvar
- {
- result = val[1]
- }
- | tSTRING_DBEG
- {
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
- }
- compstmt tRCURLY
- {
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
- }
-
- string_dvar: tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | backref
-
-
- symbol: tSYMBOL
- {
- result = @builder.symbol(val[0])
- }
-
- dsym: tSYMBEG xstring_contents tSTRING_END
- {
- result = @builder.symbol_compose(val[0], val[1], val[2])
- }
-
- numeric: tINTEGER
- {
- result = @builder.integer(val[0])
- }
- | tFLOAT
- {
- result = @builder.float(val[0])
- }
- | tUMINUS_NUM tINTEGER =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.integer(val[1]))
- }
- | tUMINUS_NUM tFLOAT =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.float(val[1]))
- }
-
- variable: tIDENTIFIER
- {
- result = @builder.ident(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tCONSTANT
- {
- result = @builder.const(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | kNIL
- {
- result = @builder.nil(val[0])
- }
- | kSELF
- {
- result = @builder.self(val[0])
- }
- | kTRUE
- {
- result = @builder.true(val[0])
- }
- | kFALSE
- {
- result = @builder.false(val[0])
- }
- | k__FILE__
- {
- result = @builder.__FILE__(val[0])
- }
- | k__LINE__
- {
- result = @builder.__LINE__(val[0])
- }
- | k__ENCODING__
- {
- result = @builder.__ENCODING__(val[0])
- }
-
- var_ref: variable
- {
- result = @builder.accessible(val[0])
- }
-
- var_lhs: variable
- {
- result = @builder.assignable(val[0])
- }
-
- backref: tNTH_REF
- {
- result = @builder.nth_ref(val[0])
- }
- | tBACK_REF
- {
- result = @builder.back_ref(val[0])
- }
-
- superclass: term
- {
- result = nil
- }
- | tLT expr_value term
- {
- result = [ val[0], val[1] ]
- }
- | error term
- {
- yyerrok
- result = nil
- }
-
- f_arglist: tLPAREN2 f_args rparen
- {
- result = @builder.args(val[0], val[1], val[2])
-
- @lexer.state = :expr_value
- }
- | f_args term
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
- | # nothing
- {
- result = []
- }
-
- f_bad_arg: tCONSTANT
- {
- diagnostic :error, :argument_const, nil, val[0]
- }
- | tIVAR
- {
- diagnostic :error, :argument_ivar, nil, val[0]
- }
- | tGVAR
- {
- diagnostic :error, :argument_gvar, nil, val[0]
- }
- | tCVAR
- {
- diagnostic :error, :argument_cvar, nil, val[0]
- }
-
- f_norm_arg: f_bad_arg
- | tIDENTIFIER
- {
- @static_env.declare val[0][0]
-
- result = @builder.arg(val[0])
- }
- | tIDENTIFIER tASSOC tIDENTIFIER
- {
- @static_env.declare val[2][0]
-
- result = @builder.objc_kwarg(val[0], val[1], val[2])
- }
- | tLABEL tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = @builder.objc_kwarg(val[0], nil, val[1])
- }
-
- f_arg_item: f_norm_arg
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_arg: f_arg_item
- {
- result = [ val[0] ]
- }
- | f_arg tCOMMA f_arg_item
- {
- result = val[0] << val[2]
- }
-
- f_opt: tIDENTIFIER tEQL arg_value
- {
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_opt: tIDENTIFIER tEQL primary_value
- {
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_optarg: f_block_opt
- {
- result = [ val[0] ]
- }
- | f_block_optarg tCOMMA f_block_opt
- {
- result = val[0] << val[2]
- }
-
- f_optarg: f_opt
- {
- result = [ val[0] ]
- }
- | f_optarg tCOMMA f_opt
- {
- result = val[0] << val[2]
- }
-
- restarg_mark: tSTAR2 | tSTAR
-
- f_rest_arg: restarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | restarg_mark
- {
- result = [ @builder.restarg(val[0]) ]
- }
-
- blkarg_mark: tAMPER2 | tAMPER
-
- f_block_arg: blkarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
- }
-
- opt_f_block_arg: tCOMMA f_block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- singleton: var_ref
- | tLPAREN2 expr rparen
- {
- result = val[1]
- }
-
- assoc_list: # nothing
- {
- result = []
- }
- | assocs trailer
-
- assocs: assoc
- {
- result = [ val[0] ]
- }
- | assocs tCOMMA assoc
- {
- result = val[0] << val[2]
- }
-
- assoc: arg_value tASSOC arg_value
- {
- result = @builder.pair(val[0], val[1], val[2])
- }
- | tLABEL arg_value
- {
- result = @builder.pair_keyword(val[0], val[1])
- }
-
- operation: tIDENTIFIER | tCONSTANT | tFID
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
- operation3: tIDENTIFIER | tFID | op
- dot_or_colon: tDOT | tCOLON2
- opt_terms: | terms
- opt_nl: | tNL
- rparen: opt_nl tRPAREN
- {
- result = val[1]
- }
- rbracket: opt_nl tRBRACK
- {
- result = val[1]
- }
- trailer: | tNL | tCOMMA
-
- term: tSEMI
- {
- yyerrok
- }
- | tNL
-
- terms: term
- | terms tSEMI
-
- none: # nothing
- {
- result = nil
- }
-end
-
----- header
-
-require 'parser'
-
-Parser.check_for_encoding_support
-
----- inner
-
- def version
- 19 # closest released match: v1_9_0_2
- end
-
- def default_encoding
- Encoding::BINARY
- end
diff --git a/test/racc/assets/mailp.y b/test/racc/assets/mailp.y
deleted file mode 100644
index eb7d4d529d..0000000000
--- a/test/racc/assets/mailp.y
+++ /dev/null
@@ -1,437 +0,0 @@
-#
-# mailp for test
-#
-
-class Testp
-
-rule
-
- content : DateH datetime { @field.date = val[1] }
- | RecvH received
- | RetpathH returnpath
- | MaddrH addrs { @field.addrs.replace val[1] }
- | SaddrH addr { @field.addr = val[1] }
- | MmboxH mboxes { @field.addrs.replace val[1] }
- | SmboxH mbox { @field.addr = val[1] }
- | MsgidH msgid { @field.msgid = val[1] }
- | KeyH keys { @field.keys.replace val[1] }
- | EncH enc
- | VersionH version
- | CTypeH ctype
- | CEncodingH cencode
- | CDispositionH cdisp
- | Mbox mbox
- {
- mb = val[1]
- @field.phrase = mb.phrase
- @field.setroute mb.route
- @field.local = mb.local
- @field.domain = mb.domain
- }
- | Spec spec
- {
- mb = val[1]
- @field.local = mb.local
- @field.domain = mb.domain
- }
- ;
-
- datetime : day DIGIT ATOM DIGIT hour zone
- # 0 1 2 3 4 5
- # day month year
- {
- t = Time.gm( val[3].to_i, val[2], val[1].to_i, 0, 0, 0 )
- result = (t + val[4] - val[5]).localtime
- }
- ;
-
- day : /* none */
- | ATOM ','
- ;
-
- hour : DIGIT ':' DIGIT
- {
- result = (result.to_i * 60 * 60) + (val[2].to_i * 60)
- }
- | DIGIT ':' DIGIT ':' DIGIT
- {
- result = (result.to_i * 60 * 60) +
- (val[2].to_i * 60)
- + val[4].to_i
- }
- ;
-
- zone : ATOM
- {
- result = ::TMail.zonestr2i( val[0] ) * 60
- }
- ;
-
- received : from by via with id for recvdatetime
- ;
-
- from : /* none */
- | FROM domain
- {
- @field.from = Address.join( val[1] )
- }
- | FROM domain '@' domain
- {
- @field.from = Address.join( val[3] )
- }
- | FROM domain DOMLIT
- {
- @field.from = Address.join( val[1] )
- }
- ;
-
- by : /* none */
- | BY domain
- {
- @field.by = Address.join( val[1] )
- }
- ;
-
- via : /* none */
- | VIA ATOM
- {
- @field.via = val[1]
- }
- ;
-
- with : /* none */
- | WITH ATOM
- {
- @field.with.push val[1]
- }
- ;
-
- id : /* none */
- | ID msgid
- {
- @field.msgid = val[1]
- }
- | ID ATOM
- {
- @field.msgid = val[1]
- }
- ;
-
- for : /* none */
- | FOR addr
- {
- @field.for_ = val[1].address
- }
- ;
-
- recvdatetime
- : /* none */
- | ';' datetime
- {
- @field.date = val[1]
- }
- ;
-
- returnpath: '<' '>'
- | routeaddr
- {
- @field.route.replace result.route
- @field.addr = result.addr
- }
- ;
-
- addrs : addr { result = val }
- | addrs ',' addr { result.push val[2] }
- ;
-
- addr : mbox
- | group
- ;
-
- mboxes : mbox
- {
- result = val
- }
- | mboxes ',' mbox
- {
- result.push val[2]
- }
- ;
-
- mbox : spec
- | routeaddr
- | phrase routeaddr
- {
- val[1].phrase = HFdecoder.decode( result )
- result = val[1]
- }
- ;
-
- group : phrase ':' mboxes ';'
- {
- result = AddressGroup.new( result, val[2] )
- }
- # | phrase ':' ';' { result = AddressGroup.new( result ) }
- ;
-
- routeaddr : '<' route spec '>'
- {
- result = val[2]
- result.route = val[1]
- }
- | '<' spec '>'
- {
- result = val[1]
- }
- ;
-
- route : at_domains ':'
- ;
-
- at_domains: '@' domain { result = [ val[1] ] }
- | at_domains ',' '@' domain { result.push val[3] }
- ;
-
- spec : local '@' domain { result = Address.new( val[0], val[2] ) }
- | local { result = Address.new( result, nil ) }
- ;
-
- local : word { result = val }
- | local '.' word { result.push val[2] }
- ;
-
- domain : domword { result = val }
- | domain '.' domword { result.push val[2] }
- ;
-
- domword : atom
- | DOMLIT
- | DIGIT
- ;
-
- msgid : '<' spec '>'
- {
- val[1] = val[1].addr
- result = val.join('')
- }
- ;
-
- phrase : word
- | phrase word { result << ' ' << val[1] }
- ;
-
- word : atom
- | QUOTED
- | DIGIT
- ;
-
- keys : phrase
- | keys ',' phrase
- ;
-
- enc : word
- {
- @field.encrypter = val[0]
- }
- | word word
- {
- @field.encrypter = val[0]
- @field.keyword = val[1]
- }
- ;
-
- version : DIGIT '.' DIGIT
- {
- @field.major = val[0].to_i
- @field.minor = val[2].to_i
- }
- ;
-
- ctype : TOKEN '/' TOKEN params
- {
- @field.main = val[0]
- @field.sub = val[2]
- }
- | TOKEN params
- {
- @field.main = val[0]
- @field.sub = ''
- }
- ;
-
- params : /* none */
- | params ';' TOKEN '=' value
- {
- @field.params[ val[2].downcase ] = val[4]
- }
- ;
-
- value : TOKEN
- | QUOTED
- ;
-
- cencode : TOKEN
- {
- @field.encoding = val[0]
- }
- ;
-
- cdisp : TOKEN disp_params
- {
- @field.disposition = val[0]
- }
- ;
-
- disp_params
- : /* none */
- | disp_params ';' disp_param
- ;
-
- disp_param: /* none */
- | TOKEN '=' value
- {
- @field.params[ val[0].downcase ] = val[2]
- }
- ;
-
- atom : ATOM
- | FROM
- | BY
- | VIA
- | WITH
- | ID
- | FOR
- ;
-
-end
-
-
----- header
-#
-# mailp for test
-#
-
-require 'tmail/mails'
-
-
-module TMail
-
----- inner
-
- MAILP_DEBUG = false
-
- def initialize
- self.debug = MAILP_DEBUG
- end
-
- def debug=( flag )
- @yydebug = flag && Racc_debug_parser
- @scanner_debug = flag
- end
-
- def debug
- @yydebug
- end
-
-
- def Mailp.parse( str, obj, ident )
- new.parse( str, obj, ident )
- end
-
-
- NATIVE_ROUTINE = {
- 'TMail::MsgidH' => :msgid_parse,
- 'TMail::RefH' => :refs_parse
- }
-
- def parse( str, obj, ident )
- return if /\A\s*\z/ === str
-
- @field = obj
-
- if mid = NATIVE_ROUTINE[ obj.type.name ] then
- send mid, str
- else
- unless ident then
- ident = obj.type.name.split('::')[-1].to_s
- cmt = []
- obj.comments.replace cmt
- else
- cmt = nil
- end
-
- @scanner = MailScanner.new( str, ident, cmt )
- @scanner.debug = @scanner_debug
- @first = [ ident.intern, ident ]
- @pass_array = [nil, nil]
-
- do_parse
- end
- end
-
-
- private
-
-
- def next_token
- if @first then
- ret = @first
- @first = nil
- ret
- else
- @scanner.scan @pass_array
- end
- end
-
- def on_error( tok, val, vstack )
- raise ParseError,
- "\nparse error in '#{@field.name}' header, on token #{val.inspect}"
- end
-
-
-
- def refs_parse( str )
- arr = []
-
- while mdata = ::TMail::MSGID.match( str ) do
- str = mdata.post_match
-
- pre = mdata.pre_match
- pre.strip!
- proc_phrase pre, arr unless pre.empty?
- arr.push mdata.to_s
- end
- str.strip!
- proc_phrase str, arr if not pre or pre.empty?
-
- @field.refs.replace arr
- end
-
- def proc_phrase( str, arr )
- while mdata = /"([^\\]*(?:\\.[^"\\]*)*)"/.match( str ) do
- str = mdata.post_match
-
- pre = mdata.pre_match
- pre.strip!
- arr.push pre unless pre.empty?
- arr.push mdata[1]
- end
- str.strip!
- arr.push unless str.empty?
- end
-
-
- def msgid_parse( str )
- if mdata = ::TMail::MSGID.match( str ) then
- @field.msgid = mdata.to_s
- else
- raise ParseError, "wrong Message-ID format: #{str}"
- end
- end
-
----- footer
-
-end # module TMail
-
-mp = TMail::Testp.new
-mp.parse
diff --git a/test/racc/assets/mediacloth.y b/test/racc/assets/mediacloth.y
deleted file mode 100644
index 94cc411ea7..0000000000
--- a/test/racc/assets/mediacloth.y
+++ /dev/null
@@ -1,599 +0,0 @@
-# Copyright (c) 2006 Pluron Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-# The parser for the MediaWiki language.
-#
-# Usage together with a lexer:
-# inputFile = File.new("data/input1", "r")
-# input = inputFile.read
-# parser = MediaWikiParser.new
-# parser.lexer = MediaWikiLexer.new
-# parser.parse(input)
-
-class MediaWikiParser
-
-token TEXT BOLD_START BOLD_END ITALIC_START ITALIC_END LINK_START LINK_END LINKSEP
- INTLINK_START INTLINK_END INTLINKSEP RESOURCESEP CHAR_ENT
- PRE_START PRE_END PREINDENT_START PREINDENT_END
- SECTION_START SECTION_END HLINE SIGNATURE_NAME SIGNATURE_DATE SIGNATURE_FULL
- PARA_START PARA_END UL_START UL_END OL_START OL_END LI_START LI_END
- DL_START DL_END DT_START DT_END DD_START DD_END TAG_START TAG_END ATTR_NAME ATTR_VALUE
- TABLE_START TABLE_END ROW_START ROW_END HEAD_START HEAD_END CELL_START CELL_END
- KEYWORD TEMPLATE_START TEMPLATE_END CATEGORY PASTE_START PASTE_END
-
-
-rule
-
-wiki:
- repeated_contents
- {
- @nodes.push WikiAST.new(0, @wiki_ast_length)
- #@nodes.last.children.insert(0, val[0])
- #puts val[0]
- @nodes.last.children += val[0]
- }
- ;
-
-contents:
- text
- {
- result = val[0]
- }
- | bulleted_list
- {
- result = val[0]
- }
- | numbered_list
- {
- result = val[0]
- }
- | dictionary_list
- {
- list = ListAST.new(@ast_index, @ast_length)
- list.list_type = :Dictionary
- list.children = val[0]
- result = list
- }
- | preformatted
- {
- result = val[0]
- }
- | section
- {
- result = val[0]
- }
- | tag
- {
- result = val[0]
- }
- | template
- {
- result = val[0]
- }
- | KEYWORD
- {
- k = KeywordAST.new(@ast_index, @ast_length)
- k.text = val[0]
- result = k
- }
- | PARA_START para_contents PARA_END
- {
- p = ParagraphAST.new(@ast_index, @ast_length)
- p.children = val[1]
- result = p
- }
- | LINK_START link_contents LINK_END
- {
- l = LinkAST.new(@ast_index, @ast_length)
- l.link_type = val[0]
- l.url = val[1][0]
- l.children += val[1][1..-1] if val[1].length > 1
- result = l
- }
- | PASTE_START para_contents PASTE_END
- {
- p = PasteAST.new(@ast_index, @ast_length)
- p.children = val[1]
- result = p
- }
- | INTLINK_START TEXT RESOURCESEP TEXT reslink_repeated_contents INTLINK_END
- {
- l = ResourceLinkAST.new(@ast_index, @ast_length)
- l.prefix = val[1]
- l.locator = val[3]
- l.children = val[4] unless val[4].nil? or val[4].empty?
- result = l
- }
- | INTLINK_START TEXT intlink_repeated_contents INTLINK_END
- {
- l = InternalLinkAST.new(@ast_index, @ast_length)
- l.locator = val[1]
- l.children = val[2] unless val[2].nil? or val[2].empty?
- result = l
- }
- | INTLINK_START CATEGORY TEXT cat_sort_contents INTLINK_END
- {
- l = CategoryAST.new(@ast_index, @ast_length)
- l.locator = val[2]
- l.sort_as = val[3]
- result = l
- }
- | INTLINK_START RESOURCESEP CATEGORY TEXT intlink_repeated_contents INTLINK_END
- {
- l = CategoryLinkAST.new(@ast_index, @ast_length)
- l.locator = val[3]
- l.children = val[4] unless val[4].nil? or val[4].empty?
- result = l
- }
- | table
- ;
-
-para_contents:
- {
- result = nil
- }
- | repeated_contents
- {
- result = val[0]
- }
- ;
-
-tag:
- TAG_START tag_attributes TAG_END
- {
- if val[0] != val[2]
- raise Racc::ParseError.new("XHTML end tag #{val[2]} does not match start tag #{val[0]}")
- end
- elem = ElementAST.new(@ast_index, @ast_length)
- elem.name = val[0]
- elem.attributes = val[1]
- result = elem
- }
- | TAG_START tag_attributes repeated_contents TAG_END
- {
- if val[0] != val[3]
- raise Racc::ParseError.new("XHTML end tag #{val[3]} does not match start tag #{val[0]}")
- end
- elem = ElementAST.new(@ast_index, @ast_length)
- elem.name = val[0]
- elem.attributes = val[1]
- elem.children += val[2]
- result = elem
- }
- ;
-
-tag_attributes:
- {
- result = nil
- }
- | ATTR_NAME tag_attributes
- {
- attr_map = val[2] ? val[2] : {}
- attr_map[val[0]] = true
- result = attr_map
- }
- | ATTR_NAME ATTR_VALUE tag_attributes
- {
- attr_map = val[2] ? val[2] : {}
- attr_map[val[0]] = val[1]
- result = attr_map
- }
- ;
-
-
-link_contents:
- TEXT
- {
- result = val
- }
- | TEXT LINKSEP link_repeated_contents
- {
- result = [val[0]]
- result += val[2]
- }
- ;
-
-
-link_repeated_contents:
- repeated_contents
- {
- result = val[0]
- }
- | repeated_contents LINKSEP link_repeated_contents
- {
- result = val[0]
- result += val[2] if val[2]
- }
- ;
-
-
-intlink_repeated_contents:
- {
- result = nil
- }
- | INTLINKSEP repeated_contents
- {
- result = val[1]
- }
- ;
-
-cat_sort_contents:
- {
- result = nil
- }
- | INTLINKSEP TEXT
- {
- result = val[1]
- }
- ;
-
-reslink_repeated_contents:
- {
- result = nil
- }
- | INTLINKSEP reslink_repeated_contents
- {
- result = val[1]
- }
- | INTLINKSEP repeated_contents reslink_repeated_contents
- {
- i = InternalLinkItemAST.new(@ast_index, @ast_length)
- i.children = val[1]
- result = [i]
- result += val[2] if val[2]
- }
- ;
-
-repeated_contents: contents
- {
- result = []
- result << val[0]
- }
- | repeated_contents contents
- {
- result = []
- result += val[0]
- result << val[1]
- }
- ;
-
-text: element
- {
- p = TextAST.new(@ast_index, @ast_length)
- p.formatting = val[0][0]
- p.contents = val[0][1]
- result = p
- }
- | formatted_element
- {
- result = val[0]
- }
- ;
-
-table:
- TABLE_START table_contents TABLE_END
- {
- table = TableAST.new(@ast_index, @ast_length)
- table.children = val[1] unless val[1].nil? or val[1].empty?
- result = table
- }
- | TABLE_START TEXT table_contents TABLE_END
- {
- table = TableAST.new(@ast_index, @ast_length)
- table.options = val[1]
- table.children = val[2] unless val[2].nil? or val[2].empty?
- result = table
- }
-
-table_contents:
- {
- result = nil
- }
- | ROW_START row_contents ROW_END table_contents
- {
- row = TableRowAST.new(@ast_index, @ast_length)
- row.children = val[1] unless val[1].nil? or val[1].empty?
- result = [row]
- result += val[3] unless val[3].nil? or val[3].empty?
- }
- | ROW_START TEXT row_contents ROW_END table_contents
- {
- row = TableRowAST.new(@ast_index, @ast_length)
- row.children = val[2] unless val[2].nil? or val[2].empty?
- row.options = val[1]
- result = [row]
- result += val[4] unless val[4].nil? or val[4].empty?
- }
-
-row_contents:
- {
- result = nil
- }
- | HEAD_START HEAD_END row_contents
- {
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.type = :head
- result = [cell]
- result += val[2] unless val[2].nil? or val[2].empty?
- }
- | HEAD_START repeated_contents HEAD_END row_contents
- {
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.children = val[1] unless val[1].nil? or val[1].empty?
- cell.type = :head
- result = [cell]
- result += val[3] unless val[3].nil? or val[3].empty?
- }
- | CELL_START CELL_END row_contents
- {
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.type = :body
- result = [cell]
- result += val[2] unless val[2].nil? or val[2].empty?
- }
- | CELL_START repeated_contents CELL_END row_contents
- {
- if val[2] == 'attributes'
- result = []
- else
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.children = val[1] unless val[1].nil? or val[1].empty?
- cell.type = :body
- result = [cell]
- end
- result += val[3] unless val[3].nil? or val[3].empty?
- if val[2] == 'attributes' and val[3] and val[3].first.class == TableCellAST
- val[3].first.attributes = val[1]
- end
- result
- }
-
-
-element:
- TEXT
- { return [:None, val[0]] }
- | HLINE
- { return [:HLine, val[0]] }
- | CHAR_ENT
- { return [:CharacterEntity, val[0]] }
- | SIGNATURE_DATE
- { return [:SignatureDate, val[0]] }
- | SIGNATURE_NAME
- { return [:SignatureName, val[0]] }
- | SIGNATURE_FULL
- { return [:SignatureFull, val[0]] }
- ;
-
-formatted_element:
- BOLD_START BOLD_END
- {
- result = FormattedAST.new(@ast_index, @ast_length)
- result.formatting = :Bold
- result
- }
- | ITALIC_START ITALIC_END
- {
- result = FormattedAST.new(@ast_index, @ast_length)
- result.formatting = :Italic
- result
- }
- | BOLD_START repeated_contents BOLD_END
- {
- p = FormattedAST.new(@ast_index, @ast_length)
- p.formatting = :Bold
- p.children += val[1]
- result = p
- }
- | ITALIC_START repeated_contents ITALIC_END
- {
- p = FormattedAST.new(@ast_index, @ast_length)
- p.formatting = :Italic
- p.children += val[1]
- result = p
- }
- ;
-
-bulleted_list: UL_START list_item list_contents UL_END
- {
- list = ListAST.new(@ast_index, @ast_length)
- list.list_type = :Bulleted
- list.children << val[1]
- list.children += val[2]
- result = list
- }
- ;
-
-numbered_list: OL_START list_item list_contents OL_END
- {
- list = ListAST.new(@ast_index, @ast_length)
- list.list_type = :Numbered
- list.children << val[1]
- list.children += val[2]
- result = list
- }
- ;
-
-list_contents:
- { result = [] }
- list_item list_contents
- {
- result << val[1]
- result += val[2]
- }
- |
- { result = [] }
- ;
-
-list_item:
- LI_START LI_END
- {
- result = ListItemAST.new(@ast_index, @ast_length)
- }
- | LI_START repeated_contents LI_END
- {
- li = ListItemAST.new(@ast_index, @ast_length)
- li.children += val[1]
- result = li
- }
- ;
-
-dictionary_list:
- DL_START dictionary_term dictionary_contents DL_END
- {
- result = [val[1]]
- result += val[2]
- }
- | DL_START dictionary_contents DL_END
- {
- result = val[1]
- }
- ;
-
-dictionary_term:
- DT_START DT_END
- {
- result = ListTermAST.new(@ast_index, @ast_length)
- }
- | DT_START repeated_contents DT_END
- {
- term = ListTermAST.new(@ast_index, @ast_length)
- term.children += val[1]
- result = term
- }
-
-dictionary_contents:
- dictionary_definition dictionary_contents
- {
- result = [val[0]]
- result += val[1] if val[1]
- }
- |
- {
- result = []
- }
-
-dictionary_definition:
- DD_START DD_END
- {
- result = ListDefinitionAST.new(@ast_index, @ast_length)
- }
- | DD_START repeated_contents DD_END
- {
- term = ListDefinitionAST.new(@ast_index, @ast_length)
- term.children += val[1]
- result = term
- }
-
-preformatted: PRE_START repeated_contents PRE_END
- {
- p = PreformattedAST.new(@ast_index, @ast_length)
- p.children += val[1]
- result = p
- }
- | PREINDENT_START repeated_contents PREINDENT_END
- {
- p = PreformattedAST.new(@ast_index, @ast_length)
- p.indented = true
- p.children += val[1]
- result = p
- }
- ;
-
-section: SECTION_START repeated_contents SECTION_END
- { result = [val[1], val[0].length]
- s = SectionAST.new(@ast_index, @ast_length)
- s.children = val[1]
- s.level = val[0].length
- result = s
- }
- ;
-
-template: TEMPLATE_START TEXT template_parameters TEMPLATE_END
- {
- t = TemplateAST.new(@ast_index, @ast_length)
- t.template_name = val[1]
- t.children = val[2] unless val[2].nil? or val[2].empty?
- result = t
- }
- ;
-
-template_parameters:
- {
- result = nil
- }
- | INTLINKSEP TEXT template_parameters
- {
- p = TemplateParameterAST.new(@ast_index, @ast_length)
- p.parameter_value = val[1]
- result = [p]
- result += val[2] if val[2]
- }
- | INTLINKSEP template template_parameters
- {
- p = TemplateParameterAST.new(@ast_index, @ast_length)
- p.children << val[1]
- result = [p]
- result += val[2] if val[2]
- }
- ;
-
-end
-
----- header ----
-require 'mediacloth/mediawikiast'
-
----- inner ----
-
-attr_accessor :lexer
-
-def initialize
- @nodes = []
- @context = []
- @wiki_ast_length = 0
- super
-end
-
-#Tokenizes input string and parses it.
-def parse(input)
- @yydebug=true
- lexer.tokenize(input)
- do_parse
- return @nodes.last
-end
-
-#Asks the lexer to return the next token.
-def next_token
- token = @lexer.lex
- if token[0].to_s.upcase.include? "_START"
- @context << token[2..3]
- elsif token[0].to_s.upcase.include? "_END"
- @ast_index = @context.last[0]
- @ast_length = token[2] + token[3] - @context.last[0]
- @context.pop
- else
- @ast_index = token[2]
- @ast_length = token[3]
- end
-
- @wiki_ast_length += token[3]
-
- return token[0..1]
-end
diff --git a/test/racc/assets/mof.y b/test/racc/assets/mof.y
deleted file mode 100644
index da3172988f..0000000000
--- a/test/racc/assets/mof.y
+++ /dev/null
@@ -1,649 +0,0 @@
-# Distributed under the Ruby license
-# See http://www.ruby-lang.org/en/LICENSE.txt for the full license text
-# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
-
-/*
- * According to appendix A of
- * http://www.dmtf.org/standards/cim/cim_spec_v22
- */
-
-class MOF::Parser
- prechigh
-/* nonassoc UMINUS */
- left '*' '/'
- left '+' '-'
- preclow
-
- token PRAGMA INCLUDE IDENTIFIER CLASS ASSOCIATION INDICATION
- AMENDED ENABLEOVERRIDE DISABLEOVERRIDE RESTRICTED TOSUBCLASS TOINSTANCE
- TRANSLATABLE QUALIFIER SCOPE SCHEMA PROPERTY REFERENCE
- METHOD PARAMETER FLAVOR INSTANCE
- AS REF ANY OF
- DT_VOID
- DT_UINT8 DT_SINT8 DT_UINT16 DT_SINT16 DT_UINT32 DT_SINT32
- DT_UINT64 DT_SINT64 DT_REAL32 DT_REAL64 DT_CHAR16 DT_STR
- DT_BOOLEAN DT_DATETIME
- positiveDecimalValue
- stringValue
- realValue
- charValue
- booleanValue
- nullValue
- binaryValue
- octalValue
- decimalValue
- hexValue
-
-rule
-
- /* Returns a Hash of filename and MofResult */
- mofSpecification
- : /* empty */
- { result = Hash.new }
- | mofProduction
- { result = { @name => @result } }
- | mofSpecification mofProduction
- { result = val[0]
- result[@name] = @result
- }
- ;
-
- mofProduction
- : compilerDirective
- | classDeclaration
- { #puts "Class '#{val[0].name}'"
- @result.classes << val[0]
- }
- | qualifierDeclaration
- { @result.qualifiers << val[0]
- @qualifiers[val[0].name.downcase] = val[0]
- }
- | instanceDeclaration
- { @result.instances << val[0] }
- ;
-
-/***
- * compilerDirective
- *
- */
-
- compilerDirective
- : "#" PRAGMA INCLUDE pragmaParameters_opt
- { raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#pragma include'") unless val[3]
- open val[3], :pragma
- }
- | "#" PRAGMA pragmaName pragmaParameters_opt
- | "#" INCLUDE pragmaParameters_opt
- { raise StyleError.new(@name,@lineno,@line,"Use '#pragma include' instead of '#include'") unless @style == :wmi
- raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#include'") unless val[2]
- open val[2], :pragma
- }
- ;
-
- pragmaName
- : IDENTIFIER
- ;
-
- pragmaParameters_opt
- : /* empty */
- { raise StyleError.new(@name,@lineno,@line,"#pragma parameter missing") unless @style == :wmi }
- | "(" pragmaParameterValues ")"
- { result = val[1] }
- ;
-
- pragmaParameterValues
- : pragmaParameterValue
- | pragmaParameterValues "," pragmaParameterValue
- ;
-
- pragmaParameterValue
- : string
- | integerValue
- { raise StyleError.new(@name,@lineno,@line,"#pragma parameter missing") unless @style == :wmi }
- | IDENTIFIER
- ;
-
-/***
- * classDeclaration
- *
- */
-
- classDeclaration
- : qualifierList_opt CLASS className alias_opt superClass_opt "{" classFeatures "}" ";"
- { qualifiers = val[0]
- features = val[6]
- # FIXME: features must not include references
- result = CIM::Class.new(val[2],qualifiers,val[3],val[4],features)
- }
- ;
-
- classFeatures
- : /* empty */
- { result = [] }
- | classFeatures classFeature
- { result = val[0] << val[1] }
- ;
-
- classFeature
- : propertyDeclaration
- | methodDeclaration
- | referenceDeclaration /* must have association qualifier */
- ;
-
-
- qualifierList_opt
- : /* empty */
- | qualifierList
- { result = CIM::QualifierSet.new val[0] }
- ;
-
- qualifierList
- : "[" qualifier qualifiers "]"
- { result = val[2]
- result.unshift val[1] if val[1] }
- ;
-
- qualifiers
- : /* empty */
- { result = [] }
- | qualifiers "," qualifier
- { result = val[0]
- result << val[2] if val[2]
- }
- ;
-
- qualifier
- : qualifierName qualifierParameter_opt flavor_opt
- { # Get qualifier decl
- qualifier = case val[0]
- when CIM::Qualifier then val[0].definition
- when CIM::QualifierDeclaration then val[0]
- when String then @qualifiers[val[0].downcase]
- else
- nil
- end
- raise MOF::Helper::Error.new(@name,@lineno,@line,"'#{val[0]}' is not a valid qualifier") unless qualifier
- value = val[1]
- raise MOF::Helper::Error.new(@name,@lineno,@line,"#{value.inspect} does not match qualifier type '#{qualifier.type}'") unless qualifier.type.matches?(value)||@style == :wmi
- # Don't propagate a boolean 'false'
- if qualifier.type == :boolean && value == false
- result = nil
- else
- result = CIM::Qualifier.new(qualifier,value,val[2])
- end
- }
- ;
-
- flavor_opt
- : /* empty */
- | ":" flavor
- { result = CIM::QualifierFlavors.new val[1] }
- ;
-
- qualifierParameter_opt
- : /* empty */
- | qualifierParameter
- ;
-
- qualifierParameter
- : "(" constantValue ")"
- { result = val[1] }
- | arrayInitializer
- ;
-
- /* CIM::Flavors */
- flavor
- : AMENDED | ENABLEOVERRIDE | DISABLEOVERRIDE | RESTRICTED | TOSUBCLASS | TRANSLATABLE | TOINSTANCE
- { case val[0].to_sym
- when :amended, :toinstance
- raise StyleError.new(@name,@lineno,@line,"'#{val[0]}' is not a valid flavor") unless @style == :wmi
- end
- }
- ;
-
- alias_opt
- : /* empty */
- | alias
- ;
-
- superClass_opt
- : /* empty */
- | superClass
- ;
-
- className
- : IDENTIFIER /* must be <schema>_<classname> in CIM v2.x */
- { raise ParseError.new("Class name must be prefixed by '<schema>_'") unless val[0].include?("_") || @style == :wmi }
- ;
-
- alias
- : AS aliasIdentifier
- { result = val[1] }
- ;
-
- aliasIdentifier
- : "$" IDENTIFIER /* NO whitespace ! */
- { result = val[1] }
- ;
-
- superClass
- : ":" className
- { result = val[1] }
- ;
-
-
- propertyDeclaration
- : qualifierList_opt dataType propertyName array_opt defaultValue_opt ";"
- { if val[3]
- type = CIM::Array.new val[3],val[1]
- else
- type = val[1]
- end
- result = CIM::Property.new(type,val[2],val[0],val[4])
- }
- ;
-
- referenceDeclaration
- : qualifierList_opt objectRef referenceName array_opt defaultValue_opt ";"
- { if val[4]
- raise StyleError.new(@name,@lineno,@line,"Array not allowed in reference declaration") unless @style == :wmi
- end
- result = CIM::Reference.new(val[1],val[2],val[0],val[4]) }
- ;
-
- methodDeclaration
- : qualifierList_opt dataType methodName "(" parameterList_opt ")" ";"
- { result = CIM::Method.new(val[1],val[2],val[0],val[4]) }
- ;
-
- propertyName
- : IDENTIFIER
- | PROPERTY
- { # tmplprov.mof has 'string Property;'
- raise StyleError.new(@name,@lineno,@line,"Invalid keyword '#{val[0]}' used for property name") unless @style == :wmi
- }
- ;
-
- referenceName
- : IDENTIFIER
- | INDICATION
- { result = "Indication" }
- ;
-
- methodName
- : IDENTIFIER
- ;
-
- dataType
- : DT_UINT8
- | DT_SINT8
- | DT_UINT16
- | DT_SINT16
- | DT_UINT32
- | DT_SINT32
- | DT_UINT64
- | DT_SINT64
- | DT_REAL32
- | DT_REAL64
- | DT_CHAR16
- | DT_STR
- | DT_BOOLEAN
- | DT_DATETIME
- | DT_VOID
- { raise StyleError.new(@name,@lineno,@line,"'void' is not a valid datatype") unless @style == :wmi }
- ;
-
- objectRef
- : className
- { # WMI uses class names as data types (without REF ?!)
- raise StyleError.new(@name,@lineno,@line,"Expected 'ref' keyword after classname '#{val[0]}'") unless @style == :wmi
- result = CIM::ReferenceType.new val[0]
- }
-
- | className REF
- { result = CIM::ReferenceType.new val[0] }
- ;
-
- parameterList_opt
- : /* empty */
- | parameterList
- ;
-
- parameterList
- : parameter parameters
- { result = val[1].unshift val[0] }
- ;
-
- parameters
- : /* empty */
- { result = [] }
- | parameters "," parameter
- { result = val[0] << val[2] }
- ;
-
- parameter
- : qualifierList_opt typespec parameterName array_opt parameterValue_opt
- { if val[3]
- type = CIM::Array.new val[3], val[1]
- else
- type = val[1]
- end
- result = CIM::Property.new(type,val[2],val[0])
- }
- ;
-
- typespec
- : dataType
- | objectRef
- ;
-
- parameterName
- : IDENTIFIER
- ;
-
- array_opt
- : /* empty */
- | array
- ;
-
- parameterValue_opt
- : /* empty */
- | defaultValue
- { raise "Default parameter value not allowed in syntax style '{@style}'" unless @style == :wmi }
- ;
-
- array
- : "[" positiveDecimalValue_opt "]"
- { result = val[1] }
- ;
-
- positiveDecimalValue_opt
- : /* empty */
- { result = -1 }
- | positiveDecimalValue
- ;
-
- defaultValue_opt
- : /* empty */
- | defaultValue
- ;
-
- defaultValue
- : "=" initializer
- { result = val[1] }
- ;
-
- initializer
- : constantValue
- | arrayInitializer
- | referenceInitializer
- ;
-
- arrayInitializer
- : "{" constantValues "}"
- { result = val[1] }
- ;
-
- constantValues
- : /* empty */
- | constantValue
- { result = [ val[0] ] }
- | constantValues "," constantValue
- { result = val[0] << val[2] }
- ;
-
- constantValue
- : integerValue
- | realValue
- | charValue
- | string
- | booleanValue
- | nullValue
- | instance
- { raise "Instance as property value not allowed in syntax style '{@style}'" unless @style == :wmi }
- ;
-
- integerValue
- : binaryValue
- | octalValue
- | decimalValue
- | positiveDecimalValue
- | hexValue
- ;
-
- string
- : stringValue
- | string stringValue
- { result = val[0] + val[1] }
- ;
-
- referenceInitializer
- : objectHandle
- | aliasIdentifier
- ;
-
- objectHandle
- : namespace_opt modelPath
- ;
-
- namespace_opt
- : /* empty */
- | namespaceHandle ":"
- ;
-
- namespaceHandle
- : IDENTIFIER
- ;
-
- /*
- * Note
- : structure depends on type of namespace
- */
-
- modelPath
- : className "." keyValuePairList
- ;
-
- keyValuePairList
- : keyValuePair keyValuePairs
- ;
-
- keyValuePairs
- : /* empty */
- | keyValuePairs "," keyValuePair
- ;
-
- keyValuePair
- : keyname "=" initializer
- ;
-
- keyname
- : propertyName | referenceName
- ;
-
-/***
- * qualifierDeclaration
- *
- */
-
- qualifierDeclaration
- /* 0 1 2 3 4 */
- : QUALIFIER qualifierName qualifierType scope defaultFlavor_opt ";"
- { result = CIM::QualifierDeclaration.new( val[1], val[2][0], val[2][1], val[3], val[4]) }
- ;
-
- defaultFlavor_opt
- : /* empty */
- | defaultFlavor
- ;
-
- qualifierName
- : IDENTIFIER
- | ASSOCIATION /* meta qualifier */
- | INDICATION /* meta qualifier */
- | REFERENCE /* Added in DSP0004 2.7.0 */
- | SCHEMA
- ;
-
- /* [type, value] */
- qualifierType
- : ":" dataType array_opt defaultValue_opt
- { type = val[2].nil? ? val[1] : CIM::Array.new(val[2],val[1])
- result = [ type, val[3] ]
- }
- ;
-
- scope
- : "," SCOPE "(" metaElements ")"
- { result = CIM::QualifierScopes.new(val[3]) }
- ;
-
- metaElements
- : metaElement
- { result = [ val[0] ] }
- | metaElements "," metaElement
- { result = val[0] << val[2] }
- ;
-
- metaElement
- : SCHEMA
- | CLASS
- | ASSOCIATION
- | INDICATION
- | QUALIFIER
- | PROPERTY
- | REFERENCE
- | METHOD
- | PARAMETER
- | ANY
- ;
-
- defaultFlavor
- : "," FLAVOR "(" flavors ")"
- { result = CIM::QualifierFlavors.new val[3] }
- ;
-
- flavors
- : flavor
- { result = [ val[0] ] }
- | flavors "," flavor
- { result = val[0] << val[2] }
- ;
-
-/***
- * instanceDeclaration
- *
- */
-
- instanceDeclaration
- : instance ";"
- ;
-
- instance
- : qualifierList_opt INSTANCE OF className alias_opt "{" valueInitializers "}"
- ;
-
- valueInitializers
- : valueInitializer
- | valueInitializers valueInitializer
- ;
-
- valueInitializer
- : qualifierList_opt keyname "=" initializer ";"
- | qualifierList_opt keyname ";"
- { raise "Instance property '#{val[1]} must have a value" unless @style == :wmi }
- ;
-
-end # class Parser
-
----- header ----
-
-# parser.rb - generated by racc
-
-require 'strscan'
-require 'rubygems'
-require 'cim'
-require File.join(File.dirname(__FILE__), 'result')
-require File.join(File.dirname(__FILE__), 'scanner')
-require File.join(File.dirname(__FILE__), 'helper')
-
----- inner ----
-
-#
-# Initialize MOF::Parser
-# MOF::Parser.new options = {}
-#
-# options -> Hash of options
-# :debug -> boolean
-# :includes -> array of include dirs
-# :style -> :cim or :wmi
-#
-def initialize options = {}
- @yydebug = options[:debug]
- @includes = options[:includes] || []
- @quiet = options[:quiet]
- @style = options[:style] || :cim # default to style CIM v2.2 syntax
-
- @lineno = 1
- @file = nil
- @iconv = nil
- @eol = "\n"
- @fname = nil
- @fstack = []
- @in_comment = false
- @seen_files = []
- @qualifiers = {}
-end
-
-#
-# Make options hash from argv
-#
-# returns [ files, options ]
-#
-
- def self.argv_handler name, argv
- files = []
- options = { :namespace => "" }
- while argv.size > 0
- case opt = argv.shift
- when "-h"
- $stderr.puts "Ruby MOF compiler"
- $stderr.puts "#{name} [-h] [-d] [-I <dir>] [<moffiles>]"
- $stderr.puts "Compiles <moffile>"
- $stderr.puts "\t-d debug"
- $stderr.puts "\t-h this help"
- $stderr.puts "\t-I <dir> include dir"
- $stderr.puts "\t-f force"
- $stderr.puts "\t-n <namespace>"
- $stderr.puts "\t-o <output>"
- $stderr.puts "\t-s <style> syntax style (wmi,cim)"
- $stderr.puts "\t-q quiet"
- $stderr.puts "\t<moffiles> file(s) to read (else use $stdin)"
- exit 0
- when "-f" then options[:force] = true
- when "-s" then options[:style] = argv.shift.to_sym
- when "-d" then options[:debug] = true
- when "-q" then options[:quiet] = true
- when "-I"
- options[:includes] ||= []
- dirname = argv.shift
- unless File.directory?(dirname)
- files << dirname
- dirname = File.dirname(dirname)
- end
- options[:includes] << Pathname.new(dirname)
- when "-n" then options[:namespace] = argv.shift
- when "-o" then options[:output] = argv.shift
- when /^-.+/
- $stderr.puts "Undefined option #{opt}"
- else
- files << opt
- end
- end
- [ files, options ]
- end
-
-include Helper
-include Scanner
-
----- footer ----
diff --git a/test/racc/assets/namae.y b/test/racc/assets/namae.y
deleted file mode 100644
index 0378345fef..0000000000
--- a/test/racc/assets/namae.y
+++ /dev/null
@@ -1,302 +0,0 @@
-# -*- ruby -*-
-# vi: set ft=ruby :
-
-# Copyright (C) 2012 President and Fellows of Harvard College
-# Copyright (C) 2013-2014 Sylvester Keil
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-# EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and documentation are
-# those of the authors and should not be interpreted as representing official
-# policies, either expressed or implied, of the copyright holder.
-
-class Namae::Parser
-
-token COMMA UWORD LWORD PWORD NICK AND APPELLATION TITLE SUFFIX
-
-expect 0
-
-rule
-
- names : { result = [] }
- | name { result = [val[0]] }
- | names AND name { result = val[0] << val[2] }
-
- name : word { result = Name.new(:given => val[0]) }
- | display_order
- | honorific word { result = val[0].merge(:family => val[1]) }
- | honorific display_order { result = val[1].merge(val[0]) }
- | sort_order
-
- honorific : APPELLATION { result = Name.new(:appellation => val[0]) }
- | TITLE { result = Name.new(:title => val[0]) }
-
- display_order : u_words word opt_suffices opt_titles
- {
- result = Name.new(:given => val[0], :family => val[1],
- :suffix => val[2], :title => val[3])
- }
- | u_words NICK last opt_suffices opt_titles
- {
- result = Name.new(:given => val[0], :nick => val[1],
- :family => val[2], :suffix => val[3], :title => val[4])
- }
- | u_words NICK von last opt_suffices opt_titles
- {
- result = Name.new(:given => val[0], :nick => val[1],
- :particle => val[2], :family => val[3],
- :suffix => val[4], :title => val[5])
- }
- | u_words von last
- {
- result = Name.new(:given => val[0], :particle => val[1],
- :family => val[2])
- }
- | von last
- {
- result = Name.new(:particle => val[0], :family => val[1])
- }
-
- sort_order : last COMMA first
- {
- result = Name.new({ :family => val[0], :suffix => val[2][0],
- :given => val[2][1] }, !!val[2][0])
- }
- | von last COMMA first
- {
- result = Name.new({ :particle => val[0], :family => val[1],
- :suffix => val[3][0], :given => val[3][1] }, !!val[3][0])
- }
- | u_words von last COMMA first
- {
- result = Name.new({ :particle => val[0,2].join(' '), :family => val[2],
- :suffix => val[4][0], :given => val[4][1] }, !!val[4][0])
- }
- ;
-
- von : LWORD
- | von LWORD { result = val.join(' ') }
- | von u_words LWORD { result = val.join(' ') }
-
- last : LWORD | u_words
-
- first : opt_words { result = [nil,val[0]] }
- | words opt_comma suffices { result = [val[2],val[0]] }
- | suffices { result = [val[0],nil] }
- | suffices COMMA words { result = [val[0],val[2]] }
-
- u_words : u_word
- | u_words u_word { result = val.join(' ') }
-
- u_word : UWORD | PWORD
-
- words : word
- | words word { result = val.join(' ') }
-
- opt_comma : /* empty */ | COMMA
- opt_words : /* empty */ | words
-
- word : LWORD | UWORD | PWORD
-
- opt_suffices : /* empty */ | suffices
-
- suffices : SUFFIX
- | suffices SUFFIX { result = val.join(' ') }
-
- opt_titles : /* empty */ | titles
-
- titles : TITLE
- | titles TITLE { result = val.join(' ') }
-
----- header
-require 'singleton'
-require 'strscan'
-
----- inner
-
- include Singleton
-
- attr_reader :options, :input
-
- def initialize
- @input, @options = StringScanner.new(''), {
- :debug => false,
- :prefer_comma_as_separator => false,
- :comma => ',',
- :stops => ',;',
- :separator => /\s*(\band\b|\&|;)\s*/i,
- :title => /\s*\b(sir|lord|count(ess)?|(gen|adm|col|maj|capt|cmdr|lt|sgt|cpl|pvt|prof|dr|md|ph\.?d)\.?)(\s+|$)/i,
- :suffix => /\s*\b(JR|Jr|jr|SR|Sr|sr|[IVX]{2,})(\.|\b)/,
- :appellation => /\s*\b((mrs?|ms|fr|hr)\.?|miss|herr|frau)(\s+|$)/i
- }
- end
-
- def debug?
- options[:debug] || ENV['DEBUG']
- end
-
- def separator
- options[:separator]
- end
-
- def comma
- options[:comma]
- end
-
- def stops
- options[:stops]
- end
-
- def title
- options[:title]
- end
-
- def suffix
- options[:suffix]
- end
-
- def appellation
- options[:appellation]
- end
-
- def prefer_comma_as_separator?
- options[:prefer_comma_as_separator]
- end
-
- def parse(input)
- parse!(input)
- rescue => e
- warn e.message if debug?
- []
- end
-
- def parse!(string)
- input.string = normalize(string)
- reset
- do_parse
- end
-
- def normalize(string)
- string = string.strip
- string
- end
-
- def reset
- @commas, @words, @initials, @suffices, @yydebug = 0, 0, 0, 0, debug?
- self
- end
-
- private
-
- def stack
- @vstack || @racc_vstack || []
- end
-
- def last_token
- stack[-1]
- end
-
- def consume_separator
- return next_token if seen_separator?
- @commas, @words, @initials, @suffices = 0, 0, 0, 0
- [:AND, :AND]
- end
-
- def consume_comma
- @commas += 1
- [:COMMA, :COMMA]
- end
-
- def consume_word(type, word)
- @words += 1
-
- case type
- when :UWORD
- @initials += 1 if word =~ /^[[:upper:]]+\b/
- when :SUFFIX
- @suffices += 1
- end
-
- [type, word]
- end
-
- def seen_separator?
- !stack.empty? && last_token == :AND
- end
-
- def suffix?
- !@suffices.zero? || will_see_suffix?
- end
-
- def will_see_suffix?
- input.peek(8).to_s.strip.split(/\s+/)[0] =~ suffix
- end
-
- def will_see_initial?
- input.peek(6).to_s.strip.split(/\s+/)[0] =~ /^[[:upper:]]+\b/
- end
-
- def seen_full_name?
- prefer_comma_as_separator? && @words > 1 &&
- (@initials > 0 || !will_see_initial?) && !will_see_suffix?
- end
-
- def next_token
- case
- when input.nil?, input.eos?
- nil
- when input.scan(separator)
- consume_separator
- when input.scan(/\s*#{comma}\s*/)
- if @commas.zero? && !seen_full_name? || @commas == 1 && suffix?
- consume_comma
- else
- consume_separator
- end
- when input.scan(/\s+/)
- next_token
- when input.scan(title)
- consume_word(:TITLE, input.matched.strip)
- when input.scan(suffix)
- consume_word(:SUFFIX, input.matched.strip)
- when input.scan(appellation)
- [:APPELLATION, input.matched.strip]
- when input.scan(/((\\\w+)?\{[^\}]*\})*[[:upper:]][^\s#{stops}]*/)
- consume_word(:UWORD, input.matched)
- when input.scan(/((\\\w+)?\{[^\}]*\})*[[:lower:]][^\s#{stops}]*/)
- consume_word(:LWORD, input.matched)
- when input.scan(/(\\\w+)?\{[^\}]*\}[^\s#{stops}]*/)
- consume_word(:PWORD, input.matched)
- when input.scan(/('[^'\n]+')|("[^"\n]+")/)
- consume_word(:NICK, input.matched[1...-1])
- else
- raise ArgumentError,
- "Failed to parse name #{input.string.inspect}: unmatched data at offset #{input.pos}"
- end
- end
-
- def on_error(tid, value, stack)
- raise ArgumentError,
- "Failed to parse name: unexpected '#{value}' at #{stack.inspect}"
- end
-
-# -*- racc -*-
diff --git a/test/racc/assets/nasl.y b/test/racc/assets/nasl.y
deleted file mode 100644
index c7b8e46551..0000000000
--- a/test/racc/assets/nasl.y
+++ /dev/null
@@ -1,626 +0,0 @@
-################################################################################
-# Copyright (c) 2011-2014, Tenable Network Security
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-################################################################################
-
-class Nasl::Grammar
-
-preclow
- right ASS_EQ ADD_EQ SUB_EQ MUL_EQ DIV_EQ MOD_EQ SLL_EQ SRA_EQ SRL_EQ
- left OR
- left AND
- left CMP_LT CMP_GT CMP_EQ CMP_NE CMP_GE CMP_LE SUBSTR_EQ SUBSTR_NE REGEX_EQ REGEX_NE
- left BIT_OR
- left BIT_XOR
- left AMPERSAND
- left BIT_SRA BIT_SRL BIT_SLL
- left ADD SUB
- left MUL DIV MOD
- right NOT
- right UMINUS BIT_NOT
- right EXP
- right INCR DECR
-prechigh
-
-# Tell the parser generator that we don't wish to use the result variable in the
-# action section of rules. Instead, the result of the rule will be the value of
-# evaluating the action block.
-options no_result_var
-
-# Tell the parser generator that we expect one shift/reduce conflict due to the
-# well-known dangling else problem. We could make the grammar solve this
-# problem, but this is how the NASL YACC file solves it, so we'll follow suit.
-expect 1
-
-rule
- ##############################################################################
- # Aggregate Statements
- ##############################################################################
-
- start : roots
- { val[0] }
- | /* Blank */
- { [] }
- ;
-
- roots : root roots
- { [val[0]] + val[1] }
- | root
- { [val[0]] }
- ;
-
- root : COMMENT export
- { c(*val) }
- | export
- { val[0] }
- | COMMENT function
- { c(*val) }
- | function
- { val[0] }
- | statement
- { val[0] }
- ;
-
- statement : simple
- { val[0] }
- | compound
- { val[0] }
- ;
-
- ##############################################################################
- # Root Statements
- ##############################################################################
-
- export : EXPORT function
- { n(:Export, *val) }
- ;
-
- function : FUNCTION ident LPAREN params RPAREN block
- { n(:Function, *val) }
- | FUNCTION ident LPAREN RPAREN block
- { n(:Function, *val) }
- ;
-
- simple : assign
- { val[0] }
- | break
- { val[0] }
- | call
- { val[0] }
- | continue
- { val[0] }
- | decr
- { val[0] }
- | empty
- { val[0] }
- | COMMENT global
- { c(*val) }
- | global
- { val[0] }
- | import
- { val[0] }
- | include
- { val[0] }
- | incr
- { val[0] }
- | local
- { val[0] }
- | rep
- { val[0] }
- | return
- { val[0] }
- ;
-
- compound : block
- { val[0] }
- | for
- { val[0] }
- | foreach
- { val[0] }
- | if
- { val[0] }
- | repeat
- { val[0] }
- | while
- { val[0] }
- ;
-
- ##############################################################################
- # Simple Statements
- ##############################################################################
-
- assign : assign_exp SEMICOLON
- { val[0] }
- ;
-
- break : BREAK SEMICOLON
- { n(:Break, *val) }
- ;
-
- call : call_exp SEMICOLON
- { val[0] }
- ;
-
- continue : CONTINUE SEMICOLON
- { n(:Continue, *val) }
- ;
-
- decr : decr_exp SEMICOLON
- { val[0] }
- ;
-
- empty : SEMICOLON
- { n(:Empty, *val) }
- ;
-
- global : GLOBAL var_decls SEMICOLON
- { n(:Global, *val) }
- ;
-
- incr : incr_exp SEMICOLON
- { val[0] }
- ;
-
- import : IMPORT LPAREN string RPAREN SEMICOLON
- { n(:Import, *val) }
- ;
-
- include : INCLUDE LPAREN string RPAREN SEMICOLON
- { n(:Include, *val) }
- ;
-
- local : LOCAL var_decls SEMICOLON
- { n(:Local, *val) }
- ;
-
- rep : call_exp REP expr SEMICOLON
- { n(:Repetition, *val[0..-1]) }
- ;
-
- return : RETURN expr SEMICOLON
- { n(:Return, *val) }
- | RETURN ref SEMICOLON
- { n(:Return, *val) }
- | RETURN SEMICOLON
- { n(:Return, *val) }
- ;
-
- ##############################################################################
- # Compound Statements
- ##############################################################################
-
- block : LBRACE statements RBRACE
- { n(:Block, *val) }
- | LBRACE RBRACE
- { n(:Block, *val) }
- ;
-
- for : FOR LPAREN field SEMICOLON expr SEMICOLON field RPAREN statement
- { n(:For, *val) }
- ;
-
- foreach : FOREACH ident LPAREN expr RPAREN statement
- { n(:Foreach, val[0], val[1], val[3], val[5]) }
- | FOREACH LPAREN ident IN expr RPAREN statement
- { n(:Foreach, val[0], val[2], val[4], val[6]) }
- ;
-
- if : IF LPAREN expr RPAREN statement
- { n(:If, *val) }
- | IF LPAREN expr RPAREN statement ELSE statement
- { n(:If, *val) }
- ;
-
- repeat : REPEAT statement UNTIL expr SEMICOLON
- { n(:Repeat, *val) }
- ;
-
- while : WHILE LPAREN expr RPAREN statement
- { n(:While, *val) }
- ;
-
- ##############################################################################
- # Expressions
- ##############################################################################
-
- assign_exp : lval ASS_EQ expr
- { n(:Assignment, *val) }
- | lval ASS_EQ ref
- { n(:Assignment, *val) }
- | lval ADD_EQ expr
- { n(:Assignment, *val) }
- | lval SUB_EQ expr
- { n(:Assignment, *val) }
- | lval MUL_EQ expr
- { n(:Assignment, *val) }
- | lval DIV_EQ expr
- { n(:Assignment, *val) }
- | lval MOD_EQ expr
- { n(:Assignment, *val) }
- | lval SRL_EQ expr
- { n(:Assignment, *val) }
- | lval SRA_EQ expr
- { n(:Assignment, *val) }
- | lval SLL_EQ expr
- { n(:Assignment, *val) }
- ;
-
- call_exp : lval LPAREN args RPAREN
- { n(:Call, *val) }
- | lval LPAREN RPAREN
- { n(:Call, *val) }
- ;
-
- decr_exp : DECR lval
- { n(:Decrement, val[0]) }
- | lval DECR
- { n(:Decrement, val[0]) }
- ;
-
- incr_exp : INCR lval
- { n(:Increment, val[0]) }
- | lval INCR
- { n(:Increment, val[0]) }
- ;
-
- expr : LPAREN expr RPAREN
- { n(:Expression, *val) }
- | expr AND expr
- { n(:Expression, *val) }
- | NOT expr
- { n(:Expression, *val) }
- | expr OR expr
- { n(:Expression, *val) }
- | expr ADD expr
- { n(:Expression, *val) }
- | expr SUB expr
- { n(:Expression, *val) }
- | SUB expr =UMINUS
- { n(:Expression, *val) }
- | BIT_NOT expr
- { n(:Expression, *val) }
- | expr MUL expr
- { n(:Expression, *val) }
- | expr EXP expr
- { n(:Expression, *val) }
- | expr DIV expr
- { n(:Expression, *val) }
- | expr MOD expr
- { n(:Expression, *val) }
- | expr AMPERSAND expr
- { n(:Expression, *val) }
- | expr BIT_XOR expr
- { n(:Expression, *val) }
- | expr BIT_OR expr
- { n(:Expression, *val) }
- | expr BIT_SRA expr
- { n(:Expression, *val) }
- | expr BIT_SRL expr
- { n(:Expression, *val) }
- | expr BIT_SLL expr
- { n(:Expression, *val) }
- | incr_exp
- { val[0] }
- | decr_exp
- { val[0] }
- | expr SUBSTR_EQ expr
- { n(:Expression, *val) }
- | expr SUBSTR_NE expr
- { n(:Expression, *val) }
- | expr REGEX_EQ expr
- { n(:Expression, *val) }
- | expr REGEX_NE expr
- { n(:Expression, *val) }
- | expr CMP_LT expr
- { n(:Expression, *val) }
- | expr CMP_GT expr
- { n(:Expression, *val) }
- | expr CMP_EQ expr
- { n(:Expression, *val) }
- | expr CMP_NE expr
- { n(:Expression, *val) }
- | expr CMP_GE expr
- { n(:Expression, *val) }
- | expr CMP_LE expr
- { n(:Expression, *val) }
- | assign_exp
- { val[0] }
- | string
- { val[0] }
- | call_exp
- { val[0] }
- | lval
- { val[0] }
- | ip
- { val[0] }
- | int
- { val[0] }
- | undef
- { val[0] }
- | list_expr
- { val[0] }
- | array_expr
- { val[0] }
- ;
-
- ##############################################################################
- # Named Components
- ##############################################################################
-
- arg : ident COLON expr
- { n(:Argument, *val) }
- | ident COLON ref
- { n(:Argument, *val) }
- | expr
- { n(:Argument, *val) }
- | ref
- { n(:Argument, *val) }
- ;
-
- kv_pair : string COLON expr
- { n(:KeyValuePair, *val) }
- | int COLON expr
- { n(:KeyValuePair, *val) }
- | ident COLON expr
- { n(:KeyValuePair, *val) }
- | string COLON ref
- { n(:KeyValuePair, *val) }
- | int COLON ref
- { n(:KeyValuePair, *val) }
- | ident COLON ref
- { n(:KeyValuePair, *val) }
- ;
-
- kv_pairs : kv_pair COMMA kv_pairs
- { [val[0]] + val[2] }
- | kv_pair COMMA
- { [val[0]] }
- | kv_pair
- { [val[0]] }
- ;
-
- lval : ident indexes
- { n(:Lvalue, *val) }
- | ident
- { n(:Lvalue, *val) }
- ;
-
- ref : AT_SIGN ident
- { n(:Reference, val[1]) }
- ;
-
- ##############################################################################
- # Anonymous Components
- ##############################################################################
-
- args : arg COMMA args
- { [val[0]] + val[2] }
- | arg
- { [val[0]] }
- ;
-
- array_expr : LBRACE kv_pairs RBRACE
- { n(:Array, *val) }
- | LBRACE RBRACE
- { n(:Array, *val) }
- ;
-
- field : assign_exp
- { val[0] }
- | call_exp
- { val[0] }
- | decr_exp
- { val[0] }
- | incr_exp
- { val[0] }
- | /* Blank */
- { nil }
- ;
-
- index : LBRACK expr RBRACK
- { val[1] }
- | PERIOD ident
- { val[1] }
- ;
-
- indexes : index indexes
- { [val[0]] + val[1] }
- | index
- { [val[0]] }
- ;
-
- list_elem : expr
- { val[0] }
- | ref
- { val[0] }
- ;
-
- list_elems : list_elem COMMA list_elems
- { [val[0]] + val[2] }
- | list_elem
- { [val[0]] }
- ;
-
- list_expr : LBRACK list_elems RBRACK
- { n(:List, *val) }
- | LBRACK RBRACK
- { n(:List, *val) }
- ;
-
- param : AMPERSAND ident
- { n(:Parameter, val[1], 'reference') }
- | ident
- { n(:Parameter, val[0], 'value') }
- ;
-
- params : param COMMA params
- { [val[0]] + val[2] }
- | param
- { [val[0]] }
- ;
-
- statements : statement statements
- { [val[0]] + val[1] }
- | statement
- { [val[0]] }
- ;
-
- var_decl : ident ASS_EQ expr
- { n(:Assignment, *val) }
- | ident ASS_EQ ref
- { n(:Assignment, *val) }
- | ident
- { val[0] }
- ;
-
- var_decls : var_decl COMMA var_decls
- { [val[0]] + val[2] }
- | var_decl
- { [val[0]] }
- ;
-
- ##############################################################################
- # Literals
- ##############################################################################
-
- ident : IDENT
- { n(:Identifier, *val) }
- | REP
- { n(:Identifier, *val) }
- | IN
- { n(:Identifier, *val) }
- ;
-
- int : INT_DEC
- { n(:Integer, *val) }
- | INT_HEX
- { n(:Integer, *val) }
- | INT_OCT
- { n(:Integer, *val) }
- | FALSE
- { n(:Integer, *val) }
- | TRUE
- { n(:Integer, *val) }
- ;
-
- ip : int PERIOD int PERIOD int PERIOD int
- { n(:Ip, *val) }
-
- string : DATA
- { n(:String, *val) }
- | STRING
- { n(:String, *val) }
- ;
-
- undef : UNDEF
- { n(:Undefined, *val) }
- ;
-end
-
----- header ----
-
-require 'nasl/parser/tree'
-
-require 'nasl/parser/argument'
-require 'nasl/parser/array'
-require 'nasl/parser/assigment'
-require 'nasl/parser/block'
-require 'nasl/parser/break'
-require 'nasl/parser/call'
-require 'nasl/parser/comment'
-require 'nasl/parser/continue'
-require 'nasl/parser/decrement'
-require 'nasl/parser/empty'
-require 'nasl/parser/export'
-require 'nasl/parser/expression'
-require 'nasl/parser/for'
-require 'nasl/parser/foreach'
-require 'nasl/parser/function'
-require 'nasl/parser/global'
-require 'nasl/parser/identifier'
-require 'nasl/parser/if'
-require 'nasl/parser/import'
-require 'nasl/parser/include'
-require 'nasl/parser/increment'
-require 'nasl/parser/integer'
-require 'nasl/parser/ip'
-require 'nasl/parser/key_value_pair'
-require 'nasl/parser/list'
-require 'nasl/parser/local'
-require 'nasl/parser/lvalue'
-require 'nasl/parser/parameter'
-require 'nasl/parser/reference'
-require 'nasl/parser/repeat'
-require 'nasl/parser/repetition'
-require 'nasl/parser/return'
-require 'nasl/parser/string'
-require 'nasl/parser/undefined'
-require 'nasl/parser/while'
-
----- inner ----
-
-def n(cls, *args)
- begin
- Nasl.const_get(cls).new(@tree, *args)
- rescue
- puts "An exception occurred during the creation of a #{cls} instance."
- puts
- puts "The arguments passed to the constructor were:"
- puts args
- puts
- puts @tok.last.context
- puts
- raise
- end
-end
-
-def c(*args)
- n(:Comment, *args)
- args[1]
-end
-
-def on_error(type, value, stack)
- raise ParseException, "The language's grammar does not permit #{value.name} to appear here", value.context
-end
-
-def next_token
- @tok = @tkz.get_token
-
- if @first && @tok.first == :COMMENT
- n(:Comment, @tok.last)
- @tok = @tkz.get_token
- end
- @first = false
-
- return @tok
-end
-
-def parse(env, code, path)
- @first = true
- @tree = Tree.new(env)
- @tkz = Tokenizer.new(code, path)
- @tree.concat(do_parse)
-end
-
----- footer ----
diff --git a/test/racc/assets/newsyn.y b/test/racc/assets/newsyn.y
deleted file mode 100644
index 5b670c966a..0000000000
--- a/test/racc/assets/newsyn.y
+++ /dev/null
@@ -1,25 +0,0 @@
-
-class A
-
- preclow
- left preclow prechigh right left nonassoc token
- right preclow prechigh right left nonassoc token
- nonassoc preclow prechigh right left nonassoc token
- prechigh
-
- convert
- left 'a'
- right 'b'
- preclow 'c'
- nonassoc 'd'
- preclow 'e'
- prechigh 'f'
- end
-
-rule
-
- left: right nonassoc preclow prechigh
-
- right: A B C
-
-end
diff --git a/test/racc/assets/noend.y b/test/racc/assets/noend.y
deleted file mode 100644
index 5aa0670be0..0000000000
--- a/test/racc/assets/noend.y
+++ /dev/null
@@ -1,4 +0,0 @@
-class MyParser
-rule
-input: A B C
-end
diff --git a/test/racc/assets/nokogiri-css.y b/test/racc/assets/nokogiri-css.y
deleted file mode 100644
index 24dfbf3b1b..0000000000
--- a/test/racc/assets/nokogiri-css.y
+++ /dev/null
@@ -1,255 +0,0 @@
-class Nokogiri::CSS::Parser
-
-token FUNCTION INCLUDES DASHMATCH LBRACE HASH PLUS GREATER S STRING IDENT
-token COMMA NUMBER PREFIXMATCH SUFFIXMATCH SUBSTRINGMATCH TILDE NOT_EQUAL
-token SLASH DOUBLESLASH NOT EQUAL RPAREN LSQUARE RSQUARE HAS
-
-rule
- selector
- : selector COMMA simple_selector_1toN {
- result = [val.first, val.last].flatten
- }
- | prefixless_combinator_selector { result = val.flatten }
- | optional_S simple_selector_1toN { result = [val.last].flatten }
- ;
- combinator
- : PLUS { result = :DIRECT_ADJACENT_SELECTOR }
- | GREATER { result = :CHILD_SELECTOR }
- | TILDE { result = :FOLLOWING_SELECTOR }
- | DOUBLESLASH { result = :DESCENDANT_SELECTOR }
- | SLASH { result = :CHILD_SELECTOR }
- ;
- simple_selector
- : element_name hcap_0toN {
- result = if val[1].nil?
- val.first
- else
- Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
- end
- }
- | function
- | function pseudo {
- result = Node.new(:CONDITIONAL_SELECTOR, val)
- }
- | function attrib {
- result = Node.new(:CONDITIONAL_SELECTOR, val)
- }
- | hcap_1toN {
- result = Node.new(:CONDITIONAL_SELECTOR,
- [Node.new(:ELEMENT_NAME, ['*']), val.first]
- )
- }
- ;
- prefixless_combinator_selector
- : combinator simple_selector_1toN {
- result = Node.new(val.first, [nil, val.last])
- }
- ;
- simple_selector_1toN
- : simple_selector combinator simple_selector_1toN {
- result = Node.new(val[1], [val.first, val.last])
- }
- | simple_selector S simple_selector_1toN {
- result = Node.new(:DESCENDANT_SELECTOR, [val.first, val.last])
- }
- | simple_selector
- ;
- class
- : '.' IDENT { result = Node.new(:CLASS_CONDITION, [val[1]]) }
- ;
- element_name
- : namespaced_ident
- | '*' { result = Node.new(:ELEMENT_NAME, val) }
- ;
- namespaced_ident
- : namespace '|' IDENT {
- result = Node.new(:ELEMENT_NAME,
- [[val.first, val.last].compact.join(':')]
- )
- }
- | IDENT {
- name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
- result = Node.new(:ELEMENT_NAME, [name])
- }
- ;
- namespace
- : IDENT { result = val[0] }
- |
- ;
- attrib
- : LSQUARE attrib_name attrib_val_0or1 RSQUARE {
- result = Node.new(:ATTRIBUTE_CONDITION,
- [val[1]] + (val[2] || [])
- )
- }
- | LSQUARE function attrib_val_0or1 RSQUARE {
- result = Node.new(:ATTRIBUTE_CONDITION,
- [val[1]] + (val[2] || [])
- )
- }
- | LSQUARE NUMBER RSQUARE {
- # Non standard, but hpricot supports it.
- result = Node.new(:PSEUDO_CLASS,
- [Node.new(:FUNCTION, ['nth-child(', val[1]])]
- )
- }
- ;
- attrib_name
- : namespace '|' IDENT {
- result = Node.new(:ELEMENT_NAME,
- [[val.first, val.last].compact.join(':')]
- )
- }
- | IDENT {
- # Default namespace is not applied to attributes.
- # So we don't add prefix "xmlns:" as in namespaced_ident.
- result = Node.new(:ELEMENT_NAME, [val.first])
- }
- ;
- function
- : FUNCTION RPAREN {
- result = Node.new(:FUNCTION, [val.first.strip])
- }
- | FUNCTION expr RPAREN {
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
- }
- | FUNCTION nth RPAREN {
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
- }
- | NOT expr RPAREN {
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
- }
- | HAS selector RPAREN {
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
- }
- ;
- expr
- : NUMBER COMMA expr { result = [val.first, val.last] }
- | STRING COMMA expr { result = [val.first, val.last] }
- | IDENT COMMA expr { result = [val.first, val.last] }
- | NUMBER
- | STRING
- | IDENT # even, odd
- {
- case val[0]
- when 'even'
- result = Node.new(:NTH, ['2','n','+','0'])
- when 'odd'
- result = Node.new(:NTH, ['2','n','+','1'])
- when 'n'
- result = Node.new(:NTH, ['1','n','+','0'])
- else
- # This is not CSS standard. It allows us to support this:
- # assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
- # assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
- # assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
- result = val
- end
- }
- ;
- nth
- : NUMBER IDENT PLUS NUMBER # 5n+3 -5n+3
- {
- if val[1] == 'n'
- result = Node.new(:NTH, val)
- else
- raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
- end
- }
- | IDENT PLUS NUMBER { # n+3, -n+3
- if val[0] == 'n'
- val.unshift("1")
- result = Node.new(:NTH, val)
- elsif val[0] == '-n'
- val[0] = 'n'
- val.unshift("-1")
- result = Node.new(:NTH, val)
- else
- raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
- end
- }
- | NUMBER IDENT { # 5n, -5n, 10n-1
- n = val[1]
- if n[0, 2] == 'n-'
- val[1] = 'n'
- val << "-"
- # b is contained in n as n is the string "n-b"
- val << n[2, n.size]
- result = Node.new(:NTH, val)
- elsif n == 'n'
- val << "+"
- val << "0"
- result = Node.new(:NTH, val)
- else
- raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
- end
- }
- ;
- pseudo
- : ':' function {
- result = Node.new(:PSEUDO_CLASS, [val[1]])
- }
- | ':' IDENT { result = Node.new(:PSEUDO_CLASS, [val[1]]) }
- ;
- hcap_0toN
- : hcap_1toN
- |
- ;
- hcap_1toN
- : attribute_id hcap_1toN {
- result = Node.new(:COMBINATOR, val)
- }
- | class hcap_1toN {
- result = Node.new(:COMBINATOR, val)
- }
- | attrib hcap_1toN {
- result = Node.new(:COMBINATOR, val)
- }
- | pseudo hcap_1toN {
- result = Node.new(:COMBINATOR, val)
- }
- | negation hcap_1toN {
- result = Node.new(:COMBINATOR, val)
- }
- | attribute_id
- | class
- | attrib
- | pseudo
- | negation
- ;
- attribute_id
- : HASH { result = Node.new(:ID, val) }
- ;
- attrib_val_0or1
- : eql_incl_dash IDENT { result = [val.first, val[1]] }
- | eql_incl_dash STRING { result = [val.first, val[1]] }
- |
- ;
- eql_incl_dash
- : EQUAL { result = :equal }
- | PREFIXMATCH { result = :prefix_match }
- | SUFFIXMATCH { result = :suffix_match }
- | SUBSTRINGMATCH { result = :substring_match }
- | NOT_EQUAL { result = :not_equal }
- | INCLUDES { result = :includes }
- | DASHMATCH { result = :dash_match }
- ;
- negation
- : NOT negation_arg RPAREN {
- result = Node.new(:NOT, [val[1]])
- }
- ;
- negation_arg
- : element_name
- | element_name hcap_1toN
- | hcap_1toN
- ;
- optional_S
- : S
- |
- ;
-end
-
----- header
-
-require 'nokogiri/css/parser_extras'
diff --git a/test/racc/assets/nonass.y b/test/racc/assets/nonass.y
deleted file mode 100644
index b9a35a2626..0000000000
--- a/test/racc/assets/nonass.y
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# nonassoc test
-#
-
-class P
-
-preclow
- nonassoc N
- left P
-prechigh
-
-rule
-
-target : exp
-exp : exp N exp
- | exp P exp
- | T
-
-end
-
----- inner
-
- def parse
- @src = [[:T,'T'], [:N,'N'], [:T,'T'], [:N,'N'], [:T,'T']]
- do_parse
- end
-
- def next_token
- @src.shift
- end
-
----- footer
-
-begin
- P.new.parse
-rescue ParseError
- exit 0
-else
- $stderr.puts 'parse error not raised: nonassoc not work'
- exit 1
-end
diff --git a/test/racc/assets/normal.y b/test/racc/assets/normal.y
deleted file mode 100644
index 96ae352c82..0000000000
--- a/test/racc/assets/normal.y
+++ /dev/null
@@ -1,27 +0,0 @@
-
-class Testp
-
- convert
- A '2'
- B '3'
- end
-
- prechigh
- left B
- preclow
-
-rule
-
-/* comment */
- target: A B C nonterminal { action "string" == /regexp/o
- 1 /= 3 }
- ; # comment
-
- nonterminal: A '+' B = A;
-
-/* end */
-end
-
----- driver
-
- # driver is old name
diff --git a/test/racc/assets/norule.y b/test/racc/assets/norule.y
deleted file mode 100644
index e50a4b3472..0000000000
--- a/test/racc/assets/norule.y
+++ /dev/null
@@ -1,4 +0,0 @@
-
-class A
-rule
-end
diff --git a/test/racc/assets/nullbug1.y b/test/racc/assets/nullbug1.y
deleted file mode 100644
index 4b267ba0ea..0000000000
--- a/test/racc/assets/nullbug1.y
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# number of conflicts must be ZERO.
-#
-
-class T
-
-rule
-
-targ : dummy
- | a b c
-
-dummy : V v
-
-V : E e
- | F f
- |
- ;
-
-E :
- ;
-
-F :
- ;
-
-end
diff --git a/test/racc/assets/nullbug2.y b/test/racc/assets/nullbug2.y
deleted file mode 100644
index 0c1d43bf3e..0000000000
--- a/test/racc/assets/nullbug2.y
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# number of conflicts must be ZERO.
-#
-
-class A
-rule
- targ: operation voidhead
- | variable
-
- voidhead : void B
- void:
-
- operation: A
- variable : A
-end
diff --git a/test/racc/assets/opal.y b/test/racc/assets/opal.y
deleted file mode 100644
index ae6a5a6bdd..0000000000
--- a/test/racc/assets/opal.y
+++ /dev/null
@@ -1,1807 +0,0 @@
-# Copyright (C) 2013 by Adam Beynon
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-
-class Opal::Parser
-
-token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
- tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
- tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP
- tOROP tMATCH tNMATCH tJSDOT tDOT tDOT2 tDOT3 tAREF tASET tLSHFT tRSHFT
- tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN tLPAREN2 tRPAREN tLPAREN_ARG
- ARRAY_BEG tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2
- tTILDE tPERCENT tDIVIDE tPLUS tMINUS tLT tGT tPIPE tBANG tCARET
- tLCURLY tRCURLY tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
- tWORDS_BEG tAWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END tSTRING
- tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG
- tLBRACK2 tLBRACK tJSLBRACK tDSTAR
-
-prechigh
- right tBANG tTILDE tUPLUS
- right tPOW
- right tUMINUS_NUM tUMINUS
- left tSTAR2 tDIVIDE tPERCENT
- left tPLUS tMINUS
- left tLSHFT tRSHFT
- left tAMPER2
- left tPIPE tCARET
- left tGT tGEQ tLT tLEQ
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
- left tANDOP
- left tOROP
- nonassoc tDOT2 tDOT3
- right tEH tCOLON
- left kRESCUE_MOD
- right tEQL tOP_ASGN
- nonassoc kDEFINED
- right kNOT
- left kOR kAND
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
- nonassoc tLBRACE_ARG
- nonassoc tLOWEST
-preclow
-
-rule
-
- program: top_compstmt
-
- top_compstmt: top_stmts opt_terms
- {
- result = new_compstmt val[0]
- }
-
- top_stmts: # none
- {
- result = new_block
- }
- | top_stmt
- {
- result = new_block val[0]
- }
- | top_stmts terms top_stmt
- {
- val[0] << val[2]
- result = val[0]
- }
-
- top_stmt: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- result = val[2]
- }
-
- bodystmt: compstmt opt_rescue opt_else opt_ensure
- {
- result = new_body(val[0], val[1], val[2], val[3])
- }
-
- compstmt: stmts opt_terms
- {
- result = new_compstmt val[0]
- }
-
- stmts: # none
- {
- result = new_block
- }
- | stmt
- {
- result = new_block val[0]
- }
- | stmts terms stmt
- {
- val[0] << val[2]
- result = val[0]
- }
-
- stmt: kALIAS fitem
- {
- lexer.lex_state = :expr_fname
- }
- fitem
- {
- result = new_alias(val[0], val[1], val[3])
- }
- | kALIAS tGVAR tGVAR
- {
- result = s(:valias, value(val[1]).to_sym, value(val[2]).to_sym)
- }
- | kALIAS tGVAR tBACK_REF
- | kALIAS tGVAR tNTH_REF
- {
- result = s(:valias, value(val[1]).to_sym, value(val[2]).to_sym)
- }
- | kUNDEF undef_list
- {
- result = val[1]
- }
- | stmt kIF_MOD expr_value
- {
- result = new_if(val[1], val[2], val[0], nil)
- }
- | stmt kUNLESS_MOD expr_value
- {
- result = new_if(val[1], val[2], nil, val[0])
- }
- | stmt kWHILE_MOD expr_value
- {
- result = new_while(val[1], val[2], val[0])
- }
- | stmt kUNTIL_MOD expr_value
- {
- result = new_until(val[1], val[2], val[0])
- }
- | stmt kRESCUE_MOD stmt
- {
- result = new_rescue_mod(val[1], val[0], val[2])
- }
- | klEND tLCURLY compstmt tRCURLY
- | lhs tEQL command_call
- {
- result = new_assign(val[0], val[1], val[2])
- }
- | mlhs tEQL command_call
- {
- result = s(:masgn, val[0], s(:to_ary, val[2]))
- }
- | var_lhs tOP_ASGN command_call
- {
- result = new_op_asgn val[1], val[0], val[2]
- }
- | primary_value tLBRACK2 aref_args tRBRACK tOP_ASGN command_call
- | primary_value tJSLBRACK aref_args tRBRACK tOP_ASGN command_call
- | primary_value tDOT tIDENTIFIER tOP_ASGN command_call
- {
- result = s(:op_asgn2, val[0], op_to_setter(val[2]), value(val[3]).to_sym, val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN command_call
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
- | backref tOP_ASGN command_call
- | lhs tEQL mrhs
- {
- result = new_assign val[0], val[1], s(:svalue, val[2])
- }
- | mlhs tEQL arg_value
- {
- result = s(:masgn, val[0], s(:to_ary, val[2]))
- }
- | mlhs tEQL mrhs
- {
- result = s(:masgn, val[0], val[2])
- }
- | expr
-
- expr: command_call
- | expr kAND expr
- {
- result = s(:and, val[0], val[2])
- }
- | expr kOR expr
- {
- result = s(:or, val[0], val[2])
- }
- | kNOT expr
- {
- result = new_unary_call(['!', []], val[1])
- }
- | tBANG command_call
- {
- result = new_unary_call(val[0], val[1])
- }
- | arg
-
- expr_value: expr
-
- command_call: command
- | block_command
- | kRETURN call_args
- {
- result = new_return(val[0], val[1])
- }
- | kBREAK call_args
- {
- result = new_break(val[0], val[1])
- }
- | kNEXT call_args
- {
- result = new_next(val[0], val[1])
- }
-
- block_command: block_call
- | block_call tJSDOT operation2 command_args
- | block_call tDOT operation2 command_args
- | block_call tCOLON2 operation2 command_args
-
- cmd_brace_block: tLBRACE_ARG opt_block_var compstmt tRCURLY
-
- command: operation command_args =tLOWEST
- {
- result = new_call(nil, val[0], val[1])
- }
- | operation command_args cmd_brace_block
- | primary_value tJSDOT operation2 command_args =tLOWEST
- {
- result = new_js_call(val[0], val[2], val[3])
- }
- | primary_value tJSDOT operation2 command_args cmd_brace_block
- | primary_value tDOT operation2 command_args =tLOWEST
- {
- result = new_call(val[0], val[2], val[3])
- }
- | primary_value tDOT operation2 command_args cmd_brace_block
- | primary_value tCOLON2 operation2 command_args =tLOWEST
- {
- result = new_call(val[0], val[2], val[3])
- }
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
- | kSUPER command_args
- {
- result = new_super(val[0], val[1])
- }
- | kYIELD command_args
- {
- result = new_yield val[1]
- }
-
- mlhs: mlhs_basic
- {
- result = val[0]
- }
- | tLPAREN mlhs_entry tRPAREN
- {
- result = val[1]
- }
-
- mlhs_entry: mlhs_basic
- {
- result = val[0]
- }
- | tLPAREN mlhs_entry tRPAREN
- {
- result = val[1]
- }
-
- mlhs_basic: mlhs_head
- {
- result = val[0]
- }
- | mlhs_head mlhs_item
- {
- result = val[0] << val[1]
- }
- | mlhs_head tSTAR mlhs_node
- {
- result = val[0] << s(:splat, val[2])
- }
- | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
- | mlhs_head tSTAR
- {
- result = val[0] << s(:splat)
- }
- | mlhs_head tSTAR tCOMMA mlhs_post
- | tSTAR mlhs_node
- {
- result = s(:array, s(:splat, val[1]))
- }
- | tSTAR
- {
- result = s(:array, s(:splat))
- }
- | tSTAR tCOMMA mlhs_post
-
- mlhs_item: mlhs_node
- {
- result = val[0]
- }
- | tLPAREN mlhs_entry tRPAREN
- {
- result = val[1]
- }
-
- mlhs_head: mlhs_item tCOMMA
- {
- result = s(:array, val[0])
- }
- | mlhs_head mlhs_item tCOMMA
- {
- result = val[0] << val[1]
- }
-
- mlhs_post: mlhs_item
- | mlhs_post tCOMMA mlhs_item
-
- mlhs_node: variable
- {
- result = new_assignable val[0]
- }
- | primary_value tLBRACK2 aref_args tRBRACK
- {
- args = val[2] ? val[2] : []
- result = s(:attrasgn, val[0], :[]=, s(:arglist, *args))
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = new_call val[0], val[2], []
- }
- | primary_value tCOLON2 tIDENTIFIER
- | primary_value tDOT tCONSTANT
- | primary_value tCOLON2 tCONSTANT
- | tCOLON3 tCONSTANT
- | backref
-
- lhs: variable
- {
- result = new_assignable val[0]
- }
- | primary_value tJSLBRACK aref_args tRBRACK
- {
- result = new_js_attrasgn(val[0], val[2])
- }
- | primary_value tLBRACK2 aref_args tRBRACK
- {
- result = new_attrasgn(val[0], :[]=, val[2])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = new_attrasgn(val[0], op_to_setter(val[2]))
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = new_attrasgn(val[0], op_to_setter(val[2]))
- }
- | primary_value tDOT tCONSTANT
- {
- result = new_attrasgn(val[0], op_to_setter(val[2]))
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = new_colon2(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = new_colon3(val[0], val[1])
- }
- | backref
-
- cname: tCONSTANT
-
- cpath: tCOLON3 cname
- {
- result = new_colon3(val[0], val[1])
- }
- | cname
- {
- result = new_const(val[0])
- }
- | primary_value tCOLON2 cname
- {
- result = new_colon2(val[0], val[1], val[2])
- }
-
- fname: tIDENTIFIER
- | tCONSTANT
- | tFID
- | op
- {
- lexer.lex_state = :expr_end
- result = val[0]
- }
- | reswords
- {
- lexer.lex_state = :expr_end
- result = val[0]
- }
-
- fitem: fname
- {
- result = new_sym(val[0])
- }
- | symbol
-
- undef_list: fitem
- {
- result = s(:undef, val[0])
- }
- | undef_list tCOMMA fitem
- {
- result = val[0] << val[2]
- }
-
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
- | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
- | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
- | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
-
- reswords: k__LINE__ | k__FILE__ | klBEGIN | klEND | kALIAS | kAND
- | kBEGIN | kBREAK | kCASE | kCLASS | kDEF | kDEFINED
- | kDO | kELSE | kELSIF | kEND | kENSURE | kFALSE
- | kFOR | kIN | kMODULE | kNEXT | kNIL | kNOT
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF
- | kSUPER | kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD
- | kIF_MOD | kUNLESS_MOD | kWHILE_MOD | kUNTIL_MOD | kRESCUE_MOD
- | kIF | kWHILE | kUNTIL | kUNLESS
-
- arg: lhs tEQL arg
- {
- result = new_assign(val[0], val[1], val[2])
- }
- | lhs tEQL arg kRESCUE_MOD arg
- {
- result = new_assign val[0], val[1], s(:rescue_mod, val[2], val[4])
- }
- | var_lhs tOP_ASGN arg
- {
- result = new_op_asgn val[1], val[0], val[2]
- }
- | primary_value tLBRACK2 aref_args tRBRACK tOP_ASGN arg
- {
- result = new_op_asgn1(val[0], val[2], val[4], val[5])
- }
- | primary_value tJSLBRACK aref_args tRBRACK tOP_ASGN arg
- {
- raise ".JS[...] #{val[4]} is not supported"
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN arg
- {
- result = s(:op_asgn2, val[0], op_to_setter(val[2]), value(val[3]).to_sym, val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN arg
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
- | tCOLON3 tCONSTANT tOP_ASGN arg
- | backref tOP_ASGN arg
- | arg tDOT2 arg
- {
- result = new_irange(val[0], val[1], val[2])
- }
- | arg tDOT3 arg
- {
- result = new_erange(val[0], val[1], val[2])
- }
- | arg tPLUS arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tMINUS arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tSTAR2 arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tDIVIDE arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tPERCENT arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tPOW arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | '-@NUM' tINTEGER tPOW arg
- {
- result = new_call new_binary_call(new_int(val[1]), val[2], val[3]), [:"-@", []], []
- }
- | '-@NUM' tFLOAT tPOW arg
- {
- result = new_call new_binary_call(new_float(val[1]), val[2], val[3]), [:"-@", []], []
- }
- | tUPLUS arg
- {
- result = new_call val[1], [:"+@", []], []
- if [:int, :float].include? val[1].type
- result = val[1]
- end
- }
- | tUMINUS arg
- {
- result = new_call val[1], [:"-@", []], []
- if val[1].type == :int
- val[1][1] = -val[1][1]
- result = val[1]
- elsif val[1].type == :float
- val[1][1] = -val[1][1].to_f
- result = val[1]
- end
- }
- | arg tPIPE arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tCARET arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tAMPER2 arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tCMP arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tGT arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tGEQ arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tLT arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tLEQ arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tEQ arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tEQQ arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tNEQ arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tMATCH arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tNMATCH arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | tBANG arg
- {
- result = new_unary_call(val[0], val[1])
- }
- | tTILDE arg
- {
- result = new_unary_call(val[0], val[1])
- }
- | arg tLSHFT arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tRSHFT arg
- {
- result = new_binary_call(val[0], val[1], val[2])
- }
- | arg tANDOP arg
- {
- result = new_and(val[0], val[1], val[2])
- }
- | arg tOROP arg
- {
- result = new_or(val[0], val[1], val[2])
- }
- | kDEFINED opt_nl arg
- {
- result = s(:defined, val[2])
- }
- | arg tEH arg tCOLON arg
- {
- result = new_if(val[1], val[0], val[2], val[4])
- }
- | primary
-
- arg_value: arg
-
- aref_args: none
- {
- result = nil
- }
- | command opt_nl
- {
- result = [val[0]]
- }
- | args trailer
- {
- result = val[0]
- }
- | args tCOMMA assocs trailer
- {
- val[0] << s(:hash, *val[2])
- result = val[0]
- }
- | assocs trailer
- {
- result = [s(:hash, *val[0])]
- }
-
- paren_args: tLPAREN2 opt_call_args rparen
- {
- result = val[1]
- }
-
- rparen: opt_nl tRPAREN
-
- opt_paren_args: none
- {
- result = []
- }
- | paren_args
-
- opt_call_args: none
- {
- result = []
- }
- | call_args
- | args tCOMMA
- {
- result = val[0]
- }
- | args tCOMMA assocs tCOMMA
- {
- result = val[0]
- result << new_hash(nil, val[2], nil)
- }
- | assocs tCOMMA
- {
- result = [new_hash(nil, val[0], nil)]
- }
-
- call_args: command
- {
- result = [val[0]]
- }
- | args opt_block_arg
- {
- result = val[0]
- add_block_pass val[0], val[1]
- }
- | assocs opt_block_arg
- {
- result = [new_hash(nil, val[0], nil)]
- add_block_pass result, val[1]
- }
- | args tCOMMA assocs opt_block_arg
- {
- result = val[0]
- result << new_hash(nil, val[2], nil)
- result << val[3] if val[3]
- }
- | block_arg
- {
- result = []
- add_block_pass result, val[0]
- }
-
- call_args2: arg_value tCOMMA args opt_block_arg
- | block_arg
-
- command_args: {
- lexer.cmdarg_push 1
- }
- open_args
- {
- lexer.cmdarg_pop
- result = val[1]
- }
-
- open_args: call_args
- | tLPAREN_ARG tRPAREN
- {
- result = nil
- }
- | tLPAREN_ARG call_args2 tRPAREN
- {
- result = val[1]
- }
-
- block_arg: tAMPER arg_value
- {
- result = new_block_pass(val[0], val[1])
- }
-
- opt_block_arg: tCOMMA block_arg
- {
- result = val[1]
- }
- | # none
- {
- result = nil
- }
-
- args: arg_value
- {
- result = [val[0]]
- }
- | tSTAR arg_value
- {
- result = [new_splat(val[0], val[1])]
- }
- | args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << new_splat(val[2], val[3])
- }
-
- mrhs: args tCOMMA arg_value
- {
- val[0] << val[2]
- result = s(:array, *val[0])
- }
- | args tCOMMA tSTAR arg_value
- {
- val[0] << s(:splat, val[3])
- result = s(:array, *val[0])
- }
- | tSTAR arg_value
- {
- result = s(:splat, val[1])
- }
-
- primary: literal
- | strings
- | xstring
- | regexp
- | words
- | awords
- | var_ref
- | backref
- | tFID
- | kBEGIN
- {
- result = lexer.line
- }
- bodystmt kEND
- {
- result = s(:begin, val[2])
- }
- | tLPAREN_ARG expr opt_nl tRPAREN
- {
- result = val[1]
- }
- | tLPAREN compstmt tRPAREN
- {
- result = new_paren(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = new_colon2(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = new_colon3(val[0], val[1])
- }
- | primary_value tLBRACK2 aref_args tRBRACK
- {
- result = new_call val[0], [:[], []], val[2]
- }
- | primary_value tJSLBRACK aref_args tRBRACK
- {
- result = new_js_call val[0], [:[], []], val[2]
- }
- | tLBRACK aref_args tRBRACK
- {
- result = new_array(val[0], val[1], val[2])
- }
- | tLBRACE assoc_list tRCURLY
- {
- result = new_hash(val[0], val[1], val[2])
- }
- | kRETURN
- {
- result = new_return(val[0])
- }
- | kYIELD tLPAREN2 call_args tRPAREN
- {
- result = new_yield val[2]
- }
- | kYIELD tLPAREN2 tRPAREN
- {
- result = s(:yield)
- }
- | kYIELD
- {
- result = s(:yield)
- }
- | kDEFINED opt_nl tLPAREN2 expr tRPAREN
- {
- result = s(:defined, val[3])
- }
- | kNOT tLPAREN2 expr tRPAREN
- {
- result = new_unary_call(['!', []], val[2])
- }
- | kNOT tLPAREN2 tRPAREN
- {
- result = new_unary_call(['!', []], new_nil(val[0]))
- }
- | operation brace_block
- {
- result = new_call(nil, val[0], [])
- result << val[1]
- }
- | method_call
- | method_call brace_block
- {
- val[0] << val[1]
- result = val[0]
- }
- | tLAMBDA lambda
- {
- result = val[1]
- }
- | kIF expr_value then compstmt if_tail kEND
- {
- result = new_if(val[0], val[1], val[3], val[4])
- }
- | kUNLESS expr_value then compstmt opt_else kEND
- {
- result = new_if(val[0], val[1], val[4], val[3])
- }
- | kWHILE
- {
- lexer.cond_push 1
- result = lexer.line
- }
- expr_value do
- {
- lexer.cond_pop
- }
- compstmt kEND
- {
- result = s(:while, val[2], val[5])
- }
- | kUNTIL
- {
- lexer.cond_push 1
- result = lexer.line
- }
- expr_value do
- {
- lexer.cond_pop
- }
- compstmt kEND
- {
- result = s(:until, val[2], val[5])
- }
- | kCASE expr_value opt_terms case_body kEND
- {
- result = s(:case, val[1], *val[3])
- }
- | kCASE opt_terms case_body kEND
- {
- result = s(:case, nil, *val[2])
- }
- | kCASE opt_terms kELSE compstmt kEND
- {
- result = s(:case, nil, val[3])
- }
- | kFOR for_var kIN
- {
- lexer.cond_push 1
- result = lexer.line
- }
- expr_value do
- {
- lexer.cond_pop
- }
- compstmt kEND
- {
- result = s(:for, val[4], val[1], val[7])
- }
- | kCLASS cpath superclass
- {
- # ...
- }
- bodystmt kEND
- {
- result = new_class val[0], val[1], val[2], val[4], val[5]
- }
- | kCLASS tLSHFT
- {
- result = lexer.line
- }
- expr term
- {
- # ...
- }
- bodystmt kEND
- {
- result = new_sclass(val[0], val[3], val[6], val[7])
- }
- | kMODULE
- {
- result = lexer.line
- }
- cpath
- {
- # ...
- }
- bodystmt kEND
- {
- result = new_module(val[0], val[2], val[4], val[5])
- }
- | kDEF fname
- {
- push_scope
- lexer.lex_state = :expr_endfn
- }
- f_arglist bodystmt kEND
- {
- result = new_def(val[0], nil, val[1], val[3], val[4], val[5])
- pop_scope
- }
- | kDEF singleton dot_or_colon
- {
- lexer.lex_state = :expr_fname
- }
- fname
- {
- push_scope
- lexer.lex_state = :expr_endfn
- }
- f_arglist bodystmt kEND
- {
- result = new_def(val[0], val[1], val[4], val[6], val[7], val[8])
- pop_scope
- }
- | kBREAK
- {
- result = new_break(val[0])
- }
- | kNEXT
- {
- result = s(:next)
- }
- | kREDO
- {
- result = s(:redo)
- }
- | kRETRY
-
- primary_value: primary
-
- then: term
- | tCOLON
- | kTHEN
- | term kTHEN
-
- do: term
- | tCOLON
- | kDO_COND
-
- lambda: f_larglist lambda_body
- {
- result = new_call nil, [:lambda, []], []
- result << new_iter(val[0], val[1])
- }
-
- f_larglist: tLPAREN2 block_param tRPAREN
- {
- result = val[1]
- }
- | tLPAREN2 tRPAREN
- {
- result = nil
- }
- | block_param
- | none
-
- lambda_body: tLAMBEG compstmt tRCURLY
- {
- result = val[1]
- }
- | kDO_LAMBDA compstmt kEND
- {
- result = val[1]
- }
-
- if_tail: opt_else
- {
- result = val[0]
- }
- | kELSIF expr_value then compstmt if_tail
- {
- result = new_if(val[0], val[1], val[3], val[4])
- }
-
- opt_else: none
- | kELSE compstmt
- {
- result = val[1]
- }
-
- f_block_optarg: f_block_opt
- {
- result = s(:block, val[0])
- }
- | f_block_optarg tCOMMA f_block_opt
- {
- val[0] << val[2]
- result = val[0]
- }
-
- f_block_opt: tIDENTIFIER tEQL primary_value
- {
- result = new_assign(new_assignable(new_ident(
- val[0])), val[1], val[2])
- }
-
- opt_block_var: none
- | tPIPE tPIPE
- {
- result = nil
- }
- | tOROP
- {
- result = nil
- }
- | tPIPE block_param tPIPE
- {
- result = val[1]
- }
-
- block_args_tail: f_block_arg
- {
- result = val[0]
- }
-
-opt_block_args_tail: tCOMMA block_args_tail
- {
- result = val[1]
- }
- | none
- {
- nil
- }
-
- block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = new_block_args(val[0], val[2], val[4], val[5])
- }
- | f_arg tCOMMA f_block_optarg opt_block_args_tail
- {
- result = new_block_args(val[0], val[2], nil, val[3])
- }
- | f_arg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = new_block_args(val[0], nil, val[2], val[3])
- }
- | f_arg tCOMMA
- {
- result = new_block_args(val[0], nil, nil, nil)
- }
- | f_arg opt_block_args_tail
- {
- result = new_block_args(val[0], nil, nil, val[1])
- }
- | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = new_block_args(nil, val[0], val[2], val[3])
- }
- | f_block_optarg opt_block_args_tail
- {
- result = new_block_args(nil, val[0], nil, val[1])
- }
- | f_rest_arg opt_block_args_tail
- {
- result = new_block_args(nil, nil, val[0], val[1])
- }
- | block_args_tail
- {
- result = new_block_args(nil, nil, nil, val[0])
- }
-
- do_block: kDO_BLOCK
- {
- push_scope :block
- result = lexer.line
- }
- opt_block_var compstmt kEND
- {
- result = new_iter val[2], val[3]
- pop_scope
- }
-
- block_call: command do_block
- {
- val[0] << val[1]
- result = val[0]
- }
- | block_call tJSDOT operation2 opt_paren_args
- | block_call tDOT operation2 opt_paren_args
- | block_call tCOLON2 operation2 opt_paren_args
-
- method_call: operation paren_args
- {
- result = new_call(nil, val[0], val[1])
- }
- | primary_value tDOT operation2 opt_paren_args
- {
- result = new_call(val[0], val[2], val[3])
- }
- | primary_value tJSDOT operation2 opt_paren_args
- {
- result = new_js_call(val[0], val[2], val[3])
- }
- | primary_value tDOT paren_args
- {
- result = new_call(val[0], [:call, []], val[2])
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- result = new_call(val[0], val[2], val[3])
- }
- | primary_value tCOLON2 operation3
- {
- result = new_call(val[0], val[2])
- }
- | kSUPER paren_args
- {
- result = new_super(val[0], val[1])
- }
- | kSUPER
- {
- result = new_super(val[0], nil)
- }
-
- brace_block: tLCURLY
- {
- push_scope :block
- result = lexer.line
- }
- opt_block_var compstmt tRCURLY
- {
- result = new_iter val[2], val[3]
- pop_scope
- }
- | kDO
- {
- push_scope :block
- result = lexer.line
- }
- opt_block_var compstmt kEND
- {
- result = new_iter val[2], val[3]
- pop_scope
- }
-
- case_body: kWHEN
- {
- result = lexer.line
- }
- args then compstmt cases
- {
- part = s(:when, s(:array, *val[2]), val[4])
- result = [part]
- result.push(*val[5]) if val[5]
- }
-
- cases: opt_else
- {
- result = [val[0]]
- }
- | case_body
-
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
- {
- exc = val[1] || s(:array)
- exc << new_assign(val[2], val[2], s(:gvar, '$!'.intern)) if val[2]
- result = [s(:resbody, exc, val[4])]
- result.push val[5].first if val[5]
- }
- | # none
- {
- result = nil
- }
-
- exc_list: arg_value
- {
- result = s(:array, val[0])
- }
- | mrhs
- | none
-
- exc_var: tASSOC lhs
- {
- result = val[1]
- }
- | none
- {
- result = nil
- }
-
- opt_ensure: kENSURE compstmt
- {
- result = val[1].nil? ? s(:nil) : val[1]
- }
- | none
-
- literal: numeric
- | symbol
- | dsym
-
- strings: string
- {
- result = new_str val[0]
- }
-
- string: string1
- | string string1
- {
- result = str_append val[0], val[1]
- }
-
- string1: tSTRING_BEG string_contents tSTRING_END
- {
- result = val[1]
- }
- | tSTRING
- {
- result = s(:str, value(val[0]))
- }
-
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
- {
- result = new_xstr(val[0], val[1], val[2])
- }
-
- regexp: tREGEXP_BEG xstring_contents tREGEXP_END
- {
- result = new_regexp val[1], val[2]
- }
-
- words: tWORDS_BEG tSPACE tSTRING_END
- {
- result = s(:array)
- }
- | tWORDS_BEG word_list tSTRING_END
- {
- result = val[1]
- }
-
- word_list: none
- {
- result = s(:array)
- }
- | word_list word tSPACE
- {
- part = val[1]
- part = s(:dstr, "", val[1]) if part.type == :evstr
- result = val[0] << part
- }
-
- word: string_content
- {
- result = val[0]
- }
- | word string_content
- {
- result = val[0].concat([val[1]])
- }
-
- awords: tAWORDS_BEG tSPACE tSTRING_END
- {
- result = s(:array)
- }
- | tAWORDS_BEG qword_list tSTRING_END
- {
- result = val[1]
- }
-
- qword_list: none
- {
- result = s(:array)
- }
- | qword_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << s(:str, value(val[1]))
- }
-
- string_contents: none
- {
- result = nil
- }
- | string_contents string_content
- {
- result = str_append val[0], val[1]
- }
-
-xstring_contents: none
- {
- result = nil
- }
- | xstring_contents string_content
- {
- result = str_append val[0], val[1]
- }
-
- string_content: tSTRING_CONTENT
- {
- result = new_str_content(val[0])
- }
- | tSTRING_DVAR
- {
- result = lexer.strterm
- lexer.strterm = nil
- }
- string_dvar
- {
- lexer.strterm = val[1]
- result = new_evstr(val[2])
- }
- | tSTRING_DBEG
- {
- lexer.cond_push 0
- lexer.cmdarg_push 0
- result = lexer.strterm
- lexer.strterm = nil
- lexer.lex_state = :expr_beg
- }
- compstmt tRCURLY
- {
- lexer.strterm = val[1]
- lexer.cond_lexpop
- lexer.cmdarg_lexpop
- result = new_evstr(val[2])
- }
-
- string_dvar: tGVAR
- {
- result = new_gvar(val[0])
- }
- | tIVAR
- {
- result = new_ivar(val[0])
- }
- | tCVAR
- {
- result = new_cvar(val[0])
- }
- | backref
-
-
- symbol: tSYMBEG sym
- {
- result = new_sym(val[1])
- lexer.lex_state = :expr_end
- }
- | tSYMBOL
- {
- result = new_sym(val[0])
- }
-
- sym: fname
- | tIVAR
- | tGVAR
- | tCVAR
-
- dsym: tSYMBEG xstring_contents tSTRING_END
- {
- result = new_dsym val[1]
- }
-
- numeric: tINTEGER
- {
- result = new_int(val[0])
- }
- | tFLOAT
- {
- result = new_float(val[0])
- }
- | '-@NUM' tINTEGER =tLOWEST
- {
- result = negate_num(new_int(val[1]))
- }
- | '-@NUM' tFLOAT =tLOWEST
- {
- result = negate_num(new_float(val[1]))
- }
- | '+@NUM' tINTEGER =tLOWEST
- {
- result = new_int(val[1])
- }
- | '+@NUM' tFLOAT =tLOWEST
- {
- result = new_float(val[1])
- }
-
- variable: tIDENTIFIER
- {
- result = new_ident(val[0])
- }
- | tIVAR
- {
- result = new_ivar(val[0])
- }
- | tGVAR
- {
- result = new_gvar(val[0])
- }
- | tCONSTANT
- {
- result = new_const(val[0])
- }
- | tCVAR
- {
- result = new_cvar(val[0])
- }
- | kNIL
- {
- result = new_nil(val[0])
- }
- | kSELF
- {
- result = new_self(val[0])
- }
- | kTRUE
- {
- result = new_true(val[0])
- }
- | kFALSE
- {
- result = new_false(val[0])
- }
- | k__FILE__
- {
- result = new___FILE__(val[0])
- }
- | k__LINE__
- {
- result = new___LINE__(val[0])
- }
-
- var_ref: variable
- {
- result = new_var_ref(val[0])
- }
-
- var_lhs: variable
- {
- result = new_assignable val[0]
- }
-
- backref: tNTH_REF
- {
- result = s(:nth_ref, value(val[0]))
- }
- | tBACK_REF
-
- superclass: term
- {
- result = nil
- }
- | tLT expr_value term
- {
- result = val[1]
- }
- | error term
- {
- result = nil
- }
-
- f_arglist: tLPAREN2 f_args opt_nl tRPAREN
- {
- result = val[1]
- lexer.lex_state = :expr_beg
- }
- | f_args term
- {
- result = val[0]
- lexer.lex_state = :expr_beg
- }
-
- kwrest_mark: tPOW
- | tDSTAR
-
- f_kwrest: kwrest_mark tIDENTIFIER
- {
- result = new_kwrestarg(val[1])
- }
- | kwrest_mark
- {
- result = new_kwrestarg()
- }
-
- f_label: tLABEL
- {
- result = new_sym(val[0])
- }
-
- f_kw: f_label arg_value
- {
- result = new_kwoptarg(val[0], val[1])
- }
- | f_label
- {
- result = new_kwarg(val[0])
- }
-
- f_kwarg: f_kw
- {
- result = [val[0]]
- }
- | f_kwarg tCOMMA f_kw
- {
- result = val[0]
- result << val[2]
- }
-
- args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
- {
- result = new_args_tail(val[0], val[2], val[3])
- }
- | f_kwarg opt_f_block_arg
- {
- result = new_args_tail(val[0], nil, val[1])
- }
- | f_kwrest opt_f_block_arg
- {
- result = new_args_tail(nil, val[0], val[1])
- }
- | f_block_arg
- {
- result = new_args_tail(nil, nil, val[0])
- }
-
- opt_args_tail: tCOMMA args_tail
- {
- result = val[1]
- }
- | # none
- {
- result = new_args_tail(nil, nil, nil)
- }
-
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = new_args(val[0], val[2], val[4], val[5])
- }
- | f_arg tCOMMA f_optarg opt_args_tail
- {
- result = new_args(val[0], val[2], nil, val[3])
- }
- | f_arg tCOMMA f_rest_arg opt_args_tail
- {
- result = new_args(val[0], nil, val[2], val[3])
- }
- | f_arg opt_args_tail
- {
- result = new_args(val[0], nil, nil, val[1])
- }
- | f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = new_args(nil, val[0], val[2], val[3])
- }
- | f_optarg opt_args_tail
- {
- result = new_args(nil, val[0], nil, val[1])
- }
- | f_rest_arg opt_args_tail
- {
- result = new_args(nil, nil, val[0], val[1])
- }
- | args_tail
- {
- result = new_args(nil, nil, nil, val[0])
- }
- | # none
- {
- result = new_args(nil, nil, nil, nil)
- }
-
- f_norm_arg: f_bad_arg
- | tIDENTIFIER
- {
- result = value(val[0]).to_sym
- scope.add_local result
- }
-
- f_bad_arg: tCONSTANT
- {
- raise 'formal argument cannot be a constant'
- }
- | tIVAR
- {
- raise 'formal argument cannot be an instance variable'
- }
- | tCVAR
- {
- raise 'formal argument cannot be a class variable'
- }
- | tGVAR
- {
- raise 'formal argument cannot be a global variable'
- }
-
- f_arg_item: f_norm_arg
- {
- result = val[0]
- }
- | tLPAREN f_margs tRPAREN
- {
- result = val[1]
- }
-
- for_var: lhs
- | mlhs
-
- f_marg: f_norm_arg
- {
- result = s(:lasgn, val[0])
- }
- | tLPAREN f_margs tRPAREN
-
- f_marg_list: f_marg
- {
- result = s(:array, val[0])
- }
- | f_marg_list tCOMMA f_marg
- {
- val[0] << val[2]
- result = val[0]
- }
-
- f_margs: f_marg_list
- | f_marg_list tCOMMA tSTAR f_norm_arg
- | f_marg_list tCOMMA tSTAR
- | tSTAR f_norm_arg
- | tSTAR
-
- f_arg: f_arg_item
- {
- result = [val[0]]
- }
- | f_arg tCOMMA f_arg_item
- {
- val[0] << val[2]
- result = val[0]
- }
-
- f_opt: tIDENTIFIER tEQL arg_value
- {
- result = new_assign(new_assignable(new_ident(val[0])), val[1], val[2])
- }
-
- f_optarg: f_opt
- {
- result = s(:block, val[0])
- }
- | f_optarg tCOMMA f_opt
- {
- result = val[0]
- val[0] << val[2]
- }
-
- restarg_mark: tSTAR2
- | tSTAR
-
- f_rest_arg: restarg_mark tIDENTIFIER
- {
- result = "*#{value(val[1])}".to_sym
- }
- | restarg_mark
- {
- result = :"*"
- }
-
- blkarg_mark: tAMPER2
- | tAMPER
-
- f_block_arg: blkarg_mark tIDENTIFIER
- {
- result = "&#{value(val[1])}".to_sym
- }
-
- opt_f_block_arg: tCOMMA f_block_arg
- {
- result = val[1]
- }
- | # none
- {
- result = nil
- }
-
- singleton: var_ref
- {
- result = val[0]
- }
- | tLPAREN2 expr opt_nl tRPAREN
- {
- result = val[1]
- }
-
- assoc_list: # none
- {
- result = []
- }
- | assocs trailer
- {
- result = val[0]
- }
-
- assocs: assoc
- {
- result = val[0]
- }
- | assocs tCOMMA assoc
- {
- result = val[0].push(*val[2])
- }
-
- assoc: arg_value tASSOC arg_value
- {
- result = [val[0], val[2]]
- }
- | tLABEL arg_value
- {
- result = [new_sym(val[0]), val[1]]
- }
-
- operation: tIDENTIFIER
- | tCONSTANT
- | tFID
-
- operation2: tIDENTIFIER
- | tCONSTANT
- | tFID
- | op
-
- operation3: tIDENTIFIER
- | tFID
- | op
-
- dot_or_colon: tDOT
- | tCOLON2
-
- opt_terms: # none
- | terms
-
- opt_nl: # none
- | tNL
-
- trailer: # none
- | tNL
- | tCOMMA
-
- term: tSEMI
- | tNL
-
- terms: term
- | terms tSEMI
-
- none: # none
- {
- result = nil
- }
-end
-
----- inner
diff --git a/test/racc/assets/opt.y b/test/racc/assets/opt.y
deleted file mode 100644
index a011953a51..0000000000
--- a/test/racc/assets/opt.y
+++ /dev/null
@@ -1,123 +0,0 @@
-#
-# check options working
-#
-
-class Calcp
-
- prechigh
- left '*' '/'
- left '+' '-'
- preclow
-
- convert
- NUMBER 'Number'
- end
-
- options no_omit_action_call no_result_var
-
-rule
-
- target : exp | /* none */ { 0 } ;
-
- exp : exp '+' exp { chk(val[0] + val[2]) }
- | exp '-' exp { chk(val[0] - val[2]) }
- | exp '*' exp { chk(val[0] * val[2]) }
- | exp '/' exp { chk(val[0] / val[2]) }
- | '(' { $emb = true } exp ')'
- {
- raise 'must not happen' unless $emb
- val[2]
- }
- | '-' NUMBER { -val[1] }
- | NUMBER
- ;
-
-end
-
-----header
-
-class Number; end
-
-----inner
-
- def parse( src )
- @src = src
- do_parse
- end
-
- def next_token
- @src.shift
- end
-
- def initialize
- @yydebug = true
- end
-
- def chk( i )
- # p i
- i
- end
-
-----footer
-
-$parser = Calcp.new
-$test_number = 1
-
-def chk( src, ans )
- result = $parser.parse(src)
- raise "test #{$test_number} failed" unless result == ans
- $test_number += 1
-end
-
-chk(
- [ [Number, 9],
- [false, false],
- [false, false] ], 9
-)
-
-chk(
- [ [Number, 5],
- ['*', nil],
- [Number, 1],
- ['-', nil],
- [Number, 1],
- ['*', nil],
- [Number, 8],
- [false, false],
- [false, false] ], -3
-)
-
-chk(
- [ [Number, 5],
- ['+', nil],
- [Number, 2],
- ['-', nil],
- [Number, 5],
- ['+', nil],
- [Number, 2],
- ['-', nil],
- [Number, 5],
- [false, false],
- [false, false] ], -1
-)
-
-chk(
- [ ['-', nil],
- [Number, 4],
- [false, false],
- [false, false] ], -4
-)
-
-chk(
- [ [Number, 7],
- ['*', nil],
- ['(', nil],
- [Number, 4],
- ['+', nil],
- [Number, 3],
- [')', nil],
- ['-', nil],
- [Number, 9],
- [false, false],
- [false, false] ], 40
-)
diff --git a/test/racc/assets/percent.y b/test/racc/assets/percent.y
deleted file mode 100644
index 68d63583ca..0000000000
--- a/test/racc/assets/percent.y
+++ /dev/null
@@ -1,35 +0,0 @@
-class ScannerChecker
-rule
- target: A
- {
- i = 7
- i %= 4
- raise 'assert failed' unless i == 3
- tmp = %-This is percent string.-
- raise 'assert failed' unless tmp == 'This is percent string.'
- a = 5; b = 3
- assert_equal(2,(a%b)) #A
- # assert_equal(2,(a %b)) # is %-string
- assert_equal(2,(a% b)) #B
- assert_equal(2,(a % b)) #C
- }
-end
-
----- inner ----
-
- def parse
- @q = [[:A, 'A'], [false, '$']]
- do_parse
- end
-
- def next_token
- @q.shift
- end
-
- def assert_equal( expect, real )
- raise "expect #{expect.inspect} but #{real.inspect}" unless expect == real
- end
-
----- footer ----
-
-parser = ScannerChecker.new.parse
diff --git a/test/racc/assets/php_serialization.y b/test/racc/assets/php_serialization.y
deleted file mode 100644
index 99f78f2081..0000000000
--- a/test/racc/assets/php_serialization.y
+++ /dev/null
@@ -1,98 +0,0 @@
-# MIT License
-# See https://github.com/divoxx/ruby-php-serialization/blob/master/LICENSE.txt
-
-class PhpSerialization::Unserializer
-rule
-
- data : null ';' { @object = val[0] }
- | bool ';' { @object = val[0] }
- | integer ';' { @object = val[0] }
- | double ';' { @object = val[0] }
- | string ';' { @object = val[0] }
- | assoc_array { @object = val[0] }
- | object { @object = val[0] }
- ;
-
- null : 'N' { result = nil }
- ;
-
- bool : 'b' ':' NUMBER { result = Integer(val[2]) > 0 }
- ;
-
- integer : 'i' ':' NUMBER { result = Integer(val[2]) }
- ;
-
- double : 'd' ':' NUMBER { result = Float(val[2]) }
- ;
-
- string : 's' ':' NUMBER ':' STRING { result = val[4] }
- ;
-
- object : 'O' ':' NUMBER ':' STRING ':' NUMBER ':' '{' attribute_list '}'
- {
- if eval("defined?(#{val[4]})")
- result = Object.const_get(val[4]).new
-
- val[9].each do |(attr_name, value)|
- # Protected and private attributes will have a \0..\0 prefix
- attr_name = attr_name.gsub(/\A\\0[^\\]+\\0/, '')
- result.instance_variable_set("@#{attr_name}", value)
- end
- else
- klass_name = val[4].gsub(/^Struct::/, '')
- attr_names, values = [], []
-
- val[9].each do |(attr_name, value)|
- # Protected and private attributes will have a \0..\0 prefix
- attr_names << attr_name.gsub(/\A\\0[^\\]+\\0/, '')
- values << value
- end
-
- result = Struct.new(klass_name, *attr_names).new(*values)
- result.instance_variable_set("@_php_class", klass_name)
- end
- }
- ;
-
- attribute_list : attribute_list attribute { result = val[0] << val[1] }
- | { result = [] }
- ;
-
- attribute : data data { result = val }
- ;
-
- assoc_array : 'a' ':' NUMBER ':' '{' attribute_list '}'
- {
- # Checks if the keys are a sequence of integers
- idx = -1
- arr = val[5].all? { |(k,v)| k == (idx += 1) }
-
- if arr
- result = val[5].map { |(k,v)| v }
- else
- result = Hash[val[5]]
- end
- }
- ;
-
-end
-
----- header ----
-require 'php_serialization/tokenizer'
-
----- inner ----
- def initialize(tokenizer_klass = Tokenizer)
- @tokenizer_klass = tokenizer_klass
- end
-
- def run(string)
- @tokenizer = @tokenizer_klass.new(string)
- yyparse(@tokenizer, :each)
- return @object
- ensure
- @tokenizer = nil
- end
-
- def next_token
- @tokenizer.next_token
- end
diff --git a/test/racc/assets/recv.y b/test/racc/assets/recv.y
deleted file mode 100644
index b6e849dda9..0000000000
--- a/test/racc/assets/recv.y
+++ /dev/null
@@ -1,97 +0,0 @@
-# s/r 5, r/r 10
-class A
-rule
-
- content: RecvH received
- ;
-
- datetime: day
- ;
-
- msgid: '<' spec '>';
-
- day:
- | ATOM ','
- ;
-
- received: recvitem_list recvdatetime
- ;
-
- recvitem_list:
- | recvitem_list recvitem
- ;
-
- recvitem: by | via | with | for ;
-
- by:
- | BY domain
- ;
-
- via:
- | VIA ATOM
- ;
-
- with: WITH ATOM
- ;
-
- for:
- | FOR addr
- ;
-
- recvdatetime:
- | ';' datetime
- ;
-
- addr: mbox | group ;
-
- mboxes: mbox
- | mboxes ',' mbox
- ;
-
- mbox: spec
- | routeaddr
- | phrase routeaddr
- ;
-
- group: phrase ':' mboxes ';'
- ;
-
- routeaddr: '<' route spec '>'
- | '<' spec '>'
- ;
-
- route: at_domains ':' ;
-
- at_domains: '@' domain
- | at_domains ',' '@' domain
- ;
-
- spec: local '@' domain
- | local
- ;
-
- local: word
- | local '.' word
- ;
-
- domain: domword
- | domain '.' domword
- ;
-
- domword: atom
- | DOMLIT
- | DIGIT
- ;
-
- phrase: word
- | phrase word
- ;
-
- word: atom
- | QUOTED
- | DIGIT
- ;
-
- atom: ATOM | FROM | BY | VIA | WITH | ID | FOR ;
-
-end
diff --git a/test/racc/assets/riml.y b/test/racc/assets/riml.y
deleted file mode 100644
index 1d99b0fdb8..0000000000
--- a/test/racc/assets/riml.y
+++ /dev/null
@@ -1,665 +0,0 @@
-# Copyright (c) 2012-2014 by Luke Gruber
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Riml::Parser
-
-token IF ELSE ELSEIF THEN UNLESS END
-token WHILE UNTIL BREAK CONTINUE
-token TRY CATCH FINALLY
-token FOR IN
-token DEF DEF_BANG SPLAT_PARAM SPLAT_ARG CALL BUILTIN_COMMAND # such as echo "hi"
-token CLASS NEW DEFM DEFM_BANG SUPER
-token RIML_FILE_COMMAND RIML_CLASS_COMMAND
-token RETURN
-token NEWLINE
-token NUMBER
-token STRING_D STRING_S # single- and double-quoted
-token EX_LITERAL
-token REGEXP
-token TRUE FALSE
-token LET UNLET UNLET_BANG IDENTIFIER
-token DICT_VAL # like dict.key, 'key' is a DICT_VAL
-token SCOPE_MODIFIER SCOPE_MODIFIER_LITERAL SPECIAL_VAR_PREFIX
-token FINISH
-
-prechigh
- right '!'
- left '*' '/' '%'
- left '+' '-' '.'
- left '>' '>#' '>?' '<' '<#' '<?' '>=' '>=#' '>=?' '<=' '<=#' '<=?'
- left '==' '==?' '==#' '=~' '=~?' '=~#' '!~' '!~?' '!~#' '!=' '!=?' '!=#'
- left IS ISNOT
- left '&&'
- left '||'
- right '?'
- right '=' '+=' '-=' '.='
- left ','
- left IF UNLESS
-preclow
-
-# All rules
-rule
-
- Root:
- /* nothing */ { result = make_node(val) { |_| Riml::Nodes.new([]) } }
- | Terminator { result = make_node(val) { |_| Riml::Nodes.new([]) } }
- | Statements { result = val[0] }
- ;
-
- # any list of expressions
- Statements:
- Statement { result = make_node(val) { |v| Riml::Nodes.new([ v[0] ]) } }
- | Statements Terminator Statement { result = val[0] << val[2] }
- | Statements Terminator { result = val[0] }
- | Terminator Statements { result = make_node(val) { |v| Riml::Nodes.new(v[1]) } }
- ;
-
- # All types of expressions in Riml
- Statement:
- ExplicitCall { result = val[0] }
- | Def { result = val[0] }
- | Return { result = val[0] }
- | UnletVariable { result = val[0] }
- | ExLiteral { result = val[0] }
- | For { result = val[0] }
- | While { result = val[0] }
- | Until { result = val[0] }
- | Try { result = val[0] }
- | ClassDefinition { result = val[0] }
- | LoopKeyword { result = val[0] }
- | EndScript { result = val[0] }
- | RimlFileCommand { result = val[0] }
- | RimlClassCommand { result = val[0] }
- | MultiAssign { result = val[0] }
- | If { result = val[0] }
- | Unless { result = val[0] }
- | Expression { result = val[0] }
- ;
-
- Expression:
- ExpressionWithoutDictLiteral { result = val[0] }
- | Dictionary { result = val[0] }
- | Dictionary DictGetWithDotLiteral { result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) } }
- | BinaryOperator { result = val[0] }
- | Ternary { result = val[0] }
- | Assign { result = val[0] }
- | Super { result = val[0] }
- | '(' Expression ')' { result = make_node(val) { |v| Riml::WrapInParensNode.new(v[1]) } }
- ;
-
- ExpressionWithoutDictLiteral:
- UnaryOperator { result = val[0] }
- | DictGet { result = val[0] }
- | ListOrDictGet { result = val[0] }
- | AllVariableRetrieval { result = val[0] }
- | LiteralWithoutDictLiteral { result = val[0] }
- | Call { result = val[0] }
- | ObjectInstantiation { result = val[0] }
- | '(' ExpressionWithoutDictLiteral ')' { result = make_node(val) { |v| Riml::WrapInParensNode.new(v[1]) } }
- ;
-
- # for inside curly-brace variable names
- PossibleStringValue:
- String { result = val[0] }
- | DictGet { result = val[0] }
- | ListOrDictGet { result = val[0] }
- | AllVariableRetrieval { result = val[0] }
- | BinaryOperator { result = val[0] }
- | Ternary { result = val[0] }
- | Call { result = val[0] }
- ;
-
- Terminator:
- NEWLINE { result = nil }
- | ';' { result = nil }
- ;
-
- LiteralWithoutDictLiteral:
- Number { result = val[0] }
- | String { result = val[0] }
- | Regexp { result = val[0] }
- | List { result = val[0] }
- | ScopeModifierLiteral { result = val[0] }
- | TRUE { result = make_node(val) { |_| Riml::TrueNode.new } }
- | FALSE { result = make_node(val) { |_| Riml::FalseNode.new } }
- ;
-
- Number:
- NUMBER { result = make_node(val) { |v| Riml::NumberNode.new(v[0]) } }
- ;
-
- String:
- STRING_S { result = make_node(val) { |v| Riml::StringNode.new(v[0], :s) } }
- | STRING_D { result = make_node(val) { |v| Riml::StringNode.new(v[0], :d) } }
- | String STRING_S { result = make_node(val) { |v| Riml::StringLiteralConcatNode.new(v[0], Riml::StringNode.new(v[1], :s)) } }
- | String STRING_D { result = make_node(val) { |v| Riml::StringLiteralConcatNode.new(v[0], Riml::StringNode.new(v[1], :d)) } }
- ;
-
- Regexp:
- REGEXP { result = make_node(val) { |v| Riml::RegexpNode.new(v[0]) } }
- ;
-
- ScopeModifierLiteral:
- SCOPE_MODIFIER_LITERAL { result = make_node(val) { |v| Riml::ScopeModifierLiteralNode.new(v[0]) } }
- ;
-
- List:
- ListLiteral { result = make_node(val) { |v| Riml::ListNode.new(v[0]) } }
- ;
-
- ListUnpack:
- '[' ListItems ';' Expression ']' { result = make_node(val) { |v| Riml::ListUnpackNode.new(v[1] << v[3]) } }
- ;
-
- ListLiteral:
- '[' ListItems ']' { result = val[1] }
- | '[' ListItems ',' ']' { result = val[1] }
- ;
-
- ListItems:
- /* nothing */ { result = [] }
- | Expression { result = [val[0]] }
- | ListItems ',' Expression { result = val[0] << val[2] }
- ;
-
- Dictionary:
- DictionaryLiteral { result = make_node(val) { |v| Riml::DictionaryNode.new(v[0]) } }
- ;
-
- # {'key': 'value', 'key2': 'value2'}
- # Save as [['key', 'value'], ['key2', 'value2']] because ruby-1.8.7 offers
- # no guarantee for key-value pair ordering.
- DictionaryLiteral:
- '{' DictItems '}' { result = val[1] }
- | '{' DictItems ',' '}' { result = val[1] }
- ;
-
- # [[key, value], [key, value]]
- DictItems:
- /* nothing */ { result = [] }
- | DictItem { result = val }
- | DictItems ',' DictItem { result = val[0] << val[2] }
- ;
-
- # [key, value]
- DictItem:
- Expression ':' Expression { result = [val[0], val[2]] }
- ;
-
- DictGet:
- AllVariableRetrieval DictGetWithDot { result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) } }
- | ListOrDictGet DictGetWithDot { result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) } }
- | Call DictGetWithDot { result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) } }
- | '(' Expression ')' DictGetWithDot { result = make_node(val) { |v| Riml::DictGetDotNode.new(Riml::WrapInParensNode.new(v[1]), v[3]) } }
- ;
-
- ListOrDictGet:
- ExpressionWithoutDictLiteral ListOrDictGetWithBrackets { result = make_node(val) { |v| Riml::ListOrDictGetNode.new(v[0], v[1]) } }
- | '(' Expression ')' ListOrDictGetWithBrackets { result = make_node(val) { |v| Riml::ListOrDictGetNode.new(Riml::WrapInParensNode.new(v[1]), v[3]) } }
- ;
-
- ListOrDictGetAssign:
- ExpressionWithoutDictLiteral ListOrDictGetWithBrackets { result = make_node(val) { |v| Riml::ListOrDictGetNode.new(v[0], v[1]) } }
- ;
-
- ListOrDictGetWithBrackets:
- '[' Expression ']' { result = [val[1]] }
- | '[' SubList ']' { result = [val[1]] }
- | ListOrDictGetWithBrackets '[' Expression ']' { result = val[0] << val[2] }
- | ListOrDictGetWithBrackets '[' SubList ']' { result = val[0] << val[2] }
- ;
-
- SubList:
- Expression ':' Expression { result = make_node(val) { |v| Riml::SublistNode.new([v[0], Riml::LiteralNode.new(' : '), v[2]]) } }
- | Expression ':' { result = make_node(val) { |v| Riml::SublistNode.new([v[0], Riml::LiteralNode.new(' :')]) } }
- | ':' Expression { result = make_node(val) { |v| Riml::SublistNode.new([Riml::LiteralNode.new(': '), v[1]]) } }
- | ':' { result = make_node(val) { |_| Riml::SublistNode.new([Riml::LiteralNode.new(':')]) } }
- ;
-
- DictGetWithDot:
- DICT_VAL { result = [val[0]] }
- | DictGetWithDot DICT_VAL { result = val[0] << val[1] }
- ;
-
- DictGetWithDotLiteral:
- '.' IDENTIFIER { result = [val[1]] }
- | DictGetWithDotLiteral DICT_VAL { result = val[0] << val[1] }
- ;
-
- Call:
- Scope DefCallIdentifier '(' ArgList ')' { result = make_node(val) { |v| Riml::CallNode.new(v[0], v[1], v[3]) } }
- | DictGet '(' ArgList ')' { result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], v[2]) } }
- | BUILTIN_COMMAND '(' ArgList ')' { result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], v[2]) } }
- | BUILTIN_COMMAND ArgListWithoutNothing { result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], v[1]) } }
- | BUILTIN_COMMAND NEWLINE { result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], []) } }
- | CALL '(' ArgList ')' { result = make_node(val) { |v| Riml::ExplicitCallNode.new(nil, nil, v[2]) } }
- ;
-
- ObjectInstantiationCall:
- Scope DefCallIdentifier '(' ArgList ')' { result = make_node(val) { |v| Riml::CallNode.new(v[0], v[1], v[3]) } }
- | Scope DefCallIdentifier { result = make_node(val) { |v| Riml::CallNode.new(v[0], v[1], []) } }
- ;
-
- RimlFileCommand:
- RIML_FILE_COMMAND '(' ArgList ')' { result = make_node(val) { |v| Riml::RimlFileCommandNode.new(nil, v[0], v[2]) } }
- | RIML_FILE_COMMAND ArgList { result = make_node(val) { |v| Riml::RimlFileCommandNode.new(nil, v[0], v[1]) } }
- ;
-
- RimlClassCommand:
- RIML_CLASS_COMMAND '(' ClassArgList ')' { result = make_node(val) { |v| Riml::RimlClassCommandNode.new(nil, v[0], v[2]) } }
- | RIML_CLASS_COMMAND ClassArgList { result = make_node(val) { |v| Riml::RimlClassCommandNode.new(nil, v[0], v[1]) } }
- ;
-
- ClassArgList:
- Scope IDENTIFIER { result = ["#{val[0]}#{val[1]}"] }
- | String { result = val }
- | ClassArgList ',' Scope IDENTIFIER { result = val[0].concat ["#{val[2]}#{val[3]}"] }
- ;
-
- ExplicitCall:
- CALL Scope DefCallIdentifier '(' ArgList ')' { result = make_node(val) { |v| Riml::ExplicitCallNode.new(v[1], v[2], v[4]) } }
- | CALL DictGet '(' ArgList ')' { result = make_node(val) { |v| Riml::ExplicitCallNode.new(nil, v[1], v[3]) } }
- ;
-
- Scope:
- SCOPE_MODIFIER { result = val[0] }
- | /* nothing */ { result = nil }
- ;
-
- # [SID, scope_modifier]
- SIDAndScope:
- Scope { result = [ nil, val[0] ] }
- | '<' IDENTIFIER '>' Scope { result = [ make_node(val) { |v| Riml::SIDNode.new(v[1]) }, val[3] ] }
- ;
-
- ArgList:
- /* nothing */ { result = [] }
- | ArgListWithoutNothingWithSplat { result = val[0] }
- ;
-
- ArgListWithSplat:
- /* nothing */ { result = [] }
- | ArgListWithoutNothingWithSplat { result = val[0] }
- ;
-
- ArgListWithoutNothingWithSplat:
- Expression { result = val }
- | SPLAT_ARG Expression { result = [ make_node(val) { |v| Riml::SplatNode.new(v[1]) } ] }
- | ArgListWithoutNothingWithSplat "," Expression { result = val[0] << val[2] }
- | ArgListWithoutNothingWithSplat "," SPLAT_ARG Expression { result = val[0] << make_node(val) { |v| Riml::SplatNode.new(v[3]) } }
- ;
-
- ArgListWithoutNothing:
- Expression { result = val }
- | ArgListWithoutNothing "," Expression { result = val[0] << val[2] }
- ;
-
- BinaryOperator:
- Expression '||' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '&&' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '==' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '==#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '==?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- # added by riml
- | Expression '===' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '!=' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '!=#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '!=?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '=~' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '=~#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '=~?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '!~' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '!~#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '!~?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '>' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '>#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '>?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '>=' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '>=#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '>=?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '<' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '<#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '<?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '<=' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '<=#' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '<=?' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression '+' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '-' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '*' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '/' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '.' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression '%' Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
-
- | Expression IS Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- | Expression ISNOT Expression { result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) } }
- ;
-
- UnaryOperator:
- '!' Expression { result = make_node(val) { |v| Riml::UnaryOperatorNode.new(val[0], [val[1]]) } }
- | '+' Expression { result = make_node(val) { |v| Riml::UnaryOperatorNode.new(val[0], [val[1]]) } }
- | '-' Expression { result = make_node(val) { |v| Riml::UnaryOperatorNode.new(val[0], [val[1]]) } }
- ;
-
- # ['=', LHS, RHS]
- Assign:
- LET AssignExpression { result = make_node(val) { |v| Riml::AssignNode.new(v[1][0], v[1][1], v[1][2]) } }
- | AssignExpression { result = make_node(val) { |v| Riml::AssignNode.new(v[0][0], v[0][1], v[0][2]) } }
- ;
-
- MultiAssign:
- Assign ',' Assign { result = make_node(val) { |v| Riml::MultiAssignNode.new([v[0], v[2]]) } }
- | MultiAssign ',' Assign { val[0].assigns << val[2]; result = val[0] }
- ;
-
- # ['=', AssignLHS, Expression]
- AssignExpression:
- AssignLHS '=' Expression { result = [val[1], val[0], val[2]] }
- | AssignLHS '+=' Expression { result = [val[1], val[0], val[2]] }
- | AssignLHS '-=' Expression { result = [val[1], val[0], val[2]] }
- | AssignLHS '.=' Expression { result = [val[1], val[0], val[2]] }
- ;
-
- AssignLHS:
- AllVariableRetrieval { result = val[0] }
- | List { result = val[0] }
- | ListUnpack { result = val[0] }
- | DictGet { result = val[0] }
- | ListOrDictGetAssign { result = val[0] }
- ;
-
- # retrieving the value of a variable
- VariableRetrieval:
- SimpleVariableRetrieval { result = val[0] }
- | SPECIAL_VAR_PREFIX IDENTIFIER { result = make_node(val) { |v| Riml::GetSpecialVariableNode.new(v[0], v[1]) } }
- | ScopeModifierLiteral ListOrDictGetWithBrackets { result = make_node(val) { |v| Riml::GetVariableByScopeAndDictNameNode.new(v[0], v[1]) } }
- ;
-
- SimpleVariableRetrieval:
- Scope IDENTIFIER { result = make_node(val) { |v| Riml::GetVariableNode.new(v[0], v[1]) } }
- ;
-
- AllVariableRetrieval:
- VariableRetrieval { result = val[0] }
- | Scope CurlyBraceName { result = make_node(val) { |v| Riml::GetCurlyBraceNameNode.new(v[0], v[1]) } }
- ;
-
- UnletVariable:
- UNLET VariableRetrieval { result = make_node(val) { |v| Riml::UnletVariableNode.new('!', [ v[1] ]) } }
- | UNLET_BANG VariableRetrieval { result = make_node(val) { |v| Riml::UnletVariableNode.new('!', [ v[1] ]) } }
- | UnletVariable VariableRetrieval { result = val[0] << val[1] }
- ;
-
- CurlyBraceName:
- CurlyBraceVarPart { result = make_node(val) { |v| Riml::CurlyBraceVariable.new([ v[0] ]) } }
- | IDENTIFIER CurlyBraceName { result = make_node(val) { |v| Riml::CurlyBraceVariable.new([ Riml::CurlyBracePart.new(v[0]), v[1] ]) } }
- | CurlyBraceName IDENTIFIER { result = val[0] << make_node(val) { |v| Riml::CurlyBracePart.new(v[1]) } }
- | CurlyBraceName CurlyBraceVarPart { result = val[0] << val[1] }
- ;
-
- CurlyBraceVarPart:
- '{' PossibleStringValue '}' { result = make_node(val) { |v| Riml::CurlyBracePart.new(v[1]) } }
- | '{' PossibleStringValue CurlyBraceVarPart '}' { result = make_node(val) { |v| Riml::CurlyBracePart.new([v[1], v[2]]) } }
- | '{' CurlyBraceVarPart PossibleStringValue '}' { result = make_node(val) { |v| Riml::CurlyBracePart.new([v[1], v[2]]) } }
- ;
-
- # Method definition
- # [SID, scope_modifier, name, parameters, keyword, expressions]
- Def:
- FunctionType SIDAndScope DefCallIdentifier DefKeywords Block END { result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], [], v[3], v[4]) } }
- | FunctionType SIDAndScope DefCallIdentifier '(' ParamList ')' DefKeywords Block END { result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], v[4], v[6], v[7]) } }
- | FunctionType SIDAndScope DefCallIdentifier '(' SPLAT_PARAM ')' DefKeywords Block END { result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], [v[4]], v[6], v[7]) } }
- | FunctionType SIDAndScope DefCallIdentifier '(' ParamList ',' SPLAT_PARAM ')' DefKeywords Block END { result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], v[4] << v[6], v[8], v[9]) } }
- ;
-
- FunctionType:
- DEF { result = "DefNode" }
- | DEF_BANG { result = "DefNode" }
- | DEFM { result = "DefMethodNode" }
- ;
-
- DefCallIdentifier:
- # use '' for first argument instead of nil in order to avoid a double scope-modifier
- CurlyBraceName { result = make_node(val) { |v| Riml::GetCurlyBraceNameNode.new('', v[0]) } }
- | IDENTIFIER { result = val[0] }
- ;
-
- # Example: 'range', 'dict' or 'abort' after function definition
- DefKeywords:
- IDENTIFIER { result = [val[0]] }
- | DefKeywords IDENTIFIER { result = val[0] << val[1] }
- | /* nothing */ { result = nil }
- ;
-
- ParamList:
- /* nothing */ { result = [] }
- | IDENTIFIER { result = val }
- | DefaultParam { result = val }
- | ParamList ',' IDENTIFIER { result = val[0] << val[2] }
- | ParamList ',' DefaultParam { result = val[0] << val[2] }
- ;
-
- DefaultParam:
- IDENTIFIER '=' Expression { result = make_node(val) { |v| Riml::DefaultParamNode.new(v[0], v[2]) } }
- ;
-
- Return:
- RETURN Returnable { result = make_node(val) { |v| Riml::ReturnNode.new(v[1]) } }
- | RETURN Returnable IF Expression { result = make_node(val) { |v| Riml::IfNode.new(v[3], Nodes.new([ReturnNode.new(v[1])])) } }
- | RETURN Returnable UNLESS Expression { result = make_node(val) { |v| Riml::UnlessNode.new(v[3], Nodes.new([ReturnNode.new(v[1])])) } }
- ;
-
- Returnable:
- /* nothing */ { result = nil }
- | Expression { result = val[0] }
- ;
-
- EndScript:
- FINISH { result = make_node(val) { |_| Riml::FinishNode.new } }
- ;
-
- # [expression, expressions]
- If:
- IF Expression IfBlock END { result = make_node(val) { |v| Riml::IfNode.new(v[1], v[2]) } }
- | IF Expression THEN Expression END { result = make_node(val) { |v| Riml::IfNode.new(v[1], Riml::Nodes.new([v[3]])) } }
- | Expression IF Expression { result = make_node(val) { |v| Riml::IfNode.new(v[2], Riml::Nodes.new([v[0]])) } }
- ;
-
- Unless:
- UNLESS Expression IfBlock END { result = make_node(val) { |v| Riml::UnlessNode.new(v[1], v[2]) } }
- | UNLESS Expression THEN Expression END { result = make_node(val) { |v| Riml::UnlessNode.new(v[1], Riml::Nodes.new([v[3]])) } }
- | Expression UNLESS Expression { result = make_node(val) { |v| Riml::UnlessNode.new(v[2], Riml::Nodes.new([v[0]])) } }
- ;
-
- Ternary:
- Expression '?' Expression ':' Expression { result = make_node(val) { |v| Riml::TernaryOperatorNode.new([v[0], v[2], v[4]]) } }
- ;
-
- While:
- WHILE Expression Block END { result = make_node(val) { |v| Riml::WhileNode.new(v[1], v[2]) } }
- ;
-
- LoopKeyword:
- BREAK { result = make_node(val) { |_| Riml::BreakNode.new } }
- | CONTINUE { result = make_node(val) { |_| Riml::ContinueNode.new } }
- ;
-
- Until:
- UNTIL Expression Block END { result = make_node(val) { |v| Riml::UntilNode.new(v[1], v[2]) } }
- ;
-
- For:
- FOR SimpleVariableRetrieval IN Expression Block END { result = make_node(val) { |v| Riml::ForNode.new(v[1], v[3], v[4]) } }
- | FOR List IN Expression Block END { result = make_node(val) { |v| Riml::ForNode.new(v[1], v[3], v[4]) } }
- | FOR ListUnpack IN Expression Block END { result = make_node(val) { |v| Riml::ForNode.new(v[1], v[3], v[4]) } }
- ;
-
- Try:
- TRY Block END { result = make_node(val) { |v| Riml::TryNode.new(v[1], nil, nil) } }
- | TRY Block Catch END { result = make_node(val) { |v| Riml::TryNode.new(v[1], v[2], nil) } }
- | TRY Block Catch FINALLY Block END { result = make_node(val) { |v| Riml::TryNode.new(v[1], v[2], v[4]) } }
- ;
-
- Catch:
- /* nothing */ { result = nil }
- | CATCH Block { result = [ make_node(val) { |v| Riml::CatchNode.new(nil, v[1]) } ] }
- | CATCH Catchable Block { result = [ make_node(val) { |v| Riml::CatchNode.new(v[1], v[2]) } ] }
- | Catch CATCH Block { result = val[0] << make_node(val) { |v| Riml::CatchNode.new(nil, v[2]) } }
- | Catch CATCH Catchable Block { result = val[0] << make_node(val) { |v| Riml::CatchNode.new(v[2], v[3]) } }
- ;
-
- Catchable:
- Regexp { result = val[0] }
- | String { result = val[0] }
- ;
-
- # [expressions]
- # expressions list could contain an ElseNode, which contains expressions
- # itself
- Block:
- NEWLINE Statements { result = val[1] }
- | NEWLINE { result = make_node(val) { |_| Riml::Nodes.new([]) } }
- ;
-
- IfBlock:
- Block { result = val[0] }
- | NEWLINE Statements ElseBlock { result = val[1] << val[2] }
- | NEWLINE Statements ElseifBlock { result = val[1] << val[2] }
- | NEWLINE Statements ElseifBlock ElseBlock { result = val[1] << val[2] << val[3] }
- ;
-
- ElseBlock:
- ELSE NEWLINE Statements { result = make_node(val) { |v| Riml::ElseNode.new(v[2]) } }
- ;
-
- ElseifBlock:
- ELSEIF Expression NEWLINE Statements { result = make_node(val) { |v| Riml::Nodes.new([Riml::ElseifNode.new(v[1], v[3])]) } }
- | ElseifBlock ELSEIF Expression NEWLINE Statements { result = val[0] << make_node(val) { |v| Riml::ElseifNode.new(v[2], v[4]) } }
- ;
-
- ClassDefinition:
- CLASS Scope IDENTIFIER Block END { result = make_node(val) { |v| Riml::ClassDefinitionNode.new(v[1], v[2], nil, v[3]) } }
- | CLASS Scope IDENTIFIER '<' Scope IDENTIFIER Block END { result = make_node(val) { |v| Riml::ClassDefinitionNode.new(v[1], v[2], (v[4] || ClassDefinitionNode::DEFAULT_SCOPE_MODIFIER) + v[5], v[6]) } }
- ;
-
- ObjectInstantiation:
- NEW ObjectInstantiationCall { result = make_node(val) { |v| Riml::ObjectInstantiationNode.new(v[1]) } }
- ;
-
- Super:
- SUPER '(' ArgListWithSplat ')' { result = make_node(val) { |v| Riml::SuperNode.new(v[2], true) } }
- | SUPER { result = make_node(val) { |_| Riml::SuperNode.new([], false) } }
- ;
-
- ExLiteral:
- EX_LITERAL { result = make_node(val) { |v| Riml::ExLiteralNode.new(v[0]) } }
- ;
-end
-
----- header
- require File.expand_path("../lexer", __FILE__)
- require File.expand_path("../nodes", __FILE__)
- require File.expand_path("../errors", __FILE__)
- require File.expand_path("../ast_rewriter", __FILE__)
----- inner
- # This code will be put as-is in the parser class
-
- attr_accessor :ast_rewriter
- attr_writer :options
-
- # The Parser and AST_Rewriter share this same hash of options
- def options
- @options ||= {}
- end
-
- def self.ast_cache
- @ast_cache
- end
- @ast_cache = {}
-
- # parses tokens or code into output nodes
- def parse(object, ast_rewriter = Riml::AST_Rewriter.new, filename = nil, included = false)
- if (ast = self.class.ast_cache[filename])
- else
- if tokens?(object)
- @tokens = object
- elsif code?(object)
- @lexer = Riml::Lexer.new(object, filename, true)
- end
-
- begin
- ast = do_parse
- rescue Racc::ParseError => e
- raise unless @lexer
- if (invalid_token = @lexer.prev_token_is_keyword?)
- warning = "#{invalid_token.inspect} is a keyword, and cannot " \
- "be used as a variable name"
- end
- error_msg = e.message
- error_msg << "\nWARNING: #{warning}" if warning
- error = Riml::ParseError.new(error_msg, @lexer.filename, @lexer.lineno)
- raise error
- end
- self.class.ast_cache[filename] = ast if filename
- end
- @ast_rewriter ||= ast_rewriter
- return ast unless @ast_rewriter
- @ast_rewriter.ast = ast.dup
- @ast_rewriter.options ||= options
- @ast_rewriter.rewrite(filename, included)
- @ast_rewriter.ast
- end
-
- # get the next token from either the list of tokens provided, or
- # the lexer getting the next token
- def next_token
- return @tokens.shift unless @lexer
- token = @lexer.next_token
- if token && @lexer.parser_info
- @current_parser_info = token.pop
- end
- token
- end
-
- private
-
- def tokens?(object)
- Array === object
- end
-
- def code?(object)
- String === object
- end
-
- def make_node(racc_val)
- node = yield racc_val
- node.parser_info = @current_parser_info
- node
- end
diff --git a/test/racc/assets/rrconf.y b/test/racc/assets/rrconf.y
deleted file mode 100644
index baf9249a77..0000000000
--- a/test/racc/assets/rrconf.y
+++ /dev/null
@@ -1,14 +0,0 @@
-# 1 s/r conflict and 1 r/r conflict
-
-class A
-rule
-
-target: a
-
-a :
- | a list
-
-list :
- | list ITEM
-
-end
diff --git a/test/racc/assets/ruby18.y b/test/racc/assets/ruby18.y
deleted file mode 100644
index eceb253298..0000000000
--- a/test/racc/assets/ruby18.y
+++ /dev/null
@@ -1,1943 +0,0 @@
-# Copyright (c) 2013 Peter Zotov <whitequark@whitequark.org>
-#
-# Parts of the source are derived from ruby_parser:
-# Copyright (c) Ryan Davis, seattle.rb
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Parser::Ruby18
-
-token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kRETURN kYIELD kSUPER
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
- k__FILE__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tNTH_REF
- tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT tREGEXP_END tUPLUS
- tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP
- tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF tASET tLSHFT tRSHFT
- tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN tLPAREN2 tRPAREN tLPAREN_ARG
- tLBRACK tLBRACK2 tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2
- tTILDE tPERCENT tDIVIDE tPLUS tMINUS tLT tGT tPIPE tBANG tCARET
- tLCURLY tRCURLY tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
- tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END tSTRING
- tSYMBOL tREGEXP_OPT tNL tEH tCOLON tCOMMA tSPACE tSEMI
-
-prechigh
- right tBANG tTILDE tUPLUS
- right tPOW
- right tUMINUS_NUM tUMINUS
- left tSTAR2 tDIVIDE tPERCENT
- left tPLUS tMINUS
- left tLSHFT tRSHFT
- left tAMPER2
- left tPIPE tCARET
- left tGT tGEQ tLT tLEQ
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
- left tANDOP
- left tOROP
- nonassoc tDOT2 tDOT3
- right tEH tCOLON
- left kRESCUE_MOD
- right tEQL tOP_ASGN
- nonassoc kDEFINED
- right kNOT
- left kOR kAND
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
- nonassoc tLBRACE_ARG
- nonassoc tLOWEST
-preclow
-
-rule
-
- program: compstmt
- {
- result = val[0]
- }
-
- bodystmt: compstmt opt_rescue opt_else opt_ensure
- {
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
- }
-
- compstmt: stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- stmts: # nothing
- {
- result = []
- }
- | stmt
- {
- result = [ val[0] ]
- }
- | error stmt
- {
- result = [ val[1] ]
- }
- | stmts terms stmt
- {
- result = val[0] << val[2]
- }
-
- stmt: kALIAS fitem
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = @builder.alias(val[0], val[1], val[3])
- }
- | kALIAS tGVAR tGVAR
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
- }
- | kALIAS tGVAR tBACK_REF
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
- }
- | kALIAS tGVAR tNTH_REF
- {
- diagnostic :error, :nth_ref_alias, nil, val[2]
- }
- | kUNDEF undef_list
- {
- result = @builder.undef_method(val[0], val[1])
- }
- | stmt kIF_MOD expr_value
- {
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
- }
- | stmt kUNLESS_MOD expr_value
- {
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
- }
- | stmt kWHILE_MOD expr_value
- {
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
- }
- | stmt kUNTIL_MOD expr_value
- {
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
- }
- | stmt kRESCUE_MOD stmt
- {
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
- }
- | klBEGIN tLCURLY compstmt tRCURLY
- {
- if in_def?
- diagnostic :error, :begin_in_method, nil, val[0]
- end
-
- result = @builder.preexe(val[0], val[1], val[2], val[3])
- }
- | klEND tLCURLY compstmt tRCURLY
- {
- result = @builder.postexe(val[0], val[1], val[2], val[3])
- }
- | lhs tEQL command_call
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | mlhs tEQL command_call
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN command_call
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | primary_value tLBRACK2 aref_args tRBRACK tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | backref tOP_ASGN command_call
- {
- @builder.op_assign(val[0], val[1], val[2])
- }
- | lhs tEQL mrhs
- {
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | mlhs tEQL arg_value
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | mlhs tEQL mrhs
- {
- result = @builder.multi_assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | expr
-
- expr: command_call
- | expr kAND expr
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | expr kOR expr
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kNOT expr
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | tBANG command_call
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | arg
-
- expr_value: expr
-
- command_call: command
- | block_command
- | kRETURN call_args
- {
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
- }
- | kBREAK call_args
- {
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
- }
- | kNEXT call_args
- {
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
- }
-
- block_command: block_call
- | block_call tDOT operation2 command_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | block_call tCOLON2 operation2 command_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
-
- cmd_brace_block: tLBRACE_ARG
- {
- @static_env.extend_dynamic
- }
- opt_block_var compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- command: operation command_args =tLOWEST
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
- }
- | operation command_args cmd_brace_block
- {
- lparen_t, args, rparen_t = val[1]
- method_call = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
-
- begin_t, block_args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, block_args, body, end_t)
- }
- | primary_value tDOT operation2 command_args =tLOWEST
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- }
- | primary_value tDOT operation2 command_args cmd_brace_block
- {
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, block_args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, block_args, body, end_t)
- }
- | primary_value tCOLON2 operation2 command_args =tLOWEST
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
- {
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, block_args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, block_args, body, end_t)
- }
- | kSUPER command_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
- }
- | kYIELD command_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:yield, val[0],
- lparen_t, args, rparen_t)
- }
-
- mlhs: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_entry tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_entry: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_entry tRPAREN
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- mlhs_basic: mlhs_head
- {
- result = val[0]
- }
- | mlhs_head mlhs_item
- {
- result = val[0] << val[1]
- }
- | mlhs_head tSTAR mlhs_node
- {
- result = val[0] << @builder.splat(val[1], val[2])
- }
- | mlhs_head tSTAR
- {
- result = val[0] << @builder.splat(val[1])
- }
- | tSTAR mlhs_node
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | tSTAR
- {
- result = [ @builder.splat(val[0]) ]
- }
-
- mlhs_item: mlhs_node
- | tLPAREN mlhs_entry tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_head: mlhs_item tCOMMA
- {
- result = [ val[0] ]
- }
- | mlhs_head mlhs_item tCOMMA
- {
- result = val[0] << val[1]
- }
-
- mlhs_node: variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 aref_args tRBRACK
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- lhs: variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 aref_args tRBRACK
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- cname: tIDENTIFIER
- {
- diagnostic :error, :module_name_const, nil, val[0]
- }
- | tCONSTANT
-
- cpath: tCOLON3 cname
- {
- result = @builder.const_global(val[0], val[1])
- }
- | cname
- {
- result = @builder.const(val[0])
- }
- | primary_value tCOLON2 cname
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
-
- fname: tIDENTIFIER | tCONSTANT | tFID
- | op
- | reswords
-
- fsym: fname
- {
- result = @builder.symbol(val[0])
- }
- | symbol
-
- fitem: fsym
- | dsym
-
- undef_list: fitem
- {
- result = [ val[0] ]
- }
- | undef_list tCOMMA
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = val[0] << val[3]
- }
-
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
- | tMATCH | tGT | tGEQ | tLT | tLEQ | tLSHFT
- | tRSHFT | tPLUS | tMINUS | tSTAR2 | tSTAR | tDIVIDE
- | tPERCENT | tPOW | tTILDE | tUPLUS | tUMINUS | tAREF
- | tASET | tBACK_REF2
-
- reswords: k__LINE__ | k__FILE__ | klBEGIN | klEND | kALIAS | kAND
- | kBEGIN | kBREAK | kCASE | kCLASS | kDEF | kDEFINED
- | kDO | kELSE | kELSIF | kEND | kENSURE | kFALSE
- | kFOR | kIN | kMODULE | kNEXT | kNIL | kNOT
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF
- | kSUPER | kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD
- | kIF | kUNLESS | kWHILE | kUNTIL
-
- arg: lhs tEQL arg
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
- }
- | var_lhs tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | primary_value tLBRACK2 aref_args tRBRACK tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
- {
- diagnostic :error, :dynamic_const, nil, val[2], [ val[3] ]
- }
- | tCOLON3 tCONSTANT tOP_ASGN arg
- {
- diagnostic :error, :dynamic_const, nil, val[1], [ val[2] ]
- }
- | backref tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | arg tDOT2 arg
- {
- result = @builder.range_inclusive(val[0], val[1], val[2])
- }
- | arg tDOT3 arg
- {
- result = @builder.range_exclusive(val[0], val[1], val[2])
- }
- | arg tPLUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMINUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tSTAR2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tDIVIDE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPERCENT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPOW arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tUMINUS_NUM tINTEGER tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.integer(val[1]),
- val[2], val[3]))
- }
- | tUMINUS_NUM tFLOAT tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.float(val[1]),
- val[2], val[3]))
- }
- | tUPLUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | tUMINUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tPIPE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCARET arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tAMPER2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCMP arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tNEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMATCH arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tNMATCH arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tBANG arg
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | tTILDE arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tLSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tRSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tANDOP arg
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | arg tOROP arg
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kDEFINED opt_nl arg
- {
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
- }
- | arg tEH arg tCOLON arg
- {
- result = @builder.ternary(val[0], val[1],
- val[2], val[3], val[4])
- }
- | primary
-
- arg_value: arg
-
- aref_args: none
- | command opt_nl
- {
- result = [ val[0] ]
- }
- | args trailer
- {
- result = val[0]
- }
- | args tCOMMA tSTAR arg opt_nl
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | assocs trailer
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
- | tSTAR arg opt_nl
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- paren_args: tLPAREN2 none tRPAREN
- {
- result = [ val[0], [], val[2] ]
- }
- | tLPAREN2 call_args opt_nl tRPAREN
- {
- result = [ val[0], val[1], val[3] ]
- }
- | tLPAREN2 block_call opt_nl tRPAREN
- {
- result = [ val[0], [ val[1] ], val[3] ]
- }
- | tLPAREN2 args tCOMMA block_call opt_nl tRPAREN
- {
- result = [ val[0], val[1] << val[3], val[5] ]
- }
-
- opt_paren_args: # nothing
- {
- result = [ nil, [], nil ]
- }
- | paren_args
-
- call_args: command
- {
- result = [ val[0] ]
- }
- | args opt_block_arg
- {
- result = val[0].concat(val[1])
- }
- | args tCOMMA tSTAR arg_value opt_block_arg
- {
- result = val[0].concat(
- [ @builder.splat(val[2], val[3]),
- *val[4] ])
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil),
- *val[1] ]
- }
- | assocs tCOMMA tSTAR arg_value opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil),
- @builder.splat(val[2], val[3]),
- *val[4] ]
- }
- | args tCOMMA assocs opt_block_arg
- {
- result = val[0].concat(
- [ @builder.associate(nil, val[2], nil),
- *val[3] ])
- }
- | args tCOMMA assocs tCOMMA tSTAR arg opt_block_arg
- {
- result = val[0].concat(
- [ @builder.associate(nil, val[2], nil),
- @builder.splat(val[4], val[5]),
- *val[6] ])
- }
- | tSTAR arg_value opt_block_arg
- {
- result = [ @builder.splat(val[0], val[1]),
- *val[2] ]
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- call_args2: arg_value tCOMMA args opt_block_arg
- {
- result = [ val[0], *val[2].concat(val[3]) ]
- }
- | arg_value tCOMMA block_arg
- {
- result = [ val[0], val[2] ]
- }
- | arg_value tCOMMA tSTAR arg_value opt_block_arg
- {
- result = [ val[0],
- @builder.splat(val[2], val[3]),
- *val[4] ]
- }
- | arg_value tCOMMA args tCOMMA tSTAR arg_value opt_block_arg
- {
- result = [ val[0],
- *val[2].
- push(@builder.splat(val[4], val[5])).
- concat(val[6]) ]
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil),
- *val[1] ]
- }
- | assocs tCOMMA tSTAR arg_value opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil),
- @builder.splat(val[2], val[3]),
- *val[4] ]
- }
- | arg_value tCOMMA assocs opt_block_arg
- {
- result = [ val[0],
- @builder.associate(nil, val[2], nil),
- *val[3] ]
- }
- | arg_value tCOMMA args tCOMMA assocs opt_block_arg
- {
- result = [ val[0],
- *val[2].
- push(@builder.associate(nil, val[4], nil)).
- concat(val[5]) ]
- }
- | arg_value tCOMMA assocs tCOMMA tSTAR arg_value opt_block_arg
- {
- result = [ val[0],
- @builder.associate(nil, val[2], nil),
- @builder.splat(val[4], val[5]),
- *val[6] ]
- }
- | arg_value tCOMMA args tCOMMA assocs tCOMMA tSTAR arg_value opt_block_arg
- {
- result = [ val[0],
- *val[2].
- push(@builder.associate(nil, val[4], nil)).
- push(@builder.splat(val[6], val[7])).
- concat(val[8]) ]
- }
- | tSTAR arg_value opt_block_arg
- {
- result = [ @builder.splat(val[0], val[1]),
- *val[2] ]
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- command_args: {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
- }
- open_args
- {
- @lexer.cmdarg = val[0]
-
- result = val[1]
- }
-
- open_args: call_args
- {
- result = [ nil, val[0], nil ]
- }
- | tLPAREN_ARG
- {
- @lexer.state = :expr_endarg
- }
- tRPAREN
- {
- result = [ val[0], [], val[2] ]
- }
- | tLPAREN_ARG call_args2
- {
- @lexer.state = :expr_endarg
- }
- tRPAREN
- {
- result = [ val[0], val[1], val[3] ]
- }
-
- block_arg: tAMPER arg_value
- {
- result = @builder.block_pass(val[0], val[1])
- }
-
- opt_block_arg: tCOMMA block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- args: arg_value
- {
- result = [ val[0] ]
- }
- | args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
-
- mrhs: args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- primary: literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | var_ref
- | backref
- | tFID
- {
- result = @builder.call_method(nil, nil, val[0])
- }
- | kBEGIN bodystmt kEND
- {
- result = @builder.begin_keyword(val[0], val[1], val[2])
- }
- | tLPAREN_ARG expr
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[4])
- }
- | tLPAREN compstmt tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.const_global(val[0], val[1])
- }
- | primary_value tLBRACK2 aref_args tRBRACK
- {
- result = @builder.index(val[0], val[1], val[2], val[3])
- }
- | tLBRACK aref_args tRBRACK
- {
- result = @builder.array(val[0], val[1], val[2])
- }
- | tLBRACE assoc_list tRCURLY
- {
- result = @builder.associate(val[0], val[1], val[2])
- }
- | kRETURN
- {
- result = @builder.keyword_cmd(:return, val[0])
- }
- | kYIELD tLPAREN2 call_args tRPAREN
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
- }
- | kYIELD tLPAREN2 tRPAREN
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
- }
- | kYIELD
- {
- result = @builder.keyword_cmd(:yield, val[0])
- }
- | kDEFINED opt_nl tLPAREN2 expr tRPAREN
- {
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
- }
- | operation brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | method_call
- | method_call brace_block
- {
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
- }
- | kIF expr_value then compstmt if_tail kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
- }
- | kUNLESS expr_value then compstmt opt_else kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
- }
- | kWHILE
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kUNTIL
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kCASE expr_value opt_terms case_body kEND
- {
- when_bodies = val[3][0..-2]
- else_t, else_body = val[3][-1]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
- }
- | kCASE opt_terms case_body kEND
- {
- when_bodies = val[2][0..-2]
- else_t, else_body = val[2][-1]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
- }
- | kCASE opt_terms kELSE compstmt kEND
- {
- result = @builder.case(val[0], nil,
- [], val[2], val[3],
- val[4])
- }
- | kFOR for_var kIN
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
- }
- | kCLASS cpath superclass
- {
- @static_env.extend_static
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @static_env.unextend
- }
- | kCLASS tLSHFT expr term
- {
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
- }
- bodystmt kEND
- {
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @static_env.unextend
-
- @def_level = val[4]
- }
- | kMODULE cpath
- {
- @static_env.extend_static
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @static_env.unextend
- }
- | kDEF fname
- {
- @def_level += 1
- @static_env.extend_static
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @static_env.unextend
- @def_level -= 1
- }
- | kDEF singleton dot_or_colon
- {
- @lexer.state = :expr_fname
- }
- fname
- {
- @def_level += 1
- @static_env.extend_static
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @static_env.unextend
- @def_level -= 1
- }
- | kBREAK
- {
- result = @builder.keyword_cmd(:break, val[0])
- }
- | kNEXT
- {
- result = @builder.keyword_cmd(:next, val[0])
- }
- | kREDO
- {
- result = @builder.keyword_cmd(:redo, val[0])
- }
- | kRETRY
- {
- result = @builder.keyword_cmd(:retry, val[0])
- }
-
- primary_value: primary
-
- then: term
- | tCOLON
- | kTHEN
- | term kTHEN
- {
- result = val[1]
- }
-
- do: term
- | tCOLON
- | kDO_COND
-
- if_tail: opt_else
- | kELSIF expr_value then compstmt if_tail
- {
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
- }
-
- opt_else: none
- | kELSE compstmt
- {
- result = val
- }
-
- for_var: lhs
- | mlhs
-
- block_par: mlhs_item
- {
- result = [ @builder.arg_expr(val[0]) ]
- }
- | block_par tCOMMA mlhs_item
- {
- result = val[0] << @builder.arg_expr(val[2])
- }
-
- block_var: block_par
- | block_par tCOMMA
- | block_par tCOMMA tAMPER lhs
- {
- result = val[0].
- push(@builder.blockarg_expr(val[2], val[3]))
- }
- | block_par tCOMMA tSTAR lhs tCOMMA tAMPER lhs
- {
- result = val[0].
- push(@builder.restarg_expr(val[2], val[3])).
- push(@builder.blockarg_expr(val[5], val[6]))
- }
- | block_par tCOMMA tSTAR tCOMMA tAMPER lhs
- {
- result = val[0].
- push(@builder.restarg_expr(val[2])).
- push(@builder.blockarg_expr(val[4], val[5]))
- }
- | block_par tCOMMA tSTAR lhs
- {
- result = val[0].
- push(@builder.restarg_expr(val[2], val[3]))
- }
- | block_par tCOMMA tSTAR
- {
- result = val[0].
- push(@builder.restarg_expr(val[2]))
- }
- | tSTAR lhs tCOMMA tAMPER lhs
- {
- result = [ @builder.restarg_expr(val[0], val[1]),
- @builder.blockarg_expr(val[3], val[4]) ]
- }
- | tSTAR tCOMMA tAMPER lhs
- {
- result = [ @builder.restarg_expr(val[0]),
- @builder.blockarg_expr(val[2], val[3]) ]
- }
- | tSTAR lhs
- {
- result = [ @builder.restarg_expr(val[0], val[1]) ]
- }
- | tSTAR
- {
- result = [ @builder.restarg_expr(val[0]) ]
- }
- | tAMPER lhs
- {
- result = [ @builder.blockarg_expr(val[0], val[1]) ]
- }
- ;
-
- opt_block_var: # nothing
- {
- result = @builder.args(nil, [], nil)
- }
- | tPIPE tPIPE
- {
- result = @builder.args(val[0], [], val[1])
- }
- | tOROP
- {
- result = @builder.args(val[0], [], val[0])
- }
- | tPIPE block_var tPIPE
- {
- result = @builder.args(val[0], val[1], val[2], false)
- }
-
- do_block: kDO_BLOCK
- {
- @static_env.extend_dynamic
- }
- opt_block_var compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- block_call: command do_block
- {
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
- }
- | block_call tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | block_call tCOLON2 operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
-
- method_call: operation paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
- }
- | primary_value tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation3
- {
- result = @builder.call_method(val[0], val[1], val[2])
- }
- | kSUPER paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
- }
- | kSUPER
- {
- result = @builder.keyword_cmd(:zsuper, val[0])
- }
-
- brace_block: tLCURLY
- {
- @static_env.extend_dynamic
- }
- opt_block_var compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
- | kDO
- {
- @static_env.extend_dynamic
- }
- opt_block_var compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- case_body: kWHEN when_args then compstmt cases
- {
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
- }
-
- when_args: args
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- cases: opt_else
- {
- result = [ val[0] ]
- }
- | case_body
-
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
- {
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
- }
- | # nothing
- {
- result = []
- }
-
- exc_list: arg_value
- {
- result = [ val[0] ]
- }
- | mrhs
- | none
-
- exc_var: tASSOC lhs
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- opt_ensure: kENSURE compstmt
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- literal: numeric
- | symbol
- | dsym
-
- strings: string
- {
- result = @builder.string_compose(nil, val[0], nil)
- }
-
- string: string1
- {
- result = [ val[0] ]
- }
- | string string1
- {
- result = val[0] << val[1]
- }
-
- string1: tSTRING_BEG string_contents tSTRING_END
- {
- result = @builder.string_compose(val[0], val[1], val[2])
- }
- | tSTRING
- {
- result = @builder.string(val[0])
- }
-
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
- {
- result = @builder.xstring_compose(val[0], val[1], val[2])
- }
-
- regexp: tREGEXP_BEG xstring_contents tSTRING_END tREGEXP_OPT
- {
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
- }
-
- words: tWORDS_BEG word_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- word_list: # nothing
- {
- result = []
- }
- | word_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- word: string_content
- {
- result = [ val[0] ]
- }
- | word string_content
- {
- result = val[0] << val[1]
- }
-
- qwords: tQWORDS_BEG qword_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- qword_list: # nothing
- {
- result = []
- }
- | qword_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.string_internal(val[1])
- }
-
- string_contents: # nothing
- {
- result = []
- }
- | string_contents string_content
- {
- result = val[0] << val[1]
- }
-
-xstring_contents: # nothing
- {
- result = []
- }
- | xstring_contents string_content
- {
- result = val[0] << val[1]
- }
-
- string_content: tSTRING_CONTENT
- {
- result = @builder.string_internal(val[0])
- }
- | tSTRING_DVAR string_dvar
- {
- result = val[1]
- }
- | tSTRING_DBEG
- {
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
- }
- compstmt tRCURLY
- {
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
- }
-
- string_dvar: tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | backref
-
-
- symbol: tSYMBOL
- {
- result = @builder.symbol(val[0])
- }
-
- dsym: tSYMBEG xstring_contents tSTRING_END
- {
- result = @builder.symbol_compose(val[0], val[1], val[2])
- }
-
- numeric: tINTEGER
- {
- result = @builder.integer(val[0])
- }
- | tFLOAT
- {
- result = @builder.float(val[0])
- }
- | tUMINUS_NUM tINTEGER =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.integer(val[1]))
- }
- | tUMINUS_NUM tFLOAT =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.float(val[1]))
- }
-
- variable: tIDENTIFIER
- {
- result = @builder.ident(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | tCONSTANT
- {
- result = @builder.const(val[0])
- }
- | kNIL
- {
- result = @builder.nil(val[0])
- }
- | kSELF
- {
- result = @builder.self(val[0])
- }
- | kTRUE
- {
- result = @builder.true(val[0])
- }
- | kFALSE
- {
- result = @builder.false(val[0])
- }
- | k__FILE__
- {
- result = @builder.__FILE__(val[0])
- }
- | k__LINE__
- {
- result = @builder.__LINE__(val[0])
- }
-
- var_ref: variable
- {
- result = @builder.accessible(val[0])
- }
-
- var_lhs: variable
- {
- result = @builder.assignable(val[0])
- }
-
- backref: tNTH_REF
- {
- result = @builder.nth_ref(val[0])
- }
- | tBACK_REF
- {
- result = @builder.back_ref(val[0])
- }
-
- superclass: term
- {
- result = nil
- }
- | tLT expr_value term
- {
- result = [ val[0], val[1] ]
- }
- | error term
- {
- yyerrok
- result = nil
- }
-
- f_arglist: tLPAREN2 f_args opt_nl tRPAREN
- {
- result = @builder.args(val[0], val[1], val[3])
-
- @lexer.state = :expr_beg
- }
- | f_args term
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
- | # nothing
- {
- result = []
- }
-
- f_norm_arg: tCONSTANT
- {
- diagnostic :error, :argument_const, nil, val[0]
- }
- | tIVAR
- {
- diagnostic :error, :argument_ivar, nil, val[0]
- }
- | tGVAR
- {
- diagnostic :error, :argument_gvar, nil, val[0]
- }
- | tCVAR
- {
- diagnostic :error, :argument_cvar, nil, val[0]
- }
- | tIDENTIFIER
- {
- @static_env.declare val[0][0]
-
- result = @builder.arg(val[0])
- }
-
- f_arg: f_norm_arg
- {
- result = [ val[0] ]
- }
- | f_arg tCOMMA f_norm_arg
- {
- result = val[0] << val[2]
- }
-
- f_opt: tIDENTIFIER tEQL arg_value
- {
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_optarg: f_opt
- {
- result = [ val[0] ]
- }
- | f_optarg tCOMMA f_opt
- {
- result = val[0] << val[2]
- }
-
- restarg_mark: tSTAR2 | tSTAR
-
- f_rest_arg: restarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | restarg_mark
- {
- result = [ @builder.restarg(val[0]) ]
- }
-
- blkarg_mark: tAMPER2 | tAMPER
-
- f_block_arg: blkarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
- }
-
- opt_f_block_arg: tCOMMA f_block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- singleton: var_ref
- | tLPAREN2 expr opt_nl tRPAREN
- {
- result = val[1]
- }
-
- assoc_list: # nothing
- {
- result = []
- }
- | assocs trailer
- {
- result = val[0]
- }
- | args trailer
- {
- result = @builder.pair_list_18(val[0])
- }
-
- assocs: assoc
- {
- result = [ val[0] ]
- }
- | assocs tCOMMA assoc
- {
- result = val[0] << val[2]
- }
-
- assoc: arg_value tASSOC arg_value
- {
- result = @builder.pair(val[0], val[1], val[2])
- }
-
- operation: tIDENTIFIER | tCONSTANT | tFID
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
- operation3: tIDENTIFIER | tFID | op
- dot_or_colon: tDOT | tCOLON2
- opt_terms: | terms
- opt_nl: | tNL
- trailer: | tNL | tCOMMA
-
- term: tSEMI
- {
- yyerrok
- }
- | tNL
-
- terms: term
- | terms tSEMI
-
- none: # nothing
- {
- result = nil
- }
-
-end
-
----- header
-
-require 'parser'
-
----- inner
-
- def version
- 18
- end
-
- def default_encoding
- Encoding::BINARY if defined? Encoding
- end
diff --git a/test/racc/assets/ruby19.y b/test/racc/assets/ruby19.y
deleted file mode 100644
index b405c952e7..0000000000
--- a/test/racc/assets/ruby19.y
+++ /dev/null
@@ -1,2174 +0,0 @@
-# Copyright (c) 2013 Peter Zotov <whitequark@whitequark.org>
-#
-# Parts of the source are derived from ruby_parser:
-# Copyright (c) Ryan Davis, seattle.rb
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Parser::Ruby19
-
-token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
- tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
- tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
- tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
- tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
- tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
- tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
- tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
- tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tREGEXP_OPT
- tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
- tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG
- tCHARACTER
-
-prechigh
- right tBANG tTILDE tUPLUS
- right tPOW
- right tUMINUS_NUM tUMINUS
- left tSTAR2 tDIVIDE tPERCENT
- left tPLUS tMINUS
- left tLSHFT tRSHFT
- left tAMPER2
- left tPIPE tCARET
- left tGT tGEQ tLT tLEQ
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
- left tANDOP
- left tOROP
- nonassoc tDOT2 tDOT3
- right tEH tCOLON
- left kRESCUE_MOD
- right tEQL tOP_ASGN
- nonassoc kDEFINED
- right kNOT
- left kOR kAND
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
- nonassoc tLBRACE_ARG
- nonassoc tLOWEST
-preclow
-
-rule
-
- program: top_compstmt
-
- top_compstmt: top_stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- top_stmts: # nothing
- {
- result = []
- }
- | top_stmt
- {
- result = [ val[0] ]
- }
- | top_stmts terms top_stmt
- {
- result = val[0] << val[2]
- }
- | error top_stmt
- {
- result = [ val[1] ]
- }
-
- top_stmt: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- result = @builder.preexe(val[0], val[1], val[2], val[3])
- }
-
- bodystmt: compstmt opt_rescue opt_else opt_ensure
- {
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
- }
-
- compstmt: stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- stmts: # nothing
- {
- result = []
- }
- | stmt
- {
- result = [ val[0] ]
- }
- | stmts terms stmt
- {
- result = val[0] << val[2]
- }
- | error stmt
- {
- result = [ val[1] ]
- }
-
- stmt: kALIAS fitem
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = @builder.alias(val[0], val[1], val[3])
- }
- | kALIAS tGVAR tGVAR
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
- }
- | kALIAS tGVAR tBACK_REF
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
- }
- | kALIAS tGVAR tNTH_REF
- {
- diagnostic :error, :nth_ref_alias, nil, val[2]
- }
- | kUNDEF undef_list
- {
- result = @builder.undef_method(val[0], val[1])
- }
- | stmt kIF_MOD expr_value
- {
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
- }
- | stmt kUNLESS_MOD expr_value
- {
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
- }
- | stmt kWHILE_MOD expr_value
- {
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
- }
- | stmt kUNTIL_MOD expr_value
- {
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
- }
- | stmt kRESCUE_MOD stmt
- {
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
- }
- | klEND tLCURLY compstmt tRCURLY
- {
- result = @builder.postexe(val[0], val[1], val[2], val[3])
- }
- | command_asgn
- | mlhs tEQL command_call
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN command_call
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | backref tOP_ASGN command_call
- {
- @builder.op_assign(val[0], val[1], val[2])
- }
- | lhs tEQL mrhs
- {
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | mlhs tEQL arg_value
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | mlhs tEQL mrhs
- {
- result = @builder.multi_assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | expr
-
- command_asgn: lhs tEQL command_call
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL command_asgn
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
-
- expr: command_call
- | expr kAND expr
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | expr kOR expr
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kNOT opt_nl expr
- {
- result = @builder.not_op(val[0], nil, val[2], nil)
- }
- | tBANG command_call
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | arg
-
- expr_value: expr
-
- command_call: command
- | block_command
-
- block_command: block_call
- | block_call tDOT operation2 command_args
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | block_call tCOLON2 operation2 command_args
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
-
- cmd_brace_block: tLBRACE_ARG
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- command: operation command_args =tLOWEST
- {
- result = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
- }
- | operation command_args cmd_brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
-
- begin_t, args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tDOT operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tDOT operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tCOLON2 operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | kSUPER command_args
- {
- result = @builder.keyword_cmd(:super, val[0],
- nil, val[1], nil)
- }
- | kYIELD command_args
- {
- result = @builder.keyword_cmd(:yield, val[0],
- nil, val[1], nil)
- }
- | kRETURN call_args
- {
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
- }
- | kBREAK call_args
- {
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
- }
- | kNEXT call_args
- {
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
- }
-
- mlhs: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_inner: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- mlhs_basic: mlhs_head
- | mlhs_head mlhs_item
- {
- result = val[0].
- push(val[1])
- }
- | mlhs_head tSTAR mlhs_node
- {
- result = val[0].
- push(@builder.splat(val[1], val[2]))
- }
- | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1], val[2])).
- concat(val[4])
- }
- | mlhs_head tSTAR
- {
- result = val[0].
- push(@builder.splat(val[1]))
- }
- | mlhs_head tSTAR tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1])).
- concat(val[3])
- }
- | tSTAR mlhs_node
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.splat(val[0]) ]
- }
- | tSTAR tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0]),
- *val[2] ]
- }
-
- mlhs_item: mlhs_node
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_head: mlhs_item tCOMMA
- {
- result = [ val[0] ]
- }
- | mlhs_head mlhs_item tCOMMA
- {
- result = val[0] << val[1]
- }
-
- mlhs_post: mlhs_item
- {
- result = [ val[0] ]
- }
- | mlhs_post tCOMMA mlhs_item
- {
- result = val[0] << val[2]
- }
-
- mlhs_node: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- cname: tIDENTIFIER
- {
- diagnostic :error, :module_name_const, nil, val[0]
- }
- | tCONSTANT
-
- cpath: tCOLON3 cname
- {
- result = @builder.const_global(val[0], val[1])
- }
- | cname
- {
- result = @builder.const(val[0])
- }
- | primary_value tCOLON2 cname
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
-
- fname: tIDENTIFIER | tCONSTANT | tFID
- | op
- | reswords
-
- fsym: fname
- {
- result = @builder.symbol(val[0])
- }
- | symbol
-
- fitem: fsym
- | dsym
-
- undef_list: fitem
- {
- result = [ val[0] ]
- }
- | undef_list tCOMMA
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = val[0] << val[3]
- }
-
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
- | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
- | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
- | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
-
- reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
- | kALIAS | kAND | kBEGIN | kBREAK | kCASE
- | kCLASS | kDEF | kDEFINED | kDO | kELSE
- | kELSIF | kEND | kENSURE | kFALSE | kFOR
- | kIN | kMODULE | kNEXT | kNIL | kNOT
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN
- | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
- | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
- | kUNTIL
-
- arg: lhs tEQL arg
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
- }
- | var_lhs tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.op_assign(val[0], val[1], rescue_)
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
- {
- diagnostic :error, :dynamic_const, nil, val[2], [ val[3] ]
- }
- | tCOLON3 tCONSTANT tOP_ASGN arg
- {
- diagnostic :error, :dynamic_const, nil, val[1], [ val[2] ]
- }
- | backref tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | arg tDOT2 arg
- {
- result = @builder.range_inclusive(val[0], val[1], val[2])
- }
- | arg tDOT3 arg
- {
- result = @builder.range_exclusive(val[0], val[1], val[2])
- }
- | arg tPLUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMINUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tSTAR2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tDIVIDE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPERCENT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPOW arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tUMINUS_NUM tINTEGER tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.integer(val[1]),
- val[2], val[3]))
- }
- | tUMINUS_NUM tFLOAT tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.float(val[1]),
- val[2], val[3]))
- }
- | tUPLUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | tUMINUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tPIPE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCARET arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tAMPER2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCMP arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tNEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMATCH arg
- {
- result = @builder.match_op(val[0], val[1], val[2])
- }
- | arg tNMATCH arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tBANG arg
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | tTILDE arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tLSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tRSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tANDOP arg
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | arg tOROP arg
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kDEFINED opt_nl arg
- {
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
- }
-
- | arg tEH arg opt_nl tCOLON arg
- {
- result = @builder.ternary(val[0], val[1],
- val[2], val[4], val[5])
- }
- | primary
-
- arg_value: arg
-
- aref_args: none
- | args trailer
- | args tCOMMA assocs trailer
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs trailer
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- paren_args: tLPAREN2 opt_call_args rparen
- {
- result = val
- }
-
- opt_paren_args: # nothing
- {
- result = [ nil, [], nil ]
- }
- | paren_args
-
- opt_call_args: # nothing
- {
- result = []
- }
- | call_args
- | args tCOMMA
- | args tCOMMA assocs tCOMMA
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs tCOMMA
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- call_args: command
- {
- result = [ val[0] ]
- }
- | args opt_block_arg
- {
- result = val[0].concat(val[1])
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- result.concat(val[1])
- }
- | args tCOMMA assocs opt_block_arg
- {
- assocs = @builder.associate(nil, val[2], nil)
- result = val[0] << assocs
- result.concat(val[3])
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- command_args: {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
- }
- call_args
- {
- @lexer.cmdarg = val[0]
-
- result = val[1]
- }
-
- block_arg: tAMPER arg_value
- {
- result = @builder.block_pass(val[0], val[1])
- }
-
- opt_block_arg: tCOMMA block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- args: arg_value
- {
- result = [ val[0] ]
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
-
- mrhs: args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- primary: literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | var_ref
- | backref
- | tFID
- {
- result = @builder.call_method(nil, nil, val[0])
- }
- | kBEGIN bodystmt kEND
- {
- result = @builder.begin_keyword(val[0], val[1], val[2])
- }
- | tLPAREN_ARG
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- expr
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- @lexer.cmdarg = val[1]
-
- result = @builder.begin(val[0], val[2], val[5])
- }
- | tLPAREN compstmt tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.const_global(val[0], val[1])
- }
- | tLBRACK aref_args tRBRACK
- {
- result = @builder.array(val[0], val[1], val[2])
- }
- | tLBRACE assoc_list tRCURLY
- {
- result = @builder.associate(val[0], val[1], val[2])
- }
- | kRETURN
- {
- result = @builder.keyword_cmd(:return, val[0])
- }
- | kYIELD tLPAREN2 call_args rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
- }
- | kYIELD tLPAREN2 rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
- }
- | kYIELD
- {
- result = @builder.keyword_cmd(:yield, val[0])
- }
- | kDEFINED opt_nl tLPAREN2 expr rparen
- {
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
- }
- | kNOT tLPAREN2 expr rparen
- {
- result = @builder.not_op(val[0], val[1], val[2], val[3])
- }
- | kNOT tLPAREN2 rparen
- {
- result = @builder.not_op(val[0], val[1], nil, val[2])
- }
- | operation brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | method_call
- | method_call brace_block
- {
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
- }
- | tLAMBDA lambda
- {
- lambda_call = @builder.call_lambda(val[0])
-
- args, (begin_t, body, end_t) = val[1]
- result = @builder.block(lambda_call,
- begin_t, args, body, end_t)
- }
- | kIF expr_value then compstmt if_tail kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
- }
- | kUNLESS expr_value then compstmt opt_else kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
- }
- | kWHILE
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kUNTIL
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kCASE expr_value opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[3]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
- }
- | kCASE opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[2]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
- }
- | kFOR for_var kIN
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
- }
- | kCLASS cpath superclass
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kCLASS tLSHFT expr term
- {
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- @def_level = val[4]
- }
- | kMODULE cpath
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kDEF fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kDEF singleton dot_or_colon
- {
- @lexer.state = :expr_fname
- }
- fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kBREAK
- {
- result = @builder.keyword_cmd(:break, val[0])
- }
- | kNEXT
- {
- result = @builder.keyword_cmd(:next, val[0])
- }
- | kREDO
- {
- result = @builder.keyword_cmd(:redo, val[0])
- }
- | kRETRY
- {
- result = @builder.keyword_cmd(:retry, val[0])
- }
-
- primary_value: primary
-
- then: term
- | kTHEN
- | term kTHEN
- {
- result = val[1]
- }
-
- do: term
- | kDO_COND
-
- if_tail: opt_else
- | kELSIF expr_value then compstmt if_tail
- {
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
- }
-
- opt_else: none
- | kELSE compstmt
- {
- result = val
- }
-
- for_var: lhs
- | mlhs
-
- f_marg: f_norm_arg
- {
- @static_env.declare val[0][0]
-
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_marg_list: f_marg
- {
- result = [ val[0] ]
- }
- | f_marg_list tCOMMA f_marg
- {
- result = val[0] << val[2]
- }
-
- f_margs: f_marg_list
- | f_marg_list tCOMMA tSTAR f_norm_arg
- {
- @static_env.declare val[3][0]
-
- result = val[0].
- push(@builder.restarg(val[2], val[3]))
- }
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
- {
- @static_env.declare val[3][0]
-
- result = val[0].
- push(@builder.restarg(val[2], val[3])).
- concat(val[5])
- }
- | f_marg_list tCOMMA tSTAR
- {
- result = val[0].
- push(@builder.restarg(val[2]))
- }
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.restarg(val[2])).
- concat(val[4])
- }
- | tSTAR f_norm_arg
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | tSTAR f_norm_arg tCOMMA f_marg_list
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.restarg(val[0]) ]
- }
- | tSTAR tCOMMA f_marg_list
- {
- result = [ @builder.restarg(val[0]),
- *val[2] ]
- }
-
- block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_block_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_block_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_block_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
- opt_block_param: # nothing
- {
- result = @builder.args(nil, [], nil)
- }
- | block_param_def
- {
- @lexer.state = :expr_value
- }
-
- block_param_def: tPIPE opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1], val[2])
- }
- | tOROP
- {
- result = @builder.args(val[0], [], val[0])
- }
- | tPIPE block_param opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
-
- opt_bv_decl: # nothing
- {
- result = []
- }
- | tSEMI bv_decls
- {
- result = val[1]
- }
-
- bv_decls: bvar
- {
- result = [ val[0] ]
- }
- | bv_decls tCOMMA bvar
- {
- result = val[0] << val[2]
- }
-
- bvar: tIDENTIFIER
- {
- result = @builder.shadowarg(val[0])
- }
- | f_bad_arg
-
- lambda: {
- @static_env.extend_dynamic
- }
- f_larglist lambda_body
- {
- result = [ val[1], val[2] ]
-
- @static_env.unextend
- }
-
- f_larglist: tLPAREN2 f_args opt_bv_decl rparen
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
- | f_args
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- lambda_body: tLAMBEG compstmt tRCURLY
- {
- result = [ val[0], val[1], val[2] ]
- }
- | kDO_LAMBDA compstmt kEND
- {
- result = [ val[0], val[1], val[2] ]
- }
-
- do_block: kDO_BLOCK
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- block_call: command do_block
- {
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
- }
- | block_call tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | block_call tCOLON2 operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
-
- method_call: operation paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
- }
- | primary_value tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation3
- {
- result = @builder.call_method(val[0], val[1], val[2])
- }
- | primary_value tDOT paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | kSUPER paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
- }
- | kSUPER
- {
- result = @builder.keyword_cmd(:zsuper, val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index(val[0], val[1], val[2], val[3])
- }
-
- brace_block: tLCURLY
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
- | kDO
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- case_body: kWHEN args then compstmt cases
- {
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
- }
-
- cases: opt_else
- {
- result = [ val[0] ]
- }
- | case_body
-
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
- {
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
- }
- |
- {
- result = []
- }
-
- exc_list: arg_value
- {
- result = [ val[0] ]
- }
- | mrhs
- | none
-
- exc_var: tASSOC lhs
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- opt_ensure: kENSURE compstmt
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- literal: numeric
- | symbol
- | dsym
-
- strings: string
- {
- result = @builder.string_compose(nil, val[0], nil)
- }
-
- string: string1
- {
- result = [ val[0] ]
- }
- | string string1
- {
- result = val[0] << val[1]
- }
-
- string1: tSTRING_BEG string_contents tSTRING_END
- {
- result = @builder.string_compose(val[0], val[1], val[2])
- }
- | tSTRING
- {
- result = @builder.string(val[0])
- }
- | tCHARACTER
- {
- result = @builder.character(val[0])
- }
-
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
- {
- result = @builder.xstring_compose(val[0], val[1], val[2])
- }
-
- regexp: tREGEXP_BEG regexp_contents tSTRING_END tREGEXP_OPT
- {
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
- }
-
- words: tWORDS_BEG word_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- word_list: # nothing
- {
- result = []
- }
- | word_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- word: string_content
- {
- result = [ val[0] ]
- }
- | word string_content
- {
- result = val[0] << val[1]
- }
-
- qwords: tQWORDS_BEG qword_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- qword_list: # nothing
- {
- result = []
- }
- | qword_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.string_internal(val[1])
- }
-
- string_contents: # nothing
- {
- result = []
- }
- | string_contents string_content
- {
- result = val[0] << val[1]
- }
-
-xstring_contents: # nothing
- {
- result = []
- }
- | xstring_contents string_content
- {
- result = val[0] << val[1]
- }
-
-regexp_contents: # nothing
- {
- result = []
- }
- | regexp_contents string_content
- {
- result = val[0] << val[1]
- }
-
- string_content: tSTRING_CONTENT
- {
- result = @builder.string_internal(val[0])
- }
- | tSTRING_DVAR string_dvar
- {
- result = val[1]
- }
- | tSTRING_DBEG
- {
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
- }
- compstmt tRCURLY
- {
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
- }
-
- string_dvar: tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | backref
-
-
- symbol: tSYMBOL
- {
- result = @builder.symbol(val[0])
- }
-
- dsym: tSYMBEG xstring_contents tSTRING_END
- {
- result = @builder.symbol_compose(val[0], val[1], val[2])
- }
-
- numeric: tINTEGER
- {
- result = @builder.integer(val[0])
- }
- | tFLOAT
- {
- result = @builder.float(val[0])
- }
- | tUMINUS_NUM tINTEGER =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.integer(val[1]))
- }
- | tUMINUS_NUM tFLOAT =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.float(val[1]))
- }
-
- user_variable: tIDENTIFIER
- {
- result = @builder.ident(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tCONSTANT
- {
- result = @builder.const(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
-
-keyword_variable: kNIL
- {
- result = @builder.nil(val[0])
- }
- | kSELF
- {
- result = @builder.self(val[0])
- }
- | kTRUE
- {
- result = @builder.true(val[0])
- }
- | kFALSE
- {
- result = @builder.false(val[0])
- }
- | k__FILE__
- {
- result = @builder.__FILE__(val[0])
- }
- | k__LINE__
- {
- result = @builder.__LINE__(val[0])
- }
- | k__ENCODING__
- {
- result = @builder.__ENCODING__(val[0])
- }
-
- var_ref: user_variable
- {
- result = @builder.accessible(val[0])
- }
- | keyword_variable
- {
- result = @builder.accessible(val[0])
- }
-
- var_lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
-
- backref: tNTH_REF
- {
- result = @builder.nth_ref(val[0])
- }
- | tBACK_REF
- {
- result = @builder.back_ref(val[0])
- }
-
- superclass: term
- {
- result = nil
- }
- | tLT expr_value term
- {
- result = [ val[0], val[1] ]
- }
- | error term
- {
- yyerrok
- result = nil
- }
-
- f_arglist: tLPAREN2 f_args rparen
- {
- result = @builder.args(val[0], val[1], val[2])
-
- @lexer.state = :expr_value
- }
- | f_args term
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_optarg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_f_block_arg
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
- | # nothing
- {
- result = []
- }
-
- f_bad_arg: tCONSTANT
- {
- diagnostic :error, :argument_const, nil, val[0]
- }
- | tIVAR
- {
- diagnostic :error, :argument_ivar, nil, val[0]
- }
- | tGVAR
- {
- diagnostic :error, :argument_gvar, nil, val[0]
- }
- | tCVAR
- {
- diagnostic :error, :argument_cvar, nil, val[0]
- }
-
- f_norm_arg: f_bad_arg
- | tIDENTIFIER
-
- f_arg_item: f_norm_arg
- {
- @static_env.declare val[0][0]
-
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_arg: f_arg_item
- {
- result = [ val[0] ]
- }
- | f_arg tCOMMA f_arg_item
- {
- result = val[0] << val[2]
- }
-
- f_opt: tIDENTIFIER tEQL arg_value
- {
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_opt: tIDENTIFIER tEQL primary_value
- {
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_optarg: f_block_opt
- {
- result = [ val[0] ]
- }
- | f_block_optarg tCOMMA f_block_opt
- {
- result = val[0] << val[2]
- }
-
- f_optarg: f_opt
- {
- result = [ val[0] ]
- }
- | f_optarg tCOMMA f_opt
- {
- result = val[0] << val[2]
- }
-
- restarg_mark: tSTAR2 | tSTAR
-
- f_rest_arg: restarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | restarg_mark
- {
- result = [ @builder.restarg(val[0]) ]
- }
-
- blkarg_mark: tAMPER2 | tAMPER
-
- f_block_arg: blkarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
- }
-
- opt_f_block_arg: tCOMMA f_block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- singleton: var_ref
- | tLPAREN2 expr rparen
- {
- result = val[1]
- }
-
- assoc_list: # nothing
- {
- result = []
- }
- | assocs trailer
-
- assocs: assoc
- {
- result = [ val[0] ]
- }
- | assocs tCOMMA assoc
- {
- result = val[0] << val[2]
- }
-
- assoc: arg_value tASSOC arg_value
- {
- result = @builder.pair(val[0], val[1], val[2])
- }
- | tLABEL arg_value
- {
- result = @builder.pair_keyword(val[0], val[1])
- }
-
- operation: tIDENTIFIER | tCONSTANT | tFID
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
- operation3: tIDENTIFIER | tFID | op
- dot_or_colon: tDOT | tCOLON2
- opt_terms: | terms
- opt_nl: | tNL
- rparen: opt_nl tRPAREN
- {
- result = val[1]
- }
- rbracket: opt_nl tRBRACK
- {
- result = val[1]
- }
- trailer: | tNL | tCOMMA
-
- term: tSEMI
- {
- yyerrok
- }
- | tNL
-
- terms: term
- | terms tSEMI
-
- none: # nothing
- {
- result = nil
- }
-end
-
----- header
-
-require 'parser'
-
-Parser.check_for_encoding_support
-
----- inner
-
- def version
- 19
- end
-
- def default_encoding
- Encoding::BINARY
- end
diff --git a/test/racc/assets/ruby20.y b/test/racc/assets/ruby20.y
deleted file mode 100644
index 6e07734778..0000000000
--- a/test/racc/assets/ruby20.y
+++ /dev/null
@@ -1,2350 +0,0 @@
-# Copyright (c) 2013 Peter Zotov <whitequark@whitequark.org>
-#
-# Parts of the source are derived from ruby_parser:
-# Copyright (c) Ryan Davis, seattle.rb
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Parser::Ruby20
-
-token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
- tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
- tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
- tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
- tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
- tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
- tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
- tDSTAR tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
- tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tREGEXP_OPT
- tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
- tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
- tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
-
-prechigh
- right tBANG tTILDE tUPLUS
- right tPOW
- right tUMINUS_NUM tUMINUS
- left tSTAR2 tDIVIDE tPERCENT
- left tPLUS tMINUS
- left tLSHFT tRSHFT
- left tAMPER2
- left tPIPE tCARET
- left tGT tGEQ tLT tLEQ
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
- left tANDOP
- left tOROP
- nonassoc tDOT2 tDOT3
- right tEH tCOLON
- left kRESCUE_MOD
- right tEQL tOP_ASGN
- nonassoc kDEFINED
- right kNOT
- left kOR kAND
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
- nonassoc tLBRACE_ARG
- nonassoc tLOWEST
-preclow
-
-rule
-
- program: top_compstmt
-
- top_compstmt: top_stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- top_stmts: # nothing
- {
- result = []
- }
- | top_stmt
- {
- result = [ val[0] ]
- }
- | top_stmts terms top_stmt
- {
- result = val[0] << val[2]
- }
- | error top_stmt
- {
- result = [ val[1] ]
- }
-
- top_stmt: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- result = @builder.preexe(val[0], val[1], val[2], val[3])
- }
-
- bodystmt: compstmt opt_rescue opt_else opt_ensure
- {
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
- }
-
- compstmt: stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- stmts: # nothing
- {
- result = []
- }
- | stmt_or_begin
- {
- result = [ val[0] ]
- }
- | stmts terms stmt_or_begin
- {
- result = val[0] << val[2]
- }
- | error stmt
- {
- result = [ val[1] ]
- }
-
- stmt_or_begin: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- if in_def?
- diagnostic :error, :begin_in_method, nil, val[0]
- end
-
- result = @builder.preexe(val[0], val[1], val[2], val[3])
- }
-
- stmt: kALIAS fitem
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = @builder.alias(val[0], val[1], val[3])
- }
- | kALIAS tGVAR tGVAR
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
- }
- | kALIAS tGVAR tBACK_REF
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
- }
- | kALIAS tGVAR tNTH_REF
- {
- diagnostic :error, :nth_ref_alias, nil, val[2]
- }
- | kUNDEF undef_list
- {
- result = @builder.undef_method(val[0], val[1])
- }
- | stmt kIF_MOD expr_value
- {
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
- }
- | stmt kUNLESS_MOD expr_value
- {
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
- }
- | stmt kWHILE_MOD expr_value
- {
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
- }
- | stmt kUNTIL_MOD expr_value
- {
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
- }
- | stmt kRESCUE_MOD stmt
- {
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
- }
- | klEND tLCURLY compstmt tRCURLY
- {
- result = @builder.postexe(val[0], val[1], val[2], val[3])
- }
- | command_asgn
- | mlhs tEQL command_call
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN command_call
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | backref tOP_ASGN command_call
- {
- @builder.op_assign(val[0], val[1], val[2])
- }
- | lhs tEQL mrhs
- {
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | mlhs tEQL arg_value
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | mlhs tEQL mrhs
- {
- result = @builder.multi_assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | expr
-
- command_asgn: lhs tEQL command_call
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL command_asgn
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
-
- expr: command_call
- | expr kAND expr
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | expr kOR expr
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kNOT opt_nl expr
- {
- result = @builder.not_op(val[0], nil, val[2], nil)
- }
- | tBANG command_call
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | arg
-
- expr_value: expr
-
- command_call: command
- | block_command
-
- block_command: block_call
- | block_call dot_or_colon operation2 command_args
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
-
- cmd_brace_block: tLBRACE_ARG
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- fcall: operation
-
- command: fcall command_args =tLOWEST
- {
- result = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
- }
- | fcall command_args cmd_brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
-
- begin_t, args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tDOT operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tDOT operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tCOLON2 operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | kSUPER command_args
- {
- result = @builder.keyword_cmd(:super, val[0],
- nil, val[1], nil)
- }
- | kYIELD command_args
- {
- result = @builder.keyword_cmd(:yield, val[0],
- nil, val[1], nil)
- }
- | kRETURN call_args
- {
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
- }
- | kBREAK call_args
- {
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
- }
- | kNEXT call_args
- {
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
- }
-
- mlhs: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_inner: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- mlhs_basic: mlhs_head
- | mlhs_head mlhs_item
- {
- result = val[0].
- push(val[1])
- }
- | mlhs_head tSTAR mlhs_node
- {
- result = val[0].
- push(@builder.splat(val[1], val[2]))
- }
- | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1], val[2])).
- concat(val[4])
- }
- | mlhs_head tSTAR
- {
- result = val[0].
- push(@builder.splat(val[1]))
- }
- | mlhs_head tSTAR tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1])).
- concat(val[3])
- }
- | tSTAR mlhs_node
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.splat(val[0]) ]
- }
- | tSTAR tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0]),
- *val[2] ]
- }
-
- mlhs_item: mlhs_node
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_head: mlhs_item tCOMMA
- {
- result = [ val[0] ]
- }
- | mlhs_head mlhs_item tCOMMA
- {
- result = val[0] << val[1]
- }
-
- mlhs_post: mlhs_item
- {
- result = [ val[0] ]
- }
- | mlhs_post tCOMMA mlhs_item
- {
- result = val[0] << val[2]
- }
-
- mlhs_node: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- cname: tIDENTIFIER
- {
- diagnostic :error, :module_name_const, nil, val[0]
- }
- | tCONSTANT
-
- cpath: tCOLON3 cname
- {
- result = @builder.const_global(val[0], val[1])
- }
- | cname
- {
- result = @builder.const(val[0])
- }
- | primary_value tCOLON2 cname
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
-
- fname: tIDENTIFIER | tCONSTANT | tFID
- | op
- | reswords
-
- fsym: fname
- {
- result = @builder.symbol(val[0])
- }
- | symbol
-
- fitem: fsym
- | dsym
-
- undef_list: fitem
- {
- result = [ val[0] ]
- }
- | undef_list tCOMMA
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = val[0] << val[3]
- }
-
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
- | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
- | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
- | tUPLUS | tUMINUS | tAREF | tASET | tDSTAR | tBACK_REF2
-
- reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
- | kALIAS | kAND | kBEGIN | kBREAK | kCASE
- | kCLASS | kDEF | kDEFINED | kDO | kELSE
- | kELSIF | kEND | kENSURE | kFALSE | kFOR
- | kIN | kMODULE | kNEXT | kNIL | kNOT
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN
- | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
- | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
- | kUNTIL
-
- arg: lhs tEQL arg
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
- }
- | var_lhs tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.op_assign(val[0], val[1], rescue_)
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
- {
- const = @builder.const_op_assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- result = @builder.op_assign(const, val[3], val[4])
- }
- | tCOLON3 tCONSTANT tOP_ASGN arg
- {
- const = @builder.const_op_assignable(
- @builder.const_global(val[0], val[1]))
- result = @builder.op_assign(const, val[2], val[3])
- }
- | backref tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | arg tDOT2 arg
- {
- result = @builder.range_inclusive(val[0], val[1], val[2])
- }
- | arg tDOT3 arg
- {
- result = @builder.range_exclusive(val[0], val[1], val[2])
- }
- | arg tPLUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMINUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tSTAR2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tDIVIDE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPERCENT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPOW arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tUMINUS_NUM tINTEGER tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.integer(val[1]),
- val[2], val[3]))
- }
- | tUMINUS_NUM tFLOAT tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.float(val[1]),
- val[2], val[3]))
- }
- | tUPLUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | tUMINUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tPIPE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCARET arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tAMPER2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCMP arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tNEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMATCH arg
- {
- result = @builder.match_op(val[0], val[1], val[2])
- }
- | arg tNMATCH arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tBANG arg
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | tTILDE arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tLSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tRSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tANDOP arg
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | arg tOROP arg
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kDEFINED opt_nl arg
- {
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
- }
-
- | arg tEH arg opt_nl tCOLON arg
- {
- result = @builder.ternary(val[0], val[1],
- val[2], val[4], val[5])
- }
- | primary
-
- arg_value: arg
-
- aref_args: none
- | args trailer
- | args tCOMMA assocs trailer
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs trailer
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- paren_args: tLPAREN2 opt_call_args rparen
- {
- result = val
- }
-
- opt_paren_args: # nothing
- {
- result = [ nil, [], nil ]
- }
- | paren_args
-
- opt_call_args: # nothing
- {
- result = []
- }
- | call_args
- | args tCOMMA
- | args tCOMMA assocs tCOMMA
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs tCOMMA
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- call_args: command
- {
- result = [ val[0] ]
- }
- | args opt_block_arg
- {
- result = val[0].concat(val[1])
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- result.concat(val[1])
- }
- | args tCOMMA assocs opt_block_arg
- {
- assocs = @builder.associate(nil, val[2], nil)
- result = val[0] << assocs
- result.concat(val[3])
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- command_args: {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
- }
- call_args
- {
- @lexer.cmdarg = val[0]
-
- result = val[1]
- }
-
- block_arg: tAMPER arg_value
- {
- result = @builder.block_pass(val[0], val[1])
- }
-
- opt_block_arg: tCOMMA block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- args: arg_value
- {
- result = [ val[0] ]
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
-
- mrhs: args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- primary: literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | symbols
- | qsymbols
- | var_ref
- | backref
- | tFID
- {
- result = @builder.call_method(nil, nil, val[0])
- }
- | kBEGIN
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- bodystmt kEND
- {
- @lexer.cmdarg = val[1]
-
- result = @builder.begin_keyword(val[0], val[2], val[3])
- }
- | tLPAREN_ARG
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- expr
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- @lexer.cmdarg = val[1]
-
- result = @builder.begin(val[0], val[2], val[5])
- }
- | tLPAREN_ARG
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- result = @builder.begin(val[0], nil, val[3])
- }
- | tLPAREN compstmt tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.const_global(val[0], val[1])
- }
- | tLBRACK aref_args tRBRACK
- {
- result = @builder.array(val[0], val[1], val[2])
- }
- | tLBRACE assoc_list tRCURLY
- {
- result = @builder.associate(val[0], val[1], val[2])
- }
- | kRETURN
- {
- result = @builder.keyword_cmd(:return, val[0])
- }
- | kYIELD tLPAREN2 call_args rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
- }
- | kYIELD tLPAREN2 rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
- }
- | kYIELD
- {
- result = @builder.keyword_cmd(:yield, val[0])
- }
- | kDEFINED opt_nl tLPAREN2 expr rparen
- {
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
- }
- | kNOT tLPAREN2 expr rparen
- {
- result = @builder.not_op(val[0], val[1], val[2], val[3])
- }
- | kNOT tLPAREN2 rparen
- {
- result = @builder.not_op(val[0], val[1], nil, val[2])
- }
- | fcall brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | method_call
- | method_call brace_block
- {
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
- }
- | tLAMBDA lambda
- {
- lambda_call = @builder.call_lambda(val[0])
-
- args, (begin_t, body, end_t) = val[1]
- result = @builder.block(lambda_call,
- begin_t, args, body, end_t)
- }
- | kIF expr_value then compstmt if_tail kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
- }
- | kUNLESS expr_value then compstmt opt_else kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
- }
- | kWHILE
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kUNTIL
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kCASE expr_value opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[3]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
- }
- | kCASE opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[2]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
- }
- | kFOR for_var kIN
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
- }
- | kCLASS cpath superclass
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kCLASS tLSHFT expr term
- {
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- @def_level = val[4]
- }
- | kMODULE cpath
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kDEF fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kDEF singleton dot_or_colon
- {
- @lexer.state = :expr_fname
- }
- fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kBREAK
- {
- result = @builder.keyword_cmd(:break, val[0])
- }
- | kNEXT
- {
- result = @builder.keyword_cmd(:next, val[0])
- }
- | kREDO
- {
- result = @builder.keyword_cmd(:redo, val[0])
- }
- | kRETRY
- {
- result = @builder.keyword_cmd(:retry, val[0])
- }
-
- primary_value: primary
-
- then: term
- | kTHEN
- | term kTHEN
- {
- result = val[1]
- }
-
- do: term
- | kDO_COND
-
- if_tail: opt_else
- | kELSIF expr_value then compstmt if_tail
- {
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
- }
-
- opt_else: none
- | kELSE compstmt
- {
- result = val
- }
-
- for_var: lhs
- | mlhs
-
- f_marg: f_norm_arg
- {
- @static_env.declare val[0][0]
-
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_marg_list: f_marg
- {
- result = [ val[0] ]
- }
- | f_marg_list tCOMMA f_marg
- {
- result = val[0] << val[2]
- }
-
- f_margs: f_marg_list
- | f_marg_list tCOMMA tSTAR f_norm_arg
- {
- @static_env.declare val[3][0]
-
- result = val[0].
- push(@builder.restarg(val[2], val[3]))
- }
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
- {
- @static_env.declare val[3][0]
-
- result = val[0].
- push(@builder.restarg(val[2], val[3])).
- concat(val[5])
- }
- | f_marg_list tCOMMA tSTAR
- {
- result = val[0].
- push(@builder.restarg(val[2]))
- }
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.restarg(val[2])).
- concat(val[4])
- }
- | tSTAR f_norm_arg
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | tSTAR f_norm_arg tCOMMA f_marg_list
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.restarg(val[0]) ]
- }
- | tSTAR tCOMMA f_marg_list
- {
- result = [ @builder.restarg(val[0]),
- *val[2] ]
- }
-
- block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[2]).concat(val[3])
- }
- | f_block_kwarg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
-opt_block_args_tail:
- tCOMMA block_args_tail
- {
- result = val[1]
- }
- | # nothing
- {
- result = []
- }
-
- block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_block_optarg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_block_args_tail
- {
- result = val[0].concat(val[1])
- }
- | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_block_optarg opt_block_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_block_optarg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | block_args_tail
-
- opt_block_param: # nothing
- {
- result = @builder.args(nil, [], nil)
- }
- | block_param_def
- {
- @lexer.state = :expr_value
- }
-
- block_param_def: tPIPE opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1], val[2])
- }
- | tOROP
- {
- result = @builder.args(val[0], [], val[0])
- }
- | tPIPE block_param opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
-
- opt_bv_decl: opt_nl
- {
- result = []
- }
- | opt_nl tSEMI bv_decls opt_nl
- {
- result = val[2]
- }
-
- bv_decls: bvar
- {
- result = [ val[0] ]
- }
- | bv_decls tCOMMA bvar
- {
- result = val[0] << val[2]
- }
-
- bvar: tIDENTIFIER
- {
- result = @builder.shadowarg(val[0])
- }
- | f_bad_arg
-
- lambda: {
- @static_env.extend_dynamic
- }
- f_larglist lambda_body
- {
- result = [ val[1], val[2] ]
-
- @static_env.unextend
- }
-
- f_larglist: tLPAREN2 f_args opt_bv_decl tRPAREN
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
- | f_args
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- lambda_body: tLAMBEG compstmt tRCURLY
- {
- result = [ val[0], val[1], val[2] ]
- }
- | kDO_LAMBDA compstmt kEND
- {
- result = [ val[0], val[1], val[2] ]
- }
-
- do_block: kDO_BLOCK
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- block_call: command do_block
- {
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
- }
- | block_call dot_or_colon operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | block_call dot_or_colon operation2 opt_paren_args brace_block
- {
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | block_call dot_or_colon operation2 command_args do_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
-
- method_call: fcall paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
- }
- | primary_value tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation3
- {
- result = @builder.call_method(val[0], val[1], val[2])
- }
- | primary_value tDOT paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | kSUPER paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
- }
- | kSUPER
- {
- result = @builder.keyword_cmd(:zsuper, val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index(val[0], val[1], val[2], val[3])
- }
-
- brace_block: tLCURLY
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
- | kDO
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- case_body: kWHEN args then compstmt cases
- {
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
- }
-
- cases: opt_else
- {
- result = [ val[0] ]
- }
- | case_body
-
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
- {
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
- }
- |
- {
- result = []
- }
-
- exc_list: arg_value
- {
- result = [ val[0] ]
- }
- | mrhs
- | none
-
- exc_var: tASSOC lhs
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- opt_ensure: kENSURE compstmt
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- literal: numeric
- | symbol
- | dsym
-
- strings: string
- {
- result = @builder.string_compose(nil, val[0], nil)
- }
-
- string: string1
- {
- result = [ val[0] ]
- }
- | string string1
- {
- result = val[0] << val[1]
- }
-
- string1: tSTRING_BEG string_contents tSTRING_END
- {
- result = @builder.string_compose(val[0], val[1], val[2])
- }
- | tSTRING
- {
- result = @builder.string(val[0])
- }
- | tCHARACTER
- {
- result = @builder.character(val[0])
- }
-
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
- {
- result = @builder.xstring_compose(val[0], val[1], val[2])
- }
-
- regexp: tREGEXP_BEG regexp_contents tSTRING_END tREGEXP_OPT
- {
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
- }
-
- words: tWORDS_BEG word_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- word_list: # nothing
- {
- result = []
- }
- | word_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- word: string_content
- {
- result = [ val[0] ]
- }
- | word string_content
- {
- result = val[0] << val[1]
- }
-
- symbols: tSYMBOLS_BEG symbol_list tSTRING_END
- {
- result = @builder.symbols_compose(val[0], val[1], val[2])
- }
-
- symbol_list: # nothing
- {
- result = []
- }
- | symbol_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- qwords: tQWORDS_BEG qword_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- qsymbols: tQSYMBOLS_BEG qsym_list tSTRING_END
- {
- result = @builder.symbols_compose(val[0], val[1], val[2])
- }
-
- qword_list: # nothing
- {
- result = []
- }
- | qword_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.string_internal(val[1])
- }
-
- qsym_list: # nothing
- {
- result = []
- }
- | qsym_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.symbol_internal(val[1])
- }
-
- string_contents: # nothing
- {
- result = []
- }
- | string_contents string_content
- {
- result = val[0] << val[1]
- }
-
-xstring_contents: # nothing
- {
- result = []
- }
- | xstring_contents string_content
- {
- result = val[0] << val[1]
- }
-
-regexp_contents: # nothing
- {
- result = []
- }
- | regexp_contents string_content
- {
- result = val[0] << val[1]
- }
-
- string_content: tSTRING_CONTENT
- {
- result = @builder.string_internal(val[0])
- }
- | tSTRING_DVAR string_dvar
- {
- result = val[1]
- }
- | tSTRING_DBEG
- {
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
- }
- compstmt tSTRING_DEND
- {
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
- }
-
- string_dvar: tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | backref
-
-
- symbol: tSYMBOL
- {
- result = @builder.symbol(val[0])
- }
-
- dsym: tSYMBEG xstring_contents tSTRING_END
- {
- result = @builder.symbol_compose(val[0], val[1], val[2])
- }
-
- numeric: tINTEGER
- {
- result = @builder.integer(val[0])
- }
- | tFLOAT
- {
- result = @builder.float(val[0])
- }
- | tUMINUS_NUM tINTEGER =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.integer(val[1]))
- }
- | tUMINUS_NUM tFLOAT =tLOWEST
- {
- result = @builder.negate(val[0],
- @builder.float(val[1]))
- }
-
- user_variable: tIDENTIFIER
- {
- result = @builder.ident(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tCONSTANT
- {
- result = @builder.const(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
-
-keyword_variable: kNIL
- {
- result = @builder.nil(val[0])
- }
- | kSELF
- {
- result = @builder.self(val[0])
- }
- | kTRUE
- {
- result = @builder.true(val[0])
- }
- | kFALSE
- {
- result = @builder.false(val[0])
- }
- | k__FILE__
- {
- result = @builder.__FILE__(val[0])
- }
- | k__LINE__
- {
- result = @builder.__LINE__(val[0])
- }
- | k__ENCODING__
- {
- result = @builder.__ENCODING__(val[0])
- }
-
- var_ref: user_variable
- {
- result = @builder.accessible(val[0])
- }
- | keyword_variable
- {
- result = @builder.accessible(val[0])
- }
-
- var_lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
-
- backref: tNTH_REF
- {
- result = @builder.nth_ref(val[0])
- }
- | tBACK_REF
- {
- result = @builder.back_ref(val[0])
- }
-
- superclass: term
- {
- result = nil
- }
- | tLT
- {
- @lexer.state = :expr_value
- }
- expr_value term
- {
- result = [ val[0], val[2] ]
- }
- | error term
- {
- yyerrok
- result = nil
- }
-
- f_arglist: tLPAREN2 f_args rparen
- {
- result = @builder.args(val[0], val[1], val[2])
-
- @lexer.state = :expr_value
- }
- | f_args term
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[2]).concat(val[3])
- }
- | f_kwarg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
- opt_args_tail: tCOMMA args_tail
- {
- result = val[1]
- }
- | # nothing
- {
- result = []
- }
-
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_optarg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_optarg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | args_tail
- {
- result = val[0]
- }
- | # nothing
- {
- result = []
- }
-
- f_bad_arg: tCONSTANT
- {
- diagnostic :error, :argument_const, nil, val[0]
- }
- | tIVAR
- {
- diagnostic :error, :argument_ivar, nil, val[0]
- }
- | tGVAR
- {
- diagnostic :error, :argument_gvar, nil, val[0]
- }
- | tCVAR
- {
- diagnostic :error, :argument_cvar, nil, val[0]
- }
-
- f_norm_arg: f_bad_arg
- | tIDENTIFIER
-
- f_arg_item: f_norm_arg
- {
- @static_env.declare val[0][0]
-
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_arg: f_arg_item
- {
- result = [ val[0] ]
- }
- | f_arg tCOMMA f_arg_item
- {
- result = val[0] << val[2]
- }
-
- f_kw: tLABEL arg_value
- {
- check_kwarg_name(val[0])
-
- @static_env.declare val[0][0]
-
- result = @builder.kwoptarg(val[0], val[1])
- }
-
- f_block_kw: tLABEL primary_value
- {
- check_kwarg_name(val[0])
-
- @static_env.declare val[0][0]
-
- result = @builder.kwoptarg(val[0], val[1])
- }
-
- f_block_kwarg: f_block_kw
- {
- result = [ val[0] ]
- }
- | f_block_kwarg tCOMMA f_block_kw
- {
- result = val[0] << val[2]
- }
-
- f_kwarg: f_kw
- {
- result = [ val[0] ]
- }
- | f_kwarg tCOMMA f_kw
- {
- result = val[0] << val[2]
- }
-
- kwrest_mark: tPOW | tDSTAR
-
- f_kwrest: kwrest_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.kwrestarg(val[0], val[1]) ]
- }
- | kwrest_mark
- {
- result = [ @builder.kwrestarg(val[0]) ]
- }
-
- f_opt: tIDENTIFIER tEQL arg_value
- {
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_opt: tIDENTIFIER tEQL primary_value
- {
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_optarg: f_block_opt
- {
- result = [ val[0] ]
- }
- | f_block_optarg tCOMMA f_block_opt
- {
- result = val[0] << val[2]
- }
-
- f_optarg: f_opt
- {
- result = [ val[0] ]
- }
- | f_optarg tCOMMA f_opt
- {
- result = val[0] << val[2]
- }
-
- restarg_mark: tSTAR2 | tSTAR
-
- f_rest_arg: restarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | restarg_mark
- {
- result = [ @builder.restarg(val[0]) ]
- }
-
- blkarg_mark: tAMPER2 | tAMPER
-
- f_block_arg: blkarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
- }
-
- opt_f_block_arg: tCOMMA f_block_arg
- {
- result = [ val[1] ]
- }
- |
- {
- result = []
- }
-
- singleton: var_ref
- | tLPAREN2 expr rparen
- {
- result = val[1]
- }
-
- assoc_list: # nothing
- {
- result = []
- }
- | assocs trailer
-
- assocs: assoc
- {
- result = [ val[0] ]
- }
- | assocs tCOMMA assoc
- {
- result = val[0] << val[2]
- }
-
- assoc: arg_value tASSOC arg_value
- {
- result = @builder.pair(val[0], val[1], val[2])
- }
- | tLABEL arg_value
- {
- result = @builder.pair_keyword(val[0], val[1])
- }
- | tDSTAR arg_value
- {
- result = @builder.kwsplat(val[0], val[1])
- }
-
- operation: tIDENTIFIER | tCONSTANT | tFID
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
- operation3: tIDENTIFIER | tFID | op
- dot_or_colon: tDOT | tCOLON2
- opt_terms: | terms
- opt_nl: | tNL
- rparen: opt_nl tRPAREN
- {
- result = val[1]
- }
- rbracket: opt_nl tRBRACK
- {
- result = val[1]
- }
- trailer: | tNL | tCOMMA
-
- term: tSEMI
- {
- yyerrok
- }
- | tNL
-
- terms: term
- | terms tSEMI
-
- none: # nothing
- {
- result = nil
- }
-end
-
----- header
-
-require 'parser'
-
-Parser.check_for_encoding_support
-
----- inner
-
- def version
- 20
- end
-
- def default_encoding
- Encoding::UTF_8
- end
diff --git a/test/racc/assets/ruby21.y b/test/racc/assets/ruby21.y
deleted file mode 100644
index 2ac94afb0c..0000000000
--- a/test/racc/assets/ruby21.y
+++ /dev/null
@@ -1,2359 +0,0 @@
-# Copyright (c) 2013 Peter Zotov <whitequark@whitequark.org>
-#
-# Parts of the source are derived from ruby_parser:
-# Copyright (c) Ryan Davis, seattle.rb
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Parser::Ruby21
-
-token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
- tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
- tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
- tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
- tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
- tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
- tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
- tDSTAR tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
- tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tREGEXP_OPT
- tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
- tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
- tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
- tRATIONAL tIMAGINARY
-
-prechigh
- right tBANG tTILDE tUPLUS
- right tPOW
- right tUMINUS_NUM tUMINUS
- left tSTAR2 tDIVIDE tPERCENT
- left tPLUS tMINUS
- left tLSHFT tRSHFT
- left tAMPER2
- left tPIPE tCARET
- left tGT tGEQ tLT tLEQ
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
- left tANDOP
- left tOROP
- nonassoc tDOT2 tDOT3
- right tEH tCOLON
- left kRESCUE_MOD
- right tEQL tOP_ASGN
- nonassoc kDEFINED
- right kNOT
- left kOR kAND
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
- nonassoc tLBRACE_ARG
- nonassoc tLOWEST
-preclow
-
-rule
-
- program: top_compstmt
-
- top_compstmt: top_stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- top_stmts: # nothing
- {
- result = []
- }
- | top_stmt
- {
- result = [ val[0] ]
- }
- | top_stmts terms top_stmt
- {
- result = val[0] << val[2]
- }
- | error top_stmt
- {
- result = [ val[1] ]
- }
-
- top_stmt: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- result = @builder.preexe(val[0], val[1], val[2], val[3])
- }
-
- bodystmt: compstmt opt_rescue opt_else opt_ensure
- {
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
- }
-
- compstmt: stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- stmts: # nothing
- {
- result = []
- }
- | stmt_or_begin
- {
- result = [ val[0] ]
- }
- | stmts terms stmt_or_begin
- {
- result = val[0] << val[2]
- }
- | error stmt
- {
- result = [ val[1] ]
- }
-
- stmt_or_begin: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- diagnostic :error, :begin_in_method, nil, val[0]
- }
-
- stmt: kALIAS fitem
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = @builder.alias(val[0], val[1], val[3])
- }
- | kALIAS tGVAR tGVAR
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
- }
- | kALIAS tGVAR tBACK_REF
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
- }
- | kALIAS tGVAR tNTH_REF
- {
- diagnostic :error, :nth_ref_alias, nil, val[2]
- }
- | kUNDEF undef_list
- {
- result = @builder.undef_method(val[0], val[1])
- }
- | stmt kIF_MOD expr_value
- {
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
- }
- | stmt kUNLESS_MOD expr_value
- {
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
- }
- | stmt kWHILE_MOD expr_value
- {
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
- }
- | stmt kUNTIL_MOD expr_value
- {
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
- }
- | stmt kRESCUE_MOD stmt
- {
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
- }
- | klEND tLCURLY compstmt tRCURLY
- {
- result = @builder.postexe(val[0], val[1], val[2], val[3])
- }
- | command_asgn
- | mlhs tEQL command_call
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN command_call
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | backref tOP_ASGN command_call
- {
- @builder.op_assign(val[0], val[1], val[2])
- }
- | lhs tEQL mrhs
- {
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | mlhs tEQL mrhs_arg
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | expr
-
- command_asgn: lhs tEQL command_call
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL command_asgn
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
-
- expr: command_call
- | expr kAND expr
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | expr kOR expr
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kNOT opt_nl expr
- {
- result = @builder.not_op(val[0], nil, val[2], nil)
- }
- | tBANG command_call
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | arg
-
- expr_value: expr
-
- command_call: command
- | block_command
-
- block_command: block_call
- | block_call dot_or_colon operation2 command_args
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
-
- cmd_brace_block: tLBRACE_ARG
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- fcall: operation
-
- command: fcall command_args =tLOWEST
- {
- result = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
- }
- | fcall command_args cmd_brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
-
- begin_t, args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tDOT operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tDOT operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tCOLON2 operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | kSUPER command_args
- {
- result = @builder.keyword_cmd(:super, val[0],
- nil, val[1], nil)
- }
- | kYIELD command_args
- {
- result = @builder.keyword_cmd(:yield, val[0],
- nil, val[1], nil)
- }
- | kRETURN call_args
- {
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
- }
- | kBREAK call_args
- {
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
- }
- | kNEXT call_args
- {
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
- }
-
- mlhs: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_inner: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- mlhs_basic: mlhs_head
- | mlhs_head mlhs_item
- {
- result = val[0].
- push(val[1])
- }
- | mlhs_head tSTAR mlhs_node
- {
- result = val[0].
- push(@builder.splat(val[1], val[2]))
- }
- | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1], val[2])).
- concat(val[4])
- }
- | mlhs_head tSTAR
- {
- result = val[0].
- push(@builder.splat(val[1]))
- }
- | mlhs_head tSTAR tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1])).
- concat(val[3])
- }
- | tSTAR mlhs_node
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.splat(val[0]) ]
- }
- | tSTAR tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0]),
- *val[2] ]
- }
-
- mlhs_item: mlhs_node
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_head: mlhs_item tCOMMA
- {
- result = [ val[0] ]
- }
- | mlhs_head mlhs_item tCOMMA
- {
- result = val[0] << val[1]
- }
-
- mlhs_post: mlhs_item
- {
- result = [ val[0] ]
- }
- | mlhs_post tCOMMA mlhs_item
- {
- result = val[0] << val[2]
- }
-
- mlhs_node: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- cname: tIDENTIFIER
- {
- diagnostic :error, :module_name_const, nil, val[0]
- }
- | tCONSTANT
-
- cpath: tCOLON3 cname
- {
- result = @builder.const_global(val[0], val[1])
- }
- | cname
- {
- result = @builder.const(val[0])
- }
- | primary_value tCOLON2 cname
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
-
- fname: tIDENTIFIER | tCONSTANT | tFID
- | op
- | reswords
-
- fsym: fname
- {
- result = @builder.symbol(val[0])
- }
- | symbol
-
- fitem: fsym
- | dsym
-
- undef_list: fitem
- {
- result = [ val[0] ]
- }
- | undef_list tCOMMA
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = val[0] << val[3]
- }
-
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
- | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
- | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
- | tUPLUS | tUMINUS | tAREF | tASET | tDSTAR | tBACK_REF2
-
- reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
- | kALIAS | kAND | kBEGIN | kBREAK | kCASE
- | kCLASS | kDEF | kDEFINED | kDO | kELSE
- | kELSIF | kEND | kENSURE | kFALSE | kFOR
- | kIN | kMODULE | kNEXT | kNIL | kNOT
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN
- | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
- | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
- | kUNTIL
-
- arg: lhs tEQL arg
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
- }
- | var_lhs tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.op_assign(val[0], val[1], rescue_)
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
- {
- const = @builder.const_op_assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- result = @builder.op_assign(const, val[3], val[4])
- }
- | tCOLON3 tCONSTANT tOP_ASGN arg
- {
- const = @builder.const_op_assignable(
- @builder.const_global(val[0], val[1]))
- result = @builder.op_assign(const, val[2], val[3])
- }
- | backref tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | arg tDOT2 arg
- {
- result = @builder.range_inclusive(val[0], val[1], val[2])
- }
- | arg tDOT3 arg
- {
- result = @builder.range_exclusive(val[0], val[1], val[2])
- }
- | arg tPLUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMINUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tSTAR2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tDIVIDE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPERCENT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPOW arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tUMINUS_NUM simple_numeric tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- val[1], val[2], val[3]))
- }
- | tUPLUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | tUMINUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tPIPE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCARET arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tAMPER2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCMP arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tNEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMATCH arg
- {
- result = @builder.match_op(val[0], val[1], val[2])
- }
- | arg tNMATCH arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tBANG arg
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | tTILDE arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tLSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tRSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tANDOP arg
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | arg tOROP arg
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kDEFINED opt_nl arg
- {
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
- }
-
- | arg tEH arg opt_nl tCOLON arg
- {
- result = @builder.ternary(val[0], val[1],
- val[2], val[4], val[5])
- }
- | primary
-
- arg_value: arg
-
- aref_args: none
- | args trailer
- | args tCOMMA assocs trailer
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs trailer
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- paren_args: tLPAREN2 opt_call_args rparen
- {
- result = val
- }
-
- opt_paren_args: # nothing
- {
- result = [ nil, [], nil ]
- }
- | paren_args
-
- opt_call_args: # nothing
- {
- result = []
- }
- | call_args
- | args tCOMMA
- | args tCOMMA assocs tCOMMA
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs tCOMMA
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- call_args: command
- {
- result = [ val[0] ]
- }
- | args opt_block_arg
- {
- result = val[0].concat(val[1])
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- result.concat(val[1])
- }
- | args tCOMMA assocs opt_block_arg
- {
- assocs = @builder.associate(nil, val[2], nil)
- result = val[0] << assocs
- result.concat(val[3])
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- command_args: {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
- }
- call_args
- {
- @lexer.cmdarg = val[0]
-
- result = val[1]
- }
-
- block_arg: tAMPER arg_value
- {
- result = @builder.block_pass(val[0], val[1])
- }
-
- opt_block_arg: tCOMMA block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- args: arg_value
- {
- result = [ val[0] ]
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
-
- mrhs_arg: mrhs
- {
- result = @builder.array(nil, val[0], nil)
- }
- | arg_value
-
- mrhs: args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- primary: literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | symbols
- | qsymbols
- | var_ref
- | backref
- | tFID
- {
- result = @builder.call_method(nil, nil, val[0])
- }
- | kBEGIN
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- bodystmt kEND
- {
- @lexer.cmdarg = val[1]
-
- result = @builder.begin_keyword(val[0], val[2], val[3])
- }
- | tLPAREN_ARG
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- expr
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- @lexer.cmdarg = val[1]
-
- result = @builder.begin(val[0], val[2], val[5])
- }
- | tLPAREN_ARG
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- result = @builder.begin(val[0], nil, val[3])
- }
- | tLPAREN compstmt tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.const_global(val[0], val[1])
- }
- | tLBRACK aref_args tRBRACK
- {
- result = @builder.array(val[0], val[1], val[2])
- }
- | tLBRACE assoc_list tRCURLY
- {
- result = @builder.associate(val[0], val[1], val[2])
- }
- | kRETURN
- {
- result = @builder.keyword_cmd(:return, val[0])
- }
- | kYIELD tLPAREN2 call_args rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
- }
- | kYIELD tLPAREN2 rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
- }
- | kYIELD
- {
- result = @builder.keyword_cmd(:yield, val[0])
- }
- | kDEFINED opt_nl tLPAREN2 expr rparen
- {
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
- }
- | kNOT tLPAREN2 expr rparen
- {
- result = @builder.not_op(val[0], val[1], val[2], val[3])
- }
- | kNOT tLPAREN2 rparen
- {
- result = @builder.not_op(val[0], val[1], nil, val[2])
- }
- | fcall brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | method_call
- | method_call brace_block
- {
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
- }
- | tLAMBDA lambda
- {
- lambda_call = @builder.call_lambda(val[0])
-
- args, (begin_t, body, end_t) = val[1]
- result = @builder.block(lambda_call,
- begin_t, args, body, end_t)
- }
- | kIF expr_value then compstmt if_tail kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
- }
- | kUNLESS expr_value then compstmt opt_else kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
- }
- | kWHILE
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kUNTIL
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kCASE expr_value opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[3]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
- }
- | kCASE opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[2]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
- }
- | kFOR for_var kIN
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
- }
- | kCLASS cpath superclass
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kCLASS tLSHFT expr term
- {
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- @def_level = val[4]
- }
- | kMODULE cpath
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kDEF fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kDEF singleton dot_or_colon
- {
- @lexer.state = :expr_fname
- }
- fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kBREAK
- {
- result = @builder.keyword_cmd(:break, val[0])
- }
- | kNEXT
- {
- result = @builder.keyword_cmd(:next, val[0])
- }
- | kREDO
- {
- result = @builder.keyword_cmd(:redo, val[0])
- }
- | kRETRY
- {
- result = @builder.keyword_cmd(:retry, val[0])
- }
-
- primary_value: primary
-
- then: term
- | kTHEN
- | term kTHEN
- {
- result = val[1]
- }
-
- do: term
- | kDO_COND
-
- if_tail: opt_else
- | kELSIF expr_value then compstmt if_tail
- {
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
- }
-
- opt_else: none
- | kELSE compstmt
- {
- result = val
- }
-
- for_var: lhs
- | mlhs
-
- f_marg: f_norm_arg
- {
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_marg_list: f_marg
- {
- result = [ val[0] ]
- }
- | f_marg_list tCOMMA f_marg
- {
- result = val[0] << val[2]
- }
-
- f_margs: f_marg_list
- | f_marg_list tCOMMA tSTAR f_norm_arg
- {
- result = val[0].
- push(@builder.restarg(val[2], val[3]))
- }
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.restarg(val[2], val[3])).
- concat(val[5])
- }
- | f_marg_list tCOMMA tSTAR
- {
- result = val[0].
- push(@builder.restarg(val[2]))
- }
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.restarg(val[2])).
- concat(val[4])
- }
- | tSTAR f_norm_arg
- {
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | tSTAR f_norm_arg tCOMMA f_marg_list
- {
- result = [ @builder.restarg(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.restarg(val[0]) ]
- }
- | tSTAR tCOMMA f_marg_list
- {
- result = [ @builder.restarg(val[0]),
- *val[2] ]
- }
-
- block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[2]).concat(val[3])
- }
- | f_block_kwarg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
-opt_block_args_tail:
- tCOMMA block_args_tail
- {
- result = val[1]
- }
- | # nothing
- {
- result = []
- }
-
- block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_block_optarg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_block_args_tail
- {
- result = val[0].concat(val[1])
- }
- | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_block_optarg opt_block_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_block_optarg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | block_args_tail
-
- opt_block_param: # nothing
- {
- result = @builder.args(nil, [], nil)
- }
- | block_param_def
- {
- @lexer.state = :expr_value
- }
-
- block_param_def: tPIPE opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1], val[2])
- }
- | tOROP
- {
- result = @builder.args(val[0], [], val[0])
- }
- | tPIPE block_param opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
-
- opt_bv_decl: opt_nl
- {
- result = []
- }
- | opt_nl tSEMI bv_decls opt_nl
- {
- result = val[2]
- }
-
- bv_decls: bvar
- {
- result = [ val[0] ]
- }
- | bv_decls tCOMMA bvar
- {
- result = val[0] << val[2]
- }
-
- bvar: tIDENTIFIER
- {
- result = @builder.shadowarg(val[0])
- }
- | f_bad_arg
-
- lambda: {
- @static_env.extend_dynamic
- }
- f_larglist
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- lambda_body
- {
- @lexer.cmdarg = val[2]
- @lexer.cmdarg.lexpop
-
- result = [ val[1], val[3] ]
-
- @static_env.unextend
- }
-
- f_larglist: tLPAREN2 f_args opt_bv_decl tRPAREN
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
- | f_args
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- lambda_body: tLAMBEG compstmt tRCURLY
- {
- result = [ val[0], val[1], val[2] ]
- }
- | kDO_LAMBDA compstmt kEND
- {
- result = [ val[0], val[1], val[2] ]
- }
-
- do_block: kDO_BLOCK
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- block_call: command do_block
- {
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
- }
- | block_call dot_or_colon operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | block_call dot_or_colon operation2 opt_paren_args brace_block
- {
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | block_call dot_or_colon operation2 command_args do_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
-
- method_call: fcall paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
- }
- | primary_value tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation3
- {
- result = @builder.call_method(val[0], val[1], val[2])
- }
- | primary_value tDOT paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | kSUPER paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
- }
- | kSUPER
- {
- result = @builder.keyword_cmd(:zsuper, val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index(val[0], val[1], val[2], val[3])
- }
-
- brace_block: tLCURLY
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
- | kDO
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- case_body: kWHEN args then compstmt cases
- {
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
- }
-
- cases: opt_else
- {
- result = [ val[0] ]
- }
- | case_body
-
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
- {
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
- }
- |
- {
- result = []
- }
-
- exc_list: arg_value
- {
- result = [ val[0] ]
- }
- | mrhs
- | none
-
- exc_var: tASSOC lhs
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- opt_ensure: kENSURE compstmt
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- literal: numeric
- | symbol
- | dsym
-
- strings: string
- {
- result = @builder.string_compose(nil, val[0], nil)
- }
-
- string: string1
- {
- result = [ val[0] ]
- }
- | string string1
- {
- result = val[0] << val[1]
- }
-
- string1: tSTRING_BEG string_contents tSTRING_END
- {
- result = @builder.string_compose(val[0], val[1], val[2])
- }
- | tSTRING
- {
- result = @builder.string(val[0])
- }
- | tCHARACTER
- {
- result = @builder.character(val[0])
- }
-
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
- {
- result = @builder.xstring_compose(val[0], val[1], val[2])
- }
-
- regexp: tREGEXP_BEG regexp_contents tSTRING_END tREGEXP_OPT
- {
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
- }
-
- words: tWORDS_BEG word_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- word_list: # nothing
- {
- result = []
- }
- | word_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- word: string_content
- {
- result = [ val[0] ]
- }
- | word string_content
- {
- result = val[0] << val[1]
- }
-
- symbols: tSYMBOLS_BEG symbol_list tSTRING_END
- {
- result = @builder.symbols_compose(val[0], val[1], val[2])
- }
-
- symbol_list: # nothing
- {
- result = []
- }
- | symbol_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- qwords: tQWORDS_BEG qword_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- qsymbols: tQSYMBOLS_BEG qsym_list tSTRING_END
- {
- result = @builder.symbols_compose(val[0], val[1], val[2])
- }
-
- qword_list: # nothing
- {
- result = []
- }
- | qword_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.string_internal(val[1])
- }
-
- qsym_list: # nothing
- {
- result = []
- }
- | qsym_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.symbol_internal(val[1])
- }
-
- string_contents: # nothing
- {
- result = []
- }
- | string_contents string_content
- {
- result = val[0] << val[1]
- }
-
-xstring_contents: # nothing
- {
- result = []
- }
- | xstring_contents string_content
- {
- result = val[0] << val[1]
- }
-
-regexp_contents: # nothing
- {
- result = []
- }
- | regexp_contents string_content
- {
- result = val[0] << val[1]
- }
-
- string_content: tSTRING_CONTENT
- {
- result = @builder.string_internal(val[0])
- }
- | tSTRING_DVAR string_dvar
- {
- result = val[1]
- }
- | tSTRING_DBEG
- {
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
- }
- compstmt tSTRING_DEND
- {
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
- }
-
- string_dvar: tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | backref
-
-
- symbol: tSYMBOL
- {
- result = @builder.symbol(val[0])
- }
-
- dsym: tSYMBEG xstring_contents tSTRING_END
- {
- result = @builder.symbol_compose(val[0], val[1], val[2])
- }
-
- numeric: simple_numeric
- {
- result = val[0]
- }
- | tUMINUS_NUM simple_numeric =tLOWEST
- {
- result = @builder.negate(val[0], val[1])
- }
-
- simple_numeric: tINTEGER
- {
- result = @builder.integer(val[0])
- }
- | tFLOAT
- {
- result = @builder.float(val[0])
- }
- | tRATIONAL
- {
- result = @builder.rational(val[0])
- }
- | tIMAGINARY
- {
- result = @builder.complex(val[0])
- }
-
- user_variable: tIDENTIFIER
- {
- result = @builder.ident(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tCONSTANT
- {
- result = @builder.const(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
-
-keyword_variable: kNIL
- {
- result = @builder.nil(val[0])
- }
- | kSELF
- {
- result = @builder.self(val[0])
- }
- | kTRUE
- {
- result = @builder.true(val[0])
- }
- | kFALSE
- {
- result = @builder.false(val[0])
- }
- | k__FILE__
- {
- result = @builder.__FILE__(val[0])
- }
- | k__LINE__
- {
- result = @builder.__LINE__(val[0])
- }
- | k__ENCODING__
- {
- result = @builder.__ENCODING__(val[0])
- }
-
- var_ref: user_variable
- {
- result = @builder.accessible(val[0])
- }
- | keyword_variable
- {
- result = @builder.accessible(val[0])
- }
-
- var_lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
-
- backref: tNTH_REF
- {
- result = @builder.nth_ref(val[0])
- }
- | tBACK_REF
- {
- result = @builder.back_ref(val[0])
- }
-
- superclass: term
- {
- result = nil
- }
- | tLT
- {
- @lexer.state = :expr_value
- }
- expr_value term
- {
- result = [ val[0], val[2] ]
- }
- | error term
- {
- yyerrok
- result = nil
- }
-
- f_arglist: tLPAREN2 f_args rparen
- {
- result = @builder.args(val[0], val[1], val[2])
-
- @lexer.state = :expr_value
- }
- | {
- result = @lexer.in_kwarg
- @lexer.in_kwarg = true
- }
- f_args term
- {
- @lexer.in_kwarg = val[0]
- result = @builder.args(nil, val[1], nil)
- }
-
-
- args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[2]).concat(val[3])
- }
- | f_kwarg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
- opt_args_tail: tCOMMA args_tail
- {
- result = val[1]
- }
- | # nothing
- {
- result = []
- }
-
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_optarg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_optarg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | args_tail
- {
- result = val[0]
- }
- | # nothing
- {
- result = []
- }
-
- f_bad_arg: tCONSTANT
- {
- diagnostic :error, :argument_const, nil, val[0]
- }
- | tIVAR
- {
- diagnostic :error, :argument_ivar, nil, val[0]
- }
- | tGVAR
- {
- diagnostic :error, :argument_gvar, nil, val[0]
- }
- | tCVAR
- {
- diagnostic :error, :argument_cvar, nil, val[0]
- }
-
- f_norm_arg: f_bad_arg
- | tIDENTIFIER
- {
- @static_env.declare val[0][0]
-
- result = val[0]
- }
-
- f_arg_item: f_norm_arg
- {
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_arg: f_arg_item
- {
- result = [ val[0] ]
- }
- | f_arg tCOMMA f_arg_item
- {
- result = val[0] << val[2]
- }
-
- f_label: tLABEL
- {
- check_kwarg_name(val[0])
-
- @static_env.declare val[0][0]
-
- result = val[0]
- }
-
- f_kw: f_label arg_value
- {
- result = @builder.kwoptarg(val[0], val[1])
- }
- | f_label
- {
- result = @builder.kwarg(val[0])
- }
-
- f_block_kw: f_label primary_value
- {
- result = @builder.kwoptarg(val[0], val[1])
- }
- | f_label
- {
- result = @builder.kwarg(val[0])
- }
-
- f_block_kwarg: f_block_kw
- {
- result = [ val[0] ]
- }
- | f_block_kwarg tCOMMA f_block_kw
- {
- result = val[0] << val[2]
- }
-
- f_kwarg: f_kw
- {
- result = [ val[0] ]
- }
- | f_kwarg tCOMMA f_kw
- {
- result = val[0] << val[2]
- }
-
- kwrest_mark: tPOW | tDSTAR
-
- f_kwrest: kwrest_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.kwrestarg(val[0], val[1]) ]
- }
- | kwrest_mark
- {
- result = [ @builder.kwrestarg(val[0]) ]
- }
-
- f_opt: f_norm_arg tEQL arg_value
- {
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_opt: f_norm_arg tEQL primary_value
- {
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_optarg: f_block_opt
- {
- result = [ val[0] ]
- }
- | f_block_optarg tCOMMA f_block_opt
- {
- result = val[0] << val[2]
- }
-
- f_optarg: f_opt
- {
- result = [ val[0] ]
- }
- | f_optarg tCOMMA f_opt
- {
- result = val[0] << val[2]
- }
-
- restarg_mark: tSTAR2 | tSTAR
-
- f_rest_arg: restarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | restarg_mark
- {
- result = [ @builder.restarg(val[0]) ]
- }
-
- blkarg_mark: tAMPER2 | tAMPER
-
- f_block_arg: blkarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
- }
-
- opt_f_block_arg: tCOMMA f_block_arg
- {
- result = [ val[1] ]
- }
- |
- {
- result = []
- }
-
- singleton: var_ref
- | tLPAREN2 expr rparen
- {
- result = val[1]
- }
-
- assoc_list: # nothing
- {
- result = []
- }
- | assocs trailer
-
- assocs: assoc
- {
- result = [ val[0] ]
- }
- | assocs tCOMMA assoc
- {
- result = val[0] << val[2]
- }
-
- assoc: arg_value tASSOC arg_value
- {
- result = @builder.pair(val[0], val[1], val[2])
- }
- | tLABEL arg_value
- {
- result = @builder.pair_keyword(val[0], val[1])
- }
- | tDSTAR arg_value
- {
- result = @builder.kwsplat(val[0], val[1])
- }
-
- operation: tIDENTIFIER | tCONSTANT | tFID
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
- operation3: tIDENTIFIER | tFID | op
- dot_or_colon: tDOT | tCOLON2
- opt_terms: | terms
- opt_nl: | tNL
- rparen: opt_nl tRPAREN
- {
- result = val[1]
- }
- rbracket: opt_nl tRBRACK
- {
- result = val[1]
- }
- trailer: | tNL | tCOMMA
-
- term: tSEMI
- {
- yyerrok
- }
- | tNL
-
- terms: term
- | terms tSEMI
-
- none: # nothing
- {
- result = nil
- }
-end
-
----- header
-
-require 'parser'
-
-Parser.check_for_encoding_support
-
----- inner
-
- def version
- 21
- end
-
- def default_encoding
- Encoding::UTF_8
- end
diff --git a/test/racc/assets/ruby22.y b/test/racc/assets/ruby22.y
deleted file mode 100644
index 751c0e866b..0000000000
--- a/test/racc/assets/ruby22.y
+++ /dev/null
@@ -1,2381 +0,0 @@
-# Copyright (c) 2013 Peter Zotov <whitequark@whitequark.org>
-#
-# Parts of the source are derived from ruby_parser:
-# Copyright (c) Ryan Davis, seattle.rb
-#
-# MIT License
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Parser::Ruby22
-
-token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
- tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
- tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
- tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
- tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
- tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
- tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
- tDSTAR tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
- tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tREGEXP_OPT
- tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
- tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
- tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
- tRATIONAL tIMAGINARY tLABEL_END
-
-prechigh
- right tBANG tTILDE tUPLUS
- right tPOW
- right tUMINUS_NUM tUMINUS
- left tSTAR2 tDIVIDE tPERCENT
- left tPLUS tMINUS
- left tLSHFT tRSHFT
- left tAMPER2
- left tPIPE tCARET
- left tGT tGEQ tLT tLEQ
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
- left tANDOP
- left tOROP
- nonassoc tDOT2 tDOT3
- right tEH tCOLON
- left kRESCUE_MOD
- right tEQL tOP_ASGN
- nonassoc kDEFINED
- right kNOT
- left kOR kAND
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
- nonassoc tLBRACE_ARG
- nonassoc tLOWEST
-preclow
-
-rule
-
- program: top_compstmt
-
- top_compstmt: top_stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- top_stmts: # nothing
- {
- result = []
- }
- | top_stmt
- {
- result = [ val[0] ]
- }
- | top_stmts terms top_stmt
- {
- result = val[0] << val[2]
- }
- | error top_stmt
- {
- result = [ val[1] ]
- }
-
- top_stmt: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- result = @builder.preexe(val[0], val[1], val[2], val[3])
- }
-
- bodystmt: compstmt opt_rescue opt_else opt_ensure
- {
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
- }
-
- compstmt: stmts opt_terms
- {
- result = @builder.compstmt(val[0])
- }
-
- stmts: # nothing
- {
- result = []
- }
- | stmt_or_begin
- {
- result = [ val[0] ]
- }
- | stmts terms stmt_or_begin
- {
- result = val[0] << val[2]
- }
- | error stmt
- {
- result = [ val[1] ]
- }
-
- stmt_or_begin: stmt
- | klBEGIN tLCURLY top_compstmt tRCURLY
- {
- diagnostic :error, :begin_in_method, nil, val[0]
- }
-
- stmt: kALIAS fitem
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = @builder.alias(val[0], val[1], val[3])
- }
- | kALIAS tGVAR tGVAR
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
- }
- | kALIAS tGVAR tBACK_REF
- {
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
- }
- | kALIAS tGVAR tNTH_REF
- {
- diagnostic :error, :nth_ref_alias, nil, val[2]
- }
- | kUNDEF undef_list
- {
- result = @builder.undef_method(val[0], val[1])
- }
- | stmt kIF_MOD expr_value
- {
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
- }
- | stmt kUNLESS_MOD expr_value
- {
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
- }
- | stmt kWHILE_MOD expr_value
- {
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
- }
- | stmt kUNTIL_MOD expr_value
- {
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
- }
- | stmt kRESCUE_MOD stmt
- {
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
- }
- | klEND tLCURLY compstmt tRCURLY
- {
- result = @builder.postexe(val[0], val[1], val[2], val[3])
- }
- | command_asgn
- | mlhs tEQL command_call
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN command_call
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | backref tOP_ASGN command_call
- {
- @builder.op_assign(val[0], val[1], val[2])
- }
- | lhs tEQL mrhs
- {
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
- }
- | mlhs tEQL mrhs_arg
- {
- result = @builder.multi_assign(val[0], val[1], val[2])
- }
- | expr
-
- command_asgn: lhs tEQL command_call
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL command_asgn
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
-
- expr: command_call
- | expr kAND expr
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | expr kOR expr
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kNOT opt_nl expr
- {
- result = @builder.not_op(val[0], nil, val[2], nil)
- }
- | tBANG command_call
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | arg
-
- expr_value: expr
-
- command_call: command
- | block_command
-
- block_command: block_call
- | block_call dot_or_colon operation2 command_args
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
-
- cmd_brace_block: tLBRACE_ARG
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- fcall: operation
-
- command: fcall command_args =tLOWEST
- {
- result = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
- }
- | fcall command_args cmd_brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
-
- begin_t, args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tDOT operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tDOT operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | primary_value tCOLON2 operation2 command_args =tLOWEST
- {
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
- }
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | kSUPER command_args
- {
- result = @builder.keyword_cmd(:super, val[0],
- nil, val[1], nil)
- }
- | kYIELD command_args
- {
- result = @builder.keyword_cmd(:yield, val[0],
- nil, val[1], nil)
- }
- | kRETURN call_args
- {
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
- }
- | kBREAK call_args
- {
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
- }
- | kNEXT call_args
- {
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
- }
-
- mlhs: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_inner: mlhs_basic
- {
- result = @builder.multi_lhs(nil, val[0], nil)
- }
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- mlhs_basic: mlhs_head
- | mlhs_head mlhs_item
- {
- result = val[0].
- push(val[1])
- }
- | mlhs_head tSTAR mlhs_node
- {
- result = val[0].
- push(@builder.splat(val[1], val[2]))
- }
- | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1], val[2])).
- concat(val[4])
- }
- | mlhs_head tSTAR
- {
- result = val[0].
- push(@builder.splat(val[1]))
- }
- | mlhs_head tSTAR tCOMMA mlhs_post
- {
- result = val[0].
- push(@builder.splat(val[1])).
- concat(val[3])
- }
- | tSTAR mlhs_node
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | tSTAR mlhs_node tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.splat(val[0]) ]
- }
- | tSTAR tCOMMA mlhs_post
- {
- result = [ @builder.splat(val[0]),
- *val[2] ]
- }
-
- mlhs_item: mlhs_node
- | tLPAREN mlhs_inner rparen
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
-
- mlhs_head: mlhs_item tCOMMA
- {
- result = [ val[0] ]
- }
- | mlhs_head mlhs_item tCOMMA
- {
- result = val[0] << val[1]
- }
-
- mlhs_post: mlhs_item
- {
- result = [ val[0] ]
- }
- | mlhs_post tCOMMA mlhs_item
- {
- result = val[0] << val[2]
- }
-
- mlhs_node: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
- }
- | primary_value tDOT tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tIDENTIFIER
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tDOT tCONSTANT
- {
- result = @builder.attr_asgn(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
- }
- | backref
- {
- result = @builder.assignable(val[0])
- }
-
- cname: tIDENTIFIER
- {
- diagnostic :error, :module_name_const, nil, val[0]
- }
- | tCONSTANT
-
- cpath: tCOLON3 cname
- {
- result = @builder.const_global(val[0], val[1])
- }
- | cname
- {
- result = @builder.const(val[0])
- }
- | primary_value tCOLON2 cname
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
-
- fname: tIDENTIFIER | tCONSTANT | tFID
- | op
- | reswords
-
- fsym: fname
- {
- result = @builder.symbol(val[0])
- }
- | symbol
-
- fitem: fsym
- | dsym
-
- undef_list: fitem
- {
- result = [ val[0] ]
- }
- | undef_list tCOMMA
- {
- @lexer.state = :expr_fname
- }
- fitem
- {
- result = val[0] << val[3]
- }
-
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
- | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
- | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
- | tUPLUS | tUMINUS | tAREF | tASET | tDSTAR | tBACK_REF2
-
- reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
- | kALIAS | kAND | kBEGIN | kBREAK | kCASE
- | kCLASS | kDEF | kDEFINED | kDO | kELSE
- | kELSIF | kEND | kENSURE | kFALSE | kFOR
- | kIN | kMODULE | kNEXT | kNIL | kNOT
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN
- | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
- | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
- | kUNTIL
-
- arg: lhs tEQL arg
- {
- result = @builder.assign(val[0], val[1], val[2])
- }
- | lhs tEQL arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
- }
- | var_lhs tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | var_lhs tOP_ASGN arg kRESCUE_MOD arg
- {
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.op_assign(val[0], val[1], rescue_)
- }
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
- }
- | primary_value tDOT tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tDOT tCONSTANT tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
- {
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
- {
- const = @builder.const_op_assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- result = @builder.op_assign(const, val[3], val[4])
- }
- | tCOLON3 tCONSTANT tOP_ASGN arg
- {
- const = @builder.const_op_assignable(
- @builder.const_global(val[0], val[1]))
- result = @builder.op_assign(const, val[2], val[3])
- }
- | backref tOP_ASGN arg
- {
- result = @builder.op_assign(val[0], val[1], val[2])
- }
- | arg tDOT2 arg
- {
- result = @builder.range_inclusive(val[0], val[1], val[2])
- }
- | arg tDOT3 arg
- {
- result = @builder.range_exclusive(val[0], val[1], val[2])
- }
- | arg tPLUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMINUS arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tSTAR2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tDIVIDE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPERCENT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tPOW arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tUMINUS_NUM simple_numeric tPOW arg
- {
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- val[1], val[2], val[3]))
- }
- | tUPLUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | tUMINUS arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tPIPE arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCARET arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tAMPER2 arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tCMP arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tGEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tLEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tEQQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tNEQ arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tMATCH arg
- {
- result = @builder.match_op(val[0], val[1], val[2])
- }
- | arg tNMATCH arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | tBANG arg
- {
- result = @builder.not_op(val[0], nil, val[1], nil)
- }
- | tTILDE arg
- {
- result = @builder.unary_op(val[0], val[1])
- }
- | arg tLSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tRSHFT arg
- {
- result = @builder.binary_op(val[0], val[1], val[2])
- }
- | arg tANDOP arg
- {
- result = @builder.logical_op(:and, val[0], val[1], val[2])
- }
- | arg tOROP arg
- {
- result = @builder.logical_op(:or, val[0], val[1], val[2])
- }
- | kDEFINED opt_nl arg
- {
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
- }
-
- # Note: MRI eventually came to rely on disambiguation based on
- # the lexer state, but it is too contrived with the Ragel lexer,
- # so we kept this approach. See ruby/ruby@b0c03f63e5 for
- # the initial commit, and ruby/ruby@23352f62a for MRI revert,
- # which we decided not to track.
- | arg tEH
- {
- @lexer.push_cond
- @lexer.cond.push(true)
- }
- arg opt_nl tCOLON
- {
- @lexer.pop_cond
- }
- arg
- {
- result = @builder.ternary(val[0], val[1],
- val[3], val[5], val[7])
- }
- | primary
-
- arg_value: arg
-
- aref_args: none
- | args trailer
- | args tCOMMA assocs trailer
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs trailer
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- paren_args: tLPAREN2 opt_call_args rparen
- {
- result = val
- }
-
- opt_paren_args: # nothing
- {
- result = [ nil, [], nil ]
- }
- | paren_args
-
- opt_call_args: # nothing
- {
- result = []
- }
- | call_args
- | args tCOMMA
- | args tCOMMA assocs tCOMMA
- {
- result = val[0] << @builder.associate(nil, val[2], nil)
- }
- | assocs tCOMMA
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- }
-
- call_args: command
- {
- result = [ val[0] ]
- }
- | args opt_block_arg
- {
- result = val[0].concat(val[1])
- }
- | assocs opt_block_arg
- {
- result = [ @builder.associate(nil, val[0], nil) ]
- result.concat(val[1])
- }
- | args tCOMMA assocs opt_block_arg
- {
- assocs = @builder.associate(nil, val[2], nil)
- result = val[0] << assocs
- result.concat(val[3])
- }
- | block_arg
- {
- result = [ val[0] ]
- }
-
- command_args: {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
- }
- call_args
- {
- @lexer.cmdarg = val[0]
-
- result = val[1]
- }
-
- block_arg: tAMPER arg_value
- {
- result = @builder.block_pass(val[0], val[1])
- }
-
- opt_block_arg: tCOMMA block_arg
- {
- result = [ val[1] ]
- }
- | # nothing
- {
- result = []
- }
-
- args: arg_value
- {
- result = [ val[0] ]
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
- | args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
-
- mrhs_arg: mrhs
- {
- result = @builder.array(nil, val[0], nil)
- }
- | arg_value
-
- mrhs: args tCOMMA arg_value
- {
- result = val[0] << val[2]
- }
- | args tCOMMA tSTAR arg_value
- {
- result = val[0] << @builder.splat(val[2], val[3])
- }
- | tSTAR arg_value
- {
- result = [ @builder.splat(val[0], val[1]) ]
- }
-
- primary: literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | symbols
- | qsymbols
- | var_ref
- | backref
- | tFID
- {
- result = @builder.call_method(nil, nil, val[0])
- }
- | kBEGIN
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- bodystmt kEND
- {
- @lexer.cmdarg = val[1]
-
- result = @builder.begin_keyword(val[0], val[2], val[3])
- }
- | tLPAREN_ARG
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- expr
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- @lexer.cmdarg = val[1]
-
- result = @builder.begin(val[0], val[2], val[5])
- }
- | tLPAREN_ARG
- {
- @lexer.state = :expr_endarg
- }
- opt_nl tRPAREN
- {
- result = @builder.begin(val[0], nil, val[3])
- }
- | tLPAREN compstmt tRPAREN
- {
- result = @builder.begin(val[0], val[1], val[2])
- }
- | primary_value tCOLON2 tCONSTANT
- {
- result = @builder.const_fetch(val[0], val[1], val[2])
- }
- | tCOLON3 tCONSTANT
- {
- result = @builder.const_global(val[0], val[1])
- }
- | tLBRACK aref_args tRBRACK
- {
- result = @builder.array(val[0], val[1], val[2])
- }
- | tLBRACE assoc_list tRCURLY
- {
- result = @builder.associate(val[0], val[1], val[2])
- }
- | kRETURN
- {
- result = @builder.keyword_cmd(:return, val[0])
- }
- | kYIELD tLPAREN2 call_args rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
- }
- | kYIELD tLPAREN2 rparen
- {
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
- }
- | kYIELD
- {
- result = @builder.keyword_cmd(:yield, val[0])
- }
- | kDEFINED opt_nl tLPAREN2 expr rparen
- {
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
- }
- | kNOT tLPAREN2 expr rparen
- {
- result = @builder.not_op(val[0], val[1], val[2], val[3])
- }
- | kNOT tLPAREN2 rparen
- {
- result = @builder.not_op(val[0], val[1], nil, val[2])
- }
- | fcall brace_block
- {
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | method_call
- | method_call brace_block
- {
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
- }
- | tLAMBDA lambda
- {
- lambda_call = @builder.call_lambda(val[0])
-
- args, (begin_t, body, end_t) = val[1]
- result = @builder.block(lambda_call,
- begin_t, args, body, end_t)
- }
- | kIF expr_value then compstmt if_tail kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
- }
- | kUNLESS expr_value then compstmt opt_else kEND
- {
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
- }
- | kWHILE
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kUNTIL
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
- }
- | kCASE expr_value opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[3]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
- }
- | kCASE opt_terms case_body kEND
- {
- *when_bodies, (else_t, else_body) = *val[2]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
- }
- | kFOR for_var kIN
- {
- @lexer.cond.push(true)
- }
- expr_value do
- {
- @lexer.cond.pop
- }
- compstmt kEND
- {
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
- }
- | kCLASS cpath superclass
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kCLASS tLSHFT expr term
- {
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- @def_level = val[4]
- }
- | kMODULE cpath
- {
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- bodystmt kEND
- {
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- }
- | kDEF fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kDEF singleton dot_or_colon
- {
- @lexer.state = :expr_fname
- }
- fname
- {
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
- }
- f_arglist bodystmt kEND
- {
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
- }
- | kBREAK
- {
- result = @builder.keyword_cmd(:break, val[0])
- }
- | kNEXT
- {
- result = @builder.keyword_cmd(:next, val[0])
- }
- | kREDO
- {
- result = @builder.keyword_cmd(:redo, val[0])
- }
- | kRETRY
- {
- result = @builder.keyword_cmd(:retry, val[0])
- }
-
- primary_value: primary
-
- then: term
- | kTHEN
- | term kTHEN
- {
- result = val[1]
- }
-
- do: term
- | kDO_COND
-
- if_tail: opt_else
- | kELSIF expr_value then compstmt if_tail
- {
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
- }
-
- opt_else: none
- | kELSE compstmt
- {
- result = val
- }
-
- for_var: lhs
- | mlhs
-
- f_marg: f_norm_arg
- {
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_marg_list: f_marg
- {
- result = [ val[0] ]
- }
- | f_marg_list tCOMMA f_marg
- {
- result = val[0] << val[2]
- }
-
- f_margs: f_marg_list
- | f_marg_list tCOMMA tSTAR f_norm_arg
- {
- result = val[0].
- push(@builder.restarg(val[2], val[3]))
- }
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.restarg(val[2], val[3])).
- concat(val[5])
- }
- | f_marg_list tCOMMA tSTAR
- {
- result = val[0].
- push(@builder.restarg(val[2]))
- }
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
- {
- result = val[0].
- push(@builder.restarg(val[2])).
- concat(val[4])
- }
- | tSTAR f_norm_arg
- {
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | tSTAR f_norm_arg tCOMMA f_marg_list
- {
- result = [ @builder.restarg(val[0], val[1]),
- *val[3] ]
- }
- | tSTAR
- {
- result = [ @builder.restarg(val[0]) ]
- }
- | tSTAR tCOMMA f_marg_list
- {
- result = [ @builder.restarg(val[0]),
- *val[2] ]
- }
-
- block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[2]).concat(val[3])
- }
- | f_block_kwarg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
-opt_block_args_tail:
- tCOMMA block_args_tail
- {
- result = val[1]
- }
- | # nothing
- {
- result = []
- }
-
- block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_block_optarg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_block_args_tail
- {
- result = val[0].concat(val[1])
- }
- | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_block_optarg opt_block_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_block_optarg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_block_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | block_args_tail
-
- opt_block_param: # nothing
- {
- result = @builder.args(nil, [], nil)
- }
- | block_param_def
- {
- @lexer.state = :expr_value
- }
-
- block_param_def: tPIPE opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1], val[2])
- }
- | tOROP
- {
- result = @builder.args(val[0], [], val[0])
- }
- | tPIPE block_param opt_bv_decl tPIPE
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
-
- opt_bv_decl: opt_nl
- {
- result = []
- }
- | opt_nl tSEMI bv_decls opt_nl
- {
- result = val[2]
- }
-
- bv_decls: bvar
- {
- result = [ val[0] ]
- }
- | bv_decls tCOMMA bvar
- {
- result = val[0] << val[2]
- }
-
- bvar: tIDENTIFIER
- {
- result = @builder.shadowarg(val[0])
- }
- | f_bad_arg
-
- lambda: {
- @static_env.extend_dynamic
- }
- f_larglist
- {
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
- }
- lambda_body
- {
- @lexer.cmdarg = val[2]
- @lexer.cmdarg.lexpop
-
- result = [ val[1], val[3] ]
-
- @static_env.unextend
- }
-
- f_larglist: tLPAREN2 f_args opt_bv_decl tRPAREN
- {
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
- }
- | f_args
- {
- result = @builder.args(nil, val[0], nil)
- }
-
- lambda_body: tLAMBEG compstmt tRCURLY
- {
- result = [ val[0], val[1], val[2] ]
- }
- | kDO_LAMBDA compstmt kEND
- {
- result = [ val[0], val[1], val[2] ]
- }
-
- do_block: kDO_BLOCK
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- block_call: command do_block
- {
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
- }
- | block_call dot_or_colon operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | block_call dot_or_colon operation2 opt_paren_args brace_block
- {
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
- | block_call dot_or_colon operation2 command_args do_block
- {
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
- }
-
- method_call: fcall paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
- }
- | primary_value tDOT operation2 opt_paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation2 paren_args
- {
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 operation3
- {
- result = @builder.call_method(val[0], val[1], val[2])
- }
- | primary_value tDOT paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | primary_value tCOLON2 paren_args
- {
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
- }
- | kSUPER paren_args
- {
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
- }
- | kSUPER
- {
- result = @builder.keyword_cmd(:zsuper, val[0])
- }
- | primary_value tLBRACK2 opt_call_args rbracket
- {
- result = @builder.index(val[0], val[1], val[2], val[3])
- }
-
- brace_block: tLCURLY
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt tRCURLY
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
- | kDO
- {
- @static_env.extend_dynamic
- }
- opt_block_param compstmt kEND
- {
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
- }
-
- case_body: kWHEN args then compstmt cases
- {
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
- }
-
- cases: opt_else
- {
- result = [ val[0] ]
- }
- | case_body
-
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
- {
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
- }
- |
- {
- result = []
- }
-
- exc_list: arg_value
- {
- result = [ val[0] ]
- }
- | mrhs
- | none
-
- exc_var: tASSOC lhs
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- opt_ensure: kENSURE compstmt
- {
- result = [ val[0], val[1] ]
- }
- | none
-
- literal: numeric
- | symbol
- | dsym
-
- strings: string
- {
- result = @builder.string_compose(nil, val[0], nil)
- }
-
- string: string1
- {
- result = [ val[0] ]
- }
- | string string1
- {
- result = val[0] << val[1]
- }
-
- string1: tSTRING_BEG string_contents tSTRING_END
- {
- result = @builder.string_compose(val[0], val[1], val[2])
- }
- | tSTRING
- {
- result = @builder.string(val[0])
- }
- | tCHARACTER
- {
- result = @builder.character(val[0])
- }
-
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
- {
- result = @builder.xstring_compose(val[0], val[1], val[2])
- }
-
- regexp: tREGEXP_BEG regexp_contents tSTRING_END tREGEXP_OPT
- {
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
- }
-
- words: tWORDS_BEG word_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- word_list: # nothing
- {
- result = []
- }
- | word_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- word: string_content
- {
- result = [ val[0] ]
- }
- | word string_content
- {
- result = val[0] << val[1]
- }
-
- symbols: tSYMBOLS_BEG symbol_list tSTRING_END
- {
- result = @builder.symbols_compose(val[0], val[1], val[2])
- }
-
- symbol_list: # nothing
- {
- result = []
- }
- | symbol_list word tSPACE
- {
- result = val[0] << @builder.word(val[1])
- }
-
- qwords: tQWORDS_BEG qword_list tSTRING_END
- {
- result = @builder.words_compose(val[0], val[1], val[2])
- }
-
- qsymbols: tQSYMBOLS_BEG qsym_list tSTRING_END
- {
- result = @builder.symbols_compose(val[0], val[1], val[2])
- }
-
- qword_list: # nothing
- {
- result = []
- }
- | qword_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.string_internal(val[1])
- }
-
- qsym_list: # nothing
- {
- result = []
- }
- | qsym_list tSTRING_CONTENT tSPACE
- {
- result = val[0] << @builder.symbol_internal(val[1])
- }
-
- string_contents: # nothing
- {
- result = []
- }
- | string_contents string_content
- {
- result = val[0] << val[1]
- }
-
-xstring_contents: # nothing
- {
- result = []
- }
- | xstring_contents string_content
- {
- result = val[0] << val[1]
- }
-
-regexp_contents: # nothing
- {
- result = []
- }
- | regexp_contents string_content
- {
- result = val[0] << val[1]
- }
-
- string_content: tSTRING_CONTENT
- {
- result = @builder.string_internal(val[0])
- }
- | tSTRING_DVAR string_dvar
- {
- result = val[1]
- }
- | tSTRING_DBEG
- {
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
- }
- compstmt tSTRING_DEND
- {
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
- }
-
- string_dvar: tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
- | backref
-
-
- symbol: tSYMBOL
- {
- result = @builder.symbol(val[0])
- }
-
- dsym: tSYMBEG xstring_contents tSTRING_END
- {
- result = @builder.symbol_compose(val[0], val[1], val[2])
- }
-
- numeric: simple_numeric
- {
- result = val[0]
- }
- | tUMINUS_NUM simple_numeric =tLOWEST
- {
- result = @builder.negate(val[0], val[1])
- }
-
- simple_numeric: tINTEGER
- {
- result = @builder.integer(val[0])
- }
- | tFLOAT
- {
- result = @builder.float(val[0])
- }
- | tRATIONAL
- {
- result = @builder.rational(val[0])
- }
- | tIMAGINARY
- {
- result = @builder.complex(val[0])
- }
-
- user_variable: tIDENTIFIER
- {
- result = @builder.ident(val[0])
- }
- | tIVAR
- {
- result = @builder.ivar(val[0])
- }
- | tGVAR
- {
- result = @builder.gvar(val[0])
- }
- | tCONSTANT
- {
- result = @builder.const(val[0])
- }
- | tCVAR
- {
- result = @builder.cvar(val[0])
- }
-
-keyword_variable: kNIL
- {
- result = @builder.nil(val[0])
- }
- | kSELF
- {
- result = @builder.self(val[0])
- }
- | kTRUE
- {
- result = @builder.true(val[0])
- }
- | kFALSE
- {
- result = @builder.false(val[0])
- }
- | k__FILE__
- {
- result = @builder.__FILE__(val[0])
- }
- | k__LINE__
- {
- result = @builder.__LINE__(val[0])
- }
- | k__ENCODING__
- {
- result = @builder.__ENCODING__(val[0])
- }
-
- var_ref: user_variable
- {
- result = @builder.accessible(val[0])
- }
- | keyword_variable
- {
- result = @builder.accessible(val[0])
- }
-
- var_lhs: user_variable
- {
- result = @builder.assignable(val[0])
- }
- | keyword_variable
- {
- result = @builder.assignable(val[0])
- }
-
- backref: tNTH_REF
- {
- result = @builder.nth_ref(val[0])
- }
- | tBACK_REF
- {
- result = @builder.back_ref(val[0])
- }
-
- superclass: term
- {
- result = nil
- }
- | tLT
- {
- @lexer.state = :expr_value
- }
- expr_value term
- {
- result = [ val[0], val[2] ]
- }
- | error term
- {
- yyerrok
- result = nil
- }
-
- f_arglist: tLPAREN2 f_args rparen
- {
- result = @builder.args(val[0], val[1], val[2])
-
- @lexer.state = :expr_value
- }
- | {
- result = @lexer.in_kwarg
- @lexer.in_kwarg = true
- }
- f_args term
- {
- @lexer.in_kwarg = val[0]
- result = @builder.args(nil, val[1], nil)
- }
-
- args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[2]).concat(val[3])
- }
- | f_kwarg opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_kwrest opt_f_block_arg
- {
- result = val[0].concat(val[1])
- }
- | f_block_arg
- {
- result = [ val[0] ]
- }
-
- opt_args_tail: tCOMMA args_tail
- {
- result = val[1]
- }
- | # nothing
- {
- result = []
- }
-
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
- }
- | f_arg tCOMMA f_optarg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_arg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
- }
- | f_optarg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_optarg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | f_rest_arg opt_args_tail
- {
- result = val[0].
- concat(val[1])
- }
- | f_rest_arg tCOMMA f_arg opt_args_tail
- {
- result = val[0].
- concat(val[2]).
- concat(val[3])
- }
- | args_tail
- {
- result = val[0]
- }
- | # nothing
- {
- result = []
- }
-
- f_bad_arg: tCONSTANT
- {
- diagnostic :error, :argument_const, nil, val[0]
- }
- | tIVAR
- {
- diagnostic :error, :argument_ivar, nil, val[0]
- }
- | tGVAR
- {
- diagnostic :error, :argument_gvar, nil, val[0]
- }
- | tCVAR
- {
- diagnostic :error, :argument_cvar, nil, val[0]
- }
-
- f_norm_arg: f_bad_arg
- | tIDENTIFIER
- {
- @static_env.declare val[0][0]
-
- result = val[0]
- }
-
- f_arg_asgn: f_norm_arg
- {
- result = val[0]
- }
-
- f_arg_item: f_arg_asgn
- {
- result = @builder.arg(val[0])
- }
- | tLPAREN f_margs rparen
- {
- result = @builder.multi_lhs(val[0], val[1], val[2])
- }
-
- f_arg: f_arg_item
- {
- result = [ val[0] ]
- }
- | f_arg tCOMMA f_arg_item
- {
- result = val[0] << val[2]
- }
-
- f_label: tLABEL
- {
- check_kwarg_name(val[0])
-
- @static_env.declare val[0][0]
-
- result = val[0]
- }
-
- f_kw: f_label arg_value
- {
- result = @builder.kwoptarg(val[0], val[1])
- }
- | f_label
- {
- result = @builder.kwarg(val[0])
- }
-
- f_block_kw: f_label primary_value
- {
- result = @builder.kwoptarg(val[0], val[1])
- }
- | f_label
- {
- result = @builder.kwarg(val[0])
- }
-
- f_block_kwarg: f_block_kw
- {
- result = [ val[0] ]
- }
- | f_block_kwarg tCOMMA f_block_kw
- {
- result = val[0] << val[2]
- }
-
- f_kwarg: f_kw
- {
- result = [ val[0] ]
- }
- | f_kwarg tCOMMA f_kw
- {
- result = val[0] << val[2]
- }
-
- kwrest_mark: tPOW | tDSTAR
-
- f_kwrest: kwrest_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.kwrestarg(val[0], val[1]) ]
- }
- | kwrest_mark
- {
- result = [ @builder.kwrestarg(val[0]) ]
- }
-
- f_opt: f_arg_asgn tEQL arg_value
- {
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_opt: f_arg_asgn tEQL primary_value
- {
- result = @builder.optarg(val[0], val[1], val[2])
- }
-
- f_block_optarg: f_block_opt
- {
- result = [ val[0] ]
- }
- | f_block_optarg tCOMMA f_block_opt
- {
- result = val[0] << val[2]
- }
-
- f_optarg: f_opt
- {
- result = [ val[0] ]
- }
- | f_optarg tCOMMA f_opt
- {
- result = val[0] << val[2]
- }
-
- restarg_mark: tSTAR2 | tSTAR
-
- f_rest_arg: restarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
- }
- | restarg_mark
- {
- result = [ @builder.restarg(val[0]) ]
- }
-
- blkarg_mark: tAMPER2 | tAMPER
-
- f_block_arg: blkarg_mark tIDENTIFIER
- {
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
- }
-
- opt_f_block_arg: tCOMMA f_block_arg
- {
- result = [ val[1] ]
- }
- |
- {
- result = []
- }
-
- singleton: var_ref
- | tLPAREN2 expr rparen
- {
- result = val[1]
- }
-
- assoc_list: # nothing
- {
- result = []
- }
- | assocs trailer
-
- assocs: assoc
- {
- result = [ val[0] ]
- }
- | assocs tCOMMA assoc
- {
- result = val[0] << val[2]
- }
-
- assoc: arg_value tASSOC arg_value
- {
- result = @builder.pair(val[0], val[1], val[2])
- }
- | tLABEL arg_value
- {
- result = @builder.pair_keyword(val[0], val[1])
- }
- | tSTRING_BEG string_contents tLABEL_END arg_value
- {
- result = @builder.pair_quoted(val[0], val[1], val[2], val[3])
- }
- | tDSTAR arg_value
- {
- result = @builder.kwsplat(val[0], val[1])
- }
-
- operation: tIDENTIFIER | tCONSTANT | tFID
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
- operation3: tIDENTIFIER | tFID | op
- dot_or_colon: tDOT | tCOLON2
- opt_terms: | terms
- opt_nl: | tNL
- rparen: opt_nl tRPAREN
- {
- result = val[1]
- }
- rbracket: opt_nl tRBRACK
- {
- result = val[1]
- }
- trailer: | tNL | tCOMMA
-
- term: tSEMI
- {
- yyerrok
- }
- | tNL
-
- terms: term
- | terms tSEMI
-
- none: # nothing
- {
- result = nil
- }
-end
-
----- header
-
-require 'parser'
-
-Parser.check_for_encoding_support
-
----- inner
-
- def version
- 22
- end
-
- def default_encoding
- Encoding::UTF_8
- end
diff --git a/test/racc/assets/scan.y b/test/racc/assets/scan.y
deleted file mode 100644
index 709254ed66..0000000000
--- a/test/racc/assets/scan.y
+++ /dev/null
@@ -1,72 +0,0 @@
-class P
-
-rule
-
- a: A
- {
- # comment test
-
- # comment test
-
- # string
- @sstring = 'squote string'
- @dstring = 'dquote string'
-
- # regexp
- @regexp = /some regexp with spaces/
-
- # gvar
- /regexp/ === 'some regexp matches to this string'
- @pre_match = $`
- @matched = $&
- @post_match = $'
- @m = $~
-
- # braces
- @array = []
- [1,2,3].each {|i|
- @array.push i
- }
- 3.times { @array.push 10 }
- }
-
-end
-
----- inner
-
- def parse
- @sstring = @dstring = nil
- @regexp = nil
- @pre_match = @matched = @post_match = @m = nil
-
- @src = [[:A, 'A'], [false, '$']]
- do_parse
-
- assert_equal 'squote string', @sstring
- assert_equal 'dquote string', @dstring
- assert_equal(/some regexp with spaces/, @regexp)
- assert_equal 'some ', @pre_match
- assert_equal 'regexp', @matched
- assert_equal ' matches to this string', @post_match
- assert_instance_of MatchData, @m
- end
-
- def assert_equal(ok, data)
- unless ok == data
- raise "expected <#{ok.inspect}> but is <#{data.inspect}>"
- end
- end
-
- def assert_instance_of(klass, obj)
- unless obj.instance_of?(klass)
- raise "expected #{klass} but is #{obj.class}"
- end
- end
-
- def next_token
- @src.shift
- end
-
----- footer
-
-P.new.parse
diff --git a/test/racc/assets/syntax.y b/test/racc/assets/syntax.y
deleted file mode 100644
index 727f74a29d..0000000000
--- a/test/racc/assets/syntax.y
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# racc syntax checker
-#
-
-class M1::M2::ParserClass < S1::S2::SuperClass
-
- token A
- | B C
-
- convert
- A '5'
- end
-
- prechigh
- left B
- preclow
-
- start target
-
- expect 0
-
-rule
-
- target: A B C
- {
- print 'abc'
- }
- | B C A
- | C B A
- {
- print 'cba'
- }
- | cont
-
- cont : A c2 B c2 C
-
- c2 : C C C C C
-
-end
-
----- inner
-
- junk code !!!!
-
-kjaljlajrlaolanbla /// %%% (*((( token rule
-akiurtlajluealjflaj @@@@ end end end end __END__
- laieu2o879urkq96ga(Q#*&%Q#
- #&lkji END
-
- q395q?/// liutjqlkr7
diff --git a/test/racc/assets/tp_plus.y b/test/racc/assets/tp_plus.y
deleted file mode 100644
index 388ed1302d..0000000000
--- a/test/racc/assets/tp_plus.y
+++ /dev/null
@@ -1,622 +0,0 @@
-# Released under an MIT License (http://www.opensource.org/licenses/MIT)
-# By Jay Strybis (https://github.com/unreal)
-
-class TPPlus::Parser
-token ASSIGN AT_SYM COMMENT JUMP IO_METHOD INPUT OUTPUT
-token NUMREG POSREG VREG SREG TIME_SEGMENT ARG UALM
-token MOVE DOT TO AT TERM OFFSET SKIP GROUP
-token SEMICOLON NEWLINE STRING
-token REAL DIGIT WORD EQUAL
-token EEQUAL NOTEQUAL GTE LTE LT GT BANG
-token PLUS MINUS STAR SLASH DIV AND OR MOD
-token IF ELSE END UNLESS FOR IN WHILE
-token WAIT_FOR WAIT_UNTIL TIMEOUT AFTER
-token FANUC_USE SET_SKIP_CONDITION NAMESPACE
-token CASE WHEN INDIRECT POSITION
-token EVAL TIMER TIMER_METHOD RAISE ABORT
-token POSITION_DATA TRUE_FALSE RUN TP_HEADER PAUSE
-token LPAREN RPAREN COLON COMMA LBRACK RBRACK LBRACE RBRACE
-token LABEL ADDRESS
-token false
-
-prechigh
- right BANG
- left STAR SLASH DIV MOD
- left PLUS MINUS
- left GT GTE LT LTE
- left EEQUAL NOTEQUAL
- left AND
- left OR
- right EQUAL
-preclow
-
-rule
- program
- #: statements { @interpreter.nodes = val[0].flatten }
- : statements { @interpreter.nodes = val[0] }
- |
- ;
-
-
- statements
- : statement terminator {
- result = [val[0]]
- result << val[1] unless val[1].nil?
- }
- | statements statement terminator {
- result = val[0] << val[1]
- result << val[2] unless val[2].nil?
- }
- ;
-
- block
- : NEWLINE statements { result = val[1] }
- ;
-
- optional_newline
- : NEWLINE
- |
- ;
-
- statement
- : comment
- | definition
- | namespace
- #| assignment
- | motion_statement
- #| jump
- #| io_method
- | label_definition
- | address
- | conditional
- | inline_conditional
- | forloop
- | while_loop
- #| program_call
- | use_statement
- | set_skip_statement
- | wait_statement
- | case_statement
- | fanuc_eval
- | timer_method
- | position_data
- | raise
- | tp_header_definition
- | empty_stmt
- | PAUSE { result = PauseNode.new }
- | ABORT { result = AbortNode.new }
- ;
-
- empty_stmt
- : NEWLINE { result = EmptyStmtNode.new() }
- ;
-
- tp_header_definition
- : TP_HEADER EQUAL tp_header_value { result = HeaderNode.new(val[0],val[2]) }
- ;
-
- tp_header_value
- : STRING
- | TRUE_FALSE
- ;
-
- raise
- : RAISE var_or_indirect { result = RaiseNode.new(val[1]) }
- ;
-
- timer_method
- : TIMER_METHOD var_or_indirect { result = TimerMethodNode.new(val[0],val[1]) }
- ;
-
- fanuc_eval
- : EVAL STRING { result = EvalNode.new(val[1]) }
- ;
-
- wait_statement
- : WAIT_FOR LPAREN indirectable COMMA STRING RPAREN
- { result = WaitForNode.new(val[2], val[4]) }
- | WAIT_UNTIL LPAREN expression RPAREN
- { result = WaitUntilNode.new(val[2], nil) }
- | WAIT_UNTIL LPAREN expression RPAREN DOT wait_modifier
- { result = WaitUntilNode.new(val[2],val[5]) }
- | WAIT_UNTIL LPAREN expression RPAREN DOT wait_modifier DOT wait_modifier
- { result = WaitUntilNode.new(val[2],val[5].merge(val[7])) }
- ;
-
- wait_modifier
- : timeout_modifier
- | after_modifier
- ;
-
- timeout_modifier
- : swallow_newlines TIMEOUT LPAREN label RPAREN
- { result = { label: val[3] } }
- ;
-
- after_modifier
- : swallow_newlines AFTER LPAREN indirectable COMMA STRING RPAREN
- { result = { timeout: [val[3],val[5]] } }
- ;
-
- label
- : LABEL { result = val[0] }
- ;
-
- use_statement
- : FANUC_USE indirectable { result = UseNode.new(val[0],val[1]) }
- ;
-
- # set_skip_condition x
- set_skip_statement
- : SET_SKIP_CONDITION expression { result = SetSkipNode.new(val[1]) }
- ;
-
- program_call
- : WORD LPAREN args RPAREN { result = CallNode.new(val[0],val[2]) }
- | RUN WORD LPAREN args RPAREN { result = CallNode.new(val[1],val[3],async: true) }
- ;
-
- args
- : arg { result = [val[0]] }
- | args COMMA arg { result = val[0] << val[2] }
- | { result = [] }
- ;
-
- arg
- : number
- | var
- | string
- | address
- ;
-
- string
- : STRING { result = StringNode.new(val[0]) }
- ;
-
- io_method
- : IO_METHOD var_or_indirect { result = IOMethodNode.new(val[0],val[1]) }
- | IO_METHOD LPAREN var_or_indirect RPAREN
- { result = IOMethodNode.new(val[0],val[2]) }
- | IO_METHOD LPAREN var_or_indirect COMMA number COMMA STRING RPAREN
- { result = IOMethodNode.new(val[0],val[2],{ pulse_time: val[4], pulse_units: val[6] }) }
- ;
-
- var_or_indirect
- : var
- | indirect_thing
- ;
-
-
- jump
- : JUMP label { result = JumpNode.new(val[1]) }
- ;
-
- conditional
- : IF expression block else_block END
- { result = ConditionalNode.new("if",val[1],val[2],val[3]) }
- | UNLESS expression block else_block END
- { result = ConditionalNode.new("unless",val[1],val[2],val[3]) }
- ;
-
- forloop
- : FOR var IN LPAREN minmax_val TO minmax_val RPAREN block END
- { result = ForNode.new(val[1],val[4],val[6],val[8]) }
- ;
-
- while_loop
- : WHILE expression block END { result = WhileNode.new(val[1],val[2]) }
- ;
-
- minmax_val
- : integer
- | var
- ;
-
- namespace
- : NAMESPACE WORD block END { result = NamespaceNode.new(val[1],val[2]) }
- ;
-
- case_statement
- : CASE var swallow_newlines
- case_conditions
- case_else
- END { result = CaseNode.new(val[1],val[3],val[4]) }
- ;
-
- case_conditions
- : case_condition { result = val }
- | case_conditions case_condition
- { result = val[0] << val[1] << val[2] }
- ;
-
- case_condition
- : WHEN case_allowed_condition swallow_newlines case_allowed_statement
- terminator { result = CaseConditionNode.new(val[1],val[3]) }
- ;
-
- case_allowed_condition
- : number
- | var
- ;
-
- case_else
- : ELSE swallow_newlines case_allowed_statement terminator
- { result = CaseConditionNode.new(nil,val[2]) }
- |
- ;
-
- case_allowed_statement
- : program_call
- | jump
- ;
-
- inline_conditional
- : inlineable
- | inlineable IF expression { result = InlineConditionalNode.new(val[1], val[2], val[0]) }
- | inlineable UNLESS expression { result = InlineConditionalNode.new(val[1], val[2], val[0]) }
- ;
-
- inlineable
- : jump
- | assignment
- | io_method
- | program_call
- ;
-
- else_block
- : ELSE block { result = val[1] }
- | { result = [] }
- ;
-
- motion_statement
- : MOVE DOT swallow_newlines TO LPAREN var RPAREN motion_modifiers
- { result = MotionNode.new(val[0],val[5],val[7]) }
- ;
-
- motion_modifiers
- : motion_modifier { result = val }
- | motion_modifiers motion_modifier
- { result = val[0] << val[1] }
- ;
-
- motion_modifier
- : DOT swallow_newlines AT LPAREN speed RPAREN
- { result = SpeedNode.new(val[4]) }
- | DOT swallow_newlines TERM LPAREN valid_terminations RPAREN
- { result = TerminationNode.new(val[4]) }
- | DOT swallow_newlines OFFSET LPAREN var RPAREN
- { result = OffsetNode.new(val[2],val[4]) }
- | DOT swallow_newlines TIME_SEGMENT LPAREN time COMMA time_seg_actions RPAREN
- { result = TimeNode.new(val[2],val[4],val[6]) }
- | DOT swallow_newlines SKIP LPAREN label optional_lpos_arg RPAREN
- { result = SkipNode.new(val[4],val[5]) }
- ;
-
- valid_terminations
- : integer
- | var
- | MINUS DIGIT {
- raise Racc::ParseError, sprintf("\ninvalid termination type: (%s)", val[1]) if val[1] != 1
-
- result = DigitNode.new(val[1].to_i * -1)
- }
- ;
-
- optional_lpos_arg
- : COMMA var { result = val[1] }
- |
- ;
-
- indirectable
- : number
- | var
- ;
-
- time_seg_actions
- : program_call
- | io_method
- ;
-
- time
- : var
- | number
- ;
-
- speed
- : indirectable COMMA STRING { result = { speed: val[0], units: val[2] } }
- | STRING { result = { speed: val[0], units: nil } }
- ;
-
- label_definition
- : label { result = LabelDefinitionNode.new(val[0]) }#@interpreter.add_label(val[1]) }
- ;
-
- definition
- : WORD ASSIGN definable { result = DefinitionNode.new(val[0],val[2]) }
- ;
-
- assignment
- : var_or_indirect EQUAL expression { result = AssignmentNode.new(val[0],val[2]) }
- | var_or_indirect PLUS EQUAL expression { result = AssignmentNode.new(
- val[0],
- ExpressionNode.new(val[0],"+",val[3])
- )
- }
- | var_or_indirect MINUS EQUAL expression { result = AssignmentNode.new(
- val[0],
- ExpressionNode.new(val[0],"-",val[3])
- )
- }
- ;
-
- var
- : var_without_namespaces
- | var_with_namespaces
- ;
-
- var_without_namespaces
- : WORD { result = VarNode.new(val[0]) }
- | WORD var_method_modifiers { result = VarMethodNode.new(val[0],val[1]) }
- ;
-
- var_with_namespaces
- : namespaces var_without_namespaces
- { result = NamespacedVarNode.new(val[0],val[1]) }
- ;
-
- var_method_modifiers
- : var_method_modifier { result = val[0] }
- | var_method_modifiers var_method_modifier
- { result = val[0].merge(val[1]) }
- ;
-
- var_method_modifier
- : DOT swallow_newlines WORD { result = { method: val[2] } }
- | DOT swallow_newlines GROUP LPAREN integer RPAREN
- { result = { group: val[4] } }
- ;
-
- namespaces
- : ns { result = [val[0]] }
- | namespaces ns { result = val[0] << val[1] }
- ;
-
- ns
- : WORD COLON COLON { result = val[0] }
- ;
-
-
- expression
- : unary_expression
- | binary_expression
- ;
-
- unary_expression
- : factor { result = val[0] }
- | address
- | BANG factor { result = ExpressionNode.new(val[1], "!", nil) }
- ;
-
- binary_expression
- : expression operator expression
- { result = ExpressionNode.new(val[0], val[1], val[2]) }
- ;
-
- operator
- : EEQUAL { result = "==" }
- | NOTEQUAL { result = "<>" }
- | LT { result = "<" }
- | GT { result = ">" }
- | GTE { result = ">=" }
- | LTE { result = "<=" }
- | PLUS { result = "+" }
- | MINUS { result = "-" }
- | OR { result = "||" }
- | STAR { result = "*" }
- | SLASH { result = "/" }
- | DIV { result = "DIV" }
- | MOD { result = "%" }
- | AND { result = "&&" }
- ;
-
- factor
- : number
- | signed_number
- | var
- | indirect_thing
- | paren_expr
- ;
-
- paren_expr
- : LPAREN expression RPAREN { result = ParenExpressionNode.new(val[1]) }
- ;
-
- indirect_thing
- : INDIRECT LPAREN STRING COMMA indirectable RPAREN
- { result = IndirectNode.new(val[2].to_sym, val[4]) }
- ;
-
- signed_number
- : sign DIGIT {
- val[1] = val[1].to_i * -1 if val[0] == "-"
- result = DigitNode.new(val[1])
- }
- | sign REAL { val[1] = val[1].to_f * -1 if val[0] == "-"; result = RealNode.new(val[1]) }
- ;
-
- sign
- : MINUS { result = "-" }
- ;
-
- number
- : integer
- | REAL { result = RealNode.new(val[0]) }
- ;
-
- integer
- : DIGIT { result = DigitNode.new(val[0]) }
- ;
-
- definable
- : numreg
- | output
- | input
- | posreg
- | position
- | vreg
- | number
- | signed_number
- | argument
- | timer
- | ualm
- | sreg
- ;
-
-
- sreg
- : SREG LBRACK DIGIT RBRACK { result = StringRegisterNode.new(val[2].to_i) }
- ;
-
- ualm
- : UALM LBRACK DIGIT RBRACK { result = UserAlarmNode.new(val[2].to_i) }
- ;
-
- timer
- : TIMER LBRACK DIGIT RBRACK { result = TimerNode.new(val[2].to_i) }
- ;
-
- argument
- : ARG LBRACK DIGIT RBRACK { result = ArgumentNode.new(val[2].to_i) }
- ;
-
- vreg
- : VREG LBRACK DIGIT RBRACK { result = VisionRegisterNode.new(val[2].to_i) }
- ;
-
- position
- : POSITION LBRACK DIGIT RBRACK { result = PositionNode.new(val[2].to_i) }
- ;
-
- numreg
- : NUMREG LBRACK DIGIT RBRACK { result = NumregNode.new(val[2].to_i) }
- ;
-
- posreg
- : POSREG LBRACK DIGIT RBRACK { result = PosregNode.new(val[2].to_i) }
- ;
-
- output
- : OUTPUT LBRACK DIGIT RBRACK { result = IONode.new(val[0], val[2].to_i) }
- ;
-
- input
- : INPUT LBRACK DIGIT RBRACK { result = IONode.new(val[0], val[2].to_i) }
- ;
-
- address
- : ADDRESS { result = AddressNode.new(val[0]) }
- ;
-
- comment
- : COMMENT { result = CommentNode.new(val[0]) }
- ;
-
- terminator
- : NEWLINE { result = TerminatorNode.new }
- | comment optional_newline { result = val[0] }
- # ^-- consume newlines or else we will get an extra space from EmptyStmt in the output
- | false
- |
- ;
-
- swallow_newlines
- : NEWLINE { result = TerminatorNode.new }
- |
- ;
-
- position_data
- : POSITION_DATA sn hash sn END
- { result = PositionDataNode.new(val[2]) }
- ;
-
- sn
- : swallow_newlines
- ;
-
- hash
- : LBRACE sn hash_attributes sn RBRACE { result = val[2] }
- | LBRACE sn RBRACE { result = {} }
- ;
-
- hash_attributes
- : hash_attribute { result = val[0] }
- | hash_attributes COMMA sn hash_attribute
- { result = val[0].merge(val[3]) }
- ;
-
- hash_attribute
- : STRING COLON hash_value { result = { val[0].to_sym => val[2] } }
- ;
-
- hash_value
- : STRING
- | hash
- | array
- | optional_sign DIGIT { val[1] = val[1].to_i * -1 if val[0] == "-"; result = val[1] }
- | optional_sign REAL { val[1] = val[1].to_f * -1 if val[0] == "-"; result = val[1] }
- | TRUE_FALSE { result = val[0] == "true" }
- ;
-
- optional_sign
- : sign
- |
- ;
-
- array
- : LBRACK sn array_values sn RBRACK { result = val[2] }
- ;
-
- array_values
- : array_value { result = val }
- | array_values COMMA sn array_value { result = val[0] << val[3] }
- ;
-
- array_value
- : hash_value
- ;
-
-
-end
-
----- inner
-
- include TPPlus::Nodes
-
- attr_reader :interpreter
- def initialize(scanner, interpreter = TPPlus::Interpreter.new)
- @scanner = scanner
- @interpreter = interpreter
- super()
- end
-
- def next_token
- t = @scanner.next_token
- @interpreter.line_count += 1 if t && t[0] == :NEWLINE
-
- #puts t.inspect
- t
- end
-
- def parse
- #@yydebug =true
-
- do_parse
- @interpreter
- end
-
- def on_error(t, val, vstack)
- raise ParseError, sprintf("Parse error on line #{@scanner.tok_line} column #{@scanner.tok_col}: %s (%s)",
- val.inspect, token_to_str(t) || '?')
- end
-
- class ParseError < StandardError ; end
diff --git a/test/racc/assets/twowaysql.y b/test/racc/assets/twowaysql.y
deleted file mode 100644
index d3bc748d3a..0000000000
--- a/test/racc/assets/twowaysql.y
+++ /dev/null
@@ -1,278 +0,0 @@
-# Copyright 2008-2015 Takuto Wada
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-class TwoWaySQL::Parser
-
-rule
-
-sql : stmt_list
- {
- result = RootNode.new( val[0] )
- }
-
-stmt_list :
- {
- result = []
- }
- | stmt_list stmt
- {
- result.push val[1]
- }
-
-stmt : primary
- | if_stmt
- | begin_stmt
-
-begin_stmt : BEGIN stmt_list END
- {
- result = BeginNode.new( val[1] )
- }
-
-if_stmt : IF sub_stmt else_stmt END
- {
- result = IfNode.new( val[0][1], val[1], val[2] )
- }
-
-else_stmt : ELSE sub_stmt
- {
- result = val[1]
- }
- |
- {
- result = nil
- }
-
-sub_stmt : and_stmt
- | or_stmt
- | stmt_list
-
-and_stmt : AND stmt_list
- {
- result = SubStatementNode.new( val[0][1], val[1] )
- }
-
-or_stmt : OR stmt_list
- {
- result = SubStatementNode.new( val[0][1], val[1] )
- }
-
-primary : IDENT
- {
- result = LiteralNode.new( val[0][1] )
- }
- | STRING_LITERAL
- {
- result = LiteralNode.new( val[0][1] )
- }
- | AND
- {
- result = LiteralNode.new( val[0][1] )
- }
- | OR
- {
- result = LiteralNode.new( val[0][1] )
- }
- | SPACES
- {
- result = WhiteSpaceNode.new( val[0][1], @preserve_space )
- }
- | COMMA
- {
- result = LiteralNode.new( val[0][1] )
- }
- | LPAREN
- {
- result = LiteralNode.new( val[0][1] )
- }
- | RPAREN
- {
- result = LiteralNode.new( val[0][1] )
- }
- | QUESTION
- {
- @num_questions += 1
- result = QuestionNode.new( @num_questions )
- }
- | ACTUAL_COMMENT
- {
- result = ActualCommentNode.new( val[0][1] , val[0][2] )
- }
- | bind_var
- | embed_var
-
-bind_var : BIND_VARIABLE STRING_LITERAL
- {
- result = BindVariableNode.new( val[0][1] )
- }
- | BIND_VARIABLE SPACES STRING_LITERAL
- {
- result = BindVariableNode.new( val[0][1] )
- }
- | BIND_VARIABLE IDENT
- {
- result = BindVariableNode.new( val[0][1] )
- }
- | BIND_VARIABLE SPACES IDENT
- {
- result = BindVariableNode.new( val[0][1] )
- }
- | PAREN_BIND_VARIABLE
- {
- result = ParenBindVariableNode.new( val[0][1] )
- }
-
-embed_var : EMBED_VARIABLE IDENT
- {
- result = EmbedVariableNode.new( val[0][1] )
- }
- | EMBED_VARIABLE SPACES IDENT
- {
- result = EmbedVariableNode.new( val[0][1] )
- }
-
-end
-
-
----- inner
-
-require 'strscan'
-
-def initialize(opts={})
- opts = {
- :debug => false,
- :preserve_space => true,
- :preserve_comment => false
- }.merge(opts)
- @yydebug = opts[:debug]
- @preserve_space = opts[:preserve_space]
- @preserve_comment = opts[:preserve_comment]
- @num_questions = 0
-end
-
-
-PAREN_EXAMPLE = '\([^\)]+\)'
-BEGIN_BIND_VARIABLE = '(\/|\#)\*([^\*]+)\*\1'
-BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*/
-PAREN_BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*#{PAREN_EXAMPLE}/
-EMBED_VARIABLE_PATTERN = /\A(\/|\#)\*\$([^\*]+)\*\1\s*/
-
-CONDITIONAL_PATTERN = /\A(\/|\#)\*(IF)\s+([^\*]+)\s*\*\1/
-BEGIN_END_PATTERN = /\A(\/|\#)\*(BEGIN|END)\s*\*\1/
-STRING_LITERAL_PATTERN = /\A(\'(?:[^\']+|\'\')*\')/ ## quoted string
-SPLIT_TOKEN_PATTERN = /\A(\S+?)(?=\s*(?:(?:\/|\#)\*|-{2,}|\(|\)|\,))/ ## stop on delimiters --,/*,#*,',',(,)
-LITERAL_PATTERN = /\A([^;\s]+)/
-SPACES_PATTERN = /\A(\s+)/
-QUESTION_PATTERN = /\A\?/
-COMMA_PATTERN = /\A\,/
-LPAREN_PATTERN = /\A\(/
-RPAREN_PATTERN = /\A\)/
-ACTUAL_COMMENT_PATTERN = /\A(\/|\#)\*(\s{1,}(?:.*?))\*\1/m ## start with spaces
-SEMICOLON_AT_INPUT_END_PATTERN = /\A\;\s*\Z/
-UNMATCHED_COMMENT_START_PATTERN = /\A(?:(?:\/|\#)\*)/
-
-#TODO: remove trailing spaces for S2Dao compatibility, but this spec sometimes causes SQL bugs...
-ELSE_PATTERN = /\A\-{2,}\s*ELSE\s*/
-AND_PATTERN = /\A(\ *AND)\b/i
-OR_PATTERN = /\A(\ *OR)\b/i
-
-
-def parse( io )
- @q = []
- io.each_line(nil) do |whole|
- @s = StringScanner.new(whole)
- end
- scan_str
-
- # @q.push [ false, nil ]
- @q.push [ false, [@s.pos, nil] ]
-
- ## call racc's private parse method
- do_parse
-end
-
-
-## called by racc
-def next_token
- @q.shift
-end
-
-
-def scan_str
- until @s.eos? do
- case
- when @s.scan(AND_PATTERN)
- @q.push [ :AND, [@s.pos, @s[1]] ]
- when @s.scan(OR_PATTERN)
- @q.push [ :OR, [@s.pos, @s[1]] ]
- when @s.scan(SPACES_PATTERN)
- @q.push [ :SPACES, [@s.pos, @s[1]] ]
- when @s.scan(QUESTION_PATTERN)
- @q.push [ :QUESTION, [@s.pos, nil] ]
- when @s.scan(COMMA_PATTERN)
- @q.push [ :COMMA, [@s.pos, ','] ]
- when @s.scan(LPAREN_PATTERN)
- @q.push [ :LPAREN, [@s.pos, '('] ]
- when @s.scan(RPAREN_PATTERN)
- @q.push [ :RPAREN, [@s.pos, ')'] ]
- when @s.scan(ELSE_PATTERN)
- @q.push [ :ELSE, [@s.pos, nil] ]
- when @s.scan(ACTUAL_COMMENT_PATTERN)
- @q.push [ :ACTUAL_COMMENT, [@s.pos, @s[1], @s[2]] ] if @preserve_comment
- when @s.scan(BEGIN_END_PATTERN)
- @q.push [ @s[2].intern, [@s.pos, nil] ]
- when @s.scan(CONDITIONAL_PATTERN)
- @q.push [ @s[2].intern, [@s.pos, @s[3]] ]
- when @s.scan(EMBED_VARIABLE_PATTERN)
- @q.push [ :EMBED_VARIABLE, [@s.pos, @s[2]] ]
- when @s.scan(PAREN_BIND_VARIABLE_PATTERN)
- @q.push [ :PAREN_BIND_VARIABLE, [@s.pos, @s[2]] ]
- when @s.scan(BIND_VARIABLE_PATTERN)
- @q.push [ :BIND_VARIABLE, [@s.pos, @s[2]] ]
- when @s.scan(STRING_LITERAL_PATTERN)
- @q.push [ :STRING_LITERAL, [@s.pos, @s[1]] ]
- when @s.scan(SPLIT_TOKEN_PATTERN)
- @q.push [ :IDENT, [@s.pos, @s[1]] ]
- when @s.scan(UNMATCHED_COMMENT_START_PATTERN) ## unmatched comment start, '/*','#*'
- raise Racc::ParseError, "unmatched comment. line:[#{line_no(@s.pos)}], str:[#{@s.rest}]"
- when @s.scan(LITERAL_PATTERN) ## other string token
- @q.push [ :IDENT, [@s.pos, @s[1]] ]
- when @s.scan(SEMICOLON_AT_INPUT_END_PATTERN)
- #drop semicolon at input end
- else
- raise Racc::ParseError, "syntax error at or near line:[#{line_no(@s.pos)}], str:[#{@s.rest}]"
- end
- end
-end
-
-
-## override racc's default on_error method
-def on_error(t, v, vstack)
- ## cursor in value-stack is an array of two items,
- ## that have position value as 0th item. like [731, "ctx[:limit] "]
- cursor = vstack.find do |tokens|
- tokens.size == 2 and tokens[0].kind_of?(Fixnum)
- end
- pos = cursor[0]
- line = line_no(pos)
- rest = @s.string[pos .. -1]
- raise Racc::ParseError, "syntax error at or near line:[#{line}], str:[#{rest}]"
-end
-
-
-def line_no(pos)
- lines = 0
- scanned = @s.string[0..(pos)]
- scanned.each_line { lines += 1 }
- lines
-end
diff --git a/test/racc/assets/unterm.y b/test/racc/assets/unterm.y
deleted file mode 100644
index 518acc7f31..0000000000
--- a/test/racc/assets/unterm.y
+++ /dev/null
@@ -1,5 +0,0 @@
-# unterminated action
-
-class A
-rule
- a: A {
diff --git a/test/racc/assets/useless.y b/test/racc/assets/useless.y
deleted file mode 100644
index 3f172e341c..0000000000
--- a/test/racc/assets/useless.y
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-class A
-token A B C X
-rule
-
-targ : A list B
- | A B C
-
-list: list X
-
-end
diff --git a/test/racc/assets/yyerr.y b/test/racc/assets/yyerr.y
deleted file mode 100644
index 9faae89a79..0000000000
--- a/test/racc/assets/yyerr.y
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# yyerror/yyerrok/yyaccept test
-#
-
-class A
-rule
-
-target: a b c
-
-a:
- {
- yyerror
- raise ArgumentError, "yyerror failed"
- }
- | error
-
-b:
- {
- yyerrok
- }
-
-c:
- {
- yyaccept
- raise ArgumentError, "yyaccept failed"
- }
-
-end
-
----- inner
-
- def parse
- do_parse
- end
-
- def next_token
- [false, '$end']
- end
-
- def on_error( *args )
- $stderr.puts "on_error called: args=#{args.inspect}"
- end
-
----- footer
-
-A.new.parse
diff --git a/test/racc/bench.y b/test/racc/bench.y
deleted file mode 100644
index c6ba136201..0000000000
--- a/test/racc/bench.y
+++ /dev/null
@@ -1,36 +0,0 @@
-class BenchmarkParser
-
-rule
-
- target: a a a a a a a a a a;
- a: b b b b b b b b b b;
- b: c c c c c c c c c c;
- c: d d d d d d d d d d;
- d: e e e e e e e e e e;
-
-end
-
----- inner
-
-def initialize
- @old = [ :e, 'e' ]
- @i = 0
-end
-
-def next_token
- return [false, '$'] if @i >= 10_0000
- @i += 1
- @old
-end
-
-def parse
- do_parse
-end
-
----- footer
-
-require 'benchmark'
-
-Benchmark.bm do |x|
- x.report { BenchmarkParser.new.parse }
-end
diff --git a/test/racc/helper.rb b/test/racc/helper.rb
deleted file mode 100644
index 2862a7903e..0000000000
--- a/test/racc/helper.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-verbose = $VERBOSE
-$VERBOSE = true
-begin
-
-require 'test/unit'
-begin
- require_relative './lib/core_assertions'
- Test::Unit::TestCase.include Test::Unit::CoreAssertions
-rescue LoadError
-end
-require 'racc/static'
-require 'fileutils'
-require 'tempfile'
-require 'timeout'
-
-module Racc
- class TestCase < Test::Unit::TestCase
- PROJECT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
-
- test_dir = File.join(PROJECT_DIR, 'test')
- test_dir = File.join(PROJECT_DIR, 'racc') unless File.exist?(test_dir)
- TEST_DIR = test_dir
- racc = File.join(PROJECT_DIR, 'bin', 'racc')
- racc = File.join(PROJECT_DIR, '..', 'libexec', 'racc') unless File.exist?(racc)
- RACC = racc
- ASSET_DIR = File.join(TEST_DIR, 'assets') # test grammars
- REGRESS_DIR = File.join(TEST_DIR, 'regress') # known-good generated outputs
-
- INC = [
- File.join(PROJECT_DIR, 'lib'),
- File.join(PROJECT_DIR, 'ext'),
- ].join(':')
-
- def setup
- @TEMP_DIR = Dir.mktmpdir("racc")
- @OUT_DIR = File.join(@TEMP_DIR, 'out')
- @TAB_DIR = File.join(@TEMP_DIR, 'tab') # generated parsers go here
- @LOG_DIR = File.join(@TEMP_DIR, 'log')
- @ERR_DIR = File.join(@TEMP_DIR, 'err')
- FileUtils.mkdir_p([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR])
- FileUtils.cp File.join(TEST_DIR, "src.intp"), @TEMP_DIR
- end
-
- def teardown
- FileUtils.rm_f(File.join(@TEMP_DIR, "src.intp"))
- FileUtils.rm_rf([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR, @TEMP_DIR])
- end
-
- def assert_compile(asset, args = [], **opt)
- file = File.basename(asset, '.y')
- args = ([args].flatten) + [
- "#{ASSET_DIR}/#{file}.y",
- '-Do',
- "-O#{@OUT_DIR}/#{file}",
- "-o#{@TAB_DIR}/#{file}",
- ]
- racc(*args, **opt)
- end
-
- def assert_debugfile(asset, ok)
- file = File.basename(asset, '.y')
- Dir.chdir(@LOG_DIR) do
- File.foreach("#{file}.y") do |line|
- line.strip!
- case line
- when /sr/ then assert_equal "sr#{ok[0]}", line
- when /rr/ then assert_equal "rr#{ok[1]}", line
- when /un/ then assert_equal "un#{ok[2]}", line
- when /ur/ then assert_equal "ur#{ok[3]}", line
- when /ex/ then assert_equal "ex#{ok[4]}", line
- else
- raise TestFailed, 'racc outputs unknown debug report???'
- end
- end
- end
- end
-
- def assert_exec(asset)
- lib_path = File.expand_path("../../lib", __FILE__)
- file = File.basename(asset, '.y')
- ruby "-I#{lib_path}", "#{@TAB_DIR}/#{file}"
- end
-
- def strip_version(source)
- source.sub(/This file is automatically generated by Racc \d+\.\d+\.\d+/, '')
- end
-
- def assert_output_unchanged(asset)
- # racc generates the difference results in GitHub Actions
- omit unless RUBY_PLATFORM =~ /darwin/
-
- file = File.basename(asset, '.y')
-
- expected = File.read("#{REGRESS_DIR}/#{file}")
- actual = File.read("#{@TAB_DIR}/#{file}")
- result = (strip_version(expected) == strip_version(actual))
-
- assert(result, "Output of test/assets/#{file}.y differed from " \
- "expectation. Try compiling it and diff with test/regress/#{file}.")
- end
-
- def racc(*arg, **opt)
- lib_path = File.expand_path("../../lib", __FILE__)
- ruby "-I#{lib_path}", "-S", RACC, *arg, **opt
- end
-
- def ruby(*arg, **opt)
- assert_ruby_status(["-C", @TEMP_DIR, *arg], **opt)
- end
- end
-end
-
-ensure
-$VERBOSE = verbose
-end
diff --git a/test/racc/infini.y b/test/racc/infini.y
deleted file mode 100644
index 88b1e1e93b..0000000000
--- a/test/racc/infini.y
+++ /dev/null
@@ -1,8 +0,0 @@
-
-class I
-
-rule
-
-list: list X
-
-end
diff --git a/test/racc/regress/README.txt b/test/racc/regress/README.txt
deleted file mode 100644
index dcab73260d..0000000000
--- a/test/racc/regress/README.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-These files are "known-good" compiler output, generated from a stable version of
-Racc. Whenever Racc is refactored, or changes are made which should not affect the
-compiler output, running "rake test" checks that the compiler output is exactly
-the same as these files.
-
-If a change is made which *should* change the compiler output, these files will
-have to be regenerated from the source in test/assets, and the results committed.
diff --git a/test/racc/regress/cadenza b/test/racc/regress/cadenza
deleted file mode 100644
index b8f940465a..0000000000
--- a/test/racc/regress/cadenza
+++ /dev/null
@@ -1,796 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-# racc_parser.rb : generated by racc
-
-module Cadenza
- class RaccParser < Racc::Parser
-
-module_eval(<<'...end cadenza.y/module_eval...', 'cadenza.y', 171)
-
-...end cadenza.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 37, 89, 90, 20, 21, 22, 23, 24, 121, 3,
- 89, 4, 72, 37, 71, 3, 68, 39, 3, 29,
- 43, 37, 65, 66, 33, 9, 34, 110, 74, 50,
- 35, 9, 37, 36, 9, 122, 38, 33, 128, 34,
- 77, 78, 79, 35, 89, 33, 36, 34, 37, 38,
- 3, 35, 46, 17, 36, 85, 33, 38, 34, 37,
- 76, 103, 35, 75, 83, 36, 9, 131, 38, 54,
- 55, 3, 33, 4, 34, 124, 78, 79, 35, 65,
- 66, 36, 67, 33, 38, 34, 125, 9, 109, 35,
- 56, 57, 36, 54, 55, 38, 20, 21, 22, 23,
- 24, 20, 21, 22, 23, 24, 20, 21, 22, 23,
- 24, 108, 29, 65, 66, 54, 55, 29, 56, 57,
- 111, 107, 29, 20, 21, 22, 23, 24, 20, 21,
- 22, 23, 24, 20, 21, 22, 23, 24, 112, 29,
- 3, 113, 116, 114, 29, 115, 3, 103, 39, 29,
- 20, 21, 22, 23, 24, 120, 9, 20, 21, 22,
- 23, 24, 9, 3, nil, 4, 29, 3, 3, 43,
- 46, nil, 3, 29, 87, 3, 3, 4, 116, 9,
- 56, 57, nil, 9, 9, 56, 57, 3, 9, 116,
- nil, 9, 9, 20, 21, 22, 23, 24, 20, 21,
- 22, 23, 24, 9, 65, 66, 56, 57, nil, 29,
- 56, 57, 106, nil, 29, 58, 59, 60, 61, 62,
- 63, 58, 59, 60, 61, 62, 63, 20, 21, 22,
- 23, 24, 20, 21, 22, 23, 24, 20, 21, 22,
- 23, 24, 20, 21, 22, 23, 24, 20, 21, 22,
- 23, 24, 20, 21, 22, 23, 24, 20, 21, 22,
- 23, 24, 20, 21, 22, 23, 24, 20, 21, 22,
- 23, 24, 20, 21, 22, 23, 24, 20, 21, 22,
- 23, 24, 56, 57, 65, 66 ]
-
-racc_action_check = [
- 87, 73, 53, 37, 37, 37, 37, 37, 85, 2,
- 52, 2, 36, 39, 35, 5, 32, 5, 6, 37,
- 6, 46, 51, 51, 87, 2, 87, 73, 37, 17,
- 87, 5, 43, 87, 6, 87, 87, 39, 122, 39,
- 39, 39, 39, 39, 129, 46, 39, 46, 116, 39,
- 7, 46, 7, 1, 46, 46, 43, 46, 43, 4,
- 38, 125, 43, 38, 43, 43, 7, 126, 43, 26,
- 26, 8, 116, 8, 116, 103, 116, 116, 116, 31,
- 31, 116, 31, 4, 116, 4, 105, 8, 72, 4,
- 27, 27, 4, 93, 93, 4, 24, 24, 24, 24,
- 24, 33, 33, 33, 33, 33, 34, 34, 34, 34,
- 34, 71, 24, 70, 70, 94, 94, 33, 95, 95,
- 75, 70, 34, 108, 108, 108, 108, 108, 89, 89,
- 89, 89, 89, 124, 124, 124, 124, 124, 76, 108,
- 118, 77, 118, 78, 89, 79, 41, 67, 41, 124,
- 3, 3, 3, 3, 3, 83, 118, 20, 20, 20,
- 20, 20, 41, 42, nil, 42, 3, 45, 48, 45,
- 48, nil, 49, 20, 49, 0, 82, 0, 82, 42,
- 96, 96, nil, 45, 48, 97, 97, 81, 49, 81,
- nil, 0, 82, 65, 65, 65, 65, 65, 66, 66,
- 66, 66, 66, 81, 69, 69, 98, 98, nil, 65,
- 99, 99, 69, nil, 66, 28, 28, 28, 28, 28,
- 28, 64, 64, 64, 64, 64, 64, 57, 57, 57,
- 57, 57, 29, 29, 29, 29, 29, 58, 58, 58,
- 58, 58, 59, 59, 59, 59, 59, 63, 63, 63,
- 63, 63, 54, 54, 54, 54, 54, 55, 55, 55,
- 55, 55, 56, 56, 56, 56, 56, 61, 61, 61,
- 61, 61, 62, 62, 62, 62, 62, 60, 60, 60,
- 60, 60, 100, 100, 123, 123 ]
-
-racc_action_pointer = [
- 151, 53, -15, 147, 56, -9, -6, 26, 47, nil,
- nil, nil, nil, nil, nil, nil, nil, 29, nil, nil,
- 154, nil, nil, nil, 93, nil, 60, 79, 202, 229,
- nil, 59, -9, 98, 103, 11, 9, 0, 57, 10,
- nil, 122, 139, 29, nil, 143, 18, nil, 144, 148,
- nil, 2, 8, -6, 249, 254, 259, 224, 234, 239,
- 274, 264, 269, 244, 208, 190, 195, 144, nil, 184,
- 93, 77, 60, -1, nil, 92, 110, 113, 115, 117,
- nil, 163, 152, 127, nil, -20, nil, -3, nil, 125,
- nil, nil, nil, 84, 106, 107, 169, 174, 195, 199,
- 271, nil, nil, 53, nil, 63, nil, nil, 120, nil,
- nil, nil, nil, nil, nil, nil, 45, nil, 116, nil,
- nil, nil, 10, 264, 130, 58, 39, nil, nil, 42,
- nil, nil ]
-
-racc_action_default = [
- -2, -70, -1, -70, -70, -70, -70, -70, -70, -60,
- -61, -62, -63, -64, -65, -66, -68, -70, -67, -69,
- -5, -7, -8, -9, -70, -11, -14, -17, -24, -70,
- -26, -33, -70, -70, -70, -70, -70, -70, -70, -70,
- -41, -70, -70, -70, -48, -70, -70, -52, -70, -70,
- 132, -3, -6, -70, -70, -70, -70, -70, -70, -70,
- -70, -70, -70, -70, -25, -70, -70, -70, -35, -70,
- -70, -70, -70, -70, -54, -70, -70, -70, -70, -70,
- -42, -70, -70, -70, -49, -70, -53, -70, -57, -70,
- -10, -12, -13, -15, -16, -18, -19, -20, -21, -22,
- -23, -27, -28, -29, -31, -34, -36, -37, -70, -50,
- -55, -58, -59, -38, -39, -40, -70, -44, -70, -43,
- -47, -51, -70, -4, -70, -70, -70, -45, -56, -30,
- -32, -46 ]
-
-racc_goto_table = [
- 18, 40, 19, 32, 104, 51, 52, 105, 2, 88,
- 47, 101, 102, 41, 45, 48, 49, 44, 69, 70,
- 1, 42, 51, 73, 53, 95, 96, 97, 98, 99,
- 100, 91, 92, 93, 94, 64, nil, 80, nil, 18,
- nil, 19, nil, 18, nil, 19, 18, 18, 19, 19,
- 82, 86, nil, nil, nil, nil, 84, 81, nil, nil,
- nil, nil, 130, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 123, nil, nil, 117, 119, nil,
- 18, nil, 19, nil, nil, nil, nil, nil, nil, 118,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 126, 51,
- 129, nil, nil, nil, 127, nil, 18, nil, 19 ]
-
-racc_goto_check = [
- 28, 16, 27, 6, 11, 4, 3, 12, 2, 25,
- 22, 10, 10, 2, 2, 2, 2, 19, 4, 4,
- 1, 15, 4, 3, 6, 8, 8, 8, 8, 8,
- 8, 5, 5, 7, 7, 9, nil, 16, nil, 28,
- nil, 27, nil, 28, nil, 27, 28, 28, 27, 27,
- 2, 22, nil, nil, nil, nil, 19, 15, nil, nil,
- nil, nil, 11, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 4, nil, nil, 16, 16, nil,
- 28, nil, 27, nil, nil, nil, nil, nil, nil, 2,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 6, 4,
- 3, nil, nil, nil, 16, nil, 28, nil, 27 ]
-
-racc_goto_pointer = [
- nil, 20, 8, -14, -15, -23, 0, -23, -33, 6,
- -54, -63, -60, nil, nil, 16, -4, nil, nil, 11,
- nil, nil, 3, nil, nil, -40, nil, 0, -2 ]
-
-racc_goto_default = [
- nil, nil, nil, nil, 31, 25, nil, 26, 27, 28,
- 30, nil, nil, 10, 5, nil, nil, 11, 6, nil,
- 12, 7, nil, 14, 8, nil, 13, 16, 15 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 42, :_reduce_none,
- 0, 42, :_reduce_2,
- 1, 44, :_reduce_3,
- 3, 44, :_reduce_4,
- 1, 46, :_reduce_5,
- 2, 46, :_reduce_6,
- 1, 46, :_reduce_7,
- 1, 46, :_reduce_8,
- 1, 46, :_reduce_9,
- 3, 46, :_reduce_10,
- 1, 48, :_reduce_none,
- 3, 48, :_reduce_12,
- 3, 48, :_reduce_13,
- 1, 49, :_reduce_none,
- 3, 49, :_reduce_15,
- 3, 49, :_reduce_16,
- 1, 50, :_reduce_none,
- 3, 50, :_reduce_18,
- 3, 50, :_reduce_19,
- 3, 50, :_reduce_20,
- 3, 50, :_reduce_21,
- 3, 50, :_reduce_22,
- 3, 50, :_reduce_23,
- 1, 51, :_reduce_none,
- 2, 51, :_reduce_25,
- 1, 45, :_reduce_none,
- 3, 45, :_reduce_27,
- 3, 45, :_reduce_28,
- 1, 52, :_reduce_29,
- 3, 52, :_reduce_30,
- 1, 53, :_reduce_31,
- 3, 53, :_reduce_32,
- 1, 47, :_reduce_none,
- 3, 47, :_reduce_34,
- 3, 54, :_reduce_35,
- 4, 55, :_reduce_36,
- 4, 55, :_reduce_37,
- 3, 56, :_reduce_38,
- 3, 57, :_reduce_39,
- 3, 57, :_reduce_40,
- 2, 58, :_reduce_41,
- 3, 58, :_reduce_42,
- 4, 58, :_reduce_43,
- 4, 58, :_reduce_44,
- 5, 58, :_reduce_45,
- 6, 59, :_reduce_46,
- 3, 60, :_reduce_47,
- 2, 61, :_reduce_48,
- 3, 61, :_reduce_49,
- 4, 62, :_reduce_50,
- 3, 63, :_reduce_51,
- 2, 64, :_reduce_52,
- 3, 64, :_reduce_53,
- 3, 65, :_reduce_54,
- 4, 65, :_reduce_55,
- 3, 66, :_reduce_56,
- 3, 67, :_reduce_57,
- 4, 68, :_reduce_58,
- 4, 68, :_reduce_59,
- 1, 69, :_reduce_60,
- 1, 69, :_reduce_none,
- 1, 69, :_reduce_none,
- 1, 69, :_reduce_none,
- 1, 69, :_reduce_none,
- 1, 69, :_reduce_none,
- 1, 43, :_reduce_66,
- 2, 43, :_reduce_67,
- 1, 43, :_reduce_68,
- 2, 43, :_reduce_69 ]
-
-racc_reduce_n = 70
-
-racc_shift_n = 132
-
-racc_token_table = {
- false => 0,
- :error => 1,
- "," => 2,
- :IDENTIFIER => 3,
- :INTEGER => 4,
- :REAL => 5,
- :STRING => 6,
- "(" => 7,
- ")" => 8,
- "*" => 9,
- "/" => 10,
- "+" => 11,
- "-" => 12,
- :OP_EQ => 13,
- :OP_NEQ => 14,
- :OP_LEQ => 15,
- :OP_GEQ => 16,
- ">" => 17,
- "<" => 18,
- :NOT => 19,
- :AND => 20,
- :OR => 21,
- ":" => 22,
- "|" => 23,
- :VAR_OPEN => 24,
- :VAR_CLOSE => 25,
- :STMT_OPEN => 26,
- :IF => 27,
- :STMT_CLOSE => 28,
- :UNLESS => 29,
- :ELSE => 30,
- :ENDIF => 31,
- :ENDUNLESS => 32,
- :FOR => 33,
- :IN => 34,
- :ENDFOR => 35,
- :BLOCK => 36,
- :ENDBLOCK => 37,
- :END => 38,
- :EXTENDS => 39,
- :TEXT_BLOCK => 40 }
-
-racc_nt_base = 41
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "\",\"",
- "IDENTIFIER",
- "INTEGER",
- "REAL",
- "STRING",
- "\"(\"",
- "\")\"",
- "\"*\"",
- "\"/\"",
- "\"+\"",
- "\"-\"",
- "OP_EQ",
- "OP_NEQ",
- "OP_LEQ",
- "OP_GEQ",
- "\">\"",
- "\"<\"",
- "NOT",
- "AND",
- "OR",
- "\":\"",
- "\"|\"",
- "VAR_OPEN",
- "VAR_CLOSE",
- "STMT_OPEN",
- "IF",
- "STMT_CLOSE",
- "UNLESS",
- "ELSE",
- "ENDIF",
- "ENDUNLESS",
- "FOR",
- "IN",
- "ENDFOR",
- "BLOCK",
- "ENDBLOCK",
- "END",
- "EXTENDS",
- "TEXT_BLOCK",
- "$start",
- "target",
- "document",
- "parameter_list",
- "logical_expression",
- "primary_expression",
- "filtered_expression",
- "multiplicative_expression",
- "additive_expression",
- "boolean_expression",
- "inverse_expression",
- "filter",
- "filter_list",
- "inject_statement",
- "if_tag",
- "else_tag",
- "end_if_tag",
- "if_block",
- "for_tag",
- "end_for_tag",
- "for_block",
- "block_tag",
- "end_block_tag",
- "block_block",
- "generic_block_tag",
- "end_generic_block_tag",
- "generic_block",
- "extends_statement",
- "document_component" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-# reduce 1 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 12)
- def _reduce_2(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 16)
- def _reduce_3(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 17)
- def _reduce_4(val, _values, result)
- result = val[0].push(val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 22)
- def _reduce_5(val, _values, result)
- result = VariableNode.new(val[0].value)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 23)
- def _reduce_6(val, _values, result)
- result = VariableNode.new(val[0].value, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 24)
- def _reduce_7(val, _values, result)
- result = ConstantNode.new(val[0].value)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 25)
- def _reduce_8(val, _values, result)
- result = ConstantNode.new(val[0].value)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 26)
- def _reduce_9(val, _values, result)
- result = ConstantNode.new(val[0].value)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 27)
- def _reduce_10(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 11 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 32)
- def _reduce_12(val, _values, result)
- result = OperationNode.new(val[0], "*", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 33)
- def _reduce_13(val, _values, result)
- result = OperationNode.new(val[0], "/", val[2])
- result
- end
-.,.,
-
-# reduce 14 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 38)
- def _reduce_15(val, _values, result)
- result = OperationNode.new(val[0], "+", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 39)
- def _reduce_16(val, _values, result)
- result = OperationNode.new(val[0], "-", val[2])
- result
- end
-.,.,
-
-# reduce 17 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 44)
- def _reduce_18(val, _values, result)
- result = OperationNode.new(val[0], "==", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 45)
- def _reduce_19(val, _values, result)
- result = OperationNode.new(val[0], "!=", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 46)
- def _reduce_20(val, _values, result)
- result = OperationNode.new(val[0], "<=", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 47)
- def _reduce_21(val, _values, result)
- result = OperationNode.new(val[0], ">=", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 48)
- def _reduce_22(val, _values, result)
- result = OperationNode.new(val[0], ">", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 49)
- def _reduce_23(val, _values, result)
- result = OperationNode.new(val[0], "<", val[2])
- result
- end
-.,.,
-
-# reduce 24 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 54)
- def _reduce_25(val, _values, result)
- result = BooleanInverseNode.new(val[1])
- result
- end
-.,.,
-
-# reduce 26 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 59)
- def _reduce_27(val, _values, result)
- result = OperationNode.new(val[0], "and", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 60)
- def _reduce_28(val, _values, result)
- result = OperationNode.new(val[0], "or", val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 64)
- def _reduce_29(val, _values, result)
- result = FilterNode.new(val[0].value)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 65)
- def _reduce_30(val, _values, result)
- result = FilterNode.new(val[0].value, val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 69)
- def _reduce_31(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 70)
- def _reduce_32(val, _values, result)
- result = val[0].push(val[2])
- result
- end
-.,.,
-
-# reduce 33 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 75)
- def _reduce_34(val, _values, result)
- result = FilteredValueNode.new(val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 79)
- def _reduce_35(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 83)
- def _reduce_36(val, _values, result)
- open_scope!; result = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 84)
- def _reduce_37(val, _values, result)
- open_scope!; result = BooleanInverseNode.new(val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 88)
- def _reduce_38(val, _values, result)
- result = close_scope!; open_scope!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 92)
- def _reduce_39(val, _values, result)
- result = close_scope!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 93)
- def _reduce_40(val, _values, result)
- result = close_scope!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 97)
- def _reduce_41(val, _values, result)
- result = IfNode.new(val[0], val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 98)
- def _reduce_42(val, _values, result)
- result = IfNode.new(val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 99)
- def _reduce_43(val, _values, result)
- result = IfNode.new(val[0], val[1], val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 100)
- def _reduce_44(val, _values, result)
- result = IfNode.new(val[0], val[2], val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 101)
- def _reduce_45(val, _values, result)
- result = IfNode.new(val[0], val[2], val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 105)
- def _reduce_46(val, _values, result)
- open_scope!; result = [val[2].value, val[4]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 109)
- def _reduce_47(val, _values, result)
- result = close_scope!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 114)
- def _reduce_48(val, _values, result)
- result = ForNode.new(VariableNode.new(val[0].first), val[0].last, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 115)
- def _reduce_49(val, _values, result)
- result = ForNode.new(VariableNode.new(val[0].first), val[0].last, val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 119)
- def _reduce_50(val, _values, result)
- result = open_block_scope!(val[2].value)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 123)
- def _reduce_51(val, _values, result)
- result = close_block_scope!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 128)
- def _reduce_52(val, _values, result)
- result = BlockNode.new(val[0], val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 129)
- def _reduce_53(val, _values, result)
- result = BlockNode.new(val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 133)
- def _reduce_54(val, _values, result)
- open_scope!; result = [val[1].value, []]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 134)
- def _reduce_55(val, _values, result)
- open_scope!; result = [val[1].value, val[2]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 138)
- def _reduce_56(val, _values, result)
- result = close_scope!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 142)
- def _reduce_57(val, _values, result)
- result = GenericBlockNode.new(val[0].first, val[2], val[0].last)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 146)
- def _reduce_58(val, _values, result)
- result = val[2].value
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 147)
- def _reduce_59(val, _values, result)
- result = VariableNode.new(val[2].value)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 151)
- def _reduce_60(val, _values, result)
- result = TextNode.new(val[0].value)
- result
- end
-.,.,
-
-# reduce 61 omitted
-
-# reduce 62 omitted
-
-# reduce 63 omitted
-
-# reduce 64 omitted
-
-# reduce 65 omitted
-
-module_eval(<<'.,.,', 'cadenza.y', 160)
- def _reduce_66(val, _values, result)
- push val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 161)
- def _reduce_67(val, _values, result)
- push val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 162)
- def _reduce_68(val, _values, result)
- document.extends = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cadenza.y', 163)
- def _reduce_69(val, _values, result)
- document.extends = val[1]
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class RaccParser
-end # module Cadenza
diff --git a/test/racc/regress/cast b/test/racc/regress/cast
deleted file mode 100644
index ede36bad79..0000000000
--- a/test/racc/regress/cast
+++ /dev/null
@@ -1,3425 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-
-require 'set'
-
-# Error classes
-module C
- class ParseError < StandardError; end
-end
-
-# Local variables:
-# mode: ruby
-# end:
-module C
- class Parser < Racc::Parser
-
-module_eval(<<'...end cast.y/module_eval...', 'cast.y', 564)
- # A.1.9 -- Preprocessing numbers -- skip
- # A.1.8 -- Header names -- skip
-
- # A.1.7 -- Puncuators -- we don't bother with {##,#,%:,%:%:} since
- # we don't do preprocessing
- @@punctuators = %r'\+\+|-[->]|&&|\|\||\.\.\.|(?:<<|>>|[<>=!*/%+\-&^|])=?|[\[\](){}.~?:;,]'
- @@digraphs = %r'<[:%]|[:%]>'
-
- # A.1.6 -- String Literals -- simple for us because we don't decode
- # the string (and indeed accept some illegal strings)
- @@string_literal = %r'L?"(?:[^\\]|\\.)*?"'m
-
- # A.1.5 -- Constants
- @@decimal_floating_constant = %r'(?:(?:\d*\.\d+|\d+\.)(?:e[-+]?\d+)?|\d+e[-+]?\d+)[fl]?'i
- @@hexadecimal_floating_constant = %r'0x(?:(?:[0-9a-f]*\.[0-9a-f]+|[0-9a-f]+\.)|[0-9a-f]+)p[-+]?\d+[fl]?'i
-
- @@integer_constant = %r'(?:[1-9][0-9]*|0x[0-9a-f]+|0[0-7]*)(?:ul?l?|ll?u?)?'i
- @@floating_constant = %r'#{@@decimal_floating_constant}|#{@@hexadecimal_floating_constant}'
- @@enumeration_constant = %r'[a-zA-Z_\\][a-zA-Z_\\0-9]*'
- @@character_constant = %r"L?'(?:[^\\]|\\.)+?'"
- # (note that as with string-literals, we accept some illegal
- # character-constants)
-
- # A.1.4 -- Universal character names -- skip
-
- # A.1.3 -- Identifiers -- skip, since an identifier is lexically
- # identical to an enumeration constant
-
- # A.1.2 Keywords
- keywords = %w'auto break case char const continue default do
-double else enum extern float for goto if inline int long register
-restrict return short signed sizeof static struct switch typedef union
- unsigned void volatile while _Bool _Complex _Imaginary'
- @@keywords = %r"#{keywords.join('|')}"
-
- def initialize
- @type_names = ::Set.new
-
- @warning_proc = lambda{}
- @pos = C::Node::Pos.new(nil, 1, 0)
- end
- def initialize_copy(x)
- @pos = x.pos.dup
- @type_names = x.type_names.dup
- end
- attr_accessor :pos, :type_names
-
- def parse(str)
- if str.respond_to? :read
- str = str.read
- end
- @str = str
- begin
- prepare_lexer(str)
- return do_parse
- rescue ParseError => e
- e.set_backtrace(caller)
- raise
- end
- end
-
- #
- # Error handler, as used by racc.
- #
- def on_error(error_token_id, error_value, value_stack)
- if error_value == '$'
- parse_error @pos, "unexpected EOF"
- else
- parse_error(error_value.pos,
- "parse error on #{token_to_str(error_token_id)} (#{error_value.val})")
- end
- end
-
- def self.feature(name)
- attr_writer "#{name}_enabled"
- class_eval <<-EOS
- def enable_#{name}
- @#{name}_enabled = true
- end
- def #{name}_enabled?
- @#{name}_enabled
- end
- EOS
- end
- private_class_method :feature
-
- #
- # Allow blocks in parentheses as expressions, as per the gcc
- # extension. [http://rubyurl.com/iB7]
- #
- feature :block_expressions
-
- private # ---------------------------------------------------------
-
- class Token
- attr_accessor :pos, :val
- def initialize(pos, val)
- @pos = pos
- @val = val
- end
- end
- def eat(str)
- lines = str.split(/\r\n|[\r\n]/, -1)
- if lines.length == 1
- @pos.col_num += lines[0].length
- else
- @pos.line_num += lines.length - 1
- @pos.col_num = lines[-1].length
- end
- end
-
- #
- # Make a Declaration from the given specs and declarators.
- #
- def make_declaration(pos, specs, declarators)
- specs.all?{|x| x.is_a?(Symbol) || x.is_a?(Type)} or raise specs.map{|x| x.class}.inspect
- decl = Declaration.new_at(pos, nil, declarators)
-
- # set storage class
- storage_classes = specs.find_all do |x|
- [:typedef, :extern, :static, :auto, :register].include? x
- end
- # 6.7.1p2: at most, one storage-class specifier may be given in
- # the declaration specifiers in a declaration
- storage_classes.length <= 1 or
- begin
- if declarators.length == 0
- for_name = ''
- else
- for_name = "for `#{declarators[0].name}'"
- end
- parse_error pos, "multiple or duplicate storage classes given #{for_name}'"
- end
- decl.storage = storage_classes[0]
-
- # set type (specifiers, qualifiers)
- decl.type = make_direct_type(pos, specs)
-
- # set function specifiers
- decl.inline = specs.include?(:inline)
-
- # look for new type names
- if decl.typedef?
- decl.declarators.each do |d|
- if d.name
- @type_names << d.name
- end
- end
- end
-
- return decl
- end
-
- def make_function_def(pos, specs, func_declarator, decl_list, defn)
- add_decl_type(func_declarator, make_direct_type(pos, specs))
-
- # get types from decl_list if necessary
- function = func_declarator.indirect_type
- function.is_a? Function or
- parse_error pos, "non function type for function `#{func_declarator.name}'"
- params = function.params
- if decl_list
- params.all?{|p| p.type.nil?} or
- parse_error pos, "both prototype and declaration list given for `#{func_declarator.name}'"
- decl_list.each do |declaration|
- declaration.declarators.each do |declarator|
- param = params.find{|p| p.name == declarator.name} or
- parse_error pos, "no parameter named #{declarator.name}"
- if declarator.indirect_type
- param.type = declarator.indirect_type
- param.type.direct_type = declaration.type.dup
- else
- param.type = declaration.type.dup
- end
- end
- end
- params.all?{|p| p.type} or
- begin
- s = params.find_all{|p| p.type.nil?}.map{|p| "`#{p.name}'"}.join(' and ')
- parse_error pos, "types missing for parameters #{s}"
- end
- end
-
- fd = FunctionDef.new_at(pos,
- function.detach,
- func_declarator.name,
- defn,
- :no_prototype => !decl_list.nil?)
-
- # set storage class
- # 6.9.1p4: only extern or static allowed
- specs.each do |s|
- [:typedef, :auto, :register].include?(s) and
- "`#{s}' illegal for function"
- end
- storage_classes = specs.find_all do |s|
- s == :extern || s == :static
- end
- # 6.7.1p2: at most, one storage-class specifier may be given in
- # the declaration specifiers in a declaration
- storage_classes.length <= 1 or
- "multiple or duplicate storage classes given for `#{func_declarator.name}'"
- fd.storage = storage_classes[0] if storage_classes[0]
-
- # set function specifiers
- # 6.7.4p5 'inline' can be repeated
- fd.inline = specs.include?(:inline)
-
- return fd
- end
-
- #
- # Make a direct type from the list of type specifiers and type
- # qualifiers.
- #
- def make_direct_type(pos, specs)
- specs_order = [:signed, :unsigned, :short, :long, :double, :void,
- :char, :int, :float, :_Bool, :_Complex, :_Imaginary]
-
- type_specs = specs.find_all do |x|
- specs_order.include?(x) || !x.is_a?(Symbol)
- end
- type_specs.sort! do |a, b|
- (specs_order.index(a)||100) <=> (specs_order.index(b)||100)
- end
-
- # set type specifiers
- # 6.7.2p2: the specifier list should be one of these
- type =
- case type_specs
- when [:void]
- Void.new
- when [:char]
- Char.new
- when [:signed, :char]
- Char.new :signed => true
- when [:unsigned, :char]
- Char.new :signed => false
- when [:short], [:signed, :short], [:short, :int],
- [:signed, :short, :int]
- Int.new :longness => -1
- when [:unsigned, :short], [:unsigned, :short, :int]
- Int.new :unsigned => true, :longness => -1
- when [:int], [:signed], [:signed, :int]
- Int.new
- when [:unsigned], [:unsigned, :int]
- Int.new :unsigned => true
- when [:long], [:signed, :long], [:long, :int],
- [:signed, :long, :int]
- Int.new :longness => 1
- when [:unsigned, :long], [:unsigned, :long, :int]
- Int.new :longness => 1, :unsigned => true
- when [:long, :long], [:signed, :long, :long],
- [:long, :long, :int], [:signed, :long, :long, :int]
- Int.new :longness => 2
- when [:unsigned, :long, :long], [:unsigned, :long, :long, :int]
- Int.new :longness => 2, :unsigned => true
- when [:float]
- Float.new
- when [:double]
- Float.new :longness => 1
- when [:long, :double]
- Float.new :longness => 2
- when [:_Bool]
- Bool.new
- when [:float, :_Complex]
- Complex.new
- when [:double, :_Complex]
- Complex.new :longness => 1
- when [:long, :double, :_Complex]
- Complex.new :longness => 2
- when [:float, :_Imaginary]
- Imaginary.new
- when [:double, :_Imaginary]
- Imaginary.new :longness => 1
- when [:long, :double, :_Imaginary]
- Imaginary.new :longness => 2
- else
- if type_specs.length == 1 &&
- [CustomType, Struct, Union, Enum].any?{|c| type_specs[0].is_a? c}
- type_specs[0]
- else
- if type_specs == []
- parse_error pos, "no type specifiers given"
- else
- parse_error pos, "invalid type specifier combination: #{type_specs.join(' ')}"
- end
- end
- end
- type.pos ||= pos
-
- # set type qualifiers
- # 6.7.3p4: type qualifiers can be repeated
- type.const = specs.any?{|x| x.equal? :const }
- type.restrict = specs.any?{|x| x.equal? :restrict}
- type.volatile = specs.any?{|x| x.equal? :volatile}
-
- return type
- end
-
- def make_parameter(pos, specs, indirect_type, name)
- type = indirect_type
- if type
- type.direct_type = make_direct_type(pos, specs)
- else
- type = make_direct_type(pos, specs)
- end
- [:typedef, :extern, :static, :auto, :inline].each do |sym|
- specs.include? sym and
- parse_error pos, "parameter `#{declarator.name}' declared `#{sym}'"
- end
- return Parameter.new_at(pos, type, name,
- :register => specs.include?(:register))
- end
-
- def add_type_quals(type, quals)
- type.const = quals.include?(:const )
- type.restrict = quals.include?(:restrict)
- type.volatile = quals.include?(:volatile)
- return type
- end
-
- #
- # Add te given type as the "most direct" type to the given
- # declarator. Return the declarator.
- #
- def add_decl_type(declarator, type)
- if declarator.indirect_type
- declarator.indirect_type.direct_type = type
- else
- declarator.indirect_type = type
- end
- return declarator
- end
-
- def param_list(params, var_args)
- if params.length == 1 &&
- params[0].type.is_a?(Void) &&
- params[0].name.nil?
- return NodeArray[]
- elsif params.empty?
- return nil
- else
- return params
- end
- end
-
- def parse_error(pos, str)
- raise ParseError, "#{pos}: #{str}"
- end
-
-...end cast.y/module_eval...
-##### State transition tables begin ###
-
-clist = [
-'99,100,65,277,108,109,120,38,373,110,111,112,113,114,115,116,117,99',
-'100,65,48,108,109,120,312,424,110,111,112,113,114,115,116,117,43,293',
-'48,425,196,366,281,72,49,50,56,128,426,38,59,294,123,124,126,127,129',
-'130,131,132,312,290,372,281,128,49,38,386,416,123,124,126,127,129,130',
-'131,132,49,365,309,71,196,50,391,183,50,147,148,149,150,88,38,196,48',
-'185,38,88,281,184,50,442,196,50,147,148,149,150,99,100,65,277,108,109',
-'120,366,50,110,111,112,113,114,115,116,117,99,100,65,50,108,109,120',
-'50,49,110,111,112,113,114,115,116,117,88,88,48,249,250,72,281,241,242',
-'169,365,128,238,38,413,89,123,124,126,127,129,130,131,132,88,239,240',
-'196,128,50,38,349,84,123,124,126,127,129,130,131,132,49,71,83,440,288',
-'50,195,346,50,147,148,149,150,445,43,262,48,439,289,196,263,347,77,196',
-'428,50,147,148,149,150,99,100,65,50,108,109,120,196,50,110,111,112,113',
-'114,115,116,117,99,100,65,50,108,109,120,238,49,110,111,112,113,114',
-'115,116,117,227,238,315,239,240,245,246,247,248,243,244,128,283,38,239',
-'240,123,124,126,127,129,130,131,132,314,284,243,244,128,50,38,379,68',
-'123,124,126,127,129,130,131,132,34,35,36,196,69,308,49,307,50,147,148',
-'149,150,303,228,229,230,231,232,233,234,235,236,237,192,50,147,148,149',
-'150,99,100,65,296,108,109,120,243,244,110,111,112,113,114,115,116,117',
-'99,100,65,50,108,109,120,447,376,110,111,112,113,114,115,116,117,196',
-'196,387,353,313,273,245,246,247,248,355,128,388,38,196,274,123,124,126',
-'127,129,130,131,132,245,246,247,248,128,285,38,454,437,123,124,126,127',
-'129,130,131,132,196,196,357,427,450,377,433,375,50,147,148,149,150,196',
-'196,196,196,196,34,35,36,241,242,50,49,50,147,148,149,150,99,100,65',
-'61,108,109,120,241,242,110,111,112,113,114,115,116,117,99,100,65,275',
-'108,109,120,243,244,110,111,112,113,114,115,116,117,249,250,243,244',
-'255,256,272,271,268,67,254,128,378,38,253,252,123,124,126,127,129,130',
-'131,132,251,389,390,251,128,252,38,253,254,123,124,126,127,129,130,131',
-'132,395,396,397,398,399,209,405,406,50,147,148,149,150,206,205,202,199',
-'198,197,192,191,384,384,187,88,50,147,148,149,150,99,100,65,103,108',
-'109,120,423,,110,111,112,113,114,115,116,117,,,10,11,12,13,14,15,16',
-'17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,37,,,128,,38,,,123,124',
-'126,127,129,130,131,132,99,100,65,,108,109,120,,,110,111,112,113,114',
-'115,116,117,,,,,,,,,50,147,148,149,150,,,,,,178,,,,,,,48,,,128,,38,',
-',123,124,126,127,129,130,131,132,99,100,65,,108,109,120,,,110,111,112',
-'113,114,115,116,117,,,,,,,49,,50,147,148,149,150,,,,,,178,,,,,,,48,',
-',128,,38,,,123,124,126,127,129,130,131,132,99,100,65,50,108,109,120',
-',,110,111,112,113,114,115,116,117,,,,,,,49,,50,147,148,149,150,,,,,',
-',,,,,,,,,,128,,38,,,123,124,126,127,129,130,131,132,99,100,65,50,108',
-'109,120,,,110,111,112,113,114,115,116,117,,,,,,,,,50,147,148,149,150',
-',,,,,,,,,,,,,,,128,,38,,,123,124,126,127,129,130,131,132,99,100,65,',
-'108,109,120,,,110,111,112,113,114,115,116,117,,,,,,,,,50,147,148,149',
-'150,,,,,,,,,,,,,,,,128,,38,,,123,124,126,127,129,130,131,132,99,100',
-'65,,108,109,120,,,110,111,112,113,114,115,116,117,,,,,,,,,50,147,148',
-'149,150,,,,,,,,,,,,,,,,128,,38,,,123,124,126,127,129,130,131,132,99',
-'100,65,,108,109,120,,,110,111,112,113,114,115,116,117,,,,,,,,,50,147',
-'148,149,150,,,,,,,,,,,,,,,,128,,38,,,123,124,126,127,129,130,131,132',
-'99,100,65,,108,109,120,,,110,111,112,113,114,115,116,117,,,,,,,,,50',
-'147,148,149,150,,,,,,,,,,,,,,,,128,,38,,,123,124,126,127,129,130,131',
-'132,99,100,65,,108,109,120,,,110,111,112,113,114,115,116,117,,,,,,,',
-',50,147,148,149,150,,,,,,,,,,,,,,,,128,,38,,120,123,124,126,127,129',
-'130,131,132,99,100,65,,108,109,120,,,110,111,112,113,114,115,116,117',
-',,,,215,,,,50,147,148,149,150,128,,,,,123,124,126,127,129,130,131,132',
-',,128,,38,,,123,124,126,127,129,130,131,132,214,,,,,216,217,218,219',
-',50,147,148,149,150,,,,,,,,,,,50,147,148,149,150,99,100,65,193,108,109',
-'120,,,110,111,112,113,114,115,116,117,,,10,11,12,13,14,15,16,17,18,19',
-'20,21,22,23,24,25,26,31,32,33,34,35,36,37,,,128,,38,,,123,124,126,127',
-'129,130,131,132,99,100,65,,108,109,120,,,110,111,112,113,114,115,116',
-'117,154,453,,,120,,,,50,147,148,149,150,,,,,,,,,,,,,,,,128,,38,,,123',
-'124,126,127,129,130,131,132,262,,128,,,263,,123,124,126,127,129,130',
-'131,132,,,,,,,,,,,50,147,148,149,150,65,,,,120,,,,,,50,147,148,149,150',
-'154,,,,120,,,15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,',
-',,128,,38,,,123,124,126,127,129,130,131,132,,,128,,,,,123,124,126,127',
-'129,130,131,132,154,,,,120,,,,,,50,147,148,149,150,384,,,,120,,,,,,50',
-'147,148,149,150,,,,,,,,,,,,,,128,,,,,123,124,126,127,129,130,131,132',
-',,128,,,,,123,124,126,127,129,130,131,132,154,,,,120,,,,,,50,147,148',
-'149,150,154,392,,,120,,,,,,50,147,148,149,150,,,,,,,,,,,,262,,128,,',
-'263,,123,124,126,127,129,130,131,132,262,,128,,,263,,123,124,126,127',
-'129,130,131,132,,,,,,,,,,,50,147,148,149,150,65,,,,120,,,,,,50,147,148',
-'149,150,154,,,,120,,,15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34',
-'35,36,,,,128,,38,,,123,124,126,127,129,130,131,132,,,128,,,,,123,124',
-'126,127,129,130,131,132,154,,,,120,,,,,,50,147,148,149,150,,,,,,,,,',
-',50,147,148,149,150,,,,,,,,,,,,262,,128,,,263,,123,124,126,127,129,130',
-'131,132,,,,,,,,,65,,,,120,,,,,,,,,,,,,50,147,148,149,150,15,16,17,18',
-'19,20,21,22,23,24,25,26,31,32,33,34,35,36,,,,128,,38,,,123,124,126,127',
-'129,130,131,132,381,,120,,,,,,,,,,,383,,120,,,,,,,,,,50,147,148,149',
-'150,,,,,,,,,,,,128,,,,,123,124,126,127,129,130,131,132,128,,,,,123,124',
-'126,127,129,130,131,132,,,,,,,,,,,,,50,147,148,149,150,305,,120,,,,',
-',50,147,148,149,150,,,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25',
-'26,31,32,33,34,35,36,37,,,128,,38,,,123,124,126,127,129,130,131,132',
-'208,,120,,,,,,,,,,,412,,120,,,,,,,,,,50,147,148,149,150,,,,,,,,,,,,128',
-',,,,123,124,126,127,129,130,131,132,128,,,,120,123,124,126,127,129,130',
-'131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,,,,50,147,148,149,150',
-'128,,,,,123,124,126,127,129,130,131,132,128,,,,120,123,124,126,127,129',
-'130,131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,,,,50,147,148,149',
-'150,128,,,,,123,124,126,127,129,130,131,132,128,,,,,123,124,126,127',
-'129,130,131,132,,,120,,,,,,,,,,50,147,148,149,150,160,120,444,,,,,,50',
-'147,148,149,150,,,,,,34,35,36,,,159,161,,,,,123,124,126,127,129,130',
-'131,132,,,,128,,,,,123,124,126,127,129,130,131,132,120,436,,,,,,,,50',
-'147,148,149,150,120,432,,,,,,,,,,50,147,148,149,150,,,,,,,,,,128,,,',
-',123,124,126,127,129,130,131,132,,128,,,,,123,124,126,127,129,130,131',
-'132,120,430,,,,,,,,,,50,147,148,149,150,120,,,,,,,,,50,147,148,149,150',
-',,,,,,,,,128,,,,,123,124,126,127,129,130,131,132,,,,128,,,,120,123,124',
-'126,127,129,130,131,132,,,,,,,,,,50,147,148,149,150,,,,,,,,,,,,50,147',
-'148,149,150,128,,,,,123,124,126,127,129,130,131,132,,,,,,,,,,,,,120',
-',,,,,,,,,,,,50,147,148,149,150,15,16,17,18,19,20,21,22,23,24,25,26,31',
-'32,33,34,35,36,,,,128,,38,,,123,124,126,127,129,130,131,132,120,418',
-',,,,,,,,,,,120,415,,,,,,,,,,,50,147,148,149,150,,,,,,,,,,128,,,,,123',
-'124,126,127,129,130,131,132,128,,,,120,123,124,126,127,129,130,131,132',
-',,,,,,,,,,,,50,147,148,149,150,,,,,,,,,50,147,148,149,150,128,,,,,123',
-'124,126,127,129,130,131,132,120,,,,,,,,,,,,,120,,266,,,,,,,,,,50,147',
-'148,149,150,,,,34,35,36,,,265,267,,,,,123,124,126,127,129,130,131,132',
-'128,,,,,123,124,126,127,129,130,131,132,120,,,,,,,,,,,,50,147,148,149',
-'150,120,,,,,,,,50,147,148,149,150,,,,34,35,36,,,,128,,,,,123,124,126',
-'127,129,130,131,132,,,,368,369,,,,,123,124,126,127,129,130,131,132,120',
-',,,,,,,50,147,148,149,150,120,,,,,,,,,,,,50,147,148,149,150,,,,34,35',
-'36,,,,128,,,,,123,124,126,127,129,130,131,132,128,,,,120,123,124,126',
-'127,129,130,131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,,,,50,147',
-'148,149,150,128,,,,,123,124,126,127,129,130,131,132,128,,,,120,123,124',
-'126,127,129,130,131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,,,,50',
-'147,148,149,150,128,,,,,123,124,126,127,129,130,131,132,128,,,,120,123',
-'124,126,127,129,130,131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,',
-',,50,147,148,149,150,128,,,,,123,124,126,127,129,130,131,132,128,,,',
-'120,123,124,126,127,129,130,131,132,,,,,120,,,,,,,,50,147,148,149,150',
-',,,,,,,,50,147,148,149,150,128,,,,,123,124,126,127,129,130,131,132,128',
-',,,120,123,124,126,127,129,130,131,132,,,,,120,,,,,,,,50,147,148,149',
-'150,,,,,,,,,50,147,148,149,150,128,,,,,123,124,126,127,129,130,131,132',
-'128,,,,120,123,124,126,127,129,130,131,132,,,,,120,,,,,,,,50,147,148',
-'149,150,,,,,,,,,50,147,148,149,150,128,,,,,123,124,126,127,129,130,131',
-'132,128,,,,120,123,124,126,127,129,130,131,132,,,,,120,,,,,,,,50,147',
-'148,149,150,,,,,,,,,50,147,148,149,150,128,,,,,123,124,126,127,129,130',
-'131,132,128,,,,120,123,124,126,127,129,130,131,132,,,,,,,,,,,,,50,147',
-'148,149,150,,,,,,,,,50,147,148,149,150,128,,,,,123,124,126,127,129,130',
-'131,132,,,,,,,,,,,,,120,318,,,,,,,,,,,,50,147,148,149,150,15,16,17,18',
-'19,20,21,22,23,24,25,26,31,32,33,34,35,36,,,,128,,38,,120,123,124,126',
-'127,129,130,131,132,,,,,120,,,,,,,,,,,,,,,,,,,,,50,147,148,149,150,128',
-',,,,123,124,126,127,129,130,131,132,128,,,,120,123,124,126,127,129,130',
-'131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,,,,50,147,148,149,150',
-'128,,,,,123,124,126,127,129,130,131,132,128,,,,120,123,124,126,127,129',
-'130,131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,,,,50,147,148,149',
-'150,128,,,,,123,124,126,127,129,130,131,132,128,,,,120,123,124,126,127',
-'129,130,131,132,,,,,120,,,,,,,,50,147,148,149,150,,,,,,,,,50,147,148',
-'149,150,128,,,,,123,124,126,127,129,130,131,132,128,,,,220,123,124,126',
-'127,129,130,131,132,,,,,220,,,,,,,,50,147,148,149,150,,,,,,,,,50,147',
-'148,149,150,128,,,,,123,124,126,127,129,130,131,132,128,,,,120,123,124',
-'126,127,129,130,131,132,,,,,224,,,,,,,,50,147,148,149,150,,,,,,,,,50',
-'147,148,149,150,128,,,,,123,124,126,127,129,130,131,132,128,,,,,123',
-'124,126,127,129,130,131,132,120,,,,,,,,,,,,50,147,148,149,150,,,,,,',
-',,50,147,148,149,150,,,,,,,,,401,402,,,,,123,124,126,127,129,130,131',
-'132,,,,,,,,,,,,,,,,,,277,364,,,,,,,50,147,148,149,150,10,11,12,13,14',
-'15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,37,281,164,49',
-',38,,,,,,,,,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,31,32',
-'33,34,35,36,37,,,,50,38,,,,,,,,,,,,,,,39,,,,,,,,,,,,,,,,,,,,,50,10,11',
-'12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,37,65',
-',,,38,,,,,,,,,,,,67,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25',
-'26,31,32,33,34,35,36,37,65,,,,38,,,,,,,,,,,,,10,11,12,13,14,15,16,17',
-'18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,37,173,,,,38,,,,,,,,,,',
-',,,,,,15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,282,,,,',
-'38,,,,,,,,,,,,,,,,15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34,35',
-'36,287,,,,,38,,,,,,,,,,,,,,,,15,16,17,18,19,20,21,22,23,24,25,26,31',
-'32,33,34,35,36,312,364,,,,38,,,,,,,,10,11,12,13,14,15,16,17,18,19,20',
-'21,22,23,24,25,26,31,32,33,34,35,36,37,281,404,49,,38,,,,,,,,,10,11',
-'12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,37,,',
-',,38,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,31,32,33,34',
-'35,36,37,,,,,38,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,31',
-'32,33,34,35,36,37,,,,,38,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24',
-'25,26,31,32,33,34,35,36,37,,,,,38,10,11,12,13,14,15,16,17,18,19,20,21',
-'22,23,24,25,26,31,32,33,34,35,36,37,,,,,38,10,11,12,13,14,15,16,17,18',
-'19,20,21,22,23,24,25,26,31,32,33,34,35,36,37,,,,,38,10,11,12,13,14,15',
-'16,17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,37,,,,359,38,15,16',
-'17,18,19,20,21,22,23,24,25,26,31,32,33,34,35,36,,,,,,38,15,16,17,18',
-'19,20,21,22,23,24,25,26,31,32,33,34,35,36,,,,,,38,15,16,17,18,19,20',
-'21,22,23,24,25,26,31,32,33,34,35,36,,,,,,38,15,16,17,18,19,20,21,22',
-'23,24,25,26,31,32,33,34,35,36,,,,,,38,15,16,17,18,19,20,21,22,23,24',
-'25,26,31,32,33,34,35,36,,,,,,38' ]
- racc_action_table = arr = ::Array.new(4308, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'112,112,112,167,112,112,112,114,294,112,112,112,112,112,112,112,112',
-'445,445,445,45,445,445,445,210,402,445,445,445,445,445,445,445,445,66',
-'186,66,403,316,280,167,46,167,114,30,112,407,112,33,186,112,112,112',
-'112,112,112,112,112,311,184,289,210,445,210,445,316,382,445,445,445',
-'445,445,445,445,445,66,280,207,46,382,167,345,85,112,112,112,112,112',
-'294,30,207,48,87,33,84,311,85,45,427,345,445,445,445,445,445,444,444',
-'444,276,444,444,444,361,66,444,444,444,444,444,444,444,444,377,377,377',
-'30,377,377,377,33,48,377,377,377,377,377,377,377,377,184,289,69,340',
-'340,70,276,136,136,73,361,444,135,444,380,60,444,444,444,444,444,444',
-'444,444,59,135,135,380,377,48,377,260,58,377,377,377,377,377,377,377',
-'377,69,70,57,419,182,276,107,257,444,444,444,444,444,429,5,260,5,419',
-'182,107,260,257,55,429,411,377,377,377,377,377,376,376,376,216,376,376',
-'376,411,69,376,376,376,376,376,376,376,376,375,375,375,217,375,375,375',
-'330,5,375,375,375,375,375,375,375,375,133,331,213,330,330,138,138,138',
-'138,336,336,376,175,376,331,331,376,376,376,376,376,376,376,376,212',
-'175,335,335,375,5,375,304,42,375,375,375,375,375,375,375,375,49,49,49',
-'304,42,204,49,203,376,376,376,376,376,201,133,133,133,133,133,133,133',
-'133,133,133,200,375,375,375,375,375,437,437,437,188,437,437,437,334',
-'334,437,437,437,437,437,437,437,437,436,436,436,263,436,436,436,431',
-'301,436,436,436,436,436,436,436,436,431,301,317,264,211,163,338,338',
-'338,338,267,437,317,437,211,163,437,437,437,437,437,437,437,437,339',
-'339,339,339,436,177,436,443,417,436,436,436,436,436,436,436,436,443',
-'417,270,410,435,302,414,300,437,437,437,437,437,410,435,302,414,300',
-'74,74,74,333,333,274,74,436,436,436,436,436,433,433,433,39,433,433,433',
-'332,332,433,433,433,433,433,433,433,433,187,187,187,165,187,187,187',
-'137,137,187,187,187,187,187,187,187,187,139,139,337,337,144,144,162',
-'161,158,151,143,433,303,433,142,141,433,433,433,433,433,433,433,433',
-'140,324,325,341,187,342,187,343,344,187,187,187,187,187,187,187,187',
-'351,354,356,362,363,119,367,369,433,433,433,433,433,116,115,113,111',
-'110,109,101,100,389,390,98,89,187,187,187,187,187,65,65,65,65,65,65',
-'65,400,,65,65,65,65,65,65,65,65,,,65,65,65,65,65,65,65,65,65,65,65,65',
-'65,65,65,65,65,65,65,65,65,65,65,65,,,65,,65,,,65,65,65,65,65,65,65',
-'65,296,296,296,,296,296,296,,,296,296,296,296,296,296,296,296,,,,,,',
-',,65,65,65,65,65,,,,,,80,,,,,,,80,,,296,,296,,,296,296,296,296,296,296',
-'296,296,432,432,432,,432,432,432,,,432,432,432,432,432,432,432,432,',
-',,,,,80,,296,296,296,296,296,,,,,,284,,,,,,,284,,,432,,432,,,432,432',
-'432,432,432,432,432,432,430,430,430,80,430,430,430,,,430,430,430,430',
-'430,430,430,430,,,,,,,284,,432,432,432,432,432,,,,,,,,,,,,,,,,430,,430',
-',,430,430,430,430,430,430,430,430,426,426,426,284,426,426,426,,,426',
-'426,426,426,426,426,426,426,,,,,,,,,430,430,430,430,430,,,,,,,,,,,,',
-',,,426,,426,,,426,426,426,426,426,426,426,426,418,418,418,,418,418,418',
-',,418,418,418,418,418,418,418,418,,,,,,,,,426,426,426,426,426,,,,,,',
-',,,,,,,,,418,,418,,,418,418,418,418,418,418,418,418,454,454,454,,454',
-'454,454,,,454,454,454,454,454,454,454,454,,,,,,,,,418,418,418,418,418',
-',,,,,,,,,,,,,,,454,,454,,,454,454,454,454,454,454,454,454,415,415,415',
-',415,415,415,,,415,415,415,415,415,415,415,415,,,,,,,,,454,454,454,454',
-'454,,,,,,,,,,,,,,,,415,,415,,,415,415,415,415,415,415,415,415,450,450',
-'450,,450,450,450,,,450,450,450,450,450,450,450,450,,,,,,,,,415,415,415',
-'415,415,,,,,,,,,,,,,,,,450,,450,,,450,450,450,450,450,450,450,450,192',
-'192,192,,192,192,192,,,192,192,192,192,192,192,192,192,,,,,,,,,450,450',
-'450,450,450,,,,,,,,,,,,,,,,192,,192,,262,192,192,192,192,192,192,192',
-'192,191,191,191,,191,191,191,,,191,191,191,191,191,191,191,191,,,,,122',
-',,,192,192,192,192,192,262,,,,,262,262,262,262,262,262,262,262,,,191',
-',191,,,191,191,191,191,191,191,191,191,122,,,,,122,122,122,122,,262',
-'262,262,262,262,,,,,,,,,,,191,191,191,191,191,102,102,102,102,102,102',
-'102,,,102,102,102,102,102,102,102,102,,,102,102,102,102,102,102,102',
-'102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102',
-',,102,,102,,,102,102,102,102,102,102,102,102,447,447,447,,447,447,447',
-',,447,447,447,447,447,447,447,447,439,439,,,439,,,,102,102,102,102,102',
-',,,,,,,,,,,,,,,447,,447,,,447,447,447,447,447,447,447,447,439,,439,',
-',439,,439,439,439,439,439,439,439,439,,,,,,,,,,,447,447,447,447,447',
-'224,,,,224,,,,,,439,439,439,439,439,393,,,,393,,,224,224,224,224,224',
-'224,224,224,224,224,224,224,224,224,224,224,224,224,,,,224,,224,,,224',
-'224,224,224,224,224,224,224,,,393,,,,,393,393,393,393,393,393,393,393',
-'67,,,,67,,,,,,224,224,224,224,224,315,,,,315,,,,,,393,393,393,393,393',
-',,,,,,,,,,,,,67,,,,,67,67,67,67,67,67,67,67,,,315,,,,,315,315,315,315',
-'315,315,315,315,154,,,,154,,,,,,67,67,67,67,67,347,347,,,347,,,,,,315',
-'315,315,315,315,,,,,,,,,,,,154,,154,,,154,,154,154,154,154,154,154,154',
-'154,347,,347,,,347,,347,347,347,347,347,347,347,347,,,,,,,,,,,154,154',
-'154,154,154,120,,,,120,,,,,,347,347,347,347,347,258,,,,258,,,120,120',
-'120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,,,,120',
-',120,,,120,120,120,120,120,120,120,120,,,258,,,,,258,258,258,258,258',
-'258,258,258,384,,,,384,,,,,,120,120,120,120,120,,,,,,,,,,,258,258,258',
-'258,258,,,,,,,,,,,,384,,384,,,384,,384,384,384,384,384,384,384,384,',
-',,,,,,,220,,,,220,,,,,,,,,,,,,384,384,384,384,384,220,220,220,220,220',
-'220,220,220,220,220,220,220,220,220,220,220,220,220,,,,220,,220,,,220',
-'220,220,220,220,220,220,220,305,,305,,,,,,,,,,,306,,306,,,,,,,,,,220',
-'220,220,220,220,,,,,,,,,,,,305,,,,,305,305,305,305,305,305,305,305,306',
-',,,,306,306,306,306,306,306,306,306,,,,,,,,,,,,,305,305,305,305,305',
-'202,,202,,,,,,306,306,306,306,306,,,202,202,202,202,202,202,202,202',
-'202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,,,202',
-',202,,,202,202,202,202,202,202,202,202,117,,117,,,,,,,,,,,379,,379,',
-',,,,,,,,202,202,202,202,202,,,,,,,,,,,,117,,,,,117,117,117,117,117,117',
-'117,117,379,,,,244,379,379,379,379,379,379,379,379,,,,,245,,,,,,,,117',
-'117,117,117,117,,,,,,,,,379,379,379,379,379,244,,,,,244,244,244,244',
-'244,244,244,244,245,,,,246,245,245,245,245,245,245,245,245,,,,,247,',
-',,,,,,244,244,244,244,244,,,,,,,,,245,245,245,245,245,246,,,,,246,246',
-'246,246,246,246,246,246,247,,,,,247,247,247,247,247,247,247,247,,,71',
-',,,,,,,,,246,246,246,246,246,71,428,428,,,,,,247,247,247,247,247,,,',
-',,71,71,71,,,71,71,,,,,71,71,71,71,71,71,71,71,,,,428,,,,,428,428,428',
-'428,428,428,428,428,416,416,,,,,,,,71,71,71,71,71,413,413,,,,,,,,,,428',
-'428,428,428,428,,,,,,,,,,416,,,,,416,416,416,416,416,416,416,416,,413',
-',,,,413,413,413,413,413,413,413,413,412,412,,,,,,,,,,416,416,416,416',
-'416,391,,,,,,,,,413,413,413,413,413,,,,,,,,,,412,,,,,412,412,412,412',
-'412,412,412,412,,,,391,,,,99,391,391,391,391,391,391,391,391,,,,,,,',
-',,412,412,412,412,412,,,,,,,,,,,,391,391,391,391,391,99,,,,,99,99,99',
-'99,99,99,99,99,,,,,,,,,,,,,388,,,,,,,,,,,,,99,99,99,99,99,388,388,388',
-'388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,,,,388,',
-'388,,,388,388,388,388,388,388,388,388,383,383,,,,,,,,,,,,381,381,,,',
-',,,,,,,388,388,388,388,388,,,,,,,,,,383,,,,,383,383,383,383,383,383',
-'383,383,381,,,,378,381,381,381,381,381,381,381,381,,,,,,,,,,,,,383,383',
-'383,383,383,,,,,,,,,381,381,381,381,381,378,,,,,378,378,378,378,378',
-'378,378,378,157,,,,,,,,,,,,,285,,157,,,,,,,,,,378,378,378,378,378,,',
-',157,157,157,,,157,157,,,,,157,157,157,157,157,157,157,157,285,,,,,285',
-'285,285,285,285,285,285,285,160,,,,,,,,,,,,157,157,157,157,157,281,',
-',,,,,,285,285,285,285,285,,,,160,160,160,,,,160,,,,,160,160,160,160',
-'160,160,160,160,,,,281,281,,,,,281,281,281,281,281,281,281,281,269,',
-',,,,,,160,160,160,160,160,178,,,,,,,,,,,,281,281,281,281,281,,,,269',
-'269,269,,,,269,,,,,269,269,269,269,269,269,269,269,178,,,,266,178,178',
-'178,178,178,178,178,178,,,,,185,,,,,,,,269,269,269,269,269,,,,,,,,,178',
-'178,178,178,178,266,,,,,266,266,266,266,266,266,266,266,185,,,,243,185',
-'185,185,185,185,185,185,185,,,,,196,,,,,,,,266,266,266,266,266,,,,,',
-',,,185,185,185,185,185,243,,,,,243,243,243,243,243,243,243,243,196,',
-',,197,196,196,196,196,196,196,196,196,,,,,198,,,,,,,,243,243,243,243',
-'243,,,,,,,,,196,196,196,196,196,197,,,,,197,197,197,197,197,197,197',
-'197,198,,,,199,198,198,198,198,198,198,198,198,,,,,256,,,,,,,,197,197',
-'197,197,197,,,,,,,,,198,198,198,198,198,199,,,,,199,199,199,199,199',
-'199,199,199,256,,,,255,256,256,256,256,256,256,256,256,,,,,254,,,,,',
-',,199,199,199,199,199,,,,,,,,,256,256,256,256,256,255,,,,,255,255,255',
-'255,255,255,255,255,254,,,,253,254,254,254,254,254,254,254,254,,,,,252',
-',,,,,,,255,255,255,255,255,,,,,,,,,254,254,254,254,254,253,,,,,253,253',
-'253,253,253,253,253,253,252,,,,251,252,252,252,252,252,252,252,252,',
-',,,250,,,,,,,,253,253,253,253,253,,,,,,,,,252,252,252,252,252,251,,',
-',,251,251,251,251,251,251,251,251,250,,,,214,250,250,250,250,250,250',
-'250,250,,,,,,,,,,,,,251,251,251,251,251,,,,,,,,,250,250,250,250,250',
-'214,,,,,214,214,214,214,214,214,214,214,,,,,,,,,,,,,215,215,,,,,,,,',
-',,,214,214,214,214,214,215,215,215,215,215,215,215,215,215,215,215,215',
-'215,215,215,215,215,215,,,,215,,215,,249,215,215,215,215,215,215,215',
-'215,,,,,248,,,,,,,,,,,,,,,,,,,,,215,215,215,215,215,249,,,,,249,249',
-'249,249,249,249,249,249,248,,,,226,248,248,248,248,248,248,248,248,',
-',,,238,,,,,,,,249,249,249,249,249,,,,,,,,,248,248,248,248,248,226,,',
-',,226,226,226,226,226,226,226,226,238,,,,239,238,238,238,238,238,238',
-'238,238,,,,,240,,,,,,,,226,226,226,226,226,,,,,,,,,238,238,238,238,238',
-'239,,,,,239,239,239,239,239,239,239,239,240,,,,241,240,240,240,240,240',
-'240,240,240,,,,,242,,,,,,,,239,239,239,239,239,,,,,,,,,240,240,240,240',
-'240,241,,,,,241,241,241,241,241,241,241,241,242,,,,123,242,242,242,242',
-'242,242,242,242,,,,,124,,,,,,,,241,241,241,241,241,,,,,,,,,242,242,242',
-'242,242,123,,,,,123,123,123,123,123,123,123,123,124,,,,125,124,124,124',
-'124,124,124,124,124,,,,,126,,,,,,,,123,123,123,123,123,,,,,,,,,124,124',
-'124,124,124,125,,,,,125,125,125,125,125,125,125,125,126,,,,,126,126',
-'126,126,126,126,126,126,365,,,,,,,,,,,,125,125,125,125,125,,,,,,,,,126',
-'126,126,126,126,,,,,,,,,365,365,,,,,365,365,365,365,365,365,365,365',
-',,,,,,,,,,,,,,,,,277,277,,,,,,,365,365,365,365,365,277,277,277,277,277',
-'277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277',
-'277,277,277,72,277,,277,,,,,,,,,72,72,72,72,72,72,72,72,72,72,72,72',
-'72,72,72,72,72,72,72,72,72,72,72,72,,,,277,72,,,,,,,,,,,,,,,1,,,,,,',
-',,,,,,,,,,,,,,72,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,41',
-',,,1,,,,,,,,,,,,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41',
-'41,41,41,41,41,41,41,62,,,,41,,,,,,,,,,,,,62,62,62,62,62,62,62,62,62',
-'62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,78,,,,62,,,,,,,,,,,,,,',
-',,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,172,,,,,78,',
-',,,,,,,,,,,,,,172,172,172,172,172,172,172,172,172,172,172,172,172,172',
-'172,172,172,172,181,,,,,172,,,,,,,,,,,,,,,,181,181,181,181,181,181,181',
-'181,181,181,181,181,181,181,181,181,181,181,312,312,,,,181,,,,,,,,312',
-'312,312,312,312,312,312,312,312,312,312,312,312,312,312,312,312,312',
-'312,312,312,312,312,312,312,366,312,,312,,,,,,,,,366,366,366,366,366',
-'366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366',
-'366,366,,,,,366,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,,,',
-'0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,,,,,6,7,7,7,7,7,7',
-'7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,,,,,7,8,8,8,8,8,8,8,8,8,8,8,8,8',
-'8,8,8,8,8,8,8,8,8,8,8,,,,,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9',
-'9,9,9,9,,,,,9,275,275,275,275,275,275,275,275,275,275,275,275,275,275',
-'275,275,275,275,275,275,275,275,275,275,,,,275,275,82,82,82,82,82,82',
-'82,82,82,82,82,82,82,82,82,82,82,82,,,,,,82,77,77,77,77,77,77,77,77',
-'77,77,77,77,77,77,77,77,77,77,,,,,,77,83,83,83,83,83,83,83,83,83,83',
-'83,83,83,83,83,83,83,83,,,,,,83,56,56,56,56,56,56,56,56,56,56,56,56',
-'56,56,56,56,56,56,,,,,,56,81,81,81,81,81,81,81,81,81,81,81,81,81,81',
-'81,81,81,81,,,,,,81' ]
- racc_action_check = arr = ::Array.new(4308, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_action_pointer = [
- 3992, 3690, nil, nil, nil, 187, 4021, 4050, 4079, 4108,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 39, nil, nil, 43, nil, nil, nil, nil, nil, 423,
- nil, 3731, 269, nil, nil, 11, 32, nil, 82, 243,
- nil, nil, nil, nil, nil, 197, 4233, 177, 166, 77,
- 149, nil, 3772, nil, nil, 522, 27, 1405, nil, 132,
- 135, 2068, 3625, 138, 366, nil, nil, 4185, 3812, nil,
- 616, 4257, 4161, 4209, 8, 76, nil, 71, nil, 433,
- nil, nil, nil, nil, nil, nil, nil, nil, 516, 2261,
- 513, 512, 1190, nil, nil, nil, nil, 179, nil, 504,
- 503, 502, -3, 501, -43, 502, 501, 1889, nil, 410,
- 1562, nil, 1117, 3398, 3411, 3454, 3467, nil, nil, nil,
- nil, nil, nil, 223, nil, 103, 89, 381, 184, 385,
- 422, 398, 396, 391, 384, nil, nil, nil, nil, nil,
- nil, 442, nil, nil, 1476, nil, nil, 2485, 415, nil,
- 2550, 414, 450, 344, nil, 420, nil, -6, nil, nil,
- nil, nil, 3851, nil, nil, 249, nil, 376, 2632, nil,
- nil, 3890, 178, nil, 53, 2688, 29, 434, 316, nil,
- nil, 1102, 1044, nil, nil, nil, 2744, 2787, 2800, 2843,
- 307, 285, 1835, 285, 283, nil, nil, 70, nil, nil,
- 15, 343, 258, 236, 3067, 3131, 127, 144, nil, nil,
- 1697, nil, nil, nil, 1334, nil, 3230, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 3243, 3286,
- 3299, 3342, 3355, 2731, 1945, 1958, 2001, 2014, 3187, 3174,
- 3024, 3011, 2968, 2955, 2912, 2899, 2856, 181, 1577, nil,
- 149, nil, 1087, 249, 305, nil, 2675, 312, nil, 2619,
- 345, nil, nil, nil, 327, 4137, 99, 3588, nil, nil,
- 30, 2567, nil, nil, 674, 2498, nil, nil, nil, 54,
- nil, nil, nil, nil, 2, nil, 580, nil, nil, nil,
- 387, 330, 385, 457, 268, 1751, 1764, nil, nil, nil,
- nil, 49, 3926, nil, nil, 1420, 18, 341, nil, nil,
- nil, nil, nil, nil, 469, 470, nil, nil, nil, nil,
- 186, 197, 370, 354, 259, 207, 190, 393, 290, 308,
- 73, 425, 412, 413, 413, 79, nil, 1491, nil, nil,
- nil, 448, nil, nil, 449, nil, 450, nil, nil, nil,
- nil, 103, 488, 489, nil, 3519, 3963, 454, nil, 455,
- nil, nil, nil, nil, nil, 224, 207, 119, 2433, 1902,
- 146, 2390, 59, 2377, 1633, nil, nil, nil, 2325, 511,
- 512, 2218, nil, 1349, nil, nil, nil, nil, nil, nil,
- 485, nil, -22, 27, nil, nil, nil, 35, nil, nil,
- 383, 197, 2202, 2150, 386, 928, 2136, 371, 812, 177,
- nil, nil, nil, nil, nil, nil, 754, 91, 2084, 183,
- 696, 329, 638, 417, nil, 384, 329, 312, nil, 1263,
- nil, nil, nil, 370, 102, 14, nil, 1248, nil, nil,
- 986, nil, nil, nil, 870, nil, nil, nil, nil, nil ]
-
-racc_action_default = [
- -265, -265, -1, -3, -4, -265, -53, -55, -57, -59,
- -64, -65, -66, -67, -68, -69, -70, -71, -72, -73,
- -74, -75, -76, -77, -78, -79, -80, -81, -82, -83,
- -265, -89, -90, -265, -115, -116, -117, -118, -166, -265,
- -2, -62, -265, -51, -60, -265, -120, -121, -265, -136,
- -258, -52, -54, -56, -58, -86, -265, -88, -107, -265,
- -110, 460, -265, -6, -7, -265, -265, -265, -50, -265,
- -119, -265, -265, -265, -135, -138, -139, -265, -265, -91,
- -265, -95, -97, -265, -265, -265, -111, -113, -262, -265,
- -5, -8, -9, -10, -11, -12, -13, -14, -179, -265,
- -265, -83, -265, -20, -21, -23, -24, -265, -26, -265,
- -265, -265, -265, -265, -265, -265, -265, -265, -180, -181,
- -265, -184, -198, -265, -265, -265, -265, -204, -205, -206,
- -207, -208, -209, -210, -212, -216, -219, -222, -227, -230,
- -232, -234, -236, -238, -240, -242, -255, -259, -260, -261,
- -264, -62, -63, -167, -265, -179, -61, -265, -265, -126,
- -265, -205, -265, -265, -134, -141, -143, -147, -148, -122,
- -137, -140, -265, -85, -92, -265, -98, -100, -265, -94,
- -96, -265, -265, -104, -265, -265, -265, -265, -265, -210,
- -257, -265, -265, -19, -22, -25, -265, -265, -265, -265,
- -265, -265, -265, -265, -265, -45, -46, -265, -48, -263,
- -151, -265, -265, -265, -265, -265, -265, -265, -190, -191,
- -265, -199, -200, -201, -265, -202, -265, -244, -245, -246,
- -247, -248, -249, -250, -251, -252, -253, -254, -265, -265,
- -265, -265, -265, -265, -265, -265, -265, -265, -265, -265,
- -265, -265, -265, -265, -265, -265, -265, -265, -265, -171,
- -265, -175, -265, -265, -265, -124, -265, -205, -125, -265,
- -265, -131, -132, -133, -265, -265, -152, -265, -145, -146,
- -154, -265, -84, -93, -265, -265, -102, -87, -103, -265,
- -106, -112, -114, -108, -265, -15, -265, -17, -18, -256,
- -265, -265, -265, -265, -265, -265, -265, -44, -49, -47,
- -150, -152, -265, -182, -183, -265, -265, -265, -187, -194,
- -196, -197, -188, -189, -265, -265, -243, -213, -214, -215,
- -217, -218, -220, -221, -223, -224, -225, -226, -228, -229,
- -231, -233, -235, -237, -239, -265, -168, -265, -170, -174,
- -176, -265, -178, -123, -265, -130, -265, -128, -149, -142,
- -144, -153, -265, -265, -165, -265, -265, -265, -159, -205,
- -99, -101, -105, -109, -16, -265, -265, -265, -265, -265,
- -265, -265, -265, -265, -265, -211, -185, -186, -265, -265,
- -203, -265, -169, -265, -173, -177, -129, -127, -155, -164,
- -265, -157, -205, -265, -163, -158, -161, -27, -29, -30,
- -265, -265, -265, -265, -265, -265, -265, -265, -265, -265,
- -195, -241, -172, -156, -160, -162, -265, -265, -265, -265,
- -265, -265, -265, -265, -39, -265, -265, -265, -43, -265,
- -192, -28, -31, -265, -265, -265, -35, -265, -37, -38,
- -265, -41, -42, -193, -265, -33, -34, -36, -40, -32 ]
-
-racc_goto_table = [
- 47, 162, 57, 152, 70, 60, 153, 5, 5, 176,
- 158, 75, 257, 51, 52, 53, 54, 76, 319, 41,
- 393, 62, 104, 279, 82, 55, 291, 340, 58, 330,
- 331, 81, 179, 180, 341, 207, 170, 101, 211, 76,
- 47, 64, 171, 47, 190, 82, 82, 188, 63, 82,
- 82, 82, 81, 81, 223, 342, 81, 81, 81, 194,
- 98, 47, 91, 361, 47, 105, 310, 168, 74, 90,
- 343, 210, 344, 213, 101, 47, 85, 338, 339, 167,
- 151, 163, 174, 151, 200, 226, 204, 78, 82, 360,
- 157, 332, 333, 153, 177, 81, 264, 98, 361, 270,
- 175, 182, 105, 2, 40, 156, 186, 98, 172, 203,
- 350, 317, 393, 1, 181, 300, 301, 302, 102, nil,
- 304, nil, nil, 190, nil, 171, 286, 212, 76, 276,
- 190, 291, 316, 292, nil, 299, 291, nil, 211, nil,
- 82, nil, 211, 334, 335, 336, 337, 81, nil, 82,
- nil, nil, nil, nil, 320, nil, 81, nil, nil, 200,
- nil, nil, 47, 200, 200, 326, 210, 327, 328, 329,
- 201, 210, 311, 324, 345, 210, 174, 325, nil, 269,
- nil, 278, 98, 82, nil, 174, 98, 98, 82, nil,
- 81, 420, 82, nil, 348, 81, nil, 153, nil, 81,
- nil, nil, 306, nil, nil, 354, nil, 190, 356, nil,
- 351, 322, 323, 370, nil, nil, nil, nil, nil, nil,
- 367, nil, nil, 380, 382, nil, nil, 212, nil, nil,
- 190, 212, nil, 371, nil, 70, nil, 171, nil, 276,
- nil, nil, 419, nil, 385, 295, nil, nil, nil, 297,
- 298, nil, nil, nil, nil, nil, nil, nil, 352, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 200, 358,
- nil, 47, 47, nil, 311, nil, nil, nil, nil, 47,
- nil, nil, 167, 394, 167, nil, 153, nil, nil, nil,
- nil, 98, nil, nil, nil, 403, 410, 411, 177, 414,
- nil, 417, nil, nil, 400, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 167,
- nil, nil, nil, 153, nil, nil, nil, 320, nil, 422,
- 429, 431, 153, nil, 435, nil, 421, nil, nil, 210,
- nil, nil, nil, nil, nil, nil, 443, 200, 200, 200,
- nil, nil, nil, nil, 374, nil, 82, nil, nil, nil,
- nil, nil, nil, 81, nil, nil, nil, nil, nil, nil,
- 98, 98, 98, 167, nil, 394, nil, nil, 153, nil,
- nil, nil, nil, nil, nil, nil, nil, 200, nil, nil,
- 200, nil, nil, nil, nil, nil, nil, nil, 200, nil,
- nil, nil, 200, nil, 200, 200, nil, nil, 200, 200,
- 98, nil, nil, 98, nil, nil, 200, 200, nil, 200,
- nil, 98, 200, nil, nil, 98, 200, 98, 98, nil,
- 189, 98, 98, 407, 408, 409, nil, nil, nil, 98,
- 98, nil, 98, nil, nil, 98, nil, nil, nil, 98,
- nil, nil, nil, nil, 221, 222, 189, 225, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 434, nil, nil, 438, nil, nil, nil,
- nil, nil, nil, nil, 441, nil, nil, nil, 446, nil,
- 448, 449, nil, nil, 451, 452, nil, nil, nil, nil,
- nil, nil, 455, 456, nil, 457, nil, nil, 458, 189,
- nil, nil, 459, nil, nil, nil, 189, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 189,
- 189, 189, 189, 189, 189, 189, 189, 189, 189, 189,
- 189, 189, 189, 189, 189, 189, 189, nil, nil, nil,
- nil, nil, nil, 189, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 189, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 189, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 189 ]
-
-racc_goto_check = [
- 15, 43, 17, 27, 40, 17, 42, 5, 5, 35,
- 42, 39, 50, 5, 5, 5, 5, 24, 59, 6,
- 51, 7, 19, 47, 24, 15, 37, 67, 15, 63,
- 63, 23, 33, 33, 68, 20, 39, 17, 20, 24,
- 15, 4, 24, 15, 73, 24, 24, 16, 8, 24,
- 24, 24, 23, 23, 62, 69, 23, 23, 23, 19,
- 15, 15, 4, 49, 15, 4, 47, 15, 41, 8,
- 70, 33, 71, 48, 17, 15, 36, 66, 66, 5,
- 6, 44, 32, 6, 17, 74, 17, 31, 24, 46,
- 41, 64, 64, 42, 6, 23, 42, 15, 49, 42,
- 34, 36, 4, 2, 2, 26, 36, 15, 31, 15,
- 53, 58, 51, 1, 31, 20, 20, 20, 18, nil,
- 20, nil, nil, 73, nil, 24, 16, 8, 24, 39,
- 73, 37, 20, 16, nil, 42, 37, nil, 20, nil,
- 24, nil, 20, 65, 65, 65, 65, 23, nil, 24,
- nil, nil, nil, nil, 42, nil, 23, nil, nil, 17,
- nil, nil, 15, 17, 17, 42, 33, 62, 62, 62,
- 9, 33, 39, 48, 20, 33, 32, 48, nil, 41,
- nil, 6, 15, 24, nil, 32, 15, 15, 24, nil,
- 23, 59, 24, nil, 27, 23, nil, 42, nil, 23,
- nil, nil, 4, nil, nil, 42, nil, 73, 42, nil,
- 16, 15, 15, 35, nil, nil, nil, nil, nil, nil,
- 42, nil, nil, 20, 20, nil, nil, 8, nil, nil,
- 73, 8, nil, 16, nil, 40, nil, 24, nil, 39,
- nil, nil, 50, nil, 62, 9, nil, nil, nil, 9,
- 9, nil, nil, nil, nil, nil, nil, nil, 15, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 17, 15,
- nil, 15, 15, nil, 39, nil, nil, nil, nil, 15,
- nil, nil, 5, 27, 5, nil, 42, nil, nil, nil,
- nil, 15, nil, nil, nil, 43, 20, 20, 6, 20,
- nil, 20, nil, nil, 42, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 5,
- nil, nil, nil, 42, nil, nil, nil, 42, nil, 27,
- 20, 20, 42, nil, 20, nil, 73, nil, nil, 33,
- nil, nil, nil, nil, nil, nil, 20, 17, 17, 17,
- nil, nil, nil, nil, 9, nil, 24, nil, nil, nil,
- nil, nil, nil, 23, nil, nil, nil, nil, nil, nil,
- 15, 15, 15, 5, nil, 27, nil, nil, 42, nil,
- nil, nil, nil, nil, nil, nil, nil, 17, nil, nil,
- 17, nil, nil, nil, nil, nil, nil, nil, 17, nil,
- nil, nil, 17, nil, 17, 17, nil, nil, 17, 17,
- 15, nil, nil, 15, nil, nil, 17, 17, nil, 17,
- nil, 15, 17, nil, nil, 15, 17, 15, 15, nil,
- 60, 15, 15, 9, 9, 9, nil, nil, nil, 15,
- 15, nil, 15, nil, nil, 15, nil, nil, nil, 15,
- nil, nil, nil, nil, 60, 60, 60, 60, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 9, nil, nil, 9, nil, nil, nil,
- nil, nil, nil, nil, 9, nil, nil, nil, 9, nil,
- 9, 9, nil, nil, 9, 9, nil, nil, nil, nil,
- nil, nil, 9, 9, nil, 9, nil, nil, 9, 60,
- nil, nil, 9, nil, nil, nil, 60, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 60,
- 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
- 60, 60, 60, 60, 60, 60, 60, nil, nil, nil,
- nil, nil, nil, 60, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 60, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 60, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 60 ]
-
-racc_goto_pointer = [
- nil, 113, 103, nil, 0, 7, 14, -20, 7, 58,
- nil, nil, nil, nil, nil, -5, -52, -28, 53, -43,
- -82, nil, nil, -25, -32, nil, 36, -64, nil, nil,
- nil, 31, 4, -49, 20, -71, 17, -158, nil, -38,
- -41, 19, -61, -71, 9, nil, -186, -144, -47, -213,
- -142, -327, nil, -150, nil, nil, nil, nil, -104, -197,
- 331, nil, -71, -212, -152, -102, -172, -224, -218, -198,
- -184, -183, nil, -55, -48 ]
-
-racc_goto_default = [
- nil, nil, nil, 3, 4, 66, 73, nil, 93, 106,
- 92, 94, 95, 96, 97, 155, nil, 29, nil, nil,
- 107, 42, 6, 7, 8, 9, 44, 259, 27, 28,
- 30, nil, 79, 80, nil, nil, nil, 86, 87, 45,
- 46, nil, 146, 363, nil, 165, 166, 362, 321, 280,
- nil, 258, 260, 261, 121, 118, 119, 122, nil, nil,
- 133, 125, 134, 135, 136, 137, 138, 139, 140, 141,
- 142, 143, 144, 145, nil ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 92, :_reduce_1,
- 2, 92, :_reduce_2,
- 1, 93, :_reduce_3,
- 1, 93, :_reduce_4,
- 4, 94, :_reduce_5,
- 3, 94, :_reduce_6,
- 1, 98, :_reduce_7,
- 2, 98, :_reduce_8,
- 1, 100, :_reduce_9,
- 1, 100, :_reduce_10,
- 1, 100, :_reduce_11,
- 1, 100, :_reduce_12,
- 1, 100, :_reduce_13,
- 1, 100, :_reduce_14,
- 3, 101, :_reduce_15,
- 4, 101, :_reduce_16,
- 3, 101, :_reduce_17,
- 3, 101, :_reduce_18,
- 3, 99, :_reduce_19,
- 2, 99, :_reduce_20,
- 1, 109, :_reduce_21,
- 2, 109, :_reduce_22,
- 1, 110, :_reduce_23,
- 1, 110, :_reduce_24,
- 2, 102, :_reduce_25,
- 1, 102, :_reduce_26,
- 5, 103, :_reduce_27,
- 7, 103, :_reduce_28,
- 5, 103, :_reduce_29,
- 5, 104, :_reduce_30,
- 7, 104, :_reduce_31,
- 9, 104, :_reduce_32,
- 8, 104, :_reduce_33,
- 8, 104, :_reduce_34,
- 7, 104, :_reduce_35,
- 8, 104, :_reduce_36,
- 7, 104, :_reduce_37,
- 7, 104, :_reduce_38,
- 6, 104, :_reduce_39,
- 8, 104, :_reduce_40,
- 7, 104, :_reduce_41,
- 7, 104, :_reduce_42,
- 6, 104, :_reduce_43,
- 3, 105, :_reduce_44,
- 2, 105, :_reduce_45,
- 2, 105, :_reduce_46,
- 3, 105, :_reduce_47,
- 2, 105, :_reduce_48,
- 3, 105, :_reduce_49,
- 3, 95, :_reduce_50,
- 2, 95, :_reduce_51,
- 2, 96, :_reduce_52,
- 1, 96, :_reduce_53,
- 2, 96, :_reduce_54,
- 1, 96, :_reduce_55,
- 2, 96, :_reduce_56,
- 1, 96, :_reduce_57,
- 2, 96, :_reduce_58,
- 1, 96, :_reduce_59,
- 1, 112, :_reduce_60,
- 3, 112, :_reduce_61,
- 1, 117, :_reduce_62,
- 3, 117, :_reduce_63,
- 1, 113, :_reduce_64,
- 1, 113, :_reduce_65,
- 1, 113, :_reduce_66,
- 1, 113, :_reduce_67,
- 1, 113, :_reduce_68,
- 1, 114, :_reduce_69,
- 1, 114, :_reduce_70,
- 1, 114, :_reduce_71,
- 1, 114, :_reduce_72,
- 1, 114, :_reduce_73,
- 1, 114, :_reduce_74,
- 1, 114, :_reduce_75,
- 1, 114, :_reduce_76,
- 1, 114, :_reduce_77,
- 1, 114, :_reduce_78,
- 1, 114, :_reduce_79,
- 1, 114, :_reduce_80,
- 1, 114, :_reduce_81,
- 1, 114, :_reduce_82,
- 1, 114, :_reduce_83,
- 5, 119, :_reduce_84,
- 4, 119, :_reduce_85,
- 2, 119, :_reduce_86,
- 5, 119, :_reduce_87,
- 2, 119, :_reduce_88,
- 1, 121, :_reduce_89,
- 1, 121, :_reduce_90,
- 1, 122, :_reduce_91,
- 2, 122, :_reduce_92,
- 3, 123, :_reduce_93,
- 2, 124, :_reduce_94,
- 1, 124, :_reduce_95,
- 2, 124, :_reduce_96,
- 1, 124, :_reduce_97,
- 1, 125, :_reduce_98,
- 3, 125, :_reduce_99,
- 1, 126, :_reduce_100,
- 3, 126, :_reduce_101,
- 2, 126, :_reduce_102,
- 5, 120, :_reduce_103,
- 4, 120, :_reduce_104,
- 6, 120, :_reduce_105,
- 5, 120, :_reduce_106,
- 2, 120, :_reduce_107,
- 5, 120, :_reduce_108,
- 6, 120, :_reduce_109,
- 2, 120, :_reduce_110,
- 1, 127, :_reduce_111,
- 3, 127, :_reduce_112,
- 1, 128, :_reduce_113,
- 3, 128, :_reduce_114,
- 1, 115, :_reduce_115,
- 1, 115, :_reduce_116,
- 1, 115, :_reduce_117,
- 1, 116, :_reduce_118,
- 2, 97, :_reduce_119,
- 1, 97, :_reduce_120,
- 1, 131, :_reduce_121,
- 3, 131, :_reduce_122,
- 5, 131, :_reduce_123,
- 4, 131, :_reduce_124,
- 4, 131, :_reduce_125,
- 3, 131, :_reduce_126,
- 6, 131, :_reduce_127,
- 5, 131, :_reduce_128,
- 6, 131, :_reduce_129,
- 5, 131, :_reduce_130,
- 4, 131, :_reduce_131,
- 4, 131, :_reduce_132,
- 4, 131, :_reduce_133,
- 3, 131, :_reduce_134,
- 2, 130, :_reduce_135,
- 1, 130, :_reduce_136,
- 3, 130, :_reduce_137,
- 2, 130, :_reduce_138,
- 1, 132, :_reduce_139,
- 2, 132, :_reduce_140,
- 1, 134, :_reduce_141,
- 3, 134, :_reduce_142,
- 1, 136, :_reduce_143,
- 3, 136, :_reduce_144,
- 2, 137, :_reduce_145,
- 2, 137, :_reduce_146,
- 1, 137, :_reduce_147,
- 1, 135, :_reduce_148,
- 3, 135, :_reduce_149,
- 2, 139, :_reduce_150,
- 1, 139, :_reduce_151,
- 1, 138, :_reduce_152,
- 2, 138, :_reduce_153,
- 1, 138, :_reduce_154,
- 3, 140, :_reduce_155,
- 4, 140, :_reduce_156,
- 3, 140, :_reduce_157,
- 3, 140, :_reduce_158,
- 2, 140, :_reduce_159,
- 4, 140, :_reduce_160,
- 3, 140, :_reduce_161,
- 4, 140, :_reduce_162,
- 3, 140, :_reduce_163,
- 3, 140, :_reduce_164,
- 2, 140, :_reduce_165,
- 1, 108, :_reduce_166,
- 1, 118, :_reduce_167,
- 3, 118, :_reduce_168,
- 4, 118, :_reduce_169,
- 2, 141, :_reduce_170,
- 1, 141, :_reduce_171,
- 4, 141, :_reduce_172,
- 3, 141, :_reduce_173,
- 2, 142, :_reduce_174,
- 1, 143, :_reduce_175,
- 2, 143, :_reduce_176,
- 3, 144, :_reduce_177,
- 2, 144, :_reduce_178,
- 1, 145, :_reduce_179,
- 1, 145, :_reduce_180,
- 1, 145, :_reduce_181,
- 3, 145, :_reduce_182,
- 3, 145, :_reduce_183,
- 1, 148, :_reduce_184,
- 4, 148, :_reduce_185,
- 4, 148, :_reduce_186,
- 3, 148, :_reduce_187,
- 3, 148, :_reduce_188,
- 3, 148, :_reduce_189,
- 2, 148, :_reduce_190,
- 2, 148, :_reduce_191,
- 6, 148, :_reduce_192,
- 7, 148, :_reduce_193,
- 1, 149, :_reduce_194,
- 3, 149, :_reduce_195,
- 1, 150, :_reduce_196,
- 1, 150, :_reduce_197,
- 1, 151, :_reduce_198,
- 2, 151, :_reduce_199,
- 2, 151, :_reduce_200,
- 2, 151, :_reduce_201,
- 2, 151, :_reduce_202,
- 4, 151, :_reduce_203,
- 1, 152, :_reduce_204,
- 1, 152, :_reduce_205,
- 1, 152, :_reduce_206,
- 1, 152, :_reduce_207,
- 1, 152, :_reduce_208,
- 1, 152, :_reduce_209,
- 1, 153, :_reduce_210,
- 4, 153, :_reduce_211,
- 1, 154, :_reduce_212,
- 3, 154, :_reduce_213,
- 3, 154, :_reduce_214,
- 3, 154, :_reduce_215,
- 1, 155, :_reduce_216,
- 3, 155, :_reduce_217,
- 3, 155, :_reduce_218,
- 1, 156, :_reduce_219,
- 3, 156, :_reduce_220,
- 3, 156, :_reduce_221,
- 1, 157, :_reduce_222,
- 3, 157, :_reduce_223,
- 3, 157, :_reduce_224,
- 3, 157, :_reduce_225,
- 3, 157, :_reduce_226,
- 1, 158, :_reduce_227,
- 3, 158, :_reduce_228,
- 3, 158, :_reduce_229,
- 1, 159, :_reduce_230,
- 3, 159, :_reduce_231,
- 1, 160, :_reduce_232,
- 3, 160, :_reduce_233,
- 1, 161, :_reduce_234,
- 3, 161, :_reduce_235,
- 1, 162, :_reduce_236,
- 3, 162, :_reduce_237,
- 1, 163, :_reduce_238,
- 3, 163, :_reduce_239,
- 1, 164, :_reduce_240,
- 5, 164, :_reduce_241,
- 1, 133, :_reduce_242,
- 3, 133, :_reduce_243,
- 1, 165, :_reduce_244,
- 1, 165, :_reduce_245,
- 1, 165, :_reduce_246,
- 1, 165, :_reduce_247,
- 1, 165, :_reduce_248,
- 1, 165, :_reduce_249,
- 1, 165, :_reduce_250,
- 1, 165, :_reduce_251,
- 1, 165, :_reduce_252,
- 1, 165, :_reduce_253,
- 1, 165, :_reduce_254,
- 1, 111, :_reduce_255,
- 3, 111, :_reduce_256,
- 1, 107, :_reduce_257,
- 1, 106, :_reduce_258,
- 1, 146, :_reduce_259,
- 1, 146, :_reduce_260,
- 1, 146, :_reduce_261,
- 1, 129, :_reduce_262,
- 2, 147, :_reduce_263,
- 1, 147, :_reduce_264 ]
-
-racc_reduce_n = 265
-
-racc_shift_n = 460
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :COLON => 2,
- :CASE => 3,
- :DEFAULT => 4,
- :LBRACE => 5,
- :RBRACE => 6,
- :SEMICOLON => 7,
- :IF => 8,
- :LPAREN => 9,
- :RPAREN => 10,
- :ELSE => 11,
- :SWITCH => 12,
- :WHILE => 13,
- :DO => 14,
- :FOR => 15,
- :GOTO => 16,
- :CONTINUE => 17,
- :BREAK => 18,
- :RETURN => 19,
- :COMMA => 20,
- :EQ => 21,
- :TYPEDEF => 22,
- :EXTERN => 23,
- :STATIC => 24,
- :AUTO => 25,
- :REGISTER => 26,
- :VOID => 27,
- :CHAR => 28,
- :SHORT => 29,
- :INT => 30,
- :LONG => 31,
- :FLOAT => 32,
- :DOUBLE => 33,
- :SIGNED => 34,
- :UNSIGNED => 35,
- :BOOL => 36,
- :COMPLEX => 37,
- :IMAGINARY => 38,
- :STRUCT => 39,
- :UNION => 40,
- :ENUM => 41,
- :CONST => 42,
- :RESTRICT => 43,
- :VOLATILE => 44,
- :INLINE => 45,
- :LBRACKET => 46,
- :RBRACKET => 47,
- :MUL => 48,
- :ELLIPSIS => 49,
- :TYPENAME => 50,
- :DOT => 51,
- :ARROW => 52,
- :INC => 53,
- :DEC => 54,
- :SIZEOF => 55,
- :AND => 56,
- :ADD => 57,
- :SUB => 58,
- :NOT => 59,
- :BANG => 60,
- :DIV => 61,
- :MOD => 62,
- :LSHIFT => 63,
- :RSHIFT => 64,
- :LT => 65,
- :GT => 66,
- :LEQ => 67,
- :GEQ => 68,
- :EQEQ => 69,
- :NEQ => 70,
- :XOR => 71,
- :OR => 72,
- :ANDAND => 73,
- :OROR => 74,
- :QUESTION => 75,
- :MULEQ => 76,
- :DIVEQ => 77,
- :MODEQ => 78,
- :ADDEQ => 79,
- :SUBEQ => 80,
- :LSHIFTEQ => 81,
- :RSHIFTEQ => 82,
- :ANDEQ => 83,
- :XOREQ => 84,
- :OREQ => 85,
- :ID => 86,
- :ICON => 87,
- :FCON => 88,
- :CCON => 89,
- :SCON => 90 }
-
-racc_nt_base = 91
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "COLON",
- "CASE",
- "DEFAULT",
- "LBRACE",
- "RBRACE",
- "SEMICOLON",
- "IF",
- "LPAREN",
- "RPAREN",
- "ELSE",
- "SWITCH",
- "WHILE",
- "DO",
- "FOR",
- "GOTO",
- "CONTINUE",
- "BREAK",
- "RETURN",
- "COMMA",
- "EQ",
- "TYPEDEF",
- "EXTERN",
- "STATIC",
- "AUTO",
- "REGISTER",
- "VOID",
- "CHAR",
- "SHORT",
- "INT",
- "LONG",
- "FLOAT",
- "DOUBLE",
- "SIGNED",
- "UNSIGNED",
- "BOOL",
- "COMPLEX",
- "IMAGINARY",
- "STRUCT",
- "UNION",
- "ENUM",
- "CONST",
- "RESTRICT",
- "VOLATILE",
- "INLINE",
- "LBRACKET",
- "RBRACKET",
- "MUL",
- "ELLIPSIS",
- "TYPENAME",
- "DOT",
- "ARROW",
- "INC",
- "DEC",
- "SIZEOF",
- "AND",
- "ADD",
- "SUB",
- "NOT",
- "BANG",
- "DIV",
- "MOD",
- "LSHIFT",
- "RSHIFT",
- "LT",
- "GT",
- "LEQ",
- "GEQ",
- "EQEQ",
- "NEQ",
- "XOR",
- "OR",
- "ANDAND",
- "OROR",
- "QUESTION",
- "MULEQ",
- "DIVEQ",
- "MODEQ",
- "ADDEQ",
- "SUBEQ",
- "LSHIFTEQ",
- "RSHIFTEQ",
- "ANDEQ",
- "XOREQ",
- "OREQ",
- "ID",
- "ICON",
- "FCON",
- "CCON",
- "SCON",
- "$start",
- "translation_unit",
- "external_declaration",
- "function_definition",
- "declaration",
- "declaration_specifiers",
- "declarator",
- "declaration_list",
- "compound_statement",
- "statement",
- "labeled_statement",
- "expression_statement",
- "selection_statement",
- "iteration_statement",
- "jump_statement",
- "identifier",
- "constant_expression",
- "typedef_name",
- "block_item_list",
- "block_item",
- "expression",
- "init_declarator_list",
- "storage_class_specifier",
- "type_specifier",
- "type_qualifier",
- "function_specifier",
- "init_declarator",
- "initializer",
- "struct_or_union_specifier",
- "enum_specifier",
- "struct_or_union",
- "struct_declaration_list",
- "struct_declaration",
- "specifier_qualifier_list",
- "struct_declarator_list",
- "struct_declarator",
- "enumerator_list",
- "enumerator",
- "enumeration_constant",
- "pointer",
- "direct_declarator",
- "type_qualifier_list",
- "assignment_expression",
- "parameter_type_list",
- "identifier_list",
- "parameter_list",
- "parameter_declaration",
- "abstract_declarator",
- "type_name",
- "direct_abstract_declarator",
- "initializer_list",
- "designation",
- "designator_list",
- "designator",
- "primary_expression",
- "constant",
- "string_literal",
- "postfix_expression",
- "argument_expression_list",
- "argument_expression",
- "unary_expression",
- "unary_operator",
- "cast_expression",
- "multiplicative_expression",
- "additive_expression",
- "shift_expression",
- "relational_expression",
- "equality_expression",
- "and_expression",
- "exclusive_or_expression",
- "inclusive_or_expression",
- "logical_and_expression",
- "logical_or_expression",
- "conditional_expression",
- "assignment_operator" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'cast.y', 32)
- def _reduce_1(val, _values, result)
- result = TranslationUnit.new_at(val[0].pos, NodeChain[val[0]])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 33)
- def _reduce_2(val, _values, result)
- result = val[0]; result.entities << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 37)
- def _reduce_3(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 38)
- def _reduce_4(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 42)
- def _reduce_5(val, _values, result)
- result = make_function_def(val[0][0], val[0][1], val[1], val[2], val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 43)
- def _reduce_6(val, _values, result)
- result = make_function_def(val[0][0], val[0][1], val[1], nil , val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 47)
- def _reduce_7(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 48)
- def _reduce_8(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 54)
- def _reduce_9(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 55)
- def _reduce_10(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 56)
- def _reduce_11(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 57)
- def _reduce_12(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 58)
- def _reduce_13(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 59)
- def _reduce_14(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 63)
- def _reduce_15(val, _values, result)
- val[2].labels.unshift(PlainLabel.new_at(val[0].pos, val[0].val)); result = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 64)
- def _reduce_16(val, _values, result)
- val[3].labels.unshift(Case .new_at(val[0].pos, val[1] )); result = val[3]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 65)
- def _reduce_17(val, _values, result)
- val[2].labels.unshift(Default .new_at(val[0].pos )); result = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 67)
- def _reduce_18(val, _values, result)
- val[2].labels.unshift(PlainLabel.new_at(val[0].pos, val[0].name)); result = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 71)
- def _reduce_19(val, _values, result)
- result = Block.new_at(val[0].pos, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 72)
- def _reduce_20(val, _values, result)
- result = Block.new_at(val[0].pos )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 76)
- def _reduce_21(val, _values, result)
- result = NodeChain[val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 77)
- def _reduce_22(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 81)
- def _reduce_23(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 82)
- def _reduce_24(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 86)
- def _reduce_25(val, _values, result)
- result = ExpressionStatement.new_at(val[0].pos, val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 87)
- def _reduce_26(val, _values, result)
- result = ExpressionStatement.new_at(val[0].pos )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 91)
- def _reduce_27(val, _values, result)
- result = If .new_at(val[0].pos, val[2], val[4] )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 92)
- def _reduce_28(val, _values, result)
- result = If .new_at(val[0].pos, val[2], val[4], val[6])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 93)
- def _reduce_29(val, _values, result)
- result = Switch.new_at(val[0].pos, val[2], val[4] )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 97)
- def _reduce_30(val, _values, result)
- result = While.new_at(val[0].pos, val[2], val[4] )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 98)
- def _reduce_31(val, _values, result)
- result = While.new_at(val[0].pos, val[4], val[1], :do => true )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 99)
- def _reduce_32(val, _values, result)
- result = For.new_at(val[0].pos, val[2], val[4], val[6], val[8])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 100)
- def _reduce_33(val, _values, result)
- result = For.new_at(val[0].pos, val[2], val[4], nil , val[7])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 101)
- def _reduce_34(val, _values, result)
- result = For.new_at(val[0].pos, val[2], nil , val[5], val[7])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 102)
- def _reduce_35(val, _values, result)
- result = For.new_at(val[0].pos, val[2], nil , nil , val[6])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 103)
- def _reduce_36(val, _values, result)
- result = For.new_at(val[0].pos, nil , val[3], val[5], val[7])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 104)
- def _reduce_37(val, _values, result)
- result = For.new_at(val[0].pos, nil , val[3], nil , val[6])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 105)
- def _reduce_38(val, _values, result)
- result = For.new_at(val[0].pos, nil , nil , val[4], val[6])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 106)
- def _reduce_39(val, _values, result)
- result = For.new_at(val[0].pos, nil , nil , nil , val[5])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 107)
- def _reduce_40(val, _values, result)
- result = For.new_at(val[0].pos, val[2], val[3], val[5], val[7])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 108)
- def _reduce_41(val, _values, result)
- result = For.new_at(val[0].pos, val[2], val[3], nil , val[6])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 109)
- def _reduce_42(val, _values, result)
- result = For.new_at(val[0].pos, val[2], nil , val[4], val[6])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 110)
- def _reduce_43(val, _values, result)
- result = For.new_at(val[0].pos, val[2], nil , nil , val[5])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 114)
- def _reduce_44(val, _values, result)
- result = Goto .new_at(val[0].pos, val[1].val)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 115)
- def _reduce_45(val, _values, result)
- result = Continue.new_at(val[0].pos )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 116)
- def _reduce_46(val, _values, result)
- result = Break .new_at(val[0].pos )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 117)
- def _reduce_47(val, _values, result)
- result = Return .new_at(val[0].pos, val[1] )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 118)
- def _reduce_48(val, _values, result)
- result = Return .new_at(val[0].pos )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 120)
- def _reduce_49(val, _values, result)
- result = Goto .new_at(val[0].pos, val[1].name)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 126)
- def _reduce_50(val, _values, result)
- result = make_declaration(val[0][0], val[0][1], val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 127)
- def _reduce_51(val, _values, result)
- result = make_declaration(val[0][0], val[0][1], NodeArray[])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 131)
- def _reduce_52(val, _values, result)
- val[1][1] << val[0][1]; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 132)
- def _reduce_53(val, _values, result)
- result = [val[0][0], [val[0][1]]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 133)
- def _reduce_54(val, _values, result)
- val[1][1] << val[0][1]; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 134)
- def _reduce_55(val, _values, result)
- result = [val[0][0], [val[0][1]]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 135)
- def _reduce_56(val, _values, result)
- val[1][1] << val[0][1]; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 136)
- def _reduce_57(val, _values, result)
- result = [val[0][0], [val[0][1]]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 137)
- def _reduce_58(val, _values, result)
- val[1][1] << val[0][1]; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 138)
- def _reduce_59(val, _values, result)
- result = [val[0][0], [val[0][1]]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 142)
- def _reduce_60(val, _values, result)
- result = NodeArray[val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 143)
- def _reduce_61(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 147)
- def _reduce_62(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 148)
- def _reduce_63(val, _values, result)
- val[0].init = val[2]; result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 152)
- def _reduce_64(val, _values, result)
- result = [val[0].pos, :typedef ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 153)
- def _reduce_65(val, _values, result)
- result = [val[0].pos, :extern ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 154)
- def _reduce_66(val, _values, result)
- result = [val[0].pos, :static ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 155)
- def _reduce_67(val, _values, result)
- result = [val[0].pos, :auto ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 156)
- def _reduce_68(val, _values, result)
- result = [val[0].pos, :register]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 160)
- def _reduce_69(val, _values, result)
- result = [val[0].pos, :void ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 161)
- def _reduce_70(val, _values, result)
- result = [val[0].pos, :char ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 162)
- def _reduce_71(val, _values, result)
- result = [val[0].pos, :short ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 163)
- def _reduce_72(val, _values, result)
- result = [val[0].pos, :int ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 164)
- def _reduce_73(val, _values, result)
- result = [val[0].pos, :long ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 165)
- def _reduce_74(val, _values, result)
- result = [val[0].pos, :float ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 166)
- def _reduce_75(val, _values, result)
- result = [val[0].pos, :double ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 167)
- def _reduce_76(val, _values, result)
- result = [val[0].pos, :signed ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 168)
- def _reduce_77(val, _values, result)
- result = [val[0].pos, :unsigned ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 169)
- def _reduce_78(val, _values, result)
- result = [val[0].pos, :_Bool ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 170)
- def _reduce_79(val, _values, result)
- result = [val[0].pos, :_Complex ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 171)
- def _reduce_80(val, _values, result)
- result = [val[0].pos, :_Imaginary]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 172)
- def _reduce_81(val, _values, result)
- result = [val[0].pos, val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 173)
- def _reduce_82(val, _values, result)
- result = [val[0].pos, val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 174)
- def _reduce_83(val, _values, result)
- result = [val[0].pos, val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 178)
- def _reduce_84(val, _values, result)
- result = val[0][1].new_at(val[0][0], val[1].val, val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 179)
- def _reduce_85(val, _values, result)
- result = val[0][1].new_at(val[0][0], nil , val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 180)
- def _reduce_86(val, _values, result)
- result = val[0][1].new_at(val[0][0], val[1].val, nil )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 182)
- def _reduce_87(val, _values, result)
- result = val[0][1].new_at(val[0][0], val[1].name, val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 183)
- def _reduce_88(val, _values, result)
- result = val[0][1].new_at(val[0][0], val[1].name, nil )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 187)
- def _reduce_89(val, _values, result)
- result = [val[0].pos, Struct]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 188)
- def _reduce_90(val, _values, result)
- result = [val[0].pos, Union ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 192)
- def _reduce_91(val, _values, result)
- result = NodeArray[val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 193)
- def _reduce_92(val, _values, result)
- val[0] << val[1]; result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 197)
- def _reduce_93(val, _values, result)
- result = make_declaration(val[0][0], val[0][1], val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 201)
- def _reduce_94(val, _values, result)
- val[1][1] << val[0][1]; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 202)
- def _reduce_95(val, _values, result)
- result = [val[0][0], [val[0][1]]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 203)
- def _reduce_96(val, _values, result)
- val[1][1] << val[0][1]; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 204)
- def _reduce_97(val, _values, result)
- result = [val[0][0], [val[0][1]]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 208)
- def _reduce_98(val, _values, result)
- result = NodeArray[val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 209)
- def _reduce_99(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 213)
- def _reduce_100(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 214)
- def _reduce_101(val, _values, result)
- result = val[0]; val[0].num_bits = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 215)
- def _reduce_102(val, _values, result)
- result = Declarator.new_at(val[0].pos, :num_bits => val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 219)
- def _reduce_103(val, _values, result)
- result = Enum.new_at(val[0].pos, val[1].val, val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 220)
- def _reduce_104(val, _values, result)
- result = Enum.new_at(val[0].pos, nil , val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 221)
- def _reduce_105(val, _values, result)
- result = Enum.new_at(val[0].pos, val[1].val, val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 222)
- def _reduce_106(val, _values, result)
- result = Enum.new_at(val[0].pos, nil , val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 223)
- def _reduce_107(val, _values, result)
- result = Enum.new_at(val[0].pos, val[1].val, nil )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 225)
- def _reduce_108(val, _values, result)
- result = Enum.new_at(val[0].pos, val[1].name, val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 226)
- def _reduce_109(val, _values, result)
- result = Enum.new_at(val[0].pos, val[1].name, val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 227)
- def _reduce_110(val, _values, result)
- result = Enum.new_at(val[0].pos, val[1].name, nil )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 231)
- def _reduce_111(val, _values, result)
- result = NodeArray[val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 232)
- def _reduce_112(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 236)
- def _reduce_113(val, _values, result)
- result = Enumerator.new_at(val[0].pos, val[0].val, nil )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 237)
- def _reduce_114(val, _values, result)
- result = Enumerator.new_at(val[0].pos, val[0].val, val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 241)
- def _reduce_115(val, _values, result)
- result = [val[0].pos, :const ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 242)
- def _reduce_116(val, _values, result)
- result = [val[0].pos, :restrict]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 243)
- def _reduce_117(val, _values, result)
- result = [val[0].pos, :volatile]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 247)
- def _reduce_118(val, _values, result)
- result = [val[0].pos, :inline]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 251)
- def _reduce_119(val, _values, result)
- result = add_decl_type(val[1], val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 252)
- def _reduce_120(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 256)
- def _reduce_121(val, _values, result)
- result = Declarator.new_at(val[0].pos, nil, val[0].val)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 257)
- def _reduce_122(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 258)
- def _reduce_123(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 259)
- def _reduce_124(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 260)
- def _reduce_125(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos, nil, val[2]))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 261)
- def _reduce_126(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 262)
- def _reduce_127(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 263)
- def _reduce_128(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 264)
- def _reduce_129(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 265)
- def _reduce_130(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 266)
- def _reduce_131(val, _values, result)
- result = add_decl_type(val[0], Array.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 267)
- def _reduce_132(val, _values, result)
- result = add_decl_type(val[0], Function.new_at(val[0].pos, nil, param_list(*val[2]), :var_args => val[2][1]))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 268)
- def _reduce_133(val, _values, result)
- result = add_decl_type(val[0], Function.new_at(val[0].pos, nil, val[2]))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 269)
- def _reduce_134(val, _values, result)
- result = add_decl_type(val[0], Function.new_at(val[0].pos ))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 273)
- def _reduce_135(val, _values, result)
- result = add_type_quals(Pointer.new_at(val[0].pos), val[1][1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 274)
- def _reduce_136(val, _values, result)
- result = Pointer.new_at(val[0].pos)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 275)
- def _reduce_137(val, _values, result)
- p = add_type_quals(Pointer.new_at(val[0].pos), val[1][1]); val[2].direct_type = p; result = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 276)
- def _reduce_138(val, _values, result)
- p = Pointer.new_at(val[0].pos) ; val[1].direct_type = p; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 280)
- def _reduce_139(val, _values, result)
- result = [val[0][0], [val[0][1]]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 281)
- def _reduce_140(val, _values, result)
- val[0][1] << val[1][1]; result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 285)
- def _reduce_141(val, _values, result)
- result = [val[0], false]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 286)
- def _reduce_142(val, _values, result)
- result = [val[0], true ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 290)
- def _reduce_143(val, _values, result)
- result = NodeArray[val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 291)
- def _reduce_144(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 295)
- def _reduce_145(val, _values, result)
- ind_type = val[1].indirect_type and ind_type.detach
- result = make_parameter(val[0][0], val[0][1], ind_type, val[1].name)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 297)
- def _reduce_146(val, _values, result)
- result = make_parameter(val[0][0], val[0][1], val[1] , nil )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 298)
- def _reduce_147(val, _values, result)
- result = make_parameter(val[0][0], val[0][1], nil , nil )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 302)
- def _reduce_148(val, _values, result)
- result = NodeArray[Parameter.new_at(val[0].pos, nil, val[0].val)]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 303)
- def _reduce_149(val, _values, result)
- result = val[0] << Parameter.new_at(val[2].pos, nil, val[2].val)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 307)
- def _reduce_150(val, _values, result)
- val[1].direct_type = make_direct_type(val[0][0], val[0][1]); result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 308)
- def _reduce_151(val, _values, result)
- result = make_direct_type(val[0][0], val[0][1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 312)
- def _reduce_152(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 313)
- def _reduce_153(val, _values, result)
- val[1].direct_type = val[0]; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 314)
- def _reduce_154(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 318)
- def _reduce_155(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 319)
- def _reduce_156(val, _values, result)
- val[0].direct_type = Array.new_at(val[0].pos, nil, val[2]); result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 320)
- def _reduce_157(val, _values, result)
- val[0].direct_type = Array.new_at(val[0].pos, nil, nil ); result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 321)
- def _reduce_158(val, _values, result)
- result = Array.new_at(val[0].pos, nil, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 322)
- def _reduce_159(val, _values, result)
- result = Array.new_at(val[0].pos )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 323)
- def _reduce_160(val, _values, result)
- val[0].direct_type = Array.new_at(val[0].pos); result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 324)
- def _reduce_161(val, _values, result)
- result = Array.new_at(val[0].pos)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 325)
- def _reduce_162(val, _values, result)
- val[0].direct_type = Function.new_at(val[0].pos, nil, param_list(*val[2]), val[2][1]); result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 326)
- def _reduce_163(val, _values, result)
- val[0].direct_type = Function.new_at(val[0].pos ); result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 327)
- def _reduce_164(val, _values, result)
- result = Function.new_at(val[0].pos, nil, param_list(*val[1]), val[1][1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 328)
- def _reduce_165(val, _values, result)
- result = Function.new_at(val[0].pos )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 334)
- def _reduce_166(val, _values, result)
- result = CustomType.new_at(val[0].pos, val[0].val)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 338)
- def _reduce_167(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 339)
- def _reduce_168(val, _values, result)
- result = CompoundLiteral.new_at(val[0].pos, nil, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 340)
- def _reduce_169(val, _values, result)
- result = CompoundLiteral.new_at(val[0].pos, nil, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 344)
- def _reduce_170(val, _values, result)
- result = NodeArray[MemberInit.new_at(val[0][0] , val[0][1], val[1])]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 345)
- def _reduce_171(val, _values, result)
- result = NodeArray[MemberInit.new_at(val[0].pos, nil , val[0])]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 346)
- def _reduce_172(val, _values, result)
- result = val[0] << MemberInit.new_at(val[2][0] , val[2][1], val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 347)
- def _reduce_173(val, _values, result)
- result = val[0] << MemberInit.new_at(val[2].pos, nil , val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 351)
- def _reduce_174(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 355)
- def _reduce_175(val, _values, result)
- result = val[0]; val[0][1] = NodeArray[val[0][1]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 356)
- def _reduce_176(val, _values, result)
- result = val[0]; val[0][1] << val[1][1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 360)
- def _reduce_177(val, _values, result)
- result = [val[1].pos, val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 361)
- def _reduce_178(val, _values, result)
- result = [val[1].pos, Member.new_at(val[1].pos, val[1].val)]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 367)
- def _reduce_179(val, _values, result)
- result = Variable.new_at(val[0].pos, val[0].val)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 368)
- def _reduce_180(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 369)
- def _reduce_181(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 371)
- def _reduce_182(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 372)
- def _reduce_183(val, _values, result)
- block_expressions_enabled? or parse_error val[0].pos, "compound statement found where expression expected"
- result = BlockExpression.new(val[1]); result.pos = val[0].pos
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 377)
- def _reduce_184(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 378)
- def _reduce_185(val, _values, result)
- result = Index .new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 379)
- def _reduce_186(val, _values, result)
- result = Call .new_at(val[0].pos, val[0], val[2] )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 380)
- def _reduce_187(val, _values, result)
- result = Call .new_at(val[0].pos, val[0], NodeArray[])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 381)
- def _reduce_188(val, _values, result)
- result = Dot .new_at(val[0].pos, val[0], Member.new(val[2].val))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 382)
- def _reduce_189(val, _values, result)
- result = Arrow .new_at(val[0].pos, val[0], Member.new(val[2].val))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 383)
- def _reduce_190(val, _values, result)
- result = PostInc .new_at(val[0].pos, val[0] )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 384)
- def _reduce_191(val, _values, result)
- result = PostDec .new_at(val[0].pos, val[0] )
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 385)
- def _reduce_192(val, _values, result)
- result = CompoundLiteral.new_at(val[0].pos, val[1], val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 386)
- def _reduce_193(val, _values, result)
- result = CompoundLiteral.new_at(val[0].pos, val[1], val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 390)
- def _reduce_194(val, _values, result)
- result = NodeArray[val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 391)
- def _reduce_195(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 395)
- def _reduce_196(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 396)
- def _reduce_197(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 400)
- def _reduce_198(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 401)
- def _reduce_199(val, _values, result)
- result = PreInc.new_at(val[0].pos, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 402)
- def _reduce_200(val, _values, result)
- result = PreDec.new_at(val[0].pos, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 403)
- def _reduce_201(val, _values, result)
- result = val[0][0].new_at(val[0][1], val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 404)
- def _reduce_202(val, _values, result)
- result = Sizeof.new_at(val[0].pos, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 405)
- def _reduce_203(val, _values, result)
- result = Sizeof.new_at(val[0].pos, val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 409)
- def _reduce_204(val, _values, result)
- result = [Address , val[0].pos]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 410)
- def _reduce_205(val, _values, result)
- result = [Dereference, val[0].pos]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 411)
- def _reduce_206(val, _values, result)
- result = [Positive , val[0].pos]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 412)
- def _reduce_207(val, _values, result)
- result = [Negative , val[0].pos]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 413)
- def _reduce_208(val, _values, result)
- result = [BitNot , val[0].pos]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 414)
- def _reduce_209(val, _values, result)
- result = [Not , val[0].pos]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 418)
- def _reduce_210(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 419)
- def _reduce_211(val, _values, result)
- result = Cast.new_at(val[0].pos, val[1], val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 423)
- def _reduce_212(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 424)
- def _reduce_213(val, _values, result)
- result = Multiply.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 425)
- def _reduce_214(val, _values, result)
- result = Divide .new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 426)
- def _reduce_215(val, _values, result)
- result = Mod .new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 430)
- def _reduce_216(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 431)
- def _reduce_217(val, _values, result)
- result = Add .new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 432)
- def _reduce_218(val, _values, result)
- result = Subtract.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 436)
- def _reduce_219(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 437)
- def _reduce_220(val, _values, result)
- result = ShiftLeft .new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 438)
- def _reduce_221(val, _values, result)
- result = ShiftRight.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 442)
- def _reduce_222(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 443)
- def _reduce_223(val, _values, result)
- result = Less.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 444)
- def _reduce_224(val, _values, result)
- result = More.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 445)
- def _reduce_225(val, _values, result)
- result = LessOrEqual.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 446)
- def _reduce_226(val, _values, result)
- result = MoreOrEqual.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 450)
- def _reduce_227(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 451)
- def _reduce_228(val, _values, result)
- result = Equal .new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 452)
- def _reduce_229(val, _values, result)
- result = NotEqual.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 456)
- def _reduce_230(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 457)
- def _reduce_231(val, _values, result)
- result = BitAnd.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 461)
- def _reduce_232(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 462)
- def _reduce_233(val, _values, result)
- result = BitXor.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 466)
- def _reduce_234(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 467)
- def _reduce_235(val, _values, result)
- result = BitOr.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 471)
- def _reduce_236(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 472)
- def _reduce_237(val, _values, result)
- result = And.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 476)
- def _reduce_238(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 477)
- def _reduce_239(val, _values, result)
- result = Or.new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 481)
- def _reduce_240(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 482)
- def _reduce_241(val, _values, result)
- result = Conditional.new_at(val[0].pos, val[0], val[2], val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 486)
- def _reduce_242(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 487)
- def _reduce_243(val, _values, result)
- result = val[1].new_at(val[0].pos, val[0], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 491)
- def _reduce_244(val, _values, result)
- result = Assign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 492)
- def _reduce_245(val, _values, result)
- result = MultiplyAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 493)
- def _reduce_246(val, _values, result)
- result = DivideAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 494)
- def _reduce_247(val, _values, result)
- result = ModAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 495)
- def _reduce_248(val, _values, result)
- result = AddAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 496)
- def _reduce_249(val, _values, result)
- result = SubtractAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 497)
- def _reduce_250(val, _values, result)
- result = ShiftLeftAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 498)
- def _reduce_251(val, _values, result)
- result = ShiftRightAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 499)
- def _reduce_252(val, _values, result)
- result = BitAndAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 500)
- def _reduce_253(val, _values, result)
- result = BitXorAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 501)
- def _reduce_254(val, _values, result)
- result = BitOrAssign
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 505)
- def _reduce_255(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 507)
- def _reduce_256(val, _values, result)
- if val[0].is_a? Comma
- if val[2].is_a? Comma
- val[0].exprs.push(*val[2].exprs)
- else
- val[0].exprs << val[2]
- end
- result = val[0]
- else
- if val[2].is_a? Comma
- val[2].exprs.unshift(val[0])
- val[2].pos = val[0].pos
- result = val[2]
- else
- result = Comma.new_at(val[0].pos, NodeArray[val[0], val[2]])
- end
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 527)
- def _reduce_257(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 542)
- def _reduce_258(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 546)
- def _reduce_259(val, _values, result)
- result = val[0].val; result.pos = val[0].pos
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 547)
- def _reduce_260(val, _values, result)
- result = val[0].val; result.pos = val[0].pos
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 550)
- def _reduce_261(val, _values, result)
- result = val[0].val; result.pos = val[0].pos
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 554)
- def _reduce_262(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 559)
- def _reduce_263(val, _values, result)
- val[0].val << val[1].val.val; result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'cast.y', 560)
- def _reduce_264(val, _values, result)
- result = val[0].val; result.pos = val[0].pos
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module C
diff --git a/test/racc/regress/csspool b/test/racc/regress/csspool
deleted file mode 100644
index 0a68d99bfd..0000000000
--- a/test/racc/regress/csspool
+++ /dev/null
@@ -1,2318 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-module CSSPool
- module CSS
- class Parser < Racc::Parser
-
-module_eval(<<'...end csspool.y/module_eval...', 'csspool.y', 670)
-
-def numeric thing
- thing = thing.gsub(/[^\d.]/, '')
- Integer(thing) rescue Float(thing)
-end
-
-def interpret_identifier s
- interpret_escapes s
-end
-
-def interpret_uri s
- interpret_escapes s.match(/^url\((.*)\)$/mui)[1].strip.match(/^(['"]?)((?:\\.|.)*)\1$/mu)[2]
-end
-
-def interpret_string_no_quote s
- interpret_escapes s.match(/^(.*)\)$/mu)[1].strip.match(/^(['"]?)((?:\\.|.)*)\1$/mu)[2]
-end
-
-def interpret_string s
- interpret_escapes s.match(/^(['"])((?:\\.|.)*)\1$/mu)[2]
-end
-
-def interpret_escapes s
- token_exp = /\\(?:([0-9a-fA-F]{1,6}(?:\r\n|\s)?)|(.))/mu
- return s.gsub(token_exp) do |escape_sequence|
- if !$1.nil?
- code = $1.chomp.to_i 16
- code = 0xFFFD if code > 0x10FFFF
- next [code].pack('U')
- end
- next '' if $2 == "\n"
- next $2
- end
-end
-
-# override racc's on_error so we can have context in our error messages
-def on_error(t, val, vstack)
- errcontext = (@ss.pre_match[-10..-1] || @ss.pre_match) +
- @ss.matched + @ss.post_match[0..9]
- line_number = @ss.pre_match.lines.count
- raise ParseError, sprintf("parse error on value %s (%s) " +
- "on line %s around \"%s\"",
- val.inspect, token_to_str(t) || '?',
- line_number, errcontext)
-end
-
-def before_pos(val)
- # don't include leading whitespace
- return current_pos - val.last.length + val.last[/\A\s*/].size
-end
-
-def after_pos(val)
- # don't include trailing whitespace
- return current_pos - val.last[/\s*\z/].size
-end
-
-# charpos will work with multibyte strings but is not available until ruby 2
-def current_pos
- @ss.respond_to?('charpos') ? @ss.charpos : @ss.pos
-end
-...end csspool.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 9, 10, 137, 83, 37, 31, 55, 139, 59, 39,
- 45, 47, 45, 47, 85, 9, 10, 55, 129, 37,
- 31, 103, 84, 130, 39, 45, 47, 157, 158, 108,
- 113, 20, 113, 56, 37, 114, 23, 114, 163, 39,
- 45, 47, 104, 27, 56, 11, 20, 346, 48, 25,
- 48, 23, 224, 29, 138, 319, 38, 46, 27, 46,
- 11, 108, 113, 48, 25, 9, 10, 114, 29, 37,
- 31, 38, 46, 242, 39, 45, 47, 115, 48, 115,
- 9, 10, 319, 163, 37, 31, 38, 46, 339, 39,
- 45, 47, 351, 306, 245, 223, 20, 108, 113, 37,
- 31, 23, 118, 114, 39, 45, 47, 244, 27, 115,
- 11, 20, 344, 48, 25, 243, 23, 313, 29, 340,
- 314, 38, 46, 27, 345, 11, 20, 55, 48, 25,
- 155, 23, 163, 29, 37, 64, 38, 46, 27, 39,
- 45, 47, 231, 48, 25, 115, 103, 232, 29, -89,
- 229, 38, 46, 203, 56, 230, 123, 250, 37, 319,
- 251, 20, 357, 39, 45, 47, 23, 104, 75, 204,
- 124, 125, 188, 27, 59, 322, 45, 47, 48, 25,
- 187, 3, 359, 29, 74, 73, 38, 46, 83, 126,
- 198, 49, 190, 197, 192, 191, 193, 194, 195, 85,
- 37, 31, 48, 108, 113, 39, 45, 47, 107, 114,
- 38, 46, 53, 105, 48, 103, 153, 170, 151, 98,
- 116, 181, 186, 46, 185, 196, 120, 20, 108, 113,
- 45, 47, 23, 215, 114, 298, 104, 297, 188, 27,
- 59, 201, 45, 47, 48, 25, 187, 121, 252, 29,
- 151, 115, 38, 46, 83, 128, 198, 202, 190, 197,
- 192, 191, 193, 194, 195, 85, 37, 31, 48, 131,
- 77, 39, 45, 47, 45, 47, 115, 46, 203, 37,
- 48, 136, 148, 170, 39, 45, 47, 181, 186, 46,
- 185, 196, 92, 20, 204, 37, 31, -28, 23, 87,
- 39, 45, 47, 156, 201, 27, 160, 163, 94, 75,
- 48, 25, 48, 164, 296, 29, 295, 83, 38, 46,
- 202, 46, 20, 48, 165, 74, 73, 23, 85, 166,
- 167, 38, 46, 188, 27, 59, 84, 168, 169, 48,
- 25, 187, 199, 294, 29, 293, 200, 38, 46, 83,
- 292, 198, 291, 190, 197, 192, 191, 193, 194, 195,
- 85, 37, 31, 92, 37, 31, 39, 45, 47, 39,
- 45, 47, 289, 163, 290, 113, 210, -33, 170, 288,
- 114, 287, 181, 186, 212, 185, 196, 92, 20, -33,
- 216, 37, 217, 23, 218, 219, 39, 45, 47, 108,
- 27, 108, 225, 94, 226, 48, 25, 188, 48, 59,
- 29, 258, 233, 38, 46, 187, 38, 46, 260, 150,
- 152, 151, 115, 83, 129, 198, 259, 190, 197, 192,
- 191, 193, 194, 195, 85, 48, 234, 163, 255, 256,
- 155, 263, 169, 38, 46, 264, 188, 168, 59, 265,
- 266, 92, 170, 92, 187, 92, 181, 186, 92, 185,
- 196, 184, 83, 278, 198, 279, 190, 197, 192, 191,
- 193, 194, 195, 85, 37, 31, 281, 286, 229, 39,
- 45, 47, 198, 231, 190, 197, 192, 191, 193, 194,
- 195, 170, 163, 300, 301, 181, 186, 302, 185, 196,
- 303, 20, 37, 306, 307, 255, 23, 39, 45, 47,
- 75, 163, 188, 27, 59, 185, 168, 312, 48, 25,
- 187, 317, 319, 29, 323, 324, 38, 46, 83, 325,
- 198, 326, 190, 197, 192, 191, 193, 194, 195, 85,
- 327, 328, 329, 330, 331, 332, 48, 333, 334, 306,
- 188, 163, 59, 338, 38, 46, nil, 170, 187, nil,
- nil, 181, 186, nil, 185, 196, 83, nil, 198, nil,
- 190, 197, 192, 191, 193, 194, 195, 85, 37, 31,
- nil, nil, nil, 39, 45, 47, nil, nil, 188, nil,
- 59, 285, nil, nil, nil, 170, 187, nil, nil, 181,
- 186, nil, 185, 196, 83, 141, 198, nil, 190, 197,
- 192, 191, 193, 194, 195, 85, nil, nil, nil, 143,
- nil, nil, 48, 241, 235, 236, 237, nil, nil, nil,
- 38, 46, nil, 170, nil, nil, 145, 181, 186, nil,
- 185, 196, nil, 144, nil, 146, nil, 147, nil, 142,
- 238, 239, 240, 272, nil, 83, nil, 198, nil, 190,
- 197, 192, 191, 193, 194, 195, 272, nil, 83, nil,
- 198, nil, 190, 197, 192, 191, 193, 194, 195, 272,
- nil, 83, nil, 198, nil, 190, 197, 192, 191, 193,
- 194, 195, 272, nil, 83, nil, 198, nil, 190, 197,
- 192, 191, 193, 194, 195, 272, nil, 83, nil, 198,
- nil, 190, 197, 192, 191, 193, 194, 195, 272, nil,
- 83, nil, 198, nil, 190, 197, 192, 191, 193, 194,
- 195 ]
-
-racc_action_check = [
- 2, 2, 47, 22, 2, 2, 11, 47, 11, 2,
- 2, 2, 41, 41, 22, 5, 5, 10, 38, 5,
- 5, 217, 22, 38, 5, 5, 5, 70, 70, 221,
- 221, 2, 210, 11, 144, 221, 2, 210, 312, 144,
- 144, 144, 217, 2, 10, 2, 5, 316, 2, 2,
- 41, 5, 112, 2, 47, 320, 2, 2, 5, 41,
- 5, 110, 110, 5, 5, 6, 6, 110, 5, 6,
- 6, 5, 5, 142, 6, 6, 6, 221, 144, 210,
- 7, 7, 321, 335, 7, 7, 144, 144, 309, 7,
- 7, 7, 337, 338, 143, 112, 6, 30, 30, 15,
- 15, 6, 30, 30, 15, 15, 15, 143, 6, 110,
- 6, 7, 315, 6, 6, 142, 7, 269, 6, 309,
- 269, 6, 6, 7, 315, 7, 15, 58, 7, 7,
- 58, 15, 340, 7, 19, 19, 7, 7, 15, 19,
- 19, 19, 131, 15, 15, 30, 99, 131, 15, 99,
- 128, 15, 15, 91, 58, 128, 34, 149, 302, 349,
- 149, 19, 350, 302, 302, 302, 19, 99, 157, 91,
- 34, 34, 286, 19, 286, 286, 42, 42, 19, 19,
- 286, 1, 358, 19, 157, 157, 19, 19, 286, 34,
- 286, 3, 286, 286, 286, 286, 286, 286, 286, 286,
- 13, 13, 302, 28, 28, 13, 13, 13, 28, 28,
- 302, 302, 9, 27, 42, 26, 57, 286, 57, 26,
- 29, 286, 286, 42, 286, 286, 32, 13, 100, 100,
- 43, 43, 13, 100, 100, 240, 26, 240, 285, 13,
- 285, 206, 44, 44, 13, 13, 285, 33, 154, 13,
- 154, 28, 13, 13, 285, 37, 285, 206, 285, 285,
- 285, 285, 285, 285, 285, 285, 21, 21, 43, 39,
- 21, 21, 21, 21, 35, 35, 100, 43, 207, 122,
- 44, 46, 53, 285, 122, 122, 122, 285, 285, 44,
- 285, 285, 25, 21, 207, 24, 24, 20, 21, 24,
- 24, 24, 24, 67, 90, 21, 71, 75, 25, 20,
- 21, 21, 35, 76, 239, 21, 239, 166, 21, 21,
- 90, 35, 24, 122, 78, 20, 20, 24, 166, 79,
- 80, 122, 122, 353, 24, 353, 166, 81, 82, 24,
- 24, 353, 86, 238, 24, 238, 88, 24, 24, 353,
- 237, 353, 237, 353, 353, 353, 353, 353, 353, 353,
- 353, 14, 14, 94, 31, 31, 14, 14, 14, 31,
- 31, 31, 236, 270, 236, 92, 92, 270, 353, 235,
- 92, 235, 353, 353, 97, 353, 353, 92, 14, 270,
- 101, 121, 102, 14, 105, 106, 121, 121, 121, 108,
- 14, 109, 114, 92, 117, 14, 14, 171, 31, 171,
- 14, 171, 137, 14, 14, 171, 31, 31, 171, 54,
- 54, 54, 92, 171, 138, 171, 171, 171, 171, 171,
- 171, 171, 171, 171, 171, 121, 139, 147, 161, 162,
- 172, 175, 176, 121, 121, 177, 83, 179, 83, 183,
- 185, 201, 171, 202, 83, 203, 171, 171, 204, 171,
- 171, 83, 83, 208, 83, 209, 83, 83, 83, 83,
- 83, 83, 83, 83, 12, 12, 214, 224, 233, 12,
- 12, 12, 189, 234, 189, 189, 189, 189, 189, 189,
- 189, 83, 243, 245, 246, 83, 83, 247, 83, 83,
- 248, 12, 146, 249, 251, 254, 12, 146, 146, 146,
- 255, 256, 261, 12, 261, 266, 267, 268, 12, 12,
- 261, 280, 284, 12, 287, 288, 12, 12, 261, 289,
- 261, 290, 261, 261, 261, 261, 261, 261, 261, 261,
- 291, 292, 293, 294, 295, 296, 146, 297, 298, 299,
- 322, 304, 322, 306, 146, 146, nil, 261, 322, nil,
- nil, 261, 261, nil, 261, 261, 322, nil, 322, nil,
- 322, 322, 322, 322, 322, 322, 322, 322, 64, 64,
- nil, nil, nil, 64, 64, 64, nil, nil, 223, nil,
- 223, 223, nil, nil, nil, 322, 223, nil, nil, 322,
- 322, nil, 322, 322, 223, 48, 223, nil, 223, 223,
- 223, 223, 223, 223, 223, 223, nil, nil, nil, 48,
- nil, nil, 64, 140, 140, 140, 140, nil, nil, nil,
- 64, 64, nil, 223, nil, nil, 48, 223, 223, nil,
- 223, 223, nil, 48, nil, 48, nil, 48, nil, 48,
- 140, 140, 140, 272, nil, 272, nil, 272, nil, 272,
- 272, 272, 272, 272, 272, 272, 313, nil, 313, nil,
- 313, nil, 313, 313, 313, 313, 313, 313, 313, 314,
- nil, 314, nil, 314, nil, 314, 314, 314, 314, 314,
- 314, 314, 344, nil, 344, nil, 344, nil, 344, 344,
- 344, 344, 344, 344, 344, 345, nil, 345, nil, 345,
- nil, 345, 345, 345, 345, 345, 345, 345, 186, nil,
- 186, nil, 186, nil, 186, 186, 186, 186, 186, 186,
- 186 ]
-
-racc_action_pointer = [
- nil, 181, -2, 191, nil, 13, 63, 78, nil, 208,
- 13, 2, 468, 194, 355, 93, nil, nil, nil, 128,
- 291, 260, -17, nil, 289, 274, 209, 207, 198, 211,
- 92, 358, 217, 239, 149, 262, nil, 197, 12, 211,
- nil, 0, 164, 218, 230, nil, 275, -4, 599, nil,
- nil, nil, nil, 277, 414, nil, nil, 211, 123, nil,
- nil, nil, nil, nil, 572, nil, nil, 293, nil, nil,
- 19, 300, nil, nil, nil, 300, 303, nil, 315, 321,
- 323, 330, 331, 442, nil, nil, 332, nil, 337, nil,
- 268, 117, 369, nil, 345, nil, nil, 374, nil, 140,
- 223, 381, 384, nil, nil, 385, 385, nil, 394, 396,
- 56, nil, 45, nil, 396, nil, nil, 394, nil, nil,
- nil, 385, 273, nil, nil, nil, nil, nil, 144, nil,
- nil, 136, nil, nil, nil, nil, nil, 354, 418, 378,
- 609, nil, 67, 88, 28, nil, 496, 430, nil, 152,
- nil, nil, nil, nil, 243, nil, nil, 150, nil, nil,
- nil, 402, 433, nil, nil, nil, 297, nil, nil, nil,
- nil, 403, 433, nil, nil, 434, 435, 438, nil, 440,
- nil, nil, nil, 430, nil, 442, 700, nil, nil, 460,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 433, 435, 437, 440, nil, 205, 242, 444, 446,
- 26, nil, nil, nil, 466, nil, nil, 15, nil, nil,
- nil, 24, nil, 584, 427, nil, nil, nil, nil, nil,
- nil, nil, nil, 472, 477, 375, 368, 346, 339, 310,
- 231, nil, nil, 485, nil, 474, 475, 489, 481, 497,
- nil, 498, nil, nil, 469, 492, 504, nil, nil, nil,
- nil, 508, nil, nil, nil, nil, 459, 509, 498, 95,
- 366, nil, 635, nil, nil, nil, nil, nil, nil, nil,
- 502, nil, nil, nil, 490, 234, 168, 510, 511, 515,
- 517, 526, 527, 528, 529, 530, 531, 533, 534, 543,
- nil, nil, 152, nil, 544, nil, 545, nil, nil, 69,
- nil, nil, 31, 648, 661, 101, 28, nil, nil, nil,
- 23, 50, 546, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 76, nil, 73, 87, nil,
- 125, nil, nil, nil, 674, 687, nil, nil, nil, 127,
- 143, nil, nil, 329, nil, nil, nil, nil, 163, nil ]
-
-racc_action_default = [
- -1, -229, -10, -229, -2, -6, -7, -8, -9, -229,
- -229, -229, -41, -42, -43, -44, -45, -46, -47, -33,
- -23, -229, -229, -55, -229, -229, -89, -229, -229, -229,
- -229, -229, -229, -103, -105, -111, -112, -115, -229, -120,
- -119, -124, -125, -126, -127, -132, -229, -229, -229, 360,
- -3, -4, -5, -229, -229, -15, -16, -229, -229, -228,
- -37, -38, -39, -40, -32, -48, -49, -229, -99, -21,
- -229, -229, -35, -26, -27, -33, -229, -53, -229, -57,
- -58, -59, -60, -229, -198, -214, -229, -62, -229, -64,
- -65, -66, -229, -71, -229, -73, -74, -229, -82, -85,
- -229, -229, -91, -92, -93, -229, -229, -95, -160, -165,
- -166, -167, -229, -174, -229, -176, -96, -229, -98, -100,
- -101, -229, -229, -106, -107, -108, -109, -110, -229, -117,
- -121, -229, -128, -129, -130, -131, -133, -115, -229, -229,
- -229, -147, -229, -229, -229, -152, -229, -33, -11, -229,
- -13, -14, -20, -18, -229, -227, -50, -28, -51, -35,
- -29, -25, -229, -32, -52, -54, -229, -197, -194, -213,
- -36, -182, -183, -184, -185, -186, -187, -188, -189, -190,
- -191, -192, -193, -229, -196, -200, -229, -212, -216, -229,
- -218, -219, -220, -221, -222, -223, -224, -225, -226, -61,
- -63, -229, -229, -229, -229, -67, -68, -69, -229, -229,
- -229, -72, -81, -84, -229, -87, -88, -89, -83, -94,
- -161, -164, -163, -229, -229, -175, -97, -102, -104, -116,
- -123, -118, -122, -229, -229, -229, -229, -229, -229, -229,
- -229, -146, -148, -33, -149, -229, -229, -114, -229, -156,
- -12, -229, -17, -22, -24, -229, -33, -56, -177, -178,
- -179, -229, -181, -215, -211, -195, -229, -209, -229, -202,
- -205, -208, -229, -217, -76, -78, -75, -77, -70, -79,
- -229, -86, -90, -162, -173, -229, -229, -229, -229, -229,
- -229, -229, -229, -229, -229, -229, -229, -229, -229, -156,
- -150, -151, -229, -153, -33, -157, -158, -19, -34, -229,
- -180, -199, -33, -229, -229, -229, -229, -80, -168, -172,
- -173, -173, -229, -134, -135, -136, -137, -138, -139, -140,
- -141, -142, -143, -144, -145, -33, -113, -229, -229, -30,
- -33, -201, -203, -204, -229, -229, -210, -169, -170, -173,
- -229, -154, -159, -229, -206, -207, -171, -155, -229, -31 ]
-
-racc_goto_table = [
- 81, 248, 183, 68, 106, 91, 117, 271, 78, 246,
- 273, 247, 82, 69, 209, 161, 97, 90, 268, 304,
- 89, 119, 54, 57, 354, 355, 318, 60, 61, 62,
- 63, 220, 221, 58, 65, 127, 76, 282, 70, 86,
- 227, 132, 133, 134, 135, 4, 228, 208, 50, 51,
- 52, 122, 159, 308, 119, 140, 67, 352, 66, 162,
- 1, 261, 347, 348, 2, 311, 88, 149, nil, 335,
- 154, nil, 207, nil, 211, nil, 214, nil, nil, nil,
- nil, nil, nil, nil, 206, nil, 222, 205, nil, 213,
- 262, 356, nil, 271, nil, nil, nil, nil, nil, nil,
- nil, nil, 254, nil, 316, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 249, 280, nil, 271, 271, nil, nil, nil, nil,
- nil, nil, 284, nil, 81, 342, 343, nil, nil, nil,
- 253, nil, 257, nil, nil, nil, 82, 336, nil, nil,
- nil, nil, nil, nil, 267, 271, 271, 247, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 310, 274, 275, 276, 277, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 283, nil, nil,
- nil, nil, nil, nil, 320, 321, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 299, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 309, 349, nil, nil, nil, nil, nil, nil, nil, nil,
- 267, nil, nil, nil, 315, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 358, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 337, nil,
- nil, 267, 267, nil, nil, nil, 341, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 350,
- nil, nil, 267, 267, 353 ]
-
-racc_goto_check = [
- 35, 62, 18, 17, 51, 41, 51, 77, 32, 58,
- 77, 58, 36, 12, 46, 15, 48, 40, 82, 68,
- 39, 55, 8, 8, 84, 84, 73, 7, 7, 7,
- 7, 70, 70, 10, 7, 61, 7, 52, 11, 7,
- 56, 61, 61, 61, 61, 2, 57, 42, 2, 2,
- 2, 59, 14, 16, 55, 63, 27, 69, 28, 17,
- 1, 74, 73, 73, 3, 81, 38, 9, nil, 68,
- 8, nil, 41, nil, 41, nil, 51, nil, nil, nil,
- nil, nil, nil, nil, 40, nil, 51, 39, nil, 48,
- 18, 73, nil, 77, nil, nil, nil, nil, nil, nil,
- nil, nil, 15, nil, 82, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 17, 46, nil, 77, 77, nil, nil, nil, nil,
- nil, nil, 18, nil, 35, 82, 82, nil, nil, nil,
- 12, nil, 32, nil, nil, nil, 36, 62, nil, nil,
- nil, nil, nil, nil, 35, 77, 77, 58, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 18, 41, 41, 41, 41, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 51, nil, nil,
- nil, nil, nil, nil, 18, 18, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 17, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 17, 18, nil, nil, nil, nil, nil, nil, nil, nil,
- 35, nil, nil, nil, 17, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 18, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 17, nil,
- nil, 35, 35, nil, nil, nil, 17, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 17,
- nil, nil, 35, 35, 17 ]
-
-racc_goto_pointer = [
- nil, 60, 43, 64, nil, nil, nil, 15, 12, 13,
- 22, 18, -7, nil, -19, -57, -202, -16, -81, nil,
- nil, nil, nil, nil, nil, nil, nil, 37, 39, nil,
- nil, nil, -14, nil, nil, -22, -10, nil, 41, -5,
- -8, -20, -45, nil, nil, nil, -78, nil, -10, nil,
- nil, -24, -180, nil, nil, -10, -81, -76, -135, 17,
- nil, 0, -145, 8, nil, nil, nil, nil, -230, -281,
- -77, nil, nil, -258, -110, nil, nil, -179, nil, nil,
- nil, -201, -168, nil, -320, nil ]
-
-racc_goto_default = [
- nil, nil, nil, nil, 5, 6, 7, 8, nil, nil,
- 172, nil, nil, 71, nil, nil, 72, nil, nil, 180,
- 12, 13, 14, 15, 16, 17, 18, nil, nil, 19,
- 21, 22, nil, 79, 80, 179, 176, 24, nil, nil,
- nil, nil, nil, 93, 95, 96, 111, 26, nil, 99,
- 100, nil, 101, 102, 28, 30, 32, 33, 34, nil,
- 35, 36, nil, 40, 41, 42, 43, 44, nil, 305,
- 110, 109, 112, nil, nil, 171, 173, 174, 175, 177,
- 178, 182, nil, 269, 270, 189 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 0, 63, :_reduce_1,
- 2, 61, :_reduce_2,
- 2, 62, :_reduce_none,
- 2, 62, :_reduce_none,
- 2, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 0, 62, :_reduce_none,
- 3, 64, :_reduce_11,
- 4, 65, :_reduce_12,
- 3, 65, :_reduce_13,
- 2, 68, :_reduce_none,
- 1, 68, :_reduce_15,
- 1, 68, :_reduce_16,
- 4, 66, :_reduce_17,
- 3, 66, :_reduce_18,
- 3, 69, :_reduce_19,
- 1, 69, :_reduce_20,
- 1, 71, :_reduce_21,
- 3, 71, :_reduce_22,
- 0, 71, :_reduce_23,
- 3, 72, :_reduce_24,
- 2, 72, :_reduce_25,
- 1, 73, :_reduce_26,
- 1, 73, :_reduce_27,
- 0, 73, :_reduce_28,
- 1, 74, :_reduce_29,
- 5, 76, :_reduce_30,
- 8, 76, :_reduce_31,
- 1, 77, :_reduce_32,
- 0, 77, :_reduce_33,
- 3, 75, :_reduce_34,
- 0, 75, :_reduce_35,
- 1, 79, :_reduce_36,
- 2, 67, :_reduce_none,
- 2, 67, :_reduce_none,
- 2, 67, :_reduce_none,
- 2, 67, :_reduce_none,
- 1, 67, :_reduce_none,
- 1, 67, :_reduce_none,
- 1, 67, :_reduce_none,
- 1, 67, :_reduce_none,
- 1, 81, :_reduce_none,
- 1, 81, :_reduce_none,
- 1, 81, :_reduce_none,
- 1, 87, :_reduce_none,
- 1, 87, :_reduce_none,
- 3, 84, :_reduce_50,
- 3, 89, :_reduce_51,
- 3, 85, :_reduce_52,
- 2, 85, :_reduce_53,
- 3, 90, :_reduce_54,
- 1, 91, :_reduce_55,
- 3, 92, :_reduce_56,
- 1, 92, :_reduce_57,
- 1, 93, :_reduce_none,
- 1, 93, :_reduce_none,
- 1, 93, :_reduce_none,
- 3, 86, :_reduce_61,
- 2, 86, :_reduce_62,
- 3, 97, :_reduce_63,
- 1, 98, :_reduce_64,
- 1, 98, :_reduce_65,
- 1, 98, :_reduce_66,
- 1, 102, :_reduce_67,
- 1, 102, :_reduce_68,
- 1, 102, :_reduce_69,
- 3, 101, :_reduce_70,
- 1, 101, :_reduce_71,
- 2, 99, :_reduce_72,
- 1, 100, :_reduce_none,
- 1, 100, :_reduce_none,
- 3, 104, :_reduce_75,
- 3, 104, :_reduce_76,
- 3, 105, :_reduce_77,
- 3, 105, :_reduce_78,
- 3, 103, :_reduce_79,
- 4, 103, :_reduce_80,
- 3, 82, :_reduce_none,
- 2, 82, :_reduce_none,
- 3, 107, :_reduce_83,
- 2, 108, :_reduce_none,
- 1, 108, :_reduce_none,
- 3, 109, :_reduce_86,
- 2, 109, :_reduce_87,
- 2, 110, :_reduce_88,
- 0, 112, :_reduce_none,
- 3, 112, :_reduce_90,
- 1, 112, :_reduce_none,
- 1, 113, :_reduce_none,
- 1, 113, :_reduce_93,
- 3, 83, :_reduce_94,
- 2, 83, :_reduce_95,
- 2, 114, :_reduce_96,
- 3, 80, :_reduce_97,
- 2, 80, :_reduce_98,
- 1, 88, :_reduce_99,
- 2, 115, :_reduce_100,
- 2, 115, :_reduce_101,
- 3, 116, :_reduce_102,
- 1, 116, :_reduce_103,
- 3, 117, :_reduce_104,
- 1, 117, :_reduce_none,
- 1, 119, :_reduce_106,
- 1, 119, :_reduce_107,
- 1, 119, :_reduce_108,
- 1, 119, :_reduce_109,
- 2, 118, :_reduce_110,
- 1, 118, :_reduce_111,
- 1, 118, :_reduce_112,
- 3, 122, :_reduce_113,
- 1, 122, :_reduce_none,
- 1, 123, :_reduce_115,
- 3, 123, :_reduce_116,
- 2, 123, :_reduce_117,
- 3, 123, :_reduce_118,
- 1, 120, :_reduce_119,
- 1, 120, :_reduce_120,
- 2, 120, :_reduce_121,
- 3, 120, :_reduce_122,
- 3, 120, :_reduce_123,
- 1, 121, :_reduce_124,
- 1, 121, :_reduce_125,
- 1, 121, :_reduce_126,
- 1, 121, :_reduce_127,
- 2, 121, :_reduce_128,
- 2, 121, :_reduce_129,
- 2, 121, :_reduce_130,
- 2, 121, :_reduce_131,
- 1, 124, :_reduce_132,
- 2, 125, :_reduce_133,
- 5, 126, :_reduce_134,
- 5, 126, :_reduce_135,
- 5, 126, :_reduce_136,
- 5, 126, :_reduce_137,
- 5, 126, :_reduce_138,
- 5, 126, :_reduce_139,
- 5, 126, :_reduce_140,
- 5, 126, :_reduce_141,
- 5, 126, :_reduce_142,
- 5, 126, :_reduce_143,
- 5, 126, :_reduce_144,
- 5, 126, :_reduce_145,
- 3, 126, :_reduce_146,
- 2, 127, :_reduce_147,
- 3, 127, :_reduce_148,
- 3, 127, :_reduce_149,
- 4, 127, :_reduce_150,
- 4, 127, :_reduce_151,
- 2, 127, :_reduce_152,
- 4, 127, :_reduce_153,
- 6, 127, :_reduce_154,
- 7, 127, :_reduce_155,
- 0, 128, :_reduce_none,
- 1, 128, :_reduce_none,
- 1, 129, :_reduce_none,
- 3, 129, :_reduce_none,
- 1, 130, :_reduce_none,
- 2, 130, :_reduce_none,
- 3, 111, :_reduce_none,
- 2, 111, :_reduce_none,
- 2, 111, :_reduce_none,
- 1, 111, :_reduce_none,
- 1, 111, :_reduce_none,
- 1, 131, :_reduce_167,
- 4, 106, :_reduce_168,
- 5, 106, :_reduce_169,
- 5, 106, :_reduce_170,
- 6, 106, :_reduce_171,
- 1, 133, :_reduce_172,
- 0, 133, :_reduce_173,
- 1, 132, :_reduce_174,
- 2, 132, :_reduce_175,
- 1, 132, :_reduce_176,
- 1, 134, :_reduce_none,
- 1, 134, :_reduce_none,
- 1, 134, :_reduce_none,
- 3, 78, :_reduce_180,
- 2, 78, :_reduce_181,
- 1, 78, :_reduce_182,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 1, 135, :_reduce_none,
- 2, 95, :_reduce_194,
- 3, 95, :_reduce_195,
- 2, 95, :_reduce_196,
- 2, 94, :_reduce_197,
- 1, 94, :_reduce_198,
- 3, 141, :_reduce_none,
- 1, 141, :_reduce_none,
- 4, 140, :_reduce_201,
- 1, 142, :_reduce_none,
- 3, 142, :_reduce_203,
- 3, 142, :_reduce_204,
- 1, 143, :_reduce_none,
- 4, 143, :_reduce_206,
- 4, 143, :_reduce_207,
- 1, 144, :_reduce_208,
- 1, 144, :_reduce_209,
- 3, 144, :_reduce_210,
- 2, 139, :_reduce_211,
- 1, 139, :_reduce_212,
- 2, 96, :_reduce_213,
- 1, 96, :_reduce_214,
- 2, 138, :_reduce_215,
- 1, 138, :_reduce_216,
- 2, 137, :_reduce_217,
- 1, 137, :_reduce_218,
- 1, 137, :_reduce_219,
- 1, 137, :_reduce_220,
- 1, 137, :_reduce_221,
- 1, 137, :_reduce_222,
- 1, 137, :_reduce_223,
- 1, 136, :_reduce_224,
- 1, 145, :_reduce_225,
- 1, 145, :_reduce_226,
- 2, 70, :_reduce_227,
- 1, 70, :_reduce_228 ]
-
-racc_reduce_n = 229
-
-racc_shift_n = 360
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :CHARSET_SYM => 2,
- :IMPORT_SYM => 3,
- :STRING => 4,
- :SEMI => 5,
- :IDENT => 6,
- :S => 7,
- :COMMA => 8,
- :LBRACE => 9,
- :RBRACE => 10,
- :STAR => 11,
- :HASH => 12,
- :LSQUARE => 13,
- :RSQUARE => 14,
- :EQUAL => 15,
- :INCLUDES => 16,
- :DASHMATCH => 17,
- :LPAREN => 18,
- :RPAREN => 19,
- :FUNCTION => 20,
- :GREATER => 21,
- :PLUS => 22,
- :SLASH => 23,
- :NUMBER => 24,
- :MINUS => 25,
- :LENGTH => 26,
- :PERCENTAGE => 27,
- :ANGLE => 28,
- :TIME => 29,
- :FREQ => 30,
- :URI => 31,
- :IMPORTANT_SYM => 32,
- :MEDIA_SYM => 33,
- :NOT => 34,
- :ONLY => 35,
- :AND => 36,
- :NTH_PSEUDO_CLASS => 37,
- :DOCUMENT_QUERY_SYM => 38,
- :FUNCTION_NO_QUOTE => 39,
- :TILDE => 40,
- :PREFIXMATCH => 41,
- :SUFFIXMATCH => 42,
- :SUBSTRINGMATCH => 43,
- :NOT_PSEUDO_CLASS => 44,
- :KEYFRAMES_SYM => 45,
- :MATCHES_PSEUDO_CLASS => 46,
- :NAMESPACE_SYM => 47,
- :MOZ_PSEUDO_ELEMENT => 48,
- :RESOLUTION => 49,
- :COLON => 50,
- :SUPPORTS_SYM => 51,
- :OR => 52,
- :VARIABLE_NAME => 53,
- :CALC_SYM => 54,
- :FONTFACE_SYM => 55,
- :UNICODE_RANGE => 56,
- :RATIO => 57,
- "|" => 58,
- "." => 59 }
-
-racc_nt_base = 60
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "CHARSET_SYM",
- "IMPORT_SYM",
- "STRING",
- "SEMI",
- "IDENT",
- "S",
- "COMMA",
- "LBRACE",
- "RBRACE",
- "STAR",
- "HASH",
- "LSQUARE",
- "RSQUARE",
- "EQUAL",
- "INCLUDES",
- "DASHMATCH",
- "LPAREN",
- "RPAREN",
- "FUNCTION",
- "GREATER",
- "PLUS",
- "SLASH",
- "NUMBER",
- "MINUS",
- "LENGTH",
- "PERCENTAGE",
- "ANGLE",
- "TIME",
- "FREQ",
- "URI",
- "IMPORTANT_SYM",
- "MEDIA_SYM",
- "NOT",
- "ONLY",
- "AND",
- "NTH_PSEUDO_CLASS",
- "DOCUMENT_QUERY_SYM",
- "FUNCTION_NO_QUOTE",
- "TILDE",
- "PREFIXMATCH",
- "SUFFIXMATCH",
- "SUBSTRINGMATCH",
- "NOT_PSEUDO_CLASS",
- "KEYFRAMES_SYM",
- "MATCHES_PSEUDO_CLASS",
- "NAMESPACE_SYM",
- "MOZ_PSEUDO_ELEMENT",
- "RESOLUTION",
- "COLON",
- "SUPPORTS_SYM",
- "OR",
- "VARIABLE_NAME",
- "CALC_SYM",
- "FONTFACE_SYM",
- "UNICODE_RANGE",
- "RATIO",
- "\"|\"",
- "\".\"",
- "$start",
- "document",
- "stylesheet",
- "@1",
- "charset",
- "import",
- "namespace",
- "body",
- "import_location",
- "medium",
- "ident",
- "media_query_list",
- "media_query",
- "optional_only_or_not",
- "media_type",
- "optional_and_exprs",
- "media_expr",
- "optional_space",
- "expr",
- "resolution",
- "ruleset",
- "conditional_rule",
- "keyframes_rule",
- "fontface_rule",
- "media",
- "document_query",
- "supports",
- "body_in_media",
- "empty_ruleset",
- "start_media",
- "start_document_query",
- "start_document_query_pos",
- "url_match_fns",
- "url_match_fn",
- "function_no_quote",
- "function",
- "uri",
- "start_supports",
- "supports_condition_root",
- "supports_negation",
- "supports_conjunction_or_disjunction",
- "supports_condition_in_parens",
- "supports_condition",
- "supports_declaration_condition",
- "supports_conjunction",
- "supports_disjunction",
- "declaration_internal",
- "start_keyframes_rule",
- "keyframes_blocks",
- "keyframes_block",
- "start_keyframes_block",
- "declarations",
- "keyframes_selectors",
- "keyframes_selector",
- "start_fontface_rule",
- "start_selector",
- "selectors",
- "selector",
- "simple_selector",
- "combinator",
- "element_name",
- "hcap",
- "simple_selectors",
- "ident_with_namespace",
- "hash",
- "class",
- "attrib",
- "pseudo",
- "any_number_of_idents",
- "multiple_idents",
- "one_or_more_semis",
- "declaration",
- "property",
- "prio",
- "operator",
- "term",
- "ratio",
- "numeric",
- "string",
- "hexcolor",
- "calc",
- "uranges",
- "calc_sum",
- "calc_product",
- "calc_value",
- "unary_operator" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 26)
- def _reduce_1(val, _values, result)
- @handler.start_document
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 28)
- def _reduce_2(val, _values, result)
- @handler.end_document
- result
- end
-.,.,
-
-# reduce 3 omitted
-
-# reduce 4 omitted
-
-# reduce 5 omitted
-
-# reduce 6 omitted
-
-# reduce 7 omitted
-
-# reduce 8 omitted
-
-# reduce 9 omitted
-
-# reduce 10 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 41)
- def _reduce_11(val, _values, result)
- @handler.charset interpret_string(val[1]), {}
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 45)
- def _reduce_12(val, _values, result)
- @handler.import_style val[2], val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 48)
- def _reduce_13(val, _values, result)
- @handler.import_style [], val[1]
-
- result
- end
-.,.,
-
-# reduce 14 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 53)
- def _reduce_15(val, _values, result)
- result = Terms::String.new interpret_string val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 54)
- def _reduce_16(val, _values, result)
- result = Terms::URI.new interpret_uri val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 58)
- def _reduce_17(val, _values, result)
- @handler.namespace val[1], val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 61)
- def _reduce_18(val, _values, result)
- @handler.namespace nil, val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 66)
- def _reduce_19(val, _values, result)
- result = val[0] << MediaType.new(val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 69)
- def _reduce_20(val, _values, result)
- result = [MediaType.new(val[0])]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 73)
- def _reduce_21(val, _values, result)
- result = MediaQueryList.new([ val[0] ])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 74)
- def _reduce_22(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 75)
- def _reduce_23(val, _values, result)
- result = MediaQueryList.new
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 78)
- def _reduce_24(val, _values, result)
- result = MediaQuery.new(val[0], val[1], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 79)
- def _reduce_25(val, _values, result)
- result = MediaQuery.new(nil, val[0], val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 82)
- def _reduce_26(val, _values, result)
- result = :only
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 83)
- def _reduce_27(val, _values, result)
- result = :not
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 84)
- def _reduce_28(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 87)
- def _reduce_29(val, _values, result)
- result = MediaType.new(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 90)
- def _reduce_30(val, _values, result)
- result = MediaType.new(val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 91)
- def _reduce_31(val, _values, result)
- result = MediaFeature.new(val[2], val[6][0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 94)
- def _reduce_32(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 95)
- def _reduce_33(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 98)
- def _reduce_34(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 99)
- def _reduce_35(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 103)
- def _reduce_36(val, _values, result)
- unit = val.first.gsub(/[\s\d.]/, '')
- number = numeric(val.first)
- result = Terms::Resolution.new(number, unit)
-
- result
- end
-.,.,
-
-# reduce 37 omitted
-
-# reduce 38 omitted
-
-# reduce 39 omitted
-
-# reduce 40 omitted
-
-# reduce 41 omitted
-
-# reduce 42 omitted
-
-# reduce 43 omitted
-
-# reduce 44 omitted
-
-# reduce 45 omitted
-
-# reduce 46 omitted
-
-# reduce 47 omitted
-
-# reduce 48 omitted
-
-# reduce 49 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 128)
- def _reduce_50(val, _values, result)
- @handler.end_media val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 132)
- def _reduce_51(val, _values, result)
- result = val[1]
- @handler.start_media result
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 137)
- def _reduce_52(val, _values, result)
- @handler.end_document_query(before_pos(val), after_pos(val))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 138)
- def _reduce_53(val, _values, result)
- @handler.end_document_query(before_pos(val), after_pos(val))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 142)
- def _reduce_54(val, _values, result)
- @handler.start_document_query(val[1], after_pos(val))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 147)
- def _reduce_55(val, _values, result)
- @handler.node_start_pos = before_pos(val)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 152)
- def _reduce_56(val, _values, result)
- result = [val[0], val[2]].flatten
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 155)
- def _reduce_57(val, _values, result)
- result = val
-
- result
- end
-.,.,
-
-# reduce 58 omitted
-
-# reduce 59 omitted
-
-# reduce 60 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 164)
- def _reduce_61(val, _values, result)
- @handler.end_supports
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 165)
- def _reduce_62(val, _values, result)
- @handler.end_supports
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 169)
- def _reduce_63(val, _values, result)
- @handler.start_supports val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 173)
- def _reduce_64(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 174)
- def _reduce_65(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 175)
- def _reduce_66(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 178)
- def _reduce_67(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 179)
- def _reduce_68(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 180)
- def _reduce_69(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 183)
- def _reduce_70(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 184)
- def _reduce_71(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 187)
- def _reduce_72(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-# reduce 73 omitted
-
-# reduce 74 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 194)
- def _reduce_75(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 195)
- def _reduce_76(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 198)
- def _reduce_77(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 199)
- def _reduce_78(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 202)
- def _reduce_79(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 203)
- def _reduce_80(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-# reduce 81 omitted
-
-# reduce 82 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 211)
- def _reduce_83(val, _values, result)
- @handler.start_keyframes_rule val[1]
-
- result
- end
-.,.,
-
-# reduce 84 omitted
-
-# reduce 85 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 219)
- def _reduce_86(val, _values, result)
- @handler.end_keyframes_block
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 220)
- def _reduce_87(val, _values, result)
- @handler.end_keyframes_block
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 224)
- def _reduce_88(val, _values, result)
- @handler.start_keyframes_block val[0]
-
- result
- end
-.,.,
-
-# reduce 89 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 229)
- def _reduce_90(val, _values, result)
- result = val[0] + ', ' + val[2]
-
- result
- end
-.,.,
-
-# reduce 91 omitted
-
-# reduce 92 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 235)
- def _reduce_93(val, _values, result)
- result = val[0].strip
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 238)
- def _reduce_94(val, _values, result)
- @handler.end_fontface_rule
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 239)
- def _reduce_95(val, _values, result)
- @handler.end_fontface_rule
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 243)
- def _reduce_96(val, _values, result)
- @handler.start_fontface_rule
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 248)
- def _reduce_97(val, _values, result)
- @handler.end_selector val.first
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 251)
- def _reduce_98(val, _values, result)
- @handler.end_selector val.first
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 256)
- def _reduce_99(val, _values, result)
- start = @handler.start_selector([])
- @handler.end_selector(start)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 261)
- def _reduce_100(val, _values, result)
- result = val.last
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 263)
- def _reduce_101(val, _values, result)
- @handler.start_selector val.first
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 269)
- def _reduce_102(val, _values, result)
- sel = Selector.new(val.first, {})
- result = [sel].concat(val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 274)
- def _reduce_103(val, _values, result)
- result = [Selector.new(val.first, {})]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 280)
- def _reduce_104(val, _values, result)
- val.flatten!
- val[2].combinator = val.delete_at 1
- result = val
-
- result
- end
-.,.,
-
-# reduce 105 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 287)
- def _reduce_106(val, _values, result)
- result = :s
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 288)
- def _reduce_107(val, _values, result)
- result = :>
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 289)
- def _reduce_108(val, _values, result)
- result = :+
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 290)
- def _reduce_109(val, _values, result)
- result = :~
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 294)
- def _reduce_110(val, _values, result)
- selector = val.first
- selector.additional_selectors = val.last
- result = [selector]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 298)
- def _reduce_111(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 301)
- def _reduce_112(val, _values, result)
- ss = Selectors::Simple.new nil, nil
- ss.additional_selectors = val.flatten
- result = [ss]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 307)
- def _reduce_113(val, _values, result)
- result = [val[0], val[2]].flatten
- result
- end
-.,.,
-
-# reduce 114 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 311)
- def _reduce_115(val, _values, result)
- result = [interpret_identifier(val[0]), nil]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 312)
- def _reduce_116(val, _values, result)
- result = [interpret_identifier(val[2]), interpret_identifier(val[0])]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 313)
- def _reduce_117(val, _values, result)
- result = [interpret_identifier(val[1]), nil]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 314)
- def _reduce_118(val, _values, result)
- result = [interpret_identifier(val[2]), '*']
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 317)
- def _reduce_119(val, _values, result)
- result = Selectors::Type.new val.first[0], nil, val.first[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 318)
- def _reduce_120(val, _values, result)
- result = Selectors::Universal.new val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 319)
- def _reduce_121(val, _values, result)
- result = Selectors::Universal.new val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 320)
- def _reduce_122(val, _values, result)
- result = Selectors::Universal.new val[2], nil, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 321)
- def _reduce_123(val, _values, result)
- result = Selectors::Universal.new val[2], nil, interpret_identifier(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 324)
- def _reduce_124(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 325)
- def _reduce_125(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 326)
- def _reduce_126(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 327)
- def _reduce_127(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 328)
- def _reduce_128(val, _values, result)
- result = val.flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 329)
- def _reduce_129(val, _values, result)
- result = val.flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 330)
- def _reduce_130(val, _values, result)
- result = val.flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 331)
- def _reduce_131(val, _values, result)
- result = val.flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 335)
- def _reduce_132(val, _values, result)
- result = Selectors::Id.new interpret_identifier val.first.sub(/^#/, '')
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 339)
- def _reduce_133(val, _values, result)
- result = Selectors::Class.new interpret_identifier val.last
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 344)
- def _reduce_134(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::EQUALS,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 352)
- def _reduce_135(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::EQUALS,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 360)
- def _reduce_136(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::INCLUDES,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 368)
- def _reduce_137(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::INCLUDES,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 376)
- def _reduce_138(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::DASHMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 384)
- def _reduce_139(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::DASHMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 392)
- def _reduce_140(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::PREFIXMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 400)
- def _reduce_141(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::PREFIXMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 408)
- def _reduce_142(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::SUFFIXMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 416)
- def _reduce_143(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::SUFFIXMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 424)
- def _reduce_144(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_identifier(val[3]),
- Selectors::Attribute::SUBSTRINGMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 432)
- def _reduce_145(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- interpret_string(val[3]),
- Selectors::Attribute::SUBSTRINGMATCH,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 440)
- def _reduce_146(val, _values, result)
- result = Selectors::Attribute.new(
- val[1][0],
- nil,
- Selectors::Attribute::SET,
- val[1][1]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 450)
- def _reduce_147(val, _values, result)
- result = Selectors::pseudo interpret_identifier(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 453)
- def _reduce_148(val, _values, result)
- result = Selectors::PseudoElement.new(
- interpret_identifier(val[2])
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 458)
- def _reduce_149(val, _values, result)
- result = Selectors::PseudoClass.new(
- interpret_identifier(val[1].sub(/\($/, '')),
- ''
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 464)
- def _reduce_150(val, _values, result)
- result = Selectors::PseudoClass.new(
- interpret_identifier(val[1].sub(/\($/, '')),
- interpret_identifier(val[2])
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 470)
- def _reduce_151(val, _values, result)
- result = Selectors::PseudoClass.new(
- 'not',
- val[2].first.to_s
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 476)
- def _reduce_152(val, _values, result)
- result = Selectors::PseudoClass.new(
- interpret_identifier(val[1].sub(/\(.*/, '')),
- interpret_identifier(val[1].sub(/.*\(/, '').sub(/\).*/, ''))
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 482)
- def _reduce_153(val, _values, result)
- result = Selectors::PseudoClass.new(
- val[1].split('(').first.strip,
- val[2].join(', ')
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 488)
- def _reduce_154(val, _values, result)
- result = Selectors::PseudoElement.new(
- interpret_identifier(val[1].sub(/\($/, ''))
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 493)
- def _reduce_155(val, _values, result)
- result = Selectors::PseudoElement.new(
- interpret_identifier(val[2].sub(/\($/, ''))
- )
-
- result
- end
-.,.,
-
-# reduce 156 omitted
-
-# reduce 157 omitted
-
-# reduce 158 omitted
-
-# reduce 159 omitted
-
-# reduce 160 omitted
-
-# reduce 161 omitted
-
-# reduce 162 omitted
-
-# reduce 163 omitted
-
-# reduce 164 omitted
-
-# reduce 165 omitted
-
-# reduce 166 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 519)
- def _reduce_167(val, _values, result)
- @handler.property val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 523)
- def _reduce_168(val, _values, result)
- result = Declaration.new(val.first, val[2], val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 525)
- def _reduce_169(val, _values, result)
- result = Declaration.new(val.first, val[3], val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 527)
- def _reduce_170(val, _values, result)
- result = Declaration.new(val.first, val[3], val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 529)
- def _reduce_171(val, _values, result)
- result = Declaration.new(val.first, val[4], val[5])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 532)
- def _reduce_172(val, _values, result)
- result = true
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 533)
- def _reduce_173(val, _values, result)
- result = false
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 536)
- def _reduce_174(val, _values, result)
- result = interpret_identifier val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 537)
- def _reduce_175(val, _values, result)
- result = interpret_identifier val.join
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 538)
- def _reduce_176(val, _values, result)
- result = interpret_identifier val[0]
- result
- end
-.,.,
-
-# reduce 177 omitted
-
-# reduce 178 omitted
-
-# reduce 179 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 547)
- def _reduce_180(val, _values, result)
- result = [val.first, val.last].flatten
- val.last.first.operator = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 550)
- def _reduce_181(val, _values, result)
- result = val.flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 551)
- def _reduce_182(val, _values, result)
- result = val
- result
- end
-.,.,
-
-# reduce 183 omitted
-
-# reduce 184 omitted
-
-# reduce 185 omitted
-
-# reduce 186 omitted
-
-# reduce 187 omitted
-
-# reduce 188 omitted
-
-# reduce 189 omitted
-
-# reduce 190 omitted
-
-# reduce 191 omitted
-
-# reduce 192 omitted
-
-# reduce 193 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 567)
- def _reduce_194(val, _values, result)
- result = val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 569)
- def _reduce_195(val, _values, result)
- name = interpret_identifier val.first.sub(/\($/, '')
- if name == 'rgb'
- result = Terms::Rgb.new(*val[1])
- else
- result = Terms::Function.new name, val[1]
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 577)
- def _reduce_196(val, _values, result)
- name = interpret_identifier val.first.sub(/\($/, '')
- result = Terms::Function.new name
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 582)
- def _reduce_197(val, _values, result)
- result = val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 584)
- def _reduce_198(val, _values, result)
- parts = val.first.split('(')
- name = interpret_identifier parts.first
- result = Terms::Function.new(name, [Terms::String.new(interpret_string_no_quote(parts.last))])
-
- result
- end
-.,.,
-
-# reduce 199 omitted
-
-# reduce 200 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 595)
- def _reduce_201(val, _values, result)
- result = Terms::Math.new(val.first.split('(').first, val[1])
-
- result
- end
-.,.,
-
-# reduce 202 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 601)
- def _reduce_203(val, _values, result)
- val.insert(1, ' '); result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 602)
- def _reduce_204(val, _values, result)
- val.insert(1, ' '); result = val.join('')
- result
- end
-.,.,
-
-# reduce 205 omitted
-
-module_eval(<<'.,.,', 'csspool.y', 606)
- def _reduce_206(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 607)
- def _reduce_207(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 610)
- def _reduce_208(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 611)
- def _reduce_209(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 612)
- def _reduce_210(val, _values, result)
- result = val.join('')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 615)
- def _reduce_211(val, _values, result)
- result = val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 616)
- def _reduce_212(val, _values, result)
- result = Terms::Hash.new val.first.sub(/^#/, '')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 619)
- def _reduce_213(val, _values, result)
- result = val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 620)
- def _reduce_214(val, _values, result)
- result = Terms::URI.new interpret_uri val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 623)
- def _reduce_215(val, _values, result)
- result = val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 624)
- def _reduce_216(val, _values, result)
- result = Terms::String.new interpret_string val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 628)
- def _reduce_217(val, _values, result)
- result = val[1]
- val[1].unary_operator = val.first
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 632)
- def _reduce_218(val, _values, result)
- result = Terms::Number.new numeric val.first
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 635)
- def _reduce_219(val, _values, result)
- result = Terms::Number.new numeric(val.first), nil, '%'
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 638)
- def _reduce_220(val, _values, result)
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 642)
- def _reduce_221(val, _values, result)
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 646)
- def _reduce_222(val, _values, result)
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 650)
- def _reduce_223(val, _values, result)
- unit = val.first.gsub(/[\s\d.]/, '')
- result = Terms::Number.new numeric(val.first), nil, unit
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 656)
- def _reduce_224(val, _values, result)
- result = Terms::Ratio.new(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 660)
- def _reduce_225(val, _values, result)
- result = :minus
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 661)
- def _reduce_226(val, _values, result)
- result = :plus
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 664)
- def _reduce_227(val, _values, result)
- result = val.first
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'csspool.y', 665)
- def _reduce_228(val, _values, result)
- result = Terms::Ident.new interpret_identifier val.first
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
- end # module CSS
-end # module CSSPool
diff --git a/test/racc/regress/edtf b/test/racc/regress/edtf
deleted file mode 100644
index 82a59a6454..0000000000
--- a/test/racc/regress/edtf
+++ /dev/null
@@ -1,1794 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-require 'strscan'
-
-module EDTF
- class Parser < Racc::Parser
-
-module_eval(<<'...end edtf.y/module_eval...', 'edtf.y', 468)
-
- @defaults = {
- :level => 2,
- :debug => false
- }.freeze
-
- class << self; attr_reader :defaults; end
-
- attr_reader :options
-
- def initialize(options = {})
- @options = Parser.defaults.merge(options)
- end
-
- def debug?
- !!(options[:debug] || ENV['DEBUG'])
- end
-
- def parse(input)
- parse!(input)
- rescue => e
- warn e.message if debug?
- nil
- end
-
- def parse!(input)
- @yydebug = debug?
- @src = StringScanner.new(input)
- do_parse
- end
-
- def on_error(tid, value, stack)
- raise ArgumentError,
- "failed to parse date: unexpected '#{value}' at #{stack.inspect}"
- end
-
- def apply_uncertainty(date, uncertainty, scope = nil)
- uncertainty.each do |u|
- scope.nil? ? date.send(u) : date.send(u, scope)
- end
- date
- end
-
- alias uoa apply_uncertainty
-
- def next_token
- case
- when @src.eos?
- nil
- # when @src.scan(/\s+/)
- # ignore whitespace
- when @src.scan(/\(/)
- ['(', @src.matched]
- # when @src.scan(/\)\?~-/)
- # [:PUA, [:uncertain!, :approximate!]]
- # when @src.scan(/\)\?-/)
- # [:PUA, [:uncertain!]]
- # when @src.scan(/\)~-/)
- # [:PUA, [:approximate!]]
- when @src.scan(/\)/)
- [')', @src.matched]
- when @src.scan(/\[/)
- ['[', @src.matched]
- when @src.scan(/\]/)
- [']', @src.matched]
- when @src.scan(/\{/)
- ['{', @src.matched]
- when @src.scan(/\}/)
- ['}', @src.matched]
- when @src.scan(/T/)
- [:T, @src.matched]
- when @src.scan(/Z/)
- [:Z, @src.matched]
- when @src.scan(/\?~/)
- [:UA, [:uncertain!, :approximate!]]
- when @src.scan(/\?/)
- [:UA, [:uncertain!]]
- when @src.scan(/~/)
- [:UA, [:approximate!]]
- when @src.scan(/open/i)
- [:OPEN, :open]
- when @src.scan(/unkn?own/i) # matches 'unkown' typo too
- [:UNKNOWN, :unknown]
- when @src.scan(/u/)
- [:U, @src.matched]
- when @src.scan(/x/i)
- [:X, @src.matched]
- when @src.scan(/y/)
- [:LONGYEAR, @src.matched]
- when @src.scan(/e/)
- [:E, @src.matched]
- when @src.scan(/\+/)
- ['+', @src.matched]
- when @src.scan(/-\(/)
- ['-(', @src.matched]
- when @src.scan(/-/)
- ['-', @src.matched]
- when @src.scan(/:/)
- [':', @src.matched]
- when @src.scan(/\//)
- ['/', @src.matched]
- when @src.scan(/\s*\.\.\s*/)
- [:DOTS, '..']
- when @src.scan(/\s*,\s*/)
- [',', ',']
- when @src.scan(/\^\w+/)
- ['^', @src.matched[1..-1]]
- when @src.scan(/\d/)
- [@src.matched, @src.matched.to_i]
- else @src.scan(/./)
- [:UNMATCHED, @src.rest]
- end
- end
-
-
-# -*- racc -*-
-...end edtf.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 208, 207, 52, 111, 236, 112, 149, 129, 128, 57,
- 253, 43, 45, 40, 55, 42, 157, 44, 43, 45,
- 40, -48, 42, 53, 44, 254, 58, 46, 47, 48,
- 49, 50, 207, 56, 46, 47, 48, 49, 50, 128,
- 94, 255, 43, 45, 40, 244, 42, 239, 44, 43,
- 45, 40, 55, 42, 54, 44, 202, 95, 46, 47,
- 48, 49, 50, 25, 141, 46, 47, 48, 49, 50,
- 12, 56, 43, 45, 40, 55, 42, 214, 44, 148,
- 55, 233, 147, 258, 92, 36, 193, 192, 46, 47,
- 48, 49, 50, 25, 56, 26, 57, 232, 234, 56,
- 12, 93, 43, 45, 40, 261, 42, 159, 44, 111,
- 33, 112, 34, 58, 111, 36, 112, 180, 46, 47,
- 48, 49, 50, 87, 58, 108, 12, 165, 43, 45,
- 40, 101, 42, 103, 44, 104, 178, 111, 166, 112,
- 111, 36, 112, 167, 46, 47, 48, 49, 50, 87,
- 218, 200, 12, 201, 43, 45, 40, 188, 42, 186,
- 44, 187, 111, 190, 112, 177, 111, 36, 112, 168,
- 46, 47, 48, 49, 50, 69, 264, 43, 45, 189,
- 191, 42, 124, 44, 12, 125, 43, 45, 40, 240,
- 42, 239, 44, 46, 47, 48, 49, 50, 265, 36,
- 133, 192, 46, 47, 48, 49, 50, 12, 266, 43,
- 45, 40, 111, 42, 112, 44, 12, 158, 43, 45,
- 40, 269, 42, 270, 44, 46, 47, 48, 49, 50,
- 156, 36, 154, 153, 46, 47, 48, 49, 50, 12,
- 275, 43, 45, 40, 152, 42, 150, 44, 146, 43,
- 45, 40, 125, 42, 36, 44, 280, 46, 47, 48,
- 49, 50, 124, 284, 285, 46, 47, 48, 49, 50,
- 43, 45, 40, 286, 42, 96, 44, 43, 45, 40,
- -66, 42, -65, 44, 290, 67, 46, 47, 48, 49,
- 50, 292, 293, 46, 47, 48, 49, 50, 43, 45,
- 40, 66, 42, 295, 44, 43, 45, 40, 296, 42,
- 297, 44, 65, 300, 46, 47, 48, 49, 50, 301,
- 180, 46, 47, 48, 49, 50, 43, 45, 40, 303,
- 42, 304, 44, 43, 45, 40, 305, 42, 281, 44,
- 306, 307, 46, 47, 48, 49, 50, 308, 64, 46,
- 47, 48, 49, 50, 43, 45, 40, -50, 42, 311,
- 44, 43, 45, 40, 312, 42, 313, 44, 314, 51,
- 46, 47, 48, 49, 50, 316, 317, 46, 47, 48,
- 49, 50, 43, 45, 318, 215, 42, 319, 44, 43,
- 45, 40, 213, 42, 212, 44, 229, 210, 46, 47,
- 48, 49, 50, 180, 209, 46, 47, 48, 49, 50,
- 43, 45, 180, nil, 42, nil, 44, 43, 45, 40,
- nil, 42, nil, 44, nil, nil, 46, 47, 48, 49,
- 50, nil, nil, 46, 47, 48, 49, 50, 43, 45,
- 40, nil, 42, nil, 44, 43, 45, 40, nil, 42,
- nil, 44, nil, nil, 46, 47, 48, 49, 50, nil,
- nil, 46, 47, 48, 49, 50, 43, 45, 40, nil,
- 42, nil, 44, 43, 45, 276, nil, 42, nil, 44,
- nil, nil, 46, 47, 48, 49, 50, nil, nil, 46,
- 47, 48, 49, 50, 43, 45, 274, nil, 42, nil,
- 44, 43, 45, 273, nil, 42, nil, 44, nil, nil,
- 46, 47, 48, 49, 50, nil, nil, 46, 47, 48,
- 49, 50, 43, 45, 40, nil, 42, nil, 44, 43,
- 45, 175, nil, 42, nil, 44, nil, nil, 46, 47,
- 48, 49, 50, nil, nil, 46, 47, 48, 49, 50,
- 43, 45, 40, nil, 42, nil, 44, 43, 45, 40,
- nil, 42, nil, 44, nil, nil, 46, 47, 48, 49,
- 50, nil, nil, 46, 47, 48, 49, 50, 43, 45,
- nil, nil, 42, nil, 44, 43, 45, nil, nil, 42,
- nil, 44, nil, nil, 46, 47, 48, 49, 50, nil,
- nil, 46, 47, 48, 49, 50, 43, 45, 315, nil,
- 42, nil, 44, 43, 45, 40, nil, 42, nil, 44,
- nil, nil, 46, 47, 48, 49, 50, nil, nil, 46,
- 47, 48, 49, 50, 43, 45, nil, nil, 42, nil,
- 44, 172, 194, 170, nil, 171, nil, 173, nil, nil,
- 46, 47, 48, 49, 50, nil, nil, 195, 196, 197,
- 198, 199, 43, 45, 40, nil, 42, nil, 44, 43,
- 45, 40, nil, 42, nil, 44, nil, nil, 46, 47,
- 48, 49, 50, nil, nil, 46, 47, 48, 49, 50,
- 43, 45, 40, nil, 42, nil, 44, 43, 45, 40,
- nil, 42, nil, 44, nil, nil, 46, 47, 48, 49,
- 50, nil, nil, 46, 47, 48, 49, 50, 43, 45,
- nil, nil, 42, nil, 44, 43, 45, 40, nil, 42,
- nil, 44, nil, nil, 46, 47, 48, 49, 50, 116,
- nil, 46, 47, 48, 49, 50, 118, 250, 247, 118,
- 104, 117, 249, 104, 260, 121, nil, 288, nil, 118,
- 250, 247, 251, 104, 118, 249, 117, 118, 104, 117,
- 121, 104, nil, 121, nil, 251, 118, 250, 247, nil,
- 104, 281, 249, 118, 250, 310, nil, 104, nil, 249,
- nil, 118, 251, 117, nil, 104, nil, 121, 108, 251,
- 118, 250, 117, 118, 104, 117, 249, 104, 110, 121,
- 111, nil, 112, 182, 184, nil, 251, 181, 118, 183,
- 117, 118, 104, 117, 121, 104, 118, 121, 117, 118,
- 104, 117, 121, 104, 118, 121, 117, nil, 104, nil,
- 121, 188, 271, 186, 118, 187, 117, 272, 104, 118,
- 121, 117, nil, 104, nil, 121, 172, 169, 170, 118,
- 171, 117, 173, 104, 118, 121, 117, nil, 104, nil,
- 121 ]
-
-racc_action_check = [
- 127, 127, 5, 93, 163, 93, 73, 63, 63, 73,
- 169, 127, 127, 127, 89, 127, 89, 127, 63, 63,
- 63, 5, 63, 5, 63, 178, 73, 127, 127, 127,
- 127, 127, 224, 89, 63, 63, 63, 63, 63, 151,
- 38, 189, 224, 224, 224, 167, 224, 167, 224, 151,
- 151, 151, 9, 151, 9, 151, 123, 38, 224, 224,
- 224, 224, 224, 67, 67, 151, 151, 151, 151, 151,
- 67, 9, 67, 67, 67, 134, 67, 134, 67, 72,
- 72, 161, 72, 202, 37, 67, 116, 115, 67, 67,
- 67, 67, 67, 0, 134, 0, 10, 161, 161, 72,
- 0, 37, 0, 0, 0, 213, 0, 91, 0, 124,
- 0, 124, 0, 10, 56, 0, 56, 109, 0, 0,
- 0, 0, 0, 33, 91, 214, 33, 98, 33, 33,
- 33, 52, 33, 52, 33, 52, 108, 214, 98, 214,
- 92, 33, 92, 98, 33, 33, 33, 33, 33, 34,
- 147, 121, 34, 121, 34, 34, 34, 112, 34, 112,
- 34, 112, 147, 113, 147, 107, 157, 34, 157, 99,
- 34, 34, 34, 34, 34, 26, 218, 26, 26, 113,
- 113, 26, 220, 26, 154, 222, 154, 154, 154, 166,
- 154, 166, 154, 26, 26, 26, 26, 26, 225, 154,
- 66, 230, 154, 154, 154, 154, 154, 87, 232, 87,
- 87, 87, 66, 87, 66, 87, 265, 90, 265, 265,
- 265, 236, 265, 238, 265, 87, 87, 87, 87, 87,
- 88, 265, 79, 78, 265, 265, 265, 265, 265, 153,
- 245, 153, 153, 153, 77, 153, 74, 153, 71, 205,
- 205, 205, 60, 205, 153, 205, 253, 153, 153, 153,
- 153, 153, 59, 256, 257, 205, 205, 205, 205, 205,
- 150, 150, 150, 260, 150, 51, 150, 12, 12, 12,
- 24, 12, 23, 12, 264, 22, 150, 150, 150, 150,
- 150, 267, 268, 12, 12, 12, 12, 12, 13, 13,
- 13, 18, 13, 271, 13, 263, 263, 263, 273, 263,
- 274, 263, 17, 280, 13, 13, 13, 13, 13, 281,
- 283, 263, 263, 263, 263, 263, 262, 262, 262, 284,
- 262, 285, 262, 36, 36, 36, 288, 36, 290, 36,
- 292, 293, 262, 262, 262, 262, 262, 295, 16, 36,
- 36, 36, 36, 36, 251, 251, 251, 14, 251, 300,
- 251, 62, 62, 62, 304, 62, 307, 62, 308, 1,
- 251, 251, 251, 251, 251, 311, 312, 62, 62, 62,
- 62, 62, 64, 64, 313, 144, 64, 316, 64, 68,
- 68, 68, 133, 68, 132, 68, 158, 129, 64, 64,
- 64, 64, 64, 160, 128, 68, 68, 68, 68, 68,
- 69, 69, 162, nil, 69, nil, 69, 70, 70, 70,
- nil, 70, nil, 70, nil, nil, 69, 69, 69, 69,
- 69, nil, nil, 70, 70, 70, 70, 70, 250, 250,
- 250, nil, 250, nil, 250, 249, 249, 249, nil, 249,
- nil, 249, nil, nil, 250, 250, 250, 250, 250, nil,
- nil, 249, 249, 249, 249, 249, 75, 75, 75, nil,
- 75, nil, 75, 247, 247, 247, nil, 247, nil, 247,
- nil, nil, 75, 75, 75, 75, 75, nil, nil, 247,
- 247, 247, 247, 247, 244, 244, 244, nil, 244, nil,
- 244, 240, 240, 240, nil, 240, nil, 240, nil, nil,
- 244, 244, 244, 244, 244, nil, nil, 240, 240, 240,
- 240, 240, 217, 217, 217, nil, 217, nil, 217, 103,
- 103, 103, nil, 103, nil, 103, nil, nil, 217, 217,
- 217, 217, 217, nil, nil, 103, 103, 103, 103, 103,
- 104, 104, 104, nil, 104, nil, 104, 216, 216, 216,
- nil, 216, nil, 216, nil, nil, 104, 104, 104, 104,
- 104, nil, nil, 216, 216, 216, 216, 216, 215, 215,
- nil, nil, 215, nil, 215, 111, 111, nil, nil, 111,
- nil, 111, nil, nil, 215, 215, 215, 215, 215, nil,
- nil, 111, 111, 111, 111, 111, 310, 310, 310, nil,
- 310, nil, 310, 149, 149, 149, nil, 149, nil, 149,
- nil, nil, 310, 310, 310, 310, 310, nil, nil, 149,
- 149, 149, 149, 149, 117, 117, nil, nil, 117, nil,
- 117, 118, 118, 118, nil, 118, nil, 118, nil, nil,
- 117, 117, 117, 117, 117, nil, nil, 118, 118, 118,
- 118, 118, 126, 126, 126, nil, 126, nil, 126, 130,
- 130, 130, nil, 130, nil, 130, nil, nil, 126, 126,
- 126, 126, 126, nil, nil, 130, 130, 130, 130, 130,
- 143, 143, 143, nil, 143, nil, 143, 145, 145, 145,
- nil, 145, nil, 145, nil, nil, 143, 143, 143, 143,
- 143, nil, nil, 145, 145, 145, 145, 145, 146, 146,
- nil, nil, 146, nil, 146, 148, 148, 148, nil, 148,
- nil, 148, nil, nil, 146, 146, 146, 146, 146, 57,
- nil, 148, 148, 148, 148, 148, 168, 168, 168, 57,
- 168, 57, 168, 57, 212, 57, nil, 261, nil, 275,
- 275, 275, 168, 275, 212, 275, 212, 261, 212, 261,
- 212, 261, nil, 261, nil, 275, 270, 270, 270, nil,
- 270, 254, 270, 297, 297, 297, nil, 297, nil, 297,
- nil, 254, 270, 254, nil, 254, nil, 254, 54, 297,
- 296, 296, 296, 95, 296, 95, 296, 95, 54, 95,
- 54, nil, 54, 110, 110, nil, 296, 110, 94, 110,
- 94, 58, 94, 58, 94, 58, 191, 58, 191, 190,
- 191, 190, 191, 190, 255, 190, 255, nil, 255, nil,
- 255, 239, 239, 239, 125, 239, 125, 239, 125, 234,
- 125, 234, nil, 234, nil, 234, 101, 101, 101, 233,
- 101, 233, 101, 233, 159, 233, 159, nil, 159, nil,
- 159 ]
-
-racc_action_pointer = [
- 86, 369, nil, nil, nil, 0, nil, nil, nil, 40,
- 82, nil, 261, 282, 336, nil, 344, 289, 287, nil,
- nil, nil, 264, 282, 280, nil, 161, nil, nil, nil,
- nil, nil, nil, 112, 138, nil, 317, 70, 26, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 275, 115, nil, 792, nil, 96, 733, 805, 248,
- 238, nil, 345, 2, 366, nil, 194, 56, 373, 394,
- 401, 244, 68, -5, 235, 450, nil, 219, 205, 204,
- nil, nil, nil, nil, nil, nil, nil, 193, 203, 2,
- 187, 93, 122, -15, 802, 787, nil, nil, 124, 154,
- nil, 840, nil, 513, 534, nil, nil, 153, 130, 105,
- 797, 569, 141, 149, nil, 75, 80, 618, 625, nil,
- nil, 133, nil, 26, 91, 828, 646, -5, 398, 392,
- 653, nil, 380, 386, 63, nil, nil, nil, nil, nil,
- nil, nil, nil, 674, 381, 681, 702, 144, 709, 597,
- 254, 33, nil, 225, 170, nil, nil, 148, 384, 848,
- 391, 67, 400, -26, nil, nil, 171, 27, 730, -5,
- nil, nil, nil, nil, nil, nil, nil, nil, 11, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 29,
- 813, 810, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 71, nil, nil, 233, nil, nil, nil, nil,
- nil, nil, 748, 91, 119, 562, 541, 506, 170, nil,
- 168, nil, 171, nil, 26, 170, nil, nil, nil, nil,
- 189, nil, 196, 843, 833, nil, 209, nil, 208, 825,
- 485, nil, nil, nil, 478, 225, nil, 457, nil, 429,
- 422, 338, nil, 238, 775, 818, 233, 234, nil, nil,
- 267, 751, 310, 289, 270, 202, nil, 261, 262, nil,
- 760, 288, nil, 293, 295, 743, nil, nil, nil, nil,
- 295, 313, nil, 308, 317, 319, nil, nil, 330, nil,
- 332, nil, 328, 329, nil, 329, 784, 767, nil, nil,
- 344, nil, nil, nil, 334, nil, nil, 336, 350, nil,
- 590, 357, 364, 372, nil, nil, 369, nil, nil, nil ]
-
-racc_action_default = [
- -176, -176, -1, -2, -3, -4, -5, -6, -7, -8,
- -9, -10, -176, -176, -34, -35, -36, -37, -38, -39,
- -40, -41, -176, -49, -51, -52, -176, -64, -67, -68,
- -69, -70, -71, -176, -176, -107, -176, -109, -110, -111,
- -128, -129, -130, -131, -132, -133, -134, -135, -136, -137,
- -138, -176, -176, -76, -176, -112, -176, -176, -176, -8,
- -9, -11, -176, -176, -176, -72, -176, -176, -55, -176,
- -170, -176, -8, -9, -10, -176, -38, -176, -81, -86,
- -87, -88, -90, -91, -92, -93, -94, -176, -176, -176,
- -176, -176, -176, -176, -176, -176, 320, -12, -13, -176,
- -16, -176, -31, -176, -176, -152, -27, -29, -176, -126,
- -176, -176, -176, -176, -28, -30, -176, -176, -176, -153,
- -160, -176, -162, -176, -176, -176, -176, -176, -176, -176,
- -73, -174, -176, -176, -8, -47, -48, -49, -50, -51,
- -53, -54, -58, -56, -176, -171, -176, -176, -98, -97,
- -96, -176, -79, -176, -176, -95, -80, -176, -176, -176,
- -126, -176, -126, -176, -14, -18, -176, -176, -176, -176,
- -147, -148, -149, -150, -145, -151, -146, -114, -44, -59,
- -127, -60, -61, -62, -63, -139, -140, -141, -142, -176,
- -176, -176, -120, -45, -154, -155, -156, -157, -158, -159,
- -161, -163, -176, -29, -30, -176, -26, -42, -77, -43,
- -78, -175, -176, -176, -176, -176, -172, -74, -176, -101,
- -176, -100, -176, -99, -176, -83, -84, -85, -89, -108,
- -176, -113, -176, -176, -176, -117, -176, -19, -176, -176,
- -176, -143, -20, -21, -176, -176, -32, -176, -164, -176,
- -176, -176, -169, -176, -176, -115, -176, -176, -121, -102,
- -176, -176, -75, -173, -44, -176, -116, -176, -176, -118,
- -176, -176, -144, -176, -176, -176, -168, -165, -166, -167,
- -176, -176, -106, -126, -176, -176, -105, -103, -176, -57,
- -176, -82, -176, -176, -23, -176, -176, -176, -15, -33,
- -176, -46, -119, -122, -176, -104, -124, -176, -176, -25,
- -176, -176, -176, -176, -24, -22, -176, -123, -125, -17 ]
-
-racc_goto_table = [
- 70, 179, 130, 13, 228, 11, 248, 115, 123, 226,
- 227, 113, 245, 5, 10, 23, 63, 11, 68, 9,
- 22, 132, 14, 18, 71, 2, 60, 24, 77, 88,
- 102, 59, 237, 243, 309, 309, 75, 75, 131, 241,
- 241, 15, 16, 70, 162, 163, 17, 160, 161, 242,
- 91, 100, 231, 135, 235, 89, 298, 99, 164, 98,
- 109, 143, 97, 27, 28, 126, 127, 144, 29, 30,
- 75, 142, 11, 145, 31, 204, 32, 174, 151, 203,
- 136, 10, 137, 61, 217, 185, 134, 140, 6, 138,
- 18, 174, 11, 1, 139, 225, 4, 3, 90, 105,
- 155, 60, 299, nil, nil, nil, 59, 176, 248, 230,
- nil, nil, nil, 248, 294, 228, nil, nil, nil, nil,
- 131, 291, nil, nil, nil, nil, nil, nil, nil, 205,
- 206, nil, nil, 211, 248, 248, nil, nil, nil, nil,
- 256, 257, nil, nil, nil, nil, 142, nil, 216, nil,
- nil, nil, nil, 262, 224, 223, 75, 75, nil, nil,
- nil, nil, 259, 221, 222, nil, nil, 219, 220, 220,
- nil, nil, nil, nil, nil, 302, nil, nil, nil, nil,
- nil, nil, nil, 267, 268, nil, nil, nil, nil, 131,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 282, 283, nil, nil, 206, nil,
- nil, 287, nil, nil, 185, nil, nil, nil, 185, 263,
- 211, 174, nil, nil, nil, nil, nil, 206, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 277, 278, 279, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 211, 289, nil, 75, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 174 ]
-
-racc_goto_check = [
- 43, 45, 52, 23, 58, 11, 66, 26, 26, 57,
- 57, 24, 16, 5, 10, 40, 23, 11, 42, 9,
- 38, 24, 30, 34, 53, 2, 10, 41, 54, 54,
- 28, 9, 19, 19, 22, 22, 23, 23, 43, 25,
- 25, 31, 32, 43, 26, 26, 33, 24, 24, 20,
- 10, 18, 45, 39, 45, 9, 17, 15, 14, 13,
- 44, 42, 12, 46, 47, 23, 23, 53, 48, 49,
- 23, 23, 11, 23, 50, 26, 51, 43, 23, 24,
- 5, 10, 40, 7, 52, 43, 9, 38, 6, 30,
- 34, 43, 11, 1, 41, 56, 4, 3, 61, 65,
- 5, 10, 29, nil, nil, nil, 9, 23, 66, 26,
- nil, nil, nil, 66, 16, 58, nil, nil, nil, nil,
- 43, 57, nil, nil, nil, nil, nil, nil, nil, 23,
- 23, nil, nil, 23, 66, 66, nil, nil, nil, nil,
- 26, 26, nil, nil, nil, nil, 23, nil, 23, nil,
- nil, nil, nil, 52, 23, 11, 23, 23, nil, nil,
- nil, nil, 26, 10, 10, nil, nil, 9, 9, 9,
- nil, nil, nil, nil, nil, 45, nil, nil, nil, nil,
- nil, nil, nil, 26, 26, nil, nil, nil, nil, 43,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 26, 26, nil, nil, 23, nil,
- nil, 26, nil, nil, 43, nil, nil, nil, 43, 23,
- 23, 43, nil, nil, nil, nil, nil, 23, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 23, 23, 23, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 23, 23, nil, 23, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 43 ]
-
-racc_goto_pointer = [
- nil, 93, 25, 97, 96, 13, 88, 71, nil, 19,
- 14, 5, 10, 7, -40, 5, -156, -219, -1, -134,
- -118, nil, -262, 3, -45, -127, -50, nil, -22, -173,
- 22, 41, 42, 46, 23, nil, nil, nil, 20, -14,
- 15, 27, -8, -26, 6, -108, 63, 64, 68, 69,
- 74, 76, -62, -2, -5, nil, -58, -144, -150, nil,
- nil, 62, nil, nil, nil, 47, -162, nil ]
-
-racc_goto_default = [
- nil, nil, nil, nil, nil, 84, nil, 7, 8, 72,
- 73, 74, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 238, 252, 62, 107, 106, nil, 114, nil, 246,
- 86, nil, nil, nil, 76, 19, 20, 21, nil, nil,
- 85, nil, nil, 41, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 78, 79, 80, 81, 82,
- 83, 35, 37, 38, 39, 119, 120, 122 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 38, :_reduce_none,
- 1, 38, :_reduce_none,
- 1, 38, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 42, :_reduce_none,
- 1, 42, :_reduce_none,
- 1, 44, :_reduce_8,
- 1, 44, :_reduce_9,
- 1, 44, :_reduce_10,
- 2, 45, :_reduce_11,
- 3, 43, :_reduce_12,
- 1, 49, :_reduce_none,
- 2, 49, :_reduce_14,
- 5, 50, :_reduce_15,
- 1, 50, :_reduce_none,
- 8, 55, :_reduce_17,
- 1, 51, :_reduce_18,
- 2, 51, :_reduce_19,
- 2, 51, :_reduce_20,
- 1, 57, :_reduce_none,
- 5, 57, :_reduce_22,
- 3, 56, :_reduce_23,
- 5, 56, :_reduce_24,
- 4, 56, :_reduce_25,
- 4, 46, :_reduce_26,
- 1, 61, :_reduce_none,
- 1, 63, :_reduce_none,
- 3, 47, :_reduce_29,
- 3, 48, :_reduce_30,
- 1, 52, :_reduce_none,
- 1, 53, :_reduce_none,
- 1, 54, :_reduce_none,
- 1, 40, :_reduce_none,
- 1, 40, :_reduce_none,
- 1, 40, :_reduce_none,
- 1, 40, :_reduce_none,
- 1, 67, :_reduce_38,
- 1, 67, :_reduce_none,
- 1, 67, :_reduce_none,
- 1, 67, :_reduce_none,
- 4, 71, :_reduce_42,
- 4, 71, :_reduce_43,
- 4, 72, :_reduce_44,
- 4, 73, :_reduce_45,
- 7, 74, :_reduce_46,
- 3, 68, :_reduce_47,
- 1, 75, :_reduce_none,
- 1, 75, :_reduce_none,
- 1, 75, :_reduce_none,
- 1, 75, :_reduce_none,
- 1, 75, :_reduce_none,
- 1, 76, :_reduce_none,
- 1, 76, :_reduce_none,
- 2, 69, :_reduce_55,
- 3, 69, :_reduce_56,
- 5, 79, :_reduce_57,
- 2, 79, :_reduce_58,
- 4, 70, :_reduce_59,
- 2, 81, :_reduce_60,
- 2, 81, :_reduce_61,
- 2, 81, :_reduce_62,
- 2, 81, :_reduce_63,
- 1, 41, :_reduce_none,
- 1, 41, :_reduce_none,
- 1, 41, :_reduce_none,
- 1, 41, :_reduce_none,
- 1, 41, :_reduce_none,
- 1, 41, :_reduce_none,
- 1, 41, :_reduce_none,
- 1, 41, :_reduce_none,
- 2, 83, :_reduce_72,
- 3, 88, :_reduce_73,
- 4, 88, :_reduce_74,
- 5, 88, :_reduce_75,
- 2, 87, :_reduce_76,
- 4, 86, :_reduce_77,
- 4, 86, :_reduce_78,
- 3, 84, :_reduce_79,
- 3, 85, :_reduce_80,
- 1, 91, :_reduce_81,
- 5, 91, :_reduce_82,
- 3, 91, :_reduce_83,
- 3, 91, :_reduce_84,
- 3, 91, :_reduce_85,
- 1, 91, :_reduce_86,
- 1, 91, :_reduce_87,
- 1, 93, :_reduce_88,
- 3, 93, :_reduce_89,
- 1, 95, :_reduce_none,
- 1, 95, :_reduce_none,
- 1, 96, :_reduce_none,
- 1, 96, :_reduce_none,
- 1, 96, :_reduce_none,
- 2, 92, :_reduce_95,
- 2, 94, :_reduce_96,
- 2, 94, :_reduce_97,
- 2, 94, :_reduce_98,
- 3, 97, :_reduce_99,
- 3, 97, :_reduce_100,
- 3, 97, :_reduce_101,
- 5, 78, :_reduce_102,
- 6, 78, :_reduce_103,
- 7, 78, :_reduce_104,
- 6, 78, :_reduce_105,
- 6, 78, :_reduce_106,
- 1, 77, :_reduce_none,
- 4, 77, :_reduce_108,
- 1, 98, :_reduce_109,
- 1, 98, :_reduce_110,
- 1, 98, :_reduce_111,
- 2, 99, :_reduce_112,
- 4, 100, :_reduce_113,
- 4, 100, :_reduce_114,
- 5, 100, :_reduce_115,
- 5, 100, :_reduce_116,
- 4, 101, :_reduce_117,
- 5, 101, :_reduce_118,
- 7, 101, :_reduce_119,
- 4, 101, :_reduce_120,
- 5, 101, :_reduce_121,
- 7, 101, :_reduce_122,
- 9, 101, :_reduce_123,
- 7, 101, :_reduce_124,
- 9, 101, :_reduce_125,
- 0, 82, :_reduce_126,
- 1, 82, :_reduce_none,
- 1, 60, :_reduce_128,
- 1, 60, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_none,
- 2, 62, :_reduce_139,
- 2, 62, :_reduce_140,
- 2, 62, :_reduce_141,
- 2, 62, :_reduce_142,
- 1, 58, :_reduce_none,
- 2, 58, :_reduce_144,
- 2, 102, :_reduce_145,
- 2, 102, :_reduce_146,
- 2, 102, :_reduce_147,
- 2, 102, :_reduce_148,
- 2, 102, :_reduce_149,
- 2, 102, :_reduce_150,
- 2, 65, :_reduce_none,
- 1, 65, :_reduce_none,
- 1, 103, :_reduce_none,
- 2, 103, :_reduce_154,
- 2, 103, :_reduce_155,
- 2, 103, :_reduce_156,
- 2, 103, :_reduce_157,
- 2, 103, :_reduce_158,
- 2, 103, :_reduce_159,
- 1, 104, :_reduce_none,
- 2, 104, :_reduce_161,
- 1, 64, :_reduce_none,
- 2, 64, :_reduce_163,
- 1, 59, :_reduce_none,
- 2, 59, :_reduce_165,
- 2, 59, :_reduce_166,
- 2, 59, :_reduce_167,
- 2, 66, :_reduce_none,
- 1, 66, :_reduce_none,
- 1, 90, :_reduce_170,
- 2, 90, :_reduce_171,
- 3, 90, :_reduce_172,
- 4, 90, :_reduce_173,
- 1, 89, :_reduce_174,
- 2, 89, :_reduce_175 ]
-
-racc_reduce_n = 176
-
-racc_shift_n = 320
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :T => 2,
- :Z => 3,
- :E => 4,
- :X => 5,
- :U => 6,
- :UNKNOWN => 7,
- :OPEN => 8,
- :LONGYEAR => 9,
- :UNMATCHED => 10,
- :DOTS => 11,
- :UA => 12,
- :PUA => 13,
- "-" => 14,
- ":" => 15,
- "2" => 16,
- "4" => 17,
- "0" => 18,
- "+" => 19,
- "1" => 20,
- "/" => 21,
- "3" => 22,
- "^" => 23,
- "[" => 24,
- "]" => 25,
- "{" => 26,
- "}" => 27,
- "," => 28,
- "(" => 29,
- ")" => 30,
- "-(" => 31,
- "5" => 32,
- "6" => 33,
- "7" => 34,
- "8" => 35,
- "9" => 36 }
-
-racc_nt_base = 37
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "T",
- "Z",
- "E",
- "X",
- "U",
- "UNKNOWN",
- "OPEN",
- "LONGYEAR",
- "UNMATCHED",
- "DOTS",
- "UA",
- "PUA",
- "\"-\"",
- "\":\"",
- "\"2\"",
- "\"4\"",
- "\"0\"",
- "\"+\"",
- "\"1\"",
- "\"/\"",
- "\"3\"",
- "\"^\"",
- "\"[\"",
- "\"]\"",
- "\"{\"",
- "\"}\"",
- "\",\"",
- "\"(\"",
- "\")\"",
- "\"-(\"",
- "\"5\"",
- "\"6\"",
- "\"7\"",
- "\"8\"",
- "\"9\"",
- "$start",
- "edtf",
- "level_0_expression",
- "level_1_expression",
- "level_2_expression",
- "date",
- "date_time",
- "positive_date",
- "negative_date",
- "year",
- "year_month",
- "year_month_day",
- "time",
- "base_time",
- "zone_offset",
- "hour",
- "minute",
- "second",
- "midnight",
- "zone_offset_hour",
- "positive_zone_offset",
- "d01_13",
- "d01_59",
- "digit",
- "month",
- "d01_12",
- "day",
- "d01_31",
- "d00_23",
- "d00_59",
- "unspecified",
- "level_1_interval",
- "long_year_simple",
- "season",
- "unspecified_year",
- "unspecified_month",
- "unspecified_day",
- "unspecified_day_and_month",
- "level_1_start",
- "level_1_end",
- "partial_uncertain_or_approximate",
- "partial_unspecified",
- "long_year",
- "positive_digit",
- "season_number",
- "ua",
- "season_qualified",
- "choice_list",
- "inclusive_list",
- "masked_precision",
- "date_and_calendar",
- "long_year_scientific",
- "integer",
- "int1_4",
- "list",
- "earlier",
- "list_elements",
- "later",
- "list_element",
- "atomic",
- "consecutives",
- "pua_base",
- "pua_year",
- "pua_year_month",
- "pua_year_month_day",
- "d01_23",
- "d01_29",
- "d01_30" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-# reduce 1 omitted
-
-# reduce 2 omitted
-
-# reduce 3 omitted
-
-# reduce 4 omitted
-
-# reduce 5 omitted
-
-# reduce 6 omitted
-
-# reduce 7 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 54)
- def _reduce_8(val, _values, result)
- result = Date.new(val[0]).year_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 55)
- def _reduce_9(val, _values, result)
- result = Date.new(*val.flatten).month_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 56)
- def _reduce_10(val, _values, result)
- result = Date.new(*val.flatten).day_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 59)
- def _reduce_11(val, _values, result)
- result = -val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 63)
- def _reduce_12(val, _values, result)
- result = DateTime.new(val[0].year, val[0].month, val[0].day, *val[2])
- result.skip_timezone = (val[2].length == 3)
-
- result
- end
-.,.,
-
-# reduce 13 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 68)
- def _reduce_14(val, _values, result)
- result = val.flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 70)
- def _reduce_15(val, _values, result)
- result = val.values_at(0, 2, 4)
- result
- end
-.,.,
-
-# reduce 16 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 73)
- def _reduce_17(val, _values, result)
- result = [24, 0, 0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 75)
- def _reduce_18(val, _values, result)
- result = 0
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 76)
- def _reduce_19(val, _values, result)
- result = -1 * val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 77)
- def _reduce_20(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 21 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 81)
- def _reduce_22(val, _values, result)
- result = 0
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 85)
- def _reduce_23(val, _values, result)
- result = Rational(val[0] * 60 + val[2], 1440)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 86)
- def _reduce_24(val, _values, result)
- result = Rational(840, 1440)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 87)
- def _reduce_25(val, _values, result)
- result = Rational(val[3], 1440)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 91)
- def _reduce_26(val, _values, result)
- result = val.zip([1000,100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
-
- result
- end
-.,.,
-
-# reduce 27 omitted
-
-# reduce 28 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 97)
- def _reduce_29(val, _values, result)
- result = [val[0], val[2]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 104)
- def _reduce_30(val, _values, result)
- result = val[0] << val[2]
- if result[2] > 31 || (result[2] > 30 && [2,4,6,9,11].include?(result[1])) || (result[2] > 29 && result[1] == 2)
- raise ArgumentError, "invalid date (invalid days #{result[2]} for month #{result[1]})"
- end
-
- result
- end
-.,.,
-
-# reduce 31 omitted
-
-# reduce 32 omitted
-
-# reduce 33 omitted
-
-# reduce 34 omitted
-
-# reduce 35 omitted
-
-# reduce 36 omitted
-
-# reduce 37 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 127)
- def _reduce_38(val, _values, result)
- result = Date.new(val[0][0]).year_precision!
- result.unspecified.year[2,2] = val[0][1]
-
- result
- end
-.,.,
-
-# reduce 39 omitted
-
-# reduce 40 omitted
-
-# reduce 41 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 138)
- def _reduce_42(val, _values, result)
- result = [val[0,3].zip([1000,100,10]).reduce(0) { |s,(a,b)| s += a * b }, [false,true]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 142)
- def _reduce_43(val, _values, result)
- result = [val[0,2].zip([1000,100]).reduce(0) { |s,(a,b)| s += a * b }, [true, true]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 146)
- def _reduce_44(val, _values, result)
- result = Date.new(val[0]).unspecified!(:month)
- result.precision = :month
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 151)
- def _reduce_45(val, _values, result)
- result = Date.new(*val[0]).unspecified!(:day)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 155)
- def _reduce_46(val, _values, result)
- result = Date.new(val[0]).unspecified!([:day,:month])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 160)
- def _reduce_47(val, _values, result)
- result = Interval.new(val[0], val[2])
-
- result
- end
-.,.,
-
-# reduce 48 omitted
-
-# reduce 49 omitted
-
-# reduce 50 omitted
-
-# reduce 51 omitted
-
-# reduce 52 omitted
-
-# reduce 53 omitted
-
-# reduce 54 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 171)
- def _reduce_55(val, _values, result)
- result = Date.new(val[1])
- result.precision = :year
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 176)
- def _reduce_56(val, _values, result)
- result = Date.new(-1 * val[2])
- result.precision = :year
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 183)
- def _reduce_57(val, _values, result)
- result = val.zip([10000,1000,100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 185)
- def _reduce_58(val, _values, result)
- result = 10 * val[0] + val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 190)
- def _reduce_59(val, _values, result)
- result = Season.new(val[0], val[2])
- val[3].each { |ua| result.send(ua) }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 194)
- def _reduce_60(val, _values, result)
- result = 21
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 195)
- def _reduce_61(val, _values, result)
- result = 22
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 196)
- def _reduce_62(val, _values, result)
- result = 23
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 197)
- def _reduce_63(val, _values, result)
- result = 24
- result
- end
-.,.,
-
-# reduce 64 omitted
-
-# reduce 65 omitted
-
-# reduce 66 omitted
-
-# reduce 67 omitted
-
-# reduce 68 omitted
-
-# reduce 69 omitted
-
-# reduce 70 omitted
-
-# reduce 71 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 215)
- def _reduce_72(val, _values, result)
- result = val[0]; result.qualifier = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 221)
- def _reduce_73(val, _values, result)
- result = Date.new(val[0].year * 10 ** val[2]).year_precision!
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 225)
- def _reduce_74(val, _values, result)
- result = Date.new(val[1] * 10 ** val[3]).year_precision!
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 229)
- def _reduce_75(val, _values, result)
- result = Date.new(-1 * val[2] * 10 ** val[4]).year_precision!
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 234)
- def _reduce_76(val, _values, result)
- result = val[0]; result.calendar = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 240)
- def _reduce_77(val, _values, result)
- d = val[0,3].zip([1000,100,10]).reduce(0) { |s,(a,b)| s += a * b }
- result = EDTF::Decade.new(d)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 245)
- def _reduce_78(val, _values, result)
- d = val[0,2].zip([1000,100]).reduce(0) { |s,(a,b)| s += a * b }
- result = EDTF::Century.new(d)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 251)
- def _reduce_79(val, _values, result)
- result = val[1].choice!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 253)
- def _reduce_80(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 255)
- def _reduce_81(val, _values, result)
- result = EDTF::Set.new(val[0]).earlier!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 256)
- def _reduce_82(val, _values, result)
- result = EDTF::Set.new([val[0]] + val[2] + [val[4]]).earlier!.later!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 257)
- def _reduce_83(val, _values, result)
- result = EDTF::Set.new([val[0]] + val[2]).earlier!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 258)
- def _reduce_84(val, _values, result)
- result = EDTF::Set.new([val[0]] + [val[2]]).earlier!.later!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 259)
- def _reduce_85(val, _values, result)
- result = EDTF::Set.new(val[0] + [val[2]]).later!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 260)
- def _reduce_86(val, _values, result)
- result = EDTF::Set.new(*val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 261)
- def _reduce_87(val, _values, result)
- result = EDTF::Set.new(val[0]).later!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 264)
- def _reduce_88(val, _values, result)
- result = [val[0]].flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 265)
- def _reduce_89(val, _values, result)
- result = val[0] + [val[2]].flatten
- result
- end
-.,.,
-
-# reduce 90 omitted
-
-# reduce 91 omitted
-
-# reduce 92 omitted
-
-# reduce 93 omitted
-
-# reduce 94 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 277)
- def _reduce_95(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 279)
- def _reduce_96(val, _values, result)
- result = Date.new(*val[0]).year_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 280)
- def _reduce_97(val, _values, result)
- result = Date.new(*val[0]).month_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 281)
- def _reduce_98(val, _values, result)
- result = Date.new(val[0]).year_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 284)
- def _reduce_99(val, _values, result)
- result = (Date.new(val[0]).day_precision! .. Date.new(val[2]).day_precision!)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 285)
- def _reduce_100(val, _values, result)
- result = (Date.new(val[0]).month_precision! .. Date.new(val[2]).month_precision!)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 286)
- def _reduce_101(val, _values, result)
- result = (Date.new(val[0]).year_precision! .. Date.new(val[2]).year_precision!)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 292)
- def _reduce_102(val, _values, result)
- result = Date.new(val[0][0], val[2], val[4])
- result.unspecified.year[2,2] = val[0][1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 297)
- def _reduce_103(val, _values, result)
- result = Date.new(val[0][0], 1, val[5])
- result.unspecified.year[2,2] = val[0][1]
- result.unspecified!(:month)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 303)
- def _reduce_104(val, _values, result)
- result = Date.new(val[0][0], 1, 1)
- result.unspecified.year[2,2] = val[0][1]
- result.unspecified!([:month, :day])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 309)
- def _reduce_105(val, _values, result)
- result = Date.new(val[0][0], val[2], 1)
- result.unspecified.year[2,2] = val[0][1]
- result.unspecified!(:day)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 315)
- def _reduce_106(val, _values, result)
- result = Date.new(val[0], 1, val[5])
- result.unspecified!(:month)
-
- result
- end
-.,.,
-
-# reduce 107 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 322)
- def _reduce_108(val, _values, result)
- result = uoa(val[1], val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 325)
- def _reduce_109(val, _values, result)
- result = val[0].year_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 326)
- def _reduce_110(val, _values, result)
- result = val[0][0].month_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 327)
- def _reduce_111(val, _values, result)
- result = val[0].day_precision!
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 329)
- def _reduce_112(val, _values, result)
- result = uoa(Date.new(val[0]), val[1], :year)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 333)
- def _reduce_113(val, _values, result)
- result = [uoa(val[0].change(:month => val[2]), val[3], [:month, :year])]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 336)
- def _reduce_114(val, _values, result)
- result = [uoa(Date.new(val[0], val[2]), val[3], [:year, :month])]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 339)
- def _reduce_115(val, _values, result)
- result = [uoa(Date.new(val[0], val[2]), val[4], [:month]), true]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 342)
- def _reduce_116(val, _values, result)
- result = [uoa(val[0].change(:month => val[2]), val[4], [:month]), true]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 348)
- def _reduce_117(val, _values, result)
- result = uoa(val[0][0].change(:day => val[2]), val[3], val[0][1] ? [:day] : nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 351)
- def _reduce_118(val, _values, result)
- result = uoa(val[0][0].change(:day => val[2]), val[4], [:day])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 354)
- def _reduce_119(val, _values, result)
- result = uoa(uoa(Date.new(val[0], val[2], val[5]), val[4], :month), val[6], :day)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 357)
- def _reduce_120(val, _values, result)
- result = uoa(Date.new(val[0][0], val[0][1], val[2]), val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 360)
- def _reduce_121(val, _values, result)
- result = uoa(Date.new(val[0][0], val[0][1], val[2]), val[4], [:day])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 363)
- def _reduce_122(val, _values, result)
- result = uoa(Date.new(val[0], val[2], val[4]), val[6], [:month, :day])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 366)
- def _reduce_123(val, _values, result)
- result = Date.new(val[0], val[2], val[4])
- result = uoa(result, val[6], [:day])
- result = uoa(result, val[8], [:month, :day])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 371)
- def _reduce_124(val, _values, result)
- result = val[0].change(:month => val[2], :day => val[4])
- result = uoa(result, val[6], [:month, :day])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 375)
- def _reduce_125(val, _values, result)
- result = val[0].change(:month => val[2], :day => val[4])
- result = uoa(result, val[6], [:day])
- result = uoa(result, val[8], [:month, :day])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 386)
- def _reduce_126(val, _values, result)
- result = []
- result
- end
-.,.,
-
-# reduce 127 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 390)
- def _reduce_128(val, _values, result)
- result = 0
- result
- end
-.,.,
-
-# reduce 129 omitted
-
-# reduce 130 omitted
-
-# reduce 131 omitted
-
-# reduce 132 omitted
-
-# reduce 133 omitted
-
-# reduce 134 omitted
-
-# reduce 135 omitted
-
-# reduce 136 omitted
-
-# reduce 137 omitted
-
-# reduce 138 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 396)
- def _reduce_139(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 397)
- def _reduce_140(val, _values, result)
- result = 10
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 398)
- def _reduce_141(val, _values, result)
- result = 11
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 399)
- def _reduce_142(val, _values, result)
- result = 12
- result
- end
-.,.,
-
-# reduce 143 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 403)
- def _reduce_144(val, _values, result)
- result = 13
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 406)
- def _reduce_145(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 407)
- def _reduce_146(val, _values, result)
- result = 10 + val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 408)
- def _reduce_147(val, _values, result)
- result = 20
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 409)
- def _reduce_148(val, _values, result)
- result = 21
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 410)
- def _reduce_149(val, _values, result)
- result = 22
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 411)
- def _reduce_150(val, _values, result)
- result = 23
- result
- end
-.,.,
-
-# reduce 151 omitted
-
-# reduce 152 omitted
-
-# reduce 153 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 419)
- def _reduce_154(val, _values, result)
- result = 24
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 420)
- def _reduce_155(val, _values, result)
- result = 25
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 421)
- def _reduce_156(val, _values, result)
- result = 26
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 422)
- def _reduce_157(val, _values, result)
- result = 27
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 423)
- def _reduce_158(val, _values, result)
- result = 28
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 424)
- def _reduce_159(val, _values, result)
- result = 29
- result
- end
-.,.,
-
-# reduce 160 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 428)
- def _reduce_161(val, _values, result)
- result = 30
- result
- end
-.,.,
-
-# reduce 162 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 432)
- def _reduce_163(val, _values, result)
- result = 31
- result
- end
-.,.,
-
-# reduce 164 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 436)
- def _reduce_165(val, _values, result)
- result = 30 + val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 437)
- def _reduce_166(val, _values, result)
- result = 40 + val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 438)
- def _reduce_167(val, _values, result)
- result = 50 + val[1]
- result
- end
-.,.,
-
-# reduce 168 omitted
-
-# reduce 169 omitted
-
-module_eval(<<'.,.,', 'edtf.y', 445)
- def _reduce_170(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 446)
- def _reduce_171(val, _values, result)
- result = 10 * val[0] + val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 449)
- def _reduce_172(val, _values, result)
- result = val.zip([100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 453)
- def _reduce_173(val, _values, result)
- result = val.zip([1000,100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 457)
- def _reduce_174(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'edtf.y', 458)
- def _reduce_175(val, _values, result)
- result = 10 * val[0] + val[1]
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module EDTF
diff --git a/test/racc/regress/huia b/test/racc/regress/huia
deleted file mode 100644
index fc8ccfe847..0000000000
--- a/test/racc/regress/huia
+++ /dev/null
@@ -1,1392 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-module Huia
- class Parser < Racc::Parser
-
-module_eval(<<'...end huia.y/module_eval...', 'huia.y', 211)
-
-attr_accessor :lexer, :scopes, :state
-
-def initialize lexer
- @lexer = lexer
- @state = []
- @scopes = []
- push_scope
-end
-
-def ast
- @ast ||= do_parse
- @scopes.first
-end
-
-def on_error t, val, vstack
- line = lexer.line
- col = lexer.column
- message = "Unexpected #{token_to_str t} at #{lexer.filename} line #{line}:#{col}:\n\n"
-
- start = line - 5 > 0 ? line - 5 : 0
- i_size = line.to_s.size
- (start..(start + 5)).each do |i|
- message << sprintf("\t%#{i_size}d: %s\n", i, lexer.get_line(i))
- message << "\t#{' ' * i_size} #{'-' * (col - 1)}^\n" if i == line
- end
-
- raise SyntaxError, message
-end
-
-def next_token
- nt = lexer.next_computed_token
- # just use a state stack for now, we'll have to do something
- # more sophisticated soon.
- if nt && nt.first == :state
- if nt.last
- state.push << nt.last
- else
- state.pop
- end
- next_token
- else
- nt
- end
-end
-
-def push_scope
- new_scope = Huia::AST::Scope.new scope
- new_scope.file = lexer.filename
- new_scope.line = lexer.line
- new_scope.column = lexer.column
- scopes.push new_scope
- new_scope
-end
-
-def pop_scope
- scopes.pop
-end
-
-def scope
- scopes.last
-end
-
-def binary left, right, method
- node(:MethodCall, left, node(:CallSignature, method, [right]))
-end
-
-def unary left, method
- node(:MethodCall, left, node(:CallSignature, method))
-end
-
-def node type, *args
- Huia::AST.const_get(type).new(*args).tap do |n|
- n.file = lexer.filename
- n.line = lexer.line
- n.column = lexer.column
- end
-end
-alias n node
-
-def allocate_local name
- node(:Variable, name).tap do |n|
- scope.allocate_local n
- end
-end
-
-def allocate_local_assignment name, value
- node(:Assignment, name, value).tap do |n|
- scope.allocate_local n
- end
-end
-
-def this_closure
- allocate_local('@')
-end
-
-def scope_instance
- node(:ScopeInstance, scope)
-end
-
-def constant name
- return scope_instance if name == 'self'
- node(:Constant, name)
-end
-
-def to_string expr
- node(:MethodCall, expr, node(:CallSignature, 'toString'))
-end
-...end huia.y/module_eval...
-##### State transition tables begin ###
-
-clist = [
-'81,137,40,180,61,62,164,153,182,71,72,77,155,178,179,39,135,37,37,5',
-'6,106,152,73,74,75,36,36,76,28,154,80,164,166,123,22,23,37,26,27,37',
-'60,63,19,186,40,36,61,62,172,,33,71,72,77,,,134,39,133,129,37,134,,169',
-'129,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33',
-'71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63',
-'19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,',
-',22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,160,39,,,37,5,6,',
-',73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71',
-'72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19',
-',40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22',
-'23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,160,39,,,37,5,6,,,73',
-'74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72',
-'77,,114,,39,,,37,,,113,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63',
-'19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,',
-',22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74',
-'75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77',
-',,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40',
-',61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23',
-',26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36',
-'76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,',
-',37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62',
-',,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27',
-',60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28',
-',80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,5',
-'6,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33',
-'71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63',
-'19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,',
-',22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74',
-'75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77',
-',,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40',
-',61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23',
-',26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36',
-'76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,',
-',37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62',
-',,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27',
-',60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28',
-',80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,',
-',,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71',
-'72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19',
-',40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22',
-'23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75',
-',36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61,62,,,33,71,72,77,,,',
-'39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26,27,,60,63,19,,40,,61',
-'62,,,33,71,72,77,,,,39,,,37,,,,,73,74,75,,36,76,28,,80,,,,22,23,,26',
-'27,,60,63,19,85,86,87,88,,,,33,89,,,,,84,,85,86,87,88,,,,91,89,,,,,84',
-',5,6,,,,,,91,,,92,93,94,95,96,97,98,,90,,,,,,,92,93,94,95,96,97,98,',
-'90,85,86,87,88,,,,,89,,,,,84,,85,86,87,88,,,,91,89,,,,,84,,,,,,,,,91',
-',,92,93,94,95,96,97,98,,90,,,,,,,92,93,94,95,96,97,98,,90,85,86,87,88',
-'156,,,,89,,,,,84,,85,86,87,88,,,,91,89,,,,,84,,165,,,,,,,91,,,92,93',
-'94,95,96,97,98,,90,,,,,,,92,93,94,95,96,97,98,,90,85,86,87,88,,,,,89',
-',,,167,84,,85,86,87,88,,,,91,89,,,,,84,,,,,,,,,91,,,92,93,94,95,96,97',
-'98,,90,,,,,,,92,93,94,95,96,97,98,,90,85,86,87,88,,,,,89,,,,,84,,85',
-'86,87,88,,,,91,89,,,,,84,,,,,,,,,91,,,92,93,94,95,96,97,98,,90,,,,,',
-',92,93,94,95,96,97,98,,90,85,86,87,88,,,,,89,,,,,84,,85,86,87,88,,,',
-'91,89,,,,,84,,,,,,,,,91,,,92,93,94,95,96,97,98,,90,,,,,,,92,93,94,95',
-'96,97,98,,90,85,86,87,88,,,,,89,,,,,84,,85,86,87,88,,,,91,89,,,,,84',
-',,,,,,,,91,,,92,93,94,95,96,97,98,,90,,,,,,,92,93,94,95,96,97,98,,90',
-'85,86,87,88,,84,,,89,,160,,,84,91,5,6,85,86,87,88,,91,,,89,,,,,84,,92',
-'93,94,95,96,97,98,91,92,93,94,95,96,97,98,,90,,,,,,,,,92,93,94,95,96',
-'97,98,,90,85,86,87,88,,,,,89,,,,,84,,85,86,87,88,,,,91,89,,,,,84,,181',
-',,,,,,91,,,92,93,94,95,96,97,98,,90,,,,,,,92,93,94,95,96,97,98,,90,85',
-'86,87,88,,,,,89,,,,,84,,85,86,87,88,,,,91,89,,,,,84,,,,,,,,,91,,,92',
-'93,94,95,96,97,98,,90,,,,,,,92,93,94,95,96,97,98,,90,87,88,,,,,89,,',
-',,84,87,88,,,,,89,,91,,,84,,87,88,,,,,89,91,,,,84,,92,93,94,95,96,97',
-'98,91,90,,,,92,93,94,95,96,97,98,,90,,,,,92,93,94,95,96,97,98,89,90',
-'87,88,,84,,,89,,,,,84,91,,,,,,,,91,,,89,,,,,84,,92,93,94,95,96,97,98',
-'91,92,93,94,95,96,97,98,,90,,89,,,,,84,,92,93,94,95,96,97,98,91,89,',
-',,,84,,,,,89,,,,91,84,,92,93,94,95,96,97,98,91,,,,,,,,92,93,94,95,96',
-'97,98,,,,92,93,94,95,96,97,98' ]
- racc_action_table = arr = ::Array.new(2246, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'1,84,1,163,1,1,179,100,178,1,1,1,102,161,161,1,81,84,1,1,1,33,100,1',
-'1,1,84,1,1,1,102,1,112,121,40,1,1,33,1,1,34,1,1,1,183,19,33,19,19,131',
-',1,19,19,19,,,80,19,80,80,19,128,,128,128,19,19,19,,19,19,19,,19,,,',
-'19,19,,19,19,,19,19,19,,123,,123,123,,,19,123,123,123,,,,123,,,123,',
-',,,123,123,123,,123,123,123,,123,,,,123,123,,123,123,,123,123,123,,23',
-',23,23,,,123,23,23,23,,,,23,,,23,,,,,23,23,23,,23,23,23,,23,,,,23,23',
-',23,23,,23,23,23,,111,,111,111,,,23,111,111,111,,,111,111,,,111,111',
-'111,,,111,111,111,,111,111,111,,111,,,,111,111,,111,111,,111,111,111',
-',27,,27,27,,,111,27,27,27,,,,27,,,27,,,,,27,27,27,,27,27,27,,27,,,,27',
-'27,,27,27,,27,27,27,,180,,180,180,,,27,180,180,180,,,,180,,,180,,,,',
-'180,180,180,,180,180,180,,180,,,,180,180,,180,180,,180,180,180,,157',
-',157,157,,,180,157,157,157,,,157,157,,,157,157,157,,,157,157,157,,157',
-'157,157,,157,,,,157,157,,157,157,,157,157,157,,37,,37,37,,,157,37,37',
-'37,,37,,37,,,37,,,37,,37,37,37,,37,37,37,,37,,,,37,37,,37,37,,37,37',
-'37,,39,,39,39,,,37,39,39,39,,,,39,,,39,,,,,39,39,39,,39,39,39,,39,,',
-',39,39,,39,39,,39,39,39,,156,,156,156,,,39,156,156,156,,,,156,,,156',
-',,,,156,156,156,,156,156,156,,156,,,,156,156,,156,156,,156,156,156,',
-'60,,60,60,,,156,60,60,60,,,,60,,,60,,,,,60,60,60,,60,60,60,,60,,,,60',
-'60,,60,60,,60,60,60,,61,,61,61,,,60,61,61,61,,,,61,,,61,,,,,61,61,61',
-',61,61,61,,61,,,,61,61,,61,61,,61,61,61,,62,,62,62,,,61,62,62,62,,,',
-'62,,,62,,,,,62,62,62,,62,62,62,,62,,,,62,62,,62,62,,62,62,62,,63,,63',
-'63,,,62,63,63,63,,,,63,,,63,,,,,63,63,63,,63,63,63,,63,,,,63,63,,63',
-'63,,63,63,63,,155,,155,155,,,63,155,155,155,,,,155,,,155,,,,,155,155',
-'155,,155,155,155,,155,,,,155,155,,155,155,,155,155,155,,129,,129,129',
-',,155,129,129,129,,,,129,,,129,,,,,129,129,129,,129,129,129,,129,,,',
-'129,129,,129,129,,129,129,129,,0,,0,0,,,129,0,0,0,,,,0,,,0,0,0,,,0,0',
-'0,,0,0,0,,0,,,,0,0,,0,0,,0,0,0,,85,,85,85,,,0,85,85,85,,,,85,,,85,,',
-',,85,85,85,,85,85,85,,85,,,,85,85,,85,85,,85,85,85,,86,,86,86,,,85,86',
-'86,86,,,,86,,,86,,,,,86,86,86,,86,86,86,,86,,,,86,86,,86,86,,86,86,86',
-',87,,87,87,,,86,87,87,87,,,,87,,,87,,,,,87,87,87,,87,87,87,,87,,,,87',
-'87,,87,87,,87,87,87,,88,,88,88,,,87,88,88,88,,,,88,,,88,,,,,88,88,88',
-',88,88,88,,88,,,,88,88,,88,88,,88,88,88,,89,,89,89,,,88,89,89,89,,,',
-'89,,,89,,,,,89,89,89,,89,89,89,,89,,,,89,89,,89,89,,89,89,89,,90,,90',
-'90,,,89,90,90,90,,,,90,,,90,,,,,90,90,90,,90,90,90,,90,,,,90,90,,90',
-'90,,90,90,90,,91,,91,91,,,90,91,91,91,,,,91,,,91,,,,,91,91,91,,91,91',
-'91,,91,,,,91,91,,91,91,,91,91,91,,92,,92,92,,,91,92,92,92,,,,92,,,92',
-',,,,92,92,92,,92,92,92,,92,,,,92,92,,92,92,,92,92,92,,93,,93,93,,,92',
-'93,93,93,,,,93,,,93,,,,,93,93,93,,93,93,93,,93,,,,93,93,,93,93,,93,93',
-'93,,94,,94,94,,,93,94,94,94,,,,94,,,94,,,,,94,94,94,,94,94,94,,94,,',
-',94,94,,94,94,,94,94,94,,95,,95,95,,,94,95,95,95,,,,95,,,95,,,,,95,95',
-'95,,95,95,95,,95,,,,95,95,,95,95,,95,95,95,,96,,96,96,,,95,96,96,96',
-',,,96,,,96,,,,,96,96,96,,96,96,96,,96,,,,96,96,,96,96,,96,96,96,,97',
-',97,97,,,96,97,97,97,,,,97,,,97,,,,,97,97,97,,97,97,97,,97,,,,97,97',
-',97,97,,97,97,97,,98,,98,98,,,97,98,98,98,,,,98,,,98,,,,,98,98,98,,98',
-'98,98,,98,,,,98,98,,98,98,,98,98,98,,153,,153,153,,,98,153,153,153,',
-',,153,,,153,,,,,153,153,153,,153,153,153,,153,,,,153,153,,153,153,,153',
-'153,153,147,147,147,147,,,,153,147,,,,,147,,3,3,3,3,,,,147,3,,,,,3,',
-'3,3,,,,,,3,,,147,147,147,147,147,147,147,,147,,,,,,,3,3,3,3,3,3,3,,3',
-'99,99,99,99,,,,,99,,,,,99,,101,101,101,101,,,,99,101,,,,,101,,,,,,,',
-',101,,,99,99,99,99,99,99,99,,99,,,,,,,101,101,101,101,101,101,101,,101',
-'104,104,104,104,104,,,,104,,,,,104,,117,117,117,117,,,,104,117,,,,,117',
-',117,,,,,,,117,,,104,104,104,104,104,104,104,,104,,,,,,,117,117,117',
-'117,117,117,117,,117,122,122,122,122,,,,,122,,,,122,122,,144,144,144',
-'144,,,,122,144,,,,,144,,,,,,,,,144,,,122,122,122,122,122,122,122,,122',
-',,,,,,144,144,144,144,144,144,144,,144,145,145,145,145,,,,,145,,,,,145',
-',146,146,146,146,,,,145,146,,,,,146,,,,,,,,,146,,,145,145,145,145,145',
-'145,145,,145,,,,,,,146,146,146,146,146,146,146,,146,148,148,148,148',
-',,,,148,,,,,148,,149,149,149,149,,,,148,149,,,,,149,,,,,,,,,149,,,148',
-'148,148,148,148,148,148,,148,,,,,,,149,149,149,149,149,149,149,,149',
-'150,150,150,150,,,,,150,,,,,150,,151,151,151,151,,,,150,151,,,,,151',
-',,,,,,,,151,,,150,150,150,150,150,150,150,,150,,,,,,,151,151,151,151',
-'151,151,151,,151,158,158,158,158,,142,,,158,,158,,,158,142,158,158,168',
-'168,168,168,,158,,,168,,,,,168,,142,142,142,142,142,142,142,168,158',
-'158,158,158,158,158,158,,158,,,,,,,,,168,168,168,168,168,168,168,,168',
-'171,171,171,171,,,,,171,,,,,171,,173,173,173,173,,,,171,173,,,,,173',
-',171,,,,,,,173,,,171,171,171,171,171,171,171,,171,,,,,,,173,173,173',
-'173,173,173,173,,173,175,175,175,175,,,,,175,,,,,175,,185,185,185,185',
-',,,175,185,,,,,185,,,,,,,,,185,,,175,175,175,175,175,175,175,,175,,',
-',,,,185,185,185,185,185,185,185,,185,126,126,,,,,126,,,,,126,125,125',
-',,,,125,,126,,,125,,139,139,,,,,139,125,,,,139,,126,126,126,126,126',
-'126,126,139,126,,,,125,125,125,125,125,125,125,,125,,,,,139,139,139',
-'139,139,139,139,141,139,138,138,,141,,,138,,,,,138,141,,,,,,,,138,,',
-'143,,,,,143,,141,141,141,141,141,141,141,143,138,138,138,138,138,138',
-'138,,138,,124,,,,,124,,143,143,143,143,143,143,143,124,127,,,,,127,',
-',,,140,,,,127,140,,124,124,124,124,124,124,124,140,,,,,,,,127,127,127',
-'127,127,127,127,,,,140,140,140,140,140,140,140' ]
- racc_action_check = arr = ::Array.new(2246, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_action_pointer = [
- 731, 0, nil, 1431, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 43,
- nil, nil, nil, 129, nil, nil, nil, 215, nil, nil,
- nil, nil, nil, 19, 22, nil, nil, 344, nil, 387,
- 31, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 473, 516, 559, 602, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 27, 16, nil, nil, -1, 774, 817, 860, 903, 946,
- 989, 1032, 1075, 1118, 1161, 1204, 1247, 1290, 1333, 1480,
- -15, 1495, -10, nil, 1544, nil, nil, nil, nil, nil,
- nil, 172, 30, nil, nil, nil, nil, 1559, nil, nil,
- nil, 14, 1608, 86, 2170, 2068, 2056, 2185, 32, 688,
- nil, 19, nil, nil, nil, nil, nil, nil, 2128, 2081,
- 2195, 2120, 1856, 2145, 1623, 1672, 1687, 1416, 1736, 1751,
- 1800, 1815, nil, 1376, nil, 645, 430, 301, 1864, nil,
- nil, -8, nil, 0, nil, nil, nil, nil, 1881, nil,
- nil, 1930, nil, 1945, nil, 1994, nil, nil, -11, 4,
- 258, nil, nil, 31, nil, 2009, nil ]
-
-racc_action_default = [
- -140, -140, -1, -4, -5, -6, -7, -10, -11, -12,
- -13, -14, -15, -16, -17, -18, -19, -20, -21, -23,
- -24, -25, -26, -140, -30, -31, -32, -140, -37, -55,
- -56, -57, -60, -140, -63, -64, -65, -140, -73, -140,
- -76, -77, -78, -79, -80, -81, -82, -83, -84, -85,
- -86, -87, -88, -89, -90, -91, -107, -108, -109, -110,
- -140, -140, -140, -140, -115, -116, -117, -118, -119, -120,
- -121, -122, -123, -124, -125, -126, -127, -128, -129, -130,
- -140, -140, -2, -3, -140, -140, -140, -140, -140, -140,
- -140, -140, -140, -140, -140, -140, -140, -140, -140, -22,
- -140, -28, -140, -34, -140, -61, -62, -74, -38, -39,
- -40, -140, -140, -46, -47, -48, -49, -69, -66, -67,
- -68, -71, -140, -140, -111, -112, -113, -114, -140, -140,
- -133, -135, -136, -137, -138, 187, -58, -59, -93, -94,
- -95, -96, -97, -98, -99, -100, -101, -102, -103, -104,
- -105, -106, -27, -140, -33, -140, -140, -140, -4, -43,
- -44, -140, -50, -52, -54, -70, -72, -75, -92, -131,
- -134, -140, -139, -29, -35, -36, -41, -42, -9, -140,
- -140, -132, -8, -140, -51, -53, -45 ]
-
-racc_goto_table = [
- 99, 82, 103, 83, 101, 1, 105, 130, 104, 108,
- 109, 110, 159, 162, 111, 115, 112, 161, 117, 116,
- 122, 102, 100, 107, 118, 119, 120, 128, 121, 183,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 124, 125, 126, 127, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 170, nil, 136, 176, 177,
- nil, nil, nil, nil, nil, nil, 138, 139, 140, 141,
- 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
- 184, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 158, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 168, nil, nil, nil, nil, nil,
- 171, nil, nil, nil, nil, nil, 157, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 174, nil, nil, nil, 173, nil, 104, 175, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 82, 83, nil,
- nil, 185 ]
-
-racc_goto_check = [
- 3, 2, 24, 4, 3, 1, 40, 77, 3, 26,
- 27, 28, 30, 35, 29, 31, 32, 33, 3, 34,
- 3, 23, 20, 43, 44, 45, 46, 75, 25, 5,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 3, 3, 3, 3, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 77, nil, 40, 30, 30,
- nil, nil, nil, nil, nil, nil, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 35, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 3, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 3, nil, nil, nil, nil, nil,
- 3, nil, nil, nil, nil, nil, 1, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 24, nil, nil, nil, 3, nil, 3, 3, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 2, 4, nil,
- nil, 3 ]
-
-racc_goto_pointer = [
- nil, 5, 0, -19, 0, -149, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- -1, nil, nil, -6, -25, -9, -28, -27, -26, -23,
- -99, -22, -21, -95, -18, -99, nil, nil, nil, nil,
- -27, nil, nil, -11, -13, -12, -11, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, -53, nil, -73, nil ]
-
-racc_goto_default = [
- nil, nil, 2, 3, 4, nil, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 20, 21,
- nil, 24, 25, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 163, 29, 30, 31,
- 32, 34, 35, 38, nil, nil, nil, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 64, 65, 66, 67,
- 68, 69, 70, 78, 79, nil, 132, nil, 131 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 54, :_reduce_none,
- 2, 54, :_reduce_2,
- 2, 55, :_reduce_3,
- 1, 55, :_reduce_4,
- 1, 55, :_reduce_5,
- 1, 57, :_reduce_none,
- 1, 57, :_reduce_none,
- 1, 58, :_reduce_none,
- 0, 58, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 56, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 2, 69, :_reduce_22,
- 1, 70, :_reduce_23,
- 1, 66, :_reduce_none,
- 1, 66, :_reduce_none,
- 1, 71, :_reduce_26,
- 3, 72, :_reduce_27,
- 1, 73, :_reduce_28,
- 3, 73, :_reduce_29,
- 1, 67, :_reduce_none,
- 1, 67, :_reduce_none,
- 1, 74, :_reduce_32,
- 3, 75, :_reduce_33,
- 1, 76, :_reduce_34,
- 3, 76, :_reduce_35,
- 3, 77, :_reduce_36,
- 1, 64, :_reduce_37,
- 1, 78, :_reduce_none,
- 1, 78, :_reduce_none,
- 1, 78, :_reduce_none,
- 3, 79, :_reduce_41,
- 3, 80, :_reduce_42,
- 2, 81, :_reduce_43,
- 1, 83, :_reduce_44,
- 5, 84, :_reduce_45,
- 1, 85, :_reduce_46,
- 1, 87, :_reduce_47,
- 1, 82, :_reduce_none,
- 1, 82, :_reduce_none,
- 1, 86, :_reduce_none,
- 3, 86, :_reduce_none,
- 1, 88, :_reduce_52,
- 3, 88, :_reduce_53,
- 1, 89, :_reduce_54,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 3, 90, :_reduce_58,
- 3, 90, :_reduce_59,
- 1, 91, :_reduce_60,
- 2, 92, :_reduce_61,
- 2, 92, :_reduce_62,
- 1, 93, :_reduce_none,
- 1, 93, :_reduce_none,
- 1, 95, :_reduce_65,
- 2, 96, :_reduce_66,
- 1, 97, :_reduce_none,
- 1, 97, :_reduce_none,
- 1, 98, :_reduce_none,
- 2, 98, :_reduce_none,
- 1, 99, :_reduce_none,
- 2, 99, :_reduce_none,
- 1, 94, :_reduce_73,
- 2, 94, :_reduce_74,
- 3, 60, :_reduce_75,
- 1, 65, :_reduce_76,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 3, 100, :_reduce_92,
- 3, 101, :_reduce_93,
- 3, 102, :_reduce_94,
- 3, 103, :_reduce_95,
- 3, 104, :_reduce_96,
- 3, 105, :_reduce_97,
- 3, 106, :_reduce_98,
- 3, 107, :_reduce_99,
- 3, 108, :_reduce_100,
- 3, 109, :_reduce_101,
- 3, 110, :_reduce_102,
- 3, 111, :_reduce_103,
- 3, 112, :_reduce_104,
- 3, 113, :_reduce_105,
- 3, 114, :_reduce_106,
- 1, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 2, 115, :_reduce_111,
- 2, 116, :_reduce_112,
- 2, 117, :_reduce_113,
- 2, 118, :_reduce_114,
- 1, 59, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 120, :_reduce_122,
- 1, 119, :_reduce_123,
- 1, 122, :_reduce_124,
- 1, 123, :_reduce_125,
- 1, 124, :_reduce_126,
- 1, 125, :_reduce_127,
- 1, 121, :_reduce_128,
- 1, 121, :_reduce_none,
- 1, 121, :_reduce_none,
- 3, 126, :_reduce_131,
- 3, 129, :_reduce_132,
- 1, 128, :_reduce_133,
- 2, 128, :_reduce_134,
- 1, 130, :_reduce_135,
- 1, 130, :_reduce_136,
- 2, 127, :_reduce_137,
- 1, 131, :_reduce_138,
- 2, 131, :_reduce_139 ]
-
-racc_reduce_n = 140
-
-racc_shift_n = 187
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :IDENTIFIER => 2,
- :EQUAL => 3,
- :PLUS => 4,
- :MINUS => 5,
- :ASTERISK => 6,
- :FWD_SLASH => 7,
- :COLON => 8,
- :FLOAT => 9,
- :INTEGER => 10,
- :STRING => 11,
- :EXPO => 12,
- :INDENT => 13,
- :OUTDENT => 14,
- :OPAREN => 15,
- :CPAREN => 16,
- :DOT => 17,
- :SIGNATURE => 18,
- :NL => 19,
- :EOF => 20,
- :PIPE => 21,
- :COMMA => 22,
- :NIL => 23,
- :TRUE => 24,
- :FALSE => 25,
- :EQUALITY => 26,
- :CALL => 27,
- :SELF => 28,
- :CONSTANT => 29,
- :CHAR => 30,
- :DOUBLE_TICK_STRING => 31,
- :DOUBLE_TICK_STRING_END => 32,
- :INTERPOLATE_START => 33,
- :INTERPOLATE_END => 34,
- :BOX => 35,
- :LSQUARE => 36,
- :RSQUARE => 37,
- :FACES => 38,
- :LFACE => 39,
- :RFACE => 40,
- :BANG => 41,
- :TILDE => 42,
- :RETURN => 43,
- :NOT_EQUALITY => 44,
- :OR => 45,
- :AND => 46,
- :GT => 47,
- :LT => 48,
- :GTE => 49,
- :LTE => 50,
- :AT => 51,
- :PERCENT => 52 }
-
-racc_nt_base = 53
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "IDENTIFIER",
- "EQUAL",
- "PLUS",
- "MINUS",
- "ASTERISK",
- "FWD_SLASH",
- "COLON",
- "FLOAT",
- "INTEGER",
- "STRING",
- "EXPO",
- "INDENT",
- "OUTDENT",
- "OPAREN",
- "CPAREN",
- "DOT",
- "SIGNATURE",
- "NL",
- "EOF",
- "PIPE",
- "COMMA",
- "NIL",
- "TRUE",
- "FALSE",
- "EQUALITY",
- "CALL",
- "SELF",
- "CONSTANT",
- "CHAR",
- "DOUBLE_TICK_STRING",
- "DOUBLE_TICK_STRING_END",
- "INTERPOLATE_START",
- "INTERPOLATE_END",
- "BOX",
- "LSQUARE",
- "RSQUARE",
- "FACES",
- "LFACE",
- "RFACE",
- "BANG",
- "TILDE",
- "RETURN",
- "NOT_EQUALITY",
- "OR",
- "AND",
- "GT",
- "LT",
- "GTE",
- "LTE",
- "AT",
- "PERCENT",
- "$start",
- "statements",
- "statement",
- "expr",
- "eol",
- "nlq",
- "literal",
- "grouped_expr",
- "binary_op",
- "unary_op",
- "method_call",
- "constant",
- "variable",
- "array",
- "hash",
- "return",
- "return_expr",
- "return_nil",
- "empty_array",
- "array_list",
- "array_items",
- "empty_hash",
- "hash_list",
- "hash_items",
- "hash_item",
- "indented",
- "indented_w_stmts",
- "indented_w_expr",
- "indented_wo_stmts",
- "indent",
- "outdent",
- "indent_w_args",
- "indent_pipe",
- "indent_args",
- "indent_wo_args",
- "indent_arg",
- "arg_var",
- "method_call_on_object",
- "method_call_on_self",
- "method_call_on_closure",
- "call_signature",
- "call_arguments",
- "call_simple_name",
- "call_argument",
- "call_passed_arg",
- "call_passed_simple",
- "call_passed_indented",
- "assignment",
- "addition",
- "subtraction",
- "multiplication",
- "division",
- "exponentiation",
- "modulo",
- "equality",
- "not_equality",
- "logical_or",
- "logical_and",
- "greater_than",
- "less_than",
- "greater_or_eq",
- "less_or_eq",
- "unary_not",
- "unary_plus",
- "unary_minus",
- "unary_complement",
- "integer",
- "float",
- "string",
- "nil",
- "true",
- "false",
- "self",
- "interpolated_string",
- "empty_string",
- "interpolated_string_contents",
- "interpolation",
- "interpolated_string_chunk",
- "chars" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-# reduce 1 omitted
-
-module_eval(<<'.,.,', 'huia.y', 44)
- def _reduce_2(val, _values, result)
- return scope
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 46)
- def _reduce_3(val, _values, result)
- return scope.append val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 47)
- def _reduce_4(val, _values, result)
- return scope.append val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 48)
- def _reduce_5(val, _values, result)
- return scope
- result
- end
-.,.,
-
-# reduce 6 omitted
-
-# reduce 7 omitted
-
-# reduce 8 omitted
-
-# reduce 9 omitted
-
-# reduce 10 omitted
-
-# reduce 11 omitted
-
-# reduce 12 omitted
-
-# reduce 13 omitted
-
-# reduce 14 omitted
-
-# reduce 15 omitted
-
-# reduce 16 omitted
-
-# reduce 17 omitted
-
-# reduce 18 omitted
-
-# reduce 19 omitted
-
-# reduce 20 omitted
-
-# reduce 21 omitted
-
-module_eval(<<'.,.,', 'huia.y', 66)
- def _reduce_22(val, _values, result)
- return n(:Return, val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 67)
- def _reduce_23(val, _values, result)
- return n(:Return, n(:Nil))
- result
- end
-.,.,
-
-# reduce 24 omitted
-
-# reduce 25 omitted
-
-module_eval(<<'.,.,', 'huia.y', 72)
- def _reduce_26(val, _values, result)
- return n :Array
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 74)
- def _reduce_27(val, _values, result)
- return val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 75)
- def _reduce_28(val, _values, result)
- return n :Array, [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 76)
- def _reduce_29(val, _values, result)
- val[0].append(val[2]); return val[0]
- result
- end
-.,.,
-
-# reduce 30 omitted
-
-# reduce 31 omitted
-
-module_eval(<<'.,.,', 'huia.y', 80)
- def _reduce_32(val, _values, result)
- return n :Hash
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 81)
- def _reduce_33(val, _values, result)
- return val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 82)
- def _reduce_34(val, _values, result)
- return n :Hash, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 83)
- def _reduce_35(val, _values, result)
- val[0].append(val[2]); return val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 84)
- def _reduce_36(val, _values, result)
- return n :HashItem, val[0], val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 86)
- def _reduce_37(val, _values, result)
- return constant val[0]
- result
- end
-.,.,
-
-# reduce 38 omitted
-
-# reduce 39 omitted
-
-# reduce 40 omitted
-
-module_eval(<<'.,.,', 'huia.y', 91)
- def _reduce_41(val, _values, result)
- return val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 92)
- def _reduce_42(val, _values, result)
- return val[0].append(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 93)
- def _reduce_43(val, _values, result)
- return val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 94)
- def _reduce_44(val, _values, result)
- return pop_scope
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 97)
- def _reduce_45(val, _values, result)
- return val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 98)
- def _reduce_46(val, _values, result)
- return push_scope
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 99)
- def _reduce_47(val, _values, result)
- return push_scope
- result
- end
-.,.,
-
-# reduce 48 omitted
-
-# reduce 49 omitted
-
-# reduce 50 omitted
-
-# reduce 51 omitted
-
-module_eval(<<'.,.,', 'huia.y', 105)
- def _reduce_52(val, _values, result)
- return scope.add_argument val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 106)
- def _reduce_53(val, _values, result)
- return n :Assignment, val[0], val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 107)
- def _reduce_54(val, _values, result)
- return n :Variable, val[0]
- result
- end
-.,.,
-
-# reduce 55 omitted
-
-# reduce 56 omitted
-
-# reduce 57 omitted
-
-module_eval(<<'.,.,', 'huia.y', 112)
- def _reduce_58(val, _values, result)
- return n :MethodCall, val[0], val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 113)
- def _reduce_59(val, _values, result)
- return n :MethodCall, val[0], n(:CallSignature, val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 114)
- def _reduce_60(val, _values, result)
- return n :MethodCall, scope_instance, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 116)
- def _reduce_61(val, _values, result)
- return n :MethodCall, this_closure, val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 117)
- def _reduce_62(val, _values, result)
- return n :MethodCall, this_closure, n(:CallSignature, val[1])
- result
- end
-.,.,
-
-# reduce 63 omitted
-
-# reduce 64 omitted
-
-module_eval(<<'.,.,', 'huia.y', 121)
- def _reduce_65(val, _values, result)
- return n :CallSignature, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 122)
- def _reduce_66(val, _values, result)
- return n :CallSignature, val[0], [val[1]]
- result
- end
-.,.,
-
-# reduce 67 omitted
-
-# reduce 68 omitted
-
-# reduce 69 omitted
-
-# reduce 70 omitted
-
-# reduce 71 omitted
-
-# reduce 72 omitted
-
-module_eval(<<'.,.,', 'huia.y', 129)
- def _reduce_73(val, _values, result)
- return val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 130)
- def _reduce_74(val, _values, result)
- return val[0].concat_signature val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 132)
- def _reduce_75(val, _values, result)
- return n :Expression, val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 134)
- def _reduce_76(val, _values, result)
- return allocate_local val[0]
- result
- end
-.,.,
-
-# reduce 77 omitted
-
-# reduce 78 omitted
-
-# reduce 79 omitted
-
-# reduce 80 omitted
-
-# reduce 81 omitted
-
-# reduce 82 omitted
-
-# reduce 83 omitted
-
-# reduce 84 omitted
-
-# reduce 85 omitted
-
-# reduce 86 omitted
-
-# reduce 87 omitted
-
-# reduce 88 omitted
-
-# reduce 89 omitted
-
-# reduce 90 omitted
-
-# reduce 91 omitted
-
-module_eval(<<'.,.,', 'huia.y', 152)
- def _reduce_92(val, _values, result)
- return allocate_local_assignment val[0], val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 153)
- def _reduce_93(val, _values, result)
- return binary val[0], val[2], 'plus:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 154)
- def _reduce_94(val, _values, result)
- return binary val[0], val[2], 'minus:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 155)
- def _reduce_95(val, _values, result)
- return binary val[0], val[2], 'multiplyBy:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 156)
- def _reduce_96(val, _values, result)
- return binary val[0], val[2], 'divideBy:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 157)
- def _reduce_97(val, _values, result)
- return binary val[0], val[2], 'toThePowerOf:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 158)
- def _reduce_98(val, _values, result)
- return binary val[0], val[2], 'moduloOf:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 159)
- def _reduce_99(val, _values, result)
- return binary val[0], val[2], 'isEqualTo:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 160)
- def _reduce_100(val, _values, result)
- return binary val[0], val[2], 'isNotEqualTo:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 161)
- def _reduce_101(val, _values, result)
- return binary val[0], val[2], 'logicalOr:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 162)
- def _reduce_102(val, _values, result)
- return binary val[0], val[2], 'logicalAnd:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 163)
- def _reduce_103(val, _values, result)
- return binary val[0], val[2], 'isGreaterThan:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 164)
- def _reduce_104(val, _values, result)
- return binary val[0], val[2], 'isLessThan:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 165)
- def _reduce_105(val, _values, result)
- return binary val[0], val[2], 'isGreaterOrEqualTo:'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 166)
- def _reduce_106(val, _values, result)
- return binary val[0], val[2], 'isLessOrEqualTo:'
- result
- end
-.,.,
-
-# reduce 107 omitted
-
-# reduce 108 omitted
-
-# reduce 109 omitted
-
-# reduce 110 omitted
-
-module_eval(<<'.,.,', 'huia.y', 173)
- def _reduce_111(val, _values, result)
- return unary val[1], 'unaryNot'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 174)
- def _reduce_112(val, _values, result)
- return unary val[1], 'unaryPlus'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 175)
- def _reduce_113(val, _values, result)
- return unary val[1], 'unaryMinus'
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 176)
- def _reduce_114(val, _values, result)
- return unary val[1], 'unaryComplement'
- result
- end
-.,.,
-
-# reduce 115 omitted
-
-# reduce 116 omitted
-
-# reduce 117 omitted
-
-# reduce 118 omitted
-
-# reduce 119 omitted
-
-# reduce 120 omitted
-
-# reduce 121 omitted
-
-module_eval(<<'.,.,', 'huia.y', 186)
- def _reduce_122(val, _values, result)
- return n :Float, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 187)
- def _reduce_123(val, _values, result)
- return n :Integer, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 188)
- def _reduce_124(val, _values, result)
- return n :Nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 189)
- def _reduce_125(val, _values, result)
- return n :True
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 190)
- def _reduce_126(val, _values, result)
- return n :False
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 191)
- def _reduce_127(val, _values, result)
- return n :Self
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 193)
- def _reduce_128(val, _values, result)
- return n :String, val[0]
- result
- end
-.,.,
-
-# reduce 129 omitted
-
-# reduce 130 omitted
-
-module_eval(<<'.,.,', 'huia.y', 197)
- def _reduce_131(val, _values, result)
- return val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 198)
- def _reduce_132(val, _values, result)
- return val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 199)
- def _reduce_133(val, _values, result)
- return n :InterpolatedString, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 200)
- def _reduce_134(val, _values, result)
- val[0].append(val[1]); return val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 201)
- def _reduce_135(val, _values, result)
- return val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 202)
- def _reduce_136(val, _values, result)
- return to_string(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 203)
- def _reduce_137(val, _values, result)
- return n :String, ''
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 205)
- def _reduce_138(val, _values, result)
- return n :String, val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'huia.y', 206)
- def _reduce_139(val, _values, result)
- val[0].append(val[1]); return val[0]
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module Huia
diff --git a/test/racc/regress/journey b/test/racc/regress/journey
deleted file mode 100644
index c532dd6eeb..0000000000
--- a/test/racc/regress/journey
+++ /dev/null
@@ -1,222 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-
-require 'journey/parser_extras'
-module Journey
- class Parser < Racc::Parser
-##### State transition tables begin ###
-
-racc_action_table = [
- 17, 21, 13, 15, 14, 7, nil, 16, 8, 19,
- 13, 15, 14, 7, 23, 16, 8, 19, 13, 15,
- 14, 7, nil, 16, 8, 13, 15, 14, 7, nil,
- 16, 8, 13, 15, 14, 7, nil, 16, 8 ]
-
-racc_action_check = [
- 1, 17, 1, 1, 1, 1, nil, 1, 1, 1,
- 20, 20, 20, 20, 20, 20, 20, 20, 0, 0,
- 0, 0, nil, 0, 0, 7, 7, 7, 7, nil,
- 7, 7, 19, 19, 19, 19, nil, 19, 19 ]
-
-racc_action_pointer = [
- 16, 0, nil, nil, nil, nil, nil, 23, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 1, nil, 30,
- 8, nil, nil, nil ]
-
-racc_action_default = [
- -18, -18, -2, -3, -4, -5, -6, -18, -9, -10,
- -11, -12, -13, -14, -15, -16, -17, -18, -1, -18,
- -18, 24, -8, -7 ]
-
-racc_goto_table = [
- 18, 1, nil, nil, nil, nil, nil, nil, 20, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 22, 18 ]
-
-racc_goto_check = [
- 2, 1, nil, nil, nil, nil, nil, nil, 1, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 2, 2 ]
-
-racc_goto_pointer = [
- nil, 1, -1, nil, nil, nil, nil, nil, nil, nil,
- nil ]
-
-racc_goto_default = [
- nil, nil, 2, 3, 4, 5, 6, 9, 10, 11,
- 12 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 2, 11, :_reduce_1,
- 1, 11, :_reduce_2,
- 1, 11, :_reduce_none,
- 1, 12, :_reduce_none,
- 1, 12, :_reduce_none,
- 1, 12, :_reduce_none,
- 3, 15, :_reduce_7,
- 3, 13, :_reduce_8,
- 1, 16, :_reduce_9,
- 1, 14, :_reduce_none,
- 1, 14, :_reduce_none,
- 1, 14, :_reduce_none,
- 1, 14, :_reduce_none,
- 1, 19, :_reduce_14,
- 1, 17, :_reduce_15,
- 1, 18, :_reduce_16,
- 1, 20, :_reduce_17 ]
-
-racc_reduce_n = 18
-
-racc_shift_n = 24
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :SLASH => 2,
- :LITERAL => 3,
- :SYMBOL => 4,
- :LPAREN => 5,
- :RPAREN => 6,
- :DOT => 7,
- :STAR => 8,
- :OR => 9 }
-
-racc_nt_base = 10
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "SLASH",
- "LITERAL",
- "SYMBOL",
- "LPAREN",
- "RPAREN",
- "DOT",
- "STAR",
- "OR",
- "$start",
- "expressions",
- "expression",
- "or",
- "terminal",
- "group",
- "star",
- "symbol",
- "literal",
- "slash",
- "dot" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'journey.y', 6)
- def _reduce_1(val, _values, result)
- result = Cat.new(val.first, val.last)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'journey.y', 7)
- def _reduce_2(val, _values, result)
- result = val.first
- result
- end
-.,.,
-
-# reduce 3 omitted
-
-# reduce 4 omitted
-
-# reduce 5 omitted
-
-# reduce 6 omitted
-
-module_eval(<<'.,.,', 'journey.y', 16)
- def _reduce_7(val, _values, result)
- result = Group.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'journey.y', 19)
- def _reduce_8(val, _values, result)
- result = Or.new([val.first, val.last])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'journey.y', 22)
- def _reduce_9(val, _values, result)
- result = Star.new(Symbol.new(val.last))
- result
- end
-.,.,
-
-# reduce 10 omitted
-
-# reduce 11 omitted
-
-# reduce 12 omitted
-
-# reduce 13 omitted
-
-module_eval(<<'.,.,', 'journey.y', 31)
- def _reduce_14(val, _values, result)
- result = Slash.new('/')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'journey.y', 34)
- def _reduce_15(val, _values, result)
- result = Symbol.new(val.first)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'journey.y', 37)
- def _reduce_16(val, _values, result)
- result = Literal.new(val.first)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'journey.y', 39)
- def _reduce_17(val, _values, result)
- result = Dot.new(val.first)
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module Journey
diff --git a/test/racc/regress/liquor b/test/racc/regress/liquor
deleted file mode 100644
index 4dec55c976..0000000000
--- a/test/racc/regress/liquor
+++ /dev/null
@@ -1,885 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-module Liquor
- class Parser < Racc::Parser
-
-module_eval(<<'...end liquor.y/module_eval...', 'liquor.y', 216)
- attr_reader :errors, :ast
-
- def initialize(tags={})
- super()
-
- @errors = []
- @ast = nil
- @tags = tags
- end
-
- def success?
- @errors.empty?
- end
-
- def parse(string, name='(code)')
- @errors.clear
- @name = name
- @ast = nil
-
- begin
- @stream = Lexer.lex(string, @name, @tags)
- @ast = do_parse
- rescue Liquor::SyntaxError => e
- @errors << e
- end
-
- success?
- end
-
- def next_token
- tok = @stream.shift
- [ tok[0], tok ] if tok
- end
-
- TOKEN_NAME_MAP = {
- :comma => ',',
- :dot => '.',
- :lblock => '{%',
- :rblock => '%}',
- :linterp => '{{',
- :rinterp => '}}',
- :lbracket => '[',
- :rbracket => ']',
- :lparen => '(',
- :rparen => ')',
- :pipe => '|',
- :op_not => '!',
- :op_mul => '*',
- :op_div => '/',
- :op_mod => '%',
- :op_plus => '+',
- :op_minus => '-',
- :op_eq => '==',
- :op_neq => '!=',
- :op_lt => '<',
- :op_leq => '<=',
- :op_gt => '>',
- :op_geq => '>=',
- :keyword => 'keyword argument name',
- :kwarg => 'keyword argument',
- :ident => 'identifier',
- }
-
- def on_error(error_token_id, error_token, value_stack)
- if token_to_str(error_token_id) == "$end"
- raise Liquor::SyntaxError.new("unexpected end of program", {
- file: @name
- })
- else
- type, (loc, value) = error_token
- type = TOKEN_NAME_MAP[type] || type
-
- raise Liquor::SyntaxError.new("unexpected token `#{type}'", loc)
- end
- end
-
- def retag(nodes)
- loc = nodes.map { |node| node[1] }.compact
- first, *, last = loc
- return first if last.nil?
-
- {
- file: first[:file],
- line: first[:line],
- start: first[:start],
- end: last[:end],
- }
- end
-
- def reduce_tag_args(list)
- list.each_slice(2).reduce([]) { |args, (k, v)|
- if v[0] == :block
- args << [ :blockarg, retag([ k, v ]), k, v[2] || [] ]
- else
- args << [ :kwarg, retag([ k, v ]), k, v ]
- end
- }
- end
-...end liquor.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 76, 26, 26, 6, 77, 70, 5, 6, 25, 25,
- 5, 28, 32, 36, 37, 34, 35, 31, 29, 27,
- 33, 2, 30, 26, 26, 2, 6, 43, 52, 5,
- 25, 25, 38, 39, 28, 32, 36, 37, 34, 35,
- 31, 29, 27, 33, 2, 30, 26, 94, 51, 98,
- 26, 96, 26, 25, 97, 38, 39, 25, 111, 25,
- 28, 32, 36, 37, 34, 35, 31, 29, 27, 33,
- 41, 30, 26, 26, 43, 6, 107, 74, 5, 25,
- 25, 38, 39, 28, 32, 36, 37, 34, 35, 31,
- 29, 27, 33, 2, 30, 7, 26, 70, 6, 96,
- 102, 5, 97, 25, 38, 39, 28, 32, 36, 37,
- 34, 35, 31, 29, 27, 33, 2, 30, 54, 26,
- 74, 6, 96, 74, 5, 97, 25, 38, 39, 28,
- 32, 36, 37, 34, 35, 31, 29, 27, 33, 2,
- 30, 87, 26, 96, 6, 22, 97, 5, 84, 25,
- 38, 39, 28, 32, 36, 37, 34, 35, 31, 29,
- 27, 33, 2, 30, 40, 26, 23, nil, 24, nil,
- nil, nil, 25, 38, 39, 28, 32, 36, 37, 34,
- 35, 31, 29, 27, 33, nil, 30, nil, 26, nil,
- 82, nil, 52, nil, nil, 25, 38, 39, 28, 32,
- 36, 37, 34, 35, 31, 29, 27, 33, nil, 30,
- nil, 26, 51, nil, nil, nil, nil, nil, 25, 38,
- 39, 28, 32, 36, 37, 34, 35, 31, 29, 27,
- 33, nil, 30, nil, 26, nil, nil, nil, 75, nil,
- nil, 25, 38, 39, 28, 32, 36, 37, 34, 35,
- 31, 29, 27, 33, nil, 30, 13, 15, nil, 13,
- 15, 21, nil, 14, 21, 38, 14, nil, nil, nil,
- 18, nil, nil, 18, 19, nil, nil, 19, nil, 13,
- 15, nil, 16, nil, 21, 16, 14, nil, nil, 13,
- 15, nil, nil, 18, 21, nil, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, 74, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, 52, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, 51, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, 81, nil, 18, 21, 16, 14, 19, nil, 13,
- 15, nil, 26, 18, 21, 16, 14, 19, nil, 25,
- nil, 101, 28, 18, nil, 16, 26, 19, nil, 29,
- 27, 106, nil, 25, nil, 16, 28, 32, 36, 37,
- 34, 35, 31, 29, 27, 33, 26, 30, nil, nil,
- nil, nil, nil, 25, nil, nil, 28, nil, 26, nil,
- nil, nil, 31, 29, 27, 25, nil, 30, 28, nil,
- 26, nil, nil, nil, 31, 29, 27, 25, nil, 30,
- 28, nil, 26, nil, nil, nil, 31, 29, 27, 25,
- nil, 30, 28, nil, 26, nil, nil, nil, 31, 29,
- 27, 25, nil, 30, 28, nil, 26, nil, nil, nil,
- 31, 29, 27, 25, nil, 30, 28, nil, 26, nil,
- nil, nil, 31, 29, 27, 25, nil, 30, 28, nil,
- nil, nil, nil, nil, nil, 29, 27 ]
-
-racc_action_check = [
- 47, 47, 55, 101, 48, 84, 101, 4, 47, 55,
- 4, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 101, 47, 56, 79, 4, 0, 54, 79, 0,
- 56, 79, 47, 47, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 0, 79, 57, 91, 79, 96,
- 104, 104, 45, 57, 104, 79, 79, 104, 109, 45,
- 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
- 12, 104, 46, 71, 13, 2, 103, 71, 2, 46,
- 71, 104, 104, 71, 71, 71, 71, 71, 71, 71,
- 71, 71, 71, 2, 71, 1, 99, 40, 3, 107,
- 99, 3, 107, 99, 71, 71, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 3, 99, 26, 88,
- 70, 81, 94, 88, 81, 94, 88, 99, 99, 88,
- 88, 88, 88, 88, 88, 88, 88, 88, 88, 81,
- 88, 72, 11, 111, 106, 6, 111, 106, 69, 11,
- 88, 88, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 106, 11, 11, 53, 7, nil, 11, nil,
- nil, nil, 53, 11, 11, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, nil, 53, nil, 49, nil,
- 53, nil, 49, nil, nil, 49, 53, 53, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, nil, 49,
- nil, 44, 49, nil, nil, nil, nil, nil, 44, 49,
- 49, 44, 44, 44, 44, 44, 44, 44, 44, 44,
- 44, nil, 44, nil, 67, nil, nil, nil, 44, nil,
- nil, 67, 44, 44, 67, 67, 67, 67, 67, 67,
- 67, 67, 67, 67, nil, 67, 30, 30, nil, 31,
- 31, 30, nil, 30, 31, 67, 31, nil, nil, nil,
- 30, nil, nil, 31, 30, nil, nil, 31, nil, 32,
- 32, nil, 30, nil, 32, 31, 32, nil, nil, 33,
- 33, nil, nil, 32, 33, nil, 33, 32, nil, 34,
- 34, nil, nil, 33, 34, 32, 34, 33, nil, 35,
- 35, nil, nil, 34, 35, 33, 35, 34, nil, 36,
- 36, nil, nil, 35, 36, 34, 36, 35, nil, 37,
- 37, nil, nil, 36, 37, 35, 37, 36, nil, 38,
- 38, nil, nil, 37, 38, 36, 38, 37, nil, 39,
- 39, nil, nil, 38, 39, 37, 39, 38, nil, 43,
- 43, 43, nil, 39, 43, 38, 43, 39, nil, 74,
- 74, nil, nil, 43, 74, 39, 74, 43, nil, 5,
- 5, nil, nil, 74, 5, 43, 5, 74, nil, 14,
- 14, nil, nil, 5, 14, 74, 14, 5, nil, 18,
- 18, nil, nil, 14, 18, 5, 18, 14, nil, 19,
- 19, nil, nil, 18, 19, 14, 19, 18, nil, 21,
- 21, nil, nil, 19, 21, 18, 21, 19, nil, 22,
- 22, 22, nil, 21, 22, 19, 22, 21, nil, 25,
- 25, nil, nil, 22, 25, 21, 25, 22, nil, 27,
- 27, 22, nil, 25, 27, 22, 27, 25, nil, 28,
- 28, nil, nil, 27, 28, 25, 28, 27, nil, 29,
- 29, nil, nil, 28, 29, 27, 29, 28, nil, 52,
- 52, nil, nil, 29, 52, 28, 52, 29, nil, 76,
- 76, nil, nil, 52, 76, 29, 76, 52, nil, 97,
- 97, 52, nil, 76, 97, 52, 97, 76, nil, 102,
- 102, nil, 58, 97, 102, 76, 102, 97, nil, 58,
- nil, 97, 58, 102, nil, 97, 66, 102, nil, 58,
- 58, 102, nil, 66, nil, 102, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 60, 66, nil, nil,
- nil, nil, nil, 60, nil, nil, 60, nil, 61, nil,
- nil, nil, 60, 60, 60, 61, nil, 60, 61, nil,
- 62, nil, nil, nil, 61, 61, 61, 62, nil, 61,
- 62, nil, 63, nil, nil, nil, 62, 62, 62, 63,
- nil, 62, 63, nil, 64, nil, nil, nil, 63, 63,
- 63, 64, nil, 63, 64, nil, 65, nil, nil, nil,
- 64, 64, 64, 65, nil, 64, 65, nil, 59, nil,
- nil, nil, 65, 65, 65, 59, nil, 65, 59, nil,
- nil, nil, nil, nil, nil, 59, 59 ]
-
-racc_action_pointer = [
- 18, 95, 67, 90, -1, 374, 140, 166, nil, nil,
- nil, 139, 41, 62, 384, nil, nil, nil, 394, 404,
- nil, 414, 424, nil, nil, 434, 113, 444, 454, 464,
- 251, 254, 274, 284, 294, 304, 314, 324, 334, 344,
- 92, nil, nil, 354, 208, 49, 69, -2, -24, 185,
- nil, nil, 474, 162, 15, -1, 20, 43, 509, 615,
- 543, 555, 567, 579, 591, 603, 523, 231, nil, 123,
- 113, 70, 111, nil, 364, nil, 484, nil, nil, 21,
- nil, 113, nil, nil, 0, nil, nil, nil, 116, nil,
- nil, 38, nil, nil, 118, nil, 22, 494, nil, 93,
- nil, -5, 504, 67, 47, nil, 136, 95, nil, 49,
- nil, 139, nil ]
-
-racc_action_default = [
- -1, -57, -1, -1, -1, -57, -57, -57, -2, -3,
- -4, -57, -57, -7, -57, -9, -10, -11, -57, -57,
- -31, -35, -57, 113, -5, -57, -57, -57, -57, -57,
- -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
- -57, -6, -12, -40, -57, -16, -17, -34, -57, -57,
- -46, -47, -57, -57, -15, -18, -19, -20, -21, -22,
- -23, -24, -25, -26, -27, -28, -29, -30, -41, -43,
- -40, -40, -57, -38, -57, -8, -35, -32, -45, -57,
- -48, -1, -13, -14, -57, -44, -37, -36, -40, -33,
- -50, -57, -42, -39, -57, -49, -57, -57, -51, -57,
- -52, -1, -57, -57, -57, -54, -1, -57, -56, -57,
- -53, -57, -55 ]
-
-racc_goto_table = [
- 1, 11, 8, 9, 10, 48, 68, 100, 42, 50,
- 44, 72, 105, 73, 45, 46, 12, 80, 49, nil,
- nil, 53, nil, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 78, nil, nil, 71,
- 85, 86, 95, nil, nil, nil, nil, nil, 79, 83,
- 92, nil, 108, nil, nil, 110, nil, nil, 93, 112,
- 89, nil, nil, nil, nil, nil, 90, nil, nil, nil,
- 88, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 91, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 99, nil, nil, nil, nil, 104, nil,
- nil, 103, nil, nil, nil, nil, 109 ]
-
-racc_goto_check = [
- 1, 4, 1, 1, 1, 9, 12, 17, 8, 14,
- 4, 10, 18, 11, 4, 4, 5, 15, 4, nil,
- nil, 4, nil, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 14, nil, nil, 4,
- 11, 11, 16, nil, nil, nil, nil, nil, 4, 8,
- 12, nil, 16, nil, nil, 16, nil, nil, 11, 16,
- 9, nil, nil, nil, nil, nil, 14, nil, nil, nil,
- 4, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 1, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 4, nil, nil, nil, nil, 4, nil,
- nil, 1, nil, nil, nil, nil, 1 ]
-
-racc_goto_pointer = [
- nil, 0, nil, nil, -4, 11, nil, nil, -5, -16,
- -32, -30, -34, nil, -13, -35, -52, -90, -90 ]
-
-racc_goto_default = [
- nil, nil, 3, 4, 47, nil, 20, 17, nil, nil,
- nil, nil, nil, 69, nil, nil, nil, nil, nil ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 0, 37, :_reduce_1,
- 2, 37, :_reduce_2,
- 2, 37, :_reduce_3,
- 2, 37, :_reduce_4,
- 3, 38, :_reduce_5,
- 3, 38, :_reduce_6,
- 1, 42, :_reduce_none,
- 3, 42, :_reduce_8,
- 1, 40, :_reduce_none,
- 1, 40, :_reduce_none,
- 1, 40, :_reduce_none,
- 2, 40, :_reduce_12,
- 4, 40, :_reduce_13,
- 4, 40, :_reduce_14,
- 3, 40, :_reduce_15,
- 2, 40, :_reduce_16,
- 2, 40, :_reduce_17,
- 3, 40, :_reduce_18,
- 3, 40, :_reduce_19,
- 3, 40, :_reduce_20,
- 3, 40, :_reduce_21,
- 3, 40, :_reduce_22,
- 3, 40, :_reduce_23,
- 3, 40, :_reduce_24,
- 3, 40, :_reduce_25,
- 3, 40, :_reduce_26,
- 3, 40, :_reduce_27,
- 3, 40, :_reduce_28,
- 3, 40, :_reduce_29,
- 3, 40, :_reduce_30,
- 1, 40, :_reduce_none,
- 3, 43, :_reduce_32,
- 3, 45, :_reduce_33,
- 1, 45, :_reduce_34,
- 0, 45, :_reduce_35,
- 3, 44, :_reduce_36,
- 2, 46, :_reduce_37,
- 1, 46, :_reduce_38,
- 3, 47, :_reduce_39,
- 0, 47, :_reduce_40,
- 3, 41, :_reduce_41,
- 3, 48, :_reduce_42,
- 1, 48, :_reduce_43,
- 2, 49, :_reduce_44,
- 4, 39, :_reduce_45,
- 3, 39, :_reduce_46,
- 1, 50, :_reduce_47,
- 2, 50, :_reduce_48,
- 4, 51, :_reduce_49,
- 2, 51, :_reduce_50,
- 2, 52, :_reduce_51,
- 2, 52, :_reduce_52,
- 4, 53, :_reduce_53,
- 3, 53, :_reduce_54,
- 4, 54, :_reduce_55,
- 2, 54, :_reduce_56 ]
-
-racc_reduce_n = 57
-
-racc_shift_n = 113
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :comma => 2,
- :dot => 3,
- :endtag => 4,
- :ident => 5,
- :integer => 6,
- :keyword => 7,
- :lblock => 8,
- :lblock2 => 9,
- :lbracket => 10,
- :linterp => 11,
- :lparen => 12,
- :op_div => 13,
- :op_eq => 14,
- :op_gt => 15,
- :op_geq => 16,
- :op_lt => 17,
- :op_leq => 18,
- :op_minus => 19,
- :op_mod => 20,
- :op_mul => 21,
- :op_neq => 22,
- :op_not => 23,
- :op_plus => 24,
- :pipe => 25,
- :plaintext => 26,
- :rblock => 27,
- :rbracket => 28,
- :rinterp => 29,
- :rparen => 30,
- :string => 31,
- :tag_ident => 32,
- :op_uminus => 33,
- :op_and => 34,
- :op_or => 35 }
-
-racc_nt_base = 36
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "comma",
- "dot",
- "endtag",
- "ident",
- "integer",
- "keyword",
- "lblock",
- "lblock2",
- "lbracket",
- "linterp",
- "lparen",
- "op_div",
- "op_eq",
- "op_gt",
- "op_geq",
- "op_lt",
- "op_leq",
- "op_minus",
- "op_mod",
- "op_mul",
- "op_neq",
- "op_not",
- "op_plus",
- "pipe",
- "plaintext",
- "rblock",
- "rbracket",
- "rinterp",
- "rparen",
- "string",
- "tag_ident",
- "op_uminus",
- "op_and",
- "op_or",
- "$start",
- "block",
- "interp",
- "tag",
- "expr",
- "filter_chain",
- "primary_expr",
- "tuple",
- "function_args",
- "tuple_content",
- "function_args_inside",
- "function_keywords",
- "filter_chain_cont",
- "filter_call",
- "tag_first_cont",
- "tag_first_cont2",
- "tag_next_cont",
- "tag_next_cont2",
- "tag_next_cont3" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'liquor.y', 47)
- def _reduce_1(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 49)
- def _reduce_2(val, _values, result)
- result = [ val[0], *val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 51)
- def _reduce_3(val, _values, result)
- result = [ val[0], *val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 53)
- def _reduce_4(val, _values, result)
- result = [ val[0], *val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 57)
- def _reduce_5(val, _values, result)
- result = [ :interp, retag(val), val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 59)
- def _reduce_6(val, _values, result)
- result = [ :interp, retag(val), val[1] ]
- result
- end
-.,.,
-
-# reduce 7 omitted
-
-module_eval(<<'.,.,', 'liquor.y', 64)
- def _reduce_8(val, _values, result)
- result = [ val[1][0], retag(val), *val[1][2..-1] ]
- result
- end
-.,.,
-
-# reduce 9 omitted
-
-# reduce 10 omitted
-
-# reduce 11 omitted
-
-module_eval(<<'.,.,', 'liquor.y', 71)
- def _reduce_12(val, _values, result)
- result = [ :call, retag(val), val[0], val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 73)
- def _reduce_13(val, _values, result)
- result = [ :index, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 75)
- def _reduce_14(val, _values, result)
- result = [ :external, retag(val), val[0], val[2], val[3] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 77)
- def _reduce_15(val, _values, result)
- result = [ :external, retag(val), val[0], val[2], nil ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 79)
- def _reduce_16(val, _values, result)
- result = [ :uminus, retag(val), val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 81)
- def _reduce_17(val, _values, result)
- result = [ :not, retag(val), val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 83)
- def _reduce_18(val, _values, result)
- result = [ :mul, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 85)
- def _reduce_19(val, _values, result)
- result = [ :div, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 87)
- def _reduce_20(val, _values, result)
- result = [ :mod, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 89)
- def _reduce_21(val, _values, result)
- result = [ :plus, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 91)
- def _reduce_22(val, _values, result)
- result = [ :minus, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 93)
- def _reduce_23(val, _values, result)
- result = [ :eq, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 95)
- def _reduce_24(val, _values, result)
- result = [ :neq, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 97)
- def _reduce_25(val, _values, result)
- result = [ :lt, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 99)
- def _reduce_26(val, _values, result)
- result = [ :leq, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 101)
- def _reduce_27(val, _values, result)
- result = [ :gt, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 103)
- def _reduce_28(val, _values, result)
- result = [ :geq, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 105)
- def _reduce_29(val, _values, result)
- result = [ :and, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 107)
- def _reduce_30(val, _values, result)
- result = [ :or, retag(val), val[0], val[2] ]
- result
- end
-.,.,
-
-# reduce 31 omitted
-
-module_eval(<<'.,.,', 'liquor.y', 112)
- def _reduce_32(val, _values, result)
- result = [ :tuple, retag(val), val[1].compact ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 116)
- def _reduce_33(val, _values, result)
- result = [ val[0], *val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 118)
- def _reduce_34(val, _values, result)
- result = [ val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 120)
- def _reduce_35(val, _values, result)
- result = [ ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 124)
- def _reduce_36(val, _values, result)
- result = [ :args, retag(val), *val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 128)
- def _reduce_37(val, _values, result)
- result = [ val[0], val[1][2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 130)
- def _reduce_38(val, _values, result)
- result = [ nil, val[0][2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 134)
- def _reduce_39(val, _values, result)
- name = val[0][2].to_sym
- tail = val[2][2]
- loc = retag([ val[0], val[1] ])
-
- if tail.include? name
- @errors << SyntaxError.new("duplicate keyword argument `#{val[0][2]}'",
- tail[name][1])
- end
-
- hash = {
- name => [ val[1][0], loc, *val[1][2..-1] ]
- }.merge(tail)
-
- result = [ :keywords, retag([ loc, val[2] ]), hash ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 150)
- def _reduce_40(val, _values, result)
- result = [ :keywords, nil, {} ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 154)
- def _reduce_41(val, _values, result)
- result = [ val[0], *val[2] ].
- reduce { |tree, node| node[3][2] = tree; node }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 160)
- def _reduce_42(val, _values, result)
- result = [ val[0], *val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 162)
- def _reduce_43(val, _values, result)
- result = [ val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 166)
- def _reduce_44(val, _values, result)
- ident_loc = val[0][1]
- empty_args_loc = { line: ident_loc[:line],
- start: ident_loc[:end] + 1,
- end: ident_loc[:end] + 1, }
- result = [ :call, val[0][1], val[0],
- [ :args, val[1][1] || empty_args_loc, nil, val[1][2] ] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 176)
- def _reduce_45(val, _values, result)
- result = [ :tag, retag(val), val[1], val[2], *reduce_tag_args(val[3][2]) ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 178)
- def _reduce_46(val, _values, result)
- result = [ :tag, retag(val), val[1], nil, *reduce_tag_args(val[2][2]) ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 186)
- def _reduce_47(val, _values, result)
- result = [ :cont, retag(val), [] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 188)
- def _reduce_48(val, _values, result)
- result = [ :cont, retag(val), [ val[0], *val[1][2] ] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 192)
- def _reduce_49(val, _values, result)
- result = [ :cont2, val[0][1], [ [:block, val[0][1], val[1] ], *val[3] ] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 194)
- def _reduce_50(val, _values, result)
- result = [ :cont2, retag(val), [ val[0], *val[1][2] ] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 198)
- def _reduce_51(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 200)
- def _reduce_52(val, _values, result)
- result = [ val[0], *val[1] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 204)
- def _reduce_53(val, _values, result)
- result = [ [:block, val[0][1], val[1] ], *val[3] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 206)
- def _reduce_54(val, _values, result)
- result = [ val[0], val[1], *val[2] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 210)
- def _reduce_55(val, _values, result)
- result = [ [:block, val[0][1], val[1] ], *val[3] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'liquor.y', 212)
- def _reduce_56(val, _values, result)
- result = [ val[0], *val[1] ]
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module Liquor
diff --git a/test/racc/regress/machete b/test/racc/regress/machete
deleted file mode 100644
index 08e4cb3a6f..0000000000
--- a/test/racc/regress/machete
+++ /dev/null
@@ -1,833 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-module Machete
- class Parser < Racc::Parser
-
-module_eval(<<'...end machete.y/module_eval...', 'machete.y', 175)
-
-include Matchers
-
-class SyntaxError < StandardError; end
-
-def parse(input)
- @input = input
- @pos = 0
-
- do_parse
-end
-
-private
-
-def integer_value(value)
- if value =~ /^0[bB]/
- value[2..-1].to_i(2)
- elsif value =~ /^0[oO]/
- value[2..-1].to_i(8)
- elsif value =~ /^0[dD]/
- value[2..-1].to_i(10)
- elsif value =~ /^0[xX]/
- value[2..-1].to_i(16)
- elsif value =~ /^0/
- value.to_i(8)
- else
- value.to_i
- end
-end
-
-def symbol_value(value)
- value[1..-1].to_sym
-end
-
-def string_value(value)
- quote = value[0..0]
- if quote == "'"
- value[1..-2].gsub("\\\\", "\\").gsub("\\'", "'")
- elsif quote == '"'
- value[1..-2].
- gsub("\\\\", "\\").
- gsub('\\"', '"').
- gsub("\\n", "\n").
- gsub("\\t", "\t").
- gsub("\\r", "\r").
- gsub("\\f", "\f").
- gsub("\\v", "\v").
- gsub("\\a", "\a").
- gsub("\\e", "\e").
- gsub("\\b", "\b").
- gsub("\\s", "\s").
- gsub(/\\([0-7]{1,3})/) { $1.to_i(8).chr }.
- gsub(/\\x([0-9a-fA-F]{1,2})/) { $1.to_i(16).chr }
- else
- raise "Unknown quote: #{quote.inspect}."
- end
-end
-
-REGEXP_OPTIONS = {
- 'i' => Regexp::IGNORECASE,
- 'm' => Regexp::MULTILINE,
- 'x' => Regexp::EXTENDED
-}
-
-def regexp_value(value)
- /\A\/(.*)\/([imx]*)\z/ =~ value
- pattern, options = $1, $2
-
- Regexp.new(pattern, options.chars.map { |ch| REGEXP_OPTIONS[ch] }.inject(:|))
-end
-
-# "^" needs to be here because if it were among operators recognized by
-# METHOD_NAME, "^=" would be recognized as two tokens.
-SIMPLE_TOKENS = [
- "|",
- "<",
- ">",
- ",",
- "=",
- "^=",
- "^",
- "$=",
- "[",
- "]",
- "*=",
- "*",
- "+",
- "?",
- "{",
- "}"
-]
-
-COMPLEX_TOKENS = [
- [:NIL, /^nil/],
- [:TRUE, /^true/],
- [:FALSE, /^false/],
- # INTEGER needs to be before METHOD_NAME, otherwise e.g. "+1" would be
- # recognized as two tokens.
- [
- :INTEGER,
- /^
- [+-]? # sign
- (
- 0[bB][01]+(_[01]+)* # binary (prefixed)
- |
- 0[oO][0-7]+(_[0-7]+)* # octal (prefixed)
- |
- 0[dD]\d+(_\d+)* # decimal (prefixed)
- |
- 0[xX][0-9a-fA-F]+(_[0-9a-fA-F]+)* # hexadecimal (prefixed)
- |
- 0[0-7]*(_[0-7]+)* # octal (unprefixed)
- |
- [1-9]\d*(_\d+)* # decimal (unprefixed)
- )
- /x
- ],
- [
- :SYMBOL,
- /^
- :
- (
- # class name
- [A-Z][a-zA-Z0-9_]*
- |
- # regular method name
- [a-z_][a-zA-Z0-9_]*[?!=]?
- |
- # instance variable name
- @[a-zA-Z_][a-zA-Z0-9_]*
- |
- # class variable name
- @@[a-zA-Z_][a-zA-Z0-9_]*
- |
- # operator (sorted by length, then alphabetically)
- (<=>|===|\[\]=|\*\*|\+@|-@|<<|<=|==|=~|>=|>>|\[\]|[%&*+\-\/<>^`|~])
- )
- /x
- ],
- [
- :STRING,
- /^
- (
- ' # sinqle-quoted string
- (
- \\[\\'] # escape
- |
- [^'] # regular character
- )*
- '
- |
- " # double-quoted string
- (
- \\ # escape
- (
- [\\"ntrfvaebs] # one-character escape
- |
- [0-7]{1,3} # octal number escape
- |
- x[0-9a-fA-F]{1,2} # hexadecimal number escape
- )
- |
- [^"] # regular character
- )*
- "
- )
- /x
- ],
- [
- :REGEXP,
- /^
- \/
- (
- \\ # escape
- (
- [\\\/ntrfvaebs\(\)\[\]\{\}\-\.\?\*\+\|\^\$] # one-character escape
- |
- [0-7]{2,3} # octal number escape
- |
- x[0-9a-fA-F]{1,2} # hexadecimal number escape
- )
- |
- [^\/] # regular character
- )*
- \/
- [imx]*
- /x
- ],
- # ANY, EVEN and ODD need to be before METHOD_NAME, otherwise they would be
- # recognized as method names.
- [:ANY, /^any/],
- [:EVEN, /^even/],
- [:ODD, /^odd/],
- # We exclude "*", "+", "<", ">", "^" and "|" from method names since they are
- # lexed as simple tokens. This is because they have also other meanings in
- # Machette patterns beside Ruby method names.
- [
- :METHOD_NAME,
- /^
- (
- # regular name
- [a-z_][a-zA-Z0-9_]*[?!=]?
- |
- # operator (sorted by length, then alphabetically)
- (<=>|===|\[\]=|\*\*|\+@|-@|<<|<=|==|=~|>=|>>|\[\]|[%&\-\/`~])
- )
- /x
- ],
- [:CLASS_NAME, /^[A-Z][a-zA-Z0-9_]*/]
-]
-
-def next_token
- skip_whitespace
-
- return false if remaining_input.empty?
-
- # Complex tokens need to be before simple tokens, otherwise e.g. "<<" would be
- # recognized as two tokens.
-
- COMPLEX_TOKENS.each do |type, regexp|
- if remaining_input =~ regexp
- @pos += $&.length
- return [type, $&]
- end
- end
-
- SIMPLE_TOKENS.each do |token|
- if remaining_input[0...token.length] == token
- @pos += token.length
- return [token, token]
- end
- end
-
- raise SyntaxError, "Unexpected character: #{remaining_input[0..0].inspect}."
-end
-
-def skip_whitespace
- if remaining_input =~ /\A^[ \t\r\n]+/
- @pos += $&.length
- end
-end
-
-def remaining_input
- @input[@pos..-1]
-end
-
-def on_error(error_token_id, error_value, value_stack)
- raise SyntaxError, "Unexpected token: #{error_value.inspect}."
-end
-...end machete.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 75, 24, 9, 10, 11, 12, 13, 14, 15, 16,
- 66, 67, 68, 7, 48, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 74, 8, 7, 76, 9, 10,
- 11, 12, 13, 14, 15, 16, 71, 18, 8, 7,
- 72, 9, 10, 11, 12, 13, 14, 15, 16, 73,
- 70, 8, 7, 19, 9, 10, 11, 12, 13, 14,
- 15, 16, 69, 18, 8, 7, 30, 31, 32, 51,
- 52, 53, 54, 33, 34, 35, 29, 8, 41, 38,
- 39, 77, 30, 31, 32, 47, 36, 37, 40, 33,
- 34, 35, 29, nil, 41, 38, 39, 18, 49, 50,
- 62, 63, 36, 37, 40, 43, 44, 55, 64, 65,
- 45, 46, 57, 58, nil, nil, nil, nil, nil, 56 ]
-
-racc_action_check = [
- 70, 17, 0, 0, 0, 0, 0, 0, 0, 0,
- 54, 54, 54, 0, 22, 8, 8, 8, 8, 8,
- 8, 8, 8, 1, 70, 0, 8, 71, 18, 18,
- 18, 18, 18, 18, 18, 18, 56, 1, 8, 18,
- 57, 48, 48, 48, 48, 48, 48, 48, 48, 58,
- 55, 18, 48, 7, 51, 51, 51, 51, 51, 51,
- 51, 51, 55, 61, 48, 51, 19, 19, 19, 28,
- 28, 28, 28, 19, 19, 19, 19, 51, 19, 19,
- 19, 75, 50, 50, 50, 21, 19, 19, 19, 50,
- 50, 50, 50, nil, 50, 50, 50, 20, 26, 26,
- 52, 52, 50, 50, 50, 20, 20, 46, 53, 53,
- 20, 20, 46, 46, nil, nil, nil, nil, nil, 46 ]
-
-racc_action_pointer = [
- 0, 23, nil, nil, nil, nil, nil, 38, 13, nil,
- nil, nil, nil, nil, nil, nil, nil, 1, 26, 64,
- 83, 59, -3, nil, nil, nil, 82, nil, 51, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 102, nil, 39, nil,
- 80, 52, 94, 102, 4, 33, 31, 11, 20, nil,
- nil, 49, nil, nil, nil, nil, nil, nil, nil, nil,
- -5, -2, nil, nil, nil, 52, nil, nil ]
-
-racc_action_default = [
- -56, -56, -1, -3, -4, -5, -6, -7, -33, -48,
- -49, -50, -51, -52, -53, -54, -55, -56, -56, -56,
- -37, -56, -34, -35, 78, -2, -56, -9, -56, -19,
- -20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
- -30, -31, -38, -39, -40, -41, -56, -32, -56, -8,
- -56, -56, -56, -56, -56, -56, -56, -56, -56, -36,
- -10, -11, -12, -15, -13, -16, -14, -17, -18, -42,
- -56, -56, -46, -47, -43, -56, -44, -45 ]
-
-racc_goto_table = [
- 1, 23, 27, 21, 22, 42, 25, 26, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 60, nil, nil, nil, nil, nil, nil,
- nil, 59, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 61 ]
-
-racc_goto_check = [
- 1, 12, 8, 10, 11, 13, 2, 7, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 8, nil, nil, nil, nil, nil, nil,
- nil, 12, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 1 ]
-
-racc_goto_pointer = [
- nil, 0, -12, nil, nil, nil, nil, -12, -17, nil,
- -5, -4, -7, -15 ]
-
-racc_goto_default = [
- nil, 20, 2, 3, 4, 5, 6, nil, nil, 28,
- nil, nil, nil, nil ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 31, :_reduce_none,
- 3, 31, :_reduce_2,
- 1, 32, :_reduce_none,
- 1, 32, :_reduce_none,
- 1, 32, :_reduce_none,
- 1, 32, :_reduce_none,
- 1, 33, :_reduce_7,
- 4, 33, :_reduce_8,
- 1, 37, :_reduce_none,
- 3, 37, :_reduce_10,
- 3, 38, :_reduce_11,
- 3, 38, :_reduce_12,
- 3, 38, :_reduce_13,
- 3, 38, :_reduce_14,
- 3, 38, :_reduce_15,
- 3, 38, :_reduce_16,
- 3, 38, :_reduce_17,
- 3, 38, :_reduce_18,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 1, 39, :_reduce_none,
- 3, 34, :_reduce_32,
- 0, 40, :_reduce_33,
- 1, 40, :_reduce_none,
- 1, 41, :_reduce_35,
- 3, 41, :_reduce_36,
- 1, 42, :_reduce_none,
- 2, 42, :_reduce_38,
- 1, 43, :_reduce_39,
- 1, 43, :_reduce_40,
- 1, 43, :_reduce_41,
- 3, 43, :_reduce_42,
- 4, 43, :_reduce_43,
- 4, 43, :_reduce_44,
- 5, 43, :_reduce_45,
- 3, 43, :_reduce_46,
- 3, 43, :_reduce_47,
- 1, 35, :_reduce_48,
- 1, 35, :_reduce_49,
- 1, 35, :_reduce_50,
- 1, 35, :_reduce_51,
- 1, 35, :_reduce_52,
- 1, 35, :_reduce_53,
- 1, 35, :_reduce_54,
- 1, 36, :_reduce_55 ]
-
-racc_reduce_n = 56
-
-racc_shift_n = 78
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :NIL => 2,
- :TRUE => 3,
- :FALSE => 4,
- :INTEGER => 5,
- :SYMBOL => 6,
- :STRING => 7,
- :REGEXP => 8,
- :ANY => 9,
- :EVEN => 10,
- :ODD => 11,
- :METHOD_NAME => 12,
- :CLASS_NAME => 13,
- "|" => 14,
- "<" => 15,
- ">" => 16,
- "," => 17,
- "=" => 18,
- "^=" => 19,
- "$=" => 20,
- "*=" => 21,
- "*" => 22,
- "+" => 23,
- "^" => 24,
- "[" => 25,
- "]" => 26,
- "?" => 27,
- "{" => 28,
- "}" => 29 }
-
-racc_nt_base = 30
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "NIL",
- "TRUE",
- "FALSE",
- "INTEGER",
- "SYMBOL",
- "STRING",
- "REGEXP",
- "ANY",
- "EVEN",
- "ODD",
- "METHOD_NAME",
- "CLASS_NAME",
- "\"|\"",
- "\"<\"",
- "\">\"",
- "\",\"",
- "\"=\"",
- "\"^=\"",
- "\"$=\"",
- "\"*=\"",
- "\"*\"",
- "\"+\"",
- "\"^\"",
- "\"[\"",
- "\"]\"",
- "\"?\"",
- "\"{\"",
- "\"}\"",
- "$start",
- "expression",
- "primary",
- "node",
- "array",
- "literal",
- "any",
- "attrs",
- "attr",
- "method_name",
- "items_opt",
- "items",
- "item",
- "quantifier" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-# reduce 1 omitted
-
-module_eval(<<'.,.,', 'machete.y', 44)
- def _reduce_2(val, _values, result)
- result = if val[0].is_a?(ChoiceMatcher)
- ChoiceMatcher.new(val[0].alternatives << val[2])
- else
- ChoiceMatcher.new([val[0], val[2]])
- end
-
- result
- end
-.,.,
-
-# reduce 3 omitted
-
-# reduce 4 omitted
-
-# reduce 5 omitted
-
-# reduce 6 omitted
-
-module_eval(<<'.,.,', 'machete.y', 57)
- def _reduce_7(val, _values, result)
- result = NodeMatcher.new(val[0].to_sym)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 60)
- def _reduce_8(val, _values, result)
- result = NodeMatcher.new(val[0].to_sym, val[2])
-
- result
- end
-.,.,
-
-# reduce 9 omitted
-
-module_eval(<<'.,.,', 'machete.y', 64)
- def _reduce_10(val, _values, result)
- result = val[0].merge(val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 66)
- def _reduce_11(val, _values, result)
- result = { val[0].to_sym => val[2] }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 68)
- def _reduce_12(val, _values, result)
- result = {
- val[0].to_sym => SymbolRegexpMatcher.new(
- Regexp.new("^" + Regexp.escape(symbol_value(val[2]).to_s))
- )
- }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 75)
- def _reduce_13(val, _values, result)
- result = {
- val[0].to_sym => SymbolRegexpMatcher.new(
- Regexp.new(Regexp.escape(symbol_value(val[2]).to_s) + "$")
- )
- }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 82)
- def _reduce_14(val, _values, result)
- result = {
- val[0].to_sym => SymbolRegexpMatcher.new(
- Regexp.new(Regexp.escape(symbol_value(val[2]).to_s))
- )
- }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 89)
- def _reduce_15(val, _values, result)
- result = {
- val[0].to_sym => StringRegexpMatcher.new(
- Regexp.new("^" + Regexp.escape(string_value(val[2])))
- )
- }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 96)
- def _reduce_16(val, _values, result)
- result = {
- val[0].to_sym => StringRegexpMatcher.new(
- Regexp.new(Regexp.escape(string_value(val[2])) + "$")
- )
- }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 103)
- def _reduce_17(val, _values, result)
- result = {
- val[0].to_sym => StringRegexpMatcher.new(
- Regexp.new(Regexp.escape(string_value(val[2])))
- )
- }
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 110)
- def _reduce_18(val, _values, result)
- result = {
- val[0].to_sym => IndifferentRegexpMatcher.new(
- Regexp.new(regexp_value(val[2]))
- )
- }
-
- result
- end
-.,.,
-
-# reduce 19 omitted
-
-# reduce 20 omitted
-
-# reduce 21 omitted
-
-# reduce 22 omitted
-
-# reduce 23 omitted
-
-# reduce 24 omitted
-
-# reduce 25 omitted
-
-# reduce 26 omitted
-
-# reduce 27 omitted
-
-# reduce 28 omitted
-
-# reduce 29 omitted
-
-# reduce 30 omitted
-
-# reduce 31 omitted
-
-module_eval(<<'.,.,', 'machete.y', 134)
- def _reduce_32(val, _values, result)
- result = ArrayMatcher.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 136)
- def _reduce_33(val, _values, result)
- result = []
- result
- end
-.,.,
-
-# reduce 34 omitted
-
-module_eval(<<'.,.,', 'machete.y', 139)
- def _reduce_35(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 140)
- def _reduce_36(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-# reduce 37 omitted
-
-module_eval(<<'.,.,', 'machete.y', 143)
- def _reduce_38(val, _values, result)
- result = Quantifier.new(val[0], *val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 145)
- def _reduce_39(val, _values, result)
- result = [0, nil, 1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 146)
- def _reduce_40(val, _values, result)
- result = [1, nil, 1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 147)
- def _reduce_41(val, _values, result)
- result = [0, 1, 1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 149)
- def _reduce_42(val, _values, result)
- result = [integer_value(val[1]), integer_value(val[1]), 1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 152)
- def _reduce_43(val, _values, result)
- result = [integer_value(val[1]), nil, 1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 155)
- def _reduce_44(val, _values, result)
- result = [0, integer_value(val[2]), 1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 158)
- def _reduce_45(val, _values, result)
- result = [integer_value(val[1]), integer_value(val[3]), 1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 160)
- def _reduce_46(val, _values, result)
- result = [0, nil, 2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 161)
- def _reduce_47(val, _values, result)
- result = [1, nil, 2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 163)
- def _reduce_48(val, _values, result)
- result = LiteralMatcher.new(nil)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 164)
- def _reduce_49(val, _values, result)
- result = LiteralMatcher.new(true)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 165)
- def _reduce_50(val, _values, result)
- result = LiteralMatcher.new(false)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 166)
- def _reduce_51(val, _values, result)
- result = LiteralMatcher.new(integer_value(val[0]))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 167)
- def _reduce_52(val, _values, result)
- result = LiteralMatcher.new(symbol_value(val[0]))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 168)
- def _reduce_53(val, _values, result)
- result = LiteralMatcher.new(string_value(val[0]))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 169)
- def _reduce_54(val, _values, result)
- result = LiteralMatcher.new(regexp_value(val[0]))
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'machete.y', 171)
- def _reduce_55(val, _values, result)
- result = AnyMatcher.new
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module Machete
diff --git a/test/racc/regress/mediacloth b/test/racc/regress/mediacloth
deleted file mode 100644
index 15430d7ad4..0000000000
--- a/test/racc/regress/mediacloth
+++ /dev/null
@@ -1,1463 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-require 'mediacloth/mediawikiast'
-
-class MediaWikiParser < Racc::Parser
-
-module_eval(<<'...end mediacloth.y/module_eval...', 'mediacloth.y', 564)
-
-attr_accessor :lexer
-
-def initialize
- @nodes = []
- @context = []
- @wiki_ast_length = 0
- super
-end
-
-#Tokenizes input string and parses it.
-def parse(input)
- @yydebug=true
- lexer.tokenize(input)
- do_parse
- return @nodes.last
-end
-
-#Asks the lexer to return the next token.
-def next_token
- token = @lexer.lex
- if token[0].to_s.upcase.include? "_START"
- @context << token[2..3]
- elsif token[0].to_s.upcase.include? "_END"
- @ast_index = @context.last[0]
- @ast_length = token[2] + token[3] - @context.last[0]
- @context.pop
- else
- @ast_index = token[2]
- @ast_length = token[3]
- end
-
- @wiki_ast_length += token[3]
-
- return token[0..1]
-end
-...end mediacloth.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 22, 28, 132, 29, 50, 13, 106, 44, 15, 86,
- 37, 87, 24, 33, 86, 34, 87, 35, 46, 23,
- 26, 25, 27, 12, 85, 30, 86, 31, 87, 42,
- 86, 32, 87, 61, 86, 63, 87, 17, 48, 81,
- 48, 21, 57, 22, 28, 53, 29, 51, 13, 11,
- 36, 15, 36, 14, 57, 24, 33, 67, 34, 45,
- 35, 68, 23, 26, 25, 27, 12, 69, 30, 86,
- 31, 87, 75, 73, 32, 70, 71, 72, 76, 77,
- 17, 82, 22, 28, 21, 29, 55, 13, 51, -65,
- 15, -65, 11, 36, 24, 33, 14, 34, 63, 35,
- 96, 23, 26, 25, 27, 12, 63, 30, 109, 31,
- 110, 113, 114, 32, 48, 117, 118, 124, 57, 17,
- 127, 22, 28, 21, 29, 128, 13, 131, 136, 15,
- 137, 11, 36, 24, 33, 14, 34, 138, 35, 75,
- 23, 26, 25, 27, 12, 51, 30, 141, 31, -63,
- 106, 106, 32, 150, 153, 51, nil, nil, 17, nil,
- 22, 28, 21, 29, nil, 13, nil, nil, 15, nil,
- 11, 36, 24, 33, 14, 34, nil, 35, nil, 23,
- 26, 25, 27, 12, nil, 30, nil, 31, nil, nil,
- nil, 32, nil, nil, nil, nil, nil, 17, nil, 22,
- 28, 21, 29, nil, 13, nil, nil, 15, nil, 11,
- 36, 24, 33, 14, 34, nil, 35, nil, 23, 26,
- 25, 27, 12, nil, 30, nil, 31, nil, nil, nil,
- 32, nil, nil, nil, nil, nil, 17, nil, 22, 28,
- 21, 29, nil, 13, nil, 142, 15, nil, 11, 36,
- 24, 33, 14, 34, nil, 35, nil, 23, 26, 25,
- 27, 12, nil, 30, nil, 31, nil, nil, nil, 32,
- nil, nil, nil, nil, nil, 17, nil, 22, 28, 21,
- 29, nil, 13, nil, nil, 15, 144, 11, 36, 24,
- 33, 14, 34, nil, 35, nil, 23, 26, 25, 27,
- 12, nil, 30, nil, 31, nil, nil, nil, 32, nil,
- nil, 98, nil, nil, 17, nil, 22, 28, 21, 29,
- nil, 13, nil, nil, 15, nil, 11, 36, 24, 33,
- 14, 34, nil, 35, nil, 23, 26, 25, 27, 12,
- nil, 30, nil, 31, nil, nil, nil, 32, nil, nil,
- nil, nil, nil, 17, nil, 22, 28, 21, 29, nil,
- 13, nil, nil, 15, nil, 11, 36, 24, 33, 14,
- 34, nil, 35, nil, 23, 26, 25, 27, 12, nil,
- 30, nil, 31, nil, nil, nil, 32, nil, nil, nil,
- nil, 101, 17, nil, 22, 28, 21, 29, nil, 13,
- nil, nil, 15, nil, 11, 36, 24, 33, 14, 34,
- nil, 35, nil, 23, 26, 25, 27, 12, nil, 30,
- nil, 31, nil, nil, nil, 32, nil, nil, nil, nil,
- nil, 17, nil, nil, nil, 21, nil, 22, 28, nil,
- 29, nil, 13, 11, 36, 15, nil, 14, nil, 24,
- 33, 102, 34, nil, 35, nil, 23, 26, 25, 27,
- 12, nil, 30, nil, 31, nil, nil, nil, 32, nil,
- nil, nil, nil, nil, 17, nil, nil, nil, 21, nil,
- nil, nil, nil, nil, nil, nil, 11, 36, 22, 28,
- 14, 29, nil, 13, nil, nil, 15, nil, 136, nil,
- 24, 33, nil, 34, nil, 35, nil, 23, 26, 25,
- 27, 12, nil, 30, nil, 31, nil, nil, nil, 32,
- nil, nil, nil, nil, nil, 17, nil, 22, 28, 21,
- 29, nil, 13, nil, nil, 15, nil, 11, 36, 24,
- 33, 14, 34, 103, 35, nil, 23, 26, 25, 27,
- 12, nil, 30, nil, 31, nil, nil, nil, 32, nil,
- nil, nil, nil, nil, 17, nil, 22, 28, 21, 29,
- nil, 13, nil, nil, 15, nil, 11, 36, 24, 33,
- 14, 34, nil, 35, 104, 23, 26, 25, 27, 12,
- nil, 30, nil, 31, nil, nil, nil, 32, nil, nil,
- nil, nil, nil, 17, nil, nil, nil, 21, nil, nil,
- nil, nil, nil, nil, nil, 11, 36, 22, 28, 14,
- 29, nil, 13, nil, nil, 15, nil, 136, nil, 24,
- 33, nil, 34, nil, 35, nil, 23, 26, 25, 27,
- 12, nil, 30, nil, 31, nil, nil, nil, 32, nil,
- nil, nil, nil, nil, 17, nil, 22, 28, 21, 29,
- nil, 13, nil, nil, 15, nil, 11, 36, 24, 33,
- 14, 34, nil, 35, nil, 23, 26, 25, 27, 12,
- nil, 30, nil, 31, nil, nil, nil, 32, nil, nil,
- nil, nil, nil, 17, nil, 22, 28, 21, 29, nil,
- 13, nil, nil, 15, nil, 11, 36, 24, 33, 14,
- 34, nil, 35, nil, 23, 26, 25, 27, 12, nil,
- 30, nil, 31, nil, nil, nil, 32, nil, nil, nil,
- nil, nil, 17, 115, 22, 28, 21, 29, nil, 13,
- nil, nil, 15, nil, 11, 36, 24, 33, 14, 34,
- nil, 35, nil, 23, 26, 25, 27, 12, nil, 30,
- nil, 31, nil, nil, nil, 32, nil, nil, nil, nil,
- nil, 17, nil, 22, 28, 21, 29, nil, 13, nil,
- nil, 15, nil, 11, 36, 24, 33, 14, 34, nil,
- 35, nil, 23, 26, 25, 27, 12, nil, 30, nil,
- 31, nil, nil, nil, 32, nil, nil, nil, nil, nil,
- 17, 78, 22, 28, 21, 29, nil, 13, nil, nil,
- 15, nil, 11, 36, 24, 33, 14, 34, nil, 35,
- nil, 23, 26, 25, 27, 12, nil, 30, nil, 31,
- nil, nil, nil, 32, nil, nil, nil, nil, nil, 17,
- nil, 22, 28, 21, 29, nil, 13, nil, 121, 15,
- nil, 11, 36, 24, 33, 14, 34, nil, 35, nil,
- 23, 26, 25, 27, 12, nil, 30, nil, 31, nil,
- nil, nil, 32, nil, nil, nil, nil, nil, 17, nil,
- 22, 28, 21, 29, nil, 13, nil, nil, 15, 123,
- 11, 36, 24, 33, 14, 34, nil, 35, nil, 23,
- 26, 25, 27, 12, nil, 30, nil, 31, nil, nil,
- nil, 32, nil, nil, nil, nil, nil, 17, nil, 22,
- 28, 21, 29, nil, 13, nil, nil, 15, nil, 11,
- 36, 24, 33, 14, 34, nil, 35, nil, 23, 26,
- 25, 27, 12, nil, 30, nil, 31, nil, nil, 126,
- 32, nil, nil, nil, nil, nil, 17, nil, 22, 28,
- 21, 29, nil, 13, nil, nil, 15, nil, 11, 36,
- 24, 33, 14, 34, nil, 35, nil, 23, 26, 25,
- 27, 12, nil, 30, nil, 31, nil, nil, nil, 32,
- nil, nil, nil, nil, nil, 17, nil, 22, 28, 21,
- 29, nil, 13, nil, nil, 15, nil, 11, 36, 24,
- 33, 14, 34, nil, 35, nil, 23, 26, 25, 27,
- 12, nil, 30, nil, 31, nil, nil, nil, 32, nil,
- nil, 129, nil, nil, 17, nil, 22, 28, 21, 29,
- nil, 13, nil, nil, 15, nil, 11, 36, 24, 33,
- 14, 34, nil, 35, nil, 23, 26, 25, 27, 12,
- nil, 30, nil, 31, nil, nil, nil, 32, nil, nil,
- nil, nil, 130, 17, nil, nil, nil, 21, nil, 22,
- 28, 88, 29, nil, 13, 11, 36, 15, nil, 14,
- nil, 24, 33, nil, 34, nil, 35, nil, 23, 26,
- 25, 27, 12, nil, 30, nil, 31, nil, nil, nil,
- 32, nil, nil, nil, nil, nil, 17, nil, 22, 28,
- 21, 29, nil, 13, nil, 134, 15, nil, 11, 36,
- 24, 33, 14, 34, nil, 35, nil, 23, 26, 25,
- 27, 12, nil, 30, nil, 31, nil, nil, nil, 32,
- nil, nil, nil, nil, nil, 17, nil, 22, 28, 21,
- 29, 89, 13, nil, nil, 15, nil, 11, 36, 24,
- 33, 14, 34, nil, 35, nil, 23, 26, 25, 27,
- 12, nil, 30, nil, 31, nil, nil, nil, 32, nil,
- nil, nil, nil, nil, 17, nil, 22, 28, 21, 29,
- nil, 13, nil, nil, 15, nil, 11, 36, 24, 33,
- 14, 34, nil, 35, nil, 23, 26, 25, 27, 12,
- nil, 30, nil, 31, nil, nil, nil, 32, nil, nil,
- nil, nil, nil, 17, nil, 22, 28, 21, 29, nil,
- 13, nil, nil, 15, nil, 11, 36, 24, 33, 14,
- 34, nil, 35, nil, 23, 26, 25, 27, 12, nil,
- 30, nil, 31, nil, nil, nil, 32, nil, nil, nil,
- nil, nil, 17, nil, 22, 28, 21, 29, nil, 13,
- nil, nil, 15, nil, 11, 36, 24, 33, 14, 34,
- nil, 35, nil, 23, 26, 25, 27, 12, nil, 30,
- nil, 31, nil, nil, 93, 32, nil, nil, nil, nil,
- nil, 17, nil, 22, 28, 21, 29, nil, 13, nil,
- nil, 15, nil, 11, 36, 24, 33, 14, 34, nil,
- 35, nil, 23, 26, 25, 27, 12, nil, 30, nil,
- 31, nil, nil, nil, 32, nil, nil, nil, nil, nil,
- 17, nil, nil, nil, 21, nil, nil, nil, nil, nil,
- nil, nil, 11, 36, nil, nil, 14 ]
-
-racc_action_check = [
- 0, 0, 106, 0, 21, 0, 67, 15, 0, 85,
- 1, 85, 0, 0, 123, 0, 123, 0, 15, 0,
- 0, 0, 0, 0, 51, 0, 142, 0, 142, 13,
- 121, 0, 121, 32, 144, 32, 144, 0, 48, 48,
- 17, 0, 30, 28, 28, 28, 28, 21, 28, 0,
- 0, 28, 106, 0, 31, 28, 28, 36, 28, 15,
- 28, 37, 28, 28, 28, 28, 28, 39, 28, 51,
- 28, 51, 44, 44, 28, 41, 42, 43, 45, 46,
- 28, 49, 29, 29, 28, 29, 29, 29, 50, 56,
- 29, 58, 28, 28, 29, 29, 28, 29, 59, 29,
- 60, 29, 29, 29, 29, 29, 62, 29, 73, 29,
- 74, 76, 77, 29, 81, 83, 84, 90, 91, 29,
- 94, 75, 75, 29, 75, 95, 75, 105, 109, 75,
- 112, 29, 29, 75, 75, 29, 75, 113, 75, 114,
- 75, 75, 75, 75, 75, 118, 75, 119, 75, 125,
- 132, 133, 75, 135, 139, 141, nil, nil, 75, nil,
- 2, 2, 75, 2, nil, 2, nil, nil, 2, nil,
- 75, 75, 2, 2, 75, 2, nil, 2, nil, 2,
- 2, 2, 2, 2, nil, 2, nil, 2, nil, nil,
- nil, 2, nil, nil, nil, nil, nil, 2, nil, 120,
- 120, 2, 120, nil, 120, nil, nil, 120, nil, 2,
- 2, 120, 120, 2, 120, nil, 120, nil, 120, 120,
- 120, 120, 120, nil, 120, nil, 120, nil, nil, nil,
- 120, nil, nil, nil, nil, nil, 120, nil, 122, 122,
- 120, 122, nil, 122, nil, 120, 122, nil, 120, 120,
- 122, 122, 120, 122, nil, 122, nil, 122, 122, 122,
- 122, 122, nil, 122, nil, 122, nil, nil, nil, 122,
- nil, nil, nil, nil, nil, 122, nil, 61, 61, 122,
- 61, nil, 61, nil, nil, 61, 122, 122, 122, 61,
- 61, 122, 61, nil, 61, nil, 61, 61, 61, 61,
- 61, nil, 61, nil, 61, nil, nil, nil, 61, nil,
- nil, 61, nil, nil, 61, nil, 40, 40, 61, 40,
- nil, 40, nil, nil, 40, nil, 61, 61, 40, 40,
- 61, 40, nil, 40, nil, 40, 40, 40, 40, 40,
- nil, 40, nil, 40, nil, nil, nil, 40, nil, nil,
- nil, nil, nil, 40, nil, 63, 63, 40, 63, nil,
- 63, nil, nil, 63, nil, 40, 40, 63, 63, 40,
- 63, nil, 63, nil, 63, 63, 63, 63, 63, nil,
- 63, nil, 63, nil, nil, nil, 63, nil, nil, nil,
- nil, 63, 63, nil, 134, 134, 63, 134, nil, 134,
- nil, nil, 134, nil, 63, 63, 134, 134, 63, 134,
- nil, 134, nil, 134, 134, 134, 134, 134, nil, 134,
- nil, 134, nil, nil, nil, 134, nil, nil, nil, nil,
- nil, 134, nil, nil, nil, 134, nil, 64, 64, nil,
- 64, nil, 64, 134, 134, 64, nil, 134, nil, 64,
- 64, 64, 64, nil, 64, nil, 64, 64, 64, 64,
- 64, nil, 64, nil, 64, nil, nil, nil, 64, nil,
- nil, nil, nil, nil, 64, nil, nil, nil, 64, nil,
- nil, nil, nil, nil, nil, nil, 64, 64, 136, 136,
- 64, 136, nil, 136, nil, nil, 136, nil, 136, nil,
- 136, 136, nil, 136, nil, 136, nil, 136, 136, 136,
- 136, 136, nil, 136, nil, 136, nil, nil, nil, 136,
- nil, nil, nil, nil, nil, 136, nil, 65, 65, 136,
- 65, nil, 65, nil, nil, 65, nil, 136, 136, 65,
- 65, 136, 65, 65, 65, nil, 65, 65, 65, 65,
- 65, nil, 65, nil, 65, nil, nil, nil, 65, nil,
- nil, nil, nil, nil, 65, nil, 66, 66, 65, 66,
- nil, 66, nil, nil, 66, nil, 65, 65, 66, 66,
- 65, 66, nil, 66, 66, 66, 66, 66, 66, 66,
- nil, 66, nil, 66, nil, nil, nil, 66, nil, nil,
- nil, nil, nil, 66, nil, nil, nil, 66, nil, nil,
- nil, nil, nil, nil, nil, 66, 66, 152, 152, 66,
- 152, nil, 152, nil, nil, 152, nil, 152, nil, 152,
- 152, nil, 152, nil, 152, nil, 152, 152, 152, 152,
- 152, nil, 152, nil, 152, nil, nil, nil, 152, nil,
- nil, nil, nil, nil, 152, nil, 71, 71, 152, 71,
- nil, 71, nil, nil, 71, nil, 152, 152, 71, 71,
- 152, 71, nil, 71, nil, 71, 71, 71, 71, 71,
- nil, 71, nil, 71, nil, nil, nil, 71, nil, nil,
- nil, nil, nil, 71, nil, 79, 79, 71, 79, nil,
- 79, nil, nil, 79, nil, 71, 71, 79, 79, 71,
- 79, nil, 79, nil, 79, 79, 79, 79, 79, nil,
- 79, nil, 79, nil, nil, nil, 79, nil, nil, nil,
- nil, nil, 79, 79, 14, 14, 79, 14, nil, 14,
- nil, nil, 14, nil, 79, 79, 14, 14, 79, 14,
- nil, 14, nil, 14, 14, 14, 14, 14, nil, 14,
- nil, 14, nil, nil, nil, 14, nil, nil, nil, nil,
- nil, 14, nil, 47, 47, 14, 47, nil, 47, nil,
- nil, 47, nil, 14, 14, 47, 47, 14, 47, nil,
- 47, nil, 47, 47, 47, 47, 47, nil, 47, nil,
- 47, nil, nil, nil, 47, nil, nil, nil, nil, nil,
- 47, 47, 86, 86, 47, 86, nil, 86, nil, nil,
- 86, nil, 47, 47, 86, 86, 47, 86, nil, 86,
- nil, 86, 86, 86, 86, 86, nil, 86, nil, 86,
- nil, nil, nil, 86, nil, nil, nil, nil, nil, 86,
- nil, 87, 87, 86, 87, nil, 87, nil, 86, 87,
- nil, 86, 86, 87, 87, 86, 87, nil, 87, nil,
- 87, 87, 87, 87, 87, nil, 87, nil, 87, nil,
- nil, nil, 87, nil, nil, nil, nil, nil, 87, nil,
- 33, 33, 87, 33, nil, 33, nil, nil, 33, 87,
- 87, 87, 33, 33, 87, 33, nil, 33, nil, 33,
- 33, 33, 33, 33, nil, 33, nil, 33, nil, nil,
- nil, 33, nil, nil, nil, nil, nil, 33, nil, 92,
- 92, 33, 92, nil, 92, nil, nil, 92, nil, 33,
- 33, 92, 92, 33, 92, nil, 92, nil, 92, 92,
- 92, 92, 92, nil, 92, nil, 92, nil, nil, 92,
- 92, nil, nil, nil, nil, nil, 92, nil, 34, 34,
- 92, 34, nil, 34, nil, nil, 34, nil, 92, 92,
- 34, 34, 92, 34, nil, 34, nil, 34, 34, 34,
- 34, 34, nil, 34, nil, 34, nil, nil, nil, 34,
- nil, nil, nil, nil, nil, 34, nil, 97, 97, 34,
- 97, nil, 97, nil, nil, 97, nil, 34, 34, 97,
- 97, 34, 97, nil, 97, nil, 97, 97, 97, 97,
- 97, nil, 97, nil, 97, nil, nil, nil, 97, nil,
- nil, 97, nil, nil, 97, nil, 100, 100, 97, 100,
- nil, 100, nil, nil, 100, nil, 97, 97, 100, 100,
- 97, 100, nil, 100, nil, 100, 100, 100, 100, 100,
- nil, 100, nil, 100, nil, nil, nil, 100, nil, nil,
- nil, nil, 100, 100, nil, nil, nil, 100, nil, 52,
- 52, 52, 52, nil, 52, 100, 100, 52, nil, 100,
- nil, 52, 52, nil, 52, nil, 52, nil, 52, 52,
- 52, 52, 52, nil, 52, nil, 52, nil, nil, nil,
- 52, nil, nil, nil, nil, nil, 52, nil, 108, 108,
- 52, 108, nil, 108, nil, 108, 108, nil, 52, 52,
- 108, 108, 52, 108, nil, 108, nil, 108, 108, 108,
- 108, 108, nil, 108, nil, 108, nil, nil, nil, 108,
- nil, nil, nil, nil, nil, 108, nil, 54, 54, 108,
- 54, 54, 54, nil, nil, 54, nil, 108, 108, 54,
- 54, 108, 54, nil, 54, nil, 54, 54, 54, 54,
- 54, nil, 54, nil, 54, nil, nil, nil, 54, nil,
- nil, nil, nil, nil, 54, nil, 111, 111, 54, 111,
- nil, 111, nil, nil, 111, nil, 54, 54, 111, 111,
- 54, 111, nil, 111, nil, 111, 111, 111, 111, 111,
- nil, 111, nil, 111, nil, nil, nil, 111, nil, nil,
- nil, nil, nil, 111, nil, 35, 35, 111, 35, nil,
- 35, nil, nil, 35, nil, 111, 111, 35, 35, 111,
- 35, nil, 35, nil, 35, 35, 35, 35, 35, nil,
- 35, nil, 35, nil, nil, nil, 35, nil, nil, nil,
- nil, nil, 35, nil, 57, 57, 35, 57, nil, 57,
- nil, nil, 57, nil, 35, 35, 57, 57, 35, 57,
- nil, 57, nil, 57, 57, 57, 57, 57, nil, 57,
- nil, 57, nil, nil, 57, 57, nil, nil, nil, nil,
- nil, 57, nil, 12, 12, 57, 12, nil, 12, nil,
- nil, 12, nil, 57, 57, 12, 12, 57, 12, nil,
- 12, nil, 12, 12, 12, 12, 12, nil, 12, nil,
- 12, nil, nil, nil, 12, nil, nil, nil, nil, nil,
- 12, nil, nil, nil, 12, nil, nil, nil, nil, nil,
- nil, nil, 12, 12, nil, nil, 12 ]
-
-racc_action_pointer = [
- -2, 10, 158, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 1321, 27, 732, 5, nil, -1, nil, nil,
- nil, 2, nil, nil, nil, nil, nil, nil, 41, 80,
- 11, 23, -2, 888, 966, 1243, 55, 61, nil, 41,
- 314, 67, 67, 21, 60, 76, 25, 771, -3, 37,
- 43, 22, 1087, nil, 1165, nil, 61, 1282, 61, 61,
- 66, 275, 69, 353, 435, 525, 564, -6, nil, nil,
- nil, 654, nil, 106, 99, 119, 99, 110, nil, 693,
- nil, 73, nil, 71, 70, -38, 810, 849, nil, nil,
- 89, 87, 927, nil, 90, 91, nil, 1005, nil, nil,
- 1044, nil, nil, nil, nil, 74, 0, nil, 1126, 116,
- nil, 1204, 119, 135, 127, nil, nil, nil, 100, 101,
- 197, -17, 236, -33, nil, 118, nil, nil, nil, nil,
- nil, nil, 138, 139, 392, 142, 486, nil, nil, 143,
- nil, 110, -21, nil, -13, nil, nil, nil, nil, nil,
- nil, nil, 615, nil, nil, nil, nil, nil ]
-
-racc_action_default = [
- -83, -83, -1, -2, -3, -4, -5, -6, -7, -8,
- -9, -10, -19, -83, -19, -83, -18, -23, -37, -39,
- -40, -43, -51, -52, -53, -54, -55, -56, -83, -83,
- -83, -83, -73, -83, -83, -83, -83, -83, -38, -83,
- -20, -83, -26, -83, -30, -83, -83, -83, -23, -83,
- -43, -46, -83, -57, -83, -58, -63, -83, -63, -73,
- -83, -83, -73, -83, -83, -83, -83, -80, 158, -11,
- -12, -83, -13, -83, -83, -83, -32, -83, -21, -83,
- -24, -23, -41, -83, -83, -46, -83, -83, -59, -60,
- -83, -83, -83, -66, -83, -83, -69, -83, -70, -72,
- -83, -74, -76, -77, -78, -83, -83, -27, -28, -34,
- -15, -31, -83, -83, -30, -22, -25, -42, -43, -83,
- -83, -46, -83, -46, -61, -65, -67, -62, -68, -71,
- -75, -79, -80, -80, -83, -83, -34, -16, -33, -83,
- -44, -43, -46, -47, -46, -49, -64, -81, -82, -29,
- -14, -35, -34, -17, -45, -48, -50, -36 ]
-
-racc_goto_table = [
- 38, 84, 74, 105, 49, 39, 90, 43, 94, 60,
- 135, 133, 1, 2, 47, 41, 107, 59, 112, 56,
- 58, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 83, nil, 119, 95, 151, 38, 99,
- nil, 52, 54, nil, nil, 80, 64, 65, 66, nil,
- 38, nil, 38, 157, nil, nil, nil, nil, nil, nil,
- 79, nil, 38, 38, 38, nil, nil, nil, 147, 148,
- 92, 143, 139, 145, 97, 146, 100, 38, 116, 149,
- 125, nil, nil, nil, 108, nil, nil, nil, 111, nil,
- 38, nil, 155, nil, 156, 38, nil, nil, 38, 120,
- 122, 140, nil, nil, nil, nil, 38, nil, nil, 38,
- nil, nil, nil, nil, nil, nil, nil, nil, 38, nil,
- 38, nil, nil, nil, 154, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 108, nil, 152,
- 38 ]
-
-racc_goto_check = [
- 3, 23, 15, 30, 22, 12, 25, 12, 25, 28,
- 14, 11, 1, 2, 18, 13, 19, 27, 16, 24,
- 24, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 22, nil, 23, 28, 14, 3, 28,
- nil, 2, 2, nil, nil, 18, 2, 2, 2, nil,
- 3, nil, 3, 14, nil, nil, nil, nil, nil, nil,
- 2, nil, 3, 3, 3, nil, nil, nil, 30, 30,
- 2, 23, 15, 23, 2, 25, 2, 3, 18, 19,
- 24, nil, nil, nil, 2, nil, nil, nil, 2, nil,
- 3, nil, 23, nil, 23, 3, nil, nil, 3, 2,
- 2, 22, nil, nil, nil, nil, 3, nil, nil, 3,
- nil, nil, nil, nil, nil, nil, nil, nil, 3, nil,
- 3, nil, nil, nil, 22, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 2, nil, 2,
- 3 ]
-
-racc_goto_pointer = [
- nil, 12, 13, -2, nil, nil, nil, nil, nil, nil,
- nil, -95, -7, 2, -99, -42, -58, nil, -3, -55,
- nil, nil, -17, -50, -11, -50, nil, -15, -23, nil,
- -64 ]
-
-racc_goto_default = [
- nil, nil, 40, 18, 3, 4, 5, 6, 7, 8,
- 9, 10, nil, nil, nil, nil, nil, 16, nil, nil,
- 19, 20, nil, nil, nil, nil, 91, nil, nil, 62,
- nil ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 58, :_reduce_1,
- 1, 60, :_reduce_2,
- 1, 60, :_reduce_3,
- 1, 60, :_reduce_4,
- 1, 60, :_reduce_5,
- 1, 60, :_reduce_6,
- 1, 60, :_reduce_7,
- 1, 60, :_reduce_8,
- 1, 60, :_reduce_9,
- 1, 60, :_reduce_10,
- 3, 60, :_reduce_11,
- 3, 60, :_reduce_12,
- 3, 60, :_reduce_13,
- 6, 60, :_reduce_14,
- 4, 60, :_reduce_15,
- 5, 60, :_reduce_16,
- 6, 60, :_reduce_17,
- 1, 60, :_reduce_none,
- 0, 69, :_reduce_19,
- 1, 69, :_reduce_20,
- 3, 67, :_reduce_21,
- 4, 67, :_reduce_22,
- 0, 75, :_reduce_23,
- 2, 75, :_reduce_24,
- 3, 75, :_reduce_25,
- 1, 70, :_reduce_26,
- 3, 70, :_reduce_27,
- 1, 76, :_reduce_28,
- 3, 76, :_reduce_29,
- 0, 72, :_reduce_30,
- 2, 72, :_reduce_31,
- 0, 73, :_reduce_32,
- 2, 73, :_reduce_33,
- 0, 71, :_reduce_34,
- 2, 71, :_reduce_35,
- 3, 71, :_reduce_36,
- 1, 59, :_reduce_37,
- 2, 59, :_reduce_38,
- 1, 61, :_reduce_39,
- 1, 61, :_reduce_40,
- 3, 74, :_reduce_41,
- 4, 74, :_reduce_42,
- 0, 79, :_reduce_43,
- 4, 79, :_reduce_44,
- 5, 79, :_reduce_45,
- 0, 80, :_reduce_46,
- 3, 80, :_reduce_47,
- 4, 80, :_reduce_48,
- 3, 80, :_reduce_49,
- 4, 80, :_reduce_50,
- 1, 77, :_reduce_51,
- 1, 77, :_reduce_52,
- 1, 77, :_reduce_53,
- 1, 77, :_reduce_54,
- 1, 77, :_reduce_55,
- 1, 77, :_reduce_56,
- 2, 78, :_reduce_57,
- 2, 78, :_reduce_58,
- 3, 78, :_reduce_59,
- 3, 78, :_reduce_60,
- 4, 62, :_reduce_61,
- 4, 63, :_reduce_62,
- 0, 83, :_reduce_63,
- 3, 82, :_reduce_64,
- 0, 82, :_reduce_65,
- 2, 81, :_reduce_66,
- 3, 81, :_reduce_67,
- 4, 64, :_reduce_68,
- 3, 64, :_reduce_69,
- 2, 84, :_reduce_70,
- 3, 84, :_reduce_71,
- 2, 85, :_reduce_72,
- 0, 85, :_reduce_73,
- 2, 86, :_reduce_74,
- 3, 86, :_reduce_75,
- 3, 65, :_reduce_76,
- 3, 65, :_reduce_77,
- 3, 66, :_reduce_78,
- 4, 68, :_reduce_79,
- 0, 87, :_reduce_80,
- 3, 87, :_reduce_81,
- 3, 87, :_reduce_82 ]
-
-racc_reduce_n = 83
-
-racc_shift_n = 158
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :TEXT => 2,
- :BOLD_START => 3,
- :BOLD_END => 4,
- :ITALIC_START => 5,
- :ITALIC_END => 6,
- :LINK_START => 7,
- :LINK_END => 8,
- :LINKSEP => 9,
- :INTLINK_START => 10,
- :INTLINK_END => 11,
- :INTLINKSEP => 12,
- :RESOURCESEP => 13,
- :CHAR_ENT => 14,
- :PRE_START => 15,
- :PRE_END => 16,
- :PREINDENT_START => 17,
- :PREINDENT_END => 18,
- :SECTION_START => 19,
- :SECTION_END => 20,
- :HLINE => 21,
- :SIGNATURE_NAME => 22,
- :SIGNATURE_DATE => 23,
- :SIGNATURE_FULL => 24,
- :PARA_START => 25,
- :PARA_END => 26,
- :UL_START => 27,
- :UL_END => 28,
- :OL_START => 29,
- :OL_END => 30,
- :LI_START => 31,
- :LI_END => 32,
- :DL_START => 33,
- :DL_END => 34,
- :DT_START => 35,
- :DT_END => 36,
- :DD_START => 37,
- :DD_END => 38,
- :TAG_START => 39,
- :TAG_END => 40,
- :ATTR_NAME => 41,
- :ATTR_VALUE => 42,
- :TABLE_START => 43,
- :TABLE_END => 44,
- :ROW_START => 45,
- :ROW_END => 46,
- :HEAD_START => 47,
- :HEAD_END => 48,
- :CELL_START => 49,
- :CELL_END => 50,
- :KEYWORD => 51,
- :TEMPLATE_START => 52,
- :TEMPLATE_END => 53,
- :CATEGORY => 54,
- :PASTE_START => 55,
- :PASTE_END => 56 }
-
-racc_nt_base = 57
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "TEXT",
- "BOLD_START",
- "BOLD_END",
- "ITALIC_START",
- "ITALIC_END",
- "LINK_START",
- "LINK_END",
- "LINKSEP",
- "INTLINK_START",
- "INTLINK_END",
- "INTLINKSEP",
- "RESOURCESEP",
- "CHAR_ENT",
- "PRE_START",
- "PRE_END",
- "PREINDENT_START",
- "PREINDENT_END",
- "SECTION_START",
- "SECTION_END",
- "HLINE",
- "SIGNATURE_NAME",
- "SIGNATURE_DATE",
- "SIGNATURE_FULL",
- "PARA_START",
- "PARA_END",
- "UL_START",
- "UL_END",
- "OL_START",
- "OL_END",
- "LI_START",
- "LI_END",
- "DL_START",
- "DL_END",
- "DT_START",
- "DT_END",
- "DD_START",
- "DD_END",
- "TAG_START",
- "TAG_END",
- "ATTR_NAME",
- "ATTR_VALUE",
- "TABLE_START",
- "TABLE_END",
- "ROW_START",
- "ROW_END",
- "HEAD_START",
- "HEAD_END",
- "CELL_START",
- "CELL_END",
- "KEYWORD",
- "TEMPLATE_START",
- "TEMPLATE_END",
- "CATEGORY",
- "PASTE_START",
- "PASTE_END",
- "$start",
- "wiki",
- "repeated_contents",
- "contents",
- "text",
- "bulleted_list",
- "numbered_list",
- "dictionary_list",
- "preformatted",
- "section",
- "tag",
- "template",
- "para_contents",
- "link_contents",
- "reslink_repeated_contents",
- "intlink_repeated_contents",
- "cat_sort_contents",
- "table",
- "tag_attributes",
- "link_repeated_contents",
- "element",
- "formatted_element",
- "table_contents",
- "row_contents",
- "list_item",
- "list_contents",
- "@1",
- "dictionary_term",
- "dictionary_contents",
- "dictionary_definition",
- "template_parameters" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'mediacloth.y', 47)
- def _reduce_1(val, _values, result)
- @nodes.push WikiAST.new(0, @wiki_ast_length)
- #@nodes.last.children.insert(0, val[0])
- #puts val[0]
- @nodes.last.children += val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 57)
- def _reduce_2(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 61)
- def _reduce_3(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 65)
- def _reduce_4(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 69)
- def _reduce_5(val, _values, result)
- list = ListAST.new(@ast_index, @ast_length)
- list.list_type = :Dictionary
- list.children = val[0]
- result = list
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 76)
- def _reduce_6(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 80)
- def _reduce_7(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 84)
- def _reduce_8(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 88)
- def _reduce_9(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 92)
- def _reduce_10(val, _values, result)
- k = KeywordAST.new(@ast_index, @ast_length)
- k.text = val[0]
- result = k
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 98)
- def _reduce_11(val, _values, result)
- p = ParagraphAST.new(@ast_index, @ast_length)
- p.children = val[1]
- result = p
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 104)
- def _reduce_12(val, _values, result)
- l = LinkAST.new(@ast_index, @ast_length)
- l.link_type = val[0]
- l.url = val[1][0]
- l.children += val[1][1..-1] if val[1].length > 1
- result = l
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 112)
- def _reduce_13(val, _values, result)
- p = PasteAST.new(@ast_index, @ast_length)
- p.children = val[1]
- result = p
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 118)
- def _reduce_14(val, _values, result)
- l = ResourceLinkAST.new(@ast_index, @ast_length)
- l.prefix = val[1]
- l.locator = val[3]
- l.children = val[4] unless val[4].nil? or val[4].empty?
- result = l
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 126)
- def _reduce_15(val, _values, result)
- l = InternalLinkAST.new(@ast_index, @ast_length)
- l.locator = val[1]
- l.children = val[2] unless val[2].nil? or val[2].empty?
- result = l
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 133)
- def _reduce_16(val, _values, result)
- l = CategoryAST.new(@ast_index, @ast_length)
- l.locator = val[2]
- l.sort_as = val[3]
- result = l
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 140)
- def _reduce_17(val, _values, result)
- l = CategoryLinkAST.new(@ast_index, @ast_length)
- l.locator = val[3]
- l.children = val[4] unless val[4].nil? or val[4].empty?
- result = l
-
- result
- end
-.,.,
-
-# reduce 18 omitted
-
-module_eval(<<'.,.,', 'mediacloth.y', 150)
- def _reduce_19(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 154)
- def _reduce_20(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 161)
- def _reduce_21(val, _values, result)
- if val[0] != val[2]
- raise Racc::ParseError.new("XHTML end tag #{val[2]} does not match start tag #{val[0]}")
- end
- elem = ElementAST.new(@ast_index, @ast_length)
- elem.name = val[0]
- elem.attributes = val[1]
- result = elem
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 171)
- def _reduce_22(val, _values, result)
- if val[0] != val[3]
- raise Racc::ParseError.new("XHTML end tag #{val[3]} does not match start tag #{val[0]}")
- end
- elem = ElementAST.new(@ast_index, @ast_length)
- elem.name = val[0]
- elem.attributes = val[1]
- elem.children += val[2]
- result = elem
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 184)
- def _reduce_23(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 188)
- def _reduce_24(val, _values, result)
- attr_map = val[2] ? val[2] : {}
- attr_map[val[0]] = true
- result = attr_map
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 194)
- def _reduce_25(val, _values, result)
- attr_map = val[2] ? val[2] : {}
- attr_map[val[0]] = val[1]
- result = attr_map
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 204)
- def _reduce_26(val, _values, result)
- result = val
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 208)
- def _reduce_27(val, _values, result)
- result = [val[0]]
- result += val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 217)
- def _reduce_28(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 221)
- def _reduce_29(val, _values, result)
- result = val[0]
- result += val[2] if val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 229)
- def _reduce_30(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 233)
- def _reduce_31(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 239)
- def _reduce_32(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 243)
- def _reduce_33(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 249)
- def _reduce_34(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 253)
- def _reduce_35(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 257)
- def _reduce_36(val, _values, result)
- i = InternalLinkItemAST.new(@ast_index, @ast_length)
- i.children = val[1]
- result = [i]
- result += val[2] if val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 266)
- def _reduce_37(val, _values, result)
- result = []
- result << val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 271)
- def _reduce_38(val, _values, result)
- result = []
- result += val[0]
- result << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 279)
- def _reduce_39(val, _values, result)
- p = TextAST.new(@ast_index, @ast_length)
- p.formatting = val[0][0]
- p.contents = val[0][1]
- result = p
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 286)
- def _reduce_40(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 293)
- def _reduce_41(val, _values, result)
- table = TableAST.new(@ast_index, @ast_length)
- table.children = val[1] unless val[1].nil? or val[1].empty?
- result = table
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 299)
- def _reduce_42(val, _values, result)
- table = TableAST.new(@ast_index, @ast_length)
- table.options = val[1]
- table.children = val[2] unless val[2].nil? or val[2].empty?
- result = table
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 307)
- def _reduce_43(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 311)
- def _reduce_44(val, _values, result)
- row = TableRowAST.new(@ast_index, @ast_length)
- row.children = val[1] unless val[1].nil? or val[1].empty?
- result = [row]
- result += val[3] unless val[3].nil? or val[3].empty?
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 318)
- def _reduce_45(val, _values, result)
- row = TableRowAST.new(@ast_index, @ast_length)
- row.children = val[2] unless val[2].nil? or val[2].empty?
- row.options = val[1]
- result = [row]
- result += val[4] unless val[4].nil? or val[4].empty?
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 327)
- def _reduce_46(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 331)
- def _reduce_47(val, _values, result)
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.type = :head
- result = [cell]
- result += val[2] unless val[2].nil? or val[2].empty?
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 338)
- def _reduce_48(val, _values, result)
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.children = val[1] unless val[1].nil? or val[1].empty?
- cell.type = :head
- result = [cell]
- result += val[3] unless val[3].nil? or val[3].empty?
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 346)
- def _reduce_49(val, _values, result)
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.type = :body
- result = [cell]
- result += val[2] unless val[2].nil? or val[2].empty?
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 353)
- def _reduce_50(val, _values, result)
- if val[2] == 'attributes'
- result = []
- else
- cell = TableCellAST.new(@ast_index, @ast_length)
- cell.children = val[1] unless val[1].nil? or val[1].empty?
- cell.type = :body
- result = [cell]
- end
- result += val[3] unless val[3].nil? or val[3].empty?
- if val[2] == 'attributes' and val[3] and val[3].first.class == TableCellAST
- val[3].first.attributes = val[1]
- end
- result
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 371)
- def _reduce_51(val, _values, result)
- return [:None, val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 373)
- def _reduce_52(val, _values, result)
- return [:HLine, val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 375)
- def _reduce_53(val, _values, result)
- return [:CharacterEntity, val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 377)
- def _reduce_54(val, _values, result)
- return [:SignatureDate, val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 379)
- def _reduce_55(val, _values, result)
- return [:SignatureName, val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 381)
- def _reduce_56(val, _values, result)
- return [:SignatureFull, val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 387)
- def _reduce_57(val, _values, result)
- result = FormattedAST.new(@ast_index, @ast_length)
- result.formatting = :Bold
- result
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 393)
- def _reduce_58(val, _values, result)
- result = FormattedAST.new(@ast_index, @ast_length)
- result.formatting = :Italic
- result
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 399)
- def _reduce_59(val, _values, result)
- p = FormattedAST.new(@ast_index, @ast_length)
- p.formatting = :Bold
- p.children += val[1]
- result = p
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 406)
- def _reduce_60(val, _values, result)
- p = FormattedAST.new(@ast_index, @ast_length)
- p.formatting = :Italic
- p.children += val[1]
- result = p
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 415)
- def _reduce_61(val, _values, result)
- list = ListAST.new(@ast_index, @ast_length)
- list.list_type = :Bulleted
- list.children << val[1]
- list.children += val[2]
- result = list
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 425)
- def _reduce_62(val, _values, result)
- list = ListAST.new(@ast_index, @ast_length)
- list.list_type = :Numbered
- list.children << val[1]
- list.children += val[2]
- result = list
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 434)
- def _reduce_63(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 437)
- def _reduce_64(val, _values, result)
- result << val[1]
- result += val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 441)
- def _reduce_65(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 447)
- def _reduce_66(val, _values, result)
- result = ListItemAST.new(@ast_index, @ast_length)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 451)
- def _reduce_67(val, _values, result)
- li = ListItemAST.new(@ast_index, @ast_length)
- li.children += val[1]
- result = li
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 460)
- def _reduce_68(val, _values, result)
- result = [val[1]]
- result += val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 465)
- def _reduce_69(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 472)
- def _reduce_70(val, _values, result)
- result = ListTermAST.new(@ast_index, @ast_length)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 476)
- def _reduce_71(val, _values, result)
- term = ListTermAST.new(@ast_index, @ast_length)
- term.children += val[1]
- result = term
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 484)
- def _reduce_72(val, _values, result)
- result = [val[0]]
- result += val[1] if val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 489)
- def _reduce_73(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 495)
- def _reduce_74(val, _values, result)
- result = ListDefinitionAST.new(@ast_index, @ast_length)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 499)
- def _reduce_75(val, _values, result)
- term = ListDefinitionAST.new(@ast_index, @ast_length)
- term.children += val[1]
- result = term
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 506)
- def _reduce_76(val, _values, result)
- p = PreformattedAST.new(@ast_index, @ast_length)
- p.children += val[1]
- result = p
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 512)
- def _reduce_77(val, _values, result)
- p = PreformattedAST.new(@ast_index, @ast_length)
- p.indented = true
- p.children += val[1]
- result = p
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 520)
- def _reduce_78(val, _values, result)
- result = [val[1], val[0].length]
- s = SectionAST.new(@ast_index, @ast_length)
- s.children = val[1]
- s.level = val[0].length
- result = s
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 530)
- def _reduce_79(val, _values, result)
- t = TemplateAST.new(@ast_index, @ast_length)
- t.template_name = val[1]
- t.children = val[2] unless val[2].nil? or val[2].empty?
- result = t
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 539)
- def _reduce_80(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 543)
- def _reduce_81(val, _values, result)
- p = TemplateParameterAST.new(@ast_index, @ast_length)
- p.parameter_value = val[1]
- result = [p]
- result += val[2] if val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mediacloth.y', 550)
- def _reduce_82(val, _values, result)
- p = TemplateParameterAST.new(@ast_index, @ast_length)
- p.children << val[1]
- result = [p]
- result += val[2] if val[2]
-
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
-end # class MediaWikiParser
diff --git a/test/racc/regress/mof b/test/racc/regress/mof
deleted file mode 100644
index 6f2cbc8464..0000000000
--- a/test/racc/regress/mof
+++ /dev/null
@@ -1,1368 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-
-# parser.rb - generated by racc
-
-require 'strscan'
-require 'rubygems'
-require 'cim'
-require File.join(File.dirname(__FILE__), 'result')
-require File.join(File.dirname(__FILE__), 'scanner')
-require File.join(File.dirname(__FILE__), 'helper')
-
-module MOF
- class Parser < Racc::Parser
-
-module_eval(<<'...end mof.y/module_eval...', 'mof.y', 571)
-
-#
-# Initialize MOF::Parser
-# MOF::Parser.new options = {}
-#
-# options -> Hash of options
-# :debug -> boolean
-# :includes -> array of include dirs
-# :style -> :cim or :wmi
-#
-def initialize options = {}
- @yydebug = options[:debug]
- @includes = options[:includes] || []
- @quiet = options[:quiet]
- @style = options[:style] || :cim # default to style CIM v2.2 syntax
-
- @lineno = 1
- @file = nil
- @iconv = nil
- @eol = "\n"
- @fname = nil
- @fstack = []
- @in_comment = false
- @seen_files = []
- @qualifiers = {}
-end
-
-#
-# Make options hash from argv
-#
-# returns [ files, options ]
-#
-
- def self.argv_handler name, argv
- files = []
- options = { :namespace => "" }
- while argv.size > 0
- case opt = argv.shift
- when "-h"
- $stderr.puts "Ruby MOF compiler"
- $stderr.puts "#{name} [-h] [-d] [-I <dir>] [<moffiles>]"
- $stderr.puts "Compiles <moffile>"
- $stderr.puts "\t-d debug"
- $stderr.puts "\t-h this help"
- $stderr.puts "\t-I <dir> include dir"
- $stderr.puts "\t-f force"
- $stderr.puts "\t-n <namespace>"
- $stderr.puts "\t-o <output>"
- $stderr.puts "\t-s <style> syntax style (wmi,cim)"
- $stderr.puts "\t-q quiet"
- $stderr.puts "\t<moffiles> file(s) to read (else use $stdin)"
- exit 0
- when "-f" then options[:force] = true
- when "-s" then options[:style] = argv.shift.to_sym
- when "-d" then options[:debug] = true
- when "-q" then options[:quiet] = true
- when "-I"
- options[:includes] ||= []
- dirname = argv.shift
- unless File.directory?(dirname)
- files << dirname
- dirname = File.dirname(dirname)
- end
- options[:includes] << Pathname.new(dirname)
- when "-n" then options[:namespace] = argv.shift
- when "-o" then options[:output] = argv.shift
- when /^-.+/
- $stderr.puts "Undefined option #{opt}"
- else
- files << opt
- end
- end
- [ files, options ]
- end
-
-include Helper
-include Scanner
-
-...end mof.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 13, 172, 163, 197, 174, 200, 63, 17, 145, 146,
- 147, 62, 121, 172, 11, 173, 174, 173, 148, 11,
- 144, 149, 150, 151, 152, 18, 163, 173, 207, 153,
- 106, 107, 108, 109, 110, 112, 111, 199, 15, 16,
- 174, 55, 57, 68, 69, 71, 72, 52, 53, 54,
- 56, 163, 7, 40, -59, 42, 42, 7, 10, 10,
- 115, 102, 114, 121, 10, 55, 57, 68, 69, 71,
- 72, 52, 53, 54, 56, 51, -77, 209, 190, 42,
- 211, 10, 10, 189, 135, 102, 51, 170, 135, 10,
- 55, 57, 68, 69, 71, 72, 52, 53, 54, 56,
- 164, 218, 10, 21, 42, 22, 23, 10, 95, 96,
- 102, 35, 191, 192, 55, 57, 25, 220, 24, 221,
- 52, 53, 54, 56, 226, 55, 57, 35, 180, 181,
- 228, 52, 53, 54, 56, 93, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- -25, 93, 79, 80, 81, 82, 83, 84, 85, 86,
- 87, 88, 89, 90, 91, 92, 29, 31, 229, 231,
- 55, 57, 68, 69, 71, 72, 52, 53, 54, 56,
- 145, 146, 147, 172, 10, 121, 174, 10, 135, 27,
- 148, 28, 144, 149, 150, 151, 152, 173, 33, 35,
- 36, 153, 55, 57, 68, 69, 71, 72, 52, 53,
- 54, 56, 106, 107, 108, 109, 110, 112, 111, 10,
- 55, 57, 68, 69, 71, 72, 52, 53, 54, 56,
- 21, 44, 22, 23, 33, 33, 21, 10, 22, 23,
- 60, 35, 65, 25, 78, 24, 97, 100, 102, 25,
- 60, 24, 93, 79, 80, 81, 82, 83, 84, 85,
- 86, 87, 88, 89, 90, 91, 92, 106, 107, 108,
- 109, 110, 112, 111, 113, 97, 18, 118, 119, 121,
- 124, 35, 126, 127, 129, 130, 131, 133, 135, 10,
- 141, 154, 35, 184, 185, 194 ]
-
-racc_action_check = [
- 1, 140, 211, 186, 140, 188, 37, 8, 131, 131,
- 131, 37, 195, 194, 0, 140, 194, 186, 131, 1,
- 131, 131, 131, 131, 131, 8, 189, 194, 196, 131,
- 192, 192, 192, 192, 192, 192, 192, 187, 7, 7,
- 187, 211, 211, 211, 211, 211, 211, 211, 211, 211,
- 211, 135, 0, 20, 197, 211, 20, 1, 211, 0,
- 75, 211, 75, 198, 1, 189, 189, 189, 189, 189,
- 189, 189, 189, 189, 189, 33, 207, 201, 177, 189,
- 205, 207, 189, 177, 206, 189, 96, 138, 208, 138,
- 135, 135, 135, 135, 135, 135, 135, 135, 135, 135,
- 137, 210, 137, 10, 135, 10, 10, 135, 47, 47,
- 135, 169, 178, 178, 33, 33, 10, 212, 10, 213,
- 33, 33, 33, 33, 217, 96, 96, 216, 142, 142,
- 221, 96, 96, 96, 96, 169, 169, 169, 169, 169,
- 169, 169, 169, 169, 169, 169, 169, 169, 169, 169,
- 42, 216, 216, 216, 216, 216, 216, 216, 216, 216,
- 216, 216, 216, 216, 216, 216, 15, 15, 222, 223,
- 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
- 181, 181, 181, 218, 229, 230, 218, 42, 233, 12,
- 181, 13, 181, 181, 181, 181, 181, 218, 16, 17,
- 18, 181, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 40, 141, 141, 141, 141, 141, 141, 141, 40,
- 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
- 11, 26, 11, 11, 29, 30, 63, 115, 63, 63,
- 34, 36, 38, 11, 43, 11, 49, 58, 60, 63,
- 61, 63, 44, 44, 44, 44, 44, 44, 44, 44,
- 44, 44, 44, 44, 44, 44, 44, 65, 65, 65,
- 65, 65, 65, 65, 66, 70, 74, 77, 78, 94,
- 98, 100, 102, 103, 116, 118, 119, 121, 122, 127,
- 130, 132, 161, 162, 164, 183 ]
-
-racc_action_pointer = [
- -5, 0, nil, nil, nil, nil, nil, 32, -2, nil,
- 95, 222, 126, 191, nil, 159, 140, 191, 169, nil,
- -5, nil, nil, nil, nil, nil, 165, nil, nil, 176,
- 177, nil, nil, 67, 212, nil, 233, -54, 176, nil,
- 155, nil, 123, 184, 220, nil, nil, 49, nil, 198,
- nil, nil, nil, nil, nil, nil, nil, nil, 181, nil,
- 181, 222, nil, 228, nil, 255, 215, nil, nil, nil,
- 227, nil, nil, nil, 249, 0, nil, 217, 258, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 215, nil, 78, nil, 219, nil,
- 273, nil, 274, 222, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 173, 221, nil, 259, 228,
- nil, 240, 220, nil, nil, nil, nil, 225, nil, nil,
- 232, -1, 226, nil, nil, 43, nil, 38, 25, nil,
- -7, 200, 69, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 284, 227, nil, 231, nil, nil, nil, nil, 103,
- nil, nil, nil, nil, nil, nil, nil, 15, 53, nil,
- nil, 171, nil, 226, nil, nil, -5, 29, -24, 18,
- nil, nil, 18, nil, 5, -52, -30, -4, -1, nil,
- nil, 14, nil, nil, nil, 12, 16, 17, 20, nil,
- 41, -6, 54, 60, nil, nil, 119, 61, 175, nil,
- nil, 67, 108, 161, nil, nil, nil, nil, nil, 120,
- 121, nil, nil, 120, nil, nil ]
-
-racc_action_default = [
- -1, -25, -2, -4, -5, -6, -7, -161, -161, -26,
- -161, -161, -161, -161, -3, -161, -12, -161, -161, -28,
- -33, -133, -134, -135, -136, -137, -161, -155, 236, -12,
- -12, -11, -10, -161, -44, -48, -161, -161, -31, -34,
- -25, -36, -100, -161, -161, -8, -9, -161, -14, -16,
- -17, -18, -110, -111, -112, -113, -114, -115, -46, -45,
- -161, -44, -27, -161, -30, -161, -161, -103, -104, -105,
- -106, -107, -108, -109, -161, -161, -101, -131, -161, -60,
- -61, -62, -63, -64, -65, -66, -67, -68, -69, -70,
- -71, -72, -73, -74, -86, -13, -161, -116, -161, -47,
- -161, -49, -161, -161, -29, -32, -37, -38, -39, -40,
- -41, -42, -43, -35, -99, -25, -161, -132, -161, -161,
- -87, -91, -93, -15, -20, -51, -50, -25, -102, -130,
- -161, -161, -161, -92, -94, -25, -138, -25, -25, -157,
- -161, -161, -161, -140, -142, -143, -144, -145, -146, -147,
- -148, -149, -150, -151, -90, -95, -96, -97, -98, -117,
- -118, -161, -161, -122, -161, -21, -22, -23, -24, -161,
- -156, -158, -55, -56, -58, -128, -129, -161, -161, -153,
- -139, -161, -119, -161, -121, -19, -161, -161, -75, -25,
- -160, -152, -161, -141, -161, -86, -161, -55, -86, -57,
- -76, -161, -154, -123, -125, -161, -93, -25, -93, -159,
- -124, -25, -161, -161, -78, -80, -161, -161, -161, -127,
- -52, -161, -79, -161, -83, -84, -53, -126, -54, -25,
- -86, -85, -81, -88, -82, -89 ]
-
-racc_goto_table = [
- 8, 8, 34, 94, 122, 105, 136, 155, 50, 66,
- 49, 76, 48, 19, 143, 187, 58, 204, 215, 32,
- 139, 61, 12, 12, 2, 14, 30, 38, 39, 26,
- 41, 171, 45, 46, 99, 101, 37, 195, 168, 167,
- 232, 227, 166, 103, 198, 196, 213, 214, 165, 222,
- 223, 230, 234, 235, 132, 137, 75, 1, 182, 203,
- 98, 201, 225, 210, 193, 177, 104, 43, 77, 116,
- 117, 50, 142, 49, 47, 123, 178, 138, 64, nil,
- nil, 179, nil, 219, 128, 125, nil, nil, nil, nil,
- 212, nil, 217, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 206, nil, nil, 208, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 140, 186, nil,
- nil, nil, 202, nil, nil, nil, nil, 169, 140, nil,
- 233, nil, nil, nil, nil, nil, 183, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 224, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 216, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 216 ]
-
-racc_goto_check = [
- 13, 13, 14, 35, 37, 28, 38, 52, 12, 30,
- 11, 30, 10, 23, 69, 39, 15, 61, 44, 7,
- 72, 14, 55, 55, 2, 2, 8, 26, 29, 25,
- 31, 72, 7, 7, 33, 34, 24, 36, 21, 20,
- 44, 61, 19, 15, 40, 41, 42, 43, 18, 45,
- 46, 47, 48, 50, 51, 17, 54, 1, 58, 60,
- 16, 52, 39, 62, 69, 63, 23, 64, 65, 66,
- 67, 12, 68, 11, 9, 10, 70, 71, 27, nil,
- nil, 28, nil, 52, 30, 14, nil, nil, nil, nil,
- 38, nil, 38, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 37, nil, nil, 37, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 13, 35, nil,
- nil, nil, 28, nil, nil, nil, nil, 13, 13, nil,
- 37, nil, nil, nil, nil, nil, 14, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 35, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 13, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 13 ]
-
-racc_goto_pointer = [
- nil, 57, 24, nil, nil, nil, nil, 3, 11, 41,
- -21, -23, -25, 0, -15, -18, 2, -69, -89, -95,
- -98, -99, nil, 3, 17, 18, 7, 40, -60, 8,
- -31, 10, nil, -24, -25, -41, -149, -90, -116, -154,
- -143, -141, -161, -160, -189, -166, -166, -172, -181, nil,
- -180, -67, -128, nil, 14, 22, nil, nil, -103, nil,
- -135, -177, -141, -75, 41, 25, -8, -7, -59, -117,
- -65, -50, -107 ]
-
-racc_goto_default = [
- nil, nil, nil, 3, 4, 5, 6, nil, nil, nil,
- nil, 70, 67, 74, 188, nil, nil, nil, nil, nil,
- nil, nil, 9, nil, nil, 20, nil, nil, nil, nil,
- 156, 157, 59, nil, 160, nil, 175, nil, nil, nil,
- 176, nil, nil, nil, nil, nil, nil, nil, nil, 120,
- 134, nil, nil, 158, nil, 73, 159, 161, nil, 162,
- nil, nil, nil, 205, nil, nil, nil, nil, nil, nil,
- nil, nil, nil ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 0, 71, :_reduce_1,
- 1, 71, :_reduce_2,
- 2, 71, :_reduce_3,
- 1, 72, :_reduce_none,
- 1, 72, :_reduce_5,
- 1, 72, :_reduce_6,
- 1, 72, :_reduce_7,
- 4, 73, :_reduce_8,
- 4, 73, :_reduce_none,
- 3, 73, :_reduce_10,
- 1, 78, :_reduce_none,
- 0, 77, :_reduce_12,
- 3, 77, :_reduce_13,
- 1, 79, :_reduce_none,
- 3, 79, :_reduce_none,
- 1, 80, :_reduce_none,
- 1, 80, :_reduce_17,
- 1, 80, :_reduce_none,
- 9, 74, :_reduce_19,
- 0, 87, :_reduce_20,
- 2, 87, :_reduce_21,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 0, 83, :_reduce_none,
- 1, 83, :_reduce_26,
- 4, 92, :_reduce_27,
- 0, 94, :_reduce_28,
- 3, 94, :_reduce_29,
- 3, 93, :_reduce_30,
- 0, 97, :_reduce_none,
- 2, 97, :_reduce_32,
- 0, 96, :_reduce_none,
- 1, 96, :_reduce_none,
- 3, 99, :_reduce_35,
- 1, 99, :_reduce_none,
- 1, 98, :_reduce_none,
- 1, 98, :_reduce_none,
- 1, 98, :_reduce_none,
- 1, 98, :_reduce_none,
- 1, 98, :_reduce_none,
- 1, 98, :_reduce_none,
- 1, 98, :_reduce_43,
- 0, 85, :_reduce_none,
- 1, 85, :_reduce_none,
- 0, 86, :_reduce_none,
- 1, 86, :_reduce_none,
- 1, 84, :_reduce_48,
- 2, 102, :_reduce_49,
- 2, 104, :_reduce_50,
- 2, 103, :_reduce_51,
- 6, 89, :_reduce_52,
- 6, 91, :_reduce_53,
- 7, 90, :_reduce_54,
- 1, 106, :_reduce_none,
- 1, 106, :_reduce_56,
- 1, 110, :_reduce_none,
- 1, 110, :_reduce_58,
- 1, 111, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_none,
- 1, 105, :_reduce_74,
- 1, 109, :_reduce_75,
- 2, 109, :_reduce_76,
- 0, 112, :_reduce_none,
- 1, 112, :_reduce_none,
- 2, 113, :_reduce_79,
- 0, 115, :_reduce_80,
- 3, 115, :_reduce_81,
- 5, 114, :_reduce_82,
- 1, 116, :_reduce_none,
- 1, 116, :_reduce_none,
- 1, 117, :_reduce_none,
- 0, 107, :_reduce_none,
- 1, 107, :_reduce_none,
- 0, 118, :_reduce_none,
- 1, 118, :_reduce_89,
- 3, 119, :_reduce_90,
- 0, 121, :_reduce_91,
- 1, 121, :_reduce_none,
- 0, 108, :_reduce_none,
- 1, 108, :_reduce_none,
- 2, 120, :_reduce_95,
- 1, 122, :_reduce_none,
- 1, 122, :_reduce_none,
- 1, 122, :_reduce_none,
- 3, 101, :_reduce_99,
- 0, 124, :_reduce_none,
- 1, 124, :_reduce_101,
- 3, 124, :_reduce_102,
- 1, 100, :_reduce_none,
- 1, 100, :_reduce_none,
- 1, 100, :_reduce_none,
- 1, 100, :_reduce_none,
- 1, 100, :_reduce_none,
- 1, 100, :_reduce_none,
- 1, 100, :_reduce_109,
- 1, 82, :_reduce_none,
- 1, 82, :_reduce_none,
- 1, 82, :_reduce_none,
- 1, 82, :_reduce_none,
- 1, 82, :_reduce_none,
- 1, 81, :_reduce_none,
- 2, 81, :_reduce_116,
- 1, 123, :_reduce_none,
- 1, 123, :_reduce_none,
- 2, 126, :_reduce_none,
- 0, 127, :_reduce_none,
- 2, 127, :_reduce_none,
- 1, 129, :_reduce_none,
- 3, 128, :_reduce_none,
- 2, 130, :_reduce_none,
- 0, 132, :_reduce_none,
- 3, 132, :_reduce_none,
- 3, 131, :_reduce_none,
- 1, 133, :_reduce_none,
- 1, 133, :_reduce_none,
- 6, 75, :_reduce_130,
- 0, 136, :_reduce_none,
- 1, 136, :_reduce_none,
- 1, 95, :_reduce_none,
- 1, 95, :_reduce_none,
- 1, 95, :_reduce_none,
- 1, 95, :_reduce_none,
- 1, 95, :_reduce_none,
- 4, 134, :_reduce_138,
- 5, 135, :_reduce_139,
- 1, 138, :_reduce_140,
- 3, 138, :_reduce_141,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 1, 139, :_reduce_none,
- 5, 137, :_reduce_152,
- 1, 140, :_reduce_153,
- 3, 140, :_reduce_154,
- 2, 76, :_reduce_none,
- 8, 125, :_reduce_none,
- 1, 141, :_reduce_none,
- 2, 141, :_reduce_none,
- 5, 142, :_reduce_none,
- 3, 142, :_reduce_160 ]
-
-racc_reduce_n = 161
-
-racc_shift_n = 236
-
-racc_token_table = {
- false => 0,
- :error => 1,
- "*" => 2,
- "/" => 3,
- "+" => 4,
- "-" => 5,
- :PRAGMA => 6,
- :INCLUDE => 7,
- :IDENTIFIER => 8,
- :CLASS => 9,
- :ASSOCIATION => 10,
- :INDICATION => 11,
- :AMENDED => 12,
- :ENABLEOVERRIDE => 13,
- :DISABLEOVERRIDE => 14,
- :RESTRICTED => 15,
- :TOSUBCLASS => 16,
- :TOINSTANCE => 17,
- :TRANSLATABLE => 18,
- :QUALIFIER => 19,
- :SCOPE => 20,
- :SCHEMA => 21,
- :PROPERTY => 22,
- :REFERENCE => 23,
- :METHOD => 24,
- :PARAMETER => 25,
- :FLAVOR => 26,
- :INSTANCE => 27,
- :AS => 28,
- :REF => 29,
- :ANY => 30,
- :OF => 31,
- :DT_VOID => 32,
- :DT_UINT8 => 33,
- :DT_SINT8 => 34,
- :DT_UINT16 => 35,
- :DT_SINT16 => 36,
- :DT_UINT32 => 37,
- :DT_SINT32 => 38,
- :DT_UINT64 => 39,
- :DT_SINT64 => 40,
- :DT_REAL32 => 41,
- :DT_REAL64 => 42,
- :DT_CHAR16 => 43,
- :DT_STR => 44,
- :DT_BOOLEAN => 45,
- :DT_DATETIME => 46,
- :positiveDecimalValue => 47,
- :stringValue => 48,
- :realValue => 49,
- :charValue => 50,
- :booleanValue => 51,
- :nullValue => 52,
- :binaryValue => 53,
- :octalValue => 54,
- :decimalValue => 55,
- :hexValue => 56,
- "#" => 57,
- "(" => 58,
- ")" => 59,
- "," => 60,
- "{" => 61,
- "}" => 62,
- ";" => 63,
- "[" => 64,
- "]" => 65,
- ":" => 66,
- "$" => 67,
- "=" => 68,
- "." => 69 }
-
-racc_nt_base = 70
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "\"*\"",
- "\"/\"",
- "\"+\"",
- "\"-\"",
- "PRAGMA",
- "INCLUDE",
- "IDENTIFIER",
- "CLASS",
- "ASSOCIATION",
- "INDICATION",
- "AMENDED",
- "ENABLEOVERRIDE",
- "DISABLEOVERRIDE",
- "RESTRICTED",
- "TOSUBCLASS",
- "TOINSTANCE",
- "TRANSLATABLE",
- "QUALIFIER",
- "SCOPE",
- "SCHEMA",
- "PROPERTY",
- "REFERENCE",
- "METHOD",
- "PARAMETER",
- "FLAVOR",
- "INSTANCE",
- "AS",
- "REF",
- "ANY",
- "OF",
- "DT_VOID",
- "DT_UINT8",
- "DT_SINT8",
- "DT_UINT16",
- "DT_SINT16",
- "DT_UINT32",
- "DT_SINT32",
- "DT_UINT64",
- "DT_SINT64",
- "DT_REAL32",
- "DT_REAL64",
- "DT_CHAR16",
- "DT_STR",
- "DT_BOOLEAN",
- "DT_DATETIME",
- "positiveDecimalValue",
- "stringValue",
- "realValue",
- "charValue",
- "booleanValue",
- "nullValue",
- "binaryValue",
- "octalValue",
- "decimalValue",
- "hexValue",
- "\"#\"",
- "\"(\"",
- "\")\"",
- "\",\"",
- "\"{\"",
- "\"}\"",
- "\";\"",
- "\"[\"",
- "\"]\"",
- "\":\"",
- "\"$\"",
- "\"=\"",
- "\".\"",
- "$start",
- "mofSpecification",
- "mofProduction",
- "compilerDirective",
- "classDeclaration",
- "qualifierDeclaration",
- "instanceDeclaration",
- "pragmaParameters_opt",
- "pragmaName",
- "pragmaParameterValues",
- "pragmaParameterValue",
- "string",
- "integerValue",
- "qualifierList_opt",
- "className",
- "alias_opt",
- "superClass_opt",
- "classFeatures",
- "classFeature",
- "propertyDeclaration",
- "methodDeclaration",
- "referenceDeclaration",
- "qualifierList",
- "qualifier",
- "qualifiers",
- "qualifierName",
- "qualifierParameter_opt",
- "flavor_opt",
- "flavor",
- "qualifierParameter",
- "constantValue",
- "arrayInitializer",
- "alias",
- "superClass",
- "aliasIdentifier",
- "dataType",
- "propertyName",
- "array_opt",
- "defaultValue_opt",
- "objectRef",
- "referenceName",
- "methodName",
- "parameterList_opt",
- "parameterList",
- "parameter",
- "parameters",
- "typespec",
- "parameterName",
- "parameterValue_opt",
- "array",
- "defaultValue",
- "positiveDecimalValue_opt",
- "initializer",
- "referenceInitializer",
- "constantValues",
- "instance",
- "objectHandle",
- "namespace_opt",
- "modelPath",
- "namespaceHandle",
- "keyValuePairList",
- "keyValuePair",
- "keyValuePairs",
- "keyname",
- "qualifierType",
- "scope",
- "defaultFlavor_opt",
- "defaultFlavor",
- "metaElements",
- "metaElement",
- "flavors",
- "valueInitializers",
- "valueInitializer" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'mof.y', 41)
- def _reduce_1(val, _values, result)
- result = Hash.new
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 43)
- def _reduce_2(val, _values, result)
- result = { @name => @result }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 45)
- def _reduce_3(val, _values, result)
- result = val[0]
- result[@name] = @result
-
- result
- end
-.,.,
-
-# reduce 4 omitted
-
-module_eval(<<'.,.,', 'mof.y', 53)
- def _reduce_5(val, _values, result)
- #puts "Class '#{val[0].name}'"
- @result.classes << val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 57)
- def _reduce_6(val, _values, result)
- @result.qualifiers << val[0]
- @qualifiers[val[0].name.downcase] = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 61)
- def _reduce_7(val, _values, result)
- @result.instances << val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 71)
- def _reduce_8(val, _values, result)
- raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#pragma include'") unless val[3]
- open val[3], :pragma
-
- result
- end
-.,.,
-
-# reduce 9 omitted
-
-module_eval(<<'.,.,', 'mof.y', 76)
- def _reduce_10(val, _values, result)
- raise StyleError.new(@name,@lineno,@line,"Use '#pragma include' instead of '#include'") unless @style == :wmi
- raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#include'") unless val[2]
- open val[2], :pragma
-
- result
- end
-.,.,
-
-# reduce 11 omitted
-
-module_eval(<<'.,.,', 'mof.y', 88)
- def _reduce_12(val, _values, result)
- raise StyleError.new(@name,@lineno,@line,"#pragma parameter missing") unless @style == :wmi
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 90)
- def _reduce_13(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 14 omitted
-
-# reduce 15 omitted
-
-# reduce 16 omitted
-
-module_eval(<<'.,.,', 'mof.y', 101)
- def _reduce_17(val, _values, result)
- raise StyleError.new(@name,@lineno,@line,"#pragma parameter missing") unless @style == :wmi
- result
- end
-.,.,
-
-# reduce 18 omitted
-
-module_eval(<<'.,.,', 'mof.y', 112)
- def _reduce_19(val, _values, result)
- qualifiers = val[0]
- features = val[6]
- # FIXME: features must not include references
- result = CIM::Class.new(val[2],qualifiers,val[3],val[4],features)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 121)
- def _reduce_20(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 123)
- def _reduce_21(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-# reduce 22 omitted
-
-# reduce 23 omitted
-
-# reduce 24 omitted
-
-# reduce 25 omitted
-
-module_eval(<<'.,.,', 'mof.y', 136)
- def _reduce_26(val, _values, result)
- result = CIM::QualifierSet.new val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 141)
- def _reduce_27(val, _values, result)
- result = val[2]
- result.unshift val[1] if val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 147)
- def _reduce_28(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 149)
- def _reduce_29(val, _values, result)
- result = val[0]
- result << val[2] if val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 156)
- def _reduce_30(val, _values, result)
- # Get qualifier decl
- qualifier = case val[0]
- when CIM::Qualifier then val[0].definition
- when CIM::QualifierDeclaration then val[0]
- when String then @qualifiers[val[0].downcase]
- else
- nil
- end
- raise MOF::Helper::Error.new(@name,@lineno,@line,"'#{val[0]}' is not a valid qualifier") unless qualifier
- value = val[1]
- raise MOF::Helper::Error.new(@name,@lineno,@line,"#{value.inspect} does not match qualifier type '#{qualifier.type}'") unless qualifier.type.matches?(value)||@style == :wmi
- # Don't propagate a boolean 'false'
- if qualifier.type == :boolean && value == false
- result = nil
- else
- result = CIM::Qualifier.new(qualifier,value,val[2])
- end
-
- result
- end
-.,.,
-
-# reduce 31 omitted
-
-module_eval(<<'.,.,', 'mof.y', 179)
- def _reduce_32(val, _values, result)
- result = CIM::QualifierFlavors.new val[1]
- result
- end
-.,.,
-
-# reduce 33 omitted
-
-# reduce 34 omitted
-
-module_eval(<<'.,.,', 'mof.y', 189)
- def _reduce_35(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 36 omitted
-
-# reduce 37 omitted
-
-# reduce 38 omitted
-
-# reduce 39 omitted
-
-# reduce 40 omitted
-
-# reduce 41 omitted
-
-# reduce 42 omitted
-
-module_eval(<<'.,.,', 'mof.y', 196)
- def _reduce_43(val, _values, result)
- case val[0].to_sym
- when :amended, :toinstance
- raise StyleError.new(@name,@lineno,@line,"'#{val[0]}' is not a valid flavor") unless @style == :wmi
- end
-
- result
- end
-.,.,
-
-# reduce 44 omitted
-
-# reduce 45 omitted
-
-# reduce 46 omitted
-
-# reduce 47 omitted
-
-module_eval(<<'.,.,', 'mof.y', 215)
- def _reduce_48(val, _values, result)
- raise ParseError.new("Class name must be prefixed by '<schema>_'") unless val[0].include?("_") || @style == :wmi
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 220)
- def _reduce_49(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 225)
- def _reduce_50(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 230)
- def _reduce_51(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 236)
- def _reduce_52(val, _values, result)
- if val[3]
- type = CIM::Array.new val[3],val[1]
- else
- type = val[1]
- end
- result = CIM::Property.new(type,val[2],val[0],val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 247)
- def _reduce_53(val, _values, result)
- if val[4]
- raise StyleError.new(@name,@lineno,@line,"Array not allowed in reference declaration") unless @style == :wmi
- end
- result = CIM::Reference.new(val[1],val[2],val[0],val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 255)
- def _reduce_54(val, _values, result)
- result = CIM::Method.new(val[1],val[2],val[0],val[4])
- result
- end
-.,.,
-
-# reduce 55 omitted
-
-module_eval(<<'.,.,', 'mof.y', 261)
- def _reduce_56(val, _values, result)
- # tmplprov.mof has 'string Property;'
- raise StyleError.new(@name,@lineno,@line,"Invalid keyword '#{val[0]}' used for property name") unless @style == :wmi
-
- result
- end
-.,.,
-
-# reduce 57 omitted
-
-module_eval(<<'.,.,', 'mof.y', 269)
- def _reduce_58(val, _values, result)
- result = "Indication"
- result
- end
-.,.,
-
-# reduce 59 omitted
-
-# reduce 60 omitted
-
-# reduce 61 omitted
-
-# reduce 62 omitted
-
-# reduce 63 omitted
-
-# reduce 64 omitted
-
-# reduce 65 omitted
-
-# reduce 66 omitted
-
-# reduce 67 omitted
-
-# reduce 68 omitted
-
-# reduce 69 omitted
-
-# reduce 70 omitted
-
-# reduce 71 omitted
-
-# reduce 72 omitted
-
-# reduce 73 omitted
-
-module_eval(<<'.,.,', 'mof.y', 292)
- def _reduce_74(val, _values, result)
- raise StyleError.new(@name,@lineno,@line,"'void' is not a valid datatype") unless @style == :wmi
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 297)
- def _reduce_75(val, _values, result)
- # WMI uses class names as data types (without REF ?!)
- raise StyleError.new(@name,@lineno,@line,"Expected 'ref' keyword after classname '#{val[0]}'") unless @style == :wmi
- result = CIM::ReferenceType.new val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 303)
- def _reduce_76(val, _values, result)
- result = CIM::ReferenceType.new val[0]
- result
- end
-.,.,
-
-# reduce 77 omitted
-
-# reduce 78 omitted
-
-module_eval(<<'.,.,', 'mof.y', 313)
- def _reduce_79(val, _values, result)
- result = val[1].unshift val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 318)
- def _reduce_80(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 320)
- def _reduce_81(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 325)
- def _reduce_82(val, _values, result)
- if val[3]
- type = CIM::Array.new val[3], val[1]
- else
- type = val[1]
- end
- result = CIM::Property.new(type,val[2],val[0])
-
- result
- end
-.,.,
-
-# reduce 83 omitted
-
-# reduce 84 omitted
-
-# reduce 85 omitted
-
-# reduce 86 omitted
-
-# reduce 87 omitted
-
-# reduce 88 omitted
-
-module_eval(<<'.,.,', 'mof.y', 351)
- def _reduce_89(val, _values, result)
- raise "Default parameter value not allowed in syntax style '{@style}'" unless @style == :wmi
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 356)
- def _reduce_90(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 361)
- def _reduce_91(val, _values, result)
- result = -1
- result
- end
-.,.,
-
-# reduce 92 omitted
-
-# reduce 93 omitted
-
-# reduce 94 omitted
-
-module_eval(<<'.,.,', 'mof.y', 372)
- def _reduce_95(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 96 omitted
-
-# reduce 97 omitted
-
-# reduce 98 omitted
-
-module_eval(<<'.,.,', 'mof.y', 383)
- def _reduce_99(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 100 omitted
-
-module_eval(<<'.,.,', 'mof.y', 389)
- def _reduce_101(val, _values, result)
- result = [ val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 391)
- def _reduce_102(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-# reduce 103 omitted
-
-# reduce 104 omitted
-
-# reduce 105 omitted
-
-# reduce 106 omitted
-
-# reduce 107 omitted
-
-# reduce 108 omitted
-
-module_eval(<<'.,.,', 'mof.y', 402)
- def _reduce_109(val, _values, result)
- raise "Instance as property value not allowed in syntax style '{@style}'" unless @style == :wmi
- result
- end
-.,.,
-
-# reduce 110 omitted
-
-# reduce 111 omitted
-
-# reduce 112 omitted
-
-# reduce 113 omitted
-
-# reduce 114 omitted
-
-# reduce 115 omitted
-
-module_eval(<<'.,.,', 'mof.y', 416)
- def _reduce_116(val, _values, result)
- result = val[0] + val[1]
- result
- end
-.,.,
-
-# reduce 117 omitted
-
-# reduce 118 omitted
-
-# reduce 119 omitted
-
-# reduce 120 omitted
-
-# reduce 121 omitted
-
-# reduce 122 omitted
-
-# reduce 123 omitted
-
-# reduce 124 omitted
-
-# reduce 125 omitted
-
-# reduce 126 omitted
-
-# reduce 127 omitted
-
-# reduce 128 omitted
-
-# reduce 129 omitted
-
-module_eval(<<'.,.,', 'mof.y', 471)
- def _reduce_130(val, _values, result)
- result = CIM::QualifierDeclaration.new( val[1], val[2][0], val[2][1], val[3], val[4])
- result
- end
-.,.,
-
-# reduce 131 omitted
-
-# reduce 132 omitted
-
-# reduce 133 omitted
-
-# reduce 134 omitted
-
-# reduce 135 omitted
-
-# reduce 136 omitted
-
-# reduce 137 omitted
-
-module_eval(<<'.,.,', 'mof.y', 490)
- def _reduce_138(val, _values, result)
- type = val[2].nil? ? val[1] : CIM::Array.new(val[2],val[1])
- result = [ type, val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 497)
- def _reduce_139(val, _values, result)
- result = CIM::QualifierScopes.new(val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 502)
- def _reduce_140(val, _values, result)
- result = [ val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 504)
- def _reduce_141(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-# reduce 142 omitted
-
-# reduce 143 omitted
-
-# reduce 144 omitted
-
-# reduce 145 omitted
-
-# reduce 146 omitted
-
-# reduce 147 omitted
-
-# reduce 148 omitted
-
-# reduce 149 omitted
-
-# reduce 150 omitted
-
-# reduce 151 omitted
-
-module_eval(<<'.,.,', 'mof.y', 522)
- def _reduce_152(val, _values, result)
- result = CIM::QualifierFlavors.new val[3]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 527)
- def _reduce_153(val, _values, result)
- result = [ val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'mof.y', 529)
- def _reduce_154(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-# reduce 155 omitted
-
-# reduce 156 omitted
-
-# reduce 157 omitted
-
-# reduce 158 omitted
-
-# reduce 159 omitted
-
-module_eval(<<'.,.,', 'mof.y', 553)
- def _reduce_160(val, _values, result)
- raise "Instance property '#{val[1]} must have a value" unless @style == :wmi
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module MOF
-
-
diff --git a/test/racc/regress/namae b/test/racc/regress/namae
deleted file mode 100644
index 43f1b09abb..0000000000
--- a/test/racc/regress/namae
+++ /dev/null
@@ -1,634 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-require 'singleton'
-require 'strscan'
-
-module Namae
- class Parser < Racc::Parser
-
-module_eval(<<'...end namae.y/module_eval...', 'namae.y', 135)
-
- include Singleton
-
- attr_reader :options, :input
-
- def initialize
- @input, @options = StringScanner.new(''), {
- :debug => false,
- :prefer_comma_as_separator => false,
- :comma => ',',
- :stops => ',;',
- :separator => /\s*(\band\b|\&|;)\s*/i,
- :title => /\s*\b(sir|lord|count(ess)?|(gen|adm|col|maj|capt|cmdr|lt|sgt|cpl|pvt|prof|dr|md|ph\.?d)\.?)(\s+|$)/i,
- :suffix => /\s*\b(JR|Jr|jr|SR|Sr|sr|[IVX]{2,})(\.|\b)/,
- :appellation => /\s*\b((mrs?|ms|fr|hr)\.?|miss|herr|frau)(\s+|$)/i
- }
- end
-
- def debug?
- options[:debug] || ENV['DEBUG']
- end
-
- def separator
- options[:separator]
- end
-
- def comma
- options[:comma]
- end
-
- def stops
- options[:stops]
- end
-
- def title
- options[:title]
- end
-
- def suffix
- options[:suffix]
- end
-
- def appellation
- options[:appellation]
- end
-
- def prefer_comma_as_separator?
- options[:prefer_comma_as_separator]
- end
-
- def parse(input)
- parse!(input)
- rescue => e
- warn e.message if debug?
- []
- end
-
- def parse!(string)
- input.string = normalize(string)
- reset
- do_parse
- end
-
- def normalize(string)
- string = string.strip
- string
- end
-
- def reset
- @commas, @words, @initials, @suffices, @yydebug = 0, 0, 0, 0, debug?
- self
- end
-
- private
-
- def stack
- @vstack || @racc_vstack || []
- end
-
- def last_token
- stack[-1]
- end
-
- def consume_separator
- return next_token if seen_separator?
- @commas, @words, @initials, @suffices = 0, 0, 0, 0
- [:AND, :AND]
- end
-
- def consume_comma
- @commas += 1
- [:COMMA, :COMMA]
- end
-
- def consume_word(type, word)
- @words += 1
-
- case type
- when :UWORD
- @initials += 1 if word =~ /^[[:upper:]]+\b/
- when :SUFFIX
- @suffices += 1
- end
-
- [type, word]
- end
-
- def seen_separator?
- !stack.empty? && last_token == :AND
- end
-
- def suffix?
- !@suffices.zero? || will_see_suffix?
- end
-
- def will_see_suffix?
- input.peek(8).to_s.strip.split(/\s+/)[0] =~ suffix
- end
-
- def will_see_initial?
- input.peek(6).to_s.strip.split(/\s+/)[0] =~ /^[[:upper:]]+\b/
- end
-
- def seen_full_name?
- prefer_comma_as_separator? && @words > 1 &&
- (@initials > 0 || !will_see_initial?) && !will_see_suffix?
- end
-
- def next_token
- case
- when input.nil?, input.eos?
- nil
- when input.scan(separator)
- consume_separator
- when input.scan(/\s*#{comma}\s*/)
- if @commas.zero? && !seen_full_name? || @commas == 1 && suffix?
- consume_comma
- else
- consume_separator
- end
- when input.scan(/\s+/)
- next_token
- when input.scan(title)
- consume_word(:TITLE, input.matched.strip)
- when input.scan(suffix)
- consume_word(:SUFFIX, input.matched.strip)
- when input.scan(appellation)
- [:APPELLATION, input.matched.strip]
- when input.scan(/((\\\w+)?\{[^\}]*\})*[[:upper:]][^\s#{stops}]*/)
- consume_word(:UWORD, input.matched)
- when input.scan(/((\\\w+)?\{[^\}]*\})*[[:lower:]][^\s#{stops}]*/)
- consume_word(:LWORD, input.matched)
- when input.scan(/(\\\w+)?\{[^\}]*\}[^\s#{stops}]*/)
- consume_word(:PWORD, input.matched)
- when input.scan(/('[^'\n]+')|("[^"\n]+")/)
- consume_word(:NICK, input.matched[1...-1])
- else
- raise ArgumentError,
- "Failed to parse name #{input.string.inspect}: unmatched data at offset #{input.pos}"
- end
- end
-
- def on_error(tid, value, stack)
- raise ArgumentError,
- "Failed to parse name: unexpected '#{value}' at #{stack.inspect}"
- end
-
-# -*- racc -*-
-...end namae.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- -39, 53, 52, 54, -40, 39, 62, -39, 39, -39,
- -39, -40, 67, -40, -40, 66, 53, 52, 54, 32,
- 59, 16, 58, -34, 53, 52, 54, -38, 17, -22,
- 30, 39, 31, 45, -38, 53, 52, 54, 14, 12,
- 15, 68, 39, 7, 8, 14, 12, 15, 58, 33,
- 7, 8, 14, 22, 15, 24, 14, 22, 15, 24,
- -19, -19, -19, 30, 42, 31, 30, 28, 31, -20,
- -20, -20, 30, 46, 31, 53, 52, 54, 30, 28,
- 31, 30, 28, 31, 30, 28, 31, -19, -19, -19,
- 30, 28, 31, 14, 22, 15, 53, 52, 54, 39,
- 58, 59, 39, 59, 39 ]
-
-racc_action_check = [
- 14, 32, 32, 32, 15, 64, 44, 14, 32, 14,
- 14, 15, 50, 15, 15, 49, 49, 49, 49, 11,
- 50, 1, 70, 49, 45, 45, 45, 12, 1, 12,
- 43, 45, 43, 27, 12, 62, 62, 62, 0, 0,
- 0, 57, 62, 0, 0, 17, 17, 17, 60, 16,
- 17, 17, 20, 20, 20, 20, 9, 9, 9, 9,
- 22, 22, 22, 24, 24, 24, 25, 25, 25, 28,
- 28, 28, 29, 29, 29, 73, 73, 73, 21, 21,
- 21, 35, 35, 35, 41, 41, 41, 42, 42, 42,
- 10, 10, 10, 5, 5, 5, 67, 67, 67, 61,
- 37, 38, 40, 72, 23 ]
-
-racc_action_pointer = [
- 35, 21, nil, nil, nil, 90, nil, nil, nil, 53,
- 87, 17, 27, nil, 0, 4, 49, 42, nil, nil,
- 49, 75, 57, 94, 60, 63, nil, 31, 66, 69,
- nil, nil, -2, nil, nil, 78, nil, 91, 91, nil,
- 92, 81, 84, 27, 4, 21, nil, nil, nil, 13,
- 10, nil, nil, nil, nil, nil, nil, 32, nil, nil,
- 39, 89, 32, nil, -5, nil, nil, 93, nil, nil,
- 13, nil, 93, 72, nil ]
-
-racc_action_default = [
- -1, -49, -2, -4, -5, -49, -8, -9, -10, -23,
- -49, -49, -19, -28, -30, -31, -49, -49, -6, -7,
- -49, -49, -38, -41, -49, -49, -29, -15, -22, -23,
- -30, -31, -36, 75, -3, -49, -15, -45, -42, -43,
- -41, -49, -22, -23, -14, -36, -21, -16, -24, -37,
- -26, -32, -38, -39, -40, -14, -11, -46, -47, -44,
- -45, -41, -36, -17, -49, -33, -35, -49, -48, -12,
- -45, -18, -25, -27, -13 ]
-
-racc_goto_table = [
- 3, 37, 26, 50, 56, 18, 2, 9, 47, 23,
- 73, 64, 20, 26, 19, 27, 50, 3, 60, 1,
- 23, 63, 26, 34, 9, nil, 36, 69, 21, 40,
- 44, 43, 25, 50, nil, 72, 26, 74, 71, 70,
- 55, nil, nil, 35, nil, nil, 61, 41, nil, 65,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 65 ]
-
-racc_goto_check = [
- 3, 8, 17, 16, 9, 3, 2, 7, 12, 3,
- 14, 15, 7, 17, 4, 10, 16, 3, 8, 1,
- 3, 12, 17, 2, 7, nil, 10, 9, 11, 10,
- 10, 7, 11, 16, nil, 16, 17, 9, 12, 8,
- 10, nil, nil, 11, nil, nil, 10, 11, nil, 3,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 3 ]
-
-racc_goto_pointer = [
- nil, 19, 6, 0, 9, nil, nil, 7, -22, -33,
- 5, 23, -24, nil, -57, -38, -29, -7, nil ]
-
-racc_goto_default = [
- nil, nil, nil, 51, 4, 5, 6, 29, nil, nil,
- 11, 10, nil, 48, 49, nil, 38, 13, 57 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 0, 12, :_reduce_1,
- 1, 12, :_reduce_2,
- 3, 12, :_reduce_3,
- 1, 13, :_reduce_4,
- 1, 13, :_reduce_none,
- 2, 13, :_reduce_6,
- 2, 13, :_reduce_7,
- 1, 13, :_reduce_none,
- 1, 16, :_reduce_9,
- 1, 16, :_reduce_10,
- 4, 15, :_reduce_11,
- 5, 15, :_reduce_12,
- 6, 15, :_reduce_13,
- 3, 15, :_reduce_14,
- 2, 15, :_reduce_15,
- 3, 17, :_reduce_16,
- 4, 17, :_reduce_17,
- 5, 17, :_reduce_18,
- 1, 22, :_reduce_none,
- 2, 22, :_reduce_20,
- 3, 22, :_reduce_21,
- 1, 21, :_reduce_none,
- 1, 21, :_reduce_none,
- 1, 23, :_reduce_24,
- 3, 23, :_reduce_25,
- 1, 23, :_reduce_26,
- 3, 23, :_reduce_27,
- 1, 18, :_reduce_none,
- 2, 18, :_reduce_29,
- 1, 28, :_reduce_none,
- 1, 28, :_reduce_none,
- 1, 25, :_reduce_none,
- 2, 25, :_reduce_33,
- 0, 26, :_reduce_none,
- 1, 26, :_reduce_none,
- 0, 24, :_reduce_none,
- 1, 24, :_reduce_none,
- 1, 14, :_reduce_none,
- 1, 14, :_reduce_none,
- 1, 14, :_reduce_none,
- 0, 19, :_reduce_none,
- 1, 19, :_reduce_none,
- 1, 27, :_reduce_none,
- 2, 27, :_reduce_44,
- 0, 20, :_reduce_none,
- 1, 20, :_reduce_none,
- 1, 29, :_reduce_none,
- 2, 29, :_reduce_48 ]
-
-racc_reduce_n = 49
-
-racc_shift_n = 75
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :COMMA => 2,
- :UWORD => 3,
- :LWORD => 4,
- :PWORD => 5,
- :NICK => 6,
- :AND => 7,
- :APPELLATION => 8,
- :TITLE => 9,
- :SUFFIX => 10 }
-
-racc_nt_base = 11
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "COMMA",
- "UWORD",
- "LWORD",
- "PWORD",
- "NICK",
- "AND",
- "APPELLATION",
- "TITLE",
- "SUFFIX",
- "$start",
- "names",
- "name",
- "word",
- "display_order",
- "honorific",
- "sort_order",
- "u_words",
- "opt_suffices",
- "opt_titles",
- "last",
- "von",
- "first",
- "opt_words",
- "words",
- "opt_comma",
- "suffices",
- "u_word",
- "titles" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'namae.y', 39)
- def _reduce_1(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 40)
- def _reduce_2(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 41)
- def _reduce_3(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 43)
- def _reduce_4(val, _values, result)
- result = Name.new(:given => val[0])
- result
- end
-.,.,
-
-# reduce 5 omitted
-
-module_eval(<<'.,.,', 'namae.y', 45)
- def _reduce_6(val, _values, result)
- result = val[0].merge(:family => val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 46)
- def _reduce_7(val, _values, result)
- result = val[1].merge(val[0])
- result
- end
-.,.,
-
-# reduce 8 omitted
-
-module_eval(<<'.,.,', 'namae.y', 49)
- def _reduce_9(val, _values, result)
- result = Name.new(:appellation => val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 50)
- def _reduce_10(val, _values, result)
- result = Name.new(:title => val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 54)
- def _reduce_11(val, _values, result)
- result = Name.new(:given => val[0], :family => val[1],
- :suffix => val[2], :title => val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 59)
- def _reduce_12(val, _values, result)
- result = Name.new(:given => val[0], :nick => val[1],
- :family => val[2], :suffix => val[3], :title => val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 64)
- def _reduce_13(val, _values, result)
- result = Name.new(:given => val[0], :nick => val[1],
- :particle => val[2], :family => val[3],
- :suffix => val[4], :title => val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 70)
- def _reduce_14(val, _values, result)
- result = Name.new(:given => val[0], :particle => val[1],
- :family => val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 75)
- def _reduce_15(val, _values, result)
- result = Name.new(:particle => val[0], :family => val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 80)
- def _reduce_16(val, _values, result)
- result = Name.new({ :family => val[0], :suffix => val[2][0],
- :given => val[2][1] }, !!val[2][0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 85)
- def _reduce_17(val, _values, result)
- result = Name.new({ :particle => val[0], :family => val[1],
- :suffix => val[3][0], :given => val[3][1] }, !!val[3][0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 90)
- def _reduce_18(val, _values, result)
- result = Name.new({ :particle => val[0,2].join(' '), :family => val[2],
- :suffix => val[4][0], :given => val[4][1] }, !!val[4][0])
-
- result
- end
-.,.,
-
-# reduce 19 omitted
-
-module_eval(<<'.,.,', 'namae.y', 96)
- def _reduce_20(val, _values, result)
- result = val.join(' ')
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 97)
- def _reduce_21(val, _values, result)
- result = val.join(' ')
- result
- end
-.,.,
-
-# reduce 22 omitted
-
-# reduce 23 omitted
-
-module_eval(<<'.,.,', 'namae.y', 101)
- def _reduce_24(val, _values, result)
- result = [nil,val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 102)
- def _reduce_25(val, _values, result)
- result = [val[2],val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 103)
- def _reduce_26(val, _values, result)
- result = [val[0],nil]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'namae.y', 104)
- def _reduce_27(val, _values, result)
- result = [val[0],val[2]]
- result
- end
-.,.,
-
-# reduce 28 omitted
-
-module_eval(<<'.,.,', 'namae.y', 107)
- def _reduce_29(val, _values, result)
- result = val.join(' ')
- result
- end
-.,.,
-
-# reduce 30 omitted
-
-# reduce 31 omitted
-
-# reduce 32 omitted
-
-module_eval(<<'.,.,', 'namae.y', 112)
- def _reduce_33(val, _values, result)
- result = val.join(' ')
- result
- end
-.,.,
-
-# reduce 34 omitted
-
-# reduce 35 omitted
-
-# reduce 36 omitted
-
-# reduce 37 omitted
-
-# reduce 38 omitted
-
-# reduce 39 omitted
-
-# reduce 40 omitted
-
-# reduce 41 omitted
-
-# reduce 42 omitted
-
-# reduce 43 omitted
-
-module_eval(<<'.,.,', 'namae.y', 122)
- def _reduce_44(val, _values, result)
- result = val.join(' ')
- result
- end
-.,.,
-
-# reduce 45 omitted
-
-# reduce 46 omitted
-
-# reduce 47 omitted
-
-module_eval(<<'.,.,', 'namae.y', 127)
- def _reduce_48(val, _values, result)
- result = val.join(' ')
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module Namae
diff --git a/test/racc/regress/nasl b/test/racc/regress/nasl
deleted file mode 100644
index ea47343001..0000000000
--- a/test/racc/regress/nasl
+++ /dev/null
@@ -1,2058 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-
-require 'nasl/parser/tree'
-
-require 'nasl/parser/argument'
-require 'nasl/parser/array'
-require 'nasl/parser/assigment'
-require 'nasl/parser/block'
-require 'nasl/parser/break'
-require 'nasl/parser/call'
-require 'nasl/parser/comment'
-require 'nasl/parser/continue'
-require 'nasl/parser/decrement'
-require 'nasl/parser/empty'
-require 'nasl/parser/export'
-require 'nasl/parser/expression'
-require 'nasl/parser/for'
-require 'nasl/parser/foreach'
-require 'nasl/parser/function'
-require 'nasl/parser/global'
-require 'nasl/parser/identifier'
-require 'nasl/parser/if'
-require 'nasl/parser/import'
-require 'nasl/parser/include'
-require 'nasl/parser/increment'
-require 'nasl/parser/integer'
-require 'nasl/parser/ip'
-require 'nasl/parser/key_value_pair'
-require 'nasl/parser/list'
-require 'nasl/parser/local'
-require 'nasl/parser/lvalue'
-require 'nasl/parser/parameter'
-require 'nasl/parser/reference'
-require 'nasl/parser/repeat'
-require 'nasl/parser/repetition'
-require 'nasl/parser/return'
-require 'nasl/parser/string'
-require 'nasl/parser/undefined'
-require 'nasl/parser/while'
-
-module Nasl
- class Grammar < Racc::Parser
-
-module_eval(<<'...end nasl.y/module_eval...', 'nasl.y', 582)
-
-def n(cls, *args)
- begin
- Nasl.const_get(cls).new(@tree, *args)
- rescue
- puts "An exception occurred during the creation of a #{cls} instance."
- puts
- puts "The arguments passed to the constructor were:"
- puts args
- puts
- puts @tok.last.context
- puts
- raise
- end
-end
-
-def c(*args)
- n(:Comment, *args)
- args[1]
-end
-
-def on_error(type, value, stack)
- raise ParseException, "The language's grammar does not permit #{value.name} to appear here", value.context
-end
-
-def next_token
- @tok = @tkz.get_token
-
- if @first && @tok.first == :COMMENT
- n(:Comment, @tok.last)
- @tok = @tkz.get_token
- end
- @first = false
-
- return @tok
-end
-
-def parse(env, code, path)
- @first = true
- @tree = Tree.new(env)
- @tkz = Tokenizer.new(code, path)
- @tree.concat(do_parse)
-end
-
-...end nasl.y/module_eval...
-##### State transition tables begin ###
-
-clist = [
-'144,143,161,162,163,164,165,166,157,158,159,160,153,152,151,154,155',
-'156,145,146,147,149,150,82,54,111,148,81,218,83,55,51,50,72,54,54,80',
-'102,103,65,55,55,53,68,54,54,66,95,102,103,55,55,53,53,43,54,218,269',
-'67,226,96,55,53,53,97,98,99,100,101,102,103,104,82,53,267,217,81,130',
-'83,131,51,50,130,54,131,80,130,54,131,55,51,50,225,55,54,195,95,147',
-'149,150,55,53,192,148,54,53,185,37,172,96,55,167,53,97,98,99,100,101',
-'102,103,104,82,53,141,148,81,54,83,148,51,50,148,55,253,80,254,54,255',
-'256,51,50,257,55,54,53,95,147,149,150,55,10,11,148,54,53,258,259,37',
-'96,55,260,53,97,98,99,100,101,102,103,104,82,53,262,138,81,54,83,137',
-'51,50,136,55,54,80,54,54,306,134,55,64,55,55,54,53,95,63,300,56,55,301',
-'53,266,53,53,268,133,94,96,270,43,53,97,98,99,100,101,102,103,104,82',
-'273,11,274,81,275,83,148,51,50,148,54,148,80,179,148,276,55,114,112',
-'109,74,54,73,95,,,,55,53,97,98,99,100,101,102,103,96,,,53,97,98,99,100',
-'101,102,103,104,82,,,,81,,83,,51,50,,54,,80,,,,55,,,,,54,,95,,,,55,53',
-'97,98,99,100,101,102,103,96,,,53,97,98,99,100,101,102,103,104,82,,,',
-'81,,83,,51,50,,,,80,154,155,156,145,146,147,149,150,54,,95,148,,,55',
-',145,146,147,149,150,,,96,148,,53,97,98,99,100,101,102,103,104,82,,',
-',81,,83,,51,50,,,,80,,145,146,147,149,150,,,54,148,95,,,,55,,145,146',
-'147,149,150,,,96,148,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,',
-'51,50,,,,80,97,98,99,100,101,,,,54,,95,,,,55,97,98,99,100,101,,,,96',
-',,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,97,98,99',
-'100,101,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104',
-'82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98',
-'99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55',
-',,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,',
-'80,208,,,,,,,,54,,95,,,,55,,,,,,,,94,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97',
-'98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,',
-',,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50',
-',,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,94,96,,,53',
-'97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95',
-',,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51',
-'50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97',
-'98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,',
-',,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50',
-',,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97',
-'98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,',
-',,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50',
-',,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97',
-'98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,',
-',,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50',
-',,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,94,96,,,53',
-'97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95',
-',,,55,,,,,,,,94,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51',
-'50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,78,,,,,,,54,,95,,,,55,,,,,,,,94,96,,',
-'53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54',
-',95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83',
-',51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,94,96,,,53,97,98,99,100,101',
-'102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,94',
-'96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,',
-',,,54,,95,,,,55,,,,,,,,94,96,,,53,97,98,99,100,101,102,103,104,82,,',
-',81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,94,96,,,53,97,98,99',
-'100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,',
-',,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80',
-',,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82',
-',,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99',
-'100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,',
-',,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80',
-',,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82',
-',,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99',
-'100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,',
-',,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80',
-',,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82',
-',,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99',
-'100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,',
-',,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80',
-',,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82',
-',,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99',
-'100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,',
-',,,,,,94,96,184,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50',
-',,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97',
-'98,99,100,101,102,103,104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,',
-',,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103,104,82,,,,81,,83,,51,50',
-',,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97,98,99,100,101,102,103',
-'104,82,,,,81,,83,,51,50,,,,80,,,,,,,,,54,,95,,,,55,,,,,,,,,96,,,53,97',
-'98,99,100,101,102,103,104,115,116,117,118,119,120,123,122,121,115,116',
-'117,118,119,120,123,122,121,153,152,151,154,155,156,145,146,147,149',
-'150,,,,148,,,,126,125,,,,124,,,,126,125,,,,124,144,143,161,162,163,164',
-'165,166,157,158,159,160,153,152,151,154,155,156,145,146,147,149,150',
-',,,148,,,,,,,,142,144,143,161,162,163,164,165,166,157,158,159,160,153',
-'152,151,154,155,156,145,146,147,149,150,,,,148,,,,,,,,221,144,143,161',
-'162,163,164,165,166,157,158,159,160,153,152,151,154,155,156,145,146',
-'147,149,150,,,,148,,,,,,,,297,144,143,161,162,163,164,165,166,157,158',
-'159,160,153,152,151,154,155,156,145,146,147,149,150,,,,148,,,,,,,,289',
-'144,143,161,162,163,164,165,166,157,158,159,160,153,152,151,154,155',
-'156,145,146,147,149,150,,,,148,,,,,,,286,144,143,161,162,163,164,165',
-'166,157,158,159,160,153,152,151,154,155,156,145,146,147,149,150,,,,148',
-',,,,,,265,144,143,161,162,163,164,165,166,157,158,159,160,153,152,151',
-'154,155,156,145,146,147,149,150,,,,148,,,,,,,299,144,143,161,162,163',
-'164,165,166,157,158,159,160,153,152,151,154,155,156,145,146,147,149',
-'150,,,,148,,,,,,,263,144,143,161,162,163,164,165,166,157,158,159,160',
-'153,152,151,154,155,156,145,146,147,149,150,,,,148,51,50,4,10,11,,251',
-'36,32,34,37,39,40,41,54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36',
-'32,34,37,39,40,41,54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36,32',
-'34,37,39,40,41,54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36,32,34',
-'37,39,40,41,54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36,32,34,37',
-'39,40,41,54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36,32,34,37,39',
-'40,41,54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36,32,34,37,39,40',
-'41,54,42,43,107,44,45,55,46,,47,,48,51,50,105,,,,53,36,32,34,37,39,40',
-'41,54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36,32,34,37,39,40,41',
-'54,42,43,,44,45,55,46,,47,,48,51,50,4,10,11,,53,36,32,34,37,39,40,41',
-'54,42,43,,44,45,55,46,,47,,48,51,50,105,,,,53,36,32,34,37,39,40,41,54',
-'42,43,,44,45,55,46,,47,,48,,,,,,,53,144,143,161,162,163,164,165,166',
-'157,158,159,160,153,152,151,154,155,156,145,146,147,149,150,,,,148,144',
-'143,161,162,163,164,165,166,157,158,159,160,153,152,151,154,155,156',
-'145,146,147,149,150,,,,148,144,143,161,162,163,164,165,166,157,158,159',
-'160,153,152,151,154,155,156,145,146,147,149,150,,,,148,144,143,161,162',
-'163,164,165,166,157,158,159,160,153,152,151,154,155,156,145,146,147',
-'149,150,,,,148,144,143,161,162,163,164,165,166,157,158,159,160,153,152',
-'151,154,155,156,145,146,147,149,150,,,,148,144,143,161,162,163,164,165',
-'166,157,158,159,160,153,152,151,154,155,156,145,146,147,149,150,,,,148',
-'144,143,161,162,163,164,165,166,157,158,159,160,153,152,151,154,155',
-'156,145,146,147,149,150,,,,148,144,143,161,162,163,164,165,166,157,158',
-'159,160,153,152,151,154,155,156,145,146,147,149,150,,,,148,144,143,161',
-'162,163,164,165,166,157,158,159,160,153,152,151,154,155,156,145,146',
-'147,149,150,,,,148,144,143,161,162,163,164,165,166,157,158,159,160,153',
-'152,151,154,155,156,145,146,147,149,150,,,,148,144,143,161,162,163,164',
-'165,166,157,158,159,160,153,152,151,154,155,156,145,146,147,149,150',
-',,,148,144,143,161,162,163,164,165,166,157,158,159,160,153,152,151,154',
-'155,156,145,146,147,149,150,,,,148,144,143,161,162,163,164,165,166,157',
-'158,159,160,153,152,151,154,155,156,145,146,147,149,150,,,,148,144,143',
-'161,162,163,164,165,166,157,158,159,160,153,152,151,154,155,156,145',
-'146,147,149,150,,,,148,144,143,161,162,163,164,165,166,157,158,159,160',
-'153,152,151,154,155,156,145,146,147,149,150,,,,148,144,143,161,162,163',
-'164,165,166,157,158,159,160,153,152,151,154,155,156,145,146,147,149',
-'150,,,,148,143,161,162,163,164,165,166,157,158,159,160,153,152,151,154',
-'155,156,145,146,147,149,150,,,,148,161,162,163,164,165,166,157,158,159',
-'160,153,152,151,154,155,156,145,146,147,149,150,,,,148,153,152,151,154',
-'155,156,145,146,147,149,150,,,,148,153,152,151,154,155,156,145,146,147',
-'149,150,,,,148,153,152,151,154,155,156,145,146,147,149,150,,,,148,153',
-'152,151,154,155,156,145,146,147,149,150,,,,148,153,152,151,154,155,156',
-'145,146,147,149,150,,,,148,153,152,151,154,155,156,145,146,147,149,150',
-',,,148,153,152,151,154,155,156,145,146,147,149,150,,,,148,153,152,151',
-'154,155,156,145,146,147,149,150,,,,148,153,152,151,154,155,156,145,146',
-'147,149,150,,,,148,152,151,154,155,156,145,146,147,149,150,,,,148,151',
-'154,155,156,145,146,147,149,150,,,,148' ]
- racc_action_table = arr = ::Array.new(4010, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213',
-'213,213,213,213,213,213,150,138,45,213,150,273,150,138,150,150,38,45',
-'94,150,74,74,33,45,94,138,35,51,150,33,150,73,73,51,150,45,94,270,273',
-'134,213,34,140,150,273,51,150,150,150,150,150,150,150,150,150,157,273',
-'210,134,157,210,157,210,157,157,52,134,52,157,132,50,132,134,297,297',
-'139,50,157,113,157,230,230,230,157,134,110,230,297,50,106,105,90,157',
-'297,77,157,157,157,157,157,157,157,157,157,114,297,75,169,114,11,114',
-'170,114,114,171,11,174,114,175,41,176,177,109,109,178,41,114,11,114',
-'229,229,229,114,4,4,229,109,41,182,183,4,114,109,187,114,114,114,114',
-'114,114,114,114,114,115,109,193,71,115,37,115,70,115,115,69,37,111,115',
-'131,218,302,62,111,32,131,218,115,37,115,31,288,1,115,296,111,207,131',
-'218,212,56,115,115,216,217,115,115,115,115,115,115,115,115,115,116,220',
-'10,225,116,226,116,231,116,116,232,95,233,116,95,234,252,95,48,46,44',
-'40,116,39,116,,,,116,95,95,95,95,95,95,95,95,116,,,116,116,116,116,116',
-'116,116,116,116,117,,,,117,,117,,117,117,,256,,117,,,,256,,,,,117,,117',
-',,,117,256,256,256,256,256,256,256,256,117,,,117,117,117,117,117,117',
-'117,117,117,118,,,,118,,118,,118,118,,,,118,235,235,235,235,235,235',
-'235,235,118,,118,235,,,118,,238,238,238,238,238,,,118,238,,118,118,118',
-'118,118,118,118,118,118,119,,,,119,,119,,119,119,,,,119,,239,239,239',
-'239,239,,,119,239,119,,,,119,,240,240,240,240,240,,,119,240,,119,119',
-'119,119,119,119,119,119,119,120,,,,120,,120,,120,120,,,,120,276,276',
-'276,276,276,,,,120,,120,,,,120,172,172,172,172,172,,,,120,,,120,120',
-'120,120,120,120,120,120,120,121,,,,121,,121,,121,121,,,,121,301,301',
-'301,301,301,,,,121,,121,,,,121,,,,,,,,,121,,,121,121,121,121,121,121',
-'121,121,121,122,,,,122,,122,,122,122,,,,122,,,,,,,,,122,,122,,,,122',
-',,,,,,,,122,,,122,122,122,122,122,122,122,122,122,123,,,,123,,123,,123',
-'123,,,,123,,,,,,,,,123,,123,,,,123,,,,,,,,,123,,,123,123,123,123,123',
-'123,123,123,123,124,,,,124,,124,,124,124,,,,124,124,,,,,,,,124,,124',
-',,,124,,,,,,,,124,124,,,124,124,124,124,124,124,124,124,124,130,,,,130',
-',130,,130,130,,,,130,,,,,,,,,130,,130,,,,130,,,,,,,,,130,,,130,130,130',
-'130,130,130,130,130,130,156,,,,156,,156,,156,156,,,,156,,,,,,,,,156',
-',156,,,,156,,,,,,,,,156,,,156,156,156,156,156,156,156,156,156,155,,',
-',155,,155,,155,155,,,,155,,,,,,,,,155,,155,,,,155,,,,,,,,,155,,,155',
-'155,155,155,155,155,155,155,155,137,,,,137,,137,,137,137,,,,137,,,,',
-',,,,137,,137,,,,137,,,,,,,,137,137,,,137,137,137,137,137,137,137,137',
-'137,154,,,,154,,154,,154,154,,,,154,,,,,,,,,154,,154,,,,154,,,,,,,,',
-'154,,,154,154,154,154,154,154,154,154,154,153,,,,153,,153,,153,153,',
-',,153,,,,,,,,,153,,153,,,,153,,,,,,,,,153,,,153,153,153,153,153,153',
-'153,153,153,152,,,,152,,152,,152,152,,,,152,,,,,,,,,152,,152,,,,152',
-',,,,,,,,152,,,152,152,152,152,152,152,152,152,152,143,,,,143,,143,,143',
-'143,,,,143,,,,,,,,,143,,143,,,,143,,,,,,,,,143,,,143,143,143,143,143',
-'143,143,143,143,144,,,,144,,144,,144,144,,,,144,,,,,,,,,144,,144,,,',
-'144,,,,,,,,,144,,,144,144,144,144,144,144,144,144,144,145,,,,145,,145',
-',145,145,,,,145,,,,,,,,,145,,145,,,,145,,,,,,,,,145,,,145,145,145,145',
-'145,145,145,145,145,146,,,,146,,146,,146,146,,,,146,,,,,,,,,146,,146',
-',,,146,,,,,,,,,146,,,146,146,146,146,146,146,146,146,146,147,,,,147',
-',147,,147,147,,,,147,,,,,,,,,147,,147,,,,147,,,,,,,,,147,,,147,147,147',
-'147,147,147,147,147,147,148,,,,148,,148,,148,148,,,,148,,,,,,,,,148',
-',148,,,,148,,,,,,,,,148,,,148,148,148,148,148,148,148,148,148,149,,',
-',149,,149,,149,149,,,,149,,,,,,,,,149,,149,,,,149,,,,,,,,,149,,,149',
-'149,149,149,149,149,149,149,149,151,,,,151,,151,,151,151,,,,151,,,,',
-',,,,151,,151,,,,151,,,,,,,,,151,,,151,151,151,151,151,151,151,151,151',
-'268,,,,268,,268,,268,268,,,,268,,,,,,,,,268,,268,,,,268,,,,,,,,268,268',
-',,268,268,268,268,268,268,268,268,268,267,,,,267,,267,,267,267,,,,267',
-',,,,,,,,267,,267,,,,267,,,,,,,,267,267,,,267,267,267,267,267,267,267',
-'267,267,262,,,,262,,262,,262,262,,,,262,,,,,,,,,262,,262,,,,262,,,,',
-',,,,262,,,262,262,262,262,262,262,262,262,262,42,,,,42,,42,,42,42,,',
-',42,,42,,,,,,,42,,42,,,,42,,,,,,,,42,42,,,42,42,42,42,42,42,42,42,42',
-'260,,,,260,,260,,260,260,,,,260,,,,,,,,,260,,260,,,,260,,,,,,,,,260',
-',,260,260,260,260,260,260,260,260,260,258,,,,258,,258,,258,258,,,,258',
-',,,,,,,,258,,258,,,,258,,,,,,,,258,258,,,258,258,258,258,258,258,258',
-'258,258,255,,,,255,,255,,255,255,,,,255,,,,,,,,,255,,255,,,,255,,,,',
-',,,255,255,,,255,255,255,255,255,255,255,255,255,254,,,,254,,254,,254',
-'254,,,,254,,,,,,,,,254,,254,,,,254,,,,,,,,254,254,,,254,254,254,254',
-'254,254,254,254,254,253,,,,253,,253,,253,253,,,,253,,,,,,,,,253,,253',
-',,,253,,,,,,,,253,253,,,253,253,253,253,253,253,253,253,253,66,,,,66',
-',66,,66,66,,,,66,,,,,,,,,66,,66,,,,66,,,,,,,,,66,,,66,66,66,66,66,66',
-'66,66,66,195,,,,195,,195,,195,195,,,,195,,,,,,,,,195,,195,,,,195,,,',
-',,,,,195,,,195,195,195,195,195,195,195,195,195,192,,,,192,,192,,192',
-'192,,,,192,,,,,,,,,192,,192,,,,192,,,,,,,,,192,,,192,192,192,192,192',
-'192,192,192,192,166,,,,166,,166,,166,166,,,,166,,,,,,,,,166,,166,,,',
-'166,,,,,,,,,166,,,166,166,166,166,166,166,166,166,166,165,,,,165,,165',
-',165,165,,,,165,,,,,,,,,165,,165,,,,165,,,,,,,,,165,,,165,165,165,165',
-'165,165,165,165,165,80,,,,80,,80,,80,80,,,,80,,,,,,,,,80,,80,,,,80,',
-',,,,,,,80,,,80,80,80,80,80,80,80,80,80,81,,,,81,,81,,81,81,,,,81,,,',
-',,,,,81,,81,,,,81,,,,,,,,,81,,,81,81,81,81,81,81,81,81,81,82,,,,82,',
-'82,,82,82,,,,82,,,,,,,,,82,,82,,,,82,,,,,,,,,82,,,82,82,82,82,82,82',
-'82,82,82,83,,,,83,,83,,83,83,,,,83,,,,,,,,,83,,83,,,,83,,,,,,,,,83,',
-',83,83,83,83,83,83,83,83,83,164,,,,164,,164,,164,164,,,,164,,,,,,,,',
-'164,,164,,,,164,,,,,,,,,164,,,164,164,164,164,164,164,164,164,164,163',
-',,,163,,163,,163,163,,,,163,,,,,,,,,163,,163,,,,163,,,,,,,,,163,,,163',
-'163,163,163,163,163,163,163,163,162,,,,162,,162,,162,162,,,,162,,,,',
-',,,,162,,162,,,,162,,,,,,,,,162,,,162,162,162,162,162,162,162,162,162',
-'96,,,,96,,96,,96,96,,,,96,,,,,,,,,96,,96,,,,96,,,,,,,,96,96,96,,96,96',
-'96,96,96,96,96,96,96,161,,,,161,,161,,161,161,,,,161,,,,,,,,,161,,161',
-',,,161,,,,,,,,,161,,,161,161,161,161,161,161,161,161,161,160,,,,160',
-',160,,160,160,,,,160,,,,,,,,,160,,160,,,,160,,,,,,,,,160,,,160,160,160',
-'160,160,160,160,160,160,159,,,,159,,159,,159,159,,,,159,,,,,,,,,159',
-',159,,,,159,,,,,,,,,159,,,159,159,159,159,159,159,159,159,159,158,,',
-',158,,158,,158,158,,,,158,,,,,,,,,158,,158,,,,158,,,,,,,,,158,,,158',
-'158,158,158,158,158,158,158,158,112,,,,112,,112,,112,112,,,,112,,,,',
-',,,,112,,112,,,,112,,,,,,,,,112,,,112,112,112,112,112,112,112,112,112',
-'79,79,79,79,79,79,79,79,79,49,49,49,49,49,49,49,49,49,242,242,242,242',
-'242,242,242,242,242,242,242,,,,242,,,,79,79,,,,79,,,,49,49,,,,49,76',
-'76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,,',
-',76,,,,,,,,76,135,135,135,135,135,135,135,135,135,135,135,135,135,135',
-'135,135,135,135,135,135,135,135,135,,,,135,,,,,,,,135,285,285,285,285',
-'285,285,285,285,285,285,285,285,285,285,285,285,285,285,285,285,285',
-'285,285,,,,285,,,,,,,,285,264,264,264,264,264,264,264,264,264,264,264',
-'264,264,264,264,264,264,264,264,264,264,264,264,,,,264,,,,,,,,264,261',
-'261,261,261,261,261,261,261,261,261,261,261,261,261,261,261,261,261',
-'261,261,261,261,261,,,,261,,,,,,,261,196,196,196,196,196,196,196,196',
-'196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,,,,196,',
-',,,,,196,287,287,287,287,287,287,287,287,287,287,287,287,287,287,287',
-'287,287,287,287,287,287,287,287,,,,287,,,,,,,287,194,194,194,194,194',
-'194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194',
-'194,,,,194,,,,,,,194,168,168,168,168,168,168,168,168,168,168,168,168',
-'168,168,168,168,168,168,168,168,168,168,168,,,,168,0,0,0,0,0,,168,0',
-'0,0,0,0,0,0,0,0,0,,0,0,0,0,,0,,0,300,300,300,,,,0,300,300,300,300,300',
-'300,300,300,300,300,,300,300,300,300,,300,,300,299,299,299,,,,300,299',
-'299,299,299,299,299,299,299,299,299,,299,299,299,299,,299,,299,286,286',
-'286,,,,299,286,286,286,286,286,286,286,286,286,286,,286,286,286,286',
-',286,,286,265,265,265,,,,286,265,265,265,265,265,265,265,265,265,265',
-',265,265,265,265,,265,,265,263,263,263,,,,265,263,263,263,263,263,263',
-'263,263,263,263,,263,263,263,263,,263,,263,43,43,43,,,,263,43,43,43',
-'43,43,43,43,43,43,43,43,43,43,43,43,,43,,43,47,47,47,,,,43,47,47,47',
-'47,47,47,47,47,47,47,,47,47,47,47,,47,,47,108,108,108,,,,47,108,108',
-'108,108,108,108,108,108,108,108,,108,108,108,108,,108,,108,3,3,3,3,3',
-',108,3,3,3,3,3,3,3,3,3,3,,3,3,3,3,,3,,3,306,306,306,,,,3,306,306,306',
-'306,306,306,306,306,306,306,,306,306,306,306,,306,,306,,,,,,,306,201',
-'201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201',
-'201,201,201,201,201,,,,201,180,180,180,180,180,180,180,180,180,180,180',
-'180,180,180,180,180,180,180,180,180,180,180,180,,,,180,197,197,197,197',
-'197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197',
-'197,197,,,,197,199,199,199,199,199,199,199,199,199,199,199,199,199,199',
-'199,199,199,199,199,199,199,199,199,,,,199,200,200,200,200,200,200,200',
-'200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,,,,200',
-'202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202',
-'202,202,202,202,202,202,,,,202,203,203,203,203,203,203,203,203,203,203',
-'203,203,203,203,203,203,203,203,203,203,203,203,203,,,,203,204,204,204',
-'204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204',
-'204,204,204,,,,204,205,205,205,205,205,205,205,205,205,205,205,205,205',
-'205,205,205,205,205,205,205,205,205,205,,,,205,206,206,206,206,206,206',
-'206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206',
-',,,206,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209',
-'209,209,209,209,209,209,209,,,,209,222,222,222,222,222,222,222,222,222',
-'222,222,222,222,222,222,222,222,222,222,222,222,222,222,,,,222,277,277',
-'277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277',
-'277,277,277,277,,,,277,279,279,279,279,279,279,279,279,279,279,279,279',
-'279,279,279,279,279,279,279,279,279,279,279,,,,279,281,281,281,281,281',
-'281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281',
-'281,,,,281,291,291,291,291,291,291,291,291,291,291,291,291,291,291,291',
-'291,291,291,291,291,291,291,291,,,,291,228,228,228,228,228,228,228,228',
-'228,228,228,228,228,228,228,228,228,228,228,228,228,228,,,,228,227,227',
-'227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227',
-'227,227,,,,227,245,245,245,245,245,245,245,245,245,245,245,,,,245,243',
-'243,243,243,243,243,243,243,243,243,243,,,,243,244,244,244,244,244,244',
-'244,244,244,244,244,,,,244,241,241,241,241,241,241,241,241,241,241,241',
-',,,241,246,246,246,246,246,246,246,246,246,246,246,,,,246,247,247,247',
-'247,247,247,247,247,247,247,247,,,,247,248,248,248,248,248,248,248,248',
-'248,248,248,,,,248,249,249,249,249,249,249,249,249,249,249,249,,,,249',
-'250,250,250,250,250,250,250,250,250,250,250,,,,250,237,237,237,237,237',
-'237,237,237,237,237,,,,237,236,236,236,236,236,236,236,236,236,,,,236' ]
- racc_action_check = arr = ::Array.new(4010, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_action_pointer = [
- 3034, 197, nil, 3268, 109, nil, nil, nil, nil, nil,
- 179, 74, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 150, 144, -6, 13, -2, nil, 123, -12, 199,
- 197, 84, 1512, 3190, 196, -18, 195, 3216, 194, 2725,
- 35, -8, 15, nil, nil, nil, 205, nil, nil, nil,
- nil, nil, 144, nil, nil, nil, 1806, nil, nil, 135,
- 175, 108, nil, -28, -39, 78, 2758, 66, nil, 2716,
- 2051, 2100, 2149, 2198, nil, nil, nil, nil, nil, nil,
- 39, nil, nil, nil, -17, 178, 2394, nil, nil, nil,
- nil, nil, nil, nil, nil, 59, 51, nil, 3242, 101,
- 59, 130, 2639, 33, 91, 140, 189, 238, 287, 336,
- 385, 434, 483, 532, 581, nil, nil, nil, nil, nil,
- 630, 132, 19, nil, 31, 2793, nil, 777, -28, 48,
- 15, nil, nil, 973, 1022, 1071, 1120, 1169, 1218, 1267,
- -7, 1316, 924, 875, 826, 728, 679, 42, 2590, 2541,
- 2492, 2443, 2345, 2296, 2247, 2002, 1953, nil, 3034, 87,
- 91, 94, 373, nil, 69, 71, 73, 73, 86, nil,
- 3381, nil, 90, 88, nil, nil, nil, 115, nil, nil,
- nil, nil, 1904, 114, 3000, 1855, 2932, 3408, nil, 3435,
- 3462, 3354, 3489, 3516, 3543, 3570, 3597, 157, nil, 3624,
- 10, nil, 139, -11, nil, nil, 164, 155, 133, nil,
- 155, nil, 3651, nil, nil, 177, 179, 3810, 3785, 115,
- 66, 189, 192, 194, 197, 305, 3972, 3959, 318, 352,
- 367, 3870, 2713, 3840, 3855, 3825, 3885, 3900, 3915, 3930,
- 3945, nil, 166, 1757, 1708, 1659, 227, nil, 1610, nil,
- 1561, 2898, 1463, 3164, 2863, 3138, nil, 1414, 1365, nil,
- 0, nil, nil, 3, nil, nil, 358, 3678, nil, 3705,
- nil, 3732, nil, nil, nil, 2828, 3112, 2966, 136, nil,
- nil, 3759, nil, nil, nil, nil, 130, 52, nil, 3086,
- 3060, 407, 142, nil, nil, nil, 3294, nil ]
-
-racc_action_default = [
- -2, -172, -1, -4, -172, -6, -8, -9, -10, -11,
- -172, -172, -15, -16, -17, -18, -19, -20, -22, -23,
- -24, -25, -26, -27, -28, -29, -30, -31, -32, -33,
- -34, -172, -172, -172, -172, -172, -40, -172, -172, -172,
- -172, -172, -172, -172, -172, -172, -172, -172, -172, -172,
- -172, -172, -128, -160, -161, -162, -172, -3, -5, -7,
- -21, -12, -172, -35, -36, -37, -172, -38, -39, -172,
- -157, -159, -42, -172, -172, -172, -172, -172, -49, -108,
- -172, -172, -172, -172, -93, -94, -105, -106, -107, -109,
- -110, -111, -112, -113, -172, -172, -172, -163, -164, -165,
- -166, -167, -169, -170, -171, -172, -172, -51, -154, -138,
- -172, -172, -172, -172, -172, -172, -172, -172, -172, -172,
- -172, -172, -172, -172, -172, -72, -74, -71, -73, -127,
- -172, -172, -142, 308, -172, -172, -41, -172, -172, -172,
- -172, -45, -47, -172, -172, -172, -172, -172, -172, -172,
- -172, -172, -172, -172, -172, -172, -172, -172, -172, -172,
- -172, -172, -172, -172, -172, -172, -172, -48, -172, -77,
- -81, -82, -172, -129, -172, -172, -172, -126, -172, -133,
- -143, -144, -146, -172, -148, -50, -153, -172, -134, -135,
- -136, -137, -172, -172, -172, -172, -172, -59, -60, -61,
- -62, -63, -64, -65, -66, -67, -68, -172, -70, -116,
- -128, -117, -131, -172, -140, -141, -172, -172, -172, -150,
- -152, -46, -155, -156, -158, -172, -172, -76, -78, -79,
- -80, -83, -84, -85, -86, -87, -88, -89, -90, -91,
- -92, -95, -96, -97, -98, -99, -100, -101, -102, -103,
- -104, -75, -172, -172, -172, -172, -125, -132, -172, -147,
- -172, -172, -172, -172, -172, -172, -69, -172, -172, -139,
- -172, -14, -149, -172, -43, -44, -172, -118, -121, -119,
- -122, -120, -123, -124, -145, -172, -172, -172, -55, -57,
- -58, -114, -115, -130, -13, -151, -172, -138, -53, -172,
- -172, -172, -172, -54, -56, -168, -172, -52 ]
-
-racc_goto_table = [
- 31, 175, 62, 31, 187, 38, 77, 183, 38, 178,
- 49, 139, 140, 49, 207, 35, 216, 106, 35, 69,
- 60, 2, 271, 75, 57, 1, 58, 33, 70, 215,
- 33, 108, 70, 174, 59, 113, 110, nil, nil, nil,
- 61, nil, nil, 31, nil, nil, nil, 31, 38, nil,
- nil, nil, 38, 49, nil, nil, nil, 49, 35, nil,
- 127, 128, 35, nil, nil, nil, nil, nil, nil, nil,
- 33, nil, nil, nil, 33, 294, nil, nil, 252, 198,
- nil, nil, 186, nil, nil, 173, 176, nil, 211, nil,
- nil, nil, nil, nil, nil, nil, 108, nil, nil, nil,
- nil, 223, 193, nil, nil, nil, nil, nil, 31, 188,
- nil, nil, nil, 38, 191, 210, nil, nil, 49, 49,
- 224, 60, 214, 35, 190, 219, nil, nil, nil, 70,
- nil, nil, nil, nil, nil, 33, 189, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 295, nil, nil, 293, nil,
- nil, nil, 175, nil, nil, nil, nil, nil, nil, 284,
- 283, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 296, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 302, nil, 174, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 305, nil, 272,
- nil, nil, nil, nil, nil, nil, nil, 278, 280, 282,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 292, 211, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 176, nil, nil,
- nil, 288, nil, 290, nil, nil, nil, nil, nil, 210,
- nil, nil, nil, 31, 219, 31, nil, nil, 38, nil,
- 38, nil, nil, 49, 298, 49, nil, nil, 35, 76,
- 35, nil, nil, nil, nil, nil, 31, 303, 304, nil,
- 33, 38, 33, nil, 307, nil, 49, 188, nil, 31,
- 31, 35, 191, 135, 38, 38, 31, 49, nil, 49,
- 49, 38, 190, 33, 35, 35, 49, 168, 169, 170,
- 171, 35, nil, nil, 189, nil, 33, 33, nil, nil,
- nil, nil, nil, 33, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 194,
- nil, 196, 197, 199, 200, 201, 202, 203, 204, 205,
- 206, 209, nil, nil, nil, nil, nil, 213, nil, nil,
- nil, nil, nil, nil, 222, nil, nil, nil, nil, nil,
- 227, 228, 229, 230, 231, 232, 233, 234, 235, 236,
- 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
- 247, 248, 249, 250, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 261,
- nil, nil, 264, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 277, 279, 281, nil, nil, nil, nil, 285, nil, 287,
- nil, nil, nil, nil, 291, 209 ]
-
-racc_goto_check = [
- 30, 43, 9, 30, 39, 34, 37, 53, 34, 49,
- 40, 35, 35, 40, 41, 32, 10, 38, 32, 33,
- 18, 2, 11, 33, 2, 1, 4, 31, 9, 50,
- 31, 6, 9, 35, 5, 6, 9, nil, nil, nil,
- 5, nil, nil, 30, nil, nil, nil, 30, 34, nil,
- nil, nil, 34, 40, nil, nil, nil, 40, 32, nil,
- 40, 40, 32, nil, nil, nil, nil, nil, nil, nil,
- 31, nil, nil, nil, 31, 11, nil, nil, 43, 37,
- nil, nil, 38, nil, nil, 9, 9, nil, 37, nil,
- nil, nil, nil, nil, nil, nil, 6, nil, nil, nil,
- nil, 37, 9, nil, nil, nil, nil, nil, 30, 30,
- nil, nil, nil, 34, 34, 9, nil, nil, 40, 40,
- 33, 18, 9, 32, 32, 9, nil, nil, nil, 9,
- nil, nil, nil, nil, nil, 31, 31, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 10, nil, nil, 41, nil,
- nil, nil, 43, nil, nil, nil, nil, nil, nil, 53,
- 49, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 43, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 39, nil, 35, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 43, nil, 9,
- nil, nil, nil, nil, nil, nil, nil, 37, 37, 37,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 37, 37, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 9, nil, nil,
- nil, 6, nil, 6, nil, nil, nil, nil, nil, 9,
- nil, nil, nil, 30, 9, 30, nil, nil, 34, nil,
- 34, nil, nil, 40, 6, 40, nil, nil, 32, 36,
- 32, nil, nil, nil, nil, nil, 30, 6, 6, nil,
- 31, 34, 31, nil, 6, nil, 40, 30, nil, 30,
- 30, 32, 34, 36, 34, 34, 30, 40, nil, 40,
- 40, 34, 32, 31, 32, 32, 40, 36, 36, 36,
- 36, 32, nil, nil, 31, nil, 31, 31, nil, nil,
- nil, nil, nil, 31, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 36,
- nil, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, 36, nil, nil, nil, nil, nil, 36, nil, nil,
- nil, nil, nil, nil, 36, nil, nil, nil, nil, nil,
- 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, 36, 36, 36, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 36,
- nil, nil, 36, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 36, 36, 36, nil, nil, nil, nil, 36, nil, 36,
- nil, nil, nil, nil, 36, 36 ]
-
-racc_goto_pointer = [
- nil, 25, 21, nil, 22, 30, -12, nil, nil, -9,
- -118, -195, nil, nil, nil, nil, nil, nil, 16, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 0, 27, 15, -18, 5, -62, 237, -36, -26, -105,
- 10, -110, nil, -94, nil, nil, nil, nil, nil, -86,
- -103, nil, nil, -89, nil, nil ]
-
-racc_goto_default = [
- nil, nil, nil, 3, 5, 6, 7, 8, 9, 52,
- nil, 25, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 26, 27, 28, 29, 30,
- 86, 88, 85, nil, 84, 87, 180, 181, nil, nil,
- 79, nil, 89, 90, 91, 92, 93, 212, 177, nil,
- 129, 132, 182, nil, 220, 71 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 80, :_reduce_1,
- 0, 80, :_reduce_2,
- 2, 81, :_reduce_3,
- 1, 81, :_reduce_4,
- 2, 82, :_reduce_5,
- 1, 82, :_reduce_6,
- 2, 82, :_reduce_7,
- 1, 82, :_reduce_8,
- 1, 82, :_reduce_9,
- 1, 85, :_reduce_10,
- 1, 85, :_reduce_11,
- 2, 83, :_reduce_12,
- 6, 84, :_reduce_13,
- 5, 84, :_reduce_14,
- 1, 86, :_reduce_15,
- 1, 86, :_reduce_16,
- 1, 86, :_reduce_17,
- 1, 86, :_reduce_18,
- 1, 86, :_reduce_19,
- 1, 86, :_reduce_20,
- 2, 86, :_reduce_21,
- 1, 86, :_reduce_22,
- 1, 86, :_reduce_23,
- 1, 86, :_reduce_24,
- 1, 86, :_reduce_25,
- 1, 86, :_reduce_26,
- 1, 86, :_reduce_27,
- 1, 86, :_reduce_28,
- 1, 87, :_reduce_29,
- 1, 87, :_reduce_30,
- 1, 87, :_reduce_31,
- 1, 87, :_reduce_32,
- 1, 87, :_reduce_33,
- 1, 87, :_reduce_34,
- 2, 91, :_reduce_35,
- 2, 92, :_reduce_36,
- 2, 93, :_reduce_37,
- 2, 94, :_reduce_38,
- 2, 95, :_reduce_39,
- 1, 96, :_reduce_40,
- 3, 97, :_reduce_41,
- 2, 100, :_reduce_42,
- 5, 98, :_reduce_43,
- 5, 99, :_reduce_44,
- 3, 101, :_reduce_45,
- 4, 102, :_reduce_46,
- 3, 103, :_reduce_47,
- 3, 103, :_reduce_48,
- 2, 103, :_reduce_49,
- 3, 90, :_reduce_50,
- 2, 90, :_reduce_51,
- 9, 104, :_reduce_52,
- 6, 105, :_reduce_53,
- 7, 105, :_reduce_54,
- 5, 106, :_reduce_55,
- 7, 106, :_reduce_56,
- 5, 107, :_reduce_57,
- 5, 108, :_reduce_58,
- 3, 109, :_reduce_59,
- 3, 109, :_reduce_60,
- 3, 109, :_reduce_61,
- 3, 109, :_reduce_62,
- 3, 109, :_reduce_63,
- 3, 109, :_reduce_64,
- 3, 109, :_reduce_65,
- 3, 109, :_reduce_66,
- 3, 109, :_reduce_67,
- 3, 109, :_reduce_68,
- 4, 110, :_reduce_69,
- 3, 110, :_reduce_70,
- 2, 111, :_reduce_71,
- 2, 111, :_reduce_72,
- 2, 113, :_reduce_73,
- 2, 113, :_reduce_74,
- 3, 115, :_reduce_75,
- 3, 115, :_reduce_76,
- 2, 115, :_reduce_77,
- 3, 115, :_reduce_78,
- 3, 115, :_reduce_79,
- 3, 115, :_reduce_80,
- 2, 115, :_reduce_81,
- 2, 115, :_reduce_82,
- 3, 115, :_reduce_83,
- 3, 115, :_reduce_84,
- 3, 115, :_reduce_85,
- 3, 115, :_reduce_86,
- 3, 115, :_reduce_87,
- 3, 115, :_reduce_88,
- 3, 115, :_reduce_89,
- 3, 115, :_reduce_90,
- 3, 115, :_reduce_91,
- 3, 115, :_reduce_92,
- 1, 115, :_reduce_93,
- 1, 115, :_reduce_94,
- 3, 115, :_reduce_95,
- 3, 115, :_reduce_96,
- 3, 115, :_reduce_97,
- 3, 115, :_reduce_98,
- 3, 115, :_reduce_99,
- 3, 115, :_reduce_100,
- 3, 115, :_reduce_101,
- 3, 115, :_reduce_102,
- 3, 115, :_reduce_103,
- 3, 115, :_reduce_104,
- 1, 115, :_reduce_105,
- 1, 115, :_reduce_106,
- 1, 115, :_reduce_107,
- 1, 115, :_reduce_108,
- 1, 115, :_reduce_109,
- 1, 115, :_reduce_110,
- 1, 115, :_reduce_111,
- 1, 115, :_reduce_112,
- 1, 115, :_reduce_113,
- 3, 126, :_reduce_114,
- 3, 126, :_reduce_115,
- 1, 126, :_reduce_116,
- 1, 126, :_reduce_117,
- 3, 127, :_reduce_118,
- 3, 127, :_reduce_119,
- 3, 127, :_reduce_120,
- 3, 127, :_reduce_121,
- 3, 127, :_reduce_122,
- 3, 127, :_reduce_123,
- 3, 128, :_reduce_124,
- 2, 128, :_reduce_125,
- 1, 128, :_reduce_126,
- 2, 119, :_reduce_127,
- 1, 119, :_reduce_128,
- 2, 116, :_reduce_129,
- 3, 120, :_reduce_130,
- 1, 120, :_reduce_131,
- 3, 125, :_reduce_132,
- 2, 125, :_reduce_133,
- 1, 118, :_reduce_134,
- 1, 118, :_reduce_135,
- 1, 118, :_reduce_136,
- 1, 118, :_reduce_137,
- 0, 118, :_reduce_138,
- 3, 130, :_reduce_139,
- 2, 130, :_reduce_140,
- 2, 129, :_reduce_141,
- 1, 129, :_reduce_142,
- 1, 131, :_reduce_143,
- 1, 131, :_reduce_144,
- 3, 132, :_reduce_145,
- 1, 132, :_reduce_146,
- 3, 124, :_reduce_147,
- 2, 124, :_reduce_148,
- 2, 133, :_reduce_149,
- 1, 133, :_reduce_150,
- 3, 89, :_reduce_151,
- 1, 89, :_reduce_152,
- 2, 117, :_reduce_153,
- 1, 117, :_reduce_154,
- 3, 134, :_reduce_155,
- 3, 134, :_reduce_156,
- 1, 134, :_reduce_157,
- 3, 112, :_reduce_158,
- 1, 112, :_reduce_159,
- 1, 88, :_reduce_160,
- 1, 88, :_reduce_161,
- 1, 88, :_reduce_162,
- 1, 122, :_reduce_163,
- 1, 122, :_reduce_164,
- 1, 122, :_reduce_165,
- 1, 122, :_reduce_166,
- 1, 122, :_reduce_167,
- 7, 121, :_reduce_168,
- 1, 114, :_reduce_169,
- 1, 114, :_reduce_170,
- 1, 123, :_reduce_171 ]
-
-racc_reduce_n = 172
-
-racc_shift_n = 308
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :ASS_EQ => 2,
- :ADD_EQ => 3,
- :SUB_EQ => 4,
- :MUL_EQ => 5,
- :DIV_EQ => 6,
- :MOD_EQ => 7,
- :SLL_EQ => 8,
- :SRA_EQ => 9,
- :SRL_EQ => 10,
- :OR => 11,
- :AND => 12,
- :CMP_LT => 13,
- :CMP_GT => 14,
- :CMP_EQ => 15,
- :CMP_NE => 16,
- :CMP_GE => 17,
- :CMP_LE => 18,
- :SUBSTR_EQ => 19,
- :SUBSTR_NE => 20,
- :REGEX_EQ => 21,
- :REGEX_NE => 22,
- :BIT_OR => 23,
- :BIT_XOR => 24,
- :AMPERSAND => 25,
- :BIT_SRA => 26,
- :BIT_SRL => 27,
- :BIT_SLL => 28,
- :ADD => 29,
- :SUB => 30,
- :MUL => 31,
- :DIV => 32,
- :MOD => 33,
- :NOT => 34,
- :UMINUS => 35,
- :BIT_NOT => 36,
- :EXP => 37,
- :INCR => 38,
- :DECR => 39,
- :COMMENT => 40,
- :EXPORT => 41,
- :FUNCTION => 42,
- :LPAREN => 43,
- :RPAREN => 44,
- :SEMICOLON => 45,
- :BREAK => 46,
- :CONTINUE => 47,
- :GLOBAL => 48,
- :IMPORT => 49,
- :INCLUDE => 50,
- :LOCAL => 51,
- :REP => 52,
- :RETURN => 53,
- :LBRACE => 54,
- :RBRACE => 55,
- :FOR => 56,
- :FOREACH => 57,
- :IN => 58,
- :IF => 59,
- :ELSE => 60,
- :REPEAT => 61,
- :UNTIL => 62,
- :WHILE => 63,
- :COLON => 64,
- :COMMA => 65,
- :AT_SIGN => 66,
- :LBRACK => 67,
- :RBRACK => 68,
- :PERIOD => 69,
- :IDENT => 70,
- :INT_DEC => 71,
- :INT_HEX => 72,
- :INT_OCT => 73,
- :FALSE => 74,
- :TRUE => 75,
- :DATA => 76,
- :STRING => 77,
- :UNDEF => 78 }
-
-racc_nt_base = 79
-
-racc_use_result_var = false
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "ASS_EQ",
- "ADD_EQ",
- "SUB_EQ",
- "MUL_EQ",
- "DIV_EQ",
- "MOD_EQ",
- "SLL_EQ",
- "SRA_EQ",
- "SRL_EQ",
- "OR",
- "AND",
- "CMP_LT",
- "CMP_GT",
- "CMP_EQ",
- "CMP_NE",
- "CMP_GE",
- "CMP_LE",
- "SUBSTR_EQ",
- "SUBSTR_NE",
- "REGEX_EQ",
- "REGEX_NE",
- "BIT_OR",
- "BIT_XOR",
- "AMPERSAND",
- "BIT_SRA",
- "BIT_SRL",
- "BIT_SLL",
- "ADD",
- "SUB",
- "MUL",
- "DIV",
- "MOD",
- "NOT",
- "UMINUS",
- "BIT_NOT",
- "EXP",
- "INCR",
- "DECR",
- "COMMENT",
- "EXPORT",
- "FUNCTION",
- "LPAREN",
- "RPAREN",
- "SEMICOLON",
- "BREAK",
- "CONTINUE",
- "GLOBAL",
- "IMPORT",
- "INCLUDE",
- "LOCAL",
- "REP",
- "RETURN",
- "LBRACE",
- "RBRACE",
- "FOR",
- "FOREACH",
- "IN",
- "IF",
- "ELSE",
- "REPEAT",
- "UNTIL",
- "WHILE",
- "COLON",
- "COMMA",
- "AT_SIGN",
- "LBRACK",
- "RBRACK",
- "PERIOD",
- "IDENT",
- "INT_DEC",
- "INT_HEX",
- "INT_OCT",
- "FALSE",
- "TRUE",
- "DATA",
- "STRING",
- "UNDEF",
- "$start",
- "start",
- "roots",
- "root",
- "export",
- "function",
- "statement",
- "simple",
- "compound",
- "ident",
- "params",
- "block",
- "assign",
- "break",
- "call",
- "continue",
- "decr",
- "empty",
- "global",
- "import",
- "include",
- "incr",
- "local",
- "rep",
- "return",
- "for",
- "foreach",
- "if",
- "repeat",
- "while",
- "assign_exp",
- "call_exp",
- "decr_exp",
- "var_decls",
- "incr_exp",
- "string",
- "expr",
- "ref",
- "statements",
- "field",
- "lval",
- "args",
- "ip",
- "int",
- "undef",
- "list_expr",
- "array_expr",
- "arg",
- "kv_pair",
- "kv_pairs",
- "indexes",
- "index",
- "list_elem",
- "list_elems",
- "param",
- "var_decl" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'nasl.y', 61)
- def _reduce_1(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 63)
- def _reduce_2(val, _values)
- []
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 67)
- def _reduce_3(val, _values)
- [val[0]] + val[1]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 69)
- def _reduce_4(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 73)
- def _reduce_5(val, _values)
- c(*val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 75)
- def _reduce_6(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 77)
- def _reduce_7(val, _values)
- c(*val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 79)
- def _reduce_8(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 81)
- def _reduce_9(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 85)
- def _reduce_10(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 87)
- def _reduce_11(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 95)
- def _reduce_12(val, _values)
- n(:Export, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 99)
- def _reduce_13(val, _values)
- n(:Function, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 101)
- def _reduce_14(val, _values)
- n(:Function, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 105)
- def _reduce_15(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 107)
- def _reduce_16(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 109)
- def _reduce_17(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 111)
- def _reduce_18(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 113)
- def _reduce_19(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 115)
- def _reduce_20(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 117)
- def _reduce_21(val, _values)
- c(*val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 119)
- def _reduce_22(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 121)
- def _reduce_23(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 123)
- def _reduce_24(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 125)
- def _reduce_25(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 127)
- def _reduce_26(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 129)
- def _reduce_27(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 131)
- def _reduce_28(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 135)
- def _reduce_29(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 137)
- def _reduce_30(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 139)
- def _reduce_31(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 141)
- def _reduce_32(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 143)
- def _reduce_33(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 145)
- def _reduce_34(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 153)
- def _reduce_35(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 157)
- def _reduce_36(val, _values)
- n(:Break, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 161)
- def _reduce_37(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 165)
- def _reduce_38(val, _values)
- n(:Continue, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 169)
- def _reduce_39(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 173)
- def _reduce_40(val, _values)
- n(:Empty, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 177)
- def _reduce_41(val, _values)
- n(:Global, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 181)
- def _reduce_42(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 185)
- def _reduce_43(val, _values)
- n(:Import, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 189)
- def _reduce_44(val, _values)
- n(:Include, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 193)
- def _reduce_45(val, _values)
- n(:Local, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 197)
- def _reduce_46(val, _values)
- n(:Repetition, *val[0..-1])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 201)
- def _reduce_47(val, _values)
- n(:Return, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 203)
- def _reduce_48(val, _values)
- n(:Return, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 205)
- def _reduce_49(val, _values)
- n(:Return, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 213)
- def _reduce_50(val, _values)
- n(:Block, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 215)
- def _reduce_51(val, _values)
- n(:Block, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 219)
- def _reduce_52(val, _values)
- n(:For, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 223)
- def _reduce_53(val, _values)
- n(:Foreach, val[0], val[1], val[3], val[5])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 225)
- def _reduce_54(val, _values)
- n(:Foreach, val[0], val[2], val[4], val[6])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 229)
- def _reduce_55(val, _values)
- n(:If, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 231)
- def _reduce_56(val, _values)
- n(:If, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 235)
- def _reduce_57(val, _values)
- n(:Repeat, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 239)
- def _reduce_58(val, _values)
- n(:While, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 247)
- def _reduce_59(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 249)
- def _reduce_60(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 251)
- def _reduce_61(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 253)
- def _reduce_62(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 255)
- def _reduce_63(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 257)
- def _reduce_64(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 259)
- def _reduce_65(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 261)
- def _reduce_66(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 263)
- def _reduce_67(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 265)
- def _reduce_68(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 269)
- def _reduce_69(val, _values)
- n(:Call, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 271)
- def _reduce_70(val, _values)
- n(:Call, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 275)
- def _reduce_71(val, _values)
- n(:Decrement, val[0])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 277)
- def _reduce_72(val, _values)
- n(:Decrement, val[0])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 281)
- def _reduce_73(val, _values)
- n(:Increment, val[0])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 283)
- def _reduce_74(val, _values)
- n(:Increment, val[0])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 287)
- def _reduce_75(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 289)
- def _reduce_76(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 291)
- def _reduce_77(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 293)
- def _reduce_78(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 295)
- def _reduce_79(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 297)
- def _reduce_80(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 299)
- def _reduce_81(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 301)
- def _reduce_82(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 303)
- def _reduce_83(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 305)
- def _reduce_84(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 307)
- def _reduce_85(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 309)
- def _reduce_86(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 311)
- def _reduce_87(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 313)
- def _reduce_88(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 315)
- def _reduce_89(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 317)
- def _reduce_90(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 319)
- def _reduce_91(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 321)
- def _reduce_92(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 323)
- def _reduce_93(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 325)
- def _reduce_94(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 327)
- def _reduce_95(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 329)
- def _reduce_96(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 331)
- def _reduce_97(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 333)
- def _reduce_98(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 335)
- def _reduce_99(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 337)
- def _reduce_100(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 339)
- def _reduce_101(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 341)
- def _reduce_102(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 343)
- def _reduce_103(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 345)
- def _reduce_104(val, _values)
- n(:Expression, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 347)
- def _reduce_105(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 349)
- def _reduce_106(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 351)
- def _reduce_107(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 353)
- def _reduce_108(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 355)
- def _reduce_109(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 357)
- def _reduce_110(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 359)
- def _reduce_111(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 361)
- def _reduce_112(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 363)
- def _reduce_113(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 371)
- def _reduce_114(val, _values)
- n(:Argument, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 373)
- def _reduce_115(val, _values)
- n(:Argument, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 375)
- def _reduce_116(val, _values)
- n(:Argument, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 377)
- def _reduce_117(val, _values)
- n(:Argument, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 381)
- def _reduce_118(val, _values)
- n(:KeyValuePair, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 383)
- def _reduce_119(val, _values)
- n(:KeyValuePair, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 385)
- def _reduce_120(val, _values)
- n(:KeyValuePair, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 387)
- def _reduce_121(val, _values)
- n(:KeyValuePair, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 389)
- def _reduce_122(val, _values)
- n(:KeyValuePair, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 391)
- def _reduce_123(val, _values)
- n(:KeyValuePair, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 395)
- def _reduce_124(val, _values)
- [val[0]] + val[2]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 397)
- def _reduce_125(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 399)
- def _reduce_126(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 403)
- def _reduce_127(val, _values)
- n(:Lvalue, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 405)
- def _reduce_128(val, _values)
- n(:Lvalue, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 409)
- def _reduce_129(val, _values)
- n(:Reference, val[1])
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 417)
- def _reduce_130(val, _values)
- [val[0]] + val[2]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 419)
- def _reduce_131(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 423)
- def _reduce_132(val, _values)
- n(:Array, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 425)
- def _reduce_133(val, _values)
- n(:Array, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 429)
- def _reduce_134(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 431)
- def _reduce_135(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 433)
- def _reduce_136(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 435)
- def _reduce_137(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 437)
- def _reduce_138(val, _values)
- nil
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 441)
- def _reduce_139(val, _values)
- val[1]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 443)
- def _reduce_140(val, _values)
- val[1]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 447)
- def _reduce_141(val, _values)
- [val[0]] + val[1]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 449)
- def _reduce_142(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 453)
- def _reduce_143(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 455)
- def _reduce_144(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 459)
- def _reduce_145(val, _values)
- [val[0]] + val[2]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 461)
- def _reduce_146(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 465)
- def _reduce_147(val, _values)
- n(:List, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 467)
- def _reduce_148(val, _values)
- n(:List, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 471)
- def _reduce_149(val, _values)
- n(:Parameter, val[1], 'reference')
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 473)
- def _reduce_150(val, _values)
- n(:Parameter, val[0], 'value')
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 477)
- def _reduce_151(val, _values)
- [val[0]] + val[2]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 479)
- def _reduce_152(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 483)
- def _reduce_153(val, _values)
- [val[0]] + val[1]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 485)
- def _reduce_154(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 489)
- def _reduce_155(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 491)
- def _reduce_156(val, _values)
- n(:Assignment, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 493)
- def _reduce_157(val, _values)
- val[0]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 497)
- def _reduce_158(val, _values)
- [val[0]] + val[2]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 499)
- def _reduce_159(val, _values)
- [val[0]]
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 507)
- def _reduce_160(val, _values)
- n(:Identifier, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 509)
- def _reduce_161(val, _values)
- n(:Identifier, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 511)
- def _reduce_162(val, _values)
- n(:Identifier, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 515)
- def _reduce_163(val, _values)
- n(:Integer, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 517)
- def _reduce_164(val, _values)
- n(:Integer, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 519)
- def _reduce_165(val, _values)
- n(:Integer, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 521)
- def _reduce_166(val, _values)
- n(:Integer, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 523)
- def _reduce_167(val, _values)
- n(:Integer, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 527)
- def _reduce_168(val, _values)
- n(:Ip, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 530)
- def _reduce_169(val, _values)
- n(:String, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 532)
- def _reduce_170(val, _values)
- n(:String, *val)
- end
-.,.,
-
-module_eval(<<'.,.,', 'nasl.y', 536)
- def _reduce_171(val, _values)
- n(:Undefined, *val)
- end
-.,.,
-
-def _reduce_none(val, _values)
- val[0]
-end
-
- end # class Grammar
-end # module Nasl
-
-
diff --git a/test/racc/regress/nokogiri-css b/test/racc/regress/nokogiri-css
deleted file mode 100644
index 0aad3a394a..0000000000
--- a/test/racc/regress/nokogiri-css
+++ /dev/null
@@ -1,836 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-
-require 'nokogiri/css/parser_extras'
-module Nokogiri
- module CSS
- class Parser < Racc::Parser
-##### State transition tables begin ###
-
-racc_action_table = [
- 24, 93, 56, 57, 33, 55, 94, 23, 24, 22,
- 12, 93, 33, 27, 89, 52, 92, 22, -23, 25,
- 108, 98, 23, 33, 26, 18, 20, 25, 27, -23,
- 23, 24, 26, 18, 20, 33, 27, 11, 39, 24,
- 22, 23, 95, 33, 18, 101, 100, 27, 22, 12,
- 25, 91, 90, 23, 33, 26, 18, 20, 25, 27,
- 90, 23, 24, 26, 18, 20, 33, 27, 96, 39,
- -23, 22, 23, 74, 24, 18, 33, 99, 27, 56,
- 87, 25, 60, 46, 23, 49, 26, 18, 20, 102,
- 27, 39, 24, 51, 23, 103, 93, 18, 26, 33,
- 27, 66, 44, 56, 58, 105, 60, 33, 35, 33,
- 109, 51, 56, 87, 39, 60, 26, 23, 85, 33,
- 18, 20, 39, 27, 39, 23, 45, 23, 18, 33,
- 18, 27, 86, 27, 39, 88, 33, 23, nil, nil,
- 18, 22, nil, 27, 39, 56, 87, 23, 60, nil,
- 18, 39, nil, 27, 23, 82, 83, 18, 20, nil,
- 27, nil, nil, nil, 82, 83, 78, 79, 80, nil,
- 81, nil, nil, nil, 77, 78, 79, 80, nil, 81,
- 4, 5, 43, 77, 4, 5, 10, nil, 56, 87,
- 6, 60, 8, 7, 6, nil, 8, 7, 4, 5,
- 10, nil, nil, nil, nil, nil, nil, nil, 6, nil,
- 8, 7 ]
-
-racc_action_check = [
- 3, 58, 24, 24, 3, 24, 57, 15, 42, 3,
- 64, 57, 42, 15, 54, 24, 56, 42, 58, 3,
- 94, 64, 3, 31, 3, 3, 3, 42, 3, 22,
- 42, 9, 42, 42, 42, 9, 42, 1, 31, 43,
- 9, 31, 59, 43, 31, 76, 76, 31, 43, 1,
- 9, 55, 55, 9, 30, 9, 9, 9, 43, 9,
- 60, 43, 12, 43, 43, 43, 12, 43, 61, 30,
- 46, 12, 30, 45, 23, 30, 29, 75, 30, 93,
- 93, 12, 93, 23, 12, 23, 12, 12, 12, 84,
- 12, 29, 27, 23, 29, 86, 87, 29, 23, 25,
- 29, 27, 18, 25, 25, 91, 25, 28, 11, 62,
- 105, 27, 51, 51, 25, 51, 27, 25, 49, 14,
- 25, 25, 28, 25, 62, 28, 21, 62, 28, 32,
- 62, 28, 50, 62, 14, 53, 39, 14, nil, nil,
- 14, 39, nil, 14, 32, 90, 90, 32, 90, nil,
- 32, 39, nil, 32, 39, 47, 47, 39, 39, nil,
- 39, nil, nil, nil, 48, 48, 47, 47, 47, nil,
- 47, nil, nil, nil, 47, 48, 48, 48, nil, 48,
- 17, 17, 17, 48, 0, 0, 0, nil, 92, 92,
- 17, 92, 17, 17, 0, nil, 0, 0, 26, 26,
- 26, nil, nil, nil, nil, nil, nil, nil, 26, nil,
- 26, 26 ]
-
-racc_action_pointer = [
- 177, 37, nil, -2, nil, nil, nil, nil, nil, 29,
- nil, 108, 60, nil, 113, -17, nil, 173, 91, nil,
- nil, 97, 0, 72, -8, 93, 191, 90, 101, 70,
- 48, 17, 123, nil, nil, nil, nil, nil, nil, 130,
- nil, nil, 6, 37, nil, 62, 41, 152, 161, 93,
- 103, 102, nil, 112, -9, 40, 4, -1, -11, 19,
- 48, 45, 103, nil, -2, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 52, 35, nil, nil, nil,
- nil, nil, nil, nil, 64, nil, 84, 84, nil, nil,
- 135, 98, 178, 69, 7, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 97, nil, nil, nil, nil ]
-
-racc_action_default = [
- -74, -75, -2, -24, -4, -5, -6, -7, -8, -24,
- -73, -75, -24, -3, -47, -10, -13, -17, -75, -19,
- -20, -75, -22, -24, -75, -24, -74, -75, -53, -54,
- -55, -56, -57, -58, -14, 110, -1, -9, -46, -24,
- -11, -12, -24, -24, -18, -75, -29, -61, -61, -75,
- -75, -75, -30, -75, -75, -38, -39, -40, -22, -75,
- -38, -75, -70, -72, -75, -44, -45, -48, -49, -50,
- -51, -52, -15, -16, -21, -75, -75, -62, -63, -64,
- -65, -66, -67, -68, -75, -27, -75, -40, -31, -32,
- -75, -43, -75, -75, -75, -33, -69, -71, -34, -25,
- -59, -60, -26, -28, -35, -75, -36, -37, -42, -41 ]
-
-racc_goto_table = [
- 53, 38, 13, 1, 54, 48, 62, 42, 34, 65,
- 37, 36, 63, 75, 84, 67, 68, 69, 70, 71,
- 62, 40, 41, 50, 47, nil, 63, nil, nil, 64,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 72, 73, nil, nil, nil, nil, nil, nil, 97,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 104, nil, 106, 107 ]
-
-racc_goto_check = [
- 18, 12, 2, 1, 19, 9, 7, 5, 2, 9,
- 8, 2, 12, 17, 17, 12, 12, 12, 12, 12,
- 7, 10, 11, 15, 16, nil, 12, nil, nil, 1,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 2, 2, nil, nil, nil, nil, nil, nil, 12,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 18, nil, 18, 18 ]
-
-racc_goto_pointer = [
- nil, 3, -1, nil, nil, -10, nil, -19, -4, -18,
- 6, 7, -13, nil, nil, 0, 1, -34, -24, -20,
- nil, nil, nil, nil ]
-
-racc_goto_default = [
- nil, nil, nil, 2, 3, 9, 17, 14, nil, 15,
- 31, 30, 16, 29, 19, 21, nil, nil, 59, nil,
- 28, 32, 76, 61 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 3, 32, :_reduce_1,
- 1, 32, :_reduce_2,
- 2, 32, :_reduce_3,
- 1, 36, :_reduce_4,
- 1, 36, :_reduce_5,
- 1, 36, :_reduce_6,
- 1, 36, :_reduce_7,
- 1, 36, :_reduce_8,
- 2, 37, :_reduce_9,
- 1, 37, :_reduce_none,
- 2, 37, :_reduce_11,
- 2, 37, :_reduce_12,
- 1, 37, :_reduce_13,
- 2, 34, :_reduce_14,
- 3, 33, :_reduce_15,
- 3, 33, :_reduce_16,
- 1, 33, :_reduce_none,
- 2, 44, :_reduce_18,
- 1, 38, :_reduce_none,
- 1, 38, :_reduce_20,
- 3, 45, :_reduce_21,
- 1, 45, :_reduce_22,
- 1, 46, :_reduce_23,
- 0, 46, :_reduce_none,
- 4, 42, :_reduce_25,
- 4, 42, :_reduce_26,
- 3, 42, :_reduce_27,
- 3, 47, :_reduce_28,
- 1, 47, :_reduce_29,
- 2, 40, :_reduce_30,
- 3, 40, :_reduce_31,
- 3, 40, :_reduce_32,
- 3, 40, :_reduce_33,
- 3, 40, :_reduce_34,
- 3, 49, :_reduce_35,
- 3, 49, :_reduce_36,
- 3, 49, :_reduce_37,
- 1, 49, :_reduce_none,
- 1, 49, :_reduce_none,
- 1, 49, :_reduce_40,
- 4, 50, :_reduce_41,
- 3, 50, :_reduce_42,
- 2, 50, :_reduce_43,
- 2, 41, :_reduce_44,
- 2, 41, :_reduce_45,
- 1, 39, :_reduce_none,
- 0, 39, :_reduce_none,
- 2, 43, :_reduce_48,
- 2, 43, :_reduce_49,
- 2, 43, :_reduce_50,
- 2, 43, :_reduce_51,
- 2, 43, :_reduce_52,
- 1, 43, :_reduce_none,
- 1, 43, :_reduce_none,
- 1, 43, :_reduce_none,
- 1, 43, :_reduce_none,
- 1, 43, :_reduce_none,
- 1, 51, :_reduce_58,
- 2, 48, :_reduce_59,
- 2, 48, :_reduce_60,
- 0, 48, :_reduce_none,
- 1, 53, :_reduce_62,
- 1, 53, :_reduce_63,
- 1, 53, :_reduce_64,
- 1, 53, :_reduce_65,
- 1, 53, :_reduce_66,
- 1, 53, :_reduce_67,
- 1, 53, :_reduce_68,
- 3, 52, :_reduce_69,
- 1, 54, :_reduce_none,
- 2, 54, :_reduce_none,
- 1, 54, :_reduce_none,
- 1, 35, :_reduce_none,
- 0, 35, :_reduce_none ]
-
-racc_reduce_n = 75
-
-racc_shift_n = 110
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :FUNCTION => 2,
- :INCLUDES => 3,
- :DASHMATCH => 4,
- :LBRACE => 5,
- :HASH => 6,
- :PLUS => 7,
- :GREATER => 8,
- :S => 9,
- :STRING => 10,
- :IDENT => 11,
- :COMMA => 12,
- :NUMBER => 13,
- :PREFIXMATCH => 14,
- :SUFFIXMATCH => 15,
- :SUBSTRINGMATCH => 16,
- :TILDE => 17,
- :NOT_EQUAL => 18,
- :SLASH => 19,
- :DOUBLESLASH => 20,
- :NOT => 21,
- :EQUAL => 22,
- :RPAREN => 23,
- :LSQUARE => 24,
- :RSQUARE => 25,
- :HAS => 26,
- "." => 27,
- "*" => 28,
- "|" => 29,
- ":" => 30 }
-
-racc_nt_base = 31
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "FUNCTION",
- "INCLUDES",
- "DASHMATCH",
- "LBRACE",
- "HASH",
- "PLUS",
- "GREATER",
- "S",
- "STRING",
- "IDENT",
- "COMMA",
- "NUMBER",
- "PREFIXMATCH",
- "SUFFIXMATCH",
- "SUBSTRINGMATCH",
- "TILDE",
- "NOT_EQUAL",
- "SLASH",
- "DOUBLESLASH",
- "NOT",
- "EQUAL",
- "RPAREN",
- "LSQUARE",
- "RSQUARE",
- "HAS",
- "\".\"",
- "\"*\"",
- "\"|\"",
- "\":\"",
- "$start",
- "selector",
- "simple_selector_1toN",
- "prefixless_combinator_selector",
- "optional_S",
- "combinator",
- "simple_selector",
- "element_name",
- "hcap_0toN",
- "function",
- "pseudo",
- "attrib",
- "hcap_1toN",
- "class",
- "namespaced_ident",
- "namespace",
- "attrib_name",
- "attrib_val_0or1",
- "expr",
- "nth",
- "attribute_id",
- "negation",
- "eql_incl_dash",
- "negation_arg" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 9)
- def _reduce_1(val, _values, result)
- result = [val.first, val.last].flatten
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 11)
- def _reduce_2(val, _values, result)
- result = val.flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 12)
- def _reduce_3(val, _values, result)
- result = [val.last].flatten
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 15)
- def _reduce_4(val, _values, result)
- result = :DIRECT_ADJACENT_SELECTOR
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 16)
- def _reduce_5(val, _values, result)
- result = :CHILD_SELECTOR
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 17)
- def _reduce_6(val, _values, result)
- result = :FOLLOWING_SELECTOR
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 18)
- def _reduce_7(val, _values, result)
- result = :DESCENDANT_SELECTOR
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 19)
- def _reduce_8(val, _values, result)
- result = :CHILD_SELECTOR
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 23)
- def _reduce_9(val, _values, result)
- result = if val[1].nil?
- val.first
- else
- Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
- end
-
- result
- end
-.,.,
-
-# reduce 10 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 31)
- def _reduce_11(val, _values, result)
- result = Node.new(:CONDITIONAL_SELECTOR, val)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 34)
- def _reduce_12(val, _values, result)
- result = Node.new(:CONDITIONAL_SELECTOR, val)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 37)
- def _reduce_13(val, _values, result)
- result = Node.new(:CONDITIONAL_SELECTOR,
- [Node.new(:ELEMENT_NAME, ['*']), val.first]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 44)
- def _reduce_14(val, _values, result)
- result = Node.new(val.first, [nil, val.last])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 49)
- def _reduce_15(val, _values, result)
- result = Node.new(val[1], [val.first, val.last])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 52)
- def _reduce_16(val, _values, result)
- result = Node.new(:DESCENDANT_SELECTOR, [val.first, val.last])
-
- result
- end
-.,.,
-
-# reduce 17 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 57)
- def _reduce_18(val, _values, result)
- result = Node.new(:CLASS_CONDITION, [val[1]])
- result
- end
-.,.,
-
-# reduce 19 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 61)
- def _reduce_20(val, _values, result)
- result = Node.new(:ELEMENT_NAME, val)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 65)
- def _reduce_21(val, _values, result)
- result = Node.new(:ELEMENT_NAME,
- [[val.first, val.last].compact.join(':')]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 70)
- def _reduce_22(val, _values, result)
- name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
- result = Node.new(:ELEMENT_NAME, [name])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 75)
- def _reduce_23(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-# reduce 24 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 80)
- def _reduce_25(val, _values, result)
- result = Node.new(:ATTRIBUTE_CONDITION,
- [val[1]] + (val[2] || [])
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 85)
- def _reduce_26(val, _values, result)
- result = Node.new(:ATTRIBUTE_CONDITION,
- [val[1]] + (val[2] || [])
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 90)
- def _reduce_27(val, _values, result)
- # Non standard, but hpricot supports it.
- result = Node.new(:PSEUDO_CLASS,
- [Node.new(:FUNCTION, ['nth-child(', val[1]])]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 98)
- def _reduce_28(val, _values, result)
- result = Node.new(:ELEMENT_NAME,
- [[val.first, val.last].compact.join(':')]
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 103)
- def _reduce_29(val, _values, result)
- # Default namespace is not applied to attributes.
- # So we don't add prefix "xmlns:" as in namespaced_ident.
- result = Node.new(:ELEMENT_NAME, [val.first])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 110)
- def _reduce_30(val, _values, result)
- result = Node.new(:FUNCTION, [val.first.strip])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 113)
- def _reduce_31(val, _values, result)
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 116)
- def _reduce_32(val, _values, result)
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 119)
- def _reduce_33(val, _values, result)
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 122)
- def _reduce_34(val, _values, result)
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 126)
- def _reduce_35(val, _values, result)
- result = [val.first, val.last]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 127)
- def _reduce_36(val, _values, result)
- result = [val.first, val.last]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 128)
- def _reduce_37(val, _values, result)
- result = [val.first, val.last]
- result
- end
-.,.,
-
-# reduce 38 omitted
-
-# reduce 39 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 133)
- def _reduce_40(val, _values, result)
- case val[0]
- when 'even'
- result = Node.new(:NTH, ['2','n','+','0'])
- when 'odd'
- result = Node.new(:NTH, ['2','n','+','1'])
- when 'n'
- result = Node.new(:NTH, ['1','n','+','0'])
- else
- # This is not CSS standard. It allows us to support this:
- # assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
- # assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
- # assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
- result = val
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 152)
- def _reduce_41(val, _values, result)
- if val[1] == 'n'
- result = Node.new(:NTH, val)
- else
- raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 158)
- def _reduce_42(val, _values, result)
- # n+3, -n+3
- if val[0] == 'n'
- val.unshift("1")
- result = Node.new(:NTH, val)
- elsif val[0] == '-n'
- val[0] = 'n'
- val.unshift("-1")
- result = Node.new(:NTH, val)
- else
- raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 170)
- def _reduce_43(val, _values, result)
- # 5n, -5n, 10n-1
- n = val[1]
- if n[0, 2] == 'n-'
- val[1] = 'n'
- val << "-"
- # b is contained in n as n is the string "n-b"
- val << n[2, n.size]
- result = Node.new(:NTH, val)
- elsif n == 'n'
- val << "+"
- val << "0"
- result = Node.new(:NTH, val)
- else
- raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 189)
- def _reduce_44(val, _values, result)
- result = Node.new(:PSEUDO_CLASS, [val[1]])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 191)
- def _reduce_45(val, _values, result)
- result = Node.new(:PSEUDO_CLASS, [val[1]])
- result
- end
-.,.,
-
-# reduce 46 omitted
-
-# reduce 47 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 199)
- def _reduce_48(val, _values, result)
- result = Node.new(:COMBINATOR, val)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 202)
- def _reduce_49(val, _values, result)
- result = Node.new(:COMBINATOR, val)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 205)
- def _reduce_50(val, _values, result)
- result = Node.new(:COMBINATOR, val)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 208)
- def _reduce_51(val, _values, result)
- result = Node.new(:COMBINATOR, val)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 211)
- def _reduce_52(val, _values, result)
- result = Node.new(:COMBINATOR, val)
-
- result
- end
-.,.,
-
-# reduce 53 omitted
-
-# reduce 54 omitted
-
-# reduce 55 omitted
-
-# reduce 56 omitted
-
-# reduce 57 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 220)
- def _reduce_58(val, _values, result)
- result = Node.new(:ID, val)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 223)
- def _reduce_59(val, _values, result)
- result = [val.first, val[1]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 224)
- def _reduce_60(val, _values, result)
- result = [val.first, val[1]]
- result
- end
-.,.,
-
-# reduce 61 omitted
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 228)
- def _reduce_62(val, _values, result)
- result = :equal
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 229)
- def _reduce_63(val, _values, result)
- result = :prefix_match
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 230)
- def _reduce_64(val, _values, result)
- result = :suffix_match
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 231)
- def _reduce_65(val, _values, result)
- result = :substring_match
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 232)
- def _reduce_66(val, _values, result)
- result = :not_equal
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 233)
- def _reduce_67(val, _values, result)
- result = :includes
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 234)
- def _reduce_68(val, _values, result)
- result = :dash_match
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'nokogiri-css.y', 238)
- def _reduce_69(val, _values, result)
- result = Node.new(:NOT, [val[1]])
-
- result
- end
-.,.,
-
-# reduce 70 omitted
-
-# reduce 71 omitted
-
-# reduce 72 omitted
-
-# reduce 73 omitted
-
-# reduce 74 omitted
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
- end # module CSS
-end # module Nokogiri
diff --git a/test/racc/regress/opal b/test/racc/regress/opal
deleted file mode 100644
index 1bd6c0f255..0000000000
--- a/test/racc/regress/opal
+++ /dev/null
@@ -1,6429 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-module Opal
- class Parser < Racc::Parser
-
-module_eval(<<'...end opal.y/module_eval...', 'opal.y', 1808)
-
-...end opal.y/module_eval...
-##### State transition tables begin ###
-
-clist = [
-'63,64,65,619,51,-94,-96,-94,57,58,268,205,206,61,73,59,60,62,23,24,66',
-'67,74,544,205,206,546,22,28,27,90,89,91,92,777,653,17,607,273,273,205',
-'206,531,41,-99,-92,94,93,575,84,50,86,85,87,273,88,95,96,-68,81,82,-97',
-'38,39,-95,597,618,-100,718,652,-98,205,206,-534,-452,575,552,716,205',
-'206,810,-452,575,-85,-93,210,575,581,214,582,575,52,-99,227,54,-79,649',
-'-92,609,608,40,101,877,-100,268,268,100,770,18,-99,-95,-87,-85,79,73',
-'75,76,77,78,-94,-97,-94,74,80,-94,272,272,63,64,65,56,51,813,53,582',
-'57,58,-535,37,83,61,272,59,60,62,258,259,66,67,-90,-84,-85,-94,876,257',
-'291,295,90,89,91,92,308,101,219,574,227,-88,100,308,-86,292,596,-91',
-'94,93,-89,84,50,86,85,361,551,88,95,96,-458,81,82,-85,101,101,574,832',
-'813,100,100,101,-85,574,900,101,100,574,-93,101,100,574,344,343,100',
-'-96,-92,362,-92,-98,214,-92,-100,52,-100,-86,54,-100,-99,-95,-99,-95',
-'-89,-99,-95,-91,813,101,277,-97,-92,-97,100,726,-97,79,73,75,76,77,78',
-'653,-88,819,74,80,-87,-90,726,63,64,65,56,51,-84,53,607,57,58,612,296',
-'83,61,653,59,60,62,258,259,66,67,544,820,653,546,652,257,291,295,90',
-'89,91,92,-86,-534,219,-331,-331,-535,-535,-89,204,41,-91,-331,94,93',
-'652,84,50,86,85,87,558,88,95,96,652,81,82,-88,38,39,-534,-87,-90,726',
-'609,608,-96,-86,-96,-84,-98,-96,-98,561,-89,-98,-86,-91,454,-91,101',
-'210,725,-89,214,100,-91,52,-100,-331,54,-331,527,528,-88,101,40,725',
-'-87,-90,100,706,544,-88,218,546,-84,-87,-90,79,73,75,76,77,78,-84,823',
-'630,74,80,824,631,561,63,64,65,56,51,-100,53,544,57,58,543,37,83,61',
-'789,59,60,62,258,259,66,67,827,-532,400,401,308,257,291,295,90,89,91',
-'92,813,-86,219,788,836,-88,101,625,725,41,-95,100,94,93,-97,84,50,86',
-'85,87,-453,88,95,96,607,81,82,-453,38,39,-97,227,231,236,237,238,233',
-'235,243,244,239,240,-449,-449,220,221,205,206,241,242,-449,210,602,-95',
-'214,-532,412,52,837,603,54,414,413,224,268,230,40,226,225,222,223,234',
-'232,228,218,229,-532,344,343,79,73,75,76,77,78,609,608,620,74,80,839',
-'245,702,63,64,65,56,51,-449,53,-449,57,58,701,37,83,61,607,59,60,62',
-'258,259,66,67,700,754,-458,840,754,257,291,295,90,89,91,92,751,607,219',
-'751,-446,531,607,-449,776,41,415,-446,94,93,-449,84,50,86,85,87,-456',
-'88,95,96,532,81,82,-456,38,39,101,-84,-534,344,343,100,344,343,842,227',
-'-92,609,608,605,264,265,-90,533,101,-85,694,210,266,100,214,-99,101',
-'52,-94,402,54,100,609,608,610,-455,40,609,608,614,752,224,-455,752,218',
-'226,225,524,946,79,73,75,76,77,78,947,537,101,74,80,850,-454,100,63',
-'64,65,56,51,-454,53,-451,57,58,852,37,83,61,-451,59,60,62,258,259,66',
-'67,103,104,105,106,107,257,28,27,90,89,91,92,101,855,219,524,593,100',
-'945,856,586,41,858,591,94,93,860,84,50,86,85,87,261,88,95,96,862,81',
-'82,227,38,39,864,227,231,236,237,238,233,235,243,244,239,240,524,584',
-'220,221,832,813,241,242,585,210,301,302,214,205,206,52,684,592,54,523',
-'256,224,308,230,40,226,225,222,223,234,232,228,218,229,-265,-283,-283',
-'79,73,75,76,77,78,-283,391,388,74,80,-535,245,650,63,64,65,56,51,583',
-'53,586,57,58,682,37,83,61,-79,59,60,62,258,259,66,67,103,104,105,106',
-'107,257,28,27,90,89,91,92,681,679,219,203,201,671,-283,670,-283,41,308',
-'202,94,93,547,84,50,86,85,87,261,88,95,96,548,81,82,878,38,39,879,227',
-'231,236,237,238,233,235,243,244,239,240,524,593,220,221,880,881,241',
-'242,822,210,883,884,214,694,491,52,886,199,54,200,256,224,308,230,40',
-'226,225,222,223,234,232,228,218,229,-263,524,534,79,73,75,76,77,78,535',
-'890,227,74,80,227,245,895,-255,-255,-255,56,-255,592,53,523,-255,-255',
-'897,37,83,-255,300,-255,-255,-255,-255,-255,-255,-255,103,104,105,106',
-'107,-255,-255,-255,-255,-255,-255,-255,227,227,-255,203,449,555,452',
-'558,451,-255,903,450,-255,-255,905,-255,-255,-255,-255,-255,-255,-255',
-'-255,-255,906,-255,-255,308,-255,-255,559,227,231,236,237,238,233,235',
-'243,244,239,240,524,521,220,221,561,570,241,242,522,-255,571,299,-255',
-'268,919,-255,-266,452,-255,451,-255,224,-255,230,-255,226,225,222,223',
-'234,232,228,-255,229,268,-284,-284,-255,-255,-255,-255,-255,-255,-284',
-'246,921,-255,-255,404,245,964,-537,-537,-537,-255,-537,520,-255,523',
-'-537,-537,-535,-255,-255,-537,561,-537,-537,-537,-537,-537,-537,-537',
-'860,931,932,629,628,-537,-537,-537,-537,-537,-537,-537,198,937,-537',
-'-286,-286,855,-284,939,-284,-537,227,-286,-537,-537,860,-537,-537,-537',
-'-537,-537,-537,-537,-537,-537,860,-537,-537,862,-537,-537,-263,227,231',
-'236,237,238,233,235,243,244,239,240,224,197,220,221,226,225,241,242',
-'196,-537,966,627,-537,-537,948,-537,967,-286,-537,-286,-537,224,-537',
-'230,-537,226,225,222,223,234,232,228,-537,229,195,108,954,-537,-537',
-'-537,-537,-537,-537,708,624,700,-537,-537,587,245,621,-536,-536,-536',
-'-537,-536,97,-537,589,-536,-536,617,-537,-537,-536,613,-536,-536,-536',
-'-536,-536,-536,-536,708,588,497,497,497,-536,-536,-536,-536,-536,-536',
-'-536,497,491,-536,-264,489,341,340,344,343,-536,791,792,-536,-536,487',
-'-536,-536,-536,-536,-536,-536,-536,-536,-536,772,-536,-536,-67,-536',
-'-536,489,227,491,215,456,341,340,344,343,227,866,867,800,915,868,95',
-'96,455,754,514,802,-536,803,453,-536,-536,515,-536,516,751,-536,729',
-'-536,224,-536,694,-536,226,225,222,223,224,807,582,-536,226,225,222',
-'223,-536,-536,-536,-536,-536,-536,525,268,721,-536,-536,341,340,344',
-'343,268,808,-536,915,,-536,,,754,,-536,-536,63,64,65,8,51,,,751,57,58',
-',,,61,,59,60,62,23,24,66,67,,752,,,,22,28,27,90,89,91,92,,,17,,341,340',
-'344,343,7,41,6,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227',
-'231,236,237,238,233,235,243,244,239,240,,752,220,221,,,241,242,,36,',
-',30,,,52,,,54,,32,224,,230,40,226,225,222,223,234,232,228,18,229,,,',
-'79,73,75,76,77,78,,,,74,80,,245,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,28,27,90,89,91,92,,563,219,336,334',
-'333,,335,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39,,227',
-'231,236,237,238,233,235,243,244,239,240,,,220,221,,,241,242,,210,,,214',
-',,52,,,54,,256,224,,230,40,226,225,222,223,234,232,228,218,229,,,,79',
-'73,75,76,77,78,,,,74,80,,245,,63,64,65,56,51,,53,,57,58,,37,83,61,,59',
-'60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,563,17,336,334,333,,335',
-',41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227,231,236,237',
-'238,233,235,243,244,239,240,,,220,221,,,241,242,,210,,,214,,,52,,,54',
-',,224,,230,40,226,225,222,223,234,232,228,18,229,,,,79,73,75,76,77,78',
-',,,74,80,,245,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66',
-'67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,',
-'88,95,96,,81,82,,38,39,,227,231,236,237,238,233,235,243,244,239,240',
-',,220,221,,,241,242,,210,,,214,,,52,,,54,,,224,,230,40,226,225,222,223',
-'234,232,228,18,229,,,,79,73,75,76,77,78,,,,74,80,,245,,-255,-255,-255',
-'56,-255,,53,,-255,-255,,37,83,-255,,-255,-255,-255,-255,-255,-255,-255',
-',,,,,-255,-255,-255,-255,-255,-255,-255,,,-255,,,,,,,-255,,,-255,-255',
-',-255,-255,-255,-255,-255,-255,-255,-255,-255,,-255,-255,,-255,-255',
-',227,231,236,237,238,233,235,243,244,239,240,,,220,221,,,241,242,,-255',
-',,-255,268,,-255,,,-255,,-255,224,-255,230,-255,226,225,222,223,234',
-'232,228,-255,229,,,,-255,-255,-255,-255,-255,-255,,,,-255,-255,,245',
-',63,64,65,-255,51,,-255,,57,58,,-255,-255,61,,59,60,62,258,259,66,67',
-',,,,,257,291,295,90,89,91,92,,,219,,,,,625,,41,,,94,93,,84,50,86,85',
-'87,,88,95,96,,81,82,,38,39,,227,231,236,237,238,233,235,243,244,239',
-'240,,,220,221,,,241,242,,210,,,214,,,52,,,54,,,224,,230,40,226,225,222',
-'223,234,232,228,218,229,,,,79,73,75,76,77,78,,,,74,80,,245,,-233,,,56',
-',,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,',
-',,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,227,231,236,237,238,233,235,243,244,239,240,,,220',
-'221,,,241,242,,36,,,30,,,52,,,54,,32,224,,230,40,226,225,222,223,234',
-'232,228,18,229,,,,79,73,75,76,77,78,,,,74,80,,245,,-233,,,56,,,53,,',
-',,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28',
-'27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81',
-'82,,38,39,,227,231,236,237,238,233,235,243,244,239,240,,,220,221,,,241',
-'242,,36,,,30,,,52,,,54,,32,224,,230,40,226,225,222,223,234,232,228,18',
-'229,,,,79,73,75,76,77,78,,,,74,80,,245,,,,,56,,,53,,,,,37,83,63,64,65',
-'8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92',
-',,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227',
-'231,236,237,238,233,235,243,244,239,240,,,220,221,,,241,242,,36,,,30',
-',,52,,,54,,32,224,,230,40,226,225,222,223,234,232,228,18,229,,,,79,73',
-'75,76,77,78,,,,74,80,,245,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57',
-'58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7',
-'41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227,231,236,237',
-'238,233,235,243,244,239,240,,,220,221,,,241,242,,36,,,30,,,52,,,54,',
-'32,224,,230,40,226,225,222,223,234,232,228,18,229,,,,79,73,75,76,77',
-'78,,,,74,80,,245,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258',
-'259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,227,231,236,237,238,233,235,243,244',
-'239,240,,,220,221,,,241,242,,210,,,214,,,52,,,54,,658,224,254,230,40',
-'226,225,222,223,234,232,228,218,229,,,,79,73,75,76,77,78,,,,74,80,,245',
-',,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66',
-'67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87',
-',88,95,96,,81,82,,38,39,,227,231,236,237,238,233,235,243,244,239,240',
-',,220,221,,,241,242,,36,,,30,,,52,,,54,,32,224,,230,40,226,225,222,223',
-'234,232,228,18,229,,,,79,73,75,76,77,78,,,,74,80,,245,,,,,56,,,53,,',
-',,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28',
-'27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81',
-'82,,38,39,,227,231,236,237,238,233,235,243,244,239,240,,,220,221,,,241',
-'242,,36,,,30,,,52,,,54,,32,224,,230,40,226,225,222,223,234,232,228,18',
-'229,,,,79,73,75,76,77,78,,,,74,80,,245,,63,64,65,56,51,,53,,57,58,,37',
-'83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,563,219',
-'336,334,333,,335,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39',
-'563,,336,334,333,,335,,,563,566,336,334,333,,335,,,829,,,210,,,214,',
-',52,,,54,,658,,,,40,,,566,,,,,218,,,569,566,79,73,75,76,77,78,,569,',
-'74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67',
-',,,,,257,291,295,90,89,91,92,,,219,,,,,,,292,,,94,93,,84,50,86,85,87',
-',88,95,96,,81,82,327,,336,334,333,227,335,,,,,,,,,,,,,,,,241,242,926',
-',,214,,,52,,,54,,,,224,,338,,226,225,222,223,,,341,340,344,343,,79,73',
-'75,76,77,78,794,,,74,80,,,,63,64,65,56,51,,53,,57,58,,296,83,61,,59',
-'60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84',
-'50,86,85,87,,88,95,96,,81,82,,38,39,,227,-555,-555,-555,-555,233,235',
-',,-555,-555,,,,,,,241,242,,210,,,214,215,,52,,,54,,,224,,230,40,226',
-'225,222,223,234,232,228,18,229,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,227,-555,-555,-555,-555,233,235,,,-555,-555,,,,,,,241,242,,210,',
-',214,,,52,,,54,,,224,,230,40,226,225,222,223,234,232,228,218,229,,,',
-'79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,',
-'57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,',
-',,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227,-555,-555',
-'-555,-555,233,235,,,-555,-555,,,,,,,241,242,,36,,,30,,,52,,,54,,32,224',
-',230,40,226,225,222,223,234,232,228,18,229,,,,79,73,75,76,77,78,,,,74',
-'80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,',
-',,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261',
-'88,95,96,,81,82,,38,39,,227,-555,-555,-555,-555,233,235,,,-555,-555',
-',,,,,,241,242,,210,,,214,,,52,,,54,,,224,254,230,40,226,225,222,223',
-'234,232,228,218,229,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51',
-',53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27,90,89,91',
-'92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39',
-',227,-555,-555,-555,-555,233,235,,,-555,-555,,,,,,,241,242,,210,,,214',
-',,52,,,54,,256,224,254,230,40,226,225,222,223,234,232,228,218,229,,',
-',79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,',
-'59,60,62,258,259,66,67,,,,,,257,28,27,90,89,91,92,,,219,,,,,,,41,,,94',
-'93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39,,227,,,,,,,,,,,,,,,,,241',
-'242,,210,,,214,,,52,,,54,,256,224,254,230,40,226,225,222,223,,,228,218',
-'229,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83',
-'61,,59,60,62,258,259,66,67,,,,,,257,28,27,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39,,227,,,,,,,,,,,,',
-',,,,241,242,,210,,,214,,,52,,,54,,256,224,254,230,40,226,225,222,223',
-',,228,218,229,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57',
-'58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,',
-'219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227,,',
-',,,,,,,,,,,,,,241,242,,210,,,214,,,52,,,54,,,224,,230,40,226,225,222',
-'223,,,228,218,229,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53',
-',57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92',
-',,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227',
-'231,236,237,238,233,235,243,,239,240,,,,,,,241,242,,210,,,214,,,52,',
-',54,,,224,,230,40,226,225,222,223,234,232,228,218,229,,,,79,73,75,76',
-'77,78,,,,74,80,,,,-255,-255,-255,56,-255,,53,,-255,-255,,37,83,-255',
-',-255,-255,-255,-255,-255,-255,-255,,,,,,-255,-255,-255,-255,-255,-255',
-'-255,,,-255,,,,,,,-255,,,-255,-255,,-255,-255,-255,-255,-255,-255,-255',
-'-255,-255,,-255,-255,,-255,-255,,227,231,236,237,238,233,235,,,239,240',
-',,,,,,241,242,,-255,,,-255,268,,-255,,,-255,,-255,224,-255,230,-255',
-'226,225,222,223,234,232,228,-255,229,,,,-255,-255,-255,-255,-255,-255',
-',,,-255,-255,,,,,,,-255,,,-255,,,,,-255,-255,63,64,65,8,51,,,,57,58',
-',,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41',
-',9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227,,,,,,,,,,,,,,',
-',,241,242,,36,,,281,,,52,,,54,,32,224,,230,40,226,225,222,223,,,228',
-'18,229,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37',
-'83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,',
-',,,292,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,327,,336,334,333,,335',
-',,,,,,,,,,,,,,,,,289,,,286,,,52,,,54,,285,,,,338,,554,,,,,,341,340,344',
-'343,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,296,83',
-'61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,',
-'292,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,764,,336,334,333,754,335',
-',,,,,,,,,751,,,,,,,,289,,,214,,,52,,,54,,,,,,338,,,,,,,,341,340,344',
-'343,,79,73,75,76,77,78,,,,74,80,,,,298,,,56,,,53,,,,,296,83,63,64,65',
-',51,,,752,57,58,,,,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89',
-'91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39',
-',227,-555,-555,-555,-555,233,235,,,-555,-555,,,,,,,241,242,,210,,,214',
-',,52,,,54,,,224,,230,40,226,225,222,223,234,232,228,218,229,,,,79,73',
-'75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58',
-',,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41',
-',9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,227,231,236,237,238',
-'233,235,243,244,239,240,,,-555,-555,,,241,242,,36,,,30,,,52,,,54,,32',
-'224,,230,40,226,225,222,223,234,232,228,18,229,,,,79,73,75,76,77,78',
-',,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60',
-'62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84',
-'50,86,85,87,,88,95,96,,81,82,,38,39,,227,231,236,237,238,233,235,243',
-'244,239,240,,,-555,-555,,,241,242,,36,,,30,,,52,,,54,,32,224,,230,40',
-'226,225,222,223,234,232,228,18,229,,,,79,73,75,76,77,78,,,,74,80,,,',
-'63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28',
-'27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,227,,,,,,,,,,,,,,,,,241,242,,210,,,214,,,52,,,54,,,224,,230',
-'40,226,225,222,223,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65',
-'56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,227,,,,,,,,,,,,,,,,,241,242,,210,,,214,,,52,,,54,,,224,,230',
-'40,226,225,222,223,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65',
-'56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,',
-',,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23',
-'24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86',
-'85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54',
-',32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51',
-',53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89',
-'91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39',
-',,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,256,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52',
-',,54,,,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27,90,89',
-'91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,256,,,,40,,,,,,,,218,,',
-',,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,',
-',,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,',
-'74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67',
-',,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87',
-',88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,',
-',,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53',
-',57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92',
-',,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,',
-',,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75',
-'76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23',
-'24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85',
-'87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54',
-',,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,',
-'53,,57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92',
-',,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,',
-',,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,18,,,,,79,73,75,76',
-'77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24',
-'66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87',
-',88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,',
-',,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,101,,,,,100,56,,,53,,',
-',,37,83,63,64,65,,51,,,,57,58,,,,61,,59,60,62,258,259,66,67,,,,,,257',
-'291,295,90,89,91,92,,,219,,,,,,,292,,,94,93,,84,50,86,85,87,,88,95,96',
-',81,82,327,,336,334,333,,335,,,,,,,,,,,,,,,,,,356,,,30,,,52,,,54,,32',
-',,,338,322,,,,,,,341,340,344,343,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,296,83,61,,59,60,62,258,259,66,67,,,,,,257,291',
-'295,90,89,91,92,,,219,,,,,,,292,,,94,93,,84,50,86,85,361,,88,95,96,',
-'81,82,327,,336,334,333,,335,,,,,,,,,,,,,,,367,,,362,,,214,,,52,,,54',
-',,,,,338,,,,,,,,341,340,344,343,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,296,83,61,,59,60,62,258,259,66,67,,,,,,257,291',
-'295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81',
-'82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218',
-',,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,219,,,,,,,41,,,94',
-'93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210',
-',,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,',
-',63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28',
-'27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81',
-'82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218',
-',,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23',
-'24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86',
-'85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54',
-',32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51',
-',53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89',
-'91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39',
-',,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73',
-'75,76,77,78,,,,74,80,,,,-531,-531,-531,56,-531,,53,,-531,-531,,37,83',
-'-531,,-531,-531,-531,-531,-531,-531,-531,,-531,,,,-531,-531,-531,-531',
-'-531,-531,-531,,,-531,,,,,,,-531,,,-531,-531,,-531,-531,-531,-531,-531',
-'-531,-531,-531,-531,,-531,-531,,-531,-531,,,,,,,,,,,,,,,,,,,,,,-531',
-',,-531,-531,,-531,,,-531,,-531,,-531,,-531,,,,,,,,-531,,-531,,,-531',
-'-531,-531,-531,-531,-531,,,,-531,-531,,,,-532,-532,-532,-531,-532,,-531',
-',-532,-532,,-531,-531,-532,,-532,-532,-532,-532,-532,-532,-532,,-532',
-',,,-532,-532,-532,-532,-532,-532,-532,,,-532,,,,,,,-532,,,-532,-532',
-',-532,-532,-532,-532,-532,-532,-532,-532,-532,,-532,-532,,-532,-532',
-',,,,,,,,,,,,,,,,,,,,,-532,,,-532,-532,,-532,,,-532,,-532,,-532,,-532',
-',,,,,,,-532,,-532,,,-532,-532,-532,-532,-532,-532,,,,-532,-532,,,,,',
-',-532,,,-532,,,,,-532,-532,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23',
-'24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86',
-'85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54',
-',32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,',
-',37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28',
-'27,90,89,91,92,,,17,,,,,,7,41,6,9,94,93,,84,50,86,85,87,,88,95,96,,81',
-'82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18',
-',,,,79,73,75,76,77,78,,,,74,80,,,,,,404,56,,,53,,,,,37,83,63,64,65,',
-'51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,',
-'17,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,',
-',,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,18,,,,,79,73,75,76,77',
-'78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66',
-'67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,',
-'88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,',
-',40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,',
-'57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17',
-',,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,',
-',,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78',
-',,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67',
-',,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63',
-'64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89',
-'91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39',
-',,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73',
-'75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58',
-',,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41',
-'6,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,',
-',,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23',
-'24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86',
-'85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54',
-',32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,',
-',37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28',
-'27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81',
-'82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18',
-',,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,52,,,54,,,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,,,,56',
-',,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,',
-',,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40',
-',,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58',
-',37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,219,,,,',
-',,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,',
-',,,,,,210,,,214,,,52,,,54,,421,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78',
-',,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67',
-',,,,,22,28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,421,,',
-',40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53',
-',57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,219',
-',,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,',
-',,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77',
-'78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259',
-'66,67,,,,,,257,28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85',
-'87,261,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,',
-'54,,256,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65',
-'56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,256,,,,40,,,,,,,,218',
-',,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,256,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,',
-'74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67',
-',,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87',
-',88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,421',
-',,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53',
-',57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92',
-',,219,,,,,,,292,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,,,,,,,,,,',
-',,,,,,,,,,,,,289,,,286,,,52,,,54,,,,,,,,,,,,,,,,,,,79,73,75,76,77,78',
-',,,74,80,,,,63,64,65,56,51,,53,,57,58,,296,83,61,,59,60,62,23,24,66',
-'67,,,,,,22,28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87',
-',88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,',
-',,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53',
-',57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17',
-',,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,',
-',,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78',
-',,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67',
-',,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58',
-',37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219',
-',,,,,,292,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,764,,336,334,333',
-'754,335,,,,,,,,,,751,,,,,,,,289,,,286,,,52,,,54,,,,,,338,749,,,,,,,341',
-'340,344,343,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,296,83,63',
-'64,65,8,51,,,752,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90',
-'89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57',
-'58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7',
-'41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,',
-',,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,',
-'74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67',
-',,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87',
-'261,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54',
-',,,254,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,658,,254,,40,,,,,,',
-',218,,,,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65',
-'8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92',
-',,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,',
-',,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75',
-'76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,',
-'61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9',
-'94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36',
-',,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,',
-',63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28',
-'27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,458,52,,,54,,,,,,40,,,,,,,,18',
-',,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,',
-',,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57',
-'58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,',
-'219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,',
-',,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76',
-'77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258',
-'259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52',
-',,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,',
-',,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,',
-',,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57',
-'58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,',
-'219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,',
-',,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76',
-'77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258',
-'259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52',
-',,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,',
-',,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,',
-',,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57',
-'58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,',
-'219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,',
-',,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76',
-'77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258',
-'259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52',
-',,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,',
-',,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,',
-',,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57',
-'58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,',
-'219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,',
-',,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76',
-'77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258',
-'259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52',
-',,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,',
-',,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51',
-',,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17',
-',,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,',
-',,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77',
-'78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259',
-'66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86',
-'85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,',
-'54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,',
-',,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61',
-',59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41',
-',,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,',
-',210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67,,,,',
-',22,28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95',
-'96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,',
-',,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58',
-',37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,219,,,,',
-',,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,',
-',,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,',
-',,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67',
-',,,,,22,28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57',
-'58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27,90,89,91,92,,,219',
-',,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39,,,,,,,,',
-',,,,,,,,,,,,,210,,,214,,,52,,,54,,256,,254,,40,,,,,,,,218,,,,,79,73',
-'75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62',
-'258,259,66,67,,,,,,257,28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84',
-'50,86,85,87,261,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,506,,,54,,256,,254,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,',
-',,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257',
-'28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96',
-',81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,510,52,,,54,,256,,254',
-',40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53',
-',57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92',
-',,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,',
-',,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,775,,,,40,,,,,,,,218,,,,,79,73',
-'75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62',
-'258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84',
-'50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,',
-',52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90',
-'89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,18,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57',
-'58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7',
-'41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,',
-',,,,,36,,,281,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,',
-',74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,23,24,66,67',
-',,,,,22,28,27,90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88',
-'95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40',
-',,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58',
-',37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27,90,89,91,92,,,219,',
-',,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39,,,,,,,,,',
-',,,,,,,,,,,,210,,,214,,,52,,,54,,256,,,,40,,,,,,,,218,,,,,79,73,75,76',
-'77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258',
-'259,66,67,,,,,,257,28,27,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86',
-'85,87,261,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52',
-',,54,,256,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65',
-'56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295',
-'90,89,91,92,,,219,,,,,,,292,,,94,93,,84,50,86,85,87,,88,95,96,,81,82',
-'764,,336,334,333,754,335,,,,,,,,,,751,,,,,,,,289,,,214,,,52,,,54,,,',
-',,338,749,,,,,,,341,340,344,343,,79,73,75,76,77,78,,,,74,80,,,,518,',
-',56,,,53,,,,,296,83,63,64,65,8,51,,,752,57,58,,,,61,,59,60,62,23,24',
-'66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85',
-'87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,281,,,52,,,54,',
-'32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51',
-',53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27,90,89,91',
-'92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39',
-',,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,256,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57',
-'58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7',
-'41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,',
-',,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,',
-'74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62',
-'23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,',
-',54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53',
-',,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22',
-'28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96',
-',81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,',
-',,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37',
-'83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,',
-',,,292,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,764,,336,334,333,754',
-'335,,,,,,,,,,751,,,,,,,,712,,,214,,,52,,,54,,,,,,338,,,,,,,,341,340',
-'344,343,,79,73,75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,296,83,63,64,65',
-'8,51,,,752,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91',
-'92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,',
-',,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73',
-'75,76,77,78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58',
-',,,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41',
-',9,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,',
-',,36,,,30,,,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74',
-'80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,',
-',,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261',
-'88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,',
-',40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53',
-',57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92',
-',,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82,,38,39,,',
-',,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,658,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,292,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,,,,,,,,,,,,,,,,,,,,,,,,289,,,286,',
-',52,,,54,,,,,,,,,,,,,,,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,296,83,61,,59,60,62,23,24,66,67,,,,,,22,28,27,90,89,91',
-'92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,',
-',,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,18,,,,,79,73,75',
-'76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258',
-'259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50',
-'86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52',
-',,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38',
-'39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79',
-'73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60',
-'62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214',
-',,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81',
-'82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,256,,,,40,,,,,,',
-',218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37',
-'83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,',
-',,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,',
-',,,,,,,210,,,214,537,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77',
-'78,,,,74,80,,,,,,,56,,,53,,,,,37,83,63,64,65,8,51,,,,57,58,,,,61,,59',
-'60,62,23,24,66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93',
-',84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30',
-',,52,,,54,,32,,,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64',
-'65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,28,27',
-'90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81',
-'82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,256,,,,40,,,,,,',
-',218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37',
-'83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,',
-',,,292,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,,,,,,,,,,,,,,,,,,,',
-',,,,289,,,286,,,52,,,54,,,,,,,,,,,,,,,,,,,79,73,75,76,77,78,,,,74,80',
-',,,,,,56,,,53,,,,,296,83,63,64,65,8,51,,,,57,58,,,,61,,59,60,62,23,24',
-'66,67,,,,,,22,28,27,90,89,91,92,,,17,,,,,,7,41,,9,94,93,,84,50,86,85',
-'87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,,,54,,32',
-',,,40,,,,,,,,18,,,,,79,73,75,76,77,78,,,,74,80,,,,,,404,56,,,53,,,,',
-'37,83,63,64,65,,51,,,,57,58,,,,61,,59,60,62,23,24,66,67,,,,,,22,28,27',
-'90,89,91,92,,,17,,,,,,,41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,',
-'38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,675,52,,,54,,,,254,,40,,,,,,,',
-'18,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56,51,,53,,57,58,,37,83',
-'61,,59,60,62,258,259,66,67,,,,,,257,291,295,90,89,91,92,,,219,,,,,,',
-'41,,,94,93,,84,50,86,85,87,,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,',
-',,,,210,,,214,,,52,,,54,,,,,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,',
-'74,80,,,,63,64,65,56,51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67',
-',,,,,257,291,295,90,89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87',
-'261,88,95,96,,81,82,,38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54',
-',,,254,,40,,,,,,,,218,,,,,79,73,75,76,77,78,,,,74,80,,,,63,64,65,56',
-'51,,53,,57,58,,37,83,61,,59,60,62,258,259,66,67,,,,,,257,291,295,90',
-'89,91,92,,,219,,,,,,,41,,,94,93,,84,50,86,85,87,261,88,95,96,,81,82',
-',38,39,,,,,,,,,,,,,,,,,,,,,,210,,,214,,,52,,,54,,658,,254,,40,,,,,,',
-',218,,,,-283,79,73,75,76,77,78,-283,-283,-283,74,80,,-283,-283,,-283',
-',56,,,53,,,,,37,83,,,,,,,,,-283,-283,,-283,-283,-283,-283,-283,,,,,',
-',,,,,,,,,,,,,,,,,,-283,-283,-283,-283,-283,-283,-283,-283,-283,-283',
-'-283,-283,-283,-283,-283,,,-283,-283,-283,,639,,,,-283,,,,,,,-283,,-283',
-',-283,-283,-283,-283,-283,-283,-283,,-283,,-283,,,,,,,,,,,,,-283,-283',
-',-89,,-283,-538,,-283,,-283,,-98,-538,-538,-538,,,-538,-538,-538,,-538',
-',,,,,,,,-538,-538,-538,,,,,,,,,-538,-538,,-538,-538,-538,-538,-538,',
-',,,,,,,,,,,,,,,,,,,,,,-538,-538,-538,-538,-538,-538,-538,-538,-538,-538',
-'-538,-538,-538,-538,-538,,,-538,-538,-538,,790,-538,,,-538,,,-538,,-538',
-',-538,,-538,,-538,-538,-538,-538,-538,-538,-538,,-538,-538,-538,,,,',
-',,,,,,,,-538,-538,-538,-538,,-538,-283,,-538,,-538,,-96,-283,-283,-283',
-',,-283,-283,-283,,-283,,,,,,,,,,-283,-283,,,,,,,,,-283,-283,,-283,-283',
-'-283,-283,-283,,,,,,,,,,,,,,,,,,,,,,,,-283,-283,-283,-283,-283,-283',
-'-283,-283,-283,-283,-283,-283,-283,-283,-283,,,-283,-283,-283,,639,-283',
-',,-283,,,-283,,-283,,-283,,-283,,-283,-283,-283,-283,-283,-283,-283',
-',-283,,-283,,,,,,,,,,,,,-283,-283,-283,-283,,-283,-538,,-283,,-283,',
-'-98,-538,-538,-538,,,,-538,-538,,-538,,,,,,,,,-538,,,,,,,,,,,-538,-538',
-',-538,-538,-538,-538,-538,,,,,,,,,,,,,,,,,,,,,,,,-538,-538,-538,-538',
-'-538,-538,-538,-538,-538,-538,-538,-538,-538,-538,-538,,,-538,-538,-538',
-',636,,,,-538,,,,,,,-538,,-538,,-538,-538,-538,-538,-538,-538,-538,,-538',
-'-538,-538,,,,,,,,,,,,,-538,-538,,-87,,-538,-278,,-538,,-538,,-96,-278',
-'-278,-278,,,-278,-278,-278,,-278,,,,,,,,,,-278,-278,-278,,,,,,,,-278',
-'-278,,-278,-278,-278,-278,-278,,,,,,,,,,,,,,,,,,,,,,,,-278,-278,-278',
-'-278,-278,-278,-278,-278,-278,-278,-278,-278,-278,-278,-278,,,-278,-278',
-'-278,,,-278,,,-278,,,-278,,-278,,-278,,-278,,-278,-278,-278,-278,-278',
-'-278,-278,,-278,,-278,,,,,,,,,,,,,-278,-278,-278,-278,-292,-278,,-278',
-'-278,,-278,-292,-292,-292,,,-292,-292,-292,,-292,,,,,,,,,,-292,-292',
-',,,,,,,,-292,-292,,-292,-292,-292,-292,-292,,,,,,,,,,,,,,,,,,,,,,,,-292',
-'-292,-292,-292,-292,-292,-292,-292,-292,-292,-292,-292,-292,-292,-292',
-',,-292,-292,-292,,,-292,,277,-292,,,-292,,-292,,-292,,-292,,-292,-292',
-'-292,-292,-292,-292,-292,,-292,,-292,,,,,,,,,,,,,-292,-292,-292,-292',
-'-554,-292,,,-292,,-292,-554,-554,-554,,,-554,-554,-554,,-554,,,,,,,',
-',,-554,,,,,,,,,,-554,-554,,-554,-554,-554,-554,-554,,,,,,,,,,,,,,-554',
-',,,,,,-554,-554,-554,,,-554,-554,-554,,-554,,,,,-554,-554,,,,-554,,',
-'-554,,,,,268,-554,-554,-554,,-554,-554,-554,-554,-554,,,,,,,,,,,,,-554',
-',,,,,,,,,,,-554,-554,,-554,,,-554,-554,-554,-554,-554,-554,-554,-554',
-'-554,,-554,,-554,,,,,268,-554,,-554,,,,,,,,,,-554,-554,,-554,-554,-554',
-'-554,-554,,-554,,,,,,436,440,,,438,,,-554,,-554,,,-554,142,143,,139',
-'121,122,123,130,127,129,,,124,125,-554,-554,,,144,145,131,132,-554,',
-',,,268,-554,,,,,,136,135,,120,141,138,137,133,134,128,126,118,140,119',
-',-554,146,,,,,,,,,,,,-554,,-554,,,-554,156,167,157,180,153,173,163,162',
-'188,191,178,161,160,155,181,189,190,165,154,168,172,174,166,159,,,,175',
-'182,177,176,169,179,164,152,171,170,183,184,185,186,187,151,158,149',
-'150,147,148,,111,113,,,112,,,,,,,,,142,143,,139,121,122,123,130,127',
-'129,,,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137',
-'133,134,128,126,118,140,119,,,146,192,,,,,,,,,,80,156,167,157,180,153',
-'173,163,162,188,191,178,161,160,155,181,189,190,165,154,168,172,174',
-'166,159,,,,175,182,177,176,169,179,164,152,171,170,183,184,185,186,187',
-'151,158,149,150,147,148,,111,113,,,112,,,,,,,,,142,143,,139,121,122',
-'123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120',
-'141,138,137,133,134,128,126,118,140,119,,,146,192,,,,,,,,,,80,156,167',
-'157,180,153,173,163,162,188,191,178,161,160,155,181,189,190,165,154',
-'168,172,174,166,159,,,,175,182,177,176,169,179,164,152,171,170,183,184',
-'185,186,187,151,158,149,150,147,148,,111,113,,,112,,,,,,,,,142,143,',
-'139,121,122,123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,,,,,',
-',,136,135,,120,141,138,137,133,134,128,126,118,140,119,,,146,192,,,',
-',,,,,,80,156,167,157,180,153,173,163,162,188,191,178,161,160,155,181',
-'189,190,165,154,168,172,174,166,159,,,,175,182,177,176,169,179,164,152',
-'171,170,183,184,185,186,187,151,158,149,150,147,148,,111,113,110,,112',
-',,,,,,,,142,143,,139,121,122,123,130,127,129,,,124,125,,,,,144,145,131',
-'132,,,,,,,,,,,,,136,135,,120,141,138,137,133,134,128,126,118,140,119',
-',,146,192,,,,,,,,,,80,156,167,157,180,153,173,163,162,188,191,178,161',
-'160,155,181,189,190,165,154,168,172,174,166,159,,,,175,182,177,176,169',
-'179,164,152,171,170,183,184,185,186,187,151,158,149,150,147,148,,111',
-'113,398,397,112,,399,,,,,,,142,143,,139,121,122,123,130,127,129,,,124',
-'125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137,133,134',
-'128,126,118,140,119,,,146,156,167,157,180,153,173,163,162,188,191,178',
-'161,160,155,181,189,190,165,154,168,172,174,166,159,,,,175,182,177,176',
-'169,179,164,152,171,170,183,184,185,186,187,151,158,149,150,147,148',
-',111,113,398,397,112,,399,,,,,,,142,143,,139,121,122,123,130,127,129',
-',,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137,133',
-'134,128,126,118,140,119,,,146,156,167,157,180,153,173,163,162,188,191',
-'178,161,160,155,181,189,190,165,154,168,172,174,166,159,,,,175,182,177',
-'176,169,179,164,152,171,170,183,184,185,186,187,151,158,149,150,147',
-'148,,111,113,,,112,,,,,,,,,142,143,,139,121,122,123,130,127,129,,,124',
-'125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137,133,134',
-'128,126,118,140,119,,,146,156,167,157,180,153,173,163,162,188,191,178',
-'161,160,155,181,189,190,165,154,168,172,174,166,159,,,,175,182,177,376',
-'375,377,374,152,171,170,183,184,185,186,187,151,158,149,150,372,373',
-',370,113,86,85,371,,88,,,,,,,142,143,,139,121,122,123,130,127,129,,',
-'124,125,,,,,144,145,131,132,,,,,,381,,,,,,,136,135,,120,141,138,137',
-'133,134,128,126,118,140,119,642,434,146,,643,,,,,,,,,142,143,,139,121',
-'122,123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,268,,,,,,,136',
-'135,,120,141,138,137,133,134,128,126,118,140,119,644,440,146,,645,,',
-',,,,,,142,143,,139,121,122,123,130,127,129,,,124,125,,,,,144,145,131',
-'132,,,,,,,,,,,,,136,135,,120,141,138,137,133,134,128,126,118,140,119',
-'430,434,146,,431,,,,,,,,,142,143,,139,121,122,123,130,127,129,,,124',
-'125,,,,,144,145,131,132,,,,,,268,,,,,,,136,135,,120,141,138,137,133',
-'134,128,126,118,140,119,961,440,146,,962,,,,,,,,,142,143,,139,121,122',
-'123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120',
-'141,138,137,133,134,128,126,118,140,119,959,434,146,,960,,,,,,,,,142',
-'143,,139,121,122,123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,',
-'268,,,,,,,136,135,,120,141,138,137,133,134,128,126,118,140,119,443,434',
-'146,,444,,,,,,,,,142,143,,139,121,122,123,130,127,129,,,124,125,,,,',
-'144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137,133,134,128,126',
-'118,140,119,443,434,146,,444,,,,,,,,,142,143,,139,121,122,123,130,127',
-'129,,,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137',
-'133,134,128,126,118,140,119,443,434,146,,444,,,,,,,,,142,143,,139,121',
-'122,123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135',
-',120,141,138,137,133,134,128,126,118,140,119,642,434,146,,643,,,,,,',
-',,142,143,,139,121,122,123,130,127,129,,,124,125,,,,,144,145,131,132',
-',,,,,268,,,,,,,136,135,,120,141,138,137,133,134,128,126,118,140,119',
-'644,440,146,,645,,,,,,,,,142,143,,139,121,122,123,130,127,129,,,124',
-'125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137,133,134',
-'128,126,118,140,119,741,440,146,,892,,,,,,,,,142,143,,139,121,122,123',
-'130,127,129,,,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141',
-'138,137,133,134,128,126,118,140,119,443,434,146,,444,,,,,,,,,142,143',
-',139,121,122,123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,268',
-',,,,,,136,135,,120,141,138,137,133,134,128,126,118,140,119,741,440,146',
-',739,,,,,,,,,142,143,,139,121,122,123,130,127,129,,,124,125,,,,,144',
-'145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137,133,134,128,126,118',
-'140,119,735,440,146,,736,,,,,,,,,142,143,,139,121,122,123,130,127,129',
-',,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141,138,137,133',
-'134,128,126,118,140,119,733,434,146,,734,,,,,,,,,142,143,,139,121,122',
-'123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,268,,,,,,,136,135',
-',120,141,138,137,133,134,128,126,118,140,119,443,434,146,,444,,,,,,',
-',,142,143,,139,121,122,123,130,127,129,,,124,125,,,,,144,145,131,132',
-',,,,,,,,,,,,136,135,,120,141,138,137,133,134,128,126,118,140,119,686',
-'434,146,,687,,,,,,,,,142,143,,139,121,122,123,130,127,129,,,124,125',
-',,,,144,145,131,132,,,,,,268,,,,,,,136,135,,120,141,138,137,133,134',
-'128,126,118,140,119,689,440,146,,690,,,,,,,,,142,143,,139,121,122,123',
-'130,127,129,,,124,125,,,,,144,145,131,132,,,,,,,,,,,,,136,135,,120,141',
-'138,137,133,134,128,126,118,140,119,443,434,146,,444,,,,,,,,,142,143',
-',139,121,122,123,130,127,129,,,124,125,,,,,144,145,131,132,,,,,,,,,',
-',,,136,135,,120,141,138,137,133,134,128,126,118,140,119,,,146' ]
- racc_action_table = arr = ::Array.new(25094, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'58,58,58,392,58,967,735,839,58,58,693,746,746,58,71,58,58,58,58,58,58',
-'58,71,703,698,698,703,58,58,58,58,58,58,58,629,485,58,615,26,293,457',
-'457,453,58,587,354,58,58,347,58,58,58,58,58,55,58,58,58,681,58,58,734',
-'58,58,733,366,392,357,568,485,736,604,604,735,376,348,321,564,310,310',
-'698,376,838,807,629,58,889,352,58,352,896,58,453,696,58,681,457,924',
-'615,615,58,746,792,927,26,293,746,615,58,948,959,735,839,58,58,58,58',
-'58,58,967,960,967,58,58,967,26,293,369,369,369,58,369,934,58,934,369',
-'369,736,58,58,369,55,369,369,369,369,369,369,369,587,354,807,792,791',
-'369,369,369,369,369,369,369,604,347,369,347,697,734,347,310,733,369',
-'366,357,369,369,736,369,369,369,369,369,321,369,369,369,209,369,369',
-'807,348,366,348,949,949,348,366,838,807,838,838,889,838,889,791,896',
-'889,896,561,561,896,961,924,369,924,962,369,924,927,369,927,686,369',
-'927,948,959,948,959,690,948,959,290,699,3,291,960,209,960,3,577,960',
-'369,369,369,369,369,369,497,687,704,369,369,689,525,578,456,456,456',
-'369,456,287,369,387,456,456,387,369,369,456,508,456,456,456,456,456',
-'456,456,314,705,507,314,497,456,456,456,456,456,456,456,686,961,456',
-'42,42,962,690,690,14,456,290,42,456,456,508,456,456,456,456,456,708',
-'456,456,456,507,456,456,687,456,456,689,689,525,841,387,387,961,686',
-'961,287,962,961,962,710,690,962,686,290,211,14,577,456,577,690,456,577',
-'290,456,14,42,456,42,296,296,687,578,456,578,689,525,578,553,317,687',
-'456,317,287,689,525,456,456,456,456,456,456,287,712,430,456,456,713',
-'431,714,455,455,455,456,455,211,456,313,455,455,313,456,456,455,643',
-'455,455,455,455,455,455,455,717,361,83,83,292,455,455,455,455,455,455',
-'455,722,430,455,642,728,431,841,648,841,455,430,841,455,455,431,455',
-'455,455,455,455,377,455,455,455,394,455,455,377,455,455,643,648,648',
-'648,648,648,648,648,648,648,648,648,361,361,648,648,346,346,648,648',
-'361,455,379,642,455,361,110,455,730,379,455,110,110,648,295,648,455',
-'648,648,648,648,648,648,648,455,648,361,855,855,455,455,455,455,455',
-'455,394,394,394,455,455,732,648,540,454,454,454,455,454,361,455,361',
-'454,454,539,455,455,454,383,454,454,454,454,454,454,454,538,860,35,737',
-'852,454,454,454,454,454,454,454,860,385,454,852,370,300,389,371,628',
-'454,193,370,454,454,371,454,454,454,454,454,372,454,454,454,301,454',
-'454,372,454,454,351,35,741,860,860,351,852,852,742,462,35,383,383,383',
-'25,25,300,302,750,628,529,454,25,750,454,300,597,454,628,97,454,597',
-'385,385,385,373,454,389,389,389,860,462,373,852,454,462,462,925,925',
-'454,454,454,454,454,454,925,526,744,454,454,753,374,744,452,452,452',
-'454,452,374,454,375,452,452,757,454,454,452,375,452,452,452,452,452',
-'452,452,5,5,5,5,5,452,452,452,452,452,452,452,278,758,452,364,364,278',
-'925,760,925,452,761,364,452,452,762,452,452,452,452,452,452,452,452',
-'452,764,452,452,305,452,452,767,484,484,484,484,484,484,484,484,484',
-'484,484,355,355,484,484,720,720,484,484,355,452,37,37,452,15,15,452',
-'519,364,452,364,452,484,312,484,452,484,484,484,484,484,484,484,452',
-'484,774,739,739,452,452,452,452,452,452,739,78,77,452,452,739,484,484',
-'451,451,451,452,451,355,452,355,451,451,517,452,452,451,514,451,451',
-'451,451,451,451,451,680,680,680,680,680,451,451,451,451,451,451,451',
-'513,509,451,13,13,503,739,502,739,451,499,13,451,451,315,451,451,451',
-'451,451,451,451,451,451,316,451,451,795,451,451,796,784,784,784,784',
-'784,784,784,784,784,784,784,711,711,784,784,799,801,784,784,711,451',
-'804,805,451,806,318,451,811,13,451,13,451,784,41,784,451,784,784,784',
-'784,784,784,784,451,784,814,303,303,451,451,451,451,451,451,303,815',
-'466,451,451,465,784,830,442,442,442,451,442,711,451,711,442,442,833',
-'451,451,442,36,442,442,442,442,442,442,442,279,279,279,279,279,442,442',
-'442,442,442,442,442,464,463,442,208,208,326,303,327,303,442,843,208',
-'442,442,846,442,442,442,442,442,442,442,442,442,847,442,442,848,442',
-'442,329,779,779,779,779,779,779,779,779,779,779,779,288,288,779,779',
-'330,342,779,779,288,442,345,34,442,442,870,442,871,208,442,208,442,779',
-'442,779,442,779,779,779,779,779,779,779,442,779,437,589,589,442,442',
-'442,442,442,442,589,20,882,442,442,353,779,953,441,441,441,442,441,288',
-'442,288,441,441,892,442,442,441,893,441,441,441,441,441,441,441,955',
-'898,899,429,428,441,441,441,441,441,441,441,12,907,441,840,840,909,589',
-'912,589,441,461,840,441,441,913,441,441,441,441,441,441,441,441,441',
-'914,441,441,915,441,441,424,446,446,446,446,446,446,446,446,446,446',
-'446,461,11,446,446,461,461,446,446,10,441,956,422,441,441,926,441,958',
-'840,441,840,441,446,441,446,441,446,446,446,446,446,446,446,441,446',
-'9,6,936,441,441,441,441,441,441,824,416,944,441,441,356,446,410,440',
-'440,440,441,440,1,441,362,440,440,391,441,441,440,388,440,440,440,440',
-'440,440,440,555,358,632,637,267,440,440,440,440,440,440,440,640,255',
-'440,626,252,824,824,824,824,440,646,647,440,440,251,440,440,440,440',
-'440,440,440,440,440,619,440,440,280,440,440,655,480,657,219,213,555',
-'555,555,555,481,768,768,669,939,768,768,768,212,939,282,673,440,676',
-'210,440,440,283,440,284,939,440,580,440,480,440,683,440,480,480,480',
-'480,481,685,579,440,481,481,481,481,440,440,440,440,440,440,289,688',
-'573,440,440,939,939,939,939,691,692,440,858,,440,,,858,,440,440,0,0',
-'0,0,0,,,858,0,0,,,,0,,0,0,0,0,0,0,0,,939,,,,0,0,0,0,0,0,0,,,0,,858,858',
-'858,858,0,0,0,0,0,0,,0,0,0,0,0,,0,0,0,,0,0,,0,0,,773,773,773,773,773',
-'773,773,773,773,773,773,,858,773,773,,,773,773,,0,,,0,,,0,,,0,,0,773',
-',773,0,773,773,773,773,773,773,773,0,773,,,,0,0,0,0,0,0,,,,0,0,,773',
-',945,945,945,0,945,,0,,945,945,,0,0,945,,945,945,945,945,945,945,945',
-',,,,,945,945,945,945,945,945,945,,829,945,829,829,829,,829,,945,,,945',
-'945,,945,945,945,945,945,945,945,945,945,,945,945,,945,945,,19,19,19',
-'19,19,19,19,19,19,19,19,,,19,19,,,19,19,,945,,,945,,,945,,,945,,945',
-'19,,19,945,19,19,19,19,19,19,19,945,19,,,,945,945,945,945,945,945,,',
-',945,945,,19,,349,349,349,945,349,,945,,349,349,,945,945,349,,349,349',
-'349,349,349,349,349,,,,,,349,349,349,349,349,349,349,,569,349,569,569',
-'569,,569,,349,,,349,349,,349,349,349,349,349,,349,349,349,,349,349,',
-'349,349,,793,793,793,793,793,793,793,793,793,793,793,,,793,793,,,793',
-'793,,349,,,349,,,349,,,349,,,793,,793,349,793,793,793,793,793,793,793',
-'349,793,,,,349,349,349,349,349,349,,,,349,349,,793,,350,350,350,349',
-'350,,349,,350,350,,349,349,350,,350,350,350,350,350,350,350,,,,,,350',
-'350,350,350,350,350,350,,,350,,,,,,,350,,,350,350,,350,350,350,350,350',
-',350,350,350,,350,350,,350,350,,873,873,873,873,873,873,873,873,873',
-'873,873,,,873,873,,,873,873,,350,,,350,,,350,,,350,,,873,,873,350,873',
-'873,873,873,873,873,873,350,873,,,,350,350,350,350,350,350,,,,350,350',
-',873,,432,432,432,350,432,,350,,432,432,,350,350,432,,432,432,432,432',
-'432,432,432,,,,,,432,432,432,432,432,432,432,,,432,,,,,,,432,,,432,432',
-',432,432,432,432,432,432,432,432,432,,432,432,,432,432,,536,536,536',
-'536,536,536,536,536,536,536,536,,,536,536,,,536,536,,432,,,432,432,',
-'432,,,432,,432,536,432,536,432,536,536,536,536,536,536,536,432,536,',
-',,432,432,432,432,432,432,,,,432,432,,536,,421,421,421,432,421,,432',
-',421,421,,432,432,421,,421,421,421,421,421,421,421,,,,,,421,421,421',
-'421,421,421,421,,,421,,,,,419,,421,,,421,421,,421,421,421,421,421,,421',
-'421,421,,421,421,,421,421,,419,419,419,419,419,419,419,419,419,419,419',
-',,419,419,,,419,419,,421,,,421,,,421,,,421,,,419,,419,421,419,419,419',
-'419,419,419,419,421,419,,,,421,421,421,421,421,421,,,,421,421,,419,',
-'419,,,421,,,421,,,,,421,421,943,943,943,943,943,,,,943,943,,,,943,,943',
-'943,943,943,943,943,943,,,,,,943,943,943,943,943,943,943,,,943,,,,,',
-'943,943,,943,943,943,,943,943,943,943,943,,943,943,943,,943,943,,943',
-'943,,672,672,672,672,672,672,672,672,672,672,672,,,672,672,,,672,672',
-',943,,,943,,,943,,,943,,943,672,,672,943,672,672,672,672,672,672,672',
-'943,672,,,,943,943,943,943,943,943,,,,943,943,,672,,672,,,943,,,943',
-',,,,943,943,935,935,935,935,935,,,,935,935,,,,935,,935,935,935,935,935',
-'935,935,,,,,,935,935,935,935,935,935,935,,,935,,,,,,935,935,,935,935',
-'935,,935,935,935,935,935,,935,935,935,,935,935,,935,935,,427,427,427',
-'427,427,427,427,427,427,427,427,,,427,427,,,427,427,,935,,,935,,,935',
-',,935,,935,427,,427,935,427,427,427,427,427,427,427,935,427,,,,935,935',
-'935,935,935,935,,,,935,935,,427,,,,,935,,,935,,,,,935,935,930,930,930',
-'930,930,,,,930,930,,,,930,,930,930,930,930,930,930,930,,,,,,930,930',
-'930,930,930,930,930,,,930,,,,,,930,930,,930,930,930,,930,930,930,930',
-'930,,930,930,930,,930,930,,930,930,,875,875,875,875,875,875,875,875',
-'875,875,875,,,875,875,,,875,875,,930,,,930,,,930,,,930,,930,875,,875',
-'930,875,875,875,875,875,875,875,930,875,,,,930,930,930,930,930,930,',
-',,930,930,,875,,,,,930,,,930,,,,,930,930,923,923,923,923,923,,,,923',
-'923,,,,923,,923,923,923,923,923,923,923,,,,,,923,923,923,923,923,923',
-'923,,,923,,,,,,923,923,,923,923,923,,923,923,923,923,923,,923,923,923',
-',923,923,,923,923,,695,695,695,695,695,695,695,695,695,695,695,,,695',
-'695,,,695,695,,923,,,923,,,923,,,923,,923,695,,695,923,695,695,695,695',
-'695,695,695,923,695,,,,923,923,923,923,923,923,,,,923,923,,695,,921',
-'921,921,923,921,,923,,921,921,,923,923,921,,921,921,921,921,921,921',
-'921,,,,,,921,921,921,921,921,921,921,,,921,,,,,,,921,,,921,921,,921',
-'921,921,921,921,,921,921,921,,921,921,,921,921,,249,249,249,249,249',
-'249,249,249,249,249,249,,,249,249,,,249,249,,921,,,921,,,921,,,921,',
-'921,249,921,249,921,249,249,249,249,249,249,249,921,249,,,,921,921,921',
-'921,921,921,,,,921,921,,249,,,,,921,,,921,,,,,921,921,904,904,904,904',
-'904,,,,904,904,,,,904,,904,904,904,904,904,904,904,,,,,,904,904,904',
-'904,904,904,904,,,904,,,,,,904,904,,904,904,904,,904,904,904,904,904',
-',904,904,904,,904,904,,904,904,,786,786,786,786,786,786,786,786,786',
-'786,786,,,786,786,,,786,786,,904,,,904,,,904,,,904,,904,786,,786,904',
-'786,786,786,786,786,786,786,904,786,,,,904,904,904,904,904,904,,,,904',
-'904,,786,,,,,904,,,904,,,,,904,904,901,901,901,901,901,,,,901,901,,',
-',901,,901,901,901,901,901,901,901,,,,,,901,901,901,901,901,901,901,',
-',901,,,,,,901,901,,901,901,901,,901,901,901,901,901,,901,901,901,,901',
-'901,,901,901,,781,781,781,781,781,781,781,781,781,781,781,,,781,781',
-',,781,781,,901,,,901,,,901,,,901,,901,781,,781,901,781,781,781,781,781',
-'781,781,901,781,,,,901,901,901,901,901,901,,,,901,901,,781,,900,900',
-'900,901,900,,901,,900,900,,901,901,900,,900,900,900,900,900,900,900',
-',,,,,900,900,900,900,900,900,900,,718,900,718,718,718,,718,,900,,,900',
-'900,,900,900,900,900,900,,900,900,900,,900,900,,900,900,338,,338,338',
-'338,,338,,,566,718,566,566,566,,566,,,718,,,900,,,900,,,900,,,900,,900',
-',,,900,,,338,,,,,900,,,338,566,900,900,900,900,900,900,,566,,900,900',
-',,,890,890,890,900,890,,900,,890,890,,900,900,890,,890,890,890,890,890',
-'890,890,,,,,,890,890,890,890,890,890,890,,,890,,,,,,,890,,,890,890,',
-'890,890,890,890,890,,890,890,890,,890,890,652,,652,652,652,469,652,',
-',,,,,,,,,,,,,,469,469,890,,,890,,,890,,,890,,,,469,,652,,469,469,469',
-'469,,,652,652,652,652,,890,890,890,890,890,890,652,,,890,890,,,,17,17',
-'17,890,17,,890,,17,17,,890,890,17,,17,17,17,17,17,17,17,,,,,,17,17,17',
-'17,17,17,17,,,17,,,,,,,17,,,17,17,,17,17,17,17,17,,17,17,17,,17,17,',
-'17,17,,479,479,479,479,479,479,479,,,479,479,,,,,,,479,479,,17,,,17',
-'17,,17,,,17,,,479,,479,17,479,479,479,479,479,479,479,17,479,,,,17,17',
-'17,17,17,17,,,,17,17,,,,18,18,18,17,18,,17,,18,18,,17,17,18,,18,18,18',
-'18,18,18,18,,,,,,18,18,18,18,18,18,18,,,18,,,,,,,18,,,18,18,,18,18,18',
-'18,18,,18,18,18,,18,18,,18,18,,478,478,478,478,478,478,478,,,478,478',
-',,,,,,478,478,,18,,,18,,,18,,,18,,,478,,478,18,478,478,478,478,478,478',
-'478,18,478,,,,18,18,18,18,18,18,,,,18,18,,,,,,,18,,,18,,,,,18,18,886',
-'886,886,886,886,,,,886,886,,,,886,,886,886,886,886,886,886,886,,,,,',
-'886,886,886,886,886,886,886,,,886,,,,,,886,886,,886,886,886,,886,886',
-'886,886,886,,886,886,886,,886,886,,886,886,,477,477,477,477,477,477',
-'477,,,477,477,,,,,,,477,477,,886,,,886,,,886,,,886,,886,477,,477,886',
-'477,477,477,477,477,477,477,886,477,,,,886,886,886,886,886,886,,,,886',
-'886,,,,881,881,881,886,881,,886,,881,881,,886,886,881,,881,881,881,881',
-'881,881,881,,,,,,881,881,881,881,881,881,881,,,881,,,,,,,881,,,881,881',
-',881,881,881,881,881,881,881,881,881,,881,881,,881,881,,476,476,476',
-'476,476,476,476,,,476,476,,,,,,,476,476,,881,,,881,,,881,,,881,,,476',
-'881,476,881,476,476,476,476,476,476,476,881,476,,,,881,881,881,881,881',
-'881,,,,881,881,,,,22,22,22,881,22,,881,,22,22,,881,881,22,,22,22,22',
-'22,22,22,22,,,,,,22,22,22,22,22,22,22,,,22,,,,,,,22,,,22,22,,22,22,22',
-'22,22,22,22,22,22,,22,22,,22,22,,475,475,475,475,475,475,475,,,475,475',
-',,,,,,475,475,,22,,,22,,,22,,,22,,22,475,22,475,22,475,475,475,475,475',
-'475,475,22,475,,,,22,22,22,22,22,22,,,,22,22,,,,23,23,23,22,23,,22,',
-'23,23,,22,22,23,,23,23,23,23,23,23,23,,,,,,23,23,23,23,23,23,23,,,23',
-',,,,,,23,,,23,23,,23,23,23,23,23,23,23,23,23,,23,23,,23,23,,474,,,,',
-',,,,,,,,,,,,474,474,,23,,,23,,,23,,,23,,23,474,23,474,23,474,474,474',
-'474,,,474,23,474,,,,23,23,23,23,23,23,,,,23,23,,,,24,24,24,23,24,,23',
-',24,24,,23,23,24,,24,24,24,24,24,24,24,,,,,,24,24,24,24,24,24,24,,,24',
-',,,,,,24,,,24,24,,24,24,24,24,24,24,24,24,24,,24,24,,24,24,,473,,,,',
-',,,,,,,,,,,,473,473,,24,,,24,,,24,,,24,,24,473,24,473,24,473,473,473',
-'473,,,473,24,473,,,,24,24,24,24,24,24,,,,24,24,,,,877,877,877,24,877',
-',24,,877,877,,24,24,877,,877,877,877,877,877,877,877,,,,,,877,877,877',
-'877,877,877,877,,,877,,,,,,,877,,,877,877,,877,877,877,877,877,,877',
-'877,877,,877,877,,877,877,,471,,,,,,,,,,,,,,,,,471,471,,877,,,877,,',
-'877,,,877,,,471,,471,877,471,471,471,471,,,471,877,471,,,,877,877,877',
-'877,877,877,,,,877,877,,,,876,876,876,877,876,,877,,876,876,,877,877',
-'876,,876,876,876,876,876,876,876,,,,,,876,876,876,876,876,876,876,,',
-'876,,,,,,,876,,,876,876,,876,876,876,876,876,,876,876,876,,876,876,',
-'876,876,,483,483,483,483,483,483,483,483,,483,483,,,,,,,483,483,,876',
-',,876,,,876,,,876,,,483,,483,876,483,483,483,483,483,483,483,876,483',
-',,,876,876,876,876,876,876,,,,876,876,,,,27,27,27,876,27,,876,,27,27',
-',876,876,27,,27,27,27,27,27,27,27,,,,,,27,27,27,27,27,27,27,,,27,,,',
-',,,27,,,27,27,,27,27,27,27,27,27,27,27,27,,27,27,,27,27,,482,482,482',
-'482,482,482,482,,,482,482,,,,,,,482,482,,27,,,27,27,,27,,,27,,27,482',
-'27,482,27,482,482,482,482,482,482,482,27,482,,,,27,27,27,27,27,27,,',
-',27,27,,,,,,,27,,,27,,,,,27,27,30,30,30,30,30,,,,30,30,,,,30,,30,30',
-'30,30,30,30,30,,,,,,30,30,30,30,30,30,30,,,30,,,,,,30,30,,30,30,30,',
-'30,30,30,30,30,,30,30,30,,30,30,,30,30,,472,,,,,,,,,,,,,,,,,472,472',
-',30,,,30,,,30,,,30,,30,472,,472,30,472,472,472,472,,,472,30,472,,,,30',
-'30,30,30,30,30,,,,30,30,,,,31,31,31,30,31,,30,,31,31,,30,30,31,,31,31',
-'31,31,31,31,31,,,,,,31,31,31,31,31,31,31,,,31,,,,,,,31,,,31,31,,31,31',
-'31,31,31,,31,31,31,,31,31,322,,322,322,322,,322,,,,,,,,,,,,,,,,,,31',
-',,31,,,31,,,31,,31,,,,322,,322,,,,,,322,322,322,322,,31,31,31,31,31',
-'31,,,,31,31,,,,32,32,32,31,32,,31,,32,32,,31,31,32,,32,32,32,32,32,32',
-'32,,,,,,32,32,32,32,32,32,32,,,32,,,,,,,32,,,32,32,,32,32,32,32,32,',
-'32,32,32,,32,32,749,,749,749,749,749,749,,,,,,,,,,749,,,,,,,,32,,,32',
-',,32,,,32,,,,,,749,,,,,,,,749,749,749,749,,32,32,32,32,32,32,,,,32,32',
-',,,32,,,32,,,32,,,,,32,32,862,862,862,,862,,,749,862,862,,,,862,,862',
-'862,862,862,862,862,862,,,,,,862,862,862,862,862,862,862,,,862,,,,,',
-',862,,,862,862,,862,862,862,862,862,,862,862,862,,862,862,,862,862,',
-'470,470,470,470,470,470,470,,,470,470,,,,,,,470,470,,862,,,862,,,862',
-',,862,,,470,,470,862,470,470,470,470,470,470,470,862,470,,,,862,862',
-'862,862,862,862,,,,862,862,,,,,,,862,,,862,,,,,862,862,835,835,835,835',
-'835,,,,835,835,,,,835,,835,835,835,835,835,835,835,,,,,,835,835,835',
-'835,835,835,835,,,835,,,,,,835,835,,835,835,835,,835,835,835,835,835',
-',835,835,835,,835,835,,835,835,,460,460,460,460,460,460,460,460,460',
-'460,460,,,460,460,,,460,460,,835,,,835,,,835,,,835,,835,460,,460,835',
-'460,460,460,460,460,460,460,835,460,,,,835,835,835,835,835,835,,,,835',
-'835,,,,,,,835,,,835,,,,,835,835,834,834,834,834,834,,,,834,834,,,,834',
-',834,834,834,834,834,834,834,,,,,,834,834,834,834,834,834,834,,,834',
-',,,,,834,834,,834,834,834,,834,834,834,834,834,,834,834,834,,834,834',
-',834,834,,459,459,459,459,459,459,459,459,459,459,459,,,459,459,,,459',
-'459,,834,,,834,,,834,,,834,,834,459,,459,834,459,459,459,459,459,459',
-'459,834,459,,,,834,834,834,834,834,834,,,,834,834,,,,832,832,832,834',
-'832,,834,,832,832,,834,834,832,,832,832,832,832,832,832,832,,,,,,832',
-'832,832,832,832,832,832,,,832,,,,,,,832,,,832,832,,832,832,832,832,832',
-',832,832,832,,832,832,,832,832,,468,,,,,,,,,,,,,,,,,468,468,,832,,,832',
-',,832,,,832,,,468,,468,832,468,468,468,468,,,,832,,,,,832,832,832,832',
-'832,832,,,,832,832,,,,38,38,38,832,38,,832,,38,38,,832,832,38,,38,38',
-'38,38,38,38,38,,,,,,38,38,38,38,38,38,38,,,38,,,,,,,38,,,38,38,,38,38',
-'38,38,38,,38,38,38,,38,38,,38,38,,467,,,,,,,,,,,,,,,,,467,467,,38,,',
-'38,,,38,,,38,,,467,,467,38,467,467,467,467,,,,38,,,,,38,38,38,38,38',
-'38,,,,38,38,,,,39,39,39,38,39,,38,,39,39,,38,38,39,,39,39,39,39,39,39',
-'39,,,,,,39,39,39,39,39,39,39,,,39,,,,,,,39,,,39,39,,39,39,39,39,39,',
-'39,39,39,,39,39,,39,39,,,,,,,,,,,,,,,,,,,,,,39,,,39,,,39,,,39,,,,,,39',
-',,,,,,,39,,,,,39,39,39,39,39,39,,,,39,39,,,,40,40,40,39,40,,39,,40,40',
-',39,39,40,,40,40,40,40,40,40,40,,,,,,40,40,40,40,40,40,40,,,40,,,,,',
-',40,,,40,40,,40,40,40,40,40,,40,40,40,,40,40,,40,40,,,,,,,,,,,,,,,,',
-',,,,,40,,,40,,,40,,,40,,,,,,40,,,,,,,,40,,,,,40,40,40,40,40,40,,,,40',
-'40,,,,,,,40,,,40,,,,,40,40,813,813,813,813,813,,,,813,813,,,,813,,813',
-'813,813,813,813,813,813,,,,,,813,813,813,813,813,813,813,,,813,,,,,',
-'813,813,,813,813,813,,813,813,813,813,813,,813,813,813,,813,813,,813',
-'813,,,,,,,,,,,,,,,,,,,,,,813,,,813,,,813,,,813,,813,,,,813,,,,,,,,813',
-',,,,813,813,813,813,813,813,,,,813,813,,,,802,802,802,813,802,,813,',
-'802,802,,813,813,802,,802,802,802,802,802,802,802,,,,,,802,802,802,802',
-'802,802,802,,,802,,,,,,,802,,,802,802,,802,802,802,802,802,,802,802',
-'802,,802,802,,802,802,,,,,,,,,,,,,,,,,,,,,,802,,,802,,,802,,,802,,802',
-',,,802,,,,,,,,802,,,,,802,802,802,802,802,802,,,,802,802,,,,52,52,52',
-'802,52,,802,,52,52,,802,802,52,,52,52,52,52,52,52,52,,,,,,52,52,52,52',
-'52,52,52,,,52,,,,,,,52,,,52,52,,52,52,52,52,52,,52,52,52,,52,52,,52',
-'52,,,,,,,,,,,,,,,,,,,,,,52,,,52,,,52,,,52,,,,,,52,,,,,,,,52,,,,,52,52',
-'52,52,52,52,,,,52,52,,,,53,53,53,52,53,,52,,53,53,,52,52,53,,53,53,53',
-'53,53,53,53,,,,,,53,53,53,53,53,53,53,,,53,,,,,,,53,,,53,53,,53,53,53',
-'53,53,53,53,53,53,,53,53,,53,53,,,,,,,,,,,,,,,,,,,,,,53,,,53,,,53,,',
-'53,,53,,,,53,,,,,,,,53,,,,,53,53,53,53,53,53,,,,53,53,,,,54,54,54,53',
-'54,,53,,54,54,,53,53,54,,54,54,54,54,54,54,54,,,,,,54,54,54,54,54,54',
-'54,,,54,,,,,,,54,,,54,54,,54,54,54,54,54,54,54,54,54,,54,54,,54,54,',
-',,,,,,,,,,,,,,,,,,,,54,,,54,,,54,,,54,,,,,,54,,,,,,,,54,,,,,54,54,54',
-'54,54,54,,,,54,54,,,,790,790,790,54,790,,54,,790,790,,54,54,790,,790',
-'790,790,790,790,790,790,,,,,,790,790,790,790,790,790,790,,,790,,,,,',
-',790,,,790,790,,790,790,790,790,790,,790,790,790,,790,790,,790,790,',
-',,,,,,,,,,,,,,,,,,,,790,,,790,,,790,,,790,,,,,,790,,,,,,,,790,,,,,790',
-'790,790,790,790,790,,,,790,790,,,,789,789,789,790,789,,790,,789,789',
-',790,790,789,,789,789,789,789,789,789,789,,,,,,789,789,789,789,789,789',
-'789,,,789,,,,,,,789,,,789,789,,789,789,789,789,789,,789,789,789,,789',
-'789,,789,789,,,,,,,,,,,,,,,,,,,,,,789,,,789,,,789,,,789,,,,,,789,,,',
-',,,,789,,,,,789,789,789,789,789,789,,,,789,789,,,,57,57,57,789,57,,789',
-',57,57,,789,789,57,,57,57,57,57,57,57,57,,,,,,57,57,57,57,57,57,57,',
-',57,,,,,,,57,,,57,57,,57,57,57,57,57,,57,57,57,,57,57,,57,57,,,,,,,',
-',,,,,,,,,,,,,,57,,,57,,,57,,,57,,,,,,57,,,,,,,,57,,,,,57,57,57,57,57',
-'57,,,,57,57,,,,381,381,381,57,381,,57,,381,381,,57,57,381,,381,381,381',
-'381,381,381,381,,,,,,381,381,381,381,381,381,381,,,381,,,,,,,381,,,381',
-'381,,381,381,381,381,381,,381,381,381,,381,381,,381,381,,,,,,,,,,,,',
-',,,,,,,,,381,,,381,,,381,,,381,,,,,,381,,,,,,,,381,,,,,381,381,381,381',
-'381,381,,,,381,381,,,,61,61,61,381,61,,381,,61,61,,381,381,61,,61,61',
-'61,61,61,61,61,,,,,,61,61,61,61,61,61,61,,,61,,,,,,,61,,,61,61,,61,61',
-'61,61,61,,61,61,61,,61,61,,61,61,,,,,,,,,,,,,,,,,,,,,,61,,,61,,,61,',
-',61,,,,,,61,,,,,,,,61,,,,,61,61,61,61,61,61,,,,61,61,61,,,,,61,61,,',
-'61,,,,,61,61,62,62,62,,62,,,,62,62,,,,62,,62,62,62,62,62,62,62,,,,,',
-'62,62,62,62,62,62,62,,,62,,,,,,,62,,,62,62,,62,62,62,62,62,,62,62,62',
-',62,62,56,,56,56,56,,56,,,,,,,,,,,,,,,,,,62,,,62,,,62,,,62,,62,,,,56',
-'56,,,,,,,56,56,56,56,,62,62,62,62,62,62,,,,62,62,,,,63,63,63,62,63,',
-'62,,63,63,,62,62,63,,63,63,63,63,63,63,63,,,,,,63,63,63,63,63,63,63',
-',,63,,,,,,,63,,,63,63,,63,63,63,63,63,,63,63,63,,63,63,559,,559,559',
-'559,,559,,,,,,,,,,,,,,,63,,,63,,,63,,,63,,,63,,,,,,559,,,,,,,,559,559',
-'559,559,,63,63,63,63,63,63,,,,63,63,,,,788,788,788,63,788,,63,,788,788',
-',63,63,788,,788,788,788,788,788,788,788,,,,,,788,788,788,788,788,788',
-'788,,,788,,,,,,,788,,,788,788,,788,788,788,788,788,,788,788,788,,788',
-'788,,788,788,,,,,,,,,,,,,,,,,,,,,,788,,,788,,,788,,,788,,,,,,788,,,',
-',,,,788,,,,,788,788,788,788,788,788,,,,788,788,,,,777,777,777,788,777',
-',788,,777,777,,788,788,777,,777,777,777,777,777,777,777,,,,,,777,777',
-'777,777,777,777,777,,,777,,,,,,,777,,,777,777,,777,777,777,777,777,',
-'777,777,777,,777,777,,777,777,,,,,,,,,,,,,,,,,,,,,,777,,,777,,,777,',
-',777,,,,,,777,,,,,,,,777,,,,,777,777,777,777,777,777,,,,777,777,,,,776',
-'776,776,777,776,,777,,776,776,,777,777,776,,776,776,776,776,776,776',
-'776,,,,,,776,776,776,776,776,776,776,,,776,,,,,,,776,,,776,776,,776',
-'776,776,776,776,,776,776,776,,776,776,,776,776,,,,,,,,,,,,,,,,,,,,,',
-'776,,,776,,,776,,,776,,,,,,776,,,,,,,,776,,,,,776,776,776,776,776,776',
-',,,776,776,,,,775,775,775,776,775,,776,,775,775,,776,776,775,,775,775',
-'775,775,775,775,775,,,,,,775,775,775,775,775,775,775,,,775,,,,,,,775',
-',,775,775,,775,775,775,775,775,,775,775,775,,775,775,,775,775,,,,,,',
-',,,,,,,,,,,,,,,775,,,775,,,775,,,775,,,,,,775,,,,,,,,775,,,,,775,775',
-'775,775,775,775,,,,775,775,,,,,,,775,,,775,,,,,775,775,769,769,769,769',
-'769,,,,769,769,,,,769,,769,769,769,769,769,769,769,,,,,,769,769,769',
-'769,769,769,769,,,769,,,,,,769,769,,769,769,769,,769,769,769,769,769',
-',769,769,769,,769,769,,769,769,,,,,,,,,,,,,,,,,,,,,,769,,,769,,,769',
-',,769,,769,,,,769,,,,,,,,769,,,,,769,769,769,769,769,769,,,,769,769',
-',,,755,755,755,769,755,,769,,755,755,,769,769,755,,755,755,755,755,755',
-'755,755,,,,,,755,755,755,755,755,755,755,,,755,,,,,,,755,,,755,755,',
-'755,755,755,755,755,,755,755,755,,755,755,,755,755,,,,,,,,,,,,,,,,,',
-',,,,755,,,755,,,755,,,755,,,,,,755,,,,,,,,755,,,,,755,755,755,755,755',
-'755,,,,755,755,,,,84,84,84,755,84,,755,,84,84,,755,755,84,,84,84,84',
-'84,84,84,84,,84,,,,84,84,84,84,84,84,84,,,84,,,,,,,84,,,84,84,,84,84',
-'84,84,84,84,84,84,84,,84,84,,84,84,,,,,,,,,,,,,,,,,,,,,,84,,,84,84,',
-'84,,,84,,84,,84,,84,,,,,,,,84,,84,,,84,84,84,84,84,84,,,,84,84,,,,87',
-'87,87,84,87,,84,,87,87,,84,84,87,,87,87,87,87,87,87,87,,87,,,,87,87',
-'87,87,87,87,87,,,87,,,,,,,87,,,87,87,,87,87,87,87,87,87,87,87,87,,87',
-'87,,87,87,,,,,,,,,,,,,,,,,,,,,,87,,,87,87,,87,,,87,,87,,87,,87,,,,,',
-',,87,,87,,,87,87,87,87,87,87,,,,87,87,,,,,,,87,,,87,,,,,87,87,748,748',
-'748,748,748,,,,748,748,,,,748,,748,748,748,748,748,748,748,,,,,,748',
-'748,748,748,748,748,748,,,748,,,,,,748,748,,748,748,748,,748,748,748',
-'748,748,,748,748,748,,748,748,,748,748,,,,,,,,,,,,,,,,,,,,,,748,,,748',
-',,748,,,748,,748,,,,748,,,,,,,,748,,,,,748,748,748,748,748,748,,,,748',
-'748,,,,,,,748,,,748,,,,,748,748,99,99,99,99,99,,,,99,99,,,,99,,99,99',
-'99,99,99,99,99,,,,,,99,99,99,99,99,99,99,,,99,,,,,,99,99,99,99,99,99',
-',99,99,99,99,99,,99,99,99,,99,99,,99,99,,,,,,,,,,,,,,,,,,,,,,99,,,99',
-',,99,,,99,,99,,,,99,,,,,,,,99,,,,,99,99,99,99,99,99,,,,99,99,,,,,,99',
-'99,,,99,,,,,99,99,103,103,103,,103,,,,103,103,,,,103,,103,103,103,103',
-'103,103,103,,,,,,103,103,103,103,103,103,103,,,103,,,,,,,103,,,103,103',
-',103,103,103,103,103,,103,103,103,,103,103,,103,103,,,,,,,,,,,,,,,,',
-',,,,,103,,,103,,,103,,,103,,,,,,103,,,,,,,,103,,,,,103,103,103,103,103',
-'103,,,,103,103,,,,104,104,104,103,104,,103,,104,104,,103,103,104,,104',
-'104,104,104,104,104,104,,,,,,104,104,104,104,104,104,104,,,104,,,,,',
-',104,,,104,104,,104,104,104,104,104,,104,104,104,,104,104,,104,104,',
-',,,,,,,,,,,,,,,,,,,,104,,,104,,,104,,,104,,,,,,104,,,,,,,,104,,,,,104',
-'104,104,104,104,104,,,,104,104,,,,105,105,105,104,105,,104,,105,105',
-',104,104,105,,105,105,105,105,105,105,105,,,,,,105,105,105,105,105,105',
-'105,,,105,,,,,,,105,,,105,105,,105,105,105,105,105,,105,105,105,,105',
-'105,,105,105,,,,,,,,,,,,,,,,,,,,,,105,,,105,,,105,,,105,,,,,,105,,,',
-',,,,105,,,,,105,105,105,105,105,105,,,,105,105,,,,106,106,106,105,106',
-',105,,106,106,,105,105,106,,106,106,106,106,106,106,106,,,,,,106,106',
-'106,106,106,106,106,,,106,,,,,,,106,,,106,106,,106,106,106,106,106,',
-'106,106,106,,106,106,,106,106,,,,,,,,,,,,,,,,,,,,,,106,,,106,,,106,',
-',106,,,,,,106,,,,,,,,106,,,,,106,106,106,106,106,106,,,,106,106,,,,',
-',,106,,,106,,,,,106,106,107,107,107,107,107,,,,107,107,,,,107,,107,107',
-'107,107,107,107,107,,,,,,107,107,107,107,107,107,107,,,107,,,,,,107',
-'107,,107,107,107,,107,107,107,107,107,,107,107,107,,107,107,,107,107',
-',,,,,,,,,,,,,,,,,,,,,107,,,107,,,107,,,107,,107,,,,107,,,,,,,,107,,',
-',,107,107,107,107,107,107,,,,107,107,,,,,,,107,,,107,,,,,107,107,108',
-'108,108,108,108,,,,108,108,,,,108,,108,108,108,108,108,108,108,,,,,',
-'108,108,108,108,108,108,108,,,108,,,,,,108,108,108,108,108,108,,108',
-'108,108,108,108,,108,108,108,,108,108,,108,108,,,,,,,,,,,,,,,,,,,,,',
-'108,,,108,,,108,,,108,,108,,,,108,,,,,,,,108,,,,,108,108,108,108,108',
-'108,,,,108,108,,,,,,,108,,,108,,,,,108,108,747,747,747,747,747,,,,747',
-'747,,,,747,,747,747,747,747,747,747,747,,,,,,747,747,747,747,747,747',
-'747,,,747,,,,,,747,747,,747,747,747,,747,747,747,747,747,,747,747,747',
-',747,747,,747,747,,,,,,,,,,,,,,,,,,,,,,747,,,747,,,747,,,747,,747,,',
-',747,,,,,,,,747,,,,,747,747,747,747,747,747,,,,747,747,,,,,,,747,,,747',
-',,,,747,747,743,743,743,743,743,,,,743,743,,,,743,,743,743,743,743,743',
-'743,743,,,,,,743,743,743,743,743,743,743,,,743,,,,,,743,743,,743,743',
-'743,,743,743,743,743,743,,743,743,743,,743,743,,743,743,,,,,,,,,,,,',
-',,,,,,,,,743,,,743,,,743,,,743,,743,,,,743,,,,,,,,743,,,,,743,743,743',
-'743,743,743,,,,743,743,,,,738,738,738,743,738,,743,,738,738,,743,743',
-'738,,738,738,738,738,738,738,738,,,,,,738,738,738,738,738,738,738,,',
-'738,,,,,,,738,,,738,738,,738,738,738,738,738,,738,738,738,,738,738,',
-'738,738,,,,,,,,,,,,,,,,,,,,,,738,,,738,,,738,,,738,,,,,,738,,,,,,,,738',
-',,,,738,738,738,738,738,738,,,,738,738,,,,,,,738,,,738,,,,,738,738,195',
-'195,195,195,195,,,,195,195,,,,195,,195,195,195,195,195,195,195,,,,,',
-'195,195,195,195,195,195,195,,,195,,,,,,195,195,,195,195,195,,195,195',
-'195,195,195,,195,195,195,,195,195,,195,195,,,,,,,,,,,,,,,,,,,,,,195',
-',,195,,,195,,,195,,195,,,,195,,,,,,,,195,,,,,195,195,195,195,195,195',
-',,,195,195,,,,196,196,196,195,196,,195,,196,196,,195,195,196,,196,196',
-'196,196,196,196,196,,,,,,196,196,196,196,196,196,196,,,196,,,,,,,196',
-',,196,196,,196,196,196,196,196,,196,196,196,,196,196,,196,196,,,,,,',
-',,,,,,,,,,,,,,,196,,,196,,,196,,,196,,196,,,,196,,,,,,,,196,,,,,196',
-'196,196,196,196,196,,,,196,196,,,,197,197,197,196,197,,196,,197,197',
-',196,196,197,,197,197,197,197,197,197,197,,,,,,197,197,197,197,197,197',
-'197,,,197,,,,,,,197,,,197,197,,197,197,197,197,197,,197,197,197,,197',
-'197,,197,197,,,,,,,,,,,,,,,,,,,,,,197,,,197,,,197,,,197,,197,,,,197',
-',,,,,,,197,,,,,197,197,197,197,197,197,,,,197,197,,,,198,198,198,197',
-'198,,197,,198,198,,197,197,198,,198,198,198,198,198,198,198,,,,,,198',
-'198,198,198,198,198,198,,,198,,,,,,,198,,,198,198,,198,198,198,198,198',
-',198,198,198,,198,198,,198,198,,,,,,,,,,,,,,,,,,,,,,198,,,198,,,198',
-',,198,,,,,,198,,,,,,,,198,,,,,198,198,198,198,198,198,,,,198,198,,,',
-'199,199,199,198,199,,198,,199,199,,198,198,199,,199,199,199,199,199',
-'199,199,,,,,,199,199,199,199,199,199,199,,,199,,,,,,,199,,,199,199,',
-'199,199,199,199,199,199,199,199,199,,199,199,,199,199,,,,,,,,,,,,,,',
-',,,,,,,199,,,199,,,199,,,199,,199,,,,199,,,,,,,,199,,,,,199,199,199',
-'199,199,199,,,,199,199,,,,200,200,200,199,200,,199,,200,200,,199,199',
-'200,,200,200,200,200,200,200,200,,,,,,200,200,200,200,200,200,200,,',
-'200,,,,,,,200,,,200,200,,200,200,200,200,200,200,200,200,200,,200,200',
-',200,200,,,,,,,,,,,,,,,,,,,,,,200,,,200,,,200,,,200,,200,,,,200,,,,',
-',,,200,,,,,200,200,200,200,200,200,,,,200,200,,,,731,731,731,200,731',
-',200,,731,731,,200,200,731,,731,731,731,731,731,731,731,,,,,,731,731',
-'731,731,731,731,731,,,731,,,,,,,731,,,731,731,,731,731,731,731,731,',
-'731,731,731,,731,731,,731,731,,,,,,,,,,,,,,,,,,,,,,731,,,731,,,731,',
-',731,,731,,,,731,,,,,,,,731,,,,,731,731,731,731,731,731,,,,731,731,',
-',,700,700,700,731,700,,731,,700,700,,731,731,700,,700,700,700,700,700',
-'700,700,,,,,,700,700,700,700,700,700,700,,,700,,,,,,,700,,,700,700,',
-'700,700,700,700,700,,700,700,700,,700,700,,700,700,,,,,,,,,,,,,,,,,',
-',,,,700,,,700,,,700,,,700,,700,,,,700,,,,,,,,700,,,,,700,700,700,700',
-'700,700,,,,700,700,,,,694,694,694,700,694,,700,,694,694,,700,700,694',
-',694,694,694,694,694,694,694,,,,,,694,694,694,694,694,694,694,,,694',
-',,,,,,694,,,694,694,,694,694,694,694,694,,694,694,694,,694,694,,,,,',
-',,,,,,,,,,,,,,,,,,,694,,,694,,,694,,,694,,,,,,,,,,,,,,,,,,,694,694,694',
-'694,694,694,,,,694,694,,,,204,204,204,694,204,,694,,204,204,,694,694',
-'204,,204,204,204,204,204,204,204,,,,,,204,204,204,204,204,204,204,,',
-'204,,,,,,,204,,,204,204,,204,204,204,204,204,,204,204,204,,204,204,',
-'204,204,,,,,,,,,,,,,,,,,,,,,,204,,,204,,,204,,,204,,,,,,204,,,,,,,,204',
-',,,,204,204,204,204,204,204,,,,204,204,,,,205,205,205,204,205,,204,',
-'205,205,,204,204,205,,205,205,205,205,205,205,205,,,,,,205,205,205,205',
-'205,205,205,,,205,,,,,,,205,,,205,205,,205,205,205,205,205,,205,205',
-'205,,205,205,,205,205,,,,,,,,,,,,,,,,,,,,,,205,,,205,,,205,,,205,,,',
-',,205,,,,,,,,205,,,,,205,205,205,205,205,205,,,,205,205,,,,206,206,206',
-'205,206,,205,,206,206,,205,205,206,,206,206,206,206,206,206,206,,,,',
-',206,206,206,206,206,206,206,,,206,,,,,,,206,,,206,206,,206,206,206',
-'206,206,,206,206,206,,206,206,,206,206,,,,,,,,,,,,,,,,,,,,,,206,,,206',
-',,206,,,206,,,,,,206,,,,,,,,206,,,,,206,206,206,206,206,206,,,,206,206',
-',,,682,682,682,206,682,,206,,682,682,,206,206,682,,682,682,682,682,682',
-'682,682,,,,,,682,682,682,682,682,682,682,,,682,,,,,,,682,,,682,682,',
-'682,682,682,682,682,,682,682,682,,682,682,600,,600,600,600,600,600,',
-',,,,,,,,600,,,,,,,,682,,,682,,,682,,,682,,,,,,600,600,,,,,,,600,600',
-'600,600,,682,682,682,682,682,682,,,,682,682,,,,,,,682,,,682,,,,,682',
-'682,678,678,678,678,678,,,600,678,678,,,,678,,678,678,678,678,678,678',
-'678,,,,,,678,678,678,678,678,678,678,,,678,,,,,,678,678,,678,678,678',
-',678,678,678,678,678,,678,678,678,,678,678,,678,678,,,,,,,,,,,,,,,,',
-',,,,,678,,,678,,,678,,,678,,678,,,,678,,,,,,,,678,,,,,678,678,678,678',
-'678,678,,,,678,678,,,,,,,678,,,678,,,,,678,678,677,677,677,677,677,',
-',,677,677,,,,677,,677,677,677,677,677,677,677,,,,,,677,677,677,677,677',
-'677,677,,,677,,,,,,677,677,,677,677,677,,677,677,677,677,677,,677,677',
-'677,,677,677,,677,677,,,,,,,,,,,,,,,,,,,,,,677,,,677,,,677,,,677,,677',
-',,,677,,,,,,,,677,,,,,677,677,677,677,677,677,,,,677,677,,,,671,671',
-'671,677,671,,677,,671,671,,677,677,671,,671,671,671,671,671,671,671',
-',,,,,671,671,671,671,671,671,671,,,671,,,,,,,671,,,671,671,,671,671',
-'671,671,671,671,671,671,671,,671,671,,671,671,,,,,,,,,,,,,,,,,,,,,,671',
-',,671,,,671,,,671,,,,671,,671,,,,,,,,671,,,,,671,671,671,671,671,671',
-',,,671,671,,,,670,670,670,671,670,,671,,670,670,,671,671,670,,670,670',
-'670,670,670,670,670,,,,,,670,670,670,670,670,670,670,,,670,,,,,,,670',
-',,670,670,,670,670,670,670,670,670,670,670,670,,670,670,,670,670,,,',
-',,,,,,,,,,,,,,,,,,670,,,670,,,670,,,670,,670,,670,,670,,,,,,,,670,,',
-',,670,670,670,670,670,670,,,,670,670,,,,,,,670,,,670,,,,,670,670,667',
-'667,667,667,667,,,,667,667,,,,667,,667,667,667,667,667,667,667,,,,,',
-'667,667,667,667,667,667,667,,,667,,,,,,667,667,,667,667,667,,667,667',
-'667,667,667,,667,667,667,,667,667,,667,667,,,,,,,,,,,,,,,,,,,,,,667',
-',,667,,,667,,,667,,667,,,,667,,,,,,,,667,,,,,667,667,667,667,667,667',
-',,,667,667,,,,,,,667,,,667,,,,,667,667,214,214,214,214,214,,,,214,214',
-',,,214,,214,214,214,214,214,214,214,,,,,,214,214,214,214,214,214,214',
-',,214,,,,,,214,214,,214,214,214,,214,214,214,214,214,,214,214,214,,214',
-'214,,214,214,,,,,,,,,,,,,,,,,,,,,,214,,,214,,,214,,,214,,214,,,,214',
-',,,,,,,214,,,,,214,214,214,214,214,214,,,,214,214,,,,215,215,215,214',
-'215,,214,,215,215,,214,214,215,,215,215,215,215,215,215,215,,,,,,215',
-'215,215,215,215,215,215,,,215,,,,,,,215,,,215,215,,215,215,215,215,215',
-',215,215,215,,215,215,,215,215,,,,,,,,,,,,,,,,,,,,,,215,,,215,,215,215',
-',,215,,,,,,215,,,,,,,,215,,,,,215,215,215,215,215,215,,,,215,215,,,',
-'218,218,218,215,218,,215,,218,218,,215,215,218,,218,218,218,218,218',
-'218,218,,,,,,218,218,218,218,218,218,218,,,218,,,,,,,218,,,218,218,',
-'218,218,218,218,218,,218,218,218,,218,218,,218,218,,,,,,,,,,,,,,,,,',
-',,,,218,,,218,,,218,,,218,,,,,,218,,,,,,,,218,,,,,218,218,218,218,218',
-'218,,,,218,218,,,,658,658,658,218,658,,218,,658,658,,218,218,658,,658',
-'658,658,658,658,658,658,,,,,,658,658,658,658,658,658,658,,,658,,,,,',
-',658,,,658,658,,658,658,658,658,658,,658,658,658,,658,658,,658,658,',
-',,,,,,,,,,,,,,,,,,,,658,,,658,,,658,,,658,,,,,,658,,,,,,,,658,,,,,658',
-'658,658,658,658,658,,,,658,658,,,,220,220,220,658,220,,658,,220,220',
-',658,658,220,,220,220,220,220,220,220,220,,,,,,220,220,220,220,220,220',
-'220,,,220,,,,,,,220,,,220,220,,220,220,220,220,220,,220,220,220,,220',
-'220,,220,220,,,,,,,,,,,,,,,,,,,,,,220,,,220,,,220,,,220,,,,,,220,,,',
-',,,,220,,,,,220,220,220,220,220,220,,,,220,220,,,,221,221,221,220,221',
-',220,,221,221,,220,220,221,,221,221,221,221,221,221,221,,,,,,221,221',
-'221,221,221,221,221,,,221,,,,,,,221,,,221,221,,221,221,221,221,221,',
-'221,221,221,,221,221,,221,221,,,,,,,,,,,,,,,,,,,,,,221,,,221,,,221,',
-',221,,,,,,221,,,,,,,,221,,,,,221,221,221,221,221,221,,,,221,221,,,,222',
-'222,222,221,222,,221,,222,222,,221,221,222,,222,222,222,222,222,222',
-'222,,,,,,222,222,222,222,222,222,222,,,222,,,,,,,222,,,222,222,,222',
-'222,222,222,222,,222,222,222,,222,222,,222,222,,,,,,,,,,,,,,,,,,,,,',
-'222,,,222,,,222,,,222,,,,,,222,,,,,,,,222,,,,,222,222,222,222,222,222',
-',,,222,222,,,,223,223,223,222,223,,222,,223,223,,222,222,223,,223,223',
-'223,223,223,223,223,,,,,,223,223,223,223,223,223,223,,,223,,,,,,,223',
-',,223,223,,223,223,223,223,223,,223,223,223,,223,223,,223,223,,,,,,',
-',,,,,,,,,,,,,,,223,,,223,,,223,,,223,,,,,,223,,,,,,,,223,,,,,223,223',
-'223,223,223,223,,,,223,223,,,,224,224,224,223,224,,223,,224,224,,223',
-'223,224,,224,224,224,224,224,224,224,,,,,,224,224,224,224,224,224,224',
-',,224,,,,,,,224,,,224,224,,224,224,224,224,224,,224,224,224,,224,224',
-',224,224,,,,,,,,,,,,,,,,,,,,,,224,,,224,,,224,,,224,,,,,,224,,,,,,,',
-'224,,,,,224,224,224,224,224,224,,,,224,224,,,,225,225,225,224,225,,224',
-',225,225,,224,224,225,,225,225,225,225,225,225,225,,,,,,225,225,225',
-'225,225,225,225,,,225,,,,,,,225,,,225,225,,225,225,225,225,225,,225',
-'225,225,,225,225,,225,225,,,,,,,,,,,,,,,,,,,,,,225,,,225,,,225,,,225',
-',,,,,225,,,,,,,,225,,,,,225,225,225,225,225,225,,,,225,225,,,,226,226',
-'226,225,226,,225,,226,226,,225,225,226,,226,226,226,226,226,226,226',
-',,,,,226,226,226,226,226,226,226,,,226,,,,,,,226,,,226,226,,226,226',
-'226,226,226,,226,226,226,,226,226,,226,226,,,,,,,,,,,,,,,,,,,,,,226',
-',,226,,,226,,,226,,,,,,226,,,,,,,,226,,,,,226,226,226,226,226,226,,',
-',226,226,,,,227,227,227,226,227,,226,,227,227,,226,226,227,,227,227',
-'227,227,227,227,227,,,,,,227,227,227,227,227,227,227,,,227,,,,,,,227',
-',,227,227,,227,227,227,227,227,,227,227,227,,227,227,,227,227,,,,,,',
-',,,,,,,,,,,,,,,227,,,227,,,227,,,227,,,,,,227,,,,,,,,227,,,,,227,227',
-'227,227,227,227,,,,227,227,,,,228,228,228,227,228,,227,,228,228,,227',
-'227,228,,228,228,228,228,228,228,228,,,,,,228,228,228,228,228,228,228',
-',,228,,,,,,,228,,,228,228,,228,228,228,228,228,,228,228,228,,228,228',
-',228,228,,,,,,,,,,,,,,,,,,,,,,228,,,228,,,228,,,228,,,,,,228,,,,,,,',
-'228,,,,,228,228,228,228,228,228,,,,228,228,,,,229,229,229,228,229,,228',
-',229,229,,228,228,229,,229,229,229,229,229,229,229,,,,,,229,229,229',
-'229,229,229,229,,,229,,,,,,,229,,,229,229,,229,229,229,229,229,,229',
-'229,229,,229,229,,229,229,,,,,,,,,,,,,,,,,,,,,,229,,,229,,,229,,,229',
-',,,,,229,,,,,,,,229,,,,,229,229,229,229,229,229,,,,229,229,,,,230,230',
-'230,229,230,,229,,230,230,,229,229,230,,230,230,230,230,230,230,230',
-',,,,,230,230,230,230,230,230,230,,,230,,,,,,,230,,,230,230,,230,230',
-'230,230,230,,230,230,230,,230,230,,230,230,,,,,,,,,,,,,,,,,,,,,,230',
-',,230,,,230,,,230,,,,,,230,,,,,,,,230,,,,,230,230,230,230,230,230,,',
-',230,230,,,,231,231,231,230,231,,230,,231,231,,230,230,231,,231,231',
-'231,231,231,231,231,,,,,,231,231,231,231,231,231,231,,,231,,,,,,,231',
-',,231,231,,231,231,231,231,231,,231,231,231,,231,231,,231,231,,,,,,',
-',,,,,,,,,,,,,,,231,,,231,,,231,,,231,,,,,,231,,,,,,,,231,,,,,231,231',
-'231,231,231,231,,,,231,231,,,,232,232,232,231,232,,231,,232,232,,231',
-'231,232,,232,232,232,232,232,232,232,,,,,,232,232,232,232,232,232,232',
-',,232,,,,,,,232,,,232,232,,232,232,232,232,232,,232,232,232,,232,232',
-',232,232,,,,,,,,,,,,,,,,,,,,,,232,,,232,,,232,,,232,,,,,,232,,,,,,,',
-'232,,,,,232,232,232,232,232,232,,,,232,232,,,,233,233,233,232,233,,232',
-',233,233,,232,232,233,,233,233,233,233,233,233,233,,,,,,233,233,233',
-'233,233,233,233,,,233,,,,,,,233,,,233,233,,233,233,233,233,233,,233',
-'233,233,,233,233,,233,233,,,,,,,,,,,,,,,,,,,,,,233,,,233,,,233,,,233',
-',,,,,233,,,,,,,,233,,,,,233,233,233,233,233,233,,,,233,233,,,,234,234',
-'234,233,234,,233,,234,234,,233,233,234,,234,234,234,234,234,234,234',
-',,,,,234,234,234,234,234,234,234,,,234,,,,,,,234,,,234,234,,234,234',
-'234,234,234,,234,234,234,,234,234,,234,234,,,,,,,,,,,,,,,,,,,,,,234',
-',,234,,,234,,,234,,,,,,234,,,,,,,,234,,,,,234,234,234,234,234,234,,',
-',234,234,,,,235,235,235,234,235,,234,,235,235,,234,234,235,,235,235',
-'235,235,235,235,235,,,,,,235,235,235,235,235,235,235,,,235,,,,,,,235',
-',,235,235,,235,235,235,235,235,,235,235,235,,235,235,,235,235,,,,,,',
-',,,,,,,,,,,,,,,235,,,235,,,235,,,235,,,,,,235,,,,,,,,235,,,,,235,235',
-'235,235,235,235,,,,235,235,,,,236,236,236,235,236,,235,,236,236,,235',
-'235,236,,236,236,236,236,236,236,236,,,,,,236,236,236,236,236,236,236',
-',,236,,,,,,,236,,,236,236,,236,236,236,236,236,,236,236,236,,236,236',
-',236,236,,,,,,,,,,,,,,,,,,,,,,236,,,236,,,236,,,236,,,,,,236,,,,,,,',
-'236,,,,,236,236,236,236,236,236,,,,236,236,,,,237,237,237,236,237,,236',
-',237,237,,236,236,237,,237,237,237,237,237,237,237,,,,,,237,237,237',
-'237,237,237,237,,,237,,,,,,,237,,,237,237,,237,237,237,237,237,,237',
-'237,237,,237,237,,237,237,,,,,,,,,,,,,,,,,,,,,,237,,,237,,,237,,,237',
-',,,,,237,,,,,,,,237,,,,,237,237,237,237,237,237,,,,237,237,,,,238,238',
-'238,237,238,,237,,238,238,,237,237,238,,238,238,238,238,238,238,238',
-',,,,,238,238,238,238,238,238,238,,,238,,,,,,,238,,,238,238,,238,238',
-'238,238,238,,238,238,238,,238,238,,238,238,,,,,,,,,,,,,,,,,,,,,,238',
-',,238,,,238,,,238,,,,,,238,,,,,,,,238,,,,,238,238,238,238,238,238,,',
-',238,238,,,,239,239,239,238,239,,238,,239,239,,238,238,239,,239,239',
-'239,239,239,239,239,,,,,,239,239,239,239,239,239,239,,,239,,,,,,,239',
-',,239,239,,239,239,239,239,239,,239,239,239,,239,239,,239,239,,,,,,',
-',,,,,,,,,,,,,,,239,,,239,,,239,,,239,,,,,,239,,,,,,,,239,,,,,239,239',
-'239,239,239,239,,,,239,239,,,,240,240,240,239,240,,239,,240,240,,239',
-'239,240,,240,240,240,240,240,240,240,,,,,,240,240,240,240,240,240,240',
-',,240,,,,,,,240,,,240,240,,240,240,240,240,240,,240,240,240,,240,240',
-',240,240,,,,,,,,,,,,,,,,,,,,,,240,,,240,,,240,,,240,,,,,,240,,,,,,,',
-'240,,,,,240,240,240,240,240,240,,,,240,240,,,,241,241,241,240,241,,240',
-',241,241,,240,240,241,,241,241,241,241,241,241,241,,,,,,241,241,241',
-'241,241,241,241,,,241,,,,,,,241,,,241,241,,241,241,241,241,241,,241',
-'241,241,,241,241,,241,241,,,,,,,,,,,,,,,,,,,,,,241,,,241,,,241,,,241',
-',,,,,241,,,,,,,,241,,,,,241,241,241,241,241,241,,,,241,241,,,,242,242',
-'242,241,242,,241,,242,242,,241,241,242,,242,242,242,242,242,242,242',
-',,,,,242,242,242,242,242,242,242,,,242,,,,,,,242,,,242,242,,242,242',
-'242,242,242,,242,242,242,,242,242,,242,242,,,,,,,,,,,,,,,,,,,,,,242',
-',,242,,,242,,,242,,,,,,242,,,,,,,,242,,,,,242,242,242,242,242,242,,',
-',242,242,,,,243,243,243,242,243,,242,,243,243,,242,242,243,,243,243',
-'243,243,243,243,243,,,,,,243,243,243,243,243,243,243,,,243,,,,,,,243',
-',,243,243,,243,243,243,243,243,,243,243,243,,243,243,,243,243,,,,,,',
-',,,,,,,,,,,,,,,243,,,243,,,243,,,243,,,,,,243,,,,,,,,243,,,,,243,243',
-'243,243,243,243,,,,243,243,,,,244,244,244,243,244,,243,,244,244,,243',
-'243,244,,244,244,244,244,244,244,244,,,,,,244,244,244,244,244,244,244',
-',,244,,,,,,,244,,,244,244,,244,244,244,244,244,,244,244,244,,244,244',
-',244,244,,,,,,,,,,,,,,,,,,,,,,244,,,244,,,244,,,244,,,,,,244,,,,,,,',
-'244,,,,,244,244,244,244,244,244,,,,244,244,,,,245,245,245,244,245,,244',
-',245,245,,244,244,245,,245,245,245,245,245,245,245,,,,,,245,245,245',
-'245,245,245,245,,,245,,,,,,,245,,,245,245,,245,245,245,245,245,,245',
-'245,245,,245,245,,245,245,,,,,,,,,,,,,,,,,,,,,,245,,,245,,,245,,,245',
-',,,,,245,,,,,,,,245,,,,,245,245,245,245,245,245,,,,245,245,,,,,,,245',
-',,245,,,,,245,245,654,654,654,654,654,,,,654,654,,,,654,,654,654,654',
-'654,654,654,654,,,,,,654,654,654,654,654,654,654,,,654,,,,,,654,654',
-',654,654,654,,654,654,654,654,654,,654,654,654,,654,654,,654,654,,,',
-',,,,,,,,,,,,,,,,,,654,,,654,,,654,,,654,,654,,,,654,,,,,,,,654,,,,,654',
-'654,654,654,654,654,,,,654,654,,,,650,650,650,654,650,,654,,650,650',
-',654,654,650,,650,650,650,650,650,650,650,,,,,,650,650,650,650,650,650',
-'650,,,650,,,,,,,650,,,650,650,,650,650,650,650,650,,650,650,650,,650',
-'650,,650,650,,,,,,,,,,,,,,,,,,,,,,650,,,650,,,650,,,650,,,,,,650,,,',
-',,,,650,,,,,650,650,650,650,650,650,,,,650,650,,,,254,254,254,650,254',
-',650,,254,254,,650,650,254,,254,254,254,254,254,254,254,,,,,,254,254',
-'254,254,254,254,254,,,254,,,,,,,254,,,254,254,,254,254,254,254,254,',
-'254,254,254,,254,254,,254,254,,,,,,,,,,,,,,,,,,,,,,254,,,254,,,254,',
-',254,,,,,,254,,,,,,,,254,,,,,254,254,254,254,254,254,,,,254,254,,,,256',
-'256,256,254,256,,254,,256,256,,254,254,256,,256,256,256,256,256,256',
-'256,,,,,,256,256,256,256,256,256,256,,,256,,,,,,,256,,,256,256,,256',
-'256,256,256,256,,256,256,256,,256,256,,256,256,,,,,,,,,,,,,,,,,,,,,',
-'256,,,256,,,256,,,256,,,,,,256,,,,,,,,256,,,,,256,256,256,256,256,256',
-',,,256,256,,,,261,261,261,256,261,,256,,261,261,,256,256,261,,261,261',
-'261,261,261,261,261,,,,,,261,261,261,261,261,261,261,,,261,,,,,,,261',
-',,261,261,,261,261,261,261,261,,261,261,261,,261,261,,261,261,,,,,,',
-',,,,,,,,,,,,,,,261,,,261,,,261,,,261,,,,,,261,,,,,,,,261,,,,,261,261',
-'261,261,261,261,,,,261,261,,,,639,639,639,261,639,,261,,639,639,,261',
-'261,639,,639,639,639,639,639,639,639,,,,,,639,639,639,639,639,639,639',
-',,639,,,,,,,639,,,639,639,,639,639,639,639,639,,639,639,639,,639,639',
-',639,639,,,,,,,,,,,,,,,,,,,,,,639,,,639,,,639,,,639,,,,,,639,,,,,,,',
-'639,,,,,639,639,639,639,639,639,,,,639,639,,,,636,636,636,639,636,,639',
-',636,636,,639,639,636,,636,636,636,636,636,636,636,,,,,,636,636,636',
-'636,636,636,636,,,636,,,,,,,636,,,636,636,,636,636,636,636,636,,636',
-'636,636,,636,636,,636,636,,,,,,,,,,,,,,,,,,,,,,636,,,636,,,636,,,636',
-',,,,,636,,,,,,,,636,,,,,636,636,636,636,636,636,,,,636,636,,,,631,631',
-'631,636,631,,636,,631,631,,636,636,631,,631,631,631,631,631,631,631',
-',,,,,631,631,631,631,631,631,631,,,631,,,,,,,631,,,631,631,,631,631',
-'631,631,631,,631,631,631,,631,631,,631,631,,,,,,,,,,,,,,,,,,,,,,631',
-',,631,,,631,,,631,,,,,,631,,,,,,,,631,,,,,631,631,631,631,631,631,,',
-',631,631,,,,630,630,630,631,630,,631,,630,630,,631,631,630,,630,630',
-'630,630,630,630,630,,,,,,630,630,630,630,630,630,630,,,630,,,,,,,630',
-',,630,630,,630,630,630,630,630,,630,630,630,,630,630,,630,630,,,,,,',
-',,,,,,,,,,,,,,,630,,,630,,,630,,,630,,,,,,630,,,,,,,,630,,,,,630,630',
-'630,630,630,630,,,,630,630,,,,268,268,268,630,268,,630,,268,268,,630',
-'630,268,,268,268,268,268,268,268,268,,,,,,268,268,268,268,268,268,268',
-',,268,,,,,,,268,,,268,268,,268,268,268,268,268,268,268,268,268,,268',
-'268,,268,268,,,,,,,,,,,,,,,,,,,,,,268,,,268,,,268,,,268,,268,,268,,268',
-',,,,,,,268,,,,,268,268,268,268,268,268,,,,268,268,,,,269,269,269,268',
-'269,,268,,269,269,,268,268,269,,269,269,269,269,269,269,269,,,,,,269',
-'269,269,269,269,269,269,,,269,,,,,,,269,,,269,269,,269,269,269,269,269',
-'269,269,269,269,,269,269,,269,269,,,,,,,,,,,,,,,,,,,,,,269,,,269,,,269',
-',,269,,269,,269,,269,,,,,,,,269,,,,,269,269,269,269,269,269,,,,269,269',
-',,,277,277,277,269,277,,269,,277,277,,269,269,277,,277,277,277,277,277',
-'277,277,,,,,,277,277,277,277,277,277,277,,,277,,,,,,,277,,,277,277,',
-'277,277,277,277,277,277,277,277,277,,277,277,,277,277,,,,,,,,,,,,,,',
-',,,,,,,277,,,277,,277,277,,,277,,277,,277,,277,,,,,,,,277,,,,,277,277',
-'277,277,277,277,,,,277,277,,,,627,627,627,277,627,,277,,627,627,,277',
-'277,627,,627,627,627,627,627,627,627,,,,,,627,627,627,627,627,627,627',
-',,627,,,,,,,627,,,627,627,,627,627,627,627,627,,627,627,627,,627,627',
-',627,627,,,,,,,,,,,,,,,,,,,,,,627,,,627,,,627,,,627,,627,,,,627,,,,',
-',,,627,,,,,627,627,627,627,627,627,,,,627,627,,,,625,625,625,627,625',
-',627,,625,625,,627,627,625,,625,625,625,625,625,625,625,,,,,,625,625',
-'625,625,625,625,625,,,625,,,,,,,625,,,625,625,,625,625,625,625,625,',
-'625,625,625,,625,625,,625,625,,,,,,,,,,,,,,,,,,,,,,625,,,625,,,625,',
-',625,,,,,,625,,,,,,,,625,,,,,625,625,625,625,625,625,,,,625,625,,,,598',
-'598,598,625,598,,625,,598,598,,625,625,598,,598,598,598,598,598,598',
-'598,,,,,,598,598,598,598,598,598,598,,,598,,,,,,,598,,,598,598,,598',
-'598,598,598,598,,598,598,598,,598,598,,598,598,,,,,,,,,,,,,,,,,,,,,',
-'598,,,598,,,598,,,598,,,,,,598,,,,,,,,598,,,,,598,598,598,598,598,598',
-',,,598,598,,,,,,,598,,,598,,,,,598,598,281,281,281,281,281,,,,281,281',
-',,,281,,281,281,281,281,281,281,281,,,,,,281,281,281,281,281,281,281',
-',,281,,,,,,281,281,,281,281,281,,281,281,281,281,281,,281,281,281,,281',
-'281,,281,281,,,,,,,,,,,,,,,,,,,,,,281,,,281,,,281,,,281,,281,,,,281',
-',,,,,,,281,,,,,281,281,281,281,281,281,,,,281,281,,,,596,596,596,281',
-'596,,281,,596,596,,281,281,596,,596,596,596,596,596,596,596,,,,,,596',
-'596,596,596,596,596,596,,,596,,,,,,,596,,,596,596,,596,596,596,596,596',
-',596,596,596,,596,596,,596,596,,,,,,,,,,,,,,,,,,,,,,596,,,596,,,596',
-',,596,,,,,,596,,,,,,,,596,,,,,596,596,596,596,596,596,,,,596,596,,,',
-'592,592,592,596,592,,596,,592,592,,596,596,592,,592,592,592,592,592',
-'592,592,,,,,,592,592,592,592,592,592,592,,,592,,,,,,,592,,,592,592,',
-'592,592,592,592,592,592,592,592,592,,592,592,,592,592,,,,,,,,,,,,,,',
-',,,,,,,592,,,592,,,592,,,592,,592,,,,592,,,,,,,,592,,,,,592,592,592',
-'592,592,592,,,,592,592,,,,586,586,586,592,586,,592,,586,586,,592,592',
-'586,,586,586,586,586,586,586,586,,,,,,586,586,586,586,586,586,586,,',
-'586,,,,,,,586,,,586,586,,586,586,586,586,586,586,586,586,586,,586,586',
-',586,586,,,,,,,,,,,,,,,,,,,,,,586,,,586,,,586,,,586,,586,,,,586,,,,',
-',,,586,,,,,586,586,586,586,586,586,,,,586,586,,,,285,285,285,586,285',
-',586,,285,285,,586,586,285,,285,285,285,285,285,285,285,,,,,,285,285',
-'285,285,285,285,285,,,285,,,,,,,285,,,285,285,,285,285,285,285,285,',
-'285,285,285,,285,285,918,,918,918,918,918,918,,,,,,,,,,918,,,,,,,,285',
-',,285,,,285,,,285,,,,,,918,918,,,,,,,918,918,918,918,,285,285,285,285',
-'285,285,,,,285,285,,,,285,,,285,,,285,,,,,285,285,286,286,286,286,286',
-',,918,286,286,,,,286,,286,286,286,286,286,286,286,,,,,,286,286,286,286',
-'286,286,286,,,286,,,,,,286,286,,286,286,286,,286,286,286,286,286,,286',
-'286,286,,286,286,,286,286,,,,,,,,,,,,,,,,,,,,,,286,,,286,,,286,,,286',
-',286,,,,286,,,,,,,,286,,,,,286,286,286,286,286,286,,,,286,286,,,,583',
-'583,583,286,583,,286,,583,583,,286,286,583,,583,583,583,583,583,583',
-'583,,,,,,583,583,583,583,583,583,583,,,583,,,,,,,583,,,583,583,,583',
-'583,583,583,583,583,583,583,583,,583,583,,583,583,,,,,,,,,,,,,,,,,,',
-',,,583,,,583,,,583,,,583,,583,,,,583,,,,,,,,583,,,,,583,583,583,583',
-'583,583,,,,583,583,,,,,,,583,,,583,,,,,583,583,581,581,581,581,581,',
-',,581,581,,,,581,,581,581,581,581,581,581,581,,,,,,581,581,581,581,581',
-'581,581,,,581,,,,,,581,581,,581,581,581,,581,581,581,581,581,,581,581',
-'581,,581,581,,581,581,,,,,,,,,,,,,,,,,,,,,,581,,,581,,,581,,,581,,581',
-',,,581,,,,,,,,581,,,,,581,581,581,581,581,581,,,,581,581,,,,,,,581,',
-',581,,,,,581,581,576,576,576,576,576,,,,576,576,,,,576,,576,576,576',
-'576,576,576,576,,,,,,576,576,576,576,576,576,576,,,576,,,,,,576,576',
-',576,576,576,,576,576,576,576,576,,576,576,576,,576,576,,576,576,,,',
-',,,,,,,,,,,,,,,,,,576,,,576,,,576,,,576,,576,,,,576,,,,,,,,576,,,,,576',
-'576,576,576,576,576,,,,576,576,,,,,,,576,,,576,,,,,576,576,572,572,572',
-'572,572,,,,572,572,,,,572,,572,572,572,572,572,572,572,,,,,,572,572',
-'572,572,572,572,572,,,572,,,,,,572,572,,572,572,572,,572,572,572,572',
-'572,,572,572,572,,572,572,,572,572,,,,,,,,,,,,,,,,,,,,,,572,,,572,,',
-'572,,,572,,572,,,,572,,,,,,,,572,,,,,572,572,572,572,572,572,,,,572',
-'572,,,,558,558,558,572,558,,572,,558,558,,572,572,558,,558,558,558,558',
-'558,558,558,,,,,,558,558,558,558,558,558,558,,,558,,,,,,,558,,,558,558',
-',558,558,558,558,558,,558,558,558,,558,558,856,,856,856,856,856,856',
-',,,,,,,,,856,,,,,,,,558,,,558,,,558,,,558,,,,,,856,,,,,,,,856,856,856',
-'856,,558,558,558,558,558,558,,,,558,558,,,,,,,558,,,558,,,,,558,558',
-'552,552,552,552,552,,,856,552,552,,,,552,,552,552,552,552,552,552,552',
-',,,,,552,552,552,552,552,552,552,,,552,,,,,,552,552,,552,552,552,,552',
-'552,552,552,552,,552,552,552,,552,552,,552,552,,,,,,,,,,,,,,,,,,,,,',
-'552,,,552,,,552,,,552,,552,,,,552,,,,,,,,552,,,,,552,552,552,552,552',
-'552,,,,552,552,,,,,,,552,,,552,,,,,552,552,551,551,551,551,551,,,,551',
-'551,,,,551,,551,551,551,551,551,551,551,,,,,,551,551,551,551,551,551',
-'551,,,551,,,,,,551,551,,551,551,551,,551,551,551,551,551,,551,551,551',
-',551,551,,551,551,,,,,,,,,,,,,,,,,,,,,,551,,,551,,,551,,,551,,551,,',
-',551,,,,,,,,551,,,,,551,551,551,551,551,551,,,,551,551,,,,546,546,546',
-'551,546,,551,,546,546,,551,551,546,,546,546,546,546,546,546,546,,,,',
-',546,546,546,546,546,546,546,,,546,,,,,,,546,,,546,546,,546,546,546',
-'546,546,546,546,546,546,,546,546,,546,546,,,,,,,,,,,,,,,,,,,,,,546,',
-',546,,,546,,,546,,,,,,546,,,,,,,,546,,,,,546,546,546,546,546,546,,,',
-'546,546,,,,543,543,543,546,543,,546,,543,543,,546,546,543,,543,543,543',
-'543,543,543,543,,,,,,543,543,543,543,543,543,543,,,543,,,,,,,543,,,543',
-'543,,543,543,543,543,543,543,543,543,543,,543,543,,543,543,,,,,,,,,',
-',,,,,,,,,,,,543,,,543,,,543,,,543,,543,,,,543,,,,,,,,543,,,,,543,543',
-'543,543,543,543,,,,543,543,,,,298,298,298,543,298,,543,,298,298,,543',
-'543,298,,298,298,298,298,298,298,298,,,,,,298,298,298,298,298,298,298',
-',,298,,,,,,,298,,,298,298,,298,298,298,298,298,,298,298,298,,298,298',
-',,,,,,,,,,,,,,,,,,,,,,,,298,,,298,,,298,,,298,,,,,,,,,,,,,,,,,,,298',
-'298,298,298,298,298,,,,298,298,,,,537,537,537,298,537,,298,,537,537',
-',298,298,537,,537,537,537,537,537,537,537,,,,,,537,537,537,537,537,537',
-'537,,,537,,,,,,,537,,,537,537,,537,537,537,537,537,,537,537,537,,537',
-'537,,537,537,,,,,,,,,,,,,,,,,,,,,,537,,,537,,,537,,,537,,,,,,537,,,',
-',,,,537,,,,,537,537,537,537,537,537,,,,537,537,,,,533,533,533,537,533',
-',537,,533,533,,537,537,533,,533,533,533,533,533,533,533,,,,,,533,533',
-'533,533,533,533,533,,,533,,,,,,,533,,,533,533,,533,533,533,533,533,',
-'533,533,533,,533,533,,533,533,,,,,,,,,,,,,,,,,,,,,,533,,,533,,,533,',
-',533,,,,,,533,,,,,,,,533,,,,,533,533,533,533,533,533,,,,533,533,,,,532',
-'532,532,533,532,,533,,532,532,,533,533,532,,532,532,532,532,532,532',
-'532,,,,,,532,532,532,532,532,532,532,,,532,,,,,,,532,,,532,532,,532',
-'532,532,532,532,,532,532,532,,532,532,,532,532,,,,,,,,,,,,,,,,,,,,,',
-'532,,,532,,,532,,,532,,,,,,532,,,,,,,,532,,,,,532,532,532,532,532,532',
-',,,532,532,,,,531,531,531,532,531,,532,,531,531,,532,532,531,,531,531',
-'531,531,531,531,531,,,,,,531,531,531,531,531,531,531,,,531,,,,,,,531',
-',,531,531,,531,531,531,531,531,,531,531,531,,531,531,,531,531,,,,,,',
-',,,,,,,,,,,,,,,531,,,531,,,531,,,531,,,,,,531,,,,,,,,531,,,,,531,531',
-'531,531,531,531,,,,531,531,,,,523,523,523,531,523,,531,,523,523,,531',
-'531,523,,523,523,523,523,523,523,523,,,,,,523,523,523,523,523,523,523',
-',,523,,,,,,,523,,,523,523,,523,523,523,523,523,523,523,523,523,,523',
-'523,,523,523,,,,,,,,,,,,,,,,,,,,,,523,,,523,,,523,,,523,,523,,,,523',
-',,,,,,,523,,,,,523,523,523,523,523,523,,,,523,523,,,,307,307,307,523',
-'307,,523,,307,307,,523,523,307,,307,307,307,307,307,307,307,,,,,,307',
-'307,307,307,307,307,307,,,307,,,,,,,307,,,307,307,,307,307,307,307,307',
-',307,307,307,,307,307,,307,307,,,,,,,,,,,,,,,,,,,,,,307,,,307,307,,307',
-',,307,,,,,,307,,,,,,,,307,,,,,307,307,307,307,307,307,,,,307,307,,,',
-',,,307,,,307,,,,,307,307,309,309,309,309,309,,,,309,309,,,,309,,309',
-'309,309,309,309,309,309,,,,,,309,309,309,309,309,309,309,,,309,,,,,',
-'309,309,,309,309,309,,309,309,309,309,309,,309,309,309,,309,309,,309',
-'309,,,,,,,,,,,,,,,,,,,,,,309,,,309,,,309,,,309,,309,,,,309,,,,,,,,309',
-',,,,309,309,309,309,309,309,,,,309,309,,,,520,520,520,309,520,,309,',
-'520,520,,309,309,520,,520,520,520,520,520,520,520,,,,,,520,520,520,520',
-'520,520,520,,,520,,,,,,,520,,,520,520,,520,520,520,520,520,520,520,520',
-'520,,520,520,,520,520,,,,,,,,,,,,,,,,,,,,,,520,,,520,,,520,,,520,,520',
-',,,520,,,,,,,,520,,,,,520,520,520,520,520,520,,,,520,520,,,,518,518',
-'518,520,518,,520,,518,518,,520,520,518,,518,518,518,518,518,518,518',
-',,,,,518,518,518,518,518,518,518,,,518,,,,,,,518,,,518,518,,518,518',
-'518,518,518,,518,518,518,,518,518,,,,,,,,,,,,,,,,,,,,,,,,,518,,,518',
-',,518,,,518,,,,,,,,,,,,,,,,,,,518,518,518,518,518,518,,,,518,518,,,',
-',,,518,,,518,,,,,518,518,512,512,512,512,512,,,,512,512,,,,512,,512',
-'512,512,512,512,512,512,,,,,,512,512,512,512,512,512,512,,,512,,,,,',
-'512,512,,512,512,512,,512,512,512,512,512,,512,512,512,,512,512,,512',
-'512,,,,,,,,,,,,,,,,,,,,,,512,,,512,,,512,,,512,,512,,,,512,,,,,,,,512',
-',,,,512,512,512,512,512,512,,,,512,512,,,,,,512,512,,,512,,,,,512,512',
-'506,506,506,,506,,,,506,506,,,,506,,506,506,506,506,506,506,506,,,,',
-',506,506,506,506,506,506,506,,,506,,,,,,,506,,,506,506,,506,506,506',
-'506,506,,506,506,506,,506,506,,506,506,,,,,,,,,,,,,,,,,,,,,,506,,,506',
-',506,506,,,506,,,,506,,506,,,,,,,,506,,,,,506,506,506,506,506,506,,',
-',506,506,,,,491,491,491,506,491,,506,,491,491,,506,506,491,,491,491',
-'491,491,491,491,491,,,,,,491,491,491,491,491,491,491,,,491,,,,,,,491',
-',,491,491,,491,491,491,491,491,,491,491,491,,491,491,,491,491,,,,,,',
-',,,,,,,,,,,,,,,491,,,491,,,491,,,491,,,,,,491,,,,,,,,491,,,,,491,491',
-'491,491,491,491,,,,491,491,,,,489,489,489,491,489,,491,,489,489,,491',
-'491,489,,489,489,489,489,489,489,489,,,,,,489,489,489,489,489,489,489',
-',,489,,,,,,,489,,,489,489,,489,489,489,489,489,489,489,489,489,,489',
-'489,,489,489,,,,,,,,,,,,,,,,,,,,,,489,,,489,,,489,,,489,,,,489,,489',
-',,,,,,,489,,,,,489,489,489,489,489,489,,,,489,489,,,,487,487,487,489',
-'487,,489,,487,487,,489,489,487,,487,487,487,487,487,487,487,,,,,,487',
-'487,487,487,487,487,487,,,487,,,,,,,487,,,487,487,,487,487,487,487,487',
-'487,487,487,487,,487,487,,487,487,,,,,,,,,,,,,,,,,,,,,,487,,,487,,,487',
-',,487,,487,,487,,487,,,,,,,,487,,,,438,487,487,487,487,487,487,438,438',
-'438,487,487,,438,438,,438,,487,,,487,,,,,487,487,,,,,,,,,438,438,,438',
-'438,438,438,438,,,,,,,,,,,,,,,,,,,,,,,,438,438,438,438,438,438,438,438',
-'438,438,438,438,438,438,438,,,438,438,438,,438,,,,438,,,,,,,438,,438',
-',438,438,438,438,438,438,438,,438,,438,,,,,,,,,,,,,438,438,,438,,438',
-'644,,438,,438,,438,644,644,644,,,644,644,644,,644,,,,,,,,,644,644,644',
-',,,,,,,,644,644,,644,644,644,644,644,,,,,,,,,,,,,,,,,,,,,,,,644,644',
-'644,644,644,644,644,644,644,644,644,644,644,644,644,,,644,644,644,,644',
-'644,,,644,,,644,,644,,644,,644,,644,644,644,644,644,644,644,,644,644',
-'644,,,,,,,,,,,,,644,644,644,644,,644,645,,644,,644,,644,645,645,645',
-',,645,645,645,,645,,,,,,,,,,645,645,,,,,,,,,645,645,,645,645,645,645',
-'645,,,,,,,,,,,,,,,,,,,,,,,,645,645,645,645,645,645,645,645,645,645,645',
-'645,645,645,645,,,645,645,645,,645,645,,,645,,,645,,645,,645,,645,,645',
-'645,645,645,645,645,645,,645,,645,,,,,,,,,,,,,645,645,645,645,,645,436',
-',645,,645,,645,436,436,436,,,,436,436,,436,,,,,,,,,436,,,,,,,,,,,436',
-'436,,436,436,436,436,436,,,,,,,,,,,,,,,,,,,,,,,,436,436,436,436,436',
-'436,436,436,436,436,436,436,436,436,436,,,436,436,436,,436,,,,436,,',
-',,,,436,,436,,436,436,436,436,436,436,436,,436,436,436,,,,,,,,,,,,,436',
-'436,,436,,436,50,,436,,436,,436,50,50,50,,,50,50,50,,50,,,,,,,,,,50',
-'50,50,,,,,,,,50,50,,50,50,50,50,50,,,,,,,,,,,,,,,,,,,,,,,,50,50,50,50',
-'50,50,50,50,50,50,50,50,50,50,50,,,50,50,50,,,50,,,50,,,50,,50,,50,',
-'50,,50,50,50,50,50,50,50,,50,,50,,,,,,,,,,,,,50,50,50,50,28,50,,50,50',
-',50,28,28,28,,,28,28,28,,28,,,,,,,,,,28,28,,,,,,,,,28,28,,28,28,28,28',
-'28,,,,,,,,,,,,,,,,,,,,,,,,28,28,28,28,28,28,28,28,28,28,28,28,28,28',
-'28,,,28,28,28,,,28,,28,28,,,28,,28,,28,,28,,28,28,28,28,28,28,28,,28',
-',28,,,,,,,,,,,,,28,28,28,28,495,28,,,28,,28,495,495,495,,,495,495,495',
-',495,,,,,,,,,,495,,,,,,,,,,495,495,,495,495,495,495,495,,,,,,,,,,,,',
-',496,,,,,,,496,496,496,,,496,496,496,,496,,,,,495,495,,,,496,,,495,',
-',,,495,495,496,496,,496,496,496,496,496,,,,,,,,,,,,,495,,,,,,,,,,,,494',
-'495,,495,,,495,494,494,494,496,496,494,494,494,,494,,496,,,,,496,496',
-',494,,,,,,,,,,494,494,,494,494,494,494,494,,496,,,,,,202,202,,,202,',
-',496,,496,,,496,202,202,,202,202,202,202,202,202,202,,,202,202,494,494',
-',,202,202,202,202,494,,,,,494,494,,,,,,202,202,,202,202,202,202,202',
-'202,202,202,202,202,202,,494,202,,,,,,,,,,,,494,,494,,,494,411,411,411',
-'411,411,411,411,411,411,411,411,411,411,411,411,411,411,411,411,411',
-'411,411,411,411,,,,411,411,411,411,411,411,411,411,411,411,411,411,411',
-'411,411,411,411,411,411,411,411,,411,411,,,411,,,,,,,,,411,411,,411',
-'411,411,411,411,411,411,,,411,411,,,,,411,411,411,411,,,,,,,,,,,,,411',
-'411,,411,411,411,411,411,411,411,411,411,411,411,,,411,411,,,,,,,,,',
-'411,415,415,415,415,415,415,415,415,415,415,415,415,415,415,415,415',
-'415,415,415,415,415,415,415,415,,,,415,415,415,415,415,415,415,415,415',
-'415,415,415,415,415,415,415,415,415,415,415,415,,415,415,,,415,,,,,',
-',,,415,415,,415,415,415,415,415,415,415,,,415,415,,,,,415,415,415,415',
-',,,,,,,,,,,,415,415,,415,415,415,415,415,415,415,415,415,415,415,,,415',
-'415,,,,,,,,,,415,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,,,',
-'8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,,8,8,,,8,,,,,,,,,8,8,,8,8',
-'8,8,8,8,8,,,8,8,,,,,8,8,8,8,,,,,,,,,,,,,8,8,,8,8,8,8,8,8,8,8,8,8,8,',
-',8,8,,,,,,,,,,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,,,,7',
-'7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,,7,7,7,,7,,,,,,,,,7,7,,7,7,7',
-'7,7,7,7,,,7,7,,,,,7,7,7,7,,,,,,,,,,,,,7,7,,7,7,7,7,7,7,7,7,7,7,7,,,7',
-'7,,,,,,,,,,7,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79',
-'79,79,79,79,79,,,,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79',
-'79,79,79,79,,79,79,79,79,79,,79,,,,,,,79,79,,79,79,79,79,79,79,79,,',
-'79,79,,,,,79,79,79,79,,,,,,,,,,,,,79,79,,79,79,79,79,79,79,79,79,79',
-'79,79,,,79,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192',
-'192,192,192,192,192,192,192,192,192,,,,192,192,192,192,192,192,192,192',
-'192,192,192,192,192,192,192,192,192,192,192,192,192,,192,192,192,192',
-'192,,192,,,,,,,192,192,,192,192,192,192,192,192,192,,,192,192,,,,,192',
-'192,192,192,,,,,,,,,,,,,192,192,,192,192,192,192,192,192,192,192,192',
-'192,192,,,192,766,766,766,766,766,766,766,766,766,766,766,766,766,766',
-'766,766,766,766,766,766,766,766,766,766,,,,766,766,766,766,766,766,766',
-'766,766,766,766,766,766,766,766,766,766,766,766,766,766,,766,766,,,766',
-',,,,,,,,766,766,,766,766,766,766,766,766,766,,,766,766,,,,,766,766,766',
-'766,,,,,,,,,,,,,766,766,,766,766,766,766,766,766,766,766,766,766,766',
-',,766,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65',
-'65,65,65,,,,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65',
-'65,65,,65,65,65,65,65,,65,,,,,,,65,65,,65,65,65,65,65,65,65,,,65,65',
-',,,,65,65,65,65,,,,,,65,,,,,,,65,65,,65,65,65,65,65,65,65,65,65,65,65',
-'534,534,65,,534,,,,,,,,,534,534,,534,534,534,534,534,534,534,,,534,534',
-',,,,534,534,534,534,,,,,,534,,,,,,,534,534,,534,534,534,534,534,534',
-'534,534,534,534,534,535,535,534,,535,,,,,,,,,535,535,,535,535,535,535',
-'535,535,535,,,535,535,,,,,535,535,535,535,,,,,,,,,,,,,535,535,,535,535',
-'535,535,535,535,535,535,535,535,535,201,201,535,,201,,,,,,,,,201,201',
-',201,201,201,201,201,201,201,,,201,201,,,,,201,201,201,201,,,,,,201',
-',,,,,,201,201,,201,201,201,201,201,201,201,201,201,201,201,947,947,201',
-',947,,,,,,,,,947,947,,947,947,947,947,947,947,947,,,947,947,,,,,947',
-'947,947,947,,,,,,,,,,,,,947,947,,947,947,947,947,947,947,947,947,947',
-'947,947,946,946,947,,946,,,,,,,,,946,946,,946,946,946,946,946,946,946',
-',,946,946,,,,,946,946,946,946,,,,,,946,,,,,,,946,946,,946,946,946,946',
-'946,946,946,946,946,946,946,266,266,946,,266,,,,,,,,,266,266,,266,266',
-'266,266,266,266,266,,,266,266,,,,,266,266,266,266,,,,,,,,,,,,,266,266',
-',266,266,266,266,266,266,266,266,266,266,266,265,265,266,,265,,,,,,',
-',,265,265,,265,265,265,265,265,265,265,,,265,265,,,,,265,265,265,265',
-',,,,,,,,,,,,265,265,,265,265,265,265,265,265,265,265,265,265,265,264',
-'264,265,,264,,,,,,,,,264,264,,264,264,264,264,264,264,264,,,264,264',
-',,,,264,264,264,264,,,,,,,,,,,,,264,264,,264,264,264,264,264,264,264',
-'264,264,264,264,449,449,264,,449,,,,,,,,,449,449,,449,449,449,449,449',
-'449,449,,,449,449,,,,,449,449,449,449,,,,,,449,,,,,,,449,449,,449,449',
-'449,449,449,449,449,449,449,449,449,450,450,449,,450,,,,,,,,,450,450',
-',450,450,450,450,450,450,450,,,450,450,,,,,450,450,450,450,,,,,,,,,',
-',,,450,450,,450,450,450,450,450,450,450,450,450,450,450,822,822,450',
-',822,,,,,,,,,822,822,,822,822,822,822,822,822,822,,,822,822,,,,,822',
-'822,822,822,,,,,,,,,,,,,822,822,,822,822,822,822,822,822,822,822,822',
-'822,822,593,593,822,,593,,,,,,,,,593,593,,593,593,593,593,593,593,593',
-',,593,593,,,,,593,593,593,593,,,,,,593,,,,,,,593,593,,593,593,593,593',
-'593,593,593,593,593,593,593,591,591,593,,591,,,,,,,,,591,591,,591,591',
-'591,591,591,591,591,,,591,591,,,,,591,591,591,591,,,,,,,,,,,,,591,591',
-',591,591,591,591,591,591,591,591,591,591,591,585,585,591,,585,,,,,,',
-',,585,585,,585,585,585,585,585,585,585,,,585,585,,,,,585,585,585,585',
-',,,,,,,,,,,,585,585,,585,585,585,585,585,585,585,585,585,585,585,584',
-'584,585,,584,,,,,,,,,584,584,,584,584,584,584,584,584,584,,,584,584',
-',,,,584,584,584,584,,,,,,584,,,,,,,584,584,,584,584,584,584,584,584',
-'584,584,584,584,584,203,203,584,,203,,,,,,,,,203,203,,203,203,203,203',
-'203,203,203,,,203,203,,,,,203,203,203,203,,,,,,,,,,,,,203,203,,203,203',
-'203,203,203,203,203,203,203,203,203,521,521,203,,521,,,,,,,,,521,521',
-',521,521,521,521,521,521,521,,,521,521,,,,,521,521,521,521,,,,,,521',
-',,,,,,521,521,,521,521,521,521,521,521,521,521,521,521,521,522,522,521',
-',522,,,,,,,,,522,522,,522,522,522,522,522,522,522,,,522,522,,,,,522',
-'522,522,522,,,,,,,,,,,,,522,522,,522,522,522,522,522,522,522,522,522',
-'522,522,524,524,522,,524,,,,,,,,,524,524,,524,524,524,524,524,524,524',
-',,524,524,,,,,524,524,524,524,,,,,,,,,,,,,524,524,,524,524,524,524,524',
-'524,524,524,524,524,524,,,524' ]
- racc_action_check = arr = ::Array.new(25094, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_action_pointer = [
- 1281, 1148, nil, 106, nil, 618, 1015, 23357, 23233, 1014,
- 962, 955, 962, 721, 208, 688, nil, 3264, 3391, 1408,
- 982, nil, 3785, 3912, 4039, 508, 13, 4420, 22600, nil,
- 4560, 4687, 4814, nil, 847, 444, 848, 660, 5488, 5615,
- 5742, 734, 213, nil, nil, nil, nil, nil, nil, nil,
- 22470, nil, 6136, 6263, 6390, 29, 7177, 6771, -2, nil,
- nil, 7025, 7165, 7292, nil, 23820, nil, nil, nil, nil,
- nil, -102, nil, nil, nil, nil, nil, 626, 625, 23481,
- nil, nil, nil, 344, 8194, nil, nil, 8321, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 601, nil, 8601,
- nil, nil, nil, 8741, 8868, 8995, 9122, 9262, 9402, nil,
- 418, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 23594, 423, nil, 9949, 10076, 10203, 10330, 10457,
- 10584, 24003, 22855, 24796, 11092, 11219, 11346, nil, 848, 97,
- 1175, 248, 1086, 1123, 12287, 12414, nil, nil, 12541, 1119,
- 12795, 12922, 13049, 13176, 13303, 13430, 13557, 13684, 13811, 13938,
- 14065, 14192, 14319, 14446, 14573, 14700, 14827, 14954, 15081, 15208,
- 15335, 15462, 15589, 15716, 15843, 15970, nil, nil, nil, 2603,
- nil, 1062, 1052, nil, 16364, 1089, 16491, nil, nil, nil,
- nil, 16618, nil, nil, 24308, 24247, 24186, 1072, 17253, 17380,
- nil, nil, nil, nil, nil, nil, nil, 17507, 543, 872,
- 1112, 18028, 1134, 1141, 1106, 18536, 18676, 235, 887, 1207,
- 206, 142, 281, 14, nil, 388, 289, nil, 20011, nil,
- 459, 499, 522, 795, nil, 629, nil, 20773, nil, 20913,
- 42, nil, 607, 262, 150, 715, 707, 234, 763, nil,
- nil, 48, 4699, nil, nil, nil, 799, 792, nil, 824,
- 840, nil, nil, nil, nil, nil, nil, nil, 3025, nil,
- nil, nil, 919, nil, nil, 924, 425, 36, 63, 1535,
- 1662, 446, 73, 882, 21, 633, 1085, 43, 1142, nil,
- nil, 379, 1095, nil, 594, nil, 64, nil, nil, 125,
- 467, 470, 483, 528, 554, 563, -5, 356, nil, 388,
- nil, 6898, nil, 462, nil, 483, nil, 201, 1034, 488,
- nil, 1030, -57, nil, 379, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 1029, 22985, nil, nil, nil, 23109, 1023, nil, nil, 1916,
- nil, 1916, 974, nil, 951, nil, nil, 2196, 947, 946,
- 287, 291, 1789, nil, nil, nil, 22338, 908, 21942, nil,
- 1141, 1014, 887, nil, nil, nil, 1014, nil, nil, 24369,
- 24430, 760, 633, -46, 506, 379, 252, 4, nil, 5234,
- 5094, 993, 514, 857, 856, 819, 816, 5488, 5361, 3138,
- 4954, 4166, 4560, 4039, 3912, 3785, 3658, 3531, 3391, 3264,
- 1141, 1149, 4420, 4293, 633, -40, nil, 21828, nil, 21701,
- nil, 21574, nil, nil, 22855, 22730, 22787, 171, nil, 680,
- nil, nil, 674, 672, nil, nil, 21447, 203, 193, 705,
- nil, nil, 21307, 704, 647, nil, nil, 643, 21167, 635,
- 21040, 24857, 24918, 20646, 24979, 228, 537, nil, nil, 463,
- nil, 20519, 20392, 20265, 23881, 23942, 1789, 20138, 523, 509,
- 415, nil, nil, 19884, nil, nil, 19757, nil, nil, nil,
- nil, 19630, 19490, 267, nil, 1114, nil, nil, 19350, 7304,
- nil, 107, nil, nil, -15, nil, 3034, nil, -61, 1521,
- nil, nil, 19223, 1252, nil, nil, 19083, 212, 227, 1234,
- 1229, 18943, nil, 18803, 24735, 24674, 18409, 20, nil, 922,
- nil, 24613, 18282, 24552, nil, nil, 18155, 472, 17888, nil,
- 11485, nil, nil, nil, 35, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, -23, nil, nil, nil, 1071,
- nil, nil, nil, nil, nil, 17761, 1051, 17634, 462, -54,
- 17126, 16999, 1070, nil, nil, nil, 16872, 1071, nil, 16745,
- 1080, nil, 330, 307, 22074, 22206, 1092, 1093, 379, nil,
- 16237, nil, 3149, nil, 16110, 1078, nil, 1120, 12668, nil,
- nil, nil, nil, nil, nil, nil, nil, 12147, nil, 1127,
- 12007, 11880, 2056, 1098, nil, nil, 1137, 11753, 11613, nil,
- 745, -34, 11473, 1113, nil, 1154, 196, 223, 1172, 227,
- 203, 1180, 1177, -81, 10965, 2476, 26, 98, -12, 217,
- 10838, nil, nil, -103, 135, 268, nil, nil, 170, nil,
- 202, 760, 319, 249, 251, nil, nil, 311, 2996, nil,
- 702, nil, 401, nil, nil, nil, nil, nil, 410, nil,
- 464, 10711, 410, 40, 37, -18, 46, 438, 9809, 668,
- nil, 483, 485, 9682, 503, nil, -25, 9542, 8461, 4826,
- 464, nil, nil, 581, nil, 8067, nil, 516, 541, nil,
- 547, 550, 554, nil, 555, nil, 23707, 607, 1164, 7940,
- nil, nil, nil, 1281, 616, 7800, 7673, 7546, nil, 887,
- nil, 2883, nil, nil, 760, nil, 2743, nil, 7419, 6644,
- 6517, 65, 14, 1535, nil, 714, 817, nil, nil, 729,
- nil, 714, 6009, nil, 735, 840, 722, 59, nil, nil,
- nil, 846, nil, 5882, 743, 793, nil, nil, nil, nil,
- nil, nil, 24491, nil, 1084, nil, nil, nil, nil, 1394,
- 879, nil, 5361, 890, 5234, 5094, nil, nil, 70, -17,
- 975, 295, nil, 924, nil, nil, 928, 938, 824, nil,
- nil, nil, 478, nil, nil, 392, 19362, nil, 1223, nil,
- 475, nil, 4954, nil, nil, nil, nil, nil, nil, nil,
- 866, 852, nil, 1662, nil, 2336, 4293, 4166, nil, nil,
- nil, 3658, 881, nil, nil, nil, 3531, nil, nil, 74,
- 3137, nil, 935, 901, nil, nil, 78, nil, 1030, 1031,
- 3010, 2883, nil, nil, 2743, nil, nil, 959, nil, 926,
- nil, nil, 928, 935, 945, 939, nil, nil, 18548, nil,
- nil, 2603, nil, 2476, 85, 541, 1051, 91, nil, nil,
- 2336, nil, nil, nil, 118, 2196, 1119, nil, nil, 1169,
- nil, nil, nil, 2056, 1130, 1408, 24125, 24064, 97, 179,
- nil, nil, nil, 1006, nil, 909, 1093, nil, 1013, 98,
- 108, 198, 202, nil, nil, nil, nil, -7 ]
-
-racc_action_default = [
- -3, -555, -1, -543, -4, -6, -555, -555, -555, -555,
- -555, -555, -555, -555, -277, -37, -38, -555, -555, -43,
- -45, -46, -289, -327, -328, -50, -255, -382, -255, -65,
- -10, -69, -76, -78, -555, -457, -555, -555, -555, -555,
- -555, -545, -232, -270, -271, -272, -273, -274, -275, -276,
- -533, -279, -555, -554, -525, -297, -554, -555, -555, -302,
- -305, -543, -555, -555, -319, -555, -329, -330, -400, -401,
- -402, -403, -404, -554, -407, -554, -554, -554, -554, -554,
- -434, -440, -441, -555, -446, -447, -448, -449, -450, -451,
- -452, -453, -454, -455, -456, -459, -460, -555, -2, -544,
- -550, -551, -552, -555, -555, -555, -555, -555, -3, -13,
- -555, -105, -106, -107, -108, -109, -110, -111, -114, -115,
- -116, -117, -118, -119, -120, -121, -122, -123, -124, -125,
- -126, -127, -128, -129, -130, -131, -132, -133, -134, -135,
- -136, -137, -138, -139, -140, -141, -142, -143, -144, -145,
- -146, -147, -148, -149, -150, -151, -152, -153, -154, -155,
- -156, -157, -158, -159, -160, -161, -162, -163, -164, -165,
- -166, -167, -168, -169, -170, -171, -172, -173, -174, -175,
- -176, -177, -178, -179, -180, -181, -182, -183, -184, -185,
- -186, -187, -555, -18, -112, -10, -555, -555, -555, -554,
- -554, -555, -555, -555, -555, -555, -555, -41, -555, -457,
- -555, -277, -555, -555, -10, -555, -42, -224, -555, -555,
- -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
- -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
- -555, -555, -555, -555, -555, -555, -369, -371, -47, -233,
- -248, -262, -262, -252, -555, -263, -555, -289, -327, -328,
- -527, -555, -48, -49, -555, -555, -555, -55, -554, -555,
- -296, -375, -383, -385, -63, -381, -64, -555, -543, -11,
- -65, -10, -555, -555, -70, -73, -10, -457, -555, -555,
- -277, -292, -545, -555, -331, -382, -555, -75, -555, -80,
- -284, -442, -443, -555, -209, -210, -225, -555, -546, -10,
- -545, -234, -545, -547, -547, -555, -555, -547, -555, -298,
- -299, -555, -555, -342, -343, -350, -554, -491, -357, -554,
- -554, -368, -490, -492, -493, -494, -495, -496, -555, -509,
- -514, -515, -517, -518, -519, -555, -44, -555, -555, -555,
- -555, -543, -555, -544, -457, -555, -555, -277, -555, -498,
- -499, -101, -555, -103, -555, -277, -555, -316, -457, -555,
- -105, -106, -143, -144, -160, -165, -172, -175, -322, -555,
- -523, -555, -405, -555, -420, -555, -422, -555, -555, -555,
- -412, -555, -555, -418, -555, -433, -435, -436, -437, -438,
- -444, -445, 968, -5, -553, -19, -20, -21, -22, -23,
- -555, -555, -15, -16, -17, -555, -555, -25, -34, -188,
- -263, -555, -555, -26, -35, -36, -27, -190, -555, -555,
- -534, -535, -554, -378, -536, -537, -534, -255, -535, -380,
- -539, -540, -554, -534, -535, -33, -198, -39, -40, -555,
- -555, -554, -554, -284, -555, -555, -555, -555, -295, -199,
- -200, -201, -202, -203, -204, -205, -206, -211, -212, -213,
- -214, -215, -216, -217, -218, -219, -220, -221, -222, -223,
- -226, -227, -228, -229, -555, -554, -249, -555, -250, -555,
- -260, -555, -264, -530, -255, -255, -255, -554, -56, -545,
- -243, -244, -262, -262, -256, -257, -555, -554, -554, -555,
- -291, -9, -544, -555, -66, -282, -81, -71, -555, -555,
- -554, -555, -555, -554, -555, -284, -555, -442, -443, -77,
- -82, -555, -555, -555, -555, -555, -230, -555, -392, -555,
- -555, -235, -236, -549, -548, -238, -549, -287, -288, -526,
- -339, -10, -10, -555, -341, -555, -359, -366, -555, -363,
- -364, -555, -367, -491, -555, -500, -555, -502, -504, -508,
- -516, -520, -10, -332, -333, -334, -10, -555, -555, -555,
- -555, -10, -387, -554, -555, -555, -554, -284, -311, -101,
- -102, -555, -554, -555, -314, -461, -555, -555, -555, -320,
- -489, -324, -541, -542, -545, -406, -421, -424, -425, -427,
- -408, -423, -409, -410, -411, -555, -414, -416, -417, -555,
- -439, -7, -14, -113, -24, -555, -269, -555, -285, -286,
- -555, -555, -59, -241, -242, -376, -555, -61, -379, -555,
- -57, -377, -534, -535, -534, -535, -555, -555, -188, -294,
- -555, -353, -555, -355, -10, -262, -261, -265, -555, -528,
- -529, -51, -372, -52, -373, -53, -374, -10, -239, -555,
- -245, -247, -43, -555, -254, -258, -555, -10, -10, -290,
- -12, -66, -555, -74, -79, -555, -534, -535, -554, -538,
- -283, -555, -555, -554, -555, -197, -207, -208, -555, -554,
- -554, -280, -281, -547, -555, -555, -340, -351, -555, -358,
- -554, -352, -555, -554, -554, -510, -497, -555, -555, -507,
- -554, -335, -554, -303, -336, -337, -338, -306, -555, -309,
- -555, -555, -555, -534, -535, -538, -283, -555, -555, -101,
- -104, -538, -555, -10, -555, -463, -555, -10, -10, -489,
- -555, -466, -467, -469, -470, -472, -473, -522, -522, -478,
- -480, -480, -480, -488, -491, -512, -555, -555, -555, -10,
- -413, -415, -419, -189, -267, -555, -555, -555, -30, -193,
- -31, -194, -60, -32, -195, -62, -196, -58, -555, -555,
- -555, -286, -285, -231, -354, -555, -555, -251, -266, -555,
- -240, -262, -555, -259, -555, -555, -72, -285, -286, -83,
- -293, -554, -348, -10, -393, -554, -394, -395, -237, -344,
- -345, -365, -555, -284, -555, -361, -362, -501, -503, -506,
- -555, -346, -555, -555, -10, -10, -308, -310, -555, -285,
- -93, -555, -285, -555, -462, -317, -555, -555, -545, -465,
- -468, -471, -555, -476, -477, -555, -555, -484, -555, -486,
- -555, -487, -555, -325, -524, -426, -429, -430, -431, -432,
- -555, -268, -28, -191, -29, -192, -555, -555, -356, -370,
- -54, -246, -262, -384, -386, -8, -10, -399, -349, -555,
- -555, -397, -283, -554, -505, -300, -555, -301, -555, -555,
- -555, -10, -312, -315, -10, -321, -323, -555, -474, -522,
- -521, -479, -480, -480, -480, -555, -513, -511, -489, -428,
- -253, -555, -398, -10, -457, -555, -555, -277, -396, -360,
- -10, -304, -307, -265, -554, -10, -555, -464, -475, -555,
- -482, -483, -485, -10, -392, -554, -555, -555, -284, -554,
- -388, -389, -390, -555, -318, -480, -555, -391, -555, -534,
- -535, -538, -283, -347, -313, -481, -326, -285 ]
-
-clist = [
-'13,307,580,251,251,251,315,378,284,699,250,250,250,5,565,529,102,208',
-'208,539,659,396,208,208,208,114,114,323,294,294,13,288,288,488,418,425',
-'498,748,331,347,348,312,99,351,715,763,109,194,14,707,366,830,208,208',
-'432,437,442,208,208,294,294,208,355,364,760,282,572,576,252,252,252',
-'723,727,98,102,117,117,659,14,290,290,590,834,114,759,405,406,407,408',
-'350,656,564,656,271,275,853,854,114,557,13,317,560,562,208,208,208,208',
-'13,13,674,357,365,5,2,280,297,641,494,495,496,409,5,606,542,545,835',
-'811,549,616,738,935,352,743,12,396,916,654,385,387,598,904,394,369,747',
-'600,766,918,14,667,833,321,550,428,429,713,14,14,411,677,678,360,193',
-'247,12,485,507,508,950,662,664,666,731,815,889,382,383,389,422,422,248',
-'262,263,615,392,865,768,710,312,312,10,714,769,848,909,763,13,208,208',
-'208,208,208,908,659,912,208,208,208,403,828,885,114,216,676,760,13,208',
-'916,504,380,10,441,410,316,319,320,668,1,499,358,728,594,762,12,759',
-'379,683,601,309,349,,12,12,565,14,,719,,938,,502,251,359,526,,,,250',
-'250,251,,,,14,,,250,,,208,208,540,,541,656,656,530,,208,,,963,13,294',
-',488,288,13,,10,,,102,,553,,294,10,10,288,,,,432,437,331,,,,,13,740',
-'267,274,276,503,252,513,512,707,717,,519,,252,,,,,12,14,,577,578,290',
-'14,902,910,,,910,759,715,759,,759,,290,12,511,208,208,,,,771,943,599',
-'14,,,271,951,275,763,102,280,294,641,517,364,280,,,,688,,,693,,595,762',
-'208,760,,10,,,688,,417,423,426,,,565,,,445,,806,,782,759,10,646,647',
-'785,,,787,,,659,,12,957,,365,,12,,579,,759,,501,505,,,114,,,,114,509',
-',797,688,,312,312,,12,,,,688,,,,622,208,208,843,623,893,,846,847,669',
-',,,,,857,859,861,441,,10,,,685,,10,692,,,117,,,821,117,656,825,826,913',
-',914,,,,,,530,,,10,634,,,,,638,894,208,,312,634,,312,13,818,,294,,,288',
-',208,,,208,656,680,,,,,,,,655,,,732,208,816,737,441,,,,,742,,,,762,',
-'13,13,441,,294,,901,711,,14,634,634,634,767,,290,,,,955,312,13,,312',
-',13,,744,,312,13,797,208,952,,208,,,703,724,724,208,,,,208,,208,14,14',
-',,441,,,365,,923,441,745,35,,,936,930,,940,941,942,14,,,795,14,,,,,14',
-'208,208,,,331,,208,,283,,,35,287,287,,12,,,,,318,,,956,13,,,,,530,965',
-',,920,,929,,13,,,,809,,354,368,,368,13,13,294,,422,288,,12,12,,,,,,294',
-',,288,,,,,,,10,14,,,12,,,863,12,35,,838,,12,14,801,632,35,35,841,,637',
-',,14,14,640,,,290,,,,,,,,208,,10,10,290,13,,,,13,13,,,,,,,634,,844,638',
-'845,634,10,,849,,10,,,,13,10,,,,,,208,208,,661,663,665,,882,114,,,12',
-',,,14,420,424,,14,14,,,688,12,,,416,,,35,,907,,12,12,,13,896,,869,14',
-',,,,283,778,780,35,,,,783,,,208,,13,13,,,,,441,,,10,,,,,,,490,,492,',
-'724,,10,493,,,,14,,,,,10,10,,,,,,,,,12,,,,12,12,14,14,,,13,294,,283',
-'925,,35,,283,,287,35,958,,,13,12,,13,,,,,287,,,,,,,,,,,35,,,13,,,,,',
-',13,,10,312,14,13,10,10,927,,,,,13,,208,12,,,14,,,14,,,,,,10,,,,,,,441',
-'207,12,12,872,874,14,,,,,,,14,,368,,,14,,,,,,,,14,,217,,,,249,249,249',
-',310,10,,,,346,346,,,346,,,304,305,306,,626,,12,,,,10,10,,,,249,249',
-',,,,12,,,12,,,,,,,,,,,,,,,346,346,346,346,12,,,,,,,12,,,,,12,,,,,,,10',
-'12,,,928,,,,657,,318,,660,,,10,,,10,,,,,,,,,673,,,,,,,,,,10,,,,,,,10',
-',,,35,10,,,,,287,,,10,,,,,,,657,,,318,,,,,,,,,,,,447,448,,,,704,705',
-',35,35,457,,,,,368,,419,249,427,249,249,,,,446,720,,,35,722,,,35,,730',
-',,35,217,,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473',
-'474,475,476,477,478,479,480,481,482,483,484,,,774,,,,,,249,,249,,,,',
-'249,,,,,,,249,249,,,,,,,,249,,798,,,,,,,,796,,,35,657,318,,,,,,,,799',
-',,35,,,,536,,,804,805,,35,35,,,,287,,,814,,346,346,,,324,,,287,,,,,',
-',,,,,,,,384,,386,386,390,393,386,,420,,,604,,,,,,,,,,,,,,,,,,,,,851',
-',,35,,,,35,35,,,,,,,,,,,,871,,,,,,870,,,35,,,,,,,,,,,,,,,,249,,420,',
-',,,,,,,,,,,,,,,,,,,,,888,,,35,,249,249,,446,648,427,,,,,,,,,,,898,899',
-',35,35,,,,,,,,,310,,,917,,,,249,,249,,249,,,,,,,,,,,318,,,,672,,,,,698',
-',,,,,,,922,249,933,35,249,,,924,,,,,695,696,697,934,,,35,,500,35,,933',
-'249,,,249,,,,,,,,,,944,,,35,,,,949,,,35,,953,,346,35,746,,,,,,,35,,',
-',249,,,249,,,,,,249,,,,,556,,,556,556,,,,,,,,,,,,,,,,,,,,,,,,773,,249',
-',,779,781,,,293,293,784,,,786,,293,293,293,,,,,,,793,,,,,,,293,249,',
-',,,,,293,293,,,,249,249,,,,,,,,,,,,,,,,,,,,,,,,,,,,,249,,,633,,,,,,',
-',,346,633,,,,,,,,,,,,,,,,,,249,,,,,,,,,,,,,,,,,,,,,,,,249,651,,,,,,',
-',,633,633,633,651,,,,,,,249,873,875,651,651,,,,,,,,,779,781,784,,,,',
-',,,,,,,249,,,,346,,,,,,,,,,,,,,,293,,293,293,293,293,293,293,293,293',
-'293,293,293,293,293,293,293,293,293,293,293,293,293,293,293,293,293',
-'293,,,,,,,,,293,,293,,,249,,293,,,,,,,,,,,,875,873,,,,249,,,,,,,293',
-',,,,,,,,,,,249,293,,,,,,,,,293,,,,,,,,,,,249,,,,,,,,,,,,,,,,,,,,,,,',
-'249,,,,,,,,,,,,,,633,,,,,633,,,,,,812,817,293,,,,,,,,,556,,,556,556',
-',,,,,812,,812,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,293,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,293,293,293,,,,,,,,,,,,,,,,,,,,,,,887,,,,891,,,,293,,293',
-',293,,,,,,,,,,,,,,,,,,,,,,,,,,,293,,,,,,,,,,,,,293,293,293,,,,,,,,,',
-'293,,,293,,,,,,,,,,,,293,,,556,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-',,,812,,,,,,,,,,,,,,,812,,,,,,,,293,,293,,,,,,,,,,,,293,,,,,,,,,,,293',
-',,,,,,,293,,,,,,,,,,,,293,293,,,,,,,,,,,293,,,,,,,,,,,,293,,,,,,293',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,293,,,,,,,,,,,,,,,,,,,,,,,,293,,,,,,,',
-',,,,,,,,,,,,293,,,,,,,,,,,,,293,293,293,,,,,,,,,,,,293,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,293,,,,,,,,,,,,,,293,293',
-',,,293,,,,,,,,,293,,,,,,,,,,293,,,,,,,,,,,,,,,,,,,,,293' ]
- racc_goto_table = arr = ::Array.new(2500, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'21,51,80,54,54,54,22,47,41,10,29,29,29,7,145,43,83,21,21,8,154,47,21',
-'21,21,48,48,104,52,52,21,21,21,61,24,24,35,84,107,16,16,29,6,16,147',
-'141,14,14,23,106,46,78,21,21,33,33,33,21,21,52,52,21,21,21,110,39,77',
-'77,56,56,56,79,79,4,83,50,50,154,23,23,23,45,89,48,108,16,16,16,16,90',
-'62,148,62,57,57,142,142,48,109,21,56,109,109,21,21,21,21,21,21,62,23',
-'23,7,2,38,42,60,33,33,33,7,7,129,55,55,91,11,55,129,92,93,4,94,20,47',
-'151,36,126,126,95,96,126,97,98,99,100,101,23,36,11,102,103,22,22,105',
-'23,23,27,36,36,19,15,112,20,113,115,116,117,60,60,60,118,119,120,124',
-'125,127,54,54,31,31,31,128,130,131,132,111,29,29,17,111,133,135,137',
-'141,21,21,21,21,21,21,139,154,144,21,21,21,5,149,12,48,18,63,110,21',
-'21,151,64,72,17,48,2,73,74,76,59,1,58,81,80,82,111,20,108,85,43,86,87',
-'88,,20,20,145,23,,145,,142,,54,54,17,51,,,,29,29,54,,,,23,,,29,,,21',
-'21,51,,51,62,62,41,,21,,,78,21,52,,61,21,21,,17,,,83,,104,,52,17,17',
-'21,,,,33,33,107,,,,,21,45,34,34,34,56,56,39,6,106,148,,39,,56,,,,,20',
-'23,,16,16,23,23,79,108,,,108,108,147,108,,108,,23,20,4,21,21,,,,129',
-'84,46,23,,,57,11,57,141,83,38,52,60,42,21,38,,,,33,,,33,,83,111,21,110',
-',17,,,33,,18,18,18,,,145,,,18,,43,,35,108,17,22,22,35,,,35,,,154,,20',
-'10,,23,,20,,4,,108,,31,31,,,48,,,,48,31,,61,33,,29,29,,20,,,,33,,,,14',
-'21,21,8,14,111,,8,8,51,,,,,,143,143,143,48,,17,,,22,,17,22,,,50,,,109',
-'50,62,109,109,111,,111,,,,,,41,,,17,57,,,,,57,145,21,,29,57,,29,21,55',
-',52,,,21,,21,,,21,62,7,,,,,,,,56,,,22,21,24,22,48,,,,,22,,,,111,,21',
-'21,48,,52,,77,21,,23,57,57,57,51,,23,,,,111,29,21,,29,,21,,16,,29,21',
-'61,21,80,,21,,,56,83,83,21,,,,21,,21,23,23,,,48,,,23,,77,48,83,44,,',
-'8,77,,143,143,143,23,,,104,23,,,,,23,21,21,,,107,,21,,9,,,44,44,44,',
-'20,,,,,25,,,8,21,,,,,41,143,,,61,,109,,21,,,,41,,44,44,,44,21,21,52',
-',54,21,,20,20,,,,,,52,,,21,,,,,,,17,23,,,20,,,47,20,44,,54,,20,23,56',
-'34,44,44,16,,34,,,23,23,34,,,23,,,,,,,,21,,17,17,23,21,,,,21,21,,,,',
-',,57,,83,57,83,57,17,,83,,17,,,,21,17,,,,,,21,21,,34,34,34,,54,48,,',
-'20,,,,23,25,25,,23,23,,,33,20,,,9,,,44,,51,,20,20,,21,16,,23,23,,,,',
-'9,18,18,44,,,,18,,,21,,21,21,,,,,48,,,17,,,,,,,25,,25,,83,,17,25,,,',
-'23,,,,,17,17,,,,,,,,,20,,,,20,20,23,23,,,21,52,,9,21,,44,,9,,44,44,22',
-',,21,20,,21,,,,,44,,,,,,,,,,,44,,,21,,,,,,,21,,17,29,23,21,17,17,23',
-',,,,21,,21,20,,,23,,,23,,,,,,17,,,,,,,48,26,20,20,18,18,23,,,,,,,23',
-',44,,,23,,,,,,,,23,,28,,,,28,28,28,,26,17,,,,26,26,,,26,,,28,28,28,',
-'25,,20,,,,17,17,,,,28,28,,,,,20,,,20,,,,,,,,,,,,,,,26,26,26,26,20,,',
-',,,,20,,,,,20,,,,,,,17,20,,,17,,,,25,,25,,25,,,17,,,17,,,,,,,,,25,,',
-',,,,,,,17,,,,,,,17,,,,44,17,,,,,44,,,17,,,,,,,25,,,25,,,,,,,,,,,,26',
-'26,,,,9,9,,44,44,26,,,,,44,,28,28,28,28,28,,,,28,9,,,44,9,,,44,,9,,',
-'44,28,,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28',
-'28,28,28,28,28,,,25,,,,,,28,,28,,,,,28,,,,,,,28,28,,,,,,,,28,,25,,,',
-',,,,9,,,44,25,25,,,,,,,,9,,,44,,,,28,,,9,9,,44,44,,,,44,,,25,,26,26',
-',,53,,,44,,,,,,,,,,,,,,53,,53,53,53,53,53,,25,,,26,,,,,,,,,,,,,,,,,',
-',,,25,,,44,,,,44,44,,,,,,,,,,,,25,,,,,,9,,,44,,,,,,,,,,,,,,,,28,,25',
-',,,,,,,,,,,,,,,,,,,,,,9,,,44,,28,28,,28,28,28,,,,,,,,,,,9,9,,44,44,',
-',,,,,,,26,,,25,,,,28,,28,,28,,,,,,,,,,,25,,,,28,,,,,26,,,,,,,,9,28,25',
-'44,28,,,44,,,,,28,28,28,9,,,44,,53,44,,25,28,,,28,,,,,,,,,,9,,,44,,',
-',9,,,44,,9,,26,44,26,,,,,,,44,,,,28,,,28,,,,,,28,,,,,53,,,53,53,,,,',
-',,,,,,,,,,,,,,,,,,,28,,28,,,28,28,,,37,37,28,,,28,,37,37,37,,,,,,,28',
-',,,,,,37,28,,,,,,,37,37,,,,28,28,,,,,,,,,,,,,,,,,,,,,,,,,,,,,28,,,53',
-',,,,,,,,26,53,,,,,,,,,,,,,,,,,,28,,,,,,,,,,,,,,,,,,,,,,,,28,53,,,,,',
-',,,53,53,53,53,,,,,,,28,28,28,53,53,,,,,,,,,28,28,28,,,,,,,,,,,,28,',
-',,26,,,,,,,,,,,,,,,37,,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37',
-'37,37,37,37,37,37,37,37,37,37,37,,,,,,,,,37,,37,,,28,,37,,,,,,,,,,,',
-'28,28,,,,28,,,,,,,37,,,,,,,,,,,,28,37,,,,,,,,,37,,,,,,,,,,,28,,,,,,',
-',,,,,,,,,,,,,,,,,28,,,,,,,,,,,,,,53,,,,,53,,,,,,53,53,37,,,,,,,,,53',
-',,53,53,,,,,,53,,53,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,37,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,37,37,37,,,,,,,,,,,,,,,,,,,,,,,53,,,,53,,,,37,,37,',
-'37,,,,,,,,,,,,,,,,,,,,,,,,,,,37,,,,,,,,,,,,,37,37,37,,,,,,,,,,37,,,37',
-',,,,,,,,,,,37,,,53,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,53,,,,,,',
-',,,,,,,,53,,,,,,,,37,,37,,,,,,,,,,,,37,,,,,,,,,,,37,,,,,,,,37,,,,,,',
-',,,,,37,37,,,,,,,,,,,37,,,,,,,,,,,,37,,,,,,37,,,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,37,,,,,,,,,,,,,,,,,,,,,,,,37,,,,,,,,,,,,,,,,,,,,37,,,,,,,,,',
-',,,37,37,37,,,,,,,,,,,,37,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,37,,,,,,,,,,,,,,37,37,,,,37,,,,,,,,,37,,,,,,,,,,37',
-',,,,,,,,,,,,,,,,,,,,37' ]
- racc_goto_check = arr = ::Array.new(2500, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_goto_pointer = [
- nil, 226, 113, nil, 70, 108, 39, 13, -290, 608,
- -529, -573, -602, nil, 39, 153, -18, 189, 193, 98,
- 133, 0, -47, 48, -162, 596, 949, 48, 975, -12,
- nil, 157, nil, -147, 285, -231, -349, 1578, 84, 35,
- nil, -23, 83, -283, 611, -281, -13, -58, 18, nil,
- 68, -40, -3, 1246, -19, -190, 46, 67, -41, -274,
- -326, -219, -397, -294, -52, nil, nil, nil, nil, nil,
- nil, nil, 153, 168, 168, nil, 168, -281, -669, -506,
- -350, 166, -136, 13, -563, 169, -143, 186, 179, -641,
- 29, -602, -459, -772, -462, -228, -705, 78, -456, -234,
- -456, -717, 94, -170, -29, -405, -506, -18, -516, -228,
- -536, -369, 142, -82, nil, -107, -107, -767, -411, -528,
- -642, nil, nil, nil, 103, 102, 62, 99, -207, -261,
- 105, -584, -423, -418, nil, -557, nil, -659, nil, -651,
- nil, -555, -662, -295, -653, -324, nil, -515, -247, -510,
- nil, -723, nil, nil, -469 ]
-
-racc_goto_default = [
- nil, nil, nil, 3, nil, 4, 353, 279, nil, 538,
- nil, 831, nil, 278, nil, nil, nil, 212, 16, 11,
- 213, 303, nil, 211, nil, 255, 15, nil, 19, 20,
- 21, nil, 25, 691, nil, nil, nil, 26, 29, nil,
- 31, 34, 33, nil, 209, 363, nil, 116, 435, 115,
- 69, nil, 42, 311, 313, nil, 314, 433, nil, nil,
- 635, 486, 253, nil, nil, 269, 43, 44, 45, 46,
- 47, 48, 49, nil, 270, 55, nil, nil, nil, nil,
- nil, nil, nil, 573, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 326, 325, 709, 328, nil,
- 329, 330, nil, nil, 439, nil, nil, nil, nil, nil,
- nil, 68, 70, 71, 72, nil, nil, nil, nil, 611,
- nil, nil, nil, nil, 395, 750, 753, 758, 755, 756,
- 757, 911, nil, nil, 761, 337, 332, 339, nil, 567,
- 568, 765, 342, 345, 260 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 143, :_reduce_none,
- 2, 144, :_reduce_2,
- 0, 145, :_reduce_3,
- 1, 145, :_reduce_4,
- 3, 145, :_reduce_5,
- 1, 147, :_reduce_none,
- 4, 147, :_reduce_7,
- 4, 150, :_reduce_8,
- 2, 151, :_reduce_9,
- 0, 155, :_reduce_10,
- 1, 155, :_reduce_11,
- 3, 155, :_reduce_12,
- 0, 169, :_reduce_13,
- 4, 149, :_reduce_14,
- 3, 149, :_reduce_15,
- 3, 149, :_reduce_none,
- 3, 149, :_reduce_17,
- 2, 149, :_reduce_18,
- 3, 149, :_reduce_19,
- 3, 149, :_reduce_20,
- 3, 149, :_reduce_21,
- 3, 149, :_reduce_22,
- 3, 149, :_reduce_23,
- 4, 149, :_reduce_none,
- 3, 149, :_reduce_25,
- 3, 149, :_reduce_26,
- 3, 149, :_reduce_27,
- 6, 149, :_reduce_none,
- 6, 149, :_reduce_none,
- 5, 149, :_reduce_30,
- 5, 149, :_reduce_none,
- 5, 149, :_reduce_none,
- 3, 149, :_reduce_none,
- 3, 149, :_reduce_34,
- 3, 149, :_reduce_35,
- 3, 149, :_reduce_36,
- 1, 149, :_reduce_none,
- 1, 168, :_reduce_none,
- 3, 168, :_reduce_39,
- 3, 168, :_reduce_40,
- 2, 168, :_reduce_41,
- 2, 168, :_reduce_42,
- 1, 168, :_reduce_none,
- 1, 158, :_reduce_none,
- 1, 160, :_reduce_none,
- 1, 160, :_reduce_none,
- 2, 160, :_reduce_47,
- 2, 160, :_reduce_48,
- 2, 160, :_reduce_49,
- 1, 172, :_reduce_none,
- 4, 172, :_reduce_none,
- 4, 172, :_reduce_none,
- 4, 172, :_reduce_none,
- 4, 177, :_reduce_none,
- 2, 171, :_reduce_55,
- 3, 171, :_reduce_none,
- 4, 171, :_reduce_57,
- 5, 171, :_reduce_none,
- 4, 171, :_reduce_59,
- 5, 171, :_reduce_none,
- 4, 171, :_reduce_61,
- 5, 171, :_reduce_none,
- 2, 171, :_reduce_63,
- 2, 171, :_reduce_64,
- 1, 161, :_reduce_65,
- 3, 161, :_reduce_66,
- 1, 181, :_reduce_67,
- 3, 181, :_reduce_68,
- 1, 180, :_reduce_69,
- 2, 180, :_reduce_70,
- 3, 180, :_reduce_71,
- 5, 180, :_reduce_none,
- 2, 180, :_reduce_73,
- 4, 180, :_reduce_none,
- 2, 180, :_reduce_75,
- 1, 180, :_reduce_76,
- 3, 180, :_reduce_none,
- 1, 183, :_reduce_78,
- 3, 183, :_reduce_79,
- 2, 182, :_reduce_80,
- 3, 182, :_reduce_81,
- 1, 185, :_reduce_none,
- 3, 185, :_reduce_none,
- 1, 184, :_reduce_84,
- 4, 184, :_reduce_85,
- 3, 184, :_reduce_86,
- 3, 184, :_reduce_none,
- 3, 184, :_reduce_none,
- 3, 184, :_reduce_none,
- 2, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 159, :_reduce_92,
- 4, 159, :_reduce_93,
- 4, 159, :_reduce_94,
- 3, 159, :_reduce_95,
- 3, 159, :_reduce_96,
- 3, 159, :_reduce_97,
- 3, 159, :_reduce_98,
- 2, 159, :_reduce_99,
- 1, 159, :_reduce_none,
- 1, 187, :_reduce_none,
- 2, 188, :_reduce_102,
- 1, 188, :_reduce_103,
- 3, 188, :_reduce_104,
- 1, 189, :_reduce_none,
- 1, 189, :_reduce_none,
- 1, 189, :_reduce_none,
- 1, 189, :_reduce_108,
- 1, 189, :_reduce_109,
- 1, 156, :_reduce_110,
- 1, 156, :_reduce_none,
- 1, 157, :_reduce_112,
- 3, 157, :_reduce_113,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 190, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 1, 191, :_reduce_none,
- 3, 170, :_reduce_188,
- 5, 170, :_reduce_189,
- 3, 170, :_reduce_190,
- 6, 170, :_reduce_191,
- 6, 170, :_reduce_192,
- 5, 170, :_reduce_193,
- 5, 170, :_reduce_none,
- 5, 170, :_reduce_none,
- 5, 170, :_reduce_none,
- 4, 170, :_reduce_none,
- 3, 170, :_reduce_none,
- 3, 170, :_reduce_199,
- 3, 170, :_reduce_200,
- 3, 170, :_reduce_201,
- 3, 170, :_reduce_202,
- 3, 170, :_reduce_203,
- 3, 170, :_reduce_204,
- 3, 170, :_reduce_205,
- 3, 170, :_reduce_206,
- 4, 170, :_reduce_207,
- 4, 170, :_reduce_208,
- 2, 170, :_reduce_209,
- 2, 170, :_reduce_210,
- 3, 170, :_reduce_211,
- 3, 170, :_reduce_212,
- 3, 170, :_reduce_213,
- 3, 170, :_reduce_214,
- 3, 170, :_reduce_215,
- 3, 170, :_reduce_216,
- 3, 170, :_reduce_217,
- 3, 170, :_reduce_218,
- 3, 170, :_reduce_219,
- 3, 170, :_reduce_220,
- 3, 170, :_reduce_221,
- 3, 170, :_reduce_222,
- 3, 170, :_reduce_223,
- 2, 170, :_reduce_224,
- 2, 170, :_reduce_225,
- 3, 170, :_reduce_226,
- 3, 170, :_reduce_227,
- 3, 170, :_reduce_228,
- 3, 170, :_reduce_229,
- 3, 170, :_reduce_230,
- 5, 170, :_reduce_231,
- 1, 170, :_reduce_none,
- 1, 167, :_reduce_none,
- 1, 164, :_reduce_234,
- 2, 164, :_reduce_235,
- 2, 164, :_reduce_236,
- 4, 164, :_reduce_237,
- 2, 164, :_reduce_238,
- 3, 199, :_reduce_239,
- 2, 201, :_reduce_none,
- 1, 202, :_reduce_241,
- 1, 202, :_reduce_none,
- 1, 200, :_reduce_243,
- 1, 200, :_reduce_none,
- 2, 200, :_reduce_245,
- 4, 200, :_reduce_246,
- 2, 200, :_reduce_247,
- 1, 173, :_reduce_248,
- 2, 173, :_reduce_249,
- 2, 173, :_reduce_250,
- 4, 173, :_reduce_251,
- 1, 173, :_reduce_252,
- 4, 205, :_reduce_none,
- 1, 205, :_reduce_none,
- 0, 207, :_reduce_255,
- 2, 176, :_reduce_256,
- 1, 206, :_reduce_none,
- 2, 206, :_reduce_258,
- 3, 206, :_reduce_259,
- 2, 204, :_reduce_260,
- 2, 203, :_reduce_261,
- 0, 203, :_reduce_262,
- 1, 196, :_reduce_263,
- 2, 196, :_reduce_264,
- 3, 196, :_reduce_265,
- 4, 196, :_reduce_266,
- 3, 166, :_reduce_267,
- 4, 166, :_reduce_268,
- 2, 166, :_reduce_269,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 1, 194, :_reduce_none,
- 0, 229, :_reduce_279,
- 4, 194, :_reduce_280,
- 4, 194, :_reduce_281,
- 3, 194, :_reduce_282,
- 3, 194, :_reduce_283,
- 2, 194, :_reduce_284,
- 4, 194, :_reduce_285,
- 4, 194, :_reduce_286,
- 3, 194, :_reduce_287,
- 3, 194, :_reduce_288,
- 1, 194, :_reduce_289,
- 4, 194, :_reduce_290,
- 3, 194, :_reduce_291,
- 1, 194, :_reduce_292,
- 5, 194, :_reduce_293,
- 4, 194, :_reduce_294,
- 3, 194, :_reduce_295,
- 2, 194, :_reduce_296,
- 1, 194, :_reduce_none,
- 2, 194, :_reduce_298,
- 2, 194, :_reduce_299,
- 6, 194, :_reduce_300,
- 6, 194, :_reduce_301,
- 0, 230, :_reduce_302,
- 0, 231, :_reduce_303,
- 7, 194, :_reduce_304,
- 0, 232, :_reduce_305,
- 0, 233, :_reduce_306,
- 7, 194, :_reduce_307,
- 5, 194, :_reduce_308,
- 4, 194, :_reduce_309,
- 5, 194, :_reduce_310,
- 0, 234, :_reduce_311,
- 0, 235, :_reduce_312,
- 9, 194, :_reduce_313,
- 0, 236, :_reduce_314,
- 6, 194, :_reduce_315,
- 0, 237, :_reduce_316,
- 0, 238, :_reduce_317,
- 8, 194, :_reduce_318,
- 0, 239, :_reduce_319,
- 0, 240, :_reduce_320,
- 6, 194, :_reduce_321,
- 0, 241, :_reduce_322,
- 6, 194, :_reduce_323,
- 0, 242, :_reduce_324,
- 0, 243, :_reduce_325,
- 9, 194, :_reduce_326,
- 1, 194, :_reduce_327,
- 1, 194, :_reduce_328,
- 1, 194, :_reduce_329,
- 1, 194, :_reduce_none,
- 1, 163, :_reduce_none,
- 1, 219, :_reduce_none,
- 1, 219, :_reduce_none,
- 1, 219, :_reduce_none,
- 2, 219, :_reduce_none,
- 1, 221, :_reduce_none,
- 1, 221, :_reduce_none,
- 1, 221, :_reduce_none,
- 2, 218, :_reduce_339,
- 3, 244, :_reduce_340,
- 2, 244, :_reduce_341,
- 1, 244, :_reduce_none,
- 1, 244, :_reduce_none,
- 3, 245, :_reduce_344,
- 3, 245, :_reduce_345,
- 1, 220, :_reduce_346,
- 5, 220, :_reduce_347,
- 1, 153, :_reduce_none,
- 2, 153, :_reduce_349,
- 1, 247, :_reduce_350,
- 3, 247, :_reduce_351,
- 3, 248, :_reduce_352,
- 1, 178, :_reduce_none,
- 2, 178, :_reduce_354,
- 1, 178, :_reduce_355,
- 3, 178, :_reduce_356,
- 1, 249, :_reduce_357,
- 2, 251, :_reduce_358,
- 1, 251, :_reduce_359,
- 6, 246, :_reduce_360,
- 4, 246, :_reduce_361,
- 4, 246, :_reduce_362,
- 2, 246, :_reduce_363,
- 2, 246, :_reduce_364,
- 4, 246, :_reduce_365,
- 2, 246, :_reduce_366,
- 2, 246, :_reduce_367,
- 1, 246, :_reduce_368,
- 0, 255, :_reduce_369,
- 5, 254, :_reduce_370,
- 2, 174, :_reduce_371,
- 4, 174, :_reduce_none,
- 4, 174, :_reduce_none,
- 4, 174, :_reduce_none,
- 2, 217, :_reduce_375,
- 4, 217, :_reduce_376,
- 4, 217, :_reduce_377,
- 3, 217, :_reduce_378,
- 4, 217, :_reduce_379,
- 3, 217, :_reduce_380,
- 2, 217, :_reduce_381,
- 1, 217, :_reduce_382,
- 0, 257, :_reduce_383,
- 5, 216, :_reduce_384,
- 0, 258, :_reduce_385,
- 5, 216, :_reduce_386,
- 0, 260, :_reduce_387,
- 6, 222, :_reduce_388,
- 1, 259, :_reduce_389,
- 1, 259, :_reduce_none,
- 6, 152, :_reduce_391,
- 0, 152, :_reduce_392,
- 1, 261, :_reduce_393,
- 1, 261, :_reduce_none,
- 1, 261, :_reduce_none,
- 2, 262, :_reduce_396,
- 1, 262, :_reduce_397,
- 2, 154, :_reduce_398,
- 1, 154, :_reduce_none,
- 1, 208, :_reduce_none,
- 1, 208, :_reduce_none,
- 1, 208, :_reduce_none,
- 1, 209, :_reduce_403,
- 1, 265, :_reduce_none,
- 2, 265, :_reduce_405,
- 3, 266, :_reduce_406,
- 1, 266, :_reduce_407,
- 3, 210, :_reduce_408,
- 3, 211, :_reduce_409,
- 3, 212, :_reduce_410,
- 3, 212, :_reduce_411,
- 1, 269, :_reduce_412,
- 3, 269, :_reduce_413,
- 1, 270, :_reduce_414,
- 2, 270, :_reduce_415,
- 3, 213, :_reduce_416,
- 3, 213, :_reduce_417,
- 1, 272, :_reduce_418,
- 3, 272, :_reduce_419,
- 1, 267, :_reduce_420,
- 2, 267, :_reduce_421,
- 1, 268, :_reduce_422,
- 2, 268, :_reduce_423,
- 1, 271, :_reduce_424,
- 0, 274, :_reduce_425,
- 3, 271, :_reduce_426,
- 0, 275, :_reduce_427,
- 4, 271, :_reduce_428,
- 1, 273, :_reduce_429,
- 1, 273, :_reduce_430,
- 1, 273, :_reduce_431,
- 1, 273, :_reduce_none,
- 2, 192, :_reduce_433,
- 1, 192, :_reduce_434,
- 1, 276, :_reduce_none,
- 1, 276, :_reduce_none,
- 1, 276, :_reduce_none,
- 1, 276, :_reduce_none,
- 3, 264, :_reduce_439,
- 1, 263, :_reduce_440,
- 1, 263, :_reduce_441,
- 2, 263, :_reduce_442,
- 2, 263, :_reduce_443,
- 2, 263, :_reduce_444,
- 2, 263, :_reduce_445,
- 1, 186, :_reduce_446,
- 1, 186, :_reduce_447,
- 1, 186, :_reduce_448,
- 1, 186, :_reduce_449,
- 1, 186, :_reduce_450,
- 1, 186, :_reduce_451,
- 1, 186, :_reduce_452,
- 1, 186, :_reduce_453,
- 1, 186, :_reduce_454,
- 1, 186, :_reduce_455,
- 1, 186, :_reduce_456,
- 1, 214, :_reduce_457,
- 1, 162, :_reduce_458,
- 1, 165, :_reduce_459,
- 1, 165, :_reduce_none,
- 1, 224, :_reduce_461,
- 3, 224, :_reduce_462,
- 2, 224, :_reduce_463,
- 4, 226, :_reduce_464,
- 2, 226, :_reduce_465,
- 1, 278, :_reduce_none,
- 1, 278, :_reduce_none,
- 2, 279, :_reduce_468,
- 1, 279, :_reduce_469,
- 1, 280, :_reduce_470,
- 2, 281, :_reduce_471,
- 1, 281, :_reduce_472,
- 1, 282, :_reduce_473,
- 3, 282, :_reduce_474,
- 4, 283, :_reduce_475,
- 2, 283, :_reduce_476,
- 2, 283, :_reduce_477,
- 1, 283, :_reduce_478,
- 2, 285, :_reduce_479,
- 0, 285, :_reduce_480,
- 6, 277, :_reduce_481,
- 4, 277, :_reduce_482,
- 4, 277, :_reduce_483,
- 2, 277, :_reduce_484,
- 4, 277, :_reduce_485,
- 2, 277, :_reduce_486,
- 2, 277, :_reduce_487,
- 1, 277, :_reduce_488,
- 0, 277, :_reduce_489,
- 1, 287, :_reduce_none,
- 1, 287, :_reduce_491,
- 1, 288, :_reduce_492,
- 1, 288, :_reduce_493,
- 1, 288, :_reduce_494,
- 1, 288, :_reduce_495,
- 1, 289, :_reduce_496,
- 3, 289, :_reduce_497,
- 1, 223, :_reduce_none,
- 1, 223, :_reduce_none,
- 1, 291, :_reduce_500,
- 3, 291, :_reduce_none,
- 1, 292, :_reduce_502,
- 3, 292, :_reduce_503,
- 1, 290, :_reduce_none,
- 4, 290, :_reduce_none,
- 3, 290, :_reduce_none,
- 2, 290, :_reduce_none,
- 1, 290, :_reduce_none,
- 1, 252, :_reduce_509,
- 3, 252, :_reduce_510,
- 3, 293, :_reduce_511,
- 1, 286, :_reduce_512,
- 3, 286, :_reduce_513,
- 1, 294, :_reduce_none,
- 1, 294, :_reduce_none,
- 2, 253, :_reduce_516,
- 1, 253, :_reduce_517,
- 1, 295, :_reduce_none,
- 1, 295, :_reduce_none,
- 2, 250, :_reduce_520,
- 2, 284, :_reduce_521,
- 0, 284, :_reduce_522,
- 1, 227, :_reduce_523,
- 4, 227, :_reduce_524,
- 0, 215, :_reduce_525,
- 2, 215, :_reduce_526,
- 1, 198, :_reduce_527,
- 3, 198, :_reduce_528,
- 3, 296, :_reduce_529,
- 2, 296, :_reduce_530,
- 1, 179, :_reduce_none,
- 1, 179, :_reduce_none,
- 1, 179, :_reduce_none,
- 1, 175, :_reduce_none,
- 1, 175, :_reduce_none,
- 1, 175, :_reduce_none,
- 1, 175, :_reduce_none,
- 1, 256, :_reduce_none,
- 1, 256, :_reduce_none,
- 1, 256, :_reduce_none,
- 1, 228, :_reduce_none,
- 1, 228, :_reduce_none,
- 0, 146, :_reduce_none,
- 1, 146, :_reduce_none,
- 0, 193, :_reduce_none,
- 1, 193, :_reduce_none,
- 0, 197, :_reduce_none,
- 1, 197, :_reduce_none,
- 1, 197, :_reduce_none,
- 1, 225, :_reduce_none,
- 1, 225, :_reduce_none,
- 1, 148, :_reduce_none,
- 2, 148, :_reduce_none,
- 0, 195, :_reduce_554 ]
-
-racc_reduce_n = 555
-
-racc_shift_n = 968
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :kCLASS => 2,
- :kMODULE => 3,
- :kDEF => 4,
- :kUNDEF => 5,
- :kBEGIN => 6,
- :kRESCUE => 7,
- :kENSURE => 8,
- :kEND => 9,
- :kIF => 10,
- :kUNLESS => 11,
- :kTHEN => 12,
- :kELSIF => 13,
- :kELSE => 14,
- :kCASE => 15,
- :kWHEN => 16,
- :kWHILE => 17,
- :kUNTIL => 18,
- :kFOR => 19,
- :kBREAK => 20,
- :kNEXT => 21,
- :kREDO => 22,
- :kRETRY => 23,
- :kIN => 24,
- :kDO => 25,
- :kDO_COND => 26,
- :kDO_BLOCK => 27,
- :kDO_LAMBDA => 28,
- :kRETURN => 29,
- :kYIELD => 30,
- :kSUPER => 31,
- :kSELF => 32,
- :kNIL => 33,
- :kTRUE => 34,
- :kFALSE => 35,
- :kAND => 36,
- :kOR => 37,
- :kNOT => 38,
- :kIF_MOD => 39,
- :kUNLESS_MOD => 40,
- :kWHILE_MOD => 41,
- :kUNTIL_MOD => 42,
- :kRESCUE_MOD => 43,
- :kALIAS => 44,
- :kDEFINED => 45,
- :klBEGIN => 46,
- :klEND => 47,
- :k__LINE__ => 48,
- :k__FILE__ => 49,
- :k__ENCODING__ => 50,
- :tIDENTIFIER => 51,
- :tFID => 52,
- :tGVAR => 53,
- :tIVAR => 54,
- :tCONSTANT => 55,
- :tLABEL => 56,
- :tCVAR => 57,
- :tNTH_REF => 58,
- :tBACK_REF => 59,
- :tSTRING_CONTENT => 60,
- :tINTEGER => 61,
- :tFLOAT => 62,
- :tREGEXP_END => 63,
- :tUPLUS => 64,
- :tUMINUS => 65,
- :tUMINUS_NUM => 66,
- :tPOW => 67,
- :tCMP => 68,
- :tEQ => 69,
- :tEQQ => 70,
- :tNEQ => 71,
- :tGEQ => 72,
- :tLEQ => 73,
- :tANDOP => 74,
- :tOROP => 75,
- :tMATCH => 76,
- :tNMATCH => 77,
- :tJSDOT => 78,
- :tDOT => 79,
- :tDOT2 => 80,
- :tDOT3 => 81,
- :tAREF => 82,
- :tASET => 83,
- :tLSHFT => 84,
- :tRSHFT => 85,
- :tCOLON2 => 86,
- :tCOLON3 => 87,
- :tOP_ASGN => 88,
- :tASSOC => 89,
- :tLPAREN => 90,
- :tLPAREN2 => 91,
- :tRPAREN => 92,
- :tLPAREN_ARG => 93,
- :ARRAY_BEG => 94,
- :tRBRACK => 95,
- :tLBRACE => 96,
- :tLBRACE_ARG => 97,
- :tSTAR => 98,
- :tSTAR2 => 99,
- :tAMPER => 100,
- :tAMPER2 => 101,
- :tTILDE => 102,
- :tPERCENT => 103,
- :tDIVIDE => 104,
- :tPLUS => 105,
- :tMINUS => 106,
- :tLT => 107,
- :tGT => 108,
- :tPIPE => 109,
- :tBANG => 110,
- :tCARET => 111,
- :tLCURLY => 112,
- :tRCURLY => 113,
- :tBACK_REF2 => 114,
- :tSYMBEG => 115,
- :tSTRING_BEG => 116,
- :tXSTRING_BEG => 117,
- :tREGEXP_BEG => 118,
- :tWORDS_BEG => 119,
- :tAWORDS_BEG => 120,
- :tSTRING_DBEG => 121,
- :tSTRING_DVAR => 122,
- :tSTRING_END => 123,
- :tSTRING => 124,
- :tSYMBOL => 125,
- :tNL => 126,
- :tEH => 127,
- :tCOLON => 128,
- :tCOMMA => 129,
- :tSPACE => 130,
- :tSEMI => 131,
- :tLAMBDA => 132,
- :tLAMBEG => 133,
- :tLBRACK2 => 134,
- :tLBRACK => 135,
- :tJSLBRACK => 136,
- :tDSTAR => 137,
- :tEQL => 138,
- :tLOWEST => 139,
- "-@NUM" => 140,
- "+@NUM" => 141 }
-
-racc_nt_base = 142
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "kCLASS",
- "kMODULE",
- "kDEF",
- "kUNDEF",
- "kBEGIN",
- "kRESCUE",
- "kENSURE",
- "kEND",
- "kIF",
- "kUNLESS",
- "kTHEN",
- "kELSIF",
- "kELSE",
- "kCASE",
- "kWHEN",
- "kWHILE",
- "kUNTIL",
- "kFOR",
- "kBREAK",
- "kNEXT",
- "kREDO",
- "kRETRY",
- "kIN",
- "kDO",
- "kDO_COND",
- "kDO_BLOCK",
- "kDO_LAMBDA",
- "kRETURN",
- "kYIELD",
- "kSUPER",
- "kSELF",
- "kNIL",
- "kTRUE",
- "kFALSE",
- "kAND",
- "kOR",
- "kNOT",
- "kIF_MOD",
- "kUNLESS_MOD",
- "kWHILE_MOD",
- "kUNTIL_MOD",
- "kRESCUE_MOD",
- "kALIAS",
- "kDEFINED",
- "klBEGIN",
- "klEND",
- "k__LINE__",
- "k__FILE__",
- "k__ENCODING__",
- "tIDENTIFIER",
- "tFID",
- "tGVAR",
- "tIVAR",
- "tCONSTANT",
- "tLABEL",
- "tCVAR",
- "tNTH_REF",
- "tBACK_REF",
- "tSTRING_CONTENT",
- "tINTEGER",
- "tFLOAT",
- "tREGEXP_END",
- "tUPLUS",
- "tUMINUS",
- "tUMINUS_NUM",
- "tPOW",
- "tCMP",
- "tEQ",
- "tEQQ",
- "tNEQ",
- "tGEQ",
- "tLEQ",
- "tANDOP",
- "tOROP",
- "tMATCH",
- "tNMATCH",
- "tJSDOT",
- "tDOT",
- "tDOT2",
- "tDOT3",
- "tAREF",
- "tASET",
- "tLSHFT",
- "tRSHFT",
- "tCOLON2",
- "tCOLON3",
- "tOP_ASGN",
- "tASSOC",
- "tLPAREN",
- "tLPAREN2",
- "tRPAREN",
- "tLPAREN_ARG",
- "ARRAY_BEG",
- "tRBRACK",
- "tLBRACE",
- "tLBRACE_ARG",
- "tSTAR",
- "tSTAR2",
- "tAMPER",
- "tAMPER2",
- "tTILDE",
- "tPERCENT",
- "tDIVIDE",
- "tPLUS",
- "tMINUS",
- "tLT",
- "tGT",
- "tPIPE",
- "tBANG",
- "tCARET",
- "tLCURLY",
- "tRCURLY",
- "tBACK_REF2",
- "tSYMBEG",
- "tSTRING_BEG",
- "tXSTRING_BEG",
- "tREGEXP_BEG",
- "tWORDS_BEG",
- "tAWORDS_BEG",
- "tSTRING_DBEG",
- "tSTRING_DVAR",
- "tSTRING_END",
- "tSTRING",
- "tSYMBOL",
- "tNL",
- "tEH",
- "tCOLON",
- "tCOMMA",
- "tSPACE",
- "tSEMI",
- "tLAMBDA",
- "tLAMBEG",
- "tLBRACK2",
- "tLBRACK",
- "tJSLBRACK",
- "tDSTAR",
- "tEQL",
- "tLOWEST",
- "\"-@NUM\"",
- "\"+@NUM\"",
- "$start",
- "program",
- "top_compstmt",
- "top_stmts",
- "opt_terms",
- "top_stmt",
- "terms",
- "stmt",
- "bodystmt",
- "compstmt",
- "opt_rescue",
- "opt_else",
- "opt_ensure",
- "stmts",
- "fitem",
- "undef_list",
- "expr_value",
- "lhs",
- "command_call",
- "mlhs",
- "var_lhs",
- "primary_value",
- "aref_args",
- "backref",
- "mrhs",
- "arg_value",
- "expr",
- "@1",
- "arg",
- "command",
- "block_command",
- "call_args",
- "block_call",
- "operation2",
- "command_args",
- "cmd_brace_block",
- "opt_block_var",
- "operation",
- "mlhs_basic",
- "mlhs_entry",
- "mlhs_head",
- "mlhs_item",
- "mlhs_node",
- "mlhs_post",
- "variable",
- "cname",
- "cpath",
- "fname",
- "op",
- "reswords",
- "symbol",
- "opt_nl",
- "primary",
- "none",
- "args",
- "trailer",
- "assocs",
- "paren_args",
- "opt_call_args",
- "rparen",
- "opt_paren_args",
- "opt_block_arg",
- "block_arg",
- "call_args2",
- "open_args",
- "@2",
- "literal",
- "strings",
- "xstring",
- "regexp",
- "words",
- "awords",
- "var_ref",
- "assoc_list",
- "brace_block",
- "method_call",
- "lambda",
- "then",
- "if_tail",
- "do",
- "case_body",
- "for_var",
- "superclass",
- "term",
- "f_arglist",
- "singleton",
- "dot_or_colon",
- "@3",
- "@4",
- "@5",
- "@6",
- "@7",
- "@8",
- "@9",
- "@10",
- "@11",
- "@12",
- "@13",
- "@14",
- "@15",
- "@16",
- "@17",
- "f_larglist",
- "lambda_body",
- "block_param",
- "f_block_optarg",
- "f_block_opt",
- "block_args_tail",
- "f_block_arg",
- "opt_block_args_tail",
- "f_arg",
- "f_rest_arg",
- "do_block",
- "@18",
- "operation3",
- "@19",
- "@20",
- "cases",
- "@21",
- "exc_list",
- "exc_var",
- "numeric",
- "dsym",
- "string",
- "string1",
- "string_contents",
- "xstring_contents",
- "word_list",
- "word",
- "string_content",
- "qword_list",
- "string_dvar",
- "@22",
- "@23",
- "sym",
- "f_args",
- "kwrest_mark",
- "f_kwrest",
- "f_label",
- "f_kw",
- "f_kwarg",
- "args_tail",
- "opt_f_block_arg",
- "opt_args_tail",
- "f_optarg",
- "f_norm_arg",
- "f_bad_arg",
- "f_arg_item",
- "f_margs",
- "f_marg",
- "f_marg_list",
- "f_opt",
- "restarg_mark",
- "blkarg_mark",
- "assoc" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-# reduce 1 omitted
-
-module_eval(<<'.,.,', 'opal.y', 70)
- def _reduce_2(val, _values, result)
- result = new_compstmt val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 75)
- def _reduce_3(val, _values, result)
- result = new_block
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 79)
- def _reduce_4(val, _values, result)
- result = new_block val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 83)
- def _reduce_5(val, _values, result)
- val[0] << val[2]
- result = val[0]
-
- result
- end
-.,.,
-
-# reduce 6 omitted
-
-module_eval(<<'.,.,', 'opal.y', 90)
- def _reduce_7(val, _values, result)
- result = val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 95)
- def _reduce_8(val, _values, result)
- result = new_body(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 100)
- def _reduce_9(val, _values, result)
- result = new_compstmt val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 105)
- def _reduce_10(val, _values, result)
- result = new_block
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 109)
- def _reduce_11(val, _values, result)
- result = new_block val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 113)
- def _reduce_12(val, _values, result)
- val[0] << val[2]
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 119)
- def _reduce_13(val, _values, result)
- lexer.lex_state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 123)
- def _reduce_14(val, _values, result)
- result = new_alias(val[0], val[1], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 127)
- def _reduce_15(val, _values, result)
- result = s(:valias, value(val[1]).to_sym, value(val[2]).to_sym)
-
- result
- end
-.,.,
-
-# reduce 16 omitted
-
-module_eval(<<'.,.,', 'opal.y', 132)
- def _reduce_17(val, _values, result)
- result = s(:valias, value(val[1]).to_sym, value(val[2]).to_sym)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 136)
- def _reduce_18(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 140)
- def _reduce_19(val, _values, result)
- result = new_if(val[1], val[2], val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 144)
- def _reduce_20(val, _values, result)
- result = new_if(val[1], val[2], nil, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 148)
- def _reduce_21(val, _values, result)
- result = new_while(val[1], val[2], val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 152)
- def _reduce_22(val, _values, result)
- result = new_until(val[1], val[2], val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 156)
- def _reduce_23(val, _values, result)
- result = new_rescue_mod(val[1], val[0], val[2])
-
- result
- end
-.,.,
-
-# reduce 24 omitted
-
-module_eval(<<'.,.,', 'opal.y', 161)
- def _reduce_25(val, _values, result)
- result = new_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 165)
- def _reduce_26(val, _values, result)
- result = s(:masgn, val[0], s(:to_ary, val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 169)
- def _reduce_27(val, _values, result)
- result = new_op_asgn val[1], val[0], val[2]
-
- result
- end
-.,.,
-
-# reduce 28 omitted
-
-# reduce 29 omitted
-
-module_eval(<<'.,.,', 'opal.y', 175)
- def _reduce_30(val, _values, result)
- result = s(:op_asgn2, val[0], op_to_setter(val[2]), value(val[3]).to_sym, val[4])
-
- result
- end
-.,.,
-
-# reduce 31 omitted
-
-# reduce 32 omitted
-
-# reduce 33 omitted
-
-module_eval(<<'.,.,', 'opal.y', 182)
- def _reduce_34(val, _values, result)
- result = new_assign val[0], val[1], s(:svalue, val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 186)
- def _reduce_35(val, _values, result)
- result = s(:masgn, val[0], s(:to_ary, val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 190)
- def _reduce_36(val, _values, result)
- result = s(:masgn, val[0], val[2])
-
- result
- end
-.,.,
-
-# reduce 37 omitted
-
-# reduce 38 omitted
-
-module_eval(<<'.,.,', 'opal.y', 197)
- def _reduce_39(val, _values, result)
- result = s(:and, val[0], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 201)
- def _reduce_40(val, _values, result)
- result = s(:or, val[0], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 205)
- def _reduce_41(val, _values, result)
- result = new_unary_call(['!', []], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 209)
- def _reduce_42(val, _values, result)
- result = new_unary_call(val[0], val[1])
-
- result
- end
-.,.,
-
-# reduce 43 omitted
-
-# reduce 44 omitted
-
-# reduce 45 omitted
-
-# reduce 46 omitted
-
-module_eval(<<'.,.,', 'opal.y', 219)
- def _reduce_47(val, _values, result)
- result = new_return(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 223)
- def _reduce_48(val, _values, result)
- result = new_break(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 227)
- def _reduce_49(val, _values, result)
- result = new_next(val[0], val[1])
-
- result
- end
-.,.,
-
-# reduce 50 omitted
-
-# reduce 51 omitted
-
-# reduce 52 omitted
-
-# reduce 53 omitted
-
-# reduce 54 omitted
-
-module_eval(<<'.,.,', 'opal.y', 239)
- def _reduce_55(val, _values, result)
- result = new_call(nil, val[0], val[1])
-
- result
- end
-.,.,
-
-# reduce 56 omitted
-
-module_eval(<<'.,.,', 'opal.y', 244)
- def _reduce_57(val, _values, result)
- result = new_js_call(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-# reduce 58 omitted
-
-module_eval(<<'.,.,', 'opal.y', 249)
- def _reduce_59(val, _values, result)
- result = new_call(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-# reduce 60 omitted
-
-module_eval(<<'.,.,', 'opal.y', 254)
- def _reduce_61(val, _values, result)
- result = new_call(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-# reduce 62 omitted
-
-module_eval(<<'.,.,', 'opal.y', 259)
- def _reduce_63(val, _values, result)
- result = new_super(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 263)
- def _reduce_64(val, _values, result)
- result = new_yield val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 268)
- def _reduce_65(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 272)
- def _reduce_66(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 277)
- def _reduce_67(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 281)
- def _reduce_68(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 286)
- def _reduce_69(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 290)
- def _reduce_70(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 294)
- def _reduce_71(val, _values, result)
- result = val[0] << s(:splat, val[2])
-
- result
- end
-.,.,
-
-# reduce 72 omitted
-
-module_eval(<<'.,.,', 'opal.y', 299)
- def _reduce_73(val, _values, result)
- result = val[0] << s(:splat)
-
- result
- end
-.,.,
-
-# reduce 74 omitted
-
-module_eval(<<'.,.,', 'opal.y', 304)
- def _reduce_75(val, _values, result)
- result = s(:array, s(:splat, val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 308)
- def _reduce_76(val, _values, result)
- result = s(:array, s(:splat))
-
- result
- end
-.,.,
-
-# reduce 77 omitted
-
-module_eval(<<'.,.,', 'opal.y', 314)
- def _reduce_78(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 318)
- def _reduce_79(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 323)
- def _reduce_80(val, _values, result)
- result = s(:array, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 327)
- def _reduce_81(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-# reduce 82 omitted
-
-# reduce 83 omitted
-
-module_eval(<<'.,.,', 'opal.y', 335)
- def _reduce_84(val, _values, result)
- result = new_assignable val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 339)
- def _reduce_85(val, _values, result)
- args = val[2] ? val[2] : []
- result = s(:attrasgn, val[0], :[]=, s(:arglist, *args))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 344)
- def _reduce_86(val, _values, result)
- result = new_call val[0], val[2], []
-
- result
- end
-.,.,
-
-# reduce 87 omitted
-
-# reduce 88 omitted
-
-# reduce 89 omitted
-
-# reduce 90 omitted
-
-# reduce 91 omitted
-
-module_eval(<<'.,.,', 'opal.y', 354)
- def _reduce_92(val, _values, result)
- result = new_assignable val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 358)
- def _reduce_93(val, _values, result)
- result = new_js_attrasgn(val[0], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 362)
- def _reduce_94(val, _values, result)
- result = new_attrasgn(val[0], :[]=, val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 366)
- def _reduce_95(val, _values, result)
- result = new_attrasgn(val[0], op_to_setter(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 370)
- def _reduce_96(val, _values, result)
- result = new_attrasgn(val[0], op_to_setter(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 374)
- def _reduce_97(val, _values, result)
- result = new_attrasgn(val[0], op_to_setter(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 378)
- def _reduce_98(val, _values, result)
- result = new_colon2(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 382)
- def _reduce_99(val, _values, result)
- result = new_colon3(val[0], val[1])
-
- result
- end
-.,.,
-
-# reduce 100 omitted
-
-# reduce 101 omitted
-
-module_eval(<<'.,.,', 'opal.y', 390)
- def _reduce_102(val, _values, result)
- result = new_colon3(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 394)
- def _reduce_103(val, _values, result)
- result = new_const(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 398)
- def _reduce_104(val, _values, result)
- result = new_colon2(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 105 omitted
-
-# reduce 106 omitted
-
-# reduce 107 omitted
-
-module_eval(<<'.,.,', 'opal.y', 406)
- def _reduce_108(val, _values, result)
- lexer.lex_state = :expr_end
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 411)
- def _reduce_109(val, _values, result)
- lexer.lex_state = :expr_end
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 417)
- def _reduce_110(val, _values, result)
- result = new_sym(val[0])
-
- result
- end
-.,.,
-
-# reduce 111 omitted
-
-module_eval(<<'.,.,', 'opal.y', 423)
- def _reduce_112(val, _values, result)
- result = s(:undef, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 427)
- def _reduce_113(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-# reduce 114 omitted
-
-# reduce 115 omitted
-
-# reduce 116 omitted
-
-# reduce 117 omitted
-
-# reduce 118 omitted
-
-# reduce 119 omitted
-
-# reduce 120 omitted
-
-# reduce 121 omitted
-
-# reduce 122 omitted
-
-# reduce 123 omitted
-
-# reduce 124 omitted
-
-# reduce 125 omitted
-
-# reduce 126 omitted
-
-# reduce 127 omitted
-
-# reduce 128 omitted
-
-# reduce 129 omitted
-
-# reduce 130 omitted
-
-# reduce 131 omitted
-
-# reduce 132 omitted
-
-# reduce 133 omitted
-
-# reduce 134 omitted
-
-# reduce 135 omitted
-
-# reduce 136 omitted
-
-# reduce 137 omitted
-
-# reduce 138 omitted
-
-# reduce 139 omitted
-
-# reduce 140 omitted
-
-# reduce 141 omitted
-
-# reduce 142 omitted
-
-# reduce 143 omitted
-
-# reduce 144 omitted
-
-# reduce 145 omitted
-
-# reduce 146 omitted
-
-# reduce 147 omitted
-
-# reduce 148 omitted
-
-# reduce 149 omitted
-
-# reduce 150 omitted
-
-# reduce 151 omitted
-
-# reduce 152 omitted
-
-# reduce 153 omitted
-
-# reduce 154 omitted
-
-# reduce 155 omitted
-
-# reduce 156 omitted
-
-# reduce 157 omitted
-
-# reduce 158 omitted
-
-# reduce 159 omitted
-
-# reduce 160 omitted
-
-# reduce 161 omitted
-
-# reduce 162 omitted
-
-# reduce 163 omitted
-
-# reduce 164 omitted
-
-# reduce 165 omitted
-
-# reduce 166 omitted
-
-# reduce 167 omitted
-
-# reduce 168 omitted
-
-# reduce 169 omitted
-
-# reduce 170 omitted
-
-# reduce 171 omitted
-
-# reduce 172 omitted
-
-# reduce 173 omitted
-
-# reduce 174 omitted
-
-# reduce 175 omitted
-
-# reduce 176 omitted
-
-# reduce 177 omitted
-
-# reduce 178 omitted
-
-# reduce 179 omitted
-
-# reduce 180 omitted
-
-# reduce 181 omitted
-
-# reduce 182 omitted
-
-# reduce 183 omitted
-
-# reduce 184 omitted
-
-# reduce 185 omitted
-
-# reduce 186 omitted
-
-# reduce 187 omitted
-
-module_eval(<<'.,.,', 'opal.y', 447)
- def _reduce_188(val, _values, result)
- result = new_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 451)
- def _reduce_189(val, _values, result)
- result = new_assign val[0], val[1], s(:rescue_mod, val[2], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 455)
- def _reduce_190(val, _values, result)
- result = new_op_asgn val[1], val[0], val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 459)
- def _reduce_191(val, _values, result)
- result = new_op_asgn1(val[0], val[2], val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 463)
- def _reduce_192(val, _values, result)
- raise ".JS[...] #{val[4]} is not supported"
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 467)
- def _reduce_193(val, _values, result)
- result = s(:op_asgn2, val[0], op_to_setter(val[2]), value(val[3]).to_sym, val[4])
-
- result
- end
-.,.,
-
-# reduce 194 omitted
-
-# reduce 195 omitted
-
-# reduce 196 omitted
-
-# reduce 197 omitted
-
-# reduce 198 omitted
-
-module_eval(<<'.,.,', 'opal.y', 476)
- def _reduce_199(val, _values, result)
- result = new_irange(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 480)
- def _reduce_200(val, _values, result)
- result = new_erange(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 484)
- def _reduce_201(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 488)
- def _reduce_202(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 492)
- def _reduce_203(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 496)
- def _reduce_204(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 500)
- def _reduce_205(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 504)
- def _reduce_206(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 508)
- def _reduce_207(val, _values, result)
- result = new_call new_binary_call(new_int(val[1]), val[2], val[3]), [:"-@", []], []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 512)
- def _reduce_208(val, _values, result)
- result = new_call new_binary_call(new_float(val[1]), val[2], val[3]), [:"-@", []], []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 516)
- def _reduce_209(val, _values, result)
- result = new_call val[1], [:"+@", []], []
- if [:int, :float].include? val[1].type
- result = val[1]
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 523)
- def _reduce_210(val, _values, result)
- result = new_call val[1], [:"-@", []], []
- if val[1].type == :int
- val[1][1] = -val[1][1]
- result = val[1]
- elsif val[1].type == :float
- val[1][1] = -val[1][1].to_f
- result = val[1]
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 534)
- def _reduce_211(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 538)
- def _reduce_212(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 542)
- def _reduce_213(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 546)
- def _reduce_214(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 550)
- def _reduce_215(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 554)
- def _reduce_216(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 558)
- def _reduce_217(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 562)
- def _reduce_218(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 566)
- def _reduce_219(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 570)
- def _reduce_220(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 574)
- def _reduce_221(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 578)
- def _reduce_222(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 582)
- def _reduce_223(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 586)
- def _reduce_224(val, _values, result)
- result = new_unary_call(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 590)
- def _reduce_225(val, _values, result)
- result = new_unary_call(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 594)
- def _reduce_226(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 598)
- def _reduce_227(val, _values, result)
- result = new_binary_call(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 602)
- def _reduce_228(val, _values, result)
- result = new_and(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 606)
- def _reduce_229(val, _values, result)
- result = new_or(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 610)
- def _reduce_230(val, _values, result)
- result = s(:defined, val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 614)
- def _reduce_231(val, _values, result)
- result = new_if(val[1], val[0], val[2], val[4])
-
- result
- end
-.,.,
-
-# reduce 232 omitted
-
-# reduce 233 omitted
-
-module_eval(<<'.,.,', 'opal.y', 622)
- def _reduce_234(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 626)
- def _reduce_235(val, _values, result)
- result = [val[0]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 630)
- def _reduce_236(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 634)
- def _reduce_237(val, _values, result)
- val[0] << s(:hash, *val[2])
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 639)
- def _reduce_238(val, _values, result)
- result = [s(:hash, *val[0])]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 644)
- def _reduce_239(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-# reduce 240 omitted
-
-module_eval(<<'.,.,', 'opal.y', 651)
- def _reduce_241(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-# reduce 242 omitted
-
-module_eval(<<'.,.,', 'opal.y', 657)
- def _reduce_243(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-# reduce 244 omitted
-
-module_eval(<<'.,.,', 'opal.y', 662)
- def _reduce_245(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 666)
- def _reduce_246(val, _values, result)
- result = val[0]
- result << new_hash(nil, val[2], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 671)
- def _reduce_247(val, _values, result)
- result = [new_hash(nil, val[0], nil)]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 676)
- def _reduce_248(val, _values, result)
- result = [val[0]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 680)
- def _reduce_249(val, _values, result)
- result = val[0]
- add_block_pass val[0], val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 685)
- def _reduce_250(val, _values, result)
- result = [new_hash(nil, val[0], nil)]
- add_block_pass result, val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 690)
- def _reduce_251(val, _values, result)
- result = val[0]
- result << new_hash(nil, val[2], nil)
- result << val[3] if val[3]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 696)
- def _reduce_252(val, _values, result)
- result = []
- add_block_pass result, val[0]
-
- result
- end
-.,.,
-
-# reduce 253 omitted
-
-# reduce 254 omitted
-
-module_eval(<<'.,.,', 'opal.y', 704)
- def _reduce_255(val, _values, result)
- lexer.cmdarg_push 1
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 708)
- def _reduce_256(val, _values, result)
- lexer.cmdarg_pop
- result = val[1]
-
- result
- end
-.,.,
-
-# reduce 257 omitted
-
-module_eval(<<'.,.,', 'opal.y', 715)
- def _reduce_258(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 719)
- def _reduce_259(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 724)
- def _reduce_260(val, _values, result)
- result = new_block_pass(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 729)
- def _reduce_261(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 733)
- def _reduce_262(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 738)
- def _reduce_263(val, _values, result)
- result = [val[0]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 742)
- def _reduce_264(val, _values, result)
- result = [new_splat(val[0], val[1])]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 746)
- def _reduce_265(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 750)
- def _reduce_266(val, _values, result)
- result = val[0] << new_splat(val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 755)
- def _reduce_267(val, _values, result)
- val[0] << val[2]
- result = s(:array, *val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 760)
- def _reduce_268(val, _values, result)
- val[0] << s(:splat, val[3])
- result = s(:array, *val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 765)
- def _reduce_269(val, _values, result)
- result = s(:splat, val[1])
-
- result
- end
-.,.,
-
-# reduce 270 omitted
-
-# reduce 271 omitted
-
-# reduce 272 omitted
-
-# reduce 273 omitted
-
-# reduce 274 omitted
-
-# reduce 275 omitted
-
-# reduce 276 omitted
-
-# reduce 277 omitted
-
-# reduce 278 omitted
-
-module_eval(<<'.,.,', 'opal.y', 779)
- def _reduce_279(val, _values, result)
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 783)
- def _reduce_280(val, _values, result)
- result = s(:begin, val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 787)
- def _reduce_281(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 791)
- def _reduce_282(val, _values, result)
- result = new_paren(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 795)
- def _reduce_283(val, _values, result)
- result = new_colon2(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 799)
- def _reduce_284(val, _values, result)
- result = new_colon3(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 803)
- def _reduce_285(val, _values, result)
- result = new_call val[0], [:[], []], val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 807)
- def _reduce_286(val, _values, result)
- result = new_js_call val[0], [:[], []], val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 811)
- def _reduce_287(val, _values, result)
- result = new_array(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 815)
- def _reduce_288(val, _values, result)
- result = new_hash(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 819)
- def _reduce_289(val, _values, result)
- result = new_return(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 823)
- def _reduce_290(val, _values, result)
- result = new_yield val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 827)
- def _reduce_291(val, _values, result)
- result = s(:yield)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 831)
- def _reduce_292(val, _values, result)
- result = s(:yield)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 835)
- def _reduce_293(val, _values, result)
- result = s(:defined, val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 839)
- def _reduce_294(val, _values, result)
- result = new_unary_call(['!', []], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 843)
- def _reduce_295(val, _values, result)
- result = new_unary_call(['!', []], new_nil(val[0]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 847)
- def _reduce_296(val, _values, result)
- result = new_call(nil, val[0], [])
- result << val[1]
-
- result
- end
-.,.,
-
-# reduce 297 omitted
-
-module_eval(<<'.,.,', 'opal.y', 853)
- def _reduce_298(val, _values, result)
- val[0] << val[1]
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 858)
- def _reduce_299(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 862)
- def _reduce_300(val, _values, result)
- result = new_if(val[0], val[1], val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 866)
- def _reduce_301(val, _values, result)
- result = new_if(val[0], val[1], val[4], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 870)
- def _reduce_302(val, _values, result)
- lexer.cond_push 1
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 875)
- def _reduce_303(val, _values, result)
- lexer.cond_pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 879)
- def _reduce_304(val, _values, result)
- result = s(:while, val[2], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 883)
- def _reduce_305(val, _values, result)
- lexer.cond_push 1
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 888)
- def _reduce_306(val, _values, result)
- lexer.cond_pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 892)
- def _reduce_307(val, _values, result)
- result = s(:until, val[2], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 896)
- def _reduce_308(val, _values, result)
- result = s(:case, val[1], *val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 900)
- def _reduce_309(val, _values, result)
- result = s(:case, nil, *val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 904)
- def _reduce_310(val, _values, result)
- result = s(:case, nil, val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 908)
- def _reduce_311(val, _values, result)
- lexer.cond_push 1
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 913)
- def _reduce_312(val, _values, result)
- lexer.cond_pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 917)
- def _reduce_313(val, _values, result)
- result = s(:for, val[4], val[1], val[7])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 921)
- def _reduce_314(val, _values, result)
- # ...
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 925)
- def _reduce_315(val, _values, result)
- result = new_class val[0], val[1], val[2], val[4], val[5]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 929)
- def _reduce_316(val, _values, result)
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 933)
- def _reduce_317(val, _values, result)
- # ...
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 937)
- def _reduce_318(val, _values, result)
- result = new_sclass(val[0], val[3], val[6], val[7])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 941)
- def _reduce_319(val, _values, result)
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 945)
- def _reduce_320(val, _values, result)
- # ...
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 949)
- def _reduce_321(val, _values, result)
- result = new_module(val[0], val[2], val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 953)
- def _reduce_322(val, _values, result)
- push_scope
- lexer.lex_state = :expr_endfn
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 958)
- def _reduce_323(val, _values, result)
- result = new_def(val[0], nil, val[1], val[3], val[4], val[5])
- pop_scope
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 963)
- def _reduce_324(val, _values, result)
- lexer.lex_state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 967)
- def _reduce_325(val, _values, result)
- push_scope
- lexer.lex_state = :expr_endfn
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 972)
- def _reduce_326(val, _values, result)
- result = new_def(val[0], val[1], val[4], val[6], val[7], val[8])
- pop_scope
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 977)
- def _reduce_327(val, _values, result)
- result = new_break(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 981)
- def _reduce_328(val, _values, result)
- result = s(:next)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 985)
- def _reduce_329(val, _values, result)
- result = s(:redo)
-
- result
- end
-.,.,
-
-# reduce 330 omitted
-
-# reduce 331 omitted
-
-# reduce 332 omitted
-
-# reduce 333 omitted
-
-# reduce 334 omitted
-
-# reduce 335 omitted
-
-# reduce 336 omitted
-
-# reduce 337 omitted
-
-# reduce 338 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1002)
- def _reduce_339(val, _values, result)
- result = new_call nil, [:lambda, []], []
- result << new_iter(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1008)
- def _reduce_340(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1012)
- def _reduce_341(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-# reduce 342 omitted
-
-# reduce 343 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1019)
- def _reduce_344(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1023)
- def _reduce_345(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1028)
- def _reduce_346(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1032)
- def _reduce_347(val, _values, result)
- result = new_if(val[0], val[1], val[3], val[4])
-
- result
- end
-.,.,
-
-# reduce 348 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1038)
- def _reduce_349(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1043)
- def _reduce_350(val, _values, result)
- result = s(:block, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1047)
- def _reduce_351(val, _values, result)
- val[0] << val[2]
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1053)
- def _reduce_352(val, _values, result)
- result = new_assign(new_assignable(new_ident(
- val[0])), val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 353 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1060)
- def _reduce_354(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1064)
- def _reduce_355(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1068)
- def _reduce_356(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1073)
- def _reduce_357(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1078)
- def _reduce_358(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1082)
- def _reduce_359(val, _values, result)
- nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1087)
- def _reduce_360(val, _values, result)
- result = new_block_args(val[0], val[2], val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1091)
- def _reduce_361(val, _values, result)
- result = new_block_args(val[0], val[2], nil, val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1095)
- def _reduce_362(val, _values, result)
- result = new_block_args(val[0], nil, val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1099)
- def _reduce_363(val, _values, result)
- result = new_block_args(val[0], nil, nil, nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1103)
- def _reduce_364(val, _values, result)
- result = new_block_args(val[0], nil, nil, val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1107)
- def _reduce_365(val, _values, result)
- result = new_block_args(nil, val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1111)
- def _reduce_366(val, _values, result)
- result = new_block_args(nil, val[0], nil, val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1115)
- def _reduce_367(val, _values, result)
- result = new_block_args(nil, nil, val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1119)
- def _reduce_368(val, _values, result)
- result = new_block_args(nil, nil, nil, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1124)
- def _reduce_369(val, _values, result)
- push_scope :block
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1129)
- def _reduce_370(val, _values, result)
- result = new_iter val[2], val[3]
- pop_scope
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1135)
- def _reduce_371(val, _values, result)
- val[0] << val[1]
- result = val[0]
-
- result
- end
-.,.,
-
-# reduce 372 omitted
-
-# reduce 373 omitted
-
-# reduce 374 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1144)
- def _reduce_375(val, _values, result)
- result = new_call(nil, val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1148)
- def _reduce_376(val, _values, result)
- result = new_call(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1152)
- def _reduce_377(val, _values, result)
- result = new_js_call(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1156)
- def _reduce_378(val, _values, result)
- result = new_call(val[0], [:call, []], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1160)
- def _reduce_379(val, _values, result)
- result = new_call(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1164)
- def _reduce_380(val, _values, result)
- result = new_call(val[0], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1168)
- def _reduce_381(val, _values, result)
- result = new_super(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1172)
- def _reduce_382(val, _values, result)
- result = new_super(val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1177)
- def _reduce_383(val, _values, result)
- push_scope :block
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1182)
- def _reduce_384(val, _values, result)
- result = new_iter val[2], val[3]
- pop_scope
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1187)
- def _reduce_385(val, _values, result)
- push_scope :block
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1192)
- def _reduce_386(val, _values, result)
- result = new_iter val[2], val[3]
- pop_scope
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1198)
- def _reduce_387(val, _values, result)
- result = lexer.line
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1202)
- def _reduce_388(val, _values, result)
- part = s(:when, s(:array, *val[2]), val[4])
- result = [part]
- result.push(*val[5]) if val[5]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1209)
- def _reduce_389(val, _values, result)
- result = [val[0]]
-
- result
- end
-.,.,
-
-# reduce 390 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1215)
- def _reduce_391(val, _values, result)
- exc = val[1] || s(:array)
- exc << new_assign(val[2], val[2], s(:gvar, '$!'.intern)) if val[2]
- result = [s(:resbody, exc, val[4])]
- result.push val[5].first if val[5]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1222)
- def _reduce_392(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1227)
- def _reduce_393(val, _values, result)
- result = s(:array, val[0])
-
- result
- end
-.,.,
-
-# reduce 394 omitted
-
-# reduce 395 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1234)
- def _reduce_396(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1238)
- def _reduce_397(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1243)
- def _reduce_398(val, _values, result)
- result = val[1].nil? ? s(:nil) : val[1]
-
- result
- end
-.,.,
-
-# reduce 399 omitted
-
-# reduce 400 omitted
-
-# reduce 401 omitted
-
-# reduce 402 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1253)
- def _reduce_403(val, _values, result)
- result = new_str val[0]
-
- result
- end
-.,.,
-
-# reduce 404 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1259)
- def _reduce_405(val, _values, result)
- result = str_append val[0], val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1264)
- def _reduce_406(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1268)
- def _reduce_407(val, _values, result)
- result = s(:str, value(val[0]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1273)
- def _reduce_408(val, _values, result)
- result = new_xstr(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1278)
- def _reduce_409(val, _values, result)
- result = new_regexp val[1], val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1283)
- def _reduce_410(val, _values, result)
- result = s(:array)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1287)
- def _reduce_411(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1292)
- def _reduce_412(val, _values, result)
- result = s(:array)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1296)
- def _reduce_413(val, _values, result)
- part = val[1]
- part = s(:dstr, "", val[1]) if part.type == :evstr
- result = val[0] << part
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1303)
- def _reduce_414(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1307)
- def _reduce_415(val, _values, result)
- result = val[0].concat([val[1]])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1312)
- def _reduce_416(val, _values, result)
- result = s(:array)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1316)
- def _reduce_417(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1321)
- def _reduce_418(val, _values, result)
- result = s(:array)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1325)
- def _reduce_419(val, _values, result)
- result = val[0] << s(:str, value(val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1330)
- def _reduce_420(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1334)
- def _reduce_421(val, _values, result)
- result = str_append val[0], val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1339)
- def _reduce_422(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1343)
- def _reduce_423(val, _values, result)
- result = str_append val[0], val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1348)
- def _reduce_424(val, _values, result)
- result = new_str_content(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1352)
- def _reduce_425(val, _values, result)
- result = lexer.strterm
- lexer.strterm = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1357)
- def _reduce_426(val, _values, result)
- lexer.strterm = val[1]
- result = new_evstr(val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1362)
- def _reduce_427(val, _values, result)
- lexer.cond_push 0
- lexer.cmdarg_push 0
- result = lexer.strterm
- lexer.strterm = nil
- lexer.lex_state = :expr_beg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1370)
- def _reduce_428(val, _values, result)
- lexer.strterm = val[1]
- lexer.cond_lexpop
- lexer.cmdarg_lexpop
- result = new_evstr(val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1378)
- def _reduce_429(val, _values, result)
- result = new_gvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1382)
- def _reduce_430(val, _values, result)
- result = new_ivar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1386)
- def _reduce_431(val, _values, result)
- result = new_cvar(val[0])
-
- result
- end
-.,.,
-
-# reduce 432 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1393)
- def _reduce_433(val, _values, result)
- result = new_sym(val[1])
- lexer.lex_state = :expr_end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1398)
- def _reduce_434(val, _values, result)
- result = new_sym(val[0])
-
- result
- end
-.,.,
-
-# reduce 435 omitted
-
-# reduce 436 omitted
-
-# reduce 437 omitted
-
-# reduce 438 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1408)
- def _reduce_439(val, _values, result)
- result = new_dsym val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1413)
- def _reduce_440(val, _values, result)
- result = new_int(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1417)
- def _reduce_441(val, _values, result)
- result = new_float(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1421)
- def _reduce_442(val, _values, result)
- result = negate_num(new_int(val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1425)
- def _reduce_443(val, _values, result)
- result = negate_num(new_float(val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1429)
- def _reduce_444(val, _values, result)
- result = new_int(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1433)
- def _reduce_445(val, _values, result)
- result = new_float(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1438)
- def _reduce_446(val, _values, result)
- result = new_ident(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1442)
- def _reduce_447(val, _values, result)
- result = new_ivar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1446)
- def _reduce_448(val, _values, result)
- result = new_gvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1450)
- def _reduce_449(val, _values, result)
- result = new_const(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1454)
- def _reduce_450(val, _values, result)
- result = new_cvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1458)
- def _reduce_451(val, _values, result)
- result = new_nil(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1462)
- def _reduce_452(val, _values, result)
- result = new_self(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1466)
- def _reduce_453(val, _values, result)
- result = new_true(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1470)
- def _reduce_454(val, _values, result)
- result = new_false(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1474)
- def _reduce_455(val, _values, result)
- result = new___FILE__(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1478)
- def _reduce_456(val, _values, result)
- result = new___LINE__(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1483)
- def _reduce_457(val, _values, result)
- result = new_var_ref(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1488)
- def _reduce_458(val, _values, result)
- result = new_assignable val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1493)
- def _reduce_459(val, _values, result)
- result = s(:nth_ref, value(val[0]))
-
- result
- end
-.,.,
-
-# reduce 460 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1499)
- def _reduce_461(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1503)
- def _reduce_462(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1507)
- def _reduce_463(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1512)
- def _reduce_464(val, _values, result)
- result = val[1]
- lexer.lex_state = :expr_beg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1517)
- def _reduce_465(val, _values, result)
- result = val[0]
- lexer.lex_state = :expr_beg
-
- result
- end
-.,.,
-
-# reduce 466 omitted
-
-# reduce 467 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1526)
- def _reduce_468(val, _values, result)
- result = new_kwrestarg(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1530)
- def _reduce_469(val, _values, result)
- result = new_kwrestarg()
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1535)
- def _reduce_470(val, _values, result)
- result = new_sym(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1540)
- def _reduce_471(val, _values, result)
- result = new_kwoptarg(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1544)
- def _reduce_472(val, _values, result)
- result = new_kwarg(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1549)
- def _reduce_473(val, _values, result)
- result = [val[0]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1553)
- def _reduce_474(val, _values, result)
- result = val[0]
- result << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1559)
- def _reduce_475(val, _values, result)
- result = new_args_tail(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1563)
- def _reduce_476(val, _values, result)
- result = new_args_tail(val[0], nil, val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1567)
- def _reduce_477(val, _values, result)
- result = new_args_tail(nil, val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1571)
- def _reduce_478(val, _values, result)
- result = new_args_tail(nil, nil, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1576)
- def _reduce_479(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1580)
- def _reduce_480(val, _values, result)
- result = new_args_tail(nil, nil, nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1585)
- def _reduce_481(val, _values, result)
- result = new_args(val[0], val[2], val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1589)
- def _reduce_482(val, _values, result)
- result = new_args(val[0], val[2], nil, val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1593)
- def _reduce_483(val, _values, result)
- result = new_args(val[0], nil, val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1597)
- def _reduce_484(val, _values, result)
- result = new_args(val[0], nil, nil, val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1601)
- def _reduce_485(val, _values, result)
- result = new_args(nil, val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1605)
- def _reduce_486(val, _values, result)
- result = new_args(nil, val[0], nil, val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1609)
- def _reduce_487(val, _values, result)
- result = new_args(nil, nil, val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1613)
- def _reduce_488(val, _values, result)
- result = new_args(nil, nil, nil, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1617)
- def _reduce_489(val, _values, result)
- result = new_args(nil, nil, nil, nil)
-
- result
- end
-.,.,
-
-# reduce 490 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1623)
- def _reduce_491(val, _values, result)
- result = value(val[0]).to_sym
- scope.add_local result
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1629)
- def _reduce_492(val, _values, result)
- raise 'formal argument cannot be a constant'
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1633)
- def _reduce_493(val, _values, result)
- raise 'formal argument cannot be an instance variable'
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1637)
- def _reduce_494(val, _values, result)
- raise 'formal argument cannot be a class variable'
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1641)
- def _reduce_495(val, _values, result)
- raise 'formal argument cannot be a global variable'
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1646)
- def _reduce_496(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1650)
- def _reduce_497(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-# reduce 498 omitted
-
-# reduce 499 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1658)
- def _reduce_500(val, _values, result)
- result = s(:lasgn, val[0])
-
- result
- end
-.,.,
-
-# reduce 501 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1664)
- def _reduce_502(val, _values, result)
- result = s(:array, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1668)
- def _reduce_503(val, _values, result)
- val[0] << val[2]
- result = val[0]
-
- result
- end
-.,.,
-
-# reduce 504 omitted
-
-# reduce 505 omitted
-
-# reduce 506 omitted
-
-# reduce 507 omitted
-
-# reduce 508 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1680)
- def _reduce_509(val, _values, result)
- result = [val[0]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1684)
- def _reduce_510(val, _values, result)
- val[0] << val[2]
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1690)
- def _reduce_511(val, _values, result)
- result = new_assign(new_assignable(new_ident(val[0])), val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1695)
- def _reduce_512(val, _values, result)
- result = s(:block, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1699)
- def _reduce_513(val, _values, result)
- result = val[0]
- val[0] << val[2]
-
- result
- end
-.,.,
-
-# reduce 514 omitted
-
-# reduce 515 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1708)
- def _reduce_516(val, _values, result)
- result = "*#{value(val[1])}".to_sym
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1712)
- def _reduce_517(val, _values, result)
- result = :"*"
-
- result
- end
-.,.,
-
-# reduce 518 omitted
-
-# reduce 519 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1720)
- def _reduce_520(val, _values, result)
- result = "&#{value(val[1])}".to_sym
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1725)
- def _reduce_521(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1729)
- def _reduce_522(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1734)
- def _reduce_523(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1738)
- def _reduce_524(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1743)
- def _reduce_525(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1747)
- def _reduce_526(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1752)
- def _reduce_527(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1756)
- def _reduce_528(val, _values, result)
- result = val[0].push(*val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1761)
- def _reduce_529(val, _values, result)
- result = [val[0], val[2]]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'opal.y', 1765)
- def _reduce_530(val, _values, result)
- result = [new_sym(val[0]), val[1]]
-
- result
- end
-.,.,
-
-# reduce 531 omitted
-
-# reduce 532 omitted
-
-# reduce 533 omitted
-
-# reduce 534 omitted
-
-# reduce 535 omitted
-
-# reduce 536 omitted
-
-# reduce 537 omitted
-
-# reduce 538 omitted
-
-# reduce 539 omitted
-
-# reduce 540 omitted
-
-# reduce 541 omitted
-
-# reduce 542 omitted
-
-# reduce 543 omitted
-
-# reduce 544 omitted
-
-# reduce 545 omitted
-
-# reduce 546 omitted
-
-# reduce 547 omitted
-
-# reduce 548 omitted
-
-# reduce 549 omitted
-
-# reduce 550 omitted
-
-# reduce 551 omitted
-
-# reduce 552 omitted
-
-# reduce 553 omitted
-
-module_eval(<<'.,.,', 'opal.y', 1802)
- def _reduce_554(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module Opal
diff --git a/test/racc/regress/php_serialization b/test/racc/regress/php_serialization
deleted file mode 100644
index 0aba4b4d3e..0000000000
--- a/test/racc/regress/php_serialization
+++ /dev/null
@@ -1,336 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-require 'php_serialization/tokenizer'
-
-module PhpSerialization
- class Unserializer < Racc::Parser
-
-module_eval(<<'...end php_serialization.y/module_eval...', 'php_serialization.y', 84)
- def initialize(tokenizer_klass = Tokenizer)
- @tokenizer_klass = tokenizer_klass
- end
-
- def run(string)
- @tokenizer = @tokenizer_klass.new(string)
- yyparse(@tokenizer, :each)
- return @object
- ensure
- @tokenizer = nil
- end
-
- def next_token
- @tokenizer.next_token
- end
-...end php_serialization.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 9, 10, 18, 20, 11, 12, 13, 21, 14, 9,
- 10, 15, 22, 11, 12, 13, 23, 14, 24, 46,
- 15, 9, 10, 25, 26, 11, 12, 13, 27, 14,
- 9, 10, 15, 28, 11, 12, 13, 29, 14, 30,
- 51, 15, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 43, 49, 47, 16, 17, 19 ]
-
-racc_action_check = [
- 0, 0, 3, 5, 0, 0, 0, 6, 0, 42,
- 42, 0, 10, 42, 42, 42, 11, 42, 12, 42,
- 42, 45, 45, 13, 14, 45, 45, 45, 15, 45,
- 50, 50, 45, 16, 50, 50, 50, 22, 50, 23,
- 50, 50, 24, 25, 26, 27, 32, 33, 34, 35,
- 36, 37, 39, 41, 47, 43, 1, 2, 4 ]
-
-racc_action_pointer = [
- -3, 56, 55, 0, 56, 1, 5, nil, nil, nil,
- 7, 11, 13, 18, 19, 23, 33, nil, nil, nil,
- nil, nil, 31, 33, 36, 37, 38, 39, nil, nil,
- nil, nil, 41, 42, 43, 39, 40, 39, nil, 47,
- nil, 47, 6, 50, nil, 18, nil, 42, nil, nil,
- 27, nil ]
-
-racc_action_default = [
- -18, -18, -18, -18, -18, -18, -18, -6, -7, -8,
- -18, -18, -18, -18, -18, -18, -18, -1, -2, -3,
- -4, -5, -18, -18, -18, -18, -18, -18, 52, -9,
- -10, -11, -18, -18, -18, -18, -18, -18, -12, -18,
- -15, -18, -18, -18, -14, -18, -17, -18, -16, -15,
- -18, -13 ]
-
-racc_goto_table = [
- 1, 42, nil, nil, nil, nil, nil, nil, nil, nil,
- 50, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 48 ]
-
-racc_goto_check = [
- 1, 9, nil, nil, nil, nil, nil, nil, nil, nil,
- 9, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 1 ]
-
-racc_goto_pointer = [
- nil, 0, nil, nil, nil, nil, nil, nil, nil, -39,
- nil ]
-
-racc_goto_default = [
- nil, 45, 2, 3, 4, 5, 6, 7, 8, nil,
- 44 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 2, 16, :_reduce_1,
- 2, 16, :_reduce_2,
- 2, 16, :_reduce_3,
- 2, 16, :_reduce_4,
- 2, 16, :_reduce_5,
- 1, 16, :_reduce_6,
- 1, 16, :_reduce_7,
- 1, 17, :_reduce_8,
- 3, 18, :_reduce_9,
- 3, 19, :_reduce_10,
- 3, 20, :_reduce_11,
- 5, 21, :_reduce_12,
- 11, 23, :_reduce_13,
- 2, 24, :_reduce_14,
- 0, 24, :_reduce_15,
- 2, 25, :_reduce_16,
- 7, 22, :_reduce_17 ]
-
-racc_reduce_n = 18
-
-racc_shift_n = 52
-
-racc_token_table = {
- false => 0,
- :error => 1,
- ";" => 2,
- "N" => 3,
- "b" => 4,
- ":" => 5,
- :NUMBER => 6,
- "i" => 7,
- "d" => 8,
- "s" => 9,
- :STRING => 10,
- "O" => 11,
- "{" => 12,
- "}" => 13,
- "a" => 14 }
-
-racc_nt_base = 15
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "\";\"",
- "\"N\"",
- "\"b\"",
- "\":\"",
- "NUMBER",
- "\"i\"",
- "\"d\"",
- "\"s\"",
- "STRING",
- "\"O\"",
- "\"{\"",
- "\"}\"",
- "\"a\"",
- "$start",
- "data",
- "null",
- "bool",
- "integer",
- "double",
- "string",
- "assoc_array",
- "object",
- "attribute_list",
- "attribute" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'php_serialization.y', 6)
- def _reduce_1(val, _values, result)
- @object = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 7)
- def _reduce_2(val, _values, result)
- @object = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 8)
- def _reduce_3(val, _values, result)
- @object = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 9)
- def _reduce_4(val, _values, result)
- @object = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 10)
- def _reduce_5(val, _values, result)
- @object = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 11)
- def _reduce_6(val, _values, result)
- @object = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 12)
- def _reduce_7(val, _values, result)
- @object = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 15)
- def _reduce_8(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 18)
- def _reduce_9(val, _values, result)
- result = Integer(val[2]) > 0
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 21)
- def _reduce_10(val, _values, result)
- result = Integer(val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 24)
- def _reduce_11(val, _values, result)
- result = Float(val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 27)
- def _reduce_12(val, _values, result)
- result = val[4]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 32)
- def _reduce_13(val, _values, result)
- if eval("defined?(#{val[4]})")
- result = Object.const_get(val[4]).new
-
- val[9].each do |(attr_name, value)|
- # Protected and private attributes will have a \0..\0 prefix
- attr_name = attr_name.gsub(/\A\\0[^\\]+\\0/, '')
- result.instance_variable_set("@#{attr_name}", value)
- end
- else
- klass_name = val[4].gsub(/^Struct::/, '')
- attr_names, values = [], []
-
- val[9].each do |(attr_name, value)|
- # Protected and private attributes will have a \0..\0 prefix
- attr_names << attr_name.gsub(/\A\\0[^\\]+\\0/, '')
- values << value
- end
-
- result = Struct.new(klass_name, *attr_names).new(*values)
- result.instance_variable_set("@_php_class", klass_name)
- end
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 56)
- def _reduce_14(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 57)
- def _reduce_15(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 60)
- def _reduce_16(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'php_serialization.y', 65)
- def _reduce_17(val, _values, result)
- # Checks if the keys are a sequence of integers
- idx = -1
- arr = val[5].all? { |(k,v)| k == (idx += 1) }
-
- if arr
- result = val[5].map { |(k,v)| v }
- else
- result = Hash[val[5]]
- end
-
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Unserializer
-end # module PhpSerialization
diff --git a/test/racc/regress/riml b/test/racc/regress/riml
deleted file mode 100644
index ce7f845426..0000000000
--- a/test/racc/regress/riml
+++ /dev/null
@@ -1,3297 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
- require File.expand_path("../lexer", __FILE__)
- require File.expand_path("../nodes", __FILE__)
- require File.expand_path("../errors", __FILE__)
- require File.expand_path("../ast_rewriter", __FILE__)
-module Riml
- class Parser < Racc::Parser
-
-module_eval(<<'...end riml.y/module_eval...', 'riml.y', 592)
- # This code will be put as-is in the parser class
-
- attr_accessor :ast_rewriter
- attr_writer :options
-
- # The Parser and AST_Rewriter share this same hash of options
- def options
- @options ||= {}
- end
-
- def self.ast_cache
- @ast_cache
- end
- @ast_cache = {}
-
- # parses tokens or code into output nodes
- def parse(object, ast_rewriter = Riml::AST_Rewriter.new, filename = nil, included = false)
- if (ast = self.class.ast_cache[filename])
- else
- if tokens?(object)
- @tokens = object
- elsif code?(object)
- @lexer = Riml::Lexer.new(object, filename, true)
- end
-
- begin
- ast = do_parse
- rescue Racc::ParseError => e
- raise unless @lexer
- if (invalid_token = @lexer.prev_token_is_keyword?)
- warning = "#{invalid_token.inspect} is a keyword, and cannot " \
- "be used as a variable name"
- end
- error_msg = e.message
- error_msg << "\nWARNING: #{warning}" if warning
- error = Riml::ParseError.new(error_msg, @lexer.filename, @lexer.lineno)
- raise error
- end
- self.class.ast_cache[filename] = ast if filename
- end
- @ast_rewriter ||= ast_rewriter
- return ast unless @ast_rewriter
- @ast_rewriter.ast = ast.dup
- @ast_rewriter.options ||= options
- @ast_rewriter.rewrite(filename, included)
- @ast_rewriter.ast
- end
-
- # get the next token from either the list of tokens provided, or
- # the lexer getting the next token
- def next_token
- return @tokens.shift unless @lexer
- token = @lexer.next_token
- if token && @lexer.parser_info
- @current_parser_info = token.pop
- end
- token
- end
-
- private
-
- def tokens?(object)
- Array === object
- end
-
- def code?(object)
- String === object
- end
-
- def make_node(racc_val)
- node = yield racc_val
- node.parser_info = @current_parser_info
- node
- end
-...end riml.y/module_eval...
-##### State transition tables begin ###
-
-clist = [
-'135,211,60,265,136,139,417,418,211,211,448,211,409,411,146,56,199,89',
-'272,258,409,270,409,271,37,46,48,47,37,49,44,45,64,449,37,392,412,60',
-'50,70,-116,61,60,50,70,62,63,129,130,132,127,128,131,115,116,117,121',
-'122,123,118,119,120,124,125,126,102,104,103,109,111,110,112,114,113',
-'106,108,107,133,134,101,100,137,188,80,38,52,37,81,38,82,85,83,84,87',
-'38,105,86,37,75,76,153,152,57,56,88,89,77,37,90,58,59,78,37,46,48,47',
-'91,49,44,45,64,72,73,-116,211,60,50,70,79,61,48,47,319,62,63,409,274',
-'-178,-178,-178,-178,60,147,273,329,316,38,-43,-43,317,331,-85,-85,-85',
-'-85,48,47,38,320,258,141,-42,-42,313,272,161,60,38,139,271,29,161,38',
-'52,313,54,129,130,132,127,128,131,115,116,117,121,122,123,118,119,120',
-'124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133,134',
-'101,100,137,182,80,277,279,164,81,164,82,85,83,84,87,164,105,86,164',
-'75,76,149,277,57,56,88,89,77,149,90,58,59,78,37,46,48,47,91,49,44,45',
-'64,72,73,-116,279,60,50,70,79,61,149,-204,462,62,63,384,164,164,400',
-'277,60,386,385,149,401,-178,-178,-178,-178,-99,147,-48,-48,164,-176',
-'-176,-176,-176,-44,-44,211,402,48,47,463,49,-98,60,50,70,29,403,38,52',
-'80,54,164,216,81,139,82,85,83,84,87,149,279,86,52,75,76,164,139,57,56',
-'88,89,77,-99,90,58,59,78,37,46,48,47,91,49,44,45,64,72,73,-116,-98,60',
-'50,70,79,61,371,-46,-46,62,63,-175,-175,-175,-175,60,50,70,-203,-47',
-'-47,-45,-45,164,153,152,129,130,132,211,215,48,47,371,49,191,192,193',
-'194,305,433,366,432,129,130,132,29,60,38,52,80,54,406,370,81,60,82,85',
-'83,84,87,149,465,86,99,75,76,153,152,57,56,88,89,77,105,90,58,59,78',
-'37,46,48,47,91,49,44,45,64,72,73,-116,105,60,50,70,79,61,164,354,323',
-'62,63,-175,-175,-175,-175,417,437,153,152,60,211,195,211,211,427,60',
-'139,430,92,431,434,435,438,440,320,441,442,443,211,129,130,132,127,128',
-'131,445,29,105,38,52,446,54,129,130,132,127,128,131,115,116,117,121',
-'122,123,118,119,120,124,125,126,102,104,103,109,111,110,112,114,113',
-'106,108,107,133,134,101,100,137,105,80,129,130,132,81,371,82,85,83,84',
-'87,371,105,86,105,75,76,149,342,57,56,88,89,77,105,90,58,59,78,37,46',
-'48,47,91,49,44,45,64,72,73,302,346,60,50,70,79,61,328,327,105,62,63',
-'326,312,129,130,132,127,128,131,115,116,117,121,122,123,118,119,120',
-'124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133,134',
-'101,29,139,38,52,80,54,105,306,81,305,82,85,83,84,87,105,333,86,139',
-'75,76,149,357,57,56,88,89,77,295,90,58,59,78,37,46,48,47,91,49,44,45',
-'64,72,73,294,149,60,50,70,79,61,361,258,362,62,63,363,276,129,130,132',
-'127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,102,104',
-'103,109,111,110,112,114,113,106,108,107,133,134,60,29,211,38,52,80,54',
-'458,435,81,368,82,85,83,84,87,105,258,86,269,75,76,374,269,57,56,88',
-'89,77,269,90,58,59,78,37,46,48,47,91,49,44,45,64,72,73,377,267,60,50',
-'70,79,61,379,380,263,62,63,262,393,129,130,132,127,128,131,115,116,117',
-'121,122,123,118,119,120,124,125,126,302,394,218,468,397,139,142,269',
-',,,129,130,132,,29,,38,52,80,54,,,81,-245,82,85,83,84,87,105,,86,,75',
-'76,,,57,56,88,89,77,,90,58,59,78,37,46,48,47,91,49,44,45,64,72,73,105',
-',60,50,70,79,61,,,,62,63,,,129,130,132,127,128,131,115,116,117,121,122',
-'123,118,119,120,124,125,126,,,,,,,,,,,,129,130,132,,29,,38,52,80,54',
-',,81,,82,85,83,84,87,105,,86,,75,76,,,57,56,88,89,77,,90,58,59,78,37',
-'46,48,47,91,49,44,45,64,72,73,105,,60,50,70,79,61,,,,62,63,419,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,29,,38,52,,54,,129,130,132,127,128,131',
-'115,116,117,121,122,123,118,119,120,124,125,126,102,104,103,109,111',
-'110,112,114,113,106,108,107,133,134,101,100,137,414,,,,,,,,,146,56,',
-'89,105,,90,,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,129,130',
-'132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,102',
-'104,103,109,111,110,112,114,113,106,108,107,133,134,101,100,137,29,',
-',52,,54,,261,146,56,,89,,105,90,,,,,46,48,47,,49,44,45,64,,,,,60,50',
-'70,,61,,,,62,63,180,146,56,,89,,,90,,,,,46,48,47,,49,44,45,64,,,,,60',
-'50,70,,61,,,,62,63,,29,,,52,,54,,261,129,130,132,127,128,131,115,116',
-'117,121,122,123,118,119,120,124,125,126,,,,365,146,56,,89,29,-119,90',
-'52,,54,,46,48,47,,49,44,45,64,,,,,60,50,70,105,61,,,,62,63,180,146,56',
-',89,,,90,,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,,29,146',
-'56,52,89,54,,90,,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63',
-'29,-121,,52,,54,,,,129,130,132,127,128,131,115,116,117,121,122,123,118',
-'119,120,124,125,126,,,,180,146,56,,89,29,,90,52,,54,350,46,48,47,,49',
-'44,45,64,,,,,60,50,70,105,61,,,,62,63,180,146,56,,89,,,90,,,,,46,48',
-'47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,,29,-119,,52,,54,,,129,130',
-'132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,,,,180',
-'146,56,,89,29,-119,90,52,,54,,46,48,47,,49,44,45,64,,,,,60,50,70,105',
-'61,,,,62,63,180,146,56,,89,,,90,,,,,46,48,47,,49,44,45,64,,,,,60,50',
-'70,,61,,,,62,63,,29,-119,,52,,54,,,129,130,132,127,128,131,115,116,117',
-'121,122,123,118,119,120,124,125,126,,,,180,146,56,,89,29,-119,90,52',
-',54,,46,48,47,,49,44,45,64,,,,,60,50,70,105,61,,,,62,63,180,146,56,',
-'89,,,90,,,,,46,48,47,,49,44,45,64,,,-116,,60,50,70,,61,,,,62,63,,29',
-'-119,,52,,54,,129,130,132,127,128,131,115,116,117,121,122,123,118,119',
-'120,124,125,126,,,,180,146,56,,89,,176,90,,52,,54,46,48,47,,49,44,45',
-'64,,,,,60,50,70,105,61,,,,62,63,180,146,56,,89,,,90,,,,,46,48,47,,49',
-'44,45,64,,,,,60,50,70,,61,,,,62,63,,29,-119,,52,,54,,,129,130,132,127',
-'128,131,115,116,117,121,122,123,118,119,120,124,125,126,,,,180,146,56',
-',89,29,-119,90,52,,54,,46,48,47,,49,44,45,64,,,,,60,50,70,105,61,,,',
-'62,63,146,56,,89,,,90,,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,',
-'62,63,,,29,-119,,52,,54,129,130,132,127,128,131,115,116,117,121,122',
-'123,118,119,120,124,125,126,,,,,146,56,,89,,29,90,,52,,54,46,48,47,',
-'49,44,45,64,,,,,60,50,70,105,61,,,,62,63,146,56,,89,,,90,,,,,46,48,47',
-',49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46',
-'48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54',
-',,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52',
-'90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89',
-',52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56',
-'29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146',
-'56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63',
-'146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,',
-'62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,',
-'61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50',
-'70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,',
-'60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64',
-',,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44',
-'45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,',
-'49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48',
-'47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,',
-'46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90',
-'54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,',
-'52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29',
-'89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146',
-'56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63',
-'146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,',
-'62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,',
-'61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50',
-'70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,',
-'60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64',
-',,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44',
-'45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,',
-'49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48',
-'47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,',
-'46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90',
-'54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,,,29,,,52,348',
-'54,129,130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125',
-'126,,,,,146,56,,89,,29,90,,52,,54,46,48,47,,49,44,45,64,,,,,60,50,70',
-'105,61,,,,62,63,146,56,,89,,,90,,,,,46,48,47,,49,44,45,64,,,,,60,50',
-'70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,',
-'60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64',
-',,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44',
-'45,64,,,-116,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48',
-'47,,49,44,45,64,,,-116,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54',
-',,167,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,',
-'52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,165',
-'89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146',
-'56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63',
-'146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,-116,,60,50,70,,61',
-',,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70',
-',61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60',
-'50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,',
-',,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45',
-'64,,,-116,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47',
-',49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46',
-'48,47,,49,44,45,64,,,-116,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90',
-'54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,',
-'52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29',
-'89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146',
-'56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63',
-'146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,',
-'62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,',
-'61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50',
-'70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,',
-'60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64',
-',,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44',
-'45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,',
-'49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48',
-'47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,',
-'46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90',
-'54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,',
-'52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29',
-'89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146',
-'56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63',
-'146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,',
-'62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,',
-'61,,,,62,63,146,56,29,89,,52,90,288,,,,46,48,47,,49,44,45,64,,,,,60',
-'50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,',
-',-116,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46,48,47,,49',
-'44,45,64,,,-116,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,54,,,,46',
-'48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52,90,288',
-',,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89,,52',
-'90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56,29,89',
-',52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146,56',
-'29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63,146',
-'56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,,62,63',
-'146,56,29,89,,52,90,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61,,,',
-'62,63,146,56,29,89,,52,,54,,,,46,48,47,,49,44,45,64,,,,,60,50,70,,61',
-',,,62,63,146,56,29,89,,52,,54,,,,46,48,47,,49,44,45,,,,,,60,50,70,,61',
-',,,62,63,146,56,188,89,,52,,,,,,46,48,47,,49,44,45,,,,,,60,50,70,,61',
-',,,62,63,,,171,,,173,,,,,,,,,,,,,,,,211,,,,,,129,130,132,127,128,131',
-',,188,,,52,129,130,132,127,128,131,115,116,117,121,122,123,118,119,120',
-'124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133,134',
-'101,100,137,460,105,,,,,129,130,132,127,128,131,,105,,,,,129,130,132',
-'127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,102,104',
-'103,109,111,110,112,114,113,106,108,107,133,134,101,100,137,211,105',
-',,,,129,130,132,127,128,131,,105,,,,,129,130,132,127,128,131,115,116',
-'117,121,122,123,118,119,120,124,125,126,102,104,103,109,111,110,112',
-'114,113,106,108,107,133,134,101,100,137,211,105,,,,,129,130,132,127',
-'128,131,,105,,,,,129,130,132,127,128,131,115,116,117,121,122,123,118',
-'119,120,124,125,126,102,104,103,109,111,110,112,114,113,106,108,107',
-'133,134,101,100,137,455,105,,,,,129,130,132,127,128,131,,105,,,,,129',
-'130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126',
-'102,104,103,109,111,110,112,114,113,106,108,107,133,134,101,100,137',
-'211,105,,,,,129,130,132,127,128,131,,105,,,,,129,130,132,127,128,131',
-'115,116,117,121,122,123,118,119,120,124,125,126,102,104,103,109,111',
-'110,112,114,113,106,108,107,133,134,101,100,137,211,105,,,,129,130,132',
-'127,128,131,,,105,,,,,129,130,132,127,128,131,115,116,117,121,122,123',
-'118,119,120,124,125,126,102,104,103,109,111,110,112,114,113,106,108',
-'107,133,134,101,100,137,105,129,130,132,127,128,131,129,130,132,127',
-'128,131,105,129,130,132,127,128,131,115,116,117,121,122,123,118,119',
-'120,124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133',
-'134,101,100,137,105,,,,,,105,,,,,,,105,129,130,132,127,128,131,115,116',
-'117,121,122,123,118,119,120,124,125,126,102,104,103,109,111,110,112',
-'114,113,106,108,107,133,134,101,100,137,,,,,,,266,129,130,132,127,128',
-'131,105,129,130,132,127,128,131,115,116,117,121,122,123,118,119,120',
-'124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133,134',
-'101,100,137,,,,,,,105,129,130,132,127,128,131,105,129,130,132,127,128',
-'131,115,116,117,121,122,123,118,119,120,124,125,126,102,104,103,109',
-'111,110,112,114,113,106,108,107,133,134,101,100,137,,,,,,,105,,,,,,275',
-'105,129,130,132,127,128,131,115,116,117,121,122,123,118,119,120,124',
-'125,126,102,104,103,109,111,110,112,114,113,106,108,107,133,134,101',
-'100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117,121,122',
-'123,118,119,120,124,125,126,102,104,103,109,111,110,112,114,113,106',
-'108,107,133,134,101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131',
-'115,116,117,121,122,123,118,119,120,124,125,126,102,104,103,109,111',
-'110,112,114,113,106,108,107,133,134,101,100,137,,,,,,,,,,,,,,105,129',
-'130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126',
-'102,104,103,109,111,110,112,114,113,106,108,107,133,134,101,100,137',
-',,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117,121,122,123,118',
-'119,120,124,125,126,129,130,132,127,128,131,115,116,117,121,122,123',
-'118,119,120,124,125,126,,,,,,,,,,,,,105,,,,,,,,,,,,,,,,,,105,129,130',
-'132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,102',
-'104,103,109,111,110,112,114,113,106,108,107,,,,,,,,,,,,,,,,,,,105,129',
-'130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126',
-'102,104,103,109,111,110,112,114,113,106,108,107,,,,,,,,,,,,,,,,,,,105',
-'129,130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125',
-'126,102,104,103,109,111,110,112,114,113,106,108,107,133,134,101,100',
-'137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117,121,122,123',
-'118,119,120,124,125,126,102,104,103,109,111,110,112,114,113,106,108',
-'107,133,134,101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115',
-'116,117,121,122,123,118,119,120,124,125,126,102,104,103,109,111,110',
-'112,114,113,106,108,107,133,134,101,100,137,,,,,,,,,,,,,337,105,129',
-'130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126',
-'102,104,103,109,111,110,112,114,113,106,108,107,133,134,101,100,137',
-',,,,,,,,,340,,,341,105,129,130,132,127,128,131,115,116,117,121,122,123',
-'118,119,120,124,125,126,102,104,103,109,111,110,112,114,113,106,108',
-'107,133,134,101,100,137,,,,,,,266,,,,,,,105,129,130,132,127,128,131',
-'115,116,117,121,122,123,118,119,120,124,125,126,102,104,103,109,111',
-'110,112,114,113,106,108,107,133,134,101,100,137,,,,,,,360,,,,,,,105',
-'129,130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125',
-'126,102,104,103,109,111,110,112,114,113,106,108,107,133,134,101,100',
-'137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117,121,122,123',
-'118,119,120,124,125,126,102,104,103,109,111,110,112,114,113,106,108',
-'107,133,134,101,100,137,,,,,,,360,,,,,,,105,129,130,132,127,128,131',
-'115,116,117,121,122,123,118,119,120,124,125,126,102,104,103,109,111',
-'110,112,114,113,106,108,107,133,134,101,100,137,,,,,,,,,,,,,,105,129',
-'130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126',
-'102,104,103,109,111,110,112,114,113,106,108,107,133,134,101,100,137',
-',,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117,121,122,123,118',
-'119,120,124,125,126,102,104,103,109,111,110,112,114,113,106,108,107',
-'133,134,101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116',
-'117,121,122,123,118,119,120,124,125,126,102,104,103,109,111,110,112',
-'114,113,106,108,107,133,134,101,100,137,,,,,,,,,,,,,,105,129,130,132',
-'127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,102,104',
-'103,109,111,110,112,114,113,106,108,107,133,134,101,100,137,,,,,,,,',
-',396,,,341,105,129,130,132,127,128,131,115,116,117,121,122,123,118,119',
-'120,124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133',
-'134,101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117',
-'121,122,123,118,119,120,124,125,126,102,104,103,109,111,110,112,114',
-'113,106,108,107,133,134,101,100,137,,,,,,,,,,399,,,,105,129,130,132',
-'127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,102,104',
-'103,109,111,110,112,114,113,106,108,107,133,134,101,100,137,,,,,,,,',
-',,,,,105,129,130,132,127,128,131,115,116,117,121,122,123,118,119,120',
-'124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133,134',
-'101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117,121',
-'122,123,118,119,120,124,125,126,102,104,103,109,111,110,112,114,113',
-'106,108,107,133,134,101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128',
-'131,115,116,117,121,122,123,118,119,120,124,125,126,102,104,103,109',
-'111,110,112,114,113,106,108,107,133,134,101,100,137,,,,,,,,,,,,,,105',
-'129,130,132,127,128,131,115,116,117,121,122,123,118,119,120,124,125',
-'126,102,104,103,109,111,110,112,114,113,106,108,107,133,134,101,100',
-'137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117,121,122,123',
-'118,119,120,124,125,126,102,104,103,109,111,110,112,114,113,106,108',
-'107,133,134,101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115',
-'116,117,121,122,123,118,119,120,124,125,126,102,104,103,109,111,110',
-'112,114,113,106,108,107,133,134,101,100,137,,,,,,,,,,,,,,105,129,130',
-'132,127,128,131,115,116,117,121,122,123,118,119,120,124,125,126,102',
-'104,103,109,111,110,112,114,113,106,108,107,133,134,101,100,137,,,,',
-',,,,,,,,,105,129,130,132,127,128,131,115,116,117,121,122,123,118,119',
-'120,124,125,126,102,104,103,109,111,110,112,114,113,106,108,107,133',
-'134,101,100,137,,,,,,,,,,,,,,105,129,130,132,127,128,131,115,116,117',
-'121,122,123,118,119,120,124,125,126,102,104,103,109,111,110,112,114',
-'113,106,108,107,133,134,101,100,137,,,,,,,,,,,,,,105' ]
- racc_action_table = arr = ::Array.new(6677, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'22,464,74,143,22,143,376,376,333,451,433,369,464,370,99,99,74,99,155',
-'345,451,155,369,155,3,99,99,99,461,99,99,99,99,433,376,333,370,99,99',
-'99,8,99,8,8,8,99,99,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22',
-'22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,99,95,3,99',
-'466,95,461,95,95,95,95,95,376,22,95,454,95,95,287,287,95,95,95,95,95',
-'332,95,95,95,95,93,95,95,95,95,95,95,95,95,95,95,95,447,95,95,95,95',
-'95,182,182,203,95,95,447,157,283,283,283,283,182,283,157,210,202,466',
-'283,283,202,210,138,138,138,138,59,59,454,203,138,24,287,287,213,298',
-'175,59,332,23,298,95,55,93,95,200,95,203,203,203,203,203,203,203,203',
-'203,203,203,203,203,203,203,203,203,203,203,203,203,203,203,203,203',
-'203,203,203,203,203,203,203,203,203,203,59,0,161,278,213,0,175,0,0,0',
-'0,0,55,203,0,200,0,0,286,277,0,0,0,0,0,284,0,0,0,0,0,0,0,0,0,0,0,0,0',
-'0,0,0,314,0,0,0,0,0,360,161,456,0,0,330,161,278,353,313,86,330,330,266',
-'355,31,31,31,31,403,31,286,286,277,42,42,42,42,284,284,386,356,386,386',
-'457,386,430,73,73,73,0,359,0,0,2,0,314,92,2,360,2,2,2,2,2,285,162,2',
-'86,2,2,313,266,2,2,2,2,2,403,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,430,2,2',
-'2,2,2,315,281,281,2,2,285,285,285,285,72,72,72,162,282,282,285,285,162',
-'40,40,186,186,186,331,90,331,331,458,331,66,66,66,66,304,410,304,410',
-'187,187,187,2,89,2,2,211,2,367,315,211,368,211,211,211,211,211,33,459',
-'211,19,211,211,181,181,211,211,211,211,211,186,211,211,211,211,211,211',
-'211,211,211,211,211,211,211,211,211,211,187,211,211,211,211,211,290',
-'290,204,211,211,33,33,33,33,416,416,387,387,88,87,70,385,389,391,392',
-'43,404,1,408,411,412,417,420,204,421,422,423,425,235,235,235,235,235',
-'235,428,211,252,211,211,429,211,204,204,204,204,204,204,204,204,204',
-'204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204',
-'204,204,204,204,204,204,204,204,204,235,460,247,247,247,460,432,460',
-'460,460,460,460,434,204,460,250,460,460,35,260,460,460,460,460,460,249',
-'460,460,460,460,460,460,460,460,460,460,460,460,460,460,460,178,268',
-'460,460,460,460,460,209,208,247,460,460,207,199,220,220,220,220,220',
-'220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220',
-'220,220,220,220,220,220,220,220,220,220,220,460,189,460,460,455,460',
-'185,184,455,183,455,455,455,455,455,220,212,455,174,455,455,170,293',
-'455,455,455,455,455,169,455,455,455,455,455,455,455,455,455,455,455',
-'455,455,455,455,166,32,455,455,455,455,455,297,299,300,455,455,301,160',
-'221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221',
-'221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,305,455',
-'445,455,455,94,455,448,449,94,312,94,94,94,94,94,221,154,94,151,94,94',
-'318,150,94,94,94,94,94,148,94,94,94,94,94,94,94,94,94,94,94,94,94,94',
-'94,322,146,94,94,94,94,94,324,325,141,94,94,140,334,222,222,222,222',
-'222,222,222,222,222,222,222,222,222,222,222,222,222,222,335,336,97,467',
-'339,96,27,344,,,,248,248,248,,94,,94,94,320,94,,,320,320,320,320,320',
-'320,320,222,,320,,320,320,,,320,320,320,320,320,,320,320,320,320,320',
-'320,320,320,320,320,320,320,320,320,320,248,,320,320,320,320,320,,,',
-'320,320,,,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223',
-'223,223,223,,,,,,,,,,,,251,251,251,,320,,320,320,438,320,,,438,,438',
-'438,438,438,438,223,,438,,438,438,,,438,438,438,438,438,,438,438,438',
-'438,438,438,438,438,438,438,438,438,438,438,438,251,,438,438,438,438',
-'438,,,,438,438,378,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,438,,438,438,,438',
-',378,378,378,378,378,378,378,378,378,378,378,378,378,378,378,378,378',
-'378,378,378,378,378,378,378,378,378,378,378,378,378,378,378,378,378',
-'378,375,,,,,,,,,258,258,,258,378,,258,,,,,258,258,258,,258,258,258,258',
-',,,,258,258,258,,258,,,,258,258,375,375,375,375,375,375,375,375,375',
-'375,375,375,375,375,375,375,375,375,375,375,375,375,375,375,375,375',
-'375,375,375,375,375,375,375,375,375,258,,,258,,258,,258,139,139,,139',
-',375,139,,,,,139,139,139,,139,139,139,139,,,,,139,139,139,,139,,,,139',
-'139,295,295,295,,295,,,295,,,,,295,295,295,,295,295,295,295,,,,,295',
-'295,295,,295,,,,295,295,,139,,,139,,139,,139,224,224,224,224,224,224',
-'224,224,224,224,224,224,224,224,224,224,224,224,,,,302,302,302,,302',
-'295,295,302,295,,295,,302,302,302,,302,302,302,302,,,,,302,302,302,224',
-'302,,,,302,302,215,215,215,,215,,,215,,,,,215,215,215,,215,215,215,215',
-',,,,215,215,215,,215,,,,215,215,,302,274,274,302,274,302,,274,,,,,274',
-'274,274,,274,274,274,274,,,,,274,274,274,,274,,,,274,274,215,215,,215',
-',215,,,,226,226,226,226,226,226,226,226,226,226,226,226,226,226,226',
-'226,226,226,,,,267,267,267,,267,274,,267,274,,274,274,267,267,267,,267',
-'267,267,267,,,,,267,267,267,226,267,,,,267,267,176,176,176,,176,,,176',
-',,,,176,176,176,,176,176,176,176,,,,,176,176,176,,176,,,,176,176,,267',
-'267,,267,,267,,,227,227,227,227,227,227,227,227,227,227,227,227,227',
-'227,227,227,227,227,,,,362,362,362,,362,176,176,362,176,,176,,362,362',
-'362,,362,362,362,362,,,,,362,362,362,227,362,,,,362,362,147,147,147',
-',147,,,147,,,,,147,147,147,,147,147,147,147,,,,,147,147,147,,147,,,',
-'147,147,,362,362,,362,,362,,,228,228,228,228,228,228,228,228,228,228',
-'228,228,228,228,228,228,228,228,,,,276,276,276,,276,147,147,276,147',
-',147,,276,276,276,,276,276,276,276,,,,,276,276,276,228,276,,,,276,276',
-'58,58,58,,58,,,58,,,,,58,58,58,,58,58,58,58,,,58,,58,58,58,,58,,,,58',
-'58,,276,276,,276,,276,,229,229,229,229,229,229,229,229,229,229,229,229',
-'229,229,229,229,229,229,,,,171,171,171,,171,,58,171,,58,,58,171,171',
-'171,,171,171,171,171,,,,,171,171,171,229,171,,,,171,171,393,393,393',
-',393,,,393,,,,,393,393,393,,393,393,393,393,,,,,393,393,393,,393,,,',
-'393,393,,171,171,,171,,171,,,230,230,230,230,230,230,230,230,230,230',
-'230,230,230,230,230,230,230,230,,,,165,165,165,,165,393,393,165,393',
-',393,,165,165,165,,165,165,165,165,,,,,165,165,165,230,165,,,,165,165',
-'109,109,,109,,,109,,,,,109,109,109,,109,109,109,109,,,,,109,109,109',
-',109,,,,109,109,,,165,165,,165,,165,231,231,231,231,231,231,231,231',
-'231,231,231,231,231,231,231,231,231,231,,,,,110,110,,110,,109,110,,109',
-',109,110,110,110,,110,110,110,110,,,,,110,110,110,231,110,,,,110,110',
-'111,111,,111,,,111,,,,,111,111,111,,111,111,111,111,,,,,111,111,111',
-',111,,,,111,111,112,112,110,112,,110,112,110,,,,112,112,112,,112,112',
-'112,112,,,,,112,112,112,,112,,,,112,112,113,113,111,113,,111,113,111',
-',,,113,113,113,,113,113,113,113,,,,,113,113,113,,113,,,,113,113,114',
-'114,112,114,,112,114,112,,,,114,114,114,,114,114,114,114,,,,,114,114',
-'114,,114,,,,114,114,115,115,113,115,,113,115,113,,,,115,115,115,,115',
-'115,115,115,,,,,115,115,115,,115,,,,115,115,116,116,114,116,,114,116',
-'114,,,,116,116,116,,116,116,116,116,,,,,116,116,116,,116,,,,116,116',
-'117,117,115,117,,115,117,115,,,,117,117,117,,117,117,117,117,,,,,117',
-'117,117,,117,,,,117,117,118,118,116,118,,116,118,116,,,,118,118,118',
-',118,118,118,118,,,,,118,118,118,,118,,,,118,118,119,119,117,119,,117',
-'119,117,,,,119,119,119,,119,119,119,119,,,,,119,119,119,,119,,,,119',
-'119,120,120,118,120,,118,120,118,,,,120,120,120,,120,120,120,120,,,',
-',120,120,120,,120,,,,120,120,121,121,119,121,,119,121,119,,,,121,121',
-'121,,121,121,121,121,,,,,121,121,121,,121,,,,121,121,122,122,120,122',
-',120,122,120,,,,122,122,122,,122,122,122,122,,,,,122,122,122,,122,,',
-',122,122,123,123,121,123,,121,123,121,,,,123,123,123,,123,123,123,123',
-',,,,123,123,123,,123,,,,123,123,124,124,122,124,,122,124,122,,,,124',
-'124,124,,124,124,124,124,,,,,124,124,124,,124,,,,124,124,125,125,123',
-'125,,123,125,123,,,,125,125,125,,125,125,125,125,,,,,125,125,125,,125',
-',,,125,125,126,126,124,126,,124,126,124,,,,126,126,126,,126,126,126',
-'126,,,,,126,126,126,,126,,,,126,126,127,127,125,127,,125,127,125,,,',
-'127,127,127,,127,127,127,127,,,,,127,127,127,,127,,,,127,127,128,128',
-'126,128,,126,128,126,,,,128,128,128,,128,128,128,128,,,,,128,128,128',
-',128,,,,128,128,129,129,127,129,,127,129,127,,,,129,129,129,,129,129',
-'129,129,,,,,129,129,129,,129,,,,129,129,130,130,128,130,,128,130,128',
-',,,130,130,130,,130,130,130,130,,,,,130,130,130,,130,,,,130,130,131',
-'131,129,131,,129,131,129,,,,131,131,131,,131,131,131,131,,,,,131,131',
-'131,,131,,,,131,131,132,132,130,132,,130,132,130,,,,132,132,132,,132',
-'132,132,132,,,,,132,132,132,,132,,,,132,132,133,133,131,133,,131,133',
-'131,,,,133,133,133,,133,133,133,133,,,,,133,133,133,,133,,,,133,133',
-'134,134,132,134,,132,134,132,,,,134,134,134,,134,134,134,134,,,,,134',
-'134,134,,134,,,,134,134,135,135,133,135,,133,135,133,,,,135,135,135',
-',135,135,135,135,,,,,135,135,135,,135,,,,135,135,136,136,134,136,,134',
-'136,134,,,,136,136,136,,136,136,136,136,,,,,136,136,136,,136,,,,136',
-'136,137,137,135,137,,135,137,135,,,,137,137,137,,137,137,137,137,,,',
-',137,137,137,,137,,,,137,137,85,85,136,85,,136,85,136,,,,85,85,85,,85',
-'85,85,85,,,,,85,85,85,,85,,,,85,85,272,272,137,272,,137,272,137,,,,272',
-'272,272,,272,272,272,272,,,,,272,272,272,,272,,,,272,272,270,270,85',
-'270,,85,270,85,,,,270,270,270,,270,270,270,270,,,,,270,270,270,,270',
-',,,270,270,,,272,,,272,272,272,232,232,232,232,232,232,232,232,232,232',
-'232,232,232,232,232,232,232,232,,,,,29,29,,29,,270,29,,270,,270,29,29',
-'29,,29,29,29,29,,,,,29,29,29,232,29,,,,29,29,437,437,,437,,,437,,,,',
-'437,437,437,,437,437,437,437,,,,,437,437,437,,437,,,,437,437,435,435',
-'29,435,,29,435,29,,,,435,435,435,,435,435,435,435,,,,,435,435,435,,435',
-',,,435,435,418,418,437,418,,437,418,437,,,,418,418,418,,418,418,418',
-'418,,,,,418,418,418,,418,,,,418,418,52,52,435,52,,435,52,435,,,,52,52',
-'52,,52,52,52,52,,,52,,52,52,52,,52,,,,52,52,54,54,418,54,,418,54,418',
-',,,54,54,54,,54,54,54,54,,,54,,54,54,54,,54,,,,54,54,56,56,52,56,,52',
-'56,52,,,56,56,56,56,,56,56,56,56,,,,,56,56,56,,56,,,,56,56,61,61,54',
-'61,,54,61,54,,,,61,61,61,,61,61,61,61,,,,,61,61,61,,61,,,,61,61,62,62',
-'56,62,,56,62,56,,,,62,62,62,,62,62,62,62,,,,,62,62,62,,62,,,,62,62,63',
-'63,61,63,,61,63,61,,,,63,63,63,,63,63,63,63,,,,,63,63,63,,63,,,,63,63',
-'78,78,62,78,,62,78,62,,,,78,78,78,,78,78,78,78,,,78,,78,78,78,,78,,',
-',78,78,80,80,63,80,,63,80,63,,,,80,80,80,,80,80,80,80,,,,,80,80,80,',
-'80,,,,80,80,81,81,78,81,,78,81,78,,,,81,81,81,,81,81,81,81,,,,,81,81',
-'81,,81,,,,81,81,82,82,80,82,,80,82,80,,,,82,82,82,,82,82,82,82,,,,,82',
-'82,82,,82,,,,82,82,261,261,81,261,,81,261,81,,,,261,261,261,,261,261',
-'261,261,,,261,,261,261,261,,261,,,,261,261,365,365,82,365,,82,365,82',
-',,,365,365,365,,365,365,365,365,,,,,365,365,365,,365,,,,365,365,341',
-'341,261,341,,261,341,261,,,,341,341,341,,341,341,341,341,,,341,,341',
-'341,341,,341,,,,341,341,337,337,365,337,,365,337,365,,,,337,337,337',
-',337,337,337,337,,,,,337,337,337,,337,,,,337,337,100,100,341,100,,341',
-'100,341,,,,100,100,100,,100,100,100,100,,,,,100,100,100,,100,,,,100',
-'100,101,101,337,101,,337,101,337,,,,101,101,101,,101,101,101,101,,,',
-',101,101,101,,101,,,,101,101,102,102,100,102,,100,102,100,,,,102,102',
-'102,,102,102,102,102,,,,,102,102,102,,102,,,,102,102,103,103,101,103',
-',101,103,101,,,,103,103,103,,103,103,103,103,,,,,103,103,103,,103,,',
-',103,103,104,104,102,104,,102,104,102,,,,104,104,104,,104,104,104,104',
-',,,,104,104,104,,104,,,,104,104,105,105,103,105,,103,105,103,,,,105',
-'105,105,,105,105,105,105,,,,,105,105,105,,105,,,,105,105,106,106,104',
-'106,,104,106,104,,,,106,106,106,,106,106,106,106,,,,,106,106,106,,106',
-',,,106,106,107,107,105,107,,105,107,105,,,,107,107,107,,107,107,107',
-'107,,,,,107,107,107,,107,,,,107,107,108,108,106,108,,106,108,106,,,',
-'108,108,108,,108,108,108,108,,,,,108,108,108,,108,,,,108,108,328,328',
-'107,328,,107,328,107,,,,328,328,328,,328,328,328,328,,,,,328,328,328',
-',328,,,,328,328,327,327,108,327,,108,327,108,,,,327,327,327,,327,327',
-'327,327,,,,,327,327,327,,327,,,,327,327,326,326,328,326,,328,326,328',
-',,,326,326,326,,326,326,326,326,,,,,326,326,326,,326,,,,326,326,323',
-'323,327,323,,327,323,327,,,,323,323,323,,323,323,323,323,,,,,323,323',
-'323,,323,,,,323,323,319,319,326,319,,326,319,326,,,,319,319,319,,319',
-'319,319,319,,,,,319,319,319,,319,,,,319,319,317,317,323,317,,323,317',
-'323,,,,317,317,317,,317,317,317,317,,,,,317,317,317,,317,,,,317,317',
-'316,316,319,316,,319,316,319,,,,316,316,316,,316,316,316,316,,,,,316',
-'316,316,,316,,,,316,316,164,164,317,164,,317,164,317,,,,164,164,164',
-',164,164,164,164,,,,,164,164,164,,164,,,,164,164,294,294,316,294,,316',
-'294,316,,,,294,294,294,,294,294,294,294,,,,,294,294,294,,294,,,,294',
-'294,291,291,164,291,,164,291,164,,,,291,291,291,,291,291,291,291,,,',
-',291,291,291,,291,,,,291,291,173,173,294,173,,294,173,294,,,,173,173',
-'173,,173,173,173,173,,,173,,173,173,173,,173,,,,173,173,288,288,291',
-'288,,291,288,291,,,,288,288,288,,288,288,288,288,,,288,,288,288,288',
-',288,,,,288,288,180,180,173,180,,173,180,173,,,,180,180,180,,180,180',
-'180,180,,,,,180,180,180,,180,,,,180,180,188,188,288,188,,288,188,288',
-',,,188,188,188,,188,188,188,188,,,,,188,188,188,,188,,,,188,188,191',
-'191,180,191,,180,191,180,,,,191,191,191,,191,191,191,191,,,,,191,191',
-'191,,191,,,,191,191,192,192,188,192,,188,192,188,,,,192,192,192,,192',
-'192,192,192,,,,,192,192,192,,192,,,,192,192,193,193,191,193,,191,193',
-'191,,,,193,193,193,,193,193,193,193,,,,,193,193,193,,193,,,,193,193',
-'194,194,192,194,,192,194,192,,,,194,194,194,,194,194,194,194,,,,,194',
-'194,194,,194,,,,194,194,275,275,193,275,,193,275,193,,,,275,275,275',
-',275,275,275,275,,,,,275,275,275,,275,,,,275,275,142,142,194,142,,194',
-',194,,,,142,142,142,,142,142,142,142,,,,,142,142,142,,142,,,,142,142',
-'57,57,275,57,,275,,275,,,,57,57,57,,57,57,57,,,,,,57,57,57,,57,,,,57',
-'57,64,64,142,64,,142,,,,,,64,64,64,,64,64,64,,,,,,64,64,64,,64,,,,64',
-'64,,,57,,,57,,,,,,,,,,,,,,,,205,,,,,,236,236,236,236,236,236,,,64,,',
-'64,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205',
-'205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205',
-'205,453,236,,,,,237,237,237,237,237,237,,205,,,,,453,453,453,453,453',
-'453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453',
-'453,453,453,453,453,453,453,453,453,453,453,453,453,382,237,,,,,238',
-'238,238,238,238,238,,453,,,,,382,382,382,382,382,382,382,382,382,382',
-'382,382,382,382,382,382,382,382,382,382,382,382,382,382,382,382,382',
-'382,382,382,382,382,382,382,382,383,238,,,,,239,239,239,239,239,239',
-',382,,,,,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383',
-'383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383',
-'383,383,383,439,239,,,,,240,240,240,240,240,240,,383,,,,,439,439,439',
-'439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,439',
-'439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,381,240',
-',,,,241,241,241,241,241,241,,439,,,,,381,381,381,381,381,381,381,381',
-'381,381,381,381,381,381,381,381,381,381,381,381,381,381,381,381,381',
-'381,381,381,381,381,381,381,381,381,381,206,241,,,,242,242,242,242,242',
-'242,,,381,,,,,206,206,206,206,206,206,206,206,206,206,206,206,206,206',
-'206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206',
-'206,206,206,206,242,243,243,243,243,243,243,244,244,244,244,244,244',
-'206,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289',
-'289,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289',
-'289,289,243,,,,,,244,,,,,,,289,145,145,145,145,145,145,145,145,145,145',
-'145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145',
-'145,145,145,145,145,145,145,145,,,,,,,145,245,245,245,245,245,245,145',
-'156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156',
-'156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156',
-'156,,,,,,,245,246,246,246,246,246,246,156,159,159,159,159,159,159,159',
-'159,159,159,159,159,159,159,159,159,159,159,159,159,159,159,159,159',
-'159,159,159,159,159,159,159,159,159,159,159,,,,,,,246,,,,,,159,159,168',
-'168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168',
-'168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168',
-',,,,,,,,,,,,,168,179,179,179,179,179,179,179,179,179,179,179,179,179',
-'179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179',
-'179,179,179,179,179,,,,,,,,,,,,,,179,201,201,201,201,201,201,201,201',
-'201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201,201',
-'201,201,201,201,201,201,201,201,201,201,,,,,,,,,,,,,,201,225,225,225',
-'225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225',
-'225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,,,,,,,,',
-',,,,,225,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233',
-'233,233,233,234,234,234,234,234,234,234,234,234,234,234,234,234,234',
-'234,234,234,234,,,,,,,,,,,,,233,,,,,,,,,,,,,,,,,,234,253,253,253,253',
-'253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253',
-'253,253,253,253,253,253,253,253,253,,,,,,,,,,,,,,,,,,,253,254,254,254',
-'254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254',
-'254,254,254,254,254,254,254,254,254,254,,,,,,,,,,,,,,,,,,,254,255,255',
-'255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255',
-'255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,,,,',
-',,,,,,,,,255,256,256,256,256,256,256,256,256,256,256,256,256,256,256',
-'256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256',
-'256,256,256,256,,,,,,,,,,,,,,256,257,257,257,257,257,257,257,257,257',
-'257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257',
-'257,257,257,257,257,257,257,257,257,,,,,,,,,,,,,257,257,259,259,259',
-'259,259,259,259,259,259,259,259,259,259,259,259,259,259,259,259,259',
-'259,259,259,259,259,259,259,259,259,259,259,259,259,259,259,,,,,,,,',
-',259,,,259,259,292,292,292,292,292,292,292,292,292,292,292,292,292,292',
-'292,292,292,292,292,292,292,292,292,292,292,292,292,292,292,292,292',
-'292,292,292,292,,,,,,,292,,,,,,,292,296,296,296,296,296,296,296,296',
-'296,296,296,296,296,296,296,296,296,296,296,296,296,296,296,296,296',
-'296,296,296,296,296,296,296,296,296,296,,,,,,,296,,,,,,,296,303,303',
-'303,303,303,303,303,303,303,303,303,303,303,303,303,303,303,303,303',
-'303,303,303,303,303,303,303,303,303,303,303,303,303,303,303,303,,,,',
-',,,,,,,,,303,307,307,307,307,307,307,307,307,307,307,307,307,307,307',
-'307,307,307,307,307,307,307,307,307,307,307,307,307,307,307,307,307',
-'307,307,307,307,,,,,,,307,,,,,,,307,308,308,308,308,308,308,308,308',
-'308,308,308,308,308,308,308,308,308,308,308,308,308,308,308,308,308',
-'308,308,308,308,308,308,308,308,308,308,,,,,,,,,,,,,,308,309,309,309',
-'309,309,309,309,309,309,309,309,309,309,309,309,309,309,309,309,309',
-'309,309,309,309,309,309,309,309,309,309,309,309,309,309,309,,,,,,,,',
-',,,,,309,310,310,310,310,310,310,310,310,310,310,310,310,310,310,310',
-'310,310,310,310,310,310,310,310,310,310,310,310,310,310,310,310,310',
-'310,310,310,,,,,,,,,,,,,,310,311,311,311,311,311,311,311,311,311,311',
-'311,311,311,311,311,311,311,311,311,311,311,311,311,311,311,311,311',
-'311,311,311,311,311,311,311,311,,,,,,,,,,,,,,311,338,338,338,338,338',
-'338,338,338,338,338,338,338,338,338,338,338,338,338,338,338,338,338',
-'338,338,338,338,338,338,338,338,338,338,338,338,338,,,,,,,,,,338,,,338',
-'338,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343',
-'343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343',
-'343,343,,,,,,,,,,,,,,343,347,347,347,347,347,347,347,347,347,347,347',
-'347,347,347,347,347,347,347,347,347,347,347,347,347,347,347,347,347',
-'347,347,347,347,347,347,347,,,,,,,,,,347,,,,347,349,349,349,349,349',
-'349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349',
-'349,349,349,349,349,349,349,349,349,349,349,349,349,,,,,,,,,,,,,,349',
-'352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352',
-'352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352',
-'352,,,,,,,,,,,,,,352,358,358,358,358,358,358,358,358,358,358,358,358',
-'358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358',
-'358,358,358,358,358,358,,,,,,,,,,,,,,358,364,364,364,364,364,364,364',
-'364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364,364',
-'364,364,364,364,364,364,364,364,364,364,364,,,,,,,,,,,,,,364,372,372',
-'372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372',
-'372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,,,,',
-',,,,,,,,,372,373,373,373,373,373,373,373,373,373,373,373,373,373,373',
-'373,373,373,373,373,373,373,373,373,373,373,373,373,373,373,373,373',
-'373,373,373,373,,,,,,,,,,,,,,373,395,395,395,395,395,395,395,395,395',
-'395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395',
-'395,395,395,395,395,395,395,395,395,,,,,,,,,,,,,,395,398,398,398,398',
-'398,398,398,398,398,398,398,398,398,398,398,398,398,398,398,398,398',
-'398,398,398,398,398,398,398,398,398,398,398,398,398,398,,,,,,,,,,,,',
-',398,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405',
-'405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405',
-'405,405,,,,,,,,,,,,,,405,452,452,452,452,452,452,452,452,452,452,452',
-'452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452',
-'452,452,452,452,452,452,452,,,,,,,,,,,,,,452' ]
- racc_action_check = arr = ::Array.new(6677, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_action_pointer = [
- 210, 463, 301, -7, nil, nil, nil, nil, -2, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 320,
- nil, nil, -2, 76, 106, nil, nil, 695, nil, 2851,
- nil, 190, 612, 362, nil, 497, nil, nil, nil, nil,
- 335, nil, 199, 369, nil, nil, nil, nil, nil, nil,
- nil, nil, 2983, nil, 3016, 129, 3049, 4402, 1541, 122,
- nil, 3082, 3115, 3148, 4435, nil, 295, nil, nil, nil,
- 414, nil, 315, 252, -42, nil, nil, nil, 3181, nil,
- 3214, 3247, 3280, nil, nil, 2722, 225, 424, 410, 347,
- 285, nil, 306, 81, 703, 81, 690, 737, nil, -7,
- 3445, 3478, 3511, 3544, 3577, 3610, 3643, 3676, 3709, 1735,
- 1798, 1831, 1864, 1897, 1930, 1963, 1996, 2029, 2062, 2095,
- 2128, 2161, 2194, 2227, 2260, 2293, 2326, 2359, 2392, 2425,
- 2458, 2491, 2524, 2557, 2590, 2623, 2656, 2689, 67, 1080,
- 714, 712, 4369, -87, nil, 4895, 657, 1443, 686, nil,
- 680, 676, nil, nil, 625, -70, 4944, 48, nil, 4993,
- 578, 171, 273, nil, 3973, 1702, 566, nil, 5042, 549,
- 588, 1604, nil, 4072, 536, 123, 1345, nil, 475, 5091,
- 4138, 378, 97, 531, 575, 519, 321, 338, 4171, 519,
- nil, 4204, 4237, 4270, 4303, nil, nil, nil, nil, 534,
- 132, 5140, 143, 127, 438, 4479, 4797, 559, 555, 554,
- 137, 392, 584, 121, nil, 1212, nil, nil, nil, nil,
- 528, 619, 710, 801, 1128, 5189, 1261, 1359, 1457, 1554,
- 1652, 1748, 2801, 5238, 5256, 425, 4467, 4520, 4573, 4626,
- 4679, 4732, 4784, 4833, 4839, 4937, 4986, 475, 739, 450,
- 440, 830, 385, 5305, 5354, 5403, 5452, 5501, 1004, 5550,
- 448, 3313, nil, nil, nil, nil, 229, 1311, 474, nil,
- 2788, nil, 2755, nil, 1247, 4336, 1507, 188, 172, nil,
- nil, 257, 269, 53, 193, 271, 186, 67, 4105, 4846,
- 347, 4039, 5599, 542, 4006, 1114, 5648, 571, 76, 570,
- 574, 576, 1178, 5697, 295, 656, nil, 5746, 5795, 5844,
- 5893, 5942, 655, 226, 211, 308, 3940, 3907, 715, 3874,
- 794, nil, 738, 3841, 745, 746, 3808, 3775, 3742, nil,
- 257, 342, 76, -23, 669, 689, 688, 3412, 5991, 688,
- nil, 3379, nil, 6040, 741, -73, nil, 6089, nil, 6138,
- nil, nil, 6187, 177, nil, 178, 195, nil, 6236, 210,
- 216, nil, 1409, nil, 6285, 3346, nil, 354, 355, -20,
- -6, nil, 6334, 6383, nil, 1009, 3, nil, 932, nil,
- nil, 4744, 4585, 4638, nil, 426, 258, 419, nil, 427,
- nil, 452, 416, 1638, nil, 6432, nil, nil, 6481, nil,
- nil, nil, nil, 235, 372, 6530, nil, nil, 457, nil,
- 296, 375, 382, nil, nil, nil, 447, 436, 2950, nil,
- 461, 463, 464, 465, nil, 442, nil, nil, 438, 395,
- 252, nil, 486, -9, 492, 2917, nil, 2884, 885, 4691,
- nil, nil, nil, nil, nil, 671, nil, 93, 617, 624,
- nil, -22, 6579, 4532, 66, 612, 254, 286, 335, 399,
- 521, -3, nil, nil, -30, nil, 55, 773, nil ]
-
-racc_action_default = [
- -1, -259, -2, -3, -4, -8, -9, -10, -11, -12,
- -13, -14, -15, -16, -17, -18, -19, -20, -21, -22,
- -23, -24, -25, -26, -27, -29, -30, -31, -32, -116,
- -34, -35, -36, -37, -38, -39, -40, -49, -50, -51,
- -52, -53, -54, -55, -56, -57, -58, -59, -60, -63,
- -64, -65, -69, -72, -75, -259, -116, -116, -119, -116,
- -115, -116, -116, -116, -116, -168, -259, -177, -179, -180,
- -259, -184, -116, -116, -116, -200, -201, -202, -217, -219,
- -116, -116, -116, -228, -229, -116, -116, -259, -116, -116,
- -257, -258, -259, -7, -116, -6, -259, -259, -188, -116,
- -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
- -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
- -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
- -116, -116, -116, -116, -116, -116, -116, -116, -83, -116,
- -28, -259, -116, -26, -31, -259, -259, -116, -80, -94,
- -79, -81, -61, -62, -182, -259, -70, -259, -76, -259,
- -259, -183, -185, -189, -116, -116, -101, -102, -127, -35,
- -37, -116, -54, -69, -259, -259, -116, -107, -120, -123,
- -116, -111, -116, -109, -259, -164, -165, -166, -116, -259,
- -167, -116, -116, -116, -116, -181, -186, -187, -117, -259,
- -259, -218, -214, -259, -259, -259, -259, -259, -259, -259,
- -237, -245, -259, -259, -255, -116, 469, -5, -183, -170,
- -129, -130, -131, -132, -133, -134, -135, -136, -137, -138,
- -139, -140, -141, -142, -143, -144, -145, -146, -147, -148,
- -149, -150, -151, -152, -153, -154, -155, -156, -157, -158,
- -159, -160, -161, -162, -163, -222, -225, -259, -116, -259,
- -259, -93, -97, -96, -169, -41, -33, -116, -259, -95,
- -116, -67, -116, -73, -116, -116, -116, -259, -190, -191,
- -192, -29, -30, -35, -36, -37, -39, -52, -75, -259,
- -259, -116, -123, -259, -116, -116, -123, -259, -259, -83,
- -259, -259, -116, -124, -259, -116, -110, -259, -171, -172,
- -173, -174, -259, -204, -203, -207, -116, -116, -259, -116,
- -116, -246, -259, -116, -259, -259, -116, -116, -116, -234,
- -259, -259, -244, -259, -105, -122, -259, -116, -259, -259,
- -86, -91, -87, -92, -82, -84, -99, -259, -68, -71,
- -74, -77, -78, -259, -193, -259, -259, -100, -128, -259,
- -259, -103, -116, -106, -125, -116, -108, -259, -116, -259,
- -208, -205, -215, -216, -220, -259, -244, -223, -259, -227,
- -230, -259, -259, -259, -235, -259, -259, -243, -238, -259,
- -242, -259, -116, -116, -256, -226, -88, -89, -90, -66,
- -98, -194, -195, -114, -259, -126, -112, -118, -259, -206,
- -259, -259, -209, -210, -221, -247, -248, -259, -116, -224,
- -259, -259, -259, -259, -240, -259, -239, -253, -259, -259,
- -113, -196, -207, -259, -207, -116, -249, -116, -116, -259,
- -231, -232, -233, -236, -241, -259, -104, -259, -259, -211,
- -212, -259, -213, -259, -250, -116, -259, -259, -207, -259,
- -116, -251, -254, -197, -259, -198, -252, -259, -199 ]
-
-racc_goto_table = [
- 2, 183, 27, 95, 27, 3, 148, 170, 413, 151,
- 155, 389, 415, 390, 154, 177, 172, 416, 260, 217,
- 96, 318, 322, 169, 181, 282, 284, 98, 140, 356,
- 209, 351, 166, 214, 200, 335, 336, 190, 207, 410,
- 202, 330, 1, nil, nil, 208, nil, nil, nil, nil,
- nil, nil, 436, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 97, nil, nil, nil, 425, 154, 390, nil,
- nil, 450, 286, nil, nil, nil, 280, 162, 291, nil,
- nil, 281, nil, 145, 96, 96, 160, nil, nil, nil,
- nil, 196, 197, 95, nil, nil, 27, 27, nil, nil,
- nil, 219, nil, nil, 268, nil, 156, nil, 159, nil,
- 168, 175, 179, 184, 285, 185, 186, 187, nil, nil,
- nil, nil, 293, nil, 304, nil, 97, 97, 198, 287,
- 283, 298, 201, 301, 203, 204, 205, 339, nil, 206,
- 97, nil, 212, 213, 264, 299, 369, 181, nil, 282,
- 284, nil, 282, 284, 220, 221, 222, 223, 224, 225,
- 226, 227, 228, 229, 230, 231, 232, 233, 234, 235,
- 236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
- 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
- 256, 257, 280, 259, nil, nil, 286, 162, 210, 286,
- nil, 179, 291, nil, 355, 281, 300, nil, 281, nil,
- nil, nil, nil, 27, nil, nil, 332, nil, 289, 292,
- nil, nil, 314, nil, nil, 296, nil, 156, 280, nil,
- 292, 315, nil, 353, 303, 314, 184, 345, 285, nil,
- 344, 285, 307, nil, 334, 308, 309, 310, 311, nil,
- 143, nil, 359, 287, 283, nil, 287, 283, 148, nil,
- 151, nil, nil, 447, nil, 451, nil, nil, nil, 179,
- nil, nil, nil, nil, nil, nil, nil, nil, 174, nil,
- nil, nil, nil, nil, nil, 189, nil, nil, nil, 464,
- nil, nil, nil, nil, nil, nil, 387, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 338, nil, nil, 343, 324, 325, nil, 404,
- 189, 179, 27, nil, 347, 376, 349, nil, 159, 352,
- 179, 345, 95, nil, 344, nil, nil, nil, nil, nil,
- nil, nil, 159, nil, nil, 289, nil, nil, 358, 179,
- 429, 387, nil, nil, nil, nil, 364, nil, nil, 367,
- nil, nil, nil, 189, nil, nil, nil, nil, nil, nil,
- 372, 373, nil, 375, nil, nil, 95, 378, nil, nil,
- 381, 382, 383, nil, nil, nil, 143, nil, nil, nil,
- nil, 395, 143, nil, nil, 398, nil, 143, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 143,
- nil, nil, nil, nil, nil, nil, 179, nil, nil, 405,
- nil, nil, 407, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 27, nil, 388, 454, 391, nil, 428, 179, nil, nil,
- nil, nil, nil, nil, 95, nil, nil, 27, nil, nil,
- 461, 95, 27, nil, nil, 466, 95, nil, nil, nil,
- nil, nil, 439, nil, nil, nil, nil, nil, nil, nil,
- 408, nil, nil, nil, nil, nil, nil, nil, nil, 452,
- nil, 453, 420, 421, 422, nil, 423, 424, nil, nil,
- 426, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 444, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 456, nil, 457, nil,
- nil, nil, 459, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 467 ]
-
-racc_goto_check = [
- 2, 58, 28, 2, 28, 3, 49, 33, 72, 49,
- 45, 76, 77, 40, 50, 55, 41, 78, 52, 4,
- 42, 74, 74, 31, 38, 27, 32, 64, 25, 37,
- 44, 48, 56, 57, 59, 60, 61, 62, 65, 71,
- 73, 75, 1, nil, nil, 41, nil, nil, nil, nil,
- nil, nil, 77, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 53, nil, nil, nil, 76, 50, 40, nil,
- nil, 72, 35, nil, nil, nil, 67, 66, 67, nil,
- nil, 26, nil, 22, 42, 42, 54, nil, nil, nil,
- nil, 64, 64, 2, nil, nil, 28, 28, nil, nil,
- nil, 28, nil, nil, 55, nil, 22, nil, 22, nil,
- 22, 53, 22, 53, 33, 22, 22, 22, nil, nil,
- nil, nil, 55, nil, 58, nil, 53, 53, 53, 38,
- 31, 45, 22, 55, 22, 22, 22, 52, nil, 22,
- 53, nil, 53, 53, 28, 50, 69, 38, nil, 27,
- 32, nil, 27, 32, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 67, 22, nil, nil, 35, 66, 70, 35,
- nil, 22, 67, nil, 67, 26, 54, nil, 26, nil,
- nil, nil, nil, 28, nil, nil, 3, nil, 22, 22,
- nil, nil, 66, nil, nil, 22, nil, 22, 67, nil,
- 22, 54, nil, 55, 22, 66, 53, 50, 33, nil,
- 49, 33, 22, nil, 54, 22, 22, 22, 22, nil,
- 23, nil, 55, 38, 31, nil, 38, 31, 49, nil,
- 49, nil, nil, 69, nil, 69, nil, nil, nil, 22,
- nil, nil, nil, nil, nil, nil, nil, nil, 23, nil,
- nil, nil, nil, nil, nil, 23, nil, nil, nil, 69,
- nil, nil, nil, nil, nil, nil, 38, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 22, nil, nil, 22, 70, 70, nil, 55,
- 23, 22, 28, nil, 22, 3, 22, nil, 22, 22,
- 22, 50, 2, nil, 49, nil, nil, nil, nil, nil,
- nil, nil, 22, nil, nil, 22, nil, nil, 22, 22,
- 55, 38, nil, nil, nil, nil, 22, nil, nil, 53,
- nil, nil, nil, 23, nil, nil, nil, nil, nil, nil,
- 22, 22, nil, 22, nil, nil, 2, 22, nil, nil,
- 22, 22, 22, nil, nil, nil, 23, nil, nil, nil,
- nil, 22, 23, nil, nil, 22, nil, 23, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 23,
- nil, nil, nil, nil, nil, nil, 22, nil, nil, 22,
- nil, nil, 53, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 28, nil, 70, 3, 70, nil, 53, 22, nil, nil,
- nil, nil, nil, nil, 2, nil, nil, 28, nil, nil,
- 3, 2, 28, nil, nil, 3, 2, nil, nil, nil,
- nil, nil, 22, nil, nil, nil, nil, nil, nil, nil,
- 70, nil, nil, nil, nil, nil, nil, nil, nil, 22,
- nil, 22, 70, 70, 70, nil, 70, 70, nil, nil,
- 70, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 70, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 70, nil, 70, nil,
- nil, nil, 70, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 70 ]
-
-racc_goto_pointer = [
- nil, 42, 0, 5, -76, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 54, 221, nil, 4, -83, -139, 2, nil,
- nil, -34, -138, -50, nil, -92, nil, -262, -35, nil,
- -318, -41, 12, nil, -56, -42, nil, nil, -243, -26,
- -29, nil, -121, 54, 31, -43, -24, -56, -58, -40,
- -180, -179, -27, nil, 19, -48, 22, -86, nil, -169,
- 111, -331, -362, -38, -182, -169, -320, -364, -359 ]
-
-racc_goto_default = [
- nil, nil, 94, 93, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, nil, 25, 26, 144, 28,
- 30, 31, 32, 33, 34, 35, 36, 290, 40, 39,
- 41, 42, 43, 51, 67, nil, 53, 157, 158, 150,
- 138, 68, nil, 55, nil, 297, nil, nil, nil, nil,
- 178, nil, 65, 66, 71, 69, 278, 163, 74, nil,
- 321, nil, nil, nil, nil, nil, nil, nil, nil ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 0, 99, :_reduce_1,
- 1, 99, :_reduce_2,
- 1, 99, :_reduce_3,
- 1, 101, :_reduce_4,
- 3, 101, :_reduce_5,
- 2, 101, :_reduce_6,
- 2, 101, :_reduce_7,
- 1, 102, :_reduce_8,
- 1, 102, :_reduce_9,
- 1, 102, :_reduce_10,
- 1, 102, :_reduce_11,
- 1, 102, :_reduce_12,
- 1, 102, :_reduce_13,
- 1, 102, :_reduce_14,
- 1, 102, :_reduce_15,
- 1, 102, :_reduce_16,
- 1, 102, :_reduce_17,
- 1, 102, :_reduce_18,
- 1, 102, :_reduce_19,
- 1, 102, :_reduce_20,
- 1, 102, :_reduce_21,
- 1, 102, :_reduce_22,
- 1, 102, :_reduce_23,
- 1, 102, :_reduce_24,
- 1, 102, :_reduce_25,
- 1, 120, :_reduce_26,
- 1, 120, :_reduce_27,
- 2, 120, :_reduce_28,
- 1, 120, :_reduce_29,
- 1, 120, :_reduce_30,
- 1, 120, :_reduce_31,
- 1, 120, :_reduce_32,
- 3, 120, :_reduce_33,
- 1, 121, :_reduce_34,
- 1, 121, :_reduce_35,
- 1, 121, :_reduce_36,
- 1, 121, :_reduce_37,
- 1, 121, :_reduce_38,
- 1, 121, :_reduce_39,
- 1, 121, :_reduce_40,
- 3, 121, :_reduce_41,
- 1, 135, :_reduce_42,
- 1, 135, :_reduce_43,
- 1, 135, :_reduce_44,
- 1, 135, :_reduce_45,
- 1, 135, :_reduce_46,
- 1, 135, :_reduce_47,
- 1, 135, :_reduce_48,
- 1, 100, :_reduce_49,
- 1, 100, :_reduce_50,
- 1, 132, :_reduce_51,
- 1, 132, :_reduce_52,
- 1, 132, :_reduce_53,
- 1, 132, :_reduce_54,
- 1, 132, :_reduce_55,
- 1, 132, :_reduce_56,
- 1, 132, :_reduce_57,
- 1, 137, :_reduce_58,
- 1, 136, :_reduce_59,
- 1, 136, :_reduce_60,
- 2, 136, :_reduce_61,
- 2, 136, :_reduce_62,
- 1, 138, :_reduce_63,
- 1, 140, :_reduce_64,
- 1, 139, :_reduce_65,
- 5, 142, :_reduce_66,
- 3, 141, :_reduce_67,
- 4, 141, :_reduce_68,
- 0, 143, :_reduce_69,
- 1, 143, :_reduce_70,
- 3, 143, :_reduce_71,
- 1, 122, :_reduce_72,
- 3, 144, :_reduce_73,
- 4, 144, :_reduce_74,
- 0, 145, :_reduce_75,
- 1, 145, :_reduce_76,
- 3, 145, :_reduce_77,
- 3, 146, :_reduce_78,
- 2, 129, :_reduce_79,
- 2, 129, :_reduce_80,
- 2, 129, :_reduce_81,
- 4, 129, :_reduce_82,
- 2, 130, :_reduce_83,
- 4, 130, :_reduce_84,
- 2, 149, :_reduce_85,
- 3, 148, :_reduce_86,
- 3, 148, :_reduce_87,
- 4, 148, :_reduce_88,
- 4, 148, :_reduce_89,
- 3, 150, :_reduce_90,
- 2, 150, :_reduce_91,
- 2, 150, :_reduce_92,
- 1, 150, :_reduce_93,
- 1, 147, :_reduce_94,
- 2, 147, :_reduce_95,
- 2, 123, :_reduce_96,
- 2, 123, :_reduce_97,
- 5, 133, :_reduce_98,
- 4, 133, :_reduce_99,
- 4, 133, :_reduce_100,
- 2, 133, :_reduce_101,
- 2, 133, :_reduce_102,
- 4, 133, :_reduce_103,
- 5, 155, :_reduce_104,
- 2, 155, :_reduce_105,
- 4, 115, :_reduce_106,
- 2, 115, :_reduce_107,
- 4, 116, :_reduce_108,
- 2, 116, :_reduce_109,
- 2, 156, :_reduce_110,
- 1, 156, :_reduce_111,
- 4, 156, :_reduce_112,
- 6, 103, :_reduce_113,
- 5, 103, :_reduce_114,
- 1, 151, :_reduce_115,
- 0, 151, :_reduce_116,
- 1, 157, :_reduce_117,
- 4, 157, :_reduce_118,
- 0, 153, :_reduce_119,
- 1, 153, :_reduce_120,
- 0, 159, :_reduce_121,
- 1, 159, :_reduce_122,
- 1, 158, :_reduce_123,
- 2, 158, :_reduce_124,
- 3, 158, :_reduce_125,
- 4, 158, :_reduce_126,
- 1, 154, :_reduce_127,
- 3, 154, :_reduce_128,
- 3, 124, :_reduce_129,
- 3, 124, :_reduce_130,
- 3, 124, :_reduce_131,
- 3, 124, :_reduce_132,
- 3, 124, :_reduce_133,
- 3, 124, :_reduce_134,
- 3, 124, :_reduce_135,
- 3, 124, :_reduce_136,
- 3, 124, :_reduce_137,
- 3, 124, :_reduce_138,
- 3, 124, :_reduce_139,
- 3, 124, :_reduce_140,
- 3, 124, :_reduce_141,
- 3, 124, :_reduce_142,
- 3, 124, :_reduce_143,
- 3, 124, :_reduce_144,
- 3, 124, :_reduce_145,
- 3, 124, :_reduce_146,
- 3, 124, :_reduce_147,
- 3, 124, :_reduce_148,
- 3, 124, :_reduce_149,
- 3, 124, :_reduce_150,
- 3, 124, :_reduce_151,
- 3, 124, :_reduce_152,
- 3, 124, :_reduce_153,
- 3, 124, :_reduce_154,
- 3, 124, :_reduce_155,
- 3, 124, :_reduce_156,
- 3, 124, :_reduce_157,
- 3, 124, :_reduce_158,
- 3, 124, :_reduce_159,
- 3, 124, :_reduce_160,
- 3, 124, :_reduce_161,
- 3, 124, :_reduce_162,
- 3, 124, :_reduce_163,
- 2, 128, :_reduce_164,
- 2, 128, :_reduce_165,
- 2, 128, :_reduce_166,
- 2, 126, :_reduce_167,
- 1, 126, :_reduce_168,
- 3, 117, :_reduce_169,
- 3, 117, :_reduce_170,
- 3, 160, :_reduce_171,
- 3, 160, :_reduce_172,
- 3, 160, :_reduce_173,
- 3, 160, :_reduce_174,
- 1, 161, :_reduce_175,
- 1, 161, :_reduce_176,
- 1, 161, :_reduce_177,
- 1, 161, :_reduce_178,
- 1, 161, :_reduce_179,
- 1, 162, :_reduce_180,
- 2, 162, :_reduce_181,
- 2, 162, :_reduce_182,
- 2, 163, :_reduce_183,
- 1, 131, :_reduce_184,
- 2, 131, :_reduce_185,
- 2, 106, :_reduce_186,
- 2, 106, :_reduce_187,
- 2, 106, :_reduce_188,
- 1, 164, :_reduce_189,
- 2, 164, :_reduce_190,
- 2, 164, :_reduce_191,
- 2, 164, :_reduce_192,
- 3, 165, :_reduce_193,
- 4, 165, :_reduce_194,
- 4, 165, :_reduce_195,
- 6, 104, :_reduce_196,
- 9, 104, :_reduce_197,
- 9, 104, :_reduce_198,
- 11, 104, :_reduce_199,
- 1, 166, :_reduce_200,
- 1, 166, :_reduce_201,
- 1, 166, :_reduce_202,
- 1, 152, :_reduce_203,
- 1, 152, :_reduce_204,
- 1, 167, :_reduce_205,
- 2, 167, :_reduce_206,
- 0, 167, :_reduce_207,
- 0, 169, :_reduce_208,
- 1, 169, :_reduce_209,
- 1, 169, :_reduce_210,
- 3, 169, :_reduce_211,
- 3, 169, :_reduce_212,
- 3, 170, :_reduce_213,
- 2, 105, :_reduce_214,
- 4, 105, :_reduce_215,
- 4, 105, :_reduce_216,
- 0, 171, :_reduce_217,
- 1, 171, :_reduce_218,
- 1, 114, :_reduce_219,
- 4, 118, :_reduce_220,
- 5, 118, :_reduce_221,
- 3, 118, :_reduce_222,
- 4, 119, :_reduce_223,
- 5, 119, :_reduce_224,
- 3, 119, :_reduce_225,
- 5, 125, :_reduce_226,
- 4, 109, :_reduce_227,
- 1, 113, :_reduce_228,
- 1, 113, :_reduce_229,
- 4, 110, :_reduce_230,
- 6, 108, :_reduce_231,
- 6, 108, :_reduce_232,
- 6, 108, :_reduce_233,
- 3, 111, :_reduce_234,
- 4, 111, :_reduce_235,
- 6, 111, :_reduce_236,
- 0, 173, :_reduce_237,
- 2, 173, :_reduce_238,
- 3, 173, :_reduce_239,
- 3, 173, :_reduce_240,
- 4, 173, :_reduce_241,
- 1, 174, :_reduce_242,
- 1, 174, :_reduce_243,
- 2, 168, :_reduce_244,
- 1, 168, :_reduce_245,
- 1, 172, :_reduce_246,
- 3, 172, :_reduce_247,
- 3, 172, :_reduce_248,
- 4, 172, :_reduce_249,
- 3, 175, :_reduce_250,
- 4, 176, :_reduce_251,
- 5, 176, :_reduce_252,
- 5, 112, :_reduce_253,
- 8, 112, :_reduce_254,
- 2, 134, :_reduce_255,
- 4, 127, :_reduce_256,
- 1, 127, :_reduce_257,
- 1, 107, :_reduce_258 ]
-
-racc_reduce_n = 259
-
-racc_shift_n = 469
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :IF => 2,
- :ELSE => 3,
- :ELSEIF => 4,
- :THEN => 5,
- :UNLESS => 6,
- :END => 7,
- :WHILE => 8,
- :UNTIL => 9,
- :BREAK => 10,
- :CONTINUE => 11,
- :TRY => 12,
- :CATCH => 13,
- :FINALLY => 14,
- :FOR => 15,
- :IN => 16,
- :DEF => 17,
- :DEF_BANG => 18,
- :SPLAT_PARAM => 19,
- :SPLAT_ARG => 20,
- :CALL => 21,
- :BUILTIN_COMMAND => 22,
- :CLASS => 23,
- :NEW => 24,
- :DEFM => 25,
- :DEFM_BANG => 26,
- :SUPER => 27,
- :RIML_FILE_COMMAND => 28,
- :RIML_CLASS_COMMAND => 29,
- :RETURN => 30,
- :NEWLINE => 31,
- :NUMBER => 32,
- :STRING_D => 33,
- :STRING_S => 34,
- :EX_LITERAL => 35,
- :REGEXP => 36,
- :TRUE => 37,
- :FALSE => 38,
- :LET => 39,
- :UNLET => 40,
- :UNLET_BANG => 41,
- :IDENTIFIER => 42,
- :DICT_VAL => 43,
- :SCOPE_MODIFIER => 44,
- :SCOPE_MODIFIER_LITERAL => 45,
- :SPECIAL_VAR_PREFIX => 46,
- :FINISH => 47,
- "!" => 48,
- "*" => 49,
- "/" => 50,
- "%" => 51,
- "+" => 52,
- "-" => 53,
- "." => 54,
- ">" => 55,
- ">#" => 56,
- ">?" => 57,
- "<" => 58,
- "<#" => 59,
- "<?" => 60,
- ">=" => 61,
- ">=#" => 62,
- ">=?" => 63,
- "<=" => 64,
- "<=#" => 65,
- "<=?" => 66,
- "==" => 67,
- "==?" => 68,
- "==#" => 69,
- "=~" => 70,
- "=~?" => 71,
- "=~#" => 72,
- "!~" => 73,
- "!~?" => 74,
- "!~#" => 75,
- "!=" => 76,
- "!=?" => 77,
- "!=#" => 78,
- :IS => 79,
- :ISNOT => 80,
- "&&" => 81,
- "||" => 82,
- "?" => 83,
- "=" => 84,
- "+=" => 85,
- "-=" => 86,
- ".=" => 87,
- "," => 88,
- "(" => 89,
- ")" => 90,
- ";" => 91,
- "[" => 92,
- "]" => 93,
- "{" => 94,
- "}" => 95,
- ":" => 96,
- "===" => 97 }
-
-racc_nt_base = 98
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "IF",
- "ELSE",
- "ELSEIF",
- "THEN",
- "UNLESS",
- "END",
- "WHILE",
- "UNTIL",
- "BREAK",
- "CONTINUE",
- "TRY",
- "CATCH",
- "FINALLY",
- "FOR",
- "IN",
- "DEF",
- "DEF_BANG",
- "SPLAT_PARAM",
- "SPLAT_ARG",
- "CALL",
- "BUILTIN_COMMAND",
- "CLASS",
- "NEW",
- "DEFM",
- "DEFM_BANG",
- "SUPER",
- "RIML_FILE_COMMAND",
- "RIML_CLASS_COMMAND",
- "RETURN",
- "NEWLINE",
- "NUMBER",
- "STRING_D",
- "STRING_S",
- "EX_LITERAL",
- "REGEXP",
- "TRUE",
- "FALSE",
- "LET",
- "UNLET",
- "UNLET_BANG",
- "IDENTIFIER",
- "DICT_VAL",
- "SCOPE_MODIFIER",
- "SCOPE_MODIFIER_LITERAL",
- "SPECIAL_VAR_PREFIX",
- "FINISH",
- "\"!\"",
- "\"*\"",
- "\"/\"",
- "\"%\"",
- "\"+\"",
- "\"-\"",
- "\".\"",
- "\">\"",
- "\">#\"",
- "\">?\"",
- "\"<\"",
- "\"<#\"",
- "\"<?\"",
- "\">=\"",
- "\">=#\"",
- "\">=?\"",
- "\"<=\"",
- "\"<=#\"",
- "\"<=?\"",
- "\"==\"",
- "\"==?\"",
- "\"==#\"",
- "\"=~\"",
- "\"=~?\"",
- "\"=~#\"",
- "\"!~\"",
- "\"!~?\"",
- "\"!~#\"",
- "\"!=\"",
- "\"!=?\"",
- "\"!=#\"",
- "IS",
- "ISNOT",
- "\"&&\"",
- "\"||\"",
- "\"?\"",
- "\"=\"",
- "\"+=\"",
- "\"-=\"",
- "\".=\"",
- "\",\"",
- "\"(\"",
- "\")\"",
- "\";\"",
- "\"[\"",
- "\"]\"",
- "\"{\"",
- "\"}\"",
- "\":\"",
- "\"===\"",
- "$start",
- "Root",
- "Terminator",
- "Statements",
- "Statement",
- "ExplicitCall",
- "Def",
- "Return",
- "UnletVariable",
- "ExLiteral",
- "For",
- "While",
- "Until",
- "Try",
- "ClassDefinition",
- "LoopKeyword",
- "EndScript",
- "RimlFileCommand",
- "RimlClassCommand",
- "MultiAssign",
- "If",
- "Unless",
- "Expression",
- "ExpressionWithoutDictLiteral",
- "Dictionary",
- "DictGetWithDotLiteral",
- "BinaryOperator",
- "Ternary",
- "Assign",
- "Super",
- "UnaryOperator",
- "DictGet",
- "ListOrDictGet",
- "AllVariableRetrieval",
- "LiteralWithoutDictLiteral",
- "Call",
- "ObjectInstantiation",
- "PossibleStringValue",
- "String",
- "Number",
- "Regexp",
- "List",
- "ScopeModifierLiteral",
- "ListLiteral",
- "ListUnpack",
- "ListItems",
- "DictionaryLiteral",
- "DictItems",
- "DictItem",
- "DictGetWithDot",
- "ListOrDictGetWithBrackets",
- "ListOrDictGetAssign",
- "SubList",
- "Scope",
- "DefCallIdentifier",
- "ArgList",
- "ArgListWithoutNothing",
- "ObjectInstantiationCall",
- "ClassArgList",
- "SIDAndScope",
- "ArgListWithoutNothingWithSplat",
- "ArgListWithSplat",
- "AssignExpression",
- "AssignLHS",
- "VariableRetrieval",
- "SimpleVariableRetrieval",
- "CurlyBraceName",
- "CurlyBraceVarPart",
- "FunctionType",
- "DefKeywords",
- "Block",
- "ParamList",
- "DefaultParam",
- "Returnable",
- "IfBlock",
- "Catch",
- "Catchable",
- "ElseBlock",
- "ElseifBlock" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'riml.y', 61)
- def _reduce_1(val, _values, result)
- result = make_node(val) { |_| Riml::Nodes.new([]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 62)
- def _reduce_2(val, _values, result)
- result = make_node(val) { |_| Riml::Nodes.new([]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 63)
- def _reduce_3(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 68)
- def _reduce_4(val, _values, result)
- result = make_node(val) { |v| Riml::Nodes.new([ v[0] ]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 69)
- def _reduce_5(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 70)
- def _reduce_6(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 71)
- def _reduce_7(val, _values, result)
- result = make_node(val) { |v| Riml::Nodes.new(v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 76)
- def _reduce_8(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 77)
- def _reduce_9(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 78)
- def _reduce_10(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 79)
- def _reduce_11(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 80)
- def _reduce_12(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 81)
- def _reduce_13(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 82)
- def _reduce_14(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 83)
- def _reduce_15(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 84)
- def _reduce_16(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 85)
- def _reduce_17(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 86)
- def _reduce_18(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 87)
- def _reduce_19(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 88)
- def _reduce_20(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 89)
- def _reduce_21(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 90)
- def _reduce_22(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 91)
- def _reduce_23(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 92)
- def _reduce_24(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 93)
- def _reduce_25(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 97)
- def _reduce_26(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 98)
- def _reduce_27(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 99)
- def _reduce_28(val, _values, result)
- result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 100)
- def _reduce_29(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 101)
- def _reduce_30(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 102)
- def _reduce_31(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 103)
- def _reduce_32(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 104)
- def _reduce_33(val, _values, result)
- result = make_node(val) { |v| Riml::WrapInParensNode.new(v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 108)
- def _reduce_34(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 109)
- def _reduce_35(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 110)
- def _reduce_36(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 111)
- def _reduce_37(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 112)
- def _reduce_38(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 113)
- def _reduce_39(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 114)
- def _reduce_40(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 115)
- def _reduce_41(val, _values, result)
- result = make_node(val) { |v| Riml::WrapInParensNode.new(v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 120)
- def _reduce_42(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 121)
- def _reduce_43(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 122)
- def _reduce_44(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 123)
- def _reduce_45(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 124)
- def _reduce_46(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 125)
- def _reduce_47(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 126)
- def _reduce_48(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 130)
- def _reduce_49(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 131)
- def _reduce_50(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 135)
- def _reduce_51(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 136)
- def _reduce_52(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 137)
- def _reduce_53(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 138)
- def _reduce_54(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 139)
- def _reduce_55(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 140)
- def _reduce_56(val, _values, result)
- result = make_node(val) { |_| Riml::TrueNode.new }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 141)
- def _reduce_57(val, _values, result)
- result = make_node(val) { |_| Riml::FalseNode.new }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 145)
- def _reduce_58(val, _values, result)
- result = make_node(val) { |v| Riml::NumberNode.new(v[0]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 149)
- def _reduce_59(val, _values, result)
- result = make_node(val) { |v| Riml::StringNode.new(v[0], :s) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 150)
- def _reduce_60(val, _values, result)
- result = make_node(val) { |v| Riml::StringNode.new(v[0], :d) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 151)
- def _reduce_61(val, _values, result)
- result = make_node(val) { |v| Riml::StringLiteralConcatNode.new(v[0], Riml::StringNode.new(v[1], :s)) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 152)
- def _reduce_62(val, _values, result)
- result = make_node(val) { |v| Riml::StringLiteralConcatNode.new(v[0], Riml::StringNode.new(v[1], :d)) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 156)
- def _reduce_63(val, _values, result)
- result = make_node(val) { |v| Riml::RegexpNode.new(v[0]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 160)
- def _reduce_64(val, _values, result)
- result = make_node(val) { |v| Riml::ScopeModifierLiteralNode.new(v[0]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 164)
- def _reduce_65(val, _values, result)
- result = make_node(val) { |v| Riml::ListNode.new(v[0]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 168)
- def _reduce_66(val, _values, result)
- result = make_node(val) { |v| Riml::ListUnpackNode.new(v[1] << v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 172)
- def _reduce_67(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 173)
- def _reduce_68(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 177)
- def _reduce_69(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 178)
- def _reduce_70(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 179)
- def _reduce_71(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 183)
- def _reduce_72(val, _values, result)
- result = make_node(val) { |v| Riml::DictionaryNode.new(v[0]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 190)
- def _reduce_73(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 191)
- def _reduce_74(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 196)
- def _reduce_75(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 197)
- def _reduce_76(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 198)
- def _reduce_77(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 203)
- def _reduce_78(val, _values, result)
- result = [val[0], val[2]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 207)
- def _reduce_79(val, _values, result)
- result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 208)
- def _reduce_80(val, _values, result)
- result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 209)
- def _reduce_81(val, _values, result)
- result = make_node(val) { |v| Riml::DictGetDotNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 210)
- def _reduce_82(val, _values, result)
- result = make_node(val) { |v| Riml::DictGetDotNode.new(Riml::WrapInParensNode.new(v[1]), v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 214)
- def _reduce_83(val, _values, result)
- result = make_node(val) { |v| Riml::ListOrDictGetNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 215)
- def _reduce_84(val, _values, result)
- result = make_node(val) { |v| Riml::ListOrDictGetNode.new(Riml::WrapInParensNode.new(v[1]), v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 219)
- def _reduce_85(val, _values, result)
- result = make_node(val) { |v| Riml::ListOrDictGetNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 223)
- def _reduce_86(val, _values, result)
- result = [val[1]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 224)
- def _reduce_87(val, _values, result)
- result = [val[1]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 225)
- def _reduce_88(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 226)
- def _reduce_89(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 230)
- def _reduce_90(val, _values, result)
- result = make_node(val) { |v| Riml::SublistNode.new([v[0], Riml::LiteralNode.new(' : '), v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 231)
- def _reduce_91(val, _values, result)
- result = make_node(val) { |v| Riml::SublistNode.new([v[0], Riml::LiteralNode.new(' :')]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 232)
- def _reduce_92(val, _values, result)
- result = make_node(val) { |v| Riml::SublistNode.new([Riml::LiteralNode.new(': '), v[1]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 233)
- def _reduce_93(val, _values, result)
- result = make_node(val) { |_| Riml::SublistNode.new([Riml::LiteralNode.new(':')]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 237)
- def _reduce_94(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 238)
- def _reduce_95(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 242)
- def _reduce_96(val, _values, result)
- result = [val[1]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 243)
- def _reduce_97(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 247)
- def _reduce_98(val, _values, result)
- result = make_node(val) { |v| Riml::CallNode.new(v[0], v[1], v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 248)
- def _reduce_99(val, _values, result)
- result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 249)
- def _reduce_100(val, _values, result)
- result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 250)
- def _reduce_101(val, _values, result)
- result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 251)
- def _reduce_102(val, _values, result)
- result = make_node(val) { |v| Riml::CallNode.new(nil, v[0], []) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 252)
- def _reduce_103(val, _values, result)
- result = make_node(val) { |v| Riml::ExplicitCallNode.new(nil, nil, v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 256)
- def _reduce_104(val, _values, result)
- result = make_node(val) { |v| Riml::CallNode.new(v[0], v[1], v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 257)
- def _reduce_105(val, _values, result)
- result = make_node(val) { |v| Riml::CallNode.new(v[0], v[1], []) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 261)
- def _reduce_106(val, _values, result)
- result = make_node(val) { |v| Riml::RimlFileCommandNode.new(nil, v[0], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 262)
- def _reduce_107(val, _values, result)
- result = make_node(val) { |v| Riml::RimlFileCommandNode.new(nil, v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 266)
- def _reduce_108(val, _values, result)
- result = make_node(val) { |v| Riml::RimlClassCommandNode.new(nil, v[0], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 267)
- def _reduce_109(val, _values, result)
- result = make_node(val) { |v| Riml::RimlClassCommandNode.new(nil, v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 271)
- def _reduce_110(val, _values, result)
- result = ["#{val[0]}#{val[1]}"]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 272)
- def _reduce_111(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 273)
- def _reduce_112(val, _values, result)
- result = val[0].concat ["#{val[2]}#{val[3]}"]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 277)
- def _reduce_113(val, _values, result)
- result = make_node(val) { |v| Riml::ExplicitCallNode.new(v[1], v[2], v[4]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 278)
- def _reduce_114(val, _values, result)
- result = make_node(val) { |v| Riml::ExplicitCallNode.new(nil, v[1], v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 282)
- def _reduce_115(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 283)
- def _reduce_116(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 288)
- def _reduce_117(val, _values, result)
- result = [ nil, val[0] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 289)
- def _reduce_118(val, _values, result)
- result = [ make_node(val) { |v| Riml::SIDNode.new(v[1]) }, val[3] ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 293)
- def _reduce_119(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 294)
- def _reduce_120(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 298)
- def _reduce_121(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 299)
- def _reduce_122(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 303)
- def _reduce_123(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 304)
- def _reduce_124(val, _values, result)
- result = [ make_node(val) { |v| Riml::SplatNode.new(v[1]) } ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 305)
- def _reduce_125(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 306)
- def _reduce_126(val, _values, result)
- result = val[0] << make_node(val) { |v| Riml::SplatNode.new(v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 310)
- def _reduce_127(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 311)
- def _reduce_128(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 315)
- def _reduce_129(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 316)
- def _reduce_130(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 318)
- def _reduce_131(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 319)
- def _reduce_132(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 320)
- def _reduce_133(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 323)
- def _reduce_134(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 325)
- def _reduce_135(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 326)
- def _reduce_136(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 327)
- def _reduce_137(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 329)
- def _reduce_138(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 330)
- def _reduce_139(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 331)
- def _reduce_140(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 333)
- def _reduce_141(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 334)
- def _reduce_142(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 335)
- def _reduce_143(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 337)
- def _reduce_144(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 338)
- def _reduce_145(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 339)
- def _reduce_146(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 341)
- def _reduce_147(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 342)
- def _reduce_148(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 343)
- def _reduce_149(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 345)
- def _reduce_150(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 346)
- def _reduce_151(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 347)
- def _reduce_152(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 349)
- def _reduce_153(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 350)
- def _reduce_154(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 351)
- def _reduce_155(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 353)
- def _reduce_156(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 354)
- def _reduce_157(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 355)
- def _reduce_158(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 356)
- def _reduce_159(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 357)
- def _reduce_160(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 358)
- def _reduce_161(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 360)
- def _reduce_162(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 361)
- def _reduce_163(val, _values, result)
- result = make_node(val) { |v| Riml::BinaryOperatorNode.new(v[1], [v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 365)
- def _reduce_164(val, _values, result)
- result = make_node(val) { |v| Riml::UnaryOperatorNode.new(val[0], [val[1]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 366)
- def _reduce_165(val, _values, result)
- result = make_node(val) { |v| Riml::UnaryOperatorNode.new(val[0], [val[1]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 367)
- def _reduce_166(val, _values, result)
- result = make_node(val) { |v| Riml::UnaryOperatorNode.new(val[0], [val[1]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 372)
- def _reduce_167(val, _values, result)
- result = make_node(val) { |v| Riml::AssignNode.new(v[1][0], v[1][1], v[1][2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 373)
- def _reduce_168(val, _values, result)
- result = make_node(val) { |v| Riml::AssignNode.new(v[0][0], v[0][1], v[0][2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 377)
- def _reduce_169(val, _values, result)
- result = make_node(val) { |v| Riml::MultiAssignNode.new([v[0], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 378)
- def _reduce_170(val, _values, result)
- val[0].assigns << val[2]; result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 383)
- def _reduce_171(val, _values, result)
- result = [val[1], val[0], val[2]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 384)
- def _reduce_172(val, _values, result)
- result = [val[1], val[0], val[2]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 385)
- def _reduce_173(val, _values, result)
- result = [val[1], val[0], val[2]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 386)
- def _reduce_174(val, _values, result)
- result = [val[1], val[0], val[2]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 390)
- def _reduce_175(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 391)
- def _reduce_176(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 392)
- def _reduce_177(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 393)
- def _reduce_178(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 394)
- def _reduce_179(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 399)
- def _reduce_180(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 400)
- def _reduce_181(val, _values, result)
- result = make_node(val) { |v| Riml::GetSpecialVariableNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 401)
- def _reduce_182(val, _values, result)
- result = make_node(val) { |v| Riml::GetVariableByScopeAndDictNameNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 405)
- def _reduce_183(val, _values, result)
- result = make_node(val) { |v| Riml::GetVariableNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 409)
- def _reduce_184(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 410)
- def _reduce_185(val, _values, result)
- result = make_node(val) { |v| Riml::GetCurlyBraceNameNode.new(v[0], v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 414)
- def _reduce_186(val, _values, result)
- result = make_node(val) { |v| Riml::UnletVariableNode.new('!', [ v[1] ]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 415)
- def _reduce_187(val, _values, result)
- result = make_node(val) { |v| Riml::UnletVariableNode.new('!', [ v[1] ]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 416)
- def _reduce_188(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 420)
- def _reduce_189(val, _values, result)
- result = make_node(val) { |v| Riml::CurlyBraceVariable.new([ v[0] ]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 421)
- def _reduce_190(val, _values, result)
- result = make_node(val) { |v| Riml::CurlyBraceVariable.new([ Riml::CurlyBracePart.new(v[0]), v[1] ]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 422)
- def _reduce_191(val, _values, result)
- result = val[0] << make_node(val) { |v| Riml::CurlyBracePart.new(v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 423)
- def _reduce_192(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 427)
- def _reduce_193(val, _values, result)
- result = make_node(val) { |v| Riml::CurlyBracePart.new(v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 428)
- def _reduce_194(val, _values, result)
- result = make_node(val) { |v| Riml::CurlyBracePart.new([v[1], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 429)
- def _reduce_195(val, _values, result)
- result = make_node(val) { |v| Riml::CurlyBracePart.new([v[1], v[2]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 435)
- def _reduce_196(val, _values, result)
- result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], [], v[3], v[4]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 436)
- def _reduce_197(val, _values, result)
- result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], v[4], v[6], v[7]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 437)
- def _reduce_198(val, _values, result)
- result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], [v[4]], v[6], v[7]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 438)
- def _reduce_199(val, _values, result)
- result = make_node(val) { |v| Riml.const_get(val[0]).new('!', v[1][0], v[1][1], v[2], v[4] << v[6], v[8], v[9]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 442)
- def _reduce_200(val, _values, result)
- result = "DefNode"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 443)
- def _reduce_201(val, _values, result)
- result = "DefNode"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 444)
- def _reduce_202(val, _values, result)
- result = "DefMethodNode"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 449)
- def _reduce_203(val, _values, result)
- result = make_node(val) { |v| Riml::GetCurlyBraceNameNode.new('', v[0]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 450)
- def _reduce_204(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 455)
- def _reduce_205(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 456)
- def _reduce_206(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 457)
- def _reduce_207(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 461)
- def _reduce_208(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 462)
- def _reduce_209(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 463)
- def _reduce_210(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 464)
- def _reduce_211(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 465)
- def _reduce_212(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 469)
- def _reduce_213(val, _values, result)
- result = make_node(val) { |v| Riml::DefaultParamNode.new(v[0], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 473)
- def _reduce_214(val, _values, result)
- result = make_node(val) { |v| Riml::ReturnNode.new(v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 474)
- def _reduce_215(val, _values, result)
- result = make_node(val) { |v| Riml::IfNode.new(v[3], Nodes.new([ReturnNode.new(v[1])])) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 475)
- def _reduce_216(val, _values, result)
- result = make_node(val) { |v| Riml::UnlessNode.new(v[3], Nodes.new([ReturnNode.new(v[1])])) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 479)
- def _reduce_217(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 480)
- def _reduce_218(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 484)
- def _reduce_219(val, _values, result)
- result = make_node(val) { |_| Riml::FinishNode.new }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 489)
- def _reduce_220(val, _values, result)
- result = make_node(val) { |v| Riml::IfNode.new(v[1], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 490)
- def _reduce_221(val, _values, result)
- result = make_node(val) { |v| Riml::IfNode.new(v[1], Riml::Nodes.new([v[3]])) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 491)
- def _reduce_222(val, _values, result)
- result = make_node(val) { |v| Riml::IfNode.new(v[2], Riml::Nodes.new([v[0]])) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 495)
- def _reduce_223(val, _values, result)
- result = make_node(val) { |v| Riml::UnlessNode.new(v[1], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 496)
- def _reduce_224(val, _values, result)
- result = make_node(val) { |v| Riml::UnlessNode.new(v[1], Riml::Nodes.new([v[3]])) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 497)
- def _reduce_225(val, _values, result)
- result = make_node(val) { |v| Riml::UnlessNode.new(v[2], Riml::Nodes.new([v[0]])) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 501)
- def _reduce_226(val, _values, result)
- result = make_node(val) { |v| Riml::TernaryOperatorNode.new([v[0], v[2], v[4]]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 505)
- def _reduce_227(val, _values, result)
- result = make_node(val) { |v| Riml::WhileNode.new(v[1], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 509)
- def _reduce_228(val, _values, result)
- result = make_node(val) { |_| Riml::BreakNode.new }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 510)
- def _reduce_229(val, _values, result)
- result = make_node(val) { |_| Riml::ContinueNode.new }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 514)
- def _reduce_230(val, _values, result)
- result = make_node(val) { |v| Riml::UntilNode.new(v[1], v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 518)
- def _reduce_231(val, _values, result)
- result = make_node(val) { |v| Riml::ForNode.new(v[1], v[3], v[4]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 519)
- def _reduce_232(val, _values, result)
- result = make_node(val) { |v| Riml::ForNode.new(v[1], v[3], v[4]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 520)
- def _reduce_233(val, _values, result)
- result = make_node(val) { |v| Riml::ForNode.new(v[1], v[3], v[4]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 524)
- def _reduce_234(val, _values, result)
- result = make_node(val) { |v| Riml::TryNode.new(v[1], nil, nil) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 525)
- def _reduce_235(val, _values, result)
- result = make_node(val) { |v| Riml::TryNode.new(v[1], v[2], nil) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 526)
- def _reduce_236(val, _values, result)
- result = make_node(val) { |v| Riml::TryNode.new(v[1], v[2], v[4]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 530)
- def _reduce_237(val, _values, result)
- result = nil
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 531)
- def _reduce_238(val, _values, result)
- result = [ make_node(val) { |v| Riml::CatchNode.new(nil, v[1]) } ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 532)
- def _reduce_239(val, _values, result)
- result = [ make_node(val) { |v| Riml::CatchNode.new(v[1], v[2]) } ]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 533)
- def _reduce_240(val, _values, result)
- result = val[0] << make_node(val) { |v| Riml::CatchNode.new(nil, v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 534)
- def _reduce_241(val, _values, result)
- result = val[0] << make_node(val) { |v| Riml::CatchNode.new(v[2], v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 538)
- def _reduce_242(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 539)
- def _reduce_243(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 546)
- def _reduce_244(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 547)
- def _reduce_245(val, _values, result)
- result = make_node(val) { |_| Riml::Nodes.new([]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 551)
- def _reduce_246(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 552)
- def _reduce_247(val, _values, result)
- result = val[1] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 553)
- def _reduce_248(val, _values, result)
- result = val[1] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 554)
- def _reduce_249(val, _values, result)
- result = val[1] << val[2] << val[3]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 558)
- def _reduce_250(val, _values, result)
- result = make_node(val) { |v| Riml::ElseNode.new(v[2]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 562)
- def _reduce_251(val, _values, result)
- result = make_node(val) { |v| Riml::Nodes.new([Riml::ElseifNode.new(v[1], v[3])]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 563)
- def _reduce_252(val, _values, result)
- result = val[0] << make_node(val) { |v| Riml::ElseifNode.new(v[2], v[4]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 567)
- def _reduce_253(val, _values, result)
- result = make_node(val) { |v| Riml::ClassDefinitionNode.new(v[1], v[2], nil, v[3]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 568)
- def _reduce_254(val, _values, result)
- result = make_node(val) { |v| Riml::ClassDefinitionNode.new(v[1], v[2], (v[4] || ClassDefinitionNode::DEFAULT_SCOPE_MODIFIER) + v[5], v[6]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 572)
- def _reduce_255(val, _values, result)
- result = make_node(val) { |v| Riml::ObjectInstantiationNode.new(v[1]) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 576)
- def _reduce_256(val, _values, result)
- result = make_node(val) { |v| Riml::SuperNode.new(v[2], true) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 577)
- def _reduce_257(val, _values, result)
- result = make_node(val) { |_| Riml::SuperNode.new([], false) }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'riml.y', 581)
- def _reduce_258(val, _values, result)
- result = make_node(val) { |v| Riml::ExLiteralNode.new(v[0]) }
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module Riml
diff --git a/test/racc/regress/ruby18 b/test/racc/regress/ruby18
deleted file mode 100644
index 24852df6fc..0000000000
--- a/test/racc/regress/ruby18
+++ /dev/null
@@ -1,6351 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-
-require 'parser'
-
-module Parser
- class Ruby18 < Racc::Parser
-
-module_eval(<<'...end ruby18.y/module_eval...', 'ruby18.y', 1936)
-
- def version
- 18
- end
-
- def default_encoding
- Encoding::BINARY if defined? Encoding
- end
-...end ruby18.y/module_eval...
-##### State transition tables begin ###
-
-clist = [
-'-277,195,196,195,196,489,-84,-277,-277,-277,511,814,578,-277,-277,-81',
-'-277,-429,558,579,531,558,489,489,-425,-82,72,259,-87,568,578,-425,195',
-'196,73,-277,-277,579,-277,-277,-277,-277,-277,489,489,477,-426,-80,476',
-'-83,-86,395,557,-426,-61,557,535,659,658,662,661,291,-74,-80,-277,-277',
-'-277,-277,-277,-277,-277,-277,-277,-277,-277,-277,-277,-277,536,291',
-'-277,-277,-277,530,549,722,477,-76,-277,479,99,-277,291,-69,621,98,-277',
-'-87,-277,-85,-277,-277,-277,-277,-277,-277,-277,-480,-277,-76,-277,258',
-'-476,510,-480,-480,-480,99,-73,488,-480,-480,98,-480,-277,-277,-74,-77',
-'-74,-277,-85,-79,-480,99,99,99,488,488,98,98,98,621,-480,-480,-74,-480',
-'-480,-480,-480,-480,-72,-76,-75,-78,768,99,99,488,488,621,98,98,-477',
-'-427,431,-74,538,558,-74,-76,-427,-480,-480,-480,-480,-480,-480,-480',
-'-480,-480,-480,-480,-480,-480,-480,-476,259,-480,-480,-480,-76,546,99',
-'-76,620,-480,259,98,-480,463,-81,557,-77,-480,521,-480,713,-480,-480',
-'-480,-480,-480,-480,-480,-226,-480,-480,-480,542,734,606,-226,-226,-226',
-'-474,194,-226,-226,-226,-259,-226,-480,-480,680,-75,-476,-480,-83,691',
-'99,-226,620,-476,558,98,-86,814,-476,254,-226,-226,-476,-226,-226,-226',
-'-226,-226,99,254,620,521,-76,98,541,-84,523,522,-429,-79,-476,258,-87',
-'540,463,-421,673,-73,557,254,-81,258,-421,690,521,-84,-473,-474,521',
-'361,-226,-421,-272,659,658,662,661,-226,825,-272,-272,-272,254,-226',
-'-272,-272,-272,-74,-272,-474,-82,-72,477,215,-80,482,99,-78,-272,-272',
-'-86,98,523,522,532,-226,215,-272,-272,-82,-272,-272,-272,-272,-272,-421',
-'-417,477,215,-226,479,-226,-421,-417,-226,523,522,527,-473,523,522,526',
-'-417,495,215,496,-272,-272,-272,-272,-272,-272,-272,-272,-272,-272,-272',
-'-272,-272,-272,-473,-271,-272,-272,-272,-278,826,-272,-271,827,-272',
-'521,-278,-272,-272,521,-272,-271,-272,568,-272,-278,-272,-272,-272,-272',
-'-272,-272,-272,-226,-272,-480,-272,-417,-480,502,-226,-226,-226,503',
-'-417,-226,-226,-226,-477,-226,-272,-272,-272,-272,215,-272,568,215,-422',
-'-226,251,-480,606,-279,496,-422,575,252,-226,-226,-279,-226,-226,-226',
-'-226,-226,523,522,524,-279,523,522,519,195,196,-480,212,291,-480,212',
-'214,213,-480,214,213,-480,192,-476,-477,215,-476,-480,99,193,-480,-477',
-'516,98,-226,-319,-477,-480,191,517,-477,-226,-319,-277,-480,-480,254',
-'-226,-480,-476,-277,-319,580,-480,234,-477,829,212,-477,-277,-428,214',
-'213,210,211,284,285,-428,590,-226,655,-480,653,652,651,654,-428,-424',
-'-477,-477,-477,591,-477,-226,-424,-226,-477,-477,-226,734,606,-477,-69',
-'-477,-477,-477,-477,-477,-477,-477,461,462,662,661,-477,-477,-477,-477',
-'-477,-477,-477,195,196,592,-423,215,659,658,662,661,-477,-423,830,-477',
-'-477,-477,-477,-477,-477,-477,-477,-477,-477,469,-477,-477,832,-477',
-'-477,-477,215,-497,-497,-497,-497,221,223,212,457,-497,-497,214,213',
-'210,211,458,229,230,880,-477,549,835,-477,-477,456,-477,-477,195,196',
-'-477,568,-477,212,-477,218,-477,214,213,210,211,222,220,216,-477,217',
-'606,187,291,-477,-477,-477,-477,-477,-477,839,-271,840,-477,-477,-476',
-'-476,-476,-271,-476,349,358,-85,-476,-476,360,359,-271,-476,616,-476',
-'-476,-476,-476,-476,-476,-476,496,624,846,847,-476,-476,-476,-476,-476',
-'-476,-476,99,99,99,672,675,98,98,98,848,-476,758,758,-476,-476,-476',
-'-476,-476,-476,-476,-476,-476,-476,759,-476,-476,436,-476,-476,-476',
-'215,219,224,225,226,221,223,883,-279,227,228,466,436,186,-278,-279,229',
-'230,467,-476,692,-278,-476,-476,-279,-476,-476,393,291,-476,-278,-476',
-'212,-476,218,-476,214,213,210,211,222,220,216,-476,217,693,758,704,-476',
-'-476,-476,-476,-476,-476,431,498,431,-476,-476,62,63,64,499,51,243,707',
-'-83,56,57,708,861,497,60,715,58,59,61,23,24,65,66,885,717,283,721,22',
-'28,27,88,87,89,90,667,668,17,669,93,94,254,537,254,41,215,215,92,91',
-'82,50,84,83,86,85,93,94,724,80,81,282,38,39,37,215,219,224,225,226,221',
-'223,231,232,227,228,-277,208,209,-428,-259,229,230,-277,200,728,-428',
-'204,-477,730,52,53,-277,606,54,-428,738,212,739,218,40,214,213,210,211',
-'222,220,216,18,217,740,886,743,79,72,74,75,76,77,568,507,745,73,78,749',
-'99,233,505,-215,753,98,62,63,64,7,51,506,755,391,56,57,758,759,760,60',
-'392,58,59,61,23,24,65,66,761,393,763,234,22,28,27,88,87,89,90,-260,818',
-'17,101,102,103,104,105,6,41,8,9,92,91,82,50,84,83,86,85,93,94,568,80',
-'81,471,38,39,37,215,219,224,225,226,221,223,231,823,227,228,-277,769',
-'396,-278,824,229,230,-277,36,397,-278,30,-477,822,52,53,-277,777,54',
-'-278,32,212,778,218,40,214,213,210,211,222,220,216,18,217,568,95,568',
-'79,72,74,75,76,77,254,254,234,73,78,62,63,64,874,51,875,351,568,56,57',
-'790,791,792,60,876,58,59,61,246,247,65,66,797,799,190,426,245,275,279',
-'88,87,89,90,101,102,103,104,105,428,189,431,436,276,805,-60,92,91,82',
-'50,84,83,86,85,93,94,394,80,81,215,451,655,280,653,652,651,654,101,102',
-'103,104,105,452,453,188,229,230,459,263,291,254,464,772,465,215,204',
-'807,471,52,53,472,212,54,218,291,214,213,210,211,645,291,216,481,217',
-'484,351,500,659,658,662,661,79,72,74,75,76,77,501,,,73,78,,62,63,64',
-'855,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87',
-'89,90,,,,,,,,537,,276,,,92,91,82,50,84,83,86,85,93,94,,80,81,,,,280',
-'215,219,224,225,226,221,223,231,232,227,228,,208,209,,,229,230,,772',
-',,204,,,52,53,,,54,,,212,,218,,214,213,210,211,222,220,216,,217,,,,79',
-'72,74,75,76,77,,,,73,78,,,233,,775,5,62,63,64,7,51,,,,56,57,,,,60,,58',
-'59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91',
-'82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,265',
-',,52,53,,,54,,32,,,,40,655,,653,652,651,654,,18,,,,,79,72,74,75,76,77',
-',,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,645,58,59,61,23,24,65,66,659',
-'658,662,661,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,,,54',
-',32,,,,40,655,,653,652,651,654,,18,,,,,79,72,74,75,76,77,,,,73,78,5',
-'62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,659,658,662,661,22',
-'28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,',
-'80,81,,38,39,37,215,,,,,,,,,,,,,,,,229,230,,36,,,30,,,52,53,,,54,,32',
-'212,,218,40,214,213,210,211,,,216,18,217,,,,79,72,74,75,76,77,,,,73',
-'78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27',
-'88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81',
-',38,39,37,215,-497,-497,-497,-497,221,223,,,-497,-497,,,,,,229,230,',
-'36,,,30,,,52,53,,,54,,32,212,,218,40,214,213,210,211,222,220,216,18',
-'217,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58',
-'59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91',
-'82,50,84,83,86,85,93,94,,80,81,,38,39,37,215,,,,,,,,,,,,,,,,229,230',
-',36,,,30,,,52,53,,,54,,32,212,,218,40,214,213,210,211,,,216,18,217,',
-',,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61',
-'23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50',
-'84,83,86,85,93,94,,80,81,,38,39,37,215,219,224,225,226,221,223,231,232',
-'227,228,,-497,-497,,,229,230,,36,,,30,,,52,53,,,54,,32,212,,218,40,214',
-'213,210,211,222,220,216,18,217,,,,79,72,74,75,76,77,,,,73,78,5,62,63',
-'64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90',
-',,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,215',
-'219,224,225,226,221,223,231,232,227,228,,-497,-497,,,229,230,,36,,,30',
-',,52,53,,,54,,32,212,,218,40,214,213,210,211,222,220,216,18,217,,,,79',
-'72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23',
-'24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84',
-'83,86,85,93,94,,80,81,,38,39,37,215,-497,-497,-497,-497,221,223,,,-497',
-'-497,,,,,,229,230,,36,,,30,,,52,53,,,54,,32,212,,218,40,214,213,210',
-'211,222,220,216,18,217,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51',
-',,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,',
-',,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,215,-497',
-'-497,-497,-497,221,223,,,-497,-497,,,,,,229,230,,36,,,30,,,52,53,,,54',
-',32,212,,218,40,214,213,210,211,222,220,216,18,217,,,,79,72,74,75,76',
-'77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,',
-',22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,215,,,,,,,,,,,,,,,,229,230,,36,,,30,,,52,53,,,54',
-',32,212,,218,40,214,213,210,211,,,216,18,217,,,,79,72,74,75,76,77,,',
-',73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28',
-'27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80',
-'81,,38,39,37,215,-497,-497,-497,-497,221,223,,,-497,-497,,,,,,229,230',
-',36,,,30,,,52,53,,,54,,32,212,,218,40,214,213,210,211,222,220,216,18',
-'217,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58',
-'59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91',
-'82,50,84,83,86,85,93,94,,80,81,,38,39,37,215,-497,-497,-497,-497,221',
-'223,,,-497,-497,,,,,,229,230,,36,,,30,,,52,53,,,54,,32,212,,218,40,214',
-'213,210,211,222,220,216,18,217,,,,79,72,74,75,76,77,,,,73,78,5,62,63',
-'64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90',
-',,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,215',
-',,,,,,,,,,,,,,,229,230,,36,,,30,,,52,53,,,54,,32,212,,,40,214,213,210',
-'211,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,',
-',60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8',
-'9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,215,,,,,,,,,,,,,,,',
-'229,230,,36,,,265,,,52,53,,,54,,32,212,,218,40,214,213,210,211,,,,18',
-',,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59',
-'61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82',
-'50,84,83,86,85,93,94,,80,81,,38,39,37,215,,,,,,,,,,,,,,,,229,230,,36',
-',,265,,,52,53,,,54,,32,212,,218,40,214,213,210,211,,,,18,,,,,79,72,74',
-'75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65',
-'66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86',
-'85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,,,54,,32',
-',,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56',
-'57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6',
-'41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,',
-',,,,,36,,,30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77',
-',,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22',
-'28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,',
-'80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,,,54,,32,,,,40,,',
-',,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60',
-',58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,',
-'30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5',
-'62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87',
-'89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79',
-'72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23',
-'24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84',
-'83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,',
-',54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7',
-'51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17',
-',,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,',
-',,,,,,,,,,,,36,,,30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75',
-'76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66',
-',,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85',
-'93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,,,54,,32,',
-',,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56',
-'57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6',
-'41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,',
-',,,,,36,,,30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77',
-',,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22',
-'28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,',
-'80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,,,54,,32,,,,40,,',
-',,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60',
-',58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,',
-'30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5',
-'62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87',
-'89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79',
-'72,74,75,76,77,,,,73,78,5,62,63,64,7,51,,,,56,57,,,,60,,58,59,61,23',
-'24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92,91,82,50,84',
-'83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,,30,,,52,53,',
-',54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,5,62,63,64,7',
-'51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17',
-',,,,,6,41,8,9,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,',
-',,,,,,,,,,,,36,,,30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,',
-',,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,7,51,,,,56,57,,,',
-'60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9',
-'92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36',
-',,30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78',
-'153,164,154,177,150,170,160,159,180,181,175,158,157,152,178,182,183',
-'162,151,165,169,171,163,156,,,172,179,174,173,166,176,161,149,168,167',
-',,,,,148,155,146,147,144,145,109,111,108,,110,,,,,,,,139,140,,137,121',
-'122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120',
-'138,136,135,131,132,127,125,118,,119,,,143,79,,,,,,,,,,78,153,164,154',
-'177,150,170,160,159,180,181,175,158,157,152,178,182,183,162,151,165',
-'169,171,163,156,,,172,179,174,173,166,176,161,149,168,167,,,,,,148,155',
-'146,147,144,145,109,111,,,110,,,,,,,,139,140,,137,121,122,123,,126,128',
-',,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131',
-'132,127,125,118,,119,,,143,79,,,62,63,64,,51,,,78,56,57,,,,60,,58,59',
-'61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50',
-'84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52',
-'53,,,54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51',
-',,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,,,,',
-',,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,',
-',,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77',
-',,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245',
-'28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81',
-',38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,241,,243,,40,,',
-',,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,28,27,88,87,89,90,,,,,,,,,,41,,,92,91',
-'82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204',
-',,52,53,,,54,,241,,243,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,28,27,88',
-'87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,241,,243,,40,,,,,,,,207,',
-',,,79,72,74,75,76,77,,,,73,78,-249,-249,-249,,-249,,,,-249,-249,,,,-249',
-',-249,-249,-249,-249,-249,-249,-249,,,,,-249,-249,-249,-249,-249,-249',
-'-249,,,,,,,,,,-249,,,-249,-249,-249,-249,-249,-249,-249,-249,-249,-249',
-',-249,-249,,-249,-249,-249,,,,,,,,,,,,,,,,,,,,-249,,,-249,254,,-249',
-'-249,,,-249,,-249,,-249,,-249,,,,,,,,-249,,,,,-249,-249,-249,-249,-249',
-'-249,,,,-249,-249,-249,-249,-249,,-249,,,,-249,-249,,,,-249,,-249,-249',
-'-249,-249,-249,-249,-249,,,,,-249,-249,-249,-249,-249,-249,-249,,,,',
-',,,,,-249,,,-249,-249,-249,-249,-249,-249,-249,-249,-249,-249,,-249',
-'-249,,-249,-249,-249,,,,,,,,,,,,,,,,,,,,-249,,,-249,263,,-249,-249,',
-',-249,,-249,,-249,,-249,,,,,,,,-249,,,,,-249,-249,-249,-249,-249,-249',
-',,,-249,-249,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,',
-',245,275,279,88,87,89,90,,,,,,,,,,276,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,,,280,,215,219,224,225,226,221,223,231,232,227,228,,208,209',
-',,229,230,273,,,270,,,52,53,,,54,,269,,212,,218,,214,213,210,211,222',
-'220,216,,217,,,79,72,74,75,76,77,,,,73,78,62,63,64,233,51,568,,,56,57',
-',,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276',
-',,92,91,82,50,84,83,86,85,93,94,,80,81,,,,280,,215,219,224,225,226,221',
-'223,231,232,227,228,,208,209,,,229,230,273,,,204,,,52,53,,,54,,,,212',
-',218,,214,213,210,211,222,220,216,,217,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,233,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,',
-',56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,',
-',,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,',
-',,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22',
-'28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80',
-'81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,',
-',,18,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58',
-'59,61,246,247,65,66,,,,,245,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82',
-'50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,',
-',52,53,,,54,,299,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62',
-'63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88',
-'87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79',
-'72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24',
-'65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86',
-'85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54',
-',,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56',
-'57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41',
-',,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,',
-'200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73',
-'78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,276,,,92,91,82,50,84,83,86,85,93,94,,80,81,,,,280',
-',215,219,224,225,226,221,223,231,232,227,228,,208,209,,,229,230,315',
-',,30,,,52,53,,,54,,32,,212,,218,,214,213,210,211,222,220,216,,217,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,233,51,,,,56,57,,,,60,,58,59,61',
-'246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92,91,320,50',
-'84,83,321,85,93,94,,80,81,,,,280,,215,219,224,225,226,221,223,231,232',
-'227,228,,208,209,,327,229,230,322,,,204,,,52,53,,,54,,,,212,,218,,214',
-'213,210,211,222,220,216,,217,,,79,72,74,75,76,77,,,,73,78,62,63,64,233',
-'51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90',
-',,,,,,,,,276,,,92,91,320,50,84,83,321,85,93,94,,80,81,,,,280,,215,219',
-'224,225,226,221,223,231,232,227,228,,208,209,,,229,230,322,,,204,,,52',
-'53,,,54,,,,212,,218,,214,213,210,211,222,220,216,,217,,,79,72,74,75',
-'76,77,,,,73,78,-473,-473,-473,233,-473,,,,-473,-473,,,,-473,,-473,-473',
-'-473,-473,-473,-473,-473,,-473,,,-473,-473,-473,-473,-473,-473,-473',
-',,,,,,,,,-473,,,-473,-473,-473,-473,-473,-473,-473,-473,-473,-473,,-473',
-'-473,,-473,-473,-473,,,,,,,,,,,,,,,,,,,,-473,,,-473,-473,,-473,-473',
-',,-473,,-473,,-473,,-473,,,,,,,,-473,,-473,,,-473,-473,-473,-473,-473',
-'-473,,,,-473,-473,-474,-474,-474,,-474,,,,-474,-474,,,,-474,,-474,-474',
-'-474,-474,-474,-474,-474,,-474,,,-474,-474,-474,-474,-474,-474,-474',
-',,,,,,,,,-474,,,-474,-474,-474,-474,-474,-474,-474,-474,-474,-474,,-474',
-'-474,,-474,-474,-474,,,,,,,,,,,,,,,,,,,,-474,,,-474,-474,,-474,-474',
-',,-474,,-474,,-474,,-474,,,,,,,,-474,,-474,,,-474,-474,-474,-474,-474',
-'-474,,,,-474,-474,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66',
-',,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91',
-'82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204',
-',,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62,63',
-'64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90',
-',,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,',
-',,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79,72,74',
-'75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66',
-',,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,7,51,,,,56,57,,,,60',
-',58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,6,41,8,9,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,36,,',
-'30,,,52,53,,,54,,32,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62',
-'63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89',
-'90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,',
-',,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,369,,,,40,,,,,,,,207,,,,,79,72',
-'74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65',
-'66,,,,,22,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,369,',
-',,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57',
-',,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,28,27,88',
-'87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,299,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23',
-'24,65,66,,,,,22,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86',
-'85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54',
-',,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56',
-'57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41',
-',,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,',
-'200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73',
-'78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88',
-'87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79',
-'72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247',
-'65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86',
-'85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54',
-',,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56',
-'57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,',
-',,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,',
-',,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77',
-',,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245',
-'275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80',
-'81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,',
-',,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58',
-'59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91',
-'82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204',
-',,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63',
-'64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87',
-'89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,',
-',,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72',
-'74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65',
-'66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85',
-'93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,',
-',,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57',
-',,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41',
-',,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,',
-'200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73',
-'78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,',
-',56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,',
-',,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,',
-',,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,',
-'245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,',
-',,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,',
-',56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,',
-',,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,',
-',,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,',
-'245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,',
-',,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,',
-',56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,',
-',,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,',
-',,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,',
-'245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,',
-',,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,',
-',56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,',
-',,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,',
-',,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,',
-'245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,',
-',,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,',
-',56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,28,27,88,87,89,90,,,,,',
-',,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,',
-',,,,,,,200,,,204,,,52,53,,,54,,241,,243,,40,,,,,,,,207,,,,,79,72,74',
-'75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66',
-',,,,245,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,445,53,,,54,,241,,243',
-',40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57',
-',,,60,,58,59,61,246,247,65,66,,,,,245,28,27,88,87,89,90,,,,,,,,,,41',
-',,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,',
-'200,,,204,,449,52,53,,,54,,241,,243,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,',
-'245,275,279,88,87,89,90,,,,,,,,,,276,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,,,280,,215,219,224,225,226,221,223,231,232,227,228,,208,209',
-',,229,230,273,,,204,,,52,53,,,54,,,,212,,218,,214,213,210,211,222,220',
-'216,,217,,,79,72,74,75,76,77,,,,73,78,62,63,64,233,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,469,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73',
-'78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23',
-'24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,',
-'56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,',
-',,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,',
-',,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77',
-',,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28',
-'27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81',
-',38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18',
-',,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61',
-'23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84',
-'83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53',
-',,54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,153,164,154,177',
-'150,170,160,159,180,181,175,158,157,152,178,182,183,162,151,165,169',
-'171,163,156,,,172,179,174,173,166,176,161,149,168,167,,,,,,148,155,146',
-'147,144,145,109,111,,,110,,,,,,,,139,140,,137,121,122,123,,126,128,',
-',124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131,132',
-'127,125,118,,119,,,143,79,,,-249,-249,-249,,-249,,,78,-249,-249,,,,-249',
-',-249,-249,-249,-249,-249,-249,-249,,,,,-249,-249,-249,-249,-249,-249',
-'-249,,,,,,,,,,-249,,,-249,-249,-249,-249,-249,-249,-249,-249,-249,-249',
-',-249,-249,,-249,-249,-249,,,,,,,,,,,,,,,,,,,,-249,,,-249,254,,-249',
-'-249,,,-249,,-249,,-249,,-249,,,,,,,,-249,,,,,-249,-249,-249,-249,-249',
-'-249,,,,-249,-249,-478,-478,-478,,-478,,,,-478,-478,,,,-478,,-478,-478',
-'-478,-478,-478,-478,-478,,,,,-478,-478,-478,-478,-478,-478,-478,,,,',
-',,,,,-478,,,-478,-478,-478,-478,-478,-478,-478,-478,-478,-478,,-478',
-'-478,,-478,-478,-478,,,,,,,,,,,,,,,,,,,,-478,,,-478,-478,,-478,-478',
-',,-478,,-478,,-478,,-478,,,,,,,,-478,,,,,-478,-478,-478,-478,-478,-478',
-',,,-478,-478,-479,-479,-479,,-479,,,,-479,-479,,,,-479,,-479,-479,-479',
-'-479,-479,-479,-479,,,,,-479,-479,-479,-479,-479,-479,-479,,,,,,,,,',
-'-479,,,-479,-479,-479,-479,-479,-479,-479,-479,-479,-479,,-479,-479',
-',-479,-479,-479,,,,,,,,,,,,,,,,,,,,-479,,,-479,-479,,-479,-479,,,-479',
-',-479,,-479,,-479,,,,,,,,-479,,,,,-479,-479,-479,-479,-479,-479,,,,-479',
-'-479,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,28',
-'27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38',
-'39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,299,,,,40,,,,,,,,207',
-',,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61',
-'246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50',
-'84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52',
-'53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,',
-'51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90',
-',,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,',
-',,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,',
-',,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,560,,243,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,',
-'73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275',
-'279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,',
-'38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,564,,243,,40,,,',
-',,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,',
-'58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87',
-'89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,584,,243,,40,,,,,,,,18,,',
-',,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,299,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51',
-',,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,',
-',,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,',
-',,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,',
-',,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87',
-'89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79,72',
-'74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65',
-'66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85',
-'93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,369',
-',,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57',
-',,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41',
-',,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,',
-'200,,,204,,,52,53,,,54,,612,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,',
-',,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245',
-'275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80',
-'81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,',
-',,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58',
-'59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91',
-'82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204',
-',,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63',
-'64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87',
-'89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,',
-',,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,628,,,,40,,,,,,,,207,,,,,79',
-'72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247',
-'65,66,,,,,245,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85',
-'93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,299',
-',,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57',
-',,,60,,58,59,61,246,247,65,66,,,,,245,28,27,88,87,89,90,,,,,,,,,,41',
-',,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,',
-'200,,,204,,,52,53,,,54,,299,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,',
-',,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28',
-'27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81',
-',38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18',
-',,,,79,72,74,75,76,77,,,,73,78,153,164,154,177,150,170,160,159,180,181',
-'175,158,157,152,178,182,183,162,151,165,169,171,163,156,,,172,179,174',
-'173,166,176,161,149,168,167,,,,,,148,155,146,147,144,145,109,111,,,110',
-',,,,,,,139,140,,137,121,122,123,,126,128,,,124,,,,,141,142,129,130,',
-',,,,,,,,,,,,134,133,,120,138,136,135,131,132,127,125,118,,119,,,143',
-'79,,,62,63,64,,51,,,78,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275',
-'279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,',
-'38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207',
-',,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61',
-'246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50',
-'84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52',
-'53,,,54,,679,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64',
-',51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,',
-',,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,',
-',,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,',
-',22,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80',
-'81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,',
-',,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58',
-'59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50',
-'84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52',
-'53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,',
-'51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90',
-',,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,',
-',,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,',
-',,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,,,280,,,,,,,,,,,,,,,,,,,,273,,,270',
-',,52,53,,,54,,697,,698,,,,,,,,,699,,,,,,79,72,74,75,76,77,,,,73,78,62',
-'63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88',
-'87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79',
-'72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247',
-'65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86',
-'85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54',
-',,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56',
-'57,,,,60,,58,59,61,246,247,65,66,,,,,245,28,27,88,87,89,90,,,,,,,,,',
-'41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,',
-',,,200,,,204,,,52,53,,,54,,560,,243,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,',
-'245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94',
-',80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,',
-',,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23',
-'24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,,,,,41,,,92,91,82,50,84,83',
-'86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,',
-'54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,',
-'56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,',
-',,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,',
-',,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76',
-'77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,23,24,65,66,,,,,22',
-'28,27,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81',
-',38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207',
-',,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61',
-'246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50',
-'84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52',
-'53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,',
-'51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90',
-',,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,',
-',,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,',
-',,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,,,280,,215,219,224,225,226,221,223',
-'231,232,227,228,,208,209,,,229,230,772,,,204,,,52,53,,,54,,,,212,,218',
-',214,213,210,211,222,220,216,,217,,,79,72,74,75,76,77,,,,73,78,62,63',
-'64,233,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88',
-'87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,780,,243,,40,,,,,,,,207,',
-',,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61',
-'246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50',
-'84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52',
-'53,,,54,,786,,243,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63',
-'64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87',
-'89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,',
-',,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,788,,243,,40,,,,,,,,207,,',
-',,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92,91,82,50,84',
-'83,86,85,93,94,,80,81,,,,280,,215,219,224,225,226,221,223,231,232,227',
-'228,,208,209,,,229,230,772,,,204,,,52,53,,,54,,,,212,,218,,214,213,210',
-'211,222,220,216,,217,,,79,72,74,75,76,77,,,,73,78,62,63,64,233,51,,',
-',56,57,,,,60,,58,59,61,23,24,65,66,,,,,22,28,27,88,87,89,90,,,17,,,',
-',,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,',
-',,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,18,,,,,79,72,74,75,76,77',
-',,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245',
-'275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80',
-'81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,802,,,,40,,',
-',,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92,91,82,50,84',
-'83,86,85,93,94,,80,81,,,,280,,,,,,,,,,,,,,,,,,,,273,,,270,,,52,53,,',
-'54,,821,,820,,,,,,,,,,,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,',
-',,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,',
-',,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,',
-',,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,',
-',,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40',
-',,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78',
-'62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279',
-'88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39',
-'37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,',
-'79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246',
-'247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92,91,82,50,84',
-'83,86,85,93,94,,80,81,,,,280,,215,219,224,225,226,221,223,231,232,227',
-'228,,208,209,,,229,230,772,,,204,,,52,53,,,54,,,,212,,218,,214,213,210',
-'211,222,220,216,,217,,,79,72,74,75,76,77,,,,73,78,62,63,64,233,51,,',
-',56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,28,27,88,87,89,90,,,,,',
-',,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,',
-',,,,,,,200,,,204,,,52,53,,,54,,299,,,,40,,,,,,,,207,,,,,79,72,74,75',
-'76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,',
-',,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92,91,82,50,84,83,86,85,93',
-'94,,80,81,,,,280,,215,219,224,225,226,221,223,231,232,227,228,,208,209',
-',,229,230,772,,,204,,,52,53,,,54,,,,212,,218,,214,213,210,211,222,220',
-'216,,217,,,79,72,74,75,76,77,,,,73,78,62,63,64,233,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,',
-',204,,,52,53,,,54,,864,,243,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,',
-'73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275',
-'279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,',
-'38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,867,,243,,40,,,',
-',,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,',
-'58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,,,280,,215,219,224,225,226,221,223',
-'231,232,227,228,,208,209,,,229,230,772,,,204,,,52,53,,,54,,,,212,,218',
-',214,213,210,211,222,220,216,,217,,,79,72,74,75,76,77,,,,73,78,62,63',
-'64,233,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88',
-'87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79',
-'72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60,,58,59,61,246,247',
-'65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86',
-'85,93,94,,80,81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54',
-',,,,,40,,,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56',
-'57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,',
-',,276,,,92,91,82,50,84,83,86,85,93,94,,80,81,,,,280,,215,219,224,225',
-'226,221,223,231,232,227,228,,208,209,,,229,230,772,,,204,,,52,53,,,54',
-',,,212,,218,,214,213,210,211,222,220,216,,217,,,79,72,74,75,76,77,,',
-',73,78,62,63,64,233,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245',
-'275,279,88,87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80',
-'81,,38,39,37,,,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,889,,243,,40',
-',,,,,,,207,,,,,79,72,74,75,76,77,,,,73,78,62,63,64,,51,,,,56,57,,,,60',
-',58,59,61,246,247,65,66,,,,,245,275,279,88,87,89,90,,,,,,,,,,276,,,92',
-'91,82,50,84,83,86,85,93,94,,80,81,,,,280,,215,219,224,225,226,221,223',
-'231,232,227,228,,208,209,,,229,230,772,,,204,,,52,53,,,54,,,,212,,218',
-',214,213,210,211,222,220,216,,217,,,79,72,74,75,76,77,,,,73,78,62,63',
-'64,233,51,,,,56,57,,,,60,,58,59,61,246,247,65,66,,,,,245,275,279,88',
-'87,89,90,,,,,,,,,,41,,,92,91,82,50,84,83,86,85,93,94,,80,81,,38,39,37',
-',,,,,,,,,,,,,,,,,,,200,,,204,,,52,53,,,54,,,,,,40,,,,,,,,207,,,,,79',
-'72,74,75,76,77,,,,73,78,153,164,154,177,150,170,160,159,180,181,175',
-'158,157,152,178,182,183,162,151,165,169,171,163,156,,,172,179,174,336',
-'335,337,334,149,168,167,,,,,,148,155,146,147,332,333,330,111,84,83,331',
-'85,,,,,,,139,140,,137,121,122,123,,126,128,,,124,,,,,141,142,129,130',
-',,,,,341,,,,,,,,134,133,,120,138,136,135,131,132,127,125,118,,119,,',
-'143,153,164,154,177,150,170,160,159,180,181,175,158,157,152,178,182',
-'183,162,151,165,169,171,163,156,,,172,179,174,173,166,176,161,149,168',
-'167,,,,,,148,155,146,147,144,145,109,111,,,110,,,,,,,,139,140,,137,121',
-'122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120',
-'138,136,135,131,132,127,125,118,,119,,,143,215,219,224,225,226,221,223',
-'231,232,227,228,,208,209,,,229,230,,,,-215,,,,,,,,,,,212,,218,,214,213',
-'210,211,222,220,216,,217,,,,,,,,635,385,,,636,,,,,233,,-215,139,140',
-',137,121,122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134',
-'133,,120,138,136,135,131,132,127,125,118,,119,433,379,143,,434,,,,,',
-',,139,140,,137,121,122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,',
-',,,,,,,134,133,,120,138,136,135,131,132,127,125,118,,119,632,385,143',
-',633,,,,,,,,139,140,,137,121,122,123,,126,128,,,124,,,,,141,142,129',
-'130,,,,,,,,,,,,,,134,133,,120,138,136,135,131,132,127,125,118,,119,630',
-'379,143,,631,,,,,,,,139,140,,137,121,122,123,,126,128,,,124,,,,,141',
-'142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131,132,127,125,118',
-',119,550,379,143,,551,,,,,,,,139,140,,137,121,122,123,,126,128,,,124',
-',,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131,132,127',
-'125,118,,119,433,379,143,,434,,,,,,,,139,140,,137,121,122,123,,126,128',
-',,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131',
-'132,127,125,118,,119,433,379,143,,434,,,,,,,,139,140,,137,121,122,123',
-',126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136',
-'135,131,132,127,125,118,,119,,,143,215,219,224,225,226,221,223,231,232',
-'227,228,,208,209,,,229,230,,,,,,,,,,,,,,,212,,218,,214,213,210,211,222',
-'220,216,,217,,,,,,,552,385,,,553,,,,,,233,556,139,140,,137,121,122,123',
-',126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136',
-'135,131,132,127,125,118,,119,376,379,143,,377,,,,,,,,139,140,,137,121',
-'122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120',
-'138,136,135,131,132,127,125,118,,119,857,379,143,,858,,,,,,,,139,140',
-',137,121,122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134',
-'133,,120,138,136,135,131,132,127,125,118,,119,597,385,143,,598,,,,,',
-',,139,140,,137,121,122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,',
-',,,,,,,134,133,,120,138,136,135,131,132,127,125,118,,119,859,385,143',
-',860,,,,,,,,139,140,,137,121,122,123,,126,128,,,124,,,,,141,142,129',
-'130,,,,,,,,,,,,,,134,133,,120,138,136,135,131,132,127,125,118,,119,594',
-'379,143,,595,,,,,,,,139,140,,137,121,122,123,,126,128,,,124,,,,,141',
-'142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131,132,127,125,118',
-',119,550,379,143,,551,,,,,,,,139,140,,137,121,122,123,,126,128,,,124',
-',,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131,132,127',
-'125,118,,119,552,385,143,,553,,,,,,,,139,140,,137,121,122,123,,126,128',
-',,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136,135,131',
-'132,127,125,118,,119,433,379,143,,434,,,,,,,,139,140,,137,121,122,123',
-',126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120,138,136',
-'135,131,132,127,125,118,,119,381,385,143,,383,,,,,,,,139,140,,137,121',
-'122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134,133,,120',
-'138,136,135,131,132,127,125,118,,119,433,379,143,,434,,,,,,,,139,140',
-',137,121,122,123,,126,128,,,124,,,,,141,142,129,130,,,,,,,,,,,,,,134',
-'133,,120,138,136,135,131,132,127,125,118,,119,,,143,215,219,224,225',
-'226,221,223,231,232,227,228,,208,209,,,229,230,,,,,,,,,,,,,,,212,,218',
-',214,213,210,211,222,220,216,,217,,215,219,224,225,226,221,223,231,232',
-'227,228,,208,209,291,233,229,230,,,,,,,,,,,,,,,212,,218,,214,213,210',
-'211,222,220,216,,217,,215,219,224,225,226,221,223,231,232,227,228,,208',
-'209,291,233,229,230,,,,,,,,,,,,,,,212,,218,,214,213,210,211,222,220',
-'216,,217,,,,,,,,,,,,,,,,,233' ]
- racc_action_table = arr = ::Array.new(24362, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'383,512,512,518,518,798,631,383,383,383,326,848,440,383,383,743,383',
-'199,446,440,347,424,306,727,334,630,70,55,316,881,711,334,603,603,70',
-'383,383,711,383,383,383,383,383,307,627,297,333,313,297,632,500,201',
-'446,333,591,424,362,848,848,848,848,440,594,199,383,383,383,383,383',
-'383,383,383,383,383,383,383,383,383,363,711,383,383,383,347,383,603',
-'303,595,383,303,512,383,518,591,744,512,383,201,383,633,383,383,383',
-'383,383,383,383,381,383,631,383,55,632,326,381,381,381,798,743,798,381',
-'381,798,381,383,383,594,383,630,383,383,316,381,326,306,727,306,727',
-'326,306,727,491,381,381,594,381,381,381,381,381,313,595,632,500,693',
-'307,627,307,627,492,307,627,633,332,582,594,368,447,594,595,332,381',
-'381,381,381,381,381,381,381,381,381,381,381,381,381,857,277,381,381',
-'381,595,381,744,595,744,381,26,744,381,394,693,447,633,381,528,381,582',
-'381,381,381,381,381,381,381,432,381,381,381,377,615,615,432,432,432',
-'321,14,432,432,432,371,432,381,381,540,381,857,381,381,551,491,432,491',
-'857,574,491,394,755,857,277,432,432,857,432,432,432,432,432,492,26,492',
-'348,377,492,376,377,528,528,35,14,857,277,14,375,283,321,528,540,574',
-'382,540,26,321,550,346,551,320,321,345,184,432,321,50,755,755,755,755',
-'432,772,50,50,50,432,432,50,50,50,376,50,321,376,35,301,402,35,301,3',
-'283,50,50,283,3,348,348,348,432,403,50,50,550,50,50,50,50,50,331,320',
-'298,404,432,298,432,331,320,432,346,346,346,320,345,345,345,320,311',
-'405,311,50,50,50,50,50,50,50,50,50,50,50,50,50,50,320,773,50,50,50,503',
-'774,50,773,775,50,344,503,50,50,343,50,773,50,429,50,503,50,50,50,50',
-'50,50,50,435,50,859,50,330,597,322,435,435,435,322,330,435,435,435,858',
-'435,50,50,50,50,401,50,878,400,335,435,25,635,803,721,803,335,438,25',
-'435,435,721,435,435,435,435,435,344,344,344,721,343,343,343,15,15,859',
-'401,439,597,400,401,401,859,400,400,597,13,859,858,420,597,859,310,13',
-'597,858,339,310,435,42,858,635,13,339,858,435,42,636,635,859,435,435',
-'597,635,636,42,441,635,442,636,782,420,858,636,271,420,420,420,420,37',
-'37,271,448,435,645,635,645,645,645,645,271,337,553,553,553,450,553,435',
-'337,435,553,553,435,870,870,553,451,553,553,553,553,553,553,553,280',
-'280,758,758,553,553,553,553,553,553,553,294,294,455,336,419,645,645',
-'645,645,553,336,783,553,553,553,553,553,553,553,553,553,553,460,553',
-'553,784,553,553,553,415,415,415,415,415,415,415,419,272,415,415,419',
-'419,419,419,272,415,415,865,553,553,787,553,553,272,553,553,305,305',
-'553,892,553,415,553,415,553,415,415,415,415,415,415,415,553,415,470',
-'9,473,553,553,553,553,553,553,800,274,801,553,553,552,552,552,274,552',
-'95,108,553,552,552,108,108,274,552,487,552,552,552,552,552,552,552,493',
-'494,806,808,552,552,552,552,552,552,552,646,640,511,526,531,646,640',
-'511,809,552,810,813,552,552,552,552,552,552,552,552,552,552,814,552',
-'552,543,552,552,552,421,421,421,421,421,421,421,871,876,421,421,286',
-'547,8,825,876,421,421,286,552,552,825,552,552,876,552,552,286,41,552',
-'825,552,421,552,421,552,421,421,421,421,421,421,421,552,421,554,872',
-'561,552,552,552,552,552,552,563,314,566,552,552,60,60,60,314,60,568',
-'576,552,60,60,577,826,314,60,583,60,60,60,60,60,60,60,873,586,36,593',
-'60,60,60,60,60,60,60,522,522,60,522,522,522,596,366,599,60,601,602,60',
-'60,60,60,60,60,60,60,60,60,604,60,60,34,60,60,60,366,366,366,366,366',
-'366,366,366,366,366,366,860,366,366,770,607,366,366,860,60,608,770,60',
-'860,611,60,60,860,617,60,770,623,366,625,366,60,366,366,366,366,366',
-'366,366,60,366,626,874,629,60,60,60,60,60,60,833,324,638,60,60,643,60',
-'366,324,366,647,60,97,97,97,97,97,324,648,198,97,97,649,655,660,97,198',
-'97,97,97,97,97,97,97,663,198,665,20,97,97,97,97,97,97,97,678,764,97',
-'4,4,4,4,4,97,97,97,97,97,97,97,97,97,97,97,97,97,97,836,97,97,837,97',
-'97,97,422,422,422,422,422,422,422,422,771,422,422,598,696,202,459,771',
-'422,422,598,97,203,459,97,598,771,97,97,598,700,97,459,97,422,701,422',
-'97,422,422,422,422,422,422,422,97,422,702,1,705,97,97,97,97,97,97,709',
-'710,712,97,97,821,821,821,854,821,855,97,716,821,821,718,719,720,821',
-'856,821,821,821,821,821,821,821,732,735,12,239,821,821,821,821,821,821',
-'821,350,350,350,350,350,240,11,244,253,821,746,264,821,821,821,821,821',
-'821,821,821,821,821,200,821,821,413,266,817,821,817,817,817,817,106',
-'106,106,106,106,267,268,10,413,413,273,275,276,279,284,821,285,288,821',
-'750,292,821,821,293,413,821,413,296,413,413,413,413,817,751,413,300',
-'413,302,312,315,817,817,817,817,821,821,821,821,821,821,317,,,821,821',
-',697,697,697,821,697,,,,697,697,,,,697,,697,697,697,697,697,697,697',
-',,,,697,697,697,697,697,697,697,,,,,,,,555,,697,,,697,697,697,697,697',
-'697,697,697,697,697,,697,697,,,,697,555,555,555,555,555,555,555,555',
-'555,555,555,,555,555,,,555,555,,697,,,697,,,697,697,,,697,,,555,,555',
-',555,555,555,555,555,555,555,,555,,,,697,697,697,697,697,697,,,,697',
-'697,,,555,,697,30,30,30,30,30,30,,,,30,30,,,,30,,30,30,30,30,30,30,30',
-',,,,30,30,30,30,30,30,30,,,30,,,,,,30,30,30,30,30,30,30,30,30,30,30',
-'30,30,30,,30,30,,30,30,30,,,,,,,,,,,,,,,,,,,,30,,,30,,,30,30,,,30,,30',
-',,,30,514,,514,514,514,514,,30,,,,,30,30,30,30,30,30,,,,30,30,737,737',
-'737,737,737,737,,,,737,737,,,,737,514,737,737,737,737,737,737,737,514',
-'514,514,514,737,737,737,737,737,737,737,,,737,,,,,,737,737,737,737,737',
-'737,737,737,737,737,737,737,737,737,,737,737,,737,737,737,,,,,,,,,,',
-',,,,,,,,,737,,,737,,,737,737,,,737,,737,,,,737,753,,753,753,753,753',
-',737,,,,,737,737,737,737,737,737,,,,737,737,736,736,736,736,736,736',
-',,,736,736,,,,736,,736,736,736,736,736,736,736,753,753,753,753,736,736',
-'736,736,736,736,736,,,736,,,,,,736,736,736,736,736,736,736,736,736,736',
-'736,736,736,736,,736,736,,736,736,736,412,,,,,,,,,,,,,,,,412,412,,736',
-',,736,,,736,736,,,736,,736,412,,412,736,412,412,412,412,,,412,736,412',
-',,,736,736,736,736,736,736,,,,736,736,606,606,606,606,606,606,,,,606',
-'606,,,,606,,606,606,606,606,606,606,606,,,,,606,606,606,606,606,606',
-'606,,,606,,,,,,606,606,606,606,606,606,606,606,606,606,606,606,606,606',
-',606,606,,606,606,606,409,409,409,409,409,409,409,,,409,409,,,,,,409',
-'409,,606,,,606,,,606,606,,,606,,606,409,,409,606,409,409,409,409,409',
-'409,409,606,409,,,,606,606,606,606,606,606,,,,606,606,589,589,589,589',
-'589,589,,,,589,589,,,,589,,589,589,589,589,589,589,589,,,,,589,589,589',
-'589,589,589,589,,,589,,,,,,589,589,589,589,589,589,589,589,589,589,589',
-'589,589,589,,589,589,,589,589,589,410,,,,,,,,,,,,,,,,410,410,,589,,',
-'589,,,589,589,,,589,,589,410,,410,589,410,410,410,410,,,410,589,410',
-',,,589,589,589,589,589,589,,,,589,589,186,186,186,186,186,186,,,,186',
-'186,,,,186,,186,186,186,186,186,186,186,,,,,186,186,186,186,186,186',
-'186,,,186,,,,,,186,186,186,186,186,186,186,186,186,186,186,186,186,186',
-',186,186,,186,186,186,399,399,399,399,399,399,399,399,399,399,399,,399',
-'399,,,399,399,,186,,,186,,,186,186,,,186,,186,399,,399,186,399,399,399',
-'399,399,399,399,186,399,,,,186,186,186,186,186,186,,,,186,186,187,187',
-'187,187,187,187,,,,187,187,,,,187,,187,187,187,187,187,187,187,,,,,187',
-'187,187,187,187,187,187,,,187,,,,,,187,187,187,187,187,187,187,187,187',
-'187,187,187,187,187,,187,187,,187,187,187,398,398,398,398,398,398,398',
-'398,398,398,398,,398,398,,,398,398,,187,,,187,,,187,187,,,187,,187,398',
-',398,187,398,398,398,398,398,398,398,187,398,,,,187,187,187,187,187',
-'187,,,,187,187,588,588,588,588,588,588,,,,588,588,,,,588,,588,588,588',
-'588,588,588,588,,,,,588,588,588,588,588,588,588,,,588,,,,,,588,588,588',
-'588,588,588,588,588,588,588,588,588,588,588,,588,588,,588,588,588,414',
-'414,414,414,414,414,414,,,414,414,,,,,,414,414,,588,,,588,,,588,588',
-',,588,,588,414,,414,588,414,414,414,414,414,414,414,588,414,,,,588,588',
-'588,588,588,588,,,,588,588,559,559,559,559,559,559,,,,559,559,,,,559',
-',559,559,559,559,559,559,559,,,,,559,559,559,559,559,559,559,,,559,',
-',,,,559,559,559,559,559,559,559,559,559,559,559,559,559,559,,559,559',
-',559,559,559,418,418,418,418,418,418,418,,,418,418,,,,,,418,418,,559',
-',,559,,,559,559,,,559,,559,418,,418,559,418,418,418,418,418,418,418',
-'559,418,,,,559,559,559,559,559,559,,,,559,559,724,724,724,724,724,724',
-',,,724,724,,,,724,,724,724,724,724,724,724,724,,,,,724,724,724,724,724',
-'724,724,,,724,,,,,,724,724,724,724,724,724,724,724,724,724,724,724,724',
-'724,,724,724,,724,724,724,411,,,,,,,,,,,,,,,,411,411,,724,,,724,,,724',
-'724,,,724,,724,411,,411,724,411,411,411,411,,,411,724,411,,,,724,724',
-'724,724,724,724,,,,724,724,706,706,706,706,706,706,,,,706,706,,,,706',
-',706,706,706,706,706,706,706,,,,,706,706,706,706,706,706,706,,,706,',
-',,,,706,706,706,706,706,706,706,706,706,706,706,706,706,706,,706,706',
-',706,706,706,416,416,416,416,416,416,416,,,416,416,,,,,,416,416,,706',
-',,706,,,706,706,,,706,,706,416,,416,706,416,416,416,416,416,416,416',
-'706,416,,,,706,706,706,706,706,706,,,,706,706,0,0,0,0,0,0,,,,0,0,,,',
-'0,,0,0,0,0,0,0,0,,,,,0,0,0,0,0,0,0,,,0,,,,,,0,0,0,0,0,0,0,0,0,0,0,0',
-'0,0,,0,0,,0,0,0,417,417,417,417,417,417,417,,,417,417,,,,,,417,417,',
-'0,,,0,,,0,0,,,0,,0,417,,417,0,417,417,417,417,417,417,417,0,417,,,,0',
-'0,0,0,0,0,,,,0,0,852,852,852,852,852,852,,,,852,852,,,,852,,852,852',
-'852,852,852,852,852,,,,,852,852,852,852,852,852,852,,,852,,,,,,852,852',
-'852,852,852,852,852,852,852,852,852,852,852,852,,852,852,,852,852,852',
-'408,,,,,,,,,,,,,,,,408,408,,852,,,852,,,852,852,,,852,,852,408,,,852',
-'408,408,408,408,,,,852,,,,,852,852,852,852,852,852,,,,852,852,270,270',
-'270,270,270,270,,,,270,270,,,,270,,270,270,270,270,270,270,270,,,,,270',
-'270,270,270,270,270,270,,,270,,,,,,270,270,270,270,270,270,270,270,270',
-'270,270,270,270,270,,270,270,,270,270,270,407,,,,,,,,,,,,,,,,407,407',
-',270,,,270,,,270,270,,,270,,270,407,,407,270,407,407,407,407,,,,270',
-',,,,270,270,270,270,270,270,,,,270,270,265,265,265,265,265,265,,,,265',
-'265,,,,265,,265,265,265,265,265,265,265,,,,,265,265,265,265,265,265',
-'265,,,265,,,,,,265,265,265,265,265,265,265,265,265,265,265,265,265,265',
-',265,265,,265,265,265,406,,,,,,,,,,,,,,,,406,406,,265,,,265,,,265,265',
-',,265,,265,406,,406,265,406,406,406,406,,,,265,,,,,265,265,265,265,265',
-'265,,,,265,265,204,204,204,204,204,204,,,,204,204,,,,204,,204,204,204',
-'204,204,204,204,,,,,204,204,204,204,204,204,204,,,204,,,,,,204,204,204',
-'204,204,204,204,204,204,204,204,204,204,204,,204,204,,204,204,204,,',
-',,,,,,,,,,,,,,,,,204,,,204,,,204,204,,,204,,204,,,,204,,,,,,,,204,,',
-',,204,204,204,204,204,204,,,,204,204,51,51,51,51,51,51,,,,51,51,,,,51',
-',51,51,51,51,51,51,51,,,,,51,51,51,51,51,51,51,,,51,,,,,,51,51,51,51',
-'51,51,51,51,51,51,51,51,51,51,,51,51,,51,51,51,,,,,,,,,,,,,,,,,,,,51',
-',,51,,,51,51,,,51,,51,,,,51,,,,,,,,51,,,,,51,51,51,51,51,51,,,,51,51',
-'845,845,845,845,845,845,,,,845,845,,,,845,,845,845,845,845,845,845,845',
-',,,,845,845,845,845,845,845,845,,,845,,,,,,845,845,845,845,845,845,845',
-'845,845,845,845,845,845,845,,845,845,,845,845,845,,,,,,,,,,,,,,,,,,',
-',845,,,845,,,845,845,,,845,,845,,,,845,,,,,,,,845,,,,,845,845,845,845',
-'845,845,,,,845,845,671,671,671,671,671,671,,,,671,671,,,,671,,671,671',
-'671,671,671,671,671,,,,,671,671,671,671,671,671,671,,,671,,,,,,671,671',
-'671,671,671,671,671,671,671,671,671,671,671,671,,671,671,,671,671,671',
-',,,,,,,,,,,,,,,,,,,671,,,671,,,671,671,,,671,,671,,,,671,,,,,,,,671',
-',,,,671,671,671,671,671,671,,,,671,671,513,513,513,513,513,513,,,,513',
-'513,,,,513,,513,513,513,513,513,513,513,,,,,513,513,513,513,513,513',
-'513,,,513,,,,,,513,513,513,513,513,513,513,513,513,513,513,513,513,513',
-',513,513,,513,513,513,,,,,,,,,,,,,,,,,,,,513,,,513,,,513,513,,,513,',
-'513,,,,513,,,,,,,,513,,,,,513,513,513,513,513,513,,,,513,513,838,838',
-'838,838,838,838,,,,838,838,,,,838,,838,838,838,838,838,838,838,,,,,838',
-'838,838,838,838,838,838,,,838,,,,,,838,838,838,838,838,838,838,838,838',
-'838,838,838,838,838,,838,838,,838,838,838,,,,,,,,,,,,,,,,,,,,838,,,838',
-',,838,838,,,838,,838,,,,838,,,,,,,,838,,,,,838,838,838,838,838,838,',
-',,838,838,794,794,794,794,794,794,,,,794,794,,,,794,,794,794,794,794',
-'794,794,794,,,,,794,794,794,794,794,794,794,,,794,,,,,,794,794,794,794',
-'794,794,794,794,794,794,794,794,794,794,,794,794,,794,794,794,,,,,,',
-',,,,,,,,,,,,,794,,,794,,,794,794,,,794,,794,,,,794,,,,,,,,794,,,,,794',
-'794,794,794,794,794,,,,794,794,644,644,644,644,644,644,,,,644,644,,',
-',644,,644,644,644,644,644,644,644,,,,,644,644,644,644,644,644,644,,',
-'644,,,,,,644,644,644,644,644,644,644,644,644,644,644,644,644,644,,644',
-'644,,644,644,644,,,,,,,,,,,,,,,,,,,,644,,,644,,,644,644,,,644,,644,',
-',,644,,,,,,,,644,,,,,644,644,644,644,644,644,,,,644,644,639,639,639',
-'639,639,639,,,,639,639,,,,639,,639,639,639,639,639,639,639,,,,,639,639',
-'639,639,639,639,639,,,639,,,,,,639,639,639,639,639,639,639,639,639,639',
-'639,639,639,639,,639,639,,639,639,639,,,,,,,,,,,,,,,,,,,,639,,,639,',
-',639,639,,,639,,639,,,,639,,,,,,,,639,,,,,639,639,639,639,639,639,,',
-',639,639,495,495,495,495,495,495,,,,495,495,,,,495,,495,495,495,495',
-'495,495,495,,,,,495,495,495,495,495,495,495,,,495,,,,,,495,495,495,495',
-'495,495,495,495,495,495,495,495,495,495,,495,495,,495,495,495,,,,,,',
-',,,,,,,,,,,,,495,,,495,,,495,495,,,495,,495,,,,495,,,,,,,,495,,,,,495',
-'495,495,495,495,495,,,,495,495,490,490,490,490,490,490,,,,490,490,,',
-',490,,490,490,490,490,490,490,490,,,,,490,490,490,490,490,490,490,,',
-'490,,,,,,490,490,490,490,490,490,490,490,490,490,490,490,490,490,,490',
-'490,,490,490,490,,,,,,,,,,,,,,,,,,,,490,,,490,,,490,490,,,490,,490,',
-',,490,,,,,,,,490,,,,,490,490,490,490,490,490,,,,490,490,748,748,748',
-'748,748,748,,,,748,748,,,,748,,748,748,748,748,748,748,748,,,,,748,748',
-'748,748,748,748,748,,,748,,,,,,748,748,748,748,748,748,748,748,748,748',
-'748,748,748,748,,748,748,,748,748,748,,,,,,,,,,,,,,,,,,,,748,,,748,',
-',748,748,,,748,,748,,,,748,,,,,,,,748,,,,,748,748,748,748,748,748,,',
-',748,748,741,741,741,741,741,741,,,,741,741,,,,741,,741,741,741,741',
-'741,741,741,,,,,741,741,741,741,741,741,741,,,741,,,,,,741,741,741,741',
-'741,741,741,741,741,741,741,741,741,741,,741,741,,741,741,741,,,,,,',
-',,,,,,,,,,,,,741,,,741,,,741,741,,,741,,741,,,,741,,,,,,,,741,,,,,741',
-'741,741,741,741,741,,,,741,741,486,486,486,486,486,486,,,,486,486,,',
-',486,,486,486,486,486,486,486,486,,,,,486,486,486,486,486,486,486,,',
-'486,,,,,,486,486,486,486,486,486,486,486,486,486,486,486,486,486,,486',
-'486,,486,486,486,,,,,,,,,,,,,,,,,,,,486,,,486,,,486,486,,,486,,486,',
-',,486,,,,,,,,486,,,,,486,486,486,486,486,486,,,,486,486,369,369,369',
-',369,,,,369,369,,,,369,,369,369,369,369,369,369,369,,,,,369,369,369',
-'369,369,369,369,,,,,,,,,,369,,,369,369,369,369,369,369,369,369,369,369',
-',369,369,,369,369,369,,,,,,,,,,,,,,,,,,,,369,,,369,,,369,369,,,369,',
-',,,,369,,,,,,,,369,,,,,369,369,369,369,369,369,,,,369,369,5,5,5,5,5',
-',,,5,5,,,,5,,5,5,5,5,5,5,5,,,,,5,5,5,5,5,5,5,,,5,,,,,,5,5,5,5,5,5,5',
-'5,5,5,5,5,5,5,,5,5,,5,5,5,,,,,,,,,,,,,,,,,,,,5,,,5,,,5,5,,,5,,5,,,,5',
-',,,,,,,5,,,,,5,5,5,5,5,5,,,,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6',
-'6,6,6,6,6,6,,,6,6,6,6,6,6,6,6,6,6,,,,,,6,6,6,6,6,6,6,6,6,,6,,,,,,,,6',
-'6,,6,6,6,6,,6,6,,,6,,,,,6,6,6,6,,,,,,,,,,,,,,6,6,,6,6,6,6,6,6,6,6,6',
-',6,,,6,6,,,,,,,,,,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7',
-',,7,7,7,7,7,7,7,7,7,7,,,,,,7,7,7,7,7,7,7,7,,,7,,,,,,,,7,7,,7,7,7,7,',
-'7,7,,,7,,,,,7,7,7,7,,,,,,,,,,,,,,7,7,,7,7,7,7,7,7,7,7,7,,7,,,7,7,,,17',
-'17,17,,17,,,7,17,17,,,,17,,17,17,17,17,17,17,17,,,,,17,17,17,17,17,17',
-'17,,,17,,,,,,,17,,,17,17,17,17,17,17,17,17,17,17,,17,17,,17,17,17,,',
-',,,,,,,,,,,,,,,,,17,,,17,,,17,17,,,17,,,,,,17,,,,,,,,17,,,,,17,17,17',
-'17,17,17,,,,17,17,18,18,18,,18,,,,18,18,,,,18,,18,18,18,18,18,18,18',
-',,,,18,18,18,18,18,18,18,,,,,,,,,,18,,,18,18,18,18,18,18,18,18,18,18',
-',18,18,,18,18,18,,,,,,,,,,,,,,,,,,,,18,,,18,,,18,18,,,18,,,,,,18,,,',
-',,,,18,,,,,18,18,18,18,18,18,,,,18,18,22,22,22,,22,,,,22,22,,,,22,,22',
-'22,22,22,22,22,22,,,,,22,22,22,22,22,22,22,,,,,,,,,,22,,,22,22,22,22',
-'22,22,22,22,22,22,,22,22,,22,22,22,,,,,,,,,,,,,,,,,,,,22,,,22,,,22,22',
-',,22,,22,,22,,22,,,,,,,,22,,,,,22,22,22,22,22,22,,,,22,22,23,23,23,',
-'23,,,,23,23,,,,23,,23,23,23,23,23,23,23,,,,,23,23,23,23,23,23,23,,,',
-',,,,,,23,,,23,23,23,23,23,23,23,23,23,23,,23,23,,23,23,23,,,,,,,,,,',
-',,,,,,,,,23,,,23,,,23,23,,,23,,23,,23,,23,,,,,,,,23,,,,,23,23,23,23',
-'23,23,,,,23,23,24,24,24,,24,,,,24,24,,,,24,,24,24,24,24,24,24,24,,,',
-',24,24,24,24,24,24,24,,,,,,,,,,24,,,24,24,24,24,24,24,24,24,24,24,,24',
-'24,,24,24,24,,,,,,,,,,,,,,,,,,,,24,,,24,,,24,24,,,24,,24,,24,,24,,,',
-',,,,24,,,,,24,24,24,24,24,24,,,,24,24,27,27,27,,27,,,,27,27,,,,27,,27',
-'27,27,27,27,27,27,,,,,27,27,27,27,27,27,27,,,,,,,,,,27,,,27,27,27,27',
-'27,27,27,27,27,27,,27,27,,27,27,27,,,,,,,,,,,,,,,,,,,,27,,,27,27,,27',
-'27,,,27,,27,,27,,27,,,,,,,,27,,,,,27,27,27,27,27,27,,,,27,27,28,28,28',
-',28,,,,28,28,,,,28,,28,28,28,28,28,28,28,,,,,28,28,28,28,28,28,28,,',
-',,,,,,,28,,,28,28,28,28,28,28,28,28,28,28,,28,28,,28,28,28,,,,,,,,,',
-',,,,,,,,,,28,,,28,28,,28,28,,,28,,28,,28,,28,,,,,,,,28,,,,,28,28,28',
-'28,28,28,,,,28,28,31,31,31,,31,,,,31,31,,,,31,,31,31,31,31,31,31,31',
-',,,,31,31,31,31,31,31,31,,,,,,,,,,31,,,31,31,31,31,31,31,31,31,31,31',
-',31,31,,,,31,,828,828,828,828,828,828,828,828,828,828,828,,828,828,',
-',828,828,31,,,31,,,31,31,,,31,,31,,828,,828,,828,828,828,828,828,828',
-'828,,828,,,31,31,31,31,31,31,,,,31,31,32,32,32,828,32,828,,,32,32,,',
-',32,,32,32,32,32,32,32,32,,,,,32,32,32,32,32,32,32,,,,,,,,,,32,,,32',
-'32,32,32,32,32,32,32,32,32,,32,32,,,,32,,468,468,468,468,468,468,468',
-'468,468,468,468,,468,468,,,468,468,32,,,32,,,32,32,,,32,,,,468,,468',
-',468,468,468,468,468,468,468,,468,,,32,32,32,32,32,32,,,,32,32,38,38',
-'38,468,38,,,,38,38,,,,38,,38,38,38,38,38,38,38,,,,,38,38,38,38,38,38',
-'38,,,,,,,,,,38,,,38,38,38,38,38,38,38,38,38,38,,38,38,,38,38,38,,,,',
-',,,,,,,,,,,,,,,38,,,38,,,38,38,,,38,,,,,,38,,,,,,,,38,,,,,38,38,38,38',
-'38,38,,,,38,38,39,39,39,,39,,,,39,39,,,,39,,39,39,39,39,39,39,39,,,',
-',39,39,39,39,39,39,39,,,,,,,,,,39,,,39,39,39,39,39,39,39,39,39,39,,39',
-'39,,39,39,39,,,,,,,,,,,,,,,,,,,,39,,,39,,,39,39,,,39,,,,,,39,,,,,,,',
-'39,,,,,39,39,39,39,39,39,,,,39,39,40,40,40,,40,,,,40,40,,,,40,,40,40',
-'40,40,40,40,40,,,,,40,40,40,40,40,40,40,,,,,,,,,,40,,,40,40,40,40,40',
-'40,40,40,40,40,,40,40,,40,40,40,,,,,,,,,,,,,,,,,,,,40,,,40,,,40,40,',
-',40,,,,,,40,,,,,,,,40,,,,,40,40,40,40,40,40,,,,40,40,52,52,52,,52,,',
-',52,52,,,,52,,52,52,52,52,52,52,52,,,,,52,52,52,52,52,52,52,,,52,,,',
-',,,52,,,52,52,52,52,52,52,52,52,52,52,,52,52,,52,52,52,,,,,,,,,,,,,',
-',,,,,,52,,,52,,,52,52,,,52,,,,,,52,,,,,,,,52,,,,,52,52,52,52,52,52,',
-',,52,52,53,53,53,,53,,,,53,53,,,,53,,53,53,53,53,53,53,53,,,,,53,53',
-'53,53,53,53,53,,,,,,,,,,53,,,53,53,53,53,53,53,53,53,53,53,,53,53,,53',
-'53,53,,,,,,,,,,,,,,,,,,,,53,,,53,,,53,53,,,53,,53,,,,53,,,,,,,,53,,',
-',,53,53,53,53,53,53,,,,53,53,54,54,54,,54,,,,54,54,,,,54,,54,54,54,54',
-'54,54,54,,,,,54,54,54,54,54,54,54,,,,,,,,,,54,,,54,54,54,54,54,54,54',
-'54,54,54,,54,54,,54,54,54,,,,,,,,,,,,,,,,,,,,54,,,54,,,54,54,,,54,,',
-',,,54,,,,,,,,54,,,,,54,54,54,54,54,54,,,,54,54,56,56,56,,56,,,,56,56',
-',,,56,,56,56,56,56,56,56,56,,,,,56,56,56,56,56,56,56,,,56,,,,,,,56,',
-',56,56,56,56,56,56,56,56,56,56,,56,56,,56,56,56,,,,,,,,,,,,,,,,,,,,56',
-',,56,,,56,56,,,56,,,,,,56,,,,,,,,56,,,,,56,56,56,56,56,56,,,,56,56,57',
-'57,57,,57,,,,57,57,,,,57,,57,57,57,57,57,57,57,,,,,57,57,57,57,57,57',
-'57,,,57,,,,,,,57,,,57,57,57,57,57,57,57,57,57,57,,57,57,,57,57,57,,',
-',,,,,,,,,,,,,,,,,57,,,57,,,57,57,,,57,,,,,,57,,,,,,,,57,,,,,57,57,57',
-'57,57,57,,,,57,57,61,61,61,,61,,,,61,61,,,,61,,61,61,61,61,61,61,61',
-',,,,61,61,61,61,61,61,61,,,,,,,,,,61,,,61,61,61,61,61,61,61,61,61,61',
-',61,61,,,,61,,689,689,689,689,689,689,689,689,689,689,689,,689,689,',
-',689,689,61,,,61,,,61,61,,,61,,61,,689,,689,,689,689,689,689,689,689',
-'689,,689,,,61,61,61,61,61,61,,,,61,61,62,62,62,689,62,,,,62,62,,,,62',
-',62,62,62,62,62,62,62,,,,,62,62,62,62,62,62,62,,,,,,,,,,62,,,62,62,62',
-'62,62,62,62,62,62,62,,62,62,,,,62,,684,684,684,684,684,684,684,684,684',
-'684,684,,684,684,,62,684,684,62,,,62,,,62,62,,,62,,,,684,,684,,684,684',
-'684,684,684,684,684,,684,,,62,62,62,62,62,62,,,,62,62,63,63,63,684,63',
-',,,63,63,,,,63,,63,63,63,63,63,63,63,,,,,63,63,63,63,63,63,63,,,,,,',
-',,,63,,,63,63,63,63,63,63,63,63,63,63,,63,63,,,,63,,374,374,374,374',
-'374,374,374,374,374,374,374,,374,374,,,374,374,63,,,63,,,63,63,,,63',
-',,,374,,374,,374,374,374,374,374,374,374,,374,,,63,63,63,63,63,63,,',
-',63,63,82,82,82,374,82,,,,82,82,,,,82,,82,82,82,82,82,82,82,,82,,,82',
-'82,82,82,82,82,82,,,,,,,,,,82,,,82,82,82,82,82,82,82,82,82,82,,82,82',
-',82,82,82,,,,,,,,,,,,,,,,,,,,82,,,82,82,,82,82,,,82,,82,,82,,82,,,,',
-',,,82,,82,,,82,82,82,82,82,82,,,,82,82,86,86,86,,86,,,,86,86,,,,86,',
-'86,86,86,86,86,86,86,,86,,,86,86,86,86,86,86,86,,,,,,,,,,86,,,86,86',
-'86,86,86,86,86,86,86,86,,86,86,,86,86,86,,,,,,,,,,,,,,,,,,,,86,,,86',
-'86,,86,86,,,86,,86,,86,,86,,,,,,,,86,,86,,,86,86,86,86,86,86,,,,86,86',
-'101,101,101,,101,,,,101,101,,,,101,,101,101,101,101,101,101,101,,,,',
-'101,101,101,101,101,101,101,,,101,,,,,,,101,,,101,101,101,101,101,101',
-'101,101,101,101,,101,101,,101,101,101,,,,,,,,,,,,,,,,,,,,101,,,101,',
-',101,101,,,101,,,,,,101,,,,,,,,101,,,,,101,101,101,101,101,101,,,,101',
-'101,102,102,102,,102,,,,102,102,,,,102,,102,102,102,102,102,102,102',
-',,,,102,102,102,102,102,102,102,,,102,,,,,,,102,,,102,102,102,102,102',
-'102,102,102,102,102,,102,102,,102,102,102,,,,,,,,,,,,,,,,,,,,102,,,102',
-',,102,102,,,102,,,,,,102,,,,,,,,102,,,,,102,102,102,102,102,102,,,,102',
-'102,103,103,103,,103,,,,103,103,,,,103,,103,103,103,103,103,103,103',
-',,,,103,103,103,103,103,103,103,,,103,,,,,,,103,,,103,103,103,103,103',
-'103,103,103,103,103,,103,103,,103,103,103,,,,,,,,,,,,,,,,,,,,103,,,103',
-',,103,103,,,103,,,,,,103,,,,,,,,103,,,,,103,103,103,103,103,103,,,,103',
-'103,104,104,104,,104,,,,104,104,,,,104,,104,104,104,104,104,104,104',
-',,,,104,104,104,104,104,104,104,,,104,,,,,,,104,,,104,104,104,104,104',
-'104,104,104,104,104,,104,104,,104,104,104,,,,,,,,,,,,,,,,,,,,104,,,104',
-',,104,104,,,104,,,,,,104,,,,,,,,104,,,,,104,104,104,104,104,104,,,,104',
-'104,105,105,105,105,105,,,,105,105,,,,105,,105,105,105,105,105,105,105',
-',,,,105,105,105,105,105,105,105,,,105,,,,,,105,105,105,105,105,105,105',
-'105,105,105,105,105,105,105,,105,105,,105,105,105,,,,,,,,,,,,,,,,,,',
-',105,,,105,,,105,105,,,105,,105,,,,105,,,,,,,,105,,,,,105,105,105,105',
-'105,105,,,,105,105,188,188,188,,188,,,,188,188,,,,188,,188,188,188,188',
-'188,188,188,,,,,188,188,188,188,188,188,188,,,,,,,,,,188,,,188,188,188',
-'188,188,188,188,188,188,188,,188,188,,188,188,188,,,,,,,,,,,,,,,,,,',
-',188,,,188,,,188,188,,,188,,188,,,,188,,,,,,,,188,,,,,188,188,188,188',
-'188,188,,,,188,188,189,189,189,,189,,,,189,189,,,,189,,189,189,189,189',
-'189,189,189,,,,,189,189,189,189,189,189,189,,,,,,,,,,189,,,189,189,189',
-'189,189,189,189,189,189,189,,189,189,,189,189,189,,,,,,,,,,,,,,,,,,',
-',189,,,189,,,189,189,,,189,,189,,,,189,,,,,,,,189,,,,,189,189,189,189',
-'189,189,,,,189,189,190,190,190,,190,,,,190,190,,,,190,,190,190,190,190',
-'190,190,190,,,,,190,190,190,190,190,190,190,,,,,,,,,,190,,,190,190,190',
-'190,190,190,190,190,190,190,,190,190,,190,190,190,,,,,,,,,,,,,,,,,,',
-',190,,,190,,,190,190,,,190,,,,,,190,,,,,,,,190,,,,,190,190,190,190,190',
-'190,,,,190,190,191,191,191,,191,,,,191,191,,,,191,,191,191,191,191,191',
-'191,191,,,,,191,191,191,191,191,191,191,,,,,,,,,,191,,,191,191,191,191',
-'191,191,191,191,191,191,,191,191,,191,191,191,,,,,,,,,,,,,,,,,,,,191',
-',,191,,,191,191,,,191,,191,,,,191,,,,,,,,191,,,,,191,191,191,191,191',
-'191,,,,191,191,194,194,194,,194,,,,194,194,,,,194,,194,194,194,194,194',
-'194,194,,,,,194,194,194,194,194,194,194,,,,,,,,,,194,,,194,194,194,194',
-'194,194,194,194,194,194,,194,194,,194,194,194,,,,,,,,,,,,,,,,,,,,194',
-',,194,,,194,194,,,194,,,,,,194,,,,,,,,194,,,,,194,194,194,194,194,194',
-',,,194,194,195,195,195,,195,,,,195,195,,,,195,,195,195,195,195,195,195',
-'195,,,,,195,195,195,195,195,195,195,,,195,,,,,,,195,,,195,195,195,195',
-'195,195,195,195,195,195,,195,195,,195,195,195,,,,,,,,,,,,,,,,,,,,195',
-',,195,,,195,195,,,195,,,,,,195,,,,,,,,195,,,,,195,195,195,195,195,195',
-',,,195,195,196,196,196,,196,,,,196,196,,,,196,,196,196,196,196,196,196',
-'196,,,,,196,196,196,196,196,196,196,,,196,,,,,,,196,,,196,196,196,196',
-'196,196,196,196,196,196,,196,196,,196,196,196,,,,,,,,,,,,,,,,,,,,196',
-',,196,,,196,196,,,196,,,,,,196,,,,,,,,196,,,,,196,196,196,196,196,196',
-',,,196,196,207,207,207,,207,,,,207,207,,,,207,,207,207,207,207,207,207',
-'207,,,,,207,207,207,207,207,207,207,,,,,,,,,,207,,,207,207,207,207,207',
-'207,207,207,207,207,,207,207,,207,207,207,,,,,,,,,,,,,,,,,,,,207,,,207',
-',,207,207,,,207,,,,,,207,,,,,,,,207,,,,,207,207,207,207,207,207,,,,207',
-'207,208,208,208,,208,,,,208,208,,,,208,,208,208,208,208,208,208,208',
-',,,,208,208,208,208,208,208,208,,,,,,,,,,208,,,208,208,208,208,208,208',
-'208,208,208,208,,208,208,,208,208,208,,,,,,,,,,,,,,,,,,,,208,,,208,',
-',208,208,,,208,,,,,,208,,,,,,,,208,,,,,208,208,208,208,208,208,,,,208',
-'208,209,209,209,,209,,,,209,209,,,,209,,209,209,209,209,209,209,209',
-',,,,209,209,209,209,209,209,209,,,,,,,,,,209,,,209,209,209,209,209,209',
-'209,209,209,209,,209,209,,209,209,209,,,,,,,,,,,,,,,,,,,,209,,,209,',
-',209,209,,,209,,,,,,209,,,,,,,,209,,,,,209,209,209,209,209,209,,,,209',
-'209,210,210,210,,210,,,,210,210,,,,210,,210,210,210,210,210,210,210',
-',,,,210,210,210,210,210,210,210,,,,,,,,,,210,,,210,210,210,210,210,210',
-'210,210,210,210,,210,210,,210,210,210,,,,,,,,,,,,,,,,,,,,210,,,210,',
-',210,210,,,210,,,,,,210,,,,,,,,210,,,,,210,210,210,210,210,210,,,,210',
-'210,211,211,211,,211,,,,211,211,,,,211,,211,211,211,211,211,211,211',
-',,,,211,211,211,211,211,211,211,,,,,,,,,,211,,,211,211,211,211,211,211',
-'211,211,211,211,,211,211,,211,211,211,,,,,,,,,,,,,,,,,,,,211,,,211,',
-',211,211,,,211,,,,,,211,,,,,,,,211,,,,,211,211,211,211,211,211,,,,211',
-'211,212,212,212,,212,,,,212,212,,,,212,,212,212,212,212,212,212,212',
-',,,,212,212,212,212,212,212,212,,,,,,,,,,212,,,212,212,212,212,212,212',
-'212,212,212,212,,212,212,,212,212,212,,,,,,,,,,,,,,,,,,,,212,,,212,',
-',212,212,,,212,,,,,,212,,,,,,,,212,,,,,212,212,212,212,212,212,,,,212',
-'212,213,213,213,,213,,,,213,213,,,,213,,213,213,213,213,213,213,213',
-',,,,213,213,213,213,213,213,213,,,,,,,,,,213,,,213,213,213,213,213,213',
-'213,213,213,213,,213,213,,213,213,213,,,,,,,,,,,,,,,,,,,,213,,,213,',
-',213,213,,,213,,,,,,213,,,,,,,,213,,,,,213,213,213,213,213,213,,,,213',
-'213,214,214,214,,214,,,,214,214,,,,214,,214,214,214,214,214,214,214',
-',,,,214,214,214,214,214,214,214,,,,,,,,,,214,,,214,214,214,214,214,214',
-'214,214,214,214,,214,214,,214,214,214,,,,,,,,,,,,,,,,,,,,214,,,214,',
-',214,214,,,214,,,,,,214,,,,,,,,214,,,,,214,214,214,214,214,214,,,,214',
-'214,215,215,215,,215,,,,215,215,,,,215,,215,215,215,215,215,215,215',
-',,,,215,215,215,215,215,215,215,,,,,,,,,,215,,,215,215,215,215,215,215',
-'215,215,215,215,,215,215,,215,215,215,,,,,,,,,,,,,,,,,,,,215,,,215,',
-',215,215,,,215,,,,,,215,,,,,,,,215,,,,,215,215,215,215,215,215,,,,215',
-'215,216,216,216,,216,,,,216,216,,,,216,,216,216,216,216,216,216,216',
-',,,,216,216,216,216,216,216,216,,,,,,,,,,216,,,216,216,216,216,216,216',
-'216,216,216,216,,216,216,,216,216,216,,,,,,,,,,,,,,,,,,,,216,,,216,',
-',216,216,,,216,,,,,,216,,,,,,,,216,,,,,216,216,216,216,216,216,,,,216',
-'216,217,217,217,,217,,,,217,217,,,,217,,217,217,217,217,217,217,217',
-',,,,217,217,217,217,217,217,217,,,,,,,,,,217,,,217,217,217,217,217,217',
-'217,217,217,217,,217,217,,217,217,217,,,,,,,,,,,,,,,,,,,,217,,,217,',
-',217,217,,,217,,,,,,217,,,,,,,,217,,,,,217,217,217,217,217,217,,,,217',
-'217,218,218,218,,218,,,,218,218,,,,218,,218,218,218,218,218,218,218',
-',,,,218,218,218,218,218,218,218,,,,,,,,,,218,,,218,218,218,218,218,218',
-'218,218,218,218,,218,218,,218,218,218,,,,,,,,,,,,,,,,,,,,218,,,218,',
-',218,218,,,218,,,,,,218,,,,,,,,218,,,,,218,218,218,218,218,218,,,,218',
-'218,219,219,219,,219,,,,219,219,,,,219,,219,219,219,219,219,219,219',
-',,,,219,219,219,219,219,219,219,,,,,,,,,,219,,,219,219,219,219,219,219',
-'219,219,219,219,,219,219,,219,219,219,,,,,,,,,,,,,,,,,,,,219,,,219,',
-',219,219,,,219,,,,,,219,,,,,,,,219,,,,,219,219,219,219,219,219,,,,219',
-'219,220,220,220,,220,,,,220,220,,,,220,,220,220,220,220,220,220,220',
-',,,,220,220,220,220,220,220,220,,,,,,,,,,220,,,220,220,220,220,220,220',
-'220,220,220,220,,220,220,,220,220,220,,,,,,,,,,,,,,,,,,,,220,,,220,',
-',220,220,,,220,,,,,,220,,,,,,,,220,,,,,220,220,220,220,220,220,,,,220',
-'220,221,221,221,,221,,,,221,221,,,,221,,221,221,221,221,221,221,221',
-',,,,221,221,221,221,221,221,221,,,,,,,,,,221,,,221,221,221,221,221,221',
-'221,221,221,221,,221,221,,221,221,221,,,,,,,,,,,,,,,,,,,,221,,,221,',
-',221,221,,,221,,,,,,221,,,,,,,,221,,,,,221,221,221,221,221,221,,,,221',
-'221,222,222,222,,222,,,,222,222,,,,222,,222,222,222,222,222,222,222',
-',,,,222,222,222,222,222,222,222,,,,,,,,,,222,,,222,222,222,222,222,222',
-'222,222,222,222,,222,222,,222,222,222,,,,,,,,,,,,,,,,,,,,222,,,222,',
-',222,222,,,222,,,,,,222,,,,,,,,222,,,,,222,222,222,222,222,222,,,,222',
-'222,223,223,223,,223,,,,223,223,,,,223,,223,223,223,223,223,223,223',
-',,,,223,223,223,223,223,223,223,,,,,,,,,,223,,,223,223,223,223,223,223',
-'223,223,223,223,,223,223,,223,223,223,,,,,,,,,,,,,,,,,,,,223,,,223,',
-',223,223,,,223,,,,,,223,,,,,,,,223,,,,,223,223,223,223,223,223,,,,223',
-'223,224,224,224,,224,,,,224,224,,,,224,,224,224,224,224,224,224,224',
-',,,,224,224,224,224,224,224,224,,,,,,,,,,224,,,224,224,224,224,224,224',
-'224,224,224,224,,224,224,,224,224,224,,,,,,,,,,,,,,,,,,,,224,,,224,',
-',224,224,,,224,,,,,,224,,,,,,,,224,,,,,224,224,224,224,224,224,,,,224',
-'224,225,225,225,,225,,,,225,225,,,,225,,225,225,225,225,225,225,225',
-',,,,225,225,225,225,225,225,225,,,,,,,,,,225,,,225,225,225,225,225,225',
-'225,225,225,225,,225,225,,225,225,225,,,,,,,,,,,,,,,,,,,,225,,,225,',
-',225,225,,,225,,,,,,225,,,,,,,,225,,,,,225,225,225,225,225,225,,,,225',
-'225,226,226,226,,226,,,,226,226,,,,226,,226,226,226,226,226,226,226',
-',,,,226,226,226,226,226,226,226,,,,,,,,,,226,,,226,226,226,226,226,226',
-'226,226,226,226,,226,226,,226,226,226,,,,,,,,,,,,,,,,,,,,226,,,226,',
-',226,226,,,226,,,,,,226,,,,,,,,226,,,,,226,226,226,226,226,226,,,,226',
-'226,227,227,227,,227,,,,227,227,,,,227,,227,227,227,227,227,227,227',
-',,,,227,227,227,227,227,227,227,,,,,,,,,,227,,,227,227,227,227,227,227',
-'227,227,227,227,,227,227,,227,227,227,,,,,,,,,,,,,,,,,,,,227,,,227,',
-',227,227,,,227,,,,,,227,,,,,,,,227,,,,,227,227,227,227,227,227,,,,227',
-'227,228,228,228,,228,,,,228,228,,,,228,,228,228,228,228,228,228,228',
-',,,,228,228,228,228,228,228,228,,,,,,,,,,228,,,228,228,228,228,228,228',
-'228,228,228,228,,228,228,,228,228,228,,,,,,,,,,,,,,,,,,,,228,,,228,',
-',228,228,,,228,,,,,,228,,,,,,,,228,,,,,228,228,228,228,228,228,,,,228',
-'228,229,229,229,,229,,,,229,229,,,,229,,229,229,229,229,229,229,229',
-',,,,229,229,229,229,229,229,229,,,,,,,,,,229,,,229,229,229,229,229,229',
-'229,229,229,229,,229,229,,229,229,229,,,,,,,,,,,,,,,,,,,,229,,,229,',
-',229,229,,,229,,,,,,229,,,,,,,,229,,,,,229,229,229,229,229,229,,,,229',
-'229,230,230,230,,230,,,,230,230,,,,230,,230,230,230,230,230,230,230',
-',,,,230,230,230,230,230,230,230,,,,,,,,,,230,,,230,230,230,230,230,230',
-'230,230,230,230,,230,230,,230,230,230,,,,,,,,,,,,,,,,,,,,230,,,230,',
-',230,230,,,230,,,,,,230,,,,,,,,230,,,,,230,230,230,230,230,230,,,,230',
-'230,231,231,231,,231,,,,231,231,,,,231,,231,231,231,231,231,231,231',
-',,,,231,231,231,231,231,231,231,,,,,,,,,,231,,,231,231,231,231,231,231',
-'231,231,231,231,,231,231,,231,231,231,,,,,,,,,,,,,,,,,,,,231,,,231,',
-',231,231,,,231,,,,,,231,,,,,,,,231,,,,,231,231,231,231,231,231,,,,231',
-'231,232,232,232,,232,,,,232,232,,,,232,,232,232,232,232,232,232,232',
-',,,,232,232,232,232,232,232,232,,,,,,,,,,232,,,232,232,232,232,232,232',
-'232,232,232,232,,232,232,,232,232,232,,,,,,,,,,,,,,,,,,,,232,,,232,',
-',232,232,,,232,,,,,,232,,,,,,,,232,,,,,232,232,232,232,232,232,,,,232',
-'232,233,233,233,,233,,,,233,233,,,,233,,233,233,233,233,233,233,233',
-',,,,233,233,233,233,233,233,233,,,,,,,,,,233,,,233,233,233,233,233,233',
-'233,233,233,233,,233,233,,233,233,233,,,,,,,,,,,,,,,,,,,,233,,,233,',
-',233,233,,,233,,,,,,233,,,,,,,,233,,,,,233,233,233,233,233,233,,,,233',
-'233,241,241,241,,241,,,,241,241,,,,241,,241,241,241,241,241,241,241',
-',,,,241,241,241,241,241,241,241,,,,,,,,,,241,,,241,241,241,241,241,241',
-'241,241,241,241,,241,241,,241,241,241,,,,,,,,,,,,,,,,,,,,241,,,241,',
-',241,241,,,241,,,,,,241,,,,,,,,241,,,,,241,241,241,241,241,241,,,,241',
-'241,243,243,243,,243,,,,243,243,,,,243,,243,243,243,243,243,243,243',
-',,,,243,243,243,243,243,243,243,,,,,,,,,,243,,,243,243,243,243,243,243',
-'243,243,243,243,,243,243,,243,243,243,,,,,,,,,,,,,,,,,,,,243,,,243,',
-',243,243,,,243,,,,,,243,,,,,,,,243,,,,,243,243,243,243,243,243,,,,243',
-'243,254,254,254,,254,,,,254,254,,,,254,,254,254,254,254,254,254,254',
-',,,,254,254,254,254,254,254,254,,,,,,,,,,254,,,254,254,254,254,254,254',
-'254,254,254,254,,254,254,,254,254,254,,,,,,,,,,,,,,,,,,,,254,,,254,',
-',254,254,,,254,,254,,254,,254,,,,,,,,254,,,,,254,254,254,254,254,254',
-',,,254,254,255,255,255,,255,,,,255,255,,,,255,,255,255,255,255,255,255',
-'255,,,,,255,255,255,255,255,255,255,,,,,,,,,,255,,,255,255,255,255,255',
-'255,255,255,255,255,,255,255,,255,255,255,,,,,,,,,,,,,,,,,,,,255,,,255',
-',,255,255,,,255,,255,,255,,255,,,,,,,,255,,,,,255,255,255,255,255,255',
-',,,255,255,263,263,263,,263,,,,263,263,,,,263,,263,263,263,263,263,263',
-'263,,,,,263,263,263,263,263,263,263,,,,,,,,,,263,,,263,263,263,263,263',
-'263,263,263,263,263,,263,263,,263,263,263,,,,,,,,,,,,,,,,,,,,263,,,263',
-',263,263,263,,,263,,263,,263,,263,,,,,,,,263,,,,,263,263,263,263,263',
-'263,,,,263,263,269,269,269,,269,,,,269,269,,,,269,,269,269,269,269,269',
-'269,269,,,,,269,269,269,269,269,269,269,,,,,,,,,,269,,,269,269,269,269',
-'269,269,269,269,269,269,,269,269,,,,269,,687,687,687,687,687,687,687',
-'687,687,687,687,,687,687,,,687,687,269,,,269,,,269,269,,,269,,,,687',
-',687,,687,687,687,687,687,687,687,,687,,,269,269,269,269,269,269,,,',
-'269,269,290,290,290,687,290,,,,290,290,,,,290,,290,290,290,290,290,290',
-'290,,,,,290,290,290,290,290,290,290,,,,,,,,,,290,,,290,290,290,290,290',
-'290,290,290,290,290,,290,290,,290,290,290,,,,,,,,,,,,,,,,,,,,290,,,290',
-'290,,290,290,,,290,,,,,,290,,,,,,,,290,,,,,290,290,290,290,290,290,',
-',,290,290,299,299,299,,299,,,,299,299,,,,299,,299,299,299,299,299,299',
-'299,,,,,299,299,299,299,299,299,299,,,,,,,,,,299,,,299,299,299,299,299',
-'299,299,299,299,299,,299,299,,299,299,299,,,,,,,,,,,,,,,,,,,,299,,,299',
-',,299,299,,,299,,,,,,299,,,,,,,,299,,,,,299,299,299,299,299,299,,,,299',
-'299,308,308,308,,308,,,,308,308,,,,308,,308,308,308,308,308,308,308',
-',,,,308,308,308,308,308,308,308,,,308,,,,,,,308,,,308,308,308,308,308',
-'308,308,308,308,308,,308,308,,308,308,308,,,,,,,,,,,,,,,,,,,,308,,,308',
-',,308,308,,,308,,,,,,308,,,,,,,,308,,,,,308,308,308,308,308,308,,,,308',
-'308,309,309,309,,309,,,,309,309,,,,309,,309,309,309,309,309,309,309',
-',,,,309,309,309,309,309,309,309,,,309,,,,,,,309,,,309,309,309,309,309',
-'309,309,309,309,309,,309,309,,309,309,309,,,,,,,,,,,,,,,,,,,,309,,,309',
-',,309,309,,,309,,,,,,309,,,,,,,,309,,,,,309,309,309,309,309,309,,,,309',
-'309,327,327,327,,327,,,,327,327,,,,327,,327,327,327,327,327,327,327',
-',,,,327,327,327,327,327,327,327,,,327,,,,,,,327,,,327,327,327,327,327',
-'327,327,327,327,327,,327,327,,327,327,327,,,,,,,,,,,,,,,,,,,,327,,,327',
-',,327,327,,,327,,,,,,327,,,,,,,,327,,,,,327,327,327,327,327,327,,,,327',
-'327,341,341,341,,341,,,,341,341,,,,341,,341,341,341,341,341,341,341',
-',,,,341,341,341,341,341,341,341,,,341,,,,,,,341,,,341,341,341,341,341',
-'341,341,341,341,341,,341,341,,341,341,341,,,,,,,,,,,,,,,,,,,,341,,,341',
-',,341,341,,,341,,,,,,341,,,,,,,,341,,,,,341,341,341,341,341,341,,,,341',
-'341,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357',
-'357,357,357,357,357,357,357,357,,,357,357,357,357,357,357,357,357,357',
-'357,,,,,,357,357,357,357,357,357,357,357,,,357,,,,,,,,357,357,,357,357',
-'357,357,,357,357,,,357,,,,,357,357,357,357,,,,,,,,,,,,,,357,357,,357',
-'357,357,357,357,357,357,357,357,,357,,,357,357,,,378,378,378,,378,,',
-'357,378,378,,,,378,,378,378,378,378,378,378,378,,,,,378,378,378,378',
-'378,378,378,,,,,,,,,,378,,,378,378,378,378,378,378,378,378,378,378,',
-'378,378,,378,378,378,,,,,,,,,,,,,,,,,,,,378,,,378,378,,378,378,,,378',
-',378,,378,,378,,,,,,,,378,,,,,378,378,378,378,378,378,,,,378,378,385',
-'385,385,,385,,,,385,385,,,,385,,385,385,385,385,385,385,385,,,,,385',
-'385,385,385,385,385,385,,,,,,,,,,385,,,385,385,385,385,385,385,385,385',
-'385,385,,385,385,,385,385,385,,,,,,,,,,,,,,,,,,,,385,,,385,385,,385',
-'385,,,385,,385,,385,,385,,,,,,,,385,,,,,385,385,385,385,385,385,,,,385',
-'385,386,386,386,,386,,,,386,386,,,,386,,386,386,386,386,386,386,386',
-',,,,386,386,386,386,386,386,386,,,,,,,,,,386,,,386,386,386,386,386,386',
-'386,386,386,386,,386,386,,386,386,386,,,,,,,,,,,,,,,,,,,,386,,,386,386',
-',386,386,,,386,,386,,386,,386,,,,,,,,386,,,,,386,386,386,386,386,386',
-',,,386,386,393,393,393,,393,,,,393,393,,,,393,,393,393,393,393,393,393',
-'393,,,,,393,393,393,393,393,393,393,,,,,,,,,,393,,,393,393,393,393,393',
-'393,393,393,393,393,,393,393,,393,393,393,,,,,,,,,,,,,,,,,,,,393,,,393',
-',,393,393,,,393,,393,,,,393,,,,,,,,393,,,,,393,393,393,393,393,393,',
-',,393,393,395,395,395,,395,,,,395,395,,,,395,,395,395,395,395,395,395',
-'395,,,,,395,395,395,395,395,395,395,,,,,,,,,,395,,,395,395,395,395,395',
-'395,395,395,395,395,,395,395,,395,395,395,,,,,,,,,,,,,,,,,,,,395,,,395',
-',,395,395,,,395,,,,,,395,,,,,,,,395,,,,,395,395,395,395,395,395,,,,395',
-'395,396,396,396,,396,,,,396,396,,,,396,,396,396,396,396,396,396,396',
-',,,,396,396,396,396,396,396,396,,,,,,,,,,396,,,396,396,396,396,396,396',
-'396,396,396,396,,396,396,,396,396,396,,,,,,,,,,,,,,,,,,,,396,,,396,',
-',396,396,,,396,,,,,,396,,,,,,,,396,,,,,396,396,396,396,396,396,,,,396',
-'396,397,397,397,,397,,,,397,397,,,,397,,397,397,397,397,397,397,397',
-',,,,397,397,397,397,397,397,397,,,,,,,,,,397,,,397,397,397,397,397,397',
-'397,397,397,397,,397,397,,397,397,397,,,,,,,,,,,,,,,,,,,,397,,,397,',
-',397,397,,,397,,,,,,397,,,,,,,,397,,,,,397,397,397,397,397,397,,,,397',
-'397,426,426,426,,426,,,,426,426,,,,426,,426,426,426,426,426,426,426',
-',,,,426,426,426,426,426,426,426,,,,,,,,,,426,,,426,426,426,426,426,426',
-'426,426,426,426,,426,426,,426,426,426,,,,,,,,,,,,,,,,,,,,426,,,426,',
-',426,426,,,426,,426,,426,,426,,,,,,,,426,,,,,426,426,426,426,426,426',
-',,,426,426,428,428,428,,428,,,,428,428,,,,428,,428,428,428,428,428,428',
-'428,,,,,428,428,428,428,428,428,428,,,,,,,,,,428,,,428,428,428,428,428',
-'428,428,428,428,428,,428,428,,428,428,428,,,,,,,,,,,,,,,,,,,,428,,,428',
-',,428,428,,,428,,428,,428,,428,,,,,,,,428,,,,,428,428,428,428,428,428',
-',,,428,428,431,431,431,,431,,,,431,431,,,,431,,431,431,431,431,431,431',
-'431,,,,,431,431,431,431,431,431,431,,,,,,,,,,431,,,431,431,431,431,431',
-'431,431,431,431,431,,431,431,,431,431,431,,,,,,,,,,,,,,,,,,,,431,,,431',
-',,431,431,,,431,,,,,,431,,,,,,,,431,,,,,431,431,431,431,431,431,,,,431',
-'431,445,445,445,,445,,,,445,445,,,,445,,445,445,445,445,445,445,445',
-',,,,445,445,445,445,445,445,445,,,445,,,,,,,445,,,445,445,445,445,445',
-'445,445,445,445,445,,445,445,,445,445,445,,,,,,,,,,,,,,,,,,,,445,,,445',
-',,445,445,,,445,,445,,445,,445,,,,,,,,445,,,,,445,445,445,445,445,445',
-',,,445,445,456,456,456,,456,,,,456,456,,,,456,,456,456,456,456,456,456',
-'456,,,,,456,456,456,456,456,456,456,,,,,,,,,,456,,,456,456,456,456,456',
-'456,456,456,456,456,,456,456,,456,456,456,,,,,,,,,,,,,,,,,,,,456,,,456',
-',,456,456,,,456,,456,,,,456,,,,,,,,456,,,,,456,456,456,456,456,456,',
-',,456,456,463,463,463,,463,,,,463,463,,,,463,,463,463,463,463,463,463',
-'463,,,,,463,463,463,463,463,463,463,,,,,,,,,,463,,,463,463,463,463,463',
-'463,463,463,463,463,,463,463,,463,463,463,,,,,,,,,,,,,,,,,,,,463,,,463',
-',,463,463,,,463,,,,,,463,,,,,,,,463,,,,,463,463,463,463,463,463,,,,463',
-'463,464,464,464,,464,,,,464,464,,,,464,,464,464,464,464,464,464,464',
-',,,,464,464,464,464,464,464,464,,,,,,,,,,464,,,464,464,464,464,464,464',
-'464,464,464,464,,464,464,,464,464,464,,,,,,,,,,,,,,,,,,,,464,,,464,',
-',464,464,,,464,,,,,,464,,,,,,,,464,,,,,464,464,464,464,464,464,,,,464',
-'464,465,465,465,,465,,,,465,465,,,,465,,465,465,465,465,465,465,465',
-',,,,465,465,465,465,465,465,465,,,,,,,,,,465,,,465,465,465,465,465,465',
-'465,465,465,465,,465,465,,465,465,465,,,,,,,,,,,,,,,,,,,,465,,,465,',
-',465,465,,,465,,,,,,465,,,,,,,,465,,,,,465,465,465,465,465,465,,,,465',
-'465,469,469,469,,469,,,,469,469,,,,469,,469,469,469,469,469,469,469',
-',,,,469,469,469,469,469,469,469,,,469,,,,,,,469,,,469,469,469,469,469',
-'469,469,469,469,469,,469,469,,469,469,469,,,,,,,,,,,,,,,,,,,,469,,,469',
-',,469,469,,,469,,,,,,469,,,,,,,,469,,,,,469,469,469,469,469,469,,,,469',
-'469,471,471,471,,471,,,,471,471,,,,471,,471,471,471,471,471,471,471',
-',,,,471,471,471,471,471,471,471,,,,,,,,,,471,,,471,471,471,471,471,471',
-'471,471,471,471,,471,471,,471,471,471,,,,,,,,,,,,,,,,,,,,471,,,471,',
-',471,471,,,471,,471,,,,471,,,,,,,,471,,,,,471,471,471,471,471,471,,',
-',471,471,476,476,476,,476,,,,476,476,,,,476,,476,476,476,476,476,476',
-'476,,,,,476,476,476,476,476,476,476,,,,,,,,,,476,,,476,476,476,476,476',
-'476,476,476,476,476,,476,476,,476,476,476,,,,,,,,,,,,,,,,,,,,476,,,476',
-',,476,476,,,476,,476,,,,476,,,,,,,,476,,,,,476,476,476,476,476,476,',
-',,476,476,479,479,479,,479,,,,479,479,,,,479,,479,479,479,479,479,479',
-'479,,,,,479,479,479,479,479,479,479,,,,,,,,,,479,,,479,479,479,479,479',
-'479,479,479,479,479,,479,479,,479,479,479,,,,,,,,,,,,,,,,,,,,479,,,479',
-',,479,479,,,479,,,,,,479,,,,,,,,479,,,,,479,479,479,479,479,479,,,,479',
-'479,482,482,482,,482,,,,482,482,,,,482,,482,482,482,482,482,482,482',
-',,,,482,482,482,482,482,482,482,,,,,,,,,,482,,,482,482,482,482,482,482',
-'482,482,482,482,,482,482,,482,482,482,,,,,,,,,,,,,,,,,,,,482,,,482,',
-',482,482,,,482,,,,,,482,,,,,,,,482,,,,,482,482,482,482,482,482,,,,482',
-'482,496,496,496,,496,,,,496,496,,,,496,,496,496,496,496,496,496,496',
-',,,,496,496,496,496,496,496,496,,,,,,,,,,496,,,496,496,496,496,496,496',
-'496,496,496,496,,496,496,,496,496,496,,,,,,,,,,,,,,,,,,,,496,,,496,',
-',496,496,,,496,,496,,,,496,,,,,,,,496,,,,,496,496,496,496,496,496,,',
-',496,496,497,497,497,,497,,,,497,497,,,,497,,497,497,497,497,497,497',
-'497,,,,,497,497,497,497,497,497,497,,,,,,,,,,497,,,497,497,497,497,497',
-'497,497,497,497,497,,497,497,,497,497,497,,,,,,,,,,,,,,,,,,,,497,,,497',
-',,497,497,,,497,,497,,,,497,,,,,,,,497,,,,,497,497,497,497,497,497,',
-',,497,497,506,506,506,,506,,,,506,506,,,,506,,506,506,506,506,506,506',
-'506,,,,,506,506,506,506,506,506,506,,,,,,,,,,506,,,506,506,506,506,506',
-'506,506,506,506,506,,506,506,,506,506,506,,,,,,,,,,,,,,,,,,,,506,,,506',
-',,506,506,,,506,,506,,,,506,,,,,,,,506,,,,,506,506,506,506,506,506,',
-',,506,506,510,510,510,,510,,,,510,510,,,,510,,510,510,510,510,510,510',
-'510,,,,,510,510,510,510,510,510,510,,,510,,,,,,,510,,,510,510,510,510',
-'510,510,510,510,510,510,,510,510,,510,510,510,,,,,,,,,,,,,,,,,,,,510',
-',,510,,,510,510,,,510,,,,,,510,,,,,,,,510,,,,,510,510,510,510,510,510',
-',,,510,510,534,534,534,534,534,534,534,534,534,534,534,534,534,534,534',
-'534,534,534,534,534,534,534,534,534,,,534,534,534,534,534,534,534,534',
-'534,534,,,,,,534,534,534,534,534,534,534,534,,,534,,,,,,,,534,534,,534',
-'534,534,534,,534,534,,,534,,,,,534,534,534,534,,,,,,,,,,,,,,534,534',
-',534,534,534,534,534,534,534,534,534,,534,,,534,534,,,537,537,537,,537',
-',,534,537,537,,,,537,,537,537,537,537,537,537,537,,,,,537,537,537,537',
-'537,537,537,,,,,,,,,,537,,,537,537,537,537,537,537,537,537,537,537,',
-'537,537,,537,537,537,,,,,,,,,,,,,,,,,,,,537,,,537,,,537,537,,,537,,',
-',,,537,,,,,,,,537,,,,,537,537,537,537,537,537,,,,537,537,538,538,538',
-',538,,,,538,538,,,,538,,538,538,538,538,538,538,538,,,,,538,538,538',
-'538,538,538,538,,,,,,,,,,538,,,538,538,538,538,538,538,538,538,538,538',
-',538,538,,538,538,538,,,,,,,,,,,,,,,,,,,,538,,,538,,,538,538,,,538,',
-'538,,,,538,,,,,,,,538,,,,,538,538,538,538,538,538,,,,538,538,541,541',
-'541,,541,,,,541,541,,,,541,,541,541,541,541,541,541,541,,,,,541,541',
-'541,541,541,541,541,,,,,,,,,,541,,,541,541,541,541,541,541,541,541,541',
-'541,,541,541,,541,541,541,,,,,,,,,,,,,,,,,,,,541,,,541,,,541,541,,,541',
-',,,,,541,,,,,,,,541,,,,,541,541,541,541,541,541,,,,541,541,542,542,542',
-',542,,,,542,542,,,,542,,542,542,542,542,542,542,542,,,,,542,542,542',
-'542,542,542,542,,,,,,,,,,542,,,542,542,542,542,542,542,542,542,542,542',
-',542,542,,542,542,542,,,,,,,,,,,,,,,,,,,,542,,,542,,,542,542,,,542,',
-',,,,542,,,,,,,,542,,,,,542,542,542,542,542,542,,,,542,542,546,546,546',
-',546,,,,546,546,,,,546,,546,546,546,546,546,546,546,,,,,546,546,546',
-'546,546,546,546,,,,,,,,,,546,,,546,546,546,546,546,546,546,546,546,546',
-',546,546,,546,546,546,,,,,,,,,,,,,,,,,,,,546,,,546,,,546,546,,,546,',
-',,,,546,,,,,,,,546,,,,,546,546,546,546,546,546,,,,546,546,549,549,549',
-',549,,,,549,549,,,,549,,549,549,549,549,549,549,549,,,,,549,549,549',
-'549,549,549,549,,,,,,,,,,549,,,549,549,549,549,549,549,549,549,549,549',
-',549,549,,549,549,549,,,,,,,,,,,,,,,,,,,,549,,,549,,,549,549,,,549,',
-',,,,549,,,,,,,,549,,,,,549,549,549,549,549,549,,,,549,549,556,556,556',
-',556,,,,556,556,,,,556,,556,556,556,556,556,556,556,,,,,556,556,556',
-'556,556,556,556,,,,,,,,,,556,,,556,556,556,556,556,556,556,556,556,556',
-',556,556,,556,556,556,,,,,,,,,,,,,,,,,,,,556,,,556,,,556,556,,,556,',
-',,,,556,,,,,,,,556,,,,,556,556,556,556,556,556,,,,556,556,557,557,557',
-',557,,,,557,557,,,,557,,557,557,557,557,557,557,557,,,,,557,557,557',
-'557,557,557,557,,,,,,,,,,557,,,557,557,557,557,557,557,557,557,557,557',
-',557,557,,,,557,,,,,,,,,,,,,,,,,,,,557,,,557,,,557,557,,,557,,557,,557',
-',,,,,,,,557,,,,,,557,557,557,557,557,557,,,,557,557,560,560,560,,560',
-',,,560,560,,,,560,,560,560,560,560,560,560,560,,,,,560,560,560,560,560',
-'560,560,,,,,,,,,,560,,,560,560,560,560,560,560,560,560,560,560,,560',
-'560,,560,560,560,,,,,,,,,,,,,,,,,,,,560,,,560,,,560,560,,,560,,,,,,560',
-',,,,,,,560,,,,,560,560,560,560,560,560,,,,560,560,564,564,564,,564,',
-',,564,564,,,,564,,564,564,564,564,564,564,564,,,,,564,564,564,564,564',
-'564,564,,,,,,,,,,564,,,564,564,564,564,564,564,564,564,564,564,,564',
-'564,,564,564,564,,,,,,,,,,,,,,,,,,,,564,,,564,,,564,564,,,564,,,,,,564',
-',,,,,,,564,,,,,564,564,564,564,564,564,,,,564,564,580,580,580,,580,',
-',,580,580,,,,580,,580,580,580,580,580,580,580,,,,,580,580,580,580,580',
-'580,580,,,,,,,,,,580,,,580,580,580,580,580,580,580,580,580,580,,580',
-'580,,580,580,580,,,,,,,,,,,,,,,,,,,,580,,,580,,,580,580,,,580,,580,',
-'580,,580,,,,,,,,580,,,,,580,580,580,580,580,580,,,,580,580,584,584,584',
-',584,,,,584,584,,,,584,,584,584,584,584,584,584,584,,,,,584,584,584',
-'584,584,584,584,,,,,,,,,,584,,,584,584,584,584,584,584,584,584,584,584',
-',584,584,,584,584,584,,,,,,,,,,,,,,,,,,,,584,,,584,,,584,584,,,584,',
-',,,,584,,,,,,,,584,,,,,584,584,584,584,584,584,,,,584,584,612,612,612',
-',612,,,,612,612,,,,612,,612,612,612,612,612,612,612,,,,,612,612,612',
-'612,612,612,612,,,,,,,,,,612,,,612,612,612,612,612,612,612,612,612,612',
-',612,612,,612,612,612,,,,,,,,,,,,,,,,,,,,612,,,612,,,612,612,,,612,',
-',,,,612,,,,,,,,612,,,,,612,612,612,612,612,612,,,,612,612,628,628,628',
-',628,,,,628,628,,,,628,,628,628,628,628,628,628,628,,,,,628,628,628',
-'628,628,628,628,,,,,,,,,,628,,,628,628,628,628,628,628,628,628,628,628',
-',628,628,,628,628,628,,,,,,,,,,,,,,,,,,,,628,,,628,,,628,628,,,628,',
-',,,,628,,,,,,,,628,,,,,628,628,628,628,628,628,,,,628,628,634,634,634',
-',634,,,,634,634,,,,634,,634,634,634,634,634,634,634,,,,,634,634,634',
-'634,634,634,634,,,634,,,,,,,634,,,634,634,634,634,634,634,634,634,634',
-'634,,634,634,,634,634,634,,,,,,,,,,,,,,,,,,,,634,,,634,,,634,634,,,634',
-',,,,,634,,,,,,,,634,,,,,634,634,634,634,634,634,,,,634,634,679,679,679',
-',679,,,,679,679,,,,679,,679,679,679,679,679,679,679,,,,,679,679,679',
-'679,679,679,679,,,,,,,,,,679,,,679,679,679,679,679,679,679,679,679,679',
-',679,679,,679,679,679,,,,,,,,,,,,,,,,,,,,679,,,679,,,679,679,,,679,',
-',,,,679,,,,,,,,679,,,,,679,679,679,679,679,679,,,,679,679,680,680,680',
-',680,,,,680,680,,,,680,,680,680,680,680,680,680,680,,,,,680,680,680',
-'680,680,680,680,,,,,,,,,,680,,,680,680,680,680,680,680,680,680,680,680',
-',680,680,,680,680,680,,,,,,,,,,,,,,,,,,,,680,,,680,,,680,680,,,680,',
-',,,,680,,,,,,,,680,,,,,680,680,680,680,680,680,,,,680,680,690,690,690',
-',690,,,,690,690,,,,690,,690,690,690,690,690,690,690,,,,,690,690,690',
-'690,690,690,690,,,,,,,,,,690,,,690,690,690,690,690,690,690,690,690,690',
-',690,690,,690,690,690,,,,,,,,,,,,,,,,,,,,690,,,690,,,690,690,,,690,',
-',,,,690,,,,,,,,690,,,,,690,690,690,690,690,690,,,,690,690,691,691,691',
-',691,,,,691,691,,,,691,,691,691,691,691,691,691,691,,,,,691,691,691',
-'691,691,691,691,,,,,,,,,,691,,,691,691,691,691,691,691,691,691,691,691',
-',691,691,,691,691,691,,,,,,,,,,,,,,,,,,,,691,,,691,,,691,691,,,691,',
-',,,,691,,,,,,,,691,,,,,691,691,691,691,691,691,,,,691,691,692,692,692',
-',692,,,,692,692,,,,692,,692,692,692,692,692,692,692,,,,,692,692,692',
-'692,692,692,692,,,,,,,,,,692,,,692,692,692,692,692,692,692,692,692,692',
-',692,692,,692,692,692,,,,,,,,,,,,,,,,,,,,692,,,692,,,692,692,,,692,',
-',,,,692,,,,,,,,692,,,,,692,692,692,692,692,692,,,,692,692,698,698,698',
-',698,,,,698,698,,,,698,,698,698,698,698,698,698,698,,,,,698,698,698',
-'698,698,698,698,,,,,,,,,,698,,,698,698,698,698,698,698,698,698,698,698',
-',698,698,,,,698,,694,694,694,694,694,694,694,694,694,694,694,,694,694',
-',,694,694,698,,,698,,,698,698,,,698,,,,694,,694,,694,694,694,694,694',
-'694,694,,694,,,698,698,698,698,698,698,,,,698,698,704,704,704,694,704',
-',,,704,704,,,,704,,704,704,704,704,704,704,704,,,,,704,704,704,704,704',
-'704,704,,,,,,,,,,704,,,704,704,704,704,704,704,704,704,704,704,,704',
-'704,,704,704,704,,,,,,,,,,,,,,,,,,,,704,,,704,,,704,704,,,704,,704,',
-'704,,704,,,,,,,,704,,,,,704,704,704,704,704,704,,,,704,704,713,713,713',
-',713,,,,713,713,,,,713,,713,713,713,713,713,713,713,,,,,713,713,713',
-'713,713,713,713,,,,,,,,,,713,,,713,713,713,713,713,713,713,713,713,713',
-',713,713,,713,713,713,,,,,,,,,,,,,,,,,,,,713,,,713,,,713,713,,,713,',
-'713,,713,,713,,,,,,,,713,,,,,713,713,713,713,713,713,,,,713,713,715',
-'715,715,,715,,,,715,715,,,,715,,715,715,715,715,715,715,715,,,,,715',
-'715,715,715,715,715,715,,,,,,,,,,715,,,715,715,715,715,715,715,715,715',
-'715,715,,715,715,,715,715,715,,,,,,,,,,,,,,,,,,,,715,,,715,,,715,715',
-',,715,,715,,715,,715,,,,,,,,715,,,,,715,715,715,715,715,715,,,,715,715',
-'728,728,728,,728,,,,728,728,,,,728,,728,728,728,728,728,728,728,,,,',
-'728,728,728,728,728,728,728,,,,,,,,,,728,,,728,728,728,728,728,728,728',
-'728,728,728,,728,728,,,,728,,767,767,767,767,767,767,767,767,767,767',
-'767,,767,767,,,767,767,728,,,728,,,728,728,,,728,,,,767,,767,,767,767',
-'767,767,767,767,767,,767,,,728,728,728,728,728,728,,,,728,728,734,734',
-'734,767,734,,,,734,734,,,,734,,734,734,734,734,734,734,734,,,,,734,734',
-'734,734,734,734,734,,,734,,,,,,,734,,,734,734,734,734,734,734,734,734',
-'734,734,,734,734,,734,734,734,,,,,,,,,,,,,,,,,,,,734,,,734,,,734,734',
-',,734,,,,,,734,,,,,,,,734,,,,,734,734,734,734,734,734,,,,734,734,740',
-'740,740,,740,,,,740,740,,,,740,,740,740,740,740,740,740,740,,,,,740',
-'740,740,740,740,740,740,,,,,,,,,,740,,,740,740,740,740,740,740,740,740',
-'740,740,,740,740,,740,740,740,,,,,,,,,,,,,,,,,,,,740,,,740,,,740,740',
-',,740,,740,,,,740,,,,,,,,740,,,,,740,740,740,740,740,740,,,,740,740',
-'759,759,759,,759,,,,759,759,,,,759,,759,759,759,759,759,759,759,,,,',
-'759,759,759,759,759,759,759,,,,,,,,,,759,,,759,759,759,759,759,759,759',
-'759,759,759,,759,759,,759,759,759,,,,,,,,,,,,,,,,,,,,759,,,759,,,759',
-'759,,,759,,,,,,759,,,,,,,,759,,,,,759,759,759,759,759,759,,,,759,759',
-'768,768,768,,768,,,,768,768,,,,768,,768,768,768,768,768,768,768,,,,',
-'768,768,768,768,768,768,768,,,,,,,,,,768,,,768,768,768,768,768,768,768',
-'768,768,768,,768,768,,768,768,768,,,,,,,,,,,,,,,,,,,,768,,,768,,,768',
-'768,,,768,,,,,,768,,,,,,,,768,,,,,768,768,768,768,768,768,,,,768,768',
-'769,769,769,,769,,,,769,769,,,,769,,769,769,769,769,769,769,769,,,,',
-'769,769,769,769,769,769,769,,,,,,,,,,769,,,769,769,769,769,769,769,769',
-'769,769,769,,769,769,,,,769,,,,,,,,,,,,,,,,,,,,769,,,769,,,769,769,',
-',769,,769,,769,,,,,,,,,,,,,,,769,769,769,769,769,769,,,,769,769,780',
-'780,780,,780,,,,780,780,,,,780,,780,780,780,780,780,780,780,,,,,780',
-'780,780,780,780,780,780,,,,,,,,,,780,,,780,780,780,780,780,780,780,780',
-'780,780,,780,780,,780,780,780,,,,,,,,,,,,,,,,,,,,780,,,780,,,780,780',
-',,780,,,,,,780,,,,,,,,780,,,,,780,780,780,780,780,780,,,,780,780,786',
-'786,786,,786,,,,786,786,,,,786,,786,786,786,786,786,786,786,,,,,786',
-'786,786,786,786,786,786,,,,,,,,,,786,,,786,786,786,786,786,786,786,786',
-'786,786,,786,786,,786,786,786,,,,,,,,,,,,,,,,,,,,786,,,786,,,786,786',
-',,786,,,,,,786,,,,,,,,786,,,,,786,786,786,786,786,786,,,,786,786,788',
-'788,788,,788,,,,788,788,,,,788,,788,788,788,788,788,788,788,,,,,788',
-'788,788,788,788,788,788,,,,,,,,,,788,,,788,788,788,788,788,788,788,788',
-'788,788,,788,788,,788,788,788,,,,,,,,,,,,,,,,,,,,788,,,788,,,788,788',
-',,788,,,,,,788,,,,,,,,788,,,,,788,788,788,788,788,788,,,,788,788,802',
-'802,802,,802,,,,802,802,,,,802,,802,802,802,802,802,802,802,,,,,802',
-'802,802,802,802,802,802,,,,,,,,,,802,,,802,802,802,802,802,802,802,802',
-'802,802,,802,802,,802,802,802,,,,,,,,,,,,,,,,,,,,802,,,802,,,802,802',
-',,802,,,,,,802,,,,,,,,802,,,,,802,802,802,802,802,802,,,,802,802,820',
-'820,820,,820,,,,820,820,,,,820,,820,820,820,820,820,820,820,,,,,820',
-'820,820,820,820,820,820,,,,,,,,,,820,,,820,820,820,820,820,820,820,820',
-'820,820,,820,820,,,,820,,600,600,600,600,600,600,600,600,600,600,600',
-',600,600,,,600,600,820,,,820,,,820,820,,,820,,,,600,,600,,600,600,600',
-'600,600,600,600,,600,,,820,820,820,820,820,820,,,,820,820,822,822,822',
-'600,822,,,,822,822,,,,822,,822,822,822,822,822,822,822,,,,,822,822,822',
-'822,822,822,822,,,,,,,,,,822,,,822,822,822,822,822,822,822,822,822,822',
-',822,822,,822,822,822,,,,,,,,,,,,,,,,,,,,822,,,822,,,822,822,,,822,',
-'822,,,,822,,,,,,,,822,,,,,822,822,822,822,822,822,,,,822,822,827,827',
-'827,,827,,,,827,827,,,,827,,827,827,827,827,827,827,827,,,,,827,827',
-'827,827,827,827,827,,,,,,,,,,827,,,827,827,827,827,827,827,827,827,827',
-'827,,827,827,,,,827,,388,388,388,388,388,388,388,388,388,388,388,,388',
-'388,,,388,388,827,,,827,,,827,827,,,827,,,,388,,388,,388,388,388,388',
-'388,388,388,,388,,,827,827,827,827,827,827,,,,827,827,832,832,832,388',
-'832,,,,832,832,,,,832,,832,832,832,832,832,832,832,,,,,832,832,832,832',
-'832,832,832,,,,,,,,,,832,,,832,832,832,832,832,832,832,832,832,832,',
-'832,832,,832,832,832,,,,,,,,,,,,,,,,,,,,832,,,832,,,832,832,,,832,,832',
-',832,,832,,,,,,,,832,,,,,832,832,832,832,832,832,,,,832,832,835,835',
-'835,,835,,,,835,835,,,,835,,835,835,835,835,835,835,835,,,,,835,835',
-'835,835,835,835,835,,,,,,,,,,835,,,835,835,835,835,835,835,835,835,835',
-'835,,835,835,,835,835,835,,,,,,,,,,,,,,,,,,,,835,,,835,,,835,835,,,835',
-',835,,835,,835,,,,,,,,835,,,,,835,835,835,835,835,835,,,,835,835,861',
-'861,861,,861,,,,861,861,,,,861,,861,861,861,861,861,861,861,,,,,861',
-'861,861,861,861,861,861,,,,,,,,,,861,,,861,861,861,861,861,861,861,861',
-'861,861,,861,861,,,,861,,237,237,237,237,237,237,237,237,237,237,237',
-',237,237,,,237,237,861,,,861,,,861,861,,,861,,,,237,,237,,237,237,237',
-'237,237,237,237,,237,,,861,861,861,861,861,861,,,,861,861,864,864,864',
-'237,864,,,,864,864,,,,864,,864,864,864,864,864,864,864,,,,,864,864,864',
-'864,864,864,864,,,,,,,,,,864,,,864,864,864,864,864,864,864,864,864,864',
-',864,864,,864,864,864,,,,,,,,,,,,,,,,,,,,864,,,864,,,864,864,,,864,',
-',,,,864,,,,,,,,864,,,,,864,864,864,864,864,864,,,,864,864,867,867,867',
-',867,,,,867,867,,,,867,,867,867,867,867,867,867,867,,,,,867,867,867',
-'867,867,867,867,,,,,,,,,,867,,,867,867,867,867,867,867,867,867,867,867',
-',867,867,,867,867,867,,,,,,,,,,,,,,,,,,,,867,,,867,,,867,867,,,867,',
-',,,,867,,,,,,,,867,,,,,867,867,867,867,867,867,,,,867,867,875,875,875',
-',875,,,,875,875,,,,875,,875,875,875,875,875,875,875,,,,,875,875,875',
-'875,875,875,875,,,,,,,,,,875,,,875,875,875,875,875,875,875,875,875,875',
-',875,875,,,,875,,677,677,677,677,677,677,677,677,677,677,677,,677,677',
-',,677,677,875,,,875,,,875,875,,,875,,,,677,,677,,677,677,677,677,677',
-'677,677,,677,,,875,875,875,875,875,875,,,,875,875,880,880,880,677,880',
-',,,880,880,,,,880,,880,880,880,880,880,880,880,,,,,880,880,880,880,880',
-'880,880,,,,,,,,,,880,,,880,880,880,880,880,880,880,880,880,880,,880',
-'880,,880,880,880,,,,,,,,,,,,,,,,,,,,880,,,880,,,880,880,,,880,,880,',
-'880,,880,,,,,,,,880,,,,,880,880,880,880,880,880,,,,880,880,886,886,886',
-',886,,,,886,886,,,,886,,886,886,886,886,886,886,886,,,,,886,886,886',
-'886,886,886,886,,,,,,,,,,886,,,886,886,886,886,886,886,886,886,886,886',
-',886,886,,,,886,,19,19,19,19,19,19,19,19,19,19,19,,19,19,,,19,19,886',
-',,886,,,886,886,,,886,,,,19,,19,,19,19,19,19,19,19,19,,19,,,886,886',
-'886,886,886,886,,,,886,886,889,889,889,19,889,,,,889,889,,,,889,,889',
-'889,889,889,889,889,889,,,,,889,889,889,889,889,889,889,,,,,,,,,,889',
-',,889,889,889,889,889,889,889,889,889,889,,889,889,,889,889,889,,,,',
-',,,,,,,,,,,,,,,889,,,889,,,889,889,,,889,,,,,,889,,,,,,,,889,,,,,889',
-'889,889,889,889,889,,,,889,889,64,64,64,64,64,64,64,64,64,64,64,64,64',
-'64,64,64,64,64,64,64,64,64,64,64,,,64,64,64,64,64,64,64,64,64,64,,,',
-',,64,64,64,64,64,64,64,64,64,64,64,64,,,,,,,64,64,,64,64,64,64,,64,64',
-',,64,,,,,64,64,64,64,,,,,,64,,,,,,,,64,64,,64,64,64,64,64,64,64,64,64',
-',64,,,64,664,664,664,664,664,664,664,664,664,664,664,664,664,664,664',
-'664,664,664,664,664,664,664,664,664,,,664,664,664,664,664,664,664,664',
-'664,664,,,,,,664,664,664,664,664,664,664,664,,,664,,,,,,,,664,664,,664',
-'664,664,664,,664,664,,,664,,,,,664,664,664,664,,,,,,,,,,,,,,664,664',
-',664,664,664,664,664,664,664,664,664,,664,,,664,581,581,581,581,581',
-'581,581,581,581,581,581,,581,581,,,581,581,,,,581,,,,,,,,,,,581,,581',
-',581,581,581,581,581,581,581,,581,,,,,,,,505,505,,,505,,,,,581,,581',
-'505,505,,505,505,505,505,,505,505,,,505,,,,,505,505,505,505,,,,,,,,',
-',,,,,505,505,,505,505,505,505,505,505,505,505,505,,505,507,507,505,',
-'507,,,,,,,,507,507,,507,507,507,507,,507,507,,,507,,,,,507,507,507,507',
-',,,,,,,,,,,,,507,507,,507,507,507,507,507,507,507,507,507,,507,499,499',
-'507,,499,,,,,,,,499,499,,499,499,499,499,,499,499,,,499,,,,,499,499',
-'499,499,,,,,,,,,,,,,,499,499,,499,499,499,499,499,499,499,499,499,,499',
-'498,498,499,,498,,,,,,,,498,498,,498,498,498,498,,498,498,,,498,,,,',
-'498,498,498,498,,,,,,,,,,,,,,498,498,,498,498,498,498,498,498,498,498',
-'498,,498,466,466,498,,466,,,,,,,,466,466,,466,466,466,466,,466,466,',
-',466,,,,,466,466,466,466,,,,,,,,,,,,,,466,466,,466,466,466,466,466,466',
-'466,466,466,,466,251,251,466,,251,,,,,,,,251,251,,251,251,251,251,,251',
-'251,,,251,,,,,251,251,251,251,,,,,,,,,,,,,,251,251,,251,251,251,251',
-'251,251,251,251,251,,251,252,252,251,,252,,,,,,,,252,252,,252,252,252',
-'252,,252,252,,,252,,,,,252,252,252,252,,,,,,,,,,,,,,252,252,,252,252',
-'252,252,252,252,252,252,252,,252,,,252,423,423,423,423,423,423,423,423',
-'423,423,423,,423,423,,,423,423,,,,,,,,,,,,,,,423,,423,,423,423,423,423',
-'423,423,423,,423,,,,,,,467,467,,,467,,,,,,423,423,467,467,,467,467,467',
-'467,,467,467,,,467,,,,,467,467,467,467,,,,,,,,,,,,,,467,467,,467,467',
-'467,467,467,467,467,467,467,,467,192,192,467,,192,,,,,,,,192,192,,192',
-'192,192,192,,192,192,,,192,,,,,192,192,192,192,,,,,,,,,,,,,,192,192',
-',192,192,192,192,192,192,192,192,192,,192,823,823,192,,823,,,,,,,,823',
-'823,,823,823,823,823,,823,823,,,823,,,,,823,823,823,823,,,,,,,,,,,,',
-',823,823,,823,823,823,823,823,823,823,823,823,,823,458,458,823,,458',
-',,,,,,,458,458,,458,458,458,458,,458,458,,,458,,,,,458,458,458,458,',
-',,,,,,,,,,,,458,458,,458,458,458,458,458,458,458,458,458,,458,824,824',
-'458,,824,,,,,,,,824,824,,824,824,824,824,,824,824,,,824,,,,,824,824',
-'824,824,,,,,,,,,,,,,,824,824,,824,824,824,824,824,824,824,824,824,,824',
-'457,457,824,,457,,,,,,,,457,457,,457,457,457,457,,457,457,,,457,,,,',
-'457,457,457,457,,,,,,,,,,,,,,457,457,,457,457,457,457,457,457,457,457',
-'457,,457,391,391,457,,391,,,,,,,,391,391,,391,391,391,391,,391,391,',
-',391,,,,,391,391,391,391,,,,,,,,,,,,,,391,391,,391,391,391,391,391,391',
-'391,391,391,,391,392,392,391,,392,,,,,,,,392,392,,392,392,392,392,,392',
-'392,,,392,,,,,392,392,392,392,,,,,,,,,,,,,,392,392,,392,392,392,392',
-'392,392,392,392,392,,392,578,578,392,,578,,,,,,,,578,578,,578,578,578',
-'578,,578,578,,,578,,,,,578,578,578,578,,,,,,,,,,,,,,578,578,,578,578',
-'578,578,578,578,578,578,578,,578,193,193,578,,193,,,,,,,,193,193,,193',
-'193,193,193,,193,193,,,193,,,,,193,193,193,193,,,,,,,,,,,,,,193,193',
-',193,193,193,193,193,193,193,193,193,,193,579,579,193,,579,,,,,,,,579',
-'579,,579,579,579,579,,579,579,,,579,,,,,579,579,579,579,,,,,,,,,,,,',
-',579,579,,579,579,579,579,579,579,579,579,579,,579,,,579,480,480,480',
-'480,480,480,480,480,480,480,480,,480,480,,,480,480,,,,,,,,,,,,,,,480',
-',480,,480,480,480,480,480,480,480,,480,,731,731,731,731,731,731,731',
-'731,731,731,731,,731,731,480,480,731,731,,,,,,,,,,,,,,,731,,731,,731',
-'731,731,731,731,731,731,,731,,682,682,682,682,682,682,682,682,682,682',
-'682,,682,682,731,731,682,682,,,,,,,,,,,,,,,682,,682,,682,682,682,682',
-'682,682,682,,682,,,,,,,,,,,,,,,,,682' ]
- racc_action_check = arr = ::Array.new(24362, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_action_pointer = [
- 2597, 995, nil, 191, 885, 4913, 5034, 5155, 604, 516,
- 951, 917, 948, 386, 141, 413, nil, 5268, 5389, 22556,
- 885, nil, 5510, 5631, 5752, 350, 171, 5873, 5994, nil,
- 1255, 6115, 6236, nil, 690, 183, 730, 446, 6357, 6478,
- 6599, 604, 399, nil, nil, nil, nil, nil, nil, nil,
- 291, 3207, 6720, 6841, 6962, 2, 7083, 7204, nil, nil,
- 757, 7325, 7446, 7567, 22797, nil, nil, nil, nil, nil,
- -87, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 7688, nil, nil, nil, 7809, nil, nil, nil,
- nil, nil, nil, nil, nil, 643, nil, 885, nil, nil,
- nil, 7930, 8051, 8172, 8293, 8414, 1036, nil, 593, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 161, nil, 1865, 1987, 8535, 8656,
- 8777, 8898, 23556, 24036, 9019, 9140, 9261, nil, 819, -67,
- 1010, -33, 832, 885, 3085, nil, nil, 9382, 9503, 9624,
- 9745, 9866, 9987, 10108, 10229, 10350, 10471, 10592, 10713, 10834,
- 10955, 11076, 11197, 11318, 11439, 11560, 11681, 11802, 11923, 12044,
- 12165, 12286, 12407, 12528, nil, nil, nil, 21951, nil, 906,
- 919, 12649, nil, 12770, 963, nil, nil, nil, nil, nil,
- nil, 23322, 23382, 955, 12891, 13012, nil, nil, nil, nil,
- nil, nil, nil, 13133, 964, 2963, 979, 991, 953, 13254,
- 2841, 424, 512, 1031, 559, 998, 962, 161, nil, 1000,
- 481, nil, nil, 189, 1024, 1026, 636, nil, 1027, nil,
- 13375, nil, 1087, 1088, 515, nil, 977, -79, 212, 13496,
- 1017, 187, 1001, -38, nil, 571, 10, 31, 13617, 13738,
- 343, 338, 983, 23, 680, 1060, 4, 1100, nil, nil,
- 260, 199, 355, nil, 801, nil, 9, 13859, nil, nil,
- 327, 259, 88, -29, -51, 348, 478, 441, nil, 396,
- nil, 13980, nil, 327, 323, 230, 226, -37, 203, nil,
- 1003, nil, nil, nil, nil, nil, nil, 14101, nil, nil,
- nil, nil, -54, -32, nil, nil, 757, nil, 39, 4792,
- nil, 102, nil, nil, 7568, 180, 179, 134, 14214, nil,
- nil, 107, 191, 0, nil, 14335, 14456, nil, 21588, nil,
- nil, 23856, 23916, 14577, 115, 14698, 14819, 14940, 1987, 1865,
- 358, 355, 248, 261, 273, 289, 2963, 2841, 2719, 1621,
- 1743, 2353, 1499, 1002, 2109, 515, 2475, 2597, 2231, 490,
- 400, 636, 885, 23430, -51, nil, 15061, nil, 15182, 261,
- nil, 15303, 214, nil, nil, 398, nil, nil, 343, 328,
- -63, 364, 466, nil, nil, 15424, -54, 95, 419, nil,
- 432, 404, nil, nil, nil, 464, 15545, 23796, 23676, 888,
- 485, nil, nil, 15666, 15787, 15908, 23262, 23496, 6237, 16029,
- 610, 16150, nil, 502, nil, nil, 16271, nil, nil, 16392,
- 24144, nil, 16513, nil, nil, nil, 4671, 640, nil, nil,
- 4305, 115, 133, 644, 652, 4183, 16634, 16755, 23202, 23142,
- 26, nil, nil, 299, nil, 23022, 16876, 23082, nil, nil,
- 16997, 549, -34, 3573, 1306, nil, nil, nil, -32, nil,
- nil, nil, 741, nil, nil, nil, 551, nil, 147, nil,
- nil, 547, nil, nil, 17118, nil, nil, 17231, 17352, nil,
- 149, 17473, 17594, 602, nil, nil, 17715, 618, nil, 17836,
- 198, 154, 636, 515, 653, 1128, 17957, 18078, nil, 2231,
- 18199, 620, nil, 669, 18320, nil, 671, nil, 667, nil,
- nil, nil, nil, nil, 171, nil, 677, 681, 23976, 24096,
- 18441, 22955, 79, 646, 18562, nil, 694, nil, 2109, 1743,
- nil, -34, nil, 692, 38, 63, 711, 378, 885, 713,
- 21346, 738, 739, -3, 806, nil, 1621, 709, 756, nil,
- nil, 757, 18683, nil, nil, 206, nil, 835, nil, nil,
- nil, nil, nil, 843, nil, 845, 739, 32, 18804, 776,
- 1, -18, 25, 75, 18925, 401, 407, nil, 785, 4061,
- 548, nil, nil, 871, 3939, 460, 547, 758, 766, 770,
- nil, nil, nil, nil, nil, 768, nil, nil, nil, nil,
- 850, nil, nil, 860, 22907, 823, nil, nil, nil, nil,
- nil, 3451, nil, nil, nil, nil, nil, 22314, 793, 19046,
- 19167, nil, 24236, nil, 7447, nil, nil, 13255, nil, 7326,
- 19288, 19409, 19530, 70, 19652, nil, 834, 1128, 19651, nil,
- 871, 973, 867, nil, 19772, 869, 2475, nil, nil, 916,
- 917, -45, 978, 19893, nil, 20014, 888, nil, 930, 909,
- 1011, 353, nil, nil, 2353, nil, nil, 11, 20135, nil,
- nil, 24190, 1021, nil, 20256, 1022, 1499, 1377, nil, nil,
- 20377, 4549, nil, -9, 68, nil, 1042, nil, 4427, nil,
- 1084, 983, nil, 1428, nil, 197, nil, nil, 444, 20498,
- nil, nil, nil, nil, 811, nil, nil, 20136, 20619, 20740,
- 760, 882, 244, 295, 248, 281, nil, nil, nil, nil,
- 20861, nil, 385, 473, 448, nil, 20982, 473, 21103, nil,
- nil, nil, nil, nil, 3817, nil, nil, nil, -7, nil,
- 624, 626, 21224, 413, nil, nil, 653, nil, 575, 552,
- 554, nil, nil, 555, 563, nil, nil, 1019, nil, nil,
- 21345, 1006, 21466, 23616, 23736, 639, 673, 21587, 6116, nil,
- nil, nil, 21708, 748, nil, 21829, 815, 938, 3695, nil,
- nil, nil, nil, nil, nil, 3329, nil, nil, -38, nil,
- nil, nil, 2719, nil, 884, 916, 930, 160, 388, 375,
- 757, 21950, nil, nil, 22071, 470, nil, 22192, nil, nil,
- 515, 698, 619, 772, 770, 22313, 633, nil, 294, nil,
- 22434, -98, nil, nil, nil, nil, 22555, nil, nil, 22676,
- nil, nil, 482, nil ]
-
-racc_action_default = [
- -4, -497, -1, -485, -5, -497, -497, -497, -497, -497,
- -497, -497, -497, -497, -271, -32, -33, -497, -497, -38,
- -40, -41, -282, -315, -316, -45, -249, -361, -285, -58,
- -4, -62, -67, -68, -497, -428, -497, -497, -497, -497,
- -497, -487, -214, -264, -265, -266, -267, -268, -269, -270,
- -475, -4, -497, -496, -467, -288, -497, -497, -292, -295,
- -485, -497, -497, -497, -497, -317, -318, -381, -382, -383,
- -384, -385, -399, -388, -401, -401, -392, -397, -411, -401,
- -413, -414, -417, -418, -419, -420, -421, -422, -423, -424,
- -425, -426, -427, -430, -431, -497, -3, -486, -492, -493,
- -494, -497, -497, -497, -497, -497, -6, -8, -497, -93,
- -94, -95, -96, -97, -98, -99, -100, -101, -105, -106,
- -107, -108, -109, -110, -111, -112, -113, -114, -115, -116,
- -117, -118, -119, -120, -121, -122, -123, -124, -125, -126,
- -127, -128, -129, -130, -131, -132, -133, -134, -135, -136,
- -137, -138, -139, -140, -141, -142, -143, -144, -145, -146,
- -147, -148, -149, -150, -151, -152, -153, -154, -155, -156,
- -157, -158, -159, -160, -161, -162, -163, -164, -165, -166,
- -167, -168, -169, -170, -13, -102, -4, -4, -497, -497,
- -497, -496, -497, -497, -497, -497, -497, -36, -497, -428,
- -497, -271, -497, -497, -4, -37, -206, -497, -497, -497,
- -497, -497, -497, -497, -497, -497, -497, -497, -497, -497,
- -497, -497, -497, -497, -497, -497, -497, -497, -497, -497,
- -497, -497, -497, -497, -351, -353, -42, -215, -228, -258,
- -258, -497, -236, -497, -259, -282, -315, -316, -470, -43,
- -44, -497, -497, -50, -496, -497, -287, -356, -362, -364,
- -56, -360, -57, -497, -58, -4, -497, -497, -63, -65,
- -4, -72, -497, -497, -79, -285, -487, -497, -319, -361,
- -497, -66, -70, -278, -415, -416, -497, -191, -192, -207,
- -497, -488, -373, -497, -274, -216, -487, -489, -489, -497,
- -497, -489, -497, -489, -289, -39, -497, -497, -497, -497,
- -485, -497, -486, -428, -497, -497, -271, -497, -331, -332,
- -88, -89, -497, -91, -497, -271, -497, -497, -428, -308,
- -93, -94, -131, -132, -148, -153, -160, -163, -310, -497,
- -465, -497, -386, -497, -497, -497, -497, -497, -497, 894,
- -7, -495, -14, -15, -16, -17, -18, -497, -10, -11,
- -12, -103, -497, -497, -21, -29, -171, -259, -497, -497,
- -22, -30, -31, -23, -173, -497, -476, -477, -226, -478,
- -479, -476, -249, -477, -359, -481, -482, -28, -180, -34,
- -35, -497, -497, -496, -278, -497, -497, -497, -181, -182,
- -183, -184, -185, -186, -187, -188, -193, -194, -195, -196,
- -197, -198, -199, -200, -201, -202, -203, -204, -205, -208,
- -209, -210, -211, -497, -347, -229, -497, -231, -497, -258,
- -256, -497, -249, -476, -477, -249, -48, -51, -497, -487,
- -487, -258, -228, -250, -251, -252, -347, -347, -497, -284,
- -497, -59, -276, -71, -64, -497, -496, -497, -497, -78,
- -497, -415, -416, -497, -497, -497, -497, -497, -212, -497,
- -496, -496, -273, -487, -217, -218, -491, -490, -220, -491,
- -487, -280, -491, -469, -281, -468, -4, -320, -321, -322,
- -4, -497, -497, -497, -497, -4, -497, -496, -497, -497,
- -278, -301, -88, -89, -90, -497, -496, -497, -304, -432,
- -497, -497, -497, -4, -445, -312, -483, -484, -487, -387,
- -400, -403, -497, -405, -389, -402, -497, -391, -497, -394,
- -396, -497, -412, -9, -497, -19, -20, -497, -497, -263,
- -279, -497, -497, -52, -227, -357, -497, -54, -358, -497,
- -476, -477, -480, -277, -497, -171, -497, -497, -349, -4,
- -497, -258, -257, -260, -497, -471, -497, -235, -497, -472,
- -46, -354, -47, -355, -347, -222, -497, -497, -497, -497,
- -497, -38, -497, -258, -497, -248, -497, -254, -4, -4,
- -283, -59, -69, -497, -476, -477, -226, -75, -77, -497,
- -179, -189, -190, -497, -496, -329, -4, -374, -496, -375,
- -376, -497, -497, -260, -221, -496, -323, -496, -293, -324,
- -325, -326, -296, -497, -299, -497, -367, -497, -497, -497,
- -476, -477, -480, -277, -497, -88, -89, -92, -497, -4,
- -497, -434, -306, -497, -4, -445, -497, -464, -464, -464,
- -444, -446, -447, -448, -449, -450, -451, -454, -456, -457,
- -459, -460, -461, -497, -497, -497, -404, -407, -408, -409,
- -410, -4, -390, -393, -395, -398, -104, -172, -261, -497,
- -497, -25, -175, -26, -176, -53, -27, -177, -55, -178,
- -497, -497, -497, -279, -213, -333, -335, -345, -497, -348,
- -497, -497, -258, -233, -497, -258, -4, -223, -224, -226,
- -226, -487, -497, -497, -241, -497, -258, -253, -497, -497,
- -497, -73, -286, -2, -4, -380, -330, -497, -497, -378,
- -275, -487, -497, -327, -497, -497, -4, -4, -298, -300,
- -497, -4, -369, -279, -497, -279, -497, -433, -4, -309,
- -497, -487, -436, -497, -440, -497, -442, -443, -497, -497,
- -458, -462, -313, -466, -497, -262, -24, -174, -497, -336,
- -80, -497, -497, -87, -344, -497, -346, -350, -352, -230,
- -497, -232, -497, -497, -258, -238, -497, -258, -497, -247,
- -255, -363, -365, -379, -4, -377, -219, -290, -497, -291,
- -497, -497, -497, -496, -302, -305, -497, -311, -497, -464,
- -464, -452, -463, -464, -497, -455, -453, -445, -406, -334,
- -497, -341, -496, -497, -497, -86, -497, -497, -258, -49,
- -225, -237, -497, -258, -243, -497, -258, -373, -4, -294,
- -297, -368, -366, -370, -371, -4, -307, -435, -497, -438,
- -439, -441, -4, -337, -340, -497, -497, -82, -84, -83,
- -85, -497, -343, -234, -497, -258, -239, -497, -242, -372,
- -496, -497, -464, -497, -497, -497, -81, -342, -258, -244,
- -497, -258, -328, -303, -437, -314, -497, -339, -240, -497,
- -245, -338, -258, -246 ]
-
-clist = [
-'35,300,306,307,268,35,310,338,494,470,440,278,278,107,185,10,96,650',
-'117,117,10,565,293,437,115,115,644,240,240,240,35,271,271,112,112,604',
-'100,732,257,261,205,278,278,278,281,10,504,352,353,354,355,35,365,372',
-'238,238,238,618,622,303,438,313,328,328,328,106,10,266,242,242,242,264',
-'565,311,571,309,318,573,754,756,757,559,810,815,813,296,520,737,197',
-'529,634,112,845,100,486,490,639,35,236,249,250,344,345,588,589,35,348',
-'475,478,326,329,483,10,485,748,513,514,239,239,239,10,290,664,294,817',
-'378,382,305,305,696,700,305,424,446,447,627,842,427,608,375,727,342',
-'343,346,528,347,666,671,650,301,751,809,811,723,574,534,1,350,357,319',
-'184,587,443,586,718,356,253,260,262,340,302,304,305,305,305,305,815',
-'872,97,317,508,339,735,515,432,435,35,35,473,308,623,736,,,,,,,,,,10',
-'10,,35,,,,,,364,370,373,,,,387,,,10,386,,,296,,,,,,637,,706,,,,,,,,',
-'849,850,,,851,,,,,278,,,,,491,492,,,,240,240,,,,,35,389,390,240,271',
-'35,674,,,,,605,610,,,10,454,,368,368,10,442,238,,257,,261,882,,,238',
-',565,,,242,242,450,884,,,264,455,565,242,804,264,,685,,,,688,,,650,',
-',493,378,382,567,,,852,439,444,,,,609,711,,,448,,554,,100,,,,,,441,239',
-'571,573,,,,460,,239,509,,,,,533,,,,843,117,,,,,,115,474,,,305,305,,',
-',112,,,,,,,599,2,,548,,,,512,,599,,,,593,,,,,,725,,518,,729,741,,,,386',
-',605,267,605,,296,,,565,,,561,599,,,,,,599,,,,,,,629,13,,,,583,13,,',
-'638,,640,,703,,,,,198,198,,,,198,198,198,,,565,,,13,272,272,,714,,,',
-'643,386,35,,296,,35,585,,,386,35,,13,198,198,844,10,198,198,,10,198',
-'314,324,324,10,709,710,35,,794,294,,543,576,577,,547,,619,619,386,,10',
-'296,695,,386,,,,,278,296,,603,676,,13,641,642,117,198,198,198,198,13',
-'115,611,869,,,271,,35,614,112,,681,683,,368,,686,,,,570,,10,572,,,362',
-'363,744,305,,,,561,838,,35,35,,626,,,,,267,,665,779,,,781,10,10,,35',
-'762,,605,746,548,712,789,,750,,,,,,10,,,,,,,,,,,13,13,198,198,198,198',
-',35,198,198,198,,35,,,,,,13,,,,10,,,267,,10,,,267,,,,,,,,,35,,747,,',
-'605,278,278,752,798,831,,,834,,10,,,,,112,,,,,,770,770,,198,198,766',
-',,305,35,,278,198,,13,774,776,,272,13,,787,806,,10,,,35,863,,,770,,866',
-',,868,,,35,35,,10,,35,819,795,,,,,35,278,,10,10,,198,198,10,599,,785',
-',,879,10,,,,14,,271,856,,14,198,,888,,619,890,,,,,,,,,198,,893,,783',
-',,35,,,14,274,274,278,278,,,,305,,278,784,10,,796,,,,,,,14,,770,770',
-',873,,,,770,316,325,325,808,,,,853,854,865,35,198,,278,862,,,35,,,,',
-',386,35,10,296,278,,,,,10,770,,,14,,278,10,,,,,14,,,770,877,,615,,,',
-'617,,,,770,625,,,887,198,,,,,,,,,,891,198,,,,,,,,,,,,,198,,,,,,,,,,',
-',,,,,,13,,,,13,,,,,13,,198,,,,,,,,701,198,14,14,,198,,,13,,,,,,,,,,',
-',14,,,,,,,,,719,720,,,,,,198,198,,,,198,,,,,,726,,,,,272,,13,,,,,,,',
-',,,,,,,,,,,,,198,,,,,,14,,13,13,274,14,,,,,,,,,,,,,,,13,,,,,,,,,,,764',
-',,,,,,,,,,,,,,,,198,,,,,13,,,,,13,,,,,,,,782,,,,,,,,,,,,,,,,,,793,13',
-',,,,,,,,198,,800,801,,,,803,,,,,,,,,,771,771,,,,,,,,13,,,,,,,,,,,,,',
-',,,,13,,,,771,,,,,,198,,13,13,,,837,13,,,,,,,13,,,,,,,,,,,,,,,,,,,,',
-'272,,,,,,,,,,,,,,,870,,,,,,,871,,,13,,,,,,,,,,,,,14,,,,14,,,,,14,,,',
-'771,771,198,,,,,771,,,,,,,14,,,,13,,,,12,670,,13,,12,,,,,13,,,,,,,,',
-'771,,,,,,,,,,,12,,,771,,,274,,14,,,,,,771,,,,,,,12,,,,,,,,,,,,,,,,14',
-'14,,,,,,,,,,,,,,,,,14,,,,,,,,,,,,12,,,,,,,,12,,,,,,,,,,,,,14,,,,,14',
-',,,,,,,,,,,,,,,,,,,,,,,,,,14,,,,,,,,,,,,,,,,,,,,,,,,,,773,773,,,,,,',
-',14,12,12,206,,,,237,237,237,,,,,,,,,14,12,,,773,287,288,289,,,,,14',
-'14,,,,14,,,237,237,,,14,,,,,,,,,,,,,,,,,,,,,274,,,,,,,,,,,,,,,,,12,',
-',,,12,,,14,,,,,,,,,,,,,,,,,,,,,,,,,,773,773,,,,,,773,,,,,,,,,,,14,,',
-',,,,14,,,,,,,14,,,,,,,,,773,,,,,,,,,,,,,,773,,,,366,237,374,237,,,388',
-'773,,,,,,,,,,,,206,398,399,400,401,402,403,404,405,406,407,408,409,410',
-'411,412,413,414,415,416,417,418,419,420,421,422,423,,,,,,,,237,,237',
-',,,,,,,,,,237,237,,,,,,,,237,,,,,,,,,,,,,,,,,,,,,,,,,,,468,,,,,,,,,480',
-',,,,,,,,,,,,,,,,12,,,,12,,,,,12,,,,,,,,,,,,,,,,,,12,,,,,,,,,,,,,,,,',
-',,,,,,,,,237,367,371,,,,,,,,,,,,,,,,,,12,,,,237,,388,555,374,,,,,,,',
-',,,,,,,,,,,,,12,12,,,,429,,430,237,,237,,,237,,,,,12,,,,,,,,,581,,,',
-',,,,,,,237,,,,,,,600,601,602,,,,12,,237,,,12,,237,,,237,,,237,,,,,,',
-',,,,,,,237,237,,,,12,,,,,237,,,,,,,,,,,,,,,,,,,,,,,,,,,,,26,12,677,237',
-',26,682,684,,,,687,,,689,,539,26,26,12,,694,26,26,26,237,,,,237,26,12',
-'12,,,,12,,,,,,,12,,237,,,,237,,26,26,26,,,26,26,,,26,,,,,,,,,,,,,563',
-',566,,731,569,,,,,,,,,,,12,,,582,237,,,,26,,,,26,26,26,26,26,,,,,,,',
-',,,,,607,,,,,613,,,566,,,613,,,,12,,,,,,,12,,,367,237,767,,12,,,,,,',
-',682,684,687,,,,,,,,,,,,237,,,,,,,,,237,,237,,,,,678,26,26,26,26,26',
-'26,,,26,26,26,,,,,,,,26,237,,702,,,,705,,,,,,,,,,,,,237,,,563,,,,716',
-',767,,,,,,,,,,,,828,,,,,,237,,237,26,26,,,,,,,,26,,26,,237,,,26,,,,',
-'742,,,,,,,,,,,,237,,,,,,,,,,237,,,237,,,,,,,,26,26,,,,,,,,,,,,,,,,,765',
-'26,,237,,,237,,,,,,,,,26,,,,237,,,,,,566,,,237,,,,,,,,566,,,,,,,,,,',
-',,,,,,,,,,,,,,613,,,,,,26,,,,,,,,,,,,,816,,,,,,,,,,,,,,,,,,,,,,,,,,',
-'833,,836,,,,,,,,,,26,,,,841,,,,,,,26,,,,,,,,,,,,,26,,,,,,,,,,563,,,566',
-',,,26,,,,26,,,,,26,,26,,,,,,,,,26,,,,26,878,,26,881,,,,,,,,,,,,,566',
-',,,,,,,,892,,,,,26,26,,,,26,,,,,,,,,,,,,26,,,,,,,,,,,,,,,,,,,,,26,,',
-',,,,,26,26,,,,,,,,,,,,,,,,,26,,,,,,,,,,,,,,,,,,,,,,,,,,,,26,,,,,26,',
-',,,26,,,,,,,,,,,,,,,,,,,,,,,,,,,26,,,,,,,,,26,,,,,,,,,,,,,,,,,,,,,,',
-',,,26,,,,,,,,,,,,,,,,,,26,,,,,,,,,,26,,26,26,,,,26,,,,,,,26,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,26,,,,,,,,,,,,,,,,,,,,,,,,,,,,26',
-',,,,,,,,,,,,,,,26,,,,,,,26,,,,,,,26' ]
- racc_goto_table = arr = ::Array.new(2846, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'41,19,13,13,39,41,13,44,79,4,29,52,52,11,11,14,8,126,49,49,14,131,3',
-'32,48,48,83,56,56,56,41,41,41,45,45,5,82,77,57,57,15,52,52,52,40,14',
-'42,13,13,13,13,41,21,21,26,26,26,78,78,56,53,41,41,41,41,9,14,37,60',
-'60,60,36,131,8,58,89,14,58,125,125,125,33,124,128,124,26,117,90,23,117',
-'91,45,92,82,76,76,93,41,28,28,28,114,114,33,33,41,114,55,55,43,43,55',
-'14,55,94,95,96,54,54,54,14,51,97,23,98,30,30,23,23,99,100,23,102,104',
-'105,106,107,59,108,19,109,112,113,115,116,118,119,120,126,54,121,123',
-'127,6,34,50,1,9,24,16,12,61,62,64,65,9,31,31,31,72,73,74,23,23,23,23',
-'128,124,10,80,81,84,5,85,30,30,41,41,86,87,79,88,,,,,,,,,,14,14,,41',
-',,,,,15,15,15,,,,15,,,14,45,,,26,,,,,,42,,33,,,,,,,,,125,125,,,125,',
-',,,52,,,,,13,13,,,,56,56,,,,,41,23,23,56,41,41,117,,,,,53,53,,,14,40',
-',54,54,14,26,26,,57,,57,77,,,26,,131,,,60,60,37,125,,,36,37,131,60,78',
-'36,,32,,,,32,,,126,,,8,30,30,59,,,83,28,28,,,,21,29,,,28,,19,,82,,,',
-',,54,54,58,58,,,,51,,54,82,,,,,11,,,,5,49,,,,,,48,51,,,23,23,,,,45,',
-',,,,,30,2,,57,,,,23,,30,,,,19,,,,,,53,,23,,53,76,,,,45,,53,2,53,,26',
-',,131,,,56,30,,,,,,30,,,,,,,19,18,,,,56,18,,,19,,13,,59,,,,,18,18,,',
-',18,18,18,,,131,,,18,18,18,,59,,,,3,45,41,,26,,41,60,,,45,41,,18,18',
-'18,79,14,18,18,,14,18,18,18,18,14,30,30,41,,76,23,,31,51,51,,31,,82',
-'82,45,,14,26,39,,45,,,,,52,26,,23,11,,18,82,82,49,18,18,18,18,18,48',
-'51,4,,,41,,41,51,45,,15,15,,54,,15,,,,31,,14,31,,,2,2,13,23,,,,56,76',
-',41,41,,54,,,,,2,,51,59,,,59,14,14,,41,44,,53,3,57,26,59,,3,,,,,,14',
-',,,,,,,,,,18,18,18,18,18,18,,41,18,18,18,,41,,,,,,18,,,,14,,,2,,14,',
-',2,,,,,,,,,41,,82,,,53,52,52,82,13,59,,,59,,14,,,,,45,,,,,,41,41,,18',
-'18,15,,,23,41,,52,18,,18,14,14,,18,18,,56,3,,14,,,41,59,,,41,,59,,,59',
-',,41,41,,14,,41,39,14,,,,,41,52,,14,14,,18,18,14,30,,60,,,59,14,,,,20',
-',41,19,,20,18,,59,,82,59,,,,,,,,,18,,59,,51,,,41,,,20,20,20,52,52,,',
-',23,,52,54,14,,51,,,,,,,20,,41,41,,3,,,,41,20,20,20,51,,,,14,14,56,41',
-'18,,52,14,,,41,,,,,,45,41,14,26,52,,,,,14,41,,,20,,52,14,,,,,20,,,41',
-'14,,2,,,,2,,,,41,2,,,14,18,,,,,,,,,,14,18,,,,,,,,,,,,,18,,,,,,,,,,,',
-',,,,,18,,,,18,,,,,18,,18,,,,,,,,2,18,20,20,,18,,,18,,,,,,,,,,,,20,,',
-',,,,,,2,2,,,,,,18,18,,,,18,,,,,,2,,,,,18,,18,,,,,,,,,,,,,,,,,,,,,18',
-',,,,,20,,18,18,20,20,,,,,,,,,,,,,,,18,,,,,,,,,,,2,,,,,,,,,,,,,,,,,18',
-',,,,18,,,,,18,,,,,,,,2,,,,,,,,,,,,,,,,,,2,18,,,,,,,,,18,,2,2,,,,2,,',
-',,,,,,,18,18,,,,,,,,18,,,,,,,,,,,,,,,,,,18,,,,18,,,,,,18,,18,18,,,2',
-'18,,,,,,,18,,,,,,,,,,,,,,,,,,,,,18,,,,,,,,,,,,,,,2,,,,,,,2,,,18,,,,',
-',,,,,,,,20,,,,20,,,,,20,,,,18,18,18,,,,,18,,,,,,,20,,,,18,,,,17,20,',
-'18,,17,,,,,18,,,,,,,,,18,,,,,,,,,,,17,,,18,,,20,,20,,,,,,18,,,,,,,17',
-',,,,,,,,,,,,,,,20,20,,,,,,,,,,,,,,,,,20,,,,,,,,,,,,17,,,,,,,,17,,,,',
-',,,,,,,,20,,,,,20,,,,,,,,,,,,,,,,,,,,,,,,,,,20,,,,,,,,,,,,,,,,,,,,,',
-',,,,20,20,,,,,,,,20,17,17,25,,,,25,25,25,,,,,,,,,20,17,,,20,25,25,25',
-',,,,20,20,,,,20,,,25,25,,,20,,,,,,,,,,,,,,,,,,,,,20,,,,,,,,,,,,,,,,',
-'17,,,,,17,,,20,,,,,,,,,,,,,,,,,,,,,,,,,,20,20,,,,,,20,,,,,,,,,,,20,',
-',,,,,20,,,,,,,20,,,,,,,,,20,,,,,,,,,,,,,,20,,,,25,25,25,25,,,25,20,',
-',,,,,,,,,,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25',
-'25,25,25,25,25,25,25,,,,,,,,25,,25,,,,,,,,,,,25,25,,,,,,,,25,,,,,,,',
-',,,,,,,,,,,,,,,,,,,25,,,,,,,,,25,,,,,,,,,,,,,,,,,17,,,,17,,,,,17,,,',
-',,,,,,,,,,,,,,17,,,,,,,,,,,,,,,,,,,,,,,,,,25,22,22,,,,,,,,,,,,,,,,,',
-'17,,,,25,,25,25,25,,,,,,,,,,,,,,,,,,,,,17,17,,,,22,,22,25,,25,,,25,',
-',,,17,,,,,,,,,25,,,,,,,,,,,25,,,,,,,25,25,25,,,,17,,25,,,17,,25,,,25',
-',,25,,,,,,,,,,,,,,25,25,,,,17,,,,,25,,,,,,,,,,,,,,,,,,,,,,,,,,,,,35',
-'17,25,25,,35,25,25,,,,25,,,25,,22,35,35,17,,25,35,35,35,25,,,,25,35',
-'17,17,,,,17,,,,,,,17,,25,,,,25,,35,35,35,,,35,35,,,35,,,,,,,,,,,,,22',
-',22,,25,22,,,,,,,,,,,17,,,22,25,,,,35,,,,35,35,35,35,35,,,,,,,,,,,,',
-'22,,,,,22,,,22,,,22,,,,17,,,,,,,17,,,22,25,25,,17,,,,,,,,25,25,25,,',
-',,,,,,,,,25,,,,,,,,,25,,25,,,,,22,35,35,35,35,35,35,,,35,35,35,,,,,',
-',,35,25,,22,,,,22,,,,,,,,,,,,,25,,,22,,,,22,,25,,,,,,,,,,,,25,,,,,,25',
-',25,35,35,,,,,,,,35,,35,,25,,,35,,,,,22,,,,,,,,,,,,25,,,,,,,,,,25,,',
-'25,,,,,,,,35,35,,,,,,,,,,,,,,,,,22,35,,25,,,25,,,,,,,,,35,,,,25,,,,',
-',22,,,25,,,,,,,,22,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,35,,,,,,,,,,,,,22',
-',,,,,,,,,,,,,,,,,,,,,,,,,,22,,22,,,,,,,,,,35,,,,22,,,,,,,35,,,,,,,,',
-',,,,35,,,,,,,,,,22,,,22,,,,35,,,,35,,,,,35,,35,,,,,,,,,35,,,,35,22,',
-'35,22,,,,,,,,,,,,,22,,,,,,,,,22,,,,,35,35,,,,35,,,,,,,,,,,,,35,,,,,',
-',,,,,,,,,,,,,,,35,,,,,,,,35,35,,,,,,,,,,,,,,,,,35,,,,,,,,,,,,,,,,,,',
-',,,,,,,,,35,,,,,35,,,,,35,,,,,,,,,,,,,,,,,,,,,,,,,,,35,,,,,,,,,35,,',
-',,,,,,,,,,,,,,,,,,,,,,,35,,,,,,,,,,,,,,,,,,35,,,,,,,,,,35,,35,35,,,',
-'35,,,,,,,35,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,35,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,35,,,,,,,,,,,,,,,,35,,,,,,,35,,,,,,,35' ]
- racc_goto_check = arr = ::Array.new(2846, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_goto_pointer = [
- nil, 156, 392, -29, -283, -435, -451, nil, 13, 60,
- 175, 7, 153, -54, 15, 22, 98, 1288, 446, -52,
- 767, -136, 1640, 71, 51, 1458, 32, nil, 76, -244,
- -67, 140, -230, -343, -282, 1993, 41, 37, nil, -27,
- 12, 0, -276, 47, -57, 27, nil, nil, 18, 12,
- -206, 80, -20, -194, 95, -190, 5, 12, -358, -103,
- 46, -284, -93, nil, -282, -423, nil, nil, nil, nil,
- nil, nil, 105, 116, 116, nil, -212, -578, -434, -303,
- 118, -146, 33, -488, 117, -156, -106, 131, -427, 16,
- -535, -411, -712, -412, -528, -214, -222, -393, -638, -428,
- -427, nil, -102, nil, -125, -125, -361, -667, -333, -468,
- nil, nil, 71, 70, 27, 67, -202, -257, 68, -376,
- -376, -495, nil, -602, -671, -569, -497, -601, -672, nil,
- nil, -407 ]
-
-racc_goto_default = [
- nil, nil, 292, nil, nil, 733, nil, 3, nil, 4,
- 312, nil, nil, nil, 202, 16, 11, 203, 286, nil,
- 201, nil, 244, 15, nil, 19, 20, 21, nil, 25,
- 596, nil, nil, nil, nil, 277, 29, nil, 31, 34,
- 33, 199, 323, nil, 114, 380, 113, 116, 68, 69,
- nil, nil, 42, 295, 297, nil, 298, 544, 545, 425,
- 562, nil, nil, 255, nil, nil, 43, 44, 45, 46,
- 47, 48, 49, nil, 256, 55, nil, nil, nil, nil,
- nil, nil, 487, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 235, nil, 384, nil, nil, nil, nil, nil, nil,
- 67, 70, 71, nil, nil, nil, nil, 525, nil, nil,
- nil, 646, 647, 648, 649, nil, 812, 656, 657, 660,
- 663, 248 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 133, :_reduce_1,
- 4, 135, :_reduce_2,
- 2, 134, :_reduce_3,
- 0, 139, :_reduce_4,
- 1, 139, :_reduce_5,
- 2, 139, :_reduce_6,
- 3, 139, :_reduce_7,
- 0, 156, :_reduce_8,
- 4, 141, :_reduce_9,
- 3, 141, :_reduce_10,
- 3, 141, :_reduce_11,
- 3, 141, :_reduce_12,
- 2, 141, :_reduce_13,
- 3, 141, :_reduce_14,
- 3, 141, :_reduce_15,
- 3, 141, :_reduce_16,
- 3, 141, :_reduce_17,
- 3, 141, :_reduce_18,
- 4, 141, :_reduce_19,
- 4, 141, :_reduce_20,
- 3, 141, :_reduce_21,
- 3, 141, :_reduce_22,
- 3, 141, :_reduce_23,
- 6, 141, :_reduce_24,
- 5, 141, :_reduce_25,
- 5, 141, :_reduce_26,
- 5, 141, :_reduce_27,
- 3, 141, :_reduce_28,
- 3, 141, :_reduce_29,
- 3, 141, :_reduce_30,
- 3, 141, :_reduce_31,
- 1, 141, :_reduce_none,
- 1, 155, :_reduce_none,
- 3, 155, :_reduce_34,
- 3, 155, :_reduce_35,
- 2, 155, :_reduce_36,
- 2, 155, :_reduce_37,
- 1, 155, :_reduce_none,
- 1, 145, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 2, 147, :_reduce_42,
- 2, 147, :_reduce_43,
- 2, 147, :_reduce_44,
- 1, 159, :_reduce_none,
- 4, 159, :_reduce_46,
- 4, 159, :_reduce_47,
- 0, 166, :_reduce_48,
- 5, 164, :_reduce_49,
- 2, 158, :_reduce_50,
- 3, 158, :_reduce_51,
- 4, 158, :_reduce_52,
- 5, 158, :_reduce_53,
- 4, 158, :_reduce_54,
- 5, 158, :_reduce_55,
- 2, 158, :_reduce_56,
- 2, 158, :_reduce_57,
- 1, 148, :_reduce_58,
- 3, 148, :_reduce_59,
- 1, 169, :_reduce_60,
- 3, 169, :_reduce_61,
- 1, 168, :_reduce_62,
- 2, 168, :_reduce_63,
- 3, 168, :_reduce_64,
- 2, 168, :_reduce_65,
- 2, 168, :_reduce_66,
- 1, 168, :_reduce_67,
- 1, 171, :_reduce_none,
- 3, 171, :_reduce_69,
- 2, 170, :_reduce_70,
- 3, 170, :_reduce_71,
- 1, 172, :_reduce_72,
- 4, 172, :_reduce_73,
- 3, 172, :_reduce_74,
- 3, 172, :_reduce_75,
- 3, 172, :_reduce_76,
- 3, 172, :_reduce_77,
- 2, 172, :_reduce_78,
- 1, 172, :_reduce_79,
- 1, 146, :_reduce_80,
- 4, 146, :_reduce_81,
- 3, 146, :_reduce_82,
- 3, 146, :_reduce_83,
- 3, 146, :_reduce_84,
- 3, 146, :_reduce_85,
- 2, 146, :_reduce_86,
- 1, 146, :_reduce_87,
- 1, 174, :_reduce_88,
- 1, 174, :_reduce_none,
- 2, 175, :_reduce_90,
- 1, 175, :_reduce_91,
- 3, 175, :_reduce_92,
- 1, 176, :_reduce_none,
- 1, 176, :_reduce_none,
- 1, 176, :_reduce_none,
- 1, 176, :_reduce_none,
- 1, 176, :_reduce_none,
- 1, 179, :_reduce_98,
- 1, 179, :_reduce_none,
- 1, 143, :_reduce_none,
- 1, 143, :_reduce_none,
- 1, 144, :_reduce_102,
- 0, 182, :_reduce_103,
- 4, 144, :_reduce_104,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 177, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 1, 178, :_reduce_none,
- 3, 157, :_reduce_171,
- 5, 157, :_reduce_172,
- 3, 157, :_reduce_173,
- 6, 157, :_reduce_174,
- 5, 157, :_reduce_175,
- 5, 157, :_reduce_176,
- 5, 157, :_reduce_177,
- 5, 157, :_reduce_178,
- 4, 157, :_reduce_179,
- 3, 157, :_reduce_180,
- 3, 157, :_reduce_181,
- 3, 157, :_reduce_182,
- 3, 157, :_reduce_183,
- 3, 157, :_reduce_184,
- 3, 157, :_reduce_185,
- 3, 157, :_reduce_186,
- 3, 157, :_reduce_187,
- 3, 157, :_reduce_188,
- 4, 157, :_reduce_189,
- 4, 157, :_reduce_190,
- 2, 157, :_reduce_191,
- 2, 157, :_reduce_192,
- 3, 157, :_reduce_193,
- 3, 157, :_reduce_194,
- 3, 157, :_reduce_195,
- 3, 157, :_reduce_196,
- 3, 157, :_reduce_197,
- 3, 157, :_reduce_198,
- 3, 157, :_reduce_199,
- 3, 157, :_reduce_200,
- 3, 157, :_reduce_201,
- 3, 157, :_reduce_202,
- 3, 157, :_reduce_203,
- 3, 157, :_reduce_204,
- 3, 157, :_reduce_205,
- 2, 157, :_reduce_206,
- 2, 157, :_reduce_207,
- 3, 157, :_reduce_208,
- 3, 157, :_reduce_209,
- 3, 157, :_reduce_210,
- 3, 157, :_reduce_211,
- 3, 157, :_reduce_212,
- 5, 157, :_reduce_213,
- 1, 157, :_reduce_none,
- 1, 154, :_reduce_none,
- 1, 151, :_reduce_none,
- 2, 151, :_reduce_217,
- 2, 151, :_reduce_218,
- 5, 151, :_reduce_219,
- 2, 151, :_reduce_220,
- 3, 151, :_reduce_221,
- 3, 189, :_reduce_222,
- 4, 189, :_reduce_223,
- 4, 189, :_reduce_224,
- 6, 189, :_reduce_225,
- 0, 190, :_reduce_226,
- 1, 190, :_reduce_none,
- 1, 160, :_reduce_228,
- 2, 160, :_reduce_229,
- 5, 160, :_reduce_230,
- 2, 160, :_reduce_231,
- 5, 160, :_reduce_232,
- 4, 160, :_reduce_233,
- 7, 160, :_reduce_234,
- 3, 160, :_reduce_235,
- 1, 160, :_reduce_236,
- 4, 193, :_reduce_237,
- 3, 193, :_reduce_238,
- 5, 193, :_reduce_239,
- 7, 193, :_reduce_240,
- 2, 193, :_reduce_241,
- 5, 193, :_reduce_242,
- 4, 193, :_reduce_243,
- 6, 193, :_reduce_244,
- 7, 193, :_reduce_245,
- 9, 193, :_reduce_246,
- 3, 193, :_reduce_247,
- 1, 193, :_reduce_248,
- 0, 195, :_reduce_249,
- 2, 163, :_reduce_250,
- 1, 194, :_reduce_251,
- 0, 196, :_reduce_252,
- 3, 194, :_reduce_253,
- 0, 197, :_reduce_254,
- 4, 194, :_reduce_255,
- 2, 192, :_reduce_256,
- 2, 191, :_reduce_257,
- 0, 191, :_reduce_258,
- 1, 186, :_reduce_259,
- 3, 186, :_reduce_260,
- 3, 153, :_reduce_261,
- 4, 153, :_reduce_262,
- 2, 153, :_reduce_263,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_none,
- 1, 184, :_reduce_272,
- 3, 184, :_reduce_273,
- 0, 218, :_reduce_274,
- 5, 184, :_reduce_275,
- 3, 184, :_reduce_276,
- 3, 184, :_reduce_277,
- 2, 184, :_reduce_278,
- 4, 184, :_reduce_279,
- 3, 184, :_reduce_280,
- 3, 184, :_reduce_281,
- 1, 184, :_reduce_282,
- 4, 184, :_reduce_283,
- 3, 184, :_reduce_284,
- 1, 184, :_reduce_285,
- 5, 184, :_reduce_286,
- 2, 184, :_reduce_287,
- 1, 184, :_reduce_none,
- 2, 184, :_reduce_289,
- 6, 184, :_reduce_290,
- 6, 184, :_reduce_291,
- 0, 219, :_reduce_292,
- 0, 220, :_reduce_293,
- 7, 184, :_reduce_294,
- 0, 221, :_reduce_295,
- 0, 222, :_reduce_296,
- 7, 184, :_reduce_297,
- 5, 184, :_reduce_298,
- 4, 184, :_reduce_299,
- 5, 184, :_reduce_300,
- 0, 223, :_reduce_301,
- 0, 224, :_reduce_302,
- 9, 184, :_reduce_303,
- 0, 225, :_reduce_304,
- 6, 184, :_reduce_305,
- 0, 226, :_reduce_306,
- 7, 184, :_reduce_307,
- 0, 227, :_reduce_308,
- 5, 184, :_reduce_309,
- 0, 228, :_reduce_310,
- 6, 184, :_reduce_311,
- 0, 229, :_reduce_312,
- 0, 230, :_reduce_313,
- 9, 184, :_reduce_314,
- 1, 184, :_reduce_315,
- 1, 184, :_reduce_316,
- 1, 184, :_reduce_317,
- 1, 184, :_reduce_318,
- 1, 150, :_reduce_none,
- 1, 208, :_reduce_none,
- 1, 208, :_reduce_none,
- 1, 208, :_reduce_none,
- 2, 208, :_reduce_323,
- 1, 210, :_reduce_none,
- 1, 210, :_reduce_none,
- 1, 210, :_reduce_none,
- 1, 209, :_reduce_none,
- 5, 209, :_reduce_328,
- 1, 137, :_reduce_none,
- 2, 137, :_reduce_330,
- 1, 212, :_reduce_none,
- 1, 212, :_reduce_none,
- 1, 231, :_reduce_333,
- 3, 231, :_reduce_334,
- 1, 232, :_reduce_none,
- 2, 232, :_reduce_none,
- 4, 232, :_reduce_337,
- 7, 232, :_reduce_338,
- 6, 232, :_reduce_339,
- 4, 232, :_reduce_340,
- 3, 232, :_reduce_341,
- 5, 232, :_reduce_342,
- 4, 232, :_reduce_343,
- 2, 232, :_reduce_344,
- 1, 232, :_reduce_345,
- 2, 232, :_reduce_346,
- 0, 165, :_reduce_347,
- 2, 165, :_reduce_348,
- 1, 165, :_reduce_349,
- 3, 165, :_reduce_350,
- 0, 234, :_reduce_351,
- 5, 233, :_reduce_352,
- 2, 161, :_reduce_353,
- 4, 161, :_reduce_354,
- 4, 161, :_reduce_355,
- 2, 207, :_reduce_356,
- 4, 207, :_reduce_357,
- 4, 207, :_reduce_358,
- 3, 207, :_reduce_359,
- 2, 207, :_reduce_360,
- 1, 207, :_reduce_361,
- 0, 236, :_reduce_362,
- 5, 206, :_reduce_363,
- 0, 237, :_reduce_364,
- 5, 206, :_reduce_365,
- 5, 211, :_reduce_366,
- 1, 238, :_reduce_none,
- 4, 238, :_reduce_368,
- 2, 238, :_reduce_369,
- 1, 239, :_reduce_370,
- 1, 239, :_reduce_none,
- 6, 136, :_reduce_372,
- 0, 136, :_reduce_373,
- 1, 240, :_reduce_374,
- 1, 240, :_reduce_none,
- 1, 240, :_reduce_none,
- 2, 241, :_reduce_377,
- 1, 241, :_reduce_none,
- 2, 138, :_reduce_379,
- 1, 138, :_reduce_none,
- 1, 198, :_reduce_none,
- 1, 198, :_reduce_none,
- 1, 198, :_reduce_none,
- 1, 199, :_reduce_384,
- 1, 243, :_reduce_385,
- 2, 243, :_reduce_386,
- 3, 244, :_reduce_387,
- 1, 244, :_reduce_388,
- 3, 200, :_reduce_389,
- 4, 201, :_reduce_390,
- 3, 202, :_reduce_391,
- 0, 247, :_reduce_392,
- 3, 247, :_reduce_393,
- 1, 248, :_reduce_394,
- 2, 248, :_reduce_395,
- 3, 203, :_reduce_396,
- 0, 250, :_reduce_397,
- 3, 250, :_reduce_398,
- 0, 245, :_reduce_399,
- 2, 245, :_reduce_400,
- 0, 246, :_reduce_401,
- 2, 246, :_reduce_402,
- 1, 249, :_reduce_403,
- 2, 249, :_reduce_404,
- 0, 252, :_reduce_405,
- 4, 249, :_reduce_406,
- 1, 251, :_reduce_407,
- 1, 251, :_reduce_408,
- 1, 251, :_reduce_409,
- 1, 251, :_reduce_none,
- 1, 180, :_reduce_411,
- 3, 181, :_reduce_412,
- 1, 242, :_reduce_413,
- 1, 242, :_reduce_414,
- 2, 242, :_reduce_415,
- 2, 242, :_reduce_416,
- 1, 173, :_reduce_417,
- 1, 173, :_reduce_418,
- 1, 173, :_reduce_419,
- 1, 173, :_reduce_420,
- 1, 173, :_reduce_421,
- 1, 173, :_reduce_422,
- 1, 173, :_reduce_423,
- 1, 173, :_reduce_424,
- 1, 173, :_reduce_425,
- 1, 173, :_reduce_426,
- 1, 173, :_reduce_427,
- 1, 204, :_reduce_428,
- 1, 149, :_reduce_429,
- 1, 152, :_reduce_430,
- 1, 152, :_reduce_431,
- 1, 213, :_reduce_432,
- 3, 213, :_reduce_433,
- 2, 213, :_reduce_434,
- 4, 215, :_reduce_435,
- 2, 215, :_reduce_436,
- 6, 253, :_reduce_437,
- 4, 253, :_reduce_438,
- 4, 253, :_reduce_439,
- 2, 253, :_reduce_440,
- 4, 253, :_reduce_441,
- 2, 253, :_reduce_442,
- 2, 253, :_reduce_443,
- 1, 253, :_reduce_444,
- 0, 253, :_reduce_445,
- 1, 259, :_reduce_446,
- 1, 259, :_reduce_447,
- 1, 259, :_reduce_448,
- 1, 259, :_reduce_449,
- 1, 259, :_reduce_450,
- 1, 254, :_reduce_451,
- 3, 254, :_reduce_452,
- 3, 260, :_reduce_453,
- 1, 255, :_reduce_454,
- 3, 255, :_reduce_455,
- 1, 261, :_reduce_none,
- 1, 261, :_reduce_none,
- 2, 256, :_reduce_458,
- 1, 256, :_reduce_459,
- 1, 262, :_reduce_none,
- 1, 262, :_reduce_none,
- 2, 258, :_reduce_462,
- 2, 257, :_reduce_463,
- 0, 257, :_reduce_464,
- 1, 216, :_reduce_none,
- 4, 216, :_reduce_466,
- 0, 205, :_reduce_467,
- 2, 205, :_reduce_468,
- 2, 205, :_reduce_469,
- 1, 188, :_reduce_470,
- 3, 188, :_reduce_471,
- 3, 263, :_reduce_472,
- 1, 167, :_reduce_none,
- 1, 167, :_reduce_none,
- 1, 167, :_reduce_none,
- 1, 162, :_reduce_none,
- 1, 162, :_reduce_none,
- 1, 162, :_reduce_none,
- 1, 162, :_reduce_none,
- 1, 235, :_reduce_none,
- 1, 235, :_reduce_none,
- 1, 235, :_reduce_none,
- 1, 217, :_reduce_none,
- 1, 217, :_reduce_none,
- 0, 140, :_reduce_none,
- 1, 140, :_reduce_none,
- 0, 183, :_reduce_none,
- 1, 183, :_reduce_none,
- 0, 187, :_reduce_none,
- 1, 187, :_reduce_none,
- 1, 187, :_reduce_none,
- 1, 214, :_reduce_492,
- 1, 214, :_reduce_none,
- 1, 142, :_reduce_none,
- 2, 142, :_reduce_none,
- 0, 185, :_reduce_496 ]
-
-racc_reduce_n = 497
-
-racc_shift_n = 894
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :kCLASS => 2,
- :kMODULE => 3,
- :kDEF => 4,
- :kUNDEF => 5,
- :kBEGIN => 6,
- :kRESCUE => 7,
- :kENSURE => 8,
- :kEND => 9,
- :kIF => 10,
- :kUNLESS => 11,
- :kTHEN => 12,
- :kELSIF => 13,
- :kELSE => 14,
- :kCASE => 15,
- :kWHEN => 16,
- :kWHILE => 17,
- :kUNTIL => 18,
- :kFOR => 19,
- :kBREAK => 20,
- :kNEXT => 21,
- :kREDO => 22,
- :kRETRY => 23,
- :kIN => 24,
- :kDO => 25,
- :kDO_COND => 26,
- :kDO_BLOCK => 27,
- :kRETURN => 28,
- :kYIELD => 29,
- :kSUPER => 30,
- :kSELF => 31,
- :kNIL => 32,
- :kTRUE => 33,
- :kFALSE => 34,
- :kAND => 35,
- :kOR => 36,
- :kNOT => 37,
- :kIF_MOD => 38,
- :kUNLESS_MOD => 39,
- :kWHILE_MOD => 40,
- :kUNTIL_MOD => 41,
- :kRESCUE_MOD => 42,
- :kALIAS => 43,
- :kDEFINED => 44,
- :klBEGIN => 45,
- :klEND => 46,
- :k__LINE__ => 47,
- :k__FILE__ => 48,
- :tIDENTIFIER => 49,
- :tFID => 50,
- :tGVAR => 51,
- :tIVAR => 52,
- :tCONSTANT => 53,
- :tCVAR => 54,
- :tNTH_REF => 55,
- :tBACK_REF => 56,
- :tSTRING_CONTENT => 57,
- :tINTEGER => 58,
- :tFLOAT => 59,
- :tREGEXP_END => 60,
- :tUPLUS => 61,
- :tUMINUS => 62,
- :tUMINUS_NUM => 63,
- :tPOW => 64,
- :tCMP => 65,
- :tEQ => 66,
- :tEQQ => 67,
- :tNEQ => 68,
- :tGEQ => 69,
- :tLEQ => 70,
- :tANDOP => 71,
- :tOROP => 72,
- :tMATCH => 73,
- :tNMATCH => 74,
- :tDOT => 75,
- :tDOT2 => 76,
- :tDOT3 => 77,
- :tAREF => 78,
- :tASET => 79,
- :tLSHFT => 80,
- :tRSHFT => 81,
- :tCOLON2 => 82,
- :tCOLON3 => 83,
- :tOP_ASGN => 84,
- :tASSOC => 85,
- :tLPAREN => 86,
- :tLPAREN2 => 87,
- :tRPAREN => 88,
- :tLPAREN_ARG => 89,
- :tLBRACK => 90,
- :tLBRACK2 => 91,
- :tRBRACK => 92,
- :tLBRACE => 93,
- :tLBRACE_ARG => 94,
- :tSTAR => 95,
- :tSTAR2 => 96,
- :tAMPER => 97,
- :tAMPER2 => 98,
- :tTILDE => 99,
- :tPERCENT => 100,
- :tDIVIDE => 101,
- :tPLUS => 102,
- :tMINUS => 103,
- :tLT => 104,
- :tGT => 105,
- :tPIPE => 106,
- :tBANG => 107,
- :tCARET => 108,
- :tLCURLY => 109,
- :tRCURLY => 110,
- :tBACK_REF2 => 111,
- :tSYMBEG => 112,
- :tSTRING_BEG => 113,
- :tXSTRING_BEG => 114,
- :tREGEXP_BEG => 115,
- :tWORDS_BEG => 116,
- :tQWORDS_BEG => 117,
- :tSTRING_DBEG => 118,
- :tSTRING_DVAR => 119,
- :tSTRING_END => 120,
- :tSTRING => 121,
- :tSYMBOL => 122,
- :tREGEXP_OPT => 123,
- :tNL => 124,
- :tEH => 125,
- :tCOLON => 126,
- :tCOMMA => 127,
- :tSPACE => 128,
- :tSEMI => 129,
- :tEQL => 130,
- :tLOWEST => 131 }
-
-racc_nt_base = 132
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "kCLASS",
- "kMODULE",
- "kDEF",
- "kUNDEF",
- "kBEGIN",
- "kRESCUE",
- "kENSURE",
- "kEND",
- "kIF",
- "kUNLESS",
- "kTHEN",
- "kELSIF",
- "kELSE",
- "kCASE",
- "kWHEN",
- "kWHILE",
- "kUNTIL",
- "kFOR",
- "kBREAK",
- "kNEXT",
- "kREDO",
- "kRETRY",
- "kIN",
- "kDO",
- "kDO_COND",
- "kDO_BLOCK",
- "kRETURN",
- "kYIELD",
- "kSUPER",
- "kSELF",
- "kNIL",
- "kTRUE",
- "kFALSE",
- "kAND",
- "kOR",
- "kNOT",
- "kIF_MOD",
- "kUNLESS_MOD",
- "kWHILE_MOD",
- "kUNTIL_MOD",
- "kRESCUE_MOD",
- "kALIAS",
- "kDEFINED",
- "klBEGIN",
- "klEND",
- "k__LINE__",
- "k__FILE__",
- "tIDENTIFIER",
- "tFID",
- "tGVAR",
- "tIVAR",
- "tCONSTANT",
- "tCVAR",
- "tNTH_REF",
- "tBACK_REF",
- "tSTRING_CONTENT",
- "tINTEGER",
- "tFLOAT",
- "tREGEXP_END",
- "tUPLUS",
- "tUMINUS",
- "tUMINUS_NUM",
- "tPOW",
- "tCMP",
- "tEQ",
- "tEQQ",
- "tNEQ",
- "tGEQ",
- "tLEQ",
- "tANDOP",
- "tOROP",
- "tMATCH",
- "tNMATCH",
- "tDOT",
- "tDOT2",
- "tDOT3",
- "tAREF",
- "tASET",
- "tLSHFT",
- "tRSHFT",
- "tCOLON2",
- "tCOLON3",
- "tOP_ASGN",
- "tASSOC",
- "tLPAREN",
- "tLPAREN2",
- "tRPAREN",
- "tLPAREN_ARG",
- "tLBRACK",
- "tLBRACK2",
- "tRBRACK",
- "tLBRACE",
- "tLBRACE_ARG",
- "tSTAR",
- "tSTAR2",
- "tAMPER",
- "tAMPER2",
- "tTILDE",
- "tPERCENT",
- "tDIVIDE",
- "tPLUS",
- "tMINUS",
- "tLT",
- "tGT",
- "tPIPE",
- "tBANG",
- "tCARET",
- "tLCURLY",
- "tRCURLY",
- "tBACK_REF2",
- "tSYMBEG",
- "tSTRING_BEG",
- "tXSTRING_BEG",
- "tREGEXP_BEG",
- "tWORDS_BEG",
- "tQWORDS_BEG",
- "tSTRING_DBEG",
- "tSTRING_DVAR",
- "tSTRING_END",
- "tSTRING",
- "tSYMBOL",
- "tREGEXP_OPT",
- "tNL",
- "tEH",
- "tCOLON",
- "tCOMMA",
- "tSPACE",
- "tSEMI",
- "tEQL",
- "tLOWEST",
- "$start",
- "program",
- "compstmt",
- "bodystmt",
- "opt_rescue",
- "opt_else",
- "opt_ensure",
- "stmts",
- "opt_terms",
- "stmt",
- "terms",
- "fitem",
- "undef_list",
- "expr_value",
- "lhs",
- "command_call",
- "mlhs",
- "var_lhs",
- "primary_value",
- "aref_args",
- "backref",
- "mrhs",
- "arg_value",
- "expr",
- "@1",
- "arg",
- "command",
- "block_command",
- "call_args",
- "block_call",
- "operation2",
- "command_args",
- "cmd_brace_block",
- "opt_block_var",
- "@2",
- "operation",
- "mlhs_basic",
- "mlhs_entry",
- "mlhs_head",
- "mlhs_item",
- "mlhs_node",
- "variable",
- "cname",
- "cpath",
- "fname",
- "op",
- "reswords",
- "fsym",
- "symbol",
- "dsym",
- "@3",
- "opt_nl",
- "primary",
- "none",
- "args",
- "trailer",
- "assocs",
- "paren_args",
- "opt_paren_args",
- "opt_block_arg",
- "block_arg",
- "call_args2",
- "open_args",
- "@4",
- "@5",
- "@6",
- "literal",
- "strings",
- "xstring",
- "regexp",
- "words",
- "qwords",
- "var_ref",
- "assoc_list",
- "brace_block",
- "method_call",
- "then",
- "if_tail",
- "do",
- "case_body",
- "for_var",
- "superclass",
- "term",
- "f_arglist",
- "singleton",
- "dot_or_colon",
- "@7",
- "@8",
- "@9",
- "@10",
- "@11",
- "@12",
- "@13",
- "@14",
- "@15",
- "@16",
- "@17",
- "@18",
- "@19",
- "block_par",
- "block_var",
- "do_block",
- "@20",
- "operation3",
- "@21",
- "@22",
- "when_args",
- "cases",
- "exc_list",
- "exc_var",
- "numeric",
- "string",
- "string1",
- "string_contents",
- "xstring_contents",
- "word_list",
- "word",
- "string_content",
- "qword_list",
- "string_dvar",
- "@23",
- "f_args",
- "f_arg",
- "f_optarg",
- "f_rest_arg",
- "opt_f_block_arg",
- "f_block_arg",
- "f_norm_arg",
- "f_opt",
- "restarg_mark",
- "blkarg_mark",
- "assoc" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 73)
- def _reduce_1(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 78)
- def _reduce_2(val, _values, result)
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 94)
- def _reduce_3(val, _values, result)
- result = @builder.compstmt(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 99)
- def _reduce_4(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 103)
- def _reduce_5(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 107)
- def _reduce_6(val, _values, result)
- result = [ val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 111)
- def _reduce_7(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 116)
- def _reduce_8(val, _values, result)
- @lexer.state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 120)
- def _reduce_9(val, _values, result)
- result = @builder.alias(val[0], val[1], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 124)
- def _reduce_10(val, _values, result)
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 130)
- def _reduce_11(val, _values, result)
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 136)
- def _reduce_12(val, _values, result)
- diagnostic :error, :nth_ref_alias, nil, val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 140)
- def _reduce_13(val, _values, result)
- result = @builder.undef_method(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 144)
- def _reduce_14(val, _values, result)
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 149)
- def _reduce_15(val, _values, result)
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 154)
- def _reduce_16(val, _values, result)
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 158)
- def _reduce_17(val, _values, result)
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 162)
- def _reduce_18(val, _values, result)
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 170)
- def _reduce_19(val, _values, result)
- if in_def?
- diagnostic :error, :begin_in_method, nil, val[0]
- end
-
- result = @builder.preexe(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 178)
- def _reduce_20(val, _values, result)
- result = @builder.postexe(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 182)
- def _reduce_21(val, _values, result)
- result = @builder.assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 186)
- def _reduce_22(val, _values, result)
- result = @builder.multi_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 190)
- def _reduce_23(val, _values, result)
- result = @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 194)
- def _reduce_24(val, _values, result)
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 201)
- def _reduce_25(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 208)
- def _reduce_26(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 215)
- def _reduce_27(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 222)
- def _reduce_28(val, _values, result)
- @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 226)
- def _reduce_29(val, _values, result)
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 231)
- def _reduce_30(val, _values, result)
- result = @builder.multi_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 235)
- def _reduce_31(val, _values, result)
- result = @builder.multi_assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
-
- result
- end
-.,.,
-
-# reduce 32 omitted
-
-# reduce 33 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 243)
- def _reduce_34(val, _values, result)
- result = @builder.logical_op(:and, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 247)
- def _reduce_35(val, _values, result)
- result = @builder.logical_op(:or, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 251)
- def _reduce_36(val, _values, result)
- result = @builder.not_op(val[0], nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 255)
- def _reduce_37(val, _values, result)
- result = @builder.not_op(val[0], nil, val[1], nil)
-
- result
- end
-.,.,
-
-# reduce 38 omitted
-
-# reduce 39 omitted
-
-# reduce 40 omitted
-
-# reduce 41 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 265)
- def _reduce_42(val, _values, result)
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 270)
- def _reduce_43(val, _values, result)
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 275)
- def _reduce_44(val, _values, result)
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-# reduce 45 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 282)
- def _reduce_46(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 288)
- def _reduce_47(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 295)
- def _reduce_48(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 299)
- def _reduce_49(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 306)
- def _reduce_50(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 312)
- def _reduce_51(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- method_call = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
-
- begin_t, block_args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, block_args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 322)
- def _reduce_52(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 329)
- def _reduce_53(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, block_args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, block_args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 339)
- def _reduce_54(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 345)
- def _reduce_55(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, block_args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, block_args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 355)
- def _reduce_56(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 361)
- def _reduce_57(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:yield, val[0],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 368)
- def _reduce_58(val, _values, result)
- result = @builder.multi_lhs(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 372)
- def _reduce_59(val, _values, result)
- result = @builder.begin(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 377)
- def _reduce_60(val, _values, result)
- result = @builder.multi_lhs(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 381)
- def _reduce_61(val, _values, result)
- result = @builder.multi_lhs(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 386)
- def _reduce_62(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 390)
- def _reduce_63(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 394)
- def _reduce_64(val, _values, result)
- result = val[0] << @builder.splat(val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 398)
- def _reduce_65(val, _values, result)
- result = val[0] << @builder.splat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 402)
- def _reduce_66(val, _values, result)
- result = [ @builder.splat(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 406)
- def _reduce_67(val, _values, result)
- result = [ @builder.splat(val[0]) ]
-
- result
- end
-.,.,
-
-# reduce 68 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 412)
- def _reduce_69(val, _values, result)
- result = @builder.begin(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 417)
- def _reduce_70(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 421)
- def _reduce_71(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 426)
- def _reduce_72(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 430)
- def _reduce_73(val, _values, result)
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 434)
- def _reduce_74(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 438)
- def _reduce_75(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 442)
- def _reduce_76(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 446)
- def _reduce_77(val, _values, result)
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 451)
- def _reduce_78(val, _values, result)
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 456)
- def _reduce_79(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 461)
- def _reduce_80(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 465)
- def _reduce_81(val, _values, result)
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 469)
- def _reduce_82(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 473)
- def _reduce_83(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 477)
- def _reduce_84(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 481)
- def _reduce_85(val, _values, result)
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 486)
- def _reduce_86(val, _values, result)
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 491)
- def _reduce_87(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 496)
- def _reduce_88(val, _values, result)
- diagnostic :error, :module_name_const, nil, val[0]
-
- result
- end
-.,.,
-
-# reduce 89 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 502)
- def _reduce_90(val, _values, result)
- result = @builder.const_global(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 506)
- def _reduce_91(val, _values, result)
- result = @builder.const(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 510)
- def _reduce_92(val, _values, result)
- result = @builder.const_fetch(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 93 omitted
-
-# reduce 94 omitted
-
-# reduce 95 omitted
-
-# reduce 96 omitted
-
-# reduce 97 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 519)
- def _reduce_98(val, _values, result)
- result = @builder.symbol(val[0])
-
- result
- end
-.,.,
-
-# reduce 99 omitted
-
-# reduce 100 omitted
-
-# reduce 101 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 528)
- def _reduce_102(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 532)
- def _reduce_103(val, _values, result)
- @lexer.state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 536)
- def _reduce_104(val, _values, result)
- result = val[0] << val[3]
-
- result
- end
-.,.,
-
-# reduce 105 omitted
-
-# reduce 106 omitted
-
-# reduce 107 omitted
-
-# reduce 108 omitted
-
-# reduce 109 omitted
-
-# reduce 110 omitted
-
-# reduce 111 omitted
-
-# reduce 112 omitted
-
-# reduce 113 omitted
-
-# reduce 114 omitted
-
-# reduce 115 omitted
-
-# reduce 116 omitted
-
-# reduce 117 omitted
-
-# reduce 118 omitted
-
-# reduce 119 omitted
-
-# reduce 120 omitted
-
-# reduce 121 omitted
-
-# reduce 122 omitted
-
-# reduce 123 omitted
-
-# reduce 124 omitted
-
-# reduce 125 omitted
-
-# reduce 126 omitted
-
-# reduce 127 omitted
-
-# reduce 128 omitted
-
-# reduce 129 omitted
-
-# reduce 130 omitted
-
-# reduce 131 omitted
-
-# reduce 132 omitted
-
-# reduce 133 omitted
-
-# reduce 134 omitted
-
-# reduce 135 omitted
-
-# reduce 136 omitted
-
-# reduce 137 omitted
-
-# reduce 138 omitted
-
-# reduce 139 omitted
-
-# reduce 140 omitted
-
-# reduce 141 omitted
-
-# reduce 142 omitted
-
-# reduce 143 omitted
-
-# reduce 144 omitted
-
-# reduce 145 omitted
-
-# reduce 146 omitted
-
-# reduce 147 omitted
-
-# reduce 148 omitted
-
-# reduce 149 omitted
-
-# reduce 150 omitted
-
-# reduce 151 omitted
-
-# reduce 152 omitted
-
-# reduce 153 omitted
-
-# reduce 154 omitted
-
-# reduce 155 omitted
-
-# reduce 156 omitted
-
-# reduce 157 omitted
-
-# reduce 158 omitted
-
-# reduce 159 omitted
-
-# reduce 160 omitted
-
-# reduce 161 omitted
-
-# reduce 162 omitted
-
-# reduce 163 omitted
-
-# reduce 164 omitted
-
-# reduce 165 omitted
-
-# reduce 166 omitted
-
-# reduce 167 omitted
-
-# reduce 168 omitted
-
-# reduce 169 omitted
-
-# reduce 170 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 555)
- def _reduce_171(val, _values, result)
- result = @builder.assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 559)
- def _reduce_172(val, _values, result)
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 569)
- def _reduce_173(val, _values, result)
- result = @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 573)
- def _reduce_174(val, _values, result)
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 580)
- def _reduce_175(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 587)
- def _reduce_176(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 594)
- def _reduce_177(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 601)
- def _reduce_178(val, _values, result)
- diagnostic :error, :dynamic_const, nil, val[2], [ val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 605)
- def _reduce_179(val, _values, result)
- diagnostic :error, :dynamic_const, nil, val[1], [ val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 609)
- def _reduce_180(val, _values, result)
- result = @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 613)
- def _reduce_181(val, _values, result)
- result = @builder.range_inclusive(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 617)
- def _reduce_182(val, _values, result)
- result = @builder.range_exclusive(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 621)
- def _reduce_183(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 625)
- def _reduce_184(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 629)
- def _reduce_185(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 633)
- def _reduce_186(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 637)
- def _reduce_187(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 641)
- def _reduce_188(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 645)
- def _reduce_189(val, _values, result)
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.integer(val[1]),
- val[2], val[3]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 652)
- def _reduce_190(val, _values, result)
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- @builder.float(val[1]),
- val[2], val[3]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 659)
- def _reduce_191(val, _values, result)
- result = @builder.unary_op(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 663)
- def _reduce_192(val, _values, result)
- result = @builder.unary_op(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 667)
- def _reduce_193(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 671)
- def _reduce_194(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 675)
- def _reduce_195(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 679)
- def _reduce_196(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 683)
- def _reduce_197(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 687)
- def _reduce_198(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 691)
- def _reduce_199(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 695)
- def _reduce_200(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 699)
- def _reduce_201(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 703)
- def _reduce_202(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 707)
- def _reduce_203(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 711)
- def _reduce_204(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 715)
- def _reduce_205(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 719)
- def _reduce_206(val, _values, result)
- result = @builder.not_op(val[0], nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 723)
- def _reduce_207(val, _values, result)
- result = @builder.unary_op(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 727)
- def _reduce_208(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 731)
- def _reduce_209(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 735)
- def _reduce_210(val, _values, result)
- result = @builder.logical_op(:and, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 739)
- def _reduce_211(val, _values, result)
- result = @builder.logical_op(:or, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 743)
- def _reduce_212(val, _values, result)
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 747)
- def _reduce_213(val, _values, result)
- result = @builder.ternary(val[0], val[1],
- val[2], val[3], val[4])
-
- result
- end
-.,.,
-
-# reduce 214 omitted
-
-# reduce 215 omitted
-
-# reduce 216 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 757)
- def _reduce_217(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 761)
- def _reduce_218(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 765)
- def _reduce_219(val, _values, result)
- result = val[0] << @builder.splat(val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 769)
- def _reduce_220(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 773)
- def _reduce_221(val, _values, result)
- result = [ @builder.splat(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 778)
- def _reduce_222(val, _values, result)
- result = [ val[0], [], val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 782)
- def _reduce_223(val, _values, result)
- result = [ val[0], val[1], val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 786)
- def _reduce_224(val, _values, result)
- result = [ val[0], [ val[1] ], val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 790)
- def _reduce_225(val, _values, result)
- result = [ val[0], val[1] << val[3], val[5] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 795)
- def _reduce_226(val, _values, result)
- result = [ nil, [], nil ]
-
- result
- end
-.,.,
-
-# reduce 227 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 801)
- def _reduce_228(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 805)
- def _reduce_229(val, _values, result)
- result = val[0].concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 809)
- def _reduce_230(val, _values, result)
- result = val[0].concat(
- [ @builder.splat(val[2], val[3]),
- *val[4] ])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 815)
- def _reduce_231(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil),
- *val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 820)
- def _reduce_232(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil),
- @builder.splat(val[2], val[3]),
- *val[4] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 826)
- def _reduce_233(val, _values, result)
- result = val[0].concat(
- [ @builder.associate(nil, val[2], nil),
- *val[3] ])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 832)
- def _reduce_234(val, _values, result)
- result = val[0].concat(
- [ @builder.associate(nil, val[2], nil),
- @builder.splat(val[4], val[5]),
- *val[6] ])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 839)
- def _reduce_235(val, _values, result)
- result = [ @builder.splat(val[0], val[1]),
- *val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 844)
- def _reduce_236(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 849)
- def _reduce_237(val, _values, result)
- result = [ val[0], *val[2].concat(val[3]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 853)
- def _reduce_238(val, _values, result)
- result = [ val[0], val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 857)
- def _reduce_239(val, _values, result)
- result = [ val[0],
- @builder.splat(val[2], val[3]),
- *val[4] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 863)
- def _reduce_240(val, _values, result)
- result = [ val[0],
- *val[2].
- push(@builder.splat(val[4], val[5])).
- concat(val[6]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 870)
- def _reduce_241(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil),
- *val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 875)
- def _reduce_242(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil),
- @builder.splat(val[2], val[3]),
- *val[4] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 881)
- def _reduce_243(val, _values, result)
- result = [ val[0],
- @builder.associate(nil, val[2], nil),
- *val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 887)
- def _reduce_244(val, _values, result)
- result = [ val[0],
- *val[2].
- push(@builder.associate(nil, val[4], nil)).
- concat(val[5]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 894)
- def _reduce_245(val, _values, result)
- result = [ val[0],
- @builder.associate(nil, val[2], nil),
- @builder.splat(val[4], val[5]),
- *val[6] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 901)
- def _reduce_246(val, _values, result)
- result = [ val[0],
- *val[2].
- push(@builder.associate(nil, val[4], nil)).
- push(@builder.splat(val[6], val[7])).
- concat(val[8]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 909)
- def _reduce_247(val, _values, result)
- result = [ @builder.splat(val[0], val[1]),
- *val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 914)
- def _reduce_248(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 918)
- def _reduce_249(val, _values, result)
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 923)
- def _reduce_250(val, _values, result)
- @lexer.cmdarg = val[0]
-
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 930)
- def _reduce_251(val, _values, result)
- result = [ nil, val[0], nil ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 934)
- def _reduce_252(val, _values, result)
- @lexer.state = :expr_endarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 938)
- def _reduce_253(val, _values, result)
- result = [ val[0], [], val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 942)
- def _reduce_254(val, _values, result)
- @lexer.state = :expr_endarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 946)
- def _reduce_255(val, _values, result)
- result = [ val[0], val[1], val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 951)
- def _reduce_256(val, _values, result)
- result = @builder.block_pass(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 956)
- def _reduce_257(val, _values, result)
- result = [ val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 960)
- def _reduce_258(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 965)
- def _reduce_259(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 969)
- def _reduce_260(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 974)
- def _reduce_261(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 978)
- def _reduce_262(val, _values, result)
- result = val[0] << @builder.splat(val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 982)
- def _reduce_263(val, _values, result)
- result = [ @builder.splat(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-# reduce 264 omitted
-
-# reduce 265 omitted
-
-# reduce 266 omitted
-
-# reduce 267 omitted
-
-# reduce 268 omitted
-
-# reduce 269 omitted
-
-# reduce 270 omitted
-
-# reduce 271 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 995)
- def _reduce_272(val, _values, result)
- result = @builder.call_method(nil, nil, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 999)
- def _reduce_273(val, _values, result)
- result = @builder.begin_keyword(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1003)
- def _reduce_274(val, _values, result)
- @lexer.state = :expr_endarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1007)
- def _reduce_275(val, _values, result)
- result = @builder.begin(val[0], val[1], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1011)
- def _reduce_276(val, _values, result)
- result = @builder.begin(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1015)
- def _reduce_277(val, _values, result)
- result = @builder.const_fetch(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1019)
- def _reduce_278(val, _values, result)
- result = @builder.const_global(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1023)
- def _reduce_279(val, _values, result)
- result = @builder.index(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1027)
- def _reduce_280(val, _values, result)
- result = @builder.array(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1031)
- def _reduce_281(val, _values, result)
- result = @builder.associate(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1035)
- def _reduce_282(val, _values, result)
- result = @builder.keyword_cmd(:return, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1039)
- def _reduce_283(val, _values, result)
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1043)
- def _reduce_284(val, _values, result)
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1047)
- def _reduce_285(val, _values, result)
- result = @builder.keyword_cmd(:yield, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1051)
- def _reduce_286(val, _values, result)
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1056)
- def _reduce_287(val, _values, result)
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-# reduce 288 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1065)
- def _reduce_289(val, _values, result)
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1071)
- def _reduce_290(val, _values, result)
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1078)
- def _reduce_291(val, _values, result)
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1085)
- def _reduce_292(val, _values, result)
- @lexer.cond.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1089)
- def _reduce_293(val, _values, result)
- @lexer.cond.pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1093)
- def _reduce_294(val, _values, result)
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1098)
- def _reduce_295(val, _values, result)
- @lexer.cond.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1102)
- def _reduce_296(val, _values, result)
- @lexer.cond.pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1106)
- def _reduce_297(val, _values, result)
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1111)
- def _reduce_298(val, _values, result)
- when_bodies = val[3][0..-2]
- else_t, else_body = val[3][-1]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1120)
- def _reduce_299(val, _values, result)
- when_bodies = val[2][0..-2]
- else_t, else_body = val[2][-1]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1129)
- def _reduce_300(val, _values, result)
- result = @builder.case(val[0], nil,
- [], val[2], val[3],
- val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1135)
- def _reduce_301(val, _values, result)
- @lexer.cond.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1139)
- def _reduce_302(val, _values, result)
- @lexer.cond.pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1143)
- def _reduce_303(val, _values, result)
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1149)
- def _reduce_304(val, _values, result)
- @static_env.extend_static
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1153)
- def _reduce_305(val, _values, result)
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1166)
- def _reduce_306(val, _values, result)
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1173)
- def _reduce_307(val, _values, result)
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @static_env.unextend
-
- @def_level = val[4]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1182)
- def _reduce_308(val, _values, result)
- @static_env.extend_static
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1186)
- def _reduce_309(val, _values, result)
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1197)
- def _reduce_310(val, _values, result)
- @def_level += 1
- @static_env.extend_static
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1202)
- def _reduce_311(val, _values, result)
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @static_env.unextend
- @def_level -= 1
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1210)
- def _reduce_312(val, _values, result)
- @lexer.state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1214)
- def _reduce_313(val, _values, result)
- @def_level += 1
- @static_env.extend_static
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1219)
- def _reduce_314(val, _values, result)
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @static_env.unextend
- @def_level -= 1
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1227)
- def _reduce_315(val, _values, result)
- result = @builder.keyword_cmd(:break, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1231)
- def _reduce_316(val, _values, result)
- result = @builder.keyword_cmd(:next, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1235)
- def _reduce_317(val, _values, result)
- result = @builder.keyword_cmd(:redo, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1239)
- def _reduce_318(val, _values, result)
- result = @builder.keyword_cmd(:retry, val[0])
-
- result
- end
-.,.,
-
-# reduce 319 omitted
-
-# reduce 320 omitted
-
-# reduce 321 omitted
-
-# reduce 322 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1249)
- def _reduce_323(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-# reduce 324 omitted
-
-# reduce 325 omitted
-
-# reduce 326 omitted
-
-# reduce 327 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1259)
- def _reduce_328(val, _values, result)
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
-
- result
- end
-.,.,
-
-# reduce 329 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1270)
- def _reduce_330(val, _values, result)
- result = val
-
- result
- end
-.,.,
-
-# reduce 331 omitted
-
-# reduce 332 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1278)
- def _reduce_333(val, _values, result)
- result = [ @builder.arg_expr(val[0]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1282)
- def _reduce_334(val, _values, result)
- result = val[0] << @builder.arg_expr(val[2])
-
- result
- end
-.,.,
-
-# reduce 335 omitted
-
-# reduce 336 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1289)
- def _reduce_337(val, _values, result)
- result = val[0].
- push(@builder.blockarg_expr(val[2], val[3]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1294)
- def _reduce_338(val, _values, result)
- result = val[0].
- push(@builder.restarg_expr(val[2], val[3])).
- push(@builder.blockarg_expr(val[5], val[6]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1300)
- def _reduce_339(val, _values, result)
- result = val[0].
- push(@builder.restarg_expr(val[2])).
- push(@builder.blockarg_expr(val[4], val[5]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1306)
- def _reduce_340(val, _values, result)
- result = val[0].
- push(@builder.restarg_expr(val[2], val[3]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1311)
- def _reduce_341(val, _values, result)
- result = val[0].
- push(@builder.restarg_expr(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1316)
- def _reduce_342(val, _values, result)
- result = [ @builder.restarg_expr(val[0], val[1]),
- @builder.blockarg_expr(val[3], val[4]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1321)
- def _reduce_343(val, _values, result)
- result = [ @builder.restarg_expr(val[0]),
- @builder.blockarg_expr(val[2], val[3]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1326)
- def _reduce_344(val, _values, result)
- result = [ @builder.restarg_expr(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1330)
- def _reduce_345(val, _values, result)
- result = [ @builder.restarg_expr(val[0]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1334)
- def _reduce_346(val, _values, result)
- result = [ @builder.blockarg_expr(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1340)
- def _reduce_347(val, _values, result)
- result = @builder.args(nil, [], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1344)
- def _reduce_348(val, _values, result)
- result = @builder.args(val[0], [], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1348)
- def _reduce_349(val, _values, result)
- result = @builder.args(val[0], [], val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1352)
- def _reduce_350(val, _values, result)
- result = @builder.args(val[0], val[1], val[2], false)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1357)
- def _reduce_351(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1361)
- def _reduce_352(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1368)
- def _reduce_353(val, _values, result)
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1374)
- def _reduce_354(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1380)
- def _reduce_355(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1387)
- def _reduce_356(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1393)
- def _reduce_357(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1399)
- def _reduce_358(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1405)
- def _reduce_359(val, _values, result)
- result = @builder.call_method(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1409)
- def _reduce_360(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1415)
- def _reduce_361(val, _values, result)
- result = @builder.keyword_cmd(:zsuper, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1420)
- def _reduce_362(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1424)
- def _reduce_363(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1430)
- def _reduce_364(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1434)
- def _reduce_365(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1441)
- def _reduce_366(val, _values, result)
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
-
- result
- end
-.,.,
-
-# reduce 367 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1448)
- def _reduce_368(val, _values, result)
- result = val[0] << @builder.splat(val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1452)
- def _reduce_369(val, _values, result)
- result = [ @builder.splat(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1457)
- def _reduce_370(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-# reduce 371 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1463)
- def _reduce_372(val, _values, result)
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1476)
- def _reduce_373(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1481)
- def _reduce_374(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-# reduce 375 omitted
-
-# reduce 376 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1488)
- def _reduce_377(val, _values, result)
- result = [ val[0], val[1] ]
-
- result
- end
-.,.,
-
-# reduce 378 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1494)
- def _reduce_379(val, _values, result)
- result = [ val[0], val[1] ]
-
- result
- end
-.,.,
-
-# reduce 380 omitted
-
-# reduce 381 omitted
-
-# reduce 382 omitted
-
-# reduce 383 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1504)
- def _reduce_384(val, _values, result)
- result = @builder.string_compose(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1509)
- def _reduce_385(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1513)
- def _reduce_386(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1518)
- def _reduce_387(val, _values, result)
- result = @builder.string_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1522)
- def _reduce_388(val, _values, result)
- result = @builder.string(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1527)
- def _reduce_389(val, _values, result)
- result = @builder.xstring_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1532)
- def _reduce_390(val, _values, result)
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1538)
- def _reduce_391(val, _values, result)
- result = @builder.words_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1543)
- def _reduce_392(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1547)
- def _reduce_393(val, _values, result)
- result = val[0] << @builder.word(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1552)
- def _reduce_394(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1556)
- def _reduce_395(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1561)
- def _reduce_396(val, _values, result)
- result = @builder.words_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1566)
- def _reduce_397(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1570)
- def _reduce_398(val, _values, result)
- result = val[0] << @builder.string_internal(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1575)
- def _reduce_399(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1579)
- def _reduce_400(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1584)
- def _reduce_401(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1588)
- def _reduce_402(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1593)
- def _reduce_403(val, _values, result)
- result = @builder.string_internal(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1597)
- def _reduce_404(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1601)
- def _reduce_405(val, _values, result)
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1606)
- def _reduce_406(val, _values, result)
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1614)
- def _reduce_407(val, _values, result)
- result = @builder.gvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1618)
- def _reduce_408(val, _values, result)
- result = @builder.ivar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1622)
- def _reduce_409(val, _values, result)
- result = @builder.cvar(val[0])
-
- result
- end
-.,.,
-
-# reduce 410 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1629)
- def _reduce_411(val, _values, result)
- result = @builder.symbol(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1634)
- def _reduce_412(val, _values, result)
- result = @builder.symbol_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1639)
- def _reduce_413(val, _values, result)
- result = @builder.integer(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1643)
- def _reduce_414(val, _values, result)
- result = @builder.float(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1647)
- def _reduce_415(val, _values, result)
- result = @builder.negate(val[0],
- @builder.integer(val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1652)
- def _reduce_416(val, _values, result)
- result = @builder.negate(val[0],
- @builder.float(val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1658)
- def _reduce_417(val, _values, result)
- result = @builder.ident(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1662)
- def _reduce_418(val, _values, result)
- result = @builder.ivar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1666)
- def _reduce_419(val, _values, result)
- result = @builder.gvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1670)
- def _reduce_420(val, _values, result)
- result = @builder.cvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1674)
- def _reduce_421(val, _values, result)
- result = @builder.const(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1678)
- def _reduce_422(val, _values, result)
- result = @builder.nil(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1682)
- def _reduce_423(val, _values, result)
- result = @builder.self(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1686)
- def _reduce_424(val, _values, result)
- result = @builder.true(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1690)
- def _reduce_425(val, _values, result)
- result = @builder.false(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1694)
- def _reduce_426(val, _values, result)
- result = @builder.__FILE__(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1698)
- def _reduce_427(val, _values, result)
- result = @builder.__LINE__(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1703)
- def _reduce_428(val, _values, result)
- result = @builder.accessible(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1708)
- def _reduce_429(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1713)
- def _reduce_430(val, _values, result)
- result = @builder.nth_ref(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1717)
- def _reduce_431(val, _values, result)
- result = @builder.back_ref(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1722)
- def _reduce_432(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1726)
- def _reduce_433(val, _values, result)
- result = [ val[0], val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1730)
- def _reduce_434(val, _values, result)
- yyerrok
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1736)
- def _reduce_435(val, _values, result)
- result = @builder.args(val[0], val[1], val[3])
-
- @lexer.state = :expr_beg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1742)
- def _reduce_436(val, _values, result)
- result = @builder.args(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1747)
- def _reduce_437(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1754)
- def _reduce_438(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1760)
- def _reduce_439(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1766)
- def _reduce_440(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1771)
- def _reduce_441(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1777)
- def _reduce_442(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1782)
- def _reduce_443(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1787)
- def _reduce_444(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1791)
- def _reduce_445(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1796)
- def _reduce_446(val, _values, result)
- diagnostic :error, :argument_const, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1800)
- def _reduce_447(val, _values, result)
- diagnostic :error, :argument_ivar, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1804)
- def _reduce_448(val, _values, result)
- diagnostic :error, :argument_gvar, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1808)
- def _reduce_449(val, _values, result)
- diagnostic :error, :argument_cvar, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1812)
- def _reduce_450(val, _values, result)
- @static_env.declare val[0][0]
-
- result = @builder.arg(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1819)
- def _reduce_451(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1823)
- def _reduce_452(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1828)
- def _reduce_453(val, _values, result)
- @static_env.declare val[0][0]
-
- result = @builder.optarg(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1835)
- def _reduce_454(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1839)
- def _reduce_455(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-# reduce 456 omitted
-
-# reduce 457 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1846)
- def _reduce_458(val, _values, result)
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1852)
- def _reduce_459(val, _values, result)
- result = [ @builder.restarg(val[0]) ]
-
- result
- end
-.,.,
-
-# reduce 460 omitted
-
-# reduce 461 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1859)
- def _reduce_462(val, _values, result)
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1866)
- def _reduce_463(val, _values, result)
- result = [ val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1870)
- def _reduce_464(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-# reduce 465 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1876)
- def _reduce_466(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1881)
- def _reduce_467(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1885)
- def _reduce_468(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1889)
- def _reduce_469(val, _values, result)
- result = @builder.pair_list_18(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1894)
- def _reduce_470(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1898)
- def _reduce_471(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby18.y', 1903)
- def _reduce_472(val, _values, result)
- result = @builder.pair(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 473 omitted
-
-# reduce 474 omitted
-
-# reduce 475 omitted
-
-# reduce 476 omitted
-
-# reduce 477 omitted
-
-# reduce 478 omitted
-
-# reduce 479 omitted
-
-# reduce 480 omitted
-
-# reduce 481 omitted
-
-# reduce 482 omitted
-
-# reduce 483 omitted
-
-# reduce 484 omitted
-
-# reduce 485 omitted
-
-# reduce 486 omitted
-
-# reduce 487 omitted
-
-# reduce 488 omitted
-
-# reduce 489 omitted
-
-# reduce 490 omitted
-
-# reduce 491 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1916)
- def _reduce_492(val, _values, result)
- yyerrok
-
- result
- end
-.,.,
-
-# reduce 493 omitted
-
-# reduce 494 omitted
-
-# reduce 495 omitted
-
-module_eval(<<'.,.,', 'ruby18.y', 1925)
- def _reduce_496(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Ruby18
-end # module Parser
diff --git a/test/racc/regress/ruby22 b/test/racc/regress/ruby22
deleted file mode 100644
index 8e68b5fe1c..0000000000
--- a/test/racc/regress/ruby22
+++ /dev/null
@@ -1,7456 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-
-require 'parser'
-
-Parser.check_for_encoding_support
-
-module Parser
- class Ruby22 < Racc::Parser
-
-module_eval(<<'...end ruby22.y/module_eval...', 'ruby22.y', 2374)
-
- def version
- 22
- end
-
- def default_encoding
- Encoding::UTF_8
- end
-...end ruby22.y/module_eval...
-##### State transition tables begin ###
-
-clist = [
-'-291,568,-102,-100,860,-99,951,-291,-291,-291,-490,568,-291,-291,-291',
-'217,-291,589,214,215,959,-288,214,215,214,215,-291,-291,-291,-105,-99',
-'-97,-103,837,806,268,-291,-291,610,-291,-291,-291,-291,-291,568,568',
-'-102,568,113,-100,715,-101,268,112,-83,815,218,-88,-482,113,-99,-288',
-'-98,-69,112,-482,-97,-291,-291,-291,-291,-291,-291,-291,-291,-291,-291',
-'-291,-291,-291,-291,-93,-104,-291,-291,-291,961,773,-291,715,612,-291',
-'-101,715,-291,-291,268,-291,-575,-291,263,-291,962,-291,-291,609,-291',
-'-291,-291,-291,-291,967,-291,113,-291,-90,-91,218,112,218,113,-102,-100',
-'267,588,112,-102,-100,-291,-574,113,-291,-291,-291,-291,112,-291,-578',
-'-291,-96,267,-88,-94,-103,-578,-578,-578,113,-93,-99,-578,-578,112,-578',
-'-99,113,-93,611,-574,-91,112,647,-578,113,113,814,113,842,112,112,-101',
-'112,-89,-578,-578,-101,-578,-578,-578,-578,-578,214,215,-91,267,580',
-'-476,268,-93,581,647,-93,-95,-476,113,736,646,-490,113,112,-93,574,-92',
-'112,-578,-578,-578,-578,-578,-578,-578,-578,-578,-578,-578,-578,-578',
-'-578,692,647,-578,-578,-578,-91,631,646,-91,-491,-578,113,626,-578,647',
-'971,112,-91,-578,515,-578,973,-578,-578,-571,-578,-578,-578,-578,-578',
-'-291,-578,-578,-578,263,-97,646,-291,-291,-291,91,92,79,-291,-291,-486',
-'-291,-578,975,646,-578,-578,-486,-92,80,-578,-89,267,218,-93,977,597',
-'-101,-412,81,-98,-291,-291,-102,-291,-291,-291,-291,-291,444,-104,548',
-'-476,545,544,543,597,546,527,-476,806,529,574,548,-571,545,544,543,-476',
-'546,91,92,-291,-291,-291,-291,-291,-291,-291,-291,-291,-291,-291,-291',
-'-291,-291,260,-571,-291,-291,-291,-412,630,261,93,94,-291,977,-412,-291',
-'597,599,598,595,-291,-105,-291,-412,-291,-291,-578,-291,-291,-291,-291',
-'-291,-476,-291,662,-291,771,599,598,-476,-476,-476,-412,988,-476,-476',
-'-476,749,-476,-291,833,527,-291,-291,529,-94,-476,-291,-476,-476,-476',
-'238,957,-485,-103,93,94,989,-476,-476,-485,-476,-476,-476,-476,-476',
-'770,899,625,-578,-292,599,598,608,597,113,-578,-292,899,113,112,-574',
-'-102,235,112,-578,-292,237,236,-476,-476,-476,-476,-476,-476,-476,-476',
-'-476,-476,-476,-476,-476,-476,899,-578,-476,-476,-476,-491,-476,-476',
-'564,563,-476,597,-91,-476,-476,597,-476,994,-476,-100,-476,-100,-476',
-'-476,597,-476,-476,-476,-476,-476,597,-476,-479,-476,959,-487,599,598',
-'613,-479,-479,-479,-487,121,-479,-479,-479,-476,-479,113,-476,-476,-476',
-'-476,112,-476,-479,-476,-479,-479,-479,-98,-476,210,527,-578,212,526',
-'-479,-479,211,-479,-479,-479,-479,-479,599,598,584,209,599,598,602,597',
-'218,939,747,981,388,599,598,600,-572,-575,585,599,598,595,-574,-479',
-'-479,-479,-479,-479,-479,-479,-479,-479,-479,-479,-479,-479,-479,-96',
-'260,-479,-479,-479,-578,-479,-479,261,-105,-479,682,-578,-479,-479,109',
-'-479,-574,-479,756,-479,-578,-479,-479,515,-479,-479,-479,-479,-479',
-'959,-479,-479,-479,1013,599,598,604,-484,-479,-578,238,-291,527,-572',
-'-484,529,-479,-479,-291,-479,-479,-479,-479,-575,-479,-578,-479,-291',
-'837,806,1014,-479,-578,-578,-578,-90,-572,-578,-578,-578,-95,-578,235',
-'1015,-99,977,237,236,-481,-104,-578,-578,-578,-578,396,-481,-483,214',
-'215,398,397,-578,-578,-483,-578,-578,-578,-578,-578,548,-479,545,544',
-'543,576,546,548,-479,545,544,543,577,546,548,-263,545,544,543,238,546',
-'575,218,-578,-578,-578,-578,-578,-578,-578,-578,-578,-578,-578,-578',
-'-578,-578,553,701,-578,-578,-578,584,772,-578,701,218,-578,556,583,-578',
-'-578,701,-578,704,-578,218,-578,585,-578,-578,704,-578,-578,-578,-578',
-'-578,-488,-578,-578,-578,214,215,548,-488,545,544,543,238,546,238,564',
-'563,-488,-578,516,557,-578,-578,-578,-578,-489,-578,218,-578,214,215',
-'-83,-489,-101,290,69,70,71,9,57,666,-489,986,63,64,701,218,512,67,987',
-'65,66,68,30,31,72,73,520,985,238,677,263,29,28,27,101,100,102,103,741',
-'742,19,238,743,107,108,635,8,45,292,10,105,104,106,95,56,97,96,98,977',
-'99,107,108,218,91,92,682,42,43,41,238,242,247,248,249,244,246,254,255',
-'250,251,517,231,232,-281,683,252,253,518,40,685,-281,33,272,689,58,59',
-'442,692,60,-281,35,235,693,241,44,237,236,695,233,234,245,243,239,20',
-'240,697,699,509,89,79,82,83,-489,84,86,85,87,707,708,-489,709,80,88',
-'711,256,574,-240,718,-489,62,502,81,93,94,290,69,70,71,9,57,501,218',
-'-292,63,64,736,530,746,67,-292,65,66,68,30,31,72,73,531,-292,750,751',
-'-264,29,28,27,101,100,102,103,-68,498,19,757,490,488,477,635,8,45,292',
-'10,105,104,106,95,56,97,96,98,486,99,107,108,977,91,92,477,42,43,41',
-'238,242,247,248,249,244,246,254,255,250,251,-291,231,232,-488,477,252',
-'253,-291,40,217,-488,33,-575,446,58,59,-291,218,60,-488,35,235,490,241',
-'44,237,236,218,233,234,245,243,239,20,240,445,257,443,89,79,82,83,507',
-'84,86,85,87,488,490,508,799,80,88,677,256,218,637,634,506,62,263,81',
-'93,94,290,69,70,71,9,57,977,263,-334,63,64,677,238,806,67,-334,65,66',
-'68,30,31,72,73,218,-334,263,218,399,29,28,27,101,100,102,103,831,218',
-'19,806,841,218,624,620,8,45,292,10,105,104,106,95,56,97,96,98,623,99',
-'107,108,218,91,92,619,42,43,41,238,242,247,248,249,244,246,254,255,250',
-'251,-291,231,232,-281,218,252,253,-291,40,386,-281,33,-575,850,58,59',
-'-291,-263,60,-281,35,235,617,241,44,237,236,614,233,234,245,243,239',
-'20,240,-265,579,859,89,79,82,83,584,84,86,85,87,578,899,939,959,80,88',
-'218,256,317,861,862,585,62,692,81,93,94,290,69,70,71,9,57,865,867,-292',
-'63,64,869,871,218,67,-292,65,66,68,30,31,72,73,873,-292,874,877,316',
-'29,28,27,101,100,102,103,879,936,19,545,544,543,880,546,8,45,292,10',
-'105,104,106,95,56,97,96,98,677,99,107,108,882,91,92,886,42,43,41,238',
-'242,247,248,249,244,246,254,255,250,251,440,231,232,888,891,252,253',
-'441,40,692,893,33,895,897,58,59,442,899,60,899,35,235,218,241,44,237',
-'236,905,233,234,245,243,239,20,240,907,909,257,89,79,82,83,915,84,86',
-'85,87,213,918,218,922,80,88,-266,256,933,208,940,941,62,207,81,93,94',
-'290,69,70,71,9,57,206,950,,63,64,,,,67,,65,66,68,30,31,72,73,116,117',
-'118,119,120,29,28,27,101,100,102,103,,936,19,545,544,543,,546,8,45,292',
-'10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247',
-'248,249,244,246,254,255,250,251,,231,232,,,252,253,,40,,,33,,,58,59',
-',,60,,35,235,,241,44,237,236,,233,234,245,243,239,20,240,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,256,,,,,62,,81,93,94,290,69,70,71,9,57,,',
-',63,64,,,,67,,65,66,68,30,31,72,73,116,117,118,119,120,29,28,27,101',
-'100,102,103,,,19,116,117,118,119,120,8,45,292,10,105,104,106,95,56,97',
-'96,98,,99,107,108,,91,92,,42,43,41,238,242,247,248,249,244,246,254,255',
-'250,251,,231,232,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237',
-'236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88',
-',256,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30',
-'31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247,248,249',
-'244,246,254,255,250,251,,231,232,,,252,253,,40,,,33,,,58,59,,,60,,35',
-'235,,241,44,237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,256,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,',
-'67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45',
-'292,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242',
-'247,248,249,244,246,254,255,250,251,,231,232,,,252,253,,40,,,294,,,58',
-'59,,,60,,35,235,,241,44,237,236,,233,234,245,243,239,20,240,,,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,218,256,,,,,62,,81,93,94,290,69,70,71,9',
-'57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103',
-',,19,,,,,,8,45,292,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92',
-',42,43,41,238,242,247,248,249,244,246,254,255,250,251,,231,232,,,252',
-'253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236,,233,234,245,243,239',
-'20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,256,,,,,62,,81,93,94,5',
-'69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,19,,,,,,8,45,7,10,105,104,106,95,56,97,96,98,,99,107,108',
-',91,92,,42,43,41,238,242,247,248,249,244,246,254,255,250,251,,231,232',
-',,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236,,233,234,245',
-'243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,256,,,,,62,,81',
-'93,94,5,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28',
-'27,101,100,102,103,,,19,,,,,,8,45,7,10,105,104,106,95,56,97,96,98,,99',
-'107,108,,91,92,,42,43,41,238,242,247,248,249,244,246,254,255,250,251',
-',231,232,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236,,233',
-'234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,256,,',
-',,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73',
-',,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95,56',
-'97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247,248,249,244,246,254',
-'255,250,251,,231,232,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44',
-'237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,',
-'80,88,,256,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66',
-'68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247,248',
-'249,244,246,254,255,250,251,,231,232,,,252,253,,40,,,33,,,58,59,,,60',
-',35,235,,241,44,237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,',
-'84,86,85,87,,,,,80,88,,256,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63',
-'64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,',
-',,,8,45,292,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,238,242,247,248,249,244,246,254,255,250,251,,231,232,,,252,253,,40',
-',,33,,,58,59,,,60,,35,235,,241,44,237,236,,233,234,245,243,239,20,240',
-',,,89,79,82,83,,84,86,85,87,,,,,80,88,,256,,,,,62,,81,93,94,290,69,70',
-'71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102',
-'103,,,19,,,,,,8,45,292,10,105,104,106,95,56,97,96,98,,99,107,108,,91',
-'92,,42,43,41,238,242,247,248,249,244,246,254,255,250,251,,231,232,,',
-'252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236,,233,234,245,243',
-'239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,256,,,,,62,,81,93',
-'94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28',
-'27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95,56,97,96,98',
-',99,107,108,,91,92,,42,43,41,238,242,247,248,249,244,246,254,255,250',
-'251,,231,232,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236',
-',233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,256',
-',,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72',
-'73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247,248,249,244,246',
-'254,255,250,251,,231,232,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241',
-'44,237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,',
-',,,80,88,,256,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65',
-'66,68,30,31,72,73,,553,,,,29,28,27,101,100,102,103,556,548,19,545,544',
-'543,,546,8,45,292,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,',
-'42,43,41,238,,564,563,,,238,557,701,548,,545,544,543,,546,,904,,40,',
-',33,,,58,59,,,60,,35,235,,,44,237,236,235,233,234,,237,236,20,233,234',
-'701,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62,,81,93,94,290,69,70',
-'71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102',
-'103,,548,19,545,544,543,,546,8,45,292,10,105,104,106,95,56,97,96,98',
-',99,107,108,,91,92,,42,43,41,238,,,548,,545,544,543,701,546,,,,,,,252',
-'253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236,,233,234,701,,239',
-'20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62,,81,93,94,290',
-'69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,42,43,41,238,,,,,,,,,,,,,,,,252,253,,40,,,33,,,58,59,,,60',
-',35,235,,241,44,237,236,,233,234,,,239,20,240,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67',
-',65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292',
-'10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247',
-'248,249,244,246,,,250,251,,,,,,252,253,,40,,,33,,,58,59,,,60,,35,235',
-',241,44,237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85',
-'87,,,,,80,88,,,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10',
-'105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247',
-'248,249,244,246,254,255,250,251,,-597,-597,,,252,253,,40,,,33,,,58,59',
-',,60,,35,235,,241,44,237,236,,233,234,245,243,239,20,240,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63',
-'64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,',
-',,,8,45,292,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,238,,,,,,,,,,,,,,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44',
-'237,236,,233,234,,,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88',
-',,,,,,62,,81,93,94,5,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72',
-'73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,7,10,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,238,-597,-597,-597,-597,244',
-'246,,,-597,-597,,,,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237',
-'236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88',
-',,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31',
-'72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106',
-'95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247,248,249,244',
-'246,254,255,250,251,,-597,-597,,,252,253,,40,,,33,,,58,59,,,60,,35,235',
-',241,44,237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85',
-'87,,,,,80,88,,,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10',
-'105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,,,,,,,,',
-',,,,,,,252,253,,40,,,294,,,58,59,,,60,,35,235,,241,44,237,236,,233,234',
-',,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62,,81,93,94',
-'290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27',
-'101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95,56,97,96,98,,99',
-'107,108,,91,92,,42,43,41,238,-597,-597,-597,-597,244,246,,,-597,-597',
-',,,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236,,233,234',
-'245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62,,81',
-'93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29',
-'28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95,56,97,96',
-'98,,99,107,108,,91,92,,42,43,41,238,-597,-597,-597,-597,244,246,,,-597',
-'-597,,,,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236,,233',
-'234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62',
-',81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,',
-',,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95,56,97',
-'96,98,,99,107,108,,91,92,,42,43,41,238,-597,-597,-597,-597,244,246,',
-',-597,-597,,,,,,252,253,,40,,,33,,,58,59,,,60,,35,235,,241,44,237,236',
-',233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,',
-',,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72',
-'73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,238,-597,-597,-597,-597,244',
-'246,,,-597,-597,,,,,,252,253,,40,,,294,,,58,59,,,60,,35,235,,241,44',
-'237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,',
-'80,88,,,,,,,62,,81,93,94,290,69,70,71,9,57,,,,63,64,,,,67,,65,66,68',
-'30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,292,10,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,242,247,248',
-'249,244,246,254,,250,251,,,,,,252,253,,40,,,33,,,58,59,,,60,,35,235',
-',241,44,237,236,,233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85',
-'87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31',
-'72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95,56',
-'97,96,98,,99,107,108,,91,92,,42,43,41,238,-597,-597,-597,-597,244,246',
-',,-597,-597,,,,,,252,253,,223,,,229,,,58,59,,,60,,,235,,241,44,237,236',
-',233,234,245,243,239,20,240,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,',
-',69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28',
-'27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,42,43,41,238,,,,,,,,,,,,,,,,252,253,,223,,,229,,,58,59,',
-',60,,,235,,241,44,237,236,,233,234,,,,20,,,,,89,79,82,83,,84,86,85,87',
-',,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72',
-'73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95,56,97',
-'96,98,,99,107,108,,91,92,,42,43,41,238,,,,,,,,,,,,,,,,252,253,,223,',
-',229,,,58,59,,,60,,,235,,241,44,237,236,,233,234,,,,20,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,238,,,,,,,,,,,,',
-',,,252,253,,223,,,229,,,58,59,,,60,,,235,,,44,237,236,,233,234,,,,20',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62,,81,93,94,69,70,71,9',
-'57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103',
-',,19,,,,,,8,45,,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42',
-'43,41,,,,,,,,,,,,,,,,,,,,40,,,33,,,58,59,,,60,,35,,,,44,,,,,,,,,20,',
-',,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,',
-',,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,',
-',,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,404,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84',
-'86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68',
-'30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105,104,106',
-'95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,',
-',229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,',
-',,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73',
-',,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97',
-'96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,',
-',58,59,,,60,,281,,279,,44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85',
-'87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310',
-'72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106',
-'95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,',
-',229,,,58,59,,,60,,404,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87',
-',,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,,303,,,299,',
-',58,59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,',
-',69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28',
-'27,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,',
-'44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62',
-'57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100',
-'102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91',
-'92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,404,,,,44,,',
-',,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81',
-'93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103',
-',,19,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,',
-'89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30',
-'31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229',
-',,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86,85,87,,,,,80',
-'88,218,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73',
-',,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105,104,106,95,56',
-'97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,,303,,,299,,,58',
-'59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69',
-'70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306',
-'312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99',
-'107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,',
-',,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71',
-'62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312',
-'101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,',
-'44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62',
-'57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,',
-',,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57',
-'81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100',
-'102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91',
-'92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,',
-',,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93',
-'94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102',
-'103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,',
-'42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,',
-',89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230',
-',,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,',
-',,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89',
-'79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,',
-'67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,',
-',,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,',
-',,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45',
-',,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,',
-',,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83',
-',84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66',
-'68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309',
-'310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223',
-',,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87',
-',,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229',
-',,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80',
-'88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,',
-',,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97',
-'96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58',
-'59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,',
-',,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305',
-'306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98',
-',99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,',
-'60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69',
-'70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306',
-'312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99',
-'107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,',
-',,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71',
-'62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312',
-'101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,',
-'44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62',
-'57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,',
-',,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57',
-'81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100',
-'102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91',
-'92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,',
-',,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93',
-'94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102',
-'103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,',
-'42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,',
-',89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230',
-',,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,',
-',,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89',
-'79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,',
-'67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,',
-',,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,',
-',,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45',
-',,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,',
-',,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83',
-',84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66',
-'68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309',
-'310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223',
-',,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87',
-',,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229',
-',,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80',
-'88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,',
-',,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97',
-'96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58',
-'59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,',
-',,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29',
-'28,27,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99',
-'107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,',
-',,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71',
-'62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100',
-'102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108,',
-'91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,279',
-',44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70',
-'71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,279',
-',44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70',
-'71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,279',
-',44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85,87,,,,,80,88,218,,,69',
-'70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27',
-'101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,',
-'44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62',
-'57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100',
-'102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91',
-'92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,',
-',,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93',
-'94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,',
-',230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,',
-',89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230',
-',,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,',
-',,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89',
-'79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,',
-'67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45',
-',,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,',
-',,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83',
-',84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66',
-'68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309',
-'310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223',
-',,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87',
-',,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229',
-',,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80',
-'88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,',
-',,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97',
-'96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,',
-',58,59,,,60,,,,279,,44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85,87',
-',,,,80,88,,,,,,,62,,81,93,94,69,70,71,9,57,,,,63,64,,,,67,,65,66,68',
-'30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,8,45,,10,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,40',
-',,33,,,58,59,,,60,,35,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86,85,87',
-',,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,',
-',229,,,58,59,,,60,,659,,279,,44,,,285,,,,,,228,,,,,89,282,82,83,,84',
-'86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68',
-'309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309',
-'310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223',
-',,229,,,58,59,,,60,,754,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85',
-'87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31',
-'72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,',
-',229,,,58,59,,,60,,281,,279,,44,,,285,,,,,,228,,,,,89,282,82,83,,84',
-'86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68',
-'30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105,104,106',
-'95,56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223',
-',,229,,,58,59,,,60,,281,,279,,44,,,285,,,,,,228,,,,,89,282,82,83,,84',
-'86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68',
-'309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,',
-'303,,,229,,,58,59,,,60,,548,,545,544,543,553,546,,,,,,,,,,556,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,,,,504,,551,62,,81,93,94,69,70,71,,57,564',
-'563,,63,64,557,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100',
-'102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91',
-'92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,,,44,,',
-',,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81',
-'93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102',
-'103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,',
-'42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108,,91,92,,42',
-'43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,285,,,,,,228',
-',,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108,,91,92,,42',
-'43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,659,,,,44,,,285,,,',
-',,228,,,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93',
-'94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,',
-',19,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,',
-'89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230',
-',,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,',
-',,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89',
-'79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,',
-'67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,',
-',,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,',
-',,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',307,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,',
-',,,,,,,,,,,303,,,299,,,58,59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82,83,,84',
-'86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68',
-'30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105,104,106',
-'95,56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223',
-',,229,,,58,59,,,60,,281,,279,,44,,,285,,,,,,228,,,,,89,282,82,83,,84',
-'86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68',
-'309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,',
-'303,,,299,,,58,59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,',
-',,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,,303,,,299,',
-',58,59,,,60,,548,,545,544,543,553,546,,,,,,,,,,556,,89,79,82,83,,84',
-'86,85,87,,,,,80,88,,,,,,551,62,,81,93,94,69,70,71,9,57,564,563,,63,64',
-'557,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,',
-',,,8,45,292,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,40,,,33,,,58,59,,,60,,35,,,,44,,,,,,,,,20,,,,',
-'89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,388,62,,81,93,94,69,70,71,,57',
-',,,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102',
-'103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,',
-'42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,520,,58,59,,,60,,,,,,44,,,,,,,,,228',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,',
-',,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,',
-',,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',45,,,105,104,106,95,56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,',
-',,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,279,,44,,,285,,,,,,228,,,',
-',89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230',
-',,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108,,91,92,,42,43,41',
-',,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,659,,279,,44,,,285,,,,,,228',
-',,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,',
-',89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230',
-',,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,',
-',,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89',
-'79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,',
-'67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,',
-',,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,',
-',,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,',
-',,,,,,223,,,229,,,58,59,,,60,,281,,279,,44,,,285,,,,,,228,,,,,89,282',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30',
-'31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229',
-',,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86,85,87,,,,,80',
-'88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,',
-',29,28,27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95,56,97,96,98',
-',99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,',
-'60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70',
-'71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,19,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,',
-'91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,',
-',,,,,,20,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62,,81,93,94,69',
-'70,71,9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100',
-'102,103,,,19,,,,,,8,45,7,10,105,104,106,95,56,97,96,98,,99,107,108,',
-'91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,40,,,33,,,58,59,,,60,,35,,,,44,,',
-',,,,,,20,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81',
-'93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102',
-'103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,',
-'42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,307,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,,,313',
-',,,,,,,,,,,,,,,,,,,947,,,229,,,58,59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,307',
-',,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,',
-',,,,,,876,,,229,,,58,59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85',
-'87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310',
-'72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106',
-'95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,',
-',229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,',
-',,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,',
-',229,,,58,59,,,60,,,,279,,44,,,285,,,,,,228,,,,,89,282,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309',
-'310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45,,,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223',
-',,229,,,58,59,,,60,,659,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85',
-'87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31',
-'72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229',
-',,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80',
-'88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,',
-',29,28,27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95,56,97,96,98',
-',99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,',
-'60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70',
-'71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,279',
-',44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70',
-'71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,279',
-',44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70',
-'71,62,57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,279',
-',44,,,285,,,,,,228,,,,,89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70',
-'71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312',
-'101,100,102,103,,,230,,,,,,,307,,,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,,303,,,299,,,58,59,,,60,,298,,,',
-',,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81',
-'93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102',
-'103,,,230,,,,,,,307,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92',
-',,,313,,,,,,,,,,,,,,,,,,,,303,,,229,,,58,59,,,60,,548,,545,544,543,553',
-'546,,,,,,,,,,556,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,315,,551,62',
-',81,93,94,69,70,71,,57,564,563,,63,64,557,,,67,,65,66,68,309,310,72',
-'73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,,876,,,229,',
-',58,59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,',
-',69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305',
-'306,312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98',
-',99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,',
-'60,,,,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69',
-'70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306',
-'312,101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99',
-'107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,',
-',,,,44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71',
-'62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312',
-'101,100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107',
-'108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,',
-'44,,,,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62',
-'57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101',
-'100,102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108',
-',91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,',
-',,,,,,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57',
-'81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100',
-'102,103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91',
-'92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,',
-',,,228,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93',
-'94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102',
-'103,,,230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,',
-'42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228',
-',,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63',
-'64,,,,67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,',
-'230,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43',
-'41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,',
-',89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,',
-',,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,',
-',,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,230,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,',
-',,,,,,223,,,229,,,58,59,,,60,,281,,279,,44,,,285,,,,,,228,,,,,89,282',
-'82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67',
-',65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,228,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,45',
-',,105,104,106,95,56,97,96,98,284,99,107,108,,91,92,,42,43,41,,,,,,,',
-',,,,,,,,,,,,223,,,229,,,58,59,,,60,,281,,,,44,,,285,,,,,,228,,,,,89',
-'282,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,',
-',67,,65,66,68,309,310,72,73,,,,,,305,306,312,101,100,102,103,,,230,',
-',,,,,45,,,105,104,106,95,56,97,96,98,284,99,107,108,,91,92,,42,43,41',
-',,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,285,,,,,,228,,,',
-',89,282,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64',
-',,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,',
-',45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,',
-',,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82',
-'83,,84,86,85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65',
-'66,68,30,31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105',
-'104,106,95,56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,',
-',,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86',
-'85,87,,,,,80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,30',
-'31,72,73,,,,,,29,28,27,101,100,102,103,,,19,,,,,,,45,,,105,104,106,95',
-'56,97,96,98,,99,107,108,,91,92,,42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229',
-',,58,59,,,60,,,,,,44,,,,,,,,,20,,,,,89,79,82,83,,84,86,85,87,,,,,80',
-'88,113,,,,,112,62,,81,93,94,69,70,71,,57,,,,63,64,,,,67,,65,66,68,309',
-'310,72,73,,,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105,104',
-'106,95,56,97,96,98,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,,348',
-',,33,,,58,59,,,60,,35,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,,,,',
-'80,88,,,,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73',
-',,,,,305,306,312,101,100,102,103,,,230,,,,,,,307,,,105,104,106,353,56',
-'97,96,354,,99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,360,,,355,,,229',
-',,58,59,,,60,,,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,',
-',,69,70,71,62,57,81,93,94,63,64,,,,67,,65,66,68,309,310,72,73,,,,,,305',
-'306,312,101,100,102,103,,,230,,,,,,,307,,,105,104,106,353,56,97,96,354',
-',99,107,108,,91,92,,,,313,,,,,,,,,,,,,,,,,,,,355,,,229,,,58,59,,,60',
-',,,,,,,,,,,,,,,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,69,70,71,62',
-'57,81,93,94,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100',
-'102,103,,,19,,,,,,,45,,,105,104,106,95,56,97,96,98,,99,107,108,,91,92',
-',42,43,41,,,,,,,,,,,,,,,,,,,,223,,,229,,,58,59,,,60,,,,,,44,,,,,,,,',
-'20,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,,,62,,81,93,94,69,70,71',
-'9,57,,,,63,64,,,,67,,65,66,68,30,31,72,73,,,,,,29,28,27,101,100,102',
-'103,,,19,,,,,,8,45,7,10,105,104,106,95,56,97,96,98,,99,107,108,,91,92',
-',42,43,41,,,,,,,,,,,,,,,,,,,,40,,,33,,,58,59,,,60,,35,,,,44,,,,,,,,',
-'20,,,,,89,79,82,83,,84,86,85,87,,,,,80,88,,,,,-579,388,62,,81,93,94',
-'-579,-579,-579,,,-579,-579,-579,,-579,,,,,,,,,-579,-579,-579,-579,,',
-',,,,,-579,-579,,-579,-579,-579,-579,-579,,,,,,,,,,,,,,,,,,,,,,,,-579',
-'-579,-579,-579,-579,-579,-579,-579,-579,-579,-579,-579,-579,-579,,,-579',
-'-579,-579,,,-579,,,-579,,,-579,-579,,-579,,-579,,-579,,-579,-579,,-579',
-'-579,-579,-579,-579,,-579,-579,-579,,,,,,,,,,,,,,-579,,,-579,-579,-579',
-'-579,-282,-579,,-579,,,,-282,-282,-282,,,-282,-282,-282,,-282,,,,,,',
-',,,-282,-282,-282,,,,,,,,-282,-282,,-282,-282,-282,-282,-282,,,,,,,',
-',,,,,,,,,,,,,,,,-282,-282,-282,-282,-282,-282,-282,-282,-282,-282,-282',
-'-282,-282,-282,,,-282,-282,-282,,,-282,,,-282,,,-282,-282,,-282,,-282',
-',-282,,-282,-282,,-282,-282,-282,-282,-282,,-282,,-282,,,,,,,,,,,,,',
-'-282,,,-282,-282,-282,-282,-580,-282,,-282,,,,-580,-580,-580,,,-580',
-'-580,-580,,-580,,,,,,,,,-580,-580,-580,-580,,,,,,,,-580,-580,,-580,-580',
-'-580,-580,-580,,,,,,,,,,,,,,,,,,,,,,,,-580,-580,-580,-580,-580,-580',
-'-580,-580,-580,-580,-580,-580,-580,-580,,,-580,-580,-580,,,-580,,,-580',
-',,-580,-580,,-580,,-580,,-580,,-580,-580,,-580,-580,-580,-580,-580,',
-'-580,-580,-580,,,,,,,,,,,,,,-580,,,-580,-580,-580,-580,-411,-580,,-580',
-',,,-411,-411,-411,,,-411,-411,-411,,-411,,,,,,,,,-411,-411,-411,,,,',
-',,,,-411,-411,,-411,-411,-411,-411,-411,,,,,,,,,,,,,,,,,,,,,,,,-411',
-'-411,-411,-411,-411,-411,-411,-411,-411,-411,-411,-411,-411,-411,,,-411',
-'-411,-411,,,-411,,263,-411,,,-411,-411,,-411,,-411,,-411,,-411,-411',
-',-411,-411,-411,-411,-411,,-411,-411,-411,,,,,,,,,,,,,,-411,,-246,-411',
-'-411,,-411,,-411,-246,-246,-246,,,-246,-246,-246,548,-246,545,544,543',
-'553,546,,,,-246,-246,,,,,556,,,,,-246,-246,,-246,-246,-246,-246,-246',
-',,,,,,,,,551,,,,,,,,,561,560,564,563,,,,557,,,,,,,,,-246,,-298,,,,,-246',
-',-298,-298,-298,263,-246,-298,-298,-298,218,-298,,,,,,,,,,-298,-298',
-',,,,,-246,-246,,-298,-298,,-298,-298,-298,-298,-298,,,,,-246,,,-246',
-',,,,-246,,,,,,,,,,,-298,-298,-298,-298,-298,-298,-298,-298,-298,-298',
-'-298,-298,-298,-298,,,-298,-298,-298,,,-298,,272,-298,,,-298,-298,,-298',
-',-298,,-298,,-298,-298,,-298,-298,-298,-298,-298,,-298,-246,-298,,,',
-',,-246,-246,-246,,,-246,-246,-246,-298,-246,,-298,-298,,-298,,-298,',
-'-246,-246,-246,,,,,,,,,-246,-246,,-246,-246,-246,-246,-246,,,,,,,,,',
-',,,,,,,,,,,,,,-246,-246,-246,-246,-246,-246,-246,-246,-246,-246,-246',
-'-246,-246,-246,,,-246,-246,-246,,,-246,,263,-246,,,-246,-246,,-246,',
-'-246,,-246,,-246,-246,,-246,-246,-246,-246,-246,,-246,-246,-246,,,,',
-',,,,,,,,,-246,,,-246,-246,,-246,,-246,173,184,174,197,170,190,180,179',
-'200,201,195,178,177,172,198,202,203,182,171,185,189,191,183,176,,,,192',
-'199,194,193,186,196,181,169,188,187,,,,,,168,175,166,167,163,164,165',
-'124,126,,,125,,,,,,,,,157,158,,154,136,137,138,145,142,144,,,139,140',
-',,,159,160,146,147,,,,,,,,,,,,,,151,150,,135,156,153,152,161,148,149',
-'143,141,133,155,134,,,162,89,,,,,,,,,,,,,,88,173,184,174,197,170,190',
-'180,179,200,201,195,178,177,172,198,202,203,182,171,185,189,191,183',
-'176,,,,192,199,194,193,186,196,181,169,188,187,,,,,,168,175,166,167',
-'163,164,165,124,126,123,,125,,,,,,,,,157,158,,154,136,137,138,145,142',
-'144,,,139,140,,,,159,160,146,147,,,,,,,,,,,,,,151,150,,135,156,153,152',
-'161,148,149,143,141,133,155,134,,,162,89,,,,,,,,,,,,,,88,173,184,174',
-'197,170,190,180,179,200,201,195,178,177,172,198,202,203,182,171,185',
-'189,191,183,176,,,,192,199,194,193,186,196,181,169,188,187,,,,,,168',
-'175,166,167,163,164,165,124,126,,,125,,,,,,,,,157,158,,154,136,137,138',
-'145,142,144,,,139,140,,,,159,160,146,147,,,,,,,,,,,,,,151,150,,135,156',
-'153,152,161,148,149,143,141,133,155,134,,,162,89,,,,,,,,,,,,,,88,173',
-'184,174,197,170,190,180,179,200,201,195,178,177,172,198,202,203,182',
-'171,185,189,191,183,176,,,,192,199,194,193,186,196,181,169,188,187,',
-',,,,168,175,166,167,163,164,165,124,126,,,125,,,,,,,,,157,158,,154,136',
-'137,138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,,,,,,,,,151,150',
-',135,156,153,152,161,148,149,143,141,133,155,134,,,162,89,,,,,,,,,,',
-',,,88,173,184,174,197,170,190,180,179,200,201,195,178,177,172,198,202',
-'203,182,171,185,189,191,183,176,,,,192,199,194,193,186,196,181,169,188',
-'187,,,,,,168,175,166,167,163,164,165,124,126,,,125,,,,,,,,,157,158,',
-'154,136,137,138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,,,,,,',
-',,151,150,,135,156,153,152,161,148,149,143,141,133,155,134,,,162,173',
-'184,174,197,170,190,180,179,200,201,195,178,177,172,198,202,203,182',
-'171,185,189,191,183,176,,,,192,199,194,371,370,372,369,169,188,187,',
-',,,,168,175,166,167,366,367,368,364,126,97,96,365,,99,,,,,,,157,158',
-',154,136,137,138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,376,',
-',,,,,,151,150,,135,156,153,152,161,148,149,143,141,133,155,134,673,424',
-'162,,674,,,,,,,,,157,158,,154,136,137,138,145,142,144,,,139,140,,,,159',
-'160,146,147,,,,,,263,,,,,,,,151,150,,135,156,153,152,161,148,149,143',
-'141,133,155,134,1008,424,162,,1009,,,,,,,,,157,158,,154,136,137,138',
-'145,142,144,,,139,140,,,,159,160,146,147,,,,,,263,,,,,,,,151,150,,135',
-'156,153,152,161,148,149,143,141,133,155,134,640,424,162,,641,,,,,,,',
-',157,158,,154,136,137,138,145,142,144,,,139,140,,,,159,160,146,147,',
-',,,,263,,,,,,,,151,150,,135,156,153,152,161,148,149,143,141,133,155',
-'134,638,417,162,,639,,,,,,,,,157,158,,154,136,137,138,145,142,144,,',
-'139,140,,,,159,160,146,147,,,,,,263,,,,,,,,151,150,,135,156,153,152',
-'161,148,149,143,141,133,155,134,670,417,162,,671,,,,,,,,,157,158,,154',
-'136,137,138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,263,,,,,,',
-',151,150,,135,156,153,152,161,148,149,143,141,133,155,134,721,417,162',
-',722,,,,,,,,,157,158,,154,136,137,138,145,142,144,,,139,140,,,,159,160',
-'146,147,,,,,,263,,,,,,,,151,150,,135,156,153,152,161,148,149,143,141',
-'133,155,134,723,424,162,,724,,,,,,,,,157,158,,154,136,137,138,145,142',
-'144,,,139,140,,,,159,160,146,147,,,,,,263,,,,,,,,151,150,,135,156,153',
-'152,161,148,149,143,141,133,155,134,983,424,162,,982,,,,,,,,,157,158',
-',154,136,137,138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,263,',
-',,,,,,151,150,,135,156,153,152,161,148,149,143,141,133,155,134,726,424',
-'162,,727,,,,,,,,,157,158,,154,136,137,138,145,142,144,,,139,140,,,,159',
-'160,146,147,,,,,,263,,,,,,,,151,150,,135,156,153,152,161,148,149,143',
-'141,133,155,134,638,417,162,,639,,,,,,,,,157,158,,154,136,137,138,145',
-'142,144,,,139,140,,,,159,160,146,147,,,,,,263,,,,,,,,151,150,,135,156',
-'153,152,161,148,149,143,141,133,155,134,475,417,162,,476,,,,,,,,,157',
-'158,,154,136,137,138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,263',
-',,,,,,,151,150,,135,156,153,152,161,148,149,143,141,133,155,134,640',
-'424,162,,641,,,,,,,,,157,158,,154,136,137,138,145,142,144,,,139,140',
-',,,159,160,146,147,,,,,,263,,,,,,,,151,150,,135,156,153,152,161,148',
-'149,143,141,133,155,134,475,417,162,,476,,,,,,,,,157,158,,154,136,137',
-'138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,,,,,,,,,151,150,,135',
-'156,153,152,161,148,149,143,141,133,155,134,413,417,162,,414,,,,,,,',
-',157,158,,154,136,137,138,145,142,144,,,139,140,,,,159,160,146,147,',
-',,,,263,,,,,,,,151,150,,135,156,153,152,161,148,149,143,141,133,155',
-'134,1006,417,162,,1007,,,,,,,,,157,158,,154,136,137,138,145,142,144',
-',,139,140,,,,159,160,146,147,,,,,,263,,,,,,,,151,150,,135,156,153,152',
-'161,148,149,143,141,133,155,134,420,424,162,,419,,,,,,,,,157,158,,154',
-'136,137,138,145,142,144,,,139,140,,,,159,160,146,147,,,,,,263,,,,,,',
-',151,150,,135,156,153,152,161,148,149,143,141,133,155,134,,548,162,545',
-'544,543,553,546,,548,,545,544,543,553,546,,556,548,,545,544,543,553',
-'546,556,548,,545,544,543,553,546,,556,,,,,551,,,556,,,,,551,561,560',
-'564,563,,,,557,551,534,564,563,,,,557,551,561,560,564,563,,,,557,561',
-'560,564,563,,,548,557,545,544,543,553,546,548,,545,544,543,553,546,',
-'548,556,545,544,543,553,546,,556,,,,,,,548,556,545,544,543,553,546,',
-'551,,,,,,,551,556,,,564,563,,,551,557,,564,563,,,,557,561,560,564,563',
-',,551,557,548,,545,544,543,553,546,561,560,564,563,,,,557,548,556,545',
-'544,543,553,546,,548,,545,544,543,553,546,,556,,,,,,,551,556,548,,545',
-'544,543,553,546,561,560,564,563,,,551,557,,556,,,,,551,561,560,564,563',
-',,,557,561,560,564,563,,,,557,551,548,,545,544,543,553,546,,561,560',
-'564,563,,,,557,556,548,,545,544,543,553,546,548,,545,544,543,553,546',
-',,556,,,,,551,,556,548,,545,544,543,553,546,,564,563,,,,557,551,,556',
-',,,,551,,561,560,564,563,,,,557,,564,563,,,,557,551,548,,545,544,543',
-'553,546,,,,564,563,,,,557,556,,,,,,,,,,,,,,,,,,,,,,551,,,,,,,,,,,564',
-'563,,,,557' ]
- racc_action_table = arr = ::Array.new(25310, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'641,339,1007,1006,774,844,890,641,641,641,38,908,641,641,641,19,641',
-'359,590,590,906,58,437,437,594,594,641,641,641,349,1020,345,724,996',
-'996,308,641,641,383,641,641,641,641,641,338,719,722,885,3,721,845,1008',
-'650,3,665,687,19,38,371,342,774,58,346,665,342,371,38,641,641,641,641',
-'641,641,641,641,641,641,641,641,641,641,671,578,641,641,641,910,641',
-'641,571,384,641,723,570,641,641,61,641,724,641,308,641,911,641,641,383',
-'641,641,641,641,641,917,641,590,641,844,670,437,590,594,339,1007,1006',
-'308,359,339,1007,1006,641,1008,908,641,641,641,641,908,641,420,641,349',
-'650,345,724,641,420,420,420,359,671,1020,420,420,359,420,1020,845,722',
-'384,723,721,845,481,420,338,719,687,885,719,338,719,1008,885,346,420',
-'420,1008,420,420,420,420,420,680,680,670,61,355,364,26,671,355,473,671',
-'578,364,571,921,481,221,570,571,671,343,723,570,420,420,420,420,420',
-'420,420,420,420,420,420,420,420,420,924,482,420,420,420,670,420,473',
-'670,39,420,853,414,420,651,927,853,670,420,443,420,928,420,420,353,420',
-'420,420,420,420,419,420,420,420,26,221,482,419,419,419,41,41,77,419',
-'419,366,419,420,929,651,420,420,366,420,77,420,39,26,680,414,930,492',
-'420,801,77,39,419,419,414,419,419,419,419,419,224,443,704,353,704,704',
-'704,607,704,332,353,913,332,913,904,353,904,904,904,353,904,313,313',
-'419,419,419,419,419,419,419,419,419,419,419,419,419,419,374,353,419',
-'419,419,801,419,374,41,41,419,932,801,419,382,492,492,492,419,224,419',
-'801,419,419,726,419,419,419,419,419,95,419,492,419,639,607,607,95,95',
-'95,801,947,95,95,95,607,95,419,704,329,419,419,329,419,95,419,95,95',
-'95,450,904,367,419,313,313,952,95,95,367,95,95,95,95,95,638,953,413',
-'726,509,382,382,382,385,589,726,509,954,288,589,726,639,450,288,726',
-'509,450,450,95,95,95,95,95,95,95,95,95,95,95,95,95,95,955,726,95,95',
-'95,222,95,95,692,692,95,605,413,95,95,380,95,956,95,638,95,413,95,95',
-'379,95,95,95,95,95,378,95,98,95,958,368,385,385,385,98,98,98,368,7,98',
-'98,98,95,98,848,95,95,95,95,848,95,98,95,98,98,98,222,95,14,328,673',
-'15,328,98,98,14,98,98,98,98,98,605,605,938,14,380,380,380,381,934,938',
-'605,934,344,379,379,379,354,982,938,378,378,378,983,98,98,98,98,98,98',
-'98,98,98,98,98,98,98,98,15,24,98,98,98,673,98,98,24,15,98,984,673,98',
-'98,1,98,673,98,621,98,673,98,98,317,98,98,98,98,98,995,98,354,98,997',
-'381,381,381,369,354,673,449,727,686,354,369,686,98,354,727,98,98,98',
-'98,727,98,640,98,727,710,710,998,98,640,640,640,621,354,640,640,640',
-'317,640,449,999,621,1000,449,449,370,317,640,640,640,640,123,370,372',
-'17,17,123,123,640,640,372,640,640,640,640,640,994,365,994,994,994,347',
-'994,701,365,701,701,701,347,701,551,807,551,551,551,454,551,347,479',
-'640,640,640,640,640,640,640,640,640,640,640,640,640,640,689,994,640',
-'640,640,357,640,640,701,483,640,689,357,640,640,551,640,701,640,326',
-'640,357,640,640,551,640,640,640,640,640,944,640,640,640,337,337,833',
-'944,833,833,833,321,833,453,689,689,944,640,318,689,640,640,640,640',
-'945,640,499,640,523,523,500,945,640,569,569,569,569,569,569,503,945',
-'946,569,569,833,505,314,569,946,569,569,569,569,569,569,569,510,946',
-'452,513,312,569,569,569,569,569,569,569,598,598,569,451,598,598,598',
-'432,569,569,569,569,569,569,569,569,569,569,569,569,1001,569,569,569',
-'307,569,569,521,569,569,569,432,432,432,432,432,432,432,432,432,432',
-'432,319,432,432,948,522,432,432,319,569,524,948,569,306,536,569,569',
-'319,537,569,948,569,432,539,432,569,432,432,540,432,432,432,432,432',
-'569,432,541,550,303,569,569,569,569,301,569,569,569,569,558,562,301',
-'565,569,569,567,432,572,432,573,301,569,297,569,569,569,566,566,566',
-'566,566,566,296,295,988,566,566,592,330,602,566,988,566,566,566,566',
-'566,566,566,331,988,610,612,618,566,566,566,566,566,566,566,293,292',
-'566,622,280,277,627,643,566,566,566,566,566,566,566,566,566,566,566',
-'566,276,566,566,566,1002,566,566,632,566,566,566,643,643,643,643,643',
-'643,643,643,643,643,643,1009,643,643,300,262,643,643,1009,566,230,300',
-'566,1009,226,566,566,1009,642,566,300,566,643,333,643,566,643,643,1005',
-'643,643,643,643,643,566,643,225,649,223,566,566,566,566,302,566,566',
-'566,566,656,658,302,664,566,566,667,643,669,439,429,302,566,672,566',
-'566,566,654,654,654,654,654,654,1022,675,46,654,654,676,679,681,654',
-'46,654,654,654,654,654,654,654,684,46,421,688,204,654,654,654,654,654',
-'654,654,703,705,654,712,717,720,412,408,654,654,654,654,654,654,654',
-'654,654,654,654,654,411,654,654,654,409,654,654,405,654,654,654,408',
-'408,408,408,408,408,408,408,408,408,408,674,408,408,304,729,408,408',
-'674,654,109,304,654,674,734,654,654,674,403,654,304,654,408,400,408',
-'654,408,408,394,408,408,408,408,408,654,408,753,350,758,654,654,654',
-'654,875,654,654,654,654,348,1010,875,1011,654,654,45,408,40,775,776',
-'875,654,777,654,654,654,653,653,653,653,653,653,779,780,581,653,653',
-'781,783,784,653,581,653,653,653,653,653,653,653,785,581,786,790,37,653',
-'653,653,653,653,653,653,794,873,653,873,873,873,795,873,653,653,653',
-'653,653,653,653,653,653,653,653,653,800,653,653,653,804,653,653,808',
-'653,653,653,760,760,760,760,760,760,760,760,760,760,760,220,760,760',
-'811,816,760,760,220,653,817,821,653,822,824,653,653,220,825,653,827',
-'653,760,830,760,653,760,760,832,760,760,760,760,760,653,760,835,838',
-'22,653,653,653,653,847,653,653,653,653,16,851,852,855,653,653,856,760',
-'872,13,876,878,653,12,653,653,653,648,648,648,648,648,648,10,889,,648',
-'648,,,,648,,648,648,648,648,648,648,648,6,6,6,6,6,648,648,648,648,648',
-'648,648,,981,648,981,981,981,,981,648,648,648,648,648,648,648,648,648',
-'648,648,648,,648,648,648,,648,648,,648,648,648,427,427,427,427,427,427',
-'427,427,427,427,427,,427,427,,,427,427,,648,,,648,,,648,648,,,648,,648',
-'427,,427,648,427,427,,427,427,427,427,427,648,427,,,,648,648,648,648',
-',648,648,648,648,,,,,648,648,,427,,,,,648,,648,648,648,849,849,849,849',
-'849,849,,,,849,849,,,,849,,849,849,849,849,849,849,849,291,291,291,291',
-'291,849,849,849,849,849,849,849,,,849,497,497,497,497,497,849,849,849',
-'849,849,849,849,849,849,849,849,849,,849,849,849,,849,849,,849,849,849',
-'519,519,519,519,519,519,519,519,519,519,519,,519,519,,,519,519,,849',
-',,849,,,849,849,,,849,,849,519,,519,849,519,519,,519,519,519,519,519',
-'849,519,,,,849,849,849,849,,849,849,849,849,,,,,849,849,,519,,,,,849',
-',849,849,849,229,229,229,229,229,229,,,,229,229,,,,229,,229,229,229',
-'229,229,229,229,,,,,,229,229,229,229,229,229,229,,,229,,,,,,229,229',
-'229,229,229,229,229,229,229,229,229,229,,229,229,229,,229,229,,229,229',
-'229,274,274,274,274,274,274,274,274,274,274,274,,274,274,,,274,274,',
-'229,,,229,,,229,229,,,229,,229,274,,274,229,274,274,,274,274,274,274',
-'274,229,274,,,,229,229,229,229,,229,229,229,229,,,,,229,229,,274,,,',
-',229,,229,229,229,33,33,33,33,33,33,,,,33,33,,,,33,,33,33,33,33,33,33',
-'33,,,,,,33,33,33,33,33,33,33,,,33,,,,,,33,33,33,33,33,33,33,33,33,33',
-'33,33,,33,33,33,,33,33,,33,33,33,644,644,644,644,644,644,644,644,644',
-'644,644,,644,644,,,644,644,,33,,,33,,,33,33,,,33,,33,644,,644,33,644',
-'644,,644,644,644,644,644,33,644,,,,33,33,33,33,,33,33,33,33,,,,,33,33',
-'644,644,,,,,33,,33,33,33,843,843,843,843,843,843,,,,843,843,,,,843,',
-'843,843,843,843,843,843,843,,,,,,843,843,843,843,843,843,843,,,843,',
-',,,,843,843,843,843,843,843,843,843,843,843,843,843,,843,843,843,,843',
-'843,,843,843,843,678,678,678,678,678,678,678,678,678,678,678,,678,678',
-',,678,678,,843,,,843,,,843,843,,,843,,843,678,,678,843,678,678,,678',
-'678,678,678,678,843,678,,,,843,843,843,843,,843,843,843,843,,,,,843',
-'843,,678,,,,,843,,843,843,843,121,121,121,121,121,121,,,,121,121,,,',
-'121,,121,121,121,121,121,121,121,,,,,,121,121,121,121,121,121,121,,',
-'121,,,,,,121,121,121,121,121,121,121,121,121,121,121,121,,121,121,121',
-',121,121,,121,121,121,755,755,755,755,755,755,755,755,755,755,755,,755',
-'755,,,755,755,,121,,,121,,,121,121,,,121,,121,755,,755,121,755,755,',
-'755,755,755,755,755,121,755,,,,121,121,121,121,,121,121,121,121,,,,',
-'121,121,,755,,,,,121,,121,121,121,498,498,498,498,498,498,,,,498,498',
-',,,498,,498,498,498,498,498,498,498,,,,,,498,498,498,498,498,498,498',
-',,498,,,,,,498,498,498,498,498,498,498,498,498,498,498,498,,498,498',
-'498,,498,498,,498,498,498,762,762,762,762,762,762,762,762,762,762,762',
-',762,762,,,762,762,,498,,,498,,,498,498,,,498,,498,762,,762,498,762',
-'762,,762,762,762,762,762,498,762,,,,498,498,498,498,,498,498,498,498',
-',,,,498,498,,762,,,,,498,,498,498,498,966,966,966,966,966,966,,,,966',
-'966,,,,966,,966,966,966,966,966,966,966,,,,,,966,966,966,966,966,966',
-'966,,,966,,,,,,966,966,966,966,966,966,966,966,966,966,966,966,,966',
-'966,966,,966,966,,966,966,966,765,765,765,765,765,765,765,765,765,765',
-'765,,765,765,,,765,765,,966,,,966,,,966,966,,,966,,966,765,,765,966',
-'765,765,,765,765,765,765,765,966,765,,,,966,966,966,966,,966,966,966',
-'966,,,,,966,966,,765,,,,,966,,966,966,966,745,745,745,745,745,745,,',
-',745,745,,,,745,,745,745,745,745,745,745,745,,,,,,745,745,745,745,745',
-'745,745,,,745,,,,,,745,745,745,745,745,745,745,745,745,745,745,745,',
-'745,745,745,,745,745,,745,745,745,767,767,767,767,767,767,767,767,767',
-'767,767,,767,767,,,767,767,,745,,,745,,,745,745,,,745,,745,767,,767',
-'745,767,767,,767,767,767,767,767,745,767,,,,745,745,745,745,,745,745',
-'745,745,,,,,745,745,,767,,,,,745,,745,745,745,206,206,206,206,206,206',
-',,,206,206,,,,206,,206,206,206,206,206,206,206,,,,,,206,206,206,206',
-'206,206,206,,,206,,,,,,206,206,206,206,206,206,206,206,206,206,206,206',
-',206,206,206,,206,206,,206,206,206,769,769,769,769,769,769,769,769,769',
-'769,769,,769,769,,,769,769,,206,,,206,,,206,206,,,206,,206,769,,769',
-'206,769,769,,769,769,769,769,769,206,769,,,,206,206,206,206,,206,206',
-'206,206,,,,,206,206,,769,,,,,206,,206,206,206,324,324,324,324,324,324',
-',,,324,324,,,,324,,324,324,324,324,324,324,324,,,,,,324,324,324,324',
-'324,324,324,,,324,,,,,,324,324,324,324,324,324,324,324,324,324,324,324',
-',324,324,324,,324,324,,324,324,324,21,21,21,21,21,21,21,21,21,21,21',
-',21,21,,,21,21,,324,,,324,,,324,324,,,324,,324,21,,21,324,21,21,,21',
-'21,21,21,21,324,21,,,,324,324,324,324,,324,324,324,324,,,,,324,324,',
-'21,,,,,324,,324,324,324,793,793,793,793,793,793,,,,793,793,,,,793,,793',
-'793,793,793,793,793,793,,,,,,793,793,793,793,793,793,793,,,793,,,,,',
-'793,793,793,793,793,793,793,793,793,793,793,793,,793,793,793,,793,793',
-',793,793,793,858,858,858,858,858,858,858,858,858,858,858,,858,858,,',
-'858,858,,793,,,793,,,793,793,,,793,,793,858,,858,793,858,858,,858,858',
-'858,858,858,793,858,,,,793,793,793,793,,793,793,793,793,,,,,793,793',
-',858,,,,,793,,793,793,793,882,882,882,882,882,882,,,,882,882,,,,882',
-',882,882,882,882,882,882,882,,,,,,882,882,882,882,882,882,882,,,882',
-',,,,,882,882,882,882,882,882,882,882,882,882,882,882,,882,882,882,,882',
-'882,,882,882,882,969,969,969,969,969,969,969,969,969,969,969,,969,969',
-',,969,969,,882,,,882,,,882,882,,,882,,882,969,,969,882,969,969,,969',
-'969,969,969,969,882,969,,,,882,882,882,882,,882,882,882,882,,,,,882',
-'882,,969,,,,,882,,882,882,882,840,840,840,840,840,840,,,,840,840,,,',
-'840,,840,840,840,840,840,840,840,,862,,,,840,840,840,840,840,840,840',
-'862,831,840,831,831,831,,831,840,840,840,840,840,840,840,840,840,840',
-'840,840,,840,840,840,,840,840,,840,840,840,468,,862,862,,,469,862,831',
-'905,,905,905,905,,905,,831,,840,,,840,,,840,840,,,840,,840,468,,,840',
-'468,468,469,468,468,,469,469,840,469,469,905,,840,840,840,840,,840,840',
-'840,840,,,,,840,840,,,,,,,840,,840,840,840,839,839,839,839,839,839,',
-',,839,839,,,,839,,839,839,839,839,839,839,839,,,,,,839,839,839,839,839',
-'839,839,,957,839,957,957,957,,957,839,839,839,839,839,839,839,839,839',
-'839,839,839,,839,839,839,,839,839,,839,839,839,460,,,959,,959,959,959',
-'957,959,,,,,,,460,460,,839,,,839,,,839,839,,,839,,839,460,,460,839,460',
-'460,,460,460,959,,460,839,460,,,,839,839,839,839,,839,839,839,839,,',
-',,839,839,,,,,,,839,,839,839,839,960,960,960,960,960,960,,,,960,960',
-',,,960,,960,960,960,960,960,960,960,,,,,,960,960,960,960,960,960,960',
-',,960,,,,,,960,960,960,960,960,960,960,960,960,960,960,960,,960,960',
-'960,,960,960,,960,960,960,461,,,,,,,,,,,,,,,,461,461,,960,,,960,,,960',
-'960,,,960,,960,461,,461,960,461,461,,461,461,,,461,960,461,,,,960,960',
-'960,960,,960,960,960,960,,,,,960,960,,,,,,,960,,960,960,960,815,815',
-'815,815,815,815,,,,815,815,,,,815,,815,815,815,815,815,815,815,,,,,',
-'815,815,815,815,815,815,815,,,815,,,,,,815,815,815,815,815,815,815,815',
-'815,815,815,815,,815,815,815,,815,815,,815,815,815,470,470,470,470,470',
-'470,470,,,470,470,,,,,,470,470,,815,,,815,,,815,815,,,815,,815,470,',
-'470,815,470,470,,470,470,470,470,470,815,470,,,,815,815,815,815,,815',
-'815,815,815,,,,,815,815,,,,,,,815,,815,815,815,735,735,735,735,735,735',
-',,,735,735,,,,735,,735,735,735,735,735,735,735,,,,,,735,735,735,735',
-'735,735,735,,,735,,,,,,735,735,735,735,735,735,735,735,735,735,735,735',
-',735,735,735,,735,735,,735,735,735,447,447,447,447,447,447,447,447,447',
-'447,447,,447,447,,,447,447,,735,,,735,,,735,735,,,735,,735,447,,447',
-'735,447,447,,447,447,447,447,447,735,447,,,,735,735,735,735,,735,735',
-'735,735,,,,,735,735,,,,,,,735,,735,735,735,814,814,814,814,814,814,',
-',,814,814,,,,814,,814,814,814,814,814,814,814,,,,,,814,814,814,814,814',
-'814,814,,,814,,,,,,814,814,814,814,814,814,814,814,814,814,814,814,',
-'814,814,814,,814,814,,814,814,814,462,,,,,,,,,,,,,,,,462,462,,814,,',
-'814,,,814,814,,,814,,814,462,,462,814,462,462,,462,462,,,462,814,462',
-',,,814,814,814,814,,814,814,814,814,,,,,814,814,,,,,,,814,,814,814,814',
-'0,0,0,0,0,0,,,,0,0,,,,0,,0,0,0,0,0,0,0,,,,,,0,0,0,0,0,0,0,,,0,,,,,,0',
-'0,0,0,0,0,0,0,0,0,0,0,,0,0,0,,0,0,,0,0,0,458,458,458,458,458,458,458',
-',,458,458,,,,,,458,458,,0,,,0,,,0,0,,,0,,0,458,,458,0,458,458,,458,458',
-'458,458,458,0,458,,,,0,0,0,0,,0,0,0,0,,,,,0,0,,,,,,,0,,0,0,0,591,591',
-'591,591,591,591,,,,591,591,,,,591,,591,591,591,591,591,591,591,,,,,',
-'591,591,591,591,591,591,591,,,591,,,,,,591,591,591,591,591,591,591,591',
-'591,591,591,591,,591,591,591,,591,591,,591,591,591,448,448,448,448,448',
-'448,448,448,448,448,448,,448,448,,,448,448,,591,,,591,,,591,591,,,591',
-',591,448,,448,591,448,448,,448,448,448,448,448,591,448,,,,591,591,591',
-'591,,591,591,591,591,,,,,591,591,,,,,,,591,,591,591,591,294,294,294',
-'294,294,294,,,,294,294,,,,294,,294,294,294,294,294,294,294,,,,,,294',
-'294,294,294,294,294,294,,,294,,,,,,294,294,294,294,294,294,294,294,294',
-'294,294,294,,294,294,294,,294,294,,294,294,294,459,,,,,,,,,,,,,,,,459',
-'459,,294,,,294,,,294,294,,,294,,294,459,,459,294,459,459,,459,459,,',
-'459,294,459,,,,294,294,294,294,,294,294,294,294,,,,,294,294,,,,,,,294',
-',294,294,294,730,730,730,730,730,730,,,,730,730,,,,730,,730,730,730',
-'730,730,730,730,,,,,,730,730,730,730,730,730,730,,,730,,,,,,730,730',
-'730,730,730,730,730,730,730,730,730,730,,730,730,730,,730,730,,730,730',
-'730,463,463,463,463,463,463,463,,,463,463,,,,,,463,463,,730,,,730,,',
-'730,730,,,730,,730,463,,463,730,463,463,,463,463,463,463,463,730,463',
-',,,730,730,730,730,,730,730,730,730,,,,,730,730,,,,,,,730,,730,730,730',
-'806,806,806,806,806,806,,,,806,806,,,,806,,806,806,806,806,806,806,806',
-',,,,,806,806,806,806,806,806,806,,,806,,,,,,806,806,806,806,806,806',
-'806,806,806,806,806,806,,806,806,806,,806,806,,806,806,806,466,466,466',
-'466,466,466,466,,,466,466,,,,,,466,466,,806,,,806,,,806,806,,,806,,806',
-'466,,466,806,466,466,,466,466,466,466,466,806,466,,,,806,806,806,806',
-',806,806,806,806,,,,,806,806,,,,,,,806,,806,806,806,943,943,943,943',
-'943,943,,,,943,943,,,,943,,943,943,943,943,943,943,943,,,,,,943,943',
-'943,943,943,943,943,,,943,,,,,,943,943,943,943,943,943,943,943,943,943',
-'943,943,,943,943,943,,943,943,,943,943,943,464,464,464,464,464,464,464',
-',,464,464,,,,,,464,464,,943,,,943,,,943,943,,,943,,943,464,,464,943',
-'464,464,,464,464,464,464,464,943,464,,,,943,943,943,943,,943,943,943',
-'943,,,,,943,943,,,,,,,943,,943,943,943,299,299,299,299,299,299,,,,299',
-'299,,,,299,,299,299,299,299,299,299,299,,,,,,299,299,299,299,299,299',
-'299,,,299,,,,,,299,299,299,299,299,299,299,299,299,299,299,299,,299',
-'299,299,,299,299,,299,299,299,465,465,465,465,465,465,465,,,465,465',
-',,,,,465,465,,299,,,299,,,299,299,,,299,,299,465,,465,299,465,465,,465',
-'465,465,465,465,299,465,,,,299,299,299,299,,299,299,299,299,,,,,299',
-'299,,,,,,,299,,299,299,299,968,968,968,968,968,968,,,,968,968,,,,968',
-',968,968,968,968,968,968,968,,,,,,968,968,968,968,968,968,968,,,968',
-',,,,,968,968,968,968,968,968,968,968,968,968,968,968,,968,968,968,,968',
-'968,,968,968,968,471,471,471,471,471,471,471,471,,471,471,,,,,,471,471',
-',968,,,968,,,968,968,,,968,,968,471,,471,968,471,471,,471,471,471,471',
-'471,968,471,,,,968,968,968,968,,968,968,968,968,,,,,968,968,,,,116,116',
-'116,968,116,968,968,968,116,116,,,,116,,116,116,116,116,116,116,116',
-',,,,,116,116,116,116,116,116,116,,,116,,,,,,,116,,,116,116,116,116,116',
-'116,116,116,,116,116,116,,116,116,,116,116,116,467,467,467,467,467,467',
-'467,,,467,467,,,,,,467,467,,116,,,116,,,116,116,,,116,,,467,,467,116',
-'467,467,,467,467,467,467,467,116,467,,,,116,116,116,116,,116,116,116',
-'116,,,,,116,116,,,,117,117,117,116,117,116,116,116,117,117,,,,117,,117',
-'117,117,117,117,117,117,,,,,,117,117,117,117,117,117,117,,,117,,,,,',
-',117,,,117,117,117,117,117,117,117,117,,117,117,117,,117,117,,117,117',
-'117,455,,,,,,,,,,,,,,,,455,455,,117,,,117,,,117,117,,,117,,,455,,455',
-'117,455,455,,455,455,,,,117,,,,,117,117,117,117,,117,117,117,117,,,',
-',117,117,,,,118,118,118,117,118,117,117,117,118,118,,,,118,,118,118',
-'118,118,118,118,118,,,,,,118,118,118,118,118,118,118,,,118,,,,,,,118',
-',,118,118,118,118,118,118,118,118,,118,118,118,,118,118,,118,118,118',
-'456,,,,,,,,,,,,,,,,456,456,,118,,,118,,,118,118,,,118,,,456,,456,118',
-'456,456,,456,456,,,,118,,,,,118,118,118,118,,118,118,118,118,,,,,118',
-'118,,,,119,119,119,118,119,118,118,118,119,119,,,,119,,119,119,119,119',
-'119,119,119,,,,,,119,119,119,119,119,119,119,,,119,,,,,,,119,,,119,119',
-'119,119,119,119,119,119,,119,119,119,,119,119,,119,119,119,457,,,,,',
-',,,,,,,,,,457,457,,119,,,119,,,119,119,,,119,,,457,,,119,457,457,,457',
-'457,,,,119,,,,,119,119,119,119,,119,119,119,119,,,,,119,119,,,,,,,119',
-',119,119,119,120,120,120,120,120,,,,120,120,,,,120,,120,120,120,120',
-'120,120,120,,,,,,120,120,120,120,120,120,120,,,120,,,,,,120,120,,120',
-'120,120,120,120,120,120,120,120,,120,120,120,,120,120,,120,120,120,',
-',,,,,,,,,,,,,,,,,,120,,,120,,,120,120,,,120,,120,,,,120,,,,,,,,,120',
-',,,,120,120,120,120,,120,120,120,120,,,,,120,120,,,,725,725,725,120',
-'725,120,120,120,725,725,,,,725,,725,725,725,725,725,725,725,,,,,,725',
-'725,725,725,725,725,725,,,725,,,,,,,725,,,725,725,725,725,725,725,725',
-'725,,725,725,725,,725,725,,725,725,725,,,,,,,,,,,,,,,,,,,,725,,,725',
-',,725,725,,,725,,,,,,725,,,,,,,,,725,,,,,725,725,725,725,,725,725,725',
-'725,,,,,725,725,,,,699,699,699,725,699,725,725,725,699,699,,,,699,,699',
-'699,699,699,699,699,699,,,,,,699,699,699,699,699,699,699,,,699,,,,,',
-',699,,,699,699,699,699,699,699,699,699,,699,699,699,,699,699,,699,699',
-'699,,,,,,,,,,,,,,,,,,,,699,,,699,,,699,699,,,699,,,,,,699,,,,,,,,,699',
-',,,,699,699,699,699,,699,699,699,699,,,,,699,699,,,,207,207,207,699',
-'207,699,699,699,207,207,,,,207,,207,207,207,207,207,207,207,,,,,,207',
-'207,207,207,207,207,207,,,207,,,,,,,207,,,207,207,207,207,207,207,207',
-'207,,207,207,207,,207,207,,207,207,207,,,,,,,,,,,,,,,,,,,,207,,,207',
-',,207,207,,,207,,207,,,,207,,,,,,,,,207,,,,,207,207,207,207,,207,207',
-'207,207,,,,,207,207,,,,208,208,208,207,208,207,207,207,208,208,,,,208',
-',208,208,208,208,208,208,208,,,,,,208,208,208,208,208,208,208,,,208',
-',,,,,,208,,,208,208,208,208,208,208,208,208,,208,208,208,,208,208,,208',
-'208,208,,,,,,,,,,,,,,,,,,,,208,,,208,,,208,208,,,208,,,,,,208,,,,,,',
-',,208,,,,,208,208,208,208,,208,208,208,208,,,,,208,208,,,,209,209,209',
-'208,209,208,208,208,209,209,,,,209,,209,209,209,209,209,209,209,,,,',
-',209,209,209,209,209,209,209,,,209,,,,,,,209,,,209,209,209,209,209,209',
-'209,209,209,209,209,209,,209,209,,209,209,209,,,,,,,,,,,,,,,,,,,,209',
-',,209,,,209,209,,,209,,209,,209,,209,,,209,,,,,,209,,,,,209,209,209',
-'209,,209,209,209,209,,,,,209,209,,,,682,682,682,209,682,209,209,209',
-'682,682,,,,682,,682,682,682,682,682,682,682,,,,,,682,682,682,682,682',
-'682,682,,,682,,,,,,,682,,,682,682,682,682,682,682,682,682,,682,682,682',
-',682,682,,682,682,682,,,,,,,,,,,,,,,,,,,,682,,,682,,,682,682,,,682,',
-'682,,,,682,,,,,,,,,682,,,,,682,682,682,682,,682,682,682,682,,,,,682',
-'682,,,,677,677,677,682,677,682,682,682,677,677,,,,677,,677,677,677,677',
-'677,677,677,,,,,,677,677,677,677,677,677,677,,,677,,,,,,,677,,,677,677',
-'677,677,677,677,677,677,,677,677,677,,677,677,,,,677,,,,,,,,,,,,,,,',
-',,,,677,,,677,,,677,677,,,677,,,,,,,,,,,,,,,,,,,,677,677,677,677,,677',
-'677,677,677,,,,,677,677,,,,212,212,212,677,212,677,677,677,212,212,',
-',,212,,212,212,212,212,212,212,212,,,,,,212,212,212,212,212,212,212',
-',,212,,,,,,,212,,,212,212,212,212,212,212,212,212,,212,212,212,,212',
-'212,,212,212,212,,,,,,,,,,,,,,,,,,,,212,,,212,,,212,212,,,212,,,,,,212',
-',,,,,,,,212,,,,,212,212,212,212,,212,212,212,212,,,,,212,212,,,,213',
-'213,213,212,213,212,212,212,213,213,,,,213,,213,213,213,213,213,213',
-'213,,,,,,213,213,213,213,213,213,213,,,213,,,,,,,213,,,213,213,213,213',
-'213,213,213,213,,213,213,213,,213,213,,213,213,213,,,,,,,,,,,,,,,,,',
-',,213,,,213,,,213,213,,,213,,213,,,,213,,,,,,,,,213,,,,,213,213,213',
-'213,,213,213,213,213,,,,,213,213,,,,214,214,214,213,214,213,213,213',
-'214,214,,,,214,,214,214,214,214,214,214,214,,,,,,214,214,214,214,214',
-'214,214,,,214,,,,,,,214,,,214,214,214,214,214,214,214,214,,214,214,214',
-',214,214,,214,214,214,,,,,,,,,,,,,,,,,,,,214,,,214,,,214,214,,,214,',
-',,,,214,,,,,,,,,214,,,,,214,214,214,214,,214,214,214,214,,,,,214,214',
-',,,215,215,215,214,215,214,214,214,215,215,,,,215,,215,215,215,215,215',
-'215,215,,,,,,215,215,215,215,215,215,215,,,215,,,,,,,215,,,215,215,215',
-'215,215,215,215,215,,215,215,215,,215,215,,215,215,215,,,,,,,,,,,,,',
-',,,,,,215,,,215,,,215,215,,,215,,,,,,215,,,,,,,,,215,,,,,215,215,215',
-'215,,215,215,215,215,,,,,215,215,,,,216,216,216,215,216,215,215,215',
-'216,216,,,,216,,216,216,216,216,216,216,216,,,,,,216,216,216,216,216',
-'216,216,,,216,,,,,,,216,,,216,216,216,216,216,216,216,216,,216,216,216',
-',216,216,,216,216,216,,,,,,,,,,,,,,,,,,,,216,,,216,,,216,216,,,216,',
-',,,,216,,,,,,,,,216,,,,,216,216,216,216,,216,216,216,216,,,,,216,216',
-',,,217,217,217,216,217,216,216,216,217,217,,,,217,,217,217,217,217,217',
-'217,217,,,,,,217,217,217,217,217,217,217,,,217,,,,,,,217,,,217,217,217',
-'217,217,217,217,217,,217,217,217,,217,217,,217,217,217,,,,,,,,,,,,,',
-',,,,,,217,,,217,,,217,217,,,217,,,,,,217,,,,,,,,,217,,,,,217,217,217',
-'217,,217,217,217,217,,,,,217,217,217,,,666,666,666,217,666,217,217,217',
-'666,666,,,,666,,666,666,666,666,666,666,666,,,,,,666,666,666,666,666',
-'666,666,,,666,,,,,,,666,,,666,666,666,666,666,666,666,666,,666,666,666',
-',666,666,,,,666,,,,,,,,,,,,,,,,,,,,666,,,666,,,666,666,,,666,,,,,,,',
-',,,,,,,,,,,,666,666,666,666,,666,666,666,666,,,,,666,666,,,,662,662',
-'662,666,662,666,666,666,662,662,,,,662,,662,662,662,662,662,662,662',
-',,,,,662,662,662,662,662,662,662,,,662,,,,,,,662,,,662,662,662,662,662',
-'662,662,662,,662,662,662,,662,662,,662,662,662,,,,,,,,,,,,,,,,,,,,662',
-',,662,,,662,662,,,662,,,,,,662,,,,,,,,,662,,,,,662,662,662,662,,662',
-'662,662,662,,,,,662,662,,,,659,659,659,662,659,662,662,662,659,659,',
-',,659,,659,659,659,659,659,659,659,,,,,,659,659,659,659,659,659,659',
-',,659,,,,,,,659,,,659,659,659,659,659,659,659,659,,659,659,659,,659',
-'659,,659,659,659,,,,,,,,,,,,,,,,,,,,659,,,659,,,659,659,,,659,,,,,,659',
-',,,,,,,,659,,,,,659,659,659,659,,659,659,659,659,,,,,659,659,,,,228',
-'228,228,659,228,659,659,659,228,228,,,,228,,228,228,228,228,228,228',
-'228,,,,,,228,228,228,228,228,228,228,,,228,,,,,,,228,,,228,228,228,228',
-'228,228,228,228,,228,228,228,,228,228,,228,228,228,,,,,,,,,,,,,,,,,',
-',,228,,,228,,,228,228,,,228,,,,,,228,,,,,,,,,228,,,,,228,228,228,228',
-',228,228,228,228,,,,,228,228,,,,231,231,231,228,231,228,228,228,231',
-'231,,,,231,,231,231,231,231,231,231,231,,,,,,231,231,231,231,231,231',
-'231,,,231,,,,,,,231,,,231,231,231,231,231,231,231,231,,231,231,231,',
-'231,231,,231,231,231,,,,,,,,,,,,,,,,,,,,231,,,231,,,231,231,,,231,,',
-',,,231,,,,,,,,,231,,,,,231,231,231,231,,231,231,231,231,,,,,231,231',
-',,,232,232,232,231,232,231,231,231,232,232,,,,232,,232,232,232,232,232',
-'232,232,,,,,,232,232,232,232,232,232,232,,,232,,,,,,,232,,,232,232,232',
-'232,232,232,232,232,,232,232,232,,232,232,,232,232,232,,,,,,,,,,,,,',
-',,,,,,232,,,232,,,232,232,,,232,,,,,,232,,,,,,,,,232,,,,,232,232,232',
-'232,,232,232,232,232,,,,,232,232,,,,233,233,233,232,233,232,232,232',
-'233,233,,,,233,,233,233,233,233,233,233,233,,,,,,233,233,233,233,233',
-'233,233,,,233,,,,,,,233,,,233,233,233,233,233,233,233,233,,233,233,233',
-',233,233,,233,233,233,,,,,,,,,,,,,,,,,,,,233,,,233,,,233,233,,,233,',
-',,,,233,,,,,,,,,233,,,,,233,233,233,233,,233,233,233,233,,,,,233,233',
-',,,234,234,234,233,234,233,233,233,234,234,,,,234,,234,234,234,234,234',
-'234,234,,,,,,234,234,234,234,234,234,234,,,234,,,,,,,234,,,234,234,234',
-'234,234,234,234,234,,234,234,234,,234,234,,234,234,234,,,,,,,,,,,,,',
-',,,,,,234,,,234,,,234,234,,,234,,,,,,234,,,,,,,,,234,,,,,234,234,234',
-'234,,234,234,234,234,,,,,234,234,,,,235,235,235,234,235,234,234,234',
-'235,235,,,,235,,235,235,235,235,235,235,235,,,,,,235,235,235,235,235',
-'235,235,,,235,,,,,,,235,,,235,235,235,235,235,235,235,235,,235,235,235',
-',235,235,,235,235,235,,,,,,,,,,,,,,,,,,,,235,,,235,,,235,235,,,235,',
-',,,,235,,,,,,,,,235,,,,,235,235,235,235,,235,235,235,235,,,,,235,235',
-',,,236,236,236,235,236,235,235,235,236,236,,,,236,,236,236,236,236,236',
-'236,236,,,,,,236,236,236,236,236,236,236,,,236,,,,,,,236,,,236,236,236',
-'236,236,236,236,236,,236,236,236,,236,236,,236,236,236,,,,,,,,,,,,,',
-',,,,,,236,,,236,,,236,236,,,236,,,,,,236,,,,,,,,,236,,,,,236,236,236',
-'236,,236,236,236,236,,,,,236,236,,,,237,237,237,236,237,236,236,236',
-'237,237,,,,237,,237,237,237,237,237,237,237,,,,,,237,237,237,237,237',
-'237,237,,,237,,,,,,,237,,,237,237,237,237,237,237,237,237,,237,237,237',
-',237,237,,237,237,237,,,,,,,,,,,,,,,,,,,,237,,,237,,,237,237,,,237,',
-',,,,237,,,,,,,,,237,,,,,237,237,237,237,,237,237,237,237,,,,,237,237',
-',,,238,238,238,237,238,237,237,237,238,238,,,,238,,238,238,238,238,238',
-'238,238,,,,,,238,238,238,238,238,238,238,,,238,,,,,,,238,,,238,238,238',
-'238,238,238,238,238,,238,238,238,,238,238,,238,238,238,,,,,,,,,,,,,',
-',,,,,,238,,,238,,,238,238,,,238,,,,,,238,,,,,,,,,238,,,,,238,238,238',
-'238,,238,238,238,238,,,,,238,238,,,,239,239,239,238,239,238,238,238',
-'239,239,,,,239,,239,239,239,239,239,239,239,,,,,,239,239,239,239,239',
-'239,239,,,239,,,,,,,239,,,239,239,239,239,239,239,239,239,,239,239,239',
-',239,239,,239,239,239,,,,,,,,,,,,,,,,,,,,239,,,239,,,239,239,,,239,',
-',,,,239,,,,,,,,,239,,,,,239,239,239,239,,239,239,239,239,,,,,239,239',
-',,,240,240,240,239,240,239,239,239,240,240,,,,240,,240,240,240,240,240',
-'240,240,,,,,,240,240,240,240,240,240,240,,,240,,,,,,,240,,,240,240,240',
-'240,240,240,240,240,,240,240,240,,240,240,,240,240,240,,,,,,,,,,,,,',
-',,,,,,240,,,240,,,240,240,,,240,,,,,,240,,,,,,,,,240,,,,,240,240,240',
-'240,,240,240,240,240,,,,,240,240,,,,241,241,241,240,241,240,240,240',
-'241,241,,,,241,,241,241,241,241,241,241,241,,,,,,241,241,241,241,241',
-'241,241,,,241,,,,,,,241,,,241,241,241,241,241,241,241,241,,241,241,241',
-',241,241,,241,241,241,,,,,,,,,,,,,,,,,,,,241,,,241,,,241,241,,,241,',
-',,,,241,,,,,,,,,241,,,,,241,241,241,241,,241,241,241,241,,,,,241,241',
-',,,242,242,242,241,242,241,241,241,242,242,,,,242,,242,242,242,242,242',
-'242,242,,,,,,242,242,242,242,242,242,242,,,242,,,,,,,242,,,242,242,242',
-'242,242,242,242,242,,242,242,242,,242,242,,242,242,242,,,,,,,,,,,,,',
-',,,,,,242,,,242,,,242,242,,,242,,,,,,242,,,,,,,,,242,,,,,242,242,242',
-'242,,242,242,242,242,,,,,242,242,,,,243,243,243,242,243,242,242,242',
-'243,243,,,,243,,243,243,243,243,243,243,243,,,,,,243,243,243,243,243',
-'243,243,,,243,,,,,,,243,,,243,243,243,243,243,243,243,243,,243,243,243',
-',243,243,,243,243,243,,,,,,,,,,,,,,,,,,,,243,,,243,,,243,243,,,243,',
-',,,,243,,,,,,,,,243,,,,,243,243,243,243,,243,243,243,243,,,,,243,243',
-',,,244,244,244,243,244,243,243,243,244,244,,,,244,,244,244,244,244,244',
-'244,244,,,,,,244,244,244,244,244,244,244,,,244,,,,,,,244,,,244,244,244',
-'244,244,244,244,244,,244,244,244,,244,244,,244,244,244,,,,,,,,,,,,,',
-',,,,,,244,,,244,,,244,244,,,244,,,,,,244,,,,,,,,,244,,,,,244,244,244',
-'244,,244,244,244,244,,,,,244,244,,,,245,245,245,244,245,244,244,244',
-'245,245,,,,245,,245,245,245,245,245,245,245,,,,,,245,245,245,245,245',
-'245,245,,,245,,,,,,,245,,,245,245,245,245,245,245,245,245,,245,245,245',
-',245,245,,245,245,245,,,,,,,,,,,,,,,,,,,,245,,,245,,,245,245,,,245,',
-',,,,245,,,,,,,,,245,,,,,245,245,245,245,,245,245,245,245,,,,,245,245',
-',,,246,246,246,245,246,245,245,245,246,246,,,,246,,246,246,246,246,246',
-'246,246,,,,,,246,246,246,246,246,246,246,,,246,,,,,,,246,,,246,246,246',
-'246,246,246,246,246,,246,246,246,,246,246,,246,246,246,,,,,,,,,,,,,',
-',,,,,,246,,,246,,,246,246,,,246,,,,,,246,,,,,,,,,246,,,,,246,246,246',
-'246,,246,246,246,246,,,,,246,246,,,,247,247,247,246,247,246,246,246',
-'247,247,,,,247,,247,247,247,247,247,247,247,,,,,,247,247,247,247,247',
-'247,247,,,247,,,,,,,247,,,247,247,247,247,247,247,247,247,,247,247,247',
-',247,247,,247,247,247,,,,,,,,,,,,,,,,,,,,247,,,247,,,247,247,,,247,',
-',,,,247,,,,,,,,,247,,,,,247,247,247,247,,247,247,247,247,,,,,247,247',
-',,,248,248,248,247,248,247,247,247,248,248,,,,248,,248,248,248,248,248',
-'248,248,,,,,,248,248,248,248,248,248,248,,,248,,,,,,,248,,,248,248,248',
-'248,248,248,248,248,,248,248,248,,248,248,,248,248,248,,,,,,,,,,,,,',
-',,,,,,248,,,248,,,248,248,,,248,,,,,,248,,,,,,,,,248,,,,,248,248,248',
-'248,,248,248,248,248,,,,,248,248,,,,249,249,249,248,249,248,248,248',
-'249,249,,,,249,,249,249,249,249,249,249,249,,,,,,249,249,249,249,249',
-'249,249,,,249,,,,,,,249,,,249,249,249,249,249,249,249,249,,249,249,249',
-',249,249,,249,249,249,,,,,,,,,,,,,,,,,,,,249,,,249,,,249,249,,,249,',
-',,,,249,,,,,,,,,249,,,,,249,249,249,249,,249,249,249,249,,,,,249,249',
-',,,250,250,250,249,250,249,249,249,250,250,,,,250,,250,250,250,250,250',
-'250,250,,,,,,250,250,250,250,250,250,250,,,250,,,,,,,250,,,250,250,250',
-'250,250,250,250,250,,250,250,250,,250,250,,250,250,250,,,,,,,,,,,,,',
-',,,,,,250,,,250,,,250,250,,,250,,,,,,250,,,,,,,,,250,,,,,250,250,250',
-'250,,250,250,250,250,,,,,250,250,,,,251,251,251,250,251,250,250,250',
-'251,251,,,,251,,251,251,251,251,251,251,251,,,,,,251,251,251,251,251',
-'251,251,,,251,,,,,,,251,,,251,251,251,251,251,251,251,251,,251,251,251',
-',251,251,,251,251,251,,,,,,,,,,,,,,,,,,,,251,,,251,,,251,251,,,251,',
-',,,,251,,,,,,,,,251,,,,,251,251,251,251,,251,251,251,251,,,,,251,251',
-',,,252,252,252,251,252,251,251,251,252,252,,,,252,,252,252,252,252,252',
-'252,252,,,,,,252,252,252,252,252,252,252,,,252,,,,,,,252,,,252,252,252',
-'252,252,252,252,252,,252,252,252,,252,252,,252,252,252,,,,,,,,,,,,,',
-',,,,,,252,,,252,,,252,252,,,252,,,,,,252,,,,,,,,,252,,,,,252,252,252',
-'252,,252,252,252,252,,,,,252,252,,,,253,253,253,252,253,252,252,252',
-'253,253,,,,253,,253,253,253,253,253,253,253,,,,,,253,253,253,253,253',
-'253,253,,,253,,,,,,,253,,,253,253,253,253,253,253,253,253,,253,253,253',
-',253,253,,253,253,253,,,,,,,,,,,,,,,,,,,,253,,,253,,,253,253,,,253,',
-',,,,253,,,,,,,,,253,,,,,253,253,253,253,,253,253,253,253,,,,,253,253',
-',,,254,254,254,253,254,253,253,253,254,254,,,,254,,254,254,254,254,254',
-'254,254,,,,,,254,254,254,254,254,254,254,,,254,,,,,,,254,,,254,254,254',
-'254,254,254,254,254,,254,254,254,,254,254,,254,254,254,,,,,,,,,,,,,',
-',,,,,,254,,,254,,,254,254,,,254,,,,,,254,,,,,,,,,254,,,,,254,254,254',
-'254,,254,254,254,254,,,,,254,254,,,,255,255,255,254,255,254,254,254',
-'255,255,,,,255,,255,255,255,255,255,255,255,,,,,,255,255,255,255,255',
-'255,255,,,255,,,,,,,255,,,255,255,255,255,255,255,255,255,,255,255,255',
-',255,255,,255,255,255,,,,,,,,,,,,,,,,,,,,255,,,255,,,255,255,,,255,',
-',,,,255,,,,,,,,,255,,,,,255,255,255,255,,255,255,255,255,,,,,255,255',
-',,,635,635,635,255,635,255,255,255,635,635,,,,635,,635,635,635,635,635',
-'635,635,,,,,,635,635,635,635,635,635,635,,,635,,,,,,,635,,,635,635,635',
-'635,635,635,635,635,,635,635,635,,635,635,,635,635,635,,,,,,,,,,,,,',
-',,,,,,635,,,635,,,635,635,,,635,,,,,,635,,,,,,,,,635,,,,,635,635,635',
-'635,,635,635,635,635,,,,,635,635,,,,634,634,634,635,634,635,635,635',
-'634,634,,,,634,,634,634,634,634,634,634,634,,,,,,634,634,634,634,634',
-'634,634,,,634,,,,,,,634,,,634,634,634,634,634,634,634,634,,634,634,634',
-',634,634,,634,634,634,,,,,,,,,,,,,,,,,,,,634,,,634,,,634,634,,,634,',
-',,,,634,,,,,,,,,634,,,,,634,634,634,634,,634,634,634,634,,,,,634,634',
-',,,263,263,263,634,263,634,634,634,263,263,,,,263,,263,263,263,263,263',
-'263,263,,,,,,263,263,263,263,263,263,263,,,263,,,,,,,263,,,263,263,263',
-'263,263,263,263,263,263,263,263,263,,263,263,,263,263,263,,,,,,,,,,',
-',,,,,,,,,263,,,263,,,263,263,,,263,,263,,263,,263,,,263,,,,,,263,,,',
-',263,263,263,263,,263,263,263,263,,,,,263,263,,,,264,264,264,263,264',
-'263,263,263,264,264,,,,264,,264,264,264,264,264,264,264,,,,,,264,264',
-'264,264,264,264,264,,,264,,,,,,,264,,,264,264,264,264,264,264,264,264',
-'264,264,264,264,,264,264,,264,264,264,,,,,,,,,,,,,,,,,,,,264,,,264,',
-',264,264,,,264,,264,,264,,264,,,264,,,,,,264,,,,,264,264,264,264,,264',
-'264,264,264,,,,,264,264,,,,272,272,272,264,272,264,264,264,272,272,',
-',,272,,272,272,272,272,272,272,272,,,,,,272,272,272,272,272,272,272',
-',,272,,,,,,,272,,,272,272,272,272,272,272,272,272,272,272,272,272,,272',
-'272,,272,272,272,,,,,,,,,,,,,,,,,,,,272,,,272,,,272,272,,,272,,272,',
-'272,,272,,,272,,,,,,272,,,,,272,272,272,272,,272,272,272,272,,,,,272',
-'272,272,,,631,631,631,272,631,272,272,272,631,631,,,,631,,631,631,631',
-'631,631,631,631,,,,,,631,631,631,631,631,631,631,,,631,,,,,,,631,,,631',
-'631,631,631,631,631,631,631,,631,631,631,,631,631,,631,631,631,,,,,',
-',,,,,,,,,,,,,,631,,,631,,,631,631,,,631,,,,,,631,,,,,,,,,631,,,,,631',
-'631,631,631,,631,631,631,631,,,,,631,631,,,,630,630,630,631,630,631',
-'631,631,630,630,,,,630,,630,630,630,630,630,630,630,,,,,,630,630,630',
-'630,630,630,630,,,630,,,,,,,630,,,630,630,630,630,630,630,630,630,,630',
-'630,630,,630,630,,630,630,630,,,,,,,,,,,,,,,,,,,,630,,,630,,,630,630',
-',,630,,,,,,630,,,,,,,,,630,,,,,630,630,630,630,,630,630,630,630,,,,',
-'630,630,,,,626,626,626,630,626,630,630,630,626,626,,,,626,,626,626,626',
-'626,626,626,626,,,,,,626,626,626,626,626,626,626,,,626,,,,,,,626,,,626',
-'626,626,626,626,626,626,626,,626,626,626,,626,626,,626,626,626,,,,,',
-',,,,,,,,,,,,,,626,,,626,,,626,626,,,626,,,,,,626,,,,,,,,,626,,,,,626',
-'626,626,626,,626,626,626,626,,,,,626,626,,,,279,279,279,626,279,626',
-'626,626,279,279,,,,279,,279,279,279,279,279,279,279,,,,,,279,279,279',
-'279,279,279,279,,,279,,,,,,,279,,,279,279,279,279,279,279,279,279,,279',
-'279,279,,279,279,,279,279,279,,,,,,,,,,,,,,,,,,,,279,,,279,,,279,279',
-',,279,,,,,,279,,,,,,,,,279,,,,,279,279,279,279,,279,279,279,279,,,,',
-'279,279,,,,625,625,625,279,625,279,279,279,625,625,,,,625,,625,625,625',
-'625,625,625,625,,,,,,625,625,625,625,625,625,625,,,625,,,,,,,625,,,625',
-'625,625,625,625,625,625,625,,625,625,625,,625,625,,625,625,625,,,,,',
-',,,,,,,,,,,,,,625,,,625,,,625,625,,,625,,,,,,625,,,,,,,,,625,,,,,625',
-'625,625,625,,625,625,625,625,,,,,625,625,,,,281,281,281,625,281,625',
-'625,625,281,281,,,,281,,281,281,281,281,281,281,281,,,,,,281,281,281',
-'281,281,281,281,,,281,,,,,,,281,,,281,281,281,281,281,281,281,281,,281',
-'281,281,,281,281,,281,281,281,,,,,,,,,,,,,,,,,,,,281,,,281,,,281,281',
-',,281,,,,,,281,,,,,,,,,281,,,,,281,281,281,281,,281,281,281,281,,,,',
-'281,281,,,,284,284,284,281,284,281,281,281,284,284,,,,284,,284,284,284',
-'284,284,284,284,,,,,,284,284,284,284,284,284,284,,,284,,,,,,,284,,,284',
-'284,284,284,284,284,284,284,,284,284,284,,284,284,,284,284,284,,,,,',
-',,,,,,,,,,,,,,284,,,284,,,284,284,,,284,,,,,,284,,,,,,,,,284,,,,,284',
-'284,284,284,,284,284,284,284,,,,,284,284,,,,285,285,285,284,285,284',
-'284,284,285,285,,,,285,,285,285,285,285,285,285,285,,,,,,285,285,285',
-'285,285,285,285,,,285,,,,,,,285,,,285,285,285,285,285,285,285,285,,285',
-'285,285,,285,285,,285,285,285,,,,,,,,,,,,,,,,,,,,285,,,285,,,285,285',
-',,285,,,,,,285,,,,,,,,,285,,,,,285,285,285,285,,285,285,285,285,,,,',
-'285,285,,,,624,624,624,285,624,285,285,285,624,624,,,,624,,624,624,624',
-'624,624,624,624,,,,,,624,624,624,624,624,624,624,,,624,,,,,,,624,,,624',
-'624,624,624,624,624,624,624,624,624,624,624,,624,624,,624,624,624,,',
-',,,,,,,,,,,,,,,,,624,,,624,,,624,624,,,624,,,,624,,624,,,624,,,,,,624',
-',,,,624,624,624,624,,624,624,624,624,,,,,624,624,,,,,,,624,,624,624',
-'624,290,290,290,290,290,,,,290,290,,,,290,,290,290,290,290,290,290,290',
-',,,,,290,290,290,290,290,290,290,,,290,,,,,,290,290,,290,290,290,290',
-'290,290,290,290,290,,290,290,290,,290,290,,290,290,290,,,,,,,,,,,,,',
-',,,,,,290,,,290,,,290,290,,,290,,290,,,,290,,,,,,,,,290,,,,,290,290',
-'290,290,,290,290,290,290,,,,,290,290,,,,623,623,623,290,623,290,290',
-'290,623,623,,,,623,,623,623,623,623,623,623,623,,,,,,623,623,623,623',
-'623,623,623,,,623,,,,,,,623,,,623,623,623,623,623,623,623,623,623,623',
-'623,623,,623,623,,623,623,623,,,,,,,,,,,,,,,,,,,,623,,,623,,,623,623',
-',,623,,623,,623,,623,,,623,,,,,,623,,,,,623,623,623,623,,623,623,623',
-'623,,,,,623,623,,,,620,620,620,623,620,623,623,623,620,620,,,,620,,620',
-'620,620,620,620,620,620,,,,,,620,620,620,620,620,620,620,,,620,,,,,',
-',620,,,620,620,620,620,620,620,620,620,,620,620,620,,620,620,,620,620',
-'620,,,,,,,,,,,,,,,,,,,,620,,,620,,,620,620,,,620,,,,,,620,,,,,,,,,620',
-',,,,620,620,620,620,,620,620,620,620,,,,,620,620,,,,619,619,619,620',
-'619,620,620,620,619,619,,,,619,,619,619,619,619,619,619,619,,,,,,619',
-'619,619,619,619,619,619,,,619,,,,,,,619,,,619,619,619,619,619,619,619',
-'619,,619,619,619,,619,619,,619,619,619,,,,,,,,,,,,,,,,,,,,619,,,619',
-',,619,619,,,619,,619,,,,619,,,,,,,,,619,,,,,619,619,619,619,,619,619',
-'619,619,,,,,619,619,,,,585,585,585,619,585,619,619,619,585,585,,,,585',
-',585,585,585,585,585,585,585,,,,,,585,585,585,585,585,585,585,,,585',
-',,,,,,585,,,585,585,585,585,585,585,585,585,585,585,585,585,,585,585',
-',585,585,585,,,,,,,,,,,,,,,,,,,,585,,,585,,,585,585,,,585,,585,,585',
-',585,,,585,,,,,,585,,,,,585,585,585,585,,585,585,585,585,,,,,585,585',
-',,,575,575,575,585,575,585,585,585,575,575,,,,575,,575,575,575,575,575',
-'575,575,,,,,,575,575,575,575,575,575,575,,,575,,,,,,,575,,,575,575,575',
-'575,575,575,575,575,575,575,575,575,,575,575,,575,575,575,,,,,,,,,,',
-',,,,,,,,,575,,,575,,,575,575,,,575,,575,,575,,575,,,575,,,,,,575,,,',
-',575,575,575,575,,575,575,575,575,,,,,575,575,,,,298,298,298,575,298',
-'575,575,575,298,298,,,,298,,298,298,298,298,298,298,298,,,,,,298,298',
-'298,298,298,298,298,,,298,,,,,,,298,,,298,298,298,298,298,298,298,298',
-',298,298,298,,298,298,,,,298,,,,,,,,,,,,,,,,,,,,298,,,298,,,298,298',
-',,298,,897,,897,897,897,897,897,,,,,,,,,,897,,298,298,298,298,,298,298',
-'298,298,,,,,298,298,,,,298,,897,298,,298,298,298,574,574,574,,574,897',
-'897,,574,574,897,,,574,,574,574,574,574,574,574,574,,,,,,574,574,574',
-'574,574,574,574,,,574,,,,,,,574,,,574,574,574,574,574,574,574,574,,574',
-'574,574,,574,574,,574,574,574,,,,,,,,,,,,,,,,,,,,574,,,574,,,574,574',
-',,574,,574,,,,574,,,,,,,,,574,,,,,574,574,574,574,,574,574,574,574,',
-',,,574,574,,,,554,554,554,574,554,574,574,574,554,554,,,,554,,554,554',
-'554,554,554,554,554,,,,,,554,554,554,554,554,554,554,,,554,,,,,,,554',
-',,554,554,554,554,554,554,554,554,,554,554,554,,554,554,,554,554,554',
-',,,,,,,,,,,,,,,,,,,554,,,554,,,554,554,,,554,,,,,,554,,,,,,,,,554,,',
-',,554,554,554,554,,554,554,554,554,,,,,554,554,,,,529,529,529,554,529',
-'554,554,554,529,529,,,,529,,529,529,529,529,529,529,529,,,,,,529,529',
-'529,529,529,529,529,,,529,,,,,,,529,,,529,529,529,529,529,529,529,529',
-'529,529,529,529,,529,529,,529,529,529,,,,,,,,,,,,,,,,,,,,529,,,529,',
-',529,529,,,529,,,,,,529,,,529,,,,,,529,,,,,529,529,529,529,,529,529',
-'529,529,,,,,529,529,,,,526,526,526,529,526,529,529,529,526,526,,,,526',
-',526,526,526,526,526,526,526,,,,,,526,526,526,526,526,526,526,,,526',
-',,,,,,526,,,526,526,526,526,526,526,526,526,526,526,526,526,,526,526',
-',526,526,526,,,,,,,,,,,,,,,,,,,,526,,,526,,,526,526,,,526,,526,,,,526',
-',,526,,,,,,526,,,,,526,526,526,526,,526,526,526,526,,,,,526,526,,,,520',
-'520,520,526,520,526,526,526,520,520,,,,520,,520,520,520,520,520,520',
-'520,,,,,,520,520,520,520,520,520,520,,,520,,,,,,,520,,,520,520,520,520',
-'520,520,520,520,,520,520,520,,520,520,,520,520,520,,,,,,,,,,,,,,,,,',
-',,520,,,520,,,520,520,,,520,,,,,,520,,,,,,,,,520,,,,,520,520,520,520',
-',520,520,520,520,,,,,520,520,,,,516,516,516,520,516,520,520,520,516',
-'516,,,,516,,516,516,516,516,516,516,516,,,,,,516,516,516,516,516,516',
-'516,,,516,,,,,,,516,,,516,516,516,516,516,516,516,516,,516,516,516,',
-'516,516,,516,516,516,,,,,,,,,,,,,,,,,,,,516,,,516,,,516,516,,,516,,',
-',,,516,,,,,,,,,516,,,,,516,516,516,516,,516,516,516,516,,,,,516,516',
-',,,515,515,515,516,515,516,516,516,515,515,,,,515,,515,515,515,515,515',
-'515,515,,,,,,515,515,515,515,515,515,515,,,515,,,,,,,515,,,515,515,515',
-'515,515,515,515,515,,515,515,515,,515,515,,515,515,515,,,,,,,,,,,,,',
-',,,,,,515,,,515,,,515,515,,,515,,,,,,515,,,,,,,,,515,,,,,515,515,515',
-'515,,515,515,515,515,,,,,515,515,,,,512,512,512,515,512,515,515,515',
-'512,512,,,,512,,512,512,512,512,512,512,512,,,,,,512,512,512,512,512',
-'512,512,,,512,,,,,,,512,,,512,512,512,512,512,512,512,512,,512,512,512',
-',512,512,,,,512,,,,,,,,,,,,,,,,,,,,512,,,512,,,512,512,,,512,,,,,,,',
-',,,,,,,,,,,,512,512,512,512,,512,512,512,512,,,,,512,512,,,,506,506',
-'506,512,506,512,512,512,506,506,,,,506,,506,506,506,506,506,506,506',
-',,,,,506,506,506,506,506,506,506,,,506,,,,,,,506,,,506,506,506,506,506',
-'506,506,506,506,506,506,506,,506,506,,506,506,506,,,,,,,,,,,,,,,,,,',
-',506,,,506,,,506,506,,,506,,506,,506,,506,,,506,,,,,,506,,,,,506,506',
-'506,506,,506,506,506,506,,,,,506,506,,,,315,315,315,506,315,506,506',
-'506,315,315,,,,315,,315,315,315,315,315,315,315,,,,,,315,315,315,315',
-'315,315,315,,,315,,,,,,,315,,,315,315,315,315,315,315,315,315,,315,315',
-'315,,315,315,,,,315,,,,,,,,,,,,,,,,,,,,315,,,315,,,315,315,,,315,,,',
-',,,,,,,,,,,,,,,,315,315,315,315,,315,315,315,315,,,,,315,315,,,,504',
-'504,504,315,504,315,315,315,504,504,,,,504,,504,504,504,504,504,504',
-'504,,,,,,504,504,504,504,504,504,504,,,504,,,,,,,504,,,504,504,504,504',
-'504,504,504,504,,504,504,504,,504,504,,,,504,,,,,,,,,,,,,,,,,,,,504',
-',,504,,,504,504,,,504,,989,,989,989,989,989,989,,,,,,,,,,989,,504,504',
-'504,504,,504,504,504,504,,,,,504,504,,,,,,989,504,,504,504,504,496,496',
-'496,496,496,989,989,,496,496,989,,,496,,496,496,496,496,496,496,496',
-',,,,,496,496,496,496,496,496,496,,,496,,,,,,496,496,496,496,496,496',
-'496,496,496,496,496,496,,496,496,496,,496,496,,496,496,496,,,,,,,,,',
-',,,,,,,,,,496,,,496,,,496,496,,,496,,496,,,,496,,,,,,,,,496,,,,,496',
-'496,496,496,,496,496,496,496,,,,,496,496,,,,,,496,496,,496,496,496,490',
-'490,490,,490,,,,490,490,,,,490,,490,490,490,490,490,490,490,,,,,,490',
-'490,490,490,490,490,490,,,490,,,,,,,490,,,490,490,490,490,490,490,490',
-'490,,490,490,490,,490,490,,490,490,490,,,,,,,,,,,,,,,,,,,,490,,,490',
-',,490,490,,,490,,,,,,490,,,,,,,,,490,,,,,490,490,490,490,,490,490,490',
-'490,,,,,490,490,,,,323,323,323,490,323,490,490,490,323,323,,,,323,,323',
-'323,323,323,323,323,323,,,,,,323,323,323,323,323,323,323,,,323,,,,,',
-',323,,,323,323,323,323,323,323,323,323,,323,323,323,,323,323,,323,323',
-'323,,,,,,,,,,,,,,,,,,,,323,,,323,323,,323,323,,,323,,,,,,323,,,,,,,',
-',323,,,,,323,323,323,323,,323,323,323,323,,,,,323,323,,,,325,325,325',
-'323,325,323,323,323,325,325,,,,325,,325,325,325,325,325,325,325,,,,',
-',325,325,325,325,325,325,325,,,325,,,,,,,325,,,325,325,325,325,325,325',
-'325,325,,325,325,325,,325,325,,325,325,325,,,,,,,,,,,,,,,,,,,,325,,',
-'325,,,325,325,,,325,,,,,,325,,,,,,,,,325,,,,,325,325,325,325,,325,325',
-'325,325,,,,,325,325,,,,488,488,488,325,488,325,325,325,488,488,,,,488',
-',488,488,488,488,488,488,488,,,,,,488,488,488,488,488,488,488,,,488',
-',,,,,,488,,,488,488,488,488,488,488,488,488,488,488,488,488,,488,488',
-',488,488,488,,,,,,,,,,,,,,,,,,,,488,,,488,,,488,488,,,488,,,,488,,488',
-',,488,,,,,,488,,,,,488,488,488,488,,488,488,488,488,,,,,488,488,,,,486',
-'486,486,488,486,488,488,488,486,486,,,,486,,486,486,486,486,486,486',
-'486,,,,,,486,486,486,486,486,486,486,,,486,,,,,,,486,,,486,486,486,486',
-'486,486,486,486,486,486,486,486,,486,486,,486,486,486,,,,,,,,,,,,,,',
-',,,,,486,,,486,,,486,486,,,486,,486,,486,,486,,,486,,,,,,486,,,,,486',
-'486,486,486,,486,486,486,486,,,,,486,486,,,,472,472,472,486,472,486',
-'486,486,472,472,,,,472,,472,472,472,472,472,472,472,,,,,,472,472,472',
-'472,472,472,472,,,472,,,,,,,472,,,472,472,472,472,472,472,472,472,,472',
-'472,472,,472,472,,472,472,472,,,,,,,,,,,,,,,,,,,,472,,,472,,,472,472',
-',,472,,,,,,472,,,,,,,,,472,,,,,472,472,472,472,,472,472,472,472,,,,',
-'472,472,,,,446,446,446,472,446,472,472,472,446,446,,,,446,,446,446,446',
-'446,446,446,446,,,,,,446,446,446,446,446,446,446,,,446,,,,,,,446,,,446',
-'446,446,446,446,446,446,446,,446,446,446,,446,446,,446,446,446,,,,,',
-',,,,,,,,,,,,,,446,,,446,,,446,446,,,446,,,,,,446,,,,,,,,,446,,,,,446',
-'446,446,446,,446,446,446,446,,,,,446,446,,,,445,445,445,446,445,446',
-'446,446,445,445,,,,445,,445,445,445,445,445,445,445,,,,,,445,445,445',
-'445,445,445,445,,,445,,,,,,,445,,,445,445,445,445,445,445,445,445,,445',
-'445,445,,445,445,,445,445,445,,,,,,,,,,,,,,,,,,,,445,,,445,,,445,445',
-',,445,,,,,,445,,,,,,,,,445,,,,,445,445,445,445,,445,445,445,445,,,,',
-'445,445,,,,444,444,444,445,444,445,445,445,444,444,,,,444,,444,444,444',
-'444,444,444,444,,,,,,444,444,444,444,444,444,444,,,444,,,,,,,444,,,444',
-'444,444,444,444,444,444,444,,444,444,444,,444,444,,444,444,444,,,,,',
-',,,,,,,,,,,,,,444,,,444,,,444,444,,,444,,,,,,444,,,,,,,,,444,,,,,444',
-'444,444,444,,444,444,444,444,,,,,444,444,,,,442,442,442,444,442,444',
-'444,444,442,442,,,,442,,442,442,442,442,442,442,442,,,,,,442,442,442',
-'442,442,442,442,,,442,,,,,,,442,,,442,442,442,442,442,442,442,442,442',
-'442,442,442,,442,442,,442,442,442,,,,,,,,,,,,,,,,,,,,442,,,442,,,442',
-'442,,,442,,442,,442,,442,,,442,,,,,,442,,,,,442,442,442,442,,442,442',
-'442,442,,,,,442,442,,,,404,404,404,442,404,442,442,442,404,404,,,,404',
-',404,404,404,404,404,404,404,,,,,,404,404,404,404,404,404,404,,,404',
-',,,,,,404,,,404,404,404,404,404,404,404,404,,404,404,404,,404,404,,404',
-'404,404,,,,,,,,,,,,,,,,,,,,404,,,404,,,404,404,,,404,,,,,,404,,,,,,',
-',,404,,,,,404,404,404,404,,404,404,404,404,,,,,404,404,,,,340,340,340',
-'404,340,404,404,404,340,340,,,,340,,340,340,340,340,340,340,340,,,,',
-',340,340,340,340,340,340,340,,,340,,,,,,,340,,,340,340,340,340,340,340',
-'340,340,,340,340,340,,340,340,,340,340,340,,,,,,,,,,,,,,,,,,,,340,,',
-'340,,,340,340,,,340,,,,,,340,,,,,,,,,340,,,,,340,340,340,340,,340,340',
-'340,340,,,,,340,340,,,,376,376,376,340,376,340,340,340,376,376,,,,376',
-',376,376,376,376,376,376,376,,,,,,376,376,376,376,376,376,376,,,376',
-',,,,,,376,,,376,376,376,376,376,376,376,376,,376,376,376,,376,376,,376',
-'376,376,,,,,,,,,,,,,,,,,,,,376,,,376,,,376,376,,,376,,,,,,376,,,,,,',
-',,376,,,,,376,376,376,376,,376,376,376,376,,,,,376,376,,,,341,341,341',
-'376,341,376,376,376,341,341,,,,341,,341,341,341,341,341,341,341,,,,',
-',341,341,341,341,341,341,341,,,341,,,,,,,341,,,341,341,341,341,341,341',
-'341,341,,341,341,341,,341,341,,341,341,341,,,,,,,,,,,,,,,,,,,,341,,',
-'341,,,341,341,,,341,,,,,,341,,,,,,,,,341,,,,,341,341,341,341,,341,341',
-'341,341,,,,,341,341,,,,360,360,360,341,360,341,341,341,360,360,,,,360',
-',360,360,360,360,360,360,360,,,,,,360,360,360,360,360,360,360,,,360',
-',,,,,,360,,,360,360,360,360,360,360,360,360,,360,360,360,,360,360,,360',
-'360,360,,,,,,,,,,,,,,,,,,,,360,,,360,,,360,360,,,360,,,,,,360,,,,,,',
-',,360,,,,,360,360,360,360,,360,360,360,360,,,,,360,360,,,,,,,360,,360',
-'360,360,5,5,5,5,5,,,,5,5,,,,5,,5,5,5,5,5,5,5,,,,,,5,5,5,5,5,5,5,,,5',
-',,,,,5,5,5,5,5,5,5,5,5,5,5,5,,5,5,5,,5,5,,5,5,5,,,,,,,,,,,,,,,,,,,,5',
-',,5,,,5,5,,,5,,5,,,,5,,,,,,,,,5,,,,,5,5,5,5,,5,5,5,5,,,,,5,5,,,,923',
-'923,923,5,923,5,5,5,923,923,,,,923,,923,923,923,923,923,923,923,,,,',
-',923,923,923,923,923,923,923,,,923,,,,,,,923,,,923,923,923,923,923,923',
-'923,923,,923,923,923,,923,923,,923,923,923,,,,,,,,,,,,,,,,,,,,923,,',
-'923,,,923,923,,,923,,,,,,923,,,,,,,,,923,,,,,923,923,923,923,,923,923',
-'923,923,,,,,923,923,,,,886,886,886,923,886,923,923,923,886,886,,,,886',
-',886,886,886,886,886,886,886,,,,,,886,886,886,886,886,886,886,,,886',
-',,,,,,886,,,886,886,886,886,886,886,886,886,,886,886,886,,886,886,,',
-',886,,,,,,,,,,,,,,,,,,,,886,,,886,,,886,886,,,886,,,,,,,,,,,,,,,,,,',
-',886,886,886,886,,886,886,886,886,,,,,886,886,,,,874,874,874,886,874',
-'886,886,886,874,874,,,,874,,874,874,874,874,874,874,874,,,,,,874,874',
-'874,874,874,874,874,,,874,,,,,,,874,,,874,874,874,874,874,874,874,874',
-',874,874,874,,874,874,,,,874,,,,,,,,,,,,,,,,,,,,874,,,874,,,874,874',
-',,874,,,,,,,,,,,,,,,,,,,,874,874,874,874,,874,874,874,874,,,,,874,874',
-',,,860,860,860,874,860,874,874,874,860,860,,,,860,,860,860,860,860,860',
-'860,860,,,,,,860,860,860,860,860,860,860,,,860,,,,,,,860,,,860,860,860',
-'860,860,860,860,860,,860,860,860,,860,860,,860,860,860,,,,,,,,,,,,,',
-',,,,,,860,,,860,,,860,860,,,860,,,,,,860,,,,,,,,,860,,,,,860,860,860',
-'860,,860,860,860,860,,,,,860,860,,,,859,859,859,860,859,860,860,860',
-'859,859,,,,859,,859,859,859,859,859,859,859,,,,,,859,859,859,859,859',
-'859,859,,,859,,,,,,,859,,,859,859,859,859,859,859,859,859,859,859,859',
-'859,,859,859,,859,859,859,,,,,,,,,,,,,,,,,,,,859,,,859,,,859,859,,,859',
-',,,859,,859,,,859,,,,,,859,,,,,859,859,859,859,,859,859,859,859,,,,',
-'859,859,,,,842,842,842,859,842,859,859,859,842,842,,,,842,,842,842,842',
-'842,842,842,842,,,,,,842,842,842,842,842,842,842,,,842,,,,,,,842,,,842',
-'842,842,842,842,842,842,842,,842,842,842,,842,842,,842,842,842,,,,,',
-',,,,,,,,,,,,,,842,,,842,,,842,842,,,842,,842,,,,842,,,,,,,,,842,,,,',
-'842,842,842,842,,842,842,842,842,,,,,842,842,,,,20,20,20,842,20,842',
-'842,842,20,20,,,,20,,20,20,20,20,20,20,20,,,,,,20,20,20,20,20,20,20',
-',,20,,,,,,,20,,,20,20,20,20,20,20,20,20,,20,20,20,,20,20,,20,20,20,',
-',,,,,,,,,,,,,,,,,,20,,,20,,,20,20,,,20,,,,,,20,,,,,,,,,20,,,,,20,20',
-'20,20,,20,20,20,20,,,,,20,20,,,,837,837,837,20,837,20,20,20,837,837',
-',,,837,,837,837,837,837,837,837,837,,,,,,837,837,837,837,837,837,837',
-',,837,,,,,,,837,,,837,837,837,837,837,837,837,837,,837,837,837,,837',
-'837,,837,837,837,,,,,,,,,,,,,,,,,,,,837,,,837,,,837,837,,,837,,,,,,837',
-',,,,,,,,837,,,,,837,837,837,837,,837,837,837,837,,,,,837,837,,,,29,29',
-'29,837,29,837,837,837,29,29,,,,29,,29,29,29,29,29,29,29,,,,,,29,29,29',
-'29,29,29,29,,,29,,,,,,,29,,,29,29,29,29,29,29,29,29,29,29,29,29,,29',
-'29,,29,29,29,,,,,,,,,,,,,,,,,,,,29,,,29,,,29,29,,,29,,29,,29,,29,,,29',
-',,,,,29,,,,,29,29,29,29,,29,29,29,29,,,,,29,29,,,,30,30,30,29,30,29',
-'29,29,30,30,,,,30,,30,30,30,30,30,30,30,,,,,,30,30,30,30,30,30,30,,',
-'30,,,,,,,30,,,30,30,30,30,30,30,30,30,30,30,30,30,,30,30,,30,30,30,',
-',,,,,,,,,,,,,,,,,,30,,,30,,,30,30,,,30,,30,,30,,30,,,30,,,,,,30,,,,',
-'30,30,30,30,,30,30,30,30,,,,,30,30,,,,31,31,31,30,31,30,30,30,31,31',
-',,,31,,31,31,31,31,31,31,31,,,,,,31,31,31,31,31,31,31,,,31,,,,,,,31',
-',,31,31,31,31,31,31,31,31,31,31,31,31,,31,31,,31,31,31,,,,,,,,,,,,,',
-',,,,,,31,,,31,,,31,31,,,31,,31,,31,,31,,,31,,,,,,31,,,,,31,31,31,31',
-',31,31,31,31,,,,,31,31,,,,34,34,34,31,34,31,31,31,34,34,,,,34,,34,34',
-'34,34,34,34,34,,,,,,34,34,34,34,34,34,34,,,34,,,,,,,34,,,34,34,34,34',
-'34,34,34,34,,34,34,34,,34,34,,,,34,,,,,,,,,,,,,,,,,,,,34,,,34,,,34,34',
-',,34,,34,,,,,,,,,,,,,,,,,,34,34,34,34,,34,34,34,34,,,,,34,34,,,,35,35',
-'35,34,35,34,34,34,35,35,,,,35,,35,35,35,35,35,35,35,,,,,,35,35,35,35',
-'35,35,35,,,35,,,,,,,35,,,35,35,35,35,35,35,35,35,,35,35,35,,35,35,,',
-',35,,,,,,,,,,,,,,,,,,,,35,,,35,,,35,35,,,35,,1015,,1015,1015,1015,1015',
-'1015,,,,,,,,,,1015,,35,35,35,35,,35,35,35,35,,,,,35,35,,,,35,,1015,35',
-',35,35,35,787,787,787,,787,1015,1015,,787,787,1015,,,787,,787,787,787',
-'787,787,787,787,,,,,,787,787,787,787,787,787,787,,,787,,,,,,,787,,,787',
-'787,787,787,787,787,787,787,,787,787,787,,787,787,,,,787,,,,,,,,,,,',
-',,,,,,,,787,,,787,,,787,787,,,787,,,,,,,,,,,,,,,,,,,,787,787,787,787',
-',787,787,787,787,,,,,787,787,,,,773,773,773,787,773,787,787,787,773',
-'773,,,,773,,773,773,773,773,773,773,773,,,,,,773,773,773,773,773,773',
-'773,,,773,,,,,,,773,,,773,773,773,773,773,773,773,773,,773,773,773,',
-'773,773,,773,773,773,,,,,,,,,,,,,,,,,,,,773,,,773,,,773,773,,,773,,',
-',,,773,,,,,,,,,773,,,,,773,773,773,773,,773,773,773,773,,,,,773,773',
-',,,772,772,772,773,772,773,773,773,772,772,,,,772,,772,772,772,772,772',
-'772,772,,,,,,772,772,772,772,772,772,772,,,772,,,,,,,772,,,772,772,772',
-'772,772,772,772,772,,772,772,772,,772,772,,772,772,772,,,,,,,,,,,,,',
-',,,,,,772,,,772,,,772,772,,,772,,,,,,772,,,,,,,,,772,,,,,772,772,772',
-'772,,772,772,772,772,,,,,772,772,,,,771,771,771,772,771,772,772,772',
-'771,771,,,,771,,771,771,771,771,771,771,771,,,,,,771,771,771,771,771',
-'771,771,,,771,,,,,,,771,,,771,771,771,771,771,771,771,771,,771,771,771',
-',771,771,,771,771,771,,,,,,,,,,,,,,,,,,,,771,,,771,,,771,771,,,771,',
-',,,,771,,,,,,,,,771,,,,,771,771,771,771,,771,771,771,771,,,,,771,771',
-',,,42,42,42,771,42,771,771,771,42,42,,,,42,,42,42,42,42,42,42,42,,,',
-',,42,42,42,42,42,42,42,,,42,,,,,,,42,,,42,42,42,42,42,42,42,42,,42,42',
-'42,,42,42,,42,42,42,,,,,,,,,,,,,,,,,,,,42,,,42,,,42,42,,,42,,,,,,42',
-',,,,,,,,42,,,,,42,42,42,42,,42,42,42,42,,,,,42,42,,,,43,43,43,42,43',
-'42,42,42,43,43,,,,43,,43,43,43,43,43,43,43,,,,,,43,43,43,43,43,43,43',
-',,43,,,,,,,43,,,43,43,43,43,43,43,43,43,,43,43,43,,43,43,,43,43,43,',
-',,,,,,,,,,,,,,,,,,43,,,43,,,43,43,,,43,,,,,,43,,,,,,,,,43,,,,,43,43',
-'43,43,,43,43,43,43,,,,,43,43,,,,44,44,44,43,44,43,43,43,44,44,,,,44',
-',44,44,44,44,44,44,44,,,,,,44,44,44,44,44,44,44,,,44,,,,,,,44,,,44,44',
-'44,44,44,44,44,44,,44,44,44,,44,44,,44,44,44,,,,,,,,,,,,,,,,,,,,44,',
-',44,,,44,44,,,44,,,,,,44,,,,,,,,,44,,,,,44,44,44,44,,44,44,44,44,,,',
-',44,44,,,,770,770,770,44,770,44,44,44,770,770,,,,770,,770,770,770,770',
-'770,770,770,,,,,,770,770,770,770,770,770,770,,,770,,,,,,,770,,,770,770',
-'770,770,770,770,770,770,,770,770,770,,770,770,,770,770,770,,,,,,,,,',
-',,,,,,,,,,770,,,770,,,770,770,,,770,,,,,,770,,,,,,,,,770,,,,,770,770',
-'770,770,,770,770,770,770,,,,,770,770,,,,756,756,756,770,756,770,770',
-'770,756,756,,,,756,,756,756,756,756,756,756,756,,,,,,756,756,756,756',
-'756,756,756,,,756,,,,,,,756,,,756,756,756,756,756,756,756,756,,756,756',
-'756,,756,756,,756,756,756,,,,,,,,,,,,,,,,,,,,756,,,756,,,756,756,,,756',
-',,,,,756,,,,,,,,,756,,,,,756,756,756,756,,756,756,756,756,,,,,756,756',
-',,,985,985,985,756,985,756,756,756,985,985,,,,985,,985,985,985,985,985',
-'985,985,,,,,,985,985,985,985,985,985,985,,,985,,,,,,,985,,,985,985,985',
-'985,985,985,985,985,985,985,985,985,,985,985,,985,985,985,,,,,,,,,,',
-',,,,,,,,,985,,,985,,,985,985,,,985,,985,,985,,985,,,985,,,,,,985,,,',
-',985,985,985,985,,985,985,985,985,,,,,985,985,,,,754,754,754,985,754',
-'985,985,985,754,754,,,,754,,754,754,754,754,754,754,754,,,,,,754,754',
-'754,754,754,754,754,,,754,,,,,,,754,,,754,754,754,754,754,754,754,754',
-',754,754,754,,754,754,,754,754,754,,,,,,,,,,,,,,,,,,,,754,,,754,,,754',
-'754,,,754,,,,,,754,,,,,,,,,754,,,,,754,754,754,754,,754,754,754,754',
-',,,,754,754,,,,59,59,59,754,59,754,754,754,59,59,,,,59,,59,59,59,59',
-'59,59,59,,,,,,59,59,59,59,59,59,59,,,59,,,,,,,59,,,59,59,59,59,59,59',
-'59,59,59,59,59,59,,59,59,,59,59,59,,,,,,,,,,,,,,,,,,,,59,,,59,,,59,59',
-',,59,,59,,,,59,,,59,,,,,,59,,,,,59,59,59,59,,59,59,59,59,,,,,59,59,',
-',,60,60,60,59,60,59,59,59,60,60,,,,60,,60,60,60,60,60,60,60,,,,,,60',
-'60,60,60,60,60,60,,,60,,,,,,,60,,,60,60,60,60,60,60,60,60,60,60,60,60',
-',60,60,,60,60,60,,,,,,,,,,,,,,,,,,,,60,,,60,,,60,60,,,60,,,,,,60,,,60',
-',,,,,60,,,,,60,60,60,60,,60,60,60,60,,,,,60,60,,,,63,63,63,60,63,60',
-'60,60,63,63,,,,63,,63,63,63,63,63,63,63,,,,,,63,63,63,63,63,63,63,,',
-'63,,,,,,,63,,,63,63,63,63,63,63,63,63,,63,63,63,,63,63,,63,63,63,,,',
-',,,,,,,,,,,,,,,,63,,,63,,,63,63,,,63,,,,,,63,,,,,,,,,63,,,,,63,63,63',
-'63,,63,63,63,63,,,,,63,63,,,,64,64,64,63,64,63,63,63,64,64,,,,64,,64',
-'64,64,64,64,64,64,,,,,,64,64,64,64,64,64,64,,,64,,,,,,,64,,,64,64,64',
-'64,64,64,64,64,,64,64,64,,64,64,,64,64,64,,,,,,,,,,,,,,,,,,,,64,,,64',
-',,64,64,,,64,,,,,,64,,,,,,,,,64,,,,,64,64,64,64,,64,64,64,64,,,,,64',
-'64,,,,67,67,67,64,67,64,64,64,67,67,,,,67,,67,67,67,67,67,67,67,,,,',
-',67,67,67,67,67,67,67,,,67,,,,,,,67,,,67,67,67,67,67,67,67,67,,67,67',
-'67,,67,67,,67,67,67,,,,,,,,,,,,,,,,,,,,67,,,67,,,67,67,,,67,,,,,,67',
-',,,,,,,,67,,,,,67,67,67,67,,67,67,67,67,,,,,67,67,67,,,,,67,67,,67,67',
-'67,68,68,68,,68,,,,68,68,,,,68,,68,68,68,68,68,68,68,,,,,,68,68,68,68',
-'68,68,68,,,68,,,,,,,68,,,68,68,68,68,68,68,68,68,,68,68,68,,68,68,,',
-',68,,,,,,,,,,,,,,,,,,,,68,,,68,,,68,68,,,68,,68,,,,,,,,,,,,,,,,,,68',
-'68,68,68,,68,68,68,68,,,,,68,68,,,,69,69,69,68,69,68,68,68,69,69,,,',
-'69,,69,69,69,69,69,69,69,,,,,,69,69,69,69,69,69,69,,,69,,,,,,,69,,,69',
-'69,69,69,69,69,69,69,,69,69,69,,69,69,,,,69,,,,,,,,,,,,,,,,,69,,,69',
-',,69,,,69,69,,,69,,,,,,,,,,,,,,,,,,,,69,69,69,69,,69,69,69,69,,,,,69',
-'69,,,,70,70,70,69,70,69,69,69,70,70,,,,70,,70,70,70,70,70,70,70,,,,',
-',70,70,70,70,70,70,70,,,70,,,,,,,70,,,70,70,70,70,70,70,70,70,,70,70',
-'70,,70,70,,,,70,,,,,,,,,,,,,,,,,,,,70,,,70,,,70,70,,,70,,,,,,,,,,,,',
-',,,,,,,70,70,70,70,,70,70,70,70,,,,,70,70,,,,731,731,731,70,731,70,70',
-'70,731,731,,,,731,,731,731,731,731,731,731,731,,,,,,731,731,731,731',
-'731,731,731,,,731,,,,,,,731,,,731,731,731,731,731,731,731,731,,731,731',
-'731,,731,731,,731,731,731,,,,,,,,,,,,,,,,,,,,731,,,731,,,731,731,,,731',
-',,,,,731,,,,,,,,,731,,,,,731,731,731,731,,731,731,731,731,,,,,731,731',
-',,,,,,731,,731,731,731,111,111,111,111,111,,,,111,111,,,,111,,111,111',
-'111,111,111,111,111,,,,,,111,111,111,111,111,111,111,,,111,,,,,,111',
-'111,111,111,111,111,111,111,111,111,111,111,,111,111,111,,111,111,,111',
-'111,111,,,,,,,,,,,,,,,,,,,,111,,,111,,,111,111,,,111,,111,,,,111,,,',
-',,,,,111,,,,,111,111,111,111,,111,111,111,111,,,,,111,111,,,,,424,111',
-'111,,111,111,111,424,424,424,,,424,424,424,,424,,,,,,,,,424,424,424',
-'424,,,,,,,,424,424,,424,424,424,424,424,,,,,,,,,,,,,,,,,,,,,,,,424,424',
-'424,424,424,424,424,424,424,424,424,424,424,424,,,424,424,424,,,424',
-',,424,,,424,424,,424,,424,,424,,424,424,,424,424,424,424,424,,424,424',
-'424,,,,,,,,,,,,,,424,,,424,424,424,424,56,424,,424,,,,56,56,56,,,56',
-'56,56,,56,,,,,,,,,,56,56,56,,,,,,,,56,56,,56,56,56,56,56,,,,,,,,,,,',
-',,,,,,,,,,,,56,56,56,56,56,56,56,56,56,56,56,56,56,56,,,56,56,56,,,56',
-',,56,,,56,56,,56,,56,,56,,56,56,,56,56,56,56,56,,56,,56,,,,,,,,,,,,',
-',56,,,56,56,56,56,425,56,,56,,,,425,425,425,,,425,425,425,,425,,,,,',
-',,,425,425,425,425,,,,,,,,425,425,,425,425,425,425,425,,,,,,,,,,,,,',
-',,,,,,,,,,425,425,425,425,425,425,425,425,425,425,425,425,425,425,,',
-'425,425,425,,,425,,,425,,,425,425,,425,,425,,425,,425,425,,425,425,425',
-'425,425,,425,425,425,,,,,,,,,,,,,,425,,,425,425,425,425,27,425,,425',
-',,,27,27,27,,,27,27,27,,27,,,,,,,,,27,27,27,,,,,,,,,27,27,,27,27,27',
-'27,27,,,,,,,,,,,,,,,,,,,,,,,,27,27,27,27,27,27,27,27,27,27,27,27,27',
-'27,,,27,27,27,,,27,,27,27,,,27,27,,27,,27,,27,,27,27,,27,27,27,27,27',
-',27,27,27,,,,,,,,,,,,,,27,,474,27,27,,27,,27,474,474,474,,,474,474,474',
-'646,474,646,646,646,646,646,,,,474,474,,,,,646,,,,,474,474,,474,474',
-'474,474,474,,,,,,,,,,646,,,,,,,,,646,646,646,646,,,,646,,,,,,,,,474',
-',28,,,,,474,,28,28,28,474,474,28,28,28,646,28,,,,,,,,,,28,28,,,,,,474',
-'474,,28,28,,28,28,28,28,28,,,,,474,,,474,,,,,474,,,,,,,,,,,28,28,28',
-'28,28,28,28,28,28,28,28,28,28,28,,,28,28,28,,,28,,28,28,,,28,28,,28',
-',28,,28,,28,28,,28,28,28,28,28,,28,415,28,,,,,,415,415,415,,,415,415',
-'415,28,415,,28,28,,28,,28,,415,415,415,,,,,,,,,415,415,,415,415,415',
-'415,415,,,,,,,,,,,,,,,,,,,,,,,,415,415,415,415,415,415,415,415,415,415',
-'415,415,415,415,,,415,415,415,,,415,,415,415,,,415,415,,415,,415,,415',
-',415,415,,415,415,415,415,415,,415,415,415,,,,,,,,,,,,,,415,,,415,415',
-',415,,415,616,616,616,616,616,616,616,616,616,616,616,616,616,616,616',
-'616,616,616,616,616,616,616,616,616,,,,616,616,616,616,616,616,616,616',
-'616,616,,,,,,616,616,616,616,616,616,616,616,616,,,616,,,,,,,,,616,616',
-',616,616,616,616,616,616,616,,,616,616,,,,616,616,616,616,,,,,,,,,,',
-',,,616,616,,616,616,616,616,616,616,616,616,616,616,616,616,,,616,616',
-',,,,,,,,,,,,,616,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,,,',
-'8,8,8,8,8,8,8,8,8,8,,,,,,8,8,8,8,8,8,8,8,8,8,,8,,,,,,,,,8,8,,8,8,8,8',
-'8,8,8,,,8,8,,,,8,8,8,8,,,,,,,,,,,,,,8,8,,8,8,8,8,8,8,8,8,8,8,8,8,,,8',
-'8,,,,,,,,,,,,,,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,,,',
-'9,9,9,9,9,9,9,9,9,9,,,,,,9,9,9,9,9,9,9,9,9,,,9,,,,,,,,,9,9,,9,9,9,9',
-'9,9,9,,,9,9,,,,9,9,9,9,,,,,,,,,,,,,,9,9,,9,9,9,9,9,9,9,9,9,9,9,9,,,9',
-'9,,,,,,,,,,,,,,9,395,395,395,395,395,395,395,395,395,395,395,395,395',
-'395,395,395,395,395,395,395,395,395,395,395,,,,395,395,395,395,395,395',
-'395,395,395,395,,,,,,395,395,395,395,395,395,395,395,395,,,395,,,,,',
-',,,395,395,,395,395,395,395,395,395,395,,,395,395,,,,395,395,395,395',
-',,,,,,,,,,,,,395,395,,395,395,395,395,395,395,395,395,395,395,395,395',
-',,395,395,,,,,,,,,,,,,,395,738,738,738,738,738,738,738,738,738,738,738',
-'738,738,738,738,738,738,738,738,738,738,738,738,738,,,,738,738,738,738',
-'738,738,738,738,738,738,,,,,,738,738,738,738,738,738,738,738,738,,,738',
-',,,,,,,,738,738,,738,738,738,738,738,738,738,,,738,738,,,,738,738,738',
-'738,,,,,,,,,,,,,,738,738,,738,738,738,738,738,738,738,738,738,738,738',
-'738,,,738,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71',
-'71,71,71,71,,,,71,71,71,71,71,71,71,71,71,71,,,,,,71,71,71,71,71,71',
-'71,71,71,71,71,71,,71,,,,,,,71,71,,71,71,71,71,71,71,71,,,71,71,,,,71',
-'71,71,71,,,,,,71,,,,,,,,71,71,,71,71,71,71,71,71,71,71,71,71,71,71,508',
-'508,71,,508,,,,,,,,,508,508,,508,508,508,508,508,508,508,,,508,508,',
-',,508,508,508,508,,,,,,508,,,,,,,,508,508,,508,508,508,508,508,508,508',
-'508,508,508,508,508,987,987,508,,987,,,,,,,,,987,987,,987,987,987,987',
-'987,987,987,,,987,987,,,,987,987,987,987,,,,,,987,,,,,,,,987,987,,987',
-'987,987,987,987,987,987,987,987,987,987,987,441,441,987,,441,,,,,,,',
-',441,441,,441,441,441,441,441,441,441,,,441,441,,,,441,441,441,441,',
-',,,,441,,,,,,,,441,441,,441,441,441,441,441,441,441,441,441,441,441',
-'441,440,440,441,,440,,,,,,,,,440,440,,440,440,440,440,440,440,440,,',
-'440,440,,,,440,440,440,440,,,,,,440,,,,,,,,440,440,,440,440,440,440',
-'440,440,440,440,440,440,440,440,507,507,440,,507,,,,,,,,,507,507,,507',
-'507,507,507,507,507,507,,,507,507,,,,507,507,507,507,,,,,,507,,,,,,',
-',507,507,,507,507,507,507,507,507,507,507,507,507,507,507,576,576,507',
-',576,,,,,,,,,576,576,,576,576,576,576,576,576,576,,,576,576,,,,576,576',
-'576,576,,,,,,576,,,,,,,,576,576,,576,576,576,576,576,576,576,576,576',
-'576,576,576,577,577,576,,577,,,,,,,,,577,577,,577,577,577,577,577,577',
-'577,,,577,577,,,,577,577,577,577,,,,,,577,,,,,,,,577,577,,577,577,577',
-'577,577,577,577,577,577,577,577,577,939,939,577,,939,,,,,,,,,939,939',
-',939,939,939,939,939,939,939,,,939,939,,,,939,939,939,939,,,,,,939,',
-',,,,,,939,939,,939,939,939,939,939,939,939,939,939,939,939,939,583,583',
-'939,,583,,,,,,,,,583,583,,583,583,583,583,583,583,583,,,583,583,,,,583',
-'583,583,583,,,,,,583,,,,,,,,583,583,,583,583,583,583,583,583,583,583',
-'583,583,583,583,517,517,583,,517,,,,,,,,,517,517,,517,517,517,517,517',
-'517,517,,,517,517,,,,517,517,517,517,,,,,,517,,,,,,,,517,517,,517,517',
-'517,517,517,517,517,517,517,517,517,517,584,584,517,,584,,,,,,,,,584',
-'584,,584,584,584,584,584,584,584,,,584,584,,,,584,584,584,584,,,,,,584',
-',,,,,,,584,584,,584,584,584,584,584,584,584,584,584,584,584,584,518',
-'518,584,,518,,,,,,,,,518,518,,518,518,518,518,518,518,518,,,518,518',
-',,,518,518,518,518,,,,,,518,,,,,,,,518,518,,518,518,518,518,518,518',
-'518,518,518,518,518,518,259,259,518,,259,,,,,,,,,259,259,,259,259,259',
-'259,259,259,259,,,259,259,,,,259,259,259,259,,,,,,,,,,,,,,259,259,,259',
-'259,259,259,259,259,259,259,259,259,259,259,210,210,259,,210,,,,,,,',
-',210,210,,210,210,210,210,210,210,210,,,210,210,,,,210,210,210,210,',
-',,,,210,,,,,,,,210,210,,210,210,210,210,210,210,210,210,210,210,210',
-'210,986,986,210,,986,,,,,,,,,986,986,,986,986,986,986,986,986,986,,',
-'986,986,,,,986,986,986,986,,,,,,986,,,,,,,,986,986,,986,986,986,986',
-'986,986,986,986,986,986,986,986,211,211,986,,211,,,,,,,,,211,211,,211',
-'211,211,211,211,211,211,,,211,211,,,,211,211,211,211,,,,,,211,,,,,,',
-',211,211,,211,211,211,211,211,211,211,211,211,211,211,211,,893,211,893',
-'893,893,893,893,,977,,977,977,977,977,977,,893,336,,336,336,336,336',
-'336,977,534,,534,534,534,534,534,,336,,,,,893,,,534,,,,,977,893,893',
-'893,893,,,,893,336,336,977,977,,,,977,534,336,336,336,336,,,,336,534',
-'534,534,534,,,975,534,975,975,975,975,975,973,,973,973,973,973,973,',
-'971,975,971,971,971,971,971,,973,,,,,,,737,971,737,737,737,737,737,',
-'975,,,,,,,973,737,,,975,975,,,971,975,,973,973,,,,973,971,971,971,971',
-',,737,971,736,,736,736,736,736,736,737,737,737,737,,,,737,693,736,693',
-'693,693,693,693,,865,,865,865,865,865,865,,693,,,,,,,736,865,867,,867',
-'867,867,867,867,736,736,736,736,,,693,736,,867,,,,,865,693,693,693,693',
-',,,693,865,865,865,865,,,,865,867,869,,869,869,869,869,869,,867,867',
-'867,867,,,,867,869,695,,695,695,695,695,695,697,,697,697,697,697,697',
-',,695,,,,,869,,697,899,,899,899,899,899,899,,869,869,,,,869,695,,899',
-',,,,697,,695,695,695,695,,,,695,,697,697,,,,697,899,895,,895,895,895',
-'895,895,,,,899,899,,,,899,895,,,,,,,,,,,,,,,,,,,,,,895,,,,,,,,,,,895',
-'895,,,,895' ]
- racc_action_check = arr = ::Array.new(25310, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_action_pointer = [
- 3995, 568, nil, -83, nil, 17702, 1301, 370, 23341, 23470,
- 1210, nil, 1170, 1222, 425, 419, 1157, 605, nil, -75,
- 18626, 2726, 1263, nil, 476, nil, 162, 22754, 22964, 18890,
- 19022, 19154, nil, 1739, 19286, 19418, nil, 1069, -77, 140,
- 1112, 197, 20086, 20218, 20350, 1034, 965, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 22484, nil, -70, 21010,
- 21142, 71, nil, 21274, 21406, nil, nil, 21538, 21678, 21810,
- 21942, 23842, nil, nil, nil, nil, nil, 143, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 359, nil, nil, 472, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 1121,
- nil, 22214, nil, nil, nil, nil, 5114, 5246, 5378, 5510,
- 5650, 2021, nil, 585, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 928, nil, 2585, 6046, 6178, 6310,
- 24710, 24834, 6706, 6838, 6970, 7102, 7234, 7366, nil, nil,
- 1175, 110, 358, 953, 205, 863, 897, nil, 7894, 1598,
- 890, 8026, 8158, 8290, 8422, 8554, 8686, 8818, 8950, 9082,
- 9214, 9346, 9478, 9610, 9742, 9874, 10006, 10138, 10270, 10402,
- 10534, 10666, 10798, 10930, 11062, 11194, nil, nil, nil, 24648,
- nil, nil, 878, 11590, 11722, nil, nil, nil, nil, nil,
- nil, nil, 11854, nil, 1598, nil, 815, 800, nil, 12382,
- 845, 12646, nil, nil, 12778, 12910, nil, nil, 285, nil,
- 13182, 1442, 817, 786, 4277, 770, 809, 756, 13974, 4841,
- 896, 794, 935, 812, 1037, nil, 752, 681, 10, nil,
- nil, nil, 690, 252, 632, 15302, nil, 490, 671, 752,
- nil, 664, nil, 15846, 2726, 15978, 578, nil, 373, 247,
- 811, 803, 170, 905, nil, nil, 24914, 688, 32, -11,
- 17166, 17430, -72, 185, 392, 7, 38, 580, 1104, 5,
- 1124, nil, nil, 217, 507, 134, nil, 617, nil, 16,
- 17562, nil, nil, nil, 108, 576, 185, 312, 397, 513,
- 554, -20, 562, nil, 251, nil, 17298, nil, 410, 404,
- 395, 463, 283, -22, 30, 351, nil, nil, nil, nil,
- nil, nil, nil, nil, 1025, 23599, nil, nil, nil, nil,
- 1020, nil, nil, 995, 17034, 963, nil, nil, 1034, 963,
- nil, 956, 942, 318, 143, 23077, nil, nil, nil, 248,
- 137, 970, nil, nil, 22349, 22619, nil, 1316, nil, 885,
- nil, nil, 752, nil, nil, nil, nil, -14, nil, 936,
- 24090, 24028, 16902, 150, 16770, 16638, 16506, 3713, 4136, 527,
- 321, 724, 711, 666, 605, 5246, 5378, 5510, 3995, 4277,
- 3290, 3431, 3854, 4418, 4700, 4841, 4559, 5114, 3149, 3155,
- 3572, 4982, 16374, 115, 22884, nil, nil, nil, nil, 544,
- nil, 86, 144, 568, nil, nil, 16242, nil, 16110, nil,
- 15714, nil, 219, nil, nil, nil, 15574, 1457, 2162, 615,
- 616, nil, nil, 625, 15434, 634, 15170, 24152, 23904, 329,
- 686, nil, 15038, 645, nil, 14906, 14774, 24462, 24586, 1457,
- 14642, 808, 825, 712, 748, nil, 14510, nil, nil, 14378,
- nil, nil, nil, nil, 24922, nil, 709, 713, nil, 718,
- 723, 731, nil, nil, nil, nil, nil, nil, nil, nil,
- 723, 616, nil, nil, 14246, nil, nil, nil, 826, nil,
- nil, nil, 827, nil, nil, 829, 893, 871, nil, 752,
- 67, 63, 869, 878, 14114, 13842, 24214, 24276, 58, nil,
- nil, 1106, nil, 24400, 24524, 13710, nil, nil, nil, 281,
- -18, 4136, 815, nil, -12, nil, nil, nil, 735, nil,
- nil, nil, 787, nil, nil, 391, nil, 239, nil, nil,
- 784, nil, 785, nil, nil, nil, 23212, nil, 787, 13578,
- 13446, 485, 837, 13314, 13042, 12514, 12250, 838, nil, nil,
- 12118, 11986, 859, nil, 11458, 11326, nil, nil, 316, 276,
- 609, 0, 857, 893, 1739, nil, 22848, nil, 1316, 980,
- 27, 157, nil, 1175, 1034, nil, 884, nil, 931, 7762,
- nil, nil, 7630, nil, 907, -80, 7498, 890, nil, 895,
- 92, 57, 941, 480, 1034, 952, 912, 6574, 1880, 980,
- 145, 1034, 6442, nil, 927, nil, 465, 27, 930, 634,
- nil, nil, 348, 25060, nil, 25141, nil, 25148, nil, 5914,
- nil, 609, nil, 936, 243, 940, nil, nil, nil, nil,
- 599, nil, 1059, nil, nil, nil, nil, 1065, nil, 33,
- 944, 25, 22, 68, 8, 5782, 328, 517, nil, 985,
- 4418, 22074, nil, nil, 1116, 3713, 25045, 25005, 23728, nil,
- nil, nil, nil, nil, nil, 2444, nil, nil, nil, nil,
- nil, nil, nil, 1013, 20878, 2021, 20614, nil, 1015, nil,
- 1175, nil, 2162, nil, nil, 2303, nil, 2444, nil, 2585,
- 20482, 19954, 19822, 19690, -83, 1035, 1035, 1038, nil, 1048,
- 1049, 1053, nil, 1078, 1058, 1063, 1058, 19558, nil, nil,
- 1193, nil, nil, 2867, 1097, 1208, nil, nil, nil, nil,
- 1097, 256, nil, nil, 1227, nil, 4559, 534, 1150, nil,
- nil, 1165, nil, nil, 3854, 3572, 1166, 1128, nil, nil,
- nil, 1129, 1131, nil, 1132, 1136, nil, 1138, nil, nil,
- 1144, 3135, 1146, 675, nil, 1279, nil, 18758, 1280, 3290,
- 3149, nil, 18494, 1880, -19, 24, nil, 1286, 358, 1457,
- nil, 1292, 1171, 98, nil, 1175, 1172, nil, 2867, 18362,
- 18230, nil, 3118, nil, nil, 25068, nil, 25085, nil, 25124,
- nil, nil, 1198, 1161, 18098, 1076, 1255, nil, 1197, nil,
- nil, nil, 3008, nil, nil, 35, 17966, nil, nil, 1210,
- -3, nil, nil, 24897, nil, 25204, nil, 14021, nil, 25165,
- nil, nil, nil, nil, 255, 3174, -114, nil, -1, nil,
- 77, 93, nil, 289, nil, nil, nil, 102, nil, nil,
- nil, 105, nil, 17834, 84, nil, nil, 99, 105, 132,
- 144, nil, 206, nil, 393, nil, nil, nil, 440, 24338,
- nil, nil, nil, 4700, 642, 666, 683, 315, 755, nil,
- nil, nil, 260, 270, 281, 306, 323, 3276, 340, 3309,
- 3431, nil, nil, nil, nil, nil, 2303, nil, 4982, 3008,
- nil, 24990, nil, 24982, nil, 24975, nil, 24905, nil, nil,
- nil, 1302, 443, 448, 557, 20746, 24772, 23966, 824, 15481,
- nil, nil, nil, nil, 602, 449, 20, 578, 605, 493,
- 495, 674, 819, nil, nil, 867, -9, -10, 39, 893,
- 1026, 1028, nil, nil, nil, 19465, nil, nil, nil, nil,
- 18, nil, 907, nil ]
-
-racc_action_default = [
- -3, -597, -1, -583, -4, -597, -7, -597, -597, -597,
- -597, -29, -597, -597, -597, -281, -597, -40, -43, -585,
- -597, -48, -50, -51, -52, -56, -258, -258, -258, -295,
- -330, -331, -68, -11, -72, -80, -82, -597, -488, -489,
- -597, -597, -597, -597, -597, -585, -239, -272, -273, -274,
- -275, -276, -277, -278, -279, -280, -573, -283, -285, -596,
- -563, -303, -391, -597, -597, -308, -311, -583, -597, -597,
- -597, -597, -332, -333, -429, -430, -431, -432, -433, -454,
- -436, -437, -456, -458, -441, -446, -450, -452, -468, -456,
- -470, -472, -473, -474, -475, -571, -477, -478, -572, -480,
- -481, -482, -483, -484, -485, -486, -487, -492, -493, -597,
- -2, -584, -592, -593, -594, -6, -597, -597, -597, -597,
- -597, -3, -17, -597, -111, -112, -113, -114, -115, -116,
- -117, -118, -119, -123, -124, -125, -126, -127, -128, -129,
- -130, -131, -132, -133, -134, -135, -136, -137, -138, -139,
- -140, -141, -142, -143, -144, -145, -146, -147, -148, -149,
- -150, -151, -152, -153, -154, -155, -156, -157, -158, -159,
- -160, -161, -162, -163, -164, -165, -166, -167, -168, -169,
- -170, -171, -172, -173, -174, -175, -176, -177, -178, -179,
- -180, -181, -182, -183, -184, -185, -186, -187, -188, -189,
- -190, -191, -192, -193, -22, -120, -11, -597, -597, -248,
- -597, -597, -597, -597, -597, -597, -597, -585, -586, -47,
- -597, -488, -489, -597, -281, -597, -597, -229, -597, -11,
- -597, -597, -597, -597, -597, -597, -597, -597, -597, -597,
- -597, -597, -597, -597, -597, -597, -597, -597, -597, -597,
- -597, -597, -597, -597, -597, -597, -236, -398, -400, -597,
- -581, -582, -57, -248, -597, -302, -404, -413, -415, -63,
- -410, -64, -585, -65, -240, -253, -262, -262, -257, -597,
- -263, -597, -454, -565, -597, -597, -66, -67, -583, -12,
- -597, -15, -597, -70, -11, -585, -597, -73, -76, -11,
- -88, -89, -597, -597, -96, -295, -298, -585, -597, -330,
- -331, -334, -411, -597, -78, -597, -84, -292, -471, -597,
- -214, -215, -230, -597, -11, -597, -585, -241, -589, -589,
- -597, -597, -589, -597, -304, -305, -521, -49, -597, -597,
- -597, -597, -583, -597, -584, -488, -489, -597, -597, -281,
- -597, -344, -345, -106, -107, -597, -109, -597, -281, -597,
- -597, -488, -489, -323, -111, -112, -153, -154, -155, -171,
- -176, -183, -186, -325, -597, -561, -597, -434, -597, -597,
- -597, -597, -597, -597, -597, -597, 1024, -5, -595, -23,
- -24, -25, -26, -27, -597, -597, -19, -20, -21, -121,
- -597, -30, -39, -268, -597, -597, -267, -31, -196, -585,
- -249, -262, -262, -574, -575, -258, -408, -576, -577, -575,
- -574, -258, -407, -409, -576, -577, -37, -204, -38, -597,
- -41, -42, -194, -263, -44, -45, -46, -585, -301, -597,
- -597, -597, -248, -292, -597, -597, -597, -205, -206, -207,
- -208, -209, -210, -211, -212, -216, -217, -218, -219, -220,
- -221, -222, -223, -224, -225, -226, -227, -228, -231, -232,
- -233, -234, -597, -380, -258, -574, -575, -54, -58, -585,
- -259, -380, -380, -585, -297, -254, -597, -255, -597, -260,
- -597, -264, -597, -568, -570, -10, -584, -14, -3, -585,
- -69, -290, -85, -74, -597, -585, -248, -597, -597, -95,
- -597, -471, -597, -81, -86, -597, -597, -597, -597, -235,
- -597, -421, -597, -286, -597, -242, -591, -590, -244, -591,
- -293, -294, -564, -392, -521, -395, -560, -560, -504, -506,
- -506, -506, -520, -522, -523, -524, -525, -526, -527, -528,
- -529, -597, -531, -533, -535, -540, -542, -543, -545, -550,
- -552, -553, -555, -556, -557, -597, -11, -335, -336, -11,
- -597, -597, -597, -597, -597, -248, -597, -597, -292, -316,
- -106, -107, -108, -597, -597, -248, -319, -494, -495, -597,
- -597, -11, -499, -327, -585, -435, -455, -460, -597, -462,
- -438, -457, -597, -459, -440, -597, -443, -597, -445, -448,
- -597, -449, -597, -469, -8, -18, -597, -28, -271, -597,
- -597, -412, -597, -250, -252, -597, -597, -59, -247, -405,
- -597, -597, -61, -406, -597, -597, -300, -587, -574, -575,
- -574, -575, -585, -194, -585, -381, -585, -383, -11, -53,
- -401, -380, -245, -11, -11, -296, -262, -261, -265, -597,
- -566, -567, -597, -13, -597, -71, -597, -77, -83, -585,
- -574, -575, -246, -92, -94, -597, -79, -597, -203, -213,
- -585, -596, -596, -284, -585, -289, -589, -597, -585, -597,
- -502, -503, -597, -597, -513, -597, -516, -597, -518, -597,
- -346, -597, -348, -350, -357, -585, -534, -544, -554, -558,
- -596, -337, -596, -309, -338, -339, -312, -597, -315, -597,
- -585, -574, -575, -578, -291, -597, -106, -107, -110, -585,
- -11, -597, -497, -321, -597, -11, -521, -521, -597, -562,
- -461, -464, -465, -466, -467, -11, -439, -442, -444, -447,
- -451, -453, -122, -269, -597, -197, -597, -588, -262, -33,
- -199, -34, -200, -60, -35, -202, -36, -201, -62, -195,
- -597, -597, -597, -597, -412, -597, -560, -560, -362, -364,
- -364, -364, -379, -597, -585, -385, -529, -537, -538, -548,
- -597, -403, -402, -11, -597, -597, -256, -266, -569, -16,
- -75, -90, -87, -299, -596, -342, -11, -422, -596, -423,
- -424, -597, -243, -393, -11, -11, -597, -560, -541, -559,
- -505, -506, -506, -532, -506, -506, -551, -506, -529, -546,
- -585, -597, -355, -597, -530, -597, -340, -597, -597, -11,
- -11, -314, -597, -11, -412, -597, -412, -597, -597, -11,
- -324, -597, -585, -597, -328, -597, -270, -32, -198, -251,
- -597, -237, -597, -360, -361, -370, -372, -597, -375, -597,
- -377, -382, -597, -597, -597, -536, -597, -399, -597, -414,
- -416, -9, -11, -428, -343, -597, -597, -426, -287, -597,
- -597, -394, -501, -597, -509, -597, -511, -597, -514, -597,
- -517, -519, -347, -349, -353, -597, -358, -306, -597, -307,
- -597, -597, -265, -596, -317, -320, -496, -597, -326, -498,
- -500, -499, -463, -597, -560, -539, -363, -364, -364, -364,
- -364, -549, -364, -384, -585, -387, -389, -390, -547, -597,
- -292, -55, -427, -11, -97, -98, -597, -597, -105, -425,
- -396, -397, -506, -506, -506, -506, -351, -597, -356, -597,
- -11, -310, -313, -417, -418, -419, -11, -322, -11, -238,
- -359, -597, -367, -597, -369, -597, -373, -597, -376, -378,
- -386, -597, -291, -578, -421, -248, -597, -597, -104, -597,
- -507, -510, -512, -515, -597, -354, -596, -597, -597, -364,
- -364, -364, -364, -388, -420, -585, -574, -575, -578, -103,
- -506, -352, -341, -318, -329, -597, -365, -368, -371, -374,
- -412, -508, -364, -366 ]
-
-clist = [
-'216,275,275,275,14,373,681,415,421,14,327,522,409,334,266,270,311,311',
-'258,431,130,130,573,110,220,535,323,2,735,438,700,127,127,220,220,220',
-'406,14,302,302,487,259,428,566,569,297,276,276,276,660,311,311,311,111',
-'114,835,474,513,338,339,378,318,342,122,205,478,479,220,220,219,937',
-'220,347,357,357,705,328,582,132,132,6,542,690,691,484,6,293,343,337',
-'337,660,621,337,823,127,295,780,277,277,277,903,262,269,271,314,525',
-'528,500,826,532,783,389,390,391,392,14,804,966,114,935,220,220,220,220',
-'14,14,115,329,332,713,716,906,730,379,657,849,657,359,363,931,385,337',
-'337,337,337,605,607,838,394,591,781,592,816,13,738,921,684,325,13,324',
-'374,601,603,606,606,782,586,601,648,350,335,331,694,696,698,487,653',
-'654,937,784,700,275,375,832,650,660,13,330,273,286,287,6,923,934,1,533',
-'550,822,416,824,393,6,813,958,336,687,472,616,473,481,14,220,220,220',
-'482,963,220,220,220,220,220,220,808,688,405,830,885,1003,903,377,405',
-'380,387,14,425,275,275,415,421,434,435,436,437,931,275,642,667,381,872',
-'636,651,717,382,383,676,995,401,407,384,740,745,426,430,492,13,823,731',
-'220,220,395,402,657,657,13,13,821,220,352,734,542,311,276,204,663,818',
-'925,881,340,510,276,326,652,1011,839,14,655,266,311,14,823,270,341,302',
-'14,672,728,826,524,495,669,700,665,700,840,672,927,725,668,,302,,,863',
-'864,774,,514,,14,220,,,277,511,,570,571,,496,114,277,1012,,,220,220',
-'793,293,964,,523,801,293,,,,499,968,,13,,505,572,892,220,337,337,503',
-',928,497,929,,672,,,,823,720,,220,672,13,956,700,590,,748,729,748,622',
-'593,,114,550,,,952,,,,594,844,628,914,,739,130,800,633,587,846,,,275',
-',,847,127,796,660,,851,480,843,852,853,,416,,763,483,,,,768,700,,700',
-',431,,,13,,,220,13,,,615,,13,,894,896,,898,900,,901,,628,812,425,132',
-',,,1004,970,,,700,,999,,13,275,,296,542,542,,,,311,,,,627,,803,,311',
-'416,632,,,26,14,,14,,26,416,786,657,302,,220,809,,,,514,302,834,,26',
-',796,,514,220,664,,,26,26,26,425,26,,,,917,,,,,425,,,,680,,275,,649',
-',,,550,656,550,,275,,,,,26,26,416,,26,,,,14,,416,14,,,,,6,220,,,,,,990',
-'991,992,993,220,943,719,965,,686,14,550,550,,,425,,792,,,,425,,,,26',
-',,960,,26,26,26,26,26,26,714,714,622,,775,,785,130,220,220,,,810,220',
-'220,,,220,127,732,733,902,1021,,791,,,311,13,622,13,14,400,,998,,14',
-'14,311,628,,,633,919,811,,,,785,302,752,854,,759,761,296,514,,764,766',
-'302,,430,,,132,1020,802,,,758,,787,,,,,,405,,622,777,,,26,26,26,26,',
-'622,26,26,26,26,26,26,,,13,845,,13,,,786,848,786,26,220,,,,,14,220,',
-',,14,,296,,,13,817,296,,,14,337,,15,550,,883,337,15,,887,220,127,26',
-'26,,785,,,,311,,26,,,,,,,866,868,870,,,672,,15,304,304,1005,26,,875',
-',26,,,,14,26,,,13,,,,857,13,13,,778,14,,,,,,,,14,14,349,358,358,26,26',
-',,,,,,786,908,,,,779,,,26,26,220,,14,14,,,14,,,,,819,14,,819,311,,,26',
-',,337,15,,,,,311,,,,15,15,,26,,,938,,,,,13,,825,14,827,13,,946,,,,,',
-'714,,13,916,,,,,920,,,,,787,,,787,,787,980,787,,924,,,777,,777,,777',
-'972,974,976,978,,979,,,,,,,,,,26,,,,,13,14,,,333,,,,,,,275,15,13,,,425',
-',14,,,13,13,,14,,14,,416,,,,,,,15,,,,,622,,,220,,,13,13,,26,13,26,1016',
-'1017,1018,1019,13,,,26,,16,,,425,,16,710,,,712,,787,26,787,1023,787',
-',787,819,,777,778,777,778,777,778,777,,13,,,,,16,,15,,,,15,,,,304,15',
-',,,,,930,,932,,,787,,,26,,304,26,,,777,,39,26,351,15,,39,,,,,953,26',
-'954,,955,,,26,,,,,790,13,403,,,794,795,,433,,,39,301,301,,,,,13,,,,',
-'16,13,,13,,,26,26,,16,16,26,26,,,26,778,,778,,778,,778,346,362,362,362',
-',,26,,,,,26,26,,,,,,,,1000,,1001,,1002,,,,489,,491,,,493,494,,,778,1010',
-',,,,39,,,,,,,,855,39,39,,,,,,,,,,,1022,,,,,,,,16,,,,,,,429,,,,26,,,',
-',26,26,,,,26,,16,,,,878,,,,26,,,,15,,15,,,884,,26,304,,,,,889,890,,304',
-',,,,,,,,,,,,,,39,,,,,,,910,911,,,913,,26,,618,,,16,,,,16,39,,,26,16',
-',,,,,,26,26,,,,15,,,15,,,,,,,,942,,16,,,,,26,,26,26,,,26,15,,,,,26,',
-'744,,,,,,,,,,,,,39,,,,39,,,,301,39,,,,658,,333,,661,26,,,,,,,301,,984',
-',,,,,,39,,,15,,,,,15,15,996,,,,,,997,,,658,,304,333,,,,,,,,,,304,,,',
-',,,,,,,,,26,,706,,,,,,,,,,,,,,,26,,,,,433,26,,26,,,,,,,,,,,,,,,15,,26',
-',38,15,,,,38,,,,,,15,,,,,,16,,16,,,,753,,,,658,333,,,,,38,300,300,,',
-',,,,,,,,,,,,,,,358,,,,,,15,,,,797,,,798,,345,361,361,361,15,,,,,,,,15',
-'15,,39,,39,807,16,,,16,301,,,,,,,,301,,,,829,,15,15,,,15,,38,16,,,15',
-',,,,38,38,,,,,,,,,,,,,,,,,,,358,,,,,,,,15,,,,948,39,,429,39,,856,,,',
-',,,,,,,16,,,,,16,16,,,39,,,,,,,,,,,,,,,,,,,,,,,,,,,,38,,,15,,,,,,,,',
-',,,,,,,,15,,,38,,,15,,15,39,,,,,39,39,,,,,912,,,,,16,,301,,,16,,,,,',
-',333,301,,16,,,,,,,,,,,,,,,,,,,,,,,,38,,,,38,,,,300,38,,,,,,,,,,,,,',
-',16,300,,39,,,,,39,,38,,,16,,,,,39,,,16,16,,,,,,,,,,,,,,,,,,,,,,,,16',
-'16,,,16,,,,,,16,,,,362,,,,,,39,,,,,,,,,,,,,39,,,,,,,,39,39,16,,,,949',
-',,,,,,,,,,,,,,,,,,39,39,,,39,,,,,,39,,,,,,,,,,,,,,,,,,,,,,,,,362,,,16',
-',,,227,39,,,,945,,,,274,274,274,,16,,,,,,16,,16,320,321,322,,,,38,,38',
-',,,,,300,,,274,274,,,,300,,,,,,,,,,,,,,,,,,39,,,,,,,,,,,,,,,,,39,,,',
-',,39,,39,,,,,,,,,,,38,,,38,,,,,,,,,,,,,,,,,,,,,,38,,,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,38,,,,,38,38,274,408,274,,,427',
-'432,,,,,300,,,,,,,,,,227,300,,447,448,449,450,451,452,453,454,455,456',
-'457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,,,,,,,,274',
-'274,,,,,,,,274,,,,,,,274,,274,38,,274,274,,38,,,,,,,,,,38,,,,,,,,,,',
-',,,,,,,,,,,,,,,519,,,,,,,,,,,,,,,,361,,,,,,38,,,,,,,,,,,,,38,,,,,,,',
-'38,38,,,,,,,,,,,,,,,,,,,,,,,,38,38,,,38,,,,,,38,,,274,,,,,,,,,,,,,,',
-',,,,,,,361,,,,,,,,38,,,,944,,,,274,,427,643,408,,,,,,,,,,,,,,,,,,,,',
-',,,,,644,,,,,,,,,,,,,,274,,274,,274,,,,,38,,,,,,,,,,,274,,,,,,38,,,678',
-'679,,38,,38,,,,,,274,,,274,,,,,,,,,,,,,,,,,,,,,,,,,274,,,,,,,,,,,,,',
-',,,,,,274,274,,,,,,,,,,274,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,274,755',
-',,274,274,760,762,,,,765,767,,,643,769,,,,,,,,,,,,,,,,,,,,,,,,274,,',
-'274,,,,,,,,,,,,,,,,,,,,274,,,,,,,,,,,,,,,,,274,,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,274,,858,,,,,,,,,,,,,,760,762,767,765',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-'274,,,,,,,,,,,,,,,,,274,858,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,969,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,274' ]
- racc_goto_table = arr = ::Array.new(2920, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-clist = [
-'31,33,33,33,22,56,10,37,37,22,69,8,23,88,73,73,64,64,140,18,60,60,94',
-'4,22,139,31,2,98,47,117,57,57,22,22,22,27,22,22,22,75,36,27,91,91,49',
-'70,70,70,178,64,64,64,6,97,92,37,51,17,17,151,63,17,15,15,39,23,22,22',
-'20,134,22,22,22,22,118,70,54,61,61,7,163,123,123,47,7,45,4,29,29,178',
-'24,29,169,57,46,128,72,72,72,116,38,38,38,50,71,71,47,174,71,131,17',
-'17,17,17,22,11,109,97,133,22,22,22,22,22,22,5,72,72,93,93,119,110,152',
-'76,111,76,55,55,175,152,29,29,29,29,155,155,11,2,112,129,113,131,21',
-'114,115,102,101,21,100,99,156,156,156,156,120,96,156,40,95,90,87,166',
-'166,166,75,40,40,134,126,117,33,86,117,74,178,21,68,44,44,44,7,67,132',
-'1,135,168,129,73,129,7,7,136,119,137,138,66,62,141,143,22,22,22,22,144',
-'145,22,22,22,22,22,22,146,139,70,118,147,133,116,150,70,153,5,22,57',
-'33,33,37,37,29,29,29,29,175,33,23,51,154,131,47,42,94,157,158,51,119',
-'20,20,159,160,161,20,20,151,21,169,162,22,22,30,28,76,76,21,21,167,22',
-'19,8,163,64,70,16,14,171,172,12,104,31,70,103,47,119,105,22,47,73,64',
-'22,169,73,106,22,22,37,54,174,31,4,23,117,47,117,107,37,128,108,47,',
-'22,,,123,123,24,,49,,22,22,,,72,63,,17,17,,6,97,72,92,,,22,22,40,45',
-'11,,29,24,45,,,,46,98,,21,,46,4,123,22,29,29,50,,129,7,129,,37,,,,169',
-'23,,22,37,21,117,117,29,,156,23,156,31,36,,97,168,,,129,,,,29,24,73',
-'93,,47,60,51,73,97,24,,,33,,,8,57,75,178,,8,44,91,139,139,,73,,39,44',
-',,,39,117,,117,,18,,,21,,,22,21,,,15,,21,,166,166,,166,166,,166,,73',
-'71,57,61,,,,10,123,,,117,,129,,21,33,,9,163,163,,,,64,,,,38,,47,,64',
-'73,38,,,41,22,,22,,41,73,168,76,22,,22,27,,,,49,22,47,,41,,75,,49,22',
-'2,,,41,41,41,57,41,,,,8,,,,,57,,,,29,,33,,38,,,,168,72,168,,33,,,,,41',
-'41,73,,41,,,,22,,73,22,,,,,7,22,,,,,,166,166,166,166,22,91,70,94,,72',
-'22,168,168,,,57,,88,,,,57,,,,41,,,91,,41,41,41,41,41,41,97,97,31,,31',
-',31,60,22,22,,,69,22,22,,,22,57,97,97,47,166,,140,,,64,21,31,21,22,9',
-',8,,22,22,64,73,,,73,47,31,,,,31,22,15,56,,20,20,9,49,,20,20,22,,20',
-',,61,24,49,,,72,,170,,,,,,70,,31,122,,,41,41,41,41,,31,41,41,41,41,41',
-'41,,,21,17,,21,,,168,17,168,41,22,,,,,22,22,,,,22,,9,,,21,122,9,,,22',
-'29,,25,168,,69,29,25,,69,22,57,41,41,,31,,,,64,,41,,,,,,,125,125,125',
-',,37,,25,25,25,23,41,,22,,41,,,,22,41,,,21,,,,20,21,21,,124,22,,,,,',
-',,22,22,25,25,25,41,41,,,,,,,168,17,,,,127,,,41,41,22,,22,22,,,22,,',
-',,124,22,,124,64,,,41,,,29,25,,,,,64,,,,25,25,,41,,,22,,,,,21,,127,22',
-'127,21,,22,,,,,,97,,21,97,,,,,97,,,,,170,,,170,,170,31,170,,122,,,122',
-',122,,122,125,125,125,125,,125,,,,,,,,,,41,,,,,21,22,,,65,,,,,,,33,25',
-'21,,,57,,22,,,21,21,,22,,22,,73,,,,,,,25,,,,,31,,,22,,,21,21,,41,21',
-'41,125,125,125,125,21,,,41,,26,,,57,,26,9,,,9,,170,41,170,125,170,,170',
-'124,,122,124,122,124,122,124,122,,21,,,,,26,,25,,,,25,,,,25,25,,,,,',
-'127,,127,,,170,,,41,,25,41,,,122,,53,41,26,25,,53,,,,,127,41,127,,127',
-',,41,,,,,9,21,65,,,9,9,,65,,,53,53,53,,,,,21,,,,,26,21,,21,,,41,41,',
-'26,26,41,41,,,41,124,,124,,124,,124,53,53,53,53,,,41,,,,,41,41,,,,,',
-',,127,,127,,127,,,,65,,65,,,65,65,,,124,127,,,,,53,,,,,,,,9,53,53,,',
-',,,,,,,,127,,,,,,,,26,,,,,,,26,,,,41,,,,,41,41,,,,41,,26,,,,9,,,,41',
-',,,25,,25,,,9,,41,25,,,,,9,9,,25,,,,,,,,,,,,,,,53,,,,,,,9,9,,,9,,41',
-',65,,,26,,,,26,53,,,41,26,,,,,,,41,41,,,,25,,,25,,,,,,,,9,,26,,,,,41',
-',41,41,,,41,25,,,,,41,,25,,,,,,,,,,,,,53,,,,53,,,,53,53,,,,65,,65,,65',
-'41,,,,,,,53,,9,,,,,,,53,,,25,,,,,25,25,9,,,,,,9,,,65,,25,65,,,,,,,,',
-',25,,,,,,,,,,,,,41,,65,,,,,,,,,,,,,,,41,,,,,65,41,,41,,,,,,,,,,,,,,',
-'25,,41,,52,25,,,,52,,,,,,25,,,,,,26,,26,,,,65,,,,65,65,,,,,52,52,52',
-',,,,,,,,,,,,,,,,,25,,,,,,25,,,,65,,,65,,52,52,52,52,25,,,,,,,,25,25',
-',53,,53,65,26,,,26,53,,,,,,,,53,,,,65,,25,25,,,25,,52,26,,,25,,,,,52',
-'52,,,,,,,,,,,,,,,,,,,25,,,,,,,,25,,,,25,53,,26,53,,65,,,,,,,,,,,26,',
-',,,26,26,,,53,,,,,,,,,,,,,,,,,,,,,,,,,,,,52,,,25,,,,,,,,,,,,,,,,,25',
-',,52,,,25,,25,53,,,,,53,53,,,,,65,,,,,26,,53,,,26,,,,,,,65,53,,26,,',
-',,,,,,,,,,,,,,,,,,,,,52,,,,52,,,,52,52,,,,,,,,,,,,,,,26,52,,53,,,,,53',
-',52,,,26,,,,,53,,,26,26,,,,,,,,,,,,,,,,,,,,,,,,26,26,,,26,,,,,,26,,',
-',53,,,,,,53,,,,,,,,,,,,,53,,,,,,,,53,53,26,,,,26,,,,,,,,,,,,,,,,,,,53',
-'53,,,53,,,,,,53,,,,,,,,,,,,,,,,,,,,,,,,,53,,,26,,,,32,53,,,,53,,,,32',
-'32,32,,26,,,,,,26,,26,32,32,32,,,,52,,52,,,,,,52,,,32,32,,,,52,,,,,',
-',,,,,,,,,,,,53,,,,,,,,,,,,,,,,,53,,,,,,53,,53,,,,,,,,,,,52,,,52,,,,',
-',,,,,,,,,,,,,,,,,52,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,52,,,,,52,52,32,32,32,,,32,32,,,,,52,,,,,,,,,,32,52,,32,32,32',
-'32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,,',
-',,,,,32,32,,,,,,,,32,,,,,,,32,,32,52,,32,32,,52,,,,,,,,,,52,,,,,,,,',
-',,,,,,,,,,,,,,,,,32,,,,,,,,,,,,,,,,52,,,,,,52,,,,,,,,,,,,,52,,,,,,,',
-'52,52,,,,,,,,,,,,,,,,,,,,,,,,52,52,,,52,,,,,,52,,,32,,,,,,,,,,,,,,,',
-',,,,,,52,,,,,,,,52,,,,52,,,,32,,32,32,32,,,,,,,,,,,,,,,,,,,,,,,,,,32',
-',,,,,,,,,,,,,32,,32,,32,,,,,52,,,,,,,,,,,32,,,,,,52,,,32,32,,52,,52',
-',,,,,32,,,32,,,,,,,,,,,,,,,,,,,,,,,,,32,,,,,,,,,,,,,,,,,,,,32,32,,,',
-',,,,,,32,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,32,32,,,32,32,32,32,,,,32',
-'32,,,32,32,,,,,,,,,,,,,,,,,,,,,,,,32,,,32,,,,,,,,,,,,,,,,,,,,32,,,,',
-',,,,,,,,,,,,32,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-',32,,32,,,,,,,,,,,,,,32,32,32,32,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,32,,,,,,,,,,,,,,,,,32,32,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,32,,,,,,,,,,,,,',
-',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,32' ]
- racc_goto_check = arr = ::Array.new(2920, nil)
- idx = 0
- clist.each do |str|
- str.split(',', -1).each do |i|
- arr[idx] = i.to_i unless i.empty?
- idx += 1
- end
- end
-
-racc_goto_pointer = [
- nil, 194, 27, nil, 20, 121, 50, 80, -313, 447,
- -515, -565, -518, nil, -213, 55, 273, -5, -194, 209,
- 49, 153, 4, -197, -318, 752, 1007, -171, 63, 25,
- 147, -19, 1934, -28, nil, nil, 17, -203, 75, -197,
- -305, 499, -227, nil, 159, 53, 62, -188, nil, 11,
- 69, -258, 1486, 1073, -278, 68, -66, 23, nil, nil,
- 12, 70, -192, 20, -18, 890, -50, -669, 128, -49,
- 17, -223, 68, -12, -290, -237, -352, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 111, 111, -48, nil,
- 108, -295, -655, -441, -321, 101, -193, 51, -564, 89,
- 102, 99, -367, 232, 222, -420, 235, -403, -263, -797,
- -454, -598, -214, -222, -439, -699, -731, -521, -476, -702,
- -481, nil, 56, -454, 163, -1, -467, 190, -550, -496,
- nil, -536, -680, -754, -803, -141, -485, 142, -328, -311,
- -4, -49, nil, -58, -54, -698, -460, -582, nil, nil,
- 152, -19, 51, 148, 163, -236, -218, 167, 167, 171,
- -339, -339, -322, -255, nil, nil, -367, -418, -140, -600,
- 47, -405, -577, nil, -587, -728, nil, nil, -439 ]
-
-racc_goto_default = [
- nil, nil, nil, 3, nil, 4, 344, 291, nil, 521,
- nil, 836, nil, 288, 289, nil, nil, nil, 11, 12,
- 18, 226, 319, nil, nil, 224, 225, nil, nil, 17,
- nil, 439, 21, 22, 23, 24, nil, 675, nil, nil,
- nil, 308, nil, 25, 410, 32, nil, nil, 34, 37,
- 36, nil, 221, 222, 356, nil, 129, 418, 128, 131,
- 75, 76, nil, 90, 46, 280, nil, nil, nil, 805,
- 411, nil, 412, 423, 629, 485, 278, 264, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, nil, 265, 61,
- nil, nil, nil, nil, nil, nil, nil, 567, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 702, 549, nil, 703,
- 926, 776, 537, nil, 538, nil, nil, 539, nil, 541,
- 645, nil, nil, nil, 547, nil, nil, nil, nil, nil,
- nil, nil, 422, nil, nil, nil, nil, nil, 74, 77,
- 78, nil, nil, nil, nil, nil, 596, nil, nil, nil,
- nil, nil, nil, 820, 737, 536, nil, 540, 828, 552,
- 554, 555, 788, 558, 559, 789, 562, 565, 283 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 146, :_reduce_none,
- 2, 147, :_reduce_2,
- 0, 148, :_reduce_3,
- 1, 148, :_reduce_4,
- 3, 148, :_reduce_5,
- 2, 148, :_reduce_6,
- 1, 150, :_reduce_none,
- 4, 150, :_reduce_8,
- 4, 153, :_reduce_9,
- 2, 154, :_reduce_10,
- 0, 158, :_reduce_11,
- 1, 158, :_reduce_12,
- 3, 158, :_reduce_13,
- 2, 158, :_reduce_14,
- 1, 159, :_reduce_none,
- 4, 159, :_reduce_16,
- 0, 175, :_reduce_17,
- 4, 152, :_reduce_18,
- 3, 152, :_reduce_19,
- 3, 152, :_reduce_20,
- 3, 152, :_reduce_21,
- 2, 152, :_reduce_22,
- 3, 152, :_reduce_23,
- 3, 152, :_reduce_24,
- 3, 152, :_reduce_25,
- 3, 152, :_reduce_26,
- 3, 152, :_reduce_27,
- 4, 152, :_reduce_28,
- 1, 152, :_reduce_none,
- 3, 152, :_reduce_30,
- 3, 152, :_reduce_31,
- 6, 152, :_reduce_32,
- 5, 152, :_reduce_33,
- 5, 152, :_reduce_34,
- 5, 152, :_reduce_35,
- 5, 152, :_reduce_36,
- 3, 152, :_reduce_37,
- 3, 152, :_reduce_38,
- 3, 152, :_reduce_39,
- 1, 152, :_reduce_none,
- 3, 163, :_reduce_41,
- 3, 163, :_reduce_42,
- 1, 174, :_reduce_none,
- 3, 174, :_reduce_44,
- 3, 174, :_reduce_45,
- 3, 174, :_reduce_46,
- 2, 174, :_reduce_47,
- 1, 174, :_reduce_none,
- 1, 162, :_reduce_none,
- 1, 165, :_reduce_none,
- 1, 165, :_reduce_none,
- 1, 179, :_reduce_none,
- 4, 179, :_reduce_53,
- 0, 187, :_reduce_54,
- 5, 184, :_reduce_55,
- 1, 186, :_reduce_none,
- 2, 178, :_reduce_57,
- 3, 178, :_reduce_58,
- 4, 178, :_reduce_59,
- 5, 178, :_reduce_60,
- 4, 178, :_reduce_61,
- 5, 178, :_reduce_62,
- 2, 178, :_reduce_63,
- 2, 178, :_reduce_64,
- 2, 178, :_reduce_65,
- 2, 178, :_reduce_66,
- 2, 178, :_reduce_67,
- 1, 164, :_reduce_68,
- 3, 164, :_reduce_69,
- 1, 191, :_reduce_70,
- 3, 191, :_reduce_71,
- 1, 190, :_reduce_none,
- 2, 190, :_reduce_73,
- 3, 190, :_reduce_74,
- 5, 190, :_reduce_75,
- 2, 190, :_reduce_76,
- 4, 190, :_reduce_77,
- 2, 190, :_reduce_78,
- 4, 190, :_reduce_79,
- 1, 190, :_reduce_80,
- 3, 190, :_reduce_81,
- 1, 194, :_reduce_none,
- 3, 194, :_reduce_83,
- 2, 193, :_reduce_84,
- 3, 193, :_reduce_85,
- 1, 196, :_reduce_86,
- 3, 196, :_reduce_87,
- 1, 195, :_reduce_88,
- 1, 195, :_reduce_89,
- 4, 195, :_reduce_90,
- 3, 195, :_reduce_91,
- 3, 195, :_reduce_92,
- 3, 195, :_reduce_93,
- 3, 195, :_reduce_94,
- 2, 195, :_reduce_95,
- 1, 195, :_reduce_96,
- 1, 171, :_reduce_97,
- 1, 171, :_reduce_98,
- 4, 171, :_reduce_99,
- 3, 171, :_reduce_100,
- 3, 171, :_reduce_101,
- 3, 171, :_reduce_102,
- 3, 171, :_reduce_103,
- 2, 171, :_reduce_104,
- 1, 171, :_reduce_105,
- 1, 199, :_reduce_106,
- 1, 199, :_reduce_none,
- 2, 200, :_reduce_108,
- 1, 200, :_reduce_109,
- 3, 200, :_reduce_110,
- 1, 201, :_reduce_none,
- 1, 201, :_reduce_none,
- 1, 201, :_reduce_none,
- 1, 201, :_reduce_none,
- 1, 201, :_reduce_none,
- 1, 204, :_reduce_116,
- 1, 204, :_reduce_none,
- 1, 160, :_reduce_none,
- 1, 160, :_reduce_none,
- 1, 161, :_reduce_120,
- 0, 207, :_reduce_121,
- 4, 161, :_reduce_122,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 202, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 1, 203, :_reduce_none,
- 3, 177, :_reduce_194,
- 5, 177, :_reduce_195,
- 3, 177, :_reduce_196,
- 5, 177, :_reduce_197,
- 6, 177, :_reduce_198,
- 5, 177, :_reduce_199,
- 5, 177, :_reduce_200,
- 5, 177, :_reduce_201,
- 5, 177, :_reduce_202,
- 4, 177, :_reduce_203,
- 3, 177, :_reduce_204,
- 3, 177, :_reduce_205,
- 3, 177, :_reduce_206,
- 3, 177, :_reduce_207,
- 3, 177, :_reduce_208,
- 3, 177, :_reduce_209,
- 3, 177, :_reduce_210,
- 3, 177, :_reduce_211,
- 3, 177, :_reduce_212,
- 4, 177, :_reduce_213,
- 2, 177, :_reduce_214,
- 2, 177, :_reduce_215,
- 3, 177, :_reduce_216,
- 3, 177, :_reduce_217,
- 3, 177, :_reduce_218,
- 3, 177, :_reduce_219,
- 3, 177, :_reduce_220,
- 3, 177, :_reduce_221,
- 3, 177, :_reduce_222,
- 3, 177, :_reduce_223,
- 3, 177, :_reduce_224,
- 3, 177, :_reduce_225,
- 3, 177, :_reduce_226,
- 3, 177, :_reduce_227,
- 3, 177, :_reduce_228,
- 2, 177, :_reduce_229,
- 2, 177, :_reduce_230,
- 3, 177, :_reduce_231,
- 3, 177, :_reduce_232,
- 3, 177, :_reduce_233,
- 3, 177, :_reduce_234,
- 3, 177, :_reduce_235,
- 0, 211, :_reduce_236,
- 0, 212, :_reduce_237,
- 8, 177, :_reduce_238,
- 1, 177, :_reduce_none,
- 1, 210, :_reduce_none,
- 1, 213, :_reduce_none,
- 2, 213, :_reduce_none,
- 4, 213, :_reduce_243,
- 2, 213, :_reduce_244,
- 3, 218, :_reduce_245,
- 0, 219, :_reduce_246,
- 1, 219, :_reduce_none,
- 0, 168, :_reduce_248,
- 1, 168, :_reduce_none,
- 2, 168, :_reduce_none,
- 4, 168, :_reduce_251,
- 2, 168, :_reduce_252,
- 1, 189, :_reduce_253,
- 2, 189, :_reduce_254,
- 2, 189, :_reduce_255,
- 4, 189, :_reduce_256,
- 1, 189, :_reduce_257,
- 0, 222, :_reduce_258,
- 2, 183, :_reduce_259,
- 2, 221, :_reduce_260,
- 2, 220, :_reduce_261,
- 0, 220, :_reduce_262,
- 1, 215, :_reduce_263,
- 2, 215, :_reduce_264,
- 3, 215, :_reduce_265,
- 4, 215, :_reduce_266,
- 1, 173, :_reduce_267,
- 1, 173, :_reduce_none,
- 3, 172, :_reduce_269,
- 4, 172, :_reduce_270,
- 2, 172, :_reduce_271,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_none,
- 1, 209, :_reduce_282,
- 0, 245, :_reduce_283,
- 4, 209, :_reduce_284,
- 0, 246, :_reduce_285,
- 0, 247, :_reduce_286,
- 6, 209, :_reduce_287,
- 0, 248, :_reduce_288,
- 4, 209, :_reduce_289,
- 3, 209, :_reduce_290,
- 3, 209, :_reduce_291,
- 2, 209, :_reduce_292,
- 3, 209, :_reduce_293,
- 3, 209, :_reduce_294,
- 1, 209, :_reduce_295,
- 4, 209, :_reduce_296,
- 3, 209, :_reduce_297,
- 1, 209, :_reduce_298,
- 5, 209, :_reduce_299,
- 4, 209, :_reduce_300,
- 3, 209, :_reduce_301,
- 2, 209, :_reduce_302,
- 1, 209, :_reduce_none,
- 2, 209, :_reduce_304,
- 2, 209, :_reduce_305,
- 6, 209, :_reduce_306,
- 6, 209, :_reduce_307,
- 0, 249, :_reduce_308,
- 0, 250, :_reduce_309,
- 7, 209, :_reduce_310,
- 0, 251, :_reduce_311,
- 0, 252, :_reduce_312,
- 7, 209, :_reduce_313,
- 5, 209, :_reduce_314,
- 4, 209, :_reduce_315,
- 0, 253, :_reduce_316,
- 0, 254, :_reduce_317,
- 9, 209, :_reduce_318,
- 0, 255, :_reduce_319,
- 6, 209, :_reduce_320,
- 0, 256, :_reduce_321,
- 7, 209, :_reduce_322,
- 0, 257, :_reduce_323,
- 5, 209, :_reduce_324,
- 0, 258, :_reduce_325,
- 6, 209, :_reduce_326,
- 0, 259, :_reduce_327,
- 0, 260, :_reduce_328,
- 9, 209, :_reduce_329,
- 1, 209, :_reduce_330,
- 1, 209, :_reduce_331,
- 1, 209, :_reduce_332,
- 1, 209, :_reduce_333,
- 1, 167, :_reduce_none,
- 1, 236, :_reduce_none,
- 1, 236, :_reduce_none,
- 2, 236, :_reduce_337,
- 1, 238, :_reduce_none,
- 1, 238, :_reduce_none,
- 1, 237, :_reduce_none,
- 5, 237, :_reduce_341,
- 1, 156, :_reduce_none,
- 2, 156, :_reduce_343,
- 1, 240, :_reduce_none,
- 1, 240, :_reduce_none,
- 1, 261, :_reduce_346,
- 3, 261, :_reduce_347,
- 1, 264, :_reduce_348,
- 3, 264, :_reduce_349,
- 1, 263, :_reduce_none,
- 4, 263, :_reduce_351,
- 6, 263, :_reduce_352,
- 3, 263, :_reduce_353,
- 5, 263, :_reduce_354,
- 2, 263, :_reduce_355,
- 4, 263, :_reduce_356,
- 1, 263, :_reduce_357,
- 3, 263, :_reduce_358,
- 4, 265, :_reduce_359,
- 2, 265, :_reduce_360,
- 2, 265, :_reduce_361,
- 1, 265, :_reduce_362,
- 2, 270, :_reduce_363,
- 0, 270, :_reduce_364,
- 6, 271, :_reduce_365,
- 8, 271, :_reduce_366,
- 4, 271, :_reduce_367,
- 6, 271, :_reduce_368,
- 4, 271, :_reduce_369,
- 2, 271, :_reduce_none,
- 6, 271, :_reduce_371,
- 2, 271, :_reduce_372,
- 4, 271, :_reduce_373,
- 6, 271, :_reduce_374,
- 2, 271, :_reduce_375,
- 4, 271, :_reduce_376,
- 2, 271, :_reduce_377,
- 4, 271, :_reduce_378,
- 1, 271, :_reduce_none,
- 0, 185, :_reduce_380,
- 1, 185, :_reduce_381,
- 3, 275, :_reduce_382,
- 1, 275, :_reduce_383,
- 4, 275, :_reduce_384,
- 1, 276, :_reduce_385,
- 4, 276, :_reduce_386,
- 1, 277, :_reduce_387,
- 3, 277, :_reduce_388,
- 1, 278, :_reduce_389,
- 1, 278, :_reduce_none,
- 0, 282, :_reduce_391,
- 0, 283, :_reduce_392,
- 4, 235, :_reduce_393,
- 4, 280, :_reduce_394,
- 1, 280, :_reduce_395,
- 3, 281, :_reduce_396,
- 3, 281, :_reduce_397,
- 0, 286, :_reduce_398,
- 5, 285, :_reduce_399,
- 2, 180, :_reduce_400,
- 4, 180, :_reduce_401,
- 5, 180, :_reduce_402,
- 5, 180, :_reduce_403,
- 2, 234, :_reduce_404,
- 4, 234, :_reduce_405,
- 4, 234, :_reduce_406,
- 3, 234, :_reduce_407,
- 3, 234, :_reduce_408,
- 3, 234, :_reduce_409,
- 2, 234, :_reduce_410,
- 1, 234, :_reduce_411,
- 4, 234, :_reduce_412,
- 0, 288, :_reduce_413,
- 5, 233, :_reduce_414,
- 0, 289, :_reduce_415,
- 5, 233, :_reduce_416,
- 5, 239, :_reduce_417,
- 1, 290, :_reduce_418,
- 1, 290, :_reduce_none,
- 6, 155, :_reduce_420,
- 0, 155, :_reduce_421,
- 1, 291, :_reduce_422,
- 1, 291, :_reduce_none,
- 1, 291, :_reduce_none,
- 2, 292, :_reduce_425,
- 1, 292, :_reduce_none,
- 2, 157, :_reduce_427,
- 1, 157, :_reduce_none,
- 1, 223, :_reduce_none,
- 1, 223, :_reduce_none,
- 1, 223, :_reduce_none,
- 1, 224, :_reduce_432,
- 1, 294, :_reduce_433,
- 2, 294, :_reduce_434,
- 3, 295, :_reduce_435,
- 1, 295, :_reduce_436,
- 1, 295, :_reduce_437,
- 3, 225, :_reduce_438,
- 4, 226, :_reduce_439,
- 3, 227, :_reduce_440,
- 0, 299, :_reduce_441,
- 3, 299, :_reduce_442,
- 1, 300, :_reduce_443,
- 2, 300, :_reduce_444,
- 3, 229, :_reduce_445,
- 0, 302, :_reduce_446,
- 3, 302, :_reduce_447,
- 3, 228, :_reduce_448,
- 3, 230, :_reduce_449,
- 0, 303, :_reduce_450,
- 3, 303, :_reduce_451,
- 0, 304, :_reduce_452,
- 3, 304, :_reduce_453,
- 0, 296, :_reduce_454,
- 2, 296, :_reduce_455,
- 0, 297, :_reduce_456,
- 2, 297, :_reduce_457,
- 0, 298, :_reduce_458,
- 2, 298, :_reduce_459,
- 1, 301, :_reduce_460,
- 2, 301, :_reduce_461,
- 0, 306, :_reduce_462,
- 4, 301, :_reduce_463,
- 1, 305, :_reduce_464,
- 1, 305, :_reduce_465,
- 1, 305, :_reduce_466,
- 1, 305, :_reduce_none,
- 1, 205, :_reduce_468,
- 3, 206, :_reduce_469,
- 1, 293, :_reduce_470,
- 2, 293, :_reduce_471,
- 1, 208, :_reduce_472,
- 1, 208, :_reduce_473,
- 1, 208, :_reduce_474,
- 1, 208, :_reduce_475,
- 1, 197, :_reduce_476,
- 1, 197, :_reduce_477,
- 1, 197, :_reduce_478,
- 1, 197, :_reduce_479,
- 1, 197, :_reduce_480,
- 1, 198, :_reduce_481,
- 1, 198, :_reduce_482,
- 1, 198, :_reduce_483,
- 1, 198, :_reduce_484,
- 1, 198, :_reduce_485,
- 1, 198, :_reduce_486,
- 1, 198, :_reduce_487,
- 1, 231, :_reduce_488,
- 1, 231, :_reduce_489,
- 1, 166, :_reduce_490,
- 1, 166, :_reduce_491,
- 1, 170, :_reduce_492,
- 1, 170, :_reduce_493,
- 1, 241, :_reduce_494,
- 0, 307, :_reduce_495,
- 4, 241, :_reduce_496,
- 2, 241, :_reduce_497,
- 3, 243, :_reduce_498,
- 0, 309, :_reduce_499,
- 3, 243, :_reduce_500,
- 4, 308, :_reduce_501,
- 2, 308, :_reduce_502,
- 2, 308, :_reduce_503,
- 1, 308, :_reduce_504,
- 2, 311, :_reduce_505,
- 0, 311, :_reduce_506,
- 6, 284, :_reduce_507,
- 8, 284, :_reduce_508,
- 4, 284, :_reduce_509,
- 6, 284, :_reduce_510,
- 4, 284, :_reduce_511,
- 6, 284, :_reduce_512,
- 2, 284, :_reduce_513,
- 4, 284, :_reduce_514,
- 6, 284, :_reduce_515,
- 2, 284, :_reduce_516,
- 4, 284, :_reduce_517,
- 2, 284, :_reduce_518,
- 4, 284, :_reduce_519,
- 1, 284, :_reduce_520,
- 0, 284, :_reduce_521,
- 1, 279, :_reduce_522,
- 1, 279, :_reduce_523,
- 1, 279, :_reduce_524,
- 1, 279, :_reduce_525,
- 1, 262, :_reduce_none,
- 1, 262, :_reduce_527,
- 1, 313, :_reduce_528,
- 1, 314, :_reduce_529,
- 3, 314, :_reduce_530,
- 1, 272, :_reduce_531,
- 3, 272, :_reduce_532,
- 1, 315, :_reduce_533,
- 2, 316, :_reduce_534,
- 1, 316, :_reduce_535,
- 2, 317, :_reduce_536,
- 1, 317, :_reduce_537,
- 1, 266, :_reduce_538,
- 3, 266, :_reduce_539,
- 1, 310, :_reduce_540,
- 3, 310, :_reduce_541,
- 1, 318, :_reduce_none,
- 1, 318, :_reduce_none,
- 2, 267, :_reduce_544,
- 1, 267, :_reduce_545,
- 3, 319, :_reduce_546,
- 3, 320, :_reduce_547,
- 1, 273, :_reduce_548,
- 3, 273, :_reduce_549,
- 1, 312, :_reduce_550,
- 3, 312, :_reduce_551,
- 1, 321, :_reduce_none,
- 1, 321, :_reduce_none,
- 2, 274, :_reduce_554,
- 1, 274, :_reduce_555,
- 1, 322, :_reduce_none,
- 1, 322, :_reduce_none,
- 2, 269, :_reduce_558,
- 2, 268, :_reduce_559,
- 0, 268, :_reduce_560,
- 1, 244, :_reduce_none,
- 3, 244, :_reduce_562,
- 0, 232, :_reduce_563,
- 2, 232, :_reduce_none,
- 1, 217, :_reduce_565,
- 3, 217, :_reduce_566,
- 3, 323, :_reduce_567,
- 2, 323, :_reduce_568,
- 4, 323, :_reduce_569,
- 2, 323, :_reduce_570,
- 1, 188, :_reduce_none,
- 1, 188, :_reduce_none,
- 1, 188, :_reduce_none,
- 1, 182, :_reduce_none,
- 1, 182, :_reduce_none,
- 1, 182, :_reduce_none,
- 1, 182, :_reduce_none,
- 1, 287, :_reduce_none,
- 1, 287, :_reduce_none,
- 1, 287, :_reduce_none,
- 1, 181, :_reduce_none,
- 1, 181, :_reduce_none,
- 0, 149, :_reduce_none,
- 1, 149, :_reduce_none,
- 0, 176, :_reduce_none,
- 1, 176, :_reduce_none,
- 2, 192, :_reduce_587,
- 2, 169, :_reduce_588,
- 0, 216, :_reduce_none,
- 1, 216, :_reduce_none,
- 1, 216, :_reduce_none,
- 1, 242, :_reduce_592,
- 1, 242, :_reduce_none,
- 1, 151, :_reduce_none,
- 2, 151, :_reduce_none,
- 0, 214, :_reduce_596 ]
-
-racc_reduce_n = 597
-
-racc_shift_n = 1024
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :kCLASS => 2,
- :kMODULE => 3,
- :kDEF => 4,
- :kUNDEF => 5,
- :kBEGIN => 6,
- :kRESCUE => 7,
- :kENSURE => 8,
- :kEND => 9,
- :kIF => 10,
- :kUNLESS => 11,
- :kTHEN => 12,
- :kELSIF => 13,
- :kELSE => 14,
- :kCASE => 15,
- :kWHEN => 16,
- :kWHILE => 17,
- :kUNTIL => 18,
- :kFOR => 19,
- :kBREAK => 20,
- :kNEXT => 21,
- :kREDO => 22,
- :kRETRY => 23,
- :kIN => 24,
- :kDO => 25,
- :kDO_COND => 26,
- :kDO_BLOCK => 27,
- :kDO_LAMBDA => 28,
- :kRETURN => 29,
- :kYIELD => 30,
- :kSUPER => 31,
- :kSELF => 32,
- :kNIL => 33,
- :kTRUE => 34,
- :kFALSE => 35,
- :kAND => 36,
- :kOR => 37,
- :kNOT => 38,
- :kIF_MOD => 39,
- :kUNLESS_MOD => 40,
- :kWHILE_MOD => 41,
- :kUNTIL_MOD => 42,
- :kRESCUE_MOD => 43,
- :kALIAS => 44,
- :kDEFINED => 45,
- :klBEGIN => 46,
- :klEND => 47,
- :k__LINE__ => 48,
- :k__FILE__ => 49,
- :k__ENCODING__ => 50,
- :tIDENTIFIER => 51,
- :tFID => 52,
- :tGVAR => 53,
- :tIVAR => 54,
- :tCONSTANT => 55,
- :tLABEL => 56,
- :tCVAR => 57,
- :tNTH_REF => 58,
- :tBACK_REF => 59,
- :tSTRING_CONTENT => 60,
- :tINTEGER => 61,
- :tFLOAT => 62,
- :tREGEXP_END => 63,
- :tUPLUS => 64,
- :tUMINUS => 65,
- :tUMINUS_NUM => 66,
- :tPOW => 67,
- :tCMP => 68,
- :tEQ => 69,
- :tEQQ => 70,
- :tNEQ => 71,
- :tGEQ => 72,
- :tLEQ => 73,
- :tANDOP => 74,
- :tOROP => 75,
- :tMATCH => 76,
- :tNMATCH => 77,
- :tDOT => 78,
- :tDOT2 => 79,
- :tDOT3 => 80,
- :tAREF => 81,
- :tASET => 82,
- :tLSHFT => 83,
- :tRSHFT => 84,
- :tCOLON2 => 85,
- :tCOLON3 => 86,
- :tOP_ASGN => 87,
- :tASSOC => 88,
- :tLPAREN => 89,
- :tLPAREN2 => 90,
- :tRPAREN => 91,
- :tLPAREN_ARG => 92,
- :tLBRACK => 93,
- :tLBRACK2 => 94,
- :tRBRACK => 95,
- :tLBRACE => 96,
- :tLBRACE_ARG => 97,
- :tSTAR => 98,
- :tSTAR2 => 99,
- :tAMPER => 100,
- :tAMPER2 => 101,
- :tTILDE => 102,
- :tPERCENT => 103,
- :tDIVIDE => 104,
- :tDSTAR => 105,
- :tPLUS => 106,
- :tMINUS => 107,
- :tLT => 108,
- :tGT => 109,
- :tPIPE => 110,
- :tBANG => 111,
- :tCARET => 112,
- :tLCURLY => 113,
- :tRCURLY => 114,
- :tBACK_REF2 => 115,
- :tSYMBEG => 116,
- :tSTRING_BEG => 117,
- :tXSTRING_BEG => 118,
- :tREGEXP_BEG => 119,
- :tREGEXP_OPT => 120,
- :tWORDS_BEG => 121,
- :tQWORDS_BEG => 122,
- :tSYMBOLS_BEG => 123,
- :tQSYMBOLS_BEG => 124,
- :tSTRING_DBEG => 125,
- :tSTRING_DVAR => 126,
- :tSTRING_END => 127,
- :tSTRING_DEND => 128,
- :tSTRING => 129,
- :tSYMBOL => 130,
- :tNL => 131,
- :tEH => 132,
- :tCOLON => 133,
- :tCOMMA => 134,
- :tSPACE => 135,
- :tSEMI => 136,
- :tLAMBDA => 137,
- :tLAMBEG => 138,
- :tCHARACTER => 139,
- :tRATIONAL => 140,
- :tIMAGINARY => 141,
- :tLABEL_END => 142,
- :tEQL => 143,
- :tLOWEST => 144 }
-
-racc_nt_base = 145
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "kCLASS",
- "kMODULE",
- "kDEF",
- "kUNDEF",
- "kBEGIN",
- "kRESCUE",
- "kENSURE",
- "kEND",
- "kIF",
- "kUNLESS",
- "kTHEN",
- "kELSIF",
- "kELSE",
- "kCASE",
- "kWHEN",
- "kWHILE",
- "kUNTIL",
- "kFOR",
- "kBREAK",
- "kNEXT",
- "kREDO",
- "kRETRY",
- "kIN",
- "kDO",
- "kDO_COND",
- "kDO_BLOCK",
- "kDO_LAMBDA",
- "kRETURN",
- "kYIELD",
- "kSUPER",
- "kSELF",
- "kNIL",
- "kTRUE",
- "kFALSE",
- "kAND",
- "kOR",
- "kNOT",
- "kIF_MOD",
- "kUNLESS_MOD",
- "kWHILE_MOD",
- "kUNTIL_MOD",
- "kRESCUE_MOD",
- "kALIAS",
- "kDEFINED",
- "klBEGIN",
- "klEND",
- "k__LINE__",
- "k__FILE__",
- "k__ENCODING__",
- "tIDENTIFIER",
- "tFID",
- "tGVAR",
- "tIVAR",
- "tCONSTANT",
- "tLABEL",
- "tCVAR",
- "tNTH_REF",
- "tBACK_REF",
- "tSTRING_CONTENT",
- "tINTEGER",
- "tFLOAT",
- "tREGEXP_END",
- "tUPLUS",
- "tUMINUS",
- "tUMINUS_NUM",
- "tPOW",
- "tCMP",
- "tEQ",
- "tEQQ",
- "tNEQ",
- "tGEQ",
- "tLEQ",
- "tANDOP",
- "tOROP",
- "tMATCH",
- "tNMATCH",
- "tDOT",
- "tDOT2",
- "tDOT3",
- "tAREF",
- "tASET",
- "tLSHFT",
- "tRSHFT",
- "tCOLON2",
- "tCOLON3",
- "tOP_ASGN",
- "tASSOC",
- "tLPAREN",
- "tLPAREN2",
- "tRPAREN",
- "tLPAREN_ARG",
- "tLBRACK",
- "tLBRACK2",
- "tRBRACK",
- "tLBRACE",
- "tLBRACE_ARG",
- "tSTAR",
- "tSTAR2",
- "tAMPER",
- "tAMPER2",
- "tTILDE",
- "tPERCENT",
- "tDIVIDE",
- "tDSTAR",
- "tPLUS",
- "tMINUS",
- "tLT",
- "tGT",
- "tPIPE",
- "tBANG",
- "tCARET",
- "tLCURLY",
- "tRCURLY",
- "tBACK_REF2",
- "tSYMBEG",
- "tSTRING_BEG",
- "tXSTRING_BEG",
- "tREGEXP_BEG",
- "tREGEXP_OPT",
- "tWORDS_BEG",
- "tQWORDS_BEG",
- "tSYMBOLS_BEG",
- "tQSYMBOLS_BEG",
- "tSTRING_DBEG",
- "tSTRING_DVAR",
- "tSTRING_END",
- "tSTRING_DEND",
- "tSTRING",
- "tSYMBOL",
- "tNL",
- "tEH",
- "tCOLON",
- "tCOMMA",
- "tSPACE",
- "tSEMI",
- "tLAMBDA",
- "tLAMBEG",
- "tCHARACTER",
- "tRATIONAL",
- "tIMAGINARY",
- "tLABEL_END",
- "tEQL",
- "tLOWEST",
- "$start",
- "program",
- "top_compstmt",
- "top_stmts",
- "opt_terms",
- "top_stmt",
- "terms",
- "stmt",
- "bodystmt",
- "compstmt",
- "opt_rescue",
- "opt_else",
- "opt_ensure",
- "stmts",
- "stmt_or_begin",
- "fitem",
- "undef_list",
- "expr_value",
- "command_asgn",
- "mlhs",
- "command_call",
- "var_lhs",
- "primary_value",
- "opt_call_args",
- "rbracket",
- "backref",
- "lhs",
- "mrhs",
- "mrhs_arg",
- "expr",
- "@1",
- "opt_nl",
- "arg",
- "command",
- "block_command",
- "block_call",
- "dot_or_colon",
- "operation2",
- "command_args",
- "cmd_brace_block",
- "opt_block_param",
- "fcall",
- "@2",
- "operation",
- "call_args",
- "mlhs_basic",
- "mlhs_inner",
- "rparen",
- "mlhs_head",
- "mlhs_item",
- "mlhs_node",
- "mlhs_post",
- "user_variable",
- "keyword_variable",
- "cname",
- "cpath",
- "fname",
- "op",
- "reswords",
- "fsym",
- "symbol",
- "dsym",
- "@3",
- "simple_numeric",
- "primary",
- "arg_value",
- "@4",
- "@5",
- "aref_args",
- "none",
- "args",
- "trailer",
- "assocs",
- "paren_args",
- "opt_paren_args",
- "opt_block_arg",
- "block_arg",
- "@6",
- "literal",
- "strings",
- "xstring",
- "regexp",
- "words",
- "qwords",
- "symbols",
- "qsymbols",
- "var_ref",
- "assoc_list",
- "brace_block",
- "method_call",
- "lambda",
- "then",
- "if_tail",
- "do",
- "case_body",
- "for_var",
- "superclass",
- "term",
- "f_arglist",
- "singleton",
- "@7",
- "@8",
- "@9",
- "@10",
- "@11",
- "@12",
- "@13",
- "@14",
- "@15",
- "@16",
- "@17",
- "@18",
- "@19",
- "@20",
- "@21",
- "@22",
- "f_marg",
- "f_norm_arg",
- "f_margs",
- "f_marg_list",
- "block_args_tail",
- "f_block_kwarg",
- "f_kwrest",
- "opt_f_block_arg",
- "f_block_arg",
- "opt_block_args_tail",
- "block_param",
- "f_arg",
- "f_block_optarg",
- "f_rest_arg",
- "block_param_def",
- "opt_bv_decl",
- "bv_decls",
- "bvar",
- "f_bad_arg",
- "f_larglist",
- "lambda_body",
- "@23",
- "@24",
- "f_args",
- "do_block",
- "@25",
- "operation3",
- "@26",
- "@27",
- "cases",
- "exc_list",
- "exc_var",
- "numeric",
- "string",
- "string1",
- "string_contents",
- "xstring_contents",
- "regexp_contents",
- "word_list",
- "word",
- "string_content",
- "symbol_list",
- "qword_list",
- "qsym_list",
- "string_dvar",
- "@28",
- "@29",
- "args_tail",
- "@30",
- "f_kwarg",
- "opt_args_tail",
- "f_optarg",
- "f_arg_asgn",
- "f_arg_item",
- "f_label",
- "f_kw",
- "f_block_kw",
- "kwrest_mark",
- "f_opt",
- "f_block_opt",
- "restarg_mark",
- "blkarg_mark",
- "assoc" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-# reduce 1 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 78)
- def _reduce_2(val, _values, result)
- result = @builder.compstmt(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 83)
- def _reduce_3(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 87)
- def _reduce_4(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 91)
- def _reduce_5(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 95)
- def _reduce_6(val, _values, result)
- result = [ val[1] ]
-
- result
- end
-.,.,
-
-# reduce 7 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 101)
- def _reduce_8(val, _values, result)
- result = @builder.preexe(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 106)
- def _reduce_9(val, _values, result)
- rescue_bodies = val[1]
- else_t, else_ = val[2]
- ensure_t, ensure_ = val[3]
-
- if rescue_bodies.empty? && !else_.nil?
- diagnostic :warning, :useless_else, nil, else_t
- end
-
- result = @builder.begin_body(val[0],
- rescue_bodies,
- else_t, else_,
- ensure_t, ensure_)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 122)
- def _reduce_10(val, _values, result)
- result = @builder.compstmt(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 127)
- def _reduce_11(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 131)
- def _reduce_12(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 135)
- def _reduce_13(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 139)
- def _reduce_14(val, _values, result)
- result = [ val[1] ]
-
- result
- end
-.,.,
-
-# reduce 15 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 145)
- def _reduce_16(val, _values, result)
- diagnostic :error, :begin_in_method, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 150)
- def _reduce_17(val, _values, result)
- @lexer.state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 154)
- def _reduce_18(val, _values, result)
- result = @builder.alias(val[0], val[1], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 158)
- def _reduce_19(val, _values, result)
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.gvar(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 164)
- def _reduce_20(val, _values, result)
- result = @builder.alias(val[0],
- @builder.gvar(val[1]),
- @builder.back_ref(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 170)
- def _reduce_21(val, _values, result)
- diagnostic :error, :nth_ref_alias, nil, val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 174)
- def _reduce_22(val, _values, result)
- result = @builder.undef_method(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 178)
- def _reduce_23(val, _values, result)
- result = @builder.condition_mod(val[0], nil,
- val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 183)
- def _reduce_24(val, _values, result)
- result = @builder.condition_mod(nil, val[0],
- val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 188)
- def _reduce_25(val, _values, result)
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 192)
- def _reduce_26(val, _values, result)
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 196)
- def _reduce_27(val, _values, result)
- rescue_body = @builder.rescue_body(val[1],
- nil, nil, nil,
- nil, val[2])
-
- result = @builder.begin_body(val[0], [ rescue_body ])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 204)
- def _reduce_28(val, _values, result)
- result = @builder.postexe(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-# reduce 29 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 209)
- def _reduce_30(val, _values, result)
- result = @builder.multi_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 213)
- def _reduce_31(val, _values, result)
- result = @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 217)
- def _reduce_32(val, _values, result)
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 224)
- def _reduce_33(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 231)
- def _reduce_34(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 238)
- def _reduce_35(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 245)
- def _reduce_36(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 252)
- def _reduce_37(val, _values, result)
- @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 256)
- def _reduce_38(val, _values, result)
- result = @builder.assign(val[0], val[1],
- @builder.array(nil, val[2], nil))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 261)
- def _reduce_39(val, _values, result)
- result = @builder.multi_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 40 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 267)
- def _reduce_41(val, _values, result)
- result = @builder.assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 271)
- def _reduce_42(val, _values, result)
- result = @builder.assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 43 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 277)
- def _reduce_44(val, _values, result)
- result = @builder.logical_op(:and, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 281)
- def _reduce_45(val, _values, result)
- result = @builder.logical_op(:or, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 285)
- def _reduce_46(val, _values, result)
- result = @builder.not_op(val[0], nil, val[2], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 289)
- def _reduce_47(val, _values, result)
- result = @builder.not_op(val[0], nil, val[1], nil)
-
- result
- end
-.,.,
-
-# reduce 48 omitted
-
-# reduce 49 omitted
-
-# reduce 50 omitted
-
-# reduce 51 omitted
-
-# reduce 52 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 301)
- def _reduce_53(val, _values, result)
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 307)
- def _reduce_54(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 311)
- def _reduce_55(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-# reduce 56 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 320)
- def _reduce_57(val, _values, result)
- result = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 325)
- def _reduce_58(val, _values, result)
- method_call = @builder.call_method(nil, nil, val[0],
- nil, val[1], nil)
-
- begin_t, args, body, end_t = val[2]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 334)
- def _reduce_59(val, _values, result)
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 339)
- def _reduce_60(val, _values, result)
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 348)
- def _reduce_61(val, _values, result)
- result = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 353)
- def _reduce_62(val, _values, result)
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 362)
- def _reduce_63(val, _values, result)
- result = @builder.keyword_cmd(:super, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 367)
- def _reduce_64(val, _values, result)
- result = @builder.keyword_cmd(:yield, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 372)
- def _reduce_65(val, _values, result)
- result = @builder.keyword_cmd(:return, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 377)
- def _reduce_66(val, _values, result)
- result = @builder.keyword_cmd(:break, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 382)
- def _reduce_67(val, _values, result)
- result = @builder.keyword_cmd(:next, val[0],
- nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 388)
- def _reduce_68(val, _values, result)
- result = @builder.multi_lhs(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 392)
- def _reduce_69(val, _values, result)
- result = @builder.begin(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 397)
- def _reduce_70(val, _values, result)
- result = @builder.multi_lhs(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 401)
- def _reduce_71(val, _values, result)
- result = @builder.multi_lhs(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 72 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 407)
- def _reduce_73(val, _values, result)
- result = val[0].
- push(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 412)
- def _reduce_74(val, _values, result)
- result = val[0].
- push(@builder.splat(val[1], val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 417)
- def _reduce_75(val, _values, result)
- result = val[0].
- push(@builder.splat(val[1], val[2])).
- concat(val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 423)
- def _reduce_76(val, _values, result)
- result = val[0].
- push(@builder.splat(val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 428)
- def _reduce_77(val, _values, result)
- result = val[0].
- push(@builder.splat(val[1])).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 434)
- def _reduce_78(val, _values, result)
- result = [ @builder.splat(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 438)
- def _reduce_79(val, _values, result)
- result = [ @builder.splat(val[0], val[1]),
- *val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 443)
- def _reduce_80(val, _values, result)
- result = [ @builder.splat(val[0]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 447)
- def _reduce_81(val, _values, result)
- result = [ @builder.splat(val[0]),
- *val[2] ]
-
- result
- end
-.,.,
-
-# reduce 82 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 454)
- def _reduce_83(val, _values, result)
- result = @builder.begin(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 459)
- def _reduce_84(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 463)
- def _reduce_85(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 468)
- def _reduce_86(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 472)
- def _reduce_87(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 477)
- def _reduce_88(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 481)
- def _reduce_89(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 485)
- def _reduce_90(val, _values, result)
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 489)
- def _reduce_91(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 493)
- def _reduce_92(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 497)
- def _reduce_93(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 501)
- def _reduce_94(val, _values, result)
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 506)
- def _reduce_95(val, _values, result)
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 511)
- def _reduce_96(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 516)
- def _reduce_97(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 520)
- def _reduce_98(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 524)
- def _reduce_99(val, _values, result)
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 528)
- def _reduce_100(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 532)
- def _reduce_101(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 536)
- def _reduce_102(val, _values, result)
- result = @builder.attr_asgn(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 540)
- def _reduce_103(val, _values, result)
- result = @builder.assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 545)
- def _reduce_104(val, _values, result)
- result = @builder.assignable(
- @builder.const_global(val[0], val[1]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 550)
- def _reduce_105(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 555)
- def _reduce_106(val, _values, result)
- diagnostic :error, :module_name_const, nil, val[0]
-
- result
- end
-.,.,
-
-# reduce 107 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 561)
- def _reduce_108(val, _values, result)
- result = @builder.const_global(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 565)
- def _reduce_109(val, _values, result)
- result = @builder.const(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 569)
- def _reduce_110(val, _values, result)
- result = @builder.const_fetch(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-# reduce 111 omitted
-
-# reduce 112 omitted
-
-# reduce 113 omitted
-
-# reduce 114 omitted
-
-# reduce 115 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 578)
- def _reduce_116(val, _values, result)
- result = @builder.symbol(val[0])
-
- result
- end
-.,.,
-
-# reduce 117 omitted
-
-# reduce 118 omitted
-
-# reduce 119 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 587)
- def _reduce_120(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 591)
- def _reduce_121(val, _values, result)
- @lexer.state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 595)
- def _reduce_122(val, _values, result)
- result = val[0] << val[3]
-
- result
- end
-.,.,
-
-# reduce 123 omitted
-
-# reduce 124 omitted
-
-# reduce 125 omitted
-
-# reduce 126 omitted
-
-# reduce 127 omitted
-
-# reduce 128 omitted
-
-# reduce 129 omitted
-
-# reduce 130 omitted
-
-# reduce 131 omitted
-
-# reduce 132 omitted
-
-# reduce 133 omitted
-
-# reduce 134 omitted
-
-# reduce 135 omitted
-
-# reduce 136 omitted
-
-# reduce 137 omitted
-
-# reduce 138 omitted
-
-# reduce 139 omitted
-
-# reduce 140 omitted
-
-# reduce 141 omitted
-
-# reduce 142 omitted
-
-# reduce 143 omitted
-
-# reduce 144 omitted
-
-# reduce 145 omitted
-
-# reduce 146 omitted
-
-# reduce 147 omitted
-
-# reduce 148 omitted
-
-# reduce 149 omitted
-
-# reduce 150 omitted
-
-# reduce 151 omitted
-
-# reduce 152 omitted
-
-# reduce 153 omitted
-
-# reduce 154 omitted
-
-# reduce 155 omitted
-
-# reduce 156 omitted
-
-# reduce 157 omitted
-
-# reduce 158 omitted
-
-# reduce 159 omitted
-
-# reduce 160 omitted
-
-# reduce 161 omitted
-
-# reduce 162 omitted
-
-# reduce 163 omitted
-
-# reduce 164 omitted
-
-# reduce 165 omitted
-
-# reduce 166 omitted
-
-# reduce 167 omitted
-
-# reduce 168 omitted
-
-# reduce 169 omitted
-
-# reduce 170 omitted
-
-# reduce 171 omitted
-
-# reduce 172 omitted
-
-# reduce 173 omitted
-
-# reduce 174 omitted
-
-# reduce 175 omitted
-
-# reduce 176 omitted
-
-# reduce 177 omitted
-
-# reduce 178 omitted
-
-# reduce 179 omitted
-
-# reduce 180 omitted
-
-# reduce 181 omitted
-
-# reduce 182 omitted
-
-# reduce 183 omitted
-
-# reduce 184 omitted
-
-# reduce 185 omitted
-
-# reduce 186 omitted
-
-# reduce 187 omitted
-
-# reduce 188 omitted
-
-# reduce 189 omitted
-
-# reduce 190 omitted
-
-# reduce 191 omitted
-
-# reduce 192 omitted
-
-# reduce 193 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 616)
- def _reduce_194(val, _values, result)
- result = @builder.assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 620)
- def _reduce_195(val, _values, result)
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.assign(val[0], val[1], rescue_)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 630)
- def _reduce_196(val, _values, result)
- result = @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 634)
- def _reduce_197(val, _values, result)
- rescue_body = @builder.rescue_body(val[3],
- nil, nil, nil,
- nil, val[4])
-
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
-
- result = @builder.op_assign(val[0], val[1], rescue_)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 644)
- def _reduce_198(val, _values, result)
- result = @builder.op_assign(
- @builder.index(
- val[0], val[1], val[2], val[3]),
- val[4], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 651)
- def _reduce_199(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 658)
- def _reduce_200(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 665)
- def _reduce_201(val, _values, result)
- result = @builder.op_assign(
- @builder.call_method(
- val[0], val[1], val[2]),
- val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 672)
- def _reduce_202(val, _values, result)
- const = @builder.const_op_assignable(
- @builder.const_fetch(val[0], val[1], val[2]))
- result = @builder.op_assign(const, val[3], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 678)
- def _reduce_203(val, _values, result)
- const = @builder.const_op_assignable(
- @builder.const_global(val[0], val[1]))
- result = @builder.op_assign(const, val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 684)
- def _reduce_204(val, _values, result)
- result = @builder.op_assign(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 688)
- def _reduce_205(val, _values, result)
- result = @builder.range_inclusive(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 692)
- def _reduce_206(val, _values, result)
- result = @builder.range_exclusive(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 696)
- def _reduce_207(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 700)
- def _reduce_208(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 704)
- def _reduce_209(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 708)
- def _reduce_210(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 712)
- def _reduce_211(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 716)
- def _reduce_212(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 720)
- def _reduce_213(val, _values, result)
- result = @builder.unary_op(val[0],
- @builder.binary_op(
- val[1], val[2], val[3]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 726)
- def _reduce_214(val, _values, result)
- result = @builder.unary_op(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 730)
- def _reduce_215(val, _values, result)
- result = @builder.unary_op(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 734)
- def _reduce_216(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 738)
- def _reduce_217(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 742)
- def _reduce_218(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 746)
- def _reduce_219(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 750)
- def _reduce_220(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 754)
- def _reduce_221(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 758)
- def _reduce_222(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 762)
- def _reduce_223(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 766)
- def _reduce_224(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 770)
- def _reduce_225(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 774)
- def _reduce_226(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 778)
- def _reduce_227(val, _values, result)
- result = @builder.match_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 782)
- def _reduce_228(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 786)
- def _reduce_229(val, _values, result)
- result = @builder.not_op(val[0], nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 790)
- def _reduce_230(val, _values, result)
- result = @builder.unary_op(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 794)
- def _reduce_231(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 798)
- def _reduce_232(val, _values, result)
- result = @builder.binary_op(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 802)
- def _reduce_233(val, _values, result)
- result = @builder.logical_op(:and, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 806)
- def _reduce_234(val, _values, result)
- result = @builder.logical_op(:or, val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 810)
- def _reduce_235(val, _values, result)
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 820)
- def _reduce_236(val, _values, result)
- @lexer.push_cond
- @lexer.cond.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 825)
- def _reduce_237(val, _values, result)
- @lexer.pop_cond
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 829)
- def _reduce_238(val, _values, result)
- result = @builder.ternary(val[0], val[1],
- val[3], val[5], val[7])
-
- result
- end
-.,.,
-
-# reduce 239 omitted
-
-# reduce 240 omitted
-
-# reduce 241 omitted
-
-# reduce 242 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 840)
- def _reduce_243(val, _values, result)
- result = val[0] << @builder.associate(nil, val[2], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 844)
- def _reduce_244(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 849)
- def _reduce_245(val, _values, result)
- result = val
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 854)
- def _reduce_246(val, _values, result)
- result = [ nil, [], nil ]
-
- result
- end
-.,.,
-
-# reduce 247 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 860)
- def _reduce_248(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-# reduce 249 omitted
-
-# reduce 250 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 866)
- def _reduce_251(val, _values, result)
- result = val[0] << @builder.associate(nil, val[2], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 870)
- def _reduce_252(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 875)
- def _reduce_253(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 879)
- def _reduce_254(val, _values, result)
- result = val[0].concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 883)
- def _reduce_255(val, _values, result)
- result = [ @builder.associate(nil, val[0], nil) ]
- result.concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 888)
- def _reduce_256(val, _values, result)
- assocs = @builder.associate(nil, val[2], nil)
- result = val[0] << assocs
- result.concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 894)
- def _reduce_257(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 898)
- def _reduce_258(val, _values, result)
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 903)
- def _reduce_259(val, _values, result)
- @lexer.cmdarg = val[0]
-
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 910)
- def _reduce_260(val, _values, result)
- result = @builder.block_pass(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 915)
- def _reduce_261(val, _values, result)
- result = [ val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 919)
- def _reduce_262(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 924)
- def _reduce_263(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 928)
- def _reduce_264(val, _values, result)
- result = [ @builder.splat(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 932)
- def _reduce_265(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 936)
- def _reduce_266(val, _values, result)
- result = val[0] << @builder.splat(val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 941)
- def _reduce_267(val, _values, result)
- result = @builder.array(nil, val[0], nil)
-
- result
- end
-.,.,
-
-# reduce 268 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 947)
- def _reduce_269(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 951)
- def _reduce_270(val, _values, result)
- result = val[0] << @builder.splat(val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 955)
- def _reduce_271(val, _values, result)
- result = [ @builder.splat(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-# reduce 272 omitted
-
-# reduce 273 omitted
-
-# reduce 274 omitted
-
-# reduce 275 omitted
-
-# reduce 276 omitted
-
-# reduce 277 omitted
-
-# reduce 278 omitted
-
-# reduce 279 omitted
-
-# reduce 280 omitted
-
-# reduce 281 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 970)
- def _reduce_282(val, _values, result)
- result = @builder.call_method(nil, nil, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 974)
- def _reduce_283(val, _values, result)
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 979)
- def _reduce_284(val, _values, result)
- @lexer.cmdarg = val[1]
-
- result = @builder.begin_keyword(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 985)
- def _reduce_285(val, _values, result)
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 990)
- def _reduce_286(val, _values, result)
- @lexer.state = :expr_endarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 994)
- def _reduce_287(val, _values, result)
- @lexer.cmdarg = val[1]
-
- result = @builder.begin(val[0], val[2], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1000)
- def _reduce_288(val, _values, result)
- @lexer.state = :expr_endarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1004)
- def _reduce_289(val, _values, result)
- result = @builder.begin(val[0], nil, val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1008)
- def _reduce_290(val, _values, result)
- result = @builder.begin(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1012)
- def _reduce_291(val, _values, result)
- result = @builder.const_fetch(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1016)
- def _reduce_292(val, _values, result)
- result = @builder.const_global(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1020)
- def _reduce_293(val, _values, result)
- result = @builder.array(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1024)
- def _reduce_294(val, _values, result)
- result = @builder.associate(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1028)
- def _reduce_295(val, _values, result)
- result = @builder.keyword_cmd(:return, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1032)
- def _reduce_296(val, _values, result)
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1036)
- def _reduce_297(val, _values, result)
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1040)
- def _reduce_298(val, _values, result)
- result = @builder.keyword_cmd(:yield, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1044)
- def _reduce_299(val, _values, result)
- result = @builder.keyword_cmd(:defined?, val[0],
- val[2], [ val[3] ], val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1049)
- def _reduce_300(val, _values, result)
- result = @builder.not_op(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1053)
- def _reduce_301(val, _values, result)
- result = @builder.not_op(val[0], val[1], nil, val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1057)
- def _reduce_302(val, _values, result)
- method_call = @builder.call_method(nil, nil, val[0])
-
- begin_t, args, body, end_t = val[1]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-# reduce 303 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1066)
- def _reduce_304(val, _values, result)
- begin_t, args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1072)
- def _reduce_305(val, _values, result)
- lambda_call = @builder.call_lambda(val[0])
-
- args, (begin_t, body, end_t) = val[1]
- result = @builder.block(lambda_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1080)
- def _reduce_306(val, _values, result)
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1087)
- def _reduce_307(val, _values, result)
- else_t, else_ = val[4]
- result = @builder.condition(val[0], val[1], val[2],
- else_, else_t,
- val[3], val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1094)
- def _reduce_308(val, _values, result)
- @lexer.cond.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1098)
- def _reduce_309(val, _values, result)
- @lexer.cond.pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1102)
- def _reduce_310(val, _values, result)
- result = @builder.loop(:while, val[0], val[2], val[3],
- val[5], val[6])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1107)
- def _reduce_311(val, _values, result)
- @lexer.cond.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1111)
- def _reduce_312(val, _values, result)
- @lexer.cond.pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1115)
- def _reduce_313(val, _values, result)
- result = @builder.loop(:until, val[0], val[2], val[3],
- val[5], val[6])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1120)
- def _reduce_314(val, _values, result)
- *when_bodies, (else_t, else_body) = *val[3]
-
- result = @builder.case(val[0], val[1],
- when_bodies, else_t, else_body,
- val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1128)
- def _reduce_315(val, _values, result)
- *when_bodies, (else_t, else_body) = *val[2]
-
- result = @builder.case(val[0], nil,
- when_bodies, else_t, else_body,
- val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1136)
- def _reduce_316(val, _values, result)
- @lexer.cond.push(true)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1140)
- def _reduce_317(val, _values, result)
- @lexer.cond.pop
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1144)
- def _reduce_318(val, _values, result)
- result = @builder.for(val[0], val[1],
- val[2], val[4],
- val[5], val[7], val[8])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1150)
- def _reduce_319(val, _values, result)
- @static_env.extend_static
- @lexer.push_cmdarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1155)
- def _reduce_320(val, _values, result)
- if in_def?
- diagnostic :error, :class_in_def, nil, val[0]
- end
-
- lt_t, superclass = val[2]
- result = @builder.def_class(val[0], val[1],
- lt_t, superclass,
- val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1169)
- def _reduce_321(val, _values, result)
- result = @def_level
- @def_level = 0
-
- @static_env.extend_static
- @lexer.push_cmdarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1177)
- def _reduce_322(val, _values, result)
- result = @builder.def_sclass(val[0], val[1], val[2],
- val[5], val[6])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- @def_level = val[4]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1187)
- def _reduce_323(val, _values, result)
- @static_env.extend_static
- @lexer.push_cmdarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1192)
- def _reduce_324(val, _values, result)
- if in_def?
- diagnostic :error, :module_in_def, nil, val[0]
- end
-
- result = @builder.def_module(val[0], val[1],
- val[3], val[4])
-
- @lexer.pop_cmdarg
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1204)
- def _reduce_325(val, _values, result)
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1210)
- def _reduce_326(val, _values, result)
- result = @builder.def_method(val[0], val[1],
- val[3], val[4], val[5])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1219)
- def _reduce_327(val, _values, result)
- @lexer.state = :expr_fname
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1223)
- def _reduce_328(val, _values, result)
- @def_level += 1
- @static_env.extend_static
- @lexer.push_cmdarg
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1229)
- def _reduce_329(val, _values, result)
- result = @builder.def_singleton(val[0], val[1], val[2],
- val[4], val[6], val[7], val[8])
-
- @lexer.pop_cmdarg
- @static_env.unextend
- @def_level -= 1
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1238)
- def _reduce_330(val, _values, result)
- result = @builder.keyword_cmd(:break, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1242)
- def _reduce_331(val, _values, result)
- result = @builder.keyword_cmd(:next, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1246)
- def _reduce_332(val, _values, result)
- result = @builder.keyword_cmd(:redo, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1250)
- def _reduce_333(val, _values, result)
- result = @builder.keyword_cmd(:retry, val[0])
-
- result
- end
-.,.,
-
-# reduce 334 omitted
-
-# reduce 335 omitted
-
-# reduce 336 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1259)
- def _reduce_337(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-# reduce 338 omitted
-
-# reduce 339 omitted
-
-# reduce 340 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1268)
- def _reduce_341(val, _values, result)
- else_t, else_ = val[4]
- result = [ val[0],
- @builder.condition(val[0], val[1], val[2],
- val[3], else_t,
- else_, nil),
- ]
-
- result
- end
-.,.,
-
-# reduce 342 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1279)
- def _reduce_343(val, _values, result)
- result = val
-
- result
- end
-.,.,
-
-# reduce 344 omitted
-
-# reduce 345 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1287)
- def _reduce_346(val, _values, result)
- result = @builder.arg(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1291)
- def _reduce_347(val, _values, result)
- result = @builder.multi_lhs(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1296)
- def _reduce_348(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1300)
- def _reduce_349(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-# reduce 350 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1306)
- def _reduce_351(val, _values, result)
- result = val[0].
- push(@builder.restarg(val[2], val[3]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1311)
- def _reduce_352(val, _values, result)
- result = val[0].
- push(@builder.restarg(val[2], val[3])).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1317)
- def _reduce_353(val, _values, result)
- result = val[0].
- push(@builder.restarg(val[2]))
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1322)
- def _reduce_354(val, _values, result)
- result = val[0].
- push(@builder.restarg(val[2])).
- concat(val[4])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1328)
- def _reduce_355(val, _values, result)
- result = [ @builder.restarg(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1332)
- def _reduce_356(val, _values, result)
- result = [ @builder.restarg(val[0], val[1]),
- *val[3] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1337)
- def _reduce_357(val, _values, result)
- result = [ @builder.restarg(val[0]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1341)
- def _reduce_358(val, _values, result)
- result = [ @builder.restarg(val[0]),
- *val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1347)
- def _reduce_359(val, _values, result)
- result = val[0].concat(val[2]).concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1351)
- def _reduce_360(val, _values, result)
- result = val[0].concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1355)
- def _reduce_361(val, _values, result)
- result = val[0].concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1359)
- def _reduce_362(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1365)
- def _reduce_363(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1369)
- def _reduce_364(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1374)
- def _reduce_365(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1381)
- def _reduce_366(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1389)
- def _reduce_367(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1395)
- def _reduce_368(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1402)
- def _reduce_369(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-# reduce 370 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1409)
- def _reduce_371(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1416)
- def _reduce_372(val, _values, result)
- result = val[0].concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1420)
- def _reduce_373(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1426)
- def _reduce_374(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1433)
- def _reduce_375(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1438)
- def _reduce_376(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1444)
- def _reduce_377(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1449)
- def _reduce_378(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-# reduce 379 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1457)
- def _reduce_380(val, _values, result)
- result = @builder.args(nil, [], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1461)
- def _reduce_381(val, _values, result)
- @lexer.state = :expr_value
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1466)
- def _reduce_382(val, _values, result)
- result = @builder.args(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1470)
- def _reduce_383(val, _values, result)
- result = @builder.args(val[0], [], val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1474)
- def _reduce_384(val, _values, result)
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1479)
- def _reduce_385(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1483)
- def _reduce_386(val, _values, result)
- result = val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1488)
- def _reduce_387(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1492)
- def _reduce_388(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1497)
- def _reduce_389(val, _values, result)
- result = @builder.shadowarg(val[0])
-
- result
- end
-.,.,
-
-# reduce 390 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1502)
- def _reduce_391(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1506)
- def _reduce_392(val, _values, result)
- result = @lexer.cmdarg.dup
- @lexer.cmdarg.clear
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1511)
- def _reduce_393(val, _values, result)
- @lexer.cmdarg = val[2]
- @lexer.cmdarg.lexpop
-
- result = [ val[1], val[3] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1521)
- def _reduce_394(val, _values, result)
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1525)
- def _reduce_395(val, _values, result)
- result = @builder.args(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1530)
- def _reduce_396(val, _values, result)
- result = [ val[0], val[1], val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1534)
- def _reduce_397(val, _values, result)
- result = [ val[0], val[1], val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1539)
- def _reduce_398(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1543)
- def _reduce_399(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1550)
- def _reduce_400(val, _values, result)
- begin_t, block_args, body, end_t = val[1]
- result = @builder.block(val[0],
- begin_t, block_args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1556)
- def _reduce_401(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1562)
- def _reduce_402(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- method_call = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1572)
- def _reduce_403(val, _values, result)
- method_call = @builder.call_method(val[0], val[1], val[2],
- nil, val[3], nil)
-
- begin_t, args, body, end_t = val[4]
- result = @builder.block(method_call,
- begin_t, args, body, end_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1582)
- def _reduce_404(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- result = @builder.call_method(nil, nil, val[0],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1588)
- def _reduce_405(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1594)
- def _reduce_406(val, _values, result)
- lparen_t, args, rparen_t = val[3]
- result = @builder.call_method(val[0], val[1], val[2],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1600)
- def _reduce_407(val, _values, result)
- result = @builder.call_method(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1604)
- def _reduce_408(val, _values, result)
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1610)
- def _reduce_409(val, _values, result)
- lparen_t, args, rparen_t = val[2]
- result = @builder.call_method(val[0], val[1], nil,
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1616)
- def _reduce_410(val, _values, result)
- lparen_t, args, rparen_t = val[1]
- result = @builder.keyword_cmd(:super, val[0],
- lparen_t, args, rparen_t)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1622)
- def _reduce_411(val, _values, result)
- result = @builder.keyword_cmd(:zsuper, val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1626)
- def _reduce_412(val, _values, result)
- result = @builder.index(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1631)
- def _reduce_413(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1635)
- def _reduce_414(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1641)
- def _reduce_415(val, _values, result)
- @static_env.extend_dynamic
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1645)
- def _reduce_416(val, _values, result)
- result = [ val[0], val[2], val[3], val[4] ]
-
- @static_env.unextend
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1652)
- def _reduce_417(val, _values, result)
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
- *val[4] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1658)
- def _reduce_418(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-# reduce 419 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1664)
- def _reduce_420(val, _values, result)
- assoc_t, exc_var = val[2]
-
- if val[1]
- exc_list = @builder.array(nil, val[1], nil)
- end
-
- result = [ @builder.rescue_body(val[0],
- exc_list, assoc_t, exc_var,
- val[3], val[4]),
- *val[5] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1677)
- def _reduce_421(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1682)
- def _reduce_422(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-# reduce 423 omitted
-
-# reduce 424 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1689)
- def _reduce_425(val, _values, result)
- result = [ val[0], val[1] ]
-
- result
- end
-.,.,
-
-# reduce 426 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1695)
- def _reduce_427(val, _values, result)
- result = [ val[0], val[1] ]
-
- result
- end
-.,.,
-
-# reduce 428 omitted
-
-# reduce 429 omitted
-
-# reduce 430 omitted
-
-# reduce 431 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1705)
- def _reduce_432(val, _values, result)
- result = @builder.string_compose(nil, val[0], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1710)
- def _reduce_433(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1714)
- def _reduce_434(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1719)
- def _reduce_435(val, _values, result)
- result = @builder.string_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1723)
- def _reduce_436(val, _values, result)
- result = @builder.string(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1727)
- def _reduce_437(val, _values, result)
- result = @builder.character(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1732)
- def _reduce_438(val, _values, result)
- result = @builder.xstring_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1737)
- def _reduce_439(val, _values, result)
- opts = @builder.regexp_options(val[3])
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1743)
- def _reduce_440(val, _values, result)
- result = @builder.words_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1748)
- def _reduce_441(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1752)
- def _reduce_442(val, _values, result)
- result = val[0] << @builder.word(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1757)
- def _reduce_443(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1761)
- def _reduce_444(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1766)
- def _reduce_445(val, _values, result)
- result = @builder.symbols_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1771)
- def _reduce_446(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1775)
- def _reduce_447(val, _values, result)
- result = val[0] << @builder.word(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1780)
- def _reduce_448(val, _values, result)
- result = @builder.words_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1785)
- def _reduce_449(val, _values, result)
- result = @builder.symbols_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1790)
- def _reduce_450(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1794)
- def _reduce_451(val, _values, result)
- result = val[0] << @builder.string_internal(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1799)
- def _reduce_452(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1803)
- def _reduce_453(val, _values, result)
- result = val[0] << @builder.symbol_internal(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1808)
- def _reduce_454(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1812)
- def _reduce_455(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1817)
- def _reduce_456(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1821)
- def _reduce_457(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1826)
- def _reduce_458(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1830)
- def _reduce_459(val, _values, result)
- result = val[0] << val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1835)
- def _reduce_460(val, _values, result)
- result = @builder.string_internal(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1839)
- def _reduce_461(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1843)
- def _reduce_462(val, _values, result)
- @lexer.cond.push(false)
- @lexer.cmdarg.push(false)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1848)
- def _reduce_463(val, _values, result)
- @lexer.cond.lexpop
- @lexer.cmdarg.lexpop
-
- result = @builder.begin(val[0], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1856)
- def _reduce_464(val, _values, result)
- result = @builder.gvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1860)
- def _reduce_465(val, _values, result)
- result = @builder.ivar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1864)
- def _reduce_466(val, _values, result)
- result = @builder.cvar(val[0])
-
- result
- end
-.,.,
-
-# reduce 467 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 1871)
- def _reduce_468(val, _values, result)
- result = @builder.symbol(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1876)
- def _reduce_469(val, _values, result)
- result = @builder.symbol_compose(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1881)
- def _reduce_470(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1885)
- def _reduce_471(val, _values, result)
- result = @builder.negate(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1890)
- def _reduce_472(val, _values, result)
- result = @builder.integer(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1894)
- def _reduce_473(val, _values, result)
- result = @builder.float(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1898)
- def _reduce_474(val, _values, result)
- result = @builder.rational(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1902)
- def _reduce_475(val, _values, result)
- result = @builder.complex(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1907)
- def _reduce_476(val, _values, result)
- result = @builder.ident(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1911)
- def _reduce_477(val, _values, result)
- result = @builder.ivar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1915)
- def _reduce_478(val, _values, result)
- result = @builder.gvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1919)
- def _reduce_479(val, _values, result)
- result = @builder.const(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1923)
- def _reduce_480(val, _values, result)
- result = @builder.cvar(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1928)
- def _reduce_481(val, _values, result)
- result = @builder.nil(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1932)
- def _reduce_482(val, _values, result)
- result = @builder.self(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1936)
- def _reduce_483(val, _values, result)
- result = @builder.true(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1940)
- def _reduce_484(val, _values, result)
- result = @builder.false(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1944)
- def _reduce_485(val, _values, result)
- result = @builder.__FILE__(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1948)
- def _reduce_486(val, _values, result)
- result = @builder.__LINE__(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1952)
- def _reduce_487(val, _values, result)
- result = @builder.__ENCODING__(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1957)
- def _reduce_488(val, _values, result)
- result = @builder.accessible(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1961)
- def _reduce_489(val, _values, result)
- result = @builder.accessible(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1966)
- def _reduce_490(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1970)
- def _reduce_491(val, _values, result)
- result = @builder.assignable(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1975)
- def _reduce_492(val, _values, result)
- result = @builder.nth_ref(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1979)
- def _reduce_493(val, _values, result)
- result = @builder.back_ref(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1984)
- def _reduce_494(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1988)
- def _reduce_495(val, _values, result)
- @lexer.state = :expr_value
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1992)
- def _reduce_496(val, _values, result)
- result = [ val[0], val[2] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 1996)
- def _reduce_497(val, _values, result)
- yyerrok
- result = nil
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2002)
- def _reduce_498(val, _values, result)
- result = @builder.args(val[0], val[1], val[2])
-
- @lexer.state = :expr_value
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2007)
- def _reduce_499(val, _values, result)
- result = @lexer.in_kwarg
- @lexer.in_kwarg = true
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2012)
- def _reduce_500(val, _values, result)
- @lexer.in_kwarg = val[0]
- result = @builder.args(nil, val[1], nil)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2018)
- def _reduce_501(val, _values, result)
- result = val[0].concat(val[2]).concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2022)
- def _reduce_502(val, _values, result)
- result = val[0].concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2026)
- def _reduce_503(val, _values, result)
- result = val[0].concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2030)
- def _reduce_504(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2035)
- def _reduce_505(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2039)
- def _reduce_506(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2044)
- def _reduce_507(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2051)
- def _reduce_508(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[6]).
- concat(val[7])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2059)
- def _reduce_509(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2065)
- def _reduce_510(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2072)
- def _reduce_511(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2078)
- def _reduce_512(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2085)
- def _reduce_513(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2090)
- def _reduce_514(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2096)
- def _reduce_515(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[4]).
- concat(val[5])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2103)
- def _reduce_516(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2108)
- def _reduce_517(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2114)
- def _reduce_518(val, _values, result)
- result = val[0].
- concat(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2119)
- def _reduce_519(val, _values, result)
- result = val[0].
- concat(val[2]).
- concat(val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2125)
- def _reduce_520(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2129)
- def _reduce_521(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2134)
- def _reduce_522(val, _values, result)
- diagnostic :error, :argument_const, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2138)
- def _reduce_523(val, _values, result)
- diagnostic :error, :argument_ivar, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2142)
- def _reduce_524(val, _values, result)
- diagnostic :error, :argument_gvar, nil, val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2146)
- def _reduce_525(val, _values, result)
- diagnostic :error, :argument_cvar, nil, val[0]
-
- result
- end
-.,.,
-
-# reduce 526 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2152)
- def _reduce_527(val, _values, result)
- @static_env.declare val[0][0]
-
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2159)
- def _reduce_528(val, _values, result)
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2164)
- def _reduce_529(val, _values, result)
- result = @builder.arg(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2168)
- def _reduce_530(val, _values, result)
- result = @builder.multi_lhs(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2173)
- def _reduce_531(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2177)
- def _reduce_532(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2182)
- def _reduce_533(val, _values, result)
- check_kwarg_name(val[0])
-
- @static_env.declare val[0][0]
-
- result = val[0]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2191)
- def _reduce_534(val, _values, result)
- result = @builder.kwoptarg(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2195)
- def _reduce_535(val, _values, result)
- result = @builder.kwarg(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2200)
- def _reduce_536(val, _values, result)
- result = @builder.kwoptarg(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2204)
- def _reduce_537(val, _values, result)
- result = @builder.kwarg(val[0])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2209)
- def _reduce_538(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2213)
- def _reduce_539(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2218)
- def _reduce_540(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2222)
- def _reduce_541(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-# reduce 542 omitted
-
-# reduce 543 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2229)
- def _reduce_544(val, _values, result)
- @static_env.declare val[1][0]
-
- result = [ @builder.kwrestarg(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2235)
- def _reduce_545(val, _values, result)
- result = [ @builder.kwrestarg(val[0]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2240)
- def _reduce_546(val, _values, result)
- result = @builder.optarg(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2245)
- def _reduce_547(val, _values, result)
- result = @builder.optarg(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2250)
- def _reduce_548(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2254)
- def _reduce_549(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2259)
- def _reduce_550(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2263)
- def _reduce_551(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-# reduce 552 omitted
-
-# reduce 553 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2270)
- def _reduce_554(val, _values, result)
- @static_env.declare val[1][0]
-
- result = [ @builder.restarg(val[0], val[1]) ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2276)
- def _reduce_555(val, _values, result)
- result = [ @builder.restarg(val[0]) ]
-
- result
- end
-.,.,
-
-# reduce 556 omitted
-
-# reduce 557 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2283)
- def _reduce_558(val, _values, result)
- @static_env.declare val[1][0]
-
- result = @builder.blockarg(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2290)
- def _reduce_559(val, _values, result)
- result = [ val[1] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2294)
- def _reduce_560(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-# reduce 561 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2300)
- def _reduce_562(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2305)
- def _reduce_563(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-# reduce 564 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2311)
- def _reduce_565(val, _values, result)
- result = [ val[0] ]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2315)
- def _reduce_566(val, _values, result)
- result = val[0] << val[2]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2320)
- def _reduce_567(val, _values, result)
- result = @builder.pair(val[0], val[1], val[2])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2324)
- def _reduce_568(val, _values, result)
- result = @builder.pair_keyword(val[0], val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2328)
- def _reduce_569(val, _values, result)
- result = @builder.pair_quoted(val[0], val[1], val[2], val[3])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2332)
- def _reduce_570(val, _values, result)
- result = @builder.kwsplat(val[0], val[1])
-
- result
- end
-.,.,
-
-# reduce 571 omitted
-
-# reduce 572 omitted
-
-# reduce 573 omitted
-
-# reduce 574 omitted
-
-# reduce 575 omitted
-
-# reduce 576 omitted
-
-# reduce 577 omitted
-
-# reduce 578 omitted
-
-# reduce 579 omitted
-
-# reduce 580 omitted
-
-# reduce 581 omitted
-
-# reduce 582 omitted
-
-# reduce 583 omitted
-
-# reduce 584 omitted
-
-# reduce 585 omitted
-
-# reduce 586 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2343)
- def _reduce_587(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'ruby22.y', 2347)
- def _reduce_588(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-# reduce 589 omitted
-
-# reduce 590 omitted
-
-# reduce 591 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2353)
- def _reduce_592(val, _values, result)
- yyerrok
-
- result
- end
-.,.,
-
-# reduce 593 omitted
-
-# reduce 594 omitted
-
-# reduce 595 omitted
-
-module_eval(<<'.,.,', 'ruby22.y', 2362)
- def _reduce_596(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Ruby22
-end # module Parser
diff --git a/test/racc/regress/tp_plus b/test/racc/regress/tp_plus
deleted file mode 100644
index bb4e1f1a00..0000000000
--- a/test/racc/regress/tp_plus
+++ /dev/null
@@ -1,1933 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-module TPPlus
- class Parser < Racc::Parser
-
-module_eval(<<'...end tp_plus.y/module_eval...', 'tp_plus.y', 592)
-
- include TPPlus::Nodes
-
- attr_reader :interpreter
- def initialize(scanner, interpreter = TPPlus::Interpreter.new)
- @scanner = scanner
- @interpreter = interpreter
- super()
- end
-
- def next_token
- t = @scanner.next_token
- @interpreter.line_count += 1 if t && t[0] == :NEWLINE
-
- #puts t.inspect
- t
- end
-
- def parse
- #@yydebug =true
-
- do_parse
- @interpreter
- end
-
- def on_error(t, val, vstack)
- raise ParseError, sprintf("Parse error on line #{@scanner.tok_line} column #{@scanner.tok_col}: %s (%s)",
- val.inspect, token_to_str(t) || '?')
- end
-
- class ParseError < StandardError ; end
-...end tp_plus.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 62, 62, 62, 62, 101, 122, 62, 41, 38, 130,
- 275, 265, 72, 41, 72, 98, 113, 72, 53, 114,
- 41, 67, 67, 67, 67, 234, 38, 26, 303, 304,
- 101, 36, 286, 159, 81, 82, 72, 308, 159, 81,
- 82, 72, 122, 287, 308, 60, 288, 60, 42, 308,
- 60, 43, 44, 131, 45, 31, 32, 355, 289, 34,
- 35, 46, 47, 102, 60, 273, 30, 72, 29, 28,
- 25, 63, 290, 37, 27, 24, 62, 41, 38, 37,
- 69, 69, 69, 69, 33, 61, 37, 97, 53, 102,
- 61, 37, 81, 82, 300, 61, 82, 26, 82, 72,
- 60, 36, 159, 81, 82, 72, 223, 221, 224, 371,
- 336, 335, 105, 220, 292, 81, 82, 72, 42, 293,
- 317, 43, 44, 294, 45, 31, 32, 96, 122, 34,
- 35, 46, 47, 96, 60, 208, 30, 209, 29, 28,
- 25, 63, 122, 37, 27, 24, 62, 41, 38, 72,
- 60, 81, 82, 72, 33, 61, 298, 116, 53, 61,
- 301, 88, 94, 96, 321, 117, 118, 26, 317, 352,
- 302, 36, 323, 305, 203, 349, 350, 351, 353, 152,
- 151, 96, 367, 81, 82, 72, 60, 255, 42, 209,
- 306, 43, 44, 313, 45, 31, 32, 314, 94, 34,
- 35, 46, 47, 122, 60, 122, 30, 61, 29, 28,
- 25, 63, 321, 37, 27, 24, 62, 41, 38, 325,
- 323, 326, 203, 327, 33, 61, 82, 72, 53, 82,
- 72, 182, 181, 179, 180, 177, 173, 26, 176, 174,
- 328, 36, 81, 82, 72, 81, 82, 72, 81, 82,
- 72, 81, 82, 81, 82, 72, 97, 333, 42, 275,
- 122, 43, 44, 96, 45, 31, 32, 33, 188, 34,
- 35, 46, 47, 333, 60, 122, 30, 346, 29, 28,
- 25, 63, 347, 37, 27, 24, 348, 178, 356, 175,
- 81, 82, 72, 357, 33, 61, 81, 82, 72, 358,
- 88, 317, 96, 81, 82, 72, 88, 359, 96, 81,
- 82, 72, 360, 88, 96, 96, 81, 82, 72, 88,
- 361, 96, 81, 82, 72, 60, 88, 362, 96, 122,
- 364, 60, 88, 72, 96, 33, 378, 94, 60, 81,
- 82, 72, 379, 94, 60, 321, 61, 81, 82, 72,
- 94, 60, 61, 323, 380, 203, 94, 60, 381, 61,
- 382, 383, 385, 94, 386, 61, 390, 72, 392, 94,
- 64, 70, 61, 81, 82, 72, 74, 75, 61, 81,
- 82, 72, 76, 88, 103, 96, 81, 82, 72, 88,
- 33, 96, 81, 82, 72, 72, 88, 111, 96, 81,
- 82, 72, 88, 72, 96, 115, 72, 121, 60, 88,
- 122, 96, 125, 127, 60, 101, 122, 185, 186, 191,
- 94, 60, 188, 122, 122, 199, 94, 60, 200, 61,
- 201, 203, 204, 94, 60, 61, 210, 211, 212, 94,
- 213, 214, 61, 215, 216, 217, 94, 218, 61, 135,
- 136, 139, 140, 137, 138, 61, 141, 142, 144, 145,
- 146, 148, 143, 147, 135, 136, 139, 140, 137, 138,
- 219, 141, 142, 144, 145, 146, 148, 143, 147, 227,
- 227, 188, 229, 230, 231, 234, 235, 135, 136, 139,
- 140, 137, 138, 207, 141, 142, 144, 145, 146, 148,
- 143, 147, 238, 188, 122, 122, 241, 242, 205, 135,
- 136, 139, 140, 137, 138, 244, 141, 142, 144, 145,
- 146, 148, 143, 147, 188, 245, 246, 247, 248, 249,
- 135, 136, 139, 140, 137, 138, 250, 141, 142, 144,
- 145, 146, 148, 143, 147, 135, 136, 139, 140, 137,
- 138, 251, 141, 142, 144, 145, 146, 148, 143, 147,
- 135, 136, 139, 140, 137, 138, 252, 141, 142, 144,
- 145, 146, 148, 143, 147, 135, 136, 139, 140, 137,
- 138, 253, 141, 142, 144, 145, 146, 148, 143, 147,
- 135, 136, 139, 140, 137, 138, 254, 141, 142, 144,
- 145, 146, 148, 143, 147, 135, 136, 139, 140, 137,
- 138, 257, 141, 142, 144, 145, 146, 148, 143, 147,
- 135, 136, 139, 140, 137, 138, 188, 141, 142, 144,
- 145, 146, 148, 143, 147, 135, 136, 139, 140, 137,
- 138, 259, 141, 142, 144, 145, 146, 148, 143, 147,
- 269, 271, 276, 122, 281, 282, 283, 284, 285 ]
-
-racc_action_check = [
- 309, 65, 312, 3, 72, 343, 188, 188, 188, 70,
- 240, 232, 105, 295, 28, 36, 48, 29, 188, 48,
- 296, 309, 65, 312, 3, 232, 383, 188, 280, 280,
- 36, 188, 249, 186, 186, 186, 186, 295, 97, 97,
- 97, 97, 272, 250, 296, 105, 251, 28, 188, 383,
- 29, 188, 188, 70, 188, 188, 188, 343, 252, 188,
- 188, 188, 188, 72, 188, 240, 188, 38, 188, 188,
- 188, 188, 253, 188, 188, 188, 225, 225, 225, 295,
- 309, 65, 312, 3, 188, 188, 296, 36, 225, 36,
- 186, 383, 224, 224, 272, 97, 254, 225, 358, 358,
- 38, 225, 209, 209, 209, 209, 187, 184, 187, 358,
- 320, 320, 38, 184, 256, 88, 88, 88, 225, 260,
- 337, 225, 225, 263, 225, 225, 225, 88, 265, 225,
- 225, 225, 225, 337, 225, 153, 225, 153, 225, 225,
- 225, 225, 266, 225, 225, 225, 2, 2, 2, 269,
- 88, 199, 199, 199, 225, 225, 270, 55, 2, 209,
- 275, 199, 88, 199, 337, 55, 55, 2, 301, 342,
- 277, 2, 337, 291, 337, 342, 342, 342, 342, 95,
- 95, 301, 357, 357, 357, 357, 199, 222, 2, 222,
- 292, 2, 2, 297, 2, 2, 2, 299, 199, 2,
- 2, 2, 2, 300, 2, 302, 2, 199, 2, 2,
- 2, 2, 301, 2, 2, 2, 0, 0, 0, 303,
- 301, 304, 301, 306, 2, 2, 293, 293, 0, 229,
- 229, 98, 98, 98, 98, 98, 98, 0, 98, 98,
- 307, 0, 326, 326, 326, 75, 75, 75, 238, 238,
- 238, 98, 98, 234, 234, 234, 308, 313, 0, 315,
- 323, 0, 0, 98, 0, 0, 0, 325, 328, 0,
- 0, 0, 0, 331, 0, 333, 0, 338, 0, 0,
- 0, 0, 339, 0, 0, 0, 340, 98, 347, 98,
- 42, 42, 42, 349, 0, 0, 114, 114, 114, 350,
- 42, 363, 42, 76, 76, 76, 114, 351, 114, 134,
- 134, 134, 352, 76, 363, 76, 116, 116, 116, 134,
- 353, 134, 200, 200, 200, 42, 116, 354, 116, 355,
- 356, 114, 200, 359, 200, 361, 365, 42, 76, 360,
- 360, 360, 366, 114, 134, 363, 42, 34, 34, 34,
- 76, 116, 114, 363, 368, 363, 134, 200, 371, 76,
- 372, 373, 376, 116, 379, 134, 384, 385, 387, 200,
- 1, 27, 116, 94, 94, 94, 30, 31, 200, 35,
- 35, 35, 32, 94, 37, 94, 43, 43, 43, 35,
- 41, 35, 45, 45, 45, 44, 43, 46, 43, 113,
- 113, 113, 45, 47, 45, 53, 58, 60, 94, 113,
- 63, 113, 64, 68, 35, 99, 101, 102, 103, 109,
- 94, 43, 111, 112, 115, 117, 35, 45, 118, 94,
- 121, 123, 132, 43, 113, 35, 173, 174, 175, 45,
- 176, 177, 43, 178, 179, 180, 113, 181, 45, 150,
- 150, 150, 150, 150, 150, 113, 150, 150, 150, 150,
- 150, 150, 150, 150, 133, 133, 133, 133, 133, 133,
- 182, 133, 133, 133, 133, 133, 133, 133, 133, 189,
- 190, 108, 191, 192, 193, 194, 197, 108, 108, 108,
- 108, 108, 108, 150, 108, 108, 108, 108, 108, 108,
- 108, 108, 201, 110, 202, 203, 204, 205, 133, 110,
- 110, 110, 110, 110, 110, 210, 110, 110, 110, 110,
- 110, 110, 110, 110, 107, 211, 212, 213, 214, 215,
- 107, 107, 107, 107, 107, 107, 216, 107, 107, 107,
- 107, 107, 107, 107, 107, 236, 236, 236, 236, 236,
- 236, 217, 236, 236, 236, 236, 236, 236, 236, 236,
- 195, 195, 195, 195, 195, 195, 218, 195, 195, 195,
- 195, 195, 195, 195, 195, 196, 196, 196, 196, 196,
- 196, 219, 196, 196, 196, 196, 196, 196, 196, 196,
- 198, 198, 198, 198, 198, 198, 221, 198, 198, 198,
- 198, 198, 198, 198, 198, 206, 206, 206, 206, 206,
- 206, 226, 206, 206, 206, 206, 206, 206, 206, 206,
- 237, 237, 237, 237, 237, 237, 227, 237, 237, 237,
- 237, 237, 237, 237, 237, 83, 83, 83, 83, 83,
- 83, 228, 83, 83, 83, 83, 83, 83, 83, 83,
- 235, 239, 241, 242, 244, 245, 246, 247, 248 ]
-
-racc_action_pointer = [
- 212, 370, 142, -1, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 341, -15, -12,
- 350, 303, 308, nil, 320, 352, 13, 355, 38, nil,
- nil, 308, 263, 359, 366, 365, 368, 374, -30, nil,
- nil, nil, nil, 388, nil, 127, nil, nil, 377, nil,
- 333, nil, nil, 385, 412, -3, nil, nil, 388, nil,
- -17, nil, -13, nil, nil, 218, 276, nil, nil, nil,
- nil, nil, nil, 604, nil, nil, nil, nil, 88, nil,
- nil, nil, nil, nil, 346, 152, nil, 12, 224, 398,
- nil, 391, 341, 344, nil, -17, nil, 499, 456, 368,
- 478, 397, 398, 372, 269, 399, 289, 395, 398, nil,
- nil, 404, nil, 351, nil, nil, nil, nil, nil, nil,
- nil, nil, 355, 433, 282, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 418, nil, nil, 60, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 358, 359, 360, 362, 363, 365, 366,
- 367, 369, 392, nil, 84, nil, 7, 31, 2, 432,
- 433, 408, 435, 436, 424, 529, 544, 468, 559, 124,
- 295, 425, 479, 480, 480, 490, 574, nil, nil, 76,
- 487, 497, 498, 499, 500, 501, 508, 523, 538, 553,
- nil, 522, 112, nil, 65, 72, 563, 601, 593, 201,
- nil, nil, -36, nil, 226, 576, 514, 589, 221, 603,
- -16, 577, 628, nil, 575, 576, 577, 578, 579, -47,
- -36, -33, -21, -7, 68, nil, 37, nil, nil, nil,
- 101, nil, nil, 75, nil, 103, 117, nil, nil, 120,
- 81, nil, 17, nil, nil, 84, nil, 153, nil, nil,
- -27, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 98, 164, 198, nil, 8, 15, 118, nil, 116,
- 178, 142, 180, 145, 147, nil, 148, 165, 182, -4,
- nil, nil, -2, 240, nil, 233, nil, nil, nil, nil,
- 83, nil, nil, 235, nil, 185, 215, nil, 243, nil,
- nil, 256, nil, 250, nil, nil, nil, 94, 202, 205,
- 238, nil, 156, -20, nil, nil, nil, 262, nil, 219,
- 225, 233, 238, 246, 248, 304, 255, 156, 70, 304,
- 312, 253, nil, 275, nil, 261, 265, nil, 279, nil,
- nil, 330, 285, 284, nil, nil, 285, nil, nil, 338,
- nil, nil, nil, 20, 291, 338, nil, 293, nil, nil,
- nil, nil, nil ]
-
-racc_action_default = [
- -2, -210, -1, -188, -8, -9, -10, -11, -12, -13,
- -14, -15, -16, -17, -18, -19, -20, -21, -22, -23,
- -24, -25, -26, -27, -28, -29, -30, -210, -210, -210,
- -210, -210, -210, -45, -210, -210, -118, -210, -210, -61,
- -62, -210, -210, -210, -210, -210, -210, -210, -81, -84,
- -85, -86, -87, -210, -111, -210, -116, -117, -210, -125,
- -210, -183, -184, -190, -210, -188, -3, -185, -7, -187,
- -210, -34, -118, -35, -36, -210, -210, -46, -103, -104,
- -158, -159, -160, -47, -128, -129, -130, -131, -210, -148,
- -149, -150, -151, -152, -210, -210, -157, -52, -210, -119,
- -121, -190, -210, -210, -58, -210, -63, -210, -210, -210,
- -210, -210, -190, -210, -210, -190, -210, -210, -210, -120,
- -126, -210, -189, -210, -192, 393, -4, -6, -186, -31,
- -32, -33, -210, -210, -210, -134, -135, -136, -137, -138,
- -139, -140, -141, -142, -143, -144, -145, -146, -147, -132,
- -210, -155, -156, -210, -50, -53, -54, -55, -56, -57,
- -112, -161, -162, -163, -164, -165, -166, -167, -168, -169,
- -170, -171, -172, -210, -210, -210, -210, -210, -210, -210,
- -210, -210, -210, -122, -210, -127, -52, -210, -210, -89,
- -89, -210, -210, -210, -210, -82, -83, -210, -113, -210,
- -210, -210, -190, -190, -210, -38, -133, -153, -48, -210,
- -210, -210, -210, -210, -210, -210, -210, -210, -210, -210,
- -123, -210, -210, -59, -210, -5, -210, -210, -210, -210,
- -67, -70, -78, -72, -210, -210, -114, -115, -210, -210,
- -210, -210, -190, -51, -210, -210, -210, -210, -210, -210,
- -210, -210, -210, -210, -210, -49, -210, -64, -88, -65,
- -210, -68, -69, -210, -73, -190, -190, -75, -76, -210,
- -210, -191, -190, -194, -195, -210, -37, -39, -41, -42,
- -210, -173, -174, -175, -176, -177, -178, -179, -180, -181,
- -182, -210, -210, -210, -71, -210, -210, -210, -154, -210,
- -190, -205, -190, -210, -210, -124, -210, -210, -210, -188,
- -79, -80, -188, -210, -193, -210, -197, -198, -199, -200,
- -210, -203, -204, -190, -40, -210, -210, -60, -210, -77,
- -74, -90, -91, -190, -196, -201, -202, -205, -210, -210,
- -210, -92, -210, -190, -207, -209, -43, -210, -66, -210,
- -210, -210, -210, -210, -210, -190, -210, -210, -210, -210,
- -210, -210, -206, -205, -44, -210, -210, -110, -210, -98,
- -99, -210, -210, -210, -107, -108, -102, -208, -93, -210,
- -94, -100, -95, -210, -210, -210, -109, -210, -105, -106,
- -97, -101, -96 ]
-
-racc_goto_table = [
- 39, 106, 39, 68, 78, 65, 123, 66, 77, 184,
- 2, 9, 40, 9, 40, 153, 274, 83, 189, 190,
- 194, 192, 193, 197, 107, 108, 261, 110, 39, 39,
- 310, 310, 71, 73, 79, 260, 233, 344, 39, 332,
- 40, 40, 104, 277, 109, 78, 171, 112, 322, 132,
- 40, 291, 309, 312, 226, 228, 1, 341, 133, 311,
- 311, 202, 272, 377, 316, 68, 343, 155, 167, 126,
- 172, 128, 129, 243, 264, 79, 150, 389, 232, 263,
- 266, 331, 365, 368, 322, 373, 387, 384, 160, 119,
- 261, 334, 183, 120, 149, 195, 196, 156, 198, 307,
- 168, 161, 162, 324, 222, 39, 163, 164, 158, 187,
- 322, 165, 166, 169, 170, nil, 206, 40, 388, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 258, nil,
- nil, nil, nil, nil, nil, 239, 240, nil, nil, nil,
- 280, nil, nil, nil, nil, 369, 155, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 295, 296, nil, nil, nil, nil, 155,
- nil, 236, 237, nil, nil, nil, 156, nil, 39, nil,
- nil, nil, nil, nil, 256, nil, nil, 158, 225, 9,
- 40, nil, nil, nil, 267, nil, nil, nil, 78, 156,
- 280, nil, 270, nil, nil, 299, nil, nil, nil, nil,
- 158, nil, nil, nil, nil, 39, nil, nil, 65, 262,
- nil, nil, nil, nil, 268, nil, 9, 40, 79, 340,
- nil, 342, nil, 315, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 337, nil, nil, 297,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 338, 354, nil, nil, nil,
- nil, nil, nil, 262, nil, nil, 78, nil, 363, nil,
- 339, nil, nil, nil, nil, nil, nil, nil, nil, 68,
- nil, nil, 68, 329, nil, nil, 330, nil, nil, nil,
- nil, 376, nil, nil, nil, nil, 79, 78, nil, nil,
- 375, 366, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 79, 370, 372,
- 374, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 391 ]
-
-racc_goto_check = [
- 40, 35, 40, 7, 39, 3, 86, 4, 29, 34,
- 2, 12, 43, 12, 43, 37, 89, 30, 5, 5,
- 34, 5, 5, 34, 30, 30, 47, 30, 40, 40,
- 36, 36, 28, 28, 40, 46, 50, 94, 40, 56,
- 43, 43, 28, 31, 40, 39, 84, 40, 75, 29,
- 43, 47, 52, 52, 45, 45, 1, 56, 30, 44,
- 44, 87, 88, 94, 90, 7, 93, 39, 39, 4,
- 85, 6, 27, 38, 50, 40, 30, 42, 48, 49,
- 51, 55, 57, 58, 75, 59, 60, 61, 62, 63,
- 47, 89, 67, 68, 71, 30, 30, 40, 30, 46,
- 73, 76, 77, 31, 37, 40, 78, 79, 12, 28,
- 75, 80, 81, 82, 83, nil, 30, 43, 36, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 5, nil,
- nil, nil, nil, nil, nil, 86, 86, nil, nil, nil,
- 34, nil, nil, nil, nil, 47, 39, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 34, 34, nil, nil, nil, nil, 39,
- nil, 30, 30, nil, nil, nil, 40, nil, 40, nil,
- nil, nil, nil, nil, 39, nil, nil, 12, 2, 12,
- 43, nil, nil, nil, 39, nil, nil, nil, 39, 40,
- 34, nil, 29, nil, nil, 86, nil, nil, nil, nil,
- 12, nil, nil, nil, nil, 40, nil, nil, 3, 40,
- nil, nil, nil, nil, 40, nil, 12, 43, 40, 5,
- nil, 34, nil, 86, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, 86, nil, nil, 40,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 35, 86, nil, nil, nil,
- nil, nil, nil, 40, nil, nil, 39, nil, 86, nil,
- 29, nil, nil, nil, nil, nil, nil, nil, nil, 7,
- nil, nil, 7, 4, nil, nil, 4, nil, nil, nil,
- nil, 35, nil, nil, nil, nil, 40, 39, nil, nil,
- 39, 29, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 40, 40, 40,
- 40, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 40 ]
-
-racc_goto_pointer = [
- nil, 56, 10, 3, 4, -89, 3, 0, nil, nil,
- nil, nil, 11, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 2, 4, -26,
- -18, -199, nil, nil, -92, -40, -265, -82, -136, -30,
- 0, nil, -306, 12, -236, -135, -194, -203, -116, -153,
- -158, -154, -243, nil, nil, -232, -274, -275, -275, -275,
- -297, -289, -10, 31, nil, nil, nil, -7, 35, nil,
- nil, 6, nil, 2, nil, -253, 3, 4, 8, 9,
- 13, 14, 15, 16, -52, -28, -57, -62, -178, -224,
- -237, nil, nil, -271, -300 ]
-
-racc_goto_default = [
- nil, nil, nil, 3, nil, nil, nil, 4, 5, 6,
- 7, 8, 87, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, nil, 55, nil,
- nil, nil, 278, 279, 124, 54, 52, nil, 154, 89,
- 91, 157, 51, 92, 49, nil, nil, 80, nil, nil,
- nil, nil, nil, 48, 50, nil, nil, nil, nil, nil,
- nil, nil, nil, 56, 57, 99, 58, 100, 59, 84,
- 85, 86, 134, 90, 93, 95, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, 318, nil, nil,
- 345, 319, 320, nil, nil ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 86, :_reduce_1,
- 0, 86, :_reduce_none,
- 2, 87, :_reduce_3,
- 3, 87, :_reduce_4,
- 2, 90, :_reduce_5,
- 1, 91, :_reduce_none,
- 0, 91, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_none,
- 1, 88, :_reduce_28,
- 1, 88, :_reduce_29,
- 1, 111, :_reduce_30,
- 3, 110, :_reduce_31,
- 1, 112, :_reduce_none,
- 1, 112, :_reduce_none,
- 2, 109, :_reduce_34,
- 2, 107, :_reduce_35,
- 2, 106, :_reduce_36,
- 6, 104, :_reduce_37,
- 4, 104, :_reduce_38,
- 6, 104, :_reduce_39,
- 8, 104, :_reduce_40,
- 1, 116, :_reduce_none,
- 1, 116, :_reduce_none,
- 5, 117, :_reduce_43,
- 7, 118, :_reduce_44,
- 1, 120, :_reduce_45,
- 2, 102, :_reduce_46,
- 2, 103, :_reduce_47,
- 4, 121, :_reduce_48,
- 5, 121, :_reduce_49,
- 1, 122, :_reduce_50,
- 3, 122, :_reduce_51,
- 0, 122, :_reduce_52,
- 1, 123, :_reduce_none,
- 1, 123, :_reduce_none,
- 1, 123, :_reduce_none,
- 1, 123, :_reduce_none,
- 1, 126, :_reduce_57,
- 2, 127, :_reduce_58,
- 4, 127, :_reduce_59,
- 8, 127, :_reduce_60,
- 1, 113, :_reduce_none,
- 1, 113, :_reduce_none,
- 2, 129, :_reduce_63,
- 5, 98, :_reduce_64,
- 5, 98, :_reduce_65,
- 10, 100, :_reduce_66,
- 4, 101, :_reduce_67,
- 1, 131, :_reduce_none,
- 1, 131, :_reduce_none,
- 4, 94, :_reduce_70,
- 6, 105, :_reduce_71,
- 1, 133, :_reduce_72,
- 2, 133, :_reduce_73,
- 5, 135, :_reduce_74,
- 1, 136, :_reduce_none,
- 1, 136, :_reduce_none,
- 4, 134, :_reduce_77,
- 0, 134, :_reduce_none,
- 1, 137, :_reduce_none,
- 1, 137, :_reduce_none,
- 1, 99, :_reduce_none,
- 3, 99, :_reduce_82,
- 3, 99, :_reduce_83,
- 1, 138, :_reduce_none,
- 1, 138, :_reduce_none,
- 1, 138, :_reduce_none,
- 1, 138, :_reduce_none,
- 2, 130, :_reduce_88,
- 0, 130, :_reduce_89,
- 8, 95, :_reduce_90,
- 1, 140, :_reduce_91,
- 2, 140, :_reduce_92,
- 6, 141, :_reduce_93,
- 6, 141, :_reduce_94,
- 6, 141, :_reduce_95,
- 8, 141, :_reduce_96,
- 7, 141, :_reduce_97,
- 1, 143, :_reduce_none,
- 1, 143, :_reduce_none,
- 2, 143, :_reduce_100,
- 2, 146, :_reduce_101,
- 0, 146, :_reduce_none,
- 1, 114, :_reduce_none,
- 1, 114, :_reduce_none,
- 1, 145, :_reduce_none,
- 1, 145, :_reduce_none,
- 1, 144, :_reduce_none,
- 1, 144, :_reduce_none,
- 3, 142, :_reduce_109,
- 1, 142, :_reduce_110,
- 1, 96, :_reduce_111,
- 3, 93, :_reduce_112,
- 3, 139, :_reduce_113,
- 4, 139, :_reduce_114,
- 4, 139, :_reduce_115,
- 1, 125, :_reduce_none,
- 1, 125, :_reduce_none,
- 1, 148, :_reduce_118,
- 2, 148, :_reduce_119,
- 2, 149, :_reduce_120,
- 1, 150, :_reduce_121,
- 2, 150, :_reduce_122,
- 3, 152, :_reduce_123,
- 6, 152, :_reduce_124,
- 1, 151, :_reduce_125,
- 2, 151, :_reduce_126,
- 3, 153, :_reduce_127,
- 1, 115, :_reduce_none,
- 1, 115, :_reduce_none,
- 1, 154, :_reduce_130,
- 1, 154, :_reduce_none,
- 2, 154, :_reduce_132,
- 3, 155, :_reduce_133,
- 1, 157, :_reduce_134,
- 1, 157, :_reduce_135,
- 1, 157, :_reduce_136,
- 1, 157, :_reduce_137,
- 1, 157, :_reduce_138,
- 1, 157, :_reduce_139,
- 1, 157, :_reduce_140,
- 1, 157, :_reduce_141,
- 1, 157, :_reduce_142,
- 1, 157, :_reduce_143,
- 1, 157, :_reduce_144,
- 1, 157, :_reduce_145,
- 1, 157, :_reduce_146,
- 1, 157, :_reduce_147,
- 1, 156, :_reduce_none,
- 1, 156, :_reduce_none,
- 1, 156, :_reduce_none,
- 1, 156, :_reduce_none,
- 1, 156, :_reduce_none,
- 3, 159, :_reduce_153,
- 6, 128, :_reduce_154,
- 2, 158, :_reduce_155,
- 2, 158, :_reduce_156,
- 1, 160, :_reduce_157,
- 1, 124, :_reduce_none,
- 1, 124, :_reduce_159,
- 1, 132, :_reduce_160,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 1, 147, :_reduce_none,
- 4, 170, :_reduce_173,
- 4, 169, :_reduce_174,
- 4, 168, :_reduce_175,
- 4, 167, :_reduce_176,
- 4, 166, :_reduce_177,
- 4, 165, :_reduce_178,
- 4, 161, :_reduce_179,
- 4, 164, :_reduce_180,
- 4, 162, :_reduce_181,
- 4, 163, :_reduce_182,
- 1, 97, :_reduce_183,
- 1, 92, :_reduce_184,
- 1, 89, :_reduce_185,
- 2, 89, :_reduce_186,
- 1, 89, :_reduce_none,
- 0, 89, :_reduce_none,
- 1, 119, :_reduce_189,
- 0, 119, :_reduce_none,
- 5, 108, :_reduce_191,
- 1, 171, :_reduce_none,
- 5, 172, :_reduce_193,
- 3, 172, :_reduce_194,
- 1, 173, :_reduce_195,
- 4, 173, :_reduce_196,
- 3, 174, :_reduce_197,
- 1, 175, :_reduce_none,
- 1, 175, :_reduce_none,
- 1, 175, :_reduce_none,
- 2, 175, :_reduce_201,
- 2, 175, :_reduce_202,
- 1, 175, :_reduce_203,
- 1, 177, :_reduce_none,
- 0, 177, :_reduce_none,
- 5, 176, :_reduce_206,
- 1, 178, :_reduce_207,
- 4, 178, :_reduce_208,
- 1, 179, :_reduce_none ]
-
-racc_reduce_n = 210
-
-racc_shift_n = 393
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :ASSIGN => 2,
- :AT_SYM => 3,
- :COMMENT => 4,
- :JUMP => 5,
- :IO_METHOD => 6,
- :INPUT => 7,
- :OUTPUT => 8,
- :NUMREG => 9,
- :POSREG => 10,
- :VREG => 11,
- :SREG => 12,
- :TIME_SEGMENT => 13,
- :ARG => 14,
- :UALM => 15,
- :MOVE => 16,
- :DOT => 17,
- :TO => 18,
- :AT => 19,
- :TERM => 20,
- :OFFSET => 21,
- :SKIP => 22,
- :GROUP => 23,
- :SEMICOLON => 24,
- :NEWLINE => 25,
- :STRING => 26,
- :REAL => 27,
- :DIGIT => 28,
- :WORD => 29,
- :EQUAL => 30,
- :EEQUAL => 31,
- :NOTEQUAL => 32,
- :GTE => 33,
- :LTE => 34,
- :LT => 35,
- :GT => 36,
- :BANG => 37,
- :PLUS => 38,
- :MINUS => 39,
- :STAR => 40,
- :SLASH => 41,
- :DIV => 42,
- :AND => 43,
- :OR => 44,
- :MOD => 45,
- :IF => 46,
- :ELSE => 47,
- :END => 48,
- :UNLESS => 49,
- :FOR => 50,
- :IN => 51,
- :WHILE => 52,
- :WAIT_FOR => 53,
- :WAIT_UNTIL => 54,
- :TIMEOUT => 55,
- :AFTER => 56,
- :FANUC_USE => 57,
- :SET_SKIP_CONDITION => 58,
- :NAMESPACE => 59,
- :CASE => 60,
- :WHEN => 61,
- :INDIRECT => 62,
- :POSITION => 63,
- :EVAL => 64,
- :TIMER => 65,
- :TIMER_METHOD => 66,
- :RAISE => 67,
- :ABORT => 68,
- :POSITION_DATA => 69,
- :TRUE_FALSE => 70,
- :RUN => 71,
- :TP_HEADER => 72,
- :PAUSE => 73,
- :LPAREN => 74,
- :RPAREN => 75,
- :COLON => 76,
- :COMMA => 77,
- :LBRACK => 78,
- :RBRACK => 79,
- :LBRACE => 80,
- :RBRACE => 81,
- :LABEL => 82,
- :ADDRESS => 83,
- :false => 84 }
-
-racc_nt_base = 85
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "ASSIGN",
- "AT_SYM",
- "COMMENT",
- "JUMP",
- "IO_METHOD",
- "INPUT",
- "OUTPUT",
- "NUMREG",
- "POSREG",
- "VREG",
- "SREG",
- "TIME_SEGMENT",
- "ARG",
- "UALM",
- "MOVE",
- "DOT",
- "TO",
- "AT",
- "TERM",
- "OFFSET",
- "SKIP",
- "GROUP",
- "SEMICOLON",
- "NEWLINE",
- "STRING",
- "REAL",
- "DIGIT",
- "WORD",
- "EQUAL",
- "EEQUAL",
- "NOTEQUAL",
- "GTE",
- "LTE",
- "LT",
- "GT",
- "BANG",
- "PLUS",
- "MINUS",
- "STAR",
- "SLASH",
- "DIV",
- "AND",
- "OR",
- "MOD",
- "IF",
- "ELSE",
- "END",
- "UNLESS",
- "FOR",
- "IN",
- "WHILE",
- "WAIT_FOR",
- "WAIT_UNTIL",
- "TIMEOUT",
- "AFTER",
- "FANUC_USE",
- "SET_SKIP_CONDITION",
- "NAMESPACE",
- "CASE",
- "WHEN",
- "INDIRECT",
- "POSITION",
- "EVAL",
- "TIMER",
- "TIMER_METHOD",
- "RAISE",
- "ABORT",
- "POSITION_DATA",
- "TRUE_FALSE",
- "RUN",
- "TP_HEADER",
- "PAUSE",
- "LPAREN",
- "RPAREN",
- "COLON",
- "COMMA",
- "LBRACK",
- "RBRACK",
- "LBRACE",
- "RBRACE",
- "LABEL",
- "ADDRESS",
- "false",
- "$start",
- "program",
- "statements",
- "statement",
- "terminator",
- "block",
- "optional_newline",
- "comment",
- "definition",
- "namespace",
- "motion_statement",
- "label_definition",
- "address",
- "conditional",
- "inline_conditional",
- "forloop",
- "while_loop",
- "use_statement",
- "set_skip_statement",
- "wait_statement",
- "case_statement",
- "fanuc_eval",
- "timer_method",
- "position_data",
- "raise",
- "tp_header_definition",
- "empty_stmt",
- "tp_header_value",
- "var_or_indirect",
- "indirectable",
- "expression",
- "wait_modifier",
- "timeout_modifier",
- "after_modifier",
- "swallow_newlines",
- "label",
- "program_call",
- "args",
- "arg",
- "number",
- "var",
- "string",
- "io_method",
- "indirect_thing",
- "jump",
- "else_block",
- "minmax_val",
- "integer",
- "case_conditions",
- "case_else",
- "case_condition",
- "case_allowed_condition",
- "case_allowed_statement",
- "inlineable",
- "assignment",
- "motion_modifiers",
- "motion_modifier",
- "speed",
- "valid_terminations",
- "time",
- "time_seg_actions",
- "optional_lpos_arg",
- "definable",
- "var_without_namespaces",
- "var_with_namespaces",
- "var_method_modifiers",
- "namespaces",
- "var_method_modifier",
- "ns",
- "unary_expression",
- "binary_expression",
- "factor",
- "operator",
- "signed_number",
- "paren_expr",
- "sign",
- "numreg",
- "output",
- "input",
- "posreg",
- "position",
- "vreg",
- "argument",
- "timer",
- "ualm",
- "sreg",
- "sn",
- "hash",
- "hash_attributes",
- "hash_attribute",
- "hash_value",
- "array",
- "optional_sign",
- "array_values",
- "array_value" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 35)
- def _reduce_1(val, _values, result)
- @interpreter.nodes = val[0]
- result
- end
-.,.,
-
-# reduce 2 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 42)
- def _reduce_3(val, _values, result)
- result = [val[0]]
- result << val[1] unless val[1].nil?
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 46)
- def _reduce_4(val, _values, result)
- result = val[0] << val[1]
- result << val[2] unless val[2].nil?
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 52)
- def _reduce_5(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 6 omitted
-
-# reduce 7 omitted
-
-# reduce 8 omitted
-
-# reduce 9 omitted
-
-# reduce 10 omitted
-
-# reduce 11 omitted
-
-# reduce 12 omitted
-
-# reduce 13 omitted
-
-# reduce 14 omitted
-
-# reduce 15 omitted
-
-# reduce 16 omitted
-
-# reduce 17 omitted
-
-# reduce 18 omitted
-
-# reduce 19 omitted
-
-# reduce 20 omitted
-
-# reduce 21 omitted
-
-# reduce 22 omitted
-
-# reduce 23 omitted
-
-# reduce 24 omitted
-
-# reduce 25 omitted
-
-# reduce 26 omitted
-
-# reduce 27 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 85)
- def _reduce_28(val, _values, result)
- result = PauseNode.new
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 86)
- def _reduce_29(val, _values, result)
- result = AbortNode.new
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 90)
- def _reduce_30(val, _values, result)
- result = EmptyStmtNode.new()
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 94)
- def _reduce_31(val, _values, result)
- result = HeaderNode.new(val[0],val[2])
- result
- end
-.,.,
-
-# reduce 32 omitted
-
-# reduce 33 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 103)
- def _reduce_34(val, _values, result)
- result = RaiseNode.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 107)
- def _reduce_35(val, _values, result)
- result = TimerMethodNode.new(val[0],val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 111)
- def _reduce_36(val, _values, result)
- result = EvalNode.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 116)
- def _reduce_37(val, _values, result)
- result = WaitForNode.new(val[2], val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 118)
- def _reduce_38(val, _values, result)
- result = WaitUntilNode.new(val[2], nil)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 120)
- def _reduce_39(val, _values, result)
- result = WaitUntilNode.new(val[2],val[5])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 122)
- def _reduce_40(val, _values, result)
- result = WaitUntilNode.new(val[2],val[5].merge(val[7]))
- result
- end
-.,.,
-
-# reduce 41 omitted
-
-# reduce 42 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 132)
- def _reduce_43(val, _values, result)
- result = { label: val[3] }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 137)
- def _reduce_44(val, _values, result)
- result = { timeout: [val[3],val[5]] }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 141)
- def _reduce_45(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 145)
- def _reduce_46(val, _values, result)
- result = UseNode.new(val[0],val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 150)
- def _reduce_47(val, _values, result)
- result = SetSkipNode.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 154)
- def _reduce_48(val, _values, result)
- result = CallNode.new(val[0],val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 155)
- def _reduce_49(val, _values, result)
- result = CallNode.new(val[1],val[3],async: true)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 159)
- def _reduce_50(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 160)
- def _reduce_51(val, _values, result)
- result = val[0] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 161)
- def _reduce_52(val, _values, result)
- result = []
- result
- end
-.,.,
-
-# reduce 53 omitted
-
-# reduce 54 omitted
-
-# reduce 55 omitted
-
-# reduce 56 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 172)
- def _reduce_57(val, _values, result)
- result = StringNode.new(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 176)
- def _reduce_58(val, _values, result)
- result = IOMethodNode.new(val[0],val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 178)
- def _reduce_59(val, _values, result)
- result = IOMethodNode.new(val[0],val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 180)
- def _reduce_60(val, _values, result)
- result = IOMethodNode.new(val[0],val[2],{ pulse_time: val[4], pulse_units: val[6] })
- result
- end
-.,.,
-
-# reduce 61 omitted
-
-# reduce 62 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 190)
- def _reduce_63(val, _values, result)
- result = JumpNode.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 195)
- def _reduce_64(val, _values, result)
- result = ConditionalNode.new("if",val[1],val[2],val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 197)
- def _reduce_65(val, _values, result)
- result = ConditionalNode.new("unless",val[1],val[2],val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 202)
- def _reduce_66(val, _values, result)
- result = ForNode.new(val[1],val[4],val[6],val[8])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 206)
- def _reduce_67(val, _values, result)
- result = WhileNode.new(val[1],val[2])
- result
- end
-.,.,
-
-# reduce 68 omitted
-
-# reduce 69 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 215)
- def _reduce_70(val, _values, result)
- result = NamespaceNode.new(val[1],val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 222)
- def _reduce_71(val, _values, result)
- result = CaseNode.new(val[1],val[3],val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 226)
- def _reduce_72(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 228)
- def _reduce_73(val, _values, result)
- result = val[0] << val[1] << val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 233)
- def _reduce_74(val, _values, result)
- result = CaseConditionNode.new(val[1],val[3])
- result
- end
-.,.,
-
-# reduce 75 omitted
-
-# reduce 76 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 243)
- def _reduce_77(val, _values, result)
- result = CaseConditionNode.new(nil,val[2])
- result
- end
-.,.,
-
-# reduce 78 omitted
-
-# reduce 79 omitted
-
-# reduce 80 omitted
-
-# reduce 81 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 254)
- def _reduce_82(val, _values, result)
- result = InlineConditionalNode.new(val[1], val[2], val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 255)
- def _reduce_83(val, _values, result)
- result = InlineConditionalNode.new(val[1], val[2], val[0])
- result
- end
-.,.,
-
-# reduce 84 omitted
-
-# reduce 85 omitted
-
-# reduce 86 omitted
-
-# reduce 87 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 266)
- def _reduce_88(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 267)
- def _reduce_89(val, _values, result)
- result = []
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 272)
- def _reduce_90(val, _values, result)
- result = MotionNode.new(val[0],val[5],val[7])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 276)
- def _reduce_91(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 278)
- def _reduce_92(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 283)
- def _reduce_93(val, _values, result)
- result = SpeedNode.new(val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 285)
- def _reduce_94(val, _values, result)
- result = TerminationNode.new(val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 287)
- def _reduce_95(val, _values, result)
- result = OffsetNode.new(val[2],val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 289)
- def _reduce_96(val, _values, result)
- result = TimeNode.new(val[2],val[4],val[6])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 291)
- def _reduce_97(val, _values, result)
- result = SkipNode.new(val[4],val[5])
- result
- end
-.,.,
-
-# reduce 98 omitted
-
-# reduce 99 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 298)
- def _reduce_100(val, _values, result)
- raise Racc::ParseError, sprintf("\ninvalid termination type: (%s)", val[1]) if val[1] != 1
-
- result = DigitNode.new(val[1].to_i * -1)
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 305)
- def _reduce_101(val, _values, result)
- result = val[1]
- result
- end
-.,.,
-
-# reduce 102 omitted
-
-# reduce 103 omitted
-
-# reduce 104 omitted
-
-# reduce 105 omitted
-
-# reduce 106 omitted
-
-# reduce 107 omitted
-
-# reduce 108 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 325)
- def _reduce_109(val, _values, result)
- result = { speed: val[0], units: val[2] }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 326)
- def _reduce_110(val, _values, result)
- result = { speed: val[0], units: nil }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 330)
- def _reduce_111(val, _values, result)
- result = LabelDefinitionNode.new(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 334)
- def _reduce_112(val, _values, result)
- result = DefinitionNode.new(val[0],val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 338)
- def _reduce_113(val, _values, result)
- result = AssignmentNode.new(val[0],val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 339)
- def _reduce_114(val, _values, result)
- result = AssignmentNode.new(
- val[0],
- ExpressionNode.new(val[0],"+",val[3])
- )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 344)
- def _reduce_115(val, _values, result)
- result = AssignmentNode.new(
- val[0],
- ExpressionNode.new(val[0],"-",val[3])
- )
-
- result
- end
-.,.,
-
-# reduce 116 omitted
-
-# reduce 117 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 357)
- def _reduce_118(val, _values, result)
- result = VarNode.new(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 358)
- def _reduce_119(val, _values, result)
- result = VarMethodNode.new(val[0],val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 363)
- def _reduce_120(val, _values, result)
- result = NamespacedVarNode.new(val[0],val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 367)
- def _reduce_121(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 369)
- def _reduce_122(val, _values, result)
- result = val[0].merge(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 373)
- def _reduce_123(val, _values, result)
- result = { method: val[2] }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 375)
- def _reduce_124(val, _values, result)
- result = { group: val[4] }
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 379)
- def _reduce_125(val, _values, result)
- result = [val[0]]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 380)
- def _reduce_126(val, _values, result)
- result = val[0] << val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 384)
- def _reduce_127(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-# reduce 128 omitted
-
-# reduce 129 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 394)
- def _reduce_130(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-# reduce 131 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 396)
- def _reduce_132(val, _values, result)
- result = ExpressionNode.new(val[1], "!", nil)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 401)
- def _reduce_133(val, _values, result)
- result = ExpressionNode.new(val[0], val[1], val[2])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 405)
- def _reduce_134(val, _values, result)
- result = "=="
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 406)
- def _reduce_135(val, _values, result)
- result = "<>"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 407)
- def _reduce_136(val, _values, result)
- result = "<"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 408)
- def _reduce_137(val, _values, result)
- result = ">"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 409)
- def _reduce_138(val, _values, result)
- result = ">="
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 410)
- def _reduce_139(val, _values, result)
- result = "<="
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 411)
- def _reduce_140(val, _values, result)
- result = "+"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 412)
- def _reduce_141(val, _values, result)
- result = "-"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 413)
- def _reduce_142(val, _values, result)
- result = "||"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 414)
- def _reduce_143(val, _values, result)
- result = "*"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 415)
- def _reduce_144(val, _values, result)
- result = "/"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 416)
- def _reduce_145(val, _values, result)
- result = "DIV"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 417)
- def _reduce_146(val, _values, result)
- result = "%"
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 418)
- def _reduce_147(val, _values, result)
- result = "&&"
- result
- end
-.,.,
-
-# reduce 148 omitted
-
-# reduce 149 omitted
-
-# reduce 150 omitted
-
-# reduce 151 omitted
-
-# reduce 152 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 430)
- def _reduce_153(val, _values, result)
- result = ParenExpressionNode.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 435)
- def _reduce_154(val, _values, result)
- result = IndirectNode.new(val[2].to_sym, val[4])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 440)
- def _reduce_155(val, _values, result)
- val[1] = val[1].to_i * -1 if val[0] == "-"
- result = DigitNode.new(val[1])
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 443)
- def _reduce_156(val, _values, result)
- val[1] = val[1].to_f * -1 if val[0] == "-"; result = RealNode.new(val[1])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 447)
- def _reduce_157(val, _values, result)
- result = "-"
- result
- end
-.,.,
-
-# reduce 158 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 452)
- def _reduce_159(val, _values, result)
- result = RealNode.new(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 456)
- def _reduce_160(val, _values, result)
- result = DigitNode.new(val[0])
- result
- end
-.,.,
-
-# reduce 161 omitted
-
-# reduce 162 omitted
-
-# reduce 163 omitted
-
-# reduce 164 omitted
-
-# reduce 165 omitted
-
-# reduce 166 omitted
-
-# reduce 167 omitted
-
-# reduce 168 omitted
-
-# reduce 169 omitted
-
-# reduce 170 omitted
-
-# reduce 171 omitted
-
-# reduce 172 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 476)
- def _reduce_173(val, _values, result)
- result = StringRegisterNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 480)
- def _reduce_174(val, _values, result)
- result = UserAlarmNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 484)
- def _reduce_175(val, _values, result)
- result = TimerNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 488)
- def _reduce_176(val, _values, result)
- result = ArgumentNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 492)
- def _reduce_177(val, _values, result)
- result = VisionRegisterNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 496)
- def _reduce_178(val, _values, result)
- result = PositionNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 500)
- def _reduce_179(val, _values, result)
- result = NumregNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 504)
- def _reduce_180(val, _values, result)
- result = PosregNode.new(val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 508)
- def _reduce_181(val, _values, result)
- result = IONode.new(val[0], val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 512)
- def _reduce_182(val, _values, result)
- result = IONode.new(val[0], val[2].to_i)
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 516)
- def _reduce_183(val, _values, result)
- result = AddressNode.new(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 520)
- def _reduce_184(val, _values, result)
- result = CommentNode.new(val[0])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 524)
- def _reduce_185(val, _values, result)
- result = TerminatorNode.new
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 525)
- def _reduce_186(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-# reduce 187 omitted
-
-# reduce 188 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 532)
- def _reduce_189(val, _values, result)
- result = TerminatorNode.new
- result
- end
-.,.,
-
-# reduce 190 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 538)
- def _reduce_191(val, _values, result)
- result = PositionDataNode.new(val[2])
- result
- end
-.,.,
-
-# reduce 192 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 546)
- def _reduce_193(val, _values, result)
- result = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 547)
- def _reduce_194(val, _values, result)
- result = {}
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 551)
- def _reduce_195(val, _values, result)
- result = val[0]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 553)
- def _reduce_196(val, _values, result)
- result = val[0].merge(val[3])
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 557)
- def _reduce_197(val, _values, result)
- result = { val[0].to_sym => val[2] }
- result
- end
-.,.,
-
-# reduce 198 omitted
-
-# reduce 199 omitted
-
-# reduce 200 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 564)
- def _reduce_201(val, _values, result)
- val[1] = val[1].to_i * -1 if val[0] == "-"; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 565)
- def _reduce_202(val, _values, result)
- val[1] = val[1].to_f * -1 if val[0] == "-"; result = val[1]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 566)
- def _reduce_203(val, _values, result)
- result = val[0] == "true"
- result
- end
-.,.,
-
-# reduce 204 omitted
-
-# reduce 205 omitted
-
-module_eval(<<'.,.,', 'tp_plus.y', 575)
- def _reduce_206(val, _values, result)
- result = val[2]
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 579)
- def _reduce_207(val, _values, result)
- result = val
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'tp_plus.y', 580)
- def _reduce_208(val, _values, result)
- result = val[0] << val[3]
- result
- end
-.,.,
-
-# reduce 209 omitted
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module TPPlus
diff --git a/test/racc/regress/twowaysql b/test/racc/regress/twowaysql
deleted file mode 100644
index 868850b320..0000000000
--- a/test/racc/regress/twowaysql
+++ /dev/null
@@ -1,556 +0,0 @@
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.4.16
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-module TwoWaySQL
- class Parser < Racc::Parser
-
-module_eval(<<'...end twowaysql.y/module_eval...', 'twowaysql.y', 148)
-
-require 'strscan'
-
-def initialize(opts={})
- opts = {
- :debug => false,
- :preserve_space => true,
- :preserve_comment => false
- }.merge(opts)
- @yydebug = opts[:debug]
- @preserve_space = opts[:preserve_space]
- @preserve_comment = opts[:preserve_comment]
- @num_questions = 0
-end
-
-
-PAREN_EXAMPLE = '\([^\)]+\)'
-BEGIN_BIND_VARIABLE = '(\/|\#)\*([^\*]+)\*\1'
-BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*/
-PAREN_BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*#{PAREN_EXAMPLE}/
-EMBED_VARIABLE_PATTERN = /\A(\/|\#)\*\$([^\*]+)\*\1\s*/
-
-CONDITIONAL_PATTERN = /\A(\/|\#)\*(IF)\s+([^\*]+)\s*\*\1/
-BEGIN_END_PATTERN = /\A(\/|\#)\*(BEGIN|END)\s*\*\1/
-STRING_LITERAL_PATTERN = /\A(\'(?:[^\']+|\'\')*\')/ ## quoted string
-SPLIT_TOKEN_PATTERN = /\A(\S+?)(?=\s*(?:(?:\/|\#)\*|-{2,}|\(|\)|\,))/ ## stop on delimiters --,/*,#*,',',(,)
-LITERAL_PATTERN = /\A([^;\s]+)/
-SPACES_PATTERN = /\A(\s+)/
-QUESTION_PATTERN = /\A\?/
-COMMA_PATTERN = /\A\,/
-LPAREN_PATTERN = /\A\(/
-RPAREN_PATTERN = /\A\)/
-ACTUAL_COMMENT_PATTERN = /\A(\/|\#)\*(\s{1,}(?:.*?))\*\1/m ## start with spaces
-SEMICOLON_AT_INPUT_END_PATTERN = /\A\;\s*\Z/
-UNMATCHED_COMMENT_START_PATTERN = /\A(?:(?:\/|\#)\*)/
-
-#TODO: remove trailing spaces for S2Dao compatibility, but this spec sometimes causes SQL bugs...
-ELSE_PATTERN = /\A\-{2,}\s*ELSE\s*/
-AND_PATTERN = /\A(\ *AND)\b/i
-OR_PATTERN = /\A(\ *OR)\b/i
-
-
-def parse( io )
- @q = []
- io.each_line(nil) do |whole|
- @s = StringScanner.new(whole)
- end
- scan_str
-
- # @q.push [ false, nil ]
- @q.push [ false, [@s.pos, nil] ]
-
- ## call racc's private parse method
- do_parse
-end
-
-
-## called by racc
-def next_token
- @q.shift
-end
-
-
-def scan_str
- until @s.eos? do
- case
- when @s.scan(AND_PATTERN)
- @q.push [ :AND, [@s.pos, @s[1]] ]
- when @s.scan(OR_PATTERN)
- @q.push [ :OR, [@s.pos, @s[1]] ]
- when @s.scan(SPACES_PATTERN)
- @q.push [ :SPACES, [@s.pos, @s[1]] ]
- when @s.scan(QUESTION_PATTERN)
- @q.push [ :QUESTION, [@s.pos, nil] ]
- when @s.scan(COMMA_PATTERN)
- @q.push [ :COMMA, [@s.pos, ','] ]
- when @s.scan(LPAREN_PATTERN)
- @q.push [ :LPAREN, [@s.pos, '('] ]
- when @s.scan(RPAREN_PATTERN)
- @q.push [ :RPAREN, [@s.pos, ')'] ]
- when @s.scan(ELSE_PATTERN)
- @q.push [ :ELSE, [@s.pos, nil] ]
- when @s.scan(ACTUAL_COMMENT_PATTERN)
- @q.push [ :ACTUAL_COMMENT, [@s.pos, @s[1], @s[2]] ] if @preserve_comment
- when @s.scan(BEGIN_END_PATTERN)
- @q.push [ @s[2].intern, [@s.pos, nil] ]
- when @s.scan(CONDITIONAL_PATTERN)
- @q.push [ @s[2].intern, [@s.pos, @s[3]] ]
- when @s.scan(EMBED_VARIABLE_PATTERN)
- @q.push [ :EMBED_VARIABLE, [@s.pos, @s[2]] ]
- when @s.scan(PAREN_BIND_VARIABLE_PATTERN)
- @q.push [ :PAREN_BIND_VARIABLE, [@s.pos, @s[2]] ]
- when @s.scan(BIND_VARIABLE_PATTERN)
- @q.push [ :BIND_VARIABLE, [@s.pos, @s[2]] ]
- when @s.scan(STRING_LITERAL_PATTERN)
- @q.push [ :STRING_LITERAL, [@s.pos, @s[1]] ]
- when @s.scan(SPLIT_TOKEN_PATTERN)
- @q.push [ :IDENT, [@s.pos, @s[1]] ]
- when @s.scan(UNMATCHED_COMMENT_START_PATTERN) ## unmatched comment start, '/*','#*'
- raise Racc::ParseError, "unmatched comment. line:[#{line_no(@s.pos)}], str:[#{@s.rest}]"
- when @s.scan(LITERAL_PATTERN) ## other string token
- @q.push [ :IDENT, [@s.pos, @s[1]] ]
- when @s.scan(SEMICOLON_AT_INPUT_END_PATTERN)
- #drop semicolon at input end
- else
- raise Racc::ParseError, "syntax error at or near line:[#{line_no(@s.pos)}], str:[#{@s.rest}]"
- end
- end
-end
-
-
-## override racc's default on_error method
-def on_error(t, v, vstack)
- ## cursor in value-stack is an array of two items,
- ## that have position value as 0th item. like [731, "ctx[:limit] "]
- cursor = vstack.find do |tokens|
- tokens.size == 2 and tokens[0].kind_of?(Fixnum)
- end
- pos = cursor[0]
- line = line_no(pos)
- rest = @s.string[pos .. -1]
- raise Racc::ParseError, "syntax error at or near line:[#{line}], str:[#{rest}]"
-end
-
-
-def line_no(pos)
- lines = 0
- scanned = @s.string[0..(pos)]
- scanned.each_line { lines += 1 }
- lines
-end
-...end twowaysql.y/module_eval...
-##### State transition tables begin ###
-
-racc_action_table = [
- 8, 36, 9, 37, 12, 13, 10, 11, 14, 15,
- 16, 17, 18, 19, 22, 23, 24, 8, 3, 9,
- 25, 12, 13, 10, 11, 14, 15, 16, 17, 18,
- 19, 22, 23, 24, 8, 38, 9, 46, 12, 13,
- 10, 11, 14, 15, 16, 17, 18, 19, 22, 23,
- 24, 8, 40, 9, 45, 12, 13, 10, 11, 14,
- 15, 16, 17, 18, 19, 22, 23, 24, 8, nil,
- 9, nil, 12, 13, 10, 11, 14, 15, 16, 17,
- 18, 19, 22, 23, 24, 35, 33, 34, 44, 43,
- 31, 32, 31, 32 ]
-
-racc_action_check = [
- 42, 24, 42, 24, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 42, 2, 1, 2,
- 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 26, 26, 26, 39, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 27, 28, 27, 37, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 41, nil,
- 41, nil, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 22, 22, 22, 34, 34,
- 9, 9, 40, 40 ]
-
-racc_action_pointer = [
- nil, 18, 15, 20, nil, nil, nil, nil, nil, 84,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 77, nil, -7, nil, 32, 49, 47, nil,
- nil, nil, nil, nil, 80, nil, nil, 46, nil, 34,
- 86, 66, -2, nil, nil, nil, nil, nil ]
-
-racc_action_default = [
- -2, -35, -1, -35, -3, -4, -5, -6, -2, -2,
- -16, -17, -18, -19, -20, -21, -22, -23, -24, -25,
- -26, -27, -35, -32, -35, 48, -35, -13, -10, -11,
- -12, -2, -2, -28, -35, -30, -33, -35, -7, -35,
- -2, -14, -15, -29, -31, -34, -8, -9 ]
-
-racc_goto_table = [
- 2, 1, 28, 39, nil, nil, nil, nil, 26, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 41, 42, 47 ]
-
-racc_goto_check = [
- 2, 1, 7, 8, nil, nil, nil, nil, 2, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, 2, 2, 7 ]
-
-racc_goto_pointer = [
- nil, 1, 0, nil, nil, nil, nil, -7, -25, nil,
- nil, nil, nil ]
-
-racc_goto_default = [
- nil, nil, 27, 4, 5, 6, 7, nil, nil, 29,
- 30, 20, 21 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 20, :_reduce_1,
- 0, 21, :_reduce_2,
- 2, 21, :_reduce_3,
- 1, 22, :_reduce_none,
- 1, 22, :_reduce_none,
- 1, 22, :_reduce_none,
- 3, 25, :_reduce_7,
- 4, 24, :_reduce_8,
- 2, 27, :_reduce_9,
- 0, 27, :_reduce_10,
- 1, 26, :_reduce_none,
- 1, 26, :_reduce_none,
- 1, 26, :_reduce_none,
- 2, 28, :_reduce_14,
- 2, 29, :_reduce_15,
- 1, 23, :_reduce_16,
- 1, 23, :_reduce_17,
- 1, 23, :_reduce_18,
- 1, 23, :_reduce_19,
- 1, 23, :_reduce_20,
- 1, 23, :_reduce_21,
- 1, 23, :_reduce_22,
- 1, 23, :_reduce_23,
- 1, 23, :_reduce_24,
- 1, 23, :_reduce_25,
- 1, 23, :_reduce_none,
- 1, 23, :_reduce_none,
- 2, 30, :_reduce_28,
- 3, 30, :_reduce_29,
- 2, 30, :_reduce_30,
- 3, 30, :_reduce_31,
- 1, 30, :_reduce_32,
- 2, 31, :_reduce_33,
- 3, 31, :_reduce_34 ]
-
-racc_reduce_n = 35
-
-racc_shift_n = 48
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :BEGIN => 2,
- :END => 3,
- :IF => 4,
- :ELSE => 5,
- :AND => 6,
- :OR => 7,
- :IDENT => 8,
- :STRING_LITERAL => 9,
- :SPACES => 10,
- :COMMA => 11,
- :LPAREN => 12,
- :RPAREN => 13,
- :QUESTION => 14,
- :ACTUAL_COMMENT => 15,
- :BIND_VARIABLE => 16,
- :PAREN_BIND_VARIABLE => 17,
- :EMBED_VARIABLE => 18 }
-
-racc_nt_base = 19
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "BEGIN",
- "END",
- "IF",
- "ELSE",
- "AND",
- "OR",
- "IDENT",
- "STRING_LITERAL",
- "SPACES",
- "COMMA",
- "LPAREN",
- "RPAREN",
- "QUESTION",
- "ACTUAL_COMMENT",
- "BIND_VARIABLE",
- "PAREN_BIND_VARIABLE",
- "EMBED_VARIABLE",
- "$start",
- "sql",
- "stmt_list",
- "stmt",
- "primary",
- "if_stmt",
- "begin_stmt",
- "sub_stmt",
- "else_stmt",
- "and_stmt",
- "or_stmt",
- "bind_var",
- "embed_var" ]
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-module_eval(<<'.,.,', 'twowaysql.y', 20)
- def _reduce_1(val, _values, result)
- result = RootNode.new( val[0] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 25)
- def _reduce_2(val, _values, result)
- result = []
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 29)
- def _reduce_3(val, _values, result)
- result.push val[1]
-
- result
- end
-.,.,
-
-# reduce 4 omitted
-
-# reduce 5 omitted
-
-# reduce 6 omitted
-
-module_eval(<<'.,.,', 'twowaysql.y', 38)
- def _reduce_7(val, _values, result)
- result = BeginNode.new( val[1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 43)
- def _reduce_8(val, _values, result)
- result = IfNode.new( val[0][1], val[1], val[2] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 48)
- def _reduce_9(val, _values, result)
- result = val[1]
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 52)
- def _reduce_10(val, _values, result)
- result = nil
-
- result
- end
-.,.,
-
-# reduce 11 omitted
-
-# reduce 12 omitted
-
-# reduce 13 omitted
-
-module_eval(<<'.,.,', 'twowaysql.y', 61)
- def _reduce_14(val, _values, result)
- result = SubStatementNode.new( val[0][1], val[1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 66)
- def _reduce_15(val, _values, result)
- result = SubStatementNode.new( val[0][1], val[1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 71)
- def _reduce_16(val, _values, result)
- result = LiteralNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 75)
- def _reduce_17(val, _values, result)
- result = LiteralNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 79)
- def _reduce_18(val, _values, result)
- result = LiteralNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 83)
- def _reduce_19(val, _values, result)
- result = LiteralNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 87)
- def _reduce_20(val, _values, result)
- result = WhiteSpaceNode.new( val[0][1], @preserve_space )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 91)
- def _reduce_21(val, _values, result)
- result = LiteralNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 95)
- def _reduce_22(val, _values, result)
- result = LiteralNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 99)
- def _reduce_23(val, _values, result)
- result = LiteralNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 103)
- def _reduce_24(val, _values, result)
- @num_questions += 1
- result = QuestionNode.new( @num_questions )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 108)
- def _reduce_25(val, _values, result)
- result = ActualCommentNode.new( val[0][1] , val[0][2] )
-
- result
- end
-.,.,
-
-# reduce 26 omitted
-
-# reduce 27 omitted
-
-module_eval(<<'.,.,', 'twowaysql.y', 115)
- def _reduce_28(val, _values, result)
- result = BindVariableNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 119)
- def _reduce_29(val, _values, result)
- result = BindVariableNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 123)
- def _reduce_30(val, _values, result)
- result = BindVariableNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 127)
- def _reduce_31(val, _values, result)
- result = BindVariableNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 131)
- def _reduce_32(val, _values, result)
- result = ParenBindVariableNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 136)
- def _reduce_33(val, _values, result)
- result = EmbedVariableNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-module_eval(<<'.,.,', 'twowaysql.y', 140)
- def _reduce_34(val, _values, result)
- result = EmbedVariableNode.new( val[0][1] )
-
- result
- end
-.,.,
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
- end # class Parser
-end # module TwoWaySQL
diff --git a/test/racc/scandata/brace b/test/racc/scandata/brace
deleted file mode 100644
index f6c843853e..0000000000
--- a/test/racc/scandata/brace
+++ /dev/null
@@ -1,7 +0,0 @@
-{ {
- } { } {
- { { { } } }
- { { { {} } } }
- {} {} {}
- }
-}
diff --git a/test/racc/scandata/gvar b/test/racc/scandata/gvar
deleted file mode 100644
index 50528ce97b..0000000000
--- a/test/racc/scandata/gvar
+++ /dev/null
@@ -1 +0,0 @@
-{ $' $" $& $-a $/ $\ $( $1 $2 $3 $? $-i }
diff --git a/test/racc/scandata/normal b/test/racc/scandata/normal
deleted file mode 100644
index e705131536..0000000000
--- a/test/racc/scandata/normal
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- # comment
- result = "string".match(/regexp/)[0]
-}
diff --git a/test/racc/scandata/percent b/test/racc/scandata/percent
deleted file mode 100644
index fded9a385c..0000000000
--- a/test/racc/scandata/percent
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- 3 % 5 # mod
- 3%5 # mod
- 3% 5 # mod
- i % 5 # mod
- i%5 # mod
- i% 5 # mod
- call %{str} # string
- call(%{str}) # string
- %q{string} # string
- %Q{string} # string
- %r{string} # string
- %w(array) # array
- %x{array} # command string
- %{string} # string
- %_string_ # string
- %/string/ # regexp
-}
diff --git a/test/racc/scandata/slash b/test/racc/scandata/slash
deleted file mode 100644
index 190135b3bd..0000000000
--- a/test/racc/scandata/slash
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- # here's many '/'s
- i = 5/1 # div
- re = /regex/ # regexp
- i /= 5 # div
- result = 5 / 1 # div
- result = 5/ 1 # div
- call(/regex/) # regexp
- call /regex/ # regexp
-}
diff --git a/test/racc/src.intp b/test/racc/src.intp
deleted file mode 100644
index 4d2460e8ed..0000000000
--- a/test/racc/src.intp
+++ /dev/null
@@ -1,34 +0,0 @@
-def assert( no, cond )
- if cond then
- else
- raise( 'assert ' + to_s(no) + ' failed' )
- end
-end
-
-assert( 1, concat(concat(concat('str=', 'a'), "b"), 'c') == 'str=abc' )
-assert( 2, 'operator' + ' ok' == 'operator ok' )
-assert( 3, 1 + 1 == 2 )
-assert( 4, 4 * 1 + 10 * 1 == 14 )
-
-if true then
- assert( 5, true )
-else
- assert( 6, false )
-end
-
-i = 1
-while i == 1 do
- i = false
-end
-assert( 7, i == false )
-assert( 8, nil == nil )
-
-def func
- assert( 9, true )
-end
-func
-
-def argfunc( str )
- assert( 10, str == 'ok' )
-end
-argfunc 'ok'
diff --git a/test/racc/start.y b/test/racc/start.y
deleted file mode 100644
index 86296899b8..0000000000
--- a/test/racc/start.y
+++ /dev/null
@@ -1,20 +0,0 @@
-class S
-
-start st
-
-rule
-
-n: D { result = 'no' }
-st : A B C n { result = 'ok' }
-
-end
-
----- inner
-
- def parse
- do_parse
- end
-
----- footer
-
-S.new.parse == 'ok' or raise 'start stmt not worked'
diff --git a/test/racc/test_chk_y.rb b/test/racc/test_chk_y.rb
deleted file mode 100644
index bb8b6b4fe3..0000000000
--- a/test/racc/test_chk_y.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
-
-module Racc
- class TestChkY < TestCase
- def setup
- super
- file = File.join(ASSET_DIR, 'chk.y')
- @debug_flags = Racc::DebugFlags.parse_option_string('o')
- parser = Racc::GrammarFileParser.new(@debug_flags)
- @result = parser.parse(File.read(file), File.basename(file))
- @states = Racc::States.new(@result.grammar).nfa
- @states.dfa
- end
-
- def test_compile_chk_y
- generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
-
- # it generates valid ruby
- assert Module.new {
- self.instance_eval(generator.generate_parser, __FILE__, __LINE__)
- }
-
- grammar = @states.grammar
-
- assert_equal 0, @states.n_srconflicts
- assert_equal 0, @states.n_rrconflicts
- assert_equal 0, grammar.n_useless_nonterminals
- assert_equal 0, grammar.n_useless_rules
- assert_nil grammar.n_expected_srconflicts
- end
-
- def test_compile_chk_y_line_convert
- params = @result.params.dup
- params.convert_line_all = true
-
- generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
-
- # it generates valid ruby
- assert Module.new {
- self.instance_eval(generator.generate_parser, __FILE__, __LINE__)
- }
-
- grammar = @states.grammar
-
- assert_equal 0, @states.n_srconflicts
- assert_equal 0, @states.n_rrconflicts
- assert_equal 0, grammar.n_useless_nonterminals
- assert_equal 0, grammar.n_useless_rules
- assert_nil grammar.n_expected_srconflicts
- end
- end
-end
diff --git a/test/racc/test_grammar_file_parser.rb b/test/racc/test_grammar_file_parser.rb
deleted file mode 100644
index b187bdcaec..0000000000
--- a/test/racc/test_grammar_file_parser.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
-
-module Racc
- class TestGrammarFileParser < TestCase
- def test_parse
- file = File.join(ASSET_DIR, 'yyerr.y')
-
- debug_flags = Racc::DebugFlags.parse_option_string('o')
- assert debug_flags.status_logging
-
- parser = Racc::GrammarFileParser.new(debug_flags)
- parser.parse(File.read(file), File.basename(file))
- end
- end
-end
diff --git a/test/racc/test_racc_command.rb b/test/racc/test_racc_command.rb
deleted file mode 100644
index b4fc0c6745..0000000000
--- a/test/racc/test_racc_command.rb
+++ /dev/null
@@ -1,322 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
-
-module Racc
- class TestRaccCommand < TestCase
- def test_syntax_y
- assert_compile 'syntax.y', '-v'
- assert_debugfile 'syntax.y', [0,0,0,0,0]
- end
-
- def test_percent_y
- assert_compile 'percent.y'
- assert_debugfile 'percent.y', []
- assert_exec 'percent.y'
- end
-
- def test_scan_y
- assert_compile 'scan.y'
- assert_debugfile 'scan.y', []
- assert_exec 'scan.y'
- end
-
- def test_newsyn_y
- assert_compile 'newsyn.y'
- assert_debugfile 'newsyn.y', []
- end
-
- def test_normal_y
- assert_compile 'normal.y'
- assert_debugfile 'normal.y', []
-
- assert_compile 'normal.y', '-vg'
- assert_debugfile 'normal.y', []
- end
-
- def test_chk_y
- assert_compile 'chk.y', '-vg'
- assert_debugfile 'chk.y', []
- assert_exec 'chk.y'
-
- assert_compile 'chk.y', '--line-convert-all'
- assert_debugfile 'chk.y', []
- assert_exec 'chk.y'
- end
-
- def test_echk_y
- assert_compile 'echk.y', '-E'
- assert_debugfile 'echk.y', []
- assert_exec 'echk.y'
- end
-
- def test_err_y
- assert_compile 'err.y'
- assert_debugfile 'err.y', []
- assert_exec 'err.y'
- end
-
- def test_mailp_y
- assert_compile 'mailp.y'
- assert_debugfile 'mailp.y', []
- end
-
- def test_conf_y
- assert_compile 'conf.y', '-v'
- assert_debugfile 'conf.y', [4,1,1,2]
- end
-
- def test_rrconf_y
- assert_compile 'rrconf.y'
- assert_debugfile 'rrconf.y', [1,1,0,0]
- end
-
- def test_useless_y
- assert_compile 'useless.y'
- assert_debugfile 'useless.y', [0,0,1,2]
- end
-
- def test_opt_y
- assert_compile 'opt.y'
- assert_debugfile 'opt.y', []
- assert_exec 'opt.y'
- end
-
- def test_yyerr_y
- assert_compile 'yyerr.y'
- assert_debugfile 'yyerr.y', []
- assert_exec 'yyerr.y'
- end
-
- def test_recv_y
- assert_compile 'recv.y'
- assert_debugfile 'recv.y', [5,10,1,4]
- end
-
- def test_ichk_y
- assert_compile 'ichk.y'
- assert_debugfile 'ichk.y', []
- assert_exec 'ichk.y'
- end
-
- def test_intp_y
- assert_compile 'intp.y'
- assert_debugfile 'intp.y', []
- assert_exec 'intp.y'
- end
-
- def test_expect_y
- assert_compile 'expect.y'
- assert_debugfile 'expect.y', [1,0,0,0,1]
- end
-
- def test_nullbug1_y
- assert_compile 'nullbug1.y'
- assert_debugfile 'nullbug1.y', [0,0,0,0]
- end
-
- def test_nullbug2_y
- assert_compile 'nullbug2.y'
- assert_debugfile 'nullbug2.y', [0,0,0,0]
- end
-
- def test_firstline_y
- assert_compile 'firstline.y'
- assert_debugfile 'firstline.y', []
- end
-
- def test_nonass_y
- assert_compile 'nonass.y'
- assert_debugfile 'nonass.y', []
- assert_exec 'nonass.y'
- end
-
- def test_digraph_y
- assert_compile 'digraph.y'
- assert_debugfile 'digraph.y', []
- assert_exec 'digraph.y'
- end
-
- def test_noend_y
- assert_compile 'noend.y'
- assert_debugfile 'noend.y', []
- end
-
- def test_norule_y
- assert_raise(Test::Unit::AssertionFailedError) {
- assert_compile 'norule.y'
- }
- end
-
- def test_unterm_y
- assert_raise(Test::Unit::AssertionFailedError) {
- assert_compile 'unterm.y'
- }
- end
-
- # Regression test for a problem where error recovery at EOF would cause
- # a Racc-generated parser to go into an infinite loop (on some grammars)
- def test_error_recovery_y
- assert_compile 'error_recovery.y'
- Timeout.timeout(10) do
- assert_exec 'error_recovery.y'
- end
- end
-
- # .y files from `parser` gem
-
- def test_ruby18
- assert_compile 'ruby18.y', [], timeout: 60
- assert_debugfile 'ruby18.y', []
- assert_output_unchanged 'ruby18.y'
- end
-
- def test_ruby22
- assert_compile 'ruby22.y', [], timeout: 60
- assert_debugfile 'ruby22.y', []
- assert_output_unchanged 'ruby22.y'
- end
-
- # .y file from csspool gem
-
- def test_csspool
- assert_compile 'csspool.y'
- assert_debugfile 'csspool.y', [5, 3]
- assert_output_unchanged 'csspool.y'
- end
-
- # .y file from opal gem
-
- def test_opal
- assert_compile 'opal.y', [], timeout: 60
- assert_debugfile 'opal.y', []
- assert_output_unchanged 'opal.y'
- end
-
- # .y file from journey gem
-
- def test_journey
- assert_compile 'journey.y'
- assert_debugfile 'journey.y', []
- assert_output_unchanged 'journey.y'
- end
-
- # .y file from nokogiri gem
-
- def test_nokogiri_css
- assert_compile 'nokogiri-css.y'
- assert_debugfile 'nokogiri-css.y', [0, 1]
- assert_output_unchanged 'nokogiri-css.y'
- end
-
- # .y file from edtf-ruby gem
-
- def test_edtf
- assert_compile 'edtf.y'
- assert_debugfile 'edtf.y', [0, 0, 0, 0, 0]
- assert_output_unchanged 'edtf.y'
- end
-
- # .y file from namae gem
-
- def test_namae
- assert_compile 'namae.y'
- assert_debugfile 'namae.y', [0, 0, 0, 0, 0]
- assert_output_unchanged 'namae.y'
- end
-
- # .y file from liquor gem
-
- def test_liquor
- assert_compile 'liquor.y'
- assert_debugfile 'liquor.y', [0, 0, 0, 0, 15]
- assert_output_unchanged 'liquor.y'
- end
-
- # .y file from nasl gem
-
- def test_nasl
- assert_compile 'nasl.y'
- assert_debugfile 'nasl.y', [0, 0, 0, 0, 1]
- assert_output_unchanged 'nasl.y'
- end
-
- # .y file from riml gem
-
- def test_riml
- assert_compile 'riml.y'
- assert_debugfile 'riml.y', [289, 0, 0, 0]
- assert_output_unchanged 'riml.y'
- end
-
- # .y file from ruby-php-serialization gem
-
- def test_php_serialization
- assert_compile 'php_serialization.y'
- assert_debugfile 'php_serialization.y', [0, 0, 0, 0]
- assert_output_unchanged 'php_serialization.y'
- end
-
- # .y file from huia language implementation
-
- def test_huia
- assert_compile 'huia.y'
- assert_debugfile 'huia.y', [285, 0, 0, 0]
- assert_output_unchanged 'huia.y'
- end
-
- # .y file from cast gem
-
- def test_cast
- assert_compile 'cast.y'
- assert_debugfile 'cast.y', [0, 0, 0, 0, 1]
- assert_output_unchanged 'cast.y'
- end
-
- # .y file from cadenza gem
-
- def test_cadenza
- assert_compile 'cadenza.y'
- assert_debugfile 'cadenza.y', [0, 0, 0, 0, 37]
- assert_output_unchanged 'cadenza.y'
- end
-
- # .y file from mediacloth gem
-
- def test_mediacloth
- assert_compile 'mediacloth.y'
- assert_debugfile 'mediacloth.y', [0, 0, 0, 0]
- assert_output_unchanged 'mediacloth.y'
- end
-
- # .y file from twowaysql gem
-
- def test_twowaysql
- assert_compile 'twowaysql.y'
- assert_debugfile 'twowaysql.y', [4, 0, 0, 0]
- assert_output_unchanged 'twowaysql.y'
- end
-
- # .y file from machete gem
-
- def test_machete
- assert_compile 'machete.y'
- assert_debugfile 'machete.y', [0, 0, 0, 0]
- assert_output_unchanged 'machete.y'
- end
-
- # .y file from mof gem
-
- def test_mof
- assert_compile 'mof.y'
- assert_debugfile 'mof.y', [7, 4, 0, 0]
- assert_output_unchanged 'mof.y'
- end
-
- # .y file from tp_plus gem
-
- def test_tp_plus
- assert_compile 'tp_plus.y'
- assert_debugfile 'tp_plus.y', [21, 0, 0, 0]
- assert_output_unchanged 'tp_plus.y'
- end
- end
-end
diff --git a/test/racc/test_scan_y.rb b/test/racc/test_scan_y.rb
deleted file mode 100644
index 4c60119119..0000000000
--- a/test/racc/test_scan_y.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
-
-module Racc
- class TestScanY < TestCase
- def setup
- super
- file = File.join(ASSET_DIR, 'scan.y')
- @debug_flags = Racc::DebugFlags.parse_option_string('o')
- parser = Racc::GrammarFileParser.new(@debug_flags)
- @result = parser.parse(File.read(file), File.basename(file))
- @states = Racc::States.new(@result.grammar).nfa
- @states.dfa
- end
-
- def test_compile
- generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
-
- # it generates valid ruby
- assert Module.new {
- self.class_eval(generator.generate_parser)
- }
-
- grammar = @states.grammar
-
- assert_equal 0, @states.n_srconflicts
- assert_equal 0, @states.n_rrconflicts
- assert_equal 0, grammar.n_useless_nonterminals
- assert_equal 0, grammar.n_useless_rules
- assert_nil grammar.n_expected_srconflicts
- end
-
- def test_compile_line_convert
- params = @result.params.dup
- params.convert_line_all = true
-
- generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
-
- # it generates valid ruby
- assert Module.new {
- self.class_eval(generator.generate_parser)
- }
-
- grammar = @states.grammar
-
- assert_equal 0, @states.n_srconflicts
- assert_equal 0, @states.n_rrconflicts
- assert_equal 0, grammar.n_useless_nonterminals
- assert_equal 0, grammar.n_useless_rules
- assert_nil grammar.n_expected_srconflicts
- end
- end
-end
diff --git a/test/racc/testscanner.rb b/test/racc/testscanner.rb
deleted file mode 100644
index d7877511ec..0000000000
--- a/test/racc/testscanner.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# racc scanner tester
-#
-
-require 'racc/raccs'
-
-
-class ScanError < StandardError; end
-
-def testdata( dir, argv )
- if argv.empty? then
- Dir.glob( dir + '/*' ) -
- Dir.glob( dir + '/*.swp' ) -
- [ dir + '/CVS' ]
- else
- argv.collect {|i| dir + '/' + i }
- end
-end
-
-
-if ARGV.delete '--print' then
- $raccs_print_type = true
- printonly = true
-else
- printonly = false
-end
-
-testdata( File.dirname($0) + '/scandata', ARGV ).each do |file|
- $stderr.print File.basename(file) + ': '
- begin
- ok = File.read(file)
- s = Racc::GrammarFileScanner.new( ok )
- sym, (val, _lineno) = s.scan
- if printonly then
- $stderr.puts
- $stderr.puts val
- next
- end
-
- val = '{' + val + "}\n"
- sym == :ACTION or raise ScanError, 'is not action!'
- val == ok or raise ScanError, "\n>>>\n#{ok}----\n#{val}<<<"
-
- $stderr.puts 'ok'
- rescue => err
- $stderr.puts 'fail (' + err.type.to_s + ')'
- $stderr.puts err.message
- $stderr.puts err.backtrace
- $stderr.puts
- end
-end
diff --git a/test/rdoc/MarkdownTest_1.0.3/Markdown Documentation - Basics.text b/test/rdoc/MarkdownTest_1.0.3/Markdown Documentation - Basics.text
index b499390f2d..6c5a6fdb4b 100644
--- a/test/rdoc/MarkdownTest_1.0.3/Markdown Documentation - Basics.text
+++ b/test/rdoc/MarkdownTest_1.0.3/Markdown Documentation - Basics.text
@@ -270,7 +270,7 @@ it easy to use Markdown to write about HTML example code:
I strongly recommend against using any `<blink>` tags.
I wish SmartyPants used named entities like `&mdash;`
- instead of decimal-encoded entities like `&#8212;`.
+ instead of decimal-encoded entites like `&#8212;`.
Output:
@@ -279,7 +279,7 @@ Output:
<p>I wish SmartyPants used named entities like
<code>&amp;mdash;</code> instead of decimal-encoded
- entities like <code>&amp;#8212;</code>.</p>
+ entites like <code>&amp;#8212;</code>.</p>
To specify an entire block of pre-formatted code, indent every line of
diff --git a/test/rdoc/helper.rb b/test/rdoc/helper.rb
deleted file mode 100644
index 2ba26c296b..0000000000
--- a/test/rdoc/helper.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-require_relative './support/test_case'
-require_relative './support/formatter_test_case'
-require_relative './support/text_formatter_test_case'
diff --git a/test/rdoc/support/formatter_test_case.rb b/test/rdoc/support/formatter_test_case.rb
deleted file mode 100644
index 9f49dd0897..0000000000
--- a/test/rdoc/support/formatter_test_case.rb
+++ /dev/null
@@ -1,764 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-
-##
-# Test case for creating new RDoc::Markup formatters. See
-# test/test_rdoc_markup_to_*.rb for examples.
-#
-# This test case adds a variety of tests to your subclass when
-# #add_visitor_tests is called. Most tests set up a scenario then call a
-# method you will provide to perform the assertion on the output.
-#
-# Your subclass must instantiate a visitor and assign it to <tt>@to</tt>.
-#
-# For example, test_accept_blank_line sets up a RDoc::Markup::BlockLine then
-# calls accept_blank_line on your visitor. You are responsible for asserting
-# that the output is correct.
-#
-# Example:
-#
-# class TestRDocMarkupToNewFormat < RDoc::Markup::FormatterTestCase
-#
-# add_visitor_tests
-#
-# def setup
-# super
-#
-# @to = RDoc::Markup::ToNewFormat.new
-# end
-#
-# def accept_blank_line
-# assert_equal :junk, @to.res.join
-# end
-#
-# # ...
-#
-# end
-
-class RDoc::Markup::FormatterTestCase < RDoc::TestCase
-
- ##
- # Call #setup when inheriting from this test case.
- #
- # Provides the following instance variables:
- #
- # +@m+:: RDoc::Markup.new
- # +@RM+:: RDoc::Markup # to reduce typing
- # +@bullet_list+:: @RM::List.new :BULLET, # ...
- # +@label_list+:: @RM::List.new :LABEL, # ...
- # +@lalpha_list+:: @RM::List.new :LALPHA, # ...
- # +@note_list+:: @RM::List.new :NOTE, # ...
- # +@number_list+:: @RM::List.new :NUMBER, # ...
- # +@ualpha_list+:: @RM::List.new :UALPHA, # ...
-
- def setup
- super
-
- @options = RDoc::Options.new
-
- @m = @RM.new
-
- @bullet_list = @RM::List.new(:BULLET,
- @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
- @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
-
- @label_list = @RM::List.new(:LABEL,
- @RM::ListItem.new('cat', @RM::Paragraph.new('cats are cool')),
- @RM::ListItem.new('dog', @RM::Paragraph.new('dogs are cool too')))
-
- @lalpha_list = @RM::List.new(:LALPHA,
- @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
- @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
-
- @note_list = @RM::List.new(:NOTE,
- @RM::ListItem.new('cat', @RM::Paragraph.new('cats are cool')),
- @RM::ListItem.new('dog', @RM::Paragraph.new('dogs are cool too')))
-
- @number_list = @RM::List.new(:NUMBER,
- @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
- @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
-
- @ualpha_list = @RM::List.new(:UALPHA,
- @RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
- @RM::ListItem.new(nil, @RM::Paragraph.new('l2')))
- end
-
- ##
- # Call to add the visitor tests to your test case
-
- def self.add_visitor_tests
- class_eval do
-
- ##
- # Calls start_accepting which needs to verify startup state
-
- def test_start_accepting
- @to.start_accepting
-
- start_accepting
- end
-
- ##
- # Calls end_accepting on your test case which needs to call
- # <tt>@to.end_accepting</tt> and verify document generation
-
- def test_end_accepting
- @to.start_accepting
- @to.res << 'hi'
-
- end_accepting
- end
-
- ##
- # Calls accept_blank_line
-
- def test_accept_blank_line
- @to.start_accepting
-
- @to.accept_blank_line @RM::BlankLine.new
-
- accept_blank_line
- end
-
- ##
- # Calls accept_block_quote
-
- def test_accept_block_quote
- @to.start_accepting
-
- @to.accept_block_quote block para 'quote'
-
- accept_block_quote
- end
- ##
- # Test case that calls <tt>@to.accept_document</tt>
-
- def test_accept_document
- @to.start_accepting
- @to.accept_document @RM::Document.new @RM::Paragraph.new 'hello'
-
- accept_document
- end
-
- ##
- # Calls accept_heading with a level 5 RDoc::Markup::Heading
-
- def test_accept_heading
- @to.start_accepting
-
- @to.accept_heading @RM::Heading.new(5, 'Hello')
-
- accept_heading
- end
-
- ##
- # Calls accept_heading_1 with a level 1 RDoc::Markup::Heading
-
- def test_accept_heading_1
- @to.start_accepting
-
- @to.accept_heading @RM::Heading.new(1, 'Hello')
-
- accept_heading_1
- end
-
- ##
- # Calls accept_heading_2 with a level 2 RDoc::Markup::Heading
-
- def test_accept_heading_2
- @to.start_accepting
-
- @to.accept_heading @RM::Heading.new(2, 'Hello')
-
- accept_heading_2
- end
-
- ##
- # Calls accept_heading_3 with a level 3 RDoc::Markup::Heading
-
- def test_accept_heading_3
- @to.start_accepting
-
- @to.accept_heading @RM::Heading.new(3, 'Hello')
-
- accept_heading_3
- end
-
- ##
- # Calls accept_heading_4 with a level 4 RDoc::Markup::Heading
-
- def test_accept_heading_4
- @to.start_accepting
-
- @to.accept_heading @RM::Heading.new(4, 'Hello')
-
- accept_heading_4
- end
-
- ##
- # Calls accept_heading_b with a bold level 1 RDoc::Markup::Heading
-
- def test_accept_heading_b
- @to.start_accepting
-
- @to.accept_heading @RM::Heading.new(1, '*Hello*')
-
- accept_heading_b
- end
-
- ##
- # Calls accept_heading_suppressed_crossref with a level 1
- # RDoc::Markup::Heading containing a suppressed crossref
-
- def test_accept_heading_suppressed_crossref # HACK to_html_crossref test
- @to.start_accepting
-
- @to.accept_heading @RM::Heading.new(1, '\\Hello')
-
- accept_heading_suppressed_crossref
- end
-
- ##
- # Calls accept_paragraph
-
- def test_accept_paragraph
- @to.start_accepting
-
- @to.accept_paragraph @RM::Paragraph.new('hi')
-
- accept_paragraph
- end
-
- ##
- # Calls accept_paragraph_b with a RDoc::Markup::Paragraph containing
- # bold words
-
- def test_accept_paragraph_b
- @to.start_accepting
-
- @to.accept_paragraph @RM::Paragraph.new('reg <b>bold words</b> reg')
-
- accept_paragraph_b
- end
-
- ##
- # Calls accept_paragraph_br with a RDoc::Markup::Paragraph containing
- # a \<br>
-
- def test_accept_paragraph_br
- @to.start_accepting
-
- @to.accept_paragraph para 'one<br>two'
-
- accept_paragraph_br
- end
-
- ##
- # Calls accept_paragraph with a Paragraph containing a hard break
-
- def test_accept_paragraph_break
- @to.start_accepting
-
- @to.accept_paragraph para('hello', hard_break, 'world')
-
- accept_paragraph_break
- end
-
- ##
- # Calls accept_paragraph_i with a RDoc::Markup::Paragraph containing
- # emphasized words
-
- def test_accept_paragraph_i
- @to.start_accepting
-
- @to.accept_paragraph @RM::Paragraph.new('reg <em>italic words</em> reg')
-
- accept_paragraph_i
- end
-
- ##
- # Calls accept_paragraph_plus with a RDoc::Markup::Paragraph containing
- # teletype words
-
- def test_accept_paragraph_plus
- @to.start_accepting
-
- @to.accept_paragraph @RM::Paragraph.new('reg +teletype+ reg')
-
- accept_paragraph_plus
- end
-
- ##
- # Calls accept_paragraph_star with a RDoc::Markup::Paragraph containing
- # bold words
-
- def test_accept_paragraph_star
- @to.start_accepting
-
- @to.accept_paragraph @RM::Paragraph.new('reg *bold* reg')
-
- accept_paragraph_star
- end
-
- ##
- # Calls accept_paragraph_underscore with a RDoc::Markup::Paragraph
- # containing emphasized words
-
- def test_accept_paragraph_underscore
- @to.start_accepting
-
- @to.accept_paragraph @RM::Paragraph.new('reg _italic_ reg')
-
- accept_paragraph_underscore
- end
-
- ##
- # Calls accept_verbatim with a RDoc::Markup::Verbatim
-
- def test_accept_verbatim
- @to.start_accepting
-
- @to.accept_verbatim @RM::Verbatim.new("hi\n", " world\n")
-
- accept_verbatim
- end
-
- ##
- # Calls accept_raw with a RDoc::Markup::Raw
-
- def test_accept_raw
- @to.start_accepting
-
- @to.accept_raw @RM::Raw.new("<table>",
- "<tr><th>Name<th>Count",
- "<tr><td>a<td>1",
- "<tr><td>b<td>2",
- "</table>")
-
- accept_raw
- end
-
- ##
- # Calls accept_rule with a RDoc::Markup::Rule
-
- def test_accept_rule
- @to.start_accepting
-
- @to.accept_rule @RM::Rule.new(4)
-
- accept_rule
- end
-
- ##
- # Calls accept_list_item_start_bullet
-
- def test_accept_list_item_start_bullet
- @to.start_accepting
-
- @to.accept_list_start @bullet_list
-
- @to.accept_list_item_start @bullet_list.items.first
-
- accept_list_item_start_bullet
- end
-
- ##
- # Calls accept_list_item_start_label
-
- def test_accept_list_item_start_label
- @to.start_accepting
-
- @to.accept_list_start @label_list
-
- @to.accept_list_item_start @label_list.items.first
-
- accept_list_item_start_label
- end
-
- ##
- # Calls accept_list_item_start_lalpha
-
- def test_accept_list_item_start_lalpha
- @to.start_accepting
-
- @to.accept_list_start @lalpha_list
-
- @to.accept_list_item_start @lalpha_list.items.first
-
- accept_list_item_start_lalpha
- end
-
- ##
- # Calls accept_list_item_start_note
-
- def test_accept_list_item_start_note
- @to.start_accepting
-
- @to.accept_list_start @note_list
-
- @to.accept_list_item_start @note_list.items.first
-
- accept_list_item_start_note
- end
-
- ##
- # Calls accept_list_item_start_note_2
-
- def test_accept_list_item_start_note_2
- list = list(:NOTE,
- item('<tt>teletype</tt>',
- para('teletype description')))
-
- @to.start_accepting
-
- list.accept @to
-
- @to.end_accepting
-
- accept_list_item_start_note_2
- end
-
- ##
- # Calls accept_list_item_start_note_multi_description
-
- def test_accept_list_item_start_note_multi_description
- list = list(:NOTE,
- item(%w[label],
- para('description one')),
- item(nil, para('description two')))
-
- @to.start_accepting
-
- list.accept @to
-
- @to.end_accepting
-
- accept_list_item_start_note_multi_description
- end
-
- ##
- # Calls accept_list_item_start_note_multi_label
-
- def test_accept_list_item_start_note_multi_label
- list = list(:NOTE,
- item(%w[one two],
- para('two headers')))
-
- @to.start_accepting
-
- list.accept @to
-
- @to.end_accepting
-
- accept_list_item_start_note_multi_label
- end
-
- ##
- # Calls accept_list_item_start_number
-
- def test_accept_list_item_start_number
- @to.start_accepting
-
- @to.accept_list_start @number_list
-
- @to.accept_list_item_start @number_list.items.first
-
- accept_list_item_start_number
- end
-
- ##
- # Calls accept_list_item_start_ualpha
-
- def test_accept_list_item_start_ualpha
- @to.start_accepting
-
- @to.accept_list_start @ualpha_list
-
- @to.accept_list_item_start @ualpha_list.items.first
-
- accept_list_item_start_ualpha
- end
-
- ##
- # Calls accept_list_item_end_bullet
-
- def test_accept_list_item_end_bullet
- @to.start_accepting
-
- @to.accept_list_start @bullet_list
-
- @to.accept_list_item_start @bullet_list.items.first
-
- @to.accept_list_item_end @bullet_list.items.first
-
- accept_list_item_end_bullet
- end
-
- ##
- # Calls accept_list_item_end_label
-
- def test_accept_list_item_end_label
- @to.start_accepting
-
- @to.accept_list_start @label_list
-
- @to.accept_list_item_start @label_list.items.first
-
- @to.accept_list_item_end @label_list.items.first
-
- accept_list_item_end_label
- end
-
- ##
- # Calls accept_list_item_end_lalpha
-
- def test_accept_list_item_end_lalpha
- @to.start_accepting
-
- @to.accept_list_start @lalpha_list
-
- @to.accept_list_item_start @lalpha_list.items.first
-
- @to.accept_list_item_end @lalpha_list.items.first
-
- accept_list_item_end_lalpha
- end
-
- ##
- # Calls accept_list_item_end_note
-
- def test_accept_list_item_end_note
- @to.start_accepting
-
- @to.accept_list_start @note_list
-
- @to.accept_list_item_start @note_list.items.first
-
- @to.accept_list_item_end @note_list.items.first
-
- accept_list_item_end_note
- end
-
- ##
- # Calls accept_list_item_end_number
-
- def test_accept_list_item_end_number
- @to.start_accepting
-
- @to.accept_list_start @number_list
-
- @to.accept_list_item_start @number_list.items.first
-
- @to.accept_list_item_end @number_list.items.first
-
- accept_list_item_end_number
- end
-
- ##
- # Calls accept_list_item_end_ualpha
-
- def test_accept_list_item_end_ualpha
- @to.start_accepting
-
- @to.accept_list_start @ualpha_list
-
- @to.accept_list_item_start @ualpha_list.items.first
-
- @to.accept_list_item_end @ualpha_list.items.first
-
- accept_list_item_end_ualpha
- end
-
- ##
- # Calls accept_list_start_bullet
-
- def test_accept_list_start_bullet
- @to.start_accepting
-
- @to.accept_list_start @bullet_list
-
- accept_list_start_bullet
- end
-
- ##
- # Calls accept_list_start_label
-
- def test_accept_list_start_label
- @to.start_accepting
-
- @to.accept_list_start @label_list
-
- accept_list_start_label
- end
-
- ##
- # Calls accept_list_start_lalpha
-
- def test_accept_list_start_lalpha
- @to.start_accepting
-
- @to.accept_list_start @lalpha_list
-
- accept_list_start_lalpha
- end
-
- ##
- # Calls accept_list_start_note
-
- def test_accept_list_start_note
- @to.start_accepting
-
- @to.accept_list_start @note_list
-
- accept_list_start_note
- end
-
- ##
- # Calls accept_list_start_number
-
- def test_accept_list_start_number
- @to.start_accepting
-
- @to.accept_list_start @number_list
-
- accept_list_start_number
- end
-
- ##
- # Calls accept_list_start_ualpha
-
- def test_accept_list_start_ualpha
- @to.start_accepting
-
- @to.accept_list_start @ualpha_list
-
- accept_list_start_ualpha
- end
-
- ##
- # Calls accept_list_end_bullet
-
- def test_accept_list_end_bullet
- @to.start_accepting
-
- @to.accept_list_start @bullet_list
-
- @to.accept_list_end @bullet_list
-
- accept_list_end_bullet
- end
-
- ##
- # Calls accept_list_end_label
-
- def test_accept_list_end_label
- @to.start_accepting
-
- @to.accept_list_start @label_list
-
- @to.accept_list_end @label_list
-
- accept_list_end_label
- end
-
- ##
- # Calls accept_list_end_lalpha
-
- def test_accept_list_end_lalpha
- @to.start_accepting
-
- @to.accept_list_start @lalpha_list
-
- @to.accept_list_end @lalpha_list
-
- accept_list_end_lalpha
- end
-
- ##
- # Calls accept_list_end_number
-
- def test_accept_list_end_number
- @to.start_accepting
-
- @to.accept_list_start @number_list
-
- @to.accept_list_end @number_list
-
- accept_list_end_number
- end
-
- ##
- # Calls accept_list_end_note
-
- def test_accept_list_end_note
- @to.start_accepting
-
- @to.accept_list_start @note_list
-
- @to.accept_list_end @note_list
-
- accept_list_end_note
- end
-
- ##
- # Calls accept_list_end_ualpha
-
- def test_accept_list_end_ualpha
- @to.start_accepting
-
- @to.accept_list_start @ualpha_list
-
- @to.accept_list_end @ualpha_list
-
- accept_list_end_ualpha
- end
-
- ##
- # Calls list_nested with a two-level list
-
- def test_list_nested
- doc = @RM::Document.new(
- @RM::List.new(:BULLET,
- @RM::ListItem.new(nil,
- @RM::Paragraph.new('l1'),
- @RM::List.new(:BULLET,
- @RM::ListItem.new(nil,
- @RM::Paragraph.new('l1.1')))),
- @RM::ListItem.new(nil,
- @RM::Paragraph.new('l2'))))
-
- doc.accept @to
-
- list_nested
- end
-
- ##
- # Calls list_verbatim with a list containing a verbatim block
-
- def test_list_verbatim # HACK overblown
- doc =
- doc(
- list(:BULLET,
- item(nil,
- para('list stuff'),
- blank_line,
- verb("* list\n",
- " with\n",
- "\n",
- " second\n",
- "\n",
- " 1. indented\n",
- " 2. numbered\n",
- "\n",
- " third\n",
- "\n",
- "* second\n"))))
-
- doc.accept @to
-
- list_verbatim
- end
- end
- end
-
-end
diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb
deleted file mode 100644
index 9a4f04b76e..0000000000
--- a/test/rdoc/support/test_case.rb
+++ /dev/null
@@ -1,216 +0,0 @@
-##
-# RDoc::TestCase is an abstract TestCase to provide common setup and teardown
-# across all RDoc tests. The test case uses minitest, so all the assertions
-# of minitest may be used.
-#
-# The testcase provides the following:
-#
-# * A reset code-object tree
-# * A reset markup preprocessor (RDoc::Markup::PreProcess)
-# * The <code>@RM</code> alias of RDoc::Markup (for less typing)
-# * <code>@pwd</code> containing the current working directory
-# * FileUtils, pp, Tempfile, Dir.tmpdir and StringIO
-
-require 'bundler/errors'
-begin
- gem 'test-unit'
-rescue NoMethodError, Gem::LoadError, Bundler::GemfileNotFound
- # for ruby tests
-end
-
-require 'test/unit'
-
-require 'fileutils'
-require 'pp'
-require 'tempfile'
-require 'tmpdir'
-require 'stringio'
-
-require 'rdoc'
-
-##
-# RDoc::TestCase is an abstract TestCase to provide common setup and teardown
-# across all RDoc tests. The test case uses minitest, so all the assertions
-# of minitest may be used.
-#
-# The testcase provides the following:
-#
-# * A reset code-object tree
-# * A reset markup preprocessor (RDoc::Markup::PreProcess)
-# * The <code>@RM</code> alias of RDoc::Markup (for less typing)
-# * <code>@pwd</code> containing the current working directory
-# * FileUtils, pp, Tempfile, Dir.tmpdir and StringIO
-
-class RDoc::TestCase < Test::Unit::TestCase
-
- ##
- # Abstract test-case setup
-
- def setup
- super
-
- @top_level = nil
-
- @RM = RDoc::Markup
-
- @pwd = Dir.pwd
-
- @store = RDoc::Store.new
-
- @rdoc = RDoc::RDoc.new
- @rdoc.store = @store
- @rdoc.options = RDoc::Options.new
-
- g = Object.new
- def g.class_dir() end
- def g.file_dir() end
- @rdoc.generator = g
-
- RDoc::Markup::PreProcess.reset
- end
-
- ##
- # Asserts +path+ is a file
-
- def assert_file path
- assert File.file?(path), "#{path} is not a file"
- end
-
- ##
- # Asserts +path+ is a directory
-
- def assert_directory path
- assert File.directory?(path), "#{path} is not a directory"
- end
-
- ##
- # Refutes +path+ exists
-
- def refute_file path
- refute File.exist?(path), "#{path} exists"
- end
-
- ##
- # Shortcut for RDoc::Markup::BlankLine.new
-
- def blank_line
- @RM::BlankLine.new
- end
-
- ##
- # Shortcut for RDoc::Markup::BlockQuote.new with +contents+
-
- def block *contents
- @RM::BlockQuote.new(*contents)
- end
-
- ##
- # Creates an RDoc::Comment with +text+ which was defined on +top_level+.
- # By default the comment has the 'rdoc' format.
-
- def comment text, top_level = @top_level, language = nil
- comment = RDoc::Comment.new text, top_level, language
- comment
- end
-
- ##
- # Shortcut for RDoc::Markup::Document.new with +contents+
-
- def doc *contents
- @RM::Document.new(*contents)
- end
-
- ##
- # Shortcut for RDoc::Markup::HardBreak.new
-
- def hard_break
- @RM::HardBreak.new
- end
-
- ##
- # Shortcut for RDoc::Markup::Heading.new with +level+ and +text+
-
- def head level, text
- @RM::Heading.new level, text
- end
-
- ##
- # Shortcut for RDoc::Markup::ListItem.new with +label+ and +parts+
-
- def item label = nil, *parts
- @RM::ListItem.new label, *parts
- end
-
- ##
- # Shortcut for RDoc::Markup::List.new with +type+ and +items+
-
- def list type = nil, *items
- @RM::List.new type, *items
- end
-
- ##
- # Enables pretty-print output
-
- def mu_pp obj # :nodoc:
- s = obj.pretty_inspect
- s = RDoc::Encoding.change_encoding s, Encoding.default_external
- s.chomp
- end
-
- ##
- # Shortcut for RDoc::Markup::Paragraph.new with +contents+
-
- def para *a
- @RM::Paragraph.new(*a)
- end
-
- ##
- # Shortcut for RDoc::Markup::Rule.new with +weight+
-
- def rule weight
- @RM::Rule.new weight
- end
-
- ##
- # Shortcut for RDoc::Markup::Raw.new with +contents+
-
- def raw *contents
- @RM::Raw.new(*contents)
- end
-
- ##
- # Creates a temporary directory changes the current directory to it for the
- # duration of the block.
- #
- # Depends upon Dir.mktmpdir
-
- def temp_dir
- Dir.mktmpdir do |temp_dir|
- Dir.chdir temp_dir do
- yield temp_dir
- end
- end
- end
-
- ##
- # Shortcut for RDoc::Markup::Verbatim.new with +parts+
-
- def verb *parts
- @RM::Verbatim.new(*parts)
- end
-
- ##
- # run capture_io with setting $VERBOSE = true
-
- def verbose_capture_output
- capture_output do
- begin
- orig_verbose = $VERBOSE
- $VERBOSE = true
- yield
- ensure
- $VERBOSE = orig_verbose
- end
- end
- end
-end
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb
index 615789dfb3..55793255ba 100644
--- a/test/rdoc/test_rdoc_any_method.rb
+++ b/test/rdoc/test_rdoc_any_method.rb
@@ -78,40 +78,13 @@ method(a, b) { |c, d| ... }
]
@c2_a.collect_tokens
- @c2_a.add_tokens(tokens)
+ @c2_a.add_tokens(*tokens)
expected = '<span class="ruby-constant">CONSTANT</span>'
assert_equal expected, @c2_a.markup_code
end
- def test_markup_code_with_line_numbers
- position_comment = "# File #{@file_name}, line 1"
- tokens = [
- { :line_no => 1, :char_no => 0, :kind => :on_comment, :text => position_comment },
- { :line_no => 1, :char_no => position_comment.size, :kind => :on_nl, :text => "\n" },
- { :line_no => 2, :char_no => 0, :kind => :on_const, :text => 'A' },
- { :line_no => 2, :char_no => 1, :kind => :on_nl, :text => "\n" },
- { :line_no => 3, :char_no => 0, :kind => :on_const, :text => 'B' }
- ]
-
- @c2_a.collect_tokens
- @c2_a.add_tokens(tokens)
-
- assert_equal <<-EXPECTED.chomp, @c2_a.markup_code
-<span class="ruby-comment"># File xref_data.rb, line 1</span>
-<span class="ruby-constant">A</span>
-<span class="ruby-constant">B</span>
- EXPECTED
-
- @options.line_numbers = true
- assert_equal <<-EXPECTED.chomp, @c2_a.markup_code
- <span class="ruby-comment"># File xref_data.rb</span>
-<span class="line-num">1</span> <span class="ruby-constant">A</span>
-<span class="line-num">2</span> <span class="ruby-constant">B</span>
- EXPECTED
- end
-
def test_markup_code_empty
assert_equal '', @c2_a.markup_code
end
@@ -160,7 +133,7 @@ method(a, b) { |c, d| ... }
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
- assert_nil loaded.singleton # defaults to nil
+ assert_equal nil, loaded.singleton # defaults to nil
assert_equal :public, loaded.visibility
assert_equal cm, loaded.parent
assert_equal section, loaded.section
@@ -178,21 +151,8 @@ method(a, b) { |c, d| ... }
assert aliased_method.display?
end
- def test_marshal_load_aliased_method_with_nil_singleton
- aliased_method = Marshal.load Marshal.dump(@c2_a)
-
- aliased_method.store = @store
- aliased_method.is_alias_for = ["C2", nil, "b"]
-
- assert_equal 'C2#a', aliased_method.full_name
- assert_equal 'C2', aliased_method.parent_name
- assert_equal '()', aliased_method.params
- assert_equal @c2_b, aliased_method.is_alias_for, 'is_alias_for'
- assert aliased_method.display?
- end
-
def test_marshal_load_class_method
- class_method = Marshal.load Marshal.dump(@c1.find_class_method_named 'm')
+ class_method = Marshal.load Marshal.dump(@c1.method_list.first)
assert_equal 'C1::m', class_method.full_name
assert_equal 'C1', class_method.parent_name
@@ -201,7 +161,7 @@ method(a, b) { |c, d| ... }
end
def test_marshal_load_instance_method
- instance_method = Marshal.load Marshal.dump(@c1.find_instance_method_named 'm')
+ instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
assert_equal 'C1#m', instance_method.full_name
assert_equal 'C1', instance_method.parent_name
@@ -247,9 +207,9 @@ method(a, b) { |c, d| ... }
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
- assert_nil loaded.singleton # defaults to nil
+ assert_equal nil, loaded.singleton # defaults to nil
assert_equal :public, loaded.visibility
- assert_nil loaded.file
+ assert_equal nil, loaded.file
assert_equal cm, loaded.parent
assert_equal section, loaded.section
assert_nil loaded.is_alias_for
@@ -304,7 +264,7 @@ method(a, b) { |c, d| ... }
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
- assert_nil loaded.singleton # defaults to nil
+ assert_equal nil, loaded.singleton # defaults to nil
assert_equal :public, loaded.visibility
assert_equal cm, loaded.parent
assert_equal section, loaded.section
@@ -507,3 +467,4 @@ method(a, b) { |c, d| ... }
end
end
+
diff --git a/test/rdoc/test_rdoc_attr.rb b/test/rdoc/test_rdoc_attr.rb
index cff52acf31..ae702ac702 100644
--- a/test/rdoc/test_rdoc_attr.rb
+++ b/test/rdoc/test_rdoc_attr.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocAttr < RDoc::TestCase
@@ -139,7 +139,7 @@ class TestRDocAttr < RDoc::TestCase
assert_equal cm, loaded.parent
assert_equal section, loaded.section
- assert loaded.display?
+ assert loaded.display?
end
def test_marshal_load_version_2
@@ -188,3 +188,4 @@ class TestRDocAttr < RDoc::TestCase
end
end
+
diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb
index 4dcc5d15ab..273a21120f 100644
--- a/test/rdoc/test_rdoc_class_module.rb
+++ b/test/rdoc/test_rdoc_class_module.rb
@@ -9,24 +9,21 @@ class TestRDocClassModule < XrefTestCase
tl3 = @store.add_file 'three.rb'
cm = RDoc::ClassModule.new 'Klass'
- comment_tl1 = RDoc::Comment.new('# comment 1', @top_level, :ruby)
- cm.add_comment comment_tl1, tl1
+ cm.add_comment '# comment 1', tl1
- assert_equal [[comment_tl1, tl1]], cm.comment_location
- assert_equal 'comment 1', cm.comment.text
+ assert_equal [['comment 1', tl1]], cm.comment_location
+ assert_equal 'comment 1', cm.comment
- comment_tl2 = RDoc::Comment.new('# comment 2', @top_level, :ruby)
- cm.add_comment comment_tl2, tl2
+ cm.add_comment '# comment 2', tl2
- assert_equal [[comment_tl1, tl1], [comment_tl2, tl2]], cm.comment_location
+ assert_equal [['comment 1', tl1], ['comment 2', tl2]], cm.comment_location
assert_equal "comment 1\n---\ncomment 2", cm.comment
- comment_tl3 = RDoc::Comment.new('# * comment 3', @top_level, :ruby)
- cm.add_comment comment_tl3, tl3
+ cm.add_comment "# * comment 3", tl3
- assert_equal [[comment_tl1, tl1],
- [comment_tl2, tl2],
- [comment_tl3, tl3]], cm.comment_location
+ assert_equal [['comment 1', tl1],
+ ['comment 2', tl2],
+ ['* comment 3', tl3]], cm.comment_location
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
end
@@ -42,13 +39,11 @@ class TestRDocClassModule < XrefTestCase
tl1 = @store.add_file 'one.rb'
cm = RDoc::ClassModule.new 'Klass'
- comment1 = RDoc::Comment.new('# comment 1', @top_level, :ruby)
- comment2 = RDoc::Comment.new('# comment 2', @top_level, :ruby)
- cm.add_comment comment1, tl1
- cm.add_comment comment2, tl1
+ cm.add_comment '# comment 1', tl1
+ cm.add_comment '# comment 2', tl1
- assert_equal [[comment1, tl1],
- [comment2, tl1]], cm.comment_location
+ assert_equal [['comment 1', tl1],
+ ['comment 2', tl1]], cm.comment_location
end
def test_add_comment_stopdoc
@@ -68,17 +63,17 @@ class TestRDocClassModule < XrefTestCase
def test_comment_equals
cm = RDoc::ClassModule.new 'Klass'
- cm.comment = RDoc::Comment.new('# comment 1', @top_level, :ruby)
+ cm.comment = '# comment 1'
- assert_equal 'comment 1', cm.comment.to_s
+ assert_equal 'comment 1', cm.comment
- cm.comment = RDoc::Comment.new('# comment 2', @top_level, :ruby)
+ cm.comment = '# comment 2'
- assert_equal "comment 1\n---\ncomment 2", cm.comment.to_s
+ assert_equal "comment 1\n---\ncomment 2", cm.comment
- cm.comment = RDoc::Comment.new('# * comment 3', @top_level, :ruby)
+ cm.comment = "# * comment 3"
- assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment.to_s
+ assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
end
def test_comment_equals_comment
@@ -96,7 +91,6 @@ class TestRDocClassModule < XrefTestCase
assert @c1.document_self_or_methods
- @c1_plus.document_self = false
@c1_m.document_self = false
assert @c1.document_self_or_methods
@@ -1283,8 +1277,7 @@ class TestRDocClassModule < XrefTestCase
n1 = @xref_data.add_module RDoc::NormalClass, 'N1'
n1_k2 = n1.add_module RDoc::NormalClass, 'N2'
- a1 = RDoc::Constant.new 'A1', '', ''
- n1.add_module_alias n1_k2, n1_k2.name, a1, @xref_data
+ n1.add_module_alias n1_k2, 'A1', @xref_data
n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
refute_nil n1_a1_c
@@ -1308,8 +1301,7 @@ class TestRDocClassModule < XrefTestCase
n1 = @xref_data.add_module RDoc::NormalModule, 'N1'
n1_n2 = n1.add_module RDoc::NormalModule, 'N2'
- a1 = RDoc::Constant.new 'A1', '', ''
- n1.add_module_alias n1_n2, n1_n2.name, a1, @xref_data
+ n1.add_module_alias n1_n2, 'A1', @xref_data
n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
refute_nil n1_a1_c
@@ -1334,8 +1326,7 @@ class TestRDocClassModule < XrefTestCase
l1_l2 = l1.add_module RDoc::NormalModule, 'L2'
o1 = @xref_data.add_module RDoc::NormalModule, 'O1'
- a1 = RDoc::Constant.new 'A1', '', ''
- o1.add_module_alias l1_l2, l1_l2.name, a1, @xref_data
+ o1.add_module_alias l1_l2, 'A1', @xref_data
o1_a1_c = o1.constants.find { |c| c.name == 'A1' }
refute_nil o1_a1_c
@@ -1367,8 +1358,7 @@ class TestRDocClassModule < XrefTestCase
const.record_location top_level
const.is_alias_for = klass
- a = RDoc::Constant.new 'A', '', ''
- top_level.add_module_alias klass, klass.name, a, top_level
+ top_level.add_module_alias klass, 'A', top_level
object.add_constant const
diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb
index fad182722a..d189ac1c4b 100644
--- a/test/rdoc/test_rdoc_code_object.rb
+++ b/test/rdoc/test_rdoc_code_object.rb
@@ -213,7 +213,7 @@ class TestRDocCodeObject < XrefTestCase
end
def test_file_name
- assert_nil @co.file_name
+ assert_equal nil, @co.file_name
@co.record_location @store.add_file 'lib/file.rb'
diff --git a/test/rdoc/test_rdoc_comment.rb b/test/rdoc/test_rdoc_comment.rb
index d3c16bceca..567daae51c 100644
--- a/test/rdoc/test_rdoc_comment.rb
+++ b/test/rdoc/test_rdoc_comment.rb
@@ -1,7 +1,7 @@
# coding: us-ascii
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocComment < RDoc::TestCase
@@ -77,7 +77,7 @@ call-seq:
comment.extract_call_seq m
- assert_nil m.call_seq
+ assert_equal nil, m.call_seq
end
def test_extract_call_seq_no_blank
@@ -241,7 +241,6 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
@comment.text = <<-TEXT
# comment
TEXT
- @comment.language = :ruby
assert_same @comment, @comment.normalize
@@ -294,7 +293,7 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
c = RDoc::Comment.new nil, @top_level
c.document = @RM::Document.new
- e = assert_raise RDoc::Error do
+ e = assert_raises RDoc::Error do
c.text = 'other'
end
diff --git a/test/rdoc/test_rdoc_constant.rb b/test/rdoc/test_rdoc_constant.rb
index 79dcdad57e..e715131579 100644
--- a/test/rdoc/test_rdoc_constant.rb
+++ b/test/rdoc/test_rdoc_constant.rb
@@ -118,7 +118,7 @@ class TestRDocConstant < XrefTestCase
assert_equal cm, loaded.parent
assert_equal section, loaded.section
- assert loaded.display?
+ assert loaded.display?
end
def test_marshal_load_version_0
diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb
index ecdb3cbd67..a7d6a58716 100644
--- a/test/rdoc/test_rdoc_context.rb
+++ b/test/rdoc/test_rdoc_context.rb
@@ -14,10 +14,10 @@ class TestRDocContext < XrefTestCase
assert_empty @context.in_files
assert_equal 'unknown', @context.name
assert_equal '', @context.comment
- assert_nil @context.parent
+ assert_equal nil, @context.parent
assert_equal :public, @context.visibility
assert_equal 1, @context.sections.length
- assert_nil @context.temporary_section
+ assert_equal nil, @context.temporary_section
assert_empty @context.classes_hash
assert_empty @context.modules_hash
@@ -232,7 +232,7 @@ class TestRDocContext < XrefTestCase
meth2.record_location @store.add_file 'second.rb'
meth2.comment = comment 'second'
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
@context.add_method meth2
end
@@ -260,7 +260,7 @@ class TestRDocContext < XrefTestCase
meth2.record_location @store.add_file 'second.rb'
meth2.comment = comment 'second'
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
@context.add_method meth2
end
@@ -280,8 +280,7 @@ class TestRDocContext < XrefTestCase
def test_add_module_alias
tl = @store.add_file 'file.rb'
- c4 = RDoc::Constant.new 'C4', '', ''
- c3_c4 = @c2.add_module_alias @c2_c3, @c2_c3.name, c4, tl
+ c3_c4 = @c2.add_module_alias @c2_c3, 'C4', tl
alias_constant = @c2.constants.first
@@ -299,8 +298,7 @@ class TestRDocContext < XrefTestCase
object = top_level.add_class RDoc::NormalClass, 'Object'
- a = RDoc::Constant.new 'A', '', ''
- top_level.add_module_alias klass, klass.name, a, top_level
+ top_level.add_module_alias klass, 'A', top_level
refute_empty object.constants
@@ -514,7 +512,7 @@ class TestRDocContext < XrefTestCase
end
def test_find_attribute_named
- assert_nil @c1.find_attribute_named('none')
+ assert_equal nil, @c1.find_attribute_named('none')
assert_equal 'R', @c1.find_attribute_named('attr').rw
assert_equal 'R', @c1.find_attribute_named('attr_reader').rw
assert_equal 'W', @c1.find_attribute_named('attr_writer').rw
@@ -522,7 +520,7 @@ class TestRDocContext < XrefTestCase
end
def test_find_class_method_named
- assert_nil @c1.find_class_method_named('none')
+ assert_equal nil, @c1.find_class_method_named('none')
m = @c1.find_class_method_named('m')
assert_instance_of RDoc::AnyMethod, m
@@ -530,23 +528,23 @@ class TestRDocContext < XrefTestCase
end
def test_find_constant_named
- assert_nil @c1.find_constant_named('NONE')
+ assert_equal nil, @c1.find_constant_named('NONE')
assert_equal ':const', @c1.find_constant_named('CONST').value
end
def test_find_enclosing_module_named
- assert_nil @c2_c3.find_enclosing_module_named('NONE')
+ assert_equal nil, @c2_c3.find_enclosing_module_named('NONE')
assert_equal @c1, @c2_c3.find_enclosing_module_named('C1')
assert_equal @c2, @c2_c3.find_enclosing_module_named('C2')
end
def test_find_file_named
- assert_nil @c1.find_file_named('nonexistent.rb')
+ assert_equal nil, @c1.find_file_named('nonexistent.rb')
assert_equal @xref_data, @c1.find_file_named(@file_name)
end
def test_find_instance_method_named
- assert_nil @c1.find_instance_method_named('none')
+ assert_equal nil, @c1.find_instance_method_named('none')
m = @c1.find_instance_method_named('m')
assert_instance_of RDoc::AnyMethod, m
@@ -561,14 +559,6 @@ class TestRDocContext < XrefTestCase
assert_equal @c2_c3, @c2.find_local_symbol('C3')
end
- def test_find_method
- loaded_c2 = Marshal.load Marshal.dump @c2
- assert_equal @c2_a, loaded_c2.find_method('a', false)
- assert_equal @c2_b, loaded_c2.find_method('b', false)
- assert_equal @c2_a, loaded_c2.find_method('a', nil)
- assert_equal @c2_b, loaded_c2.find_method('b', nil)
- end
-
def test_find_method_named
assert_equal true, @c1.find_method_named('m').singleton
end
@@ -660,7 +650,7 @@ class TestRDocContext < XrefTestCase
'instance' => {
:private => [],
:protected => [],
- :public => [@c1_plus, @c1_m],
+ :public => [@c1_m],
},
'class' => {
:private => [],
diff --git a/test/rdoc/test_rdoc_context_section.rb b/test/rdoc/test_rdoc_context_section.rb
index c520ad05a5..ff88b9b66a 100644
--- a/test/rdoc/test_rdoc_context_section.rb
+++ b/test/rdoc/test_rdoc_context_section.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocContextSection < RDoc::TestCase
@@ -11,7 +11,7 @@ class TestRDocContextSection < RDoc::TestCase
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
@S = RDoc::Context::Section
- @s = @S.new @klass, 'section', comment('# comment', @top_level, :ruby)
+ @s = @S.new @klass, 'section', comment('# comment', @top_level)
end
def test_add_comment
@@ -144,7 +144,7 @@ class TestRDocContextSection < RDoc::TestCase
end
def test_sequence
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
assert_match(/\ASEC\d{5}\Z/, @s.sequence)
end
diff --git a/test/rdoc/test_rdoc_cross_reference.rb b/test/rdoc/test_rdoc_cross_reference.rb
index 183de0930d..a294553704 100644
--- a/test/rdoc/test_rdoc_cross_reference.rb
+++ b/test/rdoc/test_rdoc_cross_reference.rb
@@ -107,24 +107,18 @@ class TestRDocCrossReference < XrefTestCase
end
def test_resolve_method
- assert_ref @c1__m, 'm'
- assert_ref @c1__m, '::m'
- assert_ref @c1_m, '#m'
- assert_ref @c1_plus, '#+'
-
- assert_ref @c1_m, 'C1#m'
- assert_ref @c1_plus, 'C1#+'
- assert_ref @c1__m, 'C1.m'
- assert_ref @c1__m, 'C1::m'
+ assert_ref @c1__m, 'm'
+ assert_ref @c1_m, '#m'
+ assert_ref @c1__m, '::m'
+
+ assert_ref @c1_m, 'C1#m'
+ assert_ref @c1__m, 'C1.m'
+ assert_ref @c1__m, 'C1::m'
assert_ref @c1_m, 'C1#m'
assert_ref @c1_m, 'C1#m()'
assert_ref @c1_m, 'C1#m(*)'
- assert_ref @c1_plus, 'C1#+'
- assert_ref @c1_plus, 'C1#+()'
- assert_ref @c1_plus, 'C1#+(*)'
-
assert_ref @c1__m, 'C1.m'
assert_ref @c1__m, 'C1.m()'
assert_ref @c1__m, 'C1.m(*)'
@@ -145,15 +139,6 @@ class TestRDocCrossReference < XrefTestCase
assert_ref @c2_c3_m, '::C2::C3#m(*)'
end
- def test_resolve_the_same_name_in_instance_and_class_method
- assert_ref @c9_a_i_foo, 'C9::A#foo'
- assert_ref @c9_a_c_bar, 'C9::A::bar'
- assert_ref @c9_b_c_foo, 'C9::B::foo'
- assert_ref @c9_b_i_bar, 'C9::B#bar'
- assert_ref @c9_b_c_foo, 'C9::B.foo'
- assert_ref @c9_a_c_bar, 'C9::B.bar'
- end
-
def test_resolve_method_equals3
m = RDoc::AnyMethod.new '', '==='
@c1.add_method m
@@ -162,7 +147,8 @@ class TestRDocCrossReference < XrefTestCase
end
def test_resolve_page
- page = @store.add_file 'README.txt', parser: RDoc::Parser::Simple
+ page = @store.add_file 'README.txt'
+ page.parser = RDoc::Parser::Simple
assert_ref page, 'README'
end
diff --git a/test/rdoc/test_rdoc_encoding.rb b/test/rdoc/test_rdoc_encoding.rb
index 58536b035e..9d9ded4bbd 100644
--- a/test/rdoc/test_rdoc_encoding.rb
+++ b/test/rdoc/test_rdoc_encoding.rb
@@ -1,7 +1,7 @@
# coding: US-ASCII
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocEncoding < RDoc::TestCase
@@ -31,7 +31,7 @@ class TestRDocEncoding < RDoc::TestCase
@tempfile.flush
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
- assert_equal "# coding: utf-8\nhi everybody", contents
+ assert_equal "hi everybody", contents
assert_equal Encoding::UTF_8, contents.encoding
end
@@ -45,7 +45,7 @@ class TestRDocEncoding < RDoc::TestCase
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
assert_equal Encoding::UTF_8, contents.encoding
- assert_equal "# coding: ISO-8859-1\nhi \u00e9verybody", contents.sub("\r", '')
+ assert_equal "hi \u00e9verybody", contents.sub("\r", '')
end
def test_class_read_file_encoding_fail
@@ -54,7 +54,7 @@ class TestRDocEncoding < RDoc::TestCase
contents = :junk
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII
end
@@ -65,13 +65,13 @@ class TestRDocEncoding < RDoc::TestCase
def test_class_read_file_encoding_fancy
expected = "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody"
- expected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8
+ exptected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8
@tempfile.write expected
@tempfile.flush
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
- assert_equal "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody", contents
+ assert_equal "hi everybody", contents
assert_equal Encoding::UTF_8, contents.encoding
end
@@ -81,7 +81,7 @@ class TestRDocEncoding < RDoc::TestCase
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII, true
- assert_equal "# coding: utf-8\n?", contents
+ assert_equal '?', contents
assert_equal Encoding::US_ASCII, contents.encoding
end
@@ -97,7 +97,7 @@ class TestRDocEncoding < RDoc::TestCase
@tempfile.flush
contents = :junk
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
end
@@ -124,58 +124,108 @@ class TestRDocEncoding < RDoc::TestCase
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
- expected = "# coding: ISO-2022-JP\n:\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:"
+ expected = ":\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:"
expected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8
assert_equal expected, contents
assert_equal Encoding::UTF_8, contents.encoding
end
- def test_class_detect_encoding
+ def test_class_set_encoding
s = "# coding: UTF-8\n"
- encoding = RDoc::Encoding.detect_encoding s
+ s = RDoc::Encoding.set_encoding s
# sanity check for 1.8
- assert_equal Encoding::UTF_8, encoding
+ assert_equal Encoding::UTF_8, s.encoding
s = "#!/bin/ruby\n# coding: UTF-8\n"
- encoding = RDoc::Encoding.detect_encoding s
+ s = RDoc::Encoding.set_encoding s
- assert_equal Encoding::UTF_8, encoding
+ assert_equal Encoding::UTF_8, s.encoding
s = "<?xml version='1.0' encoding='UTF-8'?>\n"
- encoding = RDoc::Encoding.detect_encoding s
+ s = RDoc::Encoding.set_encoding s
- assert_equal Encoding::UTF_8, encoding
+ assert_equal Encoding::UTF_8, s.encoding
s = "<?xml version='1.0' encoding=\"UTF-8\"?>\n"
- encoding = RDoc::Encoding.detect_encoding s
+ s = RDoc::Encoding.set_encoding s
+
+ assert_equal Encoding::UTF_8, s.encoding
+ end
+
+ def test_class_set_encoding_strip
+ s = "# coding: UTF-8\n# more comments"
+
+ s = RDoc::Encoding.set_encoding s
+
+ assert_equal "# more comments", s
+
+ s = "#!/bin/ruby\n# coding: UTF-8\n# more comments"
+
+ s = RDoc::Encoding.set_encoding s
- assert_equal Encoding::UTF_8, encoding
+ assert_equal "#!/bin/ruby\n# more comments", s
end
def test_class_set_encoding_bad
s = ""
- encoding = RDoc::Encoding.detect_encoding s
+ expected = s.encoding
+ s = RDoc::Encoding.set_encoding s
- assert_nil encoding
+ assert_equal expected, s.encoding
s = "# vim:set fileencoding=utf-8:\n"
- encoding = RDoc::Encoding.detect_encoding s
+ expected = s.encoding
+ s = RDoc::Encoding.set_encoding s
- assert_nil encoding
+ assert_equal expected, s.encoding
s = "# vim:set fileencoding=utf-8:\n"
- encoding = RDoc::Encoding.detect_encoding s
+ expected = s.encoding
+ s = RDoc::Encoding.set_encoding s
- assert_nil encoding
+ assert_equal expected, s.encoding
- assert_raise ArgumentError do
- s = RDoc::Encoding.detect_encoding "# -*- encoding: undecided -*-\n"
+ assert_raises ArgumentError do
+ s = RDoc::Encoding.set_encoding "# -*- encoding: undecided -*-\n"
end
end
+ def test_skip_frozen_string_literal
+ expected = "# frozen_string_literal: true\nhi everybody"
+
+ @tempfile.write expected
+ @tempfile.flush
+
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
+ assert_equal "hi everybody", contents
+ assert_equal Encoding::UTF_8, contents.encoding
+ end
+
+ def test_skip_frozen_string_literal_after_coding
+ expected = "# coding: utf-8\n# frozen-string-literal: false\nhi everybody"
+
+ @tempfile.write expected
+ @tempfile.flush
+
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
+ assert_equal "hi everybody", contents
+ assert_equal Encoding::UTF_8, contents.encoding
+ end
+
+ def test_skip_frozen_string_literal_before_coding
+ expected = "# frozen_string_literal: true\n# coding: utf-8\nhi everybody"
+
+ @tempfile.write expected
+ @tempfile.flush
+
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
+ assert_equal "hi everybody", contents
+ assert_equal Encoding::UTF_8, contents.encoding
+ end
+
def test_sanity
assert_equal Encoding::US_ASCII, ''.encoding,
'If this file is not ASCII tests may incorrectly pass'
diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb
index f5858bce6e..c004bb271e 100644
--- a/test/rdoc/test_rdoc_generator_darkfish.rb
+++ b/test/rdoc/test_rdoc_generator_darkfish.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocGeneratorDarkfish < RDoc::TestCase
@@ -39,7 +39,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
@top_level.add_constant @alias_constant
- @klass.add_module_alias @klass, @klass.name, @alias_constant, @top_level
+ @klass.add_module_alias @klass, 'A', @top_level
@meth = RDoc::AnyMethod.new nil, 'method'
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
@@ -135,7 +135,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
end
def test_install_rdoc_static_file
- src = Pathname File.expand_path(__FILE__, @pwd)
+ src = Pathname(__FILE__)
dst = File.join @tmpdir, File.basename(src)
options = {}
diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb
index 66d15d1848..6cb5463d29 100644
--- a/test/rdoc/test_rdoc_generator_json_index.rb
+++ b/test/rdoc/test_rdoc_generator_json_index.rb
@@ -1,14 +1,14 @@
# coding: US-ASCII
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocGeneratorJsonIndex < RDoc::TestCase
def setup
super
- @tmpdir = Dir.mktmpdir "test_rdoc_generator_darkfish_#{$$}_"
+ @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_darkfish_#{$$}"
FileUtils.mkdir_p @tmpdir
@options = RDoc::Options.new
@@ -95,19 +95,6 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
assert_file 'js/navigation.js'
assert_file 'js/search_index.js'
- srcdir = File.expand_path('lib/rdoc', @pwd)
- if !File.directory? srcdir
- # for Ruby core repository
- srcdir = File.expand_path("../../../lib/rdoc", __FILE__)
- end
-
- orig_file = Pathname(File.join srcdir, 'generator/template/json_index/js/navigation.js')
- generated_file = Pathname(File.join @tmpdir, 'js/navigation.js')
-
- # This is dirty hack on JRuby for MiniTest 4
- assert orig_file.mtime.inspect == generated_file.mtime.inspect,
- '.js files should be the same timestamp of original'
-
json = File.read 'js/search_index.js'
json =~ /\Avar search_data = /
@@ -150,25 +137,11 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
assert_equal expected, index
end
- def test_generate_search_index_with_reproducible_builds
- backup_epoch = ENV['SOURCE_DATE_EPOCH']
- ruby_birthday = Time.parse 'Wed, 24 Feb 1993 21:00:00 +0900'
- ENV['SOURCE_DATE_EPOCH'] = ruby_birthday.to_i.to_s
-
- @g.generate
-
- assert_file 'js/search_index.js'
- generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js')
- assert_equal ruby_birthday, generated_search_index.mtime
-
- ENV['SOURCE_DATE_EPOCH'] = backup_epoch
- end
-
def test_generate_gzipped
begin
require 'zlib'
rescue LoadError
- omit "no zlib"
+ skip "no zlib"
end
@g.generate
@g.generate_gzipped
diff --git a/test/rdoc/test_rdoc_generator_markup.rb b/test/rdoc/test_rdoc_generator_markup.rb
index 5491b7c61e..d13f5119be 100644
--- a/test/rdoc/test_rdoc_generator_markup.rb
+++ b/test/rdoc/test_rdoc_generator_markup.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocGeneratorMarkup < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_generator_pot.rb b/test/rdoc/test_rdoc_generator_pot.rb
index bafe9ecca5..5675f96b75 100644
--- a/test/rdoc/test_rdoc_generator_pot.rb
+++ b/test/rdoc/test_rdoc_generator_pot.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocGeneratorPOT < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_generator_pot_po.rb b/test/rdoc/test_rdoc_generator_pot_po.rb
index 7696a1f5b1..8786f632c0 100644
--- a/test/rdoc/test_rdoc_generator_pot_po.rb
+++ b/test/rdoc/test_rdoc_generator_pot_po.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocGeneratorPOTPO < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_generator_pot_po_entry.rb b/test/rdoc/test_rdoc_generator_pot_po_entry.rb
index d3d6271b23..5c24c2d70d 100644
--- a/test/rdoc/test_rdoc_generator_pot_po_entry.rb
+++ b/test/rdoc/test_rdoc_generator_pot_po_entry.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocGeneratorPOTPOEntry < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_generator_ri.rb b/test/rdoc/test_rdoc_generator_ri.rb
index 195c0d2482..02bcee8904 100644
--- a/test/rdoc/test_rdoc_generator_ri.rb
+++ b/test/rdoc/test_rdoc_generator_ri.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocGeneratorRI < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_i18n_locale.rb b/test/rdoc/test_rdoc_i18n_locale.rb
index 746d659c67..ff9836f9a6 100644
--- a/test/rdoc/test_rdoc_i18n_locale.rb
+++ b/test/rdoc/test_rdoc_i18n_locale.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocI18nLocale < RDoc::TestCase
@@ -23,16 +23,16 @@ class TestRDocI18nLocale < RDoc::TestCase
end
def test_load_nonexistent_po
- locale = File.join(@locale_dir, 'nonexsitent-locale')
- refute_file locale
- refute @locale.load(locale)
+ File.stub(:exist?, false) do
+ refute @locale.load('nonexsitent-locale')
+ end
end
def test_load_existent_po
begin
require 'gettext/po_parser'
rescue LoadError
- omit 'gettext gem is not found'
+ skip 'gettext gem is not found'
end
fr_locale_dir = File.join @locale_dir, 'fr'
diff --git a/test/rdoc/test_rdoc_i18n_text.rb b/test/rdoc/test_rdoc_i18n_text.rb
index 89b7e97708..be5ff581f5 100644
--- a/test/rdoc/test_rdoc_i18n_text.rb
+++ b/test/rdoc/test_rdoc_i18n_text.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocI18nText < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markdown.rb b/test/rdoc/test_rdoc_markdown.rb
index 021d94297b..99f8abf5ab 100644
--- a/test/rdoc/test_rdoc_markdown.rb
+++ b/test/rdoc/test_rdoc_markdown.rb
@@ -1,7 +1,7 @@
# coding: UTF-8
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
require 'rdoc/markup/block_quote'
require 'rdoc/markdown'
@@ -717,7 +717,7 @@ Some text. ^[With a footnote]
def test_parse_note_no_notes
@parser.notes = false
- assert_raise RDoc::Markdown::ParseError do
+ assert_raises RDoc::Markdown::ParseError do
parse "Some text.[^1]"
end
end
diff --git a/test/rdoc/test_rdoc_markdown_test.rb b/test/rdoc/test_rdoc_markdown_test.rb
index 0ecd000136..8664ac45a0 100644
--- a/test/rdoc/test_rdoc_markdown_test.rb
+++ b/test/rdoc/test_rdoc_markdown_test.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'minitest/autorun'
require 'pp'
require 'rdoc'
@@ -744,7 +744,7 @@ foo
"I strongly recommend against using any `<blink>` tags.\n",
"\n",
"I wish SmartyPants used named entities like `&mdash;`\n",
- "instead of decimal-encoded entities like `&#8212;`.\n"),
+ "instead of decimal-encoded entites like `&#8212;`.\n"),
para("Output:"),
@@ -753,7 +753,7 @@ foo
"\n",
"<p>I wish SmartyPants used named entities like\n",
"<code>&amp;mdash;</code> instead of decimal-encoded\n",
- "entities like <code>&amp;#8212;</code>.</p>\n"),
+ "entites like <code>&amp;#8212;</code>.</p>\n"),
para("To specify an entire block of pre-formatted code, indent every line of\n" +
"the block by 4 spaces or 1 tab. Just like with code spans, <code>&</code>, <code><</code>,\n" +
diff --git a/test/rdoc/test_rdoc_markup.rb b/test/rdoc/test_rdoc_markup.rb
index b9bdafab2a..8e4e8b968e 100644
--- a/test/rdoc/test_rdoc_markup.rb
+++ b/test/rdoc/test_rdoc_markup.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkup < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb
index a180666867..a939623e01 100644
--- a/test/rdoc/test_rdoc_markup_attribute_manager.rb
+++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupAttributeManager < RDoc::TestCase
@@ -36,12 +36,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
end
def crossref(text)
- crossref_bitmap = @am.attributes.bitmap_for(:_REGEXP_HANDLING_) |
+ crossref_bitmap = @am.attributes.bitmap_for(:_SPECIAL_) |
@am.attributes.bitmap_for(:CROSSREF)
- [ @am.changed_attribute_by_name([], [:CROSSREF, :_REGEXP_HANDLING_]),
- RDoc::Markup::RegexpHandling.new(crossref_bitmap, text),
- @am.changed_attribute_by_name([:CROSSREF, :_REGEXP_HANDLING_], [])
+ [ @am.changed_attribute_by_name([], [:CROSSREF, :_SPECIAL_]),
+ RDoc::Markup::Special.new(crossref_bitmap, text),
+ @am.changed_attribute_by_name([:CROSSREF, :_SPECIAL_], [])
]
end
@@ -58,12 +58,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert(tags.has_key?("test"))
end
- def test_add_regexp_handling
- @am.add_regexp_handling "WikiWord", :WIKIWORD
- regexp_handlings = @am.regexp_handlings
+ def test_add_special
+ @am.add_special "WikiWord", :WIKIWORD
+ specials = @am.special
- assert_equal 1, regexp_handlings.size
- assert regexp_handlings.assoc "WikiWord"
+ assert_equal 1, specials.size
+ assert specials.assoc "WikiWord"
end
def test_add_word_pair
@@ -75,7 +75,7 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
end
def test_add_word_pair_angle
- e = assert_raise ArgumentError do
+ e = assert_raises ArgumentError do
@am.add_word_pair '<', '>', 'angles'
end
@@ -83,7 +83,7 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
end
def test_add_word_pair_invalid
- assert_raise ArgumentError do
+ assert_raises ArgumentError do
@am.add_word_pair("<", "<", :TEST)
end
end
@@ -340,8 +340,8 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.flow(str))
end
- def test_regexp_handling
- @am.add_regexp_handling(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF)
+ def test_special
+ @am.add_special(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF)
#
# The apostrophes in "cats'" and "dogs'" suppress the flagging of these
@@ -358,8 +358,6 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.flow("#fred dogs'"))
assert_equal(["cats' ", crossref("#fred")].flatten, @am.flow("cats' #fred"))
-
- assert_equal(["(", crossref("#fred"), ")"].flatten, @am.flow("(#fred)"))
end
def test_tt_html
diff --git a/test/rdoc/test_rdoc_markup_attributes.rb b/test/rdoc/test_rdoc_markup_attributes.rb
index 0dfd72bdb6..1fad62208c 100644
--- a/test/rdoc/test_rdoc_markup_attributes.rb
+++ b/test/rdoc/test_rdoc_markup_attributes.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupAttributes < RDoc::TestCase
@@ -19,10 +19,10 @@ class TestRDocMarkupAttributes < RDoc::TestCase
@as.bitmap_for 'two'
@as.bitmap_for 'three'
- assert_equal 'none', @as.as_string(0)
- assert_equal '_REGEXP_HANDLING_', @as.as_string(1)
- assert_equal 'two', @as.as_string(2)
- assert_equal '_REGEXP_HANDLING_,two', @as.as_string(3)
+ assert_equal 'none', @as.as_string(0)
+ assert_equal '_SPECIAL_', @as.as_string(1)
+ assert_equal 'two', @as.as_string(2)
+ assert_equal '_SPECIAL_,two', @as.as_string(3)
end
def test_each_name_of
diff --git a/test/rdoc/test_rdoc_markup_document.rb b/test/rdoc/test_rdoc_markup_document.rb
index 3db834b85d..d817f1b9aa 100644
--- a/test/rdoc/test_rdoc_markup_document.rb
+++ b/test/rdoc/test_rdoc_markup_document.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupDocument < RDoc::TestCase
@@ -34,7 +34,7 @@ class TestRDocMarkupDocument < RDoc::TestCase
assert_empty @d
- assert_raise ArgumentError do
+ assert_raises ArgumentError do
@d << 'hi'
end
end
diff --git a/test/rdoc/test_rdoc_markup_formatter.rb b/test/rdoc/test_rdoc_markup_formatter.rb
index 8702db379d..0e7f72fb16 100644
--- a/test/rdoc/test_rdoc_markup_formatter.rb
+++ b/test/rdoc/test_rdoc_markup_formatter.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupFormatter < RDoc::TestCase
@@ -19,8 +19,8 @@ class TestRDocMarkupFormatter < RDoc::TestCase
convert_flow @am.flow text.dup
end
- def handle_regexp_CAPS target
- "handled #{target.text}"
+ def handle_special_CAPS special
+ "handled #{special.text}"
end
def start_accepting
@@ -37,16 +37,16 @@ class TestRDocMarkupFormatter < RDoc::TestCase
super
@markup = @RM.new
- @markup.add_regexp_handling(/[A-Z]+/, :CAPS)
+ @markup.add_special(/[A-Z]+/, :CAPS)
@attribute_manager = @markup.attribute_manager
@attributes = @attribute_manager.attributes
@to = ToTest.new @markup
- @caps = @attributes.bitmap_for :CAPS
- @regexp_handling = @attributes.bitmap_for :_REGEXP_HANDLING_
- @tt = @attributes.bitmap_for :TT
+ @caps = @attributes.bitmap_for :CAPS
+ @special = @attributes.bitmap_for :_SPECIAL_
+ @tt = @attributes.bitmap_for :TT
end
def test_class_gen_relative_url
@@ -62,19 +62,19 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'a/c.html', gen('a.html', 'a/c.html')
end
- def regexp_handling_names
- @attribute_manager.regexp_handlings.map do |_, mask|
+ def special_names
+ @attribute_manager.special.map do |_, mask|
@attributes.as_string mask
end
end
- def test_add_regexp_handling_RDOCLINK
- @to.add_regexp_handling_RDOCLINK
+ def test_add_special_RDOCLINK
+ @to.add_special_RDOCLINK
- assert_includes regexp_handling_names, 'RDOCLINK'
+ assert_includes special_names, 'RDOCLINK'
- def @to.handle_regexp_RDOCLINK target
- "<#{target.text}>"
+ def @to.handle_special_RDOCLINK special
+ "<#{special.text}>"
end
document = doc(para('{foo}[rdoc-label:bar].'))
@@ -84,13 +84,13 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal '{foo}[<rdoc-label:bar>].', formatted
end
- def test_add_regexp_handling_TIDYLINK
- @to.add_regexp_handling_TIDYLINK
+ def test_add_special_TIDYLINK
+ @to.add_special_TIDYLINK
- assert_includes regexp_handling_names, 'TIDYLINK'
+ assert_includes special_names, 'TIDYLINK'
- def @to.handle_regexp_TIDYLINK target
- "<#{target.text}>"
+ def @to.handle_special_TIDYLINK special
+ "<#{special.text}>"
end
document = doc(para('foo[rdoc-label:bar].'))
@@ -111,15 +111,15 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'http', scheme
assert_equal 'example/foo', url
- assert_nil id
+ assert_equal nil, id
end
def test_parse_url_anchor
scheme, url, id = @to.parse_url '#foottext-1'
- assert_nil scheme
+ assert_equal nil, scheme
assert_equal '#foottext-1', url
- assert_nil id
+ assert_equal nil, id
end
def test_parse_url_link
@@ -127,7 +127,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'link', scheme
assert_equal 'README.txt', url
- assert_nil id
+ assert_equal nil, id
end
def test_parse_url_link_id
@@ -135,7 +135,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'link', scheme
assert_equal 'README.txt#label-foo', url
- assert_nil id
+ assert_equal nil, id
end
def test_parse_url_rdoc_label
@@ -143,7 +143,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'link', scheme
assert_equal '#foo', url
- assert_nil id
+ assert_equal nil, id
scheme, url, id = @to.parse_url 'rdoc-label:foo:bar'
@@ -157,19 +157,20 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'http', scheme
assert_equal 'http://example/foo', url
- assert_nil id
+ assert_equal nil, id
scheme, url, id = @to.parse_url 'https://example/foo'
assert_equal 'https', scheme
assert_equal 'https://example/foo', url
- assert_nil id
+ assert_equal nil, id
end
- def test_convert_tt_regexp_handling
+ def test_convert_tt_special
converted = @to.convert '<code>AAA</code>'
assert_equal '<code>AAA</code>', converted
end
end
+
diff --git a/test/rdoc/test_rdoc_markup_hard_break.rb b/test/rdoc/test_rdoc_markup_hard_break.rb
index adebfdc311..d93d52eeda 100644
--- a/test/rdoc/test_rdoc_markup_hard_break.rb
+++ b/test/rdoc/test_rdoc_markup_hard_break.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupHardBreak < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_heading.rb b/test/rdoc/test_rdoc_markup_heading.rb
index 05a8e005ba..33e29e90e6 100644
--- a/test/rdoc/test_rdoc_markup_heading.rb
+++ b/test/rdoc/test_rdoc_markup_heading.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupHeading < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_include.rb b/test/rdoc/test_rdoc_markup_include.rb
index 9126526b73..28712fa7ed 100644
--- a/test/rdoc/test_rdoc_markup_include.rb
+++ b/test/rdoc/test_rdoc_markup_include.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupInclude < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_indented_paragraph.rb b/test/rdoc/test_rdoc_markup_indented_paragraph.rb
index 7b5758998f..53d44dcec2 100644
--- a/test/rdoc/test_rdoc_markup_indented_paragraph.rb
+++ b/test/rdoc/test_rdoc_markup_indented_paragraph.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupIndentedParagraph < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_paragraph.rb b/test/rdoc/test_rdoc_markup_paragraph.rb
index ca89a74fc3..dce3ed8efd 100644
--- a/test/rdoc/test_rdoc_markup_paragraph.rb
+++ b/test/rdoc/test_rdoc_markup_paragraph.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupParagraph < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_parser.rb b/test/rdoc/test_rdoc_markup_parser.rb
index 6fccf09612..fa4730a06f 100644
--- a/test/rdoc/test_rdoc_markup_parser.rb
+++ b/test/rdoc/test_rdoc_markup_parser.rb
@@ -1,7 +1,7 @@
# coding: utf-8
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupParser < RDoc::TestCase
@@ -22,6 +22,15 @@ class TestRDocMarkupParser < RDoc::TestCase
assert_equal @RM::Heading.new(3, 'heading three'), parser.build_heading(3)
end
+ def test_char_pos
+ parser = @RMP.new
+ s = parser.setup_scanner 'cät'
+
+ s.scan(/\S+/)
+
+ assert_equal 3, parser.char_pos(s.pos)
+ end
+
def test_get
parser = util_parser
@@ -691,6 +700,7 @@ B. l2
def test_parse_trailing_cr
expected = [ @RM::Paragraph.new('Text') ]
+ # FIXME hangs the parser:
assert_equal expected, @RMP.parse("Text\r").parts
end
@@ -1035,41 +1045,6 @@ the time
assert_equal expected, @RMP.parse(" 1\n 2\n\n 3").parts
end
- def test_parse_block_quote
- expected = [
- @RM::BlockQuote.new(@RM::Paragraph.new("foo"))
- ]
- assert_equal expected, @RMP.parse(<<-DOC).parts
->>>
- foo
- DOC
-
- expected = [
- @RM::BlockQuote.new(@RM::Paragraph.new("foo"),
- @RM::Verbatim.new("code\n"),
- @RM::Paragraph.new("bar"))
- ]
- assert_equal expected, @RMP.parse(<<-DOC).parts
->>>
- foo
- code
- bar
- DOC
-
- expected = [
- @RM::BlockQuote.new(@RM::Paragraph.new("foo"),
- @RM::BlockQuote.new(@RM::Paragraph.new("bar")),
- @RM::Paragraph.new("zot"))
- ]
- assert_equal expected, @RMP.parse(<<-DOC).parts
->>>
- foo
- >>>
- bar
- zot
- DOC
- end
-
def test_peek_token
parser = util_parser
@@ -1087,13 +1062,13 @@ the time
assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token
- assert_raise RDoc::Markup::Parser::ParseError do
+ assert_raises RDoc::Markup::Parser::ParseError do
parser.skip :NONE
end
assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token
- assert_nil parser.skip(:NONE, false)
+ assert_equal nil, parser.skip(:NONE, false)
assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token
end
@@ -1637,6 +1612,15 @@ Example heading:
assert_equal expected, @RMP.tokenize(str)
end
+ def test_token_pos
+ parser = @RMP.new
+ s = parser.setup_scanner 'cät'
+
+ s.scan(/\S+/)
+
+ assert_equal [3, 0], parser.token_pos(s.pos)
+ end
+
# HACK move to Verbatim test case
def test_verbatim_normalize
v = @RM::Verbatim.new "foo\n", "\n", "\n", "bar\n"
@@ -1661,7 +1645,7 @@ Example heading:
assert_equal [:HEADER, 1, 0, 0], parser.peek_token
- assert_raise @RMP::Error do
+ assert_raises @RMP::Error do
parser.unget
end
diff --git a/test/rdoc/test_rdoc_markup_pre_process.rb b/test/rdoc/test_rdoc_markup_pre_process.rb
index cc5bdc3abf..887ff6de9c 100644
--- a/test/rdoc/test_rdoc_markup_pre_process.rb
+++ b/test/rdoc/test_rdoc_markup_pre_process.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupPreProcess < RDoc::TestCase
@@ -73,7 +73,7 @@ contents of a string.
def test_include_file_in_other_directory
content = nil
- out, err = capture_output do
+ out, err = capture_io do
content = @pp.include_file "test.txt", '', nil
end
diff --git a/test/rdoc/test_rdoc_markup_raw.rb b/test/rdoc/test_rdoc_markup_raw.rb
index c7795b24e1..aaf4e48439 100644
--- a/test/rdoc/test_rdoc_markup_raw.rb
+++ b/test/rdoc/test_rdoc_markup_raw.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupRaw < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_to_ansi.rb b/test/rdoc/test_rdoc_markup_to_ansi.rb
index 1d1fc7db46..d06ad98fa3 100644
--- a/test/rdoc/test_rdoc_markup_to_ansi.rb
+++ b/test/rdoc/test_rdoc_markup_to_ansi.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase
diff --git a/test/rdoc/test_rdoc_markup_to_bs.rb b/test/rdoc/test_rdoc_markup_to_bs.rb
index 7ebde481e6..9b798c92b3 100644
--- a/test/rdoc/test_rdoc_markup_to_bs.rb
+++ b/test/rdoc/test_rdoc_markup_to_bs.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToBs < RDoc::Markup::TextFormatterTestCase
diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb
index fb94269064..fa5828a007 100644
--- a/test/rdoc/test_rdoc_markup_to_html.rb
+++ b/test/rdoc/test_rdoc_markup_to_html.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@@ -395,7 +395,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_paragraph para("hello\n", "world\n")
- assert_equal "\n<p>hello world </p>\n", @to.res.join
+ assert_equal "\n<p>hello world</p>\n", @to.res.join
end
def test_accept_heading_output_decoration
@@ -727,18 +727,18 @@ EXPECTED
assert_equal '<img src="https://example.com/image.png" />', @to.gen_url('https://example.com/image.png', 'ignored')
end
- def test_handle_regexp_HYPERLINK_link
- target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt'
+ def test_handle_special_HYPERLINK_link
+ special = RDoc::Markup::Special.new 0, 'link:README.txt'
- link = @to.handle_regexp_HYPERLINK target
+ link = @to.handle_special_HYPERLINK special
assert_equal '<a href="README.txt">README.txt</a>', link
end
- def test_handle_regexp_HYPERLINK_irc
- target = RDoc::Markup::RegexpHandling.new 0, 'irc://irc.freenode.net/#ruby-lang'
+ def test_handle_special_HYPERLINK_irc
+ special = RDoc::Markup::Special.new 0, 'irc://irc.freenode.net/#ruby-lang'
- link = @to.handle_regexp_HYPERLINK target
+ link = @to.handle_special_HYPERLINK special
assert_equal '<a href="irc://irc.freenode.net/#ruby-lang">irc.freenode.net/#ruby-lang</a>', link
end
diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
index bac2569f87..73b76de4d9 100644
--- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb
+++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
@@ -14,31 +14,26 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
def test_convert_CROSSREF
result = @to.convert 'C1'
- assert_equal para("<a href=\"C1.html\"><code>C1</code></a>"), result
+ assert_equal para("<a href=\"C1.html\">C1</a>"), result
end
def test_convert_CROSSREF_label
result = @to.convert 'C1@foo'
- assert_equal para("<a href=\"C1.html#class-C1-label-foo\">foo at <code>C1</code></a>"), result
+ assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>"), result
result = @to.convert 'C1#m@foo'
- assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at <code>C1#m</code></a>"),
+ assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>"),
result
end
- def test_convert_CROSSREF_label_for_md
- result = @to.convert 'EXAMPLE@foo'
- assert_equal para("<a href=\"EXAMPLE_md.html#label-foo\">foo at <code>EXAMPLE</code></a>"), result
- end
-
def test_convert_CROSSREF_label_period
result = @to.convert 'C1@foo.'
- assert_equal para("<a href=\"C1.html#class-C1-label-foo\">foo at <code>C1</code></a>."), result
+ assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>."), result
end
def test_convert_CROSSREF_label_space
result = @to.convert 'C1@foo+bar'
- assert_equal para("<a href=\"C1.html#class-C1-label-foo+bar\">foo bar at <code>C1</code></a>"),
+ assert_equal para("<a href=\"C1.html#label-foo+bar\">foo bar at C1</a>"),
result
end
@@ -46,31 +41,31 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
@c1.add_section 'Section'
result = @to.convert 'C1@Section'
- assert_equal para("<a href=\"C1.html#Section\">Section at <code>C1</code></a>"), result
+ assert_equal para("<a href=\"C1.html#Section\">Section at C1</a>"), result
end
def test_convert_CROSSREF_constant
result = @to.convert 'C1::CONST'
- assert_equal para("<a href=\"C1.html#CONST\"><code>C1::CONST</code></a>"), result
+ assert_equal para("<a href=\"C1.html#CONST\">C1::CONST</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref
result = @to.convert 'rdoc-ref:C1'
- assert_equal para("<a href=\"C1.html\"><code>C1</code></a>"), result
+ assert_equal para("<a href=\"C1.html\">C1</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_method
result = @to.convert 'rdoc-ref:C1#m'
- assert_equal para("<a href=\"C1.html#method-i-m\"><code>C1#m</code></a>"), result
+ assert_equal para("<a href=\"C1.html#method-i-m\">#m</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_method_label
result = @to.convert 'rdoc-ref:C1#m@foo'
- assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at <code>C1#m</code></a>"),
+ assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>"),
result, 'rdoc-ref:C1#m@foo'
end
@@ -80,13 +75,13 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
result = @to.convert 'rdoc-ref:C1#%'
- assert_equal para("<a href=\"C1.html#method-i-25\"><code>C1#%</code></a>"), result
+ assert_equal para("<a href=\"C1.html#method-i-25\">#%</a>"), result
m.singleton = true
result = @to.convert 'rdoc-ref:C1::%'
- assert_equal para("<a href=\"C1.html#method-c-25\"><code>C1::%</code></a>"), result
+ assert_equal para("<a href=\"C1.html#method-c-25\">::%</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_method_percent_label
@@ -95,21 +90,21 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
result = @to.convert 'rdoc-ref:C1#%@f'
- assert_equal para("<a href=\"C1.html#method-i-25-label-f\">f at <code>C1#%</code></a>"),
+ assert_equal para("<a href=\"C1.html#method-i-25-label-f\">f at C1#%</a>"),
result
m.singleton = true
result = @to.convert 'rdoc-ref:C1::%@f'
- assert_equal para("<a href=\"C1.html#method-c-25-label-f\">f at <code>C1::%</code></a>"),
+ assert_equal para("<a href=\"C1.html#method-c-25-label-f\">f at C1::%</a>"),
result
end
def test_convert_RDOCLINK_rdoc_ref_label
result = @to.convert 'rdoc-ref:C1@foo'
- assert_equal para("<a href=\"C1.html#class-C1-label-foo\">foo at <code>C1</code></a>"), result,
+ assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>"), result,
'rdoc-ref:C1@foo'
end
@@ -121,66 +116,66 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
@to.gen_url('http://example', 'HTTP example')
end
- def test_handle_regexp_CROSSREF
- assert_equal "<a href=\"C2/C3.html\"><code>C2::C3</code></a>", REGEXP_HANDLING('C2::C3')
+ def test_handle_special_CROSSREF
+ assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", SPECIAL('C2::C3')
end
- def test_handle_regexp_CROSSREF_label
- assert_equal "<a href=\"C1.html#method-i-m-label-foo\">foo at <code>C1#m</code></a>",
- REGEXP_HANDLING('C1#m@foo')
+ def test_handle_special_CROSSREF_label
+ assert_equal "<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>",
+ SPECIAL('C1#m@foo')
end
- def test_handle_regexp_CROSSREF_show_hash_false
+ def test_handle_special_CROSSREF_show_hash_false
@to.show_hash = false
- assert_equal "<a href=\"C1.html#method-i-m\"><code>m</code></a>",
- REGEXP_HANDLING('#m')
+ assert_equal "<a href=\"C1.html#method-i-m\">m</a>",
+ SPECIAL('#m')
end
- def test_handle_regexp_HYPERLINK_rdoc
+ def test_handle_special_HYPERLINK_rdoc
readme = @store.add_file 'README.txt'
readme.parser = RDoc::Parser::Simple
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2
- link = @to.handle_regexp_HYPERLINK hyper 'C2::C3'
+ link = @to.handle_special_HYPERLINK hyper 'C2::C3'
- assert_equal '<a href="C2/C3.html"><code>C2::C3</code></a>', link
+ assert_equal '<a href="C2/C3.html">C2::C3</a>', link
- link = @to.handle_regexp_HYPERLINK hyper 'C4'
+ link = @to.handle_special_HYPERLINK hyper 'C4'
- assert_equal '<a href="C4.html"><code>C4</code></a>', link
+ assert_equal '<a href="C4.html">C4</a>', link
- link = @to.handle_regexp_HYPERLINK hyper 'README.txt'
+ link = @to.handle_special_HYPERLINK hyper 'README.txt'
assert_equal '<a href="README_txt.html">README.txt</a>', link
end
- def test_handle_regexp_TIDYLINK_rdoc
+ def test_handle_special_TIDYLINK_rdoc
readme = @store.add_file 'README.txt'
readme.parser = RDoc::Parser::Simple
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2
- link = @to.handle_regexp_TIDYLINK tidy 'C2::C3'
+ link = @to.handle_special_TIDYLINK tidy 'C2::C3'
assert_equal '<a href="C2/C3.html">tidy</a>', link
- link = @to.handle_regexp_TIDYLINK tidy 'C4'
+ link = @to.handle_special_TIDYLINK tidy 'C4'
assert_equal '<a href="C4.html">tidy</a>', link
- link = @to.handle_regexp_TIDYLINK tidy 'C1#m'
+ link = @to.handle_special_TIDYLINK tidy 'C1#m'
assert_equal '<a href="C1.html#method-i-m">tidy</a>', link
- link = @to.handle_regexp_TIDYLINK tidy 'README.txt'
+ link = @to.handle_special_TIDYLINK tidy 'README.txt'
assert_equal '<a href="README_txt.html">tidy</a>', link
end
- def test_handle_regexp_TIDYLINK_label
- link = @to.handle_regexp_TIDYLINK tidy 'C1#m@foo'
+ def test_handle_special_TIDYLINK_label
+ link = @to.handle_special_TIDYLINK tidy 'C1#m@foo'
assert_equal "<a href=\"C1.html#method-i-m-label-foo\">tidy</a>",
link, 'C1#m@foo'
@@ -205,16 +200,11 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
def test_link
assert_equal 'n', @to.link('n', 'n')
- assert_equal '<a href="C1.html#method-c-m"><code>m</code></a>', @to.link('m', 'm')
- end
-
- def test_link_for_method_traverse
- @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c9
- assert_equal '<a href="C9/A.html#method-i-foo"><code>C9::B#foo</code></a>', @to.link('C9::B#foo', 'C9::B#foo')
+ assert_equal '<a href="C1.html#method-c-m">::m</a>', @to.link('m', 'm')
end
def test_link_class_method_full
- assert_equal '<a href="Parent.html#method-c-m"><code>Parent::m</code></a>',
+ assert_equal '<a href="Parent.html#method-c-m">Parent.m</a>',
@to.link('Parent::m', 'Parent::m')
end
@@ -222,20 +212,20 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
"\n<p>#{text}</p>\n"
end
- def REGEXP_HANDLING text
- @to.handle_regexp_CROSSREF regexp_handling text
+ def SPECIAL text
+ @to.handle_special_CROSSREF special text
end
def hyper reference
- RDoc::Markup::RegexpHandling.new 0, "rdoc-ref:#{reference}"
+ RDoc::Markup::Special.new 0, "rdoc-ref:#{reference}"
end
- def regexp_handling text
- RDoc::Markup::RegexpHandling.new 0, text
+ def special text
+ RDoc::Markup::Special.new 0, text
end
def tidy reference
- RDoc::Markup::RegexpHandling.new 0, "{tidy}[rdoc-ref:#{reference}]"
+ RDoc::Markup::Special.new 0, "{tidy}[rdoc-ref:#{reference}]"
end
end
diff --git a/test/rdoc/test_rdoc_markup_to_html_snippet.rb b/test/rdoc/test_rdoc_markup_to_html_snippet.rb
index 94f58b6529..d7ce211999 100644
--- a/test/rdoc/test_rdoc_markup_to_html_snippet.rb
+++ b/test/rdoc/test_rdoc_markup_to_html_snippet.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase
@@ -458,7 +458,8 @@ So there you have it
expected = <<-EXPECTED
<p>Hello
-<p>This is some text, it <strong>will</strong> be cut off after 100 characters and an ellipsis must follow
+<p>This is some text, it <strong>will</strong> be cut off after 100 characters
+and an ellipsis must follow
<p>So there you #{@ellipsis}
EXPECTED
@@ -562,7 +563,8 @@ NOTE: Given Foo::Bar, Bar is considered a class even though it may be a
RDOC
expected = <<-EXPECTED
-<p>Extracts the class, selector and method name parts from <code>name</code> like Foo::Bar#baz.
+<p>Extracts the class, selector and method name parts from <code>name</code>
+like Foo::Bar#baz.
<p>NOTE: Given Foo::Bar, #{@ellipsis}
EXPECTED
@@ -650,10 +652,10 @@ This routine modifies its +comment+ parameter.
assert_equal 3, @to.characters
end
- def test_handle_regexp_HYPERLINK_link
- target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt'
+ def test_handle_special_HYPERLINK_link
+ special = RDoc::Markup::Special.new 0, 'link:README.txt'
- link = @to.handle_regexp_HYPERLINK target
+ link = @to.handle_special_HYPERLINK special
assert_equal 'README.txt', link
end
diff --git a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb
index cbaf75a04e..0a6a864bfa 100644
--- a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb
+++ b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToJoinedParagraph < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup_to_label.rb b/test/rdoc/test_rdoc_markup_to_label.rb
index 70ea7f0f1b..23ab8cbfab 100644
--- a/test/rdoc/test_rdoc_markup_to_label.rb
+++ b/test/rdoc/test_rdoc_markup_to_label.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase
diff --git a/test/rdoc/test_rdoc_markup_to_markdown.rb b/test/rdoc/test_rdoc_markup_to_markdown.rb
index 4d3a005381..f5ea8d05da 100644
--- a/test/rdoc/test_rdoc_markup_to_markdown.rb
+++ b/test/rdoc/test_rdoc_markup_to_markdown.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase
diff --git a/test/rdoc/test_rdoc_markup_to_rdoc.rb b/test/rdoc/test_rdoc_markup_to_rdoc.rb
index 1d833b156a..31761eb44d 100644
--- a/test/rdoc/test_rdoc_markup_to_rdoc.rb
+++ b/test/rdoc/test_rdoc_markup_to_rdoc.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
diff --git a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
index 11ab6f197b..f21dbfe748 100644
--- a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
+++ b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase
diff --git a/test/rdoc/test_rdoc_markup_to_tt_only.rb b/test/rdoc/test_rdoc_markup_to_tt_only.rb
index 8508f823df..b08362cd0b 100644
--- a/test/rdoc/test_rdoc_markup_to_tt_only.rb
+++ b/test/rdoc/test_rdoc_markup_to_tt_only.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase
diff --git a/test/rdoc/test_rdoc_markup_verbatim.rb b/test/rdoc/test_rdoc_markup_verbatim.rb
index 1a650c44ef..3b05100a33 100644
--- a/test/rdoc/test_rdoc_markup_verbatim.rb
+++ b/test/rdoc/test_rdoc_markup_verbatim.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocMarkupVerbatim < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb
index 140c4afc9b..400ed9a549 100644
--- a/test/rdoc/test_rdoc_options.rb
+++ b/test/rdoc/test_rdoc_options.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocOptions < RDoc::TestCase
@@ -17,10 +17,10 @@ class TestRDocOptions < RDoc::TestCase
end
def test_check_files
- omit "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
- omit "assumes that euid is not root" if Process.euid == 0
+ skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
+ skip "skipped in root privilege" if Process.uid == 0
- out, err = capture_output do
+ out, err = capture_io do
temp_dir do
FileUtils.touch 'unreadable'
FileUtils.chmod 0, 'unreadable'
@@ -40,7 +40,7 @@ class TestRDocOptions < RDoc::TestCase
def test_check_files_warn
@options.verbosity = 2
- out, err = verbose_capture_output do
+ out, err = verbose_capture_io do
@options.files = %w[nonexistent]
@options.check_files
@@ -66,7 +66,7 @@ class TestRDocOptions < RDoc::TestCase
expected = {
'charset' => 'UTF-8',
'encoding' => encoding,
- 'exclude' => %w[~\z \.orig\z \.rej\z \.bak\z \.gemspec\z],
+ 'exclude' => [],
'hyperlink_all' => false,
'line_numbers' => false,
'locale' => nil,
@@ -218,7 +218,7 @@ rdoc_include:
end
def test_parse_dash_p
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[-p]
end
@@ -230,7 +230,7 @@ rdoc_include:
end
def test_parse_dash_p_files
- out, err = capture_output do
+ out, err = capture_io do
@options.parse ['-p', File.expand_path(__FILE__)]
end
@@ -253,7 +253,7 @@ rdoc_include:
dep_hash = RDoc::Options::DEPRECATED
options = dep_hash.keys.sort
- out, err = capture_output do
+ out, err = capture_io do
@options.parse options
end
@@ -278,7 +278,7 @@ rdoc_include:
end
def test_parse_encoding_invalid
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--encoding invalid]
end
@@ -288,7 +288,7 @@ rdoc_include:
end
def test_parse_formatter
- e = assert_raise OptionParser::InvalidOption do
+ e = assert_raises OptionParser::InvalidOption do
@options.parse %w[--format darkfish --format ri]
end
@@ -296,22 +296,8 @@ rdoc_include:
e.message
end
- def test_parse_force_update
- @options.parse %w[--force-update]
-
- assert @options.force_update
-
- @options.parse %w[--no-force-update]
-
- assert !@options.force_update
-
- @options.parse %w[-U]
-
- assert @options.force_update
- end
-
def test_parse_formatter_ri
- e = assert_raise OptionParser::InvalidOption do
+ e = assert_raises OptionParser::InvalidOption do
@options.parse %w[--format darkfish --ri]
end
@@ -320,7 +306,7 @@ rdoc_include:
@options = RDoc::Options.new
- e = assert_raise OptionParser::InvalidOption do
+ e = assert_raises OptionParser::InvalidOption do
@options.parse %w[--format darkfish -r]
end
@@ -329,7 +315,7 @@ rdoc_include:
end
def test_parse_formatter_ri_site
- e = assert_raise OptionParser::InvalidOption do
+ e = assert_raises OptionParser::InvalidOption do
@options.parse %w[--format darkfish --ri-site]
end
@@ -338,7 +324,7 @@ rdoc_include:
@options = RDoc::Options.new
- e = assert_raise OptionParser::InvalidOption do
+ e = assert_raises OptionParser::InvalidOption do
@options.parse %w[--format darkfish -R]
end
@@ -347,7 +333,7 @@ rdoc_include:
end
def test_parse_h
- out, = capture_output do
+ out, = capture_io do
begin
@options.parse %w[-h]
rescue SystemExit
@@ -359,7 +345,7 @@ rdoc_include:
end
def test_parse_help
- out, = capture_output do
+ out, = capture_io do
begin
@options.parse %w[--help]
rescue SystemExit
@@ -379,7 +365,7 @@ rdoc_include:
end
end
- out, = capture_output do
+ out, = capture_io do
begin
@options.parse %w[--help]
rescue SystemExit
@@ -406,7 +392,7 @@ rdoc_include:
end
def test_parse_ignore_invalid
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--ignore-invalid --bogus]
end
@@ -417,7 +403,7 @@ rdoc_include:
end
def test_parse_ignore_invalid_default
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--bogus --main BLAH]
end
@@ -430,8 +416,8 @@ rdoc_include:
end
def test_parse_ignore_invalid_no
- out, err = capture_output do
- assert_raise SystemExit do
+ out, err = capture_io do
+ assert_raises SystemExit do
@options.parse %w[--no-ignore-invalid --bogus=arg --bobogus --visibility=extended]
end
end
@@ -443,8 +429,8 @@ rdoc_include:
end
def test_parse_ignore_invalid_no_quiet
- out, err = capture_output do
- assert_raise SystemExit do
+ out, err = capture_io do
+ assert_raises SystemExit do
@options.parse %w[--quiet --no-ignore-invalid --bogus=arg --bobogus --visibility=extended]
end
end
@@ -456,7 +442,7 @@ rdoc_include:
end
def test_ignore_needless_arg
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--ri=foo]
end
@@ -466,7 +452,7 @@ rdoc_include:
end
def test_ignore_missing_arg
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--copy-files]
end
@@ -476,7 +462,7 @@ rdoc_include:
end
def test_parse_main
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--main MAIN]
end
@@ -487,7 +473,7 @@ rdoc_include:
end
def test_parse_markup
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--markup tomdoc]
end
@@ -500,21 +486,15 @@ rdoc_include:
def test_parse_page_dir
assert_nil @options.page_dir
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %W[--page-dir #{Dir.tmpdir}]
end
assert_empty out
assert_empty err
- expected = nil
- begin
- expected =
- Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
- rescue ArgumentError
- # On Windows, sometimes crosses different drive letters.
- expected = Pathname(Dir.tmpdir).expand_path
- end
+ expected =
+ Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
assert_equal expected, @options.page_dir
assert_equal [Dir.tmpdir], @options.files
@@ -528,7 +508,7 @@ rdoc_include:
abs_page_dir = File.join dir, 'pages'
FileUtils.mkdir abs_page_dir
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %W[--page-dir #{abs_page_dir} --root #{abs_root}]
end
@@ -550,7 +530,7 @@ rdoc_include:
def test_parse_root
assert_equal Pathname(Dir.pwd), @options.root
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %W[--root #{Dir.tmpdir}]
end
@@ -568,13 +548,13 @@ rdoc_include:
@options.parse %w[-w2]
assert_equal 2, @options.tab_width
- _, err = capture_output do
+ _, err = capture_io do
@options.parse %w[-w=2]
end
assert_match 'invalid options', err
- _, err = capture_output do
+ _, err = capture_io do
@options.parse %w[-w0]
end
@@ -582,7 +562,7 @@ rdoc_include:
end
def test_parse_template
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--template darkfish]
end
@@ -595,7 +575,7 @@ rdoc_include:
end
def test_parse_template_nonexistent
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--template NONEXISTENT]
end
@@ -618,7 +598,7 @@ rdoc_include:
FileUtils.mkdir_p template_dir
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--template load_path]
end
@@ -651,7 +631,7 @@ rdoc_include:
FileUtils.mkdir_p tmpdir
Dir.chdir tmpdir do
- e = assert_raise SystemExit do
+ e = assert_raises SystemExit do
@options.parse %w[--write-options]
end
@@ -664,7 +644,7 @@ rdoc_include:
end
def test_parse_extension_alias
- out, err = capture_output do
+ out, err = capture_io do
@options.parse %w[--extension foobar=rdoc]
end
@@ -726,7 +706,7 @@ rdoc_include:
end
def test_warn
- out, err = capture_output do
+ out, err = capture_io do
@options.warn "warnings off"
end
@@ -735,7 +715,7 @@ rdoc_include:
@options.verbosity = 2
- out, err = verbose_capture_output do
+ out, err = verbose_capture_io do
@options.warn "warnings on"
end
@@ -754,7 +734,7 @@ rdoc_include:
end
def test_version
- out, _ = capture_output do
+ out, _ = capture_io do
begin
@options.parse %w[--version]
rescue SystemExit
@@ -763,7 +743,7 @@ rdoc_include:
assert out.include?(RDoc::VERSION)
- out, _ = capture_output do
+ out, _ = capture_io do
begin
@options.parse %w[-v]
rescue SystemExit
diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb
index 7cc3c2d926..5d4da7e425 100644
--- a/test/rdoc/test_rdoc_parser.rb
+++ b/test/rdoc/test_rdoc_parser.rb
@@ -1,7 +1,7 @@
# -*- coding: us-ascii -*-
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocParser < RDoc::TestCase
@@ -19,7 +19,7 @@ class TestRDocParser < RDoc::TestCase
def test_class_binary_eh_ISO_2022_JP
iso_2022_jp = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.rd"
- File.open iso_2022_jp, 'wb' do |io|
+ open iso_2022_jp, 'wb' do |io|
io.write "# coding: ISO-2022-JP\n"
io.write ":\e$B%3%^%s%I\e(B:\n"
end
@@ -31,7 +31,7 @@ class TestRDocParser < RDoc::TestCase
def test_class_binary_eh_marshal
marshal = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.marshal"
- File.open marshal, 'wb' do |io|
+ open marshal, 'wb' do |io|
io.write Marshal.dump('')
io.write 'lots of text ' * 500
end
@@ -47,7 +47,7 @@ class TestRDocParser < RDoc::TestCase
end
def test_class_binary_large_japanese_rdoc
- capture_output do
+ capture_io do
begin
extenc, Encoding.default_external =
Encoding.default_external, Encoding::US_ASCII
@@ -92,7 +92,7 @@ class TestRDocParser < RDoc::TestCase
def test_class_for_executable
temp_dir do
content = "#!/usr/bin/env ruby -w\n"
- File.open 'app', 'w' do |io| io.write content end
+ open 'app', 'w' do |io| io.write content end
app = @store.add_file 'app'
parser = @RP.for app, 'app', content, @options, :stats
@@ -104,7 +104,7 @@ class TestRDocParser < RDoc::TestCase
end
def test_class_for_forbidden
- omit 'chmod not supported' if Gem.win_platform?
+ skip 'chmod not supported' if Gem.win_platform?
tf = Tempfile.open 'forbidden' do |io|
begin
@@ -126,7 +126,7 @@ class TestRDocParser < RDoc::TestCase
temp_dir do
content = "# -*- rdoc -*-\n= NEWS\n"
- File.open 'NEWS', 'w' do |io| io.write content end
+ open 'NEWS', 'w' do |io| io.write content end
app = @store.add_file 'NEWS'
parser = @RP.for app, 'NEWS', content, @options, :stats
@@ -140,7 +140,7 @@ class TestRDocParser < RDoc::TestCase
def test_can_parse_modeline
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.open readme_ext, 'w' do |io|
+ open readme_ext, 'w' do |io|
io.puts "# README.EXT - -*- rdoc -*- created at: Mon Aug 7 16:45:54 JST 1995"
io.puts
io.puts "This document explains how to make extension libraries for Ruby."
@@ -162,7 +162,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.open readme_ext, 'w' do |io|
+ open readme_ext, 'w' do |io|
io.puts "# README.EXT - -*- RDoc -*- created at: Mon Aug 7 16:45:54 JST 1995"
io.puts
io.puts "This document explains how to make extension libraries for Ruby."
@@ -176,7 +176,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline_coding
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.open readme_ext, 'w' do |io|
+ open readme_ext, 'w' do |io|
io.puts "# -*- coding: utf-8 -*-"
end
@@ -188,7 +188,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline_with_other
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.open readme_ext, 'w' do |io|
+ open readme_ext, 'w' do |io|
io.puts "# README.EXT - -*- mode: RDoc; indent-tabs-mode: nil -*-"
io.puts
io.puts "This document explains how to make extension libraries for Ruby."
@@ -202,7 +202,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline_no_modeline
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.open readme_ext, 'w' do |io|
+ open readme_ext, 'w' do |io|
io.puts "This document explains how to make extension libraries for Ruby."
end
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index 6601d28f60..2cc8ddf79a 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
=begin
TODO: test call-seq parsing
@@ -304,6 +304,32 @@ void Init_Blah(void) {
assert_equal 'This should show up as an alias', methods.last.comment.text
end
+ def test_do_classes_boot_class
+ content = <<-EOF
+/* Document-class: Foo
+ * this is the Foo boot class
+ */
+VALUE cFoo = boot_defclass("Foo", rb_cObject);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal "this is the Foo boot class", klass.comment.text
+ assert_equal 'Object', klass.superclass
+ end
+
+ def test_do_classes_boot_class_nil
+ content = <<-EOF
+/* Document-class: Foo
+ * this is the Foo boot class
+ */
+VALUE cFoo = boot_defclass("Foo", 0);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal "this is the Foo boot class", klass.comment.text
+ assert_equal nil, klass.superclass
+ end
+
def test_do_aliases_missing_class
content = <<-EOF
void Init_Blah(void) {
@@ -311,7 +337,7 @@ void Init_Blah(void) {
}
EOF
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
refute util_get_class(content, 'cDate')
end
@@ -485,7 +511,7 @@ void Init_foo(){
@parser = util_parser content
- @parser.do_classes_and_modules
+ @parser.do_classes
@parser.do_constants
klass = @parser.classes['cFoo']
@@ -555,7 +581,8 @@ void Init_curses(){
@parser = util_parser content
- @parser.do_classes_and_modules
+ @parser.do_modules
+ @parser.do_classes
@parser.do_constants
klass = @parser.classes['mCurses']
@@ -581,7 +608,8 @@ void Init_File(void) {
@parser = util_parser content
- @parser.do_classes_and_modules
+ @parser.do_modules
+ @parser.do_classes
@parser.do_constants
klass = @parser.classes['rb_mFConst']
@@ -629,7 +657,7 @@ void Init_Blah(void) {
klass = nil
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
klass = util_get_class content, 'cDate'
end
@@ -652,7 +680,7 @@ void Init_Blah(void) {
klass = nil
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
klass = util_get_class content, 'cDate'
end
@@ -675,7 +703,7 @@ void Init_Blah(void) {
klass = nil
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
klass = util_get_class content, 'cDate'
end
@@ -742,7 +770,7 @@ void Init_Blah(void) {
parser.missing_dependencies['y'] = ['y', :class, 'Y', 'Object', 'z']
parser.missing_dependencies['z'] = ['z', :class, 'Z', 'Object', 'y']
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
parser.do_missing
end
@@ -1349,11 +1377,11 @@ commercial() -> Date <br />
parser.find_modifiers comment, method_obj
- assert_nil method_obj.document_self
+ assert_equal nil, method_obj.document_self
end
def test_find_modifiers_yields
- comment = RDoc::Comment.new <<-COMMENT, @top_level, :c
+ comment = RDoc::Comment.new <<-COMMENT
/* :yields: a, b
*
* Blah
@@ -1602,19 +1630,6 @@ Init_IO(void) {
assert read_method.singleton
end
- def test_define_method_dynamically
- content = <<-EOF
-void
-Init_foo(void)
-{
- rb_define_singleton_method(obj, "foo", foo, -1);
-}
- EOF
-
- klass = util_get_class content, 'obj'
- assert_nil klass
- end
-
def test_define_method_with_prototype
content = <<-EOF
static VALUE rb_io_s_read(int, VALUE*, VALUE);
diff --git a/test/rdoc/test_rdoc_parser_changelog.rb b/test/rdoc/test_rdoc_parser_changelog.rb
index cb6406259c..06c3ff206e 100644
--- a/test/rdoc/test_rdoc_parser_changelog.rb
+++ b/test/rdoc/test_rdoc_parser_changelog.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocParserChangeLog < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_parser_markdown.rb b/test/rdoc/test_rdoc_parser_markdown.rb
index 06c6700d96..50893ecf99 100644
--- a/test/rdoc/test_rdoc_parser_markdown.rb
+++ b/test/rdoc/test_rdoc_parser_markdown.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocParserMarkdown < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_parser_rd.rb b/test/rdoc/test_rdoc_parser_rd.rb
index bac9c65592..e8f4250284 100644
--- a/test/rdoc/test_rdoc_parser_rd.rb
+++ b/test/rdoc/test_rdoc_parser_rd.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocParserRd < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 0c81906090..e28112fbee 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocParserRuby < RDoc::TestCase
@@ -73,7 +73,7 @@ class C; end
comment = parser.collect_first_comment
- assert_equal RDoc::Comment.new("first\n", @top_level), comment
+ assert_equal RDoc::Comment.new("=begin\nfirst\n=end\n", @top_level), comment
end
def test_get_class_or_module
@@ -100,7 +100,7 @@ class C; end
assert_equal 'E', name_t[:text]
assert_equal 'D::E', given_name
- assert_nothing_raised do
+ assert_raises RDoc::Error do
util_parser("A::\nB").get_class_or_module ctxt
end
end
@@ -231,8 +231,8 @@ class C; end
@parser.look_for_directives_in @top_level, comment
section = @top_level.current_section
- assert_nil section.title
- assert_nil section.comment
+ assert_equal nil, section.title
+ assert_equal nil, section.comment
assert_equal "# how to make a section:\n# # :section: new section\n",
comment.text
@@ -306,67 +306,6 @@ ruby
assert_equal @top_level, sum.file
end
- def test_parse_on_ignored_nl_with_nil_text
- util_parser <<ruby
-class Foo
- def meth
- variable # comment
- .chain
- end
-end
-ruby
-
- expected = <<EXPECTED
-<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meth</span>
- <span class="ruby-identifier">variable</span> <span class="ruby-comment"># comment</span>
- .<span class="ruby-identifier">chain</span>
-<span class="ruby-keyword">end</span>
-EXPECTED
- expected = expected.rstrip
-
- @parser.scan
-
- foo = @store.find_class_named 'Foo'
- meth = foo.method_list.first
-
- assert_equal 'meth', meth.name
- assert_equal @top_level, meth.file
-
- markup_code = meth.markup_code.sub(/^.*\n/, '')
- assert_equal expected, markup_code
- end
-
- def test_parse_redefined_op_with_constant
- klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
-
- comment = RDoc::Comment.new '', @top_level
-
- util_parser <<ruby
-def meth
- Integer::**()
- return Integer::**()
- break Integer::**()
- case Integer::**()
- when Integer::**()
- end
- while Integer::**()
- end
- yield Integer::**()
- defined? Integer::**()
- if Integer::**()
- end
-end
-ruby
-
- tk = @parser.get_tk
-
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
-
- meth = klass.method_list.first
- assert_equal 'meth', meth.name
- end
-
def test_parse_alias
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -435,7 +374,7 @@ ruby
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr :foo, :bar"
@@ -472,7 +411,7 @@ ruby
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr_accessor :foo, :bar"
@@ -495,43 +434,6 @@ ruby
assert_equal 'my attr', bar.comment.text
end
- def test_parse_attr_accessor_with_newline
- klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
-
- comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby
-
- util_parser "attr_accessor :foo, :bar,\n :baz,\n :qux"
-
- tk = @parser.get_tk
-
- @parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
-
- assert_equal 4, klass.attributes.length
-
- foo = klass.attributes[0]
- assert_equal 'foo', foo.name
- assert_equal 'RW', foo.rw
- assert_equal 'my attr', foo.comment.text
- assert_equal @top_level, foo.file
- assert_equal 1, foo.line
-
- bar = klass.attributes[1]
- assert_equal 'bar', bar.name
- assert_equal 'RW', bar.rw
- assert_equal 'my attr', bar.comment.text
-
- bar = klass.attributes[2]
- assert_equal 'baz', bar.name
- assert_equal 'RW', bar.rw
- assert_equal 'my attr', bar.comment.text
-
- bar = klass.attributes[3]
- assert_equal 'qux', bar.name
- assert_equal 'RW', bar.rw
- assert_equal 'my attr', bar.comment.text
- end
-
def test_parse_attr_accessor_nodoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -584,7 +486,7 @@ ruby
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# my attr\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr_writer :foo, :bar"
@@ -610,7 +512,7 @@ ruby
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
@@ -631,7 +533,7 @@ ruby
klass.parent = @top_level
comment =
- RDoc::Comment.new "##\n# :attr_accessor: \n# my method\n", @top_level, :ruby
+ RDoc::Comment.new "##\n# :attr_accessor: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
@@ -651,7 +553,7 @@ ruby
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# :attr: foo\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# :attr: foo\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
@@ -672,7 +574,7 @@ ruby
klass.parent = @top_level
comment =
- RDoc::Comment.new "##\n# :attr_reader: \n# my method\n", @top_level, :ruby
+ RDoc::Comment.new "##\n# :attr_reader: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
@@ -708,7 +610,7 @@ ruby
klass.parent = @top_level
comment =
- RDoc::Comment.new "##\n# :attr_writer: \n# my method\n", @top_level, :ruby
+ RDoc::Comment.new "##\n# :attr_writer: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
@@ -724,7 +626,7 @@ ruby
end
def test_parse_class
- comment = RDoc::Comment.new "##\n# my class\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my class\n", @top_level
util_parser "class Foo\nend"
@@ -776,7 +678,6 @@ end
blah = foo.method_list.first
assert_equal 'Foo#blah', blah.full_name
- assert_equal 3, blah.line
assert_equal @top_level, blah.file
end
@@ -826,21 +727,9 @@ end
blah = foo.method_list.first
assert_equal 'Foo#yields', blah.full_name
assert_equal 'yields(name)', blah.call_seq
- assert_equal 3, blah.line
assert_equal @top_level, blah.file
end
- def test_parse_call_syntax_sugar_for_constant
- util_parser <<-CODE
-Foo = proc{}
-Foo::()
- CODE
-
- assert_nothing_raised do
- @parser.scan
- end
- end
-
def test_parse_class_multi_ghost_methods
util_parser <<-'CLASS'
class Foo
@@ -915,7 +804,7 @@ end
def test_parse_class_lower_name_warning
@options.verbosity = 2
- stds = capture_output do
+ stds = capture_io do
util_parser "class foo\nend"
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
@@ -924,31 +813,6 @@ end
assert_match(/Expected class name or '<<'\. Got/, err)
end
- def test_parse_syntax_error_code
- @options.verbosity = 2
- stds = capture_output do
- begin
- util_parser <<INVALID_CODE
-# invalid class name
-class Invalid::@@Code
-end
-INVALID_CODE
- @parser.scan
- rescue
- end
- end
- err = stds[1]
-
- expected = <<EXPECTED
-RDoc::Parser::Ruby failure around line 2 of
-#{@filename}
-
-class Invalid::@@Code
-EXPECTED
-
- assert_match(expected, err)
- end
-
def test_parse_multi_ghost_methods
util_parser <<-'CLASS'
class Foo
@@ -1014,7 +878,7 @@ end
end
def test_parse_module
- comment = RDoc::Comment.new "##\n# my module\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my module\n", @top_level
util_parser "module Foo\nend"
@@ -1260,7 +1124,7 @@ EOF
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level
util_parser "\n"
@@ -1275,7 +1139,7 @@ EOF
assert_equal @top_level, foo.file
assert_equal 1, foo.line
- assert_nil foo.viewer
+ assert_equal nil, foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal false, foo.done_documenting
@@ -1324,7 +1188,7 @@ EOF
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level
util_parser "\n"
@@ -1336,43 +1200,35 @@ EOF
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
- assert_equal 2, foo.line
-
- assert_equal [], foo.aliases
- assert_nil foo.block_params
- assert_nil foo.call_seq
- assert_nil foo.is_alias_for
- assert_nil foo.viewer
- assert_equal true, foo.document_children
- assert_equal true, foo.document_self
- assert_equal '', foo.params
- assert_equal false, foo.done_documenting
- assert_equal false, foo.dont_rename_initialize
- assert_equal false, foo.force_documentation
- assert_equal klass, foo.parent
- assert_equal false, foo.singleton
- assert_equal :public, foo.visibility
- assert_equal "\n", foo.text
+ assert_equal 1, foo.line
+
+ assert_equal [], foo.aliases
+ assert_equal nil, foo.block_params
+ assert_equal nil, foo.call_seq
+ assert_equal nil, foo.is_alias_for
+ assert_equal nil, foo.viewer
+ assert_equal true, foo.document_children
+ assert_equal true, foo.document_self
+ assert_equal '', foo.params
+ assert_equal false, foo.done_documenting
+ assert_equal false, foo.dont_rename_initialize
+ assert_equal false, foo.force_documentation
+ assert_equal klass, foo.parent
+ assert_equal false, foo.singleton
+ assert_equal :public, foo.visibility
+ assert_equal "\n", foo.text
assert_equal klass.current_section, foo.section
stream = [
{
- :line_no => 2, :char_no => 1, :kind => :on_comment,
- :text => "# File #{@top_level.relative_name}, line 2"
+ :line_no => 1, :char_no => 1, :kind => :on_comment,
+ :text => "# File #{@top_level.relative_name}, line 1"
},
{ :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" },
{ :line_no => 1, :char_no => 1, :kind => :on_sp, :text => '' }
]
- parsed_stream = foo.token_stream.map { |t|
- {
- :line_no => t[:line_no],
- :char_no => t[:char_no],
- :kind => t[:kind],
- :text => t[:text]
- }
- }
- assert_equal stream, parsed_stream
+ assert_equal stream, foo.token_stream
end
def test_parse_comment_method_args
@@ -1446,9 +1302,6 @@ EOF
@parser.parse_constant klass, tk, @comment
- assert_equal [], klass.modules.map(&:full_name)
- assert_equal ['Foo::B', 'Foo::A'], klass.classes.map(&:full_name)
- assert_equal ['Foo::A'], klass.constants.map(&:full_name)
assert_equal 'Foo::A', klass.find_module_named('A').full_name
end
@@ -1608,7 +1461,7 @@ end
klass = RDoc::NormalClass.new 'C'
klass.parent = @top_level
- comment = RDoc::Comment.new "# my extend\n", @top_level, :ruby
+ comment = RDoc::Comment.new "# my extend\n", @top_level
util_parser "extend I"
@@ -1628,7 +1481,7 @@ end
klass = RDoc::NormalClass.new 'C'
klass.parent = @top_level
- comment = RDoc::Comment.new "# my include\n", @top_level, :ruby
+ comment = RDoc::Comment.new "# my include\n", @top_level
util_parser "include I"
@@ -1648,7 +1501,7 @@ end
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1663,19 +1516,19 @@ end
assert_equal 1, foo.line
assert_equal [], foo.aliases
- assert_nil foo.block_params
- assert_nil foo.call_seq
+ assert_equal nil, foo.block_params
+ assert_equal nil, foo.call_seq
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal false, foo.done_documenting
assert_equal false, foo.dont_rename_initialize
assert_equal false, foo.force_documentation
- assert_nil foo.is_alias_for
+ assert_equal nil, foo.is_alias_for
assert_equal '', foo.params
assert_equal klass, foo.parent
assert_equal false, foo.singleton
assert_equal 'add_my_method :foo', foo.text
- assert_nil foo.viewer
+ assert_equal nil, foo.viewer
assert_equal :public, foo.visibility
assert_equal klass.current_section, foo.section
@@ -1732,7 +1585,7 @@ end
def test_parse_meta_method_define_method
klass = RDoc::NormalClass.new 'Foo'
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "define_method :foo do end"
@@ -1751,7 +1604,7 @@ end
klass.parent = @top_level
comment =
- RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @top_level, :ruby
+ RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1770,7 +1623,7 @@ end
klass.parent = @top_level
comment =
- RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @top_level, :ruby
+ RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1791,7 +1644,7 @@ end
comment =
RDoc::Comment.new "##\n# :singleton-method: woo_hoo!\n# my method\n",
- @top_level, :ruby
+ @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1808,7 +1661,7 @@ end
def test_parse_meta_method_string_name
klass = RDoc::NormalClass.new 'Foo'
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "add_my_method 'foo'"
@@ -1840,7 +1693,7 @@ end
def test_parse_meta_method_unknown
klass = RDoc::NormalClass.new 'Foo'
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "add_my_method ('foo')"
@@ -1858,7 +1711,7 @@ end
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "def foo() :bar end"
@@ -1873,10 +1726,10 @@ end
assert_equal 1, foo.line
assert_equal [], foo.aliases
- assert_nil foo.block_params
- assert_nil foo.call_seq
- assert_nil foo.is_alias_for
- assert_nil foo.viewer
+ assert_equal nil, foo.block_params
+ assert_equal nil, foo.call_seq
+ assert_equal nil, foo.is_alias_for
+ assert_equal nil, foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal '()', foo.params
@@ -2368,31 +2221,6 @@ end
assert_equal 'C#bar', methods[1].full_name
end
- def test_parse_statements_postfix_if_unless_with_expr_mid
- util_parser <<-CODE
-class A
- class B
- def foo
- return if nil
- end
- end
-
- class C
- end
-end
- CODE
-
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
-
- a = @top_level.classes.first
- assert_equal 'A', a.full_name, 'class A'
- assert_equal 2, a.classes.length
- b = a.classes[0]
- assert_equal 'A::B', b.full_name, 'class A::B'
- c = a.classes[1]
- assert_equal 'A::C', c.full_name, 'class A::C'
- end
-
def test_parse_statements_class_nested
comment = RDoc::Comment.new "##\n# my method\n", @top_level
@@ -2898,50 +2726,6 @@ EXPECTED
assert_equal expected, markup_code
end
- def test_parse_mutable_heredocbeg
- @filename = 'file.rb'
- util_parser <<RUBY
-class Foo
- def blah()
- @str = -<<-EOM
- EOM
- end
-end
-RUBY
-
- expected = <<EXPECTED
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">blah</span>()
- <span class="ruby-ivar">@str</span> = <span class="ruby-identifier">-&lt;&lt;-EOM</span>
-<span class="ruby-value"></span><span class="ruby-identifier"> EOM</span>
- <span class="ruby-keyword">end</span>
-EXPECTED
- expected = expected.rstrip
-
- @parser.scan
-
- foo = @top_level.classes.first
- assert_equal 'Foo', foo.full_name
-
- blah = foo.method_list.first
- markup_code = blah.markup_code.sub(/^.*\n/, '')
- assert_equal expected, markup_code
- end
-
- def test_parse_heredoc_end
- code = "A = <<eos\n""OK\n""eos\n"
- util_parser code
- @parser.parse_statements @top_level
- @parser.scan
- c = @top_level.classes.first.constants.first
- assert_equal("A", c.name)
-
- util_parser code.gsub(/$/, "\r")
- @parser.parse_statements @top_level
- @parser.scan
- c = @top_level.classes.first.constants.first
- assert_equal("A", c.name)
- end
-
def test_parse_statements_method_oneliner_with_regexp
util_parser <<RUBY
class Foo
@@ -3197,12 +2981,12 @@ RUBY
@parser.skip_tkspace
- assert_nil @parser.parse_symbol_in_arg
+ assert_equal nil, @parser.parse_symbol_in_arg
@parser.get_tk # skip ','
@parser.skip_tkspace
- assert_nil @parser.parse_symbol_in_arg
+ assert_equal nil, @parser.parse_symbol_in_arg
end
def test_parse_statements_alias_method
@@ -3306,7 +3090,7 @@ end
assert_equal 'category', directive
assert_equal 'test', value
- assert_nil parser.get_tk
+ assert_equal nil, parser.get_tk
end
def test_read_directive_allow
@@ -3316,7 +3100,7 @@ end
assert_nil directive
- assert_nil parser.get_tk
+ assert_equal nil, parser.get_tk
end
def test_read_directive_empty
@@ -3326,7 +3110,7 @@ end
assert_nil directive
- assert_nil parser.get_tk
+ assert_equal nil, parser.get_tk
end
def test_read_directive_no_comment
@@ -3336,7 +3120,7 @@ end
assert_nil directive
- assert_nil parser.get_tk
+ assert_equal nil, parser.get_tk
end
def test_read_directive_one_liner
@@ -3413,14 +3197,14 @@ end
util_parser '"#{"#{"a")}" if b}"'
assert_equal '"#{"#{"a")}" if b}"', @parser.get_tk[:text]
- assert_nil @parser.get_tk
+ assert_equal nil, @parser.get_tk
end
def test_sanity_interpolation_curly
util_parser '%{ #{} }'
assert_equal '%{ #{} }', @parser.get_tk[:text]
- assert_nil @parser.get_tk
+ assert_equal nil, @parser.get_tk
end
def test_sanity_interpolation_format
@@ -3476,11 +3260,11 @@ end
foo = @top_level.classes.first
- assert_equal 'Foo comment', foo.comment.text
+ assert_equal "=begin rdoc\nFoo comment\n=end", foo.comment.text
m = foo.method_list.first
- assert_equal 'm comment', m.comment.text
+ assert_equal "=begin\nm comment\n=end", m.comment.text
end
def test_scan_block_comment_nested # Issue #41
@@ -3502,7 +3286,7 @@ end
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name
- assert_equal 'findmeindoc', foo.comment.text
+ assert_equal "=begin rdoc\nfindmeindoc\n=end", foo.comment.text
bar = foo.classes.first
@@ -3513,10 +3297,9 @@ end
def test_scan_block_comment_notflush
##
#
- # The previous test assumes that between the =begin/=end blocks that there
- # is only one line, or minima formatting directives. This test tests for
- # those who use the =begin block with longer / more advanced formatting
- # within.
+ # The previous test assumes that between the =begin/=end blocs that there is
+ # only one line, or minima formatting directives. This test tests for those
+ # who use the =begin bloc with longer / more advanced formatting within.
#
##
content = <<-CONTENT
@@ -3550,12 +3333,12 @@ end
foo = @top_level.classes.first
- assert_equal "= DESCRIPTION\n\nThis is a simple test class\n\n= RUMPUS\n\nIs a silly word",
+ assert_equal "=begin rdoc\n\n= DESCRIPTION\n\nThis is a simple test class\n\n= RUMPUS\n\nIs a silly word\n\n=end",
foo.comment.text
m = foo.method_list.first
- assert_equal 'A nice girl', m.comment.text
+ assert_equal "=begin rdoc\nA nice girl\n=end", m.comment.text
end
def test_scan_class_nested_nodoc
@@ -4059,242 +3842,4 @@ end
second_file_content, @options, @stats
end
- def test_parse_const_third_party
- util_parser <<-CLASS
-class A
- true if B
- true if B::C
- true if B::C::D
-
- module B
- end
-end
- CLASS
-
- tk = @parser.get_tk
-
- @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
-
- a = @top_level.classes.first
- assert_equal 'A', a.full_name
-
- visible = @store.all_modules.reject { |mod| mod.suppressed? }
- visible = visible.map { |mod| mod.full_name }
-
- assert_equal ['A::B'], visible
- end
-
- def test_parse_const_alias_defined_elsewhere
- util_parser <<-CLASS
-module A
- Aliased = Defined
-end
-
-module A
- class Defined
- end
-end
- CLASS
-
- @parser.scan
-
- a = @top_level.modules.first
- assert_equal 'A', a.full_name
- aliased = a.constants.first
- assert_equal 'A::Aliased', aliased.full_name
- assert_equal [], a.modules.map(&:full_name)
- assert_equal ['A::Defined', 'A::Aliased'], a.classes.map(&:full_name)
- assert_equal ['A::Aliased'], a.constants.map(&:full_name)
-
- visible = @store.all_modules.reject { |mod| mod.suppressed? }
- visible = visible.map { |mod| mod.full_name }
-
- assert_equal ['A'], visible
- end
-
- def test_parse_const_alias_defined_far_away
- util_parser <<-CLASS
-module A
- Aliased = ::B::C::Defined
-end
-
-module B
- module C
- class Defined
- end
- end
-end
- CLASS
-
- @parser.scan
-
- a = @top_level.modules.first
- assert_equal 'A', a.full_name
- assert_empty a.classes
- assert_empty a.modules
- assert_equal ['A::Aliased'], a.constants.map(&:full_name)
-
- defined = @store.find_class_named 'B::C::Defined'
- assert_equal 'B::C::Defined', defined.full_name
-
- aliased = @store.find_class_named 'B::C::Aliased'
- assert_equal 'B::C::Aliased', aliased.full_name
-
- visible = @store.all_modules.reject { |mod| mod.suppressed? }
- visible = visible.map { |mod| mod.full_name }
-
- assert_equal ['A', 'B', 'B::C'], visible
- end
-
- def test_parse_include_by_dynamic_definition
- util_parser <<-CLASS
-module A
- class B
- include(Module.new do
- def e(m)
- end
- end)
- end
-
- class C
- end
-
- class D
- end
-end
- CLASS
-
- @parser.scan
-
- a = @store.find_module_named 'A'
- assert_equal 'A', a.full_name
- a_b = a.find_class_named 'B'
- assert_equal 'A::B', a_b.full_name
- a_c = a.find_class_named 'C'
- assert_equal 'A::C', a_c.full_name
- a_d = a.find_class_named 'D'
- assert_equal 'A::D', a_d.full_name
- end
-
- def test_parse_include_by_dynamic_definition_without_paren
- util_parser <<-CLASS
-module A
- class B
- include(Module.new do
- def e m
- end
- end)
- end
-
- class C
- end
-
- class D
- end
-end
- CLASS
-
- @parser.scan
-
- a = @store.find_module_named 'A'
- assert_equal 'A', a.full_name
- a_b = a.find_class_named 'B'
- assert_equal 'A::B', a_b.full_name
- a_c = a.find_class_named 'C'
- assert_equal 'A::C', a_c.full_name
- a_d = a.find_class_named 'D'
- assert_equal 'A::D', a_d.full_name
- end
-
- def test_parse_include_by_dynamic_definition_via_variable
- util_parser <<-CLASS
-module A
- class B
- m = Module.new do
- def e(m)
- end
- end
- include m
- end
-
- class C
- end
-
- class D
- end
-end
- CLASS
-
- @parser.scan
-
- a = @store.find_module_named 'A'
- assert_equal 'A', a.full_name
- a_b = a.find_class_named 'B'
- assert_equal 'A::B', a_b.full_name
- a_c = a.find_class_named 'C'
- assert_equal 'A::C', a_c.full_name
- a_d = a.find_class_named 'D'
- assert_equal 'A::D', a_d.full_name
- end
-
- def test_parse_include_by_dynamic_definition_with_brace
- util_parser <<-CLASS
-module A
- class B
- extend(e {
- def f(g)
- end
- })
- end
-
- class C
- end
-
- class D
- end
-end
- CLASS
-
- @parser.scan
-
- a = @store.find_module_named 'A'
- assert_equal 'A', a.full_name
- a_b = a.find_class_named 'B'
- assert_equal 'A::B', a_b.full_name
- a_c = a.find_class_named 'C'
- assert_equal 'A::C', a_c.full_name
- a_d = a.find_class_named 'D'
- assert_equal 'A::D', a_d.full_name
- end
-
- def test_parse_include_by_dynamic_definition_directly
- util_parser <<-CLASS
-module A
- class B
- include Module.new do
- def e m
- end
- end
- end
-
- class C
- end
-
- class D
- end
-end
- CLASS
-
- @parser.scan
-
- a = @store.find_module_named 'A'
- assert_equal 'A', a.full_name
- a_b = a.find_class_named 'B'
- assert_equal 'A::B', a_b.full_name
- a_c = a.find_class_named 'C'
- assert_equal 'A::C', a_c.full_name
- a_d = a.find_class_named 'D'
- assert_equal 'A::D', a_d.full_name
- end
-
end
diff --git a/test/rdoc/test_rdoc_parser_simple.rb b/test/rdoc/test_rdoc_parser_simple.rb
index 2f1ad00de4..cdbcd7929d 100644
--- a/test/rdoc/test_rdoc_parser_simple.rb
+++ b/test/rdoc/test_rdoc_parser_simple.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocParserSimple < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_rd.rb b/test/rdoc/test_rdoc_rd.rb
index 83ee423455..ed67ae2caa 100644
--- a/test/rdoc/test_rdoc_rd.rb
+++ b/test/rdoc/test_rdoc_rd.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocRd < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_rd_block_parser.rb b/test/rdoc/test_rdoc_rd_block_parser.rb
index 22f432eaf4..a73c206508 100644
--- a/test/rdoc/test_rdoc_rd_block_parser.rb
+++ b/test/rdoc/test_rdoc_rd_block_parser.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocRdBlockParser < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_rd_inline.rb b/test/rdoc/test_rdoc_rd_inline.rb
index 13ab86d3d9..2869681c6e 100644
--- a/test/rdoc/test_rdoc_rd_inline.rb
+++ b/test/rdoc/test_rdoc_rd_inline.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocRdInline < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_rd_inline_parser.rb b/test/rdoc/test_rdoc_rd_inline_parser.rb
index 9aff6139bc..b4394019b3 100644
--- a/test/rdoc/test_rdoc_rd_inline_parser.rb
+++ b/test/rdoc/test_rdoc_rd_inline_parser.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocRdInlineParser < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb
index f3228c31e0..bd4794342c 100644
--- a/test/rdoc/test_rdoc_rdoc.rb
+++ b/test/rdoc/test_rdoc_rdoc.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocRDoc < RDoc::TestCase
@@ -26,7 +26,7 @@ class TestRDocRDoc < RDoc::TestCase
temp_dir do
options.op_dir = 'ri'
- capture_output do
+ capture_io do
rdoc.document options
end
@@ -53,7 +53,7 @@ class TestRDocRDoc < RDoc::TestCase
out = nil
temp_dir do
- out, = capture_output do
+ out, = capture_io do
rdoc.document options
end
@@ -78,7 +78,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_handle_pipe
$stdin = StringIO.new "hello"
- out, = capture_output do
+ out, = capture_io do
@rdoc.handle_pipe
end
@@ -92,7 +92,7 @@ class TestRDocRDoc < RDoc::TestCase
@rdoc.options.markup = 'rd'
- out, = capture_output do
+ out, = capture_io do
@rdoc.handle_pipe
end
@@ -115,11 +115,11 @@ class TestRDocRDoc < RDoc::TestCase
def test_load_options_invalid
temp_dir do
- File.open '.rdoc_options', 'w' do |io|
+ open '.rdoc_options', 'w' do |io|
io.write "a: !ruby.yaml.org,2002:str |\nfoo"
end
- e = assert_raise RDoc::Error do
+ e = assert_raises RDoc::Error do
@rdoc.load_options
end
@@ -152,6 +152,8 @@ class TestRDocRDoc < RDoc::TestCase
end
def test_normalized_file_list_not_modified
+ files = [__FILE__]
+
@rdoc.last_modified[__FILE__] = File.stat(__FILE__).mtime
files = @rdoc.normalized_file_list [__FILE__]
@@ -161,12 +163,12 @@ class TestRDocRDoc < RDoc::TestCase
def test_normalized_file_list_non_file_directory
dev = File::NULL
- omit "#{dev} is not a character special" unless
+ skip "#{dev} is not a character special" unless
File.chardev? dev
files = nil
- out, err = verbose_capture_output do
+ out, err = verbose_capture_io do
files = @rdoc.normalized_file_list [dev]
end
@@ -179,75 +181,13 @@ class TestRDocRDoc < RDoc::TestCase
assert_match %r"#{dev}$", err
end
- def test_normalized_file_list_with_dot_doc
- expected_files = []
- files = temp_dir do |dir|
- a = File.expand_path('a.rb')
- b = File.expand_path('b.rb')
- c = File.expand_path('c.rb')
- FileUtils.touch a
- FileUtils.touch b
- FileUtils.touch c
- # Use Dir.glob to convert short path of Dir.tmpdir to long path.
- a = Dir.glob(a).first
- b = Dir.glob(b).first
- c = Dir.glob(c).first
-
- dot_doc = File.expand_path('.document')
- FileUtils.touch dot_doc
- open(dot_doc, 'w') do |f|
- f.puts 'a.rb'
- f.puts 'b.rb'
- end
- expected_files << a
- expected_files << b
-
- @rdoc.normalized_file_list [File.realpath(dir)]
- end
-
- files = files.map { |file| File.expand_path file }
-
- assert_equal expected_files, files
- end
-
- def test_normalized_file_list_with_dot_doc_overridden_by_exclude_option
- expected_files = []
- files = temp_dir do |dir|
- a = File.expand_path('a.rb')
- b = File.expand_path('b.rb')
- c = File.expand_path('c.rb')
- FileUtils.touch a
- FileUtils.touch b
- FileUtils.touch c
- # Use Dir.glob to convert short path of Dir.tmpdir to long path.
- a = Dir.glob(a).first
- b = Dir.glob(b).first
- c = Dir.glob(c).first
-
- dot_doc = File.expand_path('.document')
- FileUtils.touch dot_doc
- open(dot_doc, 'w') do |f|
- f.puts 'a.rb'
- f.puts 'b.rb'
- end
- expected_files << a
-
- @rdoc.options.exclude = Regexp.new(['b.rb'].join('|'))
- @rdoc.normalized_file_list [File.realpath(dir)]
- end
-
- files = files.map { |file| File.expand_path file }
-
- assert_equal expected_files, files
- end
-
def test_parse_file
@rdoc.store = RDoc::Store.new
temp_dir do |dir|
@rdoc.options.root = Pathname(Dir.pwd)
- File.open 'test.txt', 'w' do |io|
+ open 'test.txt', 'w' do |io|
io.puts 'hi'
end
@@ -265,7 +205,7 @@ class TestRDocRDoc < RDoc::TestCase
@rdoc.options.root = Pathname root
- out, err = capture_output do
+ out, err = capture_io do
Dir.chdir root do
assert_nil @rdoc.parse_file 'binary.dat'
end
@@ -283,11 +223,11 @@ class TestRDocRDoc < RDoc::TestCase
temp_dir do |dir|
@rdoc.options.parse %W[--root #{test_path}]
- File.open 'include.txt', 'w' do |io|
+ open 'include.txt', 'w' do |io|
io.puts ':include: test.txt'
end
- out, err = capture_output do
+ out, err = capture_io do
top_level = @rdoc.parse_file 'include.txt'
end
assert_empty out
@@ -304,7 +244,7 @@ class TestRDocRDoc < RDoc::TestCase
@rdoc.options.page_dir = Pathname('pages')
@rdoc.options.root = Pathname(Dir.pwd)
- File.open 'pages/test.txt', 'w' do |io|
+ open 'pages/test.txt', 'w' do |io|
io.puts 'hi'
end
@@ -323,7 +263,7 @@ class TestRDocRDoc < RDoc::TestCase
temp_dir do |dir|
@rdoc.options.root = Pathname(dir)
- File.open 'test.txt', 'w' do |io|
+ open 'test.txt', 'w' do |io|
io.puts 'hi'
end
@@ -355,8 +295,8 @@ class TestRDocRDoc < RDoc::TestCase
end
def test_parse_file_forbidden
- omit 'chmod not supported' if Gem.win_platform?
- omit "assumes that euid is not root" if Process.euid == 0
+ skip 'chmod not supported' if Gem.win_platform?
+ skip 'skipped in root privilege' if Process.uid == 0
@rdoc.store = RDoc::Store.new
@@ -369,7 +309,7 @@ class TestRDocRDoc < RDoc::TestCase
begin
top_level = :bug
- _, err = capture_output do
+ _, err = capture_io do
top_level = @rdoc.parse_file io.path
end
@@ -400,7 +340,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_remove_unparseable_tags_emacs
temp_dir do
- File.open 'TAGS', 'wb' do |io| # emacs
+ open 'TAGS', 'wb' do |io| # emacs
io.write "\f\nlib/foo.rb,43\n"
end
@@ -414,7 +354,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_remove_unparseable_tags_vim
temp_dir do
- File.open 'TAGS', 'w' do |io| # emacs
+ open 'TAGS', 'w' do |io| # emacs
io.write "!_TAG_"
end
@@ -426,19 +366,6 @@ class TestRDocRDoc < RDoc::TestCase
end
end
- def test_remove_unparseable_CVE_2021_31799
- omit 'for Un*x platforms' if Gem.win_platform?
- temp_dir do
- file_list = ['| touch evil.txt && echo tags']
- file_list.each do |f|
- FileUtils.touch f
- end
-
- assert_equal file_list, @rdoc.remove_unparseable(file_list)
- assert_equal file_list, Dir.children('.')
- end
- end
-
def test_setup_output_dir
Dir.mktmpdir {|d|
path = File.join d, 'testdir'
@@ -466,7 +393,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_setup_output_dir_exists
Dir.mktmpdir {|path|
- File.open @rdoc.output_flag_file(path), 'w' do |io|
+ open @rdoc.output_flag_file(path), 'w' do |io|
io.puts Time.at 0
io.puts "./lib/rdoc.rb\t#{Time.at 86400}"
end
@@ -480,9 +407,9 @@ class TestRDocRDoc < RDoc::TestCase
def test_setup_output_dir_exists_empty_created_rid
Dir.mktmpdir {|path|
- File.open @rdoc.output_flag_file(path), 'w' do end
+ open @rdoc.output_flag_file(path), 'w' do end
- e = assert_raise RDoc::Error do
+ e = assert_raises RDoc::Error do
@rdoc.setup_output_dir path, false
end
@@ -494,7 +421,7 @@ class TestRDocRDoc < RDoc::TestCase
tf = Tempfile.open 'test_rdoc_rdoc' do |tempfile|
path = tempfile.path
- e = assert_raise RDoc::Error do
+ e = assert_raises RDoc::Error do
@rdoc.setup_output_dir path, false
end
@@ -507,7 +434,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_setup_output_dir_exists_not_rdoc
Dir.mktmpdir do |dir|
- e = assert_raise RDoc::Error do
+ e = assert_raises RDoc::Error do
@rdoc.setup_output_dir dir, false
end
@@ -541,25 +468,6 @@ class TestRDocRDoc < RDoc::TestCase
end
end
- def test_update_output_dir_with_reproducible_time
- Dir.mktmpdir do |d|
- backup_epoch = ENV['SOURCE_DATE_EPOCH']
- ruby_birthday = Time.parse 'Wed, 24 Feb 1993 21:00:00 +0900'
- ENV['SOURCE_DATE_EPOCH'] = ruby_birthday.to_i.to_s
-
- @rdoc.update_output_dir d, Time.now, {}
-
- assert File.exist? "#{d}/created.rid"
-
- f = File.open("#{d}/created.rid", 'r')
- head_timestamp = Time.parse f.gets.chomp
- f.close
- assert_equal ruby_birthday, head_timestamp
-
- ENV['SOURCE_DATE_EPOCH'] = backup_epoch
- end
- end
-
def test_normalized_file_list_removes_created_rid_dir
temp_dir do |d|
FileUtils.mkdir "doc"
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index 6f17fecec9..687d0968df 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocRIDriver < RDoc::TestCase
@@ -50,7 +50,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_self_dump
util_store
- out, = capture_output do
+ out, = capture_io do
RDoc::RI::Driver.dump @store1.cache_path
end
@@ -243,32 +243,6 @@ class TestRDocRIDriver < RDoc::TestCase
assert_equal expected, out
end
- def test_add_method_that_is_alias_for_original
- util_store
-
- out = doc
-
- @driver.add_method out, 'Qux#aliased'
-
- expected =
- doc(
- head(1, 'Qux#aliased'),
- blank_line,
- para('(from ~/.rdoc)'),
- rule(1),
- blank_line,
- para('alias comment'),
- blank_line,
- blank_line,
- para('(This method is an alias for Qux#original.)'),
- blank_line,
- para('original comment'),
- blank_line,
- blank_line)
-
- assert_equal expected, out
- end
-
def test_add_method_attribute
util_store
@@ -374,22 +348,6 @@ class TestRDocRIDriver < RDoc::TestCase
assert_equal expected, out
end
- def test_output_width
- @options[:width] = 10
- driver = RDoc::RI::Driver.new @options
-
- doc = @RM::Document.new
- doc << @RM::IndentedParagraph.new(0, 'new, parse, foo, bar, baz')
-
- out, = capture_output do
- driver.display doc
- end
-
- expected = "new, parse, foo,\nbar, baz\n"
-
- assert_equal expected, out
- end
-
def test_add_method_list_interative
@options[:interactive] = true
driver = RDoc::RI::Driver.new @options
@@ -432,7 +390,6 @@ class TestRDocRIDriver < RDoc::TestCase
'Foo::Bar' => [@store1],
'Foo::Baz' => [@store1, @store2],
'Inc' => [@store1],
- 'Qux' => [@store1],
}
classes = @driver.classes
@@ -550,7 +507,7 @@ class TestRDocRIDriver < RDoc::TestCase
doc = @RM::Document.new(
@RM::Paragraph.new('hi'))
- out, = capture_output do
+ out, = capture_io do
@driver.display doc
end
@@ -560,7 +517,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_class
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_class 'Foo::Bar'
end
@@ -584,7 +541,7 @@ class TestRDocRIDriver < RDoc::TestCase
@driver.show_all = true
- out, = capture_output do
+ out, = capture_io do
@driver.display_class 'Foo::Bar'
end
@@ -606,7 +563,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_class_ambiguous
util_multi_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_class 'Ambiguous'
end
@@ -616,7 +573,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_class_multi_no_doc
util_multi_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_class 'Foo::Baz'
end
@@ -630,7 +587,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_class_superclass
util_multi_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_class 'Bar'
end
@@ -640,7 +597,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_class_module
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_class 'Inc'
end
@@ -648,7 +605,7 @@ class TestRDocRIDriver < RDoc::TestCase
end
def test_display_class_page
- out, = capture_output do
+ out, = capture_io do
@driver.display_class 'ruby:README'
end
@@ -658,7 +615,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_method
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_method 'Foo::Bar#blah'
end
@@ -670,7 +627,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_method_attribute
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_method 'Foo::Bar#attr'
end
@@ -681,7 +638,7 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_method_inherited
util_multi_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_method 'Bar#inherit'
end
@@ -692,32 +649,17 @@ class TestRDocRIDriver < RDoc::TestCase
def test_display_method_overridden
util_multi_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_method 'Bar#override'
end
refute_match %r%must not be displayed%, out
end
- def test_display_name
- util_store
-
- out, = capture_output do
- assert_equal true, @driver.display_name('home:README.rdoc')
- end
-
- expected = <<-EXPECTED
-= README
-This is a README
- EXPECTED
-
- assert_equal expected, out
- end
-
def test_display_name_not_found_class
util_store
- out, = capture_output do
+ out, = capture_io do
assert_equal false, @driver.display_name('Foo::B')
end
@@ -734,7 +676,7 @@ Foo::Baz
def test_display_name_not_found_method
util_store
- out, = capture_output do
+ out, = capture_io do
assert_equal false, @driver.display_name('Foo::Bar#b')
end
@@ -751,7 +693,7 @@ Foo::Bar#bother
def test_display_name_not_found_special
util_store
- assert_raise RDoc::RI::Driver::NotFoundError do
+ assert_raises RDoc::RI::Driver::NotFoundError do
assert_equal false, @driver.display_name('Set#[]')
end
end
@@ -759,7 +701,7 @@ Foo::Bar#bother
def test_display_method_params
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_method 'Foo::Bar#bother'
end
@@ -769,7 +711,7 @@ Foo::Bar#bother
def test_display_page
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_page 'home:README.rdoc'
end
@@ -779,7 +721,7 @@ Foo::Bar#bother
def test_display_page_add_extension
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_page 'home:README'
end
@@ -798,7 +740,7 @@ Foo::Bar#bother
@store1.save_page other
- out, = capture_output do
+ out, = capture_io do
@driver.display_page 'home:README'
end
@@ -819,7 +761,7 @@ Foo::Bar#bother
@store1.save_page other
- out, = capture_output do
+ out, = capture_io do
@driver.display_page 'home:README.EXT'
end
@@ -838,7 +780,7 @@ Foo::Bar#bother
@store1.save_page other
- out, = capture_output do
+ out, = capture_io do
@driver.display_page 'home:globals'
end
@@ -848,11 +790,11 @@ Foo::Bar#bother
def test_display_page_missing
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.display_page 'home:missing'
end
- out, = capture_output do
+ out, = capture_io do
@driver.display_page_list @store1
end
@@ -872,7 +814,7 @@ Foo::Bar#bother
@store1.save_page other
- out, = capture_output do
+ out, = capture_io do
@driver.display_page_list @store1
end
@@ -887,7 +829,7 @@ Foo::Bar#bother
assert_equal 'Foo', @driver.expand_class('F')
assert_equal 'Foo::Bar', @driver.expand_class('F::Bar')
- assert_raise RDoc::RI::Driver::NotFoundError do
+ assert_raises RDoc::RI::Driver::NotFoundError do
@driver.expand_class 'F::B'
end
end
@@ -903,7 +845,7 @@ Foo::Bar#bother
@store1.save
@driver.stores = [@store1]
- assert_raise RDoc::RI::Driver::NotFoundError do
+ assert_raises RDoc::RI::Driver::NotFoundError do
@driver.expand_class 'F'
end
assert_equal 'Foo::Bar', @driver.expand_class('F::Bar')
@@ -931,7 +873,7 @@ Foo::Bar#bother
assert_equal 'Foo', @driver.expand_name('F')
assert_equal 'Foo::Bar#', @driver.expand_name('F::Bar#')
- e = assert_raise RDoc::RI::Driver::NotFoundError do
+ e = assert_raises RDoc::RI::Driver::NotFoundError do
@driver.expand_name 'Z'
end
@@ -942,7 +884,7 @@ Foo::Bar#bother
assert_equal 'ruby:README', @driver.expand_name('ruby:README')
assert_equal 'ruby:', @driver.expand_name('ruby:')
- e = assert_raise RDoc::RI::Driver::NotFoundError do
+ e = assert_raises RDoc::RI::Driver::NotFoundError do
@driver.expand_name 'nonexistent_gem:'
end
@@ -981,7 +923,6 @@ Foo::Bar#bother
[@store1, 'Foo::Bar', 'Foo::Bar', :both, 'blah'],
[@store1, 'Foo::Baz', 'Foo::Baz', :both, 'blah'],
[@store1, 'Inc', 'Inc', :both, 'blah'],
- [@store1, 'Qux', 'Qux', :both, 'blah'],
]
assert_equal expected, items
@@ -1021,7 +962,7 @@ Foo::Bar#bother
assert_equal 'gem-1.0', @driver.find_store('gem-1.0')
assert_equal 'gem-1.0', @driver.find_store('gem')
- e = assert_raise RDoc::RI::Driver::NotFoundError do
+ e = assert_raises RDoc::RI::Driver::NotFoundError do
@driver.find_store 'nonexistent'
end
@@ -1029,21 +970,21 @@ Foo::Bar#bother
end
def test_did_you_mean
- omit 'skip test with did_you_men' unless defined? DidYouMean::SpellChecker
+ skip 'skip test with did_you_men' unless defined? DidYouMean::SpellChecker
util_ancestors_store
- e = assert_raise RDoc::RI::Driver::NotFoundError do
+ e = assert_raises RDoc::RI::Driver::NotFoundError do
@driver.lookup_method 'Foo.i_methdo'
end
assert_equal "Nothing known about Foo.i_methdo\nDid you mean? i_method", e.message
- e = assert_raise RDoc::RI::Driver::NotFoundError do
+ e = assert_raises RDoc::RI::Driver::NotFoundError do
@driver.lookup_method 'Foo#i_methdo'
end
assert_equal "Nothing known about Foo#i_methdo\nDid you mean? i_method", e.message
- e = assert_raise RDoc::RI::Driver::NotFoundError do
+ e = assert_raises RDoc::RI::Driver::NotFoundError do
@driver.lookup_method 'Foo::i_methdo'
end
assert_equal "Nothing known about Foo::i_methdo\nDid you mean? c_method", e.message
@@ -1111,17 +1052,17 @@ Foo::Bar#bother
def test_list_known_classes
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.list_known_classes
end
- assert_equal "Ambiguous\nExt\nFoo\nFoo::Bar\nFoo::Baz\nInc\nQux\n", out
+ assert_equal "Ambiguous\nExt\nFoo\nFoo::Bar\nFoo::Baz\nInc\n", out
end
def test_list_known_classes_name
util_store
- out, = capture_output do
+ out, = capture_io do
@driver.list_known_classes %w[F I]
end
@@ -1186,7 +1127,7 @@ Foo::Bar#bother
method = @driver.load_method(@store2, :instance_methods, 'Bar', '#',
'inherit')
- assert_nil method
+ assert_equal nil, method
end
def test_load_methods_matching
@@ -1227,7 +1168,7 @@ Foo::Bar#bother
with_dummy_pager do
@driver.page do |io|
- omit "couldn't find a standard pager" if io == $stdout
+ skip "couldn't find a standard pager" if io == $stdout
assert @driver.paging?
end
@@ -1239,6 +1180,7 @@ Foo::Bar#bother
# this test is too fragile. Perhaps using Process.spawn will make this
# reliable
def _test_page_in_presence_of_child_status
+ skip 'this test hangs on travis-ci.org' if ENV['CI']
@driver.use_stdout = false
with_dummy_pager do
@@ -1290,7 +1232,7 @@ Foo::Bar#bother
assert_equal 'ruby', klass, 'ruby project'
assert_equal ':', type, 'ruby type'
- assert_nil meth, 'ruby page'
+ assert_equal nil, meth, 'ruby page'
end
def test_parse_name_page_extenson
@@ -1305,26 +1247,26 @@ Foo::Bar#bother
klass, type, meth = @driver.parse_name 'Foo'
assert_equal 'Foo', klass, 'Foo class'
- assert_nil type, 'Foo type'
- assert_nil meth, 'Foo method'
+ assert_equal nil, type, 'Foo type'
+ assert_equal nil, meth, 'Foo method'
klass, type, meth = @driver.parse_name 'Foo#'
assert_equal 'Foo', klass, 'Foo# class'
assert_equal '#', type, 'Foo# type'
- assert_nil meth, 'Foo# method'
+ assert_equal nil, meth, 'Foo# method'
klass, type, meth = @driver.parse_name 'Foo::'
assert_equal 'Foo', klass, 'Foo:: class'
assert_equal '::', type, 'Foo:: type'
- assert_nil meth, 'Foo:: method'
+ assert_equal nil, meth, 'Foo:: method'
klass, type, meth = @driver.parse_name 'Foo.'
assert_equal 'Foo', klass, 'Foo. class'
assert_equal '.', type, 'Foo. type'
- assert_nil meth, 'Foo. method'
+ assert_equal nil, meth, 'Foo. method'
klass, type, meth = @driver.parse_name 'Foo#Bar'
@@ -1349,14 +1291,14 @@ Foo::Bar#bother
klass, type, meth = @driver.parse_name 'Foo::Bar'
assert_equal 'Foo::Bar', klass, 'Foo::Bar class'
- assert_nil type, 'Foo::Bar type'
- assert_nil meth, 'Foo::Bar method'
+ assert_equal nil, type, 'Foo::Bar type'
+ assert_equal nil, meth, 'Foo::Bar method'
klass, type, meth = @driver.parse_name 'Foo::Bar#'
assert_equal 'Foo::Bar', klass, 'Foo::Bar# class'
assert_equal '#', type, 'Foo::Bar# type'
- assert_nil meth, 'Foo::Bar# method'
+ assert_equal nil, meth, 'Foo::Bar# method'
klass, type, meth = @driver.parse_name 'Foo::Bar#baz'
@@ -1406,7 +1348,7 @@ Foo::Bar#bother
pager = with_dummy_pager do @driver.setup_pager end
- omit "couldn't find a standard pager" unless pager
+ skip "couldn't find a standard pager" unless pager
assert @driver.paging?
ensure
@@ -1539,15 +1481,6 @@ Foo::Bar#bother
@overridden.comment = 'must not be displayed in Bar#override'
@overridden.record_location @top_level
- @cQux = @top_level.add_class RDoc::NormalClass, 'Qux'
-
- @original = @cQux.add_method RDoc::AnyMethod.new(nil, 'original')
- @original.comment = 'original comment'
- @original.record_location @top_level
-
- @aliased = @original.add_alias RDoc::Alias.new(nil, 'original', 'aliased', 'alias comment'), @cQux
- @aliased.record_location @top_level
-
@store1.save
@driver.stores = [@store1]
diff --git a/test/rdoc/test_rdoc_ri_paths.rb b/test/rdoc/test_rdoc_ri_paths.rb
index 726922daf0..b0f368353a 100644
--- a/test/rdoc/test_rdoc_ri_paths.rb
+++ b/test/rdoc/test_rdoc_ri_paths.rb
@@ -1,12 +1,11 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocRIPaths < RDoc::TestCase
def setup
super
- @orig_env = ENV.to_hash
@orig_gem_path = Gem.path
@tempdir = File.join Dir.tmpdir, "test_rdoc_ri_paths_#{$$}"
@@ -23,7 +22,7 @@ class TestRDocRIPaths < RDoc::TestCase
specs.each do |spec|
spec.loaded_from = spec.spec_file
- File.open spec.spec_file, 'w' do |file|
+ open spec.spec_file, 'w' do |file|
file.write spec.to_ruby_for_cache
end
@@ -41,7 +40,6 @@ class TestRDocRIPaths < RDoc::TestCase
Gem.use_paths(*@orig_gem_path)
Gem::Specification.reset
FileUtils.rm_rf @tempdir
- ENV.replace(@orig_env)
end
def test_class_each
diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb
index 7d59577d97..2664b35cbb 100644
--- a/test/rdoc/test_rdoc_rubygems_hook.rb
+++ b/test/rdoc/test_rdoc_rubygems_hook.rb
@@ -131,14 +131,8 @@ class TestRDocRubygemsHook < Gem::TestCase
end
def test_generate_default_gem
- Gem::Deprecate.skip_during do
- if Gem.respond_to?(:default_specifications_dir)
- klass = Gem
- else
- klass = Gem::Specification
- end
- @a.loaded_from = File.join klass.default_specifications_dir, 'a.gemspec'
- end
+ @a.loaded_from =
+ File.join Gem::Specification.default_specifications_dir, 'a.gemspec'
@hook.generate
@@ -206,8 +200,7 @@ class TestRDocRubygemsHook < Gem::TestCase
def test_remove_unwritable
skip 'chmod not supported' if Gem.win_platform?
- skip "assumes that euid is not root" if Process.euid == 0
-
+ skip 'skipped in root privilege' if Process.uid == 0
FileUtils.mkdir_p @a.base_dir
FileUtils.chmod 0, @a.base_dir
@@ -236,8 +229,7 @@ class TestRDocRubygemsHook < Gem::TestCase
def test_setup_unwritable
skip 'chmod not supported' if Gem.win_platform?
- skip "assumes that euid is not root" if Process.euid == 0
-
+ skip 'skipped in root privilege' if Process.uid == 0
FileUtils.mkdir_p @a.doc_dir
FileUtils.chmod 0, @a.doc_dir
diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb
index 1127408193..4dd1f08ddd 100644
--- a/test/rdoc/test_rdoc_servlet.rb
+++ b/test/rdoc/test_rdoc_servlet.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocServlet < RDoc::TestCase
@@ -69,7 +69,7 @@ class TestRDocServlet < RDoc::TestCase
FileUtils.mkdir 'css'
now = Time.now
- File.open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
+ open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
File.utime now, now, 'css/rdoc.css'
@s.asset_dirs[:darkfish] = '.'
@@ -143,7 +143,7 @@ class TestRDocServlet < RDoc::TestCase
@s.asset_dirs[:darkfish] = '.'
- @req.path = '/mount/path/css/rdoc.css'.dup
+ @req.path = '/mount/path/css/rdoc.css'
@s.do_GET @req, @res
@@ -166,7 +166,7 @@ class TestRDocServlet < RDoc::TestCase
@req.header['if-modified-since'] = [(Time.now + 10).httpdate]
@req.path = '/ruby/Missing.html'
- assert_raise WEBrick::HTTPStatus::NotModified do
+ assert_raises WEBrick::HTTPStatus::NotModified do
@s.do_GET @req, @res
end
end
@@ -224,7 +224,8 @@ class TestRDocServlet < RDoc::TestCase
generator = @s.generator_for store
- store.add_file 'README.rdoc', parser: RDoc::Parser::Simple
+ readme = store.add_file 'README.rdoc'
+ readme.parser = RDoc::Parser::Simple
@s.documentation_page store, generator, 'README_rdoc.html', @req, @res
@@ -232,18 +233,6 @@ class TestRDocServlet < RDoc::TestCase
assert_match %r%<body [^>]+ class="file">%, @res.body
end
- def test_documentation_page_page_with_nesting
- store = RDoc::Store.new
-
- generator = @s.generator_for store
-
- store.add_file 'nesting/README.rdoc', parser: RDoc::Parser::Simple
-
- @s.documentation_page store, generator, 'nesting/README_rdoc.html', @req, @res
-
- assert_equal 200, @res.status
- end
-
def test_documentation_source
store, path = @s.documentation_source '/ruby/Object.html'
@@ -294,7 +283,7 @@ class TestRDocServlet < RDoc::TestCase
end
def test_if_modified_since
- omit 'File.utime on directory not supported' if Gem.win_platform?
+ skip 'File.utime on directory not supported' if Gem.win_platform?
temp_dir do
now = Time.now
@@ -307,7 +296,7 @@ class TestRDocServlet < RDoc::TestCase
end
def test_if_modified_since_not_modified
- omit 'File.utime on directory not supported' if Gem.win_platform?
+ skip 'File.utime on directory not supported' if Gem.win_platform?
temp_dir do
now = Time.now
@@ -315,7 +304,7 @@ class TestRDocServlet < RDoc::TestCase
@req.header['if-modified-since'] = [(now + 10).httpdate]
- assert_raise WEBrick::HTTPStatus::NotModified do
+ assert_raises WEBrick::HTTPStatus::NotModified do
@s.if_modified_since @req, @res, '.'
end
@@ -490,7 +479,7 @@ class TestRDocServlet < RDoc::TestCase
def test_store_for_missing_documentation
FileUtils.mkdir_p(File.join @gem_doc_dir, 'spec-1.0', 'ri')
- e = assert_raise WEBrick::HTTPStatus::NotFound do
+ e = assert_raises WEBrick::HTTPStatus::NotFound do
@s.store_for 'spec-1.0'
end
@@ -499,7 +488,7 @@ class TestRDocServlet < RDoc::TestCase
end
def test_store_for_missing_gem
- e = assert_raise WEBrick::HTTPStatus::NotFound do
+ e = assert_raises WEBrick::HTTPStatus::NotFound do
@s.store_for 'missing'
end
diff --git a/test/rdoc/test_rdoc_single_class.rb b/test/rdoc/test_rdoc_single_class.rb
index ee242d7bc9..5761bfef4d 100644
--- a/test/rdoc/test_rdoc_single_class.rb
+++ b/test/rdoc/test_rdoc_single_class.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocSingleClass < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_stats.rb b/test/rdoc/test_rdoc_stats.rb
index b9918e4fd3..19fc2365b3 100644
--- a/test/rdoc/test_rdoc_stats.rb
+++ b/test/rdoc/test_rdoc_stats.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocStats < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb
index 8332d9233e..4a4cf3ac0f 100644
--- a/test/rdoc/test_rdoc_store.rb
+++ b/test/rdoc/test_rdoc_store.rb
@@ -14,7 +14,8 @@ class TestRDocStore < XrefTestCase
@top_level = @s.add_file 'file.rb'
- @page = @s.add_file 'README.txt', parser: RDoc::Parser::Simple
+ @page = @s.add_file 'README.txt'
+ @page.parser = RDoc::Parser::Simple
@page.comment = RDoc::Comment.new 'This is a page', @page
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
@@ -145,7 +146,7 @@ class TestRDocStore < XrefTestCase
end
def test_add_file_relative
- top_level = @store.add_file 'path/file.rb', relative_name: 'file.rb'
+ top_level = @store.add_file 'path/file.rb', 'file.rb'
assert_kind_of RDoc::TopLevel, top_level
assert_equal @store, top_level.store
@@ -161,7 +162,7 @@ class TestRDocStore < XrefTestCase
def test_all_classes_and_modules
expected = %w[
- C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 C9 C9::A C9::B
+ C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7
Child
M1 M1::M2
Parent
@@ -172,7 +173,7 @@ class TestRDocStore < XrefTestCase
end
def test_all_files
- assert_equal %w[EXAMPLE.md xref_data.rb],
+ assert_equal %w[xref_data.rb],
@store.all_files.map { |m| m.full_name }.sort
end
@@ -212,7 +213,7 @@ class TestRDocStore < XrefTestCase
def test_classes
expected = %w[
- C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 C9 C9::A C9::B
+ C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7
Child
Parent
]
@@ -221,8 +222,7 @@ class TestRDocStore < XrefTestCase
end
def test_complete
- a1 = RDoc::Constant.new 'A1', '', ''
- @c2.add_module_alias @c2_c3, @c2_c3.name, a1, @top_level
+ @c2.add_module_alias @c2_c3, 'A1', @top_level
@store.complete :public
@@ -309,7 +309,8 @@ class TestRDocStore < XrefTestCase
end
def test_find_text_page
- page = @store.add_file 'PAGE.txt', parser: RDoc::Parser::Simple
+ page = @store.add_file 'PAGE.txt'
+ page.parser = RDoc::Parser::Simple
assert_nil @store.find_text_page 'no such page'
@@ -406,7 +407,7 @@ class TestRDocStore < XrefTestCase
Dir.mkdir @tmpdir
- File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
+ open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@@ -440,7 +441,7 @@ class TestRDocStore < XrefTestCase
Dir.mkdir @tmpdir
- File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
+ open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@@ -489,7 +490,7 @@ class TestRDocStore < XrefTestCase
Dir.mkdir @tmpdir
- File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
+ open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@@ -523,15 +524,6 @@ class TestRDocStore < XrefTestCase
assert_includes @s.classes_hash, 'Object'
end
- def test_load_single_class
- @s.save_class @c8_s1
- @s.classes_hash.clear
-
- assert_equal @c8_s1, @s.load_class('C8::S1')
-
- assert_includes @s.classes_hash, 'C8::S1'
- end
-
def test_load_method
@s.save_method @klass, @meth_bang
@@ -546,7 +538,7 @@ class TestRDocStore < XrefTestCase
file = @s.method_file @klass.full_name, @meth.full_name
- File.open file, 'wb' do |io|
+ open file, 'wb' do |io|
io.write "\x04\bU:\x14RDoc::AnyMethod[\x0Fi\x00I" +
"\"\vmethod\x06:\x06EF\"\x11Klass#method0:\vpublic" +
"o:\eRDoc::Markup::Document\x06:\v@parts[\x06" +
@@ -571,7 +563,7 @@ class TestRDocStore < XrefTestCase
end
def test_main
- assert_nil @s.main
+ assert_equal nil, @s.main
@s.main = 'README.txt'
@@ -599,7 +591,8 @@ class TestRDocStore < XrefTestCase
end
def test_page
- page = @store.add_file 'PAGE.txt', parser: RDoc::Parser::Simple
+ page = @store.add_file 'PAGE.txt'
+ page.parser = RDoc::Parser::Simple
assert_nil @store.page 'no such page'
@@ -640,7 +633,7 @@ class TestRDocStore < XrefTestCase
expected[:ancestors]['Object'] = %w[BasicObject]
- File.open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
+ open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
cache = Marshal.load io.read
assert_equal expected, cache
@@ -708,7 +701,7 @@ class TestRDocStore < XrefTestCase
expected[:ancestors]['Object'] = %w[BasicObject]
- File.open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
+ open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
cache = Marshal.load io.read
assert_equal expected, cache
@@ -988,7 +981,7 @@ class TestRDocStore < XrefTestCase
end
def test_title
- assert_nil @s.title
+ assert_equal nil, @s.title
@s.title = 'rdoc'
diff --git a/test/rdoc/test_rdoc_task.rb b/test/rdoc/test_rdoc_task.rb
index d9fc6664fd..ac3512f42a 100644
--- a/test/rdoc/test_rdoc_task.rb
+++ b/test/rdoc/test_rdoc_task.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
begin
require 'rake'
rescue LoadError
@@ -20,19 +20,19 @@ class TestRDocTask < RDoc::TestCase
end
def test_inline_source
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
assert @t.inline_source
end
assert_equal "RDoc::Task#inline_source is deprecated\n", err
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
@t.inline_source = false
end
assert_equal "RDoc::Task#inline_source is deprecated\n", err
- capture_output do
+ capture_io do
assert @t.inline_source
end
end
@@ -131,7 +131,7 @@ class TestRDocTask < RDoc::TestCase
assert Rake::Task[:"rdoc"]
assert Rake::Task[:"rdoc:clean"]
assert Rake::Task[:"rdoc:force"]
- assert_raise(RuntimeError) { Rake::Task[:clobber_rdoc] }
+ assert_raises(RuntimeError) { Rake::Task[:clobber_rdoc] }
assert_equal options, rd.name
end
@@ -143,7 +143,7 @@ class TestRDocTask < RDoc::TestCase
end
def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
- assert_raise(ArgumentError) do
+ assert_raises(ArgumentError) do
RDoc::Task.new(:foo => "bar")
end
diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb
index 59d63b29bd..9f0e9480d3 100644
--- a/test/rdoc/test_rdoc_text.rb
+++ b/test/rdoc/test_rdoc_text.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-require_relative 'helper'
-require 'timeout'
+require 'rdoc/test_case'
class TestRDocText < RDoc::TestCase
@@ -13,7 +12,6 @@ class TestRDocText < RDoc::TestCase
@options = RDoc::Options.new
@top_level = @store.add_file 'file.rb'
- @language = nil
end
def test_self_encode_fallback
@@ -138,8 +136,6 @@ we don't worry too much.
The comments associated with
EXPECTED
- @language = :ruby
-
assert_equal expected, normalize_comment(text)
end
@@ -158,8 +154,6 @@ we don't worry too much.
The comments associated with
EXPECTED
- @language = :c
-
assert_equal expected, normalize_comment(text)
end
@@ -178,8 +172,6 @@ we don't worry too much.
The comments associated with
EXPECTED
- @language = :c
-
assert_equal expected, normalize_comment(text)
end
@@ -207,8 +199,6 @@ The comments associated with
end
def test_parse_empty_newline
- @language = :ruby
-
assert_equal RDoc::Markup::Document.new, parse("#\n")
end
@@ -268,7 +258,8 @@ paragraph will be cut off some point after the one-hundredth character.
TEXT
expected = <<-EXPECTED
-<p>This is one-hundred characters or more of text in a single paragraph. This paragraph will be cut off …
+<p>This is one-hundred characters or more of text in a single paragraph. This
+paragraph will be cut off …
EXPECTED
assert_equal expected, snippet(text)
@@ -386,32 +377,6 @@ paragraph will be cut off some point after the one-hundredth character.
assert_equal expected, strip_stars(text)
end
- def test_strip_stars_document_method_special
- text = <<-TEXT
-/*
- * Document-method: Zlib::GzipFile#mtime=
- * Document-method: []
- * Document-method: `
- * Document-method: |
- * Document-method: &
- * Document-method: <=>
- * Document-method: =~
- * Document-method: +
- * Document-method: -
- * Document-method: +@
- *
- * A comment
- */
- TEXT
-
- expected = <<-EXPECTED
-
- A comment
- EXPECTED
-
- assert_equal expected, strip_stars(text)
- end
-
def test_strip_stars_encoding
text = <<-TEXT
/*
@@ -557,7 +522,7 @@ The comments associated with
end
def test_to_html_tt_tag_mismatch
- _, err = verbose_capture_output do
+ _, err = verbose_capture_io do
assert_equal '<tt>hi', to_html('<tt>hi')
end
diff --git a/test/rdoc/test_rdoc_token_stream.rb b/test/rdoc/test_rdoc_token_stream.rb
index cdfa615dae..abf1469bbc 100644
--- a/test/rdoc/test_rdoc_token_stream.rb
+++ b/test/rdoc/test_rdoc_token_stream.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocTokenStream < RDoc::TestCase
@@ -39,20 +39,5 @@ class TestRDocTokenStream < RDoc::TestCase
assert_equal '', RDoc::TokenStream.to_html([])
end
- def test_tokens_to_s
- foo = Class.new do
- include RDoc::TokenStream
-
- def initialize
- @token_stream = [
- { line_no: 0, char_no: 0, kind: :on_ident, text: "foo" },
- { line_no: 0, char_no: 0, kind: :on_sp, text: " " },
- { line_no: 0, char_no: 0, kind: :on_tstring, text: "'bar'" },
- ]
- end
- end.new
-
- assert_equal "foo 'bar'", foo.tokens_to_s
- end
end
diff --git a/test/rdoc/test_rdoc_tom_doc.rb b/test/rdoc/test_rdoc_tom_doc.rb
index ddecea4b21..15bbd9b32d 100644
--- a/test/rdoc/test_rdoc_tom_doc.rb
+++ b/test/rdoc/test_rdoc_tom_doc.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'helper'
+require 'rdoc/test_case'
class TestRDocTomDoc < RDoc::TestCase
@@ -301,44 +301,6 @@ Returns another thing
assert_equal expected, @TD.parse(text)
end
- def test_parse_returns_with_raises
- text = <<-TEXT
-Do some stuff
-
-Returns a thing
-Raises ArgumentError when stuff
-Raises StandardError when stuff
- TEXT
- expected =
- doc(
- para('Do some stuff'),
- blank_line,
- head(3, 'Returns'),
- blank_line,
- para('Returns a thing'),
- para('Raises ArgumentError when stuff'),
- para('Raises StandardError when stuff'))
-
- assert_equal expected, @TD.parse(text)
- end
-
- def test_parse_raises_without_returns
- text = <<-TEXT
-Do some stuff
-
-Raises ArgumentError when stuff
- TEXT
- expected =
- doc(
- para('Do some stuff'),
- blank_line,
- head(3, 'Returns'),
- blank_line,
- para('Raises ArgumentError when stuff'))
-
- assert_equal expected, @TD.parse(text)
- end
-
def test_parse_returns_multiline
text = <<-TEXT
Do some stuff
@@ -358,27 +320,6 @@ Returns a thing
assert_equal expected, @TD.parse(text)
end
- def test_parse_returns_multiline_and_raises
- text = <<-TEXT
-Do some stuff
-
-Returns a thing
- that is multiline
-Raises ArgumentError
- TEXT
-
- expected =
- doc(
- para('Do some stuff'),
- blank_line,
- head(3, 'Returns'),
- blank_line,
- para('Returns a thing', ' ', 'that is multiline'),
- para('Raises ArgumentError'))
-
- assert_equal expected, @TD.parse(text)
- end
-
def test_parse_signature
text = <<-TEXT
Do some stuff
@@ -577,3 +518,4 @@ Returns a thing
end
end
+
diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb
index e396791ab8..00fc7a1bd5 100644
--- a/test/rdoc/test_rdoc_top_level.rb
+++ b/test/rdoc/test_rdoc_top_level.rb
@@ -160,7 +160,7 @@ class TestRDocTopLevel < XrefTestCase
end
def test_last_modified
- assert_nil @top_level.last_modified
+ assert_equal nil, @top_level.last_modified
stat = Object.new
def stat.mtime() 0 end
@top_level.file_stat = stat
diff --git a/test/rdoc/xref_data.rb b/test/rdoc/xref_data.rb
index aa9faaecd9..bc20d8ed91 100644
--- a/test/rdoc/xref_data.rb
+++ b/test/rdoc/xref_data.rb
@@ -20,8 +20,6 @@ class C1
def m foo
end
- def +
- end
end
class C2
@@ -96,25 +94,6 @@ class C7
CONST_NODOC = :const_nodoc # :nodoc:
end
-class C8
- class << self
- class S1
- end
- end
-end
-
-class C9
- class A
- def foo() end
- def self.bar() end
- end
-
- class B < A
- def self.foo() end
- def bar() end
- end
-end
-
module M1
def m
end
diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb
index 729e4a70b7..9f709964c6 100644
--- a/test/rdoc/xref_test_case.rb
+++ b/test/rdoc/xref_test_case.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
ENV['RDOC_TEST'] = 'yes'
-require_relative 'helper'
+require 'rdoc'
require File.expand_path '../xref_data', __FILE__
class XrefTestCase < RDoc::TestCase
@@ -22,13 +22,8 @@ class XrefTestCase < RDoc::TestCase
parser = RDoc::Parser::Ruby.new @xref_data, @file_name, XREF_DATA, @options,
stats
-
- @example_md = @store.add_file 'EXAMPLE.md'
- @example_md.parser = RDoc::Parser::Markdown
-
@top_levels = []
@top_levels.push parser.scan
- @top_levels.push @example_md
generator = Object.new
def generator.class_dir() nil end
@@ -36,10 +31,9 @@ class XrefTestCase < RDoc::TestCase
@rdoc.options = @options
@rdoc.generator = generator
- @c1 = @xref_data.find_module_named 'C1'
- @c1__m = @c1.find_class_method_named 'm' # C1::m
- @c1_m = @c1.find_instance_method_named 'm' # C1#m
- @c1_plus = @c1.find_instance_method_named '+'
+ @c1 = @xref_data.find_module_named 'C1'
+ @c1_m = @c1.method_list.last # C1#m
+ @c1__m = @c1.method_list.first # C1::m
@c2 = @xref_data.find_module_named 'C2'
@c2_a = @c2.method_list.last
@@ -59,16 +53,6 @@ class XrefTestCase < RDoc::TestCase
@c3_h2 = @xref_data.find_module_named 'C3::H2'
@c6 = @xref_data.find_module_named 'C6'
@c7 = @xref_data.find_module_named 'C7'
- @c8 = @xref_data.find_module_named 'C8'
- @c8_s1 = @xref_data.find_module_named 'C8::S1'
-
- @c9 = @xref_data.find_module_named 'C9'
- @c9_a = @xref_data.find_module_named 'C9::A'
- @c9_a_i_foo = @c9_a.method_list.first
- @c9_a_c_bar = @c9_a.method_list.last
- @c9_b = @xref_data.find_module_named 'C9::B'
- @c9_b_c_foo = @c9_b.method_list.first
- @c9_b_i_bar = @c9_b.method_list.last
@m1 = @xref_data.find_module_named 'M1'
@m1_m = @m1.method_list.first
diff --git a/test/readline/helper.rb b/test/readline/helper.rb
deleted file mode 100644
index 1b80327b57..0000000000
--- a/test/readline/helper.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-begin
- require "readline.so"
- ReadlineSo = Readline
-rescue LoadError
-end
-
-def use_ext_readline # Use ext/readline as Readline
- Object.send(:remove_const, :Readline) if Object.const_defined?(:Readline)
- Object.const_set(:Readline, ReadlineSo)
-end
-
-begin
- require "reline"
-rescue LoadError
-else
- def use_lib_reline # Use lib/reline as Readline
- Reline.send(:remove_const, 'IOGate') if Reline.const_defined?('IOGate')
- Reline.const_set('IOGate', Reline::GeneralIO)
- Reline.send(:core).config.instance_variable_set(:@test_mode, true)
- Reline.send(:core).config.reset
- Object.send(:remove_const, :Readline) if Object.const_defined?(:Readline)
- Object.const_set(:Readline, Reline)
- end
-end
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index 12cac20918..68c1ff7312 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -1,10 +1,14 @@
# frozen_string_literal: false
-require_relative "helper"
-require "test/unit"
-require "tempfile"
-require "timeout"
+begin
+ require "readline"
+rescue LoadError
+else
+ require "test/unit"
+ require "tempfile"
+ require "timeout"
+end
-module BasetestReadline
+class TestReadline < Test::Unit::TestCase
INPUTRC = "INPUTRC"
SAVED_ENV = %w[COLUMNS LINES]
@@ -21,108 +25,92 @@ module BasetestReadline
Readline.point = 0
rescue NotImplementedError
end
- Readline.special_prefixes = ""
- Readline.completion_append_character = nil
Readline.input = nil
Readline.output = nil
SAVED_ENV.each_with_index {|k, i| ENV[k] = @saved_env[i] }
end
- def test_readline
- Readline::HISTORY.clear
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- with_temp_stdio do |stdin, stdout|
- stdin.write("hello\n")
- stdin.close
- stdout.flush
- line = replace_stdio(stdin.path, stdout.path) {
- Readline.readline("> ", true)
- }
- assert_equal("hello", line)
- assert_equal(true, line.tainted?) if RUBY_VERSION < '2.7'
- stdout.rewind
- assert_equal("> ", stdout.read(2))
- assert_equal(1, Readline::HISTORY.length)
- assert_equal("hello", Readline::HISTORY[0])
-
- # Work around lack of SecurityError in Reline
- # test mode with tainted prompt.
- # Also skip test on Ruby 2.7+, where $SAFE/taint is deprecated.
- if RUBY_VERSION < '2.7' && defined?(TestRelineAsReadline) && !kind_of?(TestRelineAsReadline)
- begin
- Thread.start {
- $SAFE = 1
- assert_raise(SecurityError) do
- replace_stdio(stdin.path, stdout.path) do
- Readline.readline("> ".taint)
- end
+ if !/EditLine/n.match(Readline::VERSION)
+ def test_readline
+ with_temp_stdio do |stdin, stdout|
+ stdin.write("hello\n")
+ stdin.close
+ stdout.flush
+ line = replace_stdio(stdin.path, stdout.path) {
+ Readline.readline("> ", true)
+ }
+ assert_equal("hello", line)
+ assert_equal(true, line.tainted?)
+ stdout.rewind
+ assert_equal("> ", stdout.read(2))
+ assert_equal(1, Readline::HISTORY.length)
+ assert_equal("hello", Readline::HISTORY[0])
+ Thread.start {
+ $SAFE = 1
+ assert_raise(SecurityError) do
+ replace_stdio(stdin.path, stdout.path) do
+ Readline.readline("> ".taint)
end
- }.join
- ensure
- $SAFE = 0
- end
+ end
+ }.join
end
end
- end
-
- # line_buffer
- # point
- def test_line_buffer__point
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- omit "GNU Readline has special behaviors" if defined?(Reline) and Readline == Reline
- begin
- Readline.line_buffer
- Readline.point
- rescue NotImplementedError
- return
- end
-
- with_temp_stdio do |stdin, stdout|
- actual_text = nil
- actual_line_buffer = nil
- actual_point = nil
- Readline.completion_proc = ->(text) {
- actual_text = text
- actual_point = Readline.point
- actual_line_buffer = Readline.line_buffer
- stdin.write(" finish\n")
- stdin.flush
- stdout.flush
- return ["complete"]
- }
-
- stdin.write("first second\t")
- stdin.flush
- Readline.completion_append_character = " "
- replace_stdio(stdin.path, stdout.path) {
- Readline.readline("> ", false)
- }
- assert_equal("second", actual_text)
- assert_equal("first second", actual_line_buffer)
- assert_equal(12, actual_point)
- assert_equal("first complete finish", Readline.line_buffer)
- assert_equal(Encoding.find("locale"), Readline.line_buffer.encoding)
- assert_equal(true, Readline.line_buffer.tainted?) if RUBY_VERSION < '2.7'
- assert_equal(22, Readline.point)
+ # line_buffer
+ # point
+ def test_line_buffer__point
+ begin
+ Readline.line_buffer
+ Readline.point
+ rescue NotImplementedError
+ return
+ end
- stdin.rewind
- stdout.rewind
+ with_temp_stdio do |stdin, stdout|
+ actual_text = nil
+ actual_line_buffer = nil
+ actual_point = nil
+ Readline.completion_proc = ->(text) {
+ actual_text = text
+ actual_point = Readline.point
+ actual_line_buffer = Readline.line_buffer
+ stdin.write(" finish\n")
+ stdin.flush
+ stdout.flush
+ return ["complete"]
+ }
- stdin.write("first second\t")
- stdin.flush
- Readline.completion_append_character = nil
- replace_stdio(stdin.path, stdout.path) {
- Readline.readline("> ", false)
- }
- assert_equal("second", actual_text)
- assert_equal("first second", actual_line_buffer)
- assert_equal(12, actual_point)
- assert_equal("first complete finish", Readline.line_buffer)
- assert_equal(Encoding.find("locale"), Readline.line_buffer.encoding)
- assert_equal(true, Readline.line_buffer.tainted?) if RUBY_VERSION < '2.7'
-
- assert_equal(21, Readline.point)
+ stdin.write("first second\t")
+ stdin.flush
+ Readline.completion_append_character = " "
+ replace_stdio(stdin.path, stdout.path) {
+ Readline.readline("> ", false)
+ }
+ assert_equal("second", actual_text)
+ assert_equal("first second", actual_line_buffer)
+ assert_equal(12, actual_point)
+ assert_equal("first complete finish", Readline.line_buffer)
+ assert_equal(Encoding.find("locale"), Readline.line_buffer.encoding)
+ assert_equal(true, Readline.line_buffer.tainted?)
+ assert_equal(22, Readline.point)
+
+ stdin.rewind
+ stdout.rewind
+
+ stdin.write("first second\t")
+ stdin.flush
+ Readline.completion_append_character = nil
+ replace_stdio(stdin.path, stdout.path) {
+ Readline.readline("> ", false)
+ }
+ assert_equal("second", actual_text)
+ assert_equal("first second", actual_line_buffer)
+ assert_equal(12, actual_point)
+ assert_equal("first complete finish", Readline.line_buffer)
+ assert_equal(Encoding.find("locale"), Readline.line_buffer.encoding)
+ assert_equal(true, Readline.line_buffer.tainted?)
+ assert_equal(21, Readline.point)
+ end
end
end
@@ -150,17 +138,13 @@ module BasetestReadline
def test_completion_case_fold
expected = [true, false, "string", {"a" => "b"}]
- completion_case_fold = Readline.completion_case_fold
expected.each do |e|
Readline.completion_case_fold = e
assert_equal(e, Readline.completion_case_fold)
end
- ensure
- Readline.completion_case_fold = completion_case_fold
end
def test_completion_proc_empty_result
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
with_temp_stdio do |stdin, stdout|
stdin.write("first\t")
stdin.flush
@@ -179,7 +163,7 @@ module BasetestReadline
rescue NotimplementedError
end
end
- end
+ end if !/EditLine/n.match(Readline::VERSION)
def test_get_screen_size
begin
@@ -239,12 +223,11 @@ module BasetestReadline
end
def test_completion_encoding
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
bug5941 = '[Bug #5941]'
append_character = Readline.completion_append_character
Readline.completion_append_character = ""
completion_case_fold = Readline.completion_case_fold
- locale = get_default_internal_encoding
+ locale = Encoding.find("locale")
if locale == Encoding::UTF_8
enc1 = Encoding::EUC_JP
else
@@ -267,7 +250,7 @@ module BasetestReadline
end or
begin
return if assert_under_utf8
- omit("missing test for locale #{locale.name}")
+ skip("missing test for locale #{locale.name}")
end
expected = results[0][0...1]
Readline.completion_case_fold = false
@@ -279,10 +262,9 @@ module BasetestReadline
with_pipe {|r, w| w << "\t"}
end
ensure
- return if /EditLine/n.match(Readline::VERSION)
Readline.completion_case_fold = completion_case_fold
Readline.completion_append_character = append_character
- end
+ end if !/EditLine/n.match(Readline::VERSION)
# basic_word_break_characters
# completer_word_break_characters
@@ -291,6 +273,32 @@ module BasetestReadline
# filename_quote_characters
# special_prefixes
def test_some_characters_methods
+ method_names = [
+ "basic_word_break_characters",
+ "completer_word_break_characters",
+ "basic_quote_characters",
+ "completer_quote_characters",
+ "filename_quote_characters",
+ "special_prefixes",
+ ]
+ method_names.each do |method_name|
+ begin
+ begin
+ enc = get_default_internal_encoding
+ saved = Readline.send(method_name.to_sym)
+ expecteds = [" ", " .,|\t", ""]
+ expecteds.each do |e|
+ Readline.send((method_name + "=").to_sym, e)
+ res = Readline.send(method_name.to_sym)
+ assert_equal(e, res)
+ assert_equal(enc, res.encoding)
+ end
+ ensure
+ Readline.send((method_name + "=").to_sym, saved) if saved
+ end
+ rescue NotImplementedError
+ end
+ end
end
def test_closed_outstream
@@ -315,7 +323,6 @@ module BasetestReadline
end
def test_point
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
assert_equal(0, Readline.point)
Readline.insert_text('12345')
assert_equal(5, Readline.point)
@@ -327,10 +334,9 @@ module BasetestReadline
assert_equal('1234abc5', Readline.line_buffer)
rescue NotImplementedError
- end
+ end if !/EditLine/n.match(Readline::VERSION)
def test_insert_text
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
str = "test_insert_text"
assert_equal(0, Readline.point)
assert_equal(Readline, Readline.insert_text(str))
@@ -358,10 +364,9 @@ module BasetestReadline
Readline.delete_text
assert_equal("", Readline.line_buffer)
rescue NotImplementedError
- end
+ end if !/EditLine/n.match(Readline::VERSION)
def test_delete_text
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
str = "test_insert_text"
assert_equal(0, Readline.point)
assert_equal(Readline, Readline.insert_text(str))
@@ -369,19 +374,16 @@ module BasetestReadline
assert_equal(str, Readline.line_buffer)
Readline.delete_text
- if !defined?(Reline) or Readline != Reline
- # NOTE: unexpected but GNU Readline's spec
- assert_equal(16, Readline.point)
- assert_equal("", Readline.line_buffer)
- assert_equal(Readline, Readline.insert_text(str))
- assert_equal(32, Readline.point)
- assert_equal("", Readline.line_buffer)
- end
+ # NOTE: unexpected but GNU Readline's spec
+ assert_equal(16, Readline.point)
+ assert_equal("", Readline.line_buffer)
+ assert_equal(Readline, Readline.insert_text(str))
+ assert_equal(32, Readline.point)
+ assert_equal("", Readline.line_buffer)
rescue NotImplementedError
- end
+ end if !/EditLine/n.match(Readline::VERSION)
def test_modify_text_in_pre_input_hook
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
with_temp_stdio {|stdin, stdout|
begin
stdin.write("world\n")
@@ -395,11 +397,7 @@ module BasetestReadline
line = Readline.readline("> ")
assert_equal("hello world", line)
end
- # Readline 4.3 doesn't include inserted text or input
- # Reline's rendering logic is tricky
- if Readline::VERSION != '4.3' and (!defined?(Reline) or Readline != Reline)
- assert_equal("> hello world\n", stdout.read)
- end
+ assert_equal("> hello world\n", stdout.read)
stdout.close
rescue NotImplementedError
ensure
@@ -409,13 +407,9 @@ module BasetestReadline
end
end
}
- end
+ end if !/EditLine|\A4\.3\z/n.match(Readline::VERSION)
def test_input_metachar
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- # test will pass on Windows reline, but not readline
- omit "Won't pass on mingw readline.so using 8.0.001" if /mingw/ =~ RUBY_PLATFORM and defined?(TestReadline) and kind_of?(TestReadline)
- omit 'Needs GNU Readline 6 or later' if /mswin|mingw/ =~ RUBY_PLATFORM and defined?(TestReadline) and kind_of?(TestReadline) and Readline::VERSION < '6.0'
bug6601 = '[ruby-core:45682]'
Readline::HISTORY << "hello"
wo = nil
@@ -425,17 +419,15 @@ module BasetestReadline
end
assert_equal("hello", line, bug6601)
ensure
- wo&.close
- return if /EditLine/n.match(Readline::VERSION)
+ wo.close
Readline.delete_text
Readline::HISTORY.clear
- end
+ end if !/EditLine/n.match(Readline::VERSION)
def test_input_metachar_multibyte
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
unless Encoding.find("locale") == Encoding::UTF_8
return if assert_under_utf8
- omit 'this test needs UTF-8 locale'
+ skip 'this test needs UTF-8 locale'
end
bug6602 = '[ruby-core:45683]'
Readline::HISTORY << "\u3042\u3093"
@@ -456,14 +448,11 @@ module BasetestReadline
end
end
ensure
- return if /EditLine/n.match(Readline::VERSION)
Readline.delete_text
Readline::HISTORY.clear
- end
+ end if !/EditLine/n.match(Readline::VERSION)
def test_refresh_line
- omit "Only when refresh_line exists" unless Readline.respond_to?(:refresh_line)
- omit unless respond_to?(:assert_ruby_status)
bug6232 = '[ruby-core:43957] [Bug #6232] refresh_line after set_screen_size'
with_temp_stdio do |stdin, stdout|
replace_stdio(stdin.path, stdout.path) do
@@ -473,7 +462,7 @@ module BasetestReadline
end;
end
end
- end
+ end if Readline.respond_to?(:refresh_line)
def test_setting_quoting_detection_proc
return unless Readline.respond_to?(:quoting_detection_proc=)
@@ -490,229 +479,75 @@ module BasetestReadline
def test_using_quoting_detection_proc
saved_completer_quote_characters = Readline.completer_quote_characters
saved_completer_word_break_characters = Readline.completer_word_break_characters
-
- # skip if previous value is nil because Readline... = nil is not allowed.
- skip unless saved_completer_quote_characters
- skip unless saved_completer_word_break_characters
-
return unless Readline.respond_to?(:quoting_detection_proc=)
- begin
- passed_text = nil
- line = nil
-
- with_temp_stdio do |stdin, stdout|
- replace_stdio(stdin.path, stdout.path) do
- Readline.completion_proc = ->(text) do
- passed_text = text
- ['completion'].map { |i|
- i.encode(Encoding.default_external)
- }
- end
- Readline.completer_quote_characters = '\'"'
- Readline.completer_word_break_characters = ' '
- Readline.quoting_detection_proc = ->(text, index) do
- index > 0 && text[index-1] == '\\'
- end
-
- stdin.write("first second\\ third\t")
- stdin.flush
- line = Readline.readline('> ', false)
- end
- end
-
- assert_equal('second\\ third', passed_text)
- assert_equal('first completion', line.chomp(' '))
- ensure
- Readline.completer_quote_characters = saved_completer_quote_characters
- Readline.completer_word_break_characters = saved_completer_word_break_characters
- end
- end
-
- def test_using_quoting_detection_proc_with_multibyte_input
- Readline.completion_append_character = nil
- saved_completer_quote_characters = Readline.completer_quote_characters
- saved_completer_word_break_characters = Readline.completer_word_break_characters
-
- # skip if previous value is nil because Readline... = nil is not allowed.
- skip unless saved_completer_quote_characters
- skip unless saved_completer_word_break_characters
-
- return unless Readline.respond_to?(:quoting_detection_proc=)
- unless get_default_internal_encoding == Encoding::UTF_8
- return if assert_under_utf8
- omit 'this test needs UTF-8 locale'
- end
-
- begin
- passed_text = nil
- escaped_char_indexes = []
- line = nil
-
- with_temp_stdio do |stdin, stdout|
- replace_stdio(stdin.path, stdout.path) do
- Readline.completion_proc = ->(text) do
- passed_text = text
- ['completion'].map { |i|
- i.encode(Encoding.default_external)
- }
- end
- Readline.completer_quote_characters = '\'"'
- Readline.completer_word_break_characters = ' '
- Readline.quoting_detection_proc = ->(text, index) do
- escaped = index > 0 && text[index-1] == '\\'
- escaped_char_indexes << index if escaped
- escaped
- end
-
- stdin.write("\u3042\u3093 second\\ third\t")
- stdin.flush
- line = Readline.readline('> ', false)
- end
- end
-
- assert_equal([10], escaped_char_indexes)
- assert_equal('second\\ third', passed_text)
- assert_equal("\u3042\u3093 completion#{Readline.completion_append_character}", line)
- ensure
- Readline.completer_quote_characters = saved_completer_quote_characters
- Readline.completer_word_break_characters = saved_completer_word_break_characters
- end
- end
-
- def test_simple_completion
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
-
+ passed_text = nil
line = nil
- open(IO::NULL, 'w') do |null|
- IO.pipe do |r, w|
- Readline.input = r
- Readline.output = null
+ with_temp_stdio do |stdin, stdout|
+ replace_stdio(stdin.path, stdout.path) do
Readline.completion_proc = ->(text) do
- ['abcde', 'abc12'].map { |i|
- i.encode(get_default_internal_encoding)
- }
+ passed_text = text
+ ['completion']
end
- w.write("a\t\n")
- w.flush
- begin
- stderr = $stderr.dup
- $stderr.reopen(null)
- line = Readline.readline('> ', false)
- ensure
- $stderr.reopen(stderr)
- stderr.close
+ Readline.completer_quote_characters = '\'"'
+ Readline.completer_word_break_characters = ' '
+ Readline.quoting_detection_proc = ->(text, index) do
+ index > 0 && text[index-1] == '\\'
end
- end
- end
-
- assert_equal('abc', line)
- end
-
- def test_completion_with_completion_append_character
- omit "Skip Editline" if /EditLine/n.match(Readline::VERSION)
- omit "Readline.completion_append_character is not implemented" unless Readline.respond_to?(:completion_append_character=)
- line = nil
- append_character = Readline.completion_append_character
- open(IO::NULL, 'w') do |null|
- IO.pipe do |r, w|
- Readline.input = r
- Readline.output = null
- Readline.completion_append_character = '!'
- Readline.completion_proc = ->(text) do
- ['abcde'].map { |i|
- i.encode(get_default_internal_encoding)
- }
- end
- w.write("a\t\n")
- w.flush
+ stdin.write("first second\\ third\t")
+ stdin.flush
line = Readline.readline('> ', false)
end
end
- assert_equal('abcde!', line)
+ assert_equal('second\\ third', passed_text)
+ assert_equal('first completion', line)
ensure
- return if /EditLine/n.match(Readline::VERSION)
- return unless Readline.respond_to?(:completion_append_character=)
- Readline.completion_append_character = append_character
+ Readline.completer_quote_characters = saved_completer_quote_characters
+ Readline.completer_word_break_characters = saved_completer_word_break_characters
end
- def test_completion_quote_character_completing_unquoted_argument
- return unless Readline.respond_to?(:completion_quote_character)
-
+ def test_using_quoting_detection_proc_with_multibyte_input
saved_completer_quote_characters = Readline.completer_quote_characters
-
- quote_character = "original value"
- Readline.completion_proc = -> (_) do
- quote_character = Readline.completion_quote_character
- []
- end
- Readline.completer_quote_characters = "'\""
-
- with_temp_stdio do |stdin, stdout|
- replace_stdio(stdin.path, stdout.path) do
- stdin.write("input\t")
- stdin.flush
- Readline.readline("> ", false)
- end
+ saved_completer_word_break_characters = Readline.completer_word_break_characters
+ return unless Readline.respond_to?(:quoting_detection_proc=)
+ unless Encoding.find("locale") == Encoding::UTF_8
+ return if assert_under_utf8
+ skip 'this test needs UTF-8 locale'
end
- assert_nil(quote_character)
- ensure
- Readline.completer_quote_characters = saved_completer_quote_characters if saved_completer_quote_characters
- end
-
- def test_completion_quote_character_completing_quoted_argument
- return unless Readline.respond_to?(:completion_quote_character)
-
- saved_completer_quote_characters = Readline.completer_quote_characters
-
- quote_character = "original value"
- Readline.completion_proc = -> (_) do
- quote_character = Readline.completion_quote_character
- []
- end
- Readline.completer_quote_characters = "'\""
+ passed_text = nil
+ escaped_char_indexes = []
+ line = nil
with_temp_stdio do |stdin, stdout|
replace_stdio(stdin.path, stdout.path) do
- stdin.write("'input\t")
- stdin.flush
- Readline.readline("> ", false)
- end
- end
-
- assert_equal("'", quote_character)
- ensure
- Readline.completer_quote_characters = saved_completer_quote_characters if saved_completer_quote_characters
- end
-
- def test_completion_quote_character_after_completion
- return unless Readline.respond_to?(:completion_quote_character)
- if /solaris/i =~ RUBY_PLATFORM
- # http://rubyci.s3.amazonaws.com/solaris11s-sunc/ruby-trunk/log/20181228T102505Z.fail.html.gz
- omit 'This test does not succeed on Oracle Developer Studio for now'
- end
- omit 'Needs GNU Readline 6 or later' if /mswin|mingw/ =~ RUBY_PLATFORM and defined?(TestReadline) and kind_of?(TestReadline) and Readline::VERSION < '6.0'
-
- saved_completer_quote_characters = Readline.completer_quote_characters
-
- Readline.completion_proc = -> (_) { [] }
- Readline.completer_quote_characters = "'\""
+ Readline.completion_proc = ->(text) do
+ passed_text = text
+ ['completion']
+ end
+ Readline.completer_quote_characters = '\'"'
+ Readline.completer_word_break_characters = ' '
+ Readline.quoting_detection_proc = ->(text, index) do
+ escaped = index > 0 && text[index-1] == '\\'
+ escaped_char_indexes << index if escaped
+ escaped
+ end
- with_temp_stdio do |stdin, stdout|
- replace_stdio(stdin.path, stdout.path) do
- stdin.write("'input\t")
+ stdin.write("\u3042\u3093 second\\ third\t")
stdin.flush
- Readline.readline("> ", false)
+ line = Readline.readline('> ', false)
end
end
- assert_nil(Readline.completion_quote_character)
+ assert_equal([10], escaped_char_indexes)
+ assert_equal('second\\ third', passed_text)
+ assert_equal("\u3042\u3093 completion", line)
ensure
- Readline.completer_quote_characters = saved_completer_quote_characters if saved_completer_quote_characters
+ Readline.completer_quote_characters = saved_completer_quote_characters
+ Readline.completer_word_break_characters = saved_completer_word_break_characters
end
private
@@ -746,11 +581,6 @@ module BasetestReadline
Tempfile.create("test_readline_stdin") {|stdin|
Tempfile.create("test_readline_stdout") {|stdout|
yield stdin, stdout
- if /mswin|mingw/ =~ RUBY_PLATFORM
- # needed since readline holds refs to tempfiles, can't delete on Windows
- Readline.input = STDIN
- Readline.output = STDOUT
- end
}
}
end
@@ -782,35 +612,9 @@ module BasetestReadline
return false if ENV['LC_ALL'] == 'UTF-8'
loc = caller_locations(1, 1)[0].base_label.to_s
assert_separately([{"LC_ALL"=>"UTF-8"}, "-r", __FILE__], <<SRC)
-#omit "test \#{ENV['LC_ALL']}"
+#skip "test \#{ENV['LC_ALL']}"
#{self.class.name}.new(#{loc.dump}).run(Test::Unit::Runner.new)
SRC
return true
end
-end
-
-class TestReadline < Test::Unit::TestCase
- include BasetestReadline
-
- def setup
- use_ext_readline
- super
- end
-end if defined?(ReadlineSo) && ENV["TEST_READLINE_OR_RELINE"] != "Reline"
-
-class TestRelineAsReadline < Test::Unit::TestCase
- include BasetestReadline
-
- def setup
- use_lib_reline
- super
- end
-
- def get_default_internal_encoding
- if RUBY_PLATFORM =~ /mswin|mingw/
- Encoding.default_internal || Encoding::UTF_8
- else
- super
- end
- end
-end if defined?(Reline) && ENV["TEST_READLINE_OR_RELINE"] != "Readline"
+end if defined?(::Readline)
diff --git a/test/readline/test_readline_history.rb b/test/readline/test_readline_history.rb
index f4e93fa1b6..a9a324fb9e 100644
--- a/test/readline/test_readline_history.rb
+++ b/test/readline/test_readline_history.rb
@@ -1,28 +1,61 @@
# frozen_string_literal: false
-require_relative "helper"
-require "test/unit"
+begin
+ require "readline"
+=begin
+ class << Readline::HISTORY
+ def []=(index, str)
+ raise NotImplementedError
+ end
+
+ def pop
+ raise NotImplementedError
+ end
+
+ def shift
+ raise NotImplementedError
+ end
+
+ def delete_at(index)
+ raise NotImplementedError
+ end
+ end
+=end
+
+=begin
+ class << Readline::HISTORY
+ def clear
+ raise NotImplementedError
+ end
+ end
+=end
+rescue LoadError
+else
+ require "test/unit"
+end
+
+class Readline::TestHistory < Test::Unit::TestCase
+ include Readline
-module BasetestReadlineHistory
def setup
- Readline::HISTORY.clear
+ HISTORY.clear
end
def test_to_s
expected = "HISTORY"
- assert_equal(expected, Readline::HISTORY.to_s)
+ assert_equal(expected, HISTORY.to_s)
end
def test_get
lines = push_history(5)
lines.each_with_index do |s, i|
- assert_external_string_equal(s, Readline::HISTORY[i])
+ assert_external_string_equal(s, HISTORY[i])
end
end
def test_get__negative
lines = push_history(5)
(1..5).each do |i|
- assert_equal(lines[-i], Readline::HISTORY[-i])
+ assert_equal(lines[-i], HISTORY[-i])
end
end
@@ -31,7 +64,7 @@ module BasetestReadlineHistory
invalid_indexes = [5, 6, 100, -6, -7, -100]
invalid_indexes.each do |i|
assert_raise(IndexError, "i=<#{i}>") do
- Readline::HISTORY[i]
+ HISTORY[i]
end
end
@@ -39,7 +72,7 @@ module BasetestReadlineHistory
-100_000_000_000_000_000_000]
invalid_indexes.each do |i|
assert_raise(RangeError, "i=<#{i}>") do
- Readline::HISTORY[i]
+ HISTORY[i]
end
end
end
@@ -49,8 +82,8 @@ module BasetestReadlineHistory
push_history(5)
5.times do |i|
expected = "set: #{i}"
- Readline::HISTORY[i] = expected
- assert_external_string_equal(expected, Readline::HISTORY[i])
+ HISTORY[i] = expected
+ assert_external_string_equal(expected, HISTORY[i])
end
rescue NotImplementedError
end
@@ -58,14 +91,14 @@ module BasetestReadlineHistory
def test_set__out_of_range
assert_raise(IndexError, NotImplementedError, "index=<0>") do
- Readline::HISTORY[0] = "set: 0"
+ HISTORY[0] = "set: 0"
end
push_history(5)
invalid_indexes = [5, 6, 100, -6, -7, -100]
invalid_indexes.each do |i|
assert_raise(IndexError, NotImplementedError, "index=<#{i}>") do
- Readline::HISTORY[i] = "set: #{i}"
+ HISTORY[i] = "set: #{i}"
end
end
@@ -73,7 +106,7 @@ module BasetestReadlineHistory
-100_000_000_000_000_000_000]
invalid_indexes.each do |i|
assert_raise(RangeError, NotImplementedError, "index=<#{i}>") do
- Readline::HISTORY[i] = "set: #{i}"
+ HISTORY[i] = "set: #{i}"
end
end
end
@@ -81,102 +114,102 @@ module BasetestReadlineHistory
def test_push
5.times do |i|
s = i.to_s
- assert_equal(Readline::HISTORY, Readline::HISTORY.push(s))
- assert_external_string_equal(s, Readline::HISTORY[i])
+ assert_equal(HISTORY, HISTORY.push(s))
+ assert_external_string_equal(s, HISTORY[i])
end
- assert_equal(5, Readline::HISTORY.length)
+ assert_equal(5, HISTORY.length)
end
def test_push__operator
5.times do |i|
s = i.to_s
- assert_equal(Readline::HISTORY, Readline::HISTORY << s)
- assert_external_string_equal(s, Readline::HISTORY[i])
+ assert_equal(HISTORY, HISTORY << s)
+ assert_external_string_equal(s, HISTORY[i])
end
- assert_equal(5, Readline::HISTORY.length)
+ assert_equal(5, HISTORY.length)
end
def test_push__plural
- assert_equal(Readline::HISTORY, Readline::HISTORY.push("0", "1", "2", "3", "4"))
+ assert_equal(HISTORY, HISTORY.push("0", "1", "2", "3", "4"))
(0..4).each do |i|
- assert_external_string_equal(i.to_s, Readline::HISTORY[i])
+ assert_external_string_equal(i.to_s, HISTORY[i])
end
- assert_equal(5, Readline::HISTORY.length)
+ assert_equal(5, HISTORY.length)
- assert_equal(Readline::HISTORY, Readline::HISTORY.push("5", "6", "7", "8", "9"))
+ assert_equal(HISTORY, HISTORY.push("5", "6", "7", "8", "9"))
(5..9).each do |i|
- assert_external_string_equal(i.to_s, Readline::HISTORY[i])
+ assert_external_string_equal(i.to_s, HISTORY[i])
end
- assert_equal(10, Readline::HISTORY.length)
+ assert_equal(10, HISTORY.length)
end
def test_pop
begin
- assert_equal(nil, Readline::HISTORY.pop)
+ assert_equal(nil, HISTORY.pop)
lines = push_history(5)
(1..5).each do |i|
- assert_external_string_equal(lines[-i], Readline::HISTORY.pop)
- assert_equal(lines.length - i, Readline::HISTORY.length)
+ assert_external_string_equal(lines[-i], HISTORY.pop)
+ assert_equal(lines.length - i, HISTORY.length)
end
- assert_equal(nil, Readline::HISTORY.pop)
+ assert_equal(nil, HISTORY.pop)
rescue NotImplementedError
end
end
def test_shift
begin
- assert_equal(nil, Readline::HISTORY.shift)
+ assert_equal(nil, HISTORY.shift)
lines = push_history(5)
(0..4).each do |i|
- assert_external_string_equal(lines[i], Readline::HISTORY.shift)
- assert_equal(lines.length - (i + 1), Readline::HISTORY.length)
+ assert_external_string_equal(lines[i], HISTORY.shift)
+ assert_equal(lines.length - (i + 1), HISTORY.length)
end
- assert_equal(nil, Readline::HISTORY.shift)
+ assert_equal(nil, HISTORY.shift)
rescue NotImplementedError
end
end
def test_each
- e = Readline::HISTORY.each do |s|
+ e = HISTORY.each do |s|
assert(false) # not reachable
end
- assert_equal(Readline::HISTORY, e)
+ assert_equal(HISTORY, e)
lines = push_history(5)
i = 0
- e = Readline::HISTORY.each do |s|
- assert_external_string_equal(Readline::HISTORY[i], s)
+ e = HISTORY.each do |s|
+ assert_external_string_equal(HISTORY[i], s)
assert_external_string_equal(lines[i], s)
i += 1
end
- assert_equal(Readline::HISTORY, e)
+ assert_equal(HISTORY, e)
end
def test_each__enumerator
- e = Readline::HISTORY.each
+ e = HISTORY.each
assert_instance_of(Enumerator, e)
end
def test_length
- assert_equal(0, Readline::HISTORY.length)
+ assert_equal(0, HISTORY.length)
push_history(1)
- assert_equal(1, Readline::HISTORY.length)
+ assert_equal(1, HISTORY.length)
push_history(4)
- assert_equal(5, Readline::HISTORY.length)
- Readline::HISTORY.clear
- assert_equal(0, Readline::HISTORY.length)
+ assert_equal(5, HISTORY.length)
+ HISTORY.clear
+ assert_equal(0, HISTORY.length)
end
def test_empty_p
2.times do
- assert(Readline::HISTORY.empty?)
- Readline::HISTORY.push("s")
- assert_equal(false, Readline::HISTORY.empty?)
- Readline::HISTORY.clear
- assert(Readline::HISTORY.empty?)
+ assert(HISTORY.empty?)
+ HISTORY.push("s")
+ assert_equal(false, HISTORY.empty?)
+ HISTORY.clear
+ assert(HISTORY.empty?)
end
end
@@ -184,37 +217,37 @@ module BasetestReadlineHistory
begin
lines = push_history(5)
(0..4).each do |i|
- assert_external_string_equal(lines[i], Readline::HISTORY.delete_at(0))
+ assert_external_string_equal(lines[i], HISTORY.delete_at(0))
end
- assert(Readline::HISTORY.empty?)
+ assert(HISTORY.empty?)
lines = push_history(5)
(1..5).each do |i|
- assert_external_string_equal(lines[lines.length - i], Readline::HISTORY.delete_at(-1))
+ assert_external_string_equal(lines[lines.length - i], HISTORY.delete_at(-1))
end
- assert(Readline::HISTORY.empty?)
+ assert(HISTORY.empty?)
lines = push_history(5)
- assert_external_string_equal(lines[0], Readline::HISTORY.delete_at(0))
- assert_external_string_equal(lines[4], Readline::HISTORY.delete_at(3))
- assert_external_string_equal(lines[1], Readline::HISTORY.delete_at(0))
- assert_external_string_equal(lines[3], Readline::HISTORY.delete_at(1))
- assert_external_string_equal(lines[2], Readline::HISTORY.delete_at(0))
- assert(Readline::HISTORY.empty?)
+ assert_external_string_equal(lines[0], HISTORY.delete_at(0))
+ assert_external_string_equal(lines[4], HISTORY.delete_at(3))
+ assert_external_string_equal(lines[1], HISTORY.delete_at(0))
+ assert_external_string_equal(lines[3], HISTORY.delete_at(1))
+ assert_external_string_equal(lines[2], HISTORY.delete_at(0))
+ assert(HISTORY.empty?)
rescue NotImplementedError
end
end
def test_delete_at__out_of_range
assert_raise(IndexError, NotImplementedError, "index=<0>") do
- Readline::HISTORY.delete_at(0)
+ HISTORY.delete_at(0)
end
push_history(5)
invalid_indexes = [5, 6, 100, -6, -7, -100]
invalid_indexes.each do |i|
assert_raise(IndexError, NotImplementedError, "index=<#{i}>") do
- Readline::HISTORY.delete_at(i)
+ HISTORY.delete_at(i)
end
end
@@ -222,7 +255,7 @@ module BasetestReadlineHistory
-100_000_000_000_000_000_000]
invalid_indexes.each do |i|
assert_raise(RangeError, NotImplementedError, "index=<#{i}>") do
- Readline::HISTORY.delete_at(i)
+ HISTORY.delete_at(i)
end
end
end
@@ -238,7 +271,7 @@ module BasetestReadlineHistory
end
lines.push("#{i + 1}:#{s}")
end
- Readline::HISTORY.push(*lines)
+ HISTORY.push(*lines)
return lines
end
@@ -250,38 +283,11 @@ module BasetestReadlineHistory
def get_default_internal_encoding
return Encoding.default_internal || Encoding.find("locale")
end
-end
-
-class TestReadlineHistory < Test::Unit::TestCase
- include BasetestReadlineHistory
-
- def setup
- use_ext_readline
- super
- end
-end if defined?(::ReadlineSo) && defined?(::ReadlineSo::HISTORY) &&
- ENV["TEST_READLINE_OR_RELINE"] != "Reline" &&
+end if defined?(::Readline) && defined?(::Readline::HISTORY) &&
(
begin
- ReadlineSo::HISTORY.clear
+ Readline::HISTORY.clear
rescue NotImplementedError
false
end
)
-
-class TestRelineAsReadlineHistory < Test::Unit::TestCase
- include BasetestReadlineHistory
-
- def setup
- use_lib_reline
- super
- end
-
- def get_default_internal_encoding
- if RUBY_PLATFORM =~ /mswin|mingw/
- Encoding.default_internal || Encoding::UTF_8
- else
- super
- end
- end
-end if defined?(Reline) && ENV["TEST_READLINE_OR_RELINE"] != "Readline"
diff --git a/test/reline/helper.rb b/test/reline/helper.rb
deleted file mode 100644
index 0b5b8af310..0000000000
--- a/test/reline/helper.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
-require 'reline'
-require 'test/unit'
-
-module Reline
- class <<self
- def test_mode
- remove_const('IOGate') if const_defined?('IOGate')
- const_set('IOGate', Reline::GeneralIO)
- send(:core).config.instance_variable_set(:@test_mode, true)
- send(:core).config.reset
- end
-
- def test_reset
- Reline.instance_variable_set(:@core, nil)
- end
- end
-end
-
-RELINE_TEST_ENCODING ||=
- if ENV['RELINE_TEST_ENCODING']
- Encoding.find(ENV['RELINE_TEST_ENCODING'])
- else
- Encoding::UTF_8
- end
-
-class Reline::TestCase < Test::Unit::TestCase
- private def convert_str(input, options = {}, normalized = nil)
- return nil if input.nil?
- input.chars.map { |c|
- if Reline::Unicode::EscapedChars.include?(c.ord)
- c
- else
- c.encode(@line_editor.instance_variable_get(:@encoding), Encoding::UTF_8, **options)
- end
- }.join
- rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
- input.unicode_normalize!(:nfc)
- if normalized
- options[:undef] = :replace
- options[:replace] = '?'
- end
- normalized = true
- retry
- end
-
- def input_key_by_symbol(input)
- @line_editor.input_key(Reline::Key.new(input, input, false))
- end
-
- def input_keys(input, convert = true)
- input = convert_str(input) if convert
- input.chars.each do |c|
- if c.bytesize == 1
- eighth_bit = 0b10000000
- byte = c.bytes.first
- if byte.allbits?(eighth_bit)
- @line_editor.input_key(Reline::Key.new(byte ^ eighth_bit, byte, true))
- else
- @line_editor.input_key(Reline::Key.new(byte, byte, false))
- end
- else
- c.bytes.each do |b|
- @line_editor.input_key(Reline::Key.new(b, b, false))
- end
- end
- end
- end
-
- def assert_line(expected)
- expected = convert_str(expected)
- assert_equal(expected, @line_editor.line)
- end
-
- def assert_byte_pointer_size(expected)
- expected = convert_str(expected)
- byte_pointer = @line_editor.instance_variable_get(:@byte_pointer)
- assert_equal(
- expected.bytesize, byte_pointer,
- "<#{expected.inspect}> expected but was\n<#{@line_editor.line.byteslice(0, byte_pointer).inspect}>")
- end
-
- def assert_cursor(expected)
- assert_equal(expected, @line_editor.instance_variable_get(:@cursor))
- end
-
- def assert_cursor_max(expected)
- assert_equal(expected, @line_editor.instance_variable_get(:@cursor_max))
- end
-end
diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb
deleted file mode 100644
index c1455cd136..0000000000
--- a/test/reline/test_config.rb
+++ /dev/null
@@ -1,325 +0,0 @@
-require_relative 'helper'
-
-class Reline::Config::Test < Reline::TestCase
- def setup
- @pwd = Dir.pwd
- @tmpdir = File.join(Dir.tmpdir, "test_reline_config_#{$$}")
- begin
- Dir.mkdir(@tmpdir)
- rescue Errno::EEXIST
- FileUtils.rm_rf(@tmpdir)
- Dir.mkdir(@tmpdir)
- end
- Dir.chdir(@tmpdir)
- @config = Reline::Config.new
- end
-
- def teardown
- Dir.chdir(@pwd)
- FileUtils.rm_rf(@tmpdir)
- @config.reset
- end
-
- def test_read_lines
- @config.read_lines(<<~LINES.lines)
- set bell-style on
- LINES
-
- assert_equal :audible, @config.instance_variable_get(:@bell_style)
- end
-
- def test_read_lines_with_variable
- @config.read_lines(<<~LINES.lines)
- set disable-completion on
- LINES
-
- assert_equal true, @config.instance_variable_get(:@disable_completion)
- end
-
- def test_string_value
- @config.read_lines(<<~LINES.lines)
- set show-mode-in-prompt on
- set emacs-mode-string Emacs
- LINES
-
- assert_equal 'Emacs', @config.instance_variable_get(:@emacs_mode_string)
- end
-
- def test_string_value_with_brackets
- @config.read_lines(<<~LINES.lines)
- set show-mode-in-prompt on
- set emacs-mode-string [Emacs]
- LINES
-
- assert_equal '[Emacs]', @config.instance_variable_get(:@emacs_mode_string)
- end
-
- def test_string_value_with_brackets_and_quotes
- @config.read_lines(<<~LINES.lines)
- set show-mode-in-prompt on
- set emacs-mode-string "[Emacs]"
- LINES
-
- assert_equal '[Emacs]', @config.instance_variable_get(:@emacs_mode_string)
- end
-
- def test_string_value_with_parens
- @config.read_lines(<<~LINES.lines)
- set show-mode-in-prompt on
- set emacs-mode-string (Emacs)
- LINES
-
- assert_equal '(Emacs)', @config.instance_variable_get(:@emacs_mode_string)
- end
-
- def test_string_value_with_parens_and_quotes
- @config.read_lines(<<~LINES.lines)
- set show-mode-in-prompt on
- set emacs-mode-string "(Emacs)"
- LINES
-
- assert_equal '(Emacs)', @config.instance_variable_get(:@emacs_mode_string)
- end
-
- def test_comment_line
- @config.read_lines([" #a: error\n"])
- assert_not_include @config.key_bindings, nil
- end
-
- def test_invalid_keystroke
- @config.read_lines(["a: error\n"])
- assert_not_include @config.key_bindings, nil
- end
-
- def test_bind_key
- assert_equal ['input'.bytes, 'abcde'.bytes], @config.bind_key('"input"', '"abcde"')
- end
-
- def test_bind_key_with_macro
-
- assert_equal ['input'.bytes, :abcde], @config.bind_key('"input"', 'abcde')
- end
-
- def test_bind_key_with_escaped_chars
- assert_equal ['input'.bytes, "\e \\ \" ' \a \b \d \f \n \r \t \v".bytes], @config.bind_key('"input"', '"\\e \\\\ \\" \\\' \\a \\b \\d \\f \\n \\r \\t \\v"')
- end
-
- def test_bind_key_with_ctrl_chars
- assert_equal ['input'.bytes, "\C-h\C-h".bytes], @config.bind_key('"input"', '"\C-h\C-H"')
- assert_equal ['input'.bytes, "\C-h\C-h".bytes], @config.bind_key('"input"', '"\Control-h\Control-H"')
- end
-
- def test_bind_key_with_meta_chars
- assert_equal ['input'.bytes, "\M-h\M-H".bytes], @config.bind_key('"input"', '"\M-h\M-H"')
- assert_equal ['input'.bytes, "\M-h\M-H".bytes], @config.bind_key('"input"', '"\Meta-h\Meta-H"')
- end
-
- def test_bind_key_with_octal_number
- input = %w{i n p u t}.map(&:ord)
- assert_equal [input, "\1".bytes], @config.bind_key('"input"', '"\1"')
- assert_equal [input, "\12".bytes], @config.bind_key('"input"', '"\12"')
- assert_equal [input, "\123".bytes], @config.bind_key('"input"', '"\123"')
- assert_equal [input, "\123".bytes + '4'.bytes], @config.bind_key('"input"', '"\1234"')
- end
-
- def test_bind_key_with_hexadecimal_number
- input = %w{i n p u t}.map(&:ord)
- assert_equal [input, "\x4".bytes], @config.bind_key('"input"', '"\x4"')
- assert_equal [input, "\x45".bytes], @config.bind_key('"input"', '"\x45"')
- assert_equal [input, "\x45".bytes + '6'.bytes], @config.bind_key('"input"', '"\x456"')
- end
-
- def test_include
- File.open('included_partial', 'wt') do |f|
- f.write(<<~PARTIAL_LINES)
- set bell-style on
- PARTIAL_LINES
- end
- @config.read_lines(<<~LINES.lines)
- $include included_partial
- LINES
-
- assert_equal :audible, @config.instance_variable_get(:@bell_style)
- end
-
- def test_if
- @config.read_lines(<<~LINES.lines)
- $if Ruby
- set bell-style audible
- $else
- set bell-style visible
- $endif
- LINES
-
- assert_equal :audible, @config.instance_variable_get(:@bell_style)
- end
-
- def test_if_with_false
- @config.read_lines(<<~LINES.lines)
- $if Python
- set bell-style audible
- $else
- set bell-style visible
- $endif
- LINES
-
- assert_equal :visible, @config.instance_variable_get(:@bell_style)
- end
-
- def test_if_with_indent
- %w[Ruby Reline].each do |cond|
- @config.read_lines(<<~LINES.lines)
- set bell-style none
- $if #{cond}
- set bell-style audible
- $else
- set bell-style visible
- $endif
- LINES
-
- assert_equal :audible, @config.instance_variable_get(:@bell_style)
- end
- end
-
- def test_unclosed_if
- e = assert_raise(Reline::Config::InvalidInputrc) do
- @config.read_lines(<<~LINES.lines, "INPUTRC")
- $if Ruby
- LINES
- end
- assert_equal "INPUTRC:1: unclosed if", e.message
- end
-
- def test_unmatched_else
- e = assert_raise(Reline::Config::InvalidInputrc) do
- @config.read_lines(<<~LINES.lines, "INPUTRC")
- $else
- LINES
- end
- assert_equal "INPUTRC:1: unmatched else", e.message
- end
-
- def test_unmatched_endif
- e = assert_raise(Reline::Config::InvalidInputrc) do
- @config.read_lines(<<~LINES.lines, "INPUTRC")
- $endif
- LINES
- end
- assert_equal "INPUTRC:1: unmatched endif", e.message
- end
-
- def test_default_key_bindings
- @config.add_default_key_binding('abcd'.bytes, 'EFGH'.bytes)
- @config.read_lines(<<~'LINES'.lines)
- "abcd": "ABCD"
- "ijkl": "IJKL"
- LINES
-
- expected = { 'abcd'.bytes => 'ABCD'.bytes, 'ijkl'.bytes => 'IJKL'.bytes }
- assert_equal expected, @config.key_bindings
- end
-
- def test_additional_key_bindings
- @config.read_lines(<<~'LINES'.lines)
- "ef": "EF"
- "gh": "GH"
- LINES
-
- expected = { 'ef'.bytes => 'EF'.bytes, 'gh'.bytes => 'GH'.bytes }
- assert_equal expected, @config.key_bindings
- end
-
- def test_additional_key_bindings_with_nesting_and_comment_out
- @config.read_lines(<<~'LINES'.lines)
- #"ab": "AB"
- #"cd": "cd"
- "ef": "EF"
- "gh": "GH"
- LINES
-
- expected = { 'ef'.bytes => 'EF'.bytes, 'gh'.bytes => 'GH'.bytes }
- assert_equal expected, @config.key_bindings
- end
-
- def test_history_size
- @config.read_lines(<<~LINES.lines)
- set history-size 5000
- LINES
-
- assert_equal 5000, @config.instance_variable_get(:@history_size)
- history = Reline::History.new(@config)
- history << "a\n"
- assert_equal 1, history.size
- end
-
- def test_empty_inputrc_env
- inputrc_backup = ENV['INPUTRC']
- ENV['INPUTRC'] = ''
- assert_nothing_raised do
- @config.read
- end
- ensure
- ENV['INPUTRC'] = inputrc_backup
- end
-
- def test_inputrc
- inputrc_backup = ENV['INPUTRC']
- expected = "#{@tmpdir}/abcde"
- ENV['INPUTRC'] = expected
- assert_equal expected, @config.inputrc_path
- ensure
- ENV['INPUTRC'] = inputrc_backup
- end
-
- def test_xdg_config_home
- home_backup = ENV['HOME']
- xdg_config_home_backup = ENV['XDG_CONFIG_HOME']
- xdg_config_home = File.expand_path("#{@tmpdir}/.config/example_dir")
- expected = File.expand_path("#{xdg_config_home}/readline/inputrc")
- FileUtils.mkdir_p(File.dirname(expected))
- FileUtils.touch(expected)
- ENV['HOME'] = @tmpdir
- ENV['XDG_CONFIG_HOME'] = xdg_config_home
- assert_equal expected, @config.inputrc_path
- ensure
- FileUtils.rm(expected)
- ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup
- ENV['HOME'] = home_backup
- end
-
- def test_empty_xdg_config_home
- home_backup = ENV['HOME']
- xdg_config_home_backup = ENV['XDG_CONFIG_HOME']
- ENV['HOME'] = @tmpdir
- ENV['XDG_CONFIG_HOME'] = ''
- expected = File.expand_path('~/.config/readline/inputrc')
- FileUtils.mkdir_p(File.dirname(expected))
- FileUtils.touch(expected)
- assert_equal expected, @config.inputrc_path
- ensure
- FileUtils.rm(expected)
- ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup
- ENV['HOME'] = home_backup
- end
-
- def test_relative_xdg_config_home
- home_backup = ENV['HOME']
- xdg_config_home_backup = ENV['XDG_CONFIG_HOME']
- ENV['HOME'] = @tmpdir
- expected = File.expand_path('~/.config/readline/inputrc')
- FileUtils.mkdir_p(File.dirname(expected))
- FileUtils.touch(expected)
- result = Dir.chdir(@tmpdir) do
- xdg_config_home = ".config/example_dir"
- ENV['XDG_CONFIG_HOME'] = xdg_config_home
- inputrc = "#{xdg_config_home}/readline/inputrc"
- FileUtils.mkdir_p(File.dirname(inputrc))
- FileUtils.touch(inputrc)
- @config.inputrc_path
- end
- assert_equal expected, result
- FileUtils.rm(expected)
- ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup
- ENV['HOME'] = home_backup
- end
-end
diff --git a/test/reline/test_history.rb b/test/reline/test_history.rb
deleted file mode 100644
index 58c240fc96..0000000000
--- a/test/reline/test_history.rb
+++ /dev/null
@@ -1,301 +0,0 @@
-require_relative 'helper'
-require "reline/history"
-
-class Reline::History::Test < Reline::TestCase
- def setup
- Reline.send(:test_mode)
- end
-
- def test_ancestors
- assert_equal(Reline::History.ancestors.include?(Array), true)
- end
-
- def test_to_s
- history = history_new
- expected = "HISTORY"
- assert_equal(expected, history.to_s)
- end
-
- def test_get
- history, lines = lines = history_new_and_push_history(5)
- lines.each_with_index do |s, i|
- assert_external_string_equal(s, history[i])
- end
- end
-
- def test_get__negative
- history, lines = lines = history_new_and_push_history(5)
- (1..5).each do |i|
- assert_equal(lines[-i], history[-i])
- end
- end
-
- def test_get__out_of_range
- history, _ = history_new_and_push_history(5)
- invalid_indexes = [5, 6, 100, -6, -7, -100]
- invalid_indexes.each do |i|
- assert_raise(IndexError, "i=<#{i}>") do
- history[i]
- end
- end
-
- invalid_indexes = [100_000_000_000_000_000_000,
- -100_000_000_000_000_000_000]
- invalid_indexes.each do |i|
- assert_raise(RangeError, "i=<#{i}>") do
- history[i]
- end
- end
- end
-
- def test_set
- begin
- history, _ = history_new_and_push_history(5)
- 5.times do |i|
- expected = "set: #{i}"
- history[i] = expected
- assert_external_string_equal(expected, history[i])
- end
- rescue NotImplementedError
- end
- end
-
- def test_set__out_of_range
- history = history_new
- assert_raise(IndexError, NotImplementedError, "index=<0>") do
- history[0] = "set: 0"
- end
-
- history, _ = history_new_and_push_history(5)
- invalid_indexes = [5, 6, 100, -6, -7, -100]
- invalid_indexes.each do |i|
- assert_raise(IndexError, NotImplementedError, "index=<#{i}>") do
- history[i] = "set: #{i}"
- end
- end
-
- invalid_indexes = [100_000_000_000_000_000_000,
- -100_000_000_000_000_000_000]
- invalid_indexes.each do |i|
- assert_raise(RangeError, NotImplementedError, "index=<#{i}>") do
- history[i] = "set: #{i}"
- end
- end
- end
-
- def test_push
- history = history_new
- 5.times do |i|
- s = i.to_s
- assert_equal(history, history.push(s))
- assert_external_string_equal(s, history[i])
- end
- assert_equal(5, history.length)
- end
-
- def test_push__operator
- history = history_new
- 5.times do |i|
- s = i.to_s
- assert_equal(history, history << s)
- assert_external_string_equal(s, history[i])
- end
- assert_equal(5, history.length)
- end
-
- def test_push__plural
- history = history_new
- assert_equal(history, history.push("0", "1", "2", "3", "4"))
- (0..4).each do |i|
- assert_external_string_equal(i.to_s, history[i])
- end
- assert_equal(5, history.length)
-
- assert_equal(history, history.push("5", "6", "7", "8", "9"))
- (5..9).each do |i|
- assert_external_string_equal(i.to_s, history[i])
- end
- assert_equal(10, history.length)
- end
-
- def test_pop
- history = history_new
- begin
- assert_equal(nil, history.pop)
-
- history, lines = lines = history_new_and_push_history(5)
- (1..5).each do |i|
- assert_external_string_equal(lines[-i], history.pop)
- assert_equal(lines.length - i, history.length)
- end
-
- assert_equal(nil, history.pop)
- rescue NotImplementedError
- end
- end
-
- def test_shift
- history = history_new
- begin
- assert_equal(nil, history.shift)
-
- history, lines = lines = history_new_and_push_history(5)
- (0..4).each do |i|
- assert_external_string_equal(lines[i], history.shift)
- assert_equal(lines.length - (i + 1), history.length)
- end
-
- assert_equal(nil, history.shift)
- rescue NotImplementedError
- end
- end
-
- def test_each
- history = history_new
- e = history.each do |s|
- assert(false) # not reachable
- end
- assert_equal(history, e)
- history, lines = lines = history_new_and_push_history(5)
- i = 0
- e = history.each do |s|
- assert_external_string_equal(history[i], s)
- assert_external_string_equal(lines[i], s)
- i += 1
- end
- assert_equal(history, e)
- end
-
- def test_each__enumerator
- history = history_new
- e = history.each
- assert_instance_of(Enumerator, e)
- end
-
- def test_length
- history = history_new
- assert_equal(0, history.length)
- push_history(history, 1)
- assert_equal(1, history.length)
- push_history(history, 4)
- assert_equal(5, history.length)
- history.clear
- assert_equal(0, history.length)
- end
-
- def test_empty_p
- history = history_new
- 2.times do
- assert(history.empty?)
- history.push("s")
- assert_equal(false, history.empty?)
- history.clear
- assert(history.empty?)
- end
- end
-
- def test_delete_at
- begin
- history, lines = lines = history_new_and_push_history(5)
- (0..4).each do |i|
- assert_external_string_equal(lines[i], history.delete_at(0))
- end
- assert(history.empty?)
-
- history, lines = lines = history_new_and_push_history(5)
- (1..5).each do |i|
- assert_external_string_equal(lines[lines.length - i], history.delete_at(-1))
- end
- assert(history.empty?)
-
- history, lines = lines = history_new_and_push_history(5)
- assert_external_string_equal(lines[0], history.delete_at(0))
- assert_external_string_equal(lines[4], history.delete_at(3))
- assert_external_string_equal(lines[1], history.delete_at(0))
- assert_external_string_equal(lines[3], history.delete_at(1))
- assert_external_string_equal(lines[2], history.delete_at(0))
- assert(history.empty?)
- rescue NotImplementedError
- end
- end
-
- def test_delete_at__out_of_range
- history = history_new
- assert_raise(IndexError, NotImplementedError, "index=<0>") do
- history.delete_at(0)
- end
-
- history, _ = history_new_and_push_history(5)
- invalid_indexes = [5, 6, 100, -6, -7, -100]
- invalid_indexes.each do |i|
- assert_raise(IndexError, NotImplementedError, "index=<#{i}>") do
- history.delete_at(i)
- end
- end
-
- invalid_indexes = [100_000_000_000_000_000_000,
- -100_000_000_000_000_000_000]
- invalid_indexes.each do |i|
- assert_raise(RangeError, NotImplementedError, "index=<#{i}>") do
- history.delete_at(i)
- end
- end
- end
-
- def test_history_size_zero
- history = history_new(history_size: 0)
- assert_equal 0, history.size
- history << 'aa'
- history << 'bb'
- assert_equal 0, history.size
- history.push(*%w{aa bb cc})
- assert_equal 0, history.size
- end
-
- def test_history_size_negative_unlimited
- history = history_new(history_size: -1)
- assert_equal 0, history.size
- history << 'aa'
- history << 'bb'
- assert_equal 2, history.size
- history.push(*%w{aa bb cc})
- assert_equal 5, history.size
- end
-
- private
-
- def history_new(history_size: 10)
- Reline::History.new(Struct.new(:history_size).new(history_size))
- end
-
- def push_history(history, num)
- lines = []
- num.times do |i|
- s = "a"
- i.times do
- s = s.succ
- end
- lines.push("#{i + 1}:#{s}")
- end
- history.push(*lines)
- return history, lines
- end
-
- def history_new_and_push_history(num)
- history = history_new(history_size: 100)
- return push_history(history, num)
- end
-
- def assert_external_string_equal(expected, actual)
- assert_equal(expected, actual)
- assert_equal(get_default_internal_encoding, actual.encoding)
- end
-
- def get_default_internal_encoding
- if RUBY_PLATFORM =~ /mswin|mingw/
- Encoding.default_internal || Encoding::UTF_8
- else
- Encoding.default_internal || Encoding.find("locale")
- end
- end
-end
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
deleted file mode 100644
index a1e4015999..0000000000
--- a/test/reline/test_key_actor_emacs.rb
+++ /dev/null
@@ -1,2082 +0,0 @@
-require_relative 'helper'
-
-class Reline::KeyActor::Emacs::Test < Reline::TestCase
- def setup
- Reline.send(:test_mode)
- @prompt = '> '
- @config = Reline::Config.new # Emacs mode is default
- Reline::HISTORY.instance_variable_set(:@config, @config)
- Reline::HISTORY.clear
- @encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
- @line_editor = Reline::LineEditor.new(@config, @encoding)
- @line_editor.reset(@prompt, encoding: @encoding)
- end
-
- def test_ed_insert_one
- input_keys('a')
- assert_line('a')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(1)
- end
-
- def test_ed_insert_two
- input_keys('ab')
- assert_line('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- end
-
- def test_ed_insert_mbchar_one
- input_keys('ã‹')
- assert_line('ã‹')
- assert_byte_pointer_size('ã‹')
- assert_cursor(2)
- assert_cursor_max(2)
- end
-
- def test_ed_insert_mbchar_two
- input_keys('ã‹ã')
- assert_line('ã‹ã')
- assert_byte_pointer_size('ã‹ã')
- assert_cursor(4)
- assert_cursor_max(4)
- end
-
- def test_ed_insert_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099")
- assert_line("ã‹\u3099")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(2)
- end
-
- def test_ed_insert_for_plural_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099")
- assert_line("ã‹\u3099ã\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(4)
- end
-
- def test_move_next_and_prev
- input_keys('abd')
- assert_byte_pointer_size('abd')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(3)
- input_keys("\C-f", false)
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- input_keys('c')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(4)
- assert_line('abcd')
- end
-
- def test_move_next_and_prev_for_mbchar
- input_keys('ã‹ãã‘')
- assert_byte_pointer_size('ã‹ãã‘')
- assert_cursor(6)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ã‹ã')
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ã‹')
- assert_cursor(2)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size('ã‹ã')
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys('ã')
- assert_byte_pointer_size('ã‹ãã')
- assert_cursor(6)
- assert_cursor_max(8)
- assert_line('ã‹ããã‘')
- end
-
- def test_move_next_and_prev_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099ã‘\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099ã‘\u3099")
- assert_cursor(6)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys("ã\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099ã\u3099")
- assert_cursor(6)
- assert_cursor_max(8)
- assert_line("ã‹\u3099ã\u3099ã\u3099ã‘\u3099")
- end
-
- def test_move_to_beg_end
- input_keys('bcd')
- assert_byte_pointer_size('bcd')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- input_keys('a')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(4)
- input_keys("\C-e", false)
- assert_byte_pointer_size('abcd')
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys('e')
- assert_byte_pointer_size('abcde')
- assert_cursor(5)
- assert_cursor_max(5)
- assert_line('abcde')
- end
-
- def test_ed_newline_with_cr
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- refute(@line_editor.finished?)
- input_keys("\C-m", false)
- assert_line('ab')
- assert(@line_editor.finished?)
- end
-
- def test_ed_newline_with_lf
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- refute(@line_editor.finished?)
- input_keys("\C-j", false)
- assert_line('ab')
- assert(@line_editor.finished?)
- end
-
- def test_em_delete_prev_char
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- input_keys("\C-h", false)
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(1)
- assert_line('a')
- end
-
- def test_em_delete_prev_char_for_mbchar
- input_keys('ã‹ã')
- assert_byte_pointer_size('ã‹ã')
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys("\C-h", false)
- assert_byte_pointer_size('ã‹')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('ã‹')
- end
-
- def test_em_delete_prev_char_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys("\C-h", false)
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line("ã‹\u3099")
- end
-
- def test_ed_quoted_insert
- input_keys("ab\C-v\C-acd")
- assert_line("ab\C-acd")
- assert_byte_pointer_size("ab\C-acd")
- assert_cursor(6)
- assert_cursor_max(6)
- input_keys("\C-q\C-b")
- assert_line("ab\C-acd\C-b")
- assert_byte_pointer_size("ab\C-acd\C-b")
- assert_cursor(8)
- assert_cursor_max(8)
- end
-
- def test_ed_kill_line
- input_keys("\C-k", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- input_keys('abc')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-k", false)
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('abc')
- input_keys("\C-b\C-k", false)
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('ab')
- end
-
- def test_em_kill_line
- input_keys("\C-u", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- input_keys('abc')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-u", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- input_keys('abc')
- input_keys("\C-b\C-u", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(1)
- assert_line('c')
- input_keys("\C-u", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(1)
- assert_line('c')
- end
-
- def test_ed_move_to_beg
- input_keys('abd')
- assert_byte_pointer_size('abd')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- input_keys('c')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(4)
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(4)
- input_keys('012')
- assert_byte_pointer_size('012')
- assert_cursor(3)
- assert_cursor_max(7)
- assert_line('012abcd')
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(7)
- input_keys('ABC')
- assert_byte_pointer_size('ABC')
- assert_cursor(3)
- assert_cursor_max(10)
- assert_line('ABC012abcd')
- input_keys("\C-f" * 10 + "\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(10)
- input_keys('a')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(11)
- assert_line('aABC012abcd')
- end
-
- def test_ed_move_to_beg_with_blank
- input_keys(' abc')
- assert_byte_pointer_size(' abc')
- assert_cursor(5)
- assert_cursor_max(5)
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- end
-
- def test_ed_move_to_end
- input_keys('abd')
- assert_byte_pointer_size('abd')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- input_keys('c')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(4)
- input_keys("\C-e", false)
- assert_byte_pointer_size('abcd')
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys('012')
- assert_byte_pointer_size('abcd012')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('abcd012')
- input_keys("\C-e", false)
- assert_byte_pointer_size('abcd012')
- assert_cursor(7)
- assert_cursor_max(7)
- input_keys('ABC')
- assert_byte_pointer_size('abcd012ABC')
- assert_cursor(10)
- assert_cursor_max(10)
- assert_line('abcd012ABC')
- input_keys("\C-b" * 10 + "\C-e", false)
- assert_byte_pointer_size('abcd012ABC')
- assert_cursor(10)
- assert_cursor_max(10)
- input_keys('a')
- assert_byte_pointer_size('abcd012ABCa')
- assert_cursor(11)
- assert_cursor_max(11)
- assert_line('abcd012ABCa')
- end
-
- def test_em_delete
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- input_keys("\C-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(1)
- assert_line('b')
- end
-
- def test_em_delete_for_mbchar
- input_keys('ã‹ã')
- assert_byte_pointer_size('ã‹ã')
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(4)
- input_keys("\C-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- assert_line('ã')
- end
-
- def test_em_delete_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(4)
- input_keys("\C-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- assert_line("ã\u3099")
- end
-
- def test_ed_clear_screen
- refute(@line_editor.instance_variable_get(:@cleared))
- input_keys("\C-l", false)
- assert(@line_editor.instance_variable_get(:@cleared))
- end
-
- def test_ed_clear_screen_with_inputed
- input_keys('abc')
- input_keys("\C-b", false)
- refute(@line_editor.instance_variable_get(:@cleared))
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- input_keys("\C-l", false)
- assert(@line_editor.instance_variable_get(:@cleared))
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- assert_line('abc')
- end
-
- def test_ed_delete_next_char
- input_keys('abc')
- assert_cursor(3)
- assert_cursor_max(3)
- @line_editor.input_key(Reline::Key.new(:key_delete, :key_delete, false))
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('abc')
- end
-
- def test_em_next_word
- assert_byte_pointer_size('')
- assert_cursor(0)
- input_keys('abc def{bbb}ccc')
- input_keys("\C-a\M-F", false)
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- input_keys("\M-F", false)
- assert_byte_pointer_size('abc def')
- assert_cursor(7)
- input_keys("\M-F", false)
- assert_byte_pointer_size('abc def{bbb')
- assert_cursor(11)
- input_keys("\M-F", false)
- assert_byte_pointer_size('abc def{bbb}ccc')
- assert_cursor(15)
- input_keys("\M-F", false)
- assert_byte_pointer_size('abc def{bbb}ccc')
- assert_cursor(15)
- end
-
- def test_em_next_word_for_mbchar
- assert_cursor(0)
- input_keys('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- input_keys("\C-a\M-F", false)
- assert_byte_pointer_size('ã‚ã„ã†')
- assert_cursor(6)
- input_keys("\M-F", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã')
- assert_cursor(13)
- input_keys("\M-F", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™')
- assert_cursor(20)
- input_keys("\M-F", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_cursor(27)
- input_keys("\M-F", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_cursor(27)
- end
-
- def test_em_next_word_for_mbchar_by_plural_code_points
- assert_cursor(0)
- input_keys("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- input_keys("\C-a\M-F", false)
- assert_byte_pointer_size("ã‚ã„ã†")
- assert_cursor(6)
- input_keys("\M-F", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099")
- assert_cursor(13)
- input_keys("\M-F", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™")
- assert_cursor(20)
- input_keys("\M-F", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_cursor(27)
- input_keys("\M-F", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_cursor(27)
- end
-
- def test_em_prev_word
- input_keys('abc def{bbb}ccc')
- assert_byte_pointer_size('abc def{bbb}ccc')
- assert_cursor(15)
- input_keys("\M-B", false)
- assert_byte_pointer_size('abc def{bbb}')
- assert_cursor(12)
- input_keys("\M-B", false)
- assert_byte_pointer_size('abc def{')
- assert_cursor(8)
- input_keys("\M-B", false)
- assert_byte_pointer_size('abc ')
- assert_cursor(4)
- input_keys("\M-B", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- input_keys("\M-B", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- end
-
- def test_em_prev_word_for_mbchar
- input_keys('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_cursor(27)
- input_keys("\M-B", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}')
- assert_cursor(21)
- input_keys("\M-B", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{')
- assert_cursor(14)
- input_keys("\M-B", false)
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(7)
- input_keys("\M-B", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- input_keys("\M-B", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- end
-
- def test_em_prev_word_for_mbchar_by_plural_code_points
- input_keys("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_cursor(27)
- input_keys("\M-B", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}")
- assert_cursor(21)
- input_keys("\M-B", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{")
- assert_cursor(14)
- input_keys("\M-B", false)
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(7)
- input_keys("\M-B", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- input_keys("\M-B", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- end
-
- def test_em_delete_next_word
- input_keys('abc def{bbb}ccc')
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(15)
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(12)
- assert_line(' def{bbb}ccc')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(8)
- assert_line('{bbb}ccc')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(4)
- assert_line('}ccc')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_em_delete_next_word_for_mbchar
- input_keys('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(27)
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(21)
- assert_line(' ã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(14)
- assert_line('{ã•ã—ã™}ãŸã¡ã¤')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(7)
- assert_line('}ãŸã¡ã¤')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_em_delete_next_word_for_mbchar_by_plural_code_points
- input_keys("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(27)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(27)
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(21)
- assert_line(" ã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(14)
- assert_line('{ã•ã—ã™}ãŸã¡ã¤')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(7)
- assert_line('}ãŸã¡ã¤')
- input_keys("\M-d", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_ed_delete_prev_word
- input_keys('abc def{bbb}ccc')
- assert_byte_pointer_size('abc def{bbb}ccc')
- assert_cursor(15)
- assert_cursor_max(15)
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('abc def{bbb}')
- assert_cursor(12)
- assert_cursor_max(12)
- assert_line('abc def{bbb}')
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('abc def{')
- assert_cursor(8)
- assert_cursor_max(8)
- assert_line('abc def{')
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('abc ')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('abc ')
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_ed_delete_prev_word_for_mbchar
- input_keys('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_cursor(27)
- assert_cursor_max(27)
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}')
- assert_cursor(21)
- assert_cursor_max(21)
- assert_line('ã‚ã„ㆠã‹ãã{ã•ã—ã™}')
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{')
- assert_cursor(14)
- assert_cursor_max(14)
- assert_line('ã‚ã„ㆠã‹ãã{')
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('ã‚ã„ㆠ')
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_ed_delete_prev_word_for_mbchar_by_plural_code_points
- input_keys("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_cursor(27)
- assert_cursor_max(27)
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}")
- assert_cursor(21)
- assert_cursor_max(21)
- assert_line("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}")
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{")
- assert_cursor(14)
- assert_cursor_max(14)
- assert_line("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{")
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size("ã‚ã„ㆠ")
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('ã‚ã„ㆠ')
- input_keys("\M-\C-H", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_ed_transpose_chars
- input_keys('abc')
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- input_keys("\C-t", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- assert_line('abc')
- input_keys("\C-f\C-t", false)
- assert_byte_pointer_size('ba')
- assert_cursor(2)
- assert_cursor_max(3)
- assert_line('bac')
- input_keys("\C-t", false)
- assert_byte_pointer_size('bca')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('bca')
- input_keys("\C-t", false)
- assert_byte_pointer_size('bac')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('bac')
- end
-
- def test_ed_transpose_chars_for_mbchar
- input_keys('ã‚ã‹ã•')
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys("\C-t", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- assert_line('ã‚ã‹ã•')
- input_keys("\C-f\C-t", false)
- assert_byte_pointer_size('ã‹ã‚')
- assert_cursor(4)
- assert_cursor_max(6)
- assert_line('ã‹ã‚ã•')
- input_keys("\C-t", false)
- assert_byte_pointer_size('ã‹ã•ã‚')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line('ã‹ã•ã‚')
- input_keys("\C-t", false)
- assert_byte_pointer_size('ã‹ã‚ã•')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line('ã‹ã‚ã•')
- end
-
- def test_ed_transpose_chars_for_mbchar_by_plural_code_points
- input_keys("ã‚ã‹\u3099ã•")
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys("\C-t", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- assert_line("ã‚ã‹\u3099ã•")
- input_keys("\C-f\C-t", false)
- assert_byte_pointer_size("ã‹\u3099ã‚")
- assert_cursor(4)
- assert_cursor_max(6)
- assert_line("ã‹\u3099ã‚ã•")
- input_keys("\C-t", false)
- assert_byte_pointer_size("ã‹\u3099ã•ã‚")
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line("ã‹\u3099ã•ã‚")
- input_keys("\C-t", false)
- assert_byte_pointer_size("ã‹\u3099ã‚ã•")
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line("ã‹\u3099ã‚ã•")
- end
-
- def test_ed_transpose_words
- input_keys('abc def')
- assert_line('abc def')
- assert_byte_pointer_size('abc def')
- assert_cursor(7)
- assert_cursor_max(7)
- input_keys("\M-t", false)
- assert_line('def abc')
- assert_byte_pointer_size('def abc')
- assert_cursor(7)
- assert_cursor_max(7)
- input_keys("\C-a\C-k", false)
- input_keys(' abc def ')
- input_keys("\C-b" * 4, false)
- assert_line(' abc def ')
- assert_byte_pointer_size(' abc de')
- assert_cursor(8)
- assert_cursor_max(12)
- input_keys("\M-t", false)
- assert_line(' def abc ')
- assert_byte_pointer_size(' def abc')
- assert_cursor(9)
- assert_cursor_max(12)
- input_keys("\C-a\C-k", false)
- input_keys(' abc def ')
- input_keys("\C-b" * 6, false)
- assert_line(' abc def ')
- assert_byte_pointer_size(' abc ')
- assert_cursor(6)
- assert_cursor_max(12)
- input_keys("\M-t", false)
- assert_line(' def abc ')
- assert_byte_pointer_size(' def abc')
- assert_cursor(9)
- assert_cursor_max(12)
- input_keys("\M-t", false)
- assert_line(' abc def')
- assert_byte_pointer_size(' abc def')
- assert_cursor(12)
- assert_cursor_max(12)
- end
-
- def test_ed_transpose_words_for_mbchar
- input_keys('ã‚ã„ㆠã‹ãã')
- assert_line('ã‚ã„ㆠã‹ãã')
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã')
- assert_cursor(13)
- assert_cursor_max(13)
- input_keys("\M-t", false)
- assert_line('ã‹ãã ã‚ã„ã†')
- assert_byte_pointer_size('ã‹ãã ã‚ã„ã†')
- assert_cursor(13)
- assert_cursor_max(13)
- input_keys("\C-a\C-k", false)
- input_keys(' ã‚ã„ㆠã‹ãã ')
- input_keys("\C-b" * 4, false)
- assert_line(' ã‚ã„ㆠã‹ãã ')
- assert_byte_pointer_size(' ã‚ã„ㆠã‹ã')
- assert_cursor(13)
- assert_cursor_max(18)
- input_keys("\M-t", false)
- assert_line(' ã‹ãã ã‚ã„ㆠ')
- assert_byte_pointer_size(' ã‹ãã ã‚ã„ã†')
- assert_cursor(15)
- assert_cursor_max(18)
- input_keys("\C-a\C-k", false)
- input_keys(' ã‚ã„ㆠã‹ãã ')
- input_keys("\C-b" * 6, false)
- assert_line(' ã‚ã„ㆠã‹ãã ')
- assert_byte_pointer_size(' ã‚ã„ㆠ')
- assert_cursor(9)
- assert_cursor_max(18)
- input_keys("\M-t", false)
- assert_line(' ã‹ãã ã‚ã„ㆠ')
- assert_byte_pointer_size(' ã‹ãã ã‚ã„ã†')
- assert_cursor(15)
- assert_cursor_max(18)
- input_keys("\M-t", false)
- assert_line(' ã‚ã„ㆠã‹ãã')
- assert_byte_pointer_size(' ã‚ã„ㆠã‹ãã')
- assert_cursor(18)
- assert_cursor_max(18)
- end
-
- def test_ed_transpose_words_with_one_word
- input_keys('abc ')
- assert_line('abc ')
- assert_byte_pointer_size('abc ')
- assert_cursor(5)
- assert_cursor_max(5)
- input_keys("\M-t", false)
- assert_line('abc ')
- assert_byte_pointer_size('abc ')
- assert_cursor(5)
- assert_cursor_max(5)
- input_keys("\C-b", false)
- assert_line('abc ')
- assert_byte_pointer_size('abc ')
- assert_cursor(4)
- assert_cursor_max(5)
- input_keys("\M-t", false)
- assert_line('abc ')
- assert_byte_pointer_size('abc ')
- assert_cursor(4)
- assert_cursor_max(5)
- input_keys("\C-b" * 2, false)
- assert_line('abc ')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(5)
- input_keys("\M-t", false)
- assert_line('abc ')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(5)
- input_keys("\M-t", false)
- assert_line('abc ')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(5)
- end
-
- def test_ed_transpose_words_with_one_word_for_mbchar
- input_keys('ã‚ã„ㆠ')
- assert_line('ã‚ã„ㆠ')
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(8)
- assert_cursor_max(8)
- input_keys("\M-t", false)
- assert_line('ã‚ã„ㆠ')
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(8)
- assert_cursor_max(8)
- input_keys("\C-b", false)
- assert_line('ã‚ã„ㆠ')
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(7)
- assert_cursor_max(8)
- input_keys("\M-t", false)
- assert_line('ã‚ã„ㆠ')
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(7)
- assert_cursor_max(8)
- input_keys("\C-b" * 2, false)
- assert_line('ã‚ã„ㆠ')
- assert_byte_pointer_size('ã‚ã„')
- assert_cursor(4)
- assert_cursor_max(8)
- input_keys("\M-t", false)
- assert_line('ã‚ã„ㆠ')
- assert_byte_pointer_size('ã‚ã„')
- assert_cursor(4)
- assert_cursor_max(8)
- input_keys("\M-t", false)
- assert_line('ã‚ã„ㆠ')
- assert_byte_pointer_size('ã‚ã„')
- assert_cursor(4)
- assert_cursor_max(8)
- end
-
- def test_ed_digit
- input_keys('0123')
- assert_byte_pointer_size('0123')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('0123')
- end
-
- def test_ed_next_and_prev_char
- input_keys('abc')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- input_keys("\C-b", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- input_keys("\C-f", false)
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(3)
- input_keys("\C-f", false)
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(3)
- input_keys("\C-f", false)
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-f", false)
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(3)
- end
-
- def test_ed_next_and_prev_char_for_mbchar
- input_keys('ã‚ã„ã†')
- assert_byte_pointer_size('ã‚ã„ã†')
- assert_cursor(6)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ã‚ã„')
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size('ã‚ã„')
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size('ã‚ã„ã†')
- assert_cursor(6)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size('ã‚ã„ã†')
- assert_cursor(6)
- assert_cursor_max(6)
- end
-
- def test_ed_next_and_prev_char_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099ã\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099ã\u3099")
- assert_cursor(6)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys("\C-b", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size("ã‹\u3099ã\u3099ã\u3099")
- assert_cursor(6)
- assert_cursor_max(6)
- input_keys("\C-f", false)
- assert_byte_pointer_size("ã‹\u3099ã\u3099ã\u3099")
- assert_cursor(6)
- assert_cursor_max(6)
- end
-
- def test_em_capitol_case
- input_keys('abc def{bbb}ccc')
- input_keys("\C-a\M-c", false)
- assert_byte_pointer_size('Abc')
- assert_cursor(3)
- assert_cursor_max(15)
- assert_line('Abc def{bbb}ccc')
- input_keys("\M-c", false)
- assert_byte_pointer_size('Abc Def')
- assert_cursor(7)
- assert_cursor_max(15)
- assert_line('Abc Def{bbb}ccc')
- input_keys("\M-c", false)
- assert_byte_pointer_size('Abc Def{Bbb')
- assert_cursor(11)
- assert_cursor_max(15)
- assert_line('Abc Def{Bbb}ccc')
- input_keys("\M-c", false)
- assert_byte_pointer_size('Abc Def{Bbb}Ccc')
- assert_cursor(15)
- assert_cursor_max(15)
- assert_line('Abc Def{Bbb}Ccc')
- end
-
- def test_em_capitol_case_with_complex_example
- input_keys('{}#* AaA!!!cCc ')
- input_keys("\C-a\M-c", false)
- assert_byte_pointer_size('{}#* Aaa')
- assert_cursor(11)
- assert_cursor_max(20)
- assert_line('{}#* Aaa!!!cCc ')
- input_keys("\M-c", false)
- assert_byte_pointer_size('{}#* Aaa!!!Ccc')
- assert_cursor(17)
- assert_cursor_max(20)
- assert_line('{}#* Aaa!!!Ccc ')
- input_keys("\M-c", false)
- assert_byte_pointer_size('{}#* Aaa!!!Ccc ')
- assert_cursor(20)
- assert_cursor_max(20)
- assert_line('{}#* Aaa!!!Ccc ')
- end
-
- def test_em_lower_case
- input_keys('AbC def{bBb}CCC')
- input_keys("\C-a\M-l", false)
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(15)
- assert_line('abc def{bBb}CCC')
- input_keys("\M-l", false)
- assert_byte_pointer_size('abc def')
- assert_cursor(7)
- assert_cursor_max(15)
- assert_line('abc def{bBb}CCC')
- input_keys("\M-l", false)
- assert_byte_pointer_size('abc def{bbb')
- assert_cursor(11)
- assert_cursor_max(15)
- assert_line('abc def{bbb}CCC')
- input_keys("\M-l", false)
- assert_byte_pointer_size('abc def{bbb}ccc')
- assert_cursor(15)
- assert_cursor_max(15)
- assert_line('abc def{bbb}ccc')
- end
-
- def test_em_lower_case_with_complex_example
- input_keys('{}#* AaA!!!cCc ')
- input_keys("\C-a\M-l", false)
- assert_byte_pointer_size('{}#* aaa')
- assert_cursor(11)
- assert_cursor_max(20)
- assert_line('{}#* aaa!!!cCc ')
- input_keys("\M-l", false)
- assert_byte_pointer_size('{}#* aaa!!!ccc')
- assert_cursor(17)
- assert_cursor_max(20)
- assert_line('{}#* aaa!!!ccc ')
- input_keys("\M-l", false)
- assert_byte_pointer_size('{}#* aaa!!!ccc ')
- assert_cursor(20)
- assert_cursor_max(20)
- assert_line('{}#* aaa!!!ccc ')
- end
-
- def test_em_upper_case
- input_keys('AbC def{bBb}CCC')
- input_keys("\C-a\M-u", false)
- assert_byte_pointer_size('ABC')
- assert_cursor(3)
- assert_cursor_max(15)
- assert_line('ABC def{bBb}CCC')
- input_keys("\M-u", false)
- assert_byte_pointer_size('ABC DEF')
- assert_cursor(7)
- assert_cursor_max(15)
- assert_line('ABC DEF{bBb}CCC')
- input_keys("\M-u", false)
- assert_byte_pointer_size('ABC DEF{BBB')
- assert_cursor(11)
- assert_cursor_max(15)
- assert_line('ABC DEF{BBB}CCC')
- input_keys("\M-u", false)
- assert_byte_pointer_size('ABC DEF{BBB}CCC')
- assert_cursor(15)
- assert_cursor_max(15)
- assert_line('ABC DEF{BBB}CCC')
- end
-
- def test_em_upper_case_with_complex_example
- input_keys('{}#* AaA!!!cCc ')
- input_keys("\C-a\M-u", false)
- assert_byte_pointer_size('{}#* AAA')
- assert_cursor(11)
- assert_cursor_max(20)
- assert_line('{}#* AAA!!!cCc ')
- input_keys("\M-u", false)
- assert_byte_pointer_size('{}#* AAA!!!CCC')
- assert_cursor(17)
- assert_cursor_max(20)
- assert_line('{}#* AAA!!!CCC ')
- input_keys("\M-u", false)
- assert_byte_pointer_size('{}#* AAA!!!CCC ')
- assert_cursor(20)
- assert_cursor_max(20)
- assert_line('{}#* AAA!!!CCC ')
- end
-
- def test_em_delete_or_list
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_foo
- foo_bar
- foo_baz
- qux
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('fooo')
- assert_byte_pointer_size('fooo')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('fooo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-b", false)
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(4)
- assert_line('fooo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- @line_editor.input_key(Reline::Key.new(:em_delete_or_list, :em_delete_or_list, false))
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- @line_editor.input_key(Reline::Key.new(:em_delete_or_list, :em_delete_or_list, false))
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- assert_equal(%w{foo_foo foo_bar foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
- end
-
- def test_completion
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_foo
- foo_bar
- foo_baz
- qux
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('fo')
- assert_byte_pointer_size('fo')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('fo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('foo_')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('foo_')
- assert_equal(%w{foo_foo foo_bar foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
- input_keys('a')
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_a')
- assert_cursor(5)
- assert_cursor_max(5)
- assert_line('foo_a')
- input_keys("\C-h", false)
- input_keys('b')
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_ba')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line('foo_ba')
- end
-
- def test_completion_with_indent
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_foo
- foo_bar
- foo_baz
- qux
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys(' fo')
- assert_byte_pointer_size(' fo')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line(' fo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size(' foo_')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line(' foo_')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size(' foo_')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line(' foo_')
- assert_equal(%w{foo_foo foo_bar foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
- end
-
- def test_completion_with_indent_and_completer_quote_characters
- @line_editor.completion_proc = proc { |word|
- %w{
- "".foo_foo
- "".foo_bar
- "".foo_baz
- "".qux
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys(' "".fo')
- assert_byte_pointer_size(' "".fo')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line(' "".fo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size(' "".foo_')
- assert_cursor(9)
- assert_cursor_max(9)
- assert_line(' "".foo_')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size(' "".foo_')
- assert_cursor(9)
- assert_cursor_max(9)
- assert_line(' "".foo_')
- assert_equal(%w{"".foo_foo "".foo_bar "".foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
- end
-
- def test_completion_with_perfect_match
- @line_editor.completion_proc = proc { |word|
- %w{
- foo
- foo_bar
- }.map { |i|
- i.encode(@encoding)
- }
- }
- matched = nil
- @line_editor.dig_perfect_match_proc = proc { |m|
- matched = m
- }
- input_keys('fo')
- assert_byte_pointer_size('fo')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('fo')
- assert_equal(Reline::LineEditor::CompletionState::NORMAL, @line_editor.instance_variable_get(:@completion_state))
- assert_equal(nil, matched)
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- assert_equal(Reline::LineEditor::CompletionState::MENU_WITH_PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state))
- assert_equal(nil, matched)
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state))
- assert_equal(nil, matched)
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state))
- assert_equal('foo', matched)
- matched = nil
- input_keys('_')
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_bar')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('foo_bar')
- assert_equal(Reline::LineEditor::CompletionState::MENU_WITH_PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state))
- assert_equal(nil, matched)
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_bar')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('foo_bar')
- assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state))
- assert_equal(nil, matched)
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_bar')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('foo_bar')
- assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state))
- assert_equal('foo_bar', matched)
- end
-
- def test_completion_with_completion_ignore_case
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_foo
- foo_bar
- Foo_baz
- qux
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('fo')
- assert_byte_pointer_size('fo')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('fo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('foo_')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('foo_')
- assert_equal(%w{foo_foo foo_bar}, @line_editor.instance_variable_get(:@menu_info).list)
- @config.completion_ignore_case = true
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('foo_')
- assert_equal(%w{foo_foo foo_bar Foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
- input_keys('a')
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_a')
- assert_cursor(5)
- assert_cursor_max(5)
- assert_line('foo_a')
- input_keys("\C-h", false)
- input_keys('b')
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_ba')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line('foo_ba')
- end
-
- def test_completion_in_middle_of_line
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_foo
- foo_bar
- foo_baz
- qux
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('abcde fo ABCDE')
- assert_line('abcde fo ABCDE')
- input_keys("\C-b" * 6 + "\C-i", false)
- assert_byte_pointer_size('abcde foo_')
- assert_cursor(10)
- assert_cursor_max(16)
- assert_line('abcde foo_ ABCDE')
- input_keys("\C-b" * 2 + "\C-i", false)
- assert_byte_pointer_size('abcde foo_')
- assert_cursor(10)
- assert_cursor_max(18)
- assert_line('abcde foo_o_ ABCDE')
- end
-
- def test_completion_with_nil_value
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_foo
- foo_bar
- Foo_baz
- qux
- }.map { |i|
- i.encode(@encoding)
- }.prepend(nil)
- }
- @config.completion_ignore_case = true
- input_keys('fo')
- assert_byte_pointer_size('fo')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('fo')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('foo_')
- assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('foo_')
- assert_equal(%w{foo_foo foo_bar Foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
- input_keys('a')
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_a')
- assert_cursor(5)
- assert_cursor_max(5)
- assert_line('foo_a')
- input_keys("\C-h", false)
- input_keys('b')
- input_keys("\C-i", false)
- assert_byte_pointer_size('foo_ba')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line('foo_ba')
- end
-
- def test_em_kill_region
- input_keys('abc def{bbb}ccc ddd ')
- assert_byte_pointer_size('abc def{bbb}ccc ddd ')
- assert_cursor(26)
- assert_cursor_max(26)
- assert_line('abc def{bbb}ccc ddd ')
- input_keys("\C-w", false)
- assert_byte_pointer_size('abc def{bbb}ccc ')
- assert_cursor(20)
- assert_cursor_max(20)
- assert_line('abc def{bbb}ccc ')
- input_keys("\C-w", false)
- assert_byte_pointer_size('abc ')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_line('abc ')
- input_keys("\C-w", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- input_keys("\C-w", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_em_kill_region_mbchar
- input_keys('ã‚ ã„ ã†{ã†}ㆠ')
- assert_byte_pointer_size('ã‚ ã„ ã†{ã†}ㆠ')
- assert_cursor(21)
- assert_cursor_max(21)
- assert_line('ã‚ ã„ ã†{ã†}ㆠ')
- input_keys("\C-w", false)
- assert_byte_pointer_size('ã‚ ã„ ')
- assert_cursor(10)
- assert_cursor_max(10)
- assert_line('ã‚ ã„ ')
- input_keys("\C-w", false)
- assert_byte_pointer_size('ã‚ ')
- assert_cursor(5)
- assert_cursor_max(5)
- assert_line('ã‚ ')
- input_keys("\C-w", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_vi_search_prev
- Reline::HISTORY.concat(%w{abc 123 AAA})
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-ra\C-j")
- assert_line('abc')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- end
-
- def test_larger_histories_than_history_size
- history_size = @config.history_size
- @config.history_size = 2
- Reline::HISTORY.concat(%w{abc 123 AAA})
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-p")
- assert_line('AAA')
- assert_byte_pointer_size('AAA')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-p")
- assert_line('123')
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(3)
- input_keys("\C-p")
- assert_line('123')
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(3)
- ensure
- @config.history_size = history_size
- end
-
- def test_search_history_to_back
- Reline::HISTORY.concat([
- '1235', # old
- '12aa',
- '1234' # new
- ])
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r123")
- assert_line('1234')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0) # doesn't determine yet
- input_keys("\C-ha")
- assert_line('12aa')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-h3")
- assert_line('1235')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- end
-
- def test_search_history_to_front
- Reline::HISTORY.concat([
- '1235', # old
- '12aa',
- '1234' # new
- ])
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-s123")
- assert_line('1235')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0) # doesn't determine yet
- input_keys("\C-ha")
- assert_line('12aa')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-h3")
- assert_line('1234')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- end
-
- def test_search_history_front_and_back
- Reline::HISTORY.concat([
- '1235', # old
- '12aa',
- '1234' # new
- ])
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-s12")
- assert_line('1235')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0) # doesn't determine yet
- input_keys("\C-s")
- assert_line('12aa')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r")
- assert_line('12aa')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r")
- assert_line('1235')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- end
-
- def test_search_history_back_and_front
- Reline::HISTORY.concat([
- '1235', # old
- '12aa',
- '1234' # new
- ])
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r12")
- assert_line('1234')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0) # doesn't determine yet
- input_keys("\C-r")
- assert_line('12aa')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-s")
- assert_line('12aa')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-s")
- assert_line('1234')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- end
-
- def test_search_history_to_back_in_the_middle_of_histories
- Reline::HISTORY.concat([
- '1235', # old
- '12aa',
- '1234' # new
- ])
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-p\C-p")
- assert_line('12aa')
- assert_byte_pointer_size('12aa')
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys("\C-r123")
- assert_line('1235')
- assert_byte_pointer_size('1235')
- assert_cursor(4)
- assert_cursor_max(4)
- end
-
- def test_search_history_twice
- Reline::HISTORY.concat([
- '1235', # old
- '12aa',
- '1234' # new
- ])
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r123")
- assert_line('1234')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0) # doesn't determine yet
- input_keys("\C-r")
- assert_line('1235')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- end
-
- def test_search_history_by_last_determined
- Reline::HISTORY.concat([
- '1235', # old
- '12aa',
- '1234' # new
- ])
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r123")
- assert_line('1234')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0) # doesn't determine yet
- input_keys("\C-j")
- assert_line('1234')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(4)
- input_keys("\C-k") # delete
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r")
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys("\C-r")
- assert_line('1235')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- end
-
- def test_em_set_mark_and_em_exchange_mark
- input_keys('aaa bbb ccc ddd')
- assert_byte_pointer_size('aaa bbb ccc ddd')
- assert_cursor(15)
- assert_cursor_max(15)
- assert_line('aaa bbb ccc ddd')
- input_keys("\C-a\M-F\M-F", false)
- assert_byte_pointer_size('aaa bbb')
- assert_cursor(7)
- assert_cursor_max(15)
- assert_line('aaa bbb ccc ddd')
- assert_equal(nil, @line_editor.instance_variable_get(:@mark_pointer))
- input_keys("\x00", false) # C-Space
- assert_byte_pointer_size('aaa bbb')
- assert_cursor(7)
- assert_cursor_max(15)
- assert_line('aaa bbb ccc ddd')
- assert_equal([7, 0], @line_editor.instance_variable_get(:@mark_pointer))
- input_keys("\C-a", false)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(15)
- assert_line('aaa bbb ccc ddd')
- assert_equal([7, 0], @line_editor.instance_variable_get(:@mark_pointer))
- input_key_by_symbol(:em_exchange_mark)
- assert_byte_pointer_size('aaa bbb')
- assert_cursor(7)
- assert_cursor_max(15)
- assert_line('aaa bbb ccc ddd')
- assert_equal([0, 0], @line_editor.instance_variable_get(:@mark_pointer))
- end
-
- def test_modify_lines_with_wrong_rs
- verbose, $VERBOSE = $VERBOSE, nil
- original_global_slash = $/
- $/ = 'b'
- $VERBOSE = verbose
- @line_editor.output_modifier_proc = proc { |output| Reline::Unicode.escape_for_print(output) }
- input_keys("abcdef\n")
- result = @line_editor.__send__(:modify_lines, @line_editor.whole_lines)
- $/ = nil
- assert_equal(['abcdef'], result)
- ensure
- $VERBOSE = nil
- $/ = original_global_slash
- $VERBOSE = verbose
- end
-
- def test_ed_search_prev_history
- Reline::HISTORY.concat([
- '12356', # old
- '12aaa',
- '12345' # new
- ])
- input_keys('123')
- # The ed_search_prev_history doesn't have default binding
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12345')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12356')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12356')
- end
-
- def test_ed_search_prev_history_with_empty
- Reline::HISTORY.concat([
- '12356', # old
- '12aaa',
- '12345' # new
- ])
- # The ed_search_prev_history doesn't have default binding
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12345')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12aaa')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12356')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12356')
- end
-
- def test_ed_search_prev_history_without_match
- Reline::HISTORY.concat([
- '12356', # old
- '12aaa',
- '12345' # new
- ])
- input_keys('ABC')
- # The ed_search_prev_history doesn't have default binding
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('ABC')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('ABC')
- end
-
- def test_ed_search_next_history
- Reline::HISTORY.concat([
- '12356', # old
- '12aaa',
- '12345' # new
- ])
- input_keys('123')
- # The ed_search_prev_history and ed_search_next_history doesn't have default binding
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12345')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12356')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12356')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12345')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_byte_pointer_size('123')
- assert_cursor(3)
- assert_cursor_max(5)
- assert_line('12345')
- end
-
- def test_ed_search_next_history_with_empty
- Reline::HISTORY.concat([
- '12356', # old
- '12aaa',
- '12345' # new
- ])
- # The ed_search_prev_history and ed_search_next_history doesn't have default binding
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12345')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12aaa')
- @line_editor.__send__(:ed_search_prev_history, "\C-p".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12356')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12aaa')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- assert_line('12345')
- @line_editor.__send__(:ed_search_next_history, "\C-n".ord)
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
-=begin # TODO: move KeyStroke instance from Reline to LineEditor
- def test_key_delete
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('ab')
- [27, 91, 51, 126].each do |key|
- @line_editor.input_key(key)
- end
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('ab')
- input_keys("\C-b")
- [27, 91, 51, 126].each do |key|
- @line_editor.input_key(key)
- end
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(1)
- assert_line('a')
- end
-=end
-end
diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb
deleted file mode 100644
index c6337baea7..0000000000
--- a/test/reline/test_key_actor_vi.rb
+++ /dev/null
@@ -1,1240 +0,0 @@
-require_relative 'helper'
-
-class Reline::KeyActor::ViInsert::Test < Reline::TestCase
- def setup
- Reline.send(:test_mode)
- @prompt = '> '
- @config = Reline::Config.new
- @config.read_lines(<<~LINES.split(/(?<=\n)/))
- set editing-mode vi
- LINES
- @encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
- @line_editor = Reline::LineEditor.new(@config, @encoding)
- @line_editor.reset(@prompt, encoding: @encoding)
- end
-
- def test_vi_command_mode
- input_keys("\C-[")
- assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
- end
-
- def test_vi_command_mode_with_input
- input_keys("abc\C-[")
- assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
- assert_line('abc')
- end
-
- def test_vi_insert
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- input_keys('i')
- assert_line('i')
- assert_cursor(1)
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- input_keys("\C-[")
- assert_line('i')
- assert_cursor(0)
- assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
- input_keys('i')
- assert_line('i')
- assert_cursor(0)
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- end
-
- def test_vi_add
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- input_keys('a')
- assert_line('a')
- assert_cursor(1)
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- input_keys("\C-[")
- assert_line('a')
- assert_cursor(0)
- assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
- input_keys('a')
- assert_line('a')
- assert_cursor(1)
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- end
-
- def test_vi_insert_at_bol
- input_keys('I')
- assert_line('I')
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- input_keys("12345\C-[hh")
- assert_line('I12345')
- assert_byte_pointer_size('I12')
- assert_cursor(3)
- assert_cursor_max(6)
- assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
- input_keys('I')
- assert_line('I12345')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- end
-
- def test_vi_add_at_eol
- input_keys('A')
- assert_line('A')
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- input_keys("12345\C-[hh")
- assert_line('A12345')
- assert_byte_pointer_size('A12')
- assert_cursor(3)
- assert_cursor_max(6)
- assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
- input_keys('A')
- assert_line('A12345')
- assert_byte_pointer_size('A12345')
- assert_cursor(6)
- assert_cursor_max(6)
- assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
- end
-
- def test_ed_insert_one
- input_keys('a')
- assert_line('a')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(1)
- end
-
- def test_ed_insert_two
- input_keys('ab')
- assert_line('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- end
-
- def test_ed_insert_mbchar_one
- input_keys('ã‹')
- assert_line('ã‹')
- assert_byte_pointer_size('ã‹')
- assert_cursor(2)
- assert_cursor_max(2)
- end
-
- def test_ed_insert_mbchar_two
- input_keys('ã‹ã')
- assert_line('ã‹ã')
- assert_byte_pointer_size('ã‹ã')
- assert_cursor(4)
- assert_cursor_max(4)
- end
-
- def test_ed_insert_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099")
- assert_line("ã‹\u3099")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(2)
- end
-
- def test_ed_insert_for_plural_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099")
- assert_line("ã‹\u3099ã\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(4)
- end
-
- def test_ed_next_char
- input_keys("abcdef\C-[0")
- assert_line('abcdef')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys('l')
- assert_line('abcdef')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(6)
- input_keys('2l')
- assert_line('abcdef')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(6)
- end
-
- def test_ed_prev_char
- input_keys("abcdef\C-[")
- assert_line('abcdef')
- assert_byte_pointer_size('abcde')
- assert_cursor(5)
- assert_cursor_max(6)
- input_keys('h')
- assert_line('abcdef')
- assert_byte_pointer_size('abcd')
- assert_cursor(4)
- assert_cursor_max(6)
- input_keys('2h')
- assert_line('abcdef')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(6)
- end
-
- def test_history
- Reline::HISTORY.concat(%w{abc 123 AAA})
- input_keys("\C-[")
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- input_keys('k')
- assert_line('AAA')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- input_keys('2k')
- assert_line('abc')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- input_keys('j')
- assert_line('123')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(3)
- input_keys('2j')
- assert_line('')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- end
-
- def test_vi_paste_prev
- input_keys("abcde\C-[3h")
- assert_line('abcde')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(5)
- input_keys('P')
- assert_line('abcde')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(5)
- input_keys('d$')
- assert_line('a')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(1)
- input_keys('P')
- assert_line('bcdea')
- assert_byte_pointer_size('bcd')
- assert_cursor(3)
- assert_cursor_max(5)
- input_keys('2P')
- assert_line('bcdbcdbcdeeea')
- assert_byte_pointer_size('bcdbcdbcd')
- assert_cursor(9)
- assert_cursor_max(13)
- end
-
- def test_vi_paste_next
- input_keys("abcde\C-[3h")
- assert_line('abcde')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(5)
- input_keys('p')
- assert_line('abcde')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(5)
- input_keys('d$')
- assert_line('a')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(1)
- input_keys('p')
- assert_line('abcde')
- assert_byte_pointer_size('abcd')
- assert_cursor(4)
- assert_cursor_max(5)
- input_keys('2p')
- assert_line('abcdebcdebcde')
- assert_byte_pointer_size('abcdebcdebcd')
- assert_cursor(12)
- assert_cursor_max(13)
- end
-
- def test_vi_paste_prev_for_mbchar
- input_keys("ã‚ã„ã†ãˆãŠ\C-[3h")
- assert_line('ã‚ã„ã†ãˆãŠ')
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('P')
- assert_line('ã‚ã„ã†ãˆãŠ')
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('d$')
- assert_line('ã‚')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- input_keys('P')
- assert_line('ã„ã†ãˆãŠã‚')
- assert_byte_pointer_size('ã„ã†ãˆ')
- assert_cursor(6)
- assert_cursor_max(10)
- input_keys('2P')
- assert_line('ã„ã†ãˆã„ã†ãˆã„ã†ãˆãŠãŠãŠã‚')
- assert_byte_pointer_size('ã„ã†ãˆã„ã†ãˆã„ã†ãˆ')
- assert_cursor(18)
- assert_cursor_max(26)
- end
-
- def test_vi_paste_next_for_mbchar
- input_keys("ã‚ã„ã†ãˆãŠ\C-[3h")
- assert_line('ã‚ã„ã†ãˆãŠ')
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('p')
- assert_line('ã‚ã„ã†ãˆãŠ')
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('d$')
- assert_line('ã‚')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- input_keys('p')
- assert_line('ã‚ã„ã†ãˆãŠ')
- assert_byte_pointer_size('ã‚ã„ã†ãˆ')
- assert_cursor(8)
- assert_cursor_max(10)
- input_keys('2p')
- assert_line('ã‚ã„ã†ãˆãŠã„ã†ãˆãŠã„ã†ãˆãŠ')
- assert_byte_pointer_size('ã‚ã„ã†ãˆãŠã„ã†ãˆãŠã„ã†ãˆ')
- assert_cursor(24)
- assert_cursor_max(26)
- end
-
- def test_vi_paste_prev_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099\C-[3h")
- assert_line("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('P')
- assert_line("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('d$')
- assert_line("ã‹\u3099")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- input_keys('P')
- assert_line("ã\u3099ã\u3099ã‘\u3099ã“\u3099ã‹\u3099")
- assert_byte_pointer_size("ã\u3099ã\u3099ã‘\u3099")
- assert_cursor(6)
- assert_cursor_max(10)
- input_keys('2P')
- assert_line("ã\u3099ã\u3099ã‘\u3099ã\u3099ã\u3099ã‘\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099ã“\u3099ã“\u3099ã‹\u3099")
- assert_byte_pointer_size("ã\u3099ã\u3099ã‘\u3099ã\u3099ã\u3099ã‘\u3099ã\u3099ã\u3099ã‘\u3099")
- assert_cursor(18)
- assert_cursor_max(26)
- end
-
- def test_vi_paste_next_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099\C-[3h")
- assert_line("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('p')
- assert_line("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(10)
- input_keys('d$')
- assert_line("ã‹\u3099")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- input_keys('p')
- assert_line("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099ã\u3099ã‘\u3099")
- assert_cursor(8)
- assert_cursor_max(10)
- input_keys('2p')
- assert_line("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099ã\u3099ã\u3099ã‘\u3099ã“\u3099ã\u3099ã\u3099ã‘\u3099")
- assert_cursor(24)
- assert_cursor_max(26)
- end
-
- def test_vi_prev_next_word
- input_keys("aaa b{b}b ccc\C-[0")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(13)
- input_keys('w')
- assert_byte_pointer_size('aaa ')
- assert_cursor(4)
- assert_cursor_max(13)
- input_keys('w')
- assert_byte_pointer_size('aaa b')
- assert_cursor(5)
- assert_cursor_max(13)
- input_keys('w')
- assert_byte_pointer_size('aaa b{')
- assert_cursor(6)
- assert_cursor_max(13)
- input_keys('w')
- assert_byte_pointer_size('aaa b{b')
- assert_cursor(7)
- assert_cursor_max(13)
- input_keys('w')
- assert_byte_pointer_size('aaa b{b}')
- assert_cursor(8)
- assert_cursor_max(13)
- input_keys('w')
- assert_byte_pointer_size('aaa b{b}b ')
- assert_cursor(10)
- assert_cursor_max(13)
- input_keys('w')
- assert_byte_pointer_size('aaa b{b}b cc')
- assert_cursor(12)
- assert_cursor_max(13)
- input_keys('b')
- assert_byte_pointer_size('aaa b{b}b ')
- assert_cursor(10)
- assert_cursor_max(13)
- input_keys('b')
- assert_byte_pointer_size('aaa b{b}')
- assert_cursor(8)
- assert_cursor_max(13)
- input_keys('b')
- assert_byte_pointer_size('aaa b{b')
- assert_cursor(7)
- assert_cursor_max(13)
- input_keys('b')
- assert_byte_pointer_size('aaa b{')
- assert_cursor(6)
- assert_cursor_max(13)
- input_keys('b')
- assert_byte_pointer_size('aaa b')
- assert_cursor(5)
- assert_cursor_max(13)
- input_keys('b')
- assert_byte_pointer_size('aaa ')
- assert_cursor(4)
- assert_cursor_max(13)
- input_keys('b')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(13)
- input_keys('3w')
- assert_byte_pointer_size('aaa b{')
- assert_cursor(6)
- assert_cursor_max(13)
- input_keys('3w')
- assert_byte_pointer_size('aaa b{b}b ')
- assert_cursor(10)
- assert_cursor_max(13)
- input_keys('3w')
- assert_byte_pointer_size('aaa b{b}b cc')
- assert_cursor(12)
- assert_cursor_max(13)
- input_keys('3b')
- assert_byte_pointer_size('aaa b{b')
- assert_cursor(7)
- assert_cursor_max(13)
- input_keys('3b')
- assert_byte_pointer_size('aaa ')
- assert_cursor(4)
- assert_cursor_max(13)
- input_keys('3b')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(13)
- end
-
- def test_vi_end_word
- input_keys("aaa b{b}}}b ccc\C-[0")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aa')
- assert_cursor(2)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aaa ')
- assert_cursor(6)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aaa b')
- assert_cursor(7)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aaa b{')
- assert_cursor(8)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aaa b{b}}')
- assert_cursor(11)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aaa b{b}}}')
- assert_cursor(12)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aaa b{b}}}b cc')
- assert_cursor(18)
- assert_cursor_max(19)
- input_keys('e')
- assert_byte_pointer_size('aaa b{b}}}b cc')
- assert_cursor(18)
- assert_cursor_max(19)
- input_keys('03e')
- assert_byte_pointer_size('aaa b')
- assert_cursor(7)
- assert_cursor_max(19)
- input_keys('3e')
- assert_byte_pointer_size('aaa b{b}}}')
- assert_cursor(12)
- assert_cursor_max(19)
- input_keys('3e')
- assert_byte_pointer_size('aaa b{b}}}b cc')
- assert_cursor(18)
- assert_cursor_max(19)
- end
-
- def test_vi_prev_next_big_word
- input_keys("aaa b{b}b ccc\C-[0")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(13)
- input_keys('W')
- assert_byte_pointer_size('aaa ')
- assert_cursor(4)
- assert_cursor_max(13)
- input_keys('W')
- assert_byte_pointer_size('aaa b{b}b ')
- assert_cursor(10)
- assert_cursor_max(13)
- input_keys('W')
- assert_byte_pointer_size('aaa b{b}b cc')
- assert_cursor(12)
- assert_cursor_max(13)
- input_keys('B')
- assert_byte_pointer_size('aaa b{b}b ')
- assert_cursor(10)
- assert_cursor_max(13)
- input_keys('B')
- assert_byte_pointer_size('aaa ')
- assert_cursor(4)
- assert_cursor_max(13)
- input_keys('B')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(13)
- input_keys('2W')
- assert_byte_pointer_size('aaa b{b}b ')
- assert_cursor(10)
- assert_cursor_max(13)
- input_keys('2W')
- assert_byte_pointer_size('aaa b{b}b cc')
- assert_cursor(12)
- assert_cursor_max(13)
- input_keys('2B')
- assert_byte_pointer_size('aaa ')
- assert_cursor(4)
- assert_cursor_max(13)
- input_keys('2B')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(13)
- end
-
- def test_vi_end_big_word
- input_keys("aaa b{b}}}b ccc\C-[0")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(19)
- input_keys('E')
- assert_byte_pointer_size('aa')
- assert_cursor(2)
- assert_cursor_max(19)
- input_keys('E')
- assert_byte_pointer_size('aaa b{b}}}')
- assert_cursor(12)
- assert_cursor_max(19)
- input_keys('E')
- assert_byte_pointer_size('aaa b{b}}}b cc')
- assert_cursor(18)
- assert_cursor_max(19)
- input_keys('E')
- assert_byte_pointer_size('aaa b{b}}}b cc')
- assert_cursor(18)
- assert_cursor_max(19)
- end
-
- def test_ed_quoted_insert
- input_keys("ab\C-v\C-acd")
- assert_line("ab\C-acd")
- assert_byte_pointer_size("ab\C-acd")
- assert_cursor(6)
- assert_cursor_max(6)
- end
-
- def test_ed_quoted_insert_with_vi_arg
- input_keys("ab\C-[3\C-v\C-aacd")
- assert_line("a\C-a\C-a\C-abcd")
- assert_byte_pointer_size("a\C-a\C-a\C-abcd")
- assert_cursor(10)
- assert_cursor_max(10)
- end
-
- def test_vi_replace_char
- input_keys("abcdef\C-[03l")
- assert_line('abcdef')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(6)
- input_keys('rz')
- assert_line('abczef')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(6)
- input_keys('2rx')
- assert_line('abcxxf')
- assert_byte_pointer_size('abcxx')
- assert_cursor(5)
- assert_cursor_max(6)
- end
-
- def test_vi_next_char
- input_keys("abcdef\C-[0")
- assert_line('abcdef')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys('fz')
- assert_line('abcdef')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys('fe')
- assert_line('abcdef')
- assert_byte_pointer_size('abcd')
- assert_cursor(4)
- assert_cursor_max(6)
- end
-
- def test_vi_to_next_char
- input_keys("abcdef\C-[0")
- assert_line('abcdef')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys('tz')
- assert_line('abcdef')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys('te')
- assert_line('abcdef')
- assert_byte_pointer_size('abc')
- assert_cursor(3)
- assert_cursor_max(6)
- end
-
- def test_vi_prev_char
- input_keys("abcdef\C-[")
- assert_line('abcdef')
- assert_byte_pointer_size('abcde')
- assert_cursor(5)
- assert_cursor_max(6)
- input_keys('Fz')
- assert_line('abcdef')
- assert_byte_pointer_size('abcde')
- assert_cursor(5)
- assert_cursor_max(6)
- input_keys('Fa')
- assert_line('abcdef')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- end
-
- def test_vi_to_prev_char
- input_keys("abcdef\C-[")
- assert_line('abcdef')
- assert_byte_pointer_size('abcde')
- assert_cursor(5)
- assert_cursor_max(6)
- input_keys('Tz')
- assert_line('abcdef')
- assert_byte_pointer_size('abcde')
- assert_cursor(5)
- assert_cursor_max(6)
- input_keys('Ta')
- assert_line('abcdef')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(6)
- end
-
- def test_vi_delete_next_char
- input_keys("abc\C-[h")
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(3)
- assert_line('abc')
- input_keys('x')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(2)
- assert_line('ac')
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(1)
- assert_line('a')
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_vi_delete_next_char_for_mbchar
- input_keys("ã‚ã„ã†\C-[h")
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(6)
- assert_line('ã‚ã„ã†')
- input_keys('x')
- assert_byte_pointer_size('ã‚')
- assert_cursor(2)
- assert_cursor_max(4)
- assert_line('ã‚ã†')
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- assert_line('ã‚')
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_vi_delete_next_char_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099ã\u3099\C-[h")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(6)
- assert_line("ã‹\u3099ã\u3099ã\u3099")
- input_keys('x')
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(4)
- assert_line("ã‹\u3099ã\u3099")
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(2)
- assert_line("ã‹\u3099")
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- input_keys('x')
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_vi_delete_prev_char
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- input_keys("\C-h")
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(1)
- assert_line('a')
- end
-
- def test_vi_delete_prev_char_for_mbchar
- input_keys('ã‹ã')
- assert_byte_pointer_size('ã‹ã')
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys("\C-h")
- assert_byte_pointer_size('ã‹')
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line('ã‹')
- end
-
- def test_vi_delete_prev_char_for_mbchar_by_plural_code_points
- input_keys("ã‹\u3099ã\u3099")
- assert_byte_pointer_size("ã‹\u3099ã\u3099")
- assert_cursor(4)
- assert_cursor_max(4)
- input_keys("\C-h")
- assert_byte_pointer_size("ã‹\u3099")
- assert_cursor(2)
- assert_cursor_max(2)
- assert_line("ã‹\u3099")
- end
-
- def test_ed_delete_prev_char
- input_keys("abcdefg\C-[h")
- assert_byte_pointer_size('abcde')
- assert_cursor(5)
- assert_cursor_max(7)
- assert_line('abcdefg')
- input_keys('X')
- assert_byte_pointer_size('abcd')
- assert_cursor(4)
- assert_cursor_max(6)
- assert_line('abcdfg')
- input_keys('3X')
- assert_byte_pointer_size('a')
- assert_cursor(1)
- assert_cursor_max(3)
- assert_line('afg')
- input_keys('p')
- assert_byte_pointer_size('abcd')
- assert_cursor(4)
- assert_cursor_max(6)
- assert_line('afbcdg')
- end
-
- def test_ed_delete_prev_word
- input_keys('abc def{bbb}ccc')
- assert_byte_pointer_size('abc def{bbb}ccc')
- assert_cursor(15)
- assert_cursor_max(15)
- input_keys("\C-w")
- assert_byte_pointer_size('abc def{bbb}')
- assert_cursor(12)
- assert_cursor_max(12)
- assert_line('abc def{bbb}')
- input_keys("\C-w")
- assert_byte_pointer_size('abc def{')
- assert_cursor(8)
- assert_cursor_max(8)
- assert_line('abc def{')
- input_keys("\C-w")
- assert_byte_pointer_size('abc ')
- assert_cursor(4)
- assert_cursor_max(4)
- assert_line('abc ')
- input_keys("\C-w")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_ed_delete_prev_word_for_mbchar
- input_keys('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}ãŸã¡ã¤')
- assert_cursor(27)
- assert_cursor_max(27)
- input_keys("\C-w")
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{ã•ã—ã™}')
- assert_cursor(21)
- assert_cursor_max(21)
- assert_line('ã‚ã„ㆠã‹ãã{ã•ã—ã™}')
- input_keys("\C-w")
- assert_byte_pointer_size('ã‚ã„ㆠã‹ãã{')
- assert_cursor(14)
- assert_cursor_max(14)
- assert_line('ã‚ã„ㆠã‹ãã{')
- input_keys("\C-w")
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('ã‚ã„ㆠ')
- input_keys("\C-w")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_ed_delete_prev_word_for_mbchar_by_plural_code_points
- input_keys("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}ãŸã¡ã¤")
- assert_cursor(27)
- assert_cursor_max(27)
- input_keys("\C-w")
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}")
- assert_cursor(21)
- assert_cursor_max(21)
- assert_line("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{ã•ã—ã™}")
- input_keys("\C-w")
- assert_byte_pointer_size("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{")
- assert_cursor(14)
- assert_cursor_max(14)
- assert_line("ã‚ã„ㆠã‹\u3099ã\u3099ã\u3099{")
- input_keys("\C-w")
- assert_byte_pointer_size('ã‚ã„ㆠ')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('ã‚ã„ㆠ')
- input_keys("\C-w")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(0)
- assert_line('')
- end
-
- def test_ed_newline_with_cr
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- refute(@line_editor.finished?)
- input_keys("\C-m")
- assert_line('ab')
- assert(@line_editor.finished?)
- end
-
- def test_ed_newline_with_lf
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- refute(@line_editor.finished?)
- input_keys("\C-j")
- assert_line('ab')
- assert(@line_editor.finished?)
- end
-
- def test_vi_list_or_eof
- input_keys("\C-d") # quit from inputing
- assert_line(nil)
- assert(@line_editor.finished?)
- end
-
- def test_vi_list_or_eof_with_non_empty_line
- input_keys('ab')
- assert_byte_pointer_size('ab')
- assert_cursor(2)
- assert_cursor_max(2)
- refute(@line_editor.finished?)
- input_keys("\C-d")
- assert_line('ab')
- assert(@line_editor.finished?)
- end
-
- def test_completion_journey
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_bar
- foo_bar_baz
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('foo')
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-n")
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-n")
- assert_byte_pointer_size('foo_bar')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('foo_bar')
- input_keys("\C-n")
- assert_byte_pointer_size('foo_bar_baz')
- assert_cursor(11)
- assert_cursor_max(11)
- assert_line('foo_bar_baz')
- input_keys("\C-n")
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-n")
- assert_byte_pointer_size('foo_bar')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('foo_bar')
- input_keys("_\C-n")
- assert_byte_pointer_size('foo_bar_')
- assert_cursor(8)
- assert_cursor_max(8)
- assert_line('foo_bar_')
- input_keys("\C-n")
- assert_byte_pointer_size('foo_bar_baz')
- assert_cursor(11)
- assert_cursor_max(11)
- assert_line('foo_bar_baz')
- input_keys("\C-n")
- assert_byte_pointer_size('foo_bar_')
- assert_cursor(8)
- assert_cursor_max(8)
- assert_line('foo_bar_')
- end
-
- def test_completion_journey_reverse
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_bar
- foo_bar_baz
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('foo')
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-p")
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-p")
- assert_byte_pointer_size('foo_bar_baz')
- assert_cursor(11)
- assert_cursor_max(11)
- assert_line('foo_bar_baz')
- input_keys("\C-p")
- assert_byte_pointer_size('foo_bar')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('foo_bar')
- input_keys("\C-p")
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-p")
- assert_byte_pointer_size('foo_bar_baz')
- assert_cursor(11)
- assert_cursor_max(11)
- assert_line('foo_bar_baz')
- input_keys("\C-h\C-p")
- assert_byte_pointer_size('foo_bar_ba')
- assert_cursor(10)
- assert_cursor_max(10)
- assert_line('foo_bar_ba')
- input_keys("\C-p")
- assert_byte_pointer_size('foo_bar_baz')
- assert_cursor(11)
- assert_cursor_max(11)
- assert_line('foo_bar_baz')
- input_keys("\C-p")
- assert_byte_pointer_size('foo_bar_ba')
- assert_cursor(10)
- assert_cursor_max(10)
- assert_line('foo_bar_ba')
- end
-
- def test_completion_journey_in_middle_of_line
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_bar
- foo_bar_baz
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('abcde fo ABCDE')
- assert_line('abcde fo ABCDE')
- input_keys("\C-[" + 'h' * 5 + "i\C-n")
- assert_byte_pointer_size('abcde fo')
- assert_cursor(8)
- assert_cursor_max(14)
- assert_line('abcde fo ABCDE')
- input_keys("\C-n")
- assert_byte_pointer_size('abcde foo_bar')
- assert_cursor(13)
- assert_cursor_max(19)
- assert_line('abcde foo_bar ABCDE')
- input_keys("\C-n")
- assert_byte_pointer_size('abcde foo_bar_baz')
- assert_cursor(17)
- assert_cursor_max(23)
- assert_line('abcde foo_bar_baz ABCDE')
- input_keys("\C-n")
- assert_byte_pointer_size('abcde fo')
- assert_cursor(8)
- assert_cursor_max(14)
- assert_line('abcde fo ABCDE')
- input_keys("\C-n")
- assert_byte_pointer_size('abcde foo_bar')
- assert_cursor(13)
- assert_cursor_max(19)
- assert_line('abcde foo_bar ABCDE')
- input_keys("_\C-n")
- assert_byte_pointer_size('abcde foo_bar_')
- assert_cursor(14)
- assert_cursor_max(20)
- assert_line('abcde foo_bar_ ABCDE')
- input_keys("\C-n")
- assert_byte_pointer_size('abcde foo_bar_baz')
- assert_cursor(17)
- assert_cursor_max(23)
- assert_line('abcde foo_bar_baz ABCDE')
- input_keys("\C-n")
- assert_byte_pointer_size('abcde foo_bar_')
- assert_cursor(14)
- assert_cursor_max(20)
- assert_line('abcde foo_bar_ ABCDE')
- input_keys("\C-n")
- assert_byte_pointer_size('abcde foo_bar_baz')
- assert_cursor(17)
- assert_cursor_max(23)
- assert_line('abcde foo_bar_baz ABCDE')
- end
-
- def test_completion
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_bar
- foo_bar_baz
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('foo')
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-i")
- assert_byte_pointer_size('foo_bar')
- assert_cursor(7)
- assert_cursor_max(7)
- assert_line('foo_bar')
- end
-
- def test_completion_with_disable_completion
- @config.disable_completion = true
- @line_editor.completion_proc = proc { |word|
- %w{
- foo_bar
- foo_bar_baz
- }.map { |i|
- i.encode(@encoding)
- }
- }
- input_keys('foo')
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- input_keys("\C-i")
- assert_byte_pointer_size('foo')
- assert_cursor(3)
- assert_cursor_max(3)
- assert_line('foo')
- end
-
- def test_vi_first_print
- input_keys("abcde\C-[^")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- input_keys("0\C-ki")
- input_keys(" abcde\C-[^")
- assert_byte_pointer_size(' ')
- assert_cursor(1)
- assert_cursor_max(6)
- input_keys("0\C-ki")
- input_keys(" abcde ABCDE \C-[^")
- assert_byte_pointer_size(' ')
- assert_cursor(3)
- assert_cursor_max(17)
- end
-
- def test_ed_move_to_beg
- input_keys("abcde\C-[0")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(5)
- input_keys("0\C-ki")
- input_keys(" abcde\C-[0")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(6)
- input_keys("0\C-ki")
- input_keys(" abcde ABCDE \C-[0")
- assert_byte_pointer_size('')
- assert_cursor(0)
- assert_cursor_max(17)
- end
-
- def test_vi_delete_meta
- input_keys("aaa bbb ccc ddd eee\C-[02w")
- assert_byte_pointer_size('aaa bbb ')
- assert_cursor(8)
- assert_cursor_max(19)
- assert_line('aaa bbb ccc ddd eee')
- input_keys('dw')
- assert_byte_pointer_size('aaa bbb ')
- assert_cursor(8)
- assert_cursor_max(15)
- assert_line('aaa bbb ddd eee')
- input_keys('db')
- assert_byte_pointer_size('aaa ')
- assert_cursor(4)
- assert_cursor_max(11)
- assert_line('aaa ddd eee')
- end
-
- def test_vi_change_meta
- input_keys("aaa bbb ccc ddd eee\C-[02w")
- assert_byte_pointer_size('aaa bbb ')
- assert_cursor(8)
- assert_cursor_max(19)
- assert_line('aaa bbb ccc ddd eee')
- input_keys('cwaiueo ')
- assert_byte_pointer_size('aaa bbb aiueo ')
- assert_cursor(14)
- assert_cursor_max(21)
- assert_line('aaa bbb aiueo ddd eee')
- input_keys("\C-[")
- assert_byte_pointer_size('aaa bbb aiueo')
- assert_cursor(13)
- assert_cursor_max(21)
- assert_line('aaa bbb aiueo ddd eee')
- input_keys('cb')
- assert_byte_pointer_size('aaa bbb ')
- assert_cursor(8)
- assert_cursor_max(16)
- assert_line('aaa bbb ddd eee')
- end
-end
diff --git a/test/reline/test_key_stroke.rb b/test/reline/test_key_stroke.rb
deleted file mode 100644
index 15675a9b5a..0000000000
--- a/test/reline/test_key_stroke.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative 'helper'
-
-class Reline::KeyStroke::Test < Reline::TestCase
- using Module.new {
- refine Array do
- def as_s
- join
- end
-
- def to_keys
- map{ |b| Reline::Key.new(b, b, false) }
- end
- end
- }
-
- def test_match_status
- config = Reline::Config.new
- {
- 'a' => 'xx',
- 'ab' => 'y',
- 'abc' => 'z',
- 'x' => 'rr'
- }.each_pair do |key, func|
- config.add_default_key_binding(key.bytes, func.bytes)
- end
- stroke = Reline::KeyStroke.new(config)
- assert_equal(:matching, stroke.match_status("a".bytes))
- assert_equal(:matching, stroke.match_status("ab".bytes))
- assert_equal(:matched, stroke.match_status("abc".bytes))
- assert_equal(:matched, stroke.match_status("abz".bytes))
- assert_equal(:matched, stroke.match_status("abx".bytes))
- assert_equal(:matched, stroke.match_status("ac".bytes))
- assert_equal(:matched, stroke.match_status("aa".bytes))
- assert_equal(:matched, stroke.match_status("x".bytes))
- assert_equal(:unmatched, stroke.match_status("m".bytes))
- assert_equal(:matched, stroke.match_status("abzwabk".bytes))
- end
-
- def test_aaa
- config = Reline::Config.new
- {
- 'abc' => '123',
- }.each_pair do |key, func|
- config.add_default_key_binding(key.bytes, func.bytes)
- end
- stroke = Reline::KeyStroke.new(config)
- assert_equal('123'.bytes, stroke.expand('abc'.bytes))
- end
-end
diff --git a/test/reline/test_kill_ring.rb b/test/reline/test_kill_ring.rb
deleted file mode 100644
index 8bebfe2177..0000000000
--- a/test/reline/test_kill_ring.rb
+++ /dev/null
@@ -1,256 +0,0 @@
-require_relative 'helper'
-
-class Reline::KillRing::Test < Reline::TestCase
- def setup
- @prompt = '> '
- @kill_ring = Reline::KillRing.new
- end
-
- def test_append_one
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('a', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('a', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['a', 'a'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['a', 'a'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_two
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('b', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('b', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['a', 'b'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['b', 'a'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_three
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('c')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('c', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('c', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['b', 'c'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['a', 'b'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['c', 'a'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_three_with_max_two
- @kill_ring = Reline::KillRing.new(2)
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('c')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('c', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('c', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['b', 'c'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['c', 'b'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['b', 'c'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_four_with_max_two
- @kill_ring = Reline::KillRing.new(2)
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('c')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('d')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('d', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('d', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['c', 'd'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['d', 'c'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['c', 'd'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_after
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('ab', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('ab', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['ab', 'ab'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['ab', 'ab'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_before
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b', true)
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('ba', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('ba', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['ba', 'ba'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['ba', 'ba'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_chain_two
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('c')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('d')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('cd', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('cd', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['ab', 'cd'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['cd', 'ab'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-
- def test_append_complex_chain
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('c')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('d')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('b', true)
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('e')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('a', true)
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::FRESH, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('A')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.append('B')
- assert_equal(Reline::KillRing::State::CONTINUED, @kill_ring.instance_variable_get(:@state))
- @kill_ring.process
- assert_equal(Reline::KillRing::State::PROCESSED, @kill_ring.instance_variable_get(:@state))
- assert_equal('AB', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal('AB', @kill_ring.yank)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['abcde', 'AB'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- assert_equal(['AB', 'abcde'], @kill_ring.yank_pop)
- assert_equal(Reline::KillRing::State::YANK, @kill_ring.instance_variable_get(:@state))
- end
-end
diff --git a/test/reline/test_macro.rb b/test/reline/test_macro.rb
deleted file mode 100644
index b97de88a97..0000000000
--- a/test/reline/test_macro.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require_relative 'helper'
-
-class Reline::MacroTest < Reline::TestCase
- def setup
- @config = Reline::Config.new
- @encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
- @line_editor = Reline::LineEditor.new(@config, @encoding)
- @line_editor.instance_variable_set(:@screen_size, [24, 80])
- @output = @line_editor.output = File.open(IO::NULL, "w")
- end
-
- def teardown
- @output.close
- end
-
- def input_key(char, combined_char = char, with_meta = false)
- @line_editor.input_key(Reline::Key.new(char, combined_char, with_meta))
- end
-
- def input(str)
- str.each_byte {|c| input_key(c)}
- end
-
- def test_simple_input
- input('abc')
- assert_equal 'abc', @line_editor.line
- end
-
- def test_alias
- class << @line_editor
- alias delete_char ed_delete_prev_char
- end
- input('abc')
- assert_nothing_raised(ArgumentError) {
- input_key(:delete_char)
- }
- assert_equal 'ab', @line_editor.line
- end
-end
diff --git a/test/reline/test_reline.rb b/test/reline/test_reline.rb
deleted file mode 100644
index d2de4690d5..0000000000
--- a/test/reline/test_reline.rb
+++ /dev/null
@@ -1,315 +0,0 @@
-require_relative 'helper'
-require "reline"
-
-class Reline::Test < Reline::TestCase
- class DummyCallbackObject
- def call; end
- end
-
- def setup
- Reline.output_modifier_proc = nil
- Reline.completion_proc = nil
- Reline.prompt_proc = nil
- Reline.auto_indent_proc = nil
- Reline.pre_input_hook = nil
- Reline.dig_perfect_match_proc = nil
- end
-
- def teardown
- Reline.test_reset
- end
-
- def test_completion_append_character
- completion_append_character = Reline.completion_append_character
-
- assert_equal(nil, Reline.completion_append_character)
-
- Reline.completion_append_character = ""
- assert_equal(nil, Reline.completion_append_character)
-
- Reline.completion_append_character = "a".encode(Encoding::ASCII)
- assert_equal("a", Reline.completion_append_character)
- assert_equal(get_reline_encoding, Reline.completion_append_character.encoding)
-
- Reline.completion_append_character = "ba".encode(Encoding::ASCII)
- assert_equal("b", Reline.completion_append_character)
- assert_equal(get_reline_encoding, Reline.completion_append_character.encoding)
-
- Reline.completion_append_character = "cba".encode(Encoding::ASCII)
- assert_equal("c", Reline.completion_append_character)
- assert_equal(get_reline_encoding, Reline.completion_append_character.encoding)
-
- Reline.completion_append_character = nil
- assert_equal(nil, Reline.completion_append_character)
- ensure
- Reline.completion_append_character = completion_append_character
- end
-
- def test_basic_word_break_characters
- basic_word_break_characters = Reline.basic_word_break_characters
-
- assert_equal(" \t\n`><=;|&{(", Reline.basic_word_break_characters)
-
- Reline.basic_word_break_characters = "[".encode(Encoding::ASCII)
- assert_equal("[", Reline.basic_word_break_characters)
- assert_equal(get_reline_encoding, Reline.basic_word_break_characters.encoding)
- ensure
- Reline.basic_word_break_characters = basic_word_break_characters
- end
-
- def test_completer_word_break_characters
- completer_word_break_characters = Reline.completer_word_break_characters
-
- assert_equal(" \t\n`><=;|&{(", Reline.completer_word_break_characters)
-
- Reline.completer_word_break_characters = "[".encode(Encoding::ASCII)
- assert_equal("[", Reline.completer_word_break_characters)
- assert_equal(get_reline_encoding, Reline.completer_word_break_characters.encoding)
- ensure
- Reline.completer_word_break_characters = completer_word_break_characters
- end
-
- def test_basic_quote_characters
- basic_quote_characters = Reline.basic_quote_characters
-
- assert_equal('"\'', Reline.basic_quote_characters)
-
- Reline.basic_quote_characters = "`".encode(Encoding::ASCII)
- assert_equal("`", Reline.basic_quote_characters)
- assert_equal(get_reline_encoding, Reline.basic_quote_characters.encoding)
- ensure
- Reline.basic_quote_characters = basic_quote_characters
- end
-
- def test_completer_quote_characters
- completer_quote_characters = Reline.completer_quote_characters
-
- assert_equal('"\'', Reline.completer_quote_characters)
-
- Reline.completer_quote_characters = "`".encode(Encoding::ASCII)
- assert_equal("`", Reline.completer_quote_characters)
- assert_equal(get_reline_encoding, Reline.completer_quote_characters.encoding)
- ensure
- Reline.completer_quote_characters = completer_quote_characters
- end
-
- def test_filename_quote_characters
- filename_quote_characters = Reline.filename_quote_characters
-
- assert_equal('', Reline.filename_quote_characters)
-
- Reline.filename_quote_characters = "\'".encode(Encoding::ASCII)
- assert_equal("\'", Reline.filename_quote_characters)
- assert_equal(get_reline_encoding, Reline.filename_quote_characters.encoding)
- ensure
- Reline.filename_quote_characters = filename_quote_characters
- end
-
- def test_special_prefixes
- special_prefixes = Reline.special_prefixes
-
- assert_equal('', Reline.special_prefixes)
-
- Reline.special_prefixes = "\'".encode(Encoding::ASCII)
- assert_equal("\'", Reline.special_prefixes)
- assert_equal(get_reline_encoding, Reline.special_prefixes.encoding)
- ensure
- Reline.special_prefixes = special_prefixes
- end
-
- def test_completion_case_fold
- completion_case_fold = Reline.completion_case_fold
-
- assert_equal(nil, Reline.completion_case_fold)
-
- Reline.completion_case_fold = true
- assert_equal(true, Reline.completion_case_fold)
-
- Reline.completion_case_fold = "hoge".encode(Encoding::ASCII)
- assert_equal("hoge", Reline.completion_case_fold)
- ensure
- Reline.completion_case_fold = completion_case_fold
- end
-
- def test_completion_proc
- skip unless Reline.completion_proc == nil
- # Another test can set Reline.completion_proc
-
- # assert_equal(nil, Reline.completion_proc)
-
- p = proc {}
- Reline.completion_proc = p
- assert_equal(p, Reline.completion_proc)
-
- l = lambda {}
- Reline.completion_proc = l
- assert_equal(l, Reline.completion_proc)
-
- assert_raise(ArgumentError) { Reline.completion_proc = 42 }
- assert_raise(ArgumentError) { Reline.completion_proc = "hoge" }
-
- dummy = DummyCallbackObject.new
- Reline.completion_proc = dummy
- assert_equal(dummy, Reline.completion_proc)
- end
-
- def test_output_modifier_proc
- assert_equal(nil, Reline.output_modifier_proc)
-
- p = proc {}
- Reline.output_modifier_proc = p
- assert_equal(p, Reline.output_modifier_proc)
-
- l = lambda {}
- Reline.output_modifier_proc = l
- assert_equal(l, Reline.output_modifier_proc)
-
- assert_raise(ArgumentError) { Reline.output_modifier_proc = 42 }
- assert_raise(ArgumentError) { Reline.output_modifier_proc = "hoge" }
-
- dummy = DummyCallbackObject.new
- Reline.output_modifier_proc = dummy
- assert_equal(dummy, Reline.output_modifier_proc)
- end
-
- def test_prompt_proc
- assert_equal(nil, Reline.prompt_proc)
-
- p = proc {}
- Reline.prompt_proc = p
- assert_equal(p, Reline.prompt_proc)
-
- l = lambda {}
- Reline.prompt_proc = l
- assert_equal(l, Reline.prompt_proc)
-
- assert_raise(ArgumentError) { Reline.prompt_proc = 42 }
- assert_raise(ArgumentError) { Reline.prompt_proc = "hoge" }
-
- dummy = DummyCallbackObject.new
- Reline.prompt_proc = dummy
- assert_equal(dummy, Reline.prompt_proc)
- end
-
- def test_auto_indent_proc
- assert_equal(nil, Reline.auto_indent_proc)
-
- p = proc {}
- Reline.auto_indent_proc = p
- assert_equal(p, Reline.auto_indent_proc)
-
- l = lambda {}
- Reline.auto_indent_proc = l
- assert_equal(l, Reline.auto_indent_proc)
-
- assert_raise(ArgumentError) { Reline.auto_indent_proc = 42 }
- assert_raise(ArgumentError) { Reline.auto_indent_proc = "hoge" }
-
- dummy = DummyCallbackObject.new
- Reline.auto_indent_proc = dummy
- assert_equal(dummy, Reline.auto_indent_proc)
- end
-
- def test_pre_input_hook
- assert_equal(nil, Reline.pre_input_hook)
-
- p = proc {}
- Reline.pre_input_hook = p
- assert_equal(p, Reline.pre_input_hook)
-
- l = lambda {}
- Reline.pre_input_hook = l
- assert_equal(l, Reline.pre_input_hook)
- end
-
- def test_dig_perfect_match_proc
- assert_equal(nil, Reline.dig_perfect_match_proc)
-
- p = proc {}
- Reline.dig_perfect_match_proc = p
- assert_equal(p, Reline.dig_perfect_match_proc)
-
- l = lambda {}
- Reline.dig_perfect_match_proc = l
- assert_equal(l, Reline.dig_perfect_match_proc)
-
- assert_raise(ArgumentError) { Reline.dig_perfect_match_proc = 42 }
- assert_raise(ArgumentError) { Reline.dig_perfect_match_proc = "hoge" }
-
- dummy = DummyCallbackObject.new
- Reline.dig_perfect_match_proc = dummy
- assert_equal(dummy, Reline.dig_perfect_match_proc)
- end
-
- def test_insert_text
- # TODO
- end
-
- def test_line_buffer
- # TODO
- end
-
- def test_point
- # TODO
- end
-
- def test_input=
- # TODO
- assert_raise(TypeError) do
- Reline.input = "This is not a file."
- end
- end
-
- def test_output=
- # TODO
- assert_raise(TypeError) do
- Reline.output = "This is not a file."
- end
- end
-
- def test_vi_editing_mode
- Reline.vi_editing_mode
- assert_equal(Reline::KeyActor::ViInsert, Reline.send(:core).config.editing_mode.class)
- end
-
- def test_emacs_editing_mode
- Reline.emacs_editing_mode
- assert_equal(Reline::KeyActor::Emacs, Reline.send(:core).config.editing_mode.class)
- end
-
- def test_editing_mode
- # TODO
- end
-
- def test_readmultiline
- # readmultiline is module function
- assert_include(Reline.methods, :readmultiline)
- assert_include(Reline.private_instance_methods, :readmultiline)
- end
-
- def test_readline
- # readline is module function
- assert_include(Reline.methods, :readline)
- assert_include(Reline.private_instance_methods, :readline)
- end
-
- def test_inner_readline
- # TODO in Reline::Core
- end
-
- def test_read_io
- # TODO in Reline::Core
- end
-
- def test_read_escaped_key
- # TODO in Reline::Core
- end
-
- def test_may_req_ambiguous_char_width
- # TODO in Reline::Core
- end
-
- def get_reline_encoding
- RUBY_PLATFORM =~ /mswin|mingw/ ? Encoding::UTF_8 : Encoding::default_external
- end
-end
diff --git a/test/reline/test_string_processing.rb b/test/reline/test_string_processing.rb
deleted file mode 100644
index e76fa384f2..0000000000
--- a/test/reline/test_string_processing.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative 'helper'
-
-class Reline::LineEditor::StringProcessingTest < Reline::TestCase
- def setup
- Reline.send(:test_mode)
- @prompt = '> '
- @config = Reline::Config.new
- Reline::HISTORY.instance_variable_set(:@config, @config)
- @encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
- @line_editor = Reline::LineEditor.new(@config, @encoding)
- @line_editor.reset(@prompt, encoding: @encoding)
- end
-
- def test_calculate_width
- width = @line_editor.send(:calculate_width, 'Ruby string')
- assert_equal('Ruby string'.size, width)
- end
-
- def test_calculate_width_with_escape_sequence
- width = @line_editor.send(:calculate_width, "\1\e[31m\2RubyColor\1\e[34m\2 default string \1\e[m\2>", true)
- assert_equal('RubyColor default string >'.size, width)
- end
-end
diff --git a/test/reline/test_within_pipe.rb b/test/reline/test_within_pipe.rb
deleted file mode 100644
index 53989a794f..0000000000
--- a/test/reline/test_within_pipe.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require_relative 'helper'
-
-class Reline::WithinPipeTest < Reline::TestCase
- def setup
- Reline.send(:test_mode)
- @input_reader, @writer = IO.pipe((RELINE_TEST_ENCODING rescue Encoding.default_external))
- Reline.input = @input_reader
- @reader, @output_writer = IO.pipe((RELINE_TEST_ENCODING rescue Encoding.default_external))
- @output = Reline.output = @output_writer
- @config = Reline.send(:core).config
- @line_editor = Reline.send(:core).line_editor
- end
-
- def teardown
- Reline.input = STDIN
- Reline.output = STDOUT
- Reline.point = 0
- Reline.delete_text
- @input_reader.close
- @writer.close
- @reader.close
- @output_writer.close
- @config.reset
- end
-
- def test_simple_input
- @writer.write("abc\n")
- assert_equal 'abc', Reline.readmultiline(&proc{ true })
- end
-
- def test_unknown_macro
- @config.add_default_key_binding('abc'.bytes, :unknown_macro)
- @writer.write("abcd\n")
- assert_equal 'd', Reline.readmultiline(&proc{ true })
- end
-
- def test_macro_commands_for_moving
- @config.add_default_key_binding("\C-x\C-a".bytes, :beginning_of_line)
- @config.add_default_key_binding("\C-x\C-e".bytes, :end_of_line)
- @config.add_default_key_binding("\C-x\C-f".bytes, :forward_char)
- @config.add_default_key_binding("\C-x\C-b".bytes, :backward_char)
- @config.add_default_key_binding("\C-x\M-f".bytes, :forward_word)
- @config.add_default_key_binding("\C-x\M-b".bytes, :backward_word)
- @writer.write(" def\C-x\C-aabc\C-x\C-e ghi\C-x\C-a\C-x\C-f\C-x\C-f_\C-x\C-b\C-x\C-b_\C-x\C-f\C-x\C-f\C-x\C-f\C-x\M-f_\C-x\M-b\n")
- assert_equal 'a_b_c def_ ghi', Reline.readmultiline(&proc{ true })
- end
-
- def test_macro_commands_for_editing
- @config.add_default_key_binding("\C-x\C-d".bytes, :delete_char)
- @config.add_default_key_binding("\C-x\C-h".bytes, :backward_delete_char)
- @config.add_default_key_binding("\C-x\C-v".bytes, :quoted_insert)
- #@config.add_default_key_binding("\C-xa".bytes, :self_insert)
- @config.add_default_key_binding("\C-x\C-t".bytes, :transpose_chars)
- @config.add_default_key_binding("\C-x\M-t".bytes, :transpose_words)
- @config.add_default_key_binding("\C-x\M-u".bytes, :upcase_word)
- @config.add_default_key_binding("\C-x\M-l".bytes, :downcase_word)
- @config.add_default_key_binding("\C-x\M-c".bytes, :capitalize_word)
- @writer.write("abcde\C-b\C-b\C-b\C-x\C-d\C-x\C-h\C-x\C-v\C-a\C-f\C-f EF\C-x\C-t gh\C-x\M-t\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-x\M-u\C-x\M-l\C-x\M-c\n")
- assert_equal "a\C-aDE gh Fe", Reline.readmultiline(&proc{ true })
- end
-end
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
deleted file mode 100644
index 0ab43fa60c..0000000000
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ /dev/null
@@ -1,224 +0,0 @@
-require 'reline'
-
-begin
- require 'yamatanooroti'
-
- class Reline::TestRendering < Yamatanooroti::TestCase
- def setup
- @pwd = Dir.pwd
- @tmpdir = File.join(File.expand_path(Dir.tmpdir), "test_reline_config_#{$$}")
- begin
- Dir.mkdir(@tmpdir)
- rescue Errno::EEXIST
- FileUtils.rm_rf(@tmpdir)
- Dir.mkdir(@tmpdir)
- end
- Dir.chdir(@tmpdir)
- @inputrc_backup = ENV['INPUTRC']
- @inputrc_file = ENV['INPUTRC'] = File.join(@tmpdir, 'temporaty_inputrc')
- File.unlink(@inputrc_file) if File.exist?(@inputrc_file)
- end
-
- def teardown
- Dir.chdir(@pwd)
- FileUtils.rm_rf(@tmpdir)
- ENV['INPUTRC'] = @inputrc_backup
- end
-
- def test_history_back
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write(":a\n")
- write("\C-p")
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- prompt> :a
- => :a
- prompt> :a
- EOC
- end
-
- def test_backspace
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write(":abc\C-h\n")
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- prompt> :ab
- => :ab
- prompt>
- EOC
- end
-
- def test_autowrap
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write('01234567890123456789012')
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- prompt> 0123456789012345678901
- 2
- EOC
- end
-
- def test_finish_autowrapped_line
- start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write("[{'user'=>{'email'=>'a@a', 'id'=>'ABC'}, 'version'=>4, 'status'=>'succeeded'}]\n")
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- prompt> [{'user'=>{'email'=>'a@a', 'id'=
- >'ABC'}, 'version'=>4, 'status'=>'succee
- ded'}]
- => [{"user"=>{"email"=>"a@a", "id"=>"ABC
- "}, "version"=>4, "status"=>"succeeded"}
- ]
- prompt>
- EOC
- end
-
- def test_finish_autowrapped_line_in_the_middle_of_lines
- start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write("[{'user'=>{'email'=>'abcdef@abcdef', 'id'=>'ABC'}, 'version'=>4, 'status'=>'succeeded'}]#{"\C-b"*7}\n")
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- prompt> [{'user'=>{'email'=>'a
- bcdef@abcdef', 'id'=>'ABC'}, '
- version'=>4, 'status'=>'succee
- ded'}]
- => [{"user"=>{"email"=>"abcdef
- @abcdef", "id"=>"ABC"}, "versi
- on"=>4, "status"=>"succeeded"}
- ]
- prompt>
- EOC
- end
-
- def test_finish_autowrapped_line_in_the_middle_of_multilines
- start_terminal(30, 16, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write("<<~EOM\n ABCDEFG\nEOM\n")
- close
- assert_screen(<<~'EOC')
- Multiline REPL.
- prompt> <<~EOM
- prompt> ABCDEF
- G
- prompt> EOM
- => "ABCDEFG\n"
- prompt>
- EOC
- end
-
- def test_prompt
- File.open(@inputrc_file, 'w') do |f|
- f.write <<~'LINES'
- "abc": "123"
- LINES
- end
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write("abc\n")
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- prompt> 123
- => 123
- prompt>
- EOC
- end
-
- def test_mode_icon_emacs
- File.open(@inputrc_file, 'w') do |f|
- f.write <<~LINES
- set show-mode-in-prompt on
- LINES
- end
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- @prompt>
- EOC
- end
-
- def test_mode_icon_vi
- File.open(@inputrc_file, 'w') do |f|
- f.write <<~LINES
- set editing-mode vi
- set show-mode-in-prompt on
- LINES
- end
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- sleep 0.5
- write(":a\n\C-[k")
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- (ins)prompt> :a
- => :a
- (cmd)prompt> :a
- EOC
- end
-
- def test_original_mode_icon_emacs
- File.open(@inputrc_file, 'w') do |f|
- f.write <<~LINES
- set show-mode-in-prompt on
- set emacs-mode-string [emacs]
- LINES
- end
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- [emacs]prompt>
- EOC
- end
-
- def test_original_mode_icon_with_quote
- File.open(@inputrc_file, 'w') do |f|
- f.write <<~LINES
- set show-mode-in-prompt on
- set emacs-mode-string "[emacs]"
- LINES
- end
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- [emacs]prompt>
- EOC
- end
-
- def test_original_mode_icon_vi
- File.open(@inputrc_file, 'w') do |f|
- f.write <<~LINES
- set editing-mode vi
- set show-mode-in-prompt on
- set vi-ins-mode-string "{InS}"
- set vi-cmd-mode-string "{CmD}"
- LINES
- end
- start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
- write(":a\n\C-[k")
- close
- assert_screen(<<~EOC)
- Multiline REPL.
- {InS}prompt> :a
- => :a
- {CmD}prompt> :a
- EOC
- end
- end
-rescue LoadError, NameError
- # On Ruby repository, this test suit doesn't run because Ruby repo doesn't
- # have the yamatanooroti gem.
-end
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
index 617babf829..1ac3aea7b8 100644
--- a/test/resolv/test_dns.rb
+++ b/test/resolv/test_dns.rb
@@ -128,119 +128,6 @@ class TestResolvDNS < Test::Unit::TestCase
}
end
- def test_query_ipv4_duplicate_responses
- begin
- OpenSSL
- rescue LoadError
- skip 'autoload problem. see [ruby-dev:45021][Bug #5786]'
- end if defined?(OpenSSL)
-
- with_udp('127.0.0.1', 0) {|u|
- _, server_port, _, server_address = u.addr
- begin
- client_thread = Thread.new {
- Resolv::DNS.open(:nameserver_port => [[server_address, server_port]], :search => ['bad1.com', 'bad2.com', 'good.com'], ndots: 5) {|dns|
- dns.getaddress("example")
- }
- }
- server_thread = Thread.new {
- 3.times do
- msg, (_, client_port, _, client_address) = Timeout.timeout(5) {u.recvfrom(4096)}
- id, flags, qdcount, ancount, nscount, arcount = msg.unpack("nnnnnn")
-
- qr = (flags & 0x8000) >> 15
- opcode = (flags & 0x7800) >> 11
- aa = (flags & 0x0400) >> 10
- tc = (flags & 0x0200) >> 9
- rd = (flags & 0x0100) >> 8
- ra = (flags & 0x0080) >> 7
- z = (flags & 0x0070) >> 4
- rcode = flags & 0x000f
- rest = msg[12..-1]
-
- questions = msg.bytes[12..-1]
- labels = []
- idx = 0
- while idx < questions.length-5
- size = questions[idx]
- labels << questions[idx+1..idx+size].pack('c*')
- idx += size+1
- end
- hostname = labels.join('.')
-
- if hostname == "example.good.com"
- id = id
- qr = 1
- opcode = opcode
- aa = 0
- tc = 0
- rd = rd
- ra = 1
- z = 0
- rcode = 0
- qdcount = 1
- ancount = 1
- nscount = 0
- arcount = 0
- word2 = (qr << 15) |
- (opcode << 11) |
- (aa << 10) |
- (tc << 9) |
- (rd << 8) |
- (ra << 7) |
- (z << 4) |
- rcode
- msg = [id, word2, qdcount, ancount, nscount, arcount].pack("nnnnnn")
- msg << questions.pack('c*')
- type = 1
- klass = 1
- ttl = 3600
- rdlength = 4
- rdata = [52,0,2,1].pack("CCCC")
- rr = [0xc00c, type, klass, ttl, rdlength, rdata].pack("nnnNna*")
- msg << rr
- rdata = [52,0,2,2].pack("CCCC")
- rr = [0xc00c, type, klass, ttl, rdlength, rdata].pack("nnnNna*")
- msg << rr
-
- u.send(msg, 0, client_address, client_port)
- else
- id = id
- qr = 1
- opcode = opcode
- aa = 0
- tc = 0
- rd = rd
- ra = 1
- z = 0
- rcode = 3
- qdcount = 1
- ancount = 0
- nscount = 0
- arcount = 0
- word2 = (qr << 15) |
- (opcode << 11) |
- (aa << 10) |
- (tc << 9) |
- (rd << 8) |
- (ra << 7) |
- (z << 4) |
- rcode
- msg = [id, word2, qdcount, ancount, nscount, arcount].pack("nnnnnn")
- msg << questions.pack('c*')
-
- u.send(msg, 0, client_address, client_port)
- u.send(msg, 0, client_address, client_port)
- end
- end
- }
- result, _ = assert_join_threads([client_thread, server_thread])
- assert_instance_of(Resolv::IPv4, result)
- assert_equal("52.0.2.1", result.to_s)
- end
- }
- end
-
def test_query_ipv4_address_timeout
with_udp('127.0.0.1', 0) {|u|
_, port , _, host = u.addr
@@ -272,22 +159,13 @@ class TestResolvDNS < Test::Unit::TestCase
u.bind("127.0.0.1", 0)
_, port, _, host = u.addr
u.close
- # A race condition here.
+ # A rase condition here.
# Another program may use the port.
# But no way to prevent it.
- begin
- Timeout.timeout(5) do
- Resolv::DNS.open(:nameserver_port => [[host, port]]) {|dns|
- assert_equal([], dns.getresources("test-no-server.example.org", Resolv::DNS::Resource::IN::A))
- }
- end
- rescue Timeout::Error
- if RUBY_PLATFORM.match?(/mingw/)
- # cannot repo locally
- skip 'Timeout Error on MinGW CI'
- else
- raise Timeout::Error
- end
+ Timeout.timeout(5) do
+ Resolv::DNS.open(:nameserver_port => [[host, port]]) {|dns|
+ assert_equal([], dns.getresources("test-no-server.example.org", Resolv::DNS::Resource::IN::A))
+ }
end
end
@@ -334,24 +212,8 @@ class TestResolvDNS < Test::Unit::TestCase
def test_ipv6_create
ref = '[Bug #11910] [ruby-core:72559]'
- assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1'), ref
- assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1:127.0.0.1'), ref
- end
-
- def test_ipv6_to_s
- test_cases = [
- ["2001::abcd:abcd:abcd", "2001::ABcd:abcd:ABCD"],
- ["2001:db8::1", "2001:db8::0:1"],
- ["::", "0:0:0:0:0:0:0:0"],
- ["2001::", "2001::0"],
- ["2001:db8::1:1:1:1:1", "2001:db8:0:1:1:1:1:1"],
- ["1::1:0:0:0:1", "1:0:0:1:0:0:0:1"],
- ["1::1:0:0:1", "1:0:0:0:1:0:0:1"],
- ]
-
- test_cases.each do |expected, ipv6|
- assert_equal expected, Resolv::IPv6.create(ipv6).to_s
- end
+ assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1')
+ assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1:127.0.0.1')
end
def test_ipv6_should_be_16
@@ -403,28 +265,4 @@ class TestResolvDNS < Test::Unit::TestCase
def test_no_fd_leak_unconnected
assert_no_fd_leak {Resolv::DNS.new}
end
-
- def test_each_name
- dns = Resolv::DNS.new
- def dns.each_resource(name, typeclass)
- yield typeclass.new(name)
- end
-
- dns.each_name('127.0.0.1') do |ptr|
- assert_equal('1.0.0.127.in-addr.arpa', ptr.to_s)
- end
- dns.each_name(Resolv::IPv4.create('127.0.0.1')) do |ptr|
- assert_equal('1.0.0.127.in-addr.arpa', ptr.to_s)
- end
- dns.each_name('::1') do |ptr|
- assert_equal('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa', ptr.to_s)
- end
- dns.each_name(Resolv::IPv6.create('::1')) do |ptr|
- assert_equal('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa', ptr.to_s)
- end
- dns.each_name(Resolv::DNS::Name.create('1.0.0.127.in-addr.arpa.')) do |ptr|
- assert_equal('1.0.0.127.in-addr.arpa', ptr.to_s)
- end
- assert_raise(Resolv::ResolvError) { dns.each_name('example.com') }
- end
end
diff --git a/test/resolv/test_mdns.rb b/test/resolv/test_mdns.rb
index ff66276f9a..8e401883f1 100644
--- a/test/resolv/test_mdns.rb
+++ b/test/resolv/test_mdns.rb
@@ -3,25 +3,20 @@ require 'test/unit'
require 'resolv'
class TestResolvMDNS < Test::Unit::TestCase
+ def setup
+ end
+
def test_mdns_each_address
- mdns = Resolv::MDNS.new
- def mdns.each_resource(name, typeclass)
- if typeclass == Resolv::DNS::Resource::IN::A
- yield typeclass.new("127.0.0.1")
- else
- yield typeclass.new("::1")
- end
- end
- addrs = mdns.__send__(:use_ipv6?) ? ["127.0.0.1", "::1"] : ["127.0.0.1"]
- [
- ["example.com", []],
- ["foo.local", addrs],
- ].each do |name, expect|
- results = []
- mdns.each_address(name) do |result|
- results << result.to_s
+ begin
+ mdns = Resolv::MDNS.new
+ mdns.each_resource '_http._tcp.local', Resolv::DNS::Resource::IN::PTR do |r|
+ srv = mdns.getresource r.name, Resolv::DNS::Resource::IN::SRV
+ mdns.each_address(srv.target) do |result|
+ assert_not_nil(result)
+ end
end
- assert_equal expect, results.sort, "GH-1484"
+ rescue Errno::EADDRNOTAVAIL
+ # Handle Raspberry Pi environment.
end
end
end
diff --git a/test/rexml/data/t75.xml b/test/rexml/data/t75.xml
index eb3cccee4b..0911fb1b1a 100644
--- a/test/rexml/data/t75.xml
+++ b/test/rexml/data/t75.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="ISO-8859-1"?><?pos="3"?>
<!-- generated by hnb 1.9.17 (http://hnb.sourceforge.net) -->
<!DOCTYPE tree[
diff --git a/test/rexml/formatter/test_default.rb b/test/rexml/formatter/test_default.rb
deleted file mode 100644
index b5b131724b..0000000000
--- a/test/rexml/formatter/test_default.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative "../rexml_test_utils"
-
-module REXMLTests
- class DefaultFormatterTest < Test::Unit::TestCase
- def format(node)
- formatter = REXML::Formatters::Default.new
- output = ""
- formatter.write(node, output)
- output
- end
-
- class InstructionTest < self
- def test_content_nil
- instruction = REXML::Instruction.new("target")
- assert_equal("<?target?>", format(instruction))
- end
- end
- end
-end
diff --git a/test/rexml/functions/test_base.rb b/test/rexml/functions/test_base.rb
deleted file mode 100644
index 74dc1a31de..0000000000
--- a/test/rexml/functions/test_base.rb
+++ /dev/null
@@ -1,261 +0,0 @@
-# frozen_string_literal: false
-require "test/unit/testcase"
-
-require "rexml/document"
-
-# TODO: Split me
-module REXMLTests
- class FunctionsTester < Test::Unit::TestCase
- include REXML
-
- def setup
- super
- REXML::Functions.context = nil
- end
-
- def test_functions
- # trivial text() test
- # confuse-a-function
- source = "<a>more <b id='1'/><b id='2'>dumb</b><b id='3'/><c/> text</a>"
- doc = Document.new source
- res = ""
- XPath::each(doc.root, "text()") {|val| res << val.to_s}
- assert_equal "more text", res
-
- res = XPath::first(doc.root, "b[last()]")
- assert_equal '3', res.attributes['id']
- res = XPath::first(doc.root, "b[position()=2]")
- assert_equal '2', res.attributes['id']
- res = XPath::first(doc.root, "*[name()='c']")
- assert_equal "c", res.name
- end
-
- # Contributed by Mike Stok
- def test_starts_with
- source = <<-EOF
- <foo>
- <a href="mailto:a@b.c">a@b.c</a>
- <a href="http://www.foo.com">http://www.foo.com</a>
- </foo>
- EOF
- doc = Document.new source
- mailtos = doc.elements.to_a("//a[starts-with(@href, 'mailto:')]")
- assert_equal 1, mailtos.size
- assert_equal "mailto:a@b.c", mailtos[0].attributes['href']
-
- ailtos = doc.elements.to_a("//a[starts-with(@href, 'ailto:')]")
- assert_equal 0, ailtos.size
- end
-
- def test_string_length
- doc = Document.new <<-EOF
- <AAA>
- <Q/>
- <SSSS/>
- <BB/>
- <CCC/>
- <DDDDDDDD/>
- <EEEE/>
- </AAA>
- EOF
- assert doc, "create doc"
-
- set = doc.elements.to_a("//*[string-length(name()) = 3]")
- assert_equal 2, set.size, "nodes with names length = 3"
-
- set = doc.elements.to_a("//*[string-length(name()) < 3]")
- assert_equal 2, set.size, "nodes with names length < 3"
-
- set = doc.elements.to_a("//*[string-length(name()) > 3]")
- assert_equal 3, set.size, "nodes with names length > 3"
- end
-
- # Test provided by Mike Stok
- def test_contains
- source = <<-EOF
- <foo>
- <a href="mailto:a@b.c">a@b.c</a>
- <a href="http://www.foo.com">http://www.foo.com</a>
- </foo>
- EOF
- doc = Document.new source
-
- [['o', 2], ['foo', 1], ['bar', 0]].each { |test|
- search, expected = test
- set = doc.elements.to_a("//a[contains(@href, '#{search}')]")
- assert_equal expected, set.size
- }
- end
-
- # Mike Stok and Sean Russell
- def test_substring
- # examples from http://www.w3.org/TR/xpath#function-substring
- doc = Document.new('<test string="12345" />')
-
- #puts XPath.first(d, 'node()[0 + 1]')
- #d = Document.new("<a b='1'/>")
- #puts XPath.first(d, 'a[0 mod 0]')
- [ [1.5, 2.6, '234'],
- [0, 3, '12'],
- [0, '0 div 0', ''],
- [1, '0 div 0', ''],
- ['-42', '1 div 0', '12345'],
- ['-1 div 0', '1 div 0', '']
- ].each { |start, length, expected|
- set = doc.elements.to_a("//test[substring(@string, #{start}, #{length}) = '#{expected}']")
- assert_equal 1, set.size, "#{start}, #{length}, '#{expected}'"
- }
- end
-
- def test_substring_angrez
- testString = REXML::Functions::substring_after("helloworld","hello")
- assert_equal( 'world', testString )
- end
-
- def test_translate
- source = <<-EOF
- <doc>
- <case name='w3c one' result='BAr' /> <!-- w3c -->
- <case name='w3c two' result='AAA' /> <!-- w3c -->
- <case name='alchemy' result="gold" /> <!-- mike -->
- <case name='vbxml one' result='A Space Odyssey' />
- <case name='vbxml two' result='AbCdEf' />
- </doc>
- EOF
-
- doc = Document.new(source)
-
- [ ['bar', 'abc', 'ABC', 'w3c one'],
- ['--aaa--','abc-','ABC', 'w3c two'],
- ['lead', 'dear language', 'doll groover', 'alchemy'],
- ['A Space Odissei', 'i', 'y', 'vbxml one'],
- ['abcdefg', 'aceg', 'ACE', 'vbxml two'],
- ].each { |arg1, arg2, arg3, name|
- translate = "translate('#{arg1}', '#{arg2}', '#{arg3}')"
- set = doc.elements.to_a("//case[@result = #{translate}]")
- assert_equal 1, set.size, translate
- assert_equal name, set[0].attributes['name']
- }
- end
-
- def test_name
- d = REXML::Document.new("<a xmlns:x='foo'><b/><x:b/></a>")
- assert_equal 1, d.root.elements.to_a('*[name() = "b"]').size
- assert_equal 1, d.elements.to_a('//*[name() = "x:b"]').size
- end
-
- def test_local_name
- d = REXML::Document.new("<a xmlns:x='foo'><b/><x:b/></a>")
- assert_equal 2, d.root.elements.to_a('*[local_name() = "b"]').size
- assert_equal 2, d.elements.to_a('//*[local_name() = "b"]').size
- end
-
- def test_substring2
- doc = Document.new('<test string="12345" />')
- assert_equal(1,doc.elements.to_a("//test[substring(@string,2)='2345']").size)
- end
-
- # Submitted by Kouhei
- def test_floor_ceiling_round
- source = "<a><b id='1'/><b id='2'/><b id='3'/></a>"
- doc = REXML::Document.new(source)
-
- id_1 = doc.elements["/a/b[@id='1']"]
- id_2 = doc.elements["/a/b[@id='2']"]
- id_3 = doc.elements["/a/b[@id='3']"]
-
- good = {
- "floor" => [[], [id_1], [id_2], [id_3]],
- "ceiling" => [[id_1], [id_2], [id_3], []],
- "round" => [[id_1], [id_2], [id_3], []]
- }
- good.each do |key, value|
- (0..3).each do |i|
- xpath = "//b[number(@id) = #{key}(#{i+0.5})]"
- assert_equal(value[i], REXML::XPath.match(doc, xpath))
- end
- end
-
- good["round"] = [[], [id_1], [id_2], [id_3]]
- good.each do |key, value|
- (0..3).each do |i|
- xpath = "//b[number(@id) = #{key}(#{i+0.4})]"
- assert_equal(value[i], REXML::XPath.match(doc, xpath))
- end
- end
- end
-
- # Submitted by Kou
- def test_lang
- d = Document.new(<<-XML)
- <a xml:lang="en">
- <b xml:lang="ja">
- <c xml:lang="fr"/>
- <d/>
- <e xml:lang="ja-JP"/>
- <f xml:lang="en-US"/>
- </b>
- </a>
- XML
-
- assert_equal(1, d.elements.to_a("//*[lang('fr')]").size)
- assert_equal(3, d.elements.to_a("//*[lang('ja')]").size)
- assert_equal(2, d.elements.to_a("//*[lang('en')]").size)
- assert_equal(1, d.elements.to_a("//*[lang('en-us')]").size)
-
- d = Document.new(<<-XML)
- <root>
- <para xml:lang="en"/>
- <div xml:lang="en"><para/></div>
- <para xml:lang="EN"/>
- <para xml:lang="en-us"/>
- </root>
- XML
-
- assert_equal(5, d.elements.to_a("//*[lang('en')]").size)
- end
-
- def test_ticket_60
- document = REXML::Document.new("<a><b>A</b><b>1</b></a>")
- assert_equal( "A", REXML::XPath.first(document, '//b[.="A"]').text )
- assert_equal( "1", REXML::XPath.first(document, '//b[.="1"]').text )
- end
-
- def test_normalize_space
- source = "<a><!--COMMENT A--><b><!-- COMMENT A --></b></a>"
- doc = REXML::Document.new(source)
- predicate = "string(.)=normalize_space('\nCOMMENT \n A \n\n ')"
- m = REXML::XPath.match(doc, "//comment()[#{predicate}]")
- assert_equal( [REXML::Comment.new("COMMENT A")], m )
- end
-
- def test_string_nil_without_context
- doc = REXML::Document.new(<<-XML)
- <?xml version="1.0" encoding="UTF-8"?>
- <root>
- <foo bar="baz"/>
- <foo bar=""/>
- </root>
- XML
-
- assert_equal([doc.root.elements[2]],
- REXML::XPath.match(doc,
- "//foo[@bar=$n]",
- nil,
- {"n" => nil}))
- end
-
- def test_unregistered_method
- doc = Document.new("<root/>")
- assert_nil(XPath::first(doc.root, "to_s()"))
- end
-
- def test_nonexistent_function
- doc = Document.new("<root><nonexistent/></root>")
- # TODO: Maybe, this is not XPath spec behavior.
- # This behavior must be reconsidered.
- assert_equal(doc.root.elements[1],
- XPath::first(doc.root, "nonexistent()"))
- end
- end
-end
diff --git a/test/rexml/functions/test_boolean.rb b/test/rexml/functions/test_boolean.rb
deleted file mode 100644
index b3e2117c10..0000000000
--- a/test/rexml/functions/test_boolean.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# frozen_string_literal: false
-
-require "test/unit"
-require "rexml/document"
-require "rexml/functions"
-
-module REXMLTests
- class TestFunctionsBoolean < Test::Unit::TestCase
- def setup
- REXML::Functions.context = nil
- end
-
- def test_true
- assert_equal(true, REXML::Functions.boolean(true))
- end
-
- def test_false
- assert_equal(false, REXML::Functions.boolean(false))
- end
-
- def test_integer_true
- assert_equal(true, REXML::Functions.boolean(1))
- end
-
- def test_integer_positive_zero
- assert_equal(false, REXML::Functions.boolean(0))
- end
-
- def test_integer_negative_zero
- assert_equal(false, REXML::Functions.boolean(-0))
- end
-
- def test_float_true
- assert_equal(true, REXML::Functions.boolean(1.1))
- end
-
- def test_float_positive_zero
- assert_equal(false, REXML::Functions.boolean(-0.0))
- end
-
- def test_float_negative_zero
- assert_equal(false, REXML::Functions.boolean(-0.0))
- end
-
- def test_float_nan
- assert_equal(false, REXML::Functions.boolean(Float::NAN))
- end
-
- def test_string_true
- assert_equal(true, REXML::Functions.boolean("content"))
- end
-
- def test_string_empty
- assert_equal(false, REXML::Functions.boolean(""))
- end
-
- def test_node_set_true
- root = REXML::Document.new("<root/>").root
- assert_equal(true, REXML::Functions.boolean([root]))
- end
-
- def test_node_set_empty
- assert_equal(false, REXML::Functions.boolean([]))
- end
-
- def test_nil
- assert_equal(false, REXML::Functions.boolean(nil))
- end
-
- def test_context
- REXML::Functions.context = {node: true}
- assert_equal(true, REXML::Functions.boolean())
- end
- end
-end
diff --git a/test/rexml/functions/test_local_name.rb b/test/rexml/functions/test_local_name.rb
deleted file mode 100644
index 97c9e74852..0000000000
--- a/test/rexml/functions/test_local_name.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: false
-
-require "test/unit"
-require "rexml/document"
-require "rexml/functions"
-
-module REXMLTests
- class TestFunctionsLocalName < Test::Unit::TestCase
- def setup
- REXML::Functions.context = nil
- end
-
- def test_one
- document = REXML::Document.new(<<-XML)
-<root xmlns:x="http://example.com/x/">
- <x:child/>
-</root>
- XML
- node_set = document.root.children
- assert_equal("child", REXML::Functions.local_name(node_set))
- end
-
- def test_multiple
- document = REXML::Document.new(<<-XML)
-<root xmlns:x="http://example.com/x/">
- <x:child1/>
- <x:child2/>
-</root>
- XML
- node_set = document.root.children
- assert_equal("child1", REXML::Functions.local_name(node_set))
- end
-
- def test_nonexistent
- assert_equal("", REXML::Functions.local_name([]))
- end
-
- def test_context
- document = REXML::Document.new("<root/>")
- REXML::Functions.context = {node: document.root}
- assert_equal("root", REXML::Functions.local_name())
- end
- end
-end
diff --git a/test/rexml/functions/test_number.rb b/test/rexml/functions/test_number.rb
deleted file mode 100644
index 16e635701c..0000000000
--- a/test/rexml/functions/test_number.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: false
-
-require "test/unit"
-require "rexml/document"
-require "rexml/functions"
-
-module REXMLTests
- class TestFunctionsNumber < Test::Unit::TestCase
- def setup
- REXML::Functions.context = nil
- end
-
- def test_true
- assert_equal(1, REXML::Functions.number(true))
- end
-
- def test_false
- assert_equal(0, REXML::Functions.number(false))
- end
-
- def test_numeric
- assert_equal(29, REXML::Functions.number(29))
- end
-
- def test_string_integer
- assert_equal(100, REXML::Functions.number("100"))
- end
-
- def test_string_float
- assert_equal(-9.13, REXML::Functions.number("-9.13"))
- end
-
- def test_node_set
- root = REXML::Document.new("<root>100</root>").root
- assert_equal(100, REXML::Functions.number([root]))
- end
- end
-end
diff --git a/test/rexml/parse/test_document_type_declaration.rb b/test/rexml/parse/test_document_type_declaration.rb
index 55713909e7..80f70888fb 100644
--- a/test/rexml/parse/test_document_type_declaration.rb
+++ b/test/rexml/parse/test_document_type_declaration.rb
@@ -5,187 +5,17 @@ require "rexml/document"
module REXMLTests
class TestParseDocumentTypeDeclaration < Test::Unit::TestCase
private
- def parse(doctype)
- REXML::Document.new(<<-XML).doctype
-#{doctype}
+ def xml(internal_subset)
+ <<-XML
+<!DOCTYPE r SYSTEM "urn:x-rexml:test" [
+#{internal_subset}
+]>
<r/>
XML
end
- class TestName < self
- def test_valid
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r>
- DOCTYPE
- assert_equal("r", doctype.name)
- end
-
- def test_garbage_plus_before_name_at_line_start
- exception = assert_raise(REXML::ParseException) do
- parse(<<-DOCTYPE)
-<!DOCTYPE +
-r SYSTEM "urn:x-rexml:test" [
-]>
- DOCTYPE
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed DOCTYPE: invalid name
-Line: 5
-Position: 51
-Last 80 unconsumed characters:
-+ r SYSTEM "urn:x-rexml:test" [ ]> <r/>
- DETAIL
- end
- end
-
- class TestExternalID < self
- class TestSystem < self
- def test_left_bracket_in_system_literal
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r SYSTEM "urn:x-rexml:[test" [
-]>
- DOCTYPE
- assert_equal([
- "r",
- "SYSTEM",
- nil,
- "urn:x-rexml:[test",
- ],
- [
- doctype.name,
- doctype.external_id,
- doctype.public,
- doctype.system,
- ])
- end
-
- def test_greater_than_in_system_literal
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r SYSTEM "urn:x-rexml:>test" [
-]>
- DOCTYPE
- assert_equal([
- "r",
- "SYSTEM",
- nil,
- "urn:x-rexml:>test",
- ],
- [
- doctype.name,
- doctype.external_id,
- doctype.public,
- doctype.system,
- ])
- end
-
- def test_no_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-DOCTYPE)
-<!DOCTYPE r SYSTEM>
- DOCTYPE
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed DOCTYPE: system literal is missing
-Line: 3
-Position: 26
-Last 80 unconsumed characters:
- SYSTEM> <r/>
- DETAIL
- end
-
- def test_garbage_after_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-DOCTYPE)
-<!DOCTYPE r SYSTEM 'r.dtd'x'>
- DOCTYPE
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed DOCTYPE: garbage after external ID
-Line: 3
-Position: 36
-Last 80 unconsumed characters:
-x'> <r/>
- DETAIL
- end
-
- def test_single_quote
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r SYSTEM 'r".dtd'>
- DOCTYPE
- assert_equal("r\".dtd", doctype.system)
- end
-
- def test_double_quote
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r SYSTEM "r'.dtd">
- DOCTYPE
- assert_equal("r'.dtd", doctype.system)
- end
- end
-
- class TestPublic < self
- class TestPublicIDLiteral < self
- def test_content_double_quote
- exception = assert_raise(REXML::ParseException) do
- parse(<<-DOCTYPE)
-<!DOCTYPE r PUBLIC 'double quote " is invalid' "r.dtd">
- DOCTYPE
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed DOCTYPE: invalid public ID literal
-Line: 3
-Position: 62
-Last 80 unconsumed characters:
- PUBLIC 'double quote " is invalid' "r.dtd"> <r/>
- DETAIL
- end
-
- def test_single_quote
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r PUBLIC 'public-id-literal' "r.dtd">
- DOCTYPE
- assert_equal("public-id-literal", doctype.public)
- end
-
- def test_double_quote
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r PUBLIC "public'-id-literal" "r.dtd">
- DOCTYPE
- assert_equal("public'-id-literal", doctype.public)
- end
- end
-
- class TestSystemLiteral < self
- def test_garbage_after_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-DOCTYPE)
-<!DOCTYPE r PUBLIC 'public-id-literal' 'system-literal'x'>
- DOCTYPE
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed DOCTYPE: garbage after external ID
-Line: 3
-Position: 65
-Last 80 unconsumed characters:
-x'> <r/>
- DETAIL
- end
-
- def test_single_quote
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r PUBLIC "public-id-literal" 'system"-literal'>
- DOCTYPE
- assert_equal("system\"-literal", doctype.system)
- end
-
- def test_double_quote
- doctype = parse(<<-DOCTYPE)
-<!DOCTYPE r PUBLIC "public-id-literal" "system'-literal">
- DOCTYPE
- assert_equal("system'-literal", doctype.system)
- end
- end
- end
+ def parse(internal_subset)
+ REXML::Document.new(xml(internal_subset)).doctype
end
class TestMixed < self
@@ -215,15 +45,6 @@ x'> <r/>
assert_equal([REXML::NotationDecl, REXML::AttlistDecl],
doctype.children.collect(&:class))
end
-
- private
- def parse(internal_subset)
- super(<<-DOCTYPE)
-<!DOCTYPE r SYSTEM "urn:x-rexml:test" [
-#{internal_subset}
-]>
- DOCTYPE
- end
end
end
end
diff --git a/test/rexml/parse/test_element.rb b/test/rexml/parse/test_element.rb
deleted file mode 100644
index 9f172a28e8..0000000000
--- a/test/rexml/parse/test_element.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require "test/unit"
-require "rexml/document"
-
-module REXMLTests
- class TestParseElement < Test::Unit::TestCase
- def parse(xml)
- REXML::Document.new(xml)
- end
-
- class TestInvalid < self
- def test_top_level_end_tag
- exception = assert_raise(REXML::ParseException) do
- parse("</a>")
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Unexpected top-level end tag (got 'a')
-Line: 1
-Position: 4
-Last 80 unconsumed characters:
-
- DETAIL
- end
-
- def test_no_end_tag
- exception = assert_raise(REXML::ParseException) do
- parse("<a></")
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Missing end tag for 'a'
-Line: 1
-Position: 5
-Last 80 unconsumed characters:
-</
- DETAIL
- end
-
- def test_empty_namespace_attribute_name
- exception = assert_raise(REXML::ParseException) do
- parse("<x :a=\"\"></x>")
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Invalid attribute name: <:a="">
-Line: 1
-Position: 9
-Last 80 unconsumed characters:
-
- DETAIL
- end
-
- def test_garbage_less_than_before_root_element_at_line_start
- exception = assert_raise(REXML::ParseException) do
- parse("<\n<x/>")
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-malformed XML: missing tag start
-Line: 2
-Position: 6
-Last 80 unconsumed characters:
-< <x/>
- DETAIL
- end
-
- def test_garbage_less_than_slash_before_end_tag_at_line_start
- exception = assert_raise(REXML::ParseException) do
- parse("<x></\n</x>")
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Missing end tag for 'x'
-Line: 2
-Position: 10
-Last 80 unconsumed characters:
-</ </x>
- DETAIL
- end
- end
- end
-end
diff --git a/test/rexml/parse/test_notation_declaration.rb b/test/rexml/parse/test_notation_declaration.rb
index 19a0536d0a..0d29f0d81f 100644
--- a/test/rexml/parse/test_notation_declaration.rb
+++ b/test/rexml/parse/test_notation_declaration.rb
@@ -23,100 +23,10 @@ module REXMLTests
doctype = parse("<!NOTATION name PUBLIC 'urn:public-id'>")
assert_equal("name", doctype.notation("name").name)
end
-
- def test_no_name
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: name is missing
-Line: 5
-Position: 72
-Last 80 unconsumed characters:
- <!NOTATION> ]> <r/>
- DETAIL
- end
-
- def test_invalid_name
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION '>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: invalid name
-Line: 5
-Position: 74
-Last 80 unconsumed characters:
-'> ]> <r/>
- DETAIL
- end
-
- def test_no_id_type
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: invalid ID type
-Line: 5
-Position: 77
-Last 80 unconsumed characters:
-> ]> <r/>
- DETAIL
- end
-
- def test_invalid_id_type
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name INVALID>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: invalid ID type
-Line: 5
-Position: 85
-Last 80 unconsumed characters:
- INVALID> ]> <r/>
- DETAIL
- end
end
class TestExternalID < self
class TestSystem < self
- def test_no_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name SYSTEM>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: system literal is missing
-Line: 5
-Position: 84
-Last 80 unconsumed characters:
- SYSTEM> ]> <r/>
- DETAIL
- end
-
- def test_garbage_after_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name SYSTEM 'system-literal'x'>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: garbage before end >
-Line: 5
-Position: 103
-Last 80 unconsumed characters:
-x'> ]> <r/>
- DETAIL
- end
-
def test_single_quote
doctype = parse(<<-INTERNAL_SUBSET)
<!NOTATION name SYSTEM 'system-literal'>
@@ -134,21 +44,6 @@ x'> ]> <r/>
class TestPublic < self
class TestPublicIDLiteral < self
- def test_content_double_quote
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name PUBLIC 'double quote " is invalid' "system-literal">
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: invalid public ID literal
-Line: 5
-Position: 129
-Last 80 unconsumed characters:
- PUBLIC 'double quote " is invalid' "system-literal"> ]> <r/>
- DETAIL
- end
-
def test_single_quote
doctype = parse(<<-INTERNAL_SUBSET)
<!NOTATION name PUBLIC 'public-id-literal' "system-literal">
@@ -165,21 +60,6 @@ Last 80 unconsumed characters:
end
class TestSystemLiteral < self
- def test_garbage_after_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name PUBLIC 'public-id-literal' 'system-literal'x'>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: garbage before end >
-Line: 5
-Position: 123
-Last 80 unconsumed characters:
-x'> ]> <r/>
- DETAIL
- end
-
def test_single_quote
doctype = parse(<<-INTERNAL_SUBSET)
<!NOTATION name PUBLIC "public-id-literal" 'system-literal'>
@@ -216,66 +96,5 @@ x'> ]> <r/>
end
end
end
-
- class TestPublicID < self
- def test_no_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name PUBLIC>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: public ID literal is missing
-Line: 5
-Position: 84
-Last 80 unconsumed characters:
- PUBLIC> ]> <r/>
- DETAIL
- end
-
- def test_literal_content_double_quote
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name PUBLIC 'double quote " is invalid in PubidLiteral'>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: invalid public ID literal
-Line: 5
-Position: 128
-Last 80 unconsumed characters:
- PUBLIC 'double quote \" is invalid in PubidLiteral'> ]> <r/>
- DETAIL
- end
-
- def test_garbage_after_literal
- exception = assert_raise(REXML::ParseException) do
- parse(<<-INTERNAL_SUBSET)
-<!NOTATION name PUBLIC 'public-id-literal'x'>
- INTERNAL_SUBSET
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Malformed notation declaration: garbage before end >
-Line: 5
-Position: 106
-Last 80 unconsumed characters:
-x'> ]> <r/>
- DETAIL
- end
-
- def test_literal_single_quote
- doctype = parse(<<-INTERNAL_SUBSET)
-<!NOTATION name PUBLIC 'public-id-literal'>
- INTERNAL_SUBSET
- assert_equal("public-id-literal", doctype.notation("name").public)
- end
-
- def test_literal_double_quote
- doctype = parse(<<-INTERNAL_SUBSET)
-<!NOTATION name PUBLIC "public-id-literal">
- INTERNAL_SUBSET
- assert_equal("public-id-literal", doctype.notation("name").public)
- end
- end
end
end
diff --git a/test/rexml/parse/test_processing_instruction.rb b/test/rexml/parse/test_processing_instruction.rb
deleted file mode 100644
index f0c0c24e67..0000000000
--- a/test/rexml/parse/test_processing_instruction.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require "test/unit"
-require "rexml/document"
-
-module REXMLTests
- class TestParseProcessinInstruction < Test::Unit::TestCase
- def parse(xml)
- REXML::Document.new(xml)
- end
-
- class TestInvalid < self
- def test_no_name
- exception = assert_raise(REXML::ParseException) do
- parse("<??>")
- end
- assert_equal(<<-DETAIL.chomp, exception.to_s)
-Invalid processing instruction node
-Line: 1
-Position: 4
-Last 80 unconsumed characters:
-<??>
- DETAIL
- end
-
- def test_garbage_text
- # TODO: This should be parse error.
- # Create test/parse/test_document.rb or something and move this to it.
- doc = parse(<<-XML)
-x<?x y
-<!--?><?x -->?>
-<r/>
- XML
- pi = doc.children[1]
- assert_equal([
- "x",
- "y\n<!--",
- ],
- [
- pi.target,
- pi.content,
- ])
- end
- end
- end
-end
diff --git a/test/rexml/parser/test_tree.rb b/test/rexml/parser/test_tree.rb
index 8a5d9d1223..7ab0addca1 100644
--- a/test/rexml/parser/test_tree.rb
+++ b/test/rexml/parser/test_tree.rb
@@ -12,7 +12,7 @@ class TestTreeParser < Test::Unit::TestCase
parse(xml)
end
assert_equal(<<-MESSAGE, exception.to_s)
-Missing end tag for 'root' (got 'not-root')
+Missing end tag for 'root' (got "not-root")
Line: 1
Position: #{xml.bytesize}
Last 80 unconsumed characters:
diff --git a/test/rexml/parser/test_ultra_light.rb b/test/rexml/parser/test_ultra_light.rb
index 44fd1d1ec0..c48a13d311 100644
--- a/test/rexml/parser/test_ultra_light.rb
+++ b/test/rexml/parser/test_ultra_light.rb
@@ -16,6 +16,7 @@ class TestUltraLightParser < Test::Unit::TestCase
nil,
[:entitydecl, "name", "value"]
],
+ [:text, "\n"],
[:start_element, :parent, "root", {}],
[:text, "\n"],
],
@@ -54,7 +55,7 @@ class TestUltraLightParser < Test::Unit::TestCase
normalized_doctype[1] = normalized_parent
normalized_doctype
when :start_element
- tag, _parent, name, attributes, *children = child
+ tag, parent, name, attributes, *children = child
normalized_parent = :parent
normalized_children = children.collect do |sub_child|
normalize_child(sub_child)
diff --git a/test/rexml/rexml_test_utils.rb b/test/rexml/rexml_test_utils.rb
index 8bb002cee2..7c59629e53 100644
--- a/test/rexml/rexml_test_utils.rb
+++ b/test/rexml/rexml_test_utils.rb
@@ -1,8 +1,5 @@
# frozen_string_literal: false
-
-require "test/unit"
-require "rexml/document"
-
+require 'test/unit'
module REXMLTestUtils
def fixture_path(*components)
File.join(File.dirname(__FILE__), "data", *components)
diff --git a/test/rexml/test_attribute.rb b/test/rexml/test_attribute.rb
deleted file mode 100644
index 5175bd4454..0000000000
--- a/test/rexml/test_attribute.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative "rexml_test_utils"
-
-module REXMLTests
- class AttributeTest < Test::Unit::TestCase
- def test_empty_prefix
- error = assert_raise(ArgumentError) do
- REXML::Attribute.new(":x")
- end
- assert_equal("name must be " +
- "\#{PREFIX}:\#{LOCAL_NAME} or \#{LOCAL_NAME}: <\":x\">",
- error.message)
- end
- end
-end
diff --git a/test/rexml/test_core.rb b/test/rexml/test_core.rb
index 26e5ecd22e..0071063128 100644
--- a/test/rexml/test_core.rb
+++ b/test/rexml/test_core.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# coding: binary
# frozen_string_literal: false
require_relative "rexml_test_utils"
@@ -116,54 +116,6 @@ module REXMLTests
name4='test4'/>).join(' '), e.to_s
end
- def test_attribute_namespace_conflict
- # https://www.w3.org/TR/xml-names/#uniqAttrs
- message = <<-MESSAGE
-Duplicate attribute "a"
-Line: 4
-Position: 140
-Last 80 unconsumed characters:
- MESSAGE
- assert_raise_with_message(REXML::ParseException, message) do
- Document.new(<<-XML)
-<!-- http://www.w3.org is bound to n1 and n2 -->
-<x xmlns:n1="http://www.w3.org"
- xmlns:n2="http://www.w3.org" >
- <bad a="1" a="2" />
- <bad n1:a="1" n2:a="2" />
-</x>
- XML
- end
- end
-
- def test_attribute_default_namespace
- # https://www.w3.org/TR/xml-names/#uniqAttrs
- document = Document.new(<<-XML)
-<!-- http://www.w3.org is bound to n1 and is the default -->
-<x xmlns:n1="http://www.w3.org"
- xmlns="http://www.w3.org" >
- <good a="1" b="2" />
- <good a="1" n1:a="2" />
-</x>
- XML
- attributes = document.root.elements.collect do |element|
- element.attributes.each_attribute.collect do |attribute|
- [attribute.prefix, attribute.namespace, attribute.name]
- end
- end
- assert_equal([
- [
- ["", "", "a"],
- ["", "", "b"],
- ],
- [
- ["", "", "a"],
- ["n1", "http://www.w3.org", "a"],
- ],
- ],
- attributes)
- end
-
def test_cdata
test = "The quick brown fox jumped
& < & < \" '
@@ -925,18 +877,18 @@ EOL
EOL
# The most common case. People not caring about the namespaces much.
- assert_equal( "XY", XPath.match( doc, "/*:test/*:a/text()" ).join )
- assert_equal( "XY", XPath.match( doc, "/*:test/x:a/text()" ).join )
+ assert_equal( "XY", XPath.match( doc, "/test/a/text()" ).join )
+ assert_equal( "XY", XPath.match( doc, "/test/x:a/text()" ).join )
# Surprising? I don't think so, if you believe my definition of the "common case"
- assert_equal( "XYZ", XPath.match( doc, "//*:a/text()" ).join )
+ assert_equal( "XYZ", XPath.match( doc, "//a/text()" ).join )
# These are the uncommon cases. Namespaces are actually important, so we define our own
# mappings, and pass them in.
assert_equal( "XY", XPath.match( doc, "/f:test/f:a/text()", { "f" => "1" } ).join )
# The namespaces are defined, and override the original mappings
- assert_equal( "XY", XPath.match( doc, "/*:test/*:a/text()", { "f" => "1" } ).join )
+ assert_equal( "", XPath.match( doc, "/test/a/text()", { "f" => "1" } ).join )
assert_equal( "", XPath.match( doc, "/x:test/x:a/text()", { "f" => "1" } ).join )
- assert_equal( "XYZ", XPath.match( doc, "//*:a/text()", { "f" => "1" } ).join )
+ assert_equal( "", XPath.match( doc, "//a/text()", { "f" => "1" } ).join )
end
def test_processing_instruction
@@ -1043,7 +995,7 @@ EOL
document.write(s)
## XML Doctype
- str = '<!DOCTYPE foo SYSTEM "bar">'
+ str = '<!DOCTYPE foo "bar">'
source = REXML::Source.new(str)
doctype = REXML::DocType.new(source)
document.add(doctype)
@@ -1322,15 +1274,14 @@ EOL
def test_ticket_21
src = "<foo bar=value/>"
- exception = assert_raise(ParseException) do
+ assert_raise( ParseException, "invalid XML should be caught" ) {
+ Document.new(src)
+ }
+ begin
Document.new(src)
+ rescue
+ assert_match( /missing attribute quote/, $!.message )
end
- assert_equal(<<-DETAIL, exception.to_s)
-Missing attribute value start quote: <bar>
-Line: 1
-Position: 16
-Last 80 unconsumed characters:
- DETAIL
end
def test_ticket_63
@@ -1439,8 +1390,8 @@ ENDXML
def test_ticket_102
doc = REXML::Document.new '<doc xmlns="ns"><item name="foo"/></doc>'
- assert_equal( "foo", doc.root.elements["*:item"].attribute("name","ns").to_s )
- assert_equal( "item", doc.root.elements["*:item[@name='foo']"].name )
+ assert_equal( "foo", doc.root.elements["item"].attribute("name","ns").to_s )
+ assert_equal( "item", doc.root.elements["item[@name='foo']"].name )
end
def test_ticket_14
@@ -1469,11 +1420,11 @@ ENDXML
doc = REXML::Document.new(
'<doc xmlns="ns" xmlns:phantom="ns"><item name="foo">text</item></doc>'
)
- assert_equal 'text', doc.text( "/*:doc/*:item[@name='foo']" )
+ assert_equal 'text', doc.text( "/doc/item[@name='foo']" )
assert_equal "name='foo'",
- doc.root.elements["*:item"].attribute("name", "ns").inspect
+ doc.root.elements["item"].attribute("name", "ns").inspect
assert_equal "<item name='foo'>text</item>",
- doc.root.elements["*:item[@name='foo']"].to_s
+ doc.root.elements["item[@name='foo']"].to_s
end
def test_ticket_135
diff --git a/test/rexml/test_doctype.rb b/test/rexml/test_doctype.rb
index 915717de8e..91de05b05f 100644
--- a/test/rexml/test_doctype.rb
+++ b/test/rexml/test_doctype.rb
@@ -1,82 +1,68 @@
# frozen_string_literal: false
-
-require_relative "rexml_test_utils"
+require 'test/unit'
+require 'rexml/document'
module REXMLTests
class TestDocTypeAccessor < Test::Unit::TestCase
+
def setup
@sysid = "urn:x-test:sysid1"
- @notation_id1 = "urn:x-test:notation1"
- @notation_id2 = "urn:x-test:notation2"
- xml_system = <<-XML
- <!DOCTYPE root SYSTEM "#{@sysid}" [
- <!NOTATION n1 SYSTEM "#{@notation_id1}">
- <!NOTATION n2 SYSTEM "#{@notation_id2}">
+ @notid1 = "urn:x-test:notation1"
+ @notid2 = "urn:x-test:notation2"
+ document_string1 = <<-"XMLEND"
+ <!DOCTYPE r SYSTEM "#{@sysid}" [
+ <!NOTATION n1 SYSTEM "#{@notid1}">
+ <!NOTATION n2 SYSTEM "#{@notid2}">
]>
- <root/>
- XML
- @doc_type_system = REXML::Document.new(xml_system).doctype
+ <r/>
+ XMLEND
+ @doctype1 = REXML::Document.new(document_string1).doctype
@pubid = "TEST_ID"
- xml_public_system = <<-XML
- <!DOCTYPE root PUBLIC "#{@pubid}" "#{@sysid}">
- <root/>
- XML
- @doc_type_public_system = REXML::Document.new(xml_public_system).doctype
- end
+ document_string2 = <<-"XMLEND"
+ <!DOCTYPE r PUBLIC "#{@pubid}">
+ <r/>
+ XMLEND
+ @doctype2 = REXML::Document.new(document_string2).doctype
- def test_public
- assert_equal([
- nil,
- @pubid,
- ],
- [
- @doc_type_system.public,
- @doc_type_public_system.public,
- ])
- end
+ document_string3 = <<-"XMLEND"
+ <!DOCTYPE r PUBLIC "#{@pubid}" "#{@sysid}">
+ <r/>
+ XMLEND
+ @doctype3 = REXML::Document.new(document_string3).doctype
- def test_to_s
- assert_equal("<!DOCTYPE root PUBLIC \"#{@pubid}\" \"#{@sysid}\">",
- @doc_type_public_system.to_s)
end
- def test_to_s_apostrophe
- @doc_type_public_system.parent.context[:prologue_quote] = :apostrophe
- assert_equal("<!DOCTYPE root PUBLIC '#{@pubid}' '#{@sysid}'>",
- @doc_type_public_system.to_s)
+ def test_public
+ assert_equal(nil, @doctype1.public)
+ assert_equal(@pubid, @doctype2.public)
+ assert_equal(@pubid, @doctype3.public)
end
def test_system
- assert_equal([
- @sysid,
- @sysid,
- ],
- [
- @doc_type_system.system,
- @doc_type_public_system.system,
- ])
+ assert_equal(@sysid, @doctype1.system)
+ assert_equal(nil, @doctype2.system)
+ assert_equal(@sysid, @doctype3.system)
end
def test_notation
- assert_equal([
- @notation_id1,
- @notation_id2,
- ],
- [
- @doc_type_system.notation("n1").system,
- @doc_type_system.notation("n2").system,
- ])
+ assert_equal(@notid1, @doctype1.notation("n1").system)
+ assert_equal(@notid2, @doctype1.notation("n2").system)
end
def test_notations
- notations = @doc_type_system.notations
- assert_equal([
- @notation_id1,
- @notation_id2,
- ],
- notations.collect(&:system))
+ notations = @doctype1.notations
+ assert_equal(2, notations.length)
+ assert_equal(@notid1, find_notation(notations, "n1").system)
+ assert_equal(@notid2, find_notation(notations, "n2").system)
+ end
+
+ def find_notation(notations, name)
+ notations.find { |notation|
+ name == notation.name
+ }
end
+
end
class TestNotationDeclPublic < Test::Unit::TestCase
@@ -96,19 +82,6 @@ module REXMLTests
decl(@id, @uri).to_s)
end
- def test_to_s_apostrophe
- document = REXML::Document.new(<<-XML)
- <!DOCTYPE root SYSTEM "urn:x-test:sysid" [
- #{decl(@id, @uri).to_s}
- ]>
- <root/>
- XML
- document.context[:prologue_quote] = :apostrophe
- notation = document.doctype.notations[0]
- assert_equal("<!NOTATION #{@name} PUBLIC '#{@id}' '#{@uri}'>",
- notation.to_s)
- end
-
private
def decl(id, uri)
REXML::NotationDecl.new(@name, "PUBLIC", id, uri)
@@ -126,19 +99,6 @@ module REXMLTests
decl(@id).to_s)
end
- def test_to_s_apostrophe
- document = REXML::Document.new(<<-XML)
- <!DOCTYPE root SYSTEM "urn:x-test:sysid" [
- #{decl(@id).to_s}
- ]>
- <root/>
- XML
- document.context[:prologue_quote] = :apostrophe
- notation = document.doctype.notations[0]
- assert_equal("<!NOTATION #{@name} SYSTEM '#{@id}'>",
- notation.to_s)
- end
-
private
def decl(id)
REXML::NotationDecl.new(@name, "SYSTEM", id, nil)
diff --git a/test/rexml/test_functions.rb b/test/rexml/test_functions.rb
new file mode 100644
index 0000000000..a77be38cc1
--- /dev/null
+++ b/test/rexml/test_functions.rb
@@ -0,0 +1,238 @@
+# frozen_string_literal: false
+require "test/unit/testcase"
+
+require "rexml/document"
+
+module REXMLTests
+ class FunctionsTester < Test::Unit::TestCase
+ include REXML
+ def test_functions
+ # trivial text() test
+ # confuse-a-function
+ source = "<a>more <b id='1'/><b id='2'>dumb</b><b id='3'/><c/> text</a>"
+ doc = Document.new source
+ res = ""
+ XPath::each(doc.root, "text()") {|val| res << val.to_s}
+ assert_equal "more text", res
+
+ res = XPath::first(doc.root, "b[last()]")
+ assert_equal '3', res.attributes['id']
+ res = XPath::first(doc.root, "b[position()=2]")
+ assert_equal '2', res.attributes['id']
+ res = XPath::first(doc.root, "*[name()='c']")
+ assert_equal "c", res.name
+ end
+
+ # Contributed by Mike Stok
+ def test_starts_with
+ source = <<-EOF
+ <foo>
+ <a href="mailto:a@b.c">a@b.c</a>
+ <a href="http://www.foo.com">http://www.foo.com</a>
+ </foo>
+ EOF
+ doc = Document.new source
+ mailtos = doc.elements.to_a("//a[starts-with(@href, 'mailto:')]")
+ assert_equal 1, mailtos.size
+ assert_equal "mailto:a@b.c", mailtos[0].attributes['href']
+
+ ailtos = doc.elements.to_a("//a[starts-with(@href, 'ailto:')]")
+ assert_equal 0, ailtos.size
+ end
+
+ def test_string_length
+ doc = Document.new <<-EOF
+ <AAA>
+ <Q/>
+ <SSSS/>
+ <BB/>
+ <CCC/>
+ <DDDDDDDD/>
+ <EEEE/>
+ </AAA>
+ EOF
+ assert doc, "create doc"
+
+ set = doc.elements.to_a("//*[string-length(name()) = 3]")
+ assert_equal 2, set.size, "nodes with names length = 3"
+
+ set = doc.elements.to_a("//*[string-length(name()) < 3]")
+ assert_equal 2, set.size, "nodes with names length < 3"
+
+ set = doc.elements.to_a("//*[string-length(name()) > 3]")
+ assert_equal 3, set.size, "nodes with names length > 3"
+ end
+
+ # Test provided by Mike Stok
+ def test_contains
+ source = <<-EOF
+ <foo>
+ <a href="mailto:a@b.c">a@b.c</a>
+ <a href="http://www.foo.com">http://www.foo.com</a>
+ </foo>
+ EOF
+ doc = Document.new source
+
+ [['o', 2], ['foo', 1], ['bar', 0]].each { |test|
+ search, expected = test
+ set = doc.elements.to_a("//a[contains(@href, '#{search}')]")
+ assert_equal expected, set.size
+ }
+ end
+
+ # Mike Stok and Sean Russell
+ def test_substring
+ # examples from http://www.w3.org/TR/xpath#function-substring
+ doc = Document.new('<test string="12345" />')
+
+ #puts XPath.first(d, 'node()[0 + 1]')
+ #d = Document.new("<a b='1'/>")
+ #puts XPath.first(d, 'a[0 mod 0]')
+ [ [1.5, 2.6, '234'],
+ [0, 3, '12'],
+ [0, '0 div 0', ''],
+ [1, '0 div 0', ''],
+ ['-42', '1 div 0', '12345'],
+ ['-1 div 0', '1 div 0', '']
+ ].each { |start, length, expected|
+ set = doc.elements.to_a("//test[substring(@string, #{start}, #{length}) = '#{expected}']")
+ assert_equal 1, set.size, "#{start}, #{length}, '#{expected}'"
+ }
+ end
+
+ def test_substring_angrez
+ testString = REXML::Functions::substring_after("helloworld","hello")
+ assert_equal( 'world', testString )
+ end
+
+ def test_translate
+ source = <<-EOF
+ <doc>
+ <case name='w3c one' result='BAr' /> <!-- w3c -->
+ <case name='w3c two' result='AAA' /> <!-- w3c -->
+ <case name='alchemy' result="gold" /> <!-- mike -->
+ <case name='vbxml one' result='A Space Odyssey' />
+ <case name='vbxml two' result='AbCdEf' />
+ </doc>
+ EOF
+
+ doc = Document.new(source)
+
+ [ ['bar', 'abc', 'ABC', 'w3c one'],
+ ['--aaa--','abc-','ABC', 'w3c two'],
+ ['lead', 'dear language', 'doll groover', 'alchemy'],
+ ['A Space Odissei', 'i', 'y', 'vbxml one'],
+ ['abcdefg', 'aceg', 'ACE', 'vbxml two'],
+ ].each { |arg1, arg2, arg3, name|
+ translate = "translate('#{arg1}', '#{arg2}', '#{arg3}')"
+ set = doc.elements.to_a("//case[@result = #{translate}]")
+ assert_equal 1, set.size, translate
+ assert_equal name, set[0].attributes['name']
+ }
+ end
+
+ def test_name
+ d = REXML::Document.new("<a xmlns:x='foo'><b/><x:b/></a>")
+ assert_equal 1, d.root.elements.to_a('*[name() = "b"]').size
+ assert_equal 1, d.elements.to_a('//*[name() = "x:b"]').size
+ end
+
+ def test_local_name
+ d = REXML::Document.new("<a xmlns:x='foo'><b/><x:b/></a>")
+ assert_equal 2, d.root.elements.to_a('*[local_name() = "b"]').size
+ assert_equal 2, d.elements.to_a('//*[local_name() = "b"]').size
+ end
+
+ def test_substring2
+ doc = Document.new('<test string="12345" />')
+ assert_equal(1,doc.elements.to_a("//test[substring(@string,2)='2345']").size)
+ end
+
+ # Submitted by Kouhei
+ def test_floor_ceiling_round
+ source = "<a><b id='1'/><b id='2'/><b id='3'/></a>"
+ doc = REXML::Document.new(source)
+
+ id_1 = doc.elements["/a/b[@id='1']"]
+ id_2 = doc.elements["/a/b[@id='2']"]
+ id_3 = doc.elements["/a/b[@id='3']"]
+
+ good = {
+ "floor" => [[], [id_1], [id_2], [id_3]],
+ "ceiling" => [[id_1], [id_2], [id_3], []],
+ "round" => [[id_1], [id_2], [id_3], []]
+ }
+ good.each do |key, value|
+ (0..3).each do |i|
+ xpath = "//b[number(@id) = #{key}(#{i+0.5})]"
+ assert_equal(value[i], REXML::XPath.match(doc, xpath))
+ end
+ end
+
+ good["round"] = [[], [id_1], [id_2], [id_3]]
+ good.each do |key, value|
+ (0..3).each do |i|
+ xpath = "//b[number(@id) = #{key}(#{i+0.4})]"
+ assert_equal(value[i], REXML::XPath.match(doc, xpath))
+ end
+ end
+ end
+
+ # Submitted by Kou
+ def test_lang
+ d = Document.new(<<-XML)
+ <a xml:lang="en">
+ <b xml:lang="ja">
+ <c xml:lang="fr"/>
+ <d/>
+ <e xml:lang="ja-JP"/>
+ <f xml:lang="en-US"/>
+ </b>
+ </a>
+ XML
+
+ assert_equal(1, d.elements.to_a("//*[lang('fr')]").size)
+ assert_equal(3, d.elements.to_a("//*[lang('ja')]").size)
+ assert_equal(2, d.elements.to_a("//*[lang('en')]").size)
+ assert_equal(1, d.elements.to_a("//*[lang('en-us')]").size)
+
+ d = Document.new(<<-XML)
+ <root>
+ <para xml:lang="en"/>
+ <div xml:lang="en"><para/></div>
+ <para xml:lang="EN"/>
+ <para xml:lang="en-us"/>
+ </root>
+ XML
+
+ assert_equal(5, d.elements.to_a("//*[lang('en')]").size)
+ end
+
+ def test_ticket_60
+ document = REXML::Document.new("<a><b>A</b><b>1</b></a>")
+ assert_equal( "A", REXML::XPath.first(document, '//b[.="A"]').text )
+ assert_equal( "1", REXML::XPath.first(document, '//b[.="1"]').text )
+ end
+
+ def test_normalize_space
+ source = "<a><!--COMMENT A--><b><!-- COMMENT A --></b></a>"
+ doc = REXML::Document.new(source)
+ predicate = "string(.)=normalize_space('\nCOMMENT \n A \n\n ')"
+ m = REXML::XPath.match(doc, "//comment()[#{predicate}]")
+ assert_equal( [REXML::Comment.new("COMMENT A")], m )
+ end
+
+ def test_unregistered_method
+ doc = Document.new("<root/>")
+ assert_nil(XPath::first(doc.root, "to_s()"))
+ end
+
+ def test_nonexistent_function
+ doc = Document.new("<root><nonexistent/></root>")
+ # TODO: Maybe, this is not XPath spec behavior.
+ # This behavior must be reconsidered.
+ assert_equal(doc.root.elements[1],
+ XPath::first(doc.root, "nonexistent()"))
+ end
+ end
+end
diff --git a/test/rexml/test_functions_number.rb b/test/rexml/test_functions_number.rb
new file mode 100644
index 0000000000..84ec5c7ba7
--- /dev/null
+++ b/test/rexml/test_functions_number.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: false
+require 'rexml/document'
+require 'test/unit'
+require 'rexml/functions'
+
+module REXMLTests
+ class TC_Rexml_Functions_Number < Test::Unit::TestCase
+
+ def test_functions_number_int
+ telem = REXML::Element.new("elem")
+ telem.text="9"
+ assert_equal(9, REXML::Functions::number(telem))
+ end
+ def test_functions_number_float
+ telem = REXML::Element.new("elem")
+ telem.text="10.4"
+ assert_equal(10.4, REXML::Functions::number(telem))
+ end
+ def test_functions_number_negative_int
+ telem = REXML::Element.new("elem")
+ telem.text="-9"
+ assert_equal(-9, REXML::Functions::number(telem))
+ end
+ def test_functions_number_negative_float
+ telem = REXML::Element.new("elem")
+ telem.text="-9.13"
+ assert_equal(-9.13, REXML::Functions::number(telem))
+ end
+ #def test_functions_number_scientific_notation
+ # telem = REXML::Element.new("elem")
+ # telem.text="9.13E12"
+ # assert_equal(9.13E12, REXML::Functions::number(telem))
+ #end
+ end
+end
diff --git a/test/rexml/test_instruction.rb b/test/rexml/test_instruction.rb
deleted file mode 100644
index 96fa909e17..0000000000
--- a/test/rexml/test_instruction.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative "rexml_test_utils"
-
-module REXMLTests
- class InstructionTest < Test::Unit::TestCase
- def test_target_nil
- error = assert_raise(ArgumentError) do
- REXML::Instruction.new(nil)
- end
- assert_equal("processing instruction target must be String or " +
- "REXML::Instruction: <nil>",
- error.message)
- end
- end
-end
diff --git a/test/rexml/test_jaxen.rb b/test/rexml/test_jaxen.rb
index 9640b8290b..9cd7bee8c2 100644
--- a/test/rexml/test_jaxen.rb
+++ b/test/rexml/test_jaxen.rb
@@ -12,120 +12,119 @@ module REXMLTests
include REXMLTestUtils
include REXML
- def test_axis ; process_test_case("axis") ; end
- def test_basic ; process_test_case("basic") ; end
- def test_basicupdate ; process_test_case("basicupdate") ; end
- def test_contents ; process_test_case("contents") ; end
- def test_defaultNamespace ; process_test_case("defaultNamespace") ; end
- def test_fibo ; process_test_case("fibo") ; end
- def test_id ; process_test_case("id") ; end
- def test_jaxen24 ; process_test_case("jaxen24") ; end
- def test_lang ; process_test_case("lang") ; end
- # document() function for XSLT isn't supported
- def _test_message ; process_test_case("message") ; end
- def test_moreover ; process_test_case("moreover") ; end
- def test_much_ado ; process_test_case("much_ado") ; end
- def test_namespaces ; process_test_case("namespaces") ; end
- def test_nitf ; process_test_case("nitf") ; end
- # Exception should be considered
- def _test_numbers ; process_test_case("numbers") ; end
- def test_pi ; process_test_case("pi") ; end
- def test_pi2 ; process_test_case("pi2") ; end
- def test_simple ; process_test_case("simple") ; end
- # TODO: namespace node is needed
- def _test_testNamespaces ; process_test_case("testNamespaces") ; end
- # document() function for XSLT isn't supported
- def _test_text ; process_test_case("text") ; end
- def test_underscore ; process_test_case("underscore") ; end
- def _test_web ; process_test_case("web") ; end
- def test_web2 ; process_test_case("web2") ; end
+ def test_axis ; test("axis") ; end
+ def test_basic ; test("basic") ; end
+ def test_basicupdate ; test("basicupdate") ; end
+ def test_contents ; test("contents") ; end
+ def test_defaultNamespace ; test("defaultNamespace") ; end
+ def test_fibo ; test("fibo") ; end
+ def test_id ; test("id") ; end
+ def test_jaxen24 ; test("jaxen24") ; end
+ def test_lang ; test("lang") ; end
+ def test_message ; test("message") ; end
+ def test_moreover ; test("moreover") ; end
+ def test_much_ado ; test("much_ado") ; end
+ def test_namespaces ; test("namespaces") ; end
+ def test_nitf ; test("nitf") ; end
+ def test_numbers ; test("numbers") ; end
+ def test_pi ; test("pi") ; end
+ def test_pi2 ; test("pi2") ; end
+ def test_simple ; test("simple") ; end
+ def test_testNamespaces ; test("testNamespaces") ; end
+ def test_text ; test("text") ; end
+ def test_underscore ; test("underscore") ; end
+ def test_web ; test("web") ; end
+ def test_web2 ; test("web2") ; end
private
- def process_test_case(name)
- xml_path = "#{name}.xml"
- doc = File.open(fixture_path(xml_path)) do |file|
- Document.new(file)
- end
- test_doc = File.open(fixture_path("test/tests.xml")) do |file|
- Document.new(file)
- end
- XPath.each(test_doc,
- "/tests/document[@url='xml/#{xml_path}']/context") do |context|
- process_context(doc, context)
- end
+ def test( fname )
+# Dir.entries( xml_dir ).each { |fname|
+# if fname =~ /\.xml$/
+ doc = File.open(fixture_path(fname+".xml")) do |file|
+ Document.new(file)
+ end
+ XPath.each( doc, "/tests/document" ) {|e| handleDocument(e)}
+# end
+# }
end
# processes a tests/document/context node
- def process_context(doc, context)
- test_context = XPath.match(doc, context.attributes["select"])
- namespaces = context.namespaces
- namespaces.delete("var")
- namespaces = nil if namespaces.empty?
- variables = {}
- var_namespace = "http://jaxen.org/test-harness/var"
- XPath.each(context,
- "@*[namespace-uri() = '#{var_namespace}']") do |attribute|
- variables[attribute.name] = attribute.value
- end
- XPath.each(context, "valueOf") do |value|
- process_value_of(test_context, variables, namespaces, value)
- end
- XPath.each(context,
- "test[not(@exception) or (@exception != 'true')]") do |test|
- process_nominal_test(test_context, variables, namespaces, test)
- end
- XPath.each(context,
- "test[@exception = 'true']") do |test|
- process_exceptional_test(test_context, variables, namespaces, test)
+ def handleContext( testDoc, ctxElement)
+ testCtx = XPath.match( testDoc, ctxElement.attributes["select"] )[0]
+ namespaces = {}
+ if testCtx.class == Element
+ testCtx.prefixes.each { |pre| handleNamespace( testCtx, pre, namespaces ) }
end
+ variables = {}
+ XPath.each( ctxElement, "@*[namespace-uri() = 'http://jaxen.org/test-harness/var']") { |attrib| handleVariable(testCtx, variables, attrib) }
+ XPath.each( ctxElement, "valueOf") { |e| handleValueOf(testCtx, variables, namespaces, e) }
+ XPath.each( ctxElement, "test[not(@exception) or (@exception != 'true') ]") { |e| handleNominalTest(testCtx,variables, namespaces, e) }
+ XPath.each( ctxElement, "test[@exception = 'true']") { |e| handleExceptionalTest(testCtx,variables, namespaces, e) }
end
# processes a tests/document/context/valueOf or tests/document/context/test/valueOf node
- def process_value_of(context, variables, namespaces, value_of)
- expected = value_of.text
- xpath = value_of.attributes["select"]
- matched = XPath.match(context, xpath, namespaces, variables, strict: true)
-
- message = user_message(context, xpath, matched)
- assert_equal(expected || "",
- REXML::Functions.string(matched),
- message)
+ def handleValueOf(ctx,variables, namespaces, valueOfElement)
+ expected = valueOfElement.text
+ got = XPath.match( ctx, valueOfElement.attributes["select"], namespaces, variables )[0]
+ assert_true( (got.nil? && expected.nil?) || !got.nil? )
+ case got.class
+ when Element
+ assert_equal( got.class, Element )
+ when Attribute, Text, Comment, TrueClass, FalseClass
+ assert_equal( expected, got.to_s )
+ when Instruction
+ assert_equal( expected, got.content )
+ when Integer
+ assert_equal( exected.to_f, got )
+ when String
+ # normalize values for comparison
+ got = "" if got == nil or got == ""
+ expected = "" if expected == nil or expected == ""
+ assert_equal( expected, got )
+ else
+ assert_fail( "Wassup?" )
+ end
end
+
# processes a tests/document/context/test node ( where @exception is false or doesn't exist )
- def process_nominal_test(context, variables, namespaces, test)
- xpath = test.attributes["select"]
- matched = XPath.match(context, xpath, namespaces, variables, strict: true)
+ def handleNominalTest(ctx, variables, namespaces, testElement)
+ expected = testElement.attributes["count"]
+ got = XPath.match( ctx, testElement.attributes["select"], namespaces, variables )
# might be a test with no count attribute, but nested valueOf elements
- expected = test.attributes["count"]
- if expected
- assert_equal(Integer(expected, 10),
- matched.size,
- user_message(context, xpath, matched))
- end
+ assert( expected == got.size.to_s ) if !expected.nil?
- XPath.each(test, "valueOf") do |value_of|
- process_value_of(matched, variables, namespaces, value_of)
- end
+ XPath.each( testElement, "valueOf") { |e|
+ handleValueOf(got, variables, namespaces, e)
+ }
end
# processes a tests/document/context/test node ( where @exception is true )
- def process_exceptional_test(context, variables, namespaces, test)
- xpath = test.attributes["select"]
- assert_raise(REXML::ParseException) do
- XPath.match(context, xpath, namespaces, variables, strict: true)
- end
+ def handleExceptionalTest(ctx, variables, namespaces, testElement)
+ assert_raise( Exception ) {
+ XPath.match( ctx, testElement.attributes["select"], namespaces, variables )
+ }
end
- def user_message(context, xpath, matched)
- message = ""
- context.each_with_index do |node, i|
- message << "Node#{i}:\n"
- message << "#{node}\n"
- end
- message << "XPath: <#{xpath}>\n"
- message << "Matched <#{matched}>"
- message
+ # processes a tests/document node
+ def handleDocument(docElement)
+ puts "- Processing document: #{docElement.attributes['url']}"
+ testFile = File.new( docElement.attributes["url"] )
+ testDoc = Document.new testFile
+ XPath.each( docElement, "context") { |e| handleContext(testDoc, e) }
end
+
+ # processes a variable definition in a namespace like <test var:foo="bar">
+ def handleVariable( ctx, variables, attrib )
+ puts "--- Found attribute: #{attrib.name}"
+ variables[attrib.name] = attrib.value
+ end
+
+ # processes a namespace definition like <test xmlns:foo="fiz:bang:bam">
+ def handleNamespace( ctx, prefix, namespaces )
+ puts "--- Found namespace: #{prefix}"
+ namespaces[prefix] = ctx.namespaces[prefix]
+ end
+
end
end
diff --git a/test/rexml/test_martin_fowler.rb b/test/rexml/test_martin_fowler.rb
index add3c82723..da685a80ec 100644
--- a/test/rexml/test_martin_fowler.rb
+++ b/test/rexml/test_martin_fowler.rb
@@ -3,7 +3,7 @@ require 'test/unit'
require 'rexml/document'
module REXMLTests
- class OrderTesterMF < Test::Unit::TestCase
+ class OrderTester < Test::Unit::TestCase
DOC = <<END
<paper>
<title>Remove this element and figs order differently</title>
diff --git a/test/rexml/test_stream.rb b/test/rexml/test_stream.rb
index 08d4462ef9..d7ceedc70e 100644
--- a/test/rexml/test_stream.rb
+++ b/test/rexml/test_stream.rb
@@ -15,8 +15,8 @@ module REXMLTests
def test_listener
data = %Q{<session1 user="han" password="rootWeiler" />\n<session2 user="han" password="rootWeiler" />}
- RequestReader.new( data )
- RequestReader.new( data )
+ b = RequestReader.new( data )
+ b = RequestReader.new( data )
end
def test_ticket_49
diff --git a/test/rexml/test_text.rb b/test/rexml/test_text.rb
index e9a246e27f..3f8036eee3 100644
--- a/test/rexml/test_text.rb
+++ b/test/rexml/test_text.rb
@@ -1,57 +1,10 @@
# frozen_string_literal: false
-
-require_relative "rexml_test_utils"
+require "rexml/text"
module REXMLTests
class TextTester < Test::Unit::TestCase
include REXML
- def test_new_text_response_whitespace_default
- text = Text.new("a b\t\tc", true)
- assert_equal("a b\tc", Text.new(text).to_s)
- end
-
- def test_new_text_response_whitespace_true
- text = Text.new("a b\t\tc", true)
- assert_equal("a b\t\tc", Text.new(text, true).to_s)
- end
-
- def test_new_text_raw_default
- text = Text.new("&amp;lt;", false, nil, true)
- assert_equal("&amp;lt;", Text.new(text).to_s)
- end
-
- def test_new_text_raw_false
- text = Text.new("&amp;lt;", false, nil, true)
- assert_equal("&amp;amp;lt;", Text.new(text, false, nil, false).to_s)
- end
-
- def test_new_text_entity_filter_default
- document = REXML::Document.new(<<-XML)
-<!DOCTYPE root [
- <!ENTITY a "aaa">
- <!ENTITY b "bbb">
-]>
-<root/>
- XML
- text = Text.new("aaa bbb", false, document.root, nil, ["a"])
- assert_equal("aaa &b;",
- Text.new(text, false, document.root).to_s)
- end
-
- def test_new_text_entity_filter_custom
- document = REXML::Document.new(<<-XML)
-<!DOCTYPE root [
- <!ENTITY a "aaa">
- <!ENTITY b "bbb">
-]>
-<root/>
- XML
- text = Text.new("aaa bbb", false, document.root, nil, ["a"])
- assert_equal("&a; bbb",
- Text.new(text, false, document.root, nil, ["b"]).to_s)
- end
-
def test_shift_operator_chain
text = Text.new("original\r\n")
text << "append1\r\n" << "append2\r\n"
@@ -65,11 +18,5 @@ module REXMLTests
text << "append3\r\n" << "append4\r\n"
assert_equal("original\nappend1\nappend2\nappend3\nappend4\n", text.to_s)
end
-
- def test_clone
- text = Text.new("&amp;lt; <")
- assert_equal(text.to_s,
- text.clone.to_s)
- end
end
end
diff --git a/test/rexml/test_xml_declaration.rb b/test/rexml/test_xml_declaration.rb
index da7076126e..a4d97c41d0 100644
--- a/test/rexml/test_xml_declaration.rb
+++ b/test/rexml/test_xml_declaration.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# frozen_string_literal: false
#
# Created by Henrik MÃ¥rtensson on 2007-02-18.
@@ -9,11 +10,11 @@ require "test/unit"
module REXMLTests
class TestXmlDeclaration < Test::Unit::TestCase
def setup
- xml = <<-XML
+ xml = <<-'END_XML'
<?xml encoding= 'UTF-8' standalone='yes'?>
<root>
</root>
- XML
+ END_XML
@doc = REXML::Document.new xml
@root = @doc.root
@xml_declaration = @doc.children[0]
@@ -31,18 +32,5 @@ module REXMLTests
assert_kind_of(REXML::XMLDecl, @root.previous_sibling.previous_sibling)
assert_kind_of(REXML::Element, @xml_declaration.next_sibling.next_sibling)
end
-
- def test_write_prologue_quote
- @doc.context[:prologue_quote] = :quote
- assert_equal("<?xml version=\"1.0\" " +
- "encoding=\"UTF-8\" standalone=\"yes\"?>",
- @xml_declaration.to_s)
- end
-
- def test_is_writethis_attribute_copied_by_clone
- assert_equal(true, @xml_declaration.clone.writethis)
- @xml_declaration.nowrite
- assert_equal(false, @xml_declaration.clone.writethis)
- end
end
end
diff --git a/test/rexml/xpath/test_attribute.rb b/test/rexml/xpath/test_attribute.rb
index 713d77b22f..9304db4e0d 100644
--- a/test/rexml/xpath/test_attribute.rb
+++ b/test/rexml/xpath/test_attribute.rb
@@ -7,7 +7,7 @@ module REXMLTests
def setup
@xml = <<-XML
<?xml version="1.0" encoding="UTF-8"?>
-<root xmlns="http://example.com/">
+<root>
<child name="one">child1</child>
<child name="two">child2</child>
<child name="three">child3</child>
@@ -26,13 +26,5 @@ module REXMLTests
children = REXML::XPath.each(@document, "/root/child[@name='two']")
assert_equal(["child2"], children.collect(&:text))
end
-
- def test_no_namespace
- children = REXML::XPath.match(@document,
- "/root/child[@nothing:name='two']",
- "" => "http://example.com/",
- "nothing" => "")
- assert_equal(["child2"], children.collect(&:text))
- end
end
end
diff --git a/test/rexml/xpath/test_base.rb b/test/rexml/xpath/test_base.rb
index 210d6c7c81..5079fdd75a 100644
--- a/test/rexml/xpath/test_base.rb
+++ b/test/rexml/xpath/test_base.rb
@@ -369,15 +369,11 @@ module REXMLTests
assert_equal 2, c
end
- def match(xpath)
- XPath.match(@@doc, xpath).collect(&:to_s)
- end
-
def test_grouping
- assert_equal([],
- match("a/d/*[name()='d' and (name()='f' or name()='q')]"))
- assert_equal(["<q id='19'/>"],
- match("a/d/*[(name()='d' and name()='f') or name()='q']"))
+ t = XPath.first( @@doc, "a/d/*[name()='d' and (name()='f' or name()='q')]" )
+ assert_nil t
+ t = XPath.first( @@doc, "a/d/*[(name()='d' and name()='f') or name()='q']" )
+ assert_equal 'q', t.name
end
def test_preceding
@@ -636,36 +632,29 @@ module REXMLTests
<c id='a'/>
</b>
<c id='b'/>
- <c id='c'/>
- <c/>
</a>")
- match = lambda do |xpath|
- REXML::XPath.match(doc, xpath).collect(&:to_s)
- end
- assert_equal(["<c id='b'/>"],
- match.call("//*[local-name()='c' and @id='b']"))
- assert_equal(["<c id='b'/>"],
- match.call("//*[ local-name()='c' and @id='b' ]"))
- assert_equal(["<c id='b'/>"],
- match.call("//*[ local-name() = 'c' and @id = 'b' ]"))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/a/c[@id]'))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/a/c[(@id)]'))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/a/c[ @id ]'))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/a/c[ (@id) ]'))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/a/c[( @id )]'))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/a/c[ ( @id ) ]'))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/a/c [ ( @id ) ] '))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call(' / a / c [ ( @id ) ] '))
- assert_equal(["<c id='b'/>", "<c id='c'/>"],
- match.call('/ a / child:: c [( @id )] /'))
+ assert_equal( 1, REXML::XPath.match(doc,
+ "//*[local-name()='c' and @id='b']").size )
+ assert_equal( 1, REXML::XPath.match(doc,
+ "//*[ local-name()='c' and @id='b' ]").size )
+ assert_equal( 1, REXML::XPath.match(doc,
+ "//*[ local-name() = 'c' and @id = 'b' ]").size )
+ assert_equal( 1,
+ REXML::XPath.match(doc, '/a/c[@id]').size )
+ assert_equal( 1,
+ REXML::XPath.match(doc, '/a/c[(@id)]').size )
+ assert_equal( 1,
+ REXML::XPath.match(doc, '/a/c[ @id ]').size )
+ assert_equal( 1,
+ REXML::XPath.match(doc, '/a/c[ (@id) ]').size )
+ assert_equal( 1,
+ REXML::XPath.match(doc, '/a/c[( @id )]').size )
+ assert_equal( 1, REXML::XPath.match(doc.root,
+ '/a/c[ ( @id ) ]').size )
+ assert_equal( 1, REXML::XPath.match(doc,
+ '/a/c [ ( @id ) ] ').size )
+ assert_equal( 1, REXML::XPath.match(doc,
+ ' / a / c [ ( @id ) ] ').size )
end
def test_text_nodes
@@ -703,22 +692,11 @@ module REXMLTests
end
def test_ordering
- source = <<-XML
-<a>
- <b>
- <c id='1'/>
- <c id='2'/>
- </b>
- <b>
- <d id='3'/>
- <d id='4'/>
- </b>
-</a>
- XML
+ source = "<a><b><c id='1'/><c id='2'/></b><b><d id='1'/><d id='2'/></b></a>"
d = REXML::Document.new( source )
r = REXML::XPath.match( d, %q{/a/*/*[1]} )
- assert_equal(["1", "3"],
- r.collect {|element| element.attribute("id").value})
+ assert_equal( 1, r.size )
+ r.each { |el| assert_equal( '1', el.attribute('id').value ) }
end
def test_descendant_or_self_ordering
@@ -852,44 +830,31 @@ module REXMLTests
</a>
EOL
d = REXML::Document.new( string )
- cs = XPath.match( d, '/a/*/*[1]' )
- assert_equal(["c1", "c2"], cs.collect(&:name))
+ c1 = XPath.match( d, '/a/*/*[1]' )
+ assert_equal( 1, c1.length )
+ assert_equal( 'c1', c1[0].name )
end
def test_sum
- d = Document.new(<<-XML)
-<a>
- <b>1</b>
- <b>2</b>
- <b>3</b>
- <c>
- <d>1</d>
- <d>2</d>
- </c>
- <e att='1'/>
- <e att='2'/>
-</a>
- XML
-
- assert_equal([6], XPath::match(d, "sum(/a/b)"))
- assert_equal([9], XPath::match(d, "sum(//b | //d)"))
- assert_equal([3], XPath::match(d, "sum(/a/e/@*)"))
+ d = Document.new("<a>"+
+ "<b>1</b><b>2</b><b>3</b>"+
+ "<c><d>1</d><d>2</d></c>"+
+ "<e att='1'/><e att='2'/>"+
+ "</a>")
+
+ for v,p in [[6, "sum(/a/b)"],
+ [9, "sum(//b | //d)"],
+ [3, "sum(/a/e/@*)"] ]
+ assert_equal( v, XPath::match( d, p ).first )
+ end
end
def test_xpath_namespace
- d = REXML::Document.new(<<-XML)
-<tag1 xmlns='ns1'>
- <tag2 xmlns='ns2'/>
- <tada>xa</tada>
- <tada xmlns=''>xb</tada>
-</tag1>
- XML
- actual = []
- d.root.each_element('tada') do |element|
- actual << element.to_s
- end
- assert_equal(["<tada>xa</tada>", "<tada xmlns=''>xb</tada>"],
- actual)
+ d = REXML::Document.new("<tag1 xmlns='ns1'><tag2 xmlns='ns2'/><tada>xa</tada></tag1>")
+ x = d.root
+ num = 0
+ x.each_element('tada') { num += 1 }
+ assert_equal(1, num)
end
def test_ticket_39
@@ -1025,7 +990,7 @@ EOF
</a>"
d = Document.new(data)
res = d.elements.to_a( "//c" ).collect {|e| e.attributes['id'].to_i}
- assert_equal((1..12).to_a, res)
+ assert_equal( res, res.sort )
end
def ticket_61_fixture(doc, xpath)
diff --git a/test/rexml/xpath/test_compare.rb b/test/rexml/xpath/test_compare.rb
deleted file mode 100644
index bb666c9b12..0000000000
--- a/test/rexml/xpath/test_compare.rb
+++ /dev/null
@@ -1,256 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "../rexml_test_utils"
-
-require "rexml/document"
-
-module REXMLTests
- class TestXPathCompare < Test::Unit::TestCase
- def match(xml, xpath)
- document = REXML::Document.new(xml)
- REXML::XPath.match(document, xpath)
- end
-
- class TestEqual < self
- class TestNodeSet < self
- def test_boolean_true
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child/>
- <child/>
-</root>
- XML
- assert_equal([true],
- match(xml, "/root/child=true()"))
- end
-
- def test_boolean_false
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
-</root>
- XML
- assert_equal([false],
- match(xml, "/root/child=true()"))
- end
-
- def test_number_true
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>100</child>
- <child>200</child>
-</root>
- XML
- assert_equal([true],
- match(xml, "/root/child=100"))
- end
-
- def test_number_false
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>100</child>
- <child>200</child>
-</root>
- XML
- assert_equal([false],
- match(xml, "/root/child=300"))
- end
-
- def test_string_true
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>text</child>
- <child>string</child>
-</root>
- XML
- assert_equal([true],
- match(xml, "/root/child='string'"))
- end
-
- def test_string_false
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>text</child>
- <child>string</child>
-</root>
- XML
- assert_equal([false],
- match(xml, "/root/child='nonexistent'"))
- end
- end
-
- class TestBoolean < self
- def test_number_true
- xml = "<root/>"
- assert_equal([true],
- match(xml, "true()=1"))
- end
-
- def test_number_false
- xml = "<root/>"
- assert_equal([false],
- match(xml, "true()=0"))
- end
-
- def test_string_true
- xml = "<root/>"
- assert_equal([true],
- match(xml, "true()='string'"))
- end
-
- def test_string_false
- xml = "<root/>"
- assert_equal([false],
- match(xml, "true()=''"))
- end
- end
-
- class TestNumber < self
- def test_string_true
- xml = "<root/>"
- assert_equal([true],
- match(xml, "1='1'"))
- end
-
- def test_string_false
- xml = "<root/>"
- assert_equal([false],
- match(xml, "1='2'"))
- end
- end
- end
-
- class TestGreaterThan < self
- class TestNodeSet < self
- def test_boolean_truex
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child/>
-</root>
- XML
- assert_equal([true],
- match(xml, "/root/child>false()"))
- end
-
- def test_boolean_false
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child/>
-</root>
- XML
- assert_equal([false],
- match(xml, "/root/child>true()"))
- end
-
- def test_number_true
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>100</child>
- <child>200</child>
-</root>
- XML
- assert_equal([true],
- match(xml, "/root/child>199"))
- end
-
- def test_number_false
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>100</child>
- <child>200</child>
-</root>
- XML
- assert_equal([false],
- match(xml, "/root/child>200"))
- end
-
- def test_string_true
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>100</child>
- <child>200</child>
-</root>
- XML
- assert_equal([true],
- match(xml, "/root/child>'199'"))
- end
-
- def test_string_false
- xml = <<-XML
-<?xml version="1.0" encoding="UTF-8"?>
-<root>
- <child>100</child>
- <child>200</child>
-</root>
- XML
- assert_equal([false],
- match(xml, "/root/child>'200'"))
- end
- end
-
- class TestBoolean < self
- def test_string_true
- xml = "<root/>"
- assert_equal([true],
- match(xml, "true()>'0'"))
- end
-
- def test_string_false
- xml = "<root/>"
- assert_equal([false],
- match(xml, "true()>'1'"))
- end
- end
-
- class TestNumber < self
- def test_boolean_true
- xml = "<root/>"
- assert_equal([true],
- match(xml, "true()>0"))
- end
-
- def test_number_false
- xml = "<root/>"
- assert_equal([false],
- match(xml, "true()>1"))
- end
-
- def test_string_true
- xml = "<root/>"
- assert_equal([true],
- match(xml, "1>'0'"))
- end
-
- def test_string_false
- xml = "<root/>"
- assert_equal([false],
- match(xml, "1>'1'"))
- end
- end
-
- class TestString < self
- def test_string_true
- xml = "<root/>"
- assert_equal([true],
- match(xml, "'1'>'0'"))
- end
-
- def test_string_false
- xml = "<root/>"
- assert_equal([false],
- match(xml, "'1'>'1'"))
- end
- end
- end
- end
-end
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index 22966532b7..c899f32a8a 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -17,36 +17,16 @@ class MockClock
def keeper_thread
nil
end
-
- def stop_keeper
- if @keeper
- @keeper.kill
- @keeper.join
- @keeper = nil
- end
- end
end
def initialize
@now = 2
@reso = 1
- @ts = nil
- @inf = 2**31 - 1
- end
-
- def start_keeper
- @now = 2
- @reso = 1
- @ts&.stop_keeper
@ts = MyTS.new
@ts.write([2, :now])
@inf = 2**31 - 1
end
- def stop_keeper
- @ts.stop_keeper
- end
-
def now
@now.to_f
end
@@ -120,14 +100,6 @@ class TupleSpace
end
module TupleSpaceTestModule
- def setup
- MockClock.instance.start_keeper
- end
-
- def teardown
- MockClock.instance.stop_keeper
- end
-
def sleep(n)
if Thread.current == Thread.main
Time.forward(n)
@@ -474,7 +446,6 @@ class TupleSpaceTest < Test::Unit::TestCase
include TupleSpaceTestModule
def setup
- super
ThreadGroup.new.add(Thread.current)
@ts = Rinda::TupleSpace.new(1)
end
@@ -486,7 +457,6 @@ class TupleSpaceTest < Test::Unit::TestCase
th.join
end
}
- super
end
end
@@ -494,7 +464,6 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
include TupleSpaceTestModule
def setup
- super
ThreadGroup.new.add(Thread.current)
@ts_base = Rinda::TupleSpace.new(1)
@ts = Rinda::TupleSpaceProxy.new(@ts_base)
@@ -509,8 +478,6 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
end
}
@server.stop_service
- DRb::DRbConn.stop_pool
- super
end
def test_remote_array_and_hash
@@ -526,7 +493,6 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
end
def test_take_bug_8215
- skip "this test randomly fails on mswin" if /mswin/ =~ RUBY_PLATFORM
service = DRb.start_service("druby://localhost:0", @ts_base)
uri = service.uri
@@ -565,7 +531,6 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
'[bug:8215] tuple lost')
ensure
service.stop_service if service
- DRb::DRbConn.stop_pool
signal = /mswin|mingw/ =~ RUBY_PLATFORM ? "KILL" : "TERM"
Process.kill(signal, write) if write && status.nil?
Process.kill(signal, take) if take
@@ -604,8 +569,6 @@ module RingIPv6
return # IPv6 address for multicast not available
rescue Errno::ENETDOWN
return # Network is down
- rescue Errno::EHOSTUNREACH
- return # Unreachable for some reason
end
begin
yield v6mc
@@ -622,10 +585,8 @@ class TestRingServer < Test::Unit::TestCase
@ts = Rinda::TupleSpace.new
@rs = Rinda::RingServer.new(@ts, [], @port)
- @server = DRb.start_service("druby://localhost:0")
end
def teardown
- @rs.shutdown
# implementation-dependent
@ts.instance_eval{
if th = @keeper
@@ -633,8 +594,7 @@ class TestRingServer < Test::Unit::TestCase
th.join
end
}
- @server.stop_service
- DRb::DRbConn.stop_pool
+ @rs.shutdown
end
def test_do_reply
@@ -660,7 +620,6 @@ class TestRingServer < Test::Unit::TestCase
end
def test_do_reply_local
- skip 'timeout-based test becomes unstable with --jit-wait' if RubyVM::MJIT.enabled?
with_timeout(10) {_test_do_reply_local}
end
@@ -802,10 +761,7 @@ class TestRingServer < Test::Unit::TestCase
mth.raise(Timeout::Error)
end
tl0 << th
- yield
rescue Timeout::Error => e
- $stderr.puts "TestRingServer#with_timeout: timeout in #{n}s:"
- $stderr.puts caller
if tl
bt = e.backtrace
tl.each do |t|
diff --git a/test/ripper/assert_parse_files.rb b/test/ripper/assert_parse_files.rb
deleted file mode 100644
index 85d20cf69e..0000000000
--- a/test/ripper/assert_parse_files.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-
-module TestRipper; end
-class TestRipper::Generic < Test::Unit::TestCase
- SRCDIR = File.expand_path("../../..", __FILE__)
-
- def assert_parse_files(dir, pattern = "**/*.rb")
- assert_separately(%W[--disable-gem -rripper - #{SRCDIR}/#{dir} #{pattern}],
- __FILE__, __LINE__, "#{<<-"begin;"}\n#{<<-'end;'}", timeout: Float::INFINITY)
- pattern = "#{pattern}"
- begin;
- TEST_RATIO = ENV["TEST_RIPPER_RATIO"]&.tap {|s|break s.to_f} || 0.05 # testing all files needs too long time...
- class Parser < Ripper
- PARSER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; r.inspect; Object.new end" }
- SCANNER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; r.inspect; Object.new end" }
- end
- dir = ARGV.shift
- scripts = Dir.chdir(dir) {Dir[pattern]}
- if (1...scripts.size).include?(num = scripts.size * TEST_RATIO)
- scripts = scripts.sample(num)
- end
- scripts.sort!
- for script in scripts
- assert_nothing_raised {
- parser = Parser.new(File.read("#{dir}/#{script}"), script)
- parser.instance_eval "parse", "<#{script}>"
- }
- end
- end;
- end
-end
diff --git a/test/ripper/test_files.rb b/test/ripper/test_files.rb
new file mode 100644
index 0000000000..d90cd6479e
--- /dev/null
+++ b/test/ripper/test_files.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+require 'test/unit'
+
+module TestRipper; end
+class TestRipper::Generic < Test::Unit::TestCase
+ SRCDIR = File.expand_path("../../..", __FILE__)
+
+ %w[sample ext].each do |dir|
+ define_method("test_parse_files:#{dir}") do
+ assert_parse_files(dir)
+ end
+ end
+
+ %w[lib test].each do |dir|
+ define_method("test_parse_files:#{dir}") do
+ assert_parse_files(dir, "*.rb")
+ end
+ Dir["#{SRCDIR}/#{dir}/*/"].each do |dir|
+ dir = dir[(SRCDIR.length+1)..-2]
+ define_method("test_parse_files:#{dir}") do
+ assert_parse_files(dir)
+ end
+ end
+ end
+
+ def assert_parse_files(dir, pattern = "**/*.rb")
+ assert_separately(%W[--disable-gem -rripper - #{SRCDIR}/#{dir} #{pattern}],
+ __FILE__, __LINE__, "#{<<-"begin;"}\n#{<<-'end;'}", timeout: Float::INFINITY)
+ pattern = "#{pattern}"
+ begin;
+ TEST_RATIO = ENV["TEST_RIPPER_RATIO"]&.tap {|s|break s.to_f} || 0.05 # testing all files needs too long time...
+ class Parser < Ripper
+ PARSER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; r.inspect; Object.new end" }
+ SCANNER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; r.inspect; Object.new end" }
+ end
+ dir = ARGV.shift
+ scripts = Dir.chdir(dir) {Dir[pattern]}
+ if (1...scripts.size).include?(num = scripts.size * TEST_RATIO)
+ scripts = scripts.sample(num)
+ end
+ scripts.sort!
+ for script in scripts
+ assert_nothing_raised {
+ parser = Parser.new(File.read("#{dir}/#{script}"), script)
+ parser.instance_eval "parse", "<#{script}>"
+ }
+ end
+ end;
+ end
+end
diff --git a/test/ripper/test_files_ext.rb b/test/ripper/test_files_ext.rb
deleted file mode 100644
index b77ec0fc8d..0000000000
--- a/test/ripper/test_files_ext.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative 'assert_parse_files.rb'
-class TestRipper::Generic
- %w[ext].each do |dir|
- define_method("test_parse_files:#{dir}") do
- assert_parse_files(dir)
- end
- end
-end
diff --git a/test/ripper/test_files_lib.rb b/test/ripper/test_files_lib.rb
deleted file mode 100644
index 19f204da56..0000000000
--- a/test/ripper/test_files_lib.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative 'assert_parse_files.rb'
-class TestRipper::Generic
- %w[lib].each do |dir|
- define_method("test_parse_files:#{dir}") do
- assert_parse_files(dir, "*.rb")
- end
- Dir["#{SRCDIR}/#{dir}/*/"].each do |dir|
- dir = dir[(SRCDIR.length+1)..-2]
- define_method("test_parse_files:#{dir}") do
- assert_parse_files(dir)
- end
- end
- end
-end
diff --git a/test/ripper/test_files_sample.rb b/test/ripper/test_files_sample.rb
deleted file mode 100644
index 57538b1358..0000000000
--- a/test/ripper/test_files_sample.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative 'assert_parse_files.rb'
-class TestRipper::Generic
- %w[sample].each do |dir|
- define_method("test_parse_files:#{dir}") do
- assert_parse_files(dir)
- end
- end
-end
diff --git a/test/ripper/test_files_test.rb b/test/ripper/test_files_test.rb
deleted file mode 100644
index 5a8e368c71..0000000000
--- a/test/ripper/test_files_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require_relative 'assert_parse_files.rb'
-class TestRipper::Generic
- %w[test].each do |dir|
- define_method("test_parse_files:#{dir}") do
- assert_parse_files(dir, "*.rb")
- end
- end
-end
diff --git a/test/ripper/test_files_test_1.rb b/test/ripper/test_files_test_1.rb
deleted file mode 100644
index 25db87783e..0000000000
--- a/test/ripper/test_files_test_1.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative 'assert_parse_files.rb'
-class TestRipper::Generic
- Dir["#{SRCDIR}/test/[-a-n]*/"].each do |dir|
- dir = dir[(SRCDIR.length+1)..-2]
- define_method("test_parse_files:#{dir}") do
- assert_parse_files(dir)
- end
- end
-end
diff --git a/test/ripper/test_files_test_2.rb b/test/ripper/test_files_test_2.rb
deleted file mode 100644
index 24e935e71e..0000000000
--- a/test/ripper/test_files_test_2.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative 'assert_parse_files.rb'
-class TestRipper::Generic
- Dir["#{SRCDIR}/test/[o-z]*/"].each do |dir|
- dir = dir[(SRCDIR.length+1)..-2]
- define_method("test_parse_files:#{dir}") do
- assert_parse_files(dir)
- end
- end
-end
diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb
index 1794773d89..2a1c7881e4 100644
--- a/test/ripper/test_lexer.rb
+++ b/test/ripper/test_lexer.rb
@@ -2,6 +2,7 @@
begin
require 'ripper'
require 'test/unit'
+ ripper_test = true
module TestRipper; end
rescue LoadError
end
@@ -89,53 +90,4 @@ class TestRipper::Lexer < Test::Unit::TestCase
]
assert_equal expect, Ripper.lex(src).map {|e| e[1]}
end
-
- def test_slice
- assert_equal "string\#{nil}\n",
- Ripper.slice(%(<<HERE\nstring\#{nil}\nHERE), "heredoc_beg .*? nl $(.*?) heredoc_end", 1)
- end
-
- def state(name)
- Ripper::Lexer::State.new(Ripper.const_get(name))
- end
-
- def test_state_after_ivar
- assert_equal [[1,0],:on_ivar,"@a",state(:EXPR_END)], Ripper.lex("@a").last
- assert_equal [[1,1],:on_ivar,"@a",state(:EXPR_ENDFN)], Ripper.lex(":@a").last
- assert_equal [[1,1],:on_int,"1",state(:EXPR_END)], Ripper.lex("@1").last
- assert_equal [[1,2],:on_int,"1",state(:EXPR_END)], Ripper.lex(":@1").last
- end
-
- def test_state_after_cvar
- assert_equal [[1,0],:on_cvar,"@@a",state(:EXPR_END)], Ripper.lex("@@a").last
- assert_equal [[1,1],:on_cvar,"@@a",state(:EXPR_ENDFN)], Ripper.lex(":@@a").last
- assert_equal [[1,2],:on_int,"1",state(:EXPR_END)], Ripper.lex("@@1").last
- assert_equal [[1,3],:on_int,"1",state(:EXPR_END)], Ripper.lex(":@@1").last
- end
-
- def test_token_aftr_error_heredoc
- code = "<<A.upcase\n"
- result = Ripper::Lexer.new(code).scan
- message = proc {result.pretty_inspect}
- expected = [
- [[1, 0], :on_heredoc_beg, "<<A", state(:EXPR_BEG)],
- [[1, 2], :compile_error, "A", state(:EXPR_BEG), "can't find string \"A\" anywhere before EOF"],
- [[1, 3], :on_period, ".", state(:EXPR_DOT)],
- [[1, 4], :on_ident, "upcase", state(:EXPR_ARG)],
- [[1, 10], :on_nl, "\n", state(:EXPR_BEG)],
- ]
- pos = 0
- expected.each_with_index do |ex, i|
- s = result[i]
- assert_equal ex, s.to_a, message
- if pos > s.pos[1]
- assert_equal pos, s.pos[1] + s.tok.bytesize, message
- else
- assert_equal pos, s.pos[1], message
- pos += s.tok.bytesize
- end
- end
- assert_equal pos, code.bytesize
- assert_equal expected.size, result.size
- end
end
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index a740c21ae9..2fca61e1d1 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -58,9 +58,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal '[assign(var_field(a),ref(a))]', parse('a=a')
assert_equal '[ref(nil)]', parse('nil')
assert_equal '[ref(true)]', parse('true')
- assert_equal '[vcall(_0)]', parse('_0')
- assert_equal '[vcall(_1)]', parse('_1')
- assert_include parse('proc{_1}'), '[ref(_1)]'
end
def test_vcall
@@ -131,20 +128,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal true, thru_args_new
end
- def test_args_forward
- [
- 'def m(...) n(...) end',
- 'def m(...) end',
- 'def m(a, ...) n(1, ...) end',
- 'def m(...) n(1, ...) end',
- 'def m(a, ...) n(...) end'
- ].each do |code|
- thru_args_forward = false
- parse(code, :on_args_forward) {thru_args_forward = true}
- assert_equal true, thru_args_forward, "no args_forward for: #{code}"
- end
- end
-
def test_arg_paren
# FIXME
end
@@ -491,19 +474,9 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
}
assert_equal true, thru_heredoc_dedent
assert_match(/string_content\(\), heredoc\n/, tree)
- assert_equal(" heredoc\n", str.children[1])
assert_equal(1, width)
end
- def test_unterminated_heredoc
- assert_match("can't find string \"a\" anywhere before EOF", compile_error("<<a"))
- assert_match("can't find string \"a\" anywhere before EOF", compile_error('<<"a"'))
- assert_match("can't find string \"a\" anywhere before EOF", compile_error("<<'a'"))
- msg = nil
- parse('<<"', :on_parse_error) {|_, e| msg = e}
- assert_equal("unterminated here document identifier", msg)
- end
-
def test_massign
thru_massign = false
parse("a, b = 1, 2", :on_massign) {thru_massign = true}
@@ -547,7 +520,7 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
tree = parse("a, *b = 1, 2", :on_mlhs_add_post) {thru_mlhs_add_post = true}
assert_equal false, thru_mlhs_add_post
assert_include(tree, "massign([var_field(a),*var_field(b)],")
- thru_mlhs_add_post = false
+ thru_massign_add_post = false
tree = parse("a, *b, c = 1, 2", :on_mlhs_add_post) {thru_mlhs_add_post = true}
assert_equal true, thru_mlhs_add_post
assert_include(tree, "massign([var_field(a),*var_field(b),var_field(c)],")
@@ -760,12 +733,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal true, thru_ifop
end
- def test_ignored_nl
- ignored_nl = []
- parse("foo # comment\n...\n", :on_ignored_nl) {|_, a| ignored_nl << a}
- assert_equal ["\n"], ignored_nl
- end
-
def test_lambda
thru_lambda = false
parse('->{}', :on_lambda) {thru_lambda = true}
@@ -953,10 +920,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
parse('a {|**x|}', :on_params) {|_, *v| thru_params = true; arg = v}
assert_equal true, thru_params
assert_equal [nil, nil, nil, nil, nil, "**x", nil], arg
- thru_params = false
- parse('a {|**nil|}', :on_params) {|_, *v| thru_params = true; arg = v}
- assert_equal true, thru_params
- assert_equal [nil, nil, nil, nil, nil, :nil, nil], arg
end
def test_params_mlhs
@@ -1166,12 +1129,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal "x", thru_kwrest
end
- def test_nokw_param
- thru_nokw = false
- parse('def a(**nil) end', :on_nokw_param) {|n, val| thru_nokw = val}
- assert_equal nil, thru_nokw
- end
-
def test_retry
thru_retry = false
parse('retry', :on_retry) {thru_retry = true}
@@ -1500,12 +1457,8 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
def test_block_variables
assert_equal("[fcall(proc,[],&block([],[void()]))]", parse("proc{|;y|}"))
if defined?(Process::RLIMIT_AS)
- dir = File.dirname(__FILE__)
- as = 100 * 1024 * 1024 # 100MB
- as *= 2 if RubyVM::MJIT.enabled? # space for compiler
- assert_in_out_err(%W(-I#{dir} -rdummyparser),
- "Process.setrlimit(Process::RLIMIT_AS,#{as}); "\
- "puts DummyParser.new('proc{|;y|!y}').parse",
+ assert_in_out_err(["-I#{File.dirname(__FILE__)}", "-rdummyparser"],
+ 'Process.setrlimit(Process::RLIMIT_AS,100*1024*1024); puts DummyParser.new("proc{|;y|!y}").parse',
["[fcall(proc,[],&block([],[unary(!,ref(y))]))]"], [], '[ruby-dev:39423]')
end
end
@@ -1515,14 +1468,14 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
end
def test_invalid_instance_variable_name
- assert_equal("`@1' is not allowed as an instance variable name", compile_error('proc{@1}'))
- assert_equal("`@' without identifiers is not allowed as an instance variable name", compile_error('@%'))
+ assert_equal("`@1' is not allowed as an instance variable name", compile_error('@1'))
+ assert_equal("`@%' is not allowed as an instance variable name", compile_error('@%'))
assert_equal("`@' without identifiers is not allowed as an instance variable name", compile_error('@'))
end
def test_invalid_class_variable_name
assert_equal("`@@1' is not allowed as a class variable name", compile_error('@@1'))
- assert_equal("`@@' without identifiers is not allowed as a class variable name", compile_error('@@%'))
+ assert_equal("`@@%' is not allowed as a class variable name", compile_error('@@%'))
assert_equal("`@@' without identifiers is not allowed as a class variable name", compile_error('@@'))
end
@@ -1531,6 +1484,13 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal("`$' without identifiers is not allowed as a global variable name", compile_error('$'))
end
+ def test_warning_shadowing
+ fmt, *args = warning("x = 1; tap {|;x|}")
+ assert_match(/shadowing outer local variable/, fmt)
+ assert_equal("x", args[0])
+ assert_match(/x/, fmt % args)
+ end
+
def test_warning_ignored_magic_comment
fmt, *args = warning("1; #-*- frozen-string-literal: true -*-")
assert_match(/ignored after any tokens/, fmt)
@@ -1542,28 +1502,4 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_warn("") {fmt, = warn("\r;")}
assert_match(/encountered/, fmt)
end
-
- def test_warn_mismatched_indentations
- fmt, tokend, tokbeg, line = assert_warning("") {break warn("if true\n end\n")}
- assert_match(/mismatched indentations/, fmt)
- assert_equal(["if", "end", 1], [tokbeg, tokend, line])
- end
-
- def test_in
- thru_in = false
- parse('case 0; in 0; end', :on_in) {thru_in = true}
- assert_equal true, thru_in
- end
-
- def test_aryptn
- thru_aryptn = false
- parse('case 0; in [0]; end', :on_aryptn) {thru_aryptn = true}
- assert_equal true, thru_aryptn
- end
-
- def test_hshptn
- thru_hshptn = false
- parse('case 0; in {a:}; end', :on_hshptn) {thru_hshptn = true}
- assert_equal true, thru_hshptn
- end
end if ripper_test
diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb
index ab841b7616..e7d20a66a0 100644
--- a/test/ripper/test_ripper.rb
+++ b/test/ripper/test_ripper.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
begin
require 'ripper'
- require 'stringio'
require 'test/unit'
ripper_test = true
module TestRipper; end
@@ -66,15 +65,6 @@ class TestRipper::Ripper < Test::Unit::TestCase
assert_predicate @ripper, :yydebug
end
- def test_yydebug_ident
- out = StringIO.new
- ripper = Ripper.new 'test_xxxx'
- ripper.yydebug = true
- ripper.debug_output = out
- ripper.parse
- assert_include out.string[/.*"local variable or method".*/], 'test_xxxx'
- end
-
def test_regexp_with_option
bug11932 = '[ruby-core:72638] [Bug #11932]'
src = '/[\xC0-\xF0]/u'.dup.force_encoding(Encoding::UTF_8)
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
index cef584c157..b815da18f2 100644
--- a/test/ripper/test_scanner_events.rb
+++ b/test/ripper/test_scanner_events.rb
@@ -15,23 +15,13 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
def test_event_coverage
dispatched = Ripper::SCANNER_EVENTS.map {|event,_| event }
dispatched.each do |e|
- assert_respond_to(self, ["test_#{e}", true], "event not tested: #{e}")
+ assert_equal true, respond_to?("test_#{e}", true), "event not tested: #{e}"
end
end
- def scan(target, str, &error)
+ def scan(target, str)
sym = "on_#{target}".intern
- lexer = Ripper::Lexer.new(str)
- if error
- lexer.singleton_class.class_eval do
- define_method(:on_error) {|ev|
- yield __callee__, ev, token()
- }
- alias on_parse_error on_error
- alias compile_error on_error
- end
- end
- lexer.lex.select {|_,type,_| type == sym }.map {|_,_,tok| tok }
+ Ripper.lex(str).select {|_1,type,_2| type == sym }.map {|_1,_2,tok| tok }
end
def test_tokenize
@@ -70,11 +60,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
[[1, 7], :on_rparen, ")", Ripper::EXPR_ENDFN],
[[1, 8], :on_kw, "end", Ripper::EXPR_END]],
Ripper.lex("def m(a)end")
- assert_equal [[[1, 0], :on_int, "1", Ripper::EXPR_END],
+ assert_equal [[[1, 0], :on_int, "1", Ripper::EXPR_END | Ripper::EXPR_ENDARG],
[[1, 1], :on_nl, "\n", Ripper::EXPR_BEG],
- [[2, 0], :on_int, "2", Ripper::EXPR_END],
+ [[2, 0], :on_int, "2", Ripper::EXPR_END | Ripper::EXPR_ENDARG],
[[2, 1], :on_nl, "\n", Ripper::EXPR_BEG],
- [[3, 0], :on_int, "3", Ripper::EXPR_END]],
+ [[3, 0], :on_int, "3", Ripper::EXPR_END | Ripper::EXPR_ENDARG]],
Ripper.lex("1\n2\n3")
assert_equal [[[1, 0], :on_heredoc_beg, "<<""EOS", Ripper::EXPR_BEG],
[[1, 5], :on_nl, "\n", Ripper::EXPR_BEG],
@@ -96,21 +86,21 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
Ripper.lex("/foo\n\u3020/")
assert_equal [[[1, 0], :on_tstring_beg, "'", Ripper::EXPR_BEG],
[[1, 1], :on_tstring_content, "foo\n\xe3\x80\xa0", Ripper::EXPR_BEG],
- [[2, 3], :on_tstring_end, "'", Ripper::EXPR_END]],
+ [[2, 3], :on_tstring_end, "'", Ripper::EXPR_END | Ripper::EXPR_ENDARG]],
Ripper.lex("'foo\n\xe3\x80\xa0'")
assert_equal [[[1, 0], :on_tstring_beg, "'", Ripper::EXPR_BEG],
[[1, 1], :on_tstring_content, "\u3042\n\u3044", Ripper::EXPR_BEG],
- [[2, 3], :on_tstring_end, "'", Ripper::EXPR_END]],
+ [[2, 3], :on_tstring_end, "'", Ripper::EXPR_END | Ripper::EXPR_ENDARG]],
Ripper.lex("'\u3042\n\u3044'")
- assert_equal [[[1, 0], :on_rational, "1r", Ripper::EXPR_END],
+ assert_equal [[[1, 0], :on_rational, "1r", Ripper::EXPR_END | Ripper::EXPR_ENDARG],
[[1, 2], :on_nl, "\n", Ripper::EXPR_BEG],
- [[2, 0], :on_imaginary, "2i", Ripper::EXPR_END],
+ [[2, 0], :on_imaginary, "2i", Ripper::EXPR_END | Ripper::EXPR_ENDARG],
[[2, 2], :on_nl, "\n", Ripper::EXPR_BEG],
- [[3, 0], :on_imaginary, "3ri", Ripper::EXPR_END],
+ [[3, 0], :on_imaginary, "3ri", Ripper::EXPR_END | Ripper::EXPR_ENDARG],
[[3, 3], :on_nl, "\n", Ripper::EXPR_BEG],
- [[4, 0], :on_rational, "4.2r", Ripper::EXPR_END],
+ [[4, 0], :on_rational, "4.2r", Ripper::EXPR_END | Ripper::EXPR_ENDARG],
[[4, 4], :on_nl, "\n", Ripper::EXPR_BEG],
- [[5, 0], :on_imaginary, "5.6ri", Ripper::EXPR_END],
+ [[5, 0], :on_imaginary, "5.6ri", Ripper::EXPR_END | Ripper::EXPR_ENDARG],
],
Ripper.lex("1r\n2i\n3ri\n4.2r\n5.6ri")
assert_equal [[[1, 0], :on_heredoc_beg, "<<~EOS", Ripper::EXPR_BEG],
@@ -270,8 +260,6 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
assert_equal ['#'],
scan('embvar', '"#@@cvar"')
assert_equal [],
- scan('embvar', '"#@1"')
- assert_equal [],
scan('embvar', '"#lvar"')
assert_equal [],
scan('embvar', '"#"')
@@ -752,7 +740,6 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
assert_equal [" E\n\n"],
scan('tstring_content', "<<""'E'\n E\n\n"),
bug10392
- scan('tstring_content', "tap{<<""EOS}\n""there\n""heredoc\#@1xxx\nEOS")
end
def test_heredoc_end
@@ -853,11 +840,6 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('sp', "%w( w )")
assert_equal [],
scan('sp', "p(/ /)")
-
- assert_equal ["\\\n"],
- scan('sp', "\\\n")
- assert_equal ['\ '],
- scan('sp', '\ ')
end
# `nl' event always means End-Of-Statement.
@@ -928,22 +910,6 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('CHAR', "?a")
assert_equal [],
scan('CHAR', "@ivar")
-
- assert_equal ["?\\M-H"], scan('CHAR', '?\\M-H')
-
- assert_equal ["?\\u0041"],
- scan('CHAR', "?\\u0041")
-
- assert_equal ["?\\u{41}"],
- scan('CHAR', "?\\u{41}")
-
- err = nil
- assert_equal [], scan('CHAR', '?\\M ') {|*e| err = e}
- assert_equal([:on_parse_error, "Invalid escape character syntax", "?\\M "], err)
-
- err = nil
- scan('CHAR', '?\u{41 42}') {|*e| err = e}
- assert_equal [:on_parse_error, "Multiple codepoints at single character literal", "42"], err
end
def test_label
@@ -971,21 +937,4 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('tlambda_arg', '-> {}')
end
- def test_invalid_char
- err = nil
- assert_equal(['a'], scan('ident', "\ea") {|*e| err = e})
- assert_equal(:compile_error, err[0])
- assert_match(/Invalid char/, err[1])
- assert_equal("\e", err[2])
- end
-
- def test_invalid_hex_escape
- err = nil
- assert_equal ['U'], scan('tstring_content', '"\\xU"') {|*e| err = e}
- assert_equal [:on_parse_error, "invalid hex escape", "\\x"], err
-
- err = nil
- assert_equal ['U'], scan('tstring_content', '/\\xU/') {|*e| err = e}
- assert_equal [:on_parse_error, "invalid hex escape", "\\x"], err
- end
end if ripper_test
diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb
index 89b45941a3..d63464d5a7 100644
--- a/test/ripper/test_sexp.rb
+++ b/test/ripper/test_sexp.rb
@@ -140,334 +140,4 @@ eot
s,
bug15670)
end
-
- pattern_matching_data = {
- [__LINE__, %q{ case 0; in 0; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in, [:@int, "0", [1, 11]], [[:void_stmt]], nil]],
-
- [__LINE__, %q{ case 0; in 0 if a; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:if_mod, [:vcall, [:@ident, "a", [1, 16]]], [:@int, "0", [1, 11]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in 0 unless a; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:unless_mod, [:vcall, [:@ident, "a", [1, 20]]], [:@int, "0", [1, 11]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in a; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in, [:var_field, [:@ident, "a", [1, 11]]], [[:void_stmt]], nil]],
-
- [__LINE__, %q{ case 0; in a,; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn,
- nil,
- [[:var_field, [:@ident, "a", [1, 11]]]],
- [:var_field, nil],
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in a,b; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn,
- nil,
- [[:var_field, [:@ident, "a", [1, 11]]],
- [:var_field, [:@ident, "b", [1, 13]]]],
- nil,
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in *a; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn, nil, nil, [:var_field, [:@ident, "a", [1, 12]]], nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in *a,b; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn,
- nil,
- nil,
- [:var_field, [:@ident, "a", [1, 12]]],
- [[:var_field, [:@ident, "b", [1, 14]]]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in *a,b,c; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn,
- nil,
- nil,
- [:var_field, [:@ident, "a", [1, 12]]],
- [[:var_field, [:@ident, "b", [1, 14]]],
- [:var_field, [:@ident, "c", [1, 16]]]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in *; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in, [:aryptn, nil, nil, [:var_field, nil], nil], [[:void_stmt]], nil]],
-
- [__LINE__, %q{ case 0; in *,a; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn,
- nil,
- nil,
- [:var_field, nil],
- [[:var_field, [:@ident, "a", [1, 13]]]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in a:,**b; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn,
- nil,
- [[[:@label, "a:", [1, 11]], nil]],
- [:var_field, [:@ident, "b", [1, 16]]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in **a; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn, nil, [], [:var_field, [:@ident, "a", [1, 13]]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in **; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in, [:hshptn, nil, [], nil], [[:void_stmt]], nil]],
-
- [__LINE__, %q{ case 0; in a: 0; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn, nil, [[[:@label, "a:", [1, 11]], [:@int, "0", [1, 14]]]], nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in a:; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn, nil, [[[:@label, "a:", [1, 11]], nil]], nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in "a": 0; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn,
- nil,
- [[[:string_content, [:@tstring_content, "a", [1, 12]]],
- [:@int, "0", [1, 16]]]],
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in "a":; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn,
- nil,
- [[[:string_content, [:@tstring_content, "a", [1, 12]]], nil]],
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in a: 0, b: 0; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn,
- nil,
- [[[:@label, "a:", [1, 11]], [:@int, "0", [1, 14]]],
- [[:@label, "b:", [1, 17]], [:@int, "0", [1, 20]]]],
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in 0 => a; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:binary,
- [:@int, "0", [1, 11]],
- :"=>",
- [:var_field, [:@ident, "a", [1, 16]]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in 0 | 1; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:binary, [:@int, "0", [1, 11]], :|, [:@int, "1", [1, 15]]],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in A(0); end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn,
- [:var_ref, [:@const, "A", [1, 11]]],
- [[:@int, "0", [1, 13]]],
- nil,
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in A(a:); end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn,
- [:var_ref, [:@const, "A", [1, 11]]],
- [[[:@label, "a:", [1, 13]], nil]],
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in A(); end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn, [:var_ref, [:@const, "A", [1, 11]]], nil, nil, nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in A[a]; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn,
- [:var_ref, [:@const, "A", [1, 11]]],
- [[:var_field, [:@ident, "a", [1, 13]]]],
- nil,
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in A[a:]; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn,
- [:var_ref, [:@const, "A", [1, 11]]],
- [[[:@label, "a:", [1, 13]], nil]],
- nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in A[]; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn, [:var_ref, [:@const, "A", [1, 11]]], nil, nil, nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in [a]; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:aryptn, nil, [[:var_field, [:@ident, "a", [1, 12]]]], nil, nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in []; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in, [:aryptn, nil, nil, nil, nil], [[:void_stmt]], nil]],
-
- [__LINE__, %q{ case 0; in {a: 0}; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in,
- [:hshptn, nil, [[[:@label, "a:", [1, 12]], [:@int, "0", [1, 15]]]], nil],
- [[:void_stmt]],
- nil]],
-
- [__LINE__, %q{ case 0; in {}; end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in, [:hshptn, nil, nil, nil], [[:void_stmt]], nil]],
-
- [__LINE__, %q{ case 0; in (0); end }] =>
- [:case,
- [:@int, "0", [1, 5]],
- [:in, [:@int, "0", [1, 12]], [[:void_stmt]], nil]],
-
- [__LINE__, %q{ case 0; in a:, a:; end }] =>
- nil,
-
- [__LINE__, %q{ case 0; in a?:; end }] =>
- nil,
-
- [__LINE__, %q{ case 0; in "A":; end }] =>
- nil,
-
- [__LINE__, %q{ case 0; in "a\x0":a1, "a\0":a2; end }] =>
- nil, # duplicated key name
- }
- pattern_matching_data.each do |(i, src), expected|
- define_method(:"test_pattern_matching_#{i}") do
- sexp = Ripper.sexp(src.strip)
- assert_equal expected, sexp && sexp[1][0], src
- end
- end
-
- def test_hshptn
- parser = Class.new(Ripper::SexpBuilder) do
- def on_label(token)
- [:@label, token]
- end
- end
-
- result = parser.new("#{<<~"begin;"}#{<<~'end;'}").parse
- begin;
- case foo
- in { a: 1 }
- bar
- else
- baz
- end
- end;
-
- hshptn = result.dig(1, 2, 2, 1)
- assert_equal(:hshptn, hshptn[0])
- assert_equal([:@label, "a:"], hshptn.dig(2, 0, 0))
- end
end if ripper_test
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index 86fb91aa18..1bafb02f86 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -1113,11 +1113,8 @@ EOA
:xml_content => target.xhtml,
}
end
- _assert_maker_atom_element(feed_type,
- maker_readers, true,
- feed_readers,
- maker_extractor,
- feed_extractor,
+ _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor,
&block)
end
@@ -1218,11 +1215,8 @@ EOA
:content => target.content,
}
end
- _assert_maker_atom_element(feed_type,
- maker_readers, false,
- feed_readers,
- maker_extractor,
- feed_extractor,
+ _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor,
&block)
end
@@ -1254,21 +1248,13 @@ EOA
end
end
- def _assert_maker_atom_element(feed_type,
- maker_readers,
- maker_readers_need_block,
- feed_readers,
- maker_extractor,
- feed_extractor)
+ def _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor)
_wrap_assertion do
element = nil
feed = RSS::Maker.make("atom:#{feed_type}") do |maker|
yield maker
- if maker_readers_need_block
- target = chain_reader(maker, maker_readers) {|x| x}
- else
- target = chain_reader(maker, maker_readers)
- end
+ target = chain_reader(maker, maker_readers) {|x| x}
element = maker_extractor.call(target)
end
@@ -1476,11 +1462,8 @@ EOA
:content => target.content,
}
end
- _assert_maker_atom_element(feed_type,
- maker_readers, true,
- feed_readers,
- maker_extractor,
- feed_extractor,
+ _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor,
&block)
end
@@ -1522,11 +1505,8 @@ EOA
:content => target.content,
}
end
- _assert_maker_atom_element(feed_type,
- maker_readers, true,
- feed_readers,
- maker_extractor,
- feed_extractor,
+ _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor,
&block)
end
@@ -1643,11 +1623,8 @@ EOA
:uri => target.content,
}
end
- _assert_maker_atom_element(feed_type,
- maker_readers, true,
- feed_readers,
- maker_extractor,
- feed_extractor,
+ _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor,
&block)
end
@@ -1687,11 +1664,8 @@ EOA
nil
end
end
- _assert_maker_atom_element(feed_type,
- maker_readers, true,
- feed_readers,
- maker_extractor,
- feed_extractor,
+ _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor,
&block)
end
@@ -1753,11 +1727,8 @@ EOA
:out_of_line => target.out_of_line?,
}
end
- _assert_maker_atom_element(feed_type,
- maker_readers, true,
- feed_readers,
- maker_extractor,
- feed_extractor,
+ _assert_maker_atom_element(feed_type, maker_readers, feed_readers,
+ maker_extractor, feed_extractor,
&block)
end
diff --git a/test/rss/test_itunes.rb b/test/rss/test_itunes.rb
index 4459d8bfc7..456e0afb20 100644
--- a/test/rss/test_itunes.rb
+++ b/test/rss/test_itunes.rb
@@ -203,18 +203,14 @@ module RSS
_assert_itunes_duration(7, 14, 5, "7:14:05", readers, &rss20_maker)
_assert_itunes_duration(0, 4, 55, "04:55", readers, &rss20_maker)
_assert_itunes_duration(0, 4, 5, "4:05", readers, &rss20_maker)
- _assert_itunes_duration(0, 0, 5, "5", readers, &rss20_maker)
- _assert_itunes_duration(0, 3, 15, "195", readers, &rss20_maker)
- _assert_itunes_duration(1, 0, 1, "3601", readers, &rss20_maker)
+ _assert_itunes_duration_not_available_value("5", &rss20_maker)
_assert_itunes_duration_not_available_value("09:07:14:05", &rss20_maker)
_assert_itunes_duration_not_available_value("10:5", &rss20_maker)
_assert_itunes_duration_not_available_value("10:03:5", &rss20_maker)
_assert_itunes_duration_not_available_value("10:3:05", &rss20_maker)
_assert_itunes_duration_not_available_value("xx:xx:xx", &rss20_maker)
-
- _assert_itunes_duration_not_available_value("", &rss20_maker)
end
end
diff --git a/test/rss/test_maker_itunes.rb b/test/rss/test_maker_itunes.rb
index cba612c099..5b435f5aec 100644
--- a/test/rss/test_maker_itunes.rb
+++ b/test/rss/test_maker_itunes.rb
@@ -250,21 +250,14 @@ module RSS
feed_readers)
_assert_maker_itunes_duration(0, 4, 5, "4:05", maker_readers,
feed_readers)
- _assert_maker_itunes_duration(0, 0, 5, "0:05", maker_readers,
- feed_readers)
- _assert_maker_itunes_duration_by_value(0, 5, 15, "315", maker_readers,
- feed_readers)
- _assert_maker_itunes_duration_by_value(1, 0, 1, "3601", maker_readers,
- feed_readers)
+ _assert_maker_itunes_duration_invalid_value("5", maker_readers)
_assert_maker_itunes_duration_invalid_value("09:07:14:05", maker_readers)
_assert_maker_itunes_duration_invalid_value("10:5", maker_readers)
_assert_maker_itunes_duration_invalid_value("10:03:5", maker_readers)
_assert_maker_itunes_duration_invalid_value("10:3:05", maker_readers)
_assert_maker_itunes_duration_invalid_value("xx:xx:xx", maker_readers)
-
- _assert_maker_itunes_duration_invalid_value("", maker_readers)
end
end
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 19344a0643..7d64657d57 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -19,7 +19,7 @@ EOR
@rss_tmp = Tempfile.new(%w"rss10- .rdf")
@rss_tmp.print(@rss10)
@rss_tmp.close
- @rss_file = @rss_tmp.path
+ @rss_file = @rss_tmp.path.untaint
end
def teardown
@@ -61,61 +61,5 @@ EOR
EOR
end
end
-
- def test_parse_option_validate_nil
- assert_raise(RSS::MissingTagError) do
- RSS::Parser.parse(make_RDF(<<-RDF), :validate => nil)
- RDF
- end
- end
-
- def test_parse_option_validate_true
- assert_raise(RSS::MissingTagError) do
- RSS::Parser.parse(make_RDF(<<-RDF), :validate => true)
- RDF
- end
- end
-
- def test_parse_option_validate_false
- rdf = RSS::Parser.parse(make_RDF(<<-RDF), :validate => false)
- RDF
- assert_nil(rdf.channel)
- end
-
- def test_parse_option_ignore_unknown_element_nil
- assert_nothing_raised do
- RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => nil)
-<unknown/>
-#{make_channel}
-#{make_item}
-#{make_textinput}
-#{make_image}
- RDF
- end
- end
-
- def test_parse_option_ignore_unknown_element_true
- assert_nothing_raised do
- RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => true)
-<unknown/>
-#{make_channel}
-#{make_item}
-#{make_textinput}
-#{make_image}
- RDF
- end
- end
-
- def test_parse_option_ignore_unknown_element_false
- assert_raise(RSS::NotExpectedTagError) do
- RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => false)
-<unknown/>
-#{make_channel}
-#{make_item}
-#{make_textinput}
-#{make_image}
- RDF
- end
- end
end
end
diff --git a/test/rss/test_version.rb b/test/rss/test_version.rb
new file mode 100644
index 0000000000..731e7e5e20
--- /dev/null
+++ b/test/rss/test_version.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: false
+require_relative "rss-testcase"
+
+module RSS
+ class TestVersion < TestCase
+ def test_version
+ assert_equal("0.2.7", ::RSS::VERSION)
+ end
+ end
+end
diff --git a/test/ruby/enc/test_case_comprehensive.rb b/test/ruby/enc/test_case_comprehensive.rb
index bde47017a2..cd6447e928 100644
--- a/test/ruby/enc/test_case_comprehensive.rb
+++ b/test/ruby/enc/test_case_comprehensive.rb
@@ -73,11 +73,7 @@ TestComprehensiveCaseMapping.data_files_available? and class TestComprehensiveC
@@codepoints << code
upcase[code] = hex2utf8 data[12] unless data[12].empty?
downcase[code] = hex2utf8 data[13] unless data[13].empty?
- if code>="\u1C90" and code<="\u1CBF" # exception for Georgian: use lowercase for titlecase
- titlecase[code] = hex2utf8(data[13]) unless data[13].empty?
- else
- titlecase[code] = hex2utf8 data[14] unless data[14].empty?
- end
+ titlecase[code] = hex2utf8 data[14] unless data[14].empty?
end
read_data_file('CaseFolding') do |code, data|
casefold[code] = hex2utf8(data[2]) if data[1] =~ /^[CF]$/
diff --git a/test/ruby/enc/test_case_mapping.rb b/test/ruby/enc/test_case_mapping.rb
index 31acdc4331..d095cd569c 100644
--- a/test/ruby/enc/test_case_mapping.rb
+++ b/test/ruby/enc/test_case_mapping.rb
@@ -187,39 +187,6 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase
assert_equal 0, "\ua64A" =~ /\uA64B/i
end
- def test_georgian_canary
- message = "Reexamine implementation of Georgian in String#capitalize"
- assert_equal false, "\u1CBB".match?(/\p{assigned}/), message
- assert_equal false, "\u1CBC".match?(/\p{assigned}/), message
- end
-
- def test_georgian_unassigned
- message = "Unassigned codepoints should not be converted"
- assert_equal "\u1CBB", "\u1CBB".capitalize, message
- assert_equal "\u1CBC", "\u1CBC".capitalize, message
- end
-
- def test_georgian_capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u1C90\u1C91\u1C92".capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u1C90\u1C91\u10D2".capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u1C90\u10D1\u1C92".capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u1C90\u10D1\u10D2".capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u10D0\u1C91\u1C92".capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u10D0\u1C91\u10D2".capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u10D0\u10D1\u1C92".capitalize
- assert_equal "\u10D0\u10D1\u10D2", "\u10D0\u10D1\u10D2".capitalize
- end
-
- def test_shift_jis_downcase_ascii
- s = ("A".."Z").map {|c| "\x89#{c}"}.join("").force_encoding("Shift_JIS")
- assert_equal s, s.downcase(:ascii)
- end
-
- def test_shift_jis_upcase_ascii
- s = ("a".."z").map {|c| "\x89#{c}"}.join("").force_encoding("Shift_JIS")
- assert_equal s, s.upcase(:ascii)
- end
-
def no_longer_a_test_buffer_allocations
assert_equal 'TURKISH*ı'*10, ('I'*10).downcase(:turkic)
assert_equal 'TURKISH*ı'*100, ('I'*100).downcase(:turkic)
diff --git a/test/ruby/enc/test_cesu8.rb b/test/ruby/enc/test_cesu8.rb
deleted file mode 100644
index d9debe76cd..0000000000
--- a/test/ruby/enc/test_cesu8.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-
-class TestCESU8 < Test::Unit::TestCase
-
- def encdump(obj)
- case obj
- when String
- obj.dump
- when Regexp
- "Regexp.new(#{encdump(obj.source)}, #{obj.options})"
- else
- raise Argument, "unexpected: #{obj.inspect}"
- end
- end
-
- def enccall(recv, meth, *args)
- desc = ''
- if String === recv
- desc << encdump(recv)
- else
- desc << recv.inspect
- end
- desc << '.' << meth.to_s
- if !args.empty?
- desc << '('
- args.each_with_index {|a, i|
- desc << ',' if 0 < i
- if String === a
- desc << encdump(a)
- else
- desc << a.inspect
- end
- }
- desc << ')'
- end
- result = nil
- assert_nothing_raised(desc) {
- result = recv.send(meth, *args)
- }
- result
- end
-
- def assert_str_equal(expected, actual, message=nil)
- full_message = build_message(message, <<EOT)
-#{encdump expected} expected but not equal to
-#{encdump actual}.
-EOT
- assert_equal(expected, actual, full_message)
- end
-
- # tests start
-
- def test_cesu8_valid_encoding
- all_assertions do |a|
- [
- "\x00",
- "\x7f",
- "\u0080",
- "\u07ff",
- "\u0800",
- "\ud7ff",
- "\xed\xa0\x80\xed\xb0\x80",
- "\xed\xaf\xbf\xed\xbf\xbf",
- "\ue000",
- "\uffff",
- ].each {|s|
- s.force_encoding("cesu-8")
- a.for(s) {
- assert_predicate(s, :valid_encoding?, "#{encdump s}.valid_encoding?")
- }
- }
- [
- "\x80",
- "\xc0\x80",
- "\xc0",
- "\xe0\x80\x80",
- "\xed\xa0\x80",
- "\xed\xb0\x80\xed\xb0\x80",
- "\xe0",
- "\xff",
- ].each {|s|
- s.force_encoding("cesu-8")
- a.for(s) {
- assert_not_predicate(s, :valid_encoding?, "#{encdump s}.valid_encoding?")
- }
- }
- end
- end
-
- def test_cesu8_ord
- [
- ["\x00", 0],
- ["\x7f", 0x7f],
- ["\u0080", 0x80],
- ["\u07ff", 0x7ff],
- ["\u0800", 0x800],
- ["\ud7ff", 0xd7ff],
- ["\xed\xa0\x80\xed\xb0\x80", 0x10000],
- ["\xed\xaf\xbf\xed\xbf\xbf", 0x10ffff],
- ["\xee\x80\x80", 0xe000],
- ["\xef\xbf\xbf", 0xffff],
- ].each do |chr, ord|
- chr.force_encoding("cesu-8")
- assert_equal ord, chr.ord
- assert_equal chr, ord.chr("cesu-8")
- end
- end
-end
diff --git a/test/ruby/enc/test_emoji_breaks.rb b/test/ruby/enc/test_emoji_breaks.rb
deleted file mode 100644
index 7048d8d59f..0000000000
--- a/test/ruby/enc/test_emoji_breaks.rb
+++ /dev/null
@@ -1,122 +0,0 @@
-# frozen_string_literal: true
-# Copyright © 2018 Martin J. Dürst (duerst@it.aoyama.ac.jp)
-
-require "test/unit"
-
-class TestEmojiBreaks < Test::Unit::TestCase
-end
-
-class TestEmojiBreaks::BreakTest
- attr_reader :string, :comment, :filename, :line_number, :type, :shortname
-
- def initialize(filename, line_number, data, comment='')
- @filename = filename
- @line_number = line_number
- @comment = comment.gsub(/\s+/, ' ').strip
- if filename=='emoji-test'
- codes, @type = data.split(/\s*;\s*/)
- @shortname = ''
- else
- codes, @type, @shortname = data.split(/\s*;\s*/)
- end
- @type = @type.gsub(/\s+/, ' ').strip
- @shortname = @shortname.gsub(/\s+/, ' ').strip
- @string = codes.split(/\s+/)
- .map do |ch|
- c = ch.to_i(16)
- # eliminate cases with surrogates
- # raise ArgumentError if 0xD800 <= c and c <= 0xDFFF
- c.chr('UTF-8')
- end.join
- end
-end
-
-class TestEmojiBreaks < Test::Unit::TestCase
- EMOJI_DATA_FILES = %w[emoji-sequences emoji-test emoji-variation-sequences emoji-zwj-sequences]
- EMOJI_VERSION = RbConfig::CONFIG['UNICODE_EMOJI_VERSION']
- EMOJI_DATA_PATH = File.expand_path("../../../enc/unicode/data/emoji/#{EMOJI_VERSION}", __dir__)
-
- def self.expand_filename(basename)
- File.expand_path("#{EMOJI_DATA_PATH}/#{basename}.txt", __dir__)
- end
-
- def self.data_files_available?
- EMOJI_DATA_FILES.all? do |f|
- File.exist?(expand_filename(f))
- end
- end
-
- def test_data_files_available
- unless TestEmojiBreaks.data_files_available?
- skip "Emoji data files not available in #{EMOJI_DATA_PATH}."
- end
- end
-end
-
-TestEmojiBreaks.data_files_available? and class TestEmojiBreaks
- def read_data
- tests = []
- EMOJI_DATA_FILES.each do |filename|
- version_mismatch = true
- file_tests = []
- IO.foreach(TestEmojiBreaks.expand_filename(filename), encoding: Encoding::UTF_8) do |line|
- line.chomp!
- raise "File Name Mismatch" if $.==1 and not line=="# #{filename}.txt"
- version_mismatch = false if line=="# Version: #{EMOJI_VERSION}"
- next if /\A(#|\z)/.match? line
- file_tests << BreakTest.new(filename, $., *line.split('#')) rescue 'whatever'
- end
- raise "File Version Mismatch" if version_mismatch
- tests += file_tests
- end
- tests
- end
-
- def all_tests
- @@tests ||= read_data
- rescue Errno::ENOENT
- @@tests ||= []
- end
-
- def test_single_emoji
- all_tests.each do |test|
- expected = [test.string]
- actual = test.string.each_grapheme_cluster.to_a
- assert_equal expected, actual,
- "file: #{test.filename}, line #{test.line_number}, " +
- "type: #{test.type}, shortname: #{test.shortname}, comment: #{test.comment}"
- end
- end
-
- def test_embedded_emoji
- all_tests.each do |test|
- expected = ["\t", test.string, "\t"]
- actual = "\t#{test.string}\t".each_grapheme_cluster.to_a
- assert_equal expected, actual,
- "file: #{test.filename}, line #{test.line_number}, " +
- "type: #{test.type}, shortname: #{test.shortname}, comment: #{test.comment}"
- end
- end
-
- # test some pseodorandom combinations of emoji
- def test_mixed_emoji
- srand 0
- length = all_tests.length
- step = 503 # use a prime number
- all_tests.each do |test1|
- start = rand step
- start.step(by: step, to: length-1) do |t2|
- test2 = all_tests[t2]
- # exclude skin tones, because they glue to previous grapheme clusters
- next if (0x1F3FB..0x1F3FF).include? test2.string.ord
- expected = [test1.string, test2.string]
- actual = (test1.string+test2.string).each_grapheme_cluster.to_a
- assert_equal expected, actual,
- "file1: #{test1.filename}, line1 #{test1.line_number}, " +
- "file2: #{test2.filename}, line2 #{test2.line_number},\n" +
- "type1: #{test1.type}, shortname1: #{test1.shortname}, comment1: #{test1.comment},\n" +
- "type2: #{test2.type}, shortname2: #{test2.shortname}, comment2: #{test2.comment}"
- end
- end
- end
-end
diff --git a/test/ruby/enc/test_grapheme_breaks.rb b/test/ruby/enc/test_grapheme_breaks.rb
index 2d210946a9..7f6c776113 100644
--- a/test/ruby/enc/test_grapheme_breaks.rb
+++ b/test/ruby/enc/test_grapheme_breaks.rb
@@ -3,13 +3,10 @@
require "test/unit"
-class TestGraphemeBreaksFromFile < Test::Unit::TestCase
-end
-
-class TestGraphemeBreaksFromFile::BreakTest
+class BreakTest
attr_reader :clusters, :string, :comment, :line_number
- def initialize(line_number, data, comment)
+ def initialize (line_number, data, comment)
@line_number = line_number
@comment = comment
@clusters = data.sub(/\A\s*÷\s*/, '')
diff --git a/test/ruby/marshaltestlib.rb b/test/ruby/marshaltestlib.rb
index 5c48a8d853..358d3c5133 100644
--- a/test/ruby/marshaltestlib.rb
+++ b/test/ruby/marshaltestlib.rb
@@ -110,9 +110,7 @@ module MarshalTestLib
class MyException < Exception; def initialize(v, *args) super(*args); @v = v; end; attr_reader :v; end
def test_exception
marshal_equal(Exception.new('foo')) {|o| o.message}
- obj = Object.new
- e = assert_raise(NoMethodError) {obj.no_such_method()}
- marshal_equal(e) {|o| o.message}
+ marshal_equal(assert_raise(NoMethodError) {no_such_method()}) {|o| o.message}
end
def test_exception_subclass
diff --git a/test/ruby/sentence.rb b/test/ruby/sentence.rb
index 9bfd7c7599..28fb5d1cf8 100644
--- a/test/ruby/sentence.rb
+++ b/test/ruby/sentence.rb
@@ -353,7 +353,7 @@ class Sentence
# * No rule derives to empty sequence
# * Underivable rule simplified
# * No channel rule
- # * Symbols which has zero or one choices are not appeared in rhs.
+ # * Symbols which has zero or one choices are not appered in rhs.
#
# Note that the rules which can derive empty and non-empty
# sequences are modified to derive only non-empty sequences.
diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb
index 1acf12f7f3..e81636fa43 100644
--- a/test/ruby/test_alias.rb
+++ b/test/ruby/test_alias.rb
@@ -47,6 +47,12 @@ class TestAlias < Test::Unit::TestCase
assert_raise(NoMethodError) { x.quux }
end
+ class C
+ def m
+ $SAFE
+ end
+ end
+
def test_nonexistmethod
assert_raise(NameError){
Class.new{
@@ -227,33 +233,4 @@ class TestAlias < Test::Unit::TestCase
assert_equal(:foo, k.instance_method(:bar).original_name)
assert_equal(:foo, name)
end
-
- def test_alias_suppressing_redefinition
- assert_in_out_err(%w[-w], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- class A
- def foo; end
- alias foo foo
- def foo; end
- end
- end;
- end
-
- def test_alias_memory_leak
- assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~'end;'}", rss: true)
- begin;
- class A
- 500.times do
- 1000.times do |i|
- define_method(:"foo_#{i}") {}
-
- alias :"foo_#{i}" :"foo_#{i}"
-
- remove_method :"foo_#{i}"
- end
- GC.start
- end
- end
- end;
- end
end
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index 5c2356524f..311469aad9 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -35,8 +35,8 @@ class TestArgf < Test::Unit::TestCase
open("#{@tmpdir}/#{basename}-#{@tmp_count}", "w")
end
- def make_tempfile(basename = "argf-qux")
- t = make_tempfile0(basename)
+ def make_tempfile
+ t = make_tempfile0("argf-qux")
t.puts "foo"
t.puts "bar"
t.puts "baz"
@@ -255,26 +255,6 @@ class TestArgf < Test::Unit::TestCase
assert_warning(/#{base}/) {argf.gets}
end
- def test_inplace_nonascii
- ext = Encoding.default_external or
- skip "no default external encoding"
- t = nil
- ["\u{3042}", "\u{e9}"].any? do |n|
- t = make_tempfile(n.encode(ext))
- rescue Encoding::UndefinedConversionError
- end
- t or skip "no name to test"
- assert_in_out_err(["-i.bak", "-", t.path],
- "#{<<~"{#"}\n#{<<~'};'}")
- {#
- puts ARGF.gets.chomp + '.new'
- puts ARGF.gets.chomp + '.new'
- puts ARGF.gets.chomp + '.new'
- };
- assert_equal("foo.new\n""bar.new\n""baz.new\n", File.read(t.path))
- assert_equal("foo\n""bar\n""baz\n", File.read(t.path + ".bak"))
- end
-
def test_inplace_no_backup
t = make_tempfile
@@ -725,13 +705,6 @@ class TestArgf < Test::Unit::TestCase
["\"a\\n\\n\"", "\"b\\n\""], [])
end
- def test_each_line_chomp
- assert_in_out_err(['-e', 'ARGF.each_line(chomp: false) {|para| p para}'], "a\nb\n",
- ["\"a\\n\"", "\"b\\n\""], [])
- assert_in_out_err(['-e', 'ARGF.each_line(chomp: true) {|para| p para}'], "a\nb\n",
- ["\"a\"", "\"b\""], [])
- end
-
def test_each_byte
ruby('-e', "#{<<~"{#"}\n#{<<~'};'}", @t1.path, @t2.path, @t3.path) do |f|
{#
@@ -991,6 +964,7 @@ class TestArgf < Test::Unit::TestCase
ARGF.lines {|l| s << l }
p s
};
+ assert_match(/deprecated/, f.gets)
assert_equal("[\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\"]\n", f.read)
end
end
@@ -1001,6 +975,7 @@ class TestArgf < Test::Unit::TestCase
$stderr = $stdout
print Marshal.dump(ARGF.bytes.to_a)
};
+ assert_match(/deprecated/, f.gets)
assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
end
end
@@ -1011,6 +986,7 @@ class TestArgf < Test::Unit::TestCase
$stderr = $stdout
print [Marshal.dump(ARGF.chars.to_a)].pack('m')
};
+ assert_match(/deprecated/, f.gets)
assert_equal(["1", "\n", "2", "\n", "3", "\n", "4", "\n", "5", "\n", "6", "\n"], Marshal.load(f.read.unpack('m').first))
end
end
@@ -1021,6 +997,7 @@ class TestArgf < Test::Unit::TestCase
$stderr = $stdout
print Marshal.dump(ARGF.codepoints.to_a)
};
+ assert_match(/deprecated/, f.gets)
assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
end
end
diff --git a/test/ruby/test_arithmetic_sequence.rb b/test/ruby/test_arithmetic_sequence.rb
deleted file mode 100644
index 755f54ac5a..0000000000
--- a/test/ruby/test_arithmetic_sequence.rb
+++ /dev/null
@@ -1,494 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-
-class TestArithmeticSequence < Test::Unit::TestCase
- def test_new
- assert_raise(NoMethodError) { Enumerator::ArithmeticSequence.new }
- end
-
- def test_allocate
- assert_raise(TypeError) { Enumerator::ArithmeticSequence.allocate }
- end
-
- def test_begin
- assert_equal(1, 1.step.begin)
- assert_equal(1, 1.step(10).begin)
- assert_equal(1, 1.step(to: 10).begin)
- assert_equal(1, 1.step(nil).begin)
- assert_equal(1, 1.step(to: nil).begin)
- assert_equal(1, 1.step(by: 2).begin)
- assert_equal(1, 1.step(by: -1).begin)
- assert_equal(1, 1.step(by: nil).begin)
- assert_equal(1, 1.step(10, 2).begin)
- assert_equal(1, 1.step(10, by: 2).begin)
- assert_equal(1, 1.step(to: 10, by: 2).begin)
- assert_equal(10, 10.step(to: 1, by: -1).begin)
- assert_equal(10, 10.step(to: 1, by: -2).begin)
- assert_equal(10, 10.step(to: -1, by: -2).begin)
- assert_equal(10.0, 10.0.step(to: -1.0, by: -2.0).begin)
-
- assert_equal(3, (3..).step(2).begin)
- assert_equal(4, (4...).step(7).begin)
- assert_equal(nil, (..10).step(9).begin)
- assert_equal(nil, (...11).step(5).begin)
- end
-
- def test_end
- assert_equal(nil, 1.step.end)
- assert_equal(10, 1.step(10).end)
- assert_equal(10, 1.step(to: 10).end)
- assert_equal(nil, 1.step(nil).end)
- assert_equal(nil, 1.step(to: nil).end)
- assert_equal(nil, 1.step(by: 2).end)
- assert_equal(nil, 1.step(by: -1).end)
- assert_equal(nil, 1.step(by: nil).end)
- assert_equal(10, 1.step(10, 2).end)
- assert_equal(10, 1.step(10, by: 2).end)
- assert_equal(10, 1.step(to: 10, by: 2).end)
- assert_equal(1, 10.step(to: 1, by: -1).end)
- assert_equal(1, 10.step(to: 1, by: -2).end)
- assert_equal(-1, 10.step(to: -1, by: -2).end)
- assert_equal(-1.0, 10.0.step(to: -1.0, by: -2.0).end)
-
- assert_equal(nil, (3..).step(2).end)
- assert_equal(nil, (4...).step(7).end)
- assert_equal(10, (..10).step(9).end)
- assert_equal(11, (...11).step(5).end)
- end
-
- def test_exclude_end_p
- assert_equal(false, 1.step.exclude_end?)
- assert_equal(false, 1.step(10).exclude_end?)
- assert_equal(false, 1.step(to: 10).exclude_end?)
- assert_equal(false, 1.step(nil).exclude_end?)
- assert_equal(false, 1.step(to: nil).exclude_end?)
- assert_equal(false, 1.step(by: 2).exclude_end?)
- assert_equal(false, 1.step(by: -1).exclude_end?)
- assert_equal(false, 1.step(by: nil).exclude_end?)
- assert_equal(false, 1.step(10, 2).exclude_end?)
- assert_equal(false, 1.step(10, by: 2).exclude_end?)
- assert_equal(false, 1.step(to: 10, by: 2).exclude_end?)
- assert_equal(false, 10.step(to: 1, by: -1).exclude_end?)
- assert_equal(false, 10.step(to: 1, by: -2).exclude_end?)
- assert_equal(false, 10.step(to: -1, by: -2).exclude_end?)
-
- assert_equal(false, (3..).step(2).exclude_end?)
- assert_equal(true, (4...).step(7).exclude_end?)
- assert_equal(false, (..10).step(9).exclude_end?)
- assert_equal(true, (...11).step(5).exclude_end?)
- end
-
- def test_step
- assert_equal(1, 1.step.step)
- assert_equal(1, 1.step(10).step)
- assert_equal(1, 1.step(to: 10).step)
- assert_equal(1, 1.step(nil).step)
- assert_equal(1, 1.step(to: nil).step)
- assert_equal(2, 1.step(by: 2).step)
- assert_equal(-1, 1.step(by: -1).step)
- assert_equal(1, 1.step(by: nil).step)
- assert_equal(2, 1.step(10, 2).step)
- assert_equal(2, 1.step(10, by: 2).step)
- assert_equal(2, 1.step(to: 10, by: 2).step)
- assert_equal(-1, 10.step(to: 1, by: -1).step)
- assert_equal(-2, 10.step(to: 1, by: -2).step)
- assert_equal(-2, 10.step(to: -1, by: -2).step)
- assert_equal(-2.0, 10.0.step(to: -1.0, by: -2.0).step)
-
- assert_equal(2, (3..).step(2).step)
- assert_equal(7, (4...).step(7).step)
- assert_equal(9, (..10).step(9).step)
- assert_equal(5, (...11).step(5).step)
- end
-
- def test_eq
- seq = 1.step
- assert_equal(seq, seq)
- assert_equal(seq, 1.step)
- assert_equal(seq, 1.step(nil))
- end
-
- def test_eqq
- seq = 1.step
- assert_operator(seq, :===, seq)
- assert_operator(seq, :===, 1.step)
- assert_operator(seq, :===, 1.step(nil))
- end
-
- def test_eql_p
- seq = 1.step
- assert_operator(seq, :eql?, seq)
- assert_operator(seq, :eql?, 1.step)
- assert_operator(seq, :eql?, 1.step(nil))
- end
-
- def test_hash
- seq = 1.step
- assert_equal(seq.hash, seq.hash)
- assert_equal(seq.hash, 1.step.hash)
- assert_equal(seq.hash, 1.step(nil).hash)
- assert_kind_of(String, seq.hash.to_s)
- end
-
- def test_first
- seq = 1.step
- assert_equal(1, seq.first)
- assert_equal([1], seq.first(1))
- assert_equal([1, 2, 3], seq.first(3))
-
- seq = 1.step(by: 2)
- assert_equal(1, seq.first)
- assert_equal([1], seq.first(1))
- assert_equal([1, 3, 5], seq.first(3))
-
- seq = 10.step(by: -2)
- assert_equal(10, seq.first)
- assert_equal([10], seq.first(1))
- assert_equal([10, 8, 6], seq.first(3))
-
- seq = 1.step(by: 4)
- assert_equal([1, 5, 9], seq.first(3))
-
- seq = 1.step(10, by: 4)
- assert_equal([1, 5, 9], seq.first(5))
-
- seq = 1.step(0)
- assert_equal(nil, seq.first)
- assert_equal([], seq.first(1))
- assert_equal([], seq.first(3))
-
- seq = 1.step(10, by: -1)
- assert_equal(nil, seq.first)
- assert_equal([], seq.first(1))
- assert_equal([], seq.first(3))
-
- seq = 1.step(10, by: 0)
- assert_equal(1, seq.first)
- assert_equal([1], seq.first(1))
- assert_equal([1, 1, 1], seq.first(3))
-
- seq = 10.0.step(-1.0, by: -2.0)
- assert_equal(10.0, seq.first)
- assert_equal([10.0], seq.first(1))
- assert_equal([10.0, 8.0, 6.0], seq.first(3))
-
- seq = (1..).step(2)
- assert_equal(1, seq.first)
- assert_equal([1], seq.first(1))
- assert_equal([1, 3, 5], seq.first(3))
-
- seq = (..10).step(2)
- assert_equal(nil, seq.first)
- assert_raise(TypeError) { seq.first(1) }
- assert_raise(TypeError) { seq.first(3) }
- end
-
- def test_first_bug15518
- bug15518 = '[Bug #15518]'
- seq = (1 .. 10.0).step(1)
- five_float_classes = Array.new(5) { Float }
- assert_equal(five_float_classes, seq.first(5).map(&:class), bug15518)
- assert_equal([1.0, 2.0, 3.0, 4.0, 5.0], seq.first(5), bug15518)
- seq = (1 .. Float::INFINITY).step(1)
- assert_equal(five_float_classes, seq.first(5).map(&:class), bug15518)
- assert_equal([1.0, 2.0, 3.0, 4.0, 5.0], seq.first(5), bug15518)
- seq = (1 .. Float::INFINITY).step(1r)
- assert_equal(five_float_classes, seq.first(5).map(&:class), bug15518)
- assert_equal([1.0, 2.0, 3.0, 4.0, 5.0], seq.first(5), bug15518)
- end
-
- def test_last
- seq = 1.step(10)
- assert_equal(10, seq.last)
- assert_equal([10], seq.last(1))
- assert_equal([8, 9, 10], seq.last(3))
-
- seq = 1.step(10, 2)
- assert_equal(9, seq.last)
- assert_equal([9], seq.last(1))
- assert_equal([5, 7, 9], seq.last(3))
-
- seq = 10.step(1, -2)
- assert_equal(2, seq.last)
- assert_equal([2], seq.last(1))
- assert_equal([6, 4, 2], seq.last(3))
-
- seq = 10.step(-1, -2)
- assert_equal(0, seq.last)
-
- seq = 1.step(10, 4)
- assert_equal([1, 5, 9], seq.last(5))
-
- seq = 10.step(1)
- assert_equal(nil, seq.last)
- assert_equal([], seq.last(1))
- assert_equal([], seq.last(5))
-
- seq = 1.step(10, -1)
- assert_equal(nil, seq.last)
- assert_equal([], seq.last(1))
- assert_equal([], seq.last(5))
-
- seq = (1..10).step
- assert_equal(10, seq.last)
- assert_equal([10], seq.last(1))
- assert_equal([8, 9, 10], seq.last(3))
-
- seq = (1...10).step
- assert_equal(9, seq.last)
- assert_equal([9], seq.last(1))
- assert_equal([7, 8, 9], seq.last(3))
-
- seq = 10.0.step(-3.0, by: -2.0)
- assert_equal(-2.0, seq.last)
- assert_equal([-2.0], seq.last(1))
- assert_equal([2.0, 0.0, -2.0], seq.last(3))
- end
-
- def test_last_with_float
- res = (1..3).step(2).last(2.0)
- assert_equal([1, 3], res)
- assert_instance_of Integer, res[0]
- assert_instance_of Integer, res[1]
-
- res = (1..3).step(2).last(5.0)
- assert_equal([1, 3], res)
- assert_instance_of Integer, res[0]
- assert_instance_of Integer, res[1]
- end
-
- def test_last_with_rational
- res = (1..3).step(2).last(2r)
- assert_equal([1, 3], res)
- assert_instance_of Integer, res[0]
- assert_instance_of Integer, res[1]
-
- res = (1..3).step(2).last(10/2r)
- assert_equal([1, 3], res)
- assert_instance_of Integer, res[0]
- assert_instance_of Integer, res[1]
- end
-
- def test_to_a
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 1.step(10).to_a)
- assert_equal([1, 3, 5, 7, 9], 1.step(10, 2).to_a)
- assert_equal([1, 3, 5, 7, 9], (1..10).step(2).to_a)
- assert_equal([10, 8, 6, 4, 2], 10.step(1, by: -2).to_a)
- assert_equal([10, 8, 6, 4, 2], (10..1).step(-2).to_a)
- assert_equal([10.0, 8.0, 6.0, 4.0, 2.0], (10.0..1.0).step(-2.0).to_a)
- end
-
- def test_to_a_bug15444
- seq = ((1/10r)..(1/2r)).step(1/10r)
- assert_num_equal_type([1/10r, 1/5r, 3/10r, 2/5r, 1/2r], seq.to_a,
- '[ruby-core:90648] [Bug #15444]')
- end
-
- def test_last_bug17218
- seq = (1.0997r .. 1.1r).step(0.0001r)
- assert_equal([1.0997r, 1.0998r, 1.0999r, 1.1r], seq.to_a, '[ruby-core:100312] [Bug #17218]')
- end
-
- def test_slice
- seq = 1.step(10, 2)
- assert_equal([[1, 3, 5], [7, 9]], seq.each_slice(3).to_a)
-
- seq = 10.step(1, -2)
- assert_equal([[10, 8, 6], [4, 2]], seq.each_slice(3).to_a)
- end
-
- def test_cons
- seq = 1.step(10, 2)
- assert_equal([[1, 3, 5], [3, 5, 7], [5, 7, 9]], seq.each_cons(3).to_a)
-
- seq = 10.step(1, -2)
- assert_equal([[10, 8, 6], [8, 6, 4], [6, 4, 2]], seq.each_cons(3).to_a)
- end
-
- def test_with_index
- seq = 1.step(6, 2)
- assert_equal([[1, 0], [3, 1], [5, 2]], seq.with_index.to_a)
- assert_equal([[1, 10], [3, 11], [5, 12]], seq.with_index(10).to_a)
-
- seq = 10.step(5, -2)
- assert_equal([[10, 0], [8, 1], [6, 2]], seq.with_index.to_a)
- assert_equal([[10, 10], [8, 11], [6, 12]], seq.with_index(10).to_a)
- end
-
- def test_with_object
- obj = [0, 1]
- seq = 1.step(10, 2)
- ret = seq.each_with_object(obj) do |i, memo|
- memo[0] += i
- memo[1] *= i
- end
- assert_same(obj, ret)
- assert_equal([25, 945], ret)
-
- obj = [0, 1]
- seq = 10.step(1, -2)
- ret = seq.each_with_object(obj) do |i, memo|
- memo[0] += i
- memo[1] *= i
- end
- assert_same(obj, ret)
- assert_equal([30, 3840], ret)
- end
-
- def test_next
- seq = 1.step(10, 2)
- [1, 3, 5, 7, 9].each do |i|
- assert_equal(i, seq.next)
- end
-
- seq = 10.step(1, -2)
- [10, 8, 6, 4, 2].each do |i|
- assert_equal(i, seq.next)
- end
-
- seq = ((1/10r)..(1/2r)).step(0)
- assert_equal(1/10r, seq.next)
- end
-
- def test_next_bug15444
- seq = ((1/10r)..(1/2r)).step(1/10r)
- assert_equal(1/10r, seq.next, '[ruby-core:90648] [Bug #15444]')
- end
-
- def test_next_rewind
- seq = 1.step(6, 2)
- assert_equal(1, seq.next)
- assert_equal(3, seq.next)
- seq.rewind
- assert_equal(1, seq.next)
- assert_equal(3, seq.next)
- assert_equal(5, seq.next)
- assert_raise(StopIteration) { seq.next }
-
- seq = 10.step(5, -2)
- assert_equal(10, seq.next)
- assert_equal(8, seq.next)
- seq.rewind
- assert_equal(10, seq.next)
- assert_equal(8, seq.next)
- assert_equal(6, seq.next)
- assert_raise(StopIteration) { seq.next }
- end
-
- def test_next_after_stopiteration
- seq = 1.step(2, 2)
- assert_equal(1, seq.next)
- assert_raise(StopIteration) { seq.next }
- assert_raise(StopIteration) { seq.next }
- seq.rewind
- assert_equal(1, seq.next)
- assert_raise(StopIteration) { seq.next }
- assert_raise(StopIteration) { seq.next }
- end
-
- def test_stop_result
- seq = 1.step(2, 2)
- res = seq.each {}
- assert_equal(1, seq.next)
- exc = assert_raise(StopIteration) { seq.next }
- assert_equal(res, exc.result)
- end
-
- def test_peek
- seq = 1.step(2, 2)
- assert_equal(1, seq.peek)
- assert_equal(1, seq.peek)
- assert_equal(1, seq.next)
- assert_raise(StopIteration) { seq.peek }
- assert_raise(StopIteration) { seq.peek }
-
- seq = 10.step(9, -2)
- assert_equal(10, seq.peek)
- assert_equal(10, seq.peek)
- assert_equal(10, seq.next)
- assert_raise(StopIteration) { seq.peek }
- assert_raise(StopIteration) { seq.peek }
- end
-
- def test_next_values
- seq = 1.step(2, 2)
- assert_equal([1], seq.next_values)
- end
-
- def test_peek_values
- seq = 1.step(2, 2)
- assert_equal([1], seq.peek_values)
- end
-
- def test_num_step_inspect
- assert_equal('(1.step)', 1.step.inspect)
- assert_equal('(1.step(10))', 1.step(10).inspect)
- assert_equal('(1.step(10, 2))', 1.step(10, 2).inspect)
- assert_equal('(1.step(10, by: 2))', 1.step(10, by: 2).inspect)
- assert_equal('(1.step(by: 2))', 1.step(by: 2).inspect)
- end
-
- def test_range_step_inspect
- assert_equal('((1..).step)', (1..).step.inspect)
- assert_equal('((1..10).step)', (1..10).step.inspect)
- assert_equal('((1..10).step(2))', (1..10).step(2).inspect)
- end
-
- def test_num_step_size
- assert_equal(10, 1.step(10).size)
- assert_equal(5, 1.step(10, 2).size)
- assert_equal(4, 1.step(10, 3).size)
- assert_equal(1, 1.step(10, 10).size)
- assert_equal(0, 1.step(0).size)
- assert_equal(Float::INFINITY, 1.step.size)
-
- assert_equal(10, 10.step(1, -1).size)
- assert_equal(5, 10.step(1, -2).size)
- assert_equal(4, 10.step(1, -3).size)
- assert_equal(1, 10.step(1, -10).size)
- assert_equal(0, 1.step(2, -1).size)
- assert_equal(Float::INFINITY, 1.step(by: -1).size)
- end
-
- def test_range_step_size
- assert_equal(10, (1..10).step.size)
- assert_equal(9, (1...10).step.size)
- assert_equal(5, (1..10).step(2).size)
- assert_equal(5, (1...10).step(2).size)
- assert_equal(4, (1...9).step(2).size)
- assert_equal(Float::INFINITY, (1..).step.size)
-
- assert_equal(10, (10..1).step(-1).size)
- assert_equal(9, (10...1).step(-1).size)
- assert_equal(5, (10..1).step(-2).size)
- assert_equal(5, (10...1).step(-2).size)
- assert_equal(4, (10...2).step(-2).size)
- assert_equal(Float::INFINITY, (1..).step(-1).size)
- end
-
- def assert_num_equal_type(ary1, ary2, message=nil)
- assert_equal(ary1.length, ary2.length, message)
- ary1.zip(ary2) do |e1, e2|
- assert_equal(e1.class, e2.class, message)
- if e1.is_a? Complex
- assert_equal(e1.real, e2.real, message)
- assert_equal(e1.imag, e2.imag, message)
- else
- assert_equal(e1, e2, message)
- end
- end
- end
-
- def test_complex
- assert_num_equal_type([1, 1+1i, 1+2i], (1..).step(1i).take(3))
- assert_num_equal_type([1, 1+1.0i, 1+2.0i], (1..).step(1.0i).take(3))
- assert_num_equal_type([0.0, 0.0+1.0i, 0.0+2.0i], (0.0..).step(1.0i).take(3))
- assert_num_equal_type([0.0+0.0i, 0.0+1.0i, 0.0+2.0i], (0.0i..).step(1.0i).take(3))
- end
-
- def test_sum
- assert_equal([1, 3, 5, 7, 9].sum, (1..10).step(2).sum)
- assert_equal([1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0].sum, (1.0..10.0).step(1.5).sum)
- assert_equal([1/2r, 1r, 3/2r, 2, 5/2r, 3, 7/2r, 4].sum, ((1/2r)...(9/2r)).step(1/2r).sum)
- end
-end
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index f2956a7fba..3212ed3aca 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -41,9 +41,6 @@ class TestArray < Test::Unit::TestCase
assert_equal(2, x[2])
assert_equal([1, 2, 3], x[1..3])
assert_equal([1, 2, 3], x[1,3])
- assert_equal([3, 4, 5], x[3..])
- assert_equal([0, 1, 2], x[..2])
- assert_equal([0, 1], x[...2])
x[0, 2] = 10
assert_equal([10, 2, 3, 4, 5], x)
@@ -148,17 +145,14 @@ class TestArray < Test::Unit::TestCase
assert_equal(1, x.first)
assert_equal([1], x.first(1))
assert_equal([1, 2, 3], x.first(3))
- assert_raise_with_message(ArgumentError, /0\.\.1/) {x.first(1, 2)}
assert_equal(5, x.last)
assert_equal([5], x.last(1))
assert_equal([3, 4, 5], x.last(3))
- assert_raise_with_message(ArgumentError, /0\.\.1/) {x.last(1, 2)}
assert_equal(1, x.shift)
assert_equal([2, 3, 4], x.shift(3))
assert_equal([5], x)
- assert_raise_with_message(ArgumentError, /0\.\.1/) {x.first(1, 2)}
assert_equal([2, 3, 4, 5], x.unshift(2, 3, 4))
assert_equal([1, 2, 3, 4, 5], x.unshift(1))
@@ -167,7 +161,6 @@ class TestArray < Test::Unit::TestCase
assert_equal(5, x.pop)
assert_equal([3, 4], x.pop(2))
assert_equal([1, 2], x)
- assert_raise_with_message(ArgumentError, /0\.\.1/) {x.pop(1, 2)}
assert_equal([1, 2, 3, 4], x.push(3, 4))
assert_equal([1, 2, 3, 4, 5], x.push(5))
@@ -177,7 +170,6 @@ class TestArray < Test::Unit::TestCase
def test_find_all_0
assert_respond_to([], :find_all)
assert_respond_to([], :select) # Alias
- assert_respond_to([], :filter) # Alias
assert_equal([], [].find_all{ |obj| obj == "foo"})
x = ["foo", "bar", "baz", "baz", 1, 2, 3, 3, 4]
@@ -206,8 +198,6 @@ class TestArray < Test::Unit::TestCase
assert_equal([0, 1, 2, 13, 4, 5], [0, 1, 2, 3, 4, 5].fill(3...4){|i| i+10})
assert_equal([0, 1, 12, 13, 14, 5], [0, 1, 2, 3, 4, 5].fill(2..-2){|i| i+10})
assert_equal([0, 1, 12, 13, 4, 5], [0, 1, 2, 3, 4, 5].fill(2...-2){|i| i+10})
- assert_equal([0, 1, 2, 13, 14, 15], [0, 1, 2, 3, 4, 5].fill(3..){|i| i+10})
- assert_equal([0, 1, 2, 13, 14, 15], [0, 1, 2, 3, 4, 5].fill(3...){|i| i+10})
end
# From rubicon
@@ -241,23 +231,6 @@ class TestArray < Test::Unit::TestCase
assert_equal(@cls[], @cls[ 1, 2, 3 ]*64 & @cls[ 4, 5, 6 ]*64)
end
- def test_intersection
- assert_equal(@cls[1, 2], @cls[1, 2, 3].intersection(@cls[1, 2]))
- assert_equal(@cls[ ], @cls[1].intersection(@cls[ ]))
- assert_equal(@cls[ ], @cls[ ].intersection(@cls[1]))
- assert_equal(@cls[1], @cls[1, 2, 3].intersection(@cls[1, 2], @cls[1]))
- assert_equal(@cls[ ], @cls[1, 2, 3].intersection(@cls[1, 2], @cls[3]))
- assert_equal(@cls[ ], @cls[1, 2, 3].intersection(@cls[4, 5, 6]))
- end
-
- def test_intersection_big_array
- assert_equal(@cls[1, 2], (@cls[1, 2, 3] * 64).intersection(@cls[1, 2] * 64))
- assert_equal(@cls[ ], (@cls[1] * 64).intersection(@cls[ ]))
- assert_equal(@cls[ ], @cls[ ].intersection(@cls[1] * 64))
- assert_equal(@cls[1], (@cls[1, 2, 3] * 64).intersection((@cls[1, 2] * 64), (@cls[1] * 64)))
- assert_equal(@cls[ ], (@cls[1, 2, 3] * 64).intersection(@cls[4, 5, 6] * 64))
- end
-
def test_MUL # '*'
assert_equal(@cls[], @cls[]*3)
assert_equal(@cls[1, 1, 1], @cls[1]*3)
@@ -281,39 +254,29 @@ class TestArray < Test::Unit::TestCase
def test_MINUS # '-'
assert_equal(@cls[], @cls[1] - @cls[1])
assert_equal(@cls[1], @cls[1, 2, 3, 4, 5] - @cls[2, 3, 4, 5])
+ # Ruby 1.8 feature change
+ #assert_equal(@cls[1], @cls[1, 2, 1, 3, 1, 4, 1, 5] - @cls[2, 3, 4, 5])
assert_equal(@cls[1, 1, 1, 1], @cls[1, 2, 1, 3, 1, 4, 1, 5] - @cls[2, 3, 4, 5])
+ a = @cls[]
+ 1000.times { a << 1 }
+ assert_equal(1000, a.length)
+ #assert_equal(@cls[1], a - @cls[2])
+ assert_equal(@cls[1] * 1000, a - @cls[2])
+ #assert_equal(@cls[1], @cls[1, 2, 1] - @cls[2])
assert_equal(@cls[1, 1], @cls[1, 2, 1] - @cls[2])
assert_equal(@cls[1, 2, 3], @cls[1, 2, 3] - @cls[4, 5, 6])
end
def test_MINUS_big_array # '-'
assert_equal(@cls[1]*64, @cls[1, 2, 3, 4, 5]*64 - @cls[2, 3, 4, 5]*64)
+ # Ruby 1.8 feature change
+ #assert_equal(@cls[1], @cls[1, 2, 1, 3, 1, 4, 1, 5]*64 - @cls[2, 3, 4, 5]*64)
assert_equal(@cls[1, 1, 1, 1]*64, @cls[1, 2, 1, 3, 1, 4, 1, 5]*64 - @cls[2, 3, 4, 5]*64)
a = @cls[]
1000.times { a << 1 }
assert_equal(1000, a.length)
- assert_equal(@cls[1] * 1000, a - @cls[2])
- end
-
- def test_difference
- assert_equal(@cls[], @cls[1].difference(@cls[1]))
- assert_equal(@cls[1], @cls[1, 2, 3, 4, 5].difference(@cls[2, 3, 4, 5]))
- assert_equal(@cls[1, 1], @cls[1, 2, 1].difference(@cls[2]))
- assert_equal(@cls[1, 1, 1, 1], @cls[1, 2, 1, 3, 1, 4, 1, 5].difference(@cls[2, 3, 4, 5]))
- assert_equal(@cls[], @cls[1, 2, 3, 4].difference(@cls[1], @cls[2], @cls[3], @cls[4]))
- a = [1]
- assert_equal(@cls[1], a.difference(@cls[2], @cls[2]))
- assert_equal(@cls[], a.difference(@cls[1]))
- assert_equal(@cls[1], a)
- end
-
- def test_difference_big_array
- assert_equal(@cls[1]*64, (@cls[1, 2, 3, 4, 5] * 64).difference(@cls[2, 3, 4] * 64, @cls[3, 5] * 64))
- assert_equal(@cls[1, 1, 1, 1]*64, (@cls[1, 2, 1, 3, 1, 4, 1, 5] * 64).difference(@cls[2, 3, 4, 5] * 64))
- a = @cls[1] * 1000
- assert_equal(@cls[1] * 1000, a.difference(@cls[2], @cls[2]))
- assert_equal(@cls[], a.difference(@cls[1]))
- assert_equal(@cls[1] * 1000, a)
+ #assert_equal(@cls[1], a - @cls[2])
+ assert_equal(@cls[1] * 1000, a - @cls[2])
end
def test_LSHIFT # '<<'
@@ -389,15 +352,12 @@ class TestArray < Test::Unit::TestCase
assert_equal(@cls[99], a[-2..-2])
assert_equal(@cls[10, 11, 12], a[9..11])
- assert_equal(@cls[98, 99, 100], a[97..])
- assert_equal(@cls[1, 2, 3], a[..2])
- assert_equal(@cls[1, 2], a[...2])
assert_equal(@cls[10, 11, 12], a[-91..-89])
- assert_equal(@cls[98, 99, 100], a[-3..])
- assert_equal(@cls[1, 2, 3], a[..-98])
- assert_equal(@cls[1, 2], a[...-98])
assert_nil(a[10, -3])
+ # Ruby 1.8 feature change:
+ # Array#[size..x] returns [] instead of nil.
+ #assert_nil(a[10..7])
assert_equal [], a[10..7]
assert_raise(TypeError) {a['cat']}
@@ -453,41 +413,33 @@ class TestArray < Test::Unit::TestCase
assert_equal(b, a[10..19] = b)
assert_equal(@cls[*(0..9).to_a] + b + @cls[*(20..99).to_a], a)
+ # Ruby 1.8 feature change:
+ # assigning nil does not remove elements.
+=begin
a = @cls[*(0..99).to_a]
assert_equal(nil, a[0,1] = nil)
- assert_equal(@cls[nil] + @cls[*(1..99).to_a], a)
+ assert_equal(@cls[*(1..99).to_a], a)
a = @cls[*(0..99).to_a]
assert_equal(nil, a[10,10] = nil)
- assert_equal(@cls[*(0..9).to_a] + @cls[nil] + @cls[*(20..99).to_a], a)
+ assert_equal(@cls[*(0..9).to_a] + @cls[*(20..99).to_a], a)
a = @cls[*(0..99).to_a]
assert_equal(nil, a[-1, 1] = nil)
- assert_equal(@cls[*(0..98).to_a] + @cls[nil], a)
+ assert_equal(@cls[*(0..98).to_a], a)
a = @cls[*(0..99).to_a]
assert_equal(nil, a[-10, 10] = nil)
- assert_equal(@cls[*(0..89).to_a] + @cls[nil], a)
+ assert_equal(@cls[*(0..89).to_a], a)
a = @cls[*(0..99).to_a]
assert_equal(nil, a[0,1000] = nil)
- assert_equal(@cls[nil] , a)
+ assert_equal(@cls[] , a)
a = @cls[*(0..99).to_a]
assert_equal(nil, a[10..19] = nil)
- assert_equal(@cls[*(0..9).to_a] + @cls[nil] + @cls[*(20..99).to_a], a)
-
- a = @cls[*(0..99).to_a]
- assert_equal(nil, a[10..] = nil)
- assert_equal(@cls[*(0..9).to_a] + @cls[nil], a)
-
- a = @cls[*(0..99).to_a]
- assert_equal(nil, a[..10] = nil)
- assert_equal(@cls[nil] + @cls[*(11..99).to_a], a)
-
- a = @cls[*(0..99).to_a]
- assert_equal(nil, a[...10] = nil)
- assert_equal(@cls[nil] + @cls[*(10..99).to_a], a)
+ assert_equal(@cls[*(0..9).to_a] + @cls[*(20..99).to_a], a)
+=end
a = @cls[1, 2, 3]
a[1, 0] = a
@@ -556,14 +508,18 @@ class TestArray < Test::Unit::TestCase
end
def test_clone
- for frozen in [ false, true ]
- a = @cls[*(0..99).to_a]
- a.freeze if frozen
- b = a.clone
-
- assert_equal(a, b)
- assert_not_equal(a.__id__, b.__id__)
- assert_equal(a.frozen?, b.frozen?)
+ for taint in [ false, true ]
+ for frozen in [ false, true ]
+ a = @cls[*(0..99).to_a]
+ a.taint if taint
+ a.freeze if frozen
+ b = a.clone
+
+ assert_equal(a, b)
+ assert_not_equal(a.__id__, b.__id__)
+ assert_equal(a.frozen?, b.frozen?)
+ assert_equal(a.tainted?, b.tainted?)
+ end
end
end
@@ -574,11 +530,12 @@ class TestArray < Test::Unit::TestCase
assert_equal([], @cls[].collect { 99 })
+ # Ruby 1.9 feature change:
+ # Enumerable#collect without block returns an Enumerator.
+ #assert_equal([1, 2, 3], @cls[1, 2, 3].collect)
assert_kind_of Enumerator, @cls[1, 2, 3].collect
- assert_raise(ArgumentError) {
- assert_equal([[1, 2, 3]], [[1, 2, 3]].collect(&->(a, b, c) {[a, b, c]}))
- }
+ assert_equal([[1, 2, 3]], [[1, 2, 3]].collect(&->(a, b, c) {[a, b, c]}))
end
# also update map!
@@ -750,14 +707,18 @@ class TestArray < Test::Unit::TestCase
end
def test_dup
- for frozen in [ false, true ]
- a = @cls[*(0..99).to_a]
- a.freeze if frozen
- b = a.dup
-
- assert_equal(a, b)
- assert_not_equal(a.__id__, b.__id__)
- assert_equal(false, b.frozen?)
+ for taint in [ false, true ]
+ for frozen in [ false, true ]
+ a = @cls[*(0..99).to_a]
+ a.taint if taint
+ a.freeze if frozen
+ b = a.dup
+
+ assert_equal(a, b)
+ assert_not_equal(a.__id__, b.__id__)
+ assert_equal(false, b.frozen?)
+ assert_equal(a.tainted?, b.tainted?)
+ end
end
end
@@ -773,7 +734,7 @@ class TestArray < Test::Unit::TestCase
a = @cls[]
i = 0
a.each { |e|
- assert(false, "Never get here")
+ assert_equal(a[i], e)
i += 1
}
assert_equal(0, i)
@@ -793,7 +754,7 @@ class TestArray < Test::Unit::TestCase
a = @cls[]
i = 0
a.each_index { |ind|
- assert(false, "Never get here")
+ assert_equal(i, ind)
i += 1
}
assert_equal(0, i)
@@ -857,6 +818,13 @@ class TestArray < Test::Unit::TestCase
assert_raise(TypeError, "[ruby-dev:31197]") { [[]].flatten("") }
end
+ def test_flatten_taint
+ a6 = @cls[[1, 2], 3]
+ a6.taint
+ a7 = a6.flatten
+ assert_equal(true, a7.tainted?)
+ end
+
def test_flatten_level0
a8 = @cls[[1, 2], 3]
a9 = a8.flatten(0)
@@ -886,17 +854,6 @@ class TestArray < Test::Unit::TestCase
assert_raise(NoMethodError, bug12738) { a.flatten.m }
end
- def test_flatten_recursive
- a = []
- a << a
- assert_raise(ArgumentError) { a.flatten }
- b = [1]; c = [2, b]; b << c
- assert_raise(ArgumentError) { b.flatten }
-
- assert_equal([1, 2, b], b.flatten(1))
- assert_equal([1, 2, 1, 2, 1, c], b.flatten(4))
- end
-
def test_flatten!
a1 = @cls[ 1, 2, 3]
a2 = @cls[ 5, 6 ]
@@ -1128,6 +1085,20 @@ class TestArray < Test::Unit::TestCase
assert_equal("1,2,3", a.join(','))
$, = ""
+ a = @cls[1, 2, 3]
+ a.taint
+ s = a.join
+ assert_equal(true, s.tainted?)
+
+ bug5902 = '[ruby-core:42161]'
+ sep = ":".taint
+
+ s = @cls[].join(sep)
+ assert_equal(false, s.tainted?, bug5902)
+ s = @cls[1].join(sep)
+ assert_equal(false, s.tainted?, bug5902)
+ s = @cls[1, 2].join(sep)
+ assert_equal(true, s.tainted?, bug5902)
e = ''.force_encoding('EUC-JP')
u = ''.force_encoding('UTF-8')
@@ -1278,6 +1249,9 @@ class TestArray < Test::Unit::TestCase
a = @cls[1, 2, 3]
assert_equal(@cls[1, 2, 3, 4, 5], a.push(4, 5))
assert_equal(@cls[1, 2, 3, 4, 5, nil], a.push(nil))
+ # Ruby 1.8 feature:
+ # Array#push accepts any number of arguments.
+ #assert_raise(ArgumentError, "a.push()") { a.push() }
a.push
assert_equal @cls[1, 2, 3, 4, 5, nil], a
a.push 6, 7
@@ -1403,6 +1377,9 @@ class TestArray < Test::Unit::TestCase
a = @cls[*%w( dog cat bee ant )]
assert_equal(@cls[*%w(ant bee cat dog)], a.reverse!)
assert_equal(@cls[*%w(ant bee cat dog)], a)
+ # Ruby 1.8 feature change:
+ # Array#reverse always returns self.
+ #assert_nil(@cls[].reverse!)
assert_equal @cls[], @cls[].reverse!
end
@@ -1433,16 +1410,6 @@ class TestArray < Test::Unit::TestCase
assert_nil(a.rindex([1,2]))
assert_equal(3, a.rindex(99) {|x| x == [1,2,3] })
-
- bug15951 = "[Bug #15951]"
- o2 = Object.new
- def o2.==(other)
- other.replace([]) if Array === other
- false
- end
- a = Array.new(10)
- a.fill(o2)
- assert_nil(a.rindex(a), bug15951)
end
def test_shift
@@ -1492,14 +1459,14 @@ class TestArray < Test::Unit::TestCase
assert_equal(@cls[99], a.slice(-2..-2))
assert_equal(@cls[10, 11, 12], a.slice(9..11))
- assert_equal(@cls[98, 99, 100], a.slice(97..))
- assert_equal(@cls[10, 11, 12], a.slice(-91..-89))
assert_equal(@cls[10, 11, 12], a.slice(-91..-89))
assert_nil(a.slice(-101..-1))
- assert_nil(a.slice(-101..))
assert_nil(a.slice(10, -3))
+ # Ruby 1.8 feature change:
+ # Array#slice[size..x] always returns [].
+ #assert_nil(a.slice(10..7))
assert_equal @cls[], a.slice(10..7)
end
@@ -1540,8 +1507,6 @@ class TestArray < Test::Unit::TestCase
assert_equal(nil, a.slice!(-6,2))
assert_equal(@cls[1, 2, 3, 4, 5], a)
- assert_equal("[2, 3]", [1,2,3].slice!(1,10000).inspect, "moved from btest/knownbug")
-
assert_raise(ArgumentError) { @cls[1].slice! }
assert_raise(ArgumentError) { @cls[1].slice!(0, 0, 0) }
end
@@ -1605,21 +1570,13 @@ class TestArray < Test::Unit::TestCase
end
def test_sort_with_replace
- bug = '[ruby-core:34732]'
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 30)
- bug = "#{bug}"
- begin;
- xary = (1..100).to_a
- 100.times do
- ary = (1..100).to_a
- ary.sort! {|a,b| ary.replace(xary); a <=> b}
- GC.start
- assert_equal(xary, ary, '[ruby-dev:34732]')
- end
- assert_nothing_raised(SystemStackError, bug) do
- assert_equal(:ok, Array.new(100_000, nil).permutation {break :ok})
- end
- end;
+ xary = (1..100).to_a
+ 100.times do
+ ary = (1..100).to_a
+ ary.sort! {|a,b| ary.replace(xary); a <=> b}
+ GC.start
+ assert_equal(xary, ary, '[ruby-dev:34732]')
+ end
end
def test_sort_bang_with_freeze
@@ -1675,7 +1632,7 @@ class TestArray < Test::Unit::TestCase
def o.to_ary
foo_bar()
end
- assert_raise_with_message(NoMethodError, /foo_bar/) {a.concat(o)}
+ assert_match(/foo_bar/, assert_raise(NoMethodError) {a.concat(o)}.message)
end
def test_to_s
@@ -1698,17 +1655,15 @@ class TestArray < Test::Unit::TestCase
$, = nil
end
- StubToH = [
- [:key, :value],
- Object.new.tap do |kvp|
- def kvp.to_ary
- [:obtained, :via_to_ary]
- end
- end,
- ]
-
def test_to_h
- array = StubToH
+ kvp = Object.new
+ def kvp.to_ary
+ [:obtained, :via_to_ary]
+ end
+ array = [
+ [:key, :value],
+ kvp,
+ ]
assert_equal({key: :value, obtained: :via_to_ary}, array.to_h)
e = assert_raise(TypeError) {
@@ -1723,27 +1678,6 @@ class TestArray < Test::Unit::TestCase
assert_equal "wrong array length at 2 (expected 2, was 1)", e.message
end
- def test_to_h_block
- array = StubToH
- assert_equal({"key" => "value", "obtained" => "via_to_ary"},
- array.to_h {|k, v| [k.to_s, v.to_s]})
-
- assert_equal({first_one: :ok, not_ok: :ng},
- [[:first_one, :ok], :not_ok].to_h {|k, v| [k, v || :ng]})
-
- e = assert_raise(TypeError) {
- [[:first_one, :ok], :not_ok].to_h {|k, v| v ? [k, v] : k}
- }
- assert_equal "wrong element type Symbol at 1 (expected array)", e.message
- array = [1]
- k = eval("class C\u{1f5ff}; self; end").new
- assert_raise_with_message(TypeError, /C\u{1f5ff}/) {array.to_h {k}}
- e = assert_raise(ArgumentError) {
- [[:first_one, :ok], [1, 2], [:not_ok]].to_h {|kv| kv}
- }
- assert_equal "wrong array length at 2 (expected 2, was 1)", e.message
- end
-
def test_min
assert_equal(1, [1, 2, 3, 1, 2].min)
assert_equal(3, [1, 2, 3, 1, 2].min {|a,b| b <=> a })
@@ -1787,25 +1721,6 @@ class TestArray < Test::Unit::TestCase
assert_same(obj, [obj, 1.0].max)
end
- def test_minmax
- assert_equal([1, 3], [1, 2, 3, 1, 2].minmax)
- assert_equal([3, 1], [1, 2, 3, 1, 2].minmax {|a,b| b <=> a })
- cond = ->((a, ia), (b, ib)) { (b <=> a).nonzero? or ia <=> ib }
- assert_equal([[3, 2], [1, 3]], [1, 2, 3, 1, 2].each_with_index.minmax(&cond))
- ary = %w(albatross dog horse)
- assert_equal(["albatross", "horse"], ary.minmax)
- assert_equal(["dog", "albatross"], ary.minmax {|a,b| a.length <=> b.length })
- assert_equal([1, 3], [3,2,1].minmax)
-
- class << (obj = Object.new)
- def <=>(x) 1 <=> x end
- def coerce(x) [x, 1] end
- end
- ary = [obj, 1.0].minmax
- assert_same(obj, ary[0])
- assert_equal(obj, ary[1])
- end
-
def test_uniq
a = []
b = a.uniq
@@ -1854,31 +1769,6 @@ class TestArray < Test::Unit::TestCase
ary = [bug9340, bug9340.dup, bug9340.dup]
assert_equal 1, ary.uniq.size
assert_same bug9340, ary.uniq[0]
-
- sc = Class.new(@cls)
- a = sc[]
- b = a.dup
- assert_instance_of(sc, a.uniq)
- assert_equal(sc[], a.uniq)
- assert_equal(b, a)
-
- a = sc[1]
- b = a.dup
- assert_instance_of(sc, a.uniq)
- assert_equal(sc[1], a.uniq)
- assert_equal(b, a)
-
- a = sc[1, 1]
- b = a.dup
- assert_instance_of(sc, a.uniq)
- assert_equal(sc[1], a.uniq)
- assert_equal(b, a)
-
- a = sc[1, 1]
- b = a.dup
- assert_instance_of(sc, a.uniq{|x| x})
- assert_equal(sc[1], a.uniq{|x| x})
- assert_equal(b, a)
end
def test_uniq_with_block
@@ -2075,44 +1965,6 @@ class TestArray < Test::Unit::TestCase
assert_equal((1..128).to_a, b)
end
- def test_union
- assert_equal(@cls[], @cls[].union(@cls[]))
- assert_equal(@cls[1], @cls[1].union(@cls[]))
- assert_equal(@cls[1], @cls[].union(@cls[1]))
- assert_equal(@cls[1], @cls[].union(@cls[], @cls[1]))
- assert_equal(@cls[1], @cls[1].union(@cls[1]))
- assert_equal(@cls[1], @cls[1].union(@cls[1], @cls[1], @cls[1]))
-
- assert_equal(@cls[1,2], @cls[1].union(@cls[2]))
- assert_equal(@cls[1,2], @cls[1, 1].union(@cls[2, 2]))
- assert_equal(@cls[1,2], @cls[1, 2].union(@cls[1, 2]))
- assert_equal(@cls[1,2], @cls[1, 1].union(@cls[1, 1], @cls[1, 2], @cls[2, 1], @cls[2, 2, 2]))
-
- a = %w(a b c)
- b = %w(a b c d e)
- c = a.union(b)
- assert_equal(c, b)
- assert_not_same(c, b)
- assert_equal(%w(a b c), a)
- assert_equal(%w(a b c d e), b)
- assert(a.none?(&:frozen?))
- assert(b.none?(&:frozen?))
- assert(c.none?(&:frozen?))
- end
-
- def test_union_big_array
- assert_equal(@cls[1,2], (@cls[1]*64).union(@cls[2]*64))
- assert_equal(@cls[1,2,3], (@cls[1, 2]*64).union(@cls[1, 2]*64, @cls[3]*60))
-
- a = (1..64).to_a
- b = (1..128).to_a
- c = a | b
- assert_equal(c, b)
- assert_not_same(c, b)
- assert_equal((1..64).to_a, a)
- assert_equal((1..128).to_a, b)
- end
-
def test_combination
a = @cls[]
assert_equal(1, a.combination(0).size)
@@ -2347,7 +2199,6 @@ class TestArray < Test::Unit::TestCase
assert_raise(IndexError) { [0][LONGP] = 2 }
assert_raise(IndexError) { [0][(LONGP + 1) / 2 - 1] = 2 }
assert_raise(IndexError) { [0][LONGP..-1] = 2 }
- assert_raise(IndexError) { [0][LONGP..] = 2 }
a = [0]
a[2] = 4
assert_equal([0, nil, 4], a)
@@ -2385,7 +2236,6 @@ class TestArray < Test::Unit::TestCase
def test_aref
assert_raise(ArgumentError) { [][0, 0, 0] }
- assert_raise(TypeError) { [][(1..10).step(2)] }
end
def test_fetch
@@ -2523,25 +2373,6 @@ class TestArray < Test::Unit::TestCase
assert_equal(@cls[4, 5], a)
end
- def test_filter
- assert_equal([0, 2], [0, 1, 2, 3].filter {|x| x % 2 == 0 })
- end
-
- # alias for select!
- def test_filter!
- a = @cls[ 1, 2, 3, 4, 5 ]
- assert_equal(nil, a.filter! { true })
- assert_equal(@cls[1, 2, 3, 4, 5], a)
-
- a = @cls[ 1, 2, 3, 4, 5 ]
- assert_equal(a, a.filter! { false })
- assert_equal(@cls[], a)
-
- a = @cls[ 1, 2, 3, 4, 5 ]
- assert_equal(a, a.filter! { |i| i > 3 })
- assert_equal(@cls[4, 5], a)
- end
-
def test_delete2
a = [0] * 1024 + [1] + [0] * 1024
a.delete(0)
@@ -2635,6 +2466,9 @@ class TestArray < Test::Unit::TestCase
def test_flatten_error
a = []
+ a << a
+ assert_raise(ArgumentError) { a.flatten }
+
f = [].freeze
assert_raise(ArgumentError) { a.flatten!(1, 2) }
assert_raise(TypeError) { a.flatten!(:foo) }
@@ -2878,6 +2712,13 @@ class TestArray < Test::Unit::TestCase
assert_equal(Array2, Array2[*(1..100)][1..99].class) #not embedded
end
+ def test_inspect
+ a = @cls[1, 2, 3]
+ a.taint
+ s = a.inspect
+ assert_equal(true, s.tainted?)
+ end
+
def test_initialize2
a = [1] * 1000
a.instance_eval { initialize }
@@ -3081,7 +2922,7 @@ class TestArray < Test::Unit::TestCase
Bug11235 = '[ruby-dev:49043] [Bug #11235]'
def test_push_over_ary_max
- assert_separately(['-', ARY_MAX.to_s, Bug11235], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 120)
+ assert_separately(['-', ARY_MAX.to_s, Bug11235], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 30)
begin;
a = Array.new(ARGV[0].to_i)
assert_raise(IndexError, ARGV[1]) {0x1000.times {a.push(1)}}
@@ -3202,14 +3043,6 @@ class TestArray < Test::Unit::TestCase
assert_raise(TypeError) {[1].sum("")}
end
- def test_big_array_literal_with_kwsplat
- lit = "["
- 10000.times { lit << "{}," }
- lit << "**{}]"
-
- assert_equal(10000, eval(lit).size)
- end
-
private
def need_continuation
unless respond_to?(:callcc, true)
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb
index 5a6ec97e67..45c4d6e058 100644
--- a/test/ruby/test_assignment.rb
+++ b/test/ruby/test_assignment.rb
@@ -92,11 +92,6 @@ class TestAssignment < Test::Unit::TestCase
a,b,*c = *[*[1,2]]; assert_equal([1,2,[]], [a,b,c])
end
- def test_assign_rescue
- a = raise rescue 2; assert_equal(2, a)
- a, b = raise rescue [3,4]; assert_equal([3, 4], [a, b])
- end
-
def test_assign_abbreviated
bug2050 = '[ruby-core:25629]'
a = Hash.new {[]}
@@ -119,32 +114,32 @@ class TestAssignment < Test::Unit::TestCase
def []=(i, a); 42; end
end
- assert_raise(NoMethodError, bug11096) {
+ assert_raise(NoMethodError) {
o.instance_eval {o.foo = 1}
}
- assert_nothing_raised(NoMethodError, bug11096) {
+ assert_nothing_raised(NoMethodError) {
assert_equal(1, o.instance_eval {self.foo = 1})
}
- assert_raise(NoMethodError, bug11096) {
+ assert_raise(NoMethodError) {
o.instance_eval {o[0] = 1}
}
- assert_nothing_raised(NoMethodError, bug11096) {
+ assert_nothing_raised(NoMethodError) {
assert_equal(1, o.instance_eval {self[0] = 1})
}
- assert_nothing_raised(NoMethodError, bug11096) {
- o.instance_eval {self.foo += 1}
+ assert_raise(NoMethodError, bug11096) {
+ assert_equal(43, o.instance_eval {self.foo += 1})
}
- assert_nothing_raised(NoMethodError, bug11096) {
- o.instance_eval {self.foo &&= 1}
+ assert_raise(NoMethodError, bug11096) {
+ assert_equal(1, o.instance_eval {self.foo &&= 1})
}
- assert_nothing_raised(NoMethodError, bug11096) {
- o.instance_eval {self[0] += 1}
+ assert_raise(NoMethodError, bug11096) {
+ assert_equal(43, o.instance_eval {self[0] += 1})
}
- assert_nothing_raised(NoMethodError, bug11096) {
- o.instance_eval {self[0] &&= 1}
+ assert_raise(NoMethodError, bug11096) {
+ assert_equal(1, o.instance_eval {self[0] &&= 1})
}
end
@@ -456,7 +451,7 @@ class TestAssignment < Test::Unit::TestCase
assert(defined?(a))
assert_nil(a)
- # multiple assignment
+ # multiple asignment
a, b = 1, 2
assert_equal 1, a
assert_equal 2, b
@@ -485,10 +480,11 @@ class TestAssignment < Test::Unit::TestCase
assert_equal 1, a
assert_equal [2, 3], b
- a, *b, c = 1, 2, 3, 4
- assert_equal 1, a
- assert_equal [2,3], b
- assert_equal 4, c
+ # not supported yet
+ #a, *b, c = 1, 2, 3, 4
+ #assert_equal 1, a
+ #assert_equal [2,3], b
+ #assert_equal 4, c
a = 1, 2
assert_equal [1, 2], a
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
deleted file mode 100644
index 0d846b76e4..0000000000
--- a/test/ruby/test_ast.rb
+++ /dev/null
@@ -1,348 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-require 'tempfile'
-
-class RubyVM
- module AbstractSyntaxTree
- class Node
- class CodePosition
- include Comparable
- attr_reader :lineno, :column
- def initialize(lineno, column)
- @lineno = lineno
- @column = column
- end
-
- def <=>(other)
- case
- when lineno < other.lineno
- -1
- when lineno == other.lineno
- column <=> other.column
- when lineno > other.lineno
- 1
- end
- end
- end
-
- def beg_pos
- CodePosition.new(first_lineno, first_column)
- end
-
- def end_pos
- CodePosition.new(last_lineno, last_column)
- end
-
- alias to_s inspect
- end
- end
-end
-
-class TestAst < Test::Unit::TestCase
- class Helper
- attr_reader :errors
-
- def initialize(path, src: nil)
- @path = path
- @errors = []
- @debug = false
- @ast = RubyVM::AbstractSyntaxTree.parse(src) if src
- end
-
- def validate_range
- @errors = []
- validate_range0(ast)
-
- @errors.empty?
- end
-
- def validate_not_cared
- @errors = []
- validate_not_cared0(ast)
-
- @errors.empty?
- end
-
- def ast
- return @ast if defined?(@ast)
- @ast = RubyVM::AbstractSyntaxTree.parse_file(@path)
- end
-
- private
-
- def validate_range0(node)
- beg_pos, end_pos = node.beg_pos, node.end_pos
- children = node.children.grep(RubyVM::AbstractSyntaxTree::Node)
-
- return true if children.empty?
- # These NODE_D* has NODE_LIST as nd_next->nd_next whose last locations
- # we can not update when item is appended.
- return true if [:DSTR, :DXSTR, :DREGX, :DSYM].include? node.type
-
- min = children.map(&:beg_pos).min
- max = children.map(&:end_pos).max
-
- unless beg_pos <= min
- @errors << { type: :min_validation_error, min: min, beg_pos: beg_pos, node: node }
- end
-
- unless max <= end_pos
- @errors << { type: :max_validation_error, max: max, end_pos: end_pos, node: node }
- end
-
- p "#{node} => #{children}" if @debug
-
- children.each do |child|
- p child if @debug
- validate_range0(child)
- end
- end
-
- def validate_not_cared0(node)
- beg_pos, end_pos = node.beg_pos, node.end_pos
- children = node.children.grep(RubyVM::AbstractSyntaxTree::Node)
-
- @errors << { type: :first_lineno, node: node } if beg_pos.lineno == 0
- @errors << { type: :first_column, node: node } if beg_pos.column == -1
- @errors << { type: :last_lineno, node: node } if end_pos.lineno == 0
- @errors << { type: :last_column, node: node } if end_pos.column == -1
-
- children.each {|c| validate_not_cared0(c) }
- end
- end
-
- SRCDIR = File.expand_path("../../..", __FILE__)
-
- Dir.glob("test/**/*.rb", base: SRCDIR).each do |path|
- define_method("test_ranges:#{path}") do
- helper = Helper.new("#{SRCDIR}/#{path}")
- helper.validate_range
-
- assert_equal([], helper.errors)
- end
- end
-
- Dir.glob("test/**/*.rb", base: SRCDIR).each do |path|
- define_method("test_not_cared:#{path}") do
- helper = Helper.new("#{SRCDIR}/#{path}")
- helper.validate_not_cared
-
- assert_equal([], helper.errors)
- end
- end
-
- private def parse(src)
- EnvUtil.suppress_warning {
- RubyVM::AbstractSyntaxTree.parse(src)
- }
- end
-
- def test_allocate
- assert_raise(TypeError) {RubyVM::AbstractSyntaxTree::Node.allocate}
- end
-
- def test_parse_argument_error
- assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(0)}
- assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(nil)}
- assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(false)}
- assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(true)}
- assert_raise(TypeError) {RubyVM::AbstractSyntaxTree.parse(:foo)}
- end
-
- def test_column_with_long_heredoc_identifier
- term = "A"*257
- ast = parse("<<-#{term}\n""ddddddd\n#{term}\n")
- node = ast.children[2]
- assert_equal(:STR, node.type)
- assert_equal(0, node.first_column)
- end
-
- def test_column_of_heredoc
- node = parse("<<-SRC\nddddddd\nSRC\n").children[2]
- assert_equal(:STR, node.type)
- assert_equal(0, node.first_column)
- assert_equal(6, node.last_column)
-
- node = parse("<<SRC\nddddddd\nSRC\n").children[2]
- assert_equal(:STR, node.type)
- assert_equal(0, node.first_column)
- assert_equal(5, node.last_column)
- end
-
- def test_parse_raises_syntax_error
- assert_raise_with_message(SyntaxError, /\bend\b/) do
- RubyVM::AbstractSyntaxTree.parse("end")
- end
- end
-
- def test_parse_file_raises_syntax_error
- Tempfile.create(%w"test_ast .rb") do |f|
- f.puts "end"
- f.close
- assert_raise_with_message(SyntaxError, /\bend\b/) do
- RubyVM::AbstractSyntaxTree.parse_file(f.path)
- end
- end
- end
-
- def test_of
- proc = Proc.new { 1 + 2 }
- method = self.method(__method__)
-
- node_proc = RubyVM::AbstractSyntaxTree.of(proc)
- node_method = RubyVM::AbstractSyntaxTree.of(method)
-
- assert_instance_of(RubyVM::AbstractSyntaxTree::Node, node_proc)
- assert_instance_of(RubyVM::AbstractSyntaxTree::Node, node_method)
- assert_raise(TypeError) { RubyVM::AbstractSyntaxTree.of("1 + 2") }
-
- Tempfile.create(%w"test_of .rb") do |tmp|
- tmp.print "#{<<-"begin;"}\n#{<<-'end;'}"
- begin;
- SCRIPT_LINES__ = {}
- assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(proc {|x| x}))
- end;
- tmp.close
- assert_separately(["-", tmp.path], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- load ARGV[0]
- assert_empty(SCRIPT_LINES__)
- end;
- end
- end
-
- def test_scope_local_variables
- node = RubyVM::AbstractSyntaxTree.parse("_x = 0")
- lv, _, body = *node.children
- assert_equal([:_x], lv)
- assert_equal(:LASGN, body.type)
- end
-
- def test_call
- node = RubyVM::AbstractSyntaxTree.parse("nil.foo")
- _, _, body = *node.children
- assert_equal(:CALL, body.type)
- recv, mid, args = body.children
- assert_equal(:NIL, recv.type)
- assert_equal(:foo, mid)
- assert_nil(args)
- end
-
- def test_fcall
- node = RubyVM::AbstractSyntaxTree.parse("foo()")
- _, _, body = *node.children
- assert_equal(:FCALL, body.type)
- mid, args = body.children
- assert_equal(:foo, mid)
- assert_nil(args)
- end
-
- def test_vcall
- node = RubyVM::AbstractSyntaxTree.parse("foo")
- _, _, body = *node.children
- assert_equal(:VCALL, body.type)
- mid, args = body.children
- assert_equal(:foo, mid)
- assert_nil(args)
- end
-
- def test_defn
- node = RubyVM::AbstractSyntaxTree.parse("def a; end")
- _, _, body = *node.children
- assert_equal(:DEFN, body.type)
- mid, defn = body.children
- assert_equal(:a, mid)
- assert_equal(:SCOPE, defn.type)
- end
-
- def test_defs
- node = RubyVM::AbstractSyntaxTree.parse("def a.b; end")
- _, _, body = *node.children
- assert_equal(:DEFS, body.type)
- recv, mid, defn = body.children
- assert_equal(:VCALL, recv.type)
- assert_equal(:b, mid)
- assert_equal(:SCOPE, defn.type)
- end
-
- def test_dstr
- node = parse('"foo#{1}bar"')
- _, _, body = *node.children
- assert_equal(:DSTR, body.type)
- head, body = body.children
- assert_equal("foo", head)
- assert_equal(:EVSTR, body.type)
- body, = body.children
- assert_equal(:LIT, body.type)
- assert_equal([1], body.children)
- end
-
- def test_while
- node = RubyVM::AbstractSyntaxTree.parse('1 while qux')
- _, _, body = *node.children
- assert_equal(:WHILE, body.type)
- type1 = body.children[2]
- node = RubyVM::AbstractSyntaxTree.parse('begin 1 end while qux')
- _, _, body = *node.children
- assert_equal(:WHILE, body.type)
- type2 = body.children[2]
- assert_not_equal(type1, type2)
- end
-
- def test_until
- node = RubyVM::AbstractSyntaxTree.parse('1 until qux')
- _, _, body = *node.children
- assert_equal(:UNTIL, body.type)
- type1 = body.children[2]
- node = RubyVM::AbstractSyntaxTree.parse('begin 1 end until qux')
- _, _, body = *node.children
- assert_equal(:UNTIL, body.type)
- type2 = body.children[2]
- assert_not_equal(type1, type2)
- end
-
- def test_keyword_rest
- kwrest = lambda do |arg_str|
- node = RubyVM::AbstractSyntaxTree.parse("def a(#{arg_str}) end")
- node = node.children.last.children.last.children[1].children[-2]
- node ? node.children : node
- end
-
- assert_equal(nil, kwrest.call(''))
- assert_equal([nil], kwrest.call('**'))
- assert_equal(false, kwrest.call('**nil'))
- assert_equal([:a], kwrest.call('**a'))
- end
-
- def test_ranges_numbered_parameter
- helper = Helper.new(__FILE__, src: "1.times {_1}")
- helper.validate_range
- assert_equal([], helper.errors)
- end
-
- def test_op_asgn2
- node = RubyVM::AbstractSyntaxTree.parse("struct.field += foo")
- _, _, body = *node.children
- assert_equal(:OP_ASGN2, body.type)
- recv, _, mid, op, value = body.children
- assert_equal(:VCALL, recv.type)
- assert_equal(:field, mid)
- assert_equal(:+, op)
- assert_equal(:VCALL, value.type)
- end
-
- def test_args
- rest = 6
- node = RubyVM::AbstractSyntaxTree.parse("proc { |a| }")
- _, args = *node.children.last.children[1].children
- assert_equal(nil, args.children[rest])
-
- node = RubyVM::AbstractSyntaxTree.parse("proc { |a,| }")
- _, args = *node.children.last.children[1].children
- assert_equal(:NODE_SPECIAL_EXCESSIVE_COMMA, args.children[rest])
-
- node = RubyVM::AbstractSyntaxTree.parse("proc { |*a| }")
- _, args = *node.children.last.children[1].children
- assert_equal(:a, args.children[rest])
- end
-end
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index 171dbb6293..3095052a81 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -42,10 +42,8 @@ p Foo::Bar
require 'tmpdir'
Dir.mktmpdir('autoload') {|tmpdir|
tmpfile = tmpdir + '/foo.rb'
- tmpfile2 = tmpdir + '/bar.rb'
a = Module.new do
autoload :X, tmpfile
- autoload :Y, tmpfile2
end
b = Module.new do
include a
@@ -54,14 +52,6 @@ p Foo::Bar
assert_equal(true, b.const_defined?(:X))
assert_equal(tmpfile, a.autoload?(:X), bug4565)
assert_equal(tmpfile, b.autoload?(:X), bug4565)
- assert_equal(tmpfile, a.autoload?(:X, false))
- assert_equal(tmpfile, a.autoload?(:X, nil))
- assert_nil(b.autoload?(:X, false))
- assert_nil(b.autoload?(:X, nil))
- assert_equal(true, a.const_defined?("Y"))
- assert_equal(true, b.const_defined?("Y"))
- assert_equal(tmpfile2, a.autoload?("Y"))
- assert_equal(tmpfile2, b.autoload?("Y"))
}
end
@@ -76,12 +66,12 @@ p Foo::Bar
eval <<-END
class ::Object
module A
- autoload :C, 'test-ruby-core-69206'
+ autoload :C, 'b'
end
end
END
- File.write("test-ruby-core-69206.rb", 'module A; class C; end; end')
+ File.open('b.rb', 'w') {|file| file.puts 'module A; class C; end; end'}
assert_kind_of Class, ::A::C
end
}
@@ -257,7 +247,7 @@ p Foo::Bar
def test_autoload_private_constant
Dir.mktmpdir('autoload') do |tmpdir|
- File.write(tmpdir+"/test-bug-14469.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
+ File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
class AutoloadTest
ZZZ = :ZZZ
@@ -268,7 +258,7 @@ p Foo::Bar
bug = '[ruby-core:85516] [Bug #14469]'
begin;
class AutoloadTest
- autoload :ZZZ, "test-bug-14469.rb"
+ autoload :ZZZ, "zzz.rb"
end
assert_raise(NameError, bug) {AutoloadTest::ZZZ}
end;
@@ -277,7 +267,7 @@ p Foo::Bar
def test_autoload_deprecate_constant
Dir.mktmpdir('autoload') do |tmpdir|
- File.write(tmpdir+"/test-bug-14469.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
+ File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
class AutoloadTest
ZZZ = :ZZZ
@@ -288,67 +278,7 @@ p Foo::Bar
bug = '[ruby-core:85516] [Bug #14469]'
begin;
class AutoloadTest
- autoload :ZZZ, "test-bug-14469.rb"
- end
- assert_warning(/ZZZ is deprecated/, bug) {AutoloadTest::ZZZ}
- end;
- end
- end
-
- def test_autoload_private_constant_before_autoload
- Dir.mktmpdir('autoload') do |tmpdir|
- File.write(tmpdir+"/test-bug-11055.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- class AutoloadTest
- ZZZ = :ZZZ
- end
- end;
- assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}")
- bug = '[Bug #11055]'
- begin;
- class AutoloadTest
- autoload :ZZZ, "test-bug-11055.rb"
- private_constant :ZZZ
- ZZZ
- end
- assert_raise(NameError, bug) {AutoloadTest::ZZZ}
- end;
- assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}")
- bug = '[Bug #11055]'
- begin;
- class AutoloadTest
- autoload :ZZZ, "test-bug-11055.rb"
- private_constant :ZZZ
- end
- assert_raise(NameError, bug) {AutoloadTest::ZZZ}
- end;
- end
- end
-
- def test_autoload_deprecate_constant_before_autoload
- Dir.mktmpdir('autoload') do |tmpdir|
- File.write(tmpdir+"/test-bug-11055.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- class AutoloadTest
- ZZZ = :ZZZ
- end
- end;
- assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}")
- bug = '[Bug #11055]'
- begin;
- class AutoloadTest
- autoload :ZZZ, "test-bug-11055.rb"
- deprecate_constant :ZZZ
- end
- assert_warning(/ZZZ is deprecated/, bug) {class AutoloadTest; ZZZ; end}
- assert_warning(/ZZZ is deprecated/, bug) {AutoloadTest::ZZZ}
- end;
- assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}")
- bug = '[Bug #11055]'
- begin;
- class AutoloadTest
- autoload :ZZZ, "test-bug-11055.rb"
- deprecate_constant :ZZZ
+ autoload :ZZZ, "zzz.rb"
end
assert_warning(/ZZZ is deprecated/, bug) {AutoloadTest::ZZZ}
end;
@@ -364,7 +294,7 @@ p Foo::Bar
begin
thrs = []
3.times do
- thrs << Thread.new { AutoloadTest && nil }
+ thrs << Thread.new { AutoloadTest; nil }
thrs << Thread.new { fork { AutoloadTest } }
end
thrs.each(&:join)
@@ -381,75 +311,6 @@ p Foo::Bar
end
end if Process.respond_to?(:fork)
- def test_autoload_same_file
- Dir.mktmpdir('autoload') do |tmpdir|
- File.write("#{tmpdir}/test-bug-14742.rb", "#{<<~'begin;'}\n#{<<~'end;'}")
- begin;
- module Foo; end
- module Bar; end
- end;
- 3.times do # timing-dependent, needs a few times to hit [Bug #14742]
- assert_separately(%W[-I #{tmpdir}], "#{<<-'begin;'}\n#{<<-'end;'}")
- begin;
- autoload :Foo, 'test-bug-14742'
- autoload :Bar, 'test-bug-14742'
- t1 = Thread.new do Foo end
- t2 = Thread.new do Bar end
- t1.join
- t2.join
- bug = '[ruby-core:86935] [Bug #14742]'
- assert_instance_of Module, t1.value, bug
- assert_instance_of Module, t2.value, bug
- end;
- end
- end
- end
-
- def test_autoload_same_file_with_raise
- Dir.mktmpdir('autoload') do |tmpdir|
- File.write("#{tmpdir}/test-bug-16177.rb", "#{<<~'begin;'}\n#{<<~'end;'}")
- begin;
- raise '[ruby-core:95055] [Bug #16177]'
- end;
- assert_raise(RuntimeError, '[ruby-core:95055] [Bug #16177]') do
- assert_separately(%W[-I #{tmpdir}], "#{<<-'begin;'}\n#{<<-'end;'}")
- begin;
- autoload :Foo, 'test-bug-16177'
- autoload :Bar, 'test-bug-16177'
- t1 = Thread.new do Foo end
- t2 = Thread.new do Bar end
- t1.join
- t2.join
- end;
- end
- end
- end
-
- def test_source_location
- klass = self.class
- bug = "Bug16764"
- Dir.mktmpdir('autoload') do |tmpdir|
- path = "#{tmpdir}/test-#{bug}.rb"
- File.write(path, "#{klass}::#{bug} = __FILE__\n")
- klass.autoload(:Bug16764, path)
- assert_equal [__FILE__, __LINE__-1], klass.const_source_location(bug)
- assert_equal path, klass.const_get(bug)
- assert_equal [path, 1], klass.const_source_location(bug)
- end
- end
-
- def test_no_leak
- assert_no_memory_leak([], '', <<~'end;', 'many autoloads', timeout: 60)
- 200000.times do |i|
- m = Module.new
- m.instance_eval do
- autoload :Foo, 'x'
- autoload :Bar, i.to_s
- end
- end
- end;
- end
-
def add_autoload(path)
(@autoload_paths ||= []) << path
::Object.class_eval {autoload(:AutoloadTest, path)}
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb
index 00c96b3b9f..d38628cdb2 100644
--- a/test/ruby/test_backtrace.rb
+++ b/test/ruby/test_backtrace.rb
@@ -297,50 +297,4 @@ class TestBacktrace < Test::Unit::TestCase
end
assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label)
end
-
- def test_notty_backtrace
- err = ["-:1:in `<main>': unhandled exception"]
- assert_in_out_err([], "raise", [], err)
-
- err = ["-:2:in `foo': foo! (RuntimeError)",
- "\tfrom -:4:in `<main>'"]
- assert_in_out_err([], <<-"end;", [], err)
- def foo
- raise "foo!"
- end
- foo
- end;
-
- err = ["-:7:in `rescue in bar': bar! (RuntimeError)",
- "\tfrom -:4:in `bar'",
- "\tfrom -:9:in `<main>'",
- "-:2:in `foo': foo! (RuntimeError)",
- "\tfrom -:5:in `bar'",
- "\tfrom -:9:in `<main>'"]
- assert_in_out_err([], <<-"end;", [], err)
- def foo
- raise "foo!"
- end
- def bar
- foo
- rescue
- raise "bar!"
- end
- bar
- end;
- end
-
- def test_caller_to_enum
- err = ["-:3:in `foo': unhandled exception", "\tfrom -:in `each'"]
- assert_in_out_err([], <<-"end;", [], err, "[ruby-core:91911]")
- def foo
- return to_enum(__method__) unless block_given?
- raise
- yield 1
- end
-
- enum = foo
- enum.next
- end;
- end
end
diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb
index ab32ee54e2..dd3ca4dd22 100644
--- a/test/ruby/test_basicinstructions.rb
+++ b/test/ruby/test_basicinstructions.rb
@@ -117,6 +117,7 @@ class TestBasicInstructions < Test::Unit::TestCase
assert_equal({1=>2}, {1=>2})
assert_equal({1=>2, 3=>4}, {1=>2, 3=>4})
assert_equal({1=>2, 3=>4}, {3=>4, 1=>2})
+ # assert_equal({1=>2, 3=>4}, {1,2, 3,4}) # 1.9 doesn't support
assert_equal({"key"=>"val"}, {"key"=>"val"})
end
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index 434c5befd9..65d974005e 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -10,6 +10,7 @@ class TestBignum < Test::Unit::TestCase
FIXNUM_MAX = RbConfig::LIMITS['FIXNUM_MAX']
BIGNUM_MIN = FIXNUM_MAX + 1
+ b = BIGNUM_MIN
f = BIGNUM_MIN
n = 0
@@ -611,17 +612,17 @@ class TestBignum < Test::Unit::TestCase
return # GMP doesn't support interrupt during an operation.
end
time = Time.now
+ start_flag = false
end_flag = false
num = (65536 ** 65536)
- q = Queue.new
thread = Thread.new do
+ start_flag = true
assert_raise(RuntimeError) {
- q << true
num.to_s
end_flag = true
}
end
- q.pop # sync
+ sleep 0.001 until start_flag
thread.raise
thread.join
time = Time.now - time
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index 46485c4fd2..ad2caeb8be 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -131,48 +131,6 @@ class TestClass < Test::Unit::TestCase
[:module_function, :extend_object, :append_features, :prepend_features])
end
- def test_visibility_inside_method
- assert_warn(/calling private without arguments inside a method may not have the intended effect/, '[ruby-core:79751]') do
- Class.new do
- def self.foo
- private
- end
- foo
- end
- end
-
- assert_warn(/calling protected without arguments inside a method may not have the intended effect/, '[ruby-core:79751]') do
- Class.new do
- def self.foo
- protected
- end
- foo
- end
- end
-
- assert_warn(/calling public without arguments inside a method may not have the intended effect/, '[ruby-core:79751]') do
- Class.new do
- def self.foo
- public
- end
- foo
- end
- end
-
- assert_warn(/calling private without arguments inside a method may not have the intended effect/, '[ruby-core:79751]') do
- Class.new do
- class << self
- alias priv private
- end
-
- def self.foo
- priv
- end
- foo
- end
- end
- end
-
def test_method_redefinition
feature2155 = '[ruby-dev:39400]'
@@ -274,14 +232,6 @@ class TestClass < Test::Unit::TestCase
assert_raise(TypeError) { Class.allocate.superclass }
bug6863 = '[ruby-core:47148]'
assert_raise(TypeError, bug6863) { Class.new(Class.allocate) }
-
- allocator = Class.instance_method(:allocate)
- assert_raise_with_message(TypeError, /prohibited/) {
- allocator.bind(Rational).call
- }
- assert_raise_with_message(TypeError, /prohibited/) {
- allocator.bind_call(Rational)
- }
end
def test_nonascii_name
@@ -292,29 +242,27 @@ class TestClass < Test::Unit::TestCase
end
def test_invalid_next_from_class_definition
- assert_syntax_error("class C; next; end", /Invalid next/)
+ assert_raise(SyntaxError) { eval("class C; next; end") }
end
def test_invalid_break_from_class_definition
- assert_syntax_error("class C; break; end", /Invalid break/)
+ assert_raise(SyntaxError) { eval("class C; break; end") }
end
def test_invalid_redo_from_class_definition
- assert_syntax_error("class C; redo; end", /Invalid redo/)
+ assert_raise(SyntaxError) { eval("class C; redo; end") }
end
def test_invalid_retry_from_class_definition
- assert_syntax_error("class C; retry; end", /Invalid retry/)
+ assert_raise(SyntaxError) { eval("class C; retry; end") }
end
def test_invalid_return_from_class_definition
- assert_syntax_error("class C; return; end", /Invalid return/)
+ assert_raise(SyntaxError) { eval("class C; return; end") }
end
def test_invalid_yield_from_class_definition
- assert_raise(LocalJumpError) {
- EnvUtil.suppress_warning {eval("class C; yield; end")}
- }
+ assert_raise(LocalJumpError) { eval("class C; yield; end") }
end
def test_clone
@@ -379,22 +327,18 @@ class TestClass < Test::Unit::TestCase
end;
end
- class CloneTest
- def foo; TEST; end
- end
+ module M
+ C = 1
- CloneTest1 = CloneTest.clone
- CloneTest2 = CloneTest.clone
- class CloneTest1
- TEST = :C1
- end
- class CloneTest2
- TEST = :C2
+ def self.m
+ C
+ end
end
- def test_constant_access_from_method_in_cloned_class
- assert_equal :C1, CloneTest1.new.foo, '[Bug #15877]'
- assert_equal :C2, CloneTest2.new.foo, '[Bug #15877]'
+ def test_constant_access_from_method_in_cloned_module # [ruby-core:47834]
+ m = M.dup
+ assert_equal 1, m::C
+ assert_equal 1, m.m
end
def test_invalid_superclass
@@ -483,53 +427,6 @@ class TestClass < Test::Unit::TestCase
assert_equal(:foo, d.foo)
end
- def test_clone_singleton_class_exists
- klass = Class.new do
- def self.bar; :bar; end
- end
-
- o = klass.new
- o.singleton_class
- clone = o.clone
-
- assert_empty(o.singleton_class.instance_methods(false))
- assert_empty(clone.singleton_class.instance_methods(false))
- assert_empty(o.singleton_class.singleton_class.instance_methods(false))
- assert_empty(clone.singleton_class.singleton_class.instance_methods(false))
- end
-
- def test_clone_when_singleton_class_of_singleton_class_exists
- klass = Class.new do
- def self.bar; :bar; end
- end
-
- o = klass.new
- o.singleton_class.singleton_class
- clone = o.clone
-
- assert_empty(o.singleton_class.instance_methods(false))
- assert_empty(clone.singleton_class.instance_methods(false))
- assert_empty(o.singleton_class.singleton_class.instance_methods(false))
- assert_empty(clone.singleton_class.singleton_class.instance_methods(false))
- end
-
- def test_clone_when_method_exists_on_singleton_class_of_singleton_class
- klass = Class.new do
- def self.bar; :bar; end
- end
-
- o = klass.new
- o.singleton_class.singleton_class.define_method(:s2_method) { :s2 }
- clone = o.clone
-
- assert_empty(o.singleton_class.instance_methods(false))
- assert_empty(clone.singleton_class.instance_methods(false))
- assert_equal(:s2, o.singleton_class.s2_method)
- assert_equal(:s2, clone.singleton_class.s2_method)
- assert_equal([:s2_method], o.singleton_class.singleton_class.instance_methods(false))
- assert_equal([:s2_method], clone.singleton_class.singleton_class.instance_methods(false))
- end
-
def test_singleton_class_p
feature7609 = '[ruby-core:51087] [Feature #7609]'
assert_predicate(self.singleton_class, :singleton_class?, feature7609)
@@ -688,17 +585,15 @@ class TestClass < Test::Unit::TestCase
def test_redefinition_mismatch
m = Module.new
- m.module_eval "A = 1", __FILE__, line = __LINE__
- e = assert_raise_with_message(TypeError, /is not a class/) {
+ m.module_eval "A = 1"
+ assert_raise_with_message(TypeError, /is not a class/) {
m.module_eval "class A; end"
}
- assert_include(e.message, "#{__FILE__}:#{line}: previous definition")
n = "M\u{1f5ff}"
- m.module_eval "#{n} = 42", __FILE__, line = __LINE__
- e = assert_raise_with_message(TypeError, /#{n} is not a class/) {
+ m.module_eval "#{n} = 42"
+ assert_raise_with_message(TypeError, "#{n} is not a class") {
m.module_eval "class #{n}; end"
}
- assert_include(e.message, "#{__FILE__}:#{line}: previous definition")
assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}")
begin;
diff --git a/test/ruby/test_clone.rb b/test/ruby/test_clone.rb
index 321feb07c7..93ef438461 100644
--- a/test/ruby/test_clone.rb
+++ b/test/ruby/test_clone.rb
@@ -26,39 +26,4 @@ class TestClone < Test::Unit::TestCase
assert_equal([M003, M002, M001], M003.ancestors)
end
-
- def test_user_flags
- assert_separately([], <<-EOS)
- #
- class Array
- undef initialize_copy
- def initialize_copy(*); end
- end
- x = [1, 2, 3].clone
- assert_equal [], x, '[Bug #14847]'
- EOS
-
- assert_separately([], <<-EOS)
- #
- class Array
- undef initialize_copy
- def initialize_copy(*); end
- end
- x = [1,2,3,4,5,6,7][1..-2].clone
- x.push(1,1,1,1,1)
- assert_equal [1, 1, 1, 1, 1], x, '[Bug #14847]'
- EOS
-
- assert_separately([], <<-EOS)
- #
- class Hash
- undef initialize_copy
- def initialize_copy(*); end
- end
- h = {}
- h.default_proc = proc { raise }
- h = h.clone
- assert_equal nil, h[:not_exist], '[Bug #14847]'
- EOS
- end
end
diff --git a/test/ruby/test_comparable.rb b/test/ruby/test_comparable.rb
index b849217b7d..94c05d5f91 100644
--- a/test/ruby/test_comparable.rb
+++ b/test/ruby/test_comparable.rb
@@ -88,37 +88,7 @@ class TestComparable < Test::Unit::TestCase
assert_raise_with_message(ArgumentError, 'min argument must be smaller than max argument') {
@o.clamp(2, 1)
}
- end
-
- def test_clamp_with_range
- cmp->(x) do 0 <=> x end
- assert_equal(1, @o.clamp(1..2))
- assert_equal(-1, @o.clamp(-2..-1))
- assert_equal(@o, @o.clamp(-1..3))
-
- assert_equal(1, @o.clamp(1..1))
- assert_equal(@o, @o.clamp(0..0))
-
- assert_equal(1, @o.clamp(1..))
- assert_equal(1, @o.clamp(1...))
- assert_equal(@o, @o.clamp(0..))
- assert_equal(@o, @o.clamp(0...))
- assert_equal(@o, @o.clamp(..2))
- assert_equal(-1, @o.clamp(-2..-1))
- assert_equal(@o, @o.clamp(-2..0))
- assert_equal(@o, @o.clamp(-2..))
- assert_equal(@o, @o.clamp(-2...))
-
- exc = [ArgumentError, 'cannot clamp with an exclusive range']
- assert_raise_with_message(*exc) {@o.clamp(1...2)}
- assert_raise_with_message(*exc) {@o.clamp(0...2)}
- assert_raise_with_message(*exc) {@o.clamp(-1...0)}
- assert_raise_with_message(*exc) {@o.clamp(...2)}
-
- assert_raise_with_message(ArgumentError, 'min argument must be smaller than max argument') {
- @o.clamp(2..1)
- }
- end
+ end
def test_err
assert_raise(ArgumentError) { 1.0 < nil }
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index a4fe9d4232..316e3e21ff 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -123,10 +123,6 @@ class Complex_Test < Test::Unit::TestCase
assert_raise(TypeError){Complex(Object.new)}
assert_raise(ArgumentError){Complex()}
assert_raise(ArgumentError){Complex(1,2,3)}
- c = Complex(1,0)
- assert_same(c, Complex(c))
- assert_same(c, Complex(c, exception: false))
- assert_raise(ArgumentError){Complex(c, bad_keyword: true)}
if (0.0/0).nan?
assert_nothing_raised{Complex(0.0/0)}
@@ -273,39 +269,6 @@ class Complex_Test < Test::Unit::TestCase
assert_equal(Complex(Rational(5,3),Rational(2)), c + Rational(2,3))
end
- def test_add_with_redefining_int_plus
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Integer
- remove_method :+
- def +(other); 42; end
- end
- a = Complex(1, 2) + Complex(0, 1)
- puts a == Complex(42, 42)
- end;
- end
-
- def test_add_with_redefining_float_plus
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Float
- remove_method :+
- def +(other); 42.0; end
- end
- a = Complex(1.0, 2.0) + Complex(0, 1)
- puts a == Complex(42.0, 42.0)
- end;
- end
-
- def test_add_with_redefining_rational_plus
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Rational
- remove_method :+
- def +(other); 355/113r; end
- end
- a = Complex(1r, 2r) + Complex(0, 1)
- puts a == Complex(355/113r, 355/113r)
- end;
- end
-
def test_sub
c = Complex(1,2)
c2 = Complex(2,3)
@@ -319,39 +282,6 @@ class Complex_Test < Test::Unit::TestCase
assert_equal(Complex(Rational(1,3),Rational(2)), c - Rational(2,3))
end
- def test_sub_with_redefining_int_minus
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Integer
- remove_method :-
- def -(other); 42; end
- end
- a = Complex(1, 2) - Complex(0, 1)
- puts a == Complex(42, 42)
- end;
- end
-
- def test_sub_with_redefining_float_minus
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Float
- remove_method :-
- def -(other); 42.0; end
- end
- a = Complex(1.0, 2.0) - Complex(0, 1)
- puts a == Complex(42.0, 42.0)
- end;
- end
-
- def test_sub_with_redefining_rational_minus
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Rational
- remove_method :-
- def -(other); 355/113r; end
- end
- a = Complex(1r, 2r) - Complex(0, 1)
- puts a == Complex(355/113r, 355/113r)
- end;
- end
-
def test_mul
c = Complex(1,2)
c2 = Complex(2,3)
@@ -370,42 +300,6 @@ class Complex_Test < Test::Unit::TestCase
c = Complex(0, Float::INFINITY)
assert_equal(Complex(0, Float::INFINITY), c * Complex(1, 0))
assert_equal(Complex(-Float::INFINITY, 0), c * Complex(0, 1))
-
- assert_equal(Complex(-0.0, -0.0), Complex(-0.0, 0) * Complex(0, 0))
- end
-
- def test_mul_with_redefining_int_mult
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Integer
- remove_method :*
- def *(other); 42; end
- end
- a = Complex(2, 0) * Complex(1, 2)
- puts a == Complex(0, 84)
- end;
- end
-
- def test_mul_with_redefining_float_mult
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Float
- remove_method :*
- def *(other); 42.0; end
- end
- a = Complex(2.0, 0.0) * Complex(1, 2)
- puts a == Complex(0.0, 84.0)
- end;
- end
-
-
- def test_mul_with_redefining_rational_mult
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Rational
- remove_method :*
- def *(other); 355/113r; end
- end
- a = Complex(2r, 0r) * Complex(1, 2)
- puts a == Complex(0r, 2*355/113r)
- end;
end
def test_div
@@ -429,15 +323,6 @@ class Complex_Test < Test::Unit::TestCase
assert_equal(Complex(Rational(1,2),Rational(1)), c / Rational(2))
assert_equal(Complex(Rational(3,2),Rational(3)), c / Rational(2,3))
-
- c = Complex(1)
- [ 1, Rational(1), c ].each do |d|
- r = c / d
- assert_instance_of(Complex, r)
- assert_equal(1, r)
- assert_predicate(r.real, :integer?)
- assert_predicate(r.imag, :integer?)
- end
end
def test_quo
@@ -515,23 +400,12 @@ class Complex_Test < Test::Unit::TestCase
r = c ** Rational(-2,3)
assert_in_delta(0.432, r.real, 0.001)
assert_in_delta(-0.393, r.imag, 0.001)
-
- c = Complex(0.0, -888888888888888.0)**8888
- assert_not_predicate(c.real, :nan?)
- assert_not_predicate(c.imag, :nan?)
end
def test_cmp
- assert_nil(Complex(5, 1) <=> Complex(2))
- assert_nil(5 <=> Complex(2, 1))
-
- assert_equal(1, Complex(5) <=> Complex(2))
- assert_equal(-1, Complex(2) <=> Complex(3))
- assert_equal(0, Complex(2) <=> Complex(2))
-
- assert_equal(1, Complex(5) <=> 2)
- assert_equal(-1, Complex(2) <=> 3)
- assert_equal(0, Complex(2) <=> 2)
+ assert_raise(NoMethodError){1 <=> Complex(1,1)}
+ assert_raise(NoMethodError){Complex(1,1) <=> 1}
+ assert_raise(NoMethodError){Complex(1,1) <=> Complex(1,1)}
end
def test_eqeq
@@ -872,42 +746,10 @@ class Complex_Test < Test::Unit::TestCase
end
- def test_Complex_with_invalid_exception
- assert_raise(ArgumentError) {
- Complex("0", exception: 1)
- }
- end
-
- def test_Complex_without_exception
- assert_nothing_raised(ArgumentError){
- assert_equal(nil, Complex('5x', exception: false))
- }
- assert_nothing_raised(ArgumentError){
- assert_equal(nil, Complex(nil, exception: false))
- }
- assert_nothing_raised(ArgumentError){
- assert_equal(nil, Complex(Object.new, exception: false))
- }
- assert_nothing_raised(ArgumentError){
- assert_equal(nil, Complex(1, nil, exception: false))
- }
- assert_nothing_raised(ArgumentError){
- assert_equal(nil, Complex(1, Object.new, exception: false))
- }
-
- o = Object.new
- def o.to_c; raise; end
- assert_nothing_raised(ArgumentError){
- assert_equal(nil, Complex(o, exception: false))
- }
- assert_nothing_raised(ArgumentError){
- assert_equal(nil, Complex(1, o, exception: false))
- }
- end
-
def test_respond
c = Complex(1,1)
assert_not_respond_to(c, :%)
+ assert_not_respond_to(c, :<=>)
assert_not_respond_to(c, :div)
assert_not_respond_to(c, :divmod)
assert_not_respond_to(c, :floor)
@@ -1116,30 +958,4 @@ class Complex_Test < Test::Unit::TestCase
def test_known_bug
end
- def test_canonicalize_internal
- obj = Class.new(Numeric) do
- attr_accessor :real
- alias real? real
- end.new
- obj.real = true
- c = Complex.rect(obj, 1);
- obj.real = false
- c = c.conj
- assert_equal(obj, c.real)
- assert_equal(-1, c.imag)
- end
-
- def test_canonicalize_polar
- obj = Class.new(Numeric) do
- def initialize
- @x = 2
- end
- def real?
- (@x -= 1) > 0
- end
- end.new
- assert_raise(TypeError) do
- Complex.polar(1, obj)
- end
- end
end
diff --git a/test/ruby/test_complexrational.rb b/test/ruby/test_complexrational.rb
index bf4e2b1809..0360f5ee42 100644
--- a/test/ruby/test_complexrational.rb
+++ b/test/ruby/test_complexrational.rb
@@ -102,7 +102,7 @@ class ComplexRational_Test < Test::Unit::TestCase
assert_equal(Complex(SimpleRat(4,3),SimpleRat(1,1)), c * 2)
assert_equal(Complex(SimpleRat(1,3),SimpleRat(1,4)), c / 2)
assert_equal(Complex(SimpleRat(7,36),SimpleRat(2,3)), c ** 2)
- assert_nil(c <=> 2)
+ assert_raise(NoMethodError){c <=> 2}
assert_equal(Complex(SimpleRat(8,3),SimpleRat(1,2)), 2 + c)
assert_equal(Complex(SimpleRat(4,3),SimpleRat(-1,2)), 2 - c)
@@ -111,7 +111,7 @@ class ComplexRational_Test < Test::Unit::TestCase
r = 2 ** c
assert_in_delta(1.4940, r.real, 0.001)
assert_in_delta(0.5392, r.imag, 0.001)
- assert_nil(2 <=> c)
+ assert_raise(NoMethodError){2 <=> c}
assert_equal(Complex(SimpleRat(13,6),SimpleRat(5,2)), c + cc)
assert_equal(Complex(SimpleRat(-5,6),SimpleRat(-3,2)), c - cc)
@@ -120,7 +120,7 @@ class ComplexRational_Test < Test::Unit::TestCase
r = c ** cc
assert_in_delta(0.1732, r.real, 0.001)
assert_in_delta(0.1186, r.imag, 0.001)
- assert_nil(c <=> cc)
+ assert_raise(NoMethodError){c <=> cc}
assert_equal(Complex(SimpleRat(13,6),SimpleRat(5,2)), cc + c)
assert_equal(Complex(SimpleRat(5,6),SimpleRat(3,2)), cc - c)
@@ -129,7 +129,7 @@ class ComplexRational_Test < Test::Unit::TestCase
r = cc ** c
assert_in_delta(0.5498, r.real, 0.001)
assert_in_delta(1.0198, r.imag, 0.001)
- assert_nil(cc <=> c)
+ assert_raise(NoMethodError){cc <=> c}
assert_equal([SimpleRat,SimpleRat],
(+c).instance_eval{[real.class, imag.class]})
diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb
index 1c73b66648..8784e0e988 100644
--- a/test/ruby/test_const.rb
+++ b/test/ruby/test_const.rb
@@ -48,17 +48,6 @@ class TestConst < Test::Unit::TestCase
assert_equal 8, TEST4
end
- def test_const_access_from_nil
- assert_raise(TypeError) { eval("nil::Object") }
- assert_nil eval("defined?(nil::Object)")
-
- assert_raise(TypeError) { eval("c = nil; c::Object") }
- assert_nil eval("c = nil; defined?(c::Object)")
-
- assert_raise(TypeError) { eval("sc = Class.new; sc::C = nil; sc::C::Object") }
- assert_nil eval("sc = Class.new; sc::C = nil; defined?(sc::C::Object)")
- end
-
def test_redefinition
c = Class.new
name = "X\u{5b9a 6570}"
diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb
index 8c62d20840..a06ac98c8c 100644
--- a/test/ruby/test_continuation.rb
+++ b/test/ruby/test_continuation.rb
@@ -88,16 +88,11 @@ class TestContinuation < Test::Unit::TestCase
@memo += 1
c = cont
cont = nil
- begin
- c.call(nil)
- rescue RuntimeError
- set_trace_func(nil)
- end
+ c.call(nil)
end
end
end
cont = callcc { |cc| cc }
-
if cont
set_trace_func(func)
else
@@ -105,12 +100,12 @@ class TestContinuation < Test::Unit::TestCase
end
end
- def _test_tracing_with_set_trace_func
+ def test_tracing_with_set_trace_func
@memo = 0
tracing_with_set_trace_func
tracing_with_set_trace_func
tracing_with_set_trace_func
- assert_equal 0, @memo
+ assert_equal 3, @memo
end
def tracing_with_thread_set_trace_func
@@ -120,11 +115,7 @@ class TestContinuation < Test::Unit::TestCase
@memo += 1
c = cont
cont = nil
- begin
- c.call(nil)
- rescue RuntimeError
- Thread.current.set_trace_func(nil)
- end
+ c.call(nil)
end
end
cont = callcc { |cc| cc }
diff --git a/test/ruby/test_default_gems.rb b/test/ruby/test_default_gems.rb
deleted file mode 100644
index 3c4aea1561..0000000000
--- a/test/ruby/test_default_gems.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: false
-require 'rubygems'
-
-class TestDefaultGems < Test::Unit::TestCase
-
- def test_validate_gemspec
- skip "git not found" unless system("git", "rev-parse", %i[out err]=>IO::NULL)
- srcdir = File.expand_path('../../..', __FILE__)
- Dir.glob("#{srcdir}/{lib,ext}/**/*.gemspec").map do |src|
- assert_nothing_raised do
- raise("invalid spec in #{src}") unless Gem::Specification.load(src)
- end
- end
- end
-
-end
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb
index e1571d5714..9976db3b6f 100644
--- a/test/ruby/test_defined.rb
+++ b/test/ruby/test_defined.rb
@@ -23,80 +23,40 @@ class TestDefined < Test::Unit::TestCase
return !defined?(yield)
end
- def test_defined_global_variable
+ def test_defined
$x = nil
assert(defined?($x)) # global variable
assert_equal('global-variable', defined?($x))# returns description
- end
- def test_defined_local_variable
assert_nil(defined?(foo)) # undefined
foo=5
assert(defined?(foo)) # local variable
- end
- def test_defined_constant
assert(defined?(Array)) # constant
assert(defined?(::Array)) # toplevel constant
assert(defined?(File::Constants)) # nested constant
- end
-
- def test_defined_public_method
assert(defined?(Object.new)) # method
assert(defined?(Object::new)) # method
- end
-
- def test_defined_private_method
assert(!defined?(Object.print)) # private method
- end
-
- def test_defined_operator
assert(defined?(1 == 2)) # operator expression
- end
- def test_defined_protected_method
f = Foo.new
assert_nil(defined?(f.foo)) # protected method
f.bar(f) { |v| assert(v) }
- f.bar(Class.new(Foo).new) { |v| assert(v, "inherited protected method") }
- end
-
- def test_defined_undefined_method
- f = Foo.new
assert_nil(defined?(f.quux)) # undefined method
- end
-
- def test_defined_undefined_argument
- f = Foo.new
assert_nil(defined?(f.baz(x))) # undefined argument
x = 0
assert(defined?(f.baz(x)))
assert_nil(defined?(f.quux(x)))
assert(defined?(print(x)))
assert_nil(defined?(quux(x)))
- end
-
- def test_defined_attrasgn
- f = Foo.new
assert(defined?(f.attr = 1))
f.attrasgn_test { |v| assert(v) }
- end
-
- def test_defined_undef
- x = Object.new
- def x.foo; end
- assert(defined?(x.foo))
- x.instance_eval {undef :foo}
- assert(!defined?(x.foo), "undefed method should not be defined?")
- end
- def test_defined_yield
assert(defined_test) # not iterator
assert(!defined_test{}) # called as iterator
- end
- def test_defined_matchdata
/a/ =~ ''
assert_equal nil, defined?($&)
assert_equal nil, defined?($`)
@@ -125,16 +85,12 @@ class TestDefined < Test::Unit::TestCase
assert_equal 'global-variable', defined?($+)
assert_equal 'global-variable', defined?($1)
assert_equal nil, defined?($2)
- end
- def test_defined_literal
assert_equal("nil", defined?(nil))
assert_equal("true", defined?(true))
assert_equal("false", defined?(false))
assert_equal("expression", defined?(1))
- end
- def test_defined_empty_paren_expr
bug8224 = '[ruby-core:54024] [Bug #8224]'
(1..3).each do |level|
expr = "("*level+")"*level
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index 1bb228fd45..000bc24e85 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -11,13 +11,11 @@ class TestDir < Test::Unit::TestCase
$VERBOSE = nil
@root = File.realpath(Dir.mktmpdir('__test_dir__'))
@nodir = File.join(@root, "dummy")
- @dirs = []
for i in "a".."z"
if i.ord % 2 == 0
FileUtils.touch(File.join(@root, i))
else
FileUtils.mkdir(File.join(@root, i))
- @dirs << File.join(i, "")
end
end
end
@@ -122,7 +120,6 @@ class TestDir < Test::Unit::TestCase
end
def test_chroot_nodir
- skip if RUBY_PLATFORM =~ /android/
assert_raise(NotImplementedError, Errno::ENOENT, Errno::EPERM
) { Dir.chroot(File.join(@nodir, "")) }
end
@@ -139,9 +136,8 @@ class TestDir < Test::Unit::TestCase
Dir.glob(File.join(@root, "*"), File::FNM_DOTMATCH).sort)
assert_equal([@root] + ("a".."z").map {|f| File.join(@root, f) }.sort,
Dir.glob([@root, File.join(@root, "*")]).sort)
- assert_raise_with_message(ArgumentError, /nul-separated/) do
- Dir.glob(@root + "\0\0\0" + File.join(@root, "*"))
- end
+ assert_equal([@root] + ("a".."z").map {|f| File.join(@root, f) }.sort,
+ Dir.glob(@root + "\0\0\0" + File.join(@root, "*")).sort)
assert_equal(("a".."z").step(2).map {|f| File.join(File.join(@root, f), "") }.sort,
Dir.glob(File.join(@root, "*/")).sort)
@@ -191,28 +187,6 @@ class TestDir < Test::Unit::TestCase
end
end
- def test_glob_recursive_directory
- Dir.chdir(@root) do
- ['d', 'e'].each do |path|
- FileUtils.mkdir_p("c/#{path}/a/b/c")
- FileUtils.touch("c/#{path}/a/a.file")
- FileUtils.touch("c/#{path}/a/b/b.file")
- FileUtils.touch("c/#{path}/a/b/c/c.file")
- end
- bug15540 = '[ruby-core:91110] [Bug #15540]'
- assert_equal(["c/d/a/", "c/d/a/b/", "c/d/a/b/c/", "c/e/a/", "c/e/a/b/", "c/e/a/b/c/"],
- Dir.glob('c/{d,e}/a/**/'), bug15540)
- end
- end
-
- def test_glob_starts_with_brace
- Dir.chdir(@root) do
- bug15649 = '[ruby-core:91728] [Bug #15649]'
- assert_equal(["#{@root}/a", "#{@root}/b"],
- Dir.glob("{#{@root}/a,#{@root}/b}"), bug15649)
- end
- end
-
if Process.const_defined?(:RLIMIT_NOFILE)
def test_glob_too_may_open_files
assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}", chdir: @root)
@@ -234,38 +208,18 @@ class TestDir < Test::Unit::TestCase
def test_glob_base
files = %w[a/foo.c c/bar.c]
files.each {|n| File.write(File.join(@root, n), "")}
- Dir.mkdir(File.join(@root, "a/dir"))
- dirs = @dirs + %w[a/dir/]
- dirs.sort!
assert_equal(files, Dir.glob("*/*.c", base: @root).sort)
assert_equal(files, Dir.chdir(@root) {Dir.glob("*/*.c", base: ".").sort})
assert_equal(%w[foo.c], Dir.chdir(@root) {Dir.glob("*.c", base: "a").sort})
assert_equal(files, Dir.chdir(@root) {Dir.glob("*/*.c", base: "").sort})
assert_equal(files, Dir.chdir(@root) {Dir.glob("*/*.c", base: nil).sort})
- assert_equal(@dirs, Dir.glob("*/", base: @root).sort)
- assert_equal(@dirs, Dir.chdir(@root) {Dir.glob("*/", base: ".").sort})
- assert_equal(%w[dir/], Dir.chdir(@root) {Dir.glob("*/", base: "a").sort})
- assert_equal(@dirs, Dir.chdir(@root) {Dir.glob("*/", base: "").sort})
- assert_equal(@dirs, Dir.chdir(@root) {Dir.glob("*/", base: nil).sort})
- assert_equal(dirs, Dir.glob("**/*/", base: @root).sort)
- assert_equal(dirs, Dir.chdir(@root) {Dir.glob("**/*/", base: ".").sort})
- assert_equal(%w[dir/], Dir.chdir(@root) {Dir.glob("**/*/", base: "a").sort})
- assert_equal(dirs, Dir.chdir(@root) {Dir.glob("**/*/", base: "").sort})
- assert_equal(dirs, Dir.chdir(@root) {Dir.glob("**/*/", base: nil).sort})
end
def test_glob_base_dir
files = %w[a/foo.c c/bar.c]
files.each {|n| File.write(File.join(@root, n), "")}
- Dir.mkdir(File.join(@root, "a/dir"))
- dirs = @dirs + %w[a/dir/]
- dirs.sort!
assert_equal(files, Dir.open(@root) {|d| Dir.glob("*/*.c", base: d)}.sort)
- assert_equal(%w[foo.c], Dir.chdir(@root) {Dir.open("a") {|d| Dir.glob("*.c", base: d)}})
- assert_equal(@dirs, Dir.open(@root) {|d| Dir.glob("*/", base: d).sort})
- assert_equal(%w[dir/], Dir.chdir(@root) {Dir.open("a") {|d| Dir.glob("*/", base: d).sort}})
- assert_equal(dirs, Dir.open(@root) {|d| Dir.glob("**/*/", base: d).sort})
- assert_equal(%w[dir/], Dir.chdir(@root) {Dir.open("a") {|d| Dir.glob("**/*/", base: d).sort}})
+ assert_equal(%w[foo.c], Dir.chdir(@root) {Dir.open("a") {|d| Dir.glob("*", base: d)}})
end
def assert_entries(entries, children_only = false)
@@ -288,13 +242,11 @@ class TestDir < Test::Unit::TestCase
end
def test_children
- assert_entries(Dir.open(@root) {|dir| dir.children}, true)
assert_entries(Dir.children(@root), true)
assert_raise(ArgumentError) {Dir.children(@root+"\0")}
end
def test_each_child
- assert_entries(Dir.open(@root) {|dir| dir.each_child.to_a}, true)
assert_entries(Dir.each_child(@root).to_a, true)
assert_raise(ArgumentError) {Dir.each_child(@root+"\0").to_a}
end
@@ -392,18 +344,14 @@ class TestDir < Test::Unit::TestCase
ENV.delete("LOGDIR")
ENV["HOME"] = @nodir
- assert_nothing_raised(ArgumentError) do
+ assert_nothing_raised(ArgumentError) {
assert_equal(@nodir, Dir.home)
- end
- assert_nothing_raised(ArgumentError) do
assert_equal(@nodir, Dir.home(""))
- end
- if user = ENV["USER"]
- tilde = windows? ? "~" : "~#{user}"
- assert_nothing_raised(ArgumentError) do
- assert_equal(File.expand_path(tilde), Dir.home(user))
+ if user = ENV["USER"]
+ ENV["HOME"] = env_home
+ assert_equal(File.expand_path(env_home), Dir.home(user))
end
- end
+ }
%W[no:such:user \u{7559 5b88}:\u{756a}].each do |user|
assert_raise_with_message(ArgumentError, /#{user}/) {Dir.home(user)}
end
@@ -465,11 +413,8 @@ class TestDir < Test::Unit::TestCase
begin;
Process.setrlimit(Process::RLIMIT_NOFILE, 50)
begin
- fs = []
- tap {tap {tap {(0..100).each {fs << open(IO::NULL)}}}}
+ tap {tap {tap {(0..100).map {open(IO::NULL)}}}}
rescue Errno::EMFILE
- ensure
- fs.clear
end
list = Dir.glob("*").sort
assert_not_empty(list)
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb
index c2c0c4999e..7584074c7e 100644
--- a/test/ruby/test_dir_m17n.rb
+++ b/test/ruby/test_dir_m17n.rb
@@ -18,7 +18,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = #{code}.chr('UTF-8').force_encoding("#{encoding}")
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
assert_include(ents, filename)
EOS
@@ -26,7 +26,7 @@ class TestDir_M17N < Test::Unit::TestCase
assert_separately(%w[-EASCII-8BIT], <<-EOS, :chdir=>dir)
filename = #{code}.chr('UTF-8').force_encoding("ASCII-8BIT")
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
expected_filename = #{code}.chr('UTF-8').encode(Encoding.find("filesystem")) rescue expected_filename = "?"
expected_filename = expected_filename.force_encoding("ASCII-8BIT")
if /mswin|mingw/ =~ RUBY_PLATFORM
@@ -35,7 +35,7 @@ class TestDir_M17N < Test::Unit::TestCase
when ents.include?(expected_filename)
filename = expected_filename
else
- ents = Dir.entries(".", :encoding => Encoding.find("filesystem"))
+ ents = Dir.entries(".", {:encoding => Encoding.find("filesystem")})
filename = expected_filename
end
end
@@ -52,7 +52,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\u3042"
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
assert_include(ents, filename)
EOS
}
@@ -67,7 +67,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\xff".force_encoding("ASCII-8BIT") # invalid byte sequence as UTF-8
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
filename = "%FF" if /darwin/ =~ RUBY_PLATFORM && ents.include?("%FF")
assert_include(ents, filename)
EOS
@@ -75,7 +75,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\xff".force_encoding("UTF-8") # invalid byte sequence as UTF-8
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
filename = "%FF" if /darwin/ =~ RUBY_PLATFORM && ents.include?("%FF")
assert_include(ents, filename)
EOS
@@ -88,7 +88,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\xc2\xa1".force_encoding("utf-8")
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
assert_include(ents, filename)
EOS
assert_separately(%w[-EUTF-8], <<-'EOS', :chdir=>d)
@@ -125,13 +125,13 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\u3042"
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
assert_include(ents, filename)
EOS
assert_separately(%w[-EUTF-8:EUC-JP], <<-'EOS', :chdir=>d)
filename = "\xA4\xA2".force_encoding("euc-jp")
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
assert_include(ents, filename)
EOS
assert_separately(%w[-EUTF-8:EUC-JP], <<-'EOS', :chdir=>d)
@@ -151,7 +151,7 @@ class TestDir_M17N < Test::Unit::TestCase
File.open(filename1, "w") {}
File.open(filename2, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
assert_include(ents, filename1)
assert_include(ents, filename2)
EOS
@@ -159,7 +159,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename1 = "\u2661" # WHITE HEART SUIT which is not representable in EUC-JP
filename2 = "\xA4\xA2".force_encoding("euc-jp") # HIRAGANA LETTER A in EUC-JP
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
assert_include(ents, filename1)
assert_include(ents, filename2)
EOS
@@ -183,7 +183,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\xA4\xA2".force_encoding("euc-jp")
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
ents.each {|e| e.force_encoding("ASCII-8BIT") }
if /darwin/ =~ RUBY_PLATFORM
filename = filename.encode("utf-8")
@@ -200,7 +200,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\xA4\xA2".force_encoding("euc-jp")
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
if /darwin/ =~ RUBY_PLATFORM
filename = filename.encode("utf-8").force_encoding("euc-jp")
end
@@ -210,14 +210,14 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\xA4\xA2".force_encoding('ASCII-8BIT')
win_expected_filename = filename.encode(Encoding.find("filesystem"), "euc-jp") rescue "?"
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
unless ents.include?(filename)
case RUBY_PLATFORM
when /darwin/
filename = filename.encode("utf-8", "euc-jp").b
when /mswin|mingw/
if ents.include?(win_expected_filename.b)
- ents = Dir.entries(".", :encoding => Encoding.find("filesystem"))
+ ents = Dir.entries(".", {:encoding => Encoding.find("filesystem")})
filename = win_expected_filename
end
end
@@ -246,7 +246,7 @@ class TestDir_M17N < Test::Unit::TestCase
filename = "\xA4\xA2".force_encoding("euc-jp")
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
if /darwin/ =~ RUBY_PLATFORM
filename = filename.encode("utf-8", "euc-jp").force_encoding("euc-jp")
end
@@ -255,7 +255,7 @@ class TestDir_M17N < Test::Unit::TestCase
assert_separately(%w[-EEUC-JP:UTF-8], <<-'EOS', :chdir=>d)
filename = "\u3042"
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", **(opts||{}))
+ ents = Dir.entries(".", opts)
if /darwin/ =~ RUBY_PLATFORM
filename = filename.force_encoding("euc-jp")
end
@@ -420,7 +420,7 @@ class TestDir_M17N < Test::Unit::TestCase
else
orig.each {|o| o.force_encoding(enc) }
end
- ents = Dir.entries(".", **(opts||{})).reject {|n| /\A\./ =~ n}
+ ents = Dir.entries(".", opts).reject {|n| /\A\./ =~ n}
ents.sort!
PP.assert_equal(orig, ents, bug7267)
}
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb
index a469614d84..6f098db454 100644
--- a/test/ruby/test_econv.rb
+++ b/test/ruby/test_econv.rb
@@ -3,12 +3,7 @@ require 'test/unit'
class TestEncodingConverter < Test::Unit::TestCase
def check_ec(edst, esrc, eres, dst, src, ec, off, len, opts=nil)
- case opts
- when Hash
- res = ec.primitive_convert(src, dst, off, len, **opts)
- else
- res = ec.primitive_convert(src, dst, off, len, opts)
- end
+ res = ec.primitive_convert(src, dst, off, len, opts)
assert_equal([edst.b, esrc.b, eres],
[dst.b, src.b, res])
end
@@ -685,6 +680,7 @@ class TestEncodingConverter < Test::Unit::TestCase
ec = Encoding::Converter.new("utf-8", "euc-jp")
assert_raise(Encoding::InvalidByteSequenceError) { ec.convert("a\x80") }
assert_raise(Encoding::UndefinedConversionError) { ec.convert("\ufffd") }
+ assert_predicate(ec.convert("abc".taint), :tainted?)
ret = ec.primitive_convert(nil, "", nil, nil)
assert_equal(:finished, ret)
assert_raise(ArgumentError) { ec.convert("a") }
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb
index 019cb2417f..8f73a8fce1 100644
--- a/test/ruby/test_encoding.rb
+++ b/test/ruby/test_encoding.rb
@@ -34,6 +34,9 @@ class TestEncoding < Test::Unit::TestCase
assert_raise(TypeError) { e.dup }
assert_raise(TypeError) { e.clone }
assert_equal(e.object_id, Marshal.load(Marshal.dump(e)).object_id)
+ assert_not_predicate(e, :tainted?)
+ Marshal.load(Marshal.dump(e).taint)
+ assert_not_predicate(e, :tainted?, '[ruby-core:71793] [Bug #11760]')
end
end
@@ -117,21 +120,9 @@ class TestEncoding < Test::Unit::TestCase
assert_separately(%w[--disable=gems], "#{<<~"begin;"}\n#{<<~'end;'}")
bug9038 = '[ruby-core:57949] [Bug #9038]'
begin;
- e = assert_raise_with_message(SyntaxError, /unknown regexp option - Q/, bug9038) {
+ assert_raise_with_message(SyntaxError, /unknown regexp option - Q/, bug9038) {
eval("/regexp/sQ")
}
- assert_include(e.message, "/regexp/sQ\n")
- end;
- end
-
- def test_nonascii_library_path
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}".force_encoding("US-ASCII"))
- begin;
- assert_equal(Encoding::US_ASCII, __ENCODING__)
- $:.unshift("/\x80")
- assert_raise_with_message(LoadError, /\[Bug #16382\]/) do
- $:.resolve_feature_path "[Bug #16382]"
- end
end;
end
end
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index ef732b9924..2167271886 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -114,11 +114,6 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([1, 2, 3, 1, 2], @obj.to_a)
end
- def test_to_a_keywords
- def @obj.each(foo:) yield foo end
- assert_equal([1], @obj.to_a(foo: 1))
- end
-
def test_to_a_size_symbol
sym = Object.new
class << sym
@@ -149,7 +144,8 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([], inf.to_a)
end
- StubToH = Object.new.tap do |obj|
+ def test_to_h
+ obj = Object.new
def obj.each(*args)
yield(*args)
yield [:key, :value]
@@ -161,12 +157,6 @@ class TestEnumerable < Test::Unit::TestCase
yield kvp
end
obj.extend Enumerable
- obj.freeze
- end
-
- def test_to_h
- obj = StubToH
-
assert_equal({
:hello => :world,
:key => :value,
@@ -185,27 +175,6 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal "element has wrong array length (expected 2, was 1)", e.message
end
- def test_to_h_block
- obj = StubToH
-
- assert_equal({
- "hello" => "world",
- "key" => "value",
- "other_key" => "other_value",
- "obtained" => "via_to_ary",
- }, obj.to_h(:hello, :world) {|k, v| [k.to_s, v.to_s]})
-
- e = assert_raise(TypeError) {
- obj.to_h {:not_an_array}
- }
- assert_equal "wrong element type Symbol (expected array)", e.message
-
- e = assert_raise(ArgumentError) {
- obj.to_h {[1]}
- }
- assert_equal "element has wrong array length (expected 2, was 1)", e.message
- end
-
def test_inject
assert_equal(12, @obj.inject {|z, x| z * x })
assert_equal(48, @obj.inject {|z, x| z * 2 + x })
@@ -233,13 +202,11 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal(15, [3, 5, 7].inject(:+))
assert_float_equal(15.0, [3, 5, 7.0].inject(:+))
assert_equal(2*FIXNUM_MAX, Array.new(2, FIXNUM_MAX).inject(:+))
- assert_equal(3*FIXNUM_MAX, Array.new(3, FIXNUM_MAX).inject(:+))
assert_equal(2*(FIXNUM_MAX+1), Array.new(2, FIXNUM_MAX+1).inject(:+))
assert_equal(10*FIXNUM_MAX, Array.new(10, FIXNUM_MAX).inject(:+))
assert_equal(0, ([FIXNUM_MAX, 1, -FIXNUM_MAX, -1]*10).inject(:+))
assert_equal(FIXNUM_MAX*10, ([FIXNUM_MAX+1, -1]*10).inject(:+))
assert_equal(2*FIXNUM_MIN, Array.new(2, FIXNUM_MIN).inject(:+))
- assert_equal(3*FIXNUM_MIN, Array.new(3, FIXNUM_MIN).inject(:+))
assert_equal((FIXNUM_MAX+1).to_f, [FIXNUM_MAX, 1, 0.0].inject(:+))
assert_float_equal(10.0, [3.0, 5].inject(2.0, :+))
assert_float_equal((FIXNUM_MAX+1).to_f, [0.0, FIXNUM_MAX+1].inject(:+))
@@ -301,11 +268,6 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal(h, @obj.each_with_index.group_by(&cond))
end
- def test_tally
- h = {1 => 2, 2 => 2, 3 => 1}
- assert_equal(h, @obj.tally)
- end
-
def test_first
assert_equal(1, @obj.first)
assert_equal([1, 2, 3], @obj.first(3))
@@ -326,17 +288,6 @@ class TestEnumerable < Test::Unit::TestCase
empty.first
empty.block.call
end;
-
- bug18475 = '[ruby-dev:107059]'
- assert_in_out_err([], <<-'end;', [], /unexpected break/, bug18475)
- e = Enumerator.new do |g|
- Thread.new do
- g << 1
- end.join
- end
-
- e.first
- end;
end
def test_sort
@@ -363,21 +314,6 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal(false, @obj.all?(1..2))
end
- def test_all_with_unused_block
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- [1, 2].all?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- (1..2).all?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- 3.times.all?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- {a: 1, b: 2}.all?([:b, 2]) {|x| x == 4 }
- EOS
- end
-
def test_any
assert_equal(true, @obj.any? {|x| x >= 3 })
assert_equal(false, @obj.any? {|x| x > 3 })
@@ -393,21 +329,6 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal(true, {a: 1, b: 2}.any?(->(kv) { kv == [:b, 2] }))
end
- def test_any_with_unused_block
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- [1, 23].any?(1) {|x| x == 1 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- (1..2).any?(34) {|x| x == 2 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- 3.times.any?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- {a: 1, b: 2}.any?([:b, 2]) {|x| x == 4 }
- EOS
- end
-
def test_one
assert(@obj.one? {|x| x == 3 })
assert(!(@obj.one? {|x| x == 1 }))
@@ -427,21 +348,6 @@ class TestEnumerable < Test::Unit::TestCase
assert([ nil, true, 99 ].one?(Integer))
end
- def test_one_with_unused_block
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- [1, 2].one?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- (1..2).one?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- 3.times.one?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- {a: 1, b: 2}.one?([:b, 2]) {|x| x == 4 }
- EOS
- end
-
def test_none
assert(@obj.none? {|x| x == 4 })
assert(!(@obj.none? {|x| x == 1 }))
@@ -459,21 +365,6 @@ class TestEnumerable < Test::Unit::TestCase
assert(@empty.none?)
end
- def test_none_with_unused_block
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- [1, 2].none?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- (1..2).none?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- 3.times.none?(1) {|x| x == 3 }
- EOS
- assert_in_out_err [], <<-EOS, [], ["-:1: warning: given block not used"]
- {a: 1, b: 2}.none?([:b, 2]) {|x| x == 4 }
- EOS
- end
-
def test_min
assert_equal(1, @obj.min)
assert_equal(3, @obj.min {|a,b| b <=> a })
@@ -753,19 +644,6 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([2,1,3,2,1], @obj.reverse_each.to_a)
end
- def test_reverse_each_memory_corruption
- bug16354 = '[ruby-dev:50867]'
- assert_normal_exit %q{
- size = 1000
- (0...size).reverse_each do |i|
- i.inspect
- ObjectSpace.each_object(Array) do |a|
- a.clear if a.length == size
- end
- end
- }, bug16354
- end
-
def test_chunk
e = [].chunk {|elt| true }
assert_equal([], e.to_a)
@@ -1151,29 +1029,4 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([1, 2, 3, 4, 5, 10], (1..100).uniq{|x| (x**2) % 10 }.first(6))
assert_equal([1, [1, 2]], Foo.new.to_enum.uniq)
end
-
- def test_transient_heap_sort_by
- klass = Class.new do
- include Comparable
- attr_reader :i
- def initialize e
- @i = e
- end
- def <=> other
- GC.start
- i <=> other.i
- end
- end
- assert_equal [1, 2, 3, 4, 5], (1..5).sort_by{|e| klass.new e}
- end
-
- def test_filter_map
- @obj = (1..8).to_a
- assert_equal([4, 8, 12, 16], @obj.filter_map { |i| i * 2 if i.even? })
- assert_equal([2, 4, 6, 8, 10, 12, 14, 16], @obj.filter_map { |i| i * 2 })
- assert_equal([0, 0, 0, 0, 0, 0, 0, 0], @obj.filter_map { 0 })
- assert_equal([], @obj.filter_map { false })
- assert_equal([], @obj.filter_map { nil })
- assert_instance_of(Enumerator, @obj.filter_map)
- end
end
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index b619150571..66a45cc14e 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -72,6 +72,7 @@ class TestEnumerator < Test::Unit::TestCase
_, err = capture_io do
assert_equal([1, 2, 3], Enumerator.new(@obj, :foo, 1, 2, 3).to_a)
end
+ assert_match 'Enumerator.new without a block is deprecated', err
assert_equal([1, 2, 3], Enumerator.new { |y| i = 0; loop { y << (i += 1) } }.take(3))
assert_raise(ArgumentError) { Enumerator.new }
@@ -112,11 +113,6 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal([[1,2,3],[4,5,6],[7,8,9],[10]], (1..10).each_slice(3).to_a)
end
- def test_each_slice_size
- assert_equal(4, (1..10).each_slice(3).size)
- assert_equal(Float::INFINITY, 1.step.each_slice(3).size)
- end
-
def test_cons
a = [[1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7], [6,7,8], [7,8,9], [8,9,10]]
assert_equal(a, (1..10).each_cons(3).to_a)
@@ -305,11 +301,8 @@ class TestEnumerator < Test::Unit::TestCase
yield
end
ary = []
- e = o.to_enum { 1 }
- assert_equal(1, e.size)
- e_arg = e.each(ary)
- assert_equal(nil, e_arg.size)
- e_arg.next
+ e = o.to_enum.each(ary)
+ e.next
assert_equal([1], ary)
end
@@ -411,12 +404,6 @@ class TestEnumerator < Test::Unit::TestCase
e = (0..10).each_cons(2)
assert_equal("#<Enumerator: 0..10:each_cons(2)>", e.inspect)
- e = (0..10).each_with_object({})
- assert_equal("#<Enumerator: 0..10:each_with_object({})>", e.inspect)
-
- e = (0..10).each_with_object(a: 1)
- assert_equal("#<Enumerator: 0..10:each_with_object(a: 1)>", e.inspect)
-
e = Enumerator.new {|y| y.yield; 10 }
assert_match(/\A#<Enumerator: .*:each>/, e.inspect)
@@ -489,29 +476,8 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal([1], y.yield(1))
assert_equal([1, 2], y.yield(2))
assert_equal([1, 2, 3], y.yield(3))
- assert_equal([1, 2, 3, 4], y.yield(4, 5))
-
- a = []
- y = Enumerator::Yielder.new {|*x| a.concat(x) }
- assert_equal([1], y.yield(1))
- assert_equal([1, 2, 3], y.yield(2, 3))
assert_raise(LocalJumpError) { Enumerator::Yielder.new }
-
- # to_proc (explicit)
- a = []
- y = Enumerator::Yielder.new {|x| a << x }
- b = y.to_proc
- assert_kind_of(Proc, b)
- assert_equal([1], b.call(1))
- assert_equal([1], a)
-
- # to_proc (implicit)
- e = Enumerator.new { |y|
- assert_kind_of(Enumerator::Yielder, y)
- [1, 2, 3].each(&y)
- }
- assert_equal([1, 2, 3], e.to_a)
end
def test_size
@@ -539,14 +505,14 @@ class TestEnumerator < Test::Unit::TestCase
def test_size_for_enum_created_from_array
arr = %w[hello world]
%i[each each_with_index reverse_each sort_by! sort_by map map!
- keep_if reject! reject select! select filter! filter delete_if].each do |method|
+ keep_if reject! reject select! select delete_if].each do |method|
assert_equal arr.size, arr.send(method).size
end
end
def test_size_for_enum_created_from_enumerable
%i[find_all reject map flat_map partition group_by sort_by min_by max_by
- minmax_by each_with_index reverse_each each_entry filter_map].each do |method|
+ minmax_by each_with_index reverse_each each_entry].each do |method|
assert_equal nil, @obj.send(method).size
assert_equal 42, @sized.send(method).size
end
@@ -556,7 +522,7 @@ class TestEnumerator < Test::Unit::TestCase
def test_size_for_enum_created_from_hash
h = {a: 1, b: 2, c: 3}
- methods = %i[delete_if reject reject! select select! filter filter! keep_if each each_key each_pair]
+ methods = %i[delete_if reject reject! select select! keep_if each each_key each_pair]
enums = methods.map {|method| h.send(method)}
s = enums.group_by(&:size)
assert_equal([3], s.keys, ->{s.reject!{|k| k==3}.inspect})
@@ -566,7 +532,7 @@ class TestEnumerator < Test::Unit::TestCase
end
def test_size_for_enum_created_from_env
- %i[each_pair reject! delete_if select select! filter filter! keep_if].each do |method|
+ %i[each_pair reject! delete_if select select! keep_if].each do |method|
assert_equal ENV.size, ENV.send(method).size
end
end
@@ -666,7 +632,7 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal 4, (1..10).step(3).size
assert_equal 3, (1...10).step(3).size
assert_equal Float::INFINITY, (42..Float::INFINITY).step(2).size
- assert_equal 0, (1..10).step(-2).size
+ assert_raise(ArgumentError){ (1..10).step(-2).size }
end
def test_size_for_downup_to
@@ -695,188 +661,5 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal([0, 1], u.force)
assert_equal([0, 1], u.force)
end
-
- def test_enum_chain_and_plus
- r = 1..5
-
- e1 = r.chain()
- assert_kind_of(Enumerator::Chain, e1)
- assert_equal(5, e1.size)
- ary = []
- e1.each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5], ary)
-
- e2 = r.chain([6, 7, 8])
- assert_kind_of(Enumerator::Chain, e2)
- assert_equal(8, e2.size)
- ary = []
- e2.each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8], ary)
-
- e3 = r.chain([6, 7], 8.step)
- assert_kind_of(Enumerator::Chain, e3)
- assert_equal(Float::INFINITY, e3.size)
- ary = []
- e3.take(10).each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ary)
-
- # `a + b + c` should not return `Enumerator::Chain.new(a, b, c)`
- # because it is expected that `(a + b).each` be called.
- e4 = e2.dup
- class << e4
- attr_reader :each_is_called
- def each
- super
- @each_is_called = true
- end
- end
- e5 = e4 + 9.step
- assert_kind_of(Enumerator::Chain, e5)
- assert_equal(Float::INFINITY, e5.size)
- ary = []
- e5.take(10).each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ary)
- assert_equal(true, e4.each_is_called)
- end
-
- def test_chained_enums
- a = (1..5).each
-
- e0 = Enumerator::Chain.new()
- assert_kind_of(Enumerator::Chain, e0)
- assert_equal(0, e0.size)
- ary = []
- e0.each { |x| ary << x }
- assert_equal([], ary)
-
- e1 = Enumerator::Chain.new(a)
- assert_kind_of(Enumerator::Chain, e1)
- assert_equal(5, e1.size)
- ary = []
- e1.each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5], ary)
-
- e2 = Enumerator::Chain.new(a, [6, 7, 8])
- assert_kind_of(Enumerator::Chain, e2)
- assert_equal(8, e2.size)
- ary = []
- e2.each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8], ary)
-
- e3 = Enumerator::Chain.new(a, [6, 7], 8.step)
- assert_kind_of(Enumerator::Chain, e3)
- assert_equal(Float::INFINITY, e3.size)
- ary = []
- e3.take(10).each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ary)
-
- e4 = Enumerator::Chain.new(a, Enumerator.new { |y| y << 6 << 7 << 8 })
- assert_kind_of(Enumerator::Chain, e4)
- assert_equal(nil, e4.size)
- ary = []
- e4.each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8], ary)
-
- e5 = Enumerator::Chain.new(e1, e2)
- assert_kind_of(Enumerator::Chain, e5)
- assert_equal(13, e5.size)
- ary = []
- e5.each { |x| ary << x }
- assert_equal([1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8], ary)
-
- rewound = []
- e1.define_singleton_method(:rewind) { rewound << object_id }
- e2.define_singleton_method(:rewind) { rewound << object_id }
- e5.rewind
- assert_equal(rewound, [e2.object_id, e1.object_id])
-
- rewound = []
- a = [1]
- e6 = Enumerator::Chain.new(a)
- a.define_singleton_method(:rewind) { rewound << object_id }
- e6.rewind
- assert_equal(rewound, [])
-
- assert_equal(
- '#<Enumerator::Chain: [' +
- '#<Enumerator::Chain: [' +
- '#<Enumerator: 1..5:each>' +
- ']>, ' +
- '#<Enumerator::Chain: [' +
- '#<Enumerator: 1..5:each>, ' +
- '[6, 7, 8]' +
- ']>' +
- ']>',
- e5.inspect
- )
- end
-
- def test_produce
- assert_raise(ArgumentError) { Enumerator.produce }
-
- # Without initial object
- passed_args = []
- enum = Enumerator.produce { |obj| passed_args << obj; (obj || 0).succ }
- assert_instance_of(Enumerator, enum)
- assert_equal Float::INFINITY, enum.size
- assert_equal [1, 2, 3], enum.take(3)
- assert_equal [nil, 1, 2], passed_args
-
- # With initial object
- passed_args = []
- enum = Enumerator.produce(1) { |obj| passed_args << obj; obj.succ }
- assert_instance_of(Enumerator, enum)
- assert_equal Float::INFINITY, enum.size
- assert_equal [1, 2, 3], enum.take(3)
- assert_equal [1, 2], passed_args
-
- # With initial keyword arguments
- passed_args = []
- enum = Enumerator.produce(a: 1, b: 1) { |obj| passed_args << obj; obj.shift if obj.respond_to?(:shift)}
- assert_instance_of(Enumerator, enum)
- assert_equal Float::INFINITY, enum.size
- assert_equal [{b: 1}, [1], :a, nil], enum.take(4)
- assert_equal [{b: 1}, [1], :a], passed_args
-
- # Raising StopIteration
- words = "The quick brown fox jumps over the lazy dog.".scan(/\w+/)
- enum = Enumerator.produce { words.shift or raise StopIteration }
- assert_equal Float::INFINITY, enum.size
- assert_instance_of(Enumerator, enum)
- assert_equal %w[The quick brown fox jumps over the lazy dog], enum.to_a
-
- # Raising StopIteration
- object = [[[["abc", "def"], "ghi", "jkl"], "mno", "pqr"], "stuv", "wxyz"]
- enum = Enumerator.produce(object) { |obj|
- obj.respond_to?(:first) or raise StopIteration
- obj.first
- }
- assert_equal Float::INFINITY, enum.size
- assert_instance_of(Enumerator, enum)
- assert_nothing_raised {
- assert_equal [
- [[[["abc", "def"], "ghi", "jkl"], "mno", "pqr"], "stuv", "wxyz"],
- [[["abc", "def"], "ghi", "jkl"], "mno", "pqr"],
- [["abc", "def"], "ghi", "jkl"],
- ["abc", "def"],
- "abc",
- ], enum.to_a
- }
- end
-
- def test_chain_each_lambda
- c = Class.new do
- include Enumerable
- attr_reader :is_lambda
- def each(&block)
- return to_enum unless block
- @is_lambda = block.lambda?
- end
- end
- e = c.new
- e.chain.each{}
- assert_equal(false, e.is_lambda)
- e.chain.each(&->{})
- assert_equal(true, e.is_lambda)
- end
end
+
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index 02cd3b8502..ffed94efa6 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -46,6 +46,7 @@ class TestEnv < Test::Unit::TestCase
end
ENV['TEST'] = 'bar'
assert_equal('bar', ENV['TEST'])
+ assert_predicate(ENV['TEST'], :tainted?)
if IGNORE_CASE
assert_equal('bar', ENV['test'])
else
@@ -112,6 +113,7 @@ class TestEnv < Test::Unit::TestCase
assert_invalid_env {|v| ENV[v]}
ENV[PATH_ENV] = ""
assert_equal("", ENV[PATH_ENV])
+ assert_predicate(ENV[PATH_ENV], :tainted?)
assert_nil(ENV[""])
end
@@ -120,7 +122,7 @@ class TestEnv < Test::Unit::TestCase
assert_equal("foo", ENV.fetch("test"))
ENV.delete("test")
feature8649 = '[ruby-core:56062] [Feature #8649]'
- e = assert_raise_with_message(KeyError, /key not found: "test"/, feature8649) do
+ e = assert_raise_with_message(KeyError, 'key not found: "test"', feature8649) do
ENV.fetch("test")
end
assert_same(ENV, e.receiver)
@@ -134,6 +136,7 @@ class TestEnv < Test::Unit::TestCase
assert_nothing_raised { ENV.fetch(PATH_ENV, "foo") }
ENV[PATH_ENV] = ""
assert_equal("", ENV.fetch(PATH_ENV))
+ assert_predicate(ENV.fetch(PATH_ENV), :tainted?)
end
def test_aset
@@ -151,6 +154,9 @@ class TestEnv < Test::Unit::TestCase
assert_equal("test", ENV["foo"])
rescue Errno::EINVAL
end
+
+ ENV[PATH_ENV] = "/tmp/".taint
+ assert_equal("/tmp/", ENV[PATH_ENV])
end
def test_keys
@@ -216,18 +222,6 @@ class TestEnv < Test::Unit::TestCase
assert_nil(ENV.select! {|k, v| IGNORE_CASE ? k.upcase != "TEST" : k != "test" })
end
- def test_filter_bang
- h1 = {}
- ENV.each_pair {|k, v| h1[k] = v }
- ENV["test"] = "foo"
- ENV.filter! {|k, v| IGNORE_CASE ? k.upcase != "TEST" : k != "test" }
- h2 = {}
- ENV.each_pair {|k, v| h2[k] = v }
- assert_equal(h1, h2)
-
- assert_nil(ENV.filter! {|k, v| IGNORE_CASE ? k.upcase != "TEST" : k != "test" })
- end
-
def test_keep_if
h1 = {}
ENV.each_pair {|k, v| h1[k] = v }
@@ -260,32 +254,6 @@ class TestEnv < Test::Unit::TestCase
end
end
- def test_filter
- ENV["test"] = "foo"
- h = ENV.filter {|k| IGNORE_CASE ? k.upcase == "TEST" : k == "test" }
- assert_equal(1, h.size)
- k = h.keys.first
- v = h.values.first
- if IGNORE_CASE
- assert_equal("TEST", k.upcase)
- assert_equal("FOO", v.upcase)
- else
- assert_equal("test", k)
- assert_equal("foo", v)
- end
- end
-
- def test_slice
- ENV.clear
- ENV["foo"] = "bar"
- ENV["baz"] = "qux"
- ENV["bar"] = "rab"
- assert_equal({}, ENV.slice())
- assert_equal({}, ENV.slice(""))
- assert_equal({}, ENV.slice("unknown"))
- assert_equal({"foo"=>"bar", "baz"=>"qux"}, ENV.slice("foo", "baz"))
- end
-
def test_clear
ENV.clear
assert_equal(0, ENV.size)
@@ -358,6 +326,7 @@ class TestEnv < Test::Unit::TestCase
assert_equal("foo", v)
end
assert_invalid_env {|var| ENV.assoc(var)}
+ assert_predicate(v, :tainted?)
assert_equal(Encoding.find("locale"), v.encoding)
end
@@ -392,8 +361,6 @@ class TestEnv < Test::Unit::TestCase
def test_to_h
assert_equal(ENV.to_hash, ENV.to_h)
- assert_equal(ENV.map {|k, v| ["$#{k}", v.size]}.to_h,
- ENV.to_h {|k, v| ["$#{k}", v.size]})
end
def test_reject
@@ -433,8 +400,6 @@ class TestEnv < Test::Unit::TestCase
ENV["foo"] = "xxx"
ENV.replace({"foo"=>"bar", "baz"=>"qux"})
check(ENV.to_hash.to_a, [%w(foo bar), %w(baz qux)])
- ENV.replace({"Foo"=>"Bar", "Baz"=>"Qux"})
- check(ENV.to_hash.to_a, [%w(Foo Bar), %w(Baz Qux)])
end
def test_update
@@ -447,14 +412,14 @@ class TestEnv < Test::Unit::TestCase
ENV.clear
ENV["foo"] = "bar"
ENV["baz"] = "qux"
- ENV.update({"baz"=>"quux","a"=>"b"}) {|k, v1, v2| k + "_" + v1 + "_" + v2 }
+ ENV.update({"baz"=>"quux","a"=>"b"}) {|k, v1, v2| v1 ? k + "_" + v1 + "_" + v2 : v2 }
check(ENV.to_hash.to_a, [%w(foo bar), %w(baz baz_qux_quux), %w(a b)])
end
def test_huge_value
huge_value = "bar" * 40960
ENV["foo"] = "bar"
- if /mswin/ =~ RUBY_PLATFORM
+ if /mswin|mingw/ =~ RUBY_PLATFORM
assert_raise(Errno::EINVAL) { ENV["foo"] = huge_value }
assert_equal("bar", ENV["foo"])
else
@@ -464,10 +429,6 @@ class TestEnv < Test::Unit::TestCase
end
if /mswin|mingw/ =~ RUBY_PLATFORM
- def windows_version
- @windows_version ||= %x[ver][/Version (\d+)/, 1].to_i
- end
-
def test_win32_blocksize
keys = []
len = 32767 - ENV.to_a.flatten.inject(1) {|r,e| r + e.bytesize + 1}
@@ -477,24 +438,14 @@ class TestEnv < Test::Unit::TestCase
keys << key
ENV[key] = val
end
- if windows_version < 6
- 1.upto(12) {|i|
- assert_raise(Errno::EINVAL) { ENV[key] = val }
- }
- else
- 1.upto(12) {|i|
- assert_nothing_raised(Errno::EINVAL) { ENV[key] = val }
- }
- end
+ 1.upto(12) {|i|
+ assert_raise(Errno::EINVAL) { ENV[key] = val }
+ }
ensure
keys.each {|k| ENV.delete(k)}
end
end
- def test_frozen_env
- assert_raise(TypeError) { ENV.freeze }
- end
-
def test_frozen
ENV[PATH_ENV] = "/"
ENV.each do |k, v|
diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb
index 3d6116edbc..0bc0390d64 100644
--- a/test/ruby/test_eval.rb
+++ b/test/ruby/test_eval.rb
@@ -320,6 +320,20 @@ class TestEval < Test::Unit::TestCase
end
assert(!bad)
+ if false
+ # Ruby 2.0 doesn't see Proc as Binding
+ x = proc{}
+ eval "i4 = 1", x
+ assert_equal(1, eval("i4", x))
+ x = proc{proc{}}.call
+ eval "i4 = 22", x
+ assert_equal(22, eval("i4", x))
+ t = []
+ x = proc{proc{}}.call
+ eval "(0..9).each{|i5| t[i5] = proc{i5*2}}", x
+ assert_equal(8, t[4].call)
+ end
+
x = binding
eval "i = 1", x
assert_equal(1, eval("i", x))
@@ -345,8 +359,28 @@ class TestEval < Test::Unit::TestCase
# assert_equal(1, eval("foo11"))
assert_equal(eval("foo22"), eval("foo22", p))
assert_equal(55, eval("foo22"))
- assert_equal(55, foo22)
}.call
+
+ if false
+ # Ruby 2.0 doesn't see Proc as Binding
+ p1 = proc{i7 = 0; proc{i7}}.call
+ assert_equal(0, p1.call)
+ eval "i7=5", p1
+ assert_equal(5, p1.call)
+ assert(!defined?(i7))
+ end
+
+ if false
+ # Ruby 2.0 doesn't see Proc as Binding
+ p1 = proc{i7 = 0; proc{i7}}.call
+ i7 = nil
+ assert_equal(0, p1.call)
+ eval "i7=1", p1
+ assert_equal(1, p1.call)
+ eval "i7=5", p1
+ assert_equal(5, p1.call)
+ assert_nil(i7)
+ end
end
def test_nil_instance_eval_cvar
@@ -469,12 +503,6 @@ class TestEval < Test::Unit::TestCase
assert_same a, b
end
- def test_eval_location_binding
- assert_warning(/__FILE__ in eval/) do
- assert_equal(__FILE__, eval("__FILE__", binding))
- end
- end
-
def test_fstring_instance_eval
bug = "[ruby-core:78116] [Bug #12930]".freeze
assert_same bug, (bug.instance_eval {self})
@@ -498,17 +526,6 @@ class TestEval < Test::Unit::TestCase
}, '[Bug #10368]'
end
- def test_gced_eval_location
- Dir.mktmpdir do |d|
- File.write("#{d}/2.rb", "")
- File.write("#{d}/1.rb", "require_relative '2'\n""__FILE__\n")
- file = "1.rb"
- path = File.expand_path(file, d)
- assert_equal(path, eval(File.read(path), nil, File.expand_path(file, d)))
- assert_equal(path, eval(File.read(path), nil, File.expand_path(file, d)))
- end
- end
-
def orphan_proc
proc {eval("return :ng")}
end
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 9efcfc76cf..605248aebd 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -181,27 +181,6 @@ class TestException < Test::Unit::TestCase
}
end
- def test_catch_throw_in_require_cant_be_rescued
- bug18562 = '[ruby-core:107403]'
- Tempfile.create(["dep", ".rb"]) {|t|
- t.puts("throw :extdep, 42")
- t.close
-
- rescue_all = Class.new(Exception)
- def rescue_all.===(_)
- raise "should not reach here"
- end
-
- v = assert_throw(:extdep, bug18562) do
- require t.path
- rescue rescue_all => e
- assert(false, "should not reach here")
- end
-
- assert_equal(42, v, bug18562)
- }
- end
-
def test_throw_false
bug12743 = '[ruby-core:77229] [Bug #12743]'
Thread.start {
@@ -373,7 +352,6 @@ class TestException < Test::Unit::TestCase
end
def test_thread_signal_location
- skip
_, stderr, _ = EnvUtil.invoke_ruby(%w"--disable-gems -d", <<-RUBY, false, true)
Thread.start do
Thread.current.report_on_exception = false
@@ -509,15 +487,20 @@ end.join
end
def test_exception_in_name_error_to_str
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
bug5575 = '[ruby-core:41612]'
- begin;
+ Tempfile.create(["test_exception_in_name_error_to_str", ".rb"]) do |t|
+ t.puts <<-EOC
begin
BasicObject.new.inspect
rescue
- assert_nothing_raised(NameError, bug5575) {$!.inspect}
+ $!.inspect
end
- end;
+ EOC
+ t.close
+ assert_nothing_raised(NameError, bug5575) do
+ load(t.path)
+ end
+ end
end
def test_equal
@@ -527,28 +510,19 @@ end.join
end
def test_exception_in_exception_equal
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
bug5865 = '[ruby-core:41979]'
- begin;
+ Tempfile.create(["test_exception_in_exception_equal", ".rb"]) do |t|
+ t.puts <<-EOC
o = Object.new
def o.exception(arg)
end
+ _ = RuntimeError.new("a") == o
+ EOC
+ t.close
assert_nothing_raised(ArgumentError, bug5865) do
- RuntimeError.new("a") == o
+ load(t.path)
end
- end;
- end
-
- def test_backtrace_by_exception
- begin
- line = __LINE__; raise "foo"
- rescue => e
end
- e2 = e.exception("bar")
- assert_not_equal(e.message, e2.message)
- assert_equal(e.backtrace, e2.backtrace)
- loc = e2.backtrace_locations[0]
- assert_equal([__FILE__, line], [loc.path, loc.lineno])
end
Bug4438 = '[ruby-core:35364]'
@@ -571,6 +545,28 @@ end.join
end
end
+ def test_to_s_taintness_propagation
+ for exc in [Exception, NameError]
+ m = "abcdefg"
+ e = exc.new(m)
+ e.taint
+ s = e.to_s
+ assert_equal(false, m.tainted?,
+ "#{exc}#to_s should not propagate taintness")
+ assert_equal(false, s.tainted?,
+ "#{exc}#to_s should not propagate taintness")
+ end
+
+ o = Object.new
+ def o.to_str
+ "foo"
+ end
+ o.taint
+ e = NameError.new(o)
+ s = e.to_s
+ assert_equal(false, s.tainted?)
+ end
+
def m
m(&->{return 0})
42
@@ -703,11 +699,7 @@ end.join
end
def test_cause_at_end
- errs = [
- /-: unexpected return\n/,
- /.*undefined local variable or method `n'.*\n/,
- ]
- assert_in_out_err([], <<-'end;', [], errs)
+ assert_in_out_err([], <<-'end;', [], [/-: unexpected return\n/, /.*undefined local variable or method `n'.*\n/])
END{n}; END{return}
end;
end
@@ -811,7 +803,7 @@ end.join
e = assert_raise(exc, bug) {raise exc, "foo" => "bar", foo: "bar"}
assert_equal({"foo" => "bar", foo: "bar"}, e.arg, bug)
- e = assert_raise(exc, bug) {raise exc, "foo" => "bar", foo: "bar", cause: RuntimeError.new("zzz")}
+ e = assert_raise(exc, bug) {raise exc, "foo" => "bar", foo: "bar", cause: "zzz"}
assert_equal({"foo" => "bar", foo: "bar"}, e.arg, bug)
e = assert_raise(exc, bug) {raise exc, {}}
@@ -845,26 +837,6 @@ end.join
}
end
- def test_cause_exception_in_cause_message
- assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}") do |outs, errs, status|
- begin;
- exc = Class.new(StandardError) do
- def initialize(obj, cnt)
- super(obj)
- @errcnt = cnt
- end
- def to_s
- return super if @errcnt <= 0
- @errcnt -= 1
- raise "xxx"
- end
- end.new("ok", 10)
- raise "[Bug #17033]", cause: exc
- end;
- assert_equal(1, errs.count {|m| m.include?("[Bug #17033]")}, proc {errs.pretty_inspect})
- end
- end
-
def test_anonymous_message
assert_in_out_err([], "raise Class.new(RuntimeError), 'foo'", [], /foo\n/)
end
@@ -876,166 +848,6 @@ end.join
alias inspect pretty_inspect
end
- def test_frozen_error_receiver
- obj = Object.new.freeze
- (obj.foo = 1) rescue (e = $!)
- assert_same(obj, e.receiver)
- obj.singleton_class.const_set(:A, 2) rescue (e = $!)
- assert_same(obj.singleton_class, e.receiver)
- end
-
- def test_frozen_error_initialize
- obj = Object.new
- exc = FrozenError.new("bar", receiver: obj)
- assert_equal("bar", exc.message)
- assert_same(obj, exc.receiver)
-
- exc = FrozenError.new("bar")
- assert_equal("bar", exc.message)
- assert_raise_with_message(ArgumentError, "no receiver is available") {
- exc.receiver
- }
-
- exc = FrozenError.new
- assert_equal("FrozenError", exc.message)
- assert_raise_with_message(ArgumentError, "no receiver is available") {
- exc.receiver
- }
- end
-
- def test_frozen_error_message
- obj = Object.new.freeze
- e = assert_raise_with_message(FrozenError, /can't modify frozen #{obj.class}/) {
- obj.instance_variable_set(:@test, true)
- }
- assert_include(e.message, obj.inspect)
-
- klass = Class.new do
- def init
- @x = true
- end
- def inspect
- init
- super
- end
- end
- obj = klass.new.freeze
- e = assert_raise_with_message(FrozenError, /can't modify frozen #{obj.class}/) {
- obj.init
- }
- assert_include(e.message, klass.inspect)
- end
-
- def test_name_error_new_default
- error = NameError.new
- assert_equal("NameError", error.message)
- end
-
- def test_name_error_new_message
- error = NameError.new("Message")
- assert_equal("Message", error.message)
- end
-
- def test_name_error_new_name
- error = NameError.new("Message")
- assert_nil(error.name)
-
- error = NameError.new("Message", :foo)
- assert_equal(:foo, error.name)
- end
-
- def test_name_error_new_receiver
- receiver = Object.new
-
- error = NameError.new
- assert_raise(ArgumentError) {error.receiver}
- assert_equal("NameError", error.message)
-
- error = NameError.new(receiver: receiver)
- assert_equal(["NameError", receiver],
- [error.message, error.receiver])
-
- error = NameError.new("Message", :foo, receiver: receiver)
- assert_equal(["Message", receiver, :foo],
- [error.message, error.receiver, error.name])
- end
-
- def test_nomethod_error_new_default
- error = NoMethodError.new
- assert_equal("NoMethodError", error.message)
- end
-
- def test_nomethod_error_new_message
- error = NoMethodError.new("Message")
- assert_equal("Message", error.message)
- end
-
- def test_nomethod_error_new_name
- error = NoMethodError.new("Message")
- assert_nil(error.name)
-
- error = NoMethodError.new("Message", :foo)
- assert_equal(:foo, error.name)
- end
-
- def test_nomethod_error_new_name_args
- error = NoMethodError.new("Message", :foo)
- assert_nil(error.args)
-
- error = NoMethodError.new("Message", :foo, [1, 2])
- assert_equal([:foo, [1, 2]], [error.name, error.args])
- end
-
- def test_nomethod_error_new_name_args_priv
- error = NoMethodError.new("Message", :foo, [1, 2])
- assert_not_predicate(error, :private_call?)
-
- error = NoMethodError.new("Message", :foo, [1, 2], true)
- assert_equal([:foo, [1, 2], true],
- [error.name, error.args, error.private_call?])
- end
-
- def test_nomethod_error_new_receiver
- receiver = Object.new
-
- error = NoMethodError.new
- assert_raise(ArgumentError) {error.receiver}
-
- error = NoMethodError.new(receiver: receiver)
- assert_equal(receiver, error.receiver)
-
- error = NoMethodError.new("Message")
- assert_raise(ArgumentError) {error.receiver}
-
- error = NoMethodError.new("Message", receiver: receiver)
- assert_equal(["Message", receiver],
- [error.message, error.receiver])
-
- error = NoMethodError.new("Message", :foo)
- assert_raise(ArgumentError) {error.receiver}
-
- msg = defined?(DidYouMean.formatter) ?
- "Message\nDid you mean? for" : "Message"
-
- error = NoMethodError.new("Message", :foo, receiver: receiver)
- assert_equal([msg, :foo, receiver],
- [error.message, error.name, error.receiver])
-
- error = NoMethodError.new("Message", :foo, [1, 2])
- assert_raise(ArgumentError) {error.receiver}
-
- error = NoMethodError.new("Message", :foo, [1, 2], receiver: receiver)
- assert_equal([msg, :foo, [1, 2], receiver],
- [error.message, error.name, error.args, error.receiver])
-
- error = NoMethodError.new("Message", :foo, [1, 2], true)
- assert_raise(ArgumentError) {error.receiver}
-
- error = NoMethodError.new("Message", :foo, [1, 2], true, receiver: receiver)
- assert_equal([:foo, [1, 2], true, receiver],
- [error.name, error.args, error.private_call?, error.receiver])
- end
-
def test_name_error_info_const
obj = PrettyObject.new
@@ -1147,43 +959,6 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end;
end
- def assert_null_char(src, *args, **opts)
- begin
- eval(src)
- rescue => e
- end
- assert_not_nil(e)
- assert_include(e.message, "\0")
- assert_in_out_err([], src, [], [], *args, **opts) do |_, err,|
- err.each do |e|
- assert_not_include(e, "\0")
- end
- end
- e
- end
-
- def test_control_in_message
- bug7574 = '[ruby-dev:46749]'
- assert_null_char("#{<<~"begin;"}\n#{<<~'end;'}", bug7574)
- begin;
- Object.const_defined?("String\0")
- end;
- assert_null_char("#{<<~"begin;"}\n#{<<~'end;'}", bug7574)
- begin;
- Object.const_get("String\0")
- end;
- end
-
- def test_encoding_in_message
- name = "\u{e9}t\u{e9}"
- e = EnvUtil.with_default_external("US-ASCII") do
- assert_raise(NameError) do
- Object.const_get(name)
- end
- end
- assert_include(e.message, name)
- end
-
def test_method_missing_reason_clear
bug10969 = '[ruby-core:68515] [Bug #10969]'
a = Class.new {def method_missing(*) super end}.new
@@ -1201,7 +976,6 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
def capture_warning_warn
verbose = $VERBOSE
- deprecated = Warning[:deprecated]
warning = []
::Warning.class_eval do
@@ -1214,13 +988,11 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end
$VERBOSE = true
- Warning[:deprecated] = true
yield
return warning
ensure
$VERBOSE = verbose
- Warning[:deprecated] = deprecated
::Warning.class_eval do
remove_method :warn
@@ -1241,21 +1013,8 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
def test_kernel_warn_uplevel
warning = capture_warning_warn {warn("test warning", uplevel: 0)}
assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0])
- def (obj = Object.new).w(n) warn("test warning", uplevel: n) end
- warning = capture_warning_warn {obj.w(0)}
- assert_equal("#{__FILE__}:#{__LINE__-2}: warning: test warning\n", warning[0])
- warning = capture_warning_warn {obj.w(1)}
- assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0])
assert_raise(ArgumentError) {warn("test warning", uplevel: -1)}
assert_in_out_err(["-e", "warn 'ok', uplevel: 1"], '', [], /warning:/)
- warning = capture_warning_warn {warn("test warning", {uplevel: 0})}
- assert_equal("#{__FILE__}:#{__LINE__-1}: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call\n", warning[0])
- assert_match(/warning: The called method (?:`.*' )?is defined here|warning: test warning/, warning[1])
- warning = capture_warning_warn {warn("test warning", **{uplevel: 0})}
- assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0])
- warning = capture_warning_warn {warn("test warning", {uplevel: 0}, **{})}
- assert_equal("test warning\n{:uplevel=>0}\n", warning[0])
- assert_raise(ArgumentError) {warn("test warning", foo: 1)}
end
def test_warning_warn_invalid_argument
@@ -1303,13 +1062,6 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
};
end
- def test_warning_category
- assert_raise(TypeError) {Warning[nil]}
- assert_raise(ArgumentError) {Warning[:XXXX]}
- assert_include([true, false], Warning[:deprecated])
- assert_include([true, false], Warning[:experimental])
- end
-
def test_undefined_backtrace
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;
@@ -1389,39 +1141,16 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end
end
- def test_backtrace_in_eval
- bug = '[ruby-core:84434] [Bug #14229]'
- assert_in_out_err(['-e', 'eval("raise")'], "", [], /^\(eval\):1:/, bug)
- end
-
def test_full_message
- message = RuntimeError.new("testerror").full_message
- assert_operator(message, :end_with?, "\n")
-
test_method = "def foo; raise 'testerror'; end"
out1, err1, status1 = EnvUtil.invoke_ruby(['-e', "#{test_method}; begin; foo; rescue => e; puts e.full_message; end"], '', true, true)
- assert_predicate(status1, :success?)
- assert_empty(err1, "expected nothing wrote to $stdout by #full_message")
+ assert(status1.success?)
+ assert(err1.empty?, "expected nothing wrote to $stdout by #long_message")
_, err2, status1 = EnvUtil.invoke_ruby(['-e', "#{test_method}; begin; foo; end"], '', true, true)
assert_equal(err2, out1)
- e = RuntimeError.new("a\n")
- message = assert_nothing_raised(ArgumentError, proc {e.pretty_inspect}) do
- e.full_message
- end
- assert_operator(message, :end_with?, "\n")
- message = message.gsub(/\e\[[\d;]*m/, '')
- assert_not_operator(message, :end_with?, "\n\n")
- e = RuntimeError.new("a\n\nb\n\nc")
- message = assert_nothing_raised(ArgumentError, proc {e.pretty_inspect}) do
- e.full_message
- end
- assert_all?(message.lines) do |m|
- /\e\[\d[;\d]*m[^\e]*\n/ !~ m
- end
-
e = RuntimeError.new("testerror")
message = e.full_message(highlight: false)
assert_not_match(/\e/, message)
@@ -1429,43 +1158,20 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
bt = ["test:100", "test:99", "test:98", "test:1"]
e = assert_raise(RuntimeError) {raise RuntimeError, "testerror", bt}
- bottom = "test:100: testerror (RuntimeError)\n"
- top = "test:1\n"
- remark = "Traceback (most recent call last):"
-
message = e.full_message(highlight: false, order: :top)
assert_not_match(/\e/, message)
assert_operator(message.count("\n"), :>, 2)
- assert_operator(message, :start_with?, bottom)
- assert_operator(message, :end_with?, top)
+ assert_operator(message, :start_with?, "test:100: testerror (RuntimeError)\n")
+ assert_operator(message, :end_with?, "test:1\n")
message = e.full_message(highlight: false, order: :bottom)
assert_not_match(/\e/, message)
assert_operator(message.count("\n"), :>, 2)
- assert_operator(message, :start_with?, remark)
- assert_operator(message, :end_with?, bottom)
-
- assert_raise_with_message(ArgumentError, /:top or :bottom/) {
- e.full_message(highlight: false, order: :middle)
- }
+ assert_operator(message, :start_with?, "Traceback (most recent call last):")
+ assert_operator(message, :end_with?, "test:100: testerror (RuntimeError)\n")
message = e.full_message(highlight: true)
assert_match(/\e/, message)
- assert_not_match(/(\e\[1)m\1/, message)
- e2 = assert_raise(RuntimeError) {raise RuntimeError, "", bt}
- assert_not_match(/(\e\[1)m\1/, e2.full_message(highlight: true))
-
- message = e.full_message
- if Exception.to_tty?
- assert_match(/\e/, message)
- message = message.gsub(/\e\[[\d;]*m/, '')
- assert_operator(message, :start_with?, remark)
- assert_operator(message, :end_with?, bottom)
- else
- assert_not_match(/\e/, message)
- assert_operator(message, :start_with?, bottom)
- assert_operator(message, :end_with?, top)
- end
end
def test_exception_in_message
@@ -1476,39 +1182,6 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end
raise Bug14566
end;
- assert_in_out_err([], code, [], /Bug14566/, success: false, timeout: 2)
- end
-
- def test_non_exception_cause
- assert_raise_with_message(TypeError, /exception/) do
- raise "foo", cause: 1
- end;
- end
-
- def test_circular_cause_handle
- assert_raise_with_message(ArgumentError, /circular cause/) do
- begin
- raise "error 1"
- rescue => e1
- raise "error 2" rescue raise e1, cause: $!
- end
- end;
- end
-
- def test_super_in_method_missing
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- $VERBOSE = nil
- class Object
- def method_missing(name, *args, &block)
- super
- end
- end
-
- bug14670 = '[ruby-dev:50522] [Bug #14670]'
- assert_raise_with_message(NoMethodError, /`foo'/, bug14670) do
- Object.new.foo
- end
- end;
+ assert_in_out_err([], code, [], /Bug14566/, success: false, timeout: 1)
end
end
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index 20436eca69..0d070dcbc4 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -34,7 +34,6 @@ class TestFiber < Test::Unit::TestCase
end
def test_many_fibers
- skip 'This is unstable on GitHub Actions --jit-wait. TODO: debug it' if RubyVM::MJIT.enabled?
max = 10_000
assert_equal(max, max.times{
Fiber.new{}
@@ -110,15 +109,6 @@ class TestFiber < Test::Unit::TestCase
}
fib.resume
}
- assert_raise(FiberError){
- fib = Fiber.new{}
- fib.raise "raise in unborn fiber"
- }
- assert_raise(FiberError){
- fib = Fiber.new{}
- fib.resume
- fib.raise "raise in dead fiber"
- }
end
def test_return
@@ -137,38 +127,6 @@ class TestFiber < Test::Unit::TestCase
}
end
- def test_raise
- assert_raise(ZeroDivisionError){
- Fiber.new do
- 1/0
- end.resume
- }
- assert_raise(RuntimeError){
- fib = Fiber.new{ Fiber.yield }
- fib.resume
- fib.raise "raise and propagate"
- }
- assert_nothing_raised{
- fib = Fiber.new do
- begin
- Fiber.yield
- rescue
- end
- end
- fib.resume
- fib.raise "rescue in fiber"
- }
- fib = Fiber.new do
- begin
- Fiber.yield
- rescue
- Fiber.yield :ok
- end
- end
- fib.resume
- assert_equal(:ok, fib.raise)
- end
-
def test_transfer
ary = []
f2 = nil
@@ -302,33 +260,24 @@ class TestFiber < Test::Unit::TestCase
end
def test_fork_from_fiber
- skip 'fork not supported' unless Process.respond_to?(:fork)
- pid = nil
+ begin
+ pid = Process.fork{}
+ rescue NotImplementedError
+ return
+ else
+ Process.wait(pid)
+ end
bug5700 = '[ruby-core:41456]'
assert_nothing_raised(bug5700) do
Fiber.new do
pid = fork do
- xpid = nil
- Fiber.new {
- xpid = fork do
- # enough to trigger GC on old root fiber
- count = 10000
- count = 1000 if /openbsd/i =~ RUBY_PLATFORM
- count.times do
- Fiber.new {}.transfer
- Fiber.new { Fiber.yield }
- end
- exit!(true)
- end
- }.transfer
- _, status = Process.waitpid2(xpid)
- exit!(status.success?)
+ Fiber.new {}.transfer
end
end.resume
end
pid, status = Process.waitpid2(pid)
- assert_not_predicate(status, :signaled?, bug5700)
- assert_predicate(status, :success?, bug5700)
+ assert_equal(0, status.exitstatus, bug5700)
+ assert_equal(false, status.signaled?, bug5700)
end
def test_exit_in_fiber
@@ -351,10 +300,8 @@ class TestFiber < Test::Unit::TestCase
env = {}
env['RUBY_FIBER_VM_STACK_SIZE'] = vm_stack_size.to_s if vm_stack_size
env['RUBY_FIBER_MACHINE_STACK_SIZE'] = machine_stack_size.to_s if machine_stack_size
- out = Dir.mktmpdir("test_fiber") {|tmpdir|
- out, err, status = EnvUtil.invoke_ruby([env, '-e', script], '', true, true, chdir: tmpdir, timeout: 30)
- assert(!status.signaled?, FailDesc[status, nil, err])
- out
+ out, _ = Dir.mktmpdir("test_fiber") {|tmpdir|
+ EnvUtil.invoke_ruby([env, '-e', script], '', true, true, chdir: tmpdir, timeout: 30)
}
use_length ? out.length : out
end
@@ -362,7 +309,7 @@ class TestFiber < Test::Unit::TestCase
def test_stack_size
h_default = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', nil, nil, false))
h_0 = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 0, 0, false))
- h_large = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 1024 * 1024 * 5, 1024 * 1024 * 10, false))
+ h_large = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 1024 * 1024 * 10, 1024 * 1024 * 10, false))
assert_operator(h_default[:fiber_vm_stack_size], :>, h_0[:fiber_vm_stack_size])
assert_operator(h_default[:fiber_vm_stack_size], :<, h_large[:fiber_vm_stack_size])
@@ -375,7 +322,7 @@ class TestFiber < Test::Unit::TestCase
assert_operator(size_default, :>, 0)
size_0 = invoke_rec script, 0, nil
assert_operator(size_default, :>, size_0)
- size_large = invoke_rec script, 1024 * 1024 * 5, nil
+ size_large = invoke_rec script, 1024 * 1024 * 10, nil
assert_operator(size_default, :<, size_large)
return if /mswin|mingw/ =~ RUBY_PLATFORM
@@ -436,15 +383,6 @@ class TestFiber < Test::Unit::TestCase
assert_match(/resumed/, Fiber.current.to_s)
end
- def test_create_fiber_in_new_thread
- ret = Thread.new{
- Thread.new{
- Fiber.new{Fiber.yield :ok}.resume
- }.value
- }.value
- assert_equal :ok, ret, '[Bug #14642]'
- end
-
def test_machine_stack_gc
assert_normal_exit <<-RUBY, '[Bug #14561]', timeout: 10
enum = Enumerator.new { |y| y << 1 }
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index d570b6f6fb..10bfbd9ae0 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -147,8 +147,8 @@ class TestFile < Test::Unit::TestCase
end
def test_read_all_extended_file
- [{}, {:textmode=>true}, {:binmode=>true}].each do |mode|
- Tempfile.create("test-extended-file", **mode) {|f|
+ [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
+ Tempfile.create("test-extended-file", mode) {|f|
assert_nil(f.getc)
f.print "a"
f.rewind
@@ -158,8 +158,8 @@ class TestFile < Test::Unit::TestCase
end
def test_gets_extended_file
- [{}, {:textmode=>true}, {:binmode=>true}].each do |mode|
- Tempfile.create("test-extended-file", **mode) {|f|
+ [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
+ Tempfile.create("test-extended-file", mode) {|f|
assert_nil(f.getc)
f.print "a"
f.rewind
@@ -169,8 +169,8 @@ class TestFile < Test::Unit::TestCase
end
def test_gets_para_extended_file
- [{}, {:textmode=>true}, {:binmode=>true}].each do |mode|
- Tempfile.create("test-extended-file", **mode) {|f|
+ [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
+ Tempfile.create("test-extended-file", mode) {|f|
assert_nil(f.getc)
f.print "\na"
f.rewind
@@ -180,8 +180,8 @@ class TestFile < Test::Unit::TestCase
end
def test_each_char_extended_file
- [{}, {:textmode=>true}, {:binmode=>true}].each do |mode|
- Tempfile.create("test-extended-file", **mode) {|f|
+ [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
+ Tempfile.create("test-extended-file", mode) {|f|
assert_nil(f.getc)
f.print "a"
f.rewind
@@ -193,8 +193,8 @@ class TestFile < Test::Unit::TestCase
end
def test_each_byte_extended_file
- [{}, {:textmode=>true}, {:binmode=>true}].each do |mode|
- Tempfile.create("test-extended-file", **mode) {|f|
+ [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
+ Tempfile.create("test-extended-file", mode) {|f|
assert_nil(f.getc)
f.print "a"
f.rewind
@@ -206,8 +206,8 @@ class TestFile < Test::Unit::TestCase
end
def test_getc_extended_file
- [{}, {:textmode=>true}, {:binmode=>true}].each do |mode|
- Tempfile.create("test-extended-file", **mode) {|f|
+ [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
+ Tempfile.create("test-extended-file", mode) {|f|
assert_nil(f.getc)
f.print "a"
f.rewind
@@ -217,8 +217,8 @@ class TestFile < Test::Unit::TestCase
end
def test_getbyte_extended_file
- [{}, {:textmode=>true}, {:binmode=>true}].each do |mode|
- Tempfile.create("test-extended-file", **mode) {|f|
+ [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
+ Tempfile.create("test-extended-file", mode) {|f|
assert_nil(f.getc)
f.print "a"
f.rewind
@@ -233,9 +233,11 @@ class TestFile < Test::Unit::TestCase
end
def test_chown
- Tempfile.create("test-chown") {|f|
- assert_nothing_raised {f.chown(-1, -1)}
- assert_nothing_raised("[ruby-dev:27140]") {f.chown(nil, nil)}
+ assert_nothing_raised {
+ File.open(__FILE__) {|f| f.chown(-1, -1) }
+ }
+ assert_nothing_raised("[ruby-dev:27140]") {
+ File.open(__FILE__) {|f| f.chown nil, nil }
}
end
@@ -250,10 +252,6 @@ class TestFile < Test::Unit::TestCase
tst = realdir + (File::SEPARATOR*3 + ".")
assert_equal(realdir, File.realpath(tst))
assert_equal(realdir, File.realpath(".", tst))
- assert_equal(realdir, Dir.chdir(realdir) {File.realpath(".")})
- realpath = File.join(realdir, "test")
- File.write(realpath, "")
- assert_equal(realpath, Dir.chdir(realdir) {File.realpath("test")})
if File::ALT_SEPARATOR
bug2961 = '[ruby-core:28653]'
assert_equal(realdir, File.realpath(realdir.tr(File::SEPARATOR, File::ALT_SEPARATOR)), bug2961)
@@ -285,6 +283,26 @@ class TestFile < Test::Unit::TestCase
}
end
+ def test_realpath_taintedness
+ Dir.mktmpdir('rubytest-realpath') {|tmpdir|
+ dir = File.realpath(tmpdir).untaint
+ File.write(File.join(dir, base = "test.file"), '')
+ base.taint
+ dir.taint
+ assert_predicate(File.realpath(base, dir), :tainted?)
+ base.untaint
+ dir.taint
+ assert_predicate(File.realpath(base, dir), :tainted?)
+ base.taint
+ dir.untaint
+ assert_predicate(File.realpath(base, dir), :tainted?)
+ base.untaint
+ dir.untaint
+ assert_predicate(File.realpath(base, dir), :tainted?)
+ assert_predicate(Dir.chdir(dir) {File.realpath(base)}, :tainted?)
+ }
+ end
+
def test_realpath_special_symlink
IO.pipe do |r, w|
if File.pipe?(path = "/dev/fd/#{r.fileno}")
@@ -300,8 +318,6 @@ class TestFile < Test::Unit::TestCase
assert_equal(realdir, File.realdirpath(tst))
assert_equal(realdir, File.realdirpath(".", tst))
assert_equal(File.join(realdir, "foo"), File.realdirpath("foo", tst))
- assert_equal(realdir, Dir.chdir(realdir) {File.realdirpath(".")})
- assert_equal(File.join(realdir, "foo"), Dir.chdir(realdir) {File.realdirpath("foo")})
}
begin
result = File.realdirpath("bar", "//:/foo")
@@ -449,7 +465,17 @@ class TestFile < Test::Unit::TestCase
end
end
- if /mswin|mingw/ =~ RUBY_PLATFORM
+ def test_untainted_path
+ bug5374 = '[ruby-core:39745]'
+ cwd = ("./"*40+".".taint).dup.untaint
+ in_safe = proc {|safe| $SAFE = safe; File.stat(cwd)}
+ assert_not_send([cwd, :tainted?])
+ (0..1).each do |level|
+ assert_nothing_raised(SecurityError, bug5374) {in_safe[level]}
+ end
+ end
+
+ if /(bcc|ms|cyg)win|mingw|emx/ =~ RUBY_PLATFORM
def test_long_unc
feature3399 = '[ruby-core:30623]'
path = File.expand_path(__FILE__)
@@ -476,8 +502,6 @@ class TestFile < Test::Unit::TestCase
io = File.open(tmpdir, File::RDWR | File::TMPFILE)
rescue Errno::EINVAL
skip 'O_TMPFILE not supported (EINVAL)'
- rescue Errno::EISDIR
- skip 'O_TMPFILE not supported (EISDIR)'
rescue Errno::EOPNOTSUPP
skip 'O_TMPFILE not supported (EOPNOTSUPP)'
end
@@ -491,25 +515,4 @@ class TestFile < Test::Unit::TestCase
end
end if File::Constants.const_defined?(:TMPFILE)
- def test_absolute_path?
- assert_file.absolute_path?(File.absolute_path(__FILE__))
- assert_file.absolute_path?("//foo/bar\\baz")
- assert_file.not_absolute_path?(File.basename(__FILE__))
- assert_file.not_absolute_path?("C:foo\\bar")
- assert_file.not_absolute_path?("~")
- assert_file.not_absolute_path?("~user")
-
- if /cygwin|mswin|mingw/ =~ RUBY_PLATFORM
- assert_file.absolute_path?("C:\\foo\\bar")
- assert_file.absolute_path?("C:/foo/bar")
- else
- assert_file.not_absolute_path?("C:\\foo\\bar")
- assert_file.not_absolute_path?("C:/foo/bar")
- end
- if /mswin|mingw/ =~ RUBY_PLATFORM
- assert_file.not_absolute_path?("/foo/bar\\baz")
- else
- assert_file.absolute_path?("/foo/bar\\baz")
- end
- end
end
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 975bcb6bc2..817c3580d1 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -18,7 +18,7 @@ class TestFileExhaustive < Test::Unit::TestCase
end
def setup
- @dir = Dir.mktmpdir("ruby-test")
+ @dir = Dir.mktmpdir("rubytest-file")
File.chown(-1, Process.gid, @dir)
end
@@ -70,7 +70,7 @@ class TestFileExhaustive < Test::Unit::TestCase
def notownedfile
return @notownedfile if defined? @notownedfile
- if Process.euid != File.stat("/").uid
+ if Process.euid != 0
@notownedfile = '/'
else
@notownedfile = nil
@@ -495,39 +495,22 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_file.grpowned?(utf8_file)
end if POSIX
- def io_open(file_name)
- # avoid File.open since we do not want #to_path
- io = IO.for_fd(IO.sysopen(file_name))
- yield io
- ensure
- io&.close
- end
-
def test_suid
assert_file.not_setuid?(regular_file)
assert_file.not_setuid?(utf8_file)
- if suidfile
- assert_file.setuid?(suidfile)
- io_open(suidfile) { |io| assert_file.setuid?(io) }
- end
+ assert_file.setuid?(suidfile) if suidfile
end
def test_sgid
assert_file.not_setgid?(regular_file)
assert_file.not_setgid?(utf8_file)
- if sgidfile
- assert_file.setgid?(sgidfile)
- io_open(sgidfile) { |io| assert_file.setgid?(io) }
- end
+ assert_file.setgid?(sgidfile) if sgidfile
end
def test_sticky
assert_file.not_sticky?(regular_file)
assert_file.not_sticky?(utf8_file)
- if stickyfile
- assert_file.sticky?(stickyfile)
- io_open(stickyfile) { |io| assert_file.sticky?(io) }
- end
+ assert_file.sticky?(stickyfile) if stickyfile
end
def test_path_identical_p
@@ -623,23 +606,6 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_raise(Errno::ENOENT) { File.ctime(nofile) }
end
- def test_birthtime
- skip if RUBY_PLATFORM =~ /android/
- [regular_file, utf8_file].each do |file|
- t1 = File.birthtime(file)
- t2 = File.open(file) {|f| f.birthtime}
- assert_kind_of(Time, t1)
- assert_kind_of(Time, t2)
- assert_equal(t1, t2)
- rescue Errno::ENOSYS, NotImplementedError
- # ignore unsupporting filesystems
- rescue Errno::EPERM
- # Docker prohibits statx syscall by the default.
- skip("statx(2) is prohibited by seccomp")
- end
- assert_raise(Errno::ENOENT) { File.birthtime(nofile) }
- end if File.respond_to?(:birthtime)
-
def test_chmod
[regular_file, utf8_file].each do |file|
assert_equal(1, File.chmod(0444, file))
@@ -684,6 +650,7 @@ class TestFileExhaustive < Test::Unit::TestCase
def test_utime_symlinkfile
return unless symlinkfile
t = Time.local(2000)
+ stat = File.lstat(symlinkfile)
assert_equal(1, File.utime(t, t, symlinkfile))
assert_equal(t, File.stat(regular_file).atime)
assert_equal(t, File.stat(regular_file).mtime)
@@ -797,10 +764,7 @@ class TestFileExhaustive < Test::Unit::TestCase
def test_expand_path
assert_equal(regular_file, File.expand_path(File.basename(regular_file), File.dirname(regular_file)))
assert_equal(utf8_file, File.expand_path(File.basename(utf8_file), File.dirname(utf8_file)))
- end
-
- if NTFS
- def test_expand_path_ntfs
+ if NTFS
[regular_file, utf8_file].each do |file|
assert_equal(file, File.expand_path(file + " "))
assert_equal(file, File.expand_path(file + "."))
@@ -811,11 +775,8 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_match(/\Ae:\//i, File.expand_path('e:foo', 'd:/bar'))
assert_match(%r'\Ac:/bar/foo\z'i, File.expand_path('c:foo', 'c:/bar'))
end
- end
-
- case RUBY_PLATFORM
- when /darwin/
- def test_expand_path_hfs
+ case RUBY_PLATFORM
+ when /darwin/
["\u{feff}", *"\u{2000}"..."\u{2100}"].each do |c|
file = regular_file + c
full_path = File.expand_path(file)
@@ -831,16 +792,11 @@ class TestFileExhaustive < Test::Unit::TestCase
end
end
end
- end
-
- if DRIVE
- def test_expand_path_absolute
+ if DRIVE
assert_match(%r"\Az:/foo\z"i, File.expand_path('/foo', "z:/bar"))
assert_match(%r"\A//host/share/foo\z"i, File.expand_path('/foo', "//host/share/bar"))
assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo'))
- end
- else
- def test_expand_path_absolute
+ else
assert_equal("/foo", File.expand_path('/foo'))
end
end
@@ -1059,6 +1015,32 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo'))
end
+ def test_expand_path_returns_tainted_strings_or_not
+ assert_equal(true, File.expand_path('foo').tainted?)
+ assert_equal(true, File.expand_path('foo'.taint).tainted?)
+ assert_equal(true, File.expand_path('/foo'.taint).tainted?)
+ assert_equal(true, File.expand_path('foo', 'bar').tainted?)
+ assert_equal(true, File.expand_path('foo', '/bar'.taint).tainted?)
+ assert_equal(true, File.expand_path('foo'.taint, '/bar').tainted?)
+ assert_equal(true, File.expand_path('~').tainted?) if ENV["HOME"]
+
+ if DRIVE
+ assert_equal(true, File.expand_path('/foo').tainted?)
+ assert_equal(false, File.expand_path('//foo').tainted?)
+ assert_equal(true, File.expand_path('C:/foo'.taint).tainted?)
+ assert_equal(false, File.expand_path('C:/foo').tainted?)
+ assert_equal(true, File.expand_path('foo', '/bar').tainted?)
+ assert_equal(true, File.expand_path('foo', 'C:/bar'.taint).tainted?)
+ assert_equal(true, File.expand_path('foo'.taint, 'C:/bar').tainted?)
+ assert_equal(false, File.expand_path('foo', 'C:/bar').tainted?)
+ assert_equal(false, File.expand_path('C:/foo/../bar').tainted?)
+ assert_equal(false, File.expand_path('foo', '//bar').tainted?)
+ else
+ assert_equal(false, File.expand_path('/foo').tainted?)
+ assert_equal(false, File.expand_path('foo', '/bar').tainted?)
+ end
+ end
+
def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_home_as_base
old_home = ENV["HOME"]
home = ENV["HOME"] = "#{DRIVE}/UserHome"
@@ -1184,10 +1166,7 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal("foo", File.basename("foo", ".ext"))
assert_equal("foo", File.basename("foo.ext", ".ext"))
assert_equal("foo", File.basename("foo.ext", ".*"))
- end
-
- if NTFS
- def test_basename_strip
+ if NTFS
[regular_file, utf8_file].each do |file|
basename = File.basename(file)
assert_equal(basename, File.basename(file + " "))
@@ -1201,9 +1180,7 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal(basename, File.basename(file + ".", ".*"))
assert_equal(basename, File.basename(file + "::$DATA", ".*"))
end
- end
- else
- def test_basename_strip
+ else
[regular_file, utf8_file].each do |file|
basename = File.basename(file)
assert_equal(basename + " ", File.basename(file + " "))
@@ -1218,18 +1195,13 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal(basename, File.basename(file + "::$DATA", ".*"))
end
end
- end
-
- if File::ALT_SEPARATOR == '\\'
- def test_basename_backslash
+ if File::ALT_SEPARATOR == '\\'
a = "foo/\225\\\\"
[%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected|
assert_equal(expected.force_encoding(cp), File.basename(a.dup.force_encoding(cp)), cp)
end
end
- end
- def test_basename_encoding
assert_incompatible_encoding {|d| File.basename(d)}
assert_incompatible_encoding {|d| File.basename(d, ".*")}
assert_raise(Encoding::CompatibilityError) {File.basename("foo.ext", ".*".encode("utf-16le"))}
@@ -1245,14 +1217,8 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal(@dir, File.dirname(regular_file))
assert_equal(@dir, File.dirname(utf8_file))
assert_equal(".", File.dirname(""))
- end
-
- def test_dirname_encoding
assert_incompatible_encoding {|d| File.dirname(d)}
- end
-
- if File::ALT_SEPARATOR == '\\'
- def test_dirname_backslash
+ if File::ALT_SEPARATOR == '\\'
a = "\225\\\\foo"
[%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected|
assert_equal(expected.force_encoding(cp), File.dirname(a.dup.force_encoding(cp)), cp)
@@ -1264,23 +1230,21 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal(".test", File.extname(regular_file))
assert_equal(".test", File.extname(utf8_file))
prefixes = ["", "/", ".", "/.", "bar/.", "/bar/."]
- infixes = ["", " "]
+ infixes = ["", " ", "."]
infixes2 = infixes + [".ext "]
appendixes = [""]
if NTFS
appendixes << " " << "." << "::$DATA" << "::$DATA.bar"
- else
- appendixes << [".", "."]
end
prefixes.each do |prefix|
- appendixes.each do |appendix, ext = ""|
+ appendixes.each do |appendix|
infixes.each do |infix|
path = "#{prefix}foo#{infix}#{appendix}"
- assert_equal(ext, File.extname(path), "File.extname(#{path.inspect})")
+ assert_equal("", File.extname(path), "File.extname(#{path.inspect})")
end
infixes2.each do |infix|
path = "#{prefix}foo#{infix}.ext#{appendix}"
- assert_equal(ext.empty? ? ".ext" : appendix, File.extname(path), "File.extname(#{path.inspect})")
+ assert_equal(".ext", File.extname(path), "File.extname(#{path.inspect})")
end
end
end
@@ -1513,7 +1477,11 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_integer_or_nil(fs1.rdev_minor)
assert_integer(fs1.ino)
assert_integer(fs1.mode)
- assert_equal(hardlinkfile ? 2 : 1, fs1.nlink)
+ unless /emx|mswin|mingw/ =~ RUBY_PLATFORM
+ # on Windows, nlink is always 1. but this behavior will be changed
+ # in the future.
+ assert_equal(hardlinkfile ? 2 : 1, fs1.nlink)
+ end
assert_integer(fs1.uid)
assert_integer(fs1.gid)
assert_equal(3, fs1.size)
diff --git a/test/ruby/test_flip.rb b/test/ruby/test_flip.rb
index 9c58f5f497..b8b05aed6d 100644
--- a/test/ruby/test_flip.rb
+++ b/test/ruby/test_flip.rb
@@ -19,7 +19,7 @@ class TestFlip < Test::Unit::TestCase
assert_nothing_raised(NotImplementedError, bug6899) do
2000.times {eval %[(foo..bar) ? 1 : 2]}
end
- [foo, bar]
+ foo = bar
end
def test_shared_eval
@@ -28,7 +28,6 @@ class TestFlip < Test::Unit::TestCase
vs.select {|n| if n==2..n==16 then 1 end}
v = eval("vs.select {|n| if n==3..n==6 then 1 end}")
assert_equal([*3..6], v, bug7671)
- vs
end
def test_shared_thread
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index 7cbf3b5a8f..7fabfd351d 100644
--- a/test/ruby/test_float.rb
+++ b/test/ruby/test_float.rb
@@ -788,15 +788,9 @@ class TestFloat < Test::Unit::TestCase
assert_raise(ArgumentError) { Float('0xf.p0') }
assert_raise(ArgumentError) { Float('0xf.f') }
assert_raise(ArgumentError) { Float('0xf.fp') }
- begin
- verbose_bak, $VERBOSE = $VERBOSE, nil
- assert_equal(Float::INFINITY, Float('0xf.fp1000000000000000'))
- ensure
- $VERBOSE = verbose_bak
- end
+ assert_equal(Float::INFINITY, Float('0xf.fp1000000000000000'))
assert_equal(1, suppress_warning {Float("1e10_00")}.infinite?)
assert_raise(TypeError) { Float(nil) }
- assert_raise(TypeError) { Float(:test) }
o = Object.new
def o.to_f; inf = Float::INFINITY; inf/inf; end
assert_predicate(Float(o), :nan?)
@@ -807,49 +801,6 @@ class TestFloat < Test::Unit::TestCase
assert_raise(ArgumentError, bug4310) {under_gc_stress {Float('a'*10000)}}
end
- def test_Float_with_invalid_exception
- assert_raise(ArgumentError) {
- Float("0", exception: 1)
- }
- end
-
- def test_Float_with_exception_keyword
- assert_raise(ArgumentError) {
- Float(".", exception: true)
- }
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, Float(".", exception: false))
- }
- assert_raise(RangeError) {
- Float(1i, exception: true)
- }
- assert_nothing_raised(RangeError) {
- assert_equal(nil, Float(1i, exception: false))
- }
- assert_raise(TypeError) {
- Float(nil, exception: true)
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Float(nil, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Float(:test, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Float(Object.new, exception: false))
- }
- assert_nothing_raised(TypeError) {
- o = Object.new
- def o.to_f; 3.14; end
- assert_equal(3.14, Float(o, exception: false))
- }
- assert_nothing_raised(RuntimeError) {
- o = Object.new
- def o.to_f; raise; end
- assert_equal(nil, Float(o, exception: false))
- }
- end
-
def test_num2dbl
assert_raise(ArgumentError, "comparison of String with 0 failed") do
1.0.step(2.0, "0.5") {}
diff --git a/test/ruby/test_fnmatch.rb b/test/ruby/test_fnmatch.rb
index 16f1076e48..30250b5a19 100644
--- a/test/ruby/test_fnmatch.rb
+++ b/test/ruby/test_fnmatch.rb
@@ -10,7 +10,6 @@ class TestFnmatch < Test::Unit::TestCase
assert_equal(t.include?(i.chr), !File.fnmatch("[!#{s}]", i.chr, File::FNM_DOTMATCH))
end
end
-
def test_fnmatch
assert_file.for("[ruby-dev:22819]").fnmatch('\[1\]' , '[1]')
assert_file.for("[ruby-dev:22815]").fnmatch('*?', 'a')
@@ -18,16 +17,10 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.fnmatch('\[1\]' , '[1]', File::FNM_PATHNAME)
assert_file.fnmatch('*?', 'a', File::FNM_PATHNAME)
assert_file.fnmatch('*/', 'a/', File::FNM_PATHNAME)
- end
-
- def test_text
# text
assert_file.fnmatch('cat', 'cat')
assert_file.not_fnmatch('cat', 'category')
assert_file.not_fnmatch('cat', 'wildcat')
- end
-
- def test_any_one
# '?' matches any one character
assert_file.fnmatch('?at', 'cat')
assert_file.fnmatch('c?t', 'cat')
@@ -36,9 +29,6 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.not_fnmatch('c??t', 'cat')
assert_file.not_fnmatch('??at', 'cat')
assert_file.not_fnmatch('ca??', 'cat')
- end
-
- def test_any_chars
# '*' matches any number (including 0) of any characters
assert_file.fnmatch('c*', 'cats')
assert_file.fnmatch('c*ts', 'cats')
@@ -50,15 +40,9 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.not_fnmatch('a*abc', 'abc')
assert_file.fnmatch('a*bc', 'abc')
assert_file.not_fnmatch('a*bc', 'abcd')
- end
-
- def test_char_class
# [seq] : matches any character listed between bracket
# [!seq] or [^seq] : matches any character except those listed between bracket
bracket_test("bd-gikl-mosv-x", "bdefgiklmosvwx")
- end
-
- def test_escape
# escaping character
assert_file.fnmatch('\?', '?')
assert_file.not_fnmatch('\?', '\?')
@@ -75,9 +59,6 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.fnmatch('[a\-c]', 'c')
assert_file.not_fnmatch('[a\-c]', 'b')
assert_file.not_fnmatch('[a\-c]', '\\')
- end
-
- def test_fnm_escape
# escaping character loses its meaning if FNM_NOESCAPE is set
assert_file.not_fnmatch('\?', '?', File::FNM_NOESCAPE)
assert_file.fnmatch('\?', '\?', File::FNM_NOESCAPE)
@@ -94,9 +75,6 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.fnmatch('[a\-c]', 'c', File::FNM_NOESCAPE)
assert_file.fnmatch('[a\-c]', 'b', File::FNM_NOESCAPE) # '\\' < 'b' < 'c'
assert_file.fnmatch('[a\-c]', '\\', File::FNM_NOESCAPE)
- end
-
- def test_fnm_casefold
# case is ignored if FNM_CASEFOLD is set
assert_file.not_fnmatch('cat', 'CAT')
assert_file.fnmatch('cat', 'CAT', File::FNM_CASEFOLD)
@@ -104,17 +82,11 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.fnmatch('[a-z]', 'D', File::FNM_CASEFOLD)
assert_file.not_fnmatch('[abc]', 'B')
assert_file.fnmatch('[abc]', 'B', File::FNM_CASEFOLD)
- end
-
- def test_fnm_pathname
# wildcard doesn't match '/' if FNM_PATHNAME is set
assert_file.fnmatch('foo?boo', 'foo/boo')
assert_file.fnmatch('foo*', 'foo/boo')
assert_file.not_fnmatch('foo?boo', 'foo/boo', File::FNM_PATHNAME)
assert_file.not_fnmatch('foo*', 'foo/boo', File::FNM_PATHNAME)
- end
-
- def test_fnm_dotmatch
# wildcard matches leading period if FNM_DOTMATCH is set
assert_file.not_fnmatch('*', '.profile')
assert_file.fnmatch('*', '.profile', File::FNM_DOTMATCH)
@@ -123,9 +95,6 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.fnmatch('*/*', 'dave/.profile')
assert_file.not_fnmatch('*/*', 'dave/.profile', File::FNM_PATHNAME)
assert_file.fnmatch('*/*', 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH)
- end
-
- def test_recursive
# recursive matching
assert_file.fnmatch('**/foo', 'a/b/c/foo', File::FNM_PATHNAME)
assert_file.fnmatch('**/foo', '/foo', File::FNM_PATHNAME)
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index ef99f69f50..b3528ddacd 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -17,7 +17,6 @@ class TestGc < Test::Unit::TestCase
1.upto(10000) {
tmp = [0,1,2,3,4,5,6,7,8,9]
}
- tmp
end
l=nil
100000.times {
@@ -54,7 +53,6 @@ class TestGc < Test::Unit::TestCase
def test_start_full_mark
return unless use_rgengc?
- skip 'stress' if GC.stress
GC.start(full_mark: false)
assert_nil GC.latest_gc_info(:major_by)
@@ -64,8 +62,6 @@ class TestGc < Test::Unit::TestCase
end
def test_start_immediate_sweep
- skip 'stress' if GC.stress
-
GC.start(immediate_sweep: false)
assert_equal false, GC.latest_gc_info(:immediate_sweep)
@@ -109,16 +105,12 @@ class TestGc < Test::Unit::TestCase
end
def test_stat_single
- skip 'stress' if GC.stress
-
stat = GC.stat
assert_equal stat[:count], GC.stat(:count)
assert_raise(ArgumentError){ GC.stat(:invalid) }
end
def test_stat_constraints
- skip 'stress' if GC.stress
-
stat = GC.stat
assert_equal stat[:total_allocated_pages], stat[:heap_allocated_pages] + stat[:total_freed_pages]
assert_operator stat[:heap_sorted_length], :>=, stat[:heap_eden_pages] + stat[:heap_allocatable_pages], "stat is: " + stat.inspect
@@ -132,8 +124,6 @@ class TestGc < Test::Unit::TestCase
end
def test_latest_gc_info
- skip 'stress' if GC.stress
-
assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'eom'
GC.start
count = GC.stat(:heap_free_slots) + GC.stat(:heap_allocatable_pages) * GC::INTERNAL_CONSTANTS[:HEAP_PAGE_OBJ_LIMIT]
@@ -263,7 +253,6 @@ class TestGc < Test::Unit::TestCase
end
def test_profiler_clear
- skip "for now"
assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'eom', timeout: 30
GC::Profiler.enable
@@ -322,7 +311,7 @@ class TestGc < Test::Unit::TestCase
def test_sweep_in_finalizer
bug9205 = '[ruby-core:58833] [Bug #9205]'
2.times do
- assert_ruby_status([], <<-'end;', bug9205, timeout: 120)
+ assert_ruby_status([], <<-'end;', bug9205, timeout: 60)
raise_proc = proc do |id|
GC.start
end
@@ -372,14 +361,6 @@ class TestGc < Test::Unit::TestCase
assert_empty(out)
end
- def test_finalizer_passed_object_id
- assert_in_out_err(%w[--disable-gems], <<-EOS, ["true"], [])
- o = Object.new
- obj_id = o.object_id
- ObjectSpace.define_finalizer(o, ->(id){ p id == obj_id })
- EOS
- end
-
def test_verify_internal_consistency
assert_nil(GC.verify_internal_consistency)
end
@@ -403,7 +384,8 @@ class TestGc < Test::Unit::TestCase
end
def test_gc_stress_at_startup
- assert_in_out_err([{"RUBY_DEBUG"=>"gc_stress"}], '', [], [], '[Bug #15784]', success: true, timeout: 60)
+ skip # it'll be fixed later
+ assert_in_out_err([{"RUBY_DEBUG"=>"gc_stress"}], '', [], [], '[Bug #15784]', success: true)
end
def test_gc_disabled_start
@@ -469,12 +451,4 @@ class TestGc < Test::Unit::TestCase
skip "finalizers did not get run" if @result.empty?
assert_equal([:c1, :c2], @result)
end
-
- def test_object_ids_never_repeat
- GC.start
- a = 1000.times.map { Object.new.object_id }
- GC.start
- b = 1000.times.map { Object.new.object_id }
- assert_empty(a & b)
- end
end
diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb
deleted file mode 100644
index 75d9b01f2c..0000000000
--- a/test/ruby/test_gc_compact.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-require 'fiddle'
-
-class TestGCCompact < Test::Unit::TestCase
- def memory_location(obj)
- (Fiddle.dlwrap(obj) >> 1)
- end
-
- def big_list(level = 10)
- if level > 0
- big_list(level - 1)
- else
- 1000.times.map {
- # try to make some empty slots by allocating an object and discarding
- Object.new
- Object.new
- } # likely next to each other
- end
- end
-
- # Find an object that's allocated in a slot that had a previous
- # tenant, and that tenant moved and is still alive
- def find_object_in_recycled_slot(addresses)
- new_object = nil
-
- 100_000.times do
- new_object = Object.new
- if addresses.index memory_location(new_object)
- break
- end
- end
-
- new_object
- end
-
- def test_complex_hash_keys
- list_of_objects = big_list
- hash = list_of_objects.hash
- GC.verify_compaction_references(toward: :empty)
- assert_equal hash, list_of_objects.hash
- GC.verify_compaction_references(double_heap: false)
- assert_equal hash, list_of_objects.hash
- end
-
- def walk_ast ast
- children = ast.children.grep(RubyVM::AbstractSyntaxTree::Node)
- children.each do |child|
- assert child.type
- walk_ast child
- end
- end
-
- def test_ast_compacts
- ast = RubyVM::AbstractSyntaxTree.parse_file __FILE__
- assert GC.compact
- walk_ast ast
- end
-
- def test_compact_count
- count = GC.stat(:compact_count)
- GC.compact
- assert_equal count + 1, GC.stat(:compact_count)
- end
-end
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index d4af130a07..bdcf022668 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -149,9 +149,10 @@ class TestHash < Test::Unit::TestCase
assert_equal(nil, h['b'])
assert_equal(300, h['c'])
- assert_raise(ArgumentError) do
- @cls[[["a", 100], "b", ["c", 300]]]
- end
+ h = @cls[[["a", 100], "b", ["c", 300]]]
+ assert_equal(100, h['a'])
+ assert_equal(nil, h['b'])
+ assert_equal(300, h['c'])
end
def test_s_AREF_duplicated_key
@@ -279,24 +280,6 @@ class TestHash < Test::Unit::TestCase
assert_same a.keys[0], b.keys[0]
end
- def test_ASET_fstring_non_literal_key
- underscore = "_"
- non_literal_strings = Proc.new{ ["abc#{underscore}def", "abc" * 5, "abc" + "def", "" << "ghi" << "jkl"] }
-
- a, b = {}, {}
- non_literal_strings.call.each do |string|
- assert_equal 1, a[string] = 1
- end
-
- non_literal_strings.call.each do |string|
- assert_equal 1, b[string] = 1
- end
-
- [a.keys, b.keys].transpose.each do |key_a, key_b|
- assert_same key_a, key_b
- end
- end
-
def test_hash_aset_fstring_identity
h = {}.compare_by_identity
h['abc'] = 1
@@ -315,9 +298,17 @@ class TestHash < Test::Unit::TestCase
b = {"ABC" => :t}
assert_same a.keys[0], b.keys[0]
assert_same "ABC".freeze, a.keys[0]
- var = +'ABC'
- c = { var => :t }
- assert_same "ABC".freeze, c.keys[0]
+ end
+
+ def test_tainted_string_key
+ str = 'str'.taint
+ h = {}
+ h[str] = nil
+ key = h.keys.first
+ assert_equal true, str.tainted?
+ assert_equal false, str.frozen?
+ assert_equal true, key.tainted?
+ assert_equal true, key.frozen?
end
def test_EQUAL # '=='
@@ -342,14 +333,18 @@ class TestHash < Test::Unit::TestCase
end
def test_clone
- for frozen in [ false, true ]
- a = @h.clone
- a.freeze if frozen
- b = a.clone
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_equal(a.frozen?, b.frozen?)
+ for taint in [ false, true ]
+ for frozen in [ false, true ]
+ a = @h.clone
+ a.taint if taint
+ a.freeze if frozen
+ b = a.clone
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_equal(a.frozen?, b.frozen?)
+ assert_equal(a.tainted?, b.tainted?)
+ end
end
end
@@ -436,14 +431,18 @@ class TestHash < Test::Unit::TestCase
end
def test_dup
- for frozen in [ false, true ]
- a = @h.dup
- a.freeze if frozen
- b = a.dup
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_equal(false, b.frozen?)
+ for taint in [ false, true ]
+ for frozen in [ false, true ]
+ a = @h.dup
+ a.taint if taint
+ a.freeze if frozen
+ b = a.dup
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_equal(false, b.frozen?)
+ assert_equal(a.tainted?, b.tainted?)
+ end
end
end
@@ -651,21 +650,12 @@ class TestHash < Test::Unit::TestCase
assert_not_send([@h, :member?, 'gumby'])
end
- def hash_hint hv
- hv & 0xff
- end
-
def test_rehash
a = [ "a", "b" ]
c = [ "c", "d" ]
h = @cls[ a => 100, c => 300 ]
assert_equal(100, h[a])
-
- hv = a.hash
- begin
- a[0] << "z"
- end while hash_hint(a.hash) == hash_hint(hv)
-
+ a[0] = "z"
assert_nil(h[a])
h.rehash
assert_equal(100, h[a])
@@ -693,8 +683,10 @@ class TestHash < Test::Unit::TestCase
h.instance_variable_set(:@foo, :foo)
h.default = 42
+ h.taint
h = EnvUtil.suppress_warning {h.reject {false}}
assert_instance_of(Hash, h)
+ assert_not_predicate(h, :tainted?)
assert_nil(h.default)
assert_not_send([h, :instance_variable_defined?, :@foo])
end
@@ -742,14 +734,6 @@ class TestHash < Test::Unit::TestCase
assert_predicate(h, :compare_by_identity?)
end
- def test_replace_bug15358
- h1 = {}
- h2 = {a:1,b:2,c:3,d:4,e:5}
- h2.replace(h1)
- GC.start
- assert(true)
- end
-
def test_shift
h = @h.dup
@@ -819,6 +803,11 @@ class TestHash < Test::Unit::TestCase
assert_equal([3,4], a.delete([3,4]))
assert_equal([5,6], a.delete([5,6]))
assert_equal(0, a.length)
+
+ h = @cls[ 1=>2, 3=>4, 5=>6 ]
+ h.taint
+ a = h.to_a
+ assert_equal(true, a.tainted?)
end
def test_to_hash
@@ -855,16 +844,6 @@ class TestHash < Test::Unit::TestCase
assert_equal("nope42", h[42])
end
- def test_to_h_block
- h = @h.to_h {|k, v| [k.to_s, v.to_s]}
- assert_equal({
- "1"=>"one", "2"=>"two", "3"=>"three", to_s=>"self",
- "true"=>"true", ""=>"nil", "nil"=>""
- },
- h)
- assert_instance_of(Hash, h)
- end
-
def test_nil_to_h
h = nil.to_h
assert_equal({}, h)
@@ -926,8 +905,8 @@ class TestHash < Test::Unit::TestCase
def test_create
assert_equal({1=>2, 3=>4}, @cls[[[1,2],[3,4]]])
- assert_raise(ArgumentError) { @cls[0, 1, 2] }
- assert_raise(ArgumentError) { @cls[[[0, 1], 2]] }
+ assert_raise(ArgumentError) { Hash[0, 1, 2] }
+ assert_warning(/wrong element type Integer at 1 /) {@cls[[[1, 2], 3]]}
bug5406 = '[ruby-core:39945]'
assert_raise(ArgumentError, bug5406) { @cls[[[1, 2], [3, 4, 5]]] }
assert_equal({1=>2, 3=>4}, @cls[1,2,3,4])
@@ -983,19 +962,6 @@ class TestHash < Test::Unit::TestCase
assert_equal("FOO", h.shift)
end
- def test_shift_for_empty_hash
- # [ruby-dev:51159]
- h = @cls[]
- 100.times{|n|
- while h.size < n
- k = Random.rand 0..1<<30
- h[k] = 1
- end
- 0 while h.shift
- assert_equal({}, h)
- }
- end
-
def test_reject_bang2
assert_equal({1=>2}, @cls[1=>2,3=>4].reject! {|k, v| k + v == 7 })
assert_nil(@cls[1=>2,3=>4].reject! {|k, v| k == 5 })
@@ -1024,8 +990,10 @@ class TestHash < Test::Unit::TestCase
h.instance_variable_set(:@foo, :foo)
h.default = 42
+ h.taint
h = h.select {true}
assert_instance_of(Hash, h)
+ assert_not_predicate(h, :tainted?)
assert_nil(h.default)
assert_not_send([h, :instance_variable_defined?, :@foo])
end
@@ -1046,42 +1014,6 @@ class TestHash < Test::Unit::TestCase
assert_equal({}, {}.slice)
end
- def test_filter
- assert_equal({3=>4,5=>6}, @cls[1=>2,3=>4,5=>6].filter {|k, v| k + v >= 7 })
-
- base = @cls[ 1 => 'one', '2' => false, true => 'true', 'cat' => 99 ]
- h1 = @cls[ '2' => false, 'cat' => 99 ]
- h2 = @cls[ 1 => 'one', true => 'true' ]
- h3 = @cls[ 1 => 'one', true => 'true', 'cat' => 99 ]
-
- h = base.dup
- assert_equal(h, h.filter { true })
- assert_equal(@cls[], h.filter { false })
-
- h = base.dup
- assert_equal(h1, h.filter {|k,v| k.instance_of?(String) })
-
- assert_equal(h2, h.filter {|k,v| v.instance_of?(String) })
-
- assert_equal(h3, h.filter {|k,v| v })
- assert_equal(base, h)
-
- h.instance_variable_set(:@foo, :foo)
- h.default = 42
- h = h.filter {true}
- assert_instance_of(Hash, h)
- assert_nil(h.default)
- assert_not_send([h, :instance_variable_defined?, :@foo])
- end
-
- def test_filter!
- h = @cls[1=>2,3=>4,5=>6]
- assert_equal(h, h.filter! {|k, v| k + v >= 7 })
- assert_equal({3=>4,5=>6}, h)
- h = @cls[1=>2,3=>4,5=>6]
- assert_equal(nil, h.filter!{true})
- end
-
def test_clear2
assert_equal({}, @cls[1=>2,3=>4,5=>6].clear)
h = @cls[1=>2,3=>4,5=>6]
@@ -1150,35 +1082,11 @@ class TestHash < Test::Unit::TestCase
assert_equal({1=>6, 3=>4, 5=>7}, h1)
end
- def test_update3
- h1 = @cls[1=>2, 3=>4]
- h1.update()
- assert_equal({1=>2, 3=>4}, h1)
- h2 = {1=>3, 5=>7}
- h3 = {1=>1, 2=>4}
- h1.update(h2, h3)
- assert_equal({1=>1, 2=>4, 3=>4, 5=>7}, h1)
- end
-
- def test_update4
- h1 = @cls[1=>2, 3=>4]
- h1.update(){|k, v1, v2| k + v1 + v2 }
- assert_equal({1=>2, 3=>4}, h1)
- h2 = {1=>3, 5=>7}
- h3 = {1=>1, 2=>4}
- h1.update(h2, h3){|k, v1, v2| k + v1 + v2 }
- assert_equal({1=>8, 2=>4, 3=>4, 5=>7}, h1)
- end
-
def test_merge
h1 = @cls[1=>2, 3=>4]
h2 = {1=>3, 5=>7}
- h3 = {1=>1, 2=>4}
- assert_equal({1=>2, 3=>4}, h1.merge())
assert_equal({1=>3, 3=>4, 5=>7}, h1.merge(h2))
assert_equal({1=>6, 3=>4, 5=>7}, h1.merge(h2) {|k, v1, v2| k + v1 + v2 })
- assert_equal({1=>1, 2=>4, 3=>4, 5=>7}, h1.merge(h2, h3))
- assert_equal({1=>8, 2=>4, 3=>4, 5=>7}, h1.merge(h2, h3) {|k, v1, v2| k + v1 + v2 })
end
def test_assoc
@@ -1677,16 +1585,9 @@ class TestHash < Test::Unit::TestCase
def test_transform_values
x = @cls[a: 1, b: 2, c: 3]
- x.default = 42
y = x.transform_values {|v| v ** 2 }
assert_equal([1, 4, 9], y.values_at(:a, :b, :c))
assert_not_same(x, y)
- assert_nil(y.default)
-
- x.default_proc = proc {|h, k| k}
- y = x.transform_values {|v| v ** 2 }
- assert_nil(y.default_proc)
- assert_nil(y.default)
y = x.transform_values.with_index {|v, i| "#{v}.#{i}" }
assert_equal(%w(1.0 2.1 3.2), y.values_at(:a, :b, :c))
@@ -1710,44 +1611,6 @@ class TestHash < Test::Unit::TestCase
assert_equal(0, 1_000_000.times.count{a=Object.new.hash; b=Object.new.hash; 0 + a + b != 0 + b + a}, bug14218)
end
- def test_reserved_hash_val
- s = Struct.new(:hash)
- h = {}
- keys = [*0..8]
- keys.each {|i| h[s.new(i)]=true}
- msg = proc {h.inspect}
- assert_equal(keys, h.keys.map(&:hash), msg)
- end
-
- def hrec h, n, &b
- if n > 0
- h.each{hrec(h, n-1, &b)}
- else
- yield
- end
- end
-
- def test_huge_iter_level
- nrec = 200
-
- h = @cls[a: 1]
- hrec(h, nrec){}
- h[:c] = 3
- assert_equal(3, h[:c])
-
- h = @cls[a: 1]
- h.freeze # set hidden attribute for a frozen object
- hrec(h, nrec){}
- assert_equal(1, h.size)
-
- h = @cls[a: 1]
- assert_raise(RuntimeError){
- hrec(h, nrec){ h[:c] = 3 }
- }
- rescue SystemStackError
- # ignore
- end
-
class TestSubHash < TestHash
class SubHash < Hash
def reject(*)
@@ -1760,86 +1623,4 @@ class TestHash < Test::Unit::TestCase
super
end
end
-
- ruby2_keywords def get_flagged_hash(*args)
- args.last
- end
-
- def check_flagged_hash(k: :NG)
- k
- end
-
- def test_ruby2_keywords_hash?
- flagged_hash = get_flagged_hash(k: 1)
- assert_equal(true, Hash.ruby2_keywords_hash?(flagged_hash))
- assert_equal(false, Hash.ruby2_keywords_hash?({}))
- assert_raise(TypeError) { Hash.ruby2_keywords_hash?(1) }
- end
-
- def test_ruby2_keywords_hash
- hash = {k: 1}
- assert_equal(false, Hash.ruby2_keywords_hash?(hash))
- hash = Hash.ruby2_keywords_hash(hash)
- assert_equal(true, Hash.ruby2_keywords_hash?(hash))
- assert_equal(1, check_flagged_hash(*[hash]))
- assert_raise(TypeError) { Hash.ruby2_keywords_hash(1) }
- end
-
- def test_ar2st
- # insert
- obj = Object.new
- obj.instance_variable_set(:@h, h = {})
- def obj.hash
- 10.times{|i| @h[i] = i}
- 0
- end
- def obj.inspect
- 'test'
- end
- h[obj] = true
- assert_equal '{0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9, test=>true}', h.inspect
-
- # delete
- obj = Object.new
- obj.instance_variable_set(:@h, h = {})
- def obj.hash
- 10.times{|i| @h[i] = i}
- 0
- end
- def obj.inspect
- 'test'
- end
- def obj.eql? other
- other.class == Object
- end
- obj2 = Object.new
- def obj2.hash
- 0
- end
-
- h[obj2] = true
- h.delete obj
- assert_equal '{0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9}', h.inspect
-
- # lookup
- obj = Object.new
- obj.instance_variable_set(:@h, h = {})
- def obj.hash
- 10.times{|i| @h[i] = i}
- 0
- end
- def obj.inspect
- 'test'
- end
- def obj.eql? other
- other.class == Object
- end
- obj2 = Object.new
- def obj2.hash
- 0
- end
-
- h[obj2] = true
- assert_equal true, h[obj]
- end
end
diff --git a/test/ruby/test_ifunless.rb b/test/ruby/test_ifunless.rb
index f68e5154a2..d533e155bc 100644
--- a/test/ruby/test_ifunless.rb
+++ b/test/ruby/test_ifunless.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
require 'test/unit'
-class TestIfUnless < Test::Unit::TestCase
+class TestIfunless < Test::Unit::TestCase
def test_if_unless
x = 'test';
assert(if x == x then true else false end)
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index a111698771..1b485760e3 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -10,46 +10,7 @@ class TestInteger < Test::Unit::TestCase
self.class.bdsize(x)
end
- FIXNUM_MIN = RbConfig::LIMITS['FIXNUM_MIN']
- FIXNUM_MAX = RbConfig::LIMITS['FIXNUM_MAX']
-
def test_aref
-
- [
- *-16..16,
- *(FIXNUM_MIN-2)..(FIXNUM_MIN+2),
- *(FIXNUM_MAX-2)..(FIXNUM_MAX+2),
- ].each do |n|
- (-64..64).each do |idx|
- assert_equal((n >> idx) & 1, n[idx])
- end
- [*-66..-62, *-34..-30, *-5..5, *30..34, *62..66].each do |idx|
- (0..100).each do |len|
- assert_equal((n >> idx) & ((1 << len) - 1), n[idx, len], "#{ n }[#{ idx }, #{ len }]")
- end
- (0..100).each do |len|
- assert_equal((n >> idx) & ((1 << (len + 1)) - 1), n[idx..idx+len], "#{ n }[#{ idx }..#{ idx+len }]")
- assert_equal((n >> idx) & ((1 << len) - 1), n[idx...idx+len], "#{ n }[#{ idx }...#{ idx+len }]")
- end
-
- # endless
- assert_equal((n >> idx), n[idx..], "#{ n }[#{ idx }..]")
- assert_equal((n >> idx), n[idx...], "#{ n }[#{ idx }...#]")
-
- # beginless
- if idx >= 0 && n & ((1 << (idx + 1)) - 1) != 0
- assert_raise(ArgumentError, "#{ n }[..#{ idx }]") { n[..idx] }
- else
- assert_equal(0, n[..idx], "#{ n }[..#{ idx }]")
- end
- if idx >= 0 && n & ((1 << idx) - 1) != 0
- assert_raise(ArgumentError, "#{ n }[...#{ idx }]") { n[...idx] }
- else
- assert_equal(0, n[...idx], "#{ n }[...#{ idx }]")
- end
- end
- end
-
# assert_equal(1, (1 << 0x40000000)[0x40000000], "[ruby-dev:31271]")
# assert_equal(0, (-1 << 0x40000001)[0x40000000], "[ruby-dev:31271]")
big_zero = 0x40000000.coerce(0)[0]
@@ -63,32 +24,6 @@ class TestInteger < Test::Unit::TestCase
rescue
nil
end, "[ruby-dev:32084] [ruby-dev:34547]")
-
- x = EnvUtil.suppress_warning {2 ** -0x4000000000000000}
- assert_in_delta(0.0, (x / 2), Float::EPSILON)
-
- <<~EXPRS.each_line.with_index(__LINE__+1) do |expr, line|
- crash01: 111r+11**-11111161111111
- crash02: 1118111111111**-1111111111111111**1+1==11111
- crash03: -1111111**-1111*11 - -1111111** -111111111
- crash04: 1118111111111** -1111111111111111**1+11111111111**1 ===111
- crash05: 11** -111155555555555555 -55 !=5-555
- crash07: 1 + 111111111**-1111811111
- crash08: 18111111111**-1111111111111111**1 + 1111111111**-1111**1
- crash10: -7 - -1111111** -1111**11
- crash12: 1118111111111** -1111111111111111**1 + 1111 - -1111111** -1111*111111111119
- crash13: 1.0i - -1111111** -111111111
- crash14: 11111**111111111**111111 * -11111111111111111111**-111111111111
- crash15: ~1**1111 + -~1**~1**111
- crash17: 11** -1111111**1111 /11i
- crash18: 5555i**-5155 - -9111111**-1111**11
- crash19: 111111*-11111111111111111111**-1111111111111111
- crash20: 1111**111-11**-11111**11
- crash21: 11**-10111111119-1i -1r
- EXPRS
- name, expr = expr.split(':', 2)
- assert_ruby_status(%w"-W0", expr, name)
- end
end
def test_lshift
@@ -157,17 +92,6 @@ class TestInteger < Test::Unit::TestCase
assert_equal(2 ** 50, Integer(2.0 ** 50))
assert_raise(TypeError) { Integer(nil) }
- bug14552 = '[ruby-core:85813]'
- obj = Object.new
- def obj.to_int; "str"; end
- assert_raise(TypeError, bug14552) { Integer(obj) }
- def obj.to_i; 42; end
- assert_equal(42, Integer(obj), bug14552)
-
- obj = Object.new
- def obj.to_i; "str"; end
- assert_raise(TypeError) { Integer(obj) }
-
bug6192 = '[ruby-core:43566]'
assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("utf-16be"))}
assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("utf-16le"))}
@@ -192,61 +116,6 @@ class TestInteger < Test::Unit::TestCase
end;
end
- def test_Integer_with_invalid_exception
- assert_raise(ArgumentError) {
- Integer("0", exception: 1)
- }
- end
-
- def test_Integer_with_exception_keyword
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, Integer("1z", exception: false))
- }
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, Integer(Object.new, exception: false))
- }
- assert_nothing_raised(ArgumentError) {
- o = Object.new
- def o.to_i; 42.5; end
- assert_equal(nil, Integer(o, exception: false))
- }
- assert_nothing_raised(ArgumentError) {
- o = Object.new
- def o.to_i; raise; end
- assert_equal(nil, Integer(o, exception: false))
- }
- assert_nothing_raised(ArgumentError) {
- o = Object.new
- def o.to_int; raise; end
- assert_equal(nil, Integer(o, exception: false))
- }
- assert_nothing_raised(FloatDomainError) {
- assert_equal(nil, Integer(Float::INFINITY, exception: false))
- }
- assert_nothing_raised(FloatDomainError) {
- assert_equal(nil, Integer(-Float::INFINITY, exception: false))
- }
- assert_nothing_raised(FloatDomainError) {
- assert_equal(nil, Integer(Float::NAN, exception: false))
- }
-
- assert_raise(ArgumentError) {
- Integer("1z", exception: true)
- }
- assert_raise(TypeError) {
- Integer(nil, exception: true)
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Integer(nil, exception: false))
- }
-
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- class Integer;def method_missing(*);"";end;end
- assert_equal(0, Integer("0", 2))
- end;
- end
-
def test_int_p
assert_not_predicate(1.0, :integer?)
assert_predicate(1, :integer?)
@@ -640,9 +509,6 @@ class TestInteger < Test::Unit::TestCase
failures << n unless root*root <= n && (root+1)*(root+1) > n
end
assert_empty(failures, bug13440)
-
- x = 0xffff_ffff_ffff_ffff
- assert_equal(x, Integer.sqrt(x ** 2), "[ruby-core:95453]")
end
def test_fdiv
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 37f1477483..178e3c3d7e 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -49,8 +49,8 @@ class TestIO < Test::Unit::TestCase
end
flunk("timeout") unless wt.join(10) && rt.join(10)
ensure
- w&.close
- r&.close
+ w.close unless !w || w.closed?
+ r.close unless !r || r.closed?
(wt.kill; wt.join) if wt
(rt.kill; rt.join) if rt
raise we if we
@@ -62,8 +62,8 @@ class TestIO < Test::Unit::TestCase
begin
yield r, w
ensure
- r.close
- w.close
+ r.close unless r.closed?
+ w.close unless w.closed?
end
end
@@ -84,17 +84,12 @@ class TestIO < Test::Unit::TestCase
}
end
- def trapping_usr2
- @usr2_rcvd = 0
- r, w = IO.pipe
- trap(:USR2) do
- w.write([@usr2_rcvd += 1].pack('L'))
- end
- yield r
+ def trapping_usr1
+ @usr1_rcvd = 0
+ trap(:USR1) { @usr1_rcvd += 1 }
+ yield
ensure
- trap(:USR2, "DEFAULT")
- w&.close
- r&.close
+ trap(:USR1, "DEFAULT")
end
def test_pipe
@@ -113,65 +108,6 @@ class TestIO < Test::Unit::TestCase
].each{|thr| thr.join}
end
- def test_binmode_pipe
- EnvUtil.with_default_internal(Encoding::UTF_8) do
- EnvUtil.with_default_external(Encoding::UTF_8) do
- begin
- reader0, writer0 = IO.pipe
- reader0.binmode
- writer0.binmode
-
- reader1, writer1 = IO.pipe
-
- reader2, writer2 = IO.pipe(binmode: true)
- assert_predicate writer0, :binmode?
- assert_predicate writer2, :binmode?
- assert_equal writer0.binmode?, writer2.binmode?
- assert_equal writer0.external_encoding, writer2.external_encoding
- assert_equal writer0.internal_encoding, writer2.internal_encoding
- assert_predicate reader0, :binmode?
- assert_predicate reader2, :binmode?
- assert_equal reader0.binmode?, reader2.binmode?
- assert_equal reader0.external_encoding, reader2.external_encoding
- assert_equal reader0.internal_encoding, reader2.internal_encoding
-
- reader3, writer3 = IO.pipe("UTF-8:UTF-8", binmode: true)
- assert_predicate writer3, :binmode?
- assert_equal writer1.external_encoding, writer3.external_encoding
- assert_equal writer1.internal_encoding, writer3.internal_encoding
- assert_predicate reader3, :binmode?
- assert_equal reader1.external_encoding, reader3.external_encoding
- assert_equal reader1.internal_encoding, reader3.internal_encoding
-
- reader4, writer4 = IO.pipe("UTF-8:UTF-8", binmode: true)
- assert_predicate writer4, :binmode?
- assert_equal writer1.external_encoding, writer4.external_encoding
- assert_equal writer1.internal_encoding, writer4.internal_encoding
- assert_predicate reader4, :binmode?
- assert_equal reader1.external_encoding, reader4.external_encoding
- assert_equal reader1.internal_encoding, reader4.internal_encoding
-
- reader5, writer5 = IO.pipe("UTF-8", "UTF-8", binmode: true)
- assert_predicate writer5, :binmode?
- assert_equal writer1.external_encoding, writer5.external_encoding
- assert_equal writer1.internal_encoding, writer5.internal_encoding
- assert_predicate reader5, :binmode?
- assert_equal reader1.external_encoding, reader5.external_encoding
- assert_equal reader1.internal_encoding, reader5.internal_encoding
- ensure
- [
- reader0, writer0,
- reader1, writer1,
- reader2, writer2,
- reader3, writer3,
- reader4, writer4,
- reader5, writer5,
- ].compact.map(&:close)
- end
- end
- end
- end
-
def test_pipe_block
x = nil
ret = IO.pipe {|r, w|
@@ -405,12 +341,25 @@ class TestIO < Test::Unit::TestCase
}
end
+ def test_codepoints
+ make_tempfile {|t|
+ bug2959 = '[ruby-core:28650]'
+ a = ""
+ File.open(t, 'rt') {|f|
+ assert_warn(/deprecated/) {
+ f.codepoints {|c| a << c}
+ }
+ }
+ assert_equal("foo\nbar\nbaz\n", a, bug2959)
+ }
+ end
+
def test_rubydev33072
t = make_tempfile
path = t.path
t.close!
assert_raise(Errno::ENOENT, "[ruby-dev:33072]") do
- File.read(path, nil, nil, **{})
+ File.read(path, nil, nil, {})
end
end
@@ -440,18 +389,6 @@ class TestIO < Test::Unit::TestCase
}
end
- def test_copy_stream_append_to_nonempty
- with_srccontent("foobar") {|src, content|
- preface = 'preface'
- File.write('dst', preface)
- File.open('dst', 'ab') do |dst|
- ret = IO.copy_stream(src, dst)
- assert_equal(content.bytesize, ret)
- assert_equal(preface + content, File.read("dst"))
- end
- }
- end
-
def test_copy_stream_smaller
with_srccontent {|src, content|
@@ -619,14 +556,14 @@ class TestIO < Test::Unit::TestCase
if have_nonblock?
def test_copy_stream_no_busy_wait
- skip "MJIT has busy wait on GC. This sometimes fails with --jit." if RubyVM::MJIT.enabled?
- skip "multiple threads already active" if Thread.list.size > 1
-
msg = 'r58534 [ruby-core:80969] [Backport #13533]'
IO.pipe do |r,w|
r.nonblock = true
- assert_cpu_usage_low(msg, stop: ->{w.close}) do
- IO.copy_stream(r, IO::NULL)
+ assert_cpu_usage_low(msg) do
+ th = Thread.new { IO.copy_stream(r, IO::NULL) }
+ sleep 0.1
+ w.close
+ th.join
end
end
end
@@ -640,6 +577,7 @@ class TestIO < Test::Unit::TestCase
w2.nonblock = true
rescue Errno::EBADF
skip "nonblocking IO for pipe is not implemented"
+ break
end
s = w2.syswrite("a" * 100000)
t = Thread.new { sleep 0.1; r2.read }
@@ -705,7 +643,7 @@ class TestIO < Test::Unit::TestCase
assert_equal(bigcontent[30, 40], File.read("bigdst"))
assert_equal(0, f.pos)
rescue NotImplementedError
- #skip "pread(2) is not implemented."
+ #skip "pread(2) is not implemtented."
end
}
}
@@ -937,21 +875,20 @@ class TestIO < Test::Unit::TestCase
rescue Errno::EBADF
skip "nonblocking IO for pipe is not implemented"
end
- trapping_usr2 do |rd|
+ trapping_usr1 do
nr = 30
begin
pid = fork do
s1.close
IO.select([s2])
- Process.kill(:USR2, Process.ppid)
- buf = String.new(capacity: 16384)
- nil while s2.read(16384, buf)
+ Process.kill(:USR1, Process.ppid)
+ s2.read
end
s2.close
nr.times do
assert_equal megacontent.bytesize, IO.copy_stream("megasrc", s1)
end
- assert_equal(1, rd.read(4).unpack1('L'))
+ assert_equal(1, @usr1_rcvd)
ensure
s1.close
_, status = Process.waitpid2(pid) if pid
@@ -1255,11 +1192,10 @@ class TestIO < Test::Unit::TestCase
def test_copy_stream_to_duplex_io
result = IO.pipe {|a,w|
- th = Thread.start {w.puts "yes"; w.close}
+ Thread.start {w.puts "yes"; w.close}
IO.popen([EnvUtil.rubybin, '-pe$_="#$.:#$_"'], "r+") {|b|
IO.copy_stream(a, b)
b.close_write
- assert_join_threads([th])
b.read
}
}
@@ -1272,7 +1208,7 @@ class TestIO < Test::Unit::TestCase
opts = {}
if defined?(Process::RLIMIT_NPROC)
lim = Process.getrlimit(Process::RLIMIT_NPROC)[1]
- opts[:rlimit_nproc] = [lim, 2048].min
+ opts[:rlimit_nproc] = [lim, 1024].min
end
f = IO.popen([ruby] + args, 'r+', opts)
pid = f.pid
@@ -1360,13 +1296,6 @@ class TestIO < Test::Unit::TestCase
assert_empty(err)
end
- def test_write_no_args
- IO.pipe do |r, w|
- assert_equal 0, w.write, '[ruby-core:86285] [Bug #14338]'
- assert_equal :wait_readable, r.read_nonblock(1, exception: false)
- end
- end
-
def test_write_non_writable
with_pipe do |r, w|
assert_raise(IOError) do
@@ -1394,7 +1323,7 @@ class TestIO < Test::Unit::TestCase
def test_dup_many
opts = {}
opts[:rlimit_nofile] = 1024 if defined?(Process::RLIMIT_NOFILE)
- assert_separately([], <<-'End', **opts)
+ assert_separately([], <<-'End', opts)
a = []
assert_raise(Errno::EMFILE, Errno::ENFILE, Errno::ENOMEM) do
loop {a << IO.pipe}
@@ -1458,13 +1387,6 @@ class TestIO < Test::Unit::TestCase
end)
end
- def test_readpartial_zero_size
- File.open(IO::NULL) do |r|
- assert_empty(r.readpartial(0, s = "01234567"))
- assert_empty(s)
- end
- end
-
def test_readpartial_buffer_error
with_pipe do |r, w|
s = ""
@@ -1510,13 +1432,6 @@ class TestIO < Test::Unit::TestCase
end)
end
- def test_read_zero_size
- File.open(IO::NULL) do |r|
- assert_empty(r.read(0, s = "01234567"))
- assert_empty(s)
- end
- end
-
def test_read_buffer_error
with_pipe do |r, w|
s = ""
@@ -1554,13 +1469,6 @@ class TestIO < Test::Unit::TestCase
}
end
- def test_read_nonblock_zero_size
- File.open(IO::NULL) do |r|
- assert_empty(r.read_nonblock(0, s = "01234567"))
- assert_empty(s)
- end
- end
-
def test_write_nonblock_simple_no_exceptions
pipe(proc do |w|
w.write_nonblock('1', exception: false)
@@ -1588,14 +1496,7 @@ class TestIO < Test::Unit::TestCase
}
end if have_nonblock?
- def test_read_nonblock_invalid_exception
- with_pipe {|r, w|
- assert_raise(ArgumentError) {r.read_nonblock(4096, exception: 1)}
- }
- end if have_nonblock?
-
def test_read_nonblock_no_exceptions
- skip '[ruby-core:90895] MJIT worker may leave fd open in a forked child' if RubyVM::MJIT.enabled? # TODO: consider acquiring GVL from MJIT worker.
with_pipe {|r, w|
assert_equal :wait_readable, r.read_nonblock(4096, exception: false)
w.puts "HI!"
@@ -1630,12 +1531,6 @@ class TestIO < Test::Unit::TestCase
}
end if have_nonblock?
- def test_write_nonblock_invalid_exception
- with_pipe {|r, w|
- assert_raise(ArgumentError) {w.write_nonblock(4096, exception: 1)}
- }
- end if have_nonblock?
-
def test_write_nonblock_no_exceptions
with_pipe {|r, w|
loop {
@@ -1796,50 +1691,112 @@ class TestIO < Test::Unit::TestCase
f.gets; assert_equal(3, $.)
end
SRC
+
+ pipe(proc do |w|
+ w.puts "foo"
+ w.puts "bar"
+ w.puts "baz"
+ w.close
+ end, proc do |r|
+ r.gets; assert_equal(1, $.)
+ r.gets; assert_equal(2, $.)
+ r.lineno = 1000; assert_equal(2, $.)
+ r.gets; assert_equal(1001, $.)
+ r.gets; assert_equal(1001, $.)
+ end)
}
end
- def test_set_lineno_gets
+ def test_readline
pipe(proc do |w|
w.puts "foo"
w.puts "bar"
w.puts "baz"
w.close
end, proc do |r|
- r.gets; assert_equal(1, $.)
- r.gets; assert_equal(2, $.)
+ r.readline; assert_equal(1, $.)
+ r.readline; assert_equal(2, $.)
r.lineno = 1000; assert_equal(2, $.)
- r.gets; assert_equal(1001, $.)
- r.gets; assert_equal(1001, $.)
+ r.readline; assert_equal(1001, $.)
+ assert_raise(EOFError) { r.readline }
end)
end
- def test_set_lineno_readline
+ def test_each_char
pipe(proc do |w|
w.puts "foo"
w.puts "bar"
w.puts "baz"
w.close
end, proc do |r|
- r.readline; assert_equal(1, $.)
- r.readline; assert_equal(2, $.)
- r.lineno = 1000; assert_equal(2, $.)
- r.readline; assert_equal(1001, $.)
- assert_raise(EOFError) { r.readline }
+ a = []
+ r.each_char {|c| a << c }
+ assert_equal(%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"], a)
end)
end
- def test_each_char
+ def test_lines
+ verbose, $VERBOSE = $VERBOSE, nil
pipe(proc do |w|
w.puts "foo"
w.puts "bar"
w.puts "baz"
w.close
end, proc do |r|
- a = []
- r.each_char {|c| a << c }
- assert_equal(%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"], a)
+ e = nil
+ assert_warn(/deprecated/) {
+ e = r.lines
+ }
+ assert_equal("foo\n", e.next)
+ assert_equal("bar\n", e.next)
+ assert_equal("baz\n", e.next)
+ assert_raise(StopIteration) { e.next }
+ end)
+ ensure
+ $VERBOSE = verbose
+ end
+
+ def test_bytes
+ verbose, $VERBOSE = $VERBOSE, nil
+ pipe(proc do |w|
+ w.binmode
+ w.puts "foo"
+ w.puts "bar"
+ w.puts "baz"
+ w.close
+ end, proc do |r|
+ e = nil
+ assert_warn(/deprecated/) {
+ e = r.bytes
+ }
+ (%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
+ assert_equal(c.ord, e.next)
+ end
+ assert_raise(StopIteration) { e.next }
end)
+ ensure
+ $VERBOSE = verbose
+ end
+
+ def test_chars
+ verbose, $VERBOSE = $VERBOSE, nil
+ pipe(proc do |w|
+ w.puts "foo"
+ w.puts "bar"
+ w.puts "baz"
+ w.close
+ end, proc do |r|
+ e = nil
+ assert_warn(/deprecated/) {
+ e = r.chars
+ }
+ (%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
+ assert_equal(c, e.next)
+ end
+ assert_raise(StopIteration) { e.next }
+ end)
+ ensure
+ $VERBOSE = verbose
end
def test_readbyte
@@ -1904,6 +1861,7 @@ class TestIO < Test::Unit::TestCase
def test_pos
make_tempfile {|t|
+
open(t.path, IO::RDWR|IO::CREAT|IO::TRUNC, 0600) do |f|
f.write "Hello"
assert_equal(5, f.pos)
@@ -2186,10 +2144,6 @@ class TestIO < Test::Unit::TestCase
end
def test_autoclose_true_closed_by_finalizer
- # http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1465760
- # http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1469765
- skip 'this randomly fails with MJIT' if RubyVM::MJIT.enabled?
-
feature2250 = '[ruby-core:26222]'
pre = 'ft2250'
t = Tempfile.new(pre)
@@ -2205,7 +2159,7 @@ class TestIO < Test::Unit::TestCase
assert_raise(Errno::EBADF, feature2250) {t.close}
end
ensure
- t&.close!
+ t.close!
end
def test_autoclose_false_closed_by_finalizer
@@ -2235,33 +2189,6 @@ class TestIO < Test::Unit::TestCase
assert_equal(o, o2)
end
- def test_open_redirect_keyword
- o = Object.new
- def o.to_open(**kw); kw; end
- assert_equal({:a=>1}, open(o, a: 1))
-
- w = /Using the last argument as keyword parameters is deprecated.*The called method `(to_)?open'/m
- redefined = nil
- w.singleton_class.define_method(:===) do |s|
- match = super(s)
- redefined = !$1
- match
- end
-
- assert_warn(w) do
- assert_equal({:a=>1}, open(o, {a: 1}))
- end
-
- class << o
- remove_method(:to_open)
- end
- def o.to_open(kw); kw; end
- assert_equal({:a=>1}, open(o, a: 1))
- unless redefined
- assert_equal({:a=>1}, open(o, {a: 1}))
- end
- end
-
def test_open_pipe
open("|" + EnvUtil.rubybin, "r+") do |f|
f.puts "puts 'foo'"
@@ -2272,10 +2199,10 @@ class TestIO < Test::Unit::TestCase
def test_read_command
assert_equal("foo\n", IO.read("|echo foo"))
- assert_raise(Errno::ENOENT, Errno::EINVAL) do
+ assert_warn(/invoke external command/) do
File.read("|#{EnvUtil.rubybin} -e puts")
end
- assert_raise(Errno::ENOENT, Errno::EINVAL) do
+ assert_warn(/invoke external command/) do
File.binread("|#{EnvUtil.rubybin} -e puts")
end
assert_raise(Errno::ENOENT, Errno::EINVAL) do
@@ -2284,9 +2211,6 @@ class TestIO < Test::Unit::TestCase
assert_raise(Errno::ENOENT, Errno::EINVAL) do
Class.new(IO).binread("|#{EnvUtil.rubybin} -e puts")
end
- assert_raise(Errno::ESPIPE) do
- IO.read("|echo foo", 1, 1)
- end
end
def test_reopen
@@ -2330,13 +2254,13 @@ class TestIO < Test::Unit::TestCase
def test_reopen_inherit
mkcdtmpdir {
- system(EnvUtil.rubybin, '-e', <<-"End")
+ system(EnvUtil.rubybin, '-e', <<"End")
f = open("out", "w")
STDOUT.reopen(f)
STDERR.reopen(f)
system(#{EnvUtil.rubybin.dump}, '-e', 'STDOUT.print "out"')
system(#{EnvUtil.rubybin.dump}, '-e', 'STDERR.print "err"')
- End
+End
assert_equal("outerr", File.read("out"))
}
end
@@ -2397,7 +2321,7 @@ class TestIO < Test::Unit::TestCase
t
end
ensure
- t&.close(true) if block_given?
+ t.close(true) if t and block_given?
end
def test_reopen_encoding
@@ -2472,15 +2396,15 @@ class TestIO < Test::Unit::TestCase
assert_equal(["foo\n", "bar\n", "baz\n"], a)
a = []
- IO.foreach(t.path, :mode => "r") {|x| a << x }
+ IO.foreach(t.path, {:mode => "r" }) {|x| a << x }
assert_equal(["foo\n", "bar\n", "baz\n"], a)
a = []
- IO.foreach(t.path, :open_args => []) {|x| a << x }
+ IO.foreach(t.path, {:open_args => [] }) {|x| a << x }
assert_equal(["foo\n", "bar\n", "baz\n"], a)
a = []
- IO.foreach(t.path, :open_args => ["r"]) {|x| a << x }
+ IO.foreach(t.path, {:open_args => ["r"] }) {|x| a << x }
assert_equal(["foo\n", "bar\n", "baz\n"], a)
a = []
@@ -2536,7 +2460,7 @@ class TestIO < Test::Unit::TestCase
end
def test_print_separators
- EnvUtil.suppress_warning {$, = ':'}
+ $, = ':'
$\ = "\n"
pipe(proc do |w|
w.print('a')
@@ -2623,8 +2547,7 @@ class TestIO < Test::Unit::TestCase
assert_in_out_err([], "$> = $stderr\nputs 'foo'", [], %w(foo))
- assert_separately(%w[-Eutf-8], "#{<<~"begin;"}\n#{<<~"end;"}")
- begin;
+ assert_separately(%w[-Eutf-8], <<-"end;") # do
alias $\u{6a19 6e96 51fa 529b} $stdout
x = eval("class X\u{307b 3052}; self; end".encode("euc-jp"))
assert_raise_with_message(TypeError, /\\$\u{6a19 6e96 51fa 529b} must.*, X\u{307b 3052} given/) do
@@ -2637,6 +2560,7 @@ class TestIO < Test::Unit::TestCase
return unless defined?(Fcntl::F_GETFL)
make_tempfile {|t|
+
fd = IO.sysopen(t.path, "w")
assert_kind_of(Integer, fd)
%w[r r+ w+ a+].each do |mode|
@@ -2724,6 +2648,13 @@ class TestIO < Test::Unit::TestCase
}
end if /freebsd|linux/ =~ RUBY_PLATFORM and defined? File::NOFOLLOW
+ def test_tainted
+ make_tempfile {|t|
+ assert_predicate(File.read(t.path, 4), :tainted?, '[ruby-dev:38826]')
+ assert_predicate(File.open(t.path) {|f| f.read(4)}, :tainted?, '[ruby-dev:38826]')
+ }
+ end
+
def test_binmode_after_closed
make_tempfile {|t|
assert_raise(IOError) {t.binmode}
@@ -2747,7 +2678,7 @@ __END__
end;
10.times.map do
Thread.start do
- assert_in_out_err([], src, timeout: 20) {|stdout, stderr|
+ assert_in_out_err([], src) {|stdout, stderr|
assert_no_match(/hi.*hi/, stderr.join, bug3585)
}
end
@@ -2755,6 +2686,7 @@ __END__
end
def test_flush_in_finalizer1
+ require 'tempfile'
bug3910 = '[ruby-dev:42341]'
tmp = Tempfile.open("bug3910") {|t|
path = t.path
@@ -2780,6 +2712,7 @@ __END__
end
def test_flush_in_finalizer2
+ require 'tempfile'
bug3910 = '[ruby-dev:42341]'
Tempfile.open("bug3910") {|t|
path = t.path
@@ -2913,7 +2846,7 @@ __END__
end
def test_fcntl_lock_linux
- pad = 0
+ pad=0
Tempfile.create(self.class.name) do |f|
r, w = IO.pipe
pid = fork do
@@ -3095,9 +3028,7 @@ __END__
assert_equal(1, File.write(path, "f", 0, encoding: "UTF-8"))
assert_equal("ff", File.read(path))
assert_raise(TypeError) {
- assert_warn(/The last argument is split into positional and keyword parameters/) do
- File.write(path, "foo", Object.new => Object.new)
- end
+ File.write(path, "foo", Object.new => Object.new)
}
end
end
@@ -3224,7 +3155,7 @@ __END__
f.ioctl(tiocgwinsz, winsize)
}
ensure
- f&.close
+ f.close if f
end
end if /^(?:i.?86|x86_64)-linux/ =~ RUBY_PLATFORM
@@ -3320,12 +3251,17 @@ __END__
assert_equal 100, buf.bytesize
- msg = /can't modify string; temporarily locked/
- assert_raise_with_message(RuntimeError, msg) do
+ begin
buf.replace("")
- end
+ rescue RuntimeError => e
+ assert_match(/can't modify string; temporarily locked/, e.message)
+ Thread.pass
+ end until buf.empty?
+
+ assert_empty(buf, bug6099)
assert_predicate(th, :alive?)
w.write(data)
+ Thread.pass while th.alive?
th.join
end
assert_equal(data, buf, bug6099)
@@ -3612,17 +3548,8 @@ __END__
end
end if File::BINARY != 0
- def test_exclusive_mode
- make_tempfile do |t|
- assert_raise(Errno::EEXIST){ open(t.path, 'wx'){} }
- assert_raise(ArgumentError){ open(t.path, 'rx'){} }
- assert_raise(ArgumentError){ open(t.path, 'ax'){} }
- end
- end
-
def test_race_gets_and_close
- opt = { signal: :ABRT, timeout: 200 }
- assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}", **opt)
+ assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
bug13076 = '[ruby-core:78845] [Bug #13076]'
begin;
10.times do |i|
@@ -3644,9 +3571,9 @@ __END__
w.close
r.close
end
- t.each do |th|
- assert_same(th, th.join(2), bug13076)
- end
+ assert_nothing_raised(IOError, bug13076) {
+ t.each(&:join)
+ }
end
end;
end
@@ -3769,7 +3696,6 @@ __END__
end
def test_write_no_garbage
- skip "multiple threads already active" if Thread.list.size > 1
res = {}
ObjectSpace.count_objects(res) # creates strings on first call
[ 'foo'.b, '*' * 24 ].each do |buf|
@@ -3791,40 +3717,38 @@ __END__
end
end
end
- end
- def test_pread
- make_tempfile { |t|
- open(t.path) do |f|
- assert_equal("bar", f.pread(3, 4))
- buf = "asdf"
- assert_equal("bar", f.pread(3, 4, buf))
- assert_equal("bar", buf)
- assert_raise(EOFError) { f.pread(1, f.size) }
- end
- }
- end if IO.method_defined?(:pread)
+ def test_pread
+ make_tempfile { |t|
+ open(t.path) do |f|
+ assert_equal("bar", f.pread(3, 4))
+ buf = "asdf"
+ assert_equal("bar", f.pread(3, 4, buf))
+ assert_equal("bar", buf)
+ assert_raise(EOFError) { f.pread(1, f.size) }
+ end
+ }
+ end if IO.method_defined?(:pread)
- def test_pwrite
- make_tempfile { |t|
- open(t.path, IO::RDWR) do |f|
- assert_equal(3, f.pwrite("ooo", 4))
- assert_equal("ooo", f.pread(3, 4))
- end
- }
- end if IO.method_defined?(:pread) and IO.method_defined?(:pwrite)
+ def test_pwrite
+ make_tempfile { |t|
+ open(t.path, IO::RDWR) do |f|
+ assert_equal(3, f.pwrite("ooo", 4))
+ assert_equal("ooo", f.pread(3, 4))
+ end
+ }
+ end if IO.method_defined?(:pread) and IO.method_defined?(:pwrite)
+ end
def test_select_exceptfds
- if Etc.uname[:sysname] == 'SunOS'
- str = 'h'.freeze #(???) Only 1 byte with MSG_OOB on Solaris
- else
- str = 'hello'.freeze
+ if Etc.uname[:sysname] == 'SunOS' && Etc.uname[:release] == '5.11'
+ skip "Solaris 11 fails this"
end
TCPServer.open('localhost', 0) do |svr|
con = TCPSocket.new('localhost', svr.addr[1])
acc = svr.accept
- assert_equal str.length, con.send(str, Socket::MSG_OOB)
+ assert_equal 5, con.send('hello', Socket::MSG_OOB)
set = IO.select(nil, nil, [acc], 30)
assert_equal([[], [], [acc]], set, 'IO#select exceptions array OK')
acc.close
@@ -3832,81 +3756,20 @@ __END__
end
end if Socket.const_defined?(:MSG_OOB)
- def test_recycled_fd_close
- dot = -'.'
- IO.pipe do |sig_rd, sig_wr|
- noex = Thread.new do # everything right and never see exceptions :)
- until sig_rd.wait_readable(0)
- IO.pipe do |r, w|
- th = Thread.new { r.read(1) }
- w.write(dot)
-
- assert_same th, th.join(15), '"good" reader timeout'
- assert_equal(dot, th.value)
- end
- end
- sig_rd.read(4)
- end
- 1000.times do |i| # stupid things and make exceptions:
- IO.pipe do |r,w|
- th = Thread.new do
- begin
- while r.gets
- end
- rescue IOError => e
- e
- end
- end
- Thread.pass until th.stop?
-
- r.close
- assert_same th, th.join(30), '"bad" reader timeout'
- assert_match(/stream closed/, th.value.message)
- end
- end
- sig_wr.write 'done'
- assert_same noex, noex.join(20), '"good" writer timeout'
- assert_equal 'done', noex.value ,'r63216'
- end
- end
-
def test_select_leak
- # avoid malloc arena explosion from glibc and jemalloc:
- env = {
- 'MALLOC_ARENA_MAX' => '1',
- 'MALLOC_ARENA_TEST' => '1',
- 'MALLOC_CONF' => 'narenas:1',
- }
- assert_no_memory_leak([env], <<-"end;", <<-"end;", rss: true, timeout: 60)
+ assert_no_memory_leak([], <<-"end;", <<-"end;", rss: true, timeout: 240)
r, w = IO.pipe
rset = [r]
wset = [w]
- exc = StandardError.new(-"select used to leak on exception")
- exc.set_backtrace([])
Thread.new { IO.select(rset, wset, nil, 0) }.join
end;
- th = Thread.new do
- Thread.handle_interrupt(StandardError => :on_blocking) do
- begin
- IO.select(rset, wset)
- rescue
- retry
- end while true
- end
- end
- 50_000.times do
+ 20_000.times do
+ th = Thread.new { IO.select(rset, wset) }
Thread.pass until th.stop?
- th.raise(exc)
+ th.kill
+ th.join
+ GC.start
end
- th.kill
- th.join
end;
end
-
- def test_external_encoding_index
- IO.pipe {|r, w|
- assert_raise(TypeError) {Marshal.dump(r)}
- assert_raise(TypeError) {Marshal.dump(w)}
- }
- end
end
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index e5b0ef0585..9ff5307fc3 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -23,8 +23,7 @@ class TestIO_M17N < Test::Unit::TestCase
def pipe(*args, wp, rp)
re, we = nil, nil
- kw = args.last.is_a?(Hash) ? args.pop : {}
- r, w = IO.pipe(*args, **kw)
+ r, w = IO.pipe(*args)
rt = Thread.new do
begin
rp.call(r)
@@ -2081,56 +2080,29 @@ EOT
}
end
- %w/UTF-8 UTF-16BE UTF-16LE UTF-32BE UTF-32LE/.each do |name|
- define_method("test_strip_bom:#{name}") do
- path = "#{name}-bom.txt"
- with_tmpdir {
- text = "\uFEFF\u0100a"
- stripped = "\u0100a"
+ def test_strip_bom
+ with_tmpdir {
+ text = "\uFEFF\u0100a"
+ stripped = "\u0100a"
+ %w/UTF-8 UTF-16BE UTF-16LE UTF-32BE UTF-32LE/.each do |name|
+ path = '%s-bom.txt' % name
content = text.encode(name)
generate_file(path, content)
result = File.read(path, mode: 'rb:BOM|UTF-8')
- assert_equal(Encoding.find(name), result.encoding, name)
- assert_equal(content[1..-1].b, result.b, name)
- %w[rb rt r].each do |mode|
- message = "#{name}, mode: #{mode.dump}"
- result = File.read(path, mode: "#{mode}:BOM|UTF-8:UTF-8")
- assert_equal(Encoding::UTF_8, result.encoding, message)
- assert_equal(stripped, result, message)
- end
-
- File.open(path, "rb") {|f|
- assert_equal(Encoding.find(name), f.set_encoding_by_bom)
- }
- File.open(path, "rb", encoding: "iso-8859-1") {|f|
- assert_raise(ArgumentError) {f.set_encoding_by_bom}
- }
- }
- end
- end
-
- def test_strip_bom_no_conv
- with_tmpdir {
- path = 'UTF-8-bom.txt'
- generate_file(path, "\uFEFFa")
+ assert_equal(content[1..-1].force_encoding("ascii-8bit"),
+ result.force_encoding("ascii-8bit"))
+ result = File.read(path, mode: 'rb:BOM|UTF-8:UTF-8')
+ assert_equal(Encoding::UTF_8, result.encoding)
+ assert_equal(stripped, result)
+ end
bug3407 = '[ruby-core:30641]'
- result = File.read(path, encoding: 'BOM|UTF-8')
- assert_equal("a", result.b, bug3407)
-
- File.open(path, "rb", encoding: "iso-8859-1") {|f|
- assert_raise(ArgumentError) {f.set_encoding_by_bom}
- }
- }
- end
-
- def test_strip_bom_invalid
- with_tmpdir {
path = 'UTF-8-bom.txt'
- generate_file(path, "\uFEFFa")
+ result = File.read(path, encoding: 'BOM|UTF-8')
+ assert_equal(stripped.b, result.force_encoding("ascii-8bit"), bug3407)
bug8323 = '[ruby-core:54563] [Bug #8323]'
- expected = "a\xff".force_encoding("utf-8")
+ expected = (stripped.b + "\xff").force_encoding("utf-8")
open(path, 'ab') {|f| f.write("\xff")}
result = File.read(path, encoding: 'BOM|UTF-8')
assert_not_predicate(result, :valid_encoding?, bug8323)
@@ -2138,38 +2110,23 @@ EOT
result = File.read(path, encoding: 'BOM|UTF-8:UTF-8')
assert_not_predicate(result, :valid_encoding?, bug8323)
assert_equal(expected, result, bug8323)
- }
- end
- def test_strip_bom_no_bom
- with_tmpdir {
- bug8323 = '[ruby-core:54563] [Bug #8323]'
path = 'ascii.txt'
- stripped = "a"
generate_file(path, stripped)
result = File.read(path, encoding: 'BOM|UTF-8')
assert_equal(stripped, result, bug8323)
result = File.read(path, encoding: 'BOM|UTF-8:UTF-8')
assert_equal(stripped, result, bug8323)
-
- File.open(path, "rb") {|f|
- assert_nil(f.set_encoding_by_bom)
- }
- File.open(path, "rb", encoding: "iso-8859-1") {|f|
- assert_raise(ArgumentError) {f.set_encoding_by_bom}
- }
}
end
def test_bom_too_long_utfname
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
+ assert_separately([], <<-'end;') # do
assert_warn(/Unsupported encoding/) {
open(IO::NULL, "r:bom|utf-" + "x" * 10000) {}
}
end;
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
+ assert_separately([], <<-'end;') # do
assert_warn(/Unsupported encoding/) {
open(IO::NULL, encoding: "bom|utf-" + "x" * 10000) {}
}
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 709061d54a..ed88c9b43d 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -91,11 +91,6 @@ class TestISeq < Test::Unit::TestCase
asm = compile(src).disasm
assert_equal(src.encoding, asm.encoding)
assert_predicate(asm, :valid_encoding?)
-
- obj = Object.new
- name = "\u{2603 26a1}"
- obj.instance_eval("def #{name}; tap {}; end")
- assert_include(RubyVM::InstructionSequence.of(obj.method(name)).disasm, name)
end
LINE_BEFORE_METHOD = __LINE__
@@ -246,12 +241,9 @@ class TestISeq < Test::Unit::TestCase
end
end
assert_equal([m1, e1.message], [m2, e2.message], feature11951)
- message = e1.message.each_line
- message.with_index(1) do |line, i|
- next if /^ / =~ line
- assert_send([line, :start_with?, __FILE__],
- proc {message.map {|l, j| (i == j ? ">" : " ") + l}.join("")})
- end
+ e1, e2 = e1.message.lines
+ assert_send([e1, :start_with?, __FILE__])
+ assert_send([e2, :start_with?, __FILE__])
end
def test_compile_file_error
@@ -259,7 +251,7 @@ class TestISeq < Test::Unit::TestCase
f.puts "end"
f.close
path = f.path
- assert_in_out_err(%W[- #{path}], "#{<<-"begin;"}\n#{<<-"end;"}", /unexpected `end'/, [], success: true)
+ assert_in_out_err(%W[- #{path}], "#{<<-"begin;"}\n#{<<-"end;"}", /keyword_end/, [], success: true)
begin;
path = ARGV[0]
begin
@@ -283,18 +275,14 @@ class TestISeq < Test::Unit::TestCase
def test_inspect
%W[foo \u{30d1 30b9}].each do |name|
- assert_match(/@#{name}/, ISeq.compile("", name).inspect, name)
+ assert_match /@#{name}/, ISeq.compile("", name).inspect, name
m = ISeq.compile("class TestISeq::Inspect; def #{name}; end; instance_method(:#{name}); end").eval
- assert_match(/:#{name}@/, ISeq.of(m).inspect, name)
+ assert_match /:#{name}@/, ISeq.of(m).inspect, name
end
end
- def strip_lineno(source)
- source.gsub(/^.*?: /, "")
- end
-
def sample_iseq
- ISeq.compile(strip_lineno(<<-EOS))
+ ISeq.compile <<-EOS.gsub(/^.*?: /, "")
1: class C
2: def foo
3: begin
@@ -387,7 +375,7 @@ class TestISeq < Test::Unit::TestCase
type = ary[9]
name = ary[5]
line = ary[13].first
- case type
+ case ary[9]
when :method
assert_equal "foo", name
assert_equal 3, line
@@ -403,169 +391,44 @@ class TestISeq < Test::Unit::TestCase
}
end
- def hexdump(bin)
- bin.unpack1("H*").gsub(/.{1,32}/) {|s|
- "#{'%04x:' % $~.begin(0)}#{s.gsub(/../, " \\&").tap{|_|_[24]&&="-"}}\n"
- }
- end
-
- def assert_iseq_to_binary(code, mesg = nil)
+ def test_to_binary_with_objects
+ # conceptually backport from r62856.
+ # ISeq binary dump doesn't consider alignment in 2.5 and older
+ skip "does not work on other than x86" unless /x(?:86|64)|i\d86/ =~ RUBY_PLATFORM
+ code = "[]"+100.times.map{|i|"<</#{i}/"}.join
iseq = RubyVM::InstructionSequence.compile(code)
- bin = assert_nothing_raised(mesg) do
+ bin = assert_nothing_raised do
iseq.to_binary
rescue RuntimeError => e
skip e.message if /compile with coverage/ =~ e.message
raise
end
- 10.times do
- bin2 = iseq.to_binary
- assert_equal(bin, bin2, message(mesg) {diff hexdump(bin), hexdump(bin2)})
- end
iseq2 = RubyVM::InstructionSequence.load_from_binary(bin)
- a1 = iseq.to_a
- a2 = iseq2.to_a
- assert_equal(a1, a2, message(mesg) {diff iseq.disassemble, iseq2.disassemble})
- iseq2
- end
-
- def test_to_binary_with_objects
- assert_iseq_to_binary("[]"+100.times.map{|i|"<</#{i}/"}.join)
- assert_iseq_to_binary("@x ||= (1..2)")
+ assert_equal(iseq2.to_a, iseq.to_a)
end
- def test_to_binary_pattern_matching
- code = "case foo; in []; end"
- iseq = compile(code)
- assert_include(iseq.disasm, "TypeError")
- assert_include(iseq.disasm, "NoMatchingPatternError")
- EnvUtil.suppress_warning do
- assert_iseq_to_binary(code, "[Feature #14912]")
+ def test_to_binary_tracepoint
+ # conceptually backport from r62856.
+ # ISeq binary dump doesn't consider alignment in 2.5 and older
+ skip "does not work on other than x86" unless /x(?:86|64)|i\d86/ =~ RUBY_PLATFORM
+ filename = "#{File.basename(__FILE__)}_#{__LINE__}"
+ iseq = RubyVM::InstructionSequence.compile("x = 1\n y = 2", filename)
+ # conceptually partial backport from r63103, r65567.
+ # All ISeq#to_binary should rescue to skip when running with coverage.
+ # current trunk (2.6-) has assert_iseq_to_binary.
+ begin
+ iseq_bin = iseq.to_binary
+ rescue RuntimeError => e
+ skip e.message if /compile with coverage/ =~ e.message
+ raise
end
- end
-
- def test_to_binary_dumps_nokey
- iseq = assert_iseq_to_binary(<<-RUBY)
- o = Object.new
- class << o
- def foo(**nil); end
- end
- o
- RUBY
- assert_equal([[:nokey]], iseq.eval.singleton_method(:foo).parameters)
- end
-
- def test_to_binary_line_info
- assert_iseq_to_binary("#{<<~"begin;"}\n#{<<~'end;'}", '[Bug #14660]').eval
- begin;
- class P
- def p; end
- def q; end
- E = ""
- N = "#{E}"
- attr_reader :i
- end
- end;
- end
-
- def collect_from_binary_tracepoint_lines(tracepoint_type, filename)
- iseq = RubyVM::InstructionSequence.compile(strip_lineno(<<-RUBY), filename)
- class A
- class B
- 2.times {
- def self.foo
- _a = 'good day'
- raise
- rescue
- 'dear reader'
- end
- }
- end
- B.foo
- end
- RUBY
-
- iseq_bin = iseq.to_binary
- iseq = ISeq.load_from_binary(iseq_bin)
- lines = []
- TracePoint.new(tracepoint_type){|tp|
+ ary = []
+ TracePoint.new(:line){|tp|
next unless tp.path == filename
- lines << tp.lineno
+ ary << [tp.path, tp.lineno]
}.enable{
- EnvUtil.suppress_warning {iseq.eval}
- }
-
- lines
- end
-
- def test_to_binary_line_tracepoint
- filename = "#{File.basename(__FILE__)}_#{__LINE__}"
- lines = collect_from_binary_tracepoint_lines(:line, filename)
-
- assert_equal [1, 2, 3, 4, 4, 12, 5, 6, 8], lines, '[Bug #14702]'
- end
-
- def test_to_binary_class_tracepoint
- filename = "#{File.basename(__FILE__)}_#{__LINE__}"
- lines = collect_from_binary_tracepoint_lines(:class, filename)
-
- assert_equal [1, 2], lines, '[Bug #14702]'
- end
-
- def test_to_binary_end_tracepoint
- filename = "#{File.basename(__FILE__)}_#{__LINE__}"
- lines = collect_from_binary_tracepoint_lines(:end, filename)
-
- assert_equal [11, 13], lines, '[Bug #14702]'
- end
-
- def test_to_binary_return_tracepoint
- filename = "#{File.basename(__FILE__)}_#{__LINE__}"
- lines = collect_from_binary_tracepoint_lines(:return, filename)
-
- assert_equal [9], lines, '[Bug #14702]'
- end
-
- def test_to_binary_b_call_tracepoint
- filename = "#{File.basename(__FILE__)}_#{__LINE__}"
- lines = collect_from_binary_tracepoint_lines(:b_call, filename)
-
- assert_equal [3, 3], lines, '[Bug #14702]'
- end
-
- def test_to_binary_b_return_tracepoint
- filename = "#{File.basename(__FILE__)}_#{__LINE__}"
- lines = collect_from_binary_tracepoint_lines(:b_return, filename)
-
- assert_equal [10, 10], lines, '[Bug #14702]'
- end
-
- def test_iseq_of
- [proc{},
- method(:test_iseq_of),
- RubyVM::InstructionSequence.compile("p 1", __FILE__)].each{|src|
- iseq = RubyVM::InstructionSequence.of(src)
- assert_equal __FILE__, iseq.path
- }
- end
-
- def test_iseq_of_twice_for_same_code
- [proc{},
- method(:test_iseq_of_twice_for_same_code),
- RubyVM::InstructionSequence.compile("p 1")].each{|src|
- iseq1 = RubyVM::InstructionSequence.of(src)
- iseq2 = RubyVM::InstructionSequence.of(src)
-
- # ISeq objects should be same for same src
- assert_equal iseq1.object_id, iseq2.object_id
+ ISeq.load_from_binary(iseq_bin).eval
}
- end
-
- def test_iseq_builtin_to_a
- invokebuiltin = eval(EnvUtil.invoke_ruby(['-e', <<~EOS], '', true).first)
- insns = RubyVM::InstructionSequence.of([].method(:pack)).to_a.last
- p insns.find { |insn| insn.is_a?(Array) && insn[0] == :opt_invokebuiltin_delegate_leave }
- EOS
- assert_not_nil(invokebuiltin)
- assert_equal([:func_ptr, :argc, :index, :name], invokebuiltin[1].keys)
+ assert_equal [[filename, 1], [filename, 2]], ary, '[Bug #14702]'
end
end
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb
index 54c095338f..9bfa947607 100644
--- a/test/ruby/test_iterator.rb
+++ b/test/ruby/test_iterator.rb
@@ -12,12 +12,17 @@ class Array
end
class TestIterator < Test::Unit::TestCase
- def test_yield_at_toplevel
- assert_separately([],"#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- assert(!block_given?)
- assert(!defined?(yield))
- end;
+ def ttt
+ assert(iterator?)
+ end
+
+ def test_iterator
+ assert(!iterator?)
+
+ ttt{}
+
+ # yield at top level !! here's not toplevel
+ assert(!defined?(yield))
end
def test_array
@@ -102,16 +107,6 @@ class TestIterator < Test::Unit::TestCase
assert_equal([1, 2, 3, 4, 5, 6, 7], x)
end
- def test_array_for_masgn
- a = [Struct.new(:to_ary).new([1,2])]
- x = []
- a.each {|i,j|x << [i,j]}
- assert_equal([[1,2]], x)
- x = []
- for i,j in a; x << [i,j]; end
- assert_equal([[1,2]], x)
- end
-
def test_append_method_to_built_in_class
x = [[1,2],[3,4],[5,6]]
assert_equal(x.iter_test1{|e|e}, x.iter_test2{|e|e})
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb
deleted file mode 100644
index e3d8f9cee2..0000000000
--- a/test/ruby/test_jit.rb
+++ /dev/null
@@ -1,1124 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-require 'tmpdir'
-require_relative '../lib/jit_support'
-
-# Test for --jit option
-class TestJIT < Test::Unit::TestCase
- include JITSupport
-
- IGNORABLE_PATTERNS = [
- /\AJIT recompile: .+\n\z/,
- /\AJIT inline: .+\n\z/,
- /\ASuccessful MJIT finish\n\z/,
- ]
- MAX_CACHE_PATTERNS = [
- /\AJIT compaction \([^)]+\): .+\n\z/,
- /\ANo units can be unloaded -- .+\n\z/,
- ]
-
- # trace_* insns are not compiled for now...
- TEST_PENDING_INSNS = RubyVM::INSTRUCTION_NAMES.select { |n| n.start_with?('trace_') }.map(&:to_sym) + [
- # not supported yet
- :defineclass,
- :opt_call_c_function,
-
- # to be tested
- :invokebuiltin,
-
- # never used
- :opt_invokebuiltin_delegate,
- ].each do |insn|
- if !RubyVM::INSTRUCTION_NAMES.include?(insn.to_s)
- warn "instruction #{insn.inspect} is not defined but included in TestJIT::TEST_PENDING_INSNS"
- end
- end
-
- def self.untested_insns
- @untested_insns ||= (RubyVM::INSTRUCTION_NAMES.map(&:to_sym) - TEST_PENDING_INSNS)
- end
-
- def setup
- unless JITSupport.supported?
- skip 'JIT seems not supported on this platform'
- end
-
- # ruby -w -Itest/lib test/ruby/test_jit.rb
- if $VERBOSE && !defined?(@@at_exit_hooked)
- at_exit do
- unless TestJIT.untested_insns.empty?
- warn "you may want to add tests for following insns, when you have a chance: #{TestJIT.untested_insns.join(' ')}"
- end
- end
- @@at_exit_hooked = true
- end
- end
-
- def test_compile_insn_nop
- assert_compile_once('nil rescue true', result_inspect: 'nil', insns: %i[nop])
- end
-
- def test_compile_insn_local
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[setlocal_WC_0 getlocal_WC_0])
- begin;
- foo = 1
- foo
- end;
-
- insns = %i[setlocal getlocal setlocal_WC_0 getlocal_WC_0 setlocal_WC_1 getlocal_WC_1]
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", success_count: 3, stdout: '168', insns: insns)
- begin;
- def foo
- a = 0
- [1, 2].each do |i|
- a += i
- [3, 4].each do |j|
- a *= j
- end
- end
- a
- end
-
- print foo
- end;
- end
-
- def test_compile_insn_blockparam
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 2, insns: %i[getblockparam setblockparam])
- begin;
- def foo(&b)
- a = b
- b = 2
- a.call + 2
- end
-
- print foo { 1 }
- end;
- end
-
- def test_compile_insn_getblockparamproxy
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '4', success_count: 3, insns: %i[getblockparamproxy])
- begin;
- def bar(&b)
- b.call
- end
-
- def foo(&b)
- bar(&b) * bar(&b)
- end
-
- print foo { 2 }
- end;
- end
-
- def test_compile_insn_getspecial
- assert_compile_once('$1', result_inspect: 'nil', insns: %i[getspecial])
- end
-
- def test_compile_insn_setspecial
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: 'true', insns: %i[setspecial])
- begin;
- true if nil.nil?..nil.nil?
- end;
- end
-
- def test_compile_insn_instancevariable
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[getinstancevariable setinstancevariable])
- begin;
- @foo = 1
- @foo
- end;
-
- # optimized getinstancevariable call
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '33', success_count: 1, min_calls: 2)
- begin;
- class A
- def initialize
- @a = 1
- @b = 2
- end
-
- def three
- @a + @b
- end
- end
-
- a = A.new
- print(a.three) # set ic
- print(a.three) # inlined ic
- end;
- end
-
- def test_compile_insn_classvariable
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '1', success_count: 1, insns: %i[getclassvariable setclassvariable])
- begin;
- class Foo
- def self.foo
- @@foo = 1
- @@foo
- end
- end
-
- print Foo.foo
- end;
- end
-
- def test_compile_insn_constant
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[getconstant setconstant])
- begin;
- FOO = 1
- FOO
- end;
- end
-
- def test_compile_insn_global
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[getglobal setglobal])
- begin;
- $foo = 1
- $foo
- end;
- end
-
- def test_compile_insn_putnil
- assert_compile_once('nil', result_inspect: 'nil', insns: %i[putnil])
- end
-
- def test_compile_insn_putself
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 1, insns: %i[putself])
- begin;
- proc { print "hello" }.call
- end;
- end
-
- def test_compile_insn_putobject
- assert_compile_once('0', result_inspect: '0', insns: %i[putobject_INT2FIX_0_])
- assert_compile_once('1', result_inspect: '1', insns: %i[putobject_INT2FIX_1_])
- assert_compile_once('2', result_inspect: '2', insns: %i[putobject])
- end
-
- def test_compile_insn_definemethod_definesmethod
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'helloworld', success_count: 3, insns: %i[definemethod definesmethod])
- begin;
- print 1.times.map {
- def method_definition
- 'hello'
- end
-
- def self.smethod_definition
- 'world'
- end
-
- method_definition + smethod_definition
- }.join
- end;
- end
-
- def test_compile_insn_putspecialobject
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'a', success_count: 2, insns: %i[putspecialobject])
- begin;
- print 1.times.map {
- def a
- 'a'
- end
-
- alias :b :a
-
- b
- }.join
- end;
- end
-
- def test_compile_insn_putstring_concatstrings_tostring
- assert_compile_once('"a#{}b" + "c"', result_inspect: '"abc"', insns: %i[putstring concatstrings tostring])
- end
-
- def test_compile_insn_freezestring
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~'end;'}", stdout: 'true', success_count: 1, insns: %i[freezestring])
- begin;
- # frozen_string_literal: true
- print proc { "#{true}".frozen? }.call
- end;
- end
-
- def test_compile_insn_toregexp
- assert_compile_once('/#{true}/ =~ "true"', result_inspect: '0', insns: %i[toregexp])
- end
-
- def test_compile_insn_newarray
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '[1, 2, 3]', insns: %i[newarray])
- begin;
- a, b, c = 1, 2, 3
- [a, b, c]
- end;
- end
-
- def test_compile_insn_newarraykwsplat
- assert_compile_once('[**{ x: 1 }]', result_inspect: '[{:x=>1}]', insns: %i[newarraykwsplat])
- end
-
- def test_compile_insn_intern_duparray
- assert_compile_once('[:"#{0}"] + [1,2,3]', result_inspect: '[:"0", 1, 2, 3]', insns: %i[intern duparray])
- end
-
- def test_compile_insn_expandarray
- assert_compile_once('y = [ true, false, nil ]; x, = y; x', result_inspect: 'true', insns: %i[expandarray])
- end
-
- def test_compile_insn_concatarray
- assert_compile_once('["t", "r", *x = "u", "e"].join', result_inspect: '"true"', insns: %i[concatarray])
- end
-
- def test_compile_insn_splatarray
- assert_compile_once('[*(1..2)]', result_inspect: '[1, 2]', insns: %i[splatarray])
- end
-
- def test_compile_insn_newhash
- assert_compile_once('a = 1; { a: a }', result_inspect: '{:a=>1}', insns: %i[newhash])
- end
-
- def test_compile_insn_duphash
- assert_compile_once('{ a: 1 }', result_inspect: '{:a=>1}', insns: %i[duphash])
- end
-
- def test_compile_insn_newrange
- assert_compile_once('a = 1; 0..a', result_inspect: '0..1', insns: %i[newrange])
- end
-
- def test_compile_insn_pop
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[pop])
- begin;
- a = false
- b = 1
- a || b
- end;
- end
-
- def test_compile_insn_dup
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '3', insns: %i[dup])
- begin;
- a = 1
- a&.+(2)
- end;
- end
-
- def test_compile_insn_dupn
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: 'true', insns: %i[dupn])
- begin;
- klass = Class.new
- klass::X ||= true
- end;
- end
-
- def test_compile_insn_swap_topn
- assert_compile_once('{}["true"] = true', result_inspect: 'true', insns: %i[swap topn])
- end
-
- def test_compile_insn_reverse
- assert_compile_once('q, (w, e), r = 1, [2, 3], 4; [q, w, e, r]', result_inspect: '[1, 2, 3, 4]', insns: %i[reverse])
- end
-
- def test_compile_insn_reput
- skip "write test"
- end
-
- def test_compile_insn_setn
- assert_compile_once('[nil][0] = 1', result_inspect: '1', insns: %i[setn])
- end
-
- def test_compile_insn_adjuststack
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: 'true', insns: %i[adjuststack])
- begin;
- x = [true]
- x[0] ||= nil
- x[0]
- end;
- end
-
- def test_compile_insn_defined
- assert_compile_once('defined?(a)', result_inspect: 'nil', insns: %i[defined])
- end
-
- def test_compile_insn_checkkeyword
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'true', success_count: 1, insns: %i[checkkeyword])
- begin;
- def test(x: rand)
- x
- end
- print test(x: true)
- end;
- end
-
- def test_compile_insn_tracecoverage
- skip "write test"
- end
-
- def test_compile_insn_defineclass
- skip "support this in mjit_compile (low priority)"
- end
-
- def test_compile_insn_send
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '1', success_count: 2, insns: %i[send])
- begin;
- print proc { yield_self { 1 } }.call
- end;
- end
-
- def test_compile_insn_opt_str_freeze
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '"foo"', insns: %i[opt_str_freeze])
- begin;
- 'foo'.freeze
- end;
- end
-
- def test_compile_insn_opt_nil_p
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: 'false', insns: %i[opt_nil_p])
- begin;
- nil.nil?.nil?
- end;
- end
-
- def test_compile_insn_opt_str_uminus
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '"bar"', insns: %i[opt_str_uminus])
- begin;
- -'bar'
- end;
- end
-
- def test_compile_insn_opt_newarray_max
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '2', insns: %i[opt_newarray_max])
- begin;
- a = 1
- b = 2
- [a, b].max
- end;
- end
-
- def test_compile_insn_opt_newarray_min
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[opt_newarray_min])
- begin;
- a = 1
- b = 2
- [a, b].min
- end;
- end
-
- def test_compile_insn_opt_send_without_block
- assert_compile_once('print', result_inspect: 'nil', insns: %i[opt_send_without_block])
- end
-
- def test_compile_insn_invokesuper
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 4, insns: %i[invokesuper])
- begin;
- mod = Module.new {
- def test
- super + 2
- end
- }
- klass = Class.new {
- prepend mod
- def test
- 1
- end
- }
- print klass.new.test
- end;
- end
-
- def test_compile_insn_invokeblock_leave
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '2', success_count: 2, insns: %i[invokeblock leave])
- begin;
- def foo
- yield
- end
- print foo { 2 }
- end;
- end
-
- def test_compile_insn_throw
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '4', success_count: 2, insns: %i[throw])
- begin;
- def test
- proc do
- if 1+1 == 1
- return 3
- else
- return 4
- end
- 5
- end.call
- end
- print test
- end;
- end
-
- def test_compile_insn_jump_branchif
- assert_compile_once("#{<<~"begin;"}\n#{<<~'end;'}", result_inspect: 'nil', insns: %i[jump branchif])
- begin;
- a = false
- 1 + 1 while a
- end;
- end
-
- def test_compile_insn_branchunless
- assert_compile_once("#{<<~"begin;"}\n#{<<~'end;'}", result_inspect: '1', insns: %i[branchunless])
- begin;
- a = true
- if a
- 1
- else
- 2
- end
- end;
- end
-
- def test_compile_insn_branchnil
- assert_compile_once("#{<<~"begin;"}\n#{<<~'end;'}", result_inspect: '3', insns: %i[branchnil])
- begin;
- a = 2
- a&.+(1)
- end;
- end
-
- def test_compile_insn_checktype
- assert_compile_once("#{<<~"begin;"}\n#{<<~'end;'}", result_inspect: '"42"', insns: %i[checktype])
- begin;
- a = '2'
- "4#{a}"
- end;
- end
-
- def test_compile_insn_inlinecache
- assert_compile_once('Struct', result_inspect: 'Struct', insns: %i[opt_getinlinecache opt_setinlinecache])
- end
-
- def test_compile_insn_once
- assert_compile_once('/#{true}/o =~ "true" && $~.to_a', result_inspect: '["true"]', insns: %i[once])
- end
-
- def test_compile_insn_checkmatch_opt_case_dispatch
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '"world"', insns: %i[checkmatch opt_case_dispatch])
- begin;
- case 'hello'
- when 'hello'
- 'world'
- end
- end;
- end
-
- def test_compile_insn_opt_calc
- assert_compile_once('4 + 2 - ((2 * 3 / 2) % 2)', result_inspect: '5', insns: %i[opt_plus opt_minus opt_mult opt_div opt_mod])
- assert_compile_once('4.0 + 2.0 - ((2.0 * 3.0 / 2.0) % 2.0)', result_inspect: '5.0', insns: %i[opt_plus opt_minus opt_mult opt_div opt_mod])
- assert_compile_once('4 + 2', result_inspect: '6')
- end
-
- def test_compile_insn_opt_cmp
- assert_compile_once('(1 == 1) && (1 != 2)', result_inspect: 'true', insns: %i[opt_eq opt_neq])
- end
-
- def test_compile_insn_opt_rel
- assert_compile_once('1 < 2 && 1 <= 1 && 2 > 1 && 1 >= 1', result_inspect: 'true', insns: %i[opt_lt opt_le opt_gt opt_ge])
- end
-
- def test_compile_insn_opt_ltlt
- assert_compile_once('[1] << 2', result_inspect: '[1, 2]', insns: %i[opt_ltlt])
- end
-
- def test_compile_insn_opt_and
- assert_compile_once('1 & 3', result_inspect: '1', insns: %i[opt_and])
- end
-
- def test_compile_insn_opt_or
- assert_compile_once('1 | 3', result_inspect: '3', insns: %i[opt_or])
- end
-
- def test_compile_insn_opt_aref
- # optimized call (optimized JIT) -> send call
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '21', success_count: 2, min_calls: 1, insns: %i[opt_aref])
- begin;
- obj = Object.new
- def obj.[](h)
- h
- end
-
- block = proc { |h| h[1] }
- print block.call({ 1 => 2 })
- print block.call(obj)
- end;
-
- # send call -> optimized call (send JIT) -> optimized call
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '122', success_count: 2, min_calls: 2)
- begin;
- obj = Object.new
- def obj.[](h)
- h
- end
-
- block = proc { |h| h[1] }
- print block.call(obj)
- print block.call({ 1 => 2 })
- print block.call({ 1 => 2 })
- end;
- end
-
- def test_compile_insn_opt_aref_with
- assert_compile_once("{ '1' => 2 }['1']", result_inspect: '2', insns: %i[opt_aref_with])
- end
-
- def test_compile_insn_opt_aset
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '5', insns: %i[opt_aset opt_aset_with])
- begin;
- hash = { '1' => 2 }
- (hash['2'] = 2) + (hash[1.to_s] = 3)
- end;
- end
-
- def test_compile_insn_opt_length_size
- assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '4', insns: %i[opt_length opt_size])
- begin;
- array = [1, 2]
- array.length + array.size
- end;
- end
-
- def test_compile_insn_opt_empty_p
- assert_compile_once('[].empty?', result_inspect: 'true', insns: %i[opt_empty_p])
- end
-
- def test_compile_insn_opt_succ
- assert_compile_once('1.succ', result_inspect: '2', insns: %i[opt_succ])
- end
-
- def test_compile_insn_opt_not
- assert_compile_once('!!true', result_inspect: 'true', insns: %i[opt_not])
- end
-
- def test_compile_insn_opt_regexpmatch2
- assert_compile_once("/true/ =~ 'true'", result_inspect: '0', insns: %i[opt_regexpmatch2])
- assert_compile_once("'true' =~ /true/", result_inspect: '0', insns: %i[opt_regexpmatch2])
- end
-
- def test_compile_insn_opt_call_c_function
- skip "support this in opt_call_c_function (low priority)"
- end
-
- def test_compile_insn_opt_invokebuiltin_delegate_leave
- insns = collect_insns(RubyVM::InstructionSequence.of("\x00".method(:unpack)).to_a)
- mark_tested_insn(:opt_invokebuiltin_delegate_leave, used_insns: insns)
- assert_eval_with_jit('print "\x00".unpack("c")', stdout: '[0]', success_count: 1)
- end
-
- def test_jit_output
- out, err = eval_with_jit('5.times { puts "MJIT" }', verbose: 1, min_calls: 5)
- assert_equal("MJIT\n" * 5, out)
- assert_match(/^#{JIT_SUCCESS_PREFIX}: block in <main>@-e:1 -> .+_ruby_mjit_p\d+u\d+\.c$/, err)
- assert_match(/^Successful MJIT finish$/, err)
- end
-
- def test_nothing_to_unload_with_jit_wait
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 11, max_cache: 10, ignorable_patterns: MAX_CACHE_PATTERNS)
- begin;
- def a1() a2() end
- def a2() a3() end
- def a3() a4() end
- def a4() a5() end
- def a5() a6() end
- def a6() a7() end
- def a7() a8() end
- def a8() a9() end
- def a9() a10() end
- def a10() a11() end
- def a11() print('hello') end
- a1
- end;
- end
-
- def test_unload_units_on_fiber
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 12, max_cache: 10, ignorable_patterns: MAX_CACHE_PATTERNS)
- begin;
- def a1() a2(false); a2(true) end
- def a2(a) a3(a) end
- def a3(a) a4(a) end
- def a4(a) a5(a) end
- def a5(a) a6(a) end
- def a6(a) a7(a) end
- def a7(a) a8(a) end
- def a8(a) a9(a) end
- def a9(a) a10(a) end
- def a10(a)
- if a
- Fiber.new { a11 }.resume
- end
- end
- def a11() print('hello') end
- a1
- end;
- end
-
- def test_unload_units_and_compaction
- Dir.mktmpdir("jit_test_unload_units_") do |dir|
- # MIN_CACHE_SIZE is 10
- out, err = eval_with_jit({"TMPDIR"=>dir}, "#{<<~"begin;"}\n#{<<~'end;'}", verbose: 1, min_calls: 1, max_cache: 10)
- begin;
- i = 0
- while i < 11
- eval(<<-EOS)
- def mjit#{i}
- print #{i}
- end
- mjit#{i}
- EOS
- i += 1
- end
-
- if defined?(fork)
- # test the child does not try to delete files which are deleted by parent,
- # and test possible deadlock on fork during MJIT unload and JIT compaction on child
- Process.waitpid(Process.fork {})
- end
- end;
-
- debug_info = %Q[stdout:\n"""\n#{out}\n"""\n\nstderr:\n"""\n#{err}"""\n]
- assert_equal('012345678910', out, debug_info)
- compactions, errs = err.lines.partition do |l|
- l.match?(/\AJIT compaction \(\d+\.\dms\): Compacted \d+ methods ->/)
- end
- 10.times do |i|
- assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit#{i}@\(eval\):/, errs[i], debug_info)
- end
- assert_equal("Too many JIT code -- 1 units unloaded\n", errs[10], debug_info)
- assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit10@\(eval\):/, errs[11], debug_info)
-
- # On --jit-wait, when the number of JIT-ed code reaches --jit-max-cache,
- # it should trigger compaction.
- unless RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet
- assert_equal(3, compactions.size, debug_info)
- end
-
- if RUBY_PLATFORM.match?(/mswin/)
- # "Permission Denied" error is preventing to remove so file on AppVeyor/RubyCI.
- skip 'Removing so file is randomly failing on AppVeyor/RubyCI mswin due to Permission Denied.'
- else
- # verify .o files are deleted on unload_units
- assert_send([Dir, :empty?, dir], debug_info)
- end
- end
- end
-
- def test_local_stack_on_exception
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 2)
- begin;
- def b
- raise
- rescue
- 2
- end
-
- def a
- # Calling #b should be vm_exec, not direct mjit_exec.
- # Otherwise `1` on local variable would be purged.
- 1 + b
- end
-
- print a
- end;
- end
-
- def test_local_stack_with_sp_motion_by_blockargs
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '1', success_count: 2)
- begin;
- def b(base)
- 1
- end
-
- # This method is simple enough to have false in catch_except_p.
- # So local_stack_p would be true in JIT compiler.
- def a
- m = method(:b)
-
- # ci->flag has VM_CALL_ARGS_BLOCKARG and cfp->sp is moved in vm_caller_setup_arg_block.
- # So, for this send insn, JIT-ed code should use cfp->sp instead of local variables for stack.
- Module.module_eval(&m)
- end
-
- print a
- end;
- end
-
- def test_catching_deep_exception
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '1', success_count: 4)
- begin;
- def catch_true(paths, prefixes) # catch_except_p: TRUE
- prefixes.each do |prefix| # catch_except_p: TRUE
- paths.each do |path| # catch_except_p: FALSE
- return path
- end
- end
- end
-
- def wrapper(paths, prefixes)
- catch_true(paths, prefixes)
- end
-
- print wrapper(['1'], ['2'])
- end;
- end
-
- def test_inlined_undefined_ivar
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "bbb", success_count: 3, min_calls: 3)
- begin;
- class Foo
- def initialize
- @a = :a
- end
-
- def bar
- if @b.nil?
- @b = :b
- end
- end
- end
-
- verbose, $VERBOSE = $VERBOSE, false # suppress "instance variable @b not initialized"
- print(Foo.new.bar)
- print(Foo.new.bar)
- print(Foo.new.bar)
- $VERBOSE = verbose
- end;
- end
-
- def test_inlined_setivar_frozen
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "FrozenError\n", success_count: 2, min_calls: 3)
- begin;
- class A
- def a
- @a = 1
- end
- end
-
- a = A.new
- a.a
- a.a
- a.a
- a.freeze
- begin
- a.a
- rescue FrozenError => e
- p e.class
- end
- end;
- end
-
- def test_attr_reader
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "4nil\nnil\n6", success_count: 2, min_calls: 2)
- begin;
- class A
- attr_reader :a, :b
-
- def initialize
- @a = 2
- end
-
- def test
- a
- end
-
- def undefined
- b
- end
- end
-
- a = A.new
- print(a.test * a.test)
- p(a.undefined)
- p(a.undefined)
-
- # redefinition
- def a.test
- 3
- end
-
- print(2 * a.test)
- end;
-
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "true", success_count: 1, min_calls: 2)
- begin;
- class Hoge
- attr_reader :foo
-
- def initialize
- @foo = []
- @bar = nil
- end
- end
-
- class Fuga < Hoge
- def initialize
- @bar = nil
- @foo = []
- end
- end
-
- def test(recv)
- recv.foo.empty?
- end
-
- hoge = Hoge.new
- fuga = Fuga.new
-
- test(hoge) # VM: cc set index=1
- test(hoge) # JIT: compile with index=1
- test(fuga) # JIT -> VM: cc set index=2
- print test(hoge) # JIT: should use index=1, not index=2 in cc
- end;
- end
-
- def test_jump_to_precompiled_branch
- assert_eval_with_jit("#{<<~'begin;'}\n#{<<~'end;'}", stdout: ".0", success_count: 1, min_calls: 1)
- begin;
- def test(foo)
- ".#{foo unless foo == 1}" if true
- end
- print test(0)
- end;
- end
-
- def test_clean_so
- if RUBY_PLATFORM.match?(/mswin/)
- skip 'Removing so file is randomly failing on AppVeyor/RubyCI mswin due to Permission Denied.'
- end
- Dir.mktmpdir("jit_test_clean_so_") do |dir|
- code = "x = 0; 10.times {|i|x+=i}"
- eval_with_jit({"TMPDIR"=>dir}, code)
- assert_send([Dir, :empty?, dir])
- eval_with_jit({"TMPDIR"=>dir}, code, save_temps: true)
- assert_not_send([Dir, :empty?, dir])
- end
- end
-
- def test_clean_objects_on_exec
- if /mswin|mingw/ =~ RUBY_PLATFORM
- # TODO: check call stack and close handle of code which is not on stack, and remove objects on best-effort basis
- skip 'Removing so file being used does not work on Windows'
- end
- Dir.mktmpdir("jit_test_clean_objects_on_exec_") do |dir|
- eval_with_jit({"TMPDIR"=>dir}, "#{<<~"begin;"}\n#{<<~"end;"}", min_calls: 1)
- begin;
- def a; end; a
- exec "true"
- end;
- error_message = "Undeleted files:\n #{Dir.glob("#{dir}/*").join("\n ")}\n"
- assert_send([Dir, :empty?, dir], error_message)
- end
- end
-
- def test_lambda_longjmp
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '5', success_count: 1)
- begin;
- fib = lambda do |x|
- return x if x == 0 || x == 1
- fib.call(x-1) + fib.call(x-2)
- end
- print fib.call(5)
- end;
- end
-
- def test_stack_pointer_with_assignment
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "nil\nnil\n", success_count: 1)
- begin;
- 2.times do
- a, _ = nil
- p a
- end
- end;
- end
-
- def test_frame_omitted_inlining
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "true\ntrue\ntrue\n", success_count: 1, min_calls: 2)
- begin;
- class Numeric
- remove_method :zero?
- def zero?
- self == 0
- end
- end
-
- 3.times do
- p 0.zero?
- end
- end;
- end
-
- def test_block_handler_with_possible_frame_omitted_inlining
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "70.0\n70.0\n70.0\n", success_count: 2, min_calls: 2)
- begin;
- def multiply(a, b)
- a *= b
- end
-
- 3.times do
- p multiply(7.0, 10.0)
- end
- end;
- end
-
- def test_program_counter_with_regexpmatch
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "aa", success_count: 1)
- begin;
- 2.times do
- break if /a/ =~ "ab" && !$~[0]
- print $~[0]
- end
- end;
- end
-
- def test_pushed_values_with_opt_aset_with
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "{}{}", success_count: 1)
- begin;
- 2.times do
- print(Thread.current["a"] = {})
- end
- end;
- end
-
- def test_pushed_values_with_opt_aref_with
- assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "nil\nnil\n", success_count: 1)
- begin;
- 2.times do
- p(Thread.current["a"])
- end
- end;
- end
-
- def test_caller_locations_without_catch_table
- out, _ = eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", min_calls: 1)
- begin;
- def b # 2
- caller_locations.first # 3
- end # 4
- # 5
- def a # 6
- print # <-- don't leave PC here # 7
- b # 8
- end
- puts a
- puts a
- end;
- lines = out.lines
- assert_equal("-e:8:in `a'\n", lines[0])
- assert_equal("-e:8:in `a'\n", lines[1])
- end
-
- def test_fork_with_mjit_worker_thread
- Dir.mktmpdir("jit_test_fork_with_mjit_worker_thread_") do |dir|
- # min_calls: 2 to skip fork block
- out, err = eval_with_jit({ "TMPDIR" => dir }, "#{<<~"begin;"}\n#{<<~"end;"}", min_calls: 2, verbose: 1)
- begin;
- def before_fork; end
- def after_fork; end
-
- before_fork; before_fork # the child should not delete this .o file
- pid = Process.fork do # this child should not delete shared .pch file
- sleep 2.0 # to prevent mixing outputs on Solaris
- after_fork; after_fork # this child does not share JIT-ed after_fork with parent
- end
- after_fork; after_fork # this parent does not share JIT-ed after_fork with child
-
- Process.waitpid(pid)
- end;
- success_count = err.scan(/^#{JIT_SUCCESS_PREFIX}:/).size
- debug_info = "stdout:\n```\n#{out}\n```\n\nstderr:\n```\n#{err}```\n"
- assert_equal(3, success_count, debug_info)
-
- # assert no remove error
- assert_equal("Successful MJIT finish\n" * 2, err.gsub(/^#{JIT_SUCCESS_PREFIX}:[^\n]+\n/, ''), debug_info)
-
- # ensure objects are deleted
- assert_send([Dir, :empty?, dir], debug_info)
- end
- end if defined?(fork)
-
- private
-
- # The shortest way to test one proc
- def assert_compile_once(script, result_inspect:, insns: [], uplevel: 1)
- if script.match?(/\A\n.+\n\z/m)
- script = script.gsub(/^/, ' ')
- else
- script = " #{script} "
- end
- assert_eval_with_jit("p proc {#{script}}.call", stdout: "#{result_inspect}\n", success_count: 1, insns: insns, uplevel: uplevel + 1)
- end
-
- # Shorthand for normal test cases
- def assert_eval_with_jit(script, stdout: nil, success_count:, min_calls: 1, max_cache: 1000, insns: [], uplevel: 1, ignorable_patterns: [])
- out, err = eval_with_jit(script, verbose: 1, min_calls: min_calls, max_cache: max_cache)
- actual = err.scan(/^#{JIT_SUCCESS_PREFIX}:/).size
- # Add --jit-verbose=2 logs for cl.exe because compiler's error message is suppressed
- # for cl.exe with --jit-verbose=1. See `start_process` in mjit_worker.c.
- if RUBY_PLATFORM.match?(/mswin/) && success_count != actual
- out2, err2 = eval_with_jit(script, verbose: 2, min_calls: min_calls, max_cache: max_cache)
- end
-
- # Make sure that the script has insns expected to be tested
- used_insns = method_insns(script)
- insns.each do |insn|
- mark_tested_insn(insn, used_insns: used_insns, uplevel: uplevel + 3)
- end
-
- assert_equal(
- success_count, actual,
- "Expected #{success_count} times of JIT success, but succeeded #{actual} times.\n\n"\
- "script:\n#{code_block(script)}\nstderr:\n#{code_block(err)}#{(
- "\nstdout(verbose=2 retry):\n#{code_block(out2)}\nstderr(verbose=2 retry):\n#{code_block(err2)}" if out2 || err2
- )}",
- )
- if stdout
- assert_equal(stdout, out, "Expected stdout #{out.inspect} to match #{stdout.inspect} with script:\n#{code_block(script)}")
- end
- err_lines = err.lines.reject! do |l|
- l.chomp.empty? || l.match?(/\A#{JIT_SUCCESS_PREFIX}/) || (IGNORABLE_PATTERNS + ignorable_patterns).any? { |pat| pat.match?(l) }
- end
- unless err_lines.empty?
- warn err_lines.join(''), uplevel: uplevel
- end
- end
-
- def mark_tested_insn(insn, used_insns:, uplevel: 1)
- unless used_insns.include?(insn)
- $stderr.puts
- warn "'#{insn}' insn is not included in the script. Actual insns are: #{used_insns.join(' ')}\n", uplevel: uplevel
- end
- TestJIT.untested_insns.delete(insn)
- end
-
- # Collect block's insns or defined method's insns, which are expected to be JIT-ed.
- # Note that this intentionally excludes insns in script's toplevel because they are not JIT-ed.
- def method_insns(script)
- insns = []
- RubyVM::InstructionSequence.compile(script).to_a.last.each do |(insn, *args)|
- case insn
- when :send
- insns += collect_insns(args.last)
- when :definemethod, :definesmethod
- insns += collect_insns(args[1])
- when :defineclass
- insns += collect_insns(args[1])
- end
- end
- insns.uniq
- end
-
- # Recursively collect insns in iseq_array
- def collect_insns(iseq_array)
- return [] if iseq_array.nil?
-
- insns = iseq_array.last.select { |x| x.is_a?(Array) }.map(&:first)
- iseq_array.last.each do |(insn, *args)|
- case insn
- when :definemethod, :definesmethod, :send
- insns += collect_insns(args.last)
- end
- end
- insns
- end
-end
diff --git a/test/ruby/test_key_error.rb b/test/ruby/test_key_error.rb
deleted file mode 100644
index fe1d5bb5ab..0000000000
--- a/test/ruby/test_key_error.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'test/unit'
-
-class TestKeyError < Test::Unit::TestCase
- def test_default
- error = KeyError.new
- assert_equal("KeyError", error.message)
- end
-
- def test_message
- error = KeyError.new("Message")
- assert_equal("Message", error.message)
- end
-
- def test_receiver
- receiver = Object.new
- error = KeyError.new(receiver: receiver)
- assert_equal(receiver, error.receiver)
- error = KeyError.new
- assert_raise(ArgumentError) {error.receiver}
- end
-
- def test_key
- error = KeyError.new(key: :key)
- assert_equal(:key, error.key)
- error = KeyError.new
- assert_raise(ArgumentError) {error.key}
- end
-
- def test_receiver_and_key
- receiver = Object.new
- error = KeyError.new(receiver: receiver, key: :key)
- assert_equal([receiver, :key],
- [error.receiver, error.key])
- end
-
- def test_all
- receiver = Object.new
- error = KeyError.new("Message", receiver: receiver, key: :key)
- assert_equal(["Message", receiver, :key],
- [error.message, error.receiver, error.key])
- end
-end
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index ab3c11e149..8a45016c13 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: false
require 'test/unit'
-require '-test-/rb_call_super_kw'
-require '-test-/iter'
class TestKeywordArguments < Test::Unit::TestCase
def f1(str: "foo", num: 424242)
@@ -24,9 +22,7 @@ class TestKeywordArguments < Test::Unit::TestCase
def test_f2
assert_equal([:xyz, "foo", 424242], f2(:xyz))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `f2'/m) do
- assert_equal([{"bar"=>42}, "foo", 424242], f2("bar"=>42))
- end
+ assert_equal([{"bar"=>42}, "foo", 424242], f2("bar"=>42))
end
@@ -130,47 +126,6 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal(1, f10(b: 42))
end
- def f11(**nil)
- local_variables
- end
-
- def test_f11
- h = {}
-
- assert_equal([], f11)
- assert_equal([], f11(**{}))
- assert_equal([], f11(**h))
- end
-
- def f12(**nil, &b)
- [b, local_variables]
- end
-
- def test_f12
- h = {}
- b = proc{}
-
- assert_equal([nil, [:b]], f12)
- assert_equal([nil, [:b]], f12(**{}))
- assert_equal([nil, [:b]], f12(**h))
- assert_equal([b, [:b]], f12(&b))
- assert_equal([b, [:b]], f12(**{}, &b))
- assert_equal([b, [:b]], f12(**h, &b))
- end
-
- def f13(a, **nil)
- a
- end
-
- def test_f13
- assert_equal(1, f13(1))
- assert_equal(1, f13(1, **{}))
- assert_raise(ArgumentError) { f13(a: 1) }
- assert_raise(ArgumentError) { f13(1, a: 1) }
- assert_raise(ArgumentError) { f13(**{a: 1}) }
- assert_raise(ArgumentError) { f13(1, **{a: 1}) }
- end
-
def test_method_parameters
assert_equal([[:key, :str], [:key, :num]], method(:f1).parameters);
assert_equal([[:req, :x], [:key, :str], [:key, :num]], method(:f2).parameters);
@@ -192,3806 +147,6 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal(["bar", 111111], f[str: "bar", num: 111111])
end
- def test_regular_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- assert_equal([], c.m(**{}))
- assert_equal([], c.m(**kw))
- assert_equal([h], c.m(**h))
- assert_equal([h], c.m(a: 1))
- assert_equal([h2], c.m(**h2))
- assert_equal([h3], c.m(**h3))
- assert_equal([h3], c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.m(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.m(**kw))
- end
- assert_equal(kw, c.m(kw, **kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, c.m(**{}))
- assert_equal(kw, c.m(**kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, c.m(h))
- end
- assert_raise(ArgumentError) { c.m(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { c.m(h3) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.m(**{})
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.m(**kw)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.m(**h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.m(a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], c.m(**h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.m(**h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.m(a: 1, **h2))
- end
- assert_equal([h, kw], c.m(h))
- assert_equal([h2, kw], c.m(h2))
- assert_equal([h3, kw], c.m(h3))
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.m(**{}))
- assert_equal([1, kw], c.m(**kw))
- assert_equal([1, h], c.m(**h))
- assert_equal([1, h], c.m(a: 1))
- assert_equal([1, h2], c.m(**h2))
- assert_equal([1, h3], c.m(**h3))
- assert_equal([1, h3], c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal([1, h], c.m(h))
- end
- assert_equal([h2, kw], c.m(h2))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal([h2, h], c.m(h3))
- end
- end
-
- def test_implicit_super_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- sc = Class.new
- c = sc.new
- redef = -> do
- if defined?(c.m)
- class << c
- remove_method(:m)
- end
- end
- eval <<-END
- def c.m(*args, **kw)
- super(*args, **kw)
- end
- END
- end
- redef[]
- sc.class_eval do
- def m(*args)
- args
- end
- end
- assert_equal([], c.m(**{}))
- assert_equal([], c.m(**kw))
- assert_equal([h], c.m(**h))
- assert_equal([h], c.m(a: 1))
- assert_equal([h2], c.m(**h2))
- assert_equal([h3], c.m(**h3))
- assert_equal([h3], c.m(a: 1, **h2))
-
- sc.class_eval do
- remove_method(:m)
- def m; end
- end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
-
- sc.class_eval do
- remove_method(:m)
- def m(args)
- args
- end
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.m(**{}))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.m(**kw))
- end
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
-
- sc.class_eval do
- remove_method(:m)
- def m(**args)
- args
- end
- end
- assert_equal(kw, c.m(**{}))
- assert_equal(kw, c.m(**kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, c.m(h))
- end
- assert_raise(ArgumentError) { c.m(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { c.m(h3) }
- end
-
- sc.class_eval do
- remove_method(:m)
- def m(arg, **args)
- [arg, args]
- end
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.m(**{})
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.m(**kw)
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.m(**h))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.m(a: 1))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], c.m(**h2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.m(**h3))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.m(a: 1, **h2))
- end
-
- sc.class_eval do
- remove_method(:m)
- def m(arg=1, **args)
- [arg, args]
- end
- end
- assert_equal([1, kw], c.m(**{}))
- assert_equal([1, kw], c.m(**kw))
- assert_equal([1, h], c.m(**h))
- assert_equal([1, h], c.m(a: 1))
- assert_equal([1, h2], c.m(**h2))
- assert_equal([1, h3], c.m(**h3))
- assert_equal([1, h3], c.m(a: 1, **h2))
- end
-
- def test_explicit_super_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- sc = Class.new
- c = sc.new
- redef = -> do
- if defined?(c.m)
- class << c
- remove_method(:m)
- end
- end
- eval <<-END
- def c.m(*args, **kw)
- super(*args, **kw)
- end
- END
- end
- redef[]
- sc.class_eval do
- def m(*args)
- args
- end
- end
- assert_equal([], c.m(**{}))
- assert_equal([], c.m(**kw))
- assert_equal([h], c.m(**h))
- assert_equal([h], c.m(a: 1))
- assert_equal([h2], c.m(**h2))
- assert_equal([h3], c.m(**h3))
- assert_equal([h3], c.m(a: 1, **h2))
-
- sc.class_eval do
- remove_method(:m)
- def m; end
- end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
-
- sc.class_eval do
- remove_method(:m)
- def m(args)
- args
- end
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.m(**{}))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.m(**kw))
- end
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
-
- sc.class_eval do
- remove_method(:m)
- def m(**args)
- args
- end
- end
- assert_equal(kw, c.m(**{}))
- assert_equal(kw, c.m(**kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, c.m(h))
- end
- assert_raise(ArgumentError) { c.m(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { c.m(h3) }
- end
-
- sc.class_eval do
- remove_method(:m)
- def m(arg, **args)
- [arg, args]
- end
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.m(**{})
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.m(**kw)
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.m(**h))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.m(a: 1))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], c.m(**h2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.m(**h3))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.m(a: 1, **h2))
- end
-
- sc.class_eval do
- remove_method(:m)
- def m(arg=1, **args)
- [arg, args]
- end
- end
- assert_equal([1, kw], c.m(**{}))
- assert_equal([1, kw], c.m(**kw))
- assert_equal([1, h], c.m(**h))
- assert_equal([1, h], c.m(a: 1))
- assert_equal([1, h2], c.m(**h2))
- assert_equal([1, h3], c.m(**h3))
- assert_equal([1, h3], c.m(a: 1, **h2))
- end
-
- def test_lambda_kwsplat_call
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- f = -> { true }
- assert_equal(true, f[**{}])
- assert_equal(true, f[**kw])
- assert_raise(ArgumentError) { f[**h] }
- assert_raise(ArgumentError) { f[a: 1] }
- assert_raise(ArgumentError) { f[**h2] }
- assert_raise(ArgumentError) { f[**h3] }
-
- f = ->(a) { a }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, f[**{}])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, f[**kw])
- end
- assert_equal(h, f[**h])
- assert_equal(h, f[a: 1])
- assert_equal(h2, f[**h2])
- assert_equal(h3, f[**h3])
- assert_equal(h3, f[a: 1, **h2])
-
- f = ->(**x) { x }
- assert_equal(kw, f[**{}])
- assert_equal(kw, f[**kw])
- assert_equal(h, f[**h])
- assert_equal(h, f[a: 1])
- assert_equal(h2, f[**h2])
- assert_equal(h3, f[**h3])
- assert_equal(h3, f[a: 1, **h2])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `\[\]'/m) do
- assert_equal(h, f[h])
- end
- assert_raise(ArgumentError) { f[h2] }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `\[\]'/m) do
- assert_raise(ArgumentError) { f[h3] }
- end
-
- f = ->(a, **x) { [a,x] }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do
- assert_equal([{}, {}], f[**{}])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do
- assert_equal([{}, {}], f[**kw])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do
- assert_equal([h, {}], f[**h])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do
- assert_equal([h, {}], f[a: 1])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do
- assert_equal([h2, {}], f[**h2])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do
- assert_equal([h3, {}], f[**h3])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `\[\]'/m) do
- assert_equal([h3, {}], f[a: 1, **h2])
- end
-
- f = ->(a=1, **x) { [a, x] }
- assert_equal([1, kw], f[**{}])
- assert_equal([1, kw], f[**kw])
- assert_equal([1, h], f[**h])
- assert_equal([1, h], f[a: 1])
- assert_equal([1, h2], f[**h2])
- assert_equal([1, h3], f[**h3])
- assert_equal([1, h3], f[a: 1, **h2])
- end
-
- def test_lambda_method_kwsplat_call
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- f = -> { true }
- f = f.method(:call)
- assert_equal(true, f[**{}])
- assert_equal(true, f[**kw])
- assert_raise(ArgumentError) { f[**h] }
- assert_raise(ArgumentError) { f[a: 1] }
- assert_raise(ArgumentError) { f[**h2] }
- assert_raise(ArgumentError) { f[**h3] }
-
- f = ->(a) { a }
- f = f.method(:call)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, f[**{}])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, f[**kw])
- end
- assert_equal(h, f[**h])
- assert_equal(h, f[a: 1])
- assert_equal(h2, f[**h2])
- assert_equal(h3, f[**h3])
- assert_equal(h3, f[a: 1, **h2])
-
- f = ->(**x) { x }
- f = f.method(:call)
- assert_equal(kw, f[**{}])
- assert_equal(kw, f[**kw])
- assert_equal(h, f[**h])
- assert_equal(h, f[a: 1])
- assert_equal(h2, f[**h2])
- assert_equal(h3, f[**h3])
- assert_equal(h3, f[a: 1, **h2])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(h, f[h])
- end
- assert_raise(ArgumentError) { f[h2] }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_raise(ArgumentError) { f[h3] }
- end
-
- f = ->(a, **x) { [a,x] }
- f = f.method(:call)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], f[**{}])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], f[**kw])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], f[**h])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], f[a: 1])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, {}], f[**h2])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], f[**h3])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], f[a: 1, **h2])
- end
-
- f = ->(a=1, **x) { [a, x] }
- f = f.method(:call)
- assert_equal([1, kw], f[**{}])
- assert_equal([1, kw], f[**kw])
- assert_equal([1, h], f[**h])
- assert_equal([1, h], f[a: 1])
- assert_equal([1, h2], f[**h2])
- assert_equal([1, h3], f[**h3])
- assert_equal([1, h3], f[a: 1, **h2])
- end
-
- def test_Thread_new_kwsplat
- Thread.report_on_exception = false
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- t = Thread
- f = -> { true }
- assert_equal(true, t.new(**{}, &f).value)
- assert_equal(true, t.new(**kw, &f).value)
- assert_raise(ArgumentError) { t.new(**h, &f).value }
- assert_raise(ArgumentError) { t.new(a: 1, &f).value }
- assert_raise(ArgumentError) { t.new(**h2, &f).value }
- assert_raise(ArgumentError) { t.new(**h3, &f).value }
-
- f = ->(a) { a }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, t.new(**{}, &f).value)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, t.new(**kw, &f).value)
- end
- assert_equal(h, t.new(**h, &f).value)
- assert_equal(h, t.new(a: 1, &f).value)
- assert_equal(h2, t.new(**h2, &f).value)
- assert_equal(h3, t.new(**h3, &f).value)
- assert_equal(h3, t.new(a: 1, **h2, &f).value)
-
- f = ->(**x) { x }
- assert_equal(kw, t.new(**{}, &f).value)
- assert_equal(kw, t.new(**kw, &f).value)
- assert_equal(h, t.new(**h, &f).value)
- assert_equal(h, t.new(a: 1, &f).value)
- assert_equal(h2, t.new(**h2, &f).value)
- assert_equal(h3, t.new(**h3, &f).value)
- assert_equal(h3, t.new(a: 1, **h2, &f).value)
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(h, t.new(h, &f).value)
- end
- assert_raise(ArgumentError) { t.new(h2, &f).value }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_raise(ArgumentError) { t.new(h3, &f).value }
- end
-
- f = ->(a, **x) { [a,x] }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], t.new(**{}, &f).value)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], t.new(**kw, &f).value)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], t.new(**h, &f).value)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], t.new(a: 1, &f).value)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, {}], t.new(**h2, &f).value)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], t.new(**h3, &f).value)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], t.new(a: 1, **h2, &f).value)
- end
-
- f = ->(a=1, **x) { [a, x] }
- assert_equal([1, kw], t.new(**{}, &f).value)
- assert_equal([1, kw], t.new(**kw, &f).value)
- assert_equal([1, h], t.new(**h, &f).value)
- assert_equal([1, h], t.new(a: 1, &f).value)
- assert_equal([1, h2], t.new(**h2, &f).value)
- assert_equal([1, h3], t.new(**h3, &f).value)
- assert_equal([1, h3], t.new(a: 1, **h2, &f).value)
- ensure
- Thread.report_on_exception = true
- end
-
- def test_Fiber_resume_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- t = Fiber
- f = -> { true }
- assert_equal(true, t.new(&f).resume(**{}))
- assert_equal(true, t.new(&f).resume(**kw))
- assert_raise(ArgumentError) { t.new(&f).resume(**h) }
- assert_raise(ArgumentError) { t.new(&f).resume(a: 1) }
- assert_raise(ArgumentError) { t.new(&f).resume(**h2) }
- assert_raise(ArgumentError) { t.new(&f).resume(**h3) }
-
- f = ->(a) { a }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, t.new(&f).resume(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, t.new(&f).resume(**kw))
- end
- assert_equal(h, t.new(&f).resume(**h))
- assert_equal(h, t.new(&f).resume(a: 1))
- assert_equal(h2, t.new(&f).resume(**h2))
- assert_equal(h3, t.new(&f).resume(**h3))
- assert_equal(h3, t.new(&f).resume(a: 1, **h2))
-
- f = ->(**x) { x }
- assert_equal(kw, t.new(&f).resume(**{}))
- assert_equal(kw, t.new(&f).resume(**kw))
- assert_equal(h, t.new(&f).resume(**h))
- assert_equal(h, t.new(&f).resume(a: 1))
- assert_equal(h2, t.new(&f).resume(**h2))
- assert_equal(h3, t.new(&f).resume(**h3))
- assert_equal(h3, t.new(&f).resume(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(h, t.new(&f).resume(h))
- end
- assert_raise(ArgumentError) { t.new(&f).resume(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_raise(ArgumentError) { t.new(&f).resume(h3) }
- end
-
- f = ->(a, **x) { [a,x] }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], t.new(&f).resume(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], t.new(&f).resume(**kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], t.new(&f).resume(**h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], t.new(&f).resume(a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, {}], t.new(&f).resume(**h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], t.new(&f).resume(**h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], t.new(&f).resume(a: 1, **h2))
- end
-
- f = ->(a=1, **x) { [a, x] }
- assert_equal([1, kw], t.new(&f).resume(**{}))
- assert_equal([1, kw], t.new(&f).resume(**kw))
- assert_equal([1, h], t.new(&f).resume(**h))
- assert_equal([1, h], t.new(&f).resume(a: 1))
- assert_equal([1, h2], t.new(&f).resume(**h2))
- assert_equal([1, h3], t.new(&f).resume(**h3))
- assert_equal([1, h3], t.new(&f).resume(a: 1, **h2))
- end
-
- def test_Enumerator_Generator_each_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- g = Enumerator::Generator
- f = ->(_) { true }
- assert_equal(true, g.new(&f).each(**{}))
- assert_equal(true, g.new(&f).each(**kw))
- assert_raise(ArgumentError) { g.new(&f).each(**h) }
- assert_raise(ArgumentError) { g.new(&f).each(a: 1) }
- assert_raise(ArgumentError) { g.new(&f).each(**h2) }
- assert_raise(ArgumentError) { g.new(&f).each(**h3) }
-
- f = ->(_, a) { a }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, g.new(&f).each(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, g.new(&f).each(**kw))
- end
- assert_equal(h, g.new(&f).each(**h))
- assert_equal(h, g.new(&f).each(a: 1))
- assert_equal(h2, g.new(&f).each(**h2))
- assert_equal(h3, g.new(&f).each(**h3))
- assert_equal(h3, g.new(&f).each(a: 1, **h2))
-
- f = ->(_, **x) { x }
- assert_equal(kw, g.new(&f).each(**{}))
- assert_equal(kw, g.new(&f).each(**kw))
- assert_equal(h, g.new(&f).each(**h))
- assert_equal(h, g.new(&f).each(a: 1))
- assert_equal(h2, g.new(&f).each(**h2))
- assert_equal(h3, g.new(&f).each(**h3))
- assert_equal(h3, g.new(&f).each(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(h, g.new(&f).each(h))
- end
- assert_raise(ArgumentError) { g.new(&f).each(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_raise(ArgumentError) { g.new(&f).each(h3) }
- end
-
- f = ->(_, a, **x) { [a,x] }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], g.new(&f).each(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], g.new(&f).each(**kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], g.new(&f).each(**h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], g.new(&f).each(a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, {}], g.new(&f).each(**h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], g.new(&f).each(**h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], g.new(&f).each(a: 1, **h2))
- end
-
- f = ->(_, a=1, **x) { [a, x] }
- assert_equal([1, kw], g.new(&f).each(**{}))
- assert_equal([1, kw], g.new(&f).each(**kw))
- assert_equal([1, h], g.new(&f).each(**h))
- assert_equal([1, h], g.new(&f).each(a: 1))
- assert_equal([1, h2], g.new(&f).each(**h2))
- assert_equal([1, h3], g.new(&f).each(**h3))
- assert_equal([1, h3], g.new(&f).each(a: 1, **h2))
- end
-
- def test_Enumerator_Yielder_yield_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- g = Enumerator::Generator
- f = -> { true }
- assert_equal(true, g.new{|y| y.yield(**{})}.each(&f))
- assert_equal(true, g.new{|y| y.yield(**kw)}.each(&f))
- assert_raise(ArgumentError) { g.new{|y| y.yield(**h)}.each(&f) }
- assert_raise(ArgumentError) { g.new{|y| y.yield(a: 1)}.each(&f) }
- assert_raise(ArgumentError) { g.new{|y| y.yield(**h2)}.each(&f) }
- assert_raise(ArgumentError) { g.new{|y| y.yield(**h3)}.each(&f) }
-
- f = ->(a) { a }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, g.new{|y| y.yield(**{})}.each(&f))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, g.new{|y| y.yield(**kw)}.each(&f))
- end
- assert_equal(h, g.new{|y| y.yield(**h)}.each(&f))
- assert_equal(h, g.new{|y| y.yield(a: 1)}.each(&f))
- assert_equal(h2, g.new{|y| y.yield(**h2)}.each(&f))
- assert_equal(h3, g.new{|y| y.yield(**h3)}.each(&f))
- assert_equal(h3, g.new{|y| y.yield(a: 1, **h2)}.each(&f))
-
- f = ->(**x) { x }
- assert_equal(kw, g.new{|y| y.yield(**{})}.each(&f))
- assert_equal(kw, g.new{|y| y.yield(**kw)}.each(&f))
- assert_equal(h, g.new{|y| y.yield(**h)}.each(&f))
- assert_equal(h, g.new{|y| y.yield(a: 1)}.each(&f))
- assert_equal(h2, g.new{|y| y.yield(**h2)}.each(&f))
- assert_equal(h3, g.new{|y| y.yield(**h3)}.each(&f))
- assert_equal(h3, g.new{|y| y.yield(a: 1, **h2)}.each(&f))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(h, g.new{|y| y.yield(h)}.each(&f))
- end
- assert_raise(ArgumentError) { g.new{|y| y.yield(h2)}.each(&f) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_raise(ArgumentError) { g.new{|y| y.yield(h3)}.each(&f) }
- end
-
- f = ->(a, **x) { [a,x] }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], g.new{|y| y.yield(**{})}.each(&f))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([{}, {}], g.new{|y| y.yield(**kw)}.each(&f))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], g.new{|y| y.yield(**h)}.each(&f))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, {}], g.new{|y| y.yield(a: 1)}.each(&f))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, {}], g.new{|y| y.yield(**h2)}.each(&f))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], g.new{|y| y.yield(**h3)}.each(&f))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, {}], g.new{|y| y.yield(a: 1, **h2)}.each(&f))
- end
-
- f = ->(a=1, **x) { [a, x] }
- assert_equal([1, kw], g.new{|y| y.yield(**{})}.each(&f))
- assert_equal([1, kw], g.new{|y| y.yield(**kw)}.each(&f))
- assert_equal([1, h], g.new{|y| y.yield(**h)}.each(&f))
- assert_equal([1, h], g.new{|y| y.yield(a: 1)}.each(&f))
- assert_equal([1, h2], g.new{|y| y.yield(**h2)}.each(&f))
- assert_equal([1, h3], g.new{|y| y.yield(**h3)}.each(&f))
- assert_equal([1, h3], g.new{|y| y.yield(a: 1, **h2)}.each(&f))
- end
-
- def test_Class_new_kwsplat_call
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- sc = Class.new do
- attr_reader :args
- class << self
- alias [] new
- end
- end
-
- c = Class.new(sc) do
- def initialize(*args)
- @args = args
- end
- end
- assert_equal([], c[**{}].args)
- assert_equal([], c[**kw].args)
- assert_equal([h], c[**h].args)
- assert_equal([h], c[a: 1].args)
- assert_equal([h2], c[**h2].args)
- assert_equal([h3], c[**h3].args)
- assert_equal([h3], c[a: 1, **h2].args)
-
- c = Class.new(sc) do
- def initialize; end
- end
- assert_nil(c[**{}].args)
- assert_nil(c[**kw].args)
- assert_raise(ArgumentError) { c[**h] }
- assert_raise(ArgumentError) { c[a: 1] }
- assert_raise(ArgumentError) { c[**h2] }
- assert_raise(ArgumentError) { c[**h3] }
- assert_raise(ArgumentError) { c[a: 1, **h2] }
-
- c = Class.new(sc) do
- def initialize(args)
- @args = args
- end
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal(kw, c[**{}].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal(kw, c[**kw].args)
- end
- assert_equal(h, c[**h].args)
- assert_equal(h, c[a: 1].args)
- assert_equal(h2, c[**h2].args)
- assert_equal(h3, c[**h3].args)
- assert_equal(h3, c[a: 1, **h2].args)
-
- c = Class.new(sc) do
- def initialize(**args)
- @args = args
- end
- end
- assert_equal(kw, c[**{}].args)
- assert_equal(kw, c[**kw].args)
- assert_equal(h, c[**h].args)
- assert_equal(h, c[a: 1].args)
- assert_equal(h2, c[**h2].args)
- assert_equal(h3, c[**h3].args)
- assert_equal(h3, c[a: 1, **h2].args)
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do
- assert_equal(h, c[h].args)
- end
- assert_raise(ArgumentError) { c[h2].args }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `initialize'/m) do
- assert_raise(ArgumentError) { c[h3].args }
- end
-
- c = Class.new(sc) do
- def initialize(arg, **args)
- @args = [arg, args]
- end
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([kw, kw], c[**{}].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([kw, kw], c[**kw].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h, kw], c[**h].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h, kw], c[a: 1].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h2, kw], c[**h2].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h3, kw], c[**h3].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h3, kw], c[a: 1, **h2].args)
- end
-
- c = Class.new(sc) do
- def initialize(arg=1, **args)
- @args = [arg, args]
- end
- end
- assert_equal([1, kw], c[**{}].args)
- assert_equal([1, kw], c[**kw].args)
- assert_equal([1, h], c[**h].args)
- assert_equal([1, h], c[a: 1].args)
- assert_equal([1, h2], c[**h2].args)
- assert_equal([1, h3], c[**h3].args)
- assert_equal([1, h3], c[a: 1, **h2].args)
- end
-
- def test_Class_new_method_kwsplat_call
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- sc = Class.new do
- attr_reader :args
- end
-
- c = Class.new(sc) do
- def initialize(*args)
- @args = args
- end
- end.method(:new)
- assert_equal([], c[**{}].args)
- assert_equal([], c[**kw].args)
- assert_equal([h], c[**h].args)
- assert_equal([h], c[a: 1].args)
- assert_equal([h2], c[**h2].args)
- assert_equal([h3], c[**h3].args)
- assert_equal([h3], c[a: 1, **h2].args)
-
- c = Class.new(sc) do
- def initialize; end
- end.method(:new)
- assert_nil(c[**{}].args)
- assert_nil(c[**kw].args)
- assert_raise(ArgumentError) { c[**h] }
- assert_raise(ArgumentError) { c[a: 1] }
- assert_raise(ArgumentError) { c[**h2] }
- assert_raise(ArgumentError) { c[**h3] }
- assert_raise(ArgumentError) { c[a: 1, **h2] }
-
- c = Class.new(sc) do
- def initialize(args)
- @args = args
- end
- end.method(:new)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal(kw, c[**{}].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal(kw, c[**kw].args)
- end
- assert_equal(h, c[**h].args)
- assert_equal(h, c[a: 1].args)
- assert_equal(h2, c[**h2].args)
- assert_equal(h3, c[**h3].args)
- assert_equal(h3, c[a: 1, **h2].args)
-
- c = Class.new(sc) do
- def initialize(**args)
- @args = args
- end
- end.method(:new)
- assert_equal(kw, c[**{}].args)
- assert_equal(kw, c[**kw].args)
- assert_equal(h, c[**h].args)
- assert_equal(h, c[a: 1].args)
- assert_equal(h2, c[**h2].args)
- assert_equal(h3, c[**h3].args)
- assert_equal(h3, c[a: 1, **h2].args)
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do
- assert_equal(h, c[h].args)
- end
- assert_raise(ArgumentError) { c[h2].args }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `initialize'/m) do
- assert_raise(ArgumentError) { c[h3].args }
- end
-
- c = Class.new(sc) do
- def initialize(arg, **args)
- @args = [arg, args]
- end
- end.method(:new)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([kw, kw], c[**{}].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([kw, kw], c[**kw].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h, kw], c[**h].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h, kw], c[a: 1].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h2, kw], c[**h2].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h3, kw], c[**h3].args)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `initialize'/m) do
- assert_equal([h3, kw], c[a: 1, **h2].args)
- end
-
- c = Class.new(sc) do
- def initialize(arg=1, **args)
- @args = [arg, args]
- end
- end.method(:new)
- assert_equal([1, kw], c[**{}].args)
- assert_equal([1, kw], c[**kw].args)
- assert_equal([1, h], c[**h].args)
- assert_equal([1, h], c[a: 1].args)
- assert_equal([1, h2], c[**h2].args)
- assert_equal([1, h3], c[**h3].args)
- assert_equal([1, h3], c[a: 1, **h2].args)
- end
-
- def test_Method_call_kwsplat_call
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- assert_equal([], c.method(:m)[**{}])
- assert_equal([], c.method(:m)[**kw])
- assert_equal([h], c.method(:m)[**h])
- assert_equal([h], c.method(:m)[a: 1])
- assert_equal([h2], c.method(:m)[**h2])
- assert_equal([h3], c.method(:m)[**h3])
- assert_equal([h3], c.method(:m)[a: 1, **h2])
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- assert_nil(c.method(:m)[**{}])
- assert_nil(c.method(:m)[**kw])
- assert_raise(ArgumentError) { c.method(:m)[**h] }
- assert_raise(ArgumentError) { c.method(:m)[a: 1] }
- assert_raise(ArgumentError) { c.method(:m)[**h2] }
- assert_raise(ArgumentError) { c.method(:m)[**h3] }
- assert_raise(ArgumentError) { c.method(:m)[a: 1, **h2] }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.method(:m)[**{}])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.method(:m)[**kw])
- end
- assert_equal(h, c.method(:m)[**h])
- assert_equal(h, c.method(:m)[a: 1])
- assert_equal(h2, c.method(:m)[**h2])
- assert_equal(h3, c.method(:m)[**h3])
- assert_equal(h3, c.method(:m)[a: 1, **h2])
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, c.method(:m)[**{}])
- assert_equal(kw, c.method(:m)[**kw])
- assert_equal(h, c.method(:m)[**h])
- assert_equal(h, c.method(:m)[a: 1])
- assert_equal(h2, c.method(:m)[**h2])
- assert_equal(h3, c.method(:m)[**h3])
- assert_equal(h3, c.method(:m)[a: 1, **h2])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, c.method(:m)[h])
- end
- assert_raise(ArgumentError) { c.method(:m)[h2] }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { c.method(:m)[h3] }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], c.method(:m)[**{}])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], c.method(:m)[**kw])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.method(:m)[**h])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.method(:m)[a: 1])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], c.method(:m)[**h2])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.method(:m)[**h3])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.method(:m)[a: 1, **h2])
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.method(:m)[**{}])
- assert_equal([1, kw], c.method(:m)[**kw])
- assert_equal([1, h], c.method(:m)[**h])
- assert_equal([1, h], c.method(:m)[a: 1])
- assert_equal([1, h2], c.method(:m)[**h2])
- assert_equal([1, h3], c.method(:m)[**h3])
- assert_equal([1, h3], c.method(:m)[a: 1, **h2])
- end
-
- def test_UnboundMethod_bindcall_kwsplat_call
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- sc = c.singleton_class
- def c.m(*args)
- args
- end
- assert_equal([], sc.instance_method(:m).bind_call(c, **{}))
- assert_equal([], sc.instance_method(:m).bind_call(c, **kw))
- assert_equal([h], sc.instance_method(:m).bind_call(c, **h))
- assert_equal([h], sc.instance_method(:m).bind_call(c, a: 1))
- assert_equal([h2], sc.instance_method(:m).bind_call(c, **h2))
- assert_equal([h3], sc.instance_method(:m).bind_call(c, **h3))
- assert_equal([h3], sc.instance_method(:m).bind_call(c, a: 1, **h2))
-
- sc.remove_method(:m)
- def c.m; end
- assert_nil(sc.instance_method(:m).bind_call(c, **{}))
- assert_nil(sc.instance_method(:m).bind_call(c, **kw))
- assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **h) }
- assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, a: 1) }
- assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **h2) }
- assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, **h3) }
- assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, a: 1, **h2) }
-
- sc.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, sc.instance_method(:m).bind_call(c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, sc.instance_method(:m).bind_call(c, **kw))
- end
- assert_equal(h, sc.instance_method(:m).bind_call(c, **h))
- assert_equal(h, sc.instance_method(:m).bind_call(c, a: 1))
- assert_equal(h2, sc.instance_method(:m).bind_call(c, **h2))
- assert_equal(h3, sc.instance_method(:m).bind_call(c, **h3))
- assert_equal(h3, sc.instance_method(:m).bind_call(c, a: 1, **h2))
-
- sc.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, sc.instance_method(:m).bind_call(c, **{}))
- assert_equal(kw, sc.instance_method(:m).bind_call(c, **kw))
- assert_equal(h, sc.instance_method(:m).bind_call(c, **h))
- assert_equal(h, sc.instance_method(:m).bind_call(c, a: 1))
- assert_equal(h2, sc.instance_method(:m).bind_call(c, **h2))
- assert_equal(h3, sc.instance_method(:m).bind_call(c, **h3))
- assert_equal(h3, sc.instance_method(:m).bind_call(c, a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, sc.instance_method(:m).bind_call(c, h))
- end
- assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { sc.instance_method(:m).bind_call(c, h3) }
- end
-
- sc.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], sc.instance_method(:m).bind_call(c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], sc.instance_method(:m).bind_call(c, **kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], sc.instance_method(:m).bind_call(c, **h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], sc.instance_method(:m).bind_call(c, a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], sc.instance_method(:m).bind_call(c, **h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], sc.instance_method(:m).bind_call(c, **h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], sc.instance_method(:m).bind_call(c, a: 1, **h2))
- end
-
- sc.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], sc.instance_method(:m).bind_call(c, **{}))
- assert_equal([1, kw], sc.instance_method(:m).bind_call(c, **kw))
- assert_equal([1, h], sc.instance_method(:m).bind_call(c, **h))
- assert_equal([1, h], sc.instance_method(:m).bind_call(c, a: 1))
- assert_equal([1, h2], sc.instance_method(:m).bind_call(c, **h2))
- assert_equal([1, h3], sc.instance_method(:m).bind_call(c, **h3))
- assert_equal([1, h3], sc.instance_method(:m).bind_call(c, a: 1, **h2))
- end
-
- def test_send_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- assert_equal([], c.send(:m, **{}))
- assert_equal([], c.send(:m, **kw))
- assert_equal([h], c.send(:m, **h))
- assert_equal([h], c.send(:m, a: 1))
- assert_equal([h2], c.send(:m, **h2))
- assert_equal([h3], c.send(:m, **h3))
- assert_equal([h3], c.send(:m, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- assert_nil(c.send(:m, **{}))
- assert_nil(c.send(:m, **kw))
- assert_raise(ArgumentError) { c.send(:m, **h) }
- assert_raise(ArgumentError) { c.send(:m, a: 1) }
- assert_raise(ArgumentError) { c.send(:m, **h2) }
- assert_raise(ArgumentError) { c.send(:m, **h3) }
- assert_raise(ArgumentError) { c.send(:m, a: 1, **h2) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.send(:m, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.send(:m, **kw))
- end
- assert_equal(h, c.send(:m, **h))
- assert_equal(h, c.send(:m, a: 1))
- assert_equal(h2, c.send(:m, **h2))
- assert_equal(h3, c.send(:m, **h3))
- assert_equal(h3, c.send(:m, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, c.send(:m, **{}))
- assert_equal(kw, c.send(:m, **kw))
- assert_equal(h, c.send(:m, **h))
- assert_equal(h, c.send(:m, a: 1))
- assert_equal(h2, c.send(:m, **h2))
- assert_equal(h3, c.send(:m, **h3))
- assert_equal(h3, c.send(:m, a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, c.send(:m, h))
- end
- assert_raise(ArgumentError) { c.send(:m, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { c.send(:m, h3) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.send(:m, **{})
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.send(:m, **kw)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.send(:m, **h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.send(:m, a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], c.send(:m, **h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.send(:m, **h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.send(:m, a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.send(:m, **{}))
- assert_equal([1, kw], c.send(:m, **kw))
- assert_equal([1, h], c.send(:m, **h))
- assert_equal([1, h], c.send(:m, a: 1))
- assert_equal([1, h2], c.send(:m, **h2))
- assert_equal([1, h3], c.send(:m, **h3))
- assert_equal([1, h3], c.send(:m, a: 1, **h2))
- end
-
- def test_public_send_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- assert_equal([], c.public_send(:m, **{}))
- assert_equal([], c.public_send(:m, **kw))
- assert_equal([h], c.public_send(:m, **h))
- assert_equal([h], c.public_send(:m, a: 1))
- assert_equal([h2], c.public_send(:m, **h2))
- assert_equal([h3], c.public_send(:m, **h3))
- assert_equal([h3], c.public_send(:m, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- assert_nil(c.public_send(:m, **{}))
- assert_nil(c.public_send(:m, **kw))
- assert_raise(ArgumentError) { c.public_send(:m, **h) }
- assert_raise(ArgumentError) { c.public_send(:m, a: 1) }
- assert_raise(ArgumentError) { c.public_send(:m, **h2) }
- assert_raise(ArgumentError) { c.public_send(:m, **h3) }
- assert_raise(ArgumentError) { c.public_send(:m, a: 1, **h2) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.public_send(:m, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.public_send(:m, **kw))
- end
- assert_equal(h, c.public_send(:m, **h))
- assert_equal(h, c.public_send(:m, a: 1))
- assert_equal(h2, c.public_send(:m, **h2))
- assert_equal(h3, c.public_send(:m, **h3))
- assert_equal(h3, c.public_send(:m, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, c.public_send(:m, **{}))
- assert_equal(kw, c.public_send(:m, **kw))
- assert_equal(h, c.public_send(:m, **h))
- assert_equal(h, c.public_send(:m, a: 1))
- assert_equal(h2, c.public_send(:m, **h2))
- assert_equal(h3, c.public_send(:m, **h3))
- assert_equal(h3, c.public_send(:m, a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, c.public_send(:m, h))
- end
- assert_raise(ArgumentError) { c.public_send(:m, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { c.public_send(:m, h3) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.public_send(:m, **{})
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- c.public_send(:m, **kw)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.public_send(:m, **h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.public_send(:m, a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], c.public_send(:m, **h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.public_send(:m, **h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.public_send(:m, a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.public_send(:m, **{}))
- assert_equal([1, kw], c.public_send(:m, **kw))
- assert_equal([1, h], c.public_send(:m, **h))
- assert_equal([1, h], c.public_send(:m, a: 1))
- assert_equal([1, h2], c.public_send(:m, **h2))
- assert_equal([1, h3], c.public_send(:m, **h3))
- assert_equal([1, h3], c.public_send(:m, a: 1, **h2))
- end
-
- def test_send_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- m = c.method(:send)
- assert_equal([], m.call(:m, **{}))
- assert_equal([], m.call(:m, **kw))
- assert_equal([h], m.call(:m, **h))
- assert_equal([h], m.call(:m, a: 1))
- assert_equal([h2], m.call(:m, **h2))
- assert_equal([h3], m.call(:m, **h3))
- assert_equal([h3], m.call(:m, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- m = c.method(:send)
- assert_nil(m.call(:m, **{}))
- assert_nil(m.call(:m, **kw))
- assert_raise(ArgumentError) { m.call(:m, **h) }
- assert_raise(ArgumentError) { m.call(:m, a: 1) }
- assert_raise(ArgumentError) { m.call(:m, **h2) }
- assert_raise(ArgumentError) { m.call(:m, **h3) }
- assert_raise(ArgumentError) { m.call(:m, a: 1, **h2) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- m = c.method(:send)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, m.call(:m, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, m.call(:m, **kw))
- end
- assert_equal(h, m.call(:m, **h))
- assert_equal(h, m.call(:m, a: 1))
- assert_equal(h2, m.call(:m, **h2))
- assert_equal(h3, m.call(:m, **h3))
- assert_equal(h3, m.call(:m, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- m = c.method(:send)
- assert_equal(kw, m.call(:m, **{}))
- assert_equal(kw, m.call(:m, **kw))
- assert_equal(h, m.call(:m, **h))
- assert_equal(h, m.call(:m, a: 1))
- assert_equal(h2, m.call(:m, **h2))
- assert_equal(h3, m.call(:m, **h3))
- assert_equal(h3, m.call(:m, a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, m.call(:m, h))
- end
- assert_raise(ArgumentError) { m.call(:m, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { m.call(:m, h3) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- m = c.method(:send)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- m.call(:m, **{})
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- m.call(:m, **kw)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], m.call(:m, **h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], m.call(:m, a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], m.call(:m, **h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], m.call(:m, **h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], m.call(:m, a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- m = c.method(:send)
- assert_equal([1, kw], m.call(:m, **{}))
- assert_equal([1, kw], m.call(:m, **kw))
- assert_equal([1, h], m.call(:m, **h))
- assert_equal([1, h], m.call(:m, a: 1))
- assert_equal([1, h2], m.call(:m, **h2))
- assert_equal([1, h3], m.call(:m, **h3))
- assert_equal([1, h3], m.call(:m, a: 1, **h2))
- end
-
- def test_sym_proc_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- assert_equal([], :m.to_proc.call(c, **{}))
- assert_equal([], :m.to_proc.call(c, **kw))
- assert_equal([h], :m.to_proc.call(c, **h))
- assert_equal([h], :m.to_proc.call(c, a: 1))
- assert_equal([h2], :m.to_proc.call(c, **h2))
- assert_equal([h3], :m.to_proc.call(c, **h3))
- assert_equal([h3], :m.to_proc.call(c, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- assert_nil(:m.to_proc.call(c, **{}))
- assert_nil(:m.to_proc.call(c, **kw))
- assert_raise(ArgumentError) { :m.to_proc.call(c, **h) }
- assert_raise(ArgumentError) { :m.to_proc.call(c, a: 1) }
- assert_raise(ArgumentError) { :m.to_proc.call(c, **h2) }
- assert_raise(ArgumentError) { :m.to_proc.call(c, **h3) }
- assert_raise(ArgumentError) { :m.to_proc.call(c, a: 1, **h2) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, :m.to_proc.call(c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, :m.to_proc.call(c, **kw))
- end
- assert_equal(h, :m.to_proc.call(c, **h))
- assert_equal(h, :m.to_proc.call(c, a: 1))
- assert_equal(h2, :m.to_proc.call(c, **h2))
- assert_equal(h3, :m.to_proc.call(c, **h3))
- assert_equal(h3, :m.to_proc.call(c, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, :m.to_proc.call(c, **{}))
- assert_equal(kw, :m.to_proc.call(c, **kw))
- assert_equal(h, :m.to_proc.call(c, **h))
- assert_equal(h, :m.to_proc.call(c, a: 1))
- assert_equal(h2, :m.to_proc.call(c, **h2))
- assert_equal(h3, :m.to_proc.call(c, **h3))
- assert_equal(h3, :m.to_proc.call(c, a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, :m.to_proc.call(c, h))
- end
- assert_raise(ArgumentError) { :m.to_proc.call(c, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { :m.to_proc.call(c, h3) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], :m.to_proc.call(c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], :m.to_proc.call(c, **kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], :m.to_proc.call(c, **h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], :m.to_proc.call(c, a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], :m.to_proc.call(c, **h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], :m.to_proc.call(c, **h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], :m.to_proc.call(c, a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], :m.to_proc.call(c, **{}))
- assert_equal([1, kw], :m.to_proc.call(c, **kw))
- assert_equal([1, h], :m.to_proc.call(c, **h))
- assert_equal([1, h], :m.to_proc.call(c, a: 1))
- assert_equal([1, h2], :m.to_proc.call(c, **h2))
- assert_equal([1, h3], :m.to_proc.call(c, **h3))
- assert_equal([1, h3], :m.to_proc.call(c, a: 1, **h2))
- end
-
- def test_sym_proc_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- m = :m.to_proc.method(:call)
- assert_equal([], m.call(c, **{}))
- assert_equal([], m.call(c, **kw))
- assert_equal([h], m.call(c, **h))
- assert_equal([h], m.call(c, a: 1))
- assert_equal([h2], m.call(c, **h2))
- assert_equal([h3], m.call(c, **h3))
- assert_equal([h3], m.call(c, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- assert_nil(m.call(c, **{}))
- assert_nil(m.call(c, **kw))
- assert_raise(ArgumentError) { m.call(c, **h) }
- assert_raise(ArgumentError) { m.call(c, a: 1) }
- assert_raise(ArgumentError) { m.call(c, **h2) }
- assert_raise(ArgumentError) { m.call(c, **h3) }
- assert_raise(ArgumentError) { m.call(c, a: 1, **h2) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, m.call(c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, m.call(c, **kw))
- end
- assert_equal(h, m.call(c, **h))
- assert_equal(h, m.call(c, a: 1))
- assert_equal(h2, m.call(c, **h2))
- assert_equal(h3, m.call(c, **h3))
- assert_equal(h3, m.call(c, a: 1, **h2))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, m.call(c, **{}))
- assert_equal(kw, m.call(c, **kw))
- assert_equal(h, m.call(c, **h))
- assert_equal(h, m.call(c, a: 1))
- assert_equal(h2, m.call(c, **h2))
- assert_equal(h3, m.call(c, **h3))
- assert_equal(h3, m.call(c, a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, m.call(c, h))
- end
- assert_raise(ArgumentError) { m.call(c, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { m.call(c, h3) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], m.call(c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], m.call(c, **kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], m.call(c, **h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], m.call(c, a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], m.call(c, **h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], m.call(c, **h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], m.call(c, a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], m.call(c, **{}))
- assert_equal([1, kw], m.call(c, **kw))
- assert_equal([1, h], m.call(c, **h))
- assert_equal([1, h], m.call(c, a: 1))
- assert_equal([1, h2], m.call(c, **h2))
- assert_equal([1, h3], m.call(c, **h3))
- assert_equal([1, h3], m.call(c, a: 1, **h2))
- end
-
- def test_method_missing_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.method_missing(_, *args)
- args
- end
- assert_equal([], c.m(**{}))
- assert_equal([], c.m(**kw))
- assert_equal([h], c.m(**h))
- assert_equal([h], c.m(a: 1))
- assert_equal([h2], c.m(**h2))
- assert_equal([h3], c.m(**h3))
- assert_equal([h3], c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_); end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.m(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.m(**kw))
- end
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, **args)
- args
- end
- assert_equal(kw, c.m(**{}))
- assert_equal(kw, c.m(**kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal(h, c.m(h))
- end
- assert_raise(ArgumentError) { c.m(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_raise(ArgumentError) { c.m(h3) }
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.m(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.m(**kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.m(**h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.m(a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, kw], c.m(**h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.m(**h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.m(a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.m(**{}))
- assert_equal([1, kw], c.m(**kw))
- assert_equal([1, h], c.m(**h))
- assert_equal([1, h], c.m(a: 1))
- assert_equal([1, h2], c.m(**h2))
- assert_equal([1, h3], c.m(**h3))
- assert_equal([1, h3], c.m(a: 1, **h2))
- end
-
- def test_super_method_missing_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Class.new do
- def m(*args, **kw)
- super
- end
- end.new
- def c.method_missing(_, *args)
- args
- end
- assert_equal([], c.m(**{}))
- assert_equal([], c.m(**kw))
- assert_equal([h], c.m(**h))
- assert_equal([h], c.m(a: 1))
- assert_equal([h2], c.m(**h2))
- assert_equal([h3], c.m(**h3))
- assert_equal([h3], c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_); end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
-
- redef = -> do
- c.singleton_class.remove_method(:method_missing)
- eval <<-END
- def c.method_missing(_, args)
- args
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.m(**{}))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.m(**kw))
- end
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, **args)
- args
- end
- assert_equal(kw, c.m(**{}))
- assert_equal(kw, c.m(**kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m'/m) do
- assert_equal(h, c.m(h))
- end
- assert_raise(ArgumentError) { c.m(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `m'/m) do
- assert_raise(ArgumentError) { c.m(h3) }
- end
-
- redef = -> do
- c.singleton_class.remove_method(:method_missing)
- eval <<-END
- def c.method_missing(_, arg, **args)
- [arg, args]
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.m(**{}))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.m(**kw))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.m(**h))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.m(a: 1))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, kw], c.m(**h2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.m(**h3))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.m(a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.m(**{}))
- assert_equal([1, kw], c.m(**kw))
- assert_equal([1, h], c.m(**h))
- assert_equal([1, h], c.m(a: 1))
- assert_equal([1, h2], c.m(**h2))
- assert_equal([1, h3], c.m(**h3))
- assert_equal([1, h3], c.m(a: 1, **h2))
- end
-
- def test_rb_call_super_kw_method_missing_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- c.extend Bug::RbCallSuperKw
- def c.method_missing(_, *args)
- args
- end
- assert_equal([], c.m(**{}))
- assert_equal([], c.m(**kw))
- assert_equal([h], c.m(**h))
- assert_equal([h], c.m(a: 1))
- assert_equal([h2], c.m(**h2))
- assert_equal([h3], c.m(**h3))
- assert_equal([h3], c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_); end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.m(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.m(**kw))
- end
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, **args)
- args
- end
- assert_equal(kw, c.m(**{}))
- assert_equal(kw, c.m(**kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal(h, c.m(h))
- end
- assert_raise(ArgumentError) { c.m(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_raise(ArgumentError) { c.m(h3) }
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.m(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.m(**kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.m(**h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.m(a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, kw], c.m(**h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.m(**h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.m(a: 1, **h2))
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.m(**{}))
- assert_equal([1, kw], c.m(**kw))
- assert_equal([1, h], c.m(**h))
- assert_equal([1, h], c.m(a: 1))
- assert_equal([1, h2], c.m(**h2))
- assert_equal([1, h3], c.m(**h3))
- assert_equal([1, h3], c.m(a: 1, **h2))
- end
-
- def test_define_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- class << c
- define_method(:m) { }
- end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
-
- c = Object.new
- class << c
- define_method(:m) {|arg| arg }
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, c.m(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, c.m(**kw))
- end
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
-
- c = Object.new
- class << c
- define_method(:m) {|*args| args }
- end
- assert_equal([], c.m(**{}))
- assert_equal([], c.m(**kw))
- assert_equal([h], c.m(**h))
- assert_equal([h], c.m(a: 1))
- assert_equal([h2], c.m(**h2))
- assert_equal([h3], c.m(**h3))
- assert_equal([h3], c.m(a: 1, **h2))
-
- c = Object.new
- class << c
- define_method(:m) {|**opt| opt}
- end
- assert_equal(kw, c.m(**{}))
- assert_equal(kw, c.m(**kw))
- assert_equal(h, c.m(**h))
- assert_equal(h, c.m(a: 1))
- assert_equal(h2, c.m(**h2))
- assert_equal(h3, c.m(**h3))
- assert_equal(h3, c.m(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal(h, c.m(h))
- end
- assert_raise(ArgumentError) { c.m(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do
- assert_raise(ArgumentError) { c.m(h3) }
- end
-
- c = Object.new
- class << c
- define_method(:m) {|arg, **opt| [arg, opt] }
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([kw, kw], c.m(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([kw, kw], c.m(**kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h, kw], c.m(**h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h, kw], c.m(a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h2, kw], c.m(**h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h3, kw], c.m(**h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h3, kw], c.m(a: 1, **h2))
- end
-
- c = Object.new
- class << c
- define_method(:m) {|arg=1, **opt| [arg, opt] }
- end
- assert_equal([1, kw], c.m(**{}))
- assert_equal([1, kw], c.m(**kw))
- assert_equal([1, h], c.m(**h))
- assert_equal([1, h], c.m(a: 1))
- assert_equal([1, h2], c.m(**h2))
- assert_equal([1, h3], c.m(**h3))
- assert_equal([1, h3], c.m(a: 1, **h2))
-
- c = Object.new
- class << c
- define_method(:m) {|*args, **opt| [args, opt] }
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[], h], c.m(h))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[h], h], c.m(h, h))
- end
-
- c = Object.new
- class << c
- define_method(:m) {|arg=nil, a: nil| [arg, a] }
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([h2, 1], c.m(h3))
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([h2, 1], c.m(**h3))
- end
- end
-
- def test_define_method_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- class << c
- define_method(:m) { }
- end
- m = c.method(:m)
- assert_nil(m.call(**{}))
- assert_nil(m.call(**kw))
- assert_raise(ArgumentError) { m.call(**h) }
- assert_raise(ArgumentError) { m.call(a: 1) }
- assert_raise(ArgumentError) { m.call(**h2) }
- assert_raise(ArgumentError) { m.call(**h3) }
- assert_raise(ArgumentError) { m.call(a: 1, **h2) }
-
- c = Object.new
- class << c
- define_method(:m) {|arg| arg }
- end
- m = c.method(:m)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, m.call(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, m.call(**kw))
- end
- assert_equal(h, m.call(**h))
- assert_equal(h, m.call(a: 1))
- assert_equal(h2, m.call(**h2))
- assert_equal(h3, m.call(**h3))
- assert_equal(h3, m.call(a: 1, **h2))
-
- c = Object.new
- class << c
- define_method(:m) {|*args| args }
- end
- m = c.method(:m)
- assert_equal([], m.call(**{}))
- assert_equal([], m.call(**kw))
- assert_equal([h], m.call(**h))
- assert_equal([h], m.call(a: 1))
- assert_equal([h2], m.call(**h2))
- assert_equal([h3], m.call(**h3))
- assert_equal([h3], m.call(a: 1, **h2))
-
- c = Object.new
- class << c
- define_method(:m) {|**opt| opt}
- end
- m = c.method(:m)
- assert_equal(kw, m.call(**{}))
- assert_equal(kw, m.call(**kw))
- assert_equal(h, m.call(**h))
- assert_equal(h, m.call(a: 1))
- assert_equal(h2, m.call(**h2))
- assert_equal(h3, m.call(**h3))
- assert_equal(h3, m.call(a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal(h, m.call(h))
- end
- assert_raise(ArgumentError) { m.call(h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do
- assert_raise(ArgumentError) { m.call(h3) }
- end
-
- c = Object.new
- class << c
- define_method(:m) {|arg, **opt| [arg, opt] }
- end
- m = c.method(:m)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([kw, kw], m.call(**{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([kw, kw], m.call(**kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h, kw], m.call(**h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h, kw], m.call(a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h2, kw], m.call(**h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h3, kw], m.call(**h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h3, kw], m.call(a: 1, **h2))
- end
-
- c = Object.new
- class << c
- define_method(:m) {|arg=1, **opt| [arg, opt] }
- end
- m = c.method(:m)
- assert_equal([1, kw], m.call(**{}))
- assert_equal([1, kw], m.call(**kw))
- assert_equal([1, h], m.call(**h))
- assert_equal([1, h], m.call(a: 1))
- assert_equal([1, h2], m.call(**h2))
- assert_equal([1, h3], m.call(**h3))
- assert_equal([1, h3], m.call(a: 1, **h2))
-
- c = Object.new
- class << c
- define_method(:m) {|*args, **opt| [args, opt] }
- end
- m = c.method(:m)
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[], h], m.call(h))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[h], h], m.call(h, h))
- end
-
- c = Object.new
- class << c
- define_method(:m) {|arg=nil, a: nil| [arg, a] }
- end
- m = c.method(:m)
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([h2, 1], m.call(h3))
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([h2, 1], m.call(**h3))
- end
- end
-
- def test_attr_reader_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- class << c
- attr_reader :m
- end
- assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
- assert_raise(ArgumentError) { c.m(**h) }
- assert_raise(ArgumentError) { c.m(a: 1) }
- assert_raise(ArgumentError) { c.m(**h2) }
- assert_raise(ArgumentError) { c.m(**h3) }
- assert_raise(ArgumentError) { c.m(a: 1, **h2) }
- end
-
- def test_attr_reader_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- class << c
- attr_reader :m
- end
- m = c.method(:m)
- assert_nil(m.call(**{}))
- assert_nil(m.call(**kw))
- assert_raise(ArgumentError) { m.call(**h) }
- assert_raise(ArgumentError) { m.call(a: 1) }
- assert_raise(ArgumentError) { m.call(**h2) }
- assert_raise(ArgumentError) { m.call(**h3) }
- assert_raise(ArgumentError) { m.call(a: 1, **h2) }
- end
-
- def test_attr_writer_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- class << c
- attr_writer :m
- end
- assert_warn(/Passing the keyword argument for `m=' as the last hash parameter is deprecated/) do
- c.send(:m=, **{})
- end
- assert_warn(/Passing the keyword argument for `m=' as the last hash parameter is deprecated/) do
- c.send(:m=, **kw)
- end
- assert_equal(h, c.send(:m=, **h))
- assert_equal(h, c.send(:m=, a: 1))
- assert_equal(h2, c.send(:m=, **h2))
- assert_equal(h3, c.send(:m=, **h3))
- assert_equal(h3, c.send(:m=, a: 1, **h2))
-
- assert_equal(42, c.send(:m=, 42, **{}))
- assert_equal(42, c.send(:m=, 42, **kw))
- assert_raise(ArgumentError) { c.send(:m=, 42, **h) }
- assert_raise(ArgumentError) { c.send(:m=, 42, a: 1) }
- assert_raise(ArgumentError) { c.send(:m=, 42, **h2) }
- assert_raise(ArgumentError) { c.send(:m=, 42, **h3) }
- assert_raise(ArgumentError) { c.send(:m=, 42, a: 1, **h2) }
- end
-
- def test_attr_writer_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- class << c
- attr_writer :m
- end
- m = c.method(:m=)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- m.call(**{})
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- m.call(**kw)
- end
- assert_equal(h, m.call(**h))
- assert_equal(h, m.call(a: 1))
- assert_equal(h2, m.call(**h2))
- assert_equal(h3, m.call(**h3))
- assert_equal(h3, m.call(a: 1, **h2))
-
- assert_equal(42, m.call(42, **{}))
- assert_equal(42, m.call(42, **kw))
- assert_raise(ArgumentError) { m.call(42, **h) }
- assert_raise(ArgumentError) { m.call(42, a: 1) }
- assert_raise(ArgumentError) { m.call(42, **h2) }
- assert_raise(ArgumentError) { m.call(42, **h3) }
- assert_raise(ArgumentError) { m.call(42, a: 1, **h2) }
- end
-
- def test_proc_ruby2_keywords
- h1 = {:a=>1}
- foo = ->(*args, &block){block.call(*args)}
- assert_same(foo, foo.ruby2_keywords)
-
- assert_equal([[1], h1], foo.call(1, :a=>1, &->(*args, **kw){[args, kw]}))
- assert_equal([1, h1], foo.call(1, :a=>1, &->(*args){args}))
- assert_warn(/Using the last argument as keyword parameters is deprecated/) do
- assert_equal([[1], h1], foo.call(1, {:a=>1}, &->(*args, **kw){[args, kw]}))
- end
- assert_equal([1, h1], foo.call(1, {:a=>1}, &->(*args){args}))
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h1, {}], foo.call(:a=>1, &->(arg, **kw){[arg, kw]}))
- end
- assert_equal(h1, foo.call(:a=>1, &->(arg){arg}))
-
- [->(){}, ->(arg){}, ->(*args, **kw){}, ->(*args, k: 1){}, ->(*args, k: ){}].each do |pr|
- assert_warn(/Skipping set of ruby2_keywords flag for proc \(proc accepts keywords or proc does not accept argument splat\)/) do
- pr.ruby2_keywords
- end
- end
-
- o = Object.new
- def o.foo(*args)
- yield(*args)
- end
- foo = o.method(:foo).to_proc
- assert_warn(/Skipping set of ruby2_keywords flag for proc \(proc created from method\)/) do
- foo.ruby2_keywords
- end
-
- foo = :foo.to_proc
- assert_warn(/Skipping set of ruby2_keywords flag for proc \(proc not defined in Ruby\)/) do
- foo.ruby2_keywords
- end
-
- assert_raise(FrozenError) { ->(*args){}.freeze.ruby2_keywords }
- end
-
- def test_ruby2_keywords
- c = Class.new do
- ruby2_keywords def foo(meth, *args)
- send(meth, *args)
- end
-
- ruby2_keywords(define_method(:bfoo) do |meth, *args|
- send(meth, *args)
- end)
-
- ruby2_keywords def foo_bar(*args)
- bar(*args)
- end
-
- ruby2_keywords def foo_baz(*args)
- baz(*args)
- end
-
- define_method(:block_splat) {|*args| }
- ruby2_keywords :block_splat, def foo_bar_after_bmethod(*args)
- bar(*args)
- end
-
- ruby2_keywords def foo_baz2(*args)
- baz(*args)
- baz(*args)
- end
-
- ruby2_keywords def foo_foo_bar(meth, *args)
- foo_bar(meth, *args)
- end
-
- ruby2_keywords def foo_foo_baz(meth, *args)
- foo_baz(meth, *args)
- end
-
- ruby2_keywords def foo_mod(meth, *args)
- args << 1
- send(meth, *args)
- end
-
- ruby2_keywords def foo_bar_mod(*args)
- args << 1
- bar(*args)
- end
-
- ruby2_keywords def foo_baz_mod(*args)
- args << 1
- baz(*args)
- end
-
- def pass_bar(*args)
- bar(*args)
- end
-
- def bar(*args, **kw)
- [args, kw]
- end
-
- def baz(*args)
- args
- end
-
- ruby2_keywords def foo_dbar(*args)
- dbar(*args)
- end
-
- ruby2_keywords def foo_dbaz(*args)
- dbaz(*args)
- end
-
- define_method(:dbar) do |*args, **kw|
- [args, kw]
- end
-
- define_method(:dbaz) do |*args|
- args
- end
-
- def pass_cfunc(*args)
- self.class.new(*args).init_args
- end
-
- ruby2_keywords def block(*args)
- ->(*args, **kw){[args, kw]}.(*args)
- end
-
- ruby2_keywords def cfunc(*args)
- self.class.new(*args).init_args
- end
-
- ruby2_keywords def store_foo(meth, *args)
- @stored_args = args
- use(meth)
- end
- def use(meth)
- send(meth, *@stored_args)
- end
-
- attr_reader :init_args
- def initialize(*args, **kw)
- @init_args = [args, kw]
- end
- end
-
- mmkw = Class.new do
- def method_missing(*args, **kw)
- [args, kw]
- end
- end
-
- mmnokw = Class.new do
- def method_missing(*args)
- args
- end
- end
-
- implicit_super = Class.new(c) do
- ruby2_keywords def bar(*args)
- super
- end
-
- ruby2_keywords def baz(*args)
- super
- end
- end
-
- explicit_super = Class.new(c) do
- ruby2_keywords def bar(*args)
- super(*args)
- end
-
- ruby2_keywords def baz(*args)
- super(*args)
- end
- end
-
- h1 = {a: 1}
- o = c.new
-
- assert_equal([1, h1], o.foo_baz2(1, :a=>1))
- assert_equal([1], o.foo_baz2(1, **{}))
- assert_equal([h1], o.foo_baz2(h1, **{}))
-
- assert_equal([[1], h1], o.foo(:bar, 1, :a=>1))
- assert_equal([1, h1], o.foo(:baz, 1, :a=>1))
- assert_equal([[1], h1], o.bfoo(:bar, 1, :a=>1))
- assert_equal([1, h1], o.bfoo(:baz, 1, :a=>1))
- assert_equal([[1], h1], o.store_foo(:bar, 1, :a=>1))
- assert_equal([1, h1], o.store_foo(:baz, 1, :a=>1))
- assert_equal([[1], h1], o.foo_bar(1, :a=>1))
- assert_equal([1, h1], o.foo_baz(1, :a=>1))
- assert_equal([[1], h1], o.foo(:foo, :bar, 1, :a=>1))
- assert_equal([1, h1], o.foo(:foo, :baz, 1, :a=>1))
- assert_equal([[1], h1], o.foo(:foo_bar, 1, :a=>1))
- assert_equal([1, h1], o.foo(:foo_baz, 1, :a=>1))
- assert_equal([[1], h1], o.foo_foo_bar(1, :a=>1))
- assert_equal([1, h1], o.foo_foo_baz(1, :a=>1))
- assert_equal([[1], h1], o.foo_bar_after_bmethod(1, :a=>1))
-
- assert_equal([[1], h1], o.foo(:bar, 1, **h1))
- assert_equal([1, h1], o.foo(:baz, 1, **h1))
- assert_equal([[1], h1], o.bfoo(:bar, 1, **h1))
- assert_equal([1, h1], o.bfoo(:baz, 1, **h1))
- assert_equal([[1], h1], o.store_foo(:bar, 1, **h1))
- assert_equal([1, h1], o.store_foo(:baz, 1, **h1))
- assert_equal([[1], h1], o.foo_bar(1, **h1))
- assert_equal([1, h1], o.foo_baz(1, **h1))
- assert_equal([[1], h1], o.foo(:foo, :bar, 1, **h1))
- assert_equal([1, h1], o.foo(:foo, :baz, 1, **h1))
- assert_equal([[1], h1], o.foo(:foo_bar, 1, **h1))
- assert_equal([1, h1], o.foo(:foo_baz, 1, **h1))
- assert_equal([[1], h1], o.foo_foo_bar(1, **h1))
- assert_equal([1, h1], o.foo_foo_baz(1, **h1))
- assert_equal([[1], h1], o.foo_bar_after_bmethod(1, **h1))
-
- assert_equal([[h1], {}], o.foo(:bar, h1, **{}))
- assert_equal([h1], o.foo(:baz, h1, **{}))
- assert_equal([[h1], {}], o.bfoo(:bar, h1, **{}))
- assert_equal([h1], o.bfoo(:baz, h1, **{}))
- assert_equal([[h1], {}], o.store_foo(:bar, h1, **{}))
- assert_equal([h1], o.store_foo(:baz, h1, **{}))
- assert_equal([[h1], {}], o.foo_bar(h1, **{}))
- assert_equal([h1], o.foo_baz(h1, **{}))
- assert_equal([[h1], {}], o.foo(:foo, :bar, h1, **{}))
- assert_equal([h1], o.foo(:foo, :baz, h1, **{}))
- assert_equal([[h1], {}], o.foo(:foo_bar, h1, **{}))
- assert_equal([h1], o.foo(:foo_baz, h1, **{}))
- assert_equal([[h1], {}], o.foo_foo_bar(h1, **{}))
- assert_equal([h1], o.foo_foo_baz(h1, **{}))
- assert_equal([[h1], {}], o.foo_bar_after_bmethod(h1, **{}))
-
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do
- assert_equal([[1], h1], o.foo(:bar, 1, h1))
- end
- assert_equal([1, h1], o.foo(:baz, 1, h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do
- assert_equal([[1], h1], o.bfoo(:bar, 1, h1))
- end
- assert_equal([1, h1], o.bfoo(:baz, 1, h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do
- assert_equal([[1], h1], o.store_foo(:bar, 1, h1))
- end
- assert_equal([1, h1], o.store_foo(:baz, 1, h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do
- assert_equal([[1], h1], o.foo_bar(1, h1))
- end
- assert_equal([1, h1], o.foo_baz(1, h1))
- assert_equal([[1], h1], o.foo_bar_after_bmethod(1, h1))
-
- assert_equal([[1, h1, 1], {}], o.foo_mod(:bar, 1, :a=>1))
- assert_equal([1, h1, 1], o.foo_mod(:baz, 1, :a=>1))
- assert_equal([[1, h1, 1], {}], o.foo_bar_mod(1, :a=>1))
- assert_equal([1, h1, 1], o.foo_baz_mod(1, :a=>1))
-
- assert_equal([[1, h1, 1], {}], o.foo_mod(:bar, 1, **h1))
- assert_equal([1, h1, 1], o.foo_mod(:baz, 1, **h1))
- assert_equal([[1, h1, 1], {}], o.foo_bar_mod(1, **h1))
- assert_equal([1, h1, 1], o.foo_baz_mod(1, **h1))
-
- assert_equal([[h1, {}, 1], {}], o.foo_mod(:bar, h1, **{}))
- assert_equal([h1, {}, 1], o.foo_mod(:baz, h1, **{}))
- assert_equal([[h1, {}, 1], {}], o.foo_bar_mod(h1, **{}))
- assert_equal([h1, {}, 1], o.foo_baz_mod(h1, **{}))
-
- assert_equal([[1, h1, 1], {}], o.foo_mod(:bar, 1, h1))
- assert_equal([1, h1, 1], o.foo_mod(:baz, 1, h1))
- assert_equal([[1, h1, 1], {}], o.foo_bar_mod(1, h1))
- assert_equal([1, h1, 1], o.foo_baz_mod(1, h1))
-
- assert_equal([[1], h1], o.foo(:dbar, 1, :a=>1))
- assert_equal([1, h1], o.foo(:dbaz, 1, :a=>1))
- assert_equal([[1], h1], o.bfoo(:dbar, 1, :a=>1))
- assert_equal([1, h1], o.bfoo(:dbaz, 1, :a=>1))
- assert_equal([[1], h1], o.store_foo(:dbar, 1, :a=>1))
- assert_equal([1, h1], o.store_foo(:dbaz, 1, :a=>1))
- assert_equal([[1], h1], o.foo_dbar(1, :a=>1))
- assert_equal([1, h1], o.foo_dbaz(1, :a=>1))
-
- assert_equal([[1], h1], o.foo(:dbar, 1, **h1))
- assert_equal([1, h1], o.foo(:dbaz, 1, **h1))
- assert_equal([[1], h1], o.bfoo(:dbar, 1, **h1))
- assert_equal([1, h1], o.bfoo(:dbaz, 1, **h1))
- assert_equal([[1], h1], o.store_foo(:dbar, 1, **h1))
- assert_equal([1, h1], o.store_foo(:dbaz, 1, **h1))
- assert_equal([[1], h1], o.foo_dbar(1, **h1))
- assert_equal([1, h1], o.foo_dbaz(1, **h1))
-
- assert_equal([[h1], {}], o.foo(:dbar, h1, **{}))
- assert_equal([h1], o.foo(:dbaz, h1, **{}))
- assert_equal([[h1], {}], o.bfoo(:dbar, h1, **{}))
- assert_equal([h1], o.bfoo(:dbaz, h1, **{}))
- assert_equal([[h1], {}], o.store_foo(:dbar, h1, **{}))
- assert_equal([h1], o.store_foo(:dbaz, h1, **{}))
- assert_equal([[h1], {}], o.foo_dbar(h1, **{}))
- assert_equal([h1], o.foo_dbaz(h1, **{}))
-
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[1], h1], o.foo(:dbar, 1, h1))
- end
- assert_equal([1, h1], o.foo(:dbaz, 1, h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[1], h1], o.bfoo(:dbar, 1, h1))
- end
- assert_equal([1, h1], o.bfoo(:dbaz, 1, h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[1], h1], o.store_foo(:dbar, 1, h1))
- end
- assert_equal([1, h1], o.store_foo(:dbaz, 1, h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal([[1], h1], o.foo_dbar(1, h1))
- end
- assert_equal([1, h1], o.foo_dbaz(1, h1))
-
- assert_equal([[1], h1], o.block(1, :a=>1))
- assert_equal([[1], h1], o.block(1, **h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal([[1], h1], o.block(1, h1))
- end
- assert_equal([[h1], {}], o.block(h1, **{}))
-
- assert_equal([[1], h1], o.cfunc(1, :a=>1))
- assert_equal([[1], h1], o.cfunc(1, **h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do
- assert_equal([[1], h1], o.cfunc(1, h1))
- end
- assert_equal([[h1], {}], o.cfunc(h1, **{}))
-
- o = mmkw.new
- assert_equal([[:b, 1], h1], o.b(1, :a=>1))
- assert_equal([[:b, 1], h1], o.b(1, **h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal([[:b, 1], h1], o.b(1, h1))
- end
- assert_equal([[:b, h1], {}], o.b(h1, **{}))
-
- o = mmnokw.new
- assert_equal([:b, 1, h1], o.b(1, :a=>1))
- assert_equal([:b, 1, h1], o.b(1, **h1))
- assert_equal([:b, 1, h1], o.b(1, h1))
- assert_equal([:b, h1], o.b(h1, **{}))
-
- o = implicit_super.new
- assert_equal([[1], h1], o.bar(1, :a=>1))
- assert_equal([[1], h1], o.bar(1, **h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do
- assert_equal([[1], h1], o.bar(1, h1))
- end
- assert_equal([[h1], {}], o.bar(h1, **{}))
-
- assert_equal([1, h1], o.baz(1, :a=>1))
- assert_equal([1, h1], o.baz(1, **h1))
- assert_equal([1, h1], o.baz(1, h1))
- assert_equal([h1], o.baz(h1, **{}))
-
- o = explicit_super.new
- assert_equal([[1], h1], o.bar(1, :a=>1))
- assert_equal([[1], h1], o.bar(1, **h1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do
- assert_equal([[1], h1], o.bar(1, h1))
- end
- assert_equal([[h1], {}], o.bar(h1, **{}))
-
- assert_equal([1, h1], o.baz(1, :a=>1))
- assert_equal([1, h1], o.baz(1, **h1))
- assert_equal([1, h1], o.baz(1, h1))
- assert_equal([h1], o.baz(h1, **{}))
-
- c.class_eval do
- remove_method(:bar)
- def bar(*args, **kw)
- [args, kw]
- end
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `bar'/m) do
- assert_equal([[1], h1], o.foo(:pass_bar, 1, :a=>1))
- end
-
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `initialize'/m) do
- assert_equal([[1], h1], o.foo(:pass_cfunc, 1, :a=>1))
- end
-
- assert_warn(/Skipping set of ruby2_keywords flag for bar \(method accepts keywords or method does not accept argument splat\)/) do
- assert_nil(c.send(:ruby2_keywords, :bar))
- end
-
- o = Object.new
- class << o
- alias bar p
- end
- assert_warn(/Skipping set of ruby2_keywords flag for bar \(method not defined in Ruby\)/) do
- assert_nil(o.singleton_class.send(:ruby2_keywords, :bar))
- end
- sc = Class.new(c)
- assert_warn(/Skipping set of ruby2_keywords flag for bar \(can only set in method defining module\)/) do
- sc.send(:ruby2_keywords, :bar)
- end
- m = Module.new
- assert_warn(/Skipping set of ruby2_keywords flag for system \(can only set in method defining module\)/) do
- m.send(:ruby2_keywords, :system)
- end
-
- assert_raise(NameError) { c.send(:ruby2_keywords, "a5e36ccec4f5080a1d5e63f8") }
- assert_raise(NameError) { c.send(:ruby2_keywords, :quux) }
-
- c.freeze
- assert_raise(FrozenError) { c.send(:ruby2_keywords, :baz) }
- end
-
- def test_top_ruby2_keywords
- assert_in_out_err([], <<-INPUT, ["[1, 2, 3]", "{:k=>1}"], [])
- def bar(*a, **kw)
- p a, kw
- end
- ruby2_keywords def foo(*a)
- bar(*a)
- end
- foo(1, 2, 3, k:1)
- INPUT
- end
-
- def test_dig_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.dig(*args)
- args
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_equal([h], [c].dig(0, **h))
- assert_equal([h], [c].dig(0, a: 1))
- assert_equal([h2], [c].dig(0, **h2))
- assert_equal([h3], [c].dig(0, **h3))
- assert_equal([h3], [c].dig(0, a: 1, **h2))
-
- c.singleton_class.remove_method(:dig)
- def c.dig; end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_raise(ArgumentError) { [c].dig(0, **h) }
- assert_raise(ArgumentError) { [c].dig(0, a: 1) }
- assert_raise(ArgumentError) { [c].dig(0, **h2) }
- assert_raise(ArgumentError) { [c].dig(0, **h3) }
- assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) }
-
- c.singleton_class.remove_method(:dig)
- def c.dig(args)
- args
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_equal(kw, [c].dig(0, kw, **kw))
- assert_equal(h, [c].dig(0, **h))
- assert_equal(h, [c].dig(0, a: 1))
- assert_equal(h2, [c].dig(0, **h2))
- assert_equal(h3, [c].dig(0, **h3))
- assert_equal(h3, [c].dig(0, a: 1, **h2))
-
- c.singleton_class.remove_method(:dig)
- def c.dig(**args)
- args
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal(h, [c].dig(0, **h))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal(h, [c].dig(0, a: 1))
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do
- assert_raise(ArgumentError) { [c].dig(0, **h3) }
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do
- assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) }
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal(h, [c].dig(0, h))
- end
- assert_raise(ArgumentError) { [c].dig(0, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do
- assert_raise(ArgumentError) { [c].dig(0, h3) }
- end
-
- c.singleton_class.remove_method(:dig)
- def c.dig(arg, **args)
- [arg, args]
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_equal([h, kw], [c].dig(0, **h))
- assert_equal([h, kw], [c].dig(0, a: 1))
- assert_equal([h2, kw], [c].dig(0, **h2))
- assert_equal([h3, kw], [c].dig(0, **h3))
- assert_equal([h3, kw], [c].dig(0, a: 1, **h2))
-
- c.singleton_class.remove_method(:dig)
- def c.dig(arg=1, **args)
- [arg, args]
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal([1, h], [c].dig(0, **h))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal([1, h], [c].dig(0, a: 1))
- end
- assert_equal([h2, kw], [c].dig(0, **h2))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal([h2, h], [c].dig(0, **h3))
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal([h2, h], [c].dig(0, a: 1, **h2))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal([1, h], [c].dig(0, h))
- end
- assert_equal([h2, kw], [c].dig(0, h2))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `dig'/m) do
- assert_equal([h2, h], [c].dig(0, h3))
- end
- assert_equal([h, kw], [c].dig(0, h, **{}))
- assert_equal([h2, kw], [c].dig(0, h2, **{}))
- assert_equal([h3, kw], [c].dig(0, h3, **{}))
- end
-
- def test_dig_method_missing_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.method_missing(_, *args)
- args
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_equal([h], [c].dig(0, **h))
- assert_equal([h], [c].dig(0, a: 1))
- assert_equal([h2], [c].dig(0, **h2))
- assert_equal([h3], [c].dig(0, **h3))
- assert_equal([h3], [c].dig(0, a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing; end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_raise(ArgumentError) { [c].dig(0, **h) }
- assert_raise(ArgumentError) { [c].dig(0, a: 1) }
- assert_raise(ArgumentError) { [c].dig(0, **h2) }
- assert_raise(ArgumentError) { [c].dig(0, **h3) }
- assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) }
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, args)
- args
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_equal(kw, [c].dig(0, kw, **kw))
- assert_equal(h, [c].dig(0, **h))
- assert_equal(h, [c].dig(0, a: 1))
- assert_equal(h2, [c].dig(0, **h2))
- assert_equal(h3, [c].dig(0, **h3))
- assert_equal(h3, [c].dig(0, a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, **args)
- args
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal(h, [c].dig(0, **h))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal(h, [c].dig(0, a: 1))
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_raise(ArgumentError) { [c].dig(0, **h3) }
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_raise(ArgumentError) { [c].dig(0, a: 1, **h2) }
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal(h, [c].dig(0, h))
- end
- assert_raise(ArgumentError) { [c].dig(0, h2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_raise(ArgumentError) { [c].dig(0, h3) }
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg, **args)
- [arg, args]
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_equal([h, kw], [c].dig(0, **h))
- assert_equal([h, kw], [c].dig(0, a: 1))
- assert_equal([h2, kw], [c].dig(0, **h2))
- assert_equal([h3, kw], [c].dig(0, **h3))
- assert_equal([h3, kw], [c].dig(0, a: 1, **h2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg=1, **args)
- [arg, args]
- end
- assert_equal(c, [c].dig(0, **{}))
- assert_equal(c, [c].dig(0, **kw))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal([1, h], [c].dig(0, **h))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal([1, h], [c].dig(0, a: 1))
- end
- assert_equal([h2, kw], [c].dig(0, **h2))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, h], [c].dig(0, **h3))
- end
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, h], [c].dig(0, a: 1, **h2))
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal([1, h], [c].dig(0, h))
- end
- assert_equal([h2, kw], [c].dig(0, h2))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, h], [c].dig(0, h3))
- end
- assert_equal([h, kw], [c].dig(0, h, **{}))
- assert_equal([h2, kw], [c].dig(0, h2, **{}))
- assert_equal([h3, kw], [c].dig(0, h3, **{}))
- end
-
- def test_enumerator_size_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- c.to_enum(:each){|*args| args}.size
- m = ->(*args){ args }
- assert_equal([], c.to_enum(:each, **{}, &m).size)
- assert_equal([], c.to_enum(:each, **kw, &m).size)
- assert_equal([h], c.to_enum(:each, **h, &m).size)
- assert_equal([h], c.to_enum(:each, a: 1, &m).size)
- assert_equal([h2], c.to_enum(:each, **h2, &m).size)
- assert_equal([h3], c.to_enum(:each, **h3, &m).size)
- assert_equal([h3], c.to_enum(:each, a: 1, **h2, &m).size)
-
- m = ->(){ }
- assert_nil(c.to_enum(:each, **{}, &m).size)
- assert_nil(c.to_enum(:each, **kw, &m).size)
- assert_raise(ArgumentError) { c.to_enum(:each, **h, &m).size }
- assert_raise(ArgumentError) { c.to_enum(:each, a: 1, &m).size }
- assert_raise(ArgumentError) { c.to_enum(:each, **h2, &m).size }
- assert_raise(ArgumentError) { c.to_enum(:each, **h3, &m).size }
- assert_raise(ArgumentError) { c.to_enum(:each, a: 1, **h2, &m).size }
-
- m = ->(args){ args }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, c.to_enum(:each, **{}, &m).size)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal(kw, c.to_enum(:each, **kw, &m).size)
- end
- assert_equal(kw, c.to_enum(:each, kw, **kw, &m).size)
- assert_equal(h, c.to_enum(:each, **h, &m).size)
- assert_equal(h, c.to_enum(:each, a: 1, &m).size)
- assert_equal(h2, c.to_enum(:each, **h2, &m).size)
- assert_equal(h3, c.to_enum(:each, **h3, &m).size)
- assert_equal(h3, c.to_enum(:each, a: 1, **h2, &m).size)
-
- m = ->(**args){ args }
- assert_equal(kw, c.to_enum(:each, **{}, &m).size)
- assert_equal(kw, c.to_enum(:each, **kw, &m).size)
- assert_equal(h, c.to_enum(:each, **h, &m).size)
- assert_equal(h, c.to_enum(:each, a: 1, &m).size)
- assert_equal(h2, c.to_enum(:each, **h2, &m).size)
- assert_equal(h3, c.to_enum(:each, **h3, &m).size)
- assert_equal(h3, c.to_enum(:each, a: 1, **h2, &m).size)
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal(h, c.to_enum(:each, h, &m).size)
- end
- assert_raise(ArgumentError) { c.to_enum(:each, h2, &m).size }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do
- assert_raise(ArgumentError) { c.to_enum(:each, h3, &m).size }
- end
-
- m = ->(arg, **args){ [arg, args] }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- c.to_enum(:each, **{}, &m).size
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- c.to_enum(:each, **kw, &m).size
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h, kw], c.to_enum(:each, **h, &m).size)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h, kw], c.to_enum(:each, a: 1, &m).size)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h2, kw], c.to_enum(:each, **h2, &m).size)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h3, kw], c.to_enum(:each, **h3, &m).size)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/m) do
- assert_equal([h3, kw], c.to_enum(:each, a: 1, **h2, &m).size)
- end
- assert_equal([h, kw], c.to_enum(:each, h, &m).size)
- assert_equal([h2, kw], c.to_enum(:each, h2, &m).size)
- assert_equal([h3, kw], c.to_enum(:each, h3, &m).size)
-
- m = ->(arg=1, **args){ [arg, args] }
- assert_equal([1, kw], c.to_enum(:each, **{}, &m).size)
- assert_equal([1, kw], c.to_enum(:each, **kw, &m).size)
- assert_equal([1, h], c.to_enum(:each, **h, &m).size)
- assert_equal([1, h], c.to_enum(:each, a: 1, &m).size)
- assert_equal([1, h2], c.to_enum(:each, **h2, &m).size)
- assert_equal([1, h3], c.to_enum(:each, **h3, &m).size)
- assert_equal([1, h3], c.to_enum(:each, a: 1, **h2, &m).size)
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal([1, h], c.to_enum(:each, h, &m).size)
- end
- assert_equal([h2, kw], c.to_enum(:each, h2, &m).size)
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do
- assert_equal([h2, h], c.to_enum(:each, h3, &m).size)
- end
- end
-
- def test_instance_exec_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- m = ->(*args) { args }
- assert_equal([], c.instance_exec(**{}, &m))
- assert_equal([], c.instance_exec(**kw, &m))
- assert_equal([h], c.instance_exec(**h, &m))
- assert_equal([h], c.instance_exec(a: 1, &m))
- assert_equal([h2], c.instance_exec(**h2, &m))
- assert_equal([h3], c.instance_exec(**h3, &m))
- assert_equal([h3], c.instance_exec(a: 1, **h2, &m))
-
- m = ->() { nil }
- assert_nil(c.instance_exec(**{}, &m))
- assert_nil(c.instance_exec(**kw, &m))
- assert_raise(ArgumentError) { c.instance_exec(**h, &m) }
- assert_raise(ArgumentError) { c.instance_exec(a: 1, &m) }
- assert_raise(ArgumentError) { c.instance_exec(**h2, &m) }
- assert_raise(ArgumentError) { c.instance_exec(**h3, &m) }
- assert_raise(ArgumentError) { c.instance_exec(a: 1, **h2, &m) }
-
- m = ->(args) { args }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(**{}, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(**kw, &m))
- end
- assert_equal(kw, c.instance_exec(kw, **kw, &m))
- assert_equal(h, c.instance_exec(**h, &m))
- assert_equal(h, c.instance_exec(a: 1, &m))
- assert_equal(h2, c.instance_exec(**h2, &m))
- assert_equal(h3, c.instance_exec(**h3, &m))
- assert_equal(h3, c.instance_exec(a: 1, **h2, &m))
-
- m = ->(**args) { args }
- assert_equal(kw, c.instance_exec(**{}, &m))
- assert_equal(kw, c.instance_exec(**kw, &m))
- assert_equal(h, c.instance_exec(**h, &m))
- assert_equal(h, c.instance_exec(a: 1, &m))
- assert_equal(h2, c.instance_exec(**h2, &m))
- assert_equal(h3, c.instance_exec(**h3, &m))
- assert_equal(h3, c.instance_exec(a: 1, **h2, &m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/) do
- assert_equal(h, c.instance_exec(h, &m))
- end
- assert_raise(ArgumentError) { c.instance_exec(h2, &m) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do
- assert_raise(ArgumentError) { c.instance_exec(h3, &m) }
- end
-
- m = ->(arg, **args) { [arg, args] }
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(**{}, &m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(**kw, &m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(**h, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(a: 1, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, kw], c.instance_exec(**h2, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(**h3, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(a: 1, **h2, &m))
- end
- assert_equal([h, kw], c.instance_exec(h, &m))
- assert_equal([h2, kw], c.instance_exec(h2, &m))
- assert_equal([h3, kw], c.instance_exec(h3, &m))
-
- m = ->(arg=1, **args) { [arg, args] }
- assert_equal([1, kw], c.instance_exec(**{}, &m))
- assert_equal([1, kw], c.instance_exec(**kw, &m))
- assert_equal([1, h], c.instance_exec(**h, &m))
- assert_equal([1, h], c.instance_exec(a: 1, &m))
- assert_equal([1, h2], c.instance_exec(**h2, &m))
- assert_equal([1, h3], c.instance_exec(**h3, &m))
- assert_equal([1, h3], c.instance_exec(a: 1, **h2, &m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal([1, h], c.instance_exec(h, &m))
- end
- assert_equal([h2, kw], c.instance_exec(h2, &m))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/m) do
- assert_equal([h2, h], c.instance_exec(h3, &m))
- end
- end
-
- def test_instance_exec_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- m = c.method(:m)
- assert_equal([], c.instance_exec(**{}, &m))
- assert_equal([], c.instance_exec(**kw, &m))
- assert_equal([h], c.instance_exec(**h, &m))
- assert_equal([h], c.instance_exec(a: 1, &m))
- assert_equal([h2], c.instance_exec(**h2, &m))
- assert_equal([h3], c.instance_exec(**h3, &m))
- assert_equal([h3], c.instance_exec(a: 1, **h2, &m))
-
- c.singleton_class.remove_method(:m)
- def c.m
- end
- m = c.method(:m)
- assert_nil(c.instance_exec(**{}, &m))
- assert_nil(c.instance_exec(**kw, &m))
- assert_raise(ArgumentError) { c.instance_exec(**h, &m) }
- assert_raise(ArgumentError) { c.instance_exec(a: 1, &m) }
- assert_raise(ArgumentError) { c.instance_exec(**h2, &m) }
- assert_raise(ArgumentError) { c.instance_exec(**h3, &m) }
- assert_raise(ArgumentError) { c.instance_exec(a: 1, **h2, &m) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- m = c.method(:m)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(**{}, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(**kw, &m))
- end
- assert_equal(kw, c.instance_exec(kw, **kw, &m))
- assert_equal(h, c.instance_exec(**h, &m))
- assert_equal(h, c.instance_exec(a: 1, &m))
- assert_equal(h2, c.instance_exec(**h2, &m))
- assert_equal(h3, c.instance_exec(**h3, &m))
- assert_equal(h3, c.instance_exec(a: 1, **h2, &m))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- m = c.method(:m)
- assert_equal(kw, c.instance_exec(**{}, &m))
- assert_equal(kw, c.instance_exec(**kw, &m))
- assert_equal(h, c.instance_exec(**h, &m))
- assert_equal(h, c.instance_exec(a: 1, &m))
- assert_equal(h2, c.instance_exec(**h2, &m))
- assert_equal(h3, c.instance_exec(**h3, &m))
- assert_equal(h3, c.instance_exec(a: 1, **h2, &m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/) do
- assert_equal(h, c.instance_exec(h, &m))
- end
- assert_raise(ArgumentError) { c.instance_exec(h2, &m) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do
- assert_raise(ArgumentError) { c.instance_exec(h3, &m) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- m = c.method(:m)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(**{}, &m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(**kw, &m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(**h, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(a: 1, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, kw], c.instance_exec(**h2, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(**h3, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(a: 1, **h2, &m))
- end
- assert_equal([h, kw], c.instance_exec(h, &m))
- assert_equal([h2, kw], c.instance_exec(h2, &m))
- assert_equal([h3, kw], c.instance_exec(h3, &m))
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- m = c.method(:m)
- assert_equal([1, kw], c.instance_exec(**{}, &m))
- assert_equal([1, kw], c.instance_exec(**kw, &m))
- assert_equal([1, h], c.instance_exec(**h, &m))
- assert_equal([1, h], c.instance_exec(a: 1, &m))
- assert_equal([1, h2], c.instance_exec(**h2, &m))
- assert_equal([1, h3], c.instance_exec(**h3, &m))
- assert_equal([1, h3], c.instance_exec(a: 1, **h2, &m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal([1, h], c.instance_exec(h, &m))
- end
- assert_equal([h2, kw], c.instance_exec(h2, &m))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do
- assert_equal([h2, h], c.instance_exec(h3, &m))
- end
- end
-
- def test_instance_exec_define_method_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- c.define_singleton_method(:m) do |*args|
- args
- end
- m = c.method(:m)
- assert_equal([], c.instance_exec(**{}, &m))
- assert_equal([], c.instance_exec(**kw, &m))
- assert_equal([h], c.instance_exec(**h, &m))
- assert_equal([h], c.instance_exec(a: 1, &m))
- assert_equal([h2], c.instance_exec(**h2, &m))
- assert_equal([h3], c.instance_exec(**h3, &m))
- assert_equal([h3], c.instance_exec(a: 1, **h2, &m))
-
- c.singleton_class.remove_method(:m)
- c.define_singleton_method(:m) do
- end
- m = c.method(:m)
- assert_nil(c.instance_exec(**{}, &m))
- assert_nil(c.instance_exec(**kw, &m))
- assert_raise(ArgumentError) { c.instance_exec(**h, &m) }
- assert_raise(ArgumentError) { c.instance_exec(a: 1, &m) }
- assert_raise(ArgumentError) { c.instance_exec(**h2, &m) }
- assert_raise(ArgumentError) { c.instance_exec(**h3, &m) }
- assert_raise(ArgumentError) { c.instance_exec(a: 1, **h2, &m) }
-
- c.singleton_class.remove_method(:m)
- c.define_singleton_method(:m) do |args|
- args
- end
- m = c.method(:m)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(**{}, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(**kw, &m))
- end
- assert_equal(kw, c.instance_exec(kw, **kw, &m))
- assert_equal(h, c.instance_exec(**h, &m))
- assert_equal(h, c.instance_exec(a: 1, &m))
- assert_equal(h2, c.instance_exec(**h2, &m))
- assert_equal(h3, c.instance_exec(**h3, &m))
- assert_equal(h3, c.instance_exec(a: 1, **h2, &m))
-
- c.singleton_class.remove_method(:m)
- c.define_singleton_method(:m) do |**args|
- args
- end
- m = c.method(:m)
- assert_equal(kw, c.instance_exec(**{}, &m))
- assert_equal(kw, c.instance_exec(**kw, &m))
- assert_equal(h, c.instance_exec(**h, &m))
- assert_equal(h, c.instance_exec(a: 1, &m))
- assert_equal(h2, c.instance_exec(**h2, &m))
- assert_equal(h3, c.instance_exec(**h3, &m))
- assert_equal(h3, c.instance_exec(a: 1, **h2, &m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/) do
- assert_equal(h, c.instance_exec(h, &m))
- end
- assert_raise(ArgumentError) { c.instance_exec(h2, &m) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do
- assert_raise(ArgumentError) { c.instance_exec(h3, &m) }
- end
-
- c.singleton_class.remove_method(:m)
- c.define_singleton_method(:m) do |arg, **args|
- [arg, args]
- end
- m = c.method(:m)
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(**{}, &m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(**kw, &m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(**h, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(a: 1, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, kw], c.instance_exec(**h2, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(**h3, &m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(a: 1, **h2, &m))
- end
- assert_equal([h, kw], c.instance_exec(h, &m))
- assert_equal([h2, kw], c.instance_exec(h2, &m))
- assert_equal([h3, kw], c.instance_exec(h3, &m))
-
- c.singleton_class.remove_method(:m)
- c.define_singleton_method(:m) do |arg=1, **args|
- [arg, args]
- end
- m = c.method(:m)
- assert_equal([1, kw], c.instance_exec(**{}, &m))
- assert_equal([1, kw], c.instance_exec(**kw, &m))
- assert_equal([1, h], c.instance_exec(**h, &m))
- assert_equal([1, h], c.instance_exec(a: 1, &m))
- assert_equal([1, h2], c.instance_exec(**h2, &m))
- assert_equal([1, h3], c.instance_exec(**h3, &m))
- assert_equal([1, h3], c.instance_exec(a: 1, **h2, &m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal([1, h], c.instance_exec(h, &m))
- end
- assert_equal([h2, kw], c.instance_exec(h2, &m))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do
- assert_equal([h2, h], c.instance_exec(h3, &m))
- end
- end
-
- def test_instance_exec_sym_proc_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- def c.m(*args)
- args
- end
- assert_equal([], c.instance_exec(c, **{}, &:m))
- assert_equal([], c.instance_exec(c, **kw, &:m))
- assert_equal([h], c.instance_exec(c, **h, &:m))
- assert_equal([h], c.instance_exec(c, a: 1, &:m))
- assert_equal([h2], c.instance_exec(c, **h2, &:m))
- assert_equal([h3], c.instance_exec(c, **h3, &:m))
- assert_equal([h3], c.instance_exec(c, a: 1, **h2, &:m))
-
- c.singleton_class.remove_method(:m)
- def c.m
- end
- assert_nil(c.instance_exec(c, **{}, &:m))
- assert_nil(c.instance_exec(c, **kw, &:m))
- assert_raise(ArgumentError) { c.instance_exec(c, **h, &:m) }
- assert_raise(ArgumentError) { c.instance_exec(c, a: 1, &:m) }
- assert_raise(ArgumentError) { c.instance_exec(c, **h2, &:m) }
- assert_raise(ArgumentError) { c.instance_exec(c, **h3, &:m) }
- assert_raise(ArgumentError) { c.instance_exec(c, a: 1, **h2, &:m) }
-
- c.singleton_class.remove_method(:m)
- def c.m(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(c, **{}, &:m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal(kw, c.instance_exec(c, **kw, &:m))
- end
- assert_equal(kw, c.instance_exec(c, kw, **kw, &:m))
- assert_equal(h, c.instance_exec(c, **h, &:m))
- assert_equal(h, c.instance_exec(c, a: 1, &:m))
- assert_equal(h2, c.instance_exec(c, **h2, &:m))
- assert_equal(h3, c.instance_exec(c, **h3, &:m))
- assert_equal(h3, c.instance_exec(c, a: 1, **h2, &:m))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, c.instance_exec(c, **{}, &:m))
- assert_equal(kw, c.instance_exec(c, **kw, &:m))
- assert_equal(h, c.instance_exec(c, **h, &:m))
- assert_equal(h, c.instance_exec(c, a: 1, &:m))
- assert_equal(h2, c.instance_exec(c, **h2, &:m))
- assert_equal(h3, c.instance_exec(c, **h3, &:m))
- assert_equal(h3, c.instance_exec(c, a: 1, **h2, &:m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/) do
- assert_equal(h, c.instance_exec(c, h, &:m))
- end
- assert_raise(ArgumentError) { c.instance_exec(c, h2, &:m) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do
- assert_raise(ArgumentError) { c.instance_exec(c, h3, &:m) }
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(c, **{}, &:m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- c.instance_exec(c, **kw, &:m)
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(c, **h, &:m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h, kw], c.instance_exec(c, a: 1, &:m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h2, kw], c.instance_exec(c, **h2, &:m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(c, **h3, &:m))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated/) do
- assert_equal([h3, kw], c.instance_exec(c, a: 1, **h2, &:m))
- end
- assert_equal([h, kw], c.instance_exec(c, h, &:m))
- assert_equal([h2, kw], c.instance_exec(c, h2, &:m))
- assert_equal([h3, kw], c.instance_exec(c, h3, &:m))
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.instance_exec(c, **{}, &:m))
- assert_equal([1, kw], c.instance_exec(c, **kw, &:m))
- assert_equal([1, h], c.instance_exec(c, **h, &:m))
- assert_equal([1, h], c.instance_exec(c, a: 1, &:m))
- assert_equal([1, h2], c.instance_exec(c, **h2, &:m))
- assert_equal([1, h3], c.instance_exec(c, **h3, &:m))
- assert_equal([1, h3], c.instance_exec(c, a: 1, **h2, &:m))
- assert_warn(/Using the last argument as keyword parameters is deprecated/m) do
- assert_equal([1, h], c.instance_exec(c, h, &:m))
- end
- assert_equal([h2, kw], c.instance_exec(c, h2, &:m))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated/) do
- assert_equal([h2, h], c.instance_exec(c, h3, &:m))
- end
- end
-
- def test_rb_yield_block_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = Object.new
- c.extend Bug::Iter::Yield
- class << c
- alias m yield_block
- end
- def c.c(*args)
- args
- end
- assert_equal([], c.m(:c, **{}))
- assert_equal([], c.m(:c, **kw))
- assert_equal([h], c.m(:c, **h))
- assert_equal([h], c.m(:c, a: 1))
- assert_equal([h2], c.m(:c, **h2))
- assert_equal([h3], c.m(:c, **h3))
- assert_equal([h3], c.m(:c, a: 1, **h2))
-
- c.singleton_class.remove_method(:c)
- def c.c; end
- assert_nil(c.m(:c, **{}))
- assert_nil(c.m(:c, **kw))
- assert_raise(ArgumentError) { c.m(:c, **h) }
- assert_raise(ArgumentError) { c.m(:c, a: 1) }
- assert_raise(ArgumentError) { c.m(:c, **h2) }
- assert_raise(ArgumentError) { c.m(:c, **h3) }
- assert_raise(ArgumentError) { c.m(:c, a: 1, **h2) }
-
- c.singleton_class.remove_method(:c)
- def c.c(args)
- args
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal(kw, c.m(:c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal(kw, c.m(:c, **kw))
- end
- assert_equal(kw, c.m(:c, kw, **kw))
- assert_equal(h, c.m(:c, **h))
- assert_equal(h, c.m(:c, a: 1))
- assert_equal(h2, c.m(:c, **h2))
- assert_equal(h3, c.m(:c, **h3))
- assert_equal(h3, c.m(:c, a: 1, **h2))
-
- c.singleton_class.remove_method(:c)
- def c.c(**args)
- [args, yield(**args)]
- end
- m = ->(**args){ args }
- assert_equal([kw, kw], c.m(:c, **{}, &m))
- assert_equal([kw, kw], c.m(:c, **kw, &m))
- assert_equal([h, h], c.m(:c, **h, &m))
- assert_equal([h, h], c.m(:c, a: 1, &m))
- assert_equal([h2, h2], c.m(:c, **h2, &m))
- assert_equal([h3, h3], c.m(:c, **h3, &m))
- assert_equal([h3, h3], c.m(:c, a: 1, **h2, &m))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `c'/m) do
- assert_equal([h, h], c.m(:c, h, &m))
- end
- assert_raise(ArgumentError) { c.m(:c, h2, &m) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `c'/m) do
- assert_raise(ArgumentError) { c.m(:c, h3, &m) }
- end
-
- c.singleton_class.remove_method(:c)
- def c.c(arg, **args)
- [arg, args]
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal([kw, kw], c.m(:c, **{}))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal([kw, kw], c.m(:c, **kw))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal([h, kw], c.m(:c, **h))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal([h, kw], c.m(:c, a: 1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal([h2, kw], c.m(:c, **h2))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal([h3, kw], c.m(:c, **h3))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `c'/m) do
- assert_equal([h3, kw], c.m(:c, a: 1, **h2))
- end
- assert_equal([h, kw], c.m(:c, h))
- assert_equal([h2, kw], c.m(:c, h2))
- assert_equal([h3, kw], c.m(:c, h3))
-
- c.singleton_class.remove_method(:c)
- def c.c(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.m(:c, **{}))
- assert_equal([1, kw], c.m(:c, **kw))
- assert_equal([1, h], c.m(:c, **h))
- assert_equal([1, h], c.m(:c, a: 1))
- assert_equal([1, h2], c.m(:c, **h2))
- assert_equal([1, h3], c.m(:c, **h3))
- assert_equal([1, h3], c.m(:c, a: 1, **h2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `c'/m) do
- assert_equal([1, h], c.m(:c, h))
- end
- assert_equal([h2, kw], c.m(:c, h2))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `c'/m) do
- assert_equal([h2, h], c.m(:c, h3))
- end
- end
def p1
Proc.new do |str: "foo", num: 424242|
@@ -4099,8 +254,8 @@ class TestKeywordArguments < Test::Unit::TestCase
[:keyrest, :kw], [:block, :b]], p6.parameters)
end
- def m1(*args, **options)
- yield(*args, **options)
+ def m1(*args)
+ yield(*args)
end
def test_block
@@ -4119,73 +274,14 @@ class TestKeywordArguments < Test::Unit::TestCase
bug7665 = '[ruby-core:51278]'
bug8463 = '[ruby-core:55203] [Bug #8463]'
expect = [*%w[foo bar], {zzz: 42}]
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `rest_keyrest'/m) do
- assert_equal(expect, rest_keyrest(*expect), bug7665)
- end
+ assert_equal(expect, rest_keyrest(*expect), bug7665)
pr = proc {|*args, **opt| next *args, opt}
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(expect, pr.call(*expect), bug7665)
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(expect, pr.call(expect), bug8463)
- end
+ assert_equal(expect, pr.call(*expect), bug7665)
+ assert_equal(expect, pr.call(expect), bug8463)
pr = proc {|a, *b, **opt| next a, *b, opt}
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(expect, pr.call(expect), bug8463)
- end
+ assert_equal(expect, pr.call(expect), bug8463)
pr = proc {|a, **opt| next a, opt}
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463)
- end
- end
-
- def req_plus_keyword(x, **h)
- [x, h]
- end
-
- def opt_plus_keyword(x=1, **h)
- [x, h]
- end
-
- def splat_plus_keyword(*a, **h)
- [a, h]
- end
-
- def test_keyword_split
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `req_plus_keyword'/m) do
- assert_equal([{:a=>1}, {}], req_plus_keyword(:a=>1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `req_plus_keyword'/m) do
- assert_equal([{"a"=>1}, {}], req_plus_keyword("a"=>1))
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `req_plus_keyword'/m) do
- assert_equal([{"a"=>1, :a=>1}, {}], req_plus_keyword("a"=>1, :a=>1))
- end
- assert_equal([{:a=>1}, {}], req_plus_keyword({:a=>1}))
- assert_equal([{"a"=>1}, {}], req_plus_keyword({"a"=>1}))
- assert_equal([{"a"=>1, :a=>1}, {}], req_plus_keyword({"a"=>1, :a=>1}))
-
- assert_equal([1, {:a=>1}], opt_plus_keyword(:a=>1))
- assert_equal([1, {"a"=>1}], opt_plus_keyword("a"=>1))
- assert_equal([1, {"a"=>1, :a=>1}], opt_plus_keyword("a"=>1, :a=>1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `opt_plus_keyword'/m) do
- assert_equal([1, {:a=>1}], opt_plus_keyword({:a=>1}))
- end
- assert_equal([{"a"=>1}, {}], opt_plus_keyword({"a"=>1}))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `opt_plus_keyword'/m) do
- assert_equal([{"a"=>1}, {:a=>1}], opt_plus_keyword({"a"=>1, :a=>1}))
- end
-
- assert_equal([[], {:a=>1}], splat_plus_keyword(:a=>1))
- assert_equal([[], {"a"=>1}], splat_plus_keyword("a"=>1))
- assert_equal([[], {"a"=>1, :a=>1}], splat_plus_keyword("a"=>1, :a=>1))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `splat_plus_keyword'/m) do
- assert_equal([[], {:a=>1}], splat_plus_keyword({:a=>1}))
- end
- assert_equal([[{"a"=>1}], {}], splat_plus_keyword({"a"=>1}))
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `splat_plus_keyword'/m) do
- assert_equal([[{"a"=>1}], {:a=>1}], splat_plus_keyword({"a"=>1, :a=>1}))
- end
+ assert_equal(expect.values_at(0, -1), pr.call(expect), bug8463)
end
def test_bare_kwrest
@@ -4370,9 +466,7 @@ class TestKeywordArguments < Test::Unit::TestCase
[a, b, c, d, e, f, g]
end
end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `foo'/m) do
- assert_equal([1, 2, 1, [], {:f=>5}, 2, {}], a.new.foo(1, 2, f:5), bug8993)
- end
+ assert_equal([1, 2, 1, [], {:f=>5}, 2, {}], a.new.foo(1, 2, f:5), bug8993)
end
def test_splat_keyword_nondestructive
@@ -4405,49 +499,27 @@ class TestKeywordArguments < Test::Unit::TestCase
o = Object.new
def o.to_hash() { k: 9 } end
assert_equal([1, 42, [], o, :key, {}, nil], f9(1, o))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m1'/m) do
- assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016)
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `m1'/m) do
- assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016)
- end
+ assert_equal([1, 9], m1(1, o) {|a, k: 0| break [a, k]}, bug10016)
+ assert_equal([1, 9], m1(1, o, &->(a, k: 0) {break [a, k]}), bug10016)
end
def test_splat_hash
m = Object.new
def m.f() :ok; end
- def m.f1(a) a; end
def m.f2(a = nil) a; end
- def m.f3(**a) a; end
- def m.f4(*a) a; end
o = {a: 1}
- assert_raise_with_message(ArgumentError, /unknown keyword: :a/) {
+ assert_raise_with_message(ArgumentError, /unknown keyword: a/) {
m.f(**o)
}
o = {}
assert_equal(:ok, m.f(**o), '[ruby-core:68124] [Bug #10856]')
a = []
assert_equal(:ok, m.f(*a, **o), '[ruby-core:83638] [Bug #10856]')
- assert_equal(:OK, m.f1(*a, :OK, **o), '[ruby-core:91825] [Bug #10856]')
- assert_equal({}, m.f1(*a, o), '[ruby-core:91825] [Bug #10856]')
o = {a: 42}
- assert_warning('', 'splat to mandatory') do
- assert_equal({a: 42}, m.f1(**o))
- end
- assert_warning('') do
- assert_equal({a: 42}, m.f2(**o), '[ruby-core:82280] [Bug #13791]')
- end
- assert_warning('', 'splat to kwrest') do
- assert_equal({a: 42}, m.f3(**o))
- end
- assert_warning('', 'splat to rest') do
- assert_equal([{a: 42}], m.f4(**o))
- end
+ assert_equal({a: 42}, m.f2(**o), '[ruby-core:82280] [Bug #13791]')
- assert_warning('') do
- assert_equal({a: 42}, m.f2("a".to_sym => 42), '[ruby-core:82291] [Bug #13793]')
- end
+ assert_equal({a: 42}, m.f2("a".to_sym => 42), '[ruby-core:82291] [Bug #13793]')
o = {}
a = [:ok]
@@ -4493,14 +565,14 @@ class TestKeywordArguments < Test::Unit::TestCase
bar(k1: 1)
end
end
- assert_raise_with_message(ArgumentError, /unknown keyword: :k1/, bug10413) {
+ assert_raise_with_message(ArgumentError, /unknown keyword: k1/, bug10413) {
o.foo {raise "unreachable"}
}
end
def test_unknown_keyword
bug13004 = '[ruby-dev:49893] [Bug #13004]'
- assert_raise_with_message(ArgumentError, /unknown keyword: :"invalid-argument"/, bug13004) {
+ assert_raise_with_message(ArgumentError, /unknown keyword: invalid-argument/, bug13004) {
[].sample(random: nil, "invalid-argument": nil)
}
end
@@ -4607,477 +679,7 @@ class TestKeywordArguments < Test::Unit::TestCase
end
end
- def many_kwargs(a0: '', a1: '', a2: '', a3: '', a4: '', a5: '', a6: '', a7: '',
- b0: '', b1: '', b2: '', b3: '', b4: '', b5: '', b6: '', b7: '',
- c0: '', c1: '', c2: '', c3: '', c4: '', c5: '', c6: '', c7: '',
- d0: '', d1: '', d2: '', d3: '', d4: '', d5: '', d6: '', d7: '',
- e0: '')
- [a0, a1, a2, a3, a4, a5, a6, a7,
- b0, b1, b2, b3, b4, b5, b6, b7,
- c0, c1, c2, c3, c4, c5, c6, c7,
- d0, d1, d2, d3, d4, d5, d6, d7,
- e0]
- end
-
- def test_many_kwargs
- i = 0
- assert_equal(:ok, many_kwargs(a0: :ok)[i], "#{i}: a0"); i+=1
- assert_equal(:ok, many_kwargs(a1: :ok)[i], "#{i}: a1"); i+=1
- assert_equal(:ok, many_kwargs(a2: :ok)[i], "#{i}: a2"); i+=1
- assert_equal(:ok, many_kwargs(a3: :ok)[i], "#{i}: a3"); i+=1
- assert_equal(:ok, many_kwargs(a4: :ok)[i], "#{i}: a4"); i+=1
- assert_equal(:ok, many_kwargs(a5: :ok)[i], "#{i}: a5"); i+=1
- assert_equal(:ok, many_kwargs(a6: :ok)[i], "#{i}: a6"); i+=1
- assert_equal(:ok, many_kwargs(a7: :ok)[i], "#{i}: a7"); i+=1
-
- assert_equal(:ok, many_kwargs(b0: :ok)[i], "#{i}: b0"); i+=1
- assert_equal(:ok, many_kwargs(b1: :ok)[i], "#{i}: b1"); i+=1
- assert_equal(:ok, many_kwargs(b2: :ok)[i], "#{i}: b2"); i+=1
- assert_equal(:ok, many_kwargs(b3: :ok)[i], "#{i}: b3"); i+=1
- assert_equal(:ok, many_kwargs(b4: :ok)[i], "#{i}: b4"); i+=1
- assert_equal(:ok, many_kwargs(b5: :ok)[i], "#{i}: b5"); i+=1
- assert_equal(:ok, many_kwargs(b6: :ok)[i], "#{i}: b6"); i+=1
- assert_equal(:ok, many_kwargs(b7: :ok)[i], "#{i}: b7"); i+=1
-
- assert_equal(:ok, many_kwargs(c0: :ok)[i], "#{i}: c0"); i+=1
- assert_equal(:ok, many_kwargs(c1: :ok)[i], "#{i}: c1"); i+=1
- assert_equal(:ok, many_kwargs(c2: :ok)[i], "#{i}: c2"); i+=1
- assert_equal(:ok, many_kwargs(c3: :ok)[i], "#{i}: c3"); i+=1
- assert_equal(:ok, many_kwargs(c4: :ok)[i], "#{i}: c4"); i+=1
- assert_equal(:ok, many_kwargs(c5: :ok)[i], "#{i}: c5"); i+=1
- assert_equal(:ok, many_kwargs(c6: :ok)[i], "#{i}: c6"); i+=1
- assert_equal(:ok, many_kwargs(c7: :ok)[i], "#{i}: c7"); i+=1
-
- assert_equal(:ok, many_kwargs(d0: :ok)[i], "#{i}: d0"); i+=1
- assert_equal(:ok, many_kwargs(d1: :ok)[i], "#{i}: d1"); i+=1
- assert_equal(:ok, many_kwargs(d2: :ok)[i], "#{i}: d2"); i+=1
- assert_equal(:ok, many_kwargs(d3: :ok)[i], "#{i}: d3"); i+=1
- assert_equal(:ok, many_kwargs(d4: :ok)[i], "#{i}: d4"); i+=1
- assert_equal(:ok, many_kwargs(d5: :ok)[i], "#{i}: d5"); i+=1
- assert_equal(:ok, many_kwargs(d6: :ok)[i], "#{i}: d6"); i+=1
- assert_equal(:ok, many_kwargs(d7: :ok)[i], "#{i}: d7"); i+=1
-
- assert_equal(:ok, many_kwargs(e0: :ok)[i], "#{i}: e0"); i+=1
- end
-
def test_splat_empty_hash_with_block_passing
assert_valid_syntax("bug15087(**{}, &nil)")
end
-
- def test_do_not_use_newarraykwsplat
- assert_equal([42, "foo", 424242], f2(*[], 42, **{}))
- a = [1, 2, 3]
- assert_equal([[1,2,3,4,5,6], "foo", 424242, {:k=>:k}], f7(*a, 4,5,6, k: :k))
- end
-end
-
-class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase
- class C
- def call(*args, **kw)
- yield(self, *args, **kw)
- end
- end
- using(Module.new do
- refine C do
- def m(*args, **kw)
- super
- end
- end
- end)
-
- def test_sym_proc_refine_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = C.new
- def c.m(*args)
- args
- end
- assert_equal([], c.call(**{}, &:m))
- assert_equal([], c.call(**kw, &:m))
- assert_equal([h], c.call(**h, &:m))
- assert_equal([h], c.call(h, **{}, &:m))
- assert_equal([h], c.call(a: 1, &:m))
- assert_equal([h2], c.call(**h2, &:m))
- assert_equal([h3], c.call(**h3, &:m))
- assert_equal([h3], c.call(a: 1, **h2, &:m))
-
- c.singleton_class.remove_method(:m)
- def c.m; end
- assert_nil(c.call(**{}, &:m))
- assert_nil(c.call(**kw, &:m))
- assert_raise(ArgumentError) { c.call(**h, &:m) }
- assert_raise(ArgumentError) { c.call(a: 1, &:m) }
- assert_raise(ArgumentError) { c.call(**h2, &:m) }
- assert_raise(ArgumentError) { c.call(**h3, &:m) }
- assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m) }
-
- redef = -> do
- c.singleton_class.remove_method(:m)
- eval <<-END
- def c.m(args)
- args
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.call(**{}, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal(kw, c.call(**kw, &:m))
- end
- assert_equal(h, c.call(**h, &:m))
- assert_equal(h, c.call(a: 1, &:m))
- assert_equal(h2, c.call(**h2, &:m))
- assert_equal(h3, c.call(**h3, &:m))
- assert_equal(h3, c.call(a: 1, **h2, &:m))
-
- c.singleton_class.remove_method(:m)
- def c.m(**args)
- args
- end
- assert_equal(kw, c.call(**{}, &:m))
- assert_equal(kw, c.call(**kw, &:m))
- assert_equal(h, c.call(**h, &:m))
- assert_equal(h, c.call(a: 1, &:m))
- assert_equal(h2, c.call(**h2, &:m))
- assert_equal(h3, c.call(**h3, &:m))
- assert_equal(h3, c.call(a: 1, **h2, &:m))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(h, c.call(h, &:m))
- end
- assert_raise(ArgumentError) { c.call(h2, &:m) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `call'/m) do
- assert_raise(ArgumentError) { c.call(h3, &:m) }
- end
-
- redef = -> do
- c.singleton_class.remove_method(:m)
- eval <<-END
- def c.m(arg, **args)
- [arg, args]
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], c.call(**{}, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([kw, kw], c.call(**kw, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.call(**h, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h, kw], c.call(a: 1, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h2, kw], c.call(**h2, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.call(**h3, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `m'/m) do
- assert_equal([h3, kw], c.call(a: 1, **h2, &:m))
- end
-
- c.singleton_class.remove_method(:m)
- def c.m(arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.call(**{}, &:m))
- assert_equal([1, kw], c.call(**kw, &:m))
- assert_equal([1, h], c.call(**h, &:m))
- assert_equal([1, h], c.call(a: 1, &:m))
- assert_equal([1, h2], c.call(**h2, &:m))
- assert_equal([1, h3], c.call(**h3, &:m))
- assert_equal([1, h3], c.call(a: 1, **h2, &:m))
- end
-
- def test_sym_proc_refine_super_method_missing_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = C.new
- def c.method_missing(_, *args)
- args
- end
- assert_equal([], c.call(**{}, &:m))
- assert_equal([], c.call(**kw, &:m))
- assert_equal([h], c.call(**h, &:m))
- assert_equal([h], c.call(h, **{}, &:m))
- assert_equal([h], c.call(a: 1, &:m))
- assert_equal([h2], c.call(**h2, &:m))
- assert_equal([h3], c.call(**h3, &:m))
- assert_equal([h3], c.call(a: 1, **h2, &:m))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_) end
- assert_nil(c.call(**{}, &:m))
- assert_nil(c.call(**kw, &:m))
- assert_raise(ArgumentError) { c.call(**h, &:m) }
- assert_raise(ArgumentError) { c.call(a: 1, &:m) }
- assert_raise(ArgumentError) { c.call(**h2, &:m) }
- assert_raise(ArgumentError) { c.call(**h3, &:m) }
- assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m) }
-
- redef = -> do
- c.singleton_class.remove_method(:method_missing)
- eval <<-END
- def c.method_missing(_, args)
- args
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.call(**{}, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.call(**kw, &:m))
- end
- assert_equal(h, c.call(**h, &:m))
- assert_equal(h, c.call(a: 1, &:m))
- assert_equal(h2, c.call(**h2, &:m))
- assert_equal(h3, c.call(**h3, &:m))
- assert_equal(h3, c.call(a: 1, **h2, &:m))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, **args)
- args
- end
- assert_equal(kw, c.call(**{}, &:m))
- assert_equal(kw, c.call(**kw, &:m))
- assert_equal(h, c.call(**h, &:m))
- assert_equal(h, c.call(a: 1, &:m))
- assert_equal(h2, c.call(**h2, &:m))
- assert_equal(h3, c.call(**h3, &:m))
- assert_equal(h3, c.call(a: 1, **h2, &:m))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(h, c.call(h, &:m2))
- end
- assert_raise(ArgumentError) { c.call(h2, &:m2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `call'/m) do
- assert_raise(ArgumentError) { c.call(h3, &:m2) }
- end
-
- redef = -> do
- c.singleton_class.remove_method(:method_missing)
- eval <<-END
- def c.method_missing(_, arg, **args)
- [arg, args]
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.call(**{}, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.call(**kw, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.call(**h, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.call(a: 1, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, kw], c.call(**h2, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.call(**h3, &:m))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.call(a: 1, **h2, &:m))
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.call(**{}, &:m))
- assert_equal([1, kw], c.call(**kw, &:m))
- assert_equal([1, h], c.call(**h, &:m))
- assert_equal([1, h], c.call(a: 1, &:m))
- assert_equal([1, h2], c.call(**h2, &:m))
- assert_equal([1, h3], c.call(**h3, &:m))
- assert_equal([1, h3], c.call(a: 1, **h2, &:m))
- end
-
- def test_sym_proc_refine_method_missing_kwsplat
- kw = {}
- h = {:a=>1}
- h2 = {'a'=>1}
- h3 = {'a'=>1, :a=>1}
-
- c = C.new
- def c.method_missing(_, *args)
- args
- end
- assert_equal([], c.call(**{}, &:m2))
- assert_equal([], c.call(**kw, &:m2))
- assert_equal([h], c.call(**h, &:m2))
- assert_equal([h], c.call(h, **{}, &:m2))
- assert_equal([h], c.call(a: 1, &:m2))
- assert_equal([h2], c.call(**h2, &:m2))
- assert_equal([h3], c.call(**h3, &:m2))
- assert_equal([h3], c.call(a: 1, **h2, &:m2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_) end
- assert_nil(c.call(**{}, &:m2))
- assert_nil(c.call(**kw, &:m2))
- assert_raise(ArgumentError) { c.call(**h, &:m2) }
- assert_raise(ArgumentError) { c.call(a: 1, &:m2) }
- assert_raise(ArgumentError) { c.call(**h2, &:m2) }
- assert_raise(ArgumentError) { c.call(**h3, &:m2) }
- assert_raise(ArgumentError) { c.call(a: 1, **h2, &:m2) }
-
- redef = -> do
- c.singleton_class.remove_method(:method_missing)
- eval <<-END
- def c.method_missing(_, args)
- args
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.call(**{}, &:m2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal(kw, c.call(**kw, &:m2))
- end
- assert_equal(h, c.call(**h, &:m2))
- assert_equal(h, c.call(a: 1, &:m2))
- assert_equal(h2, c.call(**h2, &:m2))
- assert_equal(h3, c.call(**h3, &:m2))
- assert_equal(h3, c.call(a: 1, **h2, &:m2))
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, **args)
- args
- end
- assert_equal(kw, c.call(**{}, &:m2))
- assert_equal(kw, c.call(**kw, &:m2))
- assert_equal(h, c.call(**h, &:m2))
- assert_equal(h, c.call(a: 1, &:m2))
- assert_equal(h2, c.call(**h2, &:m2))
- assert_equal(h3, c.call(**h3, &:m2))
- assert_equal(h3, c.call(a: 1, **h2, &:m2))
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(h, c.call(h, &:m2))
- end
- assert_raise(ArgumentError) { c.call(h2, &:m2) }
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `call'/m) do
- assert_raise(ArgumentError) { c.call(h3, &:m2) }
- end
-
- redef = -> do
- c.singleton_class.remove_method(:method_missing)
- eval <<-END
- def c.method_missing(_, arg, **args)
- [arg, args]
- end
- END
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.call(**{}, &:m2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([kw, kw], c.call(**kw, &:m2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.call(**h, &:m2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h, kw], c.call(a: 1, &:m2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h2, kw], c.call(**h2, &:m2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.call(**h3, &:m2))
- end
- redef[]
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `method_missing'/m) do
- assert_equal([h3, kw], c.call(a: 1, **h2, &:m2))
- end
-
- c.singleton_class.remove_method(:method_missing)
- def c.method_missing(_, arg=1, **args)
- [arg, args]
- end
- assert_equal([1, kw], c.call(**{}, &:m2))
- assert_equal([1, kw], c.call(**kw, &:m2))
- assert_equal([1, h], c.call(**h, &:m2))
- assert_equal([1, h], c.call(a: 1, &:m2))
- assert_equal([1, h2], c.call(**h2, &:m2))
- assert_equal([1, h3], c.call(**h3, &:m2))
- assert_equal([1, h3], c.call(a: 1, **h2, &:m2))
- end
-
- def test_protected_kwarg
- mock = Class.new do
- def foo
- bar('x', y: 'z')
- end
- protected
- def bar(x, y)
- nil
- end
- end
-
- assert_nothing_raised do
- mock.new.foo
- end
- end
-
- def test_splat_fixnum
- bug16603 = '[ruby-core:97047] [Bug #16603]'
- assert_raise(TypeError, bug16603) { p(**42) }
- assert_raise(TypeError, bug16603) { p(k:1, **42) }
- end
-
- def test_ruby2_keywords_hash_empty_kw_splat
- def self.foo(*a) a.last end
- singleton_class.send(:ruby2_keywords, :foo)
- bug16642 = '[ruby-core:97203] [Bug #16642]'
-
- res = foo(**{})
- assert_equal({}, res, bug16642)
- assert_equal(false, res.frozen?, bug16642)
-
- res = foo(*[], **{})
- assert_equal({}, res, bug16642)
- assert_equal(false, res.frozen?, bug16642)
- end
end
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index 03b501a6c9..3ac2e4cb98 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -74,26 +74,6 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_raise(ArgumentError, bug9605) {proc(&plus).call [1,2]}
end
- def pass_along(&block)
- lambda(&block)
- end
-
- def pass_along2(&block)
- pass_along(&block)
- end
-
- def test_create_non_lambda_for_proc_one_level
- f = pass_along {}
- refute_predicate(f, :lambda?, '[Bug #15620]')
- assert_nothing_raised(ArgumentError) { f.call(:extra_arg) }
- end
-
- def test_create_non_lambda_for_proc_two_levels
- f = pass_along2 {}
- refute_predicate(f, :lambda?, '[Bug #15620]')
- assert_nothing_raised(ArgumentError) { f.call(:extra_arg) }
- end
-
def test_instance_exec
bug12568 = '[ruby-core:76300] [Bug #12568]'
assert_nothing_raised(ArgumentError, bug12568) do
@@ -177,21 +157,6 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_equal(42, return_in_callee(42), feature8693)
end
- def break_in_current(val)
- 1.tap(&->(*) {break 0})
- val
- end
-
- def break_in_callee(val)
- yield_block(&->(*) {break 0})
- val
- end
-
- def test_break
- assert_equal(42, break_in_current(42))
- assert_equal(42, break_in_callee(42))
- end
-
def test_do_lambda_source_location
exp_lineno = __LINE__ + 3
lmd = ->(x,
@@ -215,31 +180,4 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
assert_equal(exp_lineno, lineno, "must be at the beginning of the block")
end
-
- def test_not_orphan_return
- assert_equal(42, Module.new { extend self
- def m1(&b) b.call end; def m2(); m1(&-> { return 42 }) end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1(&-> { return 42 }).call end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1(&-> { return 42 }) end }.m2.call)
- end
-
- def test_not_orphan_break
- assert_equal(42, Module.new { extend self
- def m1(&b) b.call end; def m2(); m1(&-> { break 42 }) end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1(&-> { break 42 }).call end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1(&-> { break 42 }) end }.m2.call)
- end
-
- def test_not_orphan_next
- assert_equal(42, Module.new { extend self
- def m1(&b) b.call end; def m2(); m1(&-> { next 42 }) end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1(&-> { next 42 }).call end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1(&-> { next 42 }) end }.m2.call)
- end
end
diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb
index 6e5c1714a5..03371c912a 100644
--- a/test/ruby/test_lazy_enumerator.rb
+++ b/test/ruby/test_lazy_enumerator.rb
@@ -17,9 +17,9 @@ class TestLazyEnumerator < Test::Unit::TestCase
@enum.each do |v|
@current = v
if v.is_a? Enumerable
- yield(*v)
+ yield *v
else
- yield(v)
+ yield v
end
end
end
@@ -452,14 +452,6 @@ class TestLazyEnumerator < Test::Unit::TestCase
EOS
end
- def test_lazy_eager
- lazy = [1, 2, 3].lazy.map { |x| x * 2 }
- enum = lazy.eager
- assert_equal Enumerator, enum.class
- assert_equal 3, enum.size
- assert_equal [1, 2, 3], enum.map { |x| x / 2 }
- end
-
def test_lazy_to_enum
lazy = [1, 2, 3].lazy
def lazy.foo(*args)
@@ -474,54 +466,6 @@ EOS
assert_equal [1, 2, 3], lazy.to_enum.to_a
end
- def test_lazy_to_enum_lazy_methods
- a = [1, 2, 3].to_enum
- pr = proc{|x| [x, x * 2]}
- selector = proc{|x| x*2 if x % 2 == 0}
-
- [
- [:with_index, nil],
- [:with_index, 10, nil],
- [:with_index, 10, pr],
- [:map, nil],
- [:map, pr],
- [:collect, nil],
- [:flat_map, nil],
- [:flat_map, pr],
- [:collect_concat, nil],
- [:select, nil],
- [:select, selector],
- [:find_all, nil],
- [:filter, nil],
- [:filter_map, selector],
- [:filter_map, nil],
- [:reject, selector],
- [:grep, selector, nil],
- [:grep, selector, pr],
- [:grep_v, selector, nil],
- [:grep_v, selector, pr],
- [:zip, a, nil],
- [:take, 3, nil],
- [:take_while, nil],
- [:take_while, selector],
- [:drop, 1, nil],
- [:drop_while, nil],
- [:drop_while, selector],
- [:uniq, nil],
- [:uniq, proc{|x| x.odd?}],
- ].each do |args|
- block = args.pop
- assert_equal [1, 2, 3].to_enum.to_enum(*args).first(2).to_a, [1, 2, 3].to_enum.lazy.to_enum(*args).first(2).to_a
- assert_equal (0..50).to_enum.to_enum(*args).first(2).to_a, (0..50000).to_enum.lazy.to_enum(*args).first(2).to_a
- if block
- assert_equal [1, 2, 3, 4].to_enum.to_enum(*args).map(&block).first(2).to_a, [1, 2, 3, 4].to_enum.lazy.to_enum(*args).map(&block).first(2).to_a
- unless args.first == :take_while || args.first == :drop_while
- assert_equal (0..50).to_enum.to_enum(*args).map(&block).first(2).to_a, (0..50000).to_enum.lazy.to_enum(*args).map(&block).first(2).to_a
- end
- end
- end
- end
-
def test_size
lazy = [1, 2, 3].lazy
assert_equal 3, lazy.size
@@ -634,48 +578,4 @@ EOS
assert_equal([1, 2, 3, 4, 5, 10], u.first(6))
assert_equal([1, 2, 3, 4, 5, 10], u.first(6))
end
-
- def test_filter_map
- e = (1..Float::INFINITY).lazy.filter_map do |x|
- raise "too big" if x > 10000
- (x**2) % 10 if x.even?
- end
- assert_equal([4, 6, 6, 4, 0, 4], e.first(6))
- assert_equal([4, 6, 6, 4, 0, 4], e.first(6))
- end
-
- def test_with_index
- feature7877 = '[ruby-dev:47025] [Feature #7877]'
- leibniz = ->(n) {
- (0..Float::INFINITY).lazy.with_index.map {|i, j|
- raise IndexError, "limit exceeded (#{n})" unless j < n
- ((-1) ** j) / (2*i+1).to_f
- }.take(n).reduce(:+)
- }
- assert_nothing_raised(IndexError, feature7877) {
- assert_in_epsilon(Math::PI/4, leibniz[1000])
- }
-
- a = []
- ary = (0..Float::INFINITY).lazy.with_index(2) {|i, j| a << [i-1, j] }.take(2).to_a
- assert_equal([[-1, 2], [0, 3]], a)
- assert_equal([0, 1], ary)
-
- a = []
- ary = (0..Float::INFINITY).lazy.with_index(2, &->(i,j) { a << [i-1, j] }).take(2).to_a
- assert_equal([[-1, 2], [0, 3]], a)
- assert_equal([0, 1], ary)
-
- ary = (0..Float::INFINITY).lazy.with_index(2).map {|i, j| [i-1, j] }.take(2).to_a
- assert_equal([[-1, 2], [0, 3]], ary)
-
- ary = (0..Float::INFINITY).lazy.with_index(2).map(&->(i, j) { [i-1, j] }).take(2).to_a
- assert_equal([[-1, 2], [0, 3]], ary)
-
- ary = (0..Float::INFINITY).lazy.with_index(2).take(2).to_a
- assert_equal([[0, 2], [1, 3]], ary)
-
- ary = (0..Float::INFINITY).lazy.with_index.take(2).to_a
- assert_equal([[0, 0], [1, 1]], ary)
- end
end
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 7f4a329c4a..cf1a2babd7 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -45,7 +45,6 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_equal "A", ?A
assert_instance_of String, ?\n
assert_equal "\n", ?\n
- assert_equal " ", ?\s
assert_equal " ", ?\ # space
assert_equal '', ''
assert_equal 'string', 'string'
@@ -178,35 +177,18 @@ class TestRubyLiteral < Test::Unit::TestCase
end
end
- def test_frozen_string_in_array_literal
- list = eval("# frozen-string-literal: true\n""['foo', 'bar']")
- assert_equal 2, list.length
- list.each { |str| assert_predicate str, :frozen? }
- end
-
if defined?(RubyVM::InstructionSequence.compile_option) and
RubyVM::InstructionSequence.compile_option.key?(:debug_frozen_string_literal)
def test_debug_frozen_string
- src = 'n = 1; _="foo#{n ? "-#{n}" : ""}"'; f = "test.rb"; n = 1
+ src = 'n = 1; "foo#{n ? "-#{n}" : ""}"'; f = "test.rb"; n = 1
opt = {frozen_string_literal: true, debug_frozen_string_literal: true}
- str = RubyVM::InstructionSequence.compile(src, f, f, n, **opt).eval
+ str = RubyVM::InstructionSequence.compile(src, f, f, n, opt).eval
assert_equal("foo-1", str)
assert_predicate(str, :frozen?)
assert_raise_with_message(FrozenError, /created at #{Regexp.quote(f)}:#{n}/) {
str << "x"
}
end
-
- def test_debug_frozen_string_in_array_literal
- src = '["foo"]'; f = "test.rb"; n = 1
- opt = {frozen_string_literal: true, debug_frozen_string_literal: true}
- ary = RubyVM::InstructionSequence.compile(src, f, f, n, **opt).eval
- assert_equal("foo", ary.first)
- assert_predicate(ary.first, :frozen?)
- assert_raise_with_message(FrozenError, /created at #{Regexp.quote(f)}:#{n}/) {
- ary.first << "x"
- } unless ENV['RUBY_ISEQ_DUMP_DEBUG']
- end
end
def test_regexp
@@ -284,24 +266,6 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_equal "literal", h["string"]
end
- def test_hash_literal_frozen
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- def frozen_hash_literal_arg
- {0=>1,1=>4,2=>17}
- end
-
- ObjectSpace.each_object(Hash) do |a|
- if a.class == Hash and !a.default_proc and a.size == 3 &&
- a[0] == 1 && a[1] == 4 && a[2] == 17
- # should not be found.
- raise
- end
- end
- assert_not_include frozen_hash_literal_arg, 3
- end;
- end
-
def test_big_array_and_hash_literal
assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("[#{(1..1_000_000).map{'x'}.join(", ")}]").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems]
assert_normal_exit %q{GC.disable=true; x = nil; raise if eval("[#{(1..1_000_000).to_a.join(", ")}]").size != 1_000_000}, "", timeout: 300, child_env: %[--disable-gems]
@@ -552,12 +516,15 @@ class TestRubyLiteral < Test::Unit::TestCase
}
}
bug2407 = '[ruby-dev:39798]'
- head.grep_v(/^0/) do |s|
- head.grep(/^0/) do |h|
- h = "#{s}#{h}_"
- assert_syntax_error(h, /numeric literal without digits\Z/, "#{bug2407}: #{h.inspect}")
+ head.each {|h|
+ if /^0/ =~ h
+ begin
+ eval("#{h}_")
+ rescue SyntaxError => e
+ assert_match(/numeric literal without digits\Z/, e.message, bug2407)
+ end
end
- end
+ }
end
def test_float
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 6c7d0e6bae..9c7df4cb03 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -365,10 +365,7 @@ class TestM17N < Test::Unit::TestCase
"\u3042".encode("UTF-16LE"),
"\u3042".encode("UTF-16BE"),
].each do |str|
- dump = str.dump
- assert_equal(str, eval(dump), "[ruby-dev:33142]")
- assert_equal(str, dump.undump)
- assert_equal(str, eval("# frozen-string-literal: true\n#{dump}"), '[Bug #14687]')
+ assert_equal(str, eval(str.dump), "[ruby-dev:33142]")
end
end
@@ -615,8 +612,6 @@ class TestM17N < Test::Unit::TestCase
r1 = Regexp.new('\xa1'.force_encoding("ascii-8bit"))
r2 = eval('/\xa1#{r1}/'.force_encoding('ascii-8bit'))
assert_equal(Encoding::ASCII_8BIT, r2.encoding)
-
- [r1, r2]
end
def test_regexp_named_class
@@ -1533,17 +1528,6 @@ class TestM17N < Test::Unit::TestCase
}
end
- def test_setbyte_range
- s = u("\xE3\x81\x82\xE3\x81\x84")
- assert_nothing_raised { s.setbyte(0, -1) }
- assert_nothing_raised { s.setbyte(0, 0x00) }
- assert_nothing_raised { s.setbyte(0, 0x7F) }
- assert_nothing_raised { s.setbyte(0, 0x80) }
- assert_nothing_raised { s.setbyte(0, 0xff) }
- assert_nothing_raised { s.setbyte(0, 0x100) }
- assert_nothing_raised { s.setbyte(0, 0x4f7574206f6620636861722072616e6765) }
- end
-
def test_compatible
assert_nil Encoding.compatible?("",0)
assert_equal(Encoding::UTF_8, Encoding.compatible?(u(""), ua("abc")))
@@ -1582,6 +1566,8 @@ class TestM17N < Test::Unit::TestCase
s = "\u3042"
assert_equal(a("\xE3\x81\x82"), s.b)
assert_equal(Encoding::ASCII_8BIT, s.b.encoding)
+ s.taint
+ assert_predicate(s.b, :tainted?)
s = "abc".b
assert_predicate(s.b, :ascii_only?)
end
@@ -1590,31 +1576,23 @@ class TestM17N < Test::Unit::TestCase
str = "foo"
assert_equal(str, str.scrub)
assert_not_same(str, str.scrub)
+ assert_predicate(str.dup.taint.scrub, :tainted?)
str = "\u3042\u3044"
assert_equal(str, str.scrub)
assert_not_same(str, str.scrub)
+ assert_predicate(str.dup.taint.scrub, :tainted?)
str.force_encoding(Encoding::ISO_2022_JP) # dummy encoding
assert_equal(str, str.scrub)
assert_not_same(str, str.scrub)
assert_nothing_raised(ArgumentError) {str.scrub(nil)}
- end
-
- def test_scrub_modification_inside_block
- str = ("abc\u3042".b << "\xE3\x80".b).force_encoding('UTF-8')
- assert_raise(RuntimeError) {str.scrub{|_| str << "1234567890"; "?" }}
-
- str = "\x00\xD8\x42\x30".force_encoding(Encoding::UTF_16LE)
- assert_raise(RuntimeError) do
- str.scrub do |_|
- str << "1\x002\x00".force_encoding('UTF-16LE')
- "?\x00".force_encoding('UTF-16LE')
- end
- end
+ assert_predicate(str.dup.taint.scrub, :tainted?)
end
def test_scrub_replace_default
assert_equal("\uFFFD\uFFFD\uFFFD", u("\x80\x80\x80").scrub)
assert_equal("\uFFFDA", u("\xF4\x80\x80A").scrub)
+ assert_predicate(u("\x80\x80\x80").taint.scrub, :tainted?)
+ assert_predicate(u("\xF4\x80\x80A").taint.scrub, :tainted?)
# examples in Unicode 6.1.0 D93b
assert_equal("\x41\uFFFD\uFFFD\x41\uFFFD\x41",
@@ -1629,8 +1607,14 @@ class TestM17N < Test::Unit::TestCase
def test_scrub_replace_argument
assert_equal("foo", u("foo").scrub("\u3013"))
+ assert_predicate(u("foo").taint.scrub("\u3013"), :tainted?)
+ assert_not_predicate(u("foo").scrub("\u3013".taint), :tainted?)
assert_equal("\u3042\u3044", u("\xE3\x81\x82\xE3\x81\x84").scrub("\u3013"))
+ assert_predicate(u("\xE3\x81\x82\xE3\x81\x84").taint.scrub("\u3013"), :tainted?)
+ assert_not_predicate(u("\xE3\x81\x82\xE3\x81\x84").scrub("\u3013".taint), :tainted?)
assert_equal("\u3042\u3013", u("\xE3\x81\x82\xE3\x81").scrub("\u3013"))
+ assert_predicate(u("\xE3\x81\x82\xE3\x81").taint.scrub("\u3013"), :tainted?)
+ assert_predicate(u("\xE3\x81\x82\xE3\x81").scrub("\u3013".taint), :tainted?)
assert_raise(Encoding::CompatibilityError){ u("\xE3\x81\x82\xE3\x81").scrub(e("\xA4\xA2")) }
assert_raise(TypeError){ u("\xE3\x81\x82\xE3\x81").scrub(1) }
assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub(u("\x81")) }
@@ -1639,6 +1623,8 @@ class TestM17N < Test::Unit::TestCase
def test_scrub_replace_block
assert_equal("\u3042<e381>", u("\xE3\x81\x82\xE3\x81").scrub{|x|'<'+x.unpack('H*')[0]+'>'})
+ assert_predicate(u("\xE3\x81\x82\xE3\x81").taint.scrub{|x|'<'+x.unpack('H*')[0]+'>'}, :tainted?)
+ assert_predicate(u("\xE3\x81\x82\xE3\x81").scrub{|x|('<'+x.unpack('H*')[0]+'>').taint}, :tainted?)
assert_raise(Encoding::CompatibilityError){ u("\xE3\x81\x82\xE3\x81").scrub{e("\xA4\xA2")} }
assert_raise(TypeError){ u("\xE3\x81\x82\xE3\x81").scrub{1} }
assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub{u("\x81")} }
diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb
index cfb8bff882..99c162a92f 100644
--- a/test/ruby/test_m17n_comb.rb
+++ b/test/ruby/test_m17n_comb.rb
@@ -744,10 +744,6 @@ class TestM17NComb < Test::Unit::TestCase
}
end
- def crypt_supports_des_crypt?
- /openbsd/ !~ RUBY_PLATFORM
- end
-
# glibc 2.16 or later denies salt contained other than [0-9A-Za-z./] #7312
# we use this check to test strict and non-strict behavior separately #11045
strict_crypt = if defined? Etc::CS_GNU_LIBC_VERSION
@@ -764,7 +760,7 @@ class TestM17NComb < Test::Unit::TestCase
}
end
- if !strict_crypt && /openbsd/ !~ RUBY_PLATFORM
+ if !strict_crypt
def test_str_crypt_nonstrict
combination(STRINGS, STRINGS) {|str, salt|
# only test input other than [0-9A-Za-z./] to confirm non-strict behavior
@@ -776,14 +772,9 @@ class TestM17NComb < Test::Unit::TestCase
end
private def confirm_crypt_result(str, salt)
- if crypt_supports_des_crypt?
- if b(salt).length < 2
- assert_raise(ArgumentError) { str.crypt(salt) }
- return
- end
- else
- return if b(salt).length < 2
- salt = "$2a$04$0WVaz0pV3jzfZ5G5tpmH#{salt}"
+ if b(salt).length < 2
+ assert_raise(ArgumentError) { str.crypt(salt) }
+ return
end
t = str.crypt(salt)
assert_equal(b(str).crypt(b(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})")
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 90899fa83f..0565a1c04f 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -189,6 +189,57 @@ class TestMarshal < Test::Unit::TestCase
end
end
+ def test_taint
+ x = Object.new
+ x.taint
+ s = Marshal.dump(x)
+ assert_equal(true, s.tainted?)
+ y = Marshal.load(s)
+ assert_equal(true, y.tainted?)
+ end
+
+ def test_taint_each_object
+ x = Object.new
+ obj = [[x]]
+
+ # clean object causes crean stream
+ assert_equal(false, obj.tainted?)
+ assert_equal(false, obj.first.tainted?)
+ assert_equal(false, obj.first.first.tainted?)
+ s = Marshal.dump(obj)
+ assert_equal(false, s.tainted?)
+
+ # tainted object causes tainted stream
+ x.taint
+ assert_equal(false, obj.tainted?)
+ assert_equal(false, obj.first.tainted?)
+ assert_equal(true, obj.first.first.tainted?)
+ t = Marshal.dump(obj)
+ assert_equal(true, t.tainted?)
+
+ # clean stream causes clean objects
+ assert_equal(false, s.tainted?)
+ y = Marshal.load(s)
+ assert_equal(false, y.tainted?)
+ assert_equal(false, y.first.tainted?)
+ assert_equal(false, y.first.first.tainted?)
+
+ # tainted stream causes tainted objects
+ assert_equal(true, t.tainted?)
+ y = Marshal.load(t)
+ assert_equal(true, y.tainted?)
+ assert_equal(true, y.first.tainted?)
+ assert_equal(true, y.first.first.tainted?)
+
+ # same tests by different senario
+ s.taint
+ assert_equal(true, s.tainted?)
+ y = Marshal.load(s)
+ assert_equal(true, y.tainted?)
+ assert_equal(true, y.first.tainted?)
+ assert_equal(true, y.first.first.tainted?)
+ end
+
def test_symbol2
[:ruby, :"\u{7d05}\u{7389}"].each do |sym|
assert_equal(sym, Marshal.load(Marshal.dump(sym)), '[ruby-core:24788]')
@@ -448,6 +499,16 @@ class TestMarshal < Test::Unit::TestCase
module TestModule
end
+ def test_marshal_load_should_not_taint_classes
+ bug7325 = '[ruby-core:49198]'
+ for c in [TestClass, TestModule]
+ assert_not_predicate(c, :tainted?)
+ c2 = Marshal.load(Marshal.dump(c).taint)
+ assert_same(c, c2)
+ assert_not_predicate(c, :tainted?, bug7325)
+ end
+ end
+
class Bug7627 < Struct.new(:bar)
attr_accessor :foo
@@ -559,6 +620,15 @@ class TestMarshal < Test::Unit::TestCase
assert_equal(Marshal.dump(bare), Marshal.dump(packed))
end
+ def test_untainted_numeric
+ bug8945 = '[ruby-core:57346] [Bug #8945] Numerics never be tainted'
+ b = RbConfig::LIMITS['FIXNUM_MAX'] + 1
+ tainted = [0, 1.0, 1.72723e-77, b].select do |x|
+ Marshal.load(Marshal.dump(x).taint).tainted?
+ end
+ assert_empty(tainted.map {|x| [x, x.class]}, bug8945)
+ end
+
class Bug9523
attr_reader :cc
def marshal_dump
@@ -651,23 +721,6 @@ class TestMarshal < Test::Unit::TestCase
assert_equal(['X', 'X'], Marshal.load(Marshal.dump(obj), ->(v) { v == str ? v.upcase : v }))
end
- def test_marshal_proc_string_encoding
- string = "foo"
- payload = Marshal.dump(string)
- Marshal.load(payload, ->(v) {
- if v.is_a?(String)
- assert_equal(string, v)
- assert_equal(string.encoding, v.encoding)
- end
- v
- })
- end
-
- def test_marshal_proc_freeze
- object = { foo: [42, "bar"] }
- assert_equal object, Marshal.load(Marshal.dump(object), :freeze.to_proc)
- end
-
def test_marshal_load_extended_class_crash
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;
@@ -742,11 +795,7 @@ class TestMarshal < Test::Unit::TestCase
end
def marshal_dump
- if self.foo.baz
- self.foo.remove_instance_variable(:@baz)
- else
- self.foo.baz = :problem
- end
+ self.foo.baz = :problem
{foo: self.foo}
end
@@ -762,26 +811,4 @@ class TestMarshal < Test::Unit::TestCase
Marshal.dump(obj)
end
end
-
- def test_marshal_dump_removing_instance_variable
- obj = Bug15968.new
- obj.baz = :Bug15968
- assert_raise_with_message(RuntimeError, /instance variable removed/) do
- Marshal.dump(obj)
- end
- end
-
- ruby2_keywords def ruby2_keywords_hash(*a)
- a.last
- end
-
- def ruby2_keywords_test(key: 1)
- key
- end
-
- def test_marshal_with_ruby2_keywords_hash
- flagged_hash = ruby2_keywords_hash(key: 42)
- hash = Marshal.load(Marshal.dump(flagged_hash))
- assert_equal(42, ruby2_keywords_test(*[hash]))
- end
end
diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb
index 5cc12bcfeb..f226287442 100644
--- a/test/ruby/test_math.rb
+++ b/test/ruby/test_math.rb
@@ -202,7 +202,6 @@ class TestMath < Test::Unit::TestCase
check(3, Math.cbrt(27))
check(-0.1, Math.cbrt(-0.001))
assert_nothing_raised { assert_infinity(Math.cbrt(1.0/0)) }
- assert_operator(Math.cbrt(1.0 - Float::EPSILON), :<=, 1.0)
end
def test_frexp
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 03a6c560e6..77273dade5 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -22,7 +22,6 @@ class TestMethod < Test::Unit::TestCase
def mo5(a, *b, c) end
def mo6(a, *b, c, &d) end
def mo7(a, b = nil, *c, d, &e) end
- def mo8(a, b = nil, *, d, &e) end
def ma1((a), &b) nil && a end
def mk1(**) end
def mk2(**o) nil && o end
@@ -31,9 +30,6 @@ class TestMethod < Test::Unit::TestCase
def mk5(a, b = nil, **o) nil && o end
def mk6(a, b = nil, c, **o) nil && o end
def mk7(a, b = nil, *c, d, **o) nil && o end
- def mk8(a, b = nil, *c, d, e:, f: nil, **o) nil && o end
- def mnk(**nil) end
- def mf(...) end
class Base
def foo() :base end
@@ -436,29 +432,32 @@ class TestMethod < Test::Unit::TestCase
def test_inspect
o = Object.new
- def o.foo; end; line_no = __LINE__
+ def o.foo; end
m = o.method(:foo)
- assert_equal("#<Method: #{ o.inspect }.foo() #{__FILE__}:#{line_no}>", m.inspect)
+ assert_equal("#<Method: #{ o.inspect }.foo>", m.inspect)
m = o.method(:foo)
- assert_match("#<UnboundMethod: #{ class << o; self; end.inspect }#foo() #{__FILE__}:#{line_no}", m.unbind.inspect)
+ assert_equal("#<UnboundMethod: #{ class << o; self; end.inspect }#foo>", m.unbind.inspect)
c = Class.new
- c.class_eval { def foo; end; }; line_no = __LINE__
+ c.class_eval { def foo; end; }
m = c.new.method(:foo)
- assert_equal("#<Method: #{ c.inspect }#foo() #{__FILE__}:#{line_no}>", m.inspect)
+ assert_equal("#<Method: #{ c.inspect }#foo>", m.inspect)
m = c.instance_method(:foo)
- assert_equal("#<UnboundMethod: #{ c.inspect }#foo() #{__FILE__}:#{line_no}>", m.inspect)
+ assert_equal("#<UnboundMethod: #{ c.inspect }#foo>", m.inspect)
c2 = Class.new(c)
c2.class_eval { private :foo }
m2 = c2.new.method(:foo)
- assert_equal("#<Method: #{ c2.inspect }(#{ c.inspect })#foo() #{__FILE__}:#{line_no}>", m2.inspect)
+ assert_equal("#<Method: #{ c2.inspect }(#{ c.inspect })#foo>", m2.inspect)
bug7806 = '[ruby-core:52048] [Bug #7806]'
c3 = Class.new(c)
c3.class_eval { alias bar foo }
m3 = c3.new.method(:bar)
- assert_equal("#<Method: #{c3.inspect}(#{c.inspect})#bar(foo)() #{__FILE__}:#{line_no}>", m3.inspect, bug7806)
+ assert_equal("#<Method: #{c3.inspect}(#{c.inspect})#bar(foo)>", m3.inspect, bug7806)
+
+ m.taint
+ assert_predicate(m.inspect, :tainted?, "inspect result should be infected")
end
def test_callee_top_level
@@ -496,22 +495,6 @@ class TestMethod < Test::Unit::TestCase
assert_include mmethods, :meth, 'normal methods are public by default'
end
- def test_respond_to_missing_argument
- obj = Struct.new(:mid).new
- def obj.respond_to_missing?(id, *)
- self.mid = id
- true
- end
- assert_kind_of(Method, obj.method("bug15640"))
- assert_kind_of(Symbol, obj.mid)
- assert_equal("bug15640", obj.mid.to_s)
-
- arg = Struct.new(:to_str).new("bug15640_2")
- assert_kind_of(Method, obj.method(arg))
- assert_kind_of(Symbol, obj.mid)
- assert_equal("bug15640_2", obj.mid.to_s)
- end
-
define_method(:pm0) {||}
define_method(:pm1) {|a|}
define_method(:pm2) {|a, b|}
@@ -530,8 +513,6 @@ class TestMethod < Test::Unit::TestCase
define_method(:pmk5) {|a, b = nil, **o|}
define_method(:pmk6) {|a, b = nil, c, **o|}
define_method(:pmk7) {|a, b = nil, *c, d, **o|}
- define_method(:pmk8) {|a, b = nil, *c, d, e:, f: nil, **o|}
- define_method(:pmnk) {|**nil|}
def test_bound_parameters
assert_equal([], method(:m0).parameters)
@@ -544,7 +525,6 @@ class TestMethod < Test::Unit::TestCase
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:mo5).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:mo6).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:mo7).parameters)
- assert_equal([[:req, :a], [:opt, :b], [:rest], [:req, :d], [:block, :e]], method(:mo8).parameters)
assert_equal([[:req], [:block, :b]], method(:ma1).parameters)
assert_equal([[:keyrest]], method(:mk1).parameters)
assert_equal([[:keyrest, :o]], method(:mk2).parameters)
@@ -553,10 +533,6 @@ class TestMethod < Test::Unit::TestCase
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:mk5).parameters)
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:mk6).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:mk7).parameters)
- assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyreq, :e], [:key, :f], [:keyrest, :o]], method(:mk8).parameters)
- assert_equal([[:nokey]], method(:mnk).parameters)
- # pending
- assert_equal([[:rest, :*], [:block, :&]], method(:mf).parameters)
end
def test_unbound_parameters
@@ -570,7 +546,6 @@ class TestMethod < Test::Unit::TestCase
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], self.class.instance_method(:mo5).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:mo6).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:mo7).parameters)
- assert_equal([[:req, :a], [:opt, :b], [:rest], [:req, :d], [:block, :e]], self.class.instance_method(:mo8).parameters)
assert_equal([[:req], [:block, :b]], self.class.instance_method(:ma1).parameters)
assert_equal([[:keyrest]], self.class.instance_method(:mk1).parameters)
assert_equal([[:keyrest, :o]], self.class.instance_method(:mk2).parameters)
@@ -579,10 +554,6 @@ class TestMethod < Test::Unit::TestCase
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:mk5).parameters)
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:mk6).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:mk7).parameters)
- assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyreq, :e], [:key, :f], [:keyrest, :o]], self.class.instance_method(:mk8).parameters)
- assert_equal([[:nokey]], self.class.instance_method(:mnk).parameters)
- # pending
- assert_equal([[:rest, :*], [:block, :&]], self.class.instance_method(:mf).parameters)
end
def test_bmethod_bound_parameters
@@ -604,8 +575,6 @@ class TestMethod < Test::Unit::TestCase
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).parameters)
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).parameters)
- assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyreq, :e], [:key, :f], [:keyrest, :o]], method(:pmk8).parameters)
- assert_equal([[:nokey]], method(:pmnk).parameters)
end
def test_bmethod_unbound_parameters
@@ -628,8 +597,6 @@ class TestMethod < Test::Unit::TestCase
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:pmk5).parameters)
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:pmk6).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:pmk7).parameters)
- assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyreq, :e], [:key, :f], [:keyrest, :o]], self.class.instance_method(:pmk8).parameters)
- assert_equal([[:nokey]], self.class.instance_method(:pmnk).parameters)
end
def test_hidden_parameters
@@ -637,56 +604,6 @@ class TestMethod < Test::Unit::TestCase
assert_empty(method(:m).parameters.map{|_,n|n}.compact)
end
- def test_method_parameters_inspect
- assert_include(method(:m0).inspect, "()")
- assert_include(method(:m1).inspect, "(a)")
- assert_include(method(:m2).inspect, "(a, b)")
- assert_include(method(:mo1).inspect, "(a=..., &b)")
- assert_include(method(:mo2).inspect, "(a, b=...)")
- assert_include(method(:mo3).inspect, "(*a)")
- assert_include(method(:mo4).inspect, "(a, *b, &c)")
- assert_include(method(:mo5).inspect, "(a, *b, c)")
- assert_include(method(:mo6).inspect, "(a, *b, c, &d)")
- assert_include(method(:mo7).inspect, "(a, b=..., *c, d, &e)")
- assert_include(method(:mo8).inspect, "(a, b=..., *, d, &e)")
- assert_include(method(:ma1).inspect, "(_, &b)")
- assert_include(method(:mk1).inspect, "(**)")
- assert_include(method(:mk2).inspect, "(**o)")
- assert_include(method(:mk3).inspect, "(a, **o)")
- assert_include(method(:mk4).inspect, "(a=..., **o)")
- assert_include(method(:mk5).inspect, "(a, b=..., **o)")
- assert_include(method(:mk6).inspect, "(a, b=..., c, **o)")
- assert_include(method(:mk7).inspect, "(a, b=..., *c, d, **o)")
- assert_include(method(:mk8).inspect, "(a, b=..., *c, d, e:, f: ..., **o)")
- assert_include(method(:mnk).inspect, "(**nil)")
- assert_include(method(:mf).inspect, "(...)")
- end
-
- def test_unbound_method_parameters_inspect
- assert_include(self.class.instance_method(:m0).inspect, "()")
- assert_include(self.class.instance_method(:m1).inspect, "(a)")
- assert_include(self.class.instance_method(:m2).inspect, "(a, b)")
- assert_include(self.class.instance_method(:mo1).inspect, "(a=..., &b)")
- assert_include(self.class.instance_method(:mo2).inspect, "(a, b=...)")
- assert_include(self.class.instance_method(:mo3).inspect, "(*a)")
- assert_include(self.class.instance_method(:mo4).inspect, "(a, *b, &c)")
- assert_include(self.class.instance_method(:mo5).inspect, "(a, *b, c)")
- assert_include(self.class.instance_method(:mo6).inspect, "(a, *b, c, &d)")
- assert_include(self.class.instance_method(:mo7).inspect, "(a, b=..., *c, d, &e)")
- assert_include(self.class.instance_method(:mo8).inspect, "(a, b=..., *, d, &e)")
- assert_include(self.class.instance_method(:ma1).inspect, "(_, &b)")
- assert_include(self.class.instance_method(:mk1).inspect, "(**)")
- assert_include(self.class.instance_method(:mk2).inspect, "(**o)")
- assert_include(self.class.instance_method(:mk3).inspect, "(a, **o)")
- assert_include(self.class.instance_method(:mk4).inspect, "(a=..., **o)")
- assert_include(self.class.instance_method(:mk5).inspect, "(a, b=..., **o)")
- assert_include(self.class.instance_method(:mk6).inspect, "(a, b=..., c, **o)")
- assert_include(self.class.instance_method(:mk7).inspect, "(a, b=..., *c, d, **o)")
- assert_include(self.class.instance_method(:mk8).inspect, "(a, b=..., *c, d, e:, f: ..., **o)")
- assert_include(self.class.instance_method(:mnk).inspect, "(**nil)")
- assert_include(self.class.instance_method(:mf).inspect, "(...)")
- end
-
def test_public_method_with_zsuper_method
c = Class.new
c.class_eval do
@@ -734,8 +651,7 @@ class TestMethod < Test::Unit::TestCase
assert_nothing_raised { mv3 }
assert_nothing_raised { self.mv1 }
- assert_nothing_raised { self.mv2 }
- assert_raise(NoMethodError) { (self).mv2 }
+ assert_raise(NoMethodError) { self.mv2 }
assert_nothing_raised { self.mv3 }
v = Visibility.new
@@ -991,36 +907,6 @@ class TestMethod < Test::Unit::TestCase
assert_nil(m.super_method)
end
- def test_super_method_bind_unbind_clone
- bug15629_m1 = Module.new do
- def foo; end
- end
-
- bug15629_m2 = Module.new do
- def foo; end
- end
-
- bug15629_c = Class.new do
- include bug15629_m1
- include bug15629_m2
- end
-
- o = bug15629_c.new
- m = o.method(:foo)
- sm = m.super_method
- im = bug15629_c.instance_method(:foo)
- sim = im.super_method
-
- assert_equal(sm, m.clone.super_method)
- assert_equal(sim, m.unbind.super_method)
- assert_equal(sim, m.unbind.clone.super_method)
- assert_equal(sim, im.clone.super_method)
- assert_equal(sm, m.unbind.bind(o).super_method)
- assert_equal(sm, m.unbind.clone.bind(o).super_method)
- assert_equal(sm, im.bind(o).super_method)
- assert_equal(sm, im.clone.bind(o).super_method)
- end
-
def test_super_method_removed
c1 = Class.new {private def foo; end}
c2 = Class.new(c1) {public :foo}
@@ -1064,108 +950,11 @@ class TestMethod < Test::Unit::TestCase
'[ruby-core:85231] [Bug #14421]'
end
- def test_super_method_alias
- c0 = Class.new do
- def m1
- [:C0_m1]
- end
- def m2
- [:C0_m2]
- end
- end
-
- c1 = Class.new(c0) do
- def m1
- [:C1_m1] + super
- end
- alias m2 m1
- end
-
- c2 = Class.new(c1) do
- def m2
- [:C2_m2] + super
- end
- end
- o1 = c2.new
- assert_equal([:C2_m2, :C1_m1, :C0_m1], o1.m2)
-
- m = o1.method(:m2)
- assert_equal([:C2_m2, :C1_m1, :C0_m1], m.call)
-
- m = m.super_method
- assert_equal([:C1_m1, :C0_m1], m.call)
-
- m = m.super_method
- assert_equal([:C0_m1], m.call)
-
- assert_nil(m.super_method)
- end
-
- def test_super_method_alias_to_prepended_module
- m = Module.new do
- def m1
- [:P_m1] + super
- end
-
- def m2
- [:P_m2] + super
- end
- end
-
- c0 = Class.new do
- def m1
- [:C0_m1]
- end
- end
-
- c1 = Class.new(c0) do
- def m1
- [:C1_m1] + super
- end
- prepend m
- alias m2 m1
- end
-
- o1 = c1.new
- assert_equal([:P_m2, :P_m1, :C1_m1, :C0_m1], o1.m2)
-
- m = o1.method(:m2)
- assert_equal([:P_m2, :P_m1, :C1_m1, :C0_m1], m.call)
-
- m = m.super_method
- assert_equal([:P_m1, :C1_m1, :C0_m1], m.call)
-
- m = m.super_method
- assert_equal([:C1_m1, :C0_m1], m.call)
-
- m = m.super_method
- assert_equal([:C0_m1], m.call)
-
- assert_nil(m.super_method)
- end
-
- # Bug 17780
- def test_super_method_module_alias
- m = Module.new do
- def foo
- end
- alias :f :foo
- end
-
- method = m.instance_method(:f)
- super_method = method.super_method
- assert_nil(super_method)
- end
-
def rest_parameter(*rest)
rest
end
def test_splat_long_array
- if File.exist?('/etc/os-release') && File.read('/etc/os-release').include?('openSUSE Leap')
- # For RubyCI's openSUSE machine http://rubyci.s3.amazonaws.com/opensuseleap/ruby-trunk/recent.html, which tends to die with NoMemoryError here.
- skip 'do not exhaust memory on RubyCI openSUSE Leap machine'
- end
n = 10_000_000
assert_equal n , rest_parameter(*(1..n)).size, '[Feature #10440]'
end
@@ -1257,106 +1046,4 @@ class TestMethod < Test::Unit::TestCase
assert_operator(0.method(:<), :===, 5)
assert_not_operator(0.method(:<), :===, -5)
end
-
- def test_compose_with_method
- c = Class.new {
- def f(x) x * 2 end
- def g(x) x + 1 end
- }
- f = c.new.method(:f)
- g = c.new.method(:g)
-
- assert_equal(6, (f << g).call(2))
- assert_equal(6, (g >> f).call(2))
- end
-
- def test_compose_with_proc
- c = Class.new {
- def f(x) x * 2 end
- }
- f = c.new.method(:f)
- g = proc {|x| x + 1}
-
- assert_equal(6, (f << g).call(2))
- assert_equal(6, (g >> f).call(2))
- end
-
- def test_compose_with_callable
- c = Class.new {
- def f(x) x * 2 end
- }
- c2 = Class.new {
- def call(x) x + 1 end
- }
- f = c.new.method(:f)
- g = c2.new
-
- assert_equal(6, (f << g).call(2))
- assert_equal(5, (f >> g).call(2))
- end
-
- def test_compose_with_noncallable
- c = Class.new {
- def f(x) x * 2 end
- }
- f = c.new.method(:f)
-
- assert_raise(TypeError) {
- f << 5
- }
- assert_raise(TypeError) {
- f >> 5
- }
- end
-
- def test_umethod_bind_call
- foo = Base.instance_method(:foo)
- assert_equal(:base, foo.bind_call(Base.new))
- assert_equal(:base, foo.bind_call(Derived.new))
-
- plus = Integer.instance_method(:+)
- assert_equal(3, plus.bind_call(1, 2))
- end
-
- def test_method_list
- # chkbuild lists all methods.
- # The following code emulate this listing.
-
- # use_symbol = Object.instance_methods[0].is_a?(Symbol)
- nummodule = nummethod = 0
- mods = []
- ObjectSpace.each_object(Module) {|m| mods << m if m.name }
- mods = mods.sort_by {|m| m.name }
- mods.each {|mod|
- nummodule += 1
- mc = mod.kind_of?(Class) ? "class" : "module"
- puts_line = "#{mc} #{mod.name} #{(mod.ancestors - [mod]).inspect}"
- puts_line = puts_line # prevent unused var warning
- mod.singleton_methods(false).sort.each {|methname|
- nummethod += 1
- meth = mod.method(methname)
- line = "#{mod.name}.#{methname} #{meth.arity}"
- line << " not-implemented" if !mod.respond_to?(methname)
- # puts line
- }
- ms = mod.instance_methods(false)
- if true or use_symbol
- ms << :initialize if mod.private_instance_methods(false).include? :initialize
- else
- ms << "initialize" if mod.private_instance_methods(false).include? "initialize"
- end
-
- ms.sort.each {|methname|
- nummethod += 1
- meth = mod.instance_method(methname)
- line = "#{mod.name}\##{methname} #{meth.arity}"
- line << " not-implemented" if /\(not-implemented\)/ =~ meth.inspect
- # puts line
- }
- }
- # puts "#{nummodule} modules, #{nummethod} methods"
-
- assert_operator nummodule, :>, 0
- assert_operator nummethod, :>, 0
- end
end
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 231ccd2072..076ea0901f 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -28,13 +28,10 @@ class TestModule < Test::Unit::TestCase
def setup
@verbose = $VERBOSE
$VERBOSE = nil
- @deprecated = Warning[:deprecated]
- Warning[:deprecated] = true
end
def teardown
$VERBOSE = @verbose
- Warning[:deprecated] = @deprecated
end
def test_LT_0
@@ -297,11 +294,8 @@ class TestModule < Test::Unit::TestCase
end
def test_nested_get
- assert_equal Other, Object.const_get([self.class, 'Other'].join('::'))
+ assert_equal Other, Object.const_get([self.class, Other].join('::'))
assert_equal User::USER, self.class.const_get([User, 'USER'].join('::'))
- assert_raise(NameError) {
- Object.const_get([self.class.name, 'String'].join('::'))
- }
end
def test_nested_get_symbol
@@ -334,7 +328,6 @@ class TestModule < Test::Unit::TestCase
assert_send([Object, :const_defined?, [self.class.name, 'Other'].join('::')])
assert_send([self.class, :const_defined?, 'User::USER'])
assert_not_send([self.class, :const_defined?, 'User::Foo'])
- assert_not_send([Object, :const_defined?, [self.class.name, 'String'].join('::')])
end
def test_nested_defined_symbol
@@ -345,17 +338,6 @@ class TestModule < Test::Unit::TestCase
assert_raise(NameError) {self.class.const_defined?(const)}
end
- def test_nested_defined_inheritance
- assert_send([Object, :const_defined?, [self.class.name, 'User', 'MIXIN'].join('::')])
- assert_send([self.class, :const_defined?, 'User::MIXIN'])
- assert_send([Object, :const_defined?, 'File::SEEK_SET'])
-
- # const_defined? with `false`
- assert_not_send([Object, :const_defined?, [self.class.name, 'User', 'MIXIN'].join('::'), false])
- assert_not_send([self.class, :const_defined?, 'User::MIXIN', false])
- assert_not_send([Object, :const_defined?, 'File::SEEK_SET', false])
- end
-
def test_nested_defined_bad_class
assert_raise(TypeError) do
self.class.const_defined?('User::USER::Foo')
@@ -472,16 +454,6 @@ class TestModule < Test::Unit::TestCase
assert_equal([Comparable, Kernel], String.included_modules - mixins)
end
- def test_include_with_prepend
- c = Class.new{def m; [:c] end}
- p = Module.new{def m; [:p] + super end}
- q = Module.new{def m; [:q] + super end; include p}
- r = Module.new{def m; [:r] + super end; prepend q}
- s = Module.new{def m; [:s] + super end; include r}
- a = Class.new(c){def m; [:a] + super end; prepend p; include s}
- assert_equal([:p, :a, :s, :q, :r, :c], a.new.m)
- end
-
def test_instance_methods
assert_equal([:user, :user2], User.instance_methods(false).sort)
assert_equal([:user, :user2, :mixin].sort, User.instance_methods(true).sort)
@@ -490,48 +462,26 @@ class TestModule < Test::Unit::TestCase
assert_equal([:cClass], (class << CClass; self; end).instance_methods(false))
assert_equal([], (class << BClass; self; end).instance_methods(false))
assert_equal([:cm2], (class << AClass; self; end).instance_methods(false))
+ # Ruby 1.8 feature change:
+ # #instance_methods includes protected methods.
+ #assert_equal([:aClass], AClass.instance_methods(false))
assert_equal([:aClass, :aClass2], AClass.instance_methods(false).sort)
assert_equal([:aClass, :aClass2],
(AClass.instance_methods(true) - Object.instance_methods(true)).sort)
end
def test_method_defined?
- [User, Class.new{include User}, Class.new{prepend User}].each do |klass|
- [[], [true]].each do |args|
- assert !klass.method_defined?(:wombat, *args)
- assert klass.method_defined?(:mixin, *args)
- assert klass.method_defined?(:user, *args)
- assert klass.method_defined?(:user2, *args)
- assert !klass.method_defined?(:user3, *args)
-
- assert !klass.method_defined?("wombat", *args)
- assert klass.method_defined?("mixin", *args)
- assert klass.method_defined?("user", *args)
- assert klass.method_defined?("user2", *args)
- assert !klass.method_defined?("user3", *args)
- end
- end
- end
-
- def test_method_defined_without_include_super
- assert User.method_defined?(:user, false)
- assert !User.method_defined?(:mixin, false)
- assert Mixin.method_defined?(:mixin, false)
+ assert !User.method_defined?(:wombat)
+ assert User.method_defined?(:mixin)
+ assert User.method_defined?(:user)
+ assert User.method_defined?(:user2)
+ assert !User.method_defined?(:user3)
- User.const_set(:FOO, c = Class.new)
-
- c.prepend(User)
- assert !c.method_defined?(:user, false)
- c.define_method(:user){}
- assert c.method_defined?(:user, false)
-
- assert !c.method_defined?(:mixin, false)
- c.define_method(:mixin){}
- assert c.method_defined?(:mixin, false)
-
- assert !c.method_defined?(:userx, false)
- c.define_method(:userx){}
- assert c.method_defined?(:userx, false)
+ assert !User.method_defined?("wombat")
+ assert User.method_defined?("mixin")
+ assert User.method_defined?("user")
+ assert User.method_defined?("user2")
+ assert !User.method_defined?("user3")
end
def module_exec_aux
@@ -576,28 +526,6 @@ class TestModule < Test::Unit::TestCase
assert_equal("Integer", Integer.name)
assert_equal("TestModule::Mixin", Mixin.name)
assert_equal("TestModule::User", User.name)
-
- assert_predicate Integer.name, :frozen?
- assert_predicate Mixin.name, :frozen?
- assert_predicate User.name, :frozen?
- end
-
- def test_accidental_singleton_naming_with_module
- o = Object.new
- assert_nil(o.singleton_class.name)
- class << o
- module Hi; end
- end
- assert_nil(o.singleton_class.name)
- end
-
- def test_accidental_singleton_naming_with_class
- o = Object.new
- assert_nil(o.singleton_class.name)
- class << o
- class Hi; end
- end
- assert_nil(o.singleton_class.name)
end
def test_classpath
@@ -619,8 +547,6 @@ class TestModule < Test::Unit::TestCase
assert_equal(prefix+"N", m.const_get(:N).name)
assert_equal(prefix+"O", m.const_get(:O).name)
assert_equal(prefix+"C", m.const_get(:C).name)
- c = m.class_eval("Bug15891 = Class.new.freeze")
- assert_equal(prefix+"Bug15891", c.name)
end
def test_private_class_method
@@ -740,32 +666,6 @@ class TestModule < Test::Unit::TestCase
assert_equal(false, o.respond_to?(:bar=))
end
- def test_attr_public_at_toplevel
- s = Object.new
- TOPLEVEL_BINDING.eval(<<-END).call(s.singleton_class)
- proc do |c|
- c.send(:attr_accessor, :x)
- c.send(:attr, :y)
- c.send(:attr_reader, :z)
- c.send(:attr_writer, :w)
- end
- END
- assert_nil s.x
- s.x = 1
- assert_equal 1, s.x
-
- assert_nil s.y
- s.instance_variable_set(:@y, 2)
- assert_equal 2, s.y
-
- assert_nil s.z
- s.instance_variable_set(:@z, 3)
- assert_equal 3, s.z
-
- s.w = 4
- assert_equal 4, s.instance_variable_get(:@w)
- end
-
def test_const_get_evaled
c1 = Class.new
c2 = Class.new(c1)
@@ -823,6 +723,10 @@ class TestModule < Test::Unit::TestCase
assert_raise(NameError) { c1.const_get(:foo) }
bug5084 = '[ruby-dev:44200]'
assert_raise(TypeError, bug5084) { c1.const_get(1) }
+ bug7574 = '[ruby-dev:46749]'
+ assert_raise_with_message(NameError, "wrong constant name \"String\\u0000\"", bug7574) {
+ Object.const_get("String\0")
+ }
end
def test_const_defined_invalid_name
@@ -830,6 +734,10 @@ class TestModule < Test::Unit::TestCase
assert_raise(NameError) { c1.const_defined?(:foo) }
bug5084 = '[ruby-dev:44200]'
assert_raise(TypeError, bug5084) { c1.const_defined?(1) }
+ bug7574 = '[ruby-dev:46749]'
+ assert_raise_with_message(NameError, "wrong constant name \"String\\u0000\"", bug7574) {
+ Object.const_defined?("String\0")
+ }
end
def test_const_get_no_inherited
@@ -1069,8 +977,8 @@ class TestModule < Test::Unit::TestCase
end
def test_method_defined
- cl = Class.new
- def_methods = proc do
+ c = Class.new
+ c.class_eval do
def foo; end
def bar; end
def baz; end
@@ -1078,47 +986,33 @@ class TestModule < Test::Unit::TestCase
protected :bar
private :baz
end
- cl.class_eval(&def_methods)
- sc = Class.new(cl)
- mod = Module.new(&def_methods)
- only_prepend = Class.new{prepend(mod)}
- empty_prepend = cl.clone
- empty_prepend.prepend(Module.new)
- overlap_prepend = cl.clone
- overlap_prepend.prepend(mod)
- [[], [true], [false]].each do |args|
- [cl, sc, only_prepend, empty_prepend, overlap_prepend].each do |c|
- always_false = [sc, only_prepend].include?(c) && args == [false]
+ assert_equal(true, c.public_method_defined?(:foo))
+ assert_equal(false, c.public_method_defined?(:bar))
+ assert_equal(false, c.public_method_defined?(:baz))
- assert_equal(always_false ? false : true, c.public_method_defined?(:foo, *args))
- assert_equal(always_false ? false : false, c.public_method_defined?(:bar, *args))
- assert_equal(always_false ? false : false, c.public_method_defined?(:baz, *args))
+ # Test if string arguments are converted to symbols
+ assert_equal(true, c.public_method_defined?("foo"))
+ assert_equal(false, c.public_method_defined?("bar"))
+ assert_equal(false, c.public_method_defined?("baz"))
- # Test if string arguments are converted to symbols
- assert_equal(always_false ? false : true, c.public_method_defined?("foo", *args))
- assert_equal(always_false ? false : false, c.public_method_defined?("bar", *args))
- assert_equal(always_false ? false : false, c.public_method_defined?("baz", *args))
+ assert_equal(false, c.protected_method_defined?(:foo))
+ assert_equal(true, c.protected_method_defined?(:bar))
+ assert_equal(false, c.protected_method_defined?(:baz))
- assert_equal(always_false ? false : false, c.protected_method_defined?(:foo, *args))
- assert_equal(always_false ? false : true, c.protected_method_defined?(:bar, *args))
- assert_equal(always_false ? false : false, c.protected_method_defined?(:baz, *args))
+ # Test if string arguments are converted to symbols
+ assert_equal(false, c.protected_method_defined?("foo"))
+ assert_equal(true, c.protected_method_defined?("bar"))
+ assert_equal(false, c.protected_method_defined?("baz"))
- # Test if string arguments are converted to symbols
- assert_equal(always_false ? false : false, c.protected_method_defined?("foo", *args))
- assert_equal(always_false ? false : true, c.protected_method_defined?("bar", *args))
- assert_equal(always_false ? false : false, c.protected_method_defined?("baz", *args))
+ assert_equal(false, c.private_method_defined?(:foo))
+ assert_equal(false, c.private_method_defined?(:bar))
+ assert_equal(true, c.private_method_defined?(:baz))
- assert_equal(always_false ? false : false, c.private_method_defined?(:foo, *args))
- assert_equal(always_false ? false : false, c.private_method_defined?(:bar, *args))
- assert_equal(always_false ? false : true, c.private_method_defined?(:baz, *args))
-
- # Test if string arguments are converted to symbols
- assert_equal(always_false ? false : false, c.private_method_defined?("foo", *args))
- assert_equal(always_false ? false : false, c.private_method_defined?("bar", *args))
- assert_equal(always_false ? false : true, c.private_method_defined?("baz", *args))
- end
- end
+ # Test if string arguments are converted to symbols
+ assert_equal(false, c.private_method_defined?("foo"))
+ assert_equal(false, c.private_method_defined?("bar"))
+ assert_equal(true, c.private_method_defined?("baz"))
end
def test_top_public_private
@@ -1407,17 +1301,6 @@ class TestModule < Test::Unit::TestCase
assert_match(/: warning: previous definition of foo/, stderr)
end
- def test_module_function_inside_method
- assert_warn(/calling module_function without arguments inside a method may not have the intended effect/, '[ruby-core:79751]') do
- Module.new do
- def self.foo
- module_function
- end
- foo
- end
- end
- end
-
def test_protected_singleton_method
klass = Class.new
x = klass.new
@@ -1542,21 +1425,6 @@ class TestModule < Test::Unit::TestCase
RUBY
end
- def test_private_constant_const_missing
- c = Class.new
- c.const_set(:FOO, "foo")
- c.private_constant(:FOO)
- class << c
- attr_reader :const_missing_arg
- def const_missing(name)
- @const_missing_arg = name
- name == :FOO ? const_get(:FOO) : super
- end
- end
- assert_equal("foo", c::FOO)
- assert_equal(:FOO, c.const_missing_arg)
- end
-
class PrivateClass
end
private_constant :PrivateClass
@@ -1589,31 +1457,10 @@ class TestModule < Test::Unit::TestCase
c = Class.new
c.const_set(:FOO, "foo")
c.deprecate_constant(:FOO)
- assert_warn(/deprecated/) do
- Warning[:deprecated] = true
- c::FOO
- end
- assert_warn(/#{c}::FOO is deprecated/) do
- Warning[:deprecated] = true
- Class.new(c)::FOO
- end
+ assert_warn(/deprecated/) {c::FOO}
+ assert_warn(/#{c}::FOO is deprecated/) {Class.new(c)::FOO}
bug12382 = '[ruby-core:75505] [Bug #12382]'
- assert_warn(/deprecated/, bug12382) do
- Warning[:deprecated] = true
- c.class_eval "FOO"
- end
- assert_warn('') do
- Warning[:deprecated] = false
- c::FOO
- end
- assert_warn('') do
- Warning[:deprecated] = false
- Class.new(c)::FOO
- end
- assert_warn('') do
- Warning[:deprecated] = false
- c.class_eval "FOO"
- end
+ assert_warn(/deprecated/, bug12382) {c.class_eval "FOO"}
end
def test_constants_with_private_constant
@@ -1934,29 +1781,6 @@ class TestModule < Test::Unit::TestCase
assert_equal(0, 1 / 2)
end
- def test_visibility_after_refine_and_visibility_change
- m = Module.new
- c = Class.new do
- def x; :x end
- end
- c.prepend(m)
- Module.new do
- refine c do
- def x; :y end
- end
- end
-
- o1 = c.new
- o2 = c.new
- assert_equal(:x, o1.public_send(:x))
- assert_equal(:x, o2.public_send(:x))
- o1.singleton_class.send(:private, :x)
- o2.singleton_class.send(:public, :x)
-
- assert_raise(NoMethodError) { o1.public_send(:x) }
- assert_equal(:x, o2.public_send(:x))
- end
-
def test_prepend_visibility
bug8005 = '[ruby-core:53106] [Bug #8005]'
c = Class.new do
@@ -2183,13 +2007,17 @@ class TestModule < Test::Unit::TestCase
$foo
\u3042$
].each do |name|
- e = assert_raise(NameError) do
+ assert_raise_with_message(NameError, /#{Regexp.quote(quote(name))}/) do
Module.new { attr_accessor name.to_sym }
end
- assert_equal(name, e.name.to_s)
end
end
+ private def quote(name)
+ encoding = Encoding.default_internal || Encoding.default_external
+ (name.encoding == encoding || name.ascii_only?) ? name : name.inspect
+ end
+
class AttrTest
class << self
attr_accessor :cattr
@@ -2418,7 +2246,7 @@ class TestModule < Test::Unit::TestCase
A.prepend InspectIsShallow
- expect = "#<Method: A(ShallowInspect)#inspect(shallow_inspect)() -:7>"
+ expect = "#<Method: A(ShallowInspect)#inspect(shallow_inspect)>"
assert_equal expect, A.new.method(:inspect).inspect, "#{bug_10282}"
RUBY
end
@@ -2444,17 +2272,15 @@ class TestModule < Test::Unit::TestCase
def test_redefinition_mismatch
m = Module.new
- m.module_eval "A = 1", __FILE__, line = __LINE__
- e = assert_raise_with_message(TypeError, /is not a module/) {
+ m.module_eval "A = 1"
+ assert_raise_with_message(TypeError, /is not a module/) {
m.module_eval "module A; end"
}
- assert_include(e.message, "#{__FILE__}:#{line}: previous definition")
n = "M\u{1f5ff}"
- m.module_eval "#{n} = 42", __FILE__, line = __LINE__
- e = assert_raise_with_message(TypeError, /#{n} is not a module/) {
+ m.module_eval "#{n} = 42"
+ assert_raise_with_message(TypeError, "#{n} is not a module") {
m.module_eval "module #{n}; end"
}
- assert_include(e.message, "#{__FILE__}:#{line}: previous definition")
assert_separately([], <<-"end;")
Etc = (class C\u{1f5ff}; self; end).new
@@ -2482,56 +2308,6 @@ class TestModule < Test::Unit::TestCase
}
end
- ConstLocation = [__FILE__, __LINE__]
-
- def test_const_source_location
- assert_equal(ConstLocation, self.class.const_source_location(:ConstLocation))
- assert_equal(ConstLocation, self.class.const_source_location("ConstLocation"))
- assert_equal(ConstLocation, Object.const_source_location("#{self.class.name}::ConstLocation"))
- assert_raise(TypeError) {
- self.class.const_source_location(nil)
- }
- assert_raise_with_message(NameError, /wrong constant name/) {
- self.class.const_source_location("xxx")
- }
- assert_raise_with_message(TypeError, %r'does not refer to class/module') {
- self.class.const_source_location("ConstLocation::FILE")
- }
- end
-
- module CloneTestM_simple
- C = 1
- def self.m; C; end
- end
-
- module CloneTestM0
- def foo; TEST; end
- end
-
- CloneTestM1 = CloneTestM0.clone
- CloneTestM2 = CloneTestM0.clone
- module CloneTestM1
- TEST = :M1
- end
- module CloneTestM2
- TEST = :M2
- end
- class CloneTestC1
- include CloneTestM1
- end
- class CloneTestC2
- include CloneTestM2
- end
-
- def test_constant_access_from_method_in_cloned_module
- m = CloneTestM_simple.dup
- assert_equal 1, m::C, '[ruby-core:47834]'
- assert_equal 1, m.m, '[ruby-core:47834]'
-
- assert_equal :M1, CloneTestC1.new.foo, '[Bug #15877]'
- assert_equal :M2, CloneTestC2.new.foo, '[Bug #15877]'
- end
-
private
def assert_top_method_is_private(method)
@@ -2540,8 +2316,7 @@ class TestModule < Test::Unit::TestCase
assert_include(methods, :#{method}, ":#{method} should be private")
assert_raise_with_message(NoMethodError, "private method `#{method}' called for main:Object") {
- recv = self
- recv.#{method}
+ self.#{method}
}
}
end
diff --git a/test/ruby/test_not.rb b/test/ruby/test_not.rb
index 12e4c4b696..721f868a5a 100644
--- a/test/ruby/test_not.rb
+++ b/test/ruby/test_not.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
require 'test/unit'
-class TestNot < Test::Unit::TestCase
+class TestIfunless < Test::Unit::TestCase
def test_not_with_grouped_expression
assert_equal(false, (not (true)))
assert_equal(true, (not (false)))
diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb
new file mode 100644
index 0000000000..ddebb657bf
--- /dev/null
+++ b/test/ruby/test_notimp.rb
@@ -0,0 +1,85 @@
+# frozen_string_literal: false
+require 'test/unit'
+require 'timeout'
+require 'tmpdir'
+
+class TestNotImplement < Test::Unit::TestCase
+ def test_respond_to_fork
+ assert_include(Process.methods, :fork)
+ if /linux/ =~ RUBY_PLATFORM
+ assert_equal(true, Process.respond_to?(:fork))
+ end
+ end
+
+ def test_respond_to_lchmod
+ assert_include(File.methods, :lchmod)
+ if /linux/ =~ RUBY_PLATFORM
+ assert_equal(false, File.respond_to?(:lchmod))
+ end
+ if /freebsd/ =~ RUBY_PLATFORM
+ assert_equal(true, File.respond_to?(:lchmod))
+ end
+ end
+
+ def test_call_fork
+ GC.start
+ pid = nil
+ ps =
+ case RUBY_PLATFORM
+ when /linux/ # assume Linux Distribution uses procps
+ proc {`ps -eLf #{pid}`}
+ when /freebsd/
+ proc {`ps -lH #{pid}`}
+ when /darwin/
+ proc {`ps -lM #{pid}`}
+ else
+ proc {`ps -l #{pid}`}
+ end
+ assert_nothing_raised(Timeout::Error, ps) do
+ Timeout.timeout(EnvUtil.apply_timeout_scale(5)) {
+ pid = fork {}
+ Process.wait pid
+ pid = nil
+ }
+ end
+ ensure
+ if pid
+ Process.kill(:KILL, pid)
+ Process.wait pid
+ end
+ end if Process.respond_to?(:fork)
+
+ def test_call_lchmod
+ if File.respond_to?(:lchmod)
+ Dir.mktmpdir {|d|
+ f = "#{d}/f"
+ g = "#{d}/g"
+ File.open(f, "w") {}
+ File.symlink f, g
+ newmode = 0444
+ File.lchmod newmode, "#{d}/g"
+ snew = File.lstat(g)
+ assert_equal(newmode, snew.mode & 0777)
+ }
+ end
+ end
+
+ def test_method_inspect_fork
+ m = Process.method(:fork)
+ if Process.respond_to?(:fork)
+ assert_not_match(/not-implemented/, m.inspect)
+ else
+ assert_match(/not-implemented/, m.inspect)
+ end
+ end
+
+ def test_method_inspect_lchmod
+ m = File.method(:lchmod)
+ if File.respond_to?(:lchmod)
+ assert_not_match(/not-implemented/, m.inspect)
+ else
+ assert_match(/not-implemented/, m.inspect)
+ end
+ end
+
+end
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index 636f827fe3..6efc40320a 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -26,10 +26,6 @@ class TestNumeric < Test::Unit::TestCase
assert_raise_with_message(TypeError, /:"\\u3042"/) {1&:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1|:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"}
- assert_raise_with_message(TypeError, /:\u{3044}/) {1+"\u{3044}".to_sym}
- assert_raise_with_message(TypeError, /:\u{3044}/) {1&"\u{3044}".to_sym}
- assert_raise_with_message(TypeError, /:\u{3044}/) {1|"\u{3044}".to_sym}
- assert_raise_with_message(TypeError, /:\u{3044}/) {1^"\u{3044}".to_sym}
bug10711 = '[ruby-core:67405] [Bug #10711]'
exp = "1.2 can't be coerced into Integer"
@@ -56,6 +52,7 @@ class TestNumeric < Test::Unit::TestCase
end.new
assert_equal(-1, -a)
+ bug7688 = '[ruby-core:51389] [Bug #7688]'
a = Class.new(Numeric) do
def coerce(x); raise StandardError, "my error"; end
end.new
@@ -230,8 +227,7 @@ class TestNumeric < Test::Unit::TestCase
end
def assert_step(expected, (from, *args), inf: false)
- kw = args.last.is_a?(Hash) ? args.pop : {}
- enum = from.step(*args, **kw)
+ enum = from.step(*args)
size = enum.size
xsize = expected.size
@@ -240,7 +236,7 @@ class TestNumeric < Test::Unit::TestCase
assert_send [size, :>, 0], "step size: +infinity"
a = []
- from.step(*args, **kw) { |x| a << x; break if a.size == xsize }
+ from.step(*args) { |x| a << x; break if a.size == xsize }
assert_equal expected, a, "step"
a = []
@@ -250,7 +246,7 @@ class TestNumeric < Test::Unit::TestCase
assert_equal expected.size, size, "step size"
a = []
- from.step(*args, **kw) { |x| a << x }
+ from.step(*args) { |x| a << x }
assert_equal expected, a, "step"
a = []
@@ -264,11 +260,11 @@ class TestNumeric < Test::Unit::TestCase
assert_raise(ArgumentError) { 1.step(10, 1, 0) { } }
assert_raise(ArgumentError) { 1.step(10, 1, 0).size }
assert_raise(ArgumentError) { 1.step(10, 0) { } }
+ assert_raise(ArgumentError) { 1.step(10, 0).size }
assert_raise(ArgumentError) { 1.step(10, "1") { } }
assert_raise(ArgumentError) { 1.step(10, "1").size }
assert_raise(TypeError) { 1.step(10, nil) { } }
- assert_nothing_raised { 1.step(10, 0).size }
- assert_nothing_raised { 1.step(10, nil).size }
+ assert_raise(TypeError) { 1.step(10, nil).size }
assert_nothing_raised { 1.step(by: 0, to: nil) }
assert_nothing_raised { 1.step(by: 0, to: nil).size }
assert_nothing_raised { 1.step(by: 0) }
@@ -276,14 +272,6 @@ class TestNumeric < Test::Unit::TestCase
assert_nothing_raised { 1.step(by: nil) }
assert_nothing_raised { 1.step(by: nil).size }
- assert_kind_of(Enumerator::ArithmeticSequence, 1.step(10))
- assert_kind_of(Enumerator::ArithmeticSequence, 1.step(10, 2))
- assert_kind_of(Enumerator::ArithmeticSequence, 1.step(10, by: 2))
- assert_kind_of(Enumerator::ArithmeticSequence, 1.step(by: 2))
- assert_kind_of(Enumerator::ArithmeticSequence, 1.step(by: 2, to: nil))
- assert_kind_of(Enumerator::ArithmeticSequence, 1.step(by: 2, to: 10))
- assert_kind_of(Enumerator::ArithmeticSequence, 1.step(by: -1))
-
bug9811 = '[ruby-dev:48177] [Bug #9811]'
assert_raise(ArgumentError, bug9811) { 1.step(10, foo: nil) {} }
assert_raise(ArgumentError, bug9811) { 1.step(10, foo: nil).size }
@@ -292,14 +280,6 @@ class TestNumeric < Test::Unit::TestCase
assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11) {} }
assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11).size }
-
- e = assert_warn(/Using the last argument as keyword parameters is deprecated/) {
- 1.step(10, {by: "1"})
- }
- assert_warn('') {
- assert_raise(ArgumentError) {e.size}
- }
-
assert_equal(bignum*2+1, (-bignum).step(bignum, 1).size)
assert_equal(bignum*2, (-bignum).step(bignum-1, 1).size)
@@ -309,6 +289,7 @@ class TestNumeric < Test::Unit::TestCase
i <<= 1 until (bigflo - i).to_i < bignum
bigflo -= i >> 1
assert_equal(bigflo.to_i, (0.0).step(bigflo-1.0, 1.0).size)
+ assert_operator((0.0).step(bignum.to_f, 1.0).size, :>=, bignum) # may loose precision
assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 10]
assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, to: 10]
@@ -351,20 +332,6 @@ class TestNumeric < Test::Unit::TestCase
assert_step [bignum]*4, [bignum, by: 0, to: 0], inf: true
end
- def test_step_bug15537
- assert_step [10.0, 8.0, 6.0, 4.0, 2.0], [10.0, 1, -2]
- assert_step [10.0, 8.0, 6.0, 4.0, 2.0], [10.0, to: 1, by: -2]
- assert_step [10.0, 8.0, 6.0, 4.0, 2.0], [10.0, 1, -2]
- assert_step [10.0, 8.0, 6.0, 4.0, 2.0], [10, to: 1.0, by: -2]
- assert_step [10.0, 8.0, 6.0, 4.0, 2.0], [10, 1.0, -2]
-
- assert_step [10.0, 9.0, 8.0, 7.0], [10, by: -1.0], inf: true
- assert_step [10.0, 9.0, 8.0, 7.0], [10, by: -1.0, to: nil], inf: true
- assert_step [10.0, 9.0, 8.0, 7.0], [10, nil, -1.0], inf: true
- assert_step [10.0, 9.0, 8.0, 7.0], [10.0, by: -1], inf: true
- assert_step [10.0, 9.0, 8.0, 7.0], [10.0, nil, -1], inf: true
- end
-
def test_num2long
assert_raise(TypeError) { 1 & nil }
assert_raise(TypeError) { 1 & 1.0 }
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 442a7551a0..c25dcf9c37 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -96,6 +96,17 @@ class TestObject < Test::Unit::TestCase
assert_raise(TypeError) { 1.kind_of?(1) }
end
+ def test_taint_frozen_obj
+ o = Object.new
+ o.freeze
+ assert_raise(FrozenError) { o.taint }
+
+ o = Object.new
+ o.taint
+ o.freeze
+ assert_raise(FrozenError) { o.untaint }
+ end
+
def test_freeze_immediate
assert_equal(true, 1.frozen?)
1.freeze
@@ -121,27 +132,6 @@ class TestObject < Test::Unit::TestCase
assert_equal(0.0, nil.to_f)
end
- def test_nil_to_s
- str = nil.to_s
- assert_equal("", str)
- assert_predicate(str, :frozen?)
- assert_same(str, nil.to_s)
- end
-
- def test_true_to_s
- str = true.to_s
- assert_equal("true", str)
- assert_predicate(str, :frozen?)
- assert_same(str, true.to_s)
- end
-
- def test_false_to_s
- str = false.to_s
- assert_equal("false", str)
- assert_predicate(str, :frozen?)
- assert_same(str, false.to_s)
- end
-
def test_not
assert_equal(false, Object.new.send(:!))
assert_equal(true, nil.send(:!))
@@ -237,14 +227,6 @@ class TestObject < Test::Unit::TestCase
assert_equal([:foo], o.methods(false), bug8044)
end
- def test_methods_prepend_singleton
- c = Class.new(Module) {private def foo; end}
- k = c.new
- k.singleton_class
- c.module_eval {prepend(Module.new)}
- assert_equal([:foo], k.private_methods(false))
- end
-
def test_instance_variable_get
o = Object.new
o.instance_eval { @foo = :foo }
@@ -783,7 +765,36 @@ class TestObject < Test::Unit::TestCase
end
end
+ def test_untrusted
+ verbose = $VERBOSE
+ $VERBOSE = false
+ begin
+ obj = Object.new
+ assert_equal(false, obj.untrusted?)
+ assert_equal(false, obj.tainted?)
+ obj.untrust
+ assert_equal(true, obj.untrusted?)
+ assert_equal(true, obj.tainted?)
+ obj.trust
+ assert_equal(false, obj.untrusted?)
+ assert_equal(false, obj.tainted?)
+ obj.taint
+ assert_equal(true, obj.untrusted?)
+ assert_equal(true, obj.tainted?)
+ obj.untaint
+ assert_equal(false, obj.untrusted?)
+ assert_equal(false, obj.tainted?)
+ ensure
+ $VERBOSE = verbose
+ end
+ end
+
def test_to_s
+ x = Object.new
+ x.taint
+ s = x.to_s
+ assert_equal(true, s.tainted?)
+
x = eval(<<-EOS)
class ToS\u{3042}
new.to_s
@@ -792,10 +803,14 @@ class TestObject < Test::Unit::TestCase
assert_match(/\bToS\u{3042}:/, x)
name = "X".freeze
- x = Object.new
+ x = Object.new.taint
class<<x;self;end.class_eval {define_method(:to_s) {name}}
assert_same(name, x.to_s)
+ assert_not_predicate(name, :tainted?)
+ assert_raise(FrozenError) {name.taint}
assert_equal("X", [x].join(""))
+ assert_not_predicate(name, :tainted?)
+ assert_not_predicate(eval('"X".freeze'), :tainted?)
end
def test_inspect
@@ -842,29 +857,6 @@ class TestObject < Test::Unit::TestCase
assert_match(/@\u{3046}=6\b/, x.inspect)
end
- def test_singleton_methods
- assert_equal([], Object.new.singleton_methods)
- assert_equal([], Object.new.singleton_methods(false))
- c = Class.new
- def c.foo; end
- assert_equal([:foo], c.singleton_methods - [:yaml_tag])
- assert_equal([:foo], c.singleton_methods(false))
- assert_equal([], c.singleton_class.singleton_methods(false))
- c.singleton_class.singleton_class
- assert_equal([], c.singleton_class.singleton_methods(false))
-
- o = c.new.singleton_class
- assert_equal([:foo], o.singleton_methods - [:yaml_tag])
- assert_equal([], o.singleton_methods(false))
- o.singleton_class
- assert_equal([:foo], o.singleton_methods - [:yaml_tag])
- assert_equal([], o.singleton_methods(false))
-
- c.extend(Module.new{def bar; end})
- assert_equal([:bar, :foo], c.singleton_methods.sort - [:yaml_tag])
- assert_equal([:foo], c.singleton_methods(false))
- end
-
def test_singleton_class
x = Object.new
xs = class << x; self; end
@@ -891,7 +883,6 @@ class TestObject < Test::Unit::TestCase
['ArgumentError.new("bug5473")', 'ArgumentError, "bug5473"', '"bug5473"'].each do |code|
exc = code[/\A[A-Z]\w+/] || 'RuntimeError'
assert_separately([], <<-SRC)
- $VERBOSE = nil
class ::Object
def method_missing(m, *a, &b)
raise #{code}
@@ -909,7 +900,7 @@ class TestObject < Test::Unit::TestCase
assert_nothing_raised("copy") {a.instance_eval {initialize_copy(b)}}
c = a.dup.freeze
assert_raise(FrozenError, "frozen") {c.instance_eval {initialize_copy(b)}}
- d = a.dup
+ d = a.dup.trust
[a, b, c, d]
end
diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb
index 02c20aa261..c352b75b70 100644
--- a/test/ruby/test_objectspace.rb
+++ b/test/ruby/test_objectspace.rb
@@ -35,36 +35,6 @@ End
deftest_id2ref(false)
deftest_id2ref(nil)
- def test_id2ref_liveness
- assert_normal_exit <<-EOS
- ids = []
- 10.times{
- 1_000.times{
- ids << 'hello'.object_id
- }
- objs = ids.map{|id|
- begin
- ObjectSpace._id2ref(id)
- rescue RangeError
- nil
- end
- }
- GC.start
- objs.each{|e| e.inspect}
- }
- EOS
- end
-
- def test_id2ref_invalid_argument
- msg = /no implicit conversion/
- assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(nil)}
- assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(false)}
- assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(true)}
- assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(:a)}
- assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref("0")}
- assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(Object.new)}
- end
-
def test_count_objects
h = {}
ObjectSpace.count_objects(h)
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index b42314b765..2a4cc19699 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -187,16 +187,6 @@ class TestRubyOptimization < Test::Unit::TestCase
assert_redefine_method('String', '<<', 'assert_equal "b", "a" << "b"')
end
- def test_fixnum_and
- assert_equal 1, 1&3
- assert_redefine_method('Integer', '&', 'assert_equal 3, 1&3')
- end
-
- def test_fixnum_or
- assert_equal 3, 1|3
- assert_redefine_method('Integer', '|', 'assert_equal 1, 3|1')
- end
-
def test_array_plus
assert_equal [1,2], [1]+[2]
assert_redefine_method('Array', '+', 'assert_equal [2], [1]+[2]')
@@ -272,7 +262,7 @@ class TestRubyOptimization < Test::Unit::TestCase
unless file
loc, = caller_locations(1, 1)
file = loc.path
- line ||= loc.lineno + 1
+ line ||= loc.lineno
end
RubyVM::InstructionSequence.new("proc {|_|_.class_eval {#{src}}}",
file, (path || file), line,
@@ -347,7 +337,7 @@ class TestRubyOptimization < Test::Unit::TestCase
def test_tailcall_inhibited_by_rescue
bug12082 = '[ruby-core:73871] [Bug #12082]'
- EnvUtil.suppress_warning {tailcall("#{<<-"begin;"}\n#{<<~"end;"}")}
+ tailcall("#{<<-"begin;"}\n#{<<~"end;"}")
begin;
def to_be_rescued
return do_raise
@@ -398,7 +388,7 @@ class TestRubyOptimization < Test::Unit::TestCase
foo
end;1
end;
- status, _err = EnvUtil.invoke_ruby([], "", true, true, **{}) {
+ status, _err = EnvUtil.invoke_ruby([], "", true, true, {}) {
|in_p, out_p, err_p, pid|
in_p.write(script)
in_p.close
@@ -425,7 +415,7 @@ class TestRubyOptimization < Test::Unit::TestCase
def test_tailcall_condition_block
bug = '[ruby-core:78015] [Bug #12905]'
- src = "#{<<-"begin;"}\n#{<<~"end;"}", __FILE__, nil, __LINE__+1
+ src = "#{<<-"begin;"}\n#{<<~"end;"}"
begin;
def run(current, final)
if current < final
@@ -437,13 +427,13 @@ class TestRubyOptimization < Test::Unit::TestCase
end;
obj = Object.new
- self.class.tailcall(obj.singleton_class, *src, tailcall: false)
+ self.class.tailcall(obj.singleton_class, src, tailcall: false)
e = assert_raise(SystemStackError) {
obj.run(1, Float::INFINITY)
}
level = e.backtrace_locations.size
obj = Object.new
- self.class.tailcall(obj.singleton_class, *src, tailcall: true)
+ self.class.tailcall(obj.singleton_class, src, tailcall: true)
level *= 2
mesg = message {"#{bug}: #{$!.backtrace_locations.size} / #{level} stack levels"}
assert_nothing_raised(SystemStackError, mesg) {
@@ -451,22 +441,6 @@ class TestRubyOptimization < Test::Unit::TestCase
}
end
- def test_tailcall_not_to_grow_stack
- skip 'currently JIT-ed code always creates a new stack frame' if RubyVM::MJIT.enabled?
- bug16161 = '[ruby-core:94881]'
-
- tailcall("#{<<-"begin;"}\n#{<<~"end;"}")
- begin;
- def foo(n)
- return :ok if n < 1
- foo(n - 1)
- end
- end;
- assert_nothing_raised(SystemStackError, bug16161) do
- assert_equal(:ok, foo(1_000_000), bug16161)
- end
- end
-
class Bug10557
def [](_)
block_given?
@@ -583,30 +557,12 @@ class TestRubyOptimization < Test::Unit::TestCase
when "1.8.0"..."1.8.8" then :bar
end
end;
- [ true, false ].each do |opt|
- iseq = RubyVM::InstructionSequence.compile(code,
- frozen_string_literal: opt)
- insn = iseq.disasm
- assert_match %r{putobject\s+#{Regexp.quote('"1.8.0"..."1.8.8"')}}, insn
- assert_match %r{putobject\s+#{Regexp.quote('"2.0.0".."2.3.2"')}}, insn
- assert_no_match(/putstring/, insn)
- assert_no_match(/newrange/, insn)
- end
- end
-
- def test_peephole_dstr
- code = "#{<<~'begin;'}\n#{<<~'end;'}"
- begin;
- exp = -'a'
- z = 'a'
- [exp, -"#{z}"]
- end;
- [ false, true ].each do |fsl|
- iseq = RubyVM::InstructionSequence.compile(code,
- frozen_string_literal: fsl)
- assert_same(*iseq.eval,
- "[ruby-core:85542] [Bug #14475] fsl: #{fsl}")
- end
+ iseq = RubyVM::InstructionSequence.compile(code)
+ insn = iseq.disasm
+ assert_match %r{putobject\s+#{Regexp.quote('"1.8.0"..."1.8.8"')}}, insn
+ assert_match %r{putobject\s+#{Regexp.quote('"2.0.0".."2.3.2"')}}, insn
+ assert_no_match(/putstring/, insn)
+ assert_no_match(/newrange/, insn)
end
def test_branch_condition_backquote
@@ -714,6 +670,17 @@ class TestRubyOptimization < Test::Unit::TestCase
END
end
+ def test_block_parameter_should_restore_safe_level
+ assert_separately [], <<-END
+ #
+ def foo &b
+ $SAFE = 1
+ b.call
+ end
+ assert_equal 0, foo{$SAFE}
+ END
+ end
+
def test_peephole_optimization_without_trace
assert_separately [], <<-END
RubyVM::InstructionSequence.compile_option = {trace_instruction: false}
@@ -722,7 +689,7 @@ class TestRubyOptimization < Test::Unit::TestCase
end
def test_clear_unreachable_keyword_args
- assert_separately [], <<-END, timeout: 60
+ assert_separately [], <<-END, timeout: 15
script = <<-EOS
if true
else
@@ -756,7 +723,6 @@ class TestRubyOptimization < Test::Unit::TestCase
h = {}
assert_equal(bug, eval('{ok: 42, **h}; bug'))
assert_equal(:ok, eval('{ok: bug = :ok, **h}; bug'))
- assert_empty(h)
end
def test_overwritten_blockparam
@@ -769,18 +735,6 @@ class TestRubyOptimization < Test::Unit::TestCase
assert_equal(:ok, obj.a())
end
- def test_blockparam_in_rescue
- obj = Object.new
- def obj.foo(&b)
- raise
- rescue
- b.call
- end
- result = nil
- assert_equal(42, obj.foo {result = 42})
- assert_equal(42, result)
- end
-
def test_unconditional_branch_to_leave_block
assert_valid_syntax("#{<<~"begin;"}\n#{<<~'end;'}")
begin;
@@ -830,19 +784,4 @@ class TestRubyOptimization < Test::Unit::TestCase
}
end;
end
-
- def test_optimized_rescue
- assert_in_out_err("", "#{<<~"begin;"}\n#{<<~'end;'}", [], /END \(RuntimeError\)/)
- begin;
- if false
- begin
- require "some_mad_stuff"
- rescue LoadError
- puts "no mad stuff loaded"
- end
- end
-
- raise "END"
- end;
- end
end
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index 60edd00186..aec418913e 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -428,7 +428,6 @@ class TestPack < Test::Unit::TestCase
assert_operator(4, :<=, [1].pack("L!").bytesize)
end
- require 'rbconfig'
def test_pack_unpack_qQ
s1 = [578437695752307201, -506097522914230529].pack("q*")
s2 = [578437695752307201, 17940646550795321087].pack("Q*")
@@ -438,7 +437,6 @@ class TestPack < Test::Unit::TestCase
# Note: q! and Q! should not work on platform which has no long long type.
# Is there a such platform now?
- # @shyouhei: Yes. gcc -ansi is one of such platform.
s1 = [578437695752307201, -506097522914230529].pack("q!*")
s2 = [578437695752307201, 17940646550795321087].pack("Q!*")
assert_equal([578437695752307201, -506097522914230529], s2.unpack("q!*"))
@@ -448,7 +446,7 @@ class TestPack < Test::Unit::TestCase
assert_equal(8, [1].pack("Q").bytesize)
assert_operator(8, :<=, [1].pack("q!").bytesize)
assert_operator(8, :<=, [1].pack("Q!").bytesize)
- end if RbConfig::CONFIG['HAVE_LONG_LONG']
+ end
def test_pack_unpack_jJ
# Note: we assume that the size of intptr_t and uintptr_t equals to the size
@@ -802,13 +800,6 @@ EXPECTED
assert_warning(/\A(.* in '\u{3042}'\n)+\z/) {
[].pack("\u{3042}")
}
-
- assert_warning(/\A.* in '.*U'\Z/) {
- assert_equal "\000", [0].pack("\0U")
- }
- assert_warning(/\A.* in '.*U'\Z/) {
- "\000".unpack("\0U")
- }
end
def test_pack_resize
@@ -869,4 +860,20 @@ EXPECTED
assert_equal "hogefuga", "aG9nZWZ1Z2E=".unpack1("m")
assert_equal "01000001", "A".unpack1("B*")
end
+
+ def test_pack_infection
+ tainted_array_string = ["123456"]
+ tainted_array_string.first.taint
+ ['a', 'A', 'Z', 'B', 'b', 'H', 'h', 'u', 'M', 'm', 'P', 'p'].each do |f|
+ assert_predicate(tainted_array_string.pack(f), :tainted?)
+ end
+ end
+
+ def test_unpack_infection
+ tainted_string = "123456"
+ tainted_string.taint
+ ['a', 'A', 'Z', 'B', 'b', 'H', 'h', 'u', 'M', 'm'].each do |f|
+ assert_predicate(tainted_string.unpack(f).first, :tainted?)
+ end
+ end
end
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index 1e909bce1b..b725634a38 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -13,24 +13,21 @@ class TestParse < Test::Unit::TestCase
$VERBOSE = @verbose
end
- def test_error_line
- assert_syntax_error('------,,', /\n\z/, 'Message to pipe should end with a newline')
- end
-
def test_else_without_rescue
- assert_syntax_error(<<-END, %r":#{__LINE__+2}: else without rescue"o, [__FILE__, __LINE__+1])
+ x = eval <<-END, nil, __FILE__, __LINE__+1
begin
else
42
end
END
+ assert_equal(42, x)
end
def test_alias_backref
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /can't make alias/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
alias $foo $1
- end;
+ END
end
end
@@ -85,10 +82,10 @@ class TestParse < Test::Unit::TestCase
assert_equal([42, 42], [o.Foo, o.Bar])
assert_equal([42, 42], [o::baz, o::qux])
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /Can't set variable/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
$1 ||= t.foo 42
- end;
+ END
end
def t.bar(x); x + yield; end
@@ -153,65 +150,67 @@ class TestParse < Test::Unit::TestCase
end
def test_dynamic_constant_assignment
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /dynamic constant/) do
- begin;
+ assert_raise(SyntaxError) do
+ Object.new.instance_eval <<-END, __FILE__, __LINE__+1
def foo
self::FOO, self::BAR = 1, 2
::FOO, ::BAR = 1, 2
end
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /Can't set variable/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
$1, $2 = 1, 2
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /dynamic constant/) do
- begin;
+ assert_raise(SyntaxError) do
+ Object.new.instance_eval <<-END, __FILE__, __LINE__+1
def foo
::FOO = 1
end
- end;
+ END
end
c = Class.new
c.freeze
- assert_valid_syntax("#{<<~"begin;"}\n#{<<~'end;'}") do
- begin;
+ assert_nothing_raised(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+ if false
c::FOO &= 1
::FOO &= 1
- end;
+ end
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /Can't set variable/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
$1 &= 1
- end;
+ END
end
end
def test_class_module
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /must be CONSTANT/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
class foo; end
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /in method body/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
def foo
class Foo; end
module Bar; end
end
- end;
+ END
end
- assert_valid_syntax("#{<<~"begin;"}\n#{<<~'end;'}") do
- begin;
+ assert_nothing_raised(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
class Foo 1; end
- end;
+ END
end
end
@@ -271,34 +270,37 @@ class TestParse < Test::Unit::TestCase
end
def test_bad_arg
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /cannot be a constant/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
def foo(FOO); end
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /cannot be an instance variable/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
def foo(@foo); end
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /cannot be a global variable/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
def foo($foo); end
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /cannot be a class variable/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
def foo(@@foo); end
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /cannot be an instance variable/) do
- begin;
- o.foo {|; @a| @a = 42 }
- end;
+ o = Object.new
+ def o.foo(*r); yield(*r); end
+
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+ o.foo 1 {|; @a| @a = 42 }
+ END
end
end
@@ -350,7 +352,6 @@ class TestParse < Test::Unit::TestCase
def test_words
assert_equal([], %W( ))
- assert_syntax_error('%w[abc', /unterminated list/)
end
def test_dstr
@@ -358,12 +359,11 @@ class TestParse < Test::Unit::TestCase
assert_equal("foo 1 bar", "foo #@@foo bar")
"1" =~ /(.)/
assert_equal("foo 1 bar", "foo #$1 bar")
- assert_equal('foo #@1 bar', eval('"foo #@1 bar"'))
end
def test_dstr_disallowed_variable
bug8375 = '[ruby-core:54885] [Bug #8375]'
- %w[@ @. @@ @@1 @@. $ $%].each do |src|
+ %w[@ @1 @. @@ @@1 @@. $ $%].each do |src|
src = '#'+src+' '
str = assert_nothing_raised(SyntaxError, "#{bug8375} #{src.dump}") do
break eval('"'+src+'"')
@@ -376,25 +376,23 @@ class TestParse < Test::Unit::TestCase
assert_nothing_raised { eval(':""') }
end
- def assert_disallowed_variable(type, noname, invalid)
- noname.each do |name|
- assert_syntax_error("proc{a = #{name} }", "`#{noname[0]}' without identifiers is not allowed as #{type} variable name")
- end
+ def assert_disallowed_variable(type, noname, *invalid)
+ assert_syntax_error(noname, "`#{noname}' without identifiers is not allowed as #{type} variable name")
invalid.each do |name|
- assert_syntax_error("proc {a = #{name} }", "`#{name}' is not allowed as #{type} variable name")
+ assert_syntax_error(name, "`#{name}' is not allowed as #{type} variable name")
end
end
def test_disallowed_instance_variable
- assert_disallowed_variable("an instance", %w[@ @.], %w[])
+ assert_disallowed_variable("an instance", *%w[@ @1 @.])
end
def test_disallowed_class_variable
- assert_disallowed_variable("a class", %w[@@ @@.], %w[@@1])
+ assert_disallowed_variable("a class", *%w[@@ @@1 @@.])
end
def test_disallowed_gloal_variable
- assert_disallowed_variable("a global", %w[$], %w[$%])
+ assert_disallowed_variable("a global", *%w[$ $%])
end
def test_arg2
@@ -432,56 +430,31 @@ class TestParse < Test::Unit::TestCase
end
def test_duplicate_argument
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", '') do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
1.times {|&b?| }
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /duplicated argument/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
1.times {|a, a|}
- end;
+ END
end
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /duplicated argument/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
def foo(a, a); end
- end;
+ END
end
end
def test_define_singleton_error
- assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /singleton method for literals/) do
- begin;
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
def ("foo").foo; end
- end;
- end
- end
-
- def test_op_asgn1_with_block
- t = Object.new
- a = []
- blk = proc {|x| a << x }
- def t.[](_)
- yield(:aref)
- nil
- end
- def t.[]=(_, _)
- yield(:aset)
- end
- def t.dummy(_)
+ END
end
- eval <<-END, nil, __FILE__, __LINE__+1
- t[42, &blk] ||= 42
- END
- assert_equal([:aref, :aset], a)
- a.clear
- eval <<-END, nil, __FILE__, __LINE__+1
- t[42, &blk] ||= t.dummy 42 # command_asgn test
- END
- assert_equal([:aref, :aset], a)
- blk
end
def test_backquote
@@ -514,13 +487,13 @@ class TestParse < Test::Unit::TestCase
mesg = 'from the backslash through the invalid char'
e = assert_syntax_error('"\xg1"', /hex escape/)
- assert_equal(' ^~'"\n", e.message.lines.last, mesg)
+ assert_equal(' ^', e.message.lines.last, mesg)
e = assert_syntax_error('"\u{1234"', 'unterminated Unicode escape')
- assert_equal(' ^'"\n", e.message.lines.last, mesg)
+ assert_equal(' ^', e.message.lines.last, mesg)
e = assert_syntax_error('"\u{xxxx}"', 'invalid Unicode escape')
- assert_equal(' ^'"\n", e.message.lines.last, mesg)
+ assert_equal(' ^', e.message.lines.last, mesg)
e = assert_syntax_error('"\u{xxxx', 'Unicode escape')
assert_pattern_list([
@@ -531,14 +504,14 @@ class TestParse < Test::Unit::TestCase
/ \^/,
/\n/,
/.*: unterminated string.*\n.*\n/,
- / \^\n/,
+ / \^/,
], e.message)
e = assert_syntax_error('"\M1"', /escape character syntax/)
- assert_equal(' ^~~'"\n", e.message.lines.last, mesg)
+ assert_equal(' ^~~', e.message.lines.last, mesg)
e = assert_syntax_error('"\C1"', /escape character syntax/)
- assert_equal(' ^~~'"\n", e.message.lines.last, mesg)
+ assert_equal(' ^~~', e.message.lines.last, mesg)
src = '"\xD0\u{90'"\n""000000000000000000000000"
assert_syntax_error(src, /:#{__LINE__}: unterminated/o)
@@ -549,56 +522,27 @@ class TestParse < Test::Unit::TestCase
assert_equal("\x81", eval('"\C-\M-a"'))
assert_equal("\177", eval('"\c?"'))
-
- assert_warning(/use \\C-\\s/) {assert_equal("\x00", eval('"\C- "'))}
- assert_warning(/use \\M-\\s/) {assert_equal("\xa0", eval('"\M- "'))}
- assert_warning(/use \\M-\\C-\\s/) {assert_equal("\x80", eval('"\M-\C- "'))}
- assert_warning(/use \\C-\\M-\\s/) {assert_equal("\x80", eval('"\C-\M- "'))}
- assert_warning(/use \\t/) {assert_equal("\x09", eval("\"\\C-\t\""))}
- assert_warning(/use \\M-\\t/) {assert_equal("\x89", eval("\"\\M-\t\""))}
- assert_warning(/use \\M-\\t/) {assert_equal("\x89", eval("\"\\M-\\C-\t\""))}
- assert_warning(/use \\M-\\t/) {assert_equal("\x89", eval("\"\\C-\\M-\t\""))}
- assert_syntax_error("\"\\C-\x01\"", 'Invalid escape character syntax')
- assert_syntax_error("\"\\M-\x01\"", 'Invalid escape character syntax')
- assert_syntax_error("\"\\M-\\C-\x01\"", 'Invalid escape character syntax')
- assert_syntax_error("\"\\C-\\M-\x01\"", 'Invalid escape character syntax')
end
def test_question
- assert_syntax_error('?', /incomplete/)
- assert_syntax_error('? ', /unexpected/)
- assert_syntax_error("?\n", /unexpected/)
- assert_syntax_error("?\t", /unexpected/)
- assert_syntax_error("?\v", /unexpected/)
- assert_syntax_error("?\r", /unexpected/)
- assert_syntax_error("?\f", /unexpected/)
- assert_syntax_error(" ?a\x8a".force_encoding("utf-8"), /invalid multibyte/)
+ assert_raise(SyntaxError) { eval('?') }
+ assert_raise(SyntaxError) { eval('? ') }
+ assert_raise(SyntaxError) { eval("?\n") }
+ assert_raise(SyntaxError) { eval("?\t") }
+ assert_raise(SyntaxError) { eval("?\v") }
+ assert_raise(SyntaxError) { eval("?\r") }
+ assert_raise(SyntaxError) { eval("?\f") }
+ assert_raise(SyntaxError) { eval("?\f") }
+ assert_raise(SyntaxError) { eval(" ?a\x8a".force_encoding("utf-8")) }
assert_equal("\u{1234}", eval("?\u{1234}"))
assert_equal("\u{1234}", eval('?\u{1234}'))
- assert_equal("\u{1234}", eval('?\u1234'))
- assert_syntax_error('?\u{41 42}', 'Multiple codepoints at single character literal')
- e = assert_syntax_error('"#{?\u123}"', 'invalid Unicode escape')
- assert_not_match(/end-of-input/, e.message)
-
- assert_warning(/use ?\\C-\\s/) {assert_equal("\x00", eval('?\C- '))}
- assert_warning(/use ?\\M-\\s/) {assert_equal("\xa0", eval('?\M- '))}
- assert_warning(/use ?\\M-\\C-\\s/) {assert_equal("\x80", eval('?\M-\C- '))}
- assert_warning(/use ?\\C-\\M-\\s/) {assert_equal("\x80", eval('?\C-\M- '))}
- assert_warning(/use ?\\t/) {assert_equal("\x09", eval("?\\C-\t"))}
- assert_warning(/use ?\\M-\\t/) {assert_equal("\x89", eval("?\\M-\t"))}
- assert_warning(/use ?\\M-\\t/) {assert_equal("\x89", eval("?\\M-\\C-\t"))}
- assert_warning(/use ?\\M-\\t/) {assert_equal("\x89", eval("?\\C-\\M-\t"))}
- assert_syntax_error("?\\C-\x01", 'Invalid escape character syntax')
- assert_syntax_error("?\\M-\x01", 'Invalid escape character syntax')
- assert_syntax_error("?\\M-\\C-\x01", 'Invalid escape character syntax')
- assert_syntax_error("?\\C-\\M-\x01", 'Invalid escape character syntax')
end
def test_percent
assert_equal(:foo, eval('%s(foo)'))
- assert_syntax_error('%s', /unterminated quoted string/)
- assert_syntax_error('%ss', /unknown type/)
- assert_syntax_error('%z()', /unknown type/)
+ assert_raise(SyntaxError) { eval('%s') }
+ assert_raise(SyntaxError) { eval('%ss') }
+ assert_raise(SyntaxError) { eval('%z()') }
end
def test_symbol
@@ -617,21 +561,24 @@ class TestParse < Test::Unit::TestCase
assert_equal(:foobar, eval(':"foo\u{}bar"'))
assert_equal(:foobar, eval(':"foo\u{ }bar"'))
end
-
- assert_syntax_error(':@@', /is not allowed/)
- assert_syntax_error(':@@1', /is not allowed/)
- assert_syntax_error(':@', /is not allowed/)
- assert_syntax_error(':@1', /is not allowed/)
end
def test_parse_string
- assert_syntax_error("/\n", /unterminated/)
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+/
+ END
+ end
end
def test_here_document
x = nil
- assert_syntax_error("<\<FOO\n", /can't find string "FOO"/)
+ assert_raise(SyntaxError) do
+ eval %Q(
+<\<FOO
+ )
+ end
assert_nothing_raised(SyntaxError) do
x = eval %q(
@@ -642,11 +589,23 @@ FOO
end
assert_equal "\#$\n", x
- assert_syntax_error("<\<\"\n", /unterminated here document identifier/)
+ assert_raise(SyntaxError) do
+ eval %Q(
+<\<\"
+ )
+ end
- assert_syntax_error("<<``\n", /can't find string ""/)
+ assert_raise(SyntaxError) do
+ eval %q(
+<<``
+ )
+ end
- assert_syntax_error("<<--\n", /unexpected <</)
+ assert_raise(SyntaxError) do
+ eval %q(
+<<--
+ )
+ end
assert_nothing_raised(SyntaxError) do
x = eval %q(
@@ -709,22 +668,17 @@ x = __ENCODING__
end
def test_embedded_rd
- assert_valid_syntax("=begin\n""=end")
- assert_valid_syntax("=begin\n""=end\0")
- assert_valid_syntax("=begin\n""=end\C-d")
- assert_valid_syntax("=begin\n""=end\C-z")
- end
-
- def test_embedded_rd_error
- error = 'embedded document meets end of file'
- assert_syntax_error("=begin\n", error)
- assert_syntax_error("=begin", error)
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+=begin
+ END
+ end
end
def test_float
assert_equal(1.0/0, eval("1e10000"))
- assert_syntax_error('1_E', /trailing `_'/)
- assert_syntax_error('1E1E1', /unexpected constant/)
+ assert_raise(SyntaxError) { eval('1_E') }
+ assert_raise(SyntaxError) { eval('1E1E1') }
end
def test_global_variable
@@ -734,19 +688,17 @@ x = __ENCODING__
$test_parse_foobarbazqux = nil
assert_equal(nil, $&)
assert_equal(nil, eval('alias $& $preserve_last_match'))
- assert_syntax_error('a = $#', /as a global variable name\na = \$\#\n \^~$/)
+ assert_raise(SyntaxError) { eval('$#') }
end
def test_invalid_instance_variable
- pattern = /without identifiers is not allowed as an instance variable name/
- assert_syntax_error('@%', pattern)
- assert_syntax_error('@', pattern)
+ assert_raise(SyntaxError) { eval('@#') }
+ assert_raise(SyntaxError) { eval('@') }
end
def test_invalid_class_variable
- pattern = /without identifiers is not allowed as a class variable name/
- assert_syntax_error('@@%', pattern)
- assert_syntax_error('@@', pattern)
+ assert_raise(SyntaxError) { eval('@@1') }
+ assert_raise(SyntaxError) { eval('@@') }
end
def test_invalid_char
@@ -766,23 +718,56 @@ x = __ENCODING__
end
def test_unassignable
- assert_syntax_error(%q(self = 1), /Can't change the value of self/)
- assert_syntax_error(%q(nil = 1), /Can't assign to nil/)
- assert_syntax_error(%q(true = 1), /Can't assign to true/)
- assert_syntax_error(%q(false = 1), /Can't assign to false/)
- assert_syntax_error(%q(__FILE__ = 1), /Can't assign to __FILE__/)
- assert_syntax_error(%q(__LINE__ = 1), /Can't assign to __LINE__/)
- assert_syntax_error(%q(__ENCODING__ = 1), /Can't assign to __ENCODING__/)
- assert_syntax_error("def foo; FOO = 1; end", /dynamic constant assignment/)
- assert_syntax_error("x, true", /Can't assign to true/)
+ assert_raise(SyntaxError) do
+ eval %q(self = 1)
+ end
+ assert_raise(SyntaxError) do
+ eval %q(nil = 1)
+ end
+ assert_raise(SyntaxError) do
+ eval %q(true = 1)
+ end
+ assert_raise(SyntaxError) do
+ eval %q(false = 1)
+ end
+ assert_raise(SyntaxError) do
+ eval %q(__FILE__ = 1)
+ end
+ assert_raise(SyntaxError) do
+ eval %q(__LINE__ = 1)
+ end
+ assert_raise(SyntaxError) do
+ eval %q(__ENCODING__ = 1)
+ end
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+ def foo
+ FOO = 1
+ end
+ END
+ end
+ assert_raise(SyntaxError) do
+ eval "#{<<~"begin;"}\n#{<<~'end;'}", nil, __FILE__, __LINE__+1
+ begin;
+ x, true
+ end;
+ end
end
def test_block_dup
- assert_syntax_error("foo(&proc{}) {}", /both block arg and actual block/)
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+ foo(&proc{}) {}
+ END
+ end
end
def test_set_backref
- assert_syntax_error("$& = 1", /Can't set variable/)
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+ $& = 1
+ END
+ end
end
def test_arg_concat
@@ -800,24 +785,32 @@ x = __ENCODING__
end
def test_void_expr_stmts_value
+ # This test checks if void contexts are warned correctly.
+ # Thus, warnings MUST NOT be suppressed.
+ $VERBOSE = true
+ stderr = $stderr
+ $stderr = StringIO.new("")
x = 1
- useless_use = /useless use/
- unused = /unused/
- assert_nil assert_warning(useless_use) {eval("x; nil")}
- assert_nil assert_warning(useless_use) {eval("1+1; nil")}
- assert_nil assert_warning('') {eval("1.+(1); nil")}
- assert_nil assert_warning(useless_use) {eval("TestParse; nil")}
- assert_nil assert_warning(useless_use) {eval("::TestParse; nil")}
- assert_nil assert_warning(useless_use) {eval("x..x; nil")}
- assert_nil assert_warning(useless_use) {eval("x...x; nil")}
- assert_nil assert_warning(unused) {eval("self; nil")}
- assert_nil assert_warning(unused) {eval("nil; nil")}
- assert_nil assert_warning(unused) {eval("true; nil")}
- assert_nil assert_warning(unused) {eval("false; nil")}
- assert_nil assert_warning(useless_use) {eval("defined?(1); nil")}
+ assert_nil eval("x; nil")
+ assert_nil eval("1+1; nil")
+ assert_nil eval("1.+(1); nil")
+ assert_nil eval("TestParse; nil")
+ assert_nil eval("::TestParse; nil")
+ assert_nil eval("x..x; nil")
+ assert_nil eval("x...x; nil")
+ assert_nil eval("self; nil")
+ assert_nil eval("nil; nil")
+ assert_nil eval("true; nil")
+ assert_nil eval("false; nil")
+ assert_nil eval("defined?(1); nil")
assert_equal 1, x
- assert_syntax_error("1; next; 2", /Invalid next/)
+ assert_raise(SyntaxError) do
+ eval %q(1; next; 2)
+ end
+
+ assert_equal(13, $stderr.string.lines.to_a.size)
+ $stderr = stderr
end
def test_assign_in_conditional
@@ -874,7 +867,11 @@ x = __ENCODING__
end
def test_no_blockarg
- assert_syntax_error("yield(&:+)", /block argument should not be given/)
+ assert_raise(SyntaxError) do
+ eval <<-END, nil, __FILE__, __LINE__+1
+ yield(&:+)
+ END
+ end
end
def test_method_block_location
@@ -891,8 +888,10 @@ x = __ENCODING__
assert_equal(expected, actual, bug5614)
end
- def test_no_shadowing_variable_warning
- assert_no_warning(/shadowing outer local variable/) {eval("a=1; tap {|a|}")}
+ def test_shadowing_variable
+ assert_warning(/shadowing outer local variable/) {eval("a=1; tap {|a|}")}
+ a = "\u{3042}"
+ assert_warning(/#{a}/o) {eval("#{a}=1; tap {|#{a}|}")}
end
def test_unused_variable
@@ -900,12 +899,10 @@ x = __ENCODING__
assert_warning(/assigned but unused variable/) {o.instance_eval("def foo; a=1; nil; end")}
assert_warning(/assigned but unused variable/) {o.instance_eval("def bar; a=1; a(); end")}
a = "\u{3042}"
- assert_warning(/#{a}/) {o.instance_eval("def foo0; #{a}=1; nil; end")}
- assert_warning(/assigned but unused variable/) {o.instance_eval("def foo1; tap {a=1; a()}; end")}
- assert_warning('') {o.instance_eval("def bar1; a=a=1; nil; end")}
- assert_warning(/assigned but unused variable/) {o.instance_eval("def bar2; a, = 1, 2; end")}
- assert_warning('') {o.instance_eval("def marg1(a); nil; end")}
- assert_warning('') {o.instance_eval("def marg2((a)); nil; end")}
+ assert_warning(/#{a}/) {o.instance_eval("def foo; #{a}=1; nil; end")}
+ o = Object.new
+ assert_warning(/assigned but unused variable/) {o.instance_eval("def foo; tap {a=1; a()}; end")}
+ assert_warning('') {o.instance_eval("def bar; a=a=1; nil; end")}
end
def test_named_capture_conflict
@@ -1046,26 +1043,35 @@ x = __ENCODING__
end
def test_unexpected_token_error
- assert_syntax_error('"x"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', /unexpected/)
+ assert_raise(SyntaxError) do
+ eval('"x"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
+ end
end
def test_unexpected_token_after_numeric
- assert_syntax_error('0000xyz', /^ \^~~\Z/)
- assert_syntax_error('1.2i1.1', /^ \^~~\Z/)
- assert_syntax_error('1.2.3', /^ \^~\Z/)
+ assert_raise_with_message(SyntaxError, /^ \^~~\z/) do
+ eval('0000xyz')
+ end
+ assert_raise_with_message(SyntaxError, /^ \^~~\z/) do
+ eval('1.2i1.1')
+ end
end
def test_truncated_source_line
- e = assert_syntax_error("'0123456789012345678901234567890123456789' abcdefghijklmnopqrstuvwxyz0123456789 0123456789012345678901234567890123456789",
- /unexpected local variable or method/)
+ e = assert_raise_with_message(SyntaxError, /unexpected tIDENTIFIER/) do
+ eval("'0123456789012345678901234567890123456789' abcdefghijklmnopqrstuvwxyz0123456789 0123456789012345678901234567890123456789")
+ end
line = e.message.lines[1]
assert_operator(line, :start_with?, "...")
assert_operator(line, :end_with?, "...\n")
end
def test_unterminated_regexp_error
- e = assert_syntax_error("/x", /unterminated regexp meets end of file/)
- assert_not_match(/unexpected tSTRING_END/, e.message)
+ e = assert_raise(SyntaxError) do
+ eval("/x")
+ end.message
+ assert_match(/unterminated regexp meets end of file/, e)
+ assert_not_match(/unexpected tSTRING_END/, e)
end
def test_lparenarg
@@ -1075,8 +1081,7 @@ x = __ENCODING__
end
o.instance_eval {i (-1.3).abs}
assert_equal(1.3, o.x)
- o.i(nil)
- o.instance_eval {i = 0; i (-1.3).abs; i}
+ o.instance_eval {i = 0; i (-1.3).abs}
assert_equal(1.3, o.x)
end
@@ -1085,85 +1090,13 @@ x = __ENCODING__
$VERBOSE = true
x = 1
eval("if false; 0 < x < 2; end")
- x
end
end
- def test_eof
- assert_equal(42, eval("42\0""end"))
- assert_equal(42, eval("42\C-d""end"))
- assert_equal(42, eval("42\C-z""end"))
- end
-
def test_eof_in_def
- assert_syntax_error("def m\n\0""end", /unexpected/)
- assert_syntax_error("def m\n\C-d""end", /unexpected/)
- assert_syntax_error("def m\n\C-z""end", /unexpected/)
- end
-
- def test_location_of_invalid_token
- assert_syntax_error('class xxx end', /^ \^~~\Z/)
- end
-
- def test_whitespace_warning
- assert_syntax_error("\\foo", /backslash/)
- assert_syntax_error("\\ ", /escaped space/)
- assert_syntax_error("\\\t", /escaped horizontal tab/)
- assert_syntax_error("\\\f", /escaped form feed/)
- assert_syntax_error("\\\r", /escaped carriage return/)
- assert_warn(/middle of line/) {eval(" \r ")}
- assert_syntax_error("\\\v", /escaped vertical tab/)
- end
-
- def test_command_def_cmdarg
- assert_valid_syntax("\n#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- m def x(); end
- 1.tap do end
- end;
- end
-
- NONASCII_CONSTANTS = [
- *%W"\u{00de} \u{00C0}".flat_map {|c| [c, c.encode("iso-8859-15")]},
- "\u{1c4}", "\u{1f2}", "\u{1f88}", "\u{370}",
- *%W"\u{391} \u{ff21}".flat_map {|c| [c, c.encode("cp932"), c.encode("euc-jp")]},
- ]
-
- def assert_nonascii_const
- assert_all_assertions_foreach("NONASCII_CONSTANTS", *NONASCII_CONSTANTS) do |n|
- m = Module.new
- assert_not_operator(m, :const_defined?, n)
- assert_raise_with_message(NameError, /uninitialized/) do
- m.const_get(n)
- end
- assert_nil(eval("defined?(m::#{n})"))
-
- v = yield m, n
-
- assert_operator(m, :const_defined?, n)
- assert_equal("constant", eval("defined?(m::#{n})"))
- assert_same(v, m.const_get(n))
-
- m.__send__(:remove_const, n)
- assert_not_operator(m, :const_defined?, n)
- assert_nil(eval("defined?(m::#{n})"))
- end
- end
-
- def test_nonascii_const_set
- assert_nonascii_const do |m, n|
- m.const_set(n, 42)
- end
- end
-
- def test_nonascii_constant
- assert_nonascii_const do |m, n|
- m.module_eval("class #{n}; self; end")
- end
- end
-
- def test_cdmarg_after_command_args_and_tlbrace_arg
- assert_valid_syntax('let () { m(a) do; end }')
+ assert_raise(SyntaxError) { eval("def m\n\0""end") }
+ assert_raise(SyntaxError) { eval("def m\n\C-d""end") }
+ assert_raise(SyntaxError) { eval("def m\n\C-z""end") }
end
def test_void_value_in_command_rhs
diff --git a/test/ruby/test_path.rb b/test/ruby/test_path.rb
index b35e942a2a..6af4fb6ac0 100644
--- a/test/ruby/test_path.rb
+++ b/test/ruby/test_path.rb
@@ -236,14 +236,10 @@ class TestPath < Test::Unit::TestCase
assert_equal(ext, File.extname('.a/b/d/test.rb'))
unless /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
# trailing spaces and dots are ignored on NTFS.
- ext = '.'
- end
- assert_equal(ext, File.extname('a.rb.'))
- if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
- # trailing spaces and dots are ignored on NTFS.
ext = ''
end
- assert_equal(ext, File.extname('a.'))
+ assert_equal(ext, File.extname('a.rb.'))
+ assert_equal('', File.extname('a.'))
assert_equal('', File.extname('.x'))
assert_equal('', File.extname('..x'))
end
diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
deleted file mode 100644
index 2afa823d53..0000000000
--- a/test/ruby/test_pattern_matching.rb
+++ /dev/null
@@ -1,1342 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-
-experimental, Warning[:experimental] = Warning[:experimental], false # suppress "warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!"
-eval "\n#{<<~'END_of_GUARD'}", binding, __FILE__, __LINE__
-class TestPatternMatching < Test::Unit::TestCase
- class C
- class << self
- attr_accessor :keys
- end
-
- def initialize(obj)
- @obj = obj
- end
-
- def deconstruct
- @obj
- end
-
- def deconstruct_keys(keys)
- C.keys = keys
- @obj
- end
- end
-
- def test_basic
- assert_block do
- case 0
- in 0
- true
- else
- false
- end
- end
-
- assert_block do
- case 0
- in 1
- false
- else
- true
- end
- end
-
- assert_raise(NoMatchingPatternError) do
- case 0
- in 1
- false
- end
- end
-
- begin
- o = [0]
- case o
- in 1
- false
- end
- rescue => e
- assert_match o.inspect, e.message
- end
-
- assert_block do
- begin
- true
- ensure
- case 0
- in 0
- false
- end
- end
- end
-
- assert_block do
- begin
- true
- ensure
- case 0
- in 1
- else
- false
- end
- end
- end
-
- assert_raise(NoMatchingPatternError) do
- begin
- ensure
- case 0
- in 1
- end
- end
- end
-
- assert_block do
- # suppress "warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!"
- experimental, Warning[:experimental] = Warning[:experimental], false
- eval(%q{
- case true
- in a
- a
- end
- })
- ensure
- Warning[:experimental] = experimental
- end
-
- assert_block do
- tap do |a|
- tap do
- case true
- in a
- a
- end
- end
- end
- end
-
- assert_raise(NoMatchingPatternError) do
- o = BasicObject.new
- def o.match
- case 0
- in 1
- end
- end
- o.match
- end
- end
-
- def test_modifier
- assert_block do
- case 0
- in a if a == 0
- true
- end
- end
-
- assert_block do
- case 0
- in a if a != 0
- else
- true
- end
- end
-
- assert_block do
- case 0
- in a unless a != 0
- true
- end
- end
-
- assert_block do
- case 0
- in a unless a == 0
- else
- true
- end
- end
- end
-
- def test_as_pattern
- assert_block do
- case 0
- in 0 => a
- a == 0
- end
- end
- end
-
- def test_alternative_pattern
- assert_block do
- [0, 1].all? do |i|
- case i
- in 0 | 1
- true
- end
- end
- end
-
- assert_block do
- case 0
- in _ | _a
- true
- end
- end
-
- assert_syntax_error(%q{
- case 0
- in a | 0
- end
- }, /illegal variable in alternative pattern/)
- end
-
- def test_var_pattern
- # NODE_DASGN_CURR
- assert_block do
- case 0
- in a
- a == 0
- end
- end
-
- # NODE_DASGN
- b = 0
- assert_block do
- case 1
- in b
- b == 1
- end
- end
-
- # NODE_LASGN
- case 0
- in c
- assert_equal(0, c)
- else
- flunk
- end
-
- assert_syntax_error(%q{
- case 0
- in ^a
- end
- }, /no such local variable/)
-
- assert_syntax_error(%q{
- case 0
- in a, a
- end
- }, /duplicated variable name/)
-
- assert_block do
- case [0, 1, 2, 3]
- in _, _, _a, _a
- true
- end
- end
-
- assert_syntax_error(%q{
- case 0
- in a, {a:}
- end
- }, /duplicated variable name/)
-
- assert_syntax_error(%q{
- case 0
- in a, {"a":}
- end
- }, /duplicated variable name/)
-
- assert_block do
- case [0, "1"]
- in a, "#{case 1; in a; a; end}"
- true
- end
- end
-
- assert_syntax_error(%q{
- case [0, "1"]
- in a, "#{case 1; in a; a; end}", a
- end
- }, /duplicated variable name/)
-
- assert_block do
- case 0
- in a
- assert_equal(0, a)
- true
- in a
- flunk
- end
- end
-
- assert_syntax_error(%q{
- 0 in [a, a]
- }, /duplicated variable name/)
- end
-
- def test_literal_value_pattern
- assert_block do
- case [nil, self, true, false]
- in [nil, self, true, false]
- true
- end
- end
-
- assert_block do
- case [0d170, 0D170, 0xaa, 0xAa, 0xAA, 0Xaa, 0XAa, 0XaA, 0252, 0o252, 0O252]
- in [0d170, 0D170, 0xaa, 0xAa, 0xAA, 0Xaa, 0XAa, 0XaA, 0252, 0o252, 0O252]
- true
- end
-
- case [0b10101010, 0B10101010, 12r, 12.3r, 1i, 12.3ri]
- in [0b10101010, 0B10101010, 12r, 12.3r, 1i, 12.3ri]
- true
- end
- end
-
- assert_block do
- x = 'x'
- case ['a', 'a', x]
- in ['a', "a", "#{x}"]
- true
- end
- end
-
- assert_block do
- case ["a\n"]
- in [<<END]
-a
-END
- true
- end
- end
-
- assert_block do
- case [:a, :"a"]
- in [:a, :"a"]
- true
- end
- end
-
- assert_block do
- case [0, 1, 2, 3, 4, 5]
- in [0..1, 0...2, 0.., 0..., (...5), (..5)]
- true
- end
- end
-
- assert_syntax_error(%q{
- case 0
- in a..b
- end
- }, /unexpected/)
-
- assert_block do
- case 'abc'
- in /a/
- true
- end
- end
-
- assert_block do
- case 0
- in ->(i) { i == 0 }
- true
- end
- end
-
- assert_block do
- case [%(a), %q(a), %Q(a), %w(a), %W(a), %i(a), %I(a), %s(a), %x(echo a), %(), %q(), %Q(), %w(), %W(), %i(), %I(), %s(), 'a']
- in [%(a), %q(a), %Q(a), %w(a), %W(a), %i(a), %I(a), %s(a), %x(echo a), %(), %q(), %Q(), %w(), %W(), %i(), %I(), %s(), %r(a)]
- true
- end
- end
-
- assert_block do
- case [__FILE__, __LINE__ + 1, __ENCODING__]
- in [__FILE__, __LINE__, __ENCODING__]
- true
- end
- end
- end
-
- def test_constant_value_pattern
- assert_block do
- case 0
- in Integer
- true
- end
- end
-
- assert_block do
- case 0
- in Object::Integer
- true
- end
- end
-
- assert_block do
- case 0
- in ::Object::Integer
- true
- end
- end
- end
-
- def test_pin_operator_value_pattern
- assert_block do
- a = /a/
- case 'abc'
- in ^a
- true
- end
- end
-
- assert_block do
- case [0, 0]
- in a, ^a
- a == 0
- end
- end
- end
-
- def test_array_pattern
- assert_block do
- [[0], C.new([0])].all? do |i|
- case i
- in 0,;
- true
- end
- end
- end
-
- assert_block do
- [[0, 1], C.new([0, 1])].all? do |i|
- case i
- in 0,;
- true
- end
- end
- end
-
- assert_block do
- [[], C.new([])].all? do |i|
- case i
- in 0,;
- else
- true
- end
- end
- end
-
- assert_block do
- [[0, 1], C.new([0, 1])].all? do |i|
- case i
- in 0, 1
- true
- end
- end
- end
-
- assert_block do
- [[0], C.new([0])].all? do |i|
- case i
- in 0, 1
- else
- true
- end
- end
- end
-
- assert_block do
- [[], C.new([])].all? do |i|
- case i
- in *a
- a == []
- end
- end
- end
-
- assert_block do
- [[0], C.new([0])].all? do |i|
- case i
- in *a
- a == [0]
- end
- end
- end
-
- assert_block do
- [[0], C.new([0])].all? do |i|
- case i
- in *a, 0, 1
- raise a # suppress "unused variable: a" warning
- else
- true
- end
- end
- end
-
- assert_block do
- [[0, 1], C.new([0, 1])].all? do |i|
- case i
- in *a, 0, 1
- a == []
- end
- end
- end
-
- assert_block do
- [[0, 1, 2], C.new([0, 1, 2])].all? do |i|
- case i
- in *a, 1, 2
- a == [0]
- end
- end
- end
-
- assert_block do
- [[], C.new([])].all? do |i|
- case i
- in *;
- true
- end
- end
- end
-
- assert_block do
- [[0], C.new([0])].all? do |i|
- case i
- in *, 0, 1
- else
- true
- end
- end
- end
-
- assert_block do
- [[0, 1], C.new([0, 1])].all? do |i|
- case i
- in *, 0, 1
- true
- end
- end
- end
-
- assert_block do
- [[0, 1, 2], C.new([0, 1, 2])].all? do |i|
- case i
- in *, 1, 2
- true
- end
- end
- end
-
- assert_block do
- case C.new([0])
- in C(0)
- true
- end
- end
-
- assert_block do
- case C.new([0])
- in Array(0)
- else
- true
- end
- end
-
- assert_block do
- case C.new([])
- in C()
- true
- end
- end
-
- assert_block do
- case C.new([])
- in Array()
- else
- true
- end
- end
-
- assert_block do
- case C.new([0])
- in C[0]
- true
- end
- end
-
- assert_block do
- case C.new([0])
- in Array[0]
- else
- true
- end
- end
-
- assert_block do
- case C.new([])
- in C[]
- true
- end
- end
-
- assert_block do
- case C.new([])
- in Array[]
- else
- true
- end
- end
-
- assert_block do
- case []
- in []
- true
- end
- end
-
- assert_block do
- case C.new([])
- in []
- true
- end
- end
-
- assert_block do
- case [0]
- in [0]
- true
- end
- end
-
- assert_block do
- case C.new([0])
- in [0]
- true
- end
- end
-
- assert_block do
- case [0]
- in [0,]
- true
- end
- end
-
- assert_block do
- case [0, 1]
- in [0,]
- true
- end
- end
-
- assert_block do
- case []
- in [0, *a]
- raise a # suppress "unused variable: a" warning
- else
- true
- end
- end
-
- assert_block do
- case [0]
- in [0, *a]
- a == []
- end
- end
-
- assert_block do
- case [0]
- in [0, *a, 1]
- raise a # suppress "unused variable: a" warning
- else
- true
- end
- end
-
- assert_block do
- case [0, 1]
- in [0, *a, 1]
- a == []
- end
- end
-
- assert_block do
- case [0, 1, 2]
- in [0, *a, 2]
- a == [1]
- end
- end
-
- assert_block do
- case []
- in [0, *]
- else
- true
- end
- end
-
- assert_block do
- case [0]
- in [0, *]
- true
- end
- end
-
- assert_block do
- case [0, 1]
- in [0, *]
- true
- end
- end
-
- assert_block do
- case []
- in [0, *a]
- raise a # suppress "unused variable: a" warning
- else
- true
- end
- end
-
- assert_block do
- case [0]
- in [0, *a]
- a == []
- end
- end
-
- assert_block do
- case [0, 1]
- in [0, *a]
- a == [1]
- end
- end
-
- assert_block do
- case [0]
- in [0, *, 1]
- else
- true
- end
- end
-
- assert_block do
- case [0, 1]
- in [0, *, 1]
- true
- end
- end
- end
-
- def test_hash_pattern
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in a: 0
- else
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in a: 0
- true
- end
- end
- end
-
- assert_block do
- [{a: 0, b: 1}, C.new({a: 0, b: 1})].all? do |i|
- case i
- in a: 0
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in a: 0, b: 1
- else
- true
- end
- end
- end
-
- assert_block do
- [{a: 0, b: 1}, C.new({a: 0, b: 1})].all? do |i|
- case i
- in a: 0, b: 1
- true
- end
- end
- end
-
- assert_block do
- [{a: 0, b: 1, c: 2}, C.new({a: 0, b: 1, c: 2})].all? do |i|
- case i
- in a: 0, b: 1
- true
- end
- end
- end
-
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in a:
- raise a # suppress "unused variable: a" warning
- else
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in a:
- a == 0
- end
- end
- end
-
- assert_block do
- [{a: 0, b: 1}, C.new({a: 0, b: 1})].all? do |i|
- case i
- in a:
- a == 0
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in "a": 0
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in "a":;
- a == 0
- end
- end
- end
-
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in **a
- a == {}
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in **a
- a == {a: 0}
- end
- end
- end
-
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in **;
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in **;
- true
- end
- end
- end
-
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in a:, **b
- raise a # suppress "unused variable: a" warning
- raise b # suppress "unused variable: b" warning
- else
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in a:, **b
- a == 0 && b == {}
- end
- end
- end
-
- assert_block do
- [{a: 0, b: 1}, C.new({a: 0, b: 1})].all? do |i|
- case i
- in a:, **b
- a == 0 && b == {b: 1}
- end
- end
- end
-
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in **nil
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in **nil
- else
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in a:, **nil
- assert_equal(0, a)
- true
- end
- end
- end
-
- assert_block do
- [{a: 0, b: 1}, C.new({a: 0, b: 1})].all? do |i|
- case i
- in a:, **nil
- assert_equal(0, a)
- else
- true
- end
- end
- end
-
- assert_block do
- case C.new({a: 0})
- in C(a: 0)
- true
- end
- end
-
- assert_block do
- case {a: 0}
- in C(a: 0)
- else
- true
- end
- end
-
- assert_block do
- case C.new({a: 0})
- in C[a: 0]
- true
- end
- end
-
- assert_block do
- case {a: 0}
- in C[a: 0]
- else
- true
- end
- end
-
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in {a: 0}
- else
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in {a: 0}
- true
- end
- end
- end
-
- assert_block do
- [{a: 0, b: 1}, C.new({a: 0, b: 1})].all? do |i|
- case i
- in {a: 0}
- true
- end
- end
- end
-
- assert_block do
- [{}, C.new({})].all? do |i|
- case i
- in {}
- true
- end
- end
- end
-
- assert_block do
- [{a: 0}, C.new({a: 0})].all? do |i|
- case i
- in {}
- else
- true
- end
- end
- end
-
- assert_syntax_error(%q{
- case _
- in a:, a:
- end
- }, /duplicated key name/)
-
- assert_syntax_error(%q{
- case _
- in a?:
- end
- }, /key must be valid as local variables/)
-
- assert_block do
- case {a?: true}
- in a?: true
- true
- end
- end
-
- assert_block do
- case {a: 0, b: 1}
- in {a: 1,}
- false
- in {a:,}
- _a = a
- true
- end
- end
-
- assert_block do
- case {a: 0}
- in {a: 1
- }
- false
- in {a:
- 2}
- false
- in a: {b:}, c:
- _b = b
- p c
- in {a:
- }
- _a = a
- true
- end
- end
-
- assert_syntax_error(%q{
- case _
- in "a-b":
- end
- }, /key must be valid as local variables/)
-
- assert_block do
- case {"a-b": true}
- in "a-b": true
- true
- end
- end
-
- assert_syntax_error(%q{
- case _
- in "#{a}": a
- end
- }, /symbol literal with interpolation is not allowed/)
-
- assert_syntax_error(%q{
- case _
- in "#{a}":
- end
- }, /symbol literal with interpolation is not allowed/)
- end
-
- def test_paren
- assert_block do
- case 0
- in (0)
- true
- end
- end
- end
-
- def test_invalid_syntax
- assert_syntax_error(%q{
- case 0
- in a, b:
- end
- }, /unexpected/)
-
- assert_syntax_error(%q{
- case 0
- in [a:]
- end
- }, /unexpected/)
-
- assert_syntax_error(%q{
- case 0
- in {a}
- end
- }, /unexpected/)
-
- assert_syntax_error(%q{
- case 0
- in {0 => a}
- end
- }, /unexpected/)
- end
-
- ################################################################
-
- class CTypeError
- def deconstruct
- nil
- end
-
- def deconstruct_keys(keys)
- nil
- end
- end
-
- def test_deconstruct
- assert_raise(TypeError) do
- case CTypeError.new
- in []
- end
- end
- end
-
- def test_deconstruct_keys
- assert_raise(TypeError) do
- case CTypeError.new
- in {}
- end
- end
-
- assert_block do
- case {}
- in {}
- C.keys == nil
- end
- end
-
- assert_block do
- case C.new({a: 0, b: 0, c: 0})
- in {a: 0, b:}
- assert_equal(0, b)
- C.keys == [:a, :b]
- end
- end
-
- assert_block do
- case C.new({a: 0, b: 0, c: 0})
- in {a: 0, b:, **}
- assert_equal(0, b)
- C.keys == [:a, :b]
- end
- end
-
- assert_block do
- case C.new({a: 0, b: 0, c: 0})
- in {a: 0, b:, **r}
- assert_equal(0, b)
- assert_equal({c: 0}, r)
- C.keys == nil
- end
- end
-
- assert_block do
- case C.new({a: 0, b: 0, c: 0})
- in {**}
- C.keys == []
- end
- end
-
- assert_block do
- case C.new({a: 0, b: 0, c: 0})
- in {**r}
- assert_equal({a: 0, b: 0, c: 0}, r)
- C.keys == nil
- end
- end
- end
-
- ################################################################
-
- class TestPatternMatchingRefinements < Test::Unit::TestCase
- class C1
- def deconstruct
- [:C1]
- end
- end
-
- class C2
- end
-
- module M
- refine Array do
- def deconstruct
- [0]
- end
- end
-
- refine Hash do
- def deconstruct_keys(_)
- {a: 0}
- end
- end
-
- refine C2.singleton_class do
- def ===(obj)
- obj.kind_of?(C1)
- end
- end
- end
-
- using M
-
- def test_refinements
- assert_block do
- case []
- in [0]
- true
- end
- end
-
- assert_block do
- case {}
- in {a: 0}
- true
- end
- end
-
- assert_block do
- case C1.new
- in C2(:C1)
- true
- end
- end
- end
- end
-
- ################################################################
-
- def test_struct
- assert_block do
- s = Struct.new(:a, :b)
- case s[0, 1]
- in 0, 1
- true
- end
- end
-
- s = Struct.new(:a, :b, keyword_init: true)
- assert_block do
- case s[a: 0, b: 1]
- in **r
- r == {a: 0, b: 1}
- end
- end
- assert_block do
- s = Struct.new(:a, :b, keyword_init: true)
- case s[a: 0, b: 1]
- in a:, b:
- a == 0 && b == 1
- end
- end
- assert_block do
- s = Struct.new(:a, :b, keyword_init: true)
- case s[a: 0, b: 1]
- in a:, c:
- raise a # suppress "unused variable: a" warning
- raise c # suppress "unused variable: c" warning
- flunk
- in a:, b:, c:
- flunk
- in b:
- b == 1
- end
- end
- end
-
- ################################################################
-
- def test_modifier_in
- 1 in a
- assert_equal 1, a
- assert_raise(NoMatchingPatternError) do
- {a: 1} in {a: 0}
- end
- assert_syntax_error("if {} in {a:}; end", /void value expression/)
- assert_syntax_error(%q{
- 1 in a, b
- }, /unexpected/, '[ruby-core:95098]')
- assert_syntax_error(%q{
- 1 in a:
- }, /unexpected/, '[ruby-core:95098]')
- end
-
- def assert_experimental_warning(code)
- w = Warning[:experimental]
-
- Warning[:experimental] = false
- assert_warn('') {eval(code)}
-
- Warning[:experimental] = true
- assert_warn(/Pattern matching is experimental/) {eval(code)}
- ensure
- Warning[:experimental] = w
- end
-
- def test_experimental_warning
- assert_experimental_warning("case 0; in 0; end")
- assert_experimental_warning("0 in 0")
- end
-end
-END_of_GUARD
-Warning[:experimental] = experimental
diff --git a/test/ruby/test_pipe.rb b/test/ruby/test_pipe.rb
index 9fa42fd375..efca8f28c1 100644
--- a/test/ruby/test_pipe.rb
+++ b/test/ruby/test_pipe.rb
@@ -27,23 +27,4 @@ class TestPipe < Test::Unit::TestCase
end
end
end
-
- def test_stdout_epipe
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- io = STDOUT
- begin
- save = io.dup
- IO.popen("echo", "w", out: IO::NULL) do |f|
- io.reopen(f)
- Process.wait(f.pid)
- assert_raise(Errno::EPIPE) do
- io.print "foo\n"
- end
- end
- ensure
- io.reopen(save)
- end
- end;
- end
end
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 3f0d599a04..df9bb5f549 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -55,13 +55,7 @@ class TestProc < Test::Unit::TestCase
def assert_arity(n)
meta = class << self; self; end
- b = assert_warn(/Capturing the given block using Proc\.new is deprecated/) do
- Proc.new
- end
- meta.class_eval {
- remove_method(:foo) if method_defined?(:foo)
- define_method(:foo, b)
- }
+ meta.class_eval {define_method(:foo, Proc.new)}
assert_equal(n, method(:foo).arity)
end
@@ -157,6 +151,37 @@ class TestProc < Test::Unit::TestCase
assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})
end
+ def test_safe
+ safe = $SAFE
+ c = Class.new
+ x = c.new
+
+ p = proc {
+ $SAFE += 1
+ proc {$SAFE}
+ }.call
+ assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, p.call)
+ assert_equal(safe, $SAFE)
+
+ c.class_eval {define_method(:safe, p)}
+ assert_equal(safe, x.safe)
+ assert_equal(safe, x.method(:safe).call)
+ assert_equal(safe, x.method(:safe).to_proc.call)
+
+ p = proc {$SAFE += 1}
+ assert_equal(safe + 1, p.call)
+ assert_equal(safe, $SAFE)
+
+ c.class_eval {define_method(:inc, p)}
+ assert_equal(safe + 1, proc {x.inc; $SAFE}.call)
+ assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, proc {x.method(:inc).call; $SAFE}.call)
+ assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, proc {x.method(:inc).to_proc.call; $SAFE}.call)
+ assert_equal(safe, $SAFE)
+ end
+
def m2
"OK"
end
@@ -372,15 +397,6 @@ class TestProc < Test::Unit::TestCase
assert_equal([1, 2, 3], b.eval("[x, y, z]"))
end
- def test_binding_source_location
- b, expected_location = binding, [__FILE__, __LINE__]
- assert_equal(expected_location, b.source_location)
-
- file, lineno = method(:source_location_test).to_proc.binding.source_location
- assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
- assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
- end
-
def test_proc_lambda
assert_raise(ArgumentError) { proc }
assert_raise(ArgumentError) { lambda }
@@ -391,14 +407,14 @@ class TestProc < Test::Unit::TestCase
1.times { b = lambda }
b
end
- assert_raise(ArgumentError) {o.foo { :foo }.call}
+ assert_equal(:foo, o.foo { :foo }.call)
def o.foo(&b)
b = nil
1.times { b = lambda }
b
end
- assert_raise(ArgumentError) {o.foo { :foo }.call}
+ assert_equal(:foo, o.foo { :foo }.call)
end
def test_arity2
@@ -1087,26 +1103,6 @@ class TestProc < Test::Unit::TestCase
assert_equal([1,2,[3],4,5], r, "[ruby-core:19485]")
end
- def test_proc_autosplat
- def self.a(arg, kw)
- yield arg
- yield arg, **kw
- yield arg, kw
- end
-
- arr = []
- a([1,2,3], {}) do |arg1, arg2=0|
- arr << [arg1, arg2]
- end
- assert_equal([[1, 2], [[1, 2, 3], 0], [[1, 2, 3], {}]], arr)
-
- arr = []
- a([1,2,3], a: 1) do |arg1, arg2=0|
- arr << [arg1, arg2]
- end
- assert_equal([[1, 2], [[1, 2, 3], {a: 1}], [[1, 2, 3], {a: 1}]], arr)
- end
-
def test_parameters
assert_equal([], proc {}.parameters)
assert_equal([], proc {||}.parameters)
@@ -1175,9 +1171,12 @@ class TestProc < Test::Unit::TestCase
end
def test_to_s
- assert_match(/^#<Proc:0x\h+ #{ Regexp.quote(__FILE__) }:\d+>$/, proc {}.to_s)
- assert_match(/^#<Proc:0x\h+ #{ Regexp.quote(__FILE__) }:\d+ \(lambda\)>$/, lambda {}.to_s)
+ assert_match(/^#<Proc:0x\h+@#{ Regexp.quote(__FILE__) }:\d+>$/, proc {}.to_s)
+ assert_match(/^#<Proc:0x\h+@#{ Regexp.quote(__FILE__) }:\d+ \(lambda\)>$/, lambda {}.to_s)
assert_match(/^#<Proc:0x\h+ \(lambda\)>$/, method(:p).to_proc.to_s)
+ x = proc {}
+ x.taint
+ assert_predicate(x.to_s, :tainted?)
name = "Proc\u{1f37b}"
assert_include(EnvUtil.labeled_class(name, Proc).new {}.to_s, name)
end
@@ -1286,7 +1285,7 @@ class TestProc < Test::Unit::TestCase
def test_local_variables
b = get_binding
assert_equal(%i'if case when begin end a', b.local_variables)
- a = tap {|;x, y| x = y = x; break binding.local_variables}
+ a = tap {|;x, y| x = y; break binding.local_variables}
assert_equal(%i[a b x y], a.sort)
end
@@ -1329,7 +1328,7 @@ class TestProc < Test::Unit::TestCase
end
def test_local_variable_set_wb
- assert_ruby_status([], <<-'end;', '[Bug #13605]', timeout: 30)
+ assert_ruby_status([], <<-'end;', '[Bug #13605]', timeout: 15)
b = binding
n = 20_000
@@ -1377,254 +1376,4 @@ class TestProc < Test::Unit::TestCase
e.each {}
EOS
end
-
- def test_prepended_call
- assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", ["call"])
- begin;
- Proc.prepend Module.new {def call() puts "call"; super; end}
- def m(&blk) blk.call; end
- m {}
- end;
- end
-
- def test_refined_call
- assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", ["call"])
- begin;
- using Module.new {refine(Proc) {def call() puts "call"; super; end}}
- def m(&blk) blk.call; end
- m {}
- end;
- end
-
- def method_for_test_proc_without_block_for_symbol
- assert_warn(/Capturing the given block using Kernel#proc is deprecated/) do
- binding.eval('proc')
- end
- end
-
- def test_proc_without_block_for_symbol
- assert_equal('1', method_for_test_proc_without_block_for_symbol(&:to_s).call(1), '[Bug #14782]')
- end
-
- def test_compose
- f = proc {|x| x * 2}
- g = proc {|x| x + 1}
-
- assert_equal(6, (f << g).call(2))
- assert_equal(6, (g >> f).call(2))
- end
-
- def test_compose_with_multiple_args
- f = proc {|x| x * 2}
- g = proc {|x, y| x + y}
-
- assert_equal(6, (f << g).call(1, 2))
- assert_equal(6, (g >> f).call(1, 2))
- end
-
- def test_compose_with_block
- f = proc {|x| x * 2}
- g = proc {|&blk| blk.call(1) }
-
- assert_equal(8, (f << g).call { |x| x + 3 })
- assert_equal(8, (g >> f).call { |x| x + 3 })
- end
-
- def test_compose_with_lambda
- f = lambda {|x| x * 2}
- g = lambda {|x| x}
-
- assert_predicate((f << g), :lambda?)
- assert_predicate((g >> f), :lambda?)
- end
-
- def test_compose_with_method
- f = proc {|x| x * 2}
- c = Class.new {
- def g(x) x + 1 end
- }
- g = c.new.method(:g)
-
- assert_equal(6, (f << g).call(2))
- assert_equal(5, (f >> g).call(2))
- end
-
- def test_compose_with_callable
- f = proc {|x| x * 2}
- c = Class.new {
- def call(x) x + 1 end
- }
- g = c.new
-
- assert_equal(6, (f << g).call(2))
- assert_equal(5, (f >> g).call(2))
- end
-
- def test_compose_with_noncallable
- f = proc {|x| x * 2}
-
- assert_raise(TypeError) {
- (f << 5).call(2)
- }
- assert_raise(TypeError) {
- (f >> 5).call(2)
- }
- end
-
- def test_orphan_return
- assert_equal(42, Module.new { extend self
- def m1(&b) b.call end; def m2(); m1 { return 42 } end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1 { return 42 }.call end }.m2)
- assert_raise(LocalJumpError) { Module.new { extend self
- def m1(&b) b end; def m2(); m1 { return 42 } end }.m2.call }
- end
-
- def test_orphan_break
- assert_equal(42, Module.new { extend self
- def m1(&b) b.call end; def m2(); m1 { break 42 } end }.m2 )
- assert_raise(LocalJumpError) { Module.new { extend self
- def m1(&b) b end; def m2(); m1 { break 42 }.call end }.m2 }
- assert_raise(LocalJumpError) { Module.new { extend self
- def m1(&b) b end; def m2(); m1 { break 42 } end }.m2.call }
- end
-
- def test_not_orphan_next
- assert_equal(42, Module.new { extend self
- def m1(&b) b.call end; def m2(); m1 { next 42 } end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1 { next 42 }.call end }.m2)
- assert_equal(42, Module.new { extend self
- def m1(&b) b end; def m2(); m1 { next 42 } end }.m2.call)
- end
end
-
-class TestProcKeywords < Test::Unit::TestCase
- def test_compose_keywords
- f = ->(**kw) { kw.merge(:a=>1) }
- g = ->(kw) { kw.merge(:a=>2) }
-
- assert_equal(2, (f >> g).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call(a: 3)[:a])
- end
- assert_equal(2, (f >> g).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(2, (f >> g).call({a: 3})[:a])
- end
- assert_equal(2, (g << f).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (g >> f).call(a: 3)[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(2, (g << f).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (g >> f).call({a: 3})[:a])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call(**{})[:a])
- end
- assert_equal(2, (f >> g).call(**{})[:a])
- end
-
- def test_compose_keywords_method
- f = ->(**kw) { kw.merge(:a=>1) }.method(:call)
- g = ->(kw) { kw.merge(:a=>2) }.method(:call)
-
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call(a: 3)[:a])
- end
- assert_equal(2, (f >> g).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(2, (f >> g).call({a: 3})[:a])
- end
- assert_equal(2, (g << f).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (g >> f).call(a: 3)[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(2, (g << f).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (g >> f).call({a: 3})[:a])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call(**{})[:a])
- end
- assert_equal(2, (f >> g).call(**{})[:a])
- end
-
- def test_compose_keywords_non_proc
- f = ->(**kw) { kw.merge(:a=>1) }
- g = Object.new
- def g.call(kw) kw.merge(:a=>2) end
- def g.to_proc; method(:call).to_proc; end
- def g.<<(f) to_proc << f end
- def g.>>(f) to_proc >> f end
-
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call(a: 3)[:a])
- end
- assert_equal(2, (f >> g).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (f << g).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(2, (f >> g).call({a: 3})[:a])
- end
- assert_equal(2, (g << f).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (g >> f).call(a: 3)[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(2, (g << f).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method is defined here/m) do
- assert_equal(1, (g >> f).call({a: 3})[:a])
- end
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*The called method `call'/m) do
- assert_equal(1, (f << g).call(**{})[:a])
- end
- assert_equal(2, (f >> g).call(**{})[:a])
-
- f = ->(kw) { kw.merge(:a=>1) }
- g = Object.new
- def g.call(**kw) kw.merge(:a=>2) end
- def g.to_proc; method(:call).to_proc; end
- def g.<<(f) to_proc << f end
- def g.>>(f) to_proc >> f end
-
- assert_equal(1, (f << g).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(2, (f >> g).call(a: 3)[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(1, (f << g).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(2, (f >> g).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(2, (g << f).call(a: 3)[:a])
- end
- assert_equal(1, (g >> f).call(a: 3)[:a])
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(2, (g << f).call({a: 3})[:a])
- end
- assert_warn(/Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(1, (g >> f).call({a: 3})[:a])
- end
- assert_equal(1, (f << g).call(**{})[:a])
- assert_warn(/Passing the keyword argument as the last hash parameter is deprecated.*Using the last argument as keyword parameters is deprecated.*The called method `call'/m) do
- assert_equal(2, (f >> g).call(**{})[:a])
- end
- end
-end
-
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index ab723c6f63..ba7b0f1177 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -246,22 +246,21 @@ class TestProcess < Test::Unit::TestCase
assert_raise(ArgumentError) do
system(RUBY, '-e', 'exit', 'rlimit_bogus'.to_sym => 123)
end
- assert_separately([],"#{<<~"begin;"}\n#{<<~'end;'}", 'rlimit_cpu'.to_sym => 3600)
- BUG = "[ruby-core:82033] [Bug #13744]"
- begin;
- assert_equal([3600,3600], Process.getrlimit(:CPU), BUG)
+ assert_separately([],<<-"end;") # [ruby-core:82033] [Bug #13744]
+ assert(system("#{RUBY}", "-e",
+ "exit([3600,3600] == Process.getrlimit(:CPU))",
+ 'rlimit_cpu'.to_sym => 3600))
+ assert_raise(ArgumentError) do
+ system("#{RUBY}", '-e', 'exit', :rlimit_bogus => 123)
+ end
end;
- assert_raise_with_message(ArgumentError, /bogus/) do
- system(RUBY, '-e', 'exit', :rlimit_bogus => 123)
- end
-
- assert_raise_with_message(ArgumentError, /rlimit_cpu/) {
+ assert_raise(ArgumentError, /rlimit_cpu/) {
system(RUBY, '-e', 'exit', "rlimit_cpu\0".to_sym => 3600)
}
end
- MANDATORY_ENVS = %w[RUBYLIB MJIT_SEARCH_BUILD_DIR]
+ MANDATORY_ENVS = %w[RUBYLIB]
case RbConfig::CONFIG['target_os']
when /linux/
MANDATORY_ENVS << 'LD_PRELOAD'
@@ -273,9 +272,6 @@ class TestProcess < Test::Unit::TestCase
if e = RbConfig::CONFIG['LIBPATHENV']
MANDATORY_ENVS << e
end
- if e = RbConfig::CONFIG['PRELOADENV'] and !e.empty?
- MANDATORY_ENVS << e
- end
PREENVARG = ['-e', "%w[#{MANDATORY_ENVS.join(' ')}].each{|e|ENV.delete(e)}"]
ENVARG = ['-e', 'ENV.each {|k,v| puts "#{k}=#{v}" }']
ENVCOMMAND = [RUBY].concat(PREENVARG).concat(ENVARG)
@@ -634,7 +630,7 @@ class TestProcess < Test::Unit::TestCase
rescue NotImplementedError
return
end
- assert_file.pipe?("fifo")
+ assert(FileTest.pipe?("fifo"), "should be pipe")
t1 = Thread.new {
system(*ECHO["output to fifo"], :out=>"fifo")
}
@@ -680,17 +676,14 @@ class TestProcess < Test::Unit::TestCase
return
end
IO.popen([RUBY, '-e', <<-'EOS']) {|io|
- STDOUT.sync = true
trap(:USR1) { print "trap\n" }
- puts "start"
system("cat", :in => "fifo")
EOS
- assert_equal("start\n", io.gets)
- sleep 0.2 # wait for the child to stop at opening "fifo"
+ sleep 1
Process.kill(:USR1, io.pid)
- assert_equal("trap\n", io.readpartial(8))
+ sleep 1
File.write("fifo", "ok\n")
- assert_equal("ok\n", io.read)
+ assert_equal("trap\nok\n", io.read)
}
}
end unless windows? # does not support fifo
@@ -763,15 +756,6 @@ class TestProcess < Test::Unit::TestCase
Process.wait pid
end
}
-
- # ensure standard FDs we redirect to are blocking for compatibility
- with_pipes(3) do |pipes|
- src = 'p [STDIN,STDOUT,STDERR].map(&:nonblock?)'
- rdr = { 0 => pipes[0][0], 1 => pipes[1][1], 2 => pipes[2][1] }
- pid = spawn(RUBY, '-rio/nonblock', '-e', src, rdr)
- assert_equal("[false, false, false]\n", pipes[1][0].gets)
- Process.wait pid
- end
end
end
@@ -1019,15 +1003,6 @@ class TestProcess < Test::Unit::TestCase
}
end
- def test_close_others_default_false
- IO.pipe do |r,w|
- w.close_on_exec = false
- src = "IO.new(#{w.fileno}).puts(:hi)"
- assert_equal true, system(*%W(#{RUBY} --disable=gems -e #{src}))
- assert_equal "hi\n", r.gets
- end
- end unless windows? # passing non-stdio fds is not supported on Windows
-
def test_execopts_redirect_self
begin
with_pipe {|r, w|
@@ -1483,9 +1458,7 @@ class TestProcess < Test::Unit::TestCase
def test_wait_exception
bug11340 = '[ruby-dev:49176] [Bug #11340]'
t0 = t1 = nil
- sec = 3
- code = "puts;STDOUT.flush;Thread.start{gets;exit};sleep(#{sec})"
- IO.popen([RUBY, '-e', code], 'r+') do |f|
+ IO.popen([RUBY, '-e', 'puts;STDOUT.flush;Thread.start{gets;exit};sleep(3)'], 'r+') do |f|
pid = f.pid
f.gets
t0 = Time.now
@@ -1499,35 +1472,21 @@ class TestProcess < Test::Unit::TestCase
th.kill.join
end
t1 = Time.now
- diff = t1 - t0
- assert_operator(diff, :<, sec,
- ->{"#{bug11340}: #{diff} seconds to interrupt Process.wait"})
f.puts
end
+ assert_operator(t1 - t0, :<, 3,
+ ->{"#{bug11340}: #{t1-t0} seconds to interrupt Process.wait"})
end
def test_abort
with_tmpchdir do
s = run_in_child("abort")
- assert_not_predicate(s, :success?)
- write_file("test-script", "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- STDERR.reopen(STDOUT)
- begin
- raise "[Bug #16424]"
- rescue
- abort
- end
- end;
- assert_include(IO.popen([RUBY, "test-script"], &:read), "[Bug #16424]")
+ assert_not_equal(0, s.exitstatus)
end
end
def test_sleep
assert_raise(ArgumentError) { sleep(1, 1) }
- [-1, -1.0, -1r].each do |sec|
- assert_raise_with_message(ArgumentError, /not.*negative/) { sleep(sec) }
- end
end
def test_getpgid
@@ -1565,8 +1524,6 @@ class TestProcess < Test::Unit::TestCase
rescue NotImplementedError
else
assert_kind_of(Integer, max)
- assert_predicate(max, :positive?)
- skip "not limited to NGROUPS_MAX" if /darwin/ =~ RUBY_PLATFORM
gs = Process.groups
assert_operator(gs.size, :<=, max)
gs[0] ||= 0
@@ -1583,7 +1540,7 @@ class TestProcess < Test::Unit::TestCase
end
def test_seteuid_name
- user = (Etc.getpwuid(Process.euid).name rescue ENV["USER"]) or return
+ user = ENV["USER"] or return
assert_nothing_raised(TypeError) {Process.euid = user}
rescue NotImplementedError
end
@@ -1593,7 +1550,6 @@ class TestProcess < Test::Unit::TestCase
end
def test_setegid
- skip "root can use Process.egid on Android platform" if RUBY_PLATFORM =~ /android/
assert_nothing_raised(TypeError) {Process.egid += 0}
rescue NotImplementedError
end
@@ -1629,28 +1585,22 @@ class TestProcess < Test::Unit::TestCase
skip "this fails on FreeBSD and OpenBSD on multithreaded environment"
end
signal_received = []
- IO.pipe do |sig_r, sig_w|
- Signal.trap(:CHLD) do
- signal_received << true
- sig_w.write('?')
- end
- pid = nil
- IO.pipe do |r, w|
- pid = fork { r.read(1); exit }
- Thread.start {
- Thread.current.report_on_exception = false
- raise
- }
- w.puts
- end
- Process.wait pid
- assert_send [sig_r, :wait_readable, 5], 'self-pipe not readable'
+ Signal.trap(:CHLD) { signal_received << true }
+ pid = nil
+ IO.pipe do |r, w|
+ pid = fork { r.read(1); exit }
+ Thread.start {
+ Thread.current.report_on_exception = false
+ raise
+ }
+ w.puts
end
- if RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE. It may trigger extra SIGCHLD.
- assert_equal [true], signal_received.uniq, "[ruby-core:19744]"
- else
- assert_equal [true], signal_received, "[ruby-core:19744]"
+ Process.wait pid
+ 10.times do
+ break unless signal_received.empty?
+ sleep 0.01
end
+ assert_equal [true], signal_received, " [ruby-core:19744]"
rescue NotImplementedError, ArgumentError
ensure
begin
@@ -1741,7 +1691,7 @@ class TestProcess < Test::Unit::TestCase
with_tmpchdir do
assert_nothing_raised('[ruby-dev:12261]') do
- EnvUtil.timeout(3) do
+ Timeout.timeout(3) do
pid = spawn('yes | ls')
Process.waitpid pid
end
@@ -1808,12 +1758,12 @@ class TestProcess < Test::Unit::TestCase
puts Dir.entries("/proc/self/task") - %W[. ..]
end
bug4920 = '[ruby-dev:43873]'
- assert_include(1..2, data.size, bug4920)
+ assert_equal(2, data.size, bug4920)
assert_not_include(data.map(&:to_i), pid)
end
else # darwin
def test_daemon_no_threads
- data = EnvUtil.timeout(3) do
+ data = Timeout.timeout(3) do
IO.popen("-") do |f|
break f.readlines.map(&:chomp) if f
th = Thread.start {sleep 3}
@@ -1862,16 +1812,6 @@ class TestProcess < Test::Unit::TestCase
end
end
- def test_popen_reopen
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- io = File.open(IO::NULL)
- io2 = io.dup
- IO.popen("echo") {|f| io.reopen(f)}
- io.reopen(io2)
- end;
- end
-
def test_execopts_new_pgroup
return unless windows?
@@ -1882,23 +1822,22 @@ class TestProcess < Test::Unit::TestCase
end
def test_execopts_uid
- skip "root can use uid option of Kernel#system on Android platform" if RUBY_PLATFORM =~ /android/
feature6975 = '[ruby-core:47414]'
[30000, [Process.uid, ENV["USER"]]].each do |uid, user|
if user
assert_nothing_raised(feature6975) do
begin
- system(*TRUECOMMAND, uid: user, exception: true)
- rescue Errno::EPERM, Errno::EACCES, NotImplementedError
+ system(*TRUECOMMAND, uid: user)
+ rescue Errno::EPERM, NotImplementedError
end
end
end
assert_nothing_raised(feature6975) do
begin
- system(*TRUECOMMAND, uid: uid, exception: true)
- rescue Errno::EPERM, Errno::EACCES, NotImplementedError
+ system(*TRUECOMMAND, uid: uid)
+ rescue Errno::EPERM, NotImplementedError
end
end
@@ -1906,7 +1845,7 @@ class TestProcess < Test::Unit::TestCase
begin
u = IO.popen([RUBY, "-e", "print Process.uid", uid: user||uid], &:read)
assert_equal(uid.to_s, u, feature6975)
- rescue Errno::EPERM, Errno::EACCES, NotImplementedError
+ rescue Errno::EPERM, NotImplementedError
end
end
end
@@ -1914,15 +1853,9 @@ class TestProcess < Test::Unit::TestCase
def test_execopts_gid
skip "Process.groups not implemented on Windows platform" if windows?
- skip "root can use Process.groups on Android platform" if RUBY_PLATFORM =~ /android/
feature6975 = '[ruby-core:47414]'
- groups = Process.groups.map do |g|
- g = Etc.getgrgid(g) rescue next
- [g.name, g.gid]
- end
- groups.compact!
- [30000, *groups].each do |group, gid|
+ [30000, *Process.groups.map {|g| g = Etc.getgrgid(g); [g.name, g.gid]}].each do |group, gid|
assert_nothing_raised(feature6975) do
begin
system(*TRUECOMMAND, gid: group)
@@ -2098,11 +2031,7 @@ EOS
def test_clock_gettime_GETTIMEOFDAY_BASED_CLOCK_REALTIME
n = :GETTIMEOFDAY_BASED_CLOCK_REALTIME
- begin
- t = Process.clock_gettime(n)
- rescue Errno::EINVAL
- return
- end
+ t = Process.clock_gettime(n)
assert_kind_of(Float, t, "Process.clock_gettime(:#{n})")
end
@@ -2180,11 +2109,7 @@ EOS
def test_clock_getres_GETTIMEOFDAY_BASED_CLOCK_REALTIME
n = :GETTIMEOFDAY_BASED_CLOCK_REALTIME
- begin
- t = Process.clock_getres(n)
- rescue Errno::EINVAL
- return
- end
+ t = Process.clock_getres(n)
assert_kind_of(Float, t, "Process.clock_getres(:#{n})")
assert_equal(1000, Process.clock_getres(n, :nanosecond))
end
@@ -2250,7 +2175,7 @@ EOS
end
def test_deadlock_by_signal_at_forking
- assert_separately(%W(--disable=gems - #{RUBY}), <<-INPUT, timeout: 100)
+ assert_separately(["-", RUBY], <<-INPUT, timeout: 80)
ruby = ARGV.shift
GC.start # reduce garbage
GC.disable # avoid triggering CoW after forks
@@ -2258,7 +2183,7 @@ EOS
parent = $$
100.times do |i|
pid = fork {Process.kill(:QUIT, parent)}
- IO.popen([ruby, -'--disable=gems'], -'r+'){}
+ IO.popen(ruby, 'r+'){}
Process.wait(pid)
$stdout.puts
$stdout.flush
@@ -2271,7 +2196,7 @@ EOS
th = Process.detach(pid)
assert_equal pid, th.pid
status = th.value
- assert_predicate status, :success?
+ assert status.success?, status.inspect
end if defined?(fork)
def test_kill_at_spawn_failure
@@ -2279,9 +2204,7 @@ EOS
th = nil
x = with_tmpchdir {|d|
prog = "#{d}/notexist"
- q = Thread::Queue.new
- th = Thread.start {system(prog);q.push(nil);sleep}
- q.pop
+ th = Thread.start {system(prog);sleep}
th.kill
th.join(0.1)
}
@@ -2332,7 +2255,7 @@ EOS
def test_signals_work_after_exec_fail
r, w = IO.pipe
pid = status = nil
- EnvUtil.timeout(30) do
+ Timeout.timeout(30) do
pid = fork do
r.close
begin
@@ -2366,7 +2289,7 @@ EOS
def test_threading_works_after_exec_fail
r, w = IO.pipe
pid = status = nil
- EnvUtil.timeout(90) do
+ Timeout.timeout(90) do
pid = fork do
r.close
begin
@@ -2375,6 +2298,7 @@ EOS
w.syswrite("exec failed\n")
end
q = Queue.new
+ run = true
th1 = Thread.new { i = 0; i += 1 while q.empty?; i }
th2 = Thread.new { j = 0; j += 1 while q.empty? && Thread.pass.nil?; j }
sleep 0.5
@@ -2399,15 +2323,6 @@ EOS
r.close if r
end if defined?(fork)
- def test_rescue_exec_fail
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- assert_raise(Errno::ENOENT) do
- exec("", in: "")
- end
- end;
- end
-
def test_many_args
bug11418 = '[ruby-core:70251] [Bug #11418]'
assert_in_out_err([], <<-"end;", ["x"]*256, [], bug11418, timeout: 60)
diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb
index 939d17bdf7..882d33fb40 100644
--- a/test/ruby/test_rand.rb
+++ b/test/ruby/test_rand.rb
@@ -347,15 +347,10 @@ END
end
def assert_random_bytes(r)
- srand(0)
assert_equal("", r.bytes(0))
- assert_equal("", Random.bytes(0))
- x = "\xAC".force_encoding("ASCII-8BIT")
- assert_equal(x, r.bytes(1))
- assert_equal(x, Random.bytes(1))
- x = "/\xAA\xC4\x97u\xA6\x16\xB7\xC0\xCC".force_encoding("ASCII-8BIT")
- assert_equal(x, r.bytes(10))
- assert_equal(x, Random.bytes(10))
+ assert_equal("\xAC".force_encoding("ASCII-8BIT"), r.bytes(1))
+ assert_equal("/\xAA\xC4\x97u\xA6\x16\xB7\xC0\xCC".force_encoding("ASCII-8BIT"),
+ r.bytes(10))
end
def test_random_range
@@ -399,8 +394,6 @@ END
assert_raise(Errno::EDOM, Errno::ERANGE) { r.rand(1.0 / 0.0) }
assert_raise(Errno::EDOM, Errno::ERANGE) { r.rand(0.0 / 0.0) }
- assert_raise(Errno::EDOM) {r.rand(1..)}
- assert_raise(Errno::EDOM) {r.rand(..1)}
r = Random.new(0)
assert_in_delta(1.5488135039273248, r.rand(1.0...2.0), 0.0001, '[ruby-core:24655]')
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index 3953b3ecc2..da883767bc 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -3,7 +3,6 @@ require 'test/unit'
require 'delegate'
require 'timeout'
require 'bigdecimal'
-require 'rbconfig/sizeof'
class TestRange < Test::Unit::TestCase
def test_new
@@ -13,9 +12,6 @@ class TestRange < Test::Unit::TestCase
assert_raise(ArgumentError) { (1.."3") }
- assert_equal((0..nil), Range.new(0, nil, false))
- assert_equal((0...nil), Range.new(0, nil, true))
-
obj = Object.new
def obj.<=>(other)
raise RuntimeError, "cmp"
@@ -35,17 +31,14 @@ class TestRange < Test::Unit::TestCase
assert_equal(["a"], ("a" .. "a").to_a)
assert_equal(["a"], ("a" ... "b").to_a)
assert_equal(["a", "b"], ("a" .. "b").to_a)
- assert_equal([*"a".."z", "aa"], ("a"..).take(27))
end
def test_range_numeric_string
assert_equal(["6", "7", "8"], ("6".."8").to_a, "[ruby-talk:343187]")
assert_equal(["6", "7"], ("6"..."8").to_a)
assert_equal(["9", "10"], ("9".."10").to_a)
- assert_equal(["9", "10"], ("9"..).take(2))
assert_equal(["09", "10"], ("09".."10").to_a, "[ruby-dev:39361]")
assert_equal(["9", "10"], (SimpleDelegator.new("9").."10").to_a)
- assert_equal(["9", "10"], (SimpleDelegator.new("9")..).take(2))
assert_equal(["9", "10"], ("9"..SimpleDelegator.new("10")).to_a)
end
@@ -80,33 +73,22 @@ class TestRange < Test::Unit::TestCase
assert_equal(1, (1..2).min)
assert_equal(nil, (2..1).min)
assert_equal(1, (1...2).min)
- assert_equal(1, (1..).min)
- assert_raise(RangeError) { (..1).min }
- assert_raise(RangeError) { (...1).min }
assert_equal(1.0, (1.0..2.0).min)
assert_equal(nil, (2.0..1.0).min)
assert_equal(1, (1.0...2.0).min)
- assert_equal(1, (1.0..).min)
assert_equal(0, (0..0).min)
assert_equal(nil, (0...0).min)
assert_equal([0,1,2], (0..10).min(3))
assert_equal([0,1], (0..1).min(3))
- assert_equal([0,1,2], (0..).min(3))
- assert_raise(RangeError) { (..1).min(3) }
- assert_raise(RangeError) { (...1).min(3) }
-
- assert_raise(RangeError) { (0..).min {|a, b| a <=> b } }
end
def test_max
assert_equal(2, (1..2).max)
assert_equal(nil, (2..1).max)
assert_equal(1, (1...2).max)
- assert_raise(RangeError) { (1..).max }
- assert_raise(RangeError) { (1...).max }
assert_equal(2.0, (1.0..2.0).max)
assert_equal(nil, (2.0..1.0).max)
@@ -121,34 +103,6 @@ class TestRange < Test::Unit::TestCase
assert_equal([10,9,8], (0..10).max(3))
assert_equal([9,8,7], (0...10).max(3))
- assert_raise(RangeError) { (1..).max(3) }
- assert_raise(RangeError) { (1...).max(3) }
-
- assert_raise(RangeError) { (..0).min {|a, b| a <=> b } }
- end
-
- def test_minmax
- assert_equal([1, 2], (1..2).minmax)
- assert_equal([nil, nil], (2..1).minmax)
- assert_equal([1, 1], (1...2).minmax)
- assert_raise(RangeError) { (1..).minmax }
- assert_raise(RangeError) { (1...).minmax }
-
- assert_equal([1.0, 2.0], (1.0..2.0).minmax)
- assert_equal([nil, nil], (2.0..1.0).minmax)
- assert_raise(TypeError) { (1.0...2.0).minmax }
- assert_raise(TypeError) { (1...1.5).minmax }
- assert_raise(TypeError) { (1.5...2).minmax }
-
- assert_equal([-0x80000002, -0x80000002], ((-0x80000002)...(-0x80000001)).minmax)
-
- assert_equal([0, 0], (0..0).minmax)
- assert_equal([nil, nil], (0...0).minmax)
-
- assert_equal([2, 1], (1..2).minmax{|a, b| b <=> a})
-
- assert_equal(['a', 'c'], ('a'..'c').minmax)
- assert_equal(['a', 'b'], ('a'...'c').minmax)
end
def test_initialize_twice
@@ -169,10 +123,9 @@ class TestRange < Test::Unit::TestCase
assert_equal(r, Marshal.load(Marshal.dump(r)))
r = 1...2
assert_equal(r, Marshal.load(Marshal.dump(r)))
- r = (1..)
- assert_equal(r, Marshal.load(Marshal.dump(r)))
- r = (1...)
- assert_equal(r, Marshal.load(Marshal.dump(r)))
+ s = Marshal.dump(r)
+ s.sub!(/endi./n, 'end0')
+ assert_raise(ArgumentError) {Marshal.load(s)}
end
def test_bad_value
@@ -182,8 +135,6 @@ class TestRange < Test::Unit::TestCase
def test_exclude_end
assert_not_predicate(0..1, :exclude_end?)
assert_predicate(0...1, :exclude_end?)
- assert_not_predicate(0.., :exclude_end?)
- assert_predicate(0..., :exclude_end?)
end
def test_eq
@@ -194,17 +145,8 @@ class TestRange < Test::Unit::TestCase
assert_not_equal(r, (1..2))
assert_not_equal(r, (0..2))
assert_not_equal(r, (0...1))
- assert_not_equal(r, (0..nil))
subclass = Class.new(Range)
assert_equal(r, subclass.new(0,1))
-
- r = (0..nil)
- assert_equal(r, r)
- assert_equal(r, (0..nil))
- assert_not_equal(r, 0)
- assert_not_equal(r, (0...nil))
- subclass = Class.new(Range)
- assert_equal(r, subclass.new(0,nil))
end
def test_eql
@@ -217,22 +159,12 @@ class TestRange < Test::Unit::TestCase
assert_not_operator(r, :eql?, 0...1)
subclass = Class.new(Range)
assert_operator(r, :eql?, subclass.new(0,1))
-
- r = (0..nil)
- assert_operator(r, :eql?, r)
- assert_operator(r, :eql?, 0..nil)
- assert_not_operator(r, :eql?, 0)
- assert_not_operator(r, :eql?, 0...nil)
- subclass = Class.new(Range)
- assert_operator(r, :eql?, subclass.new(0,nil))
end
def test_hash
assert_kind_of(Integer, (0..1).hash)
assert_equal((0..1).hash, (0..1).hash)
assert_not_equal((0..1).hash, (0...1).hash)
- assert_equal((0..nil).hash, (0..nil).hash)
- assert_not_equal((0..nil).hash, (0...nil).hash)
assert_kind_of(String, (0..1).hash.to_s)
end
@@ -242,76 +174,31 @@ class TestRange < Test::Unit::TestCase
assert_equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], a)
a = []
- (0..).step {|x| a << x; break if a.size == 10 }
- assert_equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], a)
-
- a = []
(0..10).step(2) {|x| a << x }
assert_equal([0, 2, 4, 6, 8, 10], a)
- a = []
- (0..).step(2) {|x| a << x; break if a.size == 10 }
- assert_equal([0, 2, 4, 6, 8, 10, 12, 14, 16, 18], a)
-
- assert_kind_of(Enumerator::ArithmeticSequence, (0..10).step)
- assert_kind_of(Enumerator::ArithmeticSequence, (0..10).step(2))
- assert_kind_of(Enumerator::ArithmeticSequence, (0..10).step(0.5))
- assert_kind_of(Enumerator::ArithmeticSequence, (10..0).step(-1))
- assert_kind_of(Enumerator::ArithmeticSequence, (..10).step(2))
- assert_kind_of(Enumerator::ArithmeticSequence, (1..).step(2))
-
assert_raise(ArgumentError) { (0..10).step(-1) { } }
assert_raise(ArgumentError) { (0..10).step(0) { } }
- assert_raise(ArgumentError) { (0..).step(-1) { } }
- assert_raise(ArgumentError) { (0..).step(0) { } }
a = []
("a" .. "z").step(2) {|x| a << x }
assert_equal(%w(a c e g i k m o q s u w y), a)
a = []
- ("a" .. ).step(2) {|x| a << x; break if a.size == 13 }
- assert_equal(%w(a c e g i k m o q s u w y), a)
-
- a = []
("a" .. "z").step(2**32) {|x| a << x }
assert_equal(["a"], a)
a = []
- (:a .. :z).step(2) {|x| a << x }
- assert_equal(%i(a c e g i k m o q s u w y), a)
-
- a = []
- (:a .. ).step(2) {|x| a << x; break if a.size == 13 }
- assert_equal(%i(a c e g i k m o q s u w y), a)
-
- a = []
- (:a .. :z).step(2**32) {|x| a << x }
- assert_equal([:a], a)
-
- a = []
(2**32-1 .. 2**32+1).step(2) {|x| a << x }
assert_equal([4294967295, 4294967297], a)
zero = (2**32).coerce(0).first
assert_raise(ArgumentError) { (2**32-1 .. 2**32+1).step(zero) { } }
- a = []
- (2**32-1 .. ).step(2) {|x| a << x; break if a.size == 2 }
- assert_equal([4294967295, 4294967297], a)
-
- max = RbConfig::LIMITS["FIXNUM_MAX"]
- a = []
- (max..).step {|x| a << x; break if a.size == 2 }
- assert_equal([max, max+1], a)
- a = []
- (max..).step(max) {|x| a << x; break if a.size == 4 }
- assert_equal([max, 2*max, 3*max, 4*max], a)
o1 = Object.new
o2 = Object.new
def o1.<=>(x); -1; end
def o2.<=>(x); 0; end
assert_raise(TypeError) { (o1..o2).step(1) { } }
- assert_raise(TypeError) { (o1..).step(1) { } }
class << o1; self; end.class_eval do
define_method(:succ) { o2 }
@@ -331,43 +218,12 @@ class TestRange < Test::Unit::TestCase
assert_equal([0, 0.5, 1.0, 1.5, 2.0], a)
a = []
- (0..).step(0.5) {|x| a << x; break if a.size == 5 }
- assert_equal([0, 0.5, 1.0, 1.5, 2.0], a)
-
- a = []
(0x40000000..0x40000002).step(0.5) {|x| a << x }
assert_equal([1073741824, 1073741824.5, 1073741825.0, 1073741825.5, 1073741826], a)
o = Object.new
def o.to_int() 1 end
assert_nothing_raised("[ruby-dev:34558]") { (0..2).step(o) {|x| } }
-
- o = Object.new
- class << o
- def to_str() "a" end
- def <=>(other) to_str <=> other end
- end
-
- a = []
- (o.."c").step(1) {|x| a << x}
- assert_equal(["a", "b", "c"], a)
- a = []
- (o..).step(1) {|x| a << x; break if a.size >= 3}
- assert_equal(["a", "b", "c"], a)
- end
-
- def test_step_bug15537
- assert_equal([10.0, 9.0, 8.0, 7.0], (10 ..).step(-1.0).take(4))
- assert_equal([10.0, 9.0, 8.0, 7.0], (10.0 ..).step(-1).take(4))
- end
-
- def test_percent_step
- aseq = (1..10) % 2
- assert_equal(Enumerator::ArithmeticSequence, aseq.class)
- assert_equal(1, aseq.begin)
- assert_equal(10, aseq.end)
- assert_equal(2, aseq.step)
- assert_equal([1, 3, 5, 7, 9], aseq.to_a)
end
def test_step_ruby_core_35753
@@ -384,10 +240,6 @@ class TestRange < Test::Unit::TestCase
(0..10).each {|x| a << x }
assert_equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], a)
- a = []
- (0..).each {|x| a << x; break if a.size == 10 }
- assert_equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], a)
-
o1 = Object.new
o2 = Object.new
def o1.setcmp(v) @cmpresult = v end
@@ -428,28 +280,12 @@ class TestRange < Test::Unit::TestCase
a = []
r2.each {|x| a << x }
assert_equal([], a)
-
- o = Object.new
- class << o
- def to_str() "a" end
- def <=>(other) to_str <=> other end
- end
-
- a = []
- (o.."c").each {|x| a << x}
- assert_equal(["a", "b", "c"], a)
- a = []
- (o..).each {|x| a << x; break if a.size >= 3}
- assert_equal(["a", "b", "c"], a)
end
def test_begin_end
assert_equal(0, (0..1).begin)
assert_equal(1, (0..1).end)
assert_equal(1, (0...1).end)
- assert_equal(0, (0..nil).begin)
- assert_equal(nil, (0..nil).end)
- assert_equal(nil, (0...nil).end)
end
def test_first_last
@@ -468,72 +304,31 @@ class TestRange < Test::Unit::TestCase
assert_equal("a", ("a"..."c").first)
assert_equal("c", ("a"..."c").last)
assert_equal(0, (2...0).last)
-
- assert_equal([0, 1, 2], (0..nil).first(3))
- assert_equal(0, (0..nil).first)
- assert_equal("a", ("a"..nil).first)
- assert_raise(RangeError) { (0..nil).last }
- assert_raise(RangeError) { (0..nil).last(3) }
- assert_raise(RangeError) { (nil..0).first }
- assert_raise(RangeError) { (nil..0).first(3) }
-
- assert_equal([0, 1, 2], (0..10).first(3.0))
- assert_equal([8, 9, 10], (0..10).last(3.0))
- assert_raise(TypeError) { (0..10).first("3") }
- assert_raise(TypeError) { (0..10).last("3") }
- class << (o = Object.new)
- def to_int; 3; end
- end
- assert_equal([0, 1, 2], (0..10).first(o))
- assert_equal([8, 9, 10], (0..10).last(o))
-
- assert_raise(ArgumentError) { (0..10).first(-1) }
- assert_raise(ArgumentError) { (0..10).last(-1) }
- end
-
- def test_last_with_redefine_each
- assert_in_out_err([], <<-'end;', ['true'], [])
- class Range
- remove_method :each
- def each(&b)
- [1, 2, 3, 4, 5].each(&b)
- end
- end
- puts [3, 4, 5] == (1..10).last(3)
- end;
end
def test_to_s
assert_equal("0..1", (0..1).to_s)
assert_equal("0...1", (0...1).to_s)
- assert_equal("0..", (0..nil).to_s)
- assert_equal("0...", (0...nil).to_s)
+
+ bug11767 = '[ruby-core:71811] [Bug #11767]'
+ assert_predicate(("0".taint.."1").to_s, :tainted?, bug11767)
+ assert_predicate(("0".."1".taint).to_s, :tainted?, bug11767)
+ assert_predicate(("0".."1").taint.to_s, :tainted?, bug11767)
end
def test_inspect
assert_equal("0..1", (0..1).inspect)
assert_equal("0...1", (0...1).inspect)
- assert_equal("0..", (0..nil).inspect)
- assert_equal("0...", (0...nil).inspect)
- assert_equal("..1", (nil..1).inspect)
- assert_equal("...1", (nil...1).inspect)
- assert_equal("nil..nil", (nil..nil).inspect)
- assert_equal("nil...nil", (nil...nil).inspect)
+
+ bug11767 = '[ruby-core:71811] [Bug #11767]'
+ assert_predicate(("0".taint.."1").inspect, :tainted?, bug11767)
+ assert_predicate(("0".."1".taint).inspect, :tainted?, bug11767)
+ assert_predicate(("0".."1").taint.inspect, :tainted?, bug11767)
end
def test_eqq
assert_operator(0..10, :===, 5)
assert_not_operator(0..10, :===, 11)
- assert_operator(5..nil, :===, 11)
- assert_not_operator(5..nil, :===, 0)
- end
-
- def test_eqq_string
- assert_operator('A'..'Z', :===, 'ANA')
- assert_not_operator('A'..'Z', :===, 'ana')
- assert_operator('A'.., :===, 'ANA')
- assert_operator(..'Z', :===, 'ANA')
- assert_operator(nil..nil, :===, 'ANA')
end
def test_eqq_time
@@ -541,8 +336,6 @@ class TestRange < Test::Unit::TestCase
t = Time.now
assert_nothing_raised(TypeError, bug11113) {
assert_operator(t..(t+10), :===, t+5)
- assert_operator(t.., :===, t+5)
- assert_not_operator(t.., :===, t-5)
}
end
@@ -570,27 +363,13 @@ class TestRange < Test::Unit::TestCase
assert_operator(c.new(0)..c.new(10), :===, c.new(5), bug12003)
end
- def test_eqq_non_iteratable
- k = Class.new do
- include Comparable
- attr_reader :i
- def initialize(i) @i = i; end
- def <=>(o); i <=> o.i; end
- end
- assert_operator(k.new(0)..k.new(2), :===, k.new(1))
- end
-
def test_include
assert_include("a".."z", "c")
assert_not_include("a".."z", "5")
assert_include("a"..."z", "y")
assert_not_include("a"..."z", "z")
assert_not_include("a".."z", "cc")
- assert_include("a".., "c")
- assert_not_include("a".., "5")
assert_include(0...10, 5)
- assert_include(5..., 10)
- assert_not_include(5..., 0)
end
def test_cover
@@ -599,60 +378,6 @@ class TestRange < Test::Unit::TestCase
assert_operator("a"..."z", :cover?, "y")
assert_not_operator("a"..."z", :cover?, "z")
assert_operator("a".."z", :cover?, "cc")
- assert_not_operator(5..., :cover?, 0)
- assert_not_operator(5..., :cover?, "a")
- assert_operator(5.., :cover?, 10)
-
- assert_operator(2..5, :cover?, 2..5)
- assert_operator(2...6, :cover?, 2...6)
- assert_operator(2...6, :cover?, 2..5)
- assert_operator(2..5, :cover?, 2...6)
- assert_operator(2..5, :cover?, 2..4)
- assert_operator(2..5, :cover?, 2...4)
- assert_operator(2..5, :cover?, 2...5)
- assert_operator(2..5, :cover?, 3..5)
- assert_operator(2..5, :cover?, 3..4)
- assert_operator(2..5, :cover?, 3...6)
- assert_operator(2...6, :cover?, 2...5)
- assert_operator(2...6, :cover?, 2..5)
- assert_operator(2..6, :cover?, 2...6)
- assert_operator(2.., :cover?, 2..)
- assert_operator(2.., :cover?, 3..)
- assert_operator(1.., :cover?, 1..10)
- assert_operator(..2, :cover?, ..2)
- assert_operator(..2, :cover?, ..1)
- assert_operator(..2, :cover?, 0..1)
- assert_operator(2.0..5.0, :cover?, 2..3)
- assert_operator(2..5, :cover?, 2.0..3.0)
- assert_operator(2..5, :cover?, 2.0...3.0)
- assert_operator(2..5, :cover?, 2.0...5.0)
- assert_operator(2.0..5.0, :cover?, 2.0...3.0)
- assert_operator(2.0..5.0, :cover?, 2.0...5.0)
- assert_operator('aa'..'zz', :cover?, 'aa'...'bb')
-
- assert_not_operator(2..5, :cover?, 1..5)
- assert_not_operator(2...6, :cover?, 1..5)
- assert_not_operator(2..5, :cover?, 1...6)
- assert_not_operator(1..3, :cover?, 1...6)
- assert_not_operator(2..5, :cover?, 2..6)
- assert_not_operator(2...6, :cover?, 2..6)
- assert_not_operator(2...6, :cover?, 2...7)
- assert_not_operator(2..3, :cover?, 1..4)
- assert_not_operator(1..2, :cover?, 1.0..3.0)
- assert_not_operator(1.0..2.9, :cover?, 1.0..3.0)
- assert_not_operator(1..2, :cover?, 4..3)
- assert_not_operator(2..1, :cover?, 1..2)
- assert_not_operator(1...2, :cover?, 1...3)
- assert_not_operator(2.., :cover?, 1..)
- assert_not_operator(2.., :cover?, 1..10)
- assert_not_operator(2.., :cover?, ..10)
- assert_not_operator(1..10, :cover?, 1..)
- assert_not_operator(1..10, :cover?, ..1)
- assert_not_operator(1..5, :cover?, 3..2)
- assert_not_operator(1..10, :cover?, 3...2)
- assert_not_operator(1..10, :cover?, 3...3)
- assert_not_operator('aa'..'zz', :cover?, 'aa'...'zzz')
- assert_not_operator(1..10, :cover?, 1...10.1)
end
def test_beg_len
@@ -730,13 +455,6 @@ class TestRange < Test::Unit::TestCase
assert_equal 6, (1...6.3).size
assert_equal 5, (1.1...6).size
assert_equal 42, (1..42).each.size
- assert_nil ("a"..."z").size
-
- assert_equal Float::INFINITY, (1...).size
- assert_equal Float::INFINITY, (1.0...).size
- assert_equal Float::INFINITY, (...1).size
- assert_equal Float::INFINITY, (...1.0).size
- assert_nil ("a"...).size
end
def test_bsearch_typechecks_return_values
@@ -778,9 +496,6 @@ class TestRange < Test::Unit::TestCase
ary = [0, 100, 100, 100, 200]
assert_equal(1, (0...ary.size).bsearch {|i| ary[i] >= 100 })
-
- assert_equal(1_000_001, (0...).bsearch {|i| i > 1_000_000 })
- assert_equal( -999_999, (...0).bsearch {|i| i > -1_000_000 })
end
def test_bsearch_for_float
@@ -832,9 +547,6 @@ class TestRange < Test::Unit::TestCase
assert_in_delta(1.0, (0.0..inf).bsearch {|x| Math.log(x) >= 0 })
assert_in_delta(7.0, (0.0..10).bsearch {|x| 7.0 - x })
-
- assert_equal( 1_000_000.0.next_float, (0.0..).bsearch {|x| x > 1_000_000 })
- assert_equal(-1_000_000.0.next_float, (..0.0).bsearch {|x| x > -1_000_000 })
end
def check_bsearch_values(range, search, a)
@@ -936,8 +648,6 @@ class TestRange < Test::Unit::TestCase
assert_equal(nil, (bignum...bignum+ary.size).bsearch {|i| ary[i - bignum] >= 100 })
assert_equal(bignum + 0, (bignum...bignum+ary.size).bsearch {|i| true })
assert_equal(nil, (bignum...bignum+ary.size).bsearch {|i| false })
- assert_equal(bignum * 2 + 1, (bignum...).bsearch {|i| i > bignum * 2 })
- assert_equal(-bignum * 2 + 1, (...-bignum).bsearch {|i| i > -bignum * 2 })
assert_raise(TypeError) { ("a".."z").bsearch {} }
end
@@ -949,18 +659,4 @@ class TestRange < Test::Unit::TestCase
end
(a.."c").each {|x, &b| assert_nil(b)}
end
-
- def test_to_a
- assert_equal([1,2,3,4,5], (1..5).to_a)
- assert_equal([1,2,3,4], (1...5).to_a)
- assert_raise(RangeError) { (1..).to_a }
- end
-
- def test_beginless_range_iteration
- assert_raise(TypeError) { (..1).each { } }
- end
-
- def test_count
- assert_equal(Float::INFINITY, (1..).count)
- end
end
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 5676b41445..2152486742 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -110,7 +110,6 @@ class Rational_Test < Test::Unit::TestCase
assert_equal(Rational(3),Rational('3'))
assert_equal(Rational(1),Rational('3.0','3.0'))
assert_equal(Rational(1),Rational('3/3','3/3'))
- assert_equal(Rational(111, 1), Rational('1.11e+2'))
assert_equal(Rational(111, 10), Rational('1.11e+1'))
assert_equal(Rational(111, 10), Rational('1.11e1'))
assert_equal(Rational(111, 100), Rational('1.11e0'))
@@ -120,35 +119,7 @@ class Rational_Test < Test::Unit::TestCase
assert_raise_with_message(ArgumentError, /\u{221a 2668}/) {
Rational("\u{221a 2668}")
}
- assert_warning('') {
- assert_predicate(Rational('1e-99999999999999999999'), :zero?)
- }
-
assert_raise(TypeError){Rational(Object.new)}
- assert_raise(TypeError){Rational(Object.new, Object.new)}
- assert_raise(TypeError){Rational(1, Object.new)}
-
- o = Object.new
- def o.to_r; 1/42r; end
- assert_equal(1/42r, Rational(o))
- assert_equal(1/84r, Rational(o, 2))
- assert_equal(42, Rational(1, o))
- assert_equal(1, Rational(o, o))
-
- o = Object.new
- def o.to_r; nil; end
- assert_raise(TypeError) { Rational(o) }
- assert_raise(TypeError) { Rational(o, 2) }
- assert_raise(TypeError) { Rational(1, o) }
- assert_raise(TypeError) { Rational(o, o) }
-
- o = Object.new
- def o.to_r; raise; end
- assert_raise(RuntimeError) { Rational(o) }
- assert_raise(RuntimeError) { Rational(o, 2) }
- assert_raise(RuntimeError) { Rational(1, o) }
- assert_raise(RuntimeError) { Rational(o, o) }
-
assert_raise(ArgumentError){Rational()}
assert_raise(ArgumentError){Rational(1,2,3)}
@@ -595,16 +566,9 @@ class Rational_Test < Test::Unit::TestCase
assert_equal([Rational(2.2),Rational(1)], Rational(1).coerce(2.2))
assert_equal([Rational(2),Rational(1)], Rational(1).coerce(Rational(2)))
- assert_nothing_raised(TypeError, '[Bug #5020] [ruby-dev:44088]') do
+ assert_nothing_raised(TypeError, '[Bug #5020] [ruby-devl:44088]') do
Rational(1,2).coerce(Complex(1,1))
end
-
- assert_raise(ZeroDivisionError) do
- 1 / 0r.coerce(0+0i)[0]
- end
- assert_raise(ZeroDivisionError) do
- 1 / 0r.coerce(0.0+0i)[0]
- end
end
class ObjectX
@@ -815,42 +779,6 @@ class Rational_Test < Test::Unit::TestCase
assert_raise(ZeroDivisionError) {Rational("1/0")}
end
- def test_Rational_with_invalid_exception
- assert_raise(ArgumentError) {
- Rational("1/1", exception: 1)
- }
- end
-
- def test_Rational_without_exception
- assert_nothing_raised(ArgumentError) {
- assert_equal(nil, Rational("5/3x", exception: false))
- }
- assert_nothing_raised(ZeroDivisionError) {
- assert_equal(nil, Rational("1/0", exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Rational(nil, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Rational(Object.new, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Rational(1, nil, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Rational(1, Object.new, exception: false))
- }
-
- o = Object.new;
- def o.to_r; raise; end
- assert_nothing_raised(RuntimeError) {
- assert_equal(nil, Rational(o, exception: false))
- }
- assert_nothing_raised(TypeError) {
- assert_equal(nil, Rational(1, o, exception: false))
- }
- end
-
def test_to_i
assert_equal(1, Rational(3,2).to_i)
assert_equal(1, Integer(Rational(3,2)))
@@ -859,7 +787,6 @@ class Rational_Test < Test::Unit::TestCase
def test_to_f
assert_equal(1.5, Rational(3,2).to_f)
assert_equal(1.5, Float(Rational(3,2)))
- assert_equal(1e-23, Rational(1, 10**23).to_f, "Bug #14637")
end
def test_to_c
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 6fb04de5d6..7725820038 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -19,10 +19,6 @@ class TestRefinement < Test::Unit::TestCase
return "Foo#a"
end
- def b
- return "Foo#b"
- end
-
def call_x
return x
end
@@ -45,10 +41,6 @@ class TestRefinement < Test::Unit::TestCase
def a
return "FooExt#a"
end
-
- private def b
- return "FooExt#b"
- end
end
end
@@ -102,26 +94,10 @@ class TestRefinement < Test::Unit::TestCase
return foo.send(:z)
end
- def self.send_b_on(foo)
- return foo.send(:b)
- end
-
- def self.public_send_z_on(foo)
- return foo.public_send(:z)
- end
-
- def self.public_send_b_on(foo)
- return foo.public_send(:b)
- end
-
def self.method_z(foo)
return foo.method(:z)
end
- def self.instance_method_z(foo)
- return foo.class.instance_method(:z)
- end
-
def self.invoke_call_x_on(foo)
return foo.call_x
end
@@ -203,59 +179,16 @@ class TestRefinement < Test::Unit::TestCase
foo = Foo.new
assert_raise(NoMethodError) { foo.send(:z) }
assert_equal("FooExt#z", FooExtClient.send_z_on(foo))
- assert_equal("FooExt#b", FooExtClient.send_b_on(foo))
assert_raise(NoMethodError) { foo.send(:z) }
assert_equal(true, RespondTo::Sub.new.respond_to?(:foo))
end
- def test_public_send_should_use_refinements
- foo = Foo.new
- assert_raise(NoMethodError) { foo.public_send(:z) }
- assert_equal("FooExt#z", FooExtClient.public_send_z_on(foo))
- assert_equal("Foo#b", foo.public_send(:b))
- assert_raise(NoMethodError) { FooExtClient.public_send_b_on(foo) }
- end
-
- module MethodIntegerPowEx
- refine Integer do
- def pow(*)
- :refine_pow
- end
- end
- end
- def test_method_should_use_refinements
+ def test_method_should_not_use_refinements
foo = Foo.new
assert_raise(NameError) { foo.method(:z) }
- assert_equal("FooExt#z", FooExtClient.method_z(foo).call)
+ assert_raise(NameError) { FooExtClient.method_z(foo) }
assert_raise(NameError) { foo.method(:z) }
- assert_equal(8, eval(<<~EOS, Sandbox::BINDING))
- meth = 2.method(:pow)
- using MethodIntegerPowEx
- meth.call(3)
- EOS
- assert_equal(:refine_pow, eval_using(MethodIntegerPowEx, "2.pow(3)"))
- assert_equal(:refine_pow, eval_using(MethodIntegerPowEx, "2.method(:pow).(3)"))
- end
-
- module InstanceMethodIntegerPowEx
- refine Integer do
- def abs
- :refine_abs
- end
- end
- end
- def test_instance_method_should_use_refinements
- foo = Foo.new
- assert_raise(NameError) { Foo.instance_method(:z) }
- assert_equal("FooExt#z", FooExtClient.instance_method_z(foo).bind(foo).call)
- assert_raise(NameError) { Foo.instance_method(:z) }
- assert_equal(4, eval(<<~EOS, Sandbox::BINDING))
- meth = Integer.instance_method(:abs)
- using InstanceMethodIntegerPowEx
- meth.bind(-4).call
- EOS
- assert_equal(:refine_abs, eval_using(InstanceMethodIntegerPowEx, "Integer.instance_method(:abs).bind(-4).call"))
end
def test_no_local_rebinding
@@ -364,9 +297,9 @@ class TestRefinement < Test::Unit::TestCase
end
end
- def test_respond_to_should_use_refinements
+ def test_respond_to_should_not_use_refinements
assert_equal(false, 1.respond_to?(:foo))
- assert_equal(true, eval_using(IntegerFooExt, "1.respond_to?(:foo)"))
+ assert_equal(false, eval_using(IntegerFooExt, "1.respond_to?(:foo)"))
end
module StringCmpExt
@@ -538,7 +471,7 @@ class TestRefinement < Test::Unit::TestCase
def test_main_using_is_private
assert_raise(NoMethodError) do
- eval("recv = self; recv.using Module.new", Sandbox::BINDING)
+ eval("self.using Module.new", Sandbox::BINDING)
end
end
@@ -916,7 +849,7 @@ class TestRefinement < Test::Unit::TestCase
#{PrependAfterRefine_CODE}
undef PrependAfterRefine
}
- }, timeout: 30
+ }
end
def test_prepend_after_refine
@@ -974,10 +907,6 @@ class TestRefinement < Test::Unit::TestCase
return foo.send(:z)
end
- def self.public_send_z_on(foo)
- return foo.public_send(:z)
- end
-
def self.method_z(foo)
return foo.method(:z)
end
@@ -1562,7 +1491,6 @@ class TestRefinement < Test::Unit::TestCase
undef :foo
end
end
- ext
end
def test_call_refined_method_in_duplicate_module
@@ -2064,6 +1992,7 @@ class TestRefinement < Test::Unit::TestCase
def test_tostring
assert_equal("ok", ToString.new.string)
+ assert_predicate(ToString.new.taint.string, :tainted?)
end
class ToSymbol
@@ -2081,122 +2010,6 @@ class TestRefinement < Test::Unit::TestCase
assert_equal(:foo, ToSymbol.new("foo").symbol)
end
- module ToProc
- def self.call &block
- block.call
- end
-
- class ReturnProc
- c = self
- using Module.new {
- refine c do
- def to_proc
- proc { "to_proc" }
- end
- end
- }
- def call
- ToProc.call(&self)
- end
- end
-
- class ReturnNoProc
- c = self
- using Module.new {
- refine c do
- def to_proc
- true
- end
- end
- }
-
- def call
- ToProc.call(&self)
- end
- end
-
- class PrivateToProc
- c = self
- using Module.new {
- refine c do
- private
- def to_proc
- proc { "private_to_proc" }
- end
- end
- }
-
- def call
- ToProc.call(&self)
- end
- end
-
-
- class NonProc
- def call
- ToProc.call(&self)
- end
- end
-
- class MethodMissing
- def method_missing *args
- proc { "method_missing" }
- end
-
- def call
- ToProc.call(&self)
- end
- end
-
- class ToProcAndMethodMissing
- def method_missing *args
- proc { "method_missing" }
- end
-
- c = self
- using Module.new {
- refine c do
- def to_proc
- proc { "to_proc" }
- end
- end
- }
-
- def call
- ToProc.call(&self)
- end
- end
-
- class ToProcAndRefinements
- def to_proc
- proc { "to_proc" }
- end
-
- c = self
- using Module.new {
- refine c do
- def to_proc
- proc { "refinements_to_proc" }
- end
- end
- }
-
- def call
- ToProc.call(&self)
- end
- end
- end
-
- def test_to_proc
- assert_equal("to_proc", ToProc::ReturnProc.new.call)
- assert_equal("private_to_proc", ToProc::PrivateToProc.new.call)
- assert_raise(TypeError){ ToProc::ReturnNoProc.new.call }
- assert_raise(TypeError){ ToProc::NonProc.new.call }
- assert_equal("method_missing", ToProc::MethodMissing.new.call)
- assert_equal("to_proc", ToProc::ToProcAndMethodMissing.new.call)
- assert_equal("refinements_to_proc", ToProc::ToProcAndRefinements.new.call)
- end
-
def test_unused_refinement_for_module
bug14068 = '[ruby-core:83613] [Bug #14068]'
assert_in_out_err([], <<-INPUT, ["M1#foo"], [], bug14068)
@@ -2291,95 +2104,6 @@ class TestRefinement < Test::Unit::TestCase
end
end
assert_equal("[C[A[B]]]", c.new.foo, '[ruby-dev:50390] [Bug #14232]')
- d
- end
-
- class RefineInUsing
- module M1
- refine RefineInUsing do
- def foo
- :ok
- end
- end
- end
-
- module M2
- using M1
- refine RefineInUsing do
- def call_foo
- RefineInUsing.new.foo
- end
- end
- end
-
- using M2
- def self.test
- new.call_foo
- end
- end
-
- def test_refine_in_using
- assert_equal(:ok, RefineInUsing.test)
- end
-
- class Bug16242
- module OtherM
- end
-
- module M
- prepend OtherM
-
- refine M do
- def refine_method
- "refine_method"
- end
- end
- using M
-
- def hoge
- refine_method
- end
- end
-
- class X
- include M
- end
- end
-
- def test_refine_prepended_module
- assert_equal("refine_method", Bug16242::X.new.hoge)
- end
-
- module Bug13446
- module Enumerable
- def sum(*args)
- i = 0
- args.each { |arg| i += a }
- i
- end
- end
-
- using Module.new {
- refine Enumerable do
- alias :orig_sum :sum
- end
- }
-
- module Enumerable
- def sum(*args)
- orig_sum(*args)
- end
- end
-
- class GenericEnumerable
- include Enumerable
- end
-
- Enumerable.prepend(Module.new)
- end
-
- def test_prepend_refined_module
- assert_equal(0, Bug13446::GenericEnumerable.new.sum)
end
private
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 8709d05752..fe271dc3d7 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -90,11 +90,6 @@ class TestRegexp < Test::Unit::TestCase
rescue ArgumentError
:ok
end
- re = Regexp.union(/\//, "")
- re2 = eval(re.inspect)
- assert_equal(re.to_s, re2.to_s)
- assert_equal(re.source, re2.source)
- assert_equal(re, re2)
end
def test_word_boundary
@@ -218,23 +213,6 @@ class TestRegexp < Test::Unit::TestCase
def test_assign_named_capture_to_reserved_word
/(?<nil>.)/ =~ "a"
assert_not_include(local_variables, :nil, "[ruby-dev:32675]")
-
- def (obj = Object.new).test(s, nil: :ng)
- /(?<nil>.)/ =~ s
- binding.local_variable_get(:nil)
- end
- assert_equal("b", obj.test("b"))
-
- tap do |nil: :ng|
- /(?<nil>.)/ =~ "c"
- assert_equal("c", binding.local_variable_get(:nil))
- end
- end
-
- def test_assign_named_capture_to_const
- %W[C \u{1d402}].each do |name|
- assert_equal(:ok, Class.new.class_eval("#{name} = :ok; /(?<#{name}>.*)/ =~ 'ng'; #{name}"))
- end
end
def test_assign_named_capture_trace
@@ -541,8 +519,6 @@ class TestRegexp < Test::Unit::TestCase
s = ".........."
5.times { s.sub!(".", "") }
assert_equal(".....", s)
-
- assert_equal("\\\u{3042}", Regexp.new("\\\u{3042}").source)
end
def test_equal
@@ -691,16 +667,11 @@ class TestRegexp < Test::Unit::TestCase
test = proc {|&blk| "abc".sub("a", ""); blk.call($~) }
bug10877 = '[ruby-core:68209] [Bug #10877]'
- bug18160 = '[Bug #18160]'
test.call {|m| assert_raise_with_message(IndexError, /foo/, bug10877) {m["foo"]} }
key = "\u{3042}"
[Encoding::UTF_8, Encoding::Shift_JIS, Encoding::EUC_JP].each do |enc|
idx = key.encode(enc)
- pat = /#{idx}/
- test.call {|m| assert_raise_with_message(IndexError, pat, bug10877) {m[idx]} }
- test.call {|m| assert_raise_with_message(IndexError, pat, bug18160) {m.offset(idx)} }
- test.call {|m| assert_raise_with_message(IndexError, pat, bug18160) {m.begin(idx)} }
- test.call {|m| assert_raise_with_message(IndexError, pat, bug18160) {m.end(idx)} }
+ test.call {|m| assert_raise_with_message(IndexError, /#{idx}/, bug10877) {m[idx]} }
end
test.call {|m| assert_equal(/a/, m.regexp) }
test.call {|m| assert_equal("abc", m.string) }
@@ -970,29 +941,24 @@ class TestRegexp < Test::Unit::TestCase
end
def test_cclass_R
- assert_match(/\A\R\z/, "\r")
- assert_match(/\A\R\z/, "\n")
- assert_match(/\A\R\z/, "\f")
- assert_match(/\A\R\z/, "\v")
- assert_match(/\A\R\z/, "\r\n")
- assert_match(/\A\R\z/, "\u0085")
- assert_match(/\A\R\z/, "\u2028")
- assert_match(/\A\R\z/, "\u2029")
+ assert_match /\A\R\z/, "\r"
+ assert_match /\A\R\z/, "\n"
+ assert_match /\A\R\z/, "\r\n"
end
def test_cclass_X
- assert_match(/\A\X\z/, "\u{20 200d}")
- assert_match(/\A\X\z/, "\u{600 600}")
- assert_match(/\A\X\z/, "\u{600 20}")
- assert_match(/\A\X\z/, "\u{261d 1F3FB}")
- assert_match(/\A\X\z/, "\u{1f600}")
- assert_match(/\A\X\z/, "\u{20 324}")
- assert_match(/\A\X\X\z/, "\u{a 324}")
- assert_match(/\A\X\X\z/, "\u{d 324}")
- assert_match(/\A\X\z/, "\u{1F477 1F3FF 200D 2640 FE0F}")
- assert_match(/\A\X\z/, "\u{1F468 200D 1F393}")
- assert_match(/\A\X\z/, "\u{1F46F 200D 2642 FE0F}")
- assert_match(/\A\X\z/, "\u{1f469 200d 2764 fe0f 200d 1f469}")
+ assert_match /\A\X\z/, "\u{20 200d}"
+ assert_match /\A\X\z/, "\u{600 600}"
+ assert_match /\A\X\z/, "\u{600 20}"
+ assert_match /\A\X\z/, "\u{261d 1F3FB}"
+ assert_match /\A\X\z/, "\u{1f600}"
+ assert_match /\A\X\z/, "\u{20 308}"
+ assert_match /\A\X\X\z/, "\u{a 308}"
+ assert_match /\A\X\X\z/, "\u{d 308}"
+ assert_match /\A\X\z/, "\u{1F477 1F3FF 200D 2640 FE0F}"
+ assert_match /\A\X\z/, "\u{1F468 200D 1F393}"
+ assert_match /\A\X\z/, "\u{1F46F 200D 2642 FE0F}"
+ assert_match /\A\X\z/, "\u{1f469 200d 2764 fe0f 200d 1f469}"
assert_warning('') {/\X/ =~ "\u{a0}"}
end
@@ -1022,8 +988,6 @@ class TestRegexp < Test::Unit::TestCase
assert_raise(TypeError) { Regexp.allocate.names }
assert_raise(TypeError) { Regexp.allocate.named_captures }
- assert_not_respond_to(MatchData, :allocate)
-=begin
assert_raise(TypeError) { MatchData.allocate.hash }
assert_raise(TypeError) { MatchData.allocate.regexp }
assert_raise(TypeError) { MatchData.allocate.names }
@@ -1046,7 +1010,6 @@ class TestRegexp < Test::Unit::TestCase
assert_raise(TypeError) { $` }
assert_raise(TypeError) { $' }
assert_raise(TypeError) { $+ }
-=end
end
def test_unicode
@@ -1103,9 +1066,6 @@ class TestRegexp < Test::Unit::TestCase
assert_no_match(/^\p{age=3.0}$/u, "\u2754")
assert_no_match(/^\p{age=2.0}$/u, "\u2754")
assert_no_match(/^\p{age=1.1}$/u, "\u2754")
-
- assert_no_match(/^\p{age=12.0}$/u, "\u32FF")
- assert_match(/^\p{age=12.1}$/u, "\u32FF")
end
MatchData_A = eval("class MatchData_\u{3042} < MatchData; self; end")
@@ -1116,9 +1076,7 @@ class TestRegexp < Test::Unit::TestCase
assert_equal(a, b, '[ruby-core:24748]')
h = {a => 42}
assert_equal(42, h[b], '[ruby-core:24748]')
-=begin
assert_match(/#<TestRegexp::MatchData_\u{3042}:/, MatchData_A.allocate.inspect)
-=end
h = /^(?<@time>\d+): (?<body>.*)/.match("123456: hoge fuga")
assert_equal("123456", h["@time"])
@@ -1154,8 +1112,6 @@ class TestRegexp < Test::Unit::TestCase
bug8151 = '[ruby-core:53649]'
assert_warning(/\A\z/, bug8151) { Regexp.new('(?:[\u{33}])').to_s }
-
- assert_warning(%r[/.*/\Z]) { Regexp.new("[\n\n]") }
end
def test_property_warn
@@ -1293,12 +1249,6 @@ class TestRegexp < Test::Unit::TestCase
assert_nil($1)
end
- def test_backref_overrun
- assert_raise_with_message(SyntaxError, /invalid backref number/) do
- eval(%["".match(/(())(?<X>)((?(90000)))/)])
- end
- end
-
# This assertion is for porting x2() tests in testpy.py of Onigmo.
def assert_match_at(re, str, positions, msg = nil)
re = Regexp.new(re) unless re.is_a?(Regexp)
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index a1adb4926f..28cf686a26 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -62,6 +62,12 @@ class TestRequire < Test::Unit::TestCase
assert_require_nonascii_path(encoding, bug8165)
end
+ def test_require_insecure_path
+ assert_require_insecure_path("foo")
+ encoding = 'filesystem'
+ assert_require_insecure_path(nil, encoding)
+ end
+
def test_require_nonascii_path_utf8
bug8676 = '[ruby-core:56136] [Bug #8676]'
encoding = Encoding::UTF_8
@@ -69,6 +75,12 @@ class TestRequire < Test::Unit::TestCase
assert_require_nonascii_path(encoding, bug8676)
end
+ def test_require_insecure_path_utf8
+ encoding = Encoding::UTF_8
+ return if Encoding.find('filesystem') == encoding
+ assert_require_insecure_path(nil, encoding)
+ end
+
def test_require_nonascii_path_shift_jis
bug8676 = '[ruby-core:56136] [Bug #8676]'
encoding = Encoding::Shift_JIS
@@ -76,6 +88,12 @@ class TestRequire < Test::Unit::TestCase
assert_require_nonascii_path(encoding, bug8676)
end
+ def test_require_insecure_path_shift_jis
+ encoding = Encoding::Shift_JIS
+ return if Encoding.find('filesystem') == encoding
+ assert_require_insecure_path(nil, encoding)
+ end
+
case RUBY_PLATFORM
when /cygwin/, /mswin/, /mingw/, /darwin/
def self.ospath_encoding(path)
@@ -87,6 +105,16 @@ class TestRequire < Test::Unit::TestCase
end
end
+ SECURITY_WARNING =
+ if /mswin|mingw/ =~ RUBY_PLATFORM
+ nil
+ else
+ proc do |require_path|
+ $SAFE = 1
+ require(require_path)
+ end
+ end
+
def prepare_require_path(dir, encoding)
Dir.mktmpdir {|tmp|
begin
@@ -123,6 +151,31 @@ class TestRequire < Test::Unit::TestCase
}
end
+ def assert_require_insecure_path(dirname, encoding = nil)
+ return unless SECURITY_WARNING
+ dirname ||= "\u3042" * 5
+ encoding ||= dirname.encoding
+ prepare_require_path(dirname, encoding) {|require_path|
+ require_path.untaint
+ require(require_path)
+ $".pop
+ File.chmod(0777, File.dirname(require_path))
+ ospath = (require_path.encode('filesystem') rescue
+ require_path.encode(self.class.ospath_encoding(require_path)))
+ e = nil
+ stderr = EnvUtil.verbose_warning do
+ e = assert_raise(SecurityError) do
+ SECURITY_WARNING.call(require_path)
+ end
+ end
+ assert_include(e.message, "loading from unsafe path")
+ assert_include(stderr, "Insecure world writable dir")
+ require_path = require_path.encode(self.class.ospath_encoding(require_path))
+ assert_include(e.message, require_path)
+ assert_include(stderr, File.dirname(require_path))
+ }
+ end
+
def test_require_path_home_1
env_rubypath, env_home = ENV["RUBYPATH"], ENV["HOME"]
pathname_too_long = /pathname too long \(ignored\).*\(LoadError\)/m
@@ -201,12 +254,12 @@ class TestRequire < Test::Unit::TestCase
def assert_syntax_error_backtrace
Dir.mktmpdir do |tmp|
req = File.join(tmp, "test.rb")
- File.write(req, ",\n")
- e = assert_raise_with_message(SyntaxError, /unexpected/) {
+ File.write(req, "'\n")
+ e = assert_raise_with_message(SyntaxError, /unterminated/) {
yield req
}
- assert_not_nil(bt = e.backtrace, "no backtrace")
- assert_not_empty(bt.find_all {|b| b.start_with? __FILE__}, proc {bt.inspect})
+ assert_not_nil(bt = e.backtrace)
+ assert_not_empty(bt.find_all {|b| b.start_with? __FILE__})
end
end
@@ -214,13 +267,6 @@ class TestRequire < Test::Unit::TestCase
assert_syntax_error_backtrace {|req| require req}
end
- def test_require_syntax_error_rescued
- assert_syntax_error_backtrace do |req|
- assert_raise_with_message(SyntaxError, /unexpected/) {require req}
- require req
- end
- end
-
def test_load_syntax_error
assert_syntax_error_backtrace {|req| load req}
end
@@ -336,19 +382,6 @@ class TestRequire < Test::Unit::TestCase
}
end
- def test_require_in_wrapped_load
- Dir.mktmpdir do |tmp|
- File.write("#{tmp}/1.rb", "require_relative '2'\n")
- File.write("#{tmp}/2.rb", "class Foo\n""end\n")
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- path = ""#{tmp.dump}"/1.rb"
- begin;
- load path, true
- assert_instance_of(Class, Foo)
- end;
- end
- end
-
def test_load_scope
bug1982 = '[ruby-core:25039] [Bug #1982]'
Tempfile.create(["test_ruby_test_require", ".rb"]) {|t|
@@ -368,15 +401,15 @@ class TestRequire < Test::Unit::TestCase
bug = '[ruby-list:49994] path in ospath'
base = "test_load\u{3042 3044 3046 3048 304a}".encode(Encoding::Windows_31J)
path = nil
- Dir.mktmpdir do |dir|
- path = File.join(dir, base+".rb")
+ Tempfile.create([base, ".rb"]) do |t|
+ path = t.path
+
assert_raise_with_message(LoadError, /#{base}/) {
- load(File.join(dir, base))
+ load(File.join(File.dirname(path), base))
}
- File.open(path, "w+b") do |t|
- t.puts "warn 'ok'"
- end
+ t.puts "warn 'ok'"
+ t.close
assert_include(path, base)
assert_warn("ok\n", bug) {
assert_nothing_raised(LoadError, bug) {
@@ -386,6 +419,38 @@ class TestRequire < Test::Unit::TestCase
end
end
+ def test_tainted_loadpath
+ Tempfile.create(["test_ruby_test_require", ".rb"]) {|t|
+ abs_dir, file = File.split(t.path)
+ abs_dir = File.expand_path(abs_dir).untaint
+
+ assert_separately([], <<-INPUT)
+ abs_dir = "#{ abs_dir }"
+ $: << abs_dir
+ assert_nothing_raised {require "#{ file }"}
+ INPUT
+
+ assert_separately([], <<-INPUT)
+ abs_dir = "#{ abs_dir }"
+ $: << abs_dir.taint
+ assert_nothing_raised {require "#{ file }"}
+ INPUT
+
+ assert_separately([], <<-INPUT)
+ abs_dir = "#{ abs_dir }"
+ $: << abs_dir.taint
+ $SAFE = 1
+ assert_raise(SecurityError) {require "#{ file }"}
+ INPUT
+
+ assert_separately([], <<-INPUT)
+ abs_dir = "#{ abs_dir }"
+ $: << abs_dir << 'elsewhere'.taint
+ assert_nothing_raised {require "#{ file }"}
+ INPUT
+ }
+ end
+
def test_relative
load_path = $:.dup
$:.delete(".")
@@ -472,7 +537,7 @@ class TestRequire < Test::Unit::TestCase
t1 = Thread.new do
Thread.pass until start
begin
- Kernel.send(:require, path)
+ require(path)
rescue RuntimeError
end
@@ -481,7 +546,7 @@ class TestRequire < Test::Unit::TestCase
t2 = Thread.new do
Thread.pass until scratch[0]
- t2_res = Kernel.send(:require, path)
+ t2_res = require(path)
end
t1[:scratch] = t2[:scratch] = scratch
@@ -825,46 +890,9 @@ class TestRequire < Test::Unit::TestCase
rescue NotImplementedError, Errno::EACCES
skip "File.symlink is not implemented"
end
- File.write(File.join(tmp, "real/test_symlink_load_path.rb"), "print __FILE__")
- result = IO.popen([EnvUtil.rubybin, "-I#{tmp}/symlink", "-e", "require 'test_symlink_load_path.rb'"], &:read)
- assert_operator(result, :end_with?, "/real/test_symlink_load_path.rb")
+ File.write(File.join(tmp, "real/a.rb"), "print __FILE__")
+ result = IO.popen([EnvUtil.rubybin, "-I#{tmp}/symlink", "-e", "require 'a.rb'"], &:read)
+ assert_operator(result, :end_with?, "/real/a.rb")
}
end
-
- def test_provide_in_required_file
- paths, loaded = $:.dup, $".dup
- Dir.mktmpdir do |tmp|
- provide = File.realdirpath("provide.rb", tmp)
- File.write(File.join(tmp, "target.rb"), "raise __FILE__\n")
- File.write(provide, '$" << '"'target.rb'\n")
- $:.replace([tmp])
- assert(require("provide"))
- assert(!require("target"))
- assert_equal($".pop, provide)
- assert_equal($".pop, "target.rb")
- end
- ensure
- $:.replace(paths)
- $".replace(loaded)
- end
-
- if defined?($LOAD_PATH.resolve_feature_path)
- def test_resolve_feature_path
- paths, loaded = $:.dup, $".dup
- Dir.mktmpdir do |tmp|
- Tempfile.create(%w[feature .rb], tmp) do |file|
- file.close
- path = File.realpath(file.path)
- dir, base = File.split(path)
- $:.unshift(dir)
- assert_equal([:rb, path], $LOAD_PATH.resolve_feature_path(base))
- $".push(path)
- assert_equal([:rb, path], $LOAD_PATH.resolve_feature_path(base))
- end
- end
- ensure
- $:.replace(paths)
- $".replace(loaded)
- end
- end
end
diff --git a/test/ruby/test_require_lib.rb b/test/ruby/test_require_lib.rb
deleted file mode 100644
index 4af57173b8..0000000000
--- a/test/ruby/test_require_lib.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-
-class TestRequireLib < Test::Unit::TestCase
- TEST_RATIO = ENV["TEST_REQUIRE_THREAD_RATIO"]&.tap {|s|break s.to_f} || 0.05 # testing all files needs too long time...
-
- Dir.glob(File.expand_path('../../lib/**/*.rb', __dir__)).each do |lib|
- # skip some problems
- next if %r!/lib/(?:bundler|rubygems)\b! =~ lib
- next if %r!/lib/(?:debug|mkmf)\.rb\z! =~ lib
- # skip because "in `<module:Maker>': undefined method `add_maker' for RSS::Maker:Module (NoMethodError)"
- next if %r!/lib/rss\b! =~ lib
- # skip many files that almost use no threads
- next if TEST_RATIO < rand(0.0..1.0)
- define_method "test_thread_size:#{lib}" do
- assert_separately(['--disable-gems', '-W0'], "#{<<~"begin;"}\n#{<<~"end;"}")
- begin;
- n = Thread.list.size
- begin
- require #{lib.dump}
- rescue Exception
- skip $!
- end
- assert_equal n, Thread.list.size
- end;
- end
- end
-end
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 2842b63804..54213c4698 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -1,19 +1,10 @@
# -*- coding: us-ascii -*-
require 'test/unit'
-require 'timeout'
require 'tmpdir'
require 'tempfile'
-require_relative '../lib/jit_support'
class TestRubyOptions < Test::Unit::TestCase
- NO_JIT_DESCRIPTION =
- if RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE
- RUBY_DESCRIPTION.sub(/\+JIT /, '')
- else
- RUBY_DESCRIPTION
- end
-
def write_file(filename, content)
File.open(filename, "w") {|f|
f << content
@@ -35,7 +26,7 @@ class TestRubyOptions < Test::Unit::TestCase
def test_usage
assert_in_out_err(%w(-h)) do |r, e|
- assert_operator(r.size, :<=, 25)
+ assert_operator(r.size, :<=, 24)
longer = r[1..-1].select {|x| x.size > 80}
assert_equal([], longer)
assert_equal([], e)
@@ -75,27 +66,18 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%w(-Wx -e) + ['p $-W'], "", %w(1), [])
assert_in_out_err(%w(-W -e) + ['p $-W'], "", %w(2), [])
assert_in_out_err(%w(-w -W0 -e) + ['p $-W'], "", %w(0), [])
- assert_in_out_err(%w(-W:deprecated -e) + ['p Warning[:deprecated]'], "", %w(true), [])
- assert_in_out_err(%w(-W:no-deprecated -e) + ['p Warning[:deprecated]'], "", %w(false), [])
- assert_in_out_err(%w(-W:experimental -e) + ['p Warning[:experimental]'], "", %w(true), [])
- assert_in_out_err(%w(-W:no-experimental -e) + ['p Warning[:experimental]'], "", %w(false), [])
- assert_in_out_err(%w(-W:qux), "", [], /unknown warning category: `qux'/)
- assert_in_out_err(%w(-w -e) + ['p Warning[:deprecated]'], "", %w(true), [])
- assert_in_out_err(%w(-W -e) + ['p Warning[:deprecated]'], "", %w(true), [])
- assert_in_out_err(%w(-e) + ['p Warning[:deprecated]'], "", %w(false), [])
- code = 'puts "#{$VERBOSE}:#{Warning[:deprecated]}:#{Warning[:experimental]}"'
- Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) do |t|
- t.puts code
- t.close
- assert_in_out_err(["-r#{t.path}", '-e', code], "", %w(false:false:true false:false:true), [])
- assert_in_out_err(["-r#{t.path}", '-w', '-e', code], "", %w(true:true:true true:true:true), [])
- assert_in_out_err(["-r#{t.path}", '-W:deprecated', '-e', code], "", %w(false:true:true false:true:true), [])
- assert_in_out_err(["-r#{t.path}", '-W:no-experimental', '-e', code], "", %w(false:false:false false:false:false), [])
- end
ensure
ENV['RUBYOPT'] = save_rubyopt
end
+ def test_safe_level
+ assert_in_out_err(%w(-T -e) + [""], "", [],
+ /no -e allowed in tainted mode \(SecurityError\)/)
+
+ assert_in_out_err(%w(-T4 -S foo.rb), "", [],
+ /no -S allowed in tainted mode \(SecurityError\)/)
+ end
+
def test_debug
assert_in_out_err(["--disable-gems", "-de", "p $DEBUG"], "", %w(true), [])
@@ -114,23 +96,10 @@ class TestRubyOptions < Test::Unit::TestCase
end
private_constant :VERSION_PATTERN
- VERSION_PATTERN_WITH_JIT =
- case RUBY_ENGINE
- when 'ruby'
- /^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+JIT \[#{q[RUBY_PLATFORM]}\]$/
- else
- VERSION_PATTERN
- end
- private_constant :VERSION_PATTERN_WITH_JIT
-
def test_verbose
assert_in_out_err(["-vve", ""]) do |r, e|
assert_match(VERSION_PATTERN, r[0])
- if RubyVM::MJIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE
- assert_equal(NO_JIT_DESCRIPTION, r[0])
- else
- assert_equal(RUBY_DESCRIPTION, r[0])
- end
+ assert_equal(RUBY_DESCRIPTION, r[0])
assert_equal([], e)
end
@@ -147,11 +116,9 @@ class TestRubyOptions < Test::Unit::TestCase
end
def test_enable
- if JITSupport.supported?
- assert_in_out_err(%w(--enable all -e) + [""], "", [], [])
- assert_in_out_err(%w(--enable-all -e) + [""], "", [], [])
- assert_in_out_err(%w(--enable=all -e) + [""], "", [], [])
- end
+ assert_in_out_err(%w(--enable all -e) + [""], "", [], [])
+ assert_in_out_err(%w(--enable-all -e) + [""], "", [], [])
+ assert_in_out_err(%w(--enable=all -e) + [""], "", [], [])
assert_in_out_err(%w(--enable foobarbazqux -e) + [""], "", [],
/unknown argument for --enable: `foobarbazqux'/)
assert_in_out_err(%w(--enable), "", [], /missing argument for --enable/)
@@ -166,7 +133,6 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%w(--disable), "", [], /missing argument for --disable/)
assert_in_out_err(%w(--disable-gems -e) + ['p defined? Gem'], "", ["nil"], [])
assert_in_out_err(%w(--disable-did_you_mean -e) + ['p defined? DidYouMean'], "", ["nil"], [])
- assert_in_out_err(%w(--disable-gems -e) + ['p defined? DidYouMean'], "", ["nil"], [])
end
def test_kanji
@@ -189,45 +155,9 @@ class TestRubyOptions < Test::Unit::TestCase
def test_version
assert_in_out_err(%w(--version)) do |r, e|
assert_match(VERSION_PATTERN, r[0])
- if RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE
- assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
- else
- assert_equal(RUBY_DESCRIPTION, r[0])
- end
+ assert_equal(RUBY_DESCRIPTION, r[0])
assert_equal([], e)
end
-
- return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no'
-
- [
- %w(--version --jit --disable=jit),
- %w(--version --enable=jit --disable=jit),
- %w(--version --enable-jit --disable-jit),
- ].each do |args|
- assert_in_out_err(args) do |r, e|
- assert_match(VERSION_PATTERN, r[0])
- assert_match(NO_JIT_DESCRIPTION, r[0])
- assert_equal([], e)
- end
- end
-
- if JITSupport.supported?
- [
- %w(--version --jit),
- %w(--version --enable=jit),
- %w(--version --enable-jit),
- ].each do |args|
- assert_in_out_err(args) do |r, e|
- assert_match(VERSION_PATTERN_WITH_JIT, r[0])
- if RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE
- assert_equal(RUBY_DESCRIPTION, r[0])
- else
- assert_equal(EnvUtil.invoke_ruby(['--jit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
- end
- assert_equal([], e)
- end
- end
- end
end
def test_eval
@@ -262,7 +192,7 @@ class TestRubyOptions < Test::Unit::TestCase
end
def test_autosplit
- assert_in_out_err(%w(-W0 -an -F: -e) + ["p $F"], "foo:bar:baz\nqux:quux:quuux\n",
+ assert_in_out_err(%w(-an -F: -e) + ["p $F"], "foo:bar:baz\nqux:quux:quuux\n",
['["foo", "bar", "baz\n"]', '["qux", "quux", "quuux\n"]'], [])
end
@@ -296,8 +226,8 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%w(--encoding test_ruby_test_rubyoptions_foobarbazqux), "", [],
/unknown encoding name - test_ruby_test_rubyoptions_foobarbazqux \(RuntimeError\)/)
- if /mswin|mingw|aix|android/ =~ RUBY_PLATFORM &&
- (str = "\u3042".force_encoding(Encoding.find("external"))).valid_encoding?
+ if /mswin|mingw|aix/ =~ RUBY_PLATFORM &&
+ (str = "\u3042".force_encoding(Encoding.find("locale"))).valid_encoding?
# This result depends on locale because LANG=C doesn't affect locale
# on Windows.
# On AIX, the source encoding of stdin with LANG=C is ISO-8859-1,
@@ -319,7 +249,7 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%W(-\r -e) + [""], "", [], [])
- assert_in_out_err(%W(-\rx), "", [], /invalid option -\\r \(-h will show valid options\) \(RuntimeError\)/)
+ assert_in_out_err(%W(-\rx), "", [], /invalid option -\\x0D \(-h will show valid options\) \(RuntimeError\)/)
assert_in_out_err(%W(-\x01), "", [], /invalid option -\\x01 \(-h will show valid options\) \(RuntimeError\)/)
@@ -335,6 +265,12 @@ class TestRubyOptions < Test::Unit::TestCase
ENV['RUBYOPT'] = '-e "p 1"'
assert_in_out_err([], "", [], /invalid switch in RUBYOPT: -e \(RuntimeError\)/)
+ ENV['RUBYOPT'] = '-T1'
+ assert_in_out_err(["--disable-gems"], "", [], /no program input from stdin allowed in tainted mode \(SecurityError\)/)
+
+ ENV['RUBYOPT'] = '-T4'
+ assert_in_out_err(["--disable-gems"], "", [], /no program input from stdin allowed in tainted mode \(SecurityError\)/)
+
ENV['RUBYOPT'] = '-Eus-ascii -KN'
assert_in_out_err(%w(-Eutf-8 -KU), "p '\u3042'") do |r, e|
assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
@@ -345,20 +281,6 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%w(), "p $VERBOSE", ["true"])
assert_in_out_err(%w(-W1), "p $VERBOSE", ["false"])
assert_in_out_err(%w(-W0), "p $VERBOSE", ["nil"])
- assert_in_out_err(%w(), "p Warning[:deprecated]", ["true"])
- assert_in_out_err(%w(-W0), "p Warning[:deprecated]", ["false"])
- assert_in_out_err(%w(-W1), "p Warning[:deprecated]", ["false"])
- assert_in_out_err(%w(-W2), "p Warning[:deprecated]", ["true"])
- ENV['RUBYOPT'] = '-W:deprecated'
- assert_in_out_err(%w(), "p Warning[:deprecated]", ["true"])
- ENV['RUBYOPT'] = '-W:no-deprecated'
- assert_in_out_err(%w(), "p Warning[:deprecated]", ["false"])
- ENV['RUBYOPT'] = '-W:experimental'
- assert_in_out_err(%w(), "p Warning[:experimental]", ["true"])
- ENV['RUBYOPT'] = '-W:no-experimental'
- assert_in_out_err(%w(), "p Warning[:experimental]", ["false"])
- ENV['RUBYOPT'] = '-W:qux'
- assert_in_out_err(%w(), "", [], /unknown warning category: `qux'/)
ensure
if rubyopt_orig
ENV['RUBYOPT'] = rubyopt_orig
@@ -464,7 +386,7 @@ class TestRubyOptions < Test::Unit::TestCase
t.puts " end"
t.puts "end"
t.flush
- warning = ' warning: found `= literal\' in conditional, should be =='
+ warning = ' warning: found = in conditional, should be =='
err = ["#{t.path}:1:#{warning}",
"#{t.path}:4:#{warning}",
]
@@ -501,25 +423,13 @@ class TestRubyOptions < Test::Unit::TestCase
"begin", "if false", "for _ in []", "while false",
"def foo", "class X", "module M",
["-> do", "end"], ["-> {", "}"],
- ["if false;", "else ; end"],
- ["if false;", "elsif false ; end"],
- ["begin", "rescue ; end"],
- ["begin rescue", "else ; end"],
- ["begin", "ensure ; end"],
- [" case nil", "when true; end"],
- ["case nil; when true", "end"],
- ["if false;", "end", "if true\nelse ", "end"],
- ["else", " end", "_ = if true\n"],
].each do
- |b, e = 'end', pre = nil, post = nil|
- src = ["#{pre}#{b}\n", " #{e}\n#{post}"]
- k = b[/\A\s*(\S+)/, 1]
- e = e[/\A\s*(\S+)/, 1]
- n = 2
- n += pre.count("\n") if pre
-
- a.for("no directives with #{src}") do
- err = ["#{t.path}:#{n}: warning: mismatched indentations at '#{e}' with '#{k}' at #{n-1}"]
+ |b, e = 'end'|
+ src = ["#{b}\n", " #{e}\n"]
+ k = b[/\A\S+/]
+
+ a.for("no directives with #{b}") do
+ err = ["#{t.path}:2: warning: mismatched indentations at '#{e}' with '#{k}' at 1"]
t.rewind
t.truncate(0)
t.puts src
@@ -528,7 +438,7 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err)
end
- a.for("false directive with #{src}") do
+ a.for("false directive with #{b}") do
t.rewind
t.truncate(0)
t.puts "# -*- warn-indent: false -*-"
@@ -537,8 +447,8 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
end
- a.for("false and true directives with #{src}") do
- err = ["#{t.path}:#{n+2}: warning: mismatched indentations at '#{e}' with '#{k}' at #{n+1}"]
+ a.for("false and true directives with #{b}") do
+ err = ["#{t.path}:4: warning: mismatched indentations at '#{e}' with '#{k}' at 3"]
t.rewind
t.truncate(0)
t.puts "# -*- warn-indent: false -*-"
@@ -548,7 +458,7 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["-w", t.path], "", [], err, '[ruby-core:25442]')
end
- a.for("false directives after #{src}") do
+ a.for("false directives after #{b}") do
t.rewind
t.truncate(0)
t.puts "# -*- warn-indent: true -*-"
@@ -559,8 +469,8 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
end
- a.for("BOM with #{src}") do
- err = ["#{t.path}:#{n}: warning: mismatched indentations at '#{e}' with '#{k}' at #{n-1}"]
+ a.for("BOM with #{b}") do
+ err = ["#{t.path}:2: warning: mismatched indentations at '#{e}' with '#{k}' at 1"]
t.rewind
t.truncate(0)
t.print "\u{feff}"
@@ -632,7 +542,7 @@ class TestRubyOptions < Test::Unit::TestCase
if /linux|freebsd|netbsd|openbsd|darwin/ =~ RUBY_PLATFORM
PSCMD = EnvUtil.find_executable("ps", "-o", "command", "-p", $$.to_s) {|out| /ruby/=~out}
- PSCMD&.pop
+ PSCMD.pop if PSCMD
end
def test_set_program_name
@@ -643,18 +553,14 @@ class TestRubyOptions < Test::Unit::TestCase
pid = spawn(EnvUtil.rubybin, "test-script")
ps = nil
- now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- stop = now + 30
- begin
+ 10.times do
sleep 0.1
ps = `#{PSCMD.join(' ')} #{pid}`
break if /hello world/ =~ ps
- now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- end until Process.wait(pid, Process::WNOHANG) || now > stop
+ end
assert_match(/hello world/, ps)
- assert_operator now, :<, stop
Process.kill :KILL, pid
- EnvUtil.timeout(5) { Process.wait(pid) }
+ Process.wait(pid)
end
end
@@ -673,25 +579,24 @@ class TestRubyOptions < Test::Unit::TestCase
pid = spawn(EnvUtil.rubybin, "test-script")
ps = nil
- now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- stop = now + 30
- begin
+ 10.times do
sleep 0.1
ps = `#{PSCMD.join(' ')} #{pid}`
break if /hello world/ =~ ps
- now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- end until Process.wait(pid, Process::WNOHANG) || now > stop
+ end
assert_match(/hello world/, ps)
- assert_operator now, :<, stop
Process.kill :KILL, pid
- Timeout.timeout(5) { Process.wait(pid) }
+ Process.wait(pid)
end
end
module SEGVTest
opts = {}
- unless /mswin|mingw/ =~ RUBY_PLATFORM
+ if /mswin|mingw/ =~ RUBY_PLATFORM
+ additional = /[\s\w\.\']*/
+ else
opts[:rlimit_core] = 0
+ additional = nil
end
ExecOptions = opts.freeze
@@ -700,37 +605,42 @@ class TestRubyOptions < Test::Unit::TestCase
-e:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n
)x,
%r(
- #{ Regexp.quote(NO_JIT_DESCRIPTION) }\n\n
+ #{ Regexp.quote(RUBY_DESCRIPTION) }\n\n
)x,
%r(
(?:--\s(?:.+\n)*\n)?
--\sControl\sframe\sinformation\s-+\n
- (?:(?:c:.*\n)|(?:^\s+.+\n))*
- \n
+ (?:c:.*\n)*
)x,
%r(
(?:
--\sRuby\slevel\sbacktrace\sinformation\s----------------------------------------\n
- (?:-e:1:in\s\`(?:block\sin\s)?<main>\'\n)*
+ -e:1:in\s\`<main>\'\n
-e:1:in\s\`kill\'\n
- \n
)?
)x,
%r(
- (?:--\sMachine(?:.+\n)*\n)?
- )x,
- %r(
(?:
--\sC\slevel\sbacktrace\sinformation\s-------------------------------------------\n
- (?:(?:.*\s)?\[0x\h+\].*\n|.*:\d+\n)*\n
+ (?:(?:.*\s)?\[0x\h+\]\n)*\n
)?
)x,
+ :*,
%r(
- (?:--\sOther\sruntime\sinformation\s-+\n
- (?:.*\n)*
+ \[NOTE\]\n
+ You\smay\shave\sencountered\sa\sbug\sin\sthe\sRuby\sinterpreter\sor\sextension\slibraries.\n
+ Bug\sreports\sare\swelcome.\n
+ (?:.*\n)?
+ For\sdetails:\shttp:\/\/.*\.ruby-lang\.org/.*\n
+ \n
+ (?:
+ \[IMPORTANT\]\n
+ (?:.+\n)+
+ \n
)?
)x,
]
+ ExpectedStderrList << additional if additional
end
def assert_segv(args, message=nil)
@@ -795,6 +705,20 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["-w", "-"], "eval('a=1')", [], [], feature7730)
end
+ def test_shadowing_variable
+ bug4130 = '[ruby-dev:42718]'
+ assert_in_out_err(["-we", "def foo\n"" a=1\n"" 1.times do |a| end\n"" a\n""end"],
+ "", [], ["-e:3: warning: shadowing outer local variable - a"], bug4130)
+ assert_in_out_err(["-we", "def foo\n"" a=1\n"" 1.times do |a| end\n""end"],
+ "", [],
+ ["-e:3: warning: shadowing outer local variable - a",
+ "-e:2: warning: assigned but unused variable - a",
+ ], bug4130)
+ feature6693 = '[ruby-core:46160]'
+ assert_in_out_err(["-we", "def foo\n"" _a=1\n"" 1.times do |_a| end\n""end"],
+ "", [], [], feature6693)
+ end
+
def test_script_from_stdin
begin
require 'pty'
@@ -812,7 +736,7 @@ class TestRubyOptions < Test::Unit::TestCase
pid = spawn(EnvUtil.rubybin, :in => s, :out => w)
w.close
assert_nothing_raised('[ruby-dev:37798]') do
- result = EnvUtil.timeout(3) {r.read}
+ result = Timeout.timeout(3) {r.read}
end
Process.wait pid
}
@@ -852,11 +776,11 @@ class TestRubyOptions < Test::Unit::TestCase
def test_command_line_glob_nonascii
bug10555 = '[ruby-dev:48752] [Bug #10555]'
name = "\u{3042}.txt"
- expected = name.encode("external") rescue "?.txt"
+ expected = name.encode("locale") rescue "?.txt"
with_tmpchdir do |dir|
open(name, "w") {}
assert_in_out_err(["-e", "puts ARGV", "?.txt"], "", [expected], [],
- bug10555, encoding: "external")
+ bug10555, encoding: "locale")
end
end
@@ -891,7 +815,7 @@ class TestRubyOptions < Test::Unit::TestCase
with_tmpchdir do |dir|
Ougai.each {|f| open(f, "w") {}}
assert_in_out_err(["-Eutf-8", "-e", "puts ARGV", "*"], "", Ougai, encoding: "utf-8")
- ougai = Ougai.map {|f| f.encode("external", replace: "?")}
+ ougai = Ougai.map {|f| f.encode("locale", replace: "?")}
assert_in_out_err(["-e", "puts ARGV", "*.txt"], "", ougai)
end
end
@@ -989,10 +913,8 @@ class TestRubyOptions < Test::Unit::TestCase
[["disable", "false"], ["enable", "true"]].each do |opt, exp|
%W[frozen_string_literal frozen-string-literal].each do |arg|
key = "#{opt}=#{arg}"
- negopt = exp == "true" ? "disable" : "enable"
- env = {"RUBYOPT"=>"--#{negopt}=#{arg}"}
a.for(key) do
- assert_in_out_err([env, "--disable=gems", "--#{key}"], 'p("foo".frozen?)', [exp])
+ assert_in_out_err(["--disable=gems", "--#{key}"], 'p("foo".frozen?)', [exp])
end
end
end
@@ -1009,7 +931,7 @@ class TestRubyOptions < Test::Unit::TestCase
def test_frozen_string_literal_debug
with_debug_pat = /created at/
- wo_debug_pat = /can\'t modify frozen String: "\w+" \(FrozenError\)\n\z/
+ wo_debug_pat = /can\'t modify frozen String \(FrozenError\)\n\z/
frozen = [
["--enable-frozen-string-literal", true],
["--disable-frozen-string-literal", false],
@@ -1025,13 +947,9 @@ class TestRubyOptions < Test::Unit::TestCase
frozen.product(debugs) do |(opt1, freeze), (opt2, debug)|
opt = opts + [opt1, opt2].compact
err = !freeze ? [] : debug ? with_debug_pat : wo_debug_pat
- [
- ['"foo" << "bar"', err],
- ['"foo#{123}bar" << "bar"', err],
- ['+"foo#{123}bar" << "bar"', []],
- ['-"foo#{123}bar" << "bar"', freeze && debug ? with_debug_pat : wo_debug_pat],
- ].each do |code, expected|
- assert_in_out_err(opt, code, [], expected, [opt, code])
+ assert_in_out_err(opt, '"foo" << "bar"', [], err)
+ if freeze
+ assert_in_out_err(opt, '"foo#{123}bar" << "bar"', [], err)
end
end
end
@@ -1069,27 +987,10 @@ class TestRubyOptions < Test::Unit::TestCase
end
end
- def test_rubylib_invalid_encoding
- env = {"RUBYLIB"=>"\xFF", "LOCALE"=>"en_US.UTF-8", "LC_ALL"=>"en_US.UTF-8"}
- assert_ruby_status([env, "-e;"])
- end
-
- def test_null_script
- skip "#{IO::NULL} is not a character device" unless File.chardev?(IO::NULL)
- assert_in_out_err([IO::NULL], success: true)
- end
-
- def test_jit_debug
- # mswin uses prebuilt precompiled header. Thus it does not show a pch compilation log to check "-O0 -O1".
- if JITSupport.supported? && !RUBY_PLATFORM.match?(/mswin/)
- env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' }
- assert_in_out_err([env, "--jit-debug=-O0 -O1", "--jit-verbose=2", "" ], "", [], /-O0 -O1/)
- end
- end
-
- private
-
- def mjit_force_enabled?
- "#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?MJIT_FORCE_ENABLE\b/)
+ def test_argv_tainted
+ assert_separately(%w[- arg], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ assert_predicate(ARGV[0], :tainted?, '[ruby-dev:50596] [Bug #14941]')
+ end;
end
end
diff --git a/test/ruby/test_rubyvm_mjit.rb b/test/ruby/test_rubyvm_mjit.rb
deleted file mode 100644
index ef7475670c..0000000000
--- a/test/ruby/test_rubyvm_mjit.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-require_relative '../lib/jit_support'
-
-return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no'
-
-class TestRubyVMMJIT < Test::Unit::TestCase
- include JITSupport
-
- def setup
- unless JITSupport.supported?
- skip 'JIT seems not supported on this platform'
- end
- end
-
- def test_pause
- out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
- i = 0
- while i < 5
- eval("def mjit#{i}; end; mjit#{i}")
- i += 1
- end
- print RubyVM::MJIT.pause
- print RubyVM::MJIT.pause
- while i < 10
- eval("def mjit#{i}; end; mjit#{i}")
- i += 1
- end
- print RubyVM::MJIT.pause # no JIT here
- EOS
- assert_equal('truefalsefalse', out)
- assert_equal(
- 5, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size,
- "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```",
- )
- end
-
- def test_pause_waits_until_compaction
- out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
- def a() end; a
- def b() end; b
- RubyVM::MJIT.pause
- EOS
- assert_equal(
- 2, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size,
- "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```",
- )
- assert_equal(
- 1, err.scan(/#{JITSupport::JIT_COMPACTION_PREFIX}/).size,
- "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```",
- ) unless RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet
- end
-
- def test_pause_does_not_hang_on_full_units
- out, _ = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, max_cache: 10, wait: false)
- i = 0
- while i < 11
- eval("def mjit#{i}; end; mjit#{i}")
- i += 1
- end
- print RubyVM::MJIT.pause
- EOS
- assert_equal('true', out)
- end
-
- def test_pause_wait_false
- out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
- i = 0
- while i < 10
- eval("def mjit#{i}; end; mjit#{i}")
- i += 1
- end
- print RubyVM::MJIT.pause(wait: false)
- print RubyVM::MJIT.pause(wait: false)
- EOS
- assert_equal('truefalse', out)
- assert_equal(true, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size < 10)
- end
-
- def test_resume
- out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
- print RubyVM::MJIT.resume
- print RubyVM::MJIT.pause
- print RubyVM::MJIT.resume
- print RubyVM::MJIT.resume
- print RubyVM::MJIT.pause
- EOS
- assert_equal('falsetruetruefalsetrue', out)
- assert_equal(0, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size)
- end
-end
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 0c41f247be..3085c0902a 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -468,6 +468,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
answer_events = [
#
+ [:c_return, 1, "xyzzy", TracePoint, :trace, TracePoint, :outer, trace],
[:line, 4, 'xyzzy', self.class, method, self, :outer, :nothing],
[:c_call, 4, 'xyzzy', Integer, :times, 1, :outer, :nothing],
[:line, 4, 'xyzzy', self.class, method, self, nil, :nothing],
@@ -516,55 +517,12 @@ class TestSetTraceFunc < Test::Unit::TestCase
[:c_call, 20, "xyzzy", Module, :===, RuntimeError,:outer, :nothing],
[:c_return,20, "xyzzy", Module, :===, RuntimeError,:outer, true],
[:line, 21, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing],
+ [:c_call, 21, "xyzzy", TracePoint, :disable, trace, :outer, :nothing],
]
return events, answer_events
end
- def test_tracepoint
- events1, answer_events = *trace_by_tracepoint(:line, :class, :end, :call, :return, :c_call, :c_return, :raise)
-
- ms = [events1, answer_events].map{|evs|
- evs.map{|e|
- "#{e[0]} - #{e[2]}:#{e[1]} id: #{e[4]}"
- }
- }
-
- if false # show all events
- printf(" %-60s | %-60s\n", "actual", "expected")
- ms[0].zip(ms[1]){|a, b|
- printf("%s%-60s | %-60s\n", a==b ? ' ' : '!', a, b)
- }
- end
-
- mesg = ms[0].zip(ms[1]).map{|a, b|
- if a != b
- "actual: #{a} <-> expected: #{b}"
- end
- }.compact.join("\n")
-
- answer_events.zip(events1){|answer, event|
- assert_equal answer, event, mesg
- }
-
- [:line, :class, :end, :call, :return, :c_call, :c_return, :raise].each{|event|
- events1, answer_events = *trace_by_tracepoint(event)
- answer_events.find_all{|e| e[0] == event}.zip(events1){|answer_line, event_line|
- assert_equal answer_line, event_line
- }
- }
- end
-
- # Bug #18264
- def test_tracpoint_memory_leak
- assert_no_memory_leak([], <<-PREP, <<-CODE, rss: true)
-code = proc { TracePoint.new(:line) { } }
-1_000.times(&code)
-PREP
-1_000_000.times(&code)
-CODE
- end
-
def trace_by_set_trace_func
events = []
trace = nil
@@ -572,9 +530,6 @@ CODE
xyzzy = nil
xyzzy = xyzzy
_local_var = :outer
- method = :trace_by_set_trace_func
- raised_exc = nil
-
eval <<-EOF.gsub(/^.*?: /, ""), nil, 'xyzzy'
1: set_trace_func(lambda{|event, file, line, id, binding, klass|
2: events << [event, line, file, klass, id, binding.eval('self'), binding.eval("_local_var")] if file == 'xyzzy'
@@ -599,73 +554,44 @@ CODE
21: set_trace_func(nil)
EOF
self.class.class_eval{remove_const(:XYZZY)}
-
- answer_events = [
- #
- [:c_return, 1, "xyzzy", TracePoint, :trace, TracePoint, :outer, trace],
- [:line, 4, 'xyzzy', self.class, method, self, :outer, :nothing],
- [:c_call, 4, 'xyzzy', Integer, :times, 1, :outer, :nothing],
- [:line, 4, 'xyzzy', self.class, method, self, nil, :nothing],
- [:line, 5, 'xyzzy', self.class, method, self, :inner, :nothing],
- [:c_call, 5, 'xyzzy', Kernel, :tap, self, :inner, :nothing],
- [:c_return, 5, "xyzzy", Kernel, :tap, self, :inner, self],
- [:c_return, 4, "xyzzy", Integer, :times, 1, :outer, 1],
- [:line, 7, 'xyzzy', self.class, method, self, :outer, :nothing],
- [:c_call, 7, "xyzzy", Class, :inherited, Object, :outer, :nothing],
- [:c_return, 7, "xyzzy", Class, :inherited, Object, :outer, nil],
- [:class, 7, "xyzzy", nil, nil, xyzzy.class, nil, :nothing],
- [:line, 8, "xyzzy", nil, nil, xyzzy.class, nil, :nothing],
- [:line, 9, "xyzzy", nil, nil, xyzzy.class, :XYZZY_outer, :nothing],
- [:c_call, 9, "xyzzy", Module, :method_added, xyzzy.class, :XYZZY_outer, :nothing],
- [:c_return, 9, "xyzzy", Module, :method_added, xyzzy.class, :XYZZY_outer, nil],
- [:line, 13, "xyzzy", nil, nil, xyzzy.class, :XYZZY_outer, :nothing],
- [:c_call, 13, "xyzzy", Module, :method_added, xyzzy.class, :XYZZY_outer, :nothing],
- [:c_return,13, "xyzzy", Module, :method_added, xyzzy.class, :XYZZY_outer, nil],
- [:end, 17, "xyzzy", nil, nil, xyzzy.class, :XYZZY_outer, :nothing],
- [:line, 18, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing],
- [:c_call, 18, "xyzzy", Class, :new, xyzzy.class, :outer, :nothing],
- [:c_call, 18, "xyzzy", BasicObject, :initialize, xyzzy, :outer, :nothing],
- [:c_return,18, "xyzzy", BasicObject, :initialize, xyzzy, :outer, nil],
- [:c_return,18, "xyzzy", Class, :new, xyzzy.class, :outer, xyzzy],
- [:line, 19, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing],
- [:call, 9, "xyzzy", xyzzy.class, :foo, xyzzy, nil, :nothing],
- [:line, 10, "xyzzy", xyzzy.class, :foo, xyzzy, nil, :nothing],
- [:line, 11, "xyzzy", xyzzy.class, :foo, xyzzy, :XYZZY_foo, :nothing],
- [:call, 13, "xyzzy", xyzzy.class, :bar, xyzzy, nil, :nothing],
- [:line, 14, "xyzzy", xyzzy.class, :bar, xyzzy, nil, :nothing],
- [:line, 15, "xyzzy", xyzzy.class, :bar, xyzzy, :XYZZY_bar, :nothing],
- [:c_call, 15, "xyzzy", Kernel, :tap, xyzzy, :XYZZY_bar, :nothing],
- [:c_return,15, "xyzzy", Kernel, :tap, xyzzy, :XYZZY_bar, xyzzy],
- [:return, 16, "xyzzy", xyzzy.class, :bar, xyzzy, :XYZZY_bar, xyzzy],
- [:return, 12, "xyzzy", xyzzy.class, :foo, xyzzy, :XYZZY_foo, xyzzy],
- [:line, 20, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing],
- [:c_call, 20, "xyzzy", Kernel, :raise, self, :outer, :nothing],
- [:c_call, 20, "xyzzy", Exception, :exception, RuntimeError, :outer, :nothing],
- [:c_call, 20, "xyzzy", Exception, :initialize, raised_exc, :outer, :nothing],
- [:c_return,20, "xyzzy", Exception, :initialize, raised_exc, :outer, raised_exc],
- [:c_return,20, "xyzzy", Exception, :exception, RuntimeError, :outer, raised_exc],
- [:c_return,20, "xyzzy", Kernel, :raise, self, :outer, nil],
- [:c_call, 20, "xyzzy", Exception, :backtrace, raised_exc, :outer, :nothing],
- [:c_return,20, "xyzzy", Exception, :backtrace, raised_exc, :outer, nil],
- [:raise, 20, "xyzzy", TestSetTraceFunc, :trace_by_tracepoint, self, :outer, raised_exc],
- [:c_call, 20, "xyzzy", Module, :===, RuntimeError,:outer, :nothing],
- [:c_return,20, "xyzzy", Module, :===, RuntimeError,:outer, true],
- [:line, 21, "xyzzy", TestSetTraceFunc, method, self, :outer, :nothing],
- [:c_call, 21, "xyzzy", TracePoint, :disable, trace, :outer, :nothing],
- ]
- return events, answer_events
+ return events
end
- def test_set_trace_func
- actual_events, expected_events = trace_by_set_trace_func
- expected_events.zip(actual_events){|e, a|
- a[0] = a[0].to_s.sub('-', '_').to_sym
- assert_equal e[0..2], a[0..2], a.inspect
+ def test_tracepoint
+ events1, answer_events = *trace_by_tracepoint(:line, :class, :end, :call, :return, :c_call, :c_return, :raise)
+
+ ms = [events1, answer_events].map{|evs|
+ evs.map{|e|
+ "#{e[0]} - #{e[2]}:#{e[1]} id: #{e[4]}"
+ }
+ }
+
+ mesg = ms[0].zip(ms[1]).map{|a, b|
+ if a != b
+ "#{a} <-> #{b}"
+ end
+ }.compact.join("\n")
+
+ answer_events.zip(events1){|answer, event|
+ assert_equal answer, event, mesg
+ }
+
+ events2 = trace_by_set_trace_func
+ events1.zip(events2){|ev1, ev2|
+ ev2[0] = ev2[0].sub('-', '_').to_sym
+ assert_equal ev1[0..2], ev2[0..2], ev1.inspect
# event, line, file, klass, id, binding.eval('self'), binding.eval("_local_var")
- assert_equal e[3].nil?, a[3].nil? # klass
- assert_equal e[4].nil?, a[4].nil? # id
- assert_equal e[6], a[6] # _local_var
+ assert_equal ev1[3].nil?, ev2[3].nil? # klass
+ assert_equal ev1[4].nil?, ev2[4].nil? # id
+ assert_equal ev1[6], ev2[6] # _local_var
+ }
+
+ [:line, :class, :end, :call, :return, :c_call, :c_return, :raise].each{|event|
+ events1, answer_events = *trace_by_tracepoint(event)
+ answer_events.find_all{|e| e[0] == event}.zip(events1){|answer_line, event_line|
+ assert_equal answer_line, event_line
+ }
}
end
@@ -750,7 +676,7 @@ CODE
}
foo
trace.disable
- assert_equal([:foo, :disable, :foo, :disable], ary)
+ assert_equal([:foo, :foo], ary)
assert_equal([], args)
trace = TracePoint.new{}
@@ -777,45 +703,6 @@ CODE
assert_equal(false, trace.enabled?)
end
- def parameter_test(a, b, c)
- yield
- end
-
- def test_tracepoint_parameters
- trace = TracePoint.new(:line, :class, :end, :call, :return, :b_call, :b_return, :c_call, :c_return, :raise){|tp|
- next if !target_thread?
- next if tp.path != __FILE__
- case tp.event
- when :call, :return
- assert_equal([[:req, :a], [:req, :b], [:req, :c]], tp.parameters)
- when :b_call, :b_return
- next if tp.parameters == []
- if tp.parameters.first == [:opt, :x]
- assert_equal([[:opt, :x], [:opt, :y], [:opt, :z]], tp.parameters)
- else
- assert_equal([[:req, :p], [:req, :q], [:req, :r]], tp.parameters)
- end
- when :c_call, :c_return
- assert_equal([[:req]], tp.parameters) if tp.method_id == :getbyte
- when :line, :class, :end, :raise
- assert_raise(RuntimeError) { tp.parameters }
- end
- }
- obj = Object.new
- trace.enable{
- parameter_test(1, 2, 3) {|x, y, z|
- }
- lambda {|p, q, r| }.call(4, 5, 6)
- "".getbyte(0)
- class << obj
- end
- begin
- raise
- rescue
- end
- }
- end
-
def method_test_tracepoint_return_value obj
obj
end
@@ -842,13 +729,13 @@ CODE
end
def test_tracepoint_raised_exception
- trace = TracePoint.new(:call, :return, :raise){|tp|
+ trace = TracePoint.new(:call, :return){|tp|
next if !target_thread?
case tp.event
when :call, :return
assert_raise(RuntimeError) { tp.raised_exception }
when :raise
- assert_kind_of(XYZZYException, tp.raised_exception)
+ assert_equal(XYZZYError, tp.raised_exception)
end
}
trace.enable{
@@ -925,16 +812,14 @@ CODE
def test_tracepoint_inspect
events = []
- th = nil
trace = TracePoint.new{|tp|
- next if !target_thread? && th != Thread.current
+ next if !target_thread?
events << [tp.event, tp.inspect]
}
assert_equal("#<TracePoint:disabled>", trace.inspect)
trace.enable{
assert_equal("#<TracePoint:enabled>", trace.inspect)
- th = Thread.new{}
- th.join
+ Thread.new{}.join
}
assert_equal("#<TracePoint:disabled>", trace.inspect)
events.each{|(ev, str)|
@@ -1141,7 +1026,7 @@ CODE
}.enable{
3.times{
next
- } # 3 times b_return
+ } # 3 times b_retun
} # 1 time b_return
assert_equal 4, n
@@ -1559,6 +1444,7 @@ CODE
end
def test_throwing_return_with_finish_frame
+ target_th = Thread.current
evs = []
TracePoint.new(:call, :return){|tp|
@@ -1745,25 +1631,6 @@ CODE
ary
end
- def test_single_raise_inside_load
- events = []
- tmpdir = Dir.mktmpdir
- path = "#{tmpdir}/hola.rb"
- File.open(path, "w") { |f| f.write("raise") }
- tp = TracePoint.new(:raise) {|tp| events << [tp.event] if target_thread?}
- tp.enable{
- load path rescue nil
- }
- assert_equal [[:raise]], events
- events.clear
- tp.enable{
- require path rescue nil
- }
- assert_equal [[:raise]], events
- ensure
- FileUtils.rmtree(tmpdir)
- end
-
def f_raise
raise
rescue
@@ -1901,6 +1768,7 @@ CODE
define_method(:m) {}
tp = TracePoint.new(:call) do
+ next unless target_thread?
raise ''
end
@@ -1966,9 +1834,6 @@ CODE
}
# it is dirty hack. usually we shouldn't use such technique
Thread.pass until t.status == 'sleep'
- # When MJIT thread exists, t.status becomes 'sleep' even if it does not reach m2t_q.pop.
- # This sleep forces it to reach m2t_q.pop for --jit-wait.
- sleep 1 if RubyVM::MJIT.enabled?
t.add_trace_func proc{|ev, file, line, *args|
if file == __FILE__
@@ -1993,316 +1858,4 @@ CODE
assert_equal ["c-call", base_line + 35], events[9] # Thread#set_trace_func
assert_equal nil, events[10]
end
-
- def test_lineno_in_optimized_insn
- assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- $loc = nil
- class String
- undef -@
- def -@
- $loc = caller_locations(1, 1)[0].lineno
- end
- end
-
- assert_predicate(-"", :frozen?)
- assert_equal(__LINE__-1, $loc, '[Bug #14809]')
- end;
- end
-
- def method_for_enable_target1
- a = 1
- b = 2
- 1.times{|i|
- _x = i
- }
- _c = a + b
- end
-
- def method_for_enable_target2
- a = 1
- b = 2
- 1.times{|i|
- _x = i
- }
- _c = a + b
- end
-
- def check_with_events *trace_events
- all_events = [[:call, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:b_call, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:b_return, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:return, :method_for_enable_target1],
- # repeat
- [:call, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:b_call, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:b_return, :method_for_enable_target1],
- [:line, :method_for_enable_target1],
- [:return, :method_for_enable_target1],
- ]
- events = []
- TracePoint.new(*trace_events) do |tp|
- next unless target_thread?
- events << [tp.event, tp.method_id]
- end.enable(target: method(:method_for_enable_target1)) do
- method_for_enable_target1
- method_for_enable_target2
- method_for_enable_target1
- end
- assert_equal all_events.find_all{|(ev)| trace_events.include? ev}, events
- end
-
- def test_tracepoint_enable_target
- check_with_events :line
- check_with_events :call, :return
- check_with_events :line, :call, :return
- check_with_events :call, :return, :b_call, :b_return
- check_with_events :line, :call, :return, :b_call, :b_return
- end
-
- def test_tracepoint_nested_enabled_with_target
- code1 = proc{
- _a = 1
- }
- code2 = proc{
- _b = 2
- }
-
- ## error
-
- # targeted TP and targeted TP
- ex = assert_raise(ArgumentError) do
- tp = TracePoint.new(:line){}
- tp.enable(target: code1){
- tp.enable(target: code2){}
- }
- end
- assert_equal "can't nest-enable a targeting TracePoint", ex.message
-
- # global TP and targeted TP
- ex = assert_raise(ArgumentError) do
- tp = TracePoint.new(:line){}
- tp.enable{
- tp.enable(target: code2){}
- }
- end
- assert_equal "can't nest-enable a targeting TracePoint", ex.message
-
- # targeted TP and global TP
- ex = assert_raise(ArgumentError) do
- tp = TracePoint.new(:line){}
- tp.enable(target: code1){
- tp.enable{}
- }
- end
- assert_equal "can't nest-enable a targeting TracePoint", ex.message
-
- # targeted TP and disable
- ex = assert_raise(ArgumentError) do
- tp = TracePoint.new(:line){}
- tp.enable(target: code1){
- tp.disable{}
- }
- end
- assert_equal "can't disable a targeting TracePoint in a block", ex.message
-
- ## success with two nesting targeting tracepoints
- events = []
- tp1 = TracePoint.new(:line){|tp| events << :tp1}
- tp2 = TracePoint.new(:line){|tp| events << :tp2}
- tp1.enable(target: code1) do
- tp2.enable(target: code1) do
- code1.call
- events << :___
- end
- end
- assert_equal [:tp2, :tp1, :___], events
-
- # success with two tracepoints (global/targeting)
- events = []
- tp1 = TracePoint.new(:line){|tp| events << :tp1}
- tp2 = TracePoint.new(:line){|tp| events << :tp2}
- tp1.enable do
- tp2.enable(target: code1) do
- code1.call
- events << :___
- end
- end
- assert_equal [:tp1, :tp1, :tp1, :tp1, :tp2, :tp1, :___], events
-
- # success with two tracepoints (targeting/global)
- events = []
- tp1 = TracePoint.new(:line){|tp| events << :tp1}
- tp2 = TracePoint.new(:line){|tp| events << :tp2}
- tp1.enable(target: code1) do
- tp2.enable do
- code1.call
- events << :___
- end
- end
- assert_equal [:tp2, :tp2, :tp1, :tp2, :___], events
- end
-
- def test_tracepoint_enable_with_target_line
- events = []
- line_0 = __LINE__
- code1 = proc{
- events << 1
- events << 2
- events << 3
- }
- tp = TracePoint.new(:line) do |tp|
- events << :tp
- end
- tp.enable(target: code1, target_line: line_0 + 3) do
- code1.call
- end
- assert_equal [1, :tp, 2, 3], events
-
-
- e = assert_raise(ArgumentError) do
- TracePoint.new(:line){}.enable(target_line: 10){}
- end
- assert_equal 'only target_line is specified', e.message
-
- e = assert_raise(ArgumentError) do
- TracePoint.new(:call){}.enable(target: code1, target_line: 10){}
- end
- assert_equal 'target_line is specified, but line event is not specified', e.message
- end
-
- def test_script_compiled
- events = []
- tp = TracePoint.new(:script_compiled){|tp|
- next unless target_thread?
- events << [tp.instruction_sequence.path,
- tp.eval_script]
- }
-
- eval_script = 'a = 1'
- tp.enable{
- eval(eval_script, nil, __FILE__+"/eval")
- nil.instance_eval(eval_script, __FILE__+"/instance_eval")
- Object.class_eval(eval_script, __FILE__+"/class_eval")
- }
- assert_equal [[__FILE__+"/eval", eval_script],
- [__FILE__+"/instance_eval", eval_script],
- [__FILE__+"/class_eval", eval_script],
- ], events
-
- events.clear
- tp.enable{
- begin
- eval('a=')
- rescue SyntaxError
- end
- }
- assert_equal [], events, 'script_compiled event should not be invoked on compile error'
-
- skip "TODO: test for requires"
-
- events.clear
- tp.enable{
- require ''
- require_relative ''
- load ''
- }
- assert_equal [], events
- end
-
- def test_enable_target_thread
- events = []
- TracePoint.new(:line) do |tp|
- events << Thread.current
- end.enable(target_thread: Thread.current) do
- _a = 1
- Thread.new{
- _b = 2
- _c = 3
- }.join
- _d = 4
- end
- assert_equal Array.new(3){Thread.current}, events
-
- events = []
- tp = TracePoint.new(:line) do |tp|
- events << Thread.current
- end
-
- q1 = Queue.new
- q2 = Queue.new
-
- th = Thread.new{
- q1 << :ok; q2.pop
- _t1 = 1
- _t2 = 2
- }
- q1.pop
- tp.enable(target_thread: th) do
- q2 << 1
- _a = 1
- _b = 2
- th.join
- end
-
- assert_equal Array.new(2){th}, events
- end
-
- def test_return_event_with_rescue
- obj = Object.new
- def obj.example
- 1 if 1 == 1
- rescue
- end
- ok = false
- tp = TracePoint.new(:return) {ok = true}
- tp.enable {obj.example}
- assert ok, "return event should be emitted"
- end
-
- def test_disable_local_tracepoint_in_trace
- assert_normal_exit <<-EOS
- def foo
- trace = TracePoint.new(:b_return){|tp|
- tp.disable
- }
- trace.enable(target: method(:bar))
- end
- def bar
- 100.times{|i|
- foo; foo
- }
- end
- bar
- EOS
- end
-
- def test_stat_exists
- assert_instance_of Hash, TracePoint.stat
- end
-
- def test_tracepoint_opt_invokebuiltin_delegate_leave
- code = 'puts RubyVM::InstructionSequence.of("\x00".method(:unpack)).disasm'
- out = EnvUtil.invoke_ruby(['-e', code], '', true).first
- assert_match /^0000 opt_invokebuiltin_delegate_leave /, out
-
- event = eval(EnvUtil.invoke_ruby(['-e', <<~'EOS'], '', true).first)
- set_trace_func(proc {}); set_trace_func(nil) # Is it okay that this is required?
- TracePoint.new(:return) do |tp|
- p [tp.event, tp.method_id]
- end.enable do
- "\x00".unpack("c")
- end
- EOS
- assert_equal [:return, :unpack], event
- end
end
diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb
index a62537d59d..2d98b0b564 100644
--- a/test/ruby/test_signal.rb
+++ b/test/ruby/test_signal.rb
@@ -28,8 +28,7 @@ class TestSignal < Test::Unit::TestCase
def test_signal_process_group
bug4362 = '[ruby-dev:43169]'
assert_nothing_raised(bug4362) do
- cmd = [ EnvUtil.rubybin, '--disable=gems' '-e', 'sleep 10' ]
- pid = Process.spawn(*cmd, :pgroup => true)
+ pid = Process.spawn(EnvUtil.rubybin, '-e', 'sleep 10', :pgroup => true)
Process.kill(:"-TERM", pid)
Process.waitpid(pid)
assert_equal(true, $?.signaled?)
@@ -45,7 +44,7 @@ class TestSignal < Test::Unit::TestCase
sig = "INT"
term = :KILL
end
- IO.popen([EnvUtil.rubybin, '--disable=gems', '-e', <<-"End"], 'r+') do |io|
+ IO.popen([EnvUtil.rubybin, '-e', <<-"End"], 'r+') do |io|
Signal.trap(:#{sig}, "EXIT")
STDOUT.syswrite("a")
Thread.start { sleep(2) }
@@ -84,12 +83,10 @@ class TestSignal < Test::Unit::TestCase
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { SignalException.new("\u{30eb 30d3 30fc}") }
Signal.list.each do |signm, signo|
next if signm == "EXIT"
- assert_equal(signo, SignalException.new(signm).signo, signm)
- assert_equal(signo, SignalException.new(signm.to_sym).signo, signm)
- assert_equal(signo, SignalException.new(signo).signo, signo)
+ assert_equal(SignalException.new(signm).signo, signo)
+ assert_equal(SignalException.new(signm.to_sym).signo, signo)
+ assert_equal(SignalException.new(signo).signo, signo)
end
- e = assert_raise(ArgumentError) {SignalException.new("-SIGEXIT")}
- assert_not_match(/SIG-SIG/, e.message)
end
def test_interrupt
@@ -137,6 +134,11 @@ class TestSignal < Test::Unit::TestCase
assert_raise(ArgumentError) { Signal.trap }
+ assert_raise(SecurityError) do
+ s = proc {}.taint
+ Signal.trap(:INT, s)
+ end
+
# FIXME!
Signal.trap(:INT, nil)
Signal.trap(:INT, "")
@@ -162,8 +164,6 @@ class TestSignal < Test::Unit::TestCase
assert_raise(ArgumentError) { Signal.trap("XXXXXXXXXX", "SIG_DFL") }
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Signal.trap("\u{30eb 30d3 30fc}", "SIG_DFL") }
-
- assert_raise(ArgumentError) { Signal.trap("EXIT\0") {} }
ensure
Signal.trap(:INT, oldtrap) if oldtrap
end
@@ -228,20 +228,20 @@ class TestSignal < Test::Unit::TestCase
end
def test_signame_delivered
- args = [EnvUtil.rubybin, "--disable=gems", "-e", <<"", :err => File::NULL]
- Signal.trap("INT") do |signo|
- signame = Signal.signame(signo)
- Marshal.dump(signame, STDOUT)
- STDOUT.flush
- exit 0
- end
- Process.kill("INT", $$)
- sleep 1 # wait signal deliver
-
10.times do
- IO.popen(args) do |child|
+ IO.popen([EnvUtil.rubybin, "-e", <<EOS, :err => File::NULL]) do |child|
+ Signal.trap("INT") do |signo|
+ signame = Signal.signame(signo)
+ Marshal.dump(signame, STDOUT)
+ STDOUT.flush
+ exit 0
+ end
+ Process.kill("INT", $$)
+ sleep 1 # wait signal deliver
+EOS
+
signame = Marshal.load(child)
- assert_equal("INT", signame)
+ assert_equal(signame, "INT")
end
end
end if Process.respond_to?(:kill)
@@ -321,67 +321,4 @@ class TestSignal < Test::Unit::TestCase
end
end;
end
-
- def test_sigchld_ignore
- skip 'no SIGCHLD' unless Signal.list['CHLD']
- old = trap(:CHLD, 'IGNORE')
- cmd = [ EnvUtil.rubybin, '--disable=gems', '-e' ]
- assert(system(*cmd, 'exit!(0)'), 'no ECHILD')
- IO.pipe do |r, w|
- pid = spawn(*cmd, "STDIN.read", in: r)
- nb = Process.wait(pid, Process::WNOHANG)
- th = Thread.new(Thread.current) do |parent|
- Thread.pass until parent.stop? # wait for parent to Process.wait
- w.close
- end
- assert_raise(Errno::ECHILD) { Process.wait(pid) }
- th.join
- assert_nil nb
- end
-
- IO.pipe do |r, w|
- pids = 3.times.map { spawn(*cmd, 'exit!', out: w) }
- w.close
- zombies = pids.dup
- assert_nil r.read(1), 'children dead'
-
- Timeout.timeout(10) do
- zombies.delete_if do |pid|
- begin
- Process.kill(0, pid)
- false
- rescue Errno::ESRCH
- true
- end
- end while zombies[0]
- end
- assert_predicate zombies, :empty?, 'zombies leftover'
-
- pids.each do |pid|
- assert_raise(Errno::ECHILD) { Process.waitpid(pid) }
- end
- end
- ensure
- trap(:CHLD, old) if Signal.list['CHLD']
- end
-
- def test_sigwait_fd_unused
- t = EnvUtil.apply_timeout_scale(0.1)
- assert_separately([], <<-End)
- tgt = $$
- trap(:TERM) { exit(0) }
- e = "Process.daemon; sleep #{t * 2}; Process.kill(:TERM,\#{tgt})"
- term = [ '#{EnvUtil.rubybin}', '--disable=gems', '-e', e ]
- t2 = Thread.new { sleep } # grab sigwait_fd
- Thread.pass until t2.stop?
- Thread.new do
- sleep #{t}
- t2.kill
- t2.join
- end
- Process.spawn(*term)
- # last thread remaining, ensure it can react to SIGTERM
- loop { sleep }
- End
- end if Process.respond_to?(:kill) && Process.respond_to?(:daemon)
end
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
index 7986e9d141..a07ac7908b 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -238,12 +238,6 @@ class TestSprintf < Test::Unit::TestCase
assert_equal("with options {:capture=>/\\d+/}", sprintf("with options %p" % options))
end
- def test_inspect
- obj = Object.new
- def obj.inspect; "TEST"; end
- assert_equal("<TEST>", sprintf("<%p>", obj))
- end
-
def test_invalid
# Star precision before star width:
assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%.**d", 5, 10, 1)}
@@ -530,17 +524,12 @@ class TestSprintf < Test::Unit::TestCase
end
def test_no_hidden_garbage
- skip unless Thread.list.size == 1
-
fmt = [4, 2, 2].map { |x| "%0#{x}d" }.join('-') # defeats optimization
ObjectSpace.count_objects(res = {}) # creates strings on first call
- GC.disable
before = ObjectSpace.count_objects(res)[:T_STRING]
val = sprintf(fmt, 1970, 1, 1)
after = ObjectSpace.count_objects(res)[:T_STRING]
assert_equal before + 1, after, 'only new string is the created one'
assert_equal '1970-01-01', val
- ensure
- GC.enable
end
end
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index b6cb0321c8..9574ed31c9 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -4,11 +4,6 @@ require 'test/unit'
class TestString < Test::Unit::TestCase
ENUMERATOR_WANTARRAY = RUBY_VERSION >= "3.0.0"
- WIDE_ENCODINGS = [
- Encoding::UTF_16BE, Encoding::UTF_16LE,
- Encoding::UTF_32BE, Encoding::UTF_32LE,
- ]
-
def initialize(*args)
@cls = String
@aref_re_nth = true
@@ -17,8 +12,8 @@ class TestString < Test::Unit::TestCase
super
end
- def S(*args, **kw)
- @cls.new(*args, **kw)
+ def S(*args)
+ @cls.new(*args)
end
def test_s_new
@@ -107,16 +102,6 @@ PREP
CODE
end
- # Bug #18154
- def test_initialize_nofree_memory_leak
- assert_no_memory_leak([], <<-PREP, <<-CODE, rss: true)
-code = proc {0.to_s.__send__(:initialize, capacity: 10000)}
-1_000.times(&code)
-PREP
-100_000.times(&code)
-CODE
- end
-
def test_AREF # '[]'
assert_equal("A", S("AooBar")[0])
assert_equal("B", S("FooBaB")[-1])
@@ -617,14 +602,18 @@ CODE
end
def test_clone
- for frozen in [ false, true ]
- a = S("Cool")
- a.freeze if frozen
- b = a.clone
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_equal(a.frozen?, b.frozen?)
+ for taint in [ false, true ]
+ for frozen in [ false, true ]
+ a = S("Cool")
+ a.taint if taint
+ a.freeze if frozen
+ b = a.clone
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_equal(a.frozen?, b.frozen?)
+ assert_equal(a.tainted?, b.tainted?)
+ end
end
assert_equal("", File.read(IO::NULL).clone, '[ruby-dev:32819] reported by Kazuhiro NISHIYAMA')
@@ -671,35 +660,21 @@ CODE
assert_raise(ArgumentError) { "foo".count }
end
- def crypt_supports_des_crypt?
- /openbsd/ !~ RUBY_PLATFORM
- end
-
def test_crypt
- if crypt_supports_des_crypt?
- pass = "aaGUC/JkO9/Sc"
- good_salt = "aa"
- bad_salt = "ab"
- else
- pass = "$2a$04$0WVaz0pV3jzfZ5G5tpmHWuBQGbkjzgtSc3gJbmdy0GAGMa45MFM2."
- good_salt = "$2a$04$0WVaz0pV3jzfZ5G5tpmHWu"
- bad_salt = "$2a$04$0WVaz0pV3jzfZ5G5tpmHXu"
- end
- assert_equal(S(pass), S("mypassword").crypt(S(good_salt)))
- assert_not_equal(S(pass), S("mypassword").crypt(S(bad_salt)))
+ assert_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("aa")))
+ assert_not_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("ab")))
assert_raise(ArgumentError) {S("mypassword").crypt(S(""))}
assert_raise(ArgumentError) {S("mypassword").crypt(S("\0a"))}
assert_raise(ArgumentError) {S("mypassword").crypt(S("a\0"))}
assert_raise(ArgumentError) {S("poison\u0000null").crypt(S("aa"))}
- WIDE_ENCODINGS.each do |enc|
+ [Encoding::UTF_16BE, Encoding::UTF_16LE,
+ Encoding::UTF_32BE, Encoding::UTF_32LE].each do |enc|
assert_raise(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))}
assert_raise(ArgumentError) {S("mypassword".encode(enc)).crypt(S("aa"))}
end
- @cls == String and
- assert_no_memory_leak([], "s = ''; salt_proc = proc{#{(crypt_supports_des_crypt? ? '..' : good_salt).inspect}}", "#{<<~"begin;"}\n#{<<~'end;'}")
- begin;
- 1000.times { s.crypt(-salt_proc.call).clear }
+ @cls == String and assert_no_memory_leak([], 's = ""', <<~'end;') # do
+ 1000.times { s.crypt(-"..").clear }
end;
end
@@ -851,20 +826,21 @@ CODE
assert_raise(RuntimeError) { S('"\xA"').undump }
assert_raise(RuntimeError) { S('"\\"').undump }
assert_raise(RuntimeError) { S(%("\0")).undump }
- assert_raise_with_message(RuntimeError, /invalid/) {
- '"\\u{007F}".xxxxxx'.undump
- }
end
def test_dup
- for frozen in [ false, true ]
- a = S("hello")
- a.freeze if frozen
- b = a.dup
-
- assert_equal(a, b)
- assert_not_same(a, b)
- assert_not_predicate(b, :frozen?)
+ for taint in [ false, true ]
+ for frozen in [ false, true ]
+ a = S("hello")
+ a.taint if taint
+ a.freeze if frozen
+ b = a.dup
+
+ assert_equal(a, b)
+ assert_not_same(a, b)
+ assert_not_predicate(b, :frozen?)
+ assert_equal(a.tainted?, b.tainted?)
+ end
end
end
@@ -911,15 +887,20 @@ CODE
assert_equal [65, 66, 67], s.bytes {}
}
else
- res = []
- assert_equal s.object_id, s.bytes {|x| res << x }.object_id
- assert_equal(65, res[0])
- assert_equal(66, res[1])
- assert_equal(67, res[2])
- s = S("ABC")
- res = []
- assert_same s, s.bytes {|x| res << x }
- assert_equal [65, 66, 67], res
+ warning = /passing a block to String#bytes is deprecated/
+ assert_warning(warning) {
+ res = []
+ assert_equal s.object_id, s.bytes {|x| res << x }.object_id
+ assert_equal(65, res[0])
+ assert_equal(66, res[1])
+ assert_equal(67, res[2])
+ }
+ assert_warning(warning) {
+ s = S("ABC")
+ res = []
+ assert_same s, s.bytes {|x| res << x }
+ assert_equal [65, 66, 67], res
+ }
end
end
@@ -950,15 +931,20 @@ CODE
assert_equal [0x3042, 0x3044, 0x3046], s.codepoints {}
}
else
- res = []
- assert_equal s.object_id, s.codepoints {|x| res << x }.object_id
- assert_equal(0x3042, res[0])
- assert_equal(0x3044, res[1])
- assert_equal(0x3046, res[2])
- s = S("ABC")
- res = []
- assert_same s, s.codepoints {|x| res << x }
- assert_equal [65, 66, 67], res
+ warning = /passing a block to String#codepoints is deprecated/
+ assert_warning(warning) {
+ res = []
+ assert_equal s.object_id, s.codepoints {|x| res << x }.object_id
+ assert_equal(0x3042, res[0])
+ assert_equal(0x3044, res[1])
+ assert_equal(0x3046, res[2])
+ }
+ assert_warning(warning) {
+ s = S("ABC")
+ res = []
+ assert_same s, s.codepoints {|x| res << x }
+ assert_equal [65, 66, 67], res
+ }
end
end
@@ -983,11 +969,14 @@ CODE
assert_equal ["A", "B", "C"], s.chars {}
}
else
- res = []
- assert_equal s.object_id, s.chars {|x| res << x }.object_id
- assert_equal("A", res[0])
- assert_equal("B", res[1])
- assert_equal("C", res[2])
+ warning = /passing a block to String#chars is deprecated/
+ assert_warning(warning) {
+ res = []
+ assert_equal s.object_id, s.chars {|x| res << x }.object_id
+ assert_equal("A", res[0])
+ assert_equal("B", res[1])
+ assert_equal("C", res[2])
+ }
end
end
@@ -1010,8 +999,8 @@ CODE
end
[
- ["\u{a 324}", ["\u000A", "\u0324"]],
- ["\u{d 324}", ["\u000D", "\u0324"]],
+ ["\u{a 308}", ["\u000A", "\u0308"]],
+ ["\u{d 308}", ["\u000D", "\u0308"]],
["abc", ["a", "b", "c"]],
].each do |str, grapheme_clusters|
assert_equal grapheme_clusters, str.each_grapheme_cluster.to_a
@@ -1034,19 +1023,12 @@ CODE
"\u{1F468 200D 1F393}",
"\u{1F46F 200D 2642 FE0F}",
"\u{1f469 200d 2764 fe0f 200d 1f469}",
- ].product([Encoding::UTF_8, *WIDE_ENCODINGS]) do |g, enc|
- g = g.encode(enc)
+ ].each do |g|
assert_equal [g], g.grapheme_clusters
end
- [
- "\u{a 324}",
- "\u{d 324}",
- "abc",
- ].product([Encoding::UTF_8, *WIDE_ENCODINGS]) do |g, enc|
- g = g.encode(enc)
- assert_equal g.chars, g.grapheme_clusters
- end
+ assert_equal ["\u000A", "\u0308"], "\u{a 308}".grapheme_clusters
+ assert_equal ["\u000D", "\u0308"], "\u{d 308}".grapheme_clusters
assert_equal ["a", "b", "c"], "abc".b.grapheme_clusters
if ENUMERATOR_WANTARRAY
@@ -1054,13 +1036,15 @@ CODE
assert_equal ["A", "B", "C"], "ABC".grapheme_clusters {}
}
else
- s = "ABC".b
- res = []
- assert_same s, s.grapheme_clusters {|x| res << x }
- assert_equal(3, res.size)
- assert_equal("A", res[0])
- assert_equal("B", res[1])
- assert_equal("C", res[2])
+ warning = /passing a block to String#grapheme_clusters is deprecated/
+ assert_warning(warning) {
+ s = "ABC".b
+ res = []
+ assert_same s, s.grapheme_clusters {|x| res << x }
+ assert_equal("A", res[0])
+ assert_equal("B", res[1])
+ assert_equal("C", res[2])
+ }
end
end
@@ -1173,10 +1157,12 @@ CODE
assert_equal ["hello\n", "world"], s.lines {}
}
else
- res = []
- assert_equal s.object_id, s.lines {|x| res << x }.object_id
- assert_equal(S("hello\n"), res[0])
- assert_equal(S("world"), res[1])
+ assert_warning(/passing a block to String#lines is deprecated/) {
+ res = []
+ assert_equal s.object_id, s.lines {|x| res << x }.object_id
+ assert_equal(S("hello\n"), res[0])
+ assert_equal(S("world"), res[1])
+ }
end
end
@@ -1209,6 +1195,10 @@ CODE
S("hello").gsub(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 })
assert_equal(S("<>h<>e<>l<>l<>o<>"), S("hello").gsub(S(''), S('<\0>')))
+ a = S("hello")
+ a.taint
+ assert_predicate(a.gsub(/./, S('X')), :tainted?)
+
assert_equal("z", "abc".gsub(/./, "a" => "z"), "moved from btest/knownbug")
assert_raise(ArgumentError) { "foo".gsub }
@@ -1253,6 +1243,11 @@ CODE
a.gsub!(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 }
assert_equal(S("HELL-o"), a)
+ r = S('X')
+ r.taint
+ a.gsub!(/./, r)
+ assert_predicate(a, :tainted?)
+
a = S("hello")
assert_nil(a.sub!(S('X'), S('Y')))
end
@@ -1444,8 +1439,10 @@ CODE
assert_equal(S("foobar"), a.replace(S("foobar")))
a = S("foo")
+ a.taint
b = a.replace(S("xyz"))
assert_equal(S("xyz"), b)
+ assert_predicate(b, :tainted?)
s = "foo" * 100
s2 = ("bar" * 100).dup
@@ -1540,6 +1537,12 @@ CODE
a.scan(/(...)/) { |w| res << w }
assert_equal([[S("cru")], [S("el ")], [S("wor")]],res)
+ a = S("hello")
+ a.taint
+ res = []
+ a.scan(/./) { |w| res << w }
+ assert_predicate(res[0], :tainted?, '[ruby-core:33338] #4087')
+
/h/ =~ a
a.scan(/x/)
assert_nil($~)
@@ -1548,6 +1551,8 @@ CODE
a.scan('x')
assert_nil($~)
+ assert_equal(3, S("hello hello hello").scan("hello".taint).count(&:tainted?))
+
assert_equal(%w[1 2 3], S("a1 a2 a3").scan(/a\K./))
end
@@ -1716,51 +1721,10 @@ CODE
assert_equal([S("a"), S(""), S("b"), S("c"), S("")], S("a||b|c|").split(S('|'), -1))
assert_equal([], "".split(//, 1))
- ensure
- EnvUtil.suppress_warning {$; = fs}
- end
-
- def test_split_with_block
- fs, $; = $;, nil
- result = []; S(" a b\t c ").split {|s| result << s}
- assert_equal([S("a"), S("b"), S("c")], result)
- result = []; S(" a b\t c ").split(S(" ")) {|s| result << s}
- assert_equal([S("a"), S("b"), S("c")], result)
-
- result = []; S(" a | b | c ").split(S("|")) {|s| result << s}
- assert_equal([S(" a "), S(" b "), S(" c ")], result)
-
- result = []; S("aXXbXXcXX").split(/X./) {|s| result << s}
- assert_equal([S("a"), S("b"), S("c")], result)
-
- result = []; S("abc").split(//) {|s| result << s}
- assert_equal([S("a"), S("b"), S("c")], result)
-
- result = []; S("a|b|c").split(S('|'), 1) {|s| result << s}
- assert_equal([S("a|b|c")], result)
-
- result = []; S("a|b|c").split(S('|'), 2) {|s| result << s}
- assert_equal([S("a"), S("b|c")], result)
- result = []; S("a|b|c").split(S('|'), 3) {|s| result << s}
- assert_equal([S("a"), S("b"), S("c")], result)
- result = []; S("a|b|c|").split(S('|'), -1) {|s| result << s}
- assert_equal([S("a"), S("b"), S("c"), S("")], result)
- result = []; S("a|b|c||").split(S('|'), -1) {|s| result << s}
- assert_equal([S("a"), S("b"), S("c"), S(""), S("")], result)
-
- result = []; S("a||b|c|").split(S('|')) {|s| result << s}
- assert_equal([S("a"), S(""), S("b"), S("c")], result)
- result = []; S("a||b|c|").split(S('|'), -1) {|s| result << s}
- assert_equal([S("a"), S(""), S("b"), S("c"), S("")], result)
-
- result = []; "".split(//, 1) {|s| result << s}
- assert_equal([], result)
-
- result = []; "aaa,bbb,ccc,ddd".split(/,/) {|s| result << s.gsub(/./, "A")}
- assert_equal(["AAA"]*4, result)
+ assert_equal("[2, 3]", [1,2,3].slice!(1,10000).inspect, "moved from btest/knownbug")
ensure
- EnvUtil.suppress_warning {$; = fs}
+ $; = fs
end
def test_fs
@@ -1768,7 +1732,7 @@ CODE
$; = []
}
- assert_separately(%W[-W0], "#{<<~"begin;"}\n#{<<~'end;'}")
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
bug = '[ruby-core:79582] $; must not be GCed'
begin;
$; = " "
@@ -1791,7 +1755,10 @@ CODE
def test_split_wchar
bug8642 = '[ruby-core:56036] [Bug #8642]'
- WIDE_ENCODINGS.each do |enc|
+ [
+ Encoding::UTF_16BE, Encoding::UTF_16LE,
+ Encoding::UTF_32BE, Encoding::UTF_32LE,
+ ].each do |enc|
s = S("abc,def".encode(enc))
assert_equal(["abc", "def"].map {|c| c.encode(enc)},
s.split(",".encode(enc)),
@@ -1818,7 +1785,6 @@ CODE
s.split("b", 1).map(&:upcase!)
assert_equal("abc", s)
end
-
def test_squeeze
assert_equal(S("abc"), S("aaabbbbccc").squeeze)
assert_equal(S("aa bb cc"), S("aa bb cc").squeeze(S(" ")))
@@ -1924,6 +1890,11 @@ CODE
assert_equal(S("a\\&aba"), S("ababa").sub(/b/, '\\\\&'))
assert_equal(S("a\\baba"), S("ababa").sub(/b/, '\\\\\&'))
+ a = S("hello")
+ a.taint
+ x = a.sub(/./, S('X'))
+ assert_predicate(x, :tainted?)
+
o = Object.new
def o.to_str; "bar"; end
assert_equal("fooBARbaz", "foobarbaz".sub(o, "BAR"))
@@ -1971,6 +1942,11 @@ CODE
a=S("hello")
assert_nil(a.sub!(/X/, S('Y')))
+ r = S('X')
+ r.taint
+ a.sub!(/./, r)
+ assert_predicate(a, :tainted?)
+
bug16105 = '[Bug #16105] heap-use-after-free'
a = S("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345678")
b = a.dup
@@ -2997,7 +2973,8 @@ CODE
def test_ascii_incomat_inspect
bug4081 = '[ruby-core:33283]'
- WIDE_ENCODINGS.each do |e|
+ [Encoding::UTF_16LE, Encoding::UTF_16BE,
+ Encoding::UTF_32LE, Encoding::UTF_32BE].each do |e|
assert_equal('"abc"', "abc".encode(e).inspect)
assert_equal('"\\u3042\\u3044\\u3046"', "\u3042\u3044\u3046".encode(e).inspect)
assert_equal('"ab\\"c"', "ab\"c".encode(e).inspect, bug4081)
@@ -3144,22 +3121,6 @@ CODE
assert_same(str, -bar, "uminus deduplicates [Feature #13077]")
end
- def test_uminus_no_freeze_not_bare
- str = @cls.new("foo")
- assert_instance_of(@cls, -str)
- assert_equal(false, str.frozen?)
-
- str = @cls.new("foo")
- str.instance_variable_set(:@iv, 1)
- assert_instance_of(@cls, -str)
- assert_equal(false, str.frozen?)
- assert_equal(1, str.instance_variable_get(:@iv))
-
- str = @cls.new("foo")
- assert_instance_of(@cls, -str)
- assert_equal(false, str.frozen?)
- end
-
def test_ord
assert_equal(97, "a".ord)
assert_equal(97, "abc".ord)
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index 85de0f23a9..af68346442 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -60,10 +60,6 @@ module TestStruct
assert_equal(1, o.a)
end
- def test_attrset_id
- assert_raise(ArgumentError) { Struct.new(:x=) }
- end
-
def test_members
klass = @Struct.new(:a)
o = klass.new(1)
@@ -105,7 +101,6 @@ module TestStruct
@Struct.new("KeywordInitFalse", :a, :b, keyword_init: false)
assert_raise(ArgumentError) { @Struct::KeywordInitTrue.new(1, 2) }
- assert_raise(ArgumentError) { @Struct::KeywordInitTrue.new({a: 100}, 2) }
assert_nothing_raised { @Struct::KeywordInitFalse.new(1, 2) }
assert_nothing_raised { @Struct::KeywordInitTrue.new(a: 1, b: 2) }
assert_raise(ArgumentError) { @Struct::KeywordInitTrue.new(1, b: 2) }
@@ -113,10 +108,6 @@ module TestStruct
assert_equal @Struct::KeywordInitTrue.new(a: 1, b: 2).values, @Struct::KeywordInitFalse.new(1, 2).values
assert_equal "#{@Struct}::KeywordInitFalse", @Struct::KeywordInitFalse.inspect
assert_equal "#{@Struct}::KeywordInitTrue(keyword_init: true)", @Struct::KeywordInitTrue.inspect
- # eval is needed to prevent the warning duplication filter
- k = Class.new(@Struct::KeywordInitTrue) {def initialize(b, options); super(a: options, b: b); end}
- o = assert_warn('') { k.new(42, {foo: 1, bar: 2}) }
- assert_equal(1, o.a[:foo])
@Struct.instance_eval do
remove_const(:KeywordInitTrue)
@@ -124,16 +115,6 @@ module TestStruct
end
end
- def test_struct_new_with_keyword_init_and_block
- struct = @Struct.new(:a, :b, keyword_init: true) do
- def c
- a + b
- end
- end
-
- assert_equal(3, struct.new(a: 1, b: 2).c)
- end
-
def test_initialize
klass = @Struct.new(:a)
assert_raise(ArgumentError) { klass.new(1, 2) }
@@ -151,17 +132,6 @@ module TestStruct
assert_equal([1, 2], o.each.to_a)
end
- def test_initialize_with_kw
- klass = @Struct.new(:foo, :options) do
- def initialize(foo, **options)
- super(foo, options)
- end
- end
- assert_equal({}, klass.new(42, **Hash.new).options)
- x = assert_warn('') { klass.new(1, bar: 2) }
- assert_equal 2, x.options[:bar]
- end
-
def test_each_pair
klass = @Struct.new(:a, :b)
o = klass.new(1, 2)
@@ -246,13 +216,6 @@ module TestStruct
assert_raise(ArgumentError) { o.select(1) }
end
- def test_filter
- klass = @Struct.new(:a, :b, :c, :d, :e, :f)
- o = klass.new(1, 2, 3, 4, 5, 6)
- assert_equal([1, 3, 5], o.filter {|v| v % 2 != 0 })
- assert_raise(ArgumentError) { o.filter(1) }
- end
-
def test_big_struct
klass1 = @Struct.new(*('a'..'z').map(&:to_sym))
o = klass1.new
@@ -309,7 +272,6 @@ module TestStruct
klass = @Struct.new(:a)
o = klass.new(1)
assert_kind_of(Integer, o.hash)
- assert_kind_of(String, o.hash.to_s)
end
def test_eql
@@ -397,13 +359,6 @@ module TestStruct
assert_equal({a:1, b:2, c:3, d:4, e:5, f:6}, o.to_h)
end
- def test_to_h_block
- klass = @Struct.new(:a, :b, :c, :d, :e, :f)
- o = klass.new(1, 2, 3, 4, 5, 6)
- assert_equal({"a" => 1, "b" => 4, "c" => 9, "d" => 16, "e" => 25, "f" => 36},
- o.to_h {|k, v| [k.to_s, v*v]})
- end
-
def test_question_mark_in_member
klass = @Struct.new(:a, :b?)
x = Object.new
@@ -435,25 +390,13 @@ module TestStruct
assert_nil(o.dig(:b, 0))
end
- def test_new_duplicate
+ def test_new_dupilicate
bug12291 = '[ruby-core:74971] [Bug #12291]'
assert_raise_with_message(ArgumentError, /duplicate member/, bug12291) {
@Struct.new(:a, :a)
}
end
- def test_deconstruct_keys
- klass = @Struct.new(:a, :b)
- o = klass.new(1, 2)
- assert_equal({a: 1, b: 2}, o.deconstruct_keys(nil))
- assert_equal({a: 1, b: 2}, o.deconstruct_keys([:b, :a]))
- assert_equal({a: 1}, o.deconstruct_keys([:a]))
- assert_not_send([o.deconstruct_keys([:a, :c]), :key?, :c])
- assert_raise(TypeError) {
- o.deconstruct_keys(0)
- }
- end
-
class TopStruct < Test::Unit::TestCase
include TestStruct
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index bbfc581500..cf7580ab00 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -102,11 +102,11 @@ class TestSuper < Test::Unit::TestCase
def test_optional2
assert_raise(ArgumentError) do
# call Base#optional with 2 arguments; the 2nd arg is supplied
- Optional2.new.optional(9)
+ assert_equal(9, Optional2.new.optional(9))
end
assert_raise(ArgumentError) do
# call Base#optional with 2 arguments
- Optional2.new.optional(9, 2)
+ assert_equal(9, Optional2.new.optional(9, 2))
end
end
def test_optional3
@@ -307,29 +307,6 @@ class TestSuper < Test::Unit::TestCase
end
end
- def test_super_in_instance_eval_in_module
- super_class = EnvUtil.labeled_class("Super\u{30af 30e9 30b9}") {
- def foo
- return [:super, self]
- end
- }
- mod = EnvUtil.labeled_module("Mod\u{30af 30e9 30b9}") {
- def foo
- x = Object.new
- x.instance_eval do
- super()
- end
- end
- }
- sub_class = EnvUtil.labeled_class("Sub\u{30af 30e9 30b9}", super_class) {
- include mod
- }
- obj = sub_class.new
- assert_raise_with_message(TypeError, /Sub\u{30af 30e9 30b9}/) do
- obj.foo
- end
- end
-
def test_super_in_orphan_block
super_class = EnvUtil.labeled_class("Super\u{30af 30e9 30b9}") {
def foo
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 660f2e1574..36cbf4a710 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -161,42 +161,6 @@ class TestSymbol < Test::Unit::TestCase
assert_equal(1, first, bug11594)
end
- class TestToPRocArgWithRefinements; end
- def _test_to_proc_arg_with_refinements_call(&block)
- block.call TestToPRocArgWithRefinements.new
- end
- using Module.new {
- refine TestToPRocArgWithRefinements do
- def hoge
- :hoge
- end
- end
- }
- def test_to_proc_arg_with_refinements
- assert_equal(:hoge, _test_to_proc_arg_with_refinements_call(&:hoge))
- end
-
- def self._test_to_proc_arg_with_refinements_call(&block)
- block.call TestToPRocArgWithRefinements.new
- end
- _test_to_proc_arg_with_refinements_call(&:hoge)
- using Module.new {
- refine TestToPRocArgWithRefinements do
- def hoge
- :hogehoge
- end
- end
- }
- def test_to_proc_arg_with_refinements_override
- assert_equal(:hogehoge, _test_to_proc_arg_with_refinements_call(&:hoge))
- end
-
- def test_to_proc_arg_with_refinements_undefined
- assert_raise(NoMethodError) do
- _test_to_proc_arg_with_refinements_call(&:foo)
- end
- end
-
private def return_from_proc
Proc.new { return 1 }.tap(&:call)
end
@@ -533,6 +497,14 @@ class TestSymbol < Test::Unit::TestCase
end;
end
+ def test_not_freeze
+ bug11721 = '[ruby-core:71611] [Bug #11721]'
+ str = "\u{1f363}".taint
+ assert_not_predicate(str, :frozen?)
+ assert_equal str, str.to_sym.to_s
+ assert_not_predicate(str, :frozen?, bug11721)
+ end
+
def test_hash_nondeterministic
ruby = EnvUtil.rubybin
assert_not_equal :foo.hash, `#{ruby} -e 'puts :foo.hash'`.to_i,
@@ -555,27 +527,4 @@ class TestSymbol < Test::Unit::TestCase
puts :a == :a
RUBY
end
-
- def test_start_with?
- assert_equal(true, :hello.start_with?("hel"))
- assert_equal(false, :hello.start_with?("el"))
- assert_equal(true, :hello.start_with?("el", "he"))
-
- bug5536 = '[ruby-core:40623]'
- assert_raise(TypeError, bug5536) {:str.start_with? :not_convertible_to_string}
-
- assert_equal(true, :hello.start_with?(/hel/))
- assert_equal("hel", $&)
- assert_equal(false, :hello.start_with?(/el/))
- assert_nil($&)
- end
-
- def test_end_with?
- assert_equal(true, :hello.end_with?("llo"))
- assert_equal(false, :hello.end_with?("ll"))
- assert_equal(true, :hello.end_with?("el", "lo"))
-
- bug5536 = '[ruby-core:40623]'
- assert_raise(TypeError, bug5536) {:str.end_with? :not_convertible_to_string}
- end
end
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 86417ba12f..f8d28a4f8e 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -46,7 +46,7 @@ class TestSyntax < Test::Unit::TestCase
assert_raise(ArgumentError, enc.name) {load(f.path)}
end
ensure
- f&.close!
+ f.close! if f
end
def test_script_lines
@@ -63,7 +63,7 @@ class TestSyntax < Test::Unit::TestCase
end
end
ensure
- f&.close!
+ f.close! if f
end
def test_newline_in_block_parameters
@@ -93,40 +93,6 @@ class TestSyntax < Test::Unit::TestCase
assert_valid_syntax("tap (proc do end)", __FILE__, bug9726)
end
- def test_array_kwsplat_hash
- kw = {}
- h = {a: 1}
- assert_equal([], [**{}])
- assert_equal([], [**kw])
- assert_equal([h], [**h])
- assert_equal([{}], [{}])
- assert_equal([kw], [kw])
- assert_equal([h], [h])
-
- assert_equal([1], [1, **{}])
- assert_equal([1], [1, **kw])
- assert_equal([1, h], [1, **h])
- assert_equal([1, {}], [1, {}])
- assert_equal([1, kw], [1, kw])
- assert_equal([1, h], [1, h])
-
- assert_equal([], [**kw, **kw])
- assert_equal([], [**kw, **{}, **kw])
- assert_equal([1], [1, **kw, **{}, **kw])
-
- assert_equal([{}], [{}, **kw, **kw])
- assert_equal([kw], [kw, **kw, **kw])
- assert_equal([h], [h, **kw, **kw])
- assert_equal([h, h], [h, **kw, **kw, **h])
-
- assert_equal([h, {:a=>2}], [h, **{}, **h, a: 2])
- assert_equal([h, h], [h, **{}, a: 2, **h])
- assert_equal([h, h], [h, a: 2, **{}, **h])
- assert_equal([h, h], [h, a: 2, **h, **{}])
- assert_equal([h, {:a=>2}], [h, **h, a: 2, **{}])
- assert_equal([h, {:a=>2}], [h, **h, **{}, a: 2])
- end
-
def test_normal_argument
assert_valid_syntax('def foo(x) end')
assert_syntax_error('def foo(X) end', /constant/)
@@ -182,9 +148,7 @@ class TestSyntax < Test::Unit::TestCase
h = {k3: 31}
assert_raise(ArgumentError) {o.kw(**h)}
h = {"k1"=>11, k2: 12}
- assert_warn(/Splitting the last argument into positional and keyword parameters is deprecated.*The called method `kw'/m) do
- assert_raise(ArgumentError) {o.kw(**h)}
- end
+ assert_raise(TypeError) {o.kw(**h)}
end
def test_keyword_duplicated
@@ -223,25 +187,33 @@ class TestSyntax < Test::Unit::TestCase
end
def test_keyword_self_reference
- message = /circular argument reference - var/
- assert_syntax_error("def foo(var: defined?(var)) var end", message)
- assert_syntax_error("def foo(var: var) var end", message)
- assert_syntax_error("def foo(var: bar(var)) var end", message)
- assert_syntax_error("def foo(var: bar {var}) var end", message)
+ bug9593 = '[ruby-core:61299] [Bug #9593]'
+ o = Object.new
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var: defined?(var)) var end")
+ end
+ assert_equal(42, o.foo(var: 42))
+ assert_equal("local-variable", o.foo, bug9593)
o = Object.new
- assert_warn("") do
- o.instance_eval("def foo(var: bar {|var| var}) var end")
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var: var) var end")
end
+ assert_nil(o.foo, bug9593)
o = Object.new
- assert_warn("") do
- o.instance_eval("def foo(var: bar {| | var}) var end")
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var: bar(var)) var end")
+ end
+
+ o = Object.new
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var: bar {var}) var end")
end
o = Object.new
assert_warn("") do
- o.instance_eval("def foo(var: bar {|| var}) var end")
+ o.instance_eval("def foo(var: bar {|var| var}) var end")
end
o = Object.new
@@ -258,55 +230,56 @@ class TestSyntax < Test::Unit::TestCase
def test_keyword_invalid_name
bug11663 = '[ruby-core:71356] [Bug #11663]'
- assert_syntax_error('def foo(arg1?:) end', /arg1\?/, bug11663)
- assert_syntax_error('def foo(arg1?:, arg2:) end', /arg1\?/, bug11663)
+ o = o = Object.new
+ assert_syntax_error('def o.foo(arg1?:) end', /arg1\?/, bug11663)
+ assert_syntax_error('def o.foo(arg1?:, arg2:) end', /arg1\?/, bug11663)
assert_syntax_error('proc {|arg1?:|}', /arg1\?/, bug11663)
assert_syntax_error('proc {|arg1?:, arg2:|}', /arg1\?/, bug11663)
bug10545 = '[ruby-dev:48742] [Bug #10545]'
- assert_syntax_error('def foo(FOO: a) end', /constant/, bug10545)
- assert_syntax_error('def foo(@foo: a) end', /instance variable/)
- assert_syntax_error('def foo(@@foo: a) end', /class variable/)
+ assert_syntax_error('def o.foo(FOO: a) end', /constant/, bug10545)
+ assert_syntax_error('def o.foo(@foo: a) end', /instance variable/)
+ assert_syntax_error('def o.foo(@@foo: a) end', /class variable/)
end
- def test_keywords_specified_and_not_accepted
- assert_syntax_error('def foo(a:, **nil) end', /unexpected/)
- assert_syntax_error('def foo(a:, **nil, &b) end', /unexpected/)
- assert_syntax_error('def foo(**a, **nil) end', /unexpected/)
- assert_syntax_error('def foo(**a, **nil, &b) end', /unexpected/)
- assert_syntax_error('def foo(**nil, **a) end', /unexpected/)
- assert_syntax_error('def foo(**nil, **a, &b) end', /unexpected/)
+ def test_optional_self_reference
+ bug9593 = '[ruby-core:61299] [Bug #9593]'
+ o = Object.new
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var = defined?(var)) var end")
+ end
+ assert_equal(42, o.foo(42))
+ assert_equal("local-variable", o.foo, bug9593)
- assert_syntax_error('proc do |a:, **nil| end', /unexpected/)
- assert_syntax_error('proc do |a:, **nil, &b| end', /unexpected/)
- assert_syntax_error('proc do |**a, **nil| end', /unexpected/)
- assert_syntax_error('proc do |**a, **nil, &b| end', /unexpected/)
- assert_syntax_error('proc do |**nil, **a| end', /unexpected/)
- assert_syntax_error('proc do |**nil, **a, &b| end', /unexpected/)
- end
+ o = Object.new
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var = var) var end")
+ end
+ assert_nil(o.foo, bug9593)
- def test_optional_self_reference
- message = /circular argument reference - var/
- assert_syntax_error("def foo(var = defined?(var)) var end", message)
- assert_syntax_error("def foo(var = var) var end", message)
- assert_syntax_error("def foo(var = bar(var)) var end", message)
- assert_syntax_error("def foo(var = bar {var}) var end", message)
- assert_syntax_error("def foo(var = (def bar;end; var)) var end", message)
- assert_syntax_error("def foo(var = (def self.bar;end; var)) var end", message)
+ o = Object.new
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var = bar(var)) var end")
+ end
o = Object.new
- assert_warn("") do
- o.instance_eval("def foo(var = bar {|var| var}) var end")
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var = bar {var}) var end")
end
o = Object.new
- assert_warn("") do
- o.instance_eval("def foo(var = bar {| | var}) var end")
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var = (def bar;end; var)) var end")
+ end
+
+ o = Object.new
+ assert_warn(/circular argument reference - var/) do
+ o.instance_eval("def foo(var = (def self.bar;end; var)) var end")
end
o = Object.new
assert_warn("") do
- o.instance_eval("def foo(var = bar {|| var}) var end")
+ o.instance_eval("def foo(var = bar {|var| var}) var end")
end
o = Object.new
@@ -433,30 +406,21 @@ WARN
def test_duplicated_arg
assert_syntax_error("def foo(a, a) end", /duplicated argument name/)
assert_valid_syntax("def foo(_, _) end")
- (obj = Object.new).instance_eval("def foo(_, x, _) x end")
- assert_equal(2, obj.foo(1, 2, 3))
end
def test_duplicated_rest
assert_syntax_error("def foo(a, *a) end", /duplicated argument name/)
assert_valid_syntax("def foo(_, *_) end")
- (obj = Object.new).instance_eval("def foo(_, x, *_) x end")
- assert_equal(2, obj.foo(1, 2, 3))
end
def test_duplicated_opt
assert_syntax_error("def foo(a, a=1) end", /duplicated argument name/)
assert_valid_syntax("def foo(_, _=1) end")
- (obj = Object.new).instance_eval("def foo(_, x, _=42) x end")
- assert_equal(2, obj.foo(1, 2))
end
def test_duplicated_opt_rest
assert_syntax_error("def foo(a=1, *a) end", /duplicated argument name/)
assert_valid_syntax("def foo(_=1, *_) end")
- (obj = Object.new).instance_eval("def foo(_, x=42, *_) x end")
- assert_equal(42, obj.foo(1))
- assert_equal(2, obj.foo(1, 2))
end
def test_duplicated_rest_opt
@@ -465,85 +429,46 @@ WARN
def test_duplicated_rest_post
assert_syntax_error("def foo(*a, a) end", /duplicated argument name/)
- assert_valid_syntax("def foo(*_, _) end")
- (obj = Object.new).instance_eval("def foo(*_, x, _) x end")
- assert_equal(2, obj.foo(1, 2, 3))
- assert_equal(2, obj.foo(2, 3))
- (obj = Object.new).instance_eval("def foo(*_, _, x) x end")
- assert_equal(3, obj.foo(1, 2, 3))
- assert_equal(3, obj.foo(2, 3))
end
def test_duplicated_opt_post
assert_syntax_error("def foo(a=1, a) end", /duplicated argument name/)
assert_valid_syntax("def foo(_=1, _) end")
- (obj = Object.new).instance_eval("def foo(_=1, x, _) x end")
- assert_equal(2, obj.foo(1, 2, 3))
- assert_equal(2, obj.foo(2, 3))
- (obj = Object.new).instance_eval("def foo(_=1, _, x) x end")
- assert_equal(3, obj.foo(1, 2, 3))
- assert_equal(3, obj.foo(2, 3))
end
def test_duplicated_kw
assert_syntax_error("def foo(a, a: 1) end", /duplicated argument name/)
assert_valid_syntax("def foo(_, _: 1) end")
- (obj = Object.new).instance_eval("def foo(_, x, _: 1) x end")
- assert_equal(3, obj.foo(2, 3))
- assert_equal(3, obj.foo(2, 3, _: 42))
- (obj = Object.new).instance_eval("def foo(x, _, _: 1) x end")
- assert_equal(2, obj.foo(2, 3))
- assert_equal(2, obj.foo(2, 3, _: 42))
end
def test_duplicated_rest_kw
assert_syntax_error("def foo(*a, a: 1) end", /duplicated argument name/)
assert_nothing_raised {def foo(*_, _: 1) end}
- (obj = Object.new).instance_eval("def foo(*_, x: 42, _: 1) x end")
- assert_equal(42, obj.foo(42))
- assert_equal(42, obj.foo(2, _: 0))
- assert_equal(2, obj.foo(x: 2, _: 0))
end
def test_duplicated_opt_kw
assert_syntax_error("def foo(a=1, a: 1) end", /duplicated argument name/)
assert_valid_syntax("def foo(_=1, _: 1) end")
- (obj = Object.new).instance_eval("def foo(_=42, x, _: 1) x end")
- assert_equal(0, obj.foo(0))
- assert_equal(0, obj.foo(0, _: 3))
end
def test_duplicated_kw_kwrest
assert_syntax_error("def foo(a: 1, **a) end", /duplicated argument name/)
assert_valid_syntax("def foo(_: 1, **_) end")
- (obj = Object.new).instance_eval("def foo(_: 1, x: 42, **_) x end")
- assert_equal(42, obj.foo())
- assert_equal(42, obj.foo(a: 0))
- assert_equal(42, obj.foo(_: 0, a: 0))
- assert_equal(1, obj.foo(_: 0, x: 1, a: 0))
end
def test_duplicated_rest_kwrest
assert_syntax_error("def foo(*a, **a) end", /duplicated argument name/)
assert_valid_syntax("def foo(*_, **_) end")
- (obj = Object.new).instance_eval("def foo(*_, x, **_) x end")
- assert_equal(1, obj.foo(1))
- assert_equal(1, obj.foo(1, a: 0))
- assert_equal(2, obj.foo(1, 2, a: 0))
end
def test_duplicated_opt_kwrest
assert_syntax_error("def foo(a=1, **a) end", /duplicated argument name/)
assert_valid_syntax("def foo(_=1, **_) end")
- (obj = Object.new).instance_eval("def foo(_=42, x, **_) x end")
- assert_equal(1, obj.foo(1))
- assert_equal(1, obj.foo(1, a: 0))
- assert_equal(1, obj.foo(0, 1, a: 0))
end
def test_duplicated_when
- w = 'warning: duplicated `when\' clause with line 3 is ignored'
- assert_warning(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m) {
+ w = 'warning: duplicated when clause is ignored'
+ assert_warning(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
eval %q{
case 1
when 1, 1
@@ -552,7 +477,7 @@ WARN
end
}
}
- assert_warning(/#{w}/) {#/3: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
+ assert_warning(/#{w}/){#/3: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
a = a = 1
eval %q{
case 1
@@ -564,17 +489,6 @@ WARN
}
end
- def test_duplicated_when_check_option
- w = /duplicated `when\' clause with line 3 is ignored/
- assert_in_out_err(%[-wc], "#{<<~"begin;"}\n#{<<~'end;'}", ["Syntax OK"], w)
- begin;
- case 1
- when 1
- when 1
- end
- end;
- end
-
def test_invalid_break
assert_syntax_error("def m; break; end", /Invalid break/)
assert_syntax_error('/#{break}/', /Invalid break/)
@@ -620,7 +534,7 @@ WARN
def test_unassignable
gvar = global_variables
%w[self nil true false __FILE__ __LINE__ __ENCODING__].each do |kwd|
- assert_syntax_error("#{kwd} = nil", /Can't .* #{kwd}$/)
+ assert_raise(SyntaxError) {eval("#{kwd} = nil")}
assert_equal(gvar, global_variables)
end
end
@@ -780,8 +694,6 @@ e"
\
TEXT
end;
-
- assert_equal(" TEXT\n", eval("<<~eos\n" " \\\n" "TEXT\n" "eos\n"))
end
def test_lineno_after_heredoc
@@ -799,44 +711,33 @@ eom
assert_syntax_error('<<~ "#{}"', /unexpected <</)
end
- def test_dedented_heredoc_concatenation
- assert_equal("\n0\n1", eval("<<~0 '1'\n \n0\#{}\n0"))
- end
-
def test_heredoc_mixed_encoding
- e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\xe9\x9d\u1234
TEXT
HEREDOC
- assert_not_match(/end-of-input/, e.message)
-
- e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\xe9\x9d
\u1234
TEXT
HEREDOC
- assert_not_match(/end-of-input/, e.message)
-
- e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\u1234\xe9\x9d
TEXT
HEREDOC
- assert_not_match(/end-of-input/, e.message)
-
- e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\u1234
\xe9\x9d
TEXT
HEREDOC
- assert_not_match(/end-of-input/, e.message)
end
def test_lineno_operation_brace_block
@@ -928,20 +829,9 @@ eom
assert_syntax_error("puts <<""EOS\n""ng\n""EOS\r""NO\n", /can't find string "EOS" anywhere before EOF/)
end
- def test_heredoc_no_terminator
- assert_syntax_error("puts <<""A\n", /can't find string "A" anywhere before EOF/)
- assert_syntax_error("puts <<""A + <<""B\n", /can't find string "A" anywhere before EOF/)
- assert_syntax_error("puts <<""A + <<""B\n", /can't find string "B" anywhere before EOF/)
- end
-
- def test_unterminated_heredoc
- assert_syntax_error("<<\"EOS\n\nEOS\n", /unterminated/)
- assert_syntax_error("<<\"EOS\n\"\nEOS\n", /unterminated/)
- end
-
- def test_unterminated_heredoc_cr
- %W[\r\n \n].each do |nl|
- assert_syntax_error("<<\"\r\"#{nl}\r#{nl}", /unterminated/, nil, "CR with #{nl.inspect}")
+ def test_heredoc_newline
+ assert_warn(/ends with a newline/) do
+ eval("<<\"EOS\n\"\nEOS\n")
end
end
@@ -975,15 +865,8 @@ eom
bug10957 = '[ruby-core:68477] [Bug #10957]'
assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957)
assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957)
- assert_syntax_error('0..%q.', /unterminated string/, bug10957)
- assert_syntax_error('0...%q.', /unterminated string/, bug10957)
- end
-
- def test_range_at_eol
- assert_warn(/\.\.\. at EOL/) {eval("1...\n2")}
- assert_warn('') {eval("(1...)")}
- assert_warn('') {eval("(1...\n2)")}
- assert_warn('') {eval("{a: 1...\n2}")}
+ assert_syntax_error('0..%w.', /unterminated string/, bug10957)
+ assert_syntax_error('0...%w.', /unterminated string/, bug10957)
end
def test_too_big_nth_ref
@@ -999,21 +882,9 @@ eom
assert_syntax_error(":#\n foo", /unexpected ':'/)
end
- def test_invalid_literal_message
- assert_syntax_error("def :foo", /unexpected symbol literal/)
- assert_syntax_error("def 'foo'", /unexpected string literal/)
- end
-
def test_fluent_dot
assert_valid_syntax("a\n.foo")
assert_valid_syntax("a\n&.foo")
- assert_valid_syntax("a #\n#\n.foo\n")
- assert_valid_syntax("a #\n#\n&.foo\n")
- end
-
- def test_safe_call_in_massign_lhs
- assert_syntax_error("*a&.x=0", /multiple assignment destination/)
- assert_syntax_error("a&.x,=0", /multiple assignment destination/)
end
def test_no_warning_logop_literal
@@ -1035,6 +906,9 @@ eom
assert_warn(/literal in condition/) do
eval('1 if //')
end
+ assert_warn(/literal in condition/) do
+ eval('1 if true..false')
+ end
assert_warning(/literal in condition/) do
eval('1 if 1')
end
@@ -1065,27 +939,6 @@ eom
end
end
- def test_warning_literal_in_flip_flop
- assert_warn(/literal in flip-flop/) do
- eval('1 if ""..false')
- end
- assert_warning(/literal in flip-flop/) do
- eval('1 if :foo..false')
- end
- assert_warning(/literal in flip-flop/) do
- eval('1 if :"#{"foo".upcase}"..false')
- end
- assert_warn(/literal in flip-flop/) do
- eval('1 if ""...false')
- end
- assert_warning(/literal in flip-flop/) do
- eval('1 if :foo...false')
- end
- assert_warning(/literal in flip-flop/) do
- eval('1 if :"#{"foo".upcase}"...false')
- end
- end
-
def test_alias_symbol
bug8851 = '[ruby-dev:47681] [Bug #8851]'
formats = ['%s', ":'%s'", ':"%s"', '%%s(%s)']
@@ -1111,7 +964,7 @@ eom
end
def test_parenthesised_statement_argument
- assert_syntax_error("foo(bar rescue nil)", /unexpected `rescue' modifier/)
+ assert_syntax_error("foo(bar rescue nil)", /unexpected modifier_rescue/)
assert_valid_syntax("foo (bar rescue nil)")
end
@@ -1241,14 +1094,6 @@ eom
end
end
- def test_return_toplevel_with_argument
- assert_warn(/argument of top-level return is ignored/) {eval("return 1")}
- end
-
- def test_return_in_proc_in_class
- assert_in_out_err(['-e', 'class TestSyntax; proc{ return }.call; end'], "", [], /^-e:1:.*unexpected return \(LocalJumpError\)/)
- end
-
def test_syntax_error_in_rescue
bug12613 = '[ruby-core:76531] [Bug #12613]'
assert_syntax_error("#{<<-"begin;"}\n#{<<-"end;"}", /Invalid retry/, bug12613)
@@ -1266,12 +1111,6 @@ eom
end;
end
- def test_syntax_error_at_newline
- expected = "\n ^"
- assert_syntax_error("%[abcdef", expected)
- assert_syntax_error("%[abcdef\n", expected)
- end
-
def test_invalid_jump
assert_in_out_err(%w[-e redo], "", [], /^-e:1: /)
end
@@ -1347,24 +1186,6 @@ eom
assert_equal(:begin, result)
end
- def test_rescue_do_end_ensure_in_lambda
- result = []
- eval("#{<<-"begin;"}\n#{<<-"end;"}")
- begin;
- -> do
- result << :begin
- raise "An exception occurred!"
- rescue
- result << :rescue
- else
- result << :else
- ensure
- result << :ensure
- end.call
- end;
- assert_equal([:begin, :rescue, :ensure], result)
- end
-
def test_return_in_loop
obj = Object.new
def obj.test
@@ -1374,298 +1195,6 @@ eom
assert_nil obj.test
end
- def test_assignment_return_in_loop
- obj = Object.new
- def obj.test
- x = nil
- _y = (return until x unless x)
- end
- assert_nil obj.test, "[Bug #16695]"
- end
-
- def test_method_call_location
- line = __LINE__+5
- e = assert_raise(NoMethodError) do
- 1.upto(0) do
- end
- .
- foo(
- 1,
- 2,
- )
- end
- assert_equal(line, e.backtrace_locations[0].lineno)
-
- line = __LINE__+5
- e = assert_raise(NoMethodError) do
- 1.upto 0 do
- end
- .
- foo(
- 1,
- 2,
- )
- end
- assert_equal(line, e.backtrace_locations[0].lineno)
- end
-
- def test_methoddef_in_cond
- assert_valid_syntax('while def foo; tap do end; end; break; end')
- assert_valid_syntax('while def foo a = tap do end; end; break; end')
- end
-
- def test_classdef_in_cond
- assert_valid_syntax('while class Foo; tap do end; end; break; end')
- assert_valid_syntax('while class Foo a = tap do end; end; break; end')
- end
-
- def test_command_with_cmd_brace_block
- assert_valid_syntax('obj.foo (1) {}')
- assert_valid_syntax('obj::foo (1) {}')
- end
-
- def test_numbered_parameter
- assert_valid_syntax('proc {_1}')
- assert_equal(3, eval('[1,2].then {_1+_2}'))
- assert_equal("12", eval('[1,2].then {"#{_1}#{_2}"}'))
- assert_equal([1, 2], eval('[1,2].then {_1}'))
- assert_equal(3, eval('->{_1+_2}.call(1,2)'))
- assert_equal(4, eval('->(a=->{_1}){a}.call.call(4)'))
- assert_equal(5, eval('-> a: ->{_1} {a}.call.call(5)'))
- assert_syntax_error('proc {|| _1}', /ordinary parameter is defined/)
- assert_syntax_error('proc {|;a| _1}', /ordinary parameter is defined/)
- assert_syntax_error("proc {|\n| _1}", /ordinary parameter is defined/)
- assert_syntax_error('proc {|x| _1}', /ordinary parameter is defined/)
- assert_syntax_error('proc {_1; proc {_2}}', /numbered parameter is already used/)
- assert_syntax_error('proc {proc {_1}; _2}', /numbered parameter is already used/)
- assert_syntax_error('->(){_1}', /ordinary parameter is defined/)
- assert_syntax_error('->(x){_1}', /ordinary parameter is defined/)
- assert_syntax_error('->x{_1}', /ordinary parameter is defined/)
- assert_syntax_error('->x:_2{}', /ordinary parameter is defined/)
- assert_syntax_error('->x=_1{}', /ordinary parameter is defined/)
- assert_syntax_error('-> {_1; -> {_2}}', /numbered parameter is already used/)
- assert_syntax_error('-> {-> {_1}; _2}', /numbered parameter is already used/)
- assert_syntax_error('proc {_1; _1 = nil}', /Can't assign to numbered parameter _1/)
- mesg = proc {|n| /`_#{n}' is reserved for numbered parameter/}
- assert_warn(mesg[1]) {eval('proc {_1 = nil}')}
- assert_warn(mesg[2]) {eval('_2=1')}
- assert_warn(mesg[3]) {eval('proc {|_3|}')}
- assert_warn(mesg[4]) {instance_eval('def x(_4) end')}
- assert_warn(mesg[5]) {instance_eval('def _5; end')}
- assert_warn(mesg[6]) {instance_eval('def self._6; end')}
- assert_raise_with_message(NameError, /undefined local variable or method `_1'/) {
- eval('_1')
- }
- ['class C', 'class << C', 'module M', 'def m', 'def o.m'].each do |c|
- assert_valid_syntax("->{#{c};->{_1};end;_1}\n")
- assert_valid_syntax("->{_1;#{c};->{_1};end}\n")
- end
-
- 1.times {_1}
- end
-
- def test_value_expr_in_condition
- mesg = /void value expression/
- assert_syntax_error("tap {a = (true ? next : break)}", mesg)
- assert_valid_syntax("tap {a = (true ? true : break)}")
- assert_valid_syntax("tap {a = (break if false)}")
- assert_valid_syntax("tap {a = (break unless true)}")
- end
-
- def test_argument_forwarding
- assert_valid_syntax('def foo(...) bar(...) end')
- assert_valid_syntax('def foo(...) end')
- assert_valid_syntax('def ==(...) end')
- assert_valid_syntax('def [](...) end')
- assert_valid_syntax('def nil(...) end')
- assert_valid_syntax('def true(...) end')
- assert_valid_syntax('def false(...) end')
- assert_syntax_error('iter do |...| end', /unexpected/)
- assert_syntax_error('iter {|...|}', /unexpected/)
- assert_syntax_error('->... {}', /unexpected/)
- assert_syntax_error('->(...) {}', /unexpected/)
- assert_syntax_error('def foo(x, y, z) bar(...); end', /unexpected/)
- assert_syntax_error('def foo(x, y, z) super(...); end', /unexpected/)
- assert_syntax_error('def foo(...) yield(...); end', /unexpected/)
- assert_syntax_error('def foo(...) return(...); end', /unexpected/)
- assert_syntax_error('def foo(...) a = (...); end', /unexpected/)
- assert_syntax_error('def foo(...) [...]; end', /unexpected/)
- assert_syntax_error('def foo(...) foo[...]; end', /unexpected/)
- assert_syntax_error('def foo(...) foo[...] = x; end', /unexpected/)
- assert_syntax_error('def foo(...) foo(...) { }; end', /both block arg and actual block given/)
- assert_syntax_error('def foo(...) defined?(...); end', /unexpected/)
-
- obj1 = Object.new
- def obj1.bar(*args, **kws, &block)
- if block
- block.call(args, kws)
- else
- [args, kws]
- end
- end
- obj1.instance_eval('def foo(...) bar(...) end', __FILE__, __LINE__)
-
- klass = Class.new {
- def foo(*args, **kws, &block)
- if block
- block.call(args, kws)
- else
- [args, kws]
- end
- end
- }
- obj2 = klass.new
- obj2.instance_eval('def foo(...) super(...) end', __FILE__, __LINE__)
-
- obj3 = Object.new
- def obj3.bar(*args, &block)
- if kws = Hash.try_convert(args.last)
- args.pop
- else
- kws = {}
- end
- if block
- block.call(args, kws)
- else
- [args, kws]
- end
- end
- obj3.instance_eval('def foo(...) bar(...) end', __FILE__, __LINE__)
-
- [obj1, obj2, obj3].each do |obj|
- assert_warning('') {
- assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5) {|*x| x})
- }
- assert_warning('') {
- assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5))
- }
- warning = "warning: Using the last argument as keyword parameters is deprecated"
- assert_warning(/\A\z|:(?!#{__LINE__+1})\d+: #{warning}/o) {
- assert_equal([[], {}], obj.foo({}) {|*x| x})
- }
- assert_warning(/\A\z|:(?!#{__LINE__+1})\d+: #{warning}/o) {
- assert_equal([[], {}], obj.foo({}))
- }
- assert_equal(-1, obj.method(:foo).arity)
- parameters = obj.method(:foo).parameters
- assert_equal(:rest, parameters.dig(0, 0))
- assert_equal(:block, parameters.dig(1, 0))
- end
- end
-
- def test_argument_forwarding_with_leading_arguments
- obj = Object.new
- def obj.bar(*args, **kws, &block)
- if block
- block.call(args, kws)
- else
- [args, kws]
- end
- end
- obj.instance_eval('def foo(_a, ...) bar(...) end', __FILE__, __LINE__)
- assert_equal [[], {}], obj.foo(1)
- assert_equal [[2], {}], obj.foo(1, 2)
- assert_equal [[2, 3], {}], obj.foo(1, 2, 3)
- assert_equal [[], {a: 1}], obj.foo(1, a: 1)
- assert_equal [[2], {a: 1}], obj.foo(1, 2, a: 1)
- assert_equal [[2, 3], {a: 1}], obj.foo(1, 2, 3, a: 1)
- assert_equal [[2, 3], {a: 1}], obj.foo(1, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(...) bar(1, ...) end', __FILE__, __LINE__)
- assert_equal [[1], {}], obj.foo
- assert_equal [[1, 1], {}], obj.foo(1)
- assert_equal [[1, 1, 2], {}], obj.foo(1, 2)
- assert_equal [[1, 1, 2, 3], {}], obj.foo(1, 2, 3)
- assert_equal [[1], {a: 1}], obj.foo(a: 1)
- assert_equal [[1, 1], {a: 1}], obj.foo(1, a: 1)
- assert_equal [[1, 1, 2], {a: 1}], obj.foo(1, 2, a: 1)
- assert_equal [[1, 1, 2, 3], {a: 1}], obj.foo(1, 2, 3, a: 1)
- assert_equal [[1, 1, 2, 3], {a: 1}], obj.foo(1, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(a, ...) bar(a, ...) end', __FILE__, __LINE__)
- assert_equal [[4], {}], obj.foo(4)
- assert_equal [[4, 2], {}], obj.foo(4, 2)
- assert_equal [[4, 2, 3], {}], obj.foo(4, 2, 3)
- assert_equal [[4], {a: 1}], obj.foo(4, a: 1)
- assert_equal [[4, 2], {a: 1}], obj.foo(4, 2, a: 1)
- assert_equal [[4, 2, 3], {a: 1}], obj.foo(4, 2, 3, a: 1)
- assert_equal [[4, 2, 3], {a: 1}], obj.foo(4, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(_a, ...) bar(1, ...) end', __FILE__, __LINE__)
- assert_equal [[1], {}], obj.foo(4)
- assert_equal [[1, 2], {}], obj.foo(4, 2)
- assert_equal [[1, 2, 3], {}], obj.foo(4, 2, 3)
- assert_equal [[1], {a: 1}], obj.foo(4, a: 1)
- assert_equal [[1, 2], {a: 1}], obj.foo(4, 2, a: 1)
- assert_equal [[1, 2, 3], {a: 1}], obj.foo(4, 2, 3, a: 1)
- assert_equal [[1, 2, 3], {a: 1}], obj.foo(4, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(_a, _b, ...) bar(...) end', __FILE__, __LINE__)
- assert_equal [[], {}], obj.foo(4, 5)
- assert_equal [[2], {}], obj.foo(4, 5, 2)
- assert_equal [[2, 3], {}], obj.foo(4, 5, 2, 3)
- assert_equal [[], {a: 1}], obj.foo(4, 5, a: 1)
- assert_equal [[2], {a: 1}], obj.foo(4, 5, 2, a: 1)
- assert_equal [[2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1)
- assert_equal [[2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(_a, _b, ...) bar(1, ...) end', __FILE__, __LINE__)
- assert_equal [[1], {}], obj.foo(4, 5)
- assert_equal [[1, 2], {}], obj.foo(4, 5, 2)
- assert_equal [[1, 2, 3], {}], obj.foo(4, 5, 2, 3)
- assert_equal [[1], {a: 1}], obj.foo(4, 5, a: 1)
- assert_equal [[1, 2], {a: 1}], obj.foo(4, 5, 2, a: 1)
- assert_equal [[1, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1)
- assert_equal [[1, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(_a, ...) bar(1, 2, ...) end', __FILE__, __LINE__)
- assert_equal [[1, 2], {}], obj.foo(5)
- assert_equal [[1, 2, 5], {}], obj.foo(4, 5)
- assert_equal [[1, 2, 5, 2], {}], obj.foo(4, 5, 2)
- assert_equal [[1, 2, 5, 2, 3], {}], obj.foo(4, 5, 2, 3)
- assert_equal [[1, 2, 5], {a: 1}], obj.foo(4, 5, a: 1)
- assert_equal [[1, 2, 5, 2], {a: 1}], obj.foo(4, 5, 2, a: 1)
- assert_equal [[1, 2, 5, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1)
- assert_equal [[1, 2, 5, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(a, b, ...) bar(b, a, ...) end', __FILE__, __LINE__)
- assert_equal [[5, 4], {}], obj.foo(4, 5)
- assert_equal [[5, 4, 2], {}], obj.foo(4, 5, 2)
- assert_equal [[5, 4, 2, 3], {}], obj.foo(4, 5, 2, 3)
- assert_equal [[5, 4], {a: 1}], obj.foo(4, 5, a: 1)
- assert_equal [[5, 4, 2], {a: 1}], obj.foo(4, 5, 2, a: 1)
- assert_equal [[5, 4, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1)
- assert_equal [[5, 4, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(a, _b, ...) bar(a, ...) end', __FILE__, __LINE__)
- assert_equal [[4], {}], obj.foo(4, 5)
- assert_equal [[4, 2], {}], obj.foo(4, 5, 2)
- assert_equal [[4, 2, 3], {}], obj.foo(4, 5, 2, 3)
- assert_equal [[4], {a: 1}], obj.foo(4, 5, a: 1)
- assert_equal [[4, 2], {a: 1}], obj.foo(4, 5, 2, a: 1)
- assert_equal [[4, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1)
- assert_equal [[4, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1){|args, kws| [args, kws]}
-
- obj.singleton_class.send(:remove_method, :foo)
- obj.instance_eval('def foo(a, ...) bar(a, 1, ...) end', __FILE__, __LINE__)
- assert_equal [[4, 1], {}], obj.foo(4)
- assert_equal [[4, 1, 5], {}], obj.foo(4, 5)
- assert_equal [[4, 1, 5, 2], {}], obj.foo(4, 5, 2)
- assert_equal [[4, 1, 5, 2, 3], {}], obj.foo(4, 5, 2, 3)
- assert_equal [[4, 1, 5], {a: 1}], obj.foo(4, 5, a: 1)
- assert_equal [[4, 1, 5, 2], {a: 1}], obj.foo(4, 5, 2, a: 1)
- assert_equal [[4, 1, 5, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1)
- assert_equal [[4, 1, 5, 2, 3], {a: 1}], obj.foo(4, 5, 2, 3, a: 1){|args, kws| [args, kws]}
- end
-
private
def not_label(x) @result = x; @not_label ||= nil end
diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb
index 31c9cd7654..60037ab044 100644
--- a/test/ruby/test_system.rb
+++ b/test/ruby/test_system.rb
@@ -160,45 +160,4 @@ class TestSystem < Test::Unit::TestCase
assert_equal(true, system(tmpfilename), '[ruby-core:32745]')
}
end if File.executable?("/bin/sh")
-
- def test_system_exception
- ruby = EnvUtil.rubybin
- assert_nothing_raised do
- system('feature_14235', exception: false)
- end
- assert_nothing_raised do
- system(ruby, "-e", "abort", exception: false)
- end
- assert_nothing_raised do
- system("'#{ruby}' -e abort", exception: false)
- end
- assert_raise(Errno::ENOENT) do
- system('feature_14235', exception: true)
- end
- assert_raise_with_message(RuntimeError, /\ACommand failed with exit /) do
- system(ruby, "-e", "abort", exception: true)
- end
- assert_raise_with_message(RuntimeError, /\ACommand failed with exit /) do
- system("'#{ruby}' -e abort", exception: true)
- end
- end
-
- def test_system_exception_nonascii
- Dir.mktmpdir("ruby_script_tmp") do |tmpdir|
- name = "\u{30c6 30b9 30c8}"
- tmpfilename = "#{tmpdir}/#{name}.cmd"
- message = /#{name}\.cmd/
- assert_raise_with_message(Errno::ENOENT, message) do
- system(tmpfilename, exception: true)
- end
- open(tmpfilename, "w") {|f|
- f.print "@" if /mingw|mswin/ =~ RUBY_PLATFORM
- f.puts "exit 127"
- f.chmod(0755)
- }
- assert_raise_with_message(RuntimeError, message) do
- system(tmpfilename, exception: true)
- end
- end
- end
end
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 30a3cc784e..135d17237e 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -1,8 +1,6 @@
# -*- coding: us-ascii -*-
# frozen_string_literal: false
require 'test/unit'
-require "rbconfig/sizeof"
-require "timeout"
class TestThread < Test::Unit::TestCase
class Thread < ::Thread
@@ -29,12 +27,8 @@ class TestThread < Test::Unit::TestCase
end
def test_inspect
- line = __LINE__+1
th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start{}
- s = th.inspect
- assert_include(s, "::C\u{30b9 30ec 30c3 30c9}:")
- assert_include(s, " #{__FILE__}:#{line} ")
- assert_equal(s, th.to_s)
+ assert_match(/::C\u{30b9 30ec 30c3 30c9}:/, th.inspect)
ensure
th.join
end
@@ -172,8 +166,6 @@ class TestThread < Test::Unit::TestCase
t1.kill
t2.kill
assert_operator(c1, :>, c2, "[ruby-dev:33124]") # not guaranteed
- t1.join
- t2.join
end
def test_new
@@ -192,8 +184,8 @@ class TestThread < Test::Unit::TestCase
end
ensure
- t1&.kill&.join
- t2&.kill&.join
+ t1.kill if t1
+ t2.kill if t2
end
def test_new_symbol_proc
@@ -209,7 +201,7 @@ class TestThread < Test::Unit::TestCase
assert_nil(t.join(0.05))
ensure
- t&.kill&.join
+ t.kill if t
end
def test_join2
@@ -230,39 +222,9 @@ class TestThread < Test::Unit::TestCase
assert_equal(t1, t3.value)
ensure
- t1&.kill
- t2&.kill
- t3&.kill
- end
-
- { 'FIXNUM_MAX' => RbConfig::LIMITS['FIXNUM_MAX'],
- 'UINT64_MAX' => RbConfig::LIMITS['UINT64_MAX'],
- 'INFINITY' => Float::INFINITY
- }.each do |name, limit|
- define_method("test_join_limit_#{name}") do
- t = Thread.new {}
- assert_same t, t.join(limit), "limit=#{limit.inspect}"
- end
- end
-
- { 'minus_1' => -1,
- 'minus_0_1' => -0.1,
- 'FIXNUM_MIN' => RbConfig::LIMITS['FIXNUM_MIN'],
- 'INT64_MIN' => RbConfig::LIMITS['INT64_MIN'],
- 'minus_INFINITY' => -Float::INFINITY
- }.each do |name, limit|
- define_method("test_join_limit_negative_#{name}") do
- t = Thread.new { sleep }
- begin
- assert_nothing_raised(Timeout::Error) do
- Timeout.timeout(30) do
- assert_nil t.join(limit), "limit=#{limit.inspect}"
- end
- end
- ensure
- t.kill
- end
- end
+ t1.kill if t1
+ t2.kill if t2
+ t3.kill if t3
end
def test_kill_main_thread
@@ -309,14 +271,14 @@ class TestThread < Test::Unit::TestCase
s += 1
end
Thread.pass until t.stop?
- sleep 1 if RubyVM::MJIT.enabled? # t.stop? behaves unexpectedly with --jit-wait
assert_equal(1, s)
t.wakeup
Thread.pass while t.alive?
assert_equal(2, s)
assert_raise(ThreadError) { t.wakeup }
+
ensure
- t&.kill&.join
+ t.kill if t
end
def test_stop
@@ -437,7 +399,6 @@ class TestThread < Test::Unit::TestCase
}
assert_equal(false, q1.pop)
Thread.pass while th.alive?
- assert_raise(RuntimeError) { th.join }
}
assert_warn(/report 2/, "exception should be reported when true") {
@@ -447,7 +408,6 @@ class TestThread < Test::Unit::TestCase
}
assert_equal(true, q1.pop)
Thread.pass while th.alive?
- assert_raise(RuntimeError) { th.join }
}
assert_warn("", "the global flag should not affect already started threads") {
@@ -460,7 +420,6 @@ class TestThread < Test::Unit::TestCase
q2.push(Thread.report_on_exception = true)
assert_equal(false, q1.pop)
Thread.pass while th.alive?
- assert_raise(RuntimeError) { th.join }
}
assert_warn(/report 4/, "should defaults to the global flag at the start") {
@@ -471,7 +430,6 @@ class TestThread < Test::Unit::TestCase
}
assert_equal(true, q1.pop)
Thread.pass while th.alive?
- assert_raise(RuntimeError) { th.join }
}
assert_warn(/report 5/, "should first report and then raise with report_on_exception + abort_on_exception") {
@@ -485,7 +443,6 @@ class TestThread < Test::Unit::TestCase
q2.push(true)
Thread.pass while th.alive?
}
- assert_raise(RuntimeError) { th.join }
}
end;
end
@@ -513,10 +470,11 @@ class TestThread < Test::Unit::TestCase
es1 = e.status
es2 = e.stop?
assert_equal(["run", false], [es1, es2])
- assert_raise(RuntimeError) { a.join }
+
ensure
- b&.kill&.join
- c&.join
+ a.kill if a
+ b.kill if b
+ c.kill if c
end
def test_switch_while_busy_loop
@@ -534,7 +492,24 @@ class TestThread < Test::Unit::TestCase
end
assert(!flag, bug1402)
ensure
- waiter&.kill&.join
+ waiter.kill.join
+ end
+
+ def test_safe_level
+ ok = false
+ t = Thread.new do
+ EnvUtil.suppress_warning do
+ $SAFE = 1
+ end
+ ok = true
+ sleep
+ end
+ Thread.pass until ok
+ assert_equal(0, Thread.current.safe_level)
+ assert_equal(1, t.safe_level)
+
+ ensure
+ t.kill if t
end
def test_thread_local
@@ -554,7 +529,7 @@ class TestThread < Test::Unit::TestCase
assert_equal([:foo, :bar, :baz].sort, t.keys.sort)
ensure
- t&.kill&.join
+ t.kill if t
end
def test_thread_local_fetch
@@ -586,7 +561,7 @@ class TestThread < Test::Unit::TestCase
assert_equal(:qux, e.key)
assert_equal(t, e.receiver)
ensure
- t&.kill&.join
+ t.kill if t
end
def test_thread_local_security
@@ -616,8 +591,7 @@ class TestThread < Test::Unit::TestCase
end
Thread.pass until t.stop?
assert_predicate(t, :alive?)
- ensure
- t&.kill
+ t.kill
end
def test_mutex_deadlock
@@ -795,15 +769,14 @@ class TestThread < Test::Unit::TestCase
end
def test_handle_interrupt_blocking
- r = nil
- q = Queue.new
- e = Class.new(Exception)
+ r=:ng
+ e=Class.new(Exception)
th_s = Thread.current
- th = Thread.start {
+ th = Thread.start{
assert_raise(RuntimeError) {
Thread.handle_interrupt(Object => :on_blocking){
begin
- q.pop
+ Thread.pass until r == :wait
Thread.current.raise RuntimeError, "will raise in sleep"
r = :ok
sleep
@@ -813,26 +786,25 @@ class TestThread < Test::Unit::TestCase
}
}
}
- assert_raise(e) {q << true; th.join}
- assert_equal(:ok, r)
+ assert_raise(e) {r = :wait; sleep 0.2}
+ th.join
+ assert_equal(:ok,r)
end
def test_handle_interrupt_and_io
assert_in_out_err([], <<-INPUT, %w(ok), [])
th_waiting = true
- q = Queue.new
t = Thread.new {
Thread.current.report_on_exception = false
Thread.handle_interrupt(RuntimeError => :on_blocking) {
- q << true
nil while th_waiting
# async interrupt should be raised _before_ writing puts arguments
puts "ng"
}
}
- q.pop
+ Thread.pass while t.stop?
t.raise RuntimeError
th_waiting = false
t.join rescue nil
@@ -871,15 +843,15 @@ class TestThread < Test::Unit::TestCase
begin
begin
Thread.pass until done
- rescue
+ rescue => e
q.push :ng1
end
begin
Thread.handle_interrupt(Object => :immediate){} if Thread.pending_interrupt?
- rescue RuntimeError
+ rescue RuntimeError => e
q.push :ok
end
- rescue
+ rescue => e
q.push :ng2
ensure
q.push :ng3
@@ -947,21 +919,15 @@ _eom
def test_thread_timer_and_interrupt
bug5757 = '[ruby-dev:44985]'
pid = nil
- cmd = 'Signal.trap(:INT, "DEFAULT"); pipe=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; pipe[0].read'
+ cmd = 'Signal.trap(:INT, "DEFAULT"); r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read'
opt = {}
opt[:new_pgroup] = true if /mswin|mingw/ =~ RUBY_PLATFORM
- s, t, _err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true, **opt) do |in_p, out_p, err_p, cpid|
- assert IO.select([out_p], nil, nil, 10), 'subprocess not ready'
+ s, t, _err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true, opt) do |in_p, out_p, err_p, cpid|
out_p.gets
pid = cpid
t0 = Time.now.to_f
Process.kill(:SIGINT, pid)
- begin
- Timeout.timeout(10) { Process.wait(pid) }
- rescue Timeout::Error
- EnvUtil.terminate(pid)
- raise
- end
+ Process.wait(pid)
t1 = Time.now.to_f
[$?, t1 - t0, err_p.read]
end
@@ -1106,7 +1072,7 @@ q.pop
Thread.pass until mutex.locked?
assert_equal(mutex.owned?, false)
ensure
- th&.kill
+ th.kill if th
end
end
@@ -1150,7 +1116,6 @@ q.pop
"0 thread_machine_stack_size")
assert_operator(h_default[:thread_machine_stack_size], :<=, h_large[:thread_machine_stack_size],
"large thread_machine_stack_size")
- assert_equal("ok", invoke_rec('print :ok', 1024 * 1024 * 100, nil, false))
end
def test_vm_machine_stack_size
@@ -1179,10 +1144,12 @@ q.pop
bug8433 = '[ruby-core:55102] [Bug #8433]'
mutex = Thread::Mutex.new
+ flag = false
mutex.lock
th = Thread.new do
mutex.synchronize do
+ flag = true
sleep
end
end
@@ -1232,42 +1199,6 @@ q.pop
end
end if Process.respond_to?(:fork)
- def test_fork_while_parent_locked
- skip 'needs fork' unless Process.respond_to?(:fork)
- m = Thread::Mutex.new
- nr = 1
- thrs = []
- m.synchronize do
- thrs = nr.times.map { Thread.new { m.synchronize {} } }
- thrs.each { Thread.pass }
- pid = fork do
- m.locked? or exit!(2)
- thrs = nr.times.map { Thread.new { m.synchronize {} } }
- m.unlock
- thrs.each { |t| t.join(1) == t or exit!(1) }
- exit!(0)
- end
- _, st = Process.waitpid2(pid)
- assert_predicate st, :success?, '[ruby-core:90312] [Bug #15383]'
- end
- thrs.each { |t| assert_same t, t.join(1) }
- end
-
- def test_fork_while_mutex_locked_by_forker
- skip 'needs fork' unless Process.respond_to?(:fork)
- m = Mutex.new
- m.synchronize do
- pid = fork do
- exit!(2) unless m.locked?
- m.unlock rescue exit!(3)
- m.synchronize {} rescue exit!(4)
- exit!(0)
- end
- _, st = Timeout.timeout(30) { Process.waitpid2(pid) }
- assert_predicate st, :success?, '[ruby-core:90595] [Bug #15430]'
- end
- end
-
def test_subclass_no_initialize
t = Module.new do
break eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")
@@ -1322,18 +1253,12 @@ q.pop
end
def test_thread_interrupt_for_killed_thread
- opts = { timeout: 5, timeout_error: nil }
-
- # prevent SIGABRT from slow shutdown with MJIT
- opts[:reprieve] = 3 if RubyVM::MJIT.enabled?
-
- assert_normal_exit(<<-_end, '[Bug #8996]', **opts)
+ assert_normal_exit(<<-_end, '[Bug #8996]', timeout: 5, timeout_error: nil)
Thread.report_on_exception = false
trap(:TERM){exit}
while true
t = Thread.new{sleep 0}
t.raise Interrupt
- Thread.pass # allow t to finish
end
_end
end
@@ -1343,7 +1268,7 @@ q.pop
skip "can't trap a signal from another process on Windows"
# opt = {new_pgroup: true}
end
- assert_separately([], "#{<<~"{#"}\n#{<<~'};'}", timeout: 120)
+ assert_separately([], "#{<<~"{#"}\n#{<<~'};'}")
{#
n = 1000
sig = :INT
diff --git a/test/ruby/test_thread_cv.rb b/test/ruby/test_thread_cv.rb
deleted file mode 100644
index 38bcc3b8fa..0000000000
--- a/test/ruby/test_thread_cv.rb
+++ /dev/null
@@ -1,245 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-require 'tmpdir'
-
-class TestThreadConditionVariable < Test::Unit::TestCase
- ConditionVariable = Thread::ConditionVariable
- Mutex = Thread::Mutex
-
- def test_initialized
- assert_raise(TypeError) {
- ConditionVariable.allocate.wait(nil)
- }
- end
-
- def test_condvar_signal_and_wait
- mutex = Mutex.new
- condvar = ConditionVariable.new
- result = []
- mutex.synchronize do
- t = Thread.new do
- mutex.synchronize do
- result << 1
- condvar.signal
- end
- end
-
- result << 0
- condvar.wait(mutex)
- result << 2
- t.join
- end
- assert_equal([0, 1, 2], result)
- end
-
- def test_condvar_wait_exception_handling
- # Calling wait in the only thread running should raise a ThreadError of
- # 'stopping only thread'
- mutex = Mutex.new
- condvar = ConditionVariable.new
-
- locked = false
- thread = Thread.new do
- Thread.current.abort_on_exception = false
- mutex.synchronize do
- assert_raise(Interrupt) {
- condvar.wait(mutex)
- }
- locked = mutex.locked?
- end
- end
-
- until thread.stop?
- sleep(0.1)
- end
-
- thread.raise Interrupt, "interrupt a dead condition variable"
- thread.join
- assert(locked)
- end
-
- def test_condvar_wait_and_broadcast
- nr_threads = 3
- threads = Array.new
- mutex = Mutex.new
- condvar = ConditionVariable.new
- result = []
-
- nr_threads.times do |i|
- threads[i] = Thread.new do
- mutex.synchronize do
- result << "C1"
- condvar.wait mutex
- result << "C2"
- end
- end
- end
- sleep 0.1
- mutex.synchronize do
- result << "P1"
- condvar.broadcast
- result << "P2"
- end
- Timeout.timeout(5) do
- nr_threads.times do |i|
- threads[i].join
- end
- end
-
- assert_equal ["C1", "C1", "C1", "P1", "P2", "C2", "C2", "C2"], result
- end
-
- def test_condvar_wait_deadlock
- assert_in_out_err([], <<-INPUT, /\Afatal\nNo live threads left\. Deadlock/, [])
- mutex = Mutex.new
- cv = ConditionVariable.new
-
- klass = nil
- mesg = nil
- begin
- mutex.lock
- cv.wait mutex
- mutex.unlock
- rescue Exception => e
- klass = e.class
- mesg = e.message
- end
- puts klass
- print mesg
-INPUT
- end
-
- def test_condvar_wait_deadlock_2
- nr_threads = 3
- threads = Array.new
- mutex = Mutex.new
- condvar = ConditionVariable.new
-
- nr_threads.times do |i|
- if (i != 0)
- mutex.unlock
- end
- threads[i] = Thread.new do
- mutex.synchronize do
- condvar.wait mutex
- end
- end
- mutex.lock
- end
-
- assert_raise(Timeout::Error) do
- Timeout.timeout(0.1) { condvar.wait mutex }
- end
- mutex.unlock
- threads.each(&:kill)
- threads.each(&:join)
- end
-
- def test_condvar_timed_wait
- mutex = Mutex.new
- condvar = ConditionVariable.new
- timeout = 0.3
- locked = false
-
- t0 = Time.now
- mutex.synchronize do
- begin
- condvar.wait(mutex, timeout)
- ensure
- locked = mutex.locked?
- end
- end
- t1 = Time.now
- t = t1-t0
-
- assert_operator(timeout*0.9, :<, t)
- assert(locked)
- end
-
- def test_condvar_nolock
- mutex = Mutex.new
- condvar = ConditionVariable.new
-
- assert_raise(ThreadError) {condvar.wait(mutex)}
- end
-
- def test_condvar_nolock_2
- mutex = Mutex.new
- condvar = ConditionVariable.new
-
- Thread.new do
- assert_raise(ThreadError) {condvar.wait(mutex)}
- end.join
- end
-
- def test_condvar_nolock_3
- mutex = Mutex.new
- condvar = ConditionVariable.new
-
- Thread.new do
- assert_raise(ThreadError) {condvar.wait(mutex, 0.1)}
- end.join
- end
-
- def test_condvar_empty_signal
- mutex = Mutex.new
- condvar = ConditionVariable.new
-
- assert_nothing_raised(Exception) { mutex.synchronize {condvar.signal} }
- end
-
- def test_condvar_empty_broadcast
- mutex = Mutex.new
- condvar = ConditionVariable.new
-
- assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} }
- end
-
- def test_dup
- bug9440 = '[ruby-core:59961] [Bug #9440]'
- condvar = ConditionVariable.new
- assert_raise(NoMethodError, bug9440) do
- condvar.dup
- end
- end
-
- (DumpableCV = ConditionVariable.dup).class_eval {remove_method :marshal_dump}
-
- def test_dump
- bug9674 = '[ruby-core:61677] [Bug #9674]'
- condvar = ConditionVariable.new
- assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do
- Marshal.dump(condvar)
- end
-
- condvar = DumpableCV.new
- assert_raise(TypeError, bug9674) do
- Marshal.dump(condvar)
- end
- end
-
- def test_condvar_fork
- mutex = Mutex.new
- condvar = ConditionVariable.new
- thrs = (1..10).map do
- Thread.new { mutex.synchronize { condvar.wait(mutex) } }
- end
- thrs.each { 3.times { Thread.pass } }
- pid = fork do
- th = Thread.new do
- mutex.synchronize { condvar.wait(mutex) }
- :ok
- end
- until th.join(0.01)
- mutex.synchronize { condvar.broadcast }
- end
- exit!(th.value == :ok ? 0 : 1)
- end
- _, s = Process.waitpid2(pid)
- assert_predicate s, :success?, 'no segfault [ruby-core:86316] [Bug #14634]'
- until thrs.empty?
- mutex.synchronize { condvar.broadcast }
- thrs.delete_if { |t| t.join(0.01) }
- end
- end if Process.respond_to?(:fork)
-end
diff --git a/test/ruby/test_thread_queue.rb b/test/ruby/test_thread_queue.rb
deleted file mode 100644
index 41e6865ed4..0000000000
--- a/test/ruby/test_thread_queue.rb
+++ /dev/null
@@ -1,630 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-require 'tmpdir'
-require 'timeout'
-
-class TestThreadQueue < Test::Unit::TestCase
- Queue = Thread::Queue
- SizedQueue = Thread::SizedQueue
-
- def test_queue_initialized
- assert_raise(TypeError) {
- Queue.allocate.push(nil)
- }
- end
-
- def test_sized_queue_initialized
- assert_raise(TypeError) {
- SizedQueue.allocate.push(nil)
- }
- end
-
- def test_queue
- grind(5, 1000, 15, Queue)
- end
-
- def test_sized_queue
- grind(5, 1000, 15, SizedQueue, 1000)
- end
-
- def grind(num_threads, num_objects, num_iterations, klass, *args)
- from_workers = klass.new(*args)
- to_workers = klass.new(*args)
-
- workers = (1..num_threads).map {
- Thread.new {
- while object = to_workers.pop
- from_workers.push object
- end
- }
- }
-
- Thread.new {
- num_iterations.times {
- num_objects.times { to_workers.push 99 }
- num_objects.times { from_workers.pop }
- }
- }.join
-
- # close the queue the old way to test for backwards-compatibility
- num_threads.times { to_workers.push nil }
- workers.each { |t| t.join }
-
- assert_equal 0, from_workers.size
- assert_equal 0, to_workers.size
- end
-
- def test_sized_queue_initialize
- q = SizedQueue.new(1)
- assert_equal 1, q.max
- assert_raise(ArgumentError) { SizedQueue.new(0) }
- assert_raise(ArgumentError) { SizedQueue.new(-1) }
- end
-
- def test_sized_queue_assign_max
- q = SizedQueue.new(2)
- assert_equal(2, q.max)
- q.max = 1
- assert_equal(1, q.max)
- assert_raise(ArgumentError) { q.max = 0 }
- assert_equal(1, q.max)
- assert_raise(ArgumentError) { q.max = -1 }
- assert_equal(1, q.max)
-
- before = q.max
- q.max.times { q << 1 }
- t1 = Thread.new { q << 1 }
- sleep 0.01 until t1.stop?
- q.max = q.max + 1
- assert_equal before + 1, q.max
- ensure
- t1.join if t1
- end
-
- def test_queue_pop_interrupt
- q = Queue.new
- t1 = Thread.new { q.pop }
- sleep 0.01 until t1.stop?
- t1.kill.join
- assert_equal(0, q.num_waiting)
- end
-
- def test_queue_pop_non_block
- q = Queue.new
- assert_raise_with_message(ThreadError, /empty/) do
- q.pop(true)
- end
- end
-
- def test_sized_queue_pop_interrupt
- q = SizedQueue.new(1)
- t1 = Thread.new { q.pop }
- sleep 0.01 until t1.stop?
- t1.kill.join
- assert_equal(0, q.num_waiting)
- end
-
- def test_sized_queue_pop_non_block
- q = SizedQueue.new(1)
- assert_raise_with_message(ThreadError, /empty/) do
- q.pop(true)
- end
- end
-
- def test_sized_queue_push_interrupt
- q = SizedQueue.new(1)
- q.push(1)
- assert_raise_with_message(ThreadError, /full/) do
- q.push(2, true)
- end
- end
-
- def test_sized_queue_push_non_block
- q = SizedQueue.new(1)
- q.push(1)
- t1 = Thread.new { q.push(2) }
- sleep 0.01 until t1.stop?
- t1.kill.join
- assert_equal(0, q.num_waiting)
- end
-
- def test_thr_kill
- bug5343 = '[ruby-core:39634]'
- Dir.mktmpdir {|d|
- timeout = 60
- total_count = 250
- begin
- assert_normal_exit(<<-"_eom", bug5343, **{:timeout => timeout, :chdir=>d})
- #{total_count}.times do |i|
- open("test_thr_kill_count", "w") {|f| f.puts i }
- queue = Queue.new
- r, w = IO.pipe
- th = Thread.start {
- queue.push(nil)
- r.read 1
- }
- queue.pop
- th.kill
- th.join
- end
- _eom
- rescue Timeout::Error
- count = File.read("#{d}/test_thr_kill_count").to_i
- flunk "only #{count}/#{total_count} done in #{timeout} seconds."
- end
- }
- end
-
- def test_queue_push_return_value
- q = Queue.new
- retval = q.push(1)
- assert_same q, retval
- end
-
- def test_queue_clear_return_value
- q = Queue.new
- retval = q.clear
- assert_same q, retval
- end
-
- def test_sized_queue_clear
- # Fill queue, then test that SizedQueue#clear wakes up all waiting threads
- sq = SizedQueue.new(2)
- 2.times { sq << 1 }
-
- t1 = Thread.new do
- sq << 1
- end
-
- t2 = Thread.new do
- sq << 1
- end
-
- t3 = Thread.new do
- Thread.pass
- sq.clear
- end
-
- [t3, t2, t1].each(&:join)
- assert_equal sq.length, 2
- end
-
- def test_sized_queue_push_return_value
- q = SizedQueue.new(1)
- retval = q.push(1)
- assert_same q, retval
- end
-
- def test_sized_queue_clear_return_value
- q = SizedQueue.new(1)
- retval = q.clear
- assert_same q, retval
- end
-
- def test_sized_queue_throttle
- q = SizedQueue.new(1)
- i = 0
- consumer = Thread.new do
- while q.pop
- i += 1
- Thread.pass
- end
- end
- nprod = 4
- npush = 100
-
- producer = nprod.times.map do
- Thread.new do
- npush.times { q.push(true) }
- end
- end
- producer.each(&:join)
- q.push(nil)
- consumer.join
- assert_equal(nprod * npush, i)
- end
-
- def test_queue_thread_raise
- q = Queue.new
- th1 = Thread.new do
- begin
- q.pop
- rescue RuntimeError
- sleep
- end
- end
- th2 = Thread.new do
- sleep 0.1
- q.pop
- end
- sleep 0.1
- th1.raise
- sleep 0.1
- q << :s
- assert_nothing_raised(Timeout::Error) do
- Timeout.timeout(1) { th2.join }
- end
- ensure
- [th1, th2].each do |th|
- if th and th.alive?
- th.wakeup
- th.join
- end
- end
- end
-
- def test_dup
- bug9440 = '[ruby-core:59961] [Bug #9440]'
- q = Queue.new
- assert_raise(NoMethodError, bug9440) do
- q.dup
- end
- end
-
- (DumpableQueue = Queue.dup).class_eval {remove_method :marshal_dump}
-
- def test_dump
- bug9674 = '[ruby-core:61677] [Bug #9674]'
- q = Queue.new
- assert_raise_with_message(TypeError, /#{Queue}/, bug9674) do
- Marshal.dump(q)
- end
-
- sq = SizedQueue.new(1)
- assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do
- Marshal.dump(sq)
- end
-
- q = DumpableQueue.new
- assert_raise(TypeError, bug9674) do
- Marshal.dump(q)
- end
- end
-
- def test_close
- [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
- q = qcreate.call
- assert_equal false, q.closed?
- q << :something
- assert_equal q, q.close
- assert q.closed?
- assert_raise_with_message(ClosedQueueError, /closed/){q << :nothing}
- assert_equal q.pop, :something
- assert_nil q.pop
- assert_nil q.pop
- # non-blocking
- assert_raise_with_message(ThreadError, /queue empty/){q.pop(non_block=true)}
- end
- end
-
- # test that waiting producers are woken up on close
- def close_wakeup( num_items, num_threads, &qcreate )
- raise "This test won't work with num_items(#{num_items}) >= num_threads(#{num_threads})" if num_items >= num_threads
-
- # create the Queue
- q = yield
- threads = num_threads.times.map{Thread.new{q.pop}}
- num_items.times{|i| q << i}
-
- # wait until queue empty
- (Thread.pass; sleep 0.01) until q.size == 0
-
- # close the queue so remaining threads will wake up
- q.close
-
- # wait for them to go away
- Thread.pass until threads.all?{|thr| thr.status == false}
-
- # check that they've gone away. Convert nil to -1 so we can sort and do the comparison
- expected_values = [-1] * (num_threads - num_items) + num_items.times.to_a
- assert_equal expected_values, threads.map{|thr| thr.value || -1 }.sort
- end
-
- def test_queue_close_wakeup
- close_wakeup(15, 18){Queue.new}
- end
-
- def test_size_queue_close_wakeup
- close_wakeup(5, 8){SizedQueue.new 9}
- end
-
- def test_sized_queue_one_closed_interrupt
- q = SizedQueue.new 1
- q << :one
- t1 = Thread.new {
- Thread.current.report_on_exception = false
- q << :two
- }
- sleep 0.01 until t1.stop?
- q.close
- assert_raise(ClosedQueueError) {t1.join}
-
- assert_equal 1, q.size
- assert_equal :one, q.pop
- assert q.empty?, "queue not empty"
- end
-
- # make sure that shutdown state is handled properly by empty? for the non-blocking case
- def test_empty_non_blocking
- q = SizedQueue.new 3
- 3.times{|i| q << i}
-
- # these all block cos the queue is full
- prod_threads = 4.times.map {|i|
- Thread.new {
- Thread.current.report_on_exception = false
- q << 3+i
- }
- }
- sleep 0.01 until prod_threads.all?{|thr| thr.stop?}
-
- items = []
- # sometimes empty? is false but pop will raise ThreadError('empty'),
- # meaning a value is not immediately available but will be soon.
- while prod_threads.any?(&:alive?) or !q.empty?
- items << q.pop(true) rescue nil
- end
- assert_join_threads(prod_threads)
- items.compact!
-
- assert_equal 7.times.to_a, items.sort
- assert q.empty?
- end
-
- def test_sized_queue_closed_push_non_blocking
- q = SizedQueue.new 7
- q.close
- assert_raise_with_message(ClosedQueueError, /queue closed/){q.push(non_block=true)}
- end
-
- def test_blocked_pushers
- q = SizedQueue.new 3
- prod_threads = 6.times.map do |i|
- thr = Thread.new{
- Thread.current.report_on_exception = false
- q << i
- }
- thr[:pc] = i
- thr
- end
-
- # wait until some producer threads have finished, and the other 3 are blocked
- sleep 0.01 while prod_threads.reject{|t| t.status}.count < 3
- # this would ensure that all producer threads call push before close
- # sleep 0.01 while prod_threads.select{|t| t.status == 'sleep'}.count < 3
- q.close
-
- # more than prod_threads
- cons_threads = 10.times.map do |i|
- thr = Thread.new{q.pop}; thr[:pc] = i; thr
- end
-
- # values that came from the queue
- popped_values = cons_threads.map &:value
-
- # wait untl all threads have finished
- sleep 0.01 until prod_threads.find_all{|t| t.status}.count == 0
-
- # pick only the producer threads that got in before close
- successful_prod_threads = prod_threads.reject{|thr| thr.status == nil}
- assert_nothing_raised{ successful_prod_threads.map(&:value) }
-
- # the producer threads that tried to push after q.close should all fail
- unsuccessful_prod_threads = prod_threads - successful_prod_threads
- unsuccessful_prod_threads.each do |thr|
- assert_raise(ClosedQueueError){ thr.value }
- end
-
- assert_equal cons_threads.size, popped_values.size
- assert_equal 0, q.size
-
- # check that consumer threads with values match producers that called push before close
- assert_equal successful_prod_threads.map{|thr| thr[:pc]}, popped_values.compact.sort
- assert_nil q.pop
- end
-
- def test_deny_pushers
- [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
- q = qcreate[]
- synq = Queue.new
- prod_threads = 20.times.map do |i|
- Thread.new {
- synq.pop
- assert_raise(ClosedQueueError) {
- q << i
- }
- }
- end
- q.close
- synq.close # start producer threads
-
- prod_threads.each(&:join)
- end
- end
-
- # size should account for waiting pushers during shutdown
- def sized_queue_size_close
- q = SizedQueue.new 4
- 4.times{|i| q << i}
- Thread.new{ q << 5 }
- Thread.new{ q << 6 }
- assert_equal 4, q.size
- assert_equal 4, q.items
- q.close
- assert_equal 6, q.size
- assert_equal 4, q.items
- end
-
- def test_blocked_pushers_empty
- q = SizedQueue.new 3
- prod_threads = 6.times.map do |i|
- Thread.new{
- Thread.current.report_on_exception = false
- q << i
- }
- end
-
- # this ensures that all producer threads call push before close
- sleep 0.01 while prod_threads.select{|t| t.status == 'sleep'}.count < 3
- q.close
-
- ary = []
- until q.empty?
- ary << q.pop
- end
- assert_equal 0, q.size
-
- assert_equal 3, ary.size
- ary.each{|e| assert [0,1,2,3,4,5].include?(e)}
- assert_nil q.pop
-
- prod_threads.each{|t|
- begin
- t.join
- rescue
- end
- }
- end
-
- # test thread wakeup on one-element SizedQueue with close
- def test_one_element_sized_queue
- q = SizedQueue.new 1
- t = Thread.new{ q.pop }
- q.close
- assert_nil t.value
- end
-
- def test_close_twice
- [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
- q = qcreate[]
- q.close
- assert_nothing_raised(ClosedQueueError){q.close}
- end
- end
-
- def test_queue_close_multi_multi
- q = SizedQueue.new rand(800..1200)
-
- count_items = rand(3000..5000)
- count_producers = rand(10..20)
-
- producers = count_producers.times.map do
- Thread.new do
- sleep(rand / 100)
- count_items.times{|i| q << [i,"#{i} for #{Thread.current.inspect}"]}
- end
- end
-
- consumers = rand(7..12).times.map do
- Thread.new do
- count = 0
- while e = q.pop
- i, st = e
- count += 1 if i.is_a?(Integer) && st.is_a?(String)
- end
- count
- end
- end
-
- # No dead or finished threads, give up to 10 seconds to start running
- t = Time.now
- Thread.pass until Time.now - t > 10 || (consumers + producers).all?{|thr| thr.status =~ /\A(?:run|sleep)\z/}
-
- assert (consumers + producers).all?{|thr| thr.status =~ /\A(?:run|sleep)\z/}, 'no threads running'
-
- # just exercising the concurrency of the support methods.
- counter = Thread.new do
- until q.closed? && q.empty?
- raise if q.size > q.max
- # otherwise this exercise causes too much contention on the lock
- sleep 0.01
- end
- end
-
- producers.each &:join
- q.close
-
- # results not randomly distributed. Not sure why.
- # consumers.map{|thr| thr.value}.each do |x|
- # assert_not_equal 0, x
- # end
-
- all_items_count = consumers.map{|thr| thr.value}.inject(:+)
- assert_equal count_items * count_producers, all_items_count
-
- # don't leak this thread
- assert_nothing_raised{counter.join}
- end
-
- def test_queue_with_trap
- if ENV['APPVEYOR'] == 'True' && RUBY_PLATFORM.match?(/mswin/)
- skip 'This test fails too often on AppVeyor vs140'
- end
- if RUBY_PLATFORM.match?(/mingw/)
- skip 'This test fails too often on MinGW'
- end
-
- assert_in_out_err([], <<-INPUT, %w(INT INT exit), [])
- q = Queue.new
- trap(:INT){
- q.push 'INT'
- }
- Thread.new{
- loop{
- Process.kill :INT, $$
- }
- }
- puts q.pop
- puts q.pop
- puts 'exit'
- INPUT
- end
-
- def test_fork_while_queue_waiting
- q = Queue.new
- sq = SizedQueue.new(1)
- thq = Thread.new { q.pop }
- thsq = Thread.new { sq.pop }
- Thread.pass until thq.stop? && thsq.stop?
-
- pid = fork do
- exit!(1) if q.num_waiting != 0
- exit!(2) if sq.num_waiting != 0
- exit!(6) unless q.empty?
- exit!(7) unless sq.empty?
- q.push :child_q
- sq.push :child_sq
- exit!(3) if q.pop != :child_q
- exit!(4) if sq.pop != :child_sq
- exit!(0)
- end
- _, s = Process.waitpid2(pid)
- assert_predicate s, :success?, 'no segfault [ruby-core:86316] [Bug #14634]'
-
- q.push :thq
- sq.push :thsq
- assert_equal :thq, thq.value
- assert_equal :thsq, thsq.value
-
- sq.push(1)
- th = Thread.new { q.pop; sq.pop }
- thsq = Thread.new { sq.push(2) }
- Thread.pass until th.stop? && thsq.stop?
- pid = fork do
- exit!(1) if q.num_waiting != 0
- exit!(2) if sq.num_waiting != 0
- exit!(3) unless q.empty?
- exit!(4) if sq.empty?
- exit!(5) if sq.pop != 1
- exit!(0)
- end
- _, s = Process.waitpid2(pid)
- assert_predicate s, :success?, 'no segfault [ruby-core:86316] [Bug #14634]'
-
- assert_predicate thsq, :stop?
- assert_equal 1, sq.pop
- assert_same sq, thsq.value
- q.push('restart th')
- assert_equal 2, th.value
- end if Process.respond_to?(:fork)
-end
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 1749d92a17..5ddcc9dcfe 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -173,7 +173,7 @@ class TestTime < Test::Unit::TestCase
assert_equal(10000, Time.at(0.00001).nsec)
assert_equal(3000, Time.at(0.000003).nsec)
assert_equal(200, Time.at(0.0000002r).nsec)
- assert_in_delta(200, Time.at(0.0000002).nsec, 1, "should be within FP error")
+ assert_equal(199, Time.at(0.0000002).nsec)
assert_equal(10, Time.at(0.00000001).nsec)
assert_equal(1, Time.at(0.000000001).nsec)
@@ -375,16 +375,6 @@ class TestTime < Test::Unit::TestCase
end
end
- def test_marshal_distant_past
- assert_marshal_roundtrip(Time.utc(1890, 1, 1))
- assert_marshal_roundtrip(Time.utc(-4.5e9, 1, 1))
- end
-
- def test_marshal_distant_future
- assert_marshal_roundtrip(Time.utc(30000, 1, 1))
- assert_marshal_roundtrip(Time.utc(5.67e9, 4, 8))
- end
-
def test_at3
t2000 = get_t2000
assert_equal(t2000, Time.at(t2000))
@@ -553,30 +543,6 @@ class TestTime < Test::Unit::TestCase
assert_equal(Time.at(946684800).getlocal.to_s, Time.at(946684800).to_s)
end
- def test_inspect
- t2000 = get_t2000
- assert_equal("2000-01-01 00:00:00 UTC", t2000.inspect)
- assert_equal(Encoding::US_ASCII, t2000.inspect.encoding)
- assert_kind_of(String, Time.at(946684800).getlocal.inspect)
- assert_equal(Time.at(946684800).getlocal.inspect, Time.at(946684800).inspect)
-
- t2000 = get_t2000 + 1/10r
- assert_equal("2000-01-01 00:00:00.1 UTC", t2000.inspect)
- t2000 = get_t2000 + 1/1000000000r
- assert_equal("2000-01-01 00:00:00.000000001 UTC", t2000.inspect)
- t2000 = get_t2000 + 1/10000000000r
- assert_equal("2000-01-01 00:00:00 1/10000000000 UTC", t2000.inspect)
- t2000 = get_t2000 + 0.1
- assert_equal("2000-01-01 00:00:00 3602879701896397/36028797018963968 UTC", t2000.inspect)
-
- t2000 = get_t2000
- t2000 = t2000.localtime(9*3600)
- assert_equal("2000-01-01 09:00:00 +0900", t2000.inspect)
-
- t2000 = get_t2000.localtime(9*3600) + 1/10r
- assert_equal("2000-01-01 09:00:00.1 +0900", t2000.inspect)
- end
-
def assert_zone_encoding(time)
zone = time.zone
assert_predicate(zone, :valid_encoding?)
@@ -590,10 +556,6 @@ class TestTime < Test::Unit::TestCase
def test_zone
assert_zone_encoding Time.now
- t = Time.now.utc
- assert_equal("UTC", t.zone)
- assert_nil(t.getlocal(0).zone)
- assert_nil(t.getlocal("+02:00").zone)
end
def test_plus_minus_succ
@@ -885,13 +847,6 @@ class TestTime < Test::Unit::TestCase
assert_equal(8192, Time.now.strftime('%8192z').size)
end
- def test_strftime_wide_precision
- t2000 = get_t2000
- s = t2000.strftime("%28c")
- assert_equal(28, s.size)
- assert_equal(t2000.strftime("%c"), s.strip)
- end
-
def test_strfimte_zoneoffset
t2000 = get_t2000
t = t2000.getlocal("+09:00:00")
@@ -1011,58 +966,6 @@ class TestTime < Test::Unit::TestCase
}
end
- def test_floor
- t = Time.utc(1999,12,31, 23,59,59)
- t2 = (t+0.4).floor
- assert_equal([59,59,23, 31,12,1999, 5,365,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+0.49).floor
- assert_equal([59,59,23, 31,12,1999, 5,365,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+0.5).floor
- assert_equal([59,59,23, 31,12,1999, 5,365,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+1.4).floor
- assert_equal([0,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+1.49).floor
- assert_equal([0,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+1.5).floor
- assert_equal([0,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
-
- t2 = (t+0.123456789).floor(4)
- assert_equal([59,59,23, 31,12,1999, 5,365,false,"UTC"], t2.to_a)
- assert_equal(Rational(1234,10000), t2.subsec)
- end
-
- def test_ceil
- t = Time.utc(1999,12,31, 23,59,59)
- t2 = (t+0.4).ceil
- assert_equal([0,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+0.49).ceil
- assert_equal([0,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+0.5).ceil
- assert_equal([0,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+1.4).ceil
- assert_equal([1,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+1.49).ceil
- assert_equal([1,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
- t2 = (t+1.5).ceil
- assert_equal([1,0,0, 1,1,2000, 6,1,false,"UTC"], t2.to_a)
- assert_equal(0, t2.subsec)
-
- t2 = (t+0.123456789).ceil(4)
- assert_equal([59,59,23, 31,12,1999, 5,365,false,"UTC"], t2.to_a)
- assert_equal(Rational(1235,10000), t2.subsec)
- end
-
def test_getlocal_dont_share_eigenclass
bug5012 = "[ruby-dev:44071]"
@@ -1194,20 +1097,6 @@ class TestTime < Test::Unit::TestCase
}
end
- def test_getlocal_utc_offset
- t = Time.gm(2000)
- assert_equal [00, 30, 21, 31, 12, 1999], t.getlocal("-02:30").to_a[0, 6]
- assert_equal [00, 00, 9, 1, 1, 2000], t.getlocal("+09:00").to_a[0, 6]
- assert_equal [20, 29, 21, 31, 12, 1999], t.getlocal("-02:30:40").to_a[0, 6]
- assert_equal [35, 10, 9, 1, 1, 2000], t.getlocal("+09:10:35").to_a[0, 6]
- assert_equal [00, 30, 21, 31, 12, 1999], t.getlocal("-0230").to_a[0, 6]
- assert_equal [00, 00, 9, 1, 1, 2000], t.getlocal("+0900").to_a[0, 6]
- assert_equal [20, 29, 21, 31, 12, 1999], t.getlocal("-023040").to_a[0, 6]
- assert_equal [35, 10, 9, 1, 1, 2000], t.getlocal("+091035").to_a[0, 6]
- assert_raise(ArgumentError) {t.getlocal("-02:3040")}
- assert_raise(ArgumentError) {t.getlocal("+0910:35")}
- end
-
def test_getlocal_nil
now = Time.now
now2 = nil
@@ -1238,19 +1127,14 @@ class TestTime < Test::Unit::TestCase
end
def test_strftime_no_hidden_garbage
- skip unless Thread.list.size == 1
-
fmt = %w(Y m d).map { |x| "%#{x}" }.join('-') # defeats optimization
t = Time.at(0).getutc
ObjectSpace.count_objects(res = {}) # creates strings on first call
- GC.disable
before = ObjectSpace.count_objects(res)[:T_STRING]
val = t.strftime(fmt)
after = ObjectSpace.count_objects(res)[:T_STRING]
assert_equal before + 1, after, 'only new string is the created one'
assert_equal '1970-01-01', val
- ensure
- GC.enable
end
def test_num_exact_error
@@ -1271,9 +1155,7 @@ class TestTime < Test::Unit::TestCase
size = GC::INTERNAL_CONSTANTS[:RVALUE_SIZE]
case size
when 20 then expect = 50
- when 24 then expect = 54
when 40 then expect = 86
- when 48 then expect = 94
else
flunk "Unsupported RVALUE_SIZE=#{size}, update test_memsize"
end
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 5ee12e4dbd..bfe9b4eef3 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: false
require 'test/unit'
-require '-test-/time'
class TestTimeTZ < Test::Unit::TestCase
has_right_tz = true
@@ -9,7 +8,7 @@ class TestTimeTZ < Test::Unit::TestCase
case RUBY_PLATFORM
when /linux/
force_tz_test = true
- when /darwin|freebsd|openbsd/
+ when /darwin|freebsd/
has_lisbon_tz = false
force_tz_test = true
end
@@ -219,7 +218,6 @@ class TestTimeTZ < Test::Unit::TestCase
def test_right_utc
with_tz(tz="right/UTC") {
- ::Bug::Time.reset_leap_second_info
assert_time_constructor(tz, "2008-12-31 23:59:59 UTC", :utc, [2008,12,31,23,59,59])
assert_time_constructor(tz, "2008-12-31 23:59:60 UTC", :utc, [2008,12,31,23,59,60])
assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2008,12,31,24,0,0])
@@ -227,31 +225,6 @@ class TestTimeTZ < Test::Unit::TestCase
}
end if has_right_tz
- def test_right_utc_switching
- with_tz("UTC") { # ensure no leap second timezone
- ::Bug::Time.reset_leap_second_info
- assert_equal(4102444800, Time.utc(2100,1,1,0,0,0).to_i)
- with_tz(tz="right/UTC") {
- assert_time_constructor(tz, "2008-12-31 23:59:59 UTC", :utc, [2008,12,31,23,59,59])
- assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2008,12,31,23,59,60])
- assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2008,12,31,24,0,0])
- assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2009,1,1,0,0,0])
- assert_equal(4102444800, Time.utc(2100,1,1,0,0,0).to_i)
- }
- }
- with_tz("right/UTC") {
- ::Bug::Time.reset_leap_second_info
- assert_not_equal(4102444800, Time.utc(2100,1,1,0,0,0).to_i)
- with_tz(tz="UTC") {
- assert_time_constructor(tz, "2008-12-31 23:59:59 UTC", :utc, [2008,12,31,23,59,59])
- assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2008,12,31,23,59,60])
- assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2008,12,31,24,0,0])
- assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2009,1,1,0,0,0])
- assert_not_equal(4102444800, Time.utc(2100,1,1,0,0,0).to_i)
- }
- }
- end if has_right_tz
-
def test_right_america_los_angeles
with_tz(tz="right/America/Los_Angeles") {
assert_time_constructor(tz, "2008-12-31 15:59:59 -0800", :local, [2008,12,31,15,59,59])
@@ -260,66 +233,6 @@ class TestTimeTZ < Test::Unit::TestCase
}
end if has_right_tz
- def test_utc_names
- assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "UTC"), :utc?)
- assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "utc"), :utc?)
- assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "Z"), :utc?)
- end
-
- def test_military_names
- assert_equal( +1*3600, Time.new(2019, 1, 1, 0, 0, 0, "A").gmtoff)
- assert_equal( +2*3600, Time.new(2019, 1, 1, 0, 0, 0, "B").gmtoff)
- assert_equal( +3*3600, Time.new(2019, 1, 1, 0, 0, 0, "C").gmtoff)
- assert_equal( +4*3600, Time.new(2019, 1, 1, 0, 0, 0, "D").gmtoff)
- assert_equal( +5*3600, Time.new(2019, 1, 1, 0, 0, 0, "E").gmtoff)
- assert_equal( +6*3600, Time.new(2019, 1, 1, 0, 0, 0, "F").gmtoff)
- assert_equal( +7*3600, Time.new(2019, 1, 1, 0, 0, 0, "G").gmtoff)
- assert_equal( +8*3600, Time.new(2019, 1, 1, 0, 0, 0, "H").gmtoff)
- assert_equal( +9*3600, Time.new(2019, 1, 1, 0, 0, 0, "I").gmtoff)
- assert_equal(+10*3600, Time.new(2019, 1, 1, 0, 0, 0, "K").gmtoff)
- assert_equal(+11*3600, Time.new(2019, 1, 1, 0, 0, 0, "L").gmtoff)
- assert_equal(+12*3600, Time.new(2019, 1, 1, 0, 0, 0, "M").gmtoff)
- assert_equal( -1*3600, Time.new(2019, 1, 1, 0, 0, 0, "N").gmtoff)
- assert_equal( -2*3600, Time.new(2019, 1, 1, 0, 0, 0, "O").gmtoff)
- assert_equal( -3*3600, Time.new(2019, 1, 1, 0, 0, 0, "P").gmtoff)
- assert_equal( -4*3600, Time.new(2019, 1, 1, 0, 0, 0, "Q").gmtoff)
- assert_equal( -5*3600, Time.new(2019, 1, 1, 0, 0, 0, "R").gmtoff)
- assert_equal( -6*3600, Time.new(2019, 1, 1, 0, 0, 0, "S").gmtoff)
- assert_equal( -7*3600, Time.new(2019, 1, 1, 0, 0, 0, "T").gmtoff)
- assert_equal( -8*3600, Time.new(2019, 1, 1, 0, 0, 0, "U").gmtoff)
- assert_equal( -9*3600, Time.new(2019, 1, 1, 0, 0, 0, "V").gmtoff)
- assert_equal(-10*3600, Time.new(2019, 1, 1, 0, 0, 0, "W").gmtoff)
- assert_equal(-11*3600, Time.new(2019, 1, 1, 0, 0, 0, "X").gmtoff)
- assert_equal(-12*3600, Time.new(2019, 1, 1, 0, 0, 0, "Y").gmtoff)
- assert_equal( 0, Time.new(2019, 1, 1, 0, 0, 0, "Z").gmtoff)
-
- assert_equal( +1*3600, Time.at(0, in: "A").gmtoff)
- assert_equal( +2*3600, Time.at(0, in: "B").gmtoff)
- assert_equal( +3*3600, Time.at(0, in: "C").gmtoff)
- assert_equal( +4*3600, Time.at(0, in: "D").gmtoff)
- assert_equal( +5*3600, Time.at(0, in: "E").gmtoff)
- assert_equal( +6*3600, Time.at(0, in: "F").gmtoff)
- assert_equal( +7*3600, Time.at(0, in: "G").gmtoff)
- assert_equal( +8*3600, Time.at(0, in: "H").gmtoff)
- assert_equal( +9*3600, Time.at(0, in: "I").gmtoff)
- assert_equal(+10*3600, Time.at(0, in: "K").gmtoff)
- assert_equal(+11*3600, Time.at(0, in: "L").gmtoff)
- assert_equal(+12*3600, Time.at(0, in: "M").gmtoff)
- assert_equal( -1*3600, Time.at(0, in: "N").gmtoff)
- assert_equal( -2*3600, Time.at(0, in: "O").gmtoff)
- assert_equal( -3*3600, Time.at(0, in: "P").gmtoff)
- assert_equal( -4*3600, Time.at(0, in: "Q").gmtoff)
- assert_equal( -5*3600, Time.at(0, in: "R").gmtoff)
- assert_equal( -6*3600, Time.at(0, in: "S").gmtoff)
- assert_equal( -7*3600, Time.at(0, in: "T").gmtoff)
- assert_equal( -8*3600, Time.at(0, in: "U").gmtoff)
- assert_equal( -9*3600, Time.at(0, in: "V").gmtoff)
- assert_equal(-10*3600, Time.at(0, in: "W").gmtoff)
- assert_equal(-11*3600, Time.at(0, in: "X").gmtoff)
- assert_equal(-12*3600, Time.at(0, in: "Y").gmtoff)
- assert_equal( 0, Time.at(0, in: "Z").gmtoff)
- end
-
MON2NUM = {
"Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6,
"Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12
@@ -376,7 +289,6 @@ class TestTimeTZ < Test::Unit::TestCase
mesg = "#{mesg_utc}.localtime"
define_method(gen_test_name(tz)) {
with_tz(tz) {
- ::Bug::Time.reset_leap_second_info
t = nil
assert_nothing_raised(mesg) { t = Time.utc(*u) }
assert_equal(expected_utc, time_to_s(t), mesg_utc)
@@ -548,253 +460,4 @@ Europe/Lisbon Mon Jan 1 00:36:31 1912 UTC = Sun Dec 31 23:59:59 1911 LMT isdst
Europe/Lisbon Mon Jan 1 00:36:44 1912 UT = Sun Dec 31 23:59:59 1911 LMT isdst=0 gmtoff=-2205
Europe/Lisbon Sun Dec 31 23:59:59 1911 UT = Sun Dec 31 23:23:14 1911 LMT isdst=0 gmtoff=-2205
End
-
- class TZ
- attr_reader :name
-
- def initialize(name, abbr, offset, abbr2 = nil, offset2 = nil)
- @name = name
- @abbr = abbr
- @offset = offset
- @abbr2 = abbr2
- @offset2 = offset2
- end
-
- def dst?(t)
- return false unless @offset2
- case t when Integer
- return nil
- end
- case t.mon
- when 4..9
- true
- else
- false
- end
- end
-
- def offset(t)
- (dst?(t) ? @offset2 : @offset)
- end
-
- def local_to_utc(t)
- t - offset(t)
- end
-
- def utc_to_local(t)
- t + offset(t)
- end
-
- def abbr(t)
- dst?(t) ? @abbr2 : @abbr
- end
-
- def ==(other)
- @name == other.name and abbr(0) == other.abbr(0) and offset(0) == other.offset(0)
- end
-
- def inspect
- "#<TZ: #@name #@abbr #@offset>"
- end
- end
-end
-
-module TestTimeTZ::WithTZ
- def subtest_new(time_class, tz, tzarg, tzname, abbr, utc_offset)
- abbr, abbr2 = *abbr
- utc_offset, utc_offset2 = *utc_offset
- t = time_class.new(2018, 9, 1, 12, 0, 0, tzarg)
- utc_offset, abbr = utc_offset2, abbr2 if tz.dst?(t)
- assert_equal([2018, 9, 1, 12, 0, 0, tz], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.zone])
- h, m = (-utc_offset / 60).divmod(60)
- assert_equal(time_class.utc(2018, 9, 1, 12+h, m, 0).to_i, t.to_i)
- assert_equal(6, t.wday)
- assert_equal(244, t.yday)
- end
-
- def subtest_now(time_class, tz, tzarg, tzname, abbr, utc_offset)
- t = time_class.now(in: tzarg)
- assert_equal(tz, t.zone)
- end
-
- def subtest_getlocal(time_class, tz, tzarg, tzname, abbr, utc_offset)
- abbr, abbr2 = *abbr
- utc_offset, utc_offset2 = *utc_offset
- utc = time_class.utc(2018, 9, 1, 12, 0, 0)
- utc_offset, abbr = utc_offset2, abbr2 if tz.dst?(utc)
- t = utc.getlocal(tzarg)
- h, m = (utc_offset / 60).divmod(60)
- assert_equal([2018, 9, 1, 12+h, m, 0, tz], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.zone])
- assert_equal(time_class.utc(2018, 9, 1, 12, 0, 0), t)
- end
-
- def subtest_strftime(time_class, tz, tzarg, tzname, abbr, utc_offset)
- abbr, abbr2 = *abbr
- utc_offset, utc_offset2 = *utc_offset
- t = time_class.new(2018, 9, 1, 12, 0, 0, tzarg)
- utc_offset, abbr = utc_offset2, abbr2 if tz.dst?(t)
- h, m = (utc_offset.abs / 60).divmod(60)
- h = -h if utc_offset < 0
- assert_equal("%+.2d%.2d %s" % [h, m, abbr], t.strftime("%z %Z"))
- end
-
- def subtest_plus(time_class, tz, tzarg, tzname, abbr, utc_offset)
- abbr, abbr2 = *abbr
- utc_offset, utc_offset2 = *utc_offset
- t = time_class.new(2018, 9, 1, 12, 0, 0, tzarg) + 4000
- utc_offset, abbr = utc_offset2, abbr2 if tz.dst?(t)
- assert_equal([2018, 9, 1, 13, 6, 40, tz], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.zone])
- m, s = (4000-utc_offset).divmod(60)
- h, m = m.divmod(60)
- assert_equal(time_class.utc(2018, 9, 1, 12+h, m, s), t)
- end
-
- def subtest_at(time_class, tz, tzarg, tzname, abbr, utc_offset)
- abbr, abbr2 = *abbr
- utc_offset, utc_offset2 = *utc_offset
- utc = time_class.utc(2018, 9, 1, 12, 0, 0)
- utc_offset, abbr = utc_offset2, abbr2 if tz.dst?(utc)
- h, m = (utc_offset / 60).divmod(60)
- t = time_class.at(utc, in: tzarg)
- assert_equal([2018, 9, 1, 12+h, m, 0, tz], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.zone])
- assert_equal(utc.to_i, t.to_i)
- utc = utc.to_i
- t = time_class.at(utc, in: tzarg)
- assert_equal([2018, 9, 1, 12+h, m, 0, tz], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.zone])
- assert_equal(utc, t.to_i)
- end
-
- def subtest_marshal(time_class, tz, tzarg, tzname, abbr, utc_offset)
- t = time_class.new(2018, 9, 1, 12, 0, 0, tzarg)
- t2 = Marshal.load(Marshal.dump(t))
- assert_equal(t, t2)
- assert_equal(t.utc_offset, t2.utc_offset)
- assert_equal(t.utc_offset, (t2+1).utc_offset)
- assert_instance_of(t.zone.class, t2.zone)
- assert_equal(t.dst?, t2.dst?)
- end
-
- def test_invalid_zone
- make_timezone("INVALID", "INV", 0)
- rescue => e
- assert_kind_of(StandardError, e)
- else
- assert false, "ArgumentError expected but nothing was raised."
- end
-
- def nametest_marshal_compatibility(time_class, tzname, abbr, utc_offset)
- data = [
- "\x04\x08Iu:".b, Marshal.dump(time_class)[3..-1],
- "\x0d""\xEF\xA7\x1D\x80\x00\x00\x00\x00".b,
- Marshal.dump({offset: utc_offset, zone: abbr})[3..-1],
- ].join('')
- t = Marshal.load(data)
- assert_equal(utc_offset, t.utc_offset)
- assert_equal(utc_offset, (t+1).utc_offset)
- # t.zone may be a mere String or timezone object.
- end
-
- ZONES = {
- "Asia/Tokyo" => ["JST", +9*3600],
- "America/Los_Angeles" => ["PST", -8*3600, "PDT", -7*3600],
- "Africa/Ndjamena" => ["WAT", +1*3600],
- }
-
- def make_timezone(tzname, abbr, utc_offset, abbr2 = nil, utc_offset2 = nil)
- self.class::TIME_CLASS.find_timezone(tzname)
- end
-
- def subtest_dst?(time_class, tz, tzarg, tzname, abbr, utc_offset)
- t = time_class.new(2018, 6, 22, 12, 0, 0, tzarg)
- return unless tz.dst?(t)
- assert_predicate t, :dst?
- t = time_class.new(2018, 12, 22, 12, 0, 0, tzarg)
- assert_not_predicate t, :dst?
- end
-
- instance_methods(false).grep(/\Asub(?=test_)/) do |subtest|
- test = $'
- ZONES.each_pair do |tzname, (abbr, utc_offset, abbr2, utc_offset2)|
- define_method("#{test}@#{tzname}") do
- tz = make_timezone(tzname, abbr, utc_offset, abbr2, utc_offset2)
- time_class = self.class::TIME_CLASS
- __send__(subtest, time_class, tz, tz, tzname, [abbr, abbr2], [utc_offset, utc_offset2])
- __send__(subtest, time_class, tz, tzname, tzname, [abbr, abbr2], [utc_offset, utc_offset2])
- end
- end
- end
-
- instance_methods(false).grep(/\Aname(?=test_)/) do |subtest|
- test = $'
- ZONES.each_pair do |tzname, (abbr, utc_offset)|
- define_method("#{test}@#{tzname}") do
- time_class = self.class::TIME_CLASS
- __send__(subtest, time_class, tzname, abbr, utc_offset)
- end
- end
- end
-end
-
-class TestTimeTZ::DummyTZ < Test::Unit::TestCase
- include TestTimeTZ::WithTZ
-
- class TIME_CLASS < ::Time
- ZONES = TestTimeTZ::WithTZ::ZONES
- def self.find_timezone(tzname)
- tz = ZONES[tzname] or raise ArgumentError, "Unknown timezone: #{name}"
- TestTimeTZ::TZ.new(tzname, *tz)
- end
- end
-
- def self.make_timezone(tzname, abbr, utc_offset, abbr2 = nil, utc_offset2 = nil)
- TestTimeTZ::TZ.new(tzname, abbr, utc_offset, abbr2, utc_offset2)
- end
-
- def test_fractional_second
- x = Object.new
- def x.local_to_utc(t); t + 8*3600; end
- def x.utc_to_local(t); t - 8*3600; end
-
- t1 = Time.new(2020,11,11,12,13,14.124r, '-08:00')
- t2 = Time.new(2020,11,11,12,13,14.124r, x)
- assert_equal(t1, t2)
- end
-end
-
-begin
- require "tzinfo"
-rescue LoadError
-else
- class TestTimeTZ::GemTZInfo < Test::Unit::TestCase
- include TestTimeTZ::WithTZ
-
- class TIME_CLASS < ::Time
- def self.find_timezone(tzname)
- TZInfo::Timezone.get(tzname)
- end
- end
-
- def tz
- @tz ||= TZInfo::Timezone.get(tzname)
- end
- end
-end
-
-begin
- require "timezone"
-rescue LoadError
-else
- class TestTimeTZ::GemTimezone < Test::Unit::TestCase
- include TestTimeTZ::WithTZ
-
- class TIME_CLASS < ::Time
- def self.find_timezone(name)
- Timezone.fetch(name)
- end
- end
-
- def tz
- @tz ||= Timezone[tzname]
- end
- end
end
diff --git a/test/ruby/test_trace.rb b/test/ruby/test_trace.rb
index 5842f11aee..77be94e9be 100644
--- a/test/ruby/test_trace.rb
+++ b/test/ruby/test_trace.rb
@@ -20,6 +20,17 @@ class TestTrace < Test::Unit::TestCase
untrace_var :$x
end
+ def test_trace_tainted_proc
+ $x = 1234
+ s = proc { $y = :foo }
+ trace_var :$x, s
+ s.taint
+ $x = 42
+ assert_equal(:foo, $y)
+ ensure
+ untrace_var :$x
+ end
+
def test_trace_proc_that_raises_exception
$x = 1234
trace_var :$x, proc { raise }
diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb
index 1f4c623acb..44d238ffd2 100644
--- a/test/ruby/test_transcode.rb
+++ b/test/ruby/test_transcode.rb
@@ -2116,28 +2116,6 @@ class TestTranscode < Test::Unit::TestCase
check_both_ways("D\u00FCrst", "\xC4\xDC\x99\xA2\xA3", 'IBM037') # Dürst
end
- def test_CESU_8
- check_both_ways("aijrszAIJRSZ09", "aijrszAIJRSZ09", 'CESU-8') # single bytes
-
- # check NULL explicitly
- # this is different in CESU-8 and in Java modified UTF-8 strings
- check_both_ways("\0", "\0", 'CESU-8')
-
- # U+0080 U+00FC U+00FF U+0100 U+0400 U+0700 U+07FF
- two_byte_chars = "\xC2\x80\x20\xC3\xBC\x20\xC3\xBF\x20\xC4\x80\x20\xD0\x80\x20\xDC\x80\x20\xDF\xBF"
- check_both_ways(two_byte_chars, two_byte_chars, 'CESU-8')
-
- # U+0800 U+2200 U+4E00 U+D7FF U+E000 U+FFFF
- three_byte_chars = "\xE0\xA0\x80\x20\xE2\x88\x80\x20\xE4\xB8\x80\x20\xED\x9F\xBF\x20\xEE\x80\x80\x20\xEF\xBF\xBF"
- check_both_ways(three_byte_chars, three_byte_chars, 'CESU-8')
-
- # characters outside BMP (double surrogates in CESU-8)
- # U+10000 U+20000 U+50000 U+10FFFF
- utf8 = "\xF0\x90\x80\x80 \xF0\xA0\x80\x80 \xF1\x90\x80\x80 \xF4\x8F\xBF\xBF"
- cesu = "\xED\xA0\x80\xED\xB0\x80 \xED\xA1\x80\xED\xB0\x80 \xED\xA4\x80\xED\xB0\x80 \xED\xAF\xBF\xED\xBF\xBF"
- check_both_ways(utf8, cesu, 'CESU-8')
- end
-
def test_nothing_changed
a = "James".force_encoding("US-ASCII")
b = a.encode("Shift_JIS")
@@ -2183,14 +2161,6 @@ class TestTranscode < Test::Unit::TestCase
assert_equal("U+3042", "\u{3042}".encode("US-ASCII", fallback: fallback.method(:escape)))
end
- def test_fallback_aref
- fallback = Object.new
- def fallback.[](x)
- "U+%.4X" % x.unpack("U")
- end
- assert_equal("U+3042", "\u{3042}".encode("US-ASCII", fallback: fallback))
- end
-
bug8940 = '[ruby-core:57318] [Bug #8940]'
%w[UTF-32 UTF-16].each do |enc|
define_method("test_pseudo_encoding_inspect(#{enc})") do
diff --git a/test/ruby/test_undef.rb b/test/ruby/test_undef.rb
index e0add7c3ab..6d513a238f 100644
--- a/test/ruby/test_undef.rb
+++ b/test/ruby/test_undef.rb
@@ -25,7 +25,7 @@ class TestUndef < Test::Unit::TestCase
y = Undef1.new
assert_equal "bar", y.bar
z = Undef2.new
- assert_raise(NoMethodError) { z.bar }
+ assert_raise(NoMethodError) { z.foo }
end
def test_special_const_undef
diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb
index b053e11607..a9b1fd50ff 100644
--- a/test/ruby/test_variable.rb
+++ b/test/ruby/test_variable.rb
@@ -35,57 +35,6 @@ class TestVariable < Test::Unit::TestCase
end
end
- def test_singleton_class_included_class_variable
- c = Class.new
- c.extend(Olympians)
- assert_empty(c.singleton_class.class_variables)
- assert_raise(NameError){ c.singleton_class.class_variable_get(:@@rule) }
- c.class_variable_set(:@@foo, 1)
- assert_equal([:@@foo], c.singleton_class.class_variables)
- assert_equal(1, c.singleton_class.class_variable_get(:@@foo))
-
- c = Class.new
- c.extend(Olympians)
- sc = Class.new(c)
- assert_empty(sc.singleton_class.class_variables)
- assert_raise(NameError){ sc.singleton_class.class_variable_get(:@@rule) }
- c.class_variable_set(:@@foo, 1)
- assert_equal([:@@foo], sc.singleton_class.class_variables)
- assert_equal(1, sc.singleton_class.class_variable_get(:@@foo))
-
- c = Class.new
- o = c.new
- o.extend(Olympians)
- assert_equal([:@@rule], o.singleton_class.class_variables)
- assert_equal("Zeus", o.singleton_class.class_variable_get(:@@rule))
- c.class_variable_set(:@@foo, 1)
- assert_equal([:@@foo, :@@rule], o.singleton_class.class_variables.sort)
- assert_equal(1, o.singleton_class.class_variable_get(:@@foo))
- end
-
- class IncludeRefinedModuleClassVariableNoWarning
- module Mod
- @@_test_include_refined_module_class_variable = true
- end
-
- module Mod2
- refine Mod do
- end
- end
-
- include Mod
-
- def t
- @@_test_include_refined_module_class_variable
- end
- end
-
- def test_include_refined_module_class_variable
- assert_warning('') do
- IncludeRefinedModuleClassVariableNoWarning.new.t
- end
- end
-
def test_variable
assert_instance_of(Integer, $$)
@@ -186,7 +135,7 @@ class TestVariable < Test::Unit::TestCase
def test_special_constant_ivars
[ true, false, :symbol, "dsym#{rand(9999)}".to_sym, 1, 1.0 ].each do |v|
assert_empty v.instance_variables
- msg = "can't modify frozen #{v.class}: #{v.inspect}"
+ msg = "can't modify frozen #{v.class}"
assert_raise_with_message(FrozenError, msg) do
v.instance_variable_set(:@foo, :bar)
@@ -201,25 +150,6 @@ class TestVariable < Test::Unit::TestCase
end
end
- class ExIvar < Hash
- def initialize
- @a = 1
- @b = 2
- @c = 3
- end
-
- def ivars
- [@a, @b, @c]
- end
- end
-
- def test_external_ivars
- 3.times{
- # check inline cache for external ivar access
- assert_equal [1, 2, 3], ExIvar.new.ivars
- }
- end
-
def test_local_variables_with_kwarg
bug11674 = '[ruby-core:71437] [Bug #11674]'
v = with_kwargs_11(v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8,v9:9,v10:10,v11:11)
diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb
index 46d8b50c03..cde186c5f3 100644
--- a/test/ruby/test_weakmap.rb
+++ b/test/ruby/test_weakmap.rb
@@ -16,50 +16,30 @@ class TestWeakMap < Test::Unit::TestCase
def test_aset_const
x = Object.new
- @wm[true] = x
- assert_same(x, @wm[true])
- @wm[false] = x
- assert_same(x, @wm[false])
- @wm[nil] = x
- assert_same(x, @wm[nil])
- @wm[42] = x
- assert_same(x, @wm[42])
- @wm[:foo] = x
- assert_same(x, @wm[:foo])
-
- @wm[x] = true
- assert_same(true, @wm[x])
- @wm[x] = false
- assert_same(false, @wm[x])
- @wm[x] = nil
- assert_same(nil, @wm[x])
- @wm[x] = 42
- assert_same(42, @wm[x])
- @wm[x] = :foo
- assert_same(:foo, @wm[x])
+ assert_raise(ArgumentError) {@wm[true] = x}
+ assert_raise(ArgumentError) {@wm[false] = x}
+ assert_raise(ArgumentError) {@wm[nil] = x}
+ assert_raise(ArgumentError) {@wm[42] = x}
+ assert_raise(ArgumentError) {@wm[:foo] = x}
+ assert_raise(ArgumentError) {@wm[x] = true}
+ assert_raise(ArgumentError) {@wm[x] = false}
+ assert_raise(ArgumentError) {@wm[x] = nil}
+ assert_raise(ArgumentError) {@wm[x] = 42}
+ assert_raise(ArgumentError) {@wm[x] = :foo}
end
- def assert_weak_include(m, k, n = 100)
- if n > 0
- return assert_weak_include(m, k, n-1)
- end
+ def test_include?
+ m = __callee__[/test_(.*)/, 1]
+ k = "foo"
1.times do
x = Object.new
@wm[k] = x
assert_send([@wm, m, k])
assert_not_send([@wm, m, "FOO".downcase])
- x = Object.new
- end
- end
-
- def test_include?
- m = __callee__[/test_(.*)/, 1]
- k = "foo"
- 1.times do
- assert_weak_include(m, k)
+ x = nil
end
GC.start
- skip('TODO: failure introduced from r60440')
+ skip # TODO: failure introduced from r60440
assert_not_send([@wm, m, k])
end
alias test_member? test_include?
@@ -73,15 +53,6 @@ class TestWeakMap < Test::Unit::TestCase
@wm.inspect)
end
- def test_inspect_garbage
- 1000.times do |i|
- @wm[i] = Object.new
- @wm.inspect
- end
- assert_match(/\A\#<#{@wm.class.name}:[^:]++:(?:\s\d+\s=>\s\#<(?:Object|collected):[^:<>]*+>(?:,|>\z))+/,
- @wm.inspect)
- end
-
def test_each
m = __callee__[/test_(.*)/, 1]
x1 = Object.new
@@ -161,10 +132,4 @@ class TestWeakMap < Test::Unit::TestCase
assert_equal(2, @wm.__send__(m))
end
alias test_length test_size
-
- def test_frozen_object
- o = Object.new.freeze
- assert_nothing_raised(FrozenError) {@wm[o] = 'foo'}
- assert_nothing_raised(FrozenError) {@wm['foo'] = o}
- end
end
diff --git a/test/rubygems/fix_openssl_warnings.rb b/test/rubygems/fix_openssl_warnings.rb
new file mode 100644
index 0000000000..1f5b8b5e0a
--- /dev/null
+++ b/test/rubygems/fix_openssl_warnings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+##
+# HACK: this drives me BONKERS
+
+if defined? OpenSSL then
+ class OpenSSL::X509::ExtensionFactory
+ alias :old_create_ext :create_ext
+ def create_ext(*args)
+ @config ||= nil
+ old_create_ext(*args)
+ end
+ end
+end if RUBY_VERSION < "1.9"
diff --git a/test/rubygems/plugin/load/rubygems_plugin.rb b/test/rubygems/plugin/load/rubygems_plugin.rb
index 85a6851ace..7cc6bef90b 100644
--- a/test/rubygems/plugin/load/rubygems_plugin.rb
+++ b/test/rubygems/plugin/load/rubygems_plugin.rb
@@ -1,6 +1,4 @@
# frozen_string_literal: true
class TestGem
-
TEST_PLUGIN_LOAD = :loaded
-
end
diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb
index 7fac2ebec6..30a67789c6 100644
--- a/test/rubygems/rubygems_plugin.rb
+++ b/test/rubygems/rubygems_plugin.rb
@@ -23,3 +23,4 @@ class Gem::Commands::InterruptCommand < Gem::Command
end
Gem::CommandManager.instance.register_command :interrupt
+
diff --git a/test/rubygems/simple_gem.rb b/test/rubygems/simple_gem.rb
index 0f2ea48198..1650910aaf 100644
--- a/test/rubygems/simple_gem.rb
+++ b/test/rubygems/simple_gem.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-SIMPLE_GEM = <<-GEMDATA.freeze
+SIMPLE_GEM = <<-GEMDATA
MD5SUM = "989bf34a1cbecd52e0ea66b662b3a405"
if $0 == __FILE__
require 'optparse'
diff --git a/test/rubygems/specifications/rubyforge-0.0.1.gemspec b/test/rubygems/specifications/rubyforge-0.0.1.gemspec
deleted file mode 100644
index 0df2c4c379..0000000000
--- a/test/rubygems/specifications/rubyforge-0.0.1.gemspec
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = "rubyforge"
- s.version = "0.0.1"
- s.platform = "ruby"
- s.require_paths = ["lib"]
- s.summary = "A very bar gem"
- s.authors = ["unknown"]
- s.license = 'MIT'
- s.homepage = 'http://example.com'
- s.files = ['README.md']
- s.rubyforge_project = 'abc'
-end
diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb
index 4224755562..97a64af323 100644
--- a/test/rubygems/test_bundled_ca.rb
+++ b/test/rubygems/test_bundled_ca.rb
@@ -37,7 +37,7 @@ if ENV["CI"] || ENV["TEST_SSL"]
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.cert_store = bundled_certificate_store
http.get('/')
- rescue Errno::ENOENT, Errno::ETIMEDOUT, SocketError
+ rescue Errno::ENOENT, Errno::ETIMEDOUT
skip "#{host} seems offline, I can't tell whether ssl would work."
rescue OpenSSL::SSL::SSLError => e
# Only fail for certificate verification errors
@@ -51,16 +51,12 @@ if ENV["CI"] || ENV["TEST_SSL"]
assert_https('rubygems.org')
end
- def test_accessing_www_rubygems
- assert_https('www.rubygems.org')
- end
-
- def test_accessing_staging
- assert_https('staging.rubygems.org')
+ def test_accessing_fastly
+ assert_https('rubygems.global.ssl.fastly.net')
end
def test_accessing_new_index
- assert_https('index.rubygems.org')
+ assert_https('fastly.rubygems.org')
end
end
diff --git a/test/rubygems/test_config.rb b/test/rubygems/test_config.rb
index 70fc4e23f0..f8aadb4a23 100644
--- a/test/rubygems/test_config.rb
+++ b/test/rubygems/test_config.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems'
-require 'shellwords'
class TestConfig < Gem::TestCase
@@ -14,16 +13,12 @@ class TestConfig < Gem::TestCase
def test_good_rake_path_is_escaped
path = Gem::TestCase.class_eval('@@good_rake')
- ruby, rake = path.shellsplit
- assert_equal(Gem.ruby, ruby)
- assert_match(/\/good_rake.rb\z/, rake)
+ assert_match(/#{Gem.ruby} "[^"]*good_rake.rb"/, path)
end
def test_bad_rake_path_is_escaped
path = Gem::TestCase.class_eval('@@bad_rake')
- ruby, rake = path.shellsplit
- assert_equal(Gem.ruby, ruby)
- assert_match(/\/bad_rake.rb\z/, rake)
+ assert_match(/#{Gem.ruby} "[^"]*bad_rake.rb"/, path)
end
end
diff --git a/test/rubygems/test_deprecate.rb b/test/rubygems/test_deprecate.rb
index b92bd1c3da..fab4f33b86 100644
--- a/test/rubygems/test_deprecate.rb
+++ b/test/rubygems/test_deprecate.rb
@@ -45,7 +45,6 @@ class TestDeprecate < Gem::TestCase
end
class Thing
-
extend Gem::Deprecate
attr_accessor :message
def foo
@@ -55,7 +54,6 @@ class TestDeprecate < Gem::TestCase
@message = "bar"
end
deprecate :foo, :bar, 2099, 3
-
end
def test_deprecated_method_calls_the_old_method
@@ -76,5 +74,4 @@ class TestDeprecate < Gem::TestCase
assert_match(/Thing#foo is deprecated; use bar instead\./, err)
assert_match(/on or after 2099-03-01/, err)
end
-
end
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index b5d399f972..419497c75f 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -5,23 +5,16 @@ require 'rubygems/command'
require 'rubygems/installer'
require 'pathname'
require 'tmpdir'
-require 'rbconfig'
-
-if File.exist?(File.join(Dir.tmpdir, "Gemfile"))
- raise "rubygems/bundler tests do not work correctly if there is #{ File.join(Dir.tmpdir, "Gemfile") }"
-end
# TODO: push this up to test_case.rb once battle tested
-
+$SAFE=1
$LOAD_PATH.map! do |path|
- path.dup.tap(&Gem::UNTAINT)
+ path.dup.untaint
end
class TestGem < Gem::TestCase
- PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
-
- PROJECT_DIR = File.expand_path('../../..', __FILE__).tap(&Gem::UNTAINT)
+ PLUGINS_LOADED = []
def setup
super
@@ -38,11 +31,11 @@ class TestGem < Gem::TestCase
def test_self_finish_resolve
save_loaded_features do
- a1 = util_spec "a", "1", "b" => "> 0"
- b1 = util_spec "b", "1", "c" => ">= 1"
- b2 = util_spec "b", "2", "c" => ">= 2"
- c1 = util_spec "c", "1"
- c2 = util_spec "c", "2"
+ a1 = new_spec "a", "1", "b" => "> 0"
+ b1 = new_spec "b", "1", "c" => ">= 1"
+ b2 = new_spec "b", "2", "c" => ">= 2"
+ c1 = new_spec "c", "1"
+ c2 = new_spec "c", "2"
install_specs c1, c2, b1, b2, a1
@@ -60,13 +53,13 @@ class TestGem < Gem::TestCase
def test_self_finish_resolve_wtf
save_loaded_features do
- a1 = util_spec "a", "1", "b" => "> 0", "d" => "> 0" # this
- b1 = util_spec "b", "1", { "c" => ">= 1" }, "lib/b.rb" # this
- b2 = util_spec "b", "2", { "c" => ">= 2" }, "lib/b.rb"
- c1 = util_spec "c", "1" # this
- c2 = util_spec "c", "2"
- d1 = util_spec "d", "1", { "c" => "< 2" }, "lib/d.rb"
- d2 = util_spec "d", "2", { "c" => "< 2" }, "lib/d.rb" # this
+ a1 = new_spec "a", "1", "b" => "> 0", "d" => "> 0" # this
+ b1 = new_spec "b", "1", { "c" => ">= 1" }, "lib/b.rb" # this
+ b2 = new_spec "b", "2", { "c" => ">= 2" }, "lib/b.rb"
+ c1 = new_spec "c", "1" # this
+ c2 = new_spec "c", "2"
+ d1 = new_spec "d", "1", { "c" => "< 2" }, "lib/d.rb"
+ d2 = new_spec "d", "2", { "c" => "< 2" }, "lib/d.rb" # this
install_specs c1, c2, b1, b2, d1, d2, a1
@@ -84,11 +77,11 @@ class TestGem < Gem::TestCase
def test_self_finish_resolve_respects_loaded_specs
save_loaded_features do
- a1 = util_spec "a", "1", "b" => "> 0"
- b1 = util_spec "b", "1", "c" => ">= 1"
- b2 = util_spec "b", "2", "c" => ">= 2"
- c1 = util_spec "c", "1"
- c2 = util_spec "c", "2"
+ a1 = new_spec "a", "1", "b" => "> 0"
+ b1 = new_spec "b", "1", "c" => ">= 1"
+ b2 = new_spec "b", "2", "c" => ">= 2"
+ c1 = new_spec "c", "1"
+ c2 = new_spec "c", "2"
install_specs c1, c2, b1, b2, a1
@@ -137,101 +130,17 @@ class TestGem < Gem::TestCase
assert_equal %w[a-1], installed.map { |spec| spec.full_name }
end
- def test_self_install_permissions
- assert_self_install_permissions
- end
-
- def test_self_install_permissions_umask_0
- umask = File.umask(0)
- assert_self_install_permissions
- ensure
- File.umask(umask)
- end
-
- def test_self_install_permissions_umask_077
- umask = File.umask(077)
- assert_self_install_permissions
- ensure
- File.umask(umask)
- end
-
- def test_self_install_permissions_with_format_executable
- assert_self_install_permissions(format_executable: true)
- end
-
- def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name
- Gem::Installer.exec_format = nil
- ruby_install_name 'ruby27' do
- assert_self_install_permissions(format_executable: true)
- end
- ensure
- Gem::Installer.exec_format = nil
- end
-
- def assert_self_install_permissions(format_executable: false)
- mask = win_platform? ? 0700 : 0777
- options = {
- :dir_mode => 0500,
- :prog_mode => win_platform? ? 0410 : 0510,
- :data_mode => 0640,
- :wrappers => true,
- :format_executable => format_executable
- }
- Dir.chdir @tempdir do
- Dir.mkdir 'bin'
- Dir.mkdir 'data'
-
- File.write 'bin/foo', "#!/usr/bin/env ruby\n"
- File.chmod 0755, 'bin/foo'
-
- File.write 'data/foo.txt', "blah\n"
-
- spec_fetcher do |f|
- f.gem 'foo', 1 do |s|
- s.executables = ['foo']
- s.files = %w[bin/foo data/foo.txt]
- end
- end
- Gem.install 'foo', Gem::Requirement.default, options
- end
-
- prog_mode = (options[:prog_mode] & mask).to_s(8)
- dir_mode = (options[:dir_mode] & mask).to_s(8)
- data_mode = (options[:data_mode] & mask).to_s(8)
- prog_name = 'foo'
- prog_name = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'foo') if options[:format_executable]
- expected = {
- "bin/#{prog_name}" => prog_mode,
- 'gems/foo-1' => dir_mode,
- 'gems/foo-1/bin' => dir_mode,
- 'gems/foo-1/data' => dir_mode,
- 'gems/foo-1/bin/foo' => prog_mode,
- 'gems/foo-1/data/foo.txt' => data_mode,
- }
- # add Windows script
- expected["bin/#{prog_name}.bat"] = mask.to_s(8) if win_platform?
- result = {}
- Dir.chdir @gemhome do
- expected.each_key do |n|
- result[n] = (File.stat(n).mode & mask).to_s(8)
- end
- end
- assert_equal(expected, result)
- ensure
- File.chmod(0755, *Dir.glob(@gemhome + '/gems/**/').map {|path| path.tap(&Gem::UNTAINT)})
- end
-
def test_require_missing
save_loaded_features do
assert_raises ::LoadError do
- require "test_require_missing"
+ require "q"
end
end
end
def test_require_does_not_glob
save_loaded_features do
- a1 = util_spec "a", "1", nil, "lib/a1.rb"
+ a1 = new_spec "a", "1", nil, "lib/a1.rb"
install_specs a1
@@ -271,14 +180,6 @@ class TestGem < Gem::TestCase
assert_match 'a-2/bin/exec', Gem.bin_path('a', 'exec', '>= 0')
end
- def test_self_activate_bin_path_no_exec_name
- e = assert_raises ArgumentError do
- Gem.activate_bin_path 'a'
- end
-
- assert_equal 'you must supply exec_name', e.message
- end
-
def test_activate_bin_path_resolves_eagerly
a1 = util_spec 'a', '1' do |s|
s.executables = ['exec']
@@ -308,21 +209,6 @@ class TestGem < Gem::TestCase
assert_equal %w(a-1 b-2 c-1), loaded_spec_names
end
- def test_activate_bin_path_in_debug_mode
- a1 = util_spec 'a', '1' do |s|
- s.executables = ['exec']
- end
-
- install_specs a1
-
- output, status = Open3.capture2e(
- { "GEM_HOME" => Gem.paths.home, "DEBUG_RESOLVER" => "1" },
- Gem.ruby, "-I", File.expand_path("../../lib", __dir__), "-e", "\"Gem.activate_bin_path('a', 'exec', '>= 0')\""
- )
-
- assert status.success?, output
- end
-
def test_activate_bin_path_gives_proper_error_for_bundler
bundler = util_spec 'bundler', '2' do |s|
s.executables = ['bundle']
@@ -358,74 +244,6 @@ class TestGem < Gem::TestCase
refute_includes e.message, "can't find gem bundler (>= 0.a) with executable bundle"
end
- def test_activate_bin_path_selects_exact_bundler_version_if_present
- bundler_latest = util_spec 'bundler', '2.0.1' do |s|
- s.executables = ['bundle']
- end
-
- bundler_previous = util_spec 'bundler', '2.0.0' do |s|
- s.executables = ['bundle']
- end
-
- install_specs bundler_latest, bundler_previous
-
- File.open("Gemfile.lock", "w") do |f|
- f.write <<-L.gsub(/ {8}/, "")
- GEM
- remote: https://rubygems.org/
- specs:
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
-
- BUNDLED WITH
- 2.0.0
- L
- end
-
- File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') }
-
- load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")
-
- assert_equal %w(bundler-2.0.0), loaded_spec_names
- end
-
- def test_activate_bin_path_respects_underscore_selection_if_given
- bundler_latest = util_spec 'bundler', '2.0.1' do |s|
- s.executables = ['bundle']
- end
-
- bundler_previous = util_spec 'bundler', '1.17.3' do |s|
- s.executables = ['bundle']
- end
-
- install_specs bundler_latest, bundler_previous
-
- File.open("Gemfile.lock", "w") do |f|
- f.write <<-L.gsub(/ {8}/, "")
- GEM
- remote: https://rubygems.org/
- specs:
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
-
- BUNDLED WITH
- 2.0.1
- L
- end
-
- File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') }
-
- load Gem.activate_bin_path("bundler", "bundle", "= 1.17.3")
-
- assert_equal %w(bundler-1.17.3), loaded_spec_names
- end
-
def test_self_bin_path_no_exec_name
e = assert_raises ArgumentError do
Gem.bin_path 'a'
@@ -513,10 +331,7 @@ class TestGem < Gem::TestCase
fp.puts 'blah'
end
- foo = util_spec 'foo' do |s|
- s.files = %w[data/foo.txt]
- end
-
+ foo = util_spec 'foo' do |s| s.files = %w[data/foo.txt] end
install_gem foo
end
@@ -552,50 +367,63 @@ class TestGem < Gem::TestCase
end
def test_default_path
- vendordir(File.join(@tempdir, 'vendor')) do
- FileUtils.rm_rf Gem.user_home
+ orig_vendordir = RbConfig::CONFIG['vendordir']
+ RbConfig::CONFIG['vendordir'] = File.join @tempdir, 'vendor'
- expected = [Gem.default_dir]
+ FileUtils.rm_rf Gem.user_home
- assert_equal expected, Gem.default_path
- end
+ expected = [Gem.default_dir]
+
+ assert_equal expected, Gem.default_path
+ ensure
+ RbConfig::CONFIG['vendordir'] = orig_vendordir
end
def test_default_path_missing_vendor
- vendordir(nil) do
- FileUtils.rm_rf Gem.user_home
+ orig_vendordir = RbConfig::CONFIG['vendordir']
+ RbConfig::CONFIG.delete 'vendordir'
- expected = [Gem.default_dir]
+ FileUtils.rm_rf Gem.user_home
- assert_equal expected, Gem.default_path
- end
+ expected = [Gem.default_dir]
+
+ assert_equal expected, Gem.default_path
+ ensure
+ RbConfig::CONFIG['vendordir'] = orig_vendordir
end
def test_default_path_user_home
- vendordir(File.join(@tempdir, 'vendor')) do
- expected = [Gem.user_dir, Gem.default_dir]
+ orig_vendordir = RbConfig::CONFIG['vendordir']
+ RbConfig::CONFIG['vendordir'] = File.join @tempdir, 'vendor'
- assert_equal expected, Gem.default_path
- end
+ expected = [Gem.user_dir, Gem.default_dir]
+
+ assert_equal expected, Gem.default_path
+ ensure
+ RbConfig::CONFIG['vendordir'] = orig_vendordir
end
def test_default_path_vendor_dir
- vendordir(File.join(@tempdir, 'vendor')) do
- FileUtils.mkdir_p Gem.vendor_dir
+ orig_vendordir = RbConfig::CONFIG['vendordir']
+ RbConfig::CONFIG['vendordir'] = File.join @tempdir, 'vendor'
- FileUtils.rm_rf Gem.user_home
+ FileUtils.mkdir_p Gem.vendor_dir
- expected = [Gem.default_dir, Gem.vendor_dir]
+ FileUtils.rm_rf Gem.user_home
- assert_equal expected, Gem.default_path
- end
+ expected = [Gem.default_dir, Gem.vendor_dir]
+
+ assert_equal expected, Gem.default_path
+ ensure
+ RbConfig::CONFIG['vendordir'] = orig_vendordir
end
def test_self_default_sources
assert_equal %w[https://rubygems.org/], Gem.default_sources
end
- def test_self_use_gemdeps
+ def test_self_detect_gemdeps
+ skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
FileUtils.mkdir_p 'detect/a/b'
@@ -606,7 +434,7 @@ class TestGem < Gem::TestCase
begin
Dir.chdir 'detect/a/b'
- assert_equal add_bundler_full_name([]), Gem.use_gemdeps.map(&:full_name)
+ assert_equal add_bundler_full_name([]), Gem.detect_gemdeps.map(&:full_name)
ensure
Dir.chdir @tempdir
end
@@ -638,7 +466,7 @@ class TestGem < Gem::TestCase
Gem.ensure_gem_subdirectories @gemhome, 0750
- assert_directory_exists File.join(@gemhome, "cache")
+ assert File.directory? File.join(@gemhome, "cache")
assert_equal 0750, File::Stat.new(@gemhome).mode & 0777
assert_equal 0750, File::Stat.new(File.join(@gemhome, "cache")).mode & 0777
@@ -667,10 +495,10 @@ class TestGem < Gem::TestCase
Gem.ensure_gem_subdirectories gemdir
- assert_directory_exists util_cache_dir
+ assert File.directory?(util_cache_dir)
end
- unless win_platform? || Process.uid.zero? # only for FS that support write protection
+ unless win_platform? || Process.uid.zero? then # only for FS that support write protection
def test_self_ensure_gem_directories_write_protected
gemdir = File.join @tempdir, "egd"
FileUtils.rm_r gemdir rescue nil
@@ -717,12 +545,12 @@ class TestGem < Gem::TestCase
end
def test_self_find_files
- cwd = File.expand_path("test/rubygems", PROJECT_DIR)
+ cwd = File.expand_path("test/rubygems", @@project_dir)
$LOAD_PATH.unshift cwd
discover_path = File.join 'lib', 'sff', 'discover.rb'
- foo1, foo2 = %w(1 2).map do |version|
+ foo1, foo2 = %w(1 2).map { |version|
spec = quick_gem 'sff', version do |s|
s.files << discover_path
end
@@ -732,12 +560,12 @@ class TestGem < Gem::TestCase
end
spec
- end
+ }
Gem.refresh
expected = [
- File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
+ File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
File.join(foo2.full_gem_path, discover_path),
File.join(foo1.full_gem_path, discover_path),
]
@@ -749,12 +577,15 @@ class TestGem < Gem::TestCase
end
def test_self_find_files_with_gemfile
- cwd = File.expand_path("test/rubygems", PROJECT_DIR)
+ # write_file(File.join Dir.pwd, 'Gemfile') fails on travis 1.8.7 with $SAFE=1
+ skip if RUBY_VERSION <= "1.8.7"
+
+ cwd = File.expand_path("test/rubygems", @@project_dir)
actual_load_path = $LOAD_PATH.unshift(cwd).dup
discover_path = File.join 'lib', 'sff', 'discover.rb'
- foo1, _ = %w(1 2).map do |version|
+ foo1, _ = %w(1 2).map { |version|
spec = quick_gem 'sff', version do |s|
s.files << discover_path
end
@@ -764,7 +595,7 @@ class TestGem < Gem::TestCase
end
spec
- end
+ }
Gem.refresh
write_file(File.join Dir.pwd, 'Gemfile') do |fp|
@@ -774,23 +605,23 @@ class TestGem < Gem::TestCase
Gem.use_gemdeps(File.join Dir.pwd, 'Gemfile')
expected = [
- File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
+ File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
File.join(foo1.full_gem_path, discover_path)
].sort
assert_equal expected, Gem.find_files('sff/discover').sort
assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]'
ensure
- assert_equal cwd, actual_load_path.shift unless Gem.java_platform?
+ assert_equal cwd, actual_load_path.shift unless RUBY_VERSION <= "1.8.7"
end
def test_self_find_latest_files
- cwd = File.expand_path("test/rubygems", PROJECT_DIR)
+ cwd = File.expand_path("test/rubygems", @@project_dir)
$LOAD_PATH.unshift cwd
discover_path = File.join 'lib', 'sff', 'discover.rb'
- _, foo2 = %w(1 2).map do |version|
+ _, foo2 = %w(1 2).map { |version|
spec = quick_gem 'sff', version do |s|
s.files << discover_path
end
@@ -800,12 +631,12 @@ class TestGem < Gem::TestCase
end
spec
- end
+ }
Gem.refresh
expected = [
- File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
+ File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
File.join(foo2.full_gem_path, discover_path),
]
@@ -957,12 +788,12 @@ class TestGem < Gem::TestCase
end
def test_self_prefix
- assert_equal PROJECT_DIR, Gem.prefix
+ assert_equal @@project_dir, Gem.prefix
end
def test_self_prefix_libdir
orig_libdir = RbConfig::CONFIG['libdir']
- RbConfig::CONFIG['libdir'] = PROJECT_DIR
+ RbConfig::CONFIG['libdir'] = @@project_dir
assert_nil Gem.prefix
ensure
@@ -971,7 +802,7 @@ class TestGem < Gem::TestCase
def test_self_prefix_sitelibdir
orig_sitelibdir = RbConfig::CONFIG['sitelibdir']
- RbConfig::CONFIG['sitelibdir'] = PROJECT_DIR
+ RbConfig::CONFIG['sitelibdir'] = @@project_dir
assert_nil Gem.prefix
ensure
@@ -997,6 +828,7 @@ class TestGem < Gem::TestCase
end
def test_self_refresh
+ skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7"
util_make_gems
a1_spec = @a1.spec_file
@@ -1016,6 +848,7 @@ class TestGem < Gem::TestCase
end
def test_self_refresh_keeps_loaded_specs_activated
+ skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7"
util_make_gems
a1_spec = @a1.spec_file
@@ -1037,19 +870,41 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_escaping_spaces_in_path
- with_bindir_and_exeext("C:/Ruby 1.8/bin", ".exe") do
- ruby_install_name "ruby" do
- assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
- end
- end
+ orig_ruby = Gem.ruby
+ orig_bindir = RbConfig::CONFIG['bindir']
+ orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
+ orig_exe_ext = RbConfig::CONFIG['EXEEXT']
+
+ RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin"
+ RbConfig::CONFIG['ruby_install_name'] = "ruby"
+ RbConfig::CONFIG['EXEEXT'] = ".exe"
+ Gem.instance_variable_set("@ruby", nil)
+
+ assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
+ ensure
+ Gem.instance_variable_set("@ruby", orig_ruby)
+ RbConfig::CONFIG['bindir'] = orig_bindir
+ RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
+ RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
end
def test_self_ruby_path_without_spaces
- with_bindir_and_exeext("C:/Ruby18/bin", ".exe") do
- ruby_install_name "ruby" do
- assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
- end
- end
+ orig_ruby = Gem.ruby
+ orig_bindir = RbConfig::CONFIG['bindir']
+ orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
+ orig_exe_ext = RbConfig::CONFIG['EXEEXT']
+
+ RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin"
+ RbConfig::CONFIG['ruby_install_name'] = "ruby"
+ RbConfig::CONFIG['EXEEXT'] = ".exe"
+ Gem.instance_variable_set("@ruby", nil)
+
+ assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
+ ensure
+ Gem.instance_variable_set("@ruby", orig_ruby)
+ RbConfig::CONFIG['bindir'] = orig_bindir
+ RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
+ RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
end
def test_self_ruby_api_version
@@ -1075,7 +930,7 @@ class TestGem < Gem::TestCase
assert_equal Gem::Requirement.default, Gem.env_requirement('qux')
end
- def test_self_ruby_version_with_patchlevel_less_ancient_rubies
+ def test_self_ruby_version_1_8_5
util_set_RUBY_VERSION '1.8.5'
assert_equal Gem::Version.new('1.8.5'), Gem.ruby_version
@@ -1083,7 +938,7 @@ class TestGem < Gem::TestCase
util_restore_RUBY_VERSION
end
- def test_self_ruby_version_with_release
+ def test_self_ruby_version_1_8_6p287
util_set_RUBY_VERSION '1.8.6', 287
assert_equal Gem::Version.new('1.8.6.287'), Gem.ruby_version
@@ -1091,50 +946,10 @@ class TestGem < Gem::TestCase
util_restore_RUBY_VERSION
end
- def test_self_ruby_version_with_non_mri_implementations
- util_set_RUBY_VERSION '2.5.0', 0, 60928, 'jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]'
-
- assert_equal Gem::Version.new('2.5.0'), Gem.ruby_version
- ensure
- util_restore_RUBY_VERSION
- end
-
- def test_self_ruby_version_with_svn_prerelease
- util_set_RUBY_VERSION '2.6.0', -1, 63539, 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]'
-
- assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version
- ensure
- util_restore_RUBY_VERSION
- end
-
- def test_self_ruby_version_with_git_prerelease
- util_set_RUBY_VERSION '2.7.0', -1, 'b563439274a402e33541f5695b1bfd4ac1085638', 'ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]'
+ def test_self_ruby_version_1_9_2dev_r23493
+ util_set_RUBY_VERSION '1.9.2', -1, 23493
- assert_equal Gem::Version.new('2.7.0.preview3'), Gem.ruby_version
- ensure
- util_restore_RUBY_VERSION
- end
-
- def test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility
- util_set_RUBY_VERSION '2.6.0', -1, 63539, 'weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]', 'weirdjruby', '9.2.0.0'
-
- assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version
- ensure
- util_restore_RUBY_VERSION
- end
-
- def test_self_ruby_version_with_svn_trunk
- util_set_RUBY_VERSION '1.9.2', -1, 23493, 'ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]'
-
- assert_equal Gem::Version.new('1.9.2.dev'), Gem.ruby_version
- ensure
- util_restore_RUBY_VERSION
- end
-
- def test_self_ruby_version_with_git_master
- util_set_RUBY_VERSION '2.7.0', -1, '5de284ec78220e75643f89b454ce999da0c1c195', 'ruby 2.7.0dev (2019-12-23T01:37:30Z master 5de284ec78) [x86_64-linux]'
-
- assert_equal Gem::Version.new('2.7.0.dev'), Gem.ruby_version
+ assert_equal Gem::Version.new('1.9.2.dev.23493'), Gem.ruby_version
ensure
util_restore_RUBY_VERSION
end
@@ -1172,7 +987,7 @@ class TestGem < Gem::TestCase
def test_self_post_build
assert_equal 1, Gem.post_build_hooks.length
- Gem.post_build { |installer| }
+ Gem.post_build do |installer| end
assert_equal 2, Gem.post_build_hooks.length
end
@@ -1180,7 +995,7 @@ class TestGem < Gem::TestCase
def test_self_post_install
assert_equal 1, Gem.post_install_hooks.length
- Gem.post_install { |installer| }
+ Gem.post_install do |installer| end
assert_equal 2, Gem.post_install_hooks.length
end
@@ -1188,7 +1003,7 @@ class TestGem < Gem::TestCase
def test_self_done_installing
assert_empty Gem.done_installing_hooks
- Gem.done_installing { |gems| }
+ Gem.done_installing do |gems| end
assert_equal 1, Gem.done_installing_hooks.length
end
@@ -1204,7 +1019,7 @@ class TestGem < Gem::TestCase
def test_self_post_uninstall
assert_equal 1, Gem.post_uninstall_hooks.length
- Gem.post_uninstall { |installer| }
+ Gem.post_uninstall do |installer| end
assert_equal 2, Gem.post_uninstall_hooks.length
end
@@ -1212,7 +1027,7 @@ class TestGem < Gem::TestCase
def test_self_pre_install
assert_equal 1, Gem.pre_install_hooks.length
- Gem.pre_install { |installer| }
+ Gem.pre_install do |installer| end
assert_equal 2, Gem.pre_install_hooks.length
end
@@ -1228,7 +1043,7 @@ class TestGem < Gem::TestCase
def test_self_pre_uninstall
assert_equal 1, Gem.pre_uninstall_hooks.length
- Gem.pre_uninstall { |installer| }
+ Gem.pre_uninstall do |installer| end
assert_equal 2, Gem.pre_uninstall_hooks.length
end
@@ -1319,12 +1134,10 @@ class TestGem < Gem::TestCase
refute Gem.try_activate 'nonexistent'
end
- unless Gem.java_platform?
- expected = "Ignoring ext-1 because its extensions are not built. " +
- "Try: gem pristine ext --version 1\n"
+ expected = "Ignoring ext-1 because its extensions are not built. " +
+ "Try: gem pristine ext --version 1\n"
- assert_equal expected, err
- end
+ assert_equal expected, err
end
def test_self_use_paths_with_nils
@@ -1384,7 +1197,7 @@ class TestGem < Gem::TestCase
end
def test_self_user_home
- if ENV['HOME']
+ if ENV['HOME'] then
assert_equal ENV['HOME'], Gem.user_home
else
assert true, 'count this test'
@@ -1392,6 +1205,7 @@ class TestGem < Gem::TestCase
end
def test_self_needs
+ util_clear_gems
a = util_spec "a", "1"
b = util_spec "b", "1", "c" => nil
c = util_spec "c", "2"
@@ -1409,11 +1223,13 @@ class TestGem < Gem::TestCase
end
def test_self_needs_picks_up_unresolved_deps
+ skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7"
save_loaded_features do
+ util_clear_gems
a = util_spec "a", "1"
b = util_spec "b", "1", "c" => nil
c = util_spec "c", "2"
- d = util_spec "d", "1", {'e' => '= 1'}, "lib/d#{$$}.rb"
+ d = new_spec "d", "1", {'e' => '= 1'}, "lib/d.rb"
e = util_spec "e", "1"
install_specs a, c, b, e, d
@@ -1422,7 +1238,7 @@ class TestGem < Gem::TestCase
r.gem "a"
r.gem "b", "= 1"
- require "d#{$$}"
+ require 'd'
end
assert_equal %w!a-1 b-1 c-2 d-1 e-1!, loaded_spec_names
@@ -1433,31 +1249,78 @@ class TestGem < Gem::TestCase
input = "\x1F\x8B\b\0\xED\xA3\x1AQ\0\x03\xCBH" +
"\xCD\xC9\xC9\a\0\x86\xA6\x106\x05\0\0\0"
- output = Gem::Util.gunzip input
+ output = Gem.gunzip input
assert_equal 'hello', output
+
+ return unless Object.const_defined? :Encoding
+
assert_equal Encoding::BINARY, output.encoding
end
def test_self_gzip
input = 'hello'
- output = Gem::Util.gzip input
+ output = Gem.gzip input
zipped = StringIO.new output
assert_equal 'hello', Zlib::GzipReader.new(zipped).read
+
+ return unless Object.const_defined? :Encoding
+
assert_equal Encoding::BINARY, output.encoding
end
- def test_self_vendor_dir
- vendordir(File.join(@tempdir, 'vendor')) do
- expected =
- File.join RbConfig::CONFIG['vendordir'], 'gems',
- RbConfig::CONFIG['ruby_version']
+ if Gem.win_platform? && '1.9' > RUBY_VERSION
+ # Ruby 1.9 properly handles ~ path expansion, so no need to run such tests.
+ def test_self_user_home_userprofile
+
+ Gem.clear_paths
+
+ # safe-keep env variables
+ orig_home, orig_user_profile = ENV['HOME'], ENV['USERPROFILE']
- assert_equal expected, Gem.vendor_dir
+ # prepare for the test
+ ENV.delete('HOME')
+ ENV['USERPROFILE'] = "W:\\Users\\RubyUser"
+
+ assert_equal 'W:/Users/RubyUser', Gem.user_home
+
+ ensure
+ ENV['HOME'] = orig_home
+ ENV['USERPROFILE'] = orig_user_profile
end
+
+ def test_self_user_home_user_drive_and_path
+ Gem.clear_paths
+
+ # safe-keep env variables
+ orig_home, orig_user_profile = ENV['HOME'], ENV['USERPROFILE']
+ orig_home_drive, orig_home_path = ENV['HOMEDRIVE'], ENV['HOMEPATH']
+
+ # prepare the environment
+ ENV.delete('HOME')
+ ENV.delete('USERPROFILE')
+ ENV['HOMEDRIVE'] = 'Z:'
+ ENV['HOMEPATH'] = "\\Users\\RubyUser"
+
+ assert_equal 'Z:/Users/RubyUser', Gem.user_home
+
+ ensure
+ ENV['HOME'] = orig_home
+ ENV['USERPROFILE'] = orig_user_profile
+ ENV['HOMEDRIVE'] = orig_home_drive
+ ENV['HOMEPATH'] = orig_home_path
+ end
+ end
+
+ def test_self_vendor_dir
+ expected =
+ File.join RbConfig::CONFIG['vendordir'], 'gems',
+ RbConfig::CONFIG['ruby_version']
+
+ assert_equal expected, Gem.vendor_dir
end
def test_self_vendor_dir_ENV_GEM_VENDOR
@@ -1468,12 +1331,16 @@ class TestGem < Gem::TestCase
end
def test_self_vendor_dir_missing
- vendordir(nil) do
- assert_nil Gem.vendor_dir
- end
+ orig_vendordir = RbConfig::CONFIG['vendordir']
+ RbConfig::CONFIG.delete 'vendordir'
+
+ assert_nil Gem.vendor_dir
+ ensure
+ RbConfig::CONFIG['vendordir'] = orig_vendordir
end
def test_load_plugins
+ skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
plugin_path = File.join "lib", "rubygems_plugin.rb"
Dir.chdir @tempdir do
@@ -1528,8 +1395,8 @@ class TestGem < Gem::TestCase
write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" }
write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" }
- g = util_spec 'g', '1', nil, "lib/g.rb"
- m = util_spec 'm', '1', nil, "lib/m.rb"
+ g = new_spec 'g', '1', nil, "lib/g.rb"
+ m = new_spec 'm', '1', nil, "lib/m.rb"
install_gem g, :install_dir => Gem.dir
m0 = install_gem m, :install_dir => Gem.dir
@@ -1584,8 +1451,8 @@ class TestGem < Gem::TestCase
write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" }
write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" }
- g = util_spec 'g', '1', nil, "lib/g.rb"
- m = util_spec 'm', '1', nil, "lib/m.rb"
+ g = new_spec 'g', '1', nil, "lib/g.rb"
+ m = new_spec 'm', '1', nil, "lib/m.rb"
install_gem g, :install_dir => Gem.dir
install_gem m, :install_dir => Gem.dir
@@ -1600,9 +1467,11 @@ class TestGem < Gem::TestCase
end
def test_auto_activation_of_specific_gemdeps_file
- a = util_spec "a", "1", nil, "lib/a.rb"
- b = util_spec "b", "1", nil, "lib/b.rb"
- c = util_spec "c", "1", nil, "lib/c.rb"
+ util_clear_gems
+
+ a = new_spec "a", "1", nil, "lib/a.rb"
+ b = new_spec "b", "1", nil, "lib/b.rb"
+ c = new_spec "c", "1", nil, "lib/c.rb"
install_specs a, b, c
@@ -1616,15 +1485,18 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = path
- Gem.use_gemdeps
+ Gem.detect_gemdeps
assert_equal add_bundler_full_name(%W(a-1 b-1 c-1)), loaded_spec_names
end
- def test_auto_activation_of_used_gemdeps_file
- a = util_spec "a", "1", nil, "lib/a.rb"
- b = util_spec "b", "1", nil, "lib/b.rb"
- c = util_spec "c", "1", nil, "lib/c.rb"
+ def test_auto_activation_of_detected_gemdeps_file
+ skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
+ util_clear_gems
+
+ a = new_spec "a", "1", nil, "lib/a.rb"
+ b = new_spec "b", "1", nil, "lib/b.rb"
+ c = new_spec "c", "1", nil, "lib/c.rb"
install_specs a, b, c
@@ -1638,26 +1510,30 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = "-"
- expected_specs = [a, b, util_spec("bundler", Bundler::VERSION), c].compact
- assert_equal expected_specs, Gem.use_gemdeps.sort_by { |s| s.name }
+ expected_specs = [a, b, (Gem::USE_BUNDLER_FOR_GEMDEPS || nil) && util_spec("bundler", Bundler::VERSION), c].compact
+ assert_equal expected_specs, Gem.detect_gemdeps.sort_by { |s| s.name }
end
- LIB_PATH = File.expand_path "../../../lib".dup.tap(&Gem::UNTAINT), __FILE__.dup.tap(&Gem::UNTAINT)
- BUNDLER_LIB_PATH = File.expand_path $LOAD_PATH.find {|lp| File.file?(File.join(lp, "bundler.rb")) }.dup.tap(&Gem::UNTAINT)
- BUNDLER_FULL_NAME = "bundler-#{Bundler::VERSION}".freeze
+ LIB_PATH = File.expand_path "../../../lib".dup.untaint, __FILE__.dup.untaint
+
+ if Gem::USE_BUNDLER_FOR_GEMDEPS
+ BUNDLER_LIB_PATH = File.expand_path $LOAD_PATH.find {|lp| File.file?(File.join(lp, "bundler.rb")) }.dup.untaint
+ BUNDLER_FULL_NAME = "bundler-#{Bundler::VERSION}"
+ end
def add_bundler_full_name(names)
+ return names unless Gem::USE_BUNDLER_FOR_GEMDEPS
names << BUNDLER_FULL_NAME
names.sort!
names
end
def test_looks_for_gemdeps_files_automatically_on_start
- skip "Requiring bundler messes things up" if Gem.java_platform?
+ util_clear_gems
- a = util_spec "a", "1", nil, "lib/a.rb"
- b = util_spec "b", "1", nil, "lib/b.rb"
- c = util_spec "c", "1", nil, "lib/c.rb"
+ a = new_spec "a", "1", nil, "lib/a.rb"
+ b = new_spec "b", "1", nil, "lib/b.rb"
+ c = new_spec "c", "1", nil, "lib/c.rb"
install_specs a, b, c
@@ -1670,9 +1546,14 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = "-"
path = File.join @tempdir, "gem.deps.rb"
- cmd = [Gem.ruby.dup.tap(&Gem::UNTAINT), "-I#{LIB_PATH.tap(&Gem::UNTAINT)}",
- "-I#{BUNDLER_LIB_PATH.tap(&Gem::UNTAINT)}", "-rrubygems"]
- cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
+ cmd = [Gem.ruby.dup.untaint, "-I#{LIB_PATH.untaint}",
+ "-I#{BUNDLER_LIB_PATH.untaint}", "-rrubygems"]
+ if RUBY_VERSION < '1.9'
+ cmd << "-e 'puts Gem.loaded_specs.values.map(&:full_name).sort'"
+ cmd = cmd.join(' ')
+ else
+ cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
+ end
File.open path, "w" do |f|
f.puts "gem 'a'"
@@ -1686,14 +1567,14 @@ class TestGem < Gem::TestCase
out = IO.popen(cmd, &:read).split(/\n/)
assert_equal ["b-1", "c-1"], out - out0
- end
+ end if Gem::USE_BUNDLER_FOR_GEMDEPS
def test_looks_for_gemdeps_files_automatically_on_start_in_parent_dir
- skip "Requiring bundler messes things up" if Gem.java_platform?
+ util_clear_gems
- a = util_spec "a", "1", nil, "lib/a.rb"
- b = util_spec "b", "1", nil, "lib/b.rb"
- c = util_spec "c", "1", nil, "lib/c.rb"
+ a = new_spec "a", "1", nil, "lib/a.rb"
+ b = new_spec "b", "1", nil, "lib/b.rb"
+ c = new_spec "c", "1", nil, "lib/c.rb"
install_specs a, b, c
@@ -1708,9 +1589,14 @@ class TestGem < Gem::TestCase
Dir.mkdir "sub1"
path = File.join @tempdir, "gem.deps.rb"
- cmd = [Gem.ruby.dup.tap(&Gem::UNTAINT), "-Csub1", "-I#{LIB_PATH.tap(&Gem::UNTAINT)}",
- "-I#{BUNDLER_LIB_PATH.tap(&Gem::UNTAINT)}", "-rrubygems"]
- cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
+ cmd = [Gem.ruby.dup.untaint, "-Csub1", "-I#{LIB_PATH.untaint}",
+ "-I#{BUNDLER_LIB_PATH.untaint}", "-rrubygems"]
+ if RUBY_VERSION < '1.9'
+ cmd << "-e 'puts Gem.loaded_specs.values.map(&:full_name).sort'"
+ cmd = cmd.join(' ')
+ else
+ cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
+ end
File.open path, "w" do |f|
f.puts "gem 'a'"
@@ -1726,7 +1612,7 @@ class TestGem < Gem::TestCase
Dir.rmdir "sub1"
assert_equal ["b-1", "c-1"], out - out0
- end
+ end if Gem::USE_BUNDLER_FOR_GEMDEPS
def test_register_default_spec
Gem.clear_default_specs
@@ -1739,7 +1625,7 @@ class TestGem < Gem::TestCase
assert_equal old_style, Gem.find_unresolved_default_spec("foo.rb")
assert_equal old_style, Gem.find_unresolved_default_spec("bar.rb")
- assert_nil Gem.find_unresolved_default_spec("baz.rb")
+ assert_equal nil, Gem.find_unresolved_default_spec("baz.rb")
Gem.clear_default_specs
@@ -1752,24 +1638,39 @@ class TestGem < Gem::TestCase
assert_equal new_style, Gem.find_unresolved_default_spec("foo.rb")
assert_equal new_style, Gem.find_unresolved_default_spec("bar.rb")
- assert_nil Gem.find_unresolved_default_spec("exec")
- assert_nil Gem.find_unresolved_default_spec("README")
+ assert_equal nil, Gem.find_unresolved_default_spec("exec")
+ assert_equal nil, Gem.find_unresolved_default_spec("README")
end
- def test_register_default_spec_old_style_with_folder_starting_with_lib
- Gem.clear_default_specs
+ def test_default_gems_use_full_paths
+ begin
+ if defined?(RUBY_ENGINE) then
+ engine = RUBY_ENGINE
+ Object.send :remove_const, :RUBY_ENGINE
+ end
+ Object.const_set :RUBY_ENGINE, 'ruby'
- old_style = Gem::Specification.new do |spec|
- spec.files = ["libexec/bundle", "foo.rb", "bar.rb"]
+ refute Gem.default_gems_use_full_paths?
+ ensure
+ Object.send :remove_const, :RUBY_ENGINE
+ Object.const_set :RUBY_ENGINE, engine if engine
end
- Gem.register_default_spec old_style
-
- assert_equal old_style, Gem.find_unresolved_default_spec("foo.rb")
+ begin
+ if defined?(RUBY_ENGINE) then
+ engine = RUBY_ENGINE
+ Object.send :remove_const, :RUBY_ENGINE
+ end
+ Object.const_set :RUBY_ENGINE, 'jruby'
+ assert Gem.default_gems_use_full_paths?
+ ensure
+ Object.send :remove_const, :RUBY_ENGINE
+ Object.const_set :RUBY_ENGINE, engine if engine
+ end
end
def test_use_gemdeps
- gem_deps_file = 'gem.deps.rb'.tap(&Gem::UNTAINT)
+ gem_deps_file = 'gem.deps.rb'.untaint
spec = util_spec 'a', 1
install_specs spec
@@ -1830,6 +1731,7 @@ class TestGem < Gem::TestCase
end
def test_use_gemdeps_automatic
+ skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
spec = util_spec 'a', 1
@@ -1850,6 +1752,7 @@ class TestGem < Gem::TestCase
end
def test_use_gemdeps_automatic_missing
+ skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
Gem.use_gemdeps
@@ -1878,6 +1781,7 @@ class TestGem < Gem::TestCase
end
def test_use_gemdeps_missing_gem
+ skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
File.open 'x', 'w' do |io|
@@ -1890,23 +1794,29 @@ class TestGem < Gem::TestCase
else
platform = " #{platform}"
end
-
- expected = <<-EXPECTED
+ expected = if Gem::USE_BUNDLER_FOR_GEMDEPS
+ <<-EXPECTED
Could not find gem 'a#{platform}' in any of the gem sources listed in your Gemfile.
You may need to `gem install -g` to install missing gems
- EXPECTED
+ EXPECTED
+ else
+ <<-EXPECTED
+Unable to resolve dependency: user requested 'a (>= 0)'
+You may need to `gem install -g` to install missing gems
- Gem::Deprecate.skip_during do
- assert_output nil, expected do
- Gem.use_gemdeps
- end
+ EXPECTED
+ end
+
+ assert_output nil, expected do
+ Gem.use_gemdeps
end
ensure
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
- end
+ end if Gem::USE_BUNDLER_FOR_GEMDEPS
def test_use_gemdeps_specific
+ skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
spec = util_spec 'a', 1
@@ -1926,13 +1836,6 @@ You may need to `gem install -g` to install missing gems
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
end
- def test_operating_system_defaults
- operating_system_defaults = Gem.operating_system_defaults
-
- assert operating_system_defaults != nil
- assert operating_system_defaults.is_a? Hash
- end
-
def test_platform_defaults
platform_defaults = Gem.platform_defaults
@@ -1940,52 +1843,22 @@ You may need to `gem install -g` to install missing gems
assert platform_defaults.is_a? Hash
end
- # Ensure that `Gem.source_date_epoch` is consistent even if
- # $SOURCE_DATE_EPOCH has not been set.
- def test_default_source_date_epoch_doesnt_change
- old_epoch = ENV['SOURCE_DATE_EPOCH']
- ENV['SOURCE_DATE_EPOCH'] = nil
+ def ruby_install_name name
+ orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
+ RbConfig::CONFIG['ruby_install_name'] = name
- # Unfortunately, there is no real way to test this aside from waiting
- # enough for `Time.now.to_i` to change -- which is a whole second.
- #
- # Fortunately, we only need to do this once.
- a = Gem.source_date_epoch
- sleep 1
- b = Gem.source_date_epoch
- assert_equal a, b
+ yield
ensure
- ENV['SOURCE_DATE_EPOCH'] = old_epoch
- end
-
- def ruby_install_name(name)
- with_clean_path_to_ruby do
- orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
- RbConfig::CONFIG['ruby_install_name'] = name
-
- begin
- yield
- ensure
- if orig_RUBY_INSTALL_NAME
- RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
- else
- RbConfig::CONFIG.delete 'ruby_install_name'
- end
- end
- end
- end
-
- def with_bindir_and_exeext(bindir, exeext)
- bindir(bindir) do
- exeext(exeext) do
- yield
- end
+ if orig_RUBY_INSTALL_NAME then
+ RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
+ else
+ RbConfig::CONFIG.delete 'ruby_install_name'
end
end
def with_plugin(path)
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
- PROJECT_DIR)
+ @@project_dir)
# A single test plugin should get loaded once only, in order to preserve
# sane test semantics.
@@ -2028,5 +1901,4 @@ You may need to `gem install -g` to install missing gems
def util_cache_dir
File.join Gem.dir, "cache"
end
-
end
diff --git a/test/rubygems/test_gem_available_set.rb b/test/rubygems/test_gem_available_set.rb
index 64ee9a36a9..d4042c94f5 100644
--- a/test/rubygems/test_gem_available_set.rb
+++ b/test/rubygems/test_gem_available_set.rb
@@ -68,7 +68,7 @@ class TestGemAvailableSet < Gem::TestCase
def test_best
a1, _ = util_gem 'a', '1'
- a2, _ = util_gem 'a', '2'
+ a2, _ = util_gem 'a', '2'
set = Gem::AvailableSet.new
set.add a1, @source
@@ -97,7 +97,7 @@ class TestGemAvailableSet < Gem::TestCase
def test_sorted_normal_versions
a1, _ = util_gem 'a', '1'
- a2, _ = util_gem 'a', '2'
+ a2, _ = util_gem 'a', '2'
set = Gem::AvailableSet.new
set.add a1, @source
@@ -127,5 +127,4 @@ class TestGemAvailableSet < Gem::TestCase
assert_equal [a3a, a2, a2a, a1, a1a], g
end
-
end
diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb
index 34a451b64d..3b63b89423 100644
--- a/test/rubygems/test_gem_bundler_version_finder.rb
+++ b/test/rubygems/test_gem_bundler_version_finder.rb
@@ -2,10 +2,7 @@
require 'rubygems/test_case'
class TestGemBundlerVersionFinder < Gem::TestCase
-
def setup
- super
-
@argv = ARGV.dup
@env = ENV.to_hash.clone
ENV.delete("BUNDLER_VERSION")
@@ -16,8 +13,6 @@ class TestGemBundlerVersionFinder < Gem::TestCase
ARGV.replace @argv
ENV.replace @env
$0 = @dollar_0
-
- super
end
def bvf
@@ -116,7 +111,7 @@ class TestGemBundlerVersionFinder < Gem::TestCase
assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
end
bvf.stub(:bundler_version, v("2.a")) do
- assert_equal %w[2.a 2 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
+ assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
end
bvf.stub(:bundler_version, v("3")) do
assert_equal %w[3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
@@ -128,5 +123,4 @@ class TestGemBundlerVersionFinder < Gem::TestCase
bvf.filter!(specs)
specs
end
-
end
diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb
index 230baa5356..4442c6108e 100644
--- a/test/rubygems/test_gem_command.rb
+++ b/test/rubygems/test_gem_command.rb
@@ -3,9 +3,7 @@ require 'rubygems/test_case'
require 'rubygems/command'
class Gem::Command
-
public :parser
-
end
class TestGemCommand < Gem::TestCase
@@ -17,7 +15,7 @@ class TestGemCommand < Gem::TestCase
@common_options = Gem::Command.common_options.dup
Gem::Command.common_options.clear
- Gem::Command.common_options << [
+ Gem::Command.common_options << [
['-x', '--exe', 'Execute'], lambda do |*a|
@xopt = true
end
@@ -34,7 +32,7 @@ class TestGemCommand < Gem::TestCase
def test_self_add_specific_extra_args
added_args = %w[--all]
- @cmd.add_option('--all') { |v,o| }
+ @cmd.add_option '--all' do |v,o| end
Gem::Command.add_specific_extra_args @cmd_name, added_args
@@ -98,7 +96,7 @@ class TestGemCommand < Gem::TestCase
def test_invoke_with_bad_options
use_ui @ui do
- @cmd.when_invoked { true }
+ @cmd.when_invoked do true end
ex = assert_raises OptionParser::InvalidOption do
@cmd.invoke('-zzz')
@@ -109,7 +107,7 @@ class TestGemCommand < Gem::TestCase
end
def test_invoke_with_common_options
- @cmd.when_invoked { true }
+ @cmd.when_invoked do true end
use_ui @ui do
@cmd.invoke "-x"
@@ -197,122 +195,6 @@ class TestGemCommand < Gem::TestCase
assert_equal ['-h', 'command'], args
end
- def test_deprecate_option
- deprecate_msg = <<-EXPECTED
-WARNING: The \"--test\" option has been deprecated and will be removed in Rubygems 3.1.
- EXPECTED
-
- testCommand = Class.new(Gem::Command) do
- def initialize
- super('test', 'Gem::Command instance for testing')
-
- add_option('-t', '--test', 'Test command') do |value, options|
- options[:test] = true
- end
-
- deprecate_option('--test', version: '3.1')
- end
-
- def execute
- true
- end
- end
-
- cmd = testCommand.new
-
- use_ui @ui do
- cmd.invoke("--test")
- assert_equal deprecate_msg, @ui.error
- end
- end
-
- def test_deprecate_option_no_version
- deprecate_msg = <<-EXPECTED
-WARNING: The \"--test\" option has been deprecated and will be removed in future versions of Rubygems.
- EXPECTED
-
- testCommand = Class.new(Gem::Command) do
- def initialize
- super('test', 'Gem::Command instance for testing')
-
- add_option('-t', '--test', 'Test command') do |value, options|
- options[:test] = true
- end
-
- deprecate_option('--test')
- end
-
- def execute
- true
- end
- end
-
- cmd = testCommand.new
-
- use_ui @ui do
- cmd.invoke("--test")
- assert_equal deprecate_msg, @ui.error
- end
- end
-
- def test_deprecate_option_extra_message
- deprecate_msg = <<-EXPECTED
-WARNING: The \"--test\" option has been deprecated and will be removed in Rubygems 3.1. Whether you set `--test` mode or not, this dummy app always runs in test mode.
- EXPECTED
-
- testCommand = Class.new(Gem::Command) do
- def initialize
- super('test', 'Gem::Command instance for testing')
-
- add_option('-t', '--test', 'Test command') do |value, options|
- options[:test] = true
- end
-
- deprecate_option('--test', version: '3.1', extra_msg: 'Whether you set `--test` mode or not, this dummy app always runs in test mode.')
- end
-
- def execute
- true
- end
- end
-
- cmd = testCommand.new
-
- use_ui @ui do
- cmd.invoke("--test")
- assert_equal deprecate_msg, @ui.error
- end
- end
-
- def test_deprecate_option_extra_message_and_no_version
- deprecate_msg = <<-EXPECTED
-WARNING: The \"--test\" option has been deprecated and will be removed in future versions of Rubygems. Whether you set `--test` mode or not, this dummy app always runs in test mode.
- EXPECTED
-
- testCommand = Class.new(Gem::Command) do
- def initialize
- super('test', 'Gem::Command instance for testing')
-
- add_option('-t', '--test', 'Test command') do |value, options|
- options[:test] = true
- end
-
- deprecate_option('--test', extra_msg: 'Whether you set `--test` mode or not, this dummy app always runs in test mode.')
- end
-
- def execute
- true
- end
- end
-
- cmd = testCommand.new
-
- use_ui @ui do
- cmd.invoke("--test")
- assert_equal deprecate_msg, @ui.error
- end
- end
-
def test_show_lookup_failure_suggestions_local
correct = "non_existent_with_hint"
misspelled = "nonexistent_with_hint"
@@ -357,7 +239,7 @@ ERROR: Could not find a valid gem 'other' (>= 0) in any repository
end
use_ui @ui do
- @cmd.show_lookup_failure misspelled, Gem::Requirement.default, []
+ @cmd.show_lookup_failure misspelled, Gem::Requirement.default, [], :remote
end
expected = <<-EXPECTED
@@ -369,3 +251,4 @@ ERROR: Possible alternatives: non_existent_with_hint
end
end
+
diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb
index 45be9f01be..2d2fc7d7a0 100644
--- a/test/rubygems/test_gem_command_manager.rb
+++ b/test/rubygems/test_gem_command_manager.rb
@@ -4,8 +4,6 @@ require 'rubygems/command_manager'
class TestGemCommandManager < Gem::TestCase
- PROJECT_DIR = File.expand_path('../../..', __FILE__).tap(&Gem::UNTAINT)
-
def setup
super
@@ -31,12 +29,6 @@ class TestGemCommandManager < Gem::TestCase
e.message
end
- def test_find_alias_command
- command = @command_manager.find_command 'i'
-
- assert_kind_of Gem::Commands::InstallCommand, command
- end
-
def test_find_command_ambiguous_exact
ins_command = Class.new
Gem::Commands.send :const_set, :InsCommand, ins_command
@@ -60,7 +52,7 @@ class TestGemCommandManager < Gem::TestCase
def test_run_interrupt
old_load_path = $:.dup
- $: << File.expand_path("test/rubygems", PROJECT_DIR)
+ $: << File.expand_path("test/rubygems", @@project_dir)
Gem.load_env_plugins
@command_manager.register_command :interrupt
@@ -79,7 +71,7 @@ class TestGemCommandManager < Gem::TestCase
def test_run_crash_command
old_load_path = $:.dup
- $: << File.expand_path("test/rubygems", PROJECT_DIR)
+ $: << File.expand_path("test/rubygems", @@project_dir)
@command_manager.register_command :crash
use_ui @ui do
@@ -122,14 +114,14 @@ class TestGemCommandManager < Gem::TestCase
assert_equal :both, check_options[:domain]
assert_equal true, check_options[:wrappers]
assert_equal Gem::Requirement.default, check_options[:version]
- assert_nil check_options[:install_dir]
- assert_nil check_options[:bin_dir]
+ assert_equal nil, check_options[:install_dir]
+ assert_equal nil, check_options[:bin_dir]
#check settings
check_options = nil
@command_manager.process_args %w[
- install --force --local --document=ri,rdoc --install-dir .
- --version 3.0 --no-wrapper --bindir .
+ install --force --local --rdoc --install-dir .
+ --version 3.0 --no-wrapper --bindir .
]
assert_equal %w[rdoc ri], check_options[:document].sort
assert_equal true, check_options[:force]
@@ -262,10 +254,11 @@ class TestGemCommandManager < Gem::TestCase
#check settings
check_options = nil
- @command_manager.process_args %w[update --force --document=ri --install-dir .]
+ @command_manager.process_args %w[update --force --rdoc --install-dir .]
assert_includes check_options[:document], 'ri'
assert_equal true, check_options[:force]
assert_equal Dir.pwd, check_options[:install_dir]
end
end
+
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index 309e15f859..08854f0bf1 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -6,71 +6,16 @@ require 'rubygems/package'
class TestGemCommandsBuildCommand < Gem::TestCase
- CERT_FILE = cert_path 'public3072'
- SIGNING_KEY = key_path 'private3072'
-
- EXPIRED_CERT_FILE = cert_path 'expired'
- PRIVATE_KEY_FILE = key_path 'private'
-
def setup
super
- readme_file = File.join(@tempdir, 'README.md')
-
- File.open readme_file, 'w' do |f|
- f.write 'My awesome gem'
- end
-
@gem = util_spec 'some_gem' do |s|
- s.license = 'AGPL-3.0'
- s.files = ['README.md']
+ s.rubyforge_project = 'example'
end
@cmd = Gem::Commands::BuildCommand.new
end
- def test_handle_options
- @cmd.handle_options %w[--force --strict]
-
- assert @cmd.options[:force]
- assert @cmd.options[:strict]
- end
-
- def test_options_filename
- gemspec_file = File.join(@tempdir, @gem.spec_name)
-
- File.open gemspec_file, 'w' do |gs|
- gs.write @gem.to_ruby
- end
-
- @cmd.options[:args] = [gemspec_file]
- @cmd.options[:output] = "test.gem"
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- file = File.join(@tempdir, File::SEPARATOR, "test.gem")
- assert File.exist?(file)
-
- output = @ui.output.split "\n"
- assert_equal " Successfully built RubyGem", output.shift
- assert_equal " Name: some_gem", output.shift
- assert_equal " Version: 2", output.shift
- assert_equal " File: test.gem", output.shift
- assert_equal [], output
- end
-
- def test_handle_options_defaults
- @cmd.handle_options []
-
- refute @cmd.options[:force]
- refute @cmd.options[:strict]
- assert_nil @cmd.options[:output]
- end
-
def test_execute
gemspec_file = File.join(@tempdir, @gem.spec_name)
@@ -78,97 +23,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
gs.write @gem.to_ruby
end
- @cmd.options[:args] = [gemspec_file]
-
- util_test_build_gem @gem
- end
-
- def test_execute_bad_name
- [".", "-", "_"].each do |special_char|
- gem = util_spec 'some_gem_with_bad_name' do |s|
- s.name = "#{special_char}bad_gem_name"
- s.license = 'AGPL-3.0'
- s.files = ['README.md']
- end
-
- gemspec_file = File.join(@tempdir, gem.spec_name)
-
- File.open gemspec_file, 'w' do |gs|
- gs.write gem.to_ruby
- end
-
- @cmd.options[:args] = [gemspec_file]
-
- use_ui @ui do
- Dir.chdir @tempdir do
- assert_raises Gem::InvalidSpecificationException do
- @cmd.execute
- end
- end
- end
- end
- end
-
- def test_execute_strict_without_warnings
- gemspec_file = File.join(@tempdir, @gem.spec_name)
-
- File.open gemspec_file, 'w' do |gs|
- gs.write @gem.to_ruby
- end
-
- @cmd.options[:strict] = true
- @cmd.options[:args] = [gemspec_file]
-
- util_test_build_gem @gem
- end
-
- def test_execute_rubyforge_project_warning
- rubyforge_gemspec = File.join SPECIFICATIONS, "rubyforge-0.0.1.gemspec"
-
- @cmd.options[:args] = [rubyforge_gemspec]
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- error = @ui.error.split("\n")
- assert_equal "WARNING: rubyforge_project= is deprecated and ignored. Please remove this from your gemspec to ensure that your gem continues to build in the future.", error.shift
- assert_equal "WARNING: See https://guides.rubygems.org/specification-reference/ for help", error.shift
- assert_equal [], error
- end
-
- def test_execute_strict_with_warnings
- bad_gem = util_spec 'some_bad_gem' do |s|
- s.files = ['README.md']
- end
-
- gemspec_file = File.join(@tempdir, bad_gem.spec_name)
-
- File.open gemspec_file, 'w' do |gs|
- gs.write bad_gem.to_ruby
- end
-
- @cmd.options[:args] = [gemspec_file]
- @cmd.options[:strict] = true
-
- use_ui @ui do
- Dir.chdir @tempdir do
- assert_raises Gem::InvalidSpecificationException do
- @cmd.execute
- end
- end
- end
-
- error = @ui.error.split "\n"
- assert_equal "WARNING: licenses is empty, but is recommended. Use a license identifier from", error.shift
- assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.", error.shift
- assert_equal "WARNING: See https://guides.rubygems.org/specification-reference/ for help", error.shift
- assert_equal [], error
-
- gem_file = File.join @tempdir, File.basename(@gem.cache_file)
- refute File.exist?(gem_file)
+ util_test_build_gem @gem, gemspec_file
end
def test_execute_bad_spec
@@ -206,45 +61,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
assert_equal '', @ui.output
- assert_equal "ERROR: Gemspec file not found: some_gem.gemspec\n", @ui.error
- end
-
- def test_execute_outside_dir
- gemspec_dir = File.join @tempdir, 'build_command_gem'
- gemspec_file = File.join gemspec_dir, @gem.spec_name
- readme_file = File.join gemspec_dir, 'README.md'
-
- FileUtils.mkdir_p gemspec_dir
-
- File.open readme_file, 'w' do |f|
- f.write "My awesome gem"
- end
-
- File.open gemspec_file, 'w' do |gs|
- gs.write @gem.to_ruby
- end
-
- @cmd.options[:build_path] = gemspec_dir
- @cmd.options[:args] = [gemspec_file]
-
- use_ui @ui do
- @cmd.execute
- end
-
- output = @ui.output.split "\n"
- assert_equal " Successfully built RubyGem", output.shift
- assert_equal " Name: some_gem", output.shift
- assert_equal " Version: 2", output.shift
- assert_equal " File: some_gem-2.gem", output.shift
- assert_equal [], output
-
- gem_file = File.join gemspec_dir, File.basename(@gem.cache_file)
- assert File.exist?(gem_file)
-
- spec = Gem::Package.new(gem_file).spec
-
- assert_equal "some_gem", spec.name
- assert_equal "this is a summary", spec.summary
+ assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error
end
def test_can_find_gemspecs_without_dot_gemspec
@@ -254,77 +71,12 @@ class TestGemCommandsBuildCommand < Gem::TestCase
gs.write @gem.to_ruby
end
- @cmd.options[:args] = [gemspec_file]
-
- util_test_build_gem @gem
+ util_test_build_gem @gem, gemspec_file
end
- def test_execute_without_gem_name
- some_gem = util_spec "some_gem"
- gemspec_dir = File.join(@tempdir, "build_command_gem")
- gemspec_file = File.join(gemspec_dir, some_gem.spec_name)
-
- FileUtils.mkdir_p(gemspec_dir)
-
- File.open(gemspec_file, "w") do |gs|
- gs.write(some_gem.to_ruby)
- end
-
- @cmd.options[:args] = []
-
- use_ui @ui do
- Dir.chdir(gemspec_dir) do
- @cmd.execute
- end
- end
-
- output = @ui.output.split("\n")
- assert_equal " Successfully built RubyGem", output.shift
- assert_equal " Name: some_gem", output.shift
- assert_equal " Version: 2", output.shift
- assert_equal " File: some_gem-2.gem", output.shift
- assert_equal [], output
-
- some_gem = File.join(gemspec_dir, File.basename(some_gem.cache_file))
- assert File.exist?(some_gem)
- end
-
- def test_execute_multiple_gemspec_without_gem_name
- some_gem = util_spec "some_gem"
- another_gem = util_spec "another_gem"
- gemspec_dir = File.join(@tempdir, "build_command_gem")
- gemspec_file = File.join(gemspec_dir, some_gem.spec_name)
- another_gemspec_file = File.join(gemspec_dir, another_gem.spec_name)
-
- FileUtils.mkdir_p(gemspec_dir)
-
- File.open(gemspec_file, "w") do |gs|
- gs.write(some_gem.to_ruby)
- end
-
- File.open(another_gemspec_file, "w") do |gs|
- gs.write(another_gem.to_ruby)
- end
-
- @cmd.options[:args] = []
-
- use_ui @ui do
- Dir.chdir(gemspec_dir) do
- assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
- end
- end
-
- gemspecs = ["another_gem-2.gemspec", "some_gem-2.gemspec"]
- assert_equal "", @ui.output
- assert_equal @ui.error, "ERROR: Multiple gemspecs found: #{gemspecs}, please specify one\n"
-
- expected_gem = File.join(gemspec_dir, File.basename(another_gem.cache_file))
- refute File.exist?(expected_gem)
- end
+ def util_test_build_gem(gem, gemspec_file, check_licenses=true)
+ @cmd.options[:args] = [gemspec_file]
- def util_test_build_gem(gem)
use_ui @ui do
Dir.chdir @tempdir do
@cmd.execute
@@ -338,7 +90,11 @@ class TestGemCommandsBuildCommand < Gem::TestCase
assert_equal " File: some_gem-2.gem", output.shift
assert_equal [], output
- gem_file = File.join(@tempdir, File.basename(gem.cache_file))
+ if check_licenses
+ assert_match "WARNING: licenses is empty", @ui.error
+ end
+
+ gem_file = File.join @tempdir, File.basename(gem.cache_file)
assert File.exist?(gem_file)
spec = Gem::Package.new(gem_file).spec
@@ -359,12 +115,13 @@ class TestGemCommandsBuildCommand < Gem::TestCase
@cmd.options[:args] = [gemspec_file]
@cmd.options[:force] = true
- util_test_build_gem @gem
+ util_test_build_gem @gem, gemspec_file, false
end
- def test_build_signed_gem
- skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
+ CERT_FILE = cert_path 'public3072'
+ SIGNING_KEY = key_path 'private3072'
+ def test_build_signed_gem
trust_dir = Gem::Security.trust_dir
spec = util_spec 'some_gem' do |s|
@@ -378,9 +135,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
gs.write spec.to_ruby
end
- @cmd.options[:args] = [gemspec_file]
-
- util_test_build_gem spec
+ util_test_build_gem spec, gemspec_file
trust_dir.trust_cert OpenSSL::X509::Certificate.new(File.read(CERT_FILE))
@@ -389,121 +144,4 @@ class TestGemCommandsBuildCommand < Gem::TestCase
assert gem.verify
end
- def test_build_signed_gem_with_cert_expiration_length_days
- skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
-
- gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
-
- Gem::Security.trust_dir
-
- tmp_expired_cert_file = File.join gem_path, "gem-public_cert.pem"
- File.write(tmp_expired_cert_file, File.read(EXPIRED_CERT_FILE))
-
- tmp_private_key_file = File.join gem_path, "gem-private_key.pem"
- File.write(tmp_private_key_file, File.read(PRIVATE_KEY_FILE))
-
- spec = util_spec 'some_gem' do |s|
- s.signing_key = tmp_private_key_file
- s.cert_chain = [tmp_expired_cert_file]
- end
-
- gemspec_file = File.join(@tempdir, spec.spec_name)
-
- File.open gemspec_file, 'w' do |gs|
- gs.write spec.to_ruby
- end
-
- @cmd.options[:args] = [gemspec_file]
-
- Gem.configuration.cert_expiration_length_days = 28
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- re_signed_cert = OpenSSL::X509::Certificate.new(File.read(tmp_expired_cert_file))
- cert_days_to_expire = (re_signed_cert.not_after - re_signed_cert.not_before).to_i / (24 * 60 * 60)
-
- gem_file = File.join @tempdir, File.basename(spec.cache_file)
-
- assert File.exist?(gem_file)
- assert_equal(28, cert_days_to_expire)
- end
-
- def test_build_auto_resign_cert
- skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
-
- gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
-
- Gem::Security.trust_dir
-
- tmp_expired_cert_file = File.join gem_path, "gem-public_cert.pem"
- File.write(tmp_expired_cert_file, File.read(EXPIRED_CERT_FILE))
-
- tmp_private_key_file = File.join gem_path, "gem-private_key.pem"
- File.write(tmp_private_key_file, File.read(PRIVATE_KEY_FILE))
-
- spec = util_spec 'some_gem' do |s|
- s.signing_key = tmp_private_key_file
- s.cert_chain = [tmp_expired_cert_file]
- end
-
- gemspec_file = File.join(@tempdir, spec.spec_name)
-
- File.open gemspec_file, 'w' do |gs|
- gs.write spec.to_ruby
- end
-
- @cmd.options[:args] = [gemspec_file]
-
- Gem.configuration.cert_expiration_length_days = 28
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- output = @ui.output.split "\n"
- assert_equal "INFO: Your certificate has expired, trying to re-sign it...", output.shift
- assert_equal "INFO: Your cert: #{tmp_expired_cert_file } has been auto re-signed with the key: #{tmp_private_key_file}", output.shift
- assert_match(/INFO: Your expired cert will be located at: .+\Wgem-public_cert\.pem\.expired\.[0-9]+/, output.shift)
- end
-
- def test_build_is_reproducible
- epoch = ENV["SOURCE_DATE_EPOCH"]
- new_epoch = Time.now.to_i.to_s
- ENV["SOURCE_DATE_EPOCH"] = new_epoch
-
- gem_file = File.basename(@gem.cache_file)
-
- gemspec_file = File.join(@tempdir, @gem.spec_name)
- File.write(gemspec_file, @gem.to_ruby)
- @cmd.options[:args] = [gemspec_file]
-
- util_test_build_gem @gem
-
- build1_contents = File.read(gem_file)
-
- # Guarantee the time has changed.
- sleep 1 if Time.now.to_i == new_epoch
-
- ENV["SOURCE_DATE_EPOCH"] = new_epoch
-
- @ui = Gem::MockGemUi.new
- @cmd.options[:args] = [gemspec_file]
-
- util_test_build_gem @gem
-
- build2_contents = File.read(gem_file)
-
- assert_equal build1_contents, build2_contents
- ensure
- ENV["SOURCE_DATE_EPOCH"] = epoch
- end
-
end
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb
index fd1e66b915..2d38a57bc4 100644
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ b/test/rubygems/test_gem_commands_cert_command.rb
@@ -1,28 +1,23 @@
# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems/commands/cert_command'
+require 'rubygems/fix_openssl_warnings' if RUBY_VERSION < "1.9"
-unless defined?(OpenSSL::SSL)
+unless defined?(OpenSSL::SSL) then
warn 'Skipping `gem cert` tests. openssl not found.'
end
-if Gem.java_platform?
- warn 'Skipping `gem cert` tests on jruby.'
-end
-
class TestGemCommandsCertCommand < Gem::TestCase
ALTERNATE_CERT = load_cert 'alternate'
- EXPIRED_PUBLIC_CERT = load_cert 'expired'
ALTERNATE_KEY_FILE = key_path 'alternate'
PRIVATE_KEY_FILE = key_path 'private'
PUBLIC_KEY_FILE = key_path 'public'
- ALTERNATE_CERT_FILE = cert_path 'alternate'
- CHILD_CERT_FILE = cert_path 'child'
- PUBLIC_CERT_FILE = cert_path 'public'
- EXPIRED_PUBLIC_CERT_FILE = cert_path 'expired'
+ ALTERNATE_CERT_FILE = cert_path 'alternate'
+ CHILD_CERT_FILE = cert_path 'child'
+ PUBLIC_CERT_FILE = cert_path 'public'
def setup
super
@@ -30,14 +25,6 @@ class TestGemCommandsCertCommand < Gem::TestCase
@cmd = Gem::Commands::CertCommand.new
@trust_dir = Gem::Security.trust_dir
-
- @cleanup = []
- end
-
- def teardown
- FileUtils.rm_f(@cleanup)
-
- super
end
def test_certificates_matching
@@ -171,7 +158,7 @@ Added '/CN=alternate/DC=example'
@cmd.handle_options %W[
--build nobody@example.com
--days 26
- ]
+ ]
@build_ui = Gem::MockGemUi.new "#{passphrase}\n#{passphrase}"
@@ -204,6 +191,7 @@ Added '/CN=alternate/DC=example'
test = (cert.not_after - cert.not_before).to_i / (24 * 60 * 60)
assert_equal(test, 26)
+
end
def test_execute_build_bad_passphrase_confirmation
@@ -595,70 +583,6 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
assert_equal expected, @ui.error
end
- def test_execute_re_sign
- gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
-
- path = File.join @tempdir, 'cert.pem'
- Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
-
- assert_equal '/CN=nobody/DC=example', EXPIRED_PUBLIC_CERT.issuer.to_s
-
- tmp_expired_cert_file = File.join(Dir.tmpdir, File.basename(EXPIRED_PUBLIC_CERT_FILE))
- @cleanup << tmp_expired_cert_file
- File.write(tmp_expired_cert_file, File.read(EXPIRED_PUBLIC_CERT_FILE))
-
- @cmd.handle_options %W[
- --private-key #{PRIVATE_KEY_FILE}
- --certificate #{tmp_expired_cert_file}
- --re-sign
- ]
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected_path = File.join(gem_path, "#{File.basename(tmp_expired_cert_file)}.expired")
-
- assert_match(
- /INFO: Your certificate #{tmp_expired_cert_file} has been re-signed\nINFO: Your expired certificate will be located at: #{expected_path}\.[0-9]+/,
- @ui.output
- )
- assert_equal '', @ui.error
- end
-
- def test_execute_re_sign_with_cert_expiration_length_days
- gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
-
- path = File.join @tempdir, 'cert.pem'
- Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
-
- assert_equal '/CN=nobody/DC=example', EXPIRED_PUBLIC_CERT.issuer.to_s
-
- tmp_expired_cert_file = File.join(Dir.tmpdir, File.basename(EXPIRED_PUBLIC_CERT_FILE))
- @cleanup << tmp_expired_cert_file
- File.write(tmp_expired_cert_file, File.read(EXPIRED_PUBLIC_CERT_FILE))
-
- @cmd.handle_options %W[
- --private-key #{PRIVATE_KEY_FILE}
- --certificate #{tmp_expired_cert_file}
- --re-sign
- ]
-
- Gem.configuration.cert_expiration_length_days = 28
-
- use_ui @ui do
- @cmd.execute
- end
-
- re_signed_cert = OpenSSL::X509::Certificate.new(File.read(tmp_expired_cert_file))
- cert_days_to_expire = (re_signed_cert.not_after - re_signed_cert.not_before).to_i / (24 * 60 * 60)
-
- assert_equal(28, cert_days_to_expire)
- assert_equal '', @ui.error
- end
-
def test_handle_options
@cmd.handle_options %W[
--add #{PUBLIC_CERT_FILE}
@@ -807,4 +731,5 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
e.message
end
-end if defined?(OpenSSL::SSL) && !Gem.java_platform?
+end if defined?(OpenSSL::SSL)
+
diff --git a/test/rubygems/test_gem_commands_check_command.rb b/test/rubygems/test_gem_commands_check_command.rb
index 6a6033d35d..b220b4d36c 100644
--- a/test/rubygems/test_gem_commands_check_command.rb
+++ b/test/rubygems/test_gem_commands_check_command.rb
@@ -10,7 +10,7 @@ class TestGemCommandsCheckCommand < Gem::TestCase
@cmd = Gem::Commands::CheckCommand.new
end
- def gem(name)
+ def gem name
spec = quick_gem name do |gem|
gem.files = %W[lib/#{name}.rb Rakefile]
end
diff --git a/test/rubygems/test_gem_commands_cleanup_command.rb b/test/rubygems/test_gem_commands_cleanup_command.rb
index 3494085a64..60d208fcc0 100644
--- a/test/rubygems/test_gem_commands_cleanup_command.rb
+++ b/test/rubygems/test_gem_commands_cleanup_command.rb
@@ -56,13 +56,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
end
def test_execute_all_dependencies
- @b_1 = util_spec 'b', 1 do |s|
- s.add_dependency 'a', '1'
- end
-
- @b_2 = util_spec 'b', 2 do |s|
- s.add_dependency 'a', '2'
- end
+ @b_1 = util_spec 'b', 1 do |s| s.add_dependency 'a', '1' end
+ @b_2 = util_spec 'b', 2 do |s| s.add_dependency 'a', '2' end
install_gem @b_1
install_gem @b_2
@@ -76,13 +71,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
end
def test_execute_dev_dependencies
- @b_1 = util_spec 'b', 1 do |s|
- s.add_development_dependency 'a', '1'
- end
-
- @c_1 = util_spec 'c', 1 do |s|
- s.add_development_dependency 'a', '2'
- end
+ @b_1 = util_spec 'b', 1 do |s| s.add_development_dependency 'a', '1' end
+ @c_1 = util_spec 'c', 1 do |s| s.add_development_dependency 'a', '2' end
install_gem @b_1
install_gem @c_1
@@ -95,13 +85,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
end
def test_execute_without_dev_dependencies
- @b_1 = util_spec 'b', 1 do |s|
- s.add_development_dependency 'a', '1'
- end
-
- @c_1 = util_spec 'c', 1 do |s|
- s.add_development_dependency 'a', '2'
- end
+ @b_1 = util_spec 'b', 1 do |s| s.add_development_dependency 'a', '1' end
+ @c_1 = util_spec 'c', 1 do |s| s.add_development_dependency 'a', '2' end
install_gem @b_1
install_gem @c_1
@@ -251,32 +236,5 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
refute_path_exists d_1.gem_dir
refute_path_exists e_1.gem_dir
end
-
- def test_execute_user_install
- c_1, = util_gem 'c', '1.0'
- c_2, = util_gem 'c', '1.1'
-
- d_1, = util_gem 'd', '1.0'
- d_2, = util_gem 'd', '1.1'
-
- c_1 = install_gem c_1, :user_install => true # pick up user install path
- c_2 = install_gem c_2, :user_install => true # pick up user install path
-
- d_1 = install_gem d_1
- d_2 = install_gem d_2
-
- Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
-
- @cmd.handle_options %w[--user-install]
- @cmd.options[:args] = []
-
- @cmd.execute
-
- refute_path_exists c_1.gem_dir
- assert_path_exists c_2.gem_dir
-
- assert_path_exists d_1.gem_dir
- assert_path_exists d_2.gem_dir
- end
-
end
+
diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb
index a8d6efe794..65644f476b 100644
--- a/test/rubygems/test_gem_commands_contents_command.rb
+++ b/test/rubygems/test_gem_commands_contents_command.rb
@@ -10,7 +10,7 @@ class TestGemCommandsContentsCommand < Gem::TestCase
@cmd = Gem::Commands::ContentsCommand.new
end
- def gem(name, version = 2)
+ def gem name, version = 2
spec = quick_gem name, version do |gem|
gem.files = %W[lib/#{name}.rb Rakefile]
end
@@ -237,3 +237,4 @@ lib/foo.rb
end
end
+
diff --git a/test/rubygems/test_gem_commands_dependency_command.rb b/test/rubygems/test_gem_commands_dependency_command.rb
index eaa9594163..d0389ccf55 100644
--- a/test/rubygems/test_gem_commands_dependency_command.rb
+++ b/test/rubygems/test_gem_commands_dependency_command.rb
@@ -6,7 +6,7 @@ class TestGemCommandsDependencyCommand < Gem::TestCase
def setup
super
- @stub_ui = Gem::MockGemUi.new
+
@cmd = Gem::Commands::DependencyCommand.new
@cmd.options[:domain] = :local
end
@@ -19,17 +19,17 @@ class TestGemCommandsDependencyCommand < Gem::TestCase
@cmd.options[:args] = %w[foo]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
assert_equal "Gem foo-2\n bar (> 1)\n baz (> 1)\n\n",
- @stub_ui.output
- assert_equal '', @stub_ui.error
+ @ui.output
+ assert_equal '', @ui.error
end
def test_execute_no_args
- install_specs util_spec 'x', '2'
+ install_specs new_spec 'x', '2'
spec_fetcher do |fetcher|
fetcher.spec 'a', 1
@@ -40,7 +40,7 @@ class TestGemCommandsDependencyCommand < Gem::TestCase
@cmd.options[:args] = []
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -58,21 +58,21 @@ Gem x-2
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_no_match
@cmd.options[:args] = %w[foo]
assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal "No gems found matching foo (>= 0)\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "No gems found matching foo (>= 0)\n", @ui.output
+ assert_equal '', @ui.error
end
def test_execute_pipe_format
@@ -85,12 +85,12 @@ Gem x-2
@cmd.options[:args] = %w[foo]
@cmd.options[:pipe_format] = true
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- assert_equal "bar --version '> 1'\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "bar --version '> 1'\n", @ui.output
+ assert_equal '', @ui.error
end
def test_execute_regexp
@@ -101,9 +101,9 @@ Gem x-2
fetcher.spec 'b', 2
end
- @cmd.options[:args] = %w[[ab]]
+ @cmd.options[:args] = %w[/[ab]/]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -118,8 +118,8 @@ Gem b-2
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_reverse
@@ -135,7 +135,7 @@ Gem b-2
@cmd.options[:args] = %w[foo]
@cmd.options[:reverse_dependencies] = true
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -147,8 +147,8 @@ Gem foo-2
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_reverse_remote
@@ -157,7 +157,7 @@ Gem foo-2
@cmd.options[:domain] = :remote
assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
@@ -166,12 +166,12 @@ Gem foo-2
ERROR: Only reverse dependencies for local gems are supported.
EOF
- assert_equal '', @stub_ui.output
- assert_equal expected, @stub_ui.error
+ assert_equal '', @ui.output
+ assert_equal expected, @ui.error
end
def test_execute_remote
- install_specs util_spec 'bar', '2'
+ install_specs new_spec 'bar', '2'
spec_fetcher do |fetcher|
fetcher.spec 'foo', 2, 'bar' => '> 1'
@@ -180,12 +180,12 @@ ERROR: Only reverse dependencies for local gems are supported.
@cmd.options[:args] = %w[foo]
@cmd.options[:domain] = :remote
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- assert_equal "Gem foo-2\n bar (> 1)\n\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
+ assert_equal '', @ui.error
end
def test_execute_remote_version
@@ -201,12 +201,12 @@ ERROR: Only reverse dependencies for local gems are supported.
@cmd.options[:domain] = :remote
@cmd.options[:version] = req '= 1'
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- assert_equal "Gem a-1\n\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "Gem a-1\n\n", @ui.output
+ assert_equal '', @ui.error
end
def test_execute_prerelease
@@ -218,12 +218,13 @@ ERROR: Only reverse dependencies for local gems are supported.
@cmd.options[:domain] = :remote
@cmd.options[:prerelease] = true
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- assert_equal "Gem a-2.a\n\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "Gem a-2.a\n\n", @ui.output
+ assert_equal '', @ui.error
end
end
+
diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
index 5dd0fc7521..040e5c4c39 100644
--- a/test/rubygems/test_gem_commands_environment_command.rb
+++ b/test/rubygems/test_gem_commands_environment_command.rb
@@ -29,7 +29,6 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_match %r|RUBYGEMS PREFIX: |, @ui.output
assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|,
@ui.output
- assert_match %r|GIT EXECUTABLE: #{@cmd.send(:git_path)}|, @ui.output
assert_match %r|SYSTEM CONFIGURATION DIRECTORY:|, @ui.output
assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output
assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
@@ -90,6 +89,17 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_equal '', @ui.error
end
+ def test_execute_packageversion
+ @cmd.send :handle_options, %w[packageversion]
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ assert_equal "#{Gem::RubyGemsPackageVersion}\n", @ui.output
+ assert_equal '', @ui.error
+ end
+
def test_execute_remotesources
orig_sources = Gem.sources.dup
Gem.sources.replace %w[http://gems.example.com]
@@ -141,5 +151,4 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
assert_equal "#{Gem.platforms.join File::PATH_SEPARATOR}\n", @ui.output
assert_equal '', @ui.error
end
-
end
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
index 9989f57bd7..6858327ed3 100644
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ b/test/rubygems/test_gem_commands_fetch_command.rb
@@ -124,3 +124,4 @@ class TestGemCommandsFetchCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_commands_generate_index_command.rb b/test/rubygems/test_gem_commands_generate_index_command.rb
index d8fda32fc0..7e30a6dccf 100644
--- a/test/rubygems/test_gem_commands_generate_index_command.rb
+++ b/test/rubygems/test_gem_commands_generate_index_command.rb
@@ -3,10 +3,6 @@ require 'rubygems/test_case'
require 'rubygems/indexer'
require 'rubygems/commands/generate_index_command'
-unless defined?(Builder::XChar)
- warn "generate_index tests are being skipped. Install builder gem."
-end
-
class TestGemCommandsGenerateIndexCommand < Gem::TestCase
def setup
@@ -26,18 +22,6 @@ class TestGemCommandsGenerateIndexCommand < Gem::TestCase
assert File.exist?(specs), specs
end
- def test_execute_no_modern
- @cmd.options[:modern] = false
-
- use_ui @ui do
- @cmd.execute
- end
-
- specs = File.join @gemhome, "specs.4.8.gz"
-
- assert File.exist?(specs), specs
- end
-
def test_handle_options_directory
return if win_platform?
refute_equal '/nonexistent', @cmd.options[:directory]
@@ -63,24 +47,5 @@ class TestGemCommandsGenerateIndexCommand < Gem::TestCase
assert @cmd.options[:update]
end
- def test_handle_options_modern
- use_ui @ui do
- @cmd.handle_options %w[--modern]
- end
-
- assert_equal \
- "WARNING: The \"--modern\" option has been deprecated and will be removed in Rubygems 4.0. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.\n",
- @ui.error
- end
-
- def test_handle_options_no_modern
- use_ui @ui do
- @cmd.handle_options %w[--no-modern]
- end
-
- assert_equal \
- "WARNING: The \"--no-modern\" option has been deprecated and will be removed in Rubygems 4.0. The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.\n",
- @ui.error
- end
+end if ''.respond_to? :to_xs
-end if defined?(Builder::XChar)
diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb
index f2a519775c..986df1a9a5 100644
--- a/test/rubygems/test_gem_commands_help_command.rb
+++ b/test/rubygems/test_gem_commands_help_command.rb
@@ -4,15 +4,16 @@ require "rubygems/test_case"
require "rubygems/commands/help_command"
require "rubygems/package"
require "rubygems/command_manager"
+require File.expand_path('../rubygems_plugin', __FILE__)
class TestGemCommandsHelpCommand < Gem::TestCase
-
def setup
super
@cmd = Gem::Commands::HelpCommand.new
- load File.expand_path('../rubygems_plugin.rb', __FILE__) unless Gem::Commands.const_defined? :InterruptCommand
+ load File.expand_path('../rubygems_plugin.rb', __FILE__) unless
+ Gem::Commands.const_defined? :InterruptCommand
end
def test_gem_help_bad
@@ -44,7 +45,7 @@ class TestGemCommandsHelpCommand < Gem::TestCase
assert_match(/\s+#{cmd}\s+\S+/, out)
end
- if defined?(OpenSSL::SSL)
+ if defined?(OpenSSL::SSL) then
assert_empty err
refute_match 'No command found for ', out
@@ -60,7 +61,7 @@ class TestGemCommandsHelpCommand < Gem::TestCase
end
end
- def util_gem(*args)
+ def util_gem *args
@cmd.options[:args] = args
use_ui @ui do
@@ -71,5 +72,4 @@ class TestGemCommandsHelpCommand < Gem::TestCase
yield @ui.output, @ui.error
end
-
end
diff --git a/test/rubygems/test_gem_commands_info_command.rb b/test/rubygems/test_gem_commands_info_command.rb
deleted file mode 100644
index 373fccceee..0000000000
--- a/test/rubygems/test_gem_commands_info_command.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: true
-require 'rubygems/test_case'
-require 'rubygems/commands/info_command'
-
-class TestGemCommandsInfoCommand < Gem::TestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::InfoCommand.new
- end
-
- def gem(name, version = "1.0")
- spec = quick_gem name do |gem|
- gem.summary = "test gem"
- gem.homepage = "https://github.com/rubygems/rubygems"
- gem.files = %W[lib/#{name}.rb Rakefile]
- gem.authors = ["Colby", "Jack"]
- gem.license = "MIT"
- gem.version = version
- end
- write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
- write_file File.join(*%W[gems #{spec.full_name} Rakefile])
- spec
- end
-
- def test_execute
- @gem = gem "foo", "1.0.0"
-
- @cmd.handle_options %w[foo]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r%#{@gem.name} \(#{@gem.version}\)\n%, @ui.output
- assert_match %r%Authors: #{@gem.authors.join(', ')}\n%, @ui.output
- assert_match %r%Homepage: #{@gem.homepage}\n%, @ui.output
- assert_match %r%License: #{@gem.license}\n%, @ui.output
- assert_match %r%Installed at: #{@gem.base_dir}\n%, @ui.output
- assert_match %r%#{@gem.summary}\n%, @ui.output
- assert_match "", @ui.error
- end
-
-end
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index a233377c4a..822d40e3f3 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -55,7 +55,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
a2_pre = specs['a-2.a']
@cmd.handle_options [a2_pre.name, '--version', a2_pre.version.to_s,
- "--no-document"]
+ "--no-ri", "--no-rdoc"]
assert @cmd.options[:prerelease]
assert @cmd.options[:version].satisfied_by?(a2_pre.version)
@@ -96,64 +96,6 @@ class TestGemCommandsInstallCommand < Gem::TestCase
assert_match "1 gem installed", @ui.output
end
- def test_execute_local_dependency_nonexistent
- specs = spec_fetcher do |fetcher|
- fetcher.gem 'foo', 2, 'bar' => '0.5'
- end
-
- @cmd.options[:domain] = :local
-
- FileUtils.mv specs['foo-2'].cache_file, @tempdir
-
- @cmd.options[:args] = ['foo']
-
- use_ui @ui do
- orig_dir = Dir.pwd
- begin
- Dir.chdir @tempdir
- e = assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
- assert_equal 2, e.exit_code
- ensure
- Dir.chdir orig_dir
- end
- end
-
- expected = <<-EXPECTED
-ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in any repository
- EXPECTED
-
- assert_equal expected, @ui.error
- end
-
- def test_execute_local_dependency_nonexistent_ignore_dependencies
- specs = spec_fetcher do |fetcher|
- fetcher.gem 'foo', 2, 'bar' => '0.5'
- end
-
- @cmd.options[:domain] = :local
- @cmd.options[:ignore_dependencies] = true
-
- FileUtils.mv specs['foo-2'].cache_file, @tempdir
-
- @cmd.options[:args] = ['foo']
-
- use_ui @ui do
- orig_dir = Dir.pwd
- begin
- Dir.chdir orig_dir
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- ensure
- Dir.chdir orig_dir
- end
- end
-
- assert_match "1 gem installed", @ui.output
- end
-
def test_execute_local_transitive_prerelease
specs = spec_fetcher do |fetcher|
fetcher.download 'a', 2, 'b' => "2.a", 'c' => '3'
@@ -236,25 +178,6 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a
assert_match(/ould not find a valid gem 'no_such_gem'/, @ui.error)
end
- def test_execute_local_missing_ignore_dependencies
- spec_fetcher
-
- @cmd.options[:domain] = :local
- @cmd.options[:ignore_dependencies] = true
-
- @cmd.options[:args] = %w[no_such_gem]
-
- use_ui @ui do
- e = assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
- assert_equal 2, e.exit_code
- end
-
- # HACK no repository was checked
- assert_match(/ould not find a valid gem 'no_such_gem'/, @ui.error)
- end
-
def test_execute_no_gem
@cmd.options[:args] = %w[]
@@ -278,38 +201,6 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a
assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
end
- def test_execute_dependency_nonexistent
- spec_fetcher do |fetcher|
- fetcher.spec 'foo', 2, 'bar' => '0.5'
- end
-
- @cmd.options[:args] = ['foo']
-
- use_ui @ui do
- e = assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
-
- assert_equal 2, e.exit_code
- end
-
- expected = <<-EXPECTED
-ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in any repository
- EXPECTED
-
- assert_equal expected, @ui.error
- end
-
- def test_execute_http_proxy
- use_ui @ui do
- e = assert_raises ArgumentError, @ui.error do
- @cmd.handle_options %w[-p=foo.bar.com]
- end
-
- assert_match "Invalid uri scheme for =foo.bar.com\nPreface URLs with one of [\"http://\", \"https://\", \"file://\", \"s3://\"]", e.message
- end
- end
-
def test_execute_bad_source
spec_fetcher
@@ -470,23 +361,6 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
end
- def test_execute_with_version_specified_by_colon
- spec_fetcher do |fetcher|
- fetcher.download 'a', 1
- fetcher.download 'a', 2
- end
-
- @cmd.options[:args] = %w[a:1]
-
- use_ui @ui do
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- end
-
- assert_equal %w[a-1], @cmd.installed_specs.map { |spec| spec.full_name }
- end
-
def test_execute_prerelease_skipped_when_non_pre_available
spec_fetcher do |fetcher|
fetcher.gem 'a', '2.pre'
@@ -506,6 +380,7 @@ ERROR: Possible alternatives: non_existent_with_hint
end
def test_execute_rdoc
+ skip if RUBY_VERSION <= "1.8.7"
specs = spec_fetcher do |fetcher|
fetcher.gem 'a', 2
end
@@ -541,42 +416,6 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_path_exists File.join(a2.doc_dir, 'rdoc')
end
- def test_execute_rdoc_with_path
- specs = spec_fetcher do |fetcher|
- fetcher.gem 'a', 2
- end
-
- Gem.done_installing(&Gem::RDoc.method(:generation_hook))
-
- @cmd.options[:document] = %w[rdoc ri]
- @cmd.options[:domain] = :local
- @cmd.options[:install_dir] = 'whatever'
-
- a2 = specs['a-2']
- FileUtils.mv a2.cache_file, @tempdir
-
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- # Don't use Dir.chdir with a block, it warnings a lot because
- # of a downstream Dir.chdir with a block
- old = Dir.getwd
-
- begin
- Dir.chdir @tempdir
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- ensure
- Dir.chdir old
- end
- end
-
- wait_for_child_process_to_exit
-
- assert_path_exists 'whatever/doc/a-2', 'documentation not installed'
- end
-
def test_execute_saves_build_args
specs = spec_fetcher do |fetcher|
fetcher.gem 'a', 2
@@ -614,6 +453,7 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal args, a2.build_args
end
+
def test_execute_remote
spec_fetcher do |fetcher|
fetcher.gem 'a', 2
@@ -670,7 +510,7 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [a2.name]
- gemdir = File.join @gemhome, 'specifications'
+ gemdir = File.join @gemhome, 'specifications'
a2_gemspec = File.join(gemdir, "a-2.gemspec")
a1_gemspec = File.join(gemdir, "a-1.gemspec")
@@ -741,32 +581,12 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_empty @cmd.installed_specs
- msg = "ERROR: Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ msg = "ERROR: Can't use --version w/ multiple gems. Use name:ver instead."
assert_empty @ui.output
assert_equal msg, @ui.error.chomp
end
- def test_execute_two_version_specified_by_colon
- spec_fetcher do |fetcher|
- fetcher.gem 'a', 1
- fetcher.gem 'a', 2
- fetcher.gem 'b', 1
- fetcher.gem 'b', 2
- end
-
- @cmd.options[:args] = %w[a:1 b:1]
-
- use_ui @ui do
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- end
-
- assert_equal %w[a-1 b-1], @cmd.installed_specs.map { |spec| spec.full_name }
- end
-
def test_execute_conservative
spec_fetcher do |fetcher|
fetcher.download 'b', 2
@@ -829,23 +649,6 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
end
- def test_install_gem_ignore_dependencies_remote_platform_local
- local = Gem::Platform.local
- spec_fetcher do |fetcher|
- fetcher.gem 'a', 3
-
- fetcher.gem 'a', 3 do |s|
- s.platform = local
- end
- end
-
- @cmd.options[:ignore_dependencies] = true
-
- @cmd.install_gem 'a', '>= 0'
-
- assert_equal %W[a-3-#{local}], @cmd.installed_specs.map { |spec| spec.full_name }
- end
-
def test_install_gem_ignore_dependencies_specific_file
spec = util_spec 'a', 2
@@ -1235,116 +1038,4 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal [:test, :development], @cmd.options[:without_groups]
end
- def test_explain_platform_local
- local = Gem::Platform.local
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 2
-
- fetcher.spec 'a', 2 do |s|
- s.platform = local
- end
- end
-
- @cmd.options[:explain] = true
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Gems to install:", out.shift
- assert_equal " a-2-#{local}", out.shift
- assert_empty out
- end
-
- def test_explain_platform_local_ignore_dependencies
- local = Gem::Platform.local
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 3
-
- fetcher.spec 'a', 3 do |s|
- s.platform = local
- end
- end
-
- @cmd.options[:ignore_dependencies] = true
- @cmd.options[:explain] = true
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Gems to install:", out.shift
- assert_equal " a-3-#{local}", out.shift
- assert_empty out
- end
-
- def test_explain_platform_ruby
- local = Gem::Platform.local
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 2
-
- fetcher.spec 'a', 2 do |s|
- s.platform = local
- end
- end
-
- # equivalent to --platform=ruby
- Gem.platforms = [Gem::Platform::RUBY]
-
- @cmd.options[:explain] = true
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Gems to install:", out.shift
- assert_equal " a-2", out.shift
- assert_empty out
- end
-
- def test_explain_platform_ruby_ignore_dependencies
- local = Gem::Platform.local
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 3
-
- fetcher.spec 'a', 3 do |s|
- s.platform = local
- end
- end
-
- # equivalent to --platform=ruby
- Gem.platforms = [Gem::Platform::RUBY]
-
- @cmd.options[:ignore_dependencies] = true
- @cmd.options[:explain] = true
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
- @cmd.execute
- end
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Gems to install:", out.shift
- assert_equal " a-3", out.shift
- assert_empty out
- end
-
end
diff --git a/test/rubygems/test_gem_commands_lock_command.rb b/test/rubygems/test_gem_commands_lock_command.rb
index a35ed081cb..af1fce999c 100644
--- a/test/rubygems/test_gem_commands_lock_command.rb
+++ b/test/rubygems/test_gem_commands_lock_command.rb
@@ -66,3 +66,4 @@ gem 'd', '= 1'
end
end
+
diff --git a/test/rubygems/test_gem_commands_mirror.rb b/test/rubygems/test_gem_commands_mirror.rb
index 07ec9f3d0c..1a29755911 100644
--- a/test/rubygems/test_gem_commands_mirror.rb
+++ b/test/rubygems/test_gem_commands_mirror.rb
@@ -3,7 +3,6 @@ require 'rubygems/test_case'
require 'rubygems/commands/mirror_command'
class TestGemCommandsMirrorCommand < Gem::TestCase
-
def setup
super
diff --git a/test/rubygems/test_gem_commands_open_command.rb b/test/rubygems/test_gem_commands_open_command.rb
index e73a138204..a96fa6ea23 100644
--- a/test/rubygems/test_gem_commands_open_command.rb
+++ b/test/rubygems/test_gem_commands_open_command.rb
@@ -68,33 +68,4 @@ class TestGemCommandsOpenCommand < Gem::TestCase
assert_equal "", @ui.error
end
- def test_default_gem
- @cmd.options[:version] = "1.0"
- @cmd.options[:args] = %w[foo]
-
- version = @cmd.options[:version]
- @cmd.define_singleton_method(:spec_for) do |name|
- spec = Gem::Specification.find_all_by_name(name, version).first
-
- spec.define_singleton_method(:default_gem?) do
- true
- end
-
- return spec if spec
-
- say "Unable to find gem '#{name}'"
- end
-
- gem("foo", "1.0")
-
- assert_raises Gem::MockGemUi::TermError do
- use_ui @ui do
- @cmd.execute
- end
- end
-
- assert_match %r|'foo' is a default gem and can't be opened\.| , @ui.output
- assert_equal "", @ui.error
- end
-
end
diff --git a/test/rubygems/test_gem_commands_outdated_command.rb b/test/rubygems/test_gem_commands_outdated_command.rb
index 3c37e22a09..626b29057d 100644
--- a/test/rubygems/test_gem_commands_outdated_command.rb
+++ b/test/rubygems/test_gem_commands_outdated_command.rb
@@ -29,5 +29,5 @@ class TestGemCommandsOutdatedCommand < Gem::TestCase
assert_equal "foo (0.2 < 2.0)\n", @ui.output
assert_equal "", @ui.error
end
-
end
+
diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb
index 799d631f8a..53cac4ce87 100644
--- a/test/rubygems/test_gem_commands_owner_command.rb
+++ b/test/rubygems/test_gem_commands_owner_command.rb
@@ -8,10 +8,8 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
super
ENV["RUBYGEMS_HOST"] = nil
- @stub_ui = Gem::MockGemUi.new
- @stub_fetcher = Gem::FakeFetcher.new
- Gem::RemoteFetcher.fetcher = @stub_fetcher
- Gem.configuration = nil
+ @fetcher = Gem::FakeFetcher.new
+ Gem::RemoteFetcher.fetcher = @fetcher
Gem.configuration.rubygems_api_key = "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
@cmd = Gem::Commands::OwnerCommand.new
@@ -29,20 +27,20 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
- id: 4
EOF
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.show_owners("freewill")
end
- assert_equal Net::HTTP::Get, @stub_fetcher.last_request.class
- assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
+ assert_equal Net::HTTP::Get, @fetcher.last_request.class
+ assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
- assert_match %r{Owners for gem: freewill}, @stub_ui.output
- assert_match %r{- user1@example.com}, @stub_ui.output
- assert_match %r{- user2@example.com}, @stub_ui.output
- assert_match %r{- user3}, @stub_ui.output
- assert_match %r{- 4}, @stub_ui.output
+ assert_match %r{Owners for gem: freewill}, @ui.output
+ assert_match %r{- user1@example.com}, @ui.output
+ assert_match %r{- user2@example.com}, @ui.output
+ assert_match %r{- user3}, @ui.output
+ assert_match %r{- 4}, @ui.output
end
def test_show_owners_dont_load_objects
@@ -59,28 +57,30 @@ EOF
- id: 4
EOF
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
assert_raises Psych::DisallowedClass do
use_ui @ui do
@cmd.show_owners("freewill")
end
end
+
end
+
def test_show_owners_setting_up_host_through_env_var
response = "- email: user1@example.com\n"
host = "http://rubygems.example"
ENV["RUBYGEMS_HOST"] = host
- @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.show_owners("freewill")
end
- assert_match %r{Owners for gem: freewill}, @stub_ui.output
- assert_match %r{- user1@example.com}, @stub_ui.output
+ assert_match %r{Owners for gem: freewill}, @ui.output
+ assert_match %r{- user1@example.com}, @ui.output
end
def test_show_owners_setting_up_host
@@ -88,32 +88,32 @@ EOF
host = "http://rubygems.example"
@cmd.host = host
- @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.show_owners("freewill")
end
- assert_match %r{Owners for gem: freewill}, @stub_ui.output
- assert_match %r{- user1@example.com}, @stub_ui.output
+ assert_match %r{Owners for gem: freewill}, @ui.output
+ assert_match %r{- user1@example.com}, @ui.output
end
def test_show_owners_denied
response = "You don't have permission to push to this gem"
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.show_owners("freewill")
end
end
- assert_match response, @stub_ui.output
+ assert_match response, @ui.output
end
def test_show_owners_key
response = "- email: user1@example.com\n"
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
File.open Gem.configuration.credentials_path, 'a' do |f|
f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
end
@@ -122,56 +122,56 @@ EOF
@cmd.handle_options %w(-k other)
@cmd.show_owners('freewill')
- assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
end
def test_add_owners
response = "Owner added successfully."
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.add_owners("freewill", ["user-new1@example.com"])
end
- assert_equal Net::HTTP::Post, @stub_fetcher.last_request.class
- assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
- assert_equal "email=user-new1%40example.com", @stub_fetcher.last_request.body
+ assert_equal Net::HTTP::Post, @fetcher.last_request.class
+ assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
+ assert_equal "email=user-new1%40example.com", @fetcher.last_request.body
- assert_match response, @stub_ui.output
+ assert_match response, @ui.output
end
def test_add_owners_denied
response = "You don't have permission to push to this gem"
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.add_owners("freewill", ["user-new1@example.com"])
end
- assert_match response, @stub_ui.output
+ assert_match response, @ui.output
end
def test_add_owner_with_host_option_through_execute
host = "http://rubygems.example"
add_owner_response = "Owner added successfully."
show_owners_response = "- email: user1@example.com\n"
- @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, 'OK']
- @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, 'OK']
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, 'OK']
+ @fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, 'OK']
@cmd.handle_options %W[--host #{host} --add user-new1@example.com freewill]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- assert_match add_owner_response, @stub_ui.output
- assert_match %r{Owners for gem: freewill}, @stub_ui.output
- assert_match %r{- user1@example.com}, @stub_ui.output
+ assert_match add_owner_response, @ui.output
+ assert_match %r{Owners for gem: freewill}, @ui.output
+ assert_match %r{- user1@example.com}, @ui.output
end
def test_add_owners_key
response = "Owner added successfully."
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
File.open Gem.configuration.credentials_path, 'a' do |f|
f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
end
@@ -180,38 +180,38 @@ EOF
@cmd.handle_options %w(-k other)
@cmd.add_owners('freewill', ['user-new1@example.com'])
- assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
end
def test_remove_owners
response = "Owner removed successfully."
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.remove_owners("freewill", ["user-remove1@example.com"])
end
- assert_equal Net::HTTP::Delete, @stub_fetcher.last_request.class
- assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
- assert_equal "email=user-remove1%40example.com", @stub_fetcher.last_request.body
+ assert_equal Net::HTTP::Delete, @fetcher.last_request.class
+ assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
+ assert_equal "email=user-remove1%40example.com", @fetcher.last_request.body
- assert_match response, @stub_ui.output
+ assert_match response, @ui.output
end
def test_remove_owners_denied
response = "You don't have permission to push to this gem"
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.remove_owners("freewill", ["user-remove1@example.com"])
end
- assert_match response, @stub_ui.output
+ assert_match response, @ui.output
end
def test_remove_owners_key
response = "Owner removed successfully."
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
File.open Gem.configuration.credentials_path, 'a' do |f|
f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
end
@@ -220,53 +220,18 @@ EOF
@cmd.handle_options %w(-k other)
@cmd.remove_owners('freewill', ['user-remove1@example.com'])
- assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization']
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
end
def test_remove_owners_missing
response = 'Owner could not be found.'
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found']
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.remove_owners("freewill", ["missing@example"])
end
- assert_equal "Removing missing@example: #{response}\n", @stub_ui.output
- end
-
- def test_otp_verified_success
- response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
- response_success = "Owner added successfully."
-
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [
- [response_fail, 401, 'Unauthorized'],
- [response_success, 200, 'OK']
- ]
-
- @otp_ui = Gem::MockGemUi.new "111111\n"
- use_ui @otp_ui do
- @cmd.add_owners("freewill", ["user-new1@example.com"])
- end
-
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
- assert_match 'Code: ', @otp_ui.output
- assert_match response_success, @otp_ui.output
- assert_equal '111111', @stub_fetcher.last_request['OTP']
- end
-
- def test_otp_verified_failure
- response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
- @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 401, 'Unauthorized']
-
- @otp_ui = Gem::MockGemUi.new "111111\n"
- use_ui @otp_ui do
- @cmd.add_owners("freewill", ["user-new1@example.com"])
- end
-
- assert_match response, @otp_ui.output
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
- assert_match 'Code: ', @otp_ui.output
- assert_equal '111111', @stub_fetcher.last_request['OTP']
+ assert_equal "Removing missing@example: #{response}\n", @ui.output
end
end
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
index e872a80957..d2f8b10bb8 100644
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ b/test/rubygems/test_gem_commands_pristine_command.rb
@@ -53,60 +53,8 @@ class TestGemCommandsPristineCommand < Gem::TestCase
assert_empty out, out.inspect
end
- def test_execute_user_install
- FileUtils.chmod 0555, @gemhome
-
- a = util_spec "a" do |s|
- s.executables = %w[foo]
- s.files = %w[bin/foo lib/a.rb]
- end
-
- write_file File.join(@tempdir, "lib", "a.rb") do |fp|
- fp.puts "puts __FILE__"
- end
-
- write_file File.join(@tempdir, "bin", "foo") do |fp|
- fp.puts "#!/usr/bin/ruby"
- end
-
- install_gem_user(a)
-
- Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
-
- foo_path = File.join(Gem.user_dir, "gems", a.full_name, "bin", "foo")
- a_rb_path = File.join(Gem.user_dir, "gems", a.full_name, "lib", "a.rb")
-
- write_file foo_path do |io|
- io.puts("I changed it!")
- end
-
- write_file a_rb_path do |io|
- io.puts("I changed it!")
- end
-
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "#!/usr/bin/ruby\n", File.read(foo_path), foo_path
- assert_equal "puts __FILE__\n", File.read(a_rb_path), a_rb_path
-
- out = @ui.output.split("\n")
-
- assert_equal "Restoring gems to pristine condition...", out.shift
- assert_equal "Restored #{a.full_name}", out.shift
- assert_empty out, out.inspect
- ensure
- FileUtils.chmod(0755, @gemhome)
- end
-
def test_execute_all
- a = util_spec 'a' do |s|
- s.executables = %w[foo]
- end
-
+ a = util_spec 'a' do |s| s.executables = %w[foo] end
write_file File.join(@tempdir, 'bin', 'foo') do |fp|
fp.puts "#!/usr/bin/ruby"
end
@@ -168,9 +116,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
def test_execute_extensions_explicit
- a = util_spec 'a' do |s|
- s.extensions << 'ext/a/extconf.rb'
- end
+ a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
write_file ext_path do |io|
@@ -206,9 +152,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
def test_execute_no_extension
- a = util_spec 'a' do |s|
- s.extensions << 'ext/a/extconf.rb'
- end
+ a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
write_file ext_path do |io|
@@ -234,9 +178,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
def test_execute_with_extension_with_build_args
- a = util_spec 'a' do |s|
- s.extensions << 'ext/a/extconf.rb'
- end
+ a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end
ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
write_file ext_path do |io|
@@ -311,31 +253,6 @@ class TestGemCommandsPristineCommand < Gem::TestCase
assert_empty out, out.inspect
end
- def test_skip_many_gems
- a = util_spec 'a'
- b = util_spec 'b'
- c = util_spec 'c'
-
- install_gem a
- install_gem b
- install_gem c
-
- @cmd.options[:args] = %w[a b c]
- @cmd.options[:skip] = ['a', 'c']
-
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Restoring gems to pristine condition...", out.shift
- assert_equal "Skipped #{a.full_name}, it was given through options", out.shift
- assert_equal "Restored #{b.full_name}", out.shift
- assert_equal "Skipped #{c.full_name}, it was given through options", out.shift
- assert_empty out, out.inspect
- end
-
def test_execute_many_multi_repo
a = util_spec 'a'
install_gem a
@@ -491,39 +408,6 @@ class TestGemCommandsPristineCommand < Gem::TestCase
refute File.exist? gem_lib
end
- def test_execute_bindir
- a = util_spec 'a' do |s|
- s.name = "test_gem"
- s.executables = %w[foo]
- s.files = %w[bin/foo]
- end
-
- write_file File.join(@tempdir, 'bin', 'foo') do |fp|
- fp.puts "#!/usr/bin/ruby"
- end
-
- write_file File.join(@tempdir, 'test_bin', 'foo') do |fp|
- fp.puts "#!/usr/bin/ruby"
- end
-
- install_gem a
-
- gem_exec = File.join @gemhome, 'bin', 'foo'
- gem_bindir = File.join @tempdir, 'test_bin', 'foo'
-
- FileUtils.rm gem_exec
- FileUtils.rm gem_bindir
-
- @cmd.handle_options ["--all", "--only-executables", "--bindir", "#{gem_bindir}"]
-
- use_ui @ui do
- @cmd.execute
- end
-
- refute File.exist? gem_exec
- assert File.exist? gem_bindir
- end
-
def test_execute_unknown_gem_at_remote_source
install_specs util_spec 'a'
@@ -553,57 +437,36 @@ class TestGemCommandsPristineCommand < Gem::TestCase
@cmd.execute
end
- assert_equal(
- [
- "Restoring gems to pristine condition...",
- "Skipped default-2.0.0.0, it is a default gem",
- ],
- @ui.output.split("\n")
- )
+ assert_equal([
+ "Restoring gems to pristine condition...",
+ "Skipped default-2.0.0.0, it is a default gem",
+ ],
+ @ui.output.split("\n"))
assert_empty(@ui.error)
end
- def test_execute_multi_platform
- a = util_spec 'a' do |s|
- s.extensions << 'ext/a/extconf.rb'
- end
+ def test_execute_bundled_gem_on_old_rubies
+ util_set_RUBY_VERSION '1.9.3', 551
- b = util_spec 'b' do |s|
- s.extensions << 'ext/a/extconf.rb'
- s.platform = Gem::Platform.new("java")
+ spec = util_spec 'bigdecimal', '1.1.0' do |s|
+ s.summary = "This bigdecimal is bundled with Ruby"
end
+ install_specs spec
- ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb'
- write_file ext_path do |io|
- io.write <<-'RUBY'
- File.open "Makefile", "w" do |f|
- f.puts "clean:\n\techo cleaned\n"
- f.puts "all:\n\techo built\n"
- f.puts "install:\n\techo installed\n"
- end
- RUBY
- end
-
- install_gem a
- install_gem b
-
- @cmd.options[:extensions] = true
- @cmd.options[:extensions_set] = true
- @cmd.options[:args] = []
+ @cmd.options[:args] = %w[bigdecimal]
- util_set_arch "x86_64-darwin" do
- use_ui @ui do
- @cmd.execute
- end
+ use_ui @ui do
+ @cmd.execute
end
- out = @ui.output.split "\n"
+ assert_equal([
+ "Restoring gems to pristine condition...",
+ "Skipped bigdecimal-1.1.0, it is bundled with old Ruby"
+ ], @ui.output.split("\n"))
- assert_equal 'Restoring gems to pristine condition...', out.shift
- assert_equal 'Building native extensions. This could take a while...',
- out.shift
- assert_equal "Restored #{a.full_name}", out.shift
- assert_empty out, out.inspect
+ assert_empty @ui.error
+ ensure
+ util_restore_RUBY_VERSION
end
def test_handle_options
@@ -625,3 +488,4 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index f666c6d437..1c5dbfe23e 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -27,7 +27,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
@cmd = Gem::Commands::PushCommand.new
- singleton_gem_class.class_eval do
+ class << Gem
alias_method :orig_latest_rubygems_version, :latest_rubygems_version
def latest_rubygems_version
@@ -39,7 +39,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
def teardown
super
- singleton_gem_class.class_eval do
+ class << Gem
remove_method :latest_rubygems_version
alias_method :latest_rubygems_version, :orig_latest_rubygems_version
end
@@ -95,26 +95,6 @@ class TestGemCommandsPushCommand < Gem::TestCase
@fetcher.last_request["Content-Type"]
end
- def test_execute_allowed_push_host
- @spec, @path = util_gem "freebird", "1.0.1" do |spec|
- spec.metadata['allowed_push_host'] = "https://privategemserver.example"
- end
-
- @response = "Successfully registered gem: freewill (1.0.0)"
- @fetcher.data["#{@spec.metadata['allowed_push_host']}/api/v1/gems"] = [@response, 200, 'OK']
- @fetcher.data["#{Gem.host}/api/v1/gems"] =
- ['fail', 500, 'Internal Server Error']
-
- @cmd.options[:args] = [@path]
-
- @cmd.execute
-
- assert_equal Net::HTTP::Post, @fetcher.last_request.class
- assert_equal Gem.read_binary(@path), @fetcher.last_request.body
- assert_equal "application/octet-stream",
- @fetcher.last_request["Content-Type"]
- end
-
def test_sending_when_default_host_disabled
Gem.configuration.disable_default_gem_server = true
response = "You must specify a gem server"
@@ -132,7 +112,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
ENV["RUBYGEMS_HOST"] = @host
Gem.configuration.disable_default_gem_server = true
@response = "Successfully registered gem: freewill (1.0.0)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -160,14 +140,13 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
-
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
def test_sending_gem
@response = "Successfully registered gem: freewill (1.0.0)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -195,22 +174,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
- send_battery
- end
-
- def test_sending_gem_with_env_var_api_key
- @host = "http://privategemserver.example"
-
- @spec, @path = util_gem "freebird", "1.0.1" do |spec|
- spec.metadata['allowed_push_host'] = @host
- end
-
- @api_key = "PRIVKEY"
- ENV["GEM_HOST_API_KEY"] = "PRIVKEY"
-
- @response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -237,7 +201,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK']
send_battery
end
@@ -310,7 +274,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
@response = "Successfully registered gem: freebird (1.0.1)"
- @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, 'OK']
+ @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, 'OK']
# do not set @host
use_ui(@ui) { @cmd.send_gem(@path) }
@@ -363,47 +327,4 @@ class TestGemCommandsPushCommand < Gem::TestCase
@fetcher.last_request["Authorization"]
end
- def test_otp_verified_success
- response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
- response_success = 'Successfully registered gem: freewill (1.0.0)'
-
- @fetcher.data["#{Gem.host}/api/v1/gems"] = [
- [response_fail, 401, 'Unauthorized'],
- [response_success, 200, 'OK']
- ]
-
- @otp_ui = Gem::MockGemUi.new "111111\n"
- use_ui @otp_ui do
- @cmd.send_gem(@path)
- end
-
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
- assert_match 'Code: ', @otp_ui.output
- assert_match response_success, @otp_ui.output
- assert_equal '111111', @fetcher.last_request['OTP']
- end
-
- def test_otp_verified_failure
- response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
- @fetcher.data["#{Gem.host}/api/v1/gems"] = [response, 401, 'Unauthorized']
-
- @otp_ui = Gem::MockGemUi.new "111111\n"
- assert_raises Gem::MockGemUi::TermError do
- use_ui @otp_ui do
- @cmd.send_gem(@path)
- end
- end
-
- assert_match response, @otp_ui.output
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
- assert_match 'Code: ', @otp_ui.output
- assert_equal '111111', @fetcher.last_request['OTP']
- end
-
- private
-
- def singleton_gem_class
- class << Gem; self; end
- end
-
end
diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
index 6183e592e9..5471ecadcc 100644
--- a/test/rubygems/test_gem_commands_query_command.rb
+++ b/test/rubygems/test_gem_commands_query_command.rb
@@ -9,17 +9,14 @@ module TestGemCommandsQueryCommandSetup
@cmd = Gem::Commands::QueryCommand.new
@specs = add_gems_to_fetcher
- @stub_ui = Gem::MockGemUi.new
- @stub_fetcher = Gem::FakeFetcher.new
- @stub_fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
+ @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
raise Gem::RemoteFetcher::FetchError
end
end
end
class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase
-
include TestGemCommandsQueryCommandSetup
def test_execute
@@ -29,7 +26,7 @@ class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase
@cmd.handle_options %w[-r]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -41,8 +38,8 @@ a (2)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_all
@@ -52,7 +49,7 @@ pl (1 i386-linux)
@cmd.handle_options %w[-r --all]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -64,8 +61,8 @@ a (2, 1)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_all_prerelease
@@ -75,7 +72,7 @@ pl (1 i386-linux)
@cmd.handle_options %w[-r --all --prerelease]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -87,8 +84,8 @@ a (3.a, 2, 1)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_details
@@ -104,7 +101,7 @@ pl (1 i386-linux)
@cmd.handle_options %w[-r -d]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -127,8 +124,8 @@ pl (1)
this is a summary
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_details_cleans_text
@@ -144,7 +141,7 @@ pl (1)
@cmd.handle_options %w[-r -d]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -167,8 +164,8 @@ pl (1)
this is a summary
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_details_truncates_summary
@@ -184,7 +181,7 @@ pl (1)
@cmd.handle_options %w[-r -d]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -207,34 +204,34 @@ pl (1)
this is a summary
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_installed
@cmd.handle_options %w[-n a --installed]
assert_raises Gem::MockGemUi::SystemExitException do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal "true\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "true\n", @ui.output
+ assert_equal '', @ui.error
end
def test_execute_installed_inverse
@cmd.handle_options %w[-n a --no-installed]
e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal "false\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "false\n", @ui.output
+ assert_equal '', @ui.error
assert_equal 1, e.exit_code
end
@@ -243,26 +240,26 @@ pl (1)
@cmd.handle_options %w[-n not_installed --no-installed]
assert_raises Gem::MockGemUi::SystemExitException do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal "true\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "true\n", @ui.output
+ assert_equal '', @ui.error
end
def test_execute_installed_no_name
@cmd.handle_options %w[--installed]
e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal '', @stub_ui.output
- assert_equal "ERROR: You must specify a gem name\n", @stub_ui.error
+ assert_equal '', @ui.output
+ assert_equal "ERROR: You must specify a gem name\n", @ui.error
assert_equal 4, e.exit_code
end
@@ -271,13 +268,13 @@ pl (1)
@cmd.handle_options %w[-n not_installed --installed]
e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal "false\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "false\n", @ui.output
+ assert_equal '', @ui.error
assert_equal 1, e.exit_code
end
@@ -286,26 +283,26 @@ pl (1)
@cmd.handle_options %w[-n a --installed --version 2]
assert_raises Gem::MockGemUi::SystemExitException do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal "true\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "true\n", @ui.output
+ assert_equal '', @ui.error
end
def test_execute_installed_version_not_installed
@cmd.handle_options %w[-n c --installed --version 2]
e = assert_raises Gem::MockGemUi::TermError do
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
end
- assert_equal "false\n", @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal "false\n", @ui.output
+ assert_equal '', @ui.error
assert_equal 1, e.exit_code
end
@@ -317,7 +314,7 @@ pl (1)
@cmd.options[:domain] = :local
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -329,8 +326,8 @@ a (3.a, 2, 1)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_local_notty
@@ -340,9 +337,9 @@ pl (1 i386-linux)
@cmd.handle_options %w[]
- @stub_ui.outs.tty = false
+ @ui.outs.tty = false
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -351,8 +348,8 @@ a (3.a, 2, 1)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_local_quiet
@@ -363,7 +360,7 @@ pl (1 i386-linux)
@cmd.options[:domain] = :local
Gem.configuration.verbose = false
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -372,8 +369,8 @@ a (3.a, 2, 1)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_no_versions
@@ -383,7 +380,7 @@ pl (1 i386-linux)
@cmd.handle_options %w[-r --no-versions]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -395,8 +392,8 @@ a
pl
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_notty
@@ -406,9 +403,9 @@ pl
@cmd.handle_options %w[-r]
- @stub_ui.outs.tty = false
+ @ui.outs.tty = false
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -417,14 +414,14 @@ a (2)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_prerelease
@cmd.handle_options %w[-r --prerelease]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -435,8 +432,8 @@ pl (1 i386-linux)
a (3.a)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_prerelease_local
@@ -446,7 +443,7 @@ a (3.a)
@cmd.handle_options %w[-l --prerelease]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -458,29 +455,8 @@ a (3.a, 2, 1)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- end
-
- def test_execute_no_prerelease_local
- spec_fetcher do |fetcher|
- fetcher.legacy_platform
- end
-
- @cmd.handle_options %w[-l --no-prerelease]
-
- use_ui @stub_ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** LOCAL GEMS ***
-
-a (2, 1)
-pl (1 i386-linux)
- EOF
-
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
+ assert_equal "WARNING: prereleases are always shown locally\n", @ui.error
end
def test_execute_remote
@@ -490,7 +466,7 @@ pl (1 i386-linux)
@cmd.options[:domain] = :remote
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -502,8 +478,8 @@ a (2)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_remote_notty
@@ -513,9 +489,9 @@ pl (1 i386-linux)
@cmd.handle_options %w[]
- @stub_ui.outs.tty = false
+ @ui.outs.tty = false
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -524,8 +500,8 @@ a (3.a, 2, 1)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_remote_quiet
@@ -536,7 +512,7 @@ pl (1 i386-linux)
@cmd.options[:domain] = :remote
Gem.configuration.verbose = false
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -545,14 +521,14 @@ a (2)
pl (1 i386-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_make_entry
a_2_name = @specs['a-2'].original_name
- @stub_fetcher.data.delete \
+ @fetcher.data.delete \
"#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz"
a2 = @specs['a-2']
@@ -576,26 +552,26 @@ pl (1 i386-linux)
@cmd.handle_options %w[a pl]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- assert_match %r%^a %, @stub_ui.output
- assert_match %r%^pl %, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_match %r%^a %, @ui.output
+ assert_match %r%^pl %, @ui.output
+ assert_equal '', @ui.error
end
def test_show_gems
@cmd.options[:name] = //
@cmd.options[:domain] = :remote
- use_ui @stub_ui do
- @cmd.send :show_gems, /a/i
+ use_ui @ui do
+ @cmd.send :show_gems, /a/i, false
end
- assert_match %r%^a %, @stub_ui.output
- refute_match %r%^pl %, @stub_ui.output
- assert_empty @stub_ui.error
+ assert_match %r%^a %, @ui.output
+ refute_match %r%^pl %, @ui.output
+ assert_empty @ui.error
end
private
@@ -607,11 +583,9 @@ pl (1 i386-linux)
fetcher.spec 'a', '3.a'
end
end
-
end
class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase
-
include TestGemCommandsQueryCommandSetup
def test_execute_platform
@@ -628,7 +602,7 @@ class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase
@cmd.handle_options %w[-r -a]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -639,8 +613,8 @@ class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase
a (2 universal-darwin, 1 ruby x86-linux)
EOF
- assert_equal expected, @stub_ui.output
- assert_equal '', @stub_ui.error
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
end
def test_execute_show_default_gems
@@ -649,7 +623,7 @@ a (2 universal-darwin, 1 ruby x86-linux)
a1 = new_default_spec 'a', 1
install_default_specs a1
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -660,7 +634,7 @@ a (2 universal-darwin, 1 ruby x86-linux)
a (2, default: 1)
EOF
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
end
def test_execute_show_default_gems_with_platform
@@ -668,7 +642,7 @@ EOF
a1.platform = 'java'
install_default_specs a1
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -679,7 +653,7 @@ EOF
a (default: 1 java)
EOF
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
end
def test_execute_default_details
@@ -692,7 +666,7 @@ EOF
@cmd.handle_options %w[-l -d]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -709,7 +683,7 @@ a (2, 1)
this is a summary
EOF
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
end
def test_execute_local_details
@@ -730,11 +704,11 @@ a (2, 1)
@cmd.handle_options %w[-l -d]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- str = @stub_ui.output
+ str = @ui.output
str.gsub!(/\(\d\): [^\n]*/, "-")
str.gsub!(/at: [^\n]*/, "at: -")
@@ -764,7 +738,7 @@ pl (1)
this is a summary
EOF
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
end
def test_execute_exact_remote
@@ -776,7 +750,7 @@ pl (1)
@cmd.handle_options %w[--remote --exact coolgem]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -787,7 +761,7 @@ pl (1)
coolgem (4.2.1)
EOF
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
end
def test_execute_exact_local
@@ -799,7 +773,7 @@ coolgem (4.2.1)
@cmd.handle_options %w[--exact coolgem]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -810,7 +784,7 @@ coolgem (4.2.1)
coolgem (4.2.1)
EOF
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
end
def test_execute_exact_multiple
@@ -826,7 +800,7 @@ coolgem (4.2.1)
@cmd.handle_options %w[--exact coolgem othergem]
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
@@ -841,7 +815,7 @@ coolgem (4.2.1)
othergem (1.2.3)
EOF
- assert_equal expected, @stub_ui.output
+ assert_equal expected, @ui.output
end
private
@@ -853,5 +827,4 @@ othergem (1.2.3)
fetcher.download 'a', '3.a'
end
end
-
end
diff --git a/test/rubygems/test_gem_commands_search_command.rb b/test/rubygems/test_gem_commands_search_command.rb
index 9187050c30..61caff1fc9 100644
--- a/test/rubygems/test_gem_commands_search_command.rb
+++ b/test/rubygems/test_gem_commands_search_command.rb
@@ -15,3 +15,4 @@ class TestGemCommandsSearchCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_commands_server_command.rb b/test/rubygems/test_gem_commands_server_command.rb
index af15aadfd1..b61fc30e9b 100644
--- a/test/rubygems/test_gem_commands_server_command.rb
+++ b/test/rubygems/test_gem_commands_server_command.rb
@@ -38,12 +38,8 @@ class TestGemCommandsServerCommand < Gem::TestCase
@cmd.send :handle_options, %w[-p 65535]
assert_equal 65535, @cmd.options[:port]
- begin
- @cmd.send :handle_options, %w[-p discard]
- assert_equal 9, @cmd.options[:port]
- rescue OptionParser::InvalidArgument
- # for container environment on GitHub Actions
- end
+ @cmd.send :handle_options, %w[-p discard]
+ assert_equal 9, @cmd.options[:port]
e = assert_raises OptionParser::InvalidArgument do
@cmd.send :handle_options, %w[-p nonexistent]
@@ -61,3 +57,4 @@ class TestGemCommandsServerCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index c63f7177c7..f2541a24c7 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -10,7 +10,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
if File.exist?(bundler_gemspec)
BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1]
else
- BUNDLER_VERS = "2.0.1".freeze
+ BUNDLER_VERS = "1.16.1"
end
def setup
@@ -23,41 +23,21 @@ class TestGemCommandsSetupCommand < Gem::TestCase
FileUtils.mkdir_p 'bin'
FileUtils.mkdir_p 'lib/rubygems/ssl_certs/rubygems.org'
- File.open 'bin/gem', 'w' do
- |io| io.puts '# gem'
- end
-
- File.open 'lib/rubygems.rb', 'w' do |io|
- io.puts '# rubygems.rb'
- end
-
- File.open 'lib/rubygems/test_case.rb', 'w' do |io|
- io.puts '# test_case.rb'
- end
-
- File.open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io|
- io.puts 'PEM'
- end
+ File.open 'bin/gem', 'w' do |io| io.puts '# gem' end
+ File.open 'lib/rubygems.rb', 'w' do |io| io.puts '# rubygems.rb' end
+ File.open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end
+ File.open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io| io.puts 'PEM' end
FileUtils.mkdir_p 'bundler/exe'
FileUtils.mkdir_p 'bundler/lib/bundler'
- File.open 'bundler/exe/bundle', 'w' do |io|
- io.puts '# bundle'
- end
-
- File.open 'bundler/lib/bundler.rb', 'w' do |io|
- io.puts '# bundler.rb'
- end
-
- File.open 'bundler/lib/bundler/b.rb', 'w' do |io|
- io.puts '# b.rb'
- end
+ File.open 'bundler/exe/bundle', 'w' do |io| io.puts '# bundle' end
+ File.open 'bundler/lib/bundler.rb', 'w' do |io| io.puts '# bundler.rb' end
+ File.open 'bundler/lib/bundler/b.rb', 'w' do |io| io.puts '# b.rb' end
FileUtils.mkdir_p 'default/gems'
gemspec = Gem::Specification.new
- gemspec.author = "Us"
gemspec.name = "bundler"
gemspec.version = BUNDLER_VERS
gemspec.bindir = "exe"
@@ -67,7 +47,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
io.puts gemspec.to_ruby
end
- open(File.join(Gem.default_specifications_dir, "bundler-1.15.4.gemspec"), 'w') do |io|
+ open(File.join(Gem::Specification.default_specifications_dir, "bundler-1.15.4.gemspec"), 'w') do |io|
gemspec.version = "1.15.4"
io.puts gemspec.to_ruby
end
@@ -86,7 +66,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
FileUtils.mkdir_p 'default/gems/bundler-audit-1.0.0'
end
- def gem_install(name)
+ def gem_install name
gem = util_spec name do |s|
s.executables = [name]
s.files = %W[bin/#{name}]
@@ -123,41 +103,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_equal "I changed it!\n", File.read(gem_bin_path)
end
- def test_execute_informs_about_installed_executables
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
-
- exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
- assert_equal "\t#{default_gem_bin_path}", out.shift
- assert_equal "\t#{default_bundle_bin_path}", out.shift
- end
-
- def test_env_shebang_flag
- gem_bin_path = gem_install 'a'
- write_file gem_bin_path do |io|
- io.puts 'I changed it!'
- end
-
- @cmd.options[:document] = []
- @cmd.options[:env_shebang] = true
- @cmd.execute
-
- ruby_exec = sprintf Gem.default_exec_format, 'ruby'
-
- if Gem.win_platform?
- assert_match %r%\A#!\s*#{ruby_exec}%, File.read(default_gem_bin_path)
- assert_match %r%\A#!\s*#{ruby_exec}%, File.read(default_bundle_bin_path)
- assert_match %r%\A#!\s*#{ruby_exec}%, File.read(gem_bin_path)
- else
- assert_match %r%\A#!/usr/bin/env #{ruby_exec}%, File.read(default_gem_bin_path)
- assert_match %r%\A#!/usr/bin/env #{ruby_exec}%, File.read(default_bundle_bin_path)
- assert_match %r%\A#!/usr/bin/env #{ruby_exec}%, File.read(gem_bin_path)
- end
- end
-
def test_pem_files_in
assert_equal %w[rubygems/ssl_certs/rubygems.org/foo.pem],
@cmd.pem_files_in('lib').sort
@@ -177,30 +122,29 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_path_exists File.join(dir, 'rubygems.rb')
assert_path_exists File.join(dir, 'rubygems/ssl_certs/rubygems.org/foo.pem')
- assert_path_exists File.join(dir, 'bundler.rb')
- assert_path_exists File.join(dir, 'bundler/b.rb')
+ if Gem::USE_BUNDLER_FOR_GEMDEPS
+ assert_path_exists File.join(dir, 'bundler.rb')
+ assert_path_exists File.join(dir, 'bundler/b.rb')
+ end
end
end
def test_install_default_bundler_gem
@cmd.extend FileUtils
- bin_dir = File.join(@gemhome, 'bin')
- @cmd.install_default_bundler_gem bin_dir
+ @cmd.install_default_bundler_gem
- bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
- default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
- spec = Gem::Specification.load(default_spec_path)
+ if Gem.win_platform?
+ bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
+ default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
+ spec = Gem::Specification.load(default_spec_path)
- spec.executables.each do |e|
- if Gem.win_platform?
- assert_path_exists File.join(bin_dir, "#{e}.bat")
+ spec.executables.each do |e|
+ assert_path_exists File.join(spec.bin_dir, "#{e}.bat")
end
-
- assert_path_exists File.join bin_dir, Gem.default_exec_format % e
end
- default_dir = Gem.default_specifications_dir
+ default_dir = Gem::Specification.default_specifications_dir
# expect to remove other versions of bundler gemspecs on default specification directory.
refute_path_exists File.join(default_dir, "bundler-1.15.4.gemspec")
@@ -220,40 +164,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase
# TODO: We need to assert to remove same version of bundler on gem_dir directory(It's not site_ruby dir)
- # expect to not remove bundler-* directory.
+ # expect to not remove bundler-* direcotyr.
assert_path_exists 'default/gems/bundler-audit-1.0.0'
- end
-
- def test_install_default_bundler_gem_with_force_flag
- @cmd.extend FileUtils
-
- bin_dir = File.join(@gemhome, 'bin')
- bundle_bin = File.join(bin_dir, 'bundle')
-
- write_file bundle_bin do |f|
- f.puts '#!/usr/bin/ruby'
- f.puts ''
- f.puts 'echo "hello"'
- end
-
- bindir(bin_dir) do
- @cmd.options[:force] = true
-
- @cmd.install_default_bundler_gem bin_dir
-
- bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
- default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
- spec = Gem::Specification.load(default_spec_path)
-
- spec.executables.each do |e|
- if Gem.win_platform?
- assert_path_exists File.join(bin_dir, "#{e}.bat")
- end
-
- assert_path_exists File.join bin_dir, Gem.default_exec_format % e
- end
- end
- end
+ end if Gem::USE_BUNDLER_FOR_GEMDEPS
def test_remove_old_lib_files
lib = File.join @install_dir, 'lib'
@@ -261,7 +174,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
lib_bundler = File.join lib, 'bundler'
lib_rubygems_defaults = File.join lib_rubygems, 'defaults'
- securerandom_rb = File.join lib, 'securerandom.rb'
+ securerandom_rb = File.join lib, 'securerandom.rb'
engine_defaults_rb = File.join lib_rubygems_defaults, 'jruby.rb'
os_defaults_rb = File.join lib_rubygems_defaults, 'operating_system.rb'
@@ -273,35 +186,20 @@ class TestGemCommandsSetupCommand < Gem::TestCase
FileUtils.mkdir_p lib_rubygems_defaults
FileUtils.mkdir_p lib_bundler
- File.open securerandom_rb, 'w' do |io|
- io.puts '# securerandom.rb'
- end
+ File.open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end
- File.open old_builder_rb, 'w' do |io|
- io.puts '# builder.rb'
- end
+ File.open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end
+ File.open old_format_rb, 'w' do |io| io.puts '# format.rb' end
+ File.open old_bundler_c_rb, 'w' do |io| io.puts '# c.rb' end
- File.open old_format_rb, 'w' do |io|
- io.puts '# format.rb'
- end
-
- File.open old_bundler_c_rb, 'w' do |io|
- io.puts '# c.rb'
- end
-
- File.open engine_defaults_rb, 'w' do |io|
- io.puts '# jruby.rb'
- end
-
- File.open os_defaults_rb, 'w' do |io|
- io.puts '# operating_system.rb'
- end
+ File.open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end
+ File.open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end
@cmd.remove_old_lib_files lib
refute_path_exists old_builder_rb
refute_path_exists old_format_rb
- refute_path_exists old_bundler_c_rb
+ refute_path_exists old_bundler_c_rb if Gem::USE_BUNDLER_FOR_GEMDEPS
assert_path_exists securerandom_rb
assert_path_exists engine_defaults_rb
@@ -309,8 +207,11 @@ class TestGemCommandsSetupCommand < Gem::TestCase
end
def test_show_release_notes
- @default_external = @ui.outs.external_encoding
- @ui.outs.set_encoding Encoding::US_ASCII
+ @default_external = nil
+ if Object.const_defined? :Encoding
+ @default_external = @ui.outs.external_encoding
+ @ui.outs.set_encoding Encoding::US_ASCII
+ end
@cmd.options[:previous_version] = Gem::Version.new '2.0.2'
@@ -347,26 +248,19 @@ class TestGemCommandsSetupCommand < Gem::TestCase
* Fixed release note display for LANG=C when installing rubygems
* π is tasty
+=== 2.0.2 / 2013-03-06
+
+* Bug fixes:
+ * Other bugs fixed
+
EXPECTED
output = @ui.output
- output.force_encoding Encoding::UTF_8
+ output.force_encoding Encoding::UTF_8 if Object.const_defined? :Encoding
assert_equal expected, output
ensure
@ui.outs.set_encoding @default_external if @default_external
end
- private
-
- def default_gem_bin_path
- gem_exec = sprintf Gem.default_exec_format, 'gem'
- File.join @install_dir, 'bin', gem_exec
- end
-
- def default_bundle_bin_path
- bundle_exec = sprintf Gem.default_exec_format, 'bundle'
- File.join @install_dir, 'bin', bundle_exec
- end
-
-end unless Gem.java_platform?
+end
diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb
index c000c7a77a..56eecfc1f8 100644
--- a/test/rubygems/test_gem_commands_signin_command.rb
+++ b/test/rubygems/test_gem_commands_signin_command.rb
@@ -26,7 +26,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
end
def test_execute_when_already_signed_in_with_same_host
- host = 'http://some-gemcutter-compatible-host.org'
+ host = 'http://some-gemcutter-compatible-host.org'
util_capture(nil, host) { @cmd.execute }
old_credentials = YAML.load_file Gem.configuration.credentials_path
@@ -38,17 +38,17 @@ class TestGemCommandsSigninCommand < Gem::TestCase
end
def test_execute_when_already_signed_in_with_different_host
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf04045xxxx'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf04045xxxx'
util_capture(nil, nil, api_key) { @cmd.execute }
- host = 'http://some-gemcutter-compatible-host.org'
+ host = 'http://some-gemcutter-compatible-host.org'
util_capture(nil, host, api_key) { @cmd.execute }
credentials = YAML.load_file Gem.configuration.credentials_path
assert_equal credentials[:rubygems_api_key], api_key
- assert_nil credentials[host]
+ assert_equal credentials[host], nil
end
def test_execute_with_host_supplied
@@ -74,7 +74,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
# Utility method to capture IO/UI within the block passed
- def util_capture(ui_stub = nil, host = nil, api_key = nil)
+ def util_capture ui_stub = nil, host = nil, api_key = nil
api_key ||= 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
response = [api_key, 200, 'OK']
email = 'you@example.com'
@@ -87,7 +87,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
fetcher.data[data_key] = response
Gem::RemoteFetcher.fetcher = fetcher
- sign_in_ui = ui_stub || Gem::MockGemUi.new("#{email}\n#{password}\n")
+ sign_in_ui = ui_stub || Gem::MockGemUi.new("#{email}\n#{password}\n")
use_ui sign_in_ui do
yield
@@ -95,5 +95,4 @@ class TestGemCommandsSigninCommand < Gem::TestCase
sign_in_ui
end
-
end
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index 3a0899245b..54c0246150 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -7,17 +7,11 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
def setup
super
+ spec_fetcher
+
@cmd = Gem::Commands::SourcesCommand.new
@new_repo = "http://beta-gems.example.com"
-
- @old_https_proxy_config = Gem.configuration[:http_proxy]
- end
-
- def teardown
- Gem.configuration[:http_proxy] = @old_https_proxy_config
-
- super
end
def test_initialize_proxy
@@ -46,9 +40,9 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
fetcher.spec 'a', 1
end
- specs = Gem::Specification.map do |spec|
+ specs = Gem::Specification.map { |spec|
[spec.name, spec.version, spec.original_platform]
- end
+ }
specs_dump_gz = StringIO.new
Zlib::GzipWriter.wrap specs_dump_gz do |io|
@@ -74,83 +68,7 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
assert_equal '', @ui.error
end
- def test_execute_add_allow_typo_squatting_source
- rubygems_org = "https://rubyems.org"
-
- spec_fetcher do |fetcher|
- fetcher.spec("a", 1)
- end
-
- specs = Gem::Specification.map do |spec|
- [spec.name, spec.version, spec.original_platform]
- end
-
- specs_dump_gz = StringIO.new
- Zlib::GzipWriter.wrap(specs_dump_gz) do |io|
- Marshal.dump(specs, io)
- end
-
- @fetcher.data["#{rubygems_org}/specs.#{@marshal_version}.gz"] = specs_dump_gz.string
- @cmd.handle_options %W[--add #{rubygems_org}]
- ui = Gem::MockGemUi.new("y")
-
- use_ui ui do
- @cmd.execute
- end
-
- expected = "https://rubyems.org is too similar to https://rubygems.org\n\nDo you want to add this source? [yn] https://rubyems.org added to sources\n"
-
- assert_equal expected, ui.output
-
- source = Gem::Source.new(rubygems_org)
- assert Gem.sources.include?(source)
-
- assert_empty ui.error
- end
-
- def test_execute_add_deny_typo_squatting_source
- rubygems_org = "https://rubyems.org"
-
- spec_fetcher do |fetcher|
- fetcher.spec("a", 1)
- end
-
- specs = Gem::Specification.map do |spec|
- [spec.name, spec.version, spec.original_platform]
- end
-
- specs_dump_gz = StringIO.new
- Zlib::GzipWriter.wrap(specs_dump_gz) do |io|
- Marshal.dump(specs, io)
- end
-
- @fetcher.data["#{rubygems_org}/specs.#{@marshal_version}.gz"] =
- specs_dump_gz.string
-
- @cmd.handle_options %W[--add #{rubygems_org}]
-
- ui = Gem::MockGemUi.new("n")
-
- use_ui ui do
-
- assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
- end
-
- expected = "https://rubyems.org is too similar to https://rubygems.org\n\nDo you want to add this source? [yn] "
-
- assert_equal expected, ui.output
-
- source = Gem::Source.new(rubygems_org)
- refute Gem.sources.include?(source)
-
- assert_empty ui.error
- end
-
def test_execute_add_nonexistent_source
- spec_fetcher
-
uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz"
@fetcher.data[uri] = proc do
raise Gem::RemoteFetcher::FetchError.new('it died', uri)
@@ -174,8 +92,6 @@ Error fetching http://beta-gems.example.com:
end
def test_execute_add_redundant_source
- spec_fetcher
-
@cmd.handle_options %W[--add #{@gem_repo}]
use_ui @ui do
@@ -193,8 +109,6 @@ source #{@gem_repo} already present in the cache
end
def test_execute_add_redundant_source_trailing_slash
- spec_fetcher
-
# Remove pre-existing gem source (w/ slash)
repo_with_slash = "http://gems.example.com/"
@cmd.handle_options %W[--remove #{repo_with_slash}]
@@ -247,15 +161,15 @@ source http://gems.example.com/ already present in the cache
end
def test_execute_add_http_rubygems_org
- http_rubygems_org = 'http://rubygems.org/'
+ http_rubygems_org = 'http://rubygems.org'
spec_fetcher do |fetcher|
fetcher.spec 'a', 1
end
- specs = Gem::Specification.map do |spec|
+ specs = Gem::Specification.map { |spec|
[spec.name, spec.version, spec.original_platform]
- end
+ }
specs_dump_gz = StringIO.new
Zlib::GzipWriter.wrap specs_dump_gz do |io|
@@ -284,44 +198,6 @@ source http://gems.example.com/ already present in the cache
assert_empty @ui.error
end
- def test_execute_add_https_rubygems_org
- https_rubygems_org = 'https://rubygems.org/'
-
- spec_fetcher do |fetcher|
- fetcher.spec 'a', 1
- end
-
- specs = Gem::Specification.map do |spec|
- [spec.name, spec.version, spec.original_platform]
- end
-
- specs_dump_gz = StringIO.new
- Zlib::GzipWriter.wrap specs_dump_gz do |io|
- Marshal.dump specs, io
- end
-
- @fetcher.data["#{https_rubygems_org}/specs.#{@marshal_version}.gz"] =
- specs_dump_gz.string
-
- @cmd.handle_options %W[--add #{https_rubygems_org}]
-
- ui = Gem::MockGemUi.new "n"
-
- use_ui ui do
- assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
- end
-
- assert_equal [@gem_repo], Gem.sources
-
- expected = <<-EXPECTED
- EXPECTED
-
- assert_equal expected, @ui.output
- assert_empty @ui.error
- end
-
def test_execute_add_bad_uri
@cmd.handle_options %w[--add beta-gems.example.com]
@@ -390,8 +266,6 @@ beta-gems.example.com is not a URI
end
def test_execute_remove_no_network
- spec_fetcher
-
@cmd.handle_options %W[--remove #{@gem_repo}]
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
@@ -424,3 +298,4 @@ beta-gems.example.com is not a URI
end
end
+
diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb
index f56aa9777a..c3650649ae 100644
--- a/test/rubygems/test_gem_commands_specification_command.rb
+++ b/test/rubygems/test_gem_commands_specification_command.rb
@@ -105,7 +105,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
end
def test_execute_field
- foo = util_spec 'foo', '2'
+ foo = new_spec 'foo', '2'
install_specs foo
@@ -137,7 +137,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
end
def test_execute_marshal
- foo = util_spec 'foo', '2'
+ foo = new_spec 'foo', '2'
install_specs foo
@@ -248,3 +248,4 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_commands_stale_command.rb b/test/rubygems/test_gem_commands_stale_command.rb
index a8909c6d13..4d2f5349f0 100644
--- a/test/rubygems/test_gem_commands_stale_command.rb
+++ b/test/rubygems/test_gem_commands_stale_command.rb
@@ -6,7 +6,6 @@ class TestGemCommandsStaleCommand < Gem::TestCase
def setup
super
- @stub_ui = Gem::MockGemUi.new
@cmd = Gem::Commands::StaleCommand.new
end
@@ -32,11 +31,11 @@ class TestGemCommandsStaleCommand < Gem::TestCase
FileUtils.touch(filename, :mtime => Time.now - 86400)
end
- use_ui @stub_ui do
+ use_ui @ui do
@cmd.execute
end
- lines = @stub_ui.output.split("\n")
+ lines = @ui.output.split("\n")
assert_equal("#{foo_bar.name}-#{foo_bar.version}", lines[0].split.first)
assert_equal("#{bar_baz.name}-#{bar_baz.version}", lines[1].split.first)
end
diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb
index c3582390f9..2fdff706e7 100644
--- a/test/rubygems/test_gem_commands_uninstall_command.rb
+++ b/test/rubygems/test_gem_commands_uninstall_command.rb
@@ -6,13 +6,19 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
def setup
super
+ common_installer_setup
+
+ build_rake_in do
+ use_ui @ui do
+ @installer.install
+ end
+ end
+
@cmd = Gem::Commands::UninstallCommand.new
@executable = File.join(@gemhome, 'bin', 'executable')
end
def test_execute_all_named
- initial_install
-
util_make_gems
default = new_default_spec 'default', '1'
@@ -41,64 +47,14 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
Gem::Specification.all_names.sort
end
- def test_execute_all_named_default_single
- z_1 = new_default_spec 'z', '1'
- install_default_gems z_1
-
- assert_includes Gem::Specification.all_names, 'z-1'
-
- @cmd.options[:all] = true
- @cmd.options[:args] = %w[z]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal %w[z-1], Gem::Specification.all_names.sort
-
- output = @ui.output.split "\n"
-
- assert_equal 'Gem z-1 cannot be uninstalled because it is a default gem', output.shift
- end
-
- def test_execute_all_named_default_multiple
- z_1 = new_default_spec 'z', '1'
- install_default_gems z_1
-
- z_2, = util_gem 'z', 2
- install_gem z_2
-
- assert_includes Gem::Specification.all_names, 'z-1'
- assert_includes Gem::Specification.all_names, 'z-2'
-
- @cmd.options[:all] = true
- @cmd.options[:args] = %w[z]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal %w[z-1], Gem::Specification.all_names.sort
-
- output = @ui.output.split "\n"
-
- assert_equal 'Gem z-1 cannot be uninstalled because it is a default gem', output.shift
- assert_equal 'Successfully uninstalled z-2', output.shift
- end
-
def test_execute_dependency_order
- initial_install
-
c = quick_gem 'c' do |spec|
spec.add_dependency 'a'
end
util_build_gem c
installer = util_installer c, @gemhome
-
- use_ui @ui do
- installer.install
- end
+ use_ui @ui do installer.install end
ui = Gem::MockGemUi.new
@@ -117,9 +73,17 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_removes_executable
- initial_install
+ ui = Gem::MockGemUi.new
+
+ util_setup_gem ui
+
+ build_rake_in do
+ use_ui ui do
+ @installer.install
+ end
+ end
- if win_platform?
+ if win_platform? then
assert File.exist?(@executable)
else
assert File.symlink?(@executable)
@@ -128,9 +92,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
# Evil hack to prevent false removal success
FileUtils.rm_f @executable
- File.open @executable, "wb+" do |f|
- f.puts "binary"
- end
+ File.open @executable, "wb+" do |f| f.puts "binary" end
@cmd.options[:executables] = true
@cmd.options[:args] = [@spec.name]
@@ -146,14 +108,12 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_removes_formatted_executable
- installer = setup_base_installer
-
FileUtils.rm_f @executable # Wish this didn't happen in #setup
Gem::Installer.exec_format = 'foo-%s-bar'
- installer.format_executable = true
- installer.install
+ @installer.format_executable = true
+ @installer.install
formatted_executable = File.join @gemhome, 'bin', 'foo-executable-bar'
assert_equal true, File.exist?(formatted_executable)
@@ -172,11 +132,11 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
@gem = File.join @tempdir, @spec.file_name
FileUtils.touch @gem
- installer = util_setup_gem
+ util_setup_gem
build_rake_in do
use_ui @ui do
- installer.install
+ @installer.install
end
end
@@ -191,14 +151,11 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
assert_match(/Successfully uninstalled/, output)
end
- def test_execute_with_version_leaves_non_matching_versions
- initial_install
-
+ def test_execute_with_force_leaves_executable
ui = Gem::MockGemUi.new
util_make_gems
-
- assert_equal 3, Gem::Specification.find_all_by_name('a').length
+ util_setup_gem ui
@cmd.options[:version] = '1'
@cmd.options[:force] = true
@@ -208,100 +165,17 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
@cmd.execute
end
- assert_equal 2, Gem::Specification.find_all_by_name('a').length
-
+ assert !Gem::Specification.all_names.include?('a')
assert File.exist? File.join(@gemhome, 'bin', 'executable')
end
- def test_execute_with_version_specified_as_colon
- initial_install
-
+ def test_execute_with_force_uninstalls_all_versions
ui = Gem::MockGemUi.new "y\n"
util_make_gems
+ util_setup_gem ui
- assert_equal 3, Gem::Specification.find_all_by_name('a').length
-
- @cmd.options[:force] = true
- @cmd.options[:args] = ['a:1']
-
- use_ui ui do
- @cmd.execute
- end
-
- assert_equal 2, Gem::Specification.find_all_by_name('a').length
-
- assert File.exist? File.join(@gemhome, 'bin', 'executable')
- end
-
- def test_uninstall_selection
- ui = Gem::MockGemUi.new "1\n"
-
- util_make_gems
-
- list = Gem::Specification.find_all_by_name 'a'
-
- @cmd.options[:args] = ['a']
-
- use_ui ui do
- @cmd.execute
- end
-
- updated_list = Gem::Specification.find_all_by_name('a')
- assert_equal list.length - 1, updated_list.length
-
- assert_match ' 1. a-1', ui.output
- assert_match ' 2. a-2', ui.output
- assert_match ' 3. a-3.a', ui.output
- assert_match ' 4. All versions', ui.output
- assert_match 'uninstalled a-1', ui.output
- end
-
- def test_uninstall_selection_multiple_gems
- ui = Gem::MockGemUi.new "1\n"
-
- util_make_gems
-
- a_list = Gem::Specification.find_all_by_name('a')
- b_list = Gem::Specification.find_all_by_name('b')
- list = a_list + b_list
-
- @cmd.options[:args] = ['a', 'b']
-
- use_ui ui do
- @cmd.execute
- end
-
- updated_a_list = Gem::Specification.find_all_by_name('a')
- updated_b_list = Gem::Specification.find_all_by_name('b')
- updated_list = updated_a_list + updated_b_list
-
- assert_equal list.length - 2, updated_list.length
-
- out = ui.output.split("\n")
- assert_match 'uninstalled b-2', out.shift
- assert_match '', out.shift
- assert_match 'Select gem to uninstall:', out.shift
- assert_match ' 1. a-1', out.shift
- assert_match ' 2. a-2', out.shift
- assert_match ' 3. a-3.a', out.shift
- assert_match ' 4. All versions', out.shift
- assert_match 'uninstalled a-1', out.shift
- assert_empty out
- end
-
- def test_execute_with_force_and_without_version_uninstalls_everything
- initial_install
-
- ui = Gem::MockGemUi.new "y\n"
-
- a_1, = util_gem 'a', 1
- install_gem a_1
-
- a_3a, = util_gem 'a', '3.a'
- install_gem a_3a
-
- assert_equal 3, Gem::Specification.find_all_by_name('a').length
+ assert Gem::Specification.find_all_by_name('a').length > 1
@cmd.options[:force] = true
@cmd.options[:args] = ['a']
@@ -310,17 +184,14 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
@cmd.execute
end
- assert_empty Gem::Specification.find_all_by_name('a')
- assert_match "Removing executable", ui.output
- refute File.exist? @executable
+ refute_includes Gem::Specification.all_names, 'a'
end
def test_execute_with_force_ignores_dependencies
- initial_install
-
ui = Gem::MockGemUi.new
util_make_gems
+ util_setup_gem ui
assert Gem::Specification.find_all_by_name('dep_x').length > 0
assert Gem::Specification.find_all_by_name('x').length > 0
@@ -345,7 +216,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
gemhome2 = "#{@gemhome}2"
a_4, = util_gem 'a', 4
- install_gem a_4
+ install_gem a_4, :install_dir => gemhome2
Gem::Specification.dirs = [@gemhome, gemhome2]
@@ -361,92 +232,51 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
assert_equal %w[default-1], Gem::Specification.all_names.sort
- assert_equal "INFO: Uninstalled all gems in #{@gemhome}", @ui.output.split("\n").last
- end
-
- def test_execute_outside_gem_home
- ui = Gem::MockGemUi.new "y\n"
-
- gemhome2 = "#{@gemhome}2"
-
- a_4, = util_gem 'a', 4
- install_gem a_4 , :install_dir => gemhome2
-
- Gem::Specification.dirs = [@gemhome, gemhome2]
-
- assert_includes Gem::Specification.all_names, 'a-4'
-
- @cmd.options[:args] = ['a:4']
-
- e = assert_raises Gem::InstallError do
- use_ui ui do
- @cmd.execute
- end
- end
-
- assert_includes e.message, "a is not installed in GEM_HOME"
end
def test_handle_options
@cmd.handle_options %w[]
assert_equal false, @cmd.options[:check_dev]
- assert_nil @cmd.options[:install_dir]
+ assert_equal nil, @cmd.options[:install_dir]
assert_equal true, @cmd.options[:user_install]
assert_equal Gem::Requirement.default, @cmd.options[:version]
assert_equal false, @cmd.options[:vendor]
end
def test_handle_options_vendor
- vendordir(File.join(@tempdir, 'vendor')) do
- use_ui @ui do
- @cmd.handle_options %w[--vendor]
- end
+ use_ui @ui do
+ @cmd.handle_options %w[--vendor]
+ end
- assert @cmd.options[:vendor]
- assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
+ assert @cmd.options[:vendor]
+ assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
- assert_empty @ui.output
+ assert_empty @ui.output
- expected = <<-EXPECTED
+ expected = <<-EXPECTED
WARNING: Use your OS package manager to uninstall vendor gems
- EXPECTED
+ EXPECTED
- assert_match expected, @ui.error
- end
+ assert_match expected, @ui.error
end
- def test_execute_two_version
- @cmd.options[:args] = %w[a b]
- @cmd.options[:version] = Gem::Requirement.new("> 1")
-
- use_ui @ui do
- e = assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
+ def test_handle_options_vendor_missing
+ orig_vendordir = RbConfig::CONFIG['vendordir']
+ RbConfig::CONFIG.delete 'vendordir'
- assert_equal 1, e.exit_code
+ e = assert_raises OptionParser::InvalidOption do
+ @cmd.handle_options %w[--vendor]
end
- msg = "ERROR: Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ assert_equal 'invalid option: --vendor your platform is not supported',
+ e.message
- assert_empty @ui.output
- assert_equal msg, @ui.error.lines.last.chomp
- end
-
- def test_handle_options_vendor_missing
- vendordir(nil) do
- e = assert_raises OptionParser::InvalidOption do
- @cmd.handle_options %w[--vendor]
- end
+ refute @cmd.options[:vendor]
+ refute @cmd.options[:install_dir]
- assert_equal 'invalid option: --vendor your platform is not supported',
- e.message
-
- refute @cmd.options[:vendor]
- refute @cmd.options[:install_dir]
- end
+ ensure
+ RbConfig::CONFIG['vendordir'] = orig_vendordir
end
def test_execute_with_gem_not_installed
@@ -461,46 +291,5 @@ WARNING: Use your OS package manager to uninstall vendor gems
assert_equal output.first, "Gem 'd' is not installed"
end
- def test_execute_with_gem_uninstall_error
- initial_install
-
- util_make_gems
-
- @cmd.options[:args] = %w[a]
-
- uninstall_exception = lambda do |_a|
- ex = Gem::UninstallError.new
- ex.spec = @spec
-
- raise ex
- end
-
- e = nil
- @cmd.stub :uninstall, uninstall_exception do
- use_ui @ui do
- e = assert_raises Gem::MockGemUi::TermError do
- @cmd.execute
- end
- end
-
- assert_equal 1, e.exit_code
- end
-
- assert_empty @ui.output
- assert_match %r!Error: unable to successfully uninstall '#{@spec.name}'!, @ui.error
- end
-
- private
-
- def initial_install
- installer = setup_base_installer
- common_installer_setup
-
- build_rake_in do
- use_ui @ui do
- installer.install
- end
- end
- end
-
end
+
diff --git a/test/rubygems/test_gem_commands_unpack_command.rb b/test/rubygems/test_gem_commands_unpack_command.rb
index 7d96caaf57..61f671da7d 100644
--- a/test/rubygems/test_gem_commands_unpack_command.rb
+++ b/test/rubygems/test_gem_commands_unpack_command.rb
@@ -134,23 +134,6 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
assert File.exist?(File.join(@tempdir, 'b-2.gemspec'))
end
- def test_execute_spec_target
- util_make_gems
-
- @cmd.options[:args] = %w[a b]
- @cmd.options[:target] = 'specs'
- @cmd.options[:spec] = true
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- assert File.exist?(File.join(@tempdir, 'specs/a-3.a.gemspec'))
- assert File.exist?(File.join(@tempdir, 'specs/b-2.gemspec'))
- end
-
def test_execute_sudo
skip 'Cannot perform this test on windows (chmod)' if win_platform?
@@ -223,3 +206,4 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index 37f990ea1a..fa444fa32f 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -66,9 +66,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 9 do |s|
- s.files = %w[setup.rb]
- end
+ fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
end
@cmd.options[:args] = []
@@ -109,13 +107,8 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system_multiple
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 8 do |s|
- s.files = %w[setup.rb]
- end
-
- fetcher.download 'rubygems-update', 9 do |s|
- s.files = %w[setup.rb]
- end
+ fetcher.download 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
+ fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
end
@cmd.options[:args] = []
@@ -135,13 +128,8 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system_specific
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 8 do |s|
- s.files = %w[setup.rb]
- end
-
- fetcher.download 'rubygems-update', 9 do |s|
- s.files = %w[setup.rb]
- end
+ fetcher.download 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
+ fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
end
@cmd.options[:args] = []
@@ -161,13 +149,8 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system_specifically_to_latest_version
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 8 do |s|
- s.files = %w[setup.rb]
- end
-
- fetcher.download 'rubygems-update', 9 do |s|
- s.files = %w[setup.rb]
- end
+ fetcher.download 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end
+ fetcher.download 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end
end
@cmd.options[:args] = []
@@ -234,6 +217,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
end
def test_execute_rdoc
+ skip if RUBY_VERSION <= "1.8.7"
spec_fetcher do |fetcher|
fetcher.download 'a', 2
fetcher.spec 'a', 1
@@ -384,7 +368,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
expected = [
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
- Gem::Source.new(@gem_repo)],
+ Gem::Source.new(@gem_repo)],
]
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
@@ -404,15 +388,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 1
fetcher.spec 'a', 2
-
- fetcher.spec 'a', 2 do |s|
- s.platform = platform
- end
+ fetcher.spec 'a', 2 do |s| s.platform = platform end
end
expected = [
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
- Gem::Source.new(@gem_repo)],
+ Gem::Source.new(@gem_repo)],
]
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
@@ -429,9 +410,9 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
expected = [
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
- Gem::Source.new(@gem_repo)],
+ Gem::Source.new(@gem_repo)],
[Gem::NameTuple.new('a', v('3.a'), Gem::Platform::RUBY),
- Gem::Source.new(@gem_repo)],
+ Gem::Source.new(@gem_repo)],
]
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
@@ -504,85 +485,24 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_equal '--prefix', arguments.shift
assert_equal Gem.prefix, arguments.shift
- assert_equal '--no-document', arguments.shift
+ assert_equal '--no-rdoc', arguments.shift
+ assert_equal '--no-ri', arguments.shift
assert_equal '--previous-version', arguments.shift
assert_equal Gem::VERSION, arguments.shift
assert_empty arguments
end
- def test_explain
- spec_fetcher do |fetcher|
- fetcher.download 'a', 2
- fetcher.spec 'a', 1
- end
-
- @cmd.options[:explain] = true
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- @cmd.execute
- end
+ def test_update_rubygems_arguments_1_8_x
+ @cmd.options[:system] = '1.8.26'
- out = @ui.output.split "\n"
-
- assert_equal "Gems to update:", out.shift
- assert_equal " a-2", out.shift
- assert_empty out
- end
-
- def test_explain_platform_local
- local = Gem::Platform.local
- spec_fetcher do |fetcher|
- fetcher.download 'a', 2
-
- fetcher.download 'a', 2 do |s|
- s.platform = local
- end
-
- fetcher.spec 'a', 1
- end
-
- @cmd.options[:explain] = true
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Gems to update:", out.shift
- assert_equal " a-2-#{local}", out.shift
- assert_empty out
- end
-
- def test_explain_platform_ruby
- local = Gem::Platform.local
- spec_fetcher do |fetcher|
- fetcher.download 'a', 2
-
- fetcher.download 'a', 2 do |s|
- s.platform = local
- end
-
- fetcher.spec 'a', 1
- end
-
- # equivalent to --platform=ruby
- Gem.platforms = [Gem::Platform::RUBY]
-
- @cmd.options[:explain] = true
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
+ arguments = @cmd.update_rubygems_arguments
- assert_equal "Gems to update:", out.shift
- assert_equal " a-2", out.shift
- assert_empty out
+ assert_equal '--prefix', arguments.shift
+ assert_equal Gem.prefix, arguments.shift
+ assert_equal '--no-rdoc', arguments.shift
+ assert_equal '--no-ri', arguments.shift
+ assert_empty arguments
end
end
+
diff --git a/test/rubygems/test_gem_commands_which_command.rb b/test/rubygems/test_gem_commands_which_command.rb
index 0d63bb9b37..0c2b177273 100644
--- a/test/rubygems/test_gem_commands_which_command.rb
+++ b/test/rubygems/test_gem_commands_which_command.rb
@@ -84,3 +84,4 @@ class TestGemCommandsWhichCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb
index 1aafc92bfb..70aa2263a6 100644
--- a/test/rubygems/test_gem_commands_yank_command.rb
+++ b/test/rubygems/test_gem_commands_yank_command.rb
@@ -3,7 +3,6 @@ require 'rubygems/test_case'
require 'rubygems/commands/yank_command'
class TestGemCommandsYankCommand < Gem::TestCase
-
def setup
super
@@ -13,7 +12,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
@fetcher = Gem::RemoteFetcher.fetcher
Gem.configuration.rubygems_api_key = 'key'
- Gem.configuration.api_keys[:KEY] = 'other'
+ Gem.configuration.api_keys[:KEY] = 'other'
end
def test_handle_options
@@ -58,50 +57,6 @@ class TestGemCommandsYankCommand < Gem::TestCase
assert_equal [yank_uri], @fetcher.paths
end
- def test_execute_with_otp_success
- response_fail = 'You have enabled multifactor authentication but your request doesn\'t have the correct OTP code. Please check it and retry.'
- yank_uri = 'http://example/api/v1/gems/yank'
- @fetcher.data[yank_uri] = [
- [response_fail, 401, 'Unauthorized'],
- ['Successfully yanked', 200, 'OK']
- ]
-
- @cmd.options[:args] = %w[a]
- @cmd.options[:added_platform] = true
- @cmd.options[:version] = req('= 1.0')
-
- @otp_ui = Gem::MockGemUi.new "111111\n"
- use_ui @otp_ui do
- @cmd.execute
- end
-
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
- assert_match 'Code: ', @otp_ui.output
- assert_match %r%Yanking gem from http://example%, @otp_ui.output
- assert_match %r%Successfully yanked%, @otp_ui.output
- assert_equal '111111', @fetcher.last_request['OTP']
- end
-
- def test_execute_with_otp_failure
- response = 'You have enabled multifactor authentication but your request doesn\'t have the correct OTP code. Please check it and retry.'
- yank_uri = 'http://example/api/v1/gems/yank'
- @fetcher.data[yank_uri] = [response, 401, 'Unauthorized']
-
- @cmd.options[:args] = %w[a]
- @cmd.options[:added_platform] = true
- @cmd.options[:version] = req('= 1.0')
-
- @otp_ui = Gem::MockGemUi.new "111111\n"
- use_ui @otp_ui do
- @cmd.execute
- end
-
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output
- assert_match response, @otp_ui.output
- assert_match 'Code: ', @otp_ui.output
- assert_equal '111111', @fetcher.last_request['OTP']
- end
-
def test_execute_key
yank_uri = 'http://example/api/v1/gems/yank'
@fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK']
@@ -142,3 +97,4 @@ class TestGemCommandsYankCommand < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index 492a0c5a05..e09a76ef98 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -44,7 +44,6 @@ class TestGemConfigFile < Gem::TestCase
assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold
assert_equal true, @cfg.verbose
assert_equal [@gem_repo], Gem.sources
- assert_equal 365, @cfg.cert_expiration_length_days
File.open @temp_conf, 'w' do |fp|
fp.puts ":backtrace: true"
@@ -59,7 +58,6 @@ class TestGemConfigFile < Gem::TestCase
fp.puts "- /var/ruby/1.8/gem_home"
fp.puts ":ssl_verify_mode: 0"
fp.puts ":ssl_ca_cert: /etc/ssl/certs"
- fp.puts ":cert_expiration_length_days: 28"
end
util_config_file
@@ -73,7 +71,6 @@ class TestGemConfigFile < Gem::TestCase
@cfg.path)
assert_equal 0, @cfg.ssl_verify_mode
assert_equal '/etc/ssl/certs', @cfg.ssl_ca_cert
- assert_equal 28, @cfg.cert_expiration_length_days
end
def test_initialize_handle_arguments_config_file
@@ -157,8 +154,8 @@ class TestGemConfigFile < Gem::TestCase
File.open conf3, 'w' do |fp|
fp.puts ':verbose: :loud'
end
- ps = File::PATH_SEPARATOR
- ENV['GEMRC'] = conf1 + ps + conf2 + ps + conf3
+
+ ENV['GEMRC'] = conf1 + ':' + conf2 + ';' + conf3
util_config_file
@@ -167,12 +164,6 @@ class TestGemConfigFile < Gem::TestCase
assert_equal 2048, @cfg.bulk_threshold
end
- def test_set_config_file_name_from_environment_variable
- ENV['GEMRC'] = "/tmp/.gemrc"
- cfg = Gem::ConfigFile.new([])
- assert_equal cfg.config_file_name, "/tmp/.gemrc"
- end
-
def test_api_keys
assert_nil @cfg.instance_variable_get :@api_keys
@@ -350,7 +341,7 @@ if you believe they were disclosed to a third party.
assert_equal expected, YAML.load_file(@cfg.credentials_path)
- unless win_platform?
+ unless win_platform? then
stat = File.stat @cfg.credentials_path
assert_equal 0600, stat.mode & 0600
@@ -495,5 +486,5 @@ if you believe they were disclosed to a third party.
util_config_file
assert_equal(true, @cfg.disable_default_gem_server)
end
-
end
+
diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb
index 0caab10d32..3c11868671 100644
--- a/test/rubygems/test_gem_dependency.rb
+++ b/test/rubygems/test_gem_dependency.rb
@@ -385,11 +385,6 @@ class TestGemDependency < Gem::TestCase
assert_match "Could not find 'b' (= 2.0) among 1 total gem(s)", e.message
end
- def test_identity
- assert_equal dep("a", "= 1").identity, :released
- assert_equal dep("a", "= 1.a").identity, :complete
- assert_equal dep("a", " >= 1.a").identity, :abs_latest
- assert_equal dep("a").identity, :latest
- end
end
+
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 22f3a9158f..3d76291668 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -26,25 +26,22 @@ class TestGemDependencyInstaller < Gem::TestCase
end
def util_setup_gems
- @a1, @a1_gem = util_gem 'a', '1' do |s|
- s.executables << 'a_bin'
- end
-
+ @a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
@a1_pre, @a1_pre_gem = util_gem 'a', '1.a'
-
- @b1, @b1_gem = util_gem 'b', '1' do |s|
+ @b1, @b1_gem = util_gem 'b', '1' do |s|
s.add_dependency 'a'
s.add_development_dependency 'aa'
end
- @c1, @c1_gem = util_gem 'c', '1' do |s|
+ @c1, @c1_gem = util_gem 'c', '1' do |s|
s.add_development_dependency 'b'
end
- @d1, @d1_gem = util_gem 'd', '1' do |s|
+ @d1, @d1_gem = util_gem 'd', '1' do |s|
s.add_development_dependency 'c'
end
+ util_clear_gems
util_reset_gems
end
@@ -55,9 +52,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
- available = Gem::Deprecate.skip_during do
- inst.available_set_for 'a', Gem::Requirement.default
- end
+ available = inst.available_set_for 'a', Gem::Requirement.default
assert_equal %w[a-1], available.set.map { |s| s.spec.full_name }
end
@@ -69,9 +64,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new :prerelease => true
- available = Gem::Deprecate.skip_during do
- inst.available_set_for 'a', Gem::Requirement.default
- end
+ available = inst.available_set_for 'a', Gem::Requirement.default
assert_equal %w[a-10.a],
available.sorted.map { |s| s.spec.full_name }
@@ -86,9 +79,7 @@ class TestGemDependencyInstaller < Gem::TestCase
dep = Gem::Dependency.new 'a', Gem::Requirement.default
- available = Gem::Deprecate.skip_during do
- inst.available_set_for dep, Gem::Requirement.default
- end
+ available = inst.available_set_for dep, Gem::Requirement.default
assert_equal %w[a-1], available.set.map { |s| s.spec.full_name }
end
@@ -103,9 +94,7 @@ class TestGemDependencyInstaller < Gem::TestCase
dep = Gem::Dependency.new 'a', Gem::Requirement.default
dep.prerelease = true
- available = Gem::Deprecate.skip_during do
- inst.available_set_for dep, Gem::Requirement.default
- end
+ available = inst.available_set_for dep, Gem::Requirement.default
assert_equal %w[a-10.a],
available.sorted.map { |s| s.spec.full_name }
@@ -132,6 +121,7 @@ class TestGemDependencyInstaller < Gem::TestCase
p1a, gem = util_gem 'a', '10.a'
util_setup_spec_fetcher(p1a, @a1, @a1_pre)
+ util_clear_gems
p1a_data = Gem.read_binary(gem)
@@ -170,6 +160,7 @@ class TestGemDependencyInstaller < Gem::TestCase
p1a, gem = util_gem 'p', '1.a'
util_setup_spec_fetcher(p1a)
+ util_clear_gems
p1a_data = Gem.read_binary(gem)
@@ -189,6 +180,7 @@ class TestGemDependencyInstaller < Gem::TestCase
util_setup_gems
util_setup_spec_fetcher(@a1, @a1_pre)
+ util_clear_gems
p1a_data = Gem.read_binary(@a1_gem)
@@ -209,6 +201,8 @@ class TestGemDependencyInstaller < Gem::TestCase
s.add_dependency 'b'
end
+ util_clear_gems
+
FileUtils.mv @a1_gem, @tempdir
FileUtils.mv @b1_gem, @tempdir
FileUtils.mv e1_gem, @tempdir
@@ -437,7 +431,7 @@ class TestGemDependencyInstaller < Gem::TestCase
EXTCONF_RB
end
- e1 = util_spec 'e', '1', nil, 'extconf.rb' do |s|
+ e1 = new_spec 'e', '1', nil, 'extconf.rb' do |s|
s.extensions << 'extconf.rb'
end
e1_gem = File.join @tempdir, 'gems', "#{e1.full_name}.gem"
@@ -451,13 +445,9 @@ class TestGemDependencyInstaller < Gem::TestCase
FileUtils.mv f1_gem, @tempdir
inst = nil
- pwd = Dir.getwd
- Dir.chdir @tempdir
- begin
+ Dir.chdir @tempdir do
inst = Gem::DependencyInstaller.new
inst.install 'f'
- ensure
- Dir.chdir pwd
end
assert_equal %w[f-1], inst.installed_gems.map { |s| s.full_name }
@@ -569,6 +559,8 @@ class TestGemDependencyInstaller < Gem::TestCase
s.add_dependency 'a'
end
+ util_clear_gems
+
FileUtils.mv @a1_gem, @tempdir
FileUtils.mv @b1_gem, @tempdir
FileUtils.mv b2_gem, @tempdir
@@ -869,18 +861,15 @@ class TestGemDependencyInstaller < Gem::TestCase
si = util_setup_spec_fetcher @a1, a2_o
+ util_clear_gems
+
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
a1_data = nil
a2_o_data = nil
- File.open @a1_gem, 'rb' do |fp|
- a1_data = fp.read
- end
-
- File.open a2_o_gem, 'rb' do |fp|
- a2_o_data = fp.read
- end
+ File.open @a1_gem, 'rb' do |fp| a1_data = fp.read end
+ File.open a2_o_gem, 'rb' do |fp| a2_o_data = fp.read end
@fetcher.data["http://gems.example.com/gems/#{@a1.file_name}"] =
a1_data
@@ -904,7 +893,7 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[a-1-cpu-other_platform-1], inst.installed_gems.map { |s| s.full_name }
end
- if defined? OpenSSL
+ if defined? OpenSSL then
def test_install_security_policy
util_setup_gems
@@ -929,7 +918,7 @@ class TestGemDependencyInstaller < Gem::TestCase
end
# Wrappers don't work on mswin
- unless win_platform?
+ unless win_platform? then
def test_install_no_wrappers
util_setup_gems
@@ -982,9 +971,7 @@ class TestGemDependencyInstaller < Gem::TestCase
Gem::Specification.reset
- set = Gem::Deprecate.skip_during do
- inst.find_gems_with_sources(dep)
- end
+ set = inst.find_gems_with_sources(dep)
assert_kind_of Gem::AvailableSet, set
@@ -1002,9 +989,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
- available = Gem::Deprecate.skip_during do
- inst.find_spec_by_name_and_version('*.gem')
- end
+ available = inst.find_spec_by_name_and_version('*.gem')
assert_equal %w[a-1], available.each_spec.map { |spec| spec.full_name }
end
@@ -1015,9 +1000,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
assert_raises Gem::Package::FormatError do
- Gem::Deprecate.skip_during do
- inst.find_spec_by_name_and_version '*.gem'
- end
+ inst.find_spec_by_name_and_version '*.gem'
end
end
@@ -1027,9 +1010,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
e = assert_raises Gem::Package::FormatError do
- Gem::Deprecate.skip_during do
- inst.find_spec_by_name_and_version 'rdoc.gem'
- end
+ inst.find_spec_by_name_and_version 'rdoc.gem'
end
full_path = File.join @tempdir, 'rdoc.gem'
@@ -1042,9 +1023,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
e = assert_raises Gem::SpecificGemNotFoundException do
- Gem::Deprecate.skip_during do
- inst.find_spec_by_name_and_version 'rdoc'
- end
+ inst.find_spec_by_name_and_version 'rdoc'
end
assert_equal "Could not find a valid gem 'rdoc' (>= 0) " +
@@ -1058,9 +1037,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
e = assert_raises Gem::SpecificGemNotFoundException do
- Gem::Deprecate.skip_during do
- inst.find_spec_by_name_and_version 'rdoc'
- end
+ inst.find_spec_by_name_and_version 'rdoc'
end
assert_equal "Could not find a valid gem 'rdoc' (>= 0) " +
@@ -1077,9 +1054,7 @@ class TestGemDependencyInstaller < Gem::TestCase
set = nil
Dir.chdir @tempdir do
- set = Gem::Deprecate.skip_during do
- inst.find_gems_with_sources dep
- end
+ set = inst.find_gems_with_sources dep
end
gems = set.sorted
@@ -1094,6 +1069,7 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal 'a-1', remote.spec.full_name, 'remote spec'
assert_equal Gem::Source.new(@gem_repo), remote.source, 'remote path'
+
end
def test_find_gems_with_sources_prerelease
@@ -1103,22 +1079,16 @@ class TestGemDependencyInstaller < Gem::TestCase
dependency = Gem::Dependency.new('a', Gem::Requirement.default)
- set = Gem::Deprecate.skip_during do
- installer.find_gems_with_sources(dependency)
- end
-
- releases = set.all_specs
+ releases =
+ installer.find_gems_with_sources(dependency).all_specs
assert releases.any? { |s| s.name == 'a' and s.version.to_s == '1' }
refute releases.any? { |s| s.name == 'a' and s.version.to_s == '1.a' }
dependency.prerelease = true
- set = Gem::Deprecate.skip_during do
- installer.find_gems_with_sources(dependency)
- end
-
- prereleases = set.all_specs
+ prereleases =
+ installer.find_gems_with_sources(dependency).all_specs
assert_equal [@a1_pre, @a1], prereleases
end
@@ -1135,11 +1105,8 @@ class TestGemDependencyInstaller < Gem::TestCase
dependency = Gem::Dependency.new('a', Gem::Requirement.default)
- set = Gem::Deprecate.skip_during do
- installer.find_gems_with_sources(dependency, true)
- end
-
- releases = set.all_specs
+ releases =
+ installer.find_gems_with_sources(dependency, true).all_specs
assert_equal [a1_x86_mingw32], releases
end
@@ -1151,9 +1118,7 @@ class TestGemDependencyInstaller < Gem::TestCase
dep = Gem::Dependency.new('a')
- out = Gem::Deprecate.skip_during do
- installer.find_gems_with_sources(dep)
- end
+ out = installer.find_gems_with_sources(dep)
assert out.empty?
assert_kind_of Gem::SourceFetchProblem, installer.errors.first
@@ -1264,6 +1229,7 @@ class TestGemDependencyInstaller < Gem::TestCase
util_setup_spec_fetcher(*[@a1, @a1_pre, @b1, @c1_pre,
@d1, @d2, @x1_m, @x1_o, @w1, @y1,
@y1_1_p, @z1].compact)
- end
+ util_clear_gems
+ end
end
diff --git a/test/rubygems/test_gem_dependency_list.rb b/test/rubygems/test_gem_dependency_list.rb
index 6bf803fe5f..d03a8fdfea 100644
--- a/test/rubygems/test_gem_dependency_list.rb
+++ b/test/rubygems/test_gem_dependency_list.rb
@@ -7,30 +7,22 @@ class TestGemDependencyList < Gem::TestCase
def setup
super
+ util_clear_gems
+
@deplist = Gem::DependencyList.new
- # TODO: switch to util_spec
+ # TODO: switch to new_spec
@a1 = util_spec 'a', '1'
@a2 = util_spec 'a', '2'
@a3 = util_spec 'a', '3'
- @b1 = util_spec 'b', '1' do |s|
- s.add_dependency 'a', '>= 1'
- end
-
- @b2 = util_spec 'b', '2' do |s|
- s.add_dependency 'a', '>= 1'
- end
-
- @c1 = util_spec 'c', '1' do |s|
- s.add_dependency 'b', '>= 1'
- end
+ @b1 = util_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
+ @b2 = util_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
+ @c1 = util_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
@c2 = util_spec 'c', '2'
- @d1 = util_spec 'd', '1' do |s|
- s.add_dependency 'c', '>= 1'
- end
+ @d1 = util_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
end
def test_active_count
@@ -122,6 +114,8 @@ class TestGemDependencyList < Gem::TestCase
end
def test_ok_eh
+ util_clear_gems
+
assert @deplist.ok?, 'no dependencies'
@deplist.add @b2
@@ -134,27 +128,29 @@ class TestGemDependencyList < Gem::TestCase
end
def test_why_not_ok_eh
+ util_clear_gems
+
assert_equal({}, @deplist.why_not_ok?)
@deplist.add @b2
exp = {
"b" => [
- Gem::Dependency.new("a", ">= 1")
- ]
+ Gem::Dependency.new("a", ">= 1")
+ ]
}
assert_equal exp, @deplist.why_not_ok?
end
def test_why_not_ok_eh_old_dependency
- a = util_spec 'a', '1',
+ a = new_spec 'a', '1',
'b' => '~> 1.0'
- b0 = util_spec 'b', '1.0',
+ b0 = new_spec 'b', '1.0',
'd' => '>= 0'
- b1 = util_spec 'b', '1.1'
+ b1 = new_spec 'b', '1.1'
util_clear_gems
@@ -169,13 +165,8 @@ class TestGemDependencyList < Gem::TestCase
a1 = util_spec 'a', '1'
a2 = util_spec 'a', '2'
- b = util_spec 'b', '1' do |s|
- s.add_dependency 'a', '= 1'
- end
-
- c = util_spec 'c', '1' do |s|
- s.add_dependency 'a', '= 2'
- end
+ b = util_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end
+ c = util_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end
d = util_spec 'd', '1' do |s|
s.add_dependency 'b'
@@ -223,6 +214,8 @@ class TestGemDependencyList < Gem::TestCase
end
def test_remove_by_name
+ util_clear_gems
+
@deplist.add @a1, @b2
@deplist.remove_by_name "a-1"
@@ -264,3 +257,4 @@ class TestGemDependencyList < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_dependency_resolution_error.rb b/test/rubygems/test_gem_dependency_resolution_error.rb
index cf4663650e..b9625a3c02 100644
--- a/test/rubygems/test_gem_dependency_resolution_error.rb
+++ b/test/rubygems/test_gem_dependency_resolution_error.rb
@@ -26,3 +26,4 @@ class TestGemDependencyResolutionError < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_doctor.rb b/test/rubygems/test_gem_doctor.rb
index a0e3a18d7f..8db65d70ce 100644
--- a/test/rubygems/test_gem_doctor.rb
+++ b/test/rubygems/test_gem_doctor.rb
@@ -4,7 +4,7 @@ require 'rubygems/doctor'
class TestGemDoctor < Gem::TestCase
- def gem(name)
+ def gem name
spec = quick_gem name do |gem|
gem.files = %W[lib/#{name}.rb Rakefile]
end
@@ -166,3 +166,4 @@ This directory does not appear to be a RubyGems repository, skipping
end
end
+
diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb
index 7091acdca0..3dabd3e350 100644
--- a/test/rubygems/test_gem_ext_builder.rb
+++ b/test/rubygems/test_gem_ext_builder.rb
@@ -50,9 +50,15 @@ install:
results = results.join "\n"
- assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
- assert_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
- assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
+ if RUBY_VERSION > '2.0' then
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
+ else
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
+ end
if /nmake/ !~ results
assert_match %r%^clean: destination$%, results
@@ -81,9 +87,15 @@ install:
results = results.join "\n"
- assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
- assert_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
- assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
+ if RUBY_VERSION > '2.0' then
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
+ else
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
+ end
end
def test_build_extensions
@@ -122,6 +134,11 @@ install:
end
def test_build_extensions_with_gemhome_with_space
+ # Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940
+ if win_platform? && RUBY_VERSION <= '2.0'
+ skip 'gemhome with spaces does not work with Ruby 1.9.x on Windows'
+ end
+
new_gemhome = File.join @tempdir, 'gem home'
File.rename(@gemhome, new_gemhome)
@gemhome = new_gemhome
@@ -134,7 +151,6 @@ install:
def test_build_extensions_install_ext_only
class << Gem
-
alias orig_install_extension_in_lib install_extension_in_lib
remove_method :install_extension_in_lib
@@ -142,7 +158,6 @@ install:
def Gem.install_extension_in_lib
false
end
-
end
@spec.extensions << 'ext/extconf.rb'
@@ -179,11 +194,9 @@ install:
refute_path_exists File.join @spec.gem_dir, 'lib', 'a', 'b.rb'
ensure
class << Gem
-
remove_method :install_extension_in_lib
alias install_extension_in_lib orig_install_extension_in_lib
-
end
end
@@ -214,8 +227,6 @@ install:
end
def test_build_extensions_extconf_bad
- cwd = Dir.pwd
-
@spec.extensions << 'extconf.rb'
FileUtils.mkdir_p @spec.gem_dir
@@ -246,8 +257,6 @@ install:
assert_match %r%#{Regexp.escape Gem.ruby}: No such file%,
File.read(gem_make_out)
-
- assert_equal cwd, Dir.pwd
end
def test_build_extensions_unsupported
@@ -329,4 +338,4 @@ install:
assert_equal %w[--with-foo-dir=/nonexistent], builder.build_args
end
-end unless Gem.java_platform?
+end
diff --git a/test/rubygems/test_gem_ext_cmake_builder.rb b/test/rubygems/test_gem_ext_cmake_builder.rb
index f7dc383fe9..2093c7da55 100644
--- a/test/rubygems/test_gem_ext_cmake_builder.rb
+++ b/test/rubygems/test_gem_ext_cmake_builder.rb
@@ -10,9 +10,7 @@ class TestGemExtCmakeBuilder < Gem::TestCase
# Details: https://github.com/rubygems/rubygems/issues/1270#issuecomment-177368340
skip "CmakeBuilder doesn't work on Windows." if Gem.win_platform?
- skip "CmakeBuilder doesn't work on JRuby." if Gem.java_platform? && ENV["CI"]
-
- system('cmake', out: IO::NULL, err: [:child, :out])
+ `cmake #{Gem::Ext::Builder.redirector}`
skip 'cmake not present' unless $?.success?
@@ -27,7 +25,6 @@ class TestGemExtCmakeBuilder < Gem::TestCase
File.open File.join(@ext, 'CMakeLists.txt'), 'w' do |cmakelists|
cmakelists.write <<-eo_cmake
cmake_minimum_required(VERSION 2.6)
-project(self_build NONE)
install (FILES test.txt DESTINATION bin)
eo_cmake
end
@@ -37,7 +34,7 @@ install (FILES test.txt DESTINATION bin)
output = []
Dir.chdir @ext do
- Gem::Ext::CmakeBuilder.build nil, @dest_path, output
+ Gem::Ext::CmakeBuilder.build nil, nil, @dest_path, output
end
output = output.join "\n"
@@ -55,7 +52,7 @@ install (FILES test.txt DESTINATION bin)
error = assert_raises Gem::InstallError do
Dir.chdir @ext do
- Gem::Ext::CmakeBuilder.build nil, @dest_path, output
+ Gem::Ext::CmakeBuilder.build nil, nil, @dest_path, output
end
end
@@ -78,7 +75,7 @@ install (FILES test.txt DESTINATION bin)
output = []
Dir.chdir @ext do
- Gem::Ext::CmakeBuilder.build nil, @dest_path, output
+ Gem::Ext::CmakeBuilder.build nil, nil, @dest_path, output
end
output = output.join "\n"
diff --git a/test/rubygems/test_gem_ext_configure_builder.rb b/test/rubygems/test_gem_ext_configure_builder.rb
index eeeb654ae9..cf7559d56c 100644
--- a/test/rubygems/test_gem_ext_configure_builder.rb
+++ b/test/rubygems/test_gem_ext_configure_builder.rb
@@ -18,10 +18,6 @@ class TestGemExtConfigureBuilder < Gem::TestCase
end
def test_self_build
- if java_platform? && ENV["CI"]
- skip("failing on jruby")
- end
-
skip("test_self_build skipped on MS Windows (VC++)") if vc_windows?
File.open File.join(@ext, './configure'), 'w' do |configure|
@@ -31,7 +27,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase
output = []
Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, @dest_path, output
+ Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
end
assert_match(/^current directory:/, output.shift)
@@ -49,16 +45,12 @@ class TestGemExtConfigureBuilder < Gem::TestCase
end
def test_self_build_fail
- if java_platform? && ENV["CI"]
- skip("failing on jruby")
- end
-
skip("test_self_build_fail skipped on MS Windows (VC++)") if vc_windows?
output = []
error = assert_raises Gem::InstallError do
Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, @dest_path, output
+ Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
end
end
@@ -84,7 +76,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase
output = []
Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, @dest_path, output
+ Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
end
assert_contains_make_command 'clean', output[1]
diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb
index 556761c979..b43ebf00d9 100644
--- a/test/rubygems/test_gem_ext_ext_conf_builder.rb
+++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb
@@ -17,10 +17,6 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
def test_class_build
- if java_platform?
- skip("failing on jruby")
- end
-
if vc_windows? && !nmake_found?
skip("test_class_build skipped - nmake not found")
end
@@ -33,7 +29,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
Dir.chdir @ext do
result =
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
assert_same result, output
end
@@ -49,10 +45,6 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
def test_class_build_rbconfig_make_prog
- if java_platform?
- skip("failing on jruby")
- end
-
configure_args do
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
@@ -62,7 +54,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
output = []
Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
assert_equal "creating Makefile\n", output[2]
@@ -76,10 +68,6 @@ class TestGemExtExtConfBuilder < Gem::TestCase
env_make = ENV.delete 'MAKE'
ENV['MAKE'] = 'anothermake'
- if java_platform?
- skip("failing on jruby")
- end
-
configure_args '' do
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
@@ -89,7 +77,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
assert_raises Gem::InstallError do
Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
end
@@ -115,7 +103,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
error = assert_raises Gem::InstallError do
Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
end
@@ -142,7 +130,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
output = []
Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
refute_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n")
@@ -184,7 +172,7 @@ end
output = []
Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
assert_contains_make_command 'clean', output[4]
@@ -228,14 +216,14 @@ end
assert_equal 'Makefile not found', error.message
end
- def configure_args(args = nil)
+ def configure_args args = nil
configure_args = RbConfig::CONFIG['configure_args']
RbConfig::CONFIG['configure_args'] = args if args
yield
ensure
- if configure_args
+ if configure_args then
RbConfig::CONFIG['configure_args'] = configure_args
else
RbConfig::CONFIG.delete 'configure_args'
@@ -243,3 +231,4 @@ end
end
end
+
diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb
index c86ff07649..3229982778 100644
--- a/test/rubygems/test_gem_ext_rake_builder.rb
+++ b/test/rubygems/test_gem_ext_rake_builder.rb
@@ -3,7 +3,6 @@ require 'rubygems/test_case'
require 'rubygems/ext'
class TestGemExtRakeBuilder < Gem::TestCase
-
def setup
super
@@ -17,17 +16,19 @@ class TestGemExtRakeBuilder < Gem::TestCase
def test_class_build
create_temp_mkrf_file('task :default')
output = []
+ realdir = nil # HACK /tmp vs. /private/tmp
build_rake_in do |rake|
Dir.chdir @ext do
- Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', @dest_path, output
+ realdir = Dir.pwd
+ Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
end
output = output.join "\n"
refute_match %r%^rake failed:%, output
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
- assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path}%, output
+ assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
end
end
@@ -37,33 +38,20 @@ class TestGemExtRakeBuilder < Gem::TestCase
def test_class_build_with_args
create_temp_mkrf_file('task :default')
output = []
+ realdir = nil # HACK /tmp vs. /private/tmp
build_rake_in do |rake|
Dir.chdir @ext do
+ realdir = Dir.pwd
non_empty_args_list = ['']
- Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', @dest_path, output, non_empty_args_list
+ Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output, non_empty_args_list
end
output = output.join "\n"
refute_match %r%^rake failed:%, output
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
- assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path}%, output
- end
- end
-
- def test_class_build_no_mkrf_passes_args
- output = []
-
- build_rake_in do |rake|
- Dir.chdir @ext do
- Gem::Ext::RakeBuilder.build "ext/Rakefile", @dest_path, output, ["test1", "test2"]
- end
-
- output = output.join "\n"
-
- refute_match %r%^rake failed:%, output
- assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path} test1 test2%, output
+ assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
end
end
@@ -74,7 +62,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
build_rake_in(false) do |rake|
error = assert_raises Gem::InstallError do
Dir.chdir @ext do
- Gem::Ext::RakeBuilder.build "mkrf_conf.rb", @dest_path, output
+ Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
end
end
@@ -91,5 +79,4 @@ class TestGemExtRakeBuilder < Gem::TestCase
EO_MKRF
end
end
-
end
diff --git a/test/rubygems/test_gem_gem_runner.rb b/test/rubygems/test_gem_gem_runner.rb
index efde71dce6..0a1faa404a 100644
--- a/test/rubygems/test_gem_gem_runner.rb
+++ b/test/rubygems/test_gem_gem_runner.rb
@@ -1,15 +1,45 @@
# frozen_string_literal: true
require 'rubygems/test_case'
+begin
+ gem_home_files = lambda{
+ if Dir.exist?(ENV["GEM_HOME"])
+ require "find"
+ ary = Find.find(ENV["GEM_HOME"]).to_a
+ else
+ []
+ end
+ }
+ prev_gem_home = ENV["GEM_HOME"]
+ prev_gem_home_files = gem_home_files.call
+ prev_threads = Thread.list.map{|e| e.inspect}
+
+ require 'rubygems/gem_runner'
+ensure
+ if $!
+ msg = <<eom
+***************
+PREV
+ GEM_HOME: #{prev_gem_home}
+ Files in GEM_HOME: #{prev_gem_home_files.inspect}
+ Threads: #{prev_threads.inspect}
+Current:
+ GEM_HOME: #{ENV["GEM_HOME"]}
+ Files in GEM_HOME: #{gem_home_files.call}
+ Threads: #{Thread.list.map{|e| e.inspect}.inspect}
+Exception: #{$!.message}
+eom
+ p $!.class
+ p $!.message.frozen?
+ raise $!.class, msg, $!.backtrace
+ end
+end
class TestGemGemRunner < Gem::TestCase
def setup
super
- require 'rubygems/command'
@orig_args = Gem::Command.build_args
-
- require 'rubygems/gem_runner'
@runner = Gem::GemRunner.new
end
@@ -68,3 +98,4 @@ class TestGemGemRunner < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 03bb78271b..286d59a787 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -8,8 +8,6 @@ class TestGemGemcutterUtilities < Gem::TestCase
def setup
super
- # below needed for random testing, class property
- Gem.configuration.disable_default_gem_server = nil
ENV['RUBYGEMS_HOST'] = nil
Gem.configuration.rubygems_api_key = nil
@@ -90,7 +88,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK']
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
@@ -102,7 +100,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_with_host
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK'], 'http://example.com', ['http://example.com']
@@ -116,7 +114,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_with_host_nil
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK'], nil, [nil]
@@ -130,7 +128,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_with_host_ENV
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK'], 'http://example.com'
assert_match "Enter your http://example.com credentials.",
@@ -143,7 +141,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_skips_with_existing_credentials
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
Gem.configuration.rubygems_api_key = api_key
util_sign_in [api_key, 200, 'OK']
@@ -152,8 +150,8 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_sign_in_skips_with_key_override
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
- Gem.configuration.api_keys[:KEY] = 'other'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+ Gem.configuration.api_keys[:KEY] = 'other'
@cmd.options[:key] = :KEY
util_sign_in [api_key, 200, 'OK']
@@ -173,12 +171,14 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
assert_match %r{Signed in.}, @sign_in_ui.output
- credentials = YAML.load_file Gem.configuration.credentials_path
+ credentials = YAML.load_file Gem.configuration.credentials_path
assert_equal api_key, credentials[:rubygems_api_key]
assert_equal other_api_key, credentials[:other_api_key]
end
def test_sign_in_with_bad_credentials
+ skip 'Always uses $stdin on windows' if Gem.win_platform?
+
assert_raises Gem::MockGemUi::TermError do
util_sign_in ['Access Denied.', 403, 'Forbidden']
end
@@ -187,35 +187,9 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match %r{Access Denied.}, @sign_in_ui.output
end
- def test_sign_in_with_correct_otp_code
- api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
- response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
-
- util_sign_in(proc do
- @call_count ||= 0
- (@call_count += 1).odd? ? [response_fail, 401, 'Unauthorized'] : [api_key, 200, 'OK']
- end, nil, [], "111111\n")
-
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @sign_in_ui.output
- assert_match 'Code: ', @sign_in_ui.output
- assert_match 'Signed in.', @sign_in_ui.output
- assert_equal '111111', @fetcher.last_request['OTP']
- end
-
- def test_sign_in_with_incorrect_otp_code
- response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
-
- assert_raises Gem::MockGemUi::TermError do
- util_sign_in [response, 401, 'Unauthorized'], nil, [], "111111\n"
- end
-
- assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @sign_in_ui.output
- assert_match 'Code: ', @sign_in_ui.output
- assert_match response, @sign_in_ui.output
- assert_equal '111111', @fetcher.last_request['OTP']
- end
+ def util_sign_in response, host = nil, args = []
+ skip 'Always uses $stdin on windows' if Gem.win_platform?
- def util_sign_in(response, host = nil, args = [], extra_input = '')
email = 'you@example.com'
password = 'secret'
@@ -229,10 +203,10 @@ class TestGemGemcutterUtilities < Gem::TestCase
@fetcher.data["#{host}/api/v1/api_key"] = response
Gem::RemoteFetcher.fetcher = @fetcher
- @sign_in_ui = Gem::MockGemUi.new("#{email}\n#{password}\n" + extra_input)
+ @sign_in_ui = Gem::MockGemUi.new "#{email}\n#{password}\n"
use_ui @sign_in_ui do
- if args.length > 0
+ if args.length > 0 then
@cmd.sign_in(*args)
else
@cmd.sign_in
diff --git a/test/rubygems/test_gem_impossible_dependencies_error.rb b/test/rubygems/test_gem_impossible_dependencies_error.rb
index 8a0f8d6196..027c99a9e5 100644
--- a/test/rubygems/test_gem_impossible_dependencies_error.rb
+++ b/test/rubygems/test_gem_impossible_dependencies_error.rb
@@ -59,3 +59,4 @@ rye-0.9.8 requires net-ssh (>= 2.0.13) but it conflicted:
end
end
+
diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb
index fdef33e464..5a9075e676 100644
--- a/test/rubygems/test_gem_indexer.rb
+++ b/test/rubygems/test_gem_indexer.rb
@@ -2,8 +2,8 @@
require 'rubygems/test_case'
require 'rubygems/indexer'
-unless defined?(Builder::XChar)
- warn "Gem::Indexer tests are being skipped. Install builder gem."
+unless defined?(Builder::XChar) then
+ warn "Gem::Indexer tests are being skipped. Install builder gem." if $VERBOSE
end
class TestGemIndexer < Gem::TestCase
@@ -11,6 +11,7 @@ class TestGemIndexer < Gem::TestCase
def setup
super
+ util_clear_gems
util_make_gems
@d2_0 = util_spec 'd', '2.0' do |s|
@@ -27,23 +28,23 @@ class TestGemIndexer < Gem::TestCase
@default = new_default_spec 'default', 2
install_default_gems @default
- @indexerdir = File.join(@tempdir, 'indexer')
+ @tempdir = File.join(@tempdir, 'indexer')
- gems = File.join(@indexerdir, 'gems')
+ gems = File.join(@tempdir, 'gems')
FileUtils.mkdir_p gems
FileUtils.mv Dir[File.join(@gemhome, "cache", '*.gem')], gems
- @indexer = Gem::Indexer.new(@indexerdir)
+ @indexer = Gem::Indexer.new(@tempdir)
end
def test_initialize
- assert_equal @indexerdir, @indexer.dest_directory
+ assert_equal @tempdir, @indexer.dest_directory
assert_match %r{#{Dir.mktmpdir('gem_generate_index').match(/.*-/)}}, @indexer.directory
- indexer = Gem::Indexer.new @indexerdir
+ indexer = Gem::Indexer.new @tempdir
assert indexer.build_modern
- indexer = Gem::Indexer.new @indexerdir, :build_modern => true
+ indexer = Gem::Indexer.new @tempdir, :build_modern => true
assert indexer.build_modern
end
@@ -92,22 +93,22 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- quickdir = File.join @indexerdir, 'quick'
+ quickdir = File.join @tempdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
- assert_directory_exists quickdir
- assert_directory_exists marshal_quickdir
+ assert File.directory?(quickdir)
+ assert File.directory?(marshal_quickdir)
assert_indexed marshal_quickdir, "#{File.basename(@a1.spec_file)}.rz"
assert_indexed marshal_quickdir, "#{File.basename(@a2.spec_file)}.rz"
refute_indexed marshal_quickdir, File.basename(@c1_2.spec_file)
- assert_indexed @indexerdir, "specs.#{@marshal_version}"
- assert_indexed @indexerdir, "specs.#{@marshal_version}.gz"
+ assert_indexed @tempdir, "specs.#{@marshal_version}"
+ assert_indexed @tempdir, "specs.#{@marshal_version}.gz"
- assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
- assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
+ assert_indexed @tempdir, "latest_specs.#{@marshal_version}"
+ assert_indexed @tempdir, "latest_specs.#{@marshal_version}.gz"
end
def test_generate_index_modern
@@ -117,16 +118,16 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- refute_indexed @indexerdir, 'yaml'
- refute_indexed @indexerdir, 'yaml.Z'
- refute_indexed @indexerdir, "Marshal.#{@marshal_version}"
- refute_indexed @indexerdir, "Marshal.#{@marshal_version}.Z"
+ refute_indexed @tempdir, 'yaml'
+ refute_indexed @tempdir, 'yaml.Z'
+ refute_indexed @tempdir, "Marshal.#{@marshal_version}"
+ refute_indexed @tempdir, "Marshal.#{@marshal_version}.Z"
- quickdir = File.join @indexerdir, 'quick'
+ quickdir = File.join @tempdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
- assert_directory_exists quickdir, 'quickdir should be directory'
- assert_directory_exists marshal_quickdir
+ assert File.directory?(quickdir), 'quickdir should be directory'
+ assert File.directory?(marshal_quickdir)
refute_indexed quickdir, "index"
refute_indexed quickdir, "index.rz"
@@ -148,11 +149,11 @@ class TestGemIndexer < Gem::TestCase
refute_indexed quickdir, "#{File.basename(@c1_2.spec_file)}"
refute_indexed marshal_quickdir, "#{File.basename(@c1_2.spec_file)}"
- assert_indexed @indexerdir, "specs.#{@marshal_version}"
- assert_indexed @indexerdir, "specs.#{@marshal_version}.gz"
+ assert_indexed @tempdir, "specs.#{@marshal_version}"
+ assert_indexed @tempdir, "specs.#{@marshal_version}.gz"
- assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
- assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
+ assert_indexed @tempdir, "latest_specs.#{@marshal_version}"
+ assert_indexed @tempdir, "latest_specs.#{@marshal_version}.gz"
end
def test_generate_index_modern_back_to_back
@@ -162,26 +163,26 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- @indexer = Gem::Indexer.new @indexerdir
+ @indexer = Gem::Indexer.new @tempdir
@indexer.build_modern = true
use_ui @ui do
@indexer.generate_index
end
- quickdir = File.join @indexerdir, 'quick'
+ quickdir = File.join @tempdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
- assert_directory_exists quickdir
- assert_directory_exists marshal_quickdir
+ assert File.directory?(quickdir)
+ assert File.directory?(marshal_quickdir)
assert_indexed marshal_quickdir, "#{File.basename(@a1.spec_file)}.rz"
assert_indexed marshal_quickdir, "#{File.basename(@a2.spec_file)}.rz"
- assert_indexed @indexerdir, "specs.#{@marshal_version}"
- assert_indexed @indexerdir, "specs.#{@marshal_version}.gz"
+ assert_indexed @tempdir, "specs.#{@marshal_version}"
+ assert_indexed @tempdir, "specs.#{@marshal_version}.gz"
- assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
- assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
+ assert_indexed @tempdir, "latest_specs.#{@marshal_version}"
+ assert_indexed @tempdir, "latest_specs.#{@marshal_version}.gz"
end
def test_generate_index_ui
@@ -207,7 +208,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- specs_path = File.join @indexerdir, "specs.#{@marshal_version}"
+ specs_path = File.join @tempdir, "specs.#{@marshal_version}"
specs_dump = Gem.read_binary specs_path
specs = Marshal.load specs_dump
@@ -244,7 +245,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- latest_specs_path = File.join @indexerdir, "latest_specs.#{@marshal_version}"
+ latest_specs_path = File.join @tempdir, "latest_specs.#{@marshal_version}"
latest_specs_dump = Gem.read_binary latest_specs_path
latest_specs = Marshal.load latest_specs_dump
@@ -274,7 +275,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- prerelease_specs_path = File.join @indexerdir, "prerelease_specs.#{@marshal_version}"
+ prerelease_specs_path = File.join @tempdir, "prerelease_specs.#{@marshal_version}"
prerelease_specs_dump = Gem.read_binary prerelease_specs_path
prerelease_specs = Marshal.load prerelease_specs_dump
@@ -298,16 +299,17 @@ class TestGemIndexer < Gem::TestCase
util_remove_gem sys_gem
end
+
def test_update_index
use_ui @ui do
@indexer.generate_index
end
- quickdir = File.join @indexerdir, 'quick'
+ quickdir = File.join @tempdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
- assert_directory_exists quickdir
- assert_directory_exists marshal_quickdir
+ assert File.directory?(quickdir)
+ assert File.directory?(marshal_quickdir)
@d2_1 = util_spec 'd', '2.1'
util_build_gem @d2_1
@@ -317,7 +319,7 @@ class TestGemIndexer < Gem::TestCase
util_build_gem @d2_1_a
@d2_1_a_tuple = [@d2_1_a.name, @d2_1_a.version, @d2_1_a.original_platform]
- gems = File.join @indexerdir, 'gems'
+ gems = File.join @tempdir, 'gems'
FileUtils.mv @d2_1.cache_file, gems
FileUtils.mv @d2_1_a.cache_file, gems
@@ -361,3 +363,4 @@ class TestGemIndexer < Gem::TestCase
end
end if defined?(Builder::XChar)
+
diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb
index c6b4778336..371e408d27 100644
--- a/test/rubygems/test_gem_install_update_options.rb
+++ b/test/rubygems/test_gem_install_update_options.rb
@@ -21,16 +21,16 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
--build-root build_root
--format-exec
--ignore-dependencies
- --document
+ --rdoc
+ --ri
-E
-f
-i /install_to
-w
+ --vendor
--post-install-message
]
- args.concat %w[--vendor] unless Gem.java_platform?
-
args.concat %w[-P HighSecurity] if defined?(OpenSSL::SSL)
assert @cmd.handles?(args)
@@ -92,6 +92,24 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
assert_equal %w[ri], @cmd.options[:document]
end
+ def test_rdoc
+ @cmd.handle_options %w[--rdoc]
+
+ assert_equal %w[rdoc ri], @cmd.options[:document].sort
+ end
+
+ def test_rdoc_no
+ @cmd.handle_options %w[--no-rdoc]
+
+ assert_equal %w[ri], @cmd.options[:document]
+ end
+
+ def test_ri
+ @cmd.handle_options %w[--no-ri]
+
+ assert_equal %w[], @cmd.options[:document]
+ end
+
def test_security_policy
skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@@ -101,8 +119,6 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_security_policy_unknown
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
-
@cmd.add_install_update_options
e = assert_raises OptionParser::InvalidArgument do
@@ -112,13 +128,6 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_user_install_enabled
- @spec = quick_gem 'a' do |spec|
- util_make_exec spec
- end
-
- util_build_gem @spec
- @gem = @spec.cache_file
-
@cmd.handle_options %w[--user-install]
assert @cmd.options[:user_install]
@@ -130,13 +139,6 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_user_install_disabled_read_only
- @spec = quick_gem 'a' do |spec|
- util_make_exec spec
- end
-
- util_build_gem @spec
- @gem = @spec.cache_file
-
if win_platform?
skip('test_user_install_disabled_read_only test skipped on MS Windows')
elsif Process.uid.zero?
@@ -160,26 +162,28 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_vendor
- vendordir(File.join(@tempdir, 'vendor')) do
- @cmd.handle_options %w[--vendor]
+ @cmd.handle_options %w[--vendor]
- assert @cmd.options[:vendor]
- assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
- end
+ assert @cmd.options[:vendor]
+ assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
end
def test_vendor_missing
- vendordir(nil) do
- e = assert_raises OptionParser::InvalidOption do
- @cmd.handle_options %w[--vendor]
- end
+ orig_vendordir = RbConfig::CONFIG['vendordir']
+ RbConfig::CONFIG.delete 'vendordir'
- assert_equal 'invalid option: --vendor your platform is not supported',
- e.message
-
- refute @cmd.options[:vendor]
- refute @cmd.options[:install_dir]
+ e = assert_raises OptionParser::InvalidOption do
+ @cmd.handle_options %w[--vendor]
end
+
+ assert_equal 'invalid option: --vendor your platform is not supported',
+ e.message
+
+ refute @cmd.options[:vendor]
+ refute @cmd.options[:install_dir]
+
+ ensure
+ RbConfig::CONFIG['vendordir'] = orig_vendordir
end
def test_post_install_message_no
@@ -193,5 +197,4 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
assert_equal true, @cmd.options[:post_install_message]
end
-
end
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 731a1ac01d..a47a307049 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -2,12 +2,8 @@
require 'rubygems/installer_test_case'
class TestGemInstaller < Gem::InstallerTestCase
-
@@symlink_supported = nil
- # Our CI does not currently hit the "symlink not supported" case, but this is
- # needed for Windows developers without symlink support enabled (the default
- # for non admin) to be able to run the tests successfully
def symlink_supported?
if @@symlink_supported.nil?
begin
@@ -25,6 +21,11 @@ class TestGemInstaller < Gem::InstallerTestCase
super
common_installer_setup
+ if __name__ =~ /^test_install(_|$)/ then
+ FileUtils.rm_r @spec.gem_dir
+ FileUtils.rm_r @user_spec.gem_dir
+ end
+
@config = Gem.configuration
end
@@ -33,12 +34,10 @@ class TestGemInstaller < Gem::InstallerTestCase
super
- Gem.configuration = instance_variable_defined?(:@config) ? @config : nil
+ Gem.configuration = @config
end
def test_app_script_text
- installer = setup_base_installer
-
util_make_exec @spec, ''
expected = <<-EOF
@@ -54,11 +53,11 @@ require 'rubygems'
version = \">= 0.a\"
-str = ARGV.first
-if str
- str = str.b[/\\A_(.*)_\\z/, 1]
- if str and Gem::Version.correct?(str)
- version = str
+if ARGV.first
+ str = ARGV.first
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
+ if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
+ version = $1
ARGV.shift
end
end
@@ -71,14 +70,12 @@ load Gem.bin_path("a", "executable", version)
end
EOF
- wrapper = installer.app_script_text 'executable'
+ wrapper = @installer.app_script_text 'executable'
assert_equal expected, wrapper
end
def test_check_executable_overwrite
- installer = setup_base_installer
-
- installer.generate_bin
+ @installer.generate_bin
@spec = Gem::Specification.new do |s|
s.files = ['lib/code.rb']
@@ -90,9 +87,9 @@ end
end
util_make_exec
- installer.gem_dir = @spec.gem_dir
- installer.wrappers = true
- installer.generate_bin
+ @installer.gem_dir = @spec.gem_dir
+ @installer.wrappers = true
+ @installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -102,28 +99,37 @@ end
end
def test_check_executable_overwrite_default_bin_dir
- installer = setup_base_installer
-
- bindir(Gem.bindir) do
- util_conflict_executable false
+ if defined?(RUBY_FRAMEWORK_VERSION)
+ orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION
+ Object.send :remove_const, :RUBY_FRAMEWORK_VERSION
+ end
+ orig_bindir = RbConfig::CONFIG['bindir']
+ RbConfig::CONFIG['bindir'] = Gem.bindir
- ui = Gem::MockGemUi.new "n\n"
- use_ui ui do
- e = assert_raises Gem::InstallError do
- installer.generate_bin
- end
+ util_conflict_executable false
- conflicted = File.join @gemhome, 'bin', 'executable'
- assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
- e.message
+ ui = Gem::MockGemUi.new "n\n"
+ use_ui ui do
+ e = assert_raises Gem::InstallError do
+ @installer.generate_bin
end
+
+ conflicted = File.join @gemhome, 'bin', 'executable'
+ assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
+ e.message
+ end
+ ensure
+ Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
+ orig_RUBY_FRAMEWORK_VERSION
+ if orig_bindir then
+ RbConfig::CONFIG['bindir'] = orig_bindir
+ else
+ RbConfig::CONFIG.delete 'bindir'
end
end
def test_check_executable_overwrite_format_executable
- installer = setup_base_installer
-
- installer.generate_bin
+ @installer.generate_bin
@spec = Gem::Specification.new do |s|
s.files = ['lib/code.rb']
@@ -135,7 +141,7 @@ end
end
File.open File.join(util_inst_bindir, 'executable'), 'w' do |io|
- io.write <<-EXEC
+ io.write <<-EXEC
#!/usr/local/bin/ruby
#
# This file was generated by RubyGems
@@ -146,31 +152,27 @@ gem 'other', version
util_make_exec
Gem::Installer.exec_format = 'foo-%s-bar'
- installer.gem_dir = @spec.gem_dir
- installer.wrappers = true
- installer.format_executable = true
+ @installer.gem_dir = @spec.gem_dir
+ @installer.wrappers = true
+ @installer.format_executable = true
- installer.generate_bin # should not raise
+ @installer.generate_bin # should not raise
installed_exec = File.join util_inst_bindir, 'foo-executable-bar'
assert_path_exists installed_exec
wrapper = File.read installed_exec
assert_match %r|generated by RubyGems|, wrapper
- ensure
- Gem::Installer.exec_format = nil
end
def test_check_executable_overwrite_other_gem
- installer = setup_base_installer
-
util_conflict_executable true
ui = Gem::MockGemUi.new "n\n"
use_ui ui do
e = assert_raises Gem::InstallError do
- installer.generate_bin
+ @installer.generate_bin
end
assert_equal '"executable" from a conflicts with installed executable from conflict',
@@ -179,13 +181,11 @@ gem 'other', version
end
def test_check_executable_overwrite_other_gem_force
- installer = setup_base_installer
-
util_conflict_executable true
- installer.wrappers = true
- installer.force = true
+ @installer.wrappers = true
+ @installer.force = true
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -195,12 +195,10 @@ gem 'other', version
end
def test_check_executable_overwrite_other_non_gem
- installer = setup_base_installer
-
util_conflict_executable false
- installer.wrappers = true
+ @installer.wrappers = true
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -210,9 +208,7 @@ gem 'other', version
end unless Gem.win_platform?
def test_check_that_user_bin_dir_is_in_path
- installer = setup_base_installer
-
- bin_dir = installer.bin_dir
+ bin_dir = @installer.bin_dir
if Gem.win_platform?
bin_dir = bin_dir.downcase.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
@@ -222,7 +218,7 @@ gem 'other', version
ENV['PATH'], [ENV['PATH'], bin_dir].join(File::PATH_SEPARATOR)
use_ui @ui do
- installer.check_that_user_bin_dir_is_in_path
+ @installer.check_that_user_bin_dir_is_in_path
end
assert_empty @ui.error
@@ -236,11 +232,10 @@ gem 'other', version
orig_PATH, ENV['PATH'] =
ENV['PATH'], [ENV['PATH'], '~/bin'].join(File::PATH_SEPARATOR)
- installer = setup_base_installer
- installer.bin_dir.replace File.join @userhome, 'bin'
+ @installer.bin_dir.replace File.join @userhome, 'bin'
use_ui @ui do
- installer.check_that_user_bin_dir_is_in_path
+ @installer.check_that_user_bin_dir_is_in_path
end
assert_empty @ui.error
@@ -249,15 +244,13 @@ gem 'other', version
end
def test_check_that_user_bin_dir_is_in_path_not_in_path
- installer = setup_base_installer
-
use_ui @ui do
- installer.check_that_user_bin_dir_is_in_path
+ @installer.check_that_user_bin_dir_is_in_path
end
- expected = installer.bin_dir
+ expected = @installer.bin_dir
- if Gem.win_platform?
+ if Gem.win_platform? then
expected = expected.downcase.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
end
@@ -265,16 +258,14 @@ gem 'other', version
end
def test_ensure_dependency
- installer = setup_base_installer
-
util_spec 'a'
dep = Gem::Dependency.new 'a', '>= 2'
- assert installer.ensure_dependency(@spec, dep)
+ assert @installer.ensure_dependency(@spec, dep)
dep = Gem::Dependency.new 'b', '> 2'
e = assert_raises Gem::InstallError do
- installer.ensure_dependency @spec, dep
+ @installer.ensure_dependency @spec, dep
end
assert_equal 'a requires b (> 2)', e.message
@@ -311,32 +302,28 @@ gem 'other', version
end
def test_extract_files
- installer = setup_base_installer
-
- installer.extract_files
+ @installer.extract_files
assert_path_exists File.join @spec.gem_dir, 'bin/executable'
end
def test_generate_bin_bindir
- installer = setup_base_installer
-
- installer.wrappers = true
+ @installer.wrappers = true
@spec.executables = %w[executable]
- @spec.bindir = 'bin'
+ @spec.bindir = '.'
- exec_file = installer.formatted_program_filename 'executable'
+ exec_file = @installer.formatted_program_filename 'executable'
exec_path = File.join @spec.gem_dir, exec_file
File.open exec_path, 'w' do |f|
f.puts '#!/usr/bin/ruby'
end
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
- installer.generate_bin
+ @installer.generate_bin
- assert_directory_exists util_inst_bindir
+ assert_equal true, File.directory?(util_inst_bindir)
installed_exec = File.join(util_inst_bindir, 'executable')
assert_path_exists installed_exec
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
@@ -349,9 +336,6 @@ gem 'other', version
bin_dir = Gem.win_platform? ? File.expand_path(ENV["WINDIR"]).upcase :
"/usr/bin"
- old_path = ENV["PATH"]
- ENV["PATH"] = [ENV["PATH"], bin_dir].compact.join(File::PATH_SEPARATOR)
-
options = {
:bin_dir => bin_dir,
:install_dir => "/non/existent"
@@ -366,20 +350,15 @@ gem 'other', version
end
assert_equal "", @ui.error
-
- ensure
- ENV["PATH"] = old_path
end
def test_generate_bin_script
- installer = setup_base_installer
-
- installer.wrappers = true
+ @installer.wrappers = true
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
- installer.generate_bin
- assert_directory_exists util_inst_bindir
+ @installer.generate_bin
+ assert File.directory? util_inst_bindir
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
@@ -389,16 +368,14 @@ gem 'other', version
end
def test_generate_bin_script_format
- installer = setup_base_installer
-
- installer.format_executable = true
- installer.wrappers = true
+ @installer.format_executable = true
+ @installer.wrappers = true
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
Gem::Installer.exec_format = 'foo-%s-bar'
- installer.generate_bin
- assert_directory_exists util_inst_bindir
+ @installer.generate_bin
+ assert_equal true, File.directory?(util_inst_bindir)
installed_exec = File.join util_inst_bindir, 'foo-executable-bar'
assert_path_exists installed_exec
ensure
@@ -406,15 +383,13 @@ gem 'other', version
end
def test_generate_bin_script_format_disabled
- installer = setup_base_installer
-
- installer.wrappers = true
+ @installer.wrappers = true
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
Gem::Installer.exec_format = 'foo-%s-bar'
- installer.generate_bin
- assert_directory_exists util_inst_bindir
+ @installer.generate_bin
+ assert_equal true, File.directory?(util_inst_bindir)
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
ensure
@@ -422,9 +397,7 @@ gem 'other', version
end
def test_generate_bin_script_install_dir
- installer = setup_base_installer
-
- installer.wrappers = true
+ @installer.wrappers = true
gem_dir = File.join("#{@gemhome}2", "gems", @spec.full_name)
gem_bindir = File.join gem_dir, 'bin'
@@ -433,11 +406,11 @@ gem 'other', version
f.puts "#!/bin/ruby"
end
- installer.gem_home = "#{@gemhome}2"
- installer.gem_dir = gem_dir
- installer.bin_dir = File.join "#{@gemhome}2", 'bin'
+ @installer.gem_home = "#{@gemhome}2"
+ @installer.gem_dir = gem_dir
+ @installer.bin_dir = File.join "#{@gemhome}2", 'bin'
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join("#{@gemhome}2", "bin", 'executable')
assert_path_exists installed_exec
@@ -448,20 +421,16 @@ gem 'other', version
end
def test_generate_bin_script_no_execs
- installer = setup_base_installer
-
- installer = util_execless
+ util_execless
- installer.wrappers = true
- installer.generate_bin
+ @installer.wrappers = true
+ @installer.generate_bin
refute_path_exists util_inst_bindir, 'bin dir was created when not needed'
end
def test_generate_bin_script_no_perms
- installer = setup_base_installer
-
- installer.wrappers = true
+ @installer.wrappers = true
util_make_exec
Dir.mkdir util_inst_bindir
@@ -474,7 +443,7 @@ gem 'other', version
FileUtils.chmod 0000, util_inst_bindir
assert_raises Gem::FilePermissionError do
- installer.generate_bin
+ @installer.generate_bin
end
end
ensure
@@ -482,9 +451,7 @@ gem 'other', version
end
def test_generate_bin_script_no_shebang
- installer = setup_base_installer
-
- installer.wrappers = true
+ @installer.wrappers = true
@spec.executables = %w[executable]
gem_dir = File.join @gemhome, 'gems', @spec.full_name
@@ -494,7 +461,7 @@ gem 'other', version
f.puts "blah blah blah"
end
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join @gemhome, 'bin', 'executable'
assert_path_exists installed_exec
@@ -507,23 +474,21 @@ gem 'other', version
end
def test_generate_bin_script_wrappers
- installer = setup_base_installer
-
- installer.wrappers = true
+ @installer.wrappers = true
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
installed_exec = File.join(util_inst_bindir, 'executable')
real_exec = File.join @spec.gem_dir, 'bin', 'executable'
# fake --no-wrappers for previous install
- unless Gem.win_platform?
+ unless Gem.win_platform? then
FileUtils.mkdir_p File.dirname(installed_exec)
FileUtils.ln_s real_exec, installed_exec
end
- installer.generate_bin
- assert_directory_exists util_inst_bindir
+ @installer.generate_bin
+ assert_equal true, File.directory?(util_inst_bindir)
assert_path_exists installed_exec
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
@@ -534,16 +499,14 @@ gem 'other', version
end
def test_generate_bin_symlink
- skip "Symlinks not supported or not enabled" unless symlink_supported?
+ return if win_platform? #Windows FS do not support symlinks
- installer = setup_base_installer
-
- installer.wrappers = false
+ @installer.wrappers = false
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
- installer.generate_bin
- assert_directory_exists util_inst_bindir
+ @installer.generate_bin
+ assert_equal true, File.directory?(util_inst_bindir)
installed_exec = File.join util_inst_bindir, 'executable'
assert_equal true, File.symlink?(installed_exec)
assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
@@ -551,22 +514,18 @@ gem 'other', version
end
def test_generate_bin_symlink_no_execs
- installer = setup_base_installer
+ util_execless
- installer = util_execless
-
- installer.wrappers = false
- installer.generate_bin
+ @installer.wrappers = false
+ @installer.generate_bin
refute_path_exists util_inst_bindir
end
def test_generate_bin_symlink_no_perms
- installer = setup_base_installer
-
- installer.wrappers = false
+ @installer.wrappers = false
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
Dir.mkdir util_inst_bindir
@@ -578,7 +537,7 @@ gem 'other', version
FileUtils.chmod 0000, util_inst_bindir
assert_raises Gem::FilePermissionError do
- installer.generate_bin
+ @installer.generate_bin
end
end
ensure
@@ -586,15 +545,13 @@ gem 'other', version
end
def test_generate_bin_symlink_update_newer
- skip "Symlinks not supported or not enabled" unless symlink_supported?
-
- installer = setup_base_installer
+ return if win_platform? #Windows FS do not support symlinks
- installer.wrappers = false
+ @installer.wrappers = false
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join(util_inst_bindir, 'executable')
assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
File.readlink(installed_exec))
@@ -609,8 +566,8 @@ gem 'other', version
end
util_make_exec
- installer.gem_dir = @spec.gem_dir
- installer.generate_bin
+ @installer.gem_dir = @spec.gem_dir
+ @installer.generate_bin
installed_exec = File.join(util_inst_bindir, 'executable')
assert_equal(@spec.bin_file('executable'),
File.readlink(installed_exec),
@@ -618,15 +575,13 @@ gem 'other', version
end
def test_generate_bin_symlink_update_older
- skip "Symlinks not supported or not enabled" unless symlink_supported?
+ return if !symlink_supported?
- installer = setup_base_installer
-
- installer.wrappers = false
+ @installer.wrappers = false
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join(util_inst_bindir, 'executable')
assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
File.readlink(installed_exec))
@@ -643,10 +598,10 @@ gem 'other', version
util_make_exec
one = @spec.dup
one.version = 1
- installer = Gem::Installer.for_spec spec
- installer.gem_dir = one.gem_dir
+ @installer = Gem::Installer.for_spec spec
+ @installer.gem_dir = one.gem_dir
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
expected = File.join @spec.gem_dir, 'bin', 'executable'
@@ -656,15 +611,13 @@ gem 'other', version
end
def test_generate_bin_symlink_update_remove_wrapper
- skip "Symlinks not supported or not enabled" unless symlink_supported?
-
- installer = setup_base_installer
+ return if !symlink_supported?
- installer.wrappers = true
+ @installer.wrappers = true
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -680,10 +633,10 @@ gem 'other', version
util_make_exec
util_installer @spec, @gemhome
- installer.wrappers = false
- installer.gem_dir = @spec.gem_dir
+ @installer.wrappers = false
+ @installer.gem_dir = @spec.gem_dir
- installer.generate_bin
+ @installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_equal(@spec.bin_file('executable'),
@@ -697,23 +650,20 @@ gem 'other', version
old_alt_separator = File::ALT_SEPARATOR
File.__send__(:remove_const, :ALT_SEPARATOR)
File.const_set(:ALT_SEPARATOR, '\\')
-
- installer = setup_base_installer
-
- installer.wrappers = false
+ @installer.wrappers = false
util_make_exec
- installer.gem_dir = @spec.gem_dir
+ @installer.gem_dir = @spec.gem_dir
use_ui @ui do
- installer.generate_bin
+ @installer.generate_bin
end
- assert_directory_exists util_inst_bindir
+ assert_equal true, File.directory?(util_inst_bindir)
installed_exec = File.join(util_inst_bindir, 'executable')
assert_path_exists installed_exec
if symlink_supported?
- assert File.symlink?(installed_exec)
+ assert_send([File, :symlink?, installed_exec])
return
end
@@ -729,14 +679,12 @@ gem 'other', version
end
def test_generate_bin_uses_default_shebang
- skip "Symlinks not supported or not enabled" unless symlink_supported?
-
- installer = setup_base_installer
+ return if !symlink_supported?
- installer.wrappers = true
+ @installer.wrappers = true
util_make_exec
- installer.generate_bin
+ @installer.generate_bin
default_shebang = Gem.ruby
shebang_line = open("#{@gemhome}/bin/executable") { |f| f.readlines.first }
@@ -745,10 +693,7 @@ gem 'other', version
end
def test_initialize
- spec = util_spec 'a' do |s|
- s.platform = Gem::Platform.new 'mswin32'
- end
-
+ spec = util_spec 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
gem = File.join @tempdir, spec.file_name
Dir.mkdir util_inst_bindir
@@ -762,8 +707,6 @@ gem 'other', version
end
def test_initialize_user_install
- @gem = setup_base_gem
-
installer = Gem::Installer.at @gem, :user_install => true
assert_equal File.join(Gem.user_dir, 'gems', @spec.full_name),
@@ -772,8 +715,6 @@ gem 'other', version
end
def test_initialize_user_install_bin_dir
- @gem = setup_base_gem
-
installer =
Gem::Installer.at @gem, :user_install => true, :bin_dir => @tempdir
@@ -783,7 +724,9 @@ gem 'other', version
end
def test_install
- installer = util_setup_installer
+ Dir.mkdir util_inst_bindir
+ util_setup_gem
+ util_clear_gems
gemdir = File.join @gemhome, 'gems', @spec.full_name
cache_file = File.join @gemhome, 'cache', @spec.file_name
@@ -791,13 +734,13 @@ gem 'other', version
rakefile = File.join gemdir, 'ext', 'a', 'Rakefile'
spec_file = File.join @gemhome, 'specifications', @spec.spec_name
- Gem.pre_install do
+ Gem.pre_install do |installer|
refute_path_exists cache_file, 'cache file must not exist yet'
refute_path_exists spec_file, 'spec file must not exist yet'
true
end
- Gem.post_build do
+ Gem.post_build do |installer|
assert_path_exists gemdir, 'gem install dir must exist'
assert_path_exists rakefile, 'gem executable must exist'
refute_path_exists stub_exe, 'gem executable must not exist'
@@ -805,7 +748,7 @@ gem 'other', version
true
end
- Gem.post_install do
+ Gem.post_install do |installer|
assert_path_exists cache_file, 'cache file must exist'
assert_path_exists spec_file, 'spec file must exist'
end
@@ -813,7 +756,7 @@ gem 'other', version
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = installer.install
+ @newspec = @installer.install
end
end
@@ -831,25 +774,29 @@ gem 'other', version
assert_path_exists rakefile
+ spec_file = File.join(@gemhome, 'specifications', @spec.spec_name)
+
assert_equal spec_file, @newspec.loaded_from
assert_path_exists spec_file
- assert_same installer, @post_build_hook_arg
- assert_same installer, @post_install_hook_arg
- assert_same installer, @pre_install_hook_arg
+ assert_same @installer, @post_build_hook_arg
+ assert_same @installer, @post_install_hook_arg
+ assert_same @installer, @pre_install_hook_arg
end
def test_install_creates_working_binstub
- installer = util_setup_installer
+ Dir.mkdir util_inst_bindir
+ util_setup_gem
+ util_clear_gems
- installer.wrappers = true
+ @installer.wrappers = true
gemdir = File.join @gemhome, 'gems', @spec.full_name
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = installer.install
+ @newspec = @installer.install
end
end
@@ -863,10 +810,11 @@ gem 'other', version
end
def test_conflicting_binstubs
- @gem = setup_base_gem
+ Dir.mkdir util_inst_bindir
+ util_clear_gems
# build old version that has a bin file
- installer = util_setup_gem do |spec|
+ util_setup_gem do |spec|
File.open File.join('bin', 'executable'), 'w' do |f|
f.puts "require 'code'"
end
@@ -875,17 +823,17 @@ gem 'other', version
end
end
- installer.wrappers = true
+ @installer.wrappers = true
build_rake_in do
use_ui @ui do
- @newspec = installer.install
+ @newspec = @installer.install
end
end
- old_bin_file = File.join installer.bin_dir, 'executable'
+ old_bin_file = File.join @installer.bin_dir, 'executable'
# build new version that doesn't have a bin file
- installer = util_setup_gem do |spec|
+ util_setup_gem do |spec|
FileUtils.rm File.join('bin', 'executable')
spec.files.delete File.join('bin', 'executable')
spec.executables.delete 'executable'
@@ -897,7 +845,7 @@ gem 'other', version
build_rake_in do
use_ui @ui do
- @newspec = installer.install
+ @newspec = @installer.install
end
end
@@ -911,14 +859,16 @@ gem 'other', version
end
def test_install_creates_binstub_that_understand_version
- installer = util_setup_installer
+ Dir.mkdir util_inst_bindir
+ util_setup_gem
+ util_clear_gems
- installer.wrappers = true
+ @installer.wrappers = true
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = installer.install
+ @newspec = @installer.install
end
end
@@ -939,43 +889,19 @@ gem 'other', version
assert_includes(e.message, "can't find gem a (= 3.0)")
end
- def test_install_creates_binstub_that_prefers_user_installed_gem_to_default
- install_default_gems new_default_spec('default', '2')
-
- installer = util_setup_installer do |spec|
- spec.name = 'default'
- spec.version = '2'
- end
+ def test_install_creates_binstub_that_dont_trust_encoding
+ skip unless "".respond_to?(:force_encoding)
+ Dir.mkdir util_inst_bindir
+ util_setup_gem
util_clear_gems
- installer.wrappers = true
+ @installer.wrappers = true
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = installer.install
- end
- end
-
- exe = File.join @gemhome, 'bin', 'executable'
-
- e = assert_raises RuntimeError do
- instance_eval File.read(exe)
- end
-
- assert_equal(e.message, "ran executable")
- end
-
- def test_install_creates_binstub_that_dont_trust_encoding
- installer = util_setup_installer
-
- installer.wrappers = true
-
- @newspec = nil
- build_rake_in do
- use_ui @ui do
- @newspec = installer.install
+ @newspec = @installer.install
end
end
@@ -998,35 +924,33 @@ gem 'other', version
end
def test_install_with_no_prior_files
- installer = util_setup_installer
+ Dir.mkdir util_inst_bindir
+ util_clear_gems
+ util_setup_gem
build_rake_in do
use_ui @ui do
- assert_equal @spec, installer.install
+ assert_equal @spec, @installer.install
end
end
gemdir = File.join(@gemhome, 'gems', @spec.full_name)
assert_path_exists File.join gemdir, 'lib', 'code.rb'
- installer = util_setup_installer
-
+ util_setup_gem
# Morph spec to have lib/other.rb instead of code.rb and recreate
@spec.files = File.join('lib', 'other.rb')
Dir.chdir @tempdir do
- File.open File.join('lib', 'other.rb'), 'w' do |f|
- f.puts '1'
- end
-
+ File.open File.join('lib', 'other.rb'), 'w' do |f| f.puts '1' end
use_ui ui do
FileUtils.rm @gem
Gem::Package.build @spec
end
end
- installer = Gem::Installer.at @gem
+ @installer = Gem::Installer.at @gem
build_rake_in do
use_ui @ui do
- assert_equal @spec, installer.install
+ assert_equal @spec, @installer.install
end
end
@@ -1037,7 +961,7 @@ gem 'other', version
def test_install_force
use_ui @ui do
- installer = Gem::Installer.at old_ruby_required('= 1.4.6'), :force => true
+ installer = Gem::Installer.at old_ruby_required, :force => true
installer.install
end
@@ -1046,26 +970,24 @@ gem 'other', version
end
def test_install_missing_dirs
- installer = setup_base_installer
-
FileUtils.rm_f File.join(Gem.dir, 'cache')
- FileUtils.rm_f File.join(Gem.dir, 'doc')
+ FileUtils.rm_f File.join(Gem.dir, 'docs')
FileUtils.rm_f File.join(Gem.dir, 'specifications')
use_ui @ui do
- installer.install
+ @installer.install
end
- assert_directory_exists File.join(Gem.dir, 'cache')
- assert_directory_exists File.join(Gem.dir, 'doc')
- assert_directory_exists File.join(Gem.dir, 'specifications')
+ File.directory? File.join(Gem.dir, 'cache')
+ File.directory? File.join(Gem.dir, 'docs')
+ File.directory? File.join(Gem.dir, 'specifications')
assert_path_exists File.join @gemhome, 'cache', @spec.file_name
assert_path_exists File.join @gemhome, 'specifications', @spec.spec_name
end
def test_install_post_build_false
- installer = setup_base_installer
+ util_clear_gems
Gem.post_build do
false
@@ -1073,7 +995,7 @@ gem 'other', version
use_ui @ui do
e = assert_raises Gem::InstallError do
- installer.install
+ @installer.install
end
location = "#{__FILE__}:#{__LINE__ - 9}"
@@ -1089,14 +1011,14 @@ gem 'other', version
end
def test_install_post_build_nil
- installer = setup_base_installer
+ util_clear_gems
Gem.post_build do
nil
end
use_ui @ui do
- installer.install
+ @installer.install
end
spec_file = File.join @gemhome, 'specifications', @spec.spec_name
@@ -1107,7 +1029,7 @@ gem 'other', version
end
def test_install_pre_install_false
- installer = setup_base_installer
+ util_clear_gems
Gem.pre_install do
false
@@ -1115,7 +1037,7 @@ gem 'other', version
use_ui @ui do
e = assert_raises Gem::InstallError do
- installer.install
+ @installer.install
end
location = "#{__FILE__}:#{__LINE__ - 9}"
@@ -1128,14 +1050,14 @@ gem 'other', version
end
def test_install_pre_install_nil
- installer = setup_base_installer
+ util_clear_gems
Gem.pre_install do
nil
end
use_ui @ui do
- installer.install
+ @installer.install
end
spec_file = File.join @gemhome, 'specifications', @spec.spec_name
@@ -1143,28 +1065,26 @@ gem 'other', version
end
def test_install_with_message
- @spec = setup_base_spec
@spec.post_install_message = 'I am a shiny gem!'
use_ui @ui do
path = Gem::Package.build @spec
- installer = Gem::Installer.at path
- installer.install
+ @installer = Gem::Installer.at path
+ @installer.install
end
assert_match %r|I am a shiny gem!|, @ui.output
end
def test_install_with_skipped_message
- @spec = setup_base_spec
@spec.post_install_message = 'I am a shiny gem!'
use_ui @ui do
path = Gem::Package.build @spec
- installer = Gem::Installer.at path, :post_install_message => false
- installer.install
+ @installer = Gem::Installer.at path, :post_install_message => false
+ @installer.install
end
refute_match %r|I am a shiny gem!|, @ui.output
@@ -1173,7 +1093,6 @@ gem 'other', version
def test_install_extension_dir
gemhome2 = "#{@gemhome}2"
- @spec = setup_base_spec
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1197,8 +1116,6 @@ gem 'other', version
end
def test_install_extension_dir_is_removed_on_reinstall
- @spec = setup_base_spec
-
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1234,7 +1151,6 @@ gem 'other', version
end
def test_install_user_extension_dir
- @spec = setup_base_spec
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1263,56 +1179,91 @@ gem 'other', version
refute_path_exists File.join expected_extension_dir, 'gem_make.out'
end
- def test_find_lib_file_after_install
- skip "extensions don't quite work on jruby" if Gem.java_platform?
+ # ruby core repository needs to `depend` file for extension build.
+ # but 1.9.2 and earlier mkmf.rb does not create TOUCH file like depend.
+ if RUBY_VERSION < '1.9.3'
+ def test_find_lib_file_after_install
- @spec = setup_base_spec
- @spec.extensions << "extconf.rb"
- write_file File.join(@tempdir, "extconf.rb") do |io|
- io.write <<-RUBY
- require "mkmf"
+ @spec.extensions << "extconf.rb"
+ write_file File.join(@tempdir, "extconf.rb") do |io|
+ io.write <<-RUBY
+ require "mkmf"
+ create_makefile("#{@spec.name}")
+ RUBY
+ end
- CONFIG['CC'] = '$(TOUCH) $@ ||'
- CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
- $ruby = '#{Gem.ruby}'
+ write_file File.join(@tempdir, "a.c") do |io|
+ io.write <<-C
+ #include <ruby.h>
+ void Init_a() { }
+ C
+ end
- create_makefile("#{@spec.name}")
- RUBY
- end
+ Dir.mkdir File.join(@tempdir, "lib")
+ write_file File.join(@tempdir, 'lib', "b.rb") do |io|
+ io.write "# b.rb"
+ end
- write_file File.join(@tempdir, "depend")
+ @spec.files += %w[extconf.rb lib/b.rb a.c]
- write_file File.join(@tempdir, "a.c") do |io|
- io.write <<-C
- #include <ruby.h>
- void Init_a() { }
- C
- end
+ use_ui @ui do
+ path = Gem::Package.build @spec
+
+ installer = Gem::Installer.at path
+ installer.install
+ end
- Dir.mkdir File.join(@tempdir, "lib")
- write_file File.join(@tempdir, 'lib', "b.rb") do |io|
- io.write "# b.rb"
+ expected = File.join @spec.full_require_paths.find { |path|
+ File.exist? File.join path, 'b.rb'
+ }, 'b.rb'
+ assert_equal expected, @spec.matches_for_glob('b.rb').first
end
+ else
+ def test_find_lib_file_after_install
+ @spec.extensions << "extconf.rb"
+ write_file File.join(@tempdir, "extconf.rb") do |io|
+ io.write <<-RUBY
+ require "mkmf"
- @spec.files += %w[extconf.rb lib/b.rb depend a.c]
+ CONFIG['CC'] = '$(TOUCH) $@ ||'
+ CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
+ $ruby = '#{Gem.ruby}'
- use_ui @ui do
- path = Gem::Package.build @spec
+ create_makefile("#{@spec.name}")
+ RUBY
+ end
- installer = Gem::Installer.at path
- installer.install
- end
+ write_file File.join(@tempdir, "depend")
+
+ write_file File.join(@tempdir, "a.c") do |io|
+ io.write <<-C
+ #include <ruby.h>
+ void Init_a() { }
+ C
+ end
+
+ Dir.mkdir File.join(@tempdir, "lib")
+ write_file File.join(@tempdir, 'lib', "b.rb") do |io|
+ io.write "# b.rb"
+ end
+
+ @spec.files += %w[extconf.rb lib/b.rb depend a.c]
- expected = File.join @spec.full_require_paths.find { |path|
- File.exist? File.join path, 'b.rb'
- }, 'b.rb'
- assert_equal expected, @spec.matches_for_glob('b.rb').first
+ use_ui @ui do
+ path = Gem::Package.build @spec
+
+ installer = Gem::Installer.at path
+ installer.install
+ end
+
+ expected = File.join @spec.full_require_paths.find { |path|
+ File.exist? File.join path, 'b.rb'
+ }, 'b.rb'
+ assert_equal expected, @spec.matches_for_glob('b.rb').first
+ end
end
def test_install_extension_and_script
- skip "Makefile creation crashes on jruby" if Gem.java_platform?
-
- @spec = setup_base_spec
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1343,17 +1294,21 @@ gem 'other', version
use_ui @ui do
path = Gem::Package.build @spec
- installer = Gem::Installer.at path
- installer.install
+ @installer = Gem::Installer.at path
+ @installer.install
end
assert_path_exists File.join @spec.gem_dir, rb
assert_path_exists File.join @spec.gem_dir, rb2
end
def test_install_extension_flat
- skip "extensions don't quite work on jruby" if Gem.java_platform?
+ skip '1.9.2 and earlier mkmf.rb does not create TOUCH' if
+ RUBY_VERSION < '1.9.3'
+
+ if RUBY_VERSION == "1.9.3" and RUBY_PATCHLEVEL <= 194
+ skip "TOUCH was introduced into 1.9.3 after p194"
+ end
- @spec = setup_base_spec
@spec.require_paths = ["."]
@spec.extensions << "extconf.rb"
@@ -1371,17 +1326,17 @@ gem 'other', version
end
# empty depend file for no auto dependencies
- @spec.files += %W"depend #{@spec.name}.c".each do |file|
+ @spec.files += %W"depend #{@spec.name}.c".each {|file|
write_file File.join(@tempdir, file)
- end
+ }
so = File.join(@spec.gem_dir, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}")
refute_path_exists so
use_ui @ui do
path = Gem::Package.build @spec
- installer = Gem::Installer.at path
- installer.install
+ @installer = Gem::Installer.at path
+ @installer.install
end
assert_path_exists so
rescue
@@ -1400,56 +1355,49 @@ gem 'other', version
end
def test_installation_satisfies_dependency_eh
- installer = setup_base_installer
-
util_spec 'a'
dep = Gem::Dependency.new 'a', '>= 2'
- assert installer.installation_satisfies_dependency?(dep)
+ assert @installer.installation_satisfies_dependency?(dep)
dep = Gem::Dependency.new 'a', '> 2'
- refute installer.installation_satisfies_dependency?(dep)
+ refute @installer.installation_satisfies_dependency?(dep)
end
def test_installation_satisfies_dependency_eh_development
- installer = setup_base_installer
- installer.options[:development] = true
- installer.options[:dev_shallow] = true
+ @installer.options[:development] = true
+ @installer.options[:dev_shallow] = true
util_spec 'a'
dep = Gem::Dependency.new 'a', :development
- assert installer.installation_satisfies_dependency?(dep)
+ assert @installer.installation_satisfies_dependency?(dep)
end
def test_pre_install_checks_dependencies
- installer = setup_base_installer
@spec.add_dependency 'b', '> 5'
- installer = util_setup_gem
+ util_setup_gem
use_ui @ui do
assert_raises Gem::InstallError do
- installer.install
+ @installer.install
end
end
end
def test_pre_install_checks_dependencies_ignore
- installer = util_setup_installer
@spec.add_dependency 'b', '> 5'
- installer.ignore_dependencies = true
+ @installer.ignore_dependencies = true
build_rake_in do
use_ui @ui do
- assert installer.pre_install_checks
+ assert @installer.pre_install_checks
end
end
end
def test_pre_install_checks_dependencies_install_dir
gemhome2 = "#{@gemhome}2"
-
- @gem = setup_base_gem
@spec.add_dependency 'd'
quick_gem 'd', 2
@@ -1476,32 +1424,16 @@ gem 'other', version
def test_pre_install_checks_ruby_version
use_ui @ui do
- installer = Gem::Installer.at old_ruby_required('= 1.4.6')
+ installer = Gem::Installer.at old_ruby_required
e = assert_raises Gem::RuntimeRequirementNotMetError do
installer.pre_install_checks
end
- rv = Gem.ruby_version
+ rv = Gem.ruby_api_version
assert_equal "old_ruby_required requires Ruby version = 1.4.6. The current ruby version is #{rv}.",
e.message
end
end
- def test_pre_install_checks_ruby_version_with_prereleases
- util_set_RUBY_VERSION '2.6.0', -1, '63539', 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]'
-
- installer = Gem::Installer.at old_ruby_required('>= 2.6.0.preview2')
- assert installer.pre_install_checks
-
- installer = Gem::Installer.at old_ruby_required('> 2.6.0.preview2')
- e = assert_raises Gem::RuntimeRequirementNotMetError do
- assert installer.pre_install_checks
- end
- assert_equal "old_ruby_required requires Ruby version > 2.6.0.preview2. The current ruby version is 2.6.0.preview2.",
- e.message
- ensure
- util_restore_RUBY_VERSION
- end
-
def test_pre_install_checks_wrong_rubygems_version
spec = util_spec 'old_rubygems_required', '1' do |s|
s.required_rubygems_version = '< 0'
@@ -1512,9 +1444,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- installer = Gem::Installer.at gem
+ @installer = Gem::Installer.at gem
e = assert_raises Gem::RuntimeRequirementNotMetError do
- installer.pre_install_checks
+ @installer.pre_install_checks
end
rgv = Gem::VERSION
assert_equal "old_rubygems_required requires RubyGems version < 0. The current RubyGems version is #{rgv}. " +
@@ -1527,16 +1459,16 @@ gem 'other', version
def spec.full_name # so the spec is buildable
"malicious-1"
end
- def spec.validate(packaging, strict); end
+ def spec.validate; end
util_build_gem spec
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- installer = Gem::Installer.at gem
+ @installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- installer.pre_install_checks
+ @installer.pre_install_checks
end
assert_equal '#<Gem::Specification name=../malicious version=1> has an invalid name', e.message
end
@@ -1554,9 +1486,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- installer = Gem::Installer.at gem
+ @installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- installer.pre_install_checks
+ @installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious\n::Object.const_set(:FROM_EVAL, true)# version=1> has an invalid name", e.message
end
@@ -1576,9 +1508,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- installer = Gem::Installer.at gem
+ @installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- installer.pre_install_checks
+ @installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid require_paths", e.message
end
@@ -1599,9 +1531,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- installer = Gem::Installer.at gem
+ @installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- installer.pre_install_checks
+ @installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid extensions", e.message
end
@@ -1620,9 +1552,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- installer = Gem::Installer.at gem
+ @installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- installer.pre_install_checks
+ @installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid specification_version", e.message
end
@@ -1641,90 +1573,75 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- installer = Gem::Installer.at gem
- installer.ignore_dependencies = true
+ @installer = Gem::Installer.at gem
+ @installer.ignore_dependencies = true
e = assert_raises Gem::InstallError do
- installer.pre_install_checks
+ @installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid dependencies", e.message
end
end
def test_shebang
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/ruby"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_process_options
- installer = setup_base_installer
-
- assert_nil installer.build_root
- assert_equal File.join(@gemhome, 'bin'), installer.bin_dir
- assert_equal @gemhome, installer.gem_home
+ assert_nil @installer.build_root
+ assert_equal File.join(@gemhome, 'bin'), @installer.bin_dir
+ assert_equal @gemhome, @installer.gem_home
end
def test_process_options_build_root
build_root = File.join @tempdir, 'build_root'
- @gem = setup_base_gem
- installer = Gem::Installer.at @gem, :build_root => build_root
+ @installer = Gem::Installer.at @gem, :build_root => build_root
- assert_equal Pathname(build_root), installer.build_root
- assert_equal File.join(build_root, @gemhome, 'bin'), installer.bin_dir
- assert_equal File.join(build_root, @gemhome), installer.gem_home
+ assert_equal Pathname(build_root), @installer.build_root
+ assert_equal File.join(build_root, @gemhome, 'bin'), @installer.bin_dir
+ assert_equal File.join(build_root, @gemhome), @installer.gem_home
end
def test_shebang_arguments
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/ruby -ws"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_empty
- installer = setup_base_installer
-
util_make_exec @spec, ''
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_env
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/env ruby"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_env_arguments
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/env ruby -ws"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_env_shebang
- installer = setup_base_installer
-
util_make_exec @spec, ''
- installer.env_shebang = true
+ @installer.env_shebang = true
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
env_shebang = "/usr/bin/env" unless Gem.win_platform?
@@ -1733,68 +1650,54 @@ gem 'other', version
end
def test_shebang_nested
- installer = setup_base_installer
-
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_nested_arguments
- installer = setup_base_installer
-
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_version
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/ruby18"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_version_arguments
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_version_env
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/env ruby18"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_version_env_arguments
- installer = setup_base_installer
-
util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_custom
- installer = setup_base_installer
-
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = 'test'
@@ -1802,14 +1705,12 @@ gem 'other', version
util_make_exec @spec, "#!/usr/bin/ruby"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!test", shebang
end
def test_shebang_custom_with_expands
- installer = setup_base_installer
-
bin_env = win_platform? ? '' : '/usr/bin/env'
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name'
@@ -1818,14 +1719,12 @@ gem 'other', version
util_make_exec @spec, "#!/usr/bin/ruby"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} 3 executable 4 a", shebang
end
def test_shebang_custom_with_expands_and_arguments
- installer = setup_base_installer
-
bin_env = win_platform? ? '' : '/usr/bin/env'
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec'
@@ -1834,34 +1733,30 @@ gem 'other', version
util_make_exec @spec, "#!/usr/bin/ruby -ws"
- shebang = installer.shebang 'executable'
+ shebang = @installer.shebang 'executable'
assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} -ws 3 executable", shebang
end
def test_unpack
- installer = util_setup_installer
+ util_setup_gem
dest = File.join @gemhome, 'gems', @spec.full_name
- Gem::Deprecate.skip_during do
- installer.unpack dest
- end
+ @installer.unpack dest
assert_path_exists File.join dest, 'lib', 'code.rb'
assert_path_exists File.join dest, 'bin', 'executable'
end
def test_write_build_info_file
- installer = setup_base_installer
-
refute_path_exists @spec.build_info_file
- installer.build_args = %w[
+ @installer.build_args = %w[
--with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4
]
- installer.write_build_info_file
+ @installer.write_build_info_file
assert_path_exists @spec.build_info_file
@@ -1871,17 +1766,14 @@ gem 'other', version
end
def test_write_build_info_file_empty
- installer = setup_base_installer
-
refute_path_exists @spec.build_info_file
- installer.write_build_info_file
+ @installer.write_build_info_file
refute_path_exists @spec.build_info_file
end
def test_write_build_info_file_install_dir
- @gem = setup_base_gem
installer = Gem::Installer.at @gem, :install_dir => "#{@gemhome}2"
installer.build_args = %w[
@@ -1896,7 +1788,6 @@ gem 'other', version
end
def test_write_cache_file
- @gem = setup_base_gem
cache_file = File.join @gemhome, 'cache', @spec.file_name
gem = File.join @gemhome, @spec.file_name
@@ -1912,14 +1803,13 @@ gem 'other', version
end
def test_write_spec
- @spec = setup_base_spec
FileUtils.rm @spec.spec_file
refute_path_exists @spec.spec_file
- installer = Gem::Installer.for_spec @spec
- installer.gem_home = @gemhome
+ @installer = Gem::Installer.for_spec @spec
+ @installer.gem_home = @gemhome
- installer.write_spec
+ @installer.write_spec
assert_path_exists @spec.spec_file
@@ -1931,16 +1821,15 @@ gem 'other', version
end
def test_write_spec_writes_cached_spec
- @spec = setup_base_spec
FileUtils.rm @spec.spec_file
refute_path_exists @spec.spec_file
@spec.files = %w[a.rb b.rb c.rb]
- installer = Gem::Installer.for_spec @spec
- installer.gem_home = @gemhome
+ @installer = Gem::Installer.for_spec @spec
+ @installer.gem_home = @gemhome
- installer.write_spec
+ @installer.write_spec
# cached specs have no file manifest:
@spec.files = []
@@ -1949,9 +1838,7 @@ gem 'other', version
end
def test_dir
- installer = setup_base_installer
-
- assert_match %r!/gemhome/gems/a-2$!, installer.dir
+ assert_match %r!/gemhome/gems/a-2$!, @installer.dir
end
def test_default_gem_loaded_from
@@ -1961,102 +1848,33 @@ gem 'other', version
assert_predicate spec, :default_gem?
end
- def test_default_gem_without_wrappers
- installer = setup_base_installer
-
+ def test_default_gem
FileUtils.rm_f File.join(Gem.dir, 'specifications')
- installer.wrappers = false
- installer.options[:install_as_default] = true
- installer.gem_dir = @spec.gem_dir
+ @installer.wrappers = true
+ @installer.options[:install_as_default] = true
+ @installer.gem_dir = @spec.gem_dir
+ @installer.generate_bin
use_ui @ui do
- installer.install
+ @installer.install
end
- assert_directory_exists File.join(@spec.gem_dir, 'bin')
- installed_exec = File.join @spec.gem_dir, 'bin', 'executable'
+ assert File.directory? util_inst_bindir
+ installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
- assert_directory_exists File.join(Gem.default_dir, 'specifications')
- assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default')
+ assert File.directory? File.join(Gem.default_dir, 'specifications')
+ assert File.directory? File.join(Gem.default_dir, 'specifications', 'default')
default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'a-2.gemspec')
assert_equal Gem::Version.new("2"), default_spec.version
assert_equal ['bin/executable'], default_spec.files
-
- assert_directory_exists util_inst_bindir
-
- installed_exec = File.join util_inst_bindir, 'executable'
- assert_path_exists installed_exec
-
- wrapper = File.read installed_exec
- refute_match %r|generated by RubyGems|, wrapper
- end
-
- def test_default_gem_with_wrappers
- installer = setup_base_installer
-
- installer.wrappers = true
- installer.options[:install_as_default] = true
- installer.gem_dir = @spec.gem_dir
-
- use_ui @ui do
- installer.install
- end
-
- assert_directory_exists util_inst_bindir
-
- installed_exec = File.join util_inst_bindir, 'executable'
- assert_path_exists installed_exec
-
- wrapper = File.read installed_exec
- assert_match %r|generated by RubyGems|, wrapper
- end
-
- def test_default_gem_with_exe_as_bindir
- @spec = quick_gem 'c' do |spec|
- util_make_exec spec, '#!/usr/bin/ruby', 'exe'
- end
-
- util_build_gem @spec
-
- @spec.cache_file
-
- installer = util_installer @spec, @gemhome
-
- installer.options[:install_as_default] = true
- installer.gem_dir = @spec.gem_dir
-
- use_ui @ui do
- installer.install
- end
-
- assert_directory_exists File.join(@spec.gem_dir, 'exe')
- installed_exec = File.join @spec.gem_dir, 'exe', 'executable'
- assert_path_exists installed_exec
-
- assert_directory_exists File.join(Gem.default_dir, 'specifications')
- assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default')
-
- default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'c-2.gemspec')
- assert_equal Gem::Version.new("2"), default_spec.version
- assert_equal ['exe/executable'], default_spec.files
- end
-
- def test_package_attribute
- gem = quick_gem 'c' do |spec|
- util_make_exec spec, '#!/usr/bin/ruby', 'exe'
- end
-
- installer = util_installer(gem, @gemhome)
- assert_respond_to(installer, :package)
- assert_kind_of(Gem::Package, installer.package)
end
- def old_ruby_required(requirement)
+ def old_ruby_required
spec = util_spec 'old_ruby_required', '1' do |s|
- s.required_ruby_version = requirement
+ s.required_ruby_version = '= 1.4.6'
end
util_build_gem spec
@@ -2068,10 +1886,10 @@ gem 'other', version
@spec = util_spec 'z'
util_build_gem @spec
- util_installer @spec, @gemhome
+ @installer = util_installer @spec, @gemhome
end
- def util_conflict_executable(wrappers)
+ def util_conflict_executable wrappers
conflict = quick_gem 'conflict' do |spec|
util_make_exec spec
end
@@ -2086,5 +1904,4 @@ gem 'other', version
def mask
0100755 & (~File.umask)
end
-
end
diff --git a/test/rubygems/test_gem_local_remote_options.rb b/test/rubygems/test_gem_local_remote_options.rb
index 6c21300c2a..272623be74 100644
--- a/test/rubygems/test_gem_local_remote_options.rb
+++ b/test/rubygems/test_gem_local_remote_options.rb
@@ -44,9 +44,8 @@ class TestGemLocalRemoteOptions < Gem::TestCase
spec_fetcher
@cmd.add_local_remote_options
- Gem.configuration.sources = nil
@cmd.handle_options %W[--clear-sources]
- assert_equal Gem.default_sources, Gem.sources.to_a
+ assert_equal Gem.default_sources, Gem.sources
end
def test_local_eh
@@ -124,7 +123,7 @@ class TestGemLocalRemoteOptions < Gem::TestCase
s1 = 'htp://more-gems.example.com'
- assert_raises ArgumentError do
+ assert_raises OptionParser::InvalidArgument do
@cmd.handle_options %W[--source #{s1}]
end
@@ -132,3 +131,4 @@ class TestGemLocalRemoteOptions < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_name_tuple.rb b/test/rubygems/test_gem_name_tuple.rb
index 5331e1cdbb..9bc2924cf6 100644
--- a/test/rubygems/test_gem_name_tuple.rb
+++ b/test/rubygems/test_gem_name_tuple.rb
@@ -42,3 +42,4 @@ class TestGemNameTuple < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index 64ceda39b2..0b03ee2e0c 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -2,7 +2,7 @@
# frozen_string_literal: true
require 'rubygems/package/tar_test_case'
-require 'digest'
+require 'rubygems/simple_gem'
class TestGemPackage < Gem::Package::TarTestCase
@@ -24,8 +24,6 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_class_new_old_format
- skip "jruby can't require the simple_gem file" if Gem.java_platform?
- require_relative "simple_gem"
File.open 'old_format.gem', 'wb' do |io|
io.write SIMPLE_GEM
end
@@ -96,7 +94,7 @@ class TestGemPackage < Gem::Package::TarTestCase
}
}
- if defined?(OpenSSL::Digest)
+ if defined?(OpenSSL::Digest) then
expected['SHA256'] = {
'metadata.gz' => metadata_sha256,
'data.tar.gz' => Digest::SHA256.hexdigest(tar),
@@ -106,58 +104,14 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal expected, YAML.load(checksums)
end
- def test_build_time_uses_source_date_epoch
- epoch = ENV["SOURCE_DATE_EPOCH"]
- ENV["SOURCE_DATE_EPOCH"] = "123456789"
-
- spec = Gem::Specification.new 'build', '1'
- spec.summary = 'build'
- spec.authors = 'build'
- spec.files = ['lib/code.rb']
- spec.date = Time.at 0
- spec.rubygems_version = Gem::Version.new '0'
-
- package = Gem::Package.new spec.file_name
-
- assert_equal Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, package.build_time
- ensure
- ENV["SOURCE_DATE_EPOCH"] = epoch
- end
-
- def test_build_time_without_source_date_epoch
- epoch = ENV["SOURCE_DATE_EPOCH"]
- ENV["SOURCE_DATE_EPOCH"] = nil
-
- spec = Gem::Specification.new 'build', '1'
- spec.summary = 'build'
- spec.authors = 'build'
- spec.files = ['lib/code.rb']
- spec.rubygems_version = Gem::Version.new '0'
-
- package = Gem::Package.new spec.file_name
-
- assert_kind_of Time, package.build_time
-
- build_time = package.build_time.to_i
-
- assert_equal Gem.source_date_epoch.to_i, build_time
- ensure
- ENV["SOURCE_DATE_EPOCH"] = epoch
- end
-
def test_add_files
spec = Gem::Specification.new
spec.files = %w[lib/code.rb lib/empty]
FileUtils.mkdir_p 'lib/empty'
- File.open 'lib/code.rb', 'w' do |io|
- io.write '# lib/code.rb'
- end
-
- File.open 'lib/extra.rb', 'w' do |io|
- io.write '# lib/extra.rb'
- end
+ File.open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end
+ File.open 'lib/extra.rb', 'w' do |io| io.write '# lib/extra.rb' end
package = Gem::Package.new 'bogus.gem'
package.spec = spec
@@ -180,26 +134,16 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_add_files_symlink
+ skip 'symlink not supported' if Gem.win_platform?
+
spec = Gem::Specification.new
- spec.files = %w[lib/code.rb lib/code_sym.rb lib/code_sym2.rb]
+ spec.files = %w[lib/code.rb lib/code_sym.rb]
FileUtils.mkdir_p 'lib'
-
- File.open 'lib/code.rb', 'w' do |io|
- io.write '# lib/code.rb'
- end
+ File.open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end
# NOTE: 'code.rb' is correct, because it's relative to lib/code_sym.rb
- begin
- File.symlink('code.rb', 'lib/code_sym.rb')
- File.symlink('../lib/code.rb', 'lib/code_sym2.rb')
- rescue Errno::EACCES => e
- if win_platform?
- skip "symlink - must be admin with no UAC on Windows"
- else
- raise e
- end
- end
+ File.symlink('code.rb', 'lib/code_sym.rb')
package = Gem::Package.new 'bogus.gem'
package.spec = spec
@@ -223,7 +167,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
assert_equal %w[lib/code.rb], files
- assert_equal [{'lib/code_sym.rb' => 'lib/code.rb'}, {'lib/code_sym2.rb' => '../lib/code.rb'}], symlinks
+ assert_equal [{'lib/code_sym.rb' => 'lib/code.rb'}], symlinks
end
def test_build
@@ -355,19 +299,6 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal 'missing value for attribute summary', e.message
end
- def test_build_invalid_arguments
- spec = Gem::Specification.new 'build', '1'
-
- package = Gem::Package.new spec.file_name
- package.spec = spec
-
- e = assert_raises ArgumentError do
- package.build true, true
- end
-
- assert_equal "skip_validation = true and strict_validation = true are incompatible", e.message
- end
-
def test_build_signed
skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@@ -442,33 +373,6 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal %w[lib/code.rb], reader.contents
end
- def test_raw_spec
- data_tgz = util_tar_gz { }
-
- gem = util_tar do |tar|
- tar.add_file 'data.tar.gz', 0644 do |io|
- io.write data_tgz.string
- end
-
- tar.add_file 'metadata.gz', 0644 do |io|
- Zlib::GzipWriter.wrap io do |gzio|
- gzio.write @spec.to_yaml
- end
- end
- end
-
- gem_path = "#{@destination}/test.gem"
-
- File.open gem_path, "wb" do |io|
- io.write gem.string
- end
-
- spec, metadata = Gem::Package.raw_spec(gem_path)
-
- assert_equal @spec, spec
- assert_match @spec.to_yaml, metadata.force_encoding("UTF-8")
- end
-
def test_contents
package = Gem::Package.new @gem
@@ -490,7 +394,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_extract_files_empty
- data_tgz = util_tar_gz { }
+ data_tgz = util_tar_gz do end
gem = util_tar do |tar|
tar.add_file 'data.tar.gz', 0644 do |io|
@@ -519,9 +423,7 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file '/absolute.rb', 0644 do |io|
- io.write 'hi'
- end
+ tar.add_file '/absolute.rb', 0644 do |io| io.write 'hi' end
end
e = assert_raises Gem::Package::PathError do
@@ -533,26 +435,17 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_extract_tar_gz_symlink_relative_path
+ skip 'symlink not supported' if Gem.win_platform?
+
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file 'relative.rb', 0644 do |io|
- io.write 'hi'
- end
-
+ tar.add_file 'relative.rb', 0644 do |io| io.write 'hi' end
tar.mkdir 'lib', 0755
tar.add_symlink 'lib/foo.rb', '../relative.rb', 0644
end
- begin
- package.extract_tar_gz tgz_io, @destination
- rescue Errno::EACCES => e
- if win_platform?
- skip "symlink - must be admin with no UAC on Windows"
- else
- raise e
- end
- end
+ package.extract_tar_gz tgz_io, @destination
extracted = File.join @destination, 'lib/foo.rb'
assert_path_exists extracted
@@ -563,37 +456,33 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_extract_symlink_parent
- package = Gem::Package.new @gem
+ skip 'symlink not supported' if Gem.win_platform?
- tgz_io = util_tar_gz do |tar|
- tar.mkdir 'lib', 0755
- tar.add_symlink 'lib/link', '../..', 0644
- tar.add_file 'lib/link/outside.txt', 0644 do |io|
- io.write 'hi'
- end
- end
+ package = Gem::Package.new @gem
- # Extract into a subdirectory of @destination; if this test fails it writes
- # a file outside destination_subdir, but we want the file to remain inside
- # @destination so it will be cleaned up.
- destination_subdir = File.join @destination, 'subdir'
- FileUtils.mkdir_p destination_subdir
+ tgz_io = util_tar_gz do |tar|
+ tar.mkdir 'lib', 0755
+ tar.add_symlink 'lib/link', '../..', 0644
+ tar.add_file 'lib/link/outside.txt', 0644 do |io| io.write 'hi' end
+ end
- e = assert_raises(Gem::Package::PathError, Errno::EACCES) do
- package.extract_tar_gz tgz_io, destination_subdir
- end
+ # Extract into a subdirectory of @destination; if this test fails it writes
+ # a file outside destination_subdir, but we want the file to remain inside
+ # @destination so it will be cleaned up.
+ destination_subdir = File.join @destination, 'subdir'
+ FileUtils.mkdir_p destination_subdir
- if Gem::Package::PathError === e
- assert_equal("installing into parent path lib/link/outside.txt of " +
- "#{destination_subdir} is not allowed", e.message)
- elsif win_platform?
- skip "symlink - must be admin with no UAC on Windows"
- else
- raise e
- end
+ e = assert_raises Gem::Package::PathError do
+ package.extract_tar_gz tgz_io, destination_subdir
+ end
+
+ assert_equal("installing into parent path lib/link/outside.txt of " +
+ "#{destination_subdir} is not allowed", e.message)
end
def test_extract_symlink_parent_doesnt_delete_user_dir
+ skip if RUBY_VERSION <= "1.8.7"
+
package = Gem::Package.new @gem
# Extract into a subdirectory of @destination; if this test fails it writes
@@ -632,9 +521,7 @@ class TestGemPackage < Gem::Package::TarTestCase
tgz_io = util_tar_gz do |tar|
tar.mkdir 'lib', 0755
- tar.add_file 'lib/foo.rb', 0644 do |io|
- io.write 'hi'
- end
+ tar.add_file 'lib/foo.rb', 0644 do |io| io.write 'hi' end
tar.mkdir 'lib/foo', 0755
end
@@ -651,9 +538,7 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file './dot_slash.rb', 0644 do |io|
- io.write 'hi'
- end
+ tar.add_file './dot_slash.rb', 0644 do |io| io.write 'hi' end
end
package.extract_tar_gz tgz_io, @destination
@@ -666,9 +551,7 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
- tar.add_file '.dot_file.rb', 0644 do |io|
- io.write 'hi'
- end
+ tar.add_file '.dot_file.rb', 0644 do |io| io.write 'hi' end
end
package.extract_tar_gz tgz_io, @destination
@@ -677,33 +560,16 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_path_exists extracted
end
- if Gem.win_platform?
- def test_extract_tar_gz_case_insensitive
- package = Gem::Package.new @gem
-
- tgz_io = util_tar_gz do |tar|
- tar.add_file 'foo/file.rb', 0644 do |io|
- io.write 'hi'
- end
- end
-
- package.extract_tar_gz tgz_io, @destination.upcase
-
- extracted = File.join @destination, 'foo/file.rb'
- assert_path_exists extracted
- end
- end
-
def test_install_location
package = Gem::Package.new @gem
file = 'file.rb'.dup
- file.taint if RUBY_VERSION < '2.7'
+ file.taint
destination = package.install_location file, @destination
assert_equal File.join(@destination, 'file.rb'), destination
- refute destination.tainted? if RUBY_VERSION < '2.7'
+ refute destination.tainted?
end
def test_install_location_absolute
@@ -734,17 +600,18 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_install_location_extra_slash
+ skip 'no File.realpath on 1.8' if RUBY_VERSION < '1.9'
package = Gem::Package.new @gem
file = 'foo//file.rb'.dup
- file.taint if RUBY_VERSION < '2.7'
+ file.taint
destination = @destination.sub '/', '//'
destination = package.install_location file, destination
assert_equal File.join(@destination, 'foo', 'file.rb'), destination
- refute destination.tainted? if RUBY_VERSION < '2.7'
+ refute destination.tainted?
end
def test_install_location_relative
@@ -776,7 +643,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_load_spec
- entry = StringIO.new Gem::Util.gzip @spec.to_yaml
+ entry = StringIO.new Gem.gzip @spec.to_yaml
def entry.full_name() 'metadata.gz' end
package = Gem::Package.new 'nonexistent.gem'
@@ -806,7 +673,7 @@ class TestGemPackage < Gem::Package::TarTestCase
data_tgz = data_tgz.string
gem = util_tar do |tar|
- metadata_gz = Gem::Util.gzip @spec.to_yaml
+ metadata_gz = Gem.gzip @spec.to_yaml
tar.add_file 'metadata.gz', 0444 do |io|
io.write metadata_gz
@@ -853,7 +720,7 @@ class TestGemPackage < Gem::Package::TarTestCase
data_tgz = data_tgz.string
gem = util_tar do |tar|
- metadata_gz = Gem::Util.gzip @spec.to_yaml
+ metadata_gz = Gem.gzip @spec.to_yaml
tar.add_file 'metadata.gz', 0444 do |io|
io.write metadata_gz
@@ -889,9 +756,8 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_corrupt
- skip "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform?
tf = Tempfile.open 'corrupt' do |io|
- data = Gem::Util.gzip 'a' * 10
+ data = Gem.gzip 'a' * 10
io.write \
tar_file_header('metadata.gz', "\000x", 0644, data.length, Time.now)
io.write data
@@ -907,7 +773,7 @@ class TestGemPackage < Gem::Package::TarTestCase
e.message
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
end
def test_verify_empty
@@ -1015,7 +881,7 @@ class TestGemPackage < Gem::Package::TarTestCase
build.add_contents gem
# write bogus data.tar.gz to foil signature
- bogus_data = Gem::Util.gzip 'hello'
+ bogus_data = Gem.gzip 'hello'
fake_signer = Class.new do
def digest_name; 'SHA512'; end
def digest_algorithm; Digest(:SHA512); end
@@ -1073,40 +939,6 @@ class TestGemPackage < Gem::Package::TarTestCase
end
assert_equal "package is corrupt, exception while verifying: whatever (ArgumentError) in #{@gem}", e.message
-
- valid_metadata = ["metadata", "metadata.gz"]
- valid_metadata.each do |vm|
- $spec_loaded = false
- $good_name = vm
-
- entry = Object.new
- def entry.full_name() $good_name end
-
- package = Gem::Package.new(@gem)
- package.instance_variable_set(:@files, [])
- def package.load_spec(entry) $spec_loaded = true end
-
- package.verify_entry(entry)
-
- assert $spec_loaded
- end
-
- invalid_metadata = ["metadataxgz", "foobar\nmetadata", "metadata\nfoobar"]
- invalid_metadata.each do |vm|
- $spec_loaded = false
- $bad_name = vm
-
- entry = Object.new
- def entry.full_name() $bad_name end
-
- package = Gem::Package.new(@gem)
- package.instance_variable_set(:@files, [])
- def package.load_spec(entry) $spec_loaded = true end
-
- package.verify_entry(entry)
-
- refute $spec_loaded
- end
end
def test_spec
@@ -1115,11 +947,6 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal @spec, package.spec
end
- def test_gem_attr
- package = Gem::Package.new(@gem)
- assert_equal(@gem, package.gem.path)
- end
-
def test_spec_from_io
# This functionality is used by rubygems.org to extract spec data from an
# uploaded gem before it is written to storage.
@@ -1155,9 +982,7 @@ class TestGemPackage < Gem::Package::TarTestCase
tgz_io = StringIO.new
# can't wrap TarWriter because it seeks
- Zlib::GzipWriter.wrap tgz_io do |io|
- io.write tar_io.string
- end
+ Zlib::GzipWriter.wrap tgz_io do |io| io.write tar_io.string end
StringIO.new tgz_io.string
end
diff --git a/test/rubygems/test_gem_package_old.rb b/test/rubygems/test_gem_package_old.rb
index d2ce59cfdd..604981b3c1 100644
--- a/test/rubygems/test_gem_package_old.rb
+++ b/test/rubygems/test_gem_package_old.rb
@@ -1,92 +1,90 @@
# frozen_string_literal: true
require 'rubygems/test_case'
+require 'rubygems/simple_gem'
-unless Gem.java_platform? # jruby can't require the simple_gem file
- require 'rubygems/simple_gem'
+class TestGemPackageOld < Gem::TestCase
- class TestGemPackageOld < Gem::TestCase
+ def setup
+ super
- def setup
- super
-
- File.open 'old_format.gem', 'wb' do |io|
- io.write SIMPLE_GEM
- end
+ File.open 'old_format.gem', 'wb' do |io|
+ io.write SIMPLE_GEM
+ end
- @package = Gem::Package::Old.new 'old_format.gem'
- @destination = File.join @tempdir, 'extract'
+ @package = Gem::Package::Old.new 'old_format.gem'
+ @destination = File.join @tempdir, 'extract'
- FileUtils.mkdir_p @destination
- end
+ FileUtils.mkdir_p @destination
+ end
- def test_contents
- assert_equal %w[lib/foo.rb lib/test.rb lib/test/wow.rb], @package.contents
- end
+ def test_contents
+ assert_equal %w[lib/foo.rb lib/test.rb lib/test/wow.rb], @package.contents
+ end
- def test_contents_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ def test_contents_security_policy
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ @package.security_policy = Gem::Security::AlmostNoSecurity
- assert_raises Gem::Security::Exception do
- @package.contents
- end
+ assert_raises Gem::Security::Exception do
+ @package.contents
end
+ end
- def test_extract_files
- @package.extract_files @destination
+ def test_extract_files
+ @package.extract_files @destination
- extracted = File.join @destination, 'lib/foo.rb'
- assert_path_exists extracted
+ extracted = File.join @destination, 'lib/foo.rb'
+ assert_path_exists extracted
- mask = 0100644 & (~File.umask)
+ mask = 0100644 & (~File.umask)
- assert_equal mask, File.stat(extracted).mode unless win_platform?
- end
+ assert_equal mask, File.stat(extracted).mode unless win_platform?
+ end
- def test_extract_files_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ def test_extract_files_security_policy
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ @package.security_policy = Gem::Security::AlmostNoSecurity
- assert_raises Gem::Security::Exception do
- @package.extract_files @destination
- end
+ assert_raises Gem::Security::Exception do
+ @package.extract_files @destination
end
+ end
- def test_spec
- assert_equal 'testing', @package.spec.name
- end
+ def test_spec
+ assert_equal 'testing', @package.spec.name
+ end
- def test_spec_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ def test_spec_security_policy
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ @package.security_policy = Gem::Security::AlmostNoSecurity
- assert_raises Gem::Security::Exception do
- @package.spec
- end
+ assert_raises Gem::Security::Exception do
+ @package.spec
end
+ end
- def test_verify
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
-
- assert @package.verify
+ def test_verify
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- @package.security_policy = Gem::Security::NoSecurity
+ assert @package.verify
- assert @package.verify
+ @package.security_policy = Gem::Security::NoSecurity
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ assert @package.verify
- e = assert_raises Gem::Security::Exception do
- @package.verify
- end
+ @package.security_policy = Gem::Security::AlmostNoSecurity
- assert_equal 'old format gems do not contain signatures ' +
- 'and cannot be verified',
- e.message
+ e = assert_raises Gem::Security::Exception do
+ @package.verify
end
+ assert_equal 'old format gems do not contain signatures ' +
+ 'and cannot be verified',
+ e.message
end
+
end
+
diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb
index 7e59073407..a0719a7531 100644
--- a/test/rubygems/test_gem_package_tar_header.rb
+++ b/test/rubygems/test_gem_package_tar_header.rb
@@ -158,51 +158,10 @@ group\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
header_s[124, 12] = val
io = TempIO.new header_s
assert_raises ArgumentError do
- Gem::Package::TarHeader.from io
+ new_header = Gem::Package::TarHeader.from io
end
- io.close!
end
end
- def test_big_uid_gid
- stream = StringIO.new(
- <<-EOF.dup.force_encoding('binary').split("\n").join
-GeoIP2-City_20190528/
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000000755\x00\x80\x00
-\x00\x00v\xB2Z\x9E\x80\x00\x00\x00v\xB2Z\x9E00000000000\x0013473270100\x00015424
-\x00 5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ustar \x00
-tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
-\x00\x00\x00\x00
- EOF
- )
-
- tar_header = Gem::Package::TarHeader.from stream
-
- assert_equal 1991400094, tar_header.uid
- assert_equal 1991400094, tar_header.gid
-
- assert_equal 'GeoIP2-City_20190528/', tar_header.name
- assert_equal 0755, tar_header.mode
- assert_equal 0, tar_header.size
- assert_equal 1559064640, tar_header.mtime
- assert_equal 6932, tar_header.checksum
- end
-
end
+
diff --git a/test/rubygems/test_gem_package_tar_reader.rb b/test/rubygems/test_gem_package_tar_reader.rb
index 489685d09d..e8a902c311 100644
--- a/test/rubygems/test_gem_package_tar_reader.rb
+++ b/test/rubygems/test_gem_package_tar_reader.rb
@@ -87,3 +87,4 @@ class TestGemPackageTarReader < Gem::Package::TarTestCase
end
end
+
diff --git a/test/rubygems/test_gem_package_tar_reader_entry.rb b/test/rubygems/test_gem_package_tar_reader_entry.rb
index 87f3471678..dba1987d4d 100644
--- a/test/rubygems/test_gem_package_tar_reader_entry.rb
+++ b/test/rubygems/test_gem_package_tar_reader_entry.rb
@@ -34,28 +34,24 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
assert_equal 1, @entry.bytes_read
end
- def test_size
- assert_equal @contents.size, @entry.size
- end
-
def test_close
@entry.close
assert @entry.bytes_read
- e = assert_raises(IOError) { @entry.eof? }
+ e = assert_raises IOError do @entry.eof? end
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises(IOError) { @entry.getc }
+ e = assert_raises IOError do @entry.getc end
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises(IOError) { @entry.pos }
+ e = assert_raises IOError do @entry.pos end
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises(IOError) { @entry.read }
+ e = assert_raises IOError do @entry.read end
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
- e = assert_raises(IOError) { @entry.rewind }
+ e = assert_raises IOError do @entry.rewind end
assert_equal 'closed Gem::Package::TarReader::Entry', e.message
end
@@ -76,7 +72,6 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
end
def test_full_name_null
- skip "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform?
@entry.header.prefix << "\000"
e = assert_raises Gem::Package::TarInvalidError do
@@ -134,13 +129,6 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
assert_equal @contents[0...100], @entry.read(100)
end
- def test_readpartial
- assert_raises(EOFError) do
- @entry.read(@contents.size)
- @entry.readpartial(1)
- end
- end
-
def test_rewind
char = @entry.getc
diff --git a/test/rubygems/test_gem_package_tar_writer.rb b/test/rubygems/test_gem_package_tar_writer.rb
index 903d681c7e..bed1e3b221 100644
--- a/test/rubygems/test_gem_package_tar_writer.rb
+++ b/test/rubygems/test_gem_package_tar_writer.rb
@@ -8,20 +8,12 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
def setup
super
- # Setting `@default_source_date_epoch` to `nil` effectively resets the
- # value used for `Gem.source_date_epoch` whenever `$SOURCE_DATE_EPOCH`
- # is not set.
- Gem.instance_variable_set(:'@default_source_date_epoch', nil)
-
@data = 'abcde12345'
@io = TempIO.new
@tar_writer = Gem::Package::TarWriter.new @io
- @epoch = ENV["SOURCE_DATE_EPOCH"]
- ENV["SOURCE_DATE_EPOCH"] = nil
end
def teardown
- ENV["SOURCE_DATE_EPOCH"] = @epoch
@tar_writer.close unless @tar_writer.closed?
@io.close!
@@ -30,9 +22,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
def test_add_file
Time.stub :now, Time.at(1458518157) do
- @tar_writer.add_file 'x', 0644 do |f|
- f.write 'a' * 10
- end
+ @tar_writer.add_file 'x', 0644 do |f| f.write 'a' * 10 end
assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now),
@io.string[0, 512])
@@ -41,16 +31,6 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
assert_equal 1024, @io.pos
end
- def test_add_file_source_date_epoch
- ENV["SOURCE_DATE_EPOCH"] = "123456789"
- Time.stub :now, Time.at(1458518157) do
- @tar_writer.mkdir 'foo', 0644
-
- assert_headers_equal tar_dir_header('foo', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
- @io.string[0, 512]
- end
- end
-
def test_add_symlink
Time.stub :now, Time.at(1458518157) do
@tar_writer.add_symlink 'x', 'y', 0644
@@ -61,16 +41,6 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
assert_equal 512, @io.pos
end
- def test_add_symlink_source_date_epoch
- ENV["SOURCE_DATE_EPOCH"] = "123456789"
- Time.stub :now, Time.at(1458518157) do
- @tar_writer.add_symlink 'x', 'y', 0644
-
- assert_headers_equal(tar_symlink_header('x', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, 'y'),
- @io.string[0, 512])
- end
- end
-
def test_add_file_digest
digest_algorithms = Digest::SHA1, Digest::SHA512
@@ -130,6 +100,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now),
@io.string[0, 512])
+
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
digest = signer.digest_algorithm.new
@@ -145,6 +116,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
assert_equal 2048, @io.pos
end
+
end
def test_add_file_signer_empty
@@ -166,9 +138,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
def test_add_file_simple
Time.stub :now, Time.at(1458518157) do
- @tar_writer.add_file_simple 'x', 0644, 10 do |io|
- io.write "a" * 10
- end
+ @tar_writer.add_file_simple 'x', 0644, 10 do |io| io.write "a" * 10 end
assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now),
@io.string[0, 512])
@@ -178,18 +148,6 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
assert_equal 1024, @io.pos
end
- def test_add_file_simple_source_date_epoch
- ENV["SOURCE_DATE_EPOCH"] = "123456789"
- Time.stub :now, Time.at(1458518157) do
- @tar_writer.add_file_simple 'x', 0644, 10 do |io|
- io.write "a" * 10
- end
-
- assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
- @io.string[0, 512])
- end
- end
-
def test_add_file_simple_padding
Time.stub :now, Time.at(1458518157) do
@tar_writer.add_file_simple 'x', 0, 100
@@ -205,7 +163,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
@tar_writer.add_file_simple("lib/foo/bar", 0, 10) { |f| f.write @data }
@tar_writer.flush
- assert_equal @data + ("\0" * (512 - @data.size)),
+ assert_equal @data + ("\0" * (512-@data.size)),
@io.string[512, 512]
end
@@ -217,6 +175,12 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
end
end
+ def test_add_file_unseekable
+ assert_raises Gem::Package::NonSeekableIO do
+ Gem::Package::TarWriter.new(Object.new).add_file 'x', 0
+ end
+ end
+
def test_close
@tar_writer.close
@@ -259,16 +223,6 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
end
end
- def test_mkdir_source_date_epoch
- ENV["SOURCE_DATE_EPOCH"] = "123456789"
- Time.stub :now, Time.at(1458518157) do
- @tar_writer.mkdir 'foo', 0644
-
- assert_headers_equal tar_dir_header('foo', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc),
- @io.string[0, 512]
- end
- end
-
def test_split_name
assert_equal ['b' * 100, 'a' * 155],
@tar_writer.split_name("#{'a' * 155}/#{'b' * 100}")
@@ -305,7 +259,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
# note, GNU tar 1.28 is unable to handle this case too,
# tested with "tar --format=ustar -cPf /tmp/foo.tartar -- /aaaaaa....a"
- name = '/' + 'a' * 100
+ name = '/' + 'a' * 100
exception = assert_raises Gem::Package::TooLongFileName do
@tar_writer.split_name name
end
diff --git a/test/rubygems/test_gem_package_task.rb b/test/rubygems/test_gem_package_task.rb
index e01f4a4043..f69ee36bd3 100644
--- a/test/rubygems/test_gem_package_task.rb
+++ b/test/rubygems/test_gem_package_task.rb
@@ -1,10 +1,9 @@
# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems'
-require 'bundler/errors'
begin
require 'rubygems/package_task'
-rescue LoadError, Bundler::GemfileNotFound
+rescue LoadError
end
class TestGemPackageTask < Gem::TestCase
@@ -82,3 +81,4 @@ class TestGemPackageTask < Gem::TestCase
end
end if defined?(Rake::PackageTask)
+
diff --git a/test/rubygems/test_gem_path_support.rb b/test/rubygems/test_gem_path_support.rb
index 8715bb62dc..754c43e893 100644
--- a/test/rubygems/test_gem_path_support.rb
+++ b/test/rubygems/test_gem_path_support.rb
@@ -4,7 +4,6 @@ require 'rubygems'
require 'fileutils'
class TestGemPathSupport < Gem::TestCase
-
def setup
super
@@ -30,7 +29,7 @@ class TestGemPathSupport < Gem::TestCase
assert_equal expected, ps.path
end
- if File::ALT_SEPARATOR
+ if defined?(File::ALT_SEPARATOR) and File::ALT_SEPARATOR
def test_initialize_home_normalize
alternate = @tempdir.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
ps = Gem::PathSupport.new "GEM_HOME" => alternate
@@ -40,19 +39,17 @@ class TestGemPathSupport < Gem::TestCase
end
def test_initialize_path
- Gem.stub(:path_separator, File::PATH_SEPARATOR) do
- ps = Gem::PathSupport.new ENV.to_hash.merge("GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
+ ps = Gem::PathSupport.new ENV.to_hash.merge("GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
- assert_equal ENV["GEM_HOME"], ps.home
+ assert_equal ENV["GEM_HOME"], ps.home
- expected = [
- File.join(@tempdir, 'foo'),
- File.join(@tempdir, 'bar'),
- ENV["GEM_HOME"],
- ]
+ expected = [
+ File.join(@tempdir, 'foo'),
+ File.join(@tempdir, 'bar'),
+ ENV["GEM_HOME"],
+ ]
- assert_equal expected, ps.path
- end
+ assert_equal expected, ps.path
end
def test_initialize_regexp_path_separator
@@ -66,9 +63,9 @@ class TestGemPathSupport < Gem::TestCase
assert_equal ENV["GEM_HOME"], ps.home
expected = [
- File.join(@tempdir, 'foo'),
- File.join(@tempdir, 'bar'),
- ] + Gem.default_path << ENV["GEM_HOME"]
+ File.join(@tempdir, 'foo'),
+ File.join(@tempdir, 'bar'),
+ ] + Gem.default_path << ENV["GEM_HOME"]
assert_equal expected, ps.path
end
@@ -84,23 +81,21 @@ class TestGemPathSupport < Gem::TestCase
assert_equal ENV["GEM_HOME"], ps.home
expected = [
- File.join(@tempdir, 'foo'),
- File.join(@tempdir, 'bar'),
- ] + Gem.default_path << ENV["GEM_HOME"]
+ File.join(@tempdir, 'foo'),
+ File.join(@tempdir, 'bar'),
+ ] + Gem.default_path << ENV["GEM_HOME"]
assert_equal expected, ps.path
end
def test_initialize_home_path
- Gem.stub(:path_separator, File::PATH_SEPARATOR) do
- ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
- "GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
+ ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
+ "GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
- assert_equal File.join(@tempdir, "foo"), ps.home
+ assert_equal File.join(@tempdir, "foo"), ps.home
- expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')]
- assert_equal expected, ps.path
- end
+ expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')]
+ assert_equal expected, ps.path
end
def util_path
@@ -123,22 +118,4 @@ class TestGemPathSupport < Gem::TestCase
ps = Gem::PathSupport.new "GEM_SPEC_CACHE" => "foo"
assert_equal "foo", ps.spec_cache_dir
end
-
- def test_gem_paths_do_not_contain_symlinks
- dir = "#{@tempdir}/realgemdir"
- symlink = "#{@tempdir}/symdir"
- Dir.mkdir dir
- begin
- File.symlink(dir, symlink)
- rescue NotImplementedError, SystemCallError
- skip 'symlinks not supported'
- end
- not_existing = "#{@tempdir}/does_not_exist"
- path = "#{symlink}#{File::PATH_SEPARATOR}#{not_existing}"
-
- ps = Gem::PathSupport.new "GEM_PATH" => path, "GEM_HOME" => symlink
- assert_equal dir, ps.home
- assert_equal [dir, not_existing], ps.path
- end
-
end
diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
index 289f078867..c9abd08868 100644
--- a/test/rubygems/test_gem_platform.rb
+++ b/test/rubygems/test_gem_platform.rb
@@ -76,7 +76,6 @@ class TestGemPlatform < Gem::TestCase
'i386-solaris2.8' => ['x86', 'solaris', '2.8'],
'mswin32' => ['x86', 'mswin32', nil],
'x86_64-linux' => ['x86_64', 'linux', nil],
- 'x86_64-linux-musl' => ['x86_64', 'linux', 'musl'],
'x86_64-openbsd3.9' => ['x86_64', 'openbsd', '3.9'],
'x86_64-openbsd4.0' => ['x86_64', 'openbsd', '4.0'],
'x86_64-openbsd' => ['x86_64', 'openbsd', nil],
@@ -118,7 +117,7 @@ class TestGemPlatform < Gem::TestCase
assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
ensure
- if orig_RUBY_SO_NAME
+ if orig_RUBY_SO_NAME then
RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
else
RbConfig::CONFIG.delete 'RUBY_SO_NAME'
@@ -146,7 +145,7 @@ class TestGemPlatform < Gem::TestCase
end
def test_to_s
- if win_platform?
+ if win_platform? then
assert_equal 'x86-mswin32-60', Gem::Platform.local.to_s
else
assert_equal 'x86-darwin-8', Gem::Platform.local.to_s
@@ -212,13 +211,13 @@ class TestGemPlatform < Gem::TestCase
assert((arm === Gem::Platform.local), 'arm === armv5')
assert((armv5 === Gem::Platform.local), 'armv5 === armv5')
refute((armv7 === Gem::Platform.local), 'armv7 === armv5')
- refute((Gem::Platform.local === arm), 'armv5 === arm')
+ refute((Gem::Platform.local === arm), 'armv5 === arm')
util_set_arch 'armv7-linux'
assert((arm === Gem::Platform.local), 'arm === armv7')
refute((armv5 === Gem::Platform.local), 'armv5 === armv7')
assert((armv7 === Gem::Platform.local), 'armv7 === armv7')
- refute((Gem::Platform.local === arm), 'armv7 === arm')
+ refute((Gem::Platform.local === arm), 'armv7 === arm')
end
def test_equals3_version
@@ -298,12 +297,12 @@ class TestGemPlatform < Gem::TestCase
assert_local_match 'sparc-solaris2.8-mq5.3'
end
- def assert_local_match(name)
+ def assert_local_match name
assert_match Gem::Platform.local, name
end
- def refute_local_match(name)
+ def refute_local_match name
refute_match Gem::Platform.local, name
end
-
end
+
diff --git a/test/rubygems/test_gem_rdoc.rb b/test/rubygems/test_gem_rdoc.rb
index 6184d4b457..0355883cb3 100644
--- a/test/rubygems/test_gem_rdoc.rb
+++ b/test/rubygems/test_gem_rdoc.rb
@@ -4,8 +4,8 @@ require 'rubygems/test_case'
require 'rubygems/rdoc'
class TestGemRDoc < Gem::TestCase
-
Gem::RDoc.load_rdoc
+ rdoc_4 = Gem::Requirement.new('> 3').satisfied_by?(Gem::RDoc.rdoc_version)
def setup
super
@@ -31,8 +31,29 @@ class TestGemRDoc < Gem::TestCase
Gem.configuration[:rdoc] = nil
end
+ ##
+ # RDoc 4 ships with its own Gem::RDoc which overrides this one which is
+ # shipped for backwards compatibility.
+
+ def rdoc_4?
+ Gem::Requirement.new('>= 4.0.0.preview2').satisfied_by? \
+ @hook.class.rdoc_version
+ end
+
+ def rdoc_3?
+ Gem::Requirement.new('~> 3.0').satisfied_by? @hook.class.rdoc_version
+ end
+
+ def rdoc_3_8_or_better?
+ Gem::Requirement.new('>= 3.8').satisfied_by? @hook.class.rdoc_version
+ end
+
def test_initialize
- refute @hook.generate_rdoc
+ if rdoc_4? then
+ refute @hook.generate_rdoc
+ else
+ assert @hook.generate_rdoc
+ end
assert @hook.generate_ri
rdoc = Gem::RDoc.new @a, false, false
@@ -54,6 +75,67 @@ class TestGemRDoc < Gem::TestCase
assert_empty args
end
+ def test_document
+ skip 'RDoc 3 required' unless rdoc_3?
+
+ options = RDoc::Options.new
+ options.files = []
+
+ rdoc = @hook.new_rdoc
+ @hook.instance_variable_set :@rdoc, rdoc
+ @hook.instance_variable_set :@file_info, []
+
+ @hook.document 'darkfish', options, @a.doc_dir('rdoc')
+
+ assert @hook.rdoc_installed?
+ end unless rdoc_4
+
+ def test_generate
+ skip 'RDoc 3 required' unless rdoc_3?
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.generate
+
+ assert @hook.rdoc_installed?
+ assert @hook.ri_installed?
+
+ rdoc = @hook.instance_variable_get :@rdoc
+
+ refute rdoc.options.hyperlink_all
+ end unless rdoc_4
+
+ def test_generate_configuration_rdoc_array
+ skip 'RDoc 3 required' unless rdoc_3?
+
+ Gem.configuration[:rdoc] = %w[-A]
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.generate
+
+ rdoc = @hook.instance_variable_get :@rdoc
+
+ assert rdoc.options.hyperlink_all
+ end unless rdoc_4
+
+ def test_generate_configuration_rdoc_string
+ skip 'RDoc 3 required' unless rdoc_3?
+
+ Gem.configuration[:rdoc] = '-A'
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.generate
+
+ rdoc = @hook.instance_variable_get :@rdoc
+
+ assert rdoc.options.hyperlink_all
+ end unless rdoc_4
+
def test_generate_disabled
@hook.generate_rdoc = false
@hook.generate_ri = false
@@ -64,6 +146,57 @@ class TestGemRDoc < Gem::TestCase
refute @hook.ri_installed?
end
+ def test_generate_force
+ skip 'RDoc 3 required' unless rdoc_3?
+
+ FileUtils.mkdir_p @a.doc_dir 'ri'
+ FileUtils.mkdir_p @a.doc_dir 'rdoc'
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.force = true
+
+ @hook.generate
+
+ assert_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
+ assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
+ end unless rdoc_4
+
+ def test_generate_no_overwrite
+ skip 'RDoc 3 required' unless rdoc_3?
+
+ FileUtils.mkdir_p @a.doc_dir 'ri'
+ FileUtils.mkdir_p @a.doc_dir 'rdoc'
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.generate
+
+ refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
+ refute_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
+ end unless rdoc_4
+
+ def test_generate_legacy
+ skip 'RDoc < 3.8 required' if rdoc_3_8_or_better?
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.generate_legacy
+
+ assert @hook.rdoc_installed?
+ assert @hook.ri_installed?
+ end unless rdoc_4
+
+ def test_legacy_rdoc
+ skip 'RDoc < 3.8 required' if rdoc_3_8_or_better?
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.legacy_rdoc '--op', @a.doc_dir('rdoc')
+
+ assert @hook.rdoc_installed?
+ end unless rdoc_4
+
def test_new_rdoc
assert_kind_of RDoc::RDoc, @hook.new_rdoc
end
@@ -136,3 +269,4 @@ class TestGemRDoc < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 76a66af867..20e34e84e1 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -9,10 +9,6 @@ rescue LoadError => e
e.message =~ / -- openssl$/
end
-unless defined?(OpenSSL::SSL)
- warn 'Skipping Gem::Request tests. openssl not found.'
-end
-
require 'rubygems/remote_fetcher'
require 'rubygems/package'
require 'minitest/mock'
@@ -35,7 +31,7 @@ class TestGemRemoteFetcher < Gem::TestCase
include Gem::DefaultUserInteraction
- SERVER_DATA = <<-EOY.freeze
+ SERVER_DATA = <<-EOY
--- !ruby/object:Gem::Cache
gems:
rake-0.4.11: !ruby/object:Gem::Specification
@@ -51,8 +47,10 @@ gems:
author: Jim Weirich
email: jim@weirichhouse.org
homepage: http://rake.rubyforge.org
+ rubyforge_project: rake
description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.
autorequire:
+ default_executable: rake
bindir: bin
has_rdoc: true
required_ruby_version: !ruby/object:Gem::Version::Requirement
@@ -83,7 +81,7 @@ gems:
# Generated via:
# x = OpenSSL::PKey::DH.new(2048) # wait a while...
# x.to_s => pem
- TEST_KEY_DH2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_
+ TEST_KEY_DH2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEA3Ze2EHSfYkZLUn557torAmjBgPsqzbodaRaGZtgK1gEU+9nNJaFV
G1JKhmGUiEDyIW7idsBpe4sX/Wqjnp48Lr8IeI/SlEzLdoGpf05iRYXC8Cm9o8aM
@@ -116,14 +114,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
FileUtils.mkdir @gems_dir
# TODO: why does the remote fetcher need it written to disk?
- @a1, @a1_gem = util_gem 'a', '1' do |s|
- s.executables << 'a_bin'
- end
-
+ @a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
@a1.loaded_from = File.join(@gemhome, 'specifications', @a1.full_name)
Gem::RemoteFetcher.fetcher = nil
- @stub_ui = Gem::MockGemUi.new
+
@fetcher = Gem::RemoteFetcher.fetcher
end
@@ -158,9 +153,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
@fetcher = fetcher
e = assert_raises ArgumentError do
- Gem::Deprecate.skip_during do
- fetcher.fetch_size 'gems.example.com/yaml'
- end
+ fetcher.fetch_size 'gems.example.com/yaml'
end
assert_equal 'uri scheme is invalid: nil', e.message
@@ -175,21 +168,117 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
uri = 'http://gems.example.com/yaml'
e = assert_raises Gem::RemoteFetcher::FetchError do
- Gem::Deprecate.skip_during do
- fetcher.fetch_size uri
- end
+ fetcher.fetch_size uri
end
assert_equal "SocketError: oops (#{uri})", e.message
end
def test_no_proxy
- use_ui @stub_ui do
+ use_ui @ui do
assert_data_from_server @fetcher.fetch_path(@server_uri)
- Gem::Deprecate.skip_during do
- assert_equal SERVER_DATA.size, @fetcher.fetch_size(@server_uri)
+ assert_equal SERVER_DATA.size, @fetcher.fetch_size(@server_uri)
+ end
+ end
+
+ def test_api_endpoint
+ uri = URI.parse "http://example.com/foo"
+ target = MiniTest::Mock.new
+ target.expect :target, "gems.example.com"
+
+ dns = MiniTest::Mock.new
+ dns.expect :getresource, target, [String, Object]
+
+ fetch = Gem::RemoteFetcher.new nil, dns
+ assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
+
+ target.verify
+ dns.verify
+ end
+
+ def test_api_endpoint_ignores_trans_domain_values
+ uri = URI.parse "http://gems.example.com/foo"
+ target = MiniTest::Mock.new
+ target.expect :target, "blah.com"
+
+ dns = MiniTest::Mock.new
+ dns.expect :getresource, target, [String, Object]
+
+ fetch = Gem::RemoteFetcher.new nil, dns
+ assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
+
+ target.verify
+ dns.verify
+ end
+
+ def test_api_endpoint_ignores_trans_domain_values_that_starts_with_original
+ uri = URI.parse "http://example.com/foo"
+ target = MiniTest::Mock.new
+ target.expect :target, "example.combadguy.com"
+
+ dns = MiniTest::Mock.new
+ dns.expect :getresource, target, [String, Object]
+
+ fetch = Gem::RemoteFetcher.new nil, dns
+ assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
+
+ target.verify
+ dns.verify
+ end
+
+ def test_api_endpoint_ignores_trans_domain_values_that_end_with_original
+ uri = URI.parse "http://example.com/foo"
+ target = MiniTest::Mock.new
+ target.expect :target, "badexample.com"
+
+ dns = MiniTest::Mock.new
+ dns.expect :getresource, target, [String, Object]
+
+ fetch = Gem::RemoteFetcher.new nil, dns
+ assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
+
+ target.verify
+ dns.verify
+ end
+
+ def test_api_endpoint_ignores_trans_domain_values_that_end_with_original_in_path
+ uri = URI.parse "http://example.com/foo"
+ target = MiniTest::Mock.new
+ target.expect :target, "evil.com/a.example.com"
+
+ dns = MiniTest::Mock.new
+ dns.expect :getresource, target, [String, Object]
+
+ fetch = Gem::RemoteFetcher.new nil, dns
+ assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
+
+ target.verify
+ dns.verify
+ end
+
+ def test_api_endpoint_timeout_warning
+ uri = URI.parse "http://gems.example.com/foo"
+
+ dns = MiniTest::Mock.new
+ def dns.getresource arg, *rest
+ raise Resolv::ResolvError.new('timeout!')
+ end
+
+ fetch = Gem::RemoteFetcher.new nil, dns
+ begin
+ old_verbose, Gem.configuration.verbose = Gem.configuration.verbose, 1
+ endpoint = use_ui @ui do
+ fetch.api_endpoint(uri)
end
+ ensure
+ Gem.configuration.verbose = old_verbose
end
+
+ assert_equal uri, endpoint
+
+ assert_equal "Getting SRV record failed: timeout!\n", @ui.output
+
+ dns.verify
end
def test_cache_update_path
@@ -218,20 +307,20 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
refute_path_exists path
end
- def util_fuck_with_fetcher(data, blow = false)
+ def util_fuck_with_fetcher data, blow = false
fetcher = Gem::RemoteFetcher.fetcher
fetcher.instance_variable_set :@test_data, data
- unless blow
- def fetcher.fetch_path(arg, *rest)
+ unless blow then
+ def fetcher.fetch_path arg, *rest
@test_arg = arg
@test_data
end
else
- def fetcher.fetch_path(arg, *rest)
+ def fetcher.fetch_path arg, *rest
# OMG I'm such an ass
class << self; remove_method :fetch_path; end
- def self.fetch_path(arg, *rest)
+ def self.fetch_path arg, *rest
@test_arg = arg
@test_data
end
@@ -431,7 +520,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
util_setup_spec_fetcher @a1, @a2
@fetcher.instance_variable_set :@a1, @a1
@fetcher.instance_variable_set :@a2, @a2
- def @fetcher.fetch_path(uri, mtime = nil, head = false)
+ def @fetcher.fetch_path uri, mtime = nil, head = false
case uri.request_uri
when /#{@a1.spec_name}/ then
Gem.deflate Marshal.dump @a1
@@ -452,7 +541,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
@fetcher = fetcher
def fetcher.fetch_http(uri, mtime, head = nil)
- Gem::Util.gzip 'foo'
+ Gem.gzip 'foo'
end
assert_equal 'foo', fetcher.fetch_path(@uri + 'foo.gz')
@@ -524,24 +613,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
assert_equal url, e.uri
end
- def test_fetch_path_openssl_ssl_sslerror
- fetcher = Gem::RemoteFetcher.new nil
- @fetcher = fetcher
-
- def fetcher.fetch_http(uri, mtime = nil, head = nil)
- raise OpenSSL::SSL::SSLError
- end
-
- url = 'http://example.com/uri'
-
- e = assert_raises Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path url
- end
-
- assert_equal "OpenSSL::SSL::SSLError: OpenSSL::SSL::SSLError (#{url})", e.message
- assert_equal url, e.uri
- end
-
def test_fetch_path_unmodified
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
@@ -554,7 +625,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_implicit_no_proxy
- use_ui @stub_ui do
+ use_ui @ui do
ENV['http_proxy'] = 'http://fakeurl:12345'
fetcher = Gem::RemoteFetcher.new :no_proxy
@fetcher = fetcher
@@ -563,7 +634,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_implicit_proxy
- use_ui @stub_ui do
+ use_ui @ui do
ENV['http_proxy'] = @proxy_uri
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
@@ -572,7 +643,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_implicit_upper_case_proxy
- use_ui @stub_ui do
+ use_ui @ui do
ENV['HTTP_PROXY'] = @proxy_uri
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
@@ -581,7 +652,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_implicit_proxy_no_env
- use_ui @stub_ui do
+ use_ui @ui do
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
assert_data_from_server fetcher.fetch_path(@server_uri)
@@ -595,7 +666,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def fetcher.request(uri, request_class, last_modified = nil)
url = 'http://gems.example.com/redirect'
- unless defined? @requested
+ unless defined? @requested then
@requested = true
res = Net::HTTPMovedPermanently.new nil, 301, nil
res.add_field 'Location', url
@@ -656,11 +727,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
assert_equal "murphy", fetcher.fetch_path(@server_uri)
end
- def assert_fetch_s3(url, signature, token=nil, region='us-east-1', instance_profile_json=nil)
+ def test_fetch_s3
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
+ url = 's3://testuser:testpass@my-bucket/gems/specs.4.8.gz'
$fetched_uri = nil
- $instance_profile = instance_profile_json
def fetcher.request(uri, request_class, last_modified = nil)
$fetched_uri = uri
@@ -669,206 +740,31 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
res
end
- def fetcher.s3_uri_signer(uri)
- require 'json'
- s3_uri_signer = Gem::S3URISigner.new(uri)
- def s3_uri_signer.ec2_metadata_credentials_json
- JSON.parse($instance_profile)
- end
- # Running sign operation to make sure uri.query is not mutated
- s3_uri_signer.sign
- raise "URI query is not empty: #{uri.query}" unless uri.query.nil?
- s3_uri_signer
+ def fetcher.s3_expiration
+ 1395098371
end
data = fetcher.fetch_s3 URI.parse(url)
- assert_equal "https://my-bucket.s3.#{region}.amazonaws.com/gems/specs.4.8.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=testuser%2F20190624%2F#{region}%2Fs3%2Faws4_request&X-Amz-Date=20190624T050641Z&X-Amz-Expires=86400#{token ? "&X-Amz-Security-Token=" + token : ""}&X-Amz-SignedHeaders=host&X-Amz-Signature=#{signature}", $fetched_uri.to_s
+ assert_equal 'https://my-bucket.s3.amazonaws.com/gems/specs.4.8.gz?AWSAccessKeyId=testuser&Expires=1395098371&Signature=eUTr7NkpZEet%2BJySE%2BfH6qukroI%3D', $fetched_uri.to_s
assert_equal 'success', data
ensure
$fetched_uri = nil
end
- def test_fetch_s3_config_creds
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass'}
- }
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b'
- end
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_config_creds_with_region
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass', :region => 'us-west-2'}
- }
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2'
- end
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_config_creds_with_token
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass', :security_token => 'testtoken'}
- }
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken'
- end
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_env_creds
- ENV['AWS_ACCESS_KEY_ID'] = 'testuser'
- ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
- ENV['AWS_SESSION_TOKEN'] = nil
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env'}
- }
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b'
- end
- ensure
- ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS')}
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_env_creds_with_region
- ENV['AWS_ACCESS_KEY_ID'] = 'testuser'
- ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
- ENV['AWS_SESSION_TOKEN'] = nil
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env', :region => 'us-west-2'}
- }
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2'
- end
- ensure
- ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS')}
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_env_creds_with_token
- ENV['AWS_ACCESS_KEY_ID'] = 'testuser'
- ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
- ENV['AWS_SESSION_TOKEN'] = 'testtoken'
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env'}
- }
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken'
- end
- ensure
- ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS')}
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_url_creds
- url = 's3://testuser:testpass@my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b'
- end
- end
-
- def test_fetch_s3_instance_profile_creds
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile'}
- }
-
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b', nil, 'us-east-1',
- '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}'
- end
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_instance_profile_creds_with_region
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile', :region => 'us-west-2'}
- }
-
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2',
- '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}'
- end
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_instance_profile_creds_with_token
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile'}
- }
-
- url = 's3://my-bucket/gems/specs.4.8.gz'
- Time.stub :now, Time.at(1561353581) do
- assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken', 'us-east-1',
- '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass", "Token": "testtoken"}'
- end
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def refute_fetch_s3(url, expected_message)
+ def test_fetch_s3_no_creds
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
-
+ url = 's3://my-bucket/gems/specs.4.8.gz'
e = assert_raises Gem::RemoteFetcher::FetchError do
fetcher.fetch_s3 URI.parse(url)
end
- assert_match expected_message, e.message
- end
-
- def test_fetch_s3_no_source_key
- url = 's3://my-bucket/gems/specs.4.8.gz'
- refute_fetch_s3 url, 'no s3_source key exists in .gemrc'
- end
-
- def test_fetch_s3_no_host
- Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass'}
- }
-
- url = 's3://other-bucket/gems/specs.4.8.gz'
- refute_fetch_s3 url, 'no key for host other-bucket in s3_source in .gemrc'
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_no_id
- Gem.configuration[:s3_source] = { 'my-bucket' => {:secret => 'testpass'} }
-
- url = 's3://my-bucket/gems/specs.4.8.gz'
- refute_fetch_s3 url, 's3_source for my-bucket missing id or secret'
- ensure
- Gem.configuration[:s3_source] = nil
- end
-
- def test_fetch_s3_no_secret
- Gem.configuration[:s3_source] = { 'my-bucket' => {:id => 'testuser'} }
-
- url = 's3://my-bucket/gems/specs.4.8.gz'
- refute_fetch_s3 url, 's3_source for my-bucket missing id or secret'
- ensure
- Gem.configuration[:s3_source] = nil
+ assert_match "credentials needed", e.message
end
def test_observe_no_proxy_env_single_host
- use_ui @stub_ui do
+ use_ui @ui do
ENV["http_proxy"] = @proxy_uri
ENV["no_proxy"] = URI::parse(@server_uri).host
fetcher = Gem::RemoteFetcher.new nil
@@ -878,7 +774,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_observe_no_proxy_env_list
- use_ui @stub_ui do
+ use_ui @ui do
ENV["http_proxy"] = @proxy_uri
ENV["no_proxy"] = "fakeurl.com, #{URI::parse(@server_uri).host}"
fetcher = Gem::RemoteFetcher.new nil
@@ -900,7 +796,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_yaml_error_on_size
- use_ui @stub_ui do
+ use_ui @ui do
self.class.enable_yaml = false
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
@@ -918,11 +814,10 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_ssl_client_cert_auth_connection
skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- skip 'openssl in jruby fails' if java_platform?
ssl_server = self.class.start_ssl_server({
:SSLVerifyClient =>
- OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
+ OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_client_cert = File.join(DIR, 'client.pem')
@@ -939,7 +834,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ssl_server = self.class.start_ssl_server({
:SSLVerifyClient =>
- OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
+ OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_client_cert = File.join(DIR, 'invalid_client.pem')
@@ -947,9 +842,9 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
with_configured_fetcher(
":ssl_ca_cert: #{temp_ca_cert}\n" +
":ssl_client_cert: #{temp_client_cert}\n") do |fetcher|
- assert_raises Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
- end
+ assert_raises Gem::RemoteFetcher::FetchError do
+ fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
+ end
end
end
@@ -971,26 +866,10 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_do_not_follow_insecure_redirect
ssl_server = self.class.start_ssl_server
- temp_ca_cert = File.join(DIR, 'ca_cert.pem')
- expected_error_message =
- "redirecting to non-https resource: #{@server_uri} (https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri})"
-
- with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher|
- err = assert_raises Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri}")
- end
-
- assert_equal(err.message, expected_error_message)
- end
- end
-
- def test_nil_ca_cert
- ssl_server = self.class.start_ssl_server
- temp_ca_cert = nil
-
+ temp_ca_cert = File.join(DIR, 'ca_cert.pem'),
with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher|
assert_raises Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}")
+ fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri}")
end
end
end
@@ -1031,14 +910,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
class NilLog < WEBrick::Log
-
def log(level, data) #Do nothing
end
-
end
class << self
-
attr_reader :normal_server, :proxy_server
attr_accessor :enable_zip, :enable_yaml
@@ -1098,12 +974,12 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:SSLVerifyClient => nil,
:SSLCertName => nil
}.merge(config))
- server.mount_proc("/yaml") do |req, res|
+ server.mount_proc("/yaml") { |req, res|
res.body = "--- true\n"
- end
- server.mount_proc("/insecure_redirect") do |req, res|
+ }
+ server.mount_proc("/insecure_redirect") { |req, res|
res.set_redirect(WEBrick::HTTPStatus::MovedPermanently, req.query['to'])
- end
+ }
server.ssl_context.tmp_dh_callback = proc { TEST_KEY_DH2048 }
t = Thread.new do
begin
@@ -1136,9 +1012,9 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:DocumentRoot => nil,
:Logger => null_logger,
:AccessLog => null_logger
- )
+ )
s.mount_proc("/kill") { |req, res| s.shutdown }
- s.mount_proc("/yaml") do |req, res|
+ s.mount_proc("/yaml") { |req, res|
if req["X-Captain"]
res.body = req["X-Captain"]
elsif @enable_yaml
@@ -1150,8 +1026,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
res.body = "<h1>NOT FOUND</h1>"
res['Content-Type'] = 'text/html'
end
- end
- s.mount_proc("/yaml.Z") do |req, res|
+ }
+ s.mount_proc("/yaml.Z") { |req, res|
if @enable_zip
res.body = Zlib::Deflate.deflate(data)
res['Content-Type'] = 'text/plain'
@@ -1160,7 +1036,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
res.body = "<h1>NOT FOUND</h1>"
res['Content-Type'] = 'text/html'
end
- end
+ }
th = Thread.new do
begin
s.start
@@ -1181,7 +1057,14 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def key(filename)
OpenSSL::PKey::RSA.new(File.read(File.join(DIR, filename)))
end
+ end
+ def test_correct_for_windows_path
+ path = "/C:/WINDOWS/Temp/gems"
+ assert_equal "C:/WINDOWS/Temp/gems", @fetcher.correct_for_windows_path(path)
+
+ path = "/home/skillet"
+ assert_equal "/home/skillet", @fetcher.correct_for_windows_path(path)
end
-end if defined?(OpenSSL::SSL)
+end
diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb
index 2a756eaad7..46a49a6943 100644
--- a/test/rubygems/test_gem_request.rb
+++ b/test/rubygems/test_gem_request.rb
@@ -4,10 +4,6 @@ require 'rubygems/request'
require 'ostruct'
require 'base64'
-unless defined?(OpenSSL::SSL)
- warn 'Skipping Gem::Request tests. openssl not found.'
-end
-
class TestGemRequest < Gem::TestCase
CA_CERT_FILE = cert_path 'ca'
@@ -17,7 +13,7 @@ class TestGemRequest < Gem::TestCase
PUBLIC_CERT_FILE = cert_path 'public'
SSL_CERT = load_cert 'ssl'
- def make_request(uri, request_class, last_modified, proxy)
+ def make_request uri, request_class, last_modified, proxy
Gem::Request.create_with_proxy uri, request_class, last_modified, proxy
end
@@ -79,25 +75,14 @@ class TestGemRequest < Gem::TestCase
assert_equal URI(@proxy_uri), proxy
end
- def test_proxy_ENV
- ENV['http_proxy'] = "http://proxy"
- ENV['https_proxy'] = ""
-
- request = make_request URI('https://example'), nil, nil, nil
-
- proxy = request.proxy_uri
-
- assert_nil proxy
- end
-
def test_configure_connection_for_https
connection = Net::HTTP.new 'localhost', 443
- request = Class.new(Gem::Request) do
+ request = Class.new(Gem::Request) {
def self.get_cert_files
[TestGemRequest::PUBLIC_CERT_FILE]
end
- end.create_with_proxy URI('https://example'), nil, nil, nil
+ }.create_with_proxy URI('https://example'), nil, nil, nil
Gem::Request.configure_connection_for_https connection, request.cert_files
@@ -112,11 +97,11 @@ class TestGemRequest < Gem::TestCase
connection = Net::HTTP.new 'localhost', 443
- request = Class.new(Gem::Request) do
+ request = Class.new(Gem::Request) {
def self.get_cert_files
[TestGemRequest::PUBLIC_CERT_FILE]
end
- end.create_with_proxy URI('https://example'), nil, nil, nil
+ }.create_with_proxy URI('https://example'), nil, nil, nil
Gem::Request.configure_connection_for_https connection, request.cert_files
@@ -261,7 +246,7 @@ class TestGemRequest < Gem::TestCase
def test_user_agent_engine
util_save_version
- Object.send :remove_const, :RUBY_ENGINE
+ Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
Object.send :const_set, :RUBY_ENGINE, 'vroom'
ua = make_request(@uri, nil, nil, nil).user_agent
@@ -274,7 +259,7 @@ class TestGemRequest < Gem::TestCase
def test_user_agent_engine_ruby
util_save_version
- Object.send :remove_const, :RUBY_ENGINE
+ Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
Object.send :const_set, :RUBY_ENGINE, 'ruby'
ua = make_request(@uri, nil, nil, nil).user_agent
@@ -328,7 +313,6 @@ class TestGemRequest < Gem::TestCase
end
def test_verify_certificate
- skip if Gem.java_platform?
store = OpenSSL::X509::Store.new
context = OpenSSL::X509::StoreContext.new store
context.error = OpenSSL::X509::V_ERR_OUT_OF_MEM
@@ -342,7 +326,6 @@ class TestGemRequest < Gem::TestCase
end
def test_verify_certificate_extra_message
- skip if Gem.java_platform?
store = OpenSSL::X509::Store.new
context = OpenSSL::X509::StoreContext.new store
context.error = OpenSSL::X509::V_ERR_INVALID_CA
@@ -455,12 +438,12 @@ ERROR: Certificate is an invalid CA certificate
message =
Gem::Request.verify_certificate_message error_number, EXPIRED_CERT
- assert_equal "Cannot verify certificate issued by #{EXPIRED_CERT.issuer}",
+ assert_equal "You must add #{EXPIRED_CERT.issuer} to your local trusted store",
message
end
def util_restore_version
- Object.send :remove_const, :RUBY_ENGINE
+ Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
Object.send :const_set, :RUBY_ENGINE, @orig_RUBY_ENGINE if
defined?(@orig_RUBY_ENGINE)
@@ -473,12 +456,12 @@ ERROR: Certificate is an invalid CA certificate
end
def util_save_version
- @orig_RUBY_ENGINE = RUBY_ENGINE
+ @orig_RUBY_ENGINE = RUBY_ENGINE if defined? RUBY_ENGINE
@orig_RUBY_PATCHLEVEL = RUBY_PATCHLEVEL
@orig_RUBY_REVISION = RUBY_REVISION if defined? RUBY_REVISION
end
- def util_stub_net_http(hash)
+ def util_stub_net_http hash
old_client = Gem::Request::ConnectionPools.client
conn = Conn.new OpenStruct.new(hash)
Gem::Request::ConnectionPools.client = conn
@@ -488,10 +471,9 @@ ERROR: Certificate is an invalid CA certificate
end
class Conn
-
attr_accessor :payload
- def new(*args); self; end
+ def new *args; self; end
def use_ssl=(bool); end
def verify_callback=(setting); end
def verify_mode=(setting); end
@@ -507,7 +489,7 @@ ERROR: Certificate is an invalid CA certificate
self.payload = req
@response
end
-
end
-end if defined?(OpenSSL::SSL)
+end
+
diff --git a/test/rubygems/test_gem_request_connection_pools.rb b/test/rubygems/test_gem_request_connection_pools.rb
index f8d2095167..a087095a53 100644
--- a/test/rubygems/test_gem_request_connection_pools.rb
+++ b/test/rubygems/test_gem_request_connection_pools.rb
@@ -4,15 +4,12 @@ require 'rubygems/request'
require 'timeout'
class TestGemRequestConnectionPool < Gem::TestCase
-
class FakeHttp
-
- def initialize(*args)
+ def initialize *args
end
def start
end
-
end
def setup
@@ -28,28 +25,6 @@ class TestGemRequestConnectionPool < Gem::TestCase
super
end
- def test_to_proxy_substring
- pools = Gem::Request::ConnectionPools.new nil, []
-
- env_no_proxy = %w[
- ems.example
- ]
-
- no_proxy = pools.send :no_proxy?, 'rubygems.example', env_no_proxy
-
- refute no_proxy, 'mismatch'
- end
-
- def test_to_proxy_empty_string
- pools = Gem::Request::ConnectionPools.new nil, []
-
- env_no_proxy = [""]
-
- no_proxy = pools.send :no_proxy?, 'ems.example', env_no_proxy
-
- refute no_proxy, 'mismatch'
- end
-
def test_checkout_same_connection
uri = URI.parse('http://example/some_endpoint')
@@ -111,7 +86,8 @@ class TestGemRequestConnectionPool < Gem::TestCase
net_http_args = pools.send :net_http_args, URI('http://[::1]'), nil
- assert_equal ["::1", 80], net_http_args
+ expected_host = RUBY_VERSION >= "1.9.3" ? "::1" : "[::1]"
+ assert_equal [expected_host, 80], net_http_args
end
def test_net_http_args_proxy
@@ -142,13 +118,12 @@ class TestGemRequestConnectionPool < Gem::TestCase
pool.checkout
- Thread.new do
+ Thread.new {
assert_raises(Timeout::Error) do
Timeout.timeout(1) do
pool.checkout
end
end
- end.join
+ }.join
end
-
end
diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb
index fb71829471..5dc6c1518d 100644
--- a/test/rubygems/test_gem_request_set.rb
+++ b/test/rubygems/test_gem_request_set.rb
@@ -3,7 +3,6 @@ require 'rubygems/test_case'
require 'rubygems/request_set'
class TestGemRequestSet < Gem::TestCase
-
def setup
super
@@ -183,58 +182,6 @@ DEPENDENCIES
assert_path_exists File.join @gemhome, 'specifications', 'b-1.gemspec'
end
- def test_install_from_gemdeps_complex_dependencies
- quick_gem("z", 1)
- quick_gem("z", "1.0.1")
- quick_gem("z", "1.0.2")
- quick_gem("z", "1.0.3")
- quick_gem("z", 2)
-
- spec_fetcher do |fetcher|
- fetcher.download "z", 1
- end
-
- rs = Gem::RequestSet.new
- installed = []
-
- File.open 'Gemfile.lock', 'w' do |io|
- io.puts <<-LOCKFILE
-GEM
- remote: #{@gem_repo}
- specs:
- z (1)
-
-PLATFORMS
- #{Gem::Platform::RUBY}
-
-DEPENDENCIES
- z (~> 1.0, >= 1.0.1)
- LOCKFILE
- end
-
- File.open 'testo.gemspec', 'w' do |io|
- io.puts <<-LOCKFILE
-Gem::Specification.new do |spec|
- spec.name = 'testo'
- spec.version = '1.0.0'
- spec.add_dependency('z', '~> 1.0', '>= 1.0.1')
-end
- LOCKFILE
- end
-
- File.open 'Gemfile', 'w' do |io|
- io.puts("gemspec")
- end
-
- rs.install_from_gemdeps :gemdeps => 'Gemfile' do |req, installer|
- installed << req.full_name
- end
-
- assert_includes installed, 'z-1.0.3'
-
- assert_path_exists File.join @gemhome, 'specifications', 'z-1.0.3.gemspec'
- end
-
def test_install_from_gemdeps_version_mismatch
spec_fetcher do |fetcher|
fetcher.gem 'a', 2
@@ -271,7 +218,7 @@ ruby "0"
assert_kind_of Gem::RequestSet::GemDependencyAPI, gem_deps
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
assert_equal [dep('a')], rs.dependencies
@@ -292,7 +239,7 @@ ruby "0"
assert_kind_of Gem::RequestSet::GemDependencyAPI, gem_deps
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
assert_equal [dep('a')], rs.dependencies
end
@@ -307,7 +254,7 @@ ruby "0"
rs.load_gemdeps io.path, [:test]
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
assert_empty rs.dependencies
end
@@ -364,14 +311,8 @@ ruby "0"
end
def test_resolve_development_shallow
- a = util_spec 'a', 1 do |s|
- s.add_development_dependency 'b'
- end
-
- b = util_spec 'b', 1 do |s|
- s.add_development_dependency 'c'
- end
-
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
c = util_spec 'c', 1
a_spec = Gem::Resolver::SpecSpecification.new nil, a
@@ -405,7 +346,7 @@ ruby "0"
rs.load_gemdeps io.path
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
res = rs.resolve
assert_equal 1, res.size
@@ -469,7 +410,7 @@ ruby "0"
rs.load_gemdeps io.path
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
res = rs.resolve
assert_equal 2, res.size
@@ -587,14 +528,8 @@ ruby "0"
end
def test_sorted_requests_development_shallow
- a = util_spec 'a', 1 do |s|
- s.add_development_dependency 'b'
- end
-
- b = util_spec 'b', 1 do |s|
- s.add_development_dependency 'c'
- end
-
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
c = util_spec 'c', 1
rs = Gem::RequestSet.new
@@ -612,14 +547,8 @@ ruby "0"
end
def test_tsort_each_child_development
- a = util_spec 'a', 1 do |s|
- s.add_development_dependency 'b'
- end
-
- b = util_spec 'b', 1 do |s|
- s.add_development_dependency 'c'
- end
-
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
c = util_spec 'c', 1
rs = Gem::RequestSet.new
@@ -641,14 +570,8 @@ ruby "0"
end
def test_tsort_each_child_development_shallow
- a = util_spec 'a', 1 do |s|
- s.add_development_dependency 'b'
- end
-
- b = util_spec 'b', 1 do |s|
- s.add_development_dependency 'c'
- end
-
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
c = util_spec 'c', 1
rs = Gem::RequestSet.new
diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
index f3d4c6fc72..e8bb1d4a6d 100644
--- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb
+++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
@@ -19,29 +19,36 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.instance_variable_set :@vendor_set, @vendor_set
end
- def with_engine_version(name, version)
- engine = RUBY_ENGINE
- engine_version = RUBY_ENGINE_VERSION
+ def with_engine_version name, version
+ engine = RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE
+ engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"
+ engine_version = Object.const_get engine_version_const
- Object.send :remove_const, :RUBY_ENGINE
- Object.send :remove_const, :RUBY_ENGINE_VERSION
+ Object.send :remove_const, :RUBY_ENGINE if engine
+ Object.send :remove_const, engine_version_const if name == 'ruby' and
+ Object.const_defined? engine_version_const
- Object.const_set :RUBY_ENGINE, name if name
- Object.const_set :RUBY_ENGINE_VERSION, version if version
+ new_engine_version_const = "#{name.upcase}_VERSION"
+ Object.const_set :RUBY_ENGINE, name if name
+ Object.const_set new_engine_version_const, version if version
Gem.instance_variable_set :@ruby_version, Gem::Version.new(version)
- begin
- yield
- ensure
- Object.send :remove_const, :RUBY_ENGINE if name
- Object.send :remove_const, :RUBY_ENGINE_VERSION if version
+ yield
- Object.const_set :RUBY_ENGINE, engine
- Object.const_set :RUBY_ENGINE_VERSION, engine_version
+ ensure
+ Object.send :remove_const, :RUBY_ENGINE if name
+ Object.send :remove_const, new_engine_version_const if version
- Gem.send :remove_instance_variable, :@ruby_version
- end
+ Object.send :remove_const, engine_version_const if name == 'ruby' and
+ Object.const_defined? engine_version_const
+
+ Object.const_set :RUBY_ENGINE, engine if engine
+ Object.const_set engine_version_const, engine_version unless
+ Object.const_defined? engine_version_const
+
+ Gem.send :remove_instance_variable, :@ruby_version if
+ Gem.instance_variables.include? :@ruby_version
end
def test_gempspec_with_multiple_runtime_deps
@@ -276,14 +283,6 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
refute_empty set.dependencies
end
- with_engine_version 'truffleruby', '2.0.0' do
- set = Gem::RequestSet.new
- gda = @GDA.new set, 'gem.deps.rb'
- gda.gem 'a', :platforms => :ruby
-
- refute_empty set.dependencies
- end
-
with_engine_version 'jruby', '1.7.6' do
set = Gem::RequestSet.new
gda = @GDA.new set, 'gem.deps.rb'
@@ -311,12 +310,6 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_empty @set.dependencies
end
-
- with_engine_version 'truffleruby', '1.2.3' do
- @gda.gem 'a', :platforms => :mri
-
- assert_empty @set.dependencies
- end
end
def test_gem_platforms_maglev
@@ -339,22 +332,6 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
Gem.win_platform = win_platform
end
- def test_gem_platforms_truffleruby
- with_engine_version 'truffleruby', '1.0.0' do
- set = Gem::RequestSet.new
- gda = @GDA.new set, 'gem.deps.rb'
- gda.gem 'a', :platforms => :truffleruby
-
- refute_empty set.dependencies
-
- set = Gem::RequestSet.new
- gda = @GDA.new set, 'gem.deps.rb'
- gda.gem 'a', :platforms => :maglev
-
- assert_empty set.dependencies
- end
- end
-
def test_gem_platforms_multiple
win_platform, Gem.win_platform = Gem.win_platform?, false
@@ -650,7 +627,11 @@ end
assert_equal [dep('a'), dep('b')], @set.dependencies
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
+ end
+
+ def test_name_typo
+ assert_same @GDA, Gem::RequestSet::GemDepedencyAPI
end
def test_pin_gem_source
@@ -675,23 +656,20 @@ end
end
def test_platform_mswin
- if win_platform?
- util_set_arch 'x86-mswin32-60' do
- @gda.platform :mswin do
- @gda.gem 'a'
- end
-
- assert_equal [dep('a')], @set.dependencies
- refute_empty @set.dependencies
+ util_set_arch 'i686-darwin8.10.1' do
+ @gda.platform :mswin do
+ @gda.gem 'a'
end
- else
- util_set_arch 'i686-darwin8.10.1' do
- @gda.platform :mswin do
- @gda.gem 'a'
- end
- assert_empty @set.dependencies
+ assert_empty @set.dependencies
+ end
+
+ util_set_arch 'x86-mswin32-60' do
+ @gda.platform :mswin do
+ @gda.gem 'a'
end
+
+ refute_empty @set.dependencies
end
end
@@ -734,20 +712,26 @@ end
end
def test_platforms
- unless win_platform?
- util_set_arch 'i686-darwin8.10.1' do
- @gda.platforms :ruby do
- @gda.gem 'a'
- end
+ util_set_arch 'i686-darwin8.10.1' do
+ @gda.platforms :ruby do
+ @gda.gem 'a'
+ end
+
+ assert_equal [dep('a')], @set.dependencies
- assert_equal [dep('a')], @set.dependencies
+ @gda.platforms :mswin do
+ @gda.gem 'b'
+ end
- @gda.platforms :mswin do
- @gda.gem 'b'
- end
+ assert_equal [dep('a')], @set.dependencies
+ end
- assert_equal [dep('a')], @set.dependencies
+ util_set_arch 'x86-mswin32-60' do
+ @gda.platforms :mswin do
+ @gda.gem 'c'
end
+
+ assert_equal [dep('a'), dep('c')], @set.dependencies
end
end
@@ -761,12 +745,6 @@ end
:engine => 'jruby', :engine_version => '1.7.6'
end
-
- with_engine_version 'truffleruby', '1.0.0-rc11' do
- assert @gda.ruby RUBY_VERSION,
- :engine => 'truffleruby', :engine_version => '1.0.0-rc11'
-
- end
end
def test_ruby_engine_mismatch_engine
@@ -830,20 +808,24 @@ end
def test_with_engine_version
version = RUBY_VERSION
- engine = Gem.ruby_engine
- engine_version = RUBY_ENGINE_VERSION
+ engine = Gem.ruby_engine
+
+ engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"
+ engine_version = Object.const_get engine_version_const
with_engine_version 'other', '1.2.3' do
assert_equal 'other', Gem.ruby_engine
- assert_equal '1.2.3', RUBY_ENGINE_VERSION
+ assert_equal '1.2.3', OTHER_VERSION
- assert_equal version, RUBY_VERSION
+ assert_equal version, RUBY_VERSION if engine
end
assert_equal version, RUBY_VERSION
assert_equal engine, Gem.ruby_engine
- assert_equal engine_version, RUBY_ENGINE_VERSION if engine
+ assert_equal engine_version, Object.const_get(engine_version_const) if
+ engine
end
-end unless Gem.java_platform?
+end
+
diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb
index 7c5e256a2d..7460b7efad 100644
--- a/test/rubygems/test_gem_request_set_lockfile.rb
+++ b/test/rubygems/test_gem_request_set_lockfile.rb
@@ -21,13 +21,14 @@ class TestGemRequestSetLockfile < Gem::TestCase
@set.instance_variable_set :@vendor_set, @vendor_set
@gem_deps_file = 'gem.deps.rb'
+
end
def lockfile
Gem::RequestSet::Lockfile.build @set, @gem_deps_file
end
- def write_lockfile(lockfile)
+ def write_lockfile lockfile
@lock_file = File.expand_path "#{@gem_deps_file}.lock"
File.open @lock_file, 'w' do |io|
@@ -466,5 +467,4 @@ DEPENDENCIES
assert_equal 'hello', File.read(gem_deps_lock_file)
end
-
end
diff --git a/test/rubygems/test_gem_request_set_lockfile_parser.rb b/test/rubygems/test_gem_request_set_lockfile_parser.rb
index 7fc93c36e5..f3517da43a 100644
--- a/test/rubygems/test_gem_request_set_lockfile_parser.rb
+++ b/test/rubygems/test_gem_request_set_lockfile_parser.rb
@@ -6,7 +6,6 @@ require 'rubygems/request_set/lockfile/tokenizer'
require 'rubygems/request_set/lockfile/parser'
class TestGemRequestSetLockfileParser < Gem::TestCase
-
def setup
super
@gem_deps_file = 'gem.deps.rb'
@@ -67,6 +66,7 @@ class TestGemRequestSetLockfileParser < Gem::TestCase
assert_equal File.expand_path("#{@gem_deps_file}.lock"), e.path
end
+
def test_parse
write_lockfile <<-LOCKFILE.strip
GEM
@@ -248,8 +248,13 @@ DEPENDENCIES
assert_equal %w[a-2], lockfile_set.specs.map { |s| s.full_name }
- assert_equal %w[https://gems.example/ https://other.example/],
- lockfile_set.specs.flat_map { |s| s.sources.map{ |src| src.uri.to_s } }
+ if [].respond_to? :flat_map
+ assert_equal %w[https://gems.example/ https://other.example/],
+ lockfile_set.specs.flat_map { |s| s.sources.map{ |src| src.uri.to_s } }
+ else # FIXME: remove when 1.8 is dropped
+ assert_equal %w[https://gems.example/ https://other.example/],
+ lockfile_set.specs.map { |s| s.sources.map{ |src| src.uri.to_s } }.flatten(1)
+ end
end
def test_parse_GIT
@@ -530,16 +535,15 @@ DEPENDENCIES
refute lockfile_set
end
- def write_lockfile(lockfile)
+ def write_lockfile lockfile
File.open @lock_file, 'w' do |io|
io.write lockfile
end
end
- def parse_lockfile(set, platforms)
+ def parse_lockfile set, platforms
tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file @lock_file
parser = tokenizer.make_parser set, platforms
parser.parse
end
-
end
diff --git a/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb b/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb
index aa91fc4468..f4aba6d94a 100644
--- a/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb
+++ b/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb
@@ -6,7 +6,6 @@ require 'rubygems/request_set/lockfile/tokenizer'
require 'rubygems/request_set/lockfile/parser'
class TestGemRequestSetLockfileTokenizer < Gem::TestCase
-
def setup
super
@@ -295,7 +294,7 @@ GEM
assert_equal :token, parser.get
end
- def write_lockfile(lockfile)
+ def write_lockfile lockfile
File.open @lock_file, 'w' do |io|
io.write lockfile
end
@@ -304,5 +303,4 @@ GEM
def tokenize_lockfile
Gem::RequestSet::Lockfile::Tokenizer.from_file(@lock_file).to_a
end
-
end
diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
index 3db393e978..ea354f7b1d 100644
--- a/test/rubygems/test_gem_requirement.rb
+++ b/test/rubygems/test_gem_requirement.rb
@@ -20,12 +20,6 @@ class TestGemRequirement < Gem::TestCase
refute_requirement_equal "= 1.2", "= 1.3"
refute_requirement_equal "= 1.3", "= 1.2"
- refute_requirement_equal "~> 1.3", "~> 1.3.0"
- refute_requirement_equal "~> 1.3.0", "~> 1.3"
-
- assert_requirement_equal ["> 2", "~> 1.3"], ["> 2.0", "~> 1.3"]
- assert_requirement_equal ["> 2.0", "~> 1.3"], ["> 2", "~> 1.3"]
-
refute_equal Object.new, req("= 1.2")
refute_equal req("= 1.2"), Object.new
end
@@ -34,7 +28,6 @@ class TestGemRequirement < Gem::TestCase
assert_requirement_equal "= 2", "2"
assert_requirement_equal "= 2", ["2"]
assert_requirement_equal "= 2", v(2)
- assert_requirement_equal "2.0", "2"
end
def test_create
@@ -76,7 +69,6 @@ class TestGemRequirement < Gem::TestCase
assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse('= 1')
assert_equal ['>', Gem::Version.new(1)], Gem::Requirement.parse('> 1')
assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse("=\n1")
- assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse('1.0')
assert_equal ['=', Gem::Version.new(2)],
Gem::Requirement.parse(Gem::Version.new('2'))
@@ -234,8 +226,6 @@ class TestGemRequirement < Gem::TestCase
assert_satisfied_by "0.2.33", "= 0.2.33"
assert_satisfied_by "0.2.34", "> 0.2.33"
assert_satisfied_by "1.0", "= 1.0"
- assert_satisfied_by "1.0.0", "= 1.0"
- assert_satisfied_by "1.0", "= 1.0.0"
assert_satisfied_by "1.0", "1.0"
assert_satisfied_by "1.8.2", "> 1.8.0"
assert_satisfied_by "1.112", "> 1.111"
@@ -265,12 +255,6 @@ class TestGemRequirement < Gem::TestCase
assert_satisfied_by "3.0.rc2", "< 3.0.1"
assert_satisfied_by "3.0.rc2", "> 0"
-
- assert_satisfied_by "5.0.0.rc2", "~> 5.a"
- refute_satisfied_by "5.0.0.rc2", "~> 5.x"
-
- assert_satisfied_by "5.0.0", "~> 5.a"
- assert_satisfied_by "5.0.0", "~> 5.x"
end
def test_illformed_requirements
@@ -329,7 +313,6 @@ class TestGemRequirement < Gem::TestCase
def test_satisfied_by_boxed
refute_satisfied_by "1.3", "~> 1.4"
assert_satisfied_by "1.4", "~> 1.4"
- assert_satisfied_by "1.4.0", "~> 1.4"
assert_satisfied_by "1.5", "~> 1.4"
refute_satisfied_by "2.0", "~> 1.4"
@@ -341,20 +324,6 @@ class TestGemRequirement < Gem::TestCase
refute_satisfied_by "2.0", "~> 1.4.4"
end
- def test_satisfied_by_explicitly_bounded
- req = [">= 1.4.4", "< 1.5"]
-
- assert_satisfied_by "1.4.5", req
- assert_satisfied_by "1.5.0.rc1", req
- refute_satisfied_by "1.5.0", req
-
- req = [">= 1.4.4", "< 1.5.a"]
-
- assert_satisfied_by "1.4.5", req
- refute_satisfied_by "1.5.0.rc1", req
- refute_satisfied_by "1.5.0", req
- end
-
def test_specific
refute req('> 1') .specific?
refute req('>= 1').specific?
@@ -398,28 +367,27 @@ class TestGemRequirement < Gem::TestCase
# Assert that two requirements are equal. Handles Gem::Requirements,
# strings, arrays, numbers, and versions.
- def assert_requirement_equal(expected, actual)
+ def assert_requirement_equal expected, actual
assert_equal req(expected), req(actual)
end
# Assert that +version+ satisfies +requirement+.
- def assert_satisfied_by(version, requirement)
+ def assert_satisfied_by version, requirement
assert req(requirement).satisfied_by?(v(version)),
"#{requirement} is satisfied by #{version}"
end
# Refute the assumption that two requirements are equal.
- def refute_requirement_equal(unexpected, actual)
+ def refute_requirement_equal unexpected, actual
refute_equal req(unexpected), req(actual)
end
# Refute the assumption that +version+ satisfies +requirement+.
- def refute_satisfied_by(version, requirement)
+ def refute_satisfied_by version, requirement
refute req(requirement).satisfied_by?(v(version)),
"#{requirement} is not satisfied by #{version}"
end
-
end
diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb
index c35a264741..417f0580f7 100644
--- a/test/rubygems/test_gem_resolver.rb
+++ b/test/rubygems/test_gem_resolver.rb
@@ -23,7 +23,7 @@ class TestGemResolver < Gem::TestCase
StaticSet.new(specs)
end
- def assert_resolves_to(expected, resolver)
+ def assert_resolves_to expected, resolver
actual = resolver.resolve
exp = expected.sort_by { |s| s.full_name }
@@ -36,6 +36,10 @@ class TestGemResolver < Gem::TestCase
flunk e.message
end
+ def test_self_compatibility
+ assert_same Gem::Resolver, Gem::DependencyResolver
+ end
+
def test_self_compose_sets_best_set
best_set = @DR::BestSet.new
@@ -71,7 +75,7 @@ class TestGemResolver < Gem::TestCase
end
def test_self_compose_sets_nil
- index_set = @DR::IndexSet.new
+ index_set = @DR::IndexSet.new
composed = @DR.compose_sets index_set, nil
@@ -85,7 +89,7 @@ class TestGemResolver < Gem::TestCase
end
def test_self_compose_sets_single
- index_set = @DR::IndexSet.new
+ index_set = @DR::IndexSet.new
composed = @DR.compose_sets index_set
@@ -97,7 +101,7 @@ class TestGemResolver < Gem::TestCase
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
- act = Gem::Resolver::ActivationRequest.new a1, r1
+ act = Gem::Resolver::ActivationRequest.new a1, r1, false
res = Gem::Resolver.new [a1]
@@ -118,7 +122,7 @@ class TestGemResolver < Gem::TestCase
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
- act = Gem::Resolver::ActivationRequest.new spec, r1
+ act = Gem::Resolver::ActivationRequest.new spec, r1, false
res = Gem::Resolver.new [act]
res.development = true
@@ -137,7 +141,7 @@ class TestGemResolver < Gem::TestCase
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
- act = Gem::Resolver::ActivationRequest.new a1, r1
+ act = Gem::Resolver::ActivationRequest.new a1, r1, false
res = Gem::Resolver.new [a1]
res.ignore_dependencies = true
@@ -151,31 +155,16 @@ class TestGemResolver < Gem::TestCase
def test_resolve_conservative
a1_spec = util_spec 'a', 1
-
a2_spec = util_spec 'a', 2 do |s|
s.add_dependency 'b', 2
s.add_dependency 'c'
end
-
b1_spec = util_spec 'b', 1
b2_spec = util_spec 'b', 2
-
- c1_spec = util_spec 'c', 1 do |s|
- s.add_dependency 'd', 2
- end
-
- c2_spec = util_spec 'c', 2 do |s|
- s.add_dependency 'd', 2
- end
-
- d1_spec = util_spec 'd', 1 do |s|
- s.add_dependency 'e'
- end
-
- d2_spec = util_spec 'd', 2 do |s|
- s.add_dependency 'e'
- end
-
+ c1_spec = util_spec 'c', 1 do |s| s.add_dependency 'd', 2 end
+ c2_spec = util_spec 'c', 2 do |s| s.add_dependency 'd', 2 end
+ d1_spec = util_spec 'd', 1 do |s| s.add_dependency 'e' end
+ d2_spec = util_spec 'd', 2 do |s| s.add_dependency 'e' end
e1_spec = util_spec 'e', 1
e2_spec = util_spec 'e', 2
@@ -192,7 +181,7 @@ class TestGemResolver < Gem::TestCase
# With the following gems already installed:
# a-1, b-1, c-1, e-1
- res.skip_gems = {'a' => [a1_spec], 'b' => [b1_spec], 'c' => [c1_spec], 'e' => [e1_spec]}
+ res.skip_gems = {'a'=>[a1_spec], 'b'=>[b1_spec], 'c'=>[c1_spec], 'e'=>[e1_spec]}
# Make sure the following gems end up getting used/installed/upgraded:
# a-2 (upgraded)
@@ -204,14 +193,8 @@ class TestGemResolver < Gem::TestCase
end
def test_resolve_development
- a_spec = util_spec 'a', 1 do |s|
- s.add_development_dependency 'b'
- end
-
- b_spec = util_spec 'b', 1 do
- |s| s.add_development_dependency 'c'
- end
-
+ a_spec = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b_spec = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
c_spec = util_spec 'c', 1
a_dep = make_dep 'a', '= 1'
@@ -233,16 +216,10 @@ class TestGemResolver < Gem::TestCase
s.add_runtime_dependency 'd'
end
- b_spec = util_spec 'b', 1 do |s|
- s.add_development_dependency 'c'
- end
-
+ b_spec = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
c_spec = util_spec 'c', 1
- d_spec = util_spec 'd', 1 do |s|
- s.add_development_dependency 'e'
- end
-
+ d_spec = util_spec 'd', 1 do |s| s.add_development_dependency 'e' end
e_spec = util_spec 'e', 1
a_dep = make_dep 'a', '= 1'
@@ -326,15 +303,9 @@ class TestGemResolver < Gem::TestCase
a2_p1 = a3_p2 = nil
spec_fetcher do |fetcher|
- fetcher.spec 'a', 2
-
- a2_p1 = fetcher.spec 'a', 2 do |s|
- s.platform = Gem::Platform.local
- end
-
- a3_p2 = fetcher.spec 'a', 3 do |s|
- s.platform = unknown
- end
+ fetcher.spec 'a', 2
+ a2_p1 = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
+ a3_p2 = fetcher.spec 'a', 3 do |s| s.platform = unknown end
end
v2 = v(2)
@@ -676,6 +647,7 @@ class TestGemResolver < Gem::TestCase
# activesupport 2.3.5, 2.3.4
# Activemerchant needs activesupport >= 2.3.2. When you require activemerchant, it will activate the latest version that meets that requirement which is 2.3.5. Actionmailer on the other hand needs activesupport = 2.3.4. When rubygems tries to activate activesupport 2.3.4, it will raise an error.
+
def test_simple_activesupport_problem
sup1 = util_spec "activesupport", "2.3.4"
sup2 = util_spec "activesupport", "2.3.5"
@@ -694,12 +666,12 @@ class TestGemResolver < Gem::TestCase
end
def test_second_level_backout
- b1 = util_spec "b", "1", { "c" => ">= 1" }, "lib/b.rb"
- b2 = util_spec "b", "2", { "c" => ">= 2" }, "lib/b.rb"
- c1 = util_spec "c", "1"
- c2 = util_spec "c", "2"
- d1 = util_spec "d", "1", { "c" => "< 2" }, "lib/d.rb"
- d2 = util_spec "d", "2", { "c" => "< 2" }, "lib/d.rb"
+ b1 = new_spec "b", "1", { "c" => ">= 1" }, "lib/b.rb"
+ b2 = new_spec "b", "2", { "c" => ">= 2" }, "lib/b.rb"
+ c1 = new_spec "c", "1"
+ c2 = new_spec "c", "2"
+ d1 = new_spec "d", "1", { "c" => "< 2" }, "lib/d.rb"
+ d2 = new_spec "d", "2", { "c" => "< 2" }, "lib/d.rb"
s = set(b1, b2, c1, c2, d1, d2)
@@ -716,11 +688,11 @@ class TestGemResolver < Gem::TestCase
sourceB = Gem::Source.new 'http://example.com/b'
sourceC = Gem::Source.new 'http://example.com/c'
- spec_A_1 = util_spec 'some-dep', '0.0.1'
- spec_A_2 = util_spec 'some-dep', '1.0.0'
- spec_B_1 = util_spec 'some-dep', '0.0.1'
- spec_B_2 = util_spec 'some-dep', '0.0.2'
- spec_C_1 = util_spec 'some-dep', '0.1.0'
+ spec_A_1 = new_spec 'some-dep', '0.0.1'
+ spec_A_2 = new_spec 'some-dep', '1.0.0'
+ spec_B_1 = new_spec 'some-dep', '0.0.1'
+ spec_B_2 = new_spec 'some-dep', '0.0.2'
+ spec_C_1 = new_spec 'some-dep', '0.1.0'
set = StaticSet.new [
Gem::Resolver::SpecSpecification.new(nil, spec_B_1, sourceB),
@@ -740,15 +712,9 @@ class TestGemResolver < Gem::TestCase
def test_select_local_platforms
r = Gem::Resolver.new nil, nil
- a1 = util_spec 'a', 1
-
- a1_p1 = util_spec 'a', 1 do |s|
- s.platform = Gem::Platform.local
- end
-
- a1_p2 = util_spec 'a', 1 do |s|
- s.platform = 'unknown'
- end
+ a1 = util_spec 'a', 1
+ a1_p1 = util_spec 'a', 1 do |s| s.platform = Gem::Platform.local end
+ a1_p2 = util_spec 'a', 1 do |s| s.platform = 'unknown' end
selected = r.select_local_platforms [a1, a1_p1, a1_p2]
@@ -756,15 +722,9 @@ class TestGemResolver < Gem::TestCase
end
def test_search_for_local_platform_partial_string_match
- a1 = util_spec 'a', 1
-
- a1_p1 = util_spec 'a', 1 do |s|
- s.platform = Gem::Platform.local.os
- end
-
- a1_p2 = util_spec 'a', 1 do |s|
- s.platform = 'unknown'
- end
+ a1 = util_spec 'a', 1
+ a1_p1 = util_spec 'a', 1 do |s| s.platform = Gem::Platform.local.os end
+ a1_p2 = util_spec 'a', 1 do |s| s.platform = 'unknown' end
s = set(a1_p1, a1_p2, a1)
d = [make_dep('a')]
diff --git a/test/rubygems/test_gem_resolver_activation_request.rb b/test/rubygems/test_gem_resolver_activation_request.rb
index dc11ad47c4..ee1b38887a 100644
--- a/test/rubygems/test_gem_resolver_activation_request.rb
+++ b/test/rubygems/test_gem_resolver_activation_request.rb
@@ -13,9 +13,11 @@ class TestGemResolverActivationRequest < Gem::TestCase
source = Gem::Source::Local.new
platform = Gem::Platform::RUBY
+ @a1 = @DR::IndexSpecification.new nil, 'a', v(1), source, platform
+ @a2 = @DR::IndexSpecification.new nil, 'a', v(2), source, platform
@a3 = @DR::IndexSpecification.new nil, 'a', v(3), source, platform
- @req = @DR::ActivationRequest.new @a3, @dep
+ @req = @DR::ActivationRequest.new @a3, @dep, [@a1, @a2]
end
def test_development_eh
@@ -23,7 +25,7 @@ class TestGemResolverActivationRequest < Gem::TestCase
dep_req = @DR::DependencyRequest.new dep('a', '>= 0', :development), nil
- act_req = @DR::ActivationRequest.new @a3, dep_req
+ act_req = @DR::ActivationRequest.new @a3, dep_req, [@a1, @a2]
assert act_req.development?
end
@@ -31,14 +33,42 @@ class TestGemResolverActivationRequest < Gem::TestCase
def test_inspect
assert_match 'a-3', @req.inspect
assert_match 'from a (>= 0)', @req.inspect
+ assert_match '(others possible: a-1, a-2)', @req.inspect
+ end
+
+ def test_inspect_legacy
+ req = @DR::ActivationRequest.new @a3, @dep, true
+
+ assert_match '(others possible)', req.inspect
+
+ req = @DR::ActivationRequest.new @a3, @dep, false
+
+ refute_match '(others possible)', req.inspect
end
def test_installed_eh
v_spec = Gem::Resolver::VendorSpecification.new nil, @a3
- @req = @DR::ActivationRequest.new v_spec, @dep
+ @req = @DR::ActivationRequest.new v_spec, @dep, [@a1, @a2]
assert @req.installed?
end
+ def test_others_possible_eh
+ assert @req.others_possible?
+
+ req = @DR::ActivationRequest.new @a3, @dep, []
+
+ refute req.others_possible?
+
+ req = @DR::ActivationRequest.new @a3, @dep, true
+
+ assert req.others_possible?
+
+ req = @DR::ActivationRequest.new @a3, @dep, false
+
+ refute req.others_possible?
+ end
+
end
+
diff --git a/test/rubygems/test_gem_resolver_api_set.rb b/test/rubygems/test_gem_resolver_api_set.rb
index f6b3e49c74..5746614039 100644
--- a/test/rubygems/test_gem_resolver_api_set.rb
+++ b/test/rubygems/test_gem_resolver_api_set.rb
@@ -206,3 +206,4 @@ class TestGemResolverAPISet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_api_specification.rb b/test/rubygems/test_gem_resolver_api_specification.rb
index 87ff901320..4f198ea395 100644
--- a/test/rubygems/test_gem_resolver_api_specification.rb
+++ b/test/rubygems/test_gem_resolver_api_specification.rb
@@ -141,28 +141,5 @@ class TestGemResolverAPISpecification < Gem::TestCase
assert_equal 'a-1', spec.full_name
end
- def test_spec_jruby_platform
- spec_fetcher do |fetcher|
- fetcher.gem 'j', 1 do |spec|
- spec.platform = 'jruby'
- end
- end
-
- dep_uri = URI(@gem_repo) + 'api/v1/dependencies'
- set = Gem::Resolver::APISet.new dep_uri
- data = {
- :name => 'j',
- :number => '1',
- :platform => 'jruby',
- :dependencies => [],
- }
-
- api_spec = Gem::Resolver::APISpecification.new set, data
-
- spec = api_spec.spec
-
- assert_kind_of Gem::Specification, spec
- assert_equal 'j-1-java', spec.full_name
- end
-
end
+
diff --git a/test/rubygems/test_gem_resolver_best_set.rb b/test/rubygems/test_gem_resolver_best_set.rb
index dc6c9b4c44..556f0e8349 100644
--- a/test/rubygems/test_gem_resolver_best_set.rb
+++ b/test/rubygems/test_gem_resolver_best_set.rb
@@ -135,3 +135,4 @@ class TestGemResolverBestSet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_composed_set.rb b/test/rubygems/test_gem_resolver_composed_set.rb
index 0e745433a9..f1c2da0454 100644
--- a/test/rubygems/test_gem_resolver_composed_set.rb
+++ b/test/rubygems/test_gem_resolver_composed_set.rb
@@ -43,3 +43,4 @@ class TestGemResolverComposedSet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_conflict.rb b/test/rubygems/test_gem_resolver_conflict.rb
index 2385c3eee9..d4b3455570 100644
--- a/test/rubygems/test_gem_resolver_conflict.rb
+++ b/test/rubygems/test_gem_resolver_conflict.rb
@@ -3,6 +3,10 @@ require 'rubygems/test_case'
class TestGemResolverConflict < Gem::TestCase
+ def test_self_compatibility
+ assert_same Gem::Resolver::Conflict, Gem::Resolver::DependencyConflict
+ end
+
def test_explanation
root =
dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8'
@@ -81,3 +85,4 @@ class TestGemResolverConflict < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_dependency_request.rb b/test/rubygems/test_gem_resolver_dependency_request.rb
index 51f0be9dcd..ac8f48a526 100644
--- a/test/rubygems/test_gem_resolver_dependency_request.rb
+++ b/test/rubygems/test_gem_resolver_dependency_request.rb
@@ -82,3 +82,4 @@ class TestGemResolverDependencyRequest < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_git_set.rb b/test/rubygems/test_gem_resolver_git_set.rb
index f38859c8b4..b87a80d44e 100644
--- a/test/rubygems/test_gem_resolver_git_set.rb
+++ b/test/rubygems/test_gem_resolver_git_set.rb
@@ -187,3 +187,4 @@ class TestGemResolverGitSet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_git_specification.rb b/test/rubygems/test_gem_resolver_git_specification.rb
index 3391505555..211757eb20 100644
--- a/test/rubygems/test_gem_resolver_git_specification.rb
+++ b/test/rubygems/test_gem_resolver_git_specification.rb
@@ -63,7 +63,6 @@ class TestGemResolverGitSpecification < Gem::TestCase
# functional test for Gem::Ext::Builder
def test_install_extension
- skip if Gem.java_platform?
name, _, repository, = git_gem 'a', 1 do |s|
s.extensions << 'ext/extconf.rb'
end
@@ -112,3 +111,4 @@ class TestGemResolverGitSpecification < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_index_set.rb b/test/rubygems/test_gem_resolver_index_set.rb
index d9a30d0f58..0f18572904 100644
--- a/test/rubygems/test_gem_resolver_index_set.rb
+++ b/test/rubygems/test_gem_resolver_index_set.rb
@@ -87,3 +87,4 @@ class TestGemResolverIndexSet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_index_specification.rb b/test/rubygems/test_gem_resolver_index_specification.rb
index 43e8efd8b6..6565892750 100644
--- a/test/rubygems/test_gem_resolver_index_specification.rb
+++ b/test/rubygems/test_gem_resolver_index_specification.rb
@@ -55,9 +55,7 @@ class TestGemResolverIndexSpecification < Gem::TestCase
def test_spec
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 2
- fetcher.spec 'a', 2 do |s|
- s.platform = Gem::Platform.local
- end
+ fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
end
source = Gem::Source.new @gem_repo
@@ -73,10 +71,7 @@ class TestGemResolverIndexSpecification < Gem::TestCase
end
def test_spec_local
- a_2_p = util_spec 'a', 2 do |s|
- s.platform = Gem::Platform.local
- end
-
+ a_2_p = util_spec 'a', 2 do |s| s.platform = Gem::Platform.local end
Gem::Package.build a_2_p
source = Gem::Source::Local.new
@@ -92,3 +87,4 @@ class TestGemResolverIndexSpecification < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_installed_specification.rb b/test/rubygems/test_gem_resolver_installed_specification.rb
index e9422b75f8..1dfbb054f3 100644
--- a/test/rubygems/test_gem_resolver_installed_specification.rb
+++ b/test/rubygems/test_gem_resolver_installed_specification.rb
@@ -45,4 +45,6 @@ class TestGemResolverInstalledSpecification < Gem::TestCase
assert b_spec.installable_platform?
end
+
end
+
diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb
index 5138743cdf..e8d82d93b7 100644
--- a/test/rubygems/test_gem_resolver_installer_set.rb
+++ b/test/rubygems/test_gem_resolver_installer_set.rb
@@ -25,8 +25,8 @@ class TestGemResolverInstallerSet < Gem::TestCase
end
def test_add_always_install_errors
- @stub_fetcher = Gem::FakeFetcher.new
- Gem::RemoteFetcher.fetcher = @stub_fetcher
+ @fetcher = Gem::FakeFetcher.new
+ Gem::RemoteFetcher.fetcher = @fetcher
set = Gem::Resolver::InstallerSet.new :both
@@ -173,9 +173,7 @@ class TestGemResolverInstallerSet < Gem::TestCase
def test_load_spec
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 2
- fetcher.spec 'a', 2 do |s|
- s.platform = Gem::Platform.local
- end
+ fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
end
source = Gem::Source.new @gem_repo
@@ -199,7 +197,7 @@ class TestGemResolverInstallerSet < Gem::TestCase
def (set.remote_set).prefetch(_)
raise "called"
end
- assert_nil set.prefetch(nil)
+ assert_equal nil, set.prefetch(nil)
end
def test_prerelease_equals
@@ -257,3 +255,4 @@ class TestGemResolverInstallerSet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_local_specification.rb b/test/rubygems/test_gem_resolver_local_specification.rb
index 82598f5188..d04d1ec8b3 100644
--- a/test/rubygems/test_gem_resolver_local_specification.rb
+++ b/test/rubygems/test_gem_resolver_local_specification.rb
@@ -43,3 +43,4 @@ class TestGemResolverLocalSpecification < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_lock_set.rb b/test/rubygems/test_gem_resolver_lock_set.rb
index d5258477d7..969f13fa8b 100644
--- a/test/rubygems/test_gem_resolver_lock_set.rb
+++ b/test/rubygems/test_gem_resolver_lock_set.rb
@@ -61,3 +61,4 @@ class TestGemResolverLockSet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_lock_specification.rb b/test/rubygems/test_gem_resolver_lock_specification.rb
index 7b9b0ac8f7..3105ad65b3 100644
--- a/test/rubygems/test_gem_resolver_lock_specification.rb
+++ b/test/rubygems/test_gem_resolver_lock_specification.rb
@@ -97,3 +97,4 @@ class TestGemResolverLockSpecification < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_requirement_list.rb b/test/rubygems/test_gem_resolver_requirement_list.rb
index 4cbb939199..6361dc32e6 100644
--- a/test/rubygems/test_gem_resolver_requirement_list.rb
+++ b/test/rubygems/test_gem_resolver_requirement_list.rb
@@ -18,3 +18,4 @@ class TestGemResolverRequirementList < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_specification.rb b/test/rubygems/test_gem_resolver_specification.rb
index e663ff1837..50ac7ec3a1 100644
--- a/test/rubygems/test_gem_resolver_specification.rb
+++ b/test/rubygems/test_gem_resolver_specification.rb
@@ -4,16 +4,14 @@ require 'rubygems/test_case'
class TestGemResolverSpecification < Gem::TestCase
class TestSpec < Gem::Resolver::Specification
-
attr_writer :source
attr_reader :spec
- def initialize(spec)
+ def initialize spec
super()
@spec = spec
end
-
end
def test_install
@@ -64,3 +62,4 @@ class TestGemResolverSpecification < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_vendor_set.rb b/test/rubygems/test_gem_resolver_vendor_set.rb
index 3fc79fec16..c5b9ad019f 100644
--- a/test/rubygems/test_gem_resolver_vendor_set.rb
+++ b/test/rubygems/test_gem_resolver_vendor_set.rb
@@ -81,3 +81,4 @@ class TestGemResolverVendorSet < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_resolver_vendor_specification.rb b/test/rubygems/test_gem_resolver_vendor_specification.rb
index 315ce05539..1f9337c3fa 100644
--- a/test/rubygems/test_gem_resolver_vendor_specification.rb
+++ b/test/rubygems/test_gem_resolver_vendor_specification.rb
@@ -81,3 +81,4 @@ class TestGemResolverVendorSpecification < Gem::TestCase
end
end
+
diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb
index 71185dc86e..47010e088c 100644
--- a/test/rubygems/test_gem_security.rb
+++ b/test/rubygems/test_gem_security.rb
@@ -1,15 +1,12 @@
# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems/security'
+require 'rubygems/fix_openssl_warnings' if RUBY_VERSION < "1.9"
-unless defined?(OpenSSL::SSL)
+unless defined?(OpenSSL::SSL) then
warn 'Skipping Gem::Security tests. openssl not found.'
end
-if Gem.java_platform?
- warn 'Skipping Gem::Security tests on jruby.'
-end
-
class TestGemSecurity < Gem::TestCase
CHILD_KEY = load_key 'child'
@@ -284,7 +281,7 @@ class TestGemSecurity < Gem::TestCase
assert_path_exists path
- key_from_file = OpenSSL::PKey::RSA.new File.read(path), passphrase
+ key_from_file = OpenSSL::PKey::RSA.new File.read(path), passphrase
assert_equal key.to_pem, key_from_file.to_pem
end
@@ -311,4 +308,5 @@ class TestGemSecurity < Gem::TestCase
assert_equal key.to_pem, key_from_file.to_pem
end
-end if defined?(OpenSSL::SSL) && !Gem.java_platform?
+end if defined?(OpenSSL::SSL)
+
diff --git a/test/rubygems/test_gem_security_policy.rb b/test/rubygems/test_gem_security_policy.rb
index 8a1676cd3c..170e296a10 100644
--- a/test/rubygems/test_gem_security_policy.rb
+++ b/test/rubygems/test_gem_security_policy.rb
@@ -3,7 +3,7 @@
require 'rubygems/test_case'
-unless defined?(OpenSSL::SSL)
+unless defined?(OpenSSL::SSL) then
warn 'Skipping Gem::Security::Policy tests. openssl not found.'
end
@@ -450,7 +450,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@spec.cert_chain = [PUBLIC_CERT.to_s]
- metadata_gz = Gem::Util.gzip @spec.to_yaml
+ metadata_gz = Gem.gzip @spec.to_yaml
package = Gem::Package.new 'nonexistent.gem'
package.checksums[Gem::Security::DIGEST_NAME] = {}
@@ -473,7 +473,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@spec.cert_chain = [PUBLIC_CERT.to_s]
- metadata_gz = Gem::Util.gzip @spec.to_yaml
+ metadata_gz = Gem.gzip @spec.to_yaml
package = Gem::Package.new 'nonexistent.gem'
package.checksums[Gem::Security::DIGEST_NAME] = {}
@@ -502,7 +502,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@spec.cert_chain = [PUBLIC_CERT.to_s]
- metadata_gz = Gem::Util.gzip @spec.to_yaml
+ metadata_gz = Gem.gzip @spec.to_yaml
package = Gem::Package.new 'nonexistent.gem'
package.checksums[Gem::Security::DIGEST_NAME] = {}
@@ -518,17 +518,17 @@ class TestGemSecurityPolicy < Gem::TestCase
end
end
- def digest(data)
+ def digest data
digester = @digest.new
digester << data
digester
end
- def sign(data, key = PRIVATE_KEY)
+ def sign data, key = PRIVATE_KEY
key.sign @digest.new, data.digest
end
- def dummy_signatures(key = PRIVATE_KEY)
+ def dummy_signatures key = PRIVATE_KEY
data = digest 'hello'
digests = { Gem::Security::DIGEST_NAME => { 0 => data } }
@@ -538,3 +538,4 @@ class TestGemSecurityPolicy < Gem::TestCase
end
end if defined?(OpenSSL::SSL)
+
diff --git a/test/rubygems/test_gem_security_signer.rb b/test/rubygems/test_gem_security_signer.rb
index 08e74e6276..79dfea099d 100644
--- a/test/rubygems/test_gem_security_signer.rb
+++ b/test/rubygems/test_gem_security_signer.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'rubygems/test_case'
-unless defined?(OpenSSL::SSL)
+unless defined?(OpenSSL::SSL) then
warn 'Skipping Gem::Security::Signer tests. openssl not found.'
end
@@ -135,15 +135,12 @@ toqvglr0kdbknSRRjBVLK6tsgr07aLT9gNP7mTW2PA==
def test_sign_expired
signer = Gem::Security::Signer.new PRIVATE_KEY, [EXPIRED_CERT]
- e = assert_raises Gem::Security::Exception do
+ assert_raises Gem::Security::Exception do
signer.sign 'hello'
end
-
- assert_match "certificate /CN=nobody/DC=example not valid after 1970-01-01 00:00:00 UTC", e.message
end
def test_sign_expired_auto_update
- skip if Gem.java_platform?
FileUtils.mkdir_p File.join(Gem.user_home, '.gem'), :mode => 0700
private_key_path = File.join(Gem.user_home, '.gem', 'gem-private_key.pem')
@@ -217,3 +214,4 @@ toqvglr0kdbknSRRjBVLK6tsgr07aLT9gNP7mTW2PA==
end
end if defined?(OpenSSL::SSL)
+
diff --git a/test/rubygems/test_gem_security_trust_dir.rb b/test/rubygems/test_gem_security_trust_dir.rb
index f2b7b006dd..ab02ceb772 100644
--- a/test/rubygems/test_gem_security_trust_dir.rb
+++ b/test/rubygems/test_gem_security_trust_dir.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'rubygems/test_case'
-unless defined?(OpenSSL::SSL)
+unless defined?(OpenSSL::SSL) then
warn 'Skipping Gem::Security::TrustDir tests. openssl not found.'
end
@@ -98,3 +98,4 @@ class TestGemSecurityTrustDir < Gem::TestCase
end
end if defined?(OpenSSL::SSL)
+
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
index ca9ba4bf9c..a583bd7b35